aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs
diff options
context:
space:
mode:
authorAlexander Smirnov <alex@ydb.tech>2025-02-11 11:04:00 +0000
committerAlexander Smirnov <alex@ydb.tech>2025-02-11 11:04:00 +0000
commitbc87977191a2c88fe00dd86be6b94da72559ebbe (patch)
treedd0b714eda032ba015390e9da217fbac78bd87ef /contrib/libs
parent4b90b10cf60b38930d8f17881961b780d00dc73b (diff)
parentf895bba65827952ed934b2b46f9a45e30a191fd2 (diff)
downloadydb-bc87977191a2c88fe00dd86be6b94da72559ebbe.tar.gz
Merge branch 'rightlib' into merge-libs-250211-1102
Diffstat (limited to 'contrib/libs')
-rw-r--r--contrib/libs/android_cpufeatures/cpu-features.h323
-rw-r--r--contrib/libs/freetype/.yandex_meta/__init__.py68
-rw-r--r--contrib/libs/freetype/.yandex_meta/devtools.copyrights.report1407
-rw-r--r--contrib/libs/freetype/.yandex_meta/devtools.licenses.report898
-rw-r--r--contrib/libs/freetype/.yandex_meta/licenses.list.txt3037
-rw-r--r--contrib/libs/freetype/.yandex_meta/override.nix33
-rw-r--r--contrib/libs/freetype/LICENSE.TXT46
-rw-r--r--contrib/libs/freetype/MSBuild.rsp2
-rw-r--r--contrib/libs/freetype/README107
-rw-r--r--contrib/libs/freetype/README.git102
-rw-r--r--contrib/libs/freetype/docs/CHANGES5726
-rw-r--r--contrib/libs/freetype/docs/CMAKE2
-rw-r--r--contrib/libs/freetype/docs/CUSTOMIZE152
-rw-r--r--contrib/libs/freetype/docs/DEBUG310
-rw-r--r--contrib/libs/freetype/docs/DOCGUIDE298
-rw-r--r--contrib/libs/freetype/docs/FTL.TXT169
-rw-r--r--contrib/libs/freetype/docs/GPLv2.TXT340
-rw-r--r--contrib/libs/freetype/docs/INSTALL114
-rw-r--r--contrib/libs/freetype/docs/INSTALL.ANY157
-rw-r--r--contrib/libs/freetype/docs/INSTALL.CROSS177
-rw-r--r--contrib/libs/freetype/docs/INSTALL.GNU181
-rw-r--r--contrib/libs/freetype/docs/INSTALL.MAC32
-rw-r--r--contrib/libs/freetype/docs/INSTALL.UNIX139
-rw-r--r--contrib/libs/freetype/docs/INSTALL.VMS69
-rw-r--r--contrib/libs/freetype/docs/MAKEPP5
-rw-r--r--contrib/libs/freetype/docs/PROBLEMS90
-rw-r--r--contrib/libs/freetype/docs/README33
-rw-r--r--contrib/libs/freetype/docs/TODO40
-rw-r--r--contrib/libs/freetype/docs/VERSIONS.TXT138
-rw-r--r--contrib/libs/freetype/docs/formats.txt223
-rw-r--r--contrib/libs/freetype/docs/freetype-config.1146
-rw-r--r--contrib/libs/freetype/docs/freetype-web.txt42
-rw-r--r--contrib/libs/freetype/docs/raster.txt635
-rw-r--r--contrib/libs/freetype/docs/release224
-rw-r--r--contrib/libs/freetype/include/dlg/dlg.h290
-rw-r--r--contrib/libs/freetype/include/dlg/output.h172
-rw-r--r--contrib/libs/freetype/include/freetype/config/ftconfig.h51
-rw-r--r--contrib/libs/freetype/include/freetype/config/ftheader.h836
-rw-r--r--contrib/libs/freetype/include/freetype/config/ftmodule.h33
-rw-r--r--contrib/libs/freetype/include/freetype/config/ftoption.h1030
-rw-r--r--contrib/libs/freetype/include/freetype/config/ftstdlib.h185
-rw-r--r--contrib/libs/freetype/include/freetype/config/integer-types.h250
-rw-r--r--contrib/libs/freetype/include/freetype/config/mac-support.h49
-rw-r--r--contrib/libs/freetype/include/freetype/config/public-macros.h138
-rw-r--r--contrib/libs/freetype/include/freetype/freetype.h5289
-rw-r--r--contrib/libs/freetype/include/freetype/ftadvanc.h188
-rw-r--r--contrib/libs/freetype/include/freetype/ftbbox.h101
-rw-r--r--contrib/libs/freetype/include/freetype/ftbdf.h212
-rw-r--r--contrib/libs/freetype/include/freetype/ftbitmap.h329
-rw-r--r--contrib/libs/freetype/include/freetype/ftbzip2.h102
-rw-r--r--contrib/libs/freetype/include/freetype/ftcache.h1087
-rw-r--r--contrib/libs/freetype/include/freetype/ftcid.h167
-rw-r--r--contrib/libs/freetype/include/freetype/ftcolor.h1667
-rw-r--r--contrib/libs/freetype/include/freetype/ftdriver.h1320
-rw-r--r--contrib/libs/freetype/include/freetype/fterrdef.h283
-rw-r--r--contrib/libs/freetype/include/freetype/fterrors.h296
-rw-r--r--contrib/libs/freetype/include/freetype/ftfntfmt.h93
-rw-r--r--contrib/libs/freetype/include/freetype/ftgasp.h143
-rw-r--r--contrib/libs/freetype/include/freetype/ftglyph.h750
-rw-r--r--contrib/libs/freetype/include/freetype/ftgxval.h354
-rw-r--r--contrib/libs/freetype/include/freetype/ftgzip.h151
-rw-r--r--contrib/libs/freetype/include/freetype/ftimage.h1289
-rw-r--r--contrib/libs/freetype/include/freetype/ftincrem.h348
-rw-r--r--contrib/libs/freetype/include/freetype/ftlcdfil.h323
-rw-r--r--contrib/libs/freetype/include/freetype/ftlist.h296
-rw-r--r--contrib/libs/freetype/include/freetype/ftlogging.h184
-rw-r--r--contrib/libs/freetype/include/freetype/ftlzw.h100
-rw-r--r--contrib/libs/freetype/include/freetype/ftmac.h289
-rw-r--r--contrib/libs/freetype/include/freetype/ftmm.h834
-rw-r--r--contrib/libs/freetype/include/freetype/ftmodapi.h807
-rw-r--r--contrib/libs/freetype/include/freetype/ftmoderr.h204
-rw-r--r--contrib/libs/freetype/include/freetype/ftotval.h206
-rw-r--r--contrib/libs/freetype/include/freetype/ftoutln.h588
-rw-r--r--contrib/libs/freetype/include/freetype/ftparams.h218
-rw-r--r--contrib/libs/freetype/include/freetype/ftpfr.h179
-rw-r--r--contrib/libs/freetype/include/freetype/ftrender.h244
-rw-r--r--contrib/libs/freetype/include/freetype/ftsizes.h159
-rw-r--r--contrib/libs/freetype/include/freetype/ftsnames.h272
-rw-r--r--contrib/libs/freetype/include/freetype/ftstroke.h773
-rw-r--r--contrib/libs/freetype/include/freetype/ftsynth.h104
-rw-r--r--contrib/libs/freetype/include/freetype/ftsystem.h350
-rw-r--r--contrib/libs/freetype/include/freetype/fttrigon.h350
-rw-r--r--contrib/libs/freetype/include/freetype/fttypes.h617
-rw-r--r--contrib/libs/freetype/include/freetype/ftwinfnt.h276
-rw-r--r--contrib/libs/freetype/include/freetype/internal/autohint.h234
-rw-r--r--contrib/libs/freetype/include/freetype/internal/cffotypes.h107
-rw-r--r--contrib/libs/freetype/include/freetype/internal/cfftypes.h416
-rw-r--r--contrib/libs/freetype/include/freetype/internal/compiler-macros.h343
-rw-r--r--contrib/libs/freetype/include/freetype/internal/ftcalc.h584
-rw-r--r--contrib/libs/freetype/include/freetype/internal/ftdebug.h442
-rw-r--r--contrib/libs/freetype/include/freetype/internal/ftdrv.h289
-rw-r--r--contrib/libs/freetype/include/freetype/internal/ftgloadr.h147
-rw-r--r--contrib/libs/freetype/include/freetype/internal/fthash.h135
-rw-r--r--contrib/libs/freetype/include/freetype/internal/ftmemory.h401
-rw-r--r--contrib/libs/freetype/include/freetype/internal/ftmmtypes.h91
-rw-r--r--contrib/libs/freetype/include/freetype/internal/ftobjs.h1232
-rw-r--r--contrib/libs/freetype/include/freetype/internal/ftpsprop.h47
-rw-r--r--contrib/libs/freetype/include/freetype/internal/ftrfork.h245
-rw-r--r--contrib/libs/freetype/include/freetype/internal/ftserv.h495
-rw-r--r--contrib/libs/freetype/include/freetype/internal/ftstream.h570
-rw-r--r--contrib/libs/freetype/include/freetype/internal/fttrace.h173
-rw-r--r--contrib/libs/freetype/include/freetype/internal/ftvalid.h160
-rw-r--r--contrib/libs/freetype/include/freetype/internal/psaux.h1447
-rw-r--r--contrib/libs/freetype/include/freetype/internal/pshints.h699
-rw-r--r--contrib/libs/freetype/include/freetype/internal/services/svbdf.h66
-rw-r--r--contrib/libs/freetype/include/freetype/internal/services/svcfftl.h90
-rw-r--r--contrib/libs/freetype/include/freetype/internal/services/svcid.h69
-rw-r--r--contrib/libs/freetype/include/freetype/internal/services/svfntfmt.h55
-rw-r--r--contrib/libs/freetype/include/freetype/internal/services/svgldict.h72
-rw-r--r--contrib/libs/freetype/include/freetype/internal/services/svgxval.h72
-rw-r--r--contrib/libs/freetype/include/freetype/internal/services/svkern.h51
-rw-r--r--contrib/libs/freetype/include/freetype/internal/services/svmetric.h131
-rw-r--r--contrib/libs/freetype/include/freetype/internal/services/svmm.h214
-rw-r--r--contrib/libs/freetype/include/freetype/internal/services/svotval.h55
-rw-r--r--contrib/libs/freetype/include/freetype/internal/services/svpfr.h65
-rw-r--r--contrib/libs/freetype/include/freetype/internal/services/svpostnm.h65
-rw-r--r--contrib/libs/freetype/include/freetype/internal/services/svprop.h66
-rw-r--r--contrib/libs/freetype/include/freetype/internal/services/svpscmap.h145
-rw-r--r--contrib/libs/freetype/include/freetype/internal/services/svpsinfo.h86
-rw-r--r--contrib/libs/freetype/include/freetype/internal/services/svsfnt.h88
-rw-r--r--contrib/libs/freetype/include/freetype/internal/services/svttcmap.h90
-rw-r--r--contrib/libs/freetype/include/freetype/internal/services/svtteng.h53
-rw-r--r--contrib/libs/freetype/include/freetype/internal/services/svttglyf.h56
-rw-r--r--contrib/libs/freetype/include/freetype/internal/services/svwinfnt.h50
-rw-r--r--contrib/libs/freetype/include/freetype/internal/sfnt.h1099
-rw-r--r--contrib/libs/freetype/include/freetype/internal/svginterface.h46
-rw-r--r--contrib/libs/freetype/include/freetype/internal/t1types.h307
-rw-r--r--contrib/libs/freetype/include/freetype/internal/tttypes.h1747
-rw-r--r--contrib/libs/freetype/include/freetype/internal/wofftypes.h312
-rw-r--r--contrib/libs/freetype/include/freetype/otsvg.h336
-rw-r--r--contrib/libs/freetype/include/freetype/t1tables.h735
-rw-r--r--contrib/libs/freetype/include/freetype/ttnameid.h1235
-rw-r--r--contrib/libs/freetype/include/freetype/tttables.h856
-rw-r--r--contrib/libs/freetype/include/freetype/tttags.h124
-rw-r--r--contrib/libs/freetype/include/ft2build.h42
-rw-r--r--contrib/libs/freetype/src/autofit/afblue.c779
-rw-r--r--contrib/libs/freetype/src/autofit/afblue.h429
-rw-r--r--contrib/libs/freetype/src/autofit/afcjk.c2383
-rw-r--r--contrib/libs/freetype/src/autofit/afcjk.h141
-rw-r--r--contrib/libs/freetype/src/autofit/afcover.h105
-rw-r--r--contrib/libs/freetype/src/autofit/afdummy.c77
-rw-r--r--contrib/libs/freetype/src/autofit/afdummy.h40
-rw-r--r--contrib/libs/freetype/src/autofit/aferrors.h42
-rw-r--r--contrib/libs/freetype/src/autofit/afglobal.c513
-rw-r--r--contrib/libs/freetype/src/autofit/afglobal.h173
-rw-r--r--contrib/libs/freetype/src/autofit/afhints.c1796
-rw-r--r--contrib/libs/freetype/src/autofit/afhints.h467
-rw-r--r--contrib/libs/freetype/src/autofit/afindic.c157
-rw-r--r--contrib/libs/freetype/src/autofit/afindic.h41
-rw-r--r--contrib/libs/freetype/src/autofit/aflatin.c3643
-rw-r--r--contrib/libs/freetype/src/autofit/aflatin.h194
-rw-r--r--contrib/libs/freetype/src/autofit/afloader.c706
-rw-r--r--contrib/libs/freetype/src/autofit/afloader.h91
-rw-r--r--contrib/libs/freetype/src/autofit/afmodule.c527
-rw-r--r--contrib/libs/freetype/src/autofit/afmodule.h55
-rw-r--r--contrib/libs/freetype/src/autofit/afranges.c1072
-rw-r--r--contrib/libs/freetype/src/autofit/afranges.h47
-rw-r--r--contrib/libs/freetype/src/autofit/afscript.h408
-rw-r--r--contrib/libs/freetype/src/autofit/afshaper.c690
-rw-r--r--contrib/libs/freetype/src/autofit/afshaper.h71
-rw-r--r--contrib/libs/freetype/src/autofit/afstyles.h487
-rw-r--r--contrib/libs/freetype/src/autofit/aftypes.h511
-rw-r--r--contrib/libs/freetype/src/autofit/afws-decl.h33
-rw-r--r--contrib/libs/freetype/src/autofit/afws-iter.h31
-rw-r--r--contrib/libs/freetype/src/autofit/autofit.c35
-rw-r--r--contrib/libs/freetype/src/autofit/ft-hb.c115
-rw-r--r--contrib/libs/freetype/src/base/ftadvanc.c174
-rw-r--r--contrib/libs/freetype/src/base/ftbase.c41
-rw-r--r--contrib/libs/freetype/src/base/ftbase.h82
-rw-r--r--contrib/libs/freetype/src/base/ftbbox.c542
-rw-r--r--contrib/libs/freetype/src/base/ftbdf.c90
-rw-r--r--contrib/libs/freetype/src/base/ftbitmap.c1144
-rw-r--r--contrib/libs/freetype/src/base/ftcalc.c1126
-rw-r--r--contrib/libs/freetype/src/base/ftcid.c117
-rw-r--r--contrib/libs/freetype/src/base/ftcolor.c156
-rw-r--r--contrib/libs/freetype/src/base/ftdbgmem.c971
-rw-r--r--contrib/libs/freetype/src/base/ftdebug.c644
-rw-r--r--contrib/libs/freetype/src/base/fterrors.c45
-rw-r--r--contrib/libs/freetype/src/base/ftfntfmt.c54
-rw-r--r--contrib/libs/freetype/src/base/ftfstype.c61
-rw-r--r--contrib/libs/freetype/src/base/ftgasp.c60
-rw-r--r--contrib/libs/freetype/src/base/ftgloadr.c383
-rw-r--r--contrib/libs/freetype/src/base/ftglyph.c911
-rw-r--r--contrib/libs/freetype/src/base/ftgxval.c141
-rw-r--r--contrib/libs/freetype/src/base/fthash.c338
-rw-r--r--contrib/libs/freetype/src/base/ftinit.c263
-rw-r--r--contrib/libs/freetype/src/base/ftlcdfil.c437
-rw-r--r--contrib/libs/freetype/src/base/ftmac.c1099
-rw-r--r--contrib/libs/freetype/src/base/ftmm.c704
-rw-r--r--contrib/libs/freetype/src/base/ftobjs.c5917
-rw-r--r--contrib/libs/freetype/src/base/ftotval.c90
-rw-r--r--contrib/libs/freetype/src/base/ftoutln.c1120
-rw-r--r--contrib/libs/freetype/src/base/ftpatent.c50
-rw-r--r--contrib/libs/freetype/src/base/ftpfr.c152
-rw-r--r--contrib/libs/freetype/src/base/ftpsprop.c284
-rw-r--r--contrib/libs/freetype/src/base/ftrfork.c934
-rw-r--r--contrib/libs/freetype/src/base/ftsnames.c185
-rw-r--r--contrib/libs/freetype/src/base/ftstream.c872
-rw-r--r--contrib/libs/freetype/src/base/ftstroke.c2403
-rw-r--r--contrib/libs/freetype/src/base/ftsynth.c180
-rw-r--r--contrib/libs/freetype/src/base/ftsystem.c338
-rw-r--r--contrib/libs/freetype/src/base/fttrigon.c517
-rw-r--r--contrib/libs/freetype/src/base/fttype1.c126
-rw-r--r--contrib/libs/freetype/src/base/ftutil.c442
-rw-r--r--contrib/libs/freetype/src/base/ftwinfnt.c52
-rw-r--r--contrib/libs/freetype/src/base/md5.c291
-rw-r--r--contrib/libs/freetype/src/base/md5.h45
-rw-r--r--contrib/libs/freetype/src/bdf/README152
-rw-r--r--contrib/libs/freetype/src/bdf/bdf.c34
-rw-r--r--contrib/libs/freetype/src/bdf/bdf.h253
-rw-r--r--contrib/libs/freetype/src/bdf/bdfdrivr.c1013
-rw-r--r--contrib/libs/freetype/src/bdf/bdfdrivr.h72
-rw-r--r--contrib/libs/freetype/src/bdf/bdferror.h45
-rw-r--r--contrib/libs/freetype/src/bdf/bdflib.c2378
-rw-r--r--contrib/libs/freetype/src/bzip2/ftbzip2.c535
-rw-r--r--contrib/libs/freetype/src/cache/ftcache.c31
-rw-r--r--contrib/libs/freetype/src/cache/ftcbasic.c598
-rw-r--r--contrib/libs/freetype/src/cache/ftccache.c584
-rw-r--r--contrib/libs/freetype/src/cache/ftccache.h359
-rw-r--r--contrib/libs/freetype/src/cache/ftccback.h85
-rw-r--r--contrib/libs/freetype/src/cache/ftccmap.c323
-rw-r--r--contrib/libs/freetype/src/cache/ftcerror.h42
-rw-r--r--contrib/libs/freetype/src/cache/ftcglyph.c204
-rw-r--r--contrib/libs/freetype/src/cache/ftcglyph.h314
-rw-r--r--contrib/libs/freetype/src/cache/ftcimage.c158
-rw-r--r--contrib/libs/freetype/src/cache/ftcimage.h106
-rw-r--r--contrib/libs/freetype/src/cache/ftcmanag.c677
-rw-r--r--contrib/libs/freetype/src/cache/ftcmanag.h175
-rw-r--r--contrib/libs/freetype/src/cache/ftcmru.c341
-rw-r--r--contrib/libs/freetype/src/cache/ftcmru.h242
-rw-r--r--contrib/libs/freetype/src/cache/ftcsbits.c413
-rw-r--r--contrib/libs/freetype/src/cache/ftcsbits.h91
-rw-r--r--contrib/libs/freetype/src/cff/cff.c28
-rw-r--r--contrib/libs/freetype/src/cff/cffcmap.c230
-rw-r--r--contrib/libs/freetype/src/cff/cffcmap.h67
-rw-r--r--contrib/libs/freetype/src/cff/cffdrivr.c1263
-rw-r--r--contrib/libs/freetype/src/cff/cffdrivr.h35
-rw-r--r--contrib/libs/freetype/src/cff/cfferrs.h42
-rw-r--r--contrib/libs/freetype/src/cff/cffgload.c762
-rw-r--r--contrib/libs/freetype/src/cff/cffgload.h62
-rw-r--r--contrib/libs/freetype/src/cff/cffload.c2570
-rw-r--r--contrib/libs/freetype/src/cff/cffload.h124
-rw-r--r--contrib/libs/freetype/src/cff/cffobjs.c1175
-rw-r--r--contrib/libs/freetype/src/cff/cffobjs.h84
-rw-r--r--contrib/libs/freetype/src/cff/cffparse.c1550
-rw-r--r--contrib/libs/freetype/src/cff/cffparse.h144
-rw-r--r--contrib/libs/freetype/src/cff/cfftoken.h150
-rw-r--r--contrib/libs/freetype/src/cid/ciderrs.h41
-rw-r--r--contrib/libs/freetype/src/cid/cidgload.c618
-rw-r--r--contrib/libs/freetype/src/cid/cidgload.h58
-rw-r--r--contrib/libs/freetype/src/cid/cidload.c937
-rw-r--r--contrib/libs/freetype/src/cid/cidload.h52
-rw-r--r--contrib/libs/freetype/src/cid/cidobjs.c543
-rw-r--r--contrib/libs/freetype/src/cid/cidobjs.h154
-rw-r--r--contrib/libs/freetype/src/cid/cidparse.c311
-rw-r--r--contrib/libs/freetype/src/cid/cidparse.h130
-rw-r--r--contrib/libs/freetype/src/cid/cidriver.c274
-rw-r--r--contrib/libs/freetype/src/cid/cidriver.h36
-rw-r--r--contrib/libs/freetype/src/cid/cidtoken.h115
-rw-r--r--contrib/libs/freetype/src/cid/type1cid.c28
-rw-r--r--contrib/libs/freetype/src/dlg/dlg.c803
-rw-r--r--contrib/libs/freetype/src/dlg/dlgwrap.c32
-rw-r--r--contrib/libs/freetype/src/gzip/README.freetype22
-rw-r--r--contrib/libs/freetype/src/gzip/ftgzip.c805
-rw-r--r--contrib/libs/freetype/src/lzw/ftlzw.c415
-rw-r--r--contrib/libs/freetype/src/lzw/ftzopen.c429
-rw-r--r--contrib/libs/freetype/src/lzw/ftzopen.h174
-rw-r--r--contrib/libs/freetype/src/pcf/README96
-rw-r--r--contrib/libs/freetype/src/pcf/pcf.c35
-rw-r--r--contrib/libs/freetype/src/pcf/pcf.h251
-rw-r--r--contrib/libs/freetype/src/pcf/pcfdrivr.c836
-rw-r--r--contrib/libs/freetype/src/pcf/pcfdrivr.h44
-rw-r--r--contrib/libs/freetype/src/pcf/pcferror.h41
-rw-r--r--contrib/libs/freetype/src/pcf/pcfread.c1731
-rw-r--r--contrib/libs/freetype/src/pcf/pcfread.h44
-rw-r--r--contrib/libs/freetype/src/pcf/pcfutil.c119
-rw-r--r--contrib/libs/freetype/src/pcf/pcfutil.h55
-rw-r--r--contrib/libs/freetype/src/pfr/pfr.c29
-rw-r--r--contrib/libs/freetype/src/pfr/pfrcmap.c188
-rw-r--r--contrib/libs/freetype/src/pfr/pfrcmap.h45
-rw-r--r--contrib/libs/freetype/src/pfr/pfrdrivr.c212
-rw-r--r--contrib/libs/freetype/src/pfr/pfrdrivr.h36
-rw-r--r--contrib/libs/freetype/src/pfr/pfrerror.h41
-rw-r--r--contrib/libs/freetype/src/pfr/pfrgload.c849
-rw-r--r--contrib/libs/freetype/src/pfr/pfrgload.h49
-rw-r--r--contrib/libs/freetype/src/pfr/pfrload.c1062
-rw-r--r--contrib/libs/freetype/src/pfr/pfrload.h123
-rw-r--r--contrib/libs/freetype/src/pfr/pfrobjs.c603
-rw-r--r--contrib/libs/freetype/src/pfr/pfrobjs.h96
-rw-r--r--contrib/libs/freetype/src/pfr/pfrsbit.c813
-rw-r--r--contrib/libs/freetype/src/pfr/pfrsbit.h37
-rw-r--r--contrib/libs/freetype/src/pfr/pfrtypes.h331
-rw-r--r--contrib/libs/freetype/src/psaux/afmparse.c1094
-rw-r--r--contrib/libs/freetype/src/psaux/afmparse.h88
-rw-r--r--contrib/libs/freetype/src/psaux/cffdecode.c2411
-rw-r--r--contrib/libs/freetype/src/psaux/cffdecode.h63
-rw-r--r--contrib/libs/freetype/src/psaux/psarrst.c240
-rw-r--r--contrib/libs/freetype/src/psaux/psarrst.h99
-rw-r--r--contrib/libs/freetype/src/psaux/psaux.c40
-rw-r--r--contrib/libs/freetype/src/psaux/psauxerr.h42
-rw-r--r--contrib/libs/freetype/src/psaux/psauxmod.c190
-rw-r--r--contrib/libs/freetype/src/psaux/psauxmod.h60
-rw-r--r--contrib/libs/freetype/src/psaux/psblues.c571
-rw-r--r--contrib/libs/freetype/src/psaux/psblues.h185
-rw-r--r--contrib/libs/freetype/src/psaux/psconv.c610
-rw-r--r--contrib/libs/freetype/src/psaux/psconv.h70
-rw-r--r--contrib/libs/freetype/src/psaux/pserror.c52
-rw-r--r--contrib/libs/freetype/src/psaux/pserror.h120
-rw-r--r--contrib/libs/freetype/src/psaux/psfixed.h94
-rw-r--r--contrib/libs/freetype/src/psaux/psfont.c566
-rw-r--r--contrib/libs/freetype/src/psaux/psfont.h134
-rw-r--r--contrib/libs/freetype/src/psaux/psft.c895
-rw-r--r--contrib/libs/freetype/src/psaux/psft.h167
-rw-r--r--contrib/libs/freetype/src/psaux/psglue.h144
-rw-r--r--contrib/libs/freetype/src/psaux/pshints.c1952
-rw-r--r--contrib/libs/freetype/src/psaux/pshints.h288
-rw-r--r--contrib/libs/freetype/src/psaux/psintrp.c3050
-rw-r--r--contrib/libs/freetype/src/psaux/psintrp.h83
-rw-r--r--contrib/libs/freetype/src/psaux/psobjs.c2560
-rw-r--r--contrib/libs/freetype/src/psaux/psobjs.h312
-rw-r--r--contrib/libs/freetype/src/psaux/psread.c112
-rw-r--r--contrib/libs/freetype/src/psaux/psread.h68
-rw-r--r--contrib/libs/freetype/src/psaux/psstack.c329
-rw-r--r--contrib/libs/freetype/src/psaux/psstack.h122
-rw-r--r--contrib/libs/freetype/src/psaux/pstypes.h77
-rw-r--r--contrib/libs/freetype/src/psaux/t1cmap.c393
-rw-r--r--contrib/libs/freetype/src/psaux/t1cmap.h104
-rw-r--r--contrib/libs/freetype/src/psaux/t1decode.c2159
-rw-r--r--contrib/libs/freetype/src/psaux/t1decode.h73
-rw-r--r--contrib/libs/freetype/src/pshinter/pshalgo.c2191
-rw-r--r--contrib/libs/freetype/src/pshinter/pshalgo.h233
-rw-r--r--contrib/libs/freetype/src/pshinter/pshglob.c795
-rw-r--r--contrib/libs/freetype/src/pshinter/pshglob.h196
-rw-r--r--contrib/libs/freetype/src/pshinter/pshinter.c27
-rw-r--r--contrib/libs/freetype/src/pshinter/pshmod.c125
-rw-r--r--contrib/libs/freetype/src/pshinter/pshmod.h38
-rw-r--r--contrib/libs/freetype/src/pshinter/pshnterr.h41
-rw-r--r--contrib/libs/freetype/src/pshinter/pshrec.c1224
-rw-r--r--contrib/libs/freetype/src/pshinter/pshrec.h171
-rw-r--r--contrib/libs/freetype/src/psnames/psmodule.c621
-rw-r--r--contrib/libs/freetype/src/psnames/psmodule.h37
-rw-r--r--contrib/libs/freetype/src/psnames/psnamerr.h42
-rw-r--r--contrib/libs/freetype/src/psnames/psnames.c24
-rw-r--r--contrib/libs/freetype/src/psnames/pstables.h4238
-rw-r--r--contrib/libs/freetype/src/raster/ftraster.c2738
-rw-r--r--contrib/libs/freetype/src/raster/ftraster.h47
-rw-r--r--contrib/libs/freetype/src/raster/ftrend1.c209
-rw-r--r--contrib/libs/freetype/src/raster/ftrend1.h37
-rw-r--r--contrib/libs/freetype/src/raster/raster.c25
-rw-r--r--contrib/libs/freetype/src/raster/rasterrs.h42
-rw-r--r--contrib/libs/freetype/src/sdf/ftbsdf.c1350
-rw-r--r--contrib/libs/freetype/src/sdf/ftsdf.c3932
-rw-r--r--contrib/libs/freetype/src/sdf/ftsdf.h97
-rw-r--r--contrib/libs/freetype/src/sdf/ftsdfcommon.c104
-rw-r--r--contrib/libs/freetype/src/sdf/ftsdfcommon.h140
-rw-r--r--contrib/libs/freetype/src/sdf/ftsdferrs.h37
-rw-r--r--contrib/libs/freetype/src/sdf/ftsdfrend.c603
-rw-r--r--contrib/libs/freetype/src/sdf/ftsdfrend.h118
-rw-r--r--contrib/libs/freetype/src/sdf/sdf.c29
-rw-r--r--contrib/libs/freetype/src/sfnt/pngshim.c462
-rw-r--r--contrib/libs/freetype/src/sfnt/pngshim.h50
-rw-r--r--contrib/libs/freetype/src/sfnt/sfdriver.c1384
-rw-r--r--contrib/libs/freetype/src/sfnt/sfdriver.h35
-rw-r--r--contrib/libs/freetype/src/sfnt/sferrors.h41
-rw-r--r--contrib/libs/freetype/src/sfnt/sfnt.c41
-rw-r--r--contrib/libs/freetype/src/sfnt/sfobjs.c1552
-rw-r--r--contrib/libs/freetype/src/sfnt/sfobjs.h58
-rw-r--r--contrib/libs/freetype/src/sfnt/sfwoff.c426
-rw-r--r--contrib/libs/freetype/src/sfnt/sfwoff.h43
-rw-r--r--contrib/libs/freetype/src/sfnt/sfwoff2.c2380
-rw-r--r--contrib/libs/freetype/src/sfnt/sfwoff2.h78
-rw-r--r--contrib/libs/freetype/src/sfnt/ttbdf.c257
-rw-r--r--contrib/libs/freetype/src/sfnt/ttbdf.h49
-rw-r--r--contrib/libs/freetype/src/sfnt/ttcmap.c3902
-rw-r--r--contrib/libs/freetype/src/sfnt/ttcmap.h126
-rw-r--r--contrib/libs/freetype/src/sfnt/ttcmapc.h56
-rw-r--r--contrib/libs/freetype/src/sfnt/ttcolr.c1923
-rw-r--r--contrib/libs/freetype/src/sfnt/ttcolr.h83
-rw-r--r--contrib/libs/freetype/src/sfnt/ttcpal.c310
-rw-r--r--contrib/libs/freetype/src/sfnt/ttcpal.h48
-rw-r--r--contrib/libs/freetype/src/sfnt/ttgpos.c598
-rw-r--r--contrib/libs/freetype/src/sfnt/ttgpos.h53
-rw-r--r--contrib/libs/freetype/src/sfnt/ttkern.c317
-rw-r--r--contrib/libs/freetype/src/sfnt/ttkern.h51
-rw-r--r--contrib/libs/freetype/src/sfnt/ttload.c1496
-rw-r--r--contrib/libs/freetype/src/sfnt/ttload.h111
-rw-r--r--contrib/libs/freetype/src/sfnt/ttmtx.c338
-rw-r--r--contrib/libs/freetype/src/sfnt/ttmtx.h54
-rw-r--r--contrib/libs/freetype/src/sfnt/ttpost.c484
-rw-r--r--contrib/libs/freetype/src/sfnt/ttpost.h46
-rw-r--r--contrib/libs/freetype/src/sfnt/ttsbit.c1685
-rw-r--r--contrib/libs/freetype/src/sfnt/ttsbit.h62
-rw-r--r--contrib/libs/freetype/src/sfnt/ttsvg.c413
-rw-r--r--contrib/libs/freetype/src/sfnt/ttsvg.h43
-rw-r--r--contrib/libs/freetype/src/sfnt/woff2tags.c119
-rw-r--r--contrib/libs/freetype/src/sfnt/woff2tags.h41
-rw-r--r--contrib/libs/freetype/src/smooth/ftgrays.c2149
-rw-r--r--contrib/libs/freetype/src/smooth/ftgrays.h57
-rw-r--r--contrib/libs/freetype/src/smooth/ftsmerrs.h42
-rw-r--r--contrib/libs/freetype/src/smooth/ftsmooth.c605
-rw-r--r--contrib/libs/freetype/src/smooth/ftsmooth.h37
-rw-r--r--contrib/libs/freetype/src/smooth/smooth.c25
-rw-r--r--contrib/libs/freetype/src/svg/ftsvg.c355
-rw-r--r--contrib/libs/freetype/src/svg/ftsvg.h35
-rw-r--r--contrib/libs/freetype/src/svg/svg.c24
-rw-r--r--contrib/libs/freetype/src/svg/svgtypes.h42
-rw-r--r--contrib/libs/freetype/src/truetype/truetype.c29
-rw-r--r--contrib/libs/freetype/src/truetype/ttdriver.c704
-rw-r--r--contrib/libs/freetype/src/truetype/ttdriver.h35
-rw-r--r--contrib/libs/freetype/src/truetype/tterrors.h42
-rw-r--r--contrib/libs/freetype/src/truetype/ttgload.c2740
-rw-r--r--contrib/libs/freetype/src/truetype/ttgload.h61
-rw-r--r--contrib/libs/freetype/src/truetype/ttgxvar.c4594
-rw-r--r--contrib/libs/freetype/src/truetype/ttgxvar.h453
-rw-r--r--contrib/libs/freetype/src/truetype/ttinterp.c7751
-rw-r--r--contrib/libs/freetype/src/truetype/ttinterp.h465
-rw-r--r--contrib/libs/freetype/src/truetype/ttobjs.c1543
-rw-r--r--contrib/libs/freetype/src/truetype/ttobjs.h426
-rw-r--r--contrib/libs/freetype/src/truetype/ttpload.c665
-rw-r--r--contrib/libs/freetype/src/truetype/ttpload.h74
-rw-r--r--contrib/libs/freetype/src/type1/t1afm.c413
-rw-r--r--contrib/libs/freetype/src/type1/t1afm.h53
-rw-r--r--contrib/libs/freetype/src/type1/t1driver.c807
-rw-r--r--contrib/libs/freetype/src/type1/t1driver.h35
-rw-r--r--contrib/libs/freetype/src/type1/t1errors.h41
-rw-r--r--contrib/libs/freetype/src/type1/t1gload.c606
-rw-r--r--contrib/libs/freetype/src/type1/t1gload.h52
-rw-r--r--contrib/libs/freetype/src/type1/t1load.c2755
-rw-r--r--contrib/libs/freetype/src/type1/t1load.h126
-rw-r--r--contrib/libs/freetype/src/type1/t1objs.c655
-rw-r--r--contrib/libs/freetype/src/type1/t1objs.h160
-rw-r--r--contrib/libs/freetype/src/type1/t1parse.c487
-rw-r--r--contrib/libs/freetype/src/type1/t1parse.h137
-rw-r--r--contrib/libs/freetype/src/type1/t1tokens.h143
-rw-r--r--contrib/libs/freetype/src/type1/type1.c29
-rw-r--r--contrib/libs/freetype/src/type42/t42drivr.c248
-rw-r--r--contrib/libs/freetype/src/type42/t42drivr.h36
-rw-r--r--contrib/libs/freetype/src/type42/t42error.h41
-rw-r--r--contrib/libs/freetype/src/type42/t42objs.c698
-rw-r--r--contrib/libs/freetype/src/type42/t42objs.h123
-rw-r--r--contrib/libs/freetype/src/type42/t42parse.c1351
-rw-r--r--contrib/libs/freetype/src/type42/t42parse.h91
-rw-r--r--contrib/libs/freetype/src/type42/t42types.h56
-rw-r--r--contrib/libs/freetype/src/type42/type42.c26
-rw-r--r--contrib/libs/freetype/src/winfonts/fnterrs.h42
-rw-r--r--contrib/libs/freetype/src/winfonts/winfnt.c1219
-rw-r--r--contrib/libs/freetype/src/winfonts/winfnt.h164
-rw-r--r--contrib/libs/freetype/ya.make115
-rw-r--r--contrib/libs/lcms2/.yandex_meta/__init__.py30
-rw-r--r--contrib/libs/lcms2/.yandex_meta/devtools.copyrights.report156
-rw-r--r--contrib/libs/lcms2/.yandex_meta/devtools.licenses.report208
-rw-r--r--contrib/libs/lcms2/.yandex_meta/licenses.list.txt139
-rw-r--r--contrib/libs/lcms2/.yandex_meta/override.nix12
-rw-r--r--contrib/libs/lcms2/AUTHORS58
-rw-r--r--contrib/libs/lcms2/ChangeLog288
-rw-r--r--contrib/libs/lcms2/INSTALL2
-rw-r--r--contrib/libs/lcms2/README.md18
-rw-r--r--contrib/libs/lcms2/SECURITY.md27
-rw-r--r--contrib/libs/lcms2/include/lcms2.h1997
-rw-r--r--contrib/libs/lcms2/include/lcms2_plugin.h700
-rw-r--r--contrib/libs/lcms2/patches/register.patch5
-rw-r--r--contrib/libs/lcms2/src/cmsalpha.c650
-rw-r--r--contrib/libs/lcms2/src/cmscam02.c486
-rw-r--r--contrib/libs/lcms2/src/cmscgats.c3236
-rw-r--r--contrib/libs/lcms2/src/cmscnvrt.c1227
-rw-r--r--contrib/libs/lcms2/src/cmserr.c707
-rw-r--r--contrib/libs/lcms2/src/cmsgamma.c1513
-rw-r--r--contrib/libs/lcms2/src/cmsgmt.c659
-rw-r--r--contrib/libs/lcms2/src/cmshalf.c535
-rw-r--r--contrib/libs/lcms2/src/cmsintrp.c1330
-rw-r--r--contrib/libs/lcms2/src/cmsio0.c2097
-rw-r--r--contrib/libs/lcms2/src/cmsio1.c1039
-rw-r--r--contrib/libs/lcms2/src/cmslut.c1851
-rw-r--r--contrib/libs/lcms2/src/cmsmd5.c313
-rw-r--r--contrib/libs/lcms2/src/cmsmtrx.c176
-rw-r--r--contrib/libs/lcms2/src/cmsnamed.c1202
-rw-r--r--contrib/libs/lcms2/src/cmsopt.c1978
-rw-r--r--contrib/libs/lcms2/src/cmspack.c4056
-rw-r--r--contrib/libs/lcms2/src/cmspcs.c950
-rw-r--r--contrib/libs/lcms2/src/cmsplugin.c1052
-rw-r--r--contrib/libs/lcms2/src/cmsps2.c1583
-rw-r--r--contrib/libs/lcms2/src/cmssamp.c552
-rw-r--r--contrib/libs/lcms2/src/cmssm.c736
-rw-r--r--contrib/libs/lcms2/src/cmstypes.c6054
-rw-r--r--contrib/libs/lcms2/src/cmsvirt.c1341
-rw-r--r--contrib/libs/lcms2/src/cmswtpnt.c353
-rw-r--r--contrib/libs/lcms2/src/cmsxform.c1458
-rw-r--r--contrib/libs/lcms2/src/lcms2_internal.h1157
-rw-r--r--contrib/libs/lcms2/utils/common/utils.h101
-rw-r--r--contrib/libs/lcms2/utils/common/vprf.c336
-rw-r--r--contrib/libs/lcms2/utils/common/xgetopt.c100
-rw-r--r--contrib/libs/lcms2/utils/jpgicc/.yandex_meta/licenses.list.txt148
-rwxr-xr-xcontrib/libs/lcms2/utils/jpgicc/LICENSE_iccjpeg67
-rw-r--r--contrib/libs/lcms2/utils/jpgicc/iccjpeg.c248
-rw-r--r--contrib/libs/lcms2/utils/jpgicc/iccjpeg.h73
-rw-r--r--contrib/libs/lcms2/utils/jpgicc/jpgicc.c1279
-rw-r--r--contrib/libs/lcms2/utils/jpgicc/ya.make62
-rw-r--r--contrib/libs/lcms2/utils/linkicc/.yandex_meta/licenses.list.txt83
-rw-r--r--contrib/libs/lcms2/utils/linkicc/linkicc.c380
-rw-r--r--contrib/libs/lcms2/utils/linkicc/ya.make56
-rw-r--r--contrib/libs/lcms2/utils/psicc/.yandex_meta/licenses.list.txt83
-rw-r--r--contrib/libs/lcms2/utils/psicc/psicc.c249
-rw-r--r--contrib/libs/lcms2/utils/psicc/ya.make56
-rw-r--r--contrib/libs/lcms2/utils/tificc/.yandex_meta/licenses.list.txt83
-rw-r--r--contrib/libs/lcms2/utils/tificc/tificc.c1308
-rw-r--r--contrib/libs/lcms2/utils/tificc/ya.make57
-rw-r--r--contrib/libs/lcms2/utils/transicc/.yandex_meta/licenses.list.txt83
-rw-r--r--contrib/libs/lcms2/utils/transicc/transicc.c1331
-rw-r--r--contrib/libs/lcms2/utils/transicc/ya.make56
-rw-r--r--contrib/libs/lcms2/ya.make94
-rw-r--r--contrib/libs/libjpeg-turbo/.yandex_meta/__init__.py117
-rw-r--r--contrib/libs/libjpeg-turbo/.yandex_meta/devtools.copyrights.report2326
-rw-r--r--contrib/libs/libjpeg-turbo/.yandex_meta/devtools.licenses.report786
-rw-r--r--contrib/libs/libjpeg-turbo/.yandex_meta/licenses.list.txt1431
-rw-r--r--contrib/libs/libjpeg-turbo/.yandex_meta/override.nix12
-rw-r--r--contrib/libs/libjpeg-turbo/BUILDING.md714
-rw-r--r--contrib/libs/libjpeg-turbo/ChangeLog.md1874
-rw-r--r--contrib/libs/libjpeg-turbo/LICENSE.md132
-rw-r--r--contrib/libs/libjpeg-turbo/README.ijg258
-rw-r--r--contrib/libs/libjpeg-turbo/README.md357
-rw-r--r--contrib/libs/libjpeg-turbo/cderror.h123
-rw-r--r--contrib/libs/libjpeg-turbo/cdjpeg.c156
-rw-r--r--contrib/libs/libjpeg-turbo/cdjpeg.h161
-rw-r--r--contrib/libs/libjpeg-turbo/cjpeg.c762
-rw-r--r--contrib/libs/libjpeg-turbo/cjpeg/ya.make38
-rw-r--r--contrib/libs/libjpeg-turbo/cmyk.h61
-rw-r--r--contrib/libs/libjpeg-turbo/djpeg.c853
-rw-r--r--contrib/libs/libjpeg-turbo/djpeg/ya.make39
-rw-r--r--contrib/libs/libjpeg-turbo/jaricom.c157
-rw-r--r--contrib/libs/libjpeg-turbo/jcapimin.c295
-rw-r--r--contrib/libs/libjpeg-turbo/jcapistd.c162
-rw-r--r--contrib/libs/libjpeg-turbo/jcarith.c932
-rw-r--r--contrib/libs/libjpeg-turbo/jccoefct.c449
-rw-r--r--contrib/libs/libjpeg-turbo/jccolext.c144
-rw-r--r--contrib/libs/libjpeg-turbo/jccolor.c710
-rw-r--r--contrib/libs/libjpeg-turbo/jcdctmgr.c720
-rw-r--r--contrib/libs/libjpeg-turbo/jchuff.c1137
-rw-r--r--contrib/libs/libjpeg-turbo/jchuff.h42
-rw-r--r--contrib/libs/libjpeg-turbo/jcicc.c105
-rw-r--r--contrib/libs/libjpeg-turbo/jcinit.c80
-rw-r--r--contrib/libs/libjpeg-turbo/jcmainct.c162
-rw-r--r--contrib/libs/libjpeg-turbo/jcmarker.c664
-rw-r--r--contrib/libs/libjpeg-turbo/jcmaster.c640
-rw-r--r--contrib/libs/libjpeg-turbo/jcomapi.c109
-rw-r--r--contrib/libs/libjpeg-turbo/jconfig.h37
-rw-r--r--contrib/libs/libjpeg-turbo/jconfigint-android.h1
-rw-r--r--contrib/libs/libjpeg-turbo/jconfigint-armv7a.h2
-rw-r--r--contrib/libs/libjpeg-turbo/jconfigint-armv8a.h1
-rw-r--r--contrib/libs/libjpeg-turbo/jconfigint-ios.h1
-rw-r--r--contrib/libs/libjpeg-turbo/jconfigint-linux.h44
-rw-r--r--contrib/libs/libjpeg-turbo/jconfigint-osx.h1
-rw-r--r--contrib/libs/libjpeg-turbo/jconfigint-win.h12
-rw-r--r--contrib/libs/libjpeg-turbo/jconfigint-x86.h2
-rw-r--r--contrib/libs/libjpeg-turbo/jconfigint.h25
-rw-r--r--contrib/libs/libjpeg-turbo/jcparam.c541
-rw-r--r--contrib/libs/libjpeg-turbo/jcphuff.c1114
-rw-r--r--contrib/libs/libjpeg-turbo/jcprepct.c351
-rw-r--r--contrib/libs/libjpeg-turbo/jcsample.c522
-rw-r--r--contrib/libs/libjpeg-turbo/jctrans.c401
-rw-r--r--contrib/libs/libjpeg-turbo/jdapimin.c408
-rw-r--r--contrib/libs/libjpeg-turbo/jdapistd.c689
-rw-r--r--contrib/libs/libjpeg-turbo/jdarith.c782
-rw-r--r--contrib/libs/libjpeg-turbo/jdatadst-tj.c198
-rw-r--r--contrib/libs/libjpeg-turbo/jdatadst.c287
-rw-r--r--contrib/libs/libjpeg-turbo/jdatasrc-tj.c194
-rw-r--r--contrib/libs/libjpeg-turbo/jdatasrc.c295
-rw-r--r--contrib/libs/libjpeg-turbo/jdcoefct.c878
-rw-r--r--contrib/libs/libjpeg-turbo/jdcoefct.h83
-rw-r--r--contrib/libs/libjpeg-turbo/jdcol565.c384
-rw-r--r--contrib/libs/libjpeg-turbo/jdcolext.c141
-rw-r--r--contrib/libs/libjpeg-turbo/jdcolor.c882
-rw-r--r--contrib/libs/libjpeg-turbo/jdct.h208
-rw-r--r--contrib/libs/libjpeg-turbo/jddctmgr.c352
-rw-r--r--contrib/libs/libjpeg-turbo/jdhuff.c834
-rw-r--r--contrib/libs/libjpeg-turbo/jdhuff.h247
-rw-r--r--contrib/libs/libjpeg-turbo/jdicc.c167
-rw-r--r--contrib/libs/libjpeg-turbo/jdinput.c408
-rw-r--r--contrib/libs/libjpeg-turbo/jdmainct.c461
-rw-r--r--contrib/libs/libjpeg-turbo/jdmainct.h71
-rw-r--r--contrib/libs/libjpeg-turbo/jdmarker.c1374
-rw-r--r--contrib/libs/libjpeg-turbo/jdmaster.c726
-rw-r--r--contrib/libs/libjpeg-turbo/jdmaster.h28
-rw-r--r--contrib/libs/libjpeg-turbo/jdmerge.c588
-rw-r--r--contrib/libs/libjpeg-turbo/jdmerge.h47
-rw-r--r--contrib/libs/libjpeg-turbo/jdmrg565.c354
-rw-r--r--contrib/libs/libjpeg-turbo/jdmrgext.c184
-rw-r--r--contrib/libs/libjpeg-turbo/jdphuff.c679
-rw-r--r--contrib/libs/libjpeg-turbo/jdpostct.c294
-rw-r--r--contrib/libs/libjpeg-turbo/jdsample.c524
-rw-r--r--contrib/libs/libjpeg-turbo/jdsample.h50
-rw-r--r--contrib/libs/libjpeg-turbo/jdtrans.c156
-rw-r--r--contrib/libs/libjpeg-turbo/jerror.c251
-rw-r--r--contrib/libs/libjpeg-turbo/jerror.h331
-rw-r--r--contrib/libs/libjpeg-turbo/jfdctflt.c169
-rw-r--r--contrib/libs/libjpeg-turbo/jfdctfst.c227
-rw-r--r--contrib/libs/libjpeg-turbo/jfdctint.c288
-rw-r--r--contrib/libs/libjpeg-turbo/jidctflt.c240
-rw-r--r--contrib/libs/libjpeg-turbo/jidctfst.c371
-rw-r--r--contrib/libs/libjpeg-turbo/jidctint.c2627
-rw-r--r--contrib/libs/libjpeg-turbo/jidctred.c409
-rw-r--r--contrib/libs/libjpeg-turbo/jinclude.h149
-rw-r--r--contrib/libs/libjpeg-turbo/jmemmgr.c1180
-rw-r--r--contrib/libs/libjpeg-turbo/jmemnobs.c110
-rw-r--r--contrib/libs/libjpeg-turbo/jmemsys.h178
-rw-r--r--contrib/libs/libjpeg-turbo/jmorecfg.h382
-rw-r--r--contrib/libs/libjpeg-turbo/jpeg_nbits_table.h4098
-rw-r--r--contrib/libs/libjpeg-turbo/jpegcomp.h32
-rw-r--r--contrib/libs/libjpeg-turbo/jpegint.h375
-rw-r--r--contrib/libs/libjpeg-turbo/jpeglib.h1132
-rw-r--r--contrib/libs/libjpeg-turbo/jpegtran.c728
-rw-r--r--contrib/libs/libjpeg-turbo/jpegtran/ya.make28
-rw-r--r--contrib/libs/libjpeg-turbo/jquant1.c856
-rw-r--r--contrib/libs/libjpeg-turbo/jquant2.c1285
-rw-r--r--contrib/libs/libjpeg-turbo/jsimd.h123
-rw-r--r--contrib/libs/libjpeg-turbo/jsimd_none.c431
-rw-r--r--contrib/libs/libjpeg-turbo/jsimddct.h70
-rw-r--r--contrib/libs/libjpeg-turbo/jstdhuff.c144
-rw-r--r--contrib/libs/libjpeg-turbo/jutils.c133
-rw-r--r--contrib/libs/libjpeg-turbo/jversion.h54
-rw-r--r--contrib/libs/libjpeg-turbo/libjpeg.map11
-rw-r--r--contrib/libs/libjpeg-turbo/md5/md5.c275
-rw-r--r--contrib/libs/libjpeg-turbo/md5/md5.h57
-rw-r--r--contrib/libs/libjpeg-turbo/md5/md5hl.c129
-rw-r--r--contrib/libs/libjpeg-turbo/patches/02-sanitizer.patch91
-rw-r--r--contrib/libs/libjpeg-turbo/patches/03-asm.patch80
-rw-r--r--contrib/libs/libjpeg-turbo/patches/no-INT32.patch5
-rw-r--r--contrib/libs/libjpeg-turbo/rdbmp.c690
-rw-r--r--contrib/libs/libjpeg-turbo/rdcolmap.c253
-rw-r--r--contrib/libs/libjpeg-turbo/rdgif.c720
-rw-r--r--contrib/libs/libjpeg-turbo/rdppm.c781
-rw-r--r--contrib/libs/libjpeg-turbo/rdswitch.c428
-rw-r--r--contrib/libs/libjpeg-turbo/rdtarga.c508
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/aarch32/jccolext-neon.c148
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/aarch32/jchuff-neon.c334
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/aarch32/jsimd.c978
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/aarch32/jsimd_neon.S1209
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/aarch64/jccolext-neon.c316
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/aarch64/jchuff-neon.c411
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/aarch64/jsimd.c1056
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/aarch64/jsimd_neon.S2254
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/align.h28
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/jccolor-neon.c160
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/jcgray-neon.c120
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/jcgryext-neon.c106
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/jchuff.h131
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/jcphuff-neon.c622
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/jcsample-neon.c192
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/jdcolext-neon.c374
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/jdcolor-neon.c142
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/jdmerge-neon.c145
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/jdmrgext-neon.c723
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/jdsample-neon.c569
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/jfdctfst-neon.c214
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/jfdctint-neon.c376
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/jidctfst-neon.c472
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/jidctint-neon.c802
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/jidctred-neon.c486
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/jquanti-neon.c193
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/neon-compat.h37
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jccolext-avx2.asm578
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jccolext-mmx.asm476
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jccolext-sse2.asm503
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jccolor-avx2.asm121
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jccolor-mmx.asm121
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jccolor-sse2.asm120
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jcgray-avx2.asm113
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jcgray-mmx.asm113
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jcgray-sse2.asm112
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jcgryext-avx2.asm457
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jcgryext-mmx.asm355
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jcgryext-sse2.asm382
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jchuff-sse2.asm761
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jcphuff-sse2.asm662
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jcsample-avx2.asm388
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jcsample-mmx.asm324
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jcsample-sse2.asm351
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jdcolext-avx2.asm515
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jdcolext-mmx.asm404
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jdcolext-sse2.asm458
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jdcolor-avx2.asm118
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jdcolor-mmx.asm117
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jdcolor-sse2.asm117
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jdmerge-avx2.asm136
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jdmerge-mmx.asm123
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jdmerge-sse2.asm135
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jdmrgext-avx2.asm575
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jdmrgext-mmx.asm460
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jdmrgext-sse2.asm517
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jdsample-avx2.asm760
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jdsample-mmx.asm731
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jdsample-sse2.asm724
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jfdctflt-3dn.asm318
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jfdctflt-sse.asm369
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jfdctfst-mmx.asm395
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jfdctfst-sse2.asm403
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jfdctint-avx2.asm331
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jfdctint-mmx.asm620
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jfdctint-sse2.asm633
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jidctflt-3dn.asm451
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jidctflt-sse.asm571
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jidctflt-sse2.asm497
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jidctfst-mmx.asm499
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jidctfst-sse2.asm501
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jidctint-avx2.asm453
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jidctint-mmx.asm851
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jidctint-sse2.asm858
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jidctred-mmx.asm704
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jidctred-sse2.asm592
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jquant-3dn.asm230
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jquant-mmx.asm276
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jquant-sse.asm208
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jquantf-sse2.asm168
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jquanti-avx2.asm188
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jquanti-sse2.asm201
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jsimd.c1246
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jsimdcpu.asm135
-rw-r--r--contrib/libs/libjpeg-turbo/simd/jsimd.h1258
-rw-r--r--contrib/libs/libjpeg-turbo/simd/nasm/jcolsamp.inc135
-rw-r--r--contrib/libs/libjpeg-turbo/simd/nasm/jdct.inc31
-rw-r--r--contrib/libs/libjpeg-turbo/simd/nasm/jsimdcfg.inc93
-rw-r--r--contrib/libs/libjpeg-turbo/simd/nasm/jsimdcfg.inc.h133
-rw-r--r--contrib/libs/libjpeg-turbo/simd/nasm/jsimdext.inc520
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jccolext-avx2.asm559
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jccolext-sse2.asm484
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jccolor-avx2.asm121
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jccolor-sse2.asm120
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jcgray-avx2.asm113
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jcgray-sse2.asm112
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jcgryext-avx2.asm438
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jcgryext-sse2.asm363
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jchuff-sse2.asm583
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jcphuff-sse2.asm639
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jcsample-avx2.asm367
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jcsample-sse2.asm330
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jdcolext-avx2.asm496
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jdcolext-sse2.asm439
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jdcolor-avx2.asm118
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jdcolor-sse2.asm117
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jdmerge-avx2.asm136
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jdmerge-sse2.asm135
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jdmrgext-avx2.asm596
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jdmrgext-sse2.asm538
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jdsample-avx2.asm696
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jdsample-sse2.asm665
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jfdctflt-sse.asm355
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jfdctfst-sse2.asm389
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jfdctint-avx2.asm320
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jfdctint-sse2.asm619
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jidctflt-sse2.asm482
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jidctfst-sse2.asm491
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jidctint-avx2.asm418
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jidctint-sse2.asm847
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jidctred-sse2.asm574
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jquantf-sse2.asm155
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jquanti-avx2.asm163
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jquanti-sse2.asm188
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jsimd.c1076
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jsimdcpu.asm86
-rw-r--r--contrib/libs/libjpeg-turbo/testimages/nightshot_iso_100.bmpbin82998 -> 0 bytes
-rw-r--r--contrib/libs/libjpeg-turbo/testimages/nightshot_iso_100.txt25
-rw-r--r--contrib/libs/libjpeg-turbo/testimages/testimgari.jpgbin5126 -> 0 bytes
-rw-r--r--contrib/libs/libjpeg-turbo/testimages/testimgint.jpgbin5756 -> 0 bytes
-rw-r--r--contrib/libs/libjpeg-turbo/testimages/testorig.jpgbin5770 -> 0 bytes
-rw-r--r--contrib/libs/libjpeg-turbo/testimages/testorig.ppm4
-rw-r--r--contrib/libs/libjpeg-turbo/testimages/testorig12.jpgbin12394 -> 0 bytes
-rw-r--r--contrib/libs/libjpeg-turbo/testimages/vgl_5674_0098.bmpbin34614 -> 0 bytes
-rw-r--r--contrib/libs/libjpeg-turbo/testimages/vgl_6434_0018a.bmpbin34614 -> 0 bytes
-rw-r--r--contrib/libs/libjpeg-turbo/testimages/vgl_6548_0026a.bmpbin36534 -> 0 bytes
-rw-r--r--contrib/libs/libjpeg-turbo/tjunittest.c936
-rw-r--r--contrib/libs/libjpeg-turbo/tjunittest/ya.make28
-rw-r--r--contrib/libs/libjpeg-turbo/tjutil.c70
-rw-r--r--contrib/libs/libjpeg-turbo/tjutil.h53
-rw-r--r--contrib/libs/libjpeg-turbo/transupp.c2373
-rw-r--r--contrib/libs/libjpeg-turbo/transupp.h231
-rw-r--r--contrib/libs/libjpeg-turbo/turbojpeg-mapfile65
-rw-r--r--contrib/libs/libjpeg-turbo/turbojpeg.c2248
-rw-r--r--contrib/libs/libjpeg-turbo/turbojpeg.h1767
-rw-r--r--contrib/libs/libjpeg-turbo/ut/bittests.py380
-rw-r--r--contrib/libs/libjpeg-turbo/ut/canondata/result.json22
-rw-r--r--contrib/libs/libjpeg-turbo/ut/tjunittest.py24
-rw-r--r--contrib/libs/libjpeg-turbo/ut/ya.make23
-rw-r--r--contrib/libs/libjpeg-turbo/wrbmp.c552
-rw-r--r--contrib/libs/libjpeg-turbo/wrgif.c580
-rw-r--r--contrib/libs/libjpeg-turbo/wrppm.c366
-rw-r--r--contrib/libs/libjpeg-turbo/wrtarga.c258
-rw-r--r--contrib/libs/libjpeg-turbo/ya.make259
-rw-r--r--contrib/libs/libpng/.yandex_meta/__init__.py58
-rw-r--r--contrib/libs/libpng/.yandex_meta/devtools.copyrights.report452
-rw-r--r--contrib/libs/libpng/.yandex_meta/devtools.licenses.report498
-rw-r--r--contrib/libs/libpng/.yandex_meta/licenses.list.txt1093
-rw-r--r--contrib/libs/libpng/.yandex_meta/override.nix19
-rw-r--r--contrib/libs/libpng/ANNOUNCE44
-rw-r--r--contrib/libs/libpng/AUTHORS62
-rw-r--r--contrib/libs/libpng/CHANGES6245
-rw-r--r--contrib/libs/libpng/INSTALL463
-rw-r--r--contrib/libs/libpng/LICENSE140
-rw-r--r--contrib/libs/libpng/README182
-rw-r--r--contrib/libs/libpng/TODO22
-rw-r--r--contrib/libs/libpng/TRADEMARK8
-rw-r--r--contrib/libs/libpng/arm/arm_init.c138
-rw-r--r--contrib/libs/libpng/arm/filter_neon.S60
-rw-r--r--contrib/libs/libpng/arm/filter_neon_intrinsics.c401
-rw-r--r--contrib/libs/libpng/arm/palette_neon_intrinsics.c150
-rw-r--r--contrib/libs/libpng/include/png.h1
-rw-r--r--contrib/libs/libpng/include/pngconf.h1
-rw-r--r--contrib/libs/libpng/include/pnglibconf.h1
-rw-r--r--contrib/libs/libpng/include/ya.make17
-rw-r--r--contrib/libs/libpng/intel/filter_sse2_intrinsics.c390
-rw-r--r--contrib/libs/libpng/intel/intel_init.c51
-rw-r--r--contrib/libs/libpng/mips/filter_mmi_inline_assembly.c525
-rw-r--r--contrib/libs/libpng/mips/filter_msa_intrinsics.c807
-rw-r--r--contrib/libs/libpng/mips/mips_init.c203
-rw-r--r--contrib/libs/libpng/patches/apng.patch1564
-rw-r--r--contrib/libs/libpng/patches/pnglibconf.patch8
-rw-r--r--contrib/libs/libpng/png.c4680
-rw-r--r--contrib/libs/libpng/png.h3456
-rw-r--r--contrib/libs/libpng/pngconf.h622
-rw-r--r--contrib/libs/libpng/pngdebug.h152
-rw-r--r--contrib/libs/libpng/pngerror.c957
-rw-r--r--contrib/libs/libpng/pngget.c1558
-rw-r--r--contrib/libs/libpng/pnginfo.h305
-rw-r--r--contrib/libs/libpng/pnglibconf.h233
-rw-r--r--contrib/libs/libpng/pngmem.c283
-rw-r--r--contrib/libs/libpng/pngpread.c1290
-rw-r--r--contrib/libs/libpng/pngprefix.h0
-rw-r--r--contrib/libs/libpng/pngpriv.h2284
-rw-r--r--contrib/libs/libpng/pngread.c4337
-rw-r--r--contrib/libs/libpng/pngrio.c119
-rw-r--r--contrib/libs/libpng/pngrtran.c5039
-rw-r--r--contrib/libs/libpng/pngrutil.c5103
-rw-r--r--contrib/libs/libpng/pngset.c2128
-rw-r--r--contrib/libs/libpng/pngstruct.h499
-rw-r--r--contrib/libs/libpng/pngtrans.c867
-rw-r--r--contrib/libs/libpng/pngwio.c167
-rw-r--r--contrib/libs/libpng/pngwrite.c2519
-rw-r--r--contrib/libs/libpng/pngwtran.c574
-rw-r--r--contrib/libs/libpng/pngwutil.c2961
-rw-r--r--contrib/libs/libpng/powerpc/filter_vsx_intrinsics.c768
-rw-r--r--contrib/libs/libpng/powerpc/powerpc_init.c125
-rw-r--r--contrib/libs/libpng/ya.make69
-rw-r--r--contrib/libs/libtiff/.yandex_meta/__init__.py37
-rw-r--r--contrib/libs/libtiff/.yandex_meta/devtools.copyrights.report433
-rw-r--r--contrib/libs/libtiff/.yandex_meta/devtools.licenses.report169
-rw-r--r--contrib/libs/libtiff/.yandex_meta/licenses.list.txt228
-rw-r--r--contrib/libs/libtiff/.yandex_meta/override.nix29
-rw-r--r--contrib/libs/libtiff/CONTRIBUTING.md19
-rw-r--r--contrib/libs/libtiff/ChangeLog17406
-rw-r--r--contrib/libs/libtiff/HOWTO-RELEASE155
-rw-r--r--contrib/libs/libtiff/HOWTO-SECURITY-RELEASE19
-rw-r--r--contrib/libs/libtiff/LICENSE.md23
-rw-r--r--contrib/libs/libtiff/README.md69
-rw-r--r--contrib/libs/libtiff/RELEASE-DATE1
-rw-r--r--contrib/libs/libtiff/TODO10
-rw-r--r--contrib/libs/libtiff/libtiff.map220
-rw-r--r--contrib/libs/libtiff/libtiffxx.map4
-rw-r--r--contrib/libs/libtiff/patches/02_fix_dirs_without_imagelength.patch44
-rw-r--r--contrib/libs/libtiff/patches/03_directory_check.patch20
-rw-r--r--contrib/libs/libtiff/patches/04_fix_null_count.patch11
-rw-r--r--contrib/libs/libtiff/t4.h284
-rw-r--r--contrib/libs/libtiff/tif_aux.c411
-rw-r--r--contrib/libs/libtiff/tif_close.c166
-rw-r--r--contrib/libs/libtiff/tif_codec.c163
-rw-r--r--contrib/libs/libtiff/tif_color.c322
-rw-r--r--contrib/libs/libtiff/tif_compress.c310
-rw-r--r--contrib/libs/libtiff/tif_config.h157
-rw-r--r--contrib/libs/libtiff/tif_dir.c2365
-rw-r--r--contrib/libs/libtiff/tif_dir.h366
-rw-r--r--contrib/libs/libtiff/tif_dirinfo.c1363
-rw-r--r--contrib/libs/libtiff/tif_dirread.c8431
-rw-r--r--contrib/libs/libtiff/tif_dirwrite.c3811
-rw-r--r--contrib/libs/libtiff/tif_dumpmode.c122
-rw-r--r--contrib/libs/libtiff/tif_error.c132
-rw-r--r--contrib/libs/libtiff/tif_extension.c110
-rw-r--r--contrib/libs/libtiff/tif_fax3.c1787
-rw-r--r--contrib/libs/libtiff/tif_fax3.h648
-rw-r--r--contrib/libs/libtiff/tif_fax3sm.c1261
-rw-r--r--contrib/libs/libtiff/tif_flush.c157
-rw-r--r--contrib/libs/libtiff/tif_getimage.c3412
-rw-r--r--contrib/libs/libtiff/tif_hash_set.c603
-rw-r--r--contrib/libs/libtiff/tif_hash_set.h100
-rw-r--r--contrib/libs/libtiff/tif_jbig.c233
-rw-r--r--contrib/libs/libtiff/tif_jpeg.c2898
-rw-r--r--contrib/libs/libtiff/tif_jpeg_12.c63
-rw-r--r--contrib/libs/libtiff/tif_lerc.c1541
-rw-r--r--contrib/libs/libtiff/tif_luv.c1840
-rw-r--r--contrib/libs/libtiff/tif_lzma.c542
-rw-r--r--contrib/libs/libtiff/tif_lzw.c1456
-rw-r--r--contrib/libs/libtiff/tif_next.c194
-rw-r--r--contrib/libs/libtiff/tif_ojpeg.c2811
-rw-r--r--contrib/libs/libtiff/tif_open.c935
-rw-r--r--contrib/libs/libtiff/tif_packbits.c324
-rw-r--r--contrib/libs/libtiff/tif_pixarlog.c1677
-rw-r--r--contrib/libs/libtiff/tif_predict.c1046
-rw-r--r--contrib/libs/libtiff/tif_predict.h74
-rw-r--r--contrib/libs/libtiff/tif_print.c755
-rw-r--r--contrib/libs/libtiff/tif_read.c1663
-rw-r--r--contrib/libs/libtiff/tif_stream.cxx404
-rw-r--r--contrib/libs/libtiff/tif_strip.c380
-rw-r--r--contrib/libs/libtiff/tif_swab.c329
-rw-r--r--contrib/libs/libtiff/tif_thunder.c202
-rw-r--r--contrib/libs/libtiff/tif_tile.c284
-rw-r--r--contrib/libs/libtiff/tif_unix.c378
-rw-r--r--contrib/libs/libtiff/tif_version.c28
-rw-r--r--contrib/libs/libtiff/tif_warning.c105
-rw-r--r--contrib/libs/libtiff/tif_webp.c919
-rw-r--r--contrib/libs/libtiff/tif_win32.c446
-rw-r--r--contrib/libs/libtiff/tif_write.c960
-rw-r--r--contrib/libs/libtiff/tif_zip.c756
-rw-r--r--contrib/libs/libtiff/tif_zstd.c438
-rw-r--r--contrib/libs/libtiff/tiff.h899
-rw-r--r--contrib/libs/libtiff/tiffconf.h144
-rw-r--r--contrib/libs/libtiff/tiffio.h653
-rw-r--r--contrib/libs/libtiff/tiffio.hxx39
-rw-r--r--contrib/libs/libtiff/tiffiop.h545
-rw-r--r--contrib/libs/libtiff/tiffvers.h36
-rw-r--r--contrib/libs/libtiff/uvcode.h93
-rw-r--r--contrib/libs/libtiff/ya.make98
-rw-r--r--contrib/libs/libwebp/.yandex_meta/__init__.py44
-rw-r--r--contrib/libs/libwebp/.yandex_meta/devtools.copyrights.report311
-rw-r--r--contrib/libs/libwebp/.yandex_meta/devtools.licenses.report427
-rw-r--r--contrib/libs/libwebp/.yandex_meta/licenses.list.txt253
-rw-r--r--contrib/libs/libwebp/.yandex_meta/override.nix12
-rw-r--r--contrib/libs/libwebp/AUTHORS52
-rw-r--r--contrib/libs/libwebp/CONTRIBUTING.md29
-rw-r--r--contrib/libs/libwebp/COPYING30
-rw-r--r--contrib/libs/libwebp/ChangeLog4282
-rw-r--r--contrib/libs/libwebp/NEWS274
-rw-r--r--contrib/libs/libwebp/PATENTS23
-rw-r--r--contrib/libs/libwebp/PRESUBMIT.py214
-rw-r--r--contrib/libs/libwebp/README795
-rw-r--r--contrib/libs/libwebp/README.mux258
-rw-r--r--contrib/libs/libwebp/README.webp_js75
-rw-r--r--contrib/libs/libwebp/dec/.yandex_meta/licenses.list.txt140
-rw-r--r--contrib/libs/libwebp/dec/alpha_dec.c232
-rw-r--r--contrib/libs/libwebp/dec/alphai_dec.h54
-rw-r--r--contrib/libs/libwebp/dec/buffer_dec.c310
-rw-r--r--contrib/libs/libwebp/dec/common_dec.h54
-rw-r--r--contrib/libs/libwebp/dec/frame_dec.c803
-rw-r--r--contrib/libs/libwebp/dec/idec_dec.c908
-rw-r--r--contrib/libs/libwebp/dec/io_dec.c662
-rw-r--r--contrib/libs/libwebp/dec/quant_dec.c115
-rw-r--r--contrib/libs/libwebp/dec/tree_dec.c537
-rw-r--r--contrib/libs/libwebp/dec/vp8_dec.c722
-rw-r--r--contrib/libs/libwebp/dec/vp8_dec.h185
-rw-r--r--contrib/libs/libwebp/dec/vp8i_dec.h319
-rw-r--r--contrib/libs/libwebp/dec/vp8l_dec.c1742
-rw-r--r--contrib/libs/libwebp/dec/vp8li_dec.h135
-rw-r--r--contrib/libs/libwebp/dec/webp_dec.c852
-rw-r--r--contrib/libs/libwebp/dec/webpi_dec.h137
-rw-r--r--contrib/libs/libwebp/dec/ya.make37
-rw-r--r--contrib/libs/libwebp/demux/.yandex_meta/licenses.list.txt128
-rw-r--r--contrib/libs/libwebp/demux/anim_decode.c473
-rw-r--r--contrib/libs/libwebp/demux/demux.c978
-rw-r--r--contrib/libs/libwebp/demux/ya.make33
-rw-r--r--contrib/libs/libwebp/dsp/alpha_processing.c495
-rw-r--r--contrib/libs/libwebp/dsp/alpha_processing_mips_dsp_r2.c228
-rw-r--r--contrib/libs/libwebp/dsp/alpha_processing_neon.c192
-rw-r--r--contrib/libs/libwebp/dsp/alpha_processing_sse2.c367
-rw-r--r--contrib/libs/libwebp/dsp/alpha_processing_sse41.c92
-rw-r--r--contrib/libs/libwebp/dsp/common_sse2.h194
-rw-r--r--contrib/libs/libwebp/dsp/common_sse41.h132
-rw-r--r--contrib/libs/libwebp/dsp/cost.c411
-rw-r--r--contrib/libs/libwebp/dsp/cost_mips32.c154
-rw-r--r--contrib/libs/libwebp/dsp/cost_mips_dsp_r2.c107
-rw-r--r--contrib/libs/libwebp/dsp/cost_neon.c122
-rw-r--r--contrib/libs/libwebp/dsp/cost_sse2.c119
-rw-r--r--contrib/libs/libwebp/dsp/cpu.c253
-rw-r--r--contrib/libs/libwebp/dsp/dec.c887
-rw-r--r--contrib/libs/libwebp/dsp/dec_clip_tables.c369
-rw-r--r--contrib/libs/libwebp/dsp/dec_mips32.c587
-rw-r--r--contrib/libs/libwebp/dsp/dec_mips_dsp_r2.c994
-rw-r--r--contrib/libs/libwebp/dsp/dec_msa.c1020
-rw-r--r--contrib/libs/libwebp/dsp/dec_neon.c1663
-rw-r--r--contrib/libs/libwebp/dsp/dec_sse2.c1227
-rw-r--r--contrib/libs/libwebp/dsp/dec_sse41.c46
-rw-r--r--contrib/libs/libwebp/dsp/dsp.h731
-rw-r--r--contrib/libs/libwebp/dsp/enc.c830
-rw-r--r--contrib/libs/libwebp/dsp/enc_mips32.c677
-rw-r--r--contrib/libs/libwebp/dsp/enc_mips_dsp_r2.c1517
-rw-r--r--contrib/libs/libwebp/dsp/enc_msa.c896
-rw-r--r--contrib/libs/libwebp/dsp/enc_neon.c938
-rw-r--r--contrib/libs/libwebp/dsp/enc_sse2.c1381
-rw-r--r--contrib/libs/libwebp/dsp/enc_sse41.c339
-rw-r--r--contrib/libs/libwebp/dsp/filters.c287
-rw-r--r--contrib/libs/libwebp/dsp/filters_mips_dsp_r2.c402
-rw-r--r--contrib/libs/libwebp/dsp/filters_msa.c202
-rw-r--r--contrib/libs/libwebp/dsp/filters_neon.c329
-rw-r--r--contrib/libs/libwebp/dsp/filters_sse2.c340
-rw-r--r--contrib/libs/libwebp/dsp/lossless.c680
-rw-r--r--contrib/libs/libwebp/dsp/lossless.h259
-rw-r--r--contrib/libs/libwebp/dsp/lossless_common.h191
-rw-r--r--contrib/libs/libwebp/dsp/lossless_enc.c948
-rw-r--r--contrib/libs/libwebp/dsp/lossless_enc_mips32.c397
-rw-r--r--contrib/libs/libwebp/dsp/lossless_enc_mips_dsp_r2.c281
-rw-r--r--contrib/libs/libwebp/dsp/lossless_enc_msa.c148
-rw-r--r--contrib/libs/libwebp/dsp/lossless_enc_neon.c144
-rw-r--r--contrib/libs/libwebp/dsp/lossless_enc_sse2.c669
-rw-r--r--contrib/libs/libwebp/dsp/lossless_enc_sse41.c155
-rw-r--r--contrib/libs/libwebp/dsp/lossless_mips_dsp_r2.c701
-rw-r--r--contrib/libs/libwebp/dsp/lossless_msa.c356
-rw-r--r--contrib/libs/libwebp/dsp/lossless_neon.c645
-rw-r--r--contrib/libs/libwebp/dsp/lossless_sse2.c716
-rw-r--r--contrib/libs/libwebp/dsp/lossless_sse41.c132
-rw-r--r--contrib/libs/libwebp/dsp/mips_macro.h200
-rw-r--r--contrib/libs/libwebp/dsp/msa_macro.h1397
-rw-r--r--contrib/libs/libwebp/dsp/neon.h104
-rw-r--r--contrib/libs/libwebp/dsp/quant.h85
-rw-r--r--contrib/libs/libwebp/dsp/rescaler.c251
-rw-r--r--contrib/libs/libwebp/dsp/rescaler_mips32.c295
-rw-r--r--contrib/libs/libwebp/dsp/rescaler_mips_dsp_r2.c314
-rw-r--r--contrib/libs/libwebp/dsp/rescaler_msa.c443
-rw-r--r--contrib/libs/libwebp/dsp/rescaler_neon.c192
-rw-r--r--contrib/libs/libwebp/dsp/rescaler_sse2.c366
-rw-r--r--contrib/libs/libwebp/dsp/ssim.c159
-rw-r--r--contrib/libs/libwebp/dsp/ssim_sse2.c165
-rw-r--r--contrib/libs/libwebp/dsp/upsampling.c327
-rw-r--r--contrib/libs/libwebp/dsp/upsampling_mips_dsp_r2.c291
-rw-r--r--contrib/libs/libwebp/dsp/upsampling_msa.c688
-rw-r--r--contrib/libs/libwebp/dsp/upsampling_neon.c285
-rw-r--r--contrib/libs/libwebp/dsp/upsampling_sse2.c267
-rw-r--r--contrib/libs/libwebp/dsp/upsampling_sse41.c239
-rw-r--r--contrib/libs/libwebp/dsp/webpdsp/ya.make43
-rw-r--r--contrib/libs/libwebp/dsp/webpdsp_mips32/ya.make36
-rw-r--r--contrib/libs/libwebp/dsp/webpdsp_mips_dsp_r2/ya.make36
-rw-r--r--contrib/libs/libwebp/dsp/webpdsp_msa/ya.make35
-rw-r--r--contrib/libs/libwebp/dsp/webpdsp_neon/ya.make36
-rw-r--r--contrib/libs/libwebp/dsp/webpdsp_sse2/ya.make37
-rw-r--r--contrib/libs/libwebp/dsp/webpdsp_sse41/ya.make35
-rw-r--r--contrib/libs/libwebp/dsp/webpdspdecode/ya.make56
-rw-r--r--contrib/libs/libwebp/dsp/webpdspdecode_mips32/ya.make32
-rw-r--r--contrib/libs/libwebp/dsp/webpdspdecode_mips_dsp_r2/ya.make36
-rw-r--r--contrib/libs/libwebp/dsp/webpdspdecode_msa/ya.make34
-rw-r--r--contrib/libs/libwebp/dsp/webpdspdecode_neon/ya.make36
-rw-r--r--contrib/libs/libwebp/dsp/webpdspdecode_sse2/ya.make36
-rw-r--r--contrib/libs/libwebp/dsp/webpdspdecode_sse41/ya.make34
-rw-r--r--contrib/libs/libwebp/dsp/yuv.c308
-rw-r--r--contrib/libs/libwebp/dsp/yuv.h210
-rw-r--r--contrib/libs/libwebp/dsp/yuv_mips32.c103
-rw-r--r--contrib/libs/libwebp/dsp/yuv_mips_dsp_r2.c134
-rw-r--r--contrib/libs/libwebp/dsp/yuv_neon.c288
-rw-r--r--contrib/libs/libwebp/dsp/yuv_sse2.c874
-rw-r--r--contrib/libs/libwebp/dsp/yuv_sse41.c613
-rw-r--r--contrib/libs/libwebp/enc/.yandex_meta/licenses.list.txt140
-rw-r--r--contrib/libs/libwebp/enc/alpha_enc.c443
-rw-r--r--contrib/libs/libwebp/enc/analysis_enc.c475
-rw-r--r--contrib/libs/libwebp/enc/backward_references_cost_enc.c790
-rw-r--r--contrib/libs/libwebp/enc/backward_references_enc.c1030
-rw-r--r--contrib/libs/libwebp/enc/backward_references_enc.h240
-rw-r--r--contrib/libs/libwebp/enc/config_enc.c157
-rw-r--r--contrib/libs/libwebp/enc/cost_enc.c342
-rw-r--r--contrib/libs/libwebp/enc/cost_enc.h82
-rw-r--r--contrib/libs/libwebp/enc/filter_enc.c235
-rw-r--r--contrib/libs/libwebp/enc/frame_enc.c899
-rw-r--r--contrib/libs/libwebp/enc/histogram_enc.c1252
-rw-r--r--contrib/libs/libwebp/enc/histogram_enc.h128
-rw-r--r--contrib/libs/libwebp/enc/iterator_enc.c459
-rw-r--r--contrib/libs/libwebp/enc/near_lossless_enc.c151
-rw-r--r--contrib/libs/libwebp/enc/picture_csp_enc.c1210
-rw-r--r--contrib/libs/libwebp/enc/picture_enc.c296
-rw-r--r--contrib/libs/libwebp/enc/picture_psnr_enc.c258
-rw-r--r--contrib/libs/libwebp/enc/picture_rescale_enc.c316
-rw-r--r--contrib/libs/libwebp/enc/picture_tools_enc.c273
-rw-r--r--contrib/libs/libwebp/enc/predictor_enc.c772
-rw-r--r--contrib/libs/libwebp/enc/quant_enc.c1388
-rw-r--r--contrib/libs/libwebp/enc/syntax_enc.c388
-rw-r--r--contrib/libs/libwebp/enc/token_enc.c262
-rw-r--r--contrib/libs/libwebp/enc/tree_enc.c504
-rw-r--r--contrib/libs/libwebp/enc/vp8i_enc.h517
-rw-r--r--contrib/libs/libwebp/enc/vp8l_enc.c2138
-rw-r--r--contrib/libs/libwebp/enc/vp8li_enc.h120
-rw-r--r--contrib/libs/libwebp/enc/webp_enc.c410
-rw-r--r--contrib/libs/libwebp/enc/ya.make50
-rw-r--r--contrib/libs/libwebp/mux/.yandex_meta/licenses.list.txt132
-rw-r--r--contrib/libs/libwebp/mux/anim_encode.c1585
-rw-r--r--contrib/libs/libwebp/mux/animi.h43
-rw-r--r--contrib/libs/libwebp/mux/muxedit.c655
-rw-r--r--contrib/libs/libwebp/mux/muxi.h234
-rw-r--r--contrib/libs/libwebp/mux/muxinternal.c548
-rw-r--r--contrib/libs/libwebp/mux/muxread.c554
-rw-r--r--contrib/libs/libwebp/mux/ya.make35
-rw-r--r--contrib/libs/libwebp/utils/bit_reader_inl_utils.h196
-rw-r--r--contrib/libs/libwebp/utils/bit_reader_utils.c298
-rw-r--r--contrib/libs/libwebp/utils/bit_reader_utils.h194
-rw-r--r--contrib/libs/libwebp/utils/bit_writer_utils.c347
-rw-r--r--contrib/libs/libwebp/utils/bit_writer_utils.h154
-rw-r--r--contrib/libs/libwebp/utils/color_cache_utils.c49
-rw-r--r--contrib/libs/libwebp/utils/color_cache_utils.h89
-rw-r--r--contrib/libs/libwebp/utils/endian_inl_utils.h93
-rw-r--r--contrib/libs/libwebp/utils/filters_utils.c76
-rw-r--r--contrib/libs/libwebp/utils/filters_utils.h32
-rw-r--r--contrib/libs/libwebp/utils/huffman_encode_utils.c416
-rw-r--r--contrib/libs/libwebp/utils/huffman_encode_utils.h60
-rw-r--r--contrib/libs/libwebp/utils/huffman_utils.c235
-rw-r--r--contrib/libs/libwebp/utils/huffman_utils.h90
-rw-r--r--contrib/libs/libwebp/utils/quant_levels_dec_utils.c291
-rw-r--r--contrib/libs/libwebp/utils/quant_levels_dec_utils.h35
-rw-r--r--contrib/libs/libwebp/utils/quant_levels_utils.c140
-rw-r--r--contrib/libs/libwebp/utils/quant_levels_utils.h36
-rw-r--r--contrib/libs/libwebp/utils/random_utils.c43
-rw-r--r--contrib/libs/libwebp/utils/random_utils.h63
-rw-r--r--contrib/libs/libwebp/utils/rescaler_utils.c160
-rw-r--r--contrib/libs/libwebp/utils/rescaler_utils.h102
-rw-r--r--contrib/libs/libwebp/utils/thread_utils.c369
-rw-r--r--contrib/libs/libwebp/utils/thread_utils.h90
-rw-r--r--contrib/libs/libwebp/utils/utils.c338
-rw-r--r--contrib/libs/libwebp/utils/utils.h200
-rw-r--r--contrib/libs/libwebp/utils/webputils/ya.make36
-rw-r--r--contrib/libs/libwebp/utils/webputilsdecode/ya.make38
-rw-r--r--contrib/libs/libwebp/webp/config-android.h5
-rw-r--r--contrib/libs/libwebp/webp/config-linux.h152
-rw-r--r--contrib/libs/libwebp/webp/config.h7
-rw-r--r--contrib/libs/libwebp/webp/decode.h503
-rw-r--r--contrib/libs/libwebp/webp/demux.h363
-rw-r--r--contrib/libs/libwebp/webp/encode.h552
-rw-r--r--contrib/libs/libwebp/webp/format_constants.h87
-rw-r--r--contrib/libs/libwebp/webp/mux.h530
-rw-r--r--contrib/libs/libwebp/webp/mux_types.h98
-rw-r--r--contrib/libs/libwebp/webp/types.h68
-rw-r--r--contrib/libs/libwebp/webpdecoder/ya.make21
-rw-r--r--contrib/libs/libwebp/ya.make48
-rw-r--r--contrib/libs/openjpeg/.yandex_meta/__init__.py42
-rw-r--r--contrib/libs/openjpeg/.yandex_meta/devtools.copyrights.report573
-rw-r--r--contrib/libs/openjpeg/.yandex_meta/devtools.licenses.report608
-rw-r--r--contrib/libs/openjpeg/.yandex_meta/licenses.list.txt673
-rw-r--r--contrib/libs/openjpeg/.yandex_meta/override.nix12
-rw-r--r--contrib/libs/openjpeg/AUTHORS.md21
-rw-r--r--contrib/libs/openjpeg/CHANGELOG.md1021
-rw-r--r--contrib/libs/openjpeg/HOWTO-RELEASE34
-rw-r--r--contrib/libs/openjpeg/INSTALL.md137
-rw-r--r--contrib/libs/openjpeg/LICENSE39
-rw-r--r--contrib/libs/openjpeg/NEWS.md174
-rw-r--r--contrib/libs/openjpeg/README.md83
-rw-r--r--contrib/libs/openjpeg/THANKS.md39
-rw-r--r--contrib/libs/openjpeg/bio.c211
-rw-r--r--contrib/libs/openjpeg/bio.h142
-rw-r--r--contrib/libs/openjpeg/cio.c683
-rw-r--r--contrib/libs/openjpeg/cio.h412
-rw-r--r--contrib/libs/openjpeg/dwt.c3979
-rw-r--r--contrib/libs/openjpeg/dwt.h120
-rw-r--r--contrib/libs/openjpeg/event.c151
-rw-r--r--contrib/libs/openjpeg/event.h108
-rw-r--r--contrib/libs/openjpeg/function_list.c117
-rw-r--r--contrib/libs/openjpeg/function_list.h134
-rw-r--r--contrib/libs/openjpeg/ht_dec.c2689
-rw-r--r--contrib/libs/openjpeg/image.c263
-rw-r--r--contrib/libs/openjpeg/image.h70
-rw-r--r--contrib/libs/openjpeg/include/openjpeg.h1
-rw-r--r--contrib/libs/openjpeg/include/opj_config.h1
-rw-r--r--contrib/libs/openjpeg/invert.c295
-rw-r--r--contrib/libs/openjpeg/invert.h64
-rw-r--r--contrib/libs/openjpeg/j2k.c13595
-rw-r--r--contrib/libs/openjpeg/j2k.h954
-rw-r--r--contrib/libs/openjpeg/jp2.c3418
-rw-r--r--contrib/libs/openjpeg/jp2.h521
-rw-r--r--contrib/libs/openjpeg/mct.c464
-rw-r--r--contrib/libs/openjpeg/mct.h160
-rw-r--r--contrib/libs/openjpeg/mqc.c524
-rw-r--r--contrib/libs/openjpeg/mqc.h268
-rw-r--r--contrib/libs/openjpeg/mqc_inl.h282
-rw-r--r--contrib/libs/openjpeg/openjpeg.c1144
-rw-r--r--contrib/libs/openjpeg/openjpeg.h1783
-rw-r--r--contrib/libs/openjpeg/opj_clock.c67
-rw-r--r--contrib/libs/openjpeg/opj_clock.h59
-rw-r--r--contrib/libs/openjpeg/opj_codec.h179
-rw-r--r--contrib/libs/openjpeg/opj_common.h47
-rw-r--r--contrib/libs/openjpeg/opj_config.h14
-rw-r--r--contrib/libs/openjpeg/opj_config_private-linux.h50
-rw-r--r--contrib/libs/openjpeg/opj_config_private-osx.h3
-rw-r--r--contrib/libs/openjpeg/opj_config_private-win.h4
-rw-r--r--contrib/libs/openjpeg/opj_config_private.h9
-rw-r--r--contrib/libs/openjpeg/opj_includes.h266
-rw-r--r--contrib/libs/openjpeg/opj_intmath.h333
-rw-r--r--contrib/libs/openjpeg/opj_malloc.c249
-rw-r--r--contrib/libs/openjpeg/opj_malloc.h106
-rw-r--r--contrib/libs/openjpeg/pi.c2149
-rw-r--r--contrib/libs/openjpeg/pi.h207
-rw-r--r--contrib/libs/openjpeg/sparse_array.c346
-rw-r--r--contrib/libs/openjpeg/sparse_array.h141
-rw-r--r--contrib/libs/openjpeg/t1.c2741
-rw-r--r--contrib/libs/openjpeg/t1.h268
-rw-r--r--contrib/libs/openjpeg/t1_ht_luts.h261
-rw-r--r--contrib/libs/openjpeg/t1_luts.h175
-rw-r--r--contrib/libs/openjpeg/t2.c1705
-rw-r--r--contrib/libs/openjpeg/t2.h142
-rw-r--r--contrib/libs/openjpeg/tcd.c2930
-rw-r--r--contrib/libs/openjpeg/tcd.h512
-rw-r--r--contrib/libs/openjpeg/tgt.c344
-rw-r--r--contrib/libs/openjpeg/tgt.h148
-rw-r--r--contrib/libs/openjpeg/thread.c954
-rw-r--r--contrib/libs/openjpeg/thread.h256
-rw-r--r--contrib/libs/openjpeg/tls_keys.h37
-rw-r--r--contrib/libs/openjpeg/ya.make60
-rw-r--r--contrib/libs/openssl/ya.make4
1193 files changed, 4 insertions, 637744 deletions
diff --git a/contrib/libs/android_cpufeatures/cpu-features.h b/contrib/libs/android_cpufeatures/cpu-features.h
deleted file mode 100644
index 1e9724197a..0000000000
--- a/contrib/libs/android_cpufeatures/cpu-features.h
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#ifndef CPU_FEATURES_H
-#define CPU_FEATURES_H
-
-#include <sys/cdefs.h>
-#include <stdint.h>
-
-__BEGIN_DECLS
-
-/* A list of valid values returned by android_getCpuFamily().
- * They describe the CPU Architecture of the current process.
- */
-typedef enum {
- ANDROID_CPU_FAMILY_UNKNOWN = 0,
- ANDROID_CPU_FAMILY_ARM,
- ANDROID_CPU_FAMILY_X86,
- ANDROID_CPU_FAMILY_MIPS,
- ANDROID_CPU_FAMILY_ARM64,
- ANDROID_CPU_FAMILY_X86_64,
- ANDROID_CPU_FAMILY_MIPS64,
-
- ANDROID_CPU_FAMILY_MAX /* do not remove */
-
-} AndroidCpuFamily;
-
-/* Return the CPU family of the current process.
- *
- * Note that this matches the bitness of the current process. I.e. when
- * running a 32-bit binary on a 64-bit capable CPU, this will return the
- * 32-bit CPU family value.
- */
-extern AndroidCpuFamily android_getCpuFamily(void);
-
-/* Return a bitmap describing a set of optional CPU features that are
- * supported by the current device's CPU. The exact bit-flags returned
- * depend on the value returned by android_getCpuFamily(). See the
- * documentation for the ANDROID_CPU_*_FEATURE_* flags below for details.
- */
-extern uint64_t android_getCpuFeatures(void);
-
-/* The list of feature flags for ANDROID_CPU_FAMILY_ARM that can be
- * recognized by the library (see note below for 64-bit ARM). Value details
- * are:
- *
- * VFPv2:
- * CPU supports the VFPv2 instruction set. Many, but not all, ARMv6 CPUs
- * support these instructions. VFPv2 is a subset of VFPv3 so this will
- * be set whenever VFPv3 is set too.
- *
- * ARMv7:
- * CPU supports the ARMv7-A basic instruction set.
- * This feature is mandated by the 'armeabi-v7a' ABI.
- *
- * VFPv3:
- * CPU supports the VFPv3-D16 instruction set, providing hardware FPU
- * support for single and double precision floating point registers.
- * Note that only 16 FPU registers are available by default, unless
- * the D32 bit is set too. This feature is also mandated by the
- * 'armeabi-v7a' ABI.
- *
- * VFP_D32:
- * CPU VFP optional extension that provides 32 FPU registers,
- * instead of 16. Note that ARM mandates this feature is the 'NEON'
- * feature is implemented by the CPU.
- *
- * NEON:
- * CPU FPU supports "ARM Advanced SIMD" instructions, also known as
- * NEON. Note that this mandates the VFP_D32 feature as well, per the
- * ARM Architecture specification.
- *
- * VFP_FP16:
- * Half-width floating precision VFP extension. If set, the CPU
- * supports instructions to perform floating-point operations on
- * 16-bit registers. This is part of the VFPv4 specification, but
- * not mandated by any Android ABI.
- *
- * VFP_FMA:
- * Fused multiply-accumulate VFP instructions extension. Also part of
- * the VFPv4 specification, but not mandated by any Android ABI.
- *
- * NEON_FMA:
- * Fused multiply-accumulate NEON instructions extension. Optional
- * extension from the VFPv4 specification, but not mandated by any
- * Android ABI.
- *
- * IDIV_ARM:
- * Integer division available in ARM mode. Only available
- * on recent CPUs (e.g. Cortex-A15).
- *
- * IDIV_THUMB2:
- * Integer division available in Thumb-2 mode. Only available
- * on recent CPUs (e.g. Cortex-A15).
- *
- * iWMMXt:
- * Optional extension that adds MMX registers and operations to an
- * ARM CPU. This is only available on a few XScale-based CPU designs
- * sold by Marvell. Pretty rare in practice.
- *
- * AES:
- * CPU supports AES instructions. These instructions are only
- * available for 32-bit applications running on ARMv8 CPU.
- *
- * CRC32:
- * CPU supports CRC32 instructions. These instructions are only
- * available for 32-bit applications running on ARMv8 CPU.
- *
- * SHA2:
- * CPU supports SHA2 instructions. These instructions are only
- * available for 32-bit applications running on ARMv8 CPU.
- *
- * SHA1:
- * CPU supports SHA1 instructions. These instructions are only
- * available for 32-bit applications running on ARMv8 CPU.
- *
- * PMULL:
- * CPU supports 64-bit PMULL and PMULL2 instructions. These
- * instructions are only available for 32-bit applications
- * running on ARMv8 CPU.
- *
- * If you want to tell the compiler to generate code that targets one of
- * the feature set above, you should probably use one of the following
- * flags (for more details, see technical note at the end of this file):
- *
- * -mfpu=vfp
- * -mfpu=vfpv2
- * These are equivalent and tell GCC to use VFPv2 instructions for
- * floating-point operations. Use this if you want your code to
- * run on *some* ARMv6 devices, and any ARMv7-A device supported
- * by Android.
- *
- * Generated code requires VFPv2 feature.
- *
- * -mfpu=vfpv3-d16
- * Tell GCC to use VFPv3 instructions (using only 16 FPU registers).
- * This should be generic code that runs on any CPU that supports the
- * 'armeabi-v7a' Android ABI. Note that no ARMv6 CPU supports this.
- *
- * Generated code requires VFPv3 feature.
- *
- * -mfpu=vfpv3
- * Tell GCC to use VFPv3 instructions with 32 FPU registers.
- * Generated code requires VFPv3|VFP_D32 features.
- *
- * -mfpu=neon
- * Tell GCC to use VFPv3 instructions with 32 FPU registers, and
- * also support NEON intrinsics (see <arm_neon.h>).
- * Generated code requires VFPv3|VFP_D32|NEON features.
- *
- * -mfpu=vfpv4-d16
- * Generated code requires VFPv3|VFP_FP16|VFP_FMA features.
- *
- * -mfpu=vfpv4
- * Generated code requires VFPv3|VFP_FP16|VFP_FMA|VFP_D32 features.
- *
- * -mfpu=neon-vfpv4
- * Generated code requires VFPv3|VFP_FP16|VFP_FMA|VFP_D32|NEON|NEON_FMA
- * features.
- *
- * -mcpu=cortex-a7
- * -mcpu=cortex-a15
- * Generated code requires VFPv3|VFP_FP16|VFP_FMA|VFP_D32|
- * NEON|NEON_FMA|IDIV_ARM|IDIV_THUMB2
- * This flag implies -mfpu=neon-vfpv4.
- *
- * -mcpu=iwmmxt
- * Allows the use of iWMMXt instrinsics with GCC.
- *
- * IMPORTANT NOTE: These flags should only be tested when
- * android_getCpuFamily() returns ANDROID_CPU_FAMILY_ARM, i.e. this is a
- * 32-bit process.
- *
- * When running a 64-bit ARM process on an ARMv8 CPU,
- * android_getCpuFeatures() will return a different set of bitflags
- */
-enum {
- ANDROID_CPU_ARM_FEATURE_ARMv7 = (1 << 0),
- ANDROID_CPU_ARM_FEATURE_VFPv3 = (1 << 1),
- ANDROID_CPU_ARM_FEATURE_NEON = (1 << 2),
- ANDROID_CPU_ARM_FEATURE_LDREX_STREX = (1 << 3),
- ANDROID_CPU_ARM_FEATURE_VFPv2 = (1 << 4),
- ANDROID_CPU_ARM_FEATURE_VFP_D32 = (1 << 5),
- ANDROID_CPU_ARM_FEATURE_VFP_FP16 = (1 << 6),
- ANDROID_CPU_ARM_FEATURE_VFP_FMA = (1 << 7),
- ANDROID_CPU_ARM_FEATURE_NEON_FMA = (1 << 8),
- ANDROID_CPU_ARM_FEATURE_IDIV_ARM = (1 << 9),
- ANDROID_CPU_ARM_FEATURE_IDIV_THUMB2 = (1 << 10),
- ANDROID_CPU_ARM_FEATURE_iWMMXt = (1 << 11),
- ANDROID_CPU_ARM_FEATURE_AES = (1 << 12),
- ANDROID_CPU_ARM_FEATURE_PMULL = (1 << 13),
- ANDROID_CPU_ARM_FEATURE_SHA1 = (1 << 14),
- ANDROID_CPU_ARM_FEATURE_SHA2 = (1 << 15),
- ANDROID_CPU_ARM_FEATURE_CRC32 = (1 << 16),
-};
-
-/* The bit flags corresponding to the output of android_getCpuFeatures()
- * when android_getCpuFamily() returns ANDROID_CPU_FAMILY_ARM64. Value details
- * are:
- *
- * FP:
- * CPU has Floating-point unit.
- *
- * ASIMD:
- * CPU has Advanced SIMD unit.
- *
- * AES:
- * CPU supports AES instructions.
- *
- * CRC32:
- * CPU supports CRC32 instructions.
- *
- * SHA2:
- * CPU supports SHA2 instructions.
- *
- * SHA1:
- * CPU supports SHA1 instructions.
- *
- * PMULL:
- * CPU supports 64-bit PMULL and PMULL2 instructions.
- */
-enum {
- ANDROID_CPU_ARM64_FEATURE_FP = (1 << 0),
- ANDROID_CPU_ARM64_FEATURE_ASIMD = (1 << 1),
- ANDROID_CPU_ARM64_FEATURE_AES = (1 << 2),
- ANDROID_CPU_ARM64_FEATURE_PMULL = (1 << 3),
- ANDROID_CPU_ARM64_FEATURE_SHA1 = (1 << 4),
- ANDROID_CPU_ARM64_FEATURE_SHA2 = (1 << 5),
- ANDROID_CPU_ARM64_FEATURE_CRC32 = (1 << 6),
-};
-
-/* The bit flags corresponding to the output of android_getCpuFeatures()
- * when android_getCpuFamily() returns ANDROID_CPU_FAMILY_X86 or
- * ANDROID_CPU_FAMILY_X86_64.
- */
-enum {
- ANDROID_CPU_X86_FEATURE_SSSE3 = (1 << 0),
- ANDROID_CPU_X86_FEATURE_POPCNT = (1 << 1),
- ANDROID_CPU_X86_FEATURE_MOVBE = (1 << 2),
- ANDROID_CPU_X86_FEATURE_SSE4_1 = (1 << 3),
- ANDROID_CPU_X86_FEATURE_SSE4_2 = (1 << 4),
- ANDROID_CPU_X86_FEATURE_AES_NI = (1 << 5),
- ANDROID_CPU_X86_FEATURE_AVX = (1 << 6),
- ANDROID_CPU_X86_FEATURE_RDRAND = (1 << 7),
- ANDROID_CPU_X86_FEATURE_AVX2 = (1 << 8),
- ANDROID_CPU_X86_FEATURE_SHA_NI = (1 << 9),
-};
-
-/* The bit flags corresponding to the output of android_getCpuFeatures()
- * when android_getCpuFamily() returns ANDROID_CPU_FAMILY_MIPS
- * or ANDROID_CPU_FAMILY_MIPS64. Values are:
- *
- * R6:
- * CPU executes MIPS Release 6 instructions natively, and
- * supports obsoleted R1..R5 instructions only via kernel traps.
- *
- * MSA:
- * CPU supports Mips SIMD Architecture instructions.
- */
-enum {
- ANDROID_CPU_MIPS_FEATURE_R6 = (1 << 0),
- ANDROID_CPU_MIPS_FEATURE_MSA = (1 << 1),
-};
-
-
-/* Return the number of CPU cores detected on this device. */
-extern int android_getCpuCount(void);
-
-/* The following is used to force the CPU count and features
- * mask in sandboxed processes. Under 4.1 and higher, these processes
- * cannot access /proc, which is the only way to get information from
- * the kernel about the current hardware (at least on ARM).
- *
- * It _must_ be called only once, and before any android_getCpuXXX
- * function, any other case will fail.
- *
- * This function return 1 on success, and 0 on failure.
- */
-extern int android_setCpu(int cpu_count,
- uint64_t cpu_features);
-
-#ifdef __arm__
-/* Retrieve the ARM 32-bit CPUID value from the kernel.
- * Note that this cannot work on sandboxed processes under 4.1 and
- * higher, unless you called android_setCpuArm() before.
- */
-extern uint32_t android_getCpuIdArm(void);
-
-/* An ARM-specific variant of android_setCpu() that also allows you
- * to set the ARM CPUID field.
- */
-extern int android_setCpuArm(int cpu_count,
- uint64_t cpu_features,
- uint32_t cpu_id);
-#endif
-
-__END_DECLS
-
-#endif /* CPU_FEATURES_H */
diff --git a/contrib/libs/freetype/.yandex_meta/__init__.py b/contrib/libs/freetype/.yandex_meta/__init__.py
deleted file mode 100644
index 7b79bd5d36..0000000000
--- a/contrib/libs/freetype/.yandex_meta/__init__.py
+++ /dev/null
@@ -1,68 +0,0 @@
-import os
-import shutil
-
-from devtools.yamaker.modules import Linkable, Switch
-from devtools.yamaker.project import GNUMakeNixProject
-
-
-def post_install(self):
- # These directories contain generated includes which
- # are copied from source in include/freetype/config
- shutil.rmtree(os.path.join(self.dstdir, "builds"))
- shutil.rmtree(os.path.join(self.dstdir, "objs"))
- with self.yamakes["."] as m:
- m.ADDINCL.remove(os.path.join(self.arcdir, "builds/unix"))
- m.ADDINCL.remove(os.path.join(self.arcdir, "objs"))
- m.ADDINCL.add(os.path.join(self.arcdir, "include/freetype/config"))
- m.CFLAGS.remove("-DFT_DEBUG_LEVEL_TRACE")
- m.CFLAGS.remove("-DFT_DEBUG_LOGGING")
- m.CFLAGS.remove("-DFT_CONFIG_CONFIG_H=<ftconfig.h>")
- m.CFLAGS.remove("-DFT_CONFIG_MODULES_H=<ftmodule.h>")
- m.CFLAGS.remove("-DFT_CONFIG_OPTIONS_H=<ftoption.h>")
- m.SRCS.remove("builds/unix/ftsystem.c")
- m.SRCS.add("src/base/ftsystem.c")
- m.after("SRCS", Switch(OS_DARWIN=Linkable(SRCS=["src/base/ftmac.c"])))
-
-
-freetype = GNUMakeNixProject(
- owners=["g:cpp-contrib"],
- arcdir="contrib/libs/freetype",
- nixattr="freetype",
- flags=[
- "--enable-biarch-config",
- "--without-bzip2",
- ],
- disable_includes=[
- "adler32.c",
- "brotli/decode.h",
- "bzlib.h",
- "crc32.c",
- "ft-hb.h",
- "ftimage.h",
- "ftmisc.h",
- "inffast.c",
- "inflate.c",
- "inftrees.c",
- "hb.h",
- "hb-ft.h",
- "hb-ot.h",
- "openssl/md5.h",
- "png.h",
- "zutil.c",
- ],
- addincl_global={
- ".": {"./include"},
- },
- copy_sources=[
- "docs/*",
- "include/freetype/ftmac.h",
- "include/freetype/config/ftconfig.h",
- "include/freetype/config/ftoption.h",
- "include/freetype/config/ftmodule.h",
- "src/base/ftmac.c",
- "src/base/ftsystem.c",
- ],
- ignore_commands=["bash"],
- install_targets=["freetype"],
- post_install=post_install,
-)
diff --git a/contrib/libs/freetype/.yandex_meta/devtools.copyrights.report b/contrib/libs/freetype/.yandex_meta/devtools.copyrights.report
deleted file mode 100644
index e8543d2866..0000000000
--- a/contrib/libs/freetype/.yandex_meta/devtools.copyrights.report
+++ /dev/null
@@ -1,1407 +0,0 @@
-# File format ($ symbol means the beginning of a line):
-#
-# $ # this message
-# $ # =======================
-# $ # comments (all commentaries should starts with some number of spaces and # symbol)
-# ${action} {license id} {license text hash}
-# $BELONGS ./ya/make/file/relative/path/1/ya.make ./ya/make/2/ya.make
-# ${all_file_action} filename
-# $ # user commentaries (many lines)
-# $ generated description - files with this license, license text... (some number of lines that starts with some number of spaces, do not modify)
-# ${action} {license spdx} {license text hash}
-# $BELONGS ./ya/make/file/relative/path/3/ya.make
-# ${all_file_action} filename
-# $ # user commentaries
-# $ generated description
-# $ ...
-#
-# You can modify action, all_file_action and add commentaries
-# Available actions:
-# keep - keep license in contrib and use in credits
-# skip - skip license
-# remove - remove all files with this license
-# rename - save license text/links into licenses texts file, but not store SPDX into LINCENSE macro. You should store correct license id into devtools.license.spdx.txt file
-#
-# {all file action} records will be generated when license text contains filename that exists on filesystem (in contrib directory)
-# We suppose that that files can contain some license info
-# Available all file actions:
-# FILE_IGNORE - ignore file (do nothing)
-# FILE_INCLUDE - include all file data into licenses text file
-# =======================
-
-KEEP COPYRIGHT_SERVICE_LABEL 05eab326a2bb43e6277e3402e60b62e3
-BELONGS ya.make
- License text:
- * Copyright (C) 2013-2024 by
- * Google, Inc.
- * Written by Stuart Gill and Behdad Esfahbod.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/sfnt/pngshim.c [7:9]
- src/sfnt/pngshim.h [7:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL 0c1ded5f70c7094d63317535666157ac
-BELONGS ya.make
- License text:
- Copyright 2000, 2001, 2004 by
- Francesco Zappa Nardelli
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/pcf/pcfutil.h [5:6]
-
-KEEP COPYRIGHT_SERVICE_LABEL 114bc993e0bf3fd09ce55664c6fbc5b9
-BELONGS ya.make
- License text:
- * Copyright (C) 2007-2024 by
- * Dereg Clegg and Michael Toftdal.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- include/freetype/ftcid.h [7:8]
-
-KEEP COPYRIGHT_SERVICE_LABEL 160af8662b27f4b19ce72e59be67a182
-BELONGS ya.make
- License text:
- Copyright (C) 2018-2024 by
- Nikhil Ramakrishnan, David Turner, Robert Wilhelm, and Werner Lemberg.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- docs/DOCGUIDE [288:289]
-
-KEEP COPYRIGHT_SERVICE_LABEL 161cf70918551cc974cc2d64ca7397ad
-BELONGS ya.make
- License text:
- Copyright 1996-2002, 2006 by
- David Turner, Robert Wilhelm, and Werner Lemberg
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- docs/FTL.TXT [6:7]
-
-KEEP COPYRIGHT_SERVICE_LABEL 1961a1d330871654ef346aeeea3d1370
-BELONGS ya.make
- License text:
- Copyright (C) 2001-2002 by Francesco Zappa Nardelli
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/bdf/README [102:102]
-
-KEEP COPYRIGHT_SERVICE_LABEL 1a2e27be29f9fc0bf43bd2f18676f1b4
-BELONGS ya.make
- License text:
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- * Copyright 2003 Huw D M Davies for Codeweavers
- * Copyright 2007 Dmitry Timoshkov for Codeweavers
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/winfonts/winfnt.c [7:10]
- src/winfonts/winfnt.h [7:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL 1e47cec4075861cad1ec7aecfb812349
-BELONGS ya.make
- License text:
- * Copyright (C) 2005-2024 by
- * David Turner.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/lzw/ftzopen.c [11:12]
- src/lzw/ftzopen.h [11:12]
-
-KEEP COPYRIGHT_SERVICE_LABEL 224ab6b162d99e65fb7ff65834660b8a
-BELONGS ya.make
- License text:
- * Copyright (C) 2004-2024 by
- * David Turner, Robert Wilhelm, Werner Lemberg and George Williams.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/truetype/ttgxvar.h [7:8]
-
-KEEP COPYRIGHT_SERVICE_LABEL 24564aa94b7367facbfdc45683cbc6b7
-BELONGS ya.make
- License text:
- * Copyright (C) 2007-2024 by
- * David Turner.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- include/freetype/internal/services/svttglyf.h [7:8]
- src/base/ftpatent.c [8:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL 24b874ed2f2d777fe67244afd2e5ce45
-BELONGS ya.make
- License text:
- * Copyright (C) 2022-2024 by
- * David Turner, Robert Wilhelm, Werner Lemberg, and Moazin Khatti.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- include/freetype/internal/svginterface.h [7:8]
- include/freetype/otsvg.h [7:8]
- src/sfnt/ttsvg.c [7:8]
- src/sfnt/ttsvg.h [7:8]
- src/svg/ftsvg.c [7:8]
- src/svg/ftsvg.h [7:8]
- src/svg/svg.c [7:8]
- src/svg/svgtypes.h [7:8]
-
-KEEP COPYRIGHT_SERVICE_LABEL 26287154437da4082b06efc4bbd6a904
-BELONGS ya.make
- License text:
- * Copyright (C) 2016-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- include/freetype/internal/services/svmetric.h [7:8]
-
-KEEP COPYRIGHT_SERVICE_LABEL 30527b4b3821df90f4d70cb3166409cf
-BELONGS ya.make
- License text:
- Copyright (C) 2002-2024 by
- David Turner, Robert Wilhelm, and Werner Lemberg.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- docs/DEBUG [300:301]
- docs/VERSIONS.TXT [128:129]
- include/freetype/config/ftstdlib.h [8:9]
- include/freetype/ftbdf.h [7:8]
- include/freetype/fterrdef.h [7:8]
- include/freetype/ftfntfmt.h [7:8]
- include/freetype/ftgzip.h [7:8]
- include/freetype/ftincrem.h [7:8]
- include/freetype/ftpfr.h [7:8]
- include/freetype/ftstroke.h [7:8]
- include/freetype/internal/ftgloadr.h [7:8]
- include/freetype/internal/fttrace.h [7:8]
- src/base/ftbdf.c [7:8]
- src/base/ftfntfmt.c [7:8]
- src/base/ftgloadr.c [7:8]
- src/base/ftpfr.c [7:8]
- src/base/ftstroke.c [7:8]
- src/base/fttype1.c [7:8]
- src/base/ftutil.c [7:8]
- src/cff/cffcmap.c [7:8]
- src/cff/cffcmap.h [7:8]
- src/gzip/ftgzip.c [11:12]
- src/pfr/pfr.c [7:8]
- src/pfr/pfrcmap.c [7:8]
- src/pfr/pfrcmap.h [7:8]
- src/pfr/pfrdrivr.c [7:8]
- src/pfr/pfrdrivr.h [7:8]
- src/pfr/pfrerror.h [7:8]
- src/pfr/pfrgload.c [7:8]
- src/pfr/pfrgload.h [7:8]
- src/pfr/pfrload.c [7:8]
- src/pfr/pfrload.h [7:8]
- src/pfr/pfrobjs.c [7:8]
- src/pfr/pfrobjs.h [7:8]
- src/pfr/pfrsbit.c [7:8]
- src/pfr/pfrsbit.h [7:8]
- src/pfr/pfrtypes.h [7:8]
- src/psaux/t1cmap.c [7:8]
- src/psaux/t1cmap.h [7:8]
- src/sfnt/ttcmap.c [7:8]
- src/sfnt/ttcmap.h [7:8]
- src/type42/t42error.h [7:8]
- src/type42/type42.c [7:8]
-
-KEEP COPYRIGHT_SERVICE_LABEL 331da52bb84c1ebba5fe104b95765568
-BELONGS ya.make
- License text:
- Copyright (C) 2000, 2001, 2002, 2003, 2006, 2010 by
- Francesco Zappa Nardelli
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/pcf/pcf.h [5:6]
-
-KEEP COPYRIGHT_SERVICE_LABEL 356ca27d9304a998d8b81bf56037f07e
-BELONGS ya.make
- License text:
- * Copyright © 2009, 2023 Red Hat, Inc.
- * Copyright © 2015 Google, Inc.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/autofit/ft-hb.c [2:3]
-
-KEEP COPYRIGHT_SERVICE_LABEL 35e28ca9dde5b932e96138203e529472
-BELONGS ya.make
- License text:
- Copyright (C) 2001-2008, 2011, 2013, 2014 by
- Francesco Zappa Nardelli
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/bdf/bdfdrivr.c [5:6]
-
-KEEP COPYRIGHT_SERVICE_LABEL 35e7b27b28739ab9882b8043f46df2c8
-BELONGS ya.make
- License text:
- * Copyright 2006-2013 Adobe Systems Incorporated.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/psaux/pserror.c [7:7]
- src/psaux/pserror.h [7:7]
-
-KEEP COPYRIGHT_SERVICE_LABEL 36f4d6aa0c63b8f12c15047ba79df945
-BELONGS ya.make
- License text:
- * Copyright (C) 2013-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/autofit/afblue.c [10:11]
- src/autofit/afblue.h [10:11]
- src/autofit/afcover.h [7:8]
- src/autofit/afranges.c [7:8]
- src/autofit/afranges.h [7:8]
- src/autofit/afscript.h [7:8]
- src/autofit/afshaper.c [7:8]
- src/autofit/afshaper.h [7:8]
- src/autofit/afstyles.h [7:8]
- src/autofit/afws-decl.h [7:8]
- src/autofit/afws-iter.h [7:8]
-
-KEEP COPYRIGHT_SERVICE_LABEL 38db777b6b56373068b835a5870e3a7a
-BELONGS ya.make
- License text:
- * Copyright (C) 2018-2024 by
- * David Turner, Robert Wilhelm, Dominik Röttsches, and Werner Lemberg.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/sfnt/ttcolr.c [7:8]
-
-KEEP COPYRIGHT_SERVICE_LABEL 3b51a383362336e7d8857dff7a6a23ea
-BELONGS ya.make
- License text:
- Copyright (C) 2001, 2002, 2003, 2004 by
- Francesco Zappa Nardelli
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/bdf/bdfdrivr.h [5:6]
-
-KEEP COPYRIGHT_SERVICE_LABEL 3b85c10c1574ed7204356fa730b0b53a
-BELONGS ya.make
- License text:
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- include/freetype/config/ftconfig.h [7:8]
- include/freetype/config/ftheader.h [7:8]
- include/freetype/config/ftoption.h [7:8]
- include/freetype/config/integer-types.h [7:8]
- include/freetype/config/mac-support.h [7:8]
- include/freetype/freetype.h [7:8]
- include/freetype/ftbbox.h [7:8]
- include/freetype/ftcache.h [7:8]
- include/freetype/fterrors.h [7:8]
- include/freetype/ftglyph.h [7:8]
- include/freetype/ftimage.h [8:9]
- include/freetype/ftlist.h [7:8]
- include/freetype/ftmm.h [7:8]
- include/freetype/ftmodapi.h [7:8]
- include/freetype/ftoutln.h [8:9]
- include/freetype/ftrender.h [7:8]
- include/freetype/ftsizes.h [7:8]
- include/freetype/ftsnames.h [10:11]
- include/freetype/ftsystem.h [7:8]
- include/freetype/fttypes.h [7:8]
- include/freetype/internal/autohint.h [7:8]
- include/freetype/internal/cfftypes.h [8:9]
- include/freetype/internal/ftcalc.h [7:8]
- include/freetype/internal/ftdebug.h [7:8]
- include/freetype/internal/ftdrv.h [7:8]
- include/freetype/internal/ftmemory.h [7:8]
- include/freetype/internal/ftobjs.h [7:8]
- include/freetype/internal/ftstream.h [7:8]
- include/freetype/internal/psaux.h [8:9]
- include/freetype/internal/sfnt.h [7:8]
- include/freetype/internal/t1types.h [8:9]
- include/freetype/internal/tttypes.h [8:9]
- include/freetype/internal/wofftypes.h [8:9]
- include/freetype/t1tables.h [8:9]
- include/freetype/ttnameid.h [7:8]
- include/freetype/tttables.h [8:9]
- include/freetype/tttags.h [7:8]
- include/ft2build.h [7:8]
- src/base/ftbase.c [7:8]
- src/base/ftbbox.c [7:8]
- src/base/ftcalc.c [7:8]
- src/base/ftdebug.c [7:8]
- src/base/ftglyph.c [7:8]
- src/base/ftinit.c [7:8]
- src/base/ftmm.c [7:8]
- src/base/ftobjs.c [7:8]
- src/base/ftoutln.c [7:8]
- src/base/ftsnames.c [10:11]
- src/base/ftsystem.c [7:8]
- src/cff/cff.c [7:8]
- src/cff/cffdrivr.h [7:8]
- src/cff/cffgload.c [7:8]
- src/cff/cffgload.h [7:8]
- src/cff/cffload.c [7:8]
- src/cff/cffload.h [7:8]
- src/cff/cffobjs.c [7:8]
- src/cff/cffobjs.h [7:8]
- src/cff/cffparse.c [7:8]
- src/cff/cffparse.h [7:8]
- src/cff/cfftoken.h [7:8]
- src/cid/cidgload.c [7:8]
- src/cid/cidgload.h [7:8]
- src/cid/cidload.c [7:8]
- src/cid/cidload.h [7:8]
- src/cid/cidobjs.c [7:8]
- src/cid/cidobjs.h [7:8]
- src/cid/cidparse.c [7:8]
- src/cid/cidparse.h [7:8]
- src/cid/cidriver.c [7:8]
- src/cid/cidriver.h [7:8]
- src/cid/cidtoken.h [7:8]
- src/cid/type1cid.c [7:8]
- src/psaux/psaux.c [7:8]
- src/psaux/psobjs.c [7:8]
- src/psaux/psobjs.h [7:8]
- src/psnames/psmodule.c [7:8]
- src/psnames/psmodule.h [7:8]
- src/psnames/psnames.c [7:8]
- src/raster/ftraster.c [7:8]
- src/raster/ftraster.h [7:8]
- src/raster/ftrend1.c [7:8]
- src/raster/ftrend1.h [7:8]
- src/raster/raster.c [7:8]
- src/sfnt/sfdriver.c [7:8]
- src/sfnt/sfdriver.h [7:8]
- src/sfnt/sfnt.c [7:8]
- src/sfnt/sfobjs.c [7:8]
- src/sfnt/sfobjs.h [7:8]
- src/sfnt/sfwoff.c [7:8]
- src/sfnt/sfwoff.h [7:8]
- src/sfnt/ttkern.c [8:9]
- src/sfnt/ttkern.h [8:9]
- src/sfnt/ttload.c [8:9]
- src/sfnt/ttload.h [8:9]
- src/sfnt/ttpost.c [8:9]
- src/sfnt/ttpost.h [8:9]
- src/sfnt/ttsbit.h [7:8]
- src/smooth/ftgrays.h [7:8]
- src/smooth/ftsmooth.h [7:8]
- src/smooth/smooth.c [7:8]
- src/truetype/truetype.c [7:8]
- src/truetype/ttdriver.c [7:8]
- src/truetype/ttdriver.h [7:8]
- src/truetype/ttgload.c [7:8]
- src/truetype/ttgload.h [7:8]
- src/truetype/ttinterp.c [7:8]
- src/truetype/ttinterp.h [7:8]
- src/truetype/ttobjs.c [7:8]
- src/truetype/ttobjs.h [7:8]
- src/truetype/ttpload.c [7:8]
- src/truetype/ttpload.h [7:8]
- src/type1/t1afm.c [7:8]
- src/type1/t1afm.h [7:8]
- src/type1/t1driver.c [7:8]
- src/type1/t1driver.h [7:8]
- src/type1/t1gload.c [7:8]
- src/type1/t1gload.h [7:8]
- src/type1/t1load.c [7:8]
- src/type1/t1load.h [7:8]
- src/type1/t1objs.c [7:8]
- src/type1/t1objs.h [7:8]
- src/type1/t1parse.c [7:8]
- src/type1/t1parse.h [7:8]
- src/type1/t1tokens.h [7:8]
- src/type1/type1.c [7:8]
- src/winfonts/winfnt.c [7:10]
- src/winfonts/winfnt.h [7:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL 3c8dbb1104a58dda0585967f536f0b19
-BELONGS ya.make
- License text:
- * Copyright (C) 2018-2024 by
- * Armin Hasitzka, David Turner, Robert Wilhelm, and Werner Lemberg.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/base/fterrors.c [7:8]
-
-KEEP COPYRIGHT_SERVICE_LABEL 413b336c8a69cac2f76c8dd47992b725
-BELONGS ya.make
- License text:
- Copyright (C) <year> Free Software Foundation Inc.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- docs/INSTALL.UNIX [20:20]
-
-KEEP COPYRIGHT_SERVICE_LABEL 42309f641131ece0512293952b16361e
-BELONGS ya.make
- License text:
- Copyright 1990, 1994, 1998 The Open Group
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/pcf/pcfutil.c [3:3]
-
-KEEP COPYRIGHT_SERVICE_LABEL 42ee344b2adbd5d64451f6d1c8d2debe
-BELONGS ya.make
- License text:
- * Copyright (C) 2004-2024 by
- * Masatake YAMATO and Redhat K.K.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- include/freetype/internal/ftrfork.h [7:8]
- src/base/ftrfork.c [7:8]
-
-KEEP COPYRIGHT_SERVICE_LABEL 44c4aee6bd3a8ce9348e53ec660b48d0
-BELONGS ya.make
- License text:
- * Copyright © 2009, 2023 Red Hat, Inc.
- * Copyright © 2015 Google, Inc.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/autofit/ft-hb.c [2:3]
-
-KEEP COPYRIGHT_SERVICE_LABEL 4540a5351f0d389254fa0cc075df18dd
-BELONGS ya.make
- License text:
- Copyright (C) 2005-2024 by
- David Turner, Robert Wilhelm, and Werner Lemberg.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- README.git [92:93]
- src/autofit/aferrors.h [7:8]
- src/psnames/pstables.h [7:8]
- src/sfnt/ttbdf.c [7:8]
- src/sfnt/ttbdf.h [7:8]
- src/sfnt/ttsbit.c [7:8]
-
-KEEP COPYRIGHT_SERVICE_LABEL 4a0a5fa80fb4ffa8c1a89c3cdeaf8efb
-BELONGS ya.make
- License text:
- // Copyright (c) 2019 nyorain
- // Distributed under the Boost Software License, Version 1.0.
- // See accompanying file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- include/dlg/dlg.h [1:3]
- include/dlg/output.h [1:3]
- src/dlg/dlg.c [1:3]
-
-KEEP COPYRIGHT_SERVICE_LABEL 4ca50c7fb28140387ce302143b7a2b82
-BELONGS ya.make
- License text:
- Copyright (C) 2000-2004, 2006-2011, 2013, 2014 by
- Francesco Zappa Nardelli
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/pcf/pcfdrivr.c [5:6]
-
-KEEP COPYRIGHT_SERVICE_LABEL 4d7dea98c4742fe78f3c20ad48ae35d3
-BELONGS ya.make
- License text:
- The FreeType Project is copyright (C) 1996-2000 by David Turner,
- Robert Wilhelm, and Werner Lemberg. All rights reserved except as
- specified below.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- docs/FTL.TXT [84:86]
-
-KEEP COPYRIGHT_SERVICE_LABEL 4e8c7994fd2cca6965129defbd93b3cf
-BELONGS ya.make
- License text:
- * Copyright (C) 2003-2024 by
- * Masatake YAMATO, Redhat K.K.,
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- include/freetype/internal/services/svttcmap.h [7:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL 50795e775be30dcc0afc1ac43da22e98
-BELONGS ya.make
- License text:
- * Copyright 2000 Computing Research Labs, New Mexico State University
- * Copyright 2001-2014
- * Francesco Zappa Nardelli
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/bdf/bdflib.c [2:4]
-
-KEEP COPYRIGHT_SERVICE_LABEL 51eb35687fcd42f4d4f2dea0054a8f79
-BELONGS ya.make
- License text:
- * Copyright 2001, 2012 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/pcf/pcferror.h [7:8]
-
-KEEP COPYRIGHT_SERVICE_LABEL 556351e9242d726f11f413b590e295f2
-BELONGS ya.make
- License text:
- * Copyright (C) 2024 by
- * David Saltzman
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/sfnt/ttgpos.c [15:16]
- src/sfnt/ttgpos.h [9:10]
-
-KEEP COPYRIGHT_SERVICE_LABEL 56a118a263857e7ae4e06f4f1499e3dc
-BELONGS ya.make
- License text:
- Copyright 2000-2001, 2002 by
- Francesco Zappa Nardelli
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/pcf/pcfdrivr.h [5:6]
-
-KEEP COPYRIGHT_SERVICE_LABEL 58a30d22eb5d32504a330e4d1a223156
-BELONGS ya.make
- License text:
- * Copyright 2007-2013 Adobe Systems Incorporated.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/psaux/psarrst.c [7:7]
- src/psaux/psarrst.h [7:7]
- src/psaux/psfixed.h [7:7]
- src/psaux/psfont.h [7:7]
- src/psaux/psglue.h [7:7]
- src/psaux/pshints.h [7:7]
- src/psaux/psintrp.h [7:7]
- src/psaux/psread.c [7:7]
- src/psaux/psread.h [7:7]
- src/psaux/psstack.c [7:7]
- src/psaux/psstack.h [7:7]
-
-KEEP COPYRIGHT_SERVICE_LABEL 5b592224d6f5ec146b33656387cf92b8
-BELONGS ya.make
- License text:
- Copyright (C) 2001, 2002 by
- Francesco Zappa Nardelli
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/bdf/bdf.c [5:6]
-
-KEEP COPYRIGHT_SERVICE_LABEL 5c3fb6d40a18291906da96f112e50c12
-BELONGS ya.make
- License text:
- * Copyright (C) 2007-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- include/freetype/ftgasp.h [7:8]
- src/base/ftgasp.c [7:8]
-
-KEEP COPYRIGHT_SERVICE_LABEL 5e793949ac414e425d2618b94810d5ed
-BELONGS ya.make
- License text:
- Copyright 2000 Computing Research Labs, New Mexico State University
- Copyright 2001-2002, 2011 Francesco Zappa Nardelli
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/bdf/README [125:126]
-
-KEEP COPYRIGHT_SERVICE_LABEL 6a8e93fe0fbd4dee57108d99199610e5
-BELONGS ya.make
- License text:
- * Copyright (C) 1996-2024 by
- * Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- include/freetype/ftmac.h [7:8]
- src/base/ftmac.c [11:12]
-
-KEEP COPYRIGHT_SERVICE_LABEL 75b6726172f54ed2031b5588f513cf99
-BELONGS ya.make
- License text:
- * Copyright (C) 2008-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- include/freetype/ftadvanc.h [7:8]
- src/base/ftadvanc.c [7:8]
- src/base/ftfstype.c [7:8]
-
-KEEP COPYRIGHT_SERVICE_LABEL 77bc1ba799c4986f14138f26293a6200
-BELONGS ya.make
- License text:
- * Copyright (C) 2007-2024 by
- * Derek Clegg and Michael Toftdal.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- include/freetype/internal/services/svcid.h [7:8]
- src/base/ftcid.c [7:8]
-
-KEEP COPYRIGHT_SERVICE_LABEL 7b53ca5f33a3f0903d36a3849ee0e0d6
-BELONGS ya.make
- License text:
- * Copyright 2013 Adobe Systems Incorporated.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/psaux/psft.h [7:7]
-
-KEEP COPYRIGHT_SERVICE_LABEL 7c22c32170062458bc3f503abe9d57e1
-BELONGS ya.make
- License text:
- * Copyright (C) 2003-2024 by
- * David Turner, Robert Wilhelm, Werner Lemberg, and Dominik Röttsches.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- include/freetype/internal/services/svmm.h [7:8]
-
-KEEP COPYRIGHT_SERVICE_LABEL 7d96c9e595e12f8f64315e47103ec214
-BELONGS ya.make
- License text:
- * Copyright 2007-2014 Adobe Systems Incorporated.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/psaux/psfont.c [7:7]
- src/psaux/pshints.c [7:7]
- src/psaux/psintrp.c [7:7]
-
-KEEP COPYRIGHT_SERVICE_LABEL 7daa9169fec0e0696d7bf34fa9ae9cb2
-BELONGS ya.make
- License text:
- * Copyright (C) 2017-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- include/freetype/ftdriver.h [7:8]
- include/freetype/ftparams.h [7:8]
- include/freetype/internal/cffotypes.h [7:8]
- include/freetype/internal/ftpsprop.h [7:8]
- include/freetype/internal/services/svcfftl.h [7:8]
- src/base/ftpsprop.c [8:9]
- src/psaux/cffdecode.c [7:8]
- src/psaux/cffdecode.h [7:8]
-
-KEEP COPYRIGHT_SERVICE_LABEL 83a264e41249a991fc59d5cbb8981cd2
-BELONGS ya.make
- License text:
- Portions of this software are copyright © <year> The FreeType
- Project (www.freetype.org). All rights reserved.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- docs/FTL.TXT [51:52]
-
-KEEP COPYRIGHT_SERVICE_LABEL 8893f9fb3ea576d98200a0718fa92f36
-BELONGS ya.make
- License text:
- Copyright (C) 2003-2024 by
- David Turner, Robert Wilhelm, and Werner Lemberg.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- docs/CUSTOMIZE [142:143]
- docs/INSTALL.ANY [147:148]
- docs/INSTALL.GNU [171:172]
- docs/INSTALL.UNIX [129:130]
- docs/raster.txt [621:622]
- docs/release [214:215]
- include/freetype/ftwinfnt.h [7:8]
- include/freetype/internal/ftserv.h [7:8]
- include/freetype/internal/services/svbdf.h [7:8]
- include/freetype/internal/services/svfntfmt.h [7:8]
- include/freetype/internal/services/svgldict.h [7:8]
- include/freetype/internal/services/svpfr.h [7:8]
- include/freetype/internal/services/svpostnm.h [7:8]
- include/freetype/internal/services/svpscmap.h [7:8]
- include/freetype/internal/services/svpsinfo.h [7:8]
- include/freetype/internal/services/svsfnt.h [7:8]
- include/freetype/internal/services/svwinfnt.h [7:8]
- src/autofit/afdummy.c [8:9]
- src/autofit/afdummy.h [8:9]
- src/autofit/afglobal.c [7:8]
- src/autofit/afglobal.h [8:9]
- src/autofit/afhints.c [7:8]
- src/autofit/afhints.h [7:8]
- src/autofit/aflatin.c [7:8]
- src/autofit/aflatin.h [8:9]
- src/autofit/afloader.c [7:8]
- src/autofit/afloader.h [7:8]
- src/autofit/afmodule.c [7:8]
- src/autofit/afmodule.h [7:8]
- src/autofit/aftypes.h [7:8]
- src/autofit/autofit.c [7:8]
- src/base/ftwinfnt.c [7:8]
- src/cache/ftcbasic.c [7:8]
- src/cache/ftcmru.c [7:8]
- src/pshinter/pshnterr.h [7:8]
-
-KEEP COPYRIGHT_SERVICE_LABEL 8cf91579d8cb4087b6bd775cd2b2bbed
-BELONGS ya.make
- License text:
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- docs/GPLv2.TXT [4:6]
-
-KEEP COPYRIGHT_SERVICE_LABEL 8e3d3c17374f6d3419e05b87929177d4
-BELONGS ya.make
- License text:
- * Copyright (C) 2004-2024 by
- * Albert Chin-A-Young.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/lzw/ftlzw.c [11:12]
-
-KEEP COPYRIGHT_SERVICE_LABEL 97ce76ca0d5f5fa693b30f19531299c2
-BELONGS ya.make
- License text:
- * Copyright (C) 2019-2024 by
- * Nikhil Ramakrishnan, David Turner, Robert Wilhelm, and Werner Lemberg.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/sfnt/sfwoff2.c [7:8]
- src/sfnt/sfwoff2.h [7:8]
- src/sfnt/woff2tags.c [7:8]
- src/sfnt/woff2tags.h [7:8]
-
-KEEP COPYRIGHT_SERVICE_LABEL 990685689dbf7a402a858630ff899227
-BELONGS ya.make
- License text:
- * Copyright (C) 2008-2024 by
- * David Turner, Robert Wilhelm, Werner Lemberg, and suzuki toshiya.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/base/ftbase.h [7:8]
-
-KEEP COPYRIGHT_SERVICE_LABEL 9cc21435e8bf8498034a7670cb1697bf
-BELONGS ya.make
- License text:
- Copyright (C) 2000 by Francesco Zappa Nardelli
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/pcf/README [69:69]
-
-KEEP COPYRIGHT_SERVICE_LABEL 9dd10d760975b3722ce890536654e2c8
-BELONGS ya.make
- License text:
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- * Copyright 2003 Huw D M Davies for Codeweavers
- * Copyright 2007 Dmitry Timoshkov for Codeweavers
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/winfonts/winfnt.c [7:10]
-
-KEEP COPYRIGHT_SERVICE_LABEL a5a6d92442a6fde5d049c0bf6ab31eaf
-BELONGS ya.make
- License text:
- Copyright 2000-2001, 2003 by
- Francesco Zappa Nardelli
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/pcf/pcf.c [5:6]
-
-KEEP COPYRIGHT_SERVICE_LABEL aa2cfbf1f2b3df8d7c284df06e4d8041
-BELONGS ya.make
- License text:
- Copyright (C) 2000-2024 by
- David Turner, Robert Wilhelm, and Werner Lemberg.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- docs/INSTALL [104:105]
- docs/INSTALL.VMS [59:60]
- include/freetype/ftsynth.h [8:9]
- src/base/ftstream.c [7:8]
- src/base/ftsynth.c [7:8]
- src/cache/ftcache.c [7:8]
- src/cache/ftccache.c [7:8]
- src/cache/ftccache.h [7:8]
- src/cache/ftccmap.c [7:8]
- src/cache/ftcglyph.c [7:8]
- src/cache/ftcglyph.h [7:8]
- src/cache/ftcimage.c [7:8]
- src/cache/ftcimage.h [7:8]
- src/cache/ftcmanag.c [7:8]
- src/cache/ftcmanag.h [7:8]
- src/cache/ftcmru.h [7:8]
- src/cache/ftcsbits.c [7:8]
- src/cache/ftcsbits.h [7:8]
- src/psaux/psauxmod.c [7:8]
- src/psaux/psauxmod.h [7:8]
- src/psaux/t1decode.c [7:8]
- src/psaux/t1decode.h [7:8]
- src/smooth/ftgrays.c [7:8]
- src/smooth/ftsmooth.c [7:8]
-
-KEEP COPYRIGHT_SERVICE_LABEL aa95f63069fda02fa7f92613b24b40e7
-BELONGS ya.make
- License text:
- * Copyright (C) 2009-2024 by
- * Oran Agra and Mickey Gabel.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/sfnt/ttcmapc.h [7:8]
-
-KEEP COPYRIGHT_SERVICE_LABEL ac4f7dfdb18b55b994bce75260762462
-BELONGS ya.make
- License text:
- * Copyright (C) 2022-2024 by
- * David Turner, Robert Wilhelm, Werner Lemberg, George Williams, and
- * Dominik Röttsches.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- include/freetype/internal/ftmmtypes.h [8:10]
-
-KEEP COPYRIGHT_SERVICE_LABEL acb4a512f7200d137d0ab1859224f1ef
-BELONGS ya.make
- License text:
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, Werner Lemberg, and Dominik Röttsches.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/cff/cffdrivr.c [7:8]
-
-KEEP COPYRIGHT_SERVICE_LABEL b0755dc0e11bb697a29bd7de0ecaaeae
-BELONGS ya.make
- License text:
- * Copyright 2011-2013 Adobe Systems Incorporated.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/psaux/pstypes.h [7:7]
-
-KEEP COPYRIGHT_SERVICE_LABEL b51dbe39e416004833ab451cc4934fc8
-BELONGS ya.make
- License text:
- * Copyright (C) 2018-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- include/freetype/ftcolor.h [7:8]
- src/base/ftcolor.c [7:8]
- src/sfnt/ttcolr.h [7:8]
- src/sfnt/ttcpal.c [7:8]
- src/sfnt/ttcpal.h [7:8]
-
-KEEP COPYRIGHT_SERVICE_LABEL b8bce245a3ae4f67ad3052c16a4850d5
-BELONGS ya.make
- License text:
- * Copyright (C) 2004-2024 by
- * Masatake YAMATO, Redhat K.K,
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- include/freetype/ftgxval.h [7:9]
- src/base/ftgxval.c [7:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL b917aed0d74d5a994cbd4448bbe686a0
-BELONGS ya.make
- License text:
- * Copyright 2013-2014 Adobe Systems Incorporated.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/psaux/psft.c [7:7]
-
-KEEP COPYRIGHT_SERVICE_LABEL beb0d0fcde838baf609a39a63ead919a
-BELONGS ya.make
- License text:
- Copyright (C) 2006-2024 by
- suzuki toshiya, David Turner, Robert Wilhelm, and Werner Lemberg.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- docs/INSTALL.CROSS [166:167]
-
-KEEP COPYRIGHT_SERVICE_LABEL c0a580767e4df988cbeb3a33fe57d251
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- docs/GPLv2.TXT [251:256]
-
-KEEP COPYRIGHT_SERVICE_LABEL c253caf08281212270432e30c46c9193
-BELONGS ya.make
- License text:
- * Copyright 2013 by Google, Inc.
- * Google Author(s): Behdad Esfahbod.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/sfnt/ttsbit.c [10:11]
-
-KEEP COPYRIGHT_SERVICE_LABEL c298d16e5bf9812b4c38dbca7faf5c50
-BELONGS ya.make
- License text:
- * Copyright 2000 Computing Research Labs, New Mexico State University
- * Copyright 2001-2015
- * Francesco Zappa Nardelli
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- include/freetype/internal/fthash.h [10:12]
- src/base/fthash.c [10:12]
-
-KEEP COPYRIGHT_SERVICE_LABEL c2bead3cb724026c8528c014741db706
-BELONGS ya.make
- License text:
- * Copyright 2009-2014 Adobe Systems Incorporated.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/psaux/psblues.c [7:7]
-
-KEEP COPYRIGHT_SERVICE_LABEL cd020fb7a11edc7d8d6fbd995ebb44e5
-BELONGS ya.make
- License text:
- Copyright (C) 2006-2024 by
- David Turner, Robert Wilhelm, and Werner Lemberg.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- README [97:98]
- include/freetype/ftlcdfil.h [8:9]
- include/freetype/internal/services/svkern.h [7:8]
- include/freetype/internal/services/svtteng.h [7:8]
- src/autofit/afcjk.c [7:8]
- src/autofit/afcjk.h [7:8]
- src/base/ftlcdfil.c [7:8]
- src/psaux/afmparse.c [7:8]
- src/psaux/afmparse.h [7:8]
- src/psaux/psconv.c [7:8]
- src/psaux/psconv.h [7:8]
- src/sfnt/ttmtx.c [7:8]
- src/sfnt/ttmtx.h [7:8]
-
-KEEP COPYRIGHT_SERVICE_LABEL ceafd77116fb61c435ee12b1455c3443
-BELONGS ya.make
- License text:
- * Copyright 2009-2013 Adobe Systems Incorporated.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/psaux/psblues.h [7:7]
-
-KEEP COPYRIGHT_SERVICE_LABEL d394ce0f901e89bb6fc12ebab7f4837b
-BELONGS ya.make
- License text:
- * Copyright 2001, 2002, 2012 Francesco Zappa Nardelli
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/bdf/bdferror.h [2:2]
-
-KEEP COPYRIGHT_SERVICE_LABEL d42f9eacc3f149f0fa3f9326b47c4ffe
-BELONGS ya.make
- License text:
- Copyright 2003 by
- Francesco Zappa Nardelli
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/pcf/pcfread.h [5:6]
-
-KEEP COPYRIGHT_SERVICE_LABEL dc595fed9c07c27a41b0f8c99df43070
-BELONGS ya.make
- License text:
- * Copyright 2000 Computing Research Labs, New Mexico State University
- * Copyright 2001-2015
- * Francesco Zappa Nardelli
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- include/freetype/internal/fthash.h [10:12]
- src/base/fthash.c [10:12]
- src/bdf/README [125:126]
- src/bdf/bdf.h [2:3]
- src/bdf/bdflib.c [2:4]
-
-KEEP COPYRIGHT_SERVICE_LABEL dcdbf8afb24322faad0ffbaf7fe8c522
-BELONGS ya.make
- License text:
- * Copyright (C) 2007-2024 by
- * Rahul Bhalerao <rahul.bhalerao@redhat.com>, <b.rahul.pm@gmail.com>.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/autofit/afindic.c [7:8]
- src/autofit/afindic.h [8:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL dd6c7be6fcef5f110caacec1da61c30f
-BELONGS ya.make
- License text:
- Copyright (C) 2001-2024 by
- David Turner, Robert Wilhelm, and Werner Lemberg.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- docs/TODO [30:31]
- include/freetype/ftmoderr.h [7:8]
- include/freetype/fttrigon.h [7:8]
- include/freetype/internal/pshints.h [9:10]
- src/base/ftdbgmem.c [7:8]
- src/base/fttrigon.c [7:8]
- src/cache/ftcerror.h [7:8]
- src/cff/cfferrs.h [7:8]
- src/cid/ciderrs.h [7:8]
- src/psaux/psauxerr.h [7:8]
- src/pshinter/pshalgo.c [7:8]
- src/pshinter/pshalgo.h [7:8]
- src/pshinter/pshglob.c [8:9]
- src/pshinter/pshglob.h [7:8]
- src/pshinter/pshinter.c [7:8]
- src/pshinter/pshmod.c [7:8]
- src/pshinter/pshmod.h [7:8]
- src/pshinter/pshrec.c [7:8]
- src/pshinter/pshrec.h [7:8]
- src/psnames/psnamerr.h [7:8]
- src/raster/rasterrs.h [7:8]
- src/sfnt/sferrors.h [7:8]
- src/smooth/ftsmerrs.h [7:8]
- src/truetype/tterrors.h [7:8]
- src/type1/t1errors.h [7:8]
- src/winfonts/fnterrs.h [7:8]
-
-KEEP COPYRIGHT_SERVICE_LABEL e10b17801440995c57dfe4f8419502e7
-BELONGS ya.make
- License text:
- * Copyright (C) 2012-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- include/freetype/internal/services/svprop.h [7:8]
-
-KEEP COPYRIGHT_SERVICE_LABEL e1520b049b8cb26c0c1fad0d12487383
-BELONGS ya.make
- License text:
- * Copyright (C) 2020-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- include/freetype/config/public-macros.h [7:8]
- include/freetype/ftlogging.h [7:8]
- include/freetype/internal/compiler-macros.h [7:8]
- src/dlg/dlgwrap.c [7:8]
- src/sdf/ftbsdf.c [7:8]
- src/sdf/ftsdf.c [7:8]
- src/sdf/ftsdf.h [7:8]
- src/sdf/ftsdfcommon.c [7:8]
- src/sdf/ftsdfcommon.h [7:8]
- src/sdf/ftsdferrs.h [7:8]
- src/sdf/ftsdfrend.c [7:8]
- src/sdf/ftsdfrend.h [7:8]
- src/sdf/sdf.c [7:8]
-
-KEEP COPYRIGHT_SERVICE_LABEL e1cf22929c3960b94c8d76f235e2c6dd
-BELONGS ya.make
- License text:
- Copyright (C) 2004-2024 by
- David Turner, Robert Wilhelm, and Werner Lemberg.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- docs/formats.txt [209:210]
- include/freetype/ftbitmap.h [7:8]
- include/freetype/ftlzw.h [7:8]
- include/freetype/ftotval.h [7:8]
- include/freetype/internal/ftvalid.h [7:8]
- include/freetype/internal/services/svotval.h [7:8]
- src/base/ftbitmap.c [7:8]
- src/base/ftotval.c [7:8]
- src/cache/ftccback.h [7:8]
-
-KEEP COPYRIGHT_SERVICE_LABEL e718c2c96499b5763672fde9423d6a9a
-BELONGS ya.make
- License text:
- * Copyright 2000 Computing Research Labs, New Mexico State University
- * Copyright 2001-2004, 2011 Francesco Zappa Nardelli
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/bdf/bdf.h [2:3]
-
-KEEP COPYRIGHT_SERVICE_LABEL e8098daecf46b4d42f8adb664e560ef1
-BELONGS ya.make
- License text:
- * Copyright (C) 2010-2024 by
- * Joel Klinghed.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- include/freetype/ftbzip2.h [7:8]
- src/bzip2/ftbzip2.c [11:12]
-
-KEEP COPYRIGHT_SERVICE_LABEL ee62eb68d7b00b203af02afb0a753e1a
-BELONGS ya.make
- License text:
- * Copyright (C) 2004-2024 by
- * Masatake YAMATO, Red Hat K.K.,
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- include/freetype/internal/services/svgxval.h [7:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL efcd193de0cf2de68e85227788d583d4
-BELONGS ya.make
- License text:
- * Copyright (C) 2004-2024 by
- * David Turner, Robert Wilhelm, Werner Lemberg, and George Williams.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/truetype/ttgxvar.c [7:8]
-
-KEEP COPYRIGHT_SERVICE_LABEL f38404a02e69976b94505df0c691bed0
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/base/md5.c [11:16]
- src/base/md5.h [11:16]
-
-KEEP COPYRIGHT_SERVICE_LABEL f717d5b9a8597f941eac851a6b0eb8a5
-BELONGS ya.make
- License text:
- * Copyright (C) 2002-2024 by
- * Roberto Alameda.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/type42/t42drivr.c [7:8]
- src/type42/t42drivr.h [7:8]
- src/type42/t42objs.c [7:8]
- src/type42/t42objs.h [7:8]
- src/type42/t42parse.c [7:8]
- src/type42/t42parse.h [7:8]
- src/type42/t42types.h [7:8]
-
-KEEP COPYRIGHT_SERVICE_LABEL fa7bfd6976dc989e42570721d1b62b5e
-BELONGS ya.make
- License text:
- Copyright 2000-2010, 2012-2014 by
- Francesco Zappa Nardelli
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/pcf/pcfread.c [5:6]
diff --git a/contrib/libs/freetype/.yandex_meta/devtools.licenses.report b/contrib/libs/freetype/.yandex_meta/devtools.licenses.report
deleted file mode 100644
index 6568409982..0000000000
--- a/contrib/libs/freetype/.yandex_meta/devtools.licenses.report
+++ /dev/null
@@ -1,898 +0,0 @@
-# File format ($ symbol means the beginning of a line):
-#
-# $ # this message
-# $ # =======================
-# $ # comments (all commentaries should starts with some number of spaces and # symbol)
-# $ IGNORE_FILES {file1.ext1} {file2.ext2} - (optional) ignore listed files when generating license macro and credits
-# $ RENAME {original license id} TO {new license id} # user comments - (optional) use {new license id} instead {original license id} in ya.make files
-# $ # user comments
-# $
-# ${action} {license id} {license text hash}
-# $BELONGS ./ya/make/file/relative/path/1/ya.make ./ya/make/2/ya.make
-# ${all_file_action} filename
-# $ # user commentaries (many lines)
-# $ generated description - files with this license, license text... (some number of lines that starts with some number of spaces, do not modify)
-# ${action} {license spdx} {license text hash}
-# $BELONGS ./ya/make/file/relative/path/3/ya.make
-# ${all_file_action} filename
-# $ # user commentaries
-# $ generated description
-# $ ...
-#
-# You can modify action, all_file_action and add commentaries
-# Available actions:
-# keep - keep license in contrib and use in credits
-# skip - skip license
-# remove - remove all files with this license
-# rename - save license text/links into licenses texts file, but not store SPDX into LINCENSE macro. You should store correct license id into devtools.license.spdx.txt file
-#
-# {all file action} records will be generated when license text contains filename that exists on filesystem (in contrib directory)
-# We suppose that that files can contain some license info
-# Available all file actions:
-# FILE_IGNORE - ignore file (do nothing)
-# FILE_INCLUDE - include all file data into licenses text file
-# =======================
-IGNORE_FILES docs/CHANGES docs/MAKEPP
-
-KEEP BSL-1.0 066680c0324a757d88e233277374abb3
-BELONGS ya.make
- License text:
- // Distributed under the Boost Software License, Version 1.0.
- // See accompanying file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt
- Scancode info:
- Original SPDX id: BSL-1.0
- Score : 96.00
- Match type : NOTICE
- Links : http://www.boost.org/LICENSE_1_0.txt, http://www.boost.org/users/license.html, https://spdx.org/licenses/BSL-1.0
- Files with this license:
- include/dlg/dlg.h [2:3]
- include/dlg/output.h [2:3]
- src/dlg/dlg.c [2:3]
-
-SKIP GPL-1.0-or-later 0873b49a5188bf5ba7170a658f70d080
-BELONGS ya.make
- # Not a license
- License text:
- This license is suited to products which don't use the GNU General
- Public License.
- Scancode info:
- Original SPDX id: GPL-1.0-or-later
- Score : 100.00
- Match type : REFERENCE
- Links : http://www.gnu.org/licenses/old-licenses/gpl-1.0-standalone.html, https://spdx.org/licenses/GPL-1.0-or-later
- Files with this license:
- LICENSE.TXT [17:18]
-
-KEEP FTL OR GPL-2.0-or-later 0c56182a2e6acf0f590cf8667bc28a5f
-BELONGS ya.make
- # This library is dual-licensed under FTL or GPLv2 or later, see LICENSE.TXT
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: GPL-2.0-only
- Score : 100.00
- Match type : TEXT
- Links : http://www.gnu.org/licenses/gpl-2.0.html, http://www.gnu.org/licenses/gpl-2.0.txt, https://spdx.org/licenses/GPL-2.0-only
- Files with this license:
- docs/GPLv2.TXT [1:340]
-
-KEEP FTL OR GPL-2.0-or-later 1fea8e76b4c89cfb5a2afd274c7c1478
-BELONGS ya.make
-FILE_INCLUDE LICENSE.TXT found in files: src/base/ftbbox.c at line 12, src/pshinter/pshalgo.c at line 12, src/pshinter/pshglob.c at line 13, src/raster/ftraster.h at line 12
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: FTL
- Score : 100.00
- Match type : NOTICE
- Links : http://www.freetype.org/FTL.TXT, http://www.freetype.org/license.html, https://spdx.org/licenses/FTL
- Files with this license:
- src/base/ftbbox.c [10:14]
- src/pshinter/pshalgo.c [10:14]
- src/pshinter/pshglob.c [11:15]
- src/raster/ftraster.h [10:14]
-
-SKIP GPL-3.0-only 2592ee3eb4a93f0f69aef209920b6f5f
-BELONGS ya.make
- # Not a license
- License text:
- Note that this license is compatible to the GNU General Public
- License version 3, but not version 2.
- Scancode info:
- Original SPDX id: GPL-3.0-only
- Score : 100.00
- Match type : REFERENCE
- Links : http://www.gnu.org/licenses/gpl-3.0-standalone.html, http://www.gnu.org/licenses/gpl-3.0.html, https://spdx.org/licenses/GPL-3.0-only
- Files with this license:
- LICENSE.TXT [20:21]
-
-KEEP FTL OR GPL-2.0-or-later 3310d8fd9c9eb636fc6ae56775f317e1
-BELONGS ya.make
-FILE_INCLUDE docs/FTL.TXT found in files: docs/FTL.TXT at line 110
-FILE_INCLUDE docs/release found in files: docs/FTL.TXT at line 69
- # This library is dual-licensed under FTL and GPLv2 or later, see LICENSE.TXT
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: FTL
- Score : 99.15
- Match type : TEXT
- Links : http://www.freetype.org/FTL.TXT, http://www.freetype.org/license.html, https://spdx.org/licenses/FTL
- Files with this license:
- docs/FTL.TXT [1:164]
-
-SKIP Public-Domain 44103ae8289e9c5f1d0840ae437a527a
-BELONGS ya.make
- # Not a license
- License text:
- builds) is in the public domain.
- Scancode info:
- Original SPDX id: LicenseRef-scancode-public-domain
- Score : 100.00
- Match type : TEXT
- Links : http://www.linfo.org/publicdomain.html, https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/public-domain.LICENSE
- Files with this license:
- LICENSE.TXT [43:43]
-
-KEEP MIT 4e30ec0d253f2494c9f8e45c79a9526f
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: MIT
- Score : 100.00
- Match type : TEXT
- Links : http://opensource.org/licenses/mit-license.php, https://spdx.org/licenses/MIT
- Files with this license:
- include/freetype/internal/fthash.h [14:30]
- src/base/fthash.c [14:30]
- src/bdf/bdf.h [5:21]
- src/bdf/bdferror.h [4:20]
- src/bdf/bdflib.c [6:22]
-
-KEEP FTL OR GPL-2.0-or-later 57c85c2abcfe40a58a536fbbf4bd0005
-BELONGS ya.make
-FILE_INCLUDE LICENSE.TXT found in files: README at line 102, README.git at line 97, docs/CUSTOMIZE at line 147, docs/DOCGUIDE at line 293, docs/INSTALL at line 109, docs/INSTALL.ANY at line 152, docs/INSTALL.CROSS at line 172, docs/INSTALL.GNU at line 176, docs/INSTALL.UNIX at line 134, docs/release at line 219
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: FTL
- Score : 100.00
- Match type : NOTICE
- Links : http://www.freetype.org/FTL.TXT, http://www.freetype.org/license.html, https://spdx.org/licenses/FTL
- Files with this license:
- README [100:104]
- README.git [95:99]
- docs/CUSTOMIZE [145:149]
- docs/DOCGUIDE [291:295]
- docs/INSTALL [107:111]
- docs/INSTALL.ANY [150:154]
- docs/INSTALL.CROSS [170:174]
- docs/INSTALL.GNU [174:178]
- docs/INSTALL.UNIX [132:136]
- docs/release [217:221]
-
-KEEP Public-Domain 5c874ed316f5b266c37d6f43b0b9f411
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: LicenseRef-scancode-public-domain
- Score : 85.59
- Match type : NOTICE
- Links : http://www.linfo.org/publicdomain.html, https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/public-domain.LICENSE
- Files with this license:
- src/base/md5.h [5:21]
- Scancode info:
- Original SPDX id: LicenseRef-scancode-other-permissive
- Score : 85.59
- Match type : NOTICE
- Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/other-permissive.LICENSE
- Files with this license:
- src/base/md5.h [5:21]
-
-KEEP MIT 62574968655dfadc849b1ab4123aba22
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: MIT
- Score : 100.00
- Match type : TEXT
- Links : http://opensource.org/licenses/mit-license.php, https://spdx.org/licenses/MIT
- Files with this license:
- src/bdf/bdf.c [8:24]
- src/bdf/bdfdrivr.c [8:24]
- src/bdf/bdfdrivr.h [8:24]
- src/pcf/pcf.c [8:24]
- src/pcf/pcf.h [8:24]
- src/pcf/pcfdrivr.c [8:24]
- src/pcf/pcfdrivr.h [8:24]
- src/pcf/pcfread.c [8:24]
- src/pcf/pcfread.h [8:24]
- src/pcf/pcfutil.h [8:24]
-
-KEEP Zlib 62bce9ead950c58d512fb7a3f4761d53
-BELONGS ya.make
- License text:
- The gzip module uses the zlib license (see `src/gzip/zlib.h`) which
- Scancode info:
- Original SPDX id: Zlib
- Score : 100.00
- Match type : REFERENCE
- Links : http://www.gzip.org/zlib/zlib_license.html, http://www.zlib.net/, https://spdx.org/licenses/Zlib
- Files with this license:
- LICENSE.TXT [35:35]
-
-KEEP FTL 66a91dff4d8410e3cf57197bf0993527
-BELONGS ya.make
-FILE_INCLUDE LICENSE.TXT found in files: include/freetype/config/ftconfig.h at line 12, include/freetype/config/ftheader.h at line 12, include/freetype/config/ftoption.h at line 12, include/freetype/config/ftstdlib.h at line 13, include/freetype/config/integer-types.h at line 12, include/freetype/config/public-macros.h at line 12, include/freetype/freetype.h at line 12, include/freetype/ftadvanc.h at line 12, include/freetype/ftbbox.h at line 12, include/freetype/ftbdf.h at line 12, include/freetype/ftbitmap.h at line 12, include/freetype/ftbzip2.h at line 12, include/freetype/ftcache.h at line 12, include/freetype/ftcid.h at line 12, include/freetype/ftcolor.h at line 12, include/freetype/ftdriver.h at line 12, include/freetype/fterrdef.h at line 12, include/freetype/fterrors.h at line 12, include/freetype/ftfntfmt.h at line 12, include/freetype/ftgasp.h at line 12, include/freetype/ftglyph.h at line 12, include/freetype/ftgxval.h at line 13, include/freetype/ftgzip.h at line 12, include/freetype/ftimage.h at line 13, include/freetype/ftincrem.h at line 12, include/freetype/ftlcdfil.h at line 13, include/freetype/ftlist.h at line 12, include/freetype/ftlogging.h at line 12, include/freetype/ftlzw.h at line 12, include/freetype/ftmac.h at line 12, include/freetype/ftmm.h at line 12, include/freetype/ftmodapi.h at line 12, include/freetype/ftmoderr.h at line 12, include/freetype/ftotval.h at line 12, include/freetype/ftoutln.h at line 13, include/freetype/ftparams.h at line 12, include/freetype/ftpfr.h at line 12, include/freetype/ftrender.h at line 12, include/freetype/ftsizes.h at line 12, include/freetype/ftsnames.h at line 15, include/freetype/ftstroke.h at line 12, include/freetype/ftsynth.h at line 13, include/freetype/ftsystem.h at line 12, include/freetype/fttrigon.h at line 12, include/freetype/fttypes.h at line 12, include/freetype/ftwinfnt.h at line 12, include/freetype/internal/autohint.h at line 12, include/freetype/internal/cffotypes.h at line 12, include/freetype/internal/cfftypes.h at line 13, include/freetype/internal/compiler-macros.h at line 12, include/freetype/internal/ftcalc.h at line 12, include/freetype/internal/ftdebug.h at line 12, include/freetype/internal/ftdrv.h at line 12, include/freetype/internal/ftgloadr.h at line 12, include/freetype/internal/ftmemory.h at line 12, include/freetype/internal/ftmmtypes.h at line 14, include/freetype/internal/ftobjs.h at line 12, include/freetype/internal/ftpsprop.h at line 12, include/freetype/internal/ftrfork.h at line 12, include/freetype/internal/ftserv.h at line 12, include/freetype/internal/ftstream.h at line 12, include/freetype/internal/fttrace.h at line 12, include/freetype/internal/ftvalid.h at line 12, include/freetype/internal/psaux.h at line 13, include/freetype/internal/pshints.h at line 14, include/freetype/internal/services/svbdf.h at line 12, include/freetype/internal/services/svcfftl.h at line 12, include/freetype/internal/services/svcid.h at line 12, include/freetype/internal/services/svfntfmt.h at line 12, include/freetype/internal/services/svgldict.h at line 12, include/freetype/internal/services/svgxval.h at line 13, include/freetype/internal/services/svkern.h at line 12, include/freetype/internal/services/svmetric.h at line 12, include/freetype/internal/services/svmm.h at line 12, include/freetype/internal/services/svotval.h at line 12, include/freetype/internal/services/svpfr.h at line 12, include/freetype/internal/services/svpostnm.h at line 12, include/freetype/internal/services/svprop.h at line 12, include/freetype/internal/services/svpscmap.h at line 12, include/freetype/internal/services/svpsinfo.h at line 12, include/freetype/internal/services/svsfnt.h at line 12, include/freetype/internal/services/svttcmap.h at line 13, include/freetype/internal/services/svtteng.h at line 12, include/freetype/internal/services/svttglyf.h at line 12, include/freetype/internal/services/svwinfnt.h at line 12, include/freetype/internal/sfnt.h at line 12, include/freetype/internal/svginterface.h at line 12, include/freetype/internal/t1types.h at line 13, include/freetype/internal/tttypes.h at line 13, include/freetype/internal/wofftypes.h at line 13, include/freetype/otsvg.h at line 12, include/freetype/t1tables.h at line 13, include/freetype/ttnameid.h at line 12, include/freetype/tttables.h at line 13, include/freetype/tttags.h at line 12, include/ft2build.h at line 12, src/autofit/afblue.h at line 15, src/autofit/afcjk.c at line 12, src/autofit/afcjk.h at line 12, src/autofit/afcover.h at line 12, src/autofit/afdummy.c at line 13, src/autofit/afdummy.h at line 13, src/autofit/aferrors.h at line 12, src/autofit/afglobal.c at line 12, src/autofit/afglobal.h at line 13, src/autofit/afhints.c at line 12, src/autofit/afhints.h at line 12, src/autofit/afindic.c at line 12, src/autofit/afindic.h at line 13, src/autofit/aflatin.c at line 12, src/autofit/aflatin.h at line 13, src/autofit/afloader.c at line 12, src/autofit/afloader.h at line 12, src/autofit/afmodule.c at line 12, src/autofit/afmodule.h at line 12, src/autofit/afranges.c at line 12, src/autofit/afranges.h at line 12, src/autofit/afscript.h at line 12, src/autofit/afshaper.c at line 12, src/autofit/afshaper.h at line 12, src/autofit/afstyles.h at line 12, src/autofit/aftypes.h at line 12, src/autofit/afws-decl.h at line 12, src/autofit/afws-iter.h at line 12, src/autofit/autofit.c at line 12, src/base/ftadvanc.c at line 12, src/base/ftbase.c at line 12, src/base/ftbase.h at line 12, src/base/ftbdf.c at line 12, src/base/ftbitmap.c at line 12, src/base/ftcalc.c at line 12, src/base/ftcid.c at line 12, src/base/ftcolor.c at line 12, src/base/ftdbgmem.c at line 12, src/base/ftdebug.c at line 12, src/base/fterrors.c at line 12, src/base/ftfntfmt.c at line 12, src/base/ftfstype.c at line 12, src/base/ftgasp.c at line 12, src/base/ftgloadr.c at line 12, src/base/ftglyph.c at line 12, src/base/ftgxval.c at line 13, src/base/ftinit.c at line 12, src/base/ftlcdfil.c at line 12, src/base/ftmac.c at line 16, src/base/ftmm.c at line 12, src/base/ftobjs.c at line 12, src/base/ftotval.c at line 12, src/base/ftoutln.c at line 12, src/base/ftpatent.c at line 13, src/base/ftpfr.c at line 12, src/base/ftpsprop.c at line 13, src/base/ftrfork.c at line 15, src/base/ftsnames.c at line 15, src/base/ftstream.c at line 12, src/base/ftstroke.c at line 12, src/base/ftsynth.c at line 12, src/base/ftsystem.c at line 12, src/base/fttrigon.c at line 12, src/base/fttype1.c at line 12, src/base/ftutil.c at line 12, src/base/ftwinfnt.c at line 12, src/bzip2/ftbzip2.c at line 18, src/cache/ftcache.c at line 12, src/cache/ftcbasic.c at line 12, src/cache/ftccache.c at line 12, src/cache/ftccache.h at line 12, src/cache/ftccback.h at line 12, src/cache/ftccmap.c at line 12, src/cache/ftcerror.h at line 12, src/cache/ftcglyph.c at line 12, src/cache/ftcglyph.h at line 12, src/cache/ftcimage.c at line 12, src/cache/ftcimage.h at line 12, src/cache/ftcmanag.c at line 12, src/cache/ftcmanag.h at line 12, src/cache/ftcmru.c at line 12, src/cache/ftcmru.h at line 12, src/cache/ftcsbits.c at line 12, src/cache/ftcsbits.h at line 12, src/cff/cff.c at line 12, src/cff/cffcmap.c at line 12, src/cff/cffcmap.h at line 12, src/cff/cffdrivr.c at line 12, src/cff/cffdrivr.h at line 12, src/cff/cfferrs.h at line 12, src/cff/cffgload.c at line 12, src/cff/cffgload.h at line 12, src/cff/cffload.c at line 12, src/cff/cffload.h at line 12, src/cff/cffobjs.c at line 12, src/cff/cffobjs.h at line 12, src/cff/cffparse.c at line 12, src/cff/cffparse.h at line 12, src/cff/cfftoken.h at line 12, src/cid/ciderrs.h at line 12, src/cid/cidgload.c at line 12, src/cid/cidgload.h at line 12, src/cid/cidload.c at line 12, src/cid/cidload.h at line 12, src/cid/cidobjs.c at line 12, src/cid/cidobjs.h at line 12, src/cid/cidparse.c at line 12, src/cid/cidparse.h at line 12, src/cid/cidriver.c at line 12, src/cid/cidriver.h at line 12, src/cid/cidtoken.h at line 12, src/cid/type1cid.c at line 12, src/dlg/dlgwrap.c at line 12, src/gzip/ftgzip.c at line 16, src/lzw/ftlzw.c at line 18, src/lzw/ftzopen.c at line 16, src/lzw/ftzopen.h at line 16, src/pcf/pcferror.h at line 12, src/pfr/pfr.c at line 12, src/pfr/pfrcmap.c at line 12, src/pfr/pfrcmap.h at line 12, src/pfr/pfrdrivr.c at line 12, src/pfr/pfrdrivr.h at line 12, src/pfr/pfrerror.h at line 12, src/pfr/pfrgload.c at line 12, src/pfr/pfrgload.h at line 12, src/pfr/pfrload.c at line 12, src/pfr/pfrload.h at line 12, src/pfr/pfrobjs.c at line 12, src/pfr/pfrobjs.h at line 12, src/pfr/pfrsbit.c at line 12, src/pfr/pfrsbit.h at line 12, src/pfr/pfrtypes.h at line 12, src/psaux/afmparse.c at line 12, src/psaux/afmparse.h at line 12, src/psaux/cffdecode.c at line 12, src/psaux/cffdecode.h at line 12, src/psaux/psaux.c at line 12, src/psaux/psauxerr.h at line 12, src/psaux/psauxmod.c at line 12, src/psaux/psauxmod.h at line 12, src/psaux/psconv.c at line 12, src/psaux/psconv.h at line 12, src/psaux/psobjs.c at line 12, src/psaux/psobjs.h at line 12, src/psaux/t1cmap.c at line 12, src/psaux/t1cmap.h at line 12, src/psaux/t1decode.c at line 12, src/psaux/t1decode.h at line 12, src/pshinter/pshalgo.h at line 12, src/pshinter/pshglob.h at line 12, src/pshinter/pshinter.c at line 12, src/pshinter/pshmod.c at line 12, src/pshinter/pshmod.h at line 12, src/pshinter/pshnterr.h at line 12, src/pshinter/pshrec.c at line 12, src/pshinter/pshrec.h at line 12, src/psnames/psmodule.c at line 12, src/psnames/psmodule.h at line 12, src/psnames/psnamerr.h at line 12, src/psnames/psnames.c at line 12, src/psnames/pstables.h at line 12, src/raster/ftraster.c at line 12, src/raster/ftrend1.c at line 12, src/raster/ftrend1.h at line 12, src/raster/raster.c at line 12, src/raster/rasterrs.h at line 12, src/sdf/ftbsdf.c at line 14, src/sdf/ftsdf.c at line 14, src/sdf/ftsdf.h at line 14, src/sdf/ftsdfcommon.c at line 14, src/sdf/ftsdfcommon.h at line 14, src/sdf/ftsdferrs.h at line 14, src/sdf/ftsdfrend.c at line 14, src/sdf/ftsdfrend.h at line 14, src/sdf/sdf.c at line 14, src/sfnt/pngshim.c at line 13, src/sfnt/pngshim.h at line 13, src/sfnt/sfdriver.c at line 12, src/sfnt/sfdriver.h at line 12, src/sfnt/sferrors.h at line 12, src/sfnt/sfnt.c at line 12, src/sfnt/sfobjs.c at line 12, src/sfnt/sfobjs.h at line 12, src/sfnt/sfwoff.c at line 12, src/sfnt/sfwoff.h at line 12, src/sfnt/sfwoff2.c at line 12, src/sfnt/sfwoff2.h at line 12, src/sfnt/ttbdf.c at line 12, src/sfnt/ttbdf.h at line 12, src/sfnt/ttcmap.c at line 12, src/sfnt/ttcmap.h at line 12, src/sfnt/ttcmapc.h at line 12, src/sfnt/ttcolr.c at line 14, src/sfnt/ttcolr.h at line 14, src/sfnt/ttcpal.c at line 14, src/sfnt/ttcpal.h at line 14, src/sfnt/ttgpos.c at line 20, src/sfnt/ttgpos.h at line 14, src/sfnt/ttkern.c at line 13, src/sfnt/ttkern.h at line 13, src/sfnt/ttload.c at line 13, src/sfnt/ttload.h at line 13, src/sfnt/ttmtx.c at line 12, src/sfnt/ttmtx.h at line 12, src/sfnt/ttpost.c at line 13, src/sfnt/ttpost.h at line 13, src/sfnt/ttsbit.c at line 15, src/sfnt/ttsbit.h at line 12, src/sfnt/ttsvg.c at line 12, src/sfnt/ttsvg.h at line 12, src/sfnt/woff2tags.c at line 12, src/sfnt/woff2tags.h at line 12, src/smooth/ftgrays.c at line 12, src/smooth/ftsmerrs.h at line 12, src/smooth/ftsmooth.c at line 12, src/smooth/ftsmooth.h at line 12, src/smooth/smooth.c at line 12, src/svg/ftsvg.c at line 12, src/svg/ftsvg.h at line 12, src/svg/svg.c at line 12, src/svg/svgtypes.h at line 12, src/truetype/truetype.c at line 12, src/truetype/ttdriver.c at line 12, src/truetype/ttdriver.h at line 12, src/truetype/tterrors.h at line 12, src/truetype/ttgload.c at line 12, src/truetype/ttgload.h at line 12, src/truetype/ttgxvar.c at line 12, src/truetype/ttgxvar.h at line 12, src/truetype/ttinterp.c at line 12, src/truetype/ttinterp.h at line 12, src/truetype/ttobjs.c at line 12, src/truetype/ttobjs.h at line 12, src/truetype/ttpload.c at line 12, src/truetype/ttpload.h at line 12, src/type1/t1afm.c at line 12, src/type1/t1afm.h at line 12, src/type1/t1driver.c at line 12, src/type1/t1driver.h at line 12, src/type1/t1errors.h at line 12, src/type1/t1gload.c at line 12, src/type1/t1gload.h at line 12, src/type1/t1load.c at line 12, src/type1/t1load.h at line 12, src/type1/t1objs.c at line 12, src/type1/t1objs.h at line 12, src/type1/t1parse.c at line 12, src/type1/t1parse.h at line 12, src/type1/t1tokens.h at line 12, src/type1/type1.c at line 12, src/type42/t42drivr.c at line 12, src/type42/t42drivr.h at line 12, src/type42/t42error.h at line 12, src/type42/t42objs.c at line 12, src/type42/t42objs.h at line 12, src/type42/t42parse.c at line 12, src/type42/t42parse.h at line 12, src/type42/t42types.h at line 12, src/type42/type42.c at line 12, src/winfonts/fnterrs.h at line 12, src/winfonts/winfnt.c at line 14, src/winfonts/winfnt.h at line 13
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: FTL
- Score : 100.00
- Match type : NOTICE
- Links : http://www.freetype.org/FTL.TXT, http://www.freetype.org/license.html, https://spdx.org/licenses/FTL
- Files with this license:
- include/freetype/config/ftconfig.h [10:14]
- include/freetype/config/ftheader.h [10:14]
- include/freetype/config/ftoption.h [10:14]
- include/freetype/config/ftstdlib.h [11:15]
- include/freetype/config/integer-types.h [10:14]
- include/freetype/config/public-macros.h [10:14]
- include/freetype/freetype.h [10:14]
- include/freetype/ftadvanc.h [10:14]
- include/freetype/ftbbox.h [10:14]
- include/freetype/ftbdf.h [10:14]
- include/freetype/ftbitmap.h [10:14]
- include/freetype/ftbzip2.h [10:14]
- include/freetype/ftcache.h [10:14]
- include/freetype/ftcid.h [10:14]
- include/freetype/ftcolor.h [10:14]
- include/freetype/ftdriver.h [10:14]
- include/freetype/fterrdef.h [10:14]
- include/freetype/fterrors.h [10:14]
- include/freetype/ftfntfmt.h [10:14]
- include/freetype/ftgasp.h [10:14]
- include/freetype/ftglyph.h [10:14]
- include/freetype/ftgxval.h [11:15]
- include/freetype/ftgzip.h [10:14]
- include/freetype/ftimage.h [11:15]
- include/freetype/ftincrem.h [10:14]
- include/freetype/ftlcdfil.h [11:15]
- include/freetype/ftlist.h [10:14]
- include/freetype/ftlogging.h [10:14]
- include/freetype/ftlzw.h [10:14]
- include/freetype/ftmac.h [10:14]
- include/freetype/ftmm.h [10:14]
- include/freetype/ftmodapi.h [10:14]
- include/freetype/ftmoderr.h [10:14]
- include/freetype/ftotval.h [10:14]
- include/freetype/ftoutln.h [11:15]
- include/freetype/ftparams.h [10:14]
- include/freetype/ftpfr.h [10:14]
- include/freetype/ftrender.h [10:14]
- include/freetype/ftsizes.h [10:14]
- include/freetype/ftsnames.h [13:17]
- include/freetype/ftstroke.h [10:14]
- include/freetype/ftsynth.h [11:15]
- include/freetype/ftsystem.h [10:14]
- include/freetype/fttrigon.h [10:14]
- include/freetype/fttypes.h [10:14]
- include/freetype/ftwinfnt.h [10:14]
- include/freetype/internal/autohint.h [10:14]
- include/freetype/internal/cffotypes.h [10:14]
- include/freetype/internal/cfftypes.h [11:15]
- include/freetype/internal/compiler-macros.h [10:14]
- include/freetype/internal/ftcalc.h [10:14]
- include/freetype/internal/ftdebug.h [10:14]
- include/freetype/internal/ftdrv.h [10:14]
- include/freetype/internal/ftgloadr.h [10:14]
- include/freetype/internal/ftmemory.h [10:14]
- include/freetype/internal/ftmmtypes.h [12:16]
- include/freetype/internal/ftobjs.h [10:14]
- include/freetype/internal/ftpsprop.h [10:14]
- include/freetype/internal/ftrfork.h [10:14]
- include/freetype/internal/ftserv.h [10:14]
- include/freetype/internal/ftstream.h [10:14]
- include/freetype/internal/fttrace.h [10:14]
- include/freetype/internal/ftvalid.h [10:14]
- include/freetype/internal/psaux.h [11:15]
- include/freetype/internal/pshints.h [12:16]
- include/freetype/internal/services/svbdf.h [10:14]
- include/freetype/internal/services/svcfftl.h [10:14]
- include/freetype/internal/services/svcid.h [10:14]
- include/freetype/internal/services/svfntfmt.h [10:14]
- include/freetype/internal/services/svgldict.h [10:14]
- include/freetype/internal/services/svgxval.h [11:15]
- include/freetype/internal/services/svkern.h [10:14]
- include/freetype/internal/services/svmetric.h [10:14]
- include/freetype/internal/services/svmm.h [10:14]
- include/freetype/internal/services/svotval.h [10:14]
- include/freetype/internal/services/svpfr.h [10:14]
- include/freetype/internal/services/svpostnm.h [10:14]
- include/freetype/internal/services/svprop.h [10:14]
- include/freetype/internal/services/svpscmap.h [10:14]
- include/freetype/internal/services/svpsinfo.h [10:14]
- include/freetype/internal/services/svsfnt.h [10:14]
- include/freetype/internal/services/svttcmap.h [11:15]
- include/freetype/internal/services/svtteng.h [10:14]
- include/freetype/internal/services/svttglyf.h [10:14]
- include/freetype/internal/services/svwinfnt.h [10:14]
- include/freetype/internal/sfnt.h [10:14]
- include/freetype/internal/svginterface.h [10:14]
- include/freetype/internal/t1types.h [11:15]
- include/freetype/internal/tttypes.h [11:15]
- include/freetype/internal/wofftypes.h [11:15]
- include/freetype/otsvg.h [10:14]
- include/freetype/t1tables.h [11:15]
- include/freetype/ttnameid.h [10:14]
- include/freetype/tttables.h [11:15]
- include/freetype/tttags.h [10:14]
- include/ft2build.h [10:14]
- src/autofit/afblue.h [13:17]
- src/autofit/afcjk.c [10:14]
- src/autofit/afcjk.h [10:14]
- src/autofit/afcover.h [10:14]
- src/autofit/afdummy.c [11:15]
- src/autofit/afdummy.h [11:15]
- src/autofit/aferrors.h [10:14]
- src/autofit/afglobal.c [10:14]
- src/autofit/afglobal.h [11:15]
- src/autofit/afhints.c [10:14]
- src/autofit/afhints.h [10:14]
- src/autofit/afindic.c [10:14]
- src/autofit/afindic.h [11:15]
- src/autofit/aflatin.c [10:14]
- src/autofit/aflatin.h [11:15]
- src/autofit/afloader.c [10:14]
- src/autofit/afloader.h [10:14]
- src/autofit/afmodule.c [10:14]
- src/autofit/afmodule.h [10:14]
- src/autofit/afranges.c [10:14]
- src/autofit/afranges.h [10:14]
- src/autofit/afscript.h [10:14]
- src/autofit/afshaper.c [10:14]
- src/autofit/afshaper.h [10:14]
- src/autofit/afstyles.h [10:14]
- src/autofit/aftypes.h [10:14]
- src/autofit/afws-decl.h [10:14]
- src/autofit/afws-iter.h [10:14]
- src/autofit/autofit.c [10:14]
- src/base/ftadvanc.c [10:14]
- src/base/ftbase.c [10:14]
- src/base/ftbase.h [10:14]
- src/base/ftbdf.c [10:14]
- src/base/ftbitmap.c [10:14]
- src/base/ftcalc.c [10:14]
- src/base/ftcid.c [10:14]
- src/base/ftcolor.c [10:14]
- src/base/ftdbgmem.c [10:14]
- src/base/ftdebug.c [10:14]
- src/base/fterrors.c [10:14]
- src/base/ftfntfmt.c [10:14]
- src/base/ftfstype.c [10:14]
- src/base/ftgasp.c [10:14]
- src/base/ftgloadr.c [10:14]
- src/base/ftglyph.c [10:14]
- src/base/ftgxval.c [11:15]
- src/base/ftinit.c [10:14]
- src/base/ftlcdfil.c [10:14]
- src/base/ftmac.c [14:18]
- src/base/ftmm.c [10:14]
- src/base/ftobjs.c [10:14]
- src/base/ftotval.c [10:14]
- src/base/ftoutln.c [10:14]
- src/base/ftpatent.c [11:15]
- src/base/ftpfr.c [10:14]
- src/base/ftpsprop.c [11:15]
- src/base/ftrfork.c [13:17]
- src/base/ftsnames.c [13:17]
- src/base/ftstream.c [10:14]
- src/base/ftstroke.c [10:14]
- src/base/ftsynth.c [10:14]
- src/base/ftsystem.c [10:14]
- src/base/fttrigon.c [10:14]
- src/base/fttype1.c [10:14]
- src/base/ftutil.c [10:14]
- src/base/ftwinfnt.c [10:14]
- src/bzip2/ftbzip2.c [16:20]
- src/cache/ftcache.c [10:14]
- src/cache/ftcbasic.c [10:14]
- src/cache/ftccache.c [10:14]
- src/cache/ftccache.h [10:14]
- src/cache/ftccback.h [10:14]
- src/cache/ftccmap.c [10:14]
- src/cache/ftcerror.h [10:14]
- src/cache/ftcglyph.c [10:14]
- src/cache/ftcglyph.h [10:14]
- src/cache/ftcimage.c [10:14]
- src/cache/ftcimage.h [10:14]
- src/cache/ftcmanag.c [10:14]
- src/cache/ftcmanag.h [10:14]
- src/cache/ftcmru.c [10:14]
- src/cache/ftcmru.h [10:14]
- src/cache/ftcsbits.c [10:14]
- src/cache/ftcsbits.h [10:14]
- src/cff/cff.c [10:14]
- src/cff/cffcmap.c [10:14]
- src/cff/cffcmap.h [10:14]
- src/cff/cffdrivr.c [10:14]
- src/cff/cffdrivr.h [10:14]
- src/cff/cfferrs.h [10:14]
- src/cff/cffgload.c [10:14]
- src/cff/cffgload.h [10:14]
- src/cff/cffload.c [10:14]
- src/cff/cffload.h [10:14]
- src/cff/cffobjs.c [10:14]
- src/cff/cffobjs.h [10:14]
- src/cff/cffparse.c [10:14]
- src/cff/cffparse.h [10:14]
- src/cff/cfftoken.h [10:14]
- src/cid/ciderrs.h [10:14]
- src/cid/cidgload.c [10:14]
- src/cid/cidgload.h [10:14]
- src/cid/cidload.c [10:14]
- src/cid/cidload.h [10:14]
- src/cid/cidobjs.c [10:14]
- src/cid/cidobjs.h [10:14]
- src/cid/cidparse.c [10:14]
- src/cid/cidparse.h [10:14]
- src/cid/cidriver.c [10:14]
- src/cid/cidriver.h [10:14]
- src/cid/cidtoken.h [10:14]
- src/cid/type1cid.c [10:14]
- src/dlg/dlgwrap.c [10:14]
- src/gzip/ftgzip.c [14:18]
- src/lzw/ftlzw.c [16:20]
- src/lzw/ftzopen.c [14:18]
- src/lzw/ftzopen.h [14:18]
- src/pcf/pcferror.h [10:14]
- src/pfr/pfr.c [10:14]
- src/pfr/pfrcmap.c [10:14]
- src/pfr/pfrcmap.h [10:14]
- src/pfr/pfrdrivr.c [10:14]
- src/pfr/pfrdrivr.h [10:14]
- src/pfr/pfrerror.h [10:14]
- src/pfr/pfrgload.c [10:14]
- src/pfr/pfrgload.h [10:14]
- src/pfr/pfrload.c [10:14]
- src/pfr/pfrload.h [10:14]
- src/pfr/pfrobjs.c [10:14]
- src/pfr/pfrobjs.h [10:14]
- src/pfr/pfrsbit.c [10:14]
- src/pfr/pfrsbit.h [10:14]
- src/pfr/pfrtypes.h [10:14]
- src/psaux/afmparse.c [10:14]
- src/psaux/afmparse.h [10:14]
- src/psaux/cffdecode.c [10:14]
- src/psaux/cffdecode.h [10:14]
- src/psaux/psaux.c [10:14]
- src/psaux/psauxerr.h [10:14]
- src/psaux/psauxmod.c [10:14]
- src/psaux/psauxmod.h [10:14]
- src/psaux/psconv.c [10:14]
- src/psaux/psconv.h [10:14]
- src/psaux/psobjs.c [10:14]
- src/psaux/psobjs.h [10:14]
- src/psaux/t1cmap.c [10:14]
- src/psaux/t1cmap.h [10:14]
- src/psaux/t1decode.c [10:14]
- src/psaux/t1decode.h [10:14]
- src/pshinter/pshalgo.h [10:14]
- src/pshinter/pshglob.h [10:14]
- src/pshinter/pshinter.c [10:14]
- src/pshinter/pshmod.c [10:14]
- src/pshinter/pshmod.h [10:14]
- src/pshinter/pshnterr.h [10:14]
- src/pshinter/pshrec.c [10:14]
- src/pshinter/pshrec.h [10:14]
- src/psnames/psmodule.c [10:14]
- src/psnames/psmodule.h [10:14]
- src/psnames/psnamerr.h [10:14]
- src/psnames/psnames.c [10:14]
- src/psnames/pstables.h [10:14]
- src/raster/ftraster.c [10:14]
- src/raster/ftrend1.c [10:14]
- src/raster/ftrend1.h [10:14]
- src/raster/raster.c [10:14]
- src/raster/rasterrs.h [10:14]
- src/sdf/ftbsdf.c [12:16]
- src/sdf/ftsdf.c [12:16]
- src/sdf/ftsdf.h [12:16]
- src/sdf/ftsdfcommon.c [12:16]
- src/sdf/ftsdfcommon.h [12:16]
- src/sdf/ftsdferrs.h [12:16]
- src/sdf/ftsdfrend.c [12:16]
- src/sdf/ftsdfrend.h [12:16]
- src/sdf/sdf.c [12:16]
- src/sfnt/pngshim.c [11:15]
- src/sfnt/pngshim.h [11:15]
- src/sfnt/sfdriver.c [10:14]
- src/sfnt/sfdriver.h [10:14]
- src/sfnt/sferrors.h [10:14]
- src/sfnt/sfnt.c [10:14]
- src/sfnt/sfobjs.c [10:14]
- src/sfnt/sfobjs.h [10:14]
- src/sfnt/sfwoff.c [10:14]
- src/sfnt/sfwoff.h [10:14]
- src/sfnt/sfwoff2.c [10:14]
- src/sfnt/sfwoff2.h [10:14]
- src/sfnt/ttbdf.c [10:14]
- src/sfnt/ttbdf.h [10:14]
- src/sfnt/ttcmap.c [10:14]
- src/sfnt/ttcmap.h [10:14]
- src/sfnt/ttcmapc.h [10:14]
- src/sfnt/ttcolr.c [12:16]
- src/sfnt/ttcolr.h [12:16]
- src/sfnt/ttcpal.c [12:16]
- src/sfnt/ttcpal.h [12:16]
- src/sfnt/ttgpos.c [18:22]
- src/sfnt/ttgpos.h [12:16]
- src/sfnt/ttkern.c [11:15]
- src/sfnt/ttkern.h [11:15]
- src/sfnt/ttload.c [11:15]
- src/sfnt/ttload.h [11:15]
- src/sfnt/ttmtx.c [10:14]
- src/sfnt/ttmtx.h [10:14]
- src/sfnt/ttpost.c [11:15]
- src/sfnt/ttpost.h [11:15]
- src/sfnt/ttsbit.c [13:17]
- src/sfnt/ttsbit.h [10:14]
- src/sfnt/ttsvg.c [10:14]
- src/sfnt/ttsvg.h [10:14]
- src/sfnt/woff2tags.c [10:14]
- src/sfnt/woff2tags.h [10:14]
- src/smooth/ftgrays.c [10:14]
- src/smooth/ftsmerrs.h [10:14]
- src/smooth/ftsmooth.c [10:14]
- src/smooth/ftsmooth.h [10:14]
- src/smooth/smooth.c [10:14]
- src/svg/ftsvg.c [10:14]
- src/svg/ftsvg.h [10:14]
- src/svg/svg.c [10:14]
- src/svg/svgtypes.h [10:14]
- src/truetype/truetype.c [10:14]
- src/truetype/ttdriver.c [10:14]
- src/truetype/ttdriver.h [10:14]
- src/truetype/tterrors.h [10:14]
- src/truetype/ttgload.c [10:14]
- src/truetype/ttgload.h [10:14]
- src/truetype/ttgxvar.c [10:14]
- src/truetype/ttgxvar.h [10:14]
- src/truetype/ttinterp.c [10:14]
- src/truetype/ttinterp.h [10:14]
- src/truetype/ttobjs.c [10:14]
- src/truetype/ttobjs.h [10:14]
- src/truetype/ttpload.c [10:14]
- src/truetype/ttpload.h [10:14]
- src/type1/t1afm.c [10:14]
- src/type1/t1afm.h [10:14]
- src/type1/t1driver.c [10:14]
- src/type1/t1driver.h [10:14]
- src/type1/t1errors.h [10:14]
- src/type1/t1gload.c [10:14]
- src/type1/t1gload.h [10:14]
- src/type1/t1load.c [10:14]
- src/type1/t1load.h [10:14]
- src/type1/t1objs.c [10:14]
- src/type1/t1objs.h [10:14]
- src/type1/t1parse.c [10:14]
- src/type1/t1parse.h [10:14]
- src/type1/t1tokens.h [10:14]
- src/type1/type1.c [10:14]
- src/type42/t42drivr.c [10:14]
- src/type42/t42drivr.h [10:14]
- src/type42/t42error.h [10:14]
- src/type42/t42objs.c [10:14]
- src/type42/t42objs.h [10:14]
- src/type42/t42parse.c [10:14]
- src/type42/t42parse.h [10:14]
- src/type42/t42types.h [10:14]
- src/type42/type42.c [10:14]
- src/winfonts/fnterrs.h [10:14]
- src/winfonts/winfnt.c [12:16]
- src/winfonts/winfnt.h [11:15]
-
-KEEP MIT 6b21fe03795256387532b3d8a975f168
-BELONGS ya.make
- License text:
- the 'Old MIT' license, compatible to the above two licenses.
- Scancode info:
- Original SPDX id: MIT
- Score : 100.00
- Match type : REFERENCE
- Links : http://opensource.org/licenses/mit-license.php, https://spdx.org/licenses/MIT
- Files with this license:
- LICENSE.TXT [40:40]
-
-KEEP FTL 83a2c5ed5e0c6bdfc5afdcf10f8d37b4
-BELONGS ya.make
-FILE_INCLUDE LICENSE.TXT found in files: src/psaux/psarrst.c at line 13, src/psaux/psarrst.h at line 13, src/psaux/psblues.c at line 13, src/psaux/psblues.h at line 13, src/psaux/pserror.c at line 13, src/psaux/pserror.h at line 13, src/psaux/psfixed.h at line 13, src/psaux/psfont.c at line 13, src/psaux/psfont.h at line 13, src/psaux/psft.c at line 13, src/psaux/psft.h at line 13, src/psaux/psglue.h at line 13, src/psaux/pshints.c at line 13, src/psaux/pshints.h at line 13, src/psaux/psintrp.c at line 13, src/psaux/psintrp.h at line 13, src/psaux/psread.c at line 13, src/psaux/psread.h at line 13, src/psaux/psstack.c at line 13, src/psaux/psstack.h at line 13, src/psaux/pstypes.h at line 13
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: FTL
- Score : 100.00
- Match type : NOTICE
- Links : http://www.freetype.org/FTL.TXT, http://www.freetype.org/license.html, https://spdx.org/licenses/FTL
- Files with this license:
- src/psaux/psarrst.c [9:34]
- src/psaux/psarrst.h [9:34]
- src/psaux/psblues.c [9:34]
- src/psaux/psblues.h [9:34]
- src/psaux/pserror.c [9:34]
- src/psaux/pserror.h [9:34]
- src/psaux/psfixed.h [9:34]
- src/psaux/psfont.c [9:34]
- src/psaux/psfont.h [9:34]
- src/psaux/psft.c [9:34]
- src/psaux/psft.h [9:34]
- src/psaux/psglue.h [9:34]
- src/psaux/pshints.c [9:34]
- src/psaux/pshints.h [9:34]
- src/psaux/psintrp.c [9:34]
- src/psaux/psintrp.h [9:34]
- src/psaux/psread.c [9:34]
- src/psaux/psread.h [9:34]
- src/psaux/psstack.c [9:34]
- src/psaux/psstack.h [9:34]
- src/psaux/pstypes.h [9:34]
- Scancode info:
- Original SPDX id: LicenseRef-scancode-freetype-patent
- Score : 100.00
- Match type : NOTICE
- Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/freetype-patent.LICENSE, https://www.freetype.org/
- Files with this license:
- src/psaux/psarrst.c [9:34]
- src/psaux/psarrst.h [9:34]
- src/psaux/psblues.c [9:34]
- src/psaux/psblues.h [9:34]
- src/psaux/pserror.c [9:34]
- src/psaux/pserror.h [9:34]
- src/psaux/psfixed.h [9:34]
- src/psaux/psfont.c [9:34]
- src/psaux/psfont.h [9:34]
- src/psaux/psft.c [9:34]
- src/psaux/psft.h [9:34]
- src/psaux/psglue.h [9:34]
- src/psaux/pshints.c [9:34]
- src/psaux/pshints.h [9:34]
- src/psaux/psintrp.c [9:34]
- src/psaux/psintrp.h [9:34]
- src/psaux/psread.c [9:34]
- src/psaux/psread.h [9:34]
- src/psaux/psstack.c [9:34]
- src/psaux/psstack.h [9:34]
- src/psaux/pstypes.h [9:34]
-
-KEEP MIT 85d26f1af9c8b337eb178e683bef6ae6
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: MIT
- Score : 100.00
- Match type : TEXT
- Links : http://opensource.org/licenses/mit-license.php, https://spdx.org/licenses/MIT
- Files with this license:
- src/bdf/README [128:144]
-
-KEEP MIT 8d18be6409468bae48b33b87db85824a
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: MIT
- Score : 100.00
- Match type : TEXT
- Links : http://opensource.org/licenses/mit-license.php, https://spdx.org/licenses/MIT
- Files with this license:
- src/bdf/README [104:121]
- src/pcf/README [71:88]
-
-SKIP LicenseRef-scancode-generic-exception 999b43691b7ab7819b0829369e4d98cf
-BELONGS ya.make
- # Not a license
- License text:
- As a special exception, 'makepp' can also be used to build
- Scancode info:
- Original SPDX id: LicenseRef-scancode-generic-exception
- Score : 16.00
- Match type : INTRO
- Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/generic-exception.LICENSE
- Files with this license:
- docs/INSTALL.UNIX [28:28]
-
-KEEP FTL OR GPL-2.0-or-later 9ca03287004572c68168833d37e160cb
-BELONGS ya.make
-FILE_INCLUDE LICENSE.TXT found in files: docs/CHANGES at line 5716, docs/INSTALL.VMS at line 64, docs/TODO at line 35, docs/raster.txt at line 626
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: FTL
- Score : 100.00
- Match type : NOTICE
- Links : http://www.freetype.org/FTL.TXT, http://www.freetype.org/license.html, https://spdx.org/licenses/FTL
- Files with this license:
- docs/INSTALL.VMS [62:66]
- docs/TODO [33:37]
- docs/raster.txt [624:628]
-
-KEEP MIT-Modern-Variant 9f9cae778b69fdc859bc4e69e000361d
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: MIT-Modern-Variant
- Score : 100.00
- Match type : TEXT
- Links : http://fedoraproject.org/wiki/Licensing/MIT, https://spdx.org/licenses/MIT-Modern-Variant
- Files with this license:
- src/autofit/ft-hb.c [5:21]
-
-KEEP FTL OR GPL-2.0-or-later a14991036409f727e5ae01a4e7b3d554
-BELONGS ya.make
- # This library is dual-licensed under FTL or GPLv2 or later, see LICENSE.TXT
- License text:
- `docs/GPLv2.TXT` (any later version can be used also), for
- Scancode info:
- Original SPDX id: GPL-2.0-only
- Score : 100.00
- Match type : REFERENCE
- Links : http://www.gnu.org/licenses/gpl-2.0.html, http://www.gnu.org/licenses/gpl-2.0.txt, https://spdx.org/licenses/GPL-2.0-only
- Files with this license:
- LICENSE.TXT [24:24]
-
-SKIP GPL-2.0-or-later a7f726d25c2e8810dcf14dd8e3e3d0e1
-BELONGS ya.make
- # Not a license
- License text:
- incompatible with GPLv2 due to its advertisement clause.
- Scancode info:
- Original SPDX id: GPL-2.0-only
- Score : 100.00
- Match type : REFERENCE
- Links : http://www.gnu.org/licenses/gpl-2.0.html, http://www.gnu.org/licenses/gpl-2.0.txt, https://spdx.org/licenses/GPL-2.0-only
- Files with this license:
- LICENSE.TXT [26:26]
-
-KEEP Public-Domain aa9ddf39ee4e3b6b568d5b27c00ae8ec
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: LicenseRef-scancode-public-domain
- Score : 86.44
- Match type : NOTICE
- Links : http://www.linfo.org/publicdomain.html, https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/public-domain.LICENSE
- Files with this license:
- src/base/md5.c [5:23]
- Scancode info:
- Original SPDX id: LicenseRef-scancode-other-permissive
- Score : 86.44
- Match type : NOTICE
- Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/other-permissive.LICENSE
- Files with this license:
- src/base/md5.c [5:23]
-
-KEEP FTL c11c31d0c602d093e3dc11396e5ecbba
-BELONGS ya.make
-FILE_INCLUDE LICENSE.TXT found in files: include/freetype/config/mac-support.h at line 12
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: FTL
- Score : 60.24
- Match type : NOTICE
- Links : http://www.freetype.org/FTL.TXT, http://www.freetype.org/license.html, https://spdx.org/licenses/FTL
- Files with this license:
- include/freetype/config/mac-support.h [10:25]
- Scancode info:
- Original SPDX id: LicenseRef-scancode-autoconf-simple-exception-2.0
- Score : 60.24
- Match type : NOTICE
- Links : https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob;f=config.guess;h=a7448442748cc6f98a066d2d1051fad3b043761a;hb=HEAD, https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/autoconf-simple-exception-2.0.LICENSE
- Files with this license:
- include/freetype/config/mac-support.h [10:25]
-
-KEEP FTL cce648481427ee73679fba3698a7cfc4
-BELONGS ya.make
-FILE_INCLUDE LICENSE.TXT found in files: src/autofit/afblue.c at line 15
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: FTL
- Score : 100.00
- Match type : NOTICE
- Links : http://www.freetype.org/FTL.TXT, http://www.freetype.org/license.html, https://spdx.org/licenses/FTL
- Files with this license:
- src/autofit/afblue.c [13:17]
-
-KEEP FTL OR GPL-2.0-or-later d0312561c19360f6fa8d9350e5fd8610
-BELONGS ya.make
- # Not a license
- License text:
- - The GNU General Public License version 2, found in
- Scancode info:
- Original SPDX id: GPL-2.0-only
- Score : 100.00
- Match type : REFERENCE
- Links : http://www.gnu.org/licenses/gpl-2.0.html, http://www.gnu.org/licenses/gpl-2.0.txt, https://spdx.org/licenses/GPL-2.0-only
- Files with this license:
- LICENSE.TXT [23:23]
-
-SKIP GPL-1.0-or-later d35e5b52577516060af609f616a3d5f7
-BELONGS ya.make
- # Not a license
- License text:
- programs which already use the GPL. Note that the FTL is
- Scancode info:
- Original SPDX id: GPL-1.0-or-later
- Score : 85.00
- Match type : REFERENCE
- Links : http://www.gnu.org/licenses/old-licenses/gpl-1.0-standalone.html, https://spdx.org/licenses/GPL-1.0-or-later
- Files with this license:
- LICENSE.TXT [25:25]
-
-KEEP MIT-open-group e152fafc023fa7bc8d97938577404aa9
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: MIT-open-group
- Score : 100.00
- Match type : TEXT
- Links : http://www.xfree86.org/current/LICENSE5.html, https://spdx.org/licenses/MIT-open-group
- Files with this license:
- src/pcf/pcfutil.c [5:23]
-
-SKIP BSD-3-Clause AND LicenseRef-scancode-unknown e6eae0f8377ee1fdb4436afe2b559eaf
-BELONGS ya.make
- # Not a license
- License text:
- similar to the original BSD license *with* an advertising clause
- Scancode info:
- Original SPDX id: BSD-3-Clause
- Score : 99.00
- Match type : REFERENCE
- Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
- Files with this license:
- LICENSE.TXT [14:14]
- Scancode info:
- Original SPDX id: LicenseRef-scancode-unknown
- Score : 11.00
- Match type : REFERENCE
- Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/unknown.LICENSE
- Files with this license:
- LICENSE.TXT [14:14]
-
-KEEP FTL f1e968703880d0e469176a82d88d4ad4
-BELONGS ya.make
-FILE_INCLUDE LICENSE.TXT found in files: docs/DEBUG at line 305, docs/formats.txt at line 214
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: FTL
- Score : 100.00
- Match type : NOTICE
- Links : http://www.freetype.org/FTL.TXT, http://www.freetype.org/license.html, https://spdx.org/licenses/FTL
- Files with this license:
- docs/DEBUG [303:307]
- docs/formats.txt [212:216]
-
-KEEP FTL fc8f51aafccf7c888013e4f8f7b7d0d4
-BELONGS ya.make
-FILE_INCLUDE LICENSE.TXT found in files: src/smooth/ftgrays.h at line 12
-FILE_INCLUDE include/freetype/ftimage.h found in files: src/smooth/ftgrays.h at line 28
-FILE_INCLUDE src/smooth/ftgrays.h found in files: src/smooth/ftgrays.h at line 37
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: FTL
- Score : 60.24
- Match type : NOTICE
- Links : http://www.freetype.org/FTL.TXT, http://www.freetype.org/license.html, https://spdx.org/licenses/FTL
- Files with this license:
- src/smooth/ftgrays.h [10:37]
- Scancode info:
- Original SPDX id: LicenseRef-scancode-autoconf-simple-exception-2.0
- Score : 60.24
- Match type : NOTICE
- Links : https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob;f=config.guess;h=a7448442748cc6f98a066d2d1051fad3b043761a;hb=HEAD, https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/autoconf-simple-exception-2.0.LICENSE
- Files with this license:
- src/smooth/ftgrays.h [10:37]
-
-KEEP FTL fcf80cd87fd7e7718b1f0cfb03da22a6
-BELONGS ya.make
-FILE_INCLUDE LICENSE.TXT found in files: docs/VERSIONS.TXT at line 133
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: FTL
- Score : 100.00
- Match type : NOTICE
- Links : http://www.freetype.org/FTL.TXT, http://www.freetype.org/license.html, https://spdx.org/licenses/FTL
- Files with this license:
- docs/VERSIONS.TXT [131:135]
diff --git a/contrib/libs/freetype/.yandex_meta/licenses.list.txt b/contrib/libs/freetype/.yandex_meta/licenses.list.txt
deleted file mode 100644
index be54d2798f..0000000000
--- a/contrib/libs/freetype/.yandex_meta/licenses.list.txt
+++ /dev/null
@@ -1,3037 +0,0 @@
-====================BSL-1.0====================
-// Distributed under the Boost Software License, Version 1.0.
-// See accompanying file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt
-
-
-====================COPYRIGHT====================
- Copyright 1996-2002, 2006 by
- David Turner, Robert Wilhelm, and Werner Lemberg
-
-
-====================COPYRIGHT====================
- Copyright (C) <year> Free Software Foundation Inc.
-
-
-====================COPYRIGHT====================
- Copyright (C) 2000-2004, 2006-2011, 2013, 2014 by
- Francesco Zappa Nardelli
-
-
-====================COPYRIGHT====================
- Copyright (C) 2001, 2002 by
- Francesco Zappa Nardelli
-
-
-====================COPYRIGHT====================
- Copyright (C) 2001-2008, 2011, 2013, 2014 by
- Francesco Zappa Nardelli
-
-
-====================COPYRIGHT====================
- Portions of this software are copyright © <year> The FreeType
- Project (www.freetype.org). All rights reserved.
-
-
-====================COPYRIGHT====================
- Copyright (C) 2000, 2001, 2002, 2003, 2006, 2010 by
- Francesco Zappa Nardelli
-
-
-====================COPYRIGHT====================
- Copyright (C) 2001, 2002, 2003, 2004 by
- Francesco Zappa Nardelli
-
-
-====================COPYRIGHT====================
- Copyright 2000, 2001, 2004 by
- Francesco Zappa Nardelli
-
-
-====================COPYRIGHT====================
- Copyright 2000-2001, 2002 by
- Francesco Zappa Nardelli
-
-
-====================COPYRIGHT====================
- Copyright 2000-2001, 2003 by
- Francesco Zappa Nardelli
-
-
-====================COPYRIGHT====================
- Copyright 2000-2010, 2012-2014 by
- Francesco Zappa Nardelli
-
-
-====================COPYRIGHT====================
- Copyright 2003 by
- Francesco Zappa Nardelli
-
-
-====================COPYRIGHT====================
- The FreeType Project is copyright (C) 1996-2000 by David Turner,
- Robert Wilhelm, and Werner Lemberg. All rights reserved except as
- specified below.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, Werner Lemberg, and Dominik Röttsches.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- * Copyright 2003 Huw D M Davies for Codeweavers
- * Copyright 2007 Dmitry Timoshkov for Codeweavers
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1996-2024 by
- * Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 2002-2024 by
- * Roberto Alameda.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 2003-2024 by
- * David Turner, Robert Wilhelm, Werner Lemberg, and Dominik Röttsches.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 2003-2024 by
- * Masatake YAMATO, Redhat K.K.,
- * David Turner, Robert Wilhelm, and Werner Lemberg.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 2004-2024 by
- * Albert Chin-A-Young.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 2004-2024 by
- * David Turner, Robert Wilhelm, Werner Lemberg and George Williams.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 2004-2024 by
- * David Turner, Robert Wilhelm, Werner Lemberg, and George Williams.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 2004-2024 by
- * Masatake YAMATO and Redhat K.K.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 2004-2024 by
- * Masatake YAMATO, Red Hat K.K.,
- * David Turner, Robert Wilhelm, and Werner Lemberg.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 2004-2024 by
- * Masatake YAMATO, Redhat K.K,
- * David Turner, Robert Wilhelm, and Werner Lemberg.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 2005-2024 by
- * David Turner.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 2007-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 2007-2024 by
- * David Turner.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 2007-2024 by
- * Dereg Clegg and Michael Toftdal.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 2007-2024 by
- * Derek Clegg and Michael Toftdal.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 2007-2024 by
- * Rahul Bhalerao <rahul.bhalerao@redhat.com>, <b.rahul.pm@gmail.com>.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 2008-2024 by
- * David Turner, Robert Wilhelm, Werner Lemberg, and suzuki toshiya.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 2008-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 2009-2024 by
- * Oran Agra and Mickey Gabel.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 2010-2024 by
- * Joel Klinghed.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 2012-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 2013-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 2013-2024 by
- * Google, Inc.
- * Written by Stuart Gill and Behdad Esfahbod.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 2016-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 2017-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 2018-2024 by
- * Armin Hasitzka, David Turner, Robert Wilhelm, and Werner Lemberg.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 2018-2024 by
- * David Turner, Robert Wilhelm, Dominik Röttsches, and Werner Lemberg.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 2018-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 2019-2024 by
- * Nikhil Ramakrishnan, David Turner, Robert Wilhelm, and Werner Lemberg.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 2020-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 2022-2024 by
- * David Turner, Robert Wilhelm, Werner Lemberg, George Williams, and
- * Dominik Röttsches.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 2022-2024 by
- * David Turner, Robert Wilhelm, Werner Lemberg, and Moazin Khatti.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 2024 by
- * David Saltzman
-
-
-====================COPYRIGHT====================
- * Copyright 2000 Computing Research Labs, New Mexico State University
- * Copyright 2001-2004, 2011 Francesco Zappa Nardelli
-
-
-====================COPYRIGHT====================
- * Copyright 2000 Computing Research Labs, New Mexico State University
- * Copyright 2001-2014
- * Francesco Zappa Nardelli
-
-
-====================COPYRIGHT====================
- * Copyright 2000 Computing Research Labs, New Mexico State University
- * Copyright 2001-2015
- * Francesco Zappa Nardelli
-
-
-====================COPYRIGHT====================
- * Copyright 2001, 2002, 2012 Francesco Zappa Nardelli
-
-
-====================COPYRIGHT====================
- * Copyright 2001, 2012 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
-
-
-====================COPYRIGHT====================
- * Copyright 2006-2013 Adobe Systems Incorporated.
-
-
-====================COPYRIGHT====================
- * Copyright 2007-2013 Adobe Systems Incorporated.
-
-
-====================COPYRIGHT====================
- * Copyright 2007-2014 Adobe Systems Incorporated.
-
-
-====================COPYRIGHT====================
- * Copyright 2009-2013 Adobe Systems Incorporated.
-
-
-====================COPYRIGHT====================
- * Copyright 2009-2014 Adobe Systems Incorporated.
-
-
-====================COPYRIGHT====================
- * Copyright 2011-2013 Adobe Systems Incorporated.
-
-
-====================COPYRIGHT====================
- * Copyright 2013 Adobe Systems Incorporated.
-
-
-====================COPYRIGHT====================
- * Copyright 2013 by Google, Inc.
- * Google Author(s): Behdad Esfahbod.
-
-
-====================COPYRIGHT====================
- * Copyright 2013-2014 Adobe Systems Incorporated.
-
-
-====================COPYRIGHT====================
- * Copyright © 2009, 2023 Red Hat, Inc.
- * Copyright © 2015 Google, Inc.
-
-
-====================COPYRIGHT====================
- * This software was written by Alexander Peslyak in 2001. No copyright is
- * claimed, and the software is hereby placed in the public domain.
- * In case this attempt to disclaim copyright and place the software in the
- * public domain is deemed null and void, then the software is
- * Copyright (c) 2001 Alexander Peslyak and it is hereby released to the
- * general public under the following terms:
-
-
-====================COPYRIGHT====================
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
-
-
-====================COPYRIGHT====================
-// Copyright (c) 2019 nyorain
-// Distributed under the Boost Software License, Version 1.0.
-// See accompanying file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt
-
-
-====================COPYRIGHT====================
-Copyright (C) 2000 by Francesco Zappa Nardelli
-
-
-====================COPYRIGHT====================
-Copyright (C) 2000-2024 by
-David Turner, Robert Wilhelm, and Werner Lemberg.
-
-
-====================COPYRIGHT====================
-Copyright (C) 2001-2002 by Francesco Zappa Nardelli
-
-
-====================COPYRIGHT====================
-Copyright (C) 2001-2024 by
-David Turner, Robert Wilhelm, and Werner Lemberg.
-
-
-====================COPYRIGHT====================
-Copyright (C) 2002-2024 by
-David Turner, Robert Wilhelm, and Werner Lemberg.
-
-
-====================COPYRIGHT====================
-Copyright (C) 2003-2024 by
-David Turner, Robert Wilhelm, and Werner Lemberg.
-
-
-====================COPYRIGHT====================
-Copyright (C) 2004-2024 by
-David Turner, Robert Wilhelm, and Werner Lemberg.
-
-
-====================COPYRIGHT====================
-Copyright (C) 2005-2024 by
-David Turner, Robert Wilhelm, and Werner Lemberg.
-
-
-====================COPYRIGHT====================
-Copyright (C) 2006-2024 by
-David Turner, Robert Wilhelm, and Werner Lemberg.
-
-
-====================COPYRIGHT====================
-Copyright (C) 2006-2024 by
-suzuki toshiya, David Turner, Robert Wilhelm, and Werner Lemberg.
-
-
-====================COPYRIGHT====================
-Copyright (C) 2018-2024 by
-Nikhil Ramakrishnan, David Turner, Robert Wilhelm, and Werner Lemberg.
-
-
-====================COPYRIGHT====================
-Copyright 1990, 1994, 1998 The Open Group
-
-
-====================COPYRIGHT====================
-Copyright 2000 Computing Research Labs, New Mexico State University
-Copyright 2001-2002, 2011 Francesco Zappa Nardelli
-
-
-====================COPYRIGHT====================
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
-
-====================FTL====================
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
-
-
-====================FTL====================
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTGRAYS_H_
-#define FTGRAYS_H_
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-
-#ifdef STANDALONE_
-#error #include "ftimage.h"
-#else
-#include <ft2build.h>
-#include <freetype/ftimage.h>
-#endif
-
-
- /**************************************************************************
- *
- * To make ftgrays.h independent from configuration files we check
-
-
-====================FTL====================
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-#ifndef FREETYPE_CONFIG_MAC_SUPPORT_H_
-#define FREETYPE_CONFIG_MAC_SUPPORT_H_
-
- /**************************************************************************
- *
- * Mac support
- *
- * This is the only necessary change, so it is defined here instead
- * providing a new configuration file.
-
-
-====================FTL====================
- * This software, and all works of authorship, whether in source or
- * object code form as indicated by the copyright notice(s) included
- * herein (collectively, the "Work") is made available, and may only be
- * used, modified, and distributed under the FreeType Project License,
- * LICENSE.TXT. Additionally, subject to the terms and conditions of the
- * FreeType Project License, each contributor to the Work hereby grants
- * to any individual or legal entity exercising permissions granted by
- * the FreeType Project License and this section (hereafter, "You" or
- * "Your") a perpetual, worldwide, non-exclusive, no-charge,
- * royalty-free, irrevocable (except as stated in this section) patent
- * license to make, have made, use, offer to sell, sell, import, and
- * otherwise transfer the Work, where such license applies only to those
- * patent claims licensable by such contributor that are necessarily
- * infringed by their contribution(s) alone or by combination of their
- * contribution(s) with the Work to which such contribution(s) was
- * submitted. If You institute patent litigation against any entity
- * (including a cross-claim or counterclaim in a lawsuit) alleging that
- * the Work or a contribution incorporated within the Work constitutes
- * direct or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate as of
- * the date such litigation is filed.
- *
- * By using, modifying, or distributing the Work you indicate that you
- * have read and understood the terms and conditions of the
- * FreeType Project License as well as those provided in this section,
- * and you accept them fully.
-
-
-====================FTL====================
-This file is part of the FreeType project, and may only be used,
-modified, and distributed under the terms of the FreeType project
-license, LICENSE.TXT. By continuing to use, modify, or distribute this
-file you indicate that you have read the license and understand and
-accept it fully.
-
-
-====================FTL====================
-This file is part of the FreeType project, and may only be used,
-modified, and distributed under the terms of the FreeType project
-license, LICENSE.TXT. By continuing to use, modify, or distribute
-this file you indicate that you have read the license and understand
-and accept it fully.
-
-
-====================FTL OR GPL-2.0-or-later====================
-This file is part of the FreeType project, and may only be used,
-modified, and distributed under the terms of the FreeType project
-license, LICENSE.TXT. By continuing to use, modify, or distribute this
-file you indicate that you have read the license and understand and
-accept it fully.
-
-
-====================FTL OR GPL-2.0-or-later====================
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) year name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
-
-====================FTL OR GPL-2.0-or-later====================
- The FreeType Project LICENSE
- ----------------------------
-
- 2006-Jan-27
-
- Copyright 1996-2002, 2006 by
- David Turner, Robert Wilhelm, and Werner Lemberg
-
-
-
-Introduction
-============
-
- The FreeType Project is distributed in several archive packages;
- some of them may contain, in addition to the FreeType font engine,
- various tools and contributions which rely on, or relate to, the
- FreeType Project.
-
- This license applies to all files found in such packages, and
- which do not fall under their own explicit license. The license
- affects thus the FreeType font engine, the test programs,
- documentation and makefiles, at the very least.
-
- This license was inspired by the BSD, Artistic, and IJG
- (Independent JPEG Group) licenses, which all encourage inclusion
- and use of free software in commercial and freeware products
- alike. As a consequence, its main points are that:
-
- o We don't promise that this software works. However, we will be
- interested in any kind of bug reports. (`as is' distribution)
-
- o You can use this software for whatever you want, in parts or
- full form, without having to pay us. (`royalty-free' usage)
-
- o You may not pretend that you wrote this software. If you use
- it, or only parts of it, in a program, you must acknowledge
- somewhere in your documentation that you have used the
- FreeType code. (`credits')
-
- We specifically permit and encourage the inclusion of this
- software, with or without modifications, in commercial products.
- We disclaim all warranties covering The FreeType Project and
- assume no liability related to The FreeType Project.
-
-
- Finally, many people asked us for a preferred form for a
- credit/disclaimer to use in compliance with this license. We thus
- encourage you to use the following text:
-
- """
- Portions of this software are copyright © <year> The FreeType
- Project (www.freetype.org). All rights reserved.
- """
-
- Please replace <year> with the value from the FreeType version you
- actually use.
-
-
-Legal Terms
-===========
-
-0. Definitions
---------------
-
- Throughout this license, the terms `package', `FreeType Project',
- and `FreeType archive' refer to the set of files originally
- distributed by the authors (David Turner, Robert Wilhelm, and
- Werner Lemberg) as the `FreeType Project', be they named as alpha,
- beta or final release.
-
- `You' refers to the licensee, or person using the project, where
- `using' is a generic term including compiling the project's source
- code as well as linking it to form a `program' or `executable'.
- This program is referred to as `a program using the FreeType
- engine'.
-
- This license applies to all files distributed in the original
- FreeType Project, including all source code, binaries and
- documentation, unless otherwise stated in the file in its
- original, unmodified form as distributed in the original archive.
- If you are unsure whether or not a particular file is covered by
- this license, you must contact us to verify this.
-
- The FreeType Project is copyright (C) 1996-2000 by David Turner,
- Robert Wilhelm, and Werner Lemberg. All rights reserved except as
- specified below.
-
-1. No Warranty
---------------
-
- THE FREETYPE PROJECT IS PROVIDED `AS IS' WITHOUT WARRANTY OF ANY
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE. IN NO EVENT WILL ANY OF THE AUTHORS OR COPYRIGHT HOLDERS
- BE LIABLE FOR ANY DAMAGES CAUSED BY THE USE OR THE INABILITY TO
- USE, OF THE FREETYPE PROJECT.
-
-2. Redistribution
------------------
-
- This license grants a worldwide, royalty-free, perpetual and
- irrevocable right and license to use, execute, perform, compile,
- display, copy, create derivative works of, distribute and
- sublicense the FreeType Project (in both source and object code
- forms) and derivative works thereof for any purpose; and to
- authorize others to exercise some or all of the rights granted
- herein, subject to the following conditions:
-
- o Redistribution of source code must retain this license file
- (`FTL.TXT') unaltered; any additions, deletions or changes to
- the original files must be clearly indicated in accompanying
- documentation. The copyright notices of the unaltered,
- original files must be preserved in all copies of source
- files.
-
- o Redistribution in binary form must provide a disclaimer that
- states that the software is based in part of the work of the
- FreeType Team, in the distribution documentation. We also
- encourage you to put an URL to the FreeType web page in your
- documentation, though this isn't mandatory.
-
- These conditions apply to any software derived from or based on
- the FreeType Project, not just the unmodified files. If you use
- our work, you must acknowledge us. However, no fee need be paid
- to us.
-
-3. Advertising
---------------
-
- Neither the FreeType authors and contributors nor you shall use
- the name of the other for commercial, advertising, or promotional
- purposes without specific prior written permission.
-
- We suggest, but do not require, that you use one or more of the
- following phrases to refer to this software in your documentation
- or advertising materials: `FreeType Project', `FreeType Engine',
- `FreeType library', or `FreeType Distribution'.
-
- As you have not signed this license, you are not required to
- accept it. However, as the FreeType Project is copyrighted
- material, only this license, or another one contracted with the
- authors, grants you the right to use, distribute, and modify it.
- Therefore, by using, distributing, or modifying the FreeType
- Project, you indicate that you understand and accept all the terms
- of this license.
-
-4. Contacts
------------
-
- There are two mailing lists related to FreeType:
-
- o freetype@nongnu.org
-
- Discusses general use and applications of FreeType, as well as
- future and wanted additions to the library and distribution.
- If you are looking for support, start in this list if you
- haven't found anything to help you in the documentation.
-
- o freetype-devel@nongnu.org
-
- Discusses bugs, as well as engine internals, design issues,
- specific licenses, porting, etc.
-
- Our home page can be found at
-
-
-====================FTL OR GPL-2.0-or-later====================
- `docs/GPLv2.TXT` (any later version can be used also), for
-
-
-====================FTL OR GPL-2.0-or-later====================
- - The GNU General Public License version 2, found in
-
-
-====================FTL OR GPL-2.0-or-later====================
- * This file is part of the FreeType project, and may only be used
- * modified and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
-
-
-====================FTL OR GPL-2.0-or-later====================
-This file is part of the FreeType project, and may only be used,
-modified, and distributed under the terms of the FreeType project
-license, LICENSE.TXT. By continuing to use, modify, or distribute
-this file you indicate that you have read the license and understand
-and accept it fully.
-
-
-====================File: LICENSE.TXT====================
-FREETYPE LICENSES
------------------
-
-The FreeType 2 font engine is copyrighted work and cannot be used
-legally without a software license. In order to make this project
-usable to a vast majority of developers, we distribute it under two
-mutually exclusive open-source licenses.
-
-This means that *you* must choose *one* of the two licenses described
-below, then obey all its terms and conditions when using FreeType 2 in
-any of your projects or products.
-
- - The FreeType License, found in the file `docs/FTL.TXT`, which is
- similar to the original BSD license *with* an advertising clause
- that forces you to explicitly cite the FreeType project in your
- product's documentation. All details are in the license file.
- This license is suited to products which don't use the GNU General
- Public License.
-
- Note that this license is compatible to the GNU General Public
- License version 3, but not version 2.
-
- - The GNU General Public License version 2, found in
- `docs/GPLv2.TXT` (any later version can be used also), for
- programs which already use the GPL. Note that the FTL is
- incompatible with GPLv2 due to its advertisement clause.
-
-The contributed BDF and PCF drivers come with a license similar to
-that of the X Window System. It is compatible to the above two
-licenses (see files `src/bdf/README` and `src/pcf/README`). The same
-holds for the source code files `src/base/fthash.c` and
-`include/freetype/internal/fthash.h`; they were part of the BDF driver
-in earlier FreeType versions.
-
-The gzip module uses the zlib license (see `src/gzip/zlib.h`) which
-too is compatible to the above two licenses.
-
-The files `src/autofit/ft-hb.c` and `src/autofit/ft-hb.h` contain code
-taken almost verbatim from the HarfBuzz file `hb-ft.cc`, which uses
-the 'Old MIT' license, compatible to the above two licenses.
-
-The MD5 checksum support (only used for debugging in development
-builds) is in the public domain.
-
-
---- end of LICENSE.TXT ---
-
-
-====================File: docs/FTL.TXT====================
- The FreeType Project LICENSE
- ----------------------------
-
- 2006-Jan-27
-
- Copyright 1996-2002, 2006 by
- David Turner, Robert Wilhelm, and Werner Lemberg
-
-
-
-Introduction
-============
-
- The FreeType Project is distributed in several archive packages;
- some of them may contain, in addition to the FreeType font engine,
- various tools and contributions which rely on, or relate to, the
- FreeType Project.
-
- This license applies to all files found in such packages, and
- which do not fall under their own explicit license. The license
- affects thus the FreeType font engine, the test programs,
- documentation and makefiles, at the very least.
-
- This license was inspired by the BSD, Artistic, and IJG
- (Independent JPEG Group) licenses, which all encourage inclusion
- and use of free software in commercial and freeware products
- alike. As a consequence, its main points are that:
-
- o We don't promise that this software works. However, we will be
- interested in any kind of bug reports. (`as is' distribution)
-
- o You can use this software for whatever you want, in parts or
- full form, without having to pay us. (`royalty-free' usage)
-
- o You may not pretend that you wrote this software. If you use
- it, or only parts of it, in a program, you must acknowledge
- somewhere in your documentation that you have used the
- FreeType code. (`credits')
-
- We specifically permit and encourage the inclusion of this
- software, with or without modifications, in commercial products.
- We disclaim all warranties covering The FreeType Project and
- assume no liability related to The FreeType Project.
-
-
- Finally, many people asked us for a preferred form for a
- credit/disclaimer to use in compliance with this license. We thus
- encourage you to use the following text:
-
- """
- Portions of this software are copyright © <year> The FreeType
- Project (www.freetype.org). All rights reserved.
- """
-
- Please replace <year> with the value from the FreeType version you
- actually use.
-
-
-Legal Terms
-===========
-
-0. Definitions
---------------
-
- Throughout this license, the terms `package', `FreeType Project',
- and `FreeType archive' refer to the set of files originally
- distributed by the authors (David Turner, Robert Wilhelm, and
- Werner Lemberg) as the `FreeType Project', be they named as alpha,
- beta or final release.
-
- `You' refers to the licensee, or person using the project, where
- `using' is a generic term including compiling the project's source
- code as well as linking it to form a `program' or `executable'.
- This program is referred to as `a program using the FreeType
- engine'.
-
- This license applies to all files distributed in the original
- FreeType Project, including all source code, binaries and
- documentation, unless otherwise stated in the file in its
- original, unmodified form as distributed in the original archive.
- If you are unsure whether or not a particular file is covered by
- this license, you must contact us to verify this.
-
- The FreeType Project is copyright (C) 1996-2000 by David Turner,
- Robert Wilhelm, and Werner Lemberg. All rights reserved except as
- specified below.
-
-1. No Warranty
---------------
-
- THE FREETYPE PROJECT IS PROVIDED `AS IS' WITHOUT WARRANTY OF ANY
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE. IN NO EVENT WILL ANY OF THE AUTHORS OR COPYRIGHT HOLDERS
- BE LIABLE FOR ANY DAMAGES CAUSED BY THE USE OR THE INABILITY TO
- USE, OF THE FREETYPE PROJECT.
-
-2. Redistribution
------------------
-
- This license grants a worldwide, royalty-free, perpetual and
- irrevocable right and license to use, execute, perform, compile,
- display, copy, create derivative works of, distribute and
- sublicense the FreeType Project (in both source and object code
- forms) and derivative works thereof for any purpose; and to
- authorize others to exercise some or all of the rights granted
- herein, subject to the following conditions:
-
- o Redistribution of source code must retain this license file
- (`FTL.TXT') unaltered; any additions, deletions or changes to
- the original files must be clearly indicated in accompanying
- documentation. The copyright notices of the unaltered,
- original files must be preserved in all copies of source
- files.
-
- o Redistribution in binary form must provide a disclaimer that
- states that the software is based in part of the work of the
- FreeType Team, in the distribution documentation. We also
- encourage you to put an URL to the FreeType web page in your
- documentation, though this isn't mandatory.
-
- These conditions apply to any software derived from or based on
- the FreeType Project, not just the unmodified files. If you use
- our work, you must acknowledge us. However, no fee need be paid
- to us.
-
-3. Advertising
---------------
-
- Neither the FreeType authors and contributors nor you shall use
- the name of the other for commercial, advertising, or promotional
- purposes without specific prior written permission.
-
- We suggest, but do not require, that you use one or more of the
- following phrases to refer to this software in your documentation
- or advertising materials: `FreeType Project', `FreeType Engine',
- `FreeType library', or `FreeType Distribution'.
-
- As you have not signed this license, you are not required to
- accept it. However, as the FreeType Project is copyrighted
- material, only this license, or another one contracted with the
- authors, grants you the right to use, distribute, and modify it.
- Therefore, by using, distributing, or modifying the FreeType
- Project, you indicate that you understand and accept all the terms
- of this license.
-
-4. Contacts
------------
-
- There are two mailing lists related to FreeType:
-
- o freetype@nongnu.org
-
- Discusses general use and applications of FreeType, as well as
- future and wanted additions to the library and distribution.
- If you are looking for support, start in this list if you
- haven't found anything to help you in the documentation.
-
- o freetype-devel@nongnu.org
-
- Discusses bugs, as well as engine internals, design issues,
- specific licenses, porting, etc.
-
- Our home page can be found at
-
- https://www.freetype.org
-
-
---- end of FTL.TXT ---
-
-
-====================File: docs/release====================
-How to prepare a new release
-----------------------------
-
-. include/freetype/freetype.h: Update `FREETYPE_MAJOR`,
- `FREETYPE_MINOR`, and `FREETYPE_PATCH`.
-
-. Update version numbers in all files where necessary (for example, do
- a grep for both '2.13.2' and '2132' for release 2.13.2).
-
-. builds/unix/configure.raw: Update `version_info`.
-
-. docs/CHANGES: Document differences to last release.
-
-. README: Update.
-
-. docs/VERSIONS.TXT: Document changed `version_info`.
-
-. Update the 'dlg' submodule with
-
- git submodule foreach git pull origin master
-
-. Copy the submodule code with
-
- make copy_submodule
-
- and run
-
- make distclean && make devel && make
- make distclean && make devel && make multi
- make distclean && make devel CC=g++ && make CC=g++ ANSIFLAGS=""
- make distclean && make devel CC=g++ && make multi CC=g++ ANSIFLAGS=""
-
- sh autogen.sh
- make distclean && ./configure CC=g++ && make ANSIFLAGS=""
-
- to test compilation with both gcc and g++ (you might also add the `-j`
- flag to `make` for parallel compilation).
-
- Note that it is normally not necessary to test standard C
- compilation with the `configure`, `meson`, and `cmake` build tools
- since this is done by the CI process of 'gitlab.freedesktop.org' for
- every commit.
-
-. Test C++ compilation for 'freetype-demos' too; this needs a compiled
- FreeType library as described in the `README` file.
-
- make distclean && make
- make distclean && make CC=g++ ANSIFLAGS=""
-
-. Run `src/tools/chktrcmp.py` and check that there are no undefined
- `trace_XXXX` macros.
-
-. Update meson subproject files (for both the 'freetype' and
- 'freetype-demos' git repositories) with
-
- meson subprojects update
-
-. Test meson compilation (for both the 'freetype' and 'freetype-demos'
- git repositories) with
-
- meson setup builddir && meson compile -C builddir
-
-. Commit everything.
-
-. After pushing the new release, tag the git repositories ('freetype',
- 'freetype-demos') with
-
- git tag VER-<version> -m "" -u <committer>
-
- and push the tags with
-
- git push --tags
-
-. Check with
-
- git clean -ndx
-
- that the git directory is really clean (and remove extraneous files
- if necessary).
-
-. Say `make dist` in both the 'freetype' and 'freetype-demos'
- repositories to generate the `.tar.gz`, `.tar.xz`, and `.zip` files.
-
-. Create the doc bundles (`freetype-doc-<version>.tar.gz`,
- `freetype-doc-<version>.tar.xz`, `ftdoc<version>.zip`). This is
- everything in
-
- <freetype-web git repository>/freetype2/docs
-
- except the `reference` subdirectory. Do *not* use option `-l` from
- zip!
-
-. Run the following script (with updated `$VERSION`, `$SAVANNAH_USER`,
- `$SOURCEFORGE_USER`, and `GPG_KEY_ID` variables) to sign and upload
- the bundles to both Savannah and SourceForge. The signing code has
- been taken from the `gnupload` script (part of the 'automake'
- bundle).
-
- #!/bin/sh
-
- VERSION=2.13.2
- SAVANNAH_USER=wl
- SOURCEFORGE_USER=wlemb
- GPG_KEY_ID=BE6C3AAC63AD8E3F
-
- #####################################################################
-
- GPG="/usr/bin/gpg --batch --no-tty --local-user $GPG_KEY_ID"
-
- version=`echo $VERSION | sed "s/\\.//g"`
-
- FREETYPE_PACKAGES="freetype-$VERSION.tar.gz \
- freetype-$VERSION.tar.xz \
- ft$version.zip"
- FT2DEMOS_PACKAGES="ft2demos-$VERSION.tar.gz \
- ft2demos-$VERSION.tar.xz \
- ftdmo$version.zip"
- FTDOC_PACKAGES="freetype-doc-$VERSION.tar.gz \
- freetype-doc-$VERSION.tar.xz \
- ftdoc$version.zip"
-
- PACKAGE_LIST="$FREETYPE_PACKAGES \
- $FT2DEMOS_PACKAGES \
- $FTDOC_PACKAGES"
-
- set -e
- unset passphrase
-
- PATH=/empty echo -n "Enter GPG passphrase: "
- stty -echo
- read -r passphrase
- stty echo
- echo
-
- for f in $PACKAGE_LIST; do
- if test ! -f $f; then
- echo "$0: Cannot find \`$f'" 1>&2
- exit 1
- else
- :
- fi
- done
-
- for f in $PACKAGE_LIST; do
- echo "Signing $f..."
- rm -f $f.sig
- echo $passphrase | $GPG --passphrase-fd 0 -ba -o $f.sig $f
- done
-
- FREETYPE_SIGNATURES=
- for i in $FREETYPE_PACKAGES; do
- FREETYPE_SIGNATURES="$FREETYPE_SIGNATURES $i.sig"
- done
-
- FT2DEMOS_SIGNATURES=
- for i in $FT2DEMOS_PACKAGES; do
- FT2DEMOS_SIGNATURES="$FT2DEMOS_SIGNATURES $i.sig"
- done
-
- FTDOC_SIGNATURES=
- for i in $FTDOC_PACKAGES; do
- FTDOC_SIGNATURES="$FTDOC_SIGNATURES $i.sig"
- done
-
- SIGNATURE_LIST="$FREETYPE_SIGNATURES \
- $FT2DEMOS_SIGNATURES \
- $FTDOC_SIGNATURES"
-
- scp $PACKAGE_LIST $SIGNATURE_LIST \
- $SAVANNAH_USER@dl.sv.nongnu.org:/releases/freetype/
-
- rsync -avP -e ssh $FREETYPE_PACKAGES $FREETYPE_SIGNATURES \
- $SOURCEFORGE_USER,freetype@frs.sf.net:/home/frs/project/f/fr/freetype/freetype2/$VERSION/
- rsync -avP -e ssh $FT2DEMOS_PACKAGES $FT2DEMOS_SIGNATURES \
- $SOURCEFORGE_USER,freetype@frs.sf.net:/home/frs/project/f/fr/freetype/freetype-demos/$VERSION/
- rsync -avP -e ssh $FTDOC_PACKAGES $FTDOC_SIGNATURES \
- $SOURCEFORGE_USER,freetype@frs.sf.net:/home/frs/project/f/fr/freetype/freetype-docs/$VERSION/
-
- # EOF
-
-. Prepare a `README` file for SourceForge and upload it with the
- following script (with updated `$VERSION` and `$SOURCEFORGE_USER`
- variables).
-
- #!/bin/sh
-
- VERSION=2.13.2
- SOURCEFORGE_USER=wlemb
-
- #####################################################################
-
- rsync -avP -e ssh README \
- $SOURCEFORGE_USER,freetype@frs.sf.net:/home/frs/project/f/fr/freetype/freetype2/$VERSION/
-
- # EOF
-
-. On SourceForge, tag the just uploaded `ftXXX.zip` and
- `freetype-XXX.tar.xz` files as the default files to download for
- 'Windows' and 'Others', respectively.
-
-. Trigger the automatic generation of the online API reference by
- updating the `FT_VERSION` variable in file `.gitlab-ci.yml` of the
- 'freetype-web' repository.
-
-. Announce new release on 'freetype-announce@nongnu.org' and to
- relevant newsgroups. The text should include
-
- - SHA256 checksums of all files,
- - instructions how to verify the bundles using the `.sig` file data,
- - the PGP public key used to sign the archives.
-
-----------------------------------------------------------------------
-
-Copyright (C) 2003-2024 by
-David Turner, Robert Wilhelm, and Werner Lemberg.
-
-This file is part of the FreeType project, and may only be used,
-modified, and distributed under the terms of the FreeType project
-license, LICENSE.TXT. By continuing to use, modify, or distribute
-this file you indicate that you have read the license and understand
-and accept it fully.
-
-
---- end of release ---
-
-
-====================File: include/freetype/ftimage.h====================
-/****************************************************************************
- *
- * ftimage.h
- *
- * FreeType glyph image formats and default raster interface
- * (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
- /**************************************************************************
- *
- * Note: A 'raster' is simply a scan-line converter, used to render
- * `FT_Outline`s into `FT_Bitmap`s.
- *
- * Note: This file can be used for `STANDALONE_` compilation of raster
- * (B/W) and smooth (anti-aliased) renderers. Therefore, it must
- * rely on standard variable types only instead of aliases in
- * `fttypes.h`.
- *
- */
-
-
-#ifndef FTIMAGE_H_
-#define FTIMAGE_H_
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @section:
- * basic_types
- *
- */
-
-
- /**************************************************************************
- *
- * @type:
- * FT_Pos
- *
- * @description:
- * The type FT_Pos is used to store vectorial coordinates. Depending on
- * the context, these can represent distances in integer font units, or
- * 16.16, or 26.6 fixed-point pixel coordinates.
- */
- typedef signed long FT_Pos;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_Vector
- *
- * @description:
- * A simple structure used to store a 2D vector; coordinates are of the
- * FT_Pos type.
- *
- * @fields:
- * x ::
- * The horizontal coordinate.
- * y ::
- * The vertical coordinate.
- */
- typedef struct FT_Vector_
- {
- FT_Pos x;
- FT_Pos y;
-
- } FT_Vector;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_BBox
- *
- * @description:
- * A structure used to hold an outline's bounding box, i.e., the
- * coordinates of its extrema in the horizontal and vertical directions.
- *
- * @fields:
- * xMin ::
- * The horizontal minimum (left-most).
- *
- * yMin ::
- * The vertical minimum (bottom-most).
- *
- * xMax ::
- * The horizontal maximum (right-most).
- *
- * yMax ::
- * The vertical maximum (top-most).
- *
- * @note:
- * The bounding box is specified with the coordinates of the lower left
- * and the upper right corner. In PostScript, those values are often
- * called (llx,lly) and (urx,ury), respectively.
- *
- * If `yMin` is negative, this value gives the glyph's descender.
- * Otherwise, the glyph doesn't descend below the baseline. Similarly,
- * if `ymax` is positive, this value gives the glyph's ascender.
- *
- * `xMin` gives the horizontal distance from the glyph's origin to the
- * left edge of the glyph's bounding box. If `xMin` is negative, the
- * glyph extends to the left of the origin.
- */
- typedef struct FT_BBox_
- {
- FT_Pos xMin, yMin;
- FT_Pos xMax, yMax;
-
- } FT_BBox;
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_Pixel_Mode
- *
- * @description:
- * An enumeration type used to describe the format of pixels in a given
- * bitmap. Note that additional formats may be added in the future.
- *
- * @values:
- * FT_PIXEL_MODE_NONE ::
- * Value~0 is reserved.
- *
- * FT_PIXEL_MODE_MONO ::
- * A monochrome bitmap, using 1~bit per pixel. Note that pixels are
- * stored in most-significant order (MSB), which means that the
- * left-most pixel in a byte has value 128.
- *
- * FT_PIXEL_MODE_GRAY ::
- * An 8-bit bitmap, generally used to represent anti-aliased glyph
- * images. Each pixel is stored in one byte. Note that the number of
- * 'gray' levels is stored in the `num_grays` field of the @FT_Bitmap
- * structure (it generally is 256).
- *
- * FT_PIXEL_MODE_GRAY2 ::
- * A 2-bit per pixel bitmap, used to represent embedded anti-aliased
- * bitmaps in font files according to the OpenType specification. We
- * haven't found a single font using this format, however.
- *
- * FT_PIXEL_MODE_GRAY4 ::
- * A 4-bit per pixel bitmap, representing embedded anti-aliased bitmaps
- * in font files according to the OpenType specification. We haven't
- * found a single font using this format, however.
- *
- * FT_PIXEL_MODE_LCD ::
- * An 8-bit bitmap, representing RGB or BGR decimated glyph images used
- * for display on LCD displays; the bitmap is three times wider than
- * the original glyph image. See also @FT_RENDER_MODE_LCD.
- *
- * FT_PIXEL_MODE_LCD_V ::
- * An 8-bit bitmap, representing RGB or BGR decimated glyph images used
- * for display on rotated LCD displays; the bitmap is three times
- * taller than the original glyph image. See also
- * @FT_RENDER_MODE_LCD_V.
- *
- * FT_PIXEL_MODE_BGRA ::
- * [Since 2.5] An image with four 8-bit channels per pixel,
- * representing a color image (such as emoticons) with alpha channel.
- * For each pixel, the format is BGRA, which means, the blue channel
- * comes first in memory. The color channels are pre-multiplied and in
- * the sRGB colorspace. For example, full red at half-translucent
- * opacity will be represented as '00,00,80,80', not '00,00,FF,80'.
- * See also @FT_LOAD_COLOR.
- */
- typedef enum FT_Pixel_Mode_
- {
- FT_PIXEL_MODE_NONE = 0,
- FT_PIXEL_MODE_MONO,
- FT_PIXEL_MODE_GRAY,
- FT_PIXEL_MODE_GRAY2,
- FT_PIXEL_MODE_GRAY4,
- FT_PIXEL_MODE_LCD,
- FT_PIXEL_MODE_LCD_V,
- FT_PIXEL_MODE_BGRA,
-
- FT_PIXEL_MODE_MAX /* do not remove */
-
- } FT_Pixel_Mode;
-
-
- /* these constants are deprecated; use the corresponding `FT_Pixel_Mode` */
- /* values instead. */
-#define ft_pixel_mode_none FT_PIXEL_MODE_NONE
-#define ft_pixel_mode_mono FT_PIXEL_MODE_MONO
-#define ft_pixel_mode_grays FT_PIXEL_MODE_GRAY
-#define ft_pixel_mode_pal2 FT_PIXEL_MODE_GRAY2
-#define ft_pixel_mode_pal4 FT_PIXEL_MODE_GRAY4
-
- /* */
-
- /* For debugging, the @FT_Pixel_Mode enumeration must stay in sync */
- /* with the `pixel_modes` array in file `ftobjs.c`. */
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_Bitmap
- *
- * @description:
- * A structure used to describe a bitmap or pixmap to the raster. Note
- * that we now manage pixmaps of various depths through the `pixel_mode`
- * field.
- *
- * @fields:
- * rows ::
- * The number of bitmap rows.
- *
- * width ::
- * The number of pixels in bitmap row.
- *
- * pitch ::
- * The pitch's absolute value is the number of bytes taken by one
- * bitmap row, including padding. However, the pitch is positive when
- * the bitmap has a 'down' flow, and negative when it has an 'up' flow.
- * In all cases, the pitch is an offset to add to a bitmap pointer in
- * order to go down one row.
- *
- * Note that 'padding' means the alignment of a bitmap to a byte
- * border, and FreeType functions normally align to the smallest
- * possible integer value.
- *
- * For the B/W rasterizer, `pitch` is always an even number.
- *
- * To change the pitch of a bitmap (say, to make it a multiple of 4),
- * use @FT_Bitmap_Convert. Alternatively, you might use callback
- * functions to directly render to the application's surface; see the
- * file `example2.cpp` in the tutorial for a demonstration.
- *
- * buffer ::
- * A typeless pointer to the bitmap buffer. This value should be
- * aligned on 32-bit boundaries in most cases.
- *
- * num_grays ::
- * This field is only used with @FT_PIXEL_MODE_GRAY; it gives the
- * number of gray levels used in the bitmap.
- *
- * pixel_mode ::
- * The pixel mode, i.e., how pixel bits are stored. See @FT_Pixel_Mode
- * for possible values.
- *
- * palette_mode ::
- * This field is intended for paletted pixel modes; it indicates how
- * the palette is stored. Not used currently.
- *
- * palette ::
- * A typeless pointer to the bitmap palette; this field is intended for
- * paletted pixel modes. Not used currently.
- *
- * @note:
- * `width` and `rows` refer to the *physical* size of the bitmap, not the
- * *logical* one. For example, if @FT_Pixel_Mode is set to
- * `FT_PIXEL_MODE_LCD`, the logical width is a just a third of the
- * physical one.
- */
- typedef struct FT_Bitmap_
- {
- unsigned int rows;
- unsigned int width;
- int pitch;
- unsigned char* buffer;
- unsigned short num_grays;
- unsigned char pixel_mode;
- unsigned char palette_mode;
- void* palette;
-
- } FT_Bitmap;
-
-
- /**************************************************************************
- *
- * @section:
- * outline_processing
- *
- */
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_Outline
- *
- * @description:
- * This structure is used to describe an outline to the scan-line
- * converter.
- *
- * @fields:
- * n_contours ::
- * The number of contours in the outline.
- *
- * n_points ::
- * The number of points in the outline.
- *
- * points ::
- * A pointer to an array of `n_points` @FT_Vector elements, giving the
- * outline's point coordinates.
- *
- * tags ::
- * A pointer to an array of `n_points` chars, giving each outline
- * point's type.
- *
- * If bit~0 is unset, the point is 'off' the curve, i.e., a Bezier
- * control point, while it is 'on' if set.
- *
- * Bit~1 is meaningful for 'off' points only. If set, it indicates a
- * third-order Bezier arc control point; and a second-order control
- * point if unset.
- *
- * If bit~2 is set, bits 5-7 contain the drop-out mode (as defined in
- * the OpenType specification; the value is the same as the argument to
- * the 'SCANTYPE' instruction).
- *
- * Bits 3 and~4 are reserved for internal purposes.
- *
- * contours ::
- * An array of `n_contours` shorts, giving the end point of each
- * contour within the outline. For example, the first contour is
- * defined by the points '0' to `contours[0]`, the second one is
- * defined by the points `contours[0]+1` to `contours[1]`, etc.
- *
- * flags ::
- * A set of bit flags used to characterize the outline and give hints
- * to the scan-converter and hinter on how to convert/grid-fit it. See
- * @FT_OUTLINE_XXX.
- *
- * @note:
- * The B/W rasterizer only checks bit~2 in the `tags` array for the first
- * point of each contour. The drop-out mode as given with
- * @FT_OUTLINE_IGNORE_DROPOUTS, @FT_OUTLINE_SMART_DROPOUTS, and
- * @FT_OUTLINE_INCLUDE_STUBS in `flags` is then overridden.
- */
- typedef struct FT_Outline_
- {
- unsigned short n_contours; /* number of contours in glyph */
- unsigned short n_points; /* number of points in the glyph */
-
- FT_Vector* points; /* the outline's points */
- unsigned char* tags; /* the points flags */
- unsigned short* contours; /* the contour end points */
-
- int flags; /* outline masks */
-
- } FT_Outline;
-
- /* */
-
- /* Following limits must be consistent with */
- /* FT_Outline.{n_contours,n_points} */
-#define FT_OUTLINE_CONTOURS_MAX USHRT_MAX
-#define FT_OUTLINE_POINTS_MAX USHRT_MAX
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_OUTLINE_XXX
- *
- * @description:
- * A list of bit-field constants used for the flags in an outline's
- * `flags` field.
- *
- * @values:
- * FT_OUTLINE_NONE ::
- * Value~0 is reserved.
- *
- * FT_OUTLINE_OWNER ::
- * If set, this flag indicates that the outline's field arrays (i.e.,
- * `points`, `flags`, and `contours`) are 'owned' by the outline
- * object, and should thus be freed when it is destroyed.
- *
- * FT_OUTLINE_EVEN_ODD_FILL ::
- * By default, outlines are filled using the non-zero winding rule. If
- * set to 1, the outline will be filled using the even-odd fill rule
- * (only works with the smooth rasterizer).
- *
- * FT_OUTLINE_REVERSE_FILL ::
- * By default, outside contours of an outline are oriented in
- * clock-wise direction, as defined in the TrueType specification.
- * This flag is set if the outline uses the opposite direction
- * (typically for Type~1 fonts). This flag is ignored by the scan
- * converter.
- *
- * FT_OUTLINE_IGNORE_DROPOUTS ::
- * By default, the scan converter will try to detect drop-outs in an
- * outline and correct the glyph bitmap to ensure consistent shape
- * continuity. If set, this flag hints the scan-line converter to
- * ignore such cases. See below for more information.
- *
- * FT_OUTLINE_SMART_DROPOUTS ::
- * Select smart dropout control. If unset, use simple dropout control.
- * Ignored if @FT_OUTLINE_IGNORE_DROPOUTS is set. See below for more
- * information.
- *
- * FT_OUTLINE_INCLUDE_STUBS ::
- * If set, turn pixels on for 'stubs', otherwise exclude them. Ignored
- * if @FT_OUTLINE_IGNORE_DROPOUTS is set. See below for more
- * information.
- *
- * FT_OUTLINE_OVERLAP ::
- * [Since 2.10.3] This flag indicates that this outline contains
- * overlapping contours and the anti-aliased renderer should perform
- * oversampling to mitigate possible artifacts. This flag should _not_
- * be set for well designed glyphs without overlaps because it quadruples
- * the rendering time.
- *
- * FT_OUTLINE_HIGH_PRECISION ::
- * This flag indicates that the scan-line converter should try to
- * convert this outline to bitmaps with the highest possible quality.
- * It is typically set for small character sizes. Note that this is
- * only a hint that might be completely ignored by a given
- * scan-converter.
- *
- * FT_OUTLINE_SINGLE_PASS ::
- * This flag is set to force a given scan-converter to only use a
- * single pass over the outline to render a bitmap glyph image.
- * Normally, it is set for very large character sizes. It is only a
- * hint that might be completely ignored by a given scan-converter.
- *
- * @note:
- * The flags @FT_OUTLINE_IGNORE_DROPOUTS, @FT_OUTLINE_SMART_DROPOUTS, and
- * @FT_OUTLINE_INCLUDE_STUBS are ignored by the smooth rasterizer.
- *
- * There exists a second mechanism to pass the drop-out mode to the B/W
- * rasterizer; see the `tags` field in @FT_Outline.
- *
- * Please refer to the description of the 'SCANTYPE' instruction in the
- * [OpenType specification](https://learn.microsoft.com/en-us/typography/opentype/spec/tt_instructions#scantype)
- * how simple drop-outs, smart drop-outs, and stubs are defined.
- */
-#define FT_OUTLINE_NONE 0x0
-#define FT_OUTLINE_OWNER 0x1
-#define FT_OUTLINE_EVEN_ODD_FILL 0x2
-#define FT_OUTLINE_REVERSE_FILL 0x4
-#define FT_OUTLINE_IGNORE_DROPOUTS 0x8
-#define FT_OUTLINE_SMART_DROPOUTS 0x10
-#define FT_OUTLINE_INCLUDE_STUBS 0x20
-#define FT_OUTLINE_OVERLAP 0x40
-
-#define FT_OUTLINE_HIGH_PRECISION 0x100
-#define FT_OUTLINE_SINGLE_PASS 0x200
-
-
- /* these constants are deprecated; use the corresponding */
- /* `FT_OUTLINE_XXX` values instead */
-#define ft_outline_none FT_OUTLINE_NONE
-#define ft_outline_owner FT_OUTLINE_OWNER
-#define ft_outline_even_odd_fill FT_OUTLINE_EVEN_ODD_FILL
-#define ft_outline_reverse_fill FT_OUTLINE_REVERSE_FILL
-#define ft_outline_ignore_dropouts FT_OUTLINE_IGNORE_DROPOUTS
-#define ft_outline_high_precision FT_OUTLINE_HIGH_PRECISION
-#define ft_outline_single_pass FT_OUTLINE_SINGLE_PASS
-
- /* */
-
-#define FT_CURVE_TAG( flag ) ( flag & 0x03 )
-
- /* see the `tags` field in `FT_Outline` for a description of the values */
-#define FT_CURVE_TAG_ON 0x01
-#define FT_CURVE_TAG_CONIC 0x00
-#define FT_CURVE_TAG_CUBIC 0x02
-
-#define FT_CURVE_TAG_HAS_SCANMODE 0x04
-
-#define FT_CURVE_TAG_TOUCH_X 0x08 /* reserved for TrueType hinter */
-#define FT_CURVE_TAG_TOUCH_Y 0x10 /* reserved for TrueType hinter */
-
-#define FT_CURVE_TAG_TOUCH_BOTH ( FT_CURVE_TAG_TOUCH_X | \
- FT_CURVE_TAG_TOUCH_Y )
- /* values 0x20, 0x40, and 0x80 are reserved */
-
-
- /* these constants are deprecated; use the corresponding */
- /* `FT_CURVE_TAG_XXX` values instead */
-#define FT_Curve_Tag_On FT_CURVE_TAG_ON
-#define FT_Curve_Tag_Conic FT_CURVE_TAG_CONIC
-#define FT_Curve_Tag_Cubic FT_CURVE_TAG_CUBIC
-#define FT_Curve_Tag_Touch_X FT_CURVE_TAG_TOUCH_X
-#define FT_Curve_Tag_Touch_Y FT_CURVE_TAG_TOUCH_Y
-
-
- /**************************************************************************
- *
- * @functype:
- * FT_Outline_MoveToFunc
- *
- * @description:
- * A function pointer type used to describe the signature of a 'move to'
- * function during outline walking/decomposition.
- *
- * A 'move to' is emitted to start a new contour in an outline.
- *
- * @input:
- * to ::
- * A pointer to the target point of the 'move to'.
- *
- * user ::
- * A typeless pointer, which is passed from the caller of the
- * decomposition function.
- *
- * @return:
- * Error code. 0~means success.
- */
- typedef int
- (*FT_Outline_MoveToFunc)( const FT_Vector* to,
- void* user );
-
-#define FT_Outline_MoveTo_Func FT_Outline_MoveToFunc
-
-
- /**************************************************************************
- *
- * @functype:
- * FT_Outline_LineToFunc
- *
- * @description:
- * A function pointer type used to describe the signature of a 'line to'
- * function during outline walking/decomposition.
- *
- * A 'line to' is emitted to indicate a segment in the outline.
- *
- * @input:
- * to ::
- * A pointer to the target point of the 'line to'.
- *
- * user ::
- * A typeless pointer, which is passed from the caller of the
- * decomposition function.
- *
- * @return:
- * Error code. 0~means success.
- */
- typedef int
- (*FT_Outline_LineToFunc)( const FT_Vector* to,
- void* user );
-
-#define FT_Outline_LineTo_Func FT_Outline_LineToFunc
-
-
- /**************************************************************************
- *
- * @functype:
- * FT_Outline_ConicToFunc
- *
- * @description:
- * A function pointer type used to describe the signature of a 'conic to'
- * function during outline walking or decomposition.
- *
- * A 'conic to' is emitted to indicate a second-order Bezier arc in the
- * outline.
- *
- * @input:
- * control ::
- * An intermediate control point between the last position and the new
- * target in `to`.
- *
- * to ::
- * A pointer to the target end point of the conic arc.
- *
- * user ::
- * A typeless pointer, which is passed from the caller of the
- * decomposition function.
- *
- * @return:
- * Error code. 0~means success.
- */
- typedef int
- (*FT_Outline_ConicToFunc)( const FT_Vector* control,
- const FT_Vector* to,
- void* user );
-
-#define FT_Outline_ConicTo_Func FT_Outline_ConicToFunc
-
-
- /**************************************************************************
- *
- * @functype:
- * FT_Outline_CubicToFunc
- *
- * @description:
- * A function pointer type used to describe the signature of a 'cubic to'
- * function during outline walking or decomposition.
- *
- * A 'cubic to' is emitted to indicate a third-order Bezier arc.
- *
- * @input:
- * control1 ::
- * A pointer to the first Bezier control point.
- *
- * control2 ::
- * A pointer to the second Bezier control point.
- *
- * to ::
- * A pointer to the target end point.
- *
- * user ::
- * A typeless pointer, which is passed from the caller of the
- * decomposition function.
- *
- * @return:
- * Error code. 0~means success.
- */
- typedef int
- (*FT_Outline_CubicToFunc)( const FT_Vector* control1,
- const FT_Vector* control2,
- const FT_Vector* to,
- void* user );
-
-#define FT_Outline_CubicTo_Func FT_Outline_CubicToFunc
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_Outline_Funcs
- *
- * @description:
- * A structure to hold various function pointers used during outline
- * decomposition in order to emit segments, conic, and cubic Beziers.
- *
- * @fields:
- * move_to ::
- * The 'move to' emitter.
- *
- * line_to ::
- * The segment emitter.
- *
- * conic_to ::
- * The second-order Bezier arc emitter.
- *
- * cubic_to ::
- * The third-order Bezier arc emitter.
- *
- * shift ::
- * The shift that is applied to coordinates before they are sent to the
- * emitter.
- *
- * delta ::
- * The delta that is applied to coordinates before they are sent to the
- * emitter, but after the shift.
- *
- * @note:
- * The point coordinates sent to the emitters are the transformed version
- * of the original coordinates (this is important for high accuracy
- * during scan-conversion). The transformation is simple:
- *
- * ```
- * x' = (x << shift) - delta
- * y' = (y << shift) - delta
- * ```
- *
- * Set the values of `shift` and `delta` to~0 to get the original point
- * coordinates.
- */
- typedef struct FT_Outline_Funcs_
- {
- FT_Outline_MoveToFunc move_to;
- FT_Outline_LineToFunc line_to;
- FT_Outline_ConicToFunc conic_to;
- FT_Outline_CubicToFunc cubic_to;
-
- int shift;
- FT_Pos delta;
-
- } FT_Outline_Funcs;
-
-
- /**************************************************************************
- *
- * @section:
- * basic_types
- *
- */
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_IMAGE_TAG
- *
- * @description:
- * This macro converts four-letter tags to an unsigned long type.
- *
- * @note:
- * Since many 16-bit compilers don't like 32-bit enumerations, you should
- * redefine this macro in case of problems to something like this:
- *
- * ```
- * #define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) value
- * ```
- *
- * to get a simple enumeration without assigning special numbers.
- */
-#ifndef FT_IMAGE_TAG
-
-#define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) \
- value = ( ( FT_STATIC_BYTE_CAST( unsigned long, _x1 ) << 24 ) | \
- ( FT_STATIC_BYTE_CAST( unsigned long, _x2 ) << 16 ) | \
- ( FT_STATIC_BYTE_CAST( unsigned long, _x3 ) << 8 ) | \
- FT_STATIC_BYTE_CAST( unsigned long, _x4 ) )
-
-#endif /* FT_IMAGE_TAG */
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_Glyph_Format
- *
- * @description:
- * An enumeration type used to describe the format of a given glyph
- * image. Note that this version of FreeType only supports two image
- * formats, even though future font drivers will be able to register
- * their own format.
- *
- * @values:
- * FT_GLYPH_FORMAT_NONE ::
- * The value~0 is reserved.
- *
- * FT_GLYPH_FORMAT_COMPOSITE ::
- * The glyph image is a composite of several other images. This format
- * is _only_ used with @FT_LOAD_NO_RECURSE, and is used to report
- * compound glyphs (like accented characters).
- *
- * FT_GLYPH_FORMAT_BITMAP ::
- * The glyph image is a bitmap, and can be described as an @FT_Bitmap.
- * You generally need to access the `bitmap` field of the
- * @FT_GlyphSlotRec structure to read it.
- *
- * FT_GLYPH_FORMAT_OUTLINE ::
- * The glyph image is a vectorial outline made of line segments and
- * Bezier arcs; it can be described as an @FT_Outline; you generally
- * want to access the `outline` field of the @FT_GlyphSlotRec structure
- * to read it.
- *
- * FT_GLYPH_FORMAT_PLOTTER ::
- * The glyph image is a vectorial path with no inside and outside
- * contours. Some Type~1 fonts, like those in the Hershey family,
- * contain glyphs in this format. These are described as @FT_Outline,
- * but FreeType isn't currently capable of rendering them correctly.
- *
- * FT_GLYPH_FORMAT_SVG ::
- * [Since 2.12] The glyph is represented by an SVG document in the
- * 'SVG~' table.
- */
- typedef enum FT_Glyph_Format_
- {
- FT_IMAGE_TAG( FT_GLYPH_FORMAT_NONE, 0, 0, 0, 0 ),
-
- FT_IMAGE_TAG( FT_GLYPH_FORMAT_COMPOSITE, 'c', 'o', 'm', 'p' ),
- FT_IMAGE_TAG( FT_GLYPH_FORMAT_BITMAP, 'b', 'i', 't', 's' ),
- FT_IMAGE_TAG( FT_GLYPH_FORMAT_OUTLINE, 'o', 'u', 't', 'l' ),
- FT_IMAGE_TAG( FT_GLYPH_FORMAT_PLOTTER, 'p', 'l', 'o', 't' ),
- FT_IMAGE_TAG( FT_GLYPH_FORMAT_SVG, 'S', 'V', 'G', ' ' )
-
- } FT_Glyph_Format;
-
-
- /* these constants are deprecated; use the corresponding */
- /* `FT_Glyph_Format` values instead. */
-#define ft_glyph_format_none FT_GLYPH_FORMAT_NONE
-#define ft_glyph_format_composite FT_GLYPH_FORMAT_COMPOSITE
-#define ft_glyph_format_bitmap FT_GLYPH_FORMAT_BITMAP
-#define ft_glyph_format_outline FT_GLYPH_FORMAT_OUTLINE
-#define ft_glyph_format_plotter FT_GLYPH_FORMAT_PLOTTER
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** R A S T E R D E F I N I T I O N S *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
-
- /**************************************************************************
- *
- * @section:
- * raster
- *
- * @title:
- * Scanline Converter
- *
- * @abstract:
- * How vectorial outlines are converted into bitmaps and pixmaps.
- *
- * @description:
- * A raster or a rasterizer is a scan converter in charge of producing a
- * pixel coverage bitmap that can be used as an alpha channel when
- * compositing a glyph with a background. FreeType comes with two
- * rasterizers: bilevel `raster1` and anti-aliased `smooth` are two
- * separate modules. They are usually called from the high-level
- * @FT_Load_Glyph or @FT_Render_Glyph functions and produce the entire
- * coverage bitmap at once, while staying largely invisible to users.
- *
- * Instead of working with complete coverage bitmaps, it is also possible
- * to intercept consecutive pixel runs on the same scanline with the same
- * coverage, called _spans_, and process them individually. Only the
- * `smooth` rasterizer permits this when calling @FT_Outline_Render with
- * @FT_Raster_Params as described below.
- *
- * Working with either complete bitmaps or spans it is important to think
- * of them as colorless coverage objects suitable as alpha channels to
- * blend arbitrary colors with a background. For best results, it is
- * recommended to use gamma correction, too.
- *
- * This section also describes the public API needed to set up alternative
- * @FT_Renderer modules.
- *
- * @order:
- * FT_Span
- * FT_SpanFunc
- * FT_Raster_Params
- * FT_RASTER_FLAG_XXX
- *
- * FT_Raster
- * FT_Raster_NewFunc
- * FT_Raster_DoneFunc
- * FT_Raster_ResetFunc
- * FT_Raster_SetModeFunc
- * FT_Raster_RenderFunc
- * FT_Raster_Funcs
- *
- */
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_Span
- *
- * @description:
- * A structure to model a single span of consecutive pixels when
- * rendering an anti-aliased bitmap.
- *
- * @fields:
- * x ::
- * The span's horizontal start position.
- *
- * len ::
- * The span's length in pixels.
- *
- * coverage ::
- * The span color/coverage, ranging from 0 (background) to 255
- * (foreground).
- *
- * @note:
- * This structure is used by the span drawing callback type named
- * @FT_SpanFunc that takes the y~coordinate of the span as a parameter.
- *
- * The anti-aliased rasterizer produces coverage values from 0 to 255,
- * that is, from completely transparent to completely opaque.
- */
- typedef struct FT_Span_
- {
- short x;
- unsigned short len;
- unsigned char coverage;
-
- } FT_Span;
-
-
- /**************************************************************************
- *
- * @functype:
- * FT_SpanFunc
- *
- * @description:
- * A function used as a call-back by the anti-aliased renderer in order
- * to let client applications draw themselves the pixel spans on each
- * scan line.
- *
- * @input:
- * y ::
- * The scanline's upward y~coordinate.
- *
- * count ::
- * The number of spans to draw on this scanline.
- *
- * spans ::
- * A table of `count` spans to draw on the scanline.
- *
- * user ::
- * User-supplied data that is passed to the callback.
- *
- * @note:
- * This callback allows client applications to directly render the spans
- * of the anti-aliased bitmap to any kind of surfaces.
- *
- * This can be used to write anti-aliased outlines directly to a given
- * background bitmap using alpha compositing. It can also be used for
- * oversampling and averaging.
- */
- typedef void
- (*FT_SpanFunc)( int y,
- int count,
- const FT_Span* spans,
- void* user );
-
-#define FT_Raster_Span_Func FT_SpanFunc
-
-
- /**************************************************************************
- *
- * @functype:
- * FT_Raster_BitTest_Func
- *
- * @description:
- * Deprecated, unimplemented.
- */
- typedef int
- (*FT_Raster_BitTest_Func)( int y,
- int x,
- void* user );
-
-
- /**************************************************************************
- *
- * @functype:
- * FT_Raster_BitSet_Func
- *
- * @description:
- * Deprecated, unimplemented.
- */
- typedef void
- (*FT_Raster_BitSet_Func)( int y,
- int x,
- void* user );
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_RASTER_FLAG_XXX
- *
- * @description:
- * A list of bit flag constants as used in the `flags` field of a
- * @FT_Raster_Params structure.
- *
- * @values:
- * FT_RASTER_FLAG_DEFAULT ::
- * This value is 0.
- *
- * FT_RASTER_FLAG_AA ::
- * This flag is set to indicate that an anti-aliased glyph image should
- * be generated. Otherwise, it will be monochrome (1-bit).
- *
- * FT_RASTER_FLAG_DIRECT ::
- * This flag is set to indicate direct rendering. In this mode, client
- * applications must provide their own span callback. This lets them
- * directly draw or compose over an existing bitmap. If this bit is
- * _not_ set, the target pixmap's buffer _must_ be zeroed before
- * rendering and the output will be clipped to its size.
- *
- * Direct rendering is only possible with anti-aliased glyphs.
- *
- * FT_RASTER_FLAG_CLIP ::
- * This flag is only used in direct rendering mode. If set, the output
- * will be clipped to a box specified in the `clip_box` field of the
- * @FT_Raster_Params structure. Otherwise, the `clip_box` is
- * effectively set to the bounding box and all spans are generated.
- *
- * FT_RASTER_FLAG_SDF ::
- * This flag is set to indicate that a signed distance field glyph
- * image should be generated. This is only used while rendering with
- * the @FT_RENDER_MODE_SDF render mode.
- */
-#define FT_RASTER_FLAG_DEFAULT 0x0
-#define FT_RASTER_FLAG_AA 0x1
-#define FT_RASTER_FLAG_DIRECT 0x2
-#define FT_RASTER_FLAG_CLIP 0x4
-#define FT_RASTER_FLAG_SDF 0x8
-
- /* these constants are deprecated; use the corresponding */
- /* `FT_RASTER_FLAG_XXX` values instead */
-#define ft_raster_flag_default FT_RASTER_FLAG_DEFAULT
-#define ft_raster_flag_aa FT_RASTER_FLAG_AA
-#define ft_raster_flag_direct FT_RASTER_FLAG_DIRECT
-#define ft_raster_flag_clip FT_RASTER_FLAG_CLIP
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_Raster_Params
- *
- * @description:
- * A structure to hold the parameters used by a raster's render function,
- * passed as an argument to @FT_Outline_Render.
- *
- * @fields:
- * target ::
- * The target bitmap.
- *
- * source ::
- * A pointer to the source glyph image (e.g., an @FT_Outline).
- *
- * flags ::
- * The rendering flags.
- *
- * gray_spans ::
- * The gray span drawing callback.
- *
- * black_spans ::
- * Unused.
- *
- * bit_test ::
- * Unused.
- *
- * bit_set ::
- * Unused.
- *
- * user ::
- * User-supplied data that is passed to each drawing callback.
- *
- * clip_box ::
- * An optional span clipping box expressed in _integer_ pixels
- * (not in 26.6 fixed-point units).
- *
- * @note:
- * The @FT_RASTER_FLAG_AA bit flag must be set in the `flags` to
- * generate an anti-aliased glyph bitmap, otherwise a monochrome bitmap
- * is generated. The `target` should have appropriate pixel mode and its
- * dimensions define the clipping region.
- *
- * If both @FT_RASTER_FLAG_AA and @FT_RASTER_FLAG_DIRECT bit flags
- * are set in `flags`, the raster calls an @FT_SpanFunc callback
- * `gray_spans` with `user` data as an argument ignoring `target`. This
- * allows direct composition over a pre-existing user surface to perform
- * the span drawing and composition. To optionally clip the spans, set
- * the @FT_RASTER_FLAG_CLIP flag and `clip_box`. The monochrome raster
- * does not support the direct mode.
- *
- * The gray-level rasterizer always uses 256 gray levels. If you want
- * fewer gray levels, you have to use @FT_RASTER_FLAG_DIRECT and reduce
- * the levels in the callback function.
- */
- typedef struct FT_Raster_Params_
- {
- const FT_Bitmap* target;
- const void* source;
- int flags;
- FT_SpanFunc gray_spans;
- FT_SpanFunc black_spans; /* unused */
- FT_Raster_BitTest_Func bit_test; /* unused */
- FT_Raster_BitSet_Func bit_set; /* unused */
- void* user;
- FT_BBox clip_box;
-
- } FT_Raster_Params;
-
-
- /**************************************************************************
- *
- * @type:
- * FT_Raster
- *
- * @description:
- * An opaque handle (pointer) to a raster object. Each object can be
- * used independently to convert an outline into a bitmap or pixmap.
- *
- * @note:
- * In FreeType 2, all rasters are now encapsulated within specific
- * @FT_Renderer modules and only used in their context.
- *
- */
- typedef struct FT_RasterRec_* FT_Raster;
-
-
- /**************************************************************************
- *
- * @functype:
- * FT_Raster_NewFunc
- *
- * @description:
- * A function used to create a new raster object.
- *
- * @input:
- * memory ::
- * A handle to the memory allocator.
- *
- * @output:
- * raster ::
- * A handle to the new raster object.
- *
- * @return:
- * Error code. 0~means success.
- *
- * @note:
- * The `memory` parameter is a typeless pointer in order to avoid
- * un-wanted dependencies on the rest of the FreeType code. In practice,
- * it is an @FT_Memory object, i.e., a handle to the standard FreeType
- * memory allocator. However, this field can be completely ignored by a
- * given raster implementation.
- */
- typedef int
- (*FT_Raster_NewFunc)( void* memory,
- FT_Raster* raster );
-
-#define FT_Raster_New_Func FT_Raster_NewFunc
-
-
- /**************************************************************************
- *
- * @functype:
- * FT_Raster_DoneFunc
- *
- * @description:
- * A function used to destroy a given raster object.
- *
- * @input:
- * raster ::
- * A handle to the raster object.
- */
- typedef void
- (*FT_Raster_DoneFunc)( FT_Raster raster );
-
-#define FT_Raster_Done_Func FT_Raster_DoneFunc
-
-
- /**************************************************************************
- *
- * @functype:
- * FT_Raster_ResetFunc
- *
- * @description:
- * FreeType used to provide an area of memory called the 'render pool'
- * available to all registered rasterizers. This was not thread safe,
- * however, and now FreeType never allocates this pool.
- *
- * This function is called after a new raster object is created.
- *
- * @input:
- * raster ::
- * A handle to the new raster object.
- *
- * pool_base ::
- * Previously, the address in memory of the render pool. Set this to
- * `NULL`.
- *
- * pool_size ::
- * Previously, the size in bytes of the render pool. Set this to 0.
- *
- * @note:
- * Rasterizers should rely on dynamic or stack allocation if they want to
- * (a handle to the memory allocator is passed to the rasterizer
- * constructor).
- */
- typedef void
- (*FT_Raster_ResetFunc)( FT_Raster raster,
- unsigned char* pool_base,
- unsigned long pool_size );
-
-#define FT_Raster_Reset_Func FT_Raster_ResetFunc
-
-
- /**************************************************************************
- *
- * @functype:
- * FT_Raster_SetModeFunc
- *
- * @description:
- * This function is a generic facility to change modes or attributes in a
- * given raster. This can be used for debugging purposes, or simply to
- * allow implementation-specific 'features' in a given raster module.
- *
- * @input:
- * raster ::
- * A handle to the new raster object.
- *
- * mode ::
- * A 4-byte tag used to name the mode or property.
- *
- * args ::
- * A pointer to the new mode/property to use.
- */
- typedef int
- (*FT_Raster_SetModeFunc)( FT_Raster raster,
- unsigned long mode,
- void* args );
-
-#define FT_Raster_Set_Mode_Func FT_Raster_SetModeFunc
-
-
- /**************************************************************************
- *
- * @functype:
- * FT_Raster_RenderFunc
- *
- * @description:
- * Invoke a given raster to scan-convert a given glyph image into a
- * target bitmap.
- *
- * @input:
- * raster ::
- * A handle to the raster object.
- *
- * params ::
- * A pointer to an @FT_Raster_Params structure used to store the
- * rendering parameters.
- *
- * @return:
- * Error code. 0~means success.
- *
- * @note:
- * The exact format of the source image depends on the raster's glyph
- * format defined in its @FT_Raster_Funcs structure. It can be an
- * @FT_Outline or anything else in order to support a large array of
- * glyph formats.
- *
- * Note also that the render function can fail and return a
- * `FT_Err_Unimplemented_Feature` error code if the raster used does not
- * support direct composition.
- */
- typedef int
- (*FT_Raster_RenderFunc)( FT_Raster raster,
- const FT_Raster_Params* params );
-
-#define FT_Raster_Render_Func FT_Raster_RenderFunc
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_Raster_Funcs
- *
- * @description:
- * A structure used to describe a given raster class to the library.
- *
- * @fields:
- * glyph_format ::
- * The supported glyph format for this raster.
- *
- * raster_new ::
- * The raster constructor.
- *
- * raster_reset ::
- * Used to reset the render pool within the raster.
- *
- * raster_render ::
- * A function to render a glyph into a given bitmap.
- *
- * raster_done ::
- * The raster destructor.
- */
- typedef struct FT_Raster_Funcs_
- {
- FT_Glyph_Format glyph_format;
-
- FT_Raster_NewFunc raster_new;
- FT_Raster_ResetFunc raster_reset;
- FT_Raster_SetModeFunc raster_set_mode;
- FT_Raster_RenderFunc raster_render;
- FT_Raster_DoneFunc raster_done;
-
- } FT_Raster_Funcs;
-
- /* */
-
-
-FT_END_HEADER
-
-#endif /* FTIMAGE_H_ */
-
-
-/* END */
-
-
-/* Local Variables: */
-/* coding: utf-8 */
-/* End: */
-
-
-====================File: src/smooth/ftgrays.h====================
-/****************************************************************************
- *
- * ftgrays.h
- *
- * FreeType smooth renderer declaration
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTGRAYS_H_
-#define FTGRAYS_H_
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-
-#ifdef STANDALONE_
-#error #include "ftimage.h"
-#else
-#include <ft2build.h>
-#include <freetype/ftimage.h>
-#endif
-
-
- /**************************************************************************
- *
- * To make ftgrays.h independent from configuration files we check
- * whether FT_EXPORT_VAR has been defined already.
- *
- * On some systems and compilers (Win32 mostly), an extra keyword is
- * necessary to compile the library as a DLL.
- */
-#ifndef FT_EXPORT_VAR
-#define FT_EXPORT_VAR( x ) extern x
-#endif
-
- FT_EXPORT_VAR( const FT_Raster_Funcs ) ft_grays_raster;
-
-
-#ifdef __cplusplus
- }
-#endif
-
-#endif /* FTGRAYS_H_ */
-
-
-/* END */
-
-
-====================MIT====================
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COMPUTING RESEARCH LAB OR NEW MEXICO STATE UNIVERSITY BE LIABLE FOR ANY
- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
- * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
- * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-
-====================MIT====================
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-
-====================MIT====================
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the "Software"),
-to deal in the Software without restriction, including without limitation
-the rights to use, copy, modify, merge, publish, distribute, sublicense,
-and/or sell copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-THE COMPUTING RESEARCH LAB OR NEW MEXICO STATE UNIVERSITY BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
-OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
-THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-
-====================MIT====================
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-
-
-====================MIT====================
-the 'Old MIT' license, compatible to the above two licenses.
-
-
-====================MIT-Modern-Variant====================
- * Permission is hereby granted, without written agreement and without
- * license or royalty fees, to use, copy, modify, and distribute this
- * software and its documentation for any purpose, provided that the
- * above copyright notice and the following two paragraphs appear in
- * all copies of this software.
- *
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
-
-
-====================MIT-open-group====================
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-
-====================Public-Domain====================
- * Homepage:
- * http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5
- *
- * Author:
- * Alexander Peslyak, better known as Solar Designer <solar at openwall.com>
- *
- * This software was written by Alexander Peslyak in 2001. No copyright is
- * claimed, and the software is hereby placed in the public domain.
- * In case this attempt to disclaim copyright and place the software in the
- * public domain is deemed null and void, then the software is
- * Copyright (c) 2001 Alexander Peslyak and it is hereby released to the
- * general public under the following terms:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted.
- *
- * There's ABSOLUTELY NO WARRANTY, express or implied.
-
-
-====================Public-Domain====================
- * Homepage:
- * http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5
- *
- * Author:
- * Alexander Peslyak, better known as Solar Designer <solar at openwall.com>
- *
- * This software was written by Alexander Peslyak in 2001. No copyright is
- * claimed, and the software is hereby placed in the public domain.
- * In case this attempt to disclaim copyright and place the software in the
- * public domain is deemed null and void, then the software is
- * Copyright (c) 2001 Alexander Peslyak and it is hereby released to the
- * general public under the following terms:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted.
- *
- * There's ABSOLUTELY NO WARRANTY, express or implied.
- *
- * (This is a heavily cut-down "BSD license".)
-
-
-====================Zlib====================
-The gzip module uses the zlib license (see `src/gzip/zlib.h`) which
diff --git a/contrib/libs/freetype/.yandex_meta/override.nix b/contrib/libs/freetype/.yandex_meta/override.nix
deleted file mode 100644
index 9d9b2a3974..0000000000
--- a/contrib/libs/freetype/.yandex_meta/override.nix
+++ /dev/null
@@ -1,33 +0,0 @@
-self: super: with self; rec {
- pname = "freetype";
- version = "2.13.3";
-
- src = fetchFromGitLab {
- domain = "gitlab.freedesktop.org";
- owner = "freetype";
- repo = "freetype";
- rev = "VER-${self.lib.replaceStrings ["."] ["-"] version}";
- hash = "sha256-HJ4gKR+gLudollVsYhKQPKa6xAuM8RlCTwUhMQENFdQ=";
- leaveDotGit = true;
- fetchSubmodules = true;
- };
-
- patches = [];
-
- # autoreconfHook doesn't work here somehow
- nativeBuildInputs = [ autoconf automake libtool ];
-
- buildInputs = [ gnumake zlib ];
-
- preConfigure = "./autogen.sh";
-
- configureFlags = [
- "--build=x86_64-unknown-linux-gnu"
- ];
-
- CFLAGS = [
- "-DFT_CONFIG_OPTION_SYSTEM_ZLIB"
- "-DFT_DEBUG_LEVEL_TRACE"
- "-DFT_DEBUG_LOGGING"
- ];
-}
diff --git a/contrib/libs/freetype/LICENSE.TXT b/contrib/libs/freetype/LICENSE.TXT
deleted file mode 100644
index 8b9ce9e2e6..0000000000
--- a/contrib/libs/freetype/LICENSE.TXT
+++ /dev/null
@@ -1,46 +0,0 @@
-FREETYPE LICENSES
------------------
-
-The FreeType 2 font engine is copyrighted work and cannot be used
-legally without a software license. In order to make this project
-usable to a vast majority of developers, we distribute it under two
-mutually exclusive open-source licenses.
-
-This means that *you* must choose *one* of the two licenses described
-below, then obey all its terms and conditions when using FreeType 2 in
-any of your projects or products.
-
- - The FreeType License, found in the file `docs/FTL.TXT`, which is
- similar to the original BSD license *with* an advertising clause
- that forces you to explicitly cite the FreeType project in your
- product's documentation. All details are in the license file.
- This license is suited to products which don't use the GNU General
- Public License.
-
- Note that this license is compatible to the GNU General Public
- License version 3, but not version 2.
-
- - The GNU General Public License version 2, found in
- `docs/GPLv2.TXT` (any later version can be used also), for
- programs which already use the GPL. Note that the FTL is
- incompatible with GPLv2 due to its advertisement clause.
-
-The contributed BDF and PCF drivers come with a license similar to
-that of the X Window System. It is compatible to the above two
-licenses (see files `src/bdf/README` and `src/pcf/README`). The same
-holds for the source code files `src/base/fthash.c` and
-`include/freetype/internal/fthash.h`; they were part of the BDF driver
-in earlier FreeType versions.
-
-The gzip module uses the zlib license (see `src/gzip/zlib.h`) which
-too is compatible to the above two licenses.
-
-The files `src/autofit/ft-hb.c` and `src/autofit/ft-hb.h` contain code
-taken almost verbatim from the HarfBuzz file `hb-ft.cc`, which uses
-the 'Old MIT' license, compatible to the above two licenses.
-
-The MD5 checksum support (only used for debugging in development
-builds) is in the public domain.
-
-
---- end of LICENSE.TXT ---
diff --git a/contrib/libs/freetype/MSBuild.rsp b/contrib/libs/freetype/MSBuild.rsp
deleted file mode 100644
index 6c1d8f223b..0000000000
--- a/contrib/libs/freetype/MSBuild.rsp
+++ /dev/null
@@ -1,2 +0,0 @@
-#/p:WindowsTargetPlatformVersion=10.0.16299.0
-/p:Configuration="Release"
diff --git a/contrib/libs/freetype/README b/contrib/libs/freetype/README
deleted file mode 100644
index 0f5d3e0e02..0000000000
--- a/contrib/libs/freetype/README
+++ /dev/null
@@ -1,107 +0,0 @@
-FreeType 2.13.3
-===============
-
-Homepage: https://www.freetype.org
-
-FreeType is a freely available software library to render fonts.
-
-It is written in C, designed to be small, efficient, highly
-customizable, and portable while capable of producing high-quality
-output (glyph images) of most vector and bitmap font formats.
-
-Please read the `docs/CHANGES` file, it contains IMPORTANT
-INFORMATION.
-
-Read the files `docs/INSTALL*` for installation instructions; see the
-file `docs/LICENSE.TXT` for the available licenses.
-
-For using FreeType's git repository instead of a distribution bundle,
-please read file `README.git`. Note that you have to actually clone
-the repository; using a snapshot will not work (in other words, don't
-use gitlab's 'Download' button).
-
-The FreeType 2 API reference is located in directory `docs/reference`;
-use the file `index.html` as the top entry point. [Please note that
-currently the search function for locally installed documentation
-doesn't work due to cross-site scripting issues.]
-
-Additional documentation is available as a separate package from our
-sites. Go to
-
- https://download.savannah.gnu.org/releases/freetype/
-
-and download one of the following files.
-
- freetype-doc-2.13.3.tar.xz
- freetype-doc-2.13.3.tar.gz
- ftdoc2133.zip
-
-To view the documentation online, go to
-
- https://www.freetype.org/freetype2/docs/
-
-
-Mailing Lists
--------------
-
-The preferred way of communication with the FreeType team is using
-e-mail lists.
-
- general use and discussion: freetype@nongnu.org
- engine internals, porting, etc.: freetype-devel@nongnu.org
- announcements: freetype-announce@nongnu.org
- git repository tracker: freetype-commit@nongnu.org
-
-The lists are moderated; see
-
- https://www.freetype.org/contact.html
-
-how to subscribe.
-
-
-Bugs
-----
-
-Please submit bug reports at
-
- https://gitlab.freedesktop.org/freetype/freetype/-/issues
-
-Alternatively, you might report bugs by e-mail to
-`freetype-devel@nongnu.org`. Don't forget to send a detailed
-explanation of the problem -- there is nothing worse than receiving a
-terse message that only says 'it doesn't work'.
-
-
-Patches
--------
-
-For larger changes please provide merge requests at
-
- https://gitlab.freedesktop.org/freetype/freetype/-/merge_requests
-
-Alternatively, you can send patches to the `freetype-devel@nongnu.org`
-mailing list -- and thank you in advance for your work on improving
-FreeType!
-
-Details on the process can be found here:
-
- https://www.freetype.org/developer.html#patches
-
-
-Enjoy!
-
- The FreeType Team
-
-----------------------------------------------------------------------
-
-Copyright (C) 2006-2024 by
-David Turner, Robert Wilhelm, and Werner Lemberg.
-
-This file is part of the FreeType project, and may only be used,
-modified, and distributed under the terms of the FreeType project
-license, LICENSE.TXT. By continuing to use, modify, or distribute
-this file you indicate that you have read the license and understand
-and accept it fully.
-
-
---- end of README ---
diff --git a/contrib/libs/freetype/README.git b/contrib/libs/freetype/README.git
deleted file mode 100644
index c818bbb5f9..0000000000
--- a/contrib/libs/freetype/README.git
+++ /dev/null
@@ -1,102 +0,0 @@
-README.git
-==========
-
-
-repository issues
------------------
-
-FreeType's official repository site is
-
- https://gitlab.freedesktop.org/freetype ,
-
-from which the 'freetype.git' and 'freetype-demos.git' repositories
-can be cloned in the usual way.
-
- git clone https://gitlab.freedesktop.org/freetype/freetype.git
- git clone https://gitlab.freedesktop.org/freetype/freetype-demos.git
-
-If you want to use the Savannah mirror instead, you have to do a
-slightly different incantation because the repository names contain
-digit '2' for historical reasons.
-
- git clone \
- https://git.savannah.nongnu.org/git/freetype/freetype2.git \
- freetype
- git clone \
- https://git.savannah.nongnu.org/git/freetype/freetype2-demos.git \
- freetype-demos
-
-
-standard builds with `configure`
---------------------------------
-
-The git repository doesn't contain pre-built configuration scripts for
-UNIXish platforms. To generate them say
-
- sh autogen.sh
-
-which in turn depends on the following packages:
-
- automake (1.10.1)
- libtool (2.2.4)
- autoconf (2.62)
-
-The versions given in parentheses are known to work. Newer versions
-should work too, of course. Note that `autogen.sh` also sets up
-proper file permissions for the `configure` and auxiliary scripts.
-
-The `autogen.sh` script checks whether the versions of the above three
-tools match the numbers above. Otherwise it will complain and suggest
-either upgrading or using environment variables to point to more
-recent versions of the required tools.
-
-Note that `aclocal` is provided by the 'automake' package on Linux,
-and that `libtoolize` is called `glibtoolize` on Darwin (OS X).
-
-
-alternative build methods
--------------------------
-
-For static builds that don't use platform-specific optimizations, no
-configure script is necessary at all; saying
-
- make setup ansi
- make
-
-should work on all platforms that have GNU `make` (or `makepp`).
-
-A build with `cmake` or `meson` can be done directly from the git
-repository. However, if you want to use the `FT_DEBUG_LOGGING` macro
-(see file `docs/DEBUG` for more information) it is currently mandatory
-to execute `autogen.sh` in advance; this script clones the 'dlg' git
-submodule and copies some files into FreeType's source tree.
-
-
-Code of Conduct
----------------
-
-Please note that this project is released with a Contributor Code of
-Conduct (CoC). By participating in this project you agree to abide by
-its terms, which you can find in the following link:
-
- https://www.freedesktop.org/wiki/CodeOfConduct
-
-CoC issues may be raised to the project maintainers at the following
-address:
-
- wl@gnu.org
- apodtele@gmail.com
-
-----------------------------------------------------------------------
-
-Copyright (C) 2005-2024 by
-David Turner, Robert Wilhelm, and Werner Lemberg.
-
-This file is part of the FreeType project, and may only be used,
-modified, and distributed under the terms of the FreeType project
-license, LICENSE.TXT. By continuing to use, modify, or distribute
-this file you indicate that you have read the license and understand
-and accept it fully.
-
-
---- end of README.git ---
diff --git a/contrib/libs/freetype/docs/CHANGES b/contrib/libs/freetype/docs/CHANGES
deleted file mode 100644
index bd7b12a8a8..0000000000
--- a/contrib/libs/freetype/docs/CHANGES
+++ /dev/null
@@ -1,5726 +0,0 @@
-CHANGES BETWEEN 2.13.2 and 2.13.3 (2024-Aug-11)
-
- I. IMPORTANT CHANGES
-
- - Some fields in the `FT_Outline` structure have been changed
- from signed to unsigned type, which better reflects the actual
- usage. It is also an additional means to protect against
- malformed input.
-
-
- II. IMPORTANT BUG FIXES
-
- - Rare double-free crashes in the cache subsystem have been fixed.
-
- - Excessive stack allocation in the autohinter has been fixed.
-
-
- III. MISCELLANEOUS
-
- - The B/W rasterizer has received a major upkeep that results in
- large performance improvements. The rendering speed has increased
- and even doubled for very complex glyphs.
-
- - If the new configuration option `TT_CONFIG_OPTION_GPOS_KERNING` is
- defined, `FT_Get_Kerning` understands rudimentary GPOS kerning
- (for TrueType fonts only). This is not enabled by default since
- its usage is very limited, mainly for legacy applications that
- have to support TrueType fonts automatically converted from 'kern'
- tables to GPOS kerning. If you need proper (GPOS) kerning support
- please use a higher-level library like HarfBuzz.
-
- Code contributed by David Saltzman <davidbsaltzman@gmail.com>.
-
- - The internal structures `PS_DesignMap` and `PS_Blend` related to
- parsing of old Multiple Masters fonts have been removed from the
- public header file `t1tables.h`.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.13.1 and 2.13.2 (2023-Aug-25)
-
- I. MISCELLANEOUS
-
- - Better support for CFF2 variation fonts.
-
- - TrueType interpreter version 38 (also known as 'Infinality') has
- been removed.
-
- - Improved OpenVMS support.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.13.0 and 2.13.1 (2023-Jun-24)
-
- I. MISCELLANEOUS
-
- - New function `FT_Get_Default_Named_Instance` to get the index of
- the default named instance of an OpenType Variation Font.
-
- - A new load flag `FT_LOAD_NO_SVG` to make FreeType ignore glyphs in
- an 'SVG ' table.
-
- - New function `FT_GlyphSlot_AdjustWeight` to adjust the glyph
- weight either horizontally or vertically. This is part of the
- `ftsynth.h` header file, which is still considered to be in alpha
- stage.
-
- - TrueType interpreter version 38 (also known as 'Infinality') has
- been deactivated; the value of `TT_INTERPRETER_VERSION_38` is now
- the same as `TT_INTERPRETER_VERSION_40`.
-
- - Updated OpenVMS support.
-
- - The base API documentation has been modularized for easier
- handling.
-
- - Switching named instances on and off in Variation Fonts was buggy
- if the design coordinates didn't change.
-
- - `ftbench` has a new command-line option `-a` to apply design
- coordinates.
-
- - `ftview` can now flip SVG rendering on and off using the 'Z' key.
-
- - In `ftmulti` it is now possible to toggle the fill rule and
- overlap flag used for rendering glyphs using the 'F3' and 'F4'
- keys, respectively. Toggling the anti-aliased mode has been
- changed to the 'TAB' key.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.12.1 and 2.13.0 (2023-Feb-09)
-
- I. IMPORTANT CHANGES
-
- - The demo program `ftinspect` has been completely updated and much
- enhanced. It now combines the functionality of almost all other
- graphical FreeType demo programs into a single application based
- on the Qt framework. This was Charlie Jiang's GSoC 2022 project.
-
- - The 'COLR' v1 API is now considered as stable.
-
- https://learn.microsoft.com/en-us/typography/opentype/spec/colr
-
-
- II. MISCELLANEOUS
-
- - For OpenType Variable Fonts, `avar` table format 2.0 is now
- supported. The code was contributed by Behdad Esfahbod.
-
- Note that this is an extension supported on recent Apple platforms
- and by HarfBuzz, but not yet in the OpenType standard! See
-
- https://github.com/harfbuzz/boring-expansion-spec/blob/main/avar2.md
-
- for the specification. To deactivate it, define the configuration
- macro 'TT_CONFIG_OPTION_NO_BORING_EXPANSION'.
-
- - A new API `FT_GlyphSlot_Slant` to slant a glyph by a given angle
- has been added. Note that this function is part of `ftsynth.h`,
- which is still considered to be in alpha stage.
-
- - TrueType interpreter version 38 (also known as 'Infinality') that
- was first introduced about 10 years ago in FreeType 2.4.11 is now
- deprecated and slated to be removed in the next version. TrueType
- interpreter version 40 has been FreeType's default version for six
- years now and provides an excellent alternative. This is the last
- FreeType version with TT_INTERPRETER_VERSION_38 and
- TT_INTERPRETER_VERSION_40 treated differently.
-
- - The only referenced but never documented configuration macro
- `FT_CONFIG_OPTION_NO_GLYPH_NAMES` has been removed.
-
- - The `ftbench` demo program got a new command line option `-e` to
- set a charmap index.
-
- - Specifying a point size is now optional for the demo programs
- `ftgrid`, `ftmulti`, `ftstring`, and `ftview`. If not given, a
- default size is used.
-
- - For `ftgrid`, `ftstring`, and `ftview`, option `-e` now also
- accepts a numeric value to set a charmap index.
-
- - In `ftstring`, it is now possible to set the displayed text
- interactively by pressing the 'Enter' key.
-
- - `ftmulti` can now handle up to 16 design axes.
-
- - To avoid reserved identifiers that are globally defined, the
- auto-hinter debugging macros (which are only available if
- `FT_DEBUG_AUTOFIT` is defined)
-
- ```
- _af_debug_disable_horz_hints
- _af_debug_disable_vert_hints
- _af_debug_disable_blue_hints
- _af_debug_hints
- ```
-
- have been renamed to
-
- ```
- af_debug_disable_horz_hints_
- af_debug_disable_vert_hints_
- af_debug_disable_blue_hints_
- af_debug_hints_
- ```
-
- - The internal zlib library was updated to version 1.2.13. Note,
- however, that FreeType is *not* affected by CVE-2022-37434 since
- it doesn't use the `inflateGetHeader` function.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.12.0 and 2.12.1 (2022-May-01)
-
- I. IMPORTANT BUG FIXES
-
- - Loading CFF fonts sometimes made FreeType crash (bug introduced in
- version 2.12.0)
-
- - Loading a fully hinted TrueType glyph a second time (without
- caching) sometimes yielded different rendering results if TrueType
- hinting was active (bug introduced in version 2.12.0).
-
- - The generation of the pkg-config file `freetype2.pc` was broken if
- the build was done with cmake (bug introduced in version 2.12.0).
-
-
- II. MISCELLANEOUS
-
- - New option `--with-librsvg` for the `configure` script for better
- FreeType demo support.
-
- - The meson build no longer enforces both static and dynamic
- versions of the library by default.
-
- - The internal zlib library was updated to version 1.2.12. Note,
- however, that FreeType is *not* affected by CVE-2018-25032 since
- it only does decompression.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.11.1 and 2.12.0 (2022-Mar-30)
-
- I. IMPORTANT CHANGES
-
- - FreeType now handles OT-SVG fonts, to be controlled with
- `FT_CONFIG_OPTION_SVG` configuration macro. By default, it can
- only load the 'SVG ' table of an OpenType font. However, by using
- the `svg-hooks` property of the new 'ot-svg' module it is possible
- to register an external SVG rendering engine. The FreeType demo
- programs have been set up to use 'librsvg' as the rendering
- library.
-
- This work was Moazin Khatti's GSoC 2019 project.
-
-
- II. MISCELLANEOUS
-
- - The handling of fonts with an 'sbix' table has been improved.
-
- - Corrected bitmap offsets.
-
- - A new tag `FT_PARAM_TAG_IGNORE_SBIX` for `FT_Open_Face` makes
- FreeType ignore an 'sbix' table in a font, allowing applications
- to access the font's outline glyphs.
-
- - `FT_FACE_FLAG_SBIX` and `FT_FACE_FLAG_SBIX_OVERLAY` together
- with their corresponding preprocessor macros `FT_HAS_SBIX` and
- `FT_HAS_SBIX_OVERLAY` enable applications to treat 'sbix' tables
- as described in the OpenType specification.
-
- - The internal 'zlib' code has been updated to be in sync with the
- current 'zlib' version (1.2.11).
-
- - The previously internal load flag `FT_LOAD_SBITS_ONLY` is now
- public.
-
- - Some minor improvements of the building systems, in particular
- handling of the 'zlib' library (internal vs. external).
-
- - Support for non-desktop Universal Windows Platform.
-
- - Various other minor bug and documentation fixes.
-
- - The `ftdump` demo program shows more information for Type1 fonts
- if option `-n` is given.
-
- - `ftgrid` can now display embedded bitmap strikes.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.11.0 and 2.11.1 (2021-Dec-01)
-
- I. IMPORTANT CHANGES
-
- - Some fields in the `CID_FaceDictRec`, `CID_FaceInfoRec`, and
- `FT_Data` structures have been changed from signed to unsigned
- type, which better reflects the actual usage. It is also an
- additional means to protect against malformed input.
-
-
- II. MISCELLANEOUS
-
- - Cmake support has been further improved. To do that various
- backward-incompatible changes were necessary; please see file
- `CMakeLists.txt` for more details.
-
- - Since version 2.11.0, a C99 compiler is necessary to compile
- FreeType.
-
- - The experimental 'COLR' v1 API has been updated to the latest
- OpenType standard 1.9.
-
- - The `apinames` tool got a new option `-wV` to output an OpenVMS
- Linker Option File.
-
- - VMS support was updated.
-
- - MS Visual Studio support was added to build the demo programs.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.10.4 and 2.11.0 (2021-Jul-18)
-
- I. IMPORTANT CHANGES
-
- - A new rendering module has been added to create 8-bit Signed
- Distance Field (SDF) bitmaps for both outline and bitmap glyphs.
- The new rendering mode is called `FT_RENDER_MODE_SDF`, the pixel
- mode is `FT_PIXEL_MODE_GRAY8`, and the corresponding raster flag
- is `FT_RASTER_FLAG_SDF`.
-
- This work was Anuj Verma's GSoC 2020 project.
-
- - A new, experimental API is now available for surfacing properties
- of 'COLR' v1 color fonts (as the name says, this is an extension
- to the 'COLR' table for outline color fonts using the SFNT
- container format). 'COLR' v1 fonts are a recently proposed
- addition to OFF and OpenType; specification work currently happens
- in
-
- https://github.com/googlefonts/colr-gradients-spec/
-
- 'COLR' v1 is expected to be merged to OpenType; the ISO
- standardisation process for adding 'COLR' v1 as an amendment to
- OFF is underway.
-
- Functions similar to the already existing 'COLR' API have been
- added to access the corresponding data.
-
- FT_Get_Color_Glyph_Paint
- Retrieve the root paint for a given glyph ID.
-
- FT_Get_Paint_Layers
- Access the layers of a `PaintColrLayers` table.
-
- FT_Get_Colorline_Stops
- Retrieve the 'color stops' on a color line. As an input, a
- color stop iterator gets used, which in turn is retrieved from
- a paint.
-
- FT_Get_Paint
- Dereference an `FT_OpaquePaint` object and retrieve the
- corresponding `FT_COLR_Paint` object, which contains details
- on how to draw the respective 'COLR' v1 `Paint` table.
-
-
- II. MISCELLANEOUS
-
- - FreeType has moved its infrastructure to
-
- https://gitlab.freedesktop.org/freetype
-
- A side effect is that the git repositories are now called
- `freetype.git` and `freetype-demos.git`, which by default expand
- to the directories `freetype` and `freetype-demos`, respectively.
- The documentation has been updated accordingly.
-
- FreeType's Savannah repositories will stay; they are now mirrors
- of the 'freedesktop.org' repositories.
-
- - A new function `FT_Get_Transform` returns the values set by
- `FT_Set_Transform`.
-
- - A new configuration macro `FT_DEBUG_LOGGING` is available. It
- provides extended debugging capabilities for FreeType, for example
- showing a time stamp or displaying the component a tracing message
- comes from. See file `docs/DEBUG` for more information.
-
- This work was Priyesh Kumar's GSoC 2020 project.
-
- - The legacy Type 1 and CFF engines are further demoted due to lack
- of CFF2 charstring support. You now need to use `FT_Property_Set`
- to enable them besides the `T1_CONFIG_OPTION_OLD_ENGINE` and
- `CFF_CONFIG_OPTION_OLD_ENGINE` options, respectively.
-
- - The experimental 'warp' mode (AF_CONFIG_OPTION_USE_WARPER) for the
- auto-hinter has been removed.
-
- - The smooth rasterizer performance has been improved by >10%. Note
- that due to necessary code changes there might be very subtle
- differences in rendering. They are not visible by the eye,
- however.
-
- - PCF bitmap fonts compressed with LZW (these are usually files with
- the extension `.pcf.Z`) are now handled correctly.
-
- - Improved Meson build files, including support to build the
- FreeType demo programs.
-
- - A new demo program `ftsdf` is available to display Signed Distance
- Fields of glyphs.
-
- - The `ftlint` demo program has been extended to do more testing of
- its input. In particular, it can display horizontal and vertical
- acutances for quality assessment, together with computing MD5
- checksums of rendered glyphs.
-
- [The acutance measures how sharply the pixel coverage changes at
- glyph edges. For monochrome bitmaps, it is always 2.0 in either
- X or Y direction. For anti-aliased bitmaps, it depends on the
- hinting and the shape of a glyph and might approach or even reach
- value 2.0 for glyphs like 'I', 'L', '+', '-', or '=', while it
- might be lower for glyphs like 'O', 'S', or 'W'.]
-
- - The `ttdebug` demo program didn't show changed point coordinates
- (bug introduced in version 2.10.3).
-
- - It is now possible to adjust the axis increment for variable fonts
- in the `ftmulti` demo program.
-
- - It is now possible to change the hinting engine in the `ftstring`
- demo program.
-
- - The graphical demo programs work better now in native color depth
- on win32 and x11.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.10.3 and 2.10.4 (2020-Oct-20)
-
- I. IMPORTANT BUG FIXES
-
- - A heap buffer overflow has been found in the handling of embedded
- PNG bitmaps, introduced in FreeType version 2.6.
-
- https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-15999
-
- If you use option FT_CONFIG_OPTION_USE_PNG you should upgrade
- immediately.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.10.2 and 2.10.3 (2020-Oct-10)
-
- I. IMPORTANT CHANGES
-
- - New flag `FT_OUTLINE_OVERLAP'. If set, make the smooth rasterizer
- do 4x4 oversampling to mitigate artifacts in pixels partially
- covered by overlapping contours. Note that this at least
- quadruples the rendering time.
-
- If a glyph in a TrueType font has the `OVERLAP_SIMPLE' or
- `OVERLAP_COMPOUND' bit set, FreeType automatically selects this
- rendering mode.
-
-
- II. MISCELLANEOUS
-
- - Using the arcane method of including FreeType header files with
- macros like `FT_FREETYPE_H' is no longer mandatory (but retained
- as an optional feature for backward compatibility).
-
- - Support for building the library with Meson. Building the demo
- programs with Meson will follow in a forthcoming release.
-
- - Minor improvements to the B/W rasterizer.
-
- - Auto-hinter support for Medefaidrin script.
-
- - Fix various memory leaks (mainly for CFF) and other issues that
- might cause crashes in rare circumstances.
-
- - Jam support has been removed.
-
- - In `ftview', custom LCD filter values are now normalized and
- balanced. Unorthodox filters are still available through the `-L'
- command line option.
-
- - The GUI demo programs can now be resized.
-
- - Demo programs that accept command line option `-k' can now handle
- function keys, too. The corresponding character codes start with
- 0xF1. As an example, the POSIX shell syntax (accepted by bash,
- ksh, and zsh)
-
- -k $'\xF3q'
-
- emulates the pressing of function key `F3' followed by key `q'.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.10.1 and 2.10.2 (2020-May-09)
-
- I. IMPORTANT CHANGES
-
- - Support of WOFF2 fonts. This code contribution was Nikhil
- Ramakrishnan's GSoC 2019 project.
-
-
- II. MISCELLANEOUS
-
- - Function `FT_Get_Var_Axis_Flags' returned random data for Type 1
- MM fonts.
-
- - Type 1 fonts with non-integer metrics are now supported by the new
- (CFF) engine introduced in FreeType 2.9.
-
- - Drop support for Python 2 in Freetype's API reference generator
- `docwriter' (Python >= 3.5 is required for targets `make refdoc'
- and `make refdoc-venv').
-
- - Auto-hinter support for Hanifi Rohingya.
-
- - Document the `FT2_KEEP_ALIVE' debugging environment variable.
-
- - The Visual C++ (and Visual C) project files for Windows builds no
- longer generate libraries that contain the FreeType version in its
- filenames. Instead, a resource file gets used to make the
- libraries contain the corresponding information.
-
- - The next release will remove Jam build support.
-
- - The `ftbench' demo program has a new test for testing the
- `FT_Glyph_Stroke' functionality.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.10.0 and 2.10.1 (2019-Jul-01)
-
- I. IMPORTANT BUG FIXES
-
- - The bytecode hinting of OpenType variation fonts was flawed, since
- the data in the `CVAR' table wasn't correctly applied.
-
-
- II. MISCELLANEOUS
-
- - Auto-hinter support for Mongolian.
-
- - For distribution, `.tar.bz2' packages are replaced with `.tar.xz'
- bundles.
-
- - The handling of the default character in PCF fonts as introduced
- in version 2.10.0 was partially broken, causing premature abortion
- of charmap iteration for many fonts.
-
- - If `FT_Set_Named_Instance' was called with the same arguments
- twice in a row, the function returned an incorrect error code the
- second time.
-
- - Direct rendering using FT_RASTER_FLAG_DIRECT crashed (bug
- introduced in version 2.10.0).
-
- - Increased precision while computing OpenType font variation
- instances.
-
- - The flattening algorithm of cubic Bezier curves was slightly
- changed to make it faster. This can cause very subtle rendering
- changes, which aren't noticeable by the eye, however.
-
- - The auto-hinter now disables hinting if there are blue zones
- defined for a `style' (i.e., a certain combination of a script and
- its related typographic features) but the font doesn't contain any
- characters needed to set up at least one blue zone.
-
- - The `ftmulti' demo program now supports multiple hidden axes with
- the same name tag.
-
- - `ftview', `ftstring', and `ftgrid' got a `-k' command line option
- to emulate a sequence of keystrokes at start-up.
-
- - `ftview', `ftstring', and `ftgrid' now support screen dumping to a
- PNG file.
-
- - The bytecode debugger, `ttdebug', now supports variation TrueType
- fonts; a variation font instance can be selected with the new `-d'
- command line option.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.9.1 and 2.10.0 (2019-Mar-15)
-
- I. IMPORTANT CHANGES
-
- - A bunch of new functions has been added to access and process
- COLR/CPAL data of OpenType fonts with color-layered glyphs.
-
- FT_Palette_Data_Get
- Retrieve color palette data.
- FT_Palette_Select
- Select and activate a color palette for color-layered
- glyphs.
- FT_Palette_Set_Foreground_Color
- Set text foreground color for palette index 0xFFFF.
-
- FT_Get_Color_Glyph_Layer
- Get color layers for a given glyph (using an interator
- object).
-
- FT_Bitmap_Blend
- Blend one bitmap onto another with a given color.
-
- - An experimental feature is the new behaviour of the
- `FT_LOAD_COLOR' load flag for color-layered glyphs: Internally
- it sets a flag so that if `FT_Render_Glyph' is called with
- `FT_RENDER_MODE_NORMAL' (or `FT_Load_Glyph' with
- `FT_LOAD_RENDER'), a default blending of the color glyph layers
- will happen automatically for convenience.
-
- - As a GSoC 2018 project, Nikhil Ramakrishnan completely
- overhauled and modernized the API reference.
-
-
- II. MISCELLANEOUS
-
- - The logic for computing the global ascender, descender, and
- height of OpenType fonts has been slightly adjusted for
- consistency.
-
- . If the `useTypoMetrics' flag (i.e., bit 7 in the `fsSelection'
- field) in the `OS/2' table is set, use the `sTypo' fields in
- `OS/2' unconditionally.
- . Otherwise use the metrics data from the `hhea' table (if not
- zero).
- . Otherwise use the `sTypo' fields from the `OS/2' table (if not
- zero).
- . Otherwise use the `usWin' data from the `OS/2' table as a last
- resort.
-
- Variable fonts will apply the `MVAR' deltas to whichever metrics
- were picked.
-
- - `TT_Set_MM_Blend' could fail if call repeatedly with the same
- arguments.
-
- - The precision of handling deltas in Variation Fonts has been
- increased. The problem did only show up with multidimensional
- designspaces.
-
- - New function `FT_Library_SetLcdGeometry' to set up the geometry
- of LCD subpixels.
-
- - FreeType now uses the `defaultChar' property of PCF fonts to set
- the glyph for the undefined character at glyph index 0 (as
- FreeType already does for all other supported font formats). As
- a consequence, the order of glyphs of a PCF font if accessed
- with FreeType can be different now compared to previous
- versions.
-
- This change doesn't affect PCF font access with cmaps.
-
- - `FT_Select_Charmap' has been changed to allow parameter value
- `FT_ENCODING_NONE', which is valid for BDF, PCF, and Windows FNT
- formats to access built-in cmaps that don't have a predefined
- `FT_Encoding' value.
-
- - A previously reserved field in the `FT_GlyphSlotRec' structure
- now holds the glyph index.
-
- - On Win32 platforms, the use of `_DLL' to build the library has
- been replaced with `DLL_EXPORT' and `DLL_IMPORT'.
-
- - The usual round of fuzzer bug fixes to better reject malformed
- fonts.
-
- - `FT_Outline_New_Internal' and `FT_Outline_Done_Internal' have
- been removed. These two functions were public by oversight only
- and were never documented.
-
- - A new function `FT_Error_String' returns descriptions of error
- codes if configuration macro FT_CONFIG_OPTION_ERROR_STRINGS is
- defined.
-
- - `FT_Set_MM_WeightVector' and `FT_Get_MM_WeightVector' are new
- functions limited to Adobe MultiMaster fonts to directly set and
- get the weight vector.
-
- - Support for Position Independent Code as needed by systems that
- prohibit automatic address fixups, such as BREW, has been
- removed. [Compilation with modern compilers that use flags like
- `-fPIC' or `-fPIE' is not affected.]
-
- - The `ftdump' demo program has new options `-c' and `-C' to
- display charmaps in compact and detailed format, respectively.
- Option `-V' has been removed.
-
- - The `ftview', `ftstring', and `ftgrid' demo programs use a new
- command line option `-d' to specify the program window's width,
- height, and color depth.
-
- - The `ftview' demo program now displays red boxes for zero-width
- glyphs.
-
- - `ftglyph' has limited support to display fonts with
- color-layered glyphs. This will be improved later on.
-
- - `ftgrid' can now display bitmap fonts also.
-
- - The `ttdebug' demo program has a new option `-f' to select a
- member of a TrueType collection (TTC).
-
- - Other various improvements to the demo programs.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.9 and 2.9.1 (2019-May-01)
-
- I. IMPORTANT BUG FIXES
-
- - Type 1 fonts containing flex features were not rendered
- correctly (bug introduced in version 2.9).
-
- - CVE-2018-6942: Older FreeType versions can crash with certain
- malformed variation fonts.
-
- https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-6942
-
-
- II. MISCELLANEOUS
-
- - Bug fix: Multiple calls to `FT_Get_MM_Var' returned garbage.
-
- - The base extensions `ftlcdfil' and `ftfntfmt' are now part of
- the base module (and thus no longer configurable in file
- `modules.cfg').
-
- - Emboldening of bitmaps didn't work correctly sometimes, showing
- various artifacts (bug introduced in version 2.8.1).
-
- - Use of the `freetype-config' script to get compilation and
- linking options is deprecated since it doesn't support
- cross-compiling, among other deficiencies. Instead, you should
- use the `pkg-config' interface.
-
- The `configure' script no longer installs `freetype-config' by
- default. For backward compatibility, a new configure option
- `--enable-freetype-config' is provided that reverts this
- decision.
-
- - The auto-hinter script ranges have been updated for Unicode 11.
- No support for new scripts have been added, however, with the
- exception of Georgian Mtavruli.
-
- - Support for cmake has been improved.
-
- - The next release will remove support for Position Independent
- Code as needed by systems that prohibit automatic address
- fixups, such as BREW. [Compilation with modern compilers that
- use flags like `-fPIC' or `-fPIE' is not affected.]
-
-
-======================================================================
-
-CHANGES BETWEEN 2.8.1 and 2.9 (2018-Jan-08)
-
- I. IMPORTANT BUG FIXES
-
- - Advance width values of variation fonts were often wrong.
-
- - More fixes for variation font support; you should update to this
- version if you want to support them.
-
-
- II. IMPORTANT CHANGES
-
- - As a GSoC project, Ewald Hew extended the new (Adobe) CFF engine
- to handle Type 1 fonts also, thus greatly improving the
- rendering of this format. This is the new default. The old
- engine is still available if the configuration macro
- `T1_CONFIG_OPTION_OLD_ENGINE' gets defined; using the
- `hinting-engine' property of the `type1' driver module you can
- then switch between the two engines.
-
- - A new function, `FT_Set_Named_Instance', can be used to set or
- change the current named instance.
-
- - Starting with this FreeType version, resetting variation
- coordinates will return to the currently selected named
- instance. Previously, FreeType returned to the base font (i.e.,
- no instance set).
-
-
- III. MISCELLANEOUS
-
- - The `face_flags' field of the `FT_Face' structure has a new bit,
- `FT_FACE_FLAG_VARIATION', which is set if a variation font has
- been altered with `FT_Set_MM_Design_Coordinates',
- `FT_Set_Var_Design_Coordinates', or
- `FT_Set_Var_Blend_Coordinates'.
-
- - If the current face is a named instance, the new macro
- `FT_IS_NAMED_INSTANCE' returns true.
-
- - `FT_IS_VARIATION' is a new macro that returns true whenever a
- face object has been altered by `FT_Set_MM_Design_Coordinates',
- `FT_Set_Var_Design_Coordinates', or
- `FT_Set_Var_Blend_Coordinates'.
-
- - Changing the design coordinates of a variation font with
- `FT_Set_Var_Design_Coordinates' or
- `FT_Set_Var_Blend_Coordinates' does not influence the named
- instance index value (only `FT_Set_Named_Instance' does that).
-
- - Special PostScript names for named instances are only returned
- if the named instance is set with `FT_Set_Named_Instance' (and
- the font has corresponding entries in its `fvar' table). If
- `FT_IS_VARIATION' returns true, the algorithmically derived
- PostScript name is provided, not looking up special entries for
- named instances.
-
- - A new function `FT_Done_MM_Var' is provided to free the memory
- returned in a call to `FT_Get_MM_Var'.
-
- - On platforms using the `configure' script, the installed
- `ftoption.h' file now correctly reflects configuration options
- like `--with-harfbuzz'.
-
- - Better support to build FreeType as a DLL on Windows using
- Visual C.
-
- - All data specific to driver modules is now collected in a single
- file, `FT_DRIVER_H'. Consequently, the macros
- `FT_AUTOHINTER_H', `FT_CFF_DRIVER_H', `FT_TRUETYPE_DRIVER_H',
- and `FT_PCF_DRIVER_H' still work but are deprecated.
-
- - Some fuzzer fixes to better reject malformed fonts.
-
- - The `ftbench' demo program has a new test for opening a new face
- and loading some glyphs.
-
- - The `ftbench' demo program has a new option `-j' to specify the
- last glyph index to be used in the tests.
-
- - The `ftgrid' demo program has a new option `-n' to suppress
- display of named instances of variation fonts.
-
- - The `ttdebug' demo program can now show a stack trace (key `K')
- and switch between hexadecimal and decimal display of integers
- (key `I').
-
-
-======================================================================
-
-CHANGES BETWEEN 2.8 and 2.8.1 (2017-Sep-16)
-
- I. IMPORTANT BUG FIXES
-
- - B/W hinting of TrueType fonts didn't work properly if
- interpreter version 38 or 40 was selected.
-
- - Some severe problems within the handling of TrueType Variation
- Fonts were found and fixed.
-
- - Function `FT_Set_Var_Design_Coordinates' didn't correctly handle
- the case with less input coordinates than axes.
-
-
- II. IMPORTANT CHANGES
-
- - By default, FreeType now offers high quality LCD-optimized
- output without resorting to ClearType techniques of resolution
- tripling and filtering. In this method, called Harmony, each
- color channel is generated separately after shifting the glyph
- outline, capitalizing on the fact that the color grids on LCD
- panels are shifted by a third of a pixel. This output is
- indistinguishable from ClearType with a light 3-tap filter.
-
-
- III. MISCELLANEOUS
-
- - Using the new function `FT_Get_Var_Axis_Flags', an application
- can access the `flags' field of a variation axis (introduced in
- OpenType version 1.8.2)
-
- - More sanity checks.
-
- - The internal representation of buffers for LCD rendering has
- changed (to be more precise, the amount of padding gets computed
- differently). Applications that use the FreeType API are not
- affected.
-
- - To reset all design axis values of a variation font to its
- default values you can now say
-
- error = FT_Set_Var_Design_Coordinates( face, 0, NULL );
-
- This also works with functions `FT_Set_MM_Design_Coordinates'
- and `FT_Set_MM_Blend_Coordinates'.
-
- - FreeType now synthesizes a missing Unicode cmap for (older)
- TrueType fonts also if glyph names are available.
-
- - FreeType has improved handling of BDF fonts without the
- `POINT_SIZE', `RESOLUTION_X', or `RESOLUTION_Y' properties; the
- library now uses the values of the `SIZE' keyword if they are
- missing. Previously, `SIZE' was completely ignored, and
- FreeType used heuristic values instead.
-
- - Multiple calls to `FT_Bitmap_Convert' do work now as advertised.
- Previously, they failed with an assertion error if there was an
- empty bitmap between non-empty ones.
-
- - The warping option has moved from `light' to `normal' hinting
- where it replaces the original hinting algorithm. The `light'
- mode is now always void of any hinting in x-direction.
-
- - 16bit compiler support is now officially ended. We didn't
- provide any maintenance since many years, and given that there
- were no error or problem reports either it seems that it is no
- longer needed.
-
- - The `ftgrid' demo program can now toggle the display of grid
- lines with the `G' key.
-
- - The `ftgrid' demo program can toggle a different set of colors
- (suitable to color-blind people) with the `C' key.
-
- - The `ftgrid' demo program now supports the `-e' command line
- option to select a cmap.
-
- - The `ftdump' demo program has a new command line option `-t' to
- output the SFNT table list.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.7.1 and 2.8 (2017-May-13)
-
- I. IMPORTANT CHANGES
-
- - Support for OpenType Variation Fonts is now complete. The last
- missing part was handling the `VVAR' and `MVAR' tables, which is
- available with this release.
-
- - A new function `FT_Face_Properties' allows the control of some
- module and library properties per font. Currently, the
- following properties can be handled: stem darkening, LCD filter
- weights, and the random seed for the `random' CFF operator.
-
- - The PCF change to show more `colorful' family names (introduced
- in version 2.7.1) was too radical; it can now be configured with
- PCF_CONFIG_OPTION_LONG_FAMILY_NAMES at compile time. If
- activated, it can be switched off at run time with the new pcf
- property `no-long-family-names'. If the `FREETYPE_PROPERTIES'
- environment variable is available, you can say
-
- FREETYPE_PROPERTIES=pcf:no-long-family-names=1
-
- - Support for the following scripts has been added to the
- auto-hinter.
-
- Adlam, Avestan, Bamum, Buhid, Carian, Chakma, Coptic, Cypriot,
- Deseret, Glagolitic, Gothic, Kayah, Lisu, N'Ko, Ol Chiki, Old
- Turkic, Osage, Osmanya, Saurashtra, Shavian, Sundanese, Tai
- Viet, Tifinagh, Unified Canadian Syllabics, Vai
-
-
- II. IMPORTANT BUG FIXES
-
- - `Light' auto-hinting mode no longer uses TrueType metrics for
- TrueType fonts. This bug was introduced in version 2.4.6,
- causing horizontal scaling also. Almost all GNU/Linux
- distributions (with Fedora as a notable exception) disabled the
- corresponding patch for good reasons; chances are thus high that
- you won't notice a difference.
-
- If optical backward compatibility for legacy applications is
- necessary, you might enable the AF_CONFIG_OPTION_TT_SIZE_METRICS
- configuration option. However, it is strongly recommended to
- avoid that, adjusting font sizes instead.
-
- - Global size metrics values in the `FT_Size_Metrics' structure
- can be different for TrueType fonts. Reason is that in older
- FreeType versions the metrics were rounded differently to
- integer pixels compared to all other font formats, yielding an
- inconsistent behaviour if you used non-native hinting. Starting
- with this version, global size metrics for TrueType fonts are
- handled the same as other font formats: `ascender' gets rounded
- up, `descender' gets rounded down, `height' gets normally
- rounded, and `max_advance' gets normally rounded, too.
-
- If you need more precise values of (global) ascender, descender,
- height, or `max_advance', please take the corresponding values
- from the `FT_Face' structure and scale them manually.
-
- - If a TrueType font gets loaded with FT_LOAD_NO_HINTING, FreeType
- now scales the font linearly again (bug introduced in version
- 2.4.6).
-
- - CVE-2017-8105, CVE-2017-8287: Older FreeType versions have
- out-of-bounds writes caused by heap-based buffer overflows
- related to Type 1 fonts.
-
- https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-8105
- https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-8287
-
-
- III. MISCELLANEOUS
-
- - A new function `FT_Set_Default_Properties' has been added to
- parse the `FREETYPE_PROPERTIES' environment variable
- (previously, it was internal only). `FT_Init_FreeType' always
- call this function, but `FT_New_Library' does not (similar to
- `FT_Add_Default_Modules').
-
- - To be in sync with OpenType version 1.7 and newer, macros
-
- FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY,
- FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY,
- TT_NAME_ID_PREFERRED_FAMILY
- TT_NAME_ID_PREFERRED_SUBFAMILY
-
- are renamed to
-
- FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_FAMILY,
- FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_SUBFAMILY,
- TT_NAME_ID_TYPOGRAPHIC_FAMILY
- TT_NAME_ID_TYPOGRAPHIC_SUBFAMILY
-
- The old macro names are deprecated (but still available).
-
- - Support for SFNT `name' tables has been improved.
-
- . Format 1 `name' tables are now supported. Use new function
- `FT_Get_Sfnt_LangTag' to access associated language tags.
-
- . Language, encoding, and name IDs have been updated to OpenType
- version 1.8.1.
-
- - The new CFF engine now handles the `random' operator. All CFF
- opcodes are now supported.
-
- - The CFF module has a new property `random-seed' to control the
- pseudo-random number generation for the `random' operator.
-
- - The `freetype-config' script is now a wrapper of `pkg-config' if
- this program is available in the path.
-
- - FT_LOAD_TARGET_LCD is now a variant of FT_LOAD_TARGET_LIGHT;
- this should provide better rendering results.
-
- - A mode to display light auto-hinting with subpixel positioning
- has been added to `ftdiff'.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.7 and 2.7.1 (2016-Dec-30)
-
- I. IMPORTANT CHANGES
-
- - Support for the new CFF2 font format as introduced with OpenType
- 1.8 has been contributed by Dave Arnolds from Adobe.
-
- - Preliminary support for variation fonts as specified in OpenType
- 1.8 (in addition to the already existing support for Adobe's MM
- and Apple's GX formats). Dave Arnolds contributed handling of
- advance width change variation; more will come in the next
- version.
-
-
- II. IMPORTANT BUG FIXES
-
- - Handling of raw CID fonts was partially broken (bug introduced
- in 2.6.4).
-
- - CVE-2016-10328: Older FreeType versions had an out-of-bounds
- write caused by a heap-based buffer overflow related to the CFF
- fonts.
-
- https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-10328
-
-
- III. MISCELLANEOUS
-
- - Some limits for TrueType bytecode execution have been tightened
- to speed up FreeType's handling of malformed fonts, in
- particular to quickly abort endless loops.
-
- - The number of twilight points can no longer be set to an
- arbitrarily large value.
-
- - The total number of jump opcode instructions (like JMPR) with
- negative arguments is dynamically restricted; the same holds
- for the total number of iterations in LOOPCALL opcodes.
-
- The dynamic limits are based on the number of points in a glyph
- and the number of CVT entries. Please report if you encounter a
- font where the selected values are not adequate.
-
- - PCF family names are made more `colorful'; they now include the
- foundry and information whether they contain wide characters.
- For example, you no longer get `Fixed' but rather `Sony Fixed'
- or `Misc Fixed Wide'.
-
- - A new function `FT_Get_Var_Blend_Coordinates' (with its alias
- name `FT_Get_MM_Blend_Coordinates') to retrieve the normalized
- blend coordinates of the currently selected variation instance
- has been added to the Multiple Masters interface.
-
- - A new function `FT_Get_Var_Design_Coordinates' to retrieve the
- design coordinates of the currently selected variation instance
- has been added to the Multiple Masters interface.
-
- - A new load flag `FT_LOAD_BITMAP_METRICS_ONLY' to retrieve bitmap
- information without loading the (embedded) bitmap itself.
-
- - Retrieving advance widths from bitmap strikes (using
- `FT_Get_Advance' and `FT_Get_Advances') have been sped up.
-
- - The usual round of fuzzer fixes to better reject malformed
- fonts.
-
- - The `ftmulti' demo program can now switch engines with key `H'.
-
- - The `ftstring' demo program can now show some built-in,
- non-latin sample strings (to be selected with the TAB key).
-
- - The `ftview' demo program can now switch between a font's
- charmaps using the TAB key.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.6.5 and 2.7 (2016-Sep-08)
-
- I. IMPORTANT CHANGES
-
- - As announced earlier, the 2.7.x series now uses the new subpixel
- hinting mode as the default, emulating a modern version of
- ClearType.
-
- This change inevitably leads to different rendering results, and
- you might change the `TT_CONFIG_OPTION_SUBPIXEL_HINTING'
- configuration option to adapt it to your taste (or use the new
- `FREETYPE_PROPERTIES' environment variable). See the
- corresponding entry below for version 2.6.4, which gives more
- information.
-
- - A new option `FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES' has been
- introduced. If set (which is the default), an environment
- variable `FREETYPE_PROPERTIES' can be used to control driver
- properties. Example:
-
- FREETYPE_PROPERTIES=truetype:interpreter-version=35 \
- cff:no-stem-darkening=1 \
- autofitter:warping=1
-
- This allows to select, say, the subpixel hinting mode at runtime
- for a given application. See file `ftoption.h' for more.
-
-
- II. IMPORTANT BUG FIXES
-
- - After loading a named instance of a GX variation font, the
- `face_index' value in the returned `FT_Face' structure now
- correctly holds the named instance index in the upper 16bits as
- documented.
-
-
- III. MISCELLANEOUS
-
- - A new macro `FT_IS_NAMED_INSTANCE' to test whether a given face
- is a named instance.
-
- - More fixes to GX font handling.
-
- - Apple's `GETVARIATION' bytecode operator (needed for GX
- variation font support) has been implemented.
-
- - Another round of fuzzer fixes, mainly to reject invalid fonts
- faster.
-
- - Handling of raw CID fonts was broken (bug introduced in version
- 2.6.4).
-
- - The smooth rasterizer has been streamlined to make it faster by
- approx. 20%.
-
- - The `ftgrid' demo program now understands command line option
- `-d' to give start-up design coordinates.
-
- - The `ftdump' demo program has a new command line option `-p' to
- dump TrueType bytecode instructions.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.6.4 and 2.6.5 (2016-Jul-12)
-
- I. IMPORTANT BUG FIXES
-
- - Compilation works again on Mac OS X (bug introduced in version
- 2.6.4).
-
-
- II. IMPORTANT CHANGES
-
- - The new subpixel hinting mode is now disabled by default; it
- will be enabled by default in the forthcoming 2.7.x series.
- Main reason for reverting this feature is the principle of least
- surprise: a sudden change in appearance of all fonts (even if
- the rendering improves for almost all recent fonts) should not
- be expected in a new micro version of a series.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.6.3 and 2.6.4 (2016-Jul-05)
-
- I. IMPORTANT CHANGES
-
- - A new subpixel hinting mode has been contributed by Nikolaus
- Waxweiler, which is now the default rendering mode for TrueType
- fonts. It implements (almost everything of) version 40 of the
- bytecode engine.
-
- The existing code base in FreeType (the `Infinality code') was
- stripped to the bare minimum and all configurability removed in
- the name of speed and simplicity. The configurability was
- mainly aimed at legacy fonts like Arial, Times New Roman, or
- Courier. [Legacy fonts are fonts that modify vertical stems to
- achieve clean black-and-white bitmaps.] The new mode focuses on
- applying a minimal set of rules to all fonts indiscriminately so
- that modern and web fonts render well while legacy fonts render
- okay.
-
- Activation of the subpixel hinting support can be controlled
- with the `TT_CONFIG_OPTION_SUBPIXEL_HINTING' configuration
- option at compile time: If set to value 1, you get the old
- Infinality mode (which was never the default due to its
- slowness). Value 2 activates the new subpixel hinting mode, and
- value 3 activates both. The default is value 2.
-
- At run time, you can select the subpixel hinting mode with the
- `interpreter-version' property (provided you have compiled in
- the corresponding hinting mode); see `ftttdrv.h' for more.
-
- - Support for the following scripts has been added to the
- auto-hinter.
-
- Armenian, Cherokee, Ethiopic, Georgian, Gujarati, Gurmukhi,
- Malayalam, Sinhala, Tamil
-
-
- II. MISCELLANEOUS
-
- - Type 42 fonts as created by LilyPond are now supported.
-
- - Minor rendering improvements in the auto-hinter.
-
- - For experimental reasons, the old CFF engine now supports all
- CFF operators except `random', including the deprecated Multiple
- Masters instructions. This allows the display of fonts like
- `ITCGaramondMM-It.otf' (without font variations, though).
-
- - Another round of fixes to improve handling of invalid fonts.
-
- - The `ftgrid' demo program now displays the rendered pixels also;
- this can be switched off with the `b' key. Selection of various
- LCD filtering modes can be done with the `L' key.
-
- - The demo programs have been extended to allow selection of all
- available TrueType bytecode engines.
-
- - A very early beta version of a new, Qt based demo program called
- `ftinspect' is part of the source code bundle; it will
- eventually supersede the other demo programs. Currently, you
- have to compile it manually with `qmake; make'; note that many
- features are still missing.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.6.2 and 2.6.3 (2016-Feb-08)
-
- I. IMPORTANT CHANGES
-
- - Khmer, Myanmar, Bengali, and Kannada script support has been
- added to the auto-hinter.
-
-
- II. MISCELLANEOUS
-
- - Better support of Indic scripts like Devanagari by using a
- top-to-bottom hinting flow.
-
- - All FreeType macros starting with two underscores have been
- renamed to avoid a violation of both the C and C++ standards.
- Example: Header macros of the form `__FOO_H__' are now called
- `FOO_H_'. In most cases, this should be completely transparent
- to the user. The exception to this is `__FTERRORS_H__', which
- must be sometimes undefined by the user to get FreeType error
- strings: Both this form and the new `FTERRORS_H_' macro are
- accepted for backward compatibility.
-
- - Minor improvements mainly to the Type 1 driver.
-
- - The new CFF engine now supports all Type 2 operators except
- `random'.
-
- - The macro `_STANDALONE_', used for compiling the B/W and smooth
- rasterizers as stand-alone modules, has been renamed to
- `STANDALONE_', since macro names starting with an underscore and
- followed by an uppercase letter are reserved in both C and C++.
-
- - Function `FT_Library_SetLcdFilterWeights' now also activates
- custom LCD filter weights (instead of just adjusting them).
-
- - Support for `unpatented hinting' has been completely removed:
- Consequently, the two functions `FT_Face_CheckTrueTypePatents'
- and `FT_Face_SetUnpatentedHinting' now return always false,
- doing nothing.
-
- - The `ftgamma' demo program has been modernized; the gamma grid
- display has been moved from `ftview' to this program.
-
- - In `ftview', it is now possible to cycle through the available
- LCD filtering modes.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.6.1 and 2.6.2 (2015-Nov-28)
-
- I. IMPORTANT CHANGES
-
- - The auto-hinter now supports stem darkening, to be controlled by
- the new `no-stem-darkening' and `darkening-parameters'
- properties. This is an experimental feature contributed by
- Nikolaus Waxweiler, and the interface might change in a future
- release.
-
- - By default, stem darkening is now switched off (for both the CFF
- engine and the auto-hinter). The main reason is that you need
- linear alpha blending and gamma correction to get correct
- rendering results, and the latter is not yet available in most
- freely available rendering stacks like X11. Applying stem
- darkening without proper gamma correction leads to far too dark
- rendering results.
-
- - The meaning of `FT_RENDER_MODE_LIGHT' has been slightly
- modified. It now essentially means `no hinting along the
- horizontal axis'; in particular, no change of glyph advance
- widths. Consequently, the auto-hinter is used for all scalable
- font formats except for CFF. It is planned that other
- font-specific rendering engines (TrueType, Type 1) will follow.
-
-
- II. MISCELLANEOUS
-
- - The default LCD filter has been changed to be normalized and
- color-balanced.
-
- - For better compatibility with FontConfig, function
- `FT_Library_SetLcdFilter' accepts a new enumeration value
- `FT_LCD_FILTER_LEGACY1' (which has the same meaning as
- `FT_LCD_FILTER_LEGACY').
-
- - A large number of bugs have been detected by using the libFuzzer
- framework, which should further improve handling of invalid
- fonts. Thanks again to Kostya Serebryany and Bungeman!
-
- - `TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES', a new configuration
- option, controls the maximum number of executed opcodes within a
- bytecode program. You don't want to change this except for very
- special situations (e.g., making a library fuzzer spend less
- time to handle broken fonts).
-
- - The smooth renderer has been made faster.
-
- - The `ftstring' demo program now supports subpixel rendering; use
- key `l' to cycle through the LCD modes.
-
- - The `ftstring' demo program now supports color rendering; use
- the `space' key to cycle through various color combinations.
-
- - The graphical demo programs now use a default gamma value of 1.8
- (instead of 1.2).
-
-
-======================================================================
-
-CHANGES BETWEEN 2.6 and 2.6.1 (2015-Oct-04)
-
- I. IMPORTANT BUG FIXES
-
- - It turned out that for CFFs only the advance widths should be
- taken from the `htmx' table, not the side bearings. This bug,
- introduced in version 2.6.0, makes it necessary to upgrade if
- you are using CFFs; otherwise, you get cropped glyphs with GUI
- interfaces like GTK or Qt.
-
- - Accessing Type 42 fonts returned incorrect results if the glyph
- order of the embedded TrueType font differs from the glyph order
- of the Type 42 charstrings table.
-
-
- II. IMPORTANT CHANGES
-
- - The header file layout has been changed (again), moving all
- header files except `ft2build.h' into a subdirectory tree.
-
- Doing so reduces the possibility of header file name clashes
- (e.g., FTGL's `FTGlyph.h' with FreeType's `ftglyph.h') on case
- insensitive file systems like Mac OS X or Windows.
-
- Applications that use (a) the `freetype-config' script or
- FreeType's `freetype2.pc' file for pkg-config to get the include
- directory for the compiler, and (b) the documented way for
- header inclusion like
-
- #include <ft2build.h>
- #include FT_FREETYPE_H
- ...
-
- don't need any change to the source code.
-
- - Simple access to named instances in GX variation fonts is now
- available (in addition to the previous method via FreeType's MM
- interface). In the `FT_Face' structure, bits 16-30 of the
- `face_index' field hold the current named instance index for the
- given face index, and bits 16-30 of `style_flags' contain the
- number of instances for the given face index. `FT_Open_Face'
- and friends also understand the extended bits of the face index
- parameter.
-
- You need to enable TT_CONFIG_OPTION_GX_VAR_SUPPORT for this new
- feature. Otherwise, bits 16-30 of the two fields are zero (or
- are ignored).
-
- - Lao script support has been added to the auto-hinter.
-
-
- III. MISCELLANEOUS
-
- - The auto-hinter's Arabic script support has been enhanced.
-
- - Superscript-like and subscript-like glyphs as used by various
- phonetic alphabets like the IPA are now better supported by the
- auto-hinter.
-
- - The TrueType bytecode interpreter now runs slightly faster.
-
- - Improved support for builds with cmake.
-
- - The function `FT_CeilFix' now always rounds towards plus
- infinity.
-
- - The function `FT_FloorFix' now always rounds towards minus
- infinity.
-
- - A new load flag `FT_LOAD_COMPUTE_METRICS' has been added; it
- makes FreeType ignore pre-computed metrics, as needed by font
- validating or font editing programs. Right now, only the
- TrueType module supports it to ignore data from the `hdmx'
- table.
-
- - Another round of bug fixes to better handle broken fonts, found
- by Kostya Serebryany <kcc@google.com>.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.5.5 and 2.6 (2015-Jun-07)
-
- I. IMPORTANT CHANGES
-
- - Behdad Esfahbod contributed code for improved thread-safety,
- which results in the following model.
-
- * An `FT_Face' object can only be safely used from one thread at
- a time.
-
- * An `FT_Library' object can now be used without modification
- from multiple threads at the same time.
-
- * `FT_Face' creation and destruction with the same `FT_Library'
- object can only be done from one thread at a time.
-
- One can use a single `FT_Library' object across threads as long
- as a mutex lock is used around `FT_New_Face' and `FT_Done_Face'.
- Any calls to `FT_Load_Glyph' and similar API are safe and do not
- need the lock to be held as long as the same `FT_Face' is not
- used from multiple threads at the same time.
-
- - Thai script support has been added to the auto-hinter.
-
- - Arabic script support has been added to the auto-hinter.
-
- - Following OpenType version 1.7, advance widths and side bearing
- values in CFFs (wrapped in an SFNT structure) are now always
- taken from the `hmtx' table.
-
- - Following OpenType version 1.7, the PostScript font name of a
- CFF font (wrapped in an SFNT structure) is now always taken from
- the `name' table. This is also true for OpenType Collections
- (i.e., TTCs using CFFs subfonts instead of TTFs), where it may
- have a significant difference.
-
- - Fonts natively hinted for ClearType are now supported, properly
- handling selector index 3 of the INSTCTRL bytecode instruction.
-
- - Major improvements to the GX TrueType variation font handling.
-
-
- II. MISCELLANEOUS
-
- - A new auto-hinter property `warping' can switch on and off the
- warping code if this experimental feature is compiled in (by
- defining the AF_CONFIG_OPTION_USE_WARPER configuration option;
- by default this option is now enabled but warping is switched
- off).
-
- The AF_CONFIG_OPTION_USE_WARPER option itself is an old feature,
- available since 2006. Warping only works in `light'
- auto-hinting mode. The idea of the code is to slightly scale
- and shift a glyph along the non-hinted dimension (which is
- usually the horizontal axis) so that as much of its segments are
- aligned (more or less) to the grid. To find out a glyph's
- optimal scaling and shifting value, various parameter
- combinations are tried and scored.
-
- See file `ftautoh.h' for more; the demo programs `ftdiff',
- `ftview', and `ftgrid' can toggle warping with key `w'.
-
- - Some fields in the `FTC_ImageTypeRec' structure have been
- changed from signed to unsigned type, which better reflects the
- actual usage. It is also an additional means to protect against
- malformed input.
-
- This change doesn't break the ABI; however, it might cause
- compiler warnings.
-
- - Function `FT_Bitmap_New' has been renamed to `FT_Bitmap_Init',
- since this name better reflects its function. For backward
- compatibility, the old function name is still available.
-
- - Function `FT_Get_X11_Font_Format' has been renamed to
- `FT_Get_Font_Format', since this name better reflects its
- function. For backward compatibility, the old function name is
- still available.
-
- Additionally, the header file macro for this function has been
- renamed to `FT_FONT_FORMATS_H' (the old name `FT_XFREE86_H' is
- retained for backward compatibility).
-
- - Various improvements to the `ftgrid' demo program.
-
- . It can now display GX and MM fonts while interactively
- manipulating the axes (with keys F2, F3, and F4).
-
- . Anti-aliasing rendering modes can now be selected (with keys
- F5 and F6).
-
- . The display of point numbers can be toggled with key `D'.
-
- - Various improvements to the `ftdump' demo program.
-
- . It now displays information on MM and GX variation axes.
-
- . New command line option `-u' makes it output data in utf-8
- encoding.
-
- - The `ftmulti' demo program can now handle up to six MM or GX
- axes.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.5.4 and 2.5.5 (2014-Dec-30)
-
- I. IMPORTANT BUG FIXES
-
- - Handling of uncompressed PCF files works again (bug introduced
- in version 2.5.4).
-
-
-======================================================================
-
-CHANGES BETWEEN 2.5.3 and 2.5.4 (2014-Dec-06)
-
- I. IMPORTANT BUG FIXES
-
- - A variant of vulnerability CVE-2014-2240 was identified
- (cf. https://savannah.nongnu.org/bugs/?43661) and fixed in the
- new CFF driver. All users should upgrade.
-
- - The new auto-hinter code using HarfBuzz crashed for some invalid
- fonts.
-
- - Many fixes to better protect against malformed input.
-
-
- II. IMPORTANT CHANGES
-
- - Full auto-hinter support of the Devanagari script.
-
- - Experimental auto-hinter support of the Telugu script.
-
- - CFF stem darkening behaviour can now be controlled at build time
- using the eight macros
-
- CFF_CONFIG_OPTION_DARKENING_PARAMETER_{X,Y}{1,2,3,4} .
-
- - Some fields in the `FT_Bitmap' structure have been changed from
- signed to unsigned type, which better reflects the actual usage.
- It is also an additional means to protect against malformed
- input.
-
- This change doesn't break the ABI; however, it might cause
- compiler warnings.
-
-
- III. MISCELLANEOUS
-
- - Improvements to the auto-hinter's algorithm to recognize stems
- and local extrema.
-
- - Function `FT_Get_SubGlyph_Info' always returned an error even in
- case of success.
-
- - Version 2.5.1 introduced major bugs in the cjk part of the
- auto-hinter, which are now fixed.
-
- - The `FT_Sfnt_Tag' enumeration values have been changed to
- uppercase, e.g. `FT_SFNT_HEAD'. The lowercase variants are
- deprecated. This is for orthogonality with all other
- enumeration (and enumeration-like) values in FreeType.
-
- - `cmake' now supports builds of FreeType as an OS X framework and
- for iOS.
-
- - Improved project files for vc2010, introducing a property file.
-
- - The documentation generator for the API reference has been
- updated to produce better HTML code (with proper CSS). At the
- same time, the documentation got a better structure.
-
- - The FT_LOAD_BITMAP_CROP flag is obsolete; it is not used by any
- driver.
-
- - The TrueType DELTAP[123] bytecode instructions now work in
- subpixel hinting mode as described in the ClearType whitepaper
- (i.e., for touched points in the non-subpixel direction).
-
- - Many small improvements to the internal arithmetic routines.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.5.2 and 2.5.3 (2014-Mar-06)
-
- I. IMPORTANT BUG FIXES
-
- - A vulnerability (CVE-2014-2240) was identified and fixed in the
- new CFF driver (cf. https://savannah.nongnu.org/bugs/?41697).
- All users should upgrade.
-
- - More bug fixes related to correct positioning of composite
- glyphs.
-
- - Many fixes to better protect against malformed input.
-
-
- II. IMPORTANT CHANGES
-
- - FreeType can now use the HarfBuzz library to greatly improve the
- auto-hinting of fonts that use OpenType features: Many glyphs
- that are part of such features but don't have cmap entries are
- now handled properly, for example small caps or superscripts.
- Define the configuration macro FT_CONFIG_OPTION_USE_HARFBUZZ to
- activate HarfBuzz support.
-
- You need HarfBuzz version 0.9.19 or newer.
-
- Note that HarfBuzz depends on FreeType; this currently causes a
- chicken-and-egg problem that can be solved as follows in case
- HarfBuzz is not yet installed on your system.
-
- 1. Compile and install FreeType without the configuration
- macro FT_CONFIG_OPTION_USE_HARFBUZZ.
-
- 2. Compile and install HarfBuzz.
-
- 3. Define macro FT_CONFIG_OPTION_USE_HARFBUZZ, then compile
- and install FreeType again.
-
- With FreeType's `configure' script the procedure boils down to
- configure, build, and install FreeType, then configure, compile,
- and install HarfBuzz, then configure, compile, and install
- FreeType again (after executing `make distclean').
-
- - All libraries FreeType depends on are now checked using the
- `pkg-config' configuration files first, followed by alternative
- methods.
-
- - The new value `auto' for the various `--with-XXX' library
- options (for example `--with-harfbuzz=auto') makes the
- `configure' script automatically link to the libraries it finds.
- This is now the default.
-
- - In case FreeType's `configure' script can't find a library, you
- can pass environment variables to circumvent pkg-config, and
- those variables have been harmonized as a consequence of the
- changes mentioned above:
-
- LIBZ -> removed; use LIBZ_CFLAGS and LIBZ_LIBS
- LIBBZ2 -> removed; use BZIP2_CFLAGS and BZIP2_LIBS
- LIBPNG_LDFLAGS -> LIBPNG_LIBS
-
- `./configure --help' shows all available environment variables.
-
- - The `freetype-config' script now understands option `--static'
- to emit static linking information.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.5.1 and 2.5.2 (2013-Dec-08)
-
- I. IMPORTANT BUG FIXES
-
- - Improving the display of some broken TrueType fonts introduced a
- bug that made FreeType crash on some popular (but not fully
- conformant) fonts like `ahronbd.ttf'.
-
- - Another round of improvements to correct positioning and hinting
- of composite glyphs in TrueType fonts.
-
-
- II. MISCELLANEOUS
-
- - Version 2.5.1 introduced a bug in handling embedded bitmap
- strikes of TrueType fonts, causing garbage display under some
- circumstances.
-
- - The `ftgrid' demo program couldn't be compiled in
- non-development builds.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.5 and 2.5.1 (2013-Nov-25)
-
- I. IMPORTANT BUG FIXES
-
- - For some WinFNT files, the last glyph wasn't displayed but
- incorrectly marked as invalid.
-
- - The vertical size of glyphs was incorrectly set after a call to
- `FT_GlyphSlot_Embolden', resulting in clipped glyphs.
-
- - Many fields of the `PCLT' table in SFNT based fonts (if accessed
- with `FT_Get_Sfnt_Table') were computed incorrectly.
-
- - In TrueType fonts, hinting of composite glyphs could sometimes
- deliver incorrect positions of components or even distorted
- shapes.
-
-
- II. IMPORTANT CHANGES
-
- - WOFF font format support has been added.
-
- - The auto-hinter now supports Hebrew. Greek and Cyrillic support
- has been improved.
-
- - Support for the forthcoming `OS/2' SFNT table version 5, as can
- be found e.g. in the `Sitka' font family for Windows 8.1.
-
- - The header file layout has been changed. After installation,
- all files are now located in `<prefix>/include/freetype2'.
-
- Applications that use (a) `freetype-config' or FreeType's
- `pkg-config' file to get the include directory for the compiler,
- and (b) the documented way for header inclusion like
-
- #include <ft2build.h>
- #include FT_FREETYPE_H
- ...
-
- don't need any change to the source code.
-
-
- III. MISCELLANEOUS
-
- - The stem darkening feature of the new CFF engine can now be
- fine-tuned with the new `darkening-parameters' property.
-
- - `ftgrid' has been updated to toggle various engines with the `H'
- key, similar to `ftview' and `ftdiff'.
-
- - The functionality of `ttdebug' has been greatly enhanced.
-
- . It now displays twilight, storage, and control value data; key
- `T' shows the twilight point table, key `S' the storage data,
- and key `C' the control value table.
-
- . Some keys have been reassigned from lowercase to their
- uppercase equivalents; for example `q' to quit the program is
- now `Q'.
-
- . Key `f' finishes the current function.
-
- . Key `R' restarts the debugger.
-
- . Keys `b' and `p' set a breakpoint.
-
- . Key `B' provides a function call backtrace.
-
- - Better support of ARMv7 and x86_64 processors.
-
- - Apple's `sbix' color bitmap format is now supported.
-
- - Improved auto-hinter rendering for many TrueType fonts,
- especially in the range 20-40ppem.
-
- - A new face flag `FT_FACE_FLAG_COLOR' has been added (to be
- accessed with the macro `FT_HAS_COLOR').
-
- - `FT_Gzip_Uncompress' (modeled after zlib's `uncompress'
- function) has been added; this is a by-product of the newly
- added WOFF support.
-
- - Support for a build with `cmake' has been contributed by John
- Cary <cary@txcorp.com>.
-
- - Support for x64 builds with Visual C++ has been contributed by
- Kenneth Miller <kennethadammiller@yahoo.com>
-
- - Manual pages for most demo programs have been added.
-
- - The GETINFO bytecode instruction for TrueType fonts was buggy if
- used to retrieve subpixel hinting information. It was necessary
- to set selector bit 6 to get results for selector bits 7-10,
- which is wrong.
-
- - Improved computation of emulated vertical metrics for TrueType
- fonts.
-
- - Fixed horizontal start-up position of vertical phantom points in
- TrueType bytecode.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.4.12 and 2.5 (2013-Jun-19)
-
- I. IMPORTANT BUG FIXES
-
- - The cache manager function `FTC_Manager_Reset' didn't flush the
- cache.
-
-
- II. IMPORTANT CHANGES
-
- - Behdad Esfahbod (on behalf of Google) contributed support for
- color embedded bitmaps (eg. color emoji).
-
- A new load flag, FT_LOAD_COLOR, makes FreeType load color
- embedded-bitmaps, following this draft specification
-
- https://color-emoji.googlecode.com/git/specification/v1.html
-
- which defines two new SFNT tables, `CBDT' and `CBLC' (named and
- modeled after `EBDT' and `EBLC', respectively). The color
- bitmaps are stored in the new FT_PIXEL_MODE_BGRA format to
- represent BGRA pre-multiplied sRGB images. If PNG support is
- available, PNG color images as defined in the same proposed
- specification are supported also.
-
- Note that color bitmaps are converted to grayscale if client
- didn't ask for color.
-
- - As announced in the previous release, the old FreeType CFF
- engine is now disabled by default. It can be conditionally
- compiled by defining the configuration macro
- CFF_CONFIG_OPTION_OLD_ENGINE.
-
- - As announced in the previous release, all code related to macro
- FT_CONFIG_OPTION_OLD_INTERNALS has been removed, thus becoming
- obsolete.
-
-
- III. MISCELLANEOUS
-
- - The property API (`FT_Property_Get' and `FT_Property_Set') is
- now declared as stable.
-
- The exception, however, are the experimental auto-hinter
- properties `glyph-to-script-map' and `fallback-script' which are
- subject to change in a forthcoming release.
-
- - `ftview' has been updated to support color embedded bitmaps; it
- can be toggled on and off with key `c'. The small cache toggle
- is now key `K'.
-
- - It is now possible to control the version of the TrueType
- hinting engine using the new `interpreter-version' property of
- the `truetype' module: Versions 35 and 38 (the default) are
- supported, which roughly corresponds to disable and enable
- subpixel hinting support, respectively.
-
- In both `ftview' and `ftdiff', switching between the two
- versions can be done with key `H'. In the `ftbench' demo
- program, command line option `-H' has been extended to activate
- the non-default interpreter version.
-
- - The `ttdebug' program has been further improved. In particular,
- it accepts a new command line option `-H' to select the hinting
- engine.
-
- - `ftdump's verbose option has been renamed to `-V'. For all demo
- programs, `-v' now shows version information.
-
- - Another round of TrueType subpixel hinting fixes.
-
- - The `apinames' tool can now create an import file for NetWare.
-
- - 64bit compilation of the new CFF engine was buggy.
-
- - Some fixes to improve robustness in memory-tight situations.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.4.11 and 2.4.12 (2013-May-08)
-
- - We have another CFF parsing and hinting engine! Written by Dave
- Arnold <darnold@adobe.com>, this work has been contributed by
- Adobe in collaboration with Google. It is vastly superior to
- the old CFF engine, and it will replace it in the next release.
- Right now, it is still off by default, and you have to
- explicitly select it using the new `hinting-engine' property of
- the cff driver:
-
- ...
- #include FT_MODULE_H
- #include FT_CFF_DRIVER_H
-
- FT_Library library;
- int engine = FT_CFF_HINTING_ADOBE;
-
-
- ...
- FT_Property_Set( library, "cff", "hinting-engine", &engine );
-
- The code has a (mature) beta status; we encourage all users to
- test it and report any problems.
-
- In case you want to activate the new CFF engine unconditionally,
- apply this patch:
-
---- snip ---
-diff --git a/src/cff/cffobjs.c b/src/cff/cffobjs.c
-index ebcf189..3f2ce6b 100644
---- a/src/cff/cffobjs.c
-+++ b/src/cff/cffobjs.c
-@@ -1056,7 +1056,7 @@
-
-
- /* set default property values */
-- driver->hinting_engine = FT_CFF_HINTING_FREETYPE;
-+ driver->hinting_engine = FT_CFF_HINTING_ADOBE;
- driver->no_stem_darkening = FALSE;
-
- return FT_Err_Ok;
---- snip ---
-
- - The macro FT_CONFIG_OPTION_OLD_INTERNALS is no longer set by
- default. In the next release, we will completely remove the
- associated code. Please update your programs in case you are
- still using this macro.
-
-
- II. MISCELLANEOUS
-
- - The (top-level) `configure' script now respects the MAKE
- environment variable to specify a `make' binary. For backward
- compatibility, GNUMAKE still overrides MAKE, though.
-
- - The `ftview' and `ftdiff' demo programs have been redesigned,
- showing more options permanently on the screen, among other
- minor improvements.
-
- - Using the `H' key, it is now possible to select the CFF engine
- in both `ftview' and `ftdiff'.
-
- - The new command line option `-H' for `ftbench' selects the Adobe
- CFF engine.
-
- - It is now possible to directly select the LCD rendering mode
- with the keys `A'-`F' in `ftview'. The key mapping for cycling
- through LCD modes has been changed from `K' and `L' to `k' and
- `l', and toggling custom LCD filtering is no longer mapped to
- key `F' but to key `L'.
-
- - In `ftdiff', key `x' toggles between layout modes: Either use
- the advance width (this is new and now the default) or the
- bounding box information to determine line breaks.
-
- - For all demo tools, the new command line option `-v' shows the
- version.
-
- - For the demo tools with a GUI, the new command line options `-w'
- and `-h' select the width and the height of the output window,
- respectively.
-
- - The `ttdebug' program was broken and has been reactivated. Note
- that this program is not compiled by default.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.4.10 and 2.4.11 (2012-Dec-20)
-
- I. IMPORTANT BUG FIXES
-
- - Some vulnerabilities in the BDF implementation have been fixed.
- Users of this font format should upgrade.
-
-
- II. IMPORTANT CHANGES
-
- - Subpixel hinting support has been contributed by Infinality,
- based on Greg Hitchcock's whitepaper at
-
- https://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
-
- Originally, it was a separate patch available from
-
- https://web.archive.org/web/20150710073951/http://www.infinality.net:80/blog/
-
- and which has been integrated.
-
- Note that ClearType support is not completely implemented! In
- particular, full support for the options `compatible_widths',
- `symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
- instruction) is missing.
-
- Activation of subpixel hinting support can be controlled with
- the `TT_CONFIG_OPTION_SUBPIXEL_HINTING' configuration option; it
- is switched off by default. This feature is still experimental;
- we welcome test reports!
-
- - Support for OpenType collections (OTC) has been added.
-
- - Pure CFF fonts within an SFNT wrapper are now supported.
-
-
- III. MISCELLANEOUS
-
- - Minor rendering improvements to the auto-hinter.
-
- - `FT_GlyphSlot_Oblique' now uses a shear angle of 12°.
-
- - Experimental support to handle `property modules', for example
- to control the behaviour of the auto-hinter. The API consists
- of two new functions, `FT_Property_Set' and `FT_Property_Get'.
-
- The code is still subject to change and should not be used for
- production.
-
- - The `ftdiff' demo program now supports UTF-8 encoded input files
- for option `-f'.
-
- - Using keys `r' and `R', you can now adjust the stroker radius in
- the `ftview' demo program.
-
- - Other, minor fixes and improvements.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.4.9 and 2.4.10 (2012-Jun-15)
-
- I. IMPORTANT BUG FIXES
-
- - Incremental glyph loading as needed by ghostscript was broken.
-
-
- II. MISCELLANEOUS
-
- - A new function `FT_Outline_EmboldenXY', contributed by Alexei
- Podtelezhnikov.
-
- - In the `ftview' demo program, key `e' has been replaced with `x'
- and `y' to embolden in the horizontal and vertical direction,
- respectively.
-
- - The glyph spacing computation in `FT_GlyphSlot_Embolden' (and
- similar code in `ftview') has been improved.
-
- - Minor improvements to the TrueType bytecode interpreter and
- glyph loader, the auto-hinter, and the B/W rasterizer.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.4.8 and 2.4.9 (2012-Mar-08)
-
- I. IMPORTANT BUG FIXES
-
- - Another round of fixes to better handle invalid fonts. Many of
- them are vulnerabilities (see CVE-2012-1126 up to CVE-2012-1144
- and SA48320) so all users should upgrade.
-
-
- II. MISCELLANEOUS
-
- - The `ENCODING -1 <n>' format of BDF fonts is now supported.
-
- - For BDF fonts, support for the whole Unicode encoding range has
- been added.
-
- - Better TTF support for x_ppem != y_ppem.
-
- - `FT_Get_Advances' sometimes returned bogus values.
-
- - The demo programs no longer recognize and handle default
- suffixes; you now have to always specify the complete font name.
-
- - Better rendering and LCD mode cycling added to `ftview'.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.4.7 and 2.4.8 (2011-Nov-14)
-
- I. IMPORTANT BUG FIXES
-
- - Some vulnerabilities in handling CID-keyed PostScript fonts have
- been fixed; see CVE-2011-3439.
-
-
- II. MISCELLANEOUS
-
- - Chris Liddell contributed a new API, `FT_Get_PS_Font_Value', to
- retrieve most of the dictionary keys in Type 1 fonts.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.4.6 and 2.4.7 (2011-Oct-18)
-
- I. IMPORTANT BUG FIXES
-
- - Some vulnerabilities in handling Type 1 fonts have been fixed;
- see CVE-2011-3256.
-
-
- II. MISCELLANEOUS
-
- - FreeType now properly handles ZapfDingbats glyph names while
- constructing a Unicode character map (for fonts which don't have
- one).
-
-
-======================================================================
-
-CHANGES BETWEEN 2.4.5 and 2.4.6 (2011-Jul-29)
-
- I. IMPORTANT BUG FIXES
-
- - For TrueType based fonts, the ascender and descender values were
- incorrect sometimes (off by a pixel if the ppem value was not a
- multiple of 5). Depending on the use you might now experience
- a different layout; the change should result in better, more
- consistent line spacing.
-
- - Fix CVE-2011-0226 which causes a vulnerability while handling
- Type 1 fonts.
-
- - BDF fonts containing glyphs with negative values for ENCODING
- were incorrectly rejected. This bug has been introduced in
- FreeType version 2.2.0.
-
- - David Bevan contributed a major revision of the FreeType stroker
- code:
-
- . The behaviour of FT_STROKER_LINEJOIN_BEVEL has been corrected.
-
- . A new line join style, FT_STROKER_LINEJOIN_MITER_FIXED, has
- been introduced to support PostScript and PDF miter joins.
-
- . FT_STROKER_LINEJOIN_MITER_VARIABLE has been introduced as an
- alias for FT_STROKER_LINEJOIN_MITER.
-
- . Various stroking glitches has been fixed.
-
-
- II. MISCELLANEOUS
-
- - SFNT bitmap fonts which contain an outline glyph for `.notdef'
- only no longer set the FT_FACE_FLAG_SCALABLE flag.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.4.4 and 2.4.5 (2011-Jun-25)
-
- I. IMPORTANT BUG FIXES
-
- - A rendering regression for second-order Bézier curves has been
- fixed, introduced in 2.4.3.
-
-
- II. IMPORTANT CHANGES
-
- - If autohinting is not explicitly disabled, FreeType now uses
- the autohinter if a TrueType based font doesn't contain native
- hints.
-
- - The load flag FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH has been made
- redundant and is simply ignored; this means that FreeType now
- ignores the global advance width value in TrueType fonts.
-
-
- III. MISCELLANEOUS
-
- - `FT_Sfnt_Table_Info' can now return the number of SFNT tables of
- a font.
-
- - Support for PCF files compressed with bzip2 has been contributed
- by Joel Klinghed. To make this work, the OS must provide a
- bzip2 library.
-
- - Bradley Grainger contributed project and solution files in
- Visual Studio 2010 format.
-
- - Again some fixes to better handle broken fonts.
-
- - Some improvements to the B/W rasterizer.
-
- - Fixes to the cache module to improve robustness.
-
- - Just Fill Bugs contributed (experimental) code to compute blue
- zones for CJK Ideographs, improving the alignment of horizontal
- stems at the top or bottom edges.
-
- - The `ftgrid' demo program can now display autohinter segments,
- to be toggled on and off with key `s'.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.4.3 and 2.4.4 (2010-Nov-28)
-
- I. IMPORTANT BUG FIXES
-
- - UVS support (TrueType/OpenType cmap format 14) support is fixed.
- This regression has been introduced in version 2.4.0.
-
-
- II. MISCELLANEOUS
-
- - Detect tricky fonts (e.g. MingLiU) by the lengths and checksums
- of Type42-persistent subtables (`cvt ', `fpgm', and `prep') when
- a TrueType font without family name is given. The previous fix,
- introduced in 2.4.3, was too rigorous, causing many subsetted
- fonts (mainly from PDF files) displayed badly because FreeType
- forced rendering with the TrueType bytecode engine instead of
- the autohinter.
-
- - Better support for 64bit platforms.
-
- - More fixes to improve handling of broken fonts.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.4.2 and 2.4.3 (2010-Oct-03)
-
- I. IMPORTANT BUG FIXES
-
- - Fix rendering of certain cubic, S-shaped arcs. This regression
- has been introduced in version 2.4.0.
-
-
- II. MISCELLANEOUS
-
- - To fix the above mentioned rendering issue, a new spline
- flattening algorithm has been introduced which speeds up both
- conic and cubic arcs.
-
- - Handling of broken fonts has been further improved.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.4.1 and 2.4.2 (2010-Aug-06)
-
- I. IMPORTANT BUG FIXES
-
- - A stack overflow in CFF Type2 CharStrings interpreter is fixed.
-
- - Handling Type 42 font deallocation was broken; additionally, the
- library is now more robust against malformed Type 42 fonts.
-
-
- II. MISCELLANEOUS
-
- - Two new functions, `FT_Reference_Library' (in FT_MODULE_H) and
- `FT_Reference_Face' (in FT_FREETYPE_H), have been added to
- simplify life-cycle management. A counter gets initialized to 1
- at the time an FT_Library (or FT_Face) structure is created.
- The two new functions increment the respective counter.
- `FT_Done_Library' and `FT_Done_Face' then only destroy a library
- or face if the counter is 1, otherwise they simply decrement the
- counter.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.4.0 and 2.4.1 (2010-Jul-18)
-
- I. IMPORTANT CHANGES
-
- - A serious bug in the CFF font module prevented display of many
- glyphs in CFF fonts like `MinionPro-Regular.otf'.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.3.12 and 2.4.0 (2010-Jul-12)
-
- I. IMPORTANT CHANGES
-
- - Since May 2010, all patents regarding the TrueType bytecode
- interpreter have expired worldwide. Consequently, we now define
- TT_CONFIG_OPTION_BYTECODE_INTERPRETER by default (and undefine
- TT_CONFIG_OPTION_UNPATENTED_HINTING).
-
- - A new function `FT_Library_SetLcdFilterWeights' is available to
- adjust the filter weights set by `FT_Library_SetLcdFilter'.
-
-
- II. MISCELLANEOUS
-
- - Thanks to many reports from Robert Święcki, FreeType's stability
- in handling broken or damaged fonts is much improved.
-
- - Support for LCD filter control has been added to the demo
- programs `ftdiff' and `ftview'.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.3.11 and 2.3.12
-
- I. IMPORTANT CHANGES
-
- - For `FT_Open_Face', new parameters are available to ignore
- preferred family names: FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY and
- FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY.
-
-
- II. MISCELLANEOUS
-
- - Support for incremental font loading (controlled with the
- FT_CONFIG_OPTION_INCREMENTAL macro) is now active by default.
-
- - Better support for vertical metrics.
-
- - Various minor bug fixes.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.3.10 and 2.3.11
-
- I. IMPORTANT BUG FIXES
-
- - Version 2.3.10 broke PCF support.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.3.10 and 2.3.9
-
- I. IMPORTANT BUG FIXES
-
- - If all ASCII digits in a font have the same (unscaled) width,
- the autohinter respects this and won't change it.
-
- - TrueType fonts are now rasterized correctly if the horizontal
- and vertical resolution differ.
-
- - Type 1 fonts are now handled with increased precision internally
- to avoid serious rounding issues if non-integral coordinates are
- encountered.
-
- - Horizontally condensed CFF fonts (using the font matrix) were
- rendered incorrectly. This bug has been introduced after
- release 2.3.5.
-
-
- II. IMPORTANT CHANGES
-
- - Support for the SFNT cmap 13 table format (as defined by the new
- OpenType 1.6 specification) has been added.
-
- - B/W rasterization of well-hinted TrueType fonts at small sizes
- has been greatly improved.
-
- - Calculation of vertical metrics in OpenType fonts has been
- improved.
-
-
- III. MISCELLANEOUS
-
- - It is now possible to change the emboldening factor in the
- `ftview' demo program with keys `e' and `E'.
-
- - It is now possible to change the slant value in the `ftview'
- demo program with keys `s' and `S'.
-
- - The 5-levels grayscale mode of the `ftraster' module (which
- FreeType doesn't use by default) was broken since version 2.3.0.
-
- - Compilation of the `ftgrays' and `ftraster' modules was broken
- in stand-alone mode.
-
- - Various fixes for compilation on 64bit and 16bit architectures.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.3.9 and 2.3.8
-
- I. IMPORTANT BUG FIXES
-
- - Very unfortunately, FreeType 2.3.8 contained a change that broke
- its official ABI. The end result is that programs compiled
- against previous versions of the library, but dynamically linked
- to 2.3.8 can experience memory corruption if they call the
- `FT_Get_PS_Font_Info' function.
-
- We recommend all users to upgrade to 2.3.9 as soon as possible,
- or to downgrade to a previous release of the library if this is
- not an option.
-
- The origin of the bug is that a new field was added to the
- publicly defined `PS_FontInfoRec' structure. Unfortunately,
- objects of this type can be stack or heap allocated by callers
- of `FT_Get_PS_Font_Info', resulting in a memory buffer
- overwrite with its implementation in 2.3.8.
-
- If you want to know whether your code is vulnerable to this
- issue, simply search for the substrings `PS_FontInfo' and
- `PS_Font_Info' in your source code. If none is found, your code
- is safe and is not affected.
-
- The FreeType team apologizes for the problem.
-
- - The POSIX support of MacOS resource-fork fonts (Suitcase fonts
- and LaserWriter Type1 PostScript fonts) was broken in 2.3.8. If
- FreeType2 is built without Carbon framework, these fonts are not
- handled correctly. Version 2.3.7 didn't have this bug.
-
- - `FT_Get_Advance' (and `FT_Get_Advances') returned bad values for
- almost all font formats except TrueType fonts.
-
- - Fix a bug in the SFNT kerning table loader/parser which could
- crash the engine if certain malformed tables were encountered.
-
- - Composite SFNT bitmaps are now handled correctly.
-
-
- II. IMPORTANT CHANGES
-
- - The new functions `FT_Get_CID_Is_Internally_CID_keyed' and
- `FT_Get_CID_From_Glyph_Index' can be used to access CID-keyed
- CFF fonts via CID values. This code has been contributed by
- Michael Toftdal.
-
-
- III. MISCELLANEOUS
-
- - `FT_Outline_Get_InsideBorder' returns FT_STROKER_BORDER_RIGHT
- for empty outlines. This was incorrectly documented.
-
- - The `ftview' demo program now supports UTF-8 encoded strings.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.3.8 and 2.3.7
-
- I. IMPORTANT BUG FIXES
-
- - CID-keyed fonts in an SFNT wrapper were not handled correctly.
-
- - The smooth renderer produced truncated images (on the right) for
- outline parts with negative horizontal values. Most fonts don't
- contain outlines left to the y coordinate axis, but the effect
- was very noticeable for outlines processed with FT_Glyph_Stroke,
- using thick strokes.
-
- - `FT_Get_TrueType_Engine_Type' returned a wrong value if both
- configuration macros TT_CONFIG_OPTION_BYTECODE_INTERPRETER and
- TT_CONFIG_OPTION_UNPATENTED_HINTING were defined.
-
- - The `face_index' field in the `FT_Face' structure wasn't
- initialized properly after calling FT_Open_Face and friends with
- a positive face index for CFFs, WinFNTs, and, most importantly,
- for TrueType Collections (TTCs).
-
-
- II. IMPORTANT CHANGES
-
- - Rudimentary support for Type 1 fonts and CID-keyed Type 1 fonts
- in an SFNT wrapper has been added -- such fonts are used on the
- Mac. The core SFNT tables `TYP1' and `CID ' are passed to the
- PS Type 1 and CID-keyed PS font drivers; other tables (`ALMX',
- `BBOX', etc.) are not supported yet.
-
- - A new interface to extract advance values of glyphs without
- loading their outlines has been added. The functions are called
- `FT_Get_Advance' and `FT_Get_Advances'; they are defined in file
- `ftadvanc.h' (to be accessed as FT_ADVANCES_H).
-
- - A new function `FT_Get_FSType_Flags' (in FT_FREETYPE_H) has been
- contributed by David Bevan to access the embedding and
- subsetting restriction information of fonts.
-
-
- III. MISCELLANEOUS
-
- - FT_MulFix is now an inlined function; by default, assembler code
- is provided for x86 and ARM. See FT_CONFIG_OPTION_INLINE_MULFIX
- and FT_CONFIG_OPTION_NO_ASSEMBLER (in ftoption.h) for more.
-
- - The handling of `tricky' fonts (that is, fonts which don't work
- with the autohinter, needing the font format's hinting engine)
- has been generalized and changed slightly:
-
- . A new face flag FT_FACE_FLAG_TRICKY indicates that the font
- format's hinting engine is necessary for correct rendering.
- The macro FT_IS_TRICKY can be used to check this flag.
-
- . FT_LOAD_NO_HINTING is now ignored for tricky fonts. To really
- force raw loading of such fonts (without hinting), both
- FT_LOAD_NO_HINTING and FT_LOAD_NO_AUTOHINT must be used --
- this is something which you probably never want to do.
-
- . Tricky TrueType fonts always use the bytecode interpreter,
- either the patented or unpatented version.
-
- - The function `FT_GlyphSlot_Own_Bitmap' has been moved from
- FT_SYNTHESIS_H to FT_BITMAP_H; it is now part of the `official'
- API. (The functions in FT_SYNTHESIS_H are still subject to
- change, however.)
-
- - In the `ftdiff' demo program you can now toggle the use of
- FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH with key `a'.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.3.7 and 2.3.6
-
- I. IMPORTANT BUG FIXES
-
- - If the library was compiled on an i386 platform using gcc, and
- compiler option -O3 was given, `FT_MulFix' sometimes returned
- incorrect results which could have caused problems with
- `FT_Request_Metrics' and `FT_Select_Metrics', returning an
- incorrect descender size.
-
- - Pure CFFs without subfonts were scaled incorrectly if the font
- matrix was non-standard. This bug has been introduced in
- version 2.3.6.
-
- - The `style_name' field in the `FT_FaceRec' structure often
- contained a wrong value for Type 1 fonts. This misbehaviour
- has been introduced in version 2.3.6 while trying to fix
- another problem. [Note, however, that this value is
- informative only since the used algorithm to extract it is
- very simplistic.]
-
-
- II. IMPORTANT CHANGES
-
- - Two new macros, FT_OUTLINE_SMART_DROPOUTS and
- FT_OUTLINE_EXCLUDE_STUBS, have been introduced. Together with
- FT_OUTLINE_IGNORE_DROPOUTS (which was ignored previously) it is
- now possible to control the dropout mode of the `raster' module
- (for B&W rasterization), using the `flags' field in the
- `FT_Outline' structure.
-
- - The TrueType bytecode interpreter now passes the dropout mode to
- the B&W rasterizer. This greatly increases the output for small
- ppem values of many fonts like `pala.ttf'.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.3.6 and 2.3.5
-
- I. IMPORTANT BUG FIXES
-
- - A bunch of potential security problems have been found. All
- users should update.
-
- - Microsoft Unicode cmaps in TrueType fonts are now always
- preferred over Apple cmaps. This is not a bug per se, but there
- exist some buggy fonts created for MS which have broken Apple
- cmaps. This affects only the automatic selection of FreeType;
- it's always possible to manually select an Apple Unicode cmap if
- desired.
-
- - Many bug fixes to the TrueType bytecode interpreter.
-
- - Improved Mac support.
-
- - Subsetted CID-keyed CFFs are now supported correctly.
-
- - CID-keyed CFFs with subfonts which are scaled in a non-standard
- way are now handled correctly.
-
- - A call to FT_Open_Face with `face_index' < 0 crashed FreeType if
- the font was a Windows (bitmap) FNT/FON.
-
-
- II. IMPORTANT CHANGES
-
- - The new function `FT_Get_CID_Registry_Ordering_Supplement' gives
- access to those fields in a CID-keyed font. The code has been
- contributed by Derek Clegg.
-
- - George Williams contributed code to validate the new `MATH'
- OpenType table (within the `otvalid' module). The `ftvalid'
- demo program has been extended accordingly.
-
- - An API for cmap 14 support (for Unicode Variant Selectors, UVS)
- has been contributed by George Williams.
-
- - A new face flag FT_FACE_FLAG_CID_KEYED has been added, together
- with a macro FT_IS_CID_KEYED which evaluates to 1 if the font is
- CID-keyed.
-
-
- III. MISCELLANEOUS
-
- - Build support for symbian has been contributed.
-
- - Better WGL4 glyph name support, contributed by Sergey Tolstov.
-
- - Debugging output of the various FT_TRACEX macros is now sent to
- stderr.
-
- - The `ftview' demo program now provides artificial slanting too.
-
- - The `ftvalid' demo program has a new option `-f' to select the
- font index.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.3.5 and 2.3.4
-
- I. IMPORTANT BUG FIXES
-
- - Some subglyphs in TrueType fonts were handled incorrectly due to
- a missing graphics state reinitialization.
-
- - Large .Z files (as distributed with some X11 packages) weren't
- handled correctly, making FreeType increase the heap stack in an
- endless loop.
-
- - A large number of bugs have been fixed to avoid crashes and
- endless loops with invalid fonts.
-
-
- II. IMPORTANT CHANGES
-
- - The two new cache functions `FTC_ImageCache_LookupScaler' and
- `FTC_SBit_Cache_LookupScaler' have been added to allow lookup of
- glyphs using an `FTC_Scaler' object; this makes it possible to
- use fractional pixel sizes in the cache. The demo programs have
- been updated accordingly to use this feature.
-
- - A new API `FT_Get_CMap_Format' has been added to get the cmap
- format of a TrueType font. This is useful in handling PDF
- files. The code has been contributed by Derek Clegg.
-
- - The auto-hinter now produces better output by default for
- non-Latin scripts like Indic. This was done by using the CJK
- hinting module as the default instead of the Latin one. Thanks
- to Rahul Bhalerao for this suggestion.
-
- - A new API `FT_Face_CheckTrueTypePatents' has been added to find
- out whether a given TrueType font uses patented bytecode
- instructions. The `ft2demos' bundle contains a new program
- called `ftpatchk' which demonstrates its usage.
-
- - A new API `FT_Face_SetUnpatentedHinting' has been added to
- enable or disable the unpatented hinter.
-
- - Support for Windows FON files in PE format has been contributed
- by Dmitry Timoshkov.
-
-
- III. MISCELLANEOUS
-
- - Vincent Richomme contributed Visual C++ project files for Pocket
- PCs.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.3.4 and 2.3.3
-
- I. IMPORTANT BUG FIXES
-
- - A serious bug in the handling of bitmap fonts (and bitmap
- strikes of outline fonts) has been introduced in 2.3.3.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.3.3 and 2.3.2
-
- I. IMPORTANT BUG FIXES
-
- - Remove a serious regression in the TrueType bytecode interpreter
- that was introduced in version 2.3.2. Note that this does not
- disable the improvements introduced to the interpreter in
- version 2.3.2, only some ill cases that occurred with certain
- fonts (though a few popular ones).
-
- - The auto-hinter now ignores single-point contours for computing
- blue zones. This bug created `wavy' baselines when rendering
- text with various fonts that use these contours to model
- mark-attach points (these are points that are never rasterized
- and are placed outside of the glyph's real outline).
-
- - The `rsb_delta' and `lsb_delta' glyph slot fields are now set to
- zero for mono-spaced fonts. Otherwise code that uses them would
- essentially ruin the fixed-advance property.
-
- - Fix CVE-2007-1351 which can cause an integer overflow while
- parsing BDF fonts, leading to a potentially exploitable heap
- overflow condition.
-
-
- II. MISCELLANEOUS
-
- - Fixed compilation issues on some 64-bit platforms (see ChangeLog
- for details).
-
- - A new demo program `ftdiff' has been added to compare TrueType
- hinting, FreeType's auto hinting, and rendering without hinting
- in three columns.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.3.2 and 2.3.1
-
- I. IMPORTANT BUG FIXES
-
- - FreeType returned incorrect kerning information from TrueType
- fonts when the bytecode interpreter was enabled. This happened
- due to a typo introduced in version 2.3.0.
-
- - Negative kerning values from PFM files are now reported
- correctly (they were read as 16-bit unsigned values from the
- file).
-
- - Fixed a small memory leak when `FT_Init_FreeType' failed for
- some reason.
-
- - The Postscript hinter placed and sized very thin and ghost stems
- incorrectly.
-
- - The TrueType bytecode interpreter has been fixed to get rid of
- most of the rare differences seen in comparison to the Windows
- font loader.
-
-
- II. IMPORTANT CHANGES
-
- - The auto-hinter now better deals with serifs and corner cases
- (e.g., glyph '9' in Arial at 9pt, 96dpi). It also improves
- spacing adjustments and doesn't change widths for non-spacing
- glyphs.
-
- - Many Mac-specific functions are deprecated (but still
- available); modern replacements have been provided for them.
- See the documentation in file `ftmac.h'.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.3.1 and 2.3.0
-
- I. IMPORTANT BUG FIXES
-
- - The TrueType interpreter sometimes returned incorrect horizontal
- metrics due to a bug in the handling of the SHZ instruction.
-
- - A typo in a security check introduced after version 2.2.1
- prevented FreeType to render some glyphs in CFF fonts.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.3.0 and 2.2.1
-
- I. IMPORTANT BUG FIXES
-
- - The PCF font loader is now much more robust while loading
- malformed font files.
-
- - Various memory leaks have been found and fixed.
-
- - The TrueType name loader now deals properly with some fonts that
- encode their names in UTF-16 (the specification was vague, and
- the code incorrectly assumed UCS-4).
-
- - Fixed the TrueType bytecode loader to deal properly with subtle
- monochrome/gray issues when scaling the CVT. Some fonts
- exhibited bad rendering artifacts otherwise.
-
- - `FT_GlyphSlot_Embolden' now supports vertical layouts correctly
- (it mangled the vertical advance height).
-
- - Fixed byte endian issues of `ftmac.c' to support Mac OS X on
- i386.
-
- - The PFR font loader no longer erroneously tags font files
- without any outlines as FT_FACE_FLAG_SCALABLE.
-
-
- II. NEW API FUNCTIONS
-
- - `FT_Library_SetLcdFilter' allows you to select a special filter
- to be applied to the bitmaps generated by `FT_Render_Glyph' if
- one of the FT_RENDER_MODE_LCD and FT_RENDER_MODE_LCD_V modes has
- been selected. This filter is used to reduce color fringes;
- several settings are available through the FT_LCD_FILTER_XXX
- enumeration.
-
- Its declaration and documentation can be found in file
- `include/freetype/ftlcdfil.h' (to be accessed with macro
- FT_LCD_FILTER_H).
-
- *IMPORTANT*: This function returns an error
- (FT_Err_Unimplemented_Feature) in default builds of the library
- for patent reasons. See below.
-
- - `FT_Get_Gasp' allows you to query the flags of the TrueType
- `gasp' table for a given character pixel size. This is useful
- to duplicate the text rendering of MS Windows when the native
- bytecode interpreter is enabled (which isn't the default for
- other patent reasons).
-
- Its declaration and documentation can be found in file
- `include/freetype/ftgasp.h' (to be accessed with macro
- FT_GASP_H).
-
-
- III. IMPORTANT CHANGES
-
- - The auto-hinter has been tuned a lot to improve its results with
- serif fonts, resulting in much better font rendering of many web
- pages.
-
- - The unpatented hinter is now part of the default build of the
- library; we have added code to automatically support `tricky'
- fonts that need it.
-
- This means that FreeType should `just work' with certain Asian
- fonts, like MingLiU, which cannot properly be loaded without a
- bytecode interpreter, but which fortunately do not use any of
- the patented bytecode opcodes. We detect these fonts by name,
- so please report any font file that doesn't seem to work with
- FreeType, and we shall do what we can to support it in a next
- release.
-
- Note that the API hasn't changed, so you can still force
- unpatented hinting with a special parameter to `FT_Open_Face' as
- well. This might be useful in same cases; for example, a PDF
- reader might present a user option to activate it to deal with
- certain `tricky' embedded fonts which cannot be clearly
- identified.
-
- If you are a developer for embedded systems, you might want to
- *disable* the feature to save code space by undefining
- TT_CONFIG_OPTION_UNPATENTED_HINTING in file `ftoption.h'.
-
- - LCD-optimized rendering is now *disabled* in all default builds
- of the library, mainly due to patent issues. For more
- information see:
-
- https://lists.gnu.org/archive/html/freetype/2006-09/msg00064.html
-
- A new configuration macro FT_CONFIG_OPTION_SUBPIXEL_RENDERING
- has been introduced in `ftoption.h'; manually define it in this
- file if you want to re-enable the feature.
-
- The change only affects the implementation, not the FreeType
- API. This means that clients don't need to be modified, because
- the library still generates LCD decimated bitmaps, but with the
- added constraint that R=G=B on each triplet.
-
- The displayed result should be equal to normal anti-aliased
- rendering.
-
- Additionally, if FT_CONFIG_OPTION_SUBPIXEL_RENDERING is not
- defined, the new `FT_Library_SetLcdFilter' function returns the
- FT_Err_Unimplemented_Feature error code.
-
- - Some computation bugs in the TrueType bytecode interpreter were
- found, which allow us to get rid of very subtle and rare
- differences we had experienced with the Windows renderer.
-
- - It is now possible to cross-compile the library easily. See the
- file `docs/INSTALL.CROSS' for details.
-
- - The file `src/base/ftmac.c' now contains code for Mac OS X only;
- its deprecated function `FT_GetFile_From_Mac_Font_Name' always
- returns an error even if the QuickDraw framework is available.
- The previous version has been moved to `builds/mac/ftmac.c'.
-
- Selecting configure option `--with-quickdraw-carbon' makes the
- build process use the original `ftmac.c' file instead of the Mac
- OS X-only version.
-
-
- IV. MISCELLANEOUS
-
- - Various performance and memory footprint optimizations have been
- performed on the TrueType and CFF font loaders, sometimes with
- very drastic benefits (e.g., the TrueType loader is now about
- 25% faster; FreeType should use less heap memory under nearly
- all conditions).
-
- - The anti-aliased rasterizer has been optimized and is now 15% to
- 25% percent faster than in previous versions, depending on
- content.
-
- - The Type 1 loader has been improved; as an example, it now skips
- top-level dictionaries properly.
-
- - Better support for Mac fonts on POSIX systems, plus compilation
- fixes for Mac OS X on ppc64 where `ftmac.c' cannot be built.
-
- - Configuration without `--with-old-mac-fonts' does not include
- `ftmac.c' (this was the behaviour in FreeType version 2.1.10).
-
- - The TrueTypeGX validator (gxvalid) checks the order of glyph IDs
- in the kern table.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.2.1 and 2.2
-
- I. IMPORTANT BUG FIXES
-
- - Various integer overflows have been fixed.
-
- - PFB fonts with MacOS resource fork weren't handled correctly on
- non-MacOS platforms.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.2 and 2.1.10
-
-(not released officially)
-
- I. IMPORTANT BUG FIXES
-
- - Vertical metrics for SFNT fonts were incorrect sometimes.
-
- - The FT_HAS_KERNING macro always returned 0.
-
- - CFF OpenType fonts didn't return correct vertical metrics for
- glyphs with outlines.
-
- - If FreeType was compiled without hinters, all font formats based
- on PS outlines weren't scaled correctly.
-
-
- II. IMPORTANT CHANGES
-
- - Version 2.2 no longer exposes its internals, that is, the header
- files located in the `include/freetype/internal' directory of
- the source package are not copied anymore by the `make install'
- command. Consequently, a number of rogue clients which directly
- access FreeType's internal functions and structures won't
- compile without modification.
-
- We provide patches for most of those rogue clients. See the
- following page for more information:
-
- https://www.freetype.org/freetype2/patches/rogue-patches.html
-
- Note that, as a convenience to our Unix desktop users, version
- 2.2 is *binary* compatible with FreeType 2.1.7, which means that
- installing this release on an existing distribution shall not
- break any working desktop.
-
- - FreeType's build mechanism has been redesigned. With GNU make
- it is now sufficient in most cases to edit two files:
- `modules.cfg', to select the library components, and the
- configuration file `include/freetype/config/ftoption.h' (which
- can be copied to the objects directory). Removing unused module
- directories to prevent its compilation and editing
- `include/freetype/config/ftmodule.h' is no longer necessary.
-
- - The LIGHT hinting algorithm produces more pleasant results.
- Also, using the FT_LOAD_TARGET_LIGHT flags within FT_Load_Glyph
- always forces auto-hinting, as a special exception. This allows
- you to experiment with it even if you have enabled the TrueType
- bytecode interpreter in your build.
-
- - The auto hinter now employs a new algorithm for CJK fonts, based
- on Akito Hirai's patch. Note that this only works for fonts
- with a Unicode charmap at the moment.
-
- - The following callback function types have changed slightly (by
- adding the `const' keyword where appropriate):
-
- FT_Outline_MoveToFunc
- FT_Outline_LineToFunc
- FT_Outline_ConicToFunc
- FT_Outline_CubicToFunc
- FT_SpanFunc
- FT_Raster_RenderFunc
-
- FT_Glyph_TransformFunc
- FT_Renderer_RenderFunc
- FT_Renderer_TransformFunc
-
- Note that this doesn't affect binary backward compatibility.
-
- - On MacOS, new APIs have been added as replacements for legacy
- APIs: `FT_New_Face_From_FSRef' for `FT_New_Face_From_FSSpec',
- and `FT_GetFile_From_Mac_ATS_Name' for
- `FT_GetFile_From_Mac_Name'. Legacy APIs are still available, if
- FreeType is built without disabling them.
-
- - A new API `FT_Select_Size' has been added to select a bitmap
- strike by its index. Code using other functions to select
- bitmap strikes should be updated to use this function.
-
- - A new API `FT_Get_SubGlyph_Info' has been added to retrieve
- subglyph data. This can be used by rogue clients which used to
- access the internal headers to get the corresponding data.
-
- - In 2.1.10, the behaviour of `FT_Set_Pixel_Sizes' was changed for
- BDF/PCF fonts, and only for them. This causes inconsistency.
- In this release, we undo the change. The intent of the change
- in 2.1.10 is to allow size selection through real dimensions,
- which can now be done through `FT_Request_Size'.
-
- - Some security issues were discovered and fixed in the CFF and
- Type 1 loader, causing crashes of FreeType by malformed font
- files.
-
-
- III. MISCELLANEOUS
-
- - The documentation for FT_LOAD_TARGET_XXX and FT_RENDER_MODE_XXX
- values now better reflects its usage and differences: One set is
- used to specify the hinting algorithm, the other to specify the
- pixel rendering mode.
-
- - `FT_New_Face' and `FT_New_Face_From_FSSpec' in ftmac.c have been
- changed to count supported scalable faces (sfnt, LWFN) only, and
- to return the number of available faces via face->num_faces.
- Unsupported bitmap faces (fbit, NFNT) are ignored.
-
- - builds/unix/configure has been improved for MacOS X. It now
- automatically checks available functions in Carbon library, and
- prepare to use newest functions by default. Options to specify
- the dependencies of each Carbon APIs (FSSpec, FSRef, old/new
- QuickDraw, ATS) are available too. By manual disabling of all
- QuickDraw functionality, FreeType can be built without
- `deprecated function' warnings on MacOS 10.4.x, but
- FT_GetFile_Mac_Name in ftmac.c then is changed to a dummy
- function, and returns an `unimplemented' error. For details see
- builds/mac/README.
-
- - SFNT cmap handling has been improved, mainly to run much faster
- with CJK fonts.
-
- - A new function `FT_Get_TrueType_Engine_Type (declared in
- `FT_MODULE_H') is provided to determine the status of the
- TrueType bytecode interpreter compiled into the library
- (patented, unpatented, unimplemented).
-
- - Vertical metrics of glyphs are synthesized if the font does not
- provide such information. You can tell whether the metrics are
- synthesized or not by checking the FT_FACE_FLAG_VERTICAL flag of
- the face.
-
- - The demo programs `ftview' and `ftstring' have been rewritten
- for better readability. `ftview' has a new switch `-p' to test
- FT_New_Memory_Face (instead of FT_New_Face).
-
- - FreeType now honours bit 1 in the `head' table of TrueType fonts
- (meaning `left sidebearing point at x=0'). This helps with some
- buggy fonts.
-
- - Rudimentary support for Adobe's new `SING Glyphlet' format. See
-
- https://www.adobe.com/content/dam/acom/en/devnet/font/pdfs/5148.SING_Tutorial.pdf
-
- for more information.
-
- - The `ftdump' program from the `ft2demos' bundle now shows some
- information about charmaps. It also supports a new switch `-v'
- to increase verbosity.
-
- - Better AFM support. This includes track kerning support.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.1.10 and 2.1.9
-
- I. IMPORTANT BUG FIXES
-
- - The size comparison for BDF and PCF files could fail sometimes.
-
- - Some CFF files were still not loaded correctly. Patch from
- Derek Noonburg.
-
- - The stroker still had some serious bugs.
-
- - Boris Letocha fixed a bug in the TrueType interpreter: The
- NPUSHW instruction wasn't skipped correctly in IF clauses. Some
- fonts like `Helvetica 75 Bold' failed.
-
- - Another serious bug in handling TrueType hints caused many
- distortions. It has been introduced in version 2.1.8, and it is
- highly recommended to upgrade.
-
- - FreeType didn't properly parse empty Type 1 glyphs.
-
- - An unbound dynamic buffer growth was fixed in the PFR loader.
-
- - Several bugs have been fixed in the cache sub-system.
-
- - FreeType behaved incorrectly when resizing two distinct but very
- close character pixel sizes through `FT_Set_Char_Size' (Savannah
- bug #12263).
-
- - The auto-hinter didn't work properly for fonts without a Unicode
- charmap -- it even refused to load the glyphs.
-
-
- II. IMPORTANT CHANGES
-
- - Many fixes have been applied to drastically reduce the amount of
- heap memory used by FreeType, especially when using
- memory-mapped font files (which is the default on Unix systems
- which support them).
-
- - The auto-hinter has been replaced with a new module, called the
- `auto-fitter'. It consumes less memory than its predecessor,
- and it is prepared to support non-latin scripts better in next
- releases.
-
- - George Williams contributed code to read kerning data from PFM
- files.
-
- - FreeType now uses the TT_NAME_ID_PREFERRED_FAMILY and
- TT_NAME_ID_PREFERRED_SUBFAMILY strings (if available) for
- setting family and style in SFNT fonts (patch from Kornfeld
- Eliyahu Peter).
-
- - A new API `FT_Sfnt_Table_Info' (in FT_TRUETYPE_TABLES_H) has
- been added to retrieve name and size information of SFNT tables.
-
- - A new API `FT_OpenType_Validate' (in FT_OPENTYPE_VALIDATE_H) has
- been added to validate OpenType tables (BASE, GDEF, GPOS, GSUB,
- JSTF). After validation it is no longer necessary to check
- for errors in those tables while accessing them.
-
- Note that this module might be moved to another library in the
- future to avoid a tight dependency between FreeType and the
- OpenType specification.
-
- - A new API in FT_BITMAP_H (`FT_Bitmap_New', `FT_Bitmap_Convert',
- `FT_Bitmap_Copy', `FT_Bitmap_Embolden', `FT_Bitmap_Done') has
- been added. Its use is to convert an FT_Bitmap structure in
- 1bpp, 2bpp, 4bpp, or 8bpp format into another 8bpp FT_Bitmap,
- probably using a different pitch, and to further manipulate it.
-
- - A new API `FT_Outline_Embolden' (in FT_OUTLINE_H) gives finer
- control how outlines are emboldened.
-
- - `FT_GlyphSlot_Embolden' (in FT_SYNTHESIS_H) now handles bitmaps
- also (code contributed by Chia I Wu). Note that this function
- is still experimental and may be replaced with a better API.
-
- - The method how BDF and PCF bitmap fonts are accessed has been
- refined. Formerly, FT_Set_Pixel_Sizes and FT_Set_Char_Size
- were synonyms in FreeType's BDF and PCF interface. This has
- changed now. FT_Set_Pixel_Sizes should be used to select the
- actual font dimensions (the `strike', which is the sum of the
- `FONT_ASCENT' and `FONT_DESCENT' properties), while
- FT_Set_Char_Size selects the `nominal' size (the `PIXELSIZE'
- property). In both functions, the width parameter is ignored.
-
-
- III. MISCELLANEOUS
-
- - The BDF driver no longer converts all returned bitmaps with a
- depth of 2bpp or 4bpp to a depth of 8bpp. The documentation has
- not mentioned this explicitly, but implementors might have
- relied on this after looking into the source files.
-
- - A new option `--ftversion' has been added to freetype-config to
- return the FreeType version.
-
- - The memory debugger has been updated to dump allocation
- statistics on all allocation sources in the library. This is
- useful to spot greedy allocations when loading and processing
- fonts.
-
- - We removed a huge array of constant pointers to constant strings
- in the `psnames' module. The problem was that compilations in
- PIC mode (i.e., when generating a Unix shared object/dll) put
- the array into the non-shared writable section of the library
- since absolute pointers are not relocatable by nature.
-
- This reduces the memory consumption by approximately 16KByte per
- process linked to FreeType. We now also store the array in a
- compressed form (as a trie) which saves about 20KByte of code as
- well.
-
- - Kirill Smelkov provided patches to make src/raster/ftraster.c
- compile stand-alone again.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.1.9 and 2.1.8
-
- I. IMPORTANT BUG FIXES
-
- - The function `FT_Get_CharMap_Index' was only declared, without
- any real code. For consistency, it has been renamed to
- `FT_Get_Charmap_Index'. (This function is needed to implement
- cmap caches.)
-
- - `FT_Outline_Get_BBox' sometimes returned incorrect values for
- conic outlines (e.g., for TrueType fonts).
-
- - Handling of `bhed' table has been fixed.
-
- - The TrueType driver with enabled byte code interpreter sometimes
- returned artifacts due to incorrect rounding. This bug has been
- introduced after version 2.1.4.
-
- - The BDF driver dropped the last glyph in the font.
-
- - The BDF driver now uses the DEFAULT_CHAR property (if available)
- to select a glyph shape for the undefined glyph.
-
- - The stroker failed for closed outlines and single points.
-
-
- II. IMPORTANT CHANGES
-
- - George Williams contributed code to handle Apple's font
- distortion technology found in GX fonts (`avar', `cvar', `fvar',
- and `gvar' tables; the Multiple Masters API has been slightly
- extended to cope with the new functionality).
-
- - The `FT_GlyphSlotRec' structure has been extended: The elements
- `lsb_delta' and `rsb_delta' give the difference between hinted
- and unhinted left and right side bearings if autohinting is
- active. Using those values can improve the inter-letter spacing
- considerably. See the documentation of `FT_GlyphSlotRec' and
- the `ftstring' demo program how to use it.
-
- - Loading TrueType and Type 1 fonts has been made much faster.
-
- - The stroker is no longer experimental (but the cache subsystem
- still is).
-
-
- III. MISCELLANEOUS
-
- - A new documentation file `formats.txt' describes various font
- formats supported (and not supported) by FreeType.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.1.8 and 2.1.7
-
- I. IMPORTANT BUG FIXES
-
- - The native TrueType hinter contained some bugs which prevented
- some fonts to be rendered correctly, most notably Legendum.otf.
-
- - The PostScript hinter now produces improved results.
-
- - The linear advance width and height values were incorrectly
- rounded, making them virtually unusable if not loaded with
- FT_LOAD_LINEAR_DESIGN.
-
- - Indexing CID-keyed CFF fonts is now working: The glyph index is
- correctly treated as a CID, similar to FreeType's CID driver
- module. Note that CID CMap support is still missing.
-
- - The FT_FACE_FLAG_GLYPH_NAMES flag is now set correctly for all
- font formats.
-
- - Some subsetted Type 1 fonts weren't parsed correctly. This bug
- has been introduced in 2.1.7. In summary, the Type 1 parser has
- become more robust.
-
- - Non-decimal numbers weren't parsed correctly in PS fonts.
-
- - The WinFNT driver now correctly reports FT_ENCODING_NONE for all
- but one encoding. Use the new FT_WinFNT_ID_XXX values together
- with `FT_Get_WinFNT_Header' to get the WinFNT charset ID.
-
- - The descender metrics (face->size->metrics.descender) for WinFNT
- bitmap fonts had the wrong sign.
-
- - The (emulated) `seac' support for CFF fonts was broken.
-
- - The `flex' operator didn't work for CFF fonts.
-
- - PS glyphs which use the `hintmask' operator haven't been
- rendered correctly in some cases.
-
- - Metrics for BDF and PCF bitmap font formats have been fixed.
-
- - Autohinting is now disabled for glyphs which are vertically
- distorted or mirrored (using a transformation matrix). This
- fixes a bug which produced zero-height glyphs.
-
- - The `freetype-config' script now handles --prefix and
- --exec-prefix correctly; it also returns the proper --rpath (or
- -R) value if FreeType has been built as a shared library.
-
-
- II. IMPORTANT CHANGES
-
- - Both PCF and BDF drivers now handle the SETWIDTH_NAME and
- ADD_STYLE_NAME properties. Values are appended to
- face->style_name; example: `Bold SemiCondensed'.
-
- - The PCF driver now handles bitmap fonts compressed with the LZW
- algorithm (extension .pcf.Z, compressed with `compress').
-
- - A new API function `FT_Get_CMap_Language_ID' (declared in
- `tttables.h') is available to get the language ID of a
- TrueType/SFNT cmap.
-
- - The hexadecimal format of data after the `StartData' command in
- CID-keyed Type 1 fonts is now supported. While this can't occur
- in file-based fonts, it can happen in document-embedded
- resources of PostScript documents.
-
- - Embedded bitmaps in SFNT-based CFF fonts are now supported.
-
- - A simple API is now available to control FreeType's tracing
- mechanism if compiled with FT_DEBUG_LEVEL_TRACE. See the file
- `ftdebug.h' for more details.
-
- - YAMATO Masatake contributed improved handling of MacOS resource
- forks on non-MacOS platforms (for example, Linux can mount MacOS
- file systems).
-
- - Support for MacOS has been improved; there is now a new function
- `FT_New_Face_From_FSSpec' similar to `FT_New_Face' except that
- it accepts an FSSpec instead of a path.
-
- - The cache sub-system has been rewritten.
-
- - There is now support for deinstallation of faces.
-
- - A new API function `FTC_Manager_RemoveFaceID' has been added
- to delete all `idle' nodes that correspond to a given
- FTC_FaceID. All `locked' nodes (i.e., those with a reference
- count > 0), will be modified to prevent them from appearing in
- further lookups (they will be cleaned normally when their
- reference count reaches 0).
-
- - There is now support for point scaling (i.e., providing
- character sizes in points + dpis, instead of pixels).
-
- - Three abstract cache classes are now available:
-
- FTC_GCache: Used to store one glyph item per cache node,
- with the ability to group common attributes into
- `families'. This replaces the old
- FTC_GlyphCache class.
-
- FTC_ICache: Used to store one FT_Glyph per cache node. This
- extends FTC_GCache. Family definition, family
- comparison, and glyph loading are however left
- to sub-classes.
-
- FTC_SCache: Used to store up to 16 small bitmaps per cache
- node. This extends FTC_GCache. Family
- definition, family comparison and glyph loading
- are however left to sub-classes.
-
- - The file `src/cache/ftcbasic.c' implements:
-
- FTC_ImageCache: Extends FTC_ICache; implements family
- definitions and glyph loading similar to the
- old API.
-
- FTC_SBitCache: Extends FTC_SCache, implements family
- definitions and glyph loading similar to the
- old API
-
- Client applications should be able to extend FTC_GCache,
- FTC_ICache, or FTC_SCache much more easily (i.e., less code to
- write, and less callbacks). For example, one could envision
- caches that are capable of storing transformed (obliqued),
- stroked, emboldened, or colored glyph images. Use
- `ftcbasic.c' as an example.
-
- - All public APIs are now in `include/freetype/ftcache.h', (to
- be accessed as `FT_CACHE_H'). The contents of
- `include/freetype/cache/' is only needed by applications that
- wish to implement their own caches.
-
- - There were some major performance improvements through the use
- of various programming tricks. Cache hits are up to 70%
- faster than in the old code.
-
- - The FTC_CMapCache has been simplified. Charmaps can only be
- accessed by index right now. There is also a new API named
- `FT_Charmap_GetIndex' for this purpose.
-
- - The demo programs have been updated to the new code. The
- previous versions will not work with the current one.
-
- - Using an invalid face index in FT_Open_Face and friends now
- causes an error even if the font contains a single face only.
-
-
- III. MISCELLANEOUS
-
- - Wolfgang Domröse contributed support files for building FreeType
- on the Atari using the PureC compiler. Note that the Atari is a
- 16bit platform.
-
- - Vitaliy Pasternak contributed project files for VS.NET 2003.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.1.7 and 2.1.6
-
- I. IMPORTANT BUG FIXES
-
- - Updated to newest libtool version, fixing build problems on
- various platforms.
-
- - On Unix platforms, `make install' didn't copy the correct
- `ftconfig.h' file.
-
- Note that version 2.1.7 contains the same library C source code as
- version 2.1.6.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.1.6 and 2.1.5
-
- I. IMPORTANT BUG FIXES
-
- - The PFR font driver didn't load kerning tables correctly, and
- the functions in FT_PFR_H didn't work at all.
-
- - Type 1 font files in binary format (PFB) with an end-of-file
- indicator weren't accepted by the FreeType engine.
-
- - Fonts which contain /PaintType and /StrokeWidth no longer cause
- a segfault. This bug has been introduced in version 2.1.5.
-
- - Fonts loaded with FT_LOAD_RENDER no longer cause strange
- results. This bug has been introduced in version 2.1.5.
-
- - Some Windows (bitmap) FNT/FON files couldn't be handled
- correctly.
-
-
- II. IMPORTANT CHANGES
-
- - The internal module API has been heavily changed in favor of
- massive simplifications within the font engine. This also means
- that authors of third-party modules must adapt their code to the
- new scheme.
-
- NOTE: THE NEW SCHEME IS NOT COMPLETED YET. PLEASE WAIT UNTIL A
- FINAL ANNOUNCEMENT!
-
- - The PostScript parser has been enhanced to handle comments and
- strings correctly. Additionally, more syntax forms are
- recognized.
-
- - Added the optional unpatented hinting system for TrueType. It
- allows typefaces which need hinting to produce correct glyph
- forms (e.g., Chinese typefaces from Dynalab) to work acceptably
- without infringing Apple patents. This system is compiled only
- if TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING is defined in
- ftoption.h (activated by default).
-
-
- III. MISCELLANEOUS
-
- - There is now a guard in the public header files to protect
- against inclusion of freetype.h from FreeType 1.
-
- - Direct inclusion of freetype.h and other public header files no
- longer works. You have to use the documented scheme
-
- #include <ft2build.h>
- #include FT_FREETYPE_H
-
- to load freetype.h with a symbolic name. This protects against
- renaming of public header files (which shouldn't happen but
- actually has, avoiding two public header files with the same
- name).
-
-
-======================================================================
-
-CHANGES BETWEEN 2.1.5 and 2.1.4
-
- I. IMPORTANT BUG FIXES
-
- - Parsing the /CIDFontName field now removes the leading slash to
- be in sync with other font drivers.
-
- - gzip support was buggy. Some fonts could not be read.
-
- - Fonts which have nested subglyphs more than one level deep no
- longer cause a segfault.
-
- - Creation of synthetic cmaps for fonts in CFF format was broken
- partially.
-
- - Numeric font dictionary entries for synthetic fonts are no
- longer overwritten.
-
- - The font matrix wasn't applied to the advance width for Type1,
- CID, and CFF fonts. This caused problems when loading certain
- synthetic Type 1 fonts like `Helvetica Narrow'.
-
- - The test for the charset registry in BDF and PCF fonts is now
- case-insensitive.
-
- - FT_Vector_Rotate sometimes returned strange values due to
- rounding errors.
-
- - The PCF driver now returns the correct number of glyphs
- (including an artificial `notdef' glyph at index 0).
-
- - FreeType now supports buggy CMaps which are contained in many
- CJK fonts from Dynalab.
-
- - Opening an invalid font on a Mac caused a segfault due to
- double-freeing memory.
-
- - BDF fonts with more than 32768 glyphs weren't supported
- properly.
-
-
- II. IMPORTANT CHANGES
-
- - Accessing bitmap font formats has been synchronized. To do that
- the FT_Bitmap_Size structure has been extended to contain new
- fields `size', `x_ppem', and `y_ppem'.
-
- - The FNT driver now returns multiple faces, not multiple strikes.
-
- - The `psnames' module has been updated to the Adobe Glyph List
- version 2.0.
-
- - The `psnames' module now understands `uXXXX[X[X]]' glyph names.
-
- - The algorithm for guessing the font style has been improved.
-
- - For fonts in SFNT format, root->height is no longer increased if
- the line gap is zero. There exist fonts (containing e.g. form
- drawing characters) which intentionally have a zero line gap
- value.
-
- - ft_glyph_bbox_xxx flags are now deprecated in favour of
- FT_GLYPH_BBOX_XXX.
-
- - ft_module_xxx flags are now deprecated in favour of
- FT_MODULE_XXX.
-
- - FT_ENCODING_MS_{SJIS,GB2312,BIG5,WANSUNG,JOHAB} are now
- deprecated in favour of
- FT_ENCODING_{SJIS,GB2312,BIG5,WANSUNG,JOHAB} -- those encodings
- are not specific to Microsoft.
-
-
- III. MISCELLANEOUS
-
- - The autohinter has been further improved; for example, `m'
- glyphs now retain its vertical symmetry.
-
- - Partial support of Mac fonts on non-Mac platforms.
-
- - `make refdoc' (after first `make') builds the HTML
- documentation. You need Python for this.
-
- - The make build system should now work more reliably on DOS-like
- platforms.
-
- - Support for EMX gcc and Watson C/C++ compilers on MS-DOS has
- been added.
-
- - Better VMS build support.
-
- - Support for the pkg-config package by providing a `freetype.pc'
- file.
-
- - New configure option --with-old-mac-fonts for Darwin.
-
- - Some source files have been renamed (mainly to fit into the 8.3
- naming scheme).
-
-
-======================================================================
-
-CHANGES BETWEEN 2.1.4 and 2.1.3
-
- I. IMPORTANT BUG FIXES
-
- - Updated to newest libtool version, fixing build problems on
- various platforms.
-
- - A fix in the Gzip stream reader: It couldn't read certain .gz
- files properly due to a small typo. In certain cases, FreeType
- could also loop endlessly when trying to load tiny gzipped
- files.
-
- - The configure script now tries to use the system-wide zlib when
- it finds one (instead of the copy found in src/gzip). And
- `freetype-config' has been updated to return relevant flags in
- this case when invoked with `--libs' (e.g. `-lzlib').
-
- - Certain fonts couldn't be loaded by 2.1.3 because they lacked a
- Unicode charmap (e.g. SYMBOL.TTF). FreeType erroneously
- rejected them.
-
- - The CFF loader was modified to accept fonts which only contain a
- subset of their reference charset. This prevented the correct
- use of PDF-embedded fonts.
-
- - The logic to detect Unicode charmaps has been modified. This is
- required to support fonts which include both 16-bit and 32-bit
- charmaps (like very recent asian ones) using the new 10 and 12
- SFNT formats.
-
- - The TrueType loader now limits the depth of composite glyphs.
- This is necessary to prevent broken fonts to break the engine by
- blowing the stack with recursive glyph definitions.
-
- - The CMap cache is now capable of managing UCS-4 character codes
- that are mapped through extended charmaps in recent
- TrueType/OpenType fonts.
-
- - The cache sub-system now properly manages out-of-memory
- conditions instead of blindly reporting them to the caller.
- This means that it will try to empty the cache before restarting
- its allocations to see if that can help.
-
- - The PFR driver didn't return the list of available embedded
- bitmaps properly.
-
- - There was a nasty memory leak when using embedded bitmaps in
- certain font formats.
-
-
- II. IMPORTANT CHANGES
-
- - David Chester contributed some enhancements to the auto-hinter
- that significantly increase the quality of its output. The
- Postscript hinter was also improved in several ways.
-
- - The FT_RENDER_MODE_LIGHT render mode was implemented.
-
- - A new API function called `FT_Get_BDF_Property' has been added
- to FT_BDF_H to retrieve BDF properties from BDF _and_ PCF font
- files. THIS IS STILL EXPERIMENTAL, since it hasn't been
- properly tested yet.
-
- - A Windows FNT specific API has been added, mostly to access font
- headers. This is used by Wine.
-
- - TrueType tables without an `hmtx' table are now tolerated when
- an incremental interface is used. This happens for certain
- Type42 fonts passed from Ghostscript to FreeType.
-
- - The PFR font driver is now capable of returning the font family
- and style names when they are available (instead of the sole
- `FontID'). This is performed by parsing an *undocumented*
- portion of the font file!
-
-
- III. MISCELLANEOUS
-
- - The path stroker in FT_STROKER_H has entered beta stage. It now
- works very well, but its interface might change a bit in the
- future. More on this in later releases.
-
- - The documentation for FT_Size_Metrics didn't appear properly in
- the API reference.
-
- - The file docs/VERSION.DLL has been updated to explain versioning
- with FreeType (i.e., comparing release/libtool/so numbers, and
- how to use them in autoconf scripts).
-
- - The installation documentation has been seriously revamped.
- Everything is now in the `docs' directory.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.1.3 and 2.1.2
-
- I. IMPORTANT BUG FIXES
-
- - FT_Vector_Transform had been incorrectly modified in 2.1.2,
- resulting in incorrect transformations being applied (for
- example, rotations were processed in opposite angles).
-
- - The format 8 and 12 TrueType charmap enumeration routines have
- been fixed (FT_Get_Next_Char returned invalid values).
-
- - The PFR font driver returned incorrect advance widths if the
- outline and metrics resolution defined in the font file were
- different.
-
- - FT_Glyph_To_Bitmap now returns successfully when called with an
- FT_BitmapGlyph argument (it previously returned an error).
-
- - A bug in the Type 1 loader that prevented valid font bounding
- boxes to be loaded from multiple master fonts.
-
- - The SFNT validation code has been rewritten. FreeType can now
- load `broken' fonts that were usable on Windows, but not with
- previous versions of the library.
-
- - The computation of bearings in the BDF driver has been fixed.
-
- - The Postscript hinter crashed when trying to hint certain glyphs
- (more precisely, when trying to apply hints to an empty glyph
- outline).
-
- - The TrueType glyph loader now supports composites in `Apple
- format' (they differ slightly from Microsoft/OpenType ones in
- the way transformation offsets are computed).
-
- - FreeType was very slow at opening certain asian CID/CFF fonts,
- due to fixed increment in dynamic array re-allocations. This
- has been changed to exponential behaviour to get acceptable
- performance.
-
-
-
- II. IMPORTANT CHANGES
-
- - The PCF driver now supports gzip-compressed font files natively.
- This means that you will be able to use all these bitmap fonts
- that come with XFree86 with FreeType (and libXft/libXft2, by
- extension).
-
- - The automatic and postscript hinters have both been updated.
- This results in a relatively important increase of rendering
- quality since many nasty defaults have been suppressed. Please
- visit the web page:
-
- https://www.freetype.org/hinting/smooth-hinting.html
-
- for additional details on this topic.
-
- - The `load_flags' parameter of `FT_Load_Glyph' is now an FT_Int32
- (instead of just being an FT_Int). This breaks source and
- binary compatibility for 16bit systems only, while retaining
- both of them for 32 and 64 bit ones.
-
- Some new flags have been added consequently:
-
- FT_LOAD_NO_AUTOHINT :: Disable the use of the auto-hinter
- (but not native format hinters).
-
- FT_LOAD_TARGET_NORMAL :: Hint and render for normal
- anti-aliased displays.
-
- FT_LOAD_TARGET_MONO :: Hint and render for 1-bit displays.
-
- FT_LOAD_TARGET_LCD :: Hint and render for horizontal RGB or
- BGR subpixel displays (like LCD
- screens). THIS IS STILL
- EXPERIMENTAL!
-
- FT_LOAD_TARGET_LCD_V :: Same as FT_LOAD_TARGET_LCD, for
- vertical subpixel displays (like
- rotated LCD screens). THIS IS STILL
- EXPERIMENTAL!
-
- FT_LOAD_MONOCHROME is still supported, but only affects
- rendering, not the hinting.
-
- Note that the `ftview' demo program available in the `ft2demos'
- package has been updated to support LCD-optimized display on
- non-paletted displays (under Win32 and X11).
-
- - The PFR driver now supports embedded bitmaps (all formats
- supported), and returns correct kerning metrics for all glyphs.
-
- - The TrueType charmap loader now supports certain `broken' fonts
- that load under Windows without problems.
-
- - The cache API has been slightly modified (it's still a beta!):
-
- - The type FTC_ImageDesc has been removed; it is now replaced
- by FTC_ImageTypeRec. Note that one of its fields is a
- `load_flag' parameter for FT_Load_Glyph.
-
- - The field `num_grays' of FT_SBitRec has been changed to
- `max_grays' in order to fit within a single byte. Its
- maximum value is thus 255 (instead of 256 as previously).
-
-
- III. MISCELLANEOUS
-
- - Added support for the DESTDIR variable during `make install'.
- This simplifies packaging of FreeType.
-
- - Included modified copies of the ZLib sources in `src/gzip' in
- order to support gzip-compressed PCF fonts. We do not use the
- system-provided zlib for now, though this is a probable
- enhancement for future releases.
-
- - The DocMaker tool used to generate the on-line API reference has
- been completely rewritten. It is now located in
- `src/tools/docmaker/docmaker.py'. Features:
-
- - better cross-referenced output
- - more polished output
- - uses Python regular expressions (though it didn't speed the
- program)
- - much more modular structure, which allows for different
- `backends' in order to generate HTML, XML, or whatever
- format.
-
- One can regenerate the API reference by calling:
-
- python src/tools/docmaker/docmaker.py \
- --prefix=ft2 \
- --title=FreeType-2.1.3 \
- --output=<outputdirectory>
- include/freetype/*.h \
- include/freetype/config/*.h \
- include/freetype/cache/*.h
-
- - A new, experimental, support for incremental font loading (i.e.,
- loading of fonts where the glyphs are not in the font file
- itself, but provided by an external component, like a Postscript
- interpreter) has been added by Graham Asher. This is still work
- in progress, however.
-
- - A new, EXPERIMENTAL, path stroker has been added. It doesn't
- suffer from severe rounding errors and treat bezier arcs
- directly. Still work in progress (i.e. not part of the official
- API). See the file <freetype/ftstroker.h> for some of the
- details.
-
- - The massive re-formatting of sources and internal re-design is
- still under-way. Many internal functions, constants, and types
- have been renamed.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.1.2 and 2.1.1
-
- I. IMPORTANT BUG FIXES
-
- - Many font drivers didn't select a Unicode charmap by default
- when a new face was opened (with the FT_CONFIG_OPTION_USE_CMAPS
- options enabled), causing many applications to not be able to
- display text correctly with the 2.1.x releases.
-
- - The PFR driver had a bug in its composite loading code that
- produces incorrectly placed accents with many fonts.
-
- - The Type42 driver crashed sometimes due to a nasty bug.
-
- - The Type 1 custom encoding charmap didn't handle the case where
- the first glyph index wasn't 0.
-
- - A serious typo in the TrueType composite loader produced
- incorrectly placed glyphs in fonts like `Wingdings' and a few
- others.
-
-
- II. MISCELLANEOUS
-
- - The Win32 Visual C++ project file has been updated to include
- the PFR driver as well.
-
- - `freetype.m4' is now installed by default by `make install' on
- Unix systems.
-
- - The function FT_Get_PS_Font_Info now works with CID and Type42
- fonts as well.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.1.1 and 2.1.0
-
- I. IMPORTANT BUG FIXES
-
- - The `version_info' returned by `freetype-config' in 2.1.0
- returned an invalid value. It now returns 9:1:3 (2.0.9 returned
- 9:0:3).
-
- - Version 2.1.0 couldn't be linked against applications on Win32
- and Amiga systems due to a new debug function that wasn't
- properly propagated to the system-specific directory in
- `builds'.
-
- - Various MacOS and Mac OS X specific fixes.
-
- - Fixed a bug in the TrueType charmap validation routines that
- made version 2.1.0 too restrictive -- many popular fonts have
- been rejected.
-
- - There was still a very small difference between the monochrome
- glyph bitmaps produced by FreeType 1.x and FreeType 2.x with the
- bytecode interpreter enabled. This was caused by an invalid
- flag setting in the TrueType glyph loader, making the rasterizer
- change its drop-out control mode. Now the results should
- _really_ be completely identical.
-
- - The TrueType name table loader has been improved to support many
- popular though buggy Asian fonts. It now ignores empty name
- entries, invalid pointer offsets and a few other incorrect
- subtleties. Moreover, name strings are now loaded on demand,
- which reduces the memory load of many faces (e.g. the ARIAL.TTF
- font file contains a 10kByte name table with 70 names).
-
- - Fixed a bug in the Postscript hinter that prevented family blues
- substitution to happen correctly.
-
-
- II. NEW FEATURES
-
- - Three new font drivers in this release:
-
- * A BDF font driver, contributed by Franco Zappa Nardelli,
- heavily modified by Werner Lemberg. It also supports
- anti-aliased bitmaps (using a slightly extended BDF format).
-
- * A Type42 font driver, contributed by Roberto Alameda. It is
- still experimental but seems to work relatively well.
-
- * A PFR font driver, contributed by David Turner himself. It
- doesn't support PFR hinting -- note that BitStream has at
- least two patents on this format!
-
-
- III. MISCELLANEOUS
-
- - The cache sub-system has been optimized in important ways.
- Cache hits are now significantly faster. For example, using the
- CMap cache is about twice faster than calling FT_Get_Char_Index
- on most platforms. Similarly, using an SBit cache is about five
- times faster than loading the bitmaps from a bitmap file, and
- 300 to 500 times faster than generating them from a scalable
- format.
-
- Note that you should recompile your sources if you designed a
- custom cache class for the FT2 Cache subsystem, since the
- changes performed are source, but not binary, compatible.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.1.0 and 2.0.9
-
- I. IMPORTANT BUG FIXES
-
- - The TrueType bytecode interpreter has been fixed to produce
- _exactly_ the same output as FreeType 1.x. Previous differences
- were due to slightly distinct fixed-point computation routines
- used to perform dot products and vector length measurements.
-
- It seems that native TrueType hinting is _extremely_ sensitive
- to rounding errors. The required vector computation routines
- have been optimized and placed within the `ttinterp.c' file.
-
- - Fixed the parsing of accelerator tables in the PCF font driver.
-
- - Fixed the Type1 glyph loader routine used to compute the font's
- maximum advance width.
-
-
- II. NEW FEATURES
-
- - The `configure' script used on Unix systems has been modified to
- check that GNU Make is being used to build the library.
- Otherwise, it will display a message proposing to use the
- GNUMAKE environment variable to name it.
-
- The Unix-specific file README.UNX has been modified accordingly.
-
-
- III. MISCELLANEOUS
-
- - The FreeType License in `docs/FTL.TXT' has been updated to
- include a proposed preferred disclaimer. If you are using
- FreeType in your products, you are encouraged (but not mandated)
- to use the following text in your documentation:
-
- """
- Portions of this software are copyright © 1996-2002 The
- FreeType Project (www.freetype.org). All rights reserved.
- """
-
- - The default size of the render pool has been reduced to 16kByte.
- This shouldn't result in any noticeable performance penalty,
- unless you are using the engine as-is to render very large and
- complex glyphs.
-
- - The FreeType 2 redesign has begun. More information can be
- found at this URL:
-
- https://www.freetype.org/freetype2/redesign.html
-
- The following internal changes have been performed within the
- sources of this release:
-
- - Many internal types have been renamed to increase
- consistency. The following should be true, except for
- public types:
-
- * All structure types have a name ending in `Rec' (short
- for `record').
-
- * A pointer-to-structure type has the same name as the
- structure, _without_ the `Rec' suffix.
-
- Example:
-
- typedef struct FooRec_
- {
- ...
-
- } FooRec, *Foo;
-
- - Many internal macros have been renamed to increase
- consistency. The following should be true:
-
- * All macros have a name beginning with `FT_'. This
- required a few changes like
-
- ALLOC => FT_ALLOC
- FREE => FT_FREE
- REALLOC => FT_REALLOC
-
- * All macros are completely UPPERCASE. This required a
- few changes like:
-
- READ_Short => FT_READ_SHORT
- NEXT_Short => FT_NEXT_SHORT
- GET_ULongLE => FT_GET_ULONG_LE
- MEM_Set => FT_MEM_SET
- MEM_Copy => FT_MEM_COPY
- etc.
-
- * Whenever possible, all macro names follow the
- FT_<OBJECT>_<METHOD> pattern. For example
-
- ACCESS_Frame => FT_FRAME_ENTER
- FORGET_Frame => FT_FRAME_EXIT
- EXTRACT_Frame => FT_FRAME_EXTRACT
- RELEASE_Frame => FT_FRAME_RELEASE
-
- FILE_Pos => FT_STREAM_POS
- FILE_Seek => FT_STREAM_SEEK
- FILE_Read => FT_STREAM_READ
- FILE_ReadAt => FT_STREAM_READ_AT
- READ_Fields => FT_STREAM_READ_FIELDS
-
- - Many internal functions have been renamed to follow the
- FT_<Object>_<Method> pattern. For example:
-
- FT_Seek_Stream => FT_Stream_Seek
- FT_Read_Stream_At => FT_Stream_ReadAt
- FT_Done_Stream => FT_Stream_Close
- FT_New_Stream => FT_Stream_Open
- FT_New_Memory_Stream => FT_Stream_OpenMemory
- FT_Extract_Frame => FT_Stream_ExtractFrame
-
- Note that method names do not contain `_'.
-
- - The FT_ALLOC_ARRAY and FT_REALLOC_ARRAY have been replaced
- with FT_NEW_ARRAY and FT_RENEW_ARRAY which do not take a
- type as the fourth argument. Instead, the array element
- type size is computed automatically from the type of the
- target pointer used.
-
- - A new object class, FT_CMap, has been introduced. These
- internal objects are used to model character maps. This
- eases the support of additional charmap types within the
- engine.
-
- - A new configuration file named `ftstdlib.h' has been added
- to `include/freetype/config'. It is used to define aliases
- for _every_ routine of the ISO C library that the font
- engine uses. Each aliases has a `ft_' prefix
- (e.g. `ft_strlen' is an alias for `strlen').
-
- This is used to ease the porting of FreeType 2 to exotic
- runtime environments where the ISO C Library isn't available
- (e.g. XFree86 extension modules).
-
- More details are available in the `ChangeLog' file.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.0.9 and 2.0.8
-
- I. IMPORTANT BUG FIXES
-
- - Certain fonts like `foxjump.ttf' contain broken name tables with
- invalid entries and wild offsets. This caused FreeType to crash
- when trying to load them.
-
- The SFNT `name' table loader has been fixed to be able to
- support these strange fonts.
-
- Moreover, the code in charge of processing this table has been
- changed to always favour Windows-formatted entries over other
- ones. Hence, a font that works on Windows but not on the Mac
- will load cleanly in FreeType and report accurate values for
- Family & PostScript names.
-
- - The CID font driver has been fixed. It unfortunately returned a
- Postscript Font name with a leading slash, as in
- `/MunhwaGothic-Regular'.
-
- - FreeType 2 should now compile fine on AIX 4.3.3 as a shared
- library.
-
- - A bug in the Postscript hinter has been found and fixed,
- removing un-even stem widths at small pixel sizes (like 14-17).
-
- This improves the quality of a certain number of Postscript
- fonts.
-
-
- II. NEW FEATURES
-
- - A new function named `FT_Library_Version' has been added to
- return the current library's major, minor, and patch version
- numbers. This is important since the macros FREETYPE_MAJOR,
- FREETYPE_MINOR, and FREETYPE_PATCH cannot be used when the
- library is dynamically linked by a program.
-
- - Two new APIs have been added: `FT_Get_First_Char' and
- `FT_Get_Next_Char'.
-
- Together, these can be used to iterate efficiently over the
- currently selected charmap of a given face. Read the API
- reference for more details.
-
-
- III. MISCELLANEOUS
-
- - The FreeType sources are under heavy internal re-factoring. As
- a consequence, we have created a branch named `STABLE' on the
- CVS to hold all future releases/fixes in the 2.0.x family.
-
- The HEAD branch now contains the re-factored sources and
- shouldn't be used for testing or packaging new releases. In
- case you would like to access the 2.0.9 sources from our CVS
- repository, use the tag `VER-2-0-9'.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.0.8 and 2.0.7
-
- I. IMPORTANT BUG FIXES
-
- - There was a small but nasty bug in `freetype-config.in' which
- caused the `freetype-config' script to fail on Unix.
-
- This didn't prevent the installation of the library or even its
- execution, but caused problems when trying to compile many Unix
- packages that depend on it.
-
- - Some TrueType or OpenType fonts embedded in PDF documents do not
- have a 'cmap', 'post' and 'name' as is required by the
- specification. FreeType no longer refuses to load such fonts.
-
- - Various fixes to the PCF font driver.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.0.7 and 2.0.6
-
- I. IMPORTANT BUG FIXES
-
- - Fixed two bugs in the Type 1 font driver. The first one
- resulted in a memory leak in subtle cases. The other one caused
- FreeType to crash when trying to load `.gsf' files (Ghostscript
- so-called Postscript fonts).
-
- (This made _many_ KDE applications crash on certain systems.
- FreeType _is_ becoming a critical system component on Linux :-)
-
- - Fixed a memory leak in the CFF font driver.
-
- - Fixed a memory leak in the PCF font driver.
-
- - Fixed the Visual C++ project file
- `builds/win32/visualc/freetype.dsp' since it didn't include the
- Postscript hinter component, causing errors at build time.
-
- - Fixed a small rendering bug in the anti-aliased renderer that
- only occurred when trying to draw thin (less than 1 pixel)
- strokes.
-
- - Fixed `builds/unix/freetype2.a4' which is used to generate a
- valid `freetype2.m4' for use with autoconf.
-
- - Fixed the OpenVMS Makefiles.
-
-
- II. MISCELLANEOUS
-
- - Added `configure' and `install' scripts to the top-level
- directory. A GNU-style installation is thus now easily possible
- with
-
- ./configure <options>
- make
- make install
-
-
-======================================================================
-
-CHANGES BETWEEN 2.0.6 and 2.0.5
-
- I. IMPORTANT BUG FIXES
-
- - It wasn't possible to load embedded bitmaps when the auto-hinter
- was used. This is now fixed.
-
- - The TrueType font driver didn't load some composites properly
- (the sub-glyphs were slightly shifted, and this was only
- noticeable when using monochrome rendering).
-
- - Various fixes to the auto-hinter. They merely improve the
- output of sans-serif fonts. Note that there are still problems
- with serifed fonts and composites (accented characters).
-
- - All scalable font drivers erroneously returned un-fitted glyph
- advances when hinting was requested. This created problems for
- a number of layout applications. This is a very old bug that
- got undetected mainly because most test/demo program perform
- rounding explicitly or implicitly (through the cache).
-
- - `FT_Glyph_To_Bitmap' did erroneously modify the source glyph in
- certain cases.
-
- - `glnames.py' still contained a bug that made FreeType return
- invalid names for certain glyphs.
-
- - The library crashed when loading certain Type 1 fonts like
- `sadn.pfb' (`Stalingrad Normal'), which appear to contain
- pathetic font info dictionaries.
-
- - The TrueType glyph loader is now much more paranoid and checks
- everything when loading a given glyph image. This was necessary
- to avoid problems (crashes and/or memory overwrites) with broken
- fonts that came from a really buggy automatic font converter.
-
-
- II. IMPORTANT UPDATES AND NEW FEATURES
-
- - Important updates to the Mac-specific parts of the library.
-
- - The caching sub-system has been completely re-designed, and its
- API has evolved (the old one is still supported for backward
- compatibility).
-
- The documentation for it is not yet completed, sorry. For now,
- you are encouraged to continue using the old API. However, the
- ftview demo program in the ft2demos package has already been
- updated to use the new caching functions.
-
- - A new charmap cache is provided too. See `FTC_CMapCache'. This
- is useful to perform character code -> glyph index translations
- quickly, without the need for an opened FT_Face.
-
- - A NEW POSTSCRIPT HINTER module has been added to support native
- hints in the following formats: PostScript Type 1, PostScript
- CID, and CFF/CEF.
-
- Please test! Note that the auto-hinter produces better results
- for a number of badly-hinted fonts (mostly auto-generated ones)
- though.
-
- - A memory debugger is now part of the standard FreeType sources.
- To enable it, define FT_DEBUG_MEMORY in
- <freetype/config/ftoption.h>, and recompile the library.
-
- Additionally, define the _environment_ variable FT_DEBUG_MEMORY
- and run any program using FreeType. When the library is exited,
- a summary of memory footprints and possible leaks will be
- displayed.
-
- This works transparently with _any_ program that uses FreeType.
- However, you will need a lot of memory to use this (allocated
- blocks are never released to the heap to detect double deletes
- easily).
-
-
- III. MISCELLANEOUS
-
- - We are aware of subtle differences between the output of
- FreeType versions 1 and 2 when it comes to monochrome
- TrueType-hinted glyphs. These are most probably due to small
- differences in the monochrome rasterizers and will be worked out
- in an upcoming release.
-
- - We have decided to fork the sources in a `stable' branch, and an
- `unstable' one, since FreeType is becoming a critical component
- of many Unix systems.
-
- The next bug-fix releases of the library will be named 2.0.7,
- 2.0.8, etc., while the `2.1' branch will contain a version of
- the sources where we will start major reworking of the library's
- internals, in order to produce FreeType 2.2.0 (or even 3.0) in a
- more distant future.
-
- We also hope that this scheme will allow much more frequent
- releases than in the past.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.0.5 and 2.0.4
-
- NOTE THAT 2.0.5 DOES NOT CONTAIN THE POSTSCRIPT HINTER. THIS MODULE
- WILL BE PART OF THE NEXT RELEASE (EITHER 2.0.6 or 2.1)
-
- - Fixed a bug that made certain glyphs, like `Cacute', `cacute' and
- `lslash' unavailable from Unicode charmaps of Postscript fonts.
- This prevented the correct display of Polish text, for example.
-
- - The kerning table of Type 1 fonts was loaded by FreeType, when its
- AFM file was attached to its face, but the
- FT_FACE_FLAG_HAS_KERNING bit flags was not set correctly,
- preventing FT_Get_Kerning to return meaningful values.
-
- - Improved SFNT (TrueType & OpenType) charmap support. Slightly
- better performance, as well as support for the new formats defined
- by the OpenType 1.3 specification (8, 10, and 12)
-
- - Fixed a serious typo in `src/base/ftcalc.c' which caused invalid
- computations in certain rare cases, producing ugly artefacts.
-
- - The size of the EM square is computed with a more accurate
- algorithm for Postscript fonts. The old one caused slight errors
- with embedded fonts found in PDF documents.
-
- - Fixed a bug in the cache manager that prevented normal LRU
- behaviour within the cache manager, causing unnecessary reloads
- (for FT_Face and FT_Size objects only).
-
- - Added a new function named `FT_Get_Name_Index' to retrieve the
- glyph index of a given glyph name, when found in a face.
-
- - Added a new function named `FT_Get_Postscript_Name' to retrieve
- the `unique' Postscript font name of a given face.
-
- - Added a new public header size named FT_SIZES_H (or
- <freetype/ftsizes.h>) providing new FT_Size-management functions:
- FT_New_Size, FT_Activate_Size, FT_Done_Size.
-
- - Fixed a reallocation bug that generated a dangling pointer (and
- possibly memory leaks) with Postscript fonts (in
- src/psaux/psobjs.c).
-
- - Many fixes for 16-bit correctness.
-
- - Removed many pedantic compiler warnings from the sources.
-
- - Added an Amiga build directory in `builds/amiga'.
-
-
-======================================================================
-
-CHANGES BETWEEN 2.0.4 and 2.0.3
-
- - Fixed a rather annoying bug that was introduced in 2.0.3. Namely,
- the font transformation set through FT_Set_Transform was applied
- twice to auto-hinted glyphs, resulting in incorrectly rotated text
- output.
-
- - Fixed _many_ compiler warnings. FT2 should now compile cleanly
- with Visual C++'s most pedantic warning level (/W4). It already
- compiled fine with GCC and a few other compilers.
-
- - Fixed a bug that prevented the linear advance width of composite
- TrueType glyphs to be correctly returned.
-
- - Fixed the Visual C++ project files located in
- `builds/win32/visualc' (previous versions used older names of the
- library).
-
- - Many 32-bit constants have an `L' appended to their value, in
- order to improve the 16-bitness of the code. Someone is actually
- trying to use FT2 on an Atari ST machine!
-
- - Updated the `builds/detect.mk' file in order to automatically
- build FT2 on AIX systems. AIX uses `/usr/sbin/init' instead of
- `/sbin/init' and wasn't previously detected as a Unix platform by
- the FreeType build system.
-
- - Updated the Unix-specific portions of the build system (new
- libtool version, etc.).
-
- - The SFNT kerning loader now ensures that the table is sorted
- (since some problem fonts do not meet this requirement).
-
-
-=======================================================================
-
-CHANGES BETWEEN 2.0.3 and 2.0.2
-
- I. CHANGES TO THE MODULES / FONT DRIVERS
-
- - THE AUTO-HINTER HAS BEEN SLIGHTLY IMPROVED, in order to fix
- several annoying artefacts, mainly:
-
- - Blue zone alignment of horizontal stems wasn't performed
- correctly, resulting in artefacts like the `d' being placed
- one pixel below the `b' in some fonts like Time New Roman.
-
- - Overshoot thresholding wasn't performed correctly, creating
- unpleasant artefacts at large character pixel sizes.
-
- - Composite glyph loading has been simplified. This gets rid
- of various artefacts where the components of a composite
- glyphs were not correctly spaced.
-
- These are the last changes to the current auto-hinting module.
- A new hinting sub-system is currently in the work in order to
- support native hints in Type 1 / CFF / OpenType fonts, as well
- as globally improve rendering.
-
- - The PCF driver has been fixed. It reported invalid glyph
- dimensions for the fonts available on Solaris.
-
- - The Type 1, CID and CFF drivers have been modified to fix the
- computation of the EM size.
-
- - The Type 1 driver has been fixed to avoid a dangerous bug that
- crashed the library with non-conforming fonts (i.e. ones that do
- not place the .notdef glyph at position 0).
-
- - The TrueType driver had a rather subtle bug (dangling pointer
- when loading composite glyphs) that could crash the library in
- rare occasions!
-
-
- II. HIGH-LEVEL API CHANGES
-
- - The error code enumeration values have been changed. An error
- value is decomposed in a generic error code, and a module
- number. see <freetype/fterrors.h> for details.
-
- - A new public header file has been introduced, named
- FT_TRIGONOMETRY_H (include/freetype/fttrigon.h), providing
- trigonometric functions to compute sines, cosines, arctangents,
- etc. with 16.16 fixed precision. The implementation is based on
- the CORDIC algorithm and is very fast while being sufficiently
- accurate.
-
-
- III. INTERNALS
-
- - Added BeOS-specific files in the old build sub-system. Note
- that no changes were required to compile the library with Jam.
-
- - The configuration is now capable of automatically detecting
- 64-bit integers on a set of predefined compilers (GCC, Visual
- C++, Borland C++) and will use them by default. This provides a
- small performance boost.
-
- - A small memory leak that happened when opening 0-sized files
- (duh!) have been fixed.
-
- - Fixed bezier stack depth bug in the routines provided by the
- FT_BBOX_H header file. Also fixed similar bugs in the
- rasterizers.
-
- - The outline bounding box code has been rewritten to use direct
- computations, instead of bezier sub-division, to compute the
- exact bounding box of glyphs. This is slightly slower but more
- accurate.
-
- - The build system has been improved and fixed, mainly to support
- `make' on Windows 2000 correctly, avoid problems with `make
- distclean' on non Unix systems, etc.
-
- - Hexadecimal constants have been suffixed with `U' to avoid
- problems with certain compilers on 64-bit platforms.
-
- - A new directory named `src/tools' has been created. It contains
- Python scripts and simple unit test programs used to develop the
- library.
-
- - The DocMaker tool has been moved from `docs' to `src/tools' and
- has been updated with the following:
-
- - Now accepts the `--title=XXXX' or `-t XXXX' option from the
- command line to set the project's name in the generated API
- reference.
-
- - Now accepts the `--output=DIR' or `-o DIR' option from the
- command line to set the output directory for all generated
- HTML files.
-
- - Now accepts the `--prefix=XXXX' or `-p XXX' option from the
- command line to set the file prefix to use for all
- generated HTML files.
-
- - Now generates the current time/data on each generated page
- in order to distinguish between versions.
-
- DocMaker can be used with other projects now, not only FT2
- (e.g. MLib, FTLayout, etc.).
-
-
-======================================================================
-
-CHANGES BETWEEN 2.0.2 and 2.0.1
-
- I. CHANGES TO THE MODULES / FONT DRIVERS
-
- - THE TRUETYPE BYTECODE INTERPRETER IS NOW TURNED OFF, in order to
- avoid legal problems with the Apple patents. It seems that we
- mistakenly turned this option on in previous releases of the
- build.
-
- Note that if you want to use the bytecode interpreter in order
- to get high-quality TrueType rendering, you will need to toggle
- by hand the definition of the
- TT_CONFIG_OPTION_BYTECODE_INTERPRETER macro in the file
- `include/freetype/config/ftoption.h'.
-
- - The CFF driver has been improved by Tom Kacvinsky and Sander van
- der Wal:
-
- * Support for `seac' emulation.
- * Support for `dotsection'.
- * Support for retrieving glyph names through
- `FT_Get_Glyph_Name'.
-
- The first two items are necessary to correctly a large number of
- Type 1 fonts converted to the CFF formats by Adobe Acrobat.
-
- - The Type 1 driver was also improved by Tom & others:
-
- * Better EM size computation.
- * Better support for synthetic (transformed) fonts.
- * The Type 1 driver returns the charstrings corresponding to
- each glyph in the `glyph->control_data' field after a call to
- `FT_Load_Glyph' (thanks Ha Shao).
-
- - Various other bugfixes, including the following:
-
- * Fixed a nasty memory leak in the Type 1 driver.
- * The autohinter and the pcf driver used static writable data
- when they shouldn't.
- * Many casts were added to make the code more 64-bits safe. It
- also now compiles on Windows XP 64-bits without warnings.
- * Some incorrect writable statics were removed in the `autohint'
- and `pcf' drivers. FreeType 2 now compiles on Epoc again.
-
-
- II. CHANGES TO THE HIGH-LEVEL API
-
- - The library header files inclusion scheme has been changed. The
- old scheme looked like:
-
- #include <freetype/freetype.h>
- #include <freetype/ftglyph.h>
- #include <freetype/ftcache.h>
- #include <freetype/cache/ftimage.h>
-
- Now you should use:
-
- #include <ft2build.h>
- #include FT_FREETYPE_H
- #include FT_GLYPH_H
- #include FT_CACHE_H
- #include FT_CACHE_IMAGE_H
-
- NOTE THAT THE OLD INCLUSION SCHEME WILL STILL WORK WITH THIS
- RELEASE. HOWEVER, WE DO NOT GUARANTEE THAT THIS WILL STILL BE
- TRUE IN THE NEXT ONE (A.K.A. FREETYPE 2.1).
-
- The file <ft2build.h> is used to define the header filename
- macros. The complete and commented list of macros is available
- in the API reference under the section name `Header File Macros'
- in Chapter I.
-
- For more information, see section I of the following document:
-
- https://www.freetype.org/freetype2/docs/tutorial/step1.html
-
- - Many, many comments have been added to the public source file in
- order to automatically generate the API Reference through the
- `docmaker.py' Python script.
-
- The latter has been updated to support the grouping of sections
- in chapters and better index sort. See:
-
- https://www.freetype.org/freetype2/docs/reference/ft2-toc.html
-
-
- III. CHANGES TO THE BUILD PROCESS
-
- - If you are not building FreeType 2 with its own build system
- (but with your own Makefiles or project files), you will need to
- be aware that the build process has changed a little bit.
-
- You don't need to put the `src' directory in the include path
- when compiling any FT2 component. Instead, simply put the
- component's directory in the current include path.
-
- So, if you were doing something like:
-
- cc -c -Iinclude -Isrc src/base/ftbase.c
-
- change the line to:
-
- cc -c -Iinclude -Isrc/base src/base/ftbase.c
-
- If you were doing something like:
-
- cd src/base
- cc -c -I../../include -I.. ftbase.c
-
- change it to:
-
- cd src/base
- cc -c -I../../include ftbase.c
-
-
-======================================================================
-
-CHANGES BETWEEN 2.0.1 and 2.0
-
- 2.0.1 introduces a few changes:
-
- - Fixed many bugs related to the support of CFF / OpenType fonts.
- These formats are now much better supported though there is
- still work planned to deal with charset tables and PDF-embedded
- CFF files that use the old `seac' command.
-
- - The library could not be compiled in debug mode with a very
- small number of C compilers whose pre-processors didn't
- implement the `##' directive correctly (i.e. per se the ANSI C
- specification!) An elegant fix was found.
-
- - Added support for the free Borland command-line C++ Builder
- compiler. Use `make setup bcc32'. Also fixed a few source
- lines that generated new warnings with BCC32.
-
- - Fixed a bug in FT_Outline_Get_BBox when computing the extrema of
- a conic Bezier arc.
-
- - Updated the INSTALL file to add IDE compilation.
-
- - Other minor bug fixes, from invalid Type 1 style flags to
- correct support of synthetic (obliqued) fonts in the
- auto-hinter, better support for embedded bitmaps in a SFNT font.
-
- - Fixed some problems with `freetype-config'.
-
- Finally, the `standard' scheme for including FreeType headers is now
- gradually changing, but this will be explained in a later release
- (probably 2.0.2).
-
- And very special thanks to Tom Kacvinsky and YAMANO-UCHI Hidetoshi
- for their contributions!
-
-
-======================================================================
-
-CHANGES BETWEEN beta8 and 2.0
-
- - Changed the default installation path for public headers from
- `include/freetype' to `include/freetype2'.
-
- Also added a new `freetype-config' that is automatically generated
- and installed on Unix and Cygwin systems. The script itself is
- used to retrieve the current install path, C compilation flags as
- well as linker flags.
-
- - Fixed several small bugs:
-
- * Incorrect max advance width for fixed-pitch Type 1 fonts.
- * Incorrect glyph names for certain TrueType fonts.
- * The glyph advance was not copied when FT_Glyph_To_Bitmap was
- called.
- * The linearHoriAdvance and linearVertAdvance fields were not
- correctly returned for glyphs processed by the auto-hinter.
- * `type1z' renamed back to `type1'; the old `type1' module has
- been removed.
-
- - Revamped the build system to make it a lot more generic. This
- will allow us to re-use nearly un-modified in lots of other
- projects (including FreeType Layout).
-
- - Changed `cid' to use `psaux' too.
-
- - Added the cache sub-system. See <freetype/ftcache.h> as well as
- the sources in `src/cache'. Note that it compiles but is still
- untested for now.
-
- - Updated `docs/docmaker.py', a draft API reference is available at
- https://web.archive.org/web/20001215173400/http://www.freetype.org:80/ft2api.html.
-
- - Changed `type1' to use `psaux'.
-
- - Created a new module named `psaux' to hold the Type 1 & Type 2
- parsing routines. It should be used by `type1', `cid', and `cff'
- in the future.
-
- - Fixed an important bug in `FT_Glyph_Get_CBox'.
-
- - Fixed some compiler warnings that happened since the TrueType
- bytecode decoder was deactivated by default.
-
- - Fixed two memory leaks:
-
- * The memory manager (16 bytes) isn't released in
- FT_Done_FreeType!
- * Using custom input streams, the copy of the original stream was
- never released.
-
- - Fixed the auto-hinter by performing automatic computation of the
- `filling direction' of each glyph. This is done through a simple
- and fast approximation, and seems to work (problems spotted by
- Werner though). The Arphic fonts are a lot nicer though there are
- still a lot of things to do to handle Asian fonts correctly.
-
-
-======================================================================
-
-BETA-8 (RELEASE CANDIDATE) CHANGES
-
- - Deactivated the TrueType bytecode interpreter by default.
-
- - Deactivated the `src/type1' font driver. Now `src/type1z' is used
- by default.
-
- - Updates to the build system. We now compile the library correctly
- under Unix system through `configure' which is automatically
- called on the first `make' invocation.
-
- - Added the auto-hinting module! Fixing some bugs here and there.
-
- - Found some bugs in the composite loader (seac) of the Type1-based
- font drivers.
-
- - Renamed the directory `freetype2/config' to `freetype2/builds' and
- updated all relevant files.
-
- - Found a memory leak in the `type1' driver.
-
- - Incorporated Tom's patches to support flex operators correctly in
- OpenType/CFF fonts. Now all I need is to support pure CFF and CEF
- fonts to be done with this driver :-)
-
- - Added the Windows FNT/FON driver in `src/winfonts'. For now, it
- always `simulates' a Unicode charmap, so it shouldn't be
- considered completed right now.
-
- It is there to be more a proof of concept than anything else
- anyway. The driver is a single C source file, that compiles to 3
- Kb of code.
-
- I'm still working on the PCF/BDF drivers, but I'm too lazy to
- finish them now.
-
- - CHANGES TO THE HIGH-LEVEL API
-
- * FT_Get_Kerning has a new parameter that allows you to select the
- coordinates of the kerning vector (font units, scaled, scaled +
- grid-fitted).
- * The outline functions are now in <freetype/ftoutln.h> and not
- part of <freetype/freetype.h> anymore.
- * <freetype/ftmodule.h> now contains declarations for
- FT_New_Library, FT_Done_Library, FT_Add_Default_Modules.
- * The so-called convenience functions have moved from `ftoutln.c'
- to `ftglyph.c', and are thus available with this optional
- component of the library. They are declared in
- <freetype/ftglyph.h> now.
- * Anti-aliased rendering is now the default for FT_Render_Glyph
- (i.e. corresponds to render_mode == 0 == ft_render_mode_normal).
- To generate a monochrome bitmap, use ft_render_mode_mono, or the
- FT_LOAD_MONOCHROME flag in FT_Load_Glyph/FT_Load_Char.
- FT_LOAD_ANTI_ALIAS is still defined, but values to 0.
- * <freetype/freetype.h> now include <freetype/config/ftconfig.h>,
- solving a few headaches :-)
- * The type FT_GlyphSlotRec has now a `library' field.
-
- - CHANGES TO THE `ftglyph.h' API
-
- This API has been severely modified in order to make it simpler,
- clearer, and more efficient. It certainly now looks like a real
- `glyph factory' object, and allows client applications to manage
- (i.e. transform, bbox and render) glyph images without ever
- knowing their original format.
-
- - Added support for CID-keyed fonts to the CFF driver. Maybe
- support for pure CFF + CEF fonts should come in?
-
- - Cleaned up source code in order to avoid two functions with the
- same name. Also changed the names of the files in `type1z' from
- `t1XXXX' to `z1XXXX' in order to avoid any conflicts.
-
- `make multi' now works well :-)
-
- Also removed the use of `cidafm' for now, even if the source files
- are still there. This functionality will certainly go into a
- specific module.
-
- - ADDED SUPPORT FOR THE AUTO-HINTER
-
- It works :-) I have a demo program which simply is a copy of
- `ftview' that does a `FT_Add_Module(library,
- &autohinter_module_class)' after library initialization, and Type
- 1 & OpenType/CFF fonts are now hinted.
-
- CID fonts are not hinted, as they include no charmap and the
- auto-hinter doesn't include `generic' global metrics computations
- yet.
-
- Now, I need to release this thing to the FreeType 2 source.
-
- - CHANGES TO THE RENDERER MODULES
-
- The monochrome and smooth renderers are now in two distinct
- directories, namely `src/raster1' and `src/smooth'. Note that the
- old `src/renderer' is now gone.
-
- I ditched the 5-gray-levels renderers. Basically, it involved a
- simple #define toggle in 'src/raster1/ftraster.c'.
-
- FT_Render_Glyph, FT_Outline_Render & FT_Outline_Get_Bitmap now
- select the best renderer available, depending on render mode. If
- the current renderer for a given glyph image format isn't capable
- of supporting the render mode, another one will be found in the
- library's list. This means that client applications do not need
- to switch or set the renderers themselves (as in the latest
- change), they'll get what they want automatically. At last.
-
- Changed the demo programs accordingly.
-
- - MAJOR INTERNAL REDESIGN:
-
- A lot of internal modifications have been performed lately on the
- source in order to provide the following enhancements:
-
- * More generic module support:
-
- The FT_Module type is now defined to represent a handle to a
- given module. The file <freetype/ftmodule.h> contains the
- FT_Module_Class definition, as well as the module-loading public
- API.
-
- The FT_Driver type is still defined, and still represents a
- pointer to a font driver. Note that FT_Add_Driver is replaced
- by FT_Add_Module, FT_Get_Driver by FT_Get_Module, etc.
-
- * Support for generic glyph image types:
-
- The FT_Renderer type is a pointer to a module used to perform
- various operations on glyph image.
-
- Each renderer is capable of handling images in a single format
- (e.g. ft_glyph_format_outline). Its functions are used to:
-
- - transform an glyph image
- - render a glyph image into a bitmap
- - return the control box (dimensions) of a given glyph image
-
- The scan converters `ftraster.c' and `ftgrays.c' have been moved
- to the new directory `src/renderer', and are used to provide two
- default renderer modules.
-
- One corresponds to the `standard' scan-converter, the other to
- the `smooth' one.
-
- he current renderer can be set through the new function
- FT_Set_Renderer.
-
- The old raster-related function FT_Set_Raster, FT_Get_Raster and
- FT_Set_Raster_Mode have now disappeared, in favor of the new:
-
- FT_Get_Renderer
- FT_Set_Renderer
-
- See the file <freetype/ftrender.h> for more details.
-
- These changes were necessary to properly support different
- scalable formats in the future, like bi-color glyphs, etc.
-
- * Glyph loader object:
-
- A new internal object, called a 'glyph loader' has been
- introduced in the base layer. It is used by all scalable format
- font drivers to load glyphs and composites.
-
- This object has been created to reduce the code size of each
- driver, as each one of them basically re-implemented its
- functionality.
-
- See <freetype/internal/ftobjs.h> and the FT_GlyphLoader type for
- more information.
-
- * FT_GlyphSlot has new fields:
-
- In order to support extended features (see below), the
- FT_GlyphSlot structure has a few new fields:
-
- linearHoriAdvance:
-
- This field gives the linearly scaled (i.e. scaled but
- unhinted) advance width for the glyph, expressed as a 16.16
- fixed pixel value. This is useful to perform WYSIWYG text.
-
- linearVertAdvance:
- This field gives the linearly scaled advance height for the
- glyph (relevant in vertical glyph layouts only). This is
- useful to perform WYSIWYG text.
-
- Note that the two above field replace the removed `metrics2'
- field in the glyph slot.
-
- advance:
- This field is a vector that gives the transformed advance for
- the glyph. By default, it corresponds to the advance width,
- unless FT_LOAD_VERTICAL_LAYOUT was specified when calling
- FT_Load_Glyph or FT_Load_Char.
-
- bitmap_left:
- This field gives the distance in integer pixels from the
- current pen position to the left-most pixel of a glyph image
- IF IT IS A BITMAP. It is only valid when the `format' field
- is set to `ft_glyph_format_bitmap', for example, after calling
- the new function FT_Render_Glyph.
-
- bitmap_top:
- This field gives the distance in integer pixels from the
- current pen position (located on the baseline) to the top-most
- pixel of the glyph image IF IT IS A BITMAP. Positive values
- correspond to upwards Y.
-
- loader:
- This is a new private field for the glyph slot. Client
- applications should not touch it.
-
-
- * Support for transforms and direct rendering in FT_Load_Glyph:
-
- Most of the functionality found in <freetype/ftglyph.h> has been
- moved to the core library. Hence, the following:
-
- - A transform can be specified for a face through
- FT_Set_Transform. this transform is applied by FT_Load_Glyph
- to scalable glyph images (i.e. NOT TO BITMAPS) before the
- function returns, unless the bit flag FT_LOAD_IGNORE_TRANSFORM
- was set in the load flags.
-
- - Once a glyph image has been loaded, it can be directly
- converted to a bitmap by using the new FT_Render_Glyph
- function. Note that this function takes the glyph image from
- the glyph slot, and converts it to a bitmap whose properties
- are returned in `face.glyph.bitmap', `face.glyph.bitmap_left'
- and `face.glyph.bitmap_top'. The original native image might
- be lost after the conversion.
-
- - When using the new bit flag FT_LOAD_RENDER, the FT_Load_Glyph
- and FT_Load_Char functions will call FT_Render_Glyph
- automatically when needed.
-
- - Reformatted all modules source code in order to get rid of the
- basic data types redefinitions (i.e. `TT_Int' instead of `FT_Int',
- `T1_Fixed' instead of `FT_Fixed'). Hence the format-specific
- prefixes like `TT_', `T1_', `T2_' and `CID_' are only used for
- relevant structures.
-
-
-======================================================================
-
-OLD CHANGES FOR BETA 7
-
- - bug-fixed the OpenType/CFF parser. It now loads and displays my
- two fonts nicely, but I'm pretty certain that more testing is
- needed :-)
-
- - fixed the crummy Type 1 hinter, it now handles accented characters
- correctly (well, the accent is not always well placed, but that's
- another problem..)
-
- - added the CID-keyed Type 1 driver in `src/cid'. Works pretty well
- for only 13 Kb of code ;-) Doesn't read AFM files though, nor the
- really useful CMAP files..
-
- - fixed two bugs in the smooth renderer (src/base/ftgrays.c).
- Thanks to Boris Letocha for spotting them and providing a fix.
-
- - fixed potential `divide by zero' bugs in ftcalc.c.
-
- - added source code for the OpenType/CFF driver (still incomplete
- though..)
-
- - modified the SFNT driver slightly to perform more robust header
- checks in TT_Load_SFNT_Header. This prevents certain font files
- (e.g. some Type 1 Multiple Masters) from being incorrectly
- `recognized' as TrueType font files..
-
- - moved a lot of stuff from the TrueType driver to the SFNT module,
- this allows greater code re-use between font drivers
- (e.g. TrueType, OpenType, Compact-TrueType, etc..)
-
- - added a tiny segment cache to the SFNT Charmap 4 decoder, in order
- to minimally speed it up..
-
- - added support for Multiple Master fonts in `type1z'. There is
- also a new file named <freetype/ftmm.h> which defines functions to
- manage them from client applications.
-
- The new file `src/base/ftmm.c' is also optional to the engine..
-
- - various formatting changes (e.g. EXPORT_DEF -> FT_EXPORT_DEF) +
- small bug fixes in FT_Load_Glyph, the `type1' driver, etc..
-
- - a minor fix to the Type 1 driver to let them apply the font matrix
- correctly (used for many oblique fonts..)
-
- - some fixes for 64-bit systems (mainly changing some FT_TRACE calls
- to use %p instead of %lx). Thanks to Karl Robillard.
-
- - fixed some bugs in the sbit loader (src/base/sfnt/ttsbit.c) +
- added a new flag, FT_LOAD_CROP_BITMAP to query that bitmaps be
- cropped when loaded from a file (maybe I should move the bitmap
- cropper to the base layer ??).
-
- - changed the default number of gray levels of the smooth renderer
- to 256 (instead of the previous 128). Of course, the human eye
- can't see any difference ;-)
-
- - removed TT_MAX_SUBGLYPHS, there is no static limit on the number
- of subglyphs in a TrueType font now..
-
-
-======================================================================
-
-OLD CHANGES 16 May 2000
-
- - tagged `BETA-6' in the CVS tree. This one is a serious release
- candidate even though it doesn't incorporate the auto-hinter yet..
-
- - various obsolete files were removed, and copyright header updated
-
- - finally updated the standard raster to fix the monochrome
- rendering bug + re-enable support for 5-gray levels anti-aliasing
- (suck, suck..)
-
- - created new header files, and modified sources accordingly:
-
- <freetype/fttypes.h>
- - simple FreeType types, without the API
- <freetype/internal/ftmemory.h>
- - definition of memory-management macros
-
- - added the `DSIG' (OpenType Digital Signature) tag to
- <freetype/tttags.h>
-
- - light update/cleaning of the build system + changes to the sources
- in order to get rid of _all_ compiler warnings with three
- compilers, i.e:
-
- gcc with `-ansi -pedantic -Wall -W', Visual C++ with `/W3 /WX' and
- LCC
-
- IMPORTANT NOTE FOR WIN32-LCC USERS:
- |
- | It seems the C pre-processor that comes with LCC is broken, it
- | doesn't recognize the ANSI standard directives # and ##
- | correctly when one of the argument is a macro. Also,
- | something like:
- |
- | #define F(x) print##x
- |
- | F(("hello"))
- |
- | will get incorrectly translated to:
- |
- | print "hello")
- |
- | by its pre-processor. For this reason, you simply cannot build
- | FreeType 2 in debug mode with this compiler..
-
- - yet another massive grunt work. I've changed the definition of
- the EXPORT_DEF, EXPORT_FUNC, BASE_DEF & BASE_FUNC macros. These
- now take an argument, which is the function's return value type.
-
- This is necessary to compile FreeType as a DLL on Windows and
- OS/2. Depending on the compiler used, a compiler-specific keyword
- like __export or __system must be placed before (VisualC++) or
- after (BorlandC++) the type..
-
- Of course, this needed a lot of changes throughout the source code
- to make it compile again... All cleaned up now, apparently..
-
- Note also that there is a new EXPORT_VAR macro defined to allow
- the _declaration_ of an exportable public (constant)
- variable. This is the case of the raster interfaces (see
- ftraster.h and ftgrays.h), as well as each module's interface (see
- sfdriver.h, psdriver.h, etc..)
-
- - new feature: it is now possible to pass extra parameters to font
- drivers when creating a new face object. For now,
- this capability is unused. It could however prove to
- be useful in a near future..
-
- the FT_Open_Args structure was changes, as well as the internal
- driver interface (the specific `init_face' module function has
- now a different signature).
-
- - updated the tutorial (not finished though).
-
- - updated the top-level BUILD document
-
- - fixed a potential memory leak that could occur when loading
- embedded bitmaps.
-
- - added the declaration of FT_New_Memory_Face in
- <freetype/freetype.h>, as it was missing from the public header
- (the implementation was already in `ftobjs.c').
-
- - the file <freetype/fterrors.h> has been seriously updated in order
- to allow the automatic generation of error message tables. See
- the comments within it for more information.
-
- - major directory hierarchy re-organisation. This was done for two
- things:
-
- * first, to ease the `manual' compilation of the library by
- requiring at lot less include paths :-)
-
- * second, to allow external programs to effectively access
- internal data fields. For example, this can be extremely
- useful if someone wants to write a font producer or a font
- manager on top of FreeType.
-
- Basically, you should now use the 'freetype/' prefix for header
- inclusion, as in:
-
- #include <freetype/freetype.h>
- #include <freetype/ftglyph.h>
-
- Some new include sub-directories are available:
-
- a. the `freetype/config' directory, contains two files used to
- configure the build of the library. Client applications
- should not need to look at these normally, but they can if
- they want.
-
- #include <freetype/config/ftoption.h>
- #include <freetype/config/ftconfig.h>
-
- b. the `freetype/internal' directory, contains header files that
- describes library internals. These are the header files that
- were previously found in the `src/base' and `src/shared'
- directories.
-
-
- As usual, the build system and the demos have been updated to
- reflect the change..
-
- Here's a layout of the new directory hierarchy:
-
- TOP_DIR
- include/
- freetype/
- freetype.h
- ...
- config/
- ftoption.h
- ftconfig.h
- ftmodule.h
-
- internal/
- ftobjs.h
- ftstream.h
- ftcalc.h
- ...
-
- src/
- base/
- ...
-
- sfnt/
- psnames/
- truetype/
- type1/
- type1z/
-
-
- Compiling a module is now much easier, for example, the following
- should work when in the TOP_DIR directory on an ANSI build:
-
- gcc -c -I./include -I./src/base src/base/ftbase.c
- gcc -c -I./include -I./src/sfnt src/sfnt/sfnt.c
- etc..
-
- (of course, using -Iconfig/<system> if you provide system-specific
- configuration files).
-
- - updated the structure of FT_Outline_Funcs in order to allow direct
- coordinate scaling within the outline decomposition routine (this
- is important for virtual `on' points with TrueType outlines) +
- updates to the rasters to support this..
-
- - updated the OS/2 table loading code in `src/sfnt/ttload.c' in
- order to support version 2 of the table (see OpenType 1.2 spec)
-
- - created `include/tttables.h' and `include/t1tables.h' to allow
- client applications to access some of the SFNT and T1 tables of a
- face with a procedural interface (see `FT_Get_Sfnt_Table') +
- updates to internal source files to reflect the change..
-
- - some cleanups in the source code to get rid of warnings when
- compiling with the `-Wall -W -ansi -pedantic' options in gcc.
-
- - debugged and moved the smooth renderer to `src/base/ftgrays.c' and
- its header to `include/ftgrays.h'
-
- - updated TT_MAX_SUBGLYPHS to 96 as some CJK fonts have composites
- with up to 80 sub-glyphs !! Thanks to Werner
-
-
-======================================================================
-
-OLD CHANGES - 14-apr-2000
-
- - fixed a bug in the TrueType glyph loader that prevented the
- correct loading of some CJK glyphs in mingli.ttf
-
- - improved the standard Type 1 hinter in `src/type1'
-
- - fixed two bugs in the experimental Type 1 driver in `src/type1z'
- to handle the new XFree86 4.0 fonts (and a few other ones..)
-
- - the smooth renderer is now complete and supports sub-banding to
- render large glyphs at high speed. However, it is still located
- in `demos/src/ftgrays.c' and should move to the library itself in
- the next beta. NOTE: The smooth renderer doesn't compile in
- stand-alone mode anymore, but this should be fixed RSN..
-
- - introduced convenience functions to more easily deal with glyph
- images, see `include/ftglyph.h' for more details, as well as the
- new demo program named `demos/src/ftstring.c' that demonstrates
- its use
-
- - implemented FT_LOAD_NO_RECURSE in both the TrueType and Type 1
- drivers (this is required by the auto-hinter to improve its
- results).
-
- - changed the raster interface, in order to allow client
- applications to provide their own span-drawing callbacks.
- However, only the smooth renderer supports this. See
- `FT_Raster_Params' in the file `include/ftimage.h'.
-
- - fixed a small bug in FT_MulFix that caused incorrect transform
- computation!
-
- - Note: The tutorial is out-of-date.
-
-
-======================================================================
-
-OLD CHANGES - 12-mar-2000
-
- - changed the layout of configuration files : now, all ANSI
- configuration files are located in
- `freetype2/config'. System-specific over-rides can be placed in
- `freetype2/config/<system>'.
-
- - moved all configuration macros to `config/ftoption.h'
-
- - improvements in the Type 1 driver with AFM support
-
- - changed the fields in the FT_Outline structure : the old `flags'
- array is re-named `tags', while all ancient flags are encoded into
- a single unsigned int named `flags'.
-
- - introduced new flags in FT_Outline.flags (see
- ft_outline_.... enums in `ftimage.h').
-
- - changed outline functions to `FT_Outline_<action>' syntax
-
- - added a smooth anti-alias renderer to the demonstration programs
-
- - added Mac graphics driver (thanks Just)
-
- - FT_Open_Face changed in order to received a pointer to a
- FT_Open_Args descriptor..
-
- - various cleanups, a few more API functions implemented (see
- FT_Attach_File)
-
- - updated some docs
-
-
-======================================================================
-
-OLD CHANGES - 22-feb-2000
-
- - introduced the `psnames' module. It is used to:
-
- o convert a Postscript glyph name into the equivalent Unicode
- character code (used by the Type 1 driver(s) to synthesize on
- the fly a Unicode charmap).
-
- o provide an interface to retrieve the Postscript names of the
- Macintosh, Adobe Standard & Adobe Expert character codes.
- (the Macintosh names are used by the SFNT-module postscript
- names support routines, while the other two tables are used by
- the Type 1 driver(s)).
-
- - introduced the `type1z' alternate Type 1 driver. This is a (still
- experimental) driver for the Type 1 format that will ultimately
- replace the one in `src/type1'. It uses pattern matching to load
- data from the font, instead of a finite state analyzer. It works
- much better than the `old' driver with `broken' fonts. It is also
- much smaller (under 15 Kb).
-
- - the Type 1 drivers (both in `src/type1' and `src/type1z') are
- nearly complete. They both provide automatic Unicode charmap
- synthesis through the `psnames' module. No re-encoding vector is
- needed. (note that they still leak memory due to some code
- missing, and I'm getting lazy).
-
- Trivial AFM support has been added to read kerning information but
- wasn't exactly tested as it should ;-)
-
- - The TrueType glyph loader has been seriously rewritten (see the
- file `src/truetype/ttgload.c'. It is now much, much simpler as
- well as easier to read, maintain and understand :-) Preliminary
- versions introduced a memory leak that has been reported by Jack
- Davis, and is now fixed..
-
- - introduced the new `ft_glyph_format_plotter', used to represent
- stroked outlines like Windows `Vector' fonts, and certain Type 1
- fonts like `Hershey'. The corresponding raster will be written
- soon.
-
- - FT_New_Memory_Face is gone. Likewise, FT_Open_Face has a new
- interface that uses a structure to describe the input stream, the
- driver (if required), etc..
-
-
-TODO
-
- - Write FT_Get_Glyph_Bitmap and FT_Load_Glyph_Bitmap
-
- - Add a function like FT_Load_Character(face, char_code, load_flags)
- that would really embed a call to FT_Get_Char_Index then
- FT_Load_Glyph to ease developer's work.
-
- - Update the tutorial!
-
- - consider adding support for Multiple Master fonts in the Type 1
- drivers.
-
- - Test the AFM routines of the Type 1 drivers to check that kerning
- information is returned correctly.
-
- - write a decent auto-gridding component !! We need this to release
- FreeType 2.0 gold !
-
-
-less urgent needs:
-
- - add a CFF/Type2 driver
- - add a BDF driver
- - add a FNT/PCF/HBF driver
- - add a Speedo driver from the X11 sources
-
-
-======================================================================
-
-OLDER CHANGES - 27-jan-2000
-
- - updated the `sfnt' module interface to allow several SFNT-based
- drivers to co-exist peacefully
-
- - updated the `T1_Face' type to better separate Postscript font
- content from the rest of the FT_Face structure. Might be used
- later by the CFF/Type2 driver..
-
- - added an experimental replacement Type 1 driver featuring advanced
- (and speedy) pattern matching to retrieve the data from postscript
- fonts.
-
- - very minor changes in the implementation of FT_Set_Char_Size and
- FT_Set_Pixel_Sizes (they now implement default to lighten the font
- driver's code).
-
-
-======================================================================
-
-OLD MESSAGE
-
-This file summarizes the changes that occurred since the last `beta'
-of FreeType 2. Because the list is important, it has been divided into
-separate sections:
-
-Table Of Contents:
-
- I High-Level Interface (easier !)
- II Directory Structure
- III Glyph Image Formats
- IV Build System
- V Portability
- VI Font Drivers
-
-
-----------------------------------------------------------------------
-
-High-Level Interface:
-
- The high-level API has been considerably simplified. Here is how:
-
- - resource objects have disappeared. this means that face objects
- can now be created with a single function call (see FT_New_Face
- and FT_Open_Face)
-
- - when calling either FT_New_Face & FT_Open_Face, a size object
- and a glyph slot object are automatically created for the face,
- and can be accessed through `face->glyph' and `face->size' if
- one really needs to. In most cases, there's no need to call
- FT_New_Size or FT_New_Glyph.
-
- - similarly, FT_Load_Glyph now only takes a `face' argument
- (instead of a glyph slot and a size). Also, its `result'
- parameter is gone, as the glyph image type is returned in the
- field `face->glyph.format'
-
- - the list of available charmaps is directly accessible through
- `face->charmaps', counting `face->num_charmaps' elements. Each
- charmap has an 'encoding' field which specifies which known
- encoding it deals with. Valid values are, for example:
-
- ft_encoding_unicode (for ASCII, Latin-1 and Unicode)
- ft_encoding_apple_roman
- ft_encoding_sjis
- ft_encoding_adobe_standard
- ft_encoding_adobe_expert
-
- other values may be added in the future. Each charmap still
- holds its `platform_id' and `encoding_id' values in case the
- encoding is too exotic for the current library
-
-
-----------------------------------------------------------------------
-
-Directory Structure:
-
- Should seem obvious to most of you:
-
- freetype/
- config/ -- configuration sub-makefiles
- ansi/
- unix/ -- platform-specific configuration files
- win32/
- os2/
- msdos/
-
- include/ -- public header files, those to be included
- directly by client apps
-
- src/ -- sources of the library
- base/ -- the base layer
- sfnt/ -- the sfnt `driver' (see the drivers section
- below)
- truetype/ -- the truetype driver
- type1/ -- the type1 driver
- shared/ -- some header files shared between drivers
-
- demos/ -- demos/tools
-
- docs/ -- documentation (a bit empty for now)
-
-
-----------------------------------------------------------------------
-
-Glyph Image Formats:
-
- Drivers are now able to register new glyph image formats within the
- library. For now, the base layer supports of course bitmaps and
- vector outlines, but one could imagine something different like
- colored bitmaps, bi-color vectors or whatever else (Metafonts anyone
- ??).
-
- See the file `include/ftimage.h'. Note also that the type
- FT_Raster_Map is gone, and is now replaced by FT_Bitmap, which
- should encompass all known bitmap types.
-
- Each new image format must provide at least one `raster', i.e. a
- module capable of transforming the glyph image into a bitmap. It's
- also possible to change the default raster used for a given glyph
- image format.
-
- The default outline scan-converter now uses 128 levels of grays by
- default, which tends to smooth many things. Note that the demo
- programs have been updated significantly in order to display these..
-
-
-----------------------------------------------------------------------
-
-Build system:
-
- You still need GNU Make to build the library. The build system has
- been very seriously re-vamped in order to provide things like :
-
- - automatic host platform detection (reverting to 'config/ansi' if
- it is not detected, with pseudo-standard compilation flags)
-
- - the ability to compile from the Makefiles with very different and
- exotic compilers. Note that linking the library can be difficult
- for some platforms.
-
- For example, the file `config/win32/lcclib.bat' is invoked by the
- build system to create the `.lib' file with LCC-Win32 because its
- librarian has too many flaws to be invoked directly from the
- Makefile.
-
- Here's how it works:
-
- - the first time you type `make', the build system runs a series of
- sub-makefiles in order to detect your host platform. It then
- dumps what it found, and creates a file called `config.mk' in the
- current directory. This is a sub-Makefile used to define many
- important Make variables used to build the library.
-
- - the second time, the build system detects the `config.mk' then use
- it to build the library. All object files go into 'obj' by
- default, as well as the library file, but this can easily be
- changed.
-
- Note that you can run `make setup' to force another host platform
- detection even if a `config.mk' is present in the current
- directory. Another solution is simply to delete the file, then
- re-run make.
-
- Finally, the default compiler for all platforms is gcc (for now,
- this will hopefully changed in the future). You can however specify
- a different compiler by specifying it after the 'setup' target as
- in:
-
- gnumake setup lcc on Win32 to use the LCC compiler
- gnumake setup visualc on Win32 to use Visual C++
-
- See the file `config/<system>/detect.mk' for a list of supported
- compilers for your platforms.
-
- It should be relatively easy to write new detection rules files and
- config.mk..
-
- Finally, to build the demo programs, go to `demos' and launch GNU
- Make, it will use the `config.mk' in the top directory to build the
- test programs..
-
-
-----------------------------------------------------------------------
-
-Portability:
-
- In the previous beta, a single FT_System object was used to
- encompass all low-level operations like thread synchronisation,
- memory management and i/o access. This has been greatly simplified:
-
- - thread synchronisation has been dropped, for the simple reason
- that the library is already re-entrant, and that if you really
- need two threads accessing the same FT_Library, you should
- really synchronize access to it yourself with a simple mutex.
-
- - memory management is performed through a very simple object
- called `FT_Memory', which really is a table containing a table
- of pointers to functions like malloc, realloc and free as well
- as some user data (closure).
-
- - resources have disappeared (they created more problems than they
- solved), and i/o management have been simplified greatly as a
- result. Streams are defined through FT_Stream objects, which
- can be either memory-based or disk-based.
-
- Note that each face has its own stream, which is closed only
- when the face object is destroyed. Hence, a function like
- TT_Flush_Face in 1.x cannot be directly supported. However, if
- you really need something like this, you can easily tailor your
- own streams to achieve the same feature at a lower level (and
- use FT_Open_Face instead of FT_New_Face to create the face).
-
- See the file `include/ftsystem.h' for more details, as well as the
- implementations found in `config/unix' and `config/ansi'.
-
-
-----------------------------------------------------------------------
-
-Font Drivers:
-
- The Font Driver interface has been modified in order to support
- extensions & versioning.
-
-
- The list of the font drivers that are statically linked to the
- library at compile time is managed through a new configuration file
- called `config/<platform>/ftmodule.h'.
-
- This file is autogenerated when invoking `make modules'. This
- target will parse all sub-directories of 'src', looking for a
- `module.mk' rules file, used to describe the driver to the build
- system.
-
- Hence, one should call `make modules' each time a font driver is
- added or removed from the `src' directory.
-
- Finally, this version provides a `pseudo-driver' in `src/sfnt'.
- This driver doesn't support font files directly, but provides
- services used by all TrueType-like font drivers. Hence, its code is
- shared between the TrueType & OpenType font formats, and possibly
- more formats to come if we're lucky..
-
-
-----------------------------------------------------------------------
-
-Extensions support:
-
- The extensions support is inspired by the one found in 1.x.
-
- Now, each font driver has its own `extension registry', which lists
- which extensions are available for the font faces managed by the
- driver.
-
- Extension ids are now strings, rather than 4-byte tags, as this is
- usually more readable.
-
- Each extension has:
- - some data, associated to each face object
- - an interface (table of function pointers)
-
- An extension that is format-specific should simply register itself
- to the correct font driver. Here is some example code:
-
- // Registering an extensions
- //
- FT_Error FT_Init_XXXX_Extension( FT_Library library )
- {
- FT_DriverInterface* tt_driver;
-
- driver = FT_Get_Driver( library, "truetype" );
- if (!driver) return FT_Err_Unimplemented_Feature;
-
- return FT_Register_Extension( driver, &extension_class );
- }
-
-
- // Implementing the extensions
- //
- FT_Error FT_Proceed_Extension_XXX( FT_Face face )
- {
- FT_XXX_Extension ext;
- FT_XXX_Extension_Interface ext_interface;
-
- ext = FT_Get_Extension( face, "extensionid", &ext_interface );
- if (!ext) return error;
-
- return ext_interface->do_it(ext);
- }
-
-------------------------------------------------------------------------
-
-Copyright (C) 2000-2024 by
-David Turner, Robert Wilhelm, and Werner Lemberg.
-
-This file is part of the FreeType project, and may only be used,
-modified, and distributed under the terms of the FreeType project
-license, LICENSE.TXT. By continuing to use, modify, or distribute this
-file you indicate that you have read the license and understand and
-accept it fully.
-
-
-Local Variables:
-version-control: never
-coding: utf-8
-End:
-
---- end of CHANGES ---
diff --git a/contrib/libs/freetype/docs/CMAKE b/contrib/libs/freetype/docs/CMAKE
deleted file mode 100644
index 31237ae151..0000000000
--- a/contrib/libs/freetype/docs/CMAKE
+++ /dev/null
@@ -1,2 +0,0 @@
-Support for a cmake build has been contributed. See the remarks in the
-top-level `CMakeLists.txt' file for more.
diff --git a/contrib/libs/freetype/docs/CUSTOMIZE b/contrib/libs/freetype/docs/CUSTOMIZE
deleted file mode 100644
index a96726e4f6..0000000000
--- a/contrib/libs/freetype/docs/CUSTOMIZE
+++ /dev/null
@@ -1,152 +0,0 @@
-How to customize the compilation of the library
-===============================================
-
- FreeType is highly customizable to fit various needs, and this
- document describes how it is possible to select options and
- components at compilation time.
-
-
-I. Configuration macros
-
- The file `include/freetype/config/ftoption.h' contains a list of
- commented configuration macros that can be toggled by developers to
- indicate which features should be active while building the library.
-
- These options range from debug level to availability of certain
- features, like native TrueType hinting through a bytecode
- interpreter.
-
- We invite you to read this file for more information. You can
- change the file's content to suit your needs, or override it with
- one of the techniques described below.
-
-
-II. Modules list
-
- If you use GNU make please edit the top-level file `modules.cfg'.
- It contains a list of available FreeType modules and extensions to
- be compiled. Change it to suit your own preferences. Be aware that
- certain modules depend on others, as described in the file. GNU
- make uses `modules.cfg' to generate `ftmodule.h' (in the object
- directory).
-
- If you build FreeType in a directory separate from the source files,
- put your customized `modules.cfg' in that directory; that way you
- can keep the source files `clean'.
-
- If you don't use GNU make you have to manually edit the file
- `include/freetype/config/ftmodule.h' (which is *not* used with if
- compiled with GNU make) to add or remove the drivers and components
- you want to compile into the library. See `INSTALL.ANY' for more
- information.
-
-
-III. System interface
-
- FreeType's default interface to the system (i.e., the parts that
- deal with memory management and i/o streams) is located in
- `src/base/ftsystem.c'.
-
- The current implementation uses standard C library calls to manage
- memory and to read font files. It is however possible to write
- custom implementations to suit specific systems.
-
- To tell the GNU Make-based build system to use a custom system
- interface, you have to define the environment variable FTSYS_SRC to
- point to the relevant implementation:
-
- on Unix:
-
- ./configure <your options>
- export FTSYS_SRC=foo/my_ftsystem.c
- make
- make install
-
- on Windows:
-
- make setup <compiler>
- set FTSYS_SRC=foo/my_ftsystem.c
- make
-
-
-IV. Overriding default configuration and module headers
-
- It is possible to override the default configuration and module
- headers without changing the original files. There are three ways
- to do that:
-
-
- 1. With GNU make
-
- [This is actually a combination of method 2 and 3.]
-
- Just put your custom `ftoption.h' file into the objects directory
- (normally `<topdir>/objs' if you build in the source tree, or the
- directory where you invoke configure if you build in a separate
- directory), which GNU make prefers over the standard location. No
- action is needed for `ftmodule.h' because it is generated
- automatically in the objects directory.
-
- 2. Using the C include path
-
- Use the C include path to ensure that your own versions of the
- files are used at compile time when the lines
-
- #include FT_CONFIG_OPTIONS_H
- #include FT_CONFIG_MODULES_H
-
- are compiled. Their default values being
- <freetype/config/ftoption.h> and <freetype/config/ftmodule.h>, you
- can do something like:
-
- custom/
- config/
- ftoption.h => custom options header
- ftmodule.h => custom modules list
-
- include/ => normal FreeType 2 include
- ...
-
- then change the C include path to always give the path to `custom'
- before the FreeType 2 `include'.
-
-
- 3. Redefining FT_CONFIG_OPTIONS_H and FT_CONFIG_MODULES_H
-
- Another way to do the same thing is to redefine the macros used to
- name the configuration headers. To do so, you need a custom
- `ft2build.h' whose content can be as simple as:
-
- #ifndef FT2_BUILD_MY_PLATFORM_H_
- #define FT2_BUILD_MY_PLATFORM_H_
-
- #define FT_CONFIG_OPTIONS_H <custom/my-ftoption.h>
- #define FT_CONFIG_MODULES_H <custom/my-ftmodule.h>
-
- #include <freetype/config/ftheader.h>
-
- #endif /* FT2_BUILD_MY_PLATFORM_H_ */
-
- Place those files in a separate directory, e.g.,
-
- custom/
- ft2build.h => custom version described above
- my-ftoption.h => custom options header
- my-ftmodule.h => custom modules list header
-
- and change the C include path to ensure that `custom' is always
- placed before the FT2 `include' during compilation.
-
-----------------------------------------------------------------------
-
-Copyright (C) 2003-2024 by
-David Turner, Robert Wilhelm, and Werner Lemberg.
-
-This file is part of the FreeType project, and may only be used,
-modified, and distributed under the terms of the FreeType project
-license, LICENSE.TXT. By continuing to use, modify, or distribute
-this file you indicate that you have read the license and understand
-and accept it fully.
-
-
---- end of CUSTOMIZE ---
diff --git a/contrib/libs/freetype/docs/DEBUG b/contrib/libs/freetype/docs/DEBUG
deleted file mode 100644
index c892d4180a..0000000000
--- a/contrib/libs/freetype/docs/DEBUG
+++ /dev/null
@@ -1,310 +0,0 @@
-Debugging within the FreeType sources
-=====================================
-
-I. Configuration macros
------------------------
-
-There are several ways to enable debugging features in a FreeType 2
-builds. This is controlled through the definition of special macros
-located in the file `ftoption.h'. The macros are:
-
-
- FT_DEBUG_LEVEL_ERROR
-
- #define this macro if you want to compile the `FT_ERROR' macro
- calls to print error messages during program execution. This does
- not stop the program. Very useful to spot invalid fonts during
- development and to code workarounds for them.
-
- FT_DEBUG_LEVEL_TRACE
-
- #define this macro if you want to compile both macros `FT_ERROR'
- and `FT_TRACE'. This also includes the variants `FT_TRACE0',
- `FT_TRACE1', `FT_TRACE2', ..., `FT_TRACE7'.
-
- The trace macros are used to send debugging messages when an
- appropriate `debug level' is configured at runtime through the
- `FT2_DEBUG' environment variable (more on this later).
-
- FT_DEBUG_MEMORY
-
- If this macro is #defined, the FreeType engine is linked with a
- small but effective debugging memory manager that tracks all
- allocations and frees that are performed within the font engine.
-
- When the `FT2_DEBUG_MEMORY' environment variable is defined at
- runtime, a call to `FT_Done_FreeType' dumps memory statistics,
- including the list of leaked memory blocks and optionally with the
- source locations where these were allocated. It is always a very
- good idea to define this in development builds. This works with
- _any_ program linked to FreeType, but requires a big deal of
- memory (the debugging memory manager never frees the blocks to the
- heap in order to detect double frees).
-
- When `FT2_DEBUG_MEMORY' isn't defined at runtime, the debugging
- memory manager is ignored, and performance is unaffected.
-
- FT_DEBUG_LOGGING
-
- #define this macro for enhanced logging support; it automatically
- sets `FT_DEBUG_LEVEL_TRACE' and `FT_DEBUG_LEVEL_ERROR'.
-
- If defined, `FT_TRACE' and `FT_ERROR' can send tracing and
- debugging messages to a file. The location of the log file has to
- be set with the `FT_LOGGING_FILE' environment variable (more on
- this later).
-
- The main enhancements are the possibility of logging the time and
- the name of the `FT_COMPONENT' macro together with the affected
- `FT_TRACE' or `FT_ERROR' calls. See below how to activate this in
- the `FT2_DEBUG' environment variable.
-
-
-II. Debugging macros
---------------------
-
-Several macros can be used within the FreeType sources to help
-debugging its code:
-
-
- 1. FT_ERROR(( ... ))
-
- This macro is used to send debug messages that indicate relatively
- serious errors (like broken font files) without stopping the
- execution of the running program. Its code is compiled only when
- either `FT_DEBUG_LEVEL_ERROR' or `FT_DEBUG_LEVEL_TRACE' are
- defined in `ftoption.h'.
-
- Note that you have to use a printf-like signature, but with double
- parentheses, like in
-
- FT_ERROR(( "your %s is not %s\n", "foo", "bar" ));
-
-
- 2. FT_ASSERT( condition )
-
- This macro is used to check strong assertions at runtime. If its
- condition isn't TRUE, the program aborts with a panic message.
- Its code is compiled when either `FT_DEBUG_LEVEL_ERROR' or
- `FT_DEBUG_LEVEL_TRACE' are defined. You don't need double
- parentheses here. Example:
-
- FT_ASSERT( ptr != NULL );
-
-
- 3. FT_TRACE( level, (message...) )
-
- The `FT_TRACE' macro is used to send general-purpose debugging
- messages during program execution. This macro uses an *implicit*
- macro named `FT_COMPONENT', which names the current FreeType
- component being run.
-
- The developer should always define `FT_COMPONENT' as appropriate,
- for example as in
-
- #undef FT_COMPONENT
- #define FT_COMPONENT io
-
- The value of the `FT_COMPONENT' macro is one of the component
- names defined in the internal file `internal/fttrace.h'. If you
- modify the FreeType source code and insert a new `FT_COMPONENT'
- macro, you must register it in `fttrace.h'. If you insert or
- remove many trace macros, you can test for undefined or unused
- trace macros with the script `src/tools/chktrcmp.py'.
-
- Each such component is assigned a `debug level', ranging from
- value 0 to 7, through the use of the `FT2_DEBUG' environment
- variable (described below) when a program linked with FreeType
- starts.
-
- When `FT_TRACE' is called, its level is compared to the one of the
- corresponding component. Messages with trace levels *higher* than
- the corresponding component level are filtered out and never
- printed. This means that trace messages with level 0 are always
- printed, those with level 2 are only printed when the component
- level is *at least* 2, etc.
-
- The second parameter to `FT_TRACE' must contain parentheses and
- corresponds to a printf-like call, as in
-
- FT_TRACE( 2, ( "your %s is not %s\n", "foo", "bar" ) )
-
- The shortcut macros `FT_TRACE0', `FT_TRACE1', `FT_TRACE2', ...,
- `FT_TRACE7' can be used with constant level indices, and are much
- cleaner to use, as in
-
- FT_TRACE2(( "your %s is not %s\n", "foo", "bar" ));
-
-
-III. Environment variables
---------------------------
-
-The following environment variables control debugging output and
-behaviour of FreeType at runtime.
-
-
- FT2_DEBUG
-
- This variable is only used when FreeType is built with
- `FT_DEBUG_LEVEL_TRACE' defined. It contains a list of component
- level definitions, following this format:
-
- component1:level1 component2:level2 component3:level3 ...
-
- where `componentX' is the name of a tracing component, as defined
- in `fttrace.h'. `levelX' is the corresponding level to use at
- runtime.
-
- `any' is a special component name that is interpreted as `any/all
- components'. For example, the following definitions
-
- set FT2_DEBUG=any:2 memory:5 io:4 (on Windows)
- export FT2_DEBUG="any:2 memory:5 io:4" (on Linux with bash)
-
- both stipulate that all components should have level 2, except for
- the memory and io components, which are set to the trace levels 5
- and 4, respectively.
-
- If `FT_DEBUG_LOGGING' is defined, two more options are available.
-
- * -v: Print also the name of FreeType's component from which the
- current log is produced, together with the tracing level.
-
- * -t: Print also the time.
-
- Here are some examples how the output might look like.
-
- FT2_DEBUG="any:7 memory:5 -vt"
-
- => [20:32:02:44969 ttload:2] table directory loaded
-
- FT2_DEBUG="any:7 memory:5 -t"
-
- => [20:32:02:44969] table directory loaded
-
- FT2_DEBUG="any:7 memory:5 -v"
-
- => [ttload:2] table directory loaded
-
-
- FT_LOGGING_FILE
-
- This variable is only used if FreeType is built with the
- `FT_DEBUG_LOGGING' macro defined. It contains the path to the
- file where the user wants to put his log file. If it is not set,
- FreeType uses stderr.
-
- Examples:
-
- On UNIX-like systems with bash:
- export FT_LOGGING_FILE="/tmp/freetype2.log"
-
- On Windows:
- set FT_LOGGING_FILE=C:\Users\AppData\Local\Temp\freetype2.log
-
-
- FT2_DEBUG_MEMORY
-
- This environment variable, when defined, tells FreeType to use a
- debugging memory manager that tracks leaking memory blocks as well
- as other common errors like double frees. It is also capable of
- reporting _where_ the leaking blocks were allocated, which
- considerably saves time when debugging new additions to the
- library.
-
- This code is only compiled when FreeType is built with the
- `FT_DEBUG_MEMORY' macro #defined in `ftoption.h' though, it is
- ignored in other builds.
-
-
- FT2_ALLOC_TOTAL_MAX
-
- This variable is ignored if `FT2_DEBUG_MEMORY' is not defined. It
- allows you to specify a maximum heap size for all memory
- allocations performed by FreeType. This is very useful to test
- the robustness of the font engine and programs that use it in
- tight memory conditions.
-
- If it is undefined, or if its value is not strictly positive, no
- allocation bounds are checked at runtime.
-
-
- FT2_ALLOC_COUNT_MAX
-
- This variable is ignored if `FT2_DEBUG_MEMORY' is not defined. It
- allows you to specify a maximum number of memory allocations
- performed by FreeType before returning the error
- `FT_Err_Out_Of_Memory'. This is useful for debugging and testing
- the engine's robustness.
-
- If it is undefined, or if its value is not strictly positive, no
- allocation bounds are checked at runtime.
-
-
- FT2_KEEP_ALIVE
-
- This variable is ignored if `FT2_DEBUG_MEMORY' is not defined.
- `Keep alive' means that freed blocks aren't released to the heap.
- This is useful to detect double-frees or weird heap corruption,
- reporting the source code location of the original allocation and
- deallocation in case of a problem. It uses large amounts of
- memory, however.
-
- If it is undefined, or if its value is not strictly positive,
- freed blocks are released at runtime.
-
-
-IV. Additional Capabilities with `FT_DEBUG_LOGGING'
----------------------------------------------------
-
-If `FT_DEBUG_LOGGING' is defined, four APIs are available to provide
-additional debugging support. Use
-
- #include <freetype/ftlogging.h>
-
-to access them.
-
- FT_Trace_Set_Level( const char* level )
-
- By default, FreeType uses the tracing levels set in the
- `FT2_DEBUG' environment variable. Use this function to override
- the value with `level'. Use value `NULL' to disable tracing.
-
- FT_Trace_Set_Default_Level( void )
-
- Reset the tracing levels to the default value, i.e., the value of
- the `FT2_DEBUG' environment variable or no tracing if not set.
-
- FT_Set_Log_Handler( ft_custom_log_handler handler )
-
- Use `handler' as a custom handler for formatting tracing and error
- messages. The `ft_custom_log_handler' typedef has the following
- prototype.
-
- void
- (*ft_custom_log_handler)( const char* ft_component,
- const char* fmt,
- va_list args );
-
- `ft_component' is the current component like `ttload', `fmt' is the
- first argument of `FT_TRACE' or `FT_ERROR', and `args' holds the
- remaining arguments.
-
- FT_Set_Default_Log_Handler( void )
-
- Reset the log handler to the default version.
-
-
-------------------------------------------------------------------------
-
-Copyright (C) 2002-2024 by
-David Turner, Robert Wilhelm, and Werner Lemberg.
-
-This file is part of the FreeType project, and may only be used,
-modified, and distributed under the terms of the FreeType project
-license, LICENSE.TXT. By continuing to use, modify, or distribute this
-file you indicate that you have read the license and understand and
-accept it fully.
-
-
---- end of DEBUG ---
diff --git a/contrib/libs/freetype/docs/DOCGUIDE b/contrib/libs/freetype/docs/DOCGUIDE
deleted file mode 100644
index 332b93691b..0000000000
--- a/contrib/libs/freetype/docs/DOCGUIDE
+++ /dev/null
@@ -1,298 +0,0 @@
-Introduction
-------------
-
-Documentation is an extremely important part of any project, and it
-helps a lot if it uses consistent syntax and layout.
-
-The documentation for the FreeType library is maintained in header
-files in the `include/` directory in the form of code comments. These
-comments are extracted and organized by 'docwriter' (previously
-'docmaker'). The generated docs can be viewed in the
-`docs/reference/site/` directory after running `make refdoc`.
-
-Documentation comments follow a specific structure and format as
-described below.
-
-
-Documentation Structure
------------------------
-
-The documentation is divided into multiple chapters, which contain
-sections relevant to it. The chapter details and sections contained
-in them are listed in `include/freetype/ftchapters.h`. Any unlisted
-section is added to the 'Miscellaneous' chapter.
-
-Sections may contain sub-sections which consist of properties,
-enumerations, and other data types.
-
-
-Comment Blocks
---------------
-
-Documentation blocks follow a specific format:
-
- /***************************** (should end on column 77)
- *
- * (1 asterisk, 1 space, then content)
- *
- */ (end of block)
-
-To make 'docwriter' recognize a comment block, there must be at least
-two asterisks in the first line. As a consequence, you should change
-the second asterisk to something else if you want to prevent a comment
-block being handled by 'docwriter' (for example, change `/****/` to
-`/*#**/`).
-
-
-Markup Tags
------------
-
-Markup tags are used to indicate what comes next. The syntax for a
-tag is:
-
- @foo:
-
-An `@`, followed by the tag, and then `:`.
-
-
-Reserved Tags
--------------
-
-There are some keywords that have a special meaning to docwriter.
-As a convention, all keywords are written in lowercase.
-
-* `chapter`: Defines a chapter. Usually the title with underscores.
-* `sections`: List of sections in the chapter, in order.
-* `section`: Defines the start or continuation of a section.
-* `title`: Title for a chapter or section. May contain spaces.
-* `abstract`: The abstract for a section, visible in the Table of
- Contents (TOC).
-* `description`: Detailed description of a tag (except chapters),
- shown as synopsis.
-* `values`: A list of 'values' for the tag. These values are used for
- cross-referencing.
-
-
-Other Tags
-----------
-
-Except the ones given above, any other tags will be added as a part of
-a subsection. All tags are lowercase by convention.
-
-
-Public Header Definitions
--------------------------
-
-The public headers for FreeType have their names defined in
-`include/freetype/config/ftheader.h`. Any new public header file must
-be defined in this file, in the following format:
-
- #define FT_NEWNAME_H <freetype/newname.h>
-
-Where `newname` is the name of the header file.
-
-This macro is combined with the file location of a sub-section and
-printed with the object.
-
-
-Note on code blocks captured after comments
--------------------------------------------
-
-All non-documentation lines after a documentation comment block are
-captured to be displayed as the code for the sub-section. To stop
-collection, a line with `/* */` should be added.
-
-
-General Formatting Conventions
-------------------------------
-
-* Use two spaces after a full stop ending a sentence.
-* Use appropriate uppercasing in titles. Refer
-
- https://english.stackexchange.com/a/34
-
- for more information.
-* Do not add trailing parentheses when citing a C function.
-
-
-Markdown Usage
---------------
-
-All tags, except the ones that define the name and title for a block
-support markdown in them. Docwriter uses a markdown parser that
-follows rules given in John Gruber's markdown guide:
-
- https://daringfireball.net/projects/markdown/syntax
-
-with a few exceptions and extensions, detailed below. This may also
-be referred to as the **FreeType Flavored Markdown**.
-
-
-Headers
--------
-
-Markdown headers should not be used directly, because these are added
-based on section titles, sub-section names, and tags. However, if a
-header needs to be added, note the following correspondence to HTML tags:
-
-* Section title on top of the page is `H1`.
-* Sub-section titles are `H2`.
-* Parts of sub-sections are `H4`.
-* Any header added will be visible in the Table of Contents (TOC) of
- the page.
-
-
-Emphasis
---------
-
-* Use `_underscores_` for italics.
-* Use `**double asterisks**` for bold.
-
-Although the other notations (double underscore for bold, single
-asterisk for italics) are supported, it is recommended to use the
-above for consistency.
-
-Note that there may be cases where having two asterisks or underscores
-in a line may lead to text being picked up as italics or bold.
-Although unintentional, this is correct markdown behavior.
-
-For inline code, wrap the sequence with backticks (see below). This
-renders symbols correctly without modifications. If a symbol is
-absolutely required outside of an inline code block or code sequence,
-escape it with a backslash (like `\*` or `\_`).
-
-
-Lists
------
-
-Unordered lists can be created with asterisks:
-
- * Unordered list items can use asterisks.
- * Another list item.
-
-Ordered lists start with numbers:
-
- 1. This is an ordered list item.
- 2. Brackets after numbers won't work.
-
-To continue a list over multiple paragraphs, indent them with at least
-four spaces. For example:
-
- 1. Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
- Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
- viverra nec, fringilla in, laoreet vitae, risus.
-
- Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
- Suspendisse id sem consectetuer libero luctus adipiscing.
-
- 2. This is the second list item.
-
- This paragraph is not a part of the list.
-
-More information on lists in markdown is available at
-
- https://daringfireball.net/projects/markdown/syntax#list
-
-
-Cross-references
-----------------
-
-Other sub-sections can be linked with the `@` symbol:
-
- @description:
- While FreeType's CFF driver doesn't expose API functions by
- itself, it is possible to control its behaviour with
- @FT_Property_Set and @FT_Property_Get.
-
-If a field in the `values` table of another sub-section is linked, the
-link leads to its parent sub-section.
-
-
-Links and Images
-----------------
-
-All URLs are converted to links in the HTML documentation.
-
-Markdown syntax for links and images are fully supported.
-
-
-Inline Code
------------
-
-To indicate a span of code, wrap it with backtick quotes (`` ` ``):
-
- Use the `printf()` function.
-
-Cross-references, markdown, and html styling do not work in inline code
-sequences.
-
-
-Code and Syntax Highlighting
-----------------------------
-
-Blocks of code are fenced by lines with three back-ticks `` ``` ``
-followed by the language name, if any (used for syntax highlighting),
-as demonstrated in the following example.
-
- ```c
- x = y + z;
- if ( zookoo == 2 )
- {
- foobar();
- }
- ```
-
-Note that the indentation of the opening line and the closing line
-must be exactly the same. The code sequence itself should have a
-larger indentation than the surrounding back-ticks.
-
-Like inline code, markdown and html styling is *not* supported inside
-code blocks.
-
-
-Tables
-------
-
-Tables are used to list values, input, and other fields. The FreeType
-Flavored Markdown adopts a simple approach to tables with two columns,
-or field definition tables.
-
-Field definition names may contain alphanumeric, underscore, and the
-`.` characters. This is followed by `::`. The following lines are
-the second column of the table. A field definition ends with the
-start of another field definition, or a markup tag.
-
- @Input:
- pathname ::
- A path to the font file.
-
- face_index ::
- See @FT_Open_Face for a detailed description of this
- parameter.
-
-
-Non-breaking Space
-------------------
-
-A tilde can be used to create a non-breaking space. The example
-
- The encoding value~0 is reserved.
-
-is converted to
-
- The encoding value&nbsp;0 is reserved.
-
-
-----------------------------------------------------------------------
-
-Copyright (C) 2018-2024 by
-Nikhil Ramakrishnan, David Turner, Robert Wilhelm, and Werner Lemberg.
-
-This file is part of the FreeType project, and may only be used,
-modified, and distributed under the terms of the FreeType project
-license, LICENSE.TXT. By continuing to use, modify, or distribute
-this file you indicate that you have read the license and understand
-and accept it fully.
-
-
---- end of DOCGUIDE ---
diff --git a/contrib/libs/freetype/docs/FTL.TXT b/contrib/libs/freetype/docs/FTL.TXT
deleted file mode 100644
index c406d150fa..0000000000
--- a/contrib/libs/freetype/docs/FTL.TXT
+++ /dev/null
@@ -1,169 +0,0 @@
- The FreeType Project LICENSE
- ----------------------------
-
- 2006-Jan-27
-
- Copyright 1996-2002, 2006 by
- David Turner, Robert Wilhelm, and Werner Lemberg
-
-
-
-Introduction
-============
-
- The FreeType Project is distributed in several archive packages;
- some of them may contain, in addition to the FreeType font engine,
- various tools and contributions which rely on, or relate to, the
- FreeType Project.
-
- This license applies to all files found in such packages, and
- which do not fall under their own explicit license. The license
- affects thus the FreeType font engine, the test programs,
- documentation and makefiles, at the very least.
-
- This license was inspired by the BSD, Artistic, and IJG
- (Independent JPEG Group) licenses, which all encourage inclusion
- and use of free software in commercial and freeware products
- alike. As a consequence, its main points are that:
-
- o We don't promise that this software works. However, we will be
- interested in any kind of bug reports. (`as is' distribution)
-
- o You can use this software for whatever you want, in parts or
- full form, without having to pay us. (`royalty-free' usage)
-
- o You may not pretend that you wrote this software. If you use
- it, or only parts of it, in a program, you must acknowledge
- somewhere in your documentation that you have used the
- FreeType code. (`credits')
-
- We specifically permit and encourage the inclusion of this
- software, with or without modifications, in commercial products.
- We disclaim all warranties covering The FreeType Project and
- assume no liability related to The FreeType Project.
-
-
- Finally, many people asked us for a preferred form for a
- credit/disclaimer to use in compliance with this license. We thus
- encourage you to use the following text:
-
- """
- Portions of this software are copyright © <year> The FreeType
- Project (www.freetype.org). All rights reserved.
- """
-
- Please replace <year> with the value from the FreeType version you
- actually use.
-
-
-Legal Terms
-===========
-
-0. Definitions
---------------
-
- Throughout this license, the terms `package', `FreeType Project',
- and `FreeType archive' refer to the set of files originally
- distributed by the authors (David Turner, Robert Wilhelm, and
- Werner Lemberg) as the `FreeType Project', be they named as alpha,
- beta or final release.
-
- `You' refers to the licensee, or person using the project, where
- `using' is a generic term including compiling the project's source
- code as well as linking it to form a `program' or `executable'.
- This program is referred to as `a program using the FreeType
- engine'.
-
- This license applies to all files distributed in the original
- FreeType Project, including all source code, binaries and
- documentation, unless otherwise stated in the file in its
- original, unmodified form as distributed in the original archive.
- If you are unsure whether or not a particular file is covered by
- this license, you must contact us to verify this.
-
- The FreeType Project is copyright (C) 1996-2000 by David Turner,
- Robert Wilhelm, and Werner Lemberg. All rights reserved except as
- specified below.
-
-1. No Warranty
---------------
-
- THE FREETYPE PROJECT IS PROVIDED `AS IS' WITHOUT WARRANTY OF ANY
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE. IN NO EVENT WILL ANY OF THE AUTHORS OR COPYRIGHT HOLDERS
- BE LIABLE FOR ANY DAMAGES CAUSED BY THE USE OR THE INABILITY TO
- USE, OF THE FREETYPE PROJECT.
-
-2. Redistribution
------------------
-
- This license grants a worldwide, royalty-free, perpetual and
- irrevocable right and license to use, execute, perform, compile,
- display, copy, create derivative works of, distribute and
- sublicense the FreeType Project (in both source and object code
- forms) and derivative works thereof for any purpose; and to
- authorize others to exercise some or all of the rights granted
- herein, subject to the following conditions:
-
- o Redistribution of source code must retain this license file
- (`FTL.TXT') unaltered; any additions, deletions or changes to
- the original files must be clearly indicated in accompanying
- documentation. The copyright notices of the unaltered,
- original files must be preserved in all copies of source
- files.
-
- o Redistribution in binary form must provide a disclaimer that
- states that the software is based in part of the work of the
- FreeType Team, in the distribution documentation. We also
- encourage you to put an URL to the FreeType web page in your
- documentation, though this isn't mandatory.
-
- These conditions apply to any software derived from or based on
- the FreeType Project, not just the unmodified files. If you use
- our work, you must acknowledge us. However, no fee need be paid
- to us.
-
-3. Advertising
---------------
-
- Neither the FreeType authors and contributors nor you shall use
- the name of the other for commercial, advertising, or promotional
- purposes without specific prior written permission.
-
- We suggest, but do not require, that you use one or more of the
- following phrases to refer to this software in your documentation
- or advertising materials: `FreeType Project', `FreeType Engine',
- `FreeType library', or `FreeType Distribution'.
-
- As you have not signed this license, you are not required to
- accept it. However, as the FreeType Project is copyrighted
- material, only this license, or another one contracted with the
- authors, grants you the right to use, distribute, and modify it.
- Therefore, by using, distributing, or modifying the FreeType
- Project, you indicate that you understand and accept all the terms
- of this license.
-
-4. Contacts
------------
-
- There are two mailing lists related to FreeType:
-
- o freetype@nongnu.org
-
- Discusses general use and applications of FreeType, as well as
- future and wanted additions to the library and distribution.
- If you are looking for support, start in this list if you
- haven't found anything to help you in the documentation.
-
- o freetype-devel@nongnu.org
-
- Discusses bugs, as well as engine internals, design issues,
- specific licenses, porting, etc.
-
- Our home page can be found at
-
- https://www.freetype.org
-
-
---- end of FTL.TXT ---
diff --git a/contrib/libs/freetype/docs/GPLv2.TXT b/contrib/libs/freetype/docs/GPLv2.TXT
deleted file mode 100644
index b2fe7b6af3..0000000000
--- a/contrib/libs/freetype/docs/GPLv2.TXT
+++ /dev/null
@@ -1,340 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) year name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff --git a/contrib/libs/freetype/docs/INSTALL b/contrib/libs/freetype/docs/INSTALL
deleted file mode 100644
index 0ab2a5e9ea..0000000000
--- a/contrib/libs/freetype/docs/INSTALL
+++ /dev/null
@@ -1,114 +0,0 @@
-
-There are several ways to build the FreeType library, depending on
-your system and the level of customization you need. Here is a short
-overview of the documentation available:
-
-
-I. Prerequisites and dependencies
-=================================
-
- FreeType is a low level C library that only depends on the standard
- C library with very few platform-dependent optimizations utilized at
- build time. Any C99-compliant compiler should be able to compile
- FreeType. System libraries, such as zlib, Gzip, bzip2, Brotli,
- and libpng, might be used to handle compressed fonts or decode
- embedded PNG glyphs.
-
- FreeType auto-configuration scripts should be able to detect the
- prerequisites if the necessary headers are available at the default
- locations. Otherwise, modify `include/freetype/config/ftoption.h`
- to control how the FreeType library gets built. Normally, you don't
- need to change anything.
-
- Applications have very limited control over FreeType's behaviour at
- run-time; look at the documentation of function `FT_Property_Set`.
-
-
-II. Normal installation and upgrades
-====================================
-
- 1. Unix and Unix-like systems
-
- This also includes MacOS, Cygwin, MinGW + MSYS, Mingw-w64 + MSYS2,
- and possibly other, similar environments.
-
- Please read `INSTALL.UNIX` to install or upgrade FreeType 2 on a
- Unix system. Note that you *need* GNU Make for automatic
- compilation, since other make tools won't work (this includes BSD
- Make).
-
- GNU Make VERSION 3.81 OR NEWER IS NEEDED!
-
-
- 2. Other systems using GNU Make
-
- On some non-Unix platforms, it is possible to build the library
- using only the GNU Make utility. Note that *NO OTHER MAKE TOOL
- WILL WORK*[1]! This methods supports several compilers on
- Windows, OS/2, and BeOS, including MinGW* (without MSYS*), Visual
- C++, Borland C++, and more.
-
- Instructions are provided in the file `INSTALL.GNU`.
-
-
- 3. Other build tools and platforms.
-
- A few other tools can be used to build FreeType. You can find
- the corresponding instruction files in the FreeType root folder
- or the builds/ sub-folder.
-
- CMake :: see `CMakeLists.txt` for more information
- Meson :: see `meson.build` for more information
- MSBuild :: see `MSBuild.sln` for more information
- MMS :: see `vms_make.com` and `docs/INSTALL.VMS`
-
-
- 4. With an IDE Project File (e.g., for Visual Studio or CodeWarrior)
-
- We provide a small number of 'project files' for various IDEs to
- automatically build the library as well. Note that these files
- are not actively supported by FreeType developers, they can break
- or become obsolete.
-
- To find them, have a look at the content of the `builds/<system>`
- directory, where <system> stands for your OS or environment.
-
-
- 5. From you own IDE, or own Makefiles
-
- If you want to create your own project file, follow the
- instructions given in the `INSTALL.ANY` document of this
- directory.
-
-
-III. Custom builds of the library
-=================================
-
- Customizing the compilation of FreeType is easy, and allows you to
- select only the components of the font engine that you really need.
- For more details read the file `CUSTOMIZE`.
-
-
-----------------------------------------------------------------------
-
-[1] make++, a make tool written in Perl, has sufficient support of GNU
- make extensions to build FreeType. See
-
- https://makepp.sourceforge.net
-
- for more information; you need version 2.0 or newer, and you must
- pass option `--norc-substitution`.
-
-----------------------------------------------------------------------
-
-Copyright (C) 2000-2024 by
-David Turner, Robert Wilhelm, and Werner Lemberg.
-
-This file is part of the FreeType project, and may only be used,
-modified, and distributed under the terms of the FreeType project
-license, LICENSE.TXT. By continuing to use, modify, or distribute
-this file you indicate that you have read the license and understand
-and accept it fully.
-
-
---- end of INSTALL ---
diff --git a/contrib/libs/freetype/docs/INSTALL.ANY b/contrib/libs/freetype/docs/INSTALL.ANY
deleted file mode 100644
index 32ee707a10..0000000000
--- a/contrib/libs/freetype/docs/INSTALL.ANY
+++ /dev/null
@@ -1,157 +0,0 @@
-Instructions on how to build FreeType with your own build tool
-==============================================================
-
-See the file `CUSTOMIZE' to learn how to customize FreeType to
-specific environments.
-
-
-I. Standard procedure
----------------------
-
- * If you use macro names for FreeType header files (while mandatory
- in earlier versions, this is now optional since FreeType version
- 2.6.1) it is necessary to disable pre-compiled headers. This is
- very important for Visual C++, because lines like
-
- #include FT_FREETYPE_H
-
- are not correctly supported by this compiler while being ISO C
- compliant!
-
- * You need to add the directory `include' to your include path when
- compiling the library.
-
- * FreeType 2 is made of several components; each of them is located
- in a subdirectory of `freetype/src'. For example,
- `freetype/src/truetype/' contains the TrueType font driver.
-
- * DO NOT COMPILE ALL C FILES! Rather, compile the following ones.
-
- -- base components (required)
-
- src/base/ftsystem.c
- src/base/ftinit.c
- src/base/ftdebug.c
-
- src/base/ftbase.c
-
- src/base/ftbbox.c -- recommended, see <ftbbox.h>
- src/base/ftglyph.c -- recommended, see <ftglyph.h>
-
- src/base/ftbdf.c -- optional, see <ftbdf.h>
- src/base/ftbitmap.c -- optional, see <ftbitmap.h>
- src/base/ftcid.c -- optional, see <ftcid.h>
- src/base/ftfstype.c -- optional
- src/base/ftgasp.c -- optional, see <ftgasp.h>
- src/base/ftgxval.c -- optional, see <ftgxval.h>
- src/base/ftmm.c -- optional, see <ftmm.h>
- src/base/ftotval.c -- optional, see <ftotval.h>
- src/base/ftpatent.c -- optional
- src/base/ftpfr.c -- optional, see <ftpfr.h>
- src/base/ftstroke.c -- optional, see <ftstroke.h>
- src/base/ftsynth.c -- optional, see <ftsynth.h>
- src/base/fttype1.c -- optional, see <t1tables.h>
- src/base/ftwinfnt.c -- optional, see <ftwinfnt.h>
-
- src/base/ftmac.c -- only on the Macintosh
-
- -- font drivers (optional; at least one is needed)
-
- src/bdf/bdf.c -- BDF font driver
- src/cff/cff.c -- CFF/OpenType font driver
- src/cid/type1cid.c -- Type 1 CID-keyed font driver
- src/pcf/pcf.c -- PCF font driver
- src/pfr/pfr.c -- PFR/TrueDoc font driver
- src/sfnt/sfnt.c -- SFNT files support
- (TrueType & OpenType)
- src/truetype/truetype.c -- TrueType font driver
- src/type1/type1.c -- Type 1 font driver
- src/type42/type42.c -- Type 42 font driver
- src/winfonts/winfnt.c -- Windows FONT / FNT font driver
-
- -- rasterizers (optional; at least one is needed for vector
- formats)
-
- src/smooth/smooth.c -- anti-aliasing rasterizer
- src/raster/raster.c -- monochrome rasterizer
- src/sdf/sdf.c -- Signed Distance Field driver
-
- -- auxiliary modules (optional)
-
- src/autofit/autofit.c -- auto hinting module
- src/cache/ftcache.c -- cache sub-system (in beta)
- src/gzip/ftgzip.c -- support for compressed fonts (.gz)
- src/lzw/ftlzw.c -- support for compressed fonts (.Z)
- src/bzip2/ftbzip2.c -- support for compressed fonts (.bz2)
- src/gxvalid/gxvalid.c -- TrueTypeGX/AAT table validation
- src/otvalid/otvalid.c -- OpenType table validation
- src/psaux/psaux.c -- PostScript Type 1 parsing
- src/pshinter/pshinter.c -- PS hinting module
- src/psnames/psnames.c -- PostScript glyph names support
-
-
- Notes:
-
- `ftcache.c' needs `ftglyph.c'
- `ftfstype.c' needs `fttype1.c'
- `ftglyph.c' needs `ftbitmap.c'
- `ftstroke.c' needs `ftglyph.c'
- `ftsynth.c' needs `ftbitmap.c'
-
- `cff.c' needs `sfnt.c', `pshinter.c', and `psnames.c'
- `truetype.c' needs `sfnt.c' and `psnames.c'
- `type1.c' needs `psaux.c' `pshinter.c', and `psnames.c'
- `type1cid.c' needs `psaux.c', `pshinter.c', and `psnames.c'
- `type42.c' needs `truetype.c'
-
- Please consult the central `include/freetype/config/ftoption.h'
- configuration file for details on additional libraries necessary
- for some optional features.
-
-
- Read the file `CUSTOMIZE' in case you want to compile only a subset
- of the drivers, renderers, and optional modules; a detailed
- description of the various base extension is given in the top-level
- file `modules.cfg'.
-
- You are done. In case of problems, see the archives of the FreeType
- development mailing list.
-
-
-II. Support for flat-directory compilation
-------------------------------------------
-
- It is possible to put all FreeType 2 source files into a single
- directory, with the *exception* of the `include' hierarchy.
-
- 1. Copy all files in current directory
-
- cp freetype/src/base/*.[hc] .
- cp freetype/src/raster/*.[hc] .
- cp freetype/src/smooth/*.[hc] .
- etc.
-
- 2. Compile sources
-
- cc -c -Iinclude -DFT2_BUILD_LIBRARY ftsystem.c
- cc -c -Iinclude -DFT2_BUILD_LIBRARY ftinit.c
- cc -c -Iinclude -DFT2_BUILD_LIBRARY ftdebug.c
- cc -c -Iinclude -DFT2_BUILD_LIBRARY ftbase.c
- etc.
-
- You don't need to define the FT_FLAT_COMPILATION macro (as this
- was required in previous releases of FreeType 2).
-
-----------------------------------------------------------------------
-
-Copyright (C) 2003-2024 by
-David Turner, Robert Wilhelm, and Werner Lemberg.
-
-This file is part of the FreeType project, and may only be used,
-modified, and distributed under the terms of the FreeType project
-license, LICENSE.TXT. By continuing to use, modify, or distribute
-this file you indicate that you have read the license and understand
-and accept it fully.
-
-
---- end of INSTALL.ANY ---
diff --git a/contrib/libs/freetype/docs/INSTALL.CROSS b/contrib/libs/freetype/docs/INSTALL.CROSS
deleted file mode 100644
index b774527e56..0000000000
--- a/contrib/libs/freetype/docs/INSTALL.CROSS
+++ /dev/null
@@ -1,177 +0,0 @@
-This document contains instructions on how to cross-build the FreeType
-library on Unix systems, for example, building binaries for Linux/MIPS
-on FreeBSD/i386. Before reading this document, please consult the
-file `INSTALL.UNIX' for required tools and the basic self-building
-procedure.
-
-
- 1. Required Tools
- -----------------
-
- For self-building the FreeType library on a Unix system, GNU Make
- 3.81 or newer is required. `INSTALL.UNIX' contains hints how to
- check the installed `make'.
-
- The GNU C compiler to cross-build the target system is required.
- Currently, using a non-GNU cross compiler is untested. The cross
- compiler is expected to be installed with a system prefix. For
- example, if your building system is FreeBSD/i386 and the target
- system is Linux/MIPS, the cross compiler should be installed with
- the name `mips-ip22-linuxelf-gcc'.
-
- A C compiler for a self-build is required also, to build a tool
- (`apinames') that is executed during the build procedure. Non-GNU
- self compilers are acceptable, but such a setup is untested.
-
-
- 2. Configuration
- ----------------
-
- 2.1. Building and target system
-
- To configure a cross-build, the options `--host=<system>' and
- `--build=<system>' must be passed to the `configure' script.
- For example, if your build system is FreeBSD/i386 and the target
- system is Linux/MIPS, say
-
- ./configure \
- --build=i386-unknown-freebsd \
- --host=mips-ip22-linuxelf \
- [other options]
-
- It should be noted that `--host=<system>' specifies the system
- where the built binaries will be executed, not the system where
- the build actually happens. Older versions of GNU autoconf use
- the option pair `--host=' and `--target='. This is broken and
- doesn't work. Similarly, an explicit CC specification like
-
- env CC=mips-ip22-linux-gcc ./configure # BAD
-
- or
-
- env CC=/usr/local/mips-ip22-linux/bin/gcc ./configure # BAD
-
- doesn't work either; such a configuration confuses the
- `configure' script while trying to find the cross and native C
- compilers.
-
-
- 2.2. The prefix to install FreeType2
-
- Setting `--prefix=<prefix>' properly is important. The prefix
- to install FreeType2 is written into the `freetype-config'
- script and `freetype2.pc' configuration file.
-
- If the built FreeType 2 library is used as a part of the
- cross-building system, the prefix is expected to be different
- from the self-building system. For example, a configuration
- with `--prefix=/usr/local' installs binaries into the
- system-wide `/usr/local' directory, which then can't be executed
- due to the incorrect architecture. This causes confusion in
- configuration of all applications that use FreeType2. Instead,
- use a prefix to install the cross-build into a separate system
- tree, for example, `--prefix=/usr/local/mips-ip22-linux/'.
-
- On the other hand, if the built FreeType 2 library is used as a
- part of the target system, the prefix to install should reflect
- the file system structure of the target system.
-
-
- 2.3. Library dependencies
-
- FreeType normally depends on external libraries like `libpng' or
- `libharfbuzz'. The easiest case is to deactivate all such
- dependencies using the `--without-XXX' configuration options.
- However, if you want to use those libraries, you should ensure
- that they are available both on the target system and as
- (cross-compiled) libraries on the build system.
-
- FreeType uses `pkg-config' to find most of the libraries; the
- other libraries it links to are expected in the standard system
- directories. Since the default pkg-config's meta-information
- files (like `harfbuzz.pc') of the build platform don't work, use
- one of the two possible solutions below.
-
- o Use pkg-config's meta-information files that are adjusted to
- cross-compile and cross-link with the target platform's
- libraries. Make sure those files are found before the build
- system's default files. Example:
-
- ./configure \
- --build=i386-unknown-freebsd \
- --host=mips-ip22-linuxelf \
- PKG_CONFIG_LIBDIR="/usr/local/mips-ip22-linux/lib/pkgconfig" \
- [other options]
-
- See the manpage of `pkg-config' for more details.
-
- o Set variables like LIBPNG_LIBS as additional options to the
- `configure' script, overriding the values `pkg-config' would
- provide. `configure --help' shows the available environment
- variables. Example:
-
- ./configure \
- --build=i386-unknown-freebsd \
- --host=mips-ip22-linuxelf \
- LIBPNG_CFLAGS="-I/usr/local/mips-ip22-linux/include" \
- LIBPNG_LIBS="-L/usr/local/mips-ip22-linux/lib -lpng12" \
- [other options]
-
-
- 3. Building command
- -------------------
-
- If the configuration finishes successfully, invoking GNU make
- builds FreeType2. Just say
-
- make
-
- or
-
- gmake
-
- depending on the name the GNU make binary actually has.
-
-
- 4. Installation
- ---------------
-
- Saying
-
- make install
-
- as usual to install FreeType2 into the directory tree specified by
- the argument of the `--prefix' option.
-
- As noted in section 2.2, FreeType2 is sometimes configured to be
- installed into the system directory of the target system, and
- should not be installed in the cross-building system. In such
- cases, the make variable `DESTDIR' is useful to change the root
- directory in the installation. For example, after
-
- make DESTDIR=/mnt/target_system_root/ install
-
- the built FreeType2 library files are installed into the directory
- `/mnt/target_system_root/<prefix_in_configure>/lib'.
-
-
- 5. TODO
- -------
-
- Cross building between Cygwin (or MSys) and Unix must be tested.
-
-
-----------------------------------------------------------------------
-
-Copyright (C) 2006-2024 by
-suzuki toshiya, David Turner, Robert Wilhelm, and Werner Lemberg.
-
-
-This file is part of the FreeType project, and may only be used,
-modified, and distributed under the terms of the FreeType project
-license, LICENSE.TXT. By continuing to use, modify, or distribute
-this file you indicate that you have read the license and understand
-and accept it fully.
-
-
---- end of INSTALL.CROSS ---
diff --git a/contrib/libs/freetype/docs/INSTALL.GNU b/contrib/libs/freetype/docs/INSTALL.GNU
deleted file mode 100644
index 57f2018328..0000000000
--- a/contrib/libs/freetype/docs/INSTALL.GNU
+++ /dev/null
@@ -1,181 +0,0 @@
-This document contains instructions how to build the FreeType library
-on non-Unix systems with the help of GNU Make. Note that if you are
-running Cygwin or MinGW/MSYS in Windows, you should follow the
-instructions in the file `INSTALL.UNIX' instead.
-
-
- FreeType 2 includes a powerful and flexible build system that allows
- you to easily compile it on a great variety of platforms from the
- command line. To do so, just follow these simple instructions.
-
- 1. Install GNU Make
- -------------------
-
- The FreeType 2 build system relies on many features special to GNU
- Make.
-
- NEARLY ALL OTHER MAKE TOOLS FAIL, INCLUDING `BSD MAKE', SO REALLY
- INSTALL A RECENT VERSION OF GNU MAKE ON YOUR SYSTEM!
-
- Note that make++, a make tool written in Perl, supports enough
- features of GNU make to compile FreeType. See
-
- https://makepp.sourceforge.net
-
- for more information; you need version 2.0 or newer, and you must
- pass option `--norc-substitution'.
-
- Make sure that you are invoking GNU Make from the command line, by
- typing something like:
-
- make -v
-
- to display its version number.
-
- VERSION 3.81 OR NEWER IS NEEDED!
-
-
- 2. Invoke `make'
- ----------------
-
- Go to the root directory of FreeType 2, then simply invoke GNU
- Make from the command line. This will launch the FreeType 2 host
- platform detection routines. A summary will be displayed, for
- example, on Win32.
-
-
- ==============================================================
- FreeType build system -- automatic system detection
-
- The following settings are used:
-
- platform windows
- compiler gcc
- configuration directory .\builds\windows
- configuration rules .\builds\windows\w32-gcc.mk
-
- If this does not correspond to your system or settings please
- remove the file 'config.mk' from this directory then read the
- INSTALL file for help.
-
- Otherwise, simply type 'make' again to build the library
- or 'make refdoc' to build the API reference (the latter needs
- Python >= 3.5).
- =============================================================
-
-
- If the detected settings correspond to your platform and compiler,
- skip to step 5. Note that if your platform is completely alien to
- the build system, the detected platform will be `ansi'.
-
-
- 3. Configure the build system for a different compiler
- ------------------------------------------------------
-
- If the build system correctly detected your platform, but you want
- to use a different compiler than the one specified in the summary
- (for most platforms, gcc is the default compiler), invoke GNU Make
- with
-
- make setup <compiler>
-
- Examples:
-
- to use Visual C++ on Win32, type: `make setup visualc'
- to use Borland C++ on Win32, type `make setup bcc32'
- to use Watcom C++ on Win32, type `make setup watcom'
- to use Intel C++ on Win32, type `make setup intelc'
- to use LCC-Win32 on Win32, type: `make setup lcc'
- to use Watcom C++ on OS/2, type `make setup watcom'
- to use VisualAge C++ on OS/2, type `make setup visualage'
-
- The <compiler> name to use is platform-dependent. The list of
- available compilers for your system is available in the file
- `builds/<system>/detect.mk'.
-
- If you are satisfied by the new configuration summary, skip to
- step 5.
-
-
- 3a. Use clang instead of gcc
- ----------------------------
-
- The `clang' compiler can use FreeType's setup for `gcc'; it is
- sufficient to set the `CC' variable, for example
-
- make CC=clang
-
-
- 3b. Compiling with a C++ compiler
- ---------------------------------
-
- FreeType can be built with a C++ compiler, for example
-
- make CC="g++"
-
- If `clang++' should be used it is necessary to also override the
- `ANSIFLAGS' variable:
-
- make CC="clang++" ANSIFLAGS=""
-
-
- 4. Configure the build system for an unknown platform/compiler
- --------------------------------------------------------------
-
- The auto-detection/setup phase of the build system copies a file
- to the current directory under the name `config.mk'.
-
- For example, on OS/2+gcc, it would simply copy
- `builds/os2/os2-gcc.mk' to `./config.mk'.
-
- If for some reason your platform isn't correctly detected, copy
- manually the configuration sub-makefile to `./config.mk' and go to
- step 5.
-
- Note that this file is a sub-Makefile used to specify Make
- variables for compiler and linker invocation during the build.
- You can easily create your own version from one of the existing
- configuration files, then copy it to the current directory under
- the name `./config.mk'.
-
-
- 5. Build the library
- --------------------
-
- The auto-detection/setup phase should have copied a file in the
- current directory, called `./config.mk'. This file contains
- definitions of various Make variables used to invoke the compiler
- and linker during the build. [It has also generated a file called
- `ftmodule.h' in the objects directory (which is normally
- `<toplevel>/objs/'); please read the file `docs/CUSTOMIZE' for
- customization of FreeType.]
-
- To launch the build, simply invoke GNU Make again: The top
- Makefile will detect the configuration file and run the build with
- it. If you have used variables in step 3, you must use the same
- variables here, too.
-
-
- Final note
-
- The above instructions build a _statically_ linked library of the
- font engine in the `objs' directory. On Windows, you can build a
- DLL either with MinGW (within an MSYS shell, following the
- instructions in `INSTALL.UNIX'), or you use one of the Visual C++
- project files; see the subdirectories of `builds/windows'. For
- everything else, you are on your own, and you might follow the
- instructions in `INSTALL.ANY' to create your own Makefiles.
-
-----------------------------------------------------------------------
-
-Copyright (C) 2003-2024 by
-David Turner, Robert Wilhelm, and Werner Lemberg.
-
-This file is part of the FreeType project, and may only be used,
-modified, and distributed under the terms of the FreeType project
-license, LICENSE.TXT. By continuing to use, modify, or distribute
-this file you indicate that you have read the license and understand
-and accept it fully.
-
-
---- end of INSTALL.GNU ---
diff --git a/contrib/libs/freetype/docs/INSTALL.MAC b/contrib/libs/freetype/docs/INSTALL.MAC
deleted file mode 100644
index 2587e24a65..0000000000
--- a/contrib/libs/freetype/docs/INSTALL.MAC
+++ /dev/null
@@ -1,32 +0,0 @@
-Please follow the instructions in INSTALL.UNIX to install FreeType on
-Mac OS X.
-
-Currently FreeType2 functions based on some deprecated Carbon APIs
-return `FT_Err_Unimplemented_Feature' always, even if FreeType2 is
-configured and built on the system that deprecated Carbon APIs are
-available. To enable deprecated FreeType2 functions as far as
-possible, replace `src/base/ftmac.c' by `builds/mac/ftmac.c'.
-
-Starting with Mac OS X 10.5, gcc defaults the deployment target to
-10.5. In previous versions of Mac OS X, this defaulted to 10.1. If
-you want your built binaries to run only on 10.5, this change does not
-concern you. If you want them to also run on older versions of Mac
-OS X, then you must either set the MACOSX_DEPLOYMENT_TARGET
-environment variable or pass `-mmacosx-version-min' to gcc. You
-should specify the oldest version of Mac OS you want the code to run
-on. For example, if you use Bourne shell:
-
- export MACOSX_DEPLOYMENT_TARGET=10.2
-
-or, if you use C shell:
-
- setenv MACOSX_DEPLOYMENT_TARGET 10.2
-
-Alternatively, you could pass `-mmacosx-version-min=10.2' to gcc.
-
-Here the number 10.2 is the lowest version that the built binaries can
-run on. In the above cases, the built binaries will run on Mac OS X
-10.2 and later, but _not_ earlier. If you want to run on earlier, you
-have to set lower version, e.g., 10.0.
-
-For classic Mac OS (Mac OS 7, 8, 9) please refer to builds/mac/README.
diff --git a/contrib/libs/freetype/docs/INSTALL.UNIX b/contrib/libs/freetype/docs/INSTALL.UNIX
deleted file mode 100644
index 4a4a101e3e..0000000000
--- a/contrib/libs/freetype/docs/INSTALL.UNIX
+++ /dev/null
@@ -1,139 +0,0 @@
-This document contains instructions on how to build the FreeType
-library on Unix systems. This also works for emulations like Cygwin
-or MSys on Win32:
-
-
- 1. Ensure that you are using GNU Make
- -------------------------------------
-
- The FreeType build system _exclusively_ works with GNU Make. You
- will not be able to compile the library with the instructions
- below using any other alternative (including BSD Make).
-
- Check that you have GNU make by running the command:
-
- make -v
-
- This should dump some text that begins with:
-
- GNU Make <version number>
- Copyright (C) <year> Free Software Foundation Inc.
-
- Note that version 3.81 or higher is *required* or the build will
- fail.
-
- It is also fine to have GNU Make under another name (e.g. 'gmake')
- if you use the MAKE variable as described below.
-
- As a special exception, 'makepp' can also be used to build
- FreeType 2. See the file docs/MAKEPP for details.
-
- For builds with `cmake' please check file `CMakeLists.txt'; this
- is a contributed file not directly supported by the FreeType team.
-
-
- 2. Regenerate the configure script if needed
- --------------------------------------------
-
- This only applies if you are building a git snapshot or checkout,
- *not* if you grabbed the sources of an official release.
-
- You need to invoke the `autogen.sh' script in the top-level
- directory in order to create the `configure' script for your
- platform. Normally, this simply means typing:
-
- sh autogen.sh
-
- In case of problems, you may need to install or upgrade Automake,
- Autoconf or Libtool. See `README.git' in the top-level directory
- for more information.
-
-
- 3. Build and install the library
- --------------------------------
-
- Say
-
- ./configure --help
-
- to see the list of possible configuration options and important
- environment variables. The ./configure script will detect some
- prerequisite system libraries (libpng, brotli, etc.) if their
- headers are available at the default locations.
-
- The following should work on all Unix systems where the `make'
- command invokes GNU Make:
-
- ./configure [options]
- make
- make install (as root)
-
- The default installation path is `/usr/local'. It can be changed
- with the `--prefix=<path>' option. Example:
-
- ./configure --prefix=/usr
-
- When using a different command to invoke GNU Make, use the MAKE
- variable. For example, if `gmake' is the command to use on your
- system, do something like:
-
- MAKE=gmake ./configure [options]
- gmake
- gmake install (as root)
-
- If this still doesn't work, there must be a problem with your
- system (e.g., you are using a very old version of GNU Make).
-
- For library identification, FreeType's `configure' script uses the
- `pkg-config' interface: Assuming it needs library `foo', it calls
- the `pkg-config' program to find information on library `foo',
- which in turn looks for a `foo.pc' file installed at the system.
- Some platforms, however, don't come with `pkg-support'; you then
- have to use environment variables as described by `configure
- --help'. Example:
-
- LIBPNG_CFLAGS="-I/path/to/libpng/include/directory" \
- LIBPNG_LIBS="-L/path/to/libpng/lib/directory" \
- configure ...
-
- It is possible to compile FreeType in a different directory.
- Assuming the FreeType source files in directory `/src/freetype' a
- compilation in directory `foo' works as follows:
-
- cd foo
- /src/freetype/configure [options]
- make
- make install
-
-
- 3.1 Interdependency with HarfBuzz
- .................................
-
- Note that there is a chicken-and-egg problem currently since the
- HarfBuzz library (used by the auto-hinter to improve support of
- OpenType fonts) depends on FreeType, which can be solved as
- follows in case HarfBuzz is not yet installed on your system.
-
- 1. Call FreeType's `configure' script with option
- `--without-harfbuzz', then compile and install FreeType.
-
- 2. Compile and install HarfBuzz.
-
- 3. Call FreeType's `configure' script without option
- `--without-harfbuzz' (after executing `make distclean'), then
- compile and install FreeType again.
-
-
-----------------------------------------------------------------------
-
-Copyright (C) 2003-2024 by
-David Turner, Robert Wilhelm, and Werner Lemberg.
-
-This file is part of the FreeType project, and may only be used,
-modified, and distributed under the terms of the FreeType project
-license, LICENSE.TXT. By continuing to use, modify, or distribute
-this file you indicate that you have read the license and understand
-and accept it fully.
-
-
---- end of INSTALL.UNIX ---
diff --git a/contrib/libs/freetype/docs/INSTALL.VMS b/contrib/libs/freetype/docs/INSTALL.VMS
deleted file mode 100644
index ba5aece898..0000000000
--- a/contrib/libs/freetype/docs/INSTALL.VMS
+++ /dev/null
@@ -1,69 +0,0 @@
-How to build the FreeType library on VMS
-----------------------------------------
-
-It is actually very straightforward to install the FreeType library.
-Just execute `vms_make.com from` the toplevel directory to build the
-library. This procedure currently accepts the following options:
-
-* `DEBUG`
- Build the library with debug information and without optimization.
-
-* `lopts=<value>`
- Options to pass to the link command, e.g., `lopts=/traceback`.
-
-* `ccopt=<value>`
- Options to pass to the C compiler, e.g., `ccopt=/float=ieee`.
-
-In case you did download the demos, place them in a separate directory
-sharing the same top level as the directory of FreeType and follow the
-same instructions as above for the demos from there. The build
-process relies on this to figure out the location of the FreeType
-include files.
-
-
-To rebuild the sources it is necessary to have MMS/MMK installed on
-the system.
-
-The library is available in the directory
-
- [.LIB]
-
-To compile applications using FreeType you have to define the logical
-`FREETYPE` pointing to the directory
-
- [.INCLUDE.FREETYPE]
-
-i.e., if the directory in which this `INSTALL.VMS` file is located is
-`$disk:[freetype.docs]`, then define the logical with
-
- define freetype $disk:[freetype.include.freetype]
-
-See http://nchrem.tnw.tudelft.nl/openvms/software2.html#Freetype for
-the packages FreeType depends on.
-
-The latest versions were tested using
- - VSI C V7.4-002 and DECWindows V1.7-F on OpenVMS Alpha V8.4-2L1
- - VSI C V7.4-001 and DECWindows V1.7-E on OpenVMS IA64 V8.4-2L3
-
-
-Any problems can be reported to
-
- Jouk Jansen <joukj@hrem.nano.tudelft.nl> or
-
-Orginal version of the build procedures was created by
-
- Martin P.J. Zinser <zinser@zinser.no-ip.info>
-
-------------------------------------------------------------------------
-
-Copyright (C) 2000-2024 by
-David Turner, Robert Wilhelm, and Werner Lemberg.
-
-This file is part of the FreeType project, and may only be used,
-modified, and distributed under the terms of the FreeType project
-license, LICENSE.TXT. By continuing to use, modify, or distribute this
-file you indicate that you have read the license and understand and
-accept it fully.
-
-
---- end of INSTALL.VMS ---
diff --git a/contrib/libs/freetype/docs/MAKEPP b/contrib/libs/freetype/docs/MAKEPP
deleted file mode 100644
index 4450e47700..0000000000
--- a/contrib/libs/freetype/docs/MAKEPP
+++ /dev/null
@@ -1,5 +0,0 @@
-As a special exception, FreeType can also be built with the 'makepp'
-build tool, available from https://makepp.sourceforge.net.
-
-Note, however, that you will need at least version 2.0 and pass the
-option --norc-substitution to have it work correctly.
diff --git a/contrib/libs/freetype/docs/PROBLEMS b/contrib/libs/freetype/docs/PROBLEMS
deleted file mode 100644
index 40bdc35a67..0000000000
--- a/contrib/libs/freetype/docs/PROBLEMS
+++ /dev/null
@@ -1,90 +0,0 @@
-This file describes various problems that have been encountered in
-compiling, installing and running FreeType 2. Suggestions for
-additions or other improvements to this file are welcome.
-
-----------------------------------------------------------------------
-
-Running Problems
-================
-
-
-* Some Type 1, Multiple Masters, and CID-keyed PostScript fonts aren't
- handled correctly.
-
------
-
-Of course, there might be bugs in FreeType, but some fonts based on
-the PostScript format can't be handled indeed. The reason is that
-FreeType doesn't contain a full PostScript interpreter but applies
-pattern matching instead. In case a font doesn't follow the standard
-structure of the given font format, FreeType fails. A typical example
-is Adobe's `Optima' font family which contains extra code to switch
-between low and high resolution versions of the glyphs.
-
-It might be possible to patch FreeType in some situations, though.
-Please report failing fonts so that we investigate the problem and set
-up a list of such problematic fonts.
-
-
-* Why do identical FreeType versions render differently on different
- platforms?
-
------
-
-Different distributions compile FreeType with different options. The
-developer version of a distribution's FreeType package, which is
-needed to compile your program against FreeType, includes the file
-ftoption.h. Compare each platform's copy of ftoption.h to find the
-differences.
-
-
-----------------------------------------------------------------------
-
-
-Compilation Problems
-====================
-
-
-* I get an `internal compilation error' (ICE) while compiling FreeType
- 2.2.1 with Intel C++.
-
- This has been reported for the following compiler version:
-
- Intel(R) C++ Compiler for 32-bit applications,
- Version 9.0 Build 20050430Z Package ID: W_CC_P_9.0.019
-
------
-
-The best solution is to update the compiler to version
-
- Intel(R) C++ Compiler for 32-bit applications,
- Version 9.1 Build 20060323Z Package ID: W_CC_P_9.1.022
-
-or newer. If this isn't feasible, apply the following patch.
-
-
---- src/cache/ftcbasic.c 20 Mar 2006 12:10:24 -0000 1.20
-+++ src/cache/ftcbasic.c.patched 15 May 2006 02:51:02 -0000
-@@ -252,7 +252,7 @@
- */
-
- FT_CALLBACK_TABLE_DEF
-- const FTC_IFamilyClassRec ftc_basic_image_family_class =
-+ FTC_IFamilyClassRec ftc_basic_image_family_class =
- {
- {
- sizeof ( FTC_BasicFamilyRec ),
-@@ -266,7 +266,7 @@
-
-
- FT_CALLBACK_TABLE_DEF
-- const FTC_GCacheClassRec ftc_basic_image_cache_class =
-+ FTC_GCacheClassRec ftc_basic_image_cache_class =
- {
- {
- ftc_inode_new,
-
-
-----------------------------------------------------------------------
-
---- end of PROBLEMS ---
diff --git a/contrib/libs/freetype/docs/README b/contrib/libs/freetype/docs/README
deleted file mode 100644
index c2b5af8650..0000000000
--- a/contrib/libs/freetype/docs/README
+++ /dev/null
@@ -1,33 +0,0 @@
-After saying `make refdoc' or `make refdoc-venv' the `reference/' directory
-contains the FreeType API reference. You need Python >= 3.5 and pip to make
-this target.
-
-There are two ways to generate the documentation:
-
-1. Using `make refdoc':
-
- - Ensure `python' and `pip' are available.
- - Install pip package `docwriter' with `pip install --user docwriter'.
- - Make target with `make refdoc'.
- - This target can be run offline once required packages are installed.
-
-2. Using `make refdoc-venv' (requires internet access):
-
- - Ensure `python', `pip' and Python package `virtualenv' are available.
- - Make target with `make refdoc-venv'.
- - This may or may not require internet access every time depending on
- pip and system caching.
-
-Some troubleshooting tips:
-
-* Regularly run `pip install --upgrade docwriter' to check for updates which
-may include bug fixes.
-
-* `Docwriter' does not support Python 2. Ensure that Python >= 3.5 is
-installed and available as `python3'/`python'.
-
-* Ensure that `docwriter' is installed in the same Python target that
-`make refdoc' uses (python3/python).
-
-* If none of this works, send a mail to `freetype-devel@nongnu.org' or file
-an issue at `https://github.com/freetype/docwriter/issues'.
diff --git a/contrib/libs/freetype/docs/TODO b/contrib/libs/freetype/docs/TODO
deleted file mode 100644
index 985e363cc4..0000000000
--- a/contrib/libs/freetype/docs/TODO
+++ /dev/null
@@ -1,40 +0,0 @@
-Here is a list of items that need to be addressed in FreeType 2
----------------------------------------------------------------
-
-* Implement stem3/counter hints properly in the Postscript hinter.
-
-* Add CIDCMap support to the CID driver.
-
-* Add track kerning support to the PFR driver.
-
-* Add kerning (AFM file) support to the CID driver.
-
-
-Here is a list of bugs which should be handled
-----------------------------------------------
-
-Other bugs have been registered at the savannah bugzilla of FreeType.
-
-* CID driver:
- Handle the case where a CID font has a top-level font matrix also
- (see PLRM, 5.11.3, Type 0 CIDFonts). Since CID_FaceInfoRec lacks
- a font_matrix entry we have to directly apply it to all subfont
- matrices.
-
-* CID driver:
- Use top-level font matrix entry for setting the upem value, not the
- entries in the FDarray. If absent, use 1000.
-
-------------------------------------------------------------------------
-
-Copyright (C) 2001-2024 by
-David Turner, Robert Wilhelm, and Werner Lemberg.
-
-This file is part of the FreeType project, and may only be used,
-modified, and distributed under the terms of the FreeType project
-license, LICENSE.TXT. By continuing to use, modify, or distribute this
-file you indicate that you have read the license and understand and
-accept it fully.
-
-
---- end of TODO ---
diff --git a/contrib/libs/freetype/docs/VERSIONS.TXT b/contrib/libs/freetype/docs/VERSIONS.TXT
deleted file mode 100644
index a84067dfe1..0000000000
--- a/contrib/libs/freetype/docs/VERSIONS.TXT
+++ /dev/null
@@ -1,138 +0,0 @@
-Due to our use of `libtool' to generate and install the FreeType 2
-libraries on Unix systems, as well as other historical events, it is
-generally very difficult to know precisely which release of the font
-engine is installed on a given system.
-
-This file tries to explain why and to document ways to properly detect
-FreeType on Unix.
-
-
-1. Version and Release numbers
-------------------------------
-
-For each new public release of FreeType 2, there are generally *three*
-distinct `version' numbers to consider:
-
- * The official FreeType 2 release number, like 2.7.0 or 2.10.2.
-
- * The libtool (and Unix) specific version number, like 23.2.17.
- This is what
-
- pkg-config freetype2 --modversion
-
- or
-
- freetype-config --version
-
- returns.
-
- * The platform-specific shared object number, used for example when
- the library is installed as `/usr/lib/libfreetype.so.6.17.2'.
-
-The platform-specific number is, unsurprisingly, platform-specific and
-varies with the operating system you are using (several variants of
-Linux, FreeBSD, Solaris, etc.). You should thus _never_ use it, even
-for simple tests.
-
-The libtool-specific number does not equal the release number but is
-tied to it.
-
-The release number is available at *compile* time through the
-following macros defined in `freetype.h':
-
- - FREETYPE_MAJOR: major release number
- - FREETYPE_MINOR: minor release number
- - FREETYPE_PATCH: patch release number
-
-See below for a small autoconf fragment.
-
-The release number is also available at *runtime* through the
-`FT_Library_Version' API.
-
-
-2. History
-----------
-
-The following table gives, for all releases since 2.5.0, the
-corresponding libtool number, as well as the shared object number
-found on _most_ systems, but not all of them:
-
-
- release libtool so
- -------------------------------
- 2.13.3 26.2.20 6.20.2
- 2.13.2 26.1.20 6.20.1
- 2.13.1 26.0.20 6.20.0
- 2.13.0 25.0.19 6.19.0
- 2.12.1 24.3.18 6.18.3
- 2.12.0 24.2.18 6.18.2
- 2.11.1 24.1.18 6.18.1
- 2.11.0 24.0.18 6.18.0
- 2.10.4 23.4.17 6.17.4
- 2.10.3 23.3.17 6.17.3
- 2.10.2 23.2.17 6.17.2
- 2.10.1 23.1.17 6.17.1
- 2.10.0 23.0.17 6.17.0
- 2.9.1 22.1.16 6.16.1
- 2.9.0 22.0.16 6.16.0
- 2.8.1 21.0.15 6.15.0
- 2.8.0 20.0.14 6.14.0
- 2.7.1 19.0.13 6.13.0
- 2.7.0 18.6.12 6.12.6
- 2.6.5 18.5.12 6.12.5
- 2.6.4 18.4.12 6.12.4
- 2.6.3 18.3.12 6.12.3
- 2.6.2 18.2.12 6.12.2
- 2.6.1 18.1.12 6.12.1
- 2.6.0 18.0.12 6.12.0
- 2.5.5 17.4.11 6.11.4
- 2.5.4 17.3.11 6.11.3
- 2.5.3 17.2.11 6.11.2
- 2.5.2 17.1.11 6.11.1
- 2.5.1 17.0.11 6.11.0
- 2.5.0 16.2.10 6.10.2
-
-
-3. Autoconf Code Fragment
--------------------------
-
-Lars Clausen contributed the following autoconf fragment to check
-which version of FreeType is installed on a system (now updated to use
-`pkg-config' instead of `freetype-config'). This one tests for a
-version that is at least 2.10.2; you should change it to check against
-other release numbers.
-
-
- AC_MSG_CHECKING([whether FreeType version is 2.10.2 or higher])
- old_CPPFLAGS="$CPPFLAGS"
- CPPFLAGS=`pkg-config freetype2 --cflags`
- AC_TRY_CPP([
-
-#include <ft2build.h>
-#include <freetype/freetype.h>
-
-#if FREETYPE_MAJOR*10000 + FREETYPE_MINOR*100 + FREETYPE_PATCH < 21002
-# error FreeType version too low.
-#endif
-
- ],
- [AC_MSG_RESULT(yes)
- FREETYPE_LIBS=`pkg-config freetype2 --libs`
- AC_SUBST(FREETYPE_LIBS)
- AC_DEFINE(HAVE_FREETYPE,1,[Define if you have the FreeType2 library])
- CPPFLAGS="$old_CPPFLAGS"],
- [AC_MSG_ERROR([Need FreeType library version 2.10.2 or higher])])
-
-----------------------------------------------------------------------
-
-Copyright (C) 2002-2024 by
-David Turner, Robert Wilhelm, and Werner Lemberg.
-
-This file is part of the FreeType project, and may only be used,
-modified, and distributed under the terms of the FreeType project
-license, LICENSE.TXT. By continuing to use, modify, or distribute
-this file you indicate that you have read the license and understand
-and accept it fully.
-
-
---- end of VERSIONS.TXT ---
diff --git a/contrib/libs/freetype/docs/formats.txt b/contrib/libs/freetype/docs/formats.txt
deleted file mode 100644
index 00283e6a0a..0000000000
--- a/contrib/libs/freetype/docs/formats.txt
+++ /dev/null
@@ -1,223 +0,0 @@
-This file contains a list of various font formats. It gives the
-reference document and whether it is supported in FreeType 2.
-
-Table fields
-------------
-
- wrapper format
- The format used to represent the font data. In the table below it
- is used only if the font format differs. Possible values are
-
- SFNT binary
- PFB binary
- PS a text header, followed by binary or text data
- LZW compressed with either `gzip' or `compress'
- BZ2 compressed with `bzip2'.
-
- font format
- How the font is to be accessed, possibly after converting the file
- type and wrapper format into a generic form. Bitmap formats are
- `BDF', `PCF', and one form of `WINFNT'; all others are vector
- formats. `PS' indicates third-order, `TT' second-order Bézier
- curves.
-
- font type
- Sub-formats of the font format. `SBIT' and `MACSBIT' are bitmap
- formats, `MM' and `VAR' support optical axes. `CFF2' supports
- optical axes also.
-
- glyph access
- If not specified, the glyph access is `standard' to the font
- format. Values are `CID' for CID-keyed fonts, `SYNTHETIC' for
- fonts that are modified versions of other fonts by means of a
- transformation matrix, and `TYPE_0' for PS fonts which are to be
- accessed in a tree-like structure.
-
- FreeType driver
- The module in the FreeType library which handles the specific font
- format. A missing entry means that FreeType doesn't support the
- font format (yet).
-
-
-Notes
------
-
- The SFNT container format also provides `collections' (usually
- having the file extension `.ttc' or `.otc'). A collection contains
- multiple font faces that share some tables to avoid redundancy, thus
- reducing the file size. In FreeType, elements of a collection can
- be accessed with a proper face index.
-
- Both the GX and the OpenType 1.8 variation fonts provide `named
- instances'. FreeType maps them to face indices (they can also be
- accessed with the standard MM interface).
-
- Other font formats (not using the SFNT wrapper) also provide
- multiple faces within one file; they are marked with an asterisk
- (`*') in the table below.
-
- FreeType can be configured to support Mac files (on older Mac OS
- versions, a `file' is stored as a data and a resource fork, that is,
- within two separate data chunks). If a file can't be opened as a
- font, FreeType then checks whether it is a resource fork, trying to
- extract the contained font data from either a `POST' or `sfnt'
- resource.
-
-
-Please send additions and/or corrections to wl@gnu.org or to the
-FreeType developer's list at freetype-devel@nongnu.org (for
-subscribers only). If you can provide a font example for a format
-which isn't supported yet please send a mail too.
-
-
- wrapper font font glyph FreeType reference
- format format type access driver documents
- -----------------------------------------------------------------------------
-
- --- BDF --- --- bdf 5005.BDF_Spec.pdf, X11
-
-
- SFNT PS TYPE_1 --- type1 Type 1 GX Font Format [7]
- (for the Mac; not supported)
- SFNT PS TYPE_1 CID cid 5180.sfnt.pdf (for the Mac) [3]
- SFNT PS CFF --- cff OT spec, 5176.CFF.pdf
- (`OTTO' format)
- SFNT PS CFF CID cff OT spec, 5176.CFF.pdf
- SFNT PS CFF SYNTHETIC --- OT spec, 5176.CFF.pdf
- SFNT PS CFF2 --- cff OT spec 1.8
-
- SFNT TT SBIT --- sfnt XFree86 (bitmaps only;
- with `head' table)
- SFNT TT MACSBIT --- sfnt OT spec (for the Mac;
- bitmaps only; `bhed' table)
- SFNT TT --- --- truetype OT spec (`normal' TT font)
- SFNT TT VAR --- truetype GX spec (`?var' tables)
- SFNT TT VAR --- truetype OT spec 1.8
- (`?var' + `?VAR' tables)
-
-
- WOFF --- --- --- cff, Compressed SFNT, ver. 1.0 [6]
- truetype
- WOFF2 --- --- --- cff, Compressed SFNT, ver. 2.0 [6]
- truetype
-
-
- --- PS TYPE_1 --- type1 T1_SPEC.pdf
- (PFA, Type 1 font resource)
- PFB PS TYPE_1 --- type1 T1_SPEC.pdf,
- 5040.Download_Fonts.pdf
- (`normal' Type 1 font)
- --- PS TYPE_1 CID cid PLRM.pdf (CID Font Type 0;
- Type 9 font)
- --- PS MM --- type1 5015.Type1_Supp.pdf
- (Multiple Masters)
- --- PS CFF --- cff 5176.CFF.pdf (`pure' CFF)
- --- PS* CFF CID cff 5176.CFF.pdf (`pure' CFF)
- --- PS CFF SYNTHETIC --- 5176.CFF.pdf (`pure' CFF)
- --- PS CFF/MM --- cff old 5167.CFF.pdf (`pure' CFF)
- [3]
- --- PS* CFF/MM CID cff old 5167.CFF.pdf (`pure' CFF)
- [3]
- --- PS CFF/MM SYNTHETIC --- old 5167.CFF.pdf (`pure' CFF)
- [3]
- PS PS CFF --- --- PLRM.pdf (Type 2) [1]
- PS PS* CFF CID --- PLRM.pdf (Type 2) [1]
- PS PS CFF SYNTHETIC --- PLRM.pdf (Type 2) [1]
- PS PS CFF/MM --- --- PLRM.pdf (Type 2) [1]
- PS PS* CFF/MM CID --- PLRM.pdf (Type 2) [1]
- PS PS CFF/MM SYNTHETIC --- PLRM.pdf (Type 2) [1]
- --- PS --- TYPE_0 --- PLRM.pdf
- --- PS TYPE_3 --- --- PLRM.pdf (never supported)
- --- PS TYPE_3 CID --- PLRM.pdf (CID Font Type 1;
- Type 10 font; never supported)
- PS PS TYPE_14 --- --- PLRM.pdf (Chameleon font;
- Type 14 font; never supported?)
- --- PS TYPE_32 CID --- PLRM.pdf (CID Font Type 4;
- Type 32 font; never supported?)
- PS TT --- --- type42 5012.Type42_Spec.pdf
- (Type 42 font)
- PS TT --- CID --- PLRM.pdf (CID Font Type 2;
- Type 11 font)
-
-
- ? ? CEF ? cff ?
-
-
- --- PCF --- --- pcf X11 [4]
- LZW PCF --- --- pcf X11 [4]
- BZ2 PCF --- --- pcf X11 [4]
-
-
- --- PFR* PFR0 --- pfr [2]
- --- PFR PFR1 --- --- (undocumented, proprietary;
- probably never supported)
-
-
- --- WINFNT* --- --- winfonts Windows developer's notes [5]
- --- WINFNT VECTOR --- --- Windows developer's notes [5]
-
-
-[1] Support should be rather simple since this is identical to `CFF'
- but in a PS wrapper.
-
-[2] The official PFR specification is no longer available, but
- archive.org has archived it:
-
- https://web.archive.org/web/20091014062300/http://www.bitstream.com/font_rendering/products/truedoc/pfrspec.html
- https://web.archive.org/web/20081115152605/http://www.bitstream.com/font_rendering/pdfs/pfrspec1.3.pdf
-
- The syntax of the auxiliary data is not defined there, but is
- partially defined in MHP 1.0.3 (also called ETSI TS 101812 V1.3.1)
- section 7.4.
-
- https://www.etsi.org/
- https://webapp.etsi.org/workprogram/Report_WorkItem.asp?WKI_ID=18799
-
-[3] Support is rudimentary currently; some tables or data are not
- loaded yet.
-
-[4] See
-
- THE X WINDOW SYSTEM SERVER: X VERSION 11, RELEASE 5
- Elias Israel, Erik Fortune, Digital Press, 1992
- ISBN 1-55558-096-3
-
- for a specification given in Appendix D on pgs. 436-450. However,
- this information might be out of date; unfortunately, there is no
- PCF specification available online, and this book is out of print.
- George Williams deduced the font format from the X11 sources and
- documented it for his FontForge font editor:
-
- https://fontforge.github.io/pcf-format.html
-
-[5] This is from MS Windows 3; see Microsoft's Knowledge Base article
- at
-
- https://support.microsoft.com/kb/65123
-
-[6] Supported font formats are TrueType and OpenType fonts as
- defined in the OpenType specification 1.6 and newer.
-
-[7] `The Type 1 GX Font Format' (dated 1995-09-27) was distributed in
- Apple Developer CD-ROM in those days. The content of `TYP1' table
- is a PostScript Type 1 font without the eexec encryption. Current
- versions of FreeType don't not support this format, but FontForge
- can load it.
-
-------------------------------------------------------------------------
-
-Copyright (C) 2004-2024 by
-David Turner, Robert Wilhelm, and Werner Lemberg.
-
-This file is part of the FreeType project, and may only be used,
-modified, and distributed under the terms of the FreeType project
-license, LICENSE.TXT. By continuing to use, modify, or distribute this
-file you indicate that you have read the license and understand and
-accept it fully.
-
-
---- end of formats.txt ---
-
-Local Variables:
-coding: utf-8
-End:
diff --git a/contrib/libs/freetype/docs/freetype-config.1 b/contrib/libs/freetype/docs/freetype-config.1
deleted file mode 100644
index f52a4e6af4..0000000000
--- a/contrib/libs/freetype/docs/freetype-config.1
+++ /dev/null
@@ -1,146 +0,0 @@
-.TH FREETYPE-CONFIG 1 "August 2024" "FreeType 2.13.3"
-.
-.
-.SH NAME
-.
-freetype-config \- Get information about a libfreetype installation
-.
-.
-.SH SYNOPSIS
-.
-.B freetype-config
-.RI [ options ]
-.
-.
-.SH DESCRIPTION
-.
-.B freetype-config
-returns information needed for compiling and linking programs with the
-FreeType library, such as linker flags and compilation parameters.
-.
-Alternatively, it can be used to query information about the
-FreeType library version installed on the system, such as the
-installation (directory path) prefix or the FreeType version number.
-.
-.PP
-If
-.BR pkg-config (1)
-is found in the path,
-.B freetype-config
-acts as a wrapper for
-.BR pkg-config .
-.
-.PP
-This program is part of the FreeType package.
-.
-.
-.SH OPTIONS
-.
-There are two types of options: output/display selection options, and
-path override options.
-.
-.
-.SS Output selection options
-.
-Only one of the output selection options should be given at each program
-invocation.
-.
-.TP
-.B \-\-prefix
-Return the prefix value of the installed FreeType library (the default
-prefix will be `/usr' in most cases for distribution-installed
-packages).
-.
-.TP
-.B \-\-exec-prefix
-Return the executable prefix value of the installed FreeType library
-(will often be the same as the prefix value).
-.
-.TP
-.B \-\-ftversion
-Return the FreeType version number, directly derived from file
-`freetype.h'.
-.
-.TP
-.B \-\-version
-Return the `libtool version' of the FreeType library.
-.
-.TP
-.B \-\-libtool
-Return the library name for linking with libtool.
-.
-.TP
-.B \-\-libs
-Return compiler flags for linking with the installed FreeType library.
-.
-.TP
-.B \-\-cflags
-Return compiler flags for compiling against the installed FreeType library.
-.
-.TP
-.B \-\-static
-Make command line options display flags for static linking.
-.
-.TP
-.B \-\-help
-Show help and exit.
-.
-.
-.SS Path override options
-.
-These affect any selected output option, except the libtool version
-returned by
-.BR \-\-version .
-.
-.TP
-.BI \-\-prefix= PREFIX
-Override
-.B \-\-prefix
-value with
-.IR PREFIX .
-.
-This also sets
-.BI \-\-exec-prefix= PREFIX
-if option
-.B \-\-exec-prefix
-is not explicitly given.
-.
-.TP
-.BI \-\-exec-prefix= EPREFIX
-Override
-.B \-\-exec-prefix
-value with
-.IR EPREFIX .
-.
-.
-.SH BUGS
-In case the libraries FreeType links to are located in non-standard
-directories, and
-.BR pkg-config (1)
-is not available, the output from option
-.B \-\-libs
-might be incomplete.
-.
-It is thus recommended to use the
-.BR pkg-config (1)
-interface instead, which is able to correctly resolve all dependencies.
-.
-.PP
-Setting
-.B \-\-exec-prefix
-(either explicitly or implicitly) might return incorrect results if
-combined with option
-.BR \-\-static .
-.
-The same problem can occur if you set the
-.B SYSROOT
-environment variable.
-.
-.
-.SH AUTHOR
-.
-This manual page was contributed by Nis Martensen <nis.martensen@web.de>,
-with further refinements from the FreeType team.
-.
-.
-.\" eof
diff --git a/contrib/libs/freetype/docs/freetype-web.txt b/contrib/libs/freetype/docs/freetype-web.txt
deleted file mode 100644
index 0c9140c50b..0000000000
--- a/contrib/libs/freetype/docs/freetype-web.txt
+++ /dev/null
@@ -1,42 +0,0 @@
-How to update the FreeType web pages
-------------------------------------
-
-The 'freetype.org' website is hosted via the 'freetype-web' repo
-located at
-
- https://gitlab.com/freetype/freetype-web ,
-
-which in turn is a mirror from the master 'freetype-web' repository
-located at
-
- https://gitlab.freedesktop.org/freetype/freetype-web .
-
-Due to Cloudflare caching, changes take time to appear on
-'freetype.org', so visit
-
- https://freetype.gitlab.io/freetype-web
-
-for instant feedback.
-
-All the commits should *only* be done to the 'freetype-web' repo at
-
- https://gitlab.freedesktop.org/freetype/freetype-web
-
-When a commit is done to this repo, the CI pipeline runs and the
-website is deployed via gitlab pages at
-
- https://freetype.pages.freedesktop.org/freetype-web .
-
-The pull mirror automatically updates the repository in 'gitlab.com',
-and the CI pipeline deploys the website at:
-
- https://freetype.gitlab.io/freetype-web
-
-Since the 'freetype.org' website uses Cloudflare caching, it will take
-a while for the changes to show up in 'freetype.org'.
-
-If you have access to the Cloudflare dashboard you can purge the
-cache from there; this will cause the cache to be fetched again
-resulting in the website being updated instantly.
-
---- end of freetype-web.txt ---
diff --git a/contrib/libs/freetype/docs/raster.txt b/contrib/libs/freetype/docs/raster.txt
deleted file mode 100644
index d85b662c23..0000000000
--- a/contrib/libs/freetype/docs/raster.txt
+++ /dev/null
@@ -1,635 +0,0 @@
-
- How FreeType's rasterizer work
-
- by David Turner
-
- Revised 2007-Feb-01
-
-
-This file is an attempt to explain the internals of the FreeType
-rasterizer. The rasterizer is of quite general purpose and could
-easily be integrated into other programs.
-
-
- I. Introduction
-
- II. Rendering Technology
- 1. Requirements
- 2. Profiles and Spans
- a. Sweeping the Shape
- b. Decomposing Outlines into Profiles
- c. The Render Pool
- d. Computing Profiles Extents
- e. Computing Profiles Coordinates
- f. Sweeping and Sorting the Spans
-
-
-I. Introduction
-===============
-
- A rasterizer is a library in charge of converting a vectorial
- representation of a shape into a bitmap. The FreeType rasterizer
- has been originally developed to render the glyphs found in
- TrueType files, made up of segments and second-order Béziers.
- Meanwhile it has been extended to render third-order Bézier curves
- also. This document is an explanation of its design and
- implementation.
-
- While these explanations start from the basics, a knowledge of
- common rasterization techniques is assumed.
-
-
-II. Rendering Technology
-========================
-
-1. Requirements
----------------
-
- We assume that all scaling, rotating, hinting, etc., has been
- already done. The glyph is thus described by a list of points in
- the device space.
-
- - All point coordinates are in the 26.6 fixed float format. The
- used orientation is:
-
-
- ^ y
- | reference orientation
- |
- *----> x
- 0
-
-
- `26.6' means that 26 bits are used for the integer part of a
- value and 6 bits are used for the fractional part.
- Consequently, the `distance' between two neighbouring pixels is
- 64 `units' (1 unit = 1/64 of a pixel).
-
- Note that, for the rasterizer, pixel centers are located at
- integer coordinates. The TrueType bytecode interpreter,
- however, assumes that the lower left edge of a pixel (which is
- taken to be a square with a length of 1 unit) has integer
- coordinates.
-
-
- ^ y ^ y
- | |
- | (1,1) | (0.5,0.5)
- +-----------+ +-----+-----+
- | | | | |
- | | | | |
- | | | o-----+-----> x
- | | | (0,0) |
- | | | |
- o-----------+-----> x +-----------+
- (0,0) (-0.5,-0.5)
-
- TrueType bytecode interpreter FreeType rasterizer
-
-
- A pixel line in the target bitmap is called a `scanline'.
-
- - A glyph is usually made of several contours, also called
- `outlines'. A contour is simply a closed curve that delimits an
- outer or inner region of the glyph. It is described by a series
- of successive points of the points table.
-
- Each point of the glyph has an associated flag that indicates
- whether it is `on' or `off' the curve. Two successive `on'
- points indicate a line segment joining the two points.
-
- One `off' point amidst two `on' points indicates a second-degree
- (conic) Bézier parametric arc, defined by these three points
- (the `off' point being the control point, and the `on' ones the
- start and end points). Similarly, a third-degree (cubic) Bézier
- curve is described by four points (two `off' control points
- between two `on' points).
-
- Finally, for second-order curves only, two successive `off'
- points forces the rasterizer to create, during rendering, an
- `on' point amidst them, at their exact middle. This greatly
- facilitates the definition of successive Bézier arcs.
-
- The parametric form of a second-order Bézier curve is:
-
- P(t) = (1-t)^2*P1 + 2*t*(1-t)*P2 + t^2*P3
-
- (P1 and P3 are the end points, P2 the control point.)
-
- The parametric form of a third-order Bézier curve is:
-
- P(t) = (1-t)^3*P1 + 3*t*(1-t)^2*P2 + 3*t^2*(1-t)*P3 + t^3*P4
-
- (P1 and P4 are the end points, P2 and P3 the control points.)
-
- For both formulae, t is a real number in the range [0..1].
-
- Note that the rasterizer does not use these formulae directly.
- They exhibit, however, one very useful property of Bézier arcs:
- Each point of the curve is a weighted average of the control
- points.
-
- As all weights are positive and always sum up to 1, whatever the
- value of t, each arc point lies within the triangle (polygon)
- defined by the arc's three (four) control points.
-
- In the following, only second-order curves are discussed since
- rasterization of third-order curves is completely identical.
-
- Here some samples for second-order curves.
-
-
- * # on curve
- * off curve
- __---__
- #-__ _-- -_
- --__ _- -
- --__ # \
- --__ #
- -#
- Two `on' points
- Two `on' points and one `off' point
- between them
-
- *
- # __ Two `on' points with two `off'
- \ - - points between them. The point
- \ / \ marked `0' is the middle of the
- - 0 \ `off' points, and is a `virtual
- -_ _- # on' point where the curve passes.
- -- It does not appear in the point
- * list.
-
-
-2. Profiles and Spans
----------------------
-
- The following is a basic explanation of the _kind_ of computations
- made by the rasterizer to build a bitmap from a vector
- representation. Note that the actual implementation is slightly
- different, due to performance tuning and other factors.
-
- However, the following ideas remain in the same category, and are
- more convenient to understand.
-
-
- a. Sweeping the Shape
-
- The best way to fill a shape is to decompose it into a number of
- simple horizontal segments, then turn them on in the target
- bitmap. These segments are called `spans'.
-
- __---__
- _-- -_
- _- -
- - \
- / \
- / \
- | \
-
- __---__ Example: filling a shape
- _----------_ with spans.
- _--------------
- ----------------\
- /-----------------\ This is typically done from the top
- / \ to the bottom of the shape, in a
- | | \ movement called a `sweep'.
- V
-
- __---__
- _----------_
- _--------------
- ----------------\
- /-----------------\
- /-------------------\
- |---------------------\
-
-
- In order to draw a span, the rasterizer must compute its
- coordinates, which are simply the x coordinates of the shape's
- contours, taken on the y scanlines.
-
-
- /---/ |---| Note that there are usually
- /---/ |---| several spans per scanline.
- | /---/ |---|
- | /---/_______|---| When rendering this shape to the
- V /----------------| current scanline y, we must
- /-----------------| compute the x values of the
- a /----| |---| points a, b, c, and d.
- - - - * * - - - - * * - - y -
- / / b c| |d
-
-
- /---/ |---|
- /---/ |---| And then turn on the spans a-b
- /---/ |---| and c-d.
- /---/_______|---|
- /----------------|
- /-----------------|
- a /----| |---|
- - - - ####### - - - - ##### - - y -
- / / b c| |d
-
-
- b. Decomposing Outlines into Profiles
-
- For each scanline during the sweep, we need the following
- information:
-
- o The number of spans on the current scanline, given by the
- number of shape points intersecting the scanline (these are
- the points a, b, c, and d in the above example).
-
- o The x coordinates of these points.
-
- x coordinates are computed before the sweep, in a phase called
- `decomposition' which converts the glyph into *profiles*.
-
- Put it simply, a `profile' is a contour's portion that can only
- be either ascending or descending, i.e., it is monotonic in the
- vertical direction (we also say y-monotonic). There is no such
- thing as a horizontal profile, as we shall see.
-
- Here are a few examples:
-
-
- this square
- 1 2
- ---->---- is made of two
- | | | |
- | | profiles | |
- ^ v ^ + v
- | | | |
- | | | |
- ----<----
-
- up down
-
-
- this triangle
-
- P2 1 2
-
- |\ is made of two | \
- ^ | \ \ | \
- | | \ \ profiles | \ |
- | | \ v ^ | \ |
- | \ | | + \ v
- | \ | | \
- P1 ---___ \ ---___ \
- ---_\ ---_ \
- <--__ P3 up down
-
-
-
- A more general contour can be made of more than two profiles:
-
- __ ^
- / | / ___ / |
- / | / | / | / |
- | | / / => | v / /
- | | | | | | ^ |
- ^ | |___| | | ^ + | + | + v
- | | | v | |
- | | | up |
- |___________| | down |
-
- <-- up down
-
-
- Successive profiles are always joined by horizontal segments
- that are not part of the profiles themselves.
-
- For the rasterizer, a profile is simply an *array* that
- associates one horizontal *pixel* coordinate to each bitmap
- *scanline* crossed by the contour's section containing the
- profile. Note that profiles are *oriented* up or down along the
- glyph's original flow orientation.
-
- In other graphics libraries, profiles are also called `edges' or
- `edgelists'.
-
-
- c. The Render Pool
-
- FreeType has been designed to be able to run well on _very_
- light systems, including embedded systems with very few memory.
-
- A render pool will be allocated once; the rasterizer uses this
- pool for all its needs by managing this memory directly in it.
- The algorithms that are used for profile computation make it
- possible to use the pool as a simple growing heap. This means
- that this memory management is actually quite easy and faster
- than any kind of malloc()/free() combination.
-
- Moreover, we'll see later that the rasterizer is able, when
- dealing with profiles too large and numerous to lie all at once
- in the render pool, to immediately decompose recursively the
- rendering process into independent sub-tasks, each taking less
- memory to be performed (see `sub-banding' below).
-
- The render pool doesn't need to be large. A 4KByte pool is
- enough for nearly all renditions, though nearly 100% slower than
- a more comfortable 16KByte or 32KByte pool (that was tested with
- complex glyphs at sizes over 500 pixels).
-
-
- d. Computing Profiles Extents
-
- Remember that a profile is an array, associating a _scanline_ to
- the x pixel coordinate of its intersection with a contour.
-
- Though it's not exactly how the FreeType rasterizer works, it is
- convenient to think that we need a profile's height before
- allocating it in the pool and computing its coordinates.
-
- The profile's height is the number of scanlines crossed by the
- y-monotonic section of a contour. We thus need to compute these
- sections from the vectorial description. In order to do that,
- we are obliged to compute all (local and global) y extrema of
- the glyph (minima and maxima).
-
-
- P2 For instance, this triangle has only
- two y-extrema, which are simply
- |\
- | \ P2.y as a vertical maximum
- | \ P3.y as a vertical minimum
- | \
- | \ P1.y is not a vertical extremum (though
- | \ it is a horizontal minimum, which we
- P1 ---___ \ don't need).
- ---_\
- P3
-
-
- Note that the extrema are expressed in pixel units, not in
- scanlines. The triangle's height is certainly (P3.y-P2.y+1)
- pixel units, but its profiles' heights are computed in
- scanlines. The exact conversion is simple:
-
- - min scanline = FLOOR ( min y )
- - max scanline = CEILING( max y )
-
- A problem arises with Bézier Arcs. While a segment is always
- necessarily y-monotonic (i.e., flat, ascending, or descending),
- which makes extrema computations easy, the ascent of an arc can
- vary between its control points.
-
-
- P2
- *
- # on curve
- * off curve
- __-x--_
- _-- -_
- P1 _- - A non y-monotonic Bézier arc.
- # \
- - The arc goes from P1 to P3.
- \
- \ P3
- #
-
-
- We first need to be able to easily detect non-monotonic arcs,
- according to their control points. I will state here, without
- proof, that the monotony condition can be expressed as:
-
- P1.y <= P2.y <= P3.y for an ever-ascending arc
-
- P1.y >= P2.y >= P3.y for an ever-descending arc
-
- with the special case of
-
- P1.y = P2.y = P3.y where the arc is said to be `flat'.
-
- As you can see, these conditions can be very easily tested.
- They are, however, extremely important, as any arc that does not
- satisfy them necessarily contains an extremum.
-
- Note also that a monotonic arc can contain an extremum too,
- which is then one of its `on' points:
-
-
- P1 P2
- #---__ * P1P2P3 is ever-descending, but P1
- -_ is an y-extremum.
- -
- ---_ \
- -> \
- \ P3
- #
-
-
- Let's go back to our previous example:
-
-
- P2
- *
- # on curve
- * off curve
- __-x--_
- _-- -_
- P1 _- - A non-y-monotonic Bézier arc.
- # \
- - Here we have
- \ P2.y >= P1.y &&
- \ P3 P2.y >= P3.y (!)
- #
-
-
- We need to compute the vertical maximum of this arc to be able
- to compute a profile's height (the point marked by an `x'). The
- arc's equation indicates that a direct computation is possible,
- but we rely on a different technique, which use will become
- apparent soon.
-
- Bézier arcs have the special property of being very easily
- decomposed into two sub-arcs, which are themselves Bézier arcs.
- Moreover, it is easy to prove that there is at most one vertical
- extremum on each Bézier arc (for second-degree curves; similar
- conditions can be found for third-order arcs).
-
- For instance, the following arc P1P2P3 can be decomposed into
- two sub-arcs Q1Q2Q3 and R1R2R3:
-
-
- P2
- *
- # on curve
- * off curve
-
-
- original Bézier arc P1P2P3.
- __---__
- _-- --_
- _- -_
- - -
- / \
- / \
- # #
- P1 P3
-
-
-
- P2
- *
-
-
-
- Q3 Decomposed into two subarcs
- Q2 R2 Q1Q2Q3 and R1R2R3
- * __-#-__ *
- _-- --_
- _- R1 -_ Q1 = P1 R3 = P3
- - - Q2 = (P1+P2)/2 R2 = (P2+P3)/2
- / \
- / \ Q3 = R1 = (Q2+R2)/2
- # #
- Q1 R3 Note that Q2, R2, and Q3=R1
- are on a single line which is
- tangent to the curve.
-
-
- We have then decomposed a non-y-monotonic Bézier curve into two
- smaller sub-arcs. Note that in the above drawing, both sub-arcs
- are monotonic, and that the extremum is then Q3=R1. However, in
- a more general case, only one sub-arc is guaranteed to be
- monotonic. Getting back to our former example:
-
-
- Q2
- *
-
- __-x--_ R1
- _-- #_
- Q1 _- Q3 - R2
- # \ *
- -
- \
- \ R3
- #
-
-
- Here, we see that, though Q1Q2Q3 is still non-monotonic, R1R2R3
- is ever descending: We thus know that it doesn't contain the
- extremum. We can then re-subdivide Q1Q2Q3 into two sub-arcs and
- go on recursively, stopping when we encounter two monotonic
- subarcs, or when the subarcs become simply too small.
-
- We will finally find the vertical extremum. Note that the
- iterative process of finding an extremum is called `flattening'.
-
-
- e. Computing Profiles Coordinates
-
- Once we have the height of each profile, we are able to allocate
- it in the render pool. The next task is to compute coordinates
- for each scanline.
-
- In the case of segments, the computation is straightforward,
- using the Euclidean algorithm (also known as Bresenham).
- However, for Bézier arcs, the job is a little more complicated.
-
- We assume that all Béziers that are part of a profile are the
- result of flattening the curve, which means that they are all
- y-monotonic (ascending or descending, and never flat). We now
- have to compute the intersections of arcs with the profile's
- scanlines. One way is to use a similar scheme to flattening
- called `stepping'.
-
-
- Consider this arc, going from P1 to
- --------------------- P3. Suppose that we need to
- compute its intersections with the
- drawn scanlines. As already
- --------------------- mentioned this can be done
- directly, but the involved
- * P2 _---# P3 algorithm is far too slow.
- ------------- _-- --
- _-
- _/ Instead, it is still possible to
- ---------/----------- use the decomposition property in
- / the same recursive way, i.e.,
- | subdivide the arc into subarcs
- ------|-------------- until these get too small to cross
- | more than one scanline!
- |
- -----|--------------- This is very easily done using a
- | rasterizer-managed stack of
- | subarcs.
- # P1
-
-
- f. Sweeping and Sorting the Spans
-
- Once all our profiles have been computed, we begin the sweep to
- build (and fill) the spans.
-
- As both the TrueType and Type 1 specifications use the winding
- fill rule (but with opposite directions), we place, on each
- scanline, the present profiles in two separate lists.
-
- One list, called the `left' one, only contains ascending
- profiles, while the other `right' list contains the descending
- profiles.
-
- As each glyph is made of closed curves, a simple geometric
- property ensures that the two lists contain the same number of
- elements.
-
- Creating spans is thus straightforward:
-
- 1. We sort each list in increasing horizontal order.
-
- 2. We pair each value of the left list with its corresponding
- value in the right list.
-
-
- / / | | For example, we have here
- / / | | four profiles. Two of
- >/ / | | | them are ascending (1 &
- 1// / ^ | | | 2 3), while the two others
- // // 3| | | v are descending (2 & 4).
- / //4 | | | On the given scanline,
- a / /< | | the left list is (1,3),
- - - - *-----* - - - - *---* - - y - and the right one is
- / / b c| |d (4,2) (sorted).
-
- There are then two spans, joining
- 1 to 4 (i.e. a-b) and 3 to 2
- (i.e. c-d)!
-
-
- Sorting doesn't necessarily take much time, as in 99 cases out
- of 100, the lists' order is kept from one scanline to the next.
- We can thus implement it with two simple singly-linked lists,
- sorted by a classic bubble-sort, which takes a minimum amount of
- time when the lists are already sorted.
-
- A previous version of the rasterizer used more elaborate
- structures, like arrays to perform `faster' sorting. It turned
- out that this old scheme is not faster than the one described
- above.
-
- Once the spans have been `created', we can simply draw them in
- the target bitmap.
-
-------------------------------------------------------------------------
-
-Copyright (C) 2003-2024 by
-David Turner, Robert Wilhelm, and Werner Lemberg.
-
-This file is part of the FreeType project, and may only be used,
-modified, and distributed under the terms of the FreeType project
-license, LICENSE.TXT. By continuing to use, modify, or distribute this
-file you indicate that you have read the license and understand and
-accept it fully.
-
-
---- end of raster.txt ---
-
-Local Variables:
-coding: utf-8
-End:
diff --git a/contrib/libs/freetype/docs/release b/contrib/libs/freetype/docs/release
deleted file mode 100644
index 90ceb86883..0000000000
--- a/contrib/libs/freetype/docs/release
+++ /dev/null
@@ -1,224 +0,0 @@
-How to prepare a new release
-----------------------------
-
-. include/freetype/freetype.h: Update `FREETYPE_MAJOR`,
- `FREETYPE_MINOR`, and `FREETYPE_PATCH`.
-
-. Update version numbers in all files where necessary (for example, do
- a grep for both '2.13.2' and '2132' for release 2.13.2).
-
-. builds/unix/configure.raw: Update `version_info`.
-
-. docs/CHANGES: Document differences to last release.
-
-. README: Update.
-
-. docs/VERSIONS.TXT: Document changed `version_info`.
-
-. Update the 'dlg' submodule with
-
- git submodule foreach git pull origin master
-
-. Copy the submodule code with
-
- make copy_submodule
-
- and run
-
- make distclean && make devel && make
- make distclean && make devel && make multi
- make distclean && make devel CC=g++ && make CC=g++ ANSIFLAGS=""
- make distclean && make devel CC=g++ && make multi CC=g++ ANSIFLAGS=""
-
- sh autogen.sh
- make distclean && ./configure CC=g++ && make ANSIFLAGS=""
-
- to test compilation with both gcc and g++ (you might also add the `-j`
- flag to `make` for parallel compilation).
-
- Note that it is normally not necessary to test standard C
- compilation with the `configure`, `meson`, and `cmake` build tools
- since this is done by the CI process of 'gitlab.freedesktop.org' for
- every commit.
-
-. Test C++ compilation for 'freetype-demos' too; this needs a compiled
- FreeType library as described in the `README` file.
-
- make distclean && make
- make distclean && make CC=g++ ANSIFLAGS=""
-
-. Run `src/tools/chktrcmp.py` and check that there are no undefined
- `trace_XXXX` macros.
-
-. Update meson subproject files (for both the 'freetype' and
- 'freetype-demos' git repositories) with
-
- meson subprojects update
-
-. Test meson compilation (for both the 'freetype' and 'freetype-demos'
- git repositories) with
-
- meson setup builddir && meson compile -C builddir
-
-. Commit everything.
-
-. After pushing the new release, tag the git repositories ('freetype',
- 'freetype-demos') with
-
- git tag VER-<version> -m "" -u <committer>
-
- and push the tags with
-
- git push --tags
-
-. Check with
-
- git clean -ndx
-
- that the git directory is really clean (and remove extraneous files
- if necessary).
-
-. Say `make dist` in both the 'freetype' and 'freetype-demos'
- repositories to generate the `.tar.gz`, `.tar.xz`, and `.zip` files.
-
-. Create the doc bundles (`freetype-doc-<version>.tar.gz`,
- `freetype-doc-<version>.tar.xz`, `ftdoc<version>.zip`). This is
- everything in
-
- <freetype-web git repository>/freetype2/docs
-
- except the `reference` subdirectory. Do *not* use option `-l` from
- zip!
-
-. Run the following script (with updated `$VERSION`, `$SAVANNAH_USER`,
- `$SOURCEFORGE_USER`, and `GPG_KEY_ID` variables) to sign and upload
- the bundles to both Savannah and SourceForge. The signing code has
- been taken from the `gnupload` script (part of the 'automake'
- bundle).
-
- #!/bin/sh
-
- VERSION=2.13.2
- SAVANNAH_USER=wl
- SOURCEFORGE_USER=wlemb
- GPG_KEY_ID=BE6C3AAC63AD8E3F
-
- #####################################################################
-
- GPG="/usr/bin/gpg --batch --no-tty --local-user $GPG_KEY_ID"
-
- version=`echo $VERSION | sed "s/\\.//g"`
-
- FREETYPE_PACKAGES="freetype-$VERSION.tar.gz \
- freetype-$VERSION.tar.xz \
- ft$version.zip"
- FT2DEMOS_PACKAGES="ft2demos-$VERSION.tar.gz \
- ft2demos-$VERSION.tar.xz \
- ftdmo$version.zip"
- FTDOC_PACKAGES="freetype-doc-$VERSION.tar.gz \
- freetype-doc-$VERSION.tar.xz \
- ftdoc$version.zip"
-
- PACKAGE_LIST="$FREETYPE_PACKAGES \
- $FT2DEMOS_PACKAGES \
- $FTDOC_PACKAGES"
-
- set -e
- unset passphrase
-
- PATH=/empty echo -n "Enter GPG passphrase: "
- stty -echo
- read -r passphrase
- stty echo
- echo
-
- for f in $PACKAGE_LIST; do
- if test ! -f $f; then
- echo "$0: Cannot find \`$f'" 1>&2
- exit 1
- else
- :
- fi
- done
-
- for f in $PACKAGE_LIST; do
- echo "Signing $f..."
- rm -f $f.sig
- echo $passphrase | $GPG --passphrase-fd 0 -ba -o $f.sig $f
- done
-
- FREETYPE_SIGNATURES=
- for i in $FREETYPE_PACKAGES; do
- FREETYPE_SIGNATURES="$FREETYPE_SIGNATURES $i.sig"
- done
-
- FT2DEMOS_SIGNATURES=
- for i in $FT2DEMOS_PACKAGES; do
- FT2DEMOS_SIGNATURES="$FT2DEMOS_SIGNATURES $i.sig"
- done
-
- FTDOC_SIGNATURES=
- for i in $FTDOC_PACKAGES; do
- FTDOC_SIGNATURES="$FTDOC_SIGNATURES $i.sig"
- done
-
- SIGNATURE_LIST="$FREETYPE_SIGNATURES \
- $FT2DEMOS_SIGNATURES \
- $FTDOC_SIGNATURES"
-
- scp $PACKAGE_LIST $SIGNATURE_LIST \
- $SAVANNAH_USER@dl.sv.nongnu.org:/releases/freetype/
-
- rsync -avP -e ssh $FREETYPE_PACKAGES $FREETYPE_SIGNATURES \
- $SOURCEFORGE_USER,freetype@frs.sf.net:/home/frs/project/f/fr/freetype/freetype2/$VERSION/
- rsync -avP -e ssh $FT2DEMOS_PACKAGES $FT2DEMOS_SIGNATURES \
- $SOURCEFORGE_USER,freetype@frs.sf.net:/home/frs/project/f/fr/freetype/freetype-demos/$VERSION/
- rsync -avP -e ssh $FTDOC_PACKAGES $FTDOC_SIGNATURES \
- $SOURCEFORGE_USER,freetype@frs.sf.net:/home/frs/project/f/fr/freetype/freetype-docs/$VERSION/
-
- # EOF
-
-. Prepare a `README` file for SourceForge and upload it with the
- following script (with updated `$VERSION` and `$SOURCEFORGE_USER`
- variables).
-
- #!/bin/sh
-
- VERSION=2.13.2
- SOURCEFORGE_USER=wlemb
-
- #####################################################################
-
- rsync -avP -e ssh README \
- $SOURCEFORGE_USER,freetype@frs.sf.net:/home/frs/project/f/fr/freetype/freetype2/$VERSION/
-
- # EOF
-
-. On SourceForge, tag the just uploaded `ftXXX.zip` and
- `freetype-XXX.tar.xz` files as the default files to download for
- 'Windows' and 'Others', respectively.
-
-. Trigger the automatic generation of the online API reference by
- updating the `FT_VERSION` variable in file `.gitlab-ci.yml` of the
- 'freetype-web' repository.
-
-. Announce new release on 'freetype-announce@nongnu.org' and to
- relevant newsgroups. The text should include
-
- - SHA256 checksums of all files,
- - instructions how to verify the bundles using the `.sig` file data,
- - the PGP public key used to sign the archives.
-
-----------------------------------------------------------------------
-
-Copyright (C) 2003-2024 by
-David Turner, Robert Wilhelm, and Werner Lemberg.
-
-This file is part of the FreeType project, and may only be used,
-modified, and distributed under the terms of the FreeType project
-license, LICENSE.TXT. By continuing to use, modify, or distribute
-this file you indicate that you have read the license and understand
-and accept it fully.
-
-
---- end of release ---
diff --git a/contrib/libs/freetype/include/dlg/dlg.h b/contrib/libs/freetype/include/dlg/dlg.h
deleted file mode 100644
index fa10730e83..0000000000
--- a/contrib/libs/freetype/include/dlg/dlg.h
+++ /dev/null
@@ -1,290 +0,0 @@
-// Copyright (c) 2019 nyorain
-// Distributed under the Boost Software License, Version 1.0.
-// See accompanying file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt
-
-#ifndef INC_DLG_DLG_H_
-#define INC_DLG_DLG_H_
-
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <stdio.h>
-
-// Hosted at https://github.com/nyorain/dlg.
-// There are examples and documentation.
-// Issue reports and contributions appreciated.
-
-// - CONFIG -
-// Define this macro to make all dlg macros have no effect at all
-// #define DLG_DISABLE
-
-// the log/assertion levels below which logs/assertions are ignored
-// defaulted depending on the NDEBUG macro
-#ifndef DLG_LOG_LEVEL
- #ifdef NDEBUG
- #define DLG_LOG_LEVEL dlg_level_warn
- #else
- #define DLG_LOG_LEVEL dlg_level_trace
- #endif
-#endif
-
-#ifndef DLG_ASSERT_LEVEL
- #ifdef NDEBUG
- #define DLG_ASSERT_LEVEL dlg_level_warn
- #else
- #define DLG_ASSERT_LEVEL dlg_level_trace
- #endif
-#endif
-
-// the assert level of dlg_assert
-#ifndef DLG_DEFAULT_ASSERT
- #define DLG_DEFAULT_ASSERT dlg_level_error
-#endif
-
-// evaluated to the 'file' member in dlg_origin
-#ifndef DLG_FILE
- #define DLG_FILE dlg__strip_root_path(__FILE__, DLG_BASE_PATH)
-
- // the base path stripped from __FILE__. If you don't override DLG_FILE set this to
- // the project root to make 'main.c' from '/some/bullshit/main.c'
- #ifndef DLG_BASE_PATH
- #define DLG_BASE_PATH ""
- #endif
-#endif
-
-// Default tags applied to all logs/assertions (in the defining file).
-// Must be in format ```#define DLG_DEFAULT_TAGS "tag1", "tag2"```
-// or just nothing (as defaulted here)
-#ifndef DLG_DEFAULT_TAGS
- #define DLG_DEFAULT_TAGS_TERM NULL
-#else
- #define DLG_DEFAULT_TAGS_TERM DLG_DEFAULT_TAGS, NULL
-#endif
-
-// The function used for formatting. Can have any signature, but must be callable with
-// the arguments the log/assertions macros are called with. Must return a const char*
-// that will not be freed by dlg, the formatting function must keep track of it.
-// The formatting function might use dlg_thread_buffer or a custom owned buffer.
-// The returned const char* has to be valid until the dlg log/assertion ends.
-// Usually a c function with ... (i.e. using va_list) or a variadic c++ template do
-// allow formatting.
-#ifndef DLG_FMT_FUNC
- #define DLG_FMT_FUNC dlg__printf_format
-#endif
-
-// Only overwrite (i.e. predefine) this if you know what you are doing.
-// On windows this is used to add the dllimport specified.
-// If you are using the static version of dlg (on windows) define
-// DLG_STATIC before including dlg.h
-#ifndef DLG_API
- #if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(DLG_STATIC)
- #define DLG_API __declspec(dllimport)
- #else
- #define DLG_API
- #endif
-#endif
-
-// This macro is used when an assertion fails. It gets the source expression
-// and can return an alternative (that must stay alive).
-// Mainly useful to execute something on failed assertion.
-#ifndef DLG_FAILED_ASSERTION_TEXT
- #define DLG_FAILED_ASSERTION_TEXT(x) x
-#endif
-
-// - utility -
-// two methods needed since cplusplus does not support compound literals
-// and c does not support uniform initialization/initializer lists
-#ifdef __cplusplus
- #include <initializer_list>
- #define DLG_CREATE_TAGS(...) std::initializer_list<const char*> \
- {DLG_DEFAULT_TAGS_TERM, __VA_ARGS__, NULL}.begin()
-#else
- #define DLG_CREATE_TAGS(...) (const char* const[]) {DLG_DEFAULT_TAGS_TERM, __VA_ARGS__, NULL}
-#endif
-
-#ifdef __GNUC__
- #define DLG_PRINTF_ATTRIB(a, b) __attribute__ ((format (printf, a, b)))
-#else
- #define DLG_PRINTF_ATTRIB(a, b)
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-// Represents the importance of a log/assertion call.
-enum dlg_level {
- dlg_level_trace = 0, // temporary used debug, e.g. to check if control reaches function
- dlg_level_debug, // general debugging, prints e.g. all major events
- dlg_level_info, // general useful information
- dlg_level_warn, // warning, something went wrong but might have no (really bad) side effect
- dlg_level_error, // something really went wrong; expect serious issues
- dlg_level_fatal // critical error; application is likely to crash/exit
-};
-
-// Holds various information associated with a log/assertion call.
-// Forwarded to the output handler.
-struct dlg_origin {
- const char* file;
- unsigned int line;
- const char* func;
- enum dlg_level level;
- const char** tags; // null-terminated
- const char* expr; // assertion expression, otherwise null
-};
-
-// Type of the output handler, see dlg_set_handler.
-typedef void(*dlg_handler)(const struct dlg_origin* origin, const char* string, void* data);
-
-#ifndef DLG_DISABLE
- // Tagged/Untagged logging with variable level
- // Tags must always be in the format `("tag1", "tag2")` (including brackets)
- // Example usages:
- // dlg_log(dlg_level_warning, "test 1")
- // dlg_logt(("tag1, "tag2"), dlg_level_debug, "test %d", 2)
- #define dlg_log(level, ...) if(level >= DLG_LOG_LEVEL) \
- dlg__do_log(level, DLG_CREATE_TAGS(NULL), DLG_FILE, __LINE__, __func__, \
- DLG_FMT_FUNC(__VA_ARGS__), NULL)
- #define dlg_logt(level, tags, ...) if(level >= DLG_LOG_LEVEL) \
- dlg__do_log(level, DLG_CREATE_TAGS tags, DLG_FILE, __LINE__, __func__, \
- DLG_FMT_FUNC(__VA_ARGS__), NULL)
-
- // Dynamic level assert macros in various versions for additional arguments
- // Example usages:
- // dlg_assertl(dlg_level_warning, data != nullptr);
- // dlg_assertlt(("tag1, "tag2"), dlg_level_trace, data != nullptr);
- // dlg_asserttlm(("tag1), dlg_level_warning, data != nullptr, "Data must not be null");
- // dlg_assertlm(dlg_level_error, data != nullptr, "Data must not be null");
- #define dlg_assertl(level, expr) if(level >= DLG_ASSERT_LEVEL && !(expr)) \
- dlg__do_log(level, DLG_CREATE_TAGS(NULL), DLG_FILE, __LINE__, __func__, NULL, \
- DLG_FAILED_ASSERTION_TEXT(#expr))
- #define dlg_assertlt(level, tags, expr) if(level >= DLG_ASSERT_LEVEL && !(expr)) \
- dlg__do_log(level, DLG_CREATE_TAGS tags, DLG_FILE, __LINE__, __func__, NULL, \
- DLG_FAILED_ASSERTION_TEXT(#expr))
- #define dlg_assertlm(level, expr, ...) if(level >= DLG_ASSERT_LEVEL && !(expr)) \
- dlg__do_log(level, DLG_CREATE_TAGS(NULL), DLG_FILE, __LINE__, __func__, \
- DLG_FMT_FUNC(__VA_ARGS__), DLG_FAILED_ASSERTION_TEXT(#expr))
- #define dlg_assertltm(level, tags, expr, ...) if(level >= DLG_ASSERT_LEVEL && !(expr)) \
- dlg__do_log(level, DLG_CREATE_TAGS tags, DLG_FILE, __LINE__, \
- __func__, DLG_FMT_FUNC(__VA_ARGS__), DLG_FAILED_ASSERTION_TEXT(#expr))
-
- #define dlg__assert_or(level, tags, expr, code, msg) if(!(expr)) {\
- if(level >= DLG_ASSERT_LEVEL) \
- dlg__do_log(level, tags, DLG_FILE, __LINE__, __func__, msg, \
- DLG_FAILED_ASSERTION_TEXT(#expr)); \
- code; \
- } (void) NULL
-
- // - Private interface: not part of the abi/api but needed in macros -
- // Formats the given format string and arguments as printf would, uses the thread buffer.
- DLG_API const char* dlg__printf_format(const char* format, ...) DLG_PRINTF_ATTRIB(1, 2);
- DLG_API void dlg__do_log(enum dlg_level lvl, const char* const*, const char*, int,
- const char*, const char*, const char*);
- DLG_API const char* dlg__strip_root_path(const char* file, const char* base);
-
-#else // DLG_DISABLE
-
- #define dlg_log(level, ...)
- #define dlg_logt(level, tags, ...)
-
- #define dlg_assertl(level, expr) // assert without tags/message
- #define dlg_assertlt(level, tags, expr) // assert with tags
- #define dlg_assertlm(level, expr, ...) // assert with message
- #define dlg_assertltm(level, tags, expr, ...) // assert with tags & message
-
- #define dlg__assert_or(level, tags, expr, code, msg) if(!(expr)) { code; } (void) NULL
-#endif // DLG_DISABLE
-
-// The API below is independent from DLG_DISABLE
-
-// Sets the handler that is responsible for formatting and outputting log calls.
-// This function is not thread safe and the handler is set globally.
-// The handler itself must not change dlg tags or call a dlg macro (if it
-// does so, the provided string or tags array in 'origin' might get invalid).
-// The handler can also be used for various other things such as dealing
-// with failed assertions or filtering calls based on the passed tags.
-// The default handler is dlg_default_output (see its doc for more info).
-// If using c++ make sure the registered handler cannot throw e.g. by
-// wrapping everything into a try-catch blog.
-DLG_API void dlg_set_handler(dlg_handler handler, void* data);
-
-// The default output handler.
-// Only use this to reset the output handler, prefer to use
-// dlg_generic_output (from output.h) which this function simply calls.
-// It also flushes the stream used and correctly outputs even from multiple threads.
-DLG_API void dlg_default_output(const struct dlg_origin*, const char* string, void*);
-
-// Returns the currently active dlg handler and sets `data` to
-// its user data pointer. `data` must not be NULL.
-// Useful to create handler chains.
-// This function is not threadsafe, i.e. retrieving the handler while
-// changing it from another thread is unsafe.
-// See `dlg_set_handler`.
-DLG_API dlg_handler dlg_get_handler(void** data);
-
-// Adds the given tag associated with the given function to the thread specific list.
-// If func is not NULL the tag will only applied to calls from the same function.
-// Remove the tag again calling dlg_remove_tag (with exactly the same pointers!).
-// Does not check if the tag is already present.
-DLG_API void dlg_add_tag(const char* tag, const char* func);
-
-// Removes a tag added with dlg_add_tag (has no effect for tags no present).
-// The pointers must be exactly the same pointers that were supplied to dlg_add_tag,
-// this function will not check using strcmp. When the same tag/func combination
-// is added multiple times, this function remove exactly one candidate, it is
-// undefined which. Returns whether a tag was found (and removed).
-DLG_API bool dlg_remove_tag(const char* tag, const char* func);
-
-// Returns the thread-specific buffer and its size for dlg.
-// The buffer should only be used by formatting functions.
-// The buffer can be reallocated and the size changed, just make sure
-// to update both values correctly.
-DLG_API char** dlg_thread_buffer(size_t** size);
-
-// Untagged leveled logging
-#define dlg_trace(...) dlg_log(dlg_level_trace, __VA_ARGS__)
-#define dlg_debug(...) dlg_log(dlg_level_debug, __VA_ARGS__)
-#define dlg_info(...) dlg_log(dlg_level_info, __VA_ARGS__)
-#define dlg_warn(...) dlg_log(dlg_level_warn, __VA_ARGS__)
-#define dlg_error(...) dlg_log(dlg_level_error, __VA_ARGS__)
-#define dlg_fatal(...) dlg_log(dlg_level_fatal, __VA_ARGS__)
-
-// Tagged leveled logging
-#define dlg_tracet(tags, ...) dlg_logt(dlg_level_trace, tags, __VA_ARGS__)
-#define dlg_debugt(tags, ...) dlg_logt(dlg_level_debug, tags, __VA_ARGS__)
-#define dlg_infot(tags, ...) dlg_logt(dlg_level_info, tags, __VA_ARGS__)
-#define dlg_warnt(tags, ...) dlg_logt(dlg_level_warn, tags, __VA_ARGS__)
-#define dlg_errort(tags, ...) dlg_logt(dlg_level_error, tags, __VA_ARGS__)
-#define dlg_fatalt(tags, ...) dlg_logt(dlg_level_fatal, tags, __VA_ARGS__)
-
-// Assert macros useing DLG_DEFAULT_ASSERT as level
-#define dlg_assert(expr) dlg_assertl(DLG_DEFAULT_ASSERT, expr)
-#define dlg_assertt(tags, expr) dlg_assertlt(DLG_DEFAULT_ASSERT, tags, expr)
-#define dlg_assertm(expr, ...) dlg_assertlm(DLG_DEFAULT_ASSERT, expr, __VA_ARGS__)
-#define dlg_asserttm(tags, expr, ...) dlg_assertltm(DLG_DEFAULT_ASSERT, tags, expr, __VA_ARGS__)
-
-// If (expr) does not evaluate to true, always executes 'code' (no matter what
-// DLG_ASSERT_LEVEL is or if dlg is disabled or not).
-// When dlg is enabled and the level is greater or equal to DLG_ASSERT_LEVEL,
-// logs the failed assertion.
-// Example usages:
-// dlg_assertl_or(dlg_level_warn, data != nullptr, return);
-// dlg_assertlm_or(dlg_level_fatal, data != nullptr, return, "Data must not be null");
-// dlg_assert_or(data != nullptr, logError(); return false);
-#define dlg_assertltm_or(level, tags, expr, code, ...) dlg__assert_or(level, \
- DLG_CREATE_TAGS tags, expr, code, DLG_FMT_FUNC(__VA_ARGS__))
-#define dlg_assertlm_or(level, expr, code, ...) dlg__assert_or(level, \
- DLG_CREATE_TAGS(NULL), expr, code, DLG_FMT_FUNC(__VA_ARGS__))
-#define dlg_assertl_or(level, expr, code) dlg__assert_or(level, \
- DLG_CREATE_TAGS(NULL), expr, code, NULL)
-
-#define dlg_assert_or(expr, code) dlg_assertl_or(DLG_DEFAULT_ASSERT, expr, code)
-#define dlg_assertm_or(expr, code, ...) dlg_assertlm_or(DLG_DEFAULT_ASSERT, expr, code, __VA_ARGS__)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // header guard
diff --git a/contrib/libs/freetype/include/dlg/output.h b/contrib/libs/freetype/include/dlg/output.h
deleted file mode 100644
index 453e4a5613..0000000000
--- a/contrib/libs/freetype/include/dlg/output.h
+++ /dev/null
@@ -1,172 +0,0 @@
-// Copyright (c) 2019 nyorain
-// Distributed under the Boost Software License, Version 1.0.
-// See accompanying file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt
-
-#ifndef INC_DLG_OUTPUT_H_
-#define INC_DLG_OUTPUT_H_
-
-#include <dlg/dlg.h>
-#include <stdio.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// Text style
-enum dlg_text_style {
- dlg_text_style_reset = 0,
- dlg_text_style_bold = 1,
- dlg_text_style_dim = 2,
- dlg_text_style_italic = 3,
- dlg_text_style_underline = 4,
- dlg_text_style_blink = 5,
- dlg_text_style_rblink = 6,
- dlg_text_style_reversed = 7,
- dlg_text_style_conceal = 8,
- dlg_text_style_crossed = 9,
- dlg_text_style_none,
-};
-
-// Text color
-enum dlg_color {
- dlg_color_black = 0,
- dlg_color_red,
- dlg_color_green,
- dlg_color_yellow,
- dlg_color_blue,
- dlg_color_magenta,
- dlg_color_cyan,
- dlg_color_gray,
- dlg_color_reset = 9,
-
- dlg_color_black2 = 60,
- dlg_color_red2,
- dlg_color_green2,
- dlg_color_yellow2,
- dlg_color_blue2,
- dlg_color_magenta2,
- dlg_color_cyan2,
- dlg_color_gray2,
-
- dlg_color_none = 69,
-};
-
-struct dlg_style {
- enum dlg_text_style style;
- enum dlg_color fg;
- enum dlg_color bg;
-};
-
-// Like fprintf but fixes utf-8 output to console on windows.
-// On non-windows sytems just uses the corresponding standard library
-// functions. On windows, if dlg was compiled with the win_console option,
-// will first try to output it in a way that allows the default console
-// to display utf-8. If that fails, will fall back to the standard
-// library functions.
-DLG_API int dlg_fprintf(FILE* stream, const char* format, ...) DLG_PRINTF_ATTRIB(2, 3);
-DLG_API int dlg_vfprintf(FILE* stream, const char* format, va_list list);
-
-// Like dlg_printf, but also applies the given style to this output.
-// The style will always be applied (using escape sequences), independent of the given stream.
-// On windows escape sequences don't work out of the box, see dlg_win_init_ansi().
-DLG_API int dlg_styled_fprintf(FILE* stream, struct dlg_style style,
- const char* format, ...) DLG_PRINTF_ATTRIB(3, 4);
-
-// Features to output from the generic output handler.
-// Some features might have only an effect in the specializations.
-enum dlg_output_feature {
- dlg_output_tags = 1, // output tags list
- dlg_output_time = 2, // output time of log call (hour:minute:second)
- dlg_output_style = 4, // whether to use the supplied styles
- dlg_output_func = 8, // output function
- dlg_output_file_line = 16, // output file:line,
- dlg_output_newline = 32, // output a newline at the end
- dlg_output_threadsafe = 64, // locks stream before printing
- dlg_output_time_msecs = 128 // output micro seconds (ms on windows)
-};
-
-// The default level-dependent output styles. The array values represent the styles
-// to be used for the associated level (i.e. [0] for trace level).
-DLG_API extern const struct dlg_style dlg_default_output_styles[6];
-
-// Generic output function. Used by the default output handler and might be useful
-// for custom output handlers (that don't want to manually format the output).
-// Will call the given output func with the given data (and format + args to print)
-// for everything it has to print in printf format.
-// See also the *_stream and *_buf specializations for common usage.
-// The given output function must not be NULL.
-typedef void(*dlg_generic_output_handler)(void* data, const char* format, ...);
-DLG_API void dlg_generic_output(dlg_generic_output_handler output, void* data,
- unsigned int features, const struct dlg_origin* origin, const char* string,
- const struct dlg_style styles[6]);
-
-// Generic output function, using a format string instead of feature flags.
-// Use following conversion characters:
-// %h - output the time in H:M:S format
-// %m - output the time in milliseconds
-// %t - output the full list of tags, comma separated
-// %f - output the function name noted in the origin
-// %o - output the file:line of the origin
-// %s - print the appropriate style escape sequence.
-// %r - print the escape sequence to reset the style.
-// %c - The content of the log/assert
-// %% - print the '%' character
-// Only the above specified conversion characters are valid, the rest are
-// written as it is.
-DLG_API void dlg_generic_outputf(dlg_generic_output_handler output, void* data,
- const char* format_string, const struct dlg_origin* origin,
- const char* string, const struct dlg_style styles[6]);
-
-// Generic output function. Used by the default output handler and might be useful
-// for custom output handlers (that don't want to manually format the output).
-// If stream is NULL uses stdout.
-// Automatically uses dlg_fprintf to assure correct utf-8 even on windows consoles.
-// Locks the stream (i.e. assures threadsafe access) when the associated feature
-// is passed (note that stdout/stderr might still mix from multiple threads).
-DLG_API void dlg_generic_output_stream(FILE* stream, unsigned int features,
- const struct dlg_origin* origin, const char* string,
- const struct dlg_style styles[6]);
-DLG_API void dlg_generic_outputf_stream(FILE* stream, const char* format_string,
- const struct dlg_origin* origin, const char* string,
- const struct dlg_style styles[6], bool lock_stream);
-
-// Generic output function (see dlg_generic_output) that uses a buffer instead of
-// a stream. buf must at least point to *size bytes. Will set *size to the number
-// of bytes written (capped to the given size), if buf == NULL will set *size
-// to the needed size. The size parameter must not be NULL.
-DLG_API void dlg_generic_output_buf(char* buf, size_t* size, unsigned int features,
- const struct dlg_origin* origin, const char* string,
- const struct dlg_style styles[6]);
-DLG_API void dlg_generic_outputf_buf(char* buf, size_t* size, const char* format_string,
- const struct dlg_origin* origin, const char* string,
- const struct dlg_style styles[6]);
-
-// Returns if the given stream is a tty. Useful for custom output handlers
-// e.g. to determine whether to use color.
-// NOTE: Due to windows limitations currently returns false for wsl ttys.
-DLG_API bool dlg_is_tty(FILE* stream);
-
-// Returns the null-terminated escape sequence for the given style into buf.
-// Undefined behvaiour if any member of style has a value outside its enum range (will
-// probably result in a buffer overflow or garbage being printed).
-// If all member of style are 'none' will simply nullterminate the first buf char.
-DLG_API void dlg_escape_sequence(struct dlg_style style, char buf[12]);
-
-// The reset style escape sequence.
-DLG_API extern const char* const dlg_reset_sequence;
-
-// Just returns true without other effect on non-windows systems or if dlg
-// was compiled without the win_console option.
-// On windows tries to set the console mode to ansi to make escape sequences work.
-// This works only on newer windows 10 versions. Returns false on error.
-// Only the first call to it will have an effect, following calls just return the result.
-// The function is threadsafe. Automatically called by the default output handler.
-// This will only be able to set the mode for the stdout and stderr consoles, so
-// other streams to consoles will still not work.
-DLG_API bool dlg_win_init_ansi(void);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // header guard
diff --git a/contrib/libs/freetype/include/freetype/config/ftconfig.h b/contrib/libs/freetype/include/freetype/config/ftconfig.h
deleted file mode 100644
index 0667493fec..0000000000
--- a/contrib/libs/freetype/include/freetype/config/ftconfig.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/****************************************************************************
- *
- * ftconfig.h
- *
- * ANSI-specific configuration file (specification only).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /**************************************************************************
- *
- * This header file contains a number of macro definitions that are used by
- * the rest of the engine. Most of the macros here are automatically
- * determined at compile time, and you should not need to change it to port
- * FreeType, except to compile the library with a non-ANSI compiler.
- *
- * Note however that if some specific modifications are needed, we advise
- * you to place a modified copy in your build directory.
- *
- * The build directory is usually `builds/<system>`, and contains
- * system-specific files that are always included first when building the
- * library.
- *
- * This ANSI version should stay in `include/config/`.
- *
- */
-
-#ifndef FTCONFIG_H_
-#define FTCONFIG_H_
-
-#include <ft2build.h>
-#include FT_CONFIG_OPTIONS_H
-#include FT_CONFIG_STANDARD_LIBRARY_H
-
-#include <freetype/config/integer-types.h>
-#include <freetype/config/public-macros.h>
-#include <freetype/config/mac-support.h>
-
-#endif /* FTCONFIG_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/config/ftheader.h b/contrib/libs/freetype/include/freetype/config/ftheader.h
deleted file mode 100644
index f6ef2618de..0000000000
--- a/contrib/libs/freetype/include/freetype/config/ftheader.h
+++ /dev/null
@@ -1,836 +0,0 @@
-/****************************************************************************
- *
- * ftheader.h
- *
- * Build macros of the FreeType 2 library.
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-#ifndef FTHEADER_H_
-#define FTHEADER_H_
-
-
- /*@***********************************************************************/
- /* */
- /* <Macro> */
- /* FT_BEGIN_HEADER */
- /* */
- /* <Description> */
- /* This macro is used in association with @FT_END_HEADER in header */
- /* files to ensure that the declarations within are properly */
- /* encapsulated in an `extern "C" { .. }` block when included from a */
- /* C++ compiler. */
- /* */
-#ifndef FT_BEGIN_HEADER
-# ifdef __cplusplus
-# define FT_BEGIN_HEADER extern "C" {
-# else
-# define FT_BEGIN_HEADER /* nothing */
-# endif
-#endif
-
-
- /*@***********************************************************************/
- /* */
- /* <Macro> */
- /* FT_END_HEADER */
- /* */
- /* <Description> */
- /* This macro is used in association with @FT_BEGIN_HEADER in header */
- /* files to ensure that the declarations within are properly */
- /* encapsulated in an `extern "C" { .. }` block when included from a */
- /* C++ compiler. */
- /* */
-#ifndef FT_END_HEADER
-# ifdef __cplusplus
-# define FT_END_HEADER }
-# else
-# define FT_END_HEADER /* nothing */
-# endif
-#endif
-
-
- /**************************************************************************
- *
- * Aliases for the FreeType 2 public and configuration files.
- *
- */
-
- /**************************************************************************
- *
- * @section:
- * header_file_macros
- *
- * @title:
- * Header File Macros
- *
- * @abstract:
- * Macro definitions used to `#include` specific header files.
- *
- * @description:
- * In addition to the normal scheme of including header files like
- *
- * ```
- * #include <freetype/freetype.h>
- * #include <freetype/ftmm.h>
- * #include <freetype/ftglyph.h>
- * ```
- *
- * it is possible to used named macros instead. They can be used
- * directly in `#include` statements as in
- *
- * ```
- * #include FT_FREETYPE_H
- * #include FT_MULTIPLE_MASTERS_H
- * #include FT_GLYPH_H
- * ```
- *
- * These macros were introduced to overcome the infamous 8.3~naming rule
- * required by DOS (and `FT_MULTIPLE_MASTERS_H` is a lot more meaningful
- * than `ftmm.h`).
- *
- */
-
-
- /* configuration files */
-
- /**************************************************************************
- *
- * @macro:
- * FT_CONFIG_CONFIG_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing
- * FreeType~2 configuration data.
- *
- */
-#ifndef FT_CONFIG_CONFIG_H
-#define FT_CONFIG_CONFIG_H <freetype/config/ftconfig.h>
-#endif
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_CONFIG_STANDARD_LIBRARY_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing
- * FreeType~2 interface to the standard C library functions.
- *
- */
-#ifndef FT_CONFIG_STANDARD_LIBRARY_H
-#define FT_CONFIG_STANDARD_LIBRARY_H <freetype/config/ftstdlib.h>
-#endif
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_CONFIG_OPTIONS_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing
- * FreeType~2 project-specific configuration options.
- *
- */
-#ifndef FT_CONFIG_OPTIONS_H
-#define FT_CONFIG_OPTIONS_H <freetype/config/ftoption.h>
-#endif
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_CONFIG_MODULES_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing the
- * list of FreeType~2 modules that are statically linked to new library
- * instances in @FT_Init_FreeType.
- *
- */
-#ifndef FT_CONFIG_MODULES_H
-#define FT_CONFIG_MODULES_H <freetype/config/ftmodule.h>
-#endif
-
- /* */
-
- /* public headers */
-
- /**************************************************************************
- *
- * @macro:
- * FT_FREETYPE_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing the
- * base FreeType~2 API.
- *
- */
-#define FT_FREETYPE_H <freetype/freetype.h>
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_ERRORS_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing the
- * list of FreeType~2 error codes (and messages).
- *
- * It is included by @FT_FREETYPE_H.
- *
- */
-#define FT_ERRORS_H <freetype/fterrors.h>
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_MODULE_ERRORS_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing the
- * list of FreeType~2 module error offsets (and messages).
- *
- */
-#define FT_MODULE_ERRORS_H <freetype/ftmoderr.h>
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_SYSTEM_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing the
- * FreeType~2 interface to low-level operations (i.e., memory management
- * and stream i/o).
- *
- * It is included by @FT_FREETYPE_H.
- *
- */
-#define FT_SYSTEM_H <freetype/ftsystem.h>
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_IMAGE_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing type
- * definitions related to glyph images (i.e., bitmaps, outlines,
- * scan-converter parameters).
- *
- * It is included by @FT_FREETYPE_H.
- *
- */
-#define FT_IMAGE_H <freetype/ftimage.h>
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_TYPES_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing the
- * basic data types defined by FreeType~2.
- *
- * It is included by @FT_FREETYPE_H.
- *
- */
-#define FT_TYPES_H <freetype/fttypes.h>
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_LIST_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing the
- * list management API of FreeType~2.
- *
- * (Most applications will never need to include this file.)
- *
- */
-#define FT_LIST_H <freetype/ftlist.h>
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_OUTLINE_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing the
- * scalable outline management API of FreeType~2.
- *
- */
-#define FT_OUTLINE_H <freetype/ftoutln.h>
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_SIZES_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing the
- * API which manages multiple @FT_Size objects per face.
- *
- */
-#define FT_SIZES_H <freetype/ftsizes.h>
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_MODULE_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing the
- * module management API of FreeType~2.
- *
- */
-#define FT_MODULE_H <freetype/ftmodapi.h>
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_RENDER_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing the
- * renderer module management API of FreeType~2.
- *
- */
-#define FT_RENDER_H <freetype/ftrender.h>
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_DRIVER_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing
- * structures and macros related to the driver modules.
- *
- */
-#define FT_DRIVER_H <freetype/ftdriver.h>
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_AUTOHINTER_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing
- * structures and macros related to the auto-hinting module.
- *
- * Deprecated since version~2.9; use @FT_DRIVER_H instead.
- *
- */
-#define FT_AUTOHINTER_H FT_DRIVER_H
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_CFF_DRIVER_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing
- * structures and macros related to the CFF driver module.
- *
- * Deprecated since version~2.9; use @FT_DRIVER_H instead.
- *
- */
-#define FT_CFF_DRIVER_H FT_DRIVER_H
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_TRUETYPE_DRIVER_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing
- * structures and macros related to the TrueType driver module.
- *
- * Deprecated since version~2.9; use @FT_DRIVER_H instead.
- *
- */
-#define FT_TRUETYPE_DRIVER_H FT_DRIVER_H
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_PCF_DRIVER_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing
- * structures and macros related to the PCF driver module.
- *
- * Deprecated since version~2.9; use @FT_DRIVER_H instead.
- *
- */
-#define FT_PCF_DRIVER_H FT_DRIVER_H
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_TYPE1_TABLES_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing the
- * types and API specific to the Type~1 format.
- *
- */
-#define FT_TYPE1_TABLES_H <freetype/t1tables.h>
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_TRUETYPE_IDS_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing the
- * enumeration values which identify name strings, languages, encodings,
- * etc. This file really contains a _large_ set of constant macro
- * definitions, taken from the TrueType and OpenType specifications.
- *
- */
-#define FT_TRUETYPE_IDS_H <freetype/ttnameid.h>
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_TRUETYPE_TABLES_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing the
- * types and API specific to the TrueType (as well as OpenType) format.
- *
- */
-#define FT_TRUETYPE_TABLES_H <freetype/tttables.h>
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_TRUETYPE_TAGS_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing the
- * definitions of TrueType four-byte 'tags' which identify blocks in
- * SFNT-based font formats (i.e., TrueType and OpenType).
- *
- */
-#define FT_TRUETYPE_TAGS_H <freetype/tttags.h>
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_BDF_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing the
- * definitions of an API which accesses BDF-specific strings from a face.
- *
- */
-#define FT_BDF_H <freetype/ftbdf.h>
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_CID_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing the
- * definitions of an API which access CID font information from a face.
- *
- */
-#define FT_CID_H <freetype/ftcid.h>
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_GZIP_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing the
- * definitions of an API which supports gzip-compressed files.
- *
- */
-#define FT_GZIP_H <freetype/ftgzip.h>
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_LZW_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing the
- * definitions of an API which supports LZW-compressed files.
- *
- */
-#define FT_LZW_H <freetype/ftlzw.h>
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_BZIP2_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing the
- * definitions of an API which supports bzip2-compressed files.
- *
- */
-#define FT_BZIP2_H <freetype/ftbzip2.h>
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_WINFONTS_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing the
- * definitions of an API which supports Windows FNT files.
- *
- */
-#define FT_WINFONTS_H <freetype/ftwinfnt.h>
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_GLYPH_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing the
- * API of the optional glyph management component.
- *
- */
-#define FT_GLYPH_H <freetype/ftglyph.h>
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_BITMAP_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing the
- * API of the optional bitmap conversion component.
- *
- */
-#define FT_BITMAP_H <freetype/ftbitmap.h>
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_BBOX_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing the
- * API of the optional exact bounding box computation routines.
- *
- */
-#define FT_BBOX_H <freetype/ftbbox.h>
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_CACHE_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing the
- * API of the optional FreeType~2 cache sub-system.
- *
- */
-#define FT_CACHE_H <freetype/ftcache.h>
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_MAC_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing the
- * Macintosh-specific FreeType~2 API. The latter is used to access fonts
- * embedded in resource forks.
- *
- * This header file must be explicitly included by client applications
- * compiled on the Mac (note that the base API still works though).
- *
- */
-#define FT_MAC_H <freetype/ftmac.h>
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_MULTIPLE_MASTERS_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing the
- * optional multiple-masters management API of FreeType~2.
- *
- */
-#define FT_MULTIPLE_MASTERS_H <freetype/ftmm.h>
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_SFNT_NAMES_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing the
- * optional FreeType~2 API which accesses embedded 'name' strings in
- * SFNT-based font formats (i.e., TrueType and OpenType).
- *
- */
-#define FT_SFNT_NAMES_H <freetype/ftsnames.h>
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_OPENTYPE_VALIDATE_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing the
- * optional FreeType~2 API which validates OpenType tables ('BASE',
- * 'GDEF', 'GPOS', 'GSUB', 'JSTF').
- *
- */
-#define FT_OPENTYPE_VALIDATE_H <freetype/ftotval.h>
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_GX_VALIDATE_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing the
- * optional FreeType~2 API which validates TrueTypeGX/AAT tables ('feat',
- * 'mort', 'morx', 'bsln', 'just', 'kern', 'opbd', 'trak', 'prop').
- *
- */
-#define FT_GX_VALIDATE_H <freetype/ftgxval.h>
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_PFR_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing the
- * FreeType~2 API which accesses PFR-specific data.
- *
- */
-#define FT_PFR_H <freetype/ftpfr.h>
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_STROKER_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing the
- * FreeType~2 API which provides functions to stroke outline paths.
- */
-#define FT_STROKER_H <freetype/ftstroke.h>
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_SYNTHESIS_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing the
- * FreeType~2 API which performs artificial obliquing and emboldening.
- */
-#define FT_SYNTHESIS_H <freetype/ftsynth.h>
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_FONT_FORMATS_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing the
- * FreeType~2 API which provides functions specific to font formats.
- */
-#define FT_FONT_FORMATS_H <freetype/ftfntfmt.h>
-
- /* deprecated */
-#define FT_XFREE86_H FT_FONT_FORMATS_H
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_TRIGONOMETRY_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing the
- * FreeType~2 API which performs trigonometric computations (e.g.,
- * cosines and arc tangents).
- */
-#define FT_TRIGONOMETRY_H <freetype/fttrigon.h>
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_LCD_FILTER_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing the
- * FreeType~2 API which performs color filtering for subpixel rendering.
- */
-#define FT_LCD_FILTER_H <freetype/ftlcdfil.h>
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_INCREMENTAL_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing the
- * FreeType~2 API which performs incremental glyph loading.
- */
-#define FT_INCREMENTAL_H <freetype/ftincrem.h>
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_GASP_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing the
- * FreeType~2 API which returns entries from the TrueType GASP table.
- */
-#define FT_GASP_H <freetype/ftgasp.h>
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_ADVANCES_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing the
- * FreeType~2 API which returns individual and ranged glyph advances.
- */
-#define FT_ADVANCES_H <freetype/ftadvanc.h>
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_COLOR_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing the
- * FreeType~2 API which handles the OpenType 'CPAL' table.
- */
-#define FT_COLOR_H <freetype/ftcolor.h>
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_OTSVG_H
- *
- * @description:
- * A macro used in `#include` statements to name the file containing the
- * FreeType~2 API which handles the OpenType 'SVG~' glyphs.
- */
-#define FT_OTSVG_H <freetype/otsvg.h>
-
-
- /* */
-
- /* These header files don't need to be included by the user. */
-#define FT_ERROR_DEFINITIONS_H <freetype/fterrdef.h>
-#define FT_PARAMETER_TAGS_H <freetype/ftparams.h>
-
- /* Deprecated macros. */
-#define FT_UNPATENTED_HINTING_H <freetype/ftparams.h>
-#define FT_TRUETYPE_UNPATENTED_H <freetype/ftparams.h>
-
- /* `FT_CACHE_H` is the only header file needed for the cache subsystem. */
-#define FT_CACHE_IMAGE_H FT_CACHE_H
-#define FT_CACHE_SMALL_BITMAPS_H FT_CACHE_H
-#define FT_CACHE_CHARMAP_H FT_CACHE_H
-
- /* The internals of the cache sub-system are no longer exposed. We */
- /* default to `FT_CACHE_H` at the moment just in case, but we know */
- /* of no rogue client that uses them. */
- /* */
-#define FT_CACHE_MANAGER_H FT_CACHE_H
-#define FT_CACHE_INTERNAL_MRU_H FT_CACHE_H
-#define FT_CACHE_INTERNAL_MANAGER_H FT_CACHE_H
-#define FT_CACHE_INTERNAL_CACHE_H FT_CACHE_H
-#define FT_CACHE_INTERNAL_GLYPH_H FT_CACHE_H
-#define FT_CACHE_INTERNAL_IMAGE_H FT_CACHE_H
-#define FT_CACHE_INTERNAL_SBITS_H FT_CACHE_H
-
-/* TODO(david): Move this section below to a different header */
-#ifdef FT2_BUILD_LIBRARY
-#if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */
-
- /* We disable the warning `conditional expression is constant' here */
- /* in order to compile cleanly with the maximum level of warnings. */
- /* In particular, the warning complains about stuff like `while(0)' */
- /* which is very useful in macro definitions. There is no benefit */
- /* in having it enabled. */
-#pragma warning( disable : 4127 )
-
-#endif /* _MSC_VER */
-#endif /* FT2_BUILD_LIBRARY */
-
-#endif /* FTHEADER_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/config/ftmodule.h b/contrib/libs/freetype/include/freetype/config/ftmodule.h
deleted file mode 100644
index b315baba8a..0000000000
--- a/contrib/libs/freetype/include/freetype/config/ftmodule.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * This file registers the FreeType modules compiled into the library.
- *
- * If you use GNU make, this file IS NOT USED! Instead, it is created in
- * the objects directory (normally `<topdir>/objs/`) based on information
- * from `<topdir>/modules.cfg`.
- *
- * Please read `docs/INSTALL.ANY` and `docs/CUSTOMIZE` how to compile
- * FreeType without GNU make.
- *
- */
-
-FT_USE_MODULE( FT_Module_Class, autofit_module_class )
-FT_USE_MODULE( FT_Driver_ClassRec, tt_driver_class )
-FT_USE_MODULE( FT_Driver_ClassRec, t1_driver_class )
-FT_USE_MODULE( FT_Driver_ClassRec, cff_driver_class )
-FT_USE_MODULE( FT_Driver_ClassRec, t1cid_driver_class )
-FT_USE_MODULE( FT_Driver_ClassRec, pfr_driver_class )
-FT_USE_MODULE( FT_Driver_ClassRec, t42_driver_class )
-FT_USE_MODULE( FT_Driver_ClassRec, winfnt_driver_class )
-FT_USE_MODULE( FT_Driver_ClassRec, pcf_driver_class )
-FT_USE_MODULE( FT_Driver_ClassRec, bdf_driver_class )
-FT_USE_MODULE( FT_Module_Class, psaux_module_class )
-FT_USE_MODULE( FT_Module_Class, psnames_module_class )
-FT_USE_MODULE( FT_Module_Class, pshinter_module_class )
-FT_USE_MODULE( FT_Module_Class, sfnt_module_class )
-FT_USE_MODULE( FT_Renderer_Class, ft_smooth_renderer_class )
-FT_USE_MODULE( FT_Renderer_Class, ft_raster1_renderer_class )
-FT_USE_MODULE( FT_Renderer_Class, ft_sdf_renderer_class )
-FT_USE_MODULE( FT_Renderer_Class, ft_bitmap_sdf_renderer_class )
-FT_USE_MODULE( FT_Renderer_Class, ft_svg_renderer_class )
-
-/* EOF */
diff --git a/contrib/libs/freetype/include/freetype/config/ftoption.h b/contrib/libs/freetype/include/freetype/config/ftoption.h
deleted file mode 100644
index eb4e32d80a..0000000000
--- a/contrib/libs/freetype/include/freetype/config/ftoption.h
+++ /dev/null
@@ -1,1030 +0,0 @@
-/****************************************************************************
- *
- * ftoption.h
- *
- * User-selectable configuration macros (specification only).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTOPTION_H_
-#define FTOPTION_H_
-
-
-#include <ft2build.h>
-
-
-FT_BEGIN_HEADER
-
- /**************************************************************************
- *
- * USER-SELECTABLE CONFIGURATION MACROS
- *
- * This file contains the default configuration macro definitions for a
- * standard build of the FreeType library. There are three ways to use
- * this file to build project-specific versions of the library:
- *
- * - You can modify this file by hand, but this is not recommended in
- * cases where you would like to build several versions of the library
- * from a single source directory.
- *
- * - You can put a copy of this file in your build directory, more
- * precisely in `$BUILD/freetype/config/ftoption.h`, where `$BUILD` is
- * the name of a directory that is included _before_ the FreeType include
- * path during compilation.
- *
- * The default FreeType Makefiles use the build directory
- * `builds/<system>` by default, but you can easily change that for your
- * own projects.
- *
- * - Copy the file <ft2build.h> to `$BUILD/ft2build.h` and modify it
- * slightly to pre-define the macro `FT_CONFIG_OPTIONS_H` used to locate
- * this file during the build. For example,
- *
- * ```
- * #define FT_CONFIG_OPTIONS_H <myftoptions.h>
- * #include <freetype/config/ftheader.h>
- * ```
- *
- * will use `$BUILD/myftoptions.h` instead of this file for macro
- * definitions.
- *
- * Note also that you can similarly pre-define the macro
- * `FT_CONFIG_MODULES_H` used to locate the file listing of the modules
- * that are statically linked to the library at compile time. By
- * default, this file is `<freetype/config/ftmodule.h>`.
- *
- * We highly recommend using the third method whenever possible.
- *
- */
-
-
- /*************************************************************************/
- /*************************************************************************/
- /**** ****/
- /**** G E N E R A L F R E E T Y P E 2 C O N F I G U R A T I O N ****/
- /**** ****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /*#************************************************************************
- *
- * If you enable this configuration option, FreeType recognizes an
- * environment variable called `FREETYPE_PROPERTIES`, which can be used to
- * control the various font drivers and modules. The controllable
- * properties are listed in the section @properties.
- *
- * You have to undefine this configuration option on platforms that lack
- * the concept of environment variables (and thus don't have the `getenv`
- * function), for example Windows CE.
- *
- * `FREETYPE_PROPERTIES` has the following syntax form (broken here into
- * multiple lines for better readability).
- *
- * ```
- * <optional whitespace>
- * <module-name1> ':'
- * <property-name1> '=' <property-value1>
- * <whitespace>
- * <module-name2> ':'
- * <property-name2> '=' <property-value2>
- * ...
- * ```
- *
- * Example:
- *
- * ```
- * FREETYPE_PROPERTIES=truetype:interpreter-version=35 \
- * cff:no-stem-darkening=1
- * ```
- *
- */
-#define FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
-
-
- /**************************************************************************
- *
- * Uncomment the line below if you want to activate LCD rendering
- * technology similar to ClearType in this build of the library. This
- * technology triples the resolution in the direction color subpixels. To
- * mitigate color fringes inherent to this technology, you also need to
- * explicitly set up LCD filtering.
- *
- * When this macro is not defined, FreeType offers alternative LCD
- * rendering technology that produces excellent output.
- */
-/* #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
-
-
- /**************************************************************************
- *
- * Many compilers provide a non-ANSI 64-bit data type that can be used by
- * FreeType to speed up some computations. However, this will create some
- * problems when compiling the library in strict ANSI mode.
- *
- * For this reason, the use of 64-bit integers is normally disabled when
- * the `__STDC__` macro is defined. You can however disable this by
- * defining the macro `FT_CONFIG_OPTION_FORCE_INT64` here.
- *
- * For most compilers, this will only create compilation warnings when
- * building the library.
- *
- * ObNote: The compiler-specific 64-bit integers are detected in the
- * file `ftconfig.h` either statically or through the `configure`
- * script on supported platforms.
- */
-#undef FT_CONFIG_OPTION_FORCE_INT64
-
-
- /**************************************************************************
- *
- * If this macro is defined, do not try to use an assembler version of
- * performance-critical functions (e.g., @FT_MulFix). You should only do
- * that to verify that the assembler function works properly, or to execute
- * benchmark tests of the various implementations.
- */
-/* #define FT_CONFIG_OPTION_NO_ASSEMBLER */
-
-
- /**************************************************************************
- *
- * If this macro is defined, try to use an inlined assembler version of the
- * @FT_MulFix function, which is a 'hotspot' when loading and hinting
- * glyphs, and which should be executed as fast as possible.
- *
- * Note that if your compiler or CPU is not supported, this will default to
- * the standard and portable implementation found in `ftcalc.c`.
- */
-#define FT_CONFIG_OPTION_INLINE_MULFIX
-
-
- /**************************************************************************
- *
- * LZW-compressed file support.
- *
- * FreeType now handles font files that have been compressed with the
- * `compress` program. This is mostly used to parse many of the PCF
- * files that come with various X11 distributions. The implementation
- * uses NetBSD's `zopen` to partially uncompress the file on the fly (see
- * `src/lzw/ftgzip.c`).
- *
- * Define this macro if you want to enable this 'feature'.
- */
-#define FT_CONFIG_OPTION_USE_LZW
-
-
- /**************************************************************************
- *
- * Gzip-compressed file support.
- *
- * FreeType now handles font files that have been compressed with the
- * `gzip` program. This is mostly used to parse many of the PCF files
- * that come with XFree86. The implementation uses 'zlib' to partially
- * uncompress the file on the fly (see `src/gzip/ftgzip.c`).
- *
- * Define this macro if you want to enable this 'feature'. See also the
- * macro `FT_CONFIG_OPTION_SYSTEM_ZLIB` below.
- */
-#define FT_CONFIG_OPTION_USE_ZLIB
-
-
- /**************************************************************************
- *
- * ZLib library selection
- *
- * This macro is only used when `FT_CONFIG_OPTION_USE_ZLIB` is defined.
- * It allows FreeType's 'ftgzip' component to link to the system's
- * installation of the ZLib library. This is useful on systems like
- * Unix or VMS where it generally is already available.
- *
- * If you let it undefined, the component will use its own copy of the
- * zlib sources instead. These have been modified to be included
- * directly within the component and **not** export external function
- * names. This allows you to link any program with FreeType _and_ ZLib
- * without linking conflicts.
- *
- * Do not `#undef` this macro here since the build system might define
- * it for certain configurations only.
- *
- * If you use a build system like cmake or the `configure` script,
- * options set by those programs have precedence, overwriting the value
- * here with the configured one.
- *
- * If you use the GNU make build system directly (that is, without the
- * `configure` script) and you define this macro, you also have to pass
- * `SYSTEM_ZLIB=yes` as an argument to make.
- */
-/* #define FT_CONFIG_OPTION_SYSTEM_ZLIB */
-
-
- /**************************************************************************
- *
- * Bzip2-compressed file support.
- *
- * FreeType now handles font files that have been compressed with the
- * `bzip2` program. This is mostly used to parse many of the PCF files
- * that come with XFree86. The implementation uses `libbz2` to partially
- * uncompress the file on the fly (see `src/bzip2/ftbzip2.c`). Contrary
- * to gzip, bzip2 currently is not included and need to use the system
- * available bzip2 implementation.
- *
- * Define this macro if you want to enable this 'feature'.
- *
- * If you use a build system like cmake or the `configure` script,
- * options set by those programs have precedence, overwriting the value
- * here with the configured one.
- */
-/* #define FT_CONFIG_OPTION_USE_BZIP2 */
-
-
- /**************************************************************************
- *
- * Define to disable the use of file stream functions and types, `FILE`,
- * `fopen`, etc. Enables the use of smaller system libraries on embedded
- * systems that have multiple system libraries, some with or without file
- * stream support, in the cases where file stream support is not necessary
- * such as memory loading of font files.
- */
-/* #define FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT */
-
-
- /**************************************************************************
- *
- * PNG bitmap support.
- *
- * FreeType now handles loading color bitmap glyphs in the PNG format.
- * This requires help from the external libpng library. Uncompressed
- * color bitmaps do not need any external libraries and will be supported
- * regardless of this configuration.
- *
- * Define this macro if you want to enable this 'feature'.
- *
- * If you use a build system like cmake or the `configure` script,
- * options set by those programs have precedence, overwriting the value
- * here with the configured one.
- */
-/* #define FT_CONFIG_OPTION_USE_PNG */
-
-
- /**************************************************************************
- *
- * HarfBuzz support.
- *
- * FreeType uses the HarfBuzz library to improve auto-hinting of OpenType
- * fonts. If available, many glyphs not directly addressable by a font's
- * character map will be hinted also.
- *
- * Define this macro if you want to enable this 'feature'.
- *
- * If you use a build system like cmake or the `configure` script,
- * options set by those programs have precedence, overwriting the value
- * here with the configured one.
- */
-/* #define FT_CONFIG_OPTION_USE_HARFBUZZ */
-
-
- /**************************************************************************
- *
- * Brotli support.
- *
- * FreeType uses the Brotli library to provide support for decompressing
- * WOFF2 streams.
- *
- * Define this macro if you want to enable this 'feature'.
- *
- * If you use a build system like cmake or the `configure` script,
- * options set by those programs have precedence, overwriting the value
- * here with the configured one.
- */
-/* #define FT_CONFIG_OPTION_USE_BROTLI */
-
-
- /**************************************************************************
- *
- * Glyph Postscript Names handling
- *
- * By default, FreeType 2 is compiled with the 'psnames' module. This
- * module is in charge of converting a glyph name string into a Unicode
- * value, or return a Macintosh standard glyph name for the use with the
- * TrueType 'post' table.
- *
- * Undefine this macro if you do not want 'psnames' compiled in your
- * build of FreeType. This has the following effects:
- *
- * - The TrueType driver will provide its own set of glyph names, if you
- * build it to support postscript names in the TrueType 'post' table,
- * but will not synthesize a missing Unicode charmap.
- *
- * - The Type~1 driver will not be able to synthesize a Unicode charmap
- * out of the glyphs found in the fonts.
- *
- * You would normally undefine this configuration macro when building a
- * version of FreeType that doesn't contain a Type~1 or CFF driver.
- */
-#define FT_CONFIG_OPTION_POSTSCRIPT_NAMES
-
-
- /**************************************************************************
- *
- * Postscript Names to Unicode Values support
- *
- * By default, FreeType~2 is built with the 'psnames' module compiled in.
- * Among other things, the module is used to convert a glyph name into a
- * Unicode value. This is especially useful in order to synthesize on
- * the fly a Unicode charmap from the CFF/Type~1 driver through a big
- * table named the 'Adobe Glyph List' (AGL).
- *
- * Undefine this macro if you do not want the Adobe Glyph List compiled
- * in your 'psnames' module. The Type~1 driver will not be able to
- * synthesize a Unicode charmap out of the glyphs found in the fonts.
- */
-#define FT_CONFIG_OPTION_ADOBE_GLYPH_LIST
-
-
- /**************************************************************************
- *
- * Support for Mac fonts
- *
- * Define this macro if you want support for outline fonts in Mac format
- * (mac dfont, mac resource, macbinary containing a mac resource) on
- * non-Mac platforms.
- *
- * Note that the 'FOND' resource isn't checked.
- */
-#define FT_CONFIG_OPTION_MAC_FONTS
-
-
- /**************************************************************************
- *
- * Guessing methods to access embedded resource forks
- *
- * Enable extra Mac fonts support on non-Mac platforms (e.g., GNU/Linux).
- *
- * Resource forks which include fonts data are stored sometimes in
- * locations which users or developers don't expected. In some cases,
- * resource forks start with some offset from the head of a file. In
- * other cases, the actual resource fork is stored in file different from
- * what the user specifies. If this option is activated, FreeType tries
- * to guess whether such offsets or different file names must be used.
- *
- * Note that normal, direct access of resource forks is controlled via
- * the `FT_CONFIG_OPTION_MAC_FONTS` option.
- */
-#ifdef FT_CONFIG_OPTION_MAC_FONTS
-#define FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK
-#endif
-
-
- /**************************************************************************
- *
- * Allow the use of `FT_Incremental_Interface` to load typefaces that
- * contain no glyph data, but supply it via a callback function. This is
- * required by clients supporting document formats which supply font data
- * incrementally as the document is parsed, such as the Ghostscript
- * interpreter for the PostScript language.
- */
-#define FT_CONFIG_OPTION_INCREMENTAL
-
-
- /**************************************************************************
- *
- * The size in bytes of the render pool used by the scan-line converter to
- * do all of its work.
- */
-#define FT_RENDER_POOL_SIZE 16384L
-
-
- /**************************************************************************
- *
- * FT_MAX_MODULES
- *
- * The maximum number of modules that can be registered in a single
- * FreeType library object. 32~is the default.
- */
-#define FT_MAX_MODULES 32
-
-
- /**************************************************************************
- *
- * Debug level
- *
- * FreeType can be compiled in debug or trace mode. In debug mode,
- * errors are reported through the 'ftdebug' component. In trace mode,
- * additional messages are sent to the standard output during execution.
- *
- * Define `FT_DEBUG_LEVEL_ERROR` to build the library in debug mode.
- * Define `FT_DEBUG_LEVEL_TRACE` to build it in trace mode.
- *
- * Don't define any of these macros to compile in 'release' mode!
- *
- * Do not `#undef` these macros here since the build system might define
- * them for certain configurations only.
- */
-/* #define FT_DEBUG_LEVEL_ERROR */
-/* #define FT_DEBUG_LEVEL_TRACE */
-
-
- /**************************************************************************
- *
- * Logging
- *
- * Compiling FreeType in debug or trace mode makes FreeType write error
- * and trace log messages to `stderr`. Enabling this macro
- * automatically forces the `FT_DEBUG_LEVEL_ERROR` and
- * `FT_DEBUG_LEVEL_TRACE` macros and allows FreeType to write error and
- * trace log messages to a file instead of `stderr`. For writing logs
- * to a file, FreeType uses an the external `dlg` library (the source
- * code is in `src/dlg`).
- *
- * This option needs a C99 compiler.
- */
-/* #define FT_DEBUG_LOGGING */
-
-
- /**************************************************************************
- *
- * Autofitter debugging
- *
- * If `FT_DEBUG_AUTOFIT` is defined, FreeType provides some means to
- * control the autofitter behaviour for debugging purposes with global
- * boolean variables (consequently, you should **never** enable this
- * while compiling in 'release' mode):
- *
- * ```
- * af_debug_disable_horz_hints_
- * af_debug_disable_vert_hints_
- * af_debug_disable_blue_hints_
- * ```
- *
- * Additionally, the following functions provide dumps of various
- * internal autofit structures to stdout (using `printf`):
- *
- * ```
- * af_glyph_hints_dump_points
- * af_glyph_hints_dump_segments
- * af_glyph_hints_dump_edges
- * af_glyph_hints_get_num_segments
- * af_glyph_hints_get_segment_offset
- * ```
- *
- * As an argument, they use another global variable:
- *
- * ```
- * af_debug_hints_
- * ```
- *
- * Please have a look at the `ftgrid` demo program to see how those
- * variables and macros should be used.
- *
- * Do not `#undef` these macros here since the build system might define
- * them for certain configurations only.
- */
-/* #define FT_DEBUG_AUTOFIT */
-
-
- /**************************************************************************
- *
- * Memory Debugging
- *
- * FreeType now comes with an integrated memory debugger that is capable
- * of detecting simple errors like memory leaks or double deletes. To
- * compile it within your build of the library, you should define
- * `FT_DEBUG_MEMORY` here.
- *
- * Note that the memory debugger is only activated at runtime when when
- * the _environment_ variable `FT2_DEBUG_MEMORY` is defined also!
- *
- * Do not `#undef` this macro here since the build system might define it
- * for certain configurations only.
- */
-/* #define FT_DEBUG_MEMORY */
-
-
- /**************************************************************************
- *
- * Module errors
- *
- * If this macro is set (which is _not_ the default), the higher byte of
- * an error code gives the module in which the error has occurred, while
- * the lower byte is the real error code.
- *
- * Setting this macro makes sense for debugging purposes only, since it
- * would break source compatibility of certain programs that use
- * FreeType~2.
- *
- * More details can be found in the files `ftmoderr.h` and `fterrors.h`.
- */
-#undef FT_CONFIG_OPTION_USE_MODULE_ERRORS
-
-
- /**************************************************************************
- *
- * OpenType SVG Glyph Support
- *
- * Setting this macro enables support for OpenType SVG glyphs. By
- * default, FreeType can only fetch SVG documents. However, it can also
- * render them if external rendering hook functions are plugged in at
- * runtime.
- *
- * More details on the hooks can be found in file `otsvg.h`.
- */
-#define FT_CONFIG_OPTION_SVG
-
-
- /**************************************************************************
- *
- * Error Strings
- *
- * If this macro is set, `FT_Error_String` will return meaningful
- * descriptions. This is not enabled by default to reduce the overall
- * size of FreeType.
- *
- * More details can be found in the file `fterrors.h`.
- */
-/* #define FT_CONFIG_OPTION_ERROR_STRINGS */
-
-
- /*************************************************************************/
- /*************************************************************************/
- /**** ****/
- /**** S F N T D R I V E R C O N F I G U R A T I O N ****/
- /**** ****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /**************************************************************************
- *
- * Define `TT_CONFIG_OPTION_EMBEDDED_BITMAPS` if you want to support
- * embedded bitmaps in all formats using the 'sfnt' module (namely
- * TrueType~& OpenType).
- */
-#define TT_CONFIG_OPTION_EMBEDDED_BITMAPS
-
-
- /**************************************************************************
- *
- * Define `TT_CONFIG_OPTION_COLOR_LAYERS` if you want to support colored
- * outlines (from the 'COLR'/'CPAL' tables) in all formats using the 'sfnt'
- * module (namely TrueType~& OpenType).
- */
-#define TT_CONFIG_OPTION_COLOR_LAYERS
-
-
- /**************************************************************************
- *
- * Define `TT_CONFIG_OPTION_POSTSCRIPT_NAMES` if you want to be able to
- * load and enumerate Postscript names of glyphs in a TrueType or OpenType
- * file.
- *
- * Note that if you do not compile the 'psnames' module by undefining the
- * above `FT_CONFIG_OPTION_POSTSCRIPT_NAMES` macro, the 'sfnt' module will
- * contain additional code to read the PostScript name table from a font.
- *
- * (By default, the module uses 'psnames' to extract glyph names.)
- */
-#define TT_CONFIG_OPTION_POSTSCRIPT_NAMES
-
-
- /**************************************************************************
- *
- * Define `TT_CONFIG_OPTION_SFNT_NAMES` if your applications need to access
- * the internal name table in a SFNT-based format like TrueType or
- * OpenType. The name table contains various strings used to describe the
- * font, like family name, copyright, version, etc. It does not contain
- * any glyph name though.
- *
- * Accessing SFNT names is done through the functions declared in
- * `ftsnames.h`.
- */
-#define TT_CONFIG_OPTION_SFNT_NAMES
-
-
- /**************************************************************************
- *
- * TrueType CMap support
- *
- * Here you can fine-tune which TrueType CMap table format shall be
- * supported.
- */
-#define TT_CONFIG_CMAP_FORMAT_0
-#define TT_CONFIG_CMAP_FORMAT_2
-#define TT_CONFIG_CMAP_FORMAT_4
-#define TT_CONFIG_CMAP_FORMAT_6
-#define TT_CONFIG_CMAP_FORMAT_8
-#define TT_CONFIG_CMAP_FORMAT_10
-#define TT_CONFIG_CMAP_FORMAT_12
-#define TT_CONFIG_CMAP_FORMAT_13
-#define TT_CONFIG_CMAP_FORMAT_14
-
-
- /*************************************************************************/
- /*************************************************************************/
- /**** ****/
- /**** T R U E T Y P E D R I V E R C O N F I G U R A T I O N ****/
- /**** ****/
- /*************************************************************************/
- /*************************************************************************/
-
- /**************************************************************************
- *
- * Define `TT_CONFIG_OPTION_BYTECODE_INTERPRETER` if you want to compile a
- * bytecode interpreter in the TrueType driver.
- *
- * By undefining this, you will only compile the code necessary to load
- * TrueType glyphs without hinting.
- *
- * Do not `#undef` this macro here, since the build system might define it
- * for certain configurations only.
- */
-#define TT_CONFIG_OPTION_BYTECODE_INTERPRETER
-
-
- /**************************************************************************
- *
- * Define `TT_CONFIG_OPTION_SUBPIXEL_HINTING` if you want to compile
- * subpixel hinting support into the TrueType driver. This modifies the
- * TrueType hinting mechanism when anything but `FT_RENDER_MODE_MONO` is
- * requested.
- *
- * In particular, it modifies the bytecode interpreter to interpret (or
- * not) instructions in a certain way so that all TrueType fonts look like
- * they do in a Windows ClearType (DirectWrite) environment. See [1] for a
- * technical overview on what this means. See `ttinterp.h` for more
- * details on this option.
- *
- * The new default mode focuses on applying a minimal set of rules to all
- * fonts indiscriminately so that modern and web fonts render well while
- * legacy fonts render okay. The corresponding interpreter version is v40.
- * The so-called Infinality mode (v38) is no longer available in FreeType.
- *
- * By undefining these, you get rendering behavior like on Windows without
- * ClearType, i.e., Windows XP without ClearType enabled and Win9x
- * (interpreter version v35). Or not, depending on how much hinting blood
- * and testing tears the font designer put into a given font. If you
- * define one or both subpixel hinting options, you can switch between
- * between v35 and the ones you define (using `FT_Property_Set`).
- *
- * This option requires `TT_CONFIG_OPTION_BYTECODE_INTERPRETER` to be
- * defined.
- *
- * [1]
- * https://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
- */
-#define TT_CONFIG_OPTION_SUBPIXEL_HINTING
-
-
- /**************************************************************************
- *
- * Define `TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED` to compile the
- * TrueType glyph loader to use Apple's definition of how to handle
- * component offsets in composite glyphs.
- *
- * Apple and MS disagree on the default behavior of component offsets in
- * composites. Apple says that they should be scaled by the scaling
- * factors in the transformation matrix (roughly, it's more complex) while
- * MS says they should not. OpenType defines two bits in the composite
- * flags array which can be used to disambiguate, but old fonts will not
- * have them.
- *
- * https://www.microsoft.com/typography/otspec/glyf.htm
- * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6glyf.html
- */
-#undef TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED
-
-
- /**************************************************************************
- *
- * Define `TT_CONFIG_OPTION_GX_VAR_SUPPORT` if you want to include support
- * for Apple's distortable font technology ('fvar', 'gvar', 'cvar', and
- * 'avar' tables). Tagged 'Font Variations', this is now part of OpenType
- * also. This has many similarities to Type~1 Multiple Masters support.
- */
-#define TT_CONFIG_OPTION_GX_VAR_SUPPORT
-
-
- /**************************************************************************
- *
- * Define `TT_CONFIG_OPTION_NO_BORING_EXPANSION` if you want to exclude
- * support for 'boring' OpenType specification expansions.
- *
- * https://github.com/harfbuzz/boring-expansion-spec
- *
- * Right now, the following features are covered:
- *
- * - 'avar' version 2.0
- *
- * Most likely, this is a temporary configuration option to be removed in
- * the near future, since it is assumed that eventually those features are
- * added to the OpenType standard.
- */
-/* #define TT_CONFIG_OPTION_NO_BORING_EXPANSION */
-
-
- /**************************************************************************
- *
- * Define `TT_CONFIG_OPTION_BDF` if you want to include support for an
- * embedded 'BDF~' table within SFNT-based bitmap formats.
- */
-#define TT_CONFIG_OPTION_BDF
-
-
- /**************************************************************************
- *
- * Option `TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES` controls the maximum
- * number of bytecode instructions executed for a single run of the
- * bytecode interpreter, needed to prevent infinite loops. You don't want
- * to change this except for very special situations (e.g., making a
- * library fuzzer spend less time to handle broken fonts).
- *
- * It is not expected that this value is ever modified by a configuring
- * script; instead, it gets surrounded with `#ifndef ... #endif` so that
- * the value can be set as a preprocessor option on the compiler's command
- * line.
- */
-#ifndef TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES
-#define TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES 1000000L
-#endif
-
-
- /**************************************************************************
- *
- * Option `TT_CONFIG_OPTION_GPOS_KERNING` enables a basic GPOS kerning
- * implementation (for TrueType fonts only). With this defined, FreeType
- * is able to get kerning pair data from the GPOS 'kern' feature as well as
- * legacy 'kern' tables; without this defined, FreeType will only be able
- * to use legacy 'kern' tables.
- *
- * Note that FreeType does not support more advanced GPOS layout features;
- * even the 'kern' feature implemented here doesn't handle more
- * sophisticated kerning variants. Use a higher-level library like
- * HarfBuzz instead for that.
- */
-/* #define TT_CONFIG_OPTION_GPOS_KERNING */
-
-
- /*************************************************************************/
- /*************************************************************************/
- /**** ****/
- /**** T Y P E 1 D R I V E R C O N F I G U R A T I O N ****/
- /**** ****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /**************************************************************************
- *
- * `T1_MAX_DICT_DEPTH` is the maximum depth of nest dictionaries and arrays
- * in the Type~1 stream (see `t1load.c`). A minimum of~4 is required.
- */
-#define T1_MAX_DICT_DEPTH 5
-
-
- /**************************************************************************
- *
- * `T1_MAX_SUBRS_CALLS` details the maximum number of nested sub-routine
- * calls during glyph loading.
- */
-#define T1_MAX_SUBRS_CALLS 16
-
-
- /**************************************************************************
- *
- * `T1_MAX_CHARSTRING_OPERANDS` is the charstring stack's capacity. A
- * minimum of~16 is required.
- *
- * The Chinese font 'MingTiEG-Medium' (covering the CNS 11643 character
- * set) needs 256.
- */
-#define T1_MAX_CHARSTRINGS_OPERANDS 256
-
-
- /**************************************************************************
- *
- * Define this configuration macro if you want to prevent the compilation
- * of the 't1afm' module, which is in charge of reading Type~1 AFM files
- * into an existing face. Note that if set, the Type~1 driver will be
- * unable to produce kerning distances.
- */
-#undef T1_CONFIG_OPTION_NO_AFM
-
-
- /**************************************************************************
- *
- * Define this configuration macro if you want to prevent the compilation
- * of the Multiple Masters font support in the Type~1 driver.
- */
-#undef T1_CONFIG_OPTION_NO_MM_SUPPORT
-
-
- /**************************************************************************
- *
- * `T1_CONFIG_OPTION_OLD_ENGINE` controls whether the pre-Adobe Type~1
- * engine gets compiled into FreeType. If defined, it is possible to
- * switch between the two engines using the `hinting-engine` property of
- * the 'type1' driver module.
- */
-/* #define T1_CONFIG_OPTION_OLD_ENGINE */
-
-
- /*************************************************************************/
- /*************************************************************************/
- /**** ****/
- /**** C F F D R I V E R C O N F I G U R A T I O N ****/
- /**** ****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /**************************************************************************
- *
- * Using `CFF_CONFIG_OPTION_DARKENING_PARAMETER_{X,Y}{1,2,3,4}` it is
- * possible to set up the default values of the four control points that
- * define the stem darkening behaviour of the (new) CFF engine. For more
- * details please read the documentation of the `darkening-parameters`
- * property (file `ftdriver.h`), which allows the control at run-time.
- *
- * Do **not** undefine these macros!
- */
-#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1 500
-#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1 400
-
-#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 1000
-#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2 275
-
-#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3 1667
-#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3 275
-
-#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4 2333
-#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4 0
-
-
- /**************************************************************************
- *
- * `CFF_CONFIG_OPTION_OLD_ENGINE` controls whether the pre-Adobe CFF engine
- * gets compiled into FreeType. If defined, it is possible to switch
- * between the two engines using the `hinting-engine` property of the 'cff'
- * driver module.
- */
-/* #define CFF_CONFIG_OPTION_OLD_ENGINE */
-
-
- /*************************************************************************/
- /*************************************************************************/
- /**** ****/
- /**** P C F D R I V E R C O N F I G U R A T I O N ****/
- /**** ****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /**************************************************************************
- *
- * There are many PCF fonts just called 'Fixed' which look completely
- * different, and which have nothing to do with each other. When selecting
- * 'Fixed' in KDE or Gnome one gets results that appear rather random, the
- * style changes often if one changes the size and one cannot select some
- * fonts at all. This option makes the 'pcf' module prepend the foundry
- * name (plus a space) to the family name.
- *
- * We also check whether we have 'wide' characters; all put together, we
- * get family names like 'Sony Fixed' or 'Misc Fixed Wide'.
- *
- * If this option is activated, it can be controlled with the
- * `no-long-family-names` property of the 'pcf' driver module.
- */
-/* #define PCF_CONFIG_OPTION_LONG_FAMILY_NAMES */
-
-
- /*************************************************************************/
- /*************************************************************************/
- /**** ****/
- /**** A U T O F I T M O D U L E C O N F I G U R A T I O N ****/
- /**** ****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /**************************************************************************
- *
- * Compile 'autofit' module with CJK (Chinese, Japanese, Korean) script
- * support.
- */
-#define AF_CONFIG_OPTION_CJK
-
-
- /**************************************************************************
- *
- * Compile 'autofit' module with fallback Indic script support, covering
- * some scripts that the 'latin' submodule of the 'autofit' module doesn't
- * (yet) handle. Currently, this needs option `AF_CONFIG_OPTION_CJK`.
- */
-#ifdef AF_CONFIG_OPTION_CJK
-#define AF_CONFIG_OPTION_INDIC
-#endif
-
-
- /**************************************************************************
- *
- * Use TrueType-like size metrics for 'light' auto-hinting.
- *
- * It is strongly recommended to avoid this option, which exists only to
- * help some legacy applications retain its appearance and behaviour with
- * respect to auto-hinted TrueType fonts.
- *
- * The very reason this option exists at all are GNU/Linux distributions
- * like Fedora that did not un-patch the following change (which was
- * present in FreeType between versions 2.4.6 and 2.7.1, inclusive).
- *
- * ```
- * 2011-07-16 Steven Chu <steven.f.chu@gmail.com>
- *
- * [truetype] Fix metrics on size request for scalable fonts.
- * ```
- *
- * This problematic commit is now reverted (more or less).
- */
-/* #define AF_CONFIG_OPTION_TT_SIZE_METRICS */
-
- /* */
-
-
- /*
- * This macro is obsolete. Support has been removed in FreeType version
- * 2.5.
- */
-/* #define FT_CONFIG_OPTION_OLD_INTERNALS */
-
-
- /*
- * The next two macros are defined if native TrueType hinting is
- * requested by the definitions above. Don't change this.
- */
-#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
-#define TT_USE_BYTECODE_INTERPRETER
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
-#define TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
-#endif
-#endif
-
-
- /*
- * The TT_SUPPORT_COLRV1 macro is defined to indicate to clients that this
- * version of FreeType has support for 'COLR' v1 API. This definition is
- * useful to FreeType clients that want to build in support for 'COLR' v1
- * depending on a tip-of-tree checkout before it is officially released in
- * FreeType, and while the feature cannot yet be tested against using
- * version macros. Don't change this macro. This may be removed once the
- * feature is in a FreeType release version and version macros can be used
- * to test for availability.
- */
-#ifdef TT_CONFIG_OPTION_COLOR_LAYERS
-#define TT_SUPPORT_COLRV1
-#endif
-
-
- /*
- * Check CFF darkening parameters. The checks are the same as in function
- * `cff_property_set` in file `cffdrivr.c`.
- */
-#if CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1 < 0 || \
- CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 < 0 || \
- CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3 < 0 || \
- CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4 < 0 || \
- \
- CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1 < 0 || \
- CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2 < 0 || \
- CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3 < 0 || \
- CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4 < 0 || \
- \
- CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1 > \
- CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 || \
- CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 > \
- CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3 || \
- CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3 > \
- CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4 || \
- \
- CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1 > 500 || \
- CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2 > 500 || \
- CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3 > 500 || \
- CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4 > 500
-#error "Invalid CFF darkening parameters!"
-#endif
-
-
-FT_END_HEADER
-
-#endif /* FTOPTION_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/config/ftstdlib.h b/contrib/libs/freetype/include/freetype/config/ftstdlib.h
deleted file mode 100644
index e17aa7b89d..0000000000
--- a/contrib/libs/freetype/include/freetype/config/ftstdlib.h
+++ /dev/null
@@ -1,185 +0,0 @@
-/****************************************************************************
- *
- * ftstdlib.h
- *
- * ANSI-specific library and header configuration file (specification
- * only).
- *
- * Copyright (C) 2002-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /**************************************************************************
- *
- * This file is used to group all `#includes` to the ANSI~C library that
- * FreeType normally requires. It also defines macros to rename the
- * standard functions within the FreeType source code.
- *
- * Load a file which defines `FTSTDLIB_H_` before this one to override it.
- *
- */
-
-
-#ifndef FTSTDLIB_H_
-#define FTSTDLIB_H_
-
-
-#include <stddef.h>
-
-#define ft_ptrdiff_t ptrdiff_t
-
-
- /**************************************************************************
- *
- * integer limits
- *
- * `UINT_MAX` and `ULONG_MAX` are used to automatically compute the size of
- * `int` and `long` in bytes at compile-time. So far, this works for all
- * platforms the library has been tested on. We also check `ULLONG_MAX`
- * to see whether we can use 64-bit `long long` later on.
- *
- * Note that on the extremely rare platforms that do not provide integer
- * types that are _exactly_ 16 and 32~bits wide (e.g., some old Crays where
- * `int` is 36~bits), we do not make any guarantee about the correct
- * behaviour of FreeType~2 with all fonts.
- *
- * In these cases, `ftconfig.h` will refuse to compile anyway with a
- * message like 'couldn't find 32-bit type' or something similar.
- *
- */
-
-
-#include <limits.h>
-
-#define FT_CHAR_BIT CHAR_BIT
-#define FT_USHORT_MAX USHRT_MAX
-#define FT_INT_MAX INT_MAX
-#define FT_INT_MIN INT_MIN
-#define FT_UINT_MAX UINT_MAX
-#define FT_LONG_MIN LONG_MIN
-#define FT_LONG_MAX LONG_MAX
-#define FT_ULONG_MAX ULONG_MAX
-#ifdef LLONG_MAX
-#define FT_LLONG_MAX LLONG_MAX
-#endif
-#ifdef LLONG_MIN
-#define FT_LLONG_MIN LLONG_MIN
-#endif
-#ifdef ULLONG_MAX
-#define FT_ULLONG_MAX ULLONG_MAX
-#endif
-
-
- /**************************************************************************
- *
- * character and string processing
- *
- */
-
-
-#include <string.h>
-
-#define ft_memchr memchr
-#define ft_memcmp memcmp
-#define ft_memcpy memcpy
-#define ft_memmove memmove
-#define ft_memset memset
-#define ft_strcat strcat
-#define ft_strcmp strcmp
-#define ft_strcpy strcpy
-#define ft_strlen strlen
-#define ft_strncmp strncmp
-#define ft_strncpy strncpy
-#define ft_strrchr strrchr
-#define ft_strstr strstr
-
-
- /**************************************************************************
- *
- * file handling
- *
- */
-
-
-#include <stdio.h>
-
-#define FT_FILE FILE
-#define ft_fclose fclose
-#define ft_fopen fopen
-#define ft_fread fread
-#define ft_fseek fseek
-#define ft_ftell ftell
-#define ft_snprintf snprintf
-
-
- /**************************************************************************
- *
- * sorting
- *
- */
-
-
-#include <stdlib.h>
-
-#define ft_qsort qsort
-
-
- /**************************************************************************
- *
- * memory allocation
- *
- */
-
-
-#define ft_scalloc calloc
-#define ft_sfree free
-#define ft_smalloc malloc
-#define ft_srealloc realloc
-
-
- /**************************************************************************
- *
- * miscellaneous
- *
- */
-
-
-#define ft_strtol strtol
-#define ft_getenv getenv
-
-
- /**************************************************************************
- *
- * execution control
- *
- */
-
-
-#include <setjmp.h>
-
-#define ft_jmp_buf jmp_buf /* note: this cannot be a typedef since */
- /* `jmp_buf` is defined as a macro */
- /* on certain platforms */
-
-#define ft_longjmp longjmp
-#define ft_setjmp( b ) setjmp( *(ft_jmp_buf*) &(b) ) /* same thing here */
-
-
- /* The following is only used for debugging purposes, i.e., if */
- /* `FT_DEBUG_LEVEL_ERROR` or `FT_DEBUG_LEVEL_TRACE` are defined. */
-
-#include <stdarg.h>
-
-
-#endif /* FTSTDLIB_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/config/integer-types.h b/contrib/libs/freetype/include/freetype/config/integer-types.h
deleted file mode 100644
index c27505ffc4..0000000000
--- a/contrib/libs/freetype/include/freetype/config/integer-types.h
+++ /dev/null
@@ -1,250 +0,0 @@
-/****************************************************************************
- *
- * config/integer-types.h
- *
- * FreeType integer types definitions.
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-#ifndef FREETYPE_CONFIG_INTEGER_TYPES_H_
-#define FREETYPE_CONFIG_INTEGER_TYPES_H_
-
- /* There are systems (like the Texas Instruments 'C54x) where a `char` */
- /* has 16~bits. ANSI~C says that `sizeof(char)` is always~1. Since an */
- /* `int` has 16~bits also for this system, `sizeof(int)` gives~1 which */
- /* is probably unexpected. */
- /* */
- /* `CHAR_BIT` (defined in `limits.h`) gives the number of bits in a */
- /* `char` type. */
-
-#ifndef FT_CHAR_BIT
-#define FT_CHAR_BIT CHAR_BIT
-#endif
-
-#ifndef FT_SIZEOF_INT
-
- /* The size of an `int` type. */
-#if FT_UINT_MAX == 0xFFFFUL
-#define FT_SIZEOF_INT ( 16 / FT_CHAR_BIT )
-#elif FT_UINT_MAX == 0xFFFFFFFFUL
-#define FT_SIZEOF_INT ( 32 / FT_CHAR_BIT )
-#elif FT_UINT_MAX > 0xFFFFFFFFUL && FT_UINT_MAX == 0xFFFFFFFFFFFFFFFFUL
-#define FT_SIZEOF_INT ( 64 / FT_CHAR_BIT )
-#else
-#error "Unsupported size of `int' type!"
-#endif
-
-#endif /* !defined(FT_SIZEOF_INT) */
-
-#ifndef FT_SIZEOF_LONG
-
- /* The size of a `long` type. A five-byte `long` (as used e.g. on the */
- /* DM642) is recognized but avoided. */
-#if FT_ULONG_MAX == 0xFFFFFFFFUL
-#define FT_SIZEOF_LONG ( 32 / FT_CHAR_BIT )
-#elif FT_ULONG_MAX > 0xFFFFFFFFUL && FT_ULONG_MAX == 0xFFFFFFFFFFUL
-#define FT_SIZEOF_LONG ( 32 / FT_CHAR_BIT )
-#elif FT_ULONG_MAX > 0xFFFFFFFFUL && FT_ULONG_MAX == 0xFFFFFFFFFFFFFFFFUL
-#define FT_SIZEOF_LONG ( 64 / FT_CHAR_BIT )
-#else
-#error "Unsupported size of `long' type!"
-#endif
-
-#endif /* !defined(FT_SIZEOF_LONG) */
-
-#ifndef FT_SIZEOF_LONG_LONG
-
- /* The size of a `long long` type if available */
-#if defined( FT_ULLONG_MAX ) && FT_ULLONG_MAX >= 0xFFFFFFFFFFFFFFFFULL
-#define FT_SIZEOF_LONG_LONG ( 64 / FT_CHAR_BIT )
-#else
-#define FT_SIZEOF_LONG_LONG 0
-#endif
-
-#endif /* !defined(FT_SIZEOF_LONG_LONG) */
-
-
- /**************************************************************************
- *
- * @section:
- * basic_types
- *
- */
-
-
- /**************************************************************************
- *
- * @type:
- * FT_Int16
- *
- * @description:
- * A typedef for a 16bit signed integer type.
- */
- typedef signed short FT_Int16;
-
-
- /**************************************************************************
- *
- * @type:
- * FT_UInt16
- *
- * @description:
- * A typedef for a 16bit unsigned integer type.
- */
- typedef unsigned short FT_UInt16;
-
- /* */
-
-
- /* this #if 0 ... #endif clause is for documentation purposes */
-#if 0
-
- /**************************************************************************
- *
- * @type:
- * FT_Int32
- *
- * @description:
- * A typedef for a 32bit signed integer type. The size depends on the
- * configuration.
- */
- typedef signed XXX FT_Int32;
-
-
- /**************************************************************************
- *
- * @type:
- * FT_UInt32
- *
- * A typedef for a 32bit unsigned integer type. The size depends on the
- * configuration.
- */
- typedef unsigned XXX FT_UInt32;
-
-
- /**************************************************************************
- *
- * @type:
- * FT_Int64
- *
- * A typedef for a 64bit signed integer type. The size depends on the
- * configuration. Only defined if there is real 64bit support;
- * otherwise, it gets emulated with a structure (if necessary).
- */
- typedef signed XXX FT_Int64;
-
-
- /**************************************************************************
- *
- * @type:
- * FT_UInt64
- *
- * A typedef for a 64bit unsigned integer type. The size depends on the
- * configuration. Only defined if there is real 64bit support;
- * otherwise, it gets emulated with a structure (if necessary).
- */
- typedef unsigned XXX FT_UInt64;
-
- /* */
-
-#endif
-
-#if FT_SIZEOF_INT == ( 32 / FT_CHAR_BIT )
-
- typedef signed int FT_Int32;
- typedef unsigned int FT_UInt32;
-
-#elif FT_SIZEOF_LONG == ( 32 / FT_CHAR_BIT )
-
- typedef signed long FT_Int32;
- typedef unsigned long FT_UInt32;
-
-#else
-#error "no 32bit type found -- please check your configuration files"
-#endif
-
-
- /* look up an integer type that is at least 32~bits */
-#if FT_SIZEOF_INT >= ( 32 / FT_CHAR_BIT )
-
- typedef int FT_Fast;
- typedef unsigned int FT_UFast;
-
-#elif FT_SIZEOF_LONG >= ( 32 / FT_CHAR_BIT )
-
- typedef long FT_Fast;
- typedef unsigned long FT_UFast;
-
-#endif
-
-
- /* determine whether we have a 64-bit integer type */
-#if FT_SIZEOF_LONG == ( 64 / FT_CHAR_BIT )
-
-#define FT_INT64 long
-#define FT_UINT64 unsigned long
-
-#elif FT_SIZEOF_LONG_LONG >= ( 64 / FT_CHAR_BIT )
-
-#define FT_INT64 long long int
-#define FT_UINT64 unsigned long long int
-
- /**************************************************************************
- *
- * A 64-bit data type may create compilation problems if you compile in
- * strict ANSI mode. To avoid them, we disable other 64-bit data types if
- * `__STDC__` is defined. You can however ignore this rule by defining the
- * `FT_CONFIG_OPTION_FORCE_INT64` configuration macro.
- */
-#elif !defined( __STDC__ ) || defined( FT_CONFIG_OPTION_FORCE_INT64 )
-
-#if defined( _MSC_VER ) && _MSC_VER >= 900 /* Visual C++ (and Intel C++) */
-
- /* this compiler provides the `__int64` type */
-#define FT_INT64 __int64
-#define FT_UINT64 unsigned __int64
-
-#elif defined( __BORLANDC__ ) /* Borland C++ */
-
- /* XXXX: We should probably check the value of `__BORLANDC__` in order */
- /* to test the compiler version. */
-
- /* this compiler provides the `__int64` type */
-#define FT_INT64 __int64
-#define FT_UINT64 unsigned __int64
-
-#elif defined( __WATCOMC__ ) && __WATCOMC__ >= 1100 /* Watcom C++ */
-
-#define FT_INT64 long long int
-#define FT_UINT64 unsigned long long int
-
-#elif defined( __MWERKS__ ) /* Metrowerks CodeWarrior */
-
-#define FT_INT64 long long int
-#define FT_UINT64 unsigned long long int
-
-#elif defined( __GNUC__ )
-
- /* GCC provides the `long long` type */
-#define FT_INT64 long long int
-#define FT_UINT64 unsigned long long int
-
-#endif /* !__STDC__ */
-
-#endif /* FT_SIZEOF_LONG == (64 / FT_CHAR_BIT) */
-
-#ifdef FT_INT64
- typedef FT_INT64 FT_Int64;
- typedef FT_UINT64 FT_UInt64;
-#endif
-
-
-#endif /* FREETYPE_CONFIG_INTEGER_TYPES_H_ */
diff --git a/contrib/libs/freetype/include/freetype/config/mac-support.h b/contrib/libs/freetype/include/freetype/config/mac-support.h
deleted file mode 100644
index 07b6f915bd..0000000000
--- a/contrib/libs/freetype/include/freetype/config/mac-support.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/****************************************************************************
- *
- * config/mac-support.h
- *
- * Mac/OS X support configuration header.
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-#ifndef FREETYPE_CONFIG_MAC_SUPPORT_H_
-#define FREETYPE_CONFIG_MAC_SUPPORT_H_
-
- /**************************************************************************
- *
- * Mac support
- *
- * This is the only necessary change, so it is defined here instead
- * providing a new configuration file.
- */
-#if defined( __APPLE__ ) || ( defined( __MWERKS__ ) && defined( macintosh ) )
- /* No Carbon frameworks for 64bit 10.4.x. */
- /* `AvailabilityMacros.h` is available since Mac OS X 10.2, */
- /* so guess the system version by maximum errno before inclusion. */
-#include <errno.h>
-#ifdef ECANCELED /* defined since 10.2 */
-#include "AvailabilityMacros.h"
-#endif
-#if defined( __LP64__ ) && \
- ( MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 )
-#undef FT_MACINTOSH
-#endif
-
-#elif defined( __SC__ ) || defined( __MRC__ )
- /* Classic MacOS compilers */
-#include "ConditionalMacros.h"
-#if TARGET_OS_MAC
-#define FT_MACINTOSH 1
-#endif
-
-#endif /* Mac support */
-
-#endif /* FREETYPE_CONFIG_MAC_SUPPORT_H_ */
diff --git a/contrib/libs/freetype/include/freetype/config/public-macros.h b/contrib/libs/freetype/include/freetype/config/public-macros.h
deleted file mode 100644
index f56581a6ee..0000000000
--- a/contrib/libs/freetype/include/freetype/config/public-macros.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/****************************************************************************
- *
- * config/public-macros.h
- *
- * Define a set of compiler macros used in public FreeType headers.
- *
- * Copyright (C) 2020-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
- /*
- * The definitions in this file are used by the public FreeType headers
- * and thus should be considered part of the public API.
- *
- * Other compiler-specific macro definitions that are not exposed by the
- * FreeType API should go into
- * `include/freetype/internal/compiler-macros.h` instead.
- */
-#ifndef FREETYPE_CONFIG_PUBLIC_MACROS_H_
-#define FREETYPE_CONFIG_PUBLIC_MACROS_H_
-
- /*
- * `FT_BEGIN_HEADER` and `FT_END_HEADER` might have already been defined
- * by `freetype/config/ftheader.h`, but we don't want to include this
- * header here, so redefine the macros here only when needed. Their
- * definition is very stable, so keeping them in sync with the ones in the
- * header should not be a maintenance issue.
- */
-#ifndef FT_BEGIN_HEADER
-#ifdef __cplusplus
-#define FT_BEGIN_HEADER extern "C" {
-#else
-#define FT_BEGIN_HEADER /* empty */
-#endif
-#endif /* FT_BEGIN_HEADER */
-
-#ifndef FT_END_HEADER
-#ifdef __cplusplus
-#define FT_END_HEADER }
-#else
-#define FT_END_HEADER /* empty */
-#endif
-#endif /* FT_END_HEADER */
-
-
-FT_BEGIN_HEADER
-
- /*
- * Mark a function declaration as public. This ensures it will be
- * properly exported to client code. Place this before a function
- * declaration.
- *
- * NOTE: This macro should be considered an internal implementation
- * detail, and not part of the FreeType API. It is only defined here
- * because it is needed by `FT_EXPORT`.
- */
-
- /* Visual C, mingw */
-#if defined( _WIN32 )
-
-#if defined( FT2_BUILD_LIBRARY ) && defined( DLL_EXPORT )
-#define FT_PUBLIC_FUNCTION_ATTRIBUTE __declspec( dllexport )
-#elif defined( DLL_IMPORT )
-#define FT_PUBLIC_FUNCTION_ATTRIBUTE __declspec( dllimport )
-#endif
-
- /* gcc, clang */
-#elif ( defined( __GNUC__ ) && __GNUC__ >= 4 ) || defined( __clang__ )
-#define FT_PUBLIC_FUNCTION_ATTRIBUTE \
- __attribute__(( visibility( "default" ) ))
-
- /* Sun */
-#elif defined( __SUNPRO_C ) && __SUNPRO_C >= 0x550
-#define FT_PUBLIC_FUNCTION_ATTRIBUTE __global
-#endif
-
-
-#ifndef FT_PUBLIC_FUNCTION_ATTRIBUTE
-#define FT_PUBLIC_FUNCTION_ATTRIBUTE /* empty */
-#endif
-
-
- /*
- * Define a public FreeType API function. This ensures it is properly
- * exported or imported at build time. The macro parameter is the
- * function's return type as in:
- *
- * FT_EXPORT( FT_Bool )
- * FT_Object_Method( FT_Object obj,
- * ... );
- *
- * NOTE: This requires that all `FT_EXPORT` uses are inside
- * `FT_BEGIN_HEADER ... FT_END_HEADER` blocks. This guarantees that the
- * functions are exported with C linkage, even when the header is included
- * by a C++ source file.
- */
-#define FT_EXPORT( x ) FT_PUBLIC_FUNCTION_ATTRIBUTE extern x
-
-
- /*
- * `FT_UNUSED` indicates that a given parameter is not used -- this is
- * only used to get rid of unpleasant compiler warnings.
- *
- * Technically, this was not meant to be part of the public API, but some
- * third-party code depends on it.
- */
-#ifndef FT_UNUSED
-#define FT_UNUSED( arg ) ( (arg) = (arg) )
-#endif
-
-
- /*
- * Support for casts in both C and C++.
- */
-#ifdef __cplusplus
-#define FT_STATIC_CAST( type, var ) static_cast<type>(var)
-#define FT_REINTERPRET_CAST( type, var ) reinterpret_cast<type>(var)
-
-#define FT_STATIC_BYTE_CAST( type, var ) \
- static_cast<type>( static_cast<unsigned char>( var ) )
-#else
-#define FT_STATIC_CAST( type, var ) (type)(var)
-#define FT_REINTERPRET_CAST( type, var ) (type)(var)
-
-#define FT_STATIC_BYTE_CAST( type, var ) (type)(unsigned char)(var)
-#endif
-
-
-FT_END_HEADER
-
-#endif /* FREETYPE_CONFIG_PUBLIC_MACROS_H_ */
diff --git a/contrib/libs/freetype/include/freetype/freetype.h b/contrib/libs/freetype/include/freetype/freetype.h
deleted file mode 100644
index 58fc33dfe6..0000000000
--- a/contrib/libs/freetype/include/freetype/freetype.h
+++ /dev/null
@@ -1,5289 +0,0 @@
-/****************************************************************************
- *
- * freetype.h
- *
- * FreeType high-level API and common types (specification only).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FREETYPE_H_
-#define FREETYPE_H_
-
-
-#include <ft2build.h>
-#include FT_CONFIG_CONFIG_H
-#include <freetype/fttypes.h>
-#include <freetype/fterrors.h>
-
-
-FT_BEGIN_HEADER
-
-
-
- /**************************************************************************
- *
- * @section:
- * preamble
- *
- * @title:
- * Preamble
- *
- * @abstract:
- * What FreeType is and isn't
- *
- * @description:
- * FreeType is a library that provides access to glyphs in font files. It
- * scales the glyph images and their metrics to a requested size, and it
- * rasterizes the glyph images to produce pixel or subpixel alpha coverage
- * bitmaps.
- *
- * Note that FreeType is _not_ a text layout engine. You have to use
- * higher-level libraries like HarfBuzz, Pango, or ICU for that.
- *
- * Note also that FreeType does _not_ perform alpha blending or
- * compositing the resulting bitmaps or pixmaps by itself. Use your
- * favourite graphics library (for example, Cairo or Skia) to further
- * process FreeType's output.
- *
- */
-
-
- /**************************************************************************
- *
- * @section:
- * header_inclusion
- *
- * @title:
- * FreeType's header inclusion scheme
- *
- * @abstract:
- * How client applications should include FreeType header files.
- *
- * @description:
- * To be as flexible as possible (and for historical reasons), you must
- * load file `ft2build.h` first before other header files, for example
- *
- * ```
- * #include <ft2build.h>
- *
- * #include <freetype/freetype.h>
- * #include <freetype/ftoutln.h>
- * ```
- */
-
-
- /**************************************************************************
- *
- * @section:
- * user_allocation
- *
- * @title:
- * User allocation
- *
- * @abstract:
- * How client applications should allocate FreeType data structures.
- *
- * @description:
- * FreeType assumes that structures allocated by the user and passed as
- * arguments are zeroed out except for the actual data. In other words,
- * it is recommended to use `calloc` (or variants of it) instead of
- * `malloc` for allocation.
- *
- */
-
-
- /**************************************************************************
- *
- * @section:
- * font_testing_macros
- *
- * @title:
- * Font Testing Macros
- *
- * @abstract:
- * Macros to test various properties of fonts.
- *
- * @description:
- * Macros to test the most important font properties.
- *
- * It is recommended to use these high-level macros instead of directly
- * testing the corresponding flags, which are scattered over various
- * structures.
- *
- * @order:
- * FT_HAS_HORIZONTAL
- * FT_HAS_VERTICAL
- * FT_HAS_KERNING
- * FT_HAS_FIXED_SIZES
- * FT_HAS_GLYPH_NAMES
- * FT_HAS_COLOR
- * FT_HAS_MULTIPLE_MASTERS
- * FT_HAS_SVG
- * FT_HAS_SBIX
- * FT_HAS_SBIX_OVERLAY
- *
- * FT_IS_SFNT
- * FT_IS_SCALABLE
- * FT_IS_FIXED_WIDTH
- * FT_IS_CID_KEYED
- * FT_IS_TRICKY
- * FT_IS_NAMED_INSTANCE
- * FT_IS_VARIATION
- *
- */
-
-
- /**************************************************************************
- *
- * @section:
- * library_setup
- *
- * @title:
- * Library Setup
- *
- * @abstract:
- * Functions to start and end the usage of the FreeType library.
- *
- * @description:
- * Functions to start and end the usage of the FreeType library.
- *
- * Note that @FT_Library_Version and @FREETYPE_XXX are of limited use
- * because even a new release of FreeType with only documentation
- * changes increases the version number.
- *
- * @order:
- * FT_Library
- * FT_Init_FreeType
- * FT_Done_FreeType
- *
- * FT_Library_Version
- * FREETYPE_XXX
- *
- */
-
-
- /**************************************************************************
- *
- * @section:
- * face_creation
- *
- * @title:
- * Face Creation
- *
- * @abstract:
- * Functions to manage fonts.
- *
- * @description:
- * The functions and structures collected in this section operate on
- * fonts globally.
- *
- * @order:
- * FT_Face
- * FT_FaceRec
- * FT_FACE_FLAG_XXX
- * FT_STYLE_FLAG_XXX
- *
- * FT_New_Face
- * FT_Done_Face
- * FT_Reference_Face
- * FT_New_Memory_Face
- * FT_Face_Properties
- * FT_Open_Face
- * FT_Open_Args
- * FT_OPEN_XXX
- * FT_Parameter
- * FT_Attach_File
- * FT_Attach_Stream
- *
- */
-
-
- /**************************************************************************
- *
- * @section:
- * sizing_and_scaling
- *
- * @title:
- * Sizing and Scaling
- *
- * @abstract:
- * Functions to manage font sizes.
- *
- * @description:
- * The functions and structures collected in this section are related to
- * selecting and manipulating the size of a font globally.
- *
- * @order:
- * FT_Size
- * FT_SizeRec
- * FT_Size_Metrics
- *
- * FT_Bitmap_Size
- *
- * FT_Set_Char_Size
- * FT_Set_Pixel_Sizes
- * FT_Request_Size
- * FT_Select_Size
- * FT_Size_Request_Type
- * FT_Size_RequestRec
- * FT_Size_Request
- *
- * FT_Set_Transform
- * FT_Get_Transform
- *
- */
-
-
- /**************************************************************************
- *
- * @section:
- * glyph_retrieval
- *
- * @title:
- * Glyph Retrieval
- *
- * @abstract:
- * Functions to manage glyphs.
- *
- * @description:
- * The functions and structures collected in this section operate on
- * single glyphs, of which @FT_Load_Glyph is most important.
- *
- * @order:
- * FT_GlyphSlot
- * FT_GlyphSlotRec
- * FT_Glyph_Metrics
- *
- * FT_Load_Glyph
- * FT_LOAD_XXX
- * FT_LOAD_TARGET_MODE
- * FT_LOAD_TARGET_XXX
- *
- * FT_Render_Glyph
- * FT_Render_Mode
- * FT_Get_Kerning
- * FT_Kerning_Mode
- * FT_Get_Track_Kerning
- *
- */
-
-
- /**************************************************************************
- *
- * @section:
- * character_mapping
- *
- * @title:
- * Character Mapping
- *
- * @abstract:
- * Functions to manage character-to-glyph maps.
- *
- * @description:
- * This section holds functions and structures that are related to
- * mapping character input codes to glyph indices.
- *
- * Note that for many scripts the simplistic approach used by FreeType
- * of mapping a single character to a single glyph is not valid or
- * possible! In general, a higher-level library like HarfBuzz or ICU
- * should be used for handling text strings.
- *
- * @order:
- * FT_CharMap
- * FT_CharMapRec
- * FT_Encoding
- * FT_ENC_TAG
- *
- * FT_Select_Charmap
- * FT_Set_Charmap
- * FT_Get_Charmap_Index
- *
- * FT_Get_Char_Index
- * FT_Get_First_Char
- * FT_Get_Next_Char
- * FT_Load_Char
- *
- */
-
-
- /**************************************************************************
- *
- * @section:
- * information_retrieval
- *
- * @title:
- * Information Retrieval
- *
- * @abstract:
- * Functions to retrieve font and glyph information.
- *
- * @description:
- * Functions to retrieve font and glyph information. Only some very
- * basic data is covered; see also the chapter on the format-specific
- * API for more.
- *
- *
- * @order:
- * FT_Get_Name_Index
- * FT_Get_Glyph_Name
- * FT_Get_Postscript_Name
- * FT_Get_FSType_Flags
- * FT_FSTYPE_XXX
- * FT_Get_SubGlyph_Info
- * FT_SUBGLYPH_FLAG_XXX
- *
- */
-
-
- /**************************************************************************
- *
- * @section:
- * other_api_data
- *
- * @title:
- * Other API Data
- *
- * @abstract:
- * Other structures, enumerations, and macros.
- *
- * @description:
- * Other structures, enumerations, and macros. Deprecated functions are
- * also listed here.
- *
- * @order:
- * FT_Face_Internal
- * FT_Size_Internal
- * FT_Slot_Internal
- *
- * FT_SubGlyph
- *
- * FT_HAS_FAST_GLYPHS
- * FT_Face_CheckTrueTypePatents
- * FT_Face_SetUnpatentedHinting
- *
- */
-
-
- /*************************************************************************/
- /*************************************************************************/
- /* */
- /* B A S I C T Y P E S */
- /* */
- /*************************************************************************/
- /*************************************************************************/
-
-
- /**************************************************************************
- *
- * @section:
- * glyph_retrieval
- *
- */
-
- /**************************************************************************
- *
- * @struct:
- * FT_Glyph_Metrics
- *
- * @description:
- * A structure to model the metrics of a single glyph. The values are
- * expressed in 26.6 fractional pixel format; if the flag
- * @FT_LOAD_NO_SCALE has been used while loading the glyph, values are
- * expressed in font units instead.
- *
- * @fields:
- * width ::
- * The glyph's width.
- *
- * height ::
- * The glyph's height.
- *
- * horiBearingX ::
- * Left side bearing for horizontal layout.
- *
- * horiBearingY ::
- * Top side bearing for horizontal layout.
- *
- * horiAdvance ::
- * Advance width for horizontal layout.
- *
- * vertBearingX ::
- * Left side bearing for vertical layout.
- *
- * vertBearingY ::
- * Top side bearing for vertical layout. Larger positive values mean
- * further below the vertical glyph origin.
- *
- * vertAdvance ::
- * Advance height for vertical layout. Positive values mean the glyph
- * has a positive advance downward.
- *
- * @note:
- * If not disabled with @FT_LOAD_NO_HINTING, the values represent
- * dimensions of the hinted glyph (in case hinting is applicable).
- *
- * Stroking a glyph with an outside border does not increase
- * `horiAdvance` or `vertAdvance`; you have to manually adjust these
- * values to account for the added width and height.
- *
- * FreeType doesn't use the 'VORG' table data for CFF fonts because it
- * doesn't have an interface to quickly retrieve the glyph height. The
- * y~coordinate of the vertical origin can be simply computed as
- * `vertBearingY + height` after loading a glyph.
- */
- typedef struct FT_Glyph_Metrics_
- {
- FT_Pos width;
- FT_Pos height;
-
- FT_Pos horiBearingX;
- FT_Pos horiBearingY;
- FT_Pos horiAdvance;
-
- FT_Pos vertBearingX;
- FT_Pos vertBearingY;
- FT_Pos vertAdvance;
-
- } FT_Glyph_Metrics;
-
-
- /**************************************************************************
- *
- * @section:
- * sizing_and_scaling
- *
- */
-
- /**************************************************************************
- *
- * @struct:
- * FT_Bitmap_Size
- *
- * @description:
- * This structure models the metrics of a bitmap strike (i.e., a set of
- * glyphs for a given point size and resolution) in a bitmap font. It is
- * used for the `available_sizes` field of @FT_Face.
- *
- * @fields:
- * height ::
- * The vertical distance, in pixels, between two consecutive baselines.
- * It is always positive.
- *
- * width ::
- * The average width, in pixels, of all glyphs in the strike.
- *
- * size ::
- * The nominal size of the strike in 26.6 fractional points. This
- * field is not very useful.
- *
- * x_ppem ::
- * The horizontal ppem (nominal width) in 26.6 fractional pixels.
- *
- * y_ppem ::
- * The vertical ppem (nominal height) in 26.6 fractional pixels.
- *
- * @note:
- * Windows FNT:
- * The nominal size given in a FNT font is not reliable. If the driver
- * finds it incorrect, it sets `size` to some calculated values, and
- * `x_ppem` and `y_ppem` to the pixel width and height given in the
- * font, respectively.
- *
- * TrueType embedded bitmaps:
- * `size`, `width`, and `height` values are not contained in the bitmap
- * strike itself. They are computed from the global font parameters.
- */
- typedef struct FT_Bitmap_Size_
- {
- FT_Short height;
- FT_Short width;
-
- FT_Pos size;
-
- FT_Pos x_ppem;
- FT_Pos y_ppem;
-
- } FT_Bitmap_Size;
-
-
- /*************************************************************************/
- /*************************************************************************/
- /* */
- /* O B J E C T C L A S S E S */
- /* */
- /*************************************************************************/
- /*************************************************************************/
-
- /**************************************************************************
- *
- * @section:
- * library_setup
- *
- */
-
- /**************************************************************************
- *
- * @type:
- * FT_Library
- *
- * @description:
- * A handle to a FreeType library instance. Each 'library' is completely
- * independent from the others; it is the 'root' of a set of objects like
- * fonts, faces, sizes, etc.
- *
- * It also embeds a memory manager (see @FT_Memory), as well as a
- * scan-line converter object (see @FT_Raster).
- *
- * [Since 2.5.6] In multi-threaded applications it is easiest to use one
- * `FT_Library` object per thread. In case this is too cumbersome, a
- * single `FT_Library` object across threads is possible also, as long as
- * a mutex lock is used around @FT_New_Face and @FT_Done_Face.
- *
- * @note:
- * Library objects are normally created by @FT_Init_FreeType, and
- * destroyed with @FT_Done_FreeType. If you need reference-counting
- * (cf. @FT_Reference_Library), use @FT_New_Library and @FT_Done_Library.
- */
- typedef struct FT_LibraryRec_ *FT_Library;
-
-
- /**************************************************************************
- *
- * @section:
- * module_management
- *
- */
-
- /**************************************************************************
- *
- * @type:
- * FT_Module
- *
- * @description:
- * A handle to a given FreeType module object. A module can be a font
- * driver, a renderer, or anything else that provides services to the
- * former.
- */
- typedef struct FT_ModuleRec_* FT_Module;
-
-
- /**************************************************************************
- *
- * @type:
- * FT_Driver
- *
- * @description:
- * A handle to a given FreeType font driver object. A font driver is a
- * module capable of creating faces from font files.
- */
- typedef struct FT_DriverRec_* FT_Driver;
-
-
- /**************************************************************************
- *
- * @type:
- * FT_Renderer
- *
- * @description:
- * A handle to a given FreeType renderer. A renderer is a module in
- * charge of converting a glyph's outline image to a bitmap. It supports
- * a single glyph image format, and one or more target surface depths.
- */
- typedef struct FT_RendererRec_* FT_Renderer;
-
-
- /**************************************************************************
- *
- * @section:
- * face_creation
- *
- */
-
- /**************************************************************************
- *
- * @type:
- * FT_Face
- *
- * @description:
- * A handle to a typographic face object. A face object models a given
- * typeface, in a given style.
- *
- * @note:
- * A face object also owns a single @FT_GlyphSlot object, as well as one
- * or more @FT_Size objects.
- *
- * Use @FT_New_Face or @FT_Open_Face to create a new face object from a
- * given filepath or a custom input stream.
- *
- * Use @FT_Done_Face to destroy it (along with its slot and sizes).
- *
- * An `FT_Face` object can only be safely used from one thread at a time.
- * Similarly, creation and destruction of `FT_Face` with the same
- * @FT_Library object can only be done from one thread at a time. On the
- * other hand, functions like @FT_Load_Glyph and its siblings are
- * thread-safe and do not need the lock to be held as long as the same
- * `FT_Face` object is not used from multiple threads at the same time.
- *
- * @also:
- * See @FT_FaceRec for the publicly accessible fields of a given face
- * object.
- */
- typedef struct FT_FaceRec_* FT_Face;
-
-
- /**************************************************************************
- *
- * @section:
- * sizing_and_scaling
- *
- */
-
- /**************************************************************************
- *
- * @type:
- * FT_Size
- *
- * @description:
- * A handle to an object that models a face scaled to a given character
- * size.
- *
- * @note:
- * An @FT_Face has one _active_ `FT_Size` object that is used by
- * functions like @FT_Load_Glyph to determine the scaling transformation
- * that in turn is used to load and hint glyphs and metrics.
- *
- * A newly created `FT_Size` object contains only meaningless zero values.
- * You must use @FT_Set_Char_Size, @FT_Set_Pixel_Sizes, @FT_Request_Size
- * or even @FT_Select_Size to change the content (i.e., the scaling
- * values) of the active `FT_Size`. Otherwise, the scaling and hinting
- * will not be performed.
- *
- * You can use @FT_New_Size to create additional size objects for a given
- * @FT_Face, but they won't be used by other functions until you activate
- * it through @FT_Activate_Size. Only one size can be activated at any
- * given time per face.
- *
- * @also:
- * See @FT_SizeRec for the publicly accessible fields of a given size
- * object.
- */
- typedef struct FT_SizeRec_* FT_Size;
-
-
- /**************************************************************************
- *
- * @section:
- * glyph_retrieval
- *
- */
-
- /**************************************************************************
- *
- * @type:
- * FT_GlyphSlot
- *
- * @description:
- * A handle to a given 'glyph slot'. A slot is a container that can hold
- * any of the glyphs contained in its parent face.
- *
- * In other words, each time you call @FT_Load_Glyph or @FT_Load_Char,
- * the slot's content is erased by the new glyph data, i.e., the glyph's
- * metrics, its image (bitmap or outline), and other control information.
- *
- * @also:
- * See @FT_GlyphSlotRec for the publicly accessible glyph fields.
- */
- typedef struct FT_GlyphSlotRec_* FT_GlyphSlot;
-
-
- /**************************************************************************
- *
- * @section:
- * character_mapping
- *
- */
-
- /**************************************************************************
- *
- * @type:
- * FT_CharMap
- *
- * @description:
- * A handle to a character map (usually abbreviated to 'charmap'). A
- * charmap is used to translate character codes in a given encoding into
- * glyph indexes for its parent's face. Some font formats may provide
- * several charmaps per font.
- *
- * Each face object owns zero or more charmaps, but only one of them can
- * be 'active', providing the data used by @FT_Get_Char_Index or
- * @FT_Load_Char.
- *
- * The list of available charmaps in a face is available through the
- * `face->num_charmaps` and `face->charmaps` fields of @FT_FaceRec.
- *
- * The currently active charmap is available as `face->charmap`. You
- * should call @FT_Set_Charmap to change it.
- *
- * @note:
- * When a new face is created (either through @FT_New_Face or
- * @FT_Open_Face), the library looks for a Unicode charmap within the
- * list and automatically activates it. If there is no Unicode charmap,
- * FreeType doesn't set an 'active' charmap.
- *
- * @also:
- * See @FT_CharMapRec for the publicly accessible fields of a given
- * character map.
- */
- typedef struct FT_CharMapRec_* FT_CharMap;
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_ENC_TAG
- *
- * @description:
- * This macro converts four-letter tags into an unsigned long. It is
- * used to define 'encoding' identifiers (see @FT_Encoding).
- *
- * @note:
- * Since many 16-bit compilers don't like 32-bit enumerations, you should
- * redefine this macro in case of problems to something like this:
- *
- * ```
- * #define FT_ENC_TAG( value, a, b, c, d ) value
- * ```
- *
- * to get a simple enumeration without assigning special numbers.
- */
-
-#ifndef FT_ENC_TAG
-
-#define FT_ENC_TAG( value, a, b, c, d ) \
- value = ( ( FT_STATIC_BYTE_CAST( FT_UInt32, a ) << 24 ) | \
- ( FT_STATIC_BYTE_CAST( FT_UInt32, b ) << 16 ) | \
- ( FT_STATIC_BYTE_CAST( FT_UInt32, c ) << 8 ) | \
- FT_STATIC_BYTE_CAST( FT_UInt32, d ) )
-
-#endif /* FT_ENC_TAG */
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_Encoding
- *
- * @description:
- * An enumeration to specify character sets supported by charmaps. Used
- * in the @FT_Select_Charmap API function.
- *
- * @note:
- * Despite the name, this enumeration lists specific character
- * repertoires (i.e., charsets), and not text encoding methods (e.g.,
- * UTF-8, UTF-16, etc.).
- *
- * Other encodings might be defined in the future.
- *
- * @values:
- * FT_ENCODING_NONE ::
- * The encoding value~0 is reserved for all formats except BDF, PCF,
- * and Windows FNT; see below for more information.
- *
- * FT_ENCODING_UNICODE ::
- * The Unicode character set. This value covers all versions of the
- * Unicode repertoire, including ASCII and Latin-1. Most fonts include
- * a Unicode charmap, but not all of them.
- *
- * For example, if you want to access Unicode value U+1F028 (and the
- * font contains it), use value 0x1F028 as the input value for
- * @FT_Get_Char_Index.
- *
- * FT_ENCODING_MS_SYMBOL ::
- * Microsoft Symbol encoding, used to encode mathematical symbols and
- * wingdings. For more information, see
- * 'https://www.microsoft.com/typography/otspec/recom.htm#non-standard-symbol-fonts',
- * 'http://www.kostis.net/charsets/symbol.htm', and
- * 'http://www.kostis.net/charsets/wingding.htm'.
- *
- * This encoding uses character codes from the PUA (Private Unicode
- * Area) in the range U+F020-U+F0FF.
- *
- * FT_ENCODING_SJIS ::
- * Shift JIS encoding for Japanese. More info at
- * 'https://en.wikipedia.org/wiki/Shift_JIS'. See note on multi-byte
- * encodings below.
- *
- * FT_ENCODING_PRC ::
- * Corresponds to encoding systems mainly for Simplified Chinese as
- * used in People's Republic of China (PRC). The encoding layout is
- * based on GB~2312 and its supersets GBK and GB~18030.
- *
- * FT_ENCODING_BIG5 ::
- * Corresponds to an encoding system for Traditional Chinese as used in
- * Taiwan and Hong Kong.
- *
- * FT_ENCODING_WANSUNG ::
- * Corresponds to the Korean encoding system known as Extended Wansung
- * (MS Windows code page 949). For more information see
- * 'https://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WindowsBestFit/bestfit949.txt'.
- *
- * FT_ENCODING_JOHAB ::
- * The Korean standard character set (KS~C 5601-1992), which
- * corresponds to MS Windows code page 1361. This character set
- * includes all possible Hangul character combinations.
- *
- * FT_ENCODING_ADOBE_LATIN_1 ::
- * Corresponds to a Latin-1 encoding as defined in a Type~1 PostScript
- * font. It is limited to 256 character codes.
- *
- * FT_ENCODING_ADOBE_STANDARD ::
- * Adobe Standard encoding, as found in Type~1, CFF, and OpenType/CFF
- * fonts. It is limited to 256 character codes.
- *
- * FT_ENCODING_ADOBE_EXPERT ::
- * Adobe Expert encoding, as found in Type~1, CFF, and OpenType/CFF
- * fonts. It is limited to 256 character codes.
- *
- * FT_ENCODING_ADOBE_CUSTOM ::
- * Corresponds to a custom encoding, as found in Type~1, CFF, and
- * OpenType/CFF fonts. It is limited to 256 character codes.
- *
- * FT_ENCODING_APPLE_ROMAN ::
- * Apple roman encoding. Many TrueType and OpenType fonts contain a
- * charmap for this 8-bit encoding, since older versions of Mac OS are
- * able to use it.
- *
- * FT_ENCODING_OLD_LATIN_2 ::
- * This value is deprecated and was neither used nor reported by
- * FreeType. Don't use or test for it.
- *
- * FT_ENCODING_MS_SJIS ::
- * Same as FT_ENCODING_SJIS. Deprecated.
- *
- * FT_ENCODING_MS_GB2312 ::
- * Same as FT_ENCODING_PRC. Deprecated.
- *
- * FT_ENCODING_MS_BIG5 ::
- * Same as FT_ENCODING_BIG5. Deprecated.
- *
- * FT_ENCODING_MS_WANSUNG ::
- * Same as FT_ENCODING_WANSUNG. Deprecated.
- *
- * FT_ENCODING_MS_JOHAB ::
- * Same as FT_ENCODING_JOHAB. Deprecated.
- *
- * @note:
- * When loading a font, FreeType makes a Unicode charmap active if
- * possible (either if the font provides such a charmap, or if FreeType
- * can synthesize one from PostScript glyph name dictionaries; in either
- * case, the charmap is tagged with `FT_ENCODING_UNICODE`). If such a
- * charmap is synthesized, it is placed at the first position of the
- * charmap array.
- *
- * All other encodings are considered legacy and tagged only if
- * explicitly defined in the font file. Otherwise, `FT_ENCODING_NONE` is
- * used.
- *
- * `FT_ENCODING_NONE` is set by the BDF and PCF drivers if the charmap is
- * neither Unicode nor ISO-8859-1 (otherwise it is set to
- * `FT_ENCODING_UNICODE`). Use @FT_Get_BDF_Charset_ID to find out which
- * encoding is really present. If, for example, the `cs_registry` field
- * is 'KOI8' and the `cs_encoding` field is 'R', the font is encoded in
- * KOI8-R.
- *
- * `FT_ENCODING_NONE` is always set (with a single exception) by the
- * winfonts driver. Use @FT_Get_WinFNT_Header and examine the `charset`
- * field of the @FT_WinFNT_HeaderRec structure to find out which encoding
- * is really present. For example, @FT_WinFNT_ID_CP1251 (204) means
- * Windows code page 1251 (for Russian).
- *
- * `FT_ENCODING_NONE` is set if `platform_id` is @TT_PLATFORM_MACINTOSH
- * and `encoding_id` is not `TT_MAC_ID_ROMAN` (otherwise it is set to
- * `FT_ENCODING_APPLE_ROMAN`).
- *
- * If `platform_id` is @TT_PLATFORM_MACINTOSH, use the function
- * @FT_Get_CMap_Language_ID to query the Mac language ID that may be
- * needed to be able to distinguish Apple encoding variants. See
- *
- * https://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/Readme.txt
- *
- * to get an idea how to do that. Basically, if the language ID is~0,
- * don't use it, otherwise subtract 1 from the language ID. Then examine
- * `encoding_id`. If, for example, `encoding_id` is `TT_MAC_ID_ROMAN`
- * and the language ID (minus~1) is `TT_MAC_LANGID_GREEK`, it is the
- * Greek encoding, not Roman. `TT_MAC_ID_ARABIC` with
- * `TT_MAC_LANGID_FARSI` means the Farsi variant of the Arabic encoding.
- */
- typedef enum FT_Encoding_
- {
- FT_ENC_TAG( FT_ENCODING_NONE, 0, 0, 0, 0 ),
-
- FT_ENC_TAG( FT_ENCODING_MS_SYMBOL, 's', 'y', 'm', 'b' ),
- FT_ENC_TAG( FT_ENCODING_UNICODE, 'u', 'n', 'i', 'c' ),
-
- FT_ENC_TAG( FT_ENCODING_SJIS, 's', 'j', 'i', 's' ),
- FT_ENC_TAG( FT_ENCODING_PRC, 'g', 'b', ' ', ' ' ),
- FT_ENC_TAG( FT_ENCODING_BIG5, 'b', 'i', 'g', '5' ),
- FT_ENC_TAG( FT_ENCODING_WANSUNG, 'w', 'a', 'n', 's' ),
- FT_ENC_TAG( FT_ENCODING_JOHAB, 'j', 'o', 'h', 'a' ),
-
- /* for backward compatibility */
- FT_ENCODING_GB2312 = FT_ENCODING_PRC,
- FT_ENCODING_MS_SJIS = FT_ENCODING_SJIS,
- FT_ENCODING_MS_GB2312 = FT_ENCODING_PRC,
- FT_ENCODING_MS_BIG5 = FT_ENCODING_BIG5,
- FT_ENCODING_MS_WANSUNG = FT_ENCODING_WANSUNG,
- FT_ENCODING_MS_JOHAB = FT_ENCODING_JOHAB,
-
- FT_ENC_TAG( FT_ENCODING_ADOBE_STANDARD, 'A', 'D', 'O', 'B' ),
- FT_ENC_TAG( FT_ENCODING_ADOBE_EXPERT, 'A', 'D', 'B', 'E' ),
- FT_ENC_TAG( FT_ENCODING_ADOBE_CUSTOM, 'A', 'D', 'B', 'C' ),
- FT_ENC_TAG( FT_ENCODING_ADOBE_LATIN_1, 'l', 'a', 't', '1' ),
-
- FT_ENC_TAG( FT_ENCODING_OLD_LATIN_2, 'l', 'a', 't', '2' ),
-
- FT_ENC_TAG( FT_ENCODING_APPLE_ROMAN, 'a', 'r', 'm', 'n' )
-
- } FT_Encoding;
-
-
- /* these constants are deprecated; use the corresponding `FT_Encoding` */
- /* values instead */
-#define ft_encoding_none FT_ENCODING_NONE
-#define ft_encoding_unicode FT_ENCODING_UNICODE
-#define ft_encoding_symbol FT_ENCODING_MS_SYMBOL
-#define ft_encoding_latin_1 FT_ENCODING_ADOBE_LATIN_1
-#define ft_encoding_latin_2 FT_ENCODING_OLD_LATIN_2
-#define ft_encoding_sjis FT_ENCODING_SJIS
-#define ft_encoding_gb2312 FT_ENCODING_PRC
-#define ft_encoding_big5 FT_ENCODING_BIG5
-#define ft_encoding_wansung FT_ENCODING_WANSUNG
-#define ft_encoding_johab FT_ENCODING_JOHAB
-
-#define ft_encoding_adobe_standard FT_ENCODING_ADOBE_STANDARD
-#define ft_encoding_adobe_expert FT_ENCODING_ADOBE_EXPERT
-#define ft_encoding_adobe_custom FT_ENCODING_ADOBE_CUSTOM
-#define ft_encoding_apple_roman FT_ENCODING_APPLE_ROMAN
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_CharMapRec
- *
- * @description:
- * The base charmap structure.
- *
- * @fields:
- * face ::
- * A handle to the parent face object.
- *
- * encoding ::
- * An @FT_Encoding tag identifying the charmap. Use this with
- * @FT_Select_Charmap.
- *
- * platform_id ::
- * An ID number describing the platform for the following encoding ID.
- * This comes directly from the TrueType specification and gets
- * emulated for other formats.
- *
- * encoding_id ::
- * A platform-specific encoding number. This also comes from the
- * TrueType specification and gets emulated similarly.
- */
- typedef struct FT_CharMapRec_
- {
- FT_Face face;
- FT_Encoding encoding;
- FT_UShort platform_id;
- FT_UShort encoding_id;
-
- } FT_CharMapRec;
-
-
- /*************************************************************************/
- /*************************************************************************/
- /* */
- /* B A S E O B J E C T C L A S S E S */
- /* */
- /*************************************************************************/
- /*************************************************************************/
-
-
- /**************************************************************************
- *
- * @section:
- * other_api_data
- *
- */
-
- /**************************************************************************
- *
- * @type:
- * FT_Face_Internal
- *
- * @description:
- * An opaque handle to an `FT_Face_InternalRec` structure that models the
- * private data of a given @FT_Face object.
- *
- * This structure might change between releases of FreeType~2 and is not
- * generally available to client applications.
- */
- typedef struct FT_Face_InternalRec_* FT_Face_Internal;
-
-
- /**************************************************************************
- *
- * @section:
- * face_creation
- *
- */
-
- /**************************************************************************
- *
- * @struct:
- * FT_FaceRec
- *
- * @description:
- * FreeType root face class structure. A face object models a typeface
- * in a font file.
- *
- * @fields:
- * num_faces ::
- * The number of faces in the font file. Some font formats can have
- * multiple faces in a single font file.
- *
- * face_index ::
- * This field holds two different values. Bits 0-15 are the index of
- * the face in the font file (starting with value~0). They are set
- * to~0 if there is only one face in the font file.
- *
- * [Since 2.6.1] Bits 16-30 are relevant to GX and OpenType variation
- * fonts only, holding the named instance index for the current face
- * index (starting with value~1; value~0 indicates font access without
- * a named instance). For non-variation fonts, bits 16-30 are ignored.
- * If we have the third named instance of face~4, say, `face_index` is
- * set to 0x00030004.
- *
- * Bit 31 is always zero (that is, `face_index` is always a positive
- * value).
- *
- * [Since 2.9] Changing the design coordinates with
- * @FT_Set_Var_Design_Coordinates or @FT_Set_Var_Blend_Coordinates does
- * not influence the named instance index value (only
- * @FT_Set_Named_Instance does that).
- *
- * face_flags ::
- * A set of bit flags that give important information about the face;
- * see @FT_FACE_FLAG_XXX for the details.
- *
- * style_flags ::
- * The lower 16~bits contain a set of bit flags indicating the style of
- * the face; see @FT_STYLE_FLAG_XXX for the details.
- *
- * [Since 2.6.1] Bits 16-30 hold the number of named instances
- * available for the current face if we have a GX or OpenType variation
- * (sub)font. Bit 31 is always zero (that is, `style_flags` is always
- * a positive value). Note that a variation font has always at least
- * one named instance, namely the default instance.
- *
- * num_glyphs ::
- * The number of glyphs in the face. If the face is scalable and has
- * sbits (see `num_fixed_sizes`), it is set to the number of outline
- * glyphs.
- *
- * For CID-keyed fonts (not in an SFNT wrapper) this value gives the
- * highest CID used in the font.
- *
- * family_name ::
- * The face's family name. This is an ASCII string, usually in
- * English, that describes the typeface's family (like 'Times New
- * Roman', 'Bodoni', 'Garamond', etc). This is a least common
- * denominator used to list fonts. Some formats (TrueType & OpenType)
- * provide localized and Unicode versions of this string. Applications
- * should use the format-specific interface to access them. Can be
- * `NULL` (e.g., in fonts embedded in a PDF file).
- *
- * In case the font doesn't provide a specific family name entry,
- * FreeType tries to synthesize one, deriving it from other name
- * entries.
- *
- * style_name ::
- * The face's style name. This is an ASCII string, usually in English,
- * that describes the typeface's style (like 'Italic', 'Bold',
- * 'Condensed', etc). Not all font formats provide a style name, so
- * this field is optional, and can be set to `NULL`. As for
- * `family_name`, some formats provide localized and Unicode versions
- * of this string. Applications should use the format-specific
- * interface to access them.
- *
- * num_fixed_sizes ::
- * The number of bitmap strikes in the face. Even if the face is
- * scalable, there might still be bitmap strikes, which are called
- * 'sbits' in that case.
- *
- * available_sizes ::
- * An array of @FT_Bitmap_Size for all bitmap strikes in the face. It
- * is set to `NULL` if there is no bitmap strike.
- *
- * Note that FreeType tries to sanitize the strike data since they are
- * sometimes sloppy or incorrect, but this can easily fail.
- *
- * num_charmaps ::
- * The number of charmaps in the face.
- *
- * charmaps ::
- * An array of the charmaps of the face.
- *
- * generic ::
- * A field reserved for client uses. See the @FT_Generic type
- * description.
- *
- * bbox ::
- * The font bounding box. Coordinates are expressed in font units (see
- * `units_per_EM`). The box is large enough to contain any glyph from
- * the font. Thus, `bbox.yMax` can be seen as the 'maximum ascender',
- * and `bbox.yMin` as the 'minimum descender'. Only relevant for
- * scalable formats.
- *
- * Note that the bounding box might be off by (at least) one pixel for
- * hinted fonts. See @FT_Size_Metrics for further discussion.
- *
- * Note that the bounding box does not vary in OpenType variation fonts
- * and should only be used in relation to the default instance.
- *
- * units_per_EM ::
- * The number of font units per EM square for this face. This is
- * typically 2048 for TrueType fonts, and 1000 for Type~1 fonts. Only
- * relevant for scalable formats.
- *
- * ascender ::
- * The typographic ascender of the face, expressed in font units. For
- * font formats not having this information, it is set to `bbox.yMax`.
- * Only relevant for scalable formats.
- *
- * descender ::
- * The typographic descender of the face, expressed in font units. For
- * font formats not having this information, it is set to `bbox.yMin`.
- * Note that this field is negative for values below the baseline.
- * Only relevant for scalable formats.
- *
- * height ::
- * This value is the vertical distance between two consecutive
- * baselines, expressed in font units. It is always positive. Only
- * relevant for scalable formats.
- *
- * If you want the global glyph height, use `ascender - descender`.
- *
- * max_advance_width ::
- * The maximum advance width, in font units, for all glyphs in this
- * face. This can be used to make word wrapping computations faster.
- * Only relevant for scalable formats.
- *
- * max_advance_height ::
- * The maximum advance height, in font units, for all glyphs in this
- * face. This is only relevant for vertical layouts, and is set to
- * `height` for fonts that do not provide vertical metrics. Only
- * relevant for scalable formats.
- *
- * underline_position ::
- * The position, in font units, of the underline line for this face.
- * It is the center of the underlining stem. Only relevant for
- * scalable formats.
- *
- * underline_thickness ::
- * The thickness, in font units, of the underline for this face. Only
- * relevant for scalable formats.
- *
- * glyph ::
- * The face's associated glyph slot(s).
- *
- * size ::
- * The current active size for this face.
- *
- * charmap ::
- * The current active charmap for this face.
- *
- * @note:
- * Fields may be changed after a call to @FT_Attach_File or
- * @FT_Attach_Stream.
- *
- * For an OpenType variation font, the values of the following fields can
- * change after a call to @FT_Set_Var_Design_Coordinates (and friends) if
- * the font contains an 'MVAR' table: `ascender`, `descender`, `height`,
- * `underline_position`, and `underline_thickness`.
- *
- * Especially for TrueType fonts see also the documentation for
- * @FT_Size_Metrics.
- */
- typedef struct FT_FaceRec_
- {
- FT_Long num_faces;
- FT_Long face_index;
-
- FT_Long face_flags;
- FT_Long style_flags;
-
- FT_Long num_glyphs;
-
- FT_String* family_name;
- FT_String* style_name;
-
- FT_Int num_fixed_sizes;
- FT_Bitmap_Size* available_sizes;
-
- FT_Int num_charmaps;
- FT_CharMap* charmaps;
-
- FT_Generic generic;
-
- /* The following member variables (down to `underline_thickness`) */
- /* are only relevant to scalable outlines; cf. @FT_Bitmap_Size */
- /* for bitmap fonts. */
- FT_BBox bbox;
-
- FT_UShort units_per_EM;
- FT_Short ascender;
- FT_Short descender;
- FT_Short height;
-
- FT_Short max_advance_width;
- FT_Short max_advance_height;
-
- FT_Short underline_position;
- FT_Short underline_thickness;
-
- FT_GlyphSlot glyph;
- FT_Size size;
- FT_CharMap charmap;
-
- /* private fields, internal to FreeType */
-
- FT_Driver driver;
- FT_Memory memory;
- FT_Stream stream;
-
- FT_ListRec sizes_list;
-
- FT_Generic autohint; /* face-specific auto-hinter data */
- void* extensions; /* unused */
-
- FT_Face_Internal internal;
-
- } FT_FaceRec;
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_FACE_FLAG_XXX
- *
- * @description:
- * A list of bit flags used in the `face_flags` field of the @FT_FaceRec
- * structure. They inform client applications of properties of the
- * corresponding face.
- *
- * @values:
- * FT_FACE_FLAG_SCALABLE ::
- * The face contains outline glyphs. Note that a face can contain
- * bitmap strikes also, i.e., a face can have both this flag and
- * @FT_FACE_FLAG_FIXED_SIZES set.
- *
- * FT_FACE_FLAG_FIXED_SIZES ::
- * The face contains bitmap strikes. See also the `num_fixed_sizes`
- * and `available_sizes` fields of @FT_FaceRec.
- *
- * FT_FACE_FLAG_FIXED_WIDTH ::
- * The face contains fixed-width characters (like Courier, Lucida,
- * MonoType, etc.).
- *
- * FT_FACE_FLAG_SFNT ::
- * The face uses the SFNT storage scheme. For now, this means TrueType
- * and OpenType.
- *
- * FT_FACE_FLAG_HORIZONTAL ::
- * The face contains horizontal glyph metrics. This should be set for
- * all common formats.
- *
- * FT_FACE_FLAG_VERTICAL ::
- * The face contains vertical glyph metrics. This is only available in
- * some formats, not all of them.
- *
- * FT_FACE_FLAG_KERNING ::
- * The face contains kerning information. If set, the kerning distance
- * can be retrieved using the function @FT_Get_Kerning. Otherwise the
- * function always returns the vector (0,0).
- *
- * Note that for TrueType fonts only, FreeType supports both the 'kern'
- * table and the basic, pair-wise kerning feature from the 'GPOS' table
- * (with `TT_CONFIG_OPTION_GPOS_KERNING` enabled), though FreeType does
- * not support the more advanced GPOS layout features; use a library
- * like HarfBuzz for those instead.
- *
- * FT_FACE_FLAG_FAST_GLYPHS ::
- * THIS FLAG IS DEPRECATED. DO NOT USE OR TEST IT.
- *
- * FT_FACE_FLAG_MULTIPLE_MASTERS ::
- * The face contains multiple masters and is capable of interpolating
- * between them. Supported formats are Adobe MM, TrueType GX, and
- * OpenType variation fonts.
- *
- * See section @multiple_masters for API details.
- *
- * FT_FACE_FLAG_GLYPH_NAMES ::
- * The face contains glyph names, which can be retrieved using
- * @FT_Get_Glyph_Name. Note that some TrueType fonts contain broken
- * glyph name tables. Use the function @FT_Has_PS_Glyph_Names when
- * needed.
- *
- * FT_FACE_FLAG_EXTERNAL_STREAM ::
- * Used internally by FreeType to indicate that a face's stream was
- * provided by the client application and should not be destroyed when
- * @FT_Done_Face is called. Don't read or test this flag.
- *
- * FT_FACE_FLAG_HINTER ::
- * The font driver has a hinting machine of its own. For example, with
- * TrueType fonts, it makes sense to use data from the SFNT 'gasp'
- * table only if the native TrueType hinting engine (with the bytecode
- * interpreter) is available and active.
- *
- * FT_FACE_FLAG_CID_KEYED ::
- * The face is CID-keyed. In that case, the face is not accessed by
- * glyph indices but by CID values. For subsetted CID-keyed fonts this
- * has the consequence that not all index values are a valid argument
- * to @FT_Load_Glyph. Only the CID values for which corresponding
- * glyphs in the subsetted font exist make `FT_Load_Glyph` return
- * successfully; in all other cases you get an
- * `FT_Err_Invalid_Argument` error.
- *
- * Note that CID-keyed fonts that are in an SFNT wrapper (that is, all
- * OpenType/CFF fonts) don't have this flag set since the glyphs are
- * accessed in the normal way (using contiguous indices); the
- * 'CID-ness' isn't visible to the application.
- *
- * FT_FACE_FLAG_TRICKY ::
- * The face is 'tricky', that is, it always needs the font format's
- * native hinting engine to get a reasonable result. A typical example
- * is the old Chinese font `mingli.ttf` (but not `mingliu.ttc`) that
- * uses TrueType bytecode instructions to move and scale all of its
- * subglyphs.
- *
- * It is not possible to auto-hint such fonts using
- * @FT_LOAD_FORCE_AUTOHINT; it will also ignore @FT_LOAD_NO_HINTING.
- * You have to set both @FT_LOAD_NO_HINTING and @FT_LOAD_NO_AUTOHINT to
- * really disable hinting; however, you probably never want this except
- * for demonstration purposes.
- *
- * Currently, there are about a dozen TrueType fonts in the list of
- * tricky fonts; they are hard-coded in file `ttobjs.c`.
- *
- * FT_FACE_FLAG_COLOR ::
- * [Since 2.5.1] The face has color glyph tables. See @FT_LOAD_COLOR
- * for more information.
- *
- * FT_FACE_FLAG_VARIATION ::
- * [Since 2.9] Set if the current face (or named instance) has been
- * altered with @FT_Set_MM_Design_Coordinates,
- * @FT_Set_Var_Design_Coordinates, @FT_Set_Var_Blend_Coordinates, or
- * @FT_Set_MM_WeightVector to select a non-default instance.
- *
- * FT_FACE_FLAG_SVG ::
- * [Since 2.12] The face has an 'SVG~' OpenType table.
- *
- * FT_FACE_FLAG_SBIX ::
- * [Since 2.12] The face has an 'sbix' OpenType table *and* outlines.
- * For such fonts, @FT_FACE_FLAG_SCALABLE is not set by default to
- * retain backward compatibility.
- *
- * FT_FACE_FLAG_SBIX_OVERLAY ::
- * [Since 2.12] The face has an 'sbix' OpenType table where outlines
- * should be drawn on top of bitmap strikes.
- *
- */
-#define FT_FACE_FLAG_SCALABLE ( 1L << 0 )
-#define FT_FACE_FLAG_FIXED_SIZES ( 1L << 1 )
-#define FT_FACE_FLAG_FIXED_WIDTH ( 1L << 2 )
-#define FT_FACE_FLAG_SFNT ( 1L << 3 )
-#define FT_FACE_FLAG_HORIZONTAL ( 1L << 4 )
-#define FT_FACE_FLAG_VERTICAL ( 1L << 5 )
-#define FT_FACE_FLAG_KERNING ( 1L << 6 )
-#define FT_FACE_FLAG_FAST_GLYPHS ( 1L << 7 )
-#define FT_FACE_FLAG_MULTIPLE_MASTERS ( 1L << 8 )
-#define FT_FACE_FLAG_GLYPH_NAMES ( 1L << 9 )
-#define FT_FACE_FLAG_EXTERNAL_STREAM ( 1L << 10 )
-#define FT_FACE_FLAG_HINTER ( 1L << 11 )
-#define FT_FACE_FLAG_CID_KEYED ( 1L << 12 )
-#define FT_FACE_FLAG_TRICKY ( 1L << 13 )
-#define FT_FACE_FLAG_COLOR ( 1L << 14 )
-#define FT_FACE_FLAG_VARIATION ( 1L << 15 )
-#define FT_FACE_FLAG_SVG ( 1L << 16 )
-#define FT_FACE_FLAG_SBIX ( 1L << 17 )
-#define FT_FACE_FLAG_SBIX_OVERLAY ( 1L << 18 )
-
-
- /**************************************************************************
- *
- * @section:
- * font_testing_macros
- *
- */
-
- /**************************************************************************
- *
- * @macro:
- * FT_HAS_HORIZONTAL
- *
- * @description:
- * A macro that returns true whenever a face object contains horizontal
- * metrics (this is true for all font formats though).
- *
- * @also:
- * @FT_HAS_VERTICAL can be used to check for vertical metrics.
- *
- */
-#define FT_HAS_HORIZONTAL( face ) \
- ( !!( (face)->face_flags & FT_FACE_FLAG_HORIZONTAL ) )
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_HAS_VERTICAL
- *
- * @description:
- * A macro that returns true whenever a face object contains real
- * vertical metrics (and not only synthesized ones).
- *
- */
-#define FT_HAS_VERTICAL( face ) \
- ( !!( (face)->face_flags & FT_FACE_FLAG_VERTICAL ) )
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_HAS_KERNING
- *
- * @description:
- * A macro that returns true whenever a face object contains kerning data
- * that can be accessed with @FT_Get_Kerning.
- *
- */
-#define FT_HAS_KERNING( face ) \
- ( !!( (face)->face_flags & FT_FACE_FLAG_KERNING ) )
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_IS_SCALABLE
- *
- * @description:
- * A macro that returns true whenever a face object contains a scalable
- * font face (true for TrueType, Type~1, Type~42, CID, OpenType/CFF, and
- * PFR font formats).
- *
- */
-#define FT_IS_SCALABLE( face ) \
- ( !!( (face)->face_flags & FT_FACE_FLAG_SCALABLE ) )
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_IS_SFNT
- *
- * @description:
- * A macro that returns true whenever a face object contains a font whose
- * format is based on the SFNT storage scheme. This usually means:
- * TrueType fonts, OpenType fonts, as well as SFNT-based embedded bitmap
- * fonts.
- *
- * If this macro is true, all functions defined in @FT_SFNT_NAMES_H and
- * @FT_TRUETYPE_TABLES_H are available.
- *
- */
-#define FT_IS_SFNT( face ) \
- ( !!( (face)->face_flags & FT_FACE_FLAG_SFNT ) )
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_IS_FIXED_WIDTH
- *
- * @description:
- * A macro that returns true whenever a face object contains a font face
- * that contains fixed-width (or 'monospace', 'fixed-pitch', etc.)
- * glyphs.
- *
- */
-#define FT_IS_FIXED_WIDTH( face ) \
- ( !!( (face)->face_flags & FT_FACE_FLAG_FIXED_WIDTH ) )
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_HAS_FIXED_SIZES
- *
- * @description:
- * A macro that returns true whenever a face object contains some
- * embedded bitmaps. See the `available_sizes` field of the @FT_FaceRec
- * structure.
- *
- */
-#define FT_HAS_FIXED_SIZES( face ) \
- ( !!( (face)->face_flags & FT_FACE_FLAG_FIXED_SIZES ) )
-
-
- /**************************************************************************
- *
- * @section:
- * other_api_data
- *
- */
-
- /**************************************************************************
- *
- * @macro:
- * FT_HAS_FAST_GLYPHS
- *
- * @description:
- * Deprecated.
- *
- */
-#define FT_HAS_FAST_GLYPHS( face ) 0
-
-
- /**************************************************************************
- *
- * @section:
- * font_testing_macros
- *
- */
-
- /**************************************************************************
- *
- * @macro:
- * FT_HAS_GLYPH_NAMES
- *
- * @description:
- * A macro that returns true whenever a face object contains some glyph
- * names that can be accessed through @FT_Get_Glyph_Name.
- *
- */
-#define FT_HAS_GLYPH_NAMES( face ) \
- ( !!( (face)->face_flags & FT_FACE_FLAG_GLYPH_NAMES ) )
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_HAS_MULTIPLE_MASTERS
- *
- * @description:
- * A macro that returns true whenever a face object contains some
- * multiple masters. The functions provided by @FT_MULTIPLE_MASTERS_H
- * are then available to choose the exact design you want.
- *
- */
-#define FT_HAS_MULTIPLE_MASTERS( face ) \
- ( !!( (face)->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS ) )
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_IS_NAMED_INSTANCE
- *
- * @description:
- * A macro that returns true whenever a face object is a named instance
- * of a GX or OpenType variation font.
- *
- * [Since 2.9] Changing the design coordinates with
- * @FT_Set_Var_Design_Coordinates or @FT_Set_Var_Blend_Coordinates does
- * not influence the return value of this macro (only
- * @FT_Set_Named_Instance does that).
- *
- * @since:
- * 2.7
- *
- */
-#define FT_IS_NAMED_INSTANCE( face ) \
- ( !!( (face)->face_index & 0x7FFF0000L ) )
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_IS_VARIATION
- *
- * @description:
- * A macro that returns true whenever a face object has been altered by
- * @FT_Set_MM_Design_Coordinates, @FT_Set_Var_Design_Coordinates,
- * @FT_Set_Var_Blend_Coordinates, or @FT_Set_MM_WeightVector.
- *
- * @since:
- * 2.9
- *
- */
-#define FT_IS_VARIATION( face ) \
- ( !!( (face)->face_flags & FT_FACE_FLAG_VARIATION ) )
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_IS_CID_KEYED
- *
- * @description:
- * A macro that returns true whenever a face object contains a CID-keyed
- * font. See the discussion of @FT_FACE_FLAG_CID_KEYED for more details.
- *
- * If this macro is true, all functions defined in @FT_CID_H are
- * available.
- *
- */
-#define FT_IS_CID_KEYED( face ) \
- ( !!( (face)->face_flags & FT_FACE_FLAG_CID_KEYED ) )
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_IS_TRICKY
- *
- * @description:
- * A macro that returns true whenever a face represents a 'tricky' font.
- * See the discussion of @FT_FACE_FLAG_TRICKY for more details.
- *
- */
-#define FT_IS_TRICKY( face ) \
- ( !!( (face)->face_flags & FT_FACE_FLAG_TRICKY ) )
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_HAS_COLOR
- *
- * @description:
- * A macro that returns true whenever a face object contains tables for
- * color glyphs.
- *
- * @since:
- * 2.5.1
- *
- */
-#define FT_HAS_COLOR( face ) \
- ( !!( (face)->face_flags & FT_FACE_FLAG_COLOR ) )
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_HAS_SVG
- *
- * @description:
- * A macro that returns true whenever a face object contains an 'SVG~'
- * OpenType table.
- *
- * @since:
- * 2.12
- */
-#define FT_HAS_SVG( face ) \
- ( !!( (face)->face_flags & FT_FACE_FLAG_SVG ) )
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_HAS_SBIX
- *
- * @description:
- * A macro that returns true whenever a face object contains an 'sbix'
- * OpenType table *and* outline glyphs.
- *
- * Currently, FreeType only supports bitmap glyphs in PNG format for this
- * table (i.e., JPEG and TIFF formats are unsupported, as are
- * Apple-specific formats not part of the OpenType specification).
- *
- * @note:
- * For backward compatibility, a font with an 'sbix' table is treated as
- * a bitmap-only face. Using @FT_Open_Face with
- * @FT_PARAM_TAG_IGNORE_SBIX, an application can switch off 'sbix'
- * handling so that the face is treated as an ordinary outline font with
- * scalable outlines.
- *
- * Here is some pseudo code that roughly illustrates how to implement
- * 'sbix' handling according to the OpenType specification.
- *
- * ```
- * if ( FT_HAS_SBIX( face ) )
- * {
- * // open font as a scalable one without sbix handling
- * FT_Face face2;
- * FT_Parameter param = { FT_PARAM_TAG_IGNORE_SBIX, NULL };
- * FT_Open_Args args = { FT_OPEN_PARAMS | ...,
- * ...,
- * 1, &param };
- *
- *
- * FT_Open_Face( library, &args, 0, &face2 );
- *
- * <sort `face->available_size` as necessary into
- * `preferred_sizes`[*]>
- *
- * for ( i = 0; i < face->num_fixed_sizes; i++ )
- * {
- * size = preferred_sizes[i].size;
- *
- * error = FT_Set_Pixel_Sizes( face, size, size );
- * <error handling omitted>
- *
- * // check whether we have a glyph in a bitmap strike
- * error = FT_Load_Glyph( face,
- * glyph_index,
- * FT_LOAD_SBITS_ONLY |
- * FT_LOAD_BITMAP_METRICS_ONLY );
- * if ( error == FT_Err_Invalid_Argument )
- * continue;
- * else if ( error )
- * <other error handling omitted>
- * else
- * break;
- * }
- *
- * if ( i != face->num_fixed_sizes )
- * <load embedded bitmap with `FT_Load_Glyph`,
- * scale it, display it, etc.>
- *
- * if ( i == face->num_fixed_sizes ||
- * FT_HAS_SBIX_OVERLAY( face ) )
- * <use `face2` to load outline glyph with `FT_Load_Glyph`,
- * scale it, display it on top of the bitmap, etc.>
- * }
- * ```
- *
- * [*] Assuming a target value of 400dpi and available strike sizes 100,
- * 200, 300, and 400dpi, a possible order might be [400, 200, 300, 100]:
- * scaling 200dpi to 400dpi usually gives better results than scaling
- * 300dpi to 400dpi; it is also much faster. However, scaling 100dpi to
- * 400dpi can yield a too pixelated result, thus the preference might be
- * 300dpi over 100dpi.
- *
- * @since:
- * 2.12
- */
-#define FT_HAS_SBIX( face ) \
- ( !!( (face)->face_flags & FT_FACE_FLAG_SBIX ) )
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_HAS_SBIX_OVERLAY
- *
- * @description:
- * A macro that returns true whenever a face object contains an 'sbix'
- * OpenType table with bit~1 in its `flags` field set, instructing the
- * application to overlay the bitmap strike with the corresponding
- * outline glyph. See @FT_HAS_SBIX for pseudo code how to use it.
- *
- * @since:
- * 2.12
- */
-#define FT_HAS_SBIX_OVERLAY( face ) \
- ( !!( (face)->face_flags & FT_FACE_FLAG_SBIX_OVERLAY ) )
-
-
- /**************************************************************************
- *
- * @section:
- * face_creation
- *
- */
-
- /**************************************************************************
- *
- * @enum:
- * FT_STYLE_FLAG_XXX
- *
- * @description:
- * A list of bit flags to indicate the style of a given face. These are
- * used in the `style_flags` field of @FT_FaceRec.
- *
- * @values:
- * FT_STYLE_FLAG_ITALIC ::
- * The face style is italic or oblique.
- *
- * FT_STYLE_FLAG_BOLD ::
- * The face is bold.
- *
- * @note:
- * The style information as provided by FreeType is very basic. More
- * details are beyond the scope and should be done on a higher level (for
- * example, by analyzing various fields of the 'OS/2' table in SFNT based
- * fonts).
- */
-#define FT_STYLE_FLAG_ITALIC ( 1 << 0 )
-#define FT_STYLE_FLAG_BOLD ( 1 << 1 )
-
-
- /**************************************************************************
- *
- * @section:
- * other_api_data
- *
- */
-
- /**************************************************************************
- *
- * @type:
- * FT_Size_Internal
- *
- * @description:
- * An opaque handle to an `FT_Size_InternalRec` structure, used to model
- * private data of a given @FT_Size object.
- */
- typedef struct FT_Size_InternalRec_* FT_Size_Internal;
-
-
- /**************************************************************************
- *
- * @section:
- * sizing_and_scaling
- *
- */
-
- /**************************************************************************
- *
- * @struct:
- * FT_Size_Metrics
- *
- * @description:
- * The size metrics structure gives the metrics of a size object.
- *
- * @fields:
- * x_ppem ::
- * The width of the scaled EM square in pixels, hence the term 'ppem'
- * (pixels per EM). It is also referred to as 'nominal width'.
- *
- * y_ppem ::
- * The height of the scaled EM square in pixels, hence the term 'ppem'
- * (pixels per EM). It is also referred to as 'nominal height'.
- *
- * x_scale ::
- * A 16.16 fractional scaling value to convert horizontal metrics from
- * font units to 26.6 fractional pixels. Only relevant for scalable
- * font formats.
- *
- * y_scale ::
- * A 16.16 fractional scaling value to convert vertical metrics from
- * font units to 26.6 fractional pixels. Only relevant for scalable
- * font formats.
- *
- * ascender ::
- * The ascender in 26.6 fractional pixels, rounded up to an integer
- * value. See @FT_FaceRec for the details.
- *
- * descender ::
- * The descender in 26.6 fractional pixels, rounded down to an integer
- * value. See @FT_FaceRec for the details.
- *
- * height ::
- * The height in 26.6 fractional pixels, rounded to an integer value.
- * See @FT_FaceRec for the details.
- *
- * max_advance ::
- * The maximum advance width in 26.6 fractional pixels, rounded to an
- * integer value. See @FT_FaceRec for the details.
- *
- * @note:
- * The scaling values, if relevant, are determined first during a size
- * changing operation. The remaining fields are then set by the driver.
- * For scalable formats, they are usually set to scaled values of the
- * corresponding fields in @FT_FaceRec. Some values like ascender or
- * descender are rounded for historical reasons; more precise values (for
- * outline fonts) can be derived by scaling the corresponding @FT_FaceRec
- * values manually, with code similar to the following.
- *
- * ```
- * scaled_ascender = FT_MulFix( face->ascender,
- * size_metrics->y_scale );
- * ```
- *
- * Note that due to glyph hinting and the selected rendering mode these
- * values are usually not exact; consequently, they must be treated as
- * unreliable with an error margin of at least one pixel!
- *
- * Indeed, the only way to get the exact metrics is to render _all_
- * glyphs. As this would be a definite performance hit, it is up to
- * client applications to perform such computations.
- *
- * The `FT_Size_Metrics` structure is valid for bitmap fonts also.
- *
- *
- * **TrueType fonts with native bytecode hinting**
- *
- * All applications that handle TrueType fonts with native hinting must
- * be aware that TTFs expect different rounding of vertical font
- * dimensions. The application has to cater for this, especially if it
- * wants to rely on a TTF's vertical data (for example, to properly align
- * box characters vertically).
- *
- * Only the application knows _in advance_ that it is going to use native
- * hinting for TTFs! FreeType, on the other hand, selects the hinting
- * mode not at the time of creating an @FT_Size object but much later,
- * namely while calling @FT_Load_Glyph.
- *
- * Here is some pseudo code that illustrates a possible solution.
- *
- * ```
- * font_format = FT_Get_Font_Format( face );
- *
- * if ( !strcmp( font_format, "TrueType" ) &&
- * do_native_bytecode_hinting )
- * {
- * ascender = ROUND( FT_MulFix( face->ascender,
- * size_metrics->y_scale ) );
- * descender = ROUND( FT_MulFix( face->descender,
- * size_metrics->y_scale ) );
- * }
- * else
- * {
- * ascender = size_metrics->ascender;
- * descender = size_metrics->descender;
- * }
- *
- * height = size_metrics->height;
- * max_advance = size_metrics->max_advance;
- * ```
- */
- typedef struct FT_Size_Metrics_
- {
- FT_UShort x_ppem; /* horizontal pixels per EM */
- FT_UShort y_ppem; /* vertical pixels per EM */
-
- FT_Fixed x_scale; /* scaling values used to convert font */
- FT_Fixed y_scale; /* units to 26.6 fractional pixels */
-
- FT_Pos ascender; /* ascender in 26.6 frac. pixels */
- FT_Pos descender; /* descender in 26.6 frac. pixels */
- FT_Pos height; /* text height in 26.6 frac. pixels */
- FT_Pos max_advance; /* max horizontal advance, in 26.6 pixels */
-
- } FT_Size_Metrics;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_SizeRec
- *
- * @description:
- * FreeType root size class structure. A size object models a face
- * object at a given size.
- *
- * @fields:
- * face ::
- * Handle to the parent face object.
- *
- * generic ::
- * A typeless pointer, unused by the FreeType library or any of its
- * drivers. It can be used by client applications to link their own
- * data to each size object.
- *
- * metrics ::
- * Metrics for this size object. This field is read-only.
- */
- typedef struct FT_SizeRec_
- {
- FT_Face face; /* parent face object */
- FT_Generic generic; /* generic pointer for client uses */
- FT_Size_Metrics metrics; /* size metrics */
- FT_Size_Internal internal;
-
- } FT_SizeRec;
-
-
- /**************************************************************************
- *
- * @section:
- * other_api_data
- *
- */
-
- /**************************************************************************
- *
- * @struct:
- * FT_SubGlyph
- *
- * @description:
- * The subglyph structure is an internal object used to describe
- * subglyphs (for example, in the case of composites).
- *
- * @note:
- * The subglyph implementation is not part of the high-level API, hence
- * the forward structure declaration.
- *
- * You can however retrieve subglyph information with
- * @FT_Get_SubGlyph_Info.
- */
- typedef struct FT_SubGlyphRec_* FT_SubGlyph;
-
-
- /**************************************************************************
- *
- * @type:
- * FT_Slot_Internal
- *
- * @description:
- * An opaque handle to an `FT_Slot_InternalRec` structure, used to model
- * private data of a given @FT_GlyphSlot object.
- */
- typedef struct FT_Slot_InternalRec_* FT_Slot_Internal;
-
-
- /**************************************************************************
- *
- * @section:
- * glyph_retrieval
- *
- */
-
- /**************************************************************************
- *
- * @struct:
- * FT_GlyphSlotRec
- *
- * @description:
- * FreeType root glyph slot class structure. A glyph slot is a container
- * where individual glyphs can be loaded, be they in outline or bitmap
- * format.
- *
- * @fields:
- * library ::
- * A handle to the FreeType library instance this slot belongs to.
- *
- * face ::
- * A handle to the parent face object.
- *
- * next ::
- * In some cases (like some font tools), several glyph slots per face
- * object can be a good thing. As this is rare, the glyph slots are
- * listed through a direct, single-linked list using its `next` field.
- *
- * glyph_index ::
- * [Since 2.10] The glyph index passed as an argument to @FT_Load_Glyph
- * while initializing the glyph slot.
- *
- * generic ::
- * A typeless pointer unused by the FreeType library or any of its
- * drivers. It can be used by client applications to link their own
- * data to each glyph slot object.
- *
- * metrics ::
- * The metrics of the last loaded glyph in the slot. The returned
- * values depend on the last load flags (see the @FT_Load_Glyph API
- * function) and can be expressed either in 26.6 fractional pixels or
- * font units.
- *
- * Note that even when the glyph image is transformed, the metrics are
- * not.
- *
- * linearHoriAdvance ::
- * The advance width of the unhinted glyph. Its value is expressed in
- * 16.16 fractional pixels, unless @FT_LOAD_LINEAR_DESIGN is set when
- * loading the glyph. This field can be important to perform correct
- * WYSIWYG layout. Only relevant for scalable glyphs.
- *
- * linearVertAdvance ::
- * The advance height of the unhinted glyph. Its value is expressed in
- * 16.16 fractional pixels, unless @FT_LOAD_LINEAR_DESIGN is set when
- * loading the glyph. This field can be important to perform correct
- * WYSIWYG layout. Only relevant for scalable glyphs.
- *
- * advance ::
- * This shorthand is, depending on @FT_LOAD_IGNORE_TRANSFORM, the
- * transformed (hinted) advance width for the glyph, in 26.6 fractional
- * pixel format. As specified with @FT_LOAD_VERTICAL_LAYOUT, it uses
- * either the `horiAdvance` or the `vertAdvance` value of `metrics`
- * field.
- *
- * format ::
- * This field indicates the format of the image contained in the glyph
- * slot. Typically @FT_GLYPH_FORMAT_BITMAP, @FT_GLYPH_FORMAT_OUTLINE,
- * or @FT_GLYPH_FORMAT_COMPOSITE, but other values are possible.
- *
- * bitmap ::
- * This field is used as a bitmap descriptor. Note that the address
- * and content of the bitmap buffer can change between calls of
- * @FT_Load_Glyph and a few other functions.
- *
- * bitmap_left ::
- * The bitmap's left bearing expressed in integer pixels.
- *
- * bitmap_top ::
- * The bitmap's top bearing expressed in integer pixels. This is the
- * distance from the baseline to the top-most glyph scanline, upwards
- * y~coordinates being **positive**.
- *
- * outline ::
- * The outline descriptor for the current glyph image if its format is
- * @FT_GLYPH_FORMAT_OUTLINE. Once a glyph is loaded, `outline` can be
- * transformed, distorted, emboldened, etc. However, it must not be
- * freed.
- *
- * [Since 2.10.1] If @FT_LOAD_NO_SCALE is set, outline coordinates of
- * OpenType variation fonts for a selected instance are internally
- * handled as 26.6 fractional font units but returned as (rounded)
- * integers, as expected. To get unrounded font units, don't use
- * @FT_LOAD_NO_SCALE but load the glyph with @FT_LOAD_NO_HINTING and
- * scale it, using the font's `units_per_EM` value as the ppem.
- *
- * num_subglyphs ::
- * The number of subglyphs in a composite glyph. This field is only
- * valid for the composite glyph format that should normally only be
- * loaded with the @FT_LOAD_NO_RECURSE flag.
- *
- * subglyphs ::
- * An array of subglyph descriptors for composite glyphs. There are
- * `num_subglyphs` elements in there. Currently internal to FreeType.
- *
- * control_data ::
- * Certain font drivers can also return the control data for a given
- * glyph image (e.g. TrueType bytecode, Type~1 charstrings, etc.).
- * This field is a pointer to such data; it is currently internal to
- * FreeType.
- *
- * control_len ::
- * This is the length in bytes of the control data. Currently internal
- * to FreeType.
- *
- * other ::
- * Reserved.
- *
- * lsb_delta ::
- * The difference between hinted and unhinted left side bearing while
- * auto-hinting is active. Zero otherwise.
- *
- * rsb_delta ::
- * The difference between hinted and unhinted right side bearing while
- * auto-hinting is active. Zero otherwise.
- *
- * @note:
- * If @FT_Load_Glyph is called with default flags (see @FT_LOAD_DEFAULT)
- * the glyph image is loaded in the glyph slot in its native format
- * (e.g., an outline glyph for TrueType and Type~1 formats). [Since 2.9]
- * The prospective bitmap metrics are calculated according to
- * @FT_LOAD_TARGET_XXX and other flags even for the outline glyph, even
- * if @FT_LOAD_RENDER is not set.
- *
- * This image can later be converted into a bitmap by calling
- * @FT_Render_Glyph. This function searches the current renderer for the
- * native image's format, then invokes it.
- *
- * The renderer is in charge of transforming the native image through the
- * slot's face transformation fields, then converting it into a bitmap
- * that is returned in `slot->bitmap`.
- *
- * Note that `slot->bitmap_left` and `slot->bitmap_top` are also used to
- * specify the position of the bitmap relative to the current pen
- * position (e.g., coordinates (0,0) on the baseline). Of course,
- * `slot->format` is also changed to @FT_GLYPH_FORMAT_BITMAP.
- *
- * Here is a small pseudo code fragment that shows how to use `lsb_delta`
- * and `rsb_delta` to do fractional positioning of glyphs:
- *
- * ```
- * FT_GlyphSlot slot = face->glyph;
- * FT_Pos origin_x = 0;
- *
- *
- * for all glyphs do
- * <load glyph with `FT_Load_Glyph'>
- *
- * FT_Outline_Translate( slot->outline, origin_x & 63, 0 );
- *
- * <save glyph image, or render glyph, or ...>
- *
- * <compute kern between current and next glyph
- * and add it to `origin_x'>
- *
- * origin_x += slot->advance.x;
- * origin_x += slot->lsb_delta - slot->rsb_delta;
- * endfor
- * ```
- *
- * Here is another small pseudo code fragment that shows how to use
- * `lsb_delta` and `rsb_delta` to improve integer positioning of glyphs:
- *
- * ```
- * FT_GlyphSlot slot = face->glyph;
- * FT_Pos origin_x = 0;
- * FT_Pos prev_rsb_delta = 0;
- *
- *
- * for all glyphs do
- * <compute kern between current and previous glyph
- * and add it to `origin_x'>
- *
- * <load glyph with `FT_Load_Glyph'>
- *
- * if ( prev_rsb_delta - slot->lsb_delta > 32 )
- * origin_x -= 64;
- * else if ( prev_rsb_delta - slot->lsb_delta < -31 )
- * origin_x += 64;
- *
- * prev_rsb_delta = slot->rsb_delta;
- *
- * <save glyph image, or render glyph, or ...>
- *
- * origin_x += slot->advance.x;
- * endfor
- * ```
- *
- * If you use strong auto-hinting, you **must** apply these delta values!
- * Otherwise you will experience far too large inter-glyph spacing at
- * small rendering sizes in most cases. Note that it doesn't harm to use
- * the above code for other hinting modes also, since the delta values
- * are zero then.
- */
- typedef struct FT_GlyphSlotRec_
- {
- FT_Library library;
- FT_Face face;
- FT_GlyphSlot next;
- FT_UInt glyph_index; /* new in 2.10; was reserved previously */
- FT_Generic generic;
-
- FT_Glyph_Metrics metrics;
- FT_Fixed linearHoriAdvance;
- FT_Fixed linearVertAdvance;
- FT_Vector advance;
-
- FT_Glyph_Format format;
-
- FT_Bitmap bitmap;
- FT_Int bitmap_left;
- FT_Int bitmap_top;
-
- FT_Outline outline;
-
- FT_UInt num_subglyphs;
- FT_SubGlyph subglyphs;
-
- void* control_data;
- long control_len;
-
- FT_Pos lsb_delta;
- FT_Pos rsb_delta;
-
- void* other;
-
- FT_Slot_Internal internal;
-
- } FT_GlyphSlotRec;
-
-
- /*************************************************************************/
- /*************************************************************************/
- /* */
- /* F U N C T I O N S */
- /* */
- /*************************************************************************/
- /*************************************************************************/
-
-
- /**************************************************************************
- *
- * @section:
- * library_setup
- *
- */
-
- /**************************************************************************
- *
- * @function:
- * FT_Init_FreeType
- *
- * @description:
- * Initialize a new FreeType library object. The set of modules that are
- * registered by this function is determined at build time.
- *
- * @output:
- * alibrary ::
- * A handle to a new library object.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * In case you want to provide your own memory allocating routines, use
- * @FT_New_Library instead, followed by a call to @FT_Add_Default_Modules
- * (or a series of calls to @FT_Add_Module) and
- * @FT_Set_Default_Properties.
- *
- * See the documentation of @FT_Library and @FT_Face for multi-threading
- * issues.
- *
- * If you need reference-counting (cf. @FT_Reference_Library), use
- * @FT_New_Library and @FT_Done_Library.
- *
- * If compilation option `FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES` is
- * set, this function reads the `FREETYPE_PROPERTIES` environment
- * variable to control driver properties. See section @properties for
- * more.
- */
- FT_EXPORT( FT_Error )
- FT_Init_FreeType( FT_Library *alibrary );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Done_FreeType
- *
- * @description:
- * Destroy a given FreeType library object and all of its children,
- * including resources, drivers, faces, sizes, etc.
- *
- * @input:
- * library ::
- * A handle to the target library object.
- *
- * @return:
- * FreeType error code. 0~means success.
- */
- FT_EXPORT( FT_Error )
- FT_Done_FreeType( FT_Library library );
-
-
- /**************************************************************************
- *
- * @section:
- * face_creation
- *
- */
-
- /**************************************************************************
- *
- * @enum:
- * FT_OPEN_XXX
- *
- * @description:
- * A list of bit field constants used within the `flags` field of the
- * @FT_Open_Args structure.
- *
- * @values:
- * FT_OPEN_MEMORY ::
- * This is a memory-based stream.
- *
- * FT_OPEN_STREAM ::
- * Copy the stream from the `stream` field.
- *
- * FT_OPEN_PATHNAME ::
- * Create a new input stream from a C~path name.
- *
- * FT_OPEN_DRIVER ::
- * Use the `driver` field.
- *
- * FT_OPEN_PARAMS ::
- * Use the `num_params` and `params` fields.
- *
- * @note:
- * The `FT_OPEN_MEMORY`, `FT_OPEN_STREAM`, and `FT_OPEN_PATHNAME` flags
- * are mutually exclusive.
- */
-#define FT_OPEN_MEMORY 0x1
-#define FT_OPEN_STREAM 0x2
-#define FT_OPEN_PATHNAME 0x4
-#define FT_OPEN_DRIVER 0x8
-#define FT_OPEN_PARAMS 0x10
-
-
- /* these constants are deprecated; use the corresponding `FT_OPEN_XXX` */
- /* values instead */
-#define ft_open_memory FT_OPEN_MEMORY
-#define ft_open_stream FT_OPEN_STREAM
-#define ft_open_pathname FT_OPEN_PATHNAME
-#define ft_open_driver FT_OPEN_DRIVER
-#define ft_open_params FT_OPEN_PARAMS
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_Parameter
- *
- * @description:
- * A simple structure to pass more or less generic parameters to
- * @FT_Open_Face and @FT_Face_Properties.
- *
- * @fields:
- * tag ::
- * A four-byte identification tag.
- *
- * data ::
- * A pointer to the parameter data.
- *
- * @note:
- * The ID and function of parameters are driver-specific. See section
- * @parameter_tags for more information.
- */
- typedef struct FT_Parameter_
- {
- FT_ULong tag;
- FT_Pointer data;
-
- } FT_Parameter;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_Open_Args
- *
- * @description:
- * A structure to indicate how to open a new font file or stream. A
- * pointer to such a structure can be used as a parameter for the
- * functions @FT_Open_Face and @FT_Attach_Stream.
- *
- * @fields:
- * flags ::
- * A set of bit flags indicating how to use the structure.
- *
- * memory_base ::
- * The first byte of the file in memory.
- *
- * memory_size ::
- * The size in bytes of the file in memory.
- *
- * pathname ::
- * A pointer to an 8-bit file pathname, which must be a C~string (i.e.,
- * no null bytes except at the very end). The pointer is not owned by
- * FreeType.
- *
- * stream ::
- * A handle to a source stream object.
- *
- * driver ::
- * This field is exclusively used by @FT_Open_Face; it simply specifies
- * the font driver to use for opening the face. If set to `NULL`,
- * FreeType tries to load the face with each one of the drivers in its
- * list.
- *
- * num_params ::
- * The number of extra parameters.
- *
- * params ::
- * Extra parameters passed to the font driver when opening a new face.
- *
- * @note:
- * The stream type is determined by the contents of `flags`:
- *
- * If the @FT_OPEN_MEMORY bit is set, assume that this is a memory file
- * of `memory_size` bytes, located at `memory_address`. The data are not
- * copied, and the client is responsible for releasing and destroying
- * them _after_ the corresponding call to @FT_Done_Face.
- *
- * Otherwise, if the @FT_OPEN_STREAM bit is set, assume that a custom
- * input stream `stream` is used.
- *
- * Otherwise, if the @FT_OPEN_PATHNAME bit is set, assume that this is a
- * normal file and use `pathname` to open it.
- *
- * If none of the above bits are set or if multiple are set at the same
- * time, the flags are invalid and @FT_Open_Face fails.
- *
- * If the @FT_OPEN_DRIVER bit is set, @FT_Open_Face only tries to open
- * the file with the driver whose handler is in `driver`.
- *
- * If the @FT_OPEN_PARAMS bit is set, the parameters given by
- * `num_params` and `params` is used. They are ignored otherwise.
- *
- * Ideally, both the `pathname` and `params` fields should be tagged as
- * 'const'; this is missing for API backward compatibility. In other
- * words, applications should treat them as read-only.
- */
- typedef struct FT_Open_Args_
- {
- FT_UInt flags;
- const FT_Byte* memory_base;
- FT_Long memory_size;
- FT_String* pathname;
- FT_Stream stream;
- FT_Module driver;
- FT_Int num_params;
- FT_Parameter* params;
-
- } FT_Open_Args;
-
-
- /**************************************************************************
- *
- * @function:
- * FT_New_Face
- *
- * @description:
- * Call @FT_Open_Face to open a font by its pathname.
- *
- * @inout:
- * library ::
- * A handle to the library resource.
- *
- * @input:
- * pathname ::
- * A path to the font file.
- *
- * face_index ::
- * See @FT_Open_Face for a detailed description of this parameter.
- *
- * @output:
- * aface ::
- * A handle to a new face object. If `face_index` is greater than or
- * equal to zero, it must be non-`NULL`.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * The `pathname` string should be recognizable as such by a standard
- * `fopen` call on your system; in particular, this means that `pathname`
- * must not contain null bytes. If that is not sufficient to address all
- * file name possibilities (for example, to handle wide character file
- * names on Windows in UTF-16 encoding) you might use @FT_Open_Face to
- * pass a memory array or a stream object instead.
- *
- * Use @FT_Done_Face to destroy the created @FT_Face object (along with
- * its slot and sizes).
- */
- FT_EXPORT( FT_Error )
- FT_New_Face( FT_Library library,
- const char* filepathname,
- FT_Long face_index,
- FT_Face *aface );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_New_Memory_Face
- *
- * @description:
- * Call @FT_Open_Face to open a font that has been loaded into memory.
- *
- * @inout:
- * library ::
- * A handle to the library resource.
- *
- * @input:
- * file_base ::
- * A pointer to the beginning of the font data.
- *
- * file_size ::
- * The size of the memory chunk used by the font data.
- *
- * face_index ::
- * See @FT_Open_Face for a detailed description of this parameter.
- *
- * @output:
- * aface ::
- * A handle to a new face object. If `face_index` is greater than or
- * equal to zero, it must be non-`NULL`.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * You must not deallocate the memory before calling @FT_Done_Face.
- */
- FT_EXPORT( FT_Error )
- FT_New_Memory_Face( FT_Library library,
- const FT_Byte* file_base,
- FT_Long file_size,
- FT_Long face_index,
- FT_Face *aface );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Open_Face
- *
- * @description:
- * Create a face object from a given resource described by @FT_Open_Args.
- *
- * @inout:
- * library ::
- * A handle to the library resource.
- *
- * @input:
- * args ::
- * A pointer to an `FT_Open_Args` structure that must be filled by the
- * caller.
- *
- * face_index ::
- * This field holds two different values. Bits 0-15 are the index of
- * the face in the font file (starting with value~0). Set it to~0 if
- * there is only one face in the font file.
- *
- * [Since 2.6.1] Bits 16-30 are relevant to GX and OpenType variation
- * fonts only, specifying the named instance index for the current face
- * index (starting with value~1; value~0 makes FreeType ignore named
- * instances). For non-variation fonts, bits 16-30 are ignored.
- * Assuming that you want to access the third named instance in face~4,
- * `face_index` should be set to 0x00030004. If you want to access
- * face~4 without variation handling, simply set `face_index` to
- * value~4.
- *
- * `FT_Open_Face` and its siblings can be used to quickly check whether
- * the font format of a given font resource is supported by FreeType.
- * In general, if the `face_index` argument is negative, the function's
- * return value is~0 if the font format is recognized, or non-zero
- * otherwise. The function allocates a more or less empty face handle
- * in `*aface` (if `aface` isn't `NULL`); the only two useful fields in
- * this special case are `face->num_faces` and `face->style_flags`.
- * For any negative value of `face_index`, `face->num_faces` gives the
- * number of faces within the font file. For the negative value
- * '-(N+1)' (with 'N' a non-negative 16-bit value), bits 16-30 in
- * `face->style_flags` give the number of named instances in face 'N'
- * if we have a variation font (or zero otherwise). After examination,
- * the returned @FT_Face structure should be deallocated with a call to
- * @FT_Done_Face.
- *
- * @output:
- * aface ::
- * A handle to a new face object. If `face_index` is greater than or
- * equal to zero, it must be non-`NULL`.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * Unlike FreeType 1.x, this function automatically creates a glyph slot
- * for the face object that can be accessed directly through
- * `face->glyph`.
- *
- * Each new face object created with this function also owns a default
- * @FT_Size object, accessible as `face->size`.
- *
- * One @FT_Library instance can have multiple face objects, that is,
- * @FT_Open_Face and its siblings can be called multiple times using the
- * same `library` argument.
- *
- * See the discussion of reference counters in the description of
- * @FT_Reference_Face.
- *
- * If `FT_OPEN_STREAM` is set in `args->flags`, the stream in
- * `args->stream` is automatically closed before this function returns
- * any error (including `FT_Err_Invalid_Argument`).
- *
- * @example:
- * To loop over all faces, use code similar to the following snippet
- * (omitting the error handling).
- *
- * ```
- * ...
- * FT_Face face;
- * FT_Long i, num_faces;
- *
- *
- * error = FT_Open_Face( library, args, -1, &face );
- * if ( error ) { ... }
- *
- * num_faces = face->num_faces;
- * FT_Done_Face( face );
- *
- * for ( i = 0; i < num_faces; i++ )
- * {
- * ...
- * error = FT_Open_Face( library, args, i, &face );
- * ...
- * FT_Done_Face( face );
- * ...
- * }
- * ```
- *
- * To loop over all valid values for `face_index`, use something similar
- * to the following snippet, again without error handling. The code
- * accesses all faces immediately (thus only a single call of
- * `FT_Open_Face` within the do-loop), with and without named instances.
- *
- * ```
- * ...
- * FT_Face face;
- *
- * FT_Long num_faces = 0;
- * FT_Long num_instances = 0;
- *
- * FT_Long face_idx = 0;
- * FT_Long instance_idx = 0;
- *
- *
- * do
- * {
- * FT_Long id = ( instance_idx << 16 ) + face_idx;
- *
- *
- * error = FT_Open_Face( library, args, id, &face );
- * if ( error ) { ... }
- *
- * num_faces = face->num_faces;
- * num_instances = face->style_flags >> 16;
- *
- * ...
- *
- * FT_Done_Face( face );
- *
- * if ( instance_idx < num_instances )
- * instance_idx++;
- * else
- * {
- * face_idx++;
- * instance_idx = 0;
- * }
- *
- * } while ( face_idx < num_faces )
- * ```
- */
- FT_EXPORT( FT_Error )
- FT_Open_Face( FT_Library library,
- const FT_Open_Args* args,
- FT_Long face_index,
- FT_Face *aface );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Attach_File
- *
- * @description:
- * Call @FT_Attach_Stream to attach a file.
- *
- * @inout:
- * face ::
- * The target face object.
- *
- * @input:
- * filepathname ::
- * The pathname.
- *
- * @return:
- * FreeType error code. 0~means success.
- */
- FT_EXPORT( FT_Error )
- FT_Attach_File( FT_Face face,
- const char* filepathname );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Attach_Stream
- *
- * @description:
- * 'Attach' data to a face object. Normally, this is used to read
- * additional information for the face object. For example, you can
- * attach an AFM file that comes with a Type~1 font to get the kerning
- * values and other metrics.
- *
- * @inout:
- * face ::
- * The target face object.
- *
- * @input:
- * parameters ::
- * A pointer to @FT_Open_Args that must be filled by the caller.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * The meaning of the 'attach' (i.e., what really happens when the new
- * file is read) is not fixed by FreeType itself. It really depends on
- * the font format (and thus the font driver).
- *
- * Client applications are expected to know what they are doing when
- * invoking this function. Most drivers simply do not implement file or
- * stream attachments.
- */
- FT_EXPORT( FT_Error )
- FT_Attach_Stream( FT_Face face,
- const FT_Open_Args* parameters );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Reference_Face
- *
- * @description:
- * A counter gets initialized to~1 at the time an @FT_Face structure is
- * created. This function increments the counter. @FT_Done_Face then
- * only destroys a face if the counter is~1, otherwise it simply
- * decrements the counter.
- *
- * This function helps in managing life-cycles of structures that
- * reference @FT_Face objects.
- *
- * @input:
- * face ::
- * A handle to a target face object.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @since:
- * 2.4.2
- *
- */
- FT_EXPORT( FT_Error )
- FT_Reference_Face( FT_Face face );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Done_Face
- *
- * @description:
- * Discard a given face object, as well as all of its child slots and
- * sizes.
- *
- * @input:
- * face ::
- * A handle to a target face object.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * See the discussion of reference counters in the description of
- * @FT_Reference_Face.
- */
- FT_EXPORT( FT_Error )
- FT_Done_Face( FT_Face face );
-
-
- /**************************************************************************
- *
- * @section:
- * sizing_and_scaling
- *
- */
-
- /**************************************************************************
- *
- * @function:
- * FT_Select_Size
- *
- * @description:
- * Select a bitmap strike. To be more precise, this function sets the
- * scaling factors of the active @FT_Size object in a face so that
- * bitmaps from this particular strike are taken by @FT_Load_Glyph and
- * friends.
- *
- * @inout:
- * face ::
- * A handle to a target face object.
- *
- * @input:
- * strike_index ::
- * The index of the bitmap strike in the `available_sizes` field of
- * @FT_FaceRec structure.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * For bitmaps embedded in outline fonts it is common that only a subset
- * of the available glyphs at a given ppem value is available. FreeType
- * silently uses outlines if there is no bitmap for a given glyph index.
- *
- * For GX and OpenType variation fonts, a bitmap strike makes sense only
- * if the default instance is active (that is, no glyph variation takes
- * place); otherwise, FreeType simply ignores bitmap strikes. The same
- * is true for all named instances that are different from the default
- * instance.
- *
- * Don't use this function if you are using the FreeType cache API.
- */
- FT_EXPORT( FT_Error )
- FT_Select_Size( FT_Face face,
- FT_Int strike_index );
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_Size_Request_Type
- *
- * @description:
- * An enumeration type that lists the supported size request types, i.e.,
- * what input size (in font units) maps to the requested output size (in
- * pixels, as computed from the arguments of @FT_Size_Request).
- *
- * @values:
- * FT_SIZE_REQUEST_TYPE_NOMINAL ::
- * The nominal size. The `units_per_EM` field of @FT_FaceRec is used
- * to determine both scaling values.
- *
- * This is the standard scaling found in most applications. In
- * particular, use this size request type for TrueType fonts if they
- * provide optical scaling or something similar. Note, however, that
- * `units_per_EM` is a rather abstract value which bears no relation to
- * the actual size of the glyphs in a font.
- *
- * FT_SIZE_REQUEST_TYPE_REAL_DIM ::
- * The real dimension. The sum of the `ascender` and (minus of) the
- * `descender` fields of @FT_FaceRec is used to determine both scaling
- * values.
- *
- * FT_SIZE_REQUEST_TYPE_BBOX ::
- * The font bounding box. The width and height of the `bbox` field of
- * @FT_FaceRec are used to determine the horizontal and vertical
- * scaling value, respectively.
- *
- * FT_SIZE_REQUEST_TYPE_CELL ::
- * The `max_advance_width` field of @FT_FaceRec is used to determine
- * the horizontal scaling value; the vertical scaling value is
- * determined the same way as @FT_SIZE_REQUEST_TYPE_REAL_DIM does.
- * Finally, both scaling values are set to the smaller one. This type
- * is useful if you want to specify the font size for, say, a window of
- * a given dimension and 80x24 cells.
- *
- * FT_SIZE_REQUEST_TYPE_SCALES ::
- * Specify the scaling values directly.
- *
- * @note:
- * The above descriptions only apply to scalable formats. For bitmap
- * formats, the behaviour is up to the driver.
- *
- * See the note section of @FT_Size_Metrics if you wonder how size
- * requesting relates to scaling values.
- */
- typedef enum FT_Size_Request_Type_
- {
- FT_SIZE_REQUEST_TYPE_NOMINAL,
- FT_SIZE_REQUEST_TYPE_REAL_DIM,
- FT_SIZE_REQUEST_TYPE_BBOX,
- FT_SIZE_REQUEST_TYPE_CELL,
- FT_SIZE_REQUEST_TYPE_SCALES,
-
- FT_SIZE_REQUEST_TYPE_MAX
-
- } FT_Size_Request_Type;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_Size_RequestRec
- *
- * @description:
- * A structure to model a size request.
- *
- * @fields:
- * type ::
- * See @FT_Size_Request_Type.
- *
- * width ::
- * The desired width, given as a 26.6 fractional point value (with 72pt
- * = 1in).
- *
- * height ::
- * The desired height, given as a 26.6 fractional point value (with
- * 72pt = 1in).
- *
- * horiResolution ::
- * The horizontal resolution (dpi, i.e., pixels per inch). If set to
- * zero, `width` is treated as a 26.6 fractional **pixel** value, which
- * gets internally rounded to an integer.
- *
- * vertResolution ::
- * The vertical resolution (dpi, i.e., pixels per inch). If set to
- * zero, `height` is treated as a 26.6 fractional **pixel** value,
- * which gets internally rounded to an integer.
- *
- * @note:
- * If `width` is zero, the horizontal scaling value is set equal to the
- * vertical scaling value, and vice versa.
- *
- * If `type` is `FT_SIZE_REQUEST_TYPE_SCALES`, `width` and `height` are
- * interpreted directly as 16.16 fractional scaling values, without any
- * further modification, and both `horiResolution` and `vertResolution`
- * are ignored.
- */
- typedef struct FT_Size_RequestRec_
- {
- FT_Size_Request_Type type;
- FT_Long width;
- FT_Long height;
- FT_UInt horiResolution;
- FT_UInt vertResolution;
-
- } FT_Size_RequestRec;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_Size_Request
- *
- * @description:
- * A handle to a size request structure.
- */
- typedef struct FT_Size_RequestRec_ *FT_Size_Request;
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Request_Size
- *
- * @description:
- * Resize the scale of the active @FT_Size object in a face.
- *
- * @inout:
- * face ::
- * A handle to a target face object.
- *
- * @input:
- * req ::
- * A pointer to a @FT_Size_RequestRec.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * Although drivers may select the bitmap strike matching the request,
- * you should not rely on this if you intend to select a particular
- * bitmap strike. Use @FT_Select_Size instead in that case.
- *
- * The relation between the requested size and the resulting glyph size
- * is dependent entirely on how the size is defined in the source face.
- * The font designer chooses the final size of each glyph relative to
- * this size. For more information refer to
- * 'https://www.freetype.org/freetype2/docs/glyphs/glyphs-2.html'.
- *
- * Contrary to @FT_Set_Char_Size, this function doesn't have special code
- * to normalize zero-valued widths, heights, or resolutions, which are
- * treated as @FT_LOAD_NO_SCALE.
- *
- * Don't use this function if you are using the FreeType cache API.
- */
- FT_EXPORT( FT_Error )
- FT_Request_Size( FT_Face face,
- FT_Size_Request req );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Set_Char_Size
- *
- * @description:
- * Call @FT_Request_Size to request the nominal size (in points).
- *
- * @inout:
- * face ::
- * A handle to a target face object.
- *
- * @input:
- * char_width ::
- * The nominal width, in 26.6 fractional points.
- *
- * char_height ::
- * The nominal height, in 26.6 fractional points.
- *
- * horz_resolution ::
- * The horizontal resolution in dpi.
- *
- * vert_resolution ::
- * The vertical resolution in dpi.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * While this function allows fractional points as input values, the
- * resulting ppem value for the given resolution is always rounded to the
- * nearest integer.
- *
- * If either the character width or height is zero, it is set equal to
- * the other value.
- *
- * If either the horizontal or vertical resolution is zero, it is set
- * equal to the other value.
- *
- * A character width or height smaller than 1pt is set to 1pt; if both
- * resolution values are zero, they are set to 72dpi.
- *
- * Don't use this function if you are using the FreeType cache API.
- */
- FT_EXPORT( FT_Error )
- FT_Set_Char_Size( FT_Face face,
- FT_F26Dot6 char_width,
- FT_F26Dot6 char_height,
- FT_UInt horz_resolution,
- FT_UInt vert_resolution );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Set_Pixel_Sizes
- *
- * @description:
- * Call @FT_Request_Size to request the nominal size (in pixels).
- *
- * @inout:
- * face ::
- * A handle to the target face object.
- *
- * @input:
- * pixel_width ::
- * The nominal width, in pixels.
- *
- * pixel_height ::
- * The nominal height, in pixels.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * You should not rely on the resulting glyphs matching or being
- * constrained to this pixel size. Refer to @FT_Request_Size to
- * understand how requested sizes relate to actual sizes.
- *
- * Don't use this function if you are using the FreeType cache API.
- */
- FT_EXPORT( FT_Error )
- FT_Set_Pixel_Sizes( FT_Face face,
- FT_UInt pixel_width,
- FT_UInt pixel_height );
-
-
- /**************************************************************************
- *
- * @section:
- * glyph_retrieval
- *
- */
-
- /**************************************************************************
- *
- * @function:
- * FT_Load_Glyph
- *
- * @description:
- * Load a glyph into the glyph slot of a face object.
- *
- * @inout:
- * face ::
- * A handle to the target face object where the glyph is loaded.
- *
- * @input:
- * glyph_index ::
- * The index of the glyph in the font file. For CID-keyed fonts
- * (either in PS or in CFF format) this argument specifies the CID
- * value.
- *
- * load_flags ::
- * A flag indicating what to load for this glyph. The @FT_LOAD_XXX
- * flags can be used to control the glyph loading process (e.g.,
- * whether the outline should be scaled, whether to load bitmaps or
- * not, whether to hint the outline, etc).
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * For proper scaling and hinting, the active @FT_Size object owned by
- * the face has to be meaningfully initialized by calling
- * @FT_Set_Char_Size before this function, for example. The loaded
- * glyph may be transformed. See @FT_Set_Transform for the details.
- *
- * For subsetted CID-keyed fonts, `FT_Err_Invalid_Argument` is returned
- * for invalid CID values (that is, for CID values that don't have a
- * corresponding glyph in the font). See the discussion of the
- * @FT_FACE_FLAG_CID_KEYED flag for more details.
- *
- * If you receive `FT_Err_Glyph_Too_Big`, try getting the glyph outline
- * at EM size, then scale it manually and fill it as a graphics
- * operation.
- */
- FT_EXPORT( FT_Error )
- FT_Load_Glyph( FT_Face face,
- FT_UInt glyph_index,
- FT_Int32 load_flags );
-
-
- /**************************************************************************
- *
- * @section:
- * character_mapping
- *
- */
-
- /**************************************************************************
- *
- * @function:
- * FT_Load_Char
- *
- * @description:
- * Load a glyph into the glyph slot of a face object, accessed by its
- * character code.
- *
- * @inout:
- * face ::
- * A handle to a target face object where the glyph is loaded.
- *
- * @input:
- * char_code ::
- * The glyph's character code, according to the current charmap used in
- * the face.
- *
- * load_flags ::
- * A flag indicating what to load for this glyph. The @FT_LOAD_XXX
- * constants can be used to control the glyph loading process (e.g.,
- * whether the outline should be scaled, whether to load bitmaps or
- * not, whether to hint the outline, etc).
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * This function simply calls @FT_Get_Char_Index and @FT_Load_Glyph.
- *
- * Many fonts contain glyphs that can't be loaded by this function since
- * its glyph indices are not listed in any of the font's charmaps.
- *
- * If no active cmap is set up (i.e., `face->charmap` is zero), the call
- * to @FT_Get_Char_Index is omitted, and the function behaves identically
- * to @FT_Load_Glyph.
- */
- FT_EXPORT( FT_Error )
- FT_Load_Char( FT_Face face,
- FT_ULong char_code,
- FT_Int32 load_flags );
-
-
- /**************************************************************************
- *
- * @section:
- * glyph_retrieval
- *
- */
-
- /**************************************************************************
- *
- * @enum:
- * FT_LOAD_XXX
- *
- * @description:
- * A list of bit field constants for @FT_Load_Glyph to indicate what kind
- * of operations to perform during glyph loading.
- *
- * @values:
- * FT_LOAD_DEFAULT ::
- * Corresponding to~0, this value is used as the default glyph load
- * operation. In this case, the following happens:
- *
- * 1. FreeType looks for a bitmap for the glyph corresponding to the
- * face's current size. If one is found, the function returns. The
- * bitmap data can be accessed from the glyph slot (see note below).
- *
- * 2. If no embedded bitmap is searched for or found, FreeType looks
- * for a scalable outline. If one is found, it is loaded from the font
- * file, scaled to device pixels, then 'hinted' to the pixel grid in
- * order to optimize it. The outline data can be accessed from the
- * glyph slot (see note below).
- *
- * Note that by default the glyph loader doesn't render outlines into
- * bitmaps. The following flags are used to modify this default
- * behaviour to more specific and useful cases.
- *
- * FT_LOAD_NO_SCALE ::
- * Don't scale the loaded outline glyph but keep it in font units.
- * This flag is also assumed if @FT_Size owned by the face was not
- * properly initialized.
- *
- * This flag implies @FT_LOAD_NO_HINTING and @FT_LOAD_NO_BITMAP, and
- * unsets @FT_LOAD_RENDER.
- *
- * If the font is 'tricky' (see @FT_FACE_FLAG_TRICKY for more), using
- * `FT_LOAD_NO_SCALE` usually yields meaningless outlines because the
- * subglyphs must be scaled and positioned with hinting instructions.
- * This can be solved by loading the font without `FT_LOAD_NO_SCALE`
- * and setting the character size to `font->units_per_EM`.
- *
- * FT_LOAD_NO_HINTING ::
- * Disable hinting. This generally generates 'blurrier' bitmap glyphs
- * when the glyphs are rendered in any of the anti-aliased modes. See
- * also the note below.
- *
- * This flag is implied by @FT_LOAD_NO_SCALE.
- *
- * FT_LOAD_RENDER ::
- * Call @FT_Render_Glyph after the glyph is loaded. By default, the
- * glyph is rendered in @FT_RENDER_MODE_NORMAL mode. This can be
- * overridden by @FT_LOAD_TARGET_XXX or @FT_LOAD_MONOCHROME.
- *
- * This flag is unset by @FT_LOAD_NO_SCALE.
- *
- * FT_LOAD_NO_BITMAP ::
- * Ignore bitmap strikes when loading. Bitmap-only fonts ignore this
- * flag.
- *
- * @FT_LOAD_NO_SCALE always sets this flag.
- *
- * FT_LOAD_SBITS_ONLY ::
- * [Since 2.12] This is the opposite of @FT_LOAD_NO_BITMAP, more or
- * less: @FT_Load_Glyph returns `FT_Err_Invalid_Argument` if the face
- * contains a bitmap strike for the given size (or the strike selected
- * by @FT_Select_Size) but there is no glyph in the strike.
- *
- * Note that this load flag was part of FreeType since version 2.0.6
- * but previously tagged as internal.
- *
- * FT_LOAD_VERTICAL_LAYOUT ::
- * Load the glyph for vertical text layout. In particular, the
- * `advance` value in the @FT_GlyphSlotRec structure is set to the
- * `vertAdvance` value of the `metrics` field.
- *
- * In case @FT_HAS_VERTICAL doesn't return true, you shouldn't use this
- * flag currently. Reason is that in this case vertical metrics get
- * synthesized, and those values are not always consistent across
- * various font formats.
- *
- * FT_LOAD_FORCE_AUTOHINT ::
- * Prefer the auto-hinter over the font's native hinter. See also the
- * note below.
- *
- * FT_LOAD_PEDANTIC ::
- * Make the font driver perform pedantic verifications during glyph
- * loading and hinting. This is mostly used to detect broken glyphs in
- * fonts. By default, FreeType tries to handle broken fonts also.
- *
- * In particular, errors from the TrueType bytecode engine are not
- * passed to the application if this flag is not set; this might result
- * in partially hinted or distorted glyphs in case a glyph's bytecode
- * is buggy.
- *
- * FT_LOAD_NO_RECURSE ::
- * Don't load composite glyphs recursively. Instead, the font driver
- * fills the `num_subglyph` and `subglyphs` values of the glyph slot;
- * it also sets `glyph->format` to @FT_GLYPH_FORMAT_COMPOSITE. The
- * description of subglyphs can then be accessed with
- * @FT_Get_SubGlyph_Info.
- *
- * Don't use this flag for retrieving metrics information since some
- * font drivers only return rudimentary data.
- *
- * This flag implies @FT_LOAD_NO_SCALE and @FT_LOAD_IGNORE_TRANSFORM.
- *
- * FT_LOAD_IGNORE_TRANSFORM ::
- * Ignore the transform matrix set by @FT_Set_Transform.
- *
- * FT_LOAD_MONOCHROME ::
- * This flag is used with @FT_LOAD_RENDER to indicate that you want to
- * render an outline glyph to a 1-bit monochrome bitmap glyph, with
- * 8~pixels packed into each byte of the bitmap data.
- *
- * Note that this has no effect on the hinting algorithm used. You
- * should rather use @FT_LOAD_TARGET_MONO so that the
- * monochrome-optimized hinting algorithm is used.
- *
- * FT_LOAD_LINEAR_DESIGN ::
- * Keep `linearHoriAdvance` and `linearVertAdvance` fields of
- * @FT_GlyphSlotRec in font units. See @FT_GlyphSlotRec for details.
- *
- * FT_LOAD_NO_AUTOHINT ::
- * Disable the auto-hinter. See also the note below.
- *
- * FT_LOAD_COLOR ::
- * Load colored glyphs. FreeType searches in the following order;
- * there are slight differences depending on the font format.
- *
- * [Since 2.5] Load embedded color bitmap images (provided
- * @FT_LOAD_NO_BITMAP is not set). The resulting color bitmaps, if
- * available, have the @FT_PIXEL_MODE_BGRA format, with pre-multiplied
- * color channels. If the flag is not set and color bitmaps are found,
- * they are converted to 256-level gray bitmaps, using the
- * @FT_PIXEL_MODE_GRAY format.
- *
- * [Since 2.12] If the glyph index maps to an entry in the face's
- * 'SVG~' table, load the associated SVG document from this table and
- * set the `format` field of @FT_GlyphSlotRec to @FT_GLYPH_FORMAT_SVG
- * ([since 2.13.1] provided @FT_LOAD_NO_SVG is not set). Note that
- * FreeType itself can't render SVG documents; however, the library
- * provides hooks to seamlessly integrate an external renderer. See
- * sections @ot_svg_driver and @svg_fonts for more.
- *
- * [Since 2.10, experimental] If the glyph index maps to an entry in
- * the face's 'COLR' table with a 'CPAL' palette table (as defined in
- * the OpenType specification), make @FT_Render_Glyph provide a default
- * blending of the color glyph layers associated with the glyph index,
- * using the same bitmap format as embedded color bitmap images. This
- * is mainly for convenience and works only for glyphs in 'COLR' v0
- * tables (or glyphs in 'COLR' v1 tables that exclusively use v0
- * features). For full control of color layers use
- * @FT_Get_Color_Glyph_Layer and FreeType's color functions like
- * @FT_Palette_Select instead of setting @FT_LOAD_COLOR for rendering
- * so that the client application can handle blending by itself.
- *
- * FT_LOAD_NO_SVG ::
- * [Since 2.13.1] Ignore SVG glyph data when loading.
- *
- * FT_LOAD_COMPUTE_METRICS ::
- * [Since 2.6.1] Compute glyph metrics from the glyph data, without the
- * use of bundled metrics tables (for example, the 'hdmx' table in
- * TrueType fonts). This flag is mainly used by font validating or
- * font editing applications, which need to ignore, verify, or edit
- * those tables.
- *
- * Currently, this flag is only implemented for TrueType fonts.
- *
- * FT_LOAD_BITMAP_METRICS_ONLY ::
- * [Since 2.7.1] Request loading of the metrics and bitmap image
- * information of a (possibly embedded) bitmap glyph without allocating
- * or copying the bitmap image data itself. No effect if the target
- * glyph is not a bitmap image.
- *
- * This flag unsets @FT_LOAD_RENDER.
- *
- * FT_LOAD_CROP_BITMAP ::
- * Ignored. Deprecated.
- *
- * FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ::
- * Ignored. Deprecated.
- *
- * @note:
- * By default, hinting is enabled and the font's native hinter (see
- * @FT_FACE_FLAG_HINTER) is preferred over the auto-hinter. You can
- * disable hinting by setting @FT_LOAD_NO_HINTING or change the
- * precedence by setting @FT_LOAD_FORCE_AUTOHINT. You can also set
- * @FT_LOAD_NO_AUTOHINT in case you don't want the auto-hinter to be used
- * at all.
- *
- * See the description of @FT_FACE_FLAG_TRICKY for a special exception
- * (affecting only a handful of Asian fonts).
- *
- * Besides deciding which hinter to use, you can also decide which
- * hinting algorithm to use. See @FT_LOAD_TARGET_XXX for details.
- *
- * Note that the auto-hinter needs a valid Unicode cmap (either a native
- * one or synthesized by FreeType) for producing correct results. If a
- * font provides an incorrect mapping (for example, assigning the
- * character code U+005A, LATIN CAPITAL LETTER~Z, to a glyph depicting a
- * mathematical integral sign), the auto-hinter might produce useless
- * results.
- *
- */
-#define FT_LOAD_DEFAULT 0x0
-#define FT_LOAD_NO_SCALE ( 1L << 0 )
-#define FT_LOAD_NO_HINTING ( 1L << 1 )
-#define FT_LOAD_RENDER ( 1L << 2 )
-#define FT_LOAD_NO_BITMAP ( 1L << 3 )
-#define FT_LOAD_VERTICAL_LAYOUT ( 1L << 4 )
-#define FT_LOAD_FORCE_AUTOHINT ( 1L << 5 )
-#define FT_LOAD_CROP_BITMAP ( 1L << 6 )
-#define FT_LOAD_PEDANTIC ( 1L << 7 )
-#define FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ( 1L << 9 )
-#define FT_LOAD_NO_RECURSE ( 1L << 10 )
-#define FT_LOAD_IGNORE_TRANSFORM ( 1L << 11 )
-#define FT_LOAD_MONOCHROME ( 1L << 12 )
-#define FT_LOAD_LINEAR_DESIGN ( 1L << 13 )
-#define FT_LOAD_SBITS_ONLY ( 1L << 14 )
-#define FT_LOAD_NO_AUTOHINT ( 1L << 15 )
- /* Bits 16-19 are used by `FT_LOAD_TARGET_` */
-#define FT_LOAD_COLOR ( 1L << 20 )
-#define FT_LOAD_COMPUTE_METRICS ( 1L << 21 )
-#define FT_LOAD_BITMAP_METRICS_ONLY ( 1L << 22 )
-#define FT_LOAD_NO_SVG ( 1L << 24 )
-
- /* */
-
- /* used internally only by certain font drivers */
-#define FT_LOAD_ADVANCE_ONLY ( 1L << 8 )
-#define FT_LOAD_SVG_ONLY ( 1L << 23 )
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_LOAD_TARGET_XXX
- *
- * @description:
- * A list of values to select a specific hinting algorithm for the
- * hinter. You should OR one of these values to your `load_flags` when
- * calling @FT_Load_Glyph.
- *
- * Note that a font's native hinters may ignore the hinting algorithm you
- * have specified (e.g., the TrueType bytecode interpreter). You can set
- * @FT_LOAD_FORCE_AUTOHINT to ensure that the auto-hinter is used.
- *
- * @values:
- * FT_LOAD_TARGET_NORMAL ::
- * The default hinting algorithm, optimized for standard gray-level
- * rendering. For monochrome output, use @FT_LOAD_TARGET_MONO instead.
- *
- * FT_LOAD_TARGET_LIGHT ::
- * A lighter hinting algorithm for gray-level modes. Many generated
- * glyphs are fuzzier but better resemble their original shape. This
- * is achieved by snapping glyphs to the pixel grid only vertically
- * (Y-axis), as is done by FreeType's new CFF engine or Microsoft's
- * ClearType font renderer. This preserves inter-glyph spacing in
- * horizontal text. The snapping is done either by the native font
- * driver, if the driver itself and the font support it, or by the
- * auto-hinter.
- *
- * Advance widths are rounded to integer values; however, using the
- * `lsb_delta` and `rsb_delta` fields of @FT_GlyphSlotRec, it is
- * possible to get fractional advance widths for subpixel positioning
- * (which is recommended to use).
- *
- * If configuration option `AF_CONFIG_OPTION_TT_SIZE_METRICS` is
- * active, TrueType-like metrics are used to make this mode behave
- * similarly as in unpatched FreeType versions between 2.4.6 and 2.7.1
- * (inclusive).
- *
- * FT_LOAD_TARGET_MONO ::
- * Strong hinting algorithm that should only be used for monochrome
- * output. The result is probably unpleasant if the glyph is rendered
- * in non-monochrome modes.
- *
- * Note that for outline fonts only the TrueType font driver has proper
- * monochrome hinting support, provided the TTFs contain hints for B/W
- * rendering (which most fonts no longer provide). If these conditions
- * are not met it is very likely that you get ugly results at smaller
- * sizes.
- *
- * FT_LOAD_TARGET_LCD ::
- * A variant of @FT_LOAD_TARGET_LIGHT optimized for horizontally
- * decimated LCD displays.
- *
- * FT_LOAD_TARGET_LCD_V ::
- * A variant of @FT_LOAD_TARGET_NORMAL optimized for vertically
- * decimated LCD displays.
- *
- * @note:
- * You should use only _one_ of the `FT_LOAD_TARGET_XXX` values in your
- * `load_flags`. They can't be ORed.
- *
- * If @FT_LOAD_RENDER is also set, the glyph is rendered in the
- * corresponding mode (i.e., the mode that matches the used algorithm
- * best). An exception is `FT_LOAD_TARGET_MONO` since it implies
- * @FT_LOAD_MONOCHROME.
- *
- * You can use a hinting algorithm that doesn't correspond to the same
- * rendering mode. As an example, it is possible to use the 'light'
- * hinting algorithm and have the results rendered in horizontal LCD
- * pixel mode, with code like
- *
- * ```
- * FT_Load_Glyph( face, glyph_index,
- * load_flags | FT_LOAD_TARGET_LIGHT );
- *
- * FT_Render_Glyph( face->glyph, FT_RENDER_MODE_LCD );
- * ```
- *
- * In general, you should stick with one rendering mode. For example,
- * switching between @FT_LOAD_TARGET_NORMAL and @FT_LOAD_TARGET_MONO
- * enforces a lot of recomputation for TrueType fonts, which is slow.
- * Another reason is caching: Selecting a different mode usually causes
- * changes in both the outlines and the rasterized bitmaps; it is thus
- * necessary to empty the cache after a mode switch to avoid false hits.
- *
- */
-#define FT_LOAD_TARGET_( x ) ( FT_STATIC_CAST( FT_Int32, (x) & 15 ) << 16 )
-
-#define FT_LOAD_TARGET_NORMAL FT_LOAD_TARGET_( FT_RENDER_MODE_NORMAL )
-#define FT_LOAD_TARGET_LIGHT FT_LOAD_TARGET_( FT_RENDER_MODE_LIGHT )
-#define FT_LOAD_TARGET_MONO FT_LOAD_TARGET_( FT_RENDER_MODE_MONO )
-#define FT_LOAD_TARGET_LCD FT_LOAD_TARGET_( FT_RENDER_MODE_LCD )
-#define FT_LOAD_TARGET_LCD_V FT_LOAD_TARGET_( FT_RENDER_MODE_LCD_V )
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_LOAD_TARGET_MODE
- *
- * @description:
- * Return the @FT_Render_Mode corresponding to a given
- * @FT_LOAD_TARGET_XXX value.
- *
- */
-#define FT_LOAD_TARGET_MODE( x ) \
- FT_STATIC_CAST( FT_Render_Mode, ( (x) >> 16 ) & 15 )
-
-
- /**************************************************************************
- *
- * @section:
- * sizing_and_scaling
- *
- */
-
- /**************************************************************************
- *
- * @function:
- * FT_Set_Transform
- *
- * @description:
- * Set the transformation that is applied to glyph images when they are
- * loaded into a glyph slot through @FT_Load_Glyph.
- *
- * @inout:
- * face ::
- * A handle to the source face object.
- *
- * @input:
- * matrix ::
- * A pointer to the transformation's 2x2 matrix. Use `NULL` for the
- * identity matrix.
- * delta ::
- * A pointer to the translation vector. Use `NULL` for the null
- * vector.
- *
- * @note:
- * This function is provided as a convenience, but keep in mind that
- * @FT_Matrix coefficients are only 16.16 fixed-point values, which can
- * limit the accuracy of the results. Using floating-point computations
- * to perform the transform directly in client code instead will always
- * yield better numbers.
- *
- * The transformation is only applied to scalable image formats after the
- * glyph has been loaded. It means that hinting is unaltered by the
- * transformation and is performed on the character size given in the
- * last call to @FT_Set_Char_Size or @FT_Set_Pixel_Sizes.
- *
- * Note that this also transforms the `face.glyph.advance` field, but
- * **not** the values in `face.glyph.metrics`.
- */
- FT_EXPORT( void )
- FT_Set_Transform( FT_Face face,
- FT_Matrix* matrix,
- FT_Vector* delta );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_Transform
- *
- * @description:
- * Return the transformation that is applied to glyph images when they
- * are loaded into a glyph slot through @FT_Load_Glyph. See
- * @FT_Set_Transform for more details.
- *
- * @input:
- * face ::
- * A handle to the source face object.
- *
- * @output:
- * matrix ::
- * A pointer to a transformation's 2x2 matrix. Set this to NULL if you
- * are not interested in the value.
- *
- * delta ::
- * A pointer to a translation vector. Set this to NULL if you are not
- * interested in the value.
- *
- * @since:
- * 2.11
- *
- */
- FT_EXPORT( void )
- FT_Get_Transform( FT_Face face,
- FT_Matrix* matrix,
- FT_Vector* delta );
-
-
- /**************************************************************************
- *
- * @section:
- * glyph_retrieval
- *
- */
-
- /**************************************************************************
- *
- * @enum:
- * FT_Render_Mode
- *
- * @description:
- * Render modes supported by FreeType~2. Each mode corresponds to a
- * specific type of scanline conversion performed on the outline.
- *
- * For bitmap fonts and embedded bitmaps the `bitmap->pixel_mode` field
- * in the @FT_GlyphSlotRec structure gives the format of the returned
- * bitmap.
- *
- * All modes except @FT_RENDER_MODE_MONO use 256 levels of opacity,
- * indicating pixel coverage. Use linear alpha blending and gamma
- * correction to correctly render non-monochrome glyph bitmaps onto a
- * surface; see @FT_Render_Glyph.
- *
- * The @FT_RENDER_MODE_SDF is a special render mode that uses up to 256
- * distance values, indicating the signed distance from the grid position
- * to the nearest outline.
- *
- * @values:
- * FT_RENDER_MODE_NORMAL ::
- * Default render mode; it corresponds to 8-bit anti-aliased bitmaps.
- *
- * FT_RENDER_MODE_LIGHT ::
- * This is equivalent to @FT_RENDER_MODE_NORMAL. It is only defined as
- * a separate value because render modes are also used indirectly to
- * define hinting algorithm selectors. See @FT_LOAD_TARGET_XXX for
- * details.
- *
- * FT_RENDER_MODE_MONO ::
- * This mode corresponds to 1-bit bitmaps (with 2~levels of opacity).
- *
- * FT_RENDER_MODE_LCD ::
- * This mode corresponds to horizontal RGB and BGR subpixel displays
- * like LCD screens. It produces 8-bit bitmaps that are 3~times the
- * width of the original glyph outline in pixels, and which use the
- * @FT_PIXEL_MODE_LCD mode.
- *
- * FT_RENDER_MODE_LCD_V ::
- * This mode corresponds to vertical RGB and BGR subpixel displays
- * (like PDA screens, rotated LCD displays, etc.). It produces 8-bit
- * bitmaps that are 3~times the height of the original glyph outline in
- * pixels and use the @FT_PIXEL_MODE_LCD_V mode.
- *
- * FT_RENDER_MODE_SDF ::
- * The positive (unsigned) 8-bit bitmap values can be converted to the
- * single-channel signed distance field (SDF) by subtracting 128, with
- * the positive and negative results corresponding to the inside and
- * the outside of a glyph contour, respectively. The distance units are
- * arbitrarily determined by an adjustable @spread property.
- *
- * @note:
- * The selected render mode only affects scalable vector glyphs of a font.
- * Embedded bitmaps often have a different pixel mode like
- * @FT_PIXEL_MODE_MONO. You can use @FT_Bitmap_Convert to transform them
- * into 8-bit pixmaps.
- *
- */
- typedef enum FT_Render_Mode_
- {
- FT_RENDER_MODE_NORMAL = 0,
- FT_RENDER_MODE_LIGHT,
- FT_RENDER_MODE_MONO,
- FT_RENDER_MODE_LCD,
- FT_RENDER_MODE_LCD_V,
- FT_RENDER_MODE_SDF,
-
- FT_RENDER_MODE_MAX
-
- } FT_Render_Mode;
-
-
- /* these constants are deprecated; use the corresponding */
- /* `FT_Render_Mode` values instead */
-#define ft_render_mode_normal FT_RENDER_MODE_NORMAL
-#define ft_render_mode_mono FT_RENDER_MODE_MONO
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Render_Glyph
- *
- * @description:
- * Convert a given glyph image to a bitmap. It does so by inspecting the
- * glyph image format, finding the relevant renderer, and invoking it.
- *
- * @inout:
- * slot ::
- * A handle to the glyph slot containing the image to convert.
- *
- * @input:
- * render_mode ::
- * The render mode used to render the glyph image into a bitmap. See
- * @FT_Render_Mode for a list of possible values.
- *
- * If @FT_RENDER_MODE_NORMAL is used, a previous call of @FT_Load_Glyph
- * with flag @FT_LOAD_COLOR makes `FT_Render_Glyph` provide a default
- * blending of colored glyph layers associated with the current glyph
- * slot (provided the font contains such layers) instead of rendering
- * the glyph slot's outline. This is an experimental feature; see
- * @FT_LOAD_COLOR for more information.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * When FreeType outputs a bitmap of a glyph, it really outputs an alpha
- * coverage map. If a pixel is completely covered by a filled-in
- * outline, the bitmap contains 0xFF at that pixel, meaning that
- * 0xFF/0xFF fraction of that pixel is covered, meaning the pixel is 100%
- * black (or 0% bright). If a pixel is only 50% covered (value 0x80),
- * the pixel is made 50% black (50% bright or a middle shade of grey).
- * 0% covered means 0% black (100% bright or white).
- *
- * On high-DPI screens like on smartphones and tablets, the pixels are so
- * small that their chance of being completely covered and therefore
- * completely black are fairly good. On the low-DPI screens, however,
- * the situation is different. The pixels are too large for most of the
- * details of a glyph and shades of gray are the norm rather than the
- * exception.
- *
- * This is relevant because all our screens have a second problem: they
- * are not linear. 1~+~1 is not~2. Twice the value does not result in
- * twice the brightness. When a pixel is only 50% covered, the coverage
- * map says 50% black, and this translates to a pixel value of 128 when
- * you use 8~bits per channel (0-255). However, this does not translate
- * to 50% brightness for that pixel on our sRGB and gamma~2.2 screens.
- * Due to their non-linearity, they dwell longer in the darks and only a
- * pixel value of about 186 results in 50% brightness -- 128 ends up too
- * dark on both bright and dark backgrounds. The net result is that dark
- * text looks burnt-out, pixely and blotchy on bright background, bright
- * text too frail on dark backgrounds, and colored text on colored
- * background (for example, red on green) seems to have dark halos or
- * 'dirt' around it. The situation is especially ugly for diagonal stems
- * like in 'w' glyph shapes where the quality of FreeType's anti-aliasing
- * depends on the correct display of grays. On high-DPI screens where
- * smaller, fully black pixels reign supreme, this doesn't matter, but on
- * our low-DPI screens with all the gray shades, it does. 0% and 100%
- * brightness are the same things in linear and non-linear space, just
- * all the shades in-between aren't.
- *
- * The blending function for placing text over a background is
- *
- * ```
- * dst = alpha * src + (1 - alpha) * dst ,
- * ```
- *
- * which is known as the OVER operator.
- *
- * To correctly composite an anti-aliased pixel of a glyph onto a
- * surface,
- *
- * 1. take the foreground and background colors (e.g., in sRGB space)
- * and apply gamma to get them in a linear space,
- *
- * 2. use OVER to blend the two linear colors using the glyph pixel
- * as the alpha value (remember, the glyph bitmap is an alpha coverage
- * bitmap), and
- *
- * 3. apply inverse gamma to the blended pixel and write it back to
- * the image.
- *
- * Internal testing at Adobe found that a target inverse gamma of~1.8 for
- * step~3 gives good results across a wide range of displays with an sRGB
- * gamma curve or a similar one.
- *
- * This process can cost performance. There is an approximation that
- * does not need to know about the background color; see
- * https://bel.fi/alankila/lcd/ and
- * https://bel.fi/alankila/lcd/alpcor.html for details.
- *
- * **ATTENTION**: Linear blending is even more important when dealing
- * with subpixel-rendered glyphs to prevent color-fringing! A
- * subpixel-rendered glyph must first be filtered with a filter that
- * gives equal weight to the three color primaries and does not exceed a
- * sum of 0x100, see section @lcd_rendering. Then the only difference to
- * gray linear blending is that subpixel-rendered linear blending is done
- * 3~times per pixel: red foreground subpixel to red background subpixel
- * and so on for green and blue.
- */
- FT_EXPORT( FT_Error )
- FT_Render_Glyph( FT_GlyphSlot slot,
- FT_Render_Mode render_mode );
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_Kerning_Mode
- *
- * @description:
- * An enumeration to specify the format of kerning values returned by
- * @FT_Get_Kerning.
- *
- * @values:
- * FT_KERNING_DEFAULT ::
- * Return grid-fitted kerning distances in 26.6 fractional pixels.
- *
- * FT_KERNING_UNFITTED ::
- * Return un-grid-fitted kerning distances in 26.6 fractional pixels.
- *
- * FT_KERNING_UNSCALED ::
- * Return the kerning vector in original font units.
- *
- * @note:
- * `FT_KERNING_DEFAULT` returns full pixel values; it also makes FreeType
- * heuristically scale down kerning distances at small ppem values so
- * that they don't become too big.
- *
- * Both `FT_KERNING_DEFAULT` and `FT_KERNING_UNFITTED` use the current
- * horizontal scaling factor (as set e.g. with @FT_Set_Char_Size) to
- * convert font units to pixels.
- */
- typedef enum FT_Kerning_Mode_
- {
- FT_KERNING_DEFAULT = 0,
- FT_KERNING_UNFITTED,
- FT_KERNING_UNSCALED
-
- } FT_Kerning_Mode;
-
-
- /* these constants are deprecated; use the corresponding */
- /* `FT_Kerning_Mode` values instead */
-#define ft_kerning_default FT_KERNING_DEFAULT
-#define ft_kerning_unfitted FT_KERNING_UNFITTED
-#define ft_kerning_unscaled FT_KERNING_UNSCALED
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_Kerning
- *
- * @description:
- * Return the kerning vector between two glyphs of the same face.
- *
- * @input:
- * face ::
- * A handle to a source face object.
- *
- * left_glyph ::
- * The index of the left glyph in the kern pair.
- *
- * right_glyph ::
- * The index of the right glyph in the kern pair.
- *
- * kern_mode ::
- * See @FT_Kerning_Mode for more information. Determines the scale and
- * dimension of the returned kerning vector.
- *
- * @output:
- * akerning ::
- * The kerning vector. This is either in font units, fractional pixels
- * (26.6 format), or pixels for scalable formats, and in pixels for
- * fixed-sizes formats.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * Only horizontal layouts (left-to-right & right-to-left) are supported
- * by this method. Other layouts, or more sophisticated kernings, are
- * out of the scope of this API function -- they can be implemented
- * through format-specific interfaces.
- *
- * Note that, for TrueType fonts only, this can extract data from both
- * the 'kern' table and the basic, pair-wise kerning feature from the
- * GPOS table (with `TT_CONFIG_OPTION_GPOS_KERNING` enabled), though
- * FreeType does not support the more advanced GPOS layout features; use
- * a library like HarfBuzz for those instead. If a font has both a
- * 'kern' table and kern features of a GPOS table, the 'kern' table will
- * be used.
- *
- * Also note for right-to-left scripts, the functionality may differ for
- * fonts with GPOS tables vs. 'kern' tables. For GPOS, right-to-left
- * fonts typically use both a placement offset and an advance for pair
- * positioning, which this API does not support, so it would output
- * kerning values of zero; though if the right-to-left font used only
- * advances in GPOS pair positioning, then this API could output kerning
- * values for it, but it would use `left_glyph` to mean the first glyph
- * for that case. Whereas 'kern' tables are always advance-only and
- * always store the left glyph first.
- *
- * Use @FT_HAS_KERNING to find out whether a font has data that can be
- * extracted with `FT_Get_Kerning`.
- */
- FT_EXPORT( FT_Error )
- FT_Get_Kerning( FT_Face face,
- FT_UInt left_glyph,
- FT_UInt right_glyph,
- FT_UInt kern_mode,
- FT_Vector *akerning );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_Track_Kerning
- *
- * @description:
- * Return the track kerning for a given face object at a given size.
- *
- * @input:
- * face ::
- * A handle to a source face object.
- *
- * point_size ::
- * The point size in 16.16 fractional points.
- *
- * degree ::
- * The degree of tightness. Increasingly negative values represent
- * tighter track kerning, while increasingly positive values represent
- * looser track kerning. Value zero means no track kerning.
- *
- * @output:
- * akerning ::
- * The kerning in 16.16 fractional points, to be uniformly applied
- * between all glyphs.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * Currently, only the Type~1 font driver supports track kerning, using
- * data from AFM files (if attached with @FT_Attach_File or
- * @FT_Attach_Stream).
- *
- * Only very few AFM files come with track kerning data; please refer to
- * Adobe's AFM specification for more details.
- */
- FT_EXPORT( FT_Error )
- FT_Get_Track_Kerning( FT_Face face,
- FT_Fixed point_size,
- FT_Int degree,
- FT_Fixed* akerning );
-
-
- /**************************************************************************
- *
- * @section:
- * character_mapping
- *
- */
-
- /**************************************************************************
- *
- * @function:
- * FT_Select_Charmap
- *
- * @description:
- * Select a given charmap by its encoding tag (as listed in
- * `freetype.h`).
- *
- * @inout:
- * face ::
- * A handle to the source face object.
- *
- * @input:
- * encoding ::
- * A handle to the selected encoding.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * This function returns an error if no charmap in the face corresponds
- * to the encoding queried here.
- *
- * Because many fonts contain more than a single cmap for Unicode
- * encoding, this function has some special code to select the one that
- * covers Unicode best ('best' in the sense that a UCS-4 cmap is
- * preferred to a UCS-2 cmap). It is thus preferable to @FT_Set_Charmap
- * in this case.
- */
- FT_EXPORT( FT_Error )
- FT_Select_Charmap( FT_Face face,
- FT_Encoding encoding );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Set_Charmap
- *
- * @description:
- * Select a given charmap for character code to glyph index mapping.
- *
- * @inout:
- * face ::
- * A handle to the source face object.
- *
- * @input:
- * charmap ::
- * A handle to the selected charmap.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * This function returns an error if the charmap is not part of the face
- * (i.e., if it is not listed in the `face->charmaps` table).
- *
- * It also fails if an OpenType type~14 charmap is selected (which
- * doesn't map character codes to glyph indices at all).
- */
- FT_EXPORT( FT_Error )
- FT_Set_Charmap( FT_Face face,
- FT_CharMap charmap );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_Charmap_Index
- *
- * @description:
- * Retrieve index of a given charmap.
- *
- * @input:
- * charmap ::
- * A handle to a charmap.
- *
- * @return:
- * The index into the array of character maps within the face to which
- * `charmap` belongs. If an error occurs, -1 is returned.
- *
- */
- FT_EXPORT( FT_Int )
- FT_Get_Charmap_Index( FT_CharMap charmap );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_Char_Index
- *
- * @description:
- * Return the glyph index of a given character code. This function uses
- * the currently selected charmap to do the mapping.
- *
- * @input:
- * face ::
- * A handle to the source face object.
- *
- * charcode ::
- * The character code.
- *
- * @return:
- * The glyph index. 0~means 'undefined character code'.
- *
- * @note:
- * If you use FreeType to manipulate the contents of font files directly,
- * be aware that the glyph index returned by this function doesn't always
- * correspond to the internal indices used within the file. This is done
- * to ensure that value~0 always corresponds to the 'missing glyph'. If
- * the first glyph is not named '.notdef', then for Type~1 and Type~42
- * fonts, '.notdef' will be moved into the glyph ID~0 position, and
- * whatever was there will be moved to the position '.notdef' had. For
- * Type~1 fonts, if there is no '.notdef' glyph at all, then one will be
- * created at index~0 and whatever was there will be moved to the last
- * index -- Type~42 fonts are considered invalid under this condition.
- */
- FT_EXPORT( FT_UInt )
- FT_Get_Char_Index( FT_Face face,
- FT_ULong charcode );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_First_Char
- *
- * @description:
- * Return the first character code in the current charmap of a given
- * face, together with its corresponding glyph index.
- *
- * @input:
- * face ::
- * A handle to the source face object.
- *
- * @output:
- * agindex ::
- * Glyph index of first character code. 0~if charmap is empty.
- *
- * @return:
- * The charmap's first character code.
- *
- * @note:
- * You should use this function together with @FT_Get_Next_Char to parse
- * all character codes available in a given charmap. The code should
- * look like this:
- *
- * ```
- * FT_ULong charcode;
- * FT_UInt gindex;
- *
- *
- * charcode = FT_Get_First_Char( face, &gindex );
- * while ( gindex != 0 )
- * {
- * ... do something with (charcode,gindex) pair ...
- *
- * charcode = FT_Get_Next_Char( face, charcode, &gindex );
- * }
- * ```
- *
- * Be aware that character codes can have values up to 0xFFFFFFFF; this
- * might happen for non-Unicode or malformed cmaps. However, even with
- * regular Unicode encoding, so-called 'last resort fonts' (using SFNT
- * cmap format 13, see function @FT_Get_CMap_Format) normally have
- * entries for all Unicode characters up to 0x1FFFFF, which can cause *a
- * lot* of iterations.
- *
- * Note that `*agindex` is set to~0 if the charmap is empty. The result
- * itself can be~0 in two cases: if the charmap is empty or if the
- * value~0 is the first valid character code.
- */
- FT_EXPORT( FT_ULong )
- FT_Get_First_Char( FT_Face face,
- FT_UInt *agindex );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_Next_Char
- *
- * @description:
- * Return the next character code in the current charmap of a given face
- * following the value `char_code`, as well as the corresponding glyph
- * index.
- *
- * @input:
- * face ::
- * A handle to the source face object.
- *
- * char_code ::
- * The starting character code.
- *
- * @output:
- * agindex ::
- * Glyph index of next character code. 0~if charmap is empty.
- *
- * @return:
- * The charmap's next character code.
- *
- * @note:
- * You should use this function with @FT_Get_First_Char to walk over all
- * character codes available in a given charmap. See the note for that
- * function for a simple code example.
- *
- * Note that `*agindex` is set to~0 when there are no more codes in the
- * charmap.
- */
- FT_EXPORT( FT_ULong )
- FT_Get_Next_Char( FT_Face face,
- FT_ULong char_code,
- FT_UInt *agindex );
-
-
- /**************************************************************************
- *
- * @section:
- * face_creation
- *
- */
-
- /**************************************************************************
- *
- * @function:
- * FT_Face_Properties
- *
- * @description:
- * Set or override certain (library or module-wide) properties on a
- * face-by-face basis. Useful for finer-grained control and avoiding
- * locks on shared structures (threads can modify their own faces as they
- * see fit).
- *
- * Contrary to @FT_Property_Set, this function uses @FT_Parameter so that
- * you can pass multiple properties to the target face in one call. Note
- * that only a subset of the available properties can be controlled.
- *
- * * @FT_PARAM_TAG_STEM_DARKENING (stem darkening, corresponding to the
- * property `no-stem-darkening` provided by the 'autofit', 'cff',
- * 'type1', and 't1cid' modules; see @no-stem-darkening).
- *
- * * @FT_PARAM_TAG_LCD_FILTER_WEIGHTS (LCD filter weights, corresponding
- * to function @FT_Library_SetLcdFilterWeights).
- *
- * * @FT_PARAM_TAG_RANDOM_SEED (seed value for the CFF, Type~1, and CID
- * 'random' operator, corresponding to the `random-seed` property
- * provided by the 'cff', 'type1', and 't1cid' modules; see
- * @random-seed).
- *
- * Pass `NULL` as `data` in @FT_Parameter for a given tag to reset the
- * option and use the library or module default again.
- *
- * @input:
- * face ::
- * A handle to the source face object.
- *
- * num_properties ::
- * The number of properties that follow.
- *
- * properties ::
- * A handle to an @FT_Parameter array with `num_properties` elements.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @example:
- * Here is an example that sets three properties. You must define
- * `FT_CONFIG_OPTION_SUBPIXEL_RENDERING` to make the LCD filter examples
- * work.
- *
- * ```
- * FT_Parameter property1;
- * FT_Bool darken_stems = 1;
- *
- * FT_Parameter property2;
- * FT_LcdFiveTapFilter custom_weight =
- * { 0x11, 0x44, 0x56, 0x44, 0x11 };
- *
- * FT_Parameter property3;
- * FT_Int32 random_seed = 314159265;
- *
- * FT_Parameter properties[3] = { property1,
- * property2,
- * property3 };
- *
- *
- * property1.tag = FT_PARAM_TAG_STEM_DARKENING;
- * property1.data = &darken_stems;
- *
- * property2.tag = FT_PARAM_TAG_LCD_FILTER_WEIGHTS;
- * property2.data = custom_weight;
- *
- * property3.tag = FT_PARAM_TAG_RANDOM_SEED;
- * property3.data = &random_seed;
- *
- * FT_Face_Properties( face, 3, properties );
- * ```
- *
- * The next example resets a single property to its default value.
- *
- * ```
- * FT_Parameter property;
- *
- *
- * property.tag = FT_PARAM_TAG_LCD_FILTER_WEIGHTS;
- * property.data = NULL;
- *
- * FT_Face_Properties( face, 1, &property );
- * ```
- *
- * @since:
- * 2.8
- *
- */
- FT_EXPORT( FT_Error )
- FT_Face_Properties( FT_Face face,
- FT_UInt num_properties,
- FT_Parameter* properties );
-
-
- /**************************************************************************
- *
- * @section:
- * information_retrieval
- *
- */
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_Name_Index
- *
- * @description:
- * Return the glyph index of a given glyph name. This only works
- * for those faces where @FT_HAS_GLYPH_NAMES returns true.
- *
- * @input:
- * face ::
- * A handle to the source face object.
- *
- * glyph_name ::
- * The glyph name.
- *
- * @return:
- * The glyph index. 0~means 'undefined character code'.
- *
- * @note:
- * Acceptable glyph names might come from the [Adobe Glyph
- * List](https://github.com/adobe-type-tools/agl-aglfn). See
- * @FT_Get_Glyph_Name for the inverse functionality.
- *
- * This function has limited capabilities if the config macro
- * `FT_CONFIG_OPTION_POSTSCRIPT_NAMES` is not defined in `ftoption.h`:
- * It then works only for fonts that actually embed glyph names (which
- * many recent OpenType fonts do not).
- */
- FT_EXPORT( FT_UInt )
- FT_Get_Name_Index( FT_Face face,
- const FT_String* glyph_name );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_Glyph_Name
- *
- * @description:
- * Retrieve the ASCII name of a given glyph in a face. This only works
- * for those faces where @FT_HAS_GLYPH_NAMES returns true.
- *
- * @input:
- * face ::
- * A handle to a source face object.
- *
- * glyph_index ::
- * The glyph index.
- *
- * buffer_max ::
- * The maximum number of bytes available in the buffer.
- *
- * @output:
- * buffer ::
- * A pointer to a target buffer where the name is copied to.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * An error is returned if the face doesn't provide glyph names or if the
- * glyph index is invalid. In all cases of failure, the first byte of
- * `buffer` is set to~0 to indicate an empty name.
- *
- * The glyph name is truncated to fit within the buffer if it is too
- * long. The returned string is always zero-terminated.
- *
- * Be aware that FreeType reorders glyph indices internally so that glyph
- * index~0 always corresponds to the 'missing glyph' (called '.notdef').
- *
- * This function has limited capabilities if the config macro
- * `FT_CONFIG_OPTION_POSTSCRIPT_NAMES` is not defined in `ftoption.h`:
- * It then works only for fonts that actually embed glyph names (which
- * many recent OpenType fonts do not).
- */
- FT_EXPORT( FT_Error )
- FT_Get_Glyph_Name( FT_Face face,
- FT_UInt glyph_index,
- FT_Pointer buffer,
- FT_UInt buffer_max );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_Postscript_Name
- *
- * @description:
- * Retrieve the ASCII PostScript name of a given face, if available.
- * This only works with PostScript, TrueType, and OpenType fonts.
- *
- * @input:
- * face ::
- * A handle to the source face object.
- *
- * @return:
- * A pointer to the face's PostScript name. `NULL` if unavailable.
- *
- * @note:
- * The returned pointer is owned by the face and is destroyed with it.
- *
- * For variation fonts, this string changes if you select a different
- * instance, and you have to call `FT_Get_PostScript_Name` again to
- * retrieve it. FreeType follows Adobe TechNote #5902, 'Generating
- * PostScript Names for Fonts Using OpenType Font Variations'.
- *
- * https://download.macromedia.com/pub/developer/opentype/tech-notes/5902.AdobePSNameGeneration.html
- *
- * [Since 2.9] Special PostScript names for named instances are only
- * returned if the named instance is set with @FT_Set_Named_Instance (and
- * the font has corresponding entries in its 'fvar' table or is the
- * default named instance). If @FT_IS_VARIATION returns true, the
- * algorithmically derived PostScript name is provided, not looking up
- * special entries for named instances.
- */
- FT_EXPORT( const char* )
- FT_Get_Postscript_Name( FT_Face face );
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_SUBGLYPH_FLAG_XXX
- *
- * @description:
- * A list of constants describing subglyphs. Please refer to the 'glyf'
- * table description in the OpenType specification for the meaning of the
- * various flags (which get synthesized for non-OpenType subglyphs).
- *
- * https://docs.microsoft.com/en-us/typography/opentype/spec/glyf#composite-glyph-description
- *
- * @values:
- * FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS ::
- * FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES ::
- * FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID ::
- * FT_SUBGLYPH_FLAG_SCALE ::
- * FT_SUBGLYPH_FLAG_XY_SCALE ::
- * FT_SUBGLYPH_FLAG_2X2 ::
- * FT_SUBGLYPH_FLAG_USE_MY_METRICS ::
- *
- */
-#define FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS 1
-#define FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES 2
-#define FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID 4
-#define FT_SUBGLYPH_FLAG_SCALE 8
-#define FT_SUBGLYPH_FLAG_XY_SCALE 0x40
-#define FT_SUBGLYPH_FLAG_2X2 0x80
-#define FT_SUBGLYPH_FLAG_USE_MY_METRICS 0x200
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_SubGlyph_Info
- *
- * @description:
- * Retrieve a description of a given subglyph. Only use it if
- * `glyph->format` is @FT_GLYPH_FORMAT_COMPOSITE; an error is returned
- * otherwise.
- *
- * @input:
- * glyph ::
- * The source glyph slot.
- *
- * sub_index ::
- * The index of the subglyph. Must be less than
- * `glyph->num_subglyphs`.
- *
- * @output:
- * p_index ::
- * The glyph index of the subglyph.
- *
- * p_flags ::
- * The subglyph flags, see @FT_SUBGLYPH_FLAG_XXX.
- *
- * p_arg1 ::
- * The subglyph's first argument (if any).
- *
- * p_arg2 ::
- * The subglyph's second argument (if any).
- *
- * p_transform ::
- * The subglyph transformation (if any).
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * The values of `*p_arg1`, `*p_arg2`, and `*p_transform` must be
- * interpreted depending on the flags returned in `*p_flags`. See the
- * OpenType specification for details.
- *
- * https://docs.microsoft.com/en-us/typography/opentype/spec/glyf#composite-glyph-description
- *
- */
- FT_EXPORT( FT_Error )
- FT_Get_SubGlyph_Info( FT_GlyphSlot glyph,
- FT_UInt sub_index,
- FT_Int *p_index,
- FT_UInt *p_flags,
- FT_Int *p_arg1,
- FT_Int *p_arg2,
- FT_Matrix *p_transform );
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_FSTYPE_XXX
- *
- * @description:
- * A list of bit flags used in the `fsType` field of the OS/2 table in a
- * TrueType or OpenType font and the `FSType` entry in a PostScript font.
- * These bit flags are returned by @FT_Get_FSType_Flags; they inform
- * client applications of embedding and subsetting restrictions
- * associated with a font.
- *
- * See
- * https://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/FontPolicies.pdf
- * for more details.
- *
- * @values:
- * FT_FSTYPE_INSTALLABLE_EMBEDDING ::
- * Fonts with no fsType bit set may be embedded and permanently
- * installed on the remote system by an application.
- *
- * FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING ::
- * Fonts that have only this bit set must not be modified, embedded or
- * exchanged in any manner without first obtaining permission of the
- * font software copyright owner.
- *
- * FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING ::
- * The font may be embedded and temporarily loaded on the remote
- * system. Documents containing Preview & Print fonts must be opened
- * 'read-only'; no edits can be applied to the document.
- *
- * FT_FSTYPE_EDITABLE_EMBEDDING ::
- * The font may be embedded but must only be installed temporarily on
- * other systems. In contrast to Preview & Print fonts, documents
- * containing editable fonts may be opened for reading, editing is
- * permitted, and changes may be saved.
- *
- * FT_FSTYPE_NO_SUBSETTING ::
- * The font may not be subsetted prior to embedding.
- *
- * FT_FSTYPE_BITMAP_EMBEDDING_ONLY ::
- * Only bitmaps contained in the font may be embedded; no outline data
- * may be embedded. If there are no bitmaps available in the font,
- * then the font is unembeddable.
- *
- * @note:
- * The flags are ORed together, thus more than a single value can be
- * returned.
- *
- * While the `fsType` flags can indicate that a font may be embedded, a
- * license with the font vendor may be separately required to use the
- * font in this way.
- */
-#define FT_FSTYPE_INSTALLABLE_EMBEDDING 0x0000
-#define FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING 0x0002
-#define FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING 0x0004
-#define FT_FSTYPE_EDITABLE_EMBEDDING 0x0008
-#define FT_FSTYPE_NO_SUBSETTING 0x0100
-#define FT_FSTYPE_BITMAP_EMBEDDING_ONLY 0x0200
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_FSType_Flags
- *
- * @description:
- * Return the `fsType` flags for a font.
- *
- * @input:
- * face ::
- * A handle to the source face object.
- *
- * @return:
- * The `fsType` flags, see @FT_FSTYPE_XXX.
- *
- * @note:
- * Use this function rather than directly reading the `fs_type` field in
- * the @PS_FontInfoRec structure, which is only guaranteed to return the
- * correct results for Type~1 fonts.
- *
- * @since:
- * 2.3.8
- *
- */
- FT_EXPORT( FT_UShort )
- FT_Get_FSType_Flags( FT_Face face );
-
-
- /**************************************************************************
- *
- * @section:
- * glyph_variants
- *
- * @title:
- * Unicode Variation Sequences
- *
- * @abstract:
- * The FreeType~2 interface to Unicode Variation Sequences (UVS), using
- * the SFNT cmap format~14.
- *
- * @description:
- * Many characters, especially for CJK scripts, have variant forms. They
- * are a sort of grey area somewhere between being totally irrelevant and
- * semantically distinct; for this reason, the Unicode consortium decided
- * to introduce Variation Sequences (VS), consisting of a Unicode base
- * character and a variation selector instead of further extending the
- * already huge number of characters.
- *
- * Unicode maintains two different sets, namely 'Standardized Variation
- * Sequences' and registered 'Ideographic Variation Sequences' (IVS),
- * collected in the 'Ideographic Variation Database' (IVD).
- *
- * https://unicode.org/Public/UCD/latest/ucd/StandardizedVariants.txt
- * https://unicode.org/reports/tr37/ https://unicode.org/ivd/
- *
- * To date (January 2017), the character with the most ideographic
- * variations is U+9089, having 32 such IVS.
- *
- * Three Mongolian Variation Selectors have the values U+180B-U+180D; 256
- * generic Variation Selectors are encoded in the ranges U+FE00-U+FE0F
- * and U+E0100-U+E01EF. IVS currently use Variation Selectors from the
- * range U+E0100-U+E01EF only.
- *
- * A VS consists of the base character value followed by a single
- * Variation Selector. For example, to get the first variation of
- * U+9089, you have to write the character sequence `U+9089 U+E0100`.
- *
- * Adobe and MS decided to support both standardized and ideographic VS
- * with a new cmap subtable (format~14). It is an odd subtable because
- * it is not a mapping of input code points to glyphs, but contains lists
- * of all variations supported by the font.
- *
- * A variation may be either 'default' or 'non-default' for a given font.
- * A default variation is the one you will get for that code point if you
- * look it up in the standard Unicode cmap. A non-default variation is a
- * different glyph.
- *
- */
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Face_GetCharVariantIndex
- *
- * @description:
- * Return the glyph index of a given character code as modified by the
- * variation selector.
- *
- * @input:
- * face ::
- * A handle to the source face object.
- *
- * charcode ::
- * The character code point in Unicode.
- *
- * variantSelector ::
- * The Unicode code point of the variation selector.
- *
- * @return:
- * The glyph index. 0~means either 'undefined character code', or
- * 'undefined selector code', or 'no variation selector cmap subtable',
- * or 'current CharMap is not Unicode'.
- *
- * @note:
- * If you use FreeType to manipulate the contents of font files directly,
- * be aware that the glyph index returned by this function doesn't always
- * correspond to the internal indices used within the file. This is done
- * to ensure that value~0 always corresponds to the 'missing glyph'.
- *
- * This function is only meaningful if
- * a) the font has a variation selector cmap sub table, and
- * b) the current charmap has a Unicode encoding.
- *
- * @since:
- * 2.3.6
- *
- */
- FT_EXPORT( FT_UInt )
- FT_Face_GetCharVariantIndex( FT_Face face,
- FT_ULong charcode,
- FT_ULong variantSelector );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Face_GetCharVariantIsDefault
- *
- * @description:
- * Check whether this variation of this Unicode character is the one to
- * be found in the charmap.
- *
- * @input:
- * face ::
- * A handle to the source face object.
- *
- * charcode ::
- * The character codepoint in Unicode.
- *
- * variantSelector ::
- * The Unicode codepoint of the variation selector.
- *
- * @return:
- * 1~if found in the standard (Unicode) cmap, 0~if found in the variation
- * selector cmap, or -1 if it is not a variation.
- *
- * @note:
- * This function is only meaningful if the font has a variation selector
- * cmap subtable.
- *
- * @since:
- * 2.3.6
- *
- */
- FT_EXPORT( FT_Int )
- FT_Face_GetCharVariantIsDefault( FT_Face face,
- FT_ULong charcode,
- FT_ULong variantSelector );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Face_GetVariantSelectors
- *
- * @description:
- * Return a zero-terminated list of Unicode variation selectors found in
- * the font.
- *
- * @input:
- * face ::
- * A handle to the source face object.
- *
- * @return:
- * A pointer to an array of selector code points, or `NULL` if there is
- * no valid variation selector cmap subtable.
- *
- * @note:
- * The last item in the array is~0; the array is owned by the @FT_Face
- * object but can be overwritten or released on the next call to a
- * FreeType function.
- *
- * @since:
- * 2.3.6
- *
- */
- FT_EXPORT( FT_UInt32* )
- FT_Face_GetVariantSelectors( FT_Face face );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Face_GetVariantsOfChar
- *
- * @description:
- * Return a zero-terminated list of Unicode variation selectors found for
- * the specified character code.
- *
- * @input:
- * face ::
- * A handle to the source face object.
- *
- * charcode ::
- * The character codepoint in Unicode.
- *
- * @return:
- * A pointer to an array of variation selector code points that are
- * active for the given character, or `NULL` if the corresponding list is
- * empty.
- *
- * @note:
- * The last item in the array is~0; the array is owned by the @FT_Face
- * object but can be overwritten or released on the next call to a
- * FreeType function.
- *
- * @since:
- * 2.3.6
- *
- */
- FT_EXPORT( FT_UInt32* )
- FT_Face_GetVariantsOfChar( FT_Face face,
- FT_ULong charcode );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Face_GetCharsOfVariant
- *
- * @description:
- * Return a zero-terminated list of Unicode character codes found for the
- * specified variation selector.
- *
- * @input:
- * face ::
- * A handle to the source face object.
- *
- * variantSelector ::
- * The variation selector code point in Unicode.
- *
- * @return:
- * A list of all the code points that are specified by this selector
- * (both default and non-default codes are returned) or `NULL` if there
- * is no valid cmap or the variation selector is invalid.
- *
- * @note:
- * The last item in the array is~0; the array is owned by the @FT_Face
- * object but can be overwritten or released on the next call to a
- * FreeType function.
- *
- * @since:
- * 2.3.6
- *
- */
- FT_EXPORT( FT_UInt32* )
- FT_Face_GetCharsOfVariant( FT_Face face,
- FT_ULong variantSelector );
-
-
- /**************************************************************************
- *
- * @section:
- * computations
- *
- * @title:
- * Computations
- *
- * @abstract:
- * Crunching fixed numbers and vectors.
- *
- * @description:
- * This section contains various functions used to perform computations
- * on 16.16 fixed-point numbers or 2D vectors. FreeType does not use
- * floating-point data types.
- *
- * **Attention**: Most arithmetic functions take `FT_Long` as arguments.
- * For historical reasons, FreeType was designed under the assumption
- * that `FT_Long` is a 32-bit integer; results can thus be undefined if
- * the arguments don't fit into 32 bits.
- *
- * @order:
- * FT_MulDiv
- * FT_MulFix
- * FT_DivFix
- * FT_RoundFix
- * FT_CeilFix
- * FT_FloorFix
- * FT_Vector_Transform
- * FT_Matrix_Multiply
- * FT_Matrix_Invert
- *
- */
-
-
- /**************************************************************************
- *
- * @function:
- * FT_MulDiv
- *
- * @description:
- * Compute `(a*b)/c` with maximum accuracy, using a 64-bit intermediate
- * integer whenever necessary.
- *
- * This function isn't necessarily as fast as some processor-specific
- * operations, but is at least completely portable.
- *
- * @input:
- * a ::
- * The first multiplier.
- *
- * b ::
- * The second multiplier.
- *
- * c ::
- * The divisor.
- *
- * @return:
- * The result of `(a*b)/c`. This function never traps when trying to
- * divide by zero; it simply returns 'MaxInt' or 'MinInt' depending on
- * the signs of `a` and `b`.
- */
- FT_EXPORT( FT_Long )
- FT_MulDiv( FT_Long a,
- FT_Long b,
- FT_Long c );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_MulFix
- *
- * @description:
- * Compute `(a*b)/0x10000` with maximum accuracy. Its main use is to
- * multiply a given value by a 16.16 fixed-point factor.
- *
- * @input:
- * a ::
- * The first multiplier.
- *
- * b ::
- * The second multiplier. Use a 16.16 factor here whenever possible
- * (see note below).
- *
- * @return:
- * The result of `(a*b)/0x10000`.
- *
- * @note:
- * This function has been optimized for the case where the absolute value
- * of `a` is less than 2048, and `b` is a 16.16 scaling factor. As this
- * happens mainly when scaling from notional units to fractional pixels
- * in FreeType, it resulted in noticeable speed improvements between
- * versions 2.x and 1.x.
- *
- * As a conclusion, always try to place a 16.16 factor as the _second_
- * argument of this function; this can make a great difference.
- */
- FT_EXPORT( FT_Long )
- FT_MulFix( FT_Long a,
- FT_Long b );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_DivFix
- *
- * @description:
- * Compute `(a*0x10000)/b` with maximum accuracy. Its main use is to
- * divide a given value by a 16.16 fixed-point factor.
- *
- * @input:
- * a ::
- * The numerator.
- *
- * b ::
- * The denominator. Use a 16.16 factor here.
- *
- * @return:
- * The result of `(a*0x10000)/b`.
- */
- FT_EXPORT( FT_Long )
- FT_DivFix( FT_Long a,
- FT_Long b );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_RoundFix
- *
- * @description:
- * Round a 16.16 fixed number.
- *
- * @input:
- * a ::
- * The number to be rounded.
- *
- * @return:
- * `a` rounded to the nearest 16.16 fixed integer, halfway cases away
- * from zero.
- *
- * @note:
- * The function uses wrap-around arithmetic.
- */
- FT_EXPORT( FT_Fixed )
- FT_RoundFix( FT_Fixed a );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_CeilFix
- *
- * @description:
- * Compute the smallest following integer of a 16.16 fixed number.
- *
- * @input:
- * a ::
- * The number for which the ceiling function is to be computed.
- *
- * @return:
- * `a` rounded towards plus infinity.
- *
- * @note:
- * The function uses wrap-around arithmetic.
- */
- FT_EXPORT( FT_Fixed )
- FT_CeilFix( FT_Fixed a );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_FloorFix
- *
- * @description:
- * Compute the largest previous integer of a 16.16 fixed number.
- *
- * @input:
- * a ::
- * The number for which the floor function is to be computed.
- *
- * @return:
- * `a` rounded towards minus infinity.
- */
- FT_EXPORT( FT_Fixed )
- FT_FloorFix( FT_Fixed a );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Vector_Transform
- *
- * @description:
- * Transform a single vector through a 2x2 matrix.
- *
- * @inout:
- * vector ::
- * The target vector to transform.
- *
- * @input:
- * matrix ::
- * A pointer to the source 2x2 matrix.
- *
- * @note:
- * The result is undefined if either `vector` or `matrix` is invalid.
- */
- FT_EXPORT( void )
- FT_Vector_Transform( FT_Vector* vector,
- const FT_Matrix* matrix );
-
-
- /**************************************************************************
- *
- * @section:
- * library_setup
- *
- */
-
- /**************************************************************************
- *
- * @enum:
- * FREETYPE_XXX
- *
- * @description:
- * These three macros identify the FreeType source code version. Use
- * @FT_Library_Version to access them at runtime.
- *
- * @values:
- * FREETYPE_MAJOR ::
- * The major version number.
- * FREETYPE_MINOR ::
- * The minor version number.
- * FREETYPE_PATCH ::
- * The patch level.
- *
- * @note:
- * The version number of FreeType if built as a dynamic link library with
- * the 'libtool' package is _not_ controlled by these three macros.
- *
- */
-#define FREETYPE_MAJOR 2
-#define FREETYPE_MINOR 13
-#define FREETYPE_PATCH 3
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Library_Version
- *
- * @description:
- * Return the version of the FreeType library being used. This is useful
- * when dynamically linking to the library, since one cannot use the
- * macros @FREETYPE_MAJOR, @FREETYPE_MINOR, and @FREETYPE_PATCH.
- *
- * @input:
- * library ::
- * A source library handle.
- *
- * @output:
- * amajor ::
- * The major version number.
- *
- * aminor ::
- * The minor version number.
- *
- * apatch ::
- * The patch version number.
- *
- * @note:
- * The reason why this function takes a `library` argument is because
- * certain programs implement library initialization in a custom way that
- * doesn't use @FT_Init_FreeType.
- *
- * In such cases, the library version might not be available before the
- * library object has been created.
- */
- FT_EXPORT( void )
- FT_Library_Version( FT_Library library,
- FT_Int *amajor,
- FT_Int *aminor,
- FT_Int *apatch );
-
-
- /**************************************************************************
- *
- * @section:
- * other_api_data
- *
- */
-
- /**************************************************************************
- *
- * @function:
- * FT_Face_CheckTrueTypePatents
- *
- * @description:
- * Deprecated, does nothing.
- *
- * @input:
- * face ::
- * A face handle.
- *
- * @return:
- * Always returns false.
- *
- * @note:
- * Since May 2010, TrueType hinting is no longer patented.
- *
- * @since:
- * 2.3.5
- *
- */
- FT_EXPORT( FT_Bool )
- FT_Face_CheckTrueTypePatents( FT_Face face );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Face_SetUnpatentedHinting
- *
- * @description:
- * Deprecated, does nothing.
- *
- * @input:
- * face ::
- * A face handle.
- *
- * value ::
- * New boolean setting.
- *
- * @return:
- * Always returns false.
- *
- * @note:
- * Since May 2010, TrueType hinting is no longer patented.
- *
- * @since:
- * 2.3.5
- *
- */
- FT_EXPORT( FT_Bool )
- FT_Face_SetUnpatentedHinting( FT_Face face,
- FT_Bool value );
-
- /* */
-
-
-FT_END_HEADER
-
-#endif /* FREETYPE_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/ftadvanc.h b/contrib/libs/freetype/include/freetype/ftadvanc.h
deleted file mode 100644
index 85b8ba2554..0000000000
--- a/contrib/libs/freetype/include/freetype/ftadvanc.h
+++ /dev/null
@@ -1,188 +0,0 @@
-/****************************************************************************
- *
- * ftadvanc.h
- *
- * Quick computation of advance widths (specification only).
- *
- * Copyright (C) 2008-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTADVANC_H_
-#define FTADVANC_H_
-
-
-#include <freetype/freetype.h>
-
-#ifdef FREETYPE_H
-#error "freetype.h of FreeType 1 has been loaded!"
-#error "Please fix the directory search order for header files"
-#error "so that freetype.h of FreeType 2 is found first."
-#endif
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @section:
- * quick_advance
- *
- * @title:
- * Quick retrieval of advance values
- *
- * @abstract:
- * Retrieve horizontal and vertical advance values without processing
- * glyph outlines, if possible.
- *
- * @description:
- * This section contains functions to quickly extract advance values
- * without handling glyph outlines, if possible.
- *
- * @order:
- * FT_Get_Advance
- * FT_Get_Advances
- *
- */
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_ADVANCE_FLAG_FAST_ONLY
- *
- * @description:
- * A bit-flag to be OR-ed with the `flags` parameter of the
- * @FT_Get_Advance and @FT_Get_Advances functions.
- *
- * If set, it indicates that you want these functions to fail if the
- * corresponding hinting mode or font driver doesn't allow for very quick
- * advance computation.
- *
- * Typically, glyphs that are either unscaled, unhinted, bitmapped, or
- * light-hinted can have their advance width computed very quickly.
- *
- * Normal and bytecode hinted modes that require loading, scaling, and
- * hinting of the glyph outline, are extremely slow by comparison.
- */
-#define FT_ADVANCE_FLAG_FAST_ONLY 0x20000000L
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_Advance
- *
- * @description:
- * Retrieve the advance value of a given glyph outline in an @FT_Face.
- *
- * @input:
- * face ::
- * The source @FT_Face handle.
- *
- * gindex ::
- * The glyph index.
- *
- * load_flags ::
- * A set of bit flags similar to those used when calling
- * @FT_Load_Glyph, used to determine what kind of advances you need.
- *
- * @output:
- * padvance ::
- * The advance value. If scaling is performed (based on the value of
- * `load_flags`), the advance value is in 16.16 format. Otherwise, it
- * is in font units.
- *
- * If @FT_LOAD_VERTICAL_LAYOUT is set, this is the vertical advance
- * corresponding to a vertical layout. Otherwise, it is the horizontal
- * advance in a horizontal layout.
- *
- * @return:
- * FreeType error code. 0 means success.
- *
- * @note:
- * This function may fail if you use @FT_ADVANCE_FLAG_FAST_ONLY and if
- * the corresponding font backend doesn't have a quick way to retrieve
- * the advances.
- *
- * A scaled advance is returned in 16.16 format but isn't transformed by
- * the affine transformation specified by @FT_Set_Transform.
- */
- FT_EXPORT( FT_Error )
- FT_Get_Advance( FT_Face face,
- FT_UInt gindex,
- FT_Int32 load_flags,
- FT_Fixed *padvance );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_Advances
- *
- * @description:
- * Retrieve the advance values of several glyph outlines in an @FT_Face.
- *
- * @input:
- * face ::
- * The source @FT_Face handle.
- *
- * start ::
- * The first glyph index.
- *
- * count ::
- * The number of advance values you want to retrieve.
- *
- * load_flags ::
- * A set of bit flags similar to those used when calling
- * @FT_Load_Glyph.
- *
- * @output:
- * padvance ::
- * The advance values. This array, to be provided by the caller, must
- * contain at least `count` elements.
- *
- * If scaling is performed (based on the value of `load_flags`), the
- * advance values are in 16.16 format. Otherwise, they are in font
- * units.
- *
- * If @FT_LOAD_VERTICAL_LAYOUT is set, these are the vertical advances
- * corresponding to a vertical layout. Otherwise, they are the
- * horizontal advances in a horizontal layout.
- *
- * @return:
- * FreeType error code. 0 means success.
- *
- * @note:
- * This function may fail if you use @FT_ADVANCE_FLAG_FAST_ONLY and if
- * the corresponding font backend doesn't have a quick way to retrieve
- * the advances.
- *
- * Scaled advances are returned in 16.16 format but aren't transformed by
- * the affine transformation specified by @FT_Set_Transform.
- */
- FT_EXPORT( FT_Error )
- FT_Get_Advances( FT_Face face,
- FT_UInt start,
- FT_UInt count,
- FT_Int32 load_flags,
- FT_Fixed *padvances );
-
- /* */
-
-
-FT_END_HEADER
-
-#endif /* FTADVANC_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/ftbbox.h b/contrib/libs/freetype/include/freetype/ftbbox.h
deleted file mode 100644
index 12bbfa63a6..0000000000
--- a/contrib/libs/freetype/include/freetype/ftbbox.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/****************************************************************************
- *
- * ftbbox.h
- *
- * FreeType exact bbox computation (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /**************************************************************************
- *
- * This component has a _single_ role: to compute exact outline bounding
- * boxes.
- *
- * It is separated from the rest of the engine for various technical
- * reasons. It may well be integrated in 'ftoutln' later.
- *
- */
-
-
-#ifndef FTBBOX_H_
-#define FTBBOX_H_
-
-
-#include <freetype/freetype.h>
-
-#ifdef FREETYPE_H
-#error "freetype.h of FreeType 1 has been loaded!"
-#error "Please fix the directory search order for header files"
-#error "so that freetype.h of FreeType 2 is found first."
-#endif
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @section:
- * outline_processing
- *
- */
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Outline_Get_BBox
- *
- * @description:
- * Compute the exact bounding box of an outline. This is slower than
- * computing the control box. However, it uses an advanced algorithm
- * that returns _very_ quickly when the two boxes coincide. Otherwise,
- * the outline Bezier arcs are traversed to extract their extrema.
- *
- * @input:
- * outline ::
- * A pointer to the source outline.
- *
- * @output:
- * abbox ::
- * The outline's exact bounding box.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * If the font is tricky and the glyph has been loaded with
- * @FT_LOAD_NO_SCALE, the resulting BBox is meaningless. To get
- * reasonable values for the BBox it is necessary to load the glyph at a
- * large ppem value (so that the hinting instructions can properly shift
- * and scale the subglyphs), then extracting the BBox, which can be
- * eventually converted back to font units.
- */
- FT_EXPORT( FT_Error )
- FT_Outline_Get_BBox( FT_Outline* outline,
- FT_BBox *abbox );
-
- /* */
-
-
-FT_END_HEADER
-
-#endif /* FTBBOX_H_ */
-
-
-/* END */
-
-
-/* Local Variables: */
-/* coding: utf-8 */
-/* End: */
diff --git a/contrib/libs/freetype/include/freetype/ftbdf.h b/contrib/libs/freetype/include/freetype/ftbdf.h
deleted file mode 100644
index 6f63b0b1e7..0000000000
--- a/contrib/libs/freetype/include/freetype/ftbdf.h
+++ /dev/null
@@ -1,212 +0,0 @@
-/****************************************************************************
- *
- * ftbdf.h
- *
- * FreeType API for accessing BDF-specific strings (specification).
- *
- * Copyright (C) 2002-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTBDF_H_
-#define FTBDF_H_
-
-#include <freetype/freetype.h>
-
-#ifdef FREETYPE_H
-#error "freetype.h of FreeType 1 has been loaded!"
-#error "Please fix the directory search order for header files"
-#error "so that freetype.h of FreeType 2 is found first."
-#endif
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @section:
- * bdf_fonts
- *
- * @title:
- * BDF and PCF Files
- *
- * @abstract:
- * BDF and PCF specific API.
- *
- * @description:
- * This section contains the declaration of functions specific to BDF and
- * PCF fonts.
- *
- */
-
-
- /**************************************************************************
- *
- * @enum:
- * BDF_PropertyType
- *
- * @description:
- * A list of BDF property types.
- *
- * @values:
- * BDF_PROPERTY_TYPE_NONE ::
- * Value~0 is used to indicate a missing property.
- *
- * BDF_PROPERTY_TYPE_ATOM ::
- * Property is a string atom.
- *
- * BDF_PROPERTY_TYPE_INTEGER ::
- * Property is a 32-bit signed integer.
- *
- * BDF_PROPERTY_TYPE_CARDINAL ::
- * Property is a 32-bit unsigned integer.
- */
- typedef enum BDF_PropertyType_
- {
- BDF_PROPERTY_TYPE_NONE = 0,
- BDF_PROPERTY_TYPE_ATOM = 1,
- BDF_PROPERTY_TYPE_INTEGER = 2,
- BDF_PROPERTY_TYPE_CARDINAL = 3
-
- } BDF_PropertyType;
-
-
- /**************************************************************************
- *
- * @type:
- * BDF_Property
- *
- * @description:
- * A handle to a @BDF_PropertyRec structure to model a given BDF/PCF
- * property.
- */
- typedef struct BDF_PropertyRec_* BDF_Property;
-
-
- /**************************************************************************
- *
- * @struct:
- * BDF_PropertyRec
- *
- * @description:
- * This structure models a given BDF/PCF property.
- *
- * @fields:
- * type ::
- * The property type.
- *
- * u.atom ::
- * The atom string, if type is @BDF_PROPERTY_TYPE_ATOM. May be
- * `NULL`, indicating an empty string.
- *
- * u.integer ::
- * A signed integer, if type is @BDF_PROPERTY_TYPE_INTEGER.
- *
- * u.cardinal ::
- * An unsigned integer, if type is @BDF_PROPERTY_TYPE_CARDINAL.
- */
- typedef struct BDF_PropertyRec_
- {
- BDF_PropertyType type;
- union {
- const char* atom;
- FT_Int32 integer;
- FT_UInt32 cardinal;
-
- } u;
-
- } BDF_PropertyRec;
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_BDF_Charset_ID
- *
- * @description:
- * Retrieve a BDF font character set identity, according to the BDF
- * specification.
- *
- * @input:
- * face ::
- * A handle to the input face.
- *
- * @output:
- * acharset_encoding ::
- * Charset encoding, as a C~string, owned by the face.
- *
- * acharset_registry ::
- * Charset registry, as a C~string, owned by the face.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * This function only works with BDF faces, returning an error otherwise.
- */
- FT_EXPORT( FT_Error )
- FT_Get_BDF_Charset_ID( FT_Face face,
- const char* *acharset_encoding,
- const char* *acharset_registry );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_BDF_Property
- *
- * @description:
- * Retrieve a BDF property from a BDF or PCF font file.
- *
- * @input:
- * face ::
- * A handle to the input face.
- *
- * name ::
- * The property name.
- *
- * @output:
- * aproperty ::
- * The property.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * This function works with BDF _and_ PCF fonts. It returns an error
- * otherwise. It also returns an error if the property is not in the
- * font.
- *
- * A 'property' is a either key-value pair within the STARTPROPERTIES
- * ... ENDPROPERTIES block of a BDF font or a key-value pair from the
- * `info->props` array within a `FontRec` structure of a PCF font.
- *
- * Integer properties are always stored as 'signed' within PCF fonts;
- * consequently, @BDF_PROPERTY_TYPE_CARDINAL is a possible return value
- * for BDF fonts only.
- *
- * In case of error, `aproperty->type` is always set to
- * @BDF_PROPERTY_TYPE_NONE.
- */
- FT_EXPORT( FT_Error )
- FT_Get_BDF_Property( FT_Face face,
- const char* prop_name,
- BDF_PropertyRec *aproperty );
-
- /* */
-
-FT_END_HEADER
-
-#endif /* FTBDF_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/ftbitmap.h b/contrib/libs/freetype/include/freetype/ftbitmap.h
deleted file mode 100644
index df9d462652..0000000000
--- a/contrib/libs/freetype/include/freetype/ftbitmap.h
+++ /dev/null
@@ -1,329 +0,0 @@
-/****************************************************************************
- *
- * ftbitmap.h
- *
- * FreeType utility functions for bitmaps (specification).
- *
- * Copyright (C) 2004-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTBITMAP_H_
-#define FTBITMAP_H_
-
-
-#include <freetype/freetype.h>
-#include <freetype/ftcolor.h>
-
-#ifdef FREETYPE_H
-#error "freetype.h of FreeType 1 has been loaded!"
-#error "Please fix the directory search order for header files"
-#error "so that freetype.h of FreeType 2 is found first."
-#endif
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @section:
- * bitmap_handling
- *
- * @title:
- * Bitmap Handling
- *
- * @abstract:
- * Handling FT_Bitmap objects.
- *
- * @description:
- * This section contains functions for handling @FT_Bitmap objects,
- * automatically adjusting the target's bitmap buffer size as needed.
- *
- * Note that none of the functions changes the bitmap's 'flow' (as
- * indicated by the sign of the `pitch` field in @FT_Bitmap).
- *
- * To set the flow, assign an appropriate positive or negative value to
- * the `pitch` field of the target @FT_Bitmap object after calling
- * @FT_Bitmap_Init but before calling any of the other functions
- * described here.
- */
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Bitmap_Init
- *
- * @description:
- * Initialize a pointer to an @FT_Bitmap structure.
- *
- * @inout:
- * abitmap ::
- * A pointer to the bitmap structure.
- *
- * @note:
- * A deprecated name for the same function is `FT_Bitmap_New`.
- */
- FT_EXPORT( void )
- FT_Bitmap_Init( FT_Bitmap *abitmap );
-
-
- /* deprecated */
- FT_EXPORT( void )
- FT_Bitmap_New( FT_Bitmap *abitmap );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Bitmap_Copy
- *
- * @description:
- * Copy a bitmap into another one.
- *
- * @input:
- * library ::
- * A handle to a library object.
- *
- * source ::
- * A handle to the source bitmap.
- *
- * @output:
- * target ::
- * A handle to the target bitmap.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * `source->buffer` and `target->buffer` must neither be equal nor
- * overlap.
- */
- FT_EXPORT( FT_Error )
- FT_Bitmap_Copy( FT_Library library,
- const FT_Bitmap *source,
- FT_Bitmap *target );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Bitmap_Embolden
- *
- * @description:
- * Embolden a bitmap. The new bitmap will be about `xStrength` pixels
- * wider and `yStrength` pixels higher. The left and bottom borders are
- * kept unchanged.
- *
- * @input:
- * library ::
- * A handle to a library object.
- *
- * xStrength ::
- * How strong the glyph is emboldened horizontally. Expressed in 26.6
- * pixel format.
- *
- * yStrength ::
- * How strong the glyph is emboldened vertically. Expressed in 26.6
- * pixel format.
- *
- * @inout:
- * bitmap ::
- * A handle to the target bitmap.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * The current implementation restricts `xStrength` to be less than or
- * equal to~8 if bitmap is of pixel_mode @FT_PIXEL_MODE_MONO.
- *
- * If you want to embolden the bitmap owned by a @FT_GlyphSlotRec, you
- * should call @FT_GlyphSlot_Own_Bitmap on the slot first.
- *
- * Bitmaps in @FT_PIXEL_MODE_GRAY2 and @FT_PIXEL_MODE_GRAY@ format are
- * converted to @FT_PIXEL_MODE_GRAY format (i.e., 8bpp).
- */
- FT_EXPORT( FT_Error )
- FT_Bitmap_Embolden( FT_Library library,
- FT_Bitmap* bitmap,
- FT_Pos xStrength,
- FT_Pos yStrength );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Bitmap_Convert
- *
- * @description:
- * Convert a bitmap object with depth 1bpp, 2bpp, 4bpp, 8bpp or 32bpp to
- * a bitmap object with depth 8bpp, making the number of used bytes per
- * line (a.k.a. the 'pitch') a multiple of `alignment`.
- *
- * @input:
- * library ::
- * A handle to a library object.
- *
- * source ::
- * The source bitmap.
- *
- * alignment ::
- * The pitch of the bitmap is a multiple of this argument. Common
- * values are 1, 2, or 4.
- *
- * @output:
- * target ::
- * The target bitmap.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * It is possible to call @FT_Bitmap_Convert multiple times without
- * calling @FT_Bitmap_Done (the memory is simply reallocated).
- *
- * Use @FT_Bitmap_Done to finally remove the bitmap object.
- *
- * The `library` argument is taken to have access to FreeType's memory
- * handling functions.
- *
- * `source->buffer` and `target->buffer` must neither be equal nor
- * overlap.
- */
- FT_EXPORT( FT_Error )
- FT_Bitmap_Convert( FT_Library library,
- const FT_Bitmap *source,
- FT_Bitmap *target,
- FT_Int alignment );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Bitmap_Blend
- *
- * @description:
- * Blend a bitmap onto another bitmap, using a given color.
- *
- * @input:
- * library ::
- * A handle to a library object.
- *
- * source ::
- * The source bitmap, which can have any @FT_Pixel_Mode format.
- *
- * source_offset ::
- * The offset vector to the upper left corner of the source bitmap in
- * 26.6 pixel format. It should represent an integer offset; the
- * function will set the lowest six bits to zero to enforce that.
- *
- * color ::
- * The color used to draw `source` onto `target`.
- *
- * @inout:
- * target ::
- * A handle to an `FT_Bitmap` object. It should be either initialized
- * as empty with a call to @FT_Bitmap_Init, or it should be of type
- * @FT_PIXEL_MODE_BGRA.
- *
- * atarget_offset ::
- * The offset vector to the upper left corner of the target bitmap in
- * 26.6 pixel format. It should represent an integer offset; the
- * function will set the lowest six bits to zero to enforce that.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * This function doesn't perform clipping.
- *
- * The bitmap in `target` gets allocated or reallocated as needed; the
- * vector `atarget_offset` is updated accordingly.
- *
- * In case of allocation or reallocation, the bitmap's pitch is set to
- * `4 * width`. Both `source` and `target` must have the same bitmap
- * flow (as indicated by the sign of the `pitch` field).
- *
- * `source->buffer` and `target->buffer` must neither be equal nor
- * overlap.
- *
- * @since:
- * 2.10
- */
- FT_EXPORT( FT_Error )
- FT_Bitmap_Blend( FT_Library library,
- const FT_Bitmap* source,
- const FT_Vector source_offset,
- FT_Bitmap* target,
- FT_Vector *atarget_offset,
- FT_Color color );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_GlyphSlot_Own_Bitmap
- *
- * @description:
- * Make sure that a glyph slot owns `slot->bitmap`.
- *
- * @input:
- * slot ::
- * The glyph slot.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * This function is to be used in combination with @FT_Bitmap_Embolden.
- */
- FT_EXPORT( FT_Error )
- FT_GlyphSlot_Own_Bitmap( FT_GlyphSlot slot );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Bitmap_Done
- *
- * @description:
- * Destroy a bitmap object initialized with @FT_Bitmap_Init.
- *
- * @input:
- * library ::
- * A handle to a library object.
- *
- * bitmap ::
- * The bitmap object to be freed.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * The `library` argument is taken to have access to FreeType's memory
- * handling functions.
- */
- FT_EXPORT( FT_Error )
- FT_Bitmap_Done( FT_Library library,
- FT_Bitmap *bitmap );
-
-
- /* */
-
-
-FT_END_HEADER
-
-#endif /* FTBITMAP_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/ftbzip2.h b/contrib/libs/freetype/include/freetype/ftbzip2.h
deleted file mode 100644
index c5baea8562..0000000000
--- a/contrib/libs/freetype/include/freetype/ftbzip2.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/****************************************************************************
- *
- * ftbzip2.h
- *
- * Bzip2-compressed stream support.
- *
- * Copyright (C) 2010-2024 by
- * Joel Klinghed.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTBZIP2_H_
-#define FTBZIP2_H_
-
-#include <freetype/freetype.h>
-
-#ifdef FREETYPE_H
-#error "freetype.h of FreeType 1 has been loaded!"
-#error "Please fix the directory search order for header files"
-#error "so that freetype.h of FreeType 2 is found first."
-#endif
-
-
-FT_BEGIN_HEADER
-
- /**************************************************************************
- *
- * @section:
- * bzip2
- *
- * @title:
- * BZIP2 Streams
- *
- * @abstract:
- * Using bzip2-compressed font files.
- *
- * @description:
- * In certain builds of the library, bzip2 compression recognition is
- * automatically handled when calling @FT_New_Face or @FT_Open_Face.
- * This means that if no font driver is capable of handling the raw
- * compressed file, the library will try to open a bzip2 compressed
- * stream from it and re-open the face with it.
- *
- * The stream implementation is very basic and resets the decompression
- * process each time seeking backwards is needed within the stream,
- * which significantly undermines the performance.
- *
- * This section contains the declaration of Bzip2-specific functions.
- *
- */
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Stream_OpenBzip2
- *
- * @description:
- * Open a new stream to parse bzip2-compressed font files. This is
- * mainly used to support the compressed `*.pcf.bz2` fonts that come with
- * XFree86.
- *
- * @input:
- * stream ::
- * The target embedding stream.
- *
- * source ::
- * The source stream.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * The source stream must be opened _before_ calling this function.
- *
- * Calling the internal function `FT_Stream_Close` on the new stream will
- * **not** call `FT_Stream_Close` on the source stream. None of the
- * stream objects will be released to the heap.
- *
- * This function may return `FT_Err_Unimplemented_Feature` if your build
- * of FreeType was not compiled with bzip2 support.
- */
- FT_EXPORT( FT_Error )
- FT_Stream_OpenBzip2( FT_Stream stream,
- FT_Stream source );
-
- /* */
-
-
-FT_END_HEADER
-
-#endif /* FTBZIP2_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/ftcache.h b/contrib/libs/freetype/include/freetype/ftcache.h
deleted file mode 100644
index 140df4c96c..0000000000
--- a/contrib/libs/freetype/include/freetype/ftcache.h
+++ /dev/null
@@ -1,1087 +0,0 @@
-/****************************************************************************
- *
- * ftcache.h
- *
- * FreeType Cache subsystem (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTCACHE_H_
-#define FTCACHE_H_
-
-
-#include <freetype/ftglyph.h>
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @section:
- * cache_subsystem
- *
- * @title:
- * Cache Sub-System
- *
- * @abstract:
- * How to cache face, size, and glyph data with FreeType~2.
- *
- * @description:
- * This section describes the FreeType~2 cache sub-system, which is used
- * to limit the number of concurrently opened @FT_Face and @FT_Size
- * objects, as well as caching information like character maps and glyph
- * images while limiting their maximum memory usage.
- *
- * Note that all types and functions begin with the `FTC_` prefix rather
- * than the usual `FT_` prefix in the rest of FreeType.
- *
- * The cache is highly portable and, thus, doesn't know anything about
- * the fonts installed on your system, or how to access them. Therefore,
- * it requires the following.
- *
- * * @FTC_FaceID, an arbitrary non-zero value that uniquely identifies
- * available or installed font faces, has to be provided to the
- * cache by the client. Note that the cache only stores and compares
- * these values and doesn't try to interpret them in any way, but they
- * have to be persistent on the client side.
- *
- * * @FTC_Face_Requester, a method to convert an @FTC_FaceID into a new
- * @FT_Face object when necessary, has to be provided to the cache by
- * the client. The @FT_Face object is completely managed by the cache,
- * including its termination through @FT_Done_Face. To monitor
- * termination of face objects, the finalizer callback in the `generic`
- * field of the @FT_Face object can be used, which might also be used
- * to store the @FTC_FaceID of the face.
- *
- * Clients are free to map face IDs to anything useful. The most simple
- * usage is, for example, to associate them to a `{pathname,face_index}`
- * pair that is then used by @FTC_Face_Requester to call @FT_New_Face.
- * However, more complex schemes are also possible.
- *
- * Note that for the cache to work correctly, the face ID values must be
- * **persistent**, which means that the contents they point to should not
- * change at runtime, or that their value should not become invalid.
- * If this is unavoidable (e.g., when a font is uninstalled at runtime),
- * you should call @FTC_Manager_RemoveFaceID as soon as possible to let
- * the cache get rid of any references to the old @FTC_FaceID it may keep
- * internally. Failure to do so will lead to incorrect behaviour or even
- * crashes in @FTC_Face_Requester.
- *
- * To use the cache, start with calling @FTC_Manager_New to create a new
- * @FTC_Manager object, which models a single cache instance. You can
- * then look up @FT_Face and @FT_Size objects with
- * @FTC_Manager_LookupFace and @FTC_Manager_LookupSize, respectively, and
- * use them in any FreeType work stream. You can also cache other
- * FreeType objects as follows.
- *
- * * If you want to use the charmap caching, call @FTC_CMapCache_New,
- * then later use @FTC_CMapCache_Lookup to perform the equivalent of
- * @FT_Get_Char_Index, only much faster.
- *
- * * If you want to use the @FT_Glyph caching, call @FTC_ImageCache_New,
- * then later use @FTC_ImageCache_Lookup to retrieve the corresponding
- * @FT_Glyph objects from the cache.
- *
- * * If you need lots of small bitmaps, it is much more memory-efficient
- * to call @FTC_SBitCache_New followed by @FTC_SBitCache_Lookup. This
- * returns @FTC_SBitRec structures, which are used to store small
- * bitmaps directly. (A small bitmap is one whose metrics and
- * dimensions all fit into 8-bit integers).
- *
- * @order:
- * FTC_Manager
- * FTC_FaceID
- * FTC_Face_Requester
- *
- * FTC_Manager_New
- * FTC_Manager_Reset
- * FTC_Manager_Done
- * FTC_Manager_LookupFace
- * FTC_Manager_LookupSize
- * FTC_Manager_RemoveFaceID
- *
- * FTC_Node
- * FTC_Node_Unref
- *
- * FTC_ImageCache
- * FTC_ImageCache_New
- * FTC_ImageCache_Lookup
- *
- * FTC_SBit
- * FTC_SBitCache
- * FTC_SBitCache_New
- * FTC_SBitCache_Lookup
- *
- * FTC_CMapCache
- * FTC_CMapCache_New
- * FTC_CMapCache_Lookup
- *
- *************************************************************************/
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** BASIC TYPE DEFINITIONS *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /**************************************************************************
- *
- * @type:
- * FTC_FaceID
- *
- * @description:
- * An opaque pointer type that is used to identity face objects. The
- * contents of such objects is application-dependent.
- *
- * These pointers are typically used to point to a user-defined structure
- * containing a font file path, and face index.
- *
- * @note:
- * Never use `NULL` as a valid @FTC_FaceID.
- *
- * Face IDs are passed by the client to the cache manager that calls,
- * when needed, the @FTC_Face_Requester to translate them into new
- * @FT_Face objects.
- *
- * If the content of a given face ID changes at runtime, or if the value
- * becomes invalid (e.g., when uninstalling a font), you should
- * immediately call @FTC_Manager_RemoveFaceID before any other cache
- * function.
- *
- * Failure to do so will result in incorrect behaviour or even memory
- * leaks and crashes.
- */
- typedef FT_Pointer FTC_FaceID;
-
-
- /**************************************************************************
- *
- * @functype:
- * FTC_Face_Requester
- *
- * @description:
- * A callback function provided by client applications. It is used by
- * the cache manager to translate a given @FTC_FaceID into a new valid
- * @FT_Face object, on demand.
- *
- * @input:
- * face_id ::
- * The face ID to resolve.
- *
- * library ::
- * A handle to a FreeType library object.
- *
- * req_data ::
- * Application-provided request data (see note below).
- *
- * @output:
- * aface ::
- * A new @FT_Face handle.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * The third parameter `req_data` is the same as the one passed by the
- * client when @FTC_Manager_New is called.
- *
- * The face requester should not perform funny things on the returned
- * face object, like creating a new @FT_Size for it, or setting a
- * transformation through @FT_Set_Transform!
- */
- typedef FT_Error
- (*FTC_Face_Requester)( FTC_FaceID face_id,
- FT_Library library,
- FT_Pointer req_data,
- FT_Face* aface );
-
- /* */
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** CACHE MANAGER OBJECT *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /**************************************************************************
- *
- * @type:
- * FTC_Manager
- *
- * @description:
- * This object corresponds to one instance of the cache-subsystem. It is
- * used to cache one or more @FT_Face objects, along with corresponding
- * @FT_Size objects.
- *
- * The manager intentionally limits the total number of opened @FT_Face
- * and @FT_Size objects to control memory usage. See the `max_faces` and
- * `max_sizes` parameters of @FTC_Manager_New.
- *
- * The manager is also used to cache 'nodes' of various types while
- * limiting their total memory usage.
- *
- * All limitations are enforced by keeping lists of managed objects in
- * most-recently-used order, and flushing old nodes to make room for new
- * ones.
- */
- typedef struct FTC_ManagerRec_* FTC_Manager;
-
-
- /**************************************************************************
- *
- * @type:
- * FTC_Node
- *
- * @description:
- * An opaque handle to a cache node object. Each cache node is
- * reference-counted. A node with a count of~0 might be flushed out of a
- * full cache whenever a lookup request is performed.
- *
- * If you look up nodes, you have the ability to 'acquire' them, i.e., to
- * increment their reference count. This will prevent the node from
- * being flushed out of the cache until you explicitly 'release' it (see
- * @FTC_Node_Unref).
- *
- * See also @FTC_SBitCache_Lookup and @FTC_ImageCache_Lookup.
- */
- typedef struct FTC_NodeRec_* FTC_Node;
-
-
- /**************************************************************************
- *
- * @function:
- * FTC_Manager_New
- *
- * @description:
- * Create a new cache manager.
- *
- * @input:
- * library ::
- * The parent FreeType library handle to use.
- *
- * max_faces ::
- * Maximum number of opened @FT_Face objects managed by this cache
- * instance. Use~0 for defaults.
- *
- * max_sizes ::
- * Maximum number of opened @FT_Size objects managed by this cache
- * instance. Use~0 for defaults.
- *
- * max_bytes ::
- * Maximum number of bytes to use for cached data nodes. Use~0 for
- * defaults. Note that this value does not account for managed
- * @FT_Face and @FT_Size objects.
- *
- * requester ::
- * An application-provided callback used to translate face IDs into
- * real @FT_Face objects.
- *
- * req_data ::
- * A generic pointer that is passed to the requester each time it is
- * called (see @FTC_Face_Requester).
- *
- * @output:
- * amanager ::
- * A handle to a new manager object. 0~in case of failure.
- *
- * @return:
- * FreeType error code. 0~means success.
- */
- FT_EXPORT( FT_Error )
- FTC_Manager_New( FT_Library library,
- FT_UInt max_faces,
- FT_UInt max_sizes,
- FT_ULong max_bytes,
- FTC_Face_Requester requester,
- FT_Pointer req_data,
- FTC_Manager *amanager );
-
-
- /**************************************************************************
- *
- * @function:
- * FTC_Manager_Reset
- *
- * @description:
- * Empty a given cache manager. This simply gets rid of all the
- * currently cached @FT_Face and @FT_Size objects within the manager.
- *
- * @inout:
- * manager ::
- * A handle to the manager.
- */
- FT_EXPORT( void )
- FTC_Manager_Reset( FTC_Manager manager );
-
-
- /**************************************************************************
- *
- * @function:
- * FTC_Manager_Done
- *
- * @description:
- * Destroy a given manager after emptying it.
- *
- * @input:
- * manager ::
- * A handle to the target cache manager object.
- */
- FT_EXPORT( void )
- FTC_Manager_Done( FTC_Manager manager );
-
-
- /**************************************************************************
- *
- * @function:
- * FTC_Manager_LookupFace
- *
- * @description:
- * Retrieve the @FT_Face object that corresponds to a given face ID
- * through a cache manager.
- *
- * @input:
- * manager ::
- * A handle to the cache manager.
- *
- * face_id ::
- * The ID of the face object.
- *
- * @output:
- * aface ::
- * A handle to the face object.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * The returned @FT_Face object is always owned by the manager. You
- * should never try to discard it yourself.
- *
- * The @FT_Face object doesn't necessarily have a current size object
- * (i.e., face->size can be~0). If you need a specific 'font size', use
- * @FTC_Manager_LookupSize instead.
- *
- * Never change the face's transformation matrix (i.e., never call the
- * @FT_Set_Transform function) on a returned face! If you need to
- * transform glyphs, do it yourself after glyph loading.
- *
- * When you perform a lookup, out-of-memory errors are detected _within_
- * the lookup and force incremental flushes of the cache until enough
- * memory is released for the lookup to succeed.
- *
- * If a lookup fails with `FT_Err_Out_Of_Memory` the cache has already
- * been completely flushed, and still no memory was available for the
- * operation.
- */
- FT_EXPORT( FT_Error )
- FTC_Manager_LookupFace( FTC_Manager manager,
- FTC_FaceID face_id,
- FT_Face *aface );
-
-
- /**************************************************************************
- *
- * @struct:
- * FTC_ScalerRec
- *
- * @description:
- * A structure used to describe a given character size in either pixels
- * or points to the cache manager. See @FTC_Manager_LookupSize.
- *
- * @fields:
- * face_id ::
- * The source face ID.
- *
- * width ::
- * The character width.
- *
- * height ::
- * The character height.
- *
- * pixel ::
- * A Boolean. If 1, the `width` and `height` fields are interpreted as
- * integer pixel character sizes. Otherwise, they are expressed as
- * 1/64 of points.
- *
- * x_res ::
- * Only used when `pixel` is value~0 to indicate the horizontal
- * resolution in dpi.
- *
- * y_res ::
- * Only used when `pixel` is value~0 to indicate the vertical
- * resolution in dpi.
- *
- * @note:
- * This type is mainly used to retrieve @FT_Size objects through the
- * cache manager.
- */
- typedef struct FTC_ScalerRec_
- {
- FTC_FaceID face_id;
- FT_UInt width;
- FT_UInt height;
- FT_Int pixel;
- FT_UInt x_res;
- FT_UInt y_res;
-
- } FTC_ScalerRec;
-
-
- /**************************************************************************
- *
- * @struct:
- * FTC_Scaler
- *
- * @description:
- * A handle to an @FTC_ScalerRec structure.
- */
- typedef struct FTC_ScalerRec_* FTC_Scaler;
-
-
- /**************************************************************************
- *
- * @function:
- * FTC_Manager_LookupSize
- *
- * @description:
- * Retrieve the @FT_Size object that corresponds to a given
- * @FTC_ScalerRec pointer through a cache manager.
- *
- * @input:
- * manager ::
- * A handle to the cache manager.
- *
- * scaler ::
- * A scaler handle.
- *
- * @output:
- * asize ::
- * A handle to the size object.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * The returned @FT_Size object is always owned by the manager. You
- * should never try to discard it by yourself.
- *
- * You can access the parent @FT_Face object simply as `size->face` if
- * you need it. Note that this object is also owned by the manager.
- *
- * @note:
- * When you perform a lookup, out-of-memory errors are detected _within_
- * the lookup and force incremental flushes of the cache until enough
- * memory is released for the lookup to succeed.
- *
- * If a lookup fails with `FT_Err_Out_Of_Memory` the cache has already
- * been completely flushed, and still no memory is available for the
- * operation.
- */
- FT_EXPORT( FT_Error )
- FTC_Manager_LookupSize( FTC_Manager manager,
- FTC_Scaler scaler,
- FT_Size *asize );
-
-
- /**************************************************************************
- *
- * @function:
- * FTC_Node_Unref
- *
- * @description:
- * Decrement a cache node's internal reference count. When the count
- * reaches 0, it is not destroyed but becomes eligible for subsequent
- * cache flushes.
- *
- * @input:
- * node ::
- * The cache node handle.
- *
- * manager ::
- * The cache manager handle.
- */
- FT_EXPORT( void )
- FTC_Node_Unref( FTC_Node node,
- FTC_Manager manager );
-
-
- /**************************************************************************
- *
- * @function:
- * FTC_Manager_RemoveFaceID
- *
- * @description:
- * A special function used to indicate to the cache manager that a given
- * @FTC_FaceID is no longer valid, either because its content changed, or
- * because it was deallocated or uninstalled.
- *
- * @input:
- * manager ::
- * The cache manager handle.
- *
- * face_id ::
- * The @FTC_FaceID to be removed.
- *
- * @note:
- * This function flushes all nodes from the cache corresponding to this
- * `face_id`, with the exception of nodes with a non-null reference
- * count.
- *
- * Such nodes are however modified internally so as to never appear in
- * later lookups with the same `face_id` value, and to be immediately
- * destroyed when released by all their users.
- *
- */
- FT_EXPORT( void )
- FTC_Manager_RemoveFaceID( FTC_Manager manager,
- FTC_FaceID face_id );
-
-
- /**************************************************************************
- *
- * @type:
- * FTC_CMapCache
- *
- * @description:
- * An opaque handle used to model a charmap cache. This cache is to hold
- * character codes -> glyph indices mappings.
- *
- */
- typedef struct FTC_CMapCacheRec_* FTC_CMapCache;
-
-
- /**************************************************************************
- *
- * @function:
- * FTC_CMapCache_New
- *
- * @description:
- * Create a new charmap cache.
- *
- * @input:
- * manager ::
- * A handle to the cache manager.
- *
- * @output:
- * acache ::
- * A new cache handle. `NULL` in case of error.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * Like all other caches, this one will be destroyed with the cache
- * manager.
- *
- */
- FT_EXPORT( FT_Error )
- FTC_CMapCache_New( FTC_Manager manager,
- FTC_CMapCache *acache );
-
-
- /**************************************************************************
- *
- * @function:
- * FTC_CMapCache_Lookup
- *
- * @description:
- * Translate a character code into a glyph index, using the charmap
- * cache.
- *
- * @input:
- * cache ::
- * A charmap cache handle.
- *
- * face_id ::
- * The source face ID.
- *
- * cmap_index ::
- * The index of the charmap in the source face. Any negative value
- * means to use the cache @FT_Face's default charmap.
- *
- * char_code ::
- * The character code (in the corresponding charmap).
- *
- * @return:
- * Glyph index. 0~means 'no glyph'.
- *
- */
- FT_EXPORT( FT_UInt )
- FTC_CMapCache_Lookup( FTC_CMapCache cache,
- FTC_FaceID face_id,
- FT_Int cmap_index,
- FT_UInt32 char_code );
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** IMAGE CACHE OBJECT *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /**************************************************************************
- *
- * @struct:
- * FTC_ImageTypeRec
- *
- * @description:
- * A structure used to model the type of images in a glyph cache.
- *
- * @fields:
- * face_id ::
- * The face ID.
- *
- * width ::
- * The width in pixels.
- *
- * height ::
- * The height in pixels.
- *
- * flags ::
- * The load flags, as in @FT_Load_Glyph.
- *
- */
- typedef struct FTC_ImageTypeRec_
- {
- FTC_FaceID face_id;
- FT_UInt width;
- FT_UInt height;
- FT_Int32 flags;
-
- } FTC_ImageTypeRec;
-
-
- /**************************************************************************
- *
- * @type:
- * FTC_ImageType
- *
- * @description:
- * A handle to an @FTC_ImageTypeRec structure.
- *
- */
- typedef struct FTC_ImageTypeRec_* FTC_ImageType;
-
-
- /* */
-
-
-#define FTC_IMAGE_TYPE_COMPARE( d1, d2 ) \
- ( (d1)->face_id == (d2)->face_id && \
- (d1)->width == (d2)->width && \
- (d1)->flags == (d2)->flags )
-
-
- /**************************************************************************
- *
- * @type:
- * FTC_ImageCache
- *
- * @description:
- * A handle to a glyph image cache object. They are designed to hold
- * many distinct glyph images while not exceeding a certain memory
- * threshold.
- */
- typedef struct FTC_ImageCacheRec_* FTC_ImageCache;
-
-
- /**************************************************************************
- *
- * @function:
- * FTC_ImageCache_New
- *
- * @description:
- * Create a new glyph image cache.
- *
- * @input:
- * manager ::
- * The parent manager for the image cache.
- *
- * @output:
- * acache ::
- * A handle to the new glyph image cache object.
- *
- * @return:
- * FreeType error code. 0~means success.
- */
- FT_EXPORT( FT_Error )
- FTC_ImageCache_New( FTC_Manager manager,
- FTC_ImageCache *acache );
-
-
- /**************************************************************************
- *
- * @function:
- * FTC_ImageCache_Lookup
- *
- * @description:
- * Retrieve a given glyph image from a glyph image cache.
- *
- * @input:
- * cache ::
- * A handle to the source glyph image cache.
- *
- * type ::
- * A pointer to a glyph image type descriptor.
- *
- * gindex ::
- * The glyph index to retrieve.
- *
- * @output:
- * aglyph ::
- * The corresponding @FT_Glyph object. 0~in case of failure.
- *
- * anode ::
- * Used to return the address of the corresponding cache node after
- * incrementing its reference count (see note below).
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * The returned glyph is owned and managed by the glyph image cache.
- * Never try to transform or discard it manually! You can however create
- * a copy with @FT_Glyph_Copy and modify the new one.
- *
- * If `anode` is _not_ `NULL`, it receives the address of the cache node
- * containing the glyph image, after increasing its reference count.
- * This ensures that the node (as well as the @FT_Glyph) will always be
- * kept in the cache until you call @FTC_Node_Unref to 'release' it.
- *
- * If `anode` is `NULL`, the cache node is left unchanged, which means
- * that the @FT_Glyph could be flushed out of the cache on the next call
- * to one of the caching sub-system APIs. Don't assume that it is
- * persistent!
- */
- FT_EXPORT( FT_Error )
- FTC_ImageCache_Lookup( FTC_ImageCache cache,
- FTC_ImageType type,
- FT_UInt gindex,
- FT_Glyph *aglyph,
- FTC_Node *anode );
-
-
- /**************************************************************************
- *
- * @function:
- * FTC_ImageCache_LookupScaler
- *
- * @description:
- * A variant of @FTC_ImageCache_Lookup that uses an @FTC_ScalerRec to
- * specify the face ID and its size.
- *
- * @input:
- * cache ::
- * A handle to the source glyph image cache.
- *
- * scaler ::
- * A pointer to a scaler descriptor.
- *
- * load_flags ::
- * The corresponding load flags.
- *
- * gindex ::
- * The glyph index to retrieve.
- *
- * @output:
- * aglyph ::
- * The corresponding @FT_Glyph object. 0~in case of failure.
- *
- * anode ::
- * Used to return the address of the corresponding cache node after
- * incrementing its reference count (see note below).
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * The returned glyph is owned and managed by the glyph image cache.
- * Never try to transform or discard it manually! You can however create
- * a copy with @FT_Glyph_Copy and modify the new one.
- *
- * If `anode` is _not_ `NULL`, it receives the address of the cache node
- * containing the glyph image, after increasing its reference count.
- * This ensures that the node (as well as the @FT_Glyph) will always be
- * kept in the cache until you call @FTC_Node_Unref to 'release' it.
- *
- * If `anode` is `NULL`, the cache node is left unchanged, which means
- * that the @FT_Glyph could be flushed out of the cache on the next call
- * to one of the caching sub-system APIs. Don't assume that it is
- * persistent!
- *
- * Calls to @FT_Set_Char_Size and friends have no effect on cached
- * glyphs; you should always use the FreeType cache API instead.
- */
- FT_EXPORT( FT_Error )
- FTC_ImageCache_LookupScaler( FTC_ImageCache cache,
- FTC_Scaler scaler,
- FT_ULong load_flags,
- FT_UInt gindex,
- FT_Glyph *aglyph,
- FTC_Node *anode );
-
-
- /**************************************************************************
- *
- * @type:
- * FTC_SBit
- *
- * @description:
- * A handle to a small bitmap descriptor. See the @FTC_SBitRec structure
- * for details.
- */
- typedef struct FTC_SBitRec_* FTC_SBit;
-
-
- /**************************************************************************
- *
- * @struct:
- * FTC_SBitRec
- *
- * @description:
- * A very compact structure used to describe a small glyph bitmap.
- *
- * @fields:
- * width ::
- * The bitmap width in pixels.
- *
- * height ::
- * The bitmap height in pixels.
- *
- * left ::
- * The horizontal distance from the pen position to the left bitmap
- * border (a.k.a. 'left side bearing', or 'lsb').
- *
- * top ::
- * The vertical distance from the pen position (on the baseline) to the
- * upper bitmap border (a.k.a. 'top side bearing'). The distance is
- * positive for upwards y~coordinates.
- *
- * format ::
- * The format of the glyph bitmap (monochrome or gray).
- *
- * max_grays ::
- * Maximum gray level value (in the range 1 to~255).
- *
- * pitch ::
- * The number of bytes per bitmap line. May be positive or negative.
- *
- * xadvance ::
- * The horizontal advance width in pixels.
- *
- * yadvance ::
- * The vertical advance height in pixels.
- *
- * buffer ::
- * A pointer to the bitmap pixels.
- */
- typedef struct FTC_SBitRec_
- {
- FT_Byte width;
- FT_Byte height;
- FT_Char left;
- FT_Char top;
-
- FT_Byte format;
- FT_Byte max_grays;
- FT_Short pitch;
- FT_Char xadvance;
- FT_Char yadvance;
-
- FT_Byte* buffer;
-
- } FTC_SBitRec;
-
-
- /**************************************************************************
- *
- * @type:
- * FTC_SBitCache
- *
- * @description:
- * A handle to a small bitmap cache. These are special cache objects
- * used to store small glyph bitmaps (and anti-aliased pixmaps) in a much
- * more efficient way than the traditional glyph image cache implemented
- * by @FTC_ImageCache.
- */
- typedef struct FTC_SBitCacheRec_* FTC_SBitCache;
-
-
- /**************************************************************************
- *
- * @function:
- * FTC_SBitCache_New
- *
- * @description:
- * Create a new cache to store small glyph bitmaps.
- *
- * @input:
- * manager ::
- * A handle to the source cache manager.
- *
- * @output:
- * acache ::
- * A handle to the new sbit cache. `NULL` in case of error.
- *
- * @return:
- * FreeType error code. 0~means success.
- */
- FT_EXPORT( FT_Error )
- FTC_SBitCache_New( FTC_Manager manager,
- FTC_SBitCache *acache );
-
-
- /**************************************************************************
- *
- * @function:
- * FTC_SBitCache_Lookup
- *
- * @description:
- * Look up a given small glyph bitmap in a given sbit cache and 'lock' it
- * to prevent its flushing from the cache until needed.
- *
- * @input:
- * cache ::
- * A handle to the source sbit cache.
- *
- * type ::
- * A pointer to the glyph image type descriptor.
- *
- * gindex ::
- * The glyph index.
- *
- * @output:
- * sbit ::
- * A handle to a small bitmap descriptor.
- *
- * anode ::
- * Used to return the address of the corresponding cache node after
- * incrementing its reference count (see note below).
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * The small bitmap descriptor and its bit buffer are owned by the cache
- * and should never be freed by the application. They might as well
- * disappear from memory on the next cache lookup, so don't treat them as
- * persistent data.
- *
- * The descriptor's `buffer` field is set to~0 to indicate a missing
- * glyph bitmap.
- *
- * If `anode` is _not_ `NULL`, it receives the address of the cache node
- * containing the bitmap, after increasing its reference count. This
- * ensures that the node (as well as the image) will always be kept in
- * the cache until you call @FTC_Node_Unref to 'release' it.
- *
- * If `anode` is `NULL`, the cache node is left unchanged, which means
- * that the bitmap could be flushed out of the cache on the next call to
- * one of the caching sub-system APIs. Don't assume that it is
- * persistent!
- */
- FT_EXPORT( FT_Error )
- FTC_SBitCache_Lookup( FTC_SBitCache cache,
- FTC_ImageType type,
- FT_UInt gindex,
- FTC_SBit *sbit,
- FTC_Node *anode );
-
-
- /**************************************************************************
- *
- * @function:
- * FTC_SBitCache_LookupScaler
- *
- * @description:
- * A variant of @FTC_SBitCache_Lookup that uses an @FTC_ScalerRec to
- * specify the face ID and its size.
- *
- * @input:
- * cache ::
- * A handle to the source sbit cache.
- *
- * scaler ::
- * A pointer to the scaler descriptor.
- *
- * load_flags ::
- * The corresponding load flags.
- *
- * gindex ::
- * The glyph index.
- *
- * @output:
- * sbit ::
- * A handle to a small bitmap descriptor.
- *
- * anode ::
- * Used to return the address of the corresponding cache node after
- * incrementing its reference count (see note below).
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * The small bitmap descriptor and its bit buffer are owned by the cache
- * and should never be freed by the application. They might as well
- * disappear from memory on the next cache lookup, so don't treat them as
- * persistent data.
- *
- * The descriptor's `buffer` field is set to~0 to indicate a missing
- * glyph bitmap.
- *
- * If `anode` is _not_ `NULL`, it receives the address of the cache node
- * containing the bitmap, after increasing its reference count. This
- * ensures that the node (as well as the image) will always be kept in
- * the cache until you call @FTC_Node_Unref to 'release' it.
- *
- * If `anode` is `NULL`, the cache node is left unchanged, which means
- * that the bitmap could be flushed out of the cache on the next call to
- * one of the caching sub-system APIs. Don't assume that it is
- * persistent!
- */
- FT_EXPORT( FT_Error )
- FTC_SBitCache_LookupScaler( FTC_SBitCache cache,
- FTC_Scaler scaler,
- FT_ULong load_flags,
- FT_UInt gindex,
- FTC_SBit *sbit,
- FTC_Node *anode );
-
- /* */
-
-
-FT_END_HEADER
-
-#endif /* FTCACHE_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/ftcid.h b/contrib/libs/freetype/include/freetype/ftcid.h
deleted file mode 100644
index 96b2a90fc5..0000000000
--- a/contrib/libs/freetype/include/freetype/ftcid.h
+++ /dev/null
@@ -1,167 +0,0 @@
-/****************************************************************************
- *
- * ftcid.h
- *
- * FreeType API for accessing CID font information (specification).
- *
- * Copyright (C) 2007-2024 by
- * Dereg Clegg and Michael Toftdal.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTCID_H_
-#define FTCID_H_
-
-#include <freetype/freetype.h>
-
-#ifdef FREETYPE_H
-#error "freetype.h of FreeType 1 has been loaded!"
-#error "Please fix the directory search order for header files"
-#error "so that freetype.h of FreeType 2 is found first."
-#endif
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @section:
- * cid_fonts
- *
- * @title:
- * CID Fonts
- *
- * @abstract:
- * CID-keyed font-specific API.
- *
- * @description:
- * This section contains the declaration of CID-keyed font-specific
- * functions.
- *
- */
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_CID_Registry_Ordering_Supplement
- *
- * @description:
- * Retrieve the Registry/Ordering/Supplement triple (also known as the
- * "R/O/S") from a CID-keyed font.
- *
- * @input:
- * face ::
- * A handle to the input face.
- *
- * @output:
- * registry ::
- * The registry, as a C~string, owned by the face.
- *
- * ordering ::
- * The ordering, as a C~string, owned by the face.
- *
- * supplement ::
- * The supplement.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * This function only works with CID faces, returning an error
- * otherwise.
- *
- * @since:
- * 2.3.6
- */
- FT_EXPORT( FT_Error )
- FT_Get_CID_Registry_Ordering_Supplement( FT_Face face,
- const char* *registry,
- const char* *ordering,
- FT_Int *supplement );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_CID_Is_Internally_CID_Keyed
- *
- * @description:
- * Retrieve the type of the input face, CID keyed or not. In contrast
- * to the @FT_IS_CID_KEYED macro this function returns successfully also
- * for CID-keyed fonts in an SFNT wrapper.
- *
- * @input:
- * face ::
- * A handle to the input face.
- *
- * @output:
- * is_cid ::
- * The type of the face as an @FT_Bool.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * This function only works with CID faces and OpenType fonts, returning
- * an error otherwise.
- *
- * @since:
- * 2.3.9
- */
- FT_EXPORT( FT_Error )
- FT_Get_CID_Is_Internally_CID_Keyed( FT_Face face,
- FT_Bool *is_cid );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_CID_From_Glyph_Index
- *
- * @description:
- * Retrieve the CID of the input glyph index.
- *
- * @input:
- * face ::
- * A handle to the input face.
- *
- * glyph_index ::
- * The input glyph index.
- *
- * @output:
- * cid ::
- * The CID as an @FT_UInt.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * This function only works with CID faces and OpenType fonts, returning
- * an error otherwise.
- *
- * @since:
- * 2.3.9
- */
- FT_EXPORT( FT_Error )
- FT_Get_CID_From_Glyph_Index( FT_Face face,
- FT_UInt glyph_index,
- FT_UInt *cid );
-
- /* */
-
-
-FT_END_HEADER
-
-#endif /* FTCID_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/ftcolor.h b/contrib/libs/freetype/include/freetype/ftcolor.h
deleted file mode 100644
index 420720ddf2..0000000000
--- a/contrib/libs/freetype/include/freetype/ftcolor.h
+++ /dev/null
@@ -1,1667 +0,0 @@
-/****************************************************************************
- *
- * ftcolor.h
- *
- * FreeType's glyph color management (specification).
- *
- * Copyright (C) 2018-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTCOLOR_H_
-#define FTCOLOR_H_
-
-#include <freetype/freetype.h>
-
-#ifdef FREETYPE_H
-#error "freetype.h of FreeType 1 has been loaded!"
-#error "Please fix the directory search order for header files"
-#error "so that freetype.h of FreeType 2 is found first."
-#endif
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @section:
- * color_management
- *
- * @title:
- * Glyph Color Management
- *
- * @abstract:
- * Retrieving and manipulating OpenType's 'CPAL' table data.
- *
- * @description:
- * The functions described here allow access and manipulation of color
- * palette entries in OpenType's 'CPAL' tables.
- */
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_Color
- *
- * @description:
- * This structure models a BGRA color value of a 'CPAL' palette entry.
- *
- * The used color space is sRGB; the colors are not pre-multiplied, and
- * alpha values must be explicitly set.
- *
- * @fields:
- * blue ::
- * Blue value.
- *
- * green ::
- * Green value.
- *
- * red ::
- * Red value.
- *
- * alpha ::
- * Alpha value, giving the red, green, and blue color's opacity.
- *
- * @since:
- * 2.10
- */
- typedef struct FT_Color_
- {
- FT_Byte blue;
- FT_Byte green;
- FT_Byte red;
- FT_Byte alpha;
-
- } FT_Color;
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_PALETTE_XXX
- *
- * @description:
- * A list of bit field constants used in the `palette_flags` array of the
- * @FT_Palette_Data structure to indicate for which background a palette
- * with a given index is usable.
- *
- * @values:
- * FT_PALETTE_FOR_LIGHT_BACKGROUND ::
- * The palette is appropriate to use when displaying the font on a
- * light background such as white.
- *
- * FT_PALETTE_FOR_DARK_BACKGROUND ::
- * The palette is appropriate to use when displaying the font on a dark
- * background such as black.
- *
- * @since:
- * 2.10
- */
-#define FT_PALETTE_FOR_LIGHT_BACKGROUND 0x01
-#define FT_PALETTE_FOR_DARK_BACKGROUND 0x02
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_Palette_Data
- *
- * @description:
- * This structure holds the data of the 'CPAL' table.
- *
- * @fields:
- * num_palettes ::
- * The number of palettes.
- *
- * palette_name_ids ::
- * An optional read-only array of palette name IDs with `num_palettes`
- * elements, corresponding to entries like 'dark' or 'light' in the
- * font's 'name' table.
- *
- * An empty name ID in the 'CPAL' table gets represented as value
- * 0xFFFF.
- *
- * `NULL` if the font's 'CPAL' table doesn't contain appropriate data.
- *
- * palette_flags ::
- * An optional read-only array of palette flags with `num_palettes`
- * elements. Possible values are an ORed combination of
- * @FT_PALETTE_FOR_LIGHT_BACKGROUND and
- * @FT_PALETTE_FOR_DARK_BACKGROUND.
- *
- * `NULL` if the font's 'CPAL' table doesn't contain appropriate data.
- *
- * num_palette_entries ::
- * The number of entries in a single palette. All palettes have the
- * same size.
- *
- * palette_entry_name_ids ::
- * An optional read-only array of palette entry name IDs with
- * `num_palette_entries`. In each palette, entries with the same index
- * have the same function. For example, index~0 might correspond to
- * string 'outline' in the font's 'name' table to indicate that this
- * palette entry is used for outlines, index~1 might correspond to
- * 'fill' to indicate the filling color palette entry, etc.
- *
- * An empty entry name ID in the 'CPAL' table gets represented as value
- * 0xFFFF.
- *
- * `NULL` if the font's 'CPAL' table doesn't contain appropriate data.
- *
- * @note:
- * Use function @FT_Get_Sfnt_Name to map name IDs and entry name IDs to
- * name strings.
- *
- * Use function @FT_Palette_Select to get the colors associated with a
- * palette entry.
- *
- * @since:
- * 2.10
- */
- typedef struct FT_Palette_Data_ {
- FT_UShort num_palettes;
- const FT_UShort* palette_name_ids;
- const FT_UShort* palette_flags;
-
- FT_UShort num_palette_entries;
- const FT_UShort* palette_entry_name_ids;
-
- } FT_Palette_Data;
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Palette_Data_Get
- *
- * @description:
- * Retrieve the face's color palette data.
- *
- * @input:
- * face ::
- * The source face handle.
- *
- * @output:
- * apalette ::
- * A pointer to an @FT_Palette_Data structure.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * All arrays in the returned @FT_Palette_Data structure are read-only.
- *
- * This function always returns an error if the config macro
- * `TT_CONFIG_OPTION_COLOR_LAYERS` is not defined in `ftoption.h`.
- *
- * @since:
- * 2.10
- */
- FT_EXPORT( FT_Error )
- FT_Palette_Data_Get( FT_Face face,
- FT_Palette_Data *apalette );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Palette_Select
- *
- * @description:
- * This function has two purposes.
- *
- * (1) It activates a palette for rendering color glyphs, and
- *
- * (2) it retrieves all (unmodified) color entries of this palette. This
- * function returns a read-write array, which means that a calling
- * application can modify the palette entries on demand.
- *
- * A corollary of (2) is that calling the function, then modifying some
- * values, then calling the function again with the same arguments resets
- * all color entries to the original 'CPAL' values; all user modifications
- * are lost.
- *
- * @input:
- * face ::
- * The source face handle.
- *
- * palette_index ::
- * The palette index.
- *
- * @output:
- * apalette ::
- * An array of color entries for a palette with index `palette_index`,
- * having `num_palette_entries` elements (as found in the
- * `FT_Palette_Data` structure). If `apalette` is set to `NULL`, no
- * array gets returned (and no color entries can be modified).
- *
- * In case the font doesn't support color palettes, `NULL` is returned.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * The array pointed to by `apalette_entries` is owned and managed by
- * FreeType.
- *
- * This function always returns an error if the config macro
- * `TT_CONFIG_OPTION_COLOR_LAYERS` is not defined in `ftoption.h`.
- *
- * @since:
- * 2.10
- */
- FT_EXPORT( FT_Error )
- FT_Palette_Select( FT_Face face,
- FT_UShort palette_index,
- FT_Color* *apalette );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Palette_Set_Foreground_Color
- *
- * @description:
- * 'COLR' uses palette index 0xFFFF to indicate a 'text foreground
- * color'. This function sets this value.
- *
- * @input:
- * face ::
- * The source face handle.
- *
- * foreground_color ::
- * An `FT_Color` structure to define the text foreground color.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * If this function isn't called, the text foreground color is set to
- * white opaque (BGRA value 0xFFFFFFFF) if
- * @FT_PALETTE_FOR_DARK_BACKGROUND is present for the current palette,
- * and black opaque (BGRA value 0x000000FF) otherwise, including the case
- * that no palette types are available in the 'CPAL' table.
- *
- * This function always returns an error if the config macro
- * `TT_CONFIG_OPTION_COLOR_LAYERS` is not defined in `ftoption.h`.
- *
- * @since:
- * 2.10
- */
- FT_EXPORT( FT_Error )
- FT_Palette_Set_Foreground_Color( FT_Face face,
- FT_Color foreground_color );
-
-
- /**************************************************************************
- *
- * @section:
- * layer_management
- *
- * @title:
- * Glyph Layer Management
- *
- * @abstract:
- * Retrieving and manipulating OpenType's 'COLR' table data.
- *
- * @description:
- * The functions described here allow access of colored glyph layer data
- * in OpenType's 'COLR' tables.
- */
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_LayerIterator
- *
- * @description:
- * This iterator object is needed for @FT_Get_Color_Glyph_Layer.
- *
- * @fields:
- * num_layers ::
- * The number of glyph layers for the requested glyph index. Will be
- * set by @FT_Get_Color_Glyph_Layer.
- *
- * layer ::
- * The current layer. Will be set by @FT_Get_Color_Glyph_Layer.
- *
- * p ::
- * An opaque pointer into 'COLR' table data. The caller must set this
- * to `NULL` before the first call of @FT_Get_Color_Glyph_Layer.
- */
- typedef struct FT_LayerIterator_
- {
- FT_UInt num_layers;
- FT_UInt layer;
- FT_Byte* p;
-
- } FT_LayerIterator;
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_Color_Glyph_Layer
- *
- * @description:
- * This is an interface to the 'COLR' table in OpenType fonts to
- * iteratively retrieve the colored glyph layers associated with the
- * current glyph slot.
- *
- * https://docs.microsoft.com/en-us/typography/opentype/spec/colr
- *
- * The glyph layer data for a given glyph index, if present, provides an
- * alternative, multi-color glyph representation: Instead of rendering
- * the outline or bitmap with the given glyph index, glyphs with the
- * indices and colors returned by this function are rendered layer by
- * layer.
- *
- * The returned elements are ordered in the z~direction from bottom to
- * top; the 'n'th element should be rendered with the associated palette
- * color and blended on top of the already rendered layers (elements 0,
- * 1, ..., n-1).
- *
- * @input:
- * face ::
- * A handle to the parent face object.
- *
- * base_glyph ::
- * The glyph index the colored glyph layers are associated with.
- *
- * @inout:
- * iterator ::
- * An @FT_LayerIterator object. For the first call you should set
- * `iterator->p` to `NULL`. For all following calls, simply use the
- * same object again.
- *
- * @output:
- * aglyph_index ::
- * The glyph index of the current layer.
- *
- * acolor_index ::
- * The color index into the font face's color palette of the current
- * layer. The value 0xFFFF is special; it doesn't reference a palette
- * entry but indicates that the text foreground color should be used
- * instead (to be set up by the application outside of FreeType).
- *
- * The color palette can be retrieved with @FT_Palette_Select.
- *
- * @return:
- * Value~1 if everything is OK. If there are no more layers (or if there
- * are no layers at all), value~0 gets returned. In case of an error,
- * value~0 is returned also.
- *
- * @note:
- * This function is necessary if you want to handle glyph layers by
- * yourself. In particular, functions that operate with @FT_GlyphRec
- * objects (like @FT_Get_Glyph or @FT_Glyph_To_Bitmap) don't have access
- * to this information.
- *
- * Note that @FT_Render_Glyph is able to handle colored glyph layers
- * automatically if the @FT_LOAD_COLOR flag is passed to a previous call
- * to @FT_Load_Glyph. [This is an experimental feature.]
- *
- * @example:
- * ```
- * FT_Color* palette;
- * FT_LayerIterator iterator;
- *
- * FT_Bool have_layers;
- * FT_UInt layer_glyph_index;
- * FT_UInt layer_color_index;
- *
- *
- * error = FT_Palette_Select( face, palette_index, &palette );
- * if ( error )
- * palette = NULL;
- *
- * iterator.p = NULL;
- * have_layers = FT_Get_Color_Glyph_Layer( face,
- * glyph_index,
- * &layer_glyph_index,
- * &layer_color_index,
- * &iterator );
- *
- * if ( palette && have_layers )
- * {
- * do
- * {
- * FT_Color layer_color;
- *
- *
- * if ( layer_color_index == 0xFFFF )
- * layer_color = text_foreground_color;
- * else
- * layer_color = palette[layer_color_index];
- *
- * // Load and render glyph `layer_glyph_index', then
- * // blend resulting pixmap (using color `layer_color')
- * // with previously created pixmaps.
- *
- * } while ( FT_Get_Color_Glyph_Layer( face,
- * glyph_index,
- * &layer_glyph_index,
- * &layer_color_index,
- * &iterator ) );
- * }
- * ```
- *
- * @since:
- * 2.10
- */
- FT_EXPORT( FT_Bool )
- FT_Get_Color_Glyph_Layer( FT_Face face,
- FT_UInt base_glyph,
- FT_UInt *aglyph_index,
- FT_UInt *acolor_index,
- FT_LayerIterator* iterator );
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_PaintFormat
- *
- * @description:
- * Enumeration describing the different paint format types of the v1
- * extensions to the 'COLR' table, see
- * 'https://github.com/googlefonts/colr-gradients-spec'.
- *
- * The enumeration values loosely correspond with the format numbers of
- * the specification: FreeType always returns a fully specified 'Paint'
- * structure for the 'Transform', 'Translate', 'Scale', 'Rotate', and
- * 'Skew' table types even though the specification has different formats
- * depending on whether or not a center is specified, whether the scale
- * is uniform in x and y~direction or not, etc. Also, only non-variable
- * format identifiers are listed in this enumeration; as soon as support
- * for variable 'COLR' v1 fonts is implemented, interpolation is
- * performed dependent on axis coordinates, which are configured on the
- * @FT_Face through @FT_Set_Var_Design_Coordinates. This implies that
- * always static, readily interpolated values are returned in the 'Paint'
- * structures.
- *
- * @since:
- * 2.13
- */
- typedef enum FT_PaintFormat_
- {
- FT_COLR_PAINTFORMAT_COLR_LAYERS = 1,
- FT_COLR_PAINTFORMAT_SOLID = 2,
- FT_COLR_PAINTFORMAT_LINEAR_GRADIENT = 4,
- FT_COLR_PAINTFORMAT_RADIAL_GRADIENT = 6,
- FT_COLR_PAINTFORMAT_SWEEP_GRADIENT = 8,
- FT_COLR_PAINTFORMAT_GLYPH = 10,
- FT_COLR_PAINTFORMAT_COLR_GLYPH = 11,
- FT_COLR_PAINTFORMAT_TRANSFORM = 12,
- FT_COLR_PAINTFORMAT_TRANSLATE = 14,
- FT_COLR_PAINTFORMAT_SCALE = 16,
- FT_COLR_PAINTFORMAT_ROTATE = 24,
- FT_COLR_PAINTFORMAT_SKEW = 28,
- FT_COLR_PAINTFORMAT_COMPOSITE = 32,
- FT_COLR_PAINT_FORMAT_MAX = 33,
- FT_COLR_PAINTFORMAT_UNSUPPORTED = 255
-
- } FT_PaintFormat;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_ColorStopIterator
- *
- * @description:
- * This iterator object is needed for @FT_Get_Colorline_Stops. It keeps
- * state while iterating over the stops of an @FT_ColorLine, representing
- * the `ColorLine` struct of the v1 extensions to 'COLR', see
- * 'https://github.com/googlefonts/colr-gradients-spec'. Do not manually
- * modify fields of this iterator.
- *
- * @fields:
- * num_color_stops ::
- * The number of color stops for the requested glyph index. Set by
- * @FT_Get_Paint.
- *
- * current_color_stop ::
- * The current color stop. Set by @FT_Get_Colorline_Stops.
- *
- * p ::
- * An opaque pointer into 'COLR' table data. Set by @FT_Get_Paint.
- * Updated by @FT_Get_Colorline_Stops.
- *
- * read_variable ::
- * A boolean keeping track of whether variable color lines are to be
- * read. Set by @FT_Get_Paint.
- *
- * @since:
- * 2.13
- */
- typedef struct FT_ColorStopIterator_
- {
- FT_UInt num_color_stops;
- FT_UInt current_color_stop;
-
- FT_Byte* p;
-
- FT_Bool read_variable;
-
- } FT_ColorStopIterator;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_ColorIndex
- *
- * @description:
- * A structure representing a `ColorIndex` value of the 'COLR' v1
- * extensions, see 'https://github.com/googlefonts/colr-gradients-spec'.
- *
- * @fields:
- * palette_index ::
- * The palette index into a 'CPAL' palette.
- *
- * alpha ::
- * Alpha transparency value multiplied with the value from 'CPAL'.
- *
- * @since:
- * 2.13
- */
- typedef struct FT_ColorIndex_
- {
- FT_UInt16 palette_index;
- FT_F2Dot14 alpha;
-
- } FT_ColorIndex;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_ColorStop
- *
- * @description:
- * A structure representing a `ColorStop` value of the 'COLR' v1
- * extensions, see 'https://github.com/googlefonts/colr-gradients-spec'.
- *
- * @fields:
- * stop_offset ::
- * The stop offset along the gradient, expressed as a 16.16 fixed-point
- * coordinate.
- *
- * color ::
- * The color information for this stop, see @FT_ColorIndex.
- *
- * @since:
- * 2.13
- */
- typedef struct FT_ColorStop_
- {
- FT_Fixed stop_offset;
- FT_ColorIndex color;
-
- } FT_ColorStop;
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_PaintExtend
- *
- * @description:
- * An enumeration representing the 'Extend' mode of the 'COLR' v1
- * extensions, see 'https://github.com/googlefonts/colr-gradients-spec'.
- * It describes how the gradient fill continues at the other boundaries.
- *
- * @since:
- * 2.13
- */
- typedef enum FT_PaintExtend_
- {
- FT_COLR_PAINT_EXTEND_PAD = 0,
- FT_COLR_PAINT_EXTEND_REPEAT = 1,
- FT_COLR_PAINT_EXTEND_REFLECT = 2
-
- } FT_PaintExtend;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_ColorLine
- *
- * @description:
- * A structure representing a `ColorLine` value of the 'COLR' v1
- * extensions, see 'https://github.com/googlefonts/colr-gradients-spec'.
- * It describes a list of color stops along the defined gradient.
- *
- * @fields:
- * extend ::
- * The extend mode at the outer boundaries, see @FT_PaintExtend.
- *
- * color_stop_iterator ::
- * The @FT_ColorStopIterator used to enumerate and retrieve the
- * actual @FT_ColorStop's.
- *
- * @since:
- * 2.13
- */
- typedef struct FT_ColorLine_
- {
- FT_PaintExtend extend;
- FT_ColorStopIterator color_stop_iterator;
-
- } FT_ColorLine;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_Affine23
- *
- * @description:
- * A structure used to store a 2x3 matrix. Coefficients are in
- * 16.16 fixed-point format. The computation performed is
- *
- * ```
- * x' = x*xx + y*xy + dx
- * y' = x*yx + y*yy + dy
- * ```
- *
- * @fields:
- * xx ::
- * Matrix coefficient.
- *
- * xy ::
- * Matrix coefficient.
- *
- * dx ::
- * x translation.
- *
- * yx ::
- * Matrix coefficient.
- *
- * yy ::
- * Matrix coefficient.
- *
- * dy ::
- * y translation.
- *
- * @since:
- * 2.13
- */
- typedef struct FT_Affine_23_
- {
- FT_Fixed xx, xy, dx;
- FT_Fixed yx, yy, dy;
-
- } FT_Affine23;
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_Composite_Mode
- *
- * @description:
- * An enumeration listing the 'COLR' v1 composite modes used in
- * @FT_PaintComposite. For more details on each paint mode, see
- * 'https://www.w3.org/TR/compositing-1/#porterduffcompositingoperators'.
- *
- * @since:
- * 2.13
- */
- typedef enum FT_Composite_Mode_
- {
- FT_COLR_COMPOSITE_CLEAR = 0,
- FT_COLR_COMPOSITE_SRC = 1,
- FT_COLR_COMPOSITE_DEST = 2,
- FT_COLR_COMPOSITE_SRC_OVER = 3,
- FT_COLR_COMPOSITE_DEST_OVER = 4,
- FT_COLR_COMPOSITE_SRC_IN = 5,
- FT_COLR_COMPOSITE_DEST_IN = 6,
- FT_COLR_COMPOSITE_SRC_OUT = 7,
- FT_COLR_COMPOSITE_DEST_OUT = 8,
- FT_COLR_COMPOSITE_SRC_ATOP = 9,
- FT_COLR_COMPOSITE_DEST_ATOP = 10,
- FT_COLR_COMPOSITE_XOR = 11,
- FT_COLR_COMPOSITE_PLUS = 12,
- FT_COLR_COMPOSITE_SCREEN = 13,
- FT_COLR_COMPOSITE_OVERLAY = 14,
- FT_COLR_COMPOSITE_DARKEN = 15,
- FT_COLR_COMPOSITE_LIGHTEN = 16,
- FT_COLR_COMPOSITE_COLOR_DODGE = 17,
- FT_COLR_COMPOSITE_COLOR_BURN = 18,
- FT_COLR_COMPOSITE_HARD_LIGHT = 19,
- FT_COLR_COMPOSITE_SOFT_LIGHT = 20,
- FT_COLR_COMPOSITE_DIFFERENCE = 21,
- FT_COLR_COMPOSITE_EXCLUSION = 22,
- FT_COLR_COMPOSITE_MULTIPLY = 23,
- FT_COLR_COMPOSITE_HSL_HUE = 24,
- FT_COLR_COMPOSITE_HSL_SATURATION = 25,
- FT_COLR_COMPOSITE_HSL_COLOR = 26,
- FT_COLR_COMPOSITE_HSL_LUMINOSITY = 27,
- FT_COLR_COMPOSITE_MAX = 28
-
- } FT_Composite_Mode;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_OpaquePaint
- *
- * @description:
- * A structure representing an offset to a `Paint` value stored in any
- * of the paint tables of a 'COLR' v1 font. Compare Offset<24> there.
- * When 'COLR' v1 paint tables represented by FreeType objects such as
- * @FT_PaintColrLayers, @FT_PaintComposite, or @FT_PaintTransform
- * reference downstream nested paint tables, we do not immediately
- * retrieve them but encapsulate their location in this type. Use
- * @FT_Get_Paint to retrieve the actual @FT_COLR_Paint object that
- * describes the details of the respective paint table.
- *
- * @fields:
- * p ::
- * An internal offset to a Paint table, needs to be set to NULL before
- * passing this struct as an argument to @FT_Get_Paint.
- *
- * insert_root_transform ::
- * An internal boolean to track whether an initial root transform is
- * to be provided. Do not set this value.
- *
- * @since:
- * 2.13
- */
- typedef struct FT_Opaque_Paint_
- {
- FT_Byte* p;
- FT_Bool insert_root_transform;
- } FT_OpaquePaint;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_PaintColrLayers
- *
- * @description:
- * A structure representing a `PaintColrLayers` table of a 'COLR' v1
- * font. This table describes a set of layers that are to be composited
- * with composite mode `FT_COLR_COMPOSITE_SRC_OVER`. The return value
- * of this function is an @FT_LayerIterator initialized so that it can
- * be used with @FT_Get_Paint_Layers to retrieve the @FT_OpaquePaint
- * objects as references to each layer.
- *
- * @fields:
- * layer_iterator ::
- * The layer iterator that describes the layers of this paint.
- *
- * @since:
- * 2.13
- */
- typedef struct FT_PaintColrLayers_
- {
- FT_LayerIterator layer_iterator;
-
- } FT_PaintColrLayers;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_PaintSolid
- *
- * @description:
- * A structure representing a `PaintSolid` value of the 'COLR' v1
- * extensions, see 'https://github.com/googlefonts/colr-gradients-spec'.
- * Using a `PaintSolid` value means that the glyph layer filled with
- * this paint is solid-colored and does not contain a gradient.
- *
- * @fields:
- * color ::
- * The color information for this solid paint, see @FT_ColorIndex.
- *
- * @since:
- * 2.13
- */
- typedef struct FT_PaintSolid_
- {
- FT_ColorIndex color;
-
- } FT_PaintSolid;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_PaintLinearGradient
- *
- * @description:
- * A structure representing a `PaintLinearGradient` value of the 'COLR'
- * v1 extensions, see
- * 'https://github.com/googlefonts/colr-gradients-spec'. The glyph
- * layer filled with this paint is drawn filled with a linear gradient.
- *
- * @fields:
- * colorline ::
- * The @FT_ColorLine information for this paint, i.e., the list of
- * color stops along the gradient.
- *
- * p0 ::
- * The starting point of the gradient definition in font units
- * represented as a 16.16 fixed-point `FT_Vector`.
- *
- * p1 ::
- * The end point of the gradient definition in font units
- * represented as a 16.16 fixed-point `FT_Vector`.
- *
- * p2 ::
- * Optional point~p2 to rotate the gradient in font units
- * represented as a 16.16 fixed-point `FT_Vector`.
- * Otherwise equal to~p0.
- *
- * @since:
- * 2.13
- */
- typedef struct FT_PaintLinearGradient_
- {
- FT_ColorLine colorline;
-
- /* TODO: Potentially expose those as x0, y0 etc. */
- FT_Vector p0;
- FT_Vector p1;
- FT_Vector p2;
-
- } FT_PaintLinearGradient;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_PaintRadialGradient
- *
- * @description:
- * A structure representing a `PaintRadialGradient` value of the 'COLR'
- * v1 extensions, see
- * 'https://github.com/googlefonts/colr-gradients-spec'. The glyph
- * layer filled with this paint is drawn filled with a radial gradient.
- *
- * @fields:
- * colorline ::
- * The @FT_ColorLine information for this paint, i.e., the list of
- * color stops along the gradient.
- *
- * c0 ::
- * The center of the starting point of the radial gradient in font
- * units represented as a 16.16 fixed-point `FT_Vector`.
- *
- * r0 ::
- * The radius of the starting circle of the radial gradient in font
- * units represented as a 16.16 fixed-point value.
- *
- * c1 ::
- * The center of the end point of the radial gradient in font units
- * represented as a 16.16 fixed-point `FT_Vector`.
- *
- * r1 ::
- * The radius of the end circle of the radial gradient in font
- * units represented as a 16.16 fixed-point value.
- *
- * @since:
- * 2.13
- */
- typedef struct FT_PaintRadialGradient_
- {
- FT_ColorLine colorline;
-
- FT_Vector c0;
- FT_Pos r0;
- FT_Vector c1;
- FT_Pos r1;
-
- } FT_PaintRadialGradient;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_PaintSweepGradient
- *
- * @description:
- * A structure representing a `PaintSweepGradient` value of the 'COLR'
- * v1 extensions, see
- * 'https://github.com/googlefonts/colr-gradients-spec'. The glyph
- * layer filled with this paint is drawn filled with a sweep gradient
- * from `start_angle` to `end_angle`.
- *
- * @fields:
- * colorline ::
- * The @FT_ColorLine information for this paint, i.e., the list of
- * color stops along the gradient.
- *
- * center ::
- * The center of the sweep gradient in font units represented as a
- * vector of 16.16 fixed-point values.
- *
- * start_angle ::
- * The start angle of the sweep gradient in 16.16 fixed-point
- * format specifying degrees divided by 180.0 (as in the
- * spec). Multiply by 180.0f to receive degrees value. Values are
- * given counter-clockwise, starting from the (positive) y~axis.
- *
- * end_angle ::
- * The end angle of the sweep gradient in 16.16 fixed-point
- * format specifying degrees divided by 180.0 (as in the
- * spec). Multiply by 180.0f to receive degrees value. Values are
- * given counter-clockwise, starting from the (positive) y~axis.
- *
- * @since:
- * 2.13
- */
- typedef struct FT_PaintSweepGradient_
- {
- FT_ColorLine colorline;
-
- FT_Vector center;
- FT_Fixed start_angle;
- FT_Fixed end_angle;
-
- } FT_PaintSweepGradient;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_PaintGlyph
- *
- * @description:
- * A structure representing a 'COLR' v1 `PaintGlyph` paint table.
- *
- * @fields:
- * paint ::
- * An opaque paint object pointing to a `Paint` table that serves as
- * the fill for the glyph ID.
- *
- * glyphID ::
- * The glyph ID from the 'glyf' table, which serves as the contour
- * information that is filled with paint.
- *
- * @since:
- * 2.13
- */
- typedef struct FT_PaintGlyph_
- {
- FT_OpaquePaint paint;
- FT_UInt glyphID;
-
- } FT_PaintGlyph;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_PaintColrGlyph
- *
- * @description:
- * A structure representing a 'COLR' v1 `PaintColorGlyph` paint table.
- *
- * @fields:
- * glyphID ::
- * The glyph ID from the `BaseGlyphV1List` table that is drawn for
- * this paint.
- *
- * @since:
- * 2.13
- */
- typedef struct FT_PaintColrGlyph_
- {
- FT_UInt glyphID;
-
- } FT_PaintColrGlyph;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_PaintTransform
- *
- * @description:
- * A structure representing a 'COLR' v1 `PaintTransform` paint table.
- *
- * @fields:
- * paint ::
- * An opaque paint that is subject to being transformed.
- *
- * affine ::
- * A 2x3 transformation matrix in @FT_Affine23 format containing
- * 16.16 fixed-point values.
- *
- * @since:
- * 2.13
- */
- typedef struct FT_PaintTransform_
- {
- FT_OpaquePaint paint;
- FT_Affine23 affine;
-
- } FT_PaintTransform;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_PaintTranslate
- *
- * @description:
- * A structure representing a 'COLR' v1 `PaintTranslate` paint table.
- * Used for translating downstream paints by a given x and y~delta.
- *
- * @fields:
- * paint ::
- * An @FT_OpaquePaint object referencing the paint that is to be
- * rotated.
- *
- * dx ::
- * Translation in x~direction in font units represented as a
- * 16.16 fixed-point value.
- *
- * dy ::
- * Translation in y~direction in font units represented as a
- * 16.16 fixed-point value.
- *
- * @since:
- * 2.13
- */
- typedef struct FT_PaintTranslate_
- {
- FT_OpaquePaint paint;
-
- FT_Fixed dx;
- FT_Fixed dy;
-
- } FT_PaintTranslate;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_PaintScale
- *
- * @description:
- * A structure representing all of the 'COLR' v1 'PaintScale*' paint
- * tables. Used for scaling downstream paints by a given x and y~scale,
- * with a given center. This structure is used for all 'PaintScale*'
- * types that are part of specification; fields of this structure are
- * filled accordingly. If there is a center, the center values are set,
- * otherwise they are set to the zero coordinate. If the source font
- * file has 'PaintScaleUniform*' set, the scale values are set
- * accordingly to the same value.
- *
- * @fields:
- * paint ::
- * An @FT_OpaquePaint object referencing the paint that is to be
- * scaled.
- *
- * scale_x ::
- * Scale factor in x~direction represented as a
- * 16.16 fixed-point value.
- *
- * scale_y ::
- * Scale factor in y~direction represented as a
- * 16.16 fixed-point value.
- *
- * center_x ::
- * x~coordinate of center point to scale from represented as a
- * 16.16 fixed-point value.
- *
- * center_y ::
- * y~coordinate of center point to scale from represented as a
- * 16.16 fixed-point value.
- *
- * @since:
- * 2.13
- */
- typedef struct FT_PaintScale_
- {
- FT_OpaquePaint paint;
-
- FT_Fixed scale_x;
- FT_Fixed scale_y;
-
- FT_Fixed center_x;
- FT_Fixed center_y;
-
- } FT_PaintScale;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_PaintRotate
- *
- * @description:
- * A structure representing a 'COLR' v1 `PaintRotate` paint table. Used
- * for rotating downstream paints with a given center and angle.
- *
- * @fields:
- * paint ::
- * An @FT_OpaquePaint object referencing the paint that is to be
- * rotated.
- *
- * angle ::
- * The rotation angle that is to be applied in degrees divided by
- * 180.0 (as in the spec) represented as a 16.16 fixed-point
- * value. Multiply by 180.0f to receive degrees value.
- *
- * center_x ::
- * The x~coordinate of the pivot point of the rotation in font
- * units represented as a 16.16 fixed-point value.
- *
- * center_y ::
- * The y~coordinate of the pivot point of the rotation in font
- * units represented as a 16.16 fixed-point value.
- *
- * @since:
- * 2.13
- */
-
- typedef struct FT_PaintRotate_
- {
- FT_OpaquePaint paint;
-
- FT_Fixed angle;
-
- FT_Fixed center_x;
- FT_Fixed center_y;
-
- } FT_PaintRotate;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_PaintSkew
- *
- * @description:
- * A structure representing a 'COLR' v1 `PaintSkew` paint table. Used
- * for skewing or shearing downstream paints by a given center and
- * angle.
- *
- * @fields:
- * paint ::
- * An @FT_OpaquePaint object referencing the paint that is to be
- * skewed.
- *
- * x_skew_angle ::
- * The skewing angle in x~direction in degrees divided by 180.0
- * (as in the spec) represented as a 16.16 fixed-point
- * value. Multiply by 180.0f to receive degrees.
- *
- * y_skew_angle ::
- * The skewing angle in y~direction in degrees divided by 180.0
- * (as in the spec) represented as a 16.16 fixed-point
- * value. Multiply by 180.0f to receive degrees.
- *
- * center_x ::
- * The x~coordinate of the pivot point of the skew in font units
- * represented as a 16.16 fixed-point value.
- *
- * center_y ::
- * The y~coordinate of the pivot point of the skew in font units
- * represented as a 16.16 fixed-point value.
- *
- * @since:
- * 2.13
- */
- typedef struct FT_PaintSkew_
- {
- FT_OpaquePaint paint;
-
- FT_Fixed x_skew_angle;
- FT_Fixed y_skew_angle;
-
- FT_Fixed center_x;
- FT_Fixed center_y;
-
- } FT_PaintSkew;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_PaintComposite
- *
- * @description:
- * A structure representing a 'COLR' v1 `PaintComposite` paint table.
- * Used for compositing two paints in a 'COLR' v1 directed acyclic graph.
- *
- * @fields:
- * source_paint ::
- * An @FT_OpaquePaint object referencing the source that is to be
- * composited.
- *
- * composite_mode ::
- * An @FT_Composite_Mode enum value determining the composition
- * operation.
- *
- * backdrop_paint ::
- * An @FT_OpaquePaint object referencing the backdrop paint that
- * `source_paint` is composited onto.
- *
- * @since:
- * 2.13
- */
- typedef struct FT_PaintComposite_
- {
- FT_OpaquePaint source_paint;
- FT_Composite_Mode composite_mode;
- FT_OpaquePaint backdrop_paint;
-
- } FT_PaintComposite;
-
-
- /**************************************************************************
- *
- * @union:
- * FT_COLR_Paint
- *
- * @description:
- * A union object representing format and details of a paint table of a
- * 'COLR' v1 font, see
- * 'https://github.com/googlefonts/colr-gradients-spec'. Use
- * @FT_Get_Paint to retrieve a @FT_COLR_Paint for an @FT_OpaquePaint
- * object.
- *
- * @fields:
- * format ::
- * The gradient format for this Paint structure.
- *
- * u ::
- * Union of all paint table types:
- *
- * * @FT_PaintColrLayers
- * * @FT_PaintGlyph
- * * @FT_PaintSolid
- * * @FT_PaintLinearGradient
- * * @FT_PaintRadialGradient
- * * @FT_PaintSweepGradient
- * * @FT_PaintTransform
- * * @FT_PaintTranslate
- * * @FT_PaintRotate
- * * @FT_PaintSkew
- * * @FT_PaintComposite
- * * @FT_PaintColrGlyph
- *
- * @since:
- * 2.13
- */
- typedef struct FT_COLR_Paint_
- {
- FT_PaintFormat format;
-
- union
- {
- FT_PaintColrLayers colr_layers;
- FT_PaintGlyph glyph;
- FT_PaintSolid solid;
- FT_PaintLinearGradient linear_gradient;
- FT_PaintRadialGradient radial_gradient;
- FT_PaintSweepGradient sweep_gradient;
- FT_PaintTransform transform;
- FT_PaintTranslate translate;
- FT_PaintScale scale;
- FT_PaintRotate rotate;
- FT_PaintSkew skew;
- FT_PaintComposite composite;
- FT_PaintColrGlyph colr_glyph;
-
- } u;
-
- } FT_COLR_Paint;
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_Color_Root_Transform
- *
- * @description:
- * An enumeration to specify whether @FT_Get_Color_Glyph_Paint is to
- * return a root transform to configure the client's graphics context
- * matrix.
- *
- * @values:
- * FT_COLOR_INCLUDE_ROOT_TRANSFORM ::
- * Do include the root transform as the initial @FT_COLR_Paint object.
- *
- * FT_COLOR_NO_ROOT_TRANSFORM ::
- * Do not output an initial root transform.
- *
- * @since:
- * 2.13
- */
- typedef enum FT_Color_Root_Transform_
- {
- FT_COLOR_INCLUDE_ROOT_TRANSFORM,
- FT_COLOR_NO_ROOT_TRANSFORM,
-
- FT_COLOR_ROOT_TRANSFORM_MAX
-
- } FT_Color_Root_Transform;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_ClipBox
- *
- * @description:
- * A structure representing a 'COLR' v1 'ClipBox' table. 'COLR' v1
- * glyphs may optionally define a clip box for aiding allocation or
- * defining a maximum drawable region. Use @FT_Get_Color_Glyph_ClipBox
- * to retrieve it.
- *
- * @fields:
- * bottom_left ::
- * The bottom left corner of the clip box as an @FT_Vector with
- * fixed-point coordinates in 26.6 format.
- *
- * top_left ::
- * The top left corner of the clip box as an @FT_Vector with
- * fixed-point coordinates in 26.6 format.
- *
- * top_right ::
- * The top right corner of the clip box as an @FT_Vector with
- * fixed-point coordinates in 26.6 format.
- *
- * bottom_right ::
- * The bottom right corner of the clip box as an @FT_Vector with
- * fixed-point coordinates in 26.6 format.
- *
- * @since:
- * 2.13
- */
- typedef struct FT_ClipBox_
- {
- FT_Vector bottom_left;
- FT_Vector top_left;
- FT_Vector top_right;
- FT_Vector bottom_right;
-
- } FT_ClipBox;
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_Color_Glyph_Paint
- *
- * @description:
- * This is the starting point and interface to color gradient
- * information in a 'COLR' v1 table in OpenType fonts to recursively
- * retrieve the paint tables for the directed acyclic graph of a colored
- * glyph, given a glyph ID.
- *
- * https://github.com/googlefonts/colr-gradients-spec
- *
- * In a 'COLR' v1 font, each color glyph defines a directed acyclic
- * graph of nested paint tables, such as `PaintGlyph`, `PaintSolid`,
- * `PaintLinearGradient`, `PaintRadialGradient`, and so on. Using this
- * function and specifying a glyph ID, one retrieves the root paint
- * table for this glyph ID.
- *
- * This function allows control whether an initial root transform is
- * returned to configure scaling, transform, and translation correctly
- * on the client's graphics context. The initial root transform is
- * computed and returned according to the values configured for @FT_Size
- * and @FT_Set_Transform on the @FT_Face object, see below for details
- * of the `root_transform` parameter. This has implications for a
- * client 'COLR' v1 implementation: When this function returns an
- * initially computed root transform, at the time of executing the
- * @FT_PaintGlyph operation, the contours should be retrieved using
- * @FT_Load_Glyph at unscaled, untransformed size. This is because the
- * root transform applied to the graphics context will take care of
- * correct scaling.
- *
- * Alternatively, to allow hinting of contours, at the time of executing
- * @FT_Load_Glyph, the current graphics context transformation matrix
- * can be decomposed into a scaling matrix and a remainder, and
- * @FT_Load_Glyph can be used to retrieve the contours at scaled size.
- * Care must then be taken to blit or clip to the graphics context with
- * taking this remainder transformation into account.
- *
- * @input:
- * face ::
- * A handle to the parent face object.
- *
- * base_glyph ::
- * The glyph index for which to retrieve the root paint table.
- *
- * root_transform ::
- * Specifies whether an initially computed root is returned by the
- * @FT_PaintTransform operation to account for the activated size
- * (see @FT_Activate_Size) and the configured transform and translate
- * (see @FT_Set_Transform).
- *
- * This root transform is returned before nodes of the glyph graph of
- * the font are returned. Subsequent @FT_COLR_Paint structures
- * contain unscaled and untransformed values. The inserted root
- * transform enables the client application to apply an initial
- * transform to its graphics context. When executing subsequent
- * FT_COLR_Paint operations, values from @FT_COLR_Paint operations
- * will ultimately be correctly scaled because of the root transform
- * applied to the graphics context. Use
- * @FT_COLOR_INCLUDE_ROOT_TRANSFORM to include the root transform, use
- * @FT_COLOR_NO_ROOT_TRANSFORM to not include it. The latter may be
- * useful when traversing the 'COLR' v1 glyph graph and reaching a
- * @FT_PaintColrGlyph. When recursing into @FT_PaintColrGlyph and
- * painting that inline, no additional root transform is needed as it
- * has already been applied to the graphics context at the beginning
- * of drawing this glyph.
- *
- * @output:
- * paint ::
- * The @FT_OpaquePaint object that references the actual paint table.
- *
- * The respective actual @FT_COLR_Paint object is retrieved via
- * @FT_Get_Paint.
- *
- * @return:
- * Value~1 if everything is OK. If no color glyph is found, or the root
- * paint could not be retrieved, value~0 gets returned. In case of an
- * error, value~0 is returned also.
- *
- * @since:
- * 2.13
- */
- FT_EXPORT( FT_Bool )
- FT_Get_Color_Glyph_Paint( FT_Face face,
- FT_UInt base_glyph,
- FT_Color_Root_Transform root_transform,
- FT_OpaquePaint* paint );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_Color_Glyph_ClipBox
- *
- * @description:
- * Search for a 'COLR' v1 clip box for the specified `base_glyph` and
- * fill the `clip_box` parameter with the 'COLR' v1 'ClipBox' information
- * if one is found.
- *
- * @input:
- * face ::
- * A handle to the parent face object.
- *
- * base_glyph ::
- * The glyph index for which to retrieve the clip box.
- *
- * @output:
- * clip_box ::
- * The clip box for the requested `base_glyph` if one is found. The
- * clip box is computed taking scale and transformations configured on
- * the @FT_Face into account. @FT_ClipBox contains @FT_Vector values
- * in 26.6 format.
- *
- * @return:
- * Value~1 if a clip box is found. If no clip box is found or an error
- * occured, value~0 is returned.
- *
- * @note:
- * To retrieve the clip box in font units, reset scale to units-per-em
- * and remove transforms configured using @FT_Set_Transform.
- *
- * @since:
- * 2.13
- */
- FT_EXPORT( FT_Bool )
- FT_Get_Color_Glyph_ClipBox( FT_Face face,
- FT_UInt base_glyph,
- FT_ClipBox* clip_box );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_Paint_Layers
- *
- * @description:
- * Access the layers of a `PaintColrLayers` table.
- *
- * If the root paint of a color glyph, or a nested paint of a 'COLR'
- * glyph is a `PaintColrLayers` table, this function retrieves the
- * layers of the `PaintColrLayers` table.
- *
- * The @FT_PaintColrLayers object contains an @FT_LayerIterator, which
- * is used here to iterate over the layers. Each layer is returned as
- * an @FT_OpaquePaint object, which then can be used with @FT_Get_Paint
- * to retrieve the actual paint object.
- *
- * @input:
- * face ::
- * A handle to the parent face object.
- *
- * @inout:
- * iterator ::
- * The @FT_LayerIterator from an @FT_PaintColrLayers object, for which
- * the layers are to be retrieved. The internal state of the iterator
- * is incremented after one call to this function for retrieving one
- * layer.
- *
- * @output:
- * paint ::
- * The @FT_OpaquePaint object that references the actual paint table.
- * The respective actual @FT_COLR_Paint object is retrieved via
- * @FT_Get_Paint.
- *
- * @return:
- * Value~1 if everything is OK. Value~0 gets returned when the paint
- * object can not be retrieved or any other error occurs.
- *
- * @since:
- * 2.13
- */
- FT_EXPORT( FT_Bool )
- FT_Get_Paint_Layers( FT_Face face,
- FT_LayerIterator* iterator,
- FT_OpaquePaint* paint );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_Colorline_Stops
- *
- * @description:
- * This is an interface to color gradient information in a 'COLR' v1
- * table in OpenType fonts to iteratively retrieve the gradient and
- * solid fill information for colored glyph layers for a specified glyph
- * ID.
- *
- * https://github.com/googlefonts/colr-gradients-spec
- *
- * @input:
- * face ::
- * A handle to the parent face object.
- *
- * @inout:
- * iterator ::
- * The retrieved @FT_ColorStopIterator, configured on an @FT_ColorLine,
- * which in turn got retrieved via paint information in
- * @FT_PaintLinearGradient or @FT_PaintRadialGradient.
- *
- * @output:
- * color_stop ::
- * Color index and alpha value for the retrieved color stop.
- *
- * @return:
- * Value~1 if everything is OK. If there are no more color stops,
- * value~0 gets returned. In case of an error, value~0 is returned
- * also.
- *
- * @since:
- * 2.13
- */
- FT_EXPORT( FT_Bool )
- FT_Get_Colorline_Stops( FT_Face face,
- FT_ColorStop* color_stop,
- FT_ColorStopIterator* iterator );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_Paint
- *
- * @description:
- * Access the details of a paint using an @FT_OpaquePaint opaque paint
- * object, which internally stores the offset to the respective `Paint`
- * object in the 'COLR' table.
- *
- * @input:
- * face ::
- * A handle to the parent face object.
- *
- * opaque_paint ::
- * The opaque paint object for which the underlying @FT_COLR_Paint
- * data is to be retrieved.
- *
- * @output:
- * paint ::
- * The specific @FT_COLR_Paint object containing information coming
- * from one of the font's `Paint*` tables.
- *
- * @return:
- * Value~1 if everything is OK. Value~0 if no details can be found for
- * this paint or any other error occured.
- *
- * @since:
- * 2.13
- */
- FT_EXPORT( FT_Bool )
- FT_Get_Paint( FT_Face face,
- FT_OpaquePaint opaque_paint,
- FT_COLR_Paint* paint );
-
- /* */
-
-
-FT_END_HEADER
-
-#endif /* FTCOLOR_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/ftdriver.h b/contrib/libs/freetype/include/freetype/ftdriver.h
deleted file mode 100644
index 1b7f539f5e..0000000000
--- a/contrib/libs/freetype/include/freetype/ftdriver.h
+++ /dev/null
@@ -1,1320 +0,0 @@
-/****************************************************************************
- *
- * ftdriver.h
- *
- * FreeType API for controlling driver modules (specification only).
- *
- * Copyright (C) 2017-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTDRIVER_H_
-#define FTDRIVER_H_
-
-#include <freetype/freetype.h>
-#include <freetype/ftparams.h>
-
-#ifdef FREETYPE_H
-#error "freetype.h of FreeType 1 has been loaded!"
-#error "Please fix the directory search order for header files"
-#error "so that freetype.h of FreeType 2 is found first."
-#endif
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @section:
- * auto_hinter
- *
- * @title:
- * The auto-hinter
- *
- * @abstract:
- * Controlling the auto-hinting module.
- *
- * @description:
- * While FreeType's auto-hinter doesn't expose API functions by itself,
- * it is possible to control its behaviour with @FT_Property_Set and
- * @FT_Property_Get. The following lists the available properties
- * together with the necessary macros and structures.
- *
- * Note that the auto-hinter's module name is 'autofitter' for historical
- * reasons.
- *
- * Available properties are @increase-x-height, @no-stem-darkening
- * (experimental), @darkening-parameters (experimental),
- * @glyph-to-script-map (experimental), @fallback-script (experimental),
- * and @default-script (experimental), as documented in the @properties
- * section.
- *
- */
-
-
- /**************************************************************************
- *
- * @section:
- * cff_driver
- *
- * @title:
- * The CFF driver
- *
- * @abstract:
- * Controlling the CFF driver module.
- *
- * @description:
- * While FreeType's CFF driver doesn't expose API functions by itself, it
- * is possible to control its behaviour with @FT_Property_Set and
- * @FT_Property_Get.
- *
- * The CFF driver's module name is 'cff'.
- *
- * Available properties are @hinting-engine, @no-stem-darkening,
- * @darkening-parameters, and @random-seed, as documented in the
- * @properties section.
- *
- *
- * **Hinting and anti-aliasing principles of the new engine**
- *
- * The rasterizer is positioning horizontal features (e.g., ascender
- * height & x-height, or crossbars) on the pixel grid and minimizing the
- * amount of anti-aliasing applied to them, while placing vertical
- * features (vertical stems) on the pixel grid without hinting, thus
- * representing the stem position and weight accurately. Sometimes the
- * vertical stems may be only partially black. In this context,
- * 'anti-aliasing' means that stems are not positioned exactly on pixel
- * borders, causing a fuzzy appearance.
- *
- * There are two principles behind this approach.
- *
- * 1) No hinting in the horizontal direction: Unlike 'superhinted'
- * TrueType, which changes glyph widths to accommodate regular
- * inter-glyph spacing, Adobe's approach is 'faithful to the design' in
- * representing both the glyph width and the inter-glyph spacing designed
- * for the font. This makes the screen display as close as it can be to
- * the result one would get with infinite resolution, while preserving
- * what is considered the key characteristics of each glyph. Note that
- * the distances between unhinted and grid-fitted positions at small
- * sizes are comparable to kerning values and thus would be noticeable
- * (and distracting) while reading if hinting were applied.
- *
- * One of the reasons to not hint horizontally is anti-aliasing for LCD
- * screens: The pixel geometry of modern displays supplies three vertical
- * subpixels as the eye moves horizontally across each visible pixel. On
- * devices where we can be certain this characteristic is present a
- * rasterizer can take advantage of the subpixels to add increments of
- * weight. In Western writing systems this turns out to be the more
- * critical direction anyway; the weights and spacing of vertical stems
- * (see above) are central to Armenian, Cyrillic, Greek, and Latin type
- * designs. Even when the rasterizer uses greyscale anti-aliasing instead
- * of color (a necessary compromise when one doesn't know the screen
- * characteristics), the unhinted vertical features preserve the design's
- * weight and spacing much better than aliased type would.
- *
- * 2) Alignment in the vertical direction: Weights and spacing along the
- * y~axis are less critical; what is much more important is the visual
- * alignment of related features (like cap-height and x-height). The
- * sense of alignment for these is enhanced by the sharpness of grid-fit
- * edges, while the cruder vertical resolution (full pixels instead of
- * 1/3 pixels) is less of a problem.
- *
- * On the technical side, horizontal alignment zones for ascender,
- * x-height, and other important height values (traditionally called
- * 'blue zones') as defined in the font are positioned independently,
- * each being rounded to the nearest pixel edge, taking care of overshoot
- * suppression at small sizes, stem darkening, and scaling.
- *
- * Hstems (that is, hint values defined in the font to help align
- * horizontal features) that fall within a blue zone are said to be
- * 'captured' and are aligned to that zone. Uncaptured stems are moved
- * in one of four ways, top edge up or down, bottom edge up or down.
- * Unless there are conflicting hstems, the smallest movement is taken to
- * minimize distortion.
- *
- */
-
-
- /**************************************************************************
- *
- * @section:
- * pcf_driver
- *
- * @title:
- * The PCF driver
- *
- * @abstract:
- * Controlling the PCF driver module.
- *
- * @description:
- * While FreeType's PCF driver doesn't expose API functions by itself, it
- * is possible to control its behaviour with @FT_Property_Set and
- * @FT_Property_Get. Right now, there is a single property
- * @no-long-family-names available if FreeType is compiled with
- * PCF_CONFIG_OPTION_LONG_FAMILY_NAMES.
- *
- * The PCF driver's module name is 'pcf'.
- *
- */
-
-
- /**************************************************************************
- *
- * @section:
- * t1_cid_driver
- *
- * @title:
- * The Type 1 and CID drivers
- *
- * @abstract:
- * Controlling the Type~1 and CID driver modules.
- *
- * @description:
- * It is possible to control the behaviour of FreeType's Type~1 and
- * Type~1 CID drivers with @FT_Property_Set and @FT_Property_Get.
- *
- * Behind the scenes, both drivers use the Adobe CFF engine for hinting;
- * however, the used properties must be specified separately.
- *
- * The Type~1 driver's module name is 'type1'; the CID driver's module
- * name is 't1cid'.
- *
- * Available properties are @hinting-engine, @no-stem-darkening,
- * @darkening-parameters, and @random-seed, as documented in the
- * @properties section.
- *
- * Please see the @cff_driver section for more details on the new hinting
- * engine.
- *
- */
-
-
- /**************************************************************************
- *
- * @section:
- * tt_driver
- *
- * @title:
- * The TrueType driver
- *
- * @abstract:
- * Controlling the TrueType driver module.
- *
- * @description:
- * While FreeType's TrueType driver doesn't expose API functions by
- * itself, it is possible to control its behaviour with @FT_Property_Set
- * and @FT_Property_Get.
- *
- * The TrueType driver's module name is 'truetype'; a single property
- * @interpreter-version is available, as documented in the @properties
- * section.
- *
- * To help understand the differences between interpreter versions, we
- * introduce a list of definitions, kindly provided by Greg Hitchcock.
- *
- * _Bi-Level Rendering_
- *
- * Monochromatic rendering, exclusively used in the early days of
- * TrueType by both Apple and Microsoft. Microsoft's GDI interface
- * supported hinting of the right-side bearing point, such that the
- * advance width could be non-linear. Most often this was done to
- * achieve some level of glyph symmetry. To enable reasonable
- * performance (e.g., not having to run hinting on all glyphs just to get
- * the widths) there was a bit in the head table indicating if the side
- * bearing was hinted, and additional tables, 'hdmx' and 'LTSH', to cache
- * hinting widths across multiple sizes and device aspect ratios.
- *
- * _Font Smoothing_
- *
- * Microsoft's GDI implementation of anti-aliasing. Not traditional
- * anti-aliasing as the outlines were hinted before the sampling. The
- * widths matched the bi-level rendering.
- *
- * _ClearType Rendering_
- *
- * Technique that uses physical subpixels to improve rendering on LCD
- * (and other) displays. Because of the higher resolution, many methods
- * of improving symmetry in glyphs through hinting the right-side bearing
- * were no longer necessary. This lead to what GDI calls 'natural
- * widths' ClearType, see
- * http://rastertragedy.com/RTRCh4.htm#Sec21. Since hinting
- * has extra resolution, most non-linearity went away, but it is still
- * possible for hints to change the advance widths in this mode.
- *
- * _ClearType Compatible Widths_
- *
- * One of the earliest challenges with ClearType was allowing the
- * implementation in GDI to be selected without requiring all UI and
- * documents to reflow. To address this, a compatible method of
- * rendering ClearType was added where the font hints are executed once
- * to determine the width in bi-level rendering, and then re-run in
- * ClearType, with the difference in widths being absorbed in the font
- * hints for ClearType (mostly in the white space of hints); see
- * http://rastertragedy.com/RTRCh4.htm#Sec20. Somewhat by
- * definition, compatible width ClearType allows for non-linear widths,
- * but only when the bi-level version has non-linear widths.
- *
- * _ClearType Subpixel Positioning_
- *
- * One of the nice benefits of ClearType is the ability to more crisply
- * display fractional widths; unfortunately, the GDI model of integer
- * bitmaps did not support this. However, the WPF and Direct Write
- * frameworks do support fractional widths. DWrite calls this 'natural
- * mode', not to be confused with GDI's 'natural widths'. Subpixel
- * positioning, in the current implementation of Direct Write,
- * unfortunately does not support hinted advance widths, see
- * http://rastertragedy.com/RTRCh4.htm#Sec22. Note that the
- * TrueType interpreter fully allows the advance width to be adjusted in
- * this mode, just the DWrite client will ignore those changes.
- *
- * _ClearType Backward Compatibility_
- *
- * This is a set of exceptions made in the TrueType interpreter to
- * minimize hinting techniques that were problematic with the extra
- * resolution of ClearType; see
- * http://rastertragedy.com/RTRCh4.htm#Sec1 and
- * https://www.microsoft.com/typography/cleartype/truetypecleartype.aspx.
- * This technique is not to be confused with ClearType compatible widths.
- * ClearType backward compatibility has no direct impact on changing
- * advance widths, but there might be an indirect impact on disabling
- * some deltas. This could be worked around in backward compatibility
- * mode.
- *
- * _Native ClearType Mode_
- *
- * (Not to be confused with 'natural widths'.) This mode removes all the
- * exceptions in the TrueType interpreter when running with ClearType.
- * Any issues on widths would still apply, though.
- *
- */
-
-
- /**************************************************************************
- *
- * @section:
- * ot_svg_driver
- *
- * @title:
- * The SVG driver
- *
- * @abstract:
- * Controlling the external rendering of OT-SVG glyphs.
- *
- * @description:
- * By default, FreeType can only load the 'SVG~' table of OpenType fonts
- * if configuration macro `FT_CONFIG_OPTION_SVG` is defined. To make it
- * render SVG glyphs, an external SVG rendering library is needed. All
- * details on the interface between FreeType and the external library
- * via function hooks can be found in section @svg_fonts.
- *
- * The OT-SVG driver's module name is 'ot-svg'; it supports a single
- * property called @svg-hooks, documented below in the @properties
- * section.
- *
- */
-
-
- /**************************************************************************
- *
- * @section:
- * properties
- *
- * @title:
- * Driver properties
- *
- * @abstract:
- * Controlling driver modules.
- *
- * @description:
- * Driver modules can be controlled by setting and unsetting properties,
- * using the functions @FT_Property_Set and @FT_Property_Get. This
- * section documents the available properties, together with auxiliary
- * macros and structures.
- *
- */
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_HINTING_XXX
- *
- * @description:
- * A list of constants used for the @hinting-engine property to select
- * the hinting engine for CFF, Type~1, and CID fonts.
- *
- * @values:
- * FT_HINTING_FREETYPE ::
- * Use the old FreeType hinting engine.
- *
- * FT_HINTING_ADOBE ::
- * Use the hinting engine contributed by Adobe.
- *
- * @since:
- * 2.9
- *
- */
-#define FT_HINTING_FREETYPE 0
-#define FT_HINTING_ADOBE 1
-
- /* these constants (introduced in 2.4.12) are deprecated */
-#define FT_CFF_HINTING_FREETYPE FT_HINTING_FREETYPE
-#define FT_CFF_HINTING_ADOBE FT_HINTING_ADOBE
-
-
- /**************************************************************************
- *
- * @property:
- * hinting-engine
- *
- * @description:
- * Thanks to Adobe, which contributed a new hinting (and parsing) engine,
- * an application can select between 'freetype' and 'adobe' if compiled
- * with `CFF_CONFIG_OPTION_OLD_ENGINE`. If this configuration macro
- * isn't defined, 'hinting-engine' does nothing.
- *
- * The same holds for the Type~1 and CID modules if compiled with
- * `T1_CONFIG_OPTION_OLD_ENGINE`.
- *
- * For the 'cff' module, the default engine is 'adobe'. For both the
- * 'type1' and 't1cid' modules, the default engine is 'adobe', too.
- *
- * @note:
- * This property can be used with @FT_Property_Get also.
- *
- * This property can be set via the `FREETYPE_PROPERTIES` environment
- * variable (using values 'adobe' or 'freetype').
- *
- * @example:
- * The following example code demonstrates how to select Adobe's hinting
- * engine for the 'cff' module (omitting the error handling).
- *
- * ```
- * FT_Library library;
- * FT_UInt hinting_engine = FT_HINTING_ADOBE;
- *
- *
- * FT_Init_FreeType( &library );
- *
- * FT_Property_Set( library, "cff",
- * "hinting-engine", &hinting_engine );
- * ```
- *
- * @since:
- * 2.4.12 (for 'cff' module)
- *
- * 2.9 (for 'type1' and 't1cid' modules)
- *
- */
-
-
- /**************************************************************************
- *
- * @property:
- * no-stem-darkening
- *
- * @description:
- * All glyphs that pass through the auto-hinter will be emboldened unless
- * this property is set to TRUE. The same is true for the CFF, Type~1,
- * and CID font modules if the 'Adobe' engine is selected (which is the
- * default).
- *
- * Stem darkening emboldens glyphs at smaller sizes to make them more
- * readable on common low-DPI screens when using linear alpha blending
- * and gamma correction, see @FT_Render_Glyph. When not using linear
- * alpha blending and gamma correction, glyphs will appear heavy and
- * fuzzy!
- *
- * Gamma correction essentially lightens fonts since shades of grey are
- * shifted to higher pixel values (=~higher brightness) to match the
- * original intention to the reality of our screens. The side-effect is
- * that glyphs 'thin out'. Mac OS~X and Adobe's proprietary font
- * rendering library implement a counter-measure: stem darkening at
- * smaller sizes where shades of gray dominate. By emboldening a glyph
- * slightly in relation to its pixel size, individual pixels get higher
- * coverage of filled-in outlines and are therefore 'blacker'. This
- * counteracts the 'thinning out' of glyphs, making text remain readable
- * at smaller sizes.
- *
- * For the auto-hinter, stem-darkening is experimental currently and thus
- * switched off by default (that is, `no-stem-darkening` is set to TRUE
- * by default). Total consistency with the CFF driver is not achieved
- * right now because the emboldening method differs and glyphs must be
- * scaled down on the Y-axis to keep outline points inside their
- * precomputed blue zones. The smaller the size (especially 9ppem and
- * down), the higher the loss of emboldening versus the CFF driver.
- *
- * Note that stem darkening is never applied if @FT_LOAD_NO_SCALE is set.
- *
- * @note:
- * This property can be used with @FT_Property_Get also.
- *
- * This property can be set via the `FREETYPE_PROPERTIES` environment
- * variable (using values 1 and 0 for 'on' and 'off', respectively). It
- * can also be set per face using @FT_Face_Properties with
- * @FT_PARAM_TAG_STEM_DARKENING.
- *
- * @example:
- * ```
- * FT_Library library;
- * FT_Bool no_stem_darkening = TRUE;
- *
- *
- * FT_Init_FreeType( &library );
- *
- * FT_Property_Set( library, "cff",
- * "no-stem-darkening", &no_stem_darkening );
- * ```
- *
- * @since:
- * 2.4.12 (for 'cff' module)
- *
- * 2.6.2 (for 'autofitter' module)
- *
- * 2.9 (for 'type1' and 't1cid' modules)
- *
- */
-
-
- /**************************************************************************
- *
- * @property:
- * darkening-parameters
- *
- * @description:
- * By default, the Adobe hinting engine, as used by the CFF, Type~1, and
- * CID font drivers, darkens stems as follows (if the `no-stem-darkening`
- * property isn't set):
- *
- * ```
- * stem width <= 0.5px: darkening amount = 0.4px
- * stem width = 1px: darkening amount = 0.275px
- * stem width = 1.667px: darkening amount = 0.275px
- * stem width >= 2.333px: darkening amount = 0px
- * ```
- *
- * and piecewise linear in-between. At configuration time, these four
- * control points can be set with the macro
- * `CFF_CONFIG_OPTION_DARKENING_PARAMETERS`; the CFF, Type~1, and CID
- * drivers share these values. At runtime, the control points can be
- * changed using the `darkening-parameters` property (see the example
- * below that demonstrates this for the Type~1 driver).
- *
- * The x~values give the stem width, and the y~values the darkening
- * amount. The unit is 1000th of pixels. All coordinate values must be
- * positive; the x~values must be monotonically increasing; the y~values
- * must be monotonically decreasing and smaller than or equal to 500
- * (corresponding to half a pixel); the slope of each linear piece must
- * be shallower than -1 (e.g., -.4).
- *
- * The auto-hinter provides this property, too, as an experimental
- * feature. See @no-stem-darkening for more.
- *
- * @note:
- * This property can be used with @FT_Property_Get also.
- *
- * This property can be set via the `FREETYPE_PROPERTIES` environment
- * variable, using eight comma-separated integers without spaces. Here
- * the above example, using `\` to break the line for readability.
- *
- * ```
- * FREETYPE_PROPERTIES=\
- * type1:darkening-parameters=500,300,1000,200,1500,100,2000,0
- * ```
- *
- * @example:
- * ```
- * FT_Library library;
- * FT_Int darken_params[8] = { 500, 300, // x1, y1
- * 1000, 200, // x2, y2
- * 1500, 100, // x3, y3
- * 2000, 0 }; // x4, y4
- *
- *
- * FT_Init_FreeType( &library );
- *
- * FT_Property_Set( library, "type1",
- * "darkening-parameters", darken_params );
- * ```
- *
- * @since:
- * 2.5.1 (for 'cff' module)
- *
- * 2.6.2 (for 'autofitter' module)
- *
- * 2.9 (for 'type1' and 't1cid' modules)
- *
- */
-
-
- /**************************************************************************
- *
- * @property:
- * random-seed
- *
- * @description:
- * By default, the seed value for the CFF 'random' operator and the
- * similar '0 28 callothersubr pop' command for the Type~1 and CID
- * drivers is set to a random value. However, mainly for debugging
- * purposes, it is often necessary to use a known value as a seed so that
- * the pseudo-random number sequences generated by 'random' are
- * repeatable.
- *
- * The `random-seed` property does that. Its argument is a signed 32bit
- * integer; if the value is zero or negative, the seed given by the
- * `intitialRandomSeed` private DICT operator in a CFF file gets used (or
- * a default value if there is no such operator). If the value is
- * positive, use it instead of `initialRandomSeed`, which is consequently
- * ignored.
- *
- * @note:
- * This property can be set via the `FREETYPE_PROPERTIES` environment
- * variable. It can also be set per face using @FT_Face_Properties with
- * @FT_PARAM_TAG_RANDOM_SEED.
- *
- * @since:
- * 2.8 (for 'cff' module)
- *
- * 2.9 (for 'type1' and 't1cid' modules)
- *
- */
-
-
- /**************************************************************************
- *
- * @property:
- * no-long-family-names
- *
- * @description:
- * If `PCF_CONFIG_OPTION_LONG_FAMILY_NAMES` is active while compiling
- * FreeType, the PCF driver constructs long family names.
- *
- * There are many PCF fonts just called 'Fixed' which look completely
- * different, and which have nothing to do with each other. When
- * selecting 'Fixed' in KDE or Gnome one gets results that appear rather
- * random, the style changes often if one changes the size and one cannot
- * select some fonts at all. The improve this situation, the PCF module
- * prepends the foundry name (plus a space) to the family name. It also
- * checks whether there are 'wide' characters; all put together, family
- * names like 'Sony Fixed' or 'Misc Fixed Wide' are constructed.
- *
- * If `no-long-family-names` is set, this feature gets switched off.
- *
- * @note:
- * This property can be used with @FT_Property_Get also.
- *
- * This property can be set via the `FREETYPE_PROPERTIES` environment
- * variable (using values 1 and 0 for 'on' and 'off', respectively).
- *
- * @example:
- * ```
- * FT_Library library;
- * FT_Bool no_long_family_names = TRUE;
- *
- *
- * FT_Init_FreeType( &library );
- *
- * FT_Property_Set( library, "pcf",
- * "no-long-family-names",
- * &no_long_family_names );
- * ```
- *
- * @since:
- * 2.8
- */
-
-
- /**************************************************************************
- *
- * @enum:
- * TT_INTERPRETER_VERSION_XXX
- *
- * @description:
- * A list of constants used for the @interpreter-version property to
- * select the hinting engine for Truetype fonts.
- *
- * The numeric value in the constant names represents the version number
- * as returned by the 'GETINFO' bytecode instruction.
- *
- * @values:
- * TT_INTERPRETER_VERSION_35 ::
- * Version~35 corresponds to MS rasterizer v.1.7 as used e.g. in
- * Windows~98; only grayscale and B/W rasterizing is supported.
- *
- * TT_INTERPRETER_VERSION_38 ::
- * Version~38 is the same Version~40. The original 'Infinality' code is
- * no longer available.
- *
- * TT_INTERPRETER_VERSION_40 ::
- * Version~40 corresponds to MS rasterizer v.2.1; it is roughly
- * equivalent to the hinting provided by DirectWrite ClearType (as can
- * be found, for example, in Microsoft's Edge Browser on Windows~10).
- * It is used in FreeType to select the 'minimal' subpixel hinting
- * code, a stripped-down and higher performance version of the
- * 'Infinality' code.
- *
- * @note:
- * This property controls the behaviour of the bytecode interpreter and
- * thus how outlines get hinted. It does **not** control how glyph get
- * rasterized! In particular, it does not control subpixel color
- * filtering.
- *
- * If FreeType has not been compiled with the configuration option
- * `TT_CONFIG_OPTION_SUBPIXEL_HINTING`, selecting version~38 or~40 causes
- * an `FT_Err_Unimplemented_Feature` error.
- *
- * Depending on the graphics framework, Microsoft uses different bytecode
- * and rendering engines. As a consequence, the version numbers returned
- * by a call to the 'GETINFO' bytecode instruction are more convoluted
- * than desired.
- *
- * Here are two tables that try to shed some light on the possible values
- * for the MS rasterizer engine, together with the additional features
- * introduced by it.
- *
- * ```
- * GETINFO framework version feature
- * -------------------------------------------------------------------
- * 3 GDI (Win 3.1), v1.0 16-bit, first version
- * TrueImage
- * 33 GDI (Win NT 3.1), v1.5 32-bit
- * HP Laserjet
- * 34 GDI (Win 95) v1.6 font smoothing,
- * new SCANTYPE opcode
- * 35 GDI (Win 98/2000) v1.7 (UN)SCALED_COMPONENT_OFFSET
- * bits in composite glyphs
- * 36 MGDI (Win CE 2) v1.6+ classic ClearType
- * 37 GDI (XP and later), v1.8 ClearType
- * GDI+ old (before Vista)
- * 38 GDI+ old (Vista, Win 7), v1.9 subpixel ClearType,
- * WPF Y-direction ClearType,
- * additional error checking
- * 39 DWrite (before Win 8) v2.0 subpixel ClearType flags
- * in GETINFO opcode,
- * bug fixes
- * 40 GDI+ (after Win 7), v2.1 Y-direction ClearType flag
- * DWrite (Win 8) in GETINFO opcode,
- * Gray ClearType
- * ```
- *
- * The 'version' field gives a rough orientation only, since some
- * applications provided certain features much earlier (as an example,
- * Microsoft Reader used subpixel and Y-direction ClearType already in
- * Windows 2000). Similarly, updates to a given framework might include
- * improved hinting support.
- *
- * ```
- * version sampling rendering comment
- * x y x y
- * --------------------------------------------------------------
- * v1.0 normal normal B/W B/W bi-level
- * v1.6 high high gray gray grayscale
- * v1.8 high normal color-filter B/W (GDI) ClearType
- * v1.9 high high color-filter gray Color ClearType
- * v2.1 high normal gray B/W Gray ClearType
- * v2.1 high high gray gray Gray ClearType
- * ```
- *
- * Color and Gray ClearType are the two available variants of
- * 'Y-direction ClearType', meaning grayscale rasterization along the
- * Y-direction; the name used in the TrueType specification for this
- * feature is 'symmetric smoothing'. 'Classic ClearType' is the original
- * algorithm used before introducing a modified version in Win~XP.
- * Another name for v1.6's grayscale rendering is 'font smoothing', and
- * 'Color ClearType' is sometimes also called 'DWrite ClearType'. To
- * differentiate between today's Color ClearType and the earlier
- * ClearType variant with B/W rendering along the vertical axis, the
- * latter is sometimes called 'GDI ClearType'.
- *
- * 'Normal' and 'high' sampling describe the (virtual) resolution to
- * access the rasterized outline after the hinting process. 'Normal'
- * means 1 sample per grid line (i.e., B/W). In the current Microsoft
- * implementation, 'high' means an extra virtual resolution of 16x16 (or
- * 16x1) grid lines per pixel for bytecode instructions like 'MIRP'.
- * After hinting, these 16 grid lines are mapped to 6x5 (or 6x1) grid
- * lines for color filtering if Color ClearType is activated.
- *
- * Note that 'Gray ClearType' is essentially the same as v1.6's grayscale
- * rendering. However, the GETINFO instruction handles it differently:
- * v1.6 returns bit~12 (hinting for grayscale), while v2.1 returns
- * bits~13 (hinting for ClearType), 18 (symmetrical smoothing), and~19
- * (Gray ClearType). Also, this mode respects bits 2 and~3 for the
- * version~1 gasp table exclusively (like Color ClearType), while v1.6
- * only respects the values of version~0 (bits 0 and~1).
- *
- * Keep in mind that the features of the above interpreter versions might
- * not map exactly to FreeType features or behavior because it is a
- * fundamentally different library with different internals.
- *
- */
-#define TT_INTERPRETER_VERSION_35 35
-#define TT_INTERPRETER_VERSION_38 38
-#define TT_INTERPRETER_VERSION_40 40
-
-
- /**************************************************************************
- *
- * @property:
- * interpreter-version
- *
- * @description:
- * Currently, three versions are available, two representing the bytecode
- * interpreter with subpixel hinting support (old 'Infinality' code and
- * new stripped-down and higher performance 'minimal' code) and one
- * without, respectively. The default is subpixel support if
- * `TT_CONFIG_OPTION_SUBPIXEL_HINTING` is defined, and no subpixel
- * support otherwise (since it isn't available then).
- *
- * If subpixel hinting is on, many TrueType bytecode instructions behave
- * differently compared to B/W or grayscale rendering (except if 'native
- * ClearType' is selected by the font). Microsoft's main idea is to
- * render at a much increased horizontal resolution, then sampling down
- * the created output to subpixel precision. However, many older fonts
- * are not suited to this and must be specially taken care of by applying
- * (hardcoded) tweaks in Microsoft's interpreter.
- *
- * Details on subpixel hinting and some of the necessary tweaks can be
- * found in Greg Hitchcock's whitepaper at
- * 'https://www.microsoft.com/typography/cleartype/truetypecleartype.aspx'.
- * Note that FreeType currently doesn't really 'subpixel hint' (6x1, 6x2,
- * or 6x5 supersampling) like discussed in the paper. Depending on the
- * chosen interpreter, it simply ignores instructions on vertical stems
- * to arrive at very similar results.
- *
- * @note:
- * This property can be used with @FT_Property_Get also.
- *
- * This property can be set via the `FREETYPE_PROPERTIES` environment
- * variable (using values '35', '38', or '40').
- *
- * @example:
- * The following example code demonstrates how to deactivate subpixel
- * hinting (omitting the error handling).
- *
- * ```
- * FT_Library library;
- * FT_Face face;
- * FT_UInt interpreter_version = TT_INTERPRETER_VERSION_35;
- *
- *
- * FT_Init_FreeType( &library );
- *
- * FT_Property_Set( library, "truetype",
- * "interpreter-version",
- * &interpreter_version );
- * ```
- *
- * @since:
- * 2.5
- */
-
-
- /**************************************************************************
- *
- * @property:
- * spread
- *
- * @description:
- * This property of the 'sdf' and 'bsdf' renderers defines how the signed
- * distance field (SDF) is represented in the output bitmap. The output
- * values are calculated as follows, '128 * ( SDF / spread + 1 )', with
- * the result clamped to the 8-bit range [0..255]. Therefore, 'spread'
- * is also the maximum euclidean distance from the edge after which the
- * values are clamped. The spread is specified in pixels with the
- * default value of 8. For accurate SDF texture mapping (interpolation),
- * the spread should be large enough to accommodate the target grid unit.
- *
- * @example:
- * The following example code demonstrates how to set the SDF spread
- * (omitting the error handling).
- *
- * ```
- * FT_Library library;
- * FT_Int spread = 2;
- *
- *
- * FT_Init_FreeType( &library );
- *
- * FT_Property_Set( library, "sdf", "spread", &spread );
- * ```
- *
- * @note:
- * FreeType has two rasterizers for generating SDF, namely:
- *
- * 1. `sdf` for generating SDF directly from glyph's outline, and
- *
- * 2. `bsdf` for generating SDF from rasterized bitmaps.
- *
- * Depending on the glyph type (i.e., outline or bitmap), one of the two
- * rasterizers is chosen at runtime and used for generating SDFs. To
- * force the use of `bsdf` you should render the glyph with any of the
- * FreeType's other rendering modes (e.g., `FT_RENDER_MODE_NORMAL`) and
- * then re-render with `FT_RENDER_MODE_SDF`.
- *
- * There are some issues with stability and possible failures of the SDF
- * renderers (specifically `sdf`).
- *
- * 1. The `sdf` rasterizer is sensitive to really small features (e.g.,
- * sharp turns that are less than 1~pixel) and imperfections in the
- * glyph's outline, causing artifacts in the final output.
- *
- * 2. The `sdf` rasterizer has limited support for handling intersecting
- * contours and *cannot* handle self-intersecting contours whatsoever.
- * Self-intersection happens when a single connected contour
- * intersects itself at some point; having these in your font
- * definitely poses a problem to the rasterizer and cause artifacts,
- * too.
- *
- * 3. Generating SDF for really small glyphs may result in undesirable
- * output; the pixel grid (which stores distance information) becomes
- * too coarse.
- *
- * 4. Since the output buffer is normalized, precision at smaller spreads
- * is greater than precision at larger spread values because the
- * output range of [0..255] gets mapped to a smaller SDF range. A
- * spread of~2 should be sufficient in most cases.
- *
- * Points (1) and (2) can be avoided by using the `bsdf` rasterizer,
- * which is more stable than the `sdf` rasterizer in general.
- *
- * @since:
- * 2.11
- */
-
-
- /**************************************************************************
- *
- * @property:
- * svg-hooks
- *
- * @description:
- * Set up the interface between FreeType and an extern SVG rendering
- * library like 'librsvg'. All details on the function hooks can be
- * found in section @svg_fonts.
- *
- * @example:
- * The following example code expects that the four hook functions
- * `svg_*` are defined elsewhere. Error handling is omitted, too.
- *
- * ```
- * FT_Library library;
- * SVG_RendererHooks hooks = {
- * (SVG_Lib_Init_Func)svg_init,
- * (SVG_Lib_Free_Func)svg_free,
- * (SVG_Lib_Render_Func)svg_render,
- * (SVG_Lib_Preset_Slot_Func)svg_preset_slot };
- *
- *
- * FT_Init_FreeType( &library );
- *
- * FT_Property_Set( library, "ot-svg",
- * "svg-hooks", &hooks );
- * ```
- *
- * @since:
- * 2.12
- */
-
-
- /**************************************************************************
- *
- * @property:
- * glyph-to-script-map
- *
- * @description:
- * **Experimental only**
- *
- * The auto-hinter provides various script modules to hint glyphs.
- * Examples of supported scripts are Latin or CJK. Before a glyph is
- * auto-hinted, the Unicode character map of the font gets examined, and
- * the script is then determined based on Unicode character ranges, see
- * below.
- *
- * OpenType fonts, however, often provide much more glyphs than character
- * codes (small caps, superscripts, ligatures, swashes, etc.), to be
- * controlled by so-called 'features'. Handling OpenType features can be
- * quite complicated and thus needs a separate library on top of
- * FreeType.
- *
- * The mapping between glyph indices and scripts (in the auto-hinter
- * sense, see the @FT_AUTOHINTER_SCRIPT_XXX values) is stored as an array
- * with `num_glyphs` elements, as found in the font's @FT_Face structure.
- * The `glyph-to-script-map` property returns a pointer to this array,
- * which can be modified as needed. Note that the modification should
- * happen before the first glyph gets processed by the auto-hinter so
- * that the global analysis of the font shapes actually uses the modified
- * mapping.
- *
- * @example:
- * The following example code demonstrates how to access it (omitting the
- * error handling).
- *
- * ```
- * FT_Library library;
- * FT_Face face;
- * FT_Prop_GlyphToScriptMap prop;
- *
- *
- * FT_Init_FreeType( &library );
- * FT_New_Face( library, "foo.ttf", 0, &face );
- *
- * prop.face = face;
- *
- * FT_Property_Get( library, "autofitter",
- * "glyph-to-script-map", &prop );
- *
- * // adjust `prop.map' as needed right here
- *
- * FT_Load_Glyph( face, ..., FT_LOAD_FORCE_AUTOHINT );
- * ```
- *
- * @since:
- * 2.4.11
- *
- */
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_AUTOHINTER_SCRIPT_XXX
- *
- * @description:
- * **Experimental only**
- *
- * A list of constants used for the @glyph-to-script-map property to
- * specify the script submodule the auto-hinter should use for hinting a
- * particular glyph.
- *
- * @values:
- * FT_AUTOHINTER_SCRIPT_NONE ::
- * Don't auto-hint this glyph.
- *
- * FT_AUTOHINTER_SCRIPT_LATIN ::
- * Apply the latin auto-hinter. For the auto-hinter, 'latin' is a very
- * broad term, including Cyrillic and Greek also since characters from
- * those scripts share the same design constraints.
- *
- * By default, characters from the following Unicode ranges are
- * assigned to this submodule.
- *
- * ```
- * U+0020 - U+007F // Basic Latin (no control characters)
- * U+00A0 - U+00FF // Latin-1 Supplement (no control characters)
- * U+0100 - U+017F // Latin Extended-A
- * U+0180 - U+024F // Latin Extended-B
- * U+0250 - U+02AF // IPA Extensions
- * U+02B0 - U+02FF // Spacing Modifier Letters
- * U+0300 - U+036F // Combining Diacritical Marks
- * U+0370 - U+03FF // Greek and Coptic
- * U+0400 - U+04FF // Cyrillic
- * U+0500 - U+052F // Cyrillic Supplement
- * U+1D00 - U+1D7F // Phonetic Extensions
- * U+1D80 - U+1DBF // Phonetic Extensions Supplement
- * U+1DC0 - U+1DFF // Combining Diacritical Marks Supplement
- * U+1E00 - U+1EFF // Latin Extended Additional
- * U+1F00 - U+1FFF // Greek Extended
- * U+2000 - U+206F // General Punctuation
- * U+2070 - U+209F // Superscripts and Subscripts
- * U+20A0 - U+20CF // Currency Symbols
- * U+2150 - U+218F // Number Forms
- * U+2460 - U+24FF // Enclosed Alphanumerics
- * U+2C60 - U+2C7F // Latin Extended-C
- * U+2DE0 - U+2DFF // Cyrillic Extended-A
- * U+2E00 - U+2E7F // Supplemental Punctuation
- * U+A640 - U+A69F // Cyrillic Extended-B
- * U+A720 - U+A7FF // Latin Extended-D
- * U+FB00 - U+FB06 // Alphab. Present. Forms (Latin Ligatures)
- * U+1D400 - U+1D7FF // Mathematical Alphanumeric Symbols
- * U+1F100 - U+1F1FF // Enclosed Alphanumeric Supplement
- * ```
- *
- * FT_AUTOHINTER_SCRIPT_CJK ::
- * Apply the CJK auto-hinter, covering Chinese, Japanese, Korean, old
- * Vietnamese, and some other scripts.
- *
- * By default, characters from the following Unicode ranges are
- * assigned to this submodule.
- *
- * ```
- * U+1100 - U+11FF // Hangul Jamo
- * U+2E80 - U+2EFF // CJK Radicals Supplement
- * U+2F00 - U+2FDF // Kangxi Radicals
- * U+2FF0 - U+2FFF // Ideographic Description Characters
- * U+3000 - U+303F // CJK Symbols and Punctuation
- * U+3040 - U+309F // Hiragana
- * U+30A0 - U+30FF // Katakana
- * U+3100 - U+312F // Bopomofo
- * U+3130 - U+318F // Hangul Compatibility Jamo
- * U+3190 - U+319F // Kanbun
- * U+31A0 - U+31BF // Bopomofo Extended
- * U+31C0 - U+31EF // CJK Strokes
- * U+31F0 - U+31FF // Katakana Phonetic Extensions
- * U+3200 - U+32FF // Enclosed CJK Letters and Months
- * U+3300 - U+33FF // CJK Compatibility
- * U+3400 - U+4DBF // CJK Unified Ideographs Extension A
- * U+4DC0 - U+4DFF // Yijing Hexagram Symbols
- * U+4E00 - U+9FFF // CJK Unified Ideographs
- * U+A960 - U+A97F // Hangul Jamo Extended-A
- * U+AC00 - U+D7AF // Hangul Syllables
- * U+D7B0 - U+D7FF // Hangul Jamo Extended-B
- * U+F900 - U+FAFF // CJK Compatibility Ideographs
- * U+FE10 - U+FE1F // Vertical forms
- * U+FE30 - U+FE4F // CJK Compatibility Forms
- * U+FF00 - U+FFEF // Halfwidth and Fullwidth Forms
- * U+1B000 - U+1B0FF // Kana Supplement
- * U+1D300 - U+1D35F // Tai Xuan Hing Symbols
- * U+1F200 - U+1F2FF // Enclosed Ideographic Supplement
- * U+20000 - U+2A6DF // CJK Unified Ideographs Extension B
- * U+2A700 - U+2B73F // CJK Unified Ideographs Extension C
- * U+2B740 - U+2B81F // CJK Unified Ideographs Extension D
- * U+2F800 - U+2FA1F // CJK Compatibility Ideographs Supplement
- * ```
- *
- * FT_AUTOHINTER_SCRIPT_INDIC ::
- * Apply the indic auto-hinter, covering all major scripts from the
- * Indian sub-continent and some other related scripts like Thai, Lao,
- * or Tibetan.
- *
- * By default, characters from the following Unicode ranges are
- * assigned to this submodule.
- *
- * ```
- * U+0900 - U+0DFF // Indic Range
- * U+0F00 - U+0FFF // Tibetan
- * U+1900 - U+194F // Limbu
- * U+1B80 - U+1BBF // Sundanese
- * U+A800 - U+A82F // Syloti Nagri
- * U+ABC0 - U+ABFF // Meetei Mayek
- * U+11800 - U+118DF // Sharada
- * ```
- *
- * Note that currently Indic support is rudimentary only, missing blue
- * zone support.
- *
- * @since:
- * 2.4.11
- *
- */
-#define FT_AUTOHINTER_SCRIPT_NONE 0
-#define FT_AUTOHINTER_SCRIPT_LATIN 1
-#define FT_AUTOHINTER_SCRIPT_CJK 2
-#define FT_AUTOHINTER_SCRIPT_INDIC 3
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_Prop_GlyphToScriptMap
- *
- * @description:
- * **Experimental only**
- *
- * The data exchange structure for the @glyph-to-script-map property.
- *
- * @since:
- * 2.4.11
- *
- */
- typedef struct FT_Prop_GlyphToScriptMap_
- {
- FT_Face face;
- FT_UShort* map;
-
- } FT_Prop_GlyphToScriptMap;
-
-
- /**************************************************************************
- *
- * @property:
- * fallback-script
- *
- * @description:
- * **Experimental only**
- *
- * If no auto-hinter script module can be assigned to a glyph, a fallback
- * script gets assigned to it (see also the @glyph-to-script-map
- * property). By default, this is @FT_AUTOHINTER_SCRIPT_CJK. Using the
- * `fallback-script` property, this fallback value can be changed.
- *
- * @note:
- * This property can be used with @FT_Property_Get also.
- *
- * It's important to use the right timing for changing this value: The
- * creation of the glyph-to-script map that eventually uses the fallback
- * script value gets triggered either by setting or reading a
- * face-specific property like @glyph-to-script-map, or by auto-hinting
- * any glyph from that face. In particular, if you have already created
- * an @FT_Face structure but not loaded any glyph (using the
- * auto-hinter), a change of the fallback script will affect this face.
- *
- * @example:
- * ```
- * FT_Library library;
- * FT_UInt fallback_script = FT_AUTOHINTER_SCRIPT_NONE;
- *
- *
- * FT_Init_FreeType( &library );
- *
- * FT_Property_Set( library, "autofitter",
- * "fallback-script", &fallback_script );
- * ```
- *
- * @since:
- * 2.4.11
- *
- */
-
-
- /**************************************************************************
- *
- * @property:
- * default-script
- *
- * @description:
- * **Experimental only**
- *
- * If FreeType gets compiled with `FT_CONFIG_OPTION_USE_HARFBUZZ` to make
- * the HarfBuzz library access OpenType features for getting better glyph
- * coverages, this property sets the (auto-fitter) script to be used for
- * the default (OpenType) script data of a font's GSUB table. Features
- * for the default script are intended for all scripts not explicitly
- * handled in GSUB; an example is a 'dlig' feature, containing the
- * combination of the characters 'T', 'E', and 'L' to form a 'TEL'
- * ligature.
- *
- * By default, this is @FT_AUTOHINTER_SCRIPT_LATIN. Using the
- * `default-script` property, this default value can be changed.
- *
- * @note:
- * This property can be used with @FT_Property_Get also.
- *
- * It's important to use the right timing for changing this value: The
- * creation of the glyph-to-script map that eventually uses the default
- * script value gets triggered either by setting or reading a
- * face-specific property like @glyph-to-script-map, or by auto-hinting
- * any glyph from that face. In particular, if you have already created
- * an @FT_Face structure but not loaded any glyph (using the
- * auto-hinter), a change of the default script will affect this face.
- *
- * @example:
- * ```
- * FT_Library library;
- * FT_UInt default_script = FT_AUTOHINTER_SCRIPT_NONE;
- *
- *
- * FT_Init_FreeType( &library );
- *
- * FT_Property_Set( library, "autofitter",
- * "default-script", &default_script );
- * ```
- *
- * @since:
- * 2.5.3
- *
- */
-
-
- /**************************************************************************
- *
- * @property:
- * increase-x-height
- *
- * @description:
- * For ppem values in the range 6~<= ppem <= `increase-x-height`, round
- * up the font's x~height much more often than normally. If the value is
- * set to~0, which is the default, this feature is switched off. Use
- * this property to improve the legibility of small font sizes if
- * necessary.
- *
- * @note:
- * This property can be used with @FT_Property_Get also.
- *
- * Set this value right after calling @FT_Set_Char_Size, but before
- * loading any glyph (using the auto-hinter).
- *
- * @example:
- * ```
- * FT_Library library;
- * FT_Face face;
- * FT_Prop_IncreaseXHeight prop;
- *
- *
- * FT_Init_FreeType( &library );
- * FT_New_Face( library, "foo.ttf", 0, &face );
- * FT_Set_Char_Size( face, 10 * 64, 0, 72, 0 );
- *
- * prop.face = face;
- * prop.limit = 14;
- *
- * FT_Property_Set( library, "autofitter",
- * "increase-x-height", &prop );
- * ```
- *
- * @since:
- * 2.4.11
- *
- */
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_Prop_IncreaseXHeight
- *
- * @description:
- * The data exchange structure for the @increase-x-height property.
- *
- */
- typedef struct FT_Prop_IncreaseXHeight_
- {
- FT_Face face;
- FT_UInt limit;
-
- } FT_Prop_IncreaseXHeight;
-
-
- /**************************************************************************
- *
- * @property:
- * warping
- *
- * @description:
- * **Obsolete**
- *
- * This property was always experimental and probably never worked
- * correctly. It was entirely removed from the FreeType~2 sources. This
- * entry is only here for historical reference.
- *
- * Warping only worked in 'normal' auto-hinting mode replacing it. The
- * idea of the code was to slightly scale and shift a glyph along the
- * non-hinted dimension (which is usually the horizontal axis) so that as
- * much of its segments were aligned (more or less) to the grid. To find
- * out a glyph's optimal scaling and shifting value, various parameter
- * combinations were tried and scored.
- *
- * @since:
- * 2.6
- *
- */
-
-
- /* */
-
-
-FT_END_HEADER
-
-
-#endif /* FTDRIVER_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/fterrdef.h b/contrib/libs/freetype/include/freetype/fterrdef.h
deleted file mode 100644
index 710ca91bbd..0000000000
--- a/contrib/libs/freetype/include/freetype/fterrdef.h
+++ /dev/null
@@ -1,283 +0,0 @@
-/****************************************************************************
- *
- * fterrdef.h
- *
- * FreeType error codes (specification).
- *
- * Copyright (C) 2002-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /**************************************************************************
- *
- * @section:
- * error_code_values
- *
- * @title:
- * Error Code Values
- *
- * @abstract:
- * All possible error codes returned by FreeType functions.
- *
- * @description:
- * The list below is taken verbatim from the file `fterrdef.h` (loaded
- * automatically by including `FT_FREETYPE_H`). The first argument of the
- * `FT_ERROR_DEF_` macro is the error label; by default, the prefix
- * `FT_Err_` gets added so that you get error names like
- * `FT_Err_Cannot_Open_Resource`. The second argument is the error code,
- * and the last argument an error string, which is not used by FreeType.
- *
- * Within your application you should **only** use error names and
- * **never** its numeric values! The latter might (and actually do)
- * change in forthcoming FreeType versions.
- *
- * Macro `FT_NOERRORDEF_` defines `FT_Err_Ok`, which is always zero. See
- * the 'Error Enumerations' subsection how to automatically generate a
- * list of error strings.
- *
- */
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_Err_XXX
- *
- */
-
- /* generic errors */
-
- FT_NOERRORDEF_( Ok, 0x00,
- "no error" )
-
- FT_ERRORDEF_( Cannot_Open_Resource, 0x01,
- "cannot open resource" )
- FT_ERRORDEF_( Unknown_File_Format, 0x02,
- "unknown file format" )
- FT_ERRORDEF_( Invalid_File_Format, 0x03,
- "broken file" )
- FT_ERRORDEF_( Invalid_Version, 0x04,
- "invalid FreeType version" )
- FT_ERRORDEF_( Lower_Module_Version, 0x05,
- "module version is too low" )
- FT_ERRORDEF_( Invalid_Argument, 0x06,
- "invalid argument" )
- FT_ERRORDEF_( Unimplemented_Feature, 0x07,
- "unimplemented feature" )
- FT_ERRORDEF_( Invalid_Table, 0x08,
- "broken table" )
- FT_ERRORDEF_( Invalid_Offset, 0x09,
- "broken offset within table" )
- FT_ERRORDEF_( Array_Too_Large, 0x0A,
- "array allocation size too large" )
- FT_ERRORDEF_( Missing_Module, 0x0B,
- "missing module" )
- FT_ERRORDEF_( Missing_Property, 0x0C,
- "missing property" )
-
- /* glyph/character errors */
-
- FT_ERRORDEF_( Invalid_Glyph_Index, 0x10,
- "invalid glyph index" )
- FT_ERRORDEF_( Invalid_Character_Code, 0x11,
- "invalid character code" )
- FT_ERRORDEF_( Invalid_Glyph_Format, 0x12,
- "unsupported glyph image format" )
- FT_ERRORDEF_( Cannot_Render_Glyph, 0x13,
- "cannot render this glyph format" )
- FT_ERRORDEF_( Invalid_Outline, 0x14,
- "invalid outline" )
- FT_ERRORDEF_( Invalid_Composite, 0x15,
- "invalid composite glyph" )
- FT_ERRORDEF_( Too_Many_Hints, 0x16,
- "too many hints" )
- FT_ERRORDEF_( Invalid_Pixel_Size, 0x17,
- "invalid pixel size" )
- FT_ERRORDEF_( Invalid_SVG_Document, 0x18,
- "invalid SVG document" )
-
- /* handle errors */
-
- FT_ERRORDEF_( Invalid_Handle, 0x20,
- "invalid object handle" )
- FT_ERRORDEF_( Invalid_Library_Handle, 0x21,
- "invalid library handle" )
- FT_ERRORDEF_( Invalid_Driver_Handle, 0x22,
- "invalid module handle" )
- FT_ERRORDEF_( Invalid_Face_Handle, 0x23,
- "invalid face handle" )
- FT_ERRORDEF_( Invalid_Size_Handle, 0x24,
- "invalid size handle" )
- FT_ERRORDEF_( Invalid_Slot_Handle, 0x25,
- "invalid glyph slot handle" )
- FT_ERRORDEF_( Invalid_CharMap_Handle, 0x26,
- "invalid charmap handle" )
- FT_ERRORDEF_( Invalid_Cache_Handle, 0x27,
- "invalid cache manager handle" )
- FT_ERRORDEF_( Invalid_Stream_Handle, 0x28,
- "invalid stream handle" )
-
- /* driver errors */
-
- FT_ERRORDEF_( Too_Many_Drivers, 0x30,
- "too many modules" )
- FT_ERRORDEF_( Too_Many_Extensions, 0x31,
- "too many extensions" )
-
- /* memory errors */
-
- FT_ERRORDEF_( Out_Of_Memory, 0x40,
- "out of memory" )
- FT_ERRORDEF_( Unlisted_Object, 0x41,
- "unlisted object" )
-
- /* stream errors */
-
- FT_ERRORDEF_( Cannot_Open_Stream, 0x51,
- "cannot open stream" )
- FT_ERRORDEF_( Invalid_Stream_Seek, 0x52,
- "invalid stream seek" )
- FT_ERRORDEF_( Invalid_Stream_Skip, 0x53,
- "invalid stream skip" )
- FT_ERRORDEF_( Invalid_Stream_Read, 0x54,
- "invalid stream read" )
- FT_ERRORDEF_( Invalid_Stream_Operation, 0x55,
- "invalid stream operation" )
- FT_ERRORDEF_( Invalid_Frame_Operation, 0x56,
- "invalid frame operation" )
- FT_ERRORDEF_( Nested_Frame_Access, 0x57,
- "nested frame access" )
- FT_ERRORDEF_( Invalid_Frame_Read, 0x58,
- "invalid frame read" )
-
- /* raster errors */
-
- FT_ERRORDEF_( Raster_Uninitialized, 0x60,
- "raster uninitialized" )
- FT_ERRORDEF_( Raster_Corrupted, 0x61,
- "raster corrupted" )
- FT_ERRORDEF_( Raster_Overflow, 0x62,
- "raster overflow" )
- FT_ERRORDEF_( Raster_Negative_Height, 0x63,
- "negative height while rastering" )
-
- /* cache errors */
-
- FT_ERRORDEF_( Too_Many_Caches, 0x70,
- "too many registered caches" )
-
- /* TrueType and SFNT errors */
-
- FT_ERRORDEF_( Invalid_Opcode, 0x80,
- "invalid opcode" )
- FT_ERRORDEF_( Too_Few_Arguments, 0x81,
- "too few arguments" )
- FT_ERRORDEF_( Stack_Overflow, 0x82,
- "stack overflow" )
- FT_ERRORDEF_( Code_Overflow, 0x83,
- "code overflow" )
- FT_ERRORDEF_( Bad_Argument, 0x84,
- "bad argument" )
- FT_ERRORDEF_( Divide_By_Zero, 0x85,
- "division by zero" )
- FT_ERRORDEF_( Invalid_Reference, 0x86,
- "invalid reference" )
- FT_ERRORDEF_( Debug_OpCode, 0x87,
- "found debug opcode" )
- FT_ERRORDEF_( ENDF_In_Exec_Stream, 0x88,
- "found ENDF opcode in execution stream" )
- FT_ERRORDEF_( Nested_DEFS, 0x89,
- "nested DEFS" )
- FT_ERRORDEF_( Invalid_CodeRange, 0x8A,
- "invalid code range" )
- FT_ERRORDEF_( Execution_Too_Long, 0x8B,
- "execution context too long" )
- FT_ERRORDEF_( Too_Many_Function_Defs, 0x8C,
- "too many function definitions" )
- FT_ERRORDEF_( Too_Many_Instruction_Defs, 0x8D,
- "too many instruction definitions" )
- FT_ERRORDEF_( Table_Missing, 0x8E,
- "SFNT font table missing" )
- FT_ERRORDEF_( Horiz_Header_Missing, 0x8F,
- "horizontal header (hhea) table missing" )
- FT_ERRORDEF_( Locations_Missing, 0x90,
- "locations (loca) table missing" )
- FT_ERRORDEF_( Name_Table_Missing, 0x91,
- "name table missing" )
- FT_ERRORDEF_( CMap_Table_Missing, 0x92,
- "character map (cmap) table missing" )
- FT_ERRORDEF_( Hmtx_Table_Missing, 0x93,
- "horizontal metrics (hmtx) table missing" )
- FT_ERRORDEF_( Post_Table_Missing, 0x94,
- "PostScript (post) table missing" )
- FT_ERRORDEF_( Invalid_Horiz_Metrics, 0x95,
- "invalid horizontal metrics" )
- FT_ERRORDEF_( Invalid_CharMap_Format, 0x96,
- "invalid character map (cmap) format" )
- FT_ERRORDEF_( Invalid_PPem, 0x97,
- "invalid ppem value" )
- FT_ERRORDEF_( Invalid_Vert_Metrics, 0x98,
- "invalid vertical metrics" )
- FT_ERRORDEF_( Could_Not_Find_Context, 0x99,
- "could not find context" )
- FT_ERRORDEF_( Invalid_Post_Table_Format, 0x9A,
- "invalid PostScript (post) table format" )
- FT_ERRORDEF_( Invalid_Post_Table, 0x9B,
- "invalid PostScript (post) table" )
- FT_ERRORDEF_( DEF_In_Glyf_Bytecode, 0x9C,
- "found FDEF or IDEF opcode in glyf bytecode" )
- FT_ERRORDEF_( Missing_Bitmap, 0x9D,
- "missing bitmap in strike" )
- FT_ERRORDEF_( Missing_SVG_Hooks, 0x9E,
- "SVG hooks have not been set" )
-
- /* CFF, CID, and Type 1 errors */
-
- FT_ERRORDEF_( Syntax_Error, 0xA0,
- "opcode syntax error" )
- FT_ERRORDEF_( Stack_Underflow, 0xA1,
- "argument stack underflow" )
- FT_ERRORDEF_( Ignore, 0xA2,
- "ignore" )
- FT_ERRORDEF_( No_Unicode_Glyph_Name, 0xA3,
- "no Unicode glyph name found" )
- FT_ERRORDEF_( Glyph_Too_Big, 0xA4,
- "glyph too big for hinting" )
-
- /* BDF errors */
-
- FT_ERRORDEF_( Missing_Startfont_Field, 0xB0,
- "`STARTFONT' field missing" )
- FT_ERRORDEF_( Missing_Font_Field, 0xB1,
- "`FONT' field missing" )
- FT_ERRORDEF_( Missing_Size_Field, 0xB2,
- "`SIZE' field missing" )
- FT_ERRORDEF_( Missing_Fontboundingbox_Field, 0xB3,
- "`FONTBOUNDINGBOX' field missing" )
- FT_ERRORDEF_( Missing_Chars_Field, 0xB4,
- "`CHARS' field missing" )
- FT_ERRORDEF_( Missing_Startchar_Field, 0xB5,
- "`STARTCHAR' field missing" )
- FT_ERRORDEF_( Missing_Encoding_Field, 0xB6,
- "`ENCODING' field missing" )
- FT_ERRORDEF_( Missing_Bbx_Field, 0xB7,
- "`BBX' field missing" )
- FT_ERRORDEF_( Bbx_Too_Big, 0xB8,
- "`BBX' too big" )
- FT_ERRORDEF_( Corrupted_Font_Header, 0xB9,
- "Font header corrupted or missing fields" )
- FT_ERRORDEF_( Corrupted_Font_Glyphs, 0xBA,
- "Font glyphs corrupted or missing fields" )
-
- /* */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/fterrors.h b/contrib/libs/freetype/include/freetype/fterrors.h
deleted file mode 100644
index 27c0ece5c1..0000000000
--- a/contrib/libs/freetype/include/freetype/fterrors.h
+++ /dev/null
@@ -1,296 +0,0 @@
-/****************************************************************************
- *
- * fterrors.h
- *
- * FreeType error code handling (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /**************************************************************************
- *
- * @section:
- * error_enumerations
- *
- * @title:
- * Error Enumerations
- *
- * @abstract:
- * How to handle errors and error strings.
- *
- * @description:
- * The header file `fterrors.h` (which is automatically included by
- * `freetype.h`) defines the handling of FreeType's enumeration
- * constants. It can also be used to generate error message strings
- * with a small macro trick explained below.
- *
- * **Error Formats**
- *
- * The configuration macro `FT_CONFIG_OPTION_USE_MODULE_ERRORS` can be
- * defined in `ftoption.h` in order to make the higher byte indicate the
- * module where the error has happened (this is not compatible with
- * standard builds of FreeType~2, however). See the file `ftmoderr.h`
- * for more details.
- *
- * **Error Message Strings**
- *
- * Error definitions are set up with special macros that allow client
- * applications to build a table of error message strings. The strings
- * are not included in a normal build of FreeType~2 to save space (most
- * client applications do not use them).
- *
- * To do so, you have to define the following macros before including
- * this file.
- *
- * ```
- * FT_ERROR_START_LIST
- * ```
- *
- * This macro is called before anything else to define the start of the
- * error list. It is followed by several `FT_ERROR_DEF` calls.
- *
- * ```
- * FT_ERROR_DEF( e, v, s )
- * ```
- *
- * This macro is called to define one single error. 'e' is the error
- * code identifier (e.g., `Invalid_Argument`), 'v' is the error's
- * numerical value, and 's' is the corresponding error string.
- *
- * ```
- * FT_ERROR_END_LIST
- * ```
- *
- * This macro ends the list.
- *
- * Additionally, you have to undefine `FTERRORS_H_` before #including
- * this file.
- *
- * Here is a simple example.
- *
- * ```
- * #undef FTERRORS_H_
- * #define FT_ERRORDEF( e, v, s ) { e, s },
- * #define FT_ERROR_START_LIST {
- * #define FT_ERROR_END_LIST { 0, NULL } };
- *
- * const struct
- * {
- * int err_code;
- * const char* err_msg;
- * } ft_errors[] =
- *
- * #include <freetype/fterrors.h>
- * ```
- *
- * An alternative to using an array is a switch statement.
- *
- * ```
- * #undef FTERRORS_H_
- * #define FT_ERROR_START_LIST switch ( error_code ) {
- * #define FT_ERRORDEF( e, v, s ) case v: return s;
- * #define FT_ERROR_END_LIST }
- * ```
- *
- * If you use `FT_CONFIG_OPTION_USE_MODULE_ERRORS`, `error_code` should
- * be replaced with `FT_ERROR_BASE(error_code)` in the last example.
- */
-
- /* */
-
- /* In previous FreeType versions we used `__FTERRORS_H__`. However, */
- /* using two successive underscores in a non-system symbol name */
- /* violates the C (and C++) standard, so it was changed to the */
- /* current form. In spite of this, we have to make */
- /* */
- /* ``` */
- /* #undefine __FTERRORS_H__ */
- /* ``` */
- /* */
- /* work for backward compatibility. */
- /* */
-#if !( defined( FTERRORS_H_ ) && defined ( __FTERRORS_H__ ) )
-#define FTERRORS_H_
-#define __FTERRORS_H__
-
-
- /* include module base error codes */
-#include <freetype/ftmoderr.h>
-
-
- /*******************************************************************/
- /*******************************************************************/
- /***** *****/
- /***** SETUP MACROS *****/
- /***** *****/
- /*******************************************************************/
- /*******************************************************************/
-
-
-#undef FT_NEED_EXTERN_C
-
-
- /* FT_ERR_PREFIX is used as a prefix for error identifiers. */
- /* By default, we use `FT_Err_`. */
- /* */
-#ifndef FT_ERR_PREFIX
-#define FT_ERR_PREFIX FT_Err_
-#endif
-
-
- /* FT_ERR_BASE is used as the base for module-specific errors. */
- /* */
-#ifdef FT_CONFIG_OPTION_USE_MODULE_ERRORS
-
-#ifndef FT_ERR_BASE
-#define FT_ERR_BASE FT_Mod_Err_Base
-#endif
-
-#else
-
-#undef FT_ERR_BASE
-#define FT_ERR_BASE 0
-
-#endif /* FT_CONFIG_OPTION_USE_MODULE_ERRORS */
-
-
- /* If FT_ERRORDEF is not defined, we need to define a simple */
- /* enumeration type. */
- /* */
-#ifndef FT_ERRORDEF
-
-#define FT_INCLUDE_ERR_PROTOS
-
-#define FT_ERRORDEF( e, v, s ) e = v,
-#define FT_ERROR_START_LIST enum {
-#define FT_ERROR_END_LIST FT_ERR_CAT( FT_ERR_PREFIX, Max ) };
-
-#ifdef __cplusplus
-#define FT_NEED_EXTERN_C
- extern "C" {
-#endif
-
-#endif /* !FT_ERRORDEF */
-
-
- /* this macro is used to define an error */
-#define FT_ERRORDEF_( e, v, s ) \
- FT_ERRORDEF( FT_ERR_CAT( FT_ERR_PREFIX, e ), v + FT_ERR_BASE, s )
-
- /* this is only used for <module>_Err_Ok, which must be 0! */
-#define FT_NOERRORDEF_( e, v, s ) \
- FT_ERRORDEF( FT_ERR_CAT( FT_ERR_PREFIX, e ), v, s )
-
-
-#ifdef FT_ERROR_START_LIST
- FT_ERROR_START_LIST
-#endif
-
-
- /* now include the error codes */
-#include <freetype/fterrdef.h>
-
-
-#ifdef FT_ERROR_END_LIST
- FT_ERROR_END_LIST
-#endif
-
-
- /*******************************************************************/
- /*******************************************************************/
- /***** *****/
- /***** SIMPLE CLEANUP *****/
- /***** *****/
- /*******************************************************************/
- /*******************************************************************/
-
-#ifdef FT_NEED_EXTERN_C
- }
-#endif
-
-#undef FT_ERROR_START_LIST
-#undef FT_ERROR_END_LIST
-
-#undef FT_ERRORDEF
-#undef FT_ERRORDEF_
-#undef FT_NOERRORDEF_
-
-#undef FT_NEED_EXTERN_C
-#undef FT_ERR_BASE
-
- /* FT_ERR_PREFIX is needed internally */
-#ifndef FT2_BUILD_LIBRARY
-#undef FT_ERR_PREFIX
-#endif
-
- /* FT_INCLUDE_ERR_PROTOS: Control whether function prototypes should be */
- /* included with */
- /* */
- /* #include <freetype/fterrors.h> */
- /* */
- /* This is only true where `FT_ERRORDEF` is */
- /* undefined. */
- /* */
- /* FT_ERR_PROTOS_DEFINED: Actual multiple-inclusion protection of */
- /* `fterrors.h`. */
-#ifdef FT_INCLUDE_ERR_PROTOS
-#undef FT_INCLUDE_ERR_PROTOS
-
-#ifndef FT_ERR_PROTOS_DEFINED
-#define FT_ERR_PROTOS_DEFINED
-
-
-FT_BEGIN_HEADER
-
- /**************************************************************************
- *
- * @function:
- * FT_Error_String
- *
- * @description:
- * Retrieve the description of a valid FreeType error code.
- *
- * @input:
- * error_code ::
- * A valid FreeType error code.
- *
- * @return:
- * A C~string or `NULL`, if any error occurred.
- *
- * @note:
- * FreeType has to be compiled with `FT_CONFIG_OPTION_ERROR_STRINGS` or
- * `FT_DEBUG_LEVEL_ERROR` to get meaningful descriptions.
- * 'error_string' will be `NULL` otherwise.
- *
- * Module identification will be ignored:
- *
- * ```c
- * strcmp( FT_Error_String( FT_Err_Unknown_File_Format ),
- * FT_Error_String( BDF_Err_Unknown_File_Format ) ) == 0;
- * ```
- */
- FT_EXPORT( const char* )
- FT_Error_String( FT_Error error_code );
-
- /* */
-
-FT_END_HEADER
-
-
-#endif /* FT_ERR_PROTOS_DEFINED */
-
-#endif /* FT_INCLUDE_ERR_PROTOS */
-
-#endif /* !(FTERRORS_H_ && __FTERRORS_H__) */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/ftfntfmt.h b/contrib/libs/freetype/include/freetype/ftfntfmt.h
deleted file mode 100644
index 7c8b0874a8..0000000000
--- a/contrib/libs/freetype/include/freetype/ftfntfmt.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/****************************************************************************
- *
- * ftfntfmt.h
- *
- * Support functions for font formats.
- *
- * Copyright (C) 2002-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTFNTFMT_H_
-#define FTFNTFMT_H_
-
-#include <freetype/freetype.h>
-
-#ifdef FREETYPE_H
-#error "freetype.h of FreeType 1 has been loaded!"
-#error "Please fix the directory search order for header files"
-#error "so that freetype.h of FreeType 2 is found first."
-#endif
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @section:
- * font_formats
- *
- * @title:
- * Font Formats
- *
- * @abstract:
- * Getting the font format.
- *
- * @description:
- * The single function in this section can be used to get the font format.
- * Note that this information is not needed normally; however, there are
- * special cases (like in PDF devices) where it is important to
- * differentiate, in spite of FreeType's uniform API.
- *
- */
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_Font_Format
- *
- * @description:
- * Return a string describing the format of a given face. Possible values
- * are 'TrueType', 'Type~1', 'BDF', 'PCF', 'Type~42', 'CID~Type~1', 'CFF',
- * 'PFR', and 'Windows~FNT'.
- *
- * The return value is suitable to be used as an X11 FONT_PROPERTY.
- *
- * @input:
- * face ::
- * Input face handle.
- *
- * @return:
- * Font format string. `NULL` in case of error.
- *
- * @note:
- * A deprecated name for the same function is `FT_Get_X11_Font_Format`.
- */
- FT_EXPORT( const char* )
- FT_Get_Font_Format( FT_Face face );
-
-
- /* deprecated */
- FT_EXPORT( const char* )
- FT_Get_X11_Font_Format( FT_Face face );
-
-
- /* */
-
-
-FT_END_HEADER
-
-#endif /* FTFNTFMT_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/ftgasp.h b/contrib/libs/freetype/include/freetype/ftgasp.h
deleted file mode 100644
index 30e5a9bf82..0000000000
--- a/contrib/libs/freetype/include/freetype/ftgasp.h
+++ /dev/null
@@ -1,143 +0,0 @@
-/****************************************************************************
- *
- * ftgasp.h
- *
- * Access of TrueType's 'gasp' table (specification).
- *
- * Copyright (C) 2007-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTGASP_H_
-#define FTGASP_H_
-
-#include <freetype/freetype.h>
-
-#ifdef FREETYPE_H
-#error "freetype.h of FreeType 1 has been loaded!"
-#error "Please fix the directory search order for header files"
-#error "so that freetype.h of FreeType 2 is found first."
-#endif
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @section:
- * gasp_table
- *
- * @title:
- * Gasp Table
- *
- * @abstract:
- * Retrieving TrueType 'gasp' table entries.
- *
- * @description:
- * The function @FT_Get_Gasp can be used to query a TrueType or OpenType
- * font for specific entries in its 'gasp' table, if any. This is mainly
- * useful when implementing native TrueType hinting with the bytecode
- * interpreter to duplicate the Windows text rendering results.
- */
-
- /**************************************************************************
- *
- * @enum:
- * FT_GASP_XXX
- *
- * @description:
- * A list of values and/or bit-flags returned by the @FT_Get_Gasp
- * function.
- *
- * @values:
- * FT_GASP_NO_TABLE ::
- * This special value means that there is no GASP table in this face.
- * It is up to the client to decide what to do.
- *
- * FT_GASP_DO_GRIDFIT ::
- * Grid-fitting and hinting should be performed at the specified ppem.
- * This **really** means TrueType bytecode interpretation. If this bit
- * is not set, no hinting gets applied.
- *
- * FT_GASP_DO_GRAY ::
- * Anti-aliased rendering should be performed at the specified ppem.
- * If not set, do monochrome rendering.
- *
- * FT_GASP_SYMMETRIC_SMOOTHING ::
- * If set, smoothing along multiple axes must be used with ClearType.
- *
- * FT_GASP_SYMMETRIC_GRIDFIT ::
- * Grid-fitting must be used with ClearType's symmetric smoothing.
- *
- * @note:
- * The bit-flags `FT_GASP_DO_GRIDFIT` and `FT_GASP_DO_GRAY` are to be
- * used for standard font rasterization only. Independently of that,
- * `FT_GASP_SYMMETRIC_SMOOTHING` and `FT_GASP_SYMMETRIC_GRIDFIT` are to
- * be used if ClearType is enabled (and `FT_GASP_DO_GRIDFIT` and
- * `FT_GASP_DO_GRAY` are consequently ignored).
- *
- * 'ClearType' is Microsoft's implementation of LCD rendering, partly
- * protected by patents.
- *
- * @since:
- * 2.3.0
- */
-#define FT_GASP_NO_TABLE -1
-#define FT_GASP_DO_GRIDFIT 0x01
-#define FT_GASP_DO_GRAY 0x02
-#define FT_GASP_SYMMETRIC_GRIDFIT 0x04
-#define FT_GASP_SYMMETRIC_SMOOTHING 0x08
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_Gasp
- *
- * @description:
- * For a TrueType or OpenType font file, return the rasterizer behaviour
- * flags from the font's 'gasp' table corresponding to a given character
- * pixel size.
- *
- * @input:
- * face ::
- * The source face handle.
- *
- * ppem ::
- * The vertical character pixel size.
- *
- * @return:
- * Bit flags (see @FT_GASP_XXX), or @FT_GASP_NO_TABLE if there is no
- * 'gasp' table in the face.
- *
- * @note:
- * If you want to use the MM functionality of OpenType variation fonts
- * (i.e., using @FT_Set_Var_Design_Coordinates and friends), call this
- * function **after** setting an instance since the return values can
- * change.
- *
- * @since:
- * 2.3.0
- */
- FT_EXPORT( FT_Int )
- FT_Get_Gasp( FT_Face face,
- FT_UInt ppem );
-
- /* */
-
-
-FT_END_HEADER
-
-#endif /* FTGASP_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/ftglyph.h b/contrib/libs/freetype/include/freetype/ftglyph.h
deleted file mode 100644
index dc1eb8873a..0000000000
--- a/contrib/libs/freetype/include/freetype/ftglyph.h
+++ /dev/null
@@ -1,750 +0,0 @@
-/****************************************************************************
- *
- * ftglyph.h
- *
- * FreeType convenience functions to handle glyphs (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /**************************************************************************
- *
- * This file contains the definition of several convenience functions that
- * can be used by client applications to easily retrieve glyph bitmaps and
- * outlines from a given face.
- *
- * These functions should be optional if you are writing a font server or
- * text layout engine on top of FreeType. However, they are pretty handy
- * for many other simple uses of the library.
- *
- */
-
-
-#ifndef FTGLYPH_H_
-#define FTGLYPH_H_
-
-
-#include <freetype/freetype.h>
-
-#ifdef FREETYPE_H
-#error "freetype.h of FreeType 1 has been loaded!"
-#error "Please fix the directory search order for header files"
-#error "so that freetype.h of FreeType 2 is found first."
-#endif
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @section:
- * glyph_management
- *
- * @title:
- * Glyph Management
- *
- * @abstract:
- * Generic interface to manage individual glyph data.
- *
- * @description:
- * This section contains definitions used to manage glyph data through
- * generic @FT_Glyph objects. Each of them can contain a bitmap,
- * a vector outline, or even images in other formats. These objects are
- * detached from @FT_Face, contrary to @FT_GlyphSlot.
- *
- */
-
-
- /* forward declaration to a private type */
- typedef struct FT_Glyph_Class_ FT_Glyph_Class;
-
-
- /**************************************************************************
- *
- * @type:
- * FT_Glyph
- *
- * @description:
- * Handle to an object used to model generic glyph images. It is a
- * pointer to the @FT_GlyphRec structure and can contain a glyph bitmap
- * or pointer.
- *
- * @note:
- * Glyph objects are not owned by the library. You must thus release
- * them manually (through @FT_Done_Glyph) _before_ calling
- * @FT_Done_FreeType.
- */
- typedef struct FT_GlyphRec_* FT_Glyph;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_GlyphRec
- *
- * @description:
- * The root glyph structure contains a given glyph image plus its advance
- * width in 16.16 fixed-point format.
- *
- * @fields:
- * library ::
- * A handle to the FreeType library object.
- *
- * clazz ::
- * A pointer to the glyph's class. Private.
- *
- * format ::
- * The format of the glyph's image.
- *
- * advance ::
- * A 16.16 vector that gives the glyph's advance width.
- */
- typedef struct FT_GlyphRec_
- {
- FT_Library library;
- const FT_Glyph_Class* clazz;
- FT_Glyph_Format format;
- FT_Vector advance;
-
- } FT_GlyphRec;
-
-
- /**************************************************************************
- *
- * @type:
- * FT_BitmapGlyph
- *
- * @description:
- * A handle to an object used to model a bitmap glyph image. This is a
- * 'sub-class' of @FT_Glyph, and a pointer to @FT_BitmapGlyphRec.
- */
- typedef struct FT_BitmapGlyphRec_* FT_BitmapGlyph;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_BitmapGlyphRec
- *
- * @description:
- * A structure used for bitmap glyph images. This really is a
- * 'sub-class' of @FT_GlyphRec.
- *
- * @fields:
- * root ::
- * The root fields of @FT_Glyph.
- *
- * left ::
- * The left-side bearing, i.e., the horizontal distance from the
- * current pen position to the left border of the glyph bitmap.
- *
- * top ::
- * The top-side bearing, i.e., the vertical distance from the current
- * pen position to the top border of the glyph bitmap. This distance
- * is positive for upwards~y!
- *
- * bitmap ::
- * A descriptor for the bitmap.
- *
- * @note:
- * You can typecast an @FT_Glyph to @FT_BitmapGlyph if you have
- * `glyph->format == FT_GLYPH_FORMAT_BITMAP`. This lets you access the
- * bitmap's contents easily.
- *
- * The corresponding pixel buffer is always owned by @FT_BitmapGlyph and
- * is thus created and destroyed with it.
- */
- typedef struct FT_BitmapGlyphRec_
- {
- FT_GlyphRec root;
- FT_Int left;
- FT_Int top;
- FT_Bitmap bitmap;
-
- } FT_BitmapGlyphRec;
-
-
- /**************************************************************************
- *
- * @type:
- * FT_OutlineGlyph
- *
- * @description:
- * A handle to an object used to model an outline glyph image. This is a
- * 'sub-class' of @FT_Glyph, and a pointer to @FT_OutlineGlyphRec.
- */
- typedef struct FT_OutlineGlyphRec_* FT_OutlineGlyph;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_OutlineGlyphRec
- *
- * @description:
- * A structure used for outline (vectorial) glyph images. This really is
- * a 'sub-class' of @FT_GlyphRec.
- *
- * @fields:
- * root ::
- * The root @FT_Glyph fields.
- *
- * outline ::
- * A descriptor for the outline.
- *
- * @note:
- * You can typecast an @FT_Glyph to @FT_OutlineGlyph if you have
- * `glyph->format == FT_GLYPH_FORMAT_OUTLINE`. This lets you access the
- * outline's content easily.
- *
- * As the outline is extracted from a glyph slot, its coordinates are
- * expressed normally in 26.6 pixels, unless the flag @FT_LOAD_NO_SCALE
- * was used in @FT_Load_Glyph or @FT_Load_Char.
- *
- * The outline's tables are always owned by the object and are destroyed
- * with it.
- */
- typedef struct FT_OutlineGlyphRec_
- {
- FT_GlyphRec root;
- FT_Outline outline;
-
- } FT_OutlineGlyphRec;
-
-
- /**************************************************************************
- *
- * @type:
- * FT_SvgGlyph
- *
- * @description:
- * A handle to an object used to model an SVG glyph. This is a
- * 'sub-class' of @FT_Glyph, and a pointer to @FT_SvgGlyphRec.
- *
- * @since:
- * 2.12
- */
- typedef struct FT_SvgGlyphRec_* FT_SvgGlyph;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_SvgGlyphRec
- *
- * @description:
- * A structure used for OT-SVG glyphs. This is a 'sub-class' of
- * @FT_GlyphRec.
- *
- * @fields:
- * root ::
- * The root @FT_GlyphRec fields.
- *
- * svg_document ::
- * A pointer to the SVG document.
- *
- * svg_document_length ::
- * The length of `svg_document`.
- *
- * glyph_index ::
- * The index of the glyph to be rendered.
- *
- * metrics ::
- * A metrics object storing the size information.
- *
- * units_per_EM ::
- * The size of the EM square.
- *
- * start_glyph_id ::
- * The first glyph ID in the glyph range covered by this document.
- *
- * end_glyph_id ::
- * The last glyph ID in the glyph range covered by this document.
- *
- * transform ::
- * A 2x2 transformation matrix to apply to the glyph while rendering
- * it.
- *
- * delta ::
- * Translation to apply to the glyph while rendering.
- *
- * @note:
- * The Glyph Management API requires @FT_Glyph or its 'sub-class' to have
- * all the information needed to completely define the glyph's rendering.
- * Outline-based glyphs can directly apply transformations to the outline
- * but this is not possible for an SVG document that hasn't been parsed.
- * Therefore, the transformation is stored along with the document. In
- * the absence of a 'ViewBox' or 'Width'/'Height' attribute, the size of
- * the ViewPort should be assumed to be 'units_per_EM'.
- */
- typedef struct FT_SvgGlyphRec_
- {
- FT_GlyphRec root;
-
- FT_Byte* svg_document;
- FT_ULong svg_document_length;
-
- FT_UInt glyph_index;
-
- FT_Size_Metrics metrics;
- FT_UShort units_per_EM;
-
- FT_UShort start_glyph_id;
- FT_UShort end_glyph_id;
-
- FT_Matrix transform;
- FT_Vector delta;
-
- } FT_SvgGlyphRec;
-
-
- /**************************************************************************
- *
- * @function:
- * FT_New_Glyph
- *
- * @description:
- * A function used to create a new empty glyph image. Note that the
- * created @FT_Glyph object must be released with @FT_Done_Glyph.
- *
- * @input:
- * library ::
- * A handle to the FreeType library object.
- *
- * format ::
- * The format of the glyph's image.
- *
- * @output:
- * aglyph ::
- * A handle to the glyph object.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @since:
- * 2.10
- */
- FT_EXPORT( FT_Error )
- FT_New_Glyph( FT_Library library,
- FT_Glyph_Format format,
- FT_Glyph *aglyph );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_Glyph
- *
- * @description:
- * A function used to extract a glyph image from a slot. Note that the
- * created @FT_Glyph object must be released with @FT_Done_Glyph.
- *
- * @input:
- * slot ::
- * A handle to the source glyph slot.
- *
- * @output:
- * aglyph ::
- * A handle to the glyph object. `NULL` in case of error.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * Because `*aglyph->advance.x` and `*aglyph->advance.y` are 16.16
- * fixed-point numbers, `slot->advance.x` and `slot->advance.y` (which
- * are in 26.6 fixed-point format) must be in the range ]-32768;32768[.
- */
- FT_EXPORT( FT_Error )
- FT_Get_Glyph( FT_GlyphSlot slot,
- FT_Glyph *aglyph );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Glyph_Copy
- *
- * @description:
- * A function used to copy a glyph image. Note that the created
- * @FT_Glyph object must be released with @FT_Done_Glyph.
- *
- * @input:
- * source ::
- * A handle to the source glyph object.
- *
- * @output:
- * target ::
- * A handle to the target glyph object. `NULL` in case of error.
- *
- * @return:
- * FreeType error code. 0~means success.
- */
- FT_EXPORT( FT_Error )
- FT_Glyph_Copy( FT_Glyph source,
- FT_Glyph *target );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Glyph_Transform
- *
- * @description:
- * Transform a glyph image if its format is scalable.
- *
- * @inout:
- * glyph ::
- * A handle to the target glyph object.
- *
- * @input:
- * matrix ::
- * A pointer to a 2x2 matrix to apply.
- *
- * delta ::
- * A pointer to a 2d vector to apply. Coordinates are expressed in
- * 1/64 of a pixel.
- *
- * @return:
- * FreeType error code (if not 0, the glyph format is not scalable).
- *
- * @note:
- * The 2x2 transformation matrix is also applied to the glyph's advance
- * vector.
- */
- FT_EXPORT( FT_Error )
- FT_Glyph_Transform( FT_Glyph glyph,
- const FT_Matrix* matrix,
- const FT_Vector* delta );
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_Glyph_BBox_Mode
- *
- * @description:
- * The mode how the values of @FT_Glyph_Get_CBox are returned.
- *
- * @values:
- * FT_GLYPH_BBOX_UNSCALED ::
- * Return unscaled font units.
- *
- * FT_GLYPH_BBOX_SUBPIXELS ::
- * Return unfitted 26.6 coordinates.
- *
- * FT_GLYPH_BBOX_GRIDFIT ::
- * Return grid-fitted 26.6 coordinates.
- *
- * FT_GLYPH_BBOX_TRUNCATE ::
- * Return coordinates in integer pixels.
- *
- * FT_GLYPH_BBOX_PIXELS ::
- * Return grid-fitted pixel coordinates.
- */
- typedef enum FT_Glyph_BBox_Mode_
- {
- FT_GLYPH_BBOX_UNSCALED = 0,
- FT_GLYPH_BBOX_SUBPIXELS = 0,
- FT_GLYPH_BBOX_GRIDFIT = 1,
- FT_GLYPH_BBOX_TRUNCATE = 2,
- FT_GLYPH_BBOX_PIXELS = 3
-
- } FT_Glyph_BBox_Mode;
-
-
- /* these constants are deprecated; use the corresponding */
- /* `FT_Glyph_BBox_Mode` values instead */
-#define ft_glyph_bbox_unscaled FT_GLYPH_BBOX_UNSCALED
-#define ft_glyph_bbox_subpixels FT_GLYPH_BBOX_SUBPIXELS
-#define ft_glyph_bbox_gridfit FT_GLYPH_BBOX_GRIDFIT
-#define ft_glyph_bbox_truncate FT_GLYPH_BBOX_TRUNCATE
-#define ft_glyph_bbox_pixels FT_GLYPH_BBOX_PIXELS
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Glyph_Get_CBox
- *
- * @description:
- * Return a glyph's 'control box'. The control box encloses all the
- * outline's points, including Bezier control points. Though it
- * coincides with the exact bounding box for most glyphs, it can be
- * slightly larger in some situations (like when rotating an outline that
- * contains Bezier outside arcs).
- *
- * Computing the control box is very fast, while getting the bounding box
- * can take much more time as it needs to walk over all segments and arcs
- * in the outline. To get the latter, you can use the 'ftbbox'
- * component, which is dedicated to this single task.
- *
- * @input:
- * glyph ::
- * A handle to the source glyph object.
- *
- * mode ::
- * The mode that indicates how to interpret the returned bounding box
- * values.
- *
- * @output:
- * acbox ::
- * The glyph coordinate bounding box. Coordinates are expressed in
- * 1/64 of pixels if it is grid-fitted.
- *
- * @note:
- * Coordinates are relative to the glyph origin, using the y~upwards
- * convention.
- *
- * If the glyph has been loaded with @FT_LOAD_NO_SCALE, `bbox_mode` must
- * be set to @FT_GLYPH_BBOX_UNSCALED to get unscaled font units in 26.6
- * pixel format. The value @FT_GLYPH_BBOX_SUBPIXELS is another name for
- * this constant.
- *
- * If the font is tricky and the glyph has been loaded with
- * @FT_LOAD_NO_SCALE, the resulting CBox is meaningless. To get
- * reasonable values for the CBox it is necessary to load the glyph at a
- * large ppem value (so that the hinting instructions can properly shift
- * and scale the subglyphs), then extracting the CBox, which can be
- * eventually converted back to font units.
- *
- * Note that the maximum coordinates are exclusive, which means that one
- * can compute the width and height of the glyph image (be it in integer
- * or 26.6 pixels) as:
- *
- * ```
- * width = bbox.xMax - bbox.xMin;
- * height = bbox.yMax - bbox.yMin;
- * ```
- *
- * Note also that for 26.6 coordinates, if `bbox_mode` is set to
- * @FT_GLYPH_BBOX_GRIDFIT, the coordinates will also be grid-fitted,
- * which corresponds to:
- *
- * ```
- * bbox.xMin = FLOOR(bbox.xMin);
- * bbox.yMin = FLOOR(bbox.yMin);
- * bbox.xMax = CEILING(bbox.xMax);
- * bbox.yMax = CEILING(bbox.yMax);
- * ```
- *
- * To get the bbox in pixel coordinates, set `bbox_mode` to
- * @FT_GLYPH_BBOX_TRUNCATE.
- *
- * To get the bbox in grid-fitted pixel coordinates, set `bbox_mode` to
- * @FT_GLYPH_BBOX_PIXELS.
- */
- FT_EXPORT( void )
- FT_Glyph_Get_CBox( FT_Glyph glyph,
- FT_UInt bbox_mode,
- FT_BBox *acbox );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Glyph_To_Bitmap
- *
- * @description:
- * Convert a given glyph object to a bitmap glyph object.
- *
- * @inout:
- * the_glyph ::
- * A pointer to a handle to the target glyph.
- *
- * @input:
- * render_mode ::
- * An enumeration that describes how the data is rendered.
- *
- * origin ::
- * A pointer to a vector used to translate the glyph image before
- * rendering. Can be~0 (if no translation). The origin is expressed
- * in 26.6 pixels.
- *
- * destroy ::
- * A boolean that indicates that the original glyph image should be
- * destroyed by this function. It is never destroyed in case of error.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * This function does nothing if the glyph format isn't scalable.
- *
- * The glyph image is translated with the `origin` vector before
- * rendering.
- *
- * The first parameter is a pointer to an @FT_Glyph handle that will be
- * _replaced_ by this function (with newly allocated data). Typically,
- * you would do something like the following (omitting error handling).
- *
- * ```
- * FT_Glyph glyph;
- * FT_BitmapGlyph glyph_bitmap;
- *
- *
- * // load glyph
- * error = FT_Load_Char( face, glyph_index, FT_LOAD_DEFAULT );
- *
- * // extract glyph image
- * error = FT_Get_Glyph( face->glyph, &glyph );
- *
- * // convert to a bitmap (default render mode + destroying old)
- * if ( glyph->format != FT_GLYPH_FORMAT_BITMAP )
- * {
- * error = FT_Glyph_To_Bitmap( &glyph, FT_RENDER_MODE_NORMAL,
- * 0, 1 );
- * if ( error ) // `glyph' unchanged
- * ...
- * }
- *
- * // access bitmap content by typecasting
- * glyph_bitmap = (FT_BitmapGlyph)glyph;
- *
- * // do funny stuff with it, like blitting/drawing
- * ...
- *
- * // discard glyph image (bitmap or not)
- * FT_Done_Glyph( glyph );
- * ```
- *
- * Here is another example, again without error handling.
- *
- * ```
- * FT_Glyph glyphs[MAX_GLYPHS]
- *
- *
- * ...
- *
- * for ( idx = 0; i < MAX_GLYPHS; i++ )
- * error = FT_Load_Glyph( face, idx, FT_LOAD_DEFAULT ) ||
- * FT_Get_Glyph ( face->glyph, &glyphs[idx] );
- *
- * ...
- *
- * for ( idx = 0; i < MAX_GLYPHS; i++ )
- * {
- * FT_Glyph bitmap = glyphs[idx];
- *
- *
- * ...
- *
- * // after this call, `bitmap' no longer points into
- * // the `glyphs' array (and the old value isn't destroyed)
- * FT_Glyph_To_Bitmap( &bitmap, FT_RENDER_MODE_MONO, 0, 0 );
- *
- * ...
- *
- * FT_Done_Glyph( bitmap );
- * }
- *
- * ...
- *
- * for ( idx = 0; i < MAX_GLYPHS; i++ )
- * FT_Done_Glyph( glyphs[idx] );
- * ```
- */
- FT_EXPORT( FT_Error )
- FT_Glyph_To_Bitmap( FT_Glyph* the_glyph,
- FT_Render_Mode render_mode,
- const FT_Vector* origin,
- FT_Bool destroy );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Done_Glyph
- *
- * @description:
- * Destroy a given glyph.
- *
- * @input:
- * glyph ::
- * A handle to the target glyph object. Can be `NULL`.
- */
- FT_EXPORT( void )
- FT_Done_Glyph( FT_Glyph glyph );
-
- /* */
-
-
- /* other helpful functions */
-
- /**************************************************************************
- *
- * @section:
- * computations
- *
- */
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Matrix_Multiply
- *
- * @description:
- * Perform the matrix operation `b = a*b`.
- *
- * @input:
- * a ::
- * A pointer to matrix `a`.
- *
- * @inout:
- * b ::
- * A pointer to matrix `b`.
- *
- * @note:
- * The result is undefined if either `a` or `b` is zero.
- *
- * Since the function uses wrap-around arithmetic, results become
- * meaningless if the arguments are very large.
- */
- FT_EXPORT( void )
- FT_Matrix_Multiply( const FT_Matrix* a,
- FT_Matrix* b );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Matrix_Invert
- *
- * @description:
- * Invert a 2x2 matrix. Return an error if it can't be inverted.
- *
- * @inout:
- * matrix ::
- * A pointer to the target matrix. Remains untouched in case of error.
- *
- * @return:
- * FreeType error code. 0~means success.
- */
- FT_EXPORT( FT_Error )
- FT_Matrix_Invert( FT_Matrix* matrix );
-
- /* */
-
-
-FT_END_HEADER
-
-#endif /* FTGLYPH_H_ */
-
-
-/* END */
-
-
-/* Local Variables: */
-/* coding: utf-8 */
-/* End: */
diff --git a/contrib/libs/freetype/include/freetype/ftgxval.h b/contrib/libs/freetype/include/freetype/ftgxval.h
deleted file mode 100644
index 065cd53cc5..0000000000
--- a/contrib/libs/freetype/include/freetype/ftgxval.h
+++ /dev/null
@@ -1,354 +0,0 @@
-/****************************************************************************
- *
- * ftgxval.h
- *
- * FreeType API for validating TrueTypeGX/AAT tables (specification).
- *
- * Copyright (C) 2004-2024 by
- * Masatake YAMATO, Redhat K.K,
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-/****************************************************************************
- *
- * gxvalid is derived from both gxlayout module and otvalid module.
- * Development of gxlayout is supported by the Information-technology
- * Promotion Agency(IPA), Japan.
- *
- */
-
-
-#ifndef FTGXVAL_H_
-#define FTGXVAL_H_
-
-#include <freetype/freetype.h>
-
-#ifdef FREETYPE_H
-#error "freetype.h of FreeType 1 has been loaded!"
-#error "Please fix the directory search order for header files"
-#error "so that freetype.h of FreeType 2 is found first."
-#endif
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @section:
- * gx_validation
- *
- * @title:
- * TrueTypeGX/AAT Validation
- *
- * @abstract:
- * An API to validate TrueTypeGX/AAT tables.
- *
- * @description:
- * This section contains the declaration of functions to validate some
- * TrueTypeGX tables (feat, mort, morx, bsln, just, kern, opbd, trak,
- * prop, lcar).
- *
- * @order:
- * FT_TrueTypeGX_Validate
- * FT_TrueTypeGX_Free
- *
- * FT_ClassicKern_Validate
- * FT_ClassicKern_Free
- *
- * FT_VALIDATE_GX_LENGTH
- * FT_VALIDATE_GXXXX
- * FT_VALIDATE_CKERNXXX
- *
- */
-
- /**************************************************************************
- *
- *
- * Warning: Use `FT_VALIDATE_XXX` to validate a table.
- * Following definitions are for gxvalid developers.
- *
- *
- */
-
-#define FT_VALIDATE_feat_INDEX 0
-#define FT_VALIDATE_mort_INDEX 1
-#define FT_VALIDATE_morx_INDEX 2
-#define FT_VALIDATE_bsln_INDEX 3
-#define FT_VALIDATE_just_INDEX 4
-#define FT_VALIDATE_kern_INDEX 5
-#define FT_VALIDATE_opbd_INDEX 6
-#define FT_VALIDATE_trak_INDEX 7
-#define FT_VALIDATE_prop_INDEX 8
-#define FT_VALIDATE_lcar_INDEX 9
-#define FT_VALIDATE_GX_LAST_INDEX FT_VALIDATE_lcar_INDEX
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_VALIDATE_GX_LENGTH
- *
- * @description:
- * The number of tables checked in this module. Use it as a parameter
- * for the `table-length` argument of function @FT_TrueTypeGX_Validate.
- */
-#define FT_VALIDATE_GX_LENGTH ( FT_VALIDATE_GX_LAST_INDEX + 1 )
-
- /* */
-
- /* Up to 0x1000 is used by otvalid.
- Ox2xxx is reserved for feature OT extension. */
-#define FT_VALIDATE_GX_START 0x4000
-#define FT_VALIDATE_GX_BITFIELD( tag ) \
- ( FT_VALIDATE_GX_START << FT_VALIDATE_##tag##_INDEX )
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_VALIDATE_GXXXX
- *
- * @description:
- * A list of bit-field constants used with @FT_TrueTypeGX_Validate to
- * indicate which TrueTypeGX/AAT Type tables should be validated.
- *
- * @values:
- * FT_VALIDATE_feat ::
- * Validate 'feat' table.
- *
- * FT_VALIDATE_mort ::
- * Validate 'mort' table.
- *
- * FT_VALIDATE_morx ::
- * Validate 'morx' table.
- *
- * FT_VALIDATE_bsln ::
- * Validate 'bsln' table.
- *
- * FT_VALIDATE_just ::
- * Validate 'just' table.
- *
- * FT_VALIDATE_kern ::
- * Validate 'kern' table.
- *
- * FT_VALIDATE_opbd ::
- * Validate 'opbd' table.
- *
- * FT_VALIDATE_trak ::
- * Validate 'trak' table.
- *
- * FT_VALIDATE_prop ::
- * Validate 'prop' table.
- *
- * FT_VALIDATE_lcar ::
- * Validate 'lcar' table.
- *
- * FT_VALIDATE_GX ::
- * Validate all TrueTypeGX tables (feat, mort, morx, bsln, just, kern,
- * opbd, trak, prop and lcar).
- *
- */
-
-#define FT_VALIDATE_feat FT_VALIDATE_GX_BITFIELD( feat )
-#define FT_VALIDATE_mort FT_VALIDATE_GX_BITFIELD( mort )
-#define FT_VALIDATE_morx FT_VALIDATE_GX_BITFIELD( morx )
-#define FT_VALIDATE_bsln FT_VALIDATE_GX_BITFIELD( bsln )
-#define FT_VALIDATE_just FT_VALIDATE_GX_BITFIELD( just )
-#define FT_VALIDATE_kern FT_VALIDATE_GX_BITFIELD( kern )
-#define FT_VALIDATE_opbd FT_VALIDATE_GX_BITFIELD( opbd )
-#define FT_VALIDATE_trak FT_VALIDATE_GX_BITFIELD( trak )
-#define FT_VALIDATE_prop FT_VALIDATE_GX_BITFIELD( prop )
-#define FT_VALIDATE_lcar FT_VALIDATE_GX_BITFIELD( lcar )
-
-#define FT_VALIDATE_GX ( FT_VALIDATE_feat | \
- FT_VALIDATE_mort | \
- FT_VALIDATE_morx | \
- FT_VALIDATE_bsln | \
- FT_VALIDATE_just | \
- FT_VALIDATE_kern | \
- FT_VALIDATE_opbd | \
- FT_VALIDATE_trak | \
- FT_VALIDATE_prop | \
- FT_VALIDATE_lcar )
-
-
- /**************************************************************************
- *
- * @function:
- * FT_TrueTypeGX_Validate
- *
- * @description:
- * Validate various TrueTypeGX tables to assure that all offsets and
- * indices are valid. The idea is that a higher-level library that
- * actually does the text layout can access those tables without error
- * checking (which can be quite time consuming).
- *
- * @input:
- * face ::
- * A handle to the input face.
- *
- * validation_flags ::
- * A bit field that specifies the tables to be validated. See
- * @FT_VALIDATE_GXXXX for possible values.
- *
- * table_length ::
- * The size of the `tables` array. Normally, @FT_VALIDATE_GX_LENGTH
- * should be passed.
- *
- * @output:
- * tables ::
- * The array where all validated sfnt tables are stored. The array
- * itself must be allocated by a client.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * This function only works with TrueTypeGX fonts, returning an error
- * otherwise.
- *
- * After use, the application should deallocate the buffers pointed to by
- * each `tables` element, by calling @FT_TrueTypeGX_Free. A `NULL` value
- * indicates that the table either doesn't exist in the font, the
- * application hasn't asked for validation, or the validator doesn't have
- * the ability to validate the sfnt table.
- */
- FT_EXPORT( FT_Error )
- FT_TrueTypeGX_Validate( FT_Face face,
- FT_UInt validation_flags,
- FT_Bytes tables[FT_VALIDATE_GX_LENGTH],
- FT_UInt table_length );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_TrueTypeGX_Free
- *
- * @description:
- * Free the buffer allocated by TrueTypeGX validator.
- *
- * @input:
- * face ::
- * A handle to the input face.
- *
- * table ::
- * The pointer to the buffer allocated by @FT_TrueTypeGX_Validate.
- *
- * @note:
- * This function must be used to free the buffer allocated by
- * @FT_TrueTypeGX_Validate only.
- */
- FT_EXPORT( void )
- FT_TrueTypeGX_Free( FT_Face face,
- FT_Bytes table );
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_VALIDATE_CKERNXXX
- *
- * @description:
- * A list of bit-field constants used with @FT_ClassicKern_Validate to
- * indicate the classic kern dialect or dialects. If the selected type
- * doesn't fit, @FT_ClassicKern_Validate regards the table as invalid.
- *
- * @values:
- * FT_VALIDATE_MS ::
- * Handle the 'kern' table as a classic Microsoft kern table.
- *
- * FT_VALIDATE_APPLE ::
- * Handle the 'kern' table as a classic Apple kern table.
- *
- * FT_VALIDATE_CKERN ::
- * Handle the 'kern' as either classic Apple or Microsoft kern table.
- */
-#define FT_VALIDATE_MS ( FT_VALIDATE_GX_START << 0 )
-#define FT_VALIDATE_APPLE ( FT_VALIDATE_GX_START << 1 )
-
-#define FT_VALIDATE_CKERN ( FT_VALIDATE_MS | FT_VALIDATE_APPLE )
-
-
- /**************************************************************************
- *
- * @function:
- * FT_ClassicKern_Validate
- *
- * @description:
- * Validate classic (16-bit format) kern table to assure that the
- * offsets and indices are valid. The idea is that a higher-level
- * library that actually does the text layout can access those tables
- * without error checking (which can be quite time consuming).
- *
- * The 'kern' table validator in @FT_TrueTypeGX_Validate deals with both
- * the new 32-bit format and the classic 16-bit format, while
- * FT_ClassicKern_Validate only supports the classic 16-bit format.
- *
- * @input:
- * face ::
- * A handle to the input face.
- *
- * validation_flags ::
- * A bit field that specifies the dialect to be validated. See
- * @FT_VALIDATE_CKERNXXX for possible values.
- *
- * @output:
- * ckern_table ::
- * A pointer to the kern table.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * After use, the application should deallocate the buffers pointed to by
- * `ckern_table`, by calling @FT_ClassicKern_Free. A `NULL` value
- * indicates that the table doesn't exist in the font.
- */
- FT_EXPORT( FT_Error )
- FT_ClassicKern_Validate( FT_Face face,
- FT_UInt validation_flags,
- FT_Bytes *ckern_table );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_ClassicKern_Free
- *
- * @description:
- * Free the buffer allocated by classic Kern validator.
- *
- * @input:
- * face ::
- * A handle to the input face.
- *
- * table ::
- * The pointer to the buffer that is allocated by
- * @FT_ClassicKern_Validate.
- *
- * @note:
- * This function must be used to free the buffer allocated by
- * @FT_ClassicKern_Validate only.
- */
- FT_EXPORT( void )
- FT_ClassicKern_Free( FT_Face face,
- FT_Bytes table );
-
- /* */
-
-
-FT_END_HEADER
-
-#endif /* FTGXVAL_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/ftgzip.h b/contrib/libs/freetype/include/freetype/ftgzip.h
deleted file mode 100644
index 9516dc030a..0000000000
--- a/contrib/libs/freetype/include/freetype/ftgzip.h
+++ /dev/null
@@ -1,151 +0,0 @@
-/****************************************************************************
- *
- * ftgzip.h
- *
- * Gzip-compressed stream support.
- *
- * Copyright (C) 2002-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTGZIP_H_
-#define FTGZIP_H_
-
-#include <freetype/freetype.h>
-
-#ifdef FREETYPE_H
-#error "freetype.h of FreeType 1 has been loaded!"
-#error "Please fix the directory search order for header files"
-#error "so that freetype.h of FreeType 2 is found first."
-#endif
-
-
-FT_BEGIN_HEADER
-
- /**************************************************************************
- *
- * @section:
- * gzip
- *
- * @title:
- * GZIP Streams
- *
- * @abstract:
- * Using gzip-compressed font files.
- *
- * @description:
- * In certain builds of the library, gzip compression recognition is
- * automatically handled when calling @FT_New_Face or @FT_Open_Face.
- * This means that if no font driver is capable of handling the raw
- * compressed file, the library will try to open a gzipped stream from it
- * and re-open the face with it.
- *
- * The stream implementation is very basic and resets the decompression
- * process each time seeking backwards is needed within the stream,
- * which significantly undermines the performance.
- *
- * This section contains the declaration of Gzip-specific functions.
- *
- */
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Stream_OpenGzip
- *
- * @description:
- * Open a new stream to parse gzip-compressed font files. This is mainly
- * used to support the compressed `*.pcf.gz` fonts that come with
- * XFree86.
- *
- * @input:
- * stream ::
- * The target embedding stream.
- *
- * source ::
- * The source stream.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * The source stream must be opened _before_ calling this function.
- *
- * Calling the internal function `FT_Stream_Close` on the new stream will
- * **not** call `FT_Stream_Close` on the source stream. None of the
- * stream objects will be released to the heap.
- *
- * This function may return `FT_Err_Unimplemented_Feature` if your build
- * of FreeType was not compiled with zlib support.
- */
- FT_EXPORT( FT_Error )
- FT_Stream_OpenGzip( FT_Stream stream,
- FT_Stream source );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Gzip_Uncompress
- *
- * @description:
- * Decompress a zipped input buffer into an output buffer. This function
- * is modeled after zlib's `uncompress` function.
- *
- * @input:
- * memory ::
- * A FreeType memory handle.
- *
- * input ::
- * The input buffer.
- *
- * input_len ::
- * The length of the input buffer.
- *
- * @output:
- * output ::
- * The output buffer.
- *
- * @inout:
- * output_len ::
- * Before calling the function, this is the total size of the output
- * buffer, which must be large enough to hold the entire uncompressed
- * data (so the size of the uncompressed data must be known in
- * advance). After calling the function, `output_len` is the size of
- * the used data in `output`.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * This function may return `FT_Err_Unimplemented_Feature` if your build
- * of FreeType was not compiled with zlib support.
- *
- * @since:
- * 2.5.1
- */
- FT_EXPORT( FT_Error )
- FT_Gzip_Uncompress( FT_Memory memory,
- FT_Byte* output,
- FT_ULong* output_len,
- const FT_Byte* input,
- FT_ULong input_len );
-
- /* */
-
-
-FT_END_HEADER
-
-#endif /* FTGZIP_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/ftimage.h b/contrib/libs/freetype/include/freetype/ftimage.h
deleted file mode 100644
index 2b4b4ac60a..0000000000
--- a/contrib/libs/freetype/include/freetype/ftimage.h
+++ /dev/null
@@ -1,1289 +0,0 @@
-/****************************************************************************
- *
- * ftimage.h
- *
- * FreeType glyph image formats and default raster interface
- * (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
- /**************************************************************************
- *
- * Note: A 'raster' is simply a scan-line converter, used to render
- * `FT_Outline`s into `FT_Bitmap`s.
- *
- * Note: This file can be used for `STANDALONE_` compilation of raster
- * (B/W) and smooth (anti-aliased) renderers. Therefore, it must
- * rely on standard variable types only instead of aliases in
- * `fttypes.h`.
- *
- */
-
-
-#ifndef FTIMAGE_H_
-#define FTIMAGE_H_
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @section:
- * basic_types
- *
- */
-
-
- /**************************************************************************
- *
- * @type:
- * FT_Pos
- *
- * @description:
- * The type FT_Pos is used to store vectorial coordinates. Depending on
- * the context, these can represent distances in integer font units, or
- * 16.16, or 26.6 fixed-point pixel coordinates.
- */
- typedef signed long FT_Pos;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_Vector
- *
- * @description:
- * A simple structure used to store a 2D vector; coordinates are of the
- * FT_Pos type.
- *
- * @fields:
- * x ::
- * The horizontal coordinate.
- * y ::
- * The vertical coordinate.
- */
- typedef struct FT_Vector_
- {
- FT_Pos x;
- FT_Pos y;
-
- } FT_Vector;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_BBox
- *
- * @description:
- * A structure used to hold an outline's bounding box, i.e., the
- * coordinates of its extrema in the horizontal and vertical directions.
- *
- * @fields:
- * xMin ::
- * The horizontal minimum (left-most).
- *
- * yMin ::
- * The vertical minimum (bottom-most).
- *
- * xMax ::
- * The horizontal maximum (right-most).
- *
- * yMax ::
- * The vertical maximum (top-most).
- *
- * @note:
- * The bounding box is specified with the coordinates of the lower left
- * and the upper right corner. In PostScript, those values are often
- * called (llx,lly) and (urx,ury), respectively.
- *
- * If `yMin` is negative, this value gives the glyph's descender.
- * Otherwise, the glyph doesn't descend below the baseline. Similarly,
- * if `ymax` is positive, this value gives the glyph's ascender.
- *
- * `xMin` gives the horizontal distance from the glyph's origin to the
- * left edge of the glyph's bounding box. If `xMin` is negative, the
- * glyph extends to the left of the origin.
- */
- typedef struct FT_BBox_
- {
- FT_Pos xMin, yMin;
- FT_Pos xMax, yMax;
-
- } FT_BBox;
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_Pixel_Mode
- *
- * @description:
- * An enumeration type used to describe the format of pixels in a given
- * bitmap. Note that additional formats may be added in the future.
- *
- * @values:
- * FT_PIXEL_MODE_NONE ::
- * Value~0 is reserved.
- *
- * FT_PIXEL_MODE_MONO ::
- * A monochrome bitmap, using 1~bit per pixel. Note that pixels are
- * stored in most-significant order (MSB), which means that the
- * left-most pixel in a byte has value 128.
- *
- * FT_PIXEL_MODE_GRAY ::
- * An 8-bit bitmap, generally used to represent anti-aliased glyph
- * images. Each pixel is stored in one byte. Note that the number of
- * 'gray' levels is stored in the `num_grays` field of the @FT_Bitmap
- * structure (it generally is 256).
- *
- * FT_PIXEL_MODE_GRAY2 ::
- * A 2-bit per pixel bitmap, used to represent embedded anti-aliased
- * bitmaps in font files according to the OpenType specification. We
- * haven't found a single font using this format, however.
- *
- * FT_PIXEL_MODE_GRAY4 ::
- * A 4-bit per pixel bitmap, representing embedded anti-aliased bitmaps
- * in font files according to the OpenType specification. We haven't
- * found a single font using this format, however.
- *
- * FT_PIXEL_MODE_LCD ::
- * An 8-bit bitmap, representing RGB or BGR decimated glyph images used
- * for display on LCD displays; the bitmap is three times wider than
- * the original glyph image. See also @FT_RENDER_MODE_LCD.
- *
- * FT_PIXEL_MODE_LCD_V ::
- * An 8-bit bitmap, representing RGB or BGR decimated glyph images used
- * for display on rotated LCD displays; the bitmap is three times
- * taller than the original glyph image. See also
- * @FT_RENDER_MODE_LCD_V.
- *
- * FT_PIXEL_MODE_BGRA ::
- * [Since 2.5] An image with four 8-bit channels per pixel,
- * representing a color image (such as emoticons) with alpha channel.
- * For each pixel, the format is BGRA, which means, the blue channel
- * comes first in memory. The color channels are pre-multiplied and in
- * the sRGB colorspace. For example, full red at half-translucent
- * opacity will be represented as '00,00,80,80', not '00,00,FF,80'.
- * See also @FT_LOAD_COLOR.
- */
- typedef enum FT_Pixel_Mode_
- {
- FT_PIXEL_MODE_NONE = 0,
- FT_PIXEL_MODE_MONO,
- FT_PIXEL_MODE_GRAY,
- FT_PIXEL_MODE_GRAY2,
- FT_PIXEL_MODE_GRAY4,
- FT_PIXEL_MODE_LCD,
- FT_PIXEL_MODE_LCD_V,
- FT_PIXEL_MODE_BGRA,
-
- FT_PIXEL_MODE_MAX /* do not remove */
-
- } FT_Pixel_Mode;
-
-
- /* these constants are deprecated; use the corresponding `FT_Pixel_Mode` */
- /* values instead. */
-#define ft_pixel_mode_none FT_PIXEL_MODE_NONE
-#define ft_pixel_mode_mono FT_PIXEL_MODE_MONO
-#define ft_pixel_mode_grays FT_PIXEL_MODE_GRAY
-#define ft_pixel_mode_pal2 FT_PIXEL_MODE_GRAY2
-#define ft_pixel_mode_pal4 FT_PIXEL_MODE_GRAY4
-
- /* */
-
- /* For debugging, the @FT_Pixel_Mode enumeration must stay in sync */
- /* with the `pixel_modes` array in file `ftobjs.c`. */
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_Bitmap
- *
- * @description:
- * A structure used to describe a bitmap or pixmap to the raster. Note
- * that we now manage pixmaps of various depths through the `pixel_mode`
- * field.
- *
- * @fields:
- * rows ::
- * The number of bitmap rows.
- *
- * width ::
- * The number of pixels in bitmap row.
- *
- * pitch ::
- * The pitch's absolute value is the number of bytes taken by one
- * bitmap row, including padding. However, the pitch is positive when
- * the bitmap has a 'down' flow, and negative when it has an 'up' flow.
- * In all cases, the pitch is an offset to add to a bitmap pointer in
- * order to go down one row.
- *
- * Note that 'padding' means the alignment of a bitmap to a byte
- * border, and FreeType functions normally align to the smallest
- * possible integer value.
- *
- * For the B/W rasterizer, `pitch` is always an even number.
- *
- * To change the pitch of a bitmap (say, to make it a multiple of 4),
- * use @FT_Bitmap_Convert. Alternatively, you might use callback
- * functions to directly render to the application's surface; see the
- * file `example2.cpp` in the tutorial for a demonstration.
- *
- * buffer ::
- * A typeless pointer to the bitmap buffer. This value should be
- * aligned on 32-bit boundaries in most cases.
- *
- * num_grays ::
- * This field is only used with @FT_PIXEL_MODE_GRAY; it gives the
- * number of gray levels used in the bitmap.
- *
- * pixel_mode ::
- * The pixel mode, i.e., how pixel bits are stored. See @FT_Pixel_Mode
- * for possible values.
- *
- * palette_mode ::
- * This field is intended for paletted pixel modes; it indicates how
- * the palette is stored. Not used currently.
- *
- * palette ::
- * A typeless pointer to the bitmap palette; this field is intended for
- * paletted pixel modes. Not used currently.
- *
- * @note:
- * `width` and `rows` refer to the *physical* size of the bitmap, not the
- * *logical* one. For example, if @FT_Pixel_Mode is set to
- * `FT_PIXEL_MODE_LCD`, the logical width is a just a third of the
- * physical one.
- */
- typedef struct FT_Bitmap_
- {
- unsigned int rows;
- unsigned int width;
- int pitch;
- unsigned char* buffer;
- unsigned short num_grays;
- unsigned char pixel_mode;
- unsigned char palette_mode;
- void* palette;
-
- } FT_Bitmap;
-
-
- /**************************************************************************
- *
- * @section:
- * outline_processing
- *
- */
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_Outline
- *
- * @description:
- * This structure is used to describe an outline to the scan-line
- * converter.
- *
- * @fields:
- * n_contours ::
- * The number of contours in the outline.
- *
- * n_points ::
- * The number of points in the outline.
- *
- * points ::
- * A pointer to an array of `n_points` @FT_Vector elements, giving the
- * outline's point coordinates.
- *
- * tags ::
- * A pointer to an array of `n_points` chars, giving each outline
- * point's type.
- *
- * If bit~0 is unset, the point is 'off' the curve, i.e., a Bezier
- * control point, while it is 'on' if set.
- *
- * Bit~1 is meaningful for 'off' points only. If set, it indicates a
- * third-order Bezier arc control point; and a second-order control
- * point if unset.
- *
- * If bit~2 is set, bits 5-7 contain the drop-out mode (as defined in
- * the OpenType specification; the value is the same as the argument to
- * the 'SCANTYPE' instruction).
- *
- * Bits 3 and~4 are reserved for internal purposes.
- *
- * contours ::
- * An array of `n_contours` shorts, giving the end point of each
- * contour within the outline. For example, the first contour is
- * defined by the points '0' to `contours[0]`, the second one is
- * defined by the points `contours[0]+1` to `contours[1]`, etc.
- *
- * flags ::
- * A set of bit flags used to characterize the outline and give hints
- * to the scan-converter and hinter on how to convert/grid-fit it. See
- * @FT_OUTLINE_XXX.
- *
- * @note:
- * The B/W rasterizer only checks bit~2 in the `tags` array for the first
- * point of each contour. The drop-out mode as given with
- * @FT_OUTLINE_IGNORE_DROPOUTS, @FT_OUTLINE_SMART_DROPOUTS, and
- * @FT_OUTLINE_INCLUDE_STUBS in `flags` is then overridden.
- */
- typedef struct FT_Outline_
- {
- unsigned short n_contours; /* number of contours in glyph */
- unsigned short n_points; /* number of points in the glyph */
-
- FT_Vector* points; /* the outline's points */
- unsigned char* tags; /* the points flags */
- unsigned short* contours; /* the contour end points */
-
- int flags; /* outline masks */
-
- } FT_Outline;
-
- /* */
-
- /* Following limits must be consistent with */
- /* FT_Outline.{n_contours,n_points} */
-#define FT_OUTLINE_CONTOURS_MAX USHRT_MAX
-#define FT_OUTLINE_POINTS_MAX USHRT_MAX
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_OUTLINE_XXX
- *
- * @description:
- * A list of bit-field constants used for the flags in an outline's
- * `flags` field.
- *
- * @values:
- * FT_OUTLINE_NONE ::
- * Value~0 is reserved.
- *
- * FT_OUTLINE_OWNER ::
- * If set, this flag indicates that the outline's field arrays (i.e.,
- * `points`, `flags`, and `contours`) are 'owned' by the outline
- * object, and should thus be freed when it is destroyed.
- *
- * FT_OUTLINE_EVEN_ODD_FILL ::
- * By default, outlines are filled using the non-zero winding rule. If
- * set to 1, the outline will be filled using the even-odd fill rule
- * (only works with the smooth rasterizer).
- *
- * FT_OUTLINE_REVERSE_FILL ::
- * By default, outside contours of an outline are oriented in
- * clock-wise direction, as defined in the TrueType specification.
- * This flag is set if the outline uses the opposite direction
- * (typically for Type~1 fonts). This flag is ignored by the scan
- * converter.
- *
- * FT_OUTLINE_IGNORE_DROPOUTS ::
- * By default, the scan converter will try to detect drop-outs in an
- * outline and correct the glyph bitmap to ensure consistent shape
- * continuity. If set, this flag hints the scan-line converter to
- * ignore such cases. See below for more information.
- *
- * FT_OUTLINE_SMART_DROPOUTS ::
- * Select smart dropout control. If unset, use simple dropout control.
- * Ignored if @FT_OUTLINE_IGNORE_DROPOUTS is set. See below for more
- * information.
- *
- * FT_OUTLINE_INCLUDE_STUBS ::
- * If set, turn pixels on for 'stubs', otherwise exclude them. Ignored
- * if @FT_OUTLINE_IGNORE_DROPOUTS is set. See below for more
- * information.
- *
- * FT_OUTLINE_OVERLAP ::
- * [Since 2.10.3] This flag indicates that this outline contains
- * overlapping contours and the anti-aliased renderer should perform
- * oversampling to mitigate possible artifacts. This flag should _not_
- * be set for well designed glyphs without overlaps because it quadruples
- * the rendering time.
- *
- * FT_OUTLINE_HIGH_PRECISION ::
- * This flag indicates that the scan-line converter should try to
- * convert this outline to bitmaps with the highest possible quality.
- * It is typically set for small character sizes. Note that this is
- * only a hint that might be completely ignored by a given
- * scan-converter.
- *
- * FT_OUTLINE_SINGLE_PASS ::
- * This flag is set to force a given scan-converter to only use a
- * single pass over the outline to render a bitmap glyph image.
- * Normally, it is set for very large character sizes. It is only a
- * hint that might be completely ignored by a given scan-converter.
- *
- * @note:
- * The flags @FT_OUTLINE_IGNORE_DROPOUTS, @FT_OUTLINE_SMART_DROPOUTS, and
- * @FT_OUTLINE_INCLUDE_STUBS are ignored by the smooth rasterizer.
- *
- * There exists a second mechanism to pass the drop-out mode to the B/W
- * rasterizer; see the `tags` field in @FT_Outline.
- *
- * Please refer to the description of the 'SCANTYPE' instruction in the
- * [OpenType specification](https://learn.microsoft.com/en-us/typography/opentype/spec/tt_instructions#scantype)
- * how simple drop-outs, smart drop-outs, and stubs are defined.
- */
-#define FT_OUTLINE_NONE 0x0
-#define FT_OUTLINE_OWNER 0x1
-#define FT_OUTLINE_EVEN_ODD_FILL 0x2
-#define FT_OUTLINE_REVERSE_FILL 0x4
-#define FT_OUTLINE_IGNORE_DROPOUTS 0x8
-#define FT_OUTLINE_SMART_DROPOUTS 0x10
-#define FT_OUTLINE_INCLUDE_STUBS 0x20
-#define FT_OUTLINE_OVERLAP 0x40
-
-#define FT_OUTLINE_HIGH_PRECISION 0x100
-#define FT_OUTLINE_SINGLE_PASS 0x200
-
-
- /* these constants are deprecated; use the corresponding */
- /* `FT_OUTLINE_XXX` values instead */
-#define ft_outline_none FT_OUTLINE_NONE
-#define ft_outline_owner FT_OUTLINE_OWNER
-#define ft_outline_even_odd_fill FT_OUTLINE_EVEN_ODD_FILL
-#define ft_outline_reverse_fill FT_OUTLINE_REVERSE_FILL
-#define ft_outline_ignore_dropouts FT_OUTLINE_IGNORE_DROPOUTS
-#define ft_outline_high_precision FT_OUTLINE_HIGH_PRECISION
-#define ft_outline_single_pass FT_OUTLINE_SINGLE_PASS
-
- /* */
-
-#define FT_CURVE_TAG( flag ) ( flag & 0x03 )
-
- /* see the `tags` field in `FT_Outline` for a description of the values */
-#define FT_CURVE_TAG_ON 0x01
-#define FT_CURVE_TAG_CONIC 0x00
-#define FT_CURVE_TAG_CUBIC 0x02
-
-#define FT_CURVE_TAG_HAS_SCANMODE 0x04
-
-#define FT_CURVE_TAG_TOUCH_X 0x08 /* reserved for TrueType hinter */
-#define FT_CURVE_TAG_TOUCH_Y 0x10 /* reserved for TrueType hinter */
-
-#define FT_CURVE_TAG_TOUCH_BOTH ( FT_CURVE_TAG_TOUCH_X | \
- FT_CURVE_TAG_TOUCH_Y )
- /* values 0x20, 0x40, and 0x80 are reserved */
-
-
- /* these constants are deprecated; use the corresponding */
- /* `FT_CURVE_TAG_XXX` values instead */
-#define FT_Curve_Tag_On FT_CURVE_TAG_ON
-#define FT_Curve_Tag_Conic FT_CURVE_TAG_CONIC
-#define FT_Curve_Tag_Cubic FT_CURVE_TAG_CUBIC
-#define FT_Curve_Tag_Touch_X FT_CURVE_TAG_TOUCH_X
-#define FT_Curve_Tag_Touch_Y FT_CURVE_TAG_TOUCH_Y
-
-
- /**************************************************************************
- *
- * @functype:
- * FT_Outline_MoveToFunc
- *
- * @description:
- * A function pointer type used to describe the signature of a 'move to'
- * function during outline walking/decomposition.
- *
- * A 'move to' is emitted to start a new contour in an outline.
- *
- * @input:
- * to ::
- * A pointer to the target point of the 'move to'.
- *
- * user ::
- * A typeless pointer, which is passed from the caller of the
- * decomposition function.
- *
- * @return:
- * Error code. 0~means success.
- */
- typedef int
- (*FT_Outline_MoveToFunc)( const FT_Vector* to,
- void* user );
-
-#define FT_Outline_MoveTo_Func FT_Outline_MoveToFunc
-
-
- /**************************************************************************
- *
- * @functype:
- * FT_Outline_LineToFunc
- *
- * @description:
- * A function pointer type used to describe the signature of a 'line to'
- * function during outline walking/decomposition.
- *
- * A 'line to' is emitted to indicate a segment in the outline.
- *
- * @input:
- * to ::
- * A pointer to the target point of the 'line to'.
- *
- * user ::
- * A typeless pointer, which is passed from the caller of the
- * decomposition function.
- *
- * @return:
- * Error code. 0~means success.
- */
- typedef int
- (*FT_Outline_LineToFunc)( const FT_Vector* to,
- void* user );
-
-#define FT_Outline_LineTo_Func FT_Outline_LineToFunc
-
-
- /**************************************************************************
- *
- * @functype:
- * FT_Outline_ConicToFunc
- *
- * @description:
- * A function pointer type used to describe the signature of a 'conic to'
- * function during outline walking or decomposition.
- *
- * A 'conic to' is emitted to indicate a second-order Bezier arc in the
- * outline.
- *
- * @input:
- * control ::
- * An intermediate control point between the last position and the new
- * target in `to`.
- *
- * to ::
- * A pointer to the target end point of the conic arc.
- *
- * user ::
- * A typeless pointer, which is passed from the caller of the
- * decomposition function.
- *
- * @return:
- * Error code. 0~means success.
- */
- typedef int
- (*FT_Outline_ConicToFunc)( const FT_Vector* control,
- const FT_Vector* to,
- void* user );
-
-#define FT_Outline_ConicTo_Func FT_Outline_ConicToFunc
-
-
- /**************************************************************************
- *
- * @functype:
- * FT_Outline_CubicToFunc
- *
- * @description:
- * A function pointer type used to describe the signature of a 'cubic to'
- * function during outline walking or decomposition.
- *
- * A 'cubic to' is emitted to indicate a third-order Bezier arc.
- *
- * @input:
- * control1 ::
- * A pointer to the first Bezier control point.
- *
- * control2 ::
- * A pointer to the second Bezier control point.
- *
- * to ::
- * A pointer to the target end point.
- *
- * user ::
- * A typeless pointer, which is passed from the caller of the
- * decomposition function.
- *
- * @return:
- * Error code. 0~means success.
- */
- typedef int
- (*FT_Outline_CubicToFunc)( const FT_Vector* control1,
- const FT_Vector* control2,
- const FT_Vector* to,
- void* user );
-
-#define FT_Outline_CubicTo_Func FT_Outline_CubicToFunc
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_Outline_Funcs
- *
- * @description:
- * A structure to hold various function pointers used during outline
- * decomposition in order to emit segments, conic, and cubic Beziers.
- *
- * @fields:
- * move_to ::
- * The 'move to' emitter.
- *
- * line_to ::
- * The segment emitter.
- *
- * conic_to ::
- * The second-order Bezier arc emitter.
- *
- * cubic_to ::
- * The third-order Bezier arc emitter.
- *
- * shift ::
- * The shift that is applied to coordinates before they are sent to the
- * emitter.
- *
- * delta ::
- * The delta that is applied to coordinates before they are sent to the
- * emitter, but after the shift.
- *
- * @note:
- * The point coordinates sent to the emitters are the transformed version
- * of the original coordinates (this is important for high accuracy
- * during scan-conversion). The transformation is simple:
- *
- * ```
- * x' = (x << shift) - delta
- * y' = (y << shift) - delta
- * ```
- *
- * Set the values of `shift` and `delta` to~0 to get the original point
- * coordinates.
- */
- typedef struct FT_Outline_Funcs_
- {
- FT_Outline_MoveToFunc move_to;
- FT_Outline_LineToFunc line_to;
- FT_Outline_ConicToFunc conic_to;
- FT_Outline_CubicToFunc cubic_to;
-
- int shift;
- FT_Pos delta;
-
- } FT_Outline_Funcs;
-
-
- /**************************************************************************
- *
- * @section:
- * basic_types
- *
- */
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_IMAGE_TAG
- *
- * @description:
- * This macro converts four-letter tags to an unsigned long type.
- *
- * @note:
- * Since many 16-bit compilers don't like 32-bit enumerations, you should
- * redefine this macro in case of problems to something like this:
- *
- * ```
- * #define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) value
- * ```
- *
- * to get a simple enumeration without assigning special numbers.
- */
-#ifndef FT_IMAGE_TAG
-
-#define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) \
- value = ( ( FT_STATIC_BYTE_CAST( unsigned long, _x1 ) << 24 ) | \
- ( FT_STATIC_BYTE_CAST( unsigned long, _x2 ) << 16 ) | \
- ( FT_STATIC_BYTE_CAST( unsigned long, _x3 ) << 8 ) | \
- FT_STATIC_BYTE_CAST( unsigned long, _x4 ) )
-
-#endif /* FT_IMAGE_TAG */
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_Glyph_Format
- *
- * @description:
- * An enumeration type used to describe the format of a given glyph
- * image. Note that this version of FreeType only supports two image
- * formats, even though future font drivers will be able to register
- * their own format.
- *
- * @values:
- * FT_GLYPH_FORMAT_NONE ::
- * The value~0 is reserved.
- *
- * FT_GLYPH_FORMAT_COMPOSITE ::
- * The glyph image is a composite of several other images. This format
- * is _only_ used with @FT_LOAD_NO_RECURSE, and is used to report
- * compound glyphs (like accented characters).
- *
- * FT_GLYPH_FORMAT_BITMAP ::
- * The glyph image is a bitmap, and can be described as an @FT_Bitmap.
- * You generally need to access the `bitmap` field of the
- * @FT_GlyphSlotRec structure to read it.
- *
- * FT_GLYPH_FORMAT_OUTLINE ::
- * The glyph image is a vectorial outline made of line segments and
- * Bezier arcs; it can be described as an @FT_Outline; you generally
- * want to access the `outline` field of the @FT_GlyphSlotRec structure
- * to read it.
- *
- * FT_GLYPH_FORMAT_PLOTTER ::
- * The glyph image is a vectorial path with no inside and outside
- * contours. Some Type~1 fonts, like those in the Hershey family,
- * contain glyphs in this format. These are described as @FT_Outline,
- * but FreeType isn't currently capable of rendering them correctly.
- *
- * FT_GLYPH_FORMAT_SVG ::
- * [Since 2.12] The glyph is represented by an SVG document in the
- * 'SVG~' table.
- */
- typedef enum FT_Glyph_Format_
- {
- FT_IMAGE_TAG( FT_GLYPH_FORMAT_NONE, 0, 0, 0, 0 ),
-
- FT_IMAGE_TAG( FT_GLYPH_FORMAT_COMPOSITE, 'c', 'o', 'm', 'p' ),
- FT_IMAGE_TAG( FT_GLYPH_FORMAT_BITMAP, 'b', 'i', 't', 's' ),
- FT_IMAGE_TAG( FT_GLYPH_FORMAT_OUTLINE, 'o', 'u', 't', 'l' ),
- FT_IMAGE_TAG( FT_GLYPH_FORMAT_PLOTTER, 'p', 'l', 'o', 't' ),
- FT_IMAGE_TAG( FT_GLYPH_FORMAT_SVG, 'S', 'V', 'G', ' ' )
-
- } FT_Glyph_Format;
-
-
- /* these constants are deprecated; use the corresponding */
- /* `FT_Glyph_Format` values instead. */
-#define ft_glyph_format_none FT_GLYPH_FORMAT_NONE
-#define ft_glyph_format_composite FT_GLYPH_FORMAT_COMPOSITE
-#define ft_glyph_format_bitmap FT_GLYPH_FORMAT_BITMAP
-#define ft_glyph_format_outline FT_GLYPH_FORMAT_OUTLINE
-#define ft_glyph_format_plotter FT_GLYPH_FORMAT_PLOTTER
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** R A S T E R D E F I N I T I O N S *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
-
- /**************************************************************************
- *
- * @section:
- * raster
- *
- * @title:
- * Scanline Converter
- *
- * @abstract:
- * How vectorial outlines are converted into bitmaps and pixmaps.
- *
- * @description:
- * A raster or a rasterizer is a scan converter in charge of producing a
- * pixel coverage bitmap that can be used as an alpha channel when
- * compositing a glyph with a background. FreeType comes with two
- * rasterizers: bilevel `raster1` and anti-aliased `smooth` are two
- * separate modules. They are usually called from the high-level
- * @FT_Load_Glyph or @FT_Render_Glyph functions and produce the entire
- * coverage bitmap at once, while staying largely invisible to users.
- *
- * Instead of working with complete coverage bitmaps, it is also possible
- * to intercept consecutive pixel runs on the same scanline with the same
- * coverage, called _spans_, and process them individually. Only the
- * `smooth` rasterizer permits this when calling @FT_Outline_Render with
- * @FT_Raster_Params as described below.
- *
- * Working with either complete bitmaps or spans it is important to think
- * of them as colorless coverage objects suitable as alpha channels to
- * blend arbitrary colors with a background. For best results, it is
- * recommended to use gamma correction, too.
- *
- * This section also describes the public API needed to set up alternative
- * @FT_Renderer modules.
- *
- * @order:
- * FT_Span
- * FT_SpanFunc
- * FT_Raster_Params
- * FT_RASTER_FLAG_XXX
- *
- * FT_Raster
- * FT_Raster_NewFunc
- * FT_Raster_DoneFunc
- * FT_Raster_ResetFunc
- * FT_Raster_SetModeFunc
- * FT_Raster_RenderFunc
- * FT_Raster_Funcs
- *
- */
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_Span
- *
- * @description:
- * A structure to model a single span of consecutive pixels when
- * rendering an anti-aliased bitmap.
- *
- * @fields:
- * x ::
- * The span's horizontal start position.
- *
- * len ::
- * The span's length in pixels.
- *
- * coverage ::
- * The span color/coverage, ranging from 0 (background) to 255
- * (foreground).
- *
- * @note:
- * This structure is used by the span drawing callback type named
- * @FT_SpanFunc that takes the y~coordinate of the span as a parameter.
- *
- * The anti-aliased rasterizer produces coverage values from 0 to 255,
- * that is, from completely transparent to completely opaque.
- */
- typedef struct FT_Span_
- {
- short x;
- unsigned short len;
- unsigned char coverage;
-
- } FT_Span;
-
-
- /**************************************************************************
- *
- * @functype:
- * FT_SpanFunc
- *
- * @description:
- * A function used as a call-back by the anti-aliased renderer in order
- * to let client applications draw themselves the pixel spans on each
- * scan line.
- *
- * @input:
- * y ::
- * The scanline's upward y~coordinate.
- *
- * count ::
- * The number of spans to draw on this scanline.
- *
- * spans ::
- * A table of `count` spans to draw on the scanline.
- *
- * user ::
- * User-supplied data that is passed to the callback.
- *
- * @note:
- * This callback allows client applications to directly render the spans
- * of the anti-aliased bitmap to any kind of surfaces.
- *
- * This can be used to write anti-aliased outlines directly to a given
- * background bitmap using alpha compositing. It can also be used for
- * oversampling and averaging.
- */
- typedef void
- (*FT_SpanFunc)( int y,
- int count,
- const FT_Span* spans,
- void* user );
-
-#define FT_Raster_Span_Func FT_SpanFunc
-
-
- /**************************************************************************
- *
- * @functype:
- * FT_Raster_BitTest_Func
- *
- * @description:
- * Deprecated, unimplemented.
- */
- typedef int
- (*FT_Raster_BitTest_Func)( int y,
- int x,
- void* user );
-
-
- /**************************************************************************
- *
- * @functype:
- * FT_Raster_BitSet_Func
- *
- * @description:
- * Deprecated, unimplemented.
- */
- typedef void
- (*FT_Raster_BitSet_Func)( int y,
- int x,
- void* user );
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_RASTER_FLAG_XXX
- *
- * @description:
- * A list of bit flag constants as used in the `flags` field of a
- * @FT_Raster_Params structure.
- *
- * @values:
- * FT_RASTER_FLAG_DEFAULT ::
- * This value is 0.
- *
- * FT_RASTER_FLAG_AA ::
- * This flag is set to indicate that an anti-aliased glyph image should
- * be generated. Otherwise, it will be monochrome (1-bit).
- *
- * FT_RASTER_FLAG_DIRECT ::
- * This flag is set to indicate direct rendering. In this mode, client
- * applications must provide their own span callback. This lets them
- * directly draw or compose over an existing bitmap. If this bit is
- * _not_ set, the target pixmap's buffer _must_ be zeroed before
- * rendering and the output will be clipped to its size.
- *
- * Direct rendering is only possible with anti-aliased glyphs.
- *
- * FT_RASTER_FLAG_CLIP ::
- * This flag is only used in direct rendering mode. If set, the output
- * will be clipped to a box specified in the `clip_box` field of the
- * @FT_Raster_Params structure. Otherwise, the `clip_box` is
- * effectively set to the bounding box and all spans are generated.
- *
- * FT_RASTER_FLAG_SDF ::
- * This flag is set to indicate that a signed distance field glyph
- * image should be generated. This is only used while rendering with
- * the @FT_RENDER_MODE_SDF render mode.
- */
-#define FT_RASTER_FLAG_DEFAULT 0x0
-#define FT_RASTER_FLAG_AA 0x1
-#define FT_RASTER_FLAG_DIRECT 0x2
-#define FT_RASTER_FLAG_CLIP 0x4
-#define FT_RASTER_FLAG_SDF 0x8
-
- /* these constants are deprecated; use the corresponding */
- /* `FT_RASTER_FLAG_XXX` values instead */
-#define ft_raster_flag_default FT_RASTER_FLAG_DEFAULT
-#define ft_raster_flag_aa FT_RASTER_FLAG_AA
-#define ft_raster_flag_direct FT_RASTER_FLAG_DIRECT
-#define ft_raster_flag_clip FT_RASTER_FLAG_CLIP
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_Raster_Params
- *
- * @description:
- * A structure to hold the parameters used by a raster's render function,
- * passed as an argument to @FT_Outline_Render.
- *
- * @fields:
- * target ::
- * The target bitmap.
- *
- * source ::
- * A pointer to the source glyph image (e.g., an @FT_Outline).
- *
- * flags ::
- * The rendering flags.
- *
- * gray_spans ::
- * The gray span drawing callback.
- *
- * black_spans ::
- * Unused.
- *
- * bit_test ::
- * Unused.
- *
- * bit_set ::
- * Unused.
- *
- * user ::
- * User-supplied data that is passed to each drawing callback.
- *
- * clip_box ::
- * An optional span clipping box expressed in _integer_ pixels
- * (not in 26.6 fixed-point units).
- *
- * @note:
- * The @FT_RASTER_FLAG_AA bit flag must be set in the `flags` to
- * generate an anti-aliased glyph bitmap, otherwise a monochrome bitmap
- * is generated. The `target` should have appropriate pixel mode and its
- * dimensions define the clipping region.
- *
- * If both @FT_RASTER_FLAG_AA and @FT_RASTER_FLAG_DIRECT bit flags
- * are set in `flags`, the raster calls an @FT_SpanFunc callback
- * `gray_spans` with `user` data as an argument ignoring `target`. This
- * allows direct composition over a pre-existing user surface to perform
- * the span drawing and composition. To optionally clip the spans, set
- * the @FT_RASTER_FLAG_CLIP flag and `clip_box`. The monochrome raster
- * does not support the direct mode.
- *
- * The gray-level rasterizer always uses 256 gray levels. If you want
- * fewer gray levels, you have to use @FT_RASTER_FLAG_DIRECT and reduce
- * the levels in the callback function.
- */
- typedef struct FT_Raster_Params_
- {
- const FT_Bitmap* target;
- const void* source;
- int flags;
- FT_SpanFunc gray_spans;
- FT_SpanFunc black_spans; /* unused */
- FT_Raster_BitTest_Func bit_test; /* unused */
- FT_Raster_BitSet_Func bit_set; /* unused */
- void* user;
- FT_BBox clip_box;
-
- } FT_Raster_Params;
-
-
- /**************************************************************************
- *
- * @type:
- * FT_Raster
- *
- * @description:
- * An opaque handle (pointer) to a raster object. Each object can be
- * used independently to convert an outline into a bitmap or pixmap.
- *
- * @note:
- * In FreeType 2, all rasters are now encapsulated within specific
- * @FT_Renderer modules and only used in their context.
- *
- */
- typedef struct FT_RasterRec_* FT_Raster;
-
-
- /**************************************************************************
- *
- * @functype:
- * FT_Raster_NewFunc
- *
- * @description:
- * A function used to create a new raster object.
- *
- * @input:
- * memory ::
- * A handle to the memory allocator.
- *
- * @output:
- * raster ::
- * A handle to the new raster object.
- *
- * @return:
- * Error code. 0~means success.
- *
- * @note:
- * The `memory` parameter is a typeless pointer in order to avoid
- * un-wanted dependencies on the rest of the FreeType code. In practice,
- * it is an @FT_Memory object, i.e., a handle to the standard FreeType
- * memory allocator. However, this field can be completely ignored by a
- * given raster implementation.
- */
- typedef int
- (*FT_Raster_NewFunc)( void* memory,
- FT_Raster* raster );
-
-#define FT_Raster_New_Func FT_Raster_NewFunc
-
-
- /**************************************************************************
- *
- * @functype:
- * FT_Raster_DoneFunc
- *
- * @description:
- * A function used to destroy a given raster object.
- *
- * @input:
- * raster ::
- * A handle to the raster object.
- */
- typedef void
- (*FT_Raster_DoneFunc)( FT_Raster raster );
-
-#define FT_Raster_Done_Func FT_Raster_DoneFunc
-
-
- /**************************************************************************
- *
- * @functype:
- * FT_Raster_ResetFunc
- *
- * @description:
- * FreeType used to provide an area of memory called the 'render pool'
- * available to all registered rasterizers. This was not thread safe,
- * however, and now FreeType never allocates this pool.
- *
- * This function is called after a new raster object is created.
- *
- * @input:
- * raster ::
- * A handle to the new raster object.
- *
- * pool_base ::
- * Previously, the address in memory of the render pool. Set this to
- * `NULL`.
- *
- * pool_size ::
- * Previously, the size in bytes of the render pool. Set this to 0.
- *
- * @note:
- * Rasterizers should rely on dynamic or stack allocation if they want to
- * (a handle to the memory allocator is passed to the rasterizer
- * constructor).
- */
- typedef void
- (*FT_Raster_ResetFunc)( FT_Raster raster,
- unsigned char* pool_base,
- unsigned long pool_size );
-
-#define FT_Raster_Reset_Func FT_Raster_ResetFunc
-
-
- /**************************************************************************
- *
- * @functype:
- * FT_Raster_SetModeFunc
- *
- * @description:
- * This function is a generic facility to change modes or attributes in a
- * given raster. This can be used for debugging purposes, or simply to
- * allow implementation-specific 'features' in a given raster module.
- *
- * @input:
- * raster ::
- * A handle to the new raster object.
- *
- * mode ::
- * A 4-byte tag used to name the mode or property.
- *
- * args ::
- * A pointer to the new mode/property to use.
- */
- typedef int
- (*FT_Raster_SetModeFunc)( FT_Raster raster,
- unsigned long mode,
- void* args );
-
-#define FT_Raster_Set_Mode_Func FT_Raster_SetModeFunc
-
-
- /**************************************************************************
- *
- * @functype:
- * FT_Raster_RenderFunc
- *
- * @description:
- * Invoke a given raster to scan-convert a given glyph image into a
- * target bitmap.
- *
- * @input:
- * raster ::
- * A handle to the raster object.
- *
- * params ::
- * A pointer to an @FT_Raster_Params structure used to store the
- * rendering parameters.
- *
- * @return:
- * Error code. 0~means success.
- *
- * @note:
- * The exact format of the source image depends on the raster's glyph
- * format defined in its @FT_Raster_Funcs structure. It can be an
- * @FT_Outline or anything else in order to support a large array of
- * glyph formats.
- *
- * Note also that the render function can fail and return a
- * `FT_Err_Unimplemented_Feature` error code if the raster used does not
- * support direct composition.
- */
- typedef int
- (*FT_Raster_RenderFunc)( FT_Raster raster,
- const FT_Raster_Params* params );
-
-#define FT_Raster_Render_Func FT_Raster_RenderFunc
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_Raster_Funcs
- *
- * @description:
- * A structure used to describe a given raster class to the library.
- *
- * @fields:
- * glyph_format ::
- * The supported glyph format for this raster.
- *
- * raster_new ::
- * The raster constructor.
- *
- * raster_reset ::
- * Used to reset the render pool within the raster.
- *
- * raster_render ::
- * A function to render a glyph into a given bitmap.
- *
- * raster_done ::
- * The raster destructor.
- */
- typedef struct FT_Raster_Funcs_
- {
- FT_Glyph_Format glyph_format;
-
- FT_Raster_NewFunc raster_new;
- FT_Raster_ResetFunc raster_reset;
- FT_Raster_SetModeFunc raster_set_mode;
- FT_Raster_RenderFunc raster_render;
- FT_Raster_DoneFunc raster_done;
-
- } FT_Raster_Funcs;
-
- /* */
-
-
-FT_END_HEADER
-
-#endif /* FTIMAGE_H_ */
-
-
-/* END */
-
-
-/* Local Variables: */
-/* coding: utf-8 */
-/* End: */
diff --git a/contrib/libs/freetype/include/freetype/ftincrem.h b/contrib/libs/freetype/include/freetype/ftincrem.h
deleted file mode 100644
index 816581b78e..0000000000
--- a/contrib/libs/freetype/include/freetype/ftincrem.h
+++ /dev/null
@@ -1,348 +0,0 @@
-/****************************************************************************
- *
- * ftincrem.h
- *
- * FreeType incremental loading (specification).
- *
- * Copyright (C) 2002-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTINCREM_H_
-#define FTINCREM_H_
-
-#include <freetype/freetype.h>
-#include <freetype/ftparams.h>
-
-#ifdef FREETYPE_H
-#error "freetype.h of FreeType 1 has been loaded!"
-#error "Please fix the directory search order for header files"
-#error "so that freetype.h of FreeType 2 is found first."
-#endif
-
-
-FT_BEGIN_HEADER
-
- /**************************************************************************
- *
- * @section:
- * incremental
- *
- * @title:
- * Incremental Loading
- *
- * @abstract:
- * Custom Glyph Loading.
- *
- * @description:
- * This section contains various functions used to perform so-called
- * 'incremental' glyph loading. This is a mode where all glyphs loaded
- * from a given @FT_Face are provided by the client application.
- *
- * Apart from that, all other tables are loaded normally from the font
- * file. This mode is useful when FreeType is used within another
- * engine, e.g., a PostScript Imaging Processor.
- *
- * To enable this mode, you must use @FT_Open_Face, passing an
- * @FT_Parameter with the @FT_PARAM_TAG_INCREMENTAL tag and an
- * @FT_Incremental_Interface value. See the comments for
- * @FT_Incremental_InterfaceRec for an example.
- *
- */
-
-
- /**************************************************************************
- *
- * @type:
- * FT_Incremental
- *
- * @description:
- * An opaque type describing a user-provided object used to implement
- * 'incremental' glyph loading within FreeType. This is used to support
- * embedded fonts in certain environments (e.g., PostScript
- * interpreters), where the glyph data isn't in the font file, or must be
- * overridden by different values.
- *
- * @note:
- * It is up to client applications to create and implement
- * @FT_Incremental objects, as long as they provide implementations for
- * the methods @FT_Incremental_GetGlyphDataFunc,
- * @FT_Incremental_FreeGlyphDataFunc and
- * @FT_Incremental_GetGlyphMetricsFunc.
- *
- * See the description of @FT_Incremental_InterfaceRec to understand how
- * to use incremental objects with FreeType.
- *
- */
- typedef struct FT_IncrementalRec_* FT_Incremental;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_Incremental_MetricsRec
- *
- * @description:
- * A small structure used to contain the basic glyph metrics returned by
- * the @FT_Incremental_GetGlyphMetricsFunc method.
- *
- * @fields:
- * bearing_x ::
- * Left bearing, in font units.
- *
- * bearing_y ::
- * Top bearing, in font units.
- *
- * advance ::
- * Horizontal component of glyph advance, in font units.
- *
- * advance_v ::
- * Vertical component of glyph advance, in font units.
- *
- * @note:
- * These correspond to horizontal or vertical metrics depending on the
- * value of the `vertical` argument to the function
- * @FT_Incremental_GetGlyphMetricsFunc.
- *
- */
- typedef struct FT_Incremental_MetricsRec_
- {
- FT_Long bearing_x;
- FT_Long bearing_y;
- FT_Long advance;
- FT_Long advance_v; /* since 2.3.12 */
-
- } FT_Incremental_MetricsRec;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_Incremental_Metrics
- *
- * @description:
- * A handle to an @FT_Incremental_MetricsRec structure.
- *
- */
- typedef struct FT_Incremental_MetricsRec_* FT_Incremental_Metrics;
-
-
- /**************************************************************************
- *
- * @type:
- * FT_Incremental_GetGlyphDataFunc
- *
- * @description:
- * A function called by FreeType to access a given glyph's data bytes
- * during @FT_Load_Glyph or @FT_Load_Char if incremental loading is
- * enabled.
- *
- * Note that the format of the glyph's data bytes depends on the font
- * file format. For TrueType, it must correspond to the raw bytes within
- * the 'glyf' table. For PostScript formats, it must correspond to the
- * **unencrypted** charstring bytes, without any `lenIV` header. It is
- * undefined for any other format.
- *
- * @input:
- * incremental ::
- * Handle to an opaque @FT_Incremental handle provided by the client
- * application.
- *
- * glyph_index ::
- * Index of relevant glyph.
- *
- * @output:
- * adata ::
- * A structure describing the returned glyph data bytes (which will be
- * accessed as a read-only byte block).
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * If this function returns successfully the method
- * @FT_Incremental_FreeGlyphDataFunc will be called later to release the
- * data bytes.
- *
- * Nested calls to @FT_Incremental_GetGlyphDataFunc can happen for
- * compound glyphs.
- *
- */
- typedef FT_Error
- (*FT_Incremental_GetGlyphDataFunc)( FT_Incremental incremental,
- FT_UInt glyph_index,
- FT_Data* adata );
-
-
- /**************************************************************************
- *
- * @type:
- * FT_Incremental_FreeGlyphDataFunc
- *
- * @description:
- * A function used to release the glyph data bytes returned by a
- * successful call to @FT_Incremental_GetGlyphDataFunc.
- *
- * @input:
- * incremental ::
- * A handle to an opaque @FT_Incremental handle provided by the client
- * application.
- *
- * data ::
- * A structure describing the glyph data bytes (which will be accessed
- * as a read-only byte block).
- *
- */
- typedef void
- (*FT_Incremental_FreeGlyphDataFunc)( FT_Incremental incremental,
- FT_Data* data );
-
-
- /**************************************************************************
- *
- * @type:
- * FT_Incremental_GetGlyphMetricsFunc
- *
- * @description:
- * A function used to retrieve the basic metrics of a given glyph index
- * before accessing its data. This allows for handling font types such
- * as PCL~XL Format~1, Class~2 downloaded TrueType fonts, where the glyph
- * metrics (`hmtx` and `vmtx` tables) are permitted to be omitted from
- * the font, and the relevant metrics included in the header of the glyph
- * outline data. Importantly, this is not intended to allow custom glyph
- * metrics (for example, Postscript Metrics dictionaries), because that
- * conflicts with the requirements of outline hinting. Such custom
- * metrics must be handled separately, by the calling application.
- *
- * @input:
- * incremental ::
- * A handle to an opaque @FT_Incremental handle provided by the client
- * application.
- *
- * glyph_index ::
- * Index of relevant glyph.
- *
- * vertical ::
- * If true, return vertical metrics.
- *
- * ametrics ::
- * This parameter is used for both input and output. The original
- * glyph metrics, if any, in font units. If metrics are not available
- * all the values must be set to zero.
- *
- * @output:
- * ametrics ::
- * The glyph metrics in font units.
- *
- */
- typedef FT_Error
- (*FT_Incremental_GetGlyphMetricsFunc)
- ( FT_Incremental incremental,
- FT_UInt glyph_index,
- FT_Bool vertical,
- FT_Incremental_MetricsRec *ametrics );
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_Incremental_FuncsRec
- *
- * @description:
- * A table of functions for accessing fonts that load data incrementally.
- * Used in @FT_Incremental_InterfaceRec.
- *
- * @fields:
- * get_glyph_data ::
- * The function to get glyph data. Must not be null.
- *
- * free_glyph_data ::
- * The function to release glyph data. Must not be null.
- *
- * get_glyph_metrics ::
- * The function to get glyph metrics. May be null if the font does not
- * require it.
- *
- */
- typedef struct FT_Incremental_FuncsRec_
- {
- FT_Incremental_GetGlyphDataFunc get_glyph_data;
- FT_Incremental_FreeGlyphDataFunc free_glyph_data;
- FT_Incremental_GetGlyphMetricsFunc get_glyph_metrics;
-
- } FT_Incremental_FuncsRec;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_Incremental_InterfaceRec
- *
- * @description:
- * A structure to be used with @FT_Open_Face to indicate that the user
- * wants to support incremental glyph loading. You should use it with
- * @FT_PARAM_TAG_INCREMENTAL as in the following example:
- *
- * ```
- * FT_Incremental_InterfaceRec inc_int;
- * FT_Parameter parameter;
- * FT_Open_Args open_args;
- *
- *
- * // set up incremental descriptor
- * inc_int.funcs = my_funcs;
- * inc_int.object = my_object;
- *
- * // set up optional parameter
- * parameter.tag = FT_PARAM_TAG_INCREMENTAL;
- * parameter.data = &inc_int;
- *
- * // set up FT_Open_Args structure
- * open_args.flags = FT_OPEN_PATHNAME | FT_OPEN_PARAMS;
- * open_args.pathname = my_font_pathname;
- * open_args.num_params = 1;
- * open_args.params = &parameter; // we use one optional argument
- *
- * // open the font
- * error = FT_Open_Face( library, &open_args, index, &face );
- * ...
- * ```
- *
- */
- typedef struct FT_Incremental_InterfaceRec_
- {
- const FT_Incremental_FuncsRec* funcs;
- FT_Incremental object;
-
- } FT_Incremental_InterfaceRec;
-
-
- /**************************************************************************
- *
- * @type:
- * FT_Incremental_Interface
- *
- * @description:
- * A pointer to an @FT_Incremental_InterfaceRec structure.
- *
- */
- typedef FT_Incremental_InterfaceRec* FT_Incremental_Interface;
-
-
- /* */
-
-
-FT_END_HEADER
-
-#endif /* FTINCREM_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/ftlcdfil.h b/contrib/libs/freetype/include/freetype/ftlcdfil.h
deleted file mode 100644
index 25274dc4ac..0000000000
--- a/contrib/libs/freetype/include/freetype/ftlcdfil.h
+++ /dev/null
@@ -1,323 +0,0 @@
-/****************************************************************************
- *
- * ftlcdfil.h
- *
- * FreeType API for color filtering of subpixel bitmap glyphs
- * (specification).
- *
- * Copyright (C) 2006-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTLCDFIL_H_
-#define FTLCDFIL_H_
-
-#include <freetype/freetype.h>
-#include <freetype/ftparams.h>
-
-#ifdef FREETYPE_H
-#error "freetype.h of FreeType 1 has been loaded!"
-#error "Please fix the directory search order for header files"
-#error "so that freetype.h of FreeType 2 is found first."
-#endif
-
-
-FT_BEGIN_HEADER
-
- /**************************************************************************
- *
- * @section:
- * lcd_rendering
- *
- * @title:
- * Subpixel Rendering
- *
- * @abstract:
- * API to control subpixel rendering.
- *
- * @description:
- * FreeType provides two alternative subpixel rendering technologies.
- * Should you define `FT_CONFIG_OPTION_SUBPIXEL_RENDERING` in your
- * `ftoption.h` file, this enables ClearType-style rendering.
- * Otherwise, Harmony LCD rendering is enabled. These technologies are
- * controlled differently and API described below, although always
- * available, performs its function when appropriate method is enabled
- * and does nothing otherwise.
- *
- * ClearType-style LCD rendering exploits the color-striped structure of
- * LCD pixels, increasing the available resolution in the direction of
- * the stripe (usually horizontal RGB) by a factor of~3. Using the
- * subpixel coverages unfiltered can create severe color fringes
- * especially when rendering thin features. Indeed, to produce
- * black-on-white text, the nearby color subpixels must be dimmed
- * evenly. Therefore, an equalizing 5-tap FIR filter should be applied
- * to subpixel coverages regardless of pixel boundaries and should have
- * these properties:
- *
- * 1. It should be symmetrical, like {~a, b, c, b, a~}, to avoid
- * any shifts in appearance.
- *
- * 2. It should be color-balanced, meaning a~+ b~=~c, to reduce color
- * fringes by distributing the computed coverage for one subpixel to
- * all subpixels equally.
- *
- * 3. It should be normalized, meaning 2a~+ 2b~+ c~=~1.0 to maintain
- * overall brightness.
- *
- * Boxy 3-tap filter {0, 1/3, 1/3, 1/3, 0} is sharper but is less
- * forgiving of non-ideal gamma curves of a screen (and viewing angles),
- * beveled filters are fuzzier but more tolerant.
- *
- * Use the @FT_Library_SetLcdFilter or @FT_Library_SetLcdFilterWeights
- * API to specify a low-pass filter, which is then applied to
- * subpixel-rendered bitmaps generated through @FT_Render_Glyph.
- *
- * Harmony LCD rendering is suitable to panels with any regular subpixel
- * structure, not just monitors with 3 color striped subpixels, as long
- * as the color subpixels have fixed positions relative to the pixel
- * center. In this case, each color channel can be rendered separately
- * after shifting the outline opposite to the subpixel shift so that the
- * coverage maps are aligned. This method is immune to color fringes
- * because the shifts do not change integral coverage.
- *
- * The subpixel geometry must be specified by xy-coordinates for each
- * subpixel. By convention they may come in the RGB order: {{-1/3, 0},
- * {0, 0}, {1/3, 0}} for standard RGB striped panel or {{-1/6, 1/4},
- * {-1/6, -1/4}, {1/3, 0}} for a certain PenTile panel.
- *
- * Use the @FT_Library_SetLcdGeometry API to specify subpixel positions.
- * If one follows the RGB order convention, the same order applies to the
- * resulting @FT_PIXEL_MODE_LCD and @FT_PIXEL_MODE_LCD_V bitmaps. Note,
- * however, that the coordinate frame for the latter must be rotated
- * clockwise. Harmony with default LCD geometry is equivalent to
- * ClearType with light filter.
- *
- * As a result of ClearType filtering or Harmony shifts, the resulting
- * dimensions of LCD bitmaps can be slightly wider or taller than the
- * dimensions the original outline with regard to the pixel grid.
- * For example, for @FT_RENDER_MODE_LCD, the filter adds 2~subpixels to
- * the left, and 2~subpixels to the right. The bitmap offset values are
- * adjusted accordingly, so clients shouldn't need to modify their layout
- * and glyph positioning code when enabling the filter.
- *
- * The ClearType and Harmony rendering is applicable to glyph bitmaps
- * rendered through @FT_Render_Glyph, @FT_Load_Glyph, @FT_Load_Char, and
- * @FT_Glyph_To_Bitmap, when @FT_RENDER_MODE_LCD or @FT_RENDER_MODE_LCD_V
- * is specified. This API does not control @FT_Outline_Render and
- * @FT_Outline_Get_Bitmap.
- *
- * The described algorithms can completely remove color artefacts when
- * combined with gamma-corrected alpha blending in linear space. Each of
- * the 3~alpha values (subpixels) must by independently used to blend one
- * color channel. That is, red alpha blends the red channel of the text
- * color with the red channel of the background pixel.
- */
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_LcdFilter
- *
- * @description:
- * A list of values to identify various types of LCD filters.
- *
- * @values:
- * FT_LCD_FILTER_NONE ::
- * Do not perform filtering. When used with subpixel rendering, this
- * results in sometimes severe color fringes.
- *
- * FT_LCD_FILTER_DEFAULT ::
- * This is a beveled, normalized, and color-balanced five-tap filter
- * with weights of [0x08 0x4D 0x56 0x4D 0x08] in 1/256 units.
- *
- * FT_LCD_FILTER_LIGHT ::
- * this is a boxy, normalized, and color-balanced three-tap filter with
- * weights of [0x00 0x55 0x56 0x55 0x00] in 1/256 units.
- *
- * FT_LCD_FILTER_LEGACY ::
- * FT_LCD_FILTER_LEGACY1 ::
- * This filter corresponds to the original libXft color filter. It
- * provides high contrast output but can exhibit really bad color
- * fringes if glyphs are not extremely well hinted to the pixel grid.
- * This filter is only provided for comparison purposes, and might be
- * disabled or stay unsupported in the future. The second value is
- * provided for compatibility with FontConfig, which historically used
- * different enumeration, sometimes incorrectly forwarded to FreeType.
- *
- * @since:
- * 2.3.0 (`FT_LCD_FILTER_LEGACY1` since 2.6.2)
- */
- typedef enum FT_LcdFilter_
- {
- FT_LCD_FILTER_NONE = 0,
- FT_LCD_FILTER_DEFAULT = 1,
- FT_LCD_FILTER_LIGHT = 2,
- FT_LCD_FILTER_LEGACY1 = 3,
- FT_LCD_FILTER_LEGACY = 16,
-
- FT_LCD_FILTER_MAX /* do not remove */
-
- } FT_LcdFilter;
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Library_SetLcdFilter
- *
- * @description:
- * This function is used to change filter applied to LCD decimated
- * bitmaps, like the ones used when calling @FT_Render_Glyph with
- * @FT_RENDER_MODE_LCD or @FT_RENDER_MODE_LCD_V.
- *
- * @input:
- * library ::
- * A handle to the target library instance.
- *
- * filter ::
- * The filter type.
- *
- * You can use @FT_LCD_FILTER_NONE here to disable this feature, or
- * @FT_LCD_FILTER_DEFAULT to use a default filter that should work well
- * on most LCD screens.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * Since 2.10.3 the LCD filtering is enabled with @FT_LCD_FILTER_DEFAULT.
- * It is no longer necessary to call this function explicitly except
- * to choose a different filter or disable filtering altogether with
- * @FT_LCD_FILTER_NONE.
- *
- * This function does nothing but returns `FT_Err_Unimplemented_Feature`
- * if the configuration macro `FT_CONFIG_OPTION_SUBPIXEL_RENDERING` is
- * not defined in your build of the library.
- *
- * @since:
- * 2.3.0
- */
- FT_EXPORT( FT_Error )
- FT_Library_SetLcdFilter( FT_Library library,
- FT_LcdFilter filter );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Library_SetLcdFilterWeights
- *
- * @description:
- * This function can be used to enable LCD filter with custom weights,
- * instead of using presets in @FT_Library_SetLcdFilter.
- *
- * @input:
- * library ::
- * A handle to the target library instance.
- *
- * weights ::
- * A pointer to an array; the function copies the first five bytes and
- * uses them to specify the filter weights in 1/256 units.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * This function does nothing but returns `FT_Err_Unimplemented_Feature`
- * if the configuration macro `FT_CONFIG_OPTION_SUBPIXEL_RENDERING` is
- * not defined in your build of the library.
- *
- * LCD filter weights can also be set per face using @FT_Face_Properties
- * with @FT_PARAM_TAG_LCD_FILTER_WEIGHTS.
- *
- * @since:
- * 2.4.0
- */
- FT_EXPORT( FT_Error )
- FT_Library_SetLcdFilterWeights( FT_Library library,
- unsigned char *weights );
-
-
- /**************************************************************************
- *
- * @type:
- * FT_LcdFiveTapFilter
- *
- * @description:
- * A typedef for passing the five LCD filter weights to
- * @FT_Face_Properties within an @FT_Parameter structure.
- *
- * @since:
- * 2.8
- *
- */
-#define FT_LCD_FILTER_FIVE_TAPS 5
-
- typedef FT_Byte FT_LcdFiveTapFilter[FT_LCD_FILTER_FIVE_TAPS];
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Library_SetLcdGeometry
- *
- * @description:
- * This function can be used to modify default positions of color
- * subpixels, which controls Harmony LCD rendering.
- *
- * @input:
- * library ::
- * A handle to the target library instance.
- *
- * sub ::
- * A pointer to an array of 3 vectors in 26.6 fractional pixel format;
- * the function modifies the default values, see the note below.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * Subpixel geometry examples:
- *
- * - {{-21, 0}, {0, 0}, {21, 0}} is the default, corresponding to 3 color
- * stripes shifted by a third of a pixel. This could be an RGB panel.
- *
- * - {{21, 0}, {0, 0}, {-21, 0}} looks the same as the default but can
- * specify a BGR panel instead, while keeping the bitmap in the same
- * RGB888 format.
- *
- * - {{0, 21}, {0, 0}, {0, -21}} is the vertical RGB, but the bitmap
- * stays RGB888 as a result.
- *
- * - {{-11, 16}, {-11, -16}, {22, 0}} is a certain PenTile arrangement.
- *
- * This function does nothing and returns `FT_Err_Unimplemented_Feature`
- * in the context of ClearType-style subpixel rendering when
- * `FT_CONFIG_OPTION_SUBPIXEL_RENDERING` is defined in your build of the
- * library.
- *
- * @since:
- * 2.10.0
- */
- FT_EXPORT( FT_Error )
- FT_Library_SetLcdGeometry( FT_Library library,
- FT_Vector sub[3] );
-
- /* */
-
-
-FT_END_HEADER
-
-#endif /* FTLCDFIL_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/ftlist.h b/contrib/libs/freetype/include/freetype/ftlist.h
deleted file mode 100644
index 972fbfa2fe..0000000000
--- a/contrib/libs/freetype/include/freetype/ftlist.h
+++ /dev/null
@@ -1,296 +0,0 @@
-/****************************************************************************
- *
- * ftlist.h
- *
- * Generic list support for FreeType (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /**************************************************************************
- *
- * This file implements functions relative to list processing. Its data
- * structures are defined in `freetype.h`.
- *
- */
-
-
-#ifndef FTLIST_H_
-#define FTLIST_H_
-
-
-#include <freetype/freetype.h>
-
-#ifdef FREETYPE_H
-#error "freetype.h of FreeType 1 has been loaded!"
-#error "Please fix the directory search order for header files"
-#error "so that freetype.h of FreeType 2 is found first."
-#endif
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @section:
- * list_processing
- *
- * @title:
- * List Processing
- *
- * @abstract:
- * Simple management of lists.
- *
- * @description:
- * This section contains various definitions related to list processing
- * using doubly-linked nodes.
- *
- * @order:
- * FT_List
- * FT_ListNode
- * FT_ListRec
- * FT_ListNodeRec
- *
- * FT_List_Add
- * FT_List_Insert
- * FT_List_Find
- * FT_List_Remove
- * FT_List_Up
- * FT_List_Iterate
- * FT_List_Iterator
- * FT_List_Finalize
- * FT_List_Destructor
- *
- */
-
-
- /**************************************************************************
- *
- * @function:
- * FT_List_Find
- *
- * @description:
- * Find the list node for a given listed object.
- *
- * @input:
- * list ::
- * A pointer to the parent list.
- * data ::
- * The address of the listed object.
- *
- * @return:
- * List node. `NULL` if it wasn't found.
- */
- FT_EXPORT( FT_ListNode )
- FT_List_Find( FT_List list,
- void* data );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_List_Add
- *
- * @description:
- * Append an element to the end of a list.
- *
- * @inout:
- * list ::
- * A pointer to the parent list.
- * node ::
- * The node to append.
- */
- FT_EXPORT( void )
- FT_List_Add( FT_List list,
- FT_ListNode node );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_List_Insert
- *
- * @description:
- * Insert an element at the head of a list.
- *
- * @inout:
- * list ::
- * A pointer to parent list.
- * node ::
- * The node to insert.
- */
- FT_EXPORT( void )
- FT_List_Insert( FT_List list,
- FT_ListNode node );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_List_Remove
- *
- * @description:
- * Remove a node from a list. This function doesn't check whether the
- * node is in the list!
- *
- * @input:
- * node ::
- * The node to remove.
- *
- * @inout:
- * list ::
- * A pointer to the parent list.
- */
- FT_EXPORT( void )
- FT_List_Remove( FT_List list,
- FT_ListNode node );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_List_Up
- *
- * @description:
- * Move a node to the head/top of a list. Used to maintain LRU lists.
- *
- * @inout:
- * list ::
- * A pointer to the parent list.
- * node ::
- * The node to move.
- */
- FT_EXPORT( void )
- FT_List_Up( FT_List list,
- FT_ListNode node );
-
-
- /**************************************************************************
- *
- * @functype:
- * FT_List_Iterator
- *
- * @description:
- * An FT_List iterator function that is called during a list parse by
- * @FT_List_Iterate.
- *
- * @input:
- * node ::
- * The current iteration list node.
- *
- * user ::
- * A typeless pointer passed to @FT_List_Iterate. Can be used to point
- * to the iteration's state.
- */
- typedef FT_Error
- (*FT_List_Iterator)( FT_ListNode node,
- void* user );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_List_Iterate
- *
- * @description:
- * Parse a list and calls a given iterator function on each element.
- * Note that parsing is stopped as soon as one of the iterator calls
- * returns a non-zero value.
- *
- * @input:
- * list ::
- * A handle to the list.
- * iterator ::
- * An iterator function, called on each node of the list.
- * user ::
- * A user-supplied field that is passed as the second argument to the
- * iterator.
- *
- * @return:
- * The result (a FreeType error code) of the last iterator call.
- */
- FT_EXPORT( FT_Error )
- FT_List_Iterate( FT_List list,
- FT_List_Iterator iterator,
- void* user );
-
-
- /**************************************************************************
- *
- * @functype:
- * FT_List_Destructor
- *
- * @description:
- * An @FT_List iterator function that is called during a list
- * finalization by @FT_List_Finalize to destroy all elements in a given
- * list.
- *
- * @input:
- * system ::
- * The current system object.
- *
- * data ::
- * The current object to destroy.
- *
- * user ::
- * A typeless pointer passed to @FT_List_Iterate. It can be used to
- * point to the iteration's state.
- */
- typedef void
- (*FT_List_Destructor)( FT_Memory memory,
- void* data,
- void* user );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_List_Finalize
- *
- * @description:
- * Destroy all elements in the list as well as the list itself.
- *
- * @input:
- * list ::
- * A handle to the list.
- *
- * destroy ::
- * A list destructor that will be applied to each element of the list.
- * Set this to `NULL` if not needed.
- *
- * memory ::
- * The current memory object that handles deallocation.
- *
- * user ::
- * A user-supplied field that is passed as the last argument to the
- * destructor.
- *
- * @note:
- * This function expects that all nodes added by @FT_List_Add or
- * @FT_List_Insert have been dynamically allocated.
- */
- FT_EXPORT( void )
- FT_List_Finalize( FT_List list,
- FT_List_Destructor destroy,
- FT_Memory memory,
- void* user );
-
- /* */
-
-
-FT_END_HEADER
-
-#endif /* FTLIST_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/ftlogging.h b/contrib/libs/freetype/include/freetype/ftlogging.h
deleted file mode 100644
index 1813cfc2c2..0000000000
--- a/contrib/libs/freetype/include/freetype/ftlogging.h
+++ /dev/null
@@ -1,184 +0,0 @@
-/****************************************************************************
- *
- * ftlogging.h
- *
- * Additional debugging APIs.
- *
- * Copyright (C) 2020-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTLOGGING_H_
-#define FTLOGGING_H_
-
-
-#include <ft2build.h>
-#include FT_CONFIG_CONFIG_H
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @section:
- * debugging_apis
- *
- * @title:
- * External Debugging APIs
- *
- * @abstract:
- * Public APIs to control the `FT_DEBUG_LOGGING` macro.
- *
- * @description:
- * This section contains the declarations of public functions that
- * enables fine control of what the `FT_DEBUG_LOGGING` macro outputs.
- *
- */
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Trace_Set_Level
- *
- * @description:
- * Change the levels of tracing components of FreeType at run time.
- *
- * @input:
- * tracing_level ::
- * New tracing value.
- *
- * @example:
- * The following call makes FreeType trace everything but the 'memory'
- * component.
- *
- * ```
- * FT_Trace_Set_Level( "any:7 memory:0" );
- * ```
- *
- * @note:
- * This function does nothing if compilation option `FT_DEBUG_LOGGING`
- * isn't set.
- *
- * @since:
- * 2.11
- *
- */
- FT_EXPORT( void )
- FT_Trace_Set_Level( const char* tracing_level );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Trace_Set_Default_Level
- *
- * @description:
- * Reset tracing value of FreeType's components to the default value
- * (i.e., to the value of the `FT2_DEBUG` environment value or to NULL
- * if `FT2_DEBUG` is not set).
- *
- * @note:
- * This function does nothing if compilation option `FT_DEBUG_LOGGING`
- * isn't set.
- *
- * @since:
- * 2.11
- *
- */
- FT_EXPORT( void )
- FT_Trace_Set_Default_Level( void );
-
-
- /**************************************************************************
- *
- * @functype:
- * FT_Custom_Log_Handler
- *
- * @description:
- * A function typedef that is used to handle the logging of tracing and
- * debug messages on a file system.
- *
- * @input:
- * ft_component ::
- * The name of `FT_COMPONENT` from which the current debug or error
- * message is produced.
- *
- * fmt ::
- * Actual debug or tracing message.
- *
- * args::
- * Arguments of debug or tracing messages.
- *
- * @since:
- * 2.11
- *
- */
- typedef void
- (*FT_Custom_Log_Handler)( const char* ft_component,
- const char* fmt,
- va_list args );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Set_Log_Handler
- *
- * @description:
- * A function to set a custom log handler.
- *
- * @input:
- * handler ::
- * New logging function.
- *
- * @note:
- * This function does nothing if compilation option `FT_DEBUG_LOGGING`
- * isn't set.
- *
- * @since:
- * 2.11
- *
- */
- FT_EXPORT( void )
- FT_Set_Log_Handler( FT_Custom_Log_Handler handler );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Set_Default_Log_Handler
- *
- * @description:
- * A function to undo the effect of @FT_Set_Log_Handler, resetting the
- * log handler to FreeType's built-in version.
- *
- * @note:
- * This function does nothing if compilation option `FT_DEBUG_LOGGING`
- * isn't set.
- *
- * @since:
- * 2.11
- *
- */
- FT_EXPORT( void )
- FT_Set_Default_Log_Handler( void );
-
- /* */
-
-
-FT_END_HEADER
-
-#endif /* FTLOGGING_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/ftlzw.h b/contrib/libs/freetype/include/freetype/ftlzw.h
deleted file mode 100644
index bcf59ba706..0000000000
--- a/contrib/libs/freetype/include/freetype/ftlzw.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/****************************************************************************
- *
- * ftlzw.h
- *
- * LZW-compressed stream support.
- *
- * Copyright (C) 2004-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTLZW_H_
-#define FTLZW_H_
-
-#include <freetype/freetype.h>
-
-#ifdef FREETYPE_H
-#error "freetype.h of FreeType 1 has been loaded!"
-#error "Please fix the directory search order for header files"
-#error "so that freetype.h of FreeType 2 is found first."
-#endif
-
-
-FT_BEGIN_HEADER
-
- /**************************************************************************
- *
- * @section:
- * lzw
- *
- * @title:
- * LZW Streams
- *
- * @abstract:
- * Using LZW-compressed font files.
- *
- * @description:
- * In certain builds of the library, LZW compression recognition is
- * automatically handled when calling @FT_New_Face or @FT_Open_Face.
- * This means that if no font driver is capable of handling the raw
- * compressed file, the library will try to open a LZW stream from it and
- * re-open the face with it.
- *
- * The stream implementation is very basic and resets the decompression
- * process each time seeking backwards is needed within the stream,
- * which significantly undermines the performance.
- *
- * This section contains the declaration of LZW-specific functions.
- *
- */
-
- /**************************************************************************
- *
- * @function:
- * FT_Stream_OpenLZW
- *
- * @description:
- * Open a new stream to parse LZW-compressed font files. This is mainly
- * used to support the compressed `*.pcf.Z` fonts that come with XFree86.
- *
- * @input:
- * stream ::
- * The target embedding stream.
- *
- * source ::
- * The source stream.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * The source stream must be opened _before_ calling this function.
- *
- * Calling the internal function `FT_Stream_Close` on the new stream will
- * **not** call `FT_Stream_Close` on the source stream. None of the
- * stream objects will be released to the heap.
- *
- * This function may return `FT_Err_Unimplemented_Feature` if your build
- * of FreeType was not compiled with LZW support.
- */
- FT_EXPORT( FT_Error )
- FT_Stream_OpenLZW( FT_Stream stream,
- FT_Stream source );
-
- /* */
-
-
-FT_END_HEADER
-
-#endif /* FTLZW_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/ftmac.h b/contrib/libs/freetype/include/freetype/ftmac.h
deleted file mode 100644
index e4efde33dd..0000000000
--- a/contrib/libs/freetype/include/freetype/ftmac.h
+++ /dev/null
@@ -1,289 +0,0 @@
-/****************************************************************************
- *
- * ftmac.h
- *
- * Additional Mac-specific API.
- *
- * Copyright (C) 1996-2024 by
- * Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-/****************************************************************************
- *
- * NOTE: Include this file after `FT_FREETYPE_H` and after any
- * Mac-specific headers (because this header uses Mac types such as
- * 'Handle', 'FSSpec', 'FSRef', etc.)
- *
- */
-
-
-#ifndef FTMAC_H_
-#define FTMAC_H_
-
-
-
-
-FT_BEGIN_HEADER
-
-
- /* gcc-3.1 and later can warn about functions tagged as deprecated */
-#ifndef FT_DEPRECATED_ATTRIBUTE
-#if defined( __GNUC__ ) && \
- ( ( __GNUC__ >= 4 ) || \
- ( ( __GNUC__ == 3 ) && ( __GNUC_MINOR__ >= 1 ) ) )
-#define FT_DEPRECATED_ATTRIBUTE __attribute__(( deprecated ))
-#else
-#define FT_DEPRECATED_ATTRIBUTE
-#endif
-#endif
-
-
- /**************************************************************************
- *
- * @section:
- * mac_specific
- *
- * @title:
- * Mac Specific Interface
- *
- * @abstract:
- * Only available on the Macintosh.
- *
- * @description:
- * The following definitions are only available if FreeType is compiled
- * on a Macintosh.
- *
- */
-
-
- /**************************************************************************
- *
- * @function:
- * FT_New_Face_From_FOND
- *
- * @description:
- * Create a new face object from a FOND resource.
- *
- * @inout:
- * library ::
- * A handle to the library resource.
- *
- * @input:
- * fond ::
- * A FOND resource.
- *
- * face_index ::
- * Only supported for the -1 'sanity check' special case.
- *
- * @output:
- * aface ::
- * A handle to a new face object.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @example:
- * This function can be used to create @FT_Face objects from fonts that
- * are installed in the system as follows.
- *
- * ```
- * fond = GetResource( 'FOND', fontName );
- * error = FT_New_Face_From_FOND( library, fond, 0, &face );
- * ```
- */
- FT_EXPORT( FT_Error )
- FT_New_Face_From_FOND( FT_Library library,
- Handle fond,
- FT_Long face_index,
- FT_Face *aface )
- FT_DEPRECATED_ATTRIBUTE;
-
-
- /**************************************************************************
- *
- * @function:
- * FT_GetFile_From_Mac_Name
- *
- * @description:
- * Return an FSSpec for the disk file containing the named font.
- *
- * @input:
- * fontName ::
- * Mac OS name of the font (e.g., Times New Roman Bold).
- *
- * @output:
- * pathSpec ::
- * FSSpec to the file. For passing to @FT_New_Face_From_FSSpec.
- *
- * face_index ::
- * Index of the face. For passing to @FT_New_Face_From_FSSpec.
- *
- * @return:
- * FreeType error code. 0~means success.
- */
- FT_EXPORT( FT_Error )
- FT_GetFile_From_Mac_Name( const char* fontName,
- FSSpec* pathSpec,
- FT_Long* face_index )
- FT_DEPRECATED_ATTRIBUTE;
-
-
- /**************************************************************************
- *
- * @function:
- * FT_GetFile_From_Mac_ATS_Name
- *
- * @description:
- * Return an FSSpec for the disk file containing the named font.
- *
- * @input:
- * fontName ::
- * Mac OS name of the font in ATS framework.
- *
- * @output:
- * pathSpec ::
- * FSSpec to the file. For passing to @FT_New_Face_From_FSSpec.
- *
- * face_index ::
- * Index of the face. For passing to @FT_New_Face_From_FSSpec.
- *
- * @return:
- * FreeType error code. 0~means success.
- */
- FT_EXPORT( FT_Error )
- FT_GetFile_From_Mac_ATS_Name( const char* fontName,
- FSSpec* pathSpec,
- FT_Long* face_index )
- FT_DEPRECATED_ATTRIBUTE;
-
-
- /**************************************************************************
- *
- * @function:
- * FT_GetFilePath_From_Mac_ATS_Name
- *
- * @description:
- * Return a pathname of the disk file and face index for given font name
- * that is handled by ATS framework.
- *
- * @input:
- * fontName ::
- * Mac OS name of the font in ATS framework.
- *
- * @output:
- * path ::
- * Buffer to store pathname of the file. For passing to @FT_New_Face.
- * The client must allocate this buffer before calling this function.
- *
- * maxPathSize ::
- * Lengths of the buffer `path` that client allocated.
- *
- * face_index ::
- * Index of the face. For passing to @FT_New_Face.
- *
- * @return:
- * FreeType error code. 0~means success.
- */
- FT_EXPORT( FT_Error )
- FT_GetFilePath_From_Mac_ATS_Name( const char* fontName,
- UInt8* path,
- UInt32 maxPathSize,
- FT_Long* face_index )
- FT_DEPRECATED_ATTRIBUTE;
-
-
- /**************************************************************************
- *
- * @function:
- * FT_New_Face_From_FSSpec
- *
- * @description:
- * Create a new face object from a given resource and typeface index
- * using an FSSpec to the font file.
- *
- * @inout:
- * library ::
- * A handle to the library resource.
- *
- * @input:
- * spec ::
- * FSSpec to the font file.
- *
- * face_index ::
- * The index of the face within the resource. The first face has
- * index~0.
- * @output:
- * aface ::
- * A handle to a new face object.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * @FT_New_Face_From_FSSpec is identical to @FT_New_Face except it
- * accepts an FSSpec instead of a path.
- */
- FT_EXPORT( FT_Error )
- FT_New_Face_From_FSSpec( FT_Library library,
- const FSSpec *spec,
- FT_Long face_index,
- FT_Face *aface )
- FT_DEPRECATED_ATTRIBUTE;
-
-
- /**************************************************************************
- *
- * @function:
- * FT_New_Face_From_FSRef
- *
- * @description:
- * Create a new face object from a given resource and typeface index
- * using an FSRef to the font file.
- *
- * @inout:
- * library ::
- * A handle to the library resource.
- *
- * @input:
- * spec ::
- * FSRef to the font file.
- *
- * face_index ::
- * The index of the face within the resource. The first face has
- * index~0.
- * @output:
- * aface ::
- * A handle to a new face object.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * @FT_New_Face_From_FSRef is identical to @FT_New_Face except it accepts
- * an FSRef instead of a path.
- */
- FT_EXPORT( FT_Error )
- FT_New_Face_From_FSRef( FT_Library library,
- const FSRef *ref,
- FT_Long face_index,
- FT_Face *aface )
- FT_DEPRECATED_ATTRIBUTE;
-
- /* */
-
-
-FT_END_HEADER
-
-
-#endif /* FTMAC_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/ftmm.h b/contrib/libs/freetype/include/freetype/ftmm.h
deleted file mode 100644
index 35ed039c89..0000000000
--- a/contrib/libs/freetype/include/freetype/ftmm.h
+++ /dev/null
@@ -1,834 +0,0 @@
-/****************************************************************************
- *
- * ftmm.h
- *
- * FreeType Multiple Master font interface (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTMM_H_
-#define FTMM_H_
-
-#include <freetype/freetype.h>
-
-#ifdef FREETYPE_H
-#error "freetype.h of FreeType 1 has been loaded!"
-#error "Please fix the directory search order for header files"
-#error "so that freetype.h of FreeType 2 is found first."
-#endif
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @section:
- * multiple_masters
- *
- * @title:
- * Multiple Masters
- *
- * @abstract:
- * How to manage Multiple Masters fonts.
- *
- * @description:
- * The following types and functions are used to manage Multiple Master
- * fonts, i.e., the selection of specific design instances by setting
- * design axis coordinates.
- *
- * Besides Adobe MM fonts, the interface supports Apple's TrueType GX and
- * OpenType variation fonts. Some of the routines only work with Adobe
- * MM fonts, others will work with all three types. They are similar
- * enough that a consistent interface makes sense.
- *
- * For Adobe MM fonts, macro @FT_IS_SFNT returns false. For GX and
- * OpenType variation fonts, it returns true.
- *
- */
-
-
- /**************************************************************************
- *
- * @enum:
- * T1_MAX_MM_XXX
- *
- * @description:
- * Multiple Masters limits as defined in their specifications.
- *
- * @values:
- * T1_MAX_MM_AXIS ::
- * The maximum number of Multiple Masters axes.
- *
- * T1_MAX_MM_DESIGNS ::
- * The maximum number of Multiple Masters designs.
- *
- * T1_MAX_MM_MAP_POINTS ::
- * The maximum number of elements in a design map.
- *
- */
-#define T1_MAX_MM_AXIS 4
-#define T1_MAX_MM_DESIGNS 16
-#define T1_MAX_MM_MAP_POINTS 20
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_MM_Axis
- *
- * @description:
- * A structure to model a given axis in design space for Multiple Masters
- * fonts.
- *
- * This structure can't be used for TrueType GX or OpenType variation
- * fonts.
- *
- * @fields:
- * name ::
- * The axis's name.
- *
- * minimum ::
- * The axis's minimum design coordinate.
- *
- * maximum ::
- * The axis's maximum design coordinate.
- */
- typedef struct FT_MM_Axis_
- {
- FT_String* name;
- FT_Long minimum;
- FT_Long maximum;
-
- } FT_MM_Axis;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_Multi_Master
- *
- * @description:
- * A structure to model the axes and space of a Multiple Masters font.
- *
- * This structure can't be used for TrueType GX or OpenType variation
- * fonts.
- *
- * @fields:
- * num_axis ::
- * Number of axes. Cannot exceed~4.
- *
- * num_designs ::
- * Number of designs; should be normally 2^num_axis even though the
- * Type~1 specification strangely allows for intermediate designs to be
- * present. This number cannot exceed~16.
- *
- * axis ::
- * A table of axis descriptors.
- */
- typedef struct FT_Multi_Master_
- {
- FT_UInt num_axis;
- FT_UInt num_designs;
- FT_MM_Axis axis[T1_MAX_MM_AXIS];
-
- } FT_Multi_Master;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_Var_Axis
- *
- * @description:
- * A structure to model a given axis in design space for Multiple
- * Masters, TrueType GX, and OpenType variation fonts.
- *
- * @fields:
- * name ::
- * The axis's name. Not always meaningful for TrueType GX or OpenType
- * variation fonts.
- *
- * minimum ::
- * The axis's minimum design coordinate.
- *
- * def ::
- * The axis's default design coordinate. FreeType computes meaningful
- * default values for Adobe MM fonts.
- *
- * maximum ::
- * The axis's maximum design coordinate.
- *
- * tag ::
- * The axis's tag (the equivalent to 'name' for TrueType GX and
- * OpenType variation fonts). FreeType provides default values for
- * Adobe MM fonts if possible.
- *
- * strid ::
- * The axis name entry in the font's 'name' table. This is another
- * (and often better) version of the 'name' field for TrueType GX or
- * OpenType variation fonts. Not meaningful for Adobe MM fonts.
- *
- * @note:
- * The fields `minimum`, `def`, and `maximum` are 16.16 fractional values
- * for TrueType GX and OpenType variation fonts. For Adobe MM fonts, the
- * values are whole numbers (i.e., the fractional part is zero).
- */
- typedef struct FT_Var_Axis_
- {
- FT_String* name;
-
- FT_Fixed minimum;
- FT_Fixed def;
- FT_Fixed maximum;
-
- FT_ULong tag;
- FT_UInt strid;
-
- } FT_Var_Axis;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_Var_Named_Style
- *
- * @description:
- * A structure to model a named instance in a TrueType GX or OpenType
- * variation font.
- *
- * This structure can't be used for Adobe MM fonts.
- *
- * @fields:
- * coords ::
- * The design coordinates for this instance. This is an array with one
- * entry for each axis.
- *
- * strid ::
- * The entry in 'name' table identifying this instance.
- *
- * psid ::
- * The entry in 'name' table identifying a PostScript name for this
- * instance. Value 0xFFFF indicates a missing entry.
- */
- typedef struct FT_Var_Named_Style_
- {
- FT_Fixed* coords;
- FT_UInt strid;
- FT_UInt psid; /* since 2.7.1 */
-
- } FT_Var_Named_Style;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_MM_Var
- *
- * @description:
- * A structure to model the axes and space of an Adobe MM, TrueType GX,
- * or OpenType variation font.
- *
- * Some fields are specific to one format and not to the others.
- *
- * @fields:
- * num_axis ::
- * The number of axes. The maximum value is~4 for Adobe MM fonts; no
- * limit in TrueType GX or OpenType variation fonts.
- *
- * num_designs ::
- * The number of designs; should be normally 2^num_axis for Adobe MM
- * fonts. Not meaningful for TrueType GX or OpenType variation fonts
- * (where every glyph could have a different number of designs).
- *
- * num_namedstyles ::
- * The number of named styles; a 'named style' is a tuple of design
- * coordinates that has a string ID (in the 'name' table) associated
- * with it. The font can tell the user that, for example,
- * [Weight=1.5,Width=1.1] is 'Bold'. Another name for 'named style' is
- * 'named instance'.
- *
- * For Adobe Multiple Masters fonts, this value is always zero because
- * the format does not support named styles.
- *
- * axis ::
- * An axis descriptor table. TrueType GX and OpenType variation fonts
- * contain slightly more data than Adobe MM fonts. Memory management
- * of this pointer is done internally by FreeType.
- *
- * namedstyle ::
- * A named style (instance) table. Only meaningful for TrueType GX and
- * OpenType variation fonts. Memory management of this pointer is done
- * internally by FreeType.
- */
- typedef struct FT_MM_Var_
- {
- FT_UInt num_axis;
- FT_UInt num_designs;
- FT_UInt num_namedstyles;
- FT_Var_Axis* axis;
- FT_Var_Named_Style* namedstyle;
-
- } FT_MM_Var;
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_Multi_Master
- *
- * @description:
- * Retrieve a variation descriptor of a given Adobe MM font.
- *
- * This function can't be used with TrueType GX or OpenType variation
- * fonts.
- *
- * @input:
- * face ::
- * A handle to the source face.
- *
- * @output:
- * amaster ::
- * The Multiple Masters descriptor.
- *
- * @return:
- * FreeType error code. 0~means success.
- */
- FT_EXPORT( FT_Error )
- FT_Get_Multi_Master( FT_Face face,
- FT_Multi_Master *amaster );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_MM_Var
- *
- * @description:
- * Retrieve a variation descriptor for a given font.
- *
- * This function works with all supported variation formats.
- *
- * @input:
- * face ::
- * A handle to the source face.
- *
- * @output:
- * amaster ::
- * The variation descriptor. Allocates a data structure, which the
- * user must deallocate with a call to @FT_Done_MM_Var after use.
- *
- * @return:
- * FreeType error code. 0~means success.
- */
- FT_EXPORT( FT_Error )
- FT_Get_MM_Var( FT_Face face,
- FT_MM_Var* *amaster );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Done_MM_Var
- *
- * @description:
- * Free the memory allocated by @FT_Get_MM_Var.
- *
- * @input:
- * library ::
- * A handle of the face's parent library object that was used in the
- * call to @FT_Get_MM_Var to create `amaster`.
- *
- * @return:
- * FreeType error code. 0~means success.
- */
- FT_EXPORT( FT_Error )
- FT_Done_MM_Var( FT_Library library,
- FT_MM_Var *amaster );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Set_MM_Design_Coordinates
- *
- * @description:
- * For Adobe MM fonts, choose an interpolated font design through design
- * coordinates.
- *
- * This function can't be used with TrueType GX or OpenType variation
- * fonts.
- *
- * @inout:
- * face ::
- * A handle to the source face.
- *
- * @input:
- * num_coords ::
- * The number of available design coordinates. If it is larger than
- * the number of axes, ignore the excess values. If it is smaller than
- * the number of axes, use default values for the remaining axes.
- *
- * coords ::
- * An array of design coordinates.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * [Since 2.8.1] To reset all axes to the default values, call the
- * function with `num_coords` set to zero and `coords` set to `NULL`.
- *
- * [Since 2.9] If `num_coords` is larger than zero, this function sets
- * the @FT_FACE_FLAG_VARIATION bit in @FT_Face's `face_flags` field
- * (i.e., @FT_IS_VARIATION will return true). If `num_coords` is zero,
- * this bit flag gets unset.
- */
- FT_EXPORT( FT_Error )
- FT_Set_MM_Design_Coordinates( FT_Face face,
- FT_UInt num_coords,
- FT_Long* coords );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Set_Var_Design_Coordinates
- *
- * @description:
- * Choose an interpolated font design through design coordinates.
- *
- * This function works with all supported variation formats.
- *
- * @inout:
- * face ::
- * A handle to the source face.
- *
- * @input:
- * num_coords ::
- * The number of available design coordinates. If it is larger than
- * the number of axes, ignore the excess values. If it is smaller than
- * the number of axes, use default values for the remaining axes.
- *
- * coords ::
- * An array of design coordinates.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * The design coordinates are 16.16 fractional values for TrueType GX and
- * OpenType variation fonts. For Adobe MM fonts, the values are supposed
- * to be whole numbers (i.e., the fractional part is zero).
- *
- * [Since 2.8.1] To reset all axes to the default values, call the
- * function with `num_coords` set to zero and `coords` set to `NULL`.
- * [Since 2.9] 'Default values' means the currently selected named
- * instance (or the base font if no named instance is selected).
- *
- * [Since 2.9] If `num_coords` is larger than zero, this function sets
- * the @FT_FACE_FLAG_VARIATION bit in @FT_Face's `face_flags` field
- * (i.e., @FT_IS_VARIATION will return true). If `num_coords` is zero,
- * this bit flag gets unset.
- */
- FT_EXPORT( FT_Error )
- FT_Set_Var_Design_Coordinates( FT_Face face,
- FT_UInt num_coords,
- FT_Fixed* coords );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_Var_Design_Coordinates
- *
- * @description:
- * Get the design coordinates of the currently selected interpolated
- * font.
- *
- * This function works with all supported variation formats.
- *
- * @input:
- * face ::
- * A handle to the source face.
- *
- * num_coords ::
- * The number of design coordinates to retrieve. If it is larger than
- * the number of axes, set the excess values to~0.
- *
- * @output:
- * coords ::
- * The design coordinates array.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * The design coordinates are 16.16 fractional values for TrueType GX and
- * OpenType variation fonts. For Adobe MM fonts, the values are whole
- * numbers (i.e., the fractional part is zero).
- *
- * @since:
- * 2.7.1
- */
- FT_EXPORT( FT_Error )
- FT_Get_Var_Design_Coordinates( FT_Face face,
- FT_UInt num_coords,
- FT_Fixed* coords );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Set_MM_Blend_Coordinates
- *
- * @description:
- * Choose an interpolated font design through normalized blend
- * coordinates.
- *
- * This function works with all supported variation formats.
- *
- * @inout:
- * face ::
- * A handle to the source face.
- *
- * @input:
- * num_coords ::
- * The number of available design coordinates. If it is larger than
- * the number of axes, ignore the excess values. If it is smaller than
- * the number of axes, use default values for the remaining axes.
- *
- * coords ::
- * The design coordinates array. Each element is a 16.16 fractional
- * value and must be between 0 and 1.0 for Adobe MM fonts, and between
- * -1.0 and 1.0 for TrueType GX and OpenType variation fonts.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * [Since 2.8.1] To reset all axes to the default values, call the
- * function with `num_coords` set to zero and `coords` set to `NULL`.
- * [Since 2.9] 'Default values' means the currently selected named
- * instance (or the base font if no named instance is selected).
- *
- * [Since 2.9] If `num_coords` is larger than zero, this function sets
- * the @FT_FACE_FLAG_VARIATION bit in @FT_Face's `face_flags` field
- * (i.e., @FT_IS_VARIATION will return true). If `num_coords` is zero,
- * this bit flag gets unset.
- */
- FT_EXPORT( FT_Error )
- FT_Set_MM_Blend_Coordinates( FT_Face face,
- FT_UInt num_coords,
- FT_Fixed* coords );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_MM_Blend_Coordinates
- *
- * @description:
- * Get the normalized blend coordinates of the currently selected
- * interpolated font.
- *
- * This function works with all supported variation formats.
- *
- * @input:
- * face ::
- * A handle to the source face.
- *
- * num_coords ::
- * The number of normalized blend coordinates to retrieve. If it is
- * larger than the number of axes, set the excess values to~0.5 for
- * Adobe MM fonts, and to~0 for TrueType GX and OpenType variation
- * fonts.
- *
- * @output:
- * coords ::
- * The normalized blend coordinates array (as 16.16 fractional values).
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @since:
- * 2.7.1
- */
- FT_EXPORT( FT_Error )
- FT_Get_MM_Blend_Coordinates( FT_Face face,
- FT_UInt num_coords,
- FT_Fixed* coords );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Set_Var_Blend_Coordinates
- *
- * @description:
- * This is another name of @FT_Set_MM_Blend_Coordinates.
- */
- FT_EXPORT( FT_Error )
- FT_Set_Var_Blend_Coordinates( FT_Face face,
- FT_UInt num_coords,
- FT_Fixed* coords );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_Var_Blend_Coordinates
- *
- * @description:
- * This is another name of @FT_Get_MM_Blend_Coordinates.
- *
- * @since:
- * 2.7.1
- */
- FT_EXPORT( FT_Error )
- FT_Get_Var_Blend_Coordinates( FT_Face face,
- FT_UInt num_coords,
- FT_Fixed* coords );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Set_MM_WeightVector
- *
- * @description:
- * For Adobe MM fonts, choose an interpolated font design by directly
- * setting the weight vector.
- *
- * This function can't be used with TrueType GX or OpenType variation
- * fonts.
- *
- * @inout:
- * face ::
- * A handle to the source face.
- *
- * @input:
- * len ::
- * The length of the weight vector array. If it is larger than the
- * number of designs, the extra values are ignored. If it is less than
- * the number of designs, the remaining values are set to zero.
- *
- * weightvector ::
- * An array representing the weight vector.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * Adobe Multiple Master fonts limit the number of designs, and thus the
- * length of the weight vector to 16~elements.
- *
- * If `len` is larger than zero, this function sets the
- * @FT_FACE_FLAG_VARIATION bit in @FT_Face's `face_flags` field (i.e.,
- * @FT_IS_VARIATION will return true). If `len` is zero, this bit flag
- * is unset and the weight vector array is reset to the default values.
- *
- * The Adobe documentation also states that the values in the
- * WeightVector array must total 1.0 +/-~0.001. In practice this does
- * not seem to be enforced, so is not enforced here, either.
- *
- * @since:
- * 2.10
- */
- FT_EXPORT( FT_Error )
- FT_Set_MM_WeightVector( FT_Face face,
- FT_UInt len,
- FT_Fixed* weightvector );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_MM_WeightVector
- *
- * @description:
- * For Adobe MM fonts, retrieve the current weight vector of the font.
- *
- * This function can't be used with TrueType GX or OpenType variation
- * fonts.
- *
- * @inout:
- * face ::
- * A handle to the source face.
- *
- * len ::
- * A pointer to the size of the array to be filled. If the size of the
- * array is less than the number of designs, `FT_Err_Invalid_Argument`
- * is returned, and `len` is set to the required size (the number of
- * designs). If the size of the array is greater than the number of
- * designs, the remaining entries are set to~0. On successful
- * completion, `len` is set to the number of designs (i.e., the number
- * of values written to the array).
- *
- * @output:
- * weightvector ::
- * An array to be filled.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * Adobe Multiple Master fonts limit the number of designs, and thus the
- * length of the WeightVector to~16.
- *
- * @since:
- * 2.10
- */
- FT_EXPORT( FT_Error )
- FT_Get_MM_WeightVector( FT_Face face,
- FT_UInt* len,
- FT_Fixed* weightvector );
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_VAR_AXIS_FLAG_XXX
- *
- * @description:
- * A list of bit flags used in the return value of
- * @FT_Get_Var_Axis_Flags.
- *
- * @values:
- * FT_VAR_AXIS_FLAG_HIDDEN ::
- * The variation axis should not be exposed to user interfaces.
- *
- * @since:
- * 2.8.1
- */
-#define FT_VAR_AXIS_FLAG_HIDDEN 1
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_Var_Axis_Flags
- *
- * @description:
- * Get the 'flags' field of an OpenType Variation Axis Record.
- *
- * Not meaningful for Adobe MM fonts (`*flags` is always zero).
- *
- * @input:
- * master ::
- * The variation descriptor.
- *
- * axis_index ::
- * The index of the requested variation axis.
- *
- * @output:
- * flags ::
- * The 'flags' field. See @FT_VAR_AXIS_FLAG_XXX for possible values.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @since:
- * 2.8.1
- */
- FT_EXPORT( FT_Error )
- FT_Get_Var_Axis_Flags( FT_MM_Var* master,
- FT_UInt axis_index,
- FT_UInt* flags );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Set_Named_Instance
- *
- * @description:
- * Set or change the current named instance.
- *
- * @input:
- * face ::
- * A handle to the source face.
- *
- * instance_index ::
- * The index of the requested instance, starting with value 1. If set
- * to value 0, FreeType switches to font access without a named
- * instance.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * The function uses the value of `instance_index` to set bits 16-30 of
- * the face's `face_index` field. It also resets any variation applied
- * to the font, and the @FT_FACE_FLAG_VARIATION bit of the face's
- * `face_flags` field gets reset to zero (i.e., @FT_IS_VARIATION will
- * return false).
- *
- * For Adobe MM fonts (which don't have named instances) this function
- * simply resets the current face to the default instance.
- *
- * @since:
- * 2.9
- */
- FT_EXPORT( FT_Error )
- FT_Set_Named_Instance( FT_Face face,
- FT_UInt instance_index );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_Default_Named_Instance
- *
- * @description:
- * Retrieve the index of the default named instance, to be used with
- * @FT_Set_Named_Instance.
- *
- * The default instance of a variation font is that instance for which
- * the nth axis coordinate is equal to `axis[n].def` (as specified in the
- * @FT_MM_Var structure), with~n covering all axes.
- *
- * FreeType synthesizes a named instance for the default instance if the
- * font does not contain such an entry.
- *
- * @input:
- * face ::
- * A handle to the source face.
- *
- * @output:
- * instance_index ::
- * The index of the default named instance.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * For Adobe MM fonts (which don't have named instances) this function
- * always returns zero for `instance_index`.
- *
- * @since:
- * 2.13.1
- */
- FT_EXPORT( FT_Error )
- FT_Get_Default_Named_Instance( FT_Face face,
- FT_UInt *instance_index );
-
- /* */
-
-
-FT_END_HEADER
-
-#endif /* FTMM_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/ftmodapi.h b/contrib/libs/freetype/include/freetype/ftmodapi.h
deleted file mode 100644
index 0ee715898f..0000000000
--- a/contrib/libs/freetype/include/freetype/ftmodapi.h
+++ /dev/null
@@ -1,807 +0,0 @@
-/****************************************************************************
- *
- * ftmodapi.h
- *
- * FreeType modules public interface (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTMODAPI_H_
-#define FTMODAPI_H_
-
-
-#include <freetype/freetype.h>
-
-#ifdef FREETYPE_H
-#error "freetype.h of FreeType 1 has been loaded!"
-#error "Please fix the directory search order for header files"
-#error "so that freetype.h of FreeType 2 is found first."
-#endif
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @section:
- * module_management
- *
- * @title:
- * Module Management
- *
- * @abstract:
- * How to add, upgrade, remove, and control modules from FreeType.
- *
- * @description:
- * The definitions below are used to manage modules within FreeType.
- * Internal and external modules can be added, upgraded, and removed at
- * runtime. For example, an alternative renderer or proprietary font
- * driver can be registered and prioritized. Additionally, some module
- * properties can also be controlled.
- *
- * Here is a list of existing values of the `module_name` field in the
- * @FT_Module_Class structure.
- *
- * ```
- * autofitter
- * bdf
- * cff
- * gxvalid
- * otvalid
- * pcf
- * pfr
- * psaux
- * pshinter
- * psnames
- * raster1
- * sfnt
- * smooth
- * truetype
- * type1
- * type42
- * t1cid
- * winfonts
- * ```
- *
- * Note that the FreeType Cache sub-system is not a FreeType module.
- *
- * @order:
- * FT_Module
- * FT_Module_Constructor
- * FT_Module_Destructor
- * FT_Module_Requester
- * FT_Module_Class
- *
- * FT_Add_Module
- * FT_Get_Module
- * FT_Remove_Module
- * FT_Add_Default_Modules
- *
- * FT_FACE_DRIVER_NAME
- * FT_Property_Set
- * FT_Property_Get
- * FT_Set_Default_Properties
- *
- * FT_New_Library
- * FT_Done_Library
- * FT_Reference_Library
- *
- * FT_Renderer
- * FT_Renderer_Class
- *
- * FT_Get_Renderer
- * FT_Set_Renderer
- *
- * FT_Set_Debug_Hook
- *
- */
-
-
- /* module bit flags */
-#define FT_MODULE_FONT_DRIVER 1 /* this module is a font driver */
-#define FT_MODULE_RENDERER 2 /* this module is a renderer */
-#define FT_MODULE_HINTER 4 /* this module is a glyph hinter */
-#define FT_MODULE_STYLER 8 /* this module is a styler */
-
-#define FT_MODULE_DRIVER_SCALABLE 0x100 /* the driver supports */
- /* scalable fonts */
-#define FT_MODULE_DRIVER_NO_OUTLINES 0x200 /* the driver does not */
- /* support vector outlines */
-#define FT_MODULE_DRIVER_HAS_HINTER 0x400 /* the driver provides its */
- /* own hinter */
-#define FT_MODULE_DRIVER_HINTS_LIGHTLY 0x800 /* the driver's hinter */
- /* produces LIGHT hints */
-
-
- /* deprecated values */
-#define ft_module_font_driver FT_MODULE_FONT_DRIVER
-#define ft_module_renderer FT_MODULE_RENDERER
-#define ft_module_hinter FT_MODULE_HINTER
-#define ft_module_styler FT_MODULE_STYLER
-
-#define ft_module_driver_scalable FT_MODULE_DRIVER_SCALABLE
-#define ft_module_driver_no_outlines FT_MODULE_DRIVER_NO_OUTLINES
-#define ft_module_driver_has_hinter FT_MODULE_DRIVER_HAS_HINTER
-#define ft_module_driver_hints_lightly FT_MODULE_DRIVER_HINTS_LIGHTLY
-
-
- typedef FT_Pointer FT_Module_Interface;
-
-
- /**************************************************************************
- *
- * @functype:
- * FT_Module_Constructor
- *
- * @description:
- * A function used to initialize (not create) a new module object.
- *
- * @input:
- * module ::
- * The module to initialize.
- */
- typedef FT_Error
- (*FT_Module_Constructor)( FT_Module module );
-
-
- /**************************************************************************
- *
- * @functype:
- * FT_Module_Destructor
- *
- * @description:
- * A function used to finalize (not destroy) a given module object.
- *
- * @input:
- * module ::
- * The module to finalize.
- */
- typedef void
- (*FT_Module_Destructor)( FT_Module module );
-
-
- /**************************************************************************
- *
- * @functype:
- * FT_Module_Requester
- *
- * @description:
- * A function used to query a given module for a specific interface.
- *
- * @input:
- * module ::
- * The module to be searched.
- *
- * name ::
- * The name of the interface in the module.
- */
- typedef FT_Module_Interface
- (*FT_Module_Requester)( FT_Module module,
- const char* name );
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_Module_Class
- *
- * @description:
- * The module class descriptor. While being a public structure necessary
- * for FreeType's module bookkeeping, most of the fields are essentially
- * internal, not to be used directly by an application.
- *
- * @fields:
- * module_flags ::
- * Bit flags describing the module.
- *
- * module_size ::
- * The size of one module object/instance in bytes.
- *
- * module_name ::
- * The name of the module.
- *
- * module_version ::
- * The version, as a 16.16 fixed number (major.minor).
- *
- * module_requires ::
- * The version of FreeType this module requires, as a 16.16 fixed
- * number (major.minor). Starts at version 2.0, i.e., 0x20000.
- *
- * module_interface ::
- * A typeless pointer to a structure (which varies between different
- * modules) that holds the module's interface functions. This is
- * essentially what `get_interface` returns.
- *
- * module_init ::
- * The initializing function.
- *
- * module_done ::
- * The finalizing function.
- *
- * get_interface ::
- * The interface requesting function.
- */
- typedef struct FT_Module_Class_
- {
- FT_ULong module_flags;
- FT_Long module_size;
- const FT_String* module_name;
- FT_Fixed module_version;
- FT_Fixed module_requires;
-
- const void* module_interface;
-
- FT_Module_Constructor module_init;
- FT_Module_Destructor module_done;
- FT_Module_Requester get_interface;
-
- } FT_Module_Class;
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Add_Module
- *
- * @description:
- * Add a new module to a given library instance.
- *
- * @inout:
- * library ::
- * A handle to the library object.
- *
- * @input:
- * clazz ::
- * A pointer to class descriptor for the module.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * An error will be returned if a module already exists by that name, or
- * if the module requires a version of FreeType that is too great.
- */
- FT_EXPORT( FT_Error )
- FT_Add_Module( FT_Library library,
- const FT_Module_Class* clazz );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_Module
- *
- * @description:
- * Find a module by its name.
- *
- * @input:
- * library ::
- * A handle to the library object.
- *
- * module_name ::
- * The module's name (as an ASCII string).
- *
- * @return:
- * A module handle. 0~if none was found.
- *
- * @note:
- * FreeType's internal modules aren't documented very well, and you
- * should look up the source code for details.
- */
- FT_EXPORT( FT_Module )
- FT_Get_Module( FT_Library library,
- const char* module_name );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Remove_Module
- *
- * @description:
- * Remove a given module from a library instance.
- *
- * @inout:
- * library ::
- * A handle to a library object.
- *
- * @input:
- * module ::
- * A handle to a module object.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * The module object is destroyed by the function in case of success.
- */
- FT_EXPORT( FT_Error )
- FT_Remove_Module( FT_Library library,
- FT_Module module );
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_FACE_DRIVER_NAME
- *
- * @description:
- * A macro that retrieves the name of a font driver from a face object.
- *
- * @note:
- * The font driver name is a valid `module_name` for @FT_Property_Set
- * and @FT_Property_Get. This is not the same as @FT_Get_Font_Format.
- *
- * @since:
- * 2.11
- *
- */
-#define FT_FACE_DRIVER_NAME( face ) \
- ( ( *FT_REINTERPRET_CAST( FT_Module_Class**, \
- ( face )->driver ) )->module_name )
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Property_Set
- *
- * @description:
- * Set a property for a given module.
- *
- * @input:
- * library ::
- * A handle to the library the module is part of.
- *
- * module_name ::
- * The module name.
- *
- * property_name ::
- * The property name. Properties are described in section
- * @properties.
- *
- * Note that only a few modules have properties.
- *
- * value ::
- * A generic pointer to a variable or structure that gives the new
- * value of the property. The exact definition of `value` is
- * dependent on the property; see section @properties.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * If `module_name` isn't a valid module name, or `property_name`
- * doesn't specify a valid property, or if `value` doesn't represent a
- * valid value for the given property, an error is returned.
- *
- * The following example sets property 'bar' (a simple integer) in
- * module 'foo' to value~1.
- *
- * ```
- * FT_UInt bar;
- *
- *
- * bar = 1;
- * FT_Property_Set( library, "foo", "bar", &bar );
- * ```
- *
- * Note that the FreeType Cache sub-system doesn't recognize module
- * property changes. To avoid glyph lookup confusion within the cache
- * you should call @FTC_Manager_Reset to completely flush the cache if a
- * module property gets changed after @FTC_Manager_New has been called.
- *
- * It is not possible to set properties of the FreeType Cache sub-system
- * itself with FT_Property_Set; use @FTC_Property_Set instead.
- *
- * @since:
- * 2.4.11
- *
- */
- FT_EXPORT( FT_Error )
- FT_Property_Set( FT_Library library,
- const FT_String* module_name,
- const FT_String* property_name,
- const void* value );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Property_Get
- *
- * @description:
- * Get a module's property value.
- *
- * @input:
- * library ::
- * A handle to the library the module is part of.
- *
- * module_name ::
- * The module name.
- *
- * property_name ::
- * The property name. Properties are described in section
- * @properties.
- *
- * @inout:
- * value ::
- * A generic pointer to a variable or structure that gives the value
- * of the property. The exact definition of `value` is dependent on
- * the property; see section @properties.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * If `module_name` isn't a valid module name, or `property_name`
- * doesn't specify a valid property, or if `value` doesn't represent a
- * valid value for the given property, an error is returned.
- *
- * The following example gets property 'baz' (a range) in module 'foo'.
- *
- * ```
- * typedef range_
- * {
- * FT_Int32 min;
- * FT_Int32 max;
- *
- * } range;
- *
- * range baz;
- *
- *
- * FT_Property_Get( library, "foo", "baz", &baz );
- * ```
- *
- * It is not possible to retrieve properties of the FreeType Cache
- * sub-system with FT_Property_Get; use @FTC_Property_Get instead.
- *
- * @since:
- * 2.4.11
- *
- */
- FT_EXPORT( FT_Error )
- FT_Property_Get( FT_Library library,
- const FT_String* module_name,
- const FT_String* property_name,
- void* value );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Set_Default_Properties
- *
- * @description:
- * If compilation option `FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES` is
- * set, this function reads the `FREETYPE_PROPERTIES` environment
- * variable to control driver properties. See section @properties for
- * more.
- *
- * If the compilation option is not set, this function does nothing.
- *
- * `FREETYPE_PROPERTIES` has the following syntax form (broken here into
- * multiple lines for better readability).
- *
- * ```
- * <optional whitespace>
- * <module-name1> ':'
- * <property-name1> '=' <property-value1>
- * <whitespace>
- * <module-name2> ':'
- * <property-name2> '=' <property-value2>
- * ...
- * ```
- *
- * Example:
- *
- * ```
- * FREETYPE_PROPERTIES=truetype:interpreter-version=35 \
- * cff:no-stem-darkening=0
- * ```
- *
- * @inout:
- * library ::
- * A handle to a new library object.
- *
- * @since:
- * 2.8
- */
- FT_EXPORT( void )
- FT_Set_Default_Properties( FT_Library library );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Reference_Library
- *
- * @description:
- * A counter gets initialized to~1 at the time an @FT_Library structure
- * is created. This function increments the counter. @FT_Done_Library
- * then only destroys a library if the counter is~1, otherwise it simply
- * decrements the counter.
- *
- * This function helps in managing life-cycles of structures that
- * reference @FT_Library objects.
- *
- * @input:
- * library ::
- * A handle to a target library object.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @since:
- * 2.4.2
- */
- FT_EXPORT( FT_Error )
- FT_Reference_Library( FT_Library library );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_New_Library
- *
- * @description:
- * This function is used to create a new FreeType library instance from a
- * given memory object. It is thus possible to use libraries with
- * distinct memory allocators within the same program. Note, however,
- * that the used @FT_Memory structure is expected to remain valid for the
- * life of the @FT_Library object.
- *
- * Normally, you would call this function (followed by a call to
- * @FT_Add_Default_Modules or a series of calls to @FT_Add_Module, and a
- * call to @FT_Set_Default_Properties) instead of @FT_Init_FreeType to
- * initialize the FreeType library.
- *
- * Don't use @FT_Done_FreeType but @FT_Done_Library to destroy a library
- * instance.
- *
- * @input:
- * memory ::
- * A handle to the original memory object.
- *
- * @output:
- * alibrary ::
- * A pointer to handle of a new library object.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * See the discussion of reference counters in the description of
- * @FT_Reference_Library.
- */
- FT_EXPORT( FT_Error )
- FT_New_Library( FT_Memory memory,
- FT_Library *alibrary );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Done_Library
- *
- * @description:
- * Discard a given library object. This closes all drivers and discards
- * all resource objects.
- *
- * @input:
- * library ::
- * A handle to the target library.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * See the discussion of reference counters in the description of
- * @FT_Reference_Library.
- */
- FT_EXPORT( FT_Error )
- FT_Done_Library( FT_Library library );
-
-
- /**************************************************************************
- *
- * @functype:
- * FT_DebugHook_Func
- *
- * @description:
- * A drop-in replacement (or rather a wrapper) for the bytecode or
- * charstring interpreter's main loop function.
- *
- * Its job is essentially
- *
- * - to activate debug mode to enforce single-stepping,
- *
- * - to call the main loop function to interpret the next opcode, and
- *
- * - to show the changed context to the user.
- *
- * An example for such a main loop function is `TT_RunIns` (declared in
- * FreeType's internal header file `src/truetype/ttinterp.h`).
- *
- * Have a look at the source code of the `ttdebug` FreeType demo program
- * for an example of a drop-in replacement.
- *
- * @inout:
- * arg ::
- * A typeless pointer, to be cast to the main loop function's data
- * structure (which depends on the font module). For TrueType fonts
- * it is bytecode interpreter's execution context, `TT_ExecContext`,
- * which is declared in FreeType's internal header file `tttypes.h`.
- */
- typedef FT_Error
- (*FT_DebugHook_Func)( void* arg );
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_DEBUG_HOOK_XXX
- *
- * @description:
- * A list of named debug hook indices.
- *
- * @values:
- * FT_DEBUG_HOOK_TRUETYPE::
- * This hook index identifies the TrueType bytecode debugger.
- */
-#define FT_DEBUG_HOOK_TRUETYPE 0
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Set_Debug_Hook
- *
- * @description:
- * Set a debug hook function for debugging the interpreter of a font
- * format.
- *
- * While this is a public API function, an application needs access to
- * FreeType's internal header files to do something useful.
- *
- * Have a look at the source code of the `ttdebug` FreeType demo program
- * for an example of its usage.
- *
- * @inout:
- * library ::
- * A handle to the library object.
- *
- * @input:
- * hook_index ::
- * The index of the debug hook. You should use defined enumeration
- * macros like @FT_DEBUG_HOOK_TRUETYPE.
- *
- * debug_hook ::
- * The function used to debug the interpreter.
- *
- * @note:
- * Currently, four debug hook slots are available, but only one (for the
- * TrueType interpreter) is defined.
- */
- FT_EXPORT( void )
- FT_Set_Debug_Hook( FT_Library library,
- FT_UInt hook_index,
- FT_DebugHook_Func debug_hook );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Add_Default_Modules
- *
- * @description:
- * Add the set of default drivers to a given library object. This is
- * only useful when you create a library object with @FT_New_Library
- * (usually to plug a custom memory manager).
- *
- * @inout:
- * library ::
- * A handle to a new library object.
- */
- FT_EXPORT( void )
- FT_Add_Default_Modules( FT_Library library );
-
-
-
- /**************************************************************************
- *
- * @section:
- * truetype_engine
- *
- * @title:
- * The TrueType Engine
- *
- * @abstract:
- * TrueType bytecode support.
- *
- * @description:
- * This section contains a function used to query the level of TrueType
- * bytecode support compiled in this version of the library.
- *
- */
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_TrueTypeEngineType
- *
- * @description:
- * A list of values describing which kind of TrueType bytecode engine is
- * implemented in a given FT_Library instance. It is used by the
- * @FT_Get_TrueType_Engine_Type function.
- *
- * @values:
- * FT_TRUETYPE_ENGINE_TYPE_NONE ::
- * The library doesn't implement any kind of bytecode interpreter.
- *
- * FT_TRUETYPE_ENGINE_TYPE_UNPATENTED ::
- * Deprecated and removed.
- *
- * FT_TRUETYPE_ENGINE_TYPE_PATENTED ::
- * The library implements a bytecode interpreter that covers the full
- * instruction set of the TrueType virtual machine (this was governed
- * by patents until May 2010, hence the name).
- *
- * @since:
- * 2.2
- *
- */
- typedef enum FT_TrueTypeEngineType_
- {
- FT_TRUETYPE_ENGINE_TYPE_NONE = 0,
- FT_TRUETYPE_ENGINE_TYPE_UNPATENTED,
- FT_TRUETYPE_ENGINE_TYPE_PATENTED
-
- } FT_TrueTypeEngineType;
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_TrueType_Engine_Type
- *
- * @description:
- * Return an @FT_TrueTypeEngineType value to indicate which level of the
- * TrueType virtual machine a given library instance supports.
- *
- * @input:
- * library ::
- * A library instance.
- *
- * @return:
- * A value indicating which level is supported.
- *
- * @since:
- * 2.2
- *
- */
- FT_EXPORT( FT_TrueTypeEngineType )
- FT_Get_TrueType_Engine_Type( FT_Library library );
-
- /* */
-
-
-FT_END_HEADER
-
-#endif /* FTMODAPI_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/ftmoderr.h b/contrib/libs/freetype/include/freetype/ftmoderr.h
deleted file mode 100644
index 6722fbf8b7..0000000000
--- a/contrib/libs/freetype/include/freetype/ftmoderr.h
+++ /dev/null
@@ -1,204 +0,0 @@
-/****************************************************************************
- *
- * ftmoderr.h
- *
- * FreeType module error offsets (specification).
- *
- * Copyright (C) 2001-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /**************************************************************************
- *
- * This file is used to define the FreeType module error codes.
- *
- * If the macro `FT_CONFIG_OPTION_USE_MODULE_ERRORS` in `ftoption.h` is
- * set, the lower byte of an error value identifies the error code as
- * usual. In addition, the higher byte identifies the module. For
- * example, the error `FT_Err_Invalid_File_Format` has value 0x0003, the
- * error `TT_Err_Invalid_File_Format` has value 0x1303, the error
- * `T1_Err_Invalid_File_Format` has value 0x1403, etc.
- *
- * Note that `FT_Err_Ok`, `TT_Err_Ok`, etc. are always equal to zero,
- * including the high byte.
- *
- * If `FT_CONFIG_OPTION_USE_MODULE_ERRORS` isn't set, the higher byte of an
- * error value is set to zero.
- *
- * To hide the various `XXX_Err_` prefixes in the source code, FreeType
- * provides some macros in `fttypes.h`.
- *
- * FT_ERR( err )
- *
- * Add current error module prefix (as defined with the `FT_ERR_PREFIX`
- * macro) to `err`. For example, in the BDF module the line
- *
- * ```
- * error = FT_ERR( Invalid_Outline );
- * ```
- *
- * expands to
- *
- * ```
- * error = BDF_Err_Invalid_Outline;
- * ```
- *
- * For simplicity, you can always use `FT_Err_Ok` directly instead of
- * `FT_ERR( Ok )`.
- *
- * FT_ERR_EQ( errcode, err )
- * FT_ERR_NEQ( errcode, err )
- *
- * Compare error code `errcode` with the error `err` for equality and
- * inequality, respectively. Example:
- *
- * ```
- * if ( FT_ERR_EQ( error, Invalid_Outline ) )
- * ...
- * ```
- *
- * Using this macro you don't have to think about error prefixes. Of
- * course, if module errors are not active, the above example is the
- * same as
- *
- * ```
- * if ( error == FT_Err_Invalid_Outline )
- * ...
- * ```
- *
- * FT_ERROR_BASE( errcode )
- * FT_ERROR_MODULE( errcode )
- *
- * Get base error and module error code, respectively.
- *
- * It can also be used to create a module error message table easily with
- * something like
- *
- * ```
- * #undef FTMODERR_H_
- * #define FT_MODERRDEF( e, v, s ) { FT_Mod_Err_ ## e, s },
- * #define FT_MODERR_START_LIST {
- * #define FT_MODERR_END_LIST { 0, 0 } };
- *
- * const struct
- * {
- * int mod_err_offset;
- * const char* mod_err_msg
- * } ft_mod_errors[] =
- *
- * #include <freetype/ftmoderr.h>
- * ```
- *
- */
-
-
-#ifndef FTMODERR_H_
-#define FTMODERR_H_
-
-
- /*******************************************************************/
- /*******************************************************************/
- /***** *****/
- /***** SETUP MACROS *****/
- /***** *****/
- /*******************************************************************/
- /*******************************************************************/
-
-
-#undef FT_NEED_EXTERN_C
-
-#ifndef FT_MODERRDEF
-
-#ifdef FT_CONFIG_OPTION_USE_MODULE_ERRORS
-#define FT_MODERRDEF( e, v, s ) FT_Mod_Err_ ## e = v,
-#else
-#define FT_MODERRDEF( e, v, s ) FT_Mod_Err_ ## e = 0,
-#endif
-
-#define FT_MODERR_START_LIST enum {
-#define FT_MODERR_END_LIST FT_Mod_Err_Max };
-
-#ifdef __cplusplus
-#define FT_NEED_EXTERN_C
- extern "C" {
-#endif
-
-#endif /* !FT_MODERRDEF */
-
-
- /*******************************************************************/
- /*******************************************************************/
- /***** *****/
- /***** LIST MODULE ERROR BASES *****/
- /***** *****/
- /*******************************************************************/
- /*******************************************************************/
-
-
-#ifdef FT_MODERR_START_LIST
- FT_MODERR_START_LIST
-#endif
-
-
- FT_MODERRDEF( Base, 0x000, "base module" )
- FT_MODERRDEF( Autofit, 0x100, "autofitter module" )
- FT_MODERRDEF( BDF, 0x200, "BDF module" )
- FT_MODERRDEF( Bzip2, 0x300, "Bzip2 module" )
- FT_MODERRDEF( Cache, 0x400, "cache module" )
- FT_MODERRDEF( CFF, 0x500, "CFF module" )
- FT_MODERRDEF( CID, 0x600, "CID module" )
- FT_MODERRDEF( Gzip, 0x700, "Gzip module" )
- FT_MODERRDEF( LZW, 0x800, "LZW module" )
- FT_MODERRDEF( OTvalid, 0x900, "OpenType validation module" )
- FT_MODERRDEF( PCF, 0xA00, "PCF module" )
- FT_MODERRDEF( PFR, 0xB00, "PFR module" )
- FT_MODERRDEF( PSaux, 0xC00, "PS auxiliary module" )
- FT_MODERRDEF( PShinter, 0xD00, "PS hinter module" )
- FT_MODERRDEF( PSnames, 0xE00, "PS names module" )
- FT_MODERRDEF( Raster, 0xF00, "raster module" )
- FT_MODERRDEF( SFNT, 0x1000, "SFNT module" )
- FT_MODERRDEF( Smooth, 0x1100, "smooth raster module" )
- FT_MODERRDEF( TrueType, 0x1200, "TrueType module" )
- FT_MODERRDEF( Type1, 0x1300, "Type 1 module" )
- FT_MODERRDEF( Type42, 0x1400, "Type 42 module" )
- FT_MODERRDEF( Winfonts, 0x1500, "Windows FON/FNT module" )
- FT_MODERRDEF( GXvalid, 0x1600, "GX validation module" )
- FT_MODERRDEF( Sdf, 0x1700, "Signed distance field raster module" )
-
-
-#ifdef FT_MODERR_END_LIST
- FT_MODERR_END_LIST
-#endif
-
-
- /*******************************************************************/
- /*******************************************************************/
- /***** *****/
- /***** CLEANUP *****/
- /***** *****/
- /*******************************************************************/
- /*******************************************************************/
-
-
-#ifdef FT_NEED_EXTERN_C
- }
-#endif
-
-#undef FT_MODERR_START_LIST
-#undef FT_MODERR_END_LIST
-#undef FT_MODERRDEF
-#undef FT_NEED_EXTERN_C
-
-
-#endif /* FTMODERR_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/ftotval.h b/contrib/libs/freetype/include/freetype/ftotval.h
deleted file mode 100644
index 810200b386..0000000000
--- a/contrib/libs/freetype/include/freetype/ftotval.h
+++ /dev/null
@@ -1,206 +0,0 @@
-/****************************************************************************
- *
- * ftotval.h
- *
- * FreeType API for validating OpenType tables (specification).
- *
- * Copyright (C) 2004-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-/****************************************************************************
- *
- *
- * Warning: This module might be moved to a different library in the
- * future to avoid a tight dependency between FreeType and the
- * OpenType specification.
- *
- *
- */
-
-
-#ifndef FTOTVAL_H_
-#define FTOTVAL_H_
-
-#include <freetype/freetype.h>
-
-#ifdef FREETYPE_H
-#error "freetype.h of FreeType 1 has been loaded!"
-#error "Please fix the directory search order for header files"
-#error "so that freetype.h of FreeType 2 is found first."
-#endif
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @section:
- * ot_validation
- *
- * @title:
- * OpenType Validation
- *
- * @abstract:
- * An API to validate OpenType tables.
- *
- * @description:
- * This section contains the declaration of functions to validate some
- * OpenType tables (BASE, GDEF, GPOS, GSUB, JSTF, MATH).
- *
- * @order:
- * FT_OpenType_Validate
- * FT_OpenType_Free
- *
- * FT_VALIDATE_OTXXX
- *
- */
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_VALIDATE_OTXXX
- *
- * @description:
- * A list of bit-field constants used with @FT_OpenType_Validate to
- * indicate which OpenType tables should be validated.
- *
- * @values:
- * FT_VALIDATE_BASE ::
- * Validate BASE table.
- *
- * FT_VALIDATE_GDEF ::
- * Validate GDEF table.
- *
- * FT_VALIDATE_GPOS ::
- * Validate GPOS table.
- *
- * FT_VALIDATE_GSUB ::
- * Validate GSUB table.
- *
- * FT_VALIDATE_JSTF ::
- * Validate JSTF table.
- *
- * FT_VALIDATE_MATH ::
- * Validate MATH table.
- *
- * FT_VALIDATE_OT ::
- * Validate all OpenType tables (BASE, GDEF, GPOS, GSUB, JSTF, MATH).
- *
- */
-#define FT_VALIDATE_BASE 0x0100
-#define FT_VALIDATE_GDEF 0x0200
-#define FT_VALIDATE_GPOS 0x0400
-#define FT_VALIDATE_GSUB 0x0800
-#define FT_VALIDATE_JSTF 0x1000
-#define FT_VALIDATE_MATH 0x2000
-
-#define FT_VALIDATE_OT ( FT_VALIDATE_BASE | \
- FT_VALIDATE_GDEF | \
- FT_VALIDATE_GPOS | \
- FT_VALIDATE_GSUB | \
- FT_VALIDATE_JSTF | \
- FT_VALIDATE_MATH )
-
-
- /**************************************************************************
- *
- * @function:
- * FT_OpenType_Validate
- *
- * @description:
- * Validate various OpenType tables to assure that all offsets and
- * indices are valid. The idea is that a higher-level library that
- * actually does the text layout can access those tables without error
- * checking (which can be quite time consuming).
- *
- * @input:
- * face ::
- * A handle to the input face.
- *
- * validation_flags ::
- * A bit field that specifies the tables to be validated. See
- * @FT_VALIDATE_OTXXX for possible values.
- *
- * @output:
- * BASE_table ::
- * A pointer to the BASE table.
- *
- * GDEF_table ::
- * A pointer to the GDEF table.
- *
- * GPOS_table ::
- * A pointer to the GPOS table.
- *
- * GSUB_table ::
- * A pointer to the GSUB table.
- *
- * JSTF_table ::
- * A pointer to the JSTF table.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * This function only works with OpenType fonts, returning an error
- * otherwise.
- *
- * After use, the application should deallocate the five tables with
- * @FT_OpenType_Free. A `NULL` value indicates that the table either
- * doesn't exist in the font, or the application hasn't asked for
- * validation.
- */
- FT_EXPORT( FT_Error )
- FT_OpenType_Validate( FT_Face face,
- FT_UInt validation_flags,
- FT_Bytes *BASE_table,
- FT_Bytes *GDEF_table,
- FT_Bytes *GPOS_table,
- FT_Bytes *GSUB_table,
- FT_Bytes *JSTF_table );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_OpenType_Free
- *
- * @description:
- * Free the buffer allocated by OpenType validator.
- *
- * @input:
- * face ::
- * A handle to the input face.
- *
- * table ::
- * The pointer to the buffer that is allocated by
- * @FT_OpenType_Validate.
- *
- * @note:
- * This function must be used to free the buffer allocated by
- * @FT_OpenType_Validate only.
- */
- FT_EXPORT( void )
- FT_OpenType_Free( FT_Face face,
- FT_Bytes table );
-
-
- /* */
-
-
-FT_END_HEADER
-
-#endif /* FTOTVAL_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/ftoutln.h b/contrib/libs/freetype/include/freetype/ftoutln.h
deleted file mode 100644
index 44e94b4f5b..0000000000
--- a/contrib/libs/freetype/include/freetype/ftoutln.h
+++ /dev/null
@@ -1,588 +0,0 @@
-/****************************************************************************
- *
- * ftoutln.h
- *
- * Support for the FT_Outline type used to store glyph shapes of
- * most scalable font formats (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTOUTLN_H_
-#define FTOUTLN_H_
-
-
-#include <freetype/freetype.h>
-
-#ifdef FREETYPE_H
-#error "freetype.h of FreeType 1 has been loaded!"
-#error "Please fix the directory search order for header files"
-#error "so that freetype.h of FreeType 2 is found first."
-#endif
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @section:
- * outline_processing
- *
- * @title:
- * Outline Processing
- *
- * @abstract:
- * Functions to create, transform, and render vectorial glyph images.
- *
- * @description:
- * This section contains routines used to create and destroy scalable
- * glyph images known as 'outlines'. These can also be measured,
- * transformed, and converted into bitmaps and pixmaps.
- *
- * @order:
- * FT_Outline
- * FT_Outline_New
- * FT_Outline_Done
- * FT_Outline_Copy
- * FT_Outline_Translate
- * FT_Outline_Transform
- * FT_Outline_Embolden
- * FT_Outline_EmboldenXY
- * FT_Outline_Reverse
- * FT_Outline_Check
- *
- * FT_Outline_Get_CBox
- * FT_Outline_Get_BBox
- *
- * FT_Outline_Get_Bitmap
- * FT_Outline_Render
- * FT_Outline_Decompose
- * FT_Outline_Funcs
- * FT_Outline_MoveToFunc
- * FT_Outline_LineToFunc
- * FT_Outline_ConicToFunc
- * FT_Outline_CubicToFunc
- *
- * FT_Orientation
- * FT_Outline_Get_Orientation
- *
- * FT_OUTLINE_XXX
- *
- */
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Outline_Decompose
- *
- * @description:
- * Walk over an outline's structure to decompose it into individual
- * segments and Bezier arcs. This function also emits 'move to'
- * operations to indicate the start of new contours in the outline.
- *
- * @input:
- * outline ::
- * A pointer to the source target.
- *
- * func_interface ::
- * A table of 'emitters', i.e., function pointers called during
- * decomposition to indicate path operations.
- *
- * @inout:
- * user ::
- * A typeless pointer that is passed to each emitter during the
- * decomposition. It can be used to store the state during the
- * decomposition.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * Degenerate contours, segments, and Bezier arcs may be reported. In
- * most cases, it is best to filter these out before using the outline
- * for stroking or other path modification purposes (which may cause
- * degenerate segments to become non-degenerate and visible, like when
- * stroke caps are used or the path is otherwise outset). Some glyph
- * outlines may contain deliberate degenerate single points for mark
- * attachement.
- *
- * Similarly, the function returns success for an empty outline also
- * (doing nothing, that is, not calling any emitter); if necessary, you
- * should filter this out, too.
- */
- FT_EXPORT( FT_Error )
- FT_Outline_Decompose( FT_Outline* outline,
- const FT_Outline_Funcs* func_interface,
- void* user );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Outline_New
- *
- * @description:
- * Create a new outline of a given size.
- *
- * @input:
- * library ::
- * A handle to the library object from where the outline is allocated.
- * Note however that the new outline will **not** necessarily be
- * **freed**, when destroying the library, by @FT_Done_FreeType.
- *
- * numPoints ::
- * The maximum number of points within the outline. Must be smaller
- * than or equal to 0xFFFF (65535).
- *
- * numContours ::
- * The maximum number of contours within the outline. This value must
- * be in the range 0 to `numPoints`.
- *
- * @output:
- * anoutline ::
- * A handle to the new outline.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * The reason why this function takes a `library` parameter is simply to
- * use the library's memory allocator.
- */
- FT_EXPORT( FT_Error )
- FT_Outline_New( FT_Library library,
- FT_UInt numPoints,
- FT_Int numContours,
- FT_Outline *anoutline );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Outline_Done
- *
- * @description:
- * Destroy an outline created with @FT_Outline_New.
- *
- * @input:
- * library ::
- * A handle of the library object used to allocate the outline.
- *
- * outline ::
- * A pointer to the outline object to be discarded.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * If the outline's 'owner' field is not set, only the outline descriptor
- * will be released.
- */
- FT_EXPORT( FT_Error )
- FT_Outline_Done( FT_Library library,
- FT_Outline* outline );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Outline_Check
- *
- * @description:
- * Check the contents of an outline descriptor.
- *
- * @input:
- * outline ::
- * A handle to a source outline.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * An empty outline, or an outline with a single point only is also
- * valid.
- */
- FT_EXPORT( FT_Error )
- FT_Outline_Check( FT_Outline* outline );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Outline_Get_CBox
- *
- * @description:
- * Return an outline's 'control box'. The control box encloses all the
- * outline's points, including Bezier control points. Though it
- * coincides with the exact bounding box for most glyphs, it can be
- * slightly larger in some situations (like when rotating an outline that
- * contains Bezier outside arcs).
- *
- * Computing the control box is very fast, while getting the bounding box
- * can take much more time as it needs to walk over all segments and arcs
- * in the outline. To get the latter, you can use the 'ftbbox'
- * component, which is dedicated to this single task.
- *
- * @input:
- * outline ::
- * A pointer to the source outline descriptor.
- *
- * @output:
- * acbox ::
- * The outline's control box.
- *
- * @note:
- * See @FT_Glyph_Get_CBox for a discussion of tricky fonts.
- */
- FT_EXPORT( void )
- FT_Outline_Get_CBox( const FT_Outline* outline,
- FT_BBox *acbox );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Outline_Translate
- *
- * @description:
- * Apply a simple translation to the points of an outline.
- *
- * @inout:
- * outline ::
- * A pointer to the target outline descriptor.
- *
- * @input:
- * xOffset ::
- * The horizontal offset.
- *
- * yOffset ::
- * The vertical offset.
- */
- FT_EXPORT( void )
- FT_Outline_Translate( const FT_Outline* outline,
- FT_Pos xOffset,
- FT_Pos yOffset );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Outline_Copy
- *
- * @description:
- * Copy an outline into another one. Both objects must have the same
- * sizes (number of points & number of contours) when this function is
- * called.
- *
- * @input:
- * source ::
- * A handle to the source outline.
- *
- * @output:
- * target ::
- * A handle to the target outline.
- *
- * @return:
- * FreeType error code. 0~means success.
- */
- FT_EXPORT( FT_Error )
- FT_Outline_Copy( const FT_Outline* source,
- FT_Outline *target );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Outline_Transform
- *
- * @description:
- * Apply a simple 2x2 matrix to all of an outline's points. Useful for
- * applying rotations, slanting, flipping, etc.
- *
- * @inout:
- * outline ::
- * A pointer to the target outline descriptor.
- *
- * @input:
- * matrix ::
- * A pointer to the transformation matrix.
- *
- * @note:
- * You can use @FT_Outline_Translate if you need to translate the
- * outline's points.
- */
- FT_EXPORT( void )
- FT_Outline_Transform( const FT_Outline* outline,
- const FT_Matrix* matrix );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Outline_Embolden
- *
- * @description:
- * Embolden an outline. The new outline will be at most 4~times
- * `strength` pixels wider and higher. You may think of the left and
- * bottom borders as unchanged.
- *
- * Negative `strength` values to reduce the outline thickness are
- * possible also.
- *
- * @inout:
- * outline ::
- * A handle to the target outline.
- *
- * @input:
- * strength ::
- * How strong the glyph is emboldened. Expressed in 26.6 pixel format.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * The used algorithm to increase or decrease the thickness of the glyph
- * doesn't change the number of points; this means that certain
- * situations like acute angles or intersections are sometimes handled
- * incorrectly.
- *
- * If you need 'better' metrics values you should call
- * @FT_Outline_Get_CBox or @FT_Outline_Get_BBox.
- *
- * To get meaningful results, font scaling values must be set with
- * functions like @FT_Set_Char_Size before calling FT_Render_Glyph.
- *
- * @example:
- * ```
- * FT_Load_Glyph( face, index, FT_LOAD_DEFAULT );
- *
- * if ( face->glyph->format == FT_GLYPH_FORMAT_OUTLINE )
- * FT_Outline_Embolden( &face->glyph->outline, strength );
- * ```
- *
- */
- FT_EXPORT( FT_Error )
- FT_Outline_Embolden( FT_Outline* outline,
- FT_Pos strength );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Outline_EmboldenXY
- *
- * @description:
- * Embolden an outline. The new outline will be `xstrength` pixels wider
- * and `ystrength` pixels higher. Otherwise, it is similar to
- * @FT_Outline_Embolden, which uses the same strength in both directions.
- *
- * @since:
- * 2.4.10
- */
- FT_EXPORT( FT_Error )
- FT_Outline_EmboldenXY( FT_Outline* outline,
- FT_Pos xstrength,
- FT_Pos ystrength );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Outline_Reverse
- *
- * @description:
- * Reverse the drawing direction of an outline. This is used to ensure
- * consistent fill conventions for mirrored glyphs.
- *
- * @inout:
- * outline ::
- * A pointer to the target outline descriptor.
- *
- * @note:
- * This function toggles the bit flag @FT_OUTLINE_REVERSE_FILL in the
- * outline's `flags` field.
- *
- * It shouldn't be used by a normal client application, unless it knows
- * what it is doing.
- */
- FT_EXPORT( void )
- FT_Outline_Reverse( FT_Outline* outline );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Outline_Get_Bitmap
- *
- * @description:
- * Render an outline within a bitmap. The outline's image is simply
- * OR-ed to the target bitmap.
- *
- * @input:
- * library ::
- * A handle to a FreeType library object.
- *
- * outline ::
- * A pointer to the source outline descriptor.
- *
- * @inout:
- * abitmap ::
- * A pointer to the target bitmap descriptor.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * This function does **not create** the bitmap, it only renders an
- * outline image within the one you pass to it! Consequently, the
- * various fields in `abitmap` should be set accordingly.
- *
- * It will use the raster corresponding to the default glyph format.
- *
- * The value of the `num_grays` field in `abitmap` is ignored. If you
- * select the gray-level rasterizer, and you want less than 256 gray
- * levels, you have to use @FT_Outline_Render directly.
- */
- FT_EXPORT( FT_Error )
- FT_Outline_Get_Bitmap( FT_Library library,
- FT_Outline* outline,
- const FT_Bitmap *abitmap );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Outline_Render
- *
- * @description:
- * Render an outline within a bitmap using the current scan-convert.
- *
- * @input:
- * library ::
- * A handle to a FreeType library object.
- *
- * outline ::
- * A pointer to the source outline descriptor.
- *
- * @inout:
- * params ::
- * A pointer to an @FT_Raster_Params structure used to describe the
- * rendering operation.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * This advanced function uses @FT_Raster_Params as an argument.
- * The field `params.source` will be set to `outline` before the scan
- * converter is called, which means that the value you give to it is
- * actually ignored. Either `params.target` must point to preallocated
- * bitmap, or @FT_RASTER_FLAG_DIRECT must be set in `params.flags`
- * allowing FreeType rasterizer to be used for direct composition,
- * translucency, etc. See @FT_Raster_Params for more details.
- */
- FT_EXPORT( FT_Error )
- FT_Outline_Render( FT_Library library,
- FT_Outline* outline,
- FT_Raster_Params* params );
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_Orientation
- *
- * @description:
- * A list of values used to describe an outline's contour orientation.
- *
- * The TrueType and PostScript specifications use different conventions
- * to determine whether outline contours should be filled or unfilled.
- *
- * @values:
- * FT_ORIENTATION_TRUETYPE ::
- * According to the TrueType specification, clockwise contours must be
- * filled, and counter-clockwise ones must be unfilled.
- *
- * FT_ORIENTATION_POSTSCRIPT ::
- * According to the PostScript specification, counter-clockwise
- * contours must be filled, and clockwise ones must be unfilled.
- *
- * FT_ORIENTATION_FILL_RIGHT ::
- * This is identical to @FT_ORIENTATION_TRUETYPE, but is used to
- * remember that in TrueType, everything that is to the right of the
- * drawing direction of a contour must be filled.
- *
- * FT_ORIENTATION_FILL_LEFT ::
- * This is identical to @FT_ORIENTATION_POSTSCRIPT, but is used to
- * remember that in PostScript, everything that is to the left of the
- * drawing direction of a contour must be filled.
- *
- * FT_ORIENTATION_NONE ::
- * The orientation cannot be determined. That is, different parts of
- * the glyph have different orientation.
- *
- */
- typedef enum FT_Orientation_
- {
- FT_ORIENTATION_TRUETYPE = 0,
- FT_ORIENTATION_POSTSCRIPT = 1,
- FT_ORIENTATION_FILL_RIGHT = FT_ORIENTATION_TRUETYPE,
- FT_ORIENTATION_FILL_LEFT = FT_ORIENTATION_POSTSCRIPT,
- FT_ORIENTATION_NONE
-
- } FT_Orientation;
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Outline_Get_Orientation
- *
- * @description:
- * This function analyzes a glyph outline and tries to compute its fill
- * orientation (see @FT_Orientation). This is done by integrating the
- * total area covered by the outline. The positive integral corresponds
- * to the clockwise orientation and @FT_ORIENTATION_POSTSCRIPT is
- * returned. The negative integral corresponds to the counter-clockwise
- * orientation and @FT_ORIENTATION_TRUETYPE is returned.
- *
- * Note that this will return @FT_ORIENTATION_TRUETYPE for empty
- * outlines.
- *
- * @input:
- * outline ::
- * A handle to the source outline.
- *
- * @return:
- * The orientation.
- *
- */
- FT_EXPORT( FT_Orientation )
- FT_Outline_Get_Orientation( FT_Outline* outline );
-
-
- /* */
-
-
-FT_END_HEADER
-
-#endif /* FTOUTLN_H_ */
-
-
-/* END */
-
-
-/* Local Variables: */
-/* coding: utf-8 */
-/* End: */
diff --git a/contrib/libs/freetype/include/freetype/ftparams.h b/contrib/libs/freetype/include/freetype/ftparams.h
deleted file mode 100644
index 43bf69c202..0000000000
--- a/contrib/libs/freetype/include/freetype/ftparams.h
+++ /dev/null
@@ -1,218 +0,0 @@
-/****************************************************************************
- *
- * ftparams.h
- *
- * FreeType API for possible FT_Parameter tags (specification only).
- *
- * Copyright (C) 2017-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTPARAMS_H_
-#define FTPARAMS_H_
-
-#include <freetype/freetype.h>
-
-#ifdef FREETYPE_H
-#error "freetype.h of FreeType 1 has been loaded!"
-#error "Please fix the directory search order for header files"
-#error "so that freetype.h of FreeType 2 is found first."
-#endif
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @section:
- * parameter_tags
- *
- * @title:
- * Parameter Tags
- *
- * @abstract:
- * Macros for driver property and font loading parameter tags.
- *
- * @description:
- * This section contains macros for the @FT_Parameter structure that are
- * used with various functions to activate some special functionality or
- * different behaviour of various components of FreeType.
- *
- */
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_FAMILY
- *
- * @description:
- * A tag for @FT_Parameter to make @FT_Open_Face ignore typographic
- * family names in the 'name' table (introduced in OpenType version 1.4).
- * Use this for backward compatibility with legacy systems that have a
- * four-faces-per-family restriction.
- *
- * @since:
- * 2.8
- *
- */
-#define FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_FAMILY \
- FT_MAKE_TAG( 'i', 'g', 'p', 'f' )
-
-
- /* this constant is deprecated */
-#define FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY \
- FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_FAMILY
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_SUBFAMILY
- *
- * @description:
- * A tag for @FT_Parameter to make @FT_Open_Face ignore typographic
- * subfamily names in the 'name' table (introduced in OpenType version
- * 1.4). Use this for backward compatibility with legacy systems that
- * have a four-faces-per-family restriction.
- *
- * @since:
- * 2.8
- *
- */
-#define FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_SUBFAMILY \
- FT_MAKE_TAG( 'i', 'g', 'p', 's' )
-
-
- /* this constant is deprecated */
-#define FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY \
- FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_SUBFAMILY
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_PARAM_TAG_INCREMENTAL
- *
- * @description:
- * An @FT_Parameter tag to be used with @FT_Open_Face to indicate
- * incremental glyph loading.
- *
- */
-#define FT_PARAM_TAG_INCREMENTAL \
- FT_MAKE_TAG( 'i', 'n', 'c', 'r' )
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_PARAM_TAG_IGNORE_SBIX
- *
- * @description:
- * A tag for @FT_Parameter to make @FT_Open_Face ignore an 'sbix' table
- * while loading a font. Use this if @FT_FACE_FLAG_SBIX is set and you
- * want to access the outline glyphs in the font.
- *
- */
-#define FT_PARAM_TAG_IGNORE_SBIX \
- FT_MAKE_TAG( 'i', 's', 'b', 'x' )
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_PARAM_TAG_LCD_FILTER_WEIGHTS
- *
- * @description:
- * An @FT_Parameter tag to be used with @FT_Face_Properties. The
- * corresponding argument specifies the five LCD filter weights for a
- * given face (if using @FT_LOAD_TARGET_LCD, for example), overriding the
- * global default values or the values set up with
- * @FT_Library_SetLcdFilterWeights.
- *
- * @since:
- * 2.8
- *
- */
-#define FT_PARAM_TAG_LCD_FILTER_WEIGHTS \
- FT_MAKE_TAG( 'l', 'c', 'd', 'f' )
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_PARAM_TAG_RANDOM_SEED
- *
- * @description:
- * An @FT_Parameter tag to be used with @FT_Face_Properties. The
- * corresponding 32bit signed integer argument overrides the font
- * driver's random seed value with a face-specific one; see @random-seed.
- *
- * @since:
- * 2.8
- *
- */
-#define FT_PARAM_TAG_RANDOM_SEED \
- FT_MAKE_TAG( 's', 'e', 'e', 'd' )
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_PARAM_TAG_STEM_DARKENING
- *
- * @description:
- * An @FT_Parameter tag to be used with @FT_Face_Properties. The
- * corresponding Boolean argument specifies whether to apply stem
- * darkening, overriding the global default values or the values set up
- * with @FT_Property_Set (see @no-stem-darkening).
- *
- * This is a passive setting that only takes effect if the font driver or
- * autohinter honors it, which the CFF, Type~1, and CID drivers always
- * do, but the autohinter only in 'light' hinting mode (as of version
- * 2.9).
- *
- * @since:
- * 2.8
- *
- */
-#define FT_PARAM_TAG_STEM_DARKENING \
- FT_MAKE_TAG( 'd', 'a', 'r', 'k' )
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_PARAM_TAG_UNPATENTED_HINTING
- *
- * @description:
- * Deprecated, no effect.
- *
- * Previously: A constant used as the tag of an @FT_Parameter structure
- * to indicate that unpatented methods only should be used by the
- * TrueType bytecode interpreter for a typeface opened by @FT_Open_Face.
- *
- */
-#define FT_PARAM_TAG_UNPATENTED_HINTING \
- FT_MAKE_TAG( 'u', 'n', 'p', 'a' )
-
-
- /* */
-
-
-FT_END_HEADER
-
-
-#endif /* FTPARAMS_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/ftpfr.h b/contrib/libs/freetype/include/freetype/ftpfr.h
deleted file mode 100644
index 1a712b9552..0000000000
--- a/contrib/libs/freetype/include/freetype/ftpfr.h
+++ /dev/null
@@ -1,179 +0,0 @@
-/****************************************************************************
- *
- * ftpfr.h
- *
- * FreeType API for accessing PFR-specific data (specification only).
- *
- * Copyright (C) 2002-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTPFR_H_
-#define FTPFR_H_
-
-#include <freetype/freetype.h>
-
-#ifdef FREETYPE_H
-#error "freetype.h of FreeType 1 has been loaded!"
-#error "Please fix the directory search order for header files"
-#error "so that freetype.h of FreeType 2 is found first."
-#endif
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @section:
- * pfr_fonts
- *
- * @title:
- * PFR Fonts
- *
- * @abstract:
- * PFR/TrueDoc-specific API.
- *
- * @description:
- * This section contains the declaration of PFR-specific functions.
- *
- */
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_PFR_Metrics
- *
- * @description:
- * Return the outline and metrics resolutions of a given PFR face.
- *
- * @input:
- * face ::
- * Handle to the input face. It can be a non-PFR face.
- *
- * @output:
- * aoutline_resolution ::
- * Outline resolution. This is equivalent to `face->units_per_EM` for
- * non-PFR fonts. Optional (parameter can be `NULL`).
- *
- * ametrics_resolution ::
- * Metrics resolution. This is equivalent to `outline_resolution` for
- * non-PFR fonts. Optional (parameter can be `NULL`).
- *
- * ametrics_x_scale ::
- * A 16.16 fixed-point number used to scale distance expressed in
- * metrics units to device subpixels. This is equivalent to
- * `face->size->x_scale`, but for metrics only. Optional (parameter
- * can be `NULL`).
- *
- * ametrics_y_scale ::
- * Same as `ametrics_x_scale` but for the vertical direction.
- * optional (parameter can be `NULL`).
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * If the input face is not a PFR, this function will return an error.
- * However, in all cases, it will return valid values.
- */
- FT_EXPORT( FT_Error )
- FT_Get_PFR_Metrics( FT_Face face,
- FT_UInt *aoutline_resolution,
- FT_UInt *ametrics_resolution,
- FT_Fixed *ametrics_x_scale,
- FT_Fixed *ametrics_y_scale );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_PFR_Kerning
- *
- * @description:
- * Return the kerning pair corresponding to two glyphs in a PFR face.
- * The distance is expressed in metrics units, unlike the result of
- * @FT_Get_Kerning.
- *
- * @input:
- * face ::
- * A handle to the input face.
- *
- * left ::
- * Index of the left glyph.
- *
- * right ::
- * Index of the right glyph.
- *
- * @output:
- * avector ::
- * A kerning vector.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * This function always return distances in original PFR metrics units.
- * This is unlike @FT_Get_Kerning with the @FT_KERNING_UNSCALED mode,
- * which always returns distances converted to outline units.
- *
- * You can use the value of the `x_scale` and `y_scale` parameters
- * returned by @FT_Get_PFR_Metrics to scale these to device subpixels.
- */
- FT_EXPORT( FT_Error )
- FT_Get_PFR_Kerning( FT_Face face,
- FT_UInt left,
- FT_UInt right,
- FT_Vector *avector );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_PFR_Advance
- *
- * @description:
- * Return a given glyph advance, expressed in original metrics units,
- * from a PFR font.
- *
- * @input:
- * face ::
- * A handle to the input face.
- *
- * gindex ::
- * The glyph index.
- *
- * @output:
- * aadvance ::
- * The glyph advance in metrics units.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * You can use the `x_scale` or `y_scale` results of @FT_Get_PFR_Metrics
- * to convert the advance to device subpixels (i.e., 1/64 of pixels).
- */
- FT_EXPORT( FT_Error )
- FT_Get_PFR_Advance( FT_Face face,
- FT_UInt gindex,
- FT_Pos *aadvance );
-
- /* */
-
-
-FT_END_HEADER
-
-#endif /* FTPFR_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/ftrender.h b/contrib/libs/freetype/include/freetype/ftrender.h
deleted file mode 100644
index dc5018a1b5..0000000000
--- a/contrib/libs/freetype/include/freetype/ftrender.h
+++ /dev/null
@@ -1,244 +0,0 @@
-/****************************************************************************
- *
- * ftrender.h
- *
- * FreeType renderer modules public interface (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTRENDER_H_
-#define FTRENDER_H_
-
-
-#include <freetype/ftmodapi.h>
-#include <freetype/ftglyph.h>
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @section:
- * module_management
- *
- */
-
-
- /* create a new glyph object */
- typedef FT_Error
- (*FT_Glyph_InitFunc)( FT_Glyph glyph,
- FT_GlyphSlot slot );
-
- /* destroys a given glyph object */
- typedef void
- (*FT_Glyph_DoneFunc)( FT_Glyph glyph );
-
- typedef void
- (*FT_Glyph_TransformFunc)( FT_Glyph glyph,
- const FT_Matrix* matrix,
- const FT_Vector* delta );
-
- typedef void
- (*FT_Glyph_GetBBoxFunc)( FT_Glyph glyph,
- FT_BBox* abbox );
-
- typedef FT_Error
- (*FT_Glyph_CopyFunc)( FT_Glyph source,
- FT_Glyph target );
-
- typedef FT_Error
- (*FT_Glyph_PrepareFunc)( FT_Glyph glyph,
- FT_GlyphSlot slot );
-
-/* deprecated */
-#define FT_Glyph_Init_Func FT_Glyph_InitFunc
-#define FT_Glyph_Done_Func FT_Glyph_DoneFunc
-#define FT_Glyph_Transform_Func FT_Glyph_TransformFunc
-#define FT_Glyph_BBox_Func FT_Glyph_GetBBoxFunc
-#define FT_Glyph_Copy_Func FT_Glyph_CopyFunc
-#define FT_Glyph_Prepare_Func FT_Glyph_PrepareFunc
-
-
- struct FT_Glyph_Class_
- {
- FT_Long glyph_size;
- FT_Glyph_Format glyph_format;
-
- FT_Glyph_InitFunc glyph_init;
- FT_Glyph_DoneFunc glyph_done;
- FT_Glyph_CopyFunc glyph_copy;
- FT_Glyph_TransformFunc glyph_transform;
- FT_Glyph_GetBBoxFunc glyph_bbox;
- FT_Glyph_PrepareFunc glyph_prepare;
- };
-
-
- typedef FT_Error
- (*FT_Renderer_RenderFunc)( FT_Renderer renderer,
- FT_GlyphSlot slot,
- FT_Render_Mode mode,
- const FT_Vector* origin );
-
- typedef FT_Error
- (*FT_Renderer_TransformFunc)( FT_Renderer renderer,
- FT_GlyphSlot slot,
- const FT_Matrix* matrix,
- const FT_Vector* delta );
-
-
- typedef void
- (*FT_Renderer_GetCBoxFunc)( FT_Renderer renderer,
- FT_GlyphSlot slot,
- FT_BBox* cbox );
-
-
- typedef FT_Error
- (*FT_Renderer_SetModeFunc)( FT_Renderer renderer,
- FT_ULong mode_tag,
- FT_Pointer mode_ptr );
-
-/* deprecated identifiers */
-#define FTRenderer_render FT_Renderer_RenderFunc
-#define FTRenderer_transform FT_Renderer_TransformFunc
-#define FTRenderer_getCBox FT_Renderer_GetCBoxFunc
-#define FTRenderer_setMode FT_Renderer_SetModeFunc
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_Renderer_Class
- *
- * @description:
- * The renderer module class descriptor.
- *
- * @fields:
- * root ::
- * The root @FT_Module_Class fields.
- *
- * glyph_format ::
- * The glyph image format this renderer handles.
- *
- * render_glyph ::
- * A method used to render the image that is in a given glyph slot into
- * a bitmap.
- *
- * transform_glyph ::
- * A method used to transform the image that is in a given glyph slot.
- *
- * get_glyph_cbox ::
- * A method used to access the glyph's cbox.
- *
- * set_mode ::
- * A method used to pass additional parameters.
- *
- * raster_class ::
- * For @FT_GLYPH_FORMAT_OUTLINE renderers only. This is a pointer to
- * its raster's class.
- */
- typedef struct FT_Renderer_Class_
- {
- FT_Module_Class root;
-
- FT_Glyph_Format glyph_format;
-
- FT_Renderer_RenderFunc render_glyph;
- FT_Renderer_TransformFunc transform_glyph;
- FT_Renderer_GetCBoxFunc get_glyph_cbox;
- FT_Renderer_SetModeFunc set_mode;
-
- const FT_Raster_Funcs* raster_class;
-
- } FT_Renderer_Class;
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_Renderer
- *
- * @description:
- * Retrieve the current renderer for a given glyph format.
- *
- * @input:
- * library ::
- * A handle to the library object.
- *
- * format ::
- * The glyph format.
- *
- * @return:
- * A renderer handle. 0~if none found.
- *
- * @note:
- * An error will be returned if a module already exists by that name, or
- * if the module requires a version of FreeType that is too great.
- *
- * To add a new renderer, simply use @FT_Add_Module. To retrieve a
- * renderer by its name, use @FT_Get_Module.
- */
- FT_EXPORT( FT_Renderer )
- FT_Get_Renderer( FT_Library library,
- FT_Glyph_Format format );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Set_Renderer
- *
- * @description:
- * Set the current renderer to use, and set additional mode.
- *
- * @inout:
- * library ::
- * A handle to the library object.
- *
- * @input:
- * renderer ::
- * A handle to the renderer object.
- *
- * num_params ::
- * The number of additional parameters.
- *
- * parameters ::
- * Additional parameters.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * In case of success, the renderer will be used to convert glyph images
- * in the renderer's known format into bitmaps.
- *
- * This doesn't change the current renderer for other formats.
- *
- * Currently, no FreeType renderer module uses `parameters`; you should
- * thus always pass `NULL` as the value.
- */
- FT_EXPORT( FT_Error )
- FT_Set_Renderer( FT_Library library,
- FT_Renderer renderer,
- FT_UInt num_params,
- FT_Parameter* parameters );
-
- /* */
-
-
-FT_END_HEADER
-
-#endif /* FTRENDER_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/ftsizes.h b/contrib/libs/freetype/include/freetype/ftsizes.h
deleted file mode 100644
index 4ef5c7955d..0000000000
--- a/contrib/libs/freetype/include/freetype/ftsizes.h
+++ /dev/null
@@ -1,159 +0,0 @@
-/****************************************************************************
- *
- * ftsizes.h
- *
- * FreeType size objects management (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /**************************************************************************
- *
- * Typical application would normally not need to use these functions.
- * However, they have been placed in a public API for the rare cases where
- * they are needed.
- *
- */
-
-
-#ifndef FTSIZES_H_
-#define FTSIZES_H_
-
-
-#include <freetype/freetype.h>
-
-#ifdef FREETYPE_H
-#error "freetype.h of FreeType 1 has been loaded!"
-#error "Please fix the directory search order for header files"
-#error "so that freetype.h of FreeType 2 is found first."
-#endif
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @section:
- * sizes_management
- *
- * @title:
- * Size Management
- *
- * @abstract:
- * Managing multiple sizes per face.
- *
- * @description:
- * When creating a new face object (e.g., with @FT_New_Face), an @FT_Size
- * object is automatically created and used to store all pixel-size
- * dependent information, available in the `face->size` field.
- *
- * It is however possible to create more sizes for a given face, mostly
- * in order to manage several character pixel sizes of the same font
- * family and style. See @FT_New_Size and @FT_Done_Size.
- *
- * Note that @FT_Set_Pixel_Sizes and @FT_Set_Char_Size only modify the
- * contents of the current 'active' size; you thus need to use
- * @FT_Activate_Size to change it.
- *
- * 99% of applications won't need the functions provided here, especially
- * if they use the caching sub-system, so be cautious when using these.
- *
- */
-
-
- /**************************************************************************
- *
- * @function:
- * FT_New_Size
- *
- * @description:
- * Create a new size object from a given face object.
- *
- * @input:
- * face ::
- * A handle to a parent face object.
- *
- * @output:
- * asize ::
- * A handle to a new size object.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * You need to call @FT_Activate_Size in order to select the new size for
- * upcoming calls to @FT_Set_Pixel_Sizes, @FT_Set_Char_Size,
- * @FT_Load_Glyph, @FT_Load_Char, etc.
- */
- FT_EXPORT( FT_Error )
- FT_New_Size( FT_Face face,
- FT_Size* size );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Done_Size
- *
- * @description:
- * Discard a given size object. Note that @FT_Done_Face automatically
- * discards all size objects allocated with @FT_New_Size.
- *
- * @input:
- * size ::
- * A handle to a target size object.
- *
- * @return:
- * FreeType error code. 0~means success.
- */
- FT_EXPORT( FT_Error )
- FT_Done_Size( FT_Size size );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Activate_Size
- *
- * @description:
- * Even though it is possible to create several size objects for a given
- * face (see @FT_New_Size for details), functions like @FT_Load_Glyph or
- * @FT_Load_Char only use the one that has been activated last to
- * determine the 'current character pixel size'.
- *
- * This function can be used to 'activate' a previously created size
- * object.
- *
- * @input:
- * size ::
- * A handle to a target size object.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * If `face` is the size's parent face object, this function changes the
- * value of `face->size` to the input size handle.
- */
- FT_EXPORT( FT_Error )
- FT_Activate_Size( FT_Size size );
-
- /* */
-
-
-FT_END_HEADER
-
-#endif /* FTSIZES_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/ftsnames.h b/contrib/libs/freetype/include/freetype/ftsnames.h
deleted file mode 100644
index d5d5cd9310..0000000000
--- a/contrib/libs/freetype/include/freetype/ftsnames.h
+++ /dev/null
@@ -1,272 +0,0 @@
-/****************************************************************************
- *
- * ftsnames.h
- *
- * Simple interface to access SFNT 'name' tables (which are used
- * to hold font names, copyright info, notices, etc.) (specification).
- *
- * This is _not_ used to retrieve glyph names!
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTSNAMES_H_
-#define FTSNAMES_H_
-
-
-#include <freetype/freetype.h>
-#include <freetype/ftparams.h>
-
-#ifdef FREETYPE_H
-#error "freetype.h of FreeType 1 has been loaded!"
-#error "Please fix the directory search order for header files"
-#error "so that freetype.h of FreeType 2 is found first."
-#endif
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @section:
- * sfnt_names
- *
- * @title:
- * SFNT Names
- *
- * @abstract:
- * Access the names embedded in TrueType and OpenType files.
- *
- * @description:
- * The TrueType and OpenType specifications allow the inclusion of a
- * special names table ('name') in font files. This table contains
- * textual (and internationalized) information regarding the font, like
- * family name, copyright, version, etc.
- *
- * The definitions below are used to access them if available.
- *
- * Note that this has nothing to do with glyph names!
- *
- */
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_SfntName
- *
- * @description:
- * A structure used to model an SFNT 'name' table entry.
- *
- * @fields:
- * platform_id ::
- * The platform ID for `string`. See @TT_PLATFORM_XXX for possible
- * values.
- *
- * encoding_id ::
- * The encoding ID for `string`. See @TT_APPLE_ID_XXX, @TT_MAC_ID_XXX,
- * @TT_ISO_ID_XXX, @TT_MS_ID_XXX, and @TT_ADOBE_ID_XXX for possible
- * values.
- *
- * language_id ::
- * The language ID for `string`. See @TT_MAC_LANGID_XXX and
- * @TT_MS_LANGID_XXX for possible values.
- *
- * Registered OpenType values for `language_id` are always smaller than
- * 0x8000; values equal or larger than 0x8000 usually indicate a
- * language tag string (introduced in OpenType version 1.6). Use
- * function @FT_Get_Sfnt_LangTag with `language_id` as its argument to
- * retrieve the associated language tag.
- *
- * name_id ::
- * An identifier for `string`. See @TT_NAME_ID_XXX for possible
- * values.
- *
- * string ::
- * The 'name' string. Note that its format differs depending on the
- * (platform,encoding) pair, being either a string of bytes (without a
- * terminating `NULL` byte) or containing UTF-16BE entities.
- *
- * string_len ::
- * The length of `string` in bytes.
- *
- * @note:
- * Please refer to the TrueType or OpenType specification for more
- * details.
- */
- typedef struct FT_SfntName_
- {
- FT_UShort platform_id;
- FT_UShort encoding_id;
- FT_UShort language_id;
- FT_UShort name_id;
-
- FT_Byte* string; /* this string is *not* null-terminated! */
- FT_UInt string_len; /* in bytes */
-
- } FT_SfntName;
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_Sfnt_Name_Count
- *
- * @description:
- * Retrieve the number of name strings in the SFNT 'name' table.
- *
- * @input:
- * face ::
- * A handle to the source face.
- *
- * @return:
- * The number of strings in the 'name' table.
- *
- * @note:
- * This function always returns an error if the config macro
- * `TT_CONFIG_OPTION_SFNT_NAMES` is not defined in `ftoption.h`.
- */
- FT_EXPORT( FT_UInt )
- FT_Get_Sfnt_Name_Count( FT_Face face );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_Sfnt_Name
- *
- * @description:
- * Retrieve a string of the SFNT 'name' table for a given index.
- *
- * @input:
- * face ::
- * A handle to the source face.
- *
- * idx ::
- * The index of the 'name' string.
- *
- * @output:
- * aname ::
- * The indexed @FT_SfntName structure.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * The `string` array returned in the `aname` structure is not
- * null-terminated. Note that you don't have to deallocate `string` by
- * yourself; FreeType takes care of it if you call @FT_Done_Face.
- *
- * Use @FT_Get_Sfnt_Name_Count to get the total number of available
- * 'name' table entries, then do a loop until you get the right platform,
- * encoding, and name ID.
- *
- * 'name' table format~1 entries can use language tags also, see
- * @FT_Get_Sfnt_LangTag.
- *
- * This function always returns an error if the config macro
- * `TT_CONFIG_OPTION_SFNT_NAMES` is not defined in `ftoption.h`.
- */
- FT_EXPORT( FT_Error )
- FT_Get_Sfnt_Name( FT_Face face,
- FT_UInt idx,
- FT_SfntName *aname );
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_SfntLangTag
- *
- * @description:
- * A structure to model a language tag entry from an SFNT 'name' table.
- *
- * @fields:
- * string ::
- * The language tag string, encoded in UTF-16BE (without trailing
- * `NULL` bytes).
- *
- * string_len ::
- * The length of `string` in **bytes**.
- *
- * @note:
- * Please refer to the TrueType or OpenType specification for more
- * details.
- *
- * @since:
- * 2.8
- */
- typedef struct FT_SfntLangTag_
- {
- FT_Byte* string; /* this string is *not* null-terminated! */
- FT_UInt string_len; /* in bytes */
-
- } FT_SfntLangTag;
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_Sfnt_LangTag
- *
- * @description:
- * Retrieve the language tag associated with a language ID of an SFNT
- * 'name' table entry.
- *
- * @input:
- * face ::
- * A handle to the source face.
- *
- * langID ::
- * The language ID, as returned by @FT_Get_Sfnt_Name. This is always a
- * value larger than 0x8000.
- *
- * @output:
- * alangTag ::
- * The language tag associated with the 'name' table entry's language
- * ID.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * The `string` array returned in the `alangTag` structure is not
- * null-terminated. Note that you don't have to deallocate `string` by
- * yourself; FreeType takes care of it if you call @FT_Done_Face.
- *
- * Only 'name' table format~1 supports language tags. For format~0
- * tables, this function always returns FT_Err_Invalid_Table. For
- * invalid format~1 language ID values, FT_Err_Invalid_Argument is
- * returned.
- *
- * This function always returns an error if the config macro
- * `TT_CONFIG_OPTION_SFNT_NAMES` is not defined in `ftoption.h`.
- *
- * @since:
- * 2.8
- */
- FT_EXPORT( FT_Error )
- FT_Get_Sfnt_LangTag( FT_Face face,
- FT_UInt langID,
- FT_SfntLangTag *alangTag );
-
-
- /* */
-
-
-FT_END_HEADER
-
-#endif /* FTSNAMES_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/ftstroke.h b/contrib/libs/freetype/include/freetype/ftstroke.h
deleted file mode 100644
index 41626dc9d7..0000000000
--- a/contrib/libs/freetype/include/freetype/ftstroke.h
+++ /dev/null
@@ -1,773 +0,0 @@
-/****************************************************************************
- *
- * ftstroke.h
- *
- * FreeType path stroker (specification).
- *
- * Copyright (C) 2002-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTSTROKE_H_
-#define FTSTROKE_H_
-
-#include <freetype/ftoutln.h>
-#include <freetype/ftglyph.h>
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @section:
- * glyph_stroker
- *
- * @title:
- * Glyph Stroker
- *
- * @abstract:
- * Generating bordered and stroked glyphs.
- *
- * @description:
- * This component generates stroked outlines of a given vectorial glyph.
- * It also allows you to retrieve the 'outside' and/or the 'inside'
- * borders of the stroke.
- *
- * This can be useful to generate 'bordered' glyph, i.e., glyphs
- * displayed with a colored (and anti-aliased) border around their
- * shape.
- *
- * @order:
- * FT_Stroker
- *
- * FT_Stroker_LineJoin
- * FT_Stroker_LineCap
- * FT_StrokerBorder
- *
- * FT_Outline_GetInsideBorder
- * FT_Outline_GetOutsideBorder
- *
- * FT_Glyph_Stroke
- * FT_Glyph_StrokeBorder
- *
- * FT_Stroker_New
- * FT_Stroker_Set
- * FT_Stroker_Rewind
- * FT_Stroker_ParseOutline
- * FT_Stroker_Done
- *
- * FT_Stroker_BeginSubPath
- * FT_Stroker_EndSubPath
- *
- * FT_Stroker_LineTo
- * FT_Stroker_ConicTo
- * FT_Stroker_CubicTo
- *
- * FT_Stroker_GetBorderCounts
- * FT_Stroker_ExportBorder
- * FT_Stroker_GetCounts
- * FT_Stroker_Export
- *
- */
-
-
- /**************************************************************************
- *
- * @type:
- * FT_Stroker
- *
- * @description:
- * Opaque handle to a path stroker object.
- */
- typedef struct FT_StrokerRec_* FT_Stroker;
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_Stroker_LineJoin
- *
- * @description:
- * These values determine how two joining lines are rendered in a
- * stroker.
- *
- * @values:
- * FT_STROKER_LINEJOIN_ROUND ::
- * Used to render rounded line joins. Circular arcs are used to join
- * two lines smoothly.
- *
- * FT_STROKER_LINEJOIN_BEVEL ::
- * Used to render beveled line joins. The outer corner of the joined
- * lines is filled by enclosing the triangular region of the corner
- * with a straight line between the outer corners of each stroke.
- *
- * FT_STROKER_LINEJOIN_MITER_FIXED ::
- * Used to render mitered line joins, with fixed bevels if the miter
- * limit is exceeded. The outer edges of the strokes for the two
- * segments are extended until they meet at an angle. A bevel join
- * (see above) is used if the segments meet at too sharp an angle and
- * the outer edges meet beyond a distance corresponding to the meter
- * limit. This prevents long spikes being created.
- * `FT_STROKER_LINEJOIN_MITER_FIXED` generates a miter line join as
- * used in PostScript and PDF.
- *
- * FT_STROKER_LINEJOIN_MITER_VARIABLE ::
- * FT_STROKER_LINEJOIN_MITER ::
- * Used to render mitered line joins, with variable bevels if the miter
- * limit is exceeded. The intersection of the strokes is clipped
- * perpendicularly to the bisector, at a distance corresponding to
- * the miter limit. This prevents long spikes being created.
- * `FT_STROKER_LINEJOIN_MITER_VARIABLE` generates a mitered line join
- * as used in XPS. `FT_STROKER_LINEJOIN_MITER` is an alias for
- * `FT_STROKER_LINEJOIN_MITER_VARIABLE`, retained for backward
- * compatibility.
- */
- typedef enum FT_Stroker_LineJoin_
- {
- FT_STROKER_LINEJOIN_ROUND = 0,
- FT_STROKER_LINEJOIN_BEVEL = 1,
- FT_STROKER_LINEJOIN_MITER_VARIABLE = 2,
- FT_STROKER_LINEJOIN_MITER = FT_STROKER_LINEJOIN_MITER_VARIABLE,
- FT_STROKER_LINEJOIN_MITER_FIXED = 3
-
- } FT_Stroker_LineJoin;
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_Stroker_LineCap
- *
- * @description:
- * These values determine how the end of opened sub-paths are rendered in
- * a stroke.
- *
- * @values:
- * FT_STROKER_LINECAP_BUTT ::
- * The end of lines is rendered as a full stop on the last point
- * itself.
- *
- * FT_STROKER_LINECAP_ROUND ::
- * The end of lines is rendered as a half-circle around the last point.
- *
- * FT_STROKER_LINECAP_SQUARE ::
- * The end of lines is rendered as a square around the last point.
- */
- typedef enum FT_Stroker_LineCap_
- {
- FT_STROKER_LINECAP_BUTT = 0,
- FT_STROKER_LINECAP_ROUND,
- FT_STROKER_LINECAP_SQUARE
-
- } FT_Stroker_LineCap;
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_StrokerBorder
- *
- * @description:
- * These values are used to select a given stroke border in
- * @FT_Stroker_GetBorderCounts and @FT_Stroker_ExportBorder.
- *
- * @values:
- * FT_STROKER_BORDER_LEFT ::
- * Select the left border, relative to the drawing direction.
- *
- * FT_STROKER_BORDER_RIGHT ::
- * Select the right border, relative to the drawing direction.
- *
- * @note:
- * Applications are generally interested in the 'inside' and 'outside'
- * borders. However, there is no direct mapping between these and the
- * 'left' and 'right' ones, since this really depends on the glyph's
- * drawing orientation, which varies between font formats.
- *
- * You can however use @FT_Outline_GetInsideBorder and
- * @FT_Outline_GetOutsideBorder to get these.
- */
- typedef enum FT_StrokerBorder_
- {
- FT_STROKER_BORDER_LEFT = 0,
- FT_STROKER_BORDER_RIGHT
-
- } FT_StrokerBorder;
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Outline_GetInsideBorder
- *
- * @description:
- * Retrieve the @FT_StrokerBorder value corresponding to the 'inside'
- * borders of a given outline.
- *
- * @input:
- * outline ::
- * The source outline handle.
- *
- * @return:
- * The border index. @FT_STROKER_BORDER_RIGHT for empty or invalid
- * outlines.
- */
- FT_EXPORT( FT_StrokerBorder )
- FT_Outline_GetInsideBorder( FT_Outline* outline );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Outline_GetOutsideBorder
- *
- * @description:
- * Retrieve the @FT_StrokerBorder value corresponding to the 'outside'
- * borders of a given outline.
- *
- * @input:
- * outline ::
- * The source outline handle.
- *
- * @return:
- * The border index. @FT_STROKER_BORDER_LEFT for empty or invalid
- * outlines.
- */
- FT_EXPORT( FT_StrokerBorder )
- FT_Outline_GetOutsideBorder( FT_Outline* outline );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Stroker_New
- *
- * @description:
- * Create a new stroker object.
- *
- * @input:
- * library ::
- * FreeType library handle.
- *
- * @output:
- * astroker ::
- * A new stroker object handle. `NULL` in case of error.
- *
- * @return:
- * FreeType error code. 0~means success.
- */
- FT_EXPORT( FT_Error )
- FT_Stroker_New( FT_Library library,
- FT_Stroker *astroker );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Stroker_Set
- *
- * @description:
- * Reset a stroker object's attributes.
- *
- * @input:
- * stroker ::
- * The target stroker handle.
- *
- * radius ::
- * The border radius.
- *
- * line_cap ::
- * The line cap style.
- *
- * line_join ::
- * The line join style.
- *
- * miter_limit ::
- * The maximum reciprocal sine of half-angle at the miter join,
- * expressed as 16.16 fixed-point value.
- *
- * @note:
- * The `radius` is expressed in the same units as the outline
- * coordinates.
- *
- * The `miter_limit` multiplied by the `radius` gives the maximum size
- * of a miter spike, at which it is clipped for
- * @FT_STROKER_LINEJOIN_MITER_VARIABLE or replaced with a bevel join for
- * @FT_STROKER_LINEJOIN_MITER_FIXED.
- *
- * This function calls @FT_Stroker_Rewind automatically.
- */
- FT_EXPORT( void )
- FT_Stroker_Set( FT_Stroker stroker,
- FT_Fixed radius,
- FT_Stroker_LineCap line_cap,
- FT_Stroker_LineJoin line_join,
- FT_Fixed miter_limit );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Stroker_Rewind
- *
- * @description:
- * Reset a stroker object without changing its attributes. You should
- * call this function before beginning a new series of calls to
- * @FT_Stroker_BeginSubPath or @FT_Stroker_EndSubPath.
- *
- * @input:
- * stroker ::
- * The target stroker handle.
- */
- FT_EXPORT( void )
- FT_Stroker_Rewind( FT_Stroker stroker );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Stroker_ParseOutline
- *
- * @description:
- * A convenience function used to parse a whole outline with the stroker.
- * The resulting outline(s) can be retrieved later by functions like
- * @FT_Stroker_GetCounts and @FT_Stroker_Export.
- *
- * @input:
- * stroker ::
- * The target stroker handle.
- *
- * outline ::
- * The source outline.
- *
- * opened ::
- * A boolean. If~1, the outline is treated as an open path instead of
- * a closed one.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * If `opened` is~0 (the default), the outline is treated as a closed
- * path, and the stroker generates two distinct 'border' outlines.
- *
- * If `opened` is~1, the outline is processed as an open path, and the
- * stroker generates a single 'stroke' outline.
- *
- * This function calls @FT_Stroker_Rewind automatically.
- */
- FT_EXPORT( FT_Error )
- FT_Stroker_ParseOutline( FT_Stroker stroker,
- FT_Outline* outline,
- FT_Bool opened );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Stroker_BeginSubPath
- *
- * @description:
- * Start a new sub-path in the stroker.
- *
- * @input:
- * stroker ::
- * The target stroker handle.
- *
- * to ::
- * A pointer to the start vector.
- *
- * open ::
- * A boolean. If~1, the sub-path is treated as an open one.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * This function is useful when you need to stroke a path that is not
- * stored as an @FT_Outline object.
- */
- FT_EXPORT( FT_Error )
- FT_Stroker_BeginSubPath( FT_Stroker stroker,
- FT_Vector* to,
- FT_Bool open );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Stroker_EndSubPath
- *
- * @description:
- * Close the current sub-path in the stroker.
- *
- * @input:
- * stroker ::
- * The target stroker handle.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * You should call this function after @FT_Stroker_BeginSubPath. If the
- * subpath was not 'opened', this function 'draws' a single line segment
- * to the start position when needed.
- */
- FT_EXPORT( FT_Error )
- FT_Stroker_EndSubPath( FT_Stroker stroker );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Stroker_LineTo
- *
- * @description:
- * 'Draw' a single line segment in the stroker's current sub-path, from
- * the last position.
- *
- * @input:
- * stroker ::
- * The target stroker handle.
- *
- * to ::
- * A pointer to the destination point.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * You should call this function between @FT_Stroker_BeginSubPath and
- * @FT_Stroker_EndSubPath.
- */
- FT_EXPORT( FT_Error )
- FT_Stroker_LineTo( FT_Stroker stroker,
- FT_Vector* to );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Stroker_ConicTo
- *
- * @description:
- * 'Draw' a single quadratic Bezier in the stroker's current sub-path,
- * from the last position.
- *
- * @input:
- * stroker ::
- * The target stroker handle.
- *
- * control ::
- * A pointer to a Bezier control point.
- *
- * to ::
- * A pointer to the destination point.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * You should call this function between @FT_Stroker_BeginSubPath and
- * @FT_Stroker_EndSubPath.
- */
- FT_EXPORT( FT_Error )
- FT_Stroker_ConicTo( FT_Stroker stroker,
- FT_Vector* control,
- FT_Vector* to );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Stroker_CubicTo
- *
- * @description:
- * 'Draw' a single cubic Bezier in the stroker's current sub-path, from
- * the last position.
- *
- * @input:
- * stroker ::
- * The target stroker handle.
- *
- * control1 ::
- * A pointer to the first Bezier control point.
- *
- * control2 ::
- * A pointer to second Bezier control point.
- *
- * to ::
- * A pointer to the destination point.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * You should call this function between @FT_Stroker_BeginSubPath and
- * @FT_Stroker_EndSubPath.
- */
- FT_EXPORT( FT_Error )
- FT_Stroker_CubicTo( FT_Stroker stroker,
- FT_Vector* control1,
- FT_Vector* control2,
- FT_Vector* to );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Stroker_GetBorderCounts
- *
- * @description:
- * Call this function once you have finished parsing your paths with the
- * stroker. It returns the number of points and contours necessary to
- * export one of the 'border' or 'stroke' outlines generated by the
- * stroker.
- *
- * @input:
- * stroker ::
- * The target stroker handle.
- *
- * border ::
- * The border index.
- *
- * @output:
- * anum_points ::
- * The number of points.
- *
- * anum_contours ::
- * The number of contours.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * When an outline, or a sub-path, is 'closed', the stroker generates two
- * independent 'border' outlines, named 'left' and 'right'.
- *
- * When the outline, or a sub-path, is 'opened', the stroker merges the
- * 'border' outlines with caps. The 'left' border receives all points,
- * while the 'right' border becomes empty.
- *
- * Use the function @FT_Stroker_GetCounts instead if you want to retrieve
- * the counts associated to both borders.
- */
- FT_EXPORT( FT_Error )
- FT_Stroker_GetBorderCounts( FT_Stroker stroker,
- FT_StrokerBorder border,
- FT_UInt *anum_points,
- FT_UInt *anum_contours );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Stroker_ExportBorder
- *
- * @description:
- * Call this function after @FT_Stroker_GetBorderCounts to export the
- * corresponding border to your own @FT_Outline structure.
- *
- * Note that this function appends the border points and contours to your
- * outline, but does not try to resize its arrays.
- *
- * @input:
- * stroker ::
- * The target stroker handle.
- *
- * border ::
- * The border index.
- *
- * outline ::
- * The target outline handle.
- *
- * @note:
- * Always call this function after @FT_Stroker_GetBorderCounts to get
- * sure that there is enough room in your @FT_Outline object to receive
- * all new data.
- *
- * When an outline, or a sub-path, is 'closed', the stroker generates two
- * independent 'border' outlines, named 'left' and 'right'.
- *
- * When the outline, or a sub-path, is 'opened', the stroker merges the
- * 'border' outlines with caps. The 'left' border receives all points,
- * while the 'right' border becomes empty.
- *
- * Use the function @FT_Stroker_Export instead if you want to retrieve
- * all borders at once.
- */
- FT_EXPORT( void )
- FT_Stroker_ExportBorder( FT_Stroker stroker,
- FT_StrokerBorder border,
- FT_Outline* outline );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Stroker_GetCounts
- *
- * @description:
- * Call this function once you have finished parsing your paths with the
- * stroker. It returns the number of points and contours necessary to
- * export all points/borders from the stroked outline/path.
- *
- * @input:
- * stroker ::
- * The target stroker handle.
- *
- * @output:
- * anum_points ::
- * The number of points.
- *
- * anum_contours ::
- * The number of contours.
- *
- * @return:
- * FreeType error code. 0~means success.
- */
- FT_EXPORT( FT_Error )
- FT_Stroker_GetCounts( FT_Stroker stroker,
- FT_UInt *anum_points,
- FT_UInt *anum_contours );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Stroker_Export
- *
- * @description:
- * Call this function after @FT_Stroker_GetBorderCounts to export all
- * borders to your own @FT_Outline structure.
- *
- * Note that this function appends the border points and contours to your
- * outline, but does not try to resize its arrays.
- *
- * @input:
- * stroker ::
- * The target stroker handle.
- *
- * outline ::
- * The target outline handle.
- */
- FT_EXPORT( void )
- FT_Stroker_Export( FT_Stroker stroker,
- FT_Outline* outline );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Stroker_Done
- *
- * @description:
- * Destroy a stroker object.
- *
- * @input:
- * stroker ::
- * A stroker handle. Can be `NULL`.
- */
- FT_EXPORT( void )
- FT_Stroker_Done( FT_Stroker stroker );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Glyph_Stroke
- *
- * @description:
- * Stroke a given outline glyph object with a given stroker.
- *
- * @inout:
- * pglyph ::
- * Source glyph handle on input, new glyph handle on output.
- *
- * @input:
- * stroker ::
- * A stroker handle.
- *
- * destroy ::
- * A Boolean. If~1, the source glyph object is destroyed on success.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * The source glyph is untouched in case of error.
- *
- * Adding stroke may yield a significantly wider and taller glyph
- * depending on how large of a radius was used to stroke the glyph. You
- * may need to manually adjust horizontal and vertical advance amounts to
- * account for this added size.
- */
- FT_EXPORT( FT_Error )
- FT_Glyph_Stroke( FT_Glyph *pglyph,
- FT_Stroker stroker,
- FT_Bool destroy );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Glyph_StrokeBorder
- *
- * @description:
- * Stroke a given outline glyph object with a given stroker, but only
- * return either its inside or outside border.
- *
- * @inout:
- * pglyph ::
- * Source glyph handle on input, new glyph handle on output.
- *
- * @input:
- * stroker ::
- * A stroker handle.
- *
- * inside ::
- * A Boolean. If~1, return the inside border, otherwise the outside
- * border.
- *
- * destroy ::
- * A Boolean. If~1, the source glyph object is destroyed on success.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * The source glyph is untouched in case of error.
- *
- * Adding stroke may yield a significantly wider and taller glyph
- * depending on how large of a radius was used to stroke the glyph. You
- * may need to manually adjust horizontal and vertical advance amounts to
- * account for this added size.
- */
- FT_EXPORT( FT_Error )
- FT_Glyph_StrokeBorder( FT_Glyph *pglyph,
- FT_Stroker stroker,
- FT_Bool inside,
- FT_Bool destroy );
-
- /* */
-
-FT_END_HEADER
-
-#endif /* FTSTROKE_H_ */
-
-
-/* END */
-
-
-/* Local Variables: */
-/* coding: utf-8 */
-/* End: */
diff --git a/contrib/libs/freetype/include/freetype/ftsynth.h b/contrib/libs/freetype/include/freetype/ftsynth.h
deleted file mode 100644
index 43081b6c33..0000000000
--- a/contrib/libs/freetype/include/freetype/ftsynth.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/****************************************************************************
- *
- * ftsynth.h
- *
- * FreeType synthesizing code for emboldening and slanting
- * (specification).
- *
- * Copyright (C) 2000-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /********* *********/
- /********* WARNING, THIS IS ALPHA CODE! THIS API *********/
- /********* IS DUE TO CHANGE UNTIL STRICTLY NOTIFIED BY THE *********/
- /********* FREETYPE DEVELOPMENT TEAM *********/
- /********* *********/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /* Main reason for not lifting the functions in this module to a */
- /* 'standard' API is that the used parameters for emboldening and */
- /* slanting are not configurable. Consider the functions as a */
- /* code resource that should be copied into the application and */
- /* adapted to the particular needs. */
-
-
-#ifndef FTSYNTH_H_
-#define FTSYNTH_H_
-
-
-#include <freetype/freetype.h>
-
-#ifdef FREETYPE_H
-#error "freetype.h of FreeType 1 has been loaded!"
-#error "Please fix the directory search order for header files"
-#error "so that freetype.h of FreeType 2 is found first."
-#endif
-
-
-FT_BEGIN_HEADER
-
- /* Embolden a glyph by a 'reasonable' value (which is highly a matter of */
- /* taste). This function is actually a convenience function, providing */
- /* a wrapper for @FT_Outline_Embolden and @FT_Bitmap_Embolden. */
- /* */
- /* For emboldened outlines the height, width, and advance metrics are */
- /* increased by the strength of the emboldening -- this even affects */
- /* mono-width fonts! */
- /* */
- /* You can also call @FT_Outline_Get_CBox to get precise values. */
- FT_EXPORT( void )
- FT_GlyphSlot_Embolden( FT_GlyphSlot slot );
-
- /* Precisely adjust the glyph weight either horizontally or vertically. */
- /* The `xdelta` and `ydelta` values are fractions of the face Em size */
- /* (in fixed-point format). Considering that a regular face would have */
- /* stem widths on the order of 0.1 Em, a delta of 0.05 (0x0CCC) should */
- /* be very noticeable. To increase or decrease the weight, use positive */
- /* or negative values, respectively. */
- FT_EXPORT( void )
- FT_GlyphSlot_AdjustWeight( FT_GlyphSlot slot,
- FT_Fixed xdelta,
- FT_Fixed ydelta );
-
-
- /* Slant an outline glyph to the right by about 12 degrees. */
- FT_EXPORT( void )
- FT_GlyphSlot_Oblique( FT_GlyphSlot slot );
-
- /* Slant an outline glyph by a given sine of an angle. You can apply */
- /* slant along either x- or y-axis by choosing a corresponding non-zero */
- /* argument. If both slants are non-zero, some affine transformation */
- /* will result. */
- FT_EXPORT( void )
- FT_GlyphSlot_Slant( FT_GlyphSlot slot,
- FT_Fixed xslant,
- FT_Fixed yslant );
-
- /* */
-
-
-FT_END_HEADER
-
-#endif /* FTSYNTH_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/ftsystem.h b/contrib/libs/freetype/include/freetype/ftsystem.h
deleted file mode 100644
index 1eacb3af39..0000000000
--- a/contrib/libs/freetype/include/freetype/ftsystem.h
+++ /dev/null
@@ -1,350 +0,0 @@
-/****************************************************************************
- *
- * ftsystem.h
- *
- * FreeType low-level system interface definition (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTSYSTEM_H_
-#define FTSYSTEM_H_
-
-
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @section:
- * system_interface
- *
- * @title:
- * System Interface
- *
- * @abstract:
- * How FreeType manages memory and i/o.
- *
- * @description:
- * This section contains various definitions related to memory management
- * and i/o access. You need to understand this information if you want to
- * use a custom memory manager or you own i/o streams.
- *
- */
-
-
- /**************************************************************************
- *
- * M E M O R Y M A N A G E M E N T
- *
- */
-
-
- /**************************************************************************
- *
- * @type:
- * FT_Memory
- *
- * @description:
- * A handle to a given memory manager object, defined with an
- * @FT_MemoryRec structure.
- *
- */
- typedef struct FT_MemoryRec_* FT_Memory;
-
-
- /**************************************************************************
- *
- * @functype:
- * FT_Alloc_Func
- *
- * @description:
- * A function used to allocate `size` bytes from `memory`.
- *
- * @input:
- * memory ::
- * A handle to the source memory manager.
- *
- * size ::
- * The size in bytes to allocate.
- *
- * @return:
- * Address of new memory block. 0~in case of failure.
- *
- */
- typedef void*
- (*FT_Alloc_Func)( FT_Memory memory,
- long size );
-
-
- /**************************************************************************
- *
- * @functype:
- * FT_Free_Func
- *
- * @description:
- * A function used to release a given block of memory.
- *
- * @input:
- * memory ::
- * A handle to the source memory manager.
- *
- * block ::
- * The address of the target memory block.
- *
- */
- typedef void
- (*FT_Free_Func)( FT_Memory memory,
- void* block );
-
-
- /**************************************************************************
- *
- * @functype:
- * FT_Realloc_Func
- *
- * @description:
- * A function used to re-allocate a given block of memory.
- *
- * @input:
- * memory ::
- * A handle to the source memory manager.
- *
- * cur_size ::
- * The block's current size in bytes.
- *
- * new_size ::
- * The block's requested new size.
- *
- * block ::
- * The block's current address.
- *
- * @return:
- * New block address. 0~in case of memory shortage.
- *
- * @note:
- * In case of error, the old block must still be available.
- *
- */
- typedef void*
- (*FT_Realloc_Func)( FT_Memory memory,
- long cur_size,
- long new_size,
- void* block );
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_MemoryRec
- *
- * @description:
- * A structure used to describe a given memory manager to FreeType~2.
- *
- * @fields:
- * user ::
- * A generic typeless pointer for user data.
- *
- * alloc ::
- * A pointer type to an allocation function.
- *
- * free ::
- * A pointer type to an memory freeing function.
- *
- * realloc ::
- * A pointer type to a reallocation function.
- *
- */
- struct FT_MemoryRec_
- {
- void* user;
- FT_Alloc_Func alloc;
- FT_Free_Func free;
- FT_Realloc_Func realloc;
- };
-
-
- /**************************************************************************
- *
- * I / O M A N A G E M E N T
- *
- */
-
-
- /**************************************************************************
- *
- * @type:
- * FT_Stream
- *
- * @description:
- * A handle to an input stream.
- *
- * @also:
- * See @FT_StreamRec for the publicly accessible fields of a given stream
- * object.
- *
- */
- typedef struct FT_StreamRec_* FT_Stream;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_StreamDesc
- *
- * @description:
- * A union type used to store either a long or a pointer. This is used
- * to store a file descriptor or a `FILE*` in an input stream.
- *
- */
- typedef union FT_StreamDesc_
- {
- long value;
- void* pointer;
-
- } FT_StreamDesc;
-
-
- /**************************************************************************
- *
- * @functype:
- * FT_Stream_IoFunc
- *
- * @description:
- * A function used to seek and read data from a given input stream.
- *
- * @input:
- * stream ::
- * A handle to the source stream.
- *
- * offset ::
- * The offset from the start of the stream to seek to.
- *
- * buffer ::
- * The address of the read buffer.
- *
- * count ::
- * The number of bytes to read from the stream.
- *
- * @return:
- * If count >~0, return the number of bytes effectively read by the
- * stream (after seeking to `offset`). If count ==~0, return the status
- * of the seek operation (non-zero indicates an error).
- *
- */
- typedef unsigned long
- (*FT_Stream_IoFunc)( FT_Stream stream,
- unsigned long offset,
- unsigned char* buffer,
- unsigned long count );
-
-
- /**************************************************************************
- *
- * @functype:
- * FT_Stream_CloseFunc
- *
- * @description:
- * A function used to close a given input stream.
- *
- * @input:
- * stream ::
- * A handle to the target stream.
- *
- */
- typedef void
- (*FT_Stream_CloseFunc)( FT_Stream stream );
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_StreamRec
- *
- * @description:
- * A structure used to describe an input stream.
- *
- * @input:
- * base ::
- * For memory-based streams, this is the address of the first stream
- * byte in memory. This field should always be set to `NULL` for
- * disk-based streams.
- *
- * size ::
- * The stream size in bytes.
- *
- * In case of compressed streams where the size is unknown before
- * actually doing the decompression, the value is set to 0x7FFFFFFF.
- * (Note that this size value can occur for normal streams also; it is
- * thus just a hint.)
- *
- * pos ::
- * The current position within the stream.
- *
- * descriptor ::
- * This field is a union that can hold an integer or a pointer. It is
- * used by stream implementations to store file descriptors or `FILE*`
- * pointers.
- *
- * pathname ::
- * This field is completely ignored by FreeType. However, it is often
- * useful during debugging to use it to store the stream's filename
- * (where available).
- *
- * read ::
- * The stream's input function.
- *
- * close ::
- * The stream's close function.
- *
- * memory ::
- * The memory manager to use to preload frames. This is set internally
- * by FreeType and shouldn't be touched by stream implementations.
- *
- * cursor ::
- * This field is set and used internally by FreeType when parsing
- * frames. In particular, the `FT_GET_XXX` macros use this instead of
- * the `pos` field.
- *
- * limit ::
- * This field is set and used internally by FreeType when parsing
- * frames.
- *
- */
- typedef struct FT_StreamRec_
- {
- unsigned char* base;
- unsigned long size;
- unsigned long pos;
-
- FT_StreamDesc descriptor;
- FT_StreamDesc pathname;
- FT_Stream_IoFunc read;
- FT_Stream_CloseFunc close;
-
- FT_Memory memory;
- unsigned char* cursor;
- unsigned char* limit;
-
- } FT_StreamRec;
-
- /* */
-
-
-FT_END_HEADER
-
-#endif /* FTSYSTEM_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/fttrigon.h b/contrib/libs/freetype/include/freetype/fttrigon.h
deleted file mode 100644
index a5299e938d..0000000000
--- a/contrib/libs/freetype/include/freetype/fttrigon.h
+++ /dev/null
@@ -1,350 +0,0 @@
-/****************************************************************************
- *
- * fttrigon.h
- *
- * FreeType trigonometric functions (specification).
- *
- * Copyright (C) 2001-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTTRIGON_H_
-#define FTTRIGON_H_
-
-#include <freetype/freetype.h>
-
-#ifdef FREETYPE_H
-#error "freetype.h of FreeType 1 has been loaded!"
-#error "Please fix the directory search order for header files"
-#error "so that freetype.h of FreeType 2 is found first."
-#endif
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @section:
- * computations
- *
- */
-
-
- /**************************************************************************
- *
- * @type:
- * FT_Angle
- *
- * @description:
- * This type is used to model angle values in FreeType. Note that the
- * angle is a 16.16 fixed-point value expressed in degrees.
- *
- */
- typedef FT_Fixed FT_Angle;
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_ANGLE_PI
- *
- * @description:
- * The angle pi expressed in @FT_Angle units.
- *
- */
-#define FT_ANGLE_PI ( 180L << 16 )
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_ANGLE_2PI
- *
- * @description:
- * The angle 2*pi expressed in @FT_Angle units.
- *
- */
-#define FT_ANGLE_2PI ( FT_ANGLE_PI * 2 )
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_ANGLE_PI2
- *
- * @description:
- * The angle pi/2 expressed in @FT_Angle units.
- *
- */
-#define FT_ANGLE_PI2 ( FT_ANGLE_PI / 2 )
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_ANGLE_PI4
- *
- * @description:
- * The angle pi/4 expressed in @FT_Angle units.
- *
- */
-#define FT_ANGLE_PI4 ( FT_ANGLE_PI / 4 )
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Sin
- *
- * @description:
- * Return the sinus of a given angle in fixed-point format.
- *
- * @input:
- * angle ::
- * The input angle.
- *
- * @return:
- * The sinus value.
- *
- * @note:
- * If you need both the sinus and cosinus for a given angle, use the
- * function @FT_Vector_Unit.
- *
- */
- FT_EXPORT( FT_Fixed )
- FT_Sin( FT_Angle angle );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Cos
- *
- * @description:
- * Return the cosinus of a given angle in fixed-point format.
- *
- * @input:
- * angle ::
- * The input angle.
- *
- * @return:
- * The cosinus value.
- *
- * @note:
- * If you need both the sinus and cosinus for a given angle, use the
- * function @FT_Vector_Unit.
- *
- */
- FT_EXPORT( FT_Fixed )
- FT_Cos( FT_Angle angle );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Tan
- *
- * @description:
- * Return the tangent of a given angle in fixed-point format.
- *
- * @input:
- * angle ::
- * The input angle.
- *
- * @return:
- * The tangent value.
- *
- */
- FT_EXPORT( FT_Fixed )
- FT_Tan( FT_Angle angle );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Atan2
- *
- * @description:
- * Return the arc-tangent corresponding to a given vector (x,y) in the 2d
- * plane.
- *
- * @input:
- * x ::
- * The horizontal vector coordinate.
- *
- * y ::
- * The vertical vector coordinate.
- *
- * @return:
- * The arc-tangent value (i.e. angle).
- *
- */
- FT_EXPORT( FT_Angle )
- FT_Atan2( FT_Fixed x,
- FT_Fixed y );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Angle_Diff
- *
- * @description:
- * Return the difference between two angles. The result is always
- * constrained to the ]-PI..PI] interval.
- *
- * @input:
- * angle1 ::
- * First angle.
- *
- * angle2 ::
- * Second angle.
- *
- * @return:
- * Constrained value of `angle2-angle1`.
- *
- */
- FT_EXPORT( FT_Angle )
- FT_Angle_Diff( FT_Angle angle1,
- FT_Angle angle2 );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Vector_Unit
- *
- * @description:
- * Return the unit vector corresponding to a given angle. After the
- * call, the value of `vec.x` will be `cos(angle)`, and the value of
- * `vec.y` will be `sin(angle)`.
- *
- * This function is useful to retrieve both the sinus and cosinus of a
- * given angle quickly.
- *
- * @output:
- * vec ::
- * The address of target vector.
- *
- * @input:
- * angle ::
- * The input angle.
- *
- */
- FT_EXPORT( void )
- FT_Vector_Unit( FT_Vector* vec,
- FT_Angle angle );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Vector_Rotate
- *
- * @description:
- * Rotate a vector by a given angle.
- *
- * @inout:
- * vec ::
- * The address of target vector.
- *
- * @input:
- * angle ::
- * The input angle.
- *
- */
- FT_EXPORT( void )
- FT_Vector_Rotate( FT_Vector* vec,
- FT_Angle angle );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Vector_Length
- *
- * @description:
- * Return the length of a given vector.
- *
- * @input:
- * vec ::
- * The address of target vector.
- *
- * @return:
- * The vector length, expressed in the same units that the original
- * vector coordinates.
- *
- */
- FT_EXPORT( FT_Fixed )
- FT_Vector_Length( FT_Vector* vec );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Vector_Polarize
- *
- * @description:
- * Compute both the length and angle of a given vector.
- *
- * @input:
- * vec ::
- * The address of source vector.
- *
- * @output:
- * length ::
- * The vector length.
- *
- * angle ::
- * The vector angle.
- *
- */
- FT_EXPORT( void )
- FT_Vector_Polarize( FT_Vector* vec,
- FT_Fixed *length,
- FT_Angle *angle );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Vector_From_Polar
- *
- * @description:
- * Compute vector coordinates from a length and angle.
- *
- * @output:
- * vec ::
- * The address of source vector.
- *
- * @input:
- * length ::
- * The vector length.
- *
- * angle ::
- * The vector angle.
- *
- */
- FT_EXPORT( void )
- FT_Vector_From_Polar( FT_Vector* vec,
- FT_Fixed length,
- FT_Angle angle );
-
- /* */
-
-
-FT_END_HEADER
-
-#endif /* FTTRIGON_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/fttypes.h b/contrib/libs/freetype/include/freetype/fttypes.h
deleted file mode 100644
index 27815143a6..0000000000
--- a/contrib/libs/freetype/include/freetype/fttypes.h
+++ /dev/null
@@ -1,617 +0,0 @@
-/****************************************************************************
- *
- * fttypes.h
- *
- * FreeType simple types definitions (specification only).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTTYPES_H_
-#define FTTYPES_H_
-
-
-#include <ft2build.h>
-#include FT_CONFIG_CONFIG_H
-#include <freetype/ftsystem.h>
-#include <freetype/ftimage.h>
-
-#include <stddef.h>
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @section:
- * basic_types
- *
- * @title:
- * Basic Data Types
- *
- * @abstract:
- * The basic data types defined by the library.
- *
- * @description:
- * This section contains the basic data types defined by FreeType~2,
- * ranging from simple scalar types to bitmap descriptors. More
- * font-specific structures are defined in a different section. Note
- * that FreeType does not use floating-point data types. Fractional
- * values are represented by fixed-point integers, with lower bits
- * storing the fractional part.
- *
- * @order:
- * FT_Byte
- * FT_Bytes
- * FT_Char
- * FT_Int
- * FT_UInt
- * FT_Int16
- * FT_UInt16
- * FT_Int32
- * FT_UInt32
- * FT_Int64
- * FT_UInt64
- * FT_Short
- * FT_UShort
- * FT_Long
- * FT_ULong
- * FT_Bool
- * FT_Offset
- * FT_PtrDist
- * FT_String
- * FT_Tag
- * FT_Error
- * FT_Fixed
- * FT_Pointer
- * FT_Pos
- * FT_Vector
- * FT_BBox
- * FT_Matrix
- * FT_FWord
- * FT_UFWord
- * FT_F2Dot14
- * FT_UnitVector
- * FT_F26Dot6
- * FT_Data
- *
- * FT_MAKE_TAG
- *
- * FT_Generic
- * FT_Generic_Finalizer
- *
- * FT_Bitmap
- * FT_Pixel_Mode
- * FT_Palette_Mode
- * FT_Glyph_Format
- * FT_IMAGE_TAG
- *
- */
-
-
- /**************************************************************************
- *
- * @type:
- * FT_Bool
- *
- * @description:
- * A typedef of unsigned char, used for simple booleans. As usual,
- * values 1 and~0 represent true and false, respectively.
- */
- typedef unsigned char FT_Bool;
-
-
- /**************************************************************************
- *
- * @type:
- * FT_FWord
- *
- * @description:
- * A signed 16-bit integer used to store a distance in original font
- * units.
- */
- typedef signed short FT_FWord; /* distance in FUnits */
-
-
- /**************************************************************************
- *
- * @type:
- * FT_UFWord
- *
- * @description:
- * An unsigned 16-bit integer used to store a distance in original font
- * units.
- */
- typedef unsigned short FT_UFWord; /* unsigned distance */
-
-
- /**************************************************************************
- *
- * @type:
- * FT_Char
- *
- * @description:
- * A simple typedef for the _signed_ char type.
- */
- typedef signed char FT_Char;
-
-
- /**************************************************************************
- *
- * @type:
- * FT_Byte
- *
- * @description:
- * A simple typedef for the _unsigned_ char type.
- */
- typedef unsigned char FT_Byte;
-
-
- /**************************************************************************
- *
- * @type:
- * FT_Bytes
- *
- * @description:
- * A typedef for constant memory areas.
- */
- typedef const FT_Byte* FT_Bytes;
-
-
- /**************************************************************************
- *
- * @type:
- * FT_Tag
- *
- * @description:
- * A typedef for 32-bit tags (as used in the SFNT format).
- */
- typedef FT_UInt32 FT_Tag;
-
-
- /**************************************************************************
- *
- * @type:
- * FT_String
- *
- * @description:
- * A simple typedef for the char type, usually used for strings.
- */
- typedef char FT_String;
-
-
- /**************************************************************************
- *
- * @type:
- * FT_Short
- *
- * @description:
- * A typedef for signed short.
- */
- typedef signed short FT_Short;
-
-
- /**************************************************************************
- *
- * @type:
- * FT_UShort
- *
- * @description:
- * A typedef for unsigned short.
- */
- typedef unsigned short FT_UShort;
-
-
- /**************************************************************************
- *
- * @type:
- * FT_Int
- *
- * @description:
- * A typedef for the int type.
- */
- typedef signed int FT_Int;
-
-
- /**************************************************************************
- *
- * @type:
- * FT_UInt
- *
- * @description:
- * A typedef for the unsigned int type.
- */
- typedef unsigned int FT_UInt;
-
-
- /**************************************************************************
- *
- * @type:
- * FT_Long
- *
- * @description:
- * A typedef for signed long.
- */
- typedef signed long FT_Long;
-
-
- /**************************************************************************
- *
- * @type:
- * FT_ULong
- *
- * @description:
- * A typedef for unsigned long.
- */
- typedef unsigned long FT_ULong;
-
-
- /**************************************************************************
- *
- * @type:
- * FT_F2Dot14
- *
- * @description:
- * A signed 2.14 fixed-point type used for unit vectors.
- */
- typedef signed short FT_F2Dot14;
-
-
- /**************************************************************************
- *
- * @type:
- * FT_F26Dot6
- *
- * @description:
- * A signed 26.6 fixed-point type used for vectorial pixel coordinates.
- */
- typedef signed long FT_F26Dot6;
-
-
- /**************************************************************************
- *
- * @type:
- * FT_Fixed
- *
- * @description:
- * This type is used to store 16.16 fixed-point values, like scaling
- * values or matrix coefficients.
- */
- typedef signed long FT_Fixed;
-
-
- /**************************************************************************
- *
- * @type:
- * FT_Error
- *
- * @description:
- * The FreeType error code type. A value of~0 is always interpreted as a
- * successful operation.
- */
- typedef int FT_Error;
-
-
- /**************************************************************************
- *
- * @type:
- * FT_Pointer
- *
- * @description:
- * A simple typedef for a typeless pointer.
- */
- typedef void* FT_Pointer;
-
-
- /**************************************************************************
- *
- * @type:
- * FT_Offset
- *
- * @description:
- * This is equivalent to the ANSI~C `size_t` type, i.e., the largest
- * _unsigned_ integer type used to express a file size or position, or a
- * memory block size.
- */
- typedef size_t FT_Offset;
-
-
- /**************************************************************************
- *
- * @type:
- * FT_PtrDist
- *
- * @description:
- * This is equivalent to the ANSI~C `ptrdiff_t` type, i.e., the largest
- * _signed_ integer type used to express the distance between two
- * pointers.
- */
- typedef ft_ptrdiff_t FT_PtrDist;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_UnitVector
- *
- * @description:
- * A simple structure used to store a 2D vector unit vector. Uses
- * FT_F2Dot14 types.
- *
- * @fields:
- * x ::
- * Horizontal coordinate.
- *
- * y ::
- * Vertical coordinate.
- */
- typedef struct FT_UnitVector_
- {
- FT_F2Dot14 x;
- FT_F2Dot14 y;
-
- } FT_UnitVector;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_Matrix
- *
- * @description:
- * A simple structure used to store a 2x2 matrix. Coefficients are in
- * 16.16 fixed-point format. The computation performed is:
- *
- * ```
- * x' = x*xx + y*xy
- * y' = x*yx + y*yy
- * ```
- *
- * @fields:
- * xx ::
- * Matrix coefficient.
- *
- * xy ::
- * Matrix coefficient.
- *
- * yx ::
- * Matrix coefficient.
- *
- * yy ::
- * Matrix coefficient.
- */
- typedef struct FT_Matrix_
- {
- FT_Fixed xx, xy;
- FT_Fixed yx, yy;
-
- } FT_Matrix;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_Data
- *
- * @description:
- * Read-only binary data represented as a pointer and a length.
- *
- * @fields:
- * pointer ::
- * The data.
- *
- * length ::
- * The length of the data in bytes.
- */
- typedef struct FT_Data_
- {
- const FT_Byte* pointer;
- FT_UInt length;
-
- } FT_Data;
-
-
- /**************************************************************************
- *
- * @functype:
- * FT_Generic_Finalizer
- *
- * @description:
- * Describe a function used to destroy the 'client' data of any FreeType
- * object. See the description of the @FT_Generic type for details of
- * usage.
- *
- * @input:
- * The address of the FreeType object that is under finalization. Its
- * client data is accessed through its `generic` field.
- */
- typedef void (*FT_Generic_Finalizer)( void* object );
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_Generic
- *
- * @description:
- * Client applications often need to associate their own data to a
- * variety of FreeType core objects. For example, a text layout API
- * might want to associate a glyph cache to a given size object.
- *
- * Some FreeType object contains a `generic` field, of type `FT_Generic`,
- * which usage is left to client applications and font servers.
- *
- * It can be used to store a pointer to client-specific data, as well as
- * the address of a 'finalizer' function, which will be called by
- * FreeType when the object is destroyed (for example, the previous
- * client example would put the address of the glyph cache destructor in
- * the `finalizer` field).
- *
- * @fields:
- * data ::
- * A typeless pointer to any client-specified data. This field is
- * completely ignored by the FreeType library.
- *
- * finalizer ::
- * A pointer to a 'generic finalizer' function, which will be called
- * when the object is destroyed. If this field is set to `NULL`, no
- * code will be called.
- */
- typedef struct FT_Generic_
- {
- void* data;
- FT_Generic_Finalizer finalizer;
-
- } FT_Generic;
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_MAKE_TAG
- *
- * @description:
- * This macro converts four-letter tags that are used to label TrueType
- * tables into an `FT_Tag` type, to be used within FreeType.
- *
- * @note:
- * The produced values **must** be 32-bit integers. Don't redefine this
- * macro.
- */
-#define FT_MAKE_TAG( _x1, _x2, _x3, _x4 ) \
- ( ( FT_STATIC_BYTE_CAST( FT_Tag, _x1 ) << 24 ) | \
- ( FT_STATIC_BYTE_CAST( FT_Tag, _x2 ) << 16 ) | \
- ( FT_STATIC_BYTE_CAST( FT_Tag, _x3 ) << 8 ) | \
- FT_STATIC_BYTE_CAST( FT_Tag, _x4 ) )
-
-
- /*************************************************************************/
- /*************************************************************************/
- /* */
- /* L I S T M A N A G E M E N T */
- /* */
- /*************************************************************************/
- /*************************************************************************/
-
-
- /**************************************************************************
- *
- * @section:
- * list_processing
- *
- */
-
-
- /**************************************************************************
- *
- * @type:
- * FT_ListNode
- *
- * @description:
- * Many elements and objects in FreeType are listed through an @FT_List
- * record (see @FT_ListRec). As its name suggests, an FT_ListNode is a
- * handle to a single list element.
- */
- typedef struct FT_ListNodeRec_* FT_ListNode;
-
-
- /**************************************************************************
- *
- * @type:
- * FT_List
- *
- * @description:
- * A handle to a list record (see @FT_ListRec).
- */
- typedef struct FT_ListRec_* FT_List;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_ListNodeRec
- *
- * @description:
- * A structure used to hold a single list element.
- *
- * @fields:
- * prev ::
- * The previous element in the list. `NULL` if first.
- *
- * next ::
- * The next element in the list. `NULL` if last.
- *
- * data ::
- * A typeless pointer to the listed object.
- */
- typedef struct FT_ListNodeRec_
- {
- FT_ListNode prev;
- FT_ListNode next;
- void* data;
-
- } FT_ListNodeRec;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_ListRec
- *
- * @description:
- * A structure used to hold a simple doubly-linked list. These are used
- * in many parts of FreeType.
- *
- * @fields:
- * head ::
- * The head (first element) of doubly-linked list.
- *
- * tail ::
- * The tail (last element) of doubly-linked list.
- */
- typedef struct FT_ListRec_
- {
- FT_ListNode head;
- FT_ListNode tail;
-
- } FT_ListRec;
-
- /* */
-
-
-#define FT_IS_EMPTY( list ) ( (list).head == 0 )
-#define FT_BOOL( x ) FT_STATIC_CAST( FT_Bool, (x) != 0 )
-
- /* concatenate C tokens */
-#define FT_ERR_XCAT( x, y ) x ## y
-#define FT_ERR_CAT( x, y ) FT_ERR_XCAT( x, y )
-
- /* see `ftmoderr.h` for descriptions of the following macros */
-
-#define FT_ERR( e ) FT_ERR_CAT( FT_ERR_PREFIX, e )
-
-#define FT_ERROR_BASE( x ) ( (x) & 0xFF )
-#define FT_ERROR_MODULE( x ) ( (x) & 0xFF00U )
-
-#define FT_ERR_EQ( x, e ) \
- ( FT_ERROR_BASE( x ) == FT_ERROR_BASE( FT_ERR( e ) ) )
-#define FT_ERR_NEQ( x, e ) \
- ( FT_ERROR_BASE( x ) != FT_ERROR_BASE( FT_ERR( e ) ) )
-
-
-FT_END_HEADER
-
-#endif /* FTTYPES_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/ftwinfnt.h b/contrib/libs/freetype/include/freetype/ftwinfnt.h
deleted file mode 100644
index 2591e58866..0000000000
--- a/contrib/libs/freetype/include/freetype/ftwinfnt.h
+++ /dev/null
@@ -1,276 +0,0 @@
-/****************************************************************************
- *
- * ftwinfnt.h
- *
- * FreeType API for accessing Windows fnt-specific data.
- *
- * Copyright (C) 2003-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTWINFNT_H_
-#define FTWINFNT_H_
-
-#include <freetype/freetype.h>
-
-#ifdef FREETYPE_H
-#error "freetype.h of FreeType 1 has been loaded!"
-#error "Please fix the directory search order for header files"
-#error "so that freetype.h of FreeType 2 is found first."
-#endif
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @section:
- * winfnt_fonts
- *
- * @title:
- * Window FNT Files
- *
- * @abstract:
- * Windows FNT-specific API.
- *
- * @description:
- * This section contains the declaration of Windows FNT-specific
- * functions.
- *
- */
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_WinFNT_ID_XXX
- *
- * @description:
- * A list of valid values for the `charset` byte in @FT_WinFNT_HeaderRec.
- * Exact mapping tables for the various 'cpXXXX' encodings (except for
- * 'cp1361') can be found at 'ftp://ftp.unicode.org/Public/' in the
- * `MAPPINGS/VENDORS/MICSFT/WINDOWS` subdirectory. 'cp1361' is roughly a
- * superset of `MAPPINGS/OBSOLETE/EASTASIA/KSC/JOHAB.TXT`.
- *
- * @values:
- * FT_WinFNT_ID_DEFAULT ::
- * This is used for font enumeration and font creation as a 'don't
- * care' value. Valid font files don't contain this value. When
- * querying for information about the character set of the font that is
- * currently selected into a specified device context, this return
- * value (of the related Windows API) simply denotes failure.
- *
- * FT_WinFNT_ID_SYMBOL ::
- * There is no known mapping table available.
- *
- * FT_WinFNT_ID_MAC ::
- * Mac Roman encoding.
- *
- * FT_WinFNT_ID_OEM ::
- * From Michael Poettgen <michael@poettgen.de>:
- *
- * The 'Windows Font Mapping' article says that `FT_WinFNT_ID_OEM` is
- * used for the charset of vector fonts, like `modern.fon`,
- * `roman.fon`, and `script.fon` on Windows.
- *
- * The 'CreateFont' documentation says: The `FT_WinFNT_ID_OEM` value
- * specifies a character set that is operating-system dependent.
- *
- * The 'IFIMETRICS' documentation from the 'Windows Driver Development
- * Kit' says: This font supports an OEM-specific character set. The
- * OEM character set is system dependent.
- *
- * In general OEM, as opposed to ANSI (i.e., 'cp1252'), denotes the
- * second default codepage that most international versions of Windows
- * have. It is one of the OEM codepages from
- *
- * https://docs.microsoft.com/en-us/windows/desktop/intl/code-page-identifiers
- * ,
- *
- * and is used for the 'DOS boxes', to support legacy applications. A
- * German Windows version for example usually uses ANSI codepage 1252
- * and OEM codepage 850.
- *
- * FT_WinFNT_ID_CP874 ::
- * A superset of Thai TIS 620 and ISO 8859-11.
- *
- * FT_WinFNT_ID_CP932 ::
- * A superset of Japanese Shift-JIS (with minor deviations).
- *
- * FT_WinFNT_ID_CP936 ::
- * A superset of simplified Chinese GB 2312-1980 (with different
- * ordering and minor deviations).
- *
- * FT_WinFNT_ID_CP949 ::
- * A superset of Korean Hangul KS~C 5601-1987 (with different ordering
- * and minor deviations).
- *
- * FT_WinFNT_ID_CP950 ::
- * A superset of traditional Chinese Big~5 ETen (with different
- * ordering and minor deviations).
- *
- * FT_WinFNT_ID_CP1250 ::
- * A superset of East European ISO 8859-2 (with slightly different
- * ordering).
- *
- * FT_WinFNT_ID_CP1251 ::
- * A superset of Russian ISO 8859-5 (with different ordering).
- *
- * FT_WinFNT_ID_CP1252 ::
- * ANSI encoding. A superset of ISO 8859-1.
- *
- * FT_WinFNT_ID_CP1253 ::
- * A superset of Greek ISO 8859-7 (with minor modifications).
- *
- * FT_WinFNT_ID_CP1254 ::
- * A superset of Turkish ISO 8859-9.
- *
- * FT_WinFNT_ID_CP1255 ::
- * A superset of Hebrew ISO 8859-8 (with some modifications).
- *
- * FT_WinFNT_ID_CP1256 ::
- * A superset of Arabic ISO 8859-6 (with different ordering).
- *
- * FT_WinFNT_ID_CP1257 ::
- * A superset of Baltic ISO 8859-13 (with some deviations).
- *
- * FT_WinFNT_ID_CP1258 ::
- * For Vietnamese. This encoding doesn't cover all necessary
- * characters.
- *
- * FT_WinFNT_ID_CP1361 ::
- * Korean (Johab).
- */
-
-#define FT_WinFNT_ID_CP1252 0
-#define FT_WinFNT_ID_DEFAULT 1
-#define FT_WinFNT_ID_SYMBOL 2
-#define FT_WinFNT_ID_MAC 77
-#define FT_WinFNT_ID_CP932 128
-#define FT_WinFNT_ID_CP949 129
-#define FT_WinFNT_ID_CP1361 130
-#define FT_WinFNT_ID_CP936 134
-#define FT_WinFNT_ID_CP950 136
-#define FT_WinFNT_ID_CP1253 161
-#define FT_WinFNT_ID_CP1254 162
-#define FT_WinFNT_ID_CP1258 163
-#define FT_WinFNT_ID_CP1255 177
-#define FT_WinFNT_ID_CP1256 178
-#define FT_WinFNT_ID_CP1257 186
-#define FT_WinFNT_ID_CP1251 204
-#define FT_WinFNT_ID_CP874 222
-#define FT_WinFNT_ID_CP1250 238
-#define FT_WinFNT_ID_OEM 255
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_WinFNT_HeaderRec
- *
- * @description:
- * Windows FNT Header info.
- */
- typedef struct FT_WinFNT_HeaderRec_
- {
- FT_UShort version;
- FT_ULong file_size;
- FT_Byte copyright[60];
- FT_UShort file_type;
- FT_UShort nominal_point_size;
- FT_UShort vertical_resolution;
- FT_UShort horizontal_resolution;
- FT_UShort ascent;
- FT_UShort internal_leading;
- FT_UShort external_leading;
- FT_Byte italic;
- FT_Byte underline;
- FT_Byte strike_out;
- FT_UShort weight;
- FT_Byte charset;
- FT_UShort pixel_width;
- FT_UShort pixel_height;
- FT_Byte pitch_and_family;
- FT_UShort avg_width;
- FT_UShort max_width;
- FT_Byte first_char;
- FT_Byte last_char;
- FT_Byte default_char;
- FT_Byte break_char;
- FT_UShort bytes_per_row;
- FT_ULong device_offset;
- FT_ULong face_name_offset;
- FT_ULong bits_pointer;
- FT_ULong bits_offset;
- FT_Byte reserved;
- FT_ULong flags;
- FT_UShort A_space;
- FT_UShort B_space;
- FT_UShort C_space;
- FT_UShort color_table_offset;
- FT_ULong reserved1[4];
-
- } FT_WinFNT_HeaderRec;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_WinFNT_Header
- *
- * @description:
- * A handle to an @FT_WinFNT_HeaderRec structure.
- */
- typedef struct FT_WinFNT_HeaderRec_* FT_WinFNT_Header;
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_WinFNT_Header
- *
- * @description:
- * Retrieve a Windows FNT font info header.
- *
- * @input:
- * face ::
- * A handle to the input face.
- *
- * @output:
- * aheader ::
- * The WinFNT header.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * This function only works with Windows FNT faces, returning an error
- * otherwise.
- */
- FT_EXPORT( FT_Error )
- FT_Get_WinFNT_Header( FT_Face face,
- FT_WinFNT_HeaderRec *aheader );
-
- /* */
-
-
-FT_END_HEADER
-
-#endif /* FTWINFNT_H_ */
-
-
-/* END */
-
-
-/* Local Variables: */
-/* coding: utf-8 */
-/* End: */
diff --git a/contrib/libs/freetype/include/freetype/internal/autohint.h b/contrib/libs/freetype/include/freetype/internal/autohint.h
deleted file mode 100644
index 8865d53b38..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/autohint.h
+++ /dev/null
@@ -1,234 +0,0 @@
-/****************************************************************************
- *
- * autohint.h
- *
- * High-level 'autohint' module-specific interface (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /**************************************************************************
- *
- * The auto-hinter is used to load and automatically hint glyphs if a
- * format-specific hinter isn't available.
- *
- */
-
-
-#ifndef AUTOHINT_H_
-#define AUTOHINT_H_
-
-
- /**************************************************************************
- *
- * A small technical note regarding automatic hinting in order to clarify
- * this module interface.
- *
- * An automatic hinter might compute two kinds of data for a given face:
- *
- * - global hints: Usually some metrics that describe global properties
- * of the face. It is computed by scanning more or less
- * aggressively the glyphs in the face, and thus can be
- * very slow to compute (even if the size of global hints
- * is really small).
- *
- * - glyph hints: These describe some important features of the glyph
- * outline, as well as how to align them. They are
- * generally much faster to compute than global hints.
- *
- * The current FreeType auto-hinter does a pretty good job while performing
- * fast computations for both global and glyph hints. However, we might be
- * interested in introducing more complex and powerful algorithms in the
- * future, like the one described in the John D. Hobby paper, which
- * unfortunately requires a lot more horsepower.
- *
- * Because a sufficiently sophisticated font management system would
- * typically implement an LRU cache of opened face objects to reduce memory
- * usage, it is a good idea to be able to avoid recomputing global hints
- * every time the same face is re-opened.
- *
- * We thus provide the ability to cache global hints outside of the face
- * object, in order to speed up font re-opening time. Of course, this
- * feature is purely optional, so most client programs won't even notice
- * it.
- *
- * I initially thought that it would be a good idea to cache the glyph
- * hints too. However, my general idea now is that if you really need to
- * cache these too, you are simply in need of a new font format, where all
- * this information could be stored within the font file and decoded on the
- * fly.
- *
- */
-
-
-#include <freetype/freetype.h>
-
-
-FT_BEGIN_HEADER
-
-
- typedef struct FT_AutoHinterRec_ *FT_AutoHinter;
-
-
- /**************************************************************************
- *
- * @functype:
- * FT_AutoHinter_GlobalGetFunc
- *
- * @description:
- * Retrieve the global hints computed for a given face object. The
- * resulting data is dissociated from the face and will survive a call to
- * FT_Done_Face(). It must be discarded through the API
- * FT_AutoHinter_GlobalDoneFunc().
- *
- * @input:
- * hinter ::
- * A handle to the source auto-hinter.
- *
- * face ::
- * A handle to the source face object.
- *
- * @output:
- * global_hints ::
- * A typeless pointer to the global hints.
- *
- * global_len ::
- * The size in bytes of the global hints.
- */
- typedef void
- (*FT_AutoHinter_GlobalGetFunc)( FT_AutoHinter hinter,
- FT_Face face,
- void** global_hints,
- long* global_len );
-
-
- /**************************************************************************
- *
- * @functype:
- * FT_AutoHinter_GlobalDoneFunc
- *
- * @description:
- * Discard the global hints retrieved through
- * FT_AutoHinter_GlobalGetFunc(). This is the only way these hints are
- * freed from memory.
- *
- * @input:
- * hinter ::
- * A handle to the auto-hinter module.
- *
- * global ::
- * A pointer to retrieved global hints to discard.
- */
- typedef void
- (*FT_AutoHinter_GlobalDoneFunc)( FT_AutoHinter hinter,
- void* global );
-
-
- /**************************************************************************
- *
- * @functype:
- * FT_AutoHinter_GlobalResetFunc
- *
- * @description:
- * This function is used to recompute the global metrics in a given font.
- * This is useful when global font data changes (e.g. Multiple Masters
- * fonts where blend coordinates change).
- *
- * @input:
- * hinter ::
- * A handle to the source auto-hinter.
- *
- * face ::
- * A handle to the face.
- */
- typedef void
- (*FT_AutoHinter_GlobalResetFunc)( FT_AutoHinter hinter,
- FT_Face face );
-
-
- /**************************************************************************
- *
- * @functype:
- * FT_AutoHinter_GlyphLoadFunc
- *
- * @description:
- * This function is used to load, scale, and automatically hint a glyph
- * from a given face.
- *
- * @input:
- * face ::
- * A handle to the face.
- *
- * glyph_index ::
- * The glyph index.
- *
- * load_flags ::
- * The load flags.
- *
- * @note:
- * This function is capable of loading composite glyphs by hinting each
- * sub-glyph independently (which improves quality).
- *
- * It will call the font driver with @FT_Load_Glyph, with
- * @FT_LOAD_NO_SCALE set.
- */
- typedef FT_Error
- (*FT_AutoHinter_GlyphLoadFunc)( FT_AutoHinter hinter,
- FT_GlyphSlot slot,
- FT_Size size,
- FT_UInt glyph_index,
- FT_Int32 load_flags );
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_AutoHinter_InterfaceRec
- *
- * @description:
- * The auto-hinter module's interface.
- */
- typedef struct FT_AutoHinter_InterfaceRec_
- {
- FT_AutoHinter_GlobalResetFunc reset_face;
- FT_AutoHinter_GlobalGetFunc get_global_hints;
- FT_AutoHinter_GlobalDoneFunc done_global_hints;
- FT_AutoHinter_GlyphLoadFunc load_glyph;
-
- } FT_AutoHinter_InterfaceRec, *FT_AutoHinter_Interface;
-
-
-#define FT_DECLARE_AUTOHINTER_INTERFACE( class_ ) \
- FT_CALLBACK_TABLE const FT_AutoHinter_InterfaceRec class_;
-
-#define FT_DEFINE_AUTOHINTER_INTERFACE( \
- class_, \
- reset_face_, \
- get_global_hints_, \
- done_global_hints_, \
- load_glyph_ ) \
- FT_CALLBACK_TABLE_DEF \
- const FT_AutoHinter_InterfaceRec class_ = \
- { \
- reset_face_, \
- get_global_hints_, \
- done_global_hints_, \
- load_glyph_ \
- };
-
-
-FT_END_HEADER
-
-#endif /* AUTOHINT_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/cffotypes.h b/contrib/libs/freetype/include/freetype/internal/cffotypes.h
deleted file mode 100644
index 36b0390a5a..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/cffotypes.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/****************************************************************************
- *
- * cffotypes.h
- *
- * Basic OpenType/CFF object type definitions (specification).
- *
- * Copyright (C) 2017-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef CFFOTYPES_H_
-#define CFFOTYPES_H_
-
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/cfftypes.h>
-#include <freetype/internal/tttypes.h>
-#include <freetype/internal/services/svpscmap.h>
-#include <freetype/internal/pshints.h>
-
-
-FT_BEGIN_HEADER
-
-
- typedef TT_Face CFF_Face;
-
-
- /**************************************************************************
- *
- * @type:
- * CFF_Size
- *
- * @description:
- * A handle to an OpenType size object.
- */
- typedef struct CFF_SizeRec_
- {
- FT_SizeRec root;
- FT_ULong strike_index; /* 0xFFFFFFFF to indicate invalid */
-
- } CFF_SizeRec, *CFF_Size;
-
-
- /**************************************************************************
- *
- * @type:
- * CFF_GlyphSlot
- *
- * @description:
- * A handle to an OpenType glyph slot object.
- */
- typedef struct CFF_GlyphSlotRec_
- {
- FT_GlyphSlotRec root;
-
- FT_Bool hint;
- FT_Bool scaled;
-
- FT_Fixed x_scale;
- FT_Fixed y_scale;
-
- } CFF_GlyphSlotRec, *CFF_GlyphSlot;
-
-
- /**************************************************************************
- *
- * @type:
- * CFF_Internal
- *
- * @description:
- * The interface to the 'internal' field of `FT_Size`.
- */
- typedef struct CFF_InternalRec_
- {
- PSH_Globals topfont;
- PSH_Globals subfonts[CFF_MAX_CID_FONTS];
-
- } CFF_InternalRec, *CFF_Internal;
-
-
- /**************************************************************************
- *
- * Subglyph transformation record.
- */
- typedef struct CFF_Transform_
- {
- FT_Fixed xx, xy; /* transformation matrix coefficients */
- FT_Fixed yx, yy;
- FT_F26Dot6 ox, oy; /* offsets */
-
- } CFF_Transform;
-
-
-FT_END_HEADER
-
-
-#endif /* CFFOTYPES_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/cfftypes.h b/contrib/libs/freetype/include/freetype/internal/cfftypes.h
deleted file mode 100644
index ef2e8e7569..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/cfftypes.h
+++ /dev/null
@@ -1,416 +0,0 @@
-/****************************************************************************
- *
- * cfftypes.h
- *
- * Basic OpenType/CFF type definitions and interface (specification
- * only).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef CFFTYPES_H_
-#define CFFTYPES_H_
-
-
-#include <freetype/freetype.h>
-#include <freetype/t1tables.h>
-#include <freetype/internal/ftserv.h>
-#include <freetype/internal/services/svpscmap.h>
-#include <freetype/internal/pshints.h>
-#include <freetype/internal/t1types.h>
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @struct:
- * CFF_IndexRec
- *
- * @description:
- * A structure used to model a CFF Index table.
- *
- * @fields:
- * stream ::
- * The source input stream.
- *
- * start ::
- * The position of the first index byte in the input stream.
- *
- * count ::
- * The number of elements in the index.
- *
- * off_size ::
- * The size in bytes of object offsets in index.
- *
- * data_offset ::
- * The position of first data byte in the index's bytes.
- *
- * data_size ::
- * The size of the data table in this index.
- *
- * offsets ::
- * A table of element offsets in the index. Must be loaded explicitly.
- *
- * bytes ::
- * If the index is loaded in memory, its bytes.
- */
- typedef struct CFF_IndexRec_
- {
- FT_Stream stream;
- FT_ULong start;
- FT_UInt hdr_size;
- FT_UInt count;
- FT_Byte off_size;
- FT_ULong data_offset;
- FT_ULong data_size;
-
- FT_ULong* offsets;
- FT_Byte* bytes;
-
- } CFF_IndexRec, *CFF_Index;
-
-
- typedef struct CFF_EncodingRec_
- {
- FT_UInt format;
- FT_ULong offset;
-
- FT_UInt count;
- FT_UShort sids [256]; /* avoid dynamic allocations */
- FT_UShort codes[256];
-
- } CFF_EncodingRec, *CFF_Encoding;
-
-
- typedef struct CFF_CharsetRec_
- {
-
- FT_UInt format;
- FT_ULong offset;
-
- FT_UShort* sids;
- FT_UShort* cids; /* the inverse mapping of `sids'; only needed */
- /* for CID-keyed fonts */
- FT_UInt max_cid;
- FT_UInt num_glyphs;
-
- } CFF_CharsetRec, *CFF_Charset;
-
-
- /* cf. similar fields in file `ttgxvar.h' from the `truetype' module */
-
- typedef struct CFF_VarData_
- {
-#if 0
- FT_UInt itemCount; /* not used; always zero */
- FT_UInt shortDeltaCount; /* not used; always zero */
-#endif
-
- FT_UInt regionIdxCount; /* number of region indexes */
- FT_UInt* regionIndices; /* array of `regionIdxCount' indices; */
- /* these index `varRegionList' */
- } CFF_VarData;
-
-
- /* contribution of one axis to a region */
- typedef struct CFF_AxisCoords_
- {
- FT_Fixed startCoord;
- FT_Fixed peakCoord; /* zero peak means no effect (factor = 1) */
- FT_Fixed endCoord;
-
- } CFF_AxisCoords;
-
-
- typedef struct CFF_VarRegion_
- {
- CFF_AxisCoords* axisList; /* array of axisCount records */
-
- } CFF_VarRegion;
-
-
- typedef struct CFF_VStoreRec_
- {
- FT_UInt dataCount;
- CFF_VarData* varData; /* array of dataCount records */
- /* vsindex indexes this array */
- FT_UShort axisCount;
- FT_UInt regionCount; /* total number of regions defined */
- CFF_VarRegion* varRegionList;
-
- } CFF_VStoreRec, *CFF_VStore;
-
-
- /* forward reference */
- typedef struct CFF_FontRec_* CFF_Font;
-
-
- /* This object manages one cached blend vector. */
- /* */
- /* There is a BlendRec for Private DICT parsing in each subfont */
- /* and a BlendRec for charstrings in CF2_Font instance data. */
- /* A cached BV may be used across DICTs or Charstrings if inputs */
- /* have not changed. */
- /* */
- /* `usedBV' is reset at the start of each parse or charstring. */
- /* vsindex cannot be changed after a BV is used. */
- /* */
- /* Note: NDV is long (32/64 bit), while BV is 16.16 (FT_Int32). */
- typedef struct CFF_BlendRec_
- {
- FT_Bool builtBV; /* blendV has been built */
- FT_Bool usedBV; /* blendV has been used */
- CFF_Font font; /* top level font struct */
- FT_UInt lastVsindex; /* last vsindex used */
- FT_UInt lenNDV; /* normDV length (aka numAxes) */
- FT_Fixed* lastNDV; /* last NDV used */
- FT_UInt lenBV; /* BlendV length (aka numMasters) */
- FT_Int32* BV; /* current blendV (per DICT/glyph) */
-
- } CFF_BlendRec, *CFF_Blend;
-
-
- typedef struct CFF_FontRecDictRec_
- {
- FT_UInt version;
- FT_UInt notice;
- FT_UInt copyright;
- FT_UInt full_name;
- FT_UInt family_name;
- FT_UInt weight;
- FT_Bool is_fixed_pitch;
- FT_Fixed italic_angle;
- FT_Fixed underline_position;
- FT_Fixed underline_thickness;
- FT_Int paint_type;
- FT_Int charstring_type;
- FT_Matrix font_matrix;
- FT_Bool has_font_matrix;
- FT_ULong units_per_em; /* temporarily used as scaling value also */
- FT_Vector font_offset;
- FT_ULong unique_id;
- FT_BBox font_bbox;
- FT_Pos stroke_width;
- FT_ULong charset_offset;
- FT_ULong encoding_offset;
- FT_ULong charstrings_offset;
- FT_ULong private_offset;
- FT_ULong private_size;
- FT_Long synthetic_base;
- FT_UInt embedded_postscript;
-
- /* these should only be used for the top-level font dictionary */
- FT_UInt cid_registry;
- FT_UInt cid_ordering;
- FT_Long cid_supplement;
-
- FT_Long cid_font_version;
- FT_Long cid_font_revision;
- FT_Long cid_font_type;
- FT_ULong cid_count;
- FT_ULong cid_uid_base;
- FT_ULong cid_fd_array_offset;
- FT_ULong cid_fd_select_offset;
- FT_UInt cid_font_name;
-
- /* the next fields come from the data of the deprecated */
- /* `MultipleMaster' operator; they are needed to parse the (also */
- /* deprecated) `blend' operator in Type 2 charstrings */
- FT_UShort num_designs;
- FT_UShort num_axes;
-
- /* fields for CFF2 */
- FT_ULong vstore_offset;
- FT_UInt maxstack;
-
- } CFF_FontRecDictRec, *CFF_FontRecDict;
-
-
- /* forward reference */
- typedef struct CFF_SubFontRec_* CFF_SubFont;
-
-
- typedef struct CFF_PrivateRec_
- {
- FT_Byte num_blue_values;
- FT_Byte num_other_blues;
- FT_Byte num_family_blues;
- FT_Byte num_family_other_blues;
-
- FT_Fixed blue_values[14];
- FT_Fixed other_blues[10];
- FT_Fixed family_blues[14];
- FT_Fixed family_other_blues[10];
-
- FT_Fixed blue_scale;
- FT_Pos blue_shift;
- FT_Pos blue_fuzz;
- FT_Pos standard_width;
- FT_Pos standard_height;
-
- FT_Byte num_snap_widths;
- FT_Byte num_snap_heights;
- FT_Pos snap_widths[13];
- FT_Pos snap_heights[13];
- FT_Bool force_bold;
- FT_Fixed force_bold_threshold;
- FT_Int lenIV;
- FT_Int language_group;
- FT_Fixed expansion_factor;
- FT_Long initial_random_seed;
- FT_ULong local_subrs_offset;
- FT_Pos default_width;
- FT_Pos nominal_width;
-
- /* fields for CFF2 */
- FT_UInt vsindex;
- CFF_SubFont subfont;
-
- } CFF_PrivateRec, *CFF_Private;
-
-
- typedef struct CFF_FDSelectRec_
- {
- FT_Byte format;
- FT_UInt range_count;
-
- /* that's the table, taken from the file `as is' */
- FT_Byte* data;
- FT_UInt data_size;
-
- /* small cache for format 3 only */
- FT_UInt cache_first;
- FT_UInt cache_count;
- FT_Byte cache_fd;
-
- } CFF_FDSelectRec, *CFF_FDSelect;
-
-
- /* A SubFont packs a font dict and a private dict together. They are */
- /* needed to support CID-keyed CFF fonts. */
- typedef struct CFF_SubFontRec_
- {
- CFF_FontRecDictRec font_dict;
- CFF_PrivateRec private_dict;
-
- /* fields for CFF2 */
- CFF_BlendRec blend; /* current blend vector */
- FT_UInt lenNDV; /* current length NDV or zero */
- FT_Fixed* NDV; /* ptr to current NDV or NULL */
-
- /* `blend_stack' is a writable buffer to hold blend results. */
- /* This buffer is to the side of the normal cff parser stack; */
- /* `cff_parse_blend' and `cff_blend_doBlend' push blend results here. */
- /* The normal stack then points to these values instead of the DICT */
- /* because all other operators in Private DICT clear the stack. */
- /* `blend_stack' could be cleared at each operator other than blend. */
- /* Blended values are stored as 5-byte fixed-point values. */
-
- FT_Byte* blend_stack; /* base of stack allocation */
- FT_Byte* blend_top; /* first empty slot */
- FT_UInt blend_used; /* number of bytes in use */
- FT_UInt blend_alloc; /* number of bytes allocated */
-
- CFF_IndexRec local_subrs_index;
- FT_Byte** local_subrs; /* array of pointers */
- /* into Local Subrs INDEX data */
-
- FT_UInt32 random;
-
- } CFF_SubFontRec;
-
-
-#define CFF_MAX_CID_FONTS 256
-
-
- typedef struct CFF_FontRec_
- {
- FT_Library library;
- FT_Stream stream;
- FT_Memory memory; /* TODO: take this from stream->memory? */
- FT_ULong base_offset; /* offset to start of CFF */
- FT_UInt num_faces;
- FT_UInt num_glyphs;
-
- FT_Byte version_major;
- FT_Byte version_minor;
- FT_Byte header_size;
-
- FT_UInt top_dict_length; /* cff2 only */
-
- FT_Bool cff2;
-
- CFF_IndexRec name_index;
- CFF_IndexRec top_dict_index;
- CFF_IndexRec global_subrs_index;
-
- CFF_EncodingRec encoding;
- CFF_CharsetRec charset;
-
- CFF_IndexRec charstrings_index;
- CFF_IndexRec font_dict_index;
- CFF_IndexRec private_index;
- CFF_IndexRec local_subrs_index;
-
- FT_String* font_name;
-
- /* array of pointers into Global Subrs INDEX data */
- FT_Byte** global_subrs;
-
- /* array of pointers into String INDEX data stored at string_pool */
- FT_UInt num_strings;
- FT_Byte** strings;
- FT_Byte* string_pool;
- FT_ULong string_pool_size;
-
- CFF_SubFontRec top_font;
- FT_UInt num_subfonts;
- CFF_SubFont subfonts[CFF_MAX_CID_FONTS];
-
- CFF_FDSelectRec fd_select;
-
- /* interface to PostScript hinter */
- PSHinter_Service pshinter;
-
- /* interface to Postscript Names service */
- FT_Service_PsCMaps psnames;
-
- /* interface to CFFLoad service */
- const void* cffload;
-
- /* since version 2.3.0 */
- PS_FontInfoRec* font_info; /* font info dictionary */
-
- /* since version 2.3.6 */
- FT_String* registry;
- FT_String* ordering;
-
- /* since version 2.4.12 */
- FT_Generic cf2_instance;
-
- /* since version 2.7.1 */
- CFF_VStoreRec vstore; /* parsed vstore structure */
-
- /* since version 2.9 */
- PS_FontExtraRec* font_extra;
-
- } CFF_FontRec;
-
-
-FT_END_HEADER
-
-#endif /* CFFTYPES_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/compiler-macros.h b/contrib/libs/freetype/include/freetype/internal/compiler-macros.h
deleted file mode 100644
index 876f66e256..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/compiler-macros.h
+++ /dev/null
@@ -1,343 +0,0 @@
-/****************************************************************************
- *
- * internal/compiler-macros.h
- *
- * Compiler-specific macro definitions used internally by FreeType.
- *
- * Copyright (C) 2020-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-#ifndef INTERNAL_COMPILER_MACROS_H_
-#define INTERNAL_COMPILER_MACROS_H_
-
-#include <freetype/config/public-macros.h>
-
-FT_BEGIN_HEADER
-
- /* Fix compiler warning with sgi compiler. */
-#if defined( __sgi ) && !defined( __GNUC__ )
-# if defined( _COMPILER_VERSION ) && ( _COMPILER_VERSION >= 730 )
-# pragma set woff 3505
-# endif
-#endif
-
- /* Fix compiler warning with sgi compiler. */
-#if defined( __sgi ) && !defined( __GNUC__ )
-# if defined( _COMPILER_VERSION ) && ( _COMPILER_VERSION >= 730 )
-# pragma set woff 3505
-# endif
-#endif
-
- /* Newer compilers warn for fall-through case statements. */
-#ifndef FALL_THROUGH
-# if ( defined( __STDC_VERSION__ ) && __STDC_VERSION__ > 201710L ) || \
- ( defined( __cplusplus ) && __cplusplus > 201402L )
-# define FALL_THROUGH [[__fallthrough__]]
-# elif ( defined( __GNUC__ ) && __GNUC__ >= 7 ) || \
- ( defined( __clang__ ) && \
- ( defined( __apple_build_version__ ) \
- ? __apple_build_version__ >= 12000000 \
- : __clang_major__ >= 10 ) )
-# define FALL_THROUGH __attribute__(( __fallthrough__ ))
-# else
-# define FALL_THROUGH ( (void)0 )
-# endif
-#endif
-
- /*
- * When defining a macro that expands to a non-trivial C statement, use
- * FT_BEGIN_STMNT and FT_END_STMNT to enclose the macro's body. This
- * ensures there are no surprises when the macro is invoked in conditional
- * branches.
- *
- * Example:
- *
- * #define LOG( ... ) \
- * FT_BEGIN_STMNT \
- * if ( logging_enabled ) \
- * log( __VA_ARGS__ ); \
- * FT_END_STMNT
- */
-#define FT_BEGIN_STMNT do {
-#define FT_END_STMNT } while ( 0 )
-
- /*
- * FT_DUMMY_STMNT expands to an empty C statement. Useful for
- * conditionally defined statement macros.
- *
- * Example:
- *
- * #ifdef BUILD_CONFIG_LOGGING
- * #define LOG( ... ) \
- * FT_BEGIN_STMNT \
- * if ( logging_enabled ) \
- * log( __VA_ARGS__ ); \
- * FT_END_STMNT
- * #else
- * # define LOG( ... ) FT_DUMMY_STMNT
- * #endif
- */
-#define FT_DUMMY_STMNT FT_BEGIN_STMNT FT_END_STMNT
-
-#ifdef __UINTPTR_TYPE__
- /*
- * GCC and Clang both provide a `__UINTPTR_TYPE__` that can be used to
- * avoid a dependency on `stdint.h`.
- */
-# define FT_UINT_TO_POINTER( x ) (void *)(__UINTPTR_TYPE__)(x)
-#elif defined( _WIN64 )
- /* only 64bit Windows uses the LLP64 data model, i.e., */
- /* 32-bit integers, 64-bit pointers. */
-# define FT_UINT_TO_POINTER( x ) (void *)(unsigned __int64)(x)
-#else
-# define FT_UINT_TO_POINTER( x ) (void *)(unsigned long)(x)
-#endif
-
- /*
- * Use `FT_TYPEOF( type )` to cast a value to `type`. This is useful to
- * suppress signedness compilation warnings in macros.
- *
- * Example:
- *
- * #define PAD_( x, n ) ( (x) & ~FT_TYPEOF( x )( (n) - 1 ) )
- *
- * (The `typeof` condition is taken from gnulib's `intprops.h` header
- * file.)
- */
-#if ( ( defined( __GNUC__ ) && __GNUC__ >= 2 ) || \
- ( defined( __IBMC__ ) && __IBMC__ >= 1210 && \
- defined( __IBM__TYPEOF__ ) ) || \
- ( defined( __SUNPRO_C ) && __SUNPRO_C >= 0x5110 && !__STDC__ ) )
-#define FT_TYPEOF( type ) ( __typeof__ ( type ) )
-#else
-#define FT_TYPEOF( type ) /* empty */
-#endif
-
- /*
- * Mark a function declaration as internal to the library. This ensures
- * that it will not be exposed by default to client code, and helps
- * generate smaller and faster code on ELF-based platforms. Place this
- * before a function declaration.
- */
-
- /* Visual C, mingw */
-#if defined( _WIN32 )
-#define FT_INTERNAL_FUNCTION_ATTRIBUTE /* empty */
-
- /* gcc, clang */
-#elif ( defined( __GNUC__ ) && __GNUC__ >= 4 ) || defined( __clang__ )
-#define FT_INTERNAL_FUNCTION_ATTRIBUTE \
- __attribute__(( visibility( "hidden" ) ))
-
- /* Sun */
-#elif defined( __SUNPRO_C ) && __SUNPRO_C >= 0x550
-#define FT_INTERNAL_FUNCTION_ATTRIBUTE __hidden
-
-#else
-#define FT_INTERNAL_FUNCTION_ATTRIBUTE /* empty */
-#endif
-
- /*
- * FreeType supports compilation of its C sources with a C++ compiler (in
- * C++ mode); this introduces a number of subtle issues.
- *
- * The main one is that a C++ function declaration and its definition must
- * have the same 'linkage'. Because all FreeType headers declare their
- * functions with C linkage (i.e., within an `extern "C" { ... }` block
- * due to the magic of FT_BEGIN_HEADER and FT_END_HEADER), their
- * definition in FreeType sources should also be prefixed with `extern
- * "C"` when compiled in C++ mode.
- *
- * The `FT_FUNCTION_DECLARATION` and `FT_FUNCTION_DEFINITION` macros are
- * provided to deal with this case, as well as `FT_CALLBACK_DEF` and its
- * siblings below.
- */
-
- /*
- * `FT_FUNCTION_DECLARATION( type )` can be used to write a C function
- * declaration to ensure it will have C linkage when the library is built
- * with a C++ compiler. The parameter is the function's return type, so a
- * declaration would look like
- *
- * FT_FUNCTION_DECLARATION( int )
- * foo( int x );
- *
- * NOTE: This requires that all uses are inside of `FT_BEGIN_HEADER ...
- * FT_END_HEADER` blocks, which guarantees that the declarations have C
- * linkage when the headers are included by C++ sources.
- *
- * NOTE: Do not use directly. Use `FT_LOCAL`, `FT_BASE`, and `FT_EXPORT`
- * instead.
- */
-#define FT_FUNCTION_DECLARATION( x ) extern x
-
- /*
- * Same as `FT_FUNCTION_DECLARATION`, but for function definitions instead.
- *
- * NOTE: Do not use directly. Use `FT_LOCAL_DEF`, `FT_BASE_DEF`, and
- * `FT_EXPORT_DEF` instead.
- */
-#ifdef __cplusplus
-#define FT_FUNCTION_DEFINITION( x ) extern "C" x
-#else
-#define FT_FUNCTION_DEFINITION( x ) x
-#endif
-
- /*
- * Use `FT_LOCAL` and `FT_LOCAL_DEF` to declare and define, respectively,
- * an internal FreeType function that is only used by the sources of a
- * single `src/module/` directory. This ensures that the functions are
- * turned into static ones at build time, resulting in smaller and faster
- * code.
- */
-#ifdef FT_MAKE_OPTION_SINGLE_OBJECT
-
-#define FT_LOCAL( x ) static x
-#define FT_LOCAL_DEF( x ) static x
-
-#else
-
-#define FT_LOCAL( x ) FT_INTERNAL_FUNCTION_ATTRIBUTE \
- FT_FUNCTION_DECLARATION( x )
-#define FT_LOCAL_DEF( x ) FT_FUNCTION_DEFINITION( x )
-
-#endif /* FT_MAKE_OPTION_SINGLE_OBJECT */
-
- /*
- * Use `FT_LOCAL_ARRAY` and `FT_LOCAL_ARRAY_DEF` to declare and define,
- * respectively, a constant array that must be accessed from several
- * sources in the same `src/module/` sub-directory, and which are internal
- * to the library.
- */
-#define FT_LOCAL_ARRAY( x ) FT_INTERNAL_FUNCTION_ATTRIBUTE \
- extern const x
-#define FT_LOCAL_ARRAY_DEF( x ) FT_FUNCTION_DEFINITION( const x )
-
- /*
- * `Use FT_BASE` and `FT_BASE_DEF` to declare and define, respectively, an
- * internal library function that is used by more than a single module.
- */
-#define FT_BASE( x ) FT_INTERNAL_FUNCTION_ATTRIBUTE \
- FT_FUNCTION_DECLARATION( x )
-#define FT_BASE_DEF( x ) FT_FUNCTION_DEFINITION( x )
-
-
- /*
- * NOTE: Conditionally define `FT_EXPORT_VAR` due to its definition in
- * `src/smooth/ftgrays.h` to make the header more portable.
- */
-#ifndef FT_EXPORT_VAR
-#define FT_EXPORT_VAR( x ) FT_FUNCTION_DECLARATION( x )
-#endif
-
- /*
- * When compiling FreeType as a DLL or DSO with hidden visibility,
- * some systems/compilers need a special attribute in front OR after
- * the return type of function declarations.
- *
- * Two macros are used within the FreeType source code to define
- * exported library functions: `FT_EXPORT` and `FT_EXPORT_DEF`.
- *
- * - `FT_EXPORT( return_type )`
- *
- * is used in a function declaration, as in
- *
- * ```
- * FT_EXPORT( FT_Error )
- * FT_Init_FreeType( FT_Library* alibrary );
- * ```
- *
- * - `FT_EXPORT_DEF( return_type )`
- *
- * is used in a function definition, as in
- *
- * ```
- * FT_EXPORT_DEF( FT_Error )
- * FT_Init_FreeType( FT_Library* alibrary )
- * {
- * ... some code ...
- * return FT_Err_Ok;
- * }
- * ```
- *
- * You can provide your own implementation of `FT_EXPORT` and
- * `FT_EXPORT_DEF` here if you want.
- *
- * To export a variable, use `FT_EXPORT_VAR`.
- */
-
- /* See `freetype/config/public-macros.h` for the `FT_EXPORT` definition */
-#define FT_EXPORT_DEF( x ) FT_FUNCTION_DEFINITION( x )
-
- /*
- * The following macros are needed to compile the library with a
- * C++ compiler and with 16bit compilers.
- */
-
- /*
- * This is special. Within C++, you must specify `extern "C"` for
- * functions which are used via function pointers, and you also
- * must do that for structures which contain function pointers to
- * assure C linkage -- it's not possible to have (local) anonymous
- * functions which are accessed by (global) function pointers.
- *
- *
- * FT_CALLBACK_DEF is used to _define_ a callback function,
- * located in the same source code file as the structure that uses
- * it. FT_COMPARE_DEF, in addition, ensures the `cdecl` calling
- * convention on x86, required by the C library function `qsort`.
- *
- * FT_BASE_CALLBACK and FT_BASE_CALLBACK_DEF are used to declare
- * and define a callback function, respectively, in a similar way
- * as FT_BASE and FT_BASE_DEF work.
- *
- * FT_CALLBACK_TABLE is used to _declare_ a constant variable that
- * contains pointers to callback functions.
- *
- * FT_CALLBACK_TABLE_DEF is used to _define_ a constant variable
- * that contains pointers to callback functions.
- *
- *
- * Some 16bit compilers have to redefine these macros to insert
- * the infamous `_cdecl` or `__fastcall` declarations.
- */
-#ifdef __cplusplus
-#define FT_CALLBACK_DEF( x ) extern "C" x
-#else
-#define FT_CALLBACK_DEF( x ) static x
-#endif
-
-#if defined( __GNUC__ ) && defined( __i386__ )
-#define FT_COMPARE_DEF( x ) FT_CALLBACK_DEF( x ) __attribute__(( cdecl ))
-#elif defined( _MSC_VER ) && defined( _M_IX86 )
-#define FT_COMPARE_DEF( x ) FT_CALLBACK_DEF( x ) __cdecl
-#elif defined( __WATCOMC__ ) && __WATCOMC__ >= 1240
-#define FT_COMPARE_DEF( x ) FT_CALLBACK_DEF( x ) __watcall
-#else
-#define FT_COMPARE_DEF( x ) FT_CALLBACK_DEF( x )
-#endif
-
-#define FT_BASE_CALLBACK( x ) FT_FUNCTION_DECLARATION( x )
-#define FT_BASE_CALLBACK_DEF( x ) FT_FUNCTION_DEFINITION( x )
-
-#ifndef FT_CALLBACK_TABLE
-#ifdef __cplusplus
-#define FT_CALLBACK_TABLE extern "C"
-#define FT_CALLBACK_TABLE_DEF extern "C"
-#else
-#define FT_CALLBACK_TABLE extern
-#define FT_CALLBACK_TABLE_DEF /* nothing */
-#endif
-#endif /* FT_CALLBACK_TABLE */
-
-FT_END_HEADER
-
-#endif /* INTERNAL_COMPILER_MACROS_H_ */
diff --git a/contrib/libs/freetype/include/freetype/internal/ftcalc.h b/contrib/libs/freetype/include/freetype/internal/ftcalc.h
deleted file mode 100644
index 71128a2df9..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/ftcalc.h
+++ /dev/null
@@ -1,584 +0,0 @@
-/****************************************************************************
- *
- * ftcalc.h
- *
- * Arithmetic computations (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTCALC_H_
-#define FTCALC_H_
-
-
-#include <freetype/freetype.h>
-
-#include "compiler-macros.h"
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * FT_MulDiv() and FT_MulFix() are declared in freetype.h.
- *
- */
-
-#ifndef FT_CONFIG_OPTION_NO_ASSEMBLER
- /* Provide assembler fragments for performance-critical functions. */
- /* These must be defined `static __inline__' with GCC. */
-
-#if defined( __CC_ARM ) || defined( __ARMCC__ ) /* RVCT */
-
-#define FT_MULFIX_ASSEMBLER FT_MulFix_arm
-
- /* documentation is in freetype.h */
-
- static __inline FT_Int32
- FT_MulFix_arm( FT_Int32 a,
- FT_Int32 b )
- {
- FT_Int32 t, t2;
-
-
- __asm
- {
- smull t2, t, b, a /* (lo=t2,hi=t) = a*b */
- mov a, t, asr #31 /* a = (hi >> 31) */
- add a, a, #0x8000 /* a += 0x8000 */
- adds t2, t2, a /* t2 += a */
- adc t, t, #0 /* t += carry */
- mov a, t2, lsr #16 /* a = t2 >> 16 */
- orr a, a, t, lsl #16 /* a |= t << 16 */
- }
- return a;
- }
-
-#endif /* __CC_ARM || __ARMCC__ */
-
-
-#ifdef __GNUC__
-
-#if defined( __arm__ ) && \
- ( !defined( __thumb__ ) || defined( __thumb2__ ) ) && \
- !( defined( __CC_ARM ) || defined( __ARMCC__ ) )
-
-#define FT_MULFIX_ASSEMBLER FT_MulFix_arm
-
- /* documentation is in freetype.h */
-
- static __inline__ FT_Int32
- FT_MulFix_arm( FT_Int32 a,
- FT_Int32 b )
- {
- FT_Int32 t, t2;
-
-
- __asm__ __volatile__ (
- "smull %1, %2, %4, %3\n\t" /* (lo=%1,hi=%2) = a*b */
- "mov %0, %2, asr #31\n\t" /* %0 = (hi >> 31) */
-#if defined( __clang__ ) && defined( __thumb2__ )
- "add.w %0, %0, #0x8000\n\t" /* %0 += 0x8000 */
-#else
- "add %0, %0, #0x8000\n\t" /* %0 += 0x8000 */
-#endif
- "adds %1, %1, %0\n\t" /* %1 += %0 */
- "adc %2, %2, #0\n\t" /* %2 += carry */
- "mov %0, %1, lsr #16\n\t" /* %0 = %1 >> 16 */
- "orr %0, %0, %2, lsl #16\n\t" /* %0 |= %2 << 16 */
- : "=r"(a), "=&r"(t2), "=&r"(t)
- : "r"(a), "r"(b)
- : "cc" );
- return a;
- }
-
-#endif /* __arm__ && */
- /* ( __thumb2__ || !__thumb__ ) && */
- /* !( __CC_ARM || __ARMCC__ ) */
-
-
-#if defined( __i386__ )
-
-#define FT_MULFIX_ASSEMBLER FT_MulFix_i386
-
- /* documentation is in freetype.h */
-
- static __inline__ FT_Int32
- FT_MulFix_i386( FT_Int32 a,
- FT_Int32 b )
- {
- FT_Int32 result;
-
-
- __asm__ __volatile__ (
- "imul %%edx\n"
- "movl %%edx, %%ecx\n"
- "sarl $31, %%ecx\n"
- "addl $0x8000, %%ecx\n"
- "addl %%ecx, %%eax\n"
- "adcl $0, %%edx\n"
- "shrl $16, %%eax\n"
- "shll $16, %%edx\n"
- "addl %%edx, %%eax\n"
- : "=a"(result), "=d"(b)
- : "a"(a), "d"(b)
- : "%ecx", "cc" );
- return result;
- }
-
-#endif /* i386 */
-
-#endif /* __GNUC__ */
-
-
-#ifdef _MSC_VER /* Visual C++ */
-
-#ifdef _M_IX86
-
-#define FT_MULFIX_ASSEMBLER FT_MulFix_i386
-
- /* documentation is in freetype.h */
-
- static __inline FT_Int32
- FT_MulFix_i386( FT_Int32 a,
- FT_Int32 b )
- {
- FT_Int32 result;
-
- __asm
- {
- mov eax, a
- mov edx, b
- imul edx
- mov ecx, edx
- sar ecx, 31
- add ecx, 8000h
- add eax, ecx
- adc edx, 0
- shr eax, 16
- shl edx, 16
- add eax, edx
- mov result, eax
- }
- return result;
- }
-
-#endif /* _M_IX86 */
-
-#endif /* _MSC_VER */
-
-
-#if defined( __GNUC__ ) && defined( __x86_64__ )
-
-#define FT_MULFIX_ASSEMBLER FT_MulFix_x86_64
-
- static __inline__ FT_Int32
- FT_MulFix_x86_64( FT_Int32 a,
- FT_Int32 b )
- {
- /* Temporarily disable the warning that C90 doesn't support */
- /* `long long'. */
-#if __GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 6 )
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wlong-long"
-#endif
-
-#if 1
- /* Technically not an assembly fragment, but GCC does a really good */
- /* job at inlining it and generating good machine code for it. */
- long long ret, tmp;
-
-
- ret = (long long)a * b;
- tmp = ret >> 63;
- ret += 0x8000 + tmp;
-
- return (FT_Int32)( ret >> 16 );
-#else
-
- /* For some reason, GCC 4.6 on Ubuntu 12.04 generates invalid machine */
- /* code from the lines below. The main issue is that `wide_a' is not */
- /* properly initialized by sign-extending `a'. Instead, the generated */
- /* machine code assumes that the register that contains `a' on input */
- /* can be used directly as a 64-bit value, which is wrong most of the */
- /* time. */
- long long wide_a = (long long)a;
- long long wide_b = (long long)b;
- long long result;
-
-
- __asm__ __volatile__ (
- "imul %2, %1\n"
- "mov %1, %0\n"
- "sar $63, %0\n"
- "lea 0x8000(%1, %0), %0\n"
- "sar $16, %0\n"
- : "=&r"(result), "=&r"(wide_a)
- : "r"(wide_b)
- : "cc" );
-
- return (FT_Int32)result;
-#endif
-
-#if __GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 6 )
-#pragma GCC diagnostic pop
-#endif
- }
-
-#endif /* __GNUC__ && __x86_64__ */
-
-#endif /* !FT_CONFIG_OPTION_NO_ASSEMBLER */
-
-
-#ifdef FT_CONFIG_OPTION_INLINE_MULFIX
-#ifdef FT_MULFIX_ASSEMBLER
-#define FT_MulFix( a, b ) FT_MULFIX_ASSEMBLER( (FT_Int32)(a), (FT_Int32)(b) )
-#endif
-#endif
-
-
- /**************************************************************************
- *
- * @function:
- * FT_MulDiv_No_Round
- *
- * @description:
- * A very simple function used to perform the computation '(a*b)/c'
- * (without rounding) with maximum accuracy (it uses a 64-bit
- * intermediate integer whenever necessary).
- *
- * This function isn't necessarily as fast as some processor-specific
- * operations, but is at least completely portable.
- *
- * @input:
- * a ::
- * The first multiplier.
- * b ::
- * The second multiplier.
- * c ::
- * The divisor.
- *
- * @return:
- * The result of '(a*b)/c'. This function never traps when trying to
- * divide by zero; it simply returns 'MaxInt' or 'MinInt' depending on
- * the signs of 'a' and 'b'.
- */
- FT_BASE( FT_Long )
- FT_MulDiv_No_Round( FT_Long a,
- FT_Long b,
- FT_Long c );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_MulAddFix
- *
- * @description:
- * Compute `(s[0] * f[0] + s[1] * f[1] + ...) / 0x10000`, where `s[n]` is
- * usually a 16.16 scalar.
- *
- * @input:
- * s ::
- * The array of scalars.
- * f ::
- * The array of factors.
- * count ::
- * The number of entries in the array.
- *
- * @return:
- * The result of `(s[0] * f[0] + s[1] * f[1] + ...) / 0x10000`.
- *
- * @note:
- * This function is currently used for the scaled delta computation of
- * variation stores. It internally uses 64-bit data types when
- * available, otherwise it emulates 64-bit math by using 32-bit
- * operations, which produce a correct result but most likely at a slower
- * performance in comparison to the implementation base on `int64_t`.
- *
- */
- FT_BASE( FT_Int32 )
- FT_MulAddFix( FT_Fixed* s,
- FT_Int32* f,
- FT_UInt count );
-
-
- /*
- * A variant of FT_Matrix_Multiply which scales its result afterwards. The
- * idea is that both `a' and `b' are scaled by factors of 10 so that the
- * values are as precise as possible to get a correct result during the
- * 64bit multiplication. Let `sa' and `sb' be the scaling factors of `a'
- * and `b', respectively, then the scaling factor of the result is `sa*sb'.
- */
- FT_BASE( void )
- FT_Matrix_Multiply_Scaled( const FT_Matrix* a,
- FT_Matrix *b,
- FT_Long scaling );
-
-
- /*
- * Check a matrix. If the transformation would lead to extreme shear or
- * extreme scaling, for example, return 0. If everything is OK, return 1.
- *
- * Based on geometric considerations we use the following inequality to
- * identify a degenerate matrix.
- *
- * 32 * abs(xx*yy - xy*yx) < xx^2 + xy^2 + yx^2 + yy^2
- *
- * Value 32 is heuristic.
- */
- FT_BASE( FT_Bool )
- FT_Matrix_Check( const FT_Matrix* matrix );
-
-
- /*
- * A variant of FT_Vector_Transform. See comments for
- * FT_Matrix_Multiply_Scaled.
- */
- FT_BASE( void )
- FT_Vector_Transform_Scaled( FT_Vector* vector,
- const FT_Matrix* matrix,
- FT_Long scaling );
-
-
- /*
- * This function normalizes a vector and returns its original length. The
- * normalized vector is a 16.16 fixed-point unit vector with length close
- * to 0x10000. The accuracy of the returned length is limited to 16 bits
- * also. The function utilizes quick inverse square root approximation
- * without divisions and square roots relying on Newton's iterations
- * instead.
- */
- FT_BASE( FT_UInt32 )
- FT_Vector_NormLen( FT_Vector* vector );
-
-
- /*
- * Return -1, 0, or +1, depending on the orientation of a given corner. We
- * use the Cartesian coordinate system, with positive vertical values going
- * upwards. The function returns +1 if the corner turns to the left, -1 to
- * the right, and 0 for undecidable cases.
- */
- FT_BASE( FT_Int )
- ft_corner_orientation( FT_Pos in_x,
- FT_Pos in_y,
- FT_Pos out_x,
- FT_Pos out_y );
-
-
- /*
- * Return TRUE if a corner is flat or nearly flat. This is equivalent to
- * saying that the corner point is close to its neighbors, or inside an
- * ellipse defined by the neighbor focal points to be more precise.
- */
- FT_BASE( FT_Int )
- ft_corner_is_flat( FT_Pos in_x,
- FT_Pos in_y,
- FT_Pos out_x,
- FT_Pos out_y );
-
-
- /*
- * Return the most significant bit index.
- */
-
-#ifndef FT_CONFIG_OPTION_NO_ASSEMBLER
-
-#if defined( __clang__ ) || ( defined( __GNUC__ ) && \
- ( __GNUC__ > 3 || ( __GNUC__ == 3 && __GNUC_MINOR__ >= 4 ) ) )
-
-#if FT_SIZEOF_INT == 4
-
-#define FT_MSB( x ) ( 31 - __builtin_clz( x ) )
-
-#elif FT_SIZEOF_LONG == 4
-
-#define FT_MSB( x ) ( 31 - __builtin_clzl( x ) )
-
-#endif
-
-#elif defined( _MSC_VER ) && _MSC_VER >= 1400
-
-#if defined( _WIN32_WCE )
-
-#include <cmnintrin.h>
-#pragma intrinsic( _CountLeadingZeros )
-
-#define FT_MSB( x ) ( 31 - _CountLeadingZeros( x ) )
-
-#elif defined( _M_ARM64 ) || defined( _M_ARM ) || defined( _M_ARM64EC )
-
-#include <intrin.h>
-#pragma intrinsic( _CountLeadingZeros )
-
-#define FT_MSB( x ) ( 31 - _CountLeadingZeros( x ) )
-
-#elif defined( _M_IX86 ) || defined( _M_AMD64 ) || defined( _M_IA64 )
-
-#include <intrin.h>
-#pragma intrinsic( _BitScanReverse )
-
- static __inline FT_Int32
- FT_MSB_i386( FT_UInt32 x )
- {
- unsigned long where;
-
-
- _BitScanReverse( &where, x );
-
- return (FT_Int32)where;
- }
-
-#define FT_MSB( x ) FT_MSB_i386( x )
-
-#endif
-
-#elif defined( __WATCOMC__ ) && defined( __386__ )
-
- extern __inline FT_Int32
- FT_MSB_i386( FT_UInt32 x );
-
-#pragma aux FT_MSB_i386 = \
- "bsr eax, eax" \
- __parm [__eax] __nomemory \
- __value [__eax] \
- __modify __exact [__eax] __nomemory;
-
-#define FT_MSB( x ) FT_MSB_i386( x )
-
-#elif defined( __SunOS_5_11 )
-
-#include <string.h>
-
-#define FT_MSB( x ) ( fls( x ) - 1 )
-
-#elif defined( __DECC ) || defined( __DECCXX )
-
-#include <builtins.h>
-
-#define FT_MSB( x ) (FT_Int)( 63 - _leadz( x ) )
-
-#elif defined( _CRAYC )
-
-#include <intrinsics.h>
-
-#define FT_MSB( x ) (FT_Int)( 31 - _leadz32( x ) )
-
-#endif /* FT_MSB macro definitions */
-
-#endif /* !FT_CONFIG_OPTION_NO_ASSEMBLER */
-
-
-#ifndef FT_MSB
-
- FT_BASE( FT_Int )
- FT_MSB( FT_UInt32 z );
-
-#endif
-
-
- /*
- * Return sqrt(x*x+y*y), which is the same as `FT_Vector_Length' but uses
- * two fixed-point arguments instead.
- */
- FT_BASE( FT_Fixed )
- FT_Hypot( FT_Fixed x,
- FT_Fixed y );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_SqrtFixed
- *
- * @description:
- * Computes the square root of a 16.16 fixed-point value.
- *
- * @input:
- * x ::
- * The value to compute the root for.
- *
- * @return:
- * The result of 'sqrt(x)'.
- *
- * @note:
- * This function is slow and should be avoided. Consider @FT_Hypot or
- * @FT_Vector_NormLen instead.
- */
- FT_BASE( FT_UInt32 )
- FT_SqrtFixed( FT_UInt32 x );
-
-
-#define INT_TO_F26DOT6( x ) ( (FT_Long)(x) * 64 ) /* << 6 */
-#define INT_TO_F2DOT14( x ) ( (FT_Long)(x) * 16384 ) /* << 14 */
-#define INT_TO_FIXED( x ) ( (FT_Long)(x) * 65536 ) /* << 16 */
-#define F2DOT14_TO_FIXED( x ) ( (FT_Long)(x) * 4 ) /* << 2 */
-#define FIXED_TO_INT( x ) ( FT_RoundFix( x ) >> 16 )
-
-#define ROUND_F26DOT6( x ) ( ( (x) + 32 - ( x < 0 ) ) & -64 )
-
- /*
- * The following macros have two purposes.
- *
- * - Tag places where overflow is expected and harmless.
- *
- * - Avoid run-time sanitizer errors.
- *
- * Use with care!
- */
-#define ADD_INT( a, b ) \
- (FT_Int)( (FT_UInt)(a) + (FT_UInt)(b) )
-#define SUB_INT( a, b ) \
- (FT_Int)( (FT_UInt)(a) - (FT_UInt)(b) )
-#define MUL_INT( a, b ) \
- (FT_Int)( (FT_UInt)(a) * (FT_UInt)(b) )
-#define NEG_INT( a ) \
- (FT_Int)( (FT_UInt)0 - (FT_UInt)(a) )
-
-#define ADD_LONG( a, b ) \
- (FT_Long)( (FT_ULong)(a) + (FT_ULong)(b) )
-#define SUB_LONG( a, b ) \
- (FT_Long)( (FT_ULong)(a) - (FT_ULong)(b) )
-#define MUL_LONG( a, b ) \
- (FT_Long)( (FT_ULong)(a) * (FT_ULong)(b) )
-#define NEG_LONG( a ) \
- (FT_Long)( (FT_ULong)0 - (FT_ULong)(a) )
-
-#define ADD_INT32( a, b ) \
- (FT_Int32)( (FT_UInt32)(a) + (FT_UInt32)(b) )
-#define SUB_INT32( a, b ) \
- (FT_Int32)( (FT_UInt32)(a) - (FT_UInt32)(b) )
-#define MUL_INT32( a, b ) \
- (FT_Int32)( (FT_UInt32)(a) * (FT_UInt32)(b) )
-#define NEG_INT32( a ) \
- (FT_Int32)( (FT_UInt32)0 - (FT_UInt32)(a) )
-
-#ifdef FT_INT64
-
-#define ADD_INT64( a, b ) \
- (FT_Int64)( (FT_UInt64)(a) + (FT_UInt64)(b) )
-#define SUB_INT64( a, b ) \
- (FT_Int64)( (FT_UInt64)(a) - (FT_UInt64)(b) )
-#define MUL_INT64( a, b ) \
- (FT_Int64)( (FT_UInt64)(a) * (FT_UInt64)(b) )
-#define NEG_INT64( a ) \
- (FT_Int64)( (FT_UInt64)0 - (FT_UInt64)(a) )
-
-#endif /* FT_INT64 */
-
-
-FT_END_HEADER
-
-#endif /* FTCALC_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/ftdebug.h b/contrib/libs/freetype/include/freetype/internal/ftdebug.h
deleted file mode 100644
index d7fa8dc93c..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/ftdebug.h
+++ /dev/null
@@ -1,442 +0,0 @@
-/****************************************************************************
- *
- * ftdebug.h
- *
- * Debugging and logging component (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- *
- * IMPORTANT: A description of FreeType's debugging support can be
- * found in 'docs/DEBUG.TXT'. Read it if you need to use or
- * understand this code.
- *
- */
-
-
-#ifndef FTDEBUG_H_
-#define FTDEBUG_H_
-
-
-#include <ft2build.h>
-#include FT_CONFIG_CONFIG_H
-#include <freetype/freetype.h>
-
-#include "compiler-macros.h"
-
-#ifdef FT_DEBUG_LOGGING
-#define DLG_STATIC
-#include <dlg/output.h>
-#include <dlg/dlg.h>
-
-#include <freetype/ftlogging.h>
-#endif /* FT_DEBUG_LOGGING */
-
-
-FT_BEGIN_HEADER
-
- /* force the definition of FT_DEBUG_LEVEL_TRACE if FT_DEBUG_LOGGING is */
- /* already defined. */
- /* */
-#ifdef FT_DEBUG_LOGGING
-#undef FT_DEBUG_LEVEL_TRACE
-#define FT_DEBUG_LEVEL_TRACE
-#endif
-
- /* force the definition of FT_DEBUG_LEVEL_ERROR if FT_DEBUG_LEVEL_TRACE */
- /* is already defined; this simplifies the following #ifdefs */
- /* */
-#ifdef FT_DEBUG_LEVEL_TRACE
-#undef FT_DEBUG_LEVEL_ERROR
-#define FT_DEBUG_LEVEL_ERROR
-#endif
-
-
- /**************************************************************************
- *
- * Define the trace enums as well as the trace levels array when they are
- * needed.
- *
- */
-
-#ifdef FT_DEBUG_LEVEL_TRACE
-
-#define FT_TRACE_DEF( x ) trace_ ## x ,
-
- /* defining the enumeration */
- typedef enum FT_Trace_
- {
-#include <freetype/internal/fttrace.h>
- trace_count
-
- } FT_Trace;
-
-
- /* a pointer to the array of trace levels, */
- /* provided by `src/base/ftdebug.c' */
- extern int* ft_trace_levels;
-
-#undef FT_TRACE_DEF
-
-#endif /* FT_DEBUG_LEVEL_TRACE */
-
-
- /**************************************************************************
- *
- * Define the FT_TRACE macro
- *
- * IMPORTANT!
- *
- * Each component must define the macro FT_COMPONENT to a valid FT_Trace
- * value before using any TRACE macro.
- *
- * To get consistent logging output, there should be no newline character
- * (i.e., '\n') or a single trailing one in the message string of
- * `FT_TRACEx` and `FT_ERROR`.
- */
-
-
- /*************************************************************************
- *
- * If FT_DEBUG_LOGGING is enabled, tracing messages are sent to dlg's API.
- * If FT_DEBUG_LOGGING is disabled, tracing messages are sent to
- * `FT_Message` (defined in ftdebug.c).
- */
-#ifdef FT_DEBUG_LOGGING
-
- /* we need two macros to convert the names of `FT_COMPONENT` to a string */
-#define FT_LOGGING_TAG( x ) FT_LOGGING_TAG_( x )
-#define FT_LOGGING_TAG_( x ) #x
-
- /* we need two macros to convert the component and the trace level */
- /* to a string that combines them */
-#define FT_LOGGING_TAGX( x, y ) FT_LOGGING_TAGX_( x, y )
-#define FT_LOGGING_TAGX_( x, y ) #x ":" #y
-
-
-#define FT_LOG( level, varformat ) \
- do \
- { \
- const char* dlg_tag = FT_LOGGING_TAGX( FT_COMPONENT, level ); \
- \
- \
- ft_add_tag( dlg_tag ); \
- if ( ft_trace_levels[FT_TRACE_COMP( FT_COMPONENT )] >= level ) \
- { \
- if ( custom_output_handler != NULL ) \
- FT_Logging_Callback varformat; \
- else \
- dlg_trace varformat; \
- } \
- ft_remove_tag( dlg_tag ); \
- } while( 0 )
-
-#else /* !FT_DEBUG_LOGGING */
-
-#define FT_LOG( level, varformat ) \
- do \
- { \
- if ( ft_trace_levels[FT_TRACE_COMP( FT_COMPONENT )] >= level ) \
- FT_Message varformat; \
- } while ( 0 )
-
-#endif /* !FT_DEBUG_LOGGING */
-
-
-#ifdef FT_DEBUG_LEVEL_TRACE
-
- /* we need two macros here to make cpp expand `FT_COMPONENT' */
-#define FT_TRACE_COMP( x ) FT_TRACE_COMP_( x )
-#define FT_TRACE_COMP_( x ) trace_ ## x
-
-#define FT_TRACE( level, varformat ) FT_LOG( level, varformat )
-
-#else /* !FT_DEBUG_LEVEL_TRACE */
-
-#define FT_TRACE( level, varformat ) do { } while ( 0 ) /* nothing */
-
-#endif /* !FT_DEBUG_LEVEL_TRACE */
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Trace_Get_Count
- *
- * @description:
- * Return the number of available trace components.
- *
- * @return:
- * The number of trace components. 0 if FreeType 2 is not built with
- * FT_DEBUG_LEVEL_TRACE definition.
- *
- * @note:
- * This function may be useful if you want to access elements of the
- * internal trace levels array by an index.
- */
- FT_BASE( FT_Int )
- FT_Trace_Get_Count( void );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Trace_Get_Name
- *
- * @description:
- * Return the name of a trace component.
- *
- * @input:
- * The index of the trace component.
- *
- * @return:
- * The name of the trace component. This is a statically allocated
- * C~string, so do not free it after use. `NULL` if FreeType is not
- * built with FT_DEBUG_LEVEL_TRACE definition.
- *
- * @note:
- * Use @FT_Trace_Get_Count to get the number of available trace
- * components.
- */
- FT_BASE( const char* )
- FT_Trace_Get_Name( FT_Int idx );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Trace_Disable
- *
- * @description:
- * Switch off tracing temporarily. It can be activated again with
- * @FT_Trace_Enable.
- */
- FT_BASE( void )
- FT_Trace_Disable( void );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Trace_Enable
- *
- * @description:
- * Activate tracing. Use it after tracing has been switched off with
- * @FT_Trace_Disable.
- */
- FT_BASE( void )
- FT_Trace_Enable( void );
-
-
- /**************************************************************************
- *
- * You need two opening and closing parentheses!
- *
- * Example: FT_TRACE0(( "Value is %i", foo ))
- *
- * Output of the FT_TRACEX macros is sent to stderr.
- *
- */
-
-#define FT_TRACE0( varformat ) FT_TRACE( 0, varformat )
-#define FT_TRACE1( varformat ) FT_TRACE( 1, varformat )
-#define FT_TRACE2( varformat ) FT_TRACE( 2, varformat )
-#define FT_TRACE3( varformat ) FT_TRACE( 3, varformat )
-#define FT_TRACE4( varformat ) FT_TRACE( 4, varformat )
-#define FT_TRACE5( varformat ) FT_TRACE( 5, varformat )
-#define FT_TRACE6( varformat ) FT_TRACE( 6, varformat )
-#define FT_TRACE7( varformat ) FT_TRACE( 7, varformat )
-
-
- /**************************************************************************
- *
- * Define the FT_ERROR macro.
- *
- * Output of this macro is sent to stderr.
- *
- */
-
-#ifdef FT_DEBUG_LEVEL_ERROR
-
- /**************************************************************************
- *
- * If FT_DEBUG_LOGGING is enabled, error messages are sent to dlg's API.
- * If FT_DEBUG_LOGGING is disabled, error messages are sent to `FT_Message`
- * (defined in ftdebug.c).
- *
- */
-#ifdef FT_DEBUG_LOGGING
-
-#define FT_ERROR( varformat ) \
- do \
- { \
- const char* dlg_tag = FT_LOGGING_TAG( FT_COMPONENT ); \
- \
- \
- ft_add_tag( dlg_tag ); \
- dlg_trace varformat; \
- ft_remove_tag( dlg_tag ); \
- } while ( 0 )
-
-#else /* !FT_DEBUG_LOGGING */
-
-#define FT_ERROR( varformat ) FT_Message varformat
-
-#endif /* !FT_DEBUG_LOGGING */
-
-
-#else /* !FT_DEBUG_LEVEL_ERROR */
-
-#define FT_ERROR( varformat ) do { } while ( 0 ) /* nothing */
-
-#endif /* !FT_DEBUG_LEVEL_ERROR */
-
-
- /**************************************************************************
- *
- * Define the FT_ASSERT and FT_THROW macros. The call to `FT_Throw` makes
- * it possible to easily set a breakpoint at this function.
- *
- */
-
-#ifdef FT_DEBUG_LEVEL_ERROR
-
-#define FT_ASSERT( condition ) \
- do \
- { \
- if ( !( condition ) ) \
- FT_Panic( "assertion failed on line %d of file %s\n", \
- __LINE__, __FILE__ ); \
- } while ( 0 )
-
-#define FT_THROW( e ) \
- ( FT_Throw( FT_ERR_CAT( FT_ERR_PREFIX, e ), \
- __LINE__, \
- __FILE__ ) | \
- FT_ERR_CAT( FT_ERR_PREFIX, e ) )
-
-#else /* !FT_DEBUG_LEVEL_ERROR */
-
-#define FT_ASSERT( condition ) do { } while ( 0 )
-
-#define FT_THROW( e ) FT_ERR_CAT( FT_ERR_PREFIX, e )
-
-#endif /* !FT_DEBUG_LEVEL_ERROR */
-
-
- /**************************************************************************
- *
- * Define `FT_Message` and `FT_Panic` when needed.
- *
- */
-
-#ifdef FT_DEBUG_LEVEL_ERROR
-
-#include "stdio.h" /* for vfprintf() */
-
- /* print a message */
- FT_BASE( void )
- FT_Message( const char* fmt,
- ... );
-
- /* print a message and exit */
- FT_BASE( void )
- FT_Panic( const char* fmt,
- ... );
-
- /* report file name and line number of an error */
- FT_BASE( int )
- FT_Throw( FT_Error error,
- int line,
- const char* file );
-
-#endif /* FT_DEBUG_LEVEL_ERROR */
-
-
- FT_BASE( void )
- ft_debug_init( void );
-
-
-#ifdef FT_DEBUG_LOGGING
-
- /**************************************************************************
- *
- * 'dlg' uses output handlers to control how and where log messages are
- * printed. Therefore we need to define a default output handler for
- * FreeType.
- */
- FT_BASE( void )
- ft_log_handler( const struct dlg_origin* origin,
- const char* string,
- void* data );
-
-
- /**************************************************************************
- *
- * 1. `ft_default_log_handler` stores the function pointer that is used
- * internally by FreeType to print logs to a file.
- *
- * 2. `custom_output_handler` stores the function pointer to the callback
- * function provided by the user.
- *
- * It is defined in `ftdebug.c`.
- */
- extern dlg_handler ft_default_log_handler;
- extern FT_Custom_Log_Handler custom_output_handler;
-
-
- /**************************************************************************
- *
- * If FT_DEBUG_LOGGING macro is enabled, FreeType needs to initialize and
- * un-initialize `FILE*`.
- *
- * These functions are defined in `ftdebug.c`.
- */
- FT_BASE( void )
- ft_logging_init( void );
-
- FT_BASE( void )
- ft_logging_deinit( void );
-
-
- /**************************************************************************
- *
- * For printing the name of `FT_COMPONENT` along with the actual log we
- * need to add a tag with the name of `FT_COMPONENT`.
- *
- * These functions are defined in `ftdebug.c`.
- */
- FT_BASE( void )
- ft_add_tag( const char* tag );
-
- FT_BASE( void )
- ft_remove_tag( const char* tag );
-
-
- /**************************************************************************
- *
- * A function to print log data using a custom callback logging function
- * (which is set using `FT_Set_Log_Handler`).
- *
- * This function is defined in `ftdebug.c`.
- */
- FT_BASE( void )
- FT_Logging_Callback( const char* fmt,
- ... );
-
-#endif /* FT_DEBUG_LOGGING */
-
-
-FT_END_HEADER
-
-#endif /* FTDEBUG_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/ftdrv.h b/contrib/libs/freetype/include/freetype/internal/ftdrv.h
deleted file mode 100644
index 5609b3ef12..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/ftdrv.h
+++ /dev/null
@@ -1,289 +0,0 @@
-/****************************************************************************
- *
- * ftdrv.h
- *
- * FreeType internal font driver interface (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTDRV_H_
-#define FTDRV_H_
-
-
-#include <freetype/ftmodapi.h>
-
-#include "compiler-macros.h"
-
-FT_BEGIN_HEADER
-
-
- typedef FT_Error
- (*FT_Face_InitFunc)( FT_Stream stream,
- FT_Face face,
- FT_Int typeface_index,
- FT_Int num_params,
- FT_Parameter* parameters );
-
- typedef void
- (*FT_Face_DoneFunc)( FT_Face face );
-
-
- typedef FT_Error
- (*FT_Size_InitFunc)( FT_Size size );
-
- typedef void
- (*FT_Size_DoneFunc)( FT_Size size );
-
-
- typedef FT_Error
- (*FT_Slot_InitFunc)( FT_GlyphSlot slot );
-
- typedef void
- (*FT_Slot_DoneFunc)( FT_GlyphSlot slot );
-
-
- typedef FT_Error
- (*FT_Size_RequestFunc)( FT_Size size,
- FT_Size_Request req );
-
- typedef FT_Error
- (*FT_Size_SelectFunc)( FT_Size size,
- FT_ULong size_index );
-
- typedef FT_Error
- (*FT_Slot_LoadFunc)( FT_GlyphSlot slot,
- FT_Size size,
- FT_UInt glyph_index,
- FT_Int32 load_flags );
-
-
- typedef FT_Error
- (*FT_Face_GetKerningFunc)( FT_Face face,
- FT_UInt left_glyph,
- FT_UInt right_glyph,
- FT_Vector* kerning );
-
-
- typedef FT_Error
- (*FT_Face_AttachFunc)( FT_Face face,
- FT_Stream stream );
-
-
- typedef FT_Error
- (*FT_Face_GetAdvancesFunc)( FT_Face face,
- FT_UInt first,
- FT_UInt count,
- FT_Int32 flags,
- FT_Fixed* advances );
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_Driver_ClassRec
- *
- * @description:
- * The font driver class. This structure mostly contains pointers to
- * driver methods.
- *
- * @fields:
- * root ::
- * The parent module.
- *
- * face_object_size ::
- * The size of a face object in bytes.
- *
- * size_object_size ::
- * The size of a size object in bytes.
- *
- * slot_object_size ::
- * The size of a glyph object in bytes.
- *
- * init_face ::
- * The format-specific face constructor.
- *
- * done_face ::
- * The format-specific face destructor.
- *
- * init_size ::
- * The format-specific size constructor.
- *
- * done_size ::
- * The format-specific size destructor.
- *
- * init_slot ::
- * The format-specific slot constructor.
- *
- * done_slot ::
- * The format-specific slot destructor.
- *
- *
- * load_glyph ::
- * A function handle to load a glyph to a slot. This field is
- * mandatory!
- *
- * get_kerning ::
- * A function handle to return the unscaled kerning for a given pair of
- * glyphs. Can be set to 0 if the format doesn't support kerning.
- *
- * attach_file ::
- * This function handle is used to read additional data for a face from
- * another file/stream. For example, this can be used to add data from
- * AFM or PFM files on a Type 1 face, or a CIDMap on a CID-keyed face.
- *
- * get_advances ::
- * A function handle used to return advance widths of 'count' glyphs
- * (in font units), starting at 'first'. The 'vertical' flag must be
- * set to get vertical advance heights. The 'advances' buffer is
- * caller-allocated. The idea of this function is to be able to
- * perform device-independent text layout without loading a single
- * glyph image.
- *
- * request_size ::
- * A handle to a function used to request the new character size. Can
- * be set to 0 if the scaling done in the base layer suffices.
- *
- * select_size ::
- * A handle to a function used to select a new fixed size. It is used
- * only if @FT_FACE_FLAG_FIXED_SIZES is set. Can be set to 0 if the
- * scaling done in the base layer suffices.
- *
- * @note:
- * Most function pointers, with the exception of `load_glyph`, can be set
- * to 0 to indicate a default behaviour.
- */
- typedef struct FT_Driver_ClassRec_
- {
- FT_Module_Class root;
-
- FT_Long face_object_size;
- FT_Long size_object_size;
- FT_Long slot_object_size;
-
- FT_Face_InitFunc init_face;
- FT_Face_DoneFunc done_face;
-
- FT_Size_InitFunc init_size;
- FT_Size_DoneFunc done_size;
-
- FT_Slot_InitFunc init_slot;
- FT_Slot_DoneFunc done_slot;
-
- FT_Slot_LoadFunc load_glyph;
-
- FT_Face_GetKerningFunc get_kerning;
- FT_Face_AttachFunc attach_file;
- FT_Face_GetAdvancesFunc get_advances;
-
- /* since version 2.2 */
- FT_Size_RequestFunc request_size;
- FT_Size_SelectFunc select_size;
-
- } FT_Driver_ClassRec, *FT_Driver_Class;
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_DECLARE_DRIVER
- *
- * @description:
- * Used to create a forward declaration of an FT_Driver_ClassRec struct
- * instance.
- *
- * @macro:
- * FT_DEFINE_DRIVER
- *
- * @description:
- * Used to initialize an instance of FT_Driver_ClassRec struct.
- *
- * `ftinit.c` (ft_create_default_module_classes) already contains a
- * mechanism to call these functions for the default modules described in
- * `ftmodule.h`.
- *
- * The struct will be allocated in the global scope (or the scope where
- * the macro is used).
- */
-#define FT_DECLARE_DRIVER( class_ ) \
- FT_CALLBACK_TABLE \
- const FT_Driver_ClassRec class_;
-
-#define FT_DEFINE_DRIVER( \
- class_, \
- flags_, \
- size_, \
- name_, \
- version_, \
- requires_, \
- interface_, \
- init_, \
- done_, \
- get_interface_, \
- face_object_size_, \
- size_object_size_, \
- slot_object_size_, \
- init_face_, \
- done_face_, \
- init_size_, \
- done_size_, \
- init_slot_, \
- done_slot_, \
- load_glyph_, \
- get_kerning_, \
- attach_file_, \
- get_advances_, \
- request_size_, \
- select_size_ ) \
- FT_CALLBACK_TABLE_DEF \
- const FT_Driver_ClassRec class_ = \
- { \
- FT_DEFINE_ROOT_MODULE( flags_, \
- size_, \
- name_, \
- version_, \
- requires_, \
- interface_, \
- init_, \
- done_, \
- get_interface_ ) \
- \
- face_object_size_, \
- size_object_size_, \
- slot_object_size_, \
- \
- init_face_, \
- done_face_, \
- \
- init_size_, \
- done_size_, \
- \
- init_slot_, \
- done_slot_, \
- \
- load_glyph_, \
- \
- get_kerning_, \
- attach_file_, \
- get_advances_, \
- \
- request_size_, \
- select_size_ \
- };
-
-
-FT_END_HEADER
-
-#endif /* FTDRV_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/ftgloadr.h b/contrib/libs/freetype/include/freetype/internal/ftgloadr.h
deleted file mode 100644
index f1c155b162..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/ftgloadr.h
+++ /dev/null
@@ -1,147 +0,0 @@
-/****************************************************************************
- *
- * ftgloadr.h
- *
- * The FreeType glyph loader (specification).
- *
- * Copyright (C) 2002-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTGLOADR_H_
-#define FTGLOADR_H_
-
-
-#include <freetype/freetype.h>
-
-#include "compiler-macros.h"
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_GlyphLoader
- *
- * @description:
- * The glyph loader is an internal object used to load several glyphs
- * together (for example, in the case of composites).
- */
- typedef struct FT_SubGlyphRec_
- {
- FT_Int index;
- FT_UShort flags;
- FT_Int arg1;
- FT_Int arg2;
- FT_Matrix transform;
-
- } FT_SubGlyphRec;
-
-
- typedef struct FT_GlyphLoadRec_
- {
- FT_Outline outline; /* outline */
- FT_Vector* extra_points; /* extra points table */
- FT_Vector* extra_points2; /* second extra points table */
- FT_UInt num_subglyphs; /* number of subglyphs */
- FT_SubGlyph subglyphs; /* subglyphs */
-
- } FT_GlyphLoadRec, *FT_GlyphLoad;
-
-
- typedef struct FT_GlyphLoaderRec_
- {
- FT_Memory memory;
- FT_UInt max_points;
- FT_UInt max_contours;
- FT_UInt max_subglyphs;
- FT_Bool use_extra;
-
- FT_GlyphLoadRec base;
- FT_GlyphLoadRec current;
-
- void* other; /* for possible future extension? */
-
- } FT_GlyphLoaderRec, *FT_GlyphLoader;
-
-
- /* create new empty glyph loader */
- FT_BASE( FT_Error )
- FT_GlyphLoader_New( FT_Memory memory,
- FT_GlyphLoader *aloader );
-
- /* add an extra points table to a glyph loader */
- FT_BASE( FT_Error )
- FT_GlyphLoader_CreateExtra( FT_GlyphLoader loader );
-
- /* destroy a glyph loader */
- FT_BASE( void )
- FT_GlyphLoader_Done( FT_GlyphLoader loader );
-
- /* reset a glyph loader (frees everything int it) */
- FT_BASE( void )
- FT_GlyphLoader_Reset( FT_GlyphLoader loader );
-
- /* rewind a glyph loader */
- FT_BASE( void )
- FT_GlyphLoader_Rewind( FT_GlyphLoader loader );
-
- /* check that there is enough space to add `n_points' and `n_contours' */
- /* to the glyph loader */
- FT_BASE( FT_Error )
- FT_GlyphLoader_CheckPoints( FT_GlyphLoader loader,
- FT_UInt n_points,
- FT_UInt n_contours );
-
-
-#define FT_GLYPHLOADER_CHECK_P( _loader, _count ) \
- ( (_count) == 0 || \
- ( (FT_UInt)(_loader)->base.outline.n_points + \
- (FT_UInt)(_loader)->current.outline.n_points + \
- (FT_UInt)(_count) ) <= (_loader)->max_points )
-
-#define FT_GLYPHLOADER_CHECK_C( _loader, _count ) \
- ( (_count) == 0 || \
- ( (FT_UInt)(_loader)->base.outline.n_contours + \
- (FT_UInt)(_loader)->current.outline.n_contours + \
- (FT_UInt)(_count) ) <= (_loader)->max_contours )
-
-#define FT_GLYPHLOADER_CHECK_POINTS( _loader, _points, _contours ) \
- ( ( FT_GLYPHLOADER_CHECK_P( _loader, _points ) && \
- FT_GLYPHLOADER_CHECK_C( _loader, _contours ) ) \
- ? 0 \
- : FT_GlyphLoader_CheckPoints( (_loader), \
- (FT_UInt)(_points), \
- (FT_UInt)(_contours) ) )
-
-
- /* check that there is enough space to add `n_subs' sub-glyphs to */
- /* a glyph loader */
- FT_BASE( FT_Error )
- FT_GlyphLoader_CheckSubGlyphs( FT_GlyphLoader loader,
- FT_UInt n_subs );
-
- /* prepare a glyph loader, i.e. empty the current glyph */
- FT_BASE( void )
- FT_GlyphLoader_Prepare( FT_GlyphLoader loader );
-
- /* add the current glyph to the base glyph */
- FT_BASE( void )
- FT_GlyphLoader_Add( FT_GlyphLoader loader );
-
-
-FT_END_HEADER
-
-#endif /* FTGLOADR_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/fthash.h b/contrib/libs/freetype/include/freetype/internal/fthash.h
deleted file mode 100644
index 622ec76bb9..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/fthash.h
+++ /dev/null
@@ -1,135 +0,0 @@
-/****************************************************************************
- *
- * fthash.h
- *
- * Hashing functions (specification).
- *
- */
-
-/*
- * Copyright 2000 Computing Research Labs, New Mexico State University
- * Copyright 2001-2015
- * Francesco Zappa Nardelli
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COMPUTING RESEARCH LAB OR NEW MEXICO STATE UNIVERSITY BE LIABLE FOR ANY
- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
- * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
- * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
- /**************************************************************************
- *
- * This file is based on code from bdf.c,v 1.22 2000/03/16 20:08:50
- *
- * taken from Mark Leisher's xmbdfed package
- *
- */
-
-
-#ifndef FTHASH_H_
-#define FTHASH_H_
-
-
-#include <freetype/freetype.h>
-
-
-FT_BEGIN_HEADER
-
-
- typedef union FT_Hashkey_
- {
- FT_Int num;
- const char* str;
-
- } FT_Hashkey;
-
-
- typedef struct FT_HashnodeRec_
- {
- FT_Hashkey key;
- size_t data;
-
- } FT_HashnodeRec;
-
- typedef struct FT_HashnodeRec_ *FT_Hashnode;
-
-
- typedef FT_ULong
- (*FT_Hash_LookupFunc)( FT_Hashkey* key );
-
- typedef FT_Bool
- (*FT_Hash_CompareFunc)( FT_Hashkey* a,
- FT_Hashkey* b );
-
-
- typedef struct FT_HashRec_
- {
- FT_UInt limit;
- FT_UInt size;
- FT_UInt used;
-
- FT_Hash_LookupFunc lookup;
- FT_Hash_CompareFunc compare;
-
- FT_Hashnode* table;
-
- } FT_HashRec;
-
- typedef struct FT_HashRec_ *FT_Hash;
-
-
- FT_Error
- ft_hash_str_init( FT_Hash hash,
- FT_Memory memory );
-
- FT_Error
- ft_hash_num_init( FT_Hash hash,
- FT_Memory memory );
-
- void
- ft_hash_str_free( FT_Hash hash,
- FT_Memory memory );
-
-#define ft_hash_num_free ft_hash_str_free
-
- FT_Error
- ft_hash_str_insert( const char* key,
- size_t data,
- FT_Hash hash,
- FT_Memory memory );
-
- FT_Error
- ft_hash_num_insert( FT_Int num,
- size_t data,
- FT_Hash hash,
- FT_Memory memory );
-
- size_t*
- ft_hash_str_lookup( const char* key,
- FT_Hash hash );
-
- size_t*
- ft_hash_num_lookup( FT_Int num,
- FT_Hash hash );
-
-
-FT_END_HEADER
-
-
-#endif /* FTHASH_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/ftmemory.h b/contrib/libs/freetype/include/freetype/internal/ftmemory.h
deleted file mode 100644
index 4e05a29f13..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/ftmemory.h
+++ /dev/null
@@ -1,401 +0,0 @@
-/****************************************************************************
- *
- * ftmemory.h
- *
- * The FreeType memory management macros (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTMEMORY_H_
-#define FTMEMORY_H_
-
-
-#include <ft2build.h>
-#include FT_CONFIG_CONFIG_H
-#include <freetype/fttypes.h>
-
-#include "compiler-macros.h"
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_SET_ERROR
- *
- * @description:
- * This macro is used to set an implicit 'error' variable to a given
- * expression's value (usually a function call), and convert it to a
- * boolean which is set whenever the value is != 0.
- */
-#undef FT_SET_ERROR
-#define FT_SET_ERROR( expression ) \
- ( ( error = (expression) ) != 0 )
-
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /**** ****/
- /**** ****/
- /**** M E M O R Y ****/
- /**** ****/
- /**** ****/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /* The calculation `NULL + n' is undefined in C. Even if the resulting */
- /* pointer doesn't get dereferenced, this causes warnings with */
- /* sanitizers. */
- /* */
- /* We thus provide a macro that should be used if `base' can be NULL. */
-#define FT_OFFSET( base, count ) ( (base) ? (base) + (count) : NULL )
-
-
- /*
- * C++ refuses to handle statements like p = (void*)anything, with `p' a
- * typed pointer. Since we don't have a `typeof' operator in standard C++,
- * we have to use a template to emulate it.
- */
-
-#ifdef __cplusplus
-
-extern "C++"
-{
- template <typename T> inline T*
- cplusplus_typeof( T*,
- void *v )
- {
- return static_cast <T*> ( v );
- }
-}
-
-#define FT_ASSIGNP( p, val ) (p) = cplusplus_typeof( (p), (val) )
-
-#else
-
-#define FT_ASSIGNP( p, val ) (p) = (val)
-
-#endif
-
-
-
-#ifdef FT_DEBUG_MEMORY
-
- FT_BASE( const char* ) ft_debug_file_;
- FT_BASE( long ) ft_debug_lineno_;
-
-#define FT_DEBUG_INNER( exp ) ( ft_debug_file_ = __FILE__, \
- ft_debug_lineno_ = __LINE__, \
- (exp) )
-
-#define FT_ASSIGNP_INNER( p, exp ) ( ft_debug_file_ = __FILE__, \
- ft_debug_lineno_ = __LINE__, \
- FT_ASSIGNP( p, exp ) )
-
-#else /* !FT_DEBUG_MEMORY */
-
-#define FT_DEBUG_INNER( exp ) (exp)
-#define FT_ASSIGNP_INNER( p, exp ) FT_ASSIGNP( p, exp )
-
-#endif /* !FT_DEBUG_MEMORY */
-
-
- /*
- * The allocation functions return a pointer, and the error code is written
- * to through the `p_error' parameter.
- */
-
- /* The `q' variants of the functions below (`q' for `quick') don't fill */
- /* the allocated or reallocated memory with zero bytes. */
-
- FT_BASE( FT_Pointer )
- ft_mem_alloc( FT_Memory memory,
- FT_Long size,
- FT_Error *p_error );
-
- FT_BASE( FT_Pointer )
- ft_mem_qalloc( FT_Memory memory,
- FT_Long size,
- FT_Error *p_error );
-
- FT_BASE( FT_Pointer )
- ft_mem_realloc( FT_Memory memory,
- FT_Long item_size,
- FT_Long cur_count,
- FT_Long new_count,
- void* block,
- FT_Error *p_error );
-
- FT_BASE( FT_Pointer )
- ft_mem_qrealloc( FT_Memory memory,
- FT_Long item_size,
- FT_Long cur_count,
- FT_Long new_count,
- void* block,
- FT_Error *p_error );
-
- FT_BASE( void )
- ft_mem_free( FT_Memory memory,
- const void* P );
-
-
- /* The `Q' variants of the macros below (`Q' for `quick') don't fill */
- /* the allocated or reallocated memory with zero bytes. */
-
-#define FT_MEM_ALLOC( ptr, size ) \
- FT_ASSIGNP_INNER( ptr, ft_mem_alloc( memory, \
- (FT_Long)(size), \
- &error ) )
-
-#define FT_MEM_FREE( ptr ) \
- FT_BEGIN_STMNT \
- FT_DEBUG_INNER( ft_mem_free( memory, (ptr) ) ); \
- (ptr) = NULL; \
- FT_END_STMNT
-
-#define FT_MEM_NEW( ptr ) \
- FT_MEM_ALLOC( ptr, sizeof ( *(ptr) ) )
-
-#define FT_MEM_REALLOC( ptr, cursz, newsz ) \
- FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \
- 1, \
- (FT_Long)(cursz), \
- (FT_Long)(newsz), \
- (ptr), \
- &error ) )
-
-#define FT_MEM_QALLOC( ptr, size ) \
- FT_ASSIGNP_INNER( ptr, ft_mem_qalloc( memory, \
- (FT_Long)(size), \
- &error ) )
-
-#define FT_MEM_QNEW( ptr ) \
- FT_MEM_QALLOC( ptr, sizeof ( *(ptr) ) )
-
-#define FT_MEM_QREALLOC( ptr, cursz, newsz ) \
- FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, \
- 1, \
- (FT_Long)(cursz), \
- (FT_Long)(newsz), \
- (ptr), \
- &error ) )
-
-#define FT_MEM_ALLOC_MULT( ptr, count, item_size ) \
- FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \
- (FT_Long)(item_size), \
- 0, \
- (FT_Long)(count), \
- NULL, \
- &error ) )
-
-#define FT_MEM_REALLOC_MULT( ptr, oldcnt, newcnt, itmsz ) \
- FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \
- (FT_Long)(itmsz), \
- (FT_Long)(oldcnt), \
- (FT_Long)(newcnt), \
- (ptr), \
- &error ) )
-
-#define FT_MEM_QALLOC_MULT( ptr, count, item_size ) \
- FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, \
- (FT_Long)(item_size), \
- 0, \
- (FT_Long)(count), \
- NULL, \
- &error ) )
-
-#define FT_MEM_QREALLOC_MULT( ptr, oldcnt, newcnt, itmsz ) \
- FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, \
- (FT_Long)(itmsz), \
- (FT_Long)(oldcnt), \
- (FT_Long)(newcnt), \
- (ptr), \
- &error ) )
-
-
-#define FT_MEM_SET_ERROR( cond ) ( (cond), error != 0 )
-
-
-#define FT_MEM_SET( dest, byte, count ) \
- ft_memset( dest, byte, (FT_Offset)(count) )
-
-#define FT_MEM_COPY( dest, source, count ) \
- ft_memcpy( dest, source, (FT_Offset)(count) )
-
-#define FT_MEM_MOVE( dest, source, count ) \
- ft_memmove( dest, source, (FT_Offset)(count) )
-
-
-#define FT_MEM_ZERO( dest, count ) FT_MEM_SET( dest, 0, count )
-
-#define FT_ZERO( p ) FT_MEM_ZERO( p, sizeof ( *(p) ) )
-
-
-#define FT_ARRAY_ZERO( dest, count ) \
- FT_MEM_ZERO( dest, \
- (FT_Offset)(count) * sizeof ( *(dest) ) )
-
-#define FT_ARRAY_COPY( dest, source, count ) \
- FT_MEM_COPY( dest, \
- source, \
- (FT_Offset)(count) * sizeof ( *(dest) ) )
-
-#define FT_ARRAY_MOVE( dest, source, count ) \
- FT_MEM_MOVE( dest, \
- source, \
- (FT_Offset)(count) * sizeof ( *(dest) ) )
-
-
- /*
- * Return the maximum number of addressable elements in an array. We limit
- * ourselves to INT_MAX, rather than UINT_MAX, to avoid any problems.
- */
-#define FT_ARRAY_MAX( ptr ) ( FT_INT_MAX / sizeof ( *(ptr) ) )
-
-#define FT_ARRAY_CHECK( ptr, count ) ( (count) <= FT_ARRAY_MAX( ptr ) )
-
-
- /**************************************************************************
- *
- * The following functions macros expect that their pointer argument is
- * _typed_ in order to automatically compute array element sizes.
- */
-
-#define FT_MEM_NEW_ARRAY( ptr, count ) \
- FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \
- sizeof ( *(ptr) ), \
- 0, \
- (FT_Long)(count), \
- NULL, \
- &error ) )
-
-#define FT_MEM_RENEW_ARRAY( ptr, cursz, newsz ) \
- FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \
- sizeof ( *(ptr) ), \
- (FT_Long)(cursz), \
- (FT_Long)(newsz), \
- (ptr), \
- &error ) )
-
-#define FT_MEM_QNEW_ARRAY( ptr, count ) \
- FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, \
- sizeof ( *(ptr) ), \
- 0, \
- (FT_Long)(count), \
- NULL, \
- &error ) )
-
-#define FT_MEM_QRENEW_ARRAY( ptr, cursz, newsz ) \
- FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, \
- sizeof ( *(ptr) ), \
- (FT_Long)(cursz), \
- (FT_Long)(newsz), \
- (ptr), \
- &error ) )
-
-#define FT_ALLOC( ptr, size ) \
- FT_MEM_SET_ERROR( FT_MEM_ALLOC( ptr, size ) )
-
-#define FT_REALLOC( ptr, cursz, newsz ) \
- FT_MEM_SET_ERROR( FT_MEM_REALLOC( ptr, cursz, newsz ) )
-
-#define FT_ALLOC_MULT( ptr, count, item_size ) \
- FT_MEM_SET_ERROR( FT_MEM_ALLOC_MULT( ptr, count, item_size ) )
-
-#define FT_REALLOC_MULT( ptr, oldcnt, newcnt, itmsz ) \
- FT_MEM_SET_ERROR( FT_MEM_REALLOC_MULT( ptr, oldcnt, \
- newcnt, itmsz ) )
-
-#define FT_QALLOC( ptr, size ) \
- FT_MEM_SET_ERROR( FT_MEM_QALLOC( ptr, size ) )
-
-#define FT_QREALLOC( ptr, cursz, newsz ) \
- FT_MEM_SET_ERROR( FT_MEM_QREALLOC( ptr, cursz, newsz ) )
-
-#define FT_QALLOC_MULT( ptr, count, item_size ) \
- FT_MEM_SET_ERROR( FT_MEM_QALLOC_MULT( ptr, count, item_size ) )
-
-#define FT_QREALLOC_MULT( ptr, oldcnt, newcnt, itmsz ) \
- FT_MEM_SET_ERROR( FT_MEM_QREALLOC_MULT( ptr, oldcnt, \
- newcnt, itmsz ) )
-
-#define FT_FREE( ptr ) FT_MEM_FREE( ptr )
-
-#define FT_NEW( ptr ) FT_MEM_SET_ERROR( FT_MEM_NEW( ptr ) )
-
-#define FT_NEW_ARRAY( ptr, count ) \
- FT_MEM_SET_ERROR( FT_MEM_NEW_ARRAY( ptr, count ) )
-
-#define FT_RENEW_ARRAY( ptr, curcnt, newcnt ) \
- FT_MEM_SET_ERROR( FT_MEM_RENEW_ARRAY( ptr, curcnt, newcnt ) )
-
-#define FT_QNEW( ptr ) FT_MEM_SET_ERROR( FT_MEM_QNEW( ptr ) )
-
-#define FT_QNEW_ARRAY( ptr, count ) \
- FT_MEM_SET_ERROR( FT_MEM_QNEW_ARRAY( ptr, count ) )
-
-#define FT_QRENEW_ARRAY( ptr, curcnt, newcnt ) \
- FT_MEM_SET_ERROR( FT_MEM_QRENEW_ARRAY( ptr, curcnt, newcnt ) )
-
-
- FT_BASE( FT_Pointer )
- ft_mem_strdup( FT_Memory memory,
- const char* str,
- FT_Error *p_error );
-
- FT_BASE( FT_Pointer )
- ft_mem_dup( FT_Memory memory,
- const void* address,
- FT_ULong size,
- FT_Error *p_error );
-
-
-#define FT_MEM_STRDUP( dst, str ) \
- (dst) = (char*)ft_mem_strdup( memory, (const char*)(str), &error )
-
-#define FT_STRDUP( dst, str ) \
- FT_MEM_SET_ERROR( FT_MEM_STRDUP( dst, str ) )
-
-#define FT_MEM_DUP( dst, address, size ) \
- FT_ASSIGNP_INNER( dst, ft_mem_dup( memory, \
- (address), \
- (FT_ULong)(size), \
- &error ) )
-
-#define FT_DUP( dst, address, size ) \
- FT_MEM_SET_ERROR( FT_MEM_DUP( dst, address, size ) )
-
-
- /* Return >= 1 if a truncation occurs. */
- /* Return 0 if the source string fits the buffer. */
- /* This is *not* the same as strlcpy(). */
- FT_BASE( FT_Int )
- ft_mem_strcpyn( char* dst,
- const char* src,
- FT_ULong size );
-
-#define FT_STRCPYN( dst, src, size ) \
- ft_mem_strcpyn( (char*)dst, (const char*)(src), (FT_ULong)(size) )
-
-
-FT_END_HEADER
-
-#endif /* FTMEMORY_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/ftmmtypes.h b/contrib/libs/freetype/include/freetype/internal/ftmmtypes.h
deleted file mode 100644
index 8449e7a010..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/ftmmtypes.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/****************************************************************************
- *
- * ftmmtypes.h
- *
- * OpenType Variations type definitions for internal use
- * with the multi-masters service (specification).
- *
- * Copyright (C) 2022-2024 by
- * David Turner, Robert Wilhelm, Werner Lemberg, George Williams, and
- * Dominik Röttsches.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTMMTYPES_H_
-#define FTMMTYPES_H_
-
-FT_BEGIN_HEADER
-
-
- typedef FT_Int32 FT_ItemVarDelta;
-
- typedef struct GX_ItemVarDataRec_
- {
- FT_UInt itemCount; /* Number of delta sets per item. */
- FT_UInt regionIdxCount; /* Number of region indices. */
- FT_UInt* regionIndices; /* Array of `regionCount` indices; */
- /* these index `varRegionList`. */
- FT_Byte* deltaSet; /* Array of `itemCount` deltas; */
- /* use `innerIndex` for this array. */
- FT_UShort wordDeltaCount; /* Number of the first 32-bit ints */
- /* or 16-bit ints of `deltaSet` */
- /* depending on `longWords`. */
- FT_Bool longWords; /* If true, `deltaSet` is a 32-bit */
- /* array followed by a 16-bit */
- /* array, otherwise a 16-bit array */
- /* followed by an 8-bit array. */
- } GX_ItemVarDataRec, *GX_ItemVarData;
-
-
- /* contribution of one axis to a region */
- typedef struct GX_AxisCoordsRec_
- {
- FT_Fixed startCoord;
- FT_Fixed peakCoord; /* zero means no effect (factor = 1) */
- FT_Fixed endCoord;
-
- } GX_AxisCoordsRec, *GX_AxisCoords;
-
-
- typedef struct GX_VarRegionRec_
- {
- GX_AxisCoords axisList; /* array of axisCount records */
-
- } GX_VarRegionRec, *GX_VarRegion;
-
-
- /* item variation store */
- typedef struct GX_ItemVarStoreRec_
- {
- FT_UInt dataCount;
- GX_ItemVarData varData; /* array of dataCount records; */
- /* use `outerIndex' for this array */
- FT_UShort axisCount;
- FT_UInt regionCount; /* total number of regions defined */
- GX_VarRegion varRegionList;
-
- } GX_ItemVarStoreRec, *GX_ItemVarStore;
-
-
- typedef struct GX_DeltaSetIdxMapRec_
- {
- FT_ULong mapCount;
- FT_UInt* outerIndex; /* indices to item var data */
- FT_UInt* innerIndex; /* indices to delta set */
-
- } GX_DeltaSetIdxMapRec, *GX_DeltaSetIdxMap;
-
-
-FT_END_HEADER
-
-#endif /* FTMMTYPES_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/ftobjs.h b/contrib/libs/freetype/include/freetype/internal/ftobjs.h
deleted file mode 100644
index a1e93298fd..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/ftobjs.h
+++ /dev/null
@@ -1,1232 +0,0 @@
-/****************************************************************************
- *
- * ftobjs.h
- *
- * The FreeType private base classes (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /**************************************************************************
- *
- * This file contains the definition of all internal FreeType classes.
- *
- */
-
-
-#ifndef FTOBJS_H_
-#define FTOBJS_H_
-
-#include <freetype/ftrender.h>
-#include <freetype/ftsizes.h>
-#include <freetype/ftlcdfil.h>
-#include <freetype/internal/ftmemory.h>
-#include <freetype/internal/ftgloadr.h>
-#include <freetype/internal/ftdrv.h>
-#include <freetype/internal/autohint.h>
-#include <freetype/internal/ftserv.h>
-#include <freetype/internal/ftcalc.h>
-
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
-#include <freetype/ftincrem.h>
-#endif
-
-#include "compiler-macros.h"
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * Some generic definitions.
- */
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-
-#ifndef NULL
-#define NULL (void*)0
-#endif
-
-
- /**************************************************************************
- *
- * The min and max functions missing in C. As usual, be careful not to
- * write things like FT_MIN( a++, b++ ) to avoid side effects.
- */
-#define FT_MIN( a, b ) ( (a) < (b) ? (a) : (b) )
-#define FT_MAX( a, b ) ( (a) > (b) ? (a) : (b) )
-
-#define FT_ABS( a ) ( (a) < 0 ? -(a) : (a) )
-
- /*
- * Approximate sqrt(x*x+y*y) using the `alpha max plus beta min' algorithm.
- * We use alpha = 1, beta = 3/8, giving us results with a largest error
- * less than 7% compared to the exact value.
- */
-#define FT_HYPOT( x, y ) \
- ( x = FT_ABS( x ), \
- y = FT_ABS( y ), \
- x > y ? x + ( 3 * y >> 3 ) \
- : y + ( 3 * x >> 3 ) )
-
- /* we use FT_TYPEOF to suppress signedness compilation warnings */
-#define FT_PAD_FLOOR( x, n ) ( (x) & ~FT_TYPEOF( x )( (n) - 1 ) )
-#define FT_PAD_ROUND( x, n ) FT_PAD_FLOOR( (x) + (n) / 2, n )
-#define FT_PAD_CEIL( x, n ) FT_PAD_FLOOR( (x) + (n) - 1, n )
-
-#define FT_PIX_FLOOR( x ) ( (x) & ~FT_TYPEOF( x )63 )
-#define FT_PIX_ROUND( x ) FT_PIX_FLOOR( (x) + 32 )
-#define FT_PIX_CEIL( x ) FT_PIX_FLOOR( (x) + 63 )
-
- /* specialized versions (for signed values) */
- /* that don't produce run-time errors due to integer overflow */
-#define FT_PAD_ROUND_LONG( x, n ) FT_PAD_FLOOR( ADD_LONG( (x), (n) / 2 ), \
- n )
-#define FT_PAD_CEIL_LONG( x, n ) FT_PAD_FLOOR( ADD_LONG( (x), (n) - 1 ), \
- n )
-#define FT_PIX_ROUND_LONG( x ) FT_PIX_FLOOR( ADD_LONG( (x), 32 ) )
-#define FT_PIX_CEIL_LONG( x ) FT_PIX_FLOOR( ADD_LONG( (x), 63 ) )
-
-#define FT_PAD_ROUND_INT32( x, n ) FT_PAD_FLOOR( ADD_INT32( (x), (n) / 2 ), \
- n )
-#define FT_PAD_CEIL_INT32( x, n ) FT_PAD_FLOOR( ADD_INT32( (x), (n) - 1 ), \
- n )
-#define FT_PIX_ROUND_INT32( x ) FT_PIX_FLOOR( ADD_INT32( (x), 32 ) )
-#define FT_PIX_CEIL_INT32( x ) FT_PIX_FLOOR( ADD_INT32( (x), 63 ) )
-
-
- /*
- * character classification functions -- since these are used to parse font
- * files, we must not use those in <ctypes.h> which are locale-dependent
- */
-#define ft_isdigit( x ) ( ( (unsigned)(x) - '0' ) < 10U )
-
-#define ft_isxdigit( x ) ( ( (unsigned)(x) - '0' ) < 10U || \
- ( (unsigned)(x) - 'a' ) < 6U || \
- ( (unsigned)(x) - 'A' ) < 6U )
-
- /* the next two macros assume ASCII representation */
-#define ft_isupper( x ) ( ( (unsigned)(x) - 'A' ) < 26U )
-#define ft_islower( x ) ( ( (unsigned)(x) - 'a' ) < 26U )
-
-#define ft_isalpha( x ) ( ft_isupper( x ) || ft_islower( x ) )
-#define ft_isalnum( x ) ( ft_isdigit( x ) || ft_isalpha( x ) )
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /**** ****/
- /**** ****/
- /**** C H A R M A P S ****/
- /**** ****/
- /**** ****/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
- /* handle to internal charmap object */
- typedef struct FT_CMapRec_* FT_CMap;
-
- /* handle to charmap class structure */
- typedef const struct FT_CMap_ClassRec_* FT_CMap_Class;
-
- /* internal charmap object structure */
- typedef struct FT_CMapRec_
- {
- FT_CharMapRec charmap;
- FT_CMap_Class clazz;
-
- } FT_CMapRec;
-
- /* typecast any pointer to a charmap handle */
-#define FT_CMAP( x ) ( (FT_CMap)( x ) )
-
- /* obvious macros */
-#define FT_CMAP_PLATFORM_ID( x ) FT_CMAP( x )->charmap.platform_id
-#define FT_CMAP_ENCODING_ID( x ) FT_CMAP( x )->charmap.encoding_id
-#define FT_CMAP_ENCODING( x ) FT_CMAP( x )->charmap.encoding
-#define FT_CMAP_FACE( x ) FT_CMAP( x )->charmap.face
-
-
- /* class method definitions */
- typedef FT_Error
- (*FT_CMap_InitFunc)( FT_CMap cmap,
- FT_Pointer init_data );
-
- typedef void
- (*FT_CMap_DoneFunc)( FT_CMap cmap );
-
- typedef FT_UInt
- (*FT_CMap_CharIndexFunc)( FT_CMap cmap,
- FT_UInt32 char_code );
-
- typedef FT_UInt
- (*FT_CMap_CharNextFunc)( FT_CMap cmap,
- FT_UInt32 *achar_code );
-
- typedef FT_UInt
- (*FT_CMap_CharVarIndexFunc)( FT_CMap cmap,
- FT_CMap unicode_cmap,
- FT_UInt32 char_code,
- FT_UInt32 variant_selector );
-
- typedef FT_Int
- (*FT_CMap_CharVarIsDefaultFunc)( FT_CMap cmap,
- FT_UInt32 char_code,
- FT_UInt32 variant_selector );
-
- typedef FT_UInt32 *
- (*FT_CMap_VariantListFunc)( FT_CMap cmap,
- FT_Memory mem );
-
- typedef FT_UInt32 *
- (*FT_CMap_CharVariantListFunc)( FT_CMap cmap,
- FT_Memory mem,
- FT_UInt32 char_code );
-
- typedef FT_UInt32 *
- (*FT_CMap_VariantCharListFunc)( FT_CMap cmap,
- FT_Memory mem,
- FT_UInt32 variant_selector );
-
-
- typedef struct FT_CMap_ClassRec_
- {
- FT_ULong size;
-
- FT_CMap_InitFunc init;
- FT_CMap_DoneFunc done;
- FT_CMap_CharIndexFunc char_index;
- FT_CMap_CharNextFunc char_next;
-
- /* Subsequent entries are special ones for format 14 -- the variant */
- /* selector subtable which behaves like no other */
-
- FT_CMap_CharVarIndexFunc char_var_index;
- FT_CMap_CharVarIsDefaultFunc char_var_default;
- FT_CMap_VariantListFunc variant_list;
- FT_CMap_CharVariantListFunc charvariant_list;
- FT_CMap_VariantCharListFunc variantchar_list;
-
- } FT_CMap_ClassRec;
-
-
-#define FT_DECLARE_CMAP_CLASS( class_ ) \
- FT_CALLBACK_TABLE const FT_CMap_ClassRec class_;
-
-#define FT_DEFINE_CMAP_CLASS( \
- class_, \
- size_, \
- init_, \
- done_, \
- char_index_, \
- char_next_, \
- char_var_index_, \
- char_var_default_, \
- variant_list_, \
- charvariant_list_, \
- variantchar_list_ ) \
- FT_CALLBACK_TABLE_DEF \
- const FT_CMap_ClassRec class_ = \
- { \
- size_, \
- init_, \
- done_, \
- char_index_, \
- char_next_, \
- char_var_index_, \
- char_var_default_, \
- variant_list_, \
- charvariant_list_, \
- variantchar_list_ \
- };
-
-
- /* create a new charmap and add it to charmap->face */
- FT_BASE( FT_Error )
- FT_CMap_New( FT_CMap_Class clazz,
- FT_Pointer init_data,
- FT_CharMap charmap,
- FT_CMap *acmap );
-
- /* destroy a charmap and remove it from face's list */
- FT_BASE( void )
- FT_CMap_Done( FT_CMap cmap );
-
-
- /* add LCD padding to CBox */
- FT_BASE( void )
- ft_lcd_padding( FT_BBox* cbox,
- FT_GlyphSlot slot,
- FT_Render_Mode mode );
-
-#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
-
- typedef void (*FT_Bitmap_LcdFilterFunc)( FT_Bitmap* bitmap,
- FT_Byte* weights );
-
-
- /* This is the default LCD filter, an in-place, 5-tap FIR filter. */
- FT_BASE( void )
- ft_lcd_filter_fir( FT_Bitmap* bitmap,
- FT_LcdFiveTapFilter weights );
-
-#endif /* FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
-
- /**************************************************************************
- *
- * @struct:
- * FT_Face_InternalRec
- *
- * @description:
- * This structure contains the internal fields of each FT_Face object.
- * These fields may change between different releases of FreeType.
- *
- * @fields:
- * max_points ::
- * The maximum number of points used to store the vectorial outline of
- * any glyph in this face. If this value cannot be known in advance,
- * or if the face isn't scalable, this should be set to 0. Only
- * relevant for scalable formats.
- *
- * max_contours ::
- * The maximum number of contours used to store the vectorial outline
- * of any glyph in this face. If this value cannot be known in
- * advance, or if the face isn't scalable, this should be set to 0.
- * Only relevant for scalable formats.
- *
- * transform_matrix ::
- * A 2x2 matrix of 16.16 coefficients used to transform glyph outlines
- * after they are loaded from the font. Only used by the convenience
- * functions.
- *
- * transform_delta ::
- * A translation vector used to transform glyph outlines after they are
- * loaded from the font. Only used by the convenience functions.
- *
- * transform_flags ::
- * Some flags used to classify the transform. Only used by the
- * convenience functions.
- *
- * services ::
- * A cache for frequently used services. It should be only accessed
- * with the macro `FT_FACE_LOOKUP_SERVICE`.
- *
- * incremental_interface ::
- * If non-null, the interface through which glyph data and metrics are
- * loaded incrementally for faces that do not provide all of this data
- * when first opened. This field exists only if
- * @FT_CONFIG_OPTION_INCREMENTAL is defined.
- *
- * no_stem_darkening ::
- * Overrides the module-level default, see @stem-darkening[cff], for
- * example. FALSE and TRUE toggle stem darkening on and off,
- * respectively, value~-1 means to use the module/driver default.
- *
- * random_seed ::
- * If positive, override the seed value for the CFF 'random' operator.
- * Value~0 means to use the font's value. Value~-1 means to use the
- * CFF driver's default.
- *
- * lcd_weights ::
- * lcd_filter_func ::
- * These fields specify the LCD filtering weights and callback function
- * for ClearType-style subpixel rendering.
- *
- * refcount ::
- * A counter initialized to~1 at the time an @FT_Face structure is
- * created. @FT_Reference_Face increments this counter, and
- * @FT_Done_Face only destroys a face if the counter is~1, otherwise it
- * simply decrements it.
- */
- typedef struct FT_Face_InternalRec_
- {
- FT_Matrix transform_matrix;
- FT_Vector transform_delta;
- FT_Int transform_flags;
-
- FT_ServiceCacheRec services;
-
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- FT_Incremental_InterfaceRec* incremental_interface;
-#endif
-
- FT_Char no_stem_darkening;
- FT_Int32 random_seed;
-
-#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
- FT_LcdFiveTapFilter lcd_weights; /* filter weights, if any */
- FT_Bitmap_LcdFilterFunc lcd_filter_func; /* filtering callback */
-#endif
-
- FT_Int refcount;
-
- } FT_Face_InternalRec;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_Slot_InternalRec
- *
- * @description:
- * This structure contains the internal fields of each FT_GlyphSlot
- * object. These fields may change between different releases of
- * FreeType.
- *
- * @fields:
- * loader ::
- * The glyph loader object used to load outlines into the glyph slot.
- *
- * flags ::
- * Possible values are zero or FT_GLYPH_OWN_BITMAP. The latter
- * indicates that the FT_GlyphSlot structure owns the bitmap buffer.
- *
- * glyph_transformed ::
- * Boolean. Set to TRUE when the loaded glyph must be transformed
- * through a specific font transformation. This is _not_ the same as
- * the face transform set through FT_Set_Transform().
- *
- * glyph_matrix ::
- * The 2x2 matrix corresponding to the glyph transformation, if
- * necessary.
- *
- * glyph_delta ::
- * The 2d translation vector corresponding to the glyph transformation,
- * if necessary.
- *
- * glyph_hints ::
- * Format-specific glyph hints management.
- *
- * load_flags ::
- * The load flags passed as an argument to @FT_Load_Glyph while
- * initializing the glyph slot.
- */
-
-#define FT_GLYPH_OWN_BITMAP 0x1U
-#define FT_GLYPH_OWN_GZIP_SVG 0x2U
-
- typedef struct FT_Slot_InternalRec_
- {
- FT_GlyphLoader loader;
- FT_UInt flags;
- FT_Bool glyph_transformed;
- FT_Matrix glyph_matrix;
- FT_Vector glyph_delta;
- void* glyph_hints;
-
- FT_Int32 load_flags;
-
- } FT_GlyphSlot_InternalRec;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_Size_InternalRec
- *
- * @description:
- * This structure contains the internal fields of each FT_Size object.
- *
- * @fields:
- * module_data ::
- * Data specific to a driver module.
- *
- * autohint_mode ::
- * The used auto-hinting mode.
- *
- * autohint_metrics ::
- * Metrics used by the auto-hinter.
- *
- */
-
- typedef struct FT_Size_InternalRec_
- {
- void* module_data;
-
- FT_Render_Mode autohint_mode;
- FT_Size_Metrics autohint_metrics;
-
- } FT_Size_InternalRec;
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /**** ****/
- /**** ****/
- /**** M O D U L E S ****/
- /**** ****/
- /**** ****/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_ModuleRec
- *
- * @description:
- * A module object instance.
- *
- * @fields:
- * clazz ::
- * A pointer to the module's class.
- *
- * library ::
- * A handle to the parent library object.
- *
- * memory ::
- * A handle to the memory manager.
- */
- typedef struct FT_ModuleRec_
- {
- FT_Module_Class* clazz;
- FT_Library library;
- FT_Memory memory;
-
- } FT_ModuleRec;
-
-
- /* typecast an object to an FT_Module */
-#define FT_MODULE( x ) ( (FT_Module)(x) )
-
-#define FT_MODULE_CLASS( x ) FT_MODULE( x )->clazz
-#define FT_MODULE_LIBRARY( x ) FT_MODULE( x )->library
-#define FT_MODULE_MEMORY( x ) FT_MODULE( x )->memory
-
-
-#define FT_MODULE_IS_DRIVER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
- FT_MODULE_FONT_DRIVER )
-
-#define FT_MODULE_IS_RENDERER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
- FT_MODULE_RENDERER )
-
-#define FT_MODULE_IS_HINTER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
- FT_MODULE_HINTER )
-
-#define FT_MODULE_IS_STYLER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
- FT_MODULE_STYLER )
-
-#define FT_DRIVER_IS_SCALABLE( x ) ( FT_MODULE_CLASS( x )->module_flags & \
- FT_MODULE_DRIVER_SCALABLE )
-
-#define FT_DRIVER_USES_OUTLINES( x ) !( FT_MODULE_CLASS( x )->module_flags & \
- FT_MODULE_DRIVER_NO_OUTLINES )
-
-#define FT_DRIVER_HAS_HINTER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
- FT_MODULE_DRIVER_HAS_HINTER )
-
-#define FT_DRIVER_HINTS_LIGHTLY( x ) ( FT_MODULE_CLASS( x )->module_flags & \
- FT_MODULE_DRIVER_HINTS_LIGHTLY )
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_Module_Interface
- *
- * @description:
- * Finds a module and returns its specific interface as a typeless
- * pointer.
- *
- * @input:
- * library ::
- * A handle to the library object.
- *
- * module_name ::
- * The module's name (as an ASCII string).
- *
- * @return:
- * A module-specific interface if available, 0 otherwise.
- *
- * @note:
- * You should better be familiar with FreeType internals to know which
- * module to look for, and what its interface is :-)
- */
- FT_BASE( const void* )
- FT_Get_Module_Interface( FT_Library library,
- const char* mod_name );
-
- FT_BASE( FT_Pointer )
- ft_module_get_service( FT_Module module,
- const char* service_id,
- FT_Bool global );
-
-#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
- FT_BASE( FT_Error )
- ft_property_string_set( FT_Library library,
- const FT_String* module_name,
- const FT_String* property_name,
- FT_String* value );
-#endif
-
- /* */
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /**** ****/
- /**** ****/
- /**** F A C E, S I Z E & G L Y P H S L O T O B J E C T S ****/
- /**** ****/
- /**** ****/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
- /* a few macros used to perform easy typecasts with minimal brain damage */
-
-#define FT_FACE( x ) ( (FT_Face)(x) )
-#define FT_SIZE( x ) ( (FT_Size)(x) )
-#define FT_SLOT( x ) ( (FT_GlyphSlot)(x) )
-
-#define FT_FACE_DRIVER( x ) FT_FACE( x )->driver
-#define FT_FACE_LIBRARY( x ) FT_FACE_DRIVER( x )->root.library
-#define FT_FACE_MEMORY( x ) FT_FACE( x )->memory
-#define FT_FACE_STREAM( x ) FT_FACE( x )->stream
-
-
- /**************************************************************************
- *
- * @function:
- * FT_New_GlyphSlot
- *
- * @description:
- * It is sometimes useful to have more than one glyph slot for a given
- * face object. This function is used to create additional slots. All
- * of them are automatically discarded when the face is destroyed.
- *
- * @input:
- * face ::
- * A handle to a parent face object.
- *
- * @output:
- * aslot ::
- * A handle to a new glyph slot object.
- *
- * @return:
- * FreeType error code. 0 means success.
- */
- FT_BASE( FT_Error )
- FT_New_GlyphSlot( FT_Face face,
- FT_GlyphSlot *aslot );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Done_GlyphSlot
- *
- * @description:
- * Destroys a given glyph slot. Remember however that all slots are
- * automatically destroyed with its parent. Using this function is not
- * always mandatory.
- *
- * @input:
- * slot ::
- * A handle to a target glyph slot.
- */
- FT_BASE( void )
- FT_Done_GlyphSlot( FT_GlyphSlot slot );
-
- /* */
-
-#define FT_REQUEST_WIDTH( req ) \
- ( (req)->horiResolution \
- ? ( (req)->width * (FT_Pos)(req)->horiResolution + 36 ) / 72 \
- : (req)->width )
-
-#define FT_REQUEST_HEIGHT( req ) \
- ( (req)->vertResolution \
- ? ( (req)->height * (FT_Pos)(req)->vertResolution + 36 ) / 72 \
- : (req)->height )
-
-
- /* Set the metrics according to a bitmap strike. */
- FT_BASE( void )
- FT_Select_Metrics( FT_Face face,
- FT_ULong strike_index );
-
-
- /* Set the metrics according to a size request. */
- FT_BASE( FT_Error )
- FT_Request_Metrics( FT_Face face,
- FT_Size_Request req );
-
-
- /* Match a size request against `available_sizes'. */
- FT_BASE( FT_Error )
- FT_Match_Size( FT_Face face,
- FT_Size_Request req,
- FT_Bool ignore_width,
- FT_ULong* size_index );
-
-
- /* Use the horizontal metrics to synthesize the vertical metrics. */
- /* If `advance' is zero, it is also synthesized. */
- FT_BASE( void )
- ft_synthesize_vertical_metrics( FT_Glyph_Metrics* metrics,
- FT_Pos advance );
-
-
- /* Free the bitmap of a given glyphslot when needed (i.e., only when it */
- /* was allocated with ft_glyphslot_alloc_bitmap). */
- FT_BASE( void )
- ft_glyphslot_free_bitmap( FT_GlyphSlot slot );
-
-
- /* Preset bitmap metrics of an outline glyphslot prior to rendering */
- /* and check whether the truncated bbox is too large for rendering. */
- FT_BASE( FT_Bool )
- ft_glyphslot_preset_bitmap( FT_GlyphSlot slot,
- FT_Render_Mode mode,
- const FT_Vector* origin );
-
- /* Allocate a new bitmap buffer in a glyph slot. */
- FT_BASE( FT_Error )
- ft_glyphslot_alloc_bitmap( FT_GlyphSlot slot,
- FT_ULong size );
-
-
- /* Set the bitmap buffer in a glyph slot to a given pointer. The buffer */
- /* will not be freed by a later call to ft_glyphslot_free_bitmap. */
- FT_BASE( void )
- ft_glyphslot_set_bitmap( FT_GlyphSlot slot,
- FT_Byte* buffer );
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /**** ****/
- /**** ****/
- /**** R E N D E R E R S ****/
- /**** ****/
- /**** ****/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
-#define FT_RENDERER( x ) ( (FT_Renderer)(x) )
-#define FT_GLYPH( x ) ( (FT_Glyph)(x) )
-#define FT_BITMAP_GLYPH( x ) ( (FT_BitmapGlyph)(x) )
-#define FT_OUTLINE_GLYPH( x ) ( (FT_OutlineGlyph)(x) )
-
-
- typedef struct FT_RendererRec_
- {
- FT_ModuleRec root;
- FT_Renderer_Class* clazz;
- FT_Glyph_Format glyph_format;
- FT_Glyph_Class glyph_class;
-
- FT_Raster raster;
- FT_Raster_Render_Func raster_render;
- FT_Renderer_RenderFunc render;
-
- } FT_RendererRec;
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /**** ****/
- /**** ****/
- /**** F O N T D R I V E R S ****/
- /**** ****/
- /**** ****/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /* typecast a module into a driver easily */
-#define FT_DRIVER( x ) ( (FT_Driver)(x) )
-
- /* typecast a module as a driver, and get its driver class */
-#define FT_DRIVER_CLASS( x ) FT_DRIVER( x )->clazz
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_DriverRec
- *
- * @description:
- * The root font driver class. A font driver is responsible for managing
- * and loading font files of a given format.
- *
- * @fields:
- * root ::
- * Contains the fields of the root module class.
- *
- * clazz ::
- * A pointer to the font driver's class. Note that this is NOT
- * root.clazz. 'class' wasn't used as it is a reserved word in C++.
- *
- * faces_list ::
- * The list of faces currently opened by this driver.
- *
- * glyph_loader ::
- * Unused. Used to be glyph loader for all faces managed by this
- * driver.
- */
- typedef struct FT_DriverRec_
- {
- FT_ModuleRec root;
- FT_Driver_Class clazz;
- FT_ListRec faces_list;
- FT_GlyphLoader glyph_loader;
-
- } FT_DriverRec;
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /**** ****/
- /**** ****/
- /**** L I B R A R I E S ****/
- /**** ****/
- /**** ****/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_LibraryRec
- *
- * @description:
- * The FreeType library class. This is the root of all FreeType data.
- * Use FT_New_Library() to create a library object, and FT_Done_Library()
- * to discard it and all child objects.
- *
- * @fields:
- * memory ::
- * The library's memory object. Manages memory allocation.
- *
- * version_major ::
- * The major version number of the library.
- *
- * version_minor ::
- * The minor version number of the library.
- *
- * version_patch ::
- * The current patch level of the library.
- *
- * num_modules ::
- * The number of modules currently registered within this library.
- * This is set to 0 for new libraries. New modules are added through
- * the FT_Add_Module() API function.
- *
- * modules ::
- * A table used to store handles to the currently registered
- * modules. Note that each font driver contains a list of its opened
- * faces.
- *
- * renderers ::
- * The list of renderers currently registered within the library.
- *
- * cur_renderer ::
- * The current outline renderer. This is a shortcut used to avoid
- * parsing the list on each call to FT_Outline_Render(). It is a
- * handle to the current renderer for the FT_GLYPH_FORMAT_OUTLINE
- * format.
- *
- * auto_hinter ::
- * The auto-hinter module interface.
- *
- * debug_hooks ::
- * An array of four function pointers that allow debuggers to hook into
- * a font format's interpreter. Currently, only the TrueType bytecode
- * debugger uses this.
- *
- * lcd_weights ::
- * The LCD filter weights for ClearType-style subpixel rendering.
- *
- * lcd_filter_func ::
- * The LCD filtering callback function for for ClearType-style subpixel
- * rendering.
- *
- * lcd_geometry ::
- * This array specifies LCD subpixel geometry and controls Harmony LCD
- * rendering technique, alternative to ClearType.
- *
- * pic_container ::
- * Contains global structs and tables, instead of defining them
- * globally.
- *
- * refcount ::
- * A counter initialized to~1 at the time an @FT_Library structure is
- * created. @FT_Reference_Library increments this counter, and
- * @FT_Done_Library only destroys a library if the counter is~1,
- * otherwise it simply decrements it.
- */
- typedef struct FT_LibraryRec_
- {
- FT_Memory memory; /* library's memory manager */
-
- FT_Int version_major;
- FT_Int version_minor;
- FT_Int version_patch;
-
- FT_UInt num_modules;
- FT_Module modules[FT_MAX_MODULES]; /* module objects */
-
- FT_ListRec renderers; /* list of renderers */
- FT_Renderer cur_renderer; /* current outline renderer */
- FT_Module auto_hinter;
-
- FT_DebugHook_Func debug_hooks[4];
-
-#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
- FT_LcdFiveTapFilter lcd_weights; /* filter weights, if any */
- FT_Bitmap_LcdFilterFunc lcd_filter_func; /* filtering callback */
-#else
- FT_Vector lcd_geometry[3]; /* RGB subpixel positions */
-#endif
-
- FT_Int refcount;
-
- } FT_LibraryRec;
-
-
- FT_BASE( FT_Renderer )
- FT_Lookup_Renderer( FT_Library library,
- FT_Glyph_Format format,
- FT_ListNode* node );
-
- FT_BASE( FT_Error )
- FT_Render_Glyph_Internal( FT_Library library,
- FT_GlyphSlot slot,
- FT_Render_Mode render_mode );
-
- typedef const char*
- (*FT_Face_GetPostscriptNameFunc)( FT_Face face );
-
- typedef FT_Error
- (*FT_Face_GetGlyphNameFunc)( FT_Face face,
- FT_UInt glyph_index,
- FT_Pointer buffer,
- FT_UInt buffer_max );
-
- typedef FT_UInt
- (*FT_Face_GetGlyphNameIndexFunc)( FT_Face face,
- const FT_String* glyph_name );
-
-
-#ifndef FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM
-
- /**************************************************************************
- *
- * @function:
- * FT_New_Memory
- *
- * @description:
- * Creates a new memory object.
- *
- * @return:
- * A pointer to the new memory object. 0 in case of error.
- */
- FT_BASE( FT_Memory )
- FT_New_Memory( void );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Done_Memory
- *
- * @description:
- * Discards memory manager.
- *
- * @input:
- * memory ::
- * A handle to the memory manager.
- */
- FT_BASE( void )
- FT_Done_Memory( FT_Memory memory );
-
-#endif /* !FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM */
-
-
- /* Define default raster's interface. The default raster is located in */
- /* `src/base/ftraster.c'. */
- /* */
- /* Client applications can register new rasters through the */
- /* FT_Set_Raster() API. */
-
-#ifndef FT_NO_DEFAULT_RASTER
- FT_EXPORT_VAR( FT_Raster_Funcs ) ft_default_raster;
-#endif
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_DEFINE_OUTLINE_FUNCS
- *
- * @description:
- * Used to initialize an instance of FT_Outline_Funcs struct. The struct
- * will be allocated in the global scope (or the scope where the macro is
- * used).
- */
-#define FT_DEFINE_OUTLINE_FUNCS( \
- class_, \
- move_to_, \
- line_to_, \
- conic_to_, \
- cubic_to_, \
- shift_, \
- delta_ ) \
- static const FT_Outline_Funcs class_ = \
- { \
- move_to_, \
- line_to_, \
- conic_to_, \
- cubic_to_, \
- shift_, \
- delta_ \
- };
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_DEFINE_RASTER_FUNCS
- *
- * @description:
- * Used to initialize an instance of FT_Raster_Funcs struct. The struct
- * will be allocated in the global scope (or the scope where the macro is
- * used).
- */
-#define FT_DEFINE_RASTER_FUNCS( \
- class_, \
- glyph_format_, \
- raster_new_, \
- raster_reset_, \
- raster_set_mode_, \
- raster_render_, \
- raster_done_ ) \
- const FT_Raster_Funcs class_ = \
- { \
- glyph_format_, \
- raster_new_, \
- raster_reset_, \
- raster_set_mode_, \
- raster_render_, \
- raster_done_ \
- };
-
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_DEFINE_GLYPH
- *
- * @description:
- * The struct will be allocated in the global scope (or the scope where
- * the macro is used).
- */
-#define FT_DECLARE_GLYPH( class_ ) \
- FT_CALLBACK_TABLE const FT_Glyph_Class class_;
-
-#define FT_DEFINE_GLYPH( \
- class_, \
- size_, \
- format_, \
- init_, \
- done_, \
- copy_, \
- transform_, \
- bbox_, \
- prepare_ ) \
- FT_CALLBACK_TABLE_DEF \
- const FT_Glyph_Class class_ = \
- { \
- size_, \
- format_, \
- init_, \
- done_, \
- copy_, \
- transform_, \
- bbox_, \
- prepare_ \
- };
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_DECLARE_RENDERER
- *
- * @description:
- * Used to create a forward declaration of a FT_Renderer_Class struct
- * instance.
- *
- * @macro:
- * FT_DEFINE_RENDERER
- *
- * @description:
- * Used to initialize an instance of FT_Renderer_Class struct.
- *
- * The struct will be allocated in the global scope (or the scope where
- * the macro is used).
- */
-#define FT_DECLARE_RENDERER( class_ ) \
- FT_EXPORT_VAR( const FT_Renderer_Class ) class_;
-
-#define FT_DEFINE_RENDERER( \
- class_, \
- flags_, \
- size_, \
- name_, \
- version_, \
- requires_, \
- interface_, \
- init_, \
- done_, \
- get_interface_, \
- glyph_format_, \
- render_glyph_, \
- transform_glyph_, \
- get_glyph_cbox_, \
- set_mode_, \
- raster_class_ ) \
- FT_CALLBACK_TABLE_DEF \
- const FT_Renderer_Class class_ = \
- { \
- FT_DEFINE_ROOT_MODULE( flags_, \
- size_, \
- name_, \
- version_, \
- requires_, \
- interface_, \
- init_, \
- done_, \
- get_interface_ ) \
- glyph_format_, \
- \
- render_glyph_, \
- transform_glyph_, \
- get_glyph_cbox_, \
- set_mode_, \
- \
- raster_class_ \
- };
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_DECLARE_MODULE
- *
- * @description:
- * Used to create a forward declaration of a FT_Module_Class struct
- * instance.
- *
- * @macro:
- * FT_DEFINE_MODULE
- *
- * @description:
- * Used to initialize an instance of an FT_Module_Class struct.
- *
- * The struct will be allocated in the global scope (or the scope where
- * the macro is used).
- *
- * @macro:
- * FT_DEFINE_ROOT_MODULE
- *
- * @description:
- * Used to initialize an instance of an FT_Module_Class struct inside
- * another struct that contains it or in a function that initializes that
- * containing struct.
- */
-#define FT_DECLARE_MODULE( class_ ) \
- FT_CALLBACK_TABLE \
- const FT_Module_Class class_;
-
-#define FT_DEFINE_ROOT_MODULE( \
- flags_, \
- size_, \
- name_, \
- version_, \
- requires_, \
- interface_, \
- init_, \
- done_, \
- get_interface_ ) \
- { \
- flags_, \
- size_, \
- \
- name_, \
- version_, \
- requires_, \
- \
- interface_, \
- \
- init_, \
- done_, \
- get_interface_, \
- },
-
-#define FT_DEFINE_MODULE( \
- class_, \
- flags_, \
- size_, \
- name_, \
- version_, \
- requires_, \
- interface_, \
- init_, \
- done_, \
- get_interface_ ) \
- FT_CALLBACK_TABLE_DEF \
- const FT_Module_Class class_ = \
- { \
- flags_, \
- size_, \
- \
- name_, \
- version_, \
- requires_, \
- \
- interface_, \
- \
- init_, \
- done_, \
- get_interface_, \
- };
-
-
-FT_END_HEADER
-
-#endif /* FTOBJS_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/ftpsprop.h b/contrib/libs/freetype/include/freetype/internal/ftpsprop.h
deleted file mode 100644
index 4f11aa16ba..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/ftpsprop.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/****************************************************************************
- *
- * ftpsprop.h
- *
- * Get and set properties of PostScript drivers (specification).
- *
- * Copyright (C) 2017-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTPSPROP_H_
-#define FTPSPROP_H_
-
-
-#include <freetype/freetype.h>
-
-
-FT_BEGIN_HEADER
-
-
- FT_BASE_CALLBACK( FT_Error )
- ps_property_set( FT_Module module, /* PS_Driver */
- const char* property_name,
- const void* value,
- FT_Bool value_is_string );
-
- FT_BASE_CALLBACK( FT_Error )
- ps_property_get( FT_Module module, /* PS_Driver */
- const char* property_name,
- void* value );
-
-
-FT_END_HEADER
-
-
-#endif /* FTPSPROP_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/ftrfork.h b/contrib/libs/freetype/include/freetype/internal/ftrfork.h
deleted file mode 100644
index 05c1d6c48b..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/ftrfork.h
+++ /dev/null
@@ -1,245 +0,0 @@
-/****************************************************************************
- *
- * ftrfork.h
- *
- * Embedded resource forks accessor (specification).
- *
- * Copyright (C) 2004-2024 by
- * Masatake YAMATO and Redhat K.K.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-/****************************************************************************
- * Development of the code in this file is support of
- * Information-technology Promotion Agency, Japan.
- */
-
-
-#ifndef FTRFORK_H_
-#define FTRFORK_H_
-
-
-#include <freetype/internal/ftobjs.h>
-
-
-FT_BEGIN_HEADER
-
-
- /* Number of guessing rules supported in `FT_Raccess_Guess'. */
- /* Don't forget to increment the number if you add a new guessing rule. */
-#define FT_RACCESS_N_RULES 9
-
-
- /* A structure to describe a reference in a resource by its resource ID */
- /* and internal offset. The `POST' resource expects to be concatenated */
- /* by the order of resource IDs instead of its appearance in the file. */
-
- typedef struct FT_RFork_Ref_
- {
- FT_Short res_id;
- FT_Long offset;
-
- } FT_RFork_Ref;
-
-
-#ifdef FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK
- typedef FT_Error
- (*ft_raccess_guess_func)( FT_Library library,
- FT_Stream stream,
- char *base_file_name,
- char **result_file_name,
- FT_Long *result_offset );
-
- typedef enum FT_RFork_Rule_ {
- FT_RFork_Rule_invalid = -2,
- FT_RFork_Rule_uknown, /* -1 */
- FT_RFork_Rule_apple_double,
- FT_RFork_Rule_apple_single,
- FT_RFork_Rule_darwin_ufs_export,
- FT_RFork_Rule_darwin_newvfs,
- FT_RFork_Rule_darwin_hfsplus,
- FT_RFork_Rule_vfat,
- FT_RFork_Rule_linux_cap,
- FT_RFork_Rule_linux_double,
- FT_RFork_Rule_linux_netatalk
- } FT_RFork_Rule;
-
- /* For fast translation between rule index and rule type,
- * the macros FT_RFORK_xxx should be kept consistent with the
- * raccess_guess_funcs table
- */
- typedef struct ft_raccess_guess_rec_ {
- ft_raccess_guess_func func;
- FT_RFork_Rule type;
- } ft_raccess_guess_rec;
-
-
-#define CONST_FT_RFORK_RULE_ARRAY_BEGIN( name, type ) \
- static const type name[] = {
-#define CONST_FT_RFORK_RULE_ARRAY_ENTRY( func_suffix, type_suffix ) \
- { raccess_guess_ ## func_suffix, \
- FT_RFork_Rule_ ## type_suffix },
- /* this array is a storage, thus a final `;' is needed */
-#define CONST_FT_RFORK_RULE_ARRAY_END };
-
-#endif /* FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK */
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Raccess_Guess
- *
- * @description:
- * Guess a file name and offset where the actual resource fork is stored.
- * The macro FT_RACCESS_N_RULES holds the number of guessing rules; the
- * guessed result for the Nth rule is represented as a triplet: a new
- * file name (new_names[N]), a file offset (offsets[N]), and an error
- * code (errors[N]).
- *
- * @input:
- * library ::
- * A FreeType library instance.
- *
- * stream ::
- * A file stream containing the resource fork.
- *
- * base_name ::
- * The (base) file name of the resource fork used for some guessing
- * rules.
- *
- * @output:
- * new_names ::
- * An array of guessed file names in which the resource forks may
- * exist. If 'new_names[N]' is `NULL`, the guessed file name is equal
- * to `base_name`.
- *
- * offsets ::
- * An array of guessed file offsets. 'offsets[N]' holds the file
- * offset of the possible start of the resource fork in file
- * 'new_names[N]'.
- *
- * errors ::
- * An array of FreeType error codes. 'errors[N]' is the error code of
- * Nth guessing rule function. If 'errors[N]' is not FT_Err_Ok,
- * 'new_names[N]' and 'offsets[N]' are meaningless.
- */
- FT_BASE( void )
- FT_Raccess_Guess( FT_Library library,
- FT_Stream stream,
- char* base_name,
- char** new_names,
- FT_Long* offsets,
- FT_Error* errors );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Raccess_Get_HeaderInfo
- *
- * @description:
- * Get the information from the header of resource fork. The information
- * includes the file offset where the resource map starts, and the file
- * offset where the resource data starts. `FT_Raccess_Get_DataOffsets`
- * requires these two data.
- *
- * @input:
- * library ::
- * A FreeType library instance.
- *
- * stream ::
- * A file stream containing the resource fork.
- *
- * rfork_offset ::
- * The file offset where the resource fork starts.
- *
- * @output:
- * map_offset ::
- * The file offset where the resource map starts.
- *
- * rdata_pos ::
- * The file offset where the resource data starts.
- *
- * @return:
- * FreeType error code. FT_Err_Ok means success.
- */
- FT_BASE( FT_Error )
- FT_Raccess_Get_HeaderInfo( FT_Library library,
- FT_Stream stream,
- FT_Long rfork_offset,
- FT_Long *map_offset,
- FT_Long *rdata_pos );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Raccess_Get_DataOffsets
- *
- * @description:
- * Get the data offsets for a tag in a resource fork. Offsets are stored
- * in an array because, in some cases, resources in a resource fork have
- * the same tag.
- *
- * @input:
- * library ::
- * A FreeType library instance.
- *
- * stream ::
- * A file stream containing the resource fork.
- *
- * map_offset ::
- * The file offset where the resource map starts.
- *
- * rdata_pos ::
- * The file offset where the resource data starts.
- *
- * tag ::
- * The resource tag.
- *
- * sort_by_res_id ::
- * A Boolean to sort the fragmented resource by their ids. The
- * fragmented resources for 'POST' resource should be sorted to restore
- * Type1 font properly. For 'sfnt' resources, sorting may induce a
- * different order of the faces in comparison to that by QuickDraw API.
- *
- * @output:
- * offsets ::
- * The stream offsets for the resource data specified by 'tag'. This
- * array is allocated by the function, so you have to call @ft_mem_free
- * after use.
- *
- * count ::
- * The length of offsets array.
- *
- * @return:
- * FreeType error code. FT_Err_Ok means success.
- *
- * @note:
- * Normally you should use `FT_Raccess_Get_HeaderInfo` to get the value
- * for `map_offset` and `rdata_pos`.
- */
- FT_BASE( FT_Error )
- FT_Raccess_Get_DataOffsets( FT_Library library,
- FT_Stream stream,
- FT_Long map_offset,
- FT_Long rdata_pos,
- FT_Long tag,
- FT_Bool sort_by_res_id,
- FT_Long **offsets,
- FT_Long *count );
-
-
-FT_END_HEADER
-
-#endif /* FTRFORK_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/ftserv.h b/contrib/libs/freetype/include/freetype/internal/ftserv.h
deleted file mode 100644
index 8c35dbd713..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/ftserv.h
+++ /dev/null
@@ -1,495 +0,0 @@
-/****************************************************************************
- *
- * ftserv.h
- *
- * The FreeType services (specification only).
- *
- * Copyright (C) 2003-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
- /**************************************************************************
- *
- * Each module can export one or more 'services'. Each service is
- * identified by a constant string and modeled by a pointer; the latter
- * generally corresponds to a structure containing function pointers.
- *
- * Note that a service's data cannot be a mere function pointer because in
- * C it is possible that function pointers might be implemented differently
- * than data pointers (e.g. 48 bits instead of 32).
- *
- */
-
-
-#ifndef FTSERV_H_
-#define FTSERV_H_
-
-#include "compiler-macros.h"
-
-FT_BEGIN_HEADER
-
- /**************************************************************************
- *
- * @macro:
- * FT_FACE_FIND_SERVICE
- *
- * @description:
- * This macro is used to look up a service from a face's driver module.
- *
- * @input:
- * face ::
- * The source face handle.
- *
- * id ::
- * A string describing the service as defined in the service's header
- * files (e.g. FT_SERVICE_ID_MULTI_MASTERS which expands to
- * 'multi-masters'). It is automatically prefixed with
- * `FT_SERVICE_ID_`.
- *
- * @output:
- * ptr ::
- * A variable that receives the service pointer. Will be `NULL` if not
- * found.
- */
-#ifdef __cplusplus
-
-#define FT_FACE_FIND_SERVICE( face, ptr, id ) \
- FT_BEGIN_STMNT \
- FT_Module module = FT_MODULE( FT_FACE( face )->driver ); \
- FT_Pointer _tmp_ = NULL; \
- FT_Pointer* _pptr_ = (FT_Pointer*)&(ptr); \
- \
- \
- if ( module->clazz->get_interface ) \
- _tmp_ = module->clazz->get_interface( module, FT_SERVICE_ID_ ## id ); \
- *_pptr_ = _tmp_; \
- FT_END_STMNT
-
-#else /* !C++ */
-
-#define FT_FACE_FIND_SERVICE( face, ptr, id ) \
- FT_BEGIN_STMNT \
- FT_Module module = FT_MODULE( FT_FACE( face )->driver ); \
- FT_Pointer _tmp_ = NULL; \
- \
- if ( module->clazz->get_interface ) \
- _tmp_ = module->clazz->get_interface( module, FT_SERVICE_ID_ ## id ); \
- ptr = _tmp_; \
- FT_END_STMNT
-
-#endif /* !C++ */
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_FACE_FIND_GLOBAL_SERVICE
- *
- * @description:
- * This macro is used to look up a service from all modules.
- *
- * @input:
- * face ::
- * The source face handle.
- *
- * id ::
- * A string describing the service as defined in the service's header
- * files (e.g. FT_SERVICE_ID_MULTI_MASTERS which expands to
- * 'multi-masters'). It is automatically prefixed with
- * `FT_SERVICE_ID_`.
- *
- * @output:
- * ptr ::
- * A variable that receives the service pointer. Will be `NULL` if not
- * found.
- */
-#ifdef __cplusplus
-
-#define FT_FACE_FIND_GLOBAL_SERVICE( face, ptr, id ) \
- FT_BEGIN_STMNT \
- FT_Module module = FT_MODULE( FT_FACE( face )->driver ); \
- FT_Pointer _tmp_; \
- FT_Pointer* _pptr_ = (FT_Pointer*)&(ptr); \
- \
- \
- _tmp_ = ft_module_get_service( module, FT_SERVICE_ID_ ## id, 1 ); \
- *_pptr_ = _tmp_; \
- FT_END_STMNT
-
-#else /* !C++ */
-
-#define FT_FACE_FIND_GLOBAL_SERVICE( face, ptr, id ) \
- FT_BEGIN_STMNT \
- FT_Module module = FT_MODULE( FT_FACE( face )->driver ); \
- FT_Pointer _tmp_; \
- \
- \
- _tmp_ = ft_module_get_service( module, FT_SERVICE_ID_ ## id, 1 ); \
- ptr = _tmp_; \
- FT_END_STMNT
-
-#endif /* !C++ */
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** S E R V I C E D E S C R I P T O R S *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- /*
- * The following structure is used to _describe_ a given service to the
- * library. This is useful to build simple static service lists.
- */
- typedef struct FT_ServiceDescRec_
- {
- const char* serv_id; /* service name */
- const void* serv_data; /* service pointer/data */
-
- } FT_ServiceDescRec;
-
- typedef const FT_ServiceDescRec* FT_ServiceDesc;
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_DEFINE_SERVICEDESCREC1
- * FT_DEFINE_SERVICEDESCREC2
- * FT_DEFINE_SERVICEDESCREC3
- * FT_DEFINE_SERVICEDESCREC4
- * FT_DEFINE_SERVICEDESCREC5
- * FT_DEFINE_SERVICEDESCREC6
- * FT_DEFINE_SERVICEDESCREC7
- * FT_DEFINE_SERVICEDESCREC8
- * FT_DEFINE_SERVICEDESCREC9
- * FT_DEFINE_SERVICEDESCREC10
- *
- * @description:
- * Used to initialize an array of FT_ServiceDescRec structures.
- *
- * The array will be allocated in the global scope (or the scope where
- * the macro is used).
- */
-#define FT_DEFINE_SERVICEDESCREC1( class_, \
- serv_id_1, serv_data_1 ) \
- static const FT_ServiceDescRec class_[] = \
- { \
- { serv_id_1, serv_data_1 }, \
- { NULL, NULL } \
- };
-
-#define FT_DEFINE_SERVICEDESCREC2( class_, \
- serv_id_1, serv_data_1, \
- serv_id_2, serv_data_2 ) \
- static const FT_ServiceDescRec class_[] = \
- { \
- { serv_id_1, serv_data_1 }, \
- { serv_id_2, serv_data_2 }, \
- { NULL, NULL } \
- };
-
-#define FT_DEFINE_SERVICEDESCREC3( class_, \
- serv_id_1, serv_data_1, \
- serv_id_2, serv_data_2, \
- serv_id_3, serv_data_3 ) \
- static const FT_ServiceDescRec class_[] = \
- { \
- { serv_id_1, serv_data_1 }, \
- { serv_id_2, serv_data_2 }, \
- { serv_id_3, serv_data_3 }, \
- { NULL, NULL } \
- };
-
-#define FT_DEFINE_SERVICEDESCREC4( class_, \
- serv_id_1, serv_data_1, \
- serv_id_2, serv_data_2, \
- serv_id_3, serv_data_3, \
- serv_id_4, serv_data_4 ) \
- static const FT_ServiceDescRec class_[] = \
- { \
- { serv_id_1, serv_data_1 }, \
- { serv_id_2, serv_data_2 }, \
- { serv_id_3, serv_data_3 }, \
- { serv_id_4, serv_data_4 }, \
- { NULL, NULL } \
- };
-
-#define FT_DEFINE_SERVICEDESCREC5( class_, \
- serv_id_1, serv_data_1, \
- serv_id_2, serv_data_2, \
- serv_id_3, serv_data_3, \
- serv_id_4, serv_data_4, \
- serv_id_5, serv_data_5 ) \
- static const FT_ServiceDescRec class_[] = \
- { \
- { serv_id_1, serv_data_1 }, \
- { serv_id_2, serv_data_2 }, \
- { serv_id_3, serv_data_3 }, \
- { serv_id_4, serv_data_4 }, \
- { serv_id_5, serv_data_5 }, \
- { NULL, NULL } \
- };
-
-#define FT_DEFINE_SERVICEDESCREC6( class_, \
- serv_id_1, serv_data_1, \
- serv_id_2, serv_data_2, \
- serv_id_3, serv_data_3, \
- serv_id_4, serv_data_4, \
- serv_id_5, serv_data_5, \
- serv_id_6, serv_data_6 ) \
- static const FT_ServiceDescRec class_[] = \
- { \
- { serv_id_1, serv_data_1 }, \
- { serv_id_2, serv_data_2 }, \
- { serv_id_3, serv_data_3 }, \
- { serv_id_4, serv_data_4 }, \
- { serv_id_5, serv_data_5 }, \
- { serv_id_6, serv_data_6 }, \
- { NULL, NULL } \
- };
-
-#define FT_DEFINE_SERVICEDESCREC7( class_, \
- serv_id_1, serv_data_1, \
- serv_id_2, serv_data_2, \
- serv_id_3, serv_data_3, \
- serv_id_4, serv_data_4, \
- serv_id_5, serv_data_5, \
- serv_id_6, serv_data_6, \
- serv_id_7, serv_data_7 ) \
- static const FT_ServiceDescRec class_[] = \
- { \
- { serv_id_1, serv_data_1 }, \
- { serv_id_2, serv_data_2 }, \
- { serv_id_3, serv_data_3 }, \
- { serv_id_4, serv_data_4 }, \
- { serv_id_5, serv_data_5 }, \
- { serv_id_6, serv_data_6 }, \
- { serv_id_7, serv_data_7 }, \
- { NULL, NULL } \
- };
-
-#define FT_DEFINE_SERVICEDESCREC8( class_, \
- serv_id_1, serv_data_1, \
- serv_id_2, serv_data_2, \
- serv_id_3, serv_data_3, \
- serv_id_4, serv_data_4, \
- serv_id_5, serv_data_5, \
- serv_id_6, serv_data_6, \
- serv_id_7, serv_data_7, \
- serv_id_8, serv_data_8 ) \
- static const FT_ServiceDescRec class_[] = \
- { \
- { serv_id_1, serv_data_1 }, \
- { serv_id_2, serv_data_2 }, \
- { serv_id_3, serv_data_3 }, \
- { serv_id_4, serv_data_4 }, \
- { serv_id_5, serv_data_5 }, \
- { serv_id_6, serv_data_6 }, \
- { serv_id_7, serv_data_7 }, \
- { serv_id_8, serv_data_8 }, \
- { NULL, NULL } \
- };
-
-#define FT_DEFINE_SERVICEDESCREC9( class_, \
- serv_id_1, serv_data_1, \
- serv_id_2, serv_data_2, \
- serv_id_3, serv_data_3, \
- serv_id_4, serv_data_4, \
- serv_id_5, serv_data_5, \
- serv_id_6, serv_data_6, \
- serv_id_7, serv_data_7, \
- serv_id_8, serv_data_8, \
- serv_id_9, serv_data_9 ) \
- static const FT_ServiceDescRec class_[] = \
- { \
- { serv_id_1, serv_data_1 }, \
- { serv_id_2, serv_data_2 }, \
- { serv_id_3, serv_data_3 }, \
- { serv_id_4, serv_data_4 }, \
- { serv_id_5, serv_data_5 }, \
- { serv_id_6, serv_data_6 }, \
- { serv_id_7, serv_data_7 }, \
- { serv_id_8, serv_data_8 }, \
- { serv_id_9, serv_data_9 }, \
- { NULL, NULL } \
- };
-
-#define FT_DEFINE_SERVICEDESCREC10( class_, \
- serv_id_1, serv_data_1, \
- serv_id_2, serv_data_2, \
- serv_id_3, serv_data_3, \
- serv_id_4, serv_data_4, \
- serv_id_5, serv_data_5, \
- serv_id_6, serv_data_6, \
- serv_id_7, serv_data_7, \
- serv_id_8, serv_data_8, \
- serv_id_9, serv_data_9, \
- serv_id_10, serv_data_10 ) \
- static const FT_ServiceDescRec class_[] = \
- { \
- { serv_id_1, serv_data_1 }, \
- { serv_id_2, serv_data_2 }, \
- { serv_id_3, serv_data_3 }, \
- { serv_id_4, serv_data_4 }, \
- { serv_id_5, serv_data_5 }, \
- { serv_id_6, serv_data_6 }, \
- { serv_id_7, serv_data_7 }, \
- { serv_id_8, serv_data_8 }, \
- { serv_id_9, serv_data_9 }, \
- { serv_id_10, serv_data_10 }, \
- { NULL, NULL } \
- };
-
-
- /*
- * Parse a list of FT_ServiceDescRec descriptors and look for a specific
- * service by ID. Note that the last element in the array must be { NULL,
- * NULL }, and that the function should return NULL if the service isn't
- * available.
- *
- * This function can be used by modules to implement their `get_service'
- * method.
- */
- FT_BASE( FT_Pointer )
- ft_service_list_lookup( FT_ServiceDesc service_descriptors,
- const char* service_id );
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** S E R V I C E S C A C H E *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- /*
- * This structure is used to store a cache for several frequently used
- * services. It is the type of `face->internal->services'. You should
- * only use FT_FACE_LOOKUP_SERVICE to access it.
- *
- * All fields should have the type FT_Pointer to relax compilation
- * dependencies. We assume the developer isn't completely stupid.
- *
- * Each field must be named `service_XXXX' where `XXX' corresponds to the
- * correct FT_SERVICE_ID_XXXX macro. See the definition of
- * FT_FACE_LOOKUP_SERVICE below how this is implemented.
- *
- */
- typedef struct FT_ServiceCacheRec_
- {
- FT_Pointer service_POSTSCRIPT_FONT_NAME;
- FT_Pointer service_MULTI_MASTERS;
- FT_Pointer service_METRICS_VARIATIONS;
- FT_Pointer service_GLYPH_DICT;
- FT_Pointer service_PFR_METRICS;
- FT_Pointer service_WINFNT;
-
- } FT_ServiceCacheRec, *FT_ServiceCache;
-
-
- /*
- * A magic number used within the services cache.
- */
-
- /* ensure that value `1' has the same width as a pointer */
-#define FT_SERVICE_UNAVAILABLE ((FT_Pointer)~(FT_PtrDist)1)
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_FACE_LOOKUP_SERVICE
- *
- * @description:
- * This macro is used to look up a service from a face's driver module
- * using its cache.
- *
- * @input:
- * face ::
- * The source face handle containing the cache.
- *
- * field ::
- * The field name in the cache.
- *
- * id ::
- * The service ID.
- *
- * @output:
- * ptr ::
- * A variable receiving the service data. `NULL` if not available.
- */
-#ifdef __cplusplus
-
-#define FT_FACE_LOOKUP_SERVICE( face, ptr, id ) \
- FT_BEGIN_STMNT \
- FT_Pointer svc; \
- FT_Pointer* Pptr = (FT_Pointer*)&(ptr); \
- \
- \
- svc = FT_FACE( face )->internal->services. service_ ## id; \
- if ( svc == FT_SERVICE_UNAVAILABLE ) \
- svc = NULL; \
- else if ( svc == NULL ) \
- { \
- FT_FACE_FIND_SERVICE( face, svc, id ); \
- \
- FT_FACE( face )->internal->services. service_ ## id = \
- (FT_Pointer)( svc != NULL ? svc \
- : FT_SERVICE_UNAVAILABLE ); \
- } \
- *Pptr = svc; \
- FT_END_STMNT
-
-#else /* !C++ */
-
-#define FT_FACE_LOOKUP_SERVICE( face, ptr, id ) \
- FT_BEGIN_STMNT \
- FT_Pointer svc; \
- \
- \
- svc = FT_FACE( face )->internal->services. service_ ## id; \
- if ( svc == FT_SERVICE_UNAVAILABLE ) \
- svc = NULL; \
- else if ( svc == NULL ) \
- { \
- FT_FACE_FIND_SERVICE( face, svc, id ); \
- \
- FT_FACE( face )->internal->services. service_ ## id = \
- (FT_Pointer)( svc != NULL ? svc \
- : FT_SERVICE_UNAVAILABLE ); \
- } \
- ptr = svc; \
- FT_END_STMNT
-
-#endif /* !C++ */
-
- /*
- * A macro used to define new service structure types.
- */
-
-#define FT_DEFINE_SERVICE( name ) \
- typedef struct FT_Service_ ## name ## Rec_ \
- FT_Service_ ## name ## Rec ; \
- typedef struct FT_Service_ ## name ## Rec_ \
- const * FT_Service_ ## name ; \
- struct FT_Service_ ## name ## Rec_
-
- /* */
-
-FT_END_HEADER
-
-#endif /* FTSERV_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/ftstream.h b/contrib/libs/freetype/include/freetype/internal/ftstream.h
deleted file mode 100644
index fd52f767ef..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/ftstream.h
+++ /dev/null
@@ -1,570 +0,0 @@
-/****************************************************************************
- *
- * ftstream.h
- *
- * Stream handling (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTSTREAM_H_
-#define FTSTREAM_H_
-
-
-#include <ft2build.h>
-#include <freetype/ftsystem.h>
-#include <freetype/internal/ftobjs.h>
-
-
-FT_BEGIN_HEADER
-
-
- /* format of an 8-bit frame_op value: */
- /* */
- /* bit 76543210 */
- /* xxxxxxes */
- /* */
- /* s is set to 1 if the value is signed. */
- /* e is set to 1 if the value is little-endian. */
- /* xxx is a command. */
-
-#define FT_FRAME_OP_SHIFT 2
-#define FT_FRAME_OP_SIGNED 1
-#define FT_FRAME_OP_LITTLE 2
-#define FT_FRAME_OP_COMMAND( x ) ( x >> FT_FRAME_OP_SHIFT )
-
-#define FT_MAKE_FRAME_OP( command, little, sign ) \
- ( ( command << FT_FRAME_OP_SHIFT ) | ( little << 1 ) | sign )
-
-#define FT_FRAME_OP_END 0
-#define FT_FRAME_OP_START 1 /* start a new frame */
-#define FT_FRAME_OP_BYTE 2 /* read 1-byte value */
-#define FT_FRAME_OP_SHORT 3 /* read 2-byte value */
-#define FT_FRAME_OP_LONG 4 /* read 4-byte value */
-#define FT_FRAME_OP_OFF3 5 /* read 3-byte value */
-#define FT_FRAME_OP_BYTES 6 /* read a bytes sequence */
-
-
- typedef enum FT_Frame_Op_
- {
- ft_frame_end = 0,
- ft_frame_start = FT_MAKE_FRAME_OP( FT_FRAME_OP_START, 0, 0 ),
-
- ft_frame_byte = FT_MAKE_FRAME_OP( FT_FRAME_OP_BYTE, 0, 0 ),
- ft_frame_schar = FT_MAKE_FRAME_OP( FT_FRAME_OP_BYTE, 0, 1 ),
-
- ft_frame_ushort_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_SHORT, 0, 0 ),
- ft_frame_short_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_SHORT, 0, 1 ),
- ft_frame_ushort_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_SHORT, 1, 0 ),
- ft_frame_short_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_SHORT, 1, 1 ),
-
- ft_frame_ulong_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_LONG, 0, 0 ),
- ft_frame_long_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_LONG, 0, 1 ),
- ft_frame_ulong_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_LONG, 1, 0 ),
- ft_frame_long_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_LONG, 1, 1 ),
-
- ft_frame_uoff3_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 0, 0 ),
- ft_frame_off3_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 0, 1 ),
- ft_frame_uoff3_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 1, 0 ),
- ft_frame_off3_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 1, 1 ),
-
- ft_frame_bytes = FT_MAKE_FRAME_OP( FT_FRAME_OP_BYTES, 0, 0 ),
- ft_frame_skip = FT_MAKE_FRAME_OP( FT_FRAME_OP_BYTES, 0, 1 )
-
- } FT_Frame_Op;
-
-
- typedef struct FT_Frame_Field_
- {
- FT_Byte value;
- FT_Byte size;
- FT_UShort offset;
-
- } FT_Frame_Field;
-
-
- /* Construct an FT_Frame_Field out of a structure type and a field name. */
- /* The structure type must be set in the FT_STRUCTURE macro before */
- /* calling the FT_FRAME_START() macro. */
- /* */
-#define FT_FIELD_SIZE( f ) \
- (FT_Byte)sizeof ( ((FT_STRUCTURE*)0)->f )
-
-#define FT_FIELD_SIZE_DELTA( f ) \
- (FT_Byte)sizeof ( ((FT_STRUCTURE*)0)->f[0] )
-
-#define FT_FIELD_OFFSET( f ) \
- (FT_UShort)( offsetof( FT_STRUCTURE, f ) )
-
-#define FT_FRAME_FIELD( frame_op, field ) \
- { \
- frame_op, \
- FT_FIELD_SIZE( field ), \
- FT_FIELD_OFFSET( field ) \
- }
-
-#define FT_MAKE_EMPTY_FIELD( frame_op ) { frame_op, 0, 0 }
-
-#define FT_FRAME_START( size ) { ft_frame_start, 0, size }
-#define FT_FRAME_END { ft_frame_end, 0, 0 }
-
-#define FT_FRAME_LONG( f ) FT_FRAME_FIELD( ft_frame_long_be, f )
-#define FT_FRAME_ULONG( f ) FT_FRAME_FIELD( ft_frame_ulong_be, f )
-#define FT_FRAME_SHORT( f ) FT_FRAME_FIELD( ft_frame_short_be, f )
-#define FT_FRAME_USHORT( f ) FT_FRAME_FIELD( ft_frame_ushort_be, f )
-#define FT_FRAME_OFF3( f ) FT_FRAME_FIELD( ft_frame_off3_be, f )
-#define FT_FRAME_UOFF3( f ) FT_FRAME_FIELD( ft_frame_uoff3_be, f )
-#define FT_FRAME_BYTE( f ) FT_FRAME_FIELD( ft_frame_byte, f )
-#define FT_FRAME_CHAR( f ) FT_FRAME_FIELD( ft_frame_schar, f )
-
-#define FT_FRAME_LONG_LE( f ) FT_FRAME_FIELD( ft_frame_long_le, f )
-#define FT_FRAME_ULONG_LE( f ) FT_FRAME_FIELD( ft_frame_ulong_le, f )
-#define FT_FRAME_SHORT_LE( f ) FT_FRAME_FIELD( ft_frame_short_le, f )
-#define FT_FRAME_USHORT_LE( f ) FT_FRAME_FIELD( ft_frame_ushort_le, f )
-#define FT_FRAME_OFF3_LE( f ) FT_FRAME_FIELD( ft_frame_off3_le, f )
-#define FT_FRAME_UOFF3_LE( f ) FT_FRAME_FIELD( ft_frame_uoff3_le, f )
-
-#define FT_FRAME_SKIP_LONG { ft_frame_long_be, 0, 0 }
-#define FT_FRAME_SKIP_SHORT { ft_frame_short_be, 0, 0 }
-#define FT_FRAME_SKIP_BYTE { ft_frame_byte, 0, 0 }
-
-#define FT_FRAME_BYTES( field, count ) \
- { \
- ft_frame_bytes, \
- count, \
- FT_FIELD_OFFSET( field ) \
- }
-
-#define FT_FRAME_SKIP_BYTES( count ) { ft_frame_skip, count, 0 }
-
-
- /**************************************************************************
- *
- * Integer extraction macros -- the 'buffer' parameter must ALWAYS be of
- * type 'char*' or equivalent (1-byte elements).
- */
-
-#define FT_BYTE_( p, i ) ( ((const FT_Byte*)(p))[(i)] )
-
-#define FT_INT16( x ) ( (FT_Int16)(x) )
-#define FT_UINT16( x ) ( (FT_UInt16)(x) )
-#define FT_INT32( x ) ( (FT_Int32)(x) )
-#define FT_UINT32( x ) ( (FT_UInt32)(x) )
-
-
-#define FT_BYTE_U16( p, i, s ) ( FT_UINT16( FT_BYTE_( p, i ) ) << (s) )
-#define FT_BYTE_U32( p, i, s ) ( FT_UINT32( FT_BYTE_( p, i ) ) << (s) )
-
-
- /*
- * function acts on increases does range for emits
- * pointer checking frames error
- * -------------------------------------------------------------------
- * FT_PEEK_XXX buffer pointer no no no no
- * FT_NEXT_XXX buffer pointer yes no no no
- * FT_GET_XXX stream->cursor yes yes yes no
- * FT_READ_XXX stream->pos yes yes no yes
- */
-
-
- /*
- * `FT_PEEK_XXX' are generic macros to get data from a buffer position. No
- * safety checks are performed.
- */
-#define FT_PEEK_SHORT( p ) FT_INT16( FT_BYTE_U16( p, 0, 8 ) | \
- FT_BYTE_U16( p, 1, 0 ) )
-
-#define FT_PEEK_USHORT( p ) FT_UINT16( FT_BYTE_U16( p, 0, 8 ) | \
- FT_BYTE_U16( p, 1, 0 ) )
-
-#define FT_PEEK_LONG( p ) FT_INT32( FT_BYTE_U32( p, 0, 24 ) | \
- FT_BYTE_U32( p, 1, 16 ) | \
- FT_BYTE_U32( p, 2, 8 ) | \
- FT_BYTE_U32( p, 3, 0 ) )
-
-#define FT_PEEK_ULONG( p ) FT_UINT32( FT_BYTE_U32( p, 0, 24 ) | \
- FT_BYTE_U32( p, 1, 16 ) | \
- FT_BYTE_U32( p, 2, 8 ) | \
- FT_BYTE_U32( p, 3, 0 ) )
-
-#define FT_PEEK_OFF3( p ) ( FT_INT32( FT_BYTE_U32( p, 0, 24 ) | \
- FT_BYTE_U32( p, 1, 16 ) | \
- FT_BYTE_U32( p, 2, 8 ) ) >> 8 )
-
-#define FT_PEEK_UOFF3( p ) FT_UINT32( FT_BYTE_U32( p, 0, 16 ) | \
- FT_BYTE_U32( p, 1, 8 ) | \
- FT_BYTE_U32( p, 2, 0 ) )
-
-#define FT_PEEK_SHORT_LE( p ) FT_INT16( FT_BYTE_U16( p, 1, 8 ) | \
- FT_BYTE_U16( p, 0, 0 ) )
-
-#define FT_PEEK_USHORT_LE( p ) FT_UINT16( FT_BYTE_U16( p, 1, 8 ) | \
- FT_BYTE_U16( p, 0, 0 ) )
-
-#define FT_PEEK_LONG_LE( p ) FT_INT32( FT_BYTE_U32( p, 3, 24 ) | \
- FT_BYTE_U32( p, 2, 16 ) | \
- FT_BYTE_U32( p, 1, 8 ) | \
- FT_BYTE_U32( p, 0, 0 ) )
-
-#define FT_PEEK_ULONG_LE( p ) FT_UINT32( FT_BYTE_U32( p, 3, 24 ) | \
- FT_BYTE_U32( p, 2, 16 ) | \
- FT_BYTE_U32( p, 1, 8 ) | \
- FT_BYTE_U32( p, 0, 0 ) )
-
-#define FT_PEEK_OFF3_LE( p ) ( FT_INT32( FT_BYTE_U32( p, 2, 24 ) | \
- FT_BYTE_U32( p, 1, 16 ) | \
- FT_BYTE_U32( p, 0, 8 ) ) >> 8 )
-
-#define FT_PEEK_UOFF3_LE( p ) FT_UINT32( FT_BYTE_U32( p, 2, 16 ) | \
- FT_BYTE_U32( p, 1, 8 ) | \
- FT_BYTE_U32( p, 0, 0 ) )
-
- /*
- * `FT_NEXT_XXX' are generic macros to get data from a buffer position
- * which is then increased appropriately. No safety checks are performed.
- */
-#define FT_NEXT_CHAR( buffer ) \
- ( (signed char)*buffer++ )
-
-#define FT_NEXT_BYTE( buffer ) \
- ( (unsigned char)*buffer++ )
-
-#define FT_NEXT_SHORT( buffer ) \
- ( buffer += 2, FT_PEEK_SHORT( buffer - 2 ) )
-
-#define FT_NEXT_USHORT( buffer ) \
- ( buffer += 2, FT_PEEK_USHORT( buffer - 2 ) )
-
-#define FT_NEXT_OFF3( buffer ) \
- ( buffer += 3, FT_PEEK_OFF3( buffer - 3 ) )
-
-#define FT_NEXT_UOFF3( buffer ) \
- ( buffer += 3, FT_PEEK_UOFF3( buffer - 3 ) )
-
-#define FT_NEXT_LONG( buffer ) \
- ( buffer += 4, FT_PEEK_LONG( buffer - 4 ) )
-
-#define FT_NEXT_ULONG( buffer ) \
- ( buffer += 4, FT_PEEK_ULONG( buffer - 4 ) )
-
-
-#define FT_NEXT_SHORT_LE( buffer ) \
- ( buffer += 2, FT_PEEK_SHORT_LE( buffer - 2 ) )
-
-#define FT_NEXT_USHORT_LE( buffer ) \
- ( buffer += 2, FT_PEEK_USHORT_LE( buffer - 2 ) )
-
-#define FT_NEXT_OFF3_LE( buffer ) \
- ( buffer += 3, FT_PEEK_OFF3_LE( buffer - 3 ) )
-
-#define FT_NEXT_UOFF3_LE( buffer ) \
- ( buffer += 3, FT_PEEK_UOFF3_LE( buffer - 3 ) )
-
-#define FT_NEXT_LONG_LE( buffer ) \
- ( buffer += 4, FT_PEEK_LONG_LE( buffer - 4 ) )
-
-#define FT_NEXT_ULONG_LE( buffer ) \
- ( buffer += 4, FT_PEEK_ULONG_LE( buffer - 4 ) )
-
-
- /**************************************************************************
- *
- * The `FT_GET_XXX` macros use an implicit 'stream' variable.
- *
- * Note that a call to `FT_STREAM_SEEK` or `FT_STREAM_POS` has **no**
- * effect on `FT_GET_XXX`! They operate on `stream->pos`, while
- * `FT_GET_XXX` use `stream->cursor`.
- */
-#if 0
-#define FT_GET_MACRO( type ) FT_NEXT_ ## type ( stream->cursor )
-
-#define FT_GET_CHAR() FT_GET_MACRO( CHAR )
-#define FT_GET_BYTE() FT_GET_MACRO( BYTE )
-#define FT_GET_SHORT() FT_GET_MACRO( SHORT )
-#define FT_GET_USHORT() FT_GET_MACRO( USHORT )
-#define FT_GET_OFF3() FT_GET_MACRO( OFF3 )
-#define FT_GET_UOFF3() FT_GET_MACRO( UOFF3 )
-#define FT_GET_LONG() FT_GET_MACRO( LONG )
-#define FT_GET_ULONG() FT_GET_MACRO( ULONG )
-#define FT_GET_TAG4() FT_GET_MACRO( ULONG )
-
-#define FT_GET_SHORT_LE() FT_GET_MACRO( SHORT_LE )
-#define FT_GET_USHORT_LE() FT_GET_MACRO( USHORT_LE )
-#define FT_GET_LONG_LE() FT_GET_MACRO( LONG_LE )
-#define FT_GET_ULONG_LE() FT_GET_MACRO( ULONG_LE )
-
-#else
-#define FT_GET_MACRO( func, type ) ( (type)func( stream ) )
-
-#define FT_GET_CHAR() FT_GET_MACRO( FT_Stream_GetByte, FT_Char )
-#define FT_GET_BYTE() FT_GET_MACRO( FT_Stream_GetByte, FT_Byte )
-#define FT_GET_SHORT() FT_GET_MACRO( FT_Stream_GetUShort, FT_Int16 )
-#define FT_GET_USHORT() FT_GET_MACRO( FT_Stream_GetUShort, FT_UInt16 )
-#define FT_GET_UOFF3() FT_GET_MACRO( FT_Stream_GetUOffset, FT_UInt32 )
-#define FT_GET_LONG() FT_GET_MACRO( FT_Stream_GetULong, FT_Int32 )
-#define FT_GET_ULONG() FT_GET_MACRO( FT_Stream_GetULong, FT_UInt32 )
-#define FT_GET_TAG4() FT_GET_MACRO( FT_Stream_GetULong, FT_UInt32 )
-
-#define FT_GET_SHORT_LE() FT_GET_MACRO( FT_Stream_GetUShortLE, FT_Int16 )
-#define FT_GET_USHORT_LE() FT_GET_MACRO( FT_Stream_GetUShortLE, FT_UInt16 )
-#define FT_GET_LONG_LE() FT_GET_MACRO( FT_Stream_GetULongLE, FT_Int32 )
-#define FT_GET_ULONG_LE() FT_GET_MACRO( FT_Stream_GetULongLE, FT_UInt32 )
-#endif
-
-
-#define FT_READ_MACRO( func, type, var ) \
- ( var = (type)func( stream, &error ), \
- error != FT_Err_Ok )
-
- /*
- * The `FT_READ_XXX' macros use implicit `stream' and `error' variables.
- *
- * `FT_READ_XXX' can be controlled with `FT_STREAM_SEEK' and
- * `FT_STREAM_POS'. They use the full machinery to check whether a read is
- * valid.
- */
-#define FT_READ_BYTE( var ) FT_READ_MACRO( FT_Stream_ReadByte, FT_Byte, var )
-#define FT_READ_CHAR( var ) FT_READ_MACRO( FT_Stream_ReadByte, FT_Char, var )
-#define FT_READ_SHORT( var ) FT_READ_MACRO( FT_Stream_ReadUShort, FT_Int16, var )
-#define FT_READ_USHORT( var ) FT_READ_MACRO( FT_Stream_ReadUShort, FT_UInt16, var )
-#define FT_READ_UOFF3( var ) FT_READ_MACRO( FT_Stream_ReadUOffset, FT_UInt32, var )
-#define FT_READ_LONG( var ) FT_READ_MACRO( FT_Stream_ReadULong, FT_Int32, var )
-#define FT_READ_ULONG( var ) FT_READ_MACRO( FT_Stream_ReadULong, FT_UInt32, var )
-
-#define FT_READ_SHORT_LE( var ) FT_READ_MACRO( FT_Stream_ReadUShortLE, FT_Int16, var )
-#define FT_READ_USHORT_LE( var ) FT_READ_MACRO( FT_Stream_ReadUShortLE, FT_UInt16, var )
-#define FT_READ_LONG_LE( var ) FT_READ_MACRO( FT_Stream_ReadULongLE, FT_Int32, var )
-#define FT_READ_ULONG_LE( var ) FT_READ_MACRO( FT_Stream_ReadULongLE, FT_UInt32, var )
-
-
-#ifndef FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM
-
- /* initialize a stream for reading a regular system stream */
- FT_BASE( FT_Error )
- FT_Stream_Open( FT_Stream stream,
- const char* filepathname );
-
-#endif /* FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM */
-
-
- /* create a new (input) stream from an FT_Open_Args structure */
- FT_BASE( FT_Error )
- FT_Stream_New( FT_Library library,
- const FT_Open_Args* args,
- FT_Stream *astream );
-
- /* free a stream */
- FT_BASE( void )
- FT_Stream_Free( FT_Stream stream,
- FT_Int external );
-
- /* initialize a stream for reading in-memory data */
- FT_BASE( void )
- FT_Stream_OpenMemory( FT_Stream stream,
- const FT_Byte* base,
- FT_ULong size );
-
- /* close a stream (does not destroy the stream structure) */
- FT_BASE( void )
- FT_Stream_Close( FT_Stream stream );
-
-
- /* seek within a stream. position is relative to start of stream */
- FT_BASE( FT_Error )
- FT_Stream_Seek( FT_Stream stream,
- FT_ULong pos );
-
- /* skip bytes in a stream */
- FT_BASE( FT_Error )
- FT_Stream_Skip( FT_Stream stream,
- FT_Long distance );
-
- /* return current stream position */
- FT_BASE( FT_ULong )
- FT_Stream_Pos( FT_Stream stream );
-
- /* read bytes from a stream into a user-allocated buffer, returns an */
- /* error if not all bytes could be read. */
- FT_BASE( FT_Error )
- FT_Stream_Read( FT_Stream stream,
- FT_Byte* buffer,
- FT_ULong count );
-
- /* read bytes from a stream at a given position */
- FT_BASE( FT_Error )
- FT_Stream_ReadAt( FT_Stream stream,
- FT_ULong pos,
- FT_Byte* buffer,
- FT_ULong count );
-
- /* try to read bytes at the end of a stream; return number of bytes */
- /* really available */
- FT_BASE( FT_ULong )
- FT_Stream_TryRead( FT_Stream stream,
- FT_Byte* buffer,
- FT_ULong count );
-
- /* Enter a frame of `count' consecutive bytes in a stream. Returns an */
- /* error if the frame could not be read/accessed. The caller can use */
- /* the `FT_Stream_GetXXX' functions to retrieve frame data without */
- /* error checks. */
- /* */
- /* You must _always_ call `FT_Stream_ExitFrame' once you have entered */
- /* a stream frame! */
- /* */
- /* Nested frames are not permitted. */
- /* */
- FT_BASE( FT_Error )
- FT_Stream_EnterFrame( FT_Stream stream,
- FT_ULong count );
-
- /* exit a stream frame */
- FT_BASE( void )
- FT_Stream_ExitFrame( FT_Stream stream );
-
-
- /* Extract a stream frame. If the stream is disk-based, a heap block */
- /* is allocated and the frame bytes are read into it. If the stream */
- /* is memory-based, this function simply sets a pointer to the data. */
- /* */
- /* Useful to optimize access to memory-based streams transparently. */
- /* */
- /* `FT_Stream_GetXXX' functions can't be used. */
- /* */
- /* An extracted frame must be `freed' with a call to the function */
- /* `FT_Stream_ReleaseFrame'. */
- /* */
- FT_BASE( FT_Error )
- FT_Stream_ExtractFrame( FT_Stream stream,
- FT_ULong count,
- FT_Byte** pbytes );
-
- /* release an extract frame (see `FT_Stream_ExtractFrame') */
- FT_BASE( void )
- FT_Stream_ReleaseFrame( FT_Stream stream,
- FT_Byte** pbytes );
-
-
- /* read a byte from an entered frame */
- FT_BASE( FT_Byte )
- FT_Stream_GetByte( FT_Stream stream );
-
- /* read a 16-bit big-endian unsigned integer from an entered frame */
- FT_BASE( FT_UInt16 )
- FT_Stream_GetUShort( FT_Stream stream );
-
- /* read a 24-bit big-endian unsigned integer from an entered frame */
- FT_BASE( FT_UInt32 )
- FT_Stream_GetUOffset( FT_Stream stream );
-
- /* read a 32-bit big-endian unsigned integer from an entered frame */
- FT_BASE( FT_UInt32 )
- FT_Stream_GetULong( FT_Stream stream );
-
- /* read a 16-bit little-endian unsigned integer from an entered frame */
- FT_BASE( FT_UInt16 )
- FT_Stream_GetUShortLE( FT_Stream stream );
-
- /* read a 32-bit little-endian unsigned integer from an entered frame */
- FT_BASE( FT_UInt32 )
- FT_Stream_GetULongLE( FT_Stream stream );
-
-
- /* read a byte from a stream */
- FT_BASE( FT_Byte )
- FT_Stream_ReadByte( FT_Stream stream,
- FT_Error* error );
-
- /* read a 16-bit big-endian unsigned integer from a stream */
- FT_BASE( FT_UInt16 )
- FT_Stream_ReadUShort( FT_Stream stream,
- FT_Error* error );
-
- /* read a 24-bit big-endian unsigned integer from a stream */
- FT_BASE( FT_ULong )
- FT_Stream_ReadUOffset( FT_Stream stream,
- FT_Error* error );
-
- /* read a 32-bit big-endian integer from a stream */
- FT_BASE( FT_UInt32 )
- FT_Stream_ReadULong( FT_Stream stream,
- FT_Error* error );
-
- /* read a 16-bit little-endian unsigned integer from a stream */
- FT_BASE( FT_UInt16 )
- FT_Stream_ReadUShortLE( FT_Stream stream,
- FT_Error* error );
-
- /* read a 32-bit little-endian unsigned integer from a stream */
- FT_BASE( FT_UInt32 )
- FT_Stream_ReadULongLE( FT_Stream stream,
- FT_Error* error );
-
- /* Read a structure from a stream. The structure must be described */
- /* by an array of FT_Frame_Field records. */
- FT_BASE( FT_Error )
- FT_Stream_ReadFields( FT_Stream stream,
- const FT_Frame_Field* fields,
- void* structure );
-
-
-#define FT_STREAM_POS() \
- FT_Stream_Pos( stream )
-
-#define FT_STREAM_SEEK( position ) \
- FT_SET_ERROR( FT_Stream_Seek( stream, \
- (FT_ULong)(position) ) )
-
-#define FT_STREAM_SKIP( distance ) \
- FT_SET_ERROR( FT_Stream_Skip( stream, \
- (FT_Long)(distance) ) )
-
-#define FT_STREAM_READ( buffer, count ) \
- FT_SET_ERROR( FT_Stream_Read( stream, \
- (FT_Byte*)(buffer), \
- (FT_ULong)(count) ) )
-
-#define FT_STREAM_READ_AT( position, buffer, count ) \
- FT_SET_ERROR( FT_Stream_ReadAt( stream, \
- (FT_ULong)(position), \
- (FT_Byte*)(buffer), \
- (FT_ULong)(count) ) )
-
-#define FT_STREAM_READ_FIELDS( fields, object ) \
- FT_SET_ERROR( FT_Stream_ReadFields( stream, fields, object ) )
-
-
-#define FT_FRAME_ENTER( size ) \
- FT_SET_ERROR( \
- FT_DEBUG_INNER( FT_Stream_EnterFrame( stream, \
- (FT_ULong)(size) ) ) )
-
-#define FT_FRAME_EXIT() \
- FT_DEBUG_INNER( FT_Stream_ExitFrame( stream ) )
-
-#define FT_FRAME_EXTRACT( size, bytes ) \
- FT_SET_ERROR( \
- FT_DEBUG_INNER( FT_Stream_ExtractFrame( stream, \
- (FT_ULong)(size), \
- (FT_Byte**)&(bytes) ) ) )
-
-#define FT_FRAME_RELEASE( bytes ) \
- FT_DEBUG_INNER( FT_Stream_ReleaseFrame( stream, \
- (FT_Byte**)&(bytes) ) )
-
-
-FT_END_HEADER
-
-#endif /* FTSTREAM_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/fttrace.h b/contrib/libs/freetype/include/freetype/internal/fttrace.h
deleted file mode 100644
index 42595a29ff..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/fttrace.h
+++ /dev/null
@@ -1,173 +0,0 @@
-/****************************************************************************
- *
- * fttrace.h
- *
- * Tracing handling (specification only).
- *
- * Copyright (C) 2002-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /* definitions of trace levels for FreeType 2 */
-
- /* the maximum string length (if the argument to `FT_TRACE_DEF` */
- /* gets used as a string) plus one charachter for ':' plus */
- /* another one for the trace level */
-#define FT_MAX_TRACE_LEVEL_LENGTH (9 + 1 + 1)
-
- /* the first level must always be `trace_any' */
-FT_TRACE_DEF( any )
-
- /* base components */
-FT_TRACE_DEF( calc ) /* calculations (ftcalc.c) */
-FT_TRACE_DEF( gloader ) /* glyph loader (ftgloadr.c) */
-FT_TRACE_DEF( glyph ) /* glyph management (ftglyph.c) */
-FT_TRACE_DEF( memory ) /* memory manager (ftobjs.c) */
-FT_TRACE_DEF( init ) /* initialization (ftinit.c) */
-FT_TRACE_DEF( io ) /* i/o interface (ftsystem.c) */
-FT_TRACE_DEF( list ) /* list management (ftlist.c) */
-FT_TRACE_DEF( objs ) /* base objects (ftobjs.c) */
-FT_TRACE_DEF( outline ) /* outline management (ftoutln.c) */
-FT_TRACE_DEF( stream ) /* stream manager (ftstream.c) */
-
-FT_TRACE_DEF( bitmap ) /* bitmap manipulation (ftbitmap.c) */
-FT_TRACE_DEF( checksum ) /* bitmap checksum (ftobjs.c) */
-FT_TRACE_DEF( mm ) /* MM interface (ftmm.c) */
-FT_TRACE_DEF( psprops ) /* PS driver properties (ftpsprop.c) */
-FT_TRACE_DEF( raccess ) /* resource fork accessor (ftrfork.c) */
-FT_TRACE_DEF( synth ) /* bold/slant synthesizer (ftsynth.c) */
-
- /* rasterizers */
-FT_TRACE_DEF( raster ) /* monochrome rasterizer (ftraster.c) */
-FT_TRACE_DEF( smooth ) /* anti-aliasing raster (ftgrays.c) */
-
- /* ot-svg module */
-FT_TRACE_DEF( otsvg ) /* OT-SVG renderer (ftsvg.c) */
-
- /* cache sub-system */
-FT_TRACE_DEF( cache ) /* cache sub-system (ftcache.c, etc.) */
-
- /* SFNT driver components */
-FT_TRACE_DEF( sfdriver ) /* SFNT font driver (sfdriver.c) */
-FT_TRACE_DEF( sfobjs ) /* SFNT object handler (sfobjs.c) */
-FT_TRACE_DEF( sfwoff ) /* WOFF format handler (sfwoff.c) */
-FT_TRACE_DEF( sfwoff2 ) /* WOFF2 format handler (sfwoff2.c) */
-FT_TRACE_DEF( ttbdf ) /* TrueType embedded BDF (ttbdf.c) */
-FT_TRACE_DEF( ttcmap ) /* charmap handler (ttcmap.c) */
-FT_TRACE_DEF( ttcolr ) /* glyph layer table (ttcolr.c) */
-FT_TRACE_DEF( ttcpal ) /* color palette table (ttcpal.c) */
-FT_TRACE_DEF( ttgpos ) /* GPOS handler (ttgpos.c) */
-FT_TRACE_DEF( ttsvg ) /* OpenType SVG table (ttsvg.c) */
-FT_TRACE_DEF( ttkern ) /* kerning handler (ttkern.c) */
-FT_TRACE_DEF( ttload ) /* basic TrueType tables (ttload.c) */
-FT_TRACE_DEF( ttmtx ) /* metrics-related tables (ttmtx.c) */
-FT_TRACE_DEF( ttpost ) /* PS table processing (ttpost.c) */
-FT_TRACE_DEF( ttsbit ) /* TrueType sbit handling (ttsbit.c) */
-
- /* TrueType driver components */
-FT_TRACE_DEF( ttdriver ) /* TT font driver (ttdriver.c) */
-FT_TRACE_DEF( ttgload ) /* TT glyph loader (ttgload.c) */
-FT_TRACE_DEF( ttgxvar ) /* TrueType GX var handler (ttgxvar.c) */
-FT_TRACE_DEF( ttinterp ) /* bytecode interpreter (ttinterp.c) */
-FT_TRACE_DEF( ttobjs ) /* TT objects manager (ttobjs.c) */
-FT_TRACE_DEF( ttpload ) /* TT data/program loader (ttpload.c) */
-
- /* Type 1 driver components */
-FT_TRACE_DEF( t1afm )
-FT_TRACE_DEF( t1driver )
-FT_TRACE_DEF( t1gload )
-FT_TRACE_DEF( t1load )
-FT_TRACE_DEF( t1objs )
-FT_TRACE_DEF( t1parse )
-
- /* PostScript helper module `psaux' */
-FT_TRACE_DEF( afmparse )
-FT_TRACE_DEF( cffdecode )
-FT_TRACE_DEF( psconv )
-FT_TRACE_DEF( psobjs )
-FT_TRACE_DEF( t1decode )
-
- /* PostScript hinting module `pshinter' */
-FT_TRACE_DEF( pshalgo )
-FT_TRACE_DEF( pshrec )
-
- /* Type 2 driver components */
-FT_TRACE_DEF( cffdriver )
-FT_TRACE_DEF( cffgload )
-FT_TRACE_DEF( cffload )
-FT_TRACE_DEF( cffobjs )
-FT_TRACE_DEF( cffparse )
-
-FT_TRACE_DEF( cf2blues )
-FT_TRACE_DEF( cf2hints )
-FT_TRACE_DEF( cf2interp )
-
- /* Type 42 driver component */
-FT_TRACE_DEF( t42 )
-
- /* CID driver components */
-FT_TRACE_DEF( ciddriver )
-FT_TRACE_DEF( cidgload )
-FT_TRACE_DEF( cidload )
-FT_TRACE_DEF( cidobjs )
-FT_TRACE_DEF( cidparse )
-
- /* Windows font component */
-FT_TRACE_DEF( winfnt )
-
- /* PCF font components */
-FT_TRACE_DEF( pcfdriver )
-FT_TRACE_DEF( pcfread )
-
- /* BDF font components */
-FT_TRACE_DEF( bdfdriver )
-FT_TRACE_DEF( bdflib )
-
- /* PFR font component */
-FT_TRACE_DEF( pfr )
-
- /* OpenType validation components */
-FT_TRACE_DEF( otvcommon )
-FT_TRACE_DEF( otvbase )
-FT_TRACE_DEF( otvgdef )
-FT_TRACE_DEF( otvgpos )
-FT_TRACE_DEF( otvgsub )
-FT_TRACE_DEF( otvjstf )
-FT_TRACE_DEF( otvmath )
-FT_TRACE_DEF( otvmodule )
-
- /* TrueTypeGX/AAT validation components */
-FT_TRACE_DEF( gxvbsln )
-FT_TRACE_DEF( gxvcommon )
-FT_TRACE_DEF( gxvfeat )
-FT_TRACE_DEF( gxvjust )
-FT_TRACE_DEF( gxvkern )
-FT_TRACE_DEF( gxvmodule )
-FT_TRACE_DEF( gxvmort )
-FT_TRACE_DEF( gxvmorx )
-FT_TRACE_DEF( gxvlcar )
-FT_TRACE_DEF( gxvopbd )
-FT_TRACE_DEF( gxvprop )
-FT_TRACE_DEF( gxvtrak )
-
- /* autofit components */
-FT_TRACE_DEF( afcjk )
-FT_TRACE_DEF( afglobal )
-FT_TRACE_DEF( afhints )
-FT_TRACE_DEF( afmodule )
-FT_TRACE_DEF( aflatin )
-FT_TRACE_DEF( afshaper )
-
- /* SDF components */
-FT_TRACE_DEF( sdf ) /* signed distance raster for outlines (ftsdf.c) */
-FT_TRACE_DEF( bsdf ) /* signed distance raster for bitmaps (ftbsdf.c) */
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/ftvalid.h b/contrib/libs/freetype/include/freetype/internal/ftvalid.h
deleted file mode 100644
index a1312f2aba..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/ftvalid.h
+++ /dev/null
@@ -1,160 +0,0 @@
-/****************************************************************************
- *
- * ftvalid.h
- *
- * FreeType validation support (specification).
- *
- * Copyright (C) 2004-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTVALID_H_
-#define FTVALID_H_
-
-#include <ft2build.h>
-#include FT_CONFIG_STANDARD_LIBRARY_H /* for ft_jmpbuf */
-
-#include "compiler-macros.h"
-
-FT_BEGIN_HEADER
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /**** ****/
- /**** ****/
- /**** V A L I D A T I O N ****/
- /**** ****/
- /**** ****/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
- /* handle to a validation object */
- typedef struct FT_ValidatorRec_ volatile* FT_Validator;
-
-
- /**************************************************************************
- *
- * There are three distinct validation levels defined here:
- *
- * FT_VALIDATE_DEFAULT ::
- * A table that passes this validation level can be used reliably by
- * FreeType. It generally means that all offsets have been checked to
- * prevent out-of-bound reads, that array counts are correct, etc.
- *
- * FT_VALIDATE_TIGHT ::
- * A table that passes this validation level can be used reliably and
- * doesn't contain invalid data. For example, a charmap table that
- * returns invalid glyph indices will not pass, even though it can be
- * used with FreeType in default mode (the library will simply return an
- * error later when trying to load the glyph).
- *
- * It also checks that fields which must be a multiple of 2, 4, or 8,
- * don't have incorrect values, etc.
- *
- * FT_VALIDATE_PARANOID ::
- * Only for font debugging. Checks that a table follows the
- * specification by 100%. Very few fonts will be able to pass this level
- * anyway but it can be useful for certain tools like font
- * editors/converters.
- */
- typedef enum FT_ValidationLevel_
- {
- FT_VALIDATE_DEFAULT = 0,
- FT_VALIDATE_TIGHT,
- FT_VALIDATE_PARANOID
-
- } FT_ValidationLevel;
-
-
-#if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */
- /* We disable the warning `structure was padded due to */
- /* __declspec(align())' in order to compile cleanly with */
- /* the maximum level of warnings. */
-#pragma warning( push )
-#pragma warning( disable : 4324 )
-#endif /* _MSC_VER */
-
- /* validator structure */
- typedef struct FT_ValidatorRec_
- {
- ft_jmp_buf jump_buffer; /* used for exception handling */
-
- const FT_Byte* base; /* address of table in memory */
- const FT_Byte* limit; /* `base' + sizeof(table) in memory */
- FT_ValidationLevel level; /* validation level */
- FT_Error error; /* error returned. 0 means success */
-
- } FT_ValidatorRec;
-
-#if defined( _MSC_VER )
-#pragma warning( pop )
-#endif
-
-#define FT_VALIDATOR( x ) ( (FT_Validator)( x ) )
-
-
- FT_BASE( void )
- ft_validator_init( FT_Validator valid,
- const FT_Byte* base,
- const FT_Byte* limit,
- FT_ValidationLevel level );
-
- /* Do not use this. It's broken and will cause your validator to crash */
- /* if you run it on an invalid font. */
- FT_BASE( FT_Int )
- ft_validator_run( FT_Validator valid );
-
- /* Sets the error field in a validator, then calls `longjmp' to return */
- /* to high-level caller. Using `setjmp/longjmp' avoids many stupid */
- /* error checks within the validation routines. */
- /* */
- FT_BASE( void )
- ft_validator_error( FT_Validator valid,
- FT_Error error );
-
-
- /* Calls ft_validate_error. Assumes that the `valid' local variable */
- /* holds a pointer to the current validator object. */
- /* */
-#define FT_INVALID( _error ) FT_INVALID_( _error )
-#define FT_INVALID_( _error ) \
- ft_validator_error( valid, FT_THROW( _error ) )
-
- /* called when a broken table is detected */
-#define FT_INVALID_TOO_SHORT \
- FT_INVALID( Invalid_Table )
-
- /* called when an invalid offset is detected */
-#define FT_INVALID_OFFSET \
- FT_INVALID( Invalid_Offset )
-
- /* called when an invalid format/value is detected */
-#define FT_INVALID_FORMAT \
- FT_INVALID( Invalid_Table )
-
- /* called when an invalid glyph index is detected */
-#define FT_INVALID_GLYPH_ID \
- FT_INVALID( Invalid_Glyph_Index )
-
- /* called when an invalid field value is detected */
-#define FT_INVALID_DATA \
- FT_INVALID( Invalid_Table )
-
-
-FT_END_HEADER
-
-#endif /* FTVALID_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/psaux.h b/contrib/libs/freetype/include/freetype/internal/psaux.h
deleted file mode 100644
index 745d2cb56b..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/psaux.h
+++ /dev/null
@@ -1,1447 +0,0 @@
-/****************************************************************************
- *
- * psaux.h
- *
- * Auxiliary functions and data structures related to PostScript fonts
- * (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef PSAUX_H_
-#define PSAUX_H_
-
-
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/t1types.h>
-#include <freetype/internal/fthash.h>
-#include <freetype/internal/tttypes.h>
-#include <freetype/internal/services/svpscmap.h>
-#include <freetype/internal/cfftypes.h>
-#include <freetype/internal/cffotypes.h>
-
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * PostScript modules driver class.
- */
- typedef struct PS_DriverRec_
- {
- FT_DriverRec root;
-
- FT_UInt hinting_engine;
- FT_Bool no_stem_darkening;
- FT_Int darken_params[8];
- FT_Int32 random_seed;
-
- } PS_DriverRec, *PS_Driver;
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** T1_TABLE *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- typedef struct PS_TableRec_* PS_Table;
- typedef const struct PS_Table_FuncsRec_* PS_Table_Funcs;
-
-
- /**************************************************************************
- *
- * @struct:
- * PS_Table_FuncsRec
- *
- * @description:
- * A set of function pointers to manage PS_Table objects.
- *
- * @fields:
- * table_init ::
- * Used to initialize a table.
- *
- * table_done ::
- * Finalizes resp. destroy a given table.
- *
- * table_add ::
- * Adds a new object to a table.
- *
- * table_release ::
- * Releases table data, then finalizes it.
- */
- typedef struct PS_Table_FuncsRec_
- {
- FT_Error
- (*init)( PS_Table table,
- FT_Int count,
- FT_Memory memory );
-
- void
- (*done)( PS_Table table );
-
- FT_Error
- (*add)( PS_Table table,
- FT_Int idx,
- const void* object,
- FT_UInt length );
-
- void
- (*release)( PS_Table table );
-
- } PS_Table_FuncsRec;
-
-
- /**************************************************************************
- *
- * @struct:
- * PS_TableRec
- *
- * @description:
- * A PS_Table is a simple object used to store an array of objects in a
- * single memory block.
- *
- * @fields:
- * block ::
- * The address in memory of the growheap's block. This can change
- * between two object adds, due to reallocation.
- *
- * cursor ::
- * The current top of the grow heap within its block.
- *
- * capacity ::
- * The current size of the heap block. Increments by 1kByte chunks.
- *
- * init ::
- * Set to 0xDEADBEEF if 'elements' and 'lengths' have been allocated.
- *
- * max_elems ::
- * The maximum number of elements in table.
- *
- * elements ::
- * A table of element addresses within the block.
- *
- * lengths ::
- * A table of element sizes within the block.
- *
- * memory ::
- * The object used for memory operations (alloc/realloc).
- *
- * funcs ::
- * A table of method pointers for this object.
- */
- typedef struct PS_TableRec_
- {
- FT_Byte* block; /* current memory block */
- FT_Offset cursor; /* current cursor in memory block */
- FT_Offset capacity; /* current size of memory block */
- FT_ULong init;
-
- FT_Int max_elems;
- FT_Byte** elements; /* addresses of table elements */
- FT_UInt* lengths; /* lengths of table elements */
-
- FT_Memory memory;
- PS_Table_FuncsRec funcs;
-
- } PS_TableRec;
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** T1 FIELDS & TOKENS *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- typedef struct PS_ParserRec_* PS_Parser;
-
- typedef struct T1_TokenRec_* T1_Token;
-
- typedef struct T1_FieldRec_* T1_Field;
-
-
- /* simple enumeration type used to identify token types */
- typedef enum T1_TokenType_
- {
- T1_TOKEN_TYPE_NONE = 0,
- T1_TOKEN_TYPE_ANY,
- T1_TOKEN_TYPE_STRING,
- T1_TOKEN_TYPE_ARRAY,
- T1_TOKEN_TYPE_KEY, /* aka `name' */
-
- /* do not remove */
- T1_TOKEN_TYPE_MAX
-
- } T1_TokenType;
-
-
- /* a simple structure used to identify tokens */
- typedef struct T1_TokenRec_
- {
- FT_Byte* start; /* first character of token in input stream */
- FT_Byte* limit; /* first character after the token */
- T1_TokenType type; /* type of token */
-
- } T1_TokenRec;
-
-
- /* enumeration type used to identify object fields */
- typedef enum T1_FieldType_
- {
- T1_FIELD_TYPE_NONE = 0,
- T1_FIELD_TYPE_BOOL,
- T1_FIELD_TYPE_INTEGER,
- T1_FIELD_TYPE_FIXED,
- T1_FIELD_TYPE_FIXED_1000,
- T1_FIELD_TYPE_STRING,
- T1_FIELD_TYPE_KEY,
- T1_FIELD_TYPE_BBOX,
- T1_FIELD_TYPE_MM_BBOX,
- T1_FIELD_TYPE_INTEGER_ARRAY,
- T1_FIELD_TYPE_FIXED_ARRAY,
- T1_FIELD_TYPE_CALLBACK,
-
- /* do not remove */
- T1_FIELD_TYPE_MAX
-
- } T1_FieldType;
-
-
- typedef enum T1_FieldLocation_
- {
- T1_FIELD_LOCATION_NONE = 0,
- T1_FIELD_LOCATION_CID_INFO,
- T1_FIELD_LOCATION_FONT_DICT,
- T1_FIELD_LOCATION_FONT_EXTRA,
- T1_FIELD_LOCATION_FONT_INFO,
- T1_FIELD_LOCATION_PRIVATE,
- T1_FIELD_LOCATION_BBOX,
- T1_FIELD_LOCATION_LOADER,
- T1_FIELD_LOCATION_FACE,
- T1_FIELD_LOCATION_BLEND,
-
- /* do not remove */
- T1_FIELD_LOCATION_MAX
-
- } T1_FieldLocation;
-
-
- typedef void
- (*T1_Field_ParseFunc)( FT_Face face,
- FT_Pointer parser );
-
-
- /* structure type used to model object fields */
- typedef struct T1_FieldRec_
- {
- FT_UInt len; /* field identifier length */
- const char* ident; /* field identifier */
- T1_FieldLocation location;
- T1_FieldType type; /* type of field */
- T1_Field_ParseFunc reader;
- FT_UInt offset; /* offset of field in object */
- FT_Byte size; /* size of field in bytes */
- FT_UInt array_max; /* maximum number of elements for */
- /* array */
- FT_UInt count_offset; /* offset of element count for */
- /* arrays; must not be zero if in */
- /* use -- in other words, a */
- /* `num_FOO' element must not */
- /* start the used structure if we */
- /* parse a `FOO' array */
- FT_UInt dict; /* where we expect it */
- } T1_FieldRec;
-
-#define T1_FIELD_DICT_FONTDICT ( 1 << 0 ) /* also FontInfo and FDArray */
-#define T1_FIELD_DICT_PRIVATE ( 1 << 1 )
-
-
-
-#define T1_NEW_SIMPLE_FIELD( _ident, _type, _fname, _dict ) \
- { \
- sizeof ( _ident ) - 1, \
- _ident, T1CODE, _type, \
- NULL, \
- FT_FIELD_OFFSET( _fname ), \
- FT_FIELD_SIZE( _fname ), \
- 0, 0, \
- _dict \
- },
-
-#define T1_NEW_CALLBACK_FIELD( _ident, _reader, _dict ) \
- { \
- sizeof ( _ident ) - 1, \
- _ident, T1CODE, T1_FIELD_TYPE_CALLBACK, \
- (T1_Field_ParseFunc)_reader, \
- 0, 0, \
- 0, 0, \
- _dict \
- },
-
-#define T1_NEW_TABLE_FIELD( _ident, _type, _fname, _max, _dict ) \
- { \
- sizeof ( _ident ) - 1, \
- _ident, T1CODE, _type, \
- NULL, \
- FT_FIELD_OFFSET( _fname ), \
- FT_FIELD_SIZE_DELTA( _fname ), \
- _max, \
- FT_FIELD_OFFSET( num_ ## _fname ), \
- _dict \
- },
-
-#define T1_NEW_TABLE_FIELD2( _ident, _type, _fname, _max, _dict ) \
- { \
- sizeof ( _ident ) - 1, \
- _ident, T1CODE, _type, \
- NULL, \
- FT_FIELD_OFFSET( _fname ), \
- FT_FIELD_SIZE_DELTA( _fname ), \
- _max, 0, \
- _dict \
- },
-
-
-#define T1_FIELD_BOOL( _ident, _fname, _dict ) \
- T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_BOOL, _fname, _dict )
-
-#define T1_FIELD_NUM( _ident, _fname, _dict ) \
- T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_INTEGER, _fname, _dict )
-
-#define T1_FIELD_FIXED( _ident, _fname, _dict ) \
- T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_FIXED, _fname, _dict )
-
-#define T1_FIELD_FIXED_1000( _ident, _fname, _dict ) \
- T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_FIXED_1000, _fname, \
- _dict )
-
-#define T1_FIELD_STRING( _ident, _fname, _dict ) \
- T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_STRING, _fname, _dict )
-
-#define T1_FIELD_KEY( _ident, _fname, _dict ) \
- T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_KEY, _fname, _dict )
-
-#define T1_FIELD_BBOX( _ident, _fname, _dict ) \
- T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_BBOX, _fname, _dict )
-
-
-#define T1_FIELD_NUM_TABLE( _ident, _fname, _fmax, _dict ) \
- T1_NEW_TABLE_FIELD( _ident, T1_FIELD_TYPE_INTEGER_ARRAY, \
- _fname, _fmax, _dict )
-
-#define T1_FIELD_FIXED_TABLE( _ident, _fname, _fmax, _dict ) \
- T1_NEW_TABLE_FIELD( _ident, T1_FIELD_TYPE_FIXED_ARRAY, \
- _fname, _fmax, _dict )
-
-#define T1_FIELD_NUM_TABLE2( _ident, _fname, _fmax, _dict ) \
- T1_NEW_TABLE_FIELD2( _ident, T1_FIELD_TYPE_INTEGER_ARRAY, \
- _fname, _fmax, _dict )
-
-#define T1_FIELD_FIXED_TABLE2( _ident, _fname, _fmax, _dict ) \
- T1_NEW_TABLE_FIELD2( _ident, T1_FIELD_TYPE_FIXED_ARRAY, \
- _fname, _fmax, _dict )
-
-#define T1_FIELD_CALLBACK( _ident, _name, _dict ) \
- T1_NEW_CALLBACK_FIELD( _ident, _name, _dict )
-
-#define T1_FIELD_ZERO \
- { \
- 0, \
- NULL, T1_FIELD_LOCATION_NONE, T1_FIELD_TYPE_NONE, \
- NULL, 0, 0, 0, 0, 0 \
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** T1 PARSER *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- typedef const struct PS_Parser_FuncsRec_* PS_Parser_Funcs;
-
- typedef struct PS_Parser_FuncsRec_
- {
- void
- (*init)( PS_Parser parser,
- FT_Byte* base,
- FT_Byte* limit,
- FT_Memory memory );
-
- void
- (*done)( PS_Parser parser );
-
- void
- (*skip_spaces)( PS_Parser parser );
- void
- (*skip_PS_token)( PS_Parser parser );
-
- FT_Long
- (*to_int)( PS_Parser parser );
- FT_Fixed
- (*to_fixed)( PS_Parser parser,
- FT_Int power_ten );
-
- FT_Error
- (*to_bytes)( PS_Parser parser,
- FT_Byte* bytes,
- FT_Offset max_bytes,
- FT_ULong* pnum_bytes,
- FT_Bool delimiters );
-
- FT_Int
- (*to_coord_array)( PS_Parser parser,
- FT_Int max_coords,
- FT_Short* coords );
- FT_Int
- (*to_fixed_array)( PS_Parser parser,
- FT_Int max_values,
- FT_Fixed* values,
- FT_Int power_ten );
-
- void
- (*to_token)( PS_Parser parser,
- T1_Token token );
- void
- (*to_token_array)( PS_Parser parser,
- T1_Token tokens,
- FT_UInt max_tokens,
- FT_Int* pnum_tokens );
-
- FT_Error
- (*load_field)( PS_Parser parser,
- const T1_Field field,
- void** objects,
- FT_UInt max_objects,
- FT_ULong* pflags );
-
- FT_Error
- (*load_field_table)( PS_Parser parser,
- const T1_Field field,
- void** objects,
- FT_UInt max_objects,
- FT_ULong* pflags );
-
- } PS_Parser_FuncsRec;
-
-
- /**************************************************************************
- *
- * @struct:
- * PS_ParserRec
- *
- * @description:
- * A PS_Parser is an object used to parse a Type 1 font very quickly.
- *
- * @fields:
- * cursor ::
- * The current position in the text.
- *
- * base ::
- * Start of the processed text.
- *
- * limit ::
- * End of the processed text.
- *
- * error ::
- * The last error returned.
- *
- * memory ::
- * The object used for memory operations (alloc/realloc).
- *
- * funcs ::
- * A table of functions for the parser.
- */
- typedef struct PS_ParserRec_
- {
- FT_Byte* cursor;
- FT_Byte* base;
- FT_Byte* limit;
- FT_Error error;
- FT_Memory memory;
-
- PS_Parser_FuncsRec funcs;
-
- } PS_ParserRec;
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** PS BUILDER *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- typedef struct PS_Builder_ PS_Builder;
- typedef const struct PS_Builder_FuncsRec_* PS_Builder_Funcs;
-
- typedef struct PS_Builder_FuncsRec_
- {
- void
- (*init)( PS_Builder* ps_builder,
- void* builder,
- FT_Bool is_t1 );
-
- void
- (*done)( PS_Builder* builder );
-
- } PS_Builder_FuncsRec;
-
-
- /**************************************************************************
- *
- * @struct:
- * PS_Builder
- *
- * @description:
- * A structure used during glyph loading to store its outline.
- *
- * @fields:
- * memory ::
- * The current memory object.
- *
- * face ::
- * The current face object.
- *
- * glyph ::
- * The current glyph slot.
- *
- * loader ::
- * XXX
- *
- * base ::
- * The base glyph outline.
- *
- * current ::
- * The current glyph outline.
- *
- * pos_x ::
- * The horizontal translation (if composite glyph).
- *
- * pos_y ::
- * The vertical translation (if composite glyph).
- *
- * left_bearing ::
- * The left side bearing point.
- *
- * advance ::
- * The horizontal advance vector.
- *
- * bbox ::
- * Unused.
- *
- * path_begun ::
- * A flag which indicates that a new path has begun.
- *
- * load_points ::
- * If this flag is not set, no points are loaded.
- *
- * no_recurse ::
- * Set but not used.
- *
- * metrics_only ::
- * A boolean indicating that we only want to compute the metrics of a
- * given glyph, not load all of its points.
- *
- * is_t1 ::
- * Set if current font type is Type 1.
- *
- * funcs ::
- * An array of function pointers for the builder.
- */
- struct PS_Builder_
- {
- FT_Memory memory;
- FT_Face face;
- CFF_GlyphSlot glyph;
- FT_GlyphLoader loader;
- FT_Outline* base;
- FT_Outline* current;
-
- FT_Pos* pos_x;
- FT_Pos* pos_y;
-
- FT_Vector* left_bearing;
- FT_Vector* advance;
-
- FT_BBox* bbox; /* bounding box */
- FT_Bool path_begun;
- FT_Bool load_points;
- FT_Bool no_recurse;
-
- FT_Bool metrics_only;
- FT_Bool is_t1;
-
- PS_Builder_FuncsRec funcs;
-
- };
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** PS DECODER *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-#define PS_MAX_OPERANDS 48
-#define PS_MAX_SUBRS_CALLS 16 /* maximum subroutine nesting; */
- /* only 10 are allowed but there exist */
- /* fonts like `HiraKakuProN-W3.ttf' */
- /* (Hiragino Kaku Gothic ProN W3; */
- /* 8.2d6e1; 2014-12-19) that exceed */
- /* this limit */
-
- /* execution context charstring zone */
-
- typedef struct PS_Decoder_Zone_
- {
- FT_Byte* base;
- FT_Byte* limit;
- FT_Byte* cursor;
-
- } PS_Decoder_Zone;
-
-
- typedef FT_Error
- (*CFF_Decoder_Get_Glyph_Callback)( TT_Face face,
- FT_UInt glyph_index,
- FT_Byte** pointer,
- FT_ULong* length );
-
- typedef void
- (*CFF_Decoder_Free_Glyph_Callback)( TT_Face face,
- FT_Byte** pointer,
- FT_ULong length );
-
-
- typedef struct PS_Decoder_
- {
- PS_Builder builder;
-
- FT_Fixed stack[PS_MAX_OPERANDS + 1];
- FT_Fixed* top;
-
- PS_Decoder_Zone zones[PS_MAX_SUBRS_CALLS + 1];
- PS_Decoder_Zone* zone;
-
- FT_Int flex_state;
- FT_Int num_flex_vectors;
- FT_Vector flex_vectors[7];
-
- CFF_Font cff;
- CFF_SubFont current_subfont; /* for current glyph_index */
- FT_Generic* cf2_instance;
-
- FT_Pos* glyph_width;
- FT_Bool width_only;
- FT_Int num_hints;
-
- FT_UInt num_locals;
- FT_UInt num_globals;
-
- FT_Int locals_bias;
- FT_Int globals_bias;
-
- FT_Byte** locals;
- FT_Byte** globals;
-
- FT_Byte** glyph_names; /* for pure CFF fonts only */
- FT_UInt num_glyphs; /* number of glyphs in font */
-
- FT_Render_Mode hint_mode;
-
- FT_Bool seac;
-
- CFF_Decoder_Get_Glyph_Callback get_glyph_callback;
- CFF_Decoder_Free_Glyph_Callback free_glyph_callback;
-
- /* Type 1 stuff */
- FT_Service_PsCMaps psnames; /* for seac */
-
- FT_Int lenIV; /* internal for sub routine calls */
- FT_UInt* locals_len; /* array of subrs length (optional) */
- FT_Hash locals_hash; /* used if `num_subrs' was massaged */
-
- FT_Matrix font_matrix;
- FT_Vector font_offset;
-
- PS_Blend blend; /* for multiple master support */
-
- FT_Long* buildchar;
- FT_UInt len_buildchar;
-
- } PS_Decoder;
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** T1 BUILDER *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- typedef struct T1_BuilderRec_* T1_Builder;
-
-
- typedef FT_Error
- (*T1_Builder_Check_Points_Func)( T1_Builder builder,
- FT_Int count );
-
- typedef void
- (*T1_Builder_Add_Point_Func)( T1_Builder builder,
- FT_Pos x,
- FT_Pos y,
- FT_Byte flag );
-
- typedef FT_Error
- (*T1_Builder_Add_Point1_Func)( T1_Builder builder,
- FT_Pos x,
- FT_Pos y );
-
- typedef FT_Error
- (*T1_Builder_Add_Contour_Func)( T1_Builder builder );
-
- typedef FT_Error
- (*T1_Builder_Start_Point_Func)( T1_Builder builder,
- FT_Pos x,
- FT_Pos y );
-
- typedef void
- (*T1_Builder_Close_Contour_Func)( T1_Builder builder );
-
-
- typedef const struct T1_Builder_FuncsRec_* T1_Builder_Funcs;
-
- typedef struct T1_Builder_FuncsRec_
- {
- void
- (*init)( T1_Builder builder,
- FT_Face face,
- FT_Size size,
- FT_GlyphSlot slot,
- FT_Bool hinting );
-
- void
- (*done)( T1_Builder builder );
-
- T1_Builder_Check_Points_Func check_points;
- T1_Builder_Add_Point_Func add_point;
- T1_Builder_Add_Point1_Func add_point1;
- T1_Builder_Add_Contour_Func add_contour;
- T1_Builder_Start_Point_Func start_point;
- T1_Builder_Close_Contour_Func close_contour;
-
- } T1_Builder_FuncsRec;
-
-
- /* an enumeration type to handle charstring parsing states */
- typedef enum T1_ParseState_
- {
- T1_Parse_Start,
- T1_Parse_Have_Width,
- T1_Parse_Have_Moveto,
- T1_Parse_Have_Path
-
- } T1_ParseState;
-
-
- /**************************************************************************
- *
- * @struct:
- * T1_BuilderRec
- *
- * @description:
- * A structure used during glyph loading to store its outline.
- *
- * @fields:
- * memory ::
- * The current memory object.
- *
- * face ::
- * The current face object.
- *
- * glyph ::
- * The current glyph slot.
- *
- * loader ::
- * XXX
- *
- * base ::
- * The base glyph outline.
- *
- * current ::
- * The current glyph outline.
- *
- * max_points ::
- * maximum points in builder outline
- *
- * max_contours ::
- * Maximum number of contours in builder outline.
- *
- * pos_x ::
- * The horizontal translation (if composite glyph).
- *
- * pos_y ::
- * The vertical translation (if composite glyph).
- *
- * left_bearing ::
- * The left side bearing point.
- *
- * advance ::
- * The horizontal advance vector.
- *
- * bbox ::
- * Unused.
- *
- * parse_state ::
- * An enumeration which controls the charstring parsing state.
- *
- * load_points ::
- * If this flag is not set, no points are loaded.
- *
- * no_recurse ::
- * Set but not used.
- *
- * metrics_only ::
- * A boolean indicating that we only want to compute the metrics of a
- * given glyph, not load all of its points.
- *
- * funcs ::
- * An array of function pointers for the builder.
- */
- typedef struct T1_BuilderRec_
- {
- FT_Memory memory;
- FT_Face face;
- FT_GlyphSlot glyph;
- FT_GlyphLoader loader;
- FT_Outline* base;
- FT_Outline* current;
-
- FT_Pos pos_x;
- FT_Pos pos_y;
-
- FT_Vector left_bearing;
- FT_Vector advance;
-
- FT_BBox bbox; /* bounding box */
- T1_ParseState parse_state;
- FT_Bool load_points;
- FT_Bool no_recurse;
-
- FT_Bool metrics_only;
-
- void* hints_funcs; /* hinter-specific */
- void* hints_globals; /* hinter-specific */
-
- T1_Builder_FuncsRec funcs;
-
- } T1_BuilderRec;
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** T1 DECODER *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-#if 0
-
- /**************************************************************************
- *
- * T1_MAX_SUBRS_CALLS details the maximum number of nested sub-routine
- * calls during glyph loading.
- */
-#define T1_MAX_SUBRS_CALLS 8
-
-
- /**************************************************************************
- *
- * T1_MAX_CHARSTRING_OPERANDS is the charstring stack's capacity. A
- * minimum of 16 is required.
- */
-#define T1_MAX_CHARSTRINGS_OPERANDS 32
-
-#endif /* 0 */
-
-
- typedef struct T1_Decoder_ZoneRec_
- {
- FT_Byte* cursor;
- FT_Byte* base;
- FT_Byte* limit;
-
- } T1_Decoder_ZoneRec, *T1_Decoder_Zone;
-
-
- typedef struct T1_DecoderRec_* T1_Decoder;
- typedef const struct T1_Decoder_FuncsRec_* T1_Decoder_Funcs;
-
-
- typedef FT_Error
- (*T1_Decoder_Callback)( T1_Decoder decoder,
- FT_UInt glyph_index );
-
-
- typedef struct T1_Decoder_FuncsRec_
- {
- FT_Error
- (*init)( T1_Decoder decoder,
- FT_Face face,
- FT_Size size,
- FT_GlyphSlot slot,
- FT_Byte** glyph_names,
- PS_Blend blend,
- FT_Bool hinting,
- FT_Render_Mode hint_mode,
- T1_Decoder_Callback callback );
-
- void
- (*done)( T1_Decoder decoder );
-
-#ifdef T1_CONFIG_OPTION_OLD_ENGINE
- FT_Error
- (*parse_charstrings_old)( T1_Decoder decoder,
- FT_Byte* base,
- FT_UInt len );
-#else
- FT_Error
- (*parse_metrics)( T1_Decoder decoder,
- FT_Byte* base,
- FT_UInt len );
-#endif
-
- FT_Error
- (*parse_charstrings)( PS_Decoder* decoder,
- FT_Byte* charstring_base,
- FT_ULong charstring_len );
-
-
- } T1_Decoder_FuncsRec;
-
-
- typedef struct T1_DecoderRec_
- {
- T1_BuilderRec builder;
-
- FT_Long stack[T1_MAX_CHARSTRINGS_OPERANDS];
- FT_Long* top;
-
- T1_Decoder_ZoneRec zones[T1_MAX_SUBRS_CALLS + 1];
- T1_Decoder_Zone zone;
-
- FT_Service_PsCMaps psnames; /* for seac */
- FT_UInt num_glyphs;
- FT_Byte** glyph_names;
-
- FT_Int lenIV; /* internal for sub routine calls */
- FT_Int num_subrs;
- FT_Byte** subrs;
- FT_UInt* subrs_len; /* array of subrs length (optional) */
- FT_Hash subrs_hash; /* used if `num_subrs' was massaged */
-
- FT_Matrix font_matrix;
- FT_Vector font_offset;
-
- FT_Int flex_state;
- FT_Int num_flex_vectors;
- FT_Vector flex_vectors[7];
-
- PS_Blend blend; /* for multiple master support */
-
- FT_Render_Mode hint_mode;
-
- T1_Decoder_Callback parse_callback;
- T1_Decoder_FuncsRec funcs;
-
- FT_Long* buildchar;
- FT_UInt len_buildchar;
-
- FT_Bool seac;
-
- FT_Generic cf2_instance;
-
- } T1_DecoderRec;
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** CFF BUILDER *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- typedef struct CFF_Builder_ CFF_Builder;
-
-
- typedef FT_Error
- (*CFF_Builder_Check_Points_Func)( CFF_Builder* builder,
- FT_Int count );
-
- typedef void
- (*CFF_Builder_Add_Point_Func)( CFF_Builder* builder,
- FT_Pos x,
- FT_Pos y,
- FT_Byte flag );
- typedef FT_Error
- (*CFF_Builder_Add_Point1_Func)( CFF_Builder* builder,
- FT_Pos x,
- FT_Pos y );
- typedef FT_Error
- (*CFF_Builder_Start_Point_Func)( CFF_Builder* builder,
- FT_Pos x,
- FT_Pos y );
- typedef void
- (*CFF_Builder_Close_Contour_Func)( CFF_Builder* builder );
-
- typedef FT_Error
- (*CFF_Builder_Add_Contour_Func)( CFF_Builder* builder );
-
- typedef const struct CFF_Builder_FuncsRec_* CFF_Builder_Funcs;
-
- typedef struct CFF_Builder_FuncsRec_
- {
- void
- (*init)( CFF_Builder* builder,
- TT_Face face,
- CFF_Size size,
- CFF_GlyphSlot glyph,
- FT_Bool hinting );
-
- void
- (*done)( CFF_Builder* builder );
-
- CFF_Builder_Check_Points_Func check_points;
- CFF_Builder_Add_Point_Func add_point;
- CFF_Builder_Add_Point1_Func add_point1;
- CFF_Builder_Add_Contour_Func add_contour;
- CFF_Builder_Start_Point_Func start_point;
- CFF_Builder_Close_Contour_Func close_contour;
-
- } CFF_Builder_FuncsRec;
-
-
- /**************************************************************************
- *
- * @struct:
- * CFF_Builder
- *
- * @description:
- * A structure used during glyph loading to store its outline.
- *
- * @fields:
- * memory ::
- * The current memory object.
- *
- * face ::
- * The current face object.
- *
- * glyph ::
- * The current glyph slot.
- *
- * loader ::
- * The current glyph loader.
- *
- * base ::
- * The base glyph outline.
- *
- * current ::
- * The current glyph outline.
- *
- * pos_x ::
- * The horizontal translation (if composite glyph).
- *
- * pos_y ::
- * The vertical translation (if composite glyph).
- *
- * left_bearing ::
- * The left side bearing point.
- *
- * advance ::
- * The horizontal advance vector.
- *
- * bbox ::
- * Unused.
- *
- * path_begun ::
- * A flag which indicates that a new path has begun.
- *
- * load_points ::
- * If this flag is not set, no points are loaded.
- *
- * no_recurse ::
- * Set but not used.
- *
- * metrics_only ::
- * A boolean indicating that we only want to compute the metrics of a
- * given glyph, not load all of its points.
- *
- * hints_funcs ::
- * Auxiliary pointer for hinting.
- *
- * hints_globals ::
- * Auxiliary pointer for hinting.
- *
- * funcs ::
- * A table of method pointers for this object.
- */
- struct CFF_Builder_
- {
- FT_Memory memory;
- TT_Face face;
- CFF_GlyphSlot glyph;
- FT_GlyphLoader loader;
- FT_Outline* base;
- FT_Outline* current;
-
- FT_Pos pos_x;
- FT_Pos pos_y;
-
- FT_Vector left_bearing;
- FT_Vector advance;
-
- FT_BBox bbox; /* bounding box */
-
- FT_Bool path_begun;
- FT_Bool load_points;
- FT_Bool no_recurse;
-
- FT_Bool metrics_only;
-
- void* hints_funcs; /* hinter-specific */
- void* hints_globals; /* hinter-specific */
-
- CFF_Builder_FuncsRec funcs;
- };
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** CFF DECODER *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-
-#define CFF_MAX_OPERANDS 48
-#define CFF_MAX_SUBRS_CALLS 16 /* maximum subroutine nesting; */
- /* only 10 are allowed but there exist */
- /* fonts like `HiraKakuProN-W3.ttf' */
- /* (Hiragino Kaku Gothic ProN W3; */
- /* 8.2d6e1; 2014-12-19) that exceed */
- /* this limit */
-#define CFF_MAX_TRANS_ELEMENTS 32
-
- /* execution context charstring zone */
-
- typedef struct CFF_Decoder_Zone_
- {
- FT_Byte* base;
- FT_Byte* limit;
- FT_Byte* cursor;
-
- } CFF_Decoder_Zone;
-
-
- typedef struct CFF_Decoder_
- {
- CFF_Builder builder;
- CFF_Font cff;
-
- FT_Fixed stack[CFF_MAX_OPERANDS + 1];
- FT_Fixed* top;
-
- CFF_Decoder_Zone zones[CFF_MAX_SUBRS_CALLS + 1];
- CFF_Decoder_Zone* zone;
-
- FT_Int flex_state;
- FT_Int num_flex_vectors;
- FT_Vector flex_vectors[7];
-
- FT_Pos glyph_width;
- FT_Pos nominal_width;
-
- FT_Bool read_width;
- FT_Bool width_only;
- FT_Int num_hints;
- FT_Fixed buildchar[CFF_MAX_TRANS_ELEMENTS];
-
- FT_UInt num_locals;
- FT_UInt num_globals;
-
- FT_Int locals_bias;
- FT_Int globals_bias;
-
- FT_Byte** locals;
- FT_Byte** globals;
-
- FT_Byte** glyph_names; /* for pure CFF fonts only */
- FT_UInt num_glyphs; /* number of glyphs in font */
-
- FT_Render_Mode hint_mode;
-
- FT_Bool seac;
-
- CFF_SubFont current_subfont; /* for current glyph_index */
-
- CFF_Decoder_Get_Glyph_Callback get_glyph_callback;
- CFF_Decoder_Free_Glyph_Callback free_glyph_callback;
-
- } CFF_Decoder;
-
-
- typedef const struct CFF_Decoder_FuncsRec_* CFF_Decoder_Funcs;
-
- typedef struct CFF_Decoder_FuncsRec_
- {
- void
- (*init)( CFF_Decoder* decoder,
- TT_Face face,
- CFF_Size size,
- CFF_GlyphSlot slot,
- FT_Bool hinting,
- FT_Render_Mode hint_mode,
- CFF_Decoder_Get_Glyph_Callback get_callback,
- CFF_Decoder_Free_Glyph_Callback free_callback );
-
- FT_Error
- (*prepare)( CFF_Decoder* decoder,
- CFF_Size size,
- FT_UInt glyph_index );
-
-#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
- FT_Error
- (*parse_charstrings_old)( CFF_Decoder* decoder,
- FT_Byte* charstring_base,
- FT_ULong charstring_len,
- FT_Bool in_dict );
-#endif
-
- FT_Error
- (*parse_charstrings)( PS_Decoder* decoder,
- FT_Byte* charstring_base,
- FT_ULong charstring_len );
-
- } CFF_Decoder_FuncsRec;
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** AFM PARSER *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- typedef struct AFM_ParserRec_* AFM_Parser;
-
- typedef struct AFM_Parser_FuncsRec_
- {
- FT_Error
- (*init)( AFM_Parser parser,
- FT_Memory memory,
- FT_Byte* base,
- FT_Byte* limit );
-
- void
- (*done)( AFM_Parser parser );
-
- FT_Error
- (*parse)( AFM_Parser parser );
-
- } AFM_Parser_FuncsRec;
-
-
- typedef struct AFM_StreamRec_* AFM_Stream;
-
-
- /**************************************************************************
- *
- * @struct:
- * AFM_ParserRec
- *
- * @description:
- * An AFM_Parser is a parser for the AFM files.
- *
- * @fields:
- * memory ::
- * The object used for memory operations (alloc and realloc).
- *
- * stream ::
- * This is an opaque object.
- *
- * FontInfo ::
- * The result will be stored here.
- *
- * get_index ::
- * A user provided function to get a glyph index by its name.
- */
- typedef struct AFM_ParserRec_
- {
- FT_Memory memory;
- AFM_Stream stream;
-
- AFM_FontInfo FontInfo;
-
- FT_Int
- (*get_index)( const char* name,
- FT_Offset len,
- void* user_data );
-
- void* user_data;
-
- } AFM_ParserRec;
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** TYPE1 CHARMAPS *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- typedef const struct T1_CMap_ClassesRec_* T1_CMap_Classes;
-
- typedef struct T1_CMap_ClassesRec_
- {
- FT_CMap_Class standard;
- FT_CMap_Class expert;
- FT_CMap_Class custom;
- FT_CMap_Class unicode;
-
- } T1_CMap_ClassesRec;
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** PSAux Module Interface *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- typedef struct PSAux_ServiceRec_
- {
- /* don't use `PS_Table_Funcs' and friends to avoid compiler warnings */
- const PS_Table_FuncsRec* ps_table_funcs;
- const PS_Parser_FuncsRec* ps_parser_funcs;
- const T1_Builder_FuncsRec* t1_builder_funcs;
- const T1_Decoder_FuncsRec* t1_decoder_funcs;
-
- void
- (*t1_decrypt)( FT_Byte* buffer,
- FT_Offset length,
- FT_UShort seed );
-
- FT_UInt32
- (*cff_random)( FT_UInt32 r );
-
- void
- (*ps_decoder_init)( PS_Decoder* ps_decoder,
- void* decoder,
- FT_Bool is_t1 );
-
- void
- (*t1_make_subfont)( FT_Face face,
- PS_Private priv,
- CFF_SubFont subfont );
-
- T1_CMap_Classes t1_cmap_classes;
-
- /* fields after this comment line were added after version 2.1.10 */
- const AFM_Parser_FuncsRec* afm_parser_funcs;
-
- const CFF_Decoder_FuncsRec* cff_decoder_funcs;
-
- } PSAux_ServiceRec, *PSAux_Service;
-
- /* backward compatible type definition */
- typedef PSAux_ServiceRec PSAux_Interface;
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** Some convenience functions *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-#define IS_PS_NEWLINE( ch ) \
- ( (ch) == '\r' || \
- (ch) == '\n' )
-
-#define IS_PS_SPACE( ch ) \
- ( (ch) == ' ' || \
- IS_PS_NEWLINE( ch ) || \
- (ch) == '\t' || \
- (ch) == '\f' || \
- (ch) == '\0' )
-
-#define IS_PS_SPECIAL( ch ) \
- ( (ch) == '/' || \
- (ch) == '(' || (ch) == ')' || \
- (ch) == '<' || (ch) == '>' || \
- (ch) == '[' || (ch) == ']' || \
- (ch) == '{' || (ch) == '}' || \
- (ch) == '%' )
-
-#define IS_PS_DELIM( ch ) \
- ( IS_PS_SPACE( ch ) || \
- IS_PS_SPECIAL( ch ) )
-
-#define IS_PS_DIGIT( ch ) \
- ( (ch) >= '0' && (ch) <= '9' )
-
-#define IS_PS_XDIGIT( ch ) \
- ( IS_PS_DIGIT( ch ) || \
- ( (ch) >= 'A' && (ch) <= 'F' ) || \
- ( (ch) >= 'a' && (ch) <= 'f' ) )
-
-#define IS_PS_BASE85( ch ) \
- ( (ch) >= '!' && (ch) <= 'u' )
-
-#define IS_PS_TOKEN( cur, limit, token ) \
- ( (char)(cur)[0] == (token)[0] && \
- ( (cur) + sizeof ( (token) ) == (limit) || \
- ( (cur) + sizeof( (token) ) < (limit) && \
- IS_PS_DELIM( (cur)[sizeof ( (token) ) - 1] ) ) ) && \
- ft_strncmp( (char*)(cur), (token), sizeof ( (token) ) - 1 ) == 0 )
-
-
-FT_END_HEADER
-
-#endif /* PSAUX_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/pshints.h b/contrib/libs/freetype/include/freetype/internal/pshints.h
deleted file mode 100644
index dba6c7303f..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/pshints.h
+++ /dev/null
@@ -1,699 +0,0 @@
-/****************************************************************************
- *
- * pshints.h
- *
- * Interface to Postscript-specific (Type 1 and Type 2) hints
- * recorders (specification only). These are used to support native
- * T1/T2 hints in the 'type1', 'cid', and 'cff' font drivers.
- *
- * Copyright (C) 2001-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef PSHINTS_H_
-#define PSHINTS_H_
-
-
-#include <freetype/freetype.h>
-#include <freetype/t1tables.h>
-
-
-FT_BEGIN_HEADER
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** INTERNAL REPRESENTATION OF GLOBALS *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- typedef struct PSH_GlobalsRec_* PSH_Globals;
-
- typedef FT_Error
- (*PSH_Globals_NewFunc)( FT_Memory memory,
- T1_Private* private_dict,
- PSH_Globals* aglobals );
-
- typedef void
- (*PSH_Globals_SetScaleFunc)( PSH_Globals globals,
- FT_Fixed x_scale,
- FT_Fixed y_scale,
- FT_Fixed x_delta,
- FT_Fixed y_delta );
-
- typedef void
- (*PSH_Globals_DestroyFunc)( PSH_Globals globals );
-
-
- typedef struct PSH_Globals_FuncsRec_
- {
- PSH_Globals_NewFunc create;
- PSH_Globals_SetScaleFunc set_scale;
- PSH_Globals_DestroyFunc destroy;
-
- } PSH_Globals_FuncsRec, *PSH_Globals_Funcs;
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** PUBLIC TYPE 1 HINTS RECORDER *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- /**************************************************************************
- *
- * @type:
- * T1_Hints
- *
- * @description:
- * This is a handle to an opaque structure used to record glyph hints
- * from a Type 1 character glyph character string.
- *
- * The methods used to operate on this object are defined by the
- * @T1_Hints_FuncsRec structure. Recording glyph hints is normally
- * achieved through the following scheme:
- *
- * - Open a new hint recording session by calling the 'open' method.
- * This rewinds the recorder and prepare it for new input.
- *
- * - For each hint found in the glyph charstring, call the corresponding
- * method ('stem', 'stem3', or 'reset'). Note that these functions do
- * not return an error code.
- *
- * - Close the recording session by calling the 'close' method. It
- * returns an error code if the hints were invalid or something strange
- * happened (e.g., memory shortage).
- *
- * The hints accumulated in the object can later be used by the
- * PostScript hinter.
- *
- */
- typedef struct T1_HintsRec_* T1_Hints;
-
-
- /**************************************************************************
- *
- * @type:
- * T1_Hints_Funcs
- *
- * @description:
- * A pointer to the @T1_Hints_FuncsRec structure that defines the API of
- * a given @T1_Hints object.
- *
- */
- typedef const struct T1_Hints_FuncsRec_* T1_Hints_Funcs;
-
-
- /**************************************************************************
- *
- * @functype:
- * T1_Hints_OpenFunc
- *
- * @description:
- * A method of the @T1_Hints class used to prepare it for a new Type 1
- * hints recording session.
- *
- * @input:
- * hints ::
- * A handle to the Type 1 hints recorder.
- *
- * @note:
- * You should always call the @T1_Hints_CloseFunc method in order to
- * close an opened recording session.
- *
- */
- typedef void
- (*T1_Hints_OpenFunc)( T1_Hints hints );
-
-
- /**************************************************************************
- *
- * @functype:
- * T1_Hints_SetStemFunc
- *
- * @description:
- * A method of the @T1_Hints class used to record a new horizontal or
- * vertical stem. This corresponds to the Type 1 'hstem' and 'vstem'
- * operators.
- *
- * @input:
- * hints ::
- * A handle to the Type 1 hints recorder.
- *
- * dimension ::
- * 0 for horizontal stems (hstem), 1 for vertical ones (vstem).
- *
- * coords ::
- * Array of 2 coordinates in 16.16 format, used as (position,length)
- * stem descriptor.
- *
- * @note:
- * Use vertical coordinates (y) for horizontal stems (dim=0). Use
- * horizontal coordinates (x) for vertical stems (dim=1).
- *
- * 'coords[0]' is the absolute stem position (lowest coordinate);
- * 'coords[1]' is the length.
- *
- * The length can be negative, in which case it must be either -20 or
- * -21. It is interpreted as a 'ghost' stem, according to the Type 1
- * specification.
- *
- * If the length is -21 (corresponding to a bottom ghost stem), then the
- * real stem position is 'coords[0]+coords[1]'.
- *
- */
- typedef void
- (*T1_Hints_SetStemFunc)( T1_Hints hints,
- FT_UInt dimension,
- FT_Fixed* coords );
-
-
- /**************************************************************************
- *
- * @functype:
- * T1_Hints_SetStem3Func
- *
- * @description:
- * A method of the @T1_Hints class used to record three
- * counter-controlled horizontal or vertical stems at once.
- *
- * @input:
- * hints ::
- * A handle to the Type 1 hints recorder.
- *
- * dimension ::
- * 0 for horizontal stems, 1 for vertical ones.
- *
- * coords ::
- * An array of 6 values in 16.16 format, holding 3 (position,length)
- * pairs for the counter-controlled stems.
- *
- * @note:
- * Use vertical coordinates (y) for horizontal stems (dim=0). Use
- * horizontal coordinates (x) for vertical stems (dim=1).
- *
- * The lengths cannot be negative (ghost stems are never
- * counter-controlled).
- *
- */
- typedef void
- (*T1_Hints_SetStem3Func)( T1_Hints hints,
- FT_UInt dimension,
- FT_Fixed* coords );
-
-
- /**************************************************************************
- *
- * @functype:
- * T1_Hints_ResetFunc
- *
- * @description:
- * A method of the @T1_Hints class used to reset the stems hints in a
- * recording session.
- *
- * @input:
- * hints ::
- * A handle to the Type 1 hints recorder.
- *
- * end_point ::
- * The index of the last point in the input glyph in which the
- * previously defined hints apply.
- *
- */
- typedef void
- (*T1_Hints_ResetFunc)( T1_Hints hints,
- FT_UInt end_point );
-
-
- /**************************************************************************
- *
- * @functype:
- * T1_Hints_CloseFunc
- *
- * @description:
- * A method of the @T1_Hints class used to close a hint recording
- * session.
- *
- * @input:
- * hints ::
- * A handle to the Type 1 hints recorder.
- *
- * end_point ::
- * The index of the last point in the input glyph.
- *
- * @return:
- * FreeType error code. 0 means success.
- *
- * @note:
- * The error code is set to indicate that an error occurred during the
- * recording session.
- *
- */
- typedef FT_Error
- (*T1_Hints_CloseFunc)( T1_Hints hints,
- FT_UInt end_point );
-
-
- /**************************************************************************
- *
- * @functype:
- * T1_Hints_ApplyFunc
- *
- * @description:
- * A method of the @T1_Hints class used to apply hints to the
- * corresponding glyph outline. Must be called once all hints have been
- * recorded.
- *
- * @input:
- * hints ::
- * A handle to the Type 1 hints recorder.
- *
- * outline ::
- * A pointer to the target outline descriptor.
- *
- * globals ::
- * The hinter globals for this font.
- *
- * hint_mode ::
- * Hinting information.
- *
- * @return:
- * FreeType error code. 0 means success.
- *
- * @note:
- * On input, all points within the outline are in font coordinates. On
- * output, they are in 1/64 of pixels.
- *
- * The scaling transformation is taken from the 'globals' object which
- * must correspond to the same font as the glyph.
- *
- */
- typedef FT_Error
- (*T1_Hints_ApplyFunc)( T1_Hints hints,
- FT_Outline* outline,
- PSH_Globals globals,
- FT_Render_Mode hint_mode );
-
-
- /**************************************************************************
- *
- * @struct:
- * T1_Hints_FuncsRec
- *
- * @description:
- * The structure used to provide the API to @T1_Hints objects.
- *
- * @fields:
- * hints ::
- * A handle to the T1 Hints recorder.
- *
- * open ::
- * The function to open a recording session.
- *
- * close ::
- * The function to close a recording session.
- *
- * stem ::
- * The function to set a simple stem.
- *
- * stem3 ::
- * The function to set counter-controlled stems.
- *
- * reset ::
- * The function to reset stem hints.
- *
- * apply ::
- * The function to apply the hints to the corresponding glyph outline.
- *
- */
- typedef struct T1_Hints_FuncsRec_
- {
- T1_Hints hints;
- T1_Hints_OpenFunc open;
- T1_Hints_CloseFunc close;
- T1_Hints_SetStemFunc stem;
- T1_Hints_SetStem3Func stem3;
- T1_Hints_ResetFunc reset;
- T1_Hints_ApplyFunc apply;
-
- } T1_Hints_FuncsRec;
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** PUBLIC TYPE 2 HINTS RECORDER *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- /**************************************************************************
- *
- * @type:
- * T2_Hints
- *
- * @description:
- * This is a handle to an opaque structure used to record glyph hints
- * from a Type 2 character glyph character string.
- *
- * The methods used to operate on this object are defined by the
- * @T2_Hints_FuncsRec structure. Recording glyph hints is normally
- * achieved through the following scheme:
- *
- * - Open a new hint recording session by calling the 'open' method.
- * This rewinds the recorder and prepare it for new input.
- *
- * - For each hint found in the glyph charstring, call the corresponding
- * method ('stems', 'hintmask', 'counters'). Note that these functions
- * do not return an error code.
- *
- * - Close the recording session by calling the 'close' method. It
- * returns an error code if the hints were invalid or something strange
- * happened (e.g., memory shortage).
- *
- * The hints accumulated in the object can later be used by the
- * Postscript hinter.
- *
- */
- typedef struct T2_HintsRec_* T2_Hints;
-
-
- /**************************************************************************
- *
- * @type:
- * T2_Hints_Funcs
- *
- * @description:
- * A pointer to the @T2_Hints_FuncsRec structure that defines the API of
- * a given @T2_Hints object.
- *
- */
- typedef const struct T2_Hints_FuncsRec_* T2_Hints_Funcs;
-
-
- /**************************************************************************
- *
- * @functype:
- * T2_Hints_OpenFunc
- *
- * @description:
- * A method of the @T2_Hints class used to prepare it for a new Type 2
- * hints recording session.
- *
- * @input:
- * hints ::
- * A handle to the Type 2 hints recorder.
- *
- * @note:
- * You should always call the @T2_Hints_CloseFunc method in order to
- * close an opened recording session.
- *
- */
- typedef void
- (*T2_Hints_OpenFunc)( T2_Hints hints );
-
-
- /**************************************************************************
- *
- * @functype:
- * T2_Hints_StemsFunc
- *
- * @description:
- * A method of the @T2_Hints class used to set the table of stems in
- * either the vertical or horizontal dimension. Equivalent to the
- * 'hstem', 'vstem', 'hstemhm', and 'vstemhm' Type 2 operators.
- *
- * @input:
- * hints ::
- * A handle to the Type 2 hints recorder.
- *
- * dimension ::
- * 0 for horizontal stems (hstem), 1 for vertical ones (vstem).
- *
- * count ::
- * The number of stems.
- *
- * coords ::
- * An array of 'count' (position,length) pairs in 16.16 format.
- *
- * @note:
- * Use vertical coordinates (y) for horizontal stems (dim=0). Use
- * horizontal coordinates (x) for vertical stems (dim=1).
- *
- * There are '2*count' elements in the 'coords' array. Each even element
- * is an absolute position in font units, each odd element is a length in
- * font units.
- *
- * A length can be negative, in which case it must be either -20 or -21.
- * It is interpreted as a 'ghost' stem, according to the Type 1
- * specification.
- *
- */
- typedef void
- (*T2_Hints_StemsFunc)( T2_Hints hints,
- FT_UInt dimension,
- FT_Int count,
- FT_Fixed* coordinates );
-
-
- /**************************************************************************
- *
- * @functype:
- * T2_Hints_MaskFunc
- *
- * @description:
- * A method of the @T2_Hints class used to set a given hintmask (this
- * corresponds to the 'hintmask' Type 2 operator).
- *
- * @input:
- * hints ::
- * A handle to the Type 2 hints recorder.
- *
- * end_point ::
- * The glyph index of the last point to which the previously defined or
- * activated hints apply.
- *
- * bit_count ::
- * The number of bits in the hint mask.
- *
- * bytes ::
- * An array of bytes modelling the hint mask.
- *
- * @note:
- * If the hintmask starts the charstring (before any glyph point
- * definition), the value of `end_point` should be 0.
- *
- * `bit_count` is the number of meaningful bits in the 'bytes' array; it
- * must be equal to the total number of hints defined so far (i.e.,
- * horizontal+verticals).
- *
- * The 'bytes' array can come directly from the Type 2 charstring and
- * respects the same format.
- *
- */
- typedef void
- (*T2_Hints_MaskFunc)( T2_Hints hints,
- FT_UInt end_point,
- FT_UInt bit_count,
- const FT_Byte* bytes );
-
-
- /**************************************************************************
- *
- * @functype:
- * T2_Hints_CounterFunc
- *
- * @description:
- * A method of the @T2_Hints class used to set a given counter mask (this
- * corresponds to the 'hintmask' Type 2 operator).
- *
- * @input:
- * hints ::
- * A handle to the Type 2 hints recorder.
- *
- * end_point ::
- * A glyph index of the last point to which the previously defined or
- * active hints apply.
- *
- * bit_count ::
- * The number of bits in the hint mask.
- *
- * bytes ::
- * An array of bytes modelling the hint mask.
- *
- * @note:
- * If the hintmask starts the charstring (before any glyph point
- * definition), the value of `end_point` should be 0.
- *
- * `bit_count` is the number of meaningful bits in the 'bytes' array; it
- * must be equal to the total number of hints defined so far (i.e.,
- * horizontal+verticals).
- *
- * The 'bytes' array can come directly from the Type 2 charstring and
- * respects the same format.
- *
- */
- typedef void
- (*T2_Hints_CounterFunc)( T2_Hints hints,
- FT_UInt bit_count,
- const FT_Byte* bytes );
-
-
- /**************************************************************************
- *
- * @functype:
- * T2_Hints_CloseFunc
- *
- * @description:
- * A method of the @T2_Hints class used to close a hint recording
- * session.
- *
- * @input:
- * hints ::
- * A handle to the Type 2 hints recorder.
- *
- * end_point ::
- * The index of the last point in the input glyph.
- *
- * @return:
- * FreeType error code. 0 means success.
- *
- * @note:
- * The error code is set to indicate that an error occurred during the
- * recording session.
- *
- */
- typedef FT_Error
- (*T2_Hints_CloseFunc)( T2_Hints hints,
- FT_UInt end_point );
-
-
- /**************************************************************************
- *
- * @functype:
- * T2_Hints_ApplyFunc
- *
- * @description:
- * A method of the @T2_Hints class used to apply hints to the
- * corresponding glyph outline. Must be called after the 'close' method.
- *
- * @input:
- * hints ::
- * A handle to the Type 2 hints recorder.
- *
- * outline ::
- * A pointer to the target outline descriptor.
- *
- * globals ::
- * The hinter globals for this font.
- *
- * hint_mode ::
- * Hinting information.
- *
- * @return:
- * FreeType error code. 0 means success.
- *
- * @note:
- * On input, all points within the outline are in font coordinates. On
- * output, they are in 1/64 of pixels.
- *
- * The scaling transformation is taken from the 'globals' object which
- * must correspond to the same font than the glyph.
- *
- */
- typedef FT_Error
- (*T2_Hints_ApplyFunc)( T2_Hints hints,
- FT_Outline* outline,
- PSH_Globals globals,
- FT_Render_Mode hint_mode );
-
-
- /**************************************************************************
- *
- * @struct:
- * T2_Hints_FuncsRec
- *
- * @description:
- * The structure used to provide the API to @T2_Hints objects.
- *
- * @fields:
- * hints ::
- * A handle to the T2 hints recorder object.
- *
- * open ::
- * The function to open a recording session.
- *
- * close ::
- * The function to close a recording session.
- *
- * stems ::
- * The function to set the dimension's stems table.
- *
- * hintmask ::
- * The function to set hint masks.
- *
- * counter ::
- * The function to set counter masks.
- *
- * apply ::
- * The function to apply the hints on the corresponding glyph outline.
- *
- */
- typedef struct T2_Hints_FuncsRec_
- {
- T2_Hints hints;
- T2_Hints_OpenFunc open;
- T2_Hints_CloseFunc close;
- T2_Hints_StemsFunc stems;
- T2_Hints_MaskFunc hintmask;
- T2_Hints_CounterFunc counter;
- T2_Hints_ApplyFunc apply;
-
- } T2_Hints_FuncsRec;
-
-
- /* */
-
-
- typedef struct PSHinter_Interface_
- {
- PSH_Globals_Funcs (*get_globals_funcs)( FT_Module module );
- T1_Hints_Funcs (*get_t1_funcs) ( FT_Module module );
- T2_Hints_Funcs (*get_t2_funcs) ( FT_Module module );
-
- } PSHinter_Interface;
-
- typedef PSHinter_Interface* PSHinter_Service;
-
-
-#define FT_DEFINE_PSHINTER_INTERFACE( \
- class_, \
- get_globals_funcs_, \
- get_t1_funcs_, \
- get_t2_funcs_ ) \
- static const PSHinter_Interface class_ = \
- { \
- get_globals_funcs_, \
- get_t1_funcs_, \
- get_t2_funcs_ \
- };
-
-
-FT_END_HEADER
-
-#endif /* PSHINTS_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/services/svbdf.h b/contrib/libs/freetype/include/freetype/internal/services/svbdf.h
deleted file mode 100644
index 89e9c2e5de..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/services/svbdf.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
- *
- * svbdf.h
- *
- * The FreeType BDF services (specification).
- *
- * Copyright (C) 2003-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef SVBDF_H_
-#define SVBDF_H_
-
-#include <freetype/ftbdf.h>
-#include <freetype/internal/ftserv.h>
-
-
-FT_BEGIN_HEADER
-
-
-#define FT_SERVICE_ID_BDF "bdf"
-
- typedef FT_Error
- (*FT_BDF_GetCharsetIdFunc)( FT_Face face,
- const char* *acharset_encoding,
- const char* *acharset_registry );
-
- typedef FT_Error
- (*FT_BDF_GetPropertyFunc)( FT_Face face,
- const char* prop_name,
- BDF_PropertyRec *aproperty );
-
-
- FT_DEFINE_SERVICE( BDF )
- {
- FT_BDF_GetCharsetIdFunc get_charset_id;
- FT_BDF_GetPropertyFunc get_property;
- };
-
-
-#define FT_DEFINE_SERVICE_BDFRec( class_, \
- get_charset_id_, \
- get_property_ ) \
- static const FT_Service_BDFRec class_ = \
- { \
- get_charset_id_, get_property_ \
- };
-
- /* */
-
-
-FT_END_HEADER
-
-
-#endif /* SVBDF_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/services/svcfftl.h b/contrib/libs/freetype/include/freetype/internal/services/svcfftl.h
deleted file mode 100644
index 3cb483c344..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/services/svcfftl.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/****************************************************************************
- *
- * svcfftl.h
- *
- * The FreeType CFF tables loader service (specification).
- *
- * Copyright (C) 2017-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef SVCFFTL_H_
-#define SVCFFTL_H_
-
-#include <freetype/internal/ftserv.h>
-#include <freetype/internal/cfftypes.h>
-
-
-FT_BEGIN_HEADER
-
-
-#define FT_SERVICE_ID_CFF_LOAD "cff-load"
-
-
- typedef FT_UShort
- (*FT_Get_Standard_Encoding_Func)( FT_UInt charcode );
-
- typedef FT_Error
- (*FT_Load_Private_Dict_Func)( CFF_Font font,
- CFF_SubFont subfont,
- FT_UInt lenNDV,
- FT_Fixed* NDV );
-
- typedef FT_Byte
- (*FT_FD_Select_Get_Func)( CFF_FDSelect fdselect,
- FT_UInt glyph_index );
-
- typedef FT_Bool
- (*FT_Blend_Check_Vector_Func)( CFF_Blend blend,
- FT_UInt vsindex,
- FT_UInt lenNDV,
- FT_Fixed* NDV );
-
- typedef FT_Error
- (*FT_Blend_Build_Vector_Func)( CFF_Blend blend,
- FT_UInt vsindex,
- FT_UInt lenNDV,
- FT_Fixed* NDV );
-
-
- FT_DEFINE_SERVICE( CFFLoad )
- {
- FT_Get_Standard_Encoding_Func get_standard_encoding;
- FT_Load_Private_Dict_Func load_private_dict;
- FT_FD_Select_Get_Func fd_select_get;
- FT_Blend_Check_Vector_Func blend_check_vector;
- FT_Blend_Build_Vector_Func blend_build_vector;
- };
-
-
-#define FT_DEFINE_SERVICE_CFFLOADREC( class_, \
- get_standard_encoding_, \
- load_private_dict_, \
- fd_select_get_, \
- blend_check_vector_, \
- blend_build_vector_ ) \
- static const FT_Service_CFFLoadRec class_ = \
- { \
- get_standard_encoding_, \
- load_private_dict_, \
- fd_select_get_, \
- blend_check_vector_, \
- blend_build_vector_ \
- };
-
-
-FT_END_HEADER
-
-
-#endif
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/services/svcid.h b/contrib/libs/freetype/include/freetype/internal/services/svcid.h
deleted file mode 100644
index 8362cb8724..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/services/svcid.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/****************************************************************************
- *
- * svcid.h
- *
- * The FreeType CID font services (specification).
- *
- * Copyright (C) 2007-2024 by
- * Derek Clegg and Michael Toftdal.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef SVCID_H_
-#define SVCID_H_
-
-#include <freetype/internal/ftserv.h>
-
-
-FT_BEGIN_HEADER
-
-
-#define FT_SERVICE_ID_CID "CID"
-
- typedef FT_Error
- (*FT_CID_GetRegistryOrderingSupplementFunc)( FT_Face face,
- const char* *registry,
- const char* *ordering,
- FT_Int *supplement );
- typedef FT_Error
- (*FT_CID_GetIsInternallyCIDKeyedFunc)( FT_Face face,
- FT_Bool *is_cid );
- typedef FT_Error
- (*FT_CID_GetCIDFromGlyphIndexFunc)( FT_Face face,
- FT_UInt glyph_index,
- FT_UInt *cid );
-
- FT_DEFINE_SERVICE( CID )
- {
- FT_CID_GetRegistryOrderingSupplementFunc get_ros;
- FT_CID_GetIsInternallyCIDKeyedFunc get_is_cid;
- FT_CID_GetCIDFromGlyphIndexFunc get_cid_from_glyph_index;
- };
-
-
-#define FT_DEFINE_SERVICE_CIDREC( class_, \
- get_ros_, \
- get_is_cid_, \
- get_cid_from_glyph_index_ ) \
- static const FT_Service_CIDRec class_ = \
- { \
- get_ros_, get_is_cid_, get_cid_from_glyph_index_ \
- };
-
- /* */
-
-
-FT_END_HEADER
-
-
-#endif /* SVCID_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/services/svfntfmt.h b/contrib/libs/freetype/include/freetype/internal/services/svfntfmt.h
deleted file mode 100644
index 6b837e79fc..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/services/svfntfmt.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
- *
- * svfntfmt.h
- *
- * The FreeType font format service (specification only).
- *
- * Copyright (C) 2003-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef SVFNTFMT_H_
-#define SVFNTFMT_H_
-
-#include <freetype/internal/ftserv.h>
-
-
-FT_BEGIN_HEADER
-
-
- /*
- * A trivial service used to return the name of a face's font driver,
- * according to the XFree86 nomenclature. Note that the service data is a
- * simple constant string pointer.
- */
-
-#define FT_SERVICE_ID_FONT_FORMAT "font-format"
-
-#define FT_FONT_FORMAT_TRUETYPE "TrueType"
-#define FT_FONT_FORMAT_TYPE_1 "Type 1"
-#define FT_FONT_FORMAT_BDF "BDF"
-#define FT_FONT_FORMAT_PCF "PCF"
-#define FT_FONT_FORMAT_TYPE_42 "Type 42"
-#define FT_FONT_FORMAT_CID "CID Type 1"
-#define FT_FONT_FORMAT_CFF "CFF"
-#define FT_FONT_FORMAT_PFR "PFR"
-#define FT_FONT_FORMAT_WINFNT "Windows FNT"
-
- /* */
-
-
-FT_END_HEADER
-
-
-#endif /* SVFNTFMT_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/services/svgldict.h b/contrib/libs/freetype/include/freetype/internal/services/svgldict.h
deleted file mode 100644
index 6126ec9ada..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/services/svgldict.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/****************************************************************************
- *
- * svgldict.h
- *
- * The FreeType glyph dictionary services (specification).
- *
- * Copyright (C) 2003-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef SVGLDICT_H_
-#define SVGLDICT_H_
-
-#include <freetype/internal/ftserv.h>
-
-
-FT_BEGIN_HEADER
-
-
- /*
- * A service used to retrieve glyph names, as well as to find the index of
- * a given glyph name in a font.
- *
- */
-
-#define FT_SERVICE_ID_GLYPH_DICT "glyph-dict"
-
-
- typedef FT_Error
- (*FT_GlyphDict_GetNameFunc)( FT_Face face,
- FT_UInt glyph_index,
- FT_Pointer buffer,
- FT_UInt buffer_max );
-
- typedef FT_UInt
- (*FT_GlyphDict_NameIndexFunc)( FT_Face face,
- const FT_String* glyph_name );
-
-
- FT_DEFINE_SERVICE( GlyphDict )
- {
- FT_GlyphDict_GetNameFunc get_name;
- FT_GlyphDict_NameIndexFunc name_index; /* optional */
- };
-
-
-#define FT_DEFINE_SERVICE_GLYPHDICTREC( class_, \
- get_name_, \
- name_index_ ) \
- static const FT_Service_GlyphDictRec class_ = \
- { \
- get_name_, name_index_ \
- };
-
- /* */
-
-
-FT_END_HEADER
-
-
-#endif /* SVGLDICT_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/services/svgxval.h b/contrib/libs/freetype/include/freetype/internal/services/svgxval.h
deleted file mode 100644
index 29cf552818..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/services/svgxval.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/****************************************************************************
- *
- * svgxval.h
- *
- * FreeType API for validating TrueTypeGX/AAT tables (specification).
- *
- * Copyright (C) 2004-2024 by
- * Masatake YAMATO, Red Hat K.K.,
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-/****************************************************************************
- *
- * gxvalid is derived from both gxlayout module and otvalid module.
- * Development of gxlayout is supported by the Information-technology
- * Promotion Agency(IPA), Japan.
- *
- */
-
-
-#ifndef SVGXVAL_H_
-#define SVGXVAL_H_
-
-#include <freetype/ftgxval.h>
-#include <freetype/internal/ftvalid.h>
-
-FT_BEGIN_HEADER
-
-
-#define FT_SERVICE_ID_GX_VALIDATE "truetypegx-validate"
-#define FT_SERVICE_ID_CLASSICKERN_VALIDATE "classickern-validate"
-
- typedef FT_Error
- (*gxv_validate_func)( FT_Face face,
- FT_UInt gx_flags,
- FT_Bytes tables[FT_VALIDATE_GX_LENGTH],
- FT_UInt table_length );
-
-
- typedef FT_Error
- (*ckern_validate_func)( FT_Face face,
- FT_UInt ckern_flags,
- FT_Bytes *ckern_table );
-
-
- FT_DEFINE_SERVICE( GXvalidate )
- {
- gxv_validate_func validate;
- };
-
- FT_DEFINE_SERVICE( CKERNvalidate )
- {
- ckern_validate_func validate;
- };
-
- /* */
-
-
-FT_END_HEADER
-
-
-#endif /* SVGXVAL_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/services/svkern.h b/contrib/libs/freetype/include/freetype/internal/services/svkern.h
deleted file mode 100644
index ac1bc30c41..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/services/svkern.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/****************************************************************************
- *
- * svkern.h
- *
- * The FreeType Kerning service (specification).
- *
- * Copyright (C) 2006-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef SVKERN_H_
-#define SVKERN_H_
-
-#include <freetype/internal/ftserv.h>
-#include <freetype/tttables.h>
-
-
-FT_BEGIN_HEADER
-
-#define FT_SERVICE_ID_KERNING "kerning"
-
-
- typedef FT_Error
- (*FT_Kerning_TrackGetFunc)( FT_Face face,
- FT_Fixed point_size,
- FT_Int degree,
- FT_Fixed* akerning );
-
- FT_DEFINE_SERVICE( Kerning )
- {
- FT_Kerning_TrackGetFunc get_track;
- };
-
- /* */
-
-
-FT_END_HEADER
-
-
-#endif /* SVKERN_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/services/svmetric.h b/contrib/libs/freetype/include/freetype/internal/services/svmetric.h
deleted file mode 100644
index 8b3563b25c..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/services/svmetric.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/****************************************************************************
- *
- * svmetric.h
- *
- * The FreeType services for metrics variations (specification).
- *
- * Copyright (C) 2016-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef SVMETRIC_H_
-#define SVMETRIC_H_
-
-#include <freetype/internal/ftserv.h>
-
-
-FT_BEGIN_HEADER
-
-
- /*
- * A service to manage the `HVAR, `MVAR', and `VVAR' OpenType tables.
- *
- */
-
-#define FT_SERVICE_ID_METRICS_VARIATIONS "metrics-variations"
-
-
- /* HVAR */
-
- typedef FT_Error
- (*FT_HAdvance_Adjust_Func)( FT_Face face,
- FT_UInt gindex,
- FT_Int *avalue );
-
- typedef FT_Error
- (*FT_LSB_Adjust_Func)( FT_Face face,
- FT_UInt gindex,
- FT_Int *avalue );
-
- typedef FT_Error
- (*FT_RSB_Adjust_Func)( FT_Face face,
- FT_UInt gindex,
- FT_Int *avalue );
-
- /* VVAR */
-
- typedef FT_Error
- (*FT_VAdvance_Adjust_Func)( FT_Face face,
- FT_UInt gindex,
- FT_Int *avalue );
-
- typedef FT_Error
- (*FT_TSB_Adjust_Func)( FT_Face face,
- FT_UInt gindex,
- FT_Int *avalue );
-
- typedef FT_Error
- (*FT_BSB_Adjust_Func)( FT_Face face,
- FT_UInt gindex,
- FT_Int *avalue );
-
- typedef FT_Error
- (*FT_VOrg_Adjust_Func)( FT_Face face,
- FT_UInt gindex,
- FT_Int *avalue );
-
- /* MVAR */
-
- typedef void
- (*FT_Metrics_Adjust_Func)( FT_Face face );
-
- typedef FT_Error
- (*FT_Size_Reset_Func)( FT_Size size );
-
-
- FT_DEFINE_SERVICE( MetricsVariations )
- {
- FT_HAdvance_Adjust_Func hadvance_adjust;
- FT_LSB_Adjust_Func lsb_adjust;
- FT_RSB_Adjust_Func rsb_adjust;
-
- FT_VAdvance_Adjust_Func vadvance_adjust;
- FT_TSB_Adjust_Func tsb_adjust;
- FT_BSB_Adjust_Func bsb_adjust;
- FT_VOrg_Adjust_Func vorg_adjust;
-
- FT_Metrics_Adjust_Func metrics_adjust;
- FT_Size_Reset_Func size_reset;
- };
-
-
-#define FT_DEFINE_SERVICE_METRICSVARIATIONSREC( class_, \
- hadvance_adjust_, \
- lsb_adjust_, \
- rsb_adjust_, \
- vadvance_adjust_, \
- tsb_adjust_, \
- bsb_adjust_, \
- vorg_adjust_, \
- metrics_adjust_, \
- size_reset_ ) \
- static const FT_Service_MetricsVariationsRec class_ = \
- { \
- hadvance_adjust_, \
- lsb_adjust_, \
- rsb_adjust_, \
- vadvance_adjust_, \
- tsb_adjust_, \
- bsb_adjust_, \
- vorg_adjust_, \
- metrics_adjust_, \
- size_reset_ \
- };
-
- /* */
-
-
-FT_END_HEADER
-
-#endif /* SVMETRIC_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/services/svmm.h b/contrib/libs/freetype/include/freetype/internal/services/svmm.h
deleted file mode 100644
index 5288fadf37..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/services/svmm.h
+++ /dev/null
@@ -1,214 +0,0 @@
-/****************************************************************************
- *
- * svmm.h
- *
- * The FreeType Multiple Masters and GX var services (specification).
- *
- * Copyright (C) 2003-2024 by
- * David Turner, Robert Wilhelm, Werner Lemberg, and Dominik Röttsches.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef SVMM_H_
-#define SVMM_H_
-
-#include <freetype/ftmm.h>
-#include <freetype/internal/ftserv.h>
-#include <freetype/internal/ftmmtypes.h>
-
-
-FT_BEGIN_HEADER
-
-
- /*
- * A service used to manage multiple-masters data in a given face.
- *
- * See the related APIs in `ftmm.h' (FT_MULTIPLE_MASTERS_H).
- *
- */
-
-#define FT_SERVICE_ID_MULTI_MASTERS "multi-masters"
-
-
- typedef FT_Error
- (*FT_Get_MM_Func)( FT_Face face,
- FT_Multi_Master* master );
-
- typedef FT_Error
- (*FT_Get_MM_Var_Func)( FT_Face face,
- FT_MM_Var* *master );
-
- typedef FT_Error
- (*FT_Set_MM_Design_Func)( FT_Face face,
- FT_UInt num_coords,
- FT_Long* coords );
-
- /* use return value -1 to indicate that the new coordinates */
- /* are equal to the current ones; no changes are thus needed */
- typedef FT_Error
- (*FT_Set_Var_Design_Func)( FT_Face face,
- FT_UInt num_coords,
- FT_Fixed* coords );
-
- /* use return value -1 to indicate that the new coordinates */
- /* are equal to the current ones; no changes are thus needed */
- typedef FT_Error
- (*FT_Set_MM_Blend_Func)( FT_Face face,
- FT_UInt num_coords,
- FT_Fixed* coords );
-
- typedef FT_Error
- (*FT_Get_Var_Design_Func)( FT_Face face,
- FT_UInt num_coords,
- FT_Fixed* coords );
-
- typedef FT_Error
- (*FT_Set_Named_Instance_Func)( FT_Face face,
- FT_UInt instance_index );
-
- typedef FT_Error
- (*FT_Get_Default_Named_Instance_Func)( FT_Face face,
- FT_UInt *instance_index );
-
- typedef FT_Error
- (*FT_Get_MM_Blend_Func)( FT_Face face,
- FT_UInt num_coords,
- FT_Fixed* coords );
-
- typedef FT_Error
- (*FT_Get_Var_Blend_Func)( FT_Face face,
- FT_UInt *num_coords,
- FT_Fixed* *coords,
- FT_Fixed* *normalizedcoords,
- FT_MM_Var* *mm_var );
-
- typedef void
- (*FT_Done_Blend_Func)( FT_Face face );
-
- typedef FT_Error
- (*FT_Set_MM_WeightVector_Func)( FT_Face face,
- FT_UInt len,
- FT_Fixed* weight_vector );
-
- typedef FT_Error
- (*FT_Get_MM_WeightVector_Func)( FT_Face face,
- FT_UInt* len,
- FT_Fixed* weight_vector );
-
- typedef void
- (*FT_Construct_PS_Name_Func)( FT_Face face );
-
- typedef FT_Error
- (*FT_Var_Load_Delta_Set_Idx_Map_Func)( FT_Face face,
- FT_ULong offset,
- GX_DeltaSetIdxMap map,
- GX_ItemVarStore itemStore,
- FT_ULong table_len );
-
- typedef FT_Error
- (*FT_Var_Load_Item_Var_Store_Func)( FT_Face face,
- FT_ULong offset,
- GX_ItemVarStore itemStore );
-
- typedef FT_ItemVarDelta
- (*FT_Var_Get_Item_Delta_Func)( FT_Face face,
- GX_ItemVarStore itemStore,
- FT_UInt outerIndex,
- FT_UInt innerIndex );
-
- typedef void
- (*FT_Var_Done_Item_Var_Store_Func)( FT_Face face,
- GX_ItemVarStore itemStore );
-
- typedef void
- (*FT_Var_Done_Delta_Set_Idx_Map_Func)( FT_Face face,
- GX_DeltaSetIdxMap deltaSetIdxMap );
-
-
- FT_DEFINE_SERVICE( MultiMasters )
- {
- FT_Get_MM_Func get_mm;
- FT_Set_MM_Design_Func set_mm_design;
- FT_Set_MM_Blend_Func set_mm_blend;
- FT_Get_MM_Blend_Func get_mm_blend;
- FT_Get_MM_Var_Func get_mm_var;
- FT_Set_Var_Design_Func set_var_design;
- FT_Get_Var_Design_Func get_var_design;
- FT_Set_Named_Instance_Func set_named_instance;
- FT_Get_Default_Named_Instance_Func get_default_named_instance;
- FT_Set_MM_WeightVector_Func set_mm_weightvector;
- FT_Get_MM_WeightVector_Func get_mm_weightvector;
-
- /* for internal use; only needed for code sharing between modules */
- FT_Construct_PS_Name_Func construct_ps_name;
- FT_Var_Load_Delta_Set_Idx_Map_Func load_delta_set_idx_map;
- FT_Var_Load_Item_Var_Store_Func load_item_var_store;
- FT_Var_Get_Item_Delta_Func get_item_delta;
- FT_Var_Done_Item_Var_Store_Func done_item_var_store;
- FT_Var_Done_Delta_Set_Idx_Map_Func done_delta_set_idx_map;
- FT_Get_Var_Blend_Func get_var_blend;
- FT_Done_Blend_Func done_blend;
- };
-
-
-#define FT_DEFINE_SERVICE_MULTIMASTERSREC( class_, \
- get_mm_, \
- set_mm_design_, \
- set_mm_blend_, \
- get_mm_blend_, \
- get_mm_var_, \
- set_var_design_, \
- get_var_design_, \
- set_named_instance_, \
- get_default_named_instance_, \
- set_mm_weightvector_, \
- get_mm_weightvector_, \
- \
- construct_ps_name_, \
- load_delta_set_idx_map_, \
- load_item_var_store_, \
- get_item_delta_, \
- done_item_var_store_, \
- done_delta_set_idx_map_, \
- get_var_blend_, \
- done_blend_ ) \
- static const FT_Service_MultiMastersRec class_ = \
- { \
- get_mm_, \
- set_mm_design_, \
- set_mm_blend_, \
- get_mm_blend_, \
- get_mm_var_, \
- set_var_design_, \
- get_var_design_, \
- set_named_instance_, \
- get_default_named_instance_, \
- set_mm_weightvector_, \
- get_mm_weightvector_, \
- \
- construct_ps_name_, \
- load_delta_set_idx_map_, \
- load_item_var_store_, \
- get_item_delta_, \
- done_item_var_store_, \
- done_delta_set_idx_map_, \
- get_var_blend_, \
- done_blend_ \
- };
-
- /* */
-
-
-FT_END_HEADER
-
-#endif /* SVMM_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/services/svotval.h b/contrib/libs/freetype/include/freetype/internal/services/svotval.h
deleted file mode 100644
index 7aea7ec11f..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/services/svotval.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
- *
- * svotval.h
- *
- * The FreeType OpenType validation service (specification).
- *
- * Copyright (C) 2004-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef SVOTVAL_H_
-#define SVOTVAL_H_
-
-#include <freetype/ftotval.h>
-#include <freetype/internal/ftvalid.h>
-
-FT_BEGIN_HEADER
-
-
-#define FT_SERVICE_ID_OPENTYPE_VALIDATE "opentype-validate"
-
-
- typedef FT_Error
- (*otv_validate_func)( FT_Face volatile face,
- FT_UInt ot_flags,
- FT_Bytes *base,
- FT_Bytes *gdef,
- FT_Bytes *gpos,
- FT_Bytes *gsub,
- FT_Bytes *jstf );
-
-
- FT_DEFINE_SERVICE( OTvalidate )
- {
- otv_validate_func validate;
- };
-
- /* */
-
-
-FT_END_HEADER
-
-
-#endif /* SVOTVAL_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/services/svpfr.h b/contrib/libs/freetype/include/freetype/internal/services/svpfr.h
deleted file mode 100644
index b2fac6d086..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/services/svpfr.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************************
- *
- * svpfr.h
- *
- * Internal PFR service functions (specification).
- *
- * Copyright (C) 2003-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef SVPFR_H_
-#define SVPFR_H_
-
-#include <freetype/ftpfr.h>
-#include <freetype/internal/ftserv.h>
-
-
-FT_BEGIN_HEADER
-
-
-#define FT_SERVICE_ID_PFR_METRICS "pfr-metrics"
-
-
- typedef FT_Error
- (*FT_PFR_GetMetricsFunc)( FT_Face face,
- FT_UInt *aoutline,
- FT_UInt *ametrics,
- FT_Fixed *ax_scale,
- FT_Fixed *ay_scale );
-
- typedef FT_Error
- (*FT_PFR_GetKerningFunc)( FT_Face face,
- FT_UInt left,
- FT_UInt right,
- FT_Vector *avector );
-
- typedef FT_Error
- (*FT_PFR_GetAdvanceFunc)( FT_Face face,
- FT_UInt gindex,
- FT_Pos *aadvance );
-
-
- FT_DEFINE_SERVICE( PfrMetrics )
- {
- FT_PFR_GetMetricsFunc get_metrics;
- FT_PFR_GetKerningFunc get_kerning;
- FT_PFR_GetAdvanceFunc get_advance;
-
- };
-
-
-FT_END_HEADER
-
-#endif /* SVPFR_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/services/svpostnm.h b/contrib/libs/freetype/include/freetype/internal/services/svpostnm.h
deleted file mode 100644
index d19f3adc6d..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/services/svpostnm.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************************
- *
- * svpostnm.h
- *
- * The FreeType PostScript name services (specification).
- *
- * Copyright (C) 2003-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef SVPOSTNM_H_
-#define SVPOSTNM_H_
-
-#include <freetype/internal/ftserv.h>
-
-
-FT_BEGIN_HEADER
-
- /*
- * A trivial service used to retrieve the PostScript name of a given font
- * when available. The `get_name' field should never be `NULL`.
- *
- * The corresponding function can return `NULL` to indicate that the
- * PostScript name is not available.
- *
- * The name is owned by the face and will be destroyed with it.
- */
-
-#define FT_SERVICE_ID_POSTSCRIPT_FONT_NAME "postscript-font-name"
-
-
- typedef const char*
- (*FT_PsName_GetFunc)( FT_Face face );
-
-
- FT_DEFINE_SERVICE( PsFontName )
- {
- FT_PsName_GetFunc get_ps_font_name;
- };
-
-
-#define FT_DEFINE_SERVICE_PSFONTNAMEREC( class_, get_ps_font_name_ ) \
- static const FT_Service_PsFontNameRec class_ = \
- { \
- get_ps_font_name_ \
- };
-
- /* */
-
-
-FT_END_HEADER
-
-
-#endif /* SVPOSTNM_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/services/svprop.h b/contrib/libs/freetype/include/freetype/internal/services/svprop.h
deleted file mode 100644
index ba39c0dd4d..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/services/svprop.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
- *
- * svprop.h
- *
- * The FreeType property service (specification).
- *
- * Copyright (C) 2012-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef SVPROP_H_
-#define SVPROP_H_
-
-
-FT_BEGIN_HEADER
-
-
-#define FT_SERVICE_ID_PROPERTIES "properties"
-
-
- typedef FT_Error
- (*FT_Properties_SetFunc)( FT_Module module,
- const char* property_name,
- const void* value,
- FT_Bool value_is_string );
-
- typedef FT_Error
- (*FT_Properties_GetFunc)( FT_Module module,
- const char* property_name,
- void* value );
-
-
- FT_DEFINE_SERVICE( Properties )
- {
- FT_Properties_SetFunc set_property;
- FT_Properties_GetFunc get_property;
- };
-
-
-#define FT_DEFINE_SERVICE_PROPERTIESREC( class_, \
- set_property_, \
- get_property_ ) \
- static const FT_Service_PropertiesRec class_ = \
- { \
- set_property_, \
- get_property_ \
- };
-
- /* */
-
-
-FT_END_HEADER
-
-
-#endif /* SVPROP_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/services/svpscmap.h b/contrib/libs/freetype/include/freetype/internal/services/svpscmap.h
deleted file mode 100644
index d4908ee41a..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/services/svpscmap.h
+++ /dev/null
@@ -1,145 +0,0 @@
-/****************************************************************************
- *
- * svpscmap.h
- *
- * The FreeType PostScript charmap service (specification).
- *
- * Copyright (C) 2003-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef SVPSCMAP_H_
-#define SVPSCMAP_H_
-
-#include <freetype/internal/ftobjs.h>
-
-
-FT_BEGIN_HEADER
-
-
-#define FT_SERVICE_ID_POSTSCRIPT_CMAPS "postscript-cmaps"
-
-
- /*
- * Adobe glyph name to unicode value.
- */
- typedef FT_UInt32
- (*PS_Unicode_ValueFunc)( const char* glyph_name );
-
- /*
- * Macintosh name id to glyph name. `NULL` if invalid index.
- */
- typedef const char*
- (*PS_Macintosh_NameFunc)( FT_UInt name_index );
-
- /*
- * Adobe standard string ID to glyph name. `NULL` if invalid index.
- */
- typedef const char*
- (*PS_Adobe_Std_StringsFunc)( FT_UInt string_index );
-
-
- /*
- * Simple unicode -> glyph index charmap built from font glyph names table.
- */
- typedef struct PS_UniMap_
- {
- FT_UInt32 unicode; /* bit 31 set: is glyph variant */
- FT_UInt glyph_index;
-
- } PS_UniMap;
-
-
- typedef struct PS_UnicodesRec_* PS_Unicodes;
-
- typedef struct PS_UnicodesRec_
- {
- FT_CMapRec cmap;
- FT_UInt num_maps;
- PS_UniMap* maps;
-
- } PS_UnicodesRec;
-
-
- /*
- * A function which returns a glyph name for a given index. Returns
- * `NULL` if invalid index.
- */
- typedef const char*
- (*PS_GetGlyphNameFunc)( FT_Pointer data,
- FT_UInt string_index );
-
- /*
- * A function used to release the glyph name returned by
- * PS_GetGlyphNameFunc, when needed
- */
- typedef void
- (*PS_FreeGlyphNameFunc)( FT_Pointer data,
- const char* name );
-
- typedef FT_Error
- (*PS_Unicodes_InitFunc)( FT_Memory memory,
- PS_Unicodes unicodes,
- FT_UInt num_glyphs,
- PS_GetGlyphNameFunc get_glyph_name,
- PS_FreeGlyphNameFunc free_glyph_name,
- FT_Pointer glyph_data );
-
- typedef FT_UInt
- (*PS_Unicodes_CharIndexFunc)( PS_Unicodes unicodes,
- FT_UInt32 unicode );
-
- typedef FT_UInt
- (*PS_Unicodes_CharNextFunc)( PS_Unicodes unicodes,
- FT_UInt32 *unicode );
-
-
- FT_DEFINE_SERVICE( PsCMaps )
- {
- PS_Unicode_ValueFunc unicode_value;
-
- PS_Unicodes_InitFunc unicodes_init;
- PS_Unicodes_CharIndexFunc unicodes_char_index;
- PS_Unicodes_CharNextFunc unicodes_char_next;
-
- PS_Macintosh_NameFunc macintosh_name;
- PS_Adobe_Std_StringsFunc adobe_std_strings;
- const unsigned short* adobe_std_encoding;
- const unsigned short* adobe_expert_encoding;
- };
-
-
-#define FT_DEFINE_SERVICE_PSCMAPSREC( class_, \
- unicode_value_, \
- unicodes_init_, \
- unicodes_char_index_, \
- unicodes_char_next_, \
- macintosh_name_, \
- adobe_std_strings_, \
- adobe_std_encoding_, \
- adobe_expert_encoding_ ) \
- static const FT_Service_PsCMapsRec class_ = \
- { \
- unicode_value_, unicodes_init_, \
- unicodes_char_index_, unicodes_char_next_, macintosh_name_, \
- adobe_std_strings_, adobe_std_encoding_, adobe_expert_encoding_ \
- };
-
- /* */
-
-
-FT_END_HEADER
-
-
-#endif /* SVPSCMAP_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/services/svpsinfo.h b/contrib/libs/freetype/include/freetype/internal/services/svpsinfo.h
deleted file mode 100644
index 2aadcdd02a..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/services/svpsinfo.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/****************************************************************************
- *
- * svpsinfo.h
- *
- * The FreeType PostScript info service (specification).
- *
- * Copyright (C) 2003-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef SVPSINFO_H_
-#define SVPSINFO_H_
-
-#include <freetype/internal/ftserv.h>
-#include <freetype/internal/t1types.h>
-
-
-FT_BEGIN_HEADER
-
-
-#define FT_SERVICE_ID_POSTSCRIPT_INFO "postscript-info"
-
-
- typedef FT_Error
- (*PS_GetFontInfoFunc)( FT_Face face,
- PS_FontInfoRec* afont_info );
-
- typedef FT_Error
- (*PS_GetFontExtraFunc)( FT_Face face,
- PS_FontExtraRec* afont_extra );
-
- typedef FT_Int
- (*PS_HasGlyphNamesFunc)( FT_Face face );
-
- typedef FT_Error
- (*PS_GetFontPrivateFunc)( FT_Face face,
- PS_PrivateRec* afont_private );
-
- typedef FT_Long
- (*PS_GetFontValueFunc)( FT_Face face,
- PS_Dict_Keys key,
- FT_UInt idx,
- void *value,
- FT_Long value_len );
-
-
- FT_DEFINE_SERVICE( PsInfo )
- {
- PS_GetFontInfoFunc ps_get_font_info;
- PS_GetFontExtraFunc ps_get_font_extra;
- PS_HasGlyphNamesFunc ps_has_glyph_names;
- PS_GetFontPrivateFunc ps_get_font_private;
- PS_GetFontValueFunc ps_get_font_value;
- };
-
-
-#define FT_DEFINE_SERVICE_PSINFOREC( class_, \
- get_font_info_, \
- ps_get_font_extra_, \
- has_glyph_names_, \
- get_font_private_, \
- get_font_value_ ) \
- static const FT_Service_PsInfoRec class_ = \
- { \
- get_font_info_, ps_get_font_extra_, has_glyph_names_, \
- get_font_private_, get_font_value_ \
- };
-
- /* */
-
-
-FT_END_HEADER
-
-
-#endif /* SVPSINFO_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/services/svsfnt.h b/contrib/libs/freetype/include/freetype/internal/services/svsfnt.h
deleted file mode 100644
index 9e0f4ff202..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/services/svsfnt.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/****************************************************************************
- *
- * svsfnt.h
- *
- * The FreeType SFNT table loading service (specification).
- *
- * Copyright (C) 2003-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef SVSFNT_H_
-#define SVSFNT_H_
-
-#include <freetype/internal/ftserv.h>
-#include <freetype/tttables.h>
-
-
-FT_BEGIN_HEADER
-
-
- /*
- * SFNT table loading service.
- */
-
-#define FT_SERVICE_ID_SFNT_TABLE "sfnt-table"
-
-
- /*
- * Used to implement FT_Load_Sfnt_Table().
- */
- typedef FT_Error
- (*FT_SFNT_TableLoadFunc)( FT_Face face,
- FT_ULong tag,
- FT_Long offset,
- FT_Byte* buffer,
- FT_ULong* length );
-
- /*
- * Used to implement FT_Get_Sfnt_Table().
- */
- typedef void*
- (*FT_SFNT_TableGetFunc)( FT_Face face,
- FT_Sfnt_Tag tag );
-
-
- /*
- * Used to implement FT_Sfnt_Table_Info().
- */
- typedef FT_Error
- (*FT_SFNT_TableInfoFunc)( FT_Face face,
- FT_UInt idx,
- FT_ULong *tag,
- FT_ULong *offset,
- FT_ULong *length );
-
-
- FT_DEFINE_SERVICE( SFNT_Table )
- {
- FT_SFNT_TableLoadFunc load_table;
- FT_SFNT_TableGetFunc get_table;
- FT_SFNT_TableInfoFunc table_info;
- };
-
-
-#define FT_DEFINE_SERVICE_SFNT_TABLEREC( class_, load_, get_, info_ ) \
- static const FT_Service_SFNT_TableRec class_ = \
- { \
- load_, get_, info_ \
- };
-
- /* */
-
-
-FT_END_HEADER
-
-
-#endif /* SVSFNT_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/services/svttcmap.h b/contrib/libs/freetype/include/freetype/internal/services/svttcmap.h
deleted file mode 100644
index 250886bcc5..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/services/svttcmap.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/****************************************************************************
- *
- * svttcmap.h
- *
- * The FreeType TrueType/sfnt cmap extra information service.
- *
- * Copyright (C) 2003-2024 by
- * Masatake YAMATO, Redhat K.K.,
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-/* Development of this service is support of
- Information-technology Promotion Agency, Japan. */
-
-#ifndef SVTTCMAP_H_
-#define SVTTCMAP_H_
-
-#include <freetype/internal/ftserv.h>
-#include <freetype/tttables.h>
-
-
-FT_BEGIN_HEADER
-
-
-#define FT_SERVICE_ID_TT_CMAP "tt-cmaps"
-
-
- /**************************************************************************
- *
- * @struct:
- * TT_CMapInfo
- *
- * @description:
- * A structure used to store TrueType/sfnt specific cmap information
- * which is not covered by the generic @FT_CharMap structure. This
- * structure can be accessed with the @FT_Get_TT_CMap_Info function.
- *
- * @fields:
- * language ::
- * The language ID used in Mac fonts. Definitions of values are in
- * `ttnameid.h`.
- *
- * format ::
- * The cmap format. OpenType 1.6 defines the formats 0 (byte encoding
- * table), 2~(high-byte mapping through table), 4~(segment mapping to
- * delta values), 6~(trimmed table mapping), 8~(mixed 16-bit and 32-bit
- * coverage), 10~(trimmed array), 12~(segmented coverage), 13~(last
- * resort font), and 14 (Unicode Variation Sequences).
- */
- typedef struct TT_CMapInfo_
- {
- FT_ULong language;
- FT_Long format;
-
- } TT_CMapInfo;
-
-
- typedef FT_Error
- (*TT_CMap_Info_GetFunc)( FT_CharMap charmap,
- TT_CMapInfo *cmap_info );
-
-
- FT_DEFINE_SERVICE( TTCMaps )
- {
- TT_CMap_Info_GetFunc get_cmap_info;
- };
-
-
-#define FT_DEFINE_SERVICE_TTCMAPSREC( class_, get_cmap_info_ ) \
- static const FT_Service_TTCMapsRec class_ = \
- { \
- get_cmap_info_ \
- };
-
- /* */
-
-
-FT_END_HEADER
-
-#endif /* SVTTCMAP_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/services/svtteng.h b/contrib/libs/freetype/include/freetype/internal/services/svtteng.h
deleted file mode 100644
index 14967529a9..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/services/svtteng.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/****************************************************************************
- *
- * svtteng.h
- *
- * The FreeType TrueType engine query service (specification).
- *
- * Copyright (C) 2006-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef SVTTENG_H_
-#define SVTTENG_H_
-
-#include <freetype/internal/ftserv.h>
-#include <freetype/ftmodapi.h>
-
-
-FT_BEGIN_HEADER
-
-
- /*
- * SFNT table loading service.
- */
-
-#define FT_SERVICE_ID_TRUETYPE_ENGINE "truetype-engine"
-
- /*
- * Used to implement FT_Get_TrueType_Engine_Type
- */
-
- FT_DEFINE_SERVICE( TrueTypeEngine )
- {
- FT_TrueTypeEngineType engine_type;
- };
-
- /* */
-
-
-FT_END_HEADER
-
-
-#endif /* SVTTENG_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/services/svttglyf.h b/contrib/libs/freetype/include/freetype/internal/services/svttglyf.h
deleted file mode 100644
index f190b3985d..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/services/svttglyf.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/****************************************************************************
- *
- * svttglyf.h
- *
- * The FreeType TrueType glyph service.
- *
- * Copyright (C) 2007-2024 by
- * David Turner.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-#ifndef SVTTGLYF_H_
-#define SVTTGLYF_H_
-
-#include <freetype/internal/ftserv.h>
-#include <freetype/tttables.h>
-
-
-FT_BEGIN_HEADER
-
-
-#define FT_SERVICE_ID_TT_GLYF "tt-glyf"
-
-
- typedef FT_ULong
- (*TT_Glyf_GetLocationFunc)( FT_Face face,
- FT_UInt gindex,
- FT_ULong *psize );
-
- FT_DEFINE_SERVICE( TTGlyf )
- {
- TT_Glyf_GetLocationFunc get_location;
- };
-
-
-#define FT_DEFINE_SERVICE_TTGLYFREC( class_, get_location_ ) \
- static const FT_Service_TTGlyfRec class_ = \
- { \
- get_location_ \
- };
-
- /* */
-
-
-FT_END_HEADER
-
-#endif /* SVTTGLYF_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/services/svwinfnt.h b/contrib/libs/freetype/include/freetype/internal/services/svwinfnt.h
deleted file mode 100644
index 49f3fb7f77..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/services/svwinfnt.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/****************************************************************************
- *
- * svwinfnt.h
- *
- * The FreeType Windows FNT/FONT service (specification).
- *
- * Copyright (C) 2003-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef SVWINFNT_H_
-#define SVWINFNT_H_
-
-#include <freetype/internal/ftserv.h>
-#include <freetype/ftwinfnt.h>
-
-
-FT_BEGIN_HEADER
-
-
-#define FT_SERVICE_ID_WINFNT "winfonts"
-
- typedef FT_Error
- (*FT_WinFnt_GetHeaderFunc)( FT_Face face,
- FT_WinFNT_HeaderRec *aheader );
-
-
- FT_DEFINE_SERVICE( WinFnt )
- {
- FT_WinFnt_GetHeaderFunc get_header;
- };
-
- /* */
-
-
-FT_END_HEADER
-
-
-#endif /* SVWINFNT_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/sfnt.h b/contrib/libs/freetype/include/freetype/internal/sfnt.h
deleted file mode 100644
index 35e4e73af0..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/sfnt.h
+++ /dev/null
@@ -1,1099 +0,0 @@
-/****************************************************************************
- *
- * sfnt.h
- *
- * High-level 'sfnt' driver interface (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef SFNT_H_
-#define SFNT_H_
-
-
-#include <freetype/internal/ftdrv.h>
-#include <freetype/internal/tttypes.h>
-#include <freetype/internal/wofftypes.h>
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @functype:
- * TT_Init_Face_Func
- *
- * @description:
- * First part of the SFNT face object initialization. This finds the
- * face in a SFNT file or collection, and load its format tag in
- * face->format_tag.
- *
- * @input:
- * stream ::
- * The input stream.
- *
- * face ::
- * A handle to the target face object.
- *
- * face_index ::
- * The index of the TrueType font, if we are opening a collection, in
- * bits 0-15. The numbered instance index~+~1 of a GX (sub)font, if
- * applicable, in bits 16-30.
- *
- * num_params ::
- * The number of additional parameters.
- *
- * params ::
- * Optional additional parameters.
- *
- * @return:
- * FreeType error code. 0 means success.
- *
- * @note:
- * The stream cursor must be at the font file's origin.
- *
- * This function recognizes fonts embedded in a 'TrueType collection'.
- *
- * Once the format tag has been validated by the font driver, it should
- * then call the TT_Load_Face_Func() callback to read the rest of the
- * SFNT tables in the object.
- */
- typedef FT_Error
- (*TT_Init_Face_Func)( FT_Stream stream,
- TT_Face face,
- FT_Int face_index,
- FT_Int num_params,
- FT_Parameter* params );
-
-
- /**************************************************************************
- *
- * @functype:
- * TT_Load_Face_Func
- *
- * @description:
- * Second part of the SFNT face object initialization. This loads the
- * common SFNT tables (head, OS/2, maxp, metrics, etc.) in the face
- * object.
- *
- * @input:
- * stream ::
- * The input stream.
- *
- * face ::
- * A handle to the target face object.
- *
- * face_index ::
- * The index of the TrueType font, if we are opening a collection, in
- * bits 0-15. The numbered instance index~+~1 of a GX (sub)font, if
- * applicable, in bits 16-30.
- *
- * num_params ::
- * The number of additional parameters.
- *
- * params ::
- * Optional additional parameters.
- *
- * @return:
- * FreeType error code. 0 means success.
- *
- * @note:
- * This function must be called after TT_Init_Face_Func().
- */
- typedef FT_Error
- (*TT_Load_Face_Func)( FT_Stream stream,
- TT_Face face,
- FT_Int face_index,
- FT_Int num_params,
- FT_Parameter* params );
-
-
- /**************************************************************************
- *
- * @functype:
- * TT_Done_Face_Func
- *
- * @description:
- * A callback used to delete the common SFNT data from a face.
- *
- * @input:
- * face ::
- * A handle to the target face object.
- *
- * @note:
- * This function does NOT destroy the face object.
- */
- typedef void
- (*TT_Done_Face_Func)( TT_Face face );
-
-
- /**************************************************************************
- *
- * @functype:
- * TT_Load_Any_Func
- *
- * @description:
- * Load any font table into client memory.
- *
- * @input:
- * face ::
- * The face object to look for.
- *
- * tag ::
- * The tag of table to load. Use the value 0 if you want to access the
- * whole font file, else set this parameter to a valid TrueType table
- * tag that you can forge with the MAKE_TT_TAG macro.
- *
- * offset ::
- * The starting offset in the table (or the file if tag == 0).
- *
- * length ::
- * The address of the decision variable:
- *
- * If `length == NULL`: Loads the whole table. Returns an error if
- * 'offset' == 0!
- *
- * If `*length == 0`: Exits immediately; returning the length of the
- * given table or of the font file, depending on the value of 'tag'.
- *
- * If `*length != 0`: Loads the next 'length' bytes of table or font,
- * starting at offset 'offset' (in table or font too).
- *
- * @output:
- * buffer ::
- * The address of target buffer.
- *
- * @return:
- * TrueType error code. 0 means success.
- */
- typedef FT_Error
- (*TT_Load_Any_Func)( TT_Face face,
- FT_ULong tag,
- FT_Long offset,
- FT_Byte *buffer,
- FT_ULong* length );
-
-
- /**************************************************************************
- *
- * @functype:
- * TT_Find_SBit_Image_Func
- *
- * @description:
- * Check whether an embedded bitmap (an 'sbit') exists for a given glyph,
- * at a given strike.
- *
- * @input:
- * face ::
- * The target face object.
- *
- * glyph_index ::
- * The glyph index.
- *
- * strike_index ::
- * The current strike index.
- *
- * @output:
- * arange ::
- * The SBit range containing the glyph index.
- *
- * astrike ::
- * The SBit strike containing the glyph index.
- *
- * aglyph_offset ::
- * The offset of the glyph data in 'EBDT' table.
- *
- * @return:
- * FreeType error code. 0 means success. Returns
- * SFNT_Err_Invalid_Argument if no sbit exists for the requested glyph.
- */
- typedef FT_Error
- (*TT_Find_SBit_Image_Func)( TT_Face face,
- FT_UInt glyph_index,
- FT_ULong strike_index,
- TT_SBit_Range *arange,
- TT_SBit_Strike *astrike,
- FT_ULong *aglyph_offset );
-
-
- /**************************************************************************
- *
- * @functype:
- * TT_Load_SBit_Metrics_Func
- *
- * @description:
- * Get the big metrics for a given embedded bitmap.
- *
- * @input:
- * stream ::
- * The input stream.
- *
- * range ::
- * The SBit range containing the glyph.
- *
- * @output:
- * big_metrics ::
- * A big SBit metrics structure for the glyph.
- *
- * @return:
- * FreeType error code. 0 means success.
- *
- * @note:
- * The stream cursor must be positioned at the glyph's offset within the
- * 'EBDT' table before the call.
- *
- * If the image format uses variable metrics, the stream cursor is
- * positioned just after the metrics header in the 'EBDT' table on
- * function exit.
- */
- typedef FT_Error
- (*TT_Load_SBit_Metrics_Func)( FT_Stream stream,
- TT_SBit_Range range,
- TT_SBit_Metrics metrics );
-
-
- /**************************************************************************
- *
- * @functype:
- * TT_Load_SBit_Image_Func
- *
- * @description:
- * Load a given glyph sbit image from the font resource. This also
- * returns its metrics.
- *
- * @input:
- * face ::
- * The target face object.
- *
- * strike_index ::
- * The strike index.
- *
- * glyph_index ::
- * The current glyph index.
- *
- * load_flags ::
- * The current load flags.
- *
- * stream ::
- * The input stream.
- *
- * @output:
- * amap ::
- * The target pixmap.
- *
- * ametrics ::
- * A big sbit metrics structure for the glyph image.
- *
- * @return:
- * FreeType error code. 0 means success. Returns an error if no glyph
- * sbit exists for the index.
- *
- * @note:
- * The `map.buffer` field is always freed before the glyph is loaded.
- */
- typedef FT_Error
- (*TT_Load_SBit_Image_Func)( TT_Face face,
- FT_ULong strike_index,
- FT_UInt glyph_index,
- FT_UInt load_flags,
- FT_Stream stream,
- FT_Bitmap *amap,
- TT_SBit_MetricsRec *ametrics );
-
-
- /**************************************************************************
- *
- * @functype:
- * TT_Load_Svg_Doc_Func
- *
- * @description:
- * Scan the SVG document list to find the document containing the glyph
- * that has the ID 'glyph*XXX*', where *XXX* is the value of
- * `glyph_index` as a decimal integer.
- *
- * @inout:
- * glyph ::
- * The glyph slot from which pointers to the SVG document list is to be
- * grabbed. The results are stored back in the slot.
- *
- * @input:
- * glyph_index ::
- * The index of the glyph that is to be looked up.
- *
- * @return:
- * FreeType error code. 0 means success.
- */
- typedef FT_Error
- (*TT_Load_Svg_Doc_Func)( FT_GlyphSlot glyph,
- FT_UInt glyph_index );
-
-
- /**************************************************************************
- *
- * @functype:
- * TT_Set_SBit_Strike_Func
- *
- * @description:
- * Select an sbit strike for a given size request.
- *
- * @input:
- * face ::
- * The target face object.
- *
- * req ::
- * The size request.
- *
- * @output:
- * astrike_index ::
- * The index of the sbit strike.
- *
- * @return:
- * FreeType error code. 0 means success. Returns an error if no sbit
- * strike exists for the selected ppem values.
- */
- typedef FT_Error
- (*TT_Set_SBit_Strike_Func)( TT_Face face,
- FT_Size_Request req,
- FT_ULong* astrike_index );
-
-
- /**************************************************************************
- *
- * @functype:
- * TT_Load_Strike_Metrics_Func
- *
- * @description:
- * Load the metrics of a given strike.
- *
- * @input:
- * face ::
- * The target face object.
- *
- * strike_index ::
- * The strike index.
- *
- * @output:
- * metrics ::
- * the metrics of the strike.
- *
- * @return:
- * FreeType error code. 0 means success. Returns an error if no such
- * sbit strike exists.
- */
- typedef FT_Error
- (*TT_Load_Strike_Metrics_Func)( TT_Face face,
- FT_ULong strike_index,
- FT_Size_Metrics* metrics );
-
-
- /**************************************************************************
- *
- * @functype:
- * TT_Get_PS_Name_Func
- *
- * @description:
- * Get the PostScript glyph name of a glyph.
- *
- * @input:
- * idx ::
- * The glyph index.
- *
- * PSname ::
- * The address of a string pointer. Will be `NULL` in case of error,
- * otherwise it is a pointer to the glyph name.
- *
- * You must not modify the returned string!
- *
- * @output:
- * FreeType error code. 0 means success.
- */
- typedef FT_Error
- (*TT_Get_PS_Name_Func)( TT_Face face,
- FT_UInt idx,
- FT_String** PSname );
-
-
- /**************************************************************************
- *
- * @functype:
- * TT_Load_Metrics_Func
- *
- * @description:
- * Load a metrics table, which is a table with a horizontal and a
- * vertical version.
- *
- * @input:
- * face ::
- * A handle to the target face object.
- *
- * stream ::
- * The input stream.
- *
- * vertical ::
- * A boolean flag. If set, load the vertical one.
- *
- * @return:
- * FreeType error code. 0 means success.
- */
- typedef FT_Error
- (*TT_Load_Metrics_Func)( TT_Face face,
- FT_Stream stream,
- FT_Bool vertical );
-
-
- /**************************************************************************
- *
- * @functype:
- * TT_Get_Metrics_Func
- *
- * @description:
- * Load the horizontal or vertical header in a face object.
- *
- * @input:
- * face ::
- * A handle to the target face object.
- *
- * vertical ::
- * A boolean flag. If set, load vertical metrics.
- *
- * gindex ::
- * The glyph index.
- *
- * @output:
- * abearing ::
- * The horizontal (or vertical) bearing. Set to zero in case of error.
- *
- * aadvance ::
- * The horizontal (or vertical) advance. Set to zero in case of error.
- */
- typedef void
- (*TT_Get_Metrics_Func)( TT_Face face,
- FT_Bool vertical,
- FT_UInt gindex,
- FT_Short* abearing,
- FT_UShort* aadvance );
-
-
- /**************************************************************************
- *
- * @functype:
- * TT_Set_Palette_Func
- *
- * @description:
- * Load the colors into `face->palette` for a given palette index.
- *
- * @input:
- * face ::
- * The target face object.
- *
- * idx ::
- * The palette index.
- *
- * @return:
- * FreeType error code. 0 means success.
- */
- typedef FT_Error
- (*TT_Set_Palette_Func)( TT_Face face,
- FT_UInt idx );
-
-
- /**************************************************************************
- *
- * @functype:
- * TT_Get_Colr_Layer_Func
- *
- * @description:
- * Iteratively get the color layer data of a given glyph index.
- *
- * @input:
- * face ::
- * The target face object.
- *
- * base_glyph ::
- * The glyph index the colored glyph layers are associated with.
- *
- * @inout:
- * iterator ::
- * An @FT_LayerIterator object. For the first call you should set
- * `iterator->p` to `NULL`. For all following calls, simply use the
- * same object again.
- *
- * @output:
- * aglyph_index ::
- * The glyph index of the current layer.
- *
- * acolor_index ::
- * The color index into the font face's color palette of the current
- * layer. The value 0xFFFF is special; it doesn't reference a palette
- * entry but indicates that the text foreground color should be used
- * instead (to be set up by the application outside of FreeType).
- *
- * @return:
- * Value~1 if everything is OK. If there are no more layers (or if there
- * are no layers at all), value~0 gets returned. In case of an error,
- * value~0 is returned also.
- */
- typedef FT_Bool
- (*TT_Get_Colr_Layer_Func)( TT_Face face,
- FT_UInt base_glyph,
- FT_UInt *aglyph_index,
- FT_UInt *acolor_index,
- FT_LayerIterator* iterator );
-
-
- /**************************************************************************
- *
- * @functype:
- * TT_Get_Color_Glyph_Paint_Func
- *
- * @description:
- * Find the root @FT_OpaquePaint object for a given glyph ID.
- *
- * @input:
- * face ::
- * The target face object.
- *
- * base_glyph ::
- * The glyph index the colored glyph layers are associated with.
- *
- * @output:
- * paint ::
- * The root @FT_OpaquePaint object.
- *
- * @return:
- * Value~1 if everything is OK. If no color glyph is found, or the root
- * paint could not be retrieved, value~0 gets returned. In case of an
- * error, value~0 is returned also.
- */
- typedef FT_Bool
- ( *TT_Get_Color_Glyph_Paint_Func )( TT_Face face,
- FT_UInt base_glyph,
- FT_Color_Root_Transform root_transform,
- FT_OpaquePaint *paint );
-
-
- /**************************************************************************
- *
- * @functype:
- * TT_Get_Color_Glyph_ClipBox_Func
- *
- * @description:
- * Search for a 'COLR' v1 clip box for the specified `base_glyph` and
- * fill the `clip_box` parameter with the 'COLR' v1 'ClipBox' information
- * if one is found.
- *
- * @input:
- * face ::
- * A handle to the parent face object.
- *
- * base_glyph ::
- * The glyph index for which to retrieve the clip box.
- *
- * @output:
- * clip_box ::
- * The clip box for the requested `base_glyph` if one is found. The
- * clip box is computed taking scale and transformations configured on
- * the @FT_Face into account. @FT_ClipBox contains @FT_Vector values
- * in 26.6 format.
- *
- * @note:
- * To retrieve the clip box in font units, reset scale to units-per-em
- * and remove transforms configured using @FT_Set_Transform.
- *
- * @return:
- * Value~1 if a ClipBox is found. If no clip box is found or an
- * error occured, value~0 is returned.
- */
- typedef FT_Bool
- ( *TT_Get_Color_Glyph_ClipBox_Func )( TT_Face face,
- FT_UInt base_glyph,
- FT_ClipBox* clip_box );
-
-
- /**************************************************************************
- *
- * @functype:
- * TT_Get_Paint_Layers_Func
- *
- * @description:
- * Access the layers of a `PaintColrLayers` table.
- *
- * @input:
- * face ::
- * The target face object.
- *
- * @inout:
- * iterator ::
- * The @FT_LayerIterator from an @FT_PaintColrLayers object, for which
- * the layers are to be retrieved. The internal state of the iterator
- * is incremented after one call to this function for retrieving one
- * layer.
- *
- * @output:
- * paint ::
- * The root @FT_OpaquePaint object referencing the actual paint table.
- *
- * @return:
- * Value~1 if everything is OK. Value~0 gets returned when the paint
- * object can not be retrieved or any other error occurs.
- */
- typedef FT_Bool
- ( *TT_Get_Paint_Layers_Func )( TT_Face face,
- FT_LayerIterator* iterator,
- FT_OpaquePaint *paint );
-
-
- /**************************************************************************
- *
- * @functype:
- * TT_Get_Colorline_Stops_Func
- *
- * @description:
- * Get the gradient and solid fill information for a given glyph.
- *
- * @input:
- * face ::
- * The target face object.
- *
- * @inout:
- * iterator ::
- * An @FT_ColorStopIterator object. For the first call you should set
- * `iterator->p` to `NULL`. For all following calls, simply use the
- * same object again.
- *
- * @output:
- * color_stop ::
- * Color index and alpha value for the retrieved color stop.
- *
- * @return:
- * Value~1 if everything is OK. If there are no more color stops,
- * value~0 gets returned. In case of an error, value~0 is returned
- * also.
- */
- typedef FT_Bool
- ( *TT_Get_Colorline_Stops_Func )( TT_Face face,
- FT_ColorStop *color_stop,
- FT_ColorStopIterator* iterator );
-
-
- /**************************************************************************
- *
- * @functype:
- * TT_Get_Paint_Func
- *
- * @description:
- * Get the paint details for a given @FT_OpaquePaint object.
- *
- * @input:
- * face ::
- * The target face object.
- *
- * opaque_paint ::
- * The @FT_OpaquePaint object.
- *
- * @output:
- * paint ::
- * An @FT_COLR_Paint object holding the details on `opaque_paint`.
- *
- * @return:
- * Value~1 if everything is OK. Value~0 if no details can be found for
- * this paint or any other error occured.
- */
- typedef FT_Bool
- ( *TT_Get_Paint_Func )( TT_Face face,
- FT_OpaquePaint opaque_paint,
- FT_COLR_Paint *paint );
-
-
- /**************************************************************************
- *
- * @functype:
- * TT_Blend_Colr_Func
- *
- * @description:
- * Blend the bitmap in `new_glyph` into `base_glyph` using the color
- * specified by `color_index`. If `color_index` is 0xFFFF, use
- * `face->foreground_color` if `face->have_foreground_color` is set.
- * Otherwise check `face->palette_data.palette_flags`: If present and
- * @FT_PALETTE_FOR_DARK_BACKGROUND is set, use BGRA value 0xFFFFFFFF
- * (white opaque). Otherwise use BGRA value 0x000000FF (black opaque).
- *
- * @input:
- * face ::
- * The target face object.
- *
- * color_index ::
- * Color index from the COLR table.
- *
- * base_glyph ::
- * Slot for bitmap to be merged into. The underlying bitmap may get
- * reallocated.
- *
- * new_glyph ::
- * Slot to be incooperated into `base_glyph`.
- *
- * @return:
- * FreeType error code. 0 means success. Returns an error if
- * color_index is invalid or reallocation fails.
- */
- typedef FT_Error
- (*TT_Blend_Colr_Func)( TT_Face face,
- FT_UInt color_index,
- FT_GlyphSlot base_glyph,
- FT_GlyphSlot new_glyph );
-
-
- /**************************************************************************
- *
- * @functype:
- * TT_Get_Name_Func
- *
- * @description:
- * From the 'name' table, return a given ENGLISH name record in ASCII.
- *
- * @input:
- * face ::
- * A handle to the source face object.
- *
- * nameid ::
- * The name id of the name record to return.
- *
- * @inout:
- * name ::
- * The address of an allocated string pointer. `NULL` if no name is
- * present.
- *
- * @return:
- * FreeType error code. 0 means success.
- */
- typedef FT_Error
- (*TT_Get_Name_Func)( TT_Face face,
- FT_UShort nameid,
- FT_String** name );
-
-
- /**************************************************************************
- *
- * @functype:
- * TT_Get_Name_ID_Func
- *
- * @description:
- * Search whether an ENGLISH version for a given name ID is in the 'name'
- * table.
- *
- * @input:
- * face ::
- * A handle to the source face object.
- *
- * nameid ::
- * The name id of the name record to return.
- *
- * @output:
- * win ::
- * If non-negative, an index into the 'name' table with the
- * corresponding (3,1) or (3,0) Windows entry.
- *
- * apple ::
- * If non-negative, an index into the 'name' table with the
- * corresponding (1,0) Apple entry.
- *
- * @return:
- * 1 if there is either a win or apple entry (or both), 0 otheriwse.
- */
- typedef FT_Bool
- (*TT_Get_Name_ID_Func)( TT_Face face,
- FT_UShort nameid,
- FT_Int *win,
- FT_Int *apple );
-
-
- /**************************************************************************
- *
- * @functype:
- * TT_Load_Table_Func
- *
- * @description:
- * Load a given TrueType table.
- *
- * @input:
- * face ::
- * A handle to the target face object.
- *
- * stream ::
- * The input stream.
- *
- * @return:
- * FreeType error code. 0 means success.
- *
- * @note:
- * The function uses `face->goto_table` to seek the stream to the start
- * of the table, except while loading the font directory.
- */
- typedef FT_Error
- (*TT_Load_Table_Func)( TT_Face face,
- FT_Stream stream );
-
-
- /**************************************************************************
- *
- * @functype:
- * TT_Free_Table_Func
- *
- * @description:
- * Free a given TrueType table.
- *
- * @input:
- * face ::
- * A handle to the target face object.
- */
- typedef void
- (*TT_Free_Table_Func)( TT_Face face );
-
-
- /*
- * @functype:
- * TT_Face_GetKerningFunc
- *
- * @description:
- * Return the horizontal kerning value between two glyphs.
- *
- * @input:
- * face ::
- * A handle to the source face object.
- *
- * left_glyph ::
- * The left glyph index.
- *
- * right_glyph ::
- * The right glyph index.
- *
- * @return:
- * The kerning value in font units.
- */
- typedef FT_Int
- (*TT_Face_GetKerningFunc)( TT_Face face,
- FT_UInt left_glyph,
- FT_UInt right_glyph );
-
-
- /**************************************************************************
- *
- * @struct:
- * SFNT_Interface
- *
- * @description:
- * This structure holds pointers to the functions used to load and free
- * the basic tables that are required in a 'sfnt' font file.
- *
- * @fields:
- * Check the various xxx_Func() descriptions for details.
- */
- typedef struct SFNT_Interface_
- {
- TT_Loader_GotoTableFunc goto_table;
-
- TT_Init_Face_Func init_face;
- TT_Load_Face_Func load_face;
- TT_Done_Face_Func done_face;
- FT_Module_Requester get_interface;
-
- TT_Load_Any_Func load_any;
-
- /* these functions are called by `load_face' but they can also */
- /* be called from external modules, if there is a need to do so */
- TT_Load_Table_Func load_head;
- TT_Load_Metrics_Func load_hhea;
- TT_Load_Table_Func load_cmap;
- TT_Load_Table_Func load_maxp;
- TT_Load_Table_Func load_os2;
- TT_Load_Table_Func load_post;
-
- TT_Load_Table_Func load_name;
- TT_Free_Table_Func free_name;
-
- /* this field was called `load_kerning' up to version 2.1.10 */
- TT_Load_Table_Func load_kern;
-
- TT_Load_Table_Func load_gpos;
- TT_Load_Table_Func load_gasp;
- TT_Load_Table_Func load_pclt;
-
- /* see `ttload.h'; this field was called `load_bitmap_header' up to */
- /* version 2.1.10 */
- TT_Load_Table_Func load_bhed;
-
- TT_Load_SBit_Image_Func load_sbit_image;
-
- /* see `ttpost.h' */
- TT_Get_PS_Name_Func get_psname;
- TT_Free_Table_Func free_psnames;
-
- /* starting here, the structure differs from version 2.1.7 */
-
- /* this field was introduced in version 2.1.8, named `get_psname' */
- TT_Face_GetKerningFunc get_kerning;
-
- /* new elements introduced after version 2.1.10 */
-
- TT_Face_GetKerningFunc get_gpos_kerning;
-
- /* load the font directory, i.e., the offset table and */
- /* the table directory */
- TT_Load_Table_Func load_font_dir;
- TT_Load_Metrics_Func load_hmtx;
-
- TT_Load_Table_Func load_eblc;
- TT_Free_Table_Func free_eblc;
-
- TT_Set_SBit_Strike_Func set_sbit_strike;
- TT_Load_Strike_Metrics_Func load_strike_metrics;
-
- TT_Load_Table_Func load_cpal;
- TT_Load_Table_Func load_colr;
- TT_Free_Table_Func free_cpal;
- TT_Free_Table_Func free_colr;
- TT_Set_Palette_Func set_palette;
- TT_Get_Colr_Layer_Func get_colr_layer;
- TT_Get_Color_Glyph_Paint_Func get_colr_glyph_paint;
- TT_Get_Color_Glyph_ClipBox_Func get_color_glyph_clipbox;
- TT_Get_Paint_Layers_Func get_paint_layers;
- TT_Get_Colorline_Stops_Func get_colorline_stops;
- TT_Get_Paint_Func get_paint;
- TT_Blend_Colr_Func colr_blend;
-
- TT_Get_Metrics_Func get_metrics;
-
- TT_Get_Name_Func get_name;
- TT_Get_Name_ID_Func get_name_id;
-
- /* OpenType SVG Support */
- TT_Load_Table_Func load_svg;
- TT_Free_Table_Func free_svg;
- TT_Load_Svg_Doc_Func load_svg_doc;
-
- } SFNT_Interface;
-
-
- /* transitional */
- typedef SFNT_Interface* SFNT_Service;
-
-
-#define FT_DEFINE_SFNT_INTERFACE( \
- class_, \
- goto_table_, \
- init_face_, \
- load_face_, \
- done_face_, \
- get_interface_, \
- load_any_, \
- load_head_, \
- load_hhea_, \
- load_cmap_, \
- load_maxp_, \
- load_os2_, \
- load_post_, \
- load_name_, \
- free_name_, \
- load_kern_, \
- load_gpos_, \
- load_gasp_, \
- load_pclt_, \
- load_bhed_, \
- load_sbit_image_, \
- get_psname_, \
- free_psnames_, \
- get_kerning_, \
- get_gpos_kerning_, \
- load_font_dir_, \
- load_hmtx_, \
- load_eblc_, \
- free_eblc_, \
- set_sbit_strike_, \
- load_strike_metrics_, \
- load_cpal_, \
- load_colr_, \
- free_cpal_, \
- free_colr_, \
- set_palette_, \
- get_colr_layer_, \
- get_colr_glyph_paint_, \
- get_color_glyph_clipbox, \
- get_paint_layers_, \
- get_colorline_stops_, \
- get_paint_, \
- colr_blend_, \
- get_metrics_, \
- get_name_, \
- get_name_id_, \
- load_svg_, \
- free_svg_, \
- load_svg_doc_ ) \
- static const SFNT_Interface class_ = \
- { \
- goto_table_, \
- init_face_, \
- load_face_, \
- done_face_, \
- get_interface_, \
- load_any_, \
- load_head_, \
- load_hhea_, \
- load_cmap_, \
- load_maxp_, \
- load_os2_, \
- load_post_, \
- load_name_, \
- free_name_, \
- load_kern_, \
- load_gpos_, \
- load_gasp_, \
- load_pclt_, \
- load_bhed_, \
- load_sbit_image_, \
- get_psname_, \
- free_psnames_, \
- get_kerning_, \
- get_gpos_kerning_, \
- load_font_dir_, \
- load_hmtx_, \
- load_eblc_, \
- free_eblc_, \
- set_sbit_strike_, \
- load_strike_metrics_, \
- load_cpal_, \
- load_colr_, \
- free_cpal_, \
- free_colr_, \
- set_palette_, \
- get_colr_layer_, \
- get_colr_glyph_paint_, \
- get_color_glyph_clipbox, \
- get_paint_layers_, \
- get_colorline_stops_, \
- get_paint_, \
- colr_blend_, \
- get_metrics_, \
- get_name_, \
- get_name_id_, \
- load_svg_, \
- free_svg_, \
- load_svg_doc_ \
- };
-
-
-FT_END_HEADER
-
-#endif /* SFNT_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/svginterface.h b/contrib/libs/freetype/include/freetype/internal/svginterface.h
deleted file mode 100644
index 68c99efb10..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/svginterface.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/****************************************************************************
- *
- * svginterface.h
- *
- * Interface of ot-svg module (specification only).
- *
- * Copyright (C) 2022-2024 by
- * David Turner, Robert Wilhelm, Werner Lemberg, and Moazin Khatti.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef SVGINTERFACE_H_
-#define SVGINTERFACE_H_
-
-#include <ft2build.h>
-#include <freetype/otsvg.h>
-
-
-FT_BEGIN_HEADER
-
- typedef FT_Error
- (*Preset_Bitmap_Func)( FT_Module module,
- FT_GlyphSlot slot,
- FT_Bool cache );
-
- typedef struct SVG_Interface_
- {
- Preset_Bitmap_Func preset_slot;
-
- } SVG_Interface;
-
- typedef SVG_Interface* SVG_Service;
-
-FT_END_HEADER
-
-#endif /* SVGINTERFACE_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/t1types.h b/contrib/libs/freetype/include/freetype/internal/t1types.h
deleted file mode 100644
index 1821ae5cc8..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/t1types.h
+++ /dev/null
@@ -1,307 +0,0 @@
-/****************************************************************************
- *
- * t1types.h
- *
- * Basic Type1/Type2 type definitions and interface (specification
- * only).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef T1TYPES_H_
-#define T1TYPES_H_
-
-
-#include <freetype/ftmm.h>
-#include <freetype/internal/pshints.h>
-#include <freetype/internal/ftserv.h>
-#include <freetype/internal/fthash.h>
-#include <freetype/internal/services/svpscmap.h>
-
-
-FT_BEGIN_HEADER
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /*** ***/
- /*** ***/
- /*** REQUIRED TYPE1/TYPE2 TABLES DEFINITIONS ***/
- /*** ***/
- /*** ***/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /**************************************************************************
- *
- * @struct:
- * T1_EncodingRec
- *
- * @description:
- * A structure modeling a custom encoding.
- *
- * @fields:
- * num_chars ::
- * The number of character codes in the encoding. Usually 256.
- *
- * code_first ::
- * The lowest valid character code in the encoding.
- *
- * code_last ::
- * The highest valid character code in the encoding + 1. When equal to
- * code_first there are no valid character codes.
- *
- * char_index ::
- * An array of corresponding glyph indices.
- *
- * char_name ::
- * An array of corresponding glyph names.
- */
- typedef struct T1_EncodingRecRec_
- {
- FT_Int num_chars;
- FT_Int code_first;
- FT_Int code_last;
-
- FT_UShort* char_index;
- const FT_String** char_name;
-
- } T1_EncodingRec, *T1_Encoding;
-
-
- /* used to hold extra data of PS_FontInfoRec that
- * cannot be stored in the publicly defined structure.
- *
- * Note these can't be blended with multiple-masters.
- */
- typedef struct PS_FontExtraRec_
- {
- FT_UShort fs_type;
-
- } PS_FontExtraRec;
-
-
- typedef struct T1_FontRec_
- {
- PS_FontInfoRec font_info; /* font info dictionary */
- PS_FontExtraRec font_extra; /* font info extra fields */
- PS_PrivateRec private_dict; /* private dictionary */
- FT_String* font_name; /* top-level dictionary */
-
- T1_EncodingType encoding_type;
- T1_EncodingRec encoding;
-
- FT_Byte* subrs_block;
- FT_Byte* charstrings_block;
- FT_Byte* glyph_names_block;
-
- FT_Int num_subrs;
- FT_Byte** subrs;
- FT_UInt* subrs_len;
- FT_Hash subrs_hash;
-
- FT_Int num_glyphs;
- FT_String** glyph_names; /* array of glyph names */
- FT_Byte** charstrings; /* array of glyph charstrings */
- FT_UInt* charstrings_len;
-
- FT_Byte paint_type;
- FT_Byte font_type;
- FT_Matrix font_matrix;
- FT_Vector font_offset;
- FT_BBox font_bbox;
- FT_Long font_id;
-
- FT_Fixed stroke_width;
-
- } T1_FontRec, *T1_Font;
-
-
- typedef struct CID_SubrsRec_
- {
- FT_Int num_subrs;
- FT_Byte** code;
-
- } CID_SubrsRec, *CID_Subrs;
-
-
- /* this structure is used to store the BlendDesignMap entry for an axis */
- typedef struct PS_DesignMap_
- {
- FT_Byte num_points;
- FT_Long* design_points;
- FT_Fixed* blend_points;
-
- } PS_DesignMapRec, *PS_DesignMap;
-
- /* backward compatible definition */
- typedef PS_DesignMapRec T1_DesignMap;
-
-
- typedef struct PS_BlendRec_
- {
- FT_UInt num_designs;
- FT_UInt num_axis;
-
- FT_String* axis_names[T1_MAX_MM_AXIS];
- FT_Fixed* design_pos[T1_MAX_MM_DESIGNS];
- PS_DesignMapRec design_map[T1_MAX_MM_AXIS];
-
- FT_Fixed* weight_vector;
- FT_Fixed* default_weight_vector;
-
- PS_FontInfo font_infos[T1_MAX_MM_DESIGNS + 1];
- PS_Private privates [T1_MAX_MM_DESIGNS + 1];
-
- FT_ULong blend_bitflags;
-
- FT_BBox* bboxes [T1_MAX_MM_DESIGNS + 1];
-
- /* since 2.3.0 */
-
- /* undocumented, optional: the default design instance; */
- /* corresponds to default_weight_vector -- */
- /* num_default_design_vector == 0 means it is not present */
- /* in the font and associated metrics files */
- FT_UInt default_design_vector[T1_MAX_MM_DESIGNS];
- FT_UInt num_default_design_vector;
-
- } PS_BlendRec, *PS_Blend;
-
-
- /* backward compatible definition */
- typedef PS_BlendRec T1_Blend;
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /*** ***/
- /*** ***/
- /*** AFM FONT INFORMATION STRUCTURES ***/
- /*** ***/
- /*** ***/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
- typedef struct AFM_TrackKernRec_
- {
- FT_Int degree;
- FT_Fixed min_ptsize;
- FT_Fixed min_kern;
- FT_Fixed max_ptsize;
- FT_Fixed max_kern;
-
- } AFM_TrackKernRec, *AFM_TrackKern;
-
- typedef struct AFM_KernPairRec_
- {
- FT_UInt index1;
- FT_UInt index2;
- FT_Int x;
- FT_Int y;
-
- } AFM_KernPairRec, *AFM_KernPair;
-
- typedef struct AFM_FontInfoRec_
- {
- FT_Bool IsCIDFont;
- FT_BBox FontBBox;
- FT_Fixed Ascender; /* optional, mind the zero */
- FT_Fixed Descender; /* optional, mind the zero */
- AFM_TrackKern TrackKerns; /* free if non-NULL */
- FT_UInt NumTrackKern;
- AFM_KernPair KernPairs; /* free if non-NULL */
- FT_UInt NumKernPair;
-
- } AFM_FontInfoRec, *AFM_FontInfo;
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /*** ***/
- /*** ***/
- /*** ORIGINAL T1_FACE CLASS DEFINITION ***/
- /*** ***/
- /*** ***/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
- typedef struct T1_FaceRec_* T1_Face;
- typedef struct CID_FaceRec_* CID_Face;
-
-
- typedef struct T1_FaceRec_
- {
- FT_FaceRec root;
- T1_FontRec type1;
- const void* psnames;
- const void* psaux;
- const void* afm_data;
- FT_CharMapRec charmaprecs[2];
- FT_CharMap charmaps[2];
-
- /* support for Multiple Masters fonts */
- PS_Blend blend;
-
- /* undocumented, optional: indices of subroutines that express */
- /* the NormalizeDesignVector and the ConvertDesignVector procedure, */
- /* respectively, as Type 2 charstrings; -1 if keywords not present */
- FT_Int ndv_idx;
- FT_Int cdv_idx;
-
- /* undocumented, optional: has the same meaning as len_buildchar */
- /* for Type 2 fonts; manipulated by othersubrs 19, 24, and 25 */
- FT_UInt len_buildchar;
- FT_Long* buildchar;
-
- /* since version 2.1 - interface to PostScript hinter */
- const void* pshinter;
-
- } T1_FaceRec;
-
-
- typedef struct CID_FaceRec_
- {
- FT_FaceRec root;
- void* psnames;
- void* psaux;
- CID_FaceInfoRec cid;
- PS_FontExtraRec font_extra;
-#if 0
- void* afm_data;
-#endif
- CID_Subrs subrs;
-
- /* since version 2.1 - interface to PostScript hinter */
- void* pshinter;
-
- /* since version 2.1.8, but was originally positioned after `afm_data' */
- FT_Byte* binary_data; /* used if hex data has been converted */
- FT_Stream cid_stream;
-
- } CID_FaceRec;
-
-
-FT_END_HEADER
-
-#endif /* T1TYPES_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/tttypes.h b/contrib/libs/freetype/include/freetype/internal/tttypes.h
deleted file mode 100644
index 7053e656a7..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/tttypes.h
+++ /dev/null
@@ -1,1747 +0,0 @@
-/****************************************************************************
- *
- * tttypes.h
- *
- * Basic SFNT/TrueType type definitions and interface (specification
- * only).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef TTTYPES_H_
-#define TTTYPES_H_
-
-
-#include <freetype/tttables.h>
-#include <freetype/internal/ftobjs.h>
-#include <freetype/ftcolor.h>
-#include "freetype/fttypes.h"
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
-#include <freetype/ftmm.h>
-#endif
-
-
-FT_BEGIN_HEADER
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /*** ***/
- /*** ***/
- /*** REQUIRED TRUETYPE/OPENTYPE TABLES DEFINITIONS ***/
- /*** ***/
- /*** ***/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /**************************************************************************
- *
- * @struct:
- * TTC_HeaderRec
- *
- * @description:
- * TrueType collection header. This table contains the offsets of the
- * font headers of each distinct TrueType face in the file.
- *
- * @fields:
- * tag ::
- * Must be 'ttc~' to indicate a TrueType collection.
- *
- * version ::
- * The version number.
- *
- * count ::
- * The number of faces in the collection. The specification says this
- * should be an unsigned long, but we use a signed long since we need
- * the value -1 for specific purposes.
- *
- * offsets ::
- * The offsets of the font headers, one per face.
- */
- typedef struct TTC_HeaderRec_
- {
- FT_ULong tag;
- FT_Fixed version;
- FT_Long count;
- FT_ULong* offsets;
-
- } TTC_HeaderRec;
-
-
- /**************************************************************************
- *
- * @struct:
- * SFNT_HeaderRec
- *
- * @description:
- * SFNT file format header.
- *
- * @fields:
- * format_tag ::
- * The font format tag.
- *
- * num_tables ::
- * The number of tables in file.
- *
- * search_range ::
- * Must be '16 * (max power of 2 <= num_tables)'.
- *
- * entry_selector ::
- * Must be log2 of 'search_range / 16'.
- *
- * range_shift ::
- * Must be 'num_tables * 16 - search_range'.
- */
- typedef struct SFNT_HeaderRec_
- {
- FT_ULong format_tag;
- FT_UShort num_tables;
- FT_UShort search_range;
- FT_UShort entry_selector;
- FT_UShort range_shift;
-
- FT_ULong offset; /* not in file */
-
- } SFNT_HeaderRec, *SFNT_Header;
-
-
- /**************************************************************************
- *
- * @struct:
- * TT_TableRec
- *
- * @description:
- * This structure describes a given table of a TrueType font.
- *
- * @fields:
- * Tag ::
- * A four-bytes tag describing the table.
- *
- * CheckSum ::
- * The table checksum. This value can be ignored.
- *
- * Offset ::
- * The offset of the table from the start of the TrueType font in its
- * resource.
- *
- * Length ::
- * The table length (in bytes).
- */
- typedef struct TT_TableRec_
- {
- FT_ULong Tag; /* table type */
- FT_ULong CheckSum; /* table checksum */
- FT_ULong Offset; /* table file offset */
- FT_ULong Length; /* table length */
-
- } TT_TableRec, *TT_Table;
-
-
- /**************************************************************************
- *
- * @struct:
- * TT_LongMetricsRec
- *
- * @description:
- * A structure modeling the long metrics of the 'hmtx' and 'vmtx'
- * TrueType tables. The values are expressed in font units.
- *
- * @fields:
- * advance ::
- * The advance width or height for the glyph.
- *
- * bearing ::
- * The left-side or top-side bearing for the glyph.
- */
- typedef struct TT_LongMetricsRec_
- {
- FT_UShort advance;
- FT_Short bearing;
-
- } TT_LongMetricsRec, *TT_LongMetrics;
-
-
- /**************************************************************************
- *
- * @type:
- * TT_ShortMetrics
- *
- * @description:
- * A simple type to model the short metrics of the 'hmtx' and 'vmtx'
- * tables.
- */
- typedef FT_Short TT_ShortMetrics;
-
-
- /**************************************************************************
- *
- * @struct:
- * TT_NameRec
- *
- * @description:
- * A structure modeling TrueType name records. Name records are used to
- * store important strings like family name, style name, copyright,
- * etc. in _localized_ versions (i.e., language, encoding, etc).
- *
- * @fields:
- * platformID ::
- * The ID of the name's encoding platform.
- *
- * encodingID ::
- * The platform-specific ID for the name's encoding.
- *
- * languageID ::
- * The platform-specific ID for the name's language.
- *
- * nameID ::
- * The ID specifying what kind of name this is.
- *
- * stringLength ::
- * The length of the string in bytes.
- *
- * stringOffset ::
- * The offset to the string in the 'name' table.
- *
- * string ::
- * A pointer to the string's bytes. Note that these are usually UTF-16
- * encoded characters.
- */
- typedef struct TT_NameRec_
- {
- FT_UShort platformID;
- FT_UShort encodingID;
- FT_UShort languageID;
- FT_UShort nameID;
- FT_UShort stringLength;
- FT_ULong stringOffset;
-
- /* this last field is not defined in the spec */
- /* but used by the FreeType engine */
-
- FT_Byte* string;
-
- } TT_NameRec, *TT_Name;
-
-
- /**************************************************************************
- *
- * @struct:
- * TT_LangTagRec
- *
- * @description:
- * A structure modeling language tag records in SFNT 'name' tables,
- * introduced in OpenType version 1.6.
- *
- * @fields:
- * stringLength ::
- * The length of the string in bytes.
- *
- * stringOffset ::
- * The offset to the string in the 'name' table.
- *
- * string ::
- * A pointer to the string's bytes. Note that these are UTF-16BE
- * encoded characters.
- */
- typedef struct TT_LangTagRec_
- {
- FT_UShort stringLength;
- FT_ULong stringOffset;
-
- /* this last field is not defined in the spec */
- /* but used by the FreeType engine */
-
- FT_Byte* string;
-
- } TT_LangTagRec, *TT_LangTag;
-
-
- /**************************************************************************
- *
- * @struct:
- * TT_NameTableRec
- *
- * @description:
- * A structure modeling the TrueType name table.
- *
- * @fields:
- * format ::
- * The format of the name table.
- *
- * numNameRecords ::
- * The number of names in table.
- *
- * storageOffset ::
- * The offset of the name table in the 'name' TrueType table.
- *
- * names ::
- * An array of name records.
- *
- * numLangTagRecords ::
- * The number of language tags in table.
- *
- * langTags ::
- * An array of language tag records.
- *
- * stream ::
- * The file's input stream.
- */
- typedef struct TT_NameTableRec_
- {
- FT_UShort format;
- FT_UInt numNameRecords;
- FT_UInt storageOffset;
- TT_NameRec* names;
- FT_UInt numLangTagRecords;
- TT_LangTagRec* langTags;
- FT_Stream stream;
-
- } TT_NameTableRec, *TT_NameTable;
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /*** ***/
- /*** ***/
- /*** OPTIONAL TRUETYPE/OPENTYPE TABLES DEFINITIONS ***/
- /*** ***/
- /*** ***/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /**************************************************************************
- *
- * @struct:
- * TT_GaspRangeRec
- *
- * @description:
- * A tiny structure used to model a gasp range according to the TrueType
- * specification.
- *
- * @fields:
- * maxPPEM ::
- * The maximum ppem value to which `gaspFlag` applies.
- *
- * gaspFlag ::
- * A flag describing the grid-fitting and anti-aliasing modes to be
- * used.
- */
- typedef struct TT_GaspRangeRec_
- {
- FT_UShort maxPPEM;
- FT_UShort gaspFlag;
-
- } TT_GaspRangeRec, *TT_GaspRange;
-
-
-#define TT_GASP_GRIDFIT 0x01
-#define TT_GASP_DOGRAY 0x02
-
-
- /**************************************************************************
- *
- * @struct:
- * TT_GaspRec
- *
- * @description:
- * A structure modeling the TrueType 'gasp' table used to specify
- * grid-fitting and anti-aliasing behaviour.
- *
- * @fields:
- * version ::
- * The version number.
- *
- * numRanges ::
- * The number of gasp ranges in table.
- *
- * gaspRanges ::
- * An array of gasp ranges.
- */
- typedef struct TT_Gasp_
- {
- FT_UShort version;
- FT_UShort numRanges;
- TT_GaspRange gaspRanges;
-
- } TT_GaspRec;
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /*** ***/
- /*** ***/
- /*** EMBEDDED BITMAPS SUPPORT ***/
- /*** ***/
- /*** ***/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /**************************************************************************
- *
- * @struct:
- * TT_SBit_MetricsRec
- *
- * @description:
- * A structure used to hold the big metrics of a given glyph bitmap in a
- * TrueType or OpenType font. These are usually found in the 'EBDT'
- * (Microsoft) or 'bloc' (Apple) table.
- *
- * @fields:
- * height ::
- * The glyph height in pixels.
- *
- * width ::
- * The glyph width in pixels.
- *
- * horiBearingX ::
- * The horizontal left bearing.
- *
- * horiBearingY ::
- * The horizontal top bearing.
- *
- * horiAdvance ::
- * The horizontal advance.
- *
- * vertBearingX ::
- * The vertical left bearing.
- *
- * vertBearingY ::
- * The vertical top bearing.
- *
- * vertAdvance ::
- * The vertical advance.
- */
- typedef struct TT_SBit_MetricsRec_
- {
- FT_UShort height;
- FT_UShort width;
-
- FT_Short horiBearingX;
- FT_Short horiBearingY;
- FT_UShort horiAdvance;
-
- FT_Short vertBearingX;
- FT_Short vertBearingY;
- FT_UShort vertAdvance;
-
- } TT_SBit_MetricsRec, *TT_SBit_Metrics;
-
-
- /**************************************************************************
- *
- * @struct:
- * TT_SBit_SmallMetricsRec
- *
- * @description:
- * A structure used to hold the small metrics of a given glyph bitmap in
- * a TrueType or OpenType font. These are usually found in the 'EBDT'
- * (Microsoft) or the 'bdat' (Apple) table.
- *
- * @fields:
- * height ::
- * The glyph height in pixels.
- *
- * width ::
- * The glyph width in pixels.
- *
- * bearingX ::
- * The left-side bearing.
- *
- * bearingY ::
- * The top-side bearing.
- *
- * advance ::
- * The advance width or height.
- */
- typedef struct TT_SBit_Small_Metrics_
- {
- FT_Byte height;
- FT_Byte width;
-
- FT_Char bearingX;
- FT_Char bearingY;
- FT_Byte advance;
-
- } TT_SBit_SmallMetricsRec, *TT_SBit_SmallMetrics;
-
-
- /**************************************************************************
- *
- * @struct:
- * TT_SBit_LineMetricsRec
- *
- * @description:
- * A structure used to describe the text line metrics of a given bitmap
- * strike, for either a horizontal or vertical layout.
- *
- * @fields:
- * ascender ::
- * The ascender in pixels.
- *
- * descender ::
- * The descender in pixels.
- *
- * max_width ::
- * The maximum glyph width in pixels.
- *
- * caret_slope_enumerator ::
- * Rise of the caret slope, typically set to 1 for non-italic fonts.
- *
- * caret_slope_denominator ::
- * Rise of the caret slope, typically set to 0 for non-italic fonts.
- *
- * caret_offset ::
- * Offset in pixels to move the caret for proper positioning.
- *
- * min_origin_SB ::
- * Minimum of horiBearingX (resp. vertBearingY).
- * min_advance_SB ::
- * Minimum of
- *
- * horizontal advance - ( horiBearingX + width )
- *
- * resp.
- *
- * vertical advance - ( vertBearingY + height )
- *
- * max_before_BL ::
- * Maximum of horiBearingY (resp. vertBearingY).
- *
- * min_after_BL ::
- * Minimum of
- *
- * horiBearingY - height
- *
- * resp.
- *
- * vertBearingX - width
- *
- * pads ::
- * Unused (to make the size of the record a multiple of 32 bits.
- */
- typedef struct TT_SBit_LineMetricsRec_
- {
- FT_Char ascender;
- FT_Char descender;
- FT_Byte max_width;
- FT_Char caret_slope_numerator;
- FT_Char caret_slope_denominator;
- FT_Char caret_offset;
- FT_Char min_origin_SB;
- FT_Char min_advance_SB;
- FT_Char max_before_BL;
- FT_Char min_after_BL;
- FT_Char pads[2];
-
- } TT_SBit_LineMetricsRec, *TT_SBit_LineMetrics;
-
-
- /**************************************************************************
- *
- * @struct:
- * TT_SBit_RangeRec
- *
- * @description:
- * A TrueType/OpenType subIndexTable as defined in the 'EBLC' (Microsoft)
- * or 'bloc' (Apple) tables.
- *
- * @fields:
- * first_glyph ::
- * The first glyph index in the range.
- *
- * last_glyph ::
- * The last glyph index in the range.
- *
- * index_format ::
- * The format of index table. Valid values are 1 to 5.
- *
- * image_format ::
- * The format of 'EBDT' image data.
- *
- * image_offset ::
- * The offset to image data in 'EBDT'.
- *
- * image_size ::
- * For index formats 2 and 5. This is the size in bytes of each glyph
- * bitmap.
- *
- * big_metrics ::
- * For index formats 2 and 5. This is the big metrics for each glyph
- * bitmap.
- *
- * num_glyphs ::
- * For index formats 4 and 5. This is the number of glyphs in the code
- * array.
- *
- * glyph_offsets ::
- * For index formats 1 and 3.
- *
- * glyph_codes ::
- * For index formats 4 and 5.
- *
- * table_offset ::
- * The offset of the index table in the 'EBLC' table. Only used during
- * strike loading.
- */
- typedef struct TT_SBit_RangeRec_
- {
- FT_UShort first_glyph;
- FT_UShort last_glyph;
-
- FT_UShort index_format;
- FT_UShort image_format;
- FT_ULong image_offset;
-
- FT_ULong image_size;
- TT_SBit_MetricsRec metrics;
- FT_ULong num_glyphs;
-
- FT_ULong* glyph_offsets;
- FT_UShort* glyph_codes;
-
- FT_ULong table_offset;
-
- } TT_SBit_RangeRec, *TT_SBit_Range;
-
-
- /**************************************************************************
- *
- * @struct:
- * TT_SBit_StrikeRec
- *
- * @description:
- * A structure used describe a given bitmap strike in the 'EBLC'
- * (Microsoft) or 'bloc' (Apple) tables.
- *
- * @fields:
- * num_index_ranges ::
- * The number of index ranges.
- *
- * index_ranges ::
- * An array of glyph index ranges.
- *
- * color_ref ::
- * Unused. `color_ref` is put in for future enhancements, but these
- * fields are already in use by other platforms (e.g. Newton). For
- * details, please see
- *
- * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6bloc.html
- *
- * hori ::
- * The line metrics for horizontal layouts.
- *
- * vert ::
- * The line metrics for vertical layouts.
- *
- * start_glyph ::
- * The lowest glyph index for this strike.
- *
- * end_glyph ::
- * The highest glyph index for this strike.
- *
- * x_ppem ::
- * The number of horizontal pixels per EM.
- *
- * y_ppem ::
- * The number of vertical pixels per EM.
- *
- * bit_depth ::
- * The bit depth. Valid values are 1, 2, 4, and 8.
- *
- * flags ::
- * Is this a vertical or horizontal strike? For details, please see
- *
- * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6bloc.html
- */
- typedef struct TT_SBit_StrikeRec_
- {
- FT_Int num_ranges;
- TT_SBit_Range sbit_ranges;
- FT_ULong ranges_offset;
-
- FT_ULong color_ref;
-
- TT_SBit_LineMetricsRec hori;
- TT_SBit_LineMetricsRec vert;
-
- FT_UShort start_glyph;
- FT_UShort end_glyph;
-
- FT_Byte x_ppem;
- FT_Byte y_ppem;
-
- FT_Byte bit_depth;
- FT_Char flags;
-
- } TT_SBit_StrikeRec, *TT_SBit_Strike;
-
-
- /**************************************************************************
- *
- * @struct:
- * TT_SBit_ComponentRec
- *
- * @description:
- * A simple structure to describe a compound sbit element.
- *
- * @fields:
- * glyph_code ::
- * The element's glyph index.
- *
- * x_offset ::
- * The element's left bearing.
- *
- * y_offset ::
- * The element's top bearing.
- */
- typedef struct TT_SBit_ComponentRec_
- {
- FT_UShort glyph_code;
- FT_Char x_offset;
- FT_Char y_offset;
-
- } TT_SBit_ComponentRec, *TT_SBit_Component;
-
-
- /**************************************************************************
- *
- * @struct:
- * TT_SBit_ScaleRec
- *
- * @description:
- * A structure used describe a given bitmap scaling table, as defined in
- * the 'EBSC' table.
- *
- * @fields:
- * hori ::
- * The horizontal line metrics.
- *
- * vert ::
- * The vertical line metrics.
- *
- * x_ppem ::
- * The number of horizontal pixels per EM.
- *
- * y_ppem ::
- * The number of vertical pixels per EM.
- *
- * x_ppem_substitute ::
- * Substitution x_ppem value.
- *
- * y_ppem_substitute ::
- * Substitution y_ppem value.
- */
- typedef struct TT_SBit_ScaleRec_
- {
- TT_SBit_LineMetricsRec hori;
- TT_SBit_LineMetricsRec vert;
-
- FT_Byte x_ppem;
- FT_Byte y_ppem;
-
- FT_Byte x_ppem_substitute;
- FT_Byte y_ppem_substitute;
-
- } TT_SBit_ScaleRec, *TT_SBit_Scale;
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /*** ***/
- /*** ***/
- /*** POSTSCRIPT GLYPH NAMES SUPPORT ***/
- /*** ***/
- /*** ***/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /**************************************************************************
- *
- * @struct:
- * TT_Post_NamesRec
- *
- * @description:
- * Postscript names table, either format 2.0 or 2.5.
- *
- * @fields:
- * loaded ::
- * A flag to indicate whether the PS names are loaded.
- *
- * num_glyphs ::
- * The number of named glyphs in the table.
- *
- * num_names ::
- * The number of PS names stored in the table.
- *
- * glyph_indices ::
- * The indices of the glyphs in the names arrays.
- *
- * glyph_names ::
- * The PS names not in Mac Encoding.
- */
- typedef struct TT_Post_NamesRec_
- {
- FT_Bool loaded;
- FT_UShort num_glyphs;
- FT_UShort num_names;
- FT_UShort* glyph_indices;
- FT_Byte** glyph_names;
-
- } TT_Post_NamesRec, *TT_Post_Names;
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /*** ***/
- /*** ***/
- /*** GX VARIATION TABLE SUPPORT ***/
- /*** ***/
- /*** ***/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- typedef struct GX_BlendRec_ *GX_Blend;
-#endif
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /*** ***/
- /*** ***/
- /*** EMBEDDED BDF PROPERTIES TABLE SUPPORT ***/
- /*** ***/
- /*** ***/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
- /*
- * These types are used to support a `BDF ' table that isn't part of the
- * official TrueType specification. It is mainly used in SFNT-based bitmap
- * fonts that were generated from a set of BDF fonts.
- *
- * The format of the table is as follows.
- *
- * USHORT version `BDF ' table version number, should be 0x0001. USHORT
- * strikeCount Number of strikes (bitmap sizes) in this table. ULONG
- * stringTable Offset (from start of BDF table) to string
- * table.
- *
- * This is followed by an array of `strikeCount' descriptors, having the
- * following format.
- *
- * USHORT ppem Vertical pixels per EM for this strike. USHORT numItems
- * Number of items for this strike (properties and
- * atoms). Maximum is 255.
- *
- * This array in turn is followed by `strikeCount' value sets. Each `value
- * set' is an array of `numItems' items with the following format.
- *
- * ULONG item_name Offset in string table to item name.
- * USHORT item_type The item type. Possible values are
- * 0 => string (e.g., COMMENT)
- * 1 => atom (e.g., FONT or even SIZE)
- * 2 => int32
- * 3 => uint32
- * 0x10 => A flag to indicate a properties. This
- * is ORed with the above values.
- * ULONG item_value For strings => Offset into string table without
- * the corresponding double quotes.
- * For atoms => Offset into string table.
- * For integers => Direct value.
- *
- * All strings in the string table consist of bytes and are
- * zero-terminated.
- *
- */
-
-#ifdef TT_CONFIG_OPTION_BDF
-
- typedef struct TT_BDFRec_
- {
- FT_Byte* table;
- FT_Byte* table_end;
- FT_Byte* strings;
- FT_ULong strings_size;
- FT_UInt num_strikes;
- FT_Bool loaded;
-
- } TT_BDFRec, *TT_BDF;
-
-#endif /* TT_CONFIG_OPTION_BDF */
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /*** ***/
- /*** ***/
- /*** ORIGINAL TT_FACE CLASS DEFINITION ***/
- /*** ***/
- /*** ***/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /**************************************************************************
- *
- * This structure/class is defined here because it is common to the
- * following formats: TTF, OpenType-TT, and OpenType-CFF.
- *
- * Note, however, that the classes TT_Size and TT_GlyphSlot are not shared
- * between font drivers, and are thus defined in `ttobjs.h`.
- *
- */
-
-
- /**************************************************************************
- *
- * @type:
- * TT_Face
- *
- * @description:
- * A handle to a TrueType face/font object. A TT_Face encapsulates the
- * resolution and scaling independent parts of a TrueType font resource.
- *
- * @note:
- * The TT_Face structure is also used as a 'parent class' for the
- * OpenType-CFF class (T2_Face).
- */
- typedef struct TT_FaceRec_* TT_Face;
-
-
- /* a function type used for the truetype bytecode interpreter hooks */
- typedef FT_Error
- (*TT_Interpreter)( void* exec_context );
-
- /* forward declaration */
- typedef struct TT_LoaderRec_* TT_Loader;
-
-
- /**************************************************************************
- *
- * @functype:
- * TT_Loader_GotoTableFunc
- *
- * @description:
- * Seeks a stream to the start of a given TrueType table.
- *
- * @input:
- * face ::
- * A handle to the target face object.
- *
- * tag ::
- * A 4-byte tag used to name the table.
- *
- * stream ::
- * The input stream.
- *
- * @output:
- * length ::
- * The length of the table in bytes. Set to 0 if not needed.
- *
- * @return:
- * FreeType error code. 0 means success.
- *
- * @note:
- * The stream cursor must be at the font file's origin.
- */
- typedef FT_Error
- (*TT_Loader_GotoTableFunc)( TT_Face face,
- FT_ULong tag,
- FT_Stream stream,
- FT_ULong* length );
-
-
- /**************************************************************************
- *
- * @functype:
- * TT_Loader_StartGlyphFunc
- *
- * @description:
- * Seeks a stream to the start of a given glyph element, and opens a
- * frame for it.
- *
- * @input:
- * loader ::
- * The current TrueType glyph loader object.
- *
- * glyph index :: The index of the glyph to access.
- *
- * offset ::
- * The offset of the glyph according to the 'locations' table.
- *
- * byte_count ::
- * The size of the frame in bytes.
- *
- * @return:
- * FreeType error code. 0 means success.
- *
- * @note:
- * This function is normally equivalent to FT_STREAM_SEEK(offset)
- * followed by FT_FRAME_ENTER(byte_count) with the loader's stream, but
- * alternative formats (e.g. compressed ones) might use something
- * different.
- */
- typedef FT_Error
- (*TT_Loader_StartGlyphFunc)( TT_Loader loader,
- FT_UInt glyph_index,
- FT_ULong offset,
- FT_UInt byte_count );
-
-
- /**************************************************************************
- *
- * @functype:
- * TT_Loader_ReadGlyphFunc
- *
- * @description:
- * Reads one glyph element (its header, a simple glyph, or a composite)
- * from the loader's current stream frame.
- *
- * @input:
- * loader ::
- * The current TrueType glyph loader object.
- *
- * @return:
- * FreeType error code. 0 means success.
- */
- typedef FT_Error
- (*TT_Loader_ReadGlyphFunc)( TT_Loader loader );
-
-
- /**************************************************************************
- *
- * @functype:
- * TT_Loader_EndGlyphFunc
- *
- * @description:
- * Closes the current loader stream frame for the glyph.
- *
- * @input:
- * loader ::
- * The current TrueType glyph loader object.
- */
- typedef void
- (*TT_Loader_EndGlyphFunc)( TT_Loader loader );
-
-
- typedef enum TT_SbitTableType_
- {
- TT_SBIT_TABLE_TYPE_NONE = 0,
- TT_SBIT_TABLE_TYPE_EBLC, /* `EBLC' (Microsoft), */
- /* `bloc' (Apple) */
- TT_SBIT_TABLE_TYPE_CBLC, /* `CBLC' (Google) */
- TT_SBIT_TABLE_TYPE_SBIX, /* `sbix' (Apple) */
-
- /* do not remove */
- TT_SBIT_TABLE_TYPE_MAX
-
- } TT_SbitTableType;
-
-
- /* OpenType 1.8 brings new tables for variation font support; */
- /* to make the old MM and GX fonts still work we need to check */
- /* the presence (and validity) of the functionality provided */
- /* by those tables. The following flag macros are for the */
- /* field `variation_support'. */
- /* */
- /* Note that `fvar' gets checked immediately at font loading, */
- /* while the other features are only loaded if MM support is */
- /* actually requested. */
-
- /* FVAR */
-#define TT_FACE_FLAG_VAR_FVAR ( 1 << 0 )
-
- /* HVAR */
-#define TT_FACE_FLAG_VAR_HADVANCE ( 1 << 1 )
-#define TT_FACE_FLAG_VAR_LSB ( 1 << 2 )
-#define TT_FACE_FLAG_VAR_RSB ( 1 << 3 )
-
- /* VVAR */
-#define TT_FACE_FLAG_VAR_VADVANCE ( 1 << 4 )
-#define TT_FACE_FLAG_VAR_TSB ( 1 << 5 )
-#define TT_FACE_FLAG_VAR_BSB ( 1 << 6 )
-#define TT_FACE_FLAG_VAR_VORG ( 1 << 7 )
-
- /* MVAR */
-#define TT_FACE_FLAG_VAR_MVAR ( 1 << 8 )
-
-
- /**************************************************************************
- *
- * TrueType Face Type
- *
- * @struct:
- * TT_Face
- *
- * @description:
- * The TrueType face class. These objects model the resolution and
- * point-size independent data found in a TrueType font file.
- *
- * @fields:
- * root ::
- * The base FT_Face structure, managed by the base layer.
- *
- * ttc_header ::
- * The TrueType collection header, used when the file is a 'ttc' rather
- * than a 'ttf'. For ordinary font files, the field `ttc_header.count`
- * is set to 0.
- *
- * format_tag ::
- * The font format tag.
- *
- * num_tables ::
- * The number of TrueType tables in this font file.
- *
- * dir_tables ::
- * The directory of TrueType tables for this font file.
- *
- * header ::
- * The font's font header ('head' table). Read on font opening.
- *
- * horizontal ::
- * The font's horizontal header ('hhea' table). This field also
- * contains the associated horizontal metrics table ('hmtx').
- *
- * max_profile ::
- * The font's maximum profile table. Read on font opening. Note that
- * some maximum values cannot be taken directly from this table. We
- * thus define additional fields below to hold the computed maxima.
- *
- * vertical_info ::
- * A boolean which is set when the font file contains vertical metrics.
- * If not, the value of the 'vertical' field is undefined.
- *
- * vertical ::
- * The font's vertical header ('vhea' table). This field also contains
- * the associated vertical metrics table ('vmtx'), if found.
- * IMPORTANT: The contents of this field is undefined if the
- * `vertical_info` field is unset.
- *
- * num_names ::
- * The number of name records within this TrueType font.
- *
- * name_table ::
- * The table of name records ('name').
- *
- * os2 ::
- * The font's OS/2 table ('OS/2').
- *
- * postscript ::
- * The font's PostScript table ('post' table). The PostScript glyph
- * names are not loaded by the driver on face opening. See the
- * 'ttpost' module for more details.
- *
- * cmap_table ::
- * Address of the face's 'cmap' SFNT table in memory (it's an extracted
- * frame).
- *
- * cmap_size ::
- * The size in bytes of the `cmap_table` described above.
- *
- * goto_table ::
- * A function called by each TrueType table loader to position a
- * stream's cursor to the start of a given table according to its tag.
- * It defaults to TT_Goto_Face but can be different for strange formats
- * (e.g. Type 42).
- *
- * access_glyph_frame ::
- * A function used to access the frame of a given glyph within the
- * face's font file.
- *
- * forget_glyph_frame ::
- * A function used to forget the frame of a given glyph when all data
- * has been loaded.
- *
- * read_glyph_header ::
- * A function used to read a glyph header. It must be called between
- * an 'access' and 'forget'.
- *
- * read_simple_glyph ::
- * A function used to read a simple glyph. It must be called after the
- * header was read, and before the 'forget'.
- *
- * read_composite_glyph ::
- * A function used to read a composite glyph. It must be called after
- * the header was read, and before the 'forget'.
- *
- * sfnt ::
- * A pointer to the SFNT service.
- *
- * psnames ::
- * A pointer to the PostScript names service.
- *
- * mm ::
- * A pointer to the Multiple Masters service.
- *
- * tt_var ::
- * A pointer to the Metrics Variations service for the "truetype"
- * driver.
- *
- * face_var ::
- * A pointer to the Metrics Variations service for this `TT_Face`'s
- * driver.
- *
- * psaux ::
- * A pointer to the PostScript Auxiliary service.
- *
- * gasp ::
- * The grid-fitting and scaling properties table ('gasp'). This table
- * is optional in TrueType/OpenType fonts.
- *
- * pclt ::
- * The 'pclt' SFNT table.
- *
- * num_sbit_scales ::
- * The number of sbit scales for this font.
- *
- * sbit_scales ::
- * Array of sbit scales embedded in this font. This table is optional
- * in a TrueType/OpenType font.
- *
- * postscript_names ::
- * A table used to store the Postscript names of the glyphs for this
- * font. See the file `ttconfig.h` for comments on the
- * TT_CONFIG_OPTION_POSTSCRIPT_NAMES option.
- *
- * palette_data ::
- * Some fields from the 'CPAL' table that are directly indexed.
- *
- * palette_index ::
- * The current palette index, as set by @FT_Palette_Select.
- *
- * palette ::
- * An array containing the current palette's colors.
- *
- * have_foreground_color ::
- * There was a call to @FT_Palette_Set_Foreground_Color.
- *
- * foreground_color ::
- * The current foreground color corresponding to 'CPAL' color index
- * 0xFFFF. Only valid if `have_foreground_color` is set.
- *
- * font_program_size ::
- * Size in bytecodes of the face's font program. 0 if none defined.
- * Ignored for Type 2 fonts.
- *
- * font_program ::
- * The face's font program (bytecode stream) executed at load time,
- * also used during glyph rendering. Comes from the 'fpgm' table.
- * Ignored for Type 2 font fonts.
- *
- * cvt_program_size ::
- * The size in bytecodes of the face's cvt program. Ignored for Type 2
- * fonts.
- *
- * cvt_program ::
- * The face's cvt program (bytecode stream) executed each time an
- * instance/size is changed/reset. Comes from the 'prep' table.
- * Ignored for Type 2 fonts.
- *
- * cvt_size ::
- * Size of the control value table (in entries). Ignored for Type 2
- * fonts.
- *
- * cvt ::
- * The face's original control value table. Coordinates are expressed
- * in unscaled font units (in 26.6 format). Comes from the 'cvt~'
- * table. Ignored for Type 2 fonts.
- *
- * If varied by the `CVAR' table, non-integer values are possible.
- *
- * interpreter ::
- * A pointer to the TrueType bytecode interpreters field is also used
- * to hook the debugger in 'ttdebug'.
- *
- * extra ::
- * Reserved for third-party font drivers.
- *
- * postscript_name ::
- * The PS name of the font. Used by the postscript name service.
- *
- * glyf_len ::
- * The length of the 'glyf' table. Needed for malformed 'loca' tables.
- *
- * glyf_offset ::
- * The file offset of the 'glyf' table.
- *
- * is_cff2 ::
- * Set if the font format is CFF2.
- *
- * doblend ::
- * A boolean which is set if the font should be blended (this is for GX
- * var).
- *
- * blend ::
- * Contains the data needed to control GX variation tables (rather like
- * Multiple Master data).
- *
- * variation_support ::
- * Flags that indicate which OpenType functionality related to font
- * variation support is present, valid, and usable. For example,
- * TT_FACE_FLAG_VAR_FVAR is only set if we have at least one design
- * axis.
- *
- * var_postscript_prefix ::
- * The PostScript name prefix needed for constructing a variation font
- * instance's PS name .
- *
- * var_postscript_prefix_len ::
- * The length of the `var_postscript_prefix` string.
- *
- * var_default_named_instance ::
- * The index of the default named instance.
- *
- * non_var_style_name ::
- * The non-variation style name, used as a backup.
- *
- * horz_metrics_size ::
- * The size of the 'hmtx' table.
- *
- * vert_metrics_size ::
- * The size of the 'vmtx' table.
- *
- * num_locations ::
- * The number of glyph locations in this TrueType file. This should be
- * one more than the number of glyphs. Ignored for Type 2 fonts.
- *
- * glyph_locations ::
- * An array of longs. These are offsets to glyph data within the
- * 'glyf' table. Ignored for Type 2 font faces.
- *
- * hdmx_table ::
- * A pointer to the 'hdmx' table.
- *
- * hdmx_table_size ::
- * The size of the 'hdmx' table.
- *
- * hdmx_record_count ::
- * The number of hdmx records.
- *
- * hdmx_record_size ::
- * The size of a single hdmx record.
- *
- * hdmx_records ::
- * A array of pointers to the 'hdmx' table records sorted by ppem.
- *
- * sbit_table ::
- * A pointer to the font's embedded bitmap location table.
- *
- * sbit_table_size ::
- * The size of `sbit_table`.
- *
- * sbit_table_type ::
- * The sbit table type (CBLC, sbix, etc.).
- *
- * sbit_num_strikes ::
- * The number of sbit strikes exposed by FreeType's API, omitting
- * invalid strikes.
- *
- * sbit_strike_map ::
- * A mapping between the strike indices exposed by the API and the
- * indices used in the font's sbit table.
- *
- * kern_table ::
- * A pointer to the 'kern' table.
- *
- * kern_table_size ::
- * The size of the 'kern' table.
- *
- * num_kern_tables ::
- * The number of supported kern subtables (up to 32; FreeType
- * recognizes only horizontal ones with format 0).
- *
- * kern_avail_bits ::
- * The availability status of kern subtables; if bit n is set, table n
- * is available.
- *
- * kern_order_bits ::
- * The sortedness status of kern subtables; if bit n is set, table n is
- * sorted.
- *
- * bdf ::
- * Data related to an SFNT font's 'bdf' table; see `tttypes.h`.
- *
- * horz_metrics_offset ::
- * The file offset of the 'hmtx' table.
- *
- * vert_metrics_offset ::
- * The file offset of the 'vmtx' table.
- *
- * ebdt_start ::
- * The file offset of the sbit data table (CBDT, bdat, etc.).
- *
- * ebdt_size ::
- * The size of the sbit data table.
- *
- * cpal ::
- * A pointer to data related to the 'CPAL' table. `NULL` if the table
- * is not available.
- *
- * colr ::
- * A pointer to data related to the 'COLR' table. `NULL` if the table
- * is not available.
- *
- * svg ::
- * A pointer to data related to the 'SVG' table. `NULL` if the table
- * is not available.
- */
- typedef struct TT_FaceRec_
- {
- FT_FaceRec root;
-
- TTC_HeaderRec ttc_header;
-
- FT_ULong format_tag;
- FT_UShort num_tables;
- TT_Table dir_tables;
-
- TT_Header header; /* TrueType header table */
- TT_HoriHeader horizontal; /* TrueType horizontal header */
-
- TT_MaxProfile max_profile;
-
- FT_Bool vertical_info;
- TT_VertHeader vertical; /* TT Vertical header, if present */
-
- FT_UShort num_names; /* number of name records */
- TT_NameTableRec name_table; /* name table */
-
- TT_OS2 os2; /* TrueType OS/2 table */
- TT_Postscript postscript; /* TrueType Postscript table */
-
- FT_Byte* cmap_table; /* extracted `cmap' table */
- FT_ULong cmap_size;
-
- TT_Loader_GotoTableFunc goto_table;
-
- TT_Loader_StartGlyphFunc access_glyph_frame;
- TT_Loader_EndGlyphFunc forget_glyph_frame;
- TT_Loader_ReadGlyphFunc read_glyph_header;
- TT_Loader_ReadGlyphFunc read_simple_glyph;
- TT_Loader_ReadGlyphFunc read_composite_glyph;
-
- /* a typeless pointer to the SFNT_Interface table used to load */
- /* the basic TrueType tables in the face object */
- void* sfnt;
-
- /* a typeless pointer to the FT_Service_PsCMapsRec table used to */
- /* handle glyph names <-> unicode & Mac values */
- void* psnames;
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- /* a typeless pointer to the FT_Service_MultiMasters table used to */
- /* handle variation fonts */
- void* mm;
-
- /* a typeless pointer to the FT_Service_MetricsVariationsRec table */
- /* used to handle the HVAR, VVAR, and MVAR OpenType tables by the */
- /* "truetype" driver */
- void* tt_var;
-
- /* a typeless pointer to the FT_Service_MetricsVariationsRec table */
- /* used to handle the HVAR, VVAR, and MVAR OpenType tables by this */
- /* TT_Face's driver */
- void* face_var; /* since 2.13.1 */
-#endif
-
- /* a typeless pointer to the PostScript Aux service */
- void* psaux;
-
-
- /************************************************************************
- *
- * Optional TrueType/OpenType tables
- *
- */
-
- /* grid-fitting and scaling table */
- TT_GaspRec gasp; /* the `gasp' table */
-
- /* PCL 5 table */
- TT_PCLT pclt;
-
- /* embedded bitmaps support */
- FT_ULong num_sbit_scales;
- TT_SBit_Scale sbit_scales;
-
- /* postscript names table */
- TT_Post_NamesRec postscript_names;
-
- /* glyph colors */
- FT_Palette_Data palette_data; /* since 2.10 */
- FT_UShort palette_index;
- FT_Color* palette;
- FT_Bool have_foreground_color;
- FT_Color foreground_color;
-
-
- /************************************************************************
- *
- * TrueType-specific fields (ignored by the CFF driver)
- *
- */
-
- /* the font program, if any */
- FT_ULong font_program_size;
- FT_Byte* font_program;
-
- /* the cvt program, if any */
- FT_ULong cvt_program_size;
- FT_Byte* cvt_program;
-
- /* the original, unscaled, control value table */
- FT_ULong cvt_size;
- FT_Int32* cvt;
-
- /* A pointer to the bytecode interpreter to use. This is also */
- /* used to hook the debugger for the `ttdebug' utility. */
- TT_Interpreter interpreter;
-
-
- /************************************************************************
- *
- * Other tables or fields. This is used by derivative formats like
- * OpenType.
- *
- */
-
- FT_Generic extra;
-
- const char* postscript_name;
-
- FT_ULong glyf_len;
- FT_ULong glyf_offset; /* since 2.7.1 */
-
- FT_Bool is_cff2; /* since 2.7.1 */
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- FT_Bool doblend;
- GX_Blend blend;
-
- FT_UInt32 variation_support; /* since 2.7.1 */
-
- const char* var_postscript_prefix; /* since 2.7.2 */
- FT_UInt var_postscript_prefix_len; /* since 2.7.2 */
-
- FT_UInt var_default_named_instance; /* since 2.13.1 */
-
- const char* non_var_style_name; /* since 2.13.1 */
-#endif
-
- /* since version 2.2 */
-
- FT_ULong horz_metrics_size;
- FT_ULong vert_metrics_size;
-
- FT_ULong num_locations; /* up to 0xFFFF + 1 */
- FT_Byte* glyph_locations;
-
- FT_Byte* hdmx_table;
- FT_ULong hdmx_table_size;
- FT_UInt hdmx_record_count;
- FT_ULong hdmx_record_size;
- FT_Byte** hdmx_records;
-
- FT_Byte* sbit_table;
- FT_ULong sbit_table_size;
- TT_SbitTableType sbit_table_type;
- FT_UInt sbit_num_strikes;
- FT_UInt* sbit_strike_map;
-
- FT_Byte* kern_table;
- FT_ULong kern_table_size;
- FT_UInt num_kern_tables;
- FT_UInt32 kern_avail_bits;
- FT_UInt32 kern_order_bits;
-
-#ifdef TT_CONFIG_OPTION_GPOS_KERNING
- FT_Byte* gpos_table;
- FT_Bool gpos_kerning_available;
-#endif
-
-#ifdef TT_CONFIG_OPTION_BDF
- TT_BDFRec bdf;
-#endif /* TT_CONFIG_OPTION_BDF */
-
- /* since 2.3.0 */
- FT_ULong horz_metrics_offset;
- FT_ULong vert_metrics_offset;
-
-#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
- /* since 2.7 */
- FT_ULong ebdt_start; /* either `CBDT', `EBDT', or `bdat' */
- FT_ULong ebdt_size;
-#endif
-
- /* since 2.10 */
- void* cpal;
- void* colr;
-
- /* since 2.12 */
- void* svg;
-
- } TT_FaceRec;
-
-
- /**************************************************************************
- *
- * @struct:
- * TT_GlyphZoneRec
- *
- * @description:
- * A glyph zone is used to load, scale and hint glyph outline
- * coordinates.
- *
- * @fields:
- * memory ::
- * A handle to the memory manager.
- *
- * max_points ::
- * The maximum size in points of the zone.
- *
- * max_contours ::
- * Max size in links contours of the zone.
- *
- * n_points ::
- * The current number of points in the zone.
- *
- * n_contours ::
- * The current number of contours in the zone.
- *
- * org ::
- * The original glyph coordinates (font units/scaled).
- *
- * cur ::
- * The current glyph coordinates (scaled/hinted).
- *
- * tags ::
- * The point control tags.
- *
- * contours ::
- * The contours end points.
- *
- * first_point ::
- * Offset of the current subglyph's first point.
- */
- typedef struct TT_GlyphZoneRec_
- {
- FT_Memory memory;
- FT_UShort max_points;
- FT_UShort max_contours;
- FT_UShort n_points; /* number of points in zone */
- FT_UShort n_contours; /* number of contours */
-
- FT_Vector* org; /* original point coordinates */
- FT_Vector* cur; /* current point coordinates */
- FT_Vector* orus; /* original (unscaled) point coordinates */
-
- FT_Byte* tags; /* current touch flags */
- FT_UShort* contours; /* contour end points */
-
- FT_UShort first_point; /* offset of first (#0) point */
-
- } TT_GlyphZoneRec, *TT_GlyphZone;
-
-
- /* handle to execution context */
- typedef struct TT_ExecContextRec_* TT_ExecContext;
-
-
- /**************************************************************************
- *
- * @type:
- * TT_Size
- *
- * @description:
- * A handle to a TrueType size object.
- */
- typedef struct TT_SizeRec_* TT_Size;
-
-
- /* glyph loader structure */
- typedef struct TT_LoaderRec_
- {
- TT_Face face;
- TT_Size size;
- FT_GlyphSlot glyph;
- FT_GlyphLoader gloader;
-
- FT_ULong load_flags;
- FT_UInt glyph_index;
-
- FT_Stream stream;
- FT_UInt byte_len;
-
- FT_Short n_contours;
- FT_BBox bbox;
- FT_Int left_bearing;
- FT_Int advance;
- FT_Int linear;
- FT_Bool linear_def;
- FT_Vector pp1;
- FT_Vector pp2;
-
- /* the zone where we load our glyphs */
- TT_GlyphZoneRec base;
- TT_GlyphZoneRec zone;
-
- TT_ExecContext exec;
- FT_Byte* instructions;
- FT_ULong ins_pos;
-
- /* for possible extensibility in other formats */
- void* other;
-
- /* since version 2.1.8 */
- FT_Int top_bearing;
- FT_Int vadvance;
- FT_Vector pp3;
- FT_Vector pp4;
-
- /* since version 2.2.1 */
- FT_Byte* cursor;
- FT_Byte* limit;
-
- /* since version 2.6.2 */
- FT_ListRec composites;
-
- /* since version 2.11.2 */
- FT_Byte* widthp;
-
- } TT_LoaderRec;
-
-
-FT_END_HEADER
-
-#endif /* TTTYPES_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/internal/wofftypes.h b/contrib/libs/freetype/include/freetype/internal/wofftypes.h
deleted file mode 100644
index 4a169d12f5..0000000000
--- a/contrib/libs/freetype/include/freetype/internal/wofftypes.h
+++ /dev/null
@@ -1,312 +0,0 @@
-/****************************************************************************
- *
- * wofftypes.h
- *
- * Basic WOFF/WOFF2 type definitions and interface (specification
- * only).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef WOFFTYPES_H_
-#define WOFFTYPES_H_
-
-
-#include <freetype/tttables.h>
-#include <freetype/internal/ftobjs.h>
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @struct:
- * WOFF_HeaderRec
- *
- * @description:
- * WOFF file format header.
- *
- * @fields:
- * See
- *
- * https://www.w3.org/TR/WOFF/#WOFFHeader
- */
- typedef struct WOFF_HeaderRec_
- {
- FT_ULong signature;
- FT_ULong flavor;
- FT_ULong length;
- FT_UShort num_tables;
- FT_UShort reserved;
- FT_ULong totalSfntSize;
- FT_UShort majorVersion;
- FT_UShort minorVersion;
- FT_ULong metaOffset;
- FT_ULong metaLength;
- FT_ULong metaOrigLength;
- FT_ULong privOffset;
- FT_ULong privLength;
-
- } WOFF_HeaderRec, *WOFF_Header;
-
-
- /**************************************************************************
- *
- * @struct:
- * WOFF_TableRec
- *
- * @description:
- * This structure describes a given table of a WOFF font.
- *
- * @fields:
- * Tag ::
- * A four-bytes tag describing the table.
- *
- * Offset ::
- * The offset of the table from the start of the WOFF font in its
- * resource.
- *
- * CompLength ::
- * Compressed table length (in bytes).
- *
- * OrigLength ::
- * Uncompressed table length (in bytes).
- *
- * CheckSum ::
- * The table checksum. This value can be ignored.
- *
- * OrigOffset ::
- * The uncompressed table file offset. This value gets computed while
- * constructing the (uncompressed) SFNT header. It is not contained in
- * the WOFF file.
- */
- typedef struct WOFF_TableRec_
- {
- FT_Tag Tag; /* table ID */
- FT_ULong Offset; /* table file offset */
- FT_ULong CompLength; /* compressed table length */
- FT_ULong OrigLength; /* uncompressed table length */
- FT_ULong CheckSum; /* uncompressed checksum */
-
- FT_ULong OrigOffset; /* uncompressed table file offset */
- /* (not in the WOFF file) */
- } WOFF_TableRec, *WOFF_Table;
-
-
- /**************************************************************************
- *
- * @struct:
- * WOFF2_TtcFontRec
- *
- * @description:
- * Metadata for a TTC font entry in WOFF2.
- *
- * @fields:
- * flavor ::
- * TTC font flavor.
- *
- * num_tables ::
- * Number of tables in TTC, indicating number of elements in
- * `table_indices`.
- *
- * table_indices ::
- * Array of table indices for each TTC font.
- */
- typedef struct WOFF2_TtcFontRec_
- {
- FT_ULong flavor;
- FT_UShort num_tables;
- FT_UShort* table_indices;
-
- } WOFF2_TtcFontRec, *WOFF2_TtcFont;
-
-
- /**************************************************************************
- *
- * @struct:
- * WOFF2_HeaderRec
- *
- * @description:
- * WOFF2 file format header.
- *
- * @fields:
- * See
- *
- * https://www.w3.org/TR/WOFF2/#woff20Header
- *
- * @note:
- * We don't care about the fields `reserved`, `majorVersion` and
- * `minorVersion`, so they are not included. The `totalSfntSize` field
- * does not necessarily represent the actual size of the uncompressed
- * SFNT font stream, so that is used as a reference value instead.
- */
- typedef struct WOFF2_HeaderRec_
- {
- FT_ULong signature;
- FT_ULong flavor;
- FT_ULong length;
- FT_UShort num_tables;
- FT_ULong totalSfntSize;
- FT_ULong totalCompressedSize;
- FT_ULong metaOffset;
- FT_ULong metaLength;
- FT_ULong metaOrigLength;
- FT_ULong privOffset;
- FT_ULong privLength;
-
- FT_ULong uncompressed_size; /* uncompressed brotli stream size */
- FT_ULong compressed_offset; /* compressed stream offset */
- FT_ULong header_version; /* version of original TTC Header */
- FT_UShort num_fonts; /* number of fonts in TTC */
- FT_ULong actual_sfnt_size; /* actual size of sfnt stream */
-
- WOFF2_TtcFont ttc_fonts; /* metadata for fonts in a TTC */
-
- } WOFF2_HeaderRec, *WOFF2_Header;
-
-
- /**************************************************************************
- *
- * @struct:
- * WOFF2_TableRec
- *
- * @description:
- * This structure describes a given table of a WOFF2 font.
- *
- * @fields:
- * See
- *
- * https://www.w3.org/TR/WOFF2/#table_dir_format
- */
- typedef struct WOFF2_TableRec_
- {
- FT_Byte FlagByte; /* table type and flags */
- FT_Tag Tag; /* table file offset */
- FT_ULong dst_length; /* uncompressed table length */
- FT_ULong TransformLength; /* transformed length */
-
- FT_ULong flags; /* calculated flags */
- FT_ULong src_offset; /* compressed table offset */
- FT_ULong src_length; /* compressed table length */
- FT_ULong dst_offset; /* uncompressed table offset */
-
- } WOFF2_TableRec, *WOFF2_Table;
-
-
- /**************************************************************************
- *
- * @struct:
- * WOFF2_InfoRec
- *
- * @description:
- * Metadata for WOFF2 font that may be required for reconstruction of
- * sfnt tables.
- *
- * @fields:
- * header_checksum ::
- * Checksum of SFNT offset table.
- *
- * num_glyphs ::
- * Number of glyphs in the font.
- *
- * num_hmetrics ::
- * `numberOfHMetrics` field in the 'hhea' table.
- *
- * x_mins ::
- * `xMin` values of glyph bounding box.
- *
- * glyf_table ::
- * A pointer to the `glyf' table record.
- *
- * loca_table ::
- * A pointer to the `loca' table record.
- *
- * head_table ::
- * A pointer to the `head' table record.
- */
- typedef struct WOFF2_InfoRec_
- {
- FT_ULong header_checksum;
- FT_UShort num_glyphs;
- FT_UShort num_hmetrics;
- FT_Short* x_mins;
-
- WOFF2_Table glyf_table;
- WOFF2_Table loca_table;
- WOFF2_Table head_table;
-
- } WOFF2_InfoRec, *WOFF2_Info;
-
-
- /**************************************************************************
- *
- * @struct:
- * WOFF2_SubstreamRec
- *
- * @description:
- * This structure stores information about a substream in the transformed
- * 'glyf' table in a WOFF2 stream.
- *
- * @fields:
- * start ::
- * Beginning of the substream relative to uncompressed table stream.
- *
- * offset ::
- * Offset of the substream relative to uncompressed table stream.
- *
- * size ::
- * Size of the substream.
- */
- typedef struct WOFF2_SubstreamRec_
- {
- FT_ULong start;
- FT_ULong offset;
- FT_ULong size;
-
- } WOFF2_SubstreamRec, *WOFF2_Substream;
-
-
- /**************************************************************************
- *
- * @struct:
- * WOFF2_PointRec
- *
- * @description:
- * This structure stores information about a point in the transformed
- * 'glyf' table in a WOFF2 stream.
- *
- * @fields:
- * x ::
- * x-coordinate of point.
- *
- * y ::
- * y-coordinate of point.
- *
- * on_curve ::
- * Set if point is on-curve.
- */
- typedef struct WOFF2_PointRec_
- {
- FT_Int x;
- FT_Int y;
- FT_Bool on_curve;
-
- } WOFF2_PointRec, *WOFF2_Point;
-
-
-FT_END_HEADER
-
-#endif /* WOFFTYPES_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/otsvg.h b/contrib/libs/freetype/include/freetype/otsvg.h
deleted file mode 100644
index 9d356938cc..0000000000
--- a/contrib/libs/freetype/include/freetype/otsvg.h
+++ /dev/null
@@ -1,336 +0,0 @@
-/****************************************************************************
- *
- * otsvg.h
- *
- * Interface for OT-SVG support related things (specification).
- *
- * Copyright (C) 2022-2024 by
- * David Turner, Robert Wilhelm, Werner Lemberg, and Moazin Khatti.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef OTSVG_H_
-#define OTSVG_H_
-
-#include <freetype/freetype.h>
-
-#ifdef FREETYPE_H
-#error "freetype.h of FreeType 1 has been loaded!"
-#error "Please fix the directory search order for header files"
-#error "so that freetype.h of FreeType 2 is found first."
-#endif
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @section:
- * svg_fonts
- *
- * @title:
- * OpenType SVG Fonts
- *
- * @abstract:
- * OT-SVG API between FreeType and an external SVG rendering library.
- *
- * @description:
- * This section describes the four hooks necessary to render SVG
- * 'documents' that are contained in an OpenType font's 'SVG~' table.
- *
- * For more information on the implementation, see our standard hooks
- * based on 'librsvg' in the [FreeType Demo
- * Programs](https://gitlab.freedesktop.org/freetype/freetype-demos)
- * repository.
- *
- */
-
-
- /**************************************************************************
- *
- * @functype:
- * SVG_Lib_Init_Func
- *
- * @description:
- * A callback that is called when the first OT-SVG glyph is rendered in
- * the lifetime of an @FT_Library object. In a typical implementation,
- * one would want to allocate a structure and point the `data_pointer`
- * to it and perform any library initializations that might be needed.
- *
- * @inout:
- * data_pointer ::
- * The SVG rendering module stores a pointer variable that can be used
- * by clients to store any data that needs to be shared across
- * different hooks. `data_pointer` is essentially a pointer to that
- * pointer such that it can be written to as well as read from.
- *
- * @return:
- * FreeType error code. 0 means success.
- *
- * @since:
- * 2.12
- */
- typedef FT_Error
- (*SVG_Lib_Init_Func)( FT_Pointer *data_pointer );
-
-
- /**************************************************************************
- *
- * @functype:
- * SVG_Lib_Free_Func
- *
- * @description:
- * A callback that is called when the `ot-svg` module is being freed.
- * It is only called if the init hook was called earlier. This means
- * that neither the init nor the free hook is called if no OT-SVG glyph
- * is rendered.
- *
- * In a typical implementation, one would want to free any state
- * structure that was allocated in the init hook and perform any
- * library-related closure that might be needed.
- *
- * @inout:
- * data_pointer ::
- * The SVG rendering module stores a pointer variable that can be used
- * by clients to store any data that needs to be shared across
- * different hooks. `data_pointer` is essentially a pointer to that
- * pointer such that it can be written to as well as read from.
- *
- * @since:
- * 2.12
- */
- typedef void
- (*SVG_Lib_Free_Func)( FT_Pointer *data_pointer );
-
-
- /**************************************************************************
- *
- * @functype:
- * SVG_Lib_Render_Func
- *
- * @description:
- * A callback that is called to render an OT-SVG glyph. This callback
- * hook is called right after the preset hook @SVG_Lib_Preset_Slot_Func
- * has been called with `cache` set to `TRUE`. The data necessary to
- * render is available through the handle @FT_SVG_Document, which is set
- * in the `other` field of @FT_GlyphSlotRec.
- *
- * The render hook is expected to render the SVG glyph to the bitmap
- * buffer that is allocated already at `slot->bitmap.buffer`. It also
- * sets the `num_grays` value as well as `slot->format`.
- *
- * @input:
- * slot ::
- * The slot to render.
- *
- * @inout:
- * data_pointer ::
- * The SVG rendering module stores a pointer variable that can be used
- * by clients to store any data that needs to be shared across
- * different hooks. `data_pointer` is essentially a pointer to that
- * pointer such that it can be written to as well as read from.
- *
- * @return:
- * FreeType error code. 0 means success.
- *
- * @since:
- * 2.12
- */
- typedef FT_Error
- (*SVG_Lib_Render_Func)( FT_GlyphSlot slot,
- FT_Pointer *data_pointer );
-
-
- /**************************************************************************
- *
- * @functype:
- * SVG_Lib_Preset_Slot_Func
- *
- * @description:
- * A callback that is called to preset the glyph slot. It is called from
- * two places.
- *
- * 1. When `FT_Load_Glyph` needs to preset the glyph slot.
- *
- * 2. Right before the `svg` module calls the render callback hook.
- *
- * When it is the former, the argument `cache` is set to `FALSE`. When
- * it is the latter, the argument `cache` is set to `TRUE`. This
- * distinction has been made because many calculations that are necessary
- * for presetting a glyph slot are the same needed later for the render
- * callback hook. Thus, if `cache` is `TRUE`, the hook can _cache_ those
- * calculations in a memory block referenced by the state pointer.
- *
- * This hook is expected to preset the slot by setting parameters such as
- * `bitmap_left`, `bitmap_top`, `width`, `rows`, `pitch`, and
- * `pixel_mode`. It is also expected to set all the metrics for the slot
- * including the vertical advance if it is not already set. Typically,
- * fonts have horizontal advances but not vertical ones. If those are
- * available, they had already been set, otherwise they have to be
- * estimated and set manually. The hook must take into account the
- * transformations that have been set, and translate the transformation
- * matrices into the SVG coordinate system, as the original matrix is
- * intended for the TTF/CFF coordinate system.
- *
- * @input:
- * slot ::
- * The glyph slot that has the SVG document loaded.
- *
- * cache ::
- * See description.
- *
- * @inout:
- * data_pointer ::
- * The SVG rendering module stores a pointer variable that can be used
- * by clients to store any data that needs to be shared across
- * different hooks. `data_pointer` is essentially a pointer to that
- * pointer such that it can be written to as well as read from.
- *
- * @return:
- * FreeType error code. 0 means success.
- *
- * @since:
- * 2.12
- */
- typedef FT_Error
- (*SVG_Lib_Preset_Slot_Func)( FT_GlyphSlot slot,
- FT_Bool cache,
- FT_Pointer *state );
-
-
- /**************************************************************************
- *
- * @struct:
- * SVG_RendererHooks
- *
- * @description:
- * A structure that stores the four hooks needed to render OT-SVG glyphs
- * properly. The structure is publicly used to set the hooks via the
- * @svg-hooks driver property.
- *
- * The behavior of each hook is described in its documentation. One
- * thing to note is that the preset hook and the render hook often need
- * to do the same operations; therefore, it's better to cache the
- * intermediate data in a state structure to avoid calculating it twice.
- * For example, in the preset hook one can draw the glyph on a recorder
- * surface and later create a bitmap surface from it in the render hook.
- *
- * All four hooks must be non-NULL.
- *
- * @fields:
- * init_svg ::
- * The initialization hook.
- *
- * free_svg ::
- * The cleanup hook.
- *
- * render_hook ::
- * The render hook.
- *
- * preset_slot ::
- * The preset hook.
- *
- * @since:
- * 2.12
- */
- typedef struct SVG_RendererHooks_
- {
- SVG_Lib_Init_Func init_svg;
- SVG_Lib_Free_Func free_svg;
- SVG_Lib_Render_Func render_svg;
-
- SVG_Lib_Preset_Slot_Func preset_slot;
-
- } SVG_RendererHooks;
-
-
- /**************************************************************************
- *
- * @struct:
- * FT_SVG_DocumentRec
- *
- * @description:
- * A structure that models one SVG document.
- *
- * @fields:
- * svg_document ::
- * A pointer to the SVG document.
- *
- * svg_document_length ::
- * The length of `svg_document`.
- *
- * metrics ::
- * A metrics object storing the size information.
- *
- * units_per_EM ::
- * The size of the EM square.
- *
- * start_glyph_id ::
- * The first glyph ID in the glyph range covered by this document.
- *
- * end_glyph_id ::
- * The last glyph ID in the glyph range covered by this document.
- *
- * transform ::
- * A 2x2 transformation matrix to apply to the glyph while rendering
- * it.
- *
- * delta ::
- * The translation to apply to the glyph while rendering.
- *
- * @note:
- * When an @FT_GlyphSlot object `slot` is passed down to a renderer, the
- * renderer can only access the `metrics` and `units_per_EM` fields via
- * `slot->face`. However, when @FT_Glyph_To_Bitmap sets up a dummy
- * object, it has no way to set a `face` object. Thus, metrics
- * information and `units_per_EM` (which is necessary for OT-SVG) has to
- * be stored separately.
- *
- * @since:
- * 2.12
- */
- typedef struct FT_SVG_DocumentRec_
- {
- FT_Byte* svg_document;
- FT_ULong svg_document_length;
-
- FT_Size_Metrics metrics;
- FT_UShort units_per_EM;
-
- FT_UShort start_glyph_id;
- FT_UShort end_glyph_id;
-
- FT_Matrix transform;
- FT_Vector delta;
-
- } FT_SVG_DocumentRec;
-
-
- /**************************************************************************
- *
- * @type:
- * FT_SVG_Document
- *
- * @description:
- * A handle to an @FT_SVG_DocumentRec object.
- *
- * @since:
- * 2.12
- */
- typedef struct FT_SVG_DocumentRec_* FT_SVG_Document;
-
-
-FT_END_HEADER
-
-#endif /* OTSVG_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/t1tables.h b/contrib/libs/freetype/include/freetype/t1tables.h
deleted file mode 100644
index fbd558aa34..0000000000
--- a/contrib/libs/freetype/include/freetype/t1tables.h
+++ /dev/null
@@ -1,735 +0,0 @@
-/****************************************************************************
- *
- * t1tables.h
- *
- * Basic Type 1/Type 2 tables definitions and interface (specification
- * only).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef T1TABLES_H_
-#define T1TABLES_H_
-
-
-#include <freetype/freetype.h>
-
-#ifdef FREETYPE_H
-#error "freetype.h of FreeType 1 has been loaded!"
-#error "Please fix the directory search order for header files"
-#error "so that freetype.h of FreeType 2 is found first."
-#endif
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @section:
- * type1_tables
- *
- * @title:
- * Type 1 Tables
- *
- * @abstract:
- * Type~1-specific font tables.
- *
- * @description:
- * This section contains the definition of Type~1-specific tables,
- * including structures related to other PostScript font formats.
- *
- * @order:
- * PS_FontInfoRec
- * PS_FontInfo
- * PS_PrivateRec
- * PS_Private
- *
- * CID_FaceDictRec
- * CID_FaceDict
- * CID_FaceInfoRec
- * CID_FaceInfo
- *
- * FT_Has_PS_Glyph_Names
- * FT_Get_PS_Font_Info
- * FT_Get_PS_Font_Private
- * FT_Get_PS_Font_Value
- *
- * T1_Blend_Flags
- * T1_EncodingType
- * PS_Dict_Keys
- *
- */
-
-
- /* Note that we separate font data in PS_FontInfoRec and PS_PrivateRec */
- /* structures in order to support Multiple Master fonts. */
-
-
- /**************************************************************************
- *
- * @struct:
- * PS_FontInfoRec
- *
- * @description:
- * A structure used to model a Type~1 or Type~2 FontInfo dictionary.
- * Note that for Multiple Master fonts, each instance has its own
- * FontInfo dictionary.
- */
- typedef struct PS_FontInfoRec_
- {
- FT_String* version;
- FT_String* notice;
- FT_String* full_name;
- FT_String* family_name;
- FT_String* weight;
- FT_Long italic_angle;
- FT_Bool is_fixed_pitch;
- FT_Short underline_position;
- FT_UShort underline_thickness;
-
- } PS_FontInfoRec;
-
-
- /**************************************************************************
- *
- * @struct:
- * PS_FontInfo
- *
- * @description:
- * A handle to a @PS_FontInfoRec structure.
- */
- typedef struct PS_FontInfoRec_* PS_FontInfo;
-
-
- /**************************************************************************
- *
- * @struct:
- * T1_FontInfo
- *
- * @description:
- * This type is equivalent to @PS_FontInfoRec. It is deprecated but kept
- * to maintain source compatibility between various versions of FreeType.
- */
- typedef PS_FontInfoRec T1_FontInfo;
-
-
- /**************************************************************************
- *
- * @struct:
- * PS_PrivateRec
- *
- * @description:
- * A structure used to model a Type~1 or Type~2 private dictionary. Note
- * that for Multiple Master fonts, each instance has its own Private
- * dictionary.
- */
- typedef struct PS_PrivateRec_
- {
- FT_Int unique_id;
- FT_Int lenIV;
-
- FT_Byte num_blue_values;
- FT_Byte num_other_blues;
- FT_Byte num_family_blues;
- FT_Byte num_family_other_blues;
-
- FT_Short blue_values[14];
- FT_Short other_blues[10];
-
- FT_Short family_blues [14];
- FT_Short family_other_blues[10];
-
- FT_Fixed blue_scale;
- FT_Int blue_shift;
- FT_Int blue_fuzz;
-
- FT_UShort standard_width[1];
- FT_UShort standard_height[1];
-
- FT_Byte num_snap_widths;
- FT_Byte num_snap_heights;
- FT_Bool force_bold;
- FT_Bool round_stem_up;
-
- FT_Short snap_widths [13]; /* including std width */
- FT_Short snap_heights[13]; /* including std height */
-
- FT_Fixed expansion_factor;
-
- FT_Long language_group;
- FT_Long password;
-
- FT_Short min_feature[2];
-
- } PS_PrivateRec;
-
-
- /**************************************************************************
- *
- * @struct:
- * PS_Private
- *
- * @description:
- * A handle to a @PS_PrivateRec structure.
- */
- typedef struct PS_PrivateRec_* PS_Private;
-
-
- /**************************************************************************
- *
- * @struct:
- * T1_Private
- *
- * @description:
- * This type is equivalent to @PS_PrivateRec. It is deprecated but kept
- * to maintain source compatibility between various versions of FreeType.
- */
- typedef PS_PrivateRec T1_Private;
-
-
- /**************************************************************************
- *
- * @enum:
- * T1_Blend_Flags
- *
- * @description:
- * A set of flags used to indicate which fields are present in a given
- * blend dictionary (font info or private). Used to support Multiple
- * Masters fonts.
- *
- * @values:
- * T1_BLEND_UNDERLINE_POSITION ::
- * T1_BLEND_UNDERLINE_THICKNESS ::
- * T1_BLEND_ITALIC_ANGLE ::
- * T1_BLEND_BLUE_VALUES ::
- * T1_BLEND_OTHER_BLUES ::
- * T1_BLEND_STANDARD_WIDTH ::
- * T1_BLEND_STANDARD_HEIGHT ::
- * T1_BLEND_STEM_SNAP_WIDTHS ::
- * T1_BLEND_STEM_SNAP_HEIGHTS ::
- * T1_BLEND_BLUE_SCALE ::
- * T1_BLEND_BLUE_SHIFT ::
- * T1_BLEND_FAMILY_BLUES ::
- * T1_BLEND_FAMILY_OTHER_BLUES ::
- * T1_BLEND_FORCE_BOLD ::
- */
- typedef enum T1_Blend_Flags_
- {
- /* required fields in a FontInfo blend dictionary */
- T1_BLEND_UNDERLINE_POSITION = 0,
- T1_BLEND_UNDERLINE_THICKNESS,
- T1_BLEND_ITALIC_ANGLE,
-
- /* required fields in a Private blend dictionary */
- T1_BLEND_BLUE_VALUES,
- T1_BLEND_OTHER_BLUES,
- T1_BLEND_STANDARD_WIDTH,
- T1_BLEND_STANDARD_HEIGHT,
- T1_BLEND_STEM_SNAP_WIDTHS,
- T1_BLEND_STEM_SNAP_HEIGHTS,
- T1_BLEND_BLUE_SCALE,
- T1_BLEND_BLUE_SHIFT,
- T1_BLEND_FAMILY_BLUES,
- T1_BLEND_FAMILY_OTHER_BLUES,
- T1_BLEND_FORCE_BOLD,
-
- T1_BLEND_MAX /* do not remove */
-
- } T1_Blend_Flags;
-
-
- /* these constants are deprecated; use the corresponding */
- /* `T1_Blend_Flags` values instead */
-#define t1_blend_underline_position T1_BLEND_UNDERLINE_POSITION
-#define t1_blend_underline_thickness T1_BLEND_UNDERLINE_THICKNESS
-#define t1_blend_italic_angle T1_BLEND_ITALIC_ANGLE
-#define t1_blend_blue_values T1_BLEND_BLUE_VALUES
-#define t1_blend_other_blues T1_BLEND_OTHER_BLUES
-#define t1_blend_standard_widths T1_BLEND_STANDARD_WIDTH
-#define t1_blend_standard_height T1_BLEND_STANDARD_HEIGHT
-#define t1_blend_stem_snap_widths T1_BLEND_STEM_SNAP_WIDTHS
-#define t1_blend_stem_snap_heights T1_BLEND_STEM_SNAP_HEIGHTS
-#define t1_blend_blue_scale T1_BLEND_BLUE_SCALE
-#define t1_blend_blue_shift T1_BLEND_BLUE_SHIFT
-#define t1_blend_family_blues T1_BLEND_FAMILY_BLUES
-#define t1_blend_family_other_blues T1_BLEND_FAMILY_OTHER_BLUES
-#define t1_blend_force_bold T1_BLEND_FORCE_BOLD
-#define t1_blend_max T1_BLEND_MAX
-
- /* */
-
-
- /**************************************************************************
- *
- * @struct:
- * CID_FaceDictRec
- *
- * @description:
- * A structure used to represent data in a CID top-level dictionary. In
- * most cases, they are part of the font's '/FDArray' array. Within a
- * CID font file, such (internal) subfont dictionaries are enclosed by
- * '%ADOBeginFontDict' and '%ADOEndFontDict' comments.
- *
- * Note that `CID_FaceDictRec` misses a field for the '/FontName'
- * keyword, specifying the subfont's name (the top-level font name is
- * given by the '/CIDFontName' keyword). This is an oversight, but it
- * doesn't limit the 'cid' font module's functionality because FreeType
- * neither needs this entry nor gives access to CID subfonts.
- */
- typedef struct CID_FaceDictRec_
- {
- PS_PrivateRec private_dict;
-
- FT_UInt len_buildchar;
- FT_Fixed forcebold_threshold;
- FT_Pos stroke_width;
- FT_Fixed expansion_factor; /* this is a duplicate of */
- /* `private_dict->expansion_factor' */
- FT_Byte paint_type;
- FT_Byte font_type;
- FT_Matrix font_matrix;
- FT_Vector font_offset;
-
- FT_UInt num_subrs;
- FT_ULong subrmap_offset;
- FT_UInt sd_bytes;
-
- } CID_FaceDictRec;
-
-
- /**************************************************************************
- *
- * @struct:
- * CID_FaceDict
- *
- * @description:
- * A handle to a @CID_FaceDictRec structure.
- */
- typedef struct CID_FaceDictRec_* CID_FaceDict;
-
-
- /**************************************************************************
- *
- * @struct:
- * CID_FontDict
- *
- * @description:
- * This type is equivalent to @CID_FaceDictRec. It is deprecated but
- * kept to maintain source compatibility between various versions of
- * FreeType.
- */
- typedef CID_FaceDictRec CID_FontDict;
-
-
- /**************************************************************************
- *
- * @struct:
- * CID_FaceInfoRec
- *
- * @description:
- * A structure used to represent CID Face information.
- */
- typedef struct CID_FaceInfoRec_
- {
- FT_String* cid_font_name;
- FT_Fixed cid_version;
- FT_Int cid_font_type;
-
- FT_String* registry;
- FT_String* ordering;
- FT_Int supplement;
-
- PS_FontInfoRec font_info;
- FT_BBox font_bbox;
- FT_ULong uid_base;
-
- FT_Int num_xuid;
- FT_ULong xuid[16];
-
- FT_ULong cidmap_offset;
- FT_UInt fd_bytes;
- FT_UInt gd_bytes;
- FT_ULong cid_count;
-
- FT_UInt num_dicts;
- CID_FaceDict font_dicts;
-
- FT_ULong data_offset;
-
- } CID_FaceInfoRec;
-
-
- /**************************************************************************
- *
- * @struct:
- * CID_FaceInfo
- *
- * @description:
- * A handle to a @CID_FaceInfoRec structure.
- */
- typedef struct CID_FaceInfoRec_* CID_FaceInfo;
-
-
- /**************************************************************************
- *
- * @struct:
- * CID_Info
- *
- * @description:
- * This type is equivalent to @CID_FaceInfoRec. It is deprecated but kept
- * to maintain source compatibility between various versions of FreeType.
- */
- typedef CID_FaceInfoRec CID_Info;
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Has_PS_Glyph_Names
- *
- * @description:
- * Return true if a given face provides reliable PostScript glyph names.
- * This is similar to using the @FT_HAS_GLYPH_NAMES macro, except that
- * certain fonts (mostly TrueType) contain incorrect glyph name tables.
- *
- * When this function returns true, the caller is sure that the glyph
- * names returned by @FT_Get_Glyph_Name are reliable.
- *
- * @input:
- * face ::
- * face handle
- *
- * @return:
- * Boolean. True if glyph names are reliable.
- *
- */
- FT_EXPORT( FT_Int )
- FT_Has_PS_Glyph_Names( FT_Face face );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_PS_Font_Info
- *
- * @description:
- * Retrieve the @PS_FontInfoRec structure corresponding to a given
- * PostScript font.
- *
- * @input:
- * face ::
- * PostScript face handle.
- *
- * @output:
- * afont_info ::
- * A pointer to a @PS_FontInfoRec object.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * String pointers within the @PS_FontInfoRec structure are owned by the
- * face and don't need to be freed by the caller. Missing entries in the
- * font's FontInfo dictionary are represented by `NULL` pointers.
- *
- * The following font formats support this feature: 'Type~1', 'Type~42',
- * 'CFF', 'CID~Type~1'. For other font formats this function returns the
- * `FT_Err_Invalid_Argument` error code.
- *
- * @example:
- * ```
- * PS_FontInfoRec font_info;
- *
- *
- * error = FT_Get_PS_Font_Info( face, &font_info );
- * ...
- * ```
- *
- */
- FT_EXPORT( FT_Error )
- FT_Get_PS_Font_Info( FT_Face face,
- PS_FontInfo afont_info );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_PS_Font_Private
- *
- * @description:
- * Retrieve the @PS_PrivateRec structure corresponding to a given
- * PostScript font.
- *
- * @input:
- * face ::
- * PostScript face handle.
- *
- * @output:
- * afont_private ::
- * A pointer to a @PS_PrivateRec object.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * The string pointers within the @PS_PrivateRec structure are owned by
- * the face and don't need to be freed by the caller.
- *
- * Only the 'Type~1' font format supports this feature. For other font
- * formats this function returns the `FT_Err_Invalid_Argument` error
- * code.
- *
- * @example:
- * ```
- * PS_PrivateRec font_private;
- *
- *
- * error = FT_Get_PS_Font_Private( face, &font_private );
- * ...
- * ```
- *
- */
- FT_EXPORT( FT_Error )
- FT_Get_PS_Font_Private( FT_Face face,
- PS_Private afont_private );
-
-
- /**************************************************************************
- *
- * @enum:
- * T1_EncodingType
- *
- * @description:
- * An enumeration describing the 'Encoding' entry in a Type 1 dictionary.
- *
- * @values:
- * T1_ENCODING_TYPE_NONE ::
- * T1_ENCODING_TYPE_ARRAY ::
- * T1_ENCODING_TYPE_STANDARD ::
- * T1_ENCODING_TYPE_ISOLATIN1 ::
- * T1_ENCODING_TYPE_EXPERT ::
- *
- * @since:
- * 2.4.8
- */
- typedef enum T1_EncodingType_
- {
- T1_ENCODING_TYPE_NONE = 0,
- T1_ENCODING_TYPE_ARRAY,
- T1_ENCODING_TYPE_STANDARD,
- T1_ENCODING_TYPE_ISOLATIN1,
- T1_ENCODING_TYPE_EXPERT
-
- } T1_EncodingType;
-
-
- /**************************************************************************
- *
- * @enum:
- * PS_Dict_Keys
- *
- * @description:
- * An enumeration used in calls to @FT_Get_PS_Font_Value to identify the
- * Type~1 dictionary entry to retrieve.
- *
- * @values:
- * PS_DICT_FONT_TYPE ::
- * PS_DICT_FONT_MATRIX ::
- * PS_DICT_FONT_BBOX ::
- * PS_DICT_PAINT_TYPE ::
- * PS_DICT_FONT_NAME ::
- * PS_DICT_UNIQUE_ID ::
- * PS_DICT_NUM_CHAR_STRINGS ::
- * PS_DICT_CHAR_STRING_KEY ::
- * PS_DICT_CHAR_STRING ::
- * PS_DICT_ENCODING_TYPE ::
- * PS_DICT_ENCODING_ENTRY ::
- * PS_DICT_NUM_SUBRS ::
- * PS_DICT_SUBR ::
- * PS_DICT_STD_HW ::
- * PS_DICT_STD_VW ::
- * PS_DICT_NUM_BLUE_VALUES ::
- * PS_DICT_BLUE_VALUE ::
- * PS_DICT_BLUE_FUZZ ::
- * PS_DICT_NUM_OTHER_BLUES ::
- * PS_DICT_OTHER_BLUE ::
- * PS_DICT_NUM_FAMILY_BLUES ::
- * PS_DICT_FAMILY_BLUE ::
- * PS_DICT_NUM_FAMILY_OTHER_BLUES ::
- * PS_DICT_FAMILY_OTHER_BLUE ::
- * PS_DICT_BLUE_SCALE ::
- * PS_DICT_BLUE_SHIFT ::
- * PS_DICT_NUM_STEM_SNAP_H ::
- * PS_DICT_STEM_SNAP_H ::
- * PS_DICT_NUM_STEM_SNAP_V ::
- * PS_DICT_STEM_SNAP_V ::
- * PS_DICT_FORCE_BOLD ::
- * PS_DICT_RND_STEM_UP ::
- * PS_DICT_MIN_FEATURE ::
- * PS_DICT_LEN_IV ::
- * PS_DICT_PASSWORD ::
- * PS_DICT_LANGUAGE_GROUP ::
- * PS_DICT_VERSION ::
- * PS_DICT_NOTICE ::
- * PS_DICT_FULL_NAME ::
- * PS_DICT_FAMILY_NAME ::
- * PS_DICT_WEIGHT ::
- * PS_DICT_IS_FIXED_PITCH ::
- * PS_DICT_UNDERLINE_POSITION ::
- * PS_DICT_UNDERLINE_THICKNESS ::
- * PS_DICT_FS_TYPE ::
- * PS_DICT_ITALIC_ANGLE ::
- *
- * @since:
- * 2.4.8
- */
- typedef enum PS_Dict_Keys_
- {
- /* conventionally in the font dictionary */
- PS_DICT_FONT_TYPE, /* FT_Byte */
- PS_DICT_FONT_MATRIX, /* FT_Fixed */
- PS_DICT_FONT_BBOX, /* FT_Fixed */
- PS_DICT_PAINT_TYPE, /* FT_Byte */
- PS_DICT_FONT_NAME, /* FT_String* */
- PS_DICT_UNIQUE_ID, /* FT_Int */
- PS_DICT_NUM_CHAR_STRINGS, /* FT_Int */
- PS_DICT_CHAR_STRING_KEY, /* FT_String* */
- PS_DICT_CHAR_STRING, /* FT_String* */
- PS_DICT_ENCODING_TYPE, /* T1_EncodingType */
- PS_DICT_ENCODING_ENTRY, /* FT_String* */
-
- /* conventionally in the font Private dictionary */
- PS_DICT_NUM_SUBRS, /* FT_Int */
- PS_DICT_SUBR, /* FT_String* */
- PS_DICT_STD_HW, /* FT_UShort */
- PS_DICT_STD_VW, /* FT_UShort */
- PS_DICT_NUM_BLUE_VALUES, /* FT_Byte */
- PS_DICT_BLUE_VALUE, /* FT_Short */
- PS_DICT_BLUE_FUZZ, /* FT_Int */
- PS_DICT_NUM_OTHER_BLUES, /* FT_Byte */
- PS_DICT_OTHER_BLUE, /* FT_Short */
- PS_DICT_NUM_FAMILY_BLUES, /* FT_Byte */
- PS_DICT_FAMILY_BLUE, /* FT_Short */
- PS_DICT_NUM_FAMILY_OTHER_BLUES, /* FT_Byte */
- PS_DICT_FAMILY_OTHER_BLUE, /* FT_Short */
- PS_DICT_BLUE_SCALE, /* FT_Fixed */
- PS_DICT_BLUE_SHIFT, /* FT_Int */
- PS_DICT_NUM_STEM_SNAP_H, /* FT_Byte */
- PS_DICT_STEM_SNAP_H, /* FT_Short */
- PS_DICT_NUM_STEM_SNAP_V, /* FT_Byte */
- PS_DICT_STEM_SNAP_V, /* FT_Short */
- PS_DICT_FORCE_BOLD, /* FT_Bool */
- PS_DICT_RND_STEM_UP, /* FT_Bool */
- PS_DICT_MIN_FEATURE, /* FT_Short */
- PS_DICT_LEN_IV, /* FT_Int */
- PS_DICT_PASSWORD, /* FT_Long */
- PS_DICT_LANGUAGE_GROUP, /* FT_Long */
-
- /* conventionally in the font FontInfo dictionary */
- PS_DICT_VERSION, /* FT_String* */
- PS_DICT_NOTICE, /* FT_String* */
- PS_DICT_FULL_NAME, /* FT_String* */
- PS_DICT_FAMILY_NAME, /* FT_String* */
- PS_DICT_WEIGHT, /* FT_String* */
- PS_DICT_IS_FIXED_PITCH, /* FT_Bool */
- PS_DICT_UNDERLINE_POSITION, /* FT_Short */
- PS_DICT_UNDERLINE_THICKNESS, /* FT_UShort */
- PS_DICT_FS_TYPE, /* FT_UShort */
- PS_DICT_ITALIC_ANGLE, /* FT_Long */
-
- PS_DICT_MAX = PS_DICT_ITALIC_ANGLE
-
- } PS_Dict_Keys;
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_PS_Font_Value
- *
- * @description:
- * Retrieve the value for the supplied key from a PostScript font.
- *
- * @input:
- * face ::
- * PostScript face handle.
- *
- * key ::
- * An enumeration value representing the dictionary key to retrieve.
- *
- * idx ::
- * For array values, this specifies the index to be returned.
- *
- * value ::
- * A pointer to memory into which to write the value.
- *
- * valen_len ::
- * The size, in bytes, of the memory supplied for the value.
- *
- * @output:
- * value ::
- * The value matching the above key, if it exists.
- *
- * @return:
- * The amount of memory (in bytes) required to hold the requested value
- * (if it exists, -1 otherwise).
- *
- * @note:
- * The values returned are not pointers into the internal structures of
- * the face, but are 'fresh' copies, so that the memory containing them
- * belongs to the calling application. This also enforces the
- * 'read-only' nature of these values, i.e., this function cannot be
- * used to manipulate the face.
- *
- * `value` is a void pointer because the values returned can be of
- * various types.
- *
- * If either `value` is `NULL` or `value_len` is too small, just the
- * required memory size for the requested entry is returned.
- *
- * The `idx` parameter is used, not only to retrieve elements of, for
- * example, the FontMatrix or FontBBox, but also to retrieve name keys
- * from the CharStrings dictionary, and the charstrings themselves. It
- * is ignored for atomic values.
- *
- * `PS_DICT_BLUE_SCALE` returns a value that is scaled up by 1000. To
- * get the value as in the font stream, you need to divide by 65536000.0
- * (to remove the FT_Fixed scale, and the x1000 scale).
- *
- * IMPORTANT: Only key/value pairs read by the FreeType interpreter can
- * be retrieved. So, for example, PostScript procedures such as NP, ND,
- * and RD are not available. Arbitrary keys are, obviously, not be
- * available either.
- *
- * If the font's format is not PostScript-based, this function returns
- * the `FT_Err_Invalid_Argument` error code.
- *
- * @since:
- * 2.4.8
- *
- */
- FT_EXPORT( FT_Long )
- FT_Get_PS_Font_Value( FT_Face face,
- PS_Dict_Keys key,
- FT_UInt idx,
- void *value,
- FT_Long value_len );
-
- /* */
-
-FT_END_HEADER
-
-#endif /* T1TABLES_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/ttnameid.h b/contrib/libs/freetype/include/freetype/ttnameid.h
deleted file mode 100644
index d5d470e380..0000000000
--- a/contrib/libs/freetype/include/freetype/ttnameid.h
+++ /dev/null
@@ -1,1235 +0,0 @@
-/****************************************************************************
- *
- * ttnameid.h
- *
- * TrueType name ID definitions (specification only).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef TTNAMEID_H_
-#define TTNAMEID_H_
-
-
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @section:
- * truetype_tables
- */
-
-
- /**************************************************************************
- *
- * Possible values for the 'platform' identifier code in the name records
- * of an SFNT 'name' table.
- *
- */
-
-
- /**************************************************************************
- *
- * @enum:
- * TT_PLATFORM_XXX
- *
- * @description:
- * A list of valid values for the `platform_id` identifier code in
- * @FT_CharMapRec and @FT_SfntName structures.
- *
- * @values:
- * TT_PLATFORM_APPLE_UNICODE ::
- * Used by Apple to indicate a Unicode character map and/or name entry.
- * See @TT_APPLE_ID_XXX for corresponding `encoding_id` values. Note
- * that name entries in this format are coded as big-endian UCS-2
- * character codes _only_.
- *
- * TT_PLATFORM_MACINTOSH ::
- * Used by Apple to indicate a MacOS-specific charmap and/or name
- * entry. See @TT_MAC_ID_XXX for corresponding `encoding_id` values.
- * Note that most TrueType fonts contain an Apple roman charmap to be
- * usable on MacOS systems (even if they contain a Microsoft charmap as
- * well).
- *
- * TT_PLATFORM_ISO ::
- * This value was used to specify ISO/IEC 10646 charmaps. It is
- * however now deprecated. See @TT_ISO_ID_XXX for a list of
- * corresponding `encoding_id` values.
- *
- * TT_PLATFORM_MICROSOFT ::
- * Used by Microsoft to indicate Windows-specific charmaps. See
- * @TT_MS_ID_XXX for a list of corresponding `encoding_id` values.
- * Note that most fonts contain a Unicode charmap using
- * (`TT_PLATFORM_MICROSOFT`, @TT_MS_ID_UNICODE_CS).
- *
- * TT_PLATFORM_CUSTOM ::
- * Used to indicate application-specific charmaps.
- *
- * TT_PLATFORM_ADOBE ::
- * This value isn't part of any font format specification, but is used
- * by FreeType to report Adobe-specific charmaps in an @FT_CharMapRec
- * structure. See @TT_ADOBE_ID_XXX.
- */
-
-#define TT_PLATFORM_APPLE_UNICODE 0
-#define TT_PLATFORM_MACINTOSH 1
-#define TT_PLATFORM_ISO 2 /* deprecated */
-#define TT_PLATFORM_MICROSOFT 3
-#define TT_PLATFORM_CUSTOM 4
-#define TT_PLATFORM_ADOBE 7 /* artificial */
-
-
- /**************************************************************************
- *
- * @enum:
- * TT_APPLE_ID_XXX
- *
- * @description:
- * A list of valid values for the `encoding_id` for
- * @TT_PLATFORM_APPLE_UNICODE charmaps and name entries.
- *
- * @values:
- * TT_APPLE_ID_DEFAULT ::
- * Unicode version 1.0.
- *
- * TT_APPLE_ID_UNICODE_1_1 ::
- * Unicode 1.1; specifies Hangul characters starting at U+34xx.
- *
- * TT_APPLE_ID_ISO_10646 ::
- * Deprecated (identical to preceding).
- *
- * TT_APPLE_ID_UNICODE_2_0 ::
- * Unicode 2.0 and beyond (UTF-16 BMP only).
- *
- * TT_APPLE_ID_UNICODE_32 ::
- * Unicode 3.1 and beyond, using UTF-32.
- *
- * TT_APPLE_ID_VARIANT_SELECTOR ::
- * From Adobe, not Apple. Not a normal cmap. Specifies variations on
- * a real cmap.
- *
- * TT_APPLE_ID_FULL_UNICODE ::
- * Used for fallback fonts that provide complete Unicode coverage with
- * a type~13 cmap.
- */
-
-#define TT_APPLE_ID_DEFAULT 0 /* Unicode 1.0 */
-#define TT_APPLE_ID_UNICODE_1_1 1 /* specify Hangul at U+34xx */
-#define TT_APPLE_ID_ISO_10646 2 /* deprecated */
-#define TT_APPLE_ID_UNICODE_2_0 3 /* or later */
-#define TT_APPLE_ID_UNICODE_32 4 /* 2.0 or later, full repertoire */
-#define TT_APPLE_ID_VARIANT_SELECTOR 5 /* variation selector data */
-#define TT_APPLE_ID_FULL_UNICODE 6 /* used with type 13 cmaps */
-
-
- /**************************************************************************
- *
- * @enum:
- * TT_MAC_ID_XXX
- *
- * @description:
- * A list of valid values for the `encoding_id` for
- * @TT_PLATFORM_MACINTOSH charmaps and name entries.
- */
-
-#define TT_MAC_ID_ROMAN 0
-#define TT_MAC_ID_JAPANESE 1
-#define TT_MAC_ID_TRADITIONAL_CHINESE 2
-#define TT_MAC_ID_KOREAN 3
-#define TT_MAC_ID_ARABIC 4
-#define TT_MAC_ID_HEBREW 5
-#define TT_MAC_ID_GREEK 6
-#define TT_MAC_ID_RUSSIAN 7
-#define TT_MAC_ID_RSYMBOL 8
-#define TT_MAC_ID_DEVANAGARI 9
-#define TT_MAC_ID_GURMUKHI 10
-#define TT_MAC_ID_GUJARATI 11
-#define TT_MAC_ID_ORIYA 12
-#define TT_MAC_ID_BENGALI 13
-#define TT_MAC_ID_TAMIL 14
-#define TT_MAC_ID_TELUGU 15
-#define TT_MAC_ID_KANNADA 16
-#define TT_MAC_ID_MALAYALAM 17
-#define TT_MAC_ID_SINHALESE 18
-#define TT_MAC_ID_BURMESE 19
-#define TT_MAC_ID_KHMER 20
-#define TT_MAC_ID_THAI 21
-#define TT_MAC_ID_LAOTIAN 22
-#define TT_MAC_ID_GEORGIAN 23
-#define TT_MAC_ID_ARMENIAN 24
-#define TT_MAC_ID_MALDIVIAN 25
-#define TT_MAC_ID_SIMPLIFIED_CHINESE 25
-#define TT_MAC_ID_TIBETAN 26
-#define TT_MAC_ID_MONGOLIAN 27
-#define TT_MAC_ID_GEEZ 28
-#define TT_MAC_ID_SLAVIC 29
-#define TT_MAC_ID_VIETNAMESE 30
-#define TT_MAC_ID_SINDHI 31
-#define TT_MAC_ID_UNINTERP 32
-
-
- /**************************************************************************
- *
- * @enum:
- * TT_ISO_ID_XXX
- *
- * @description:
- * A list of valid values for the `encoding_id` for @TT_PLATFORM_ISO
- * charmaps and name entries.
- *
- * Their use is now deprecated.
- *
- * @values:
- * TT_ISO_ID_7BIT_ASCII ::
- * ASCII.
- * TT_ISO_ID_10646 ::
- * ISO/10646.
- * TT_ISO_ID_8859_1 ::
- * Also known as Latin-1.
- */
-
-#define TT_ISO_ID_7BIT_ASCII 0
-#define TT_ISO_ID_10646 1
-#define TT_ISO_ID_8859_1 2
-
-
- /**************************************************************************
- *
- * @enum:
- * TT_MS_ID_XXX
- *
- * @description:
- * A list of valid values for the `encoding_id` for
- * @TT_PLATFORM_MICROSOFT charmaps and name entries.
- *
- * @values:
- * TT_MS_ID_SYMBOL_CS ::
- * Microsoft symbol encoding. See @FT_ENCODING_MS_SYMBOL.
- *
- * TT_MS_ID_UNICODE_CS ::
- * Microsoft WGL4 charmap, matching Unicode. See @FT_ENCODING_UNICODE.
- *
- * TT_MS_ID_SJIS ::
- * Shift JIS Japanese encoding. See @FT_ENCODING_SJIS.
- *
- * TT_MS_ID_PRC ::
- * Chinese encodings as used in the People's Republic of China (PRC).
- * This means the encodings GB~2312 and its supersets GBK and GB~18030.
- * See @FT_ENCODING_PRC.
- *
- * TT_MS_ID_BIG_5 ::
- * Traditional Chinese as used in Taiwan and Hong Kong. See
- * @FT_ENCODING_BIG5.
- *
- * TT_MS_ID_WANSUNG ::
- * Korean Extended Wansung encoding. See @FT_ENCODING_WANSUNG.
- *
- * TT_MS_ID_JOHAB ::
- * Korean Johab encoding. See @FT_ENCODING_JOHAB.
- *
- * TT_MS_ID_UCS_4 ::
- * UCS-4 or UTF-32 charmaps. This has been added to the OpenType
- * specification version 1.4 (mid-2001).
- */
-
-#define TT_MS_ID_SYMBOL_CS 0
-#define TT_MS_ID_UNICODE_CS 1
-#define TT_MS_ID_SJIS 2
-#define TT_MS_ID_PRC 3
-#define TT_MS_ID_BIG_5 4
-#define TT_MS_ID_WANSUNG 5
-#define TT_MS_ID_JOHAB 6
-#define TT_MS_ID_UCS_4 10
-
- /* this value is deprecated */
-#define TT_MS_ID_GB2312 TT_MS_ID_PRC
-
-
- /**************************************************************************
- *
- * @enum:
- * TT_ADOBE_ID_XXX
- *
- * @description:
- * A list of valid values for the `encoding_id` for @TT_PLATFORM_ADOBE
- * charmaps. This is a FreeType-specific extension!
- *
- * @values:
- * TT_ADOBE_ID_STANDARD ::
- * Adobe standard encoding.
- * TT_ADOBE_ID_EXPERT ::
- * Adobe expert encoding.
- * TT_ADOBE_ID_CUSTOM ::
- * Adobe custom encoding.
- * TT_ADOBE_ID_LATIN_1 ::
- * Adobe Latin~1 encoding.
- */
-
-#define TT_ADOBE_ID_STANDARD 0
-#define TT_ADOBE_ID_EXPERT 1
-#define TT_ADOBE_ID_CUSTOM 2
-#define TT_ADOBE_ID_LATIN_1 3
-
-
- /**************************************************************************
- *
- * @enum:
- * TT_MAC_LANGID_XXX
- *
- * @description:
- * Possible values of the language identifier field in the name records
- * of the SFNT 'name' table if the 'platform' identifier code is
- * @TT_PLATFORM_MACINTOSH. These values are also used as return values
- * for function @FT_Get_CMap_Language_ID.
- *
- * The canonical source for Apple's IDs is
- *
- * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6name.html
- */
-
-#define TT_MAC_LANGID_ENGLISH 0
-#define TT_MAC_LANGID_FRENCH 1
-#define TT_MAC_LANGID_GERMAN 2
-#define TT_MAC_LANGID_ITALIAN 3
-#define TT_MAC_LANGID_DUTCH 4
-#define TT_MAC_LANGID_SWEDISH 5
-#define TT_MAC_LANGID_SPANISH 6
-#define TT_MAC_LANGID_DANISH 7
-#define TT_MAC_LANGID_PORTUGUESE 8
-#define TT_MAC_LANGID_NORWEGIAN 9
-#define TT_MAC_LANGID_HEBREW 10
-#define TT_MAC_LANGID_JAPANESE 11
-#define TT_MAC_LANGID_ARABIC 12
-#define TT_MAC_LANGID_FINNISH 13
-#define TT_MAC_LANGID_GREEK 14
-#define TT_MAC_LANGID_ICELANDIC 15
-#define TT_MAC_LANGID_MALTESE 16
-#define TT_MAC_LANGID_TURKISH 17
-#define TT_MAC_LANGID_CROATIAN 18
-#define TT_MAC_LANGID_CHINESE_TRADITIONAL 19
-#define TT_MAC_LANGID_URDU 20
-#define TT_MAC_LANGID_HINDI 21
-#define TT_MAC_LANGID_THAI 22
-#define TT_MAC_LANGID_KOREAN 23
-#define TT_MAC_LANGID_LITHUANIAN 24
-#define TT_MAC_LANGID_POLISH 25
-#define TT_MAC_LANGID_HUNGARIAN 26
-#define TT_MAC_LANGID_ESTONIAN 27
-#define TT_MAC_LANGID_LETTISH 28
-#define TT_MAC_LANGID_SAAMISK 29
-#define TT_MAC_LANGID_FAEROESE 30
-#define TT_MAC_LANGID_FARSI 31
-#define TT_MAC_LANGID_RUSSIAN 32
-#define TT_MAC_LANGID_CHINESE_SIMPLIFIED 33
-#define TT_MAC_LANGID_FLEMISH 34
-#define TT_MAC_LANGID_IRISH 35
-#define TT_MAC_LANGID_ALBANIAN 36
-#define TT_MAC_LANGID_ROMANIAN 37
-#define TT_MAC_LANGID_CZECH 38
-#define TT_MAC_LANGID_SLOVAK 39
-#define TT_MAC_LANGID_SLOVENIAN 40
-#define TT_MAC_LANGID_YIDDISH 41
-#define TT_MAC_LANGID_SERBIAN 42
-#define TT_MAC_LANGID_MACEDONIAN 43
-#define TT_MAC_LANGID_BULGARIAN 44
-#define TT_MAC_LANGID_UKRAINIAN 45
-#define TT_MAC_LANGID_BYELORUSSIAN 46
-#define TT_MAC_LANGID_UZBEK 47
-#define TT_MAC_LANGID_KAZAKH 48
-#define TT_MAC_LANGID_AZERBAIJANI 49
-#define TT_MAC_LANGID_AZERBAIJANI_CYRILLIC_SCRIPT 49
-#define TT_MAC_LANGID_AZERBAIJANI_ARABIC_SCRIPT 50
-#define TT_MAC_LANGID_ARMENIAN 51
-#define TT_MAC_LANGID_GEORGIAN 52
-#define TT_MAC_LANGID_MOLDAVIAN 53
-#define TT_MAC_LANGID_KIRGHIZ 54
-#define TT_MAC_LANGID_TAJIKI 55
-#define TT_MAC_LANGID_TURKMEN 56
-#define TT_MAC_LANGID_MONGOLIAN 57
-#define TT_MAC_LANGID_MONGOLIAN_MONGOLIAN_SCRIPT 57
-#define TT_MAC_LANGID_MONGOLIAN_CYRILLIC_SCRIPT 58
-#define TT_MAC_LANGID_PASHTO 59
-#define TT_MAC_LANGID_KURDISH 60
-#define TT_MAC_LANGID_KASHMIRI 61
-#define TT_MAC_LANGID_SINDHI 62
-#define TT_MAC_LANGID_TIBETAN 63
-#define TT_MAC_LANGID_NEPALI 64
-#define TT_MAC_LANGID_SANSKRIT 65
-#define TT_MAC_LANGID_MARATHI 66
-#define TT_MAC_LANGID_BENGALI 67
-#define TT_MAC_LANGID_ASSAMESE 68
-#define TT_MAC_LANGID_GUJARATI 69
-#define TT_MAC_LANGID_PUNJABI 70
-#define TT_MAC_LANGID_ORIYA 71
-#define TT_MAC_LANGID_MALAYALAM 72
-#define TT_MAC_LANGID_KANNADA 73
-#define TT_MAC_LANGID_TAMIL 74
-#define TT_MAC_LANGID_TELUGU 75
-#define TT_MAC_LANGID_SINHALESE 76
-#define TT_MAC_LANGID_BURMESE 77
-#define TT_MAC_LANGID_KHMER 78
-#define TT_MAC_LANGID_LAO 79
-#define TT_MAC_LANGID_VIETNAMESE 80
-#define TT_MAC_LANGID_INDONESIAN 81
-#define TT_MAC_LANGID_TAGALOG 82
-#define TT_MAC_LANGID_MALAY_ROMAN_SCRIPT 83
-#define TT_MAC_LANGID_MALAY_ARABIC_SCRIPT 84
-#define TT_MAC_LANGID_AMHARIC 85
-#define TT_MAC_LANGID_TIGRINYA 86
-#define TT_MAC_LANGID_GALLA 87
-#define TT_MAC_LANGID_SOMALI 88
-#define TT_MAC_LANGID_SWAHILI 89
-#define TT_MAC_LANGID_RUANDA 90
-#define TT_MAC_LANGID_RUNDI 91
-#define TT_MAC_LANGID_CHEWA 92
-#define TT_MAC_LANGID_MALAGASY 93
-#define TT_MAC_LANGID_ESPERANTO 94
-#define TT_MAC_LANGID_WELSH 128
-#define TT_MAC_LANGID_BASQUE 129
-#define TT_MAC_LANGID_CATALAN 130
-#define TT_MAC_LANGID_LATIN 131
-#define TT_MAC_LANGID_QUECHUA 132
-#define TT_MAC_LANGID_GUARANI 133
-#define TT_MAC_LANGID_AYMARA 134
-#define TT_MAC_LANGID_TATAR 135
-#define TT_MAC_LANGID_UIGHUR 136
-#define TT_MAC_LANGID_DZONGKHA 137
-#define TT_MAC_LANGID_JAVANESE 138
-#define TT_MAC_LANGID_SUNDANESE 139
-
- /* The following codes are new as of 2000-03-10 */
-#define TT_MAC_LANGID_GALICIAN 140
-#define TT_MAC_LANGID_AFRIKAANS 141
-#define TT_MAC_LANGID_BRETON 142
-#define TT_MAC_LANGID_INUKTITUT 143
-#define TT_MAC_LANGID_SCOTTISH_GAELIC 144
-#define TT_MAC_LANGID_MANX_GAELIC 145
-#define TT_MAC_LANGID_IRISH_GAELIC 146
-#define TT_MAC_LANGID_TONGAN 147
-#define TT_MAC_LANGID_GREEK_POLYTONIC 148
-#define TT_MAC_LANGID_GREELANDIC 149
-#define TT_MAC_LANGID_AZERBAIJANI_ROMAN_SCRIPT 150
-
-
- /**************************************************************************
- *
- * @enum:
- * TT_MS_LANGID_XXX
- *
- * @description:
- * Possible values of the language identifier field in the name records
- * of the SFNT 'name' table if the 'platform' identifier code is
- * @TT_PLATFORM_MICROSOFT. These values are also used as return values
- * for function @FT_Get_CMap_Language_ID.
- *
- * The canonical source for Microsoft's IDs is
- *
- * https://docs.microsoft.com/en-us/windows/desktop/Intl/language-identifier-constants-and-strings ,
- *
- * however, we only provide macros for language identifiers present in
- * the OpenType specification: Microsoft has abandoned the concept of
- * LCIDs (language code identifiers), and format~1 of the 'name' table
- * provides a better mechanism for languages not covered here.
- *
- * More legacy values not listed in the reference can be found in the
- * @FT_TRUETYPE_IDS_H header file.
- */
-
-#define TT_MS_LANGID_ARABIC_SAUDI_ARABIA 0x0401
-#define TT_MS_LANGID_ARABIC_IRAQ 0x0801
-#define TT_MS_LANGID_ARABIC_EGYPT 0x0C01
-#define TT_MS_LANGID_ARABIC_LIBYA 0x1001
-#define TT_MS_LANGID_ARABIC_ALGERIA 0x1401
-#define TT_MS_LANGID_ARABIC_MOROCCO 0x1801
-#define TT_MS_LANGID_ARABIC_TUNISIA 0x1C01
-#define TT_MS_LANGID_ARABIC_OMAN 0x2001
-#define TT_MS_LANGID_ARABIC_YEMEN 0x2401
-#define TT_MS_LANGID_ARABIC_SYRIA 0x2801
-#define TT_MS_LANGID_ARABIC_JORDAN 0x2C01
-#define TT_MS_LANGID_ARABIC_LEBANON 0x3001
-#define TT_MS_LANGID_ARABIC_KUWAIT 0x3401
-#define TT_MS_LANGID_ARABIC_UAE 0x3801
-#define TT_MS_LANGID_ARABIC_BAHRAIN 0x3C01
-#define TT_MS_LANGID_ARABIC_QATAR 0x4001
-#define TT_MS_LANGID_BULGARIAN_BULGARIA 0x0402
-#define TT_MS_LANGID_CATALAN_CATALAN 0x0403
-#define TT_MS_LANGID_CHINESE_TAIWAN 0x0404
-#define TT_MS_LANGID_CHINESE_PRC 0x0804
-#define TT_MS_LANGID_CHINESE_HONG_KONG 0x0C04
-#define TT_MS_LANGID_CHINESE_SINGAPORE 0x1004
-#define TT_MS_LANGID_CHINESE_MACAO 0x1404
-#define TT_MS_LANGID_CZECH_CZECH_REPUBLIC 0x0405
-#define TT_MS_LANGID_DANISH_DENMARK 0x0406
-#define TT_MS_LANGID_GERMAN_GERMANY 0x0407
-#define TT_MS_LANGID_GERMAN_SWITZERLAND 0x0807
-#define TT_MS_LANGID_GERMAN_AUSTRIA 0x0C07
-#define TT_MS_LANGID_GERMAN_LUXEMBOURG 0x1007
-#define TT_MS_LANGID_GERMAN_LIECHTENSTEIN 0x1407
-#define TT_MS_LANGID_GREEK_GREECE 0x0408
-#define TT_MS_LANGID_ENGLISH_UNITED_STATES 0x0409
-#define TT_MS_LANGID_ENGLISH_UNITED_KINGDOM 0x0809
-#define TT_MS_LANGID_ENGLISH_AUSTRALIA 0x0C09
-#define TT_MS_LANGID_ENGLISH_CANADA 0x1009
-#define TT_MS_LANGID_ENGLISH_NEW_ZEALAND 0x1409
-#define TT_MS_LANGID_ENGLISH_IRELAND 0x1809
-#define TT_MS_LANGID_ENGLISH_SOUTH_AFRICA 0x1C09
-#define TT_MS_LANGID_ENGLISH_JAMAICA 0x2009
-#define TT_MS_LANGID_ENGLISH_CARIBBEAN 0x2409
-#define TT_MS_LANGID_ENGLISH_BELIZE 0x2809
-#define TT_MS_LANGID_ENGLISH_TRINIDAD 0x2C09
-#define TT_MS_LANGID_ENGLISH_ZIMBABWE 0x3009
-#define TT_MS_LANGID_ENGLISH_PHILIPPINES 0x3409
-#define TT_MS_LANGID_ENGLISH_INDIA 0x4009
-#define TT_MS_LANGID_ENGLISH_MALAYSIA 0x4409
-#define TT_MS_LANGID_ENGLISH_SINGAPORE 0x4809
-#define TT_MS_LANGID_SPANISH_SPAIN_TRADITIONAL_SORT 0x040A
-#define TT_MS_LANGID_SPANISH_MEXICO 0x080A
-#define TT_MS_LANGID_SPANISH_SPAIN_MODERN_SORT 0x0C0A
-#define TT_MS_LANGID_SPANISH_GUATEMALA 0x100A
-#define TT_MS_LANGID_SPANISH_COSTA_RICA 0x140A
-#define TT_MS_LANGID_SPANISH_PANAMA 0x180A
-#define TT_MS_LANGID_SPANISH_DOMINICAN_REPUBLIC 0x1C0A
-#define TT_MS_LANGID_SPANISH_VENEZUELA 0x200A
-#define TT_MS_LANGID_SPANISH_COLOMBIA 0x240A
-#define TT_MS_LANGID_SPANISH_PERU 0x280A
-#define TT_MS_LANGID_SPANISH_ARGENTINA 0x2C0A
-#define TT_MS_LANGID_SPANISH_ECUADOR 0x300A
-#define TT_MS_LANGID_SPANISH_CHILE 0x340A
-#define TT_MS_LANGID_SPANISH_URUGUAY 0x380A
-#define TT_MS_LANGID_SPANISH_PARAGUAY 0x3C0A
-#define TT_MS_LANGID_SPANISH_BOLIVIA 0x400A
-#define TT_MS_LANGID_SPANISH_EL_SALVADOR 0x440A
-#define TT_MS_LANGID_SPANISH_HONDURAS 0x480A
-#define TT_MS_LANGID_SPANISH_NICARAGUA 0x4C0A
-#define TT_MS_LANGID_SPANISH_PUERTO_RICO 0x500A
-#define TT_MS_LANGID_SPANISH_UNITED_STATES 0x540A
-#define TT_MS_LANGID_FINNISH_FINLAND 0x040B
-#define TT_MS_LANGID_FRENCH_FRANCE 0x040C
-#define TT_MS_LANGID_FRENCH_BELGIUM 0x080C
-#define TT_MS_LANGID_FRENCH_CANADA 0x0C0C
-#define TT_MS_LANGID_FRENCH_SWITZERLAND 0x100C
-#define TT_MS_LANGID_FRENCH_LUXEMBOURG 0x140C
-#define TT_MS_LANGID_FRENCH_MONACO 0x180C
-#define TT_MS_LANGID_HEBREW_ISRAEL 0x040D
-#define TT_MS_LANGID_HUNGARIAN_HUNGARY 0x040E
-#define TT_MS_LANGID_ICELANDIC_ICELAND 0x040F
-#define TT_MS_LANGID_ITALIAN_ITALY 0x0410
-#define TT_MS_LANGID_ITALIAN_SWITZERLAND 0x0810
-#define TT_MS_LANGID_JAPANESE_JAPAN 0x0411
-#define TT_MS_LANGID_KOREAN_KOREA 0x0412
-#define TT_MS_LANGID_DUTCH_NETHERLANDS 0x0413
-#define TT_MS_LANGID_DUTCH_BELGIUM 0x0813
-#define TT_MS_LANGID_NORWEGIAN_NORWAY_BOKMAL 0x0414
-#define TT_MS_LANGID_NORWEGIAN_NORWAY_NYNORSK 0x0814
-#define TT_MS_LANGID_POLISH_POLAND 0x0415
-#define TT_MS_LANGID_PORTUGUESE_BRAZIL 0x0416
-#define TT_MS_LANGID_PORTUGUESE_PORTUGAL 0x0816
-#define TT_MS_LANGID_ROMANSH_SWITZERLAND 0x0417
-#define TT_MS_LANGID_ROMANIAN_ROMANIA 0x0418
-#define TT_MS_LANGID_RUSSIAN_RUSSIA 0x0419
-#define TT_MS_LANGID_CROATIAN_CROATIA 0x041A
-#define TT_MS_LANGID_SERBIAN_SERBIA_LATIN 0x081A
-#define TT_MS_LANGID_SERBIAN_SERBIA_CYRILLIC 0x0C1A
-#define TT_MS_LANGID_CROATIAN_BOSNIA_HERZEGOVINA 0x101A
-#define TT_MS_LANGID_BOSNIAN_BOSNIA_HERZEGOVINA 0x141A
-#define TT_MS_LANGID_SERBIAN_BOSNIA_HERZ_LATIN 0x181A
-#define TT_MS_LANGID_SERBIAN_BOSNIA_HERZ_CYRILLIC 0x1C1A
-#define TT_MS_LANGID_BOSNIAN_BOSNIA_HERZ_CYRILLIC 0x201A
-#define TT_MS_LANGID_SLOVAK_SLOVAKIA 0x041B
-#define TT_MS_LANGID_ALBANIAN_ALBANIA 0x041C
-#define TT_MS_LANGID_SWEDISH_SWEDEN 0x041D
-#define TT_MS_LANGID_SWEDISH_FINLAND 0x081D
-#define TT_MS_LANGID_THAI_THAILAND 0x041E
-#define TT_MS_LANGID_TURKISH_TURKEY 0x041F
-#define TT_MS_LANGID_URDU_PAKISTAN 0x0420
-#define TT_MS_LANGID_INDONESIAN_INDONESIA 0x0421
-#define TT_MS_LANGID_UKRAINIAN_UKRAINE 0x0422
-#define TT_MS_LANGID_BELARUSIAN_BELARUS 0x0423
-#define TT_MS_LANGID_SLOVENIAN_SLOVENIA 0x0424
-#define TT_MS_LANGID_ESTONIAN_ESTONIA 0x0425
-#define TT_MS_LANGID_LATVIAN_LATVIA 0x0426
-#define TT_MS_LANGID_LITHUANIAN_LITHUANIA 0x0427
-#define TT_MS_LANGID_TAJIK_TAJIKISTAN 0x0428
-#define TT_MS_LANGID_VIETNAMESE_VIET_NAM 0x042A
-#define TT_MS_LANGID_ARMENIAN_ARMENIA 0x042B
-#define TT_MS_LANGID_AZERI_AZERBAIJAN_LATIN 0x042C
-#define TT_MS_LANGID_AZERI_AZERBAIJAN_CYRILLIC 0x082C
-#define TT_MS_LANGID_BASQUE_BASQUE 0x042D
-#define TT_MS_LANGID_UPPER_SORBIAN_GERMANY 0x042E
-#define TT_MS_LANGID_LOWER_SORBIAN_GERMANY 0x082E
-#define TT_MS_LANGID_MACEDONIAN_MACEDONIA 0x042F
-#define TT_MS_LANGID_SETSWANA_SOUTH_AFRICA 0x0432
-#define TT_MS_LANGID_ISIXHOSA_SOUTH_AFRICA 0x0434
-#define TT_MS_LANGID_ISIZULU_SOUTH_AFRICA 0x0435
-#define TT_MS_LANGID_AFRIKAANS_SOUTH_AFRICA 0x0436
-#define TT_MS_LANGID_GEORGIAN_GEORGIA 0x0437
-#define TT_MS_LANGID_FAEROESE_FAEROE_ISLANDS 0x0438
-#define TT_MS_LANGID_HINDI_INDIA 0x0439
-#define TT_MS_LANGID_MALTESE_MALTA 0x043A
-#define TT_MS_LANGID_SAMI_NORTHERN_NORWAY 0x043B
-#define TT_MS_LANGID_SAMI_NORTHERN_SWEDEN 0x083B
-#define TT_MS_LANGID_SAMI_NORTHERN_FINLAND 0x0C3B
-#define TT_MS_LANGID_SAMI_LULE_NORWAY 0x103B
-#define TT_MS_LANGID_SAMI_LULE_SWEDEN 0x143B
-#define TT_MS_LANGID_SAMI_SOUTHERN_NORWAY 0x183B
-#define TT_MS_LANGID_SAMI_SOUTHERN_SWEDEN 0x1C3B
-#define TT_MS_LANGID_SAMI_SKOLT_FINLAND 0x203B
-#define TT_MS_LANGID_SAMI_INARI_FINLAND 0x243B
-#define TT_MS_LANGID_IRISH_IRELAND 0x083C
-#define TT_MS_LANGID_MALAY_MALAYSIA 0x043E
-#define TT_MS_LANGID_MALAY_BRUNEI_DARUSSALAM 0x083E
-#define TT_MS_LANGID_KAZAKH_KAZAKHSTAN 0x043F
-#define TT_MS_LANGID_KYRGYZ_KYRGYZSTAN /* Cyrillic */ 0x0440
-#define TT_MS_LANGID_KISWAHILI_KENYA 0x0441
-#define TT_MS_LANGID_TURKMEN_TURKMENISTAN 0x0442
-#define TT_MS_LANGID_UZBEK_UZBEKISTAN_LATIN 0x0443
-#define TT_MS_LANGID_UZBEK_UZBEKISTAN_CYRILLIC 0x0843
-#define TT_MS_LANGID_TATAR_RUSSIA 0x0444
-#define TT_MS_LANGID_BENGALI_INDIA 0x0445
-#define TT_MS_LANGID_BENGALI_BANGLADESH 0x0845
-#define TT_MS_LANGID_PUNJABI_INDIA 0x0446
-#define TT_MS_LANGID_GUJARATI_INDIA 0x0447
-#define TT_MS_LANGID_ODIA_INDIA 0x0448
-#define TT_MS_LANGID_TAMIL_INDIA 0x0449
-#define TT_MS_LANGID_TELUGU_INDIA 0x044A
-#define TT_MS_LANGID_KANNADA_INDIA 0x044B
-#define TT_MS_LANGID_MALAYALAM_INDIA 0x044C
-#define TT_MS_LANGID_ASSAMESE_INDIA 0x044D
-#define TT_MS_LANGID_MARATHI_INDIA 0x044E
-#define TT_MS_LANGID_SANSKRIT_INDIA 0x044F
-#define TT_MS_LANGID_MONGOLIAN_MONGOLIA /* Cyrillic */ 0x0450
-#define TT_MS_LANGID_MONGOLIAN_PRC 0x0850
-#define TT_MS_LANGID_TIBETAN_PRC 0x0451
-#define TT_MS_LANGID_WELSH_UNITED_KINGDOM 0x0452
-#define TT_MS_LANGID_KHMER_CAMBODIA 0x0453
-#define TT_MS_LANGID_LAO_LAOS 0x0454
-#define TT_MS_LANGID_GALICIAN_GALICIAN 0x0456
-#define TT_MS_LANGID_KONKANI_INDIA 0x0457
-#define TT_MS_LANGID_SYRIAC_SYRIA 0x045A
-#define TT_MS_LANGID_SINHALA_SRI_LANKA 0x045B
-#define TT_MS_LANGID_INUKTITUT_CANADA 0x045D
-#define TT_MS_LANGID_INUKTITUT_CANADA_LATIN 0x085D
-#define TT_MS_LANGID_AMHARIC_ETHIOPIA 0x045E
-#define TT_MS_LANGID_TAMAZIGHT_ALGERIA 0x085F
-#define TT_MS_LANGID_NEPALI_NEPAL 0x0461
-#define TT_MS_LANGID_FRISIAN_NETHERLANDS 0x0462
-#define TT_MS_LANGID_PASHTO_AFGHANISTAN 0x0463
-#define TT_MS_LANGID_FILIPINO_PHILIPPINES 0x0464
-#define TT_MS_LANGID_DHIVEHI_MALDIVES 0x0465
-#define TT_MS_LANGID_HAUSA_NIGERIA 0x0468
-#define TT_MS_LANGID_YORUBA_NIGERIA 0x046A
-#define TT_MS_LANGID_QUECHUA_BOLIVIA 0x046B
-#define TT_MS_LANGID_QUECHUA_ECUADOR 0x086B
-#define TT_MS_LANGID_QUECHUA_PERU 0x0C6B
-#define TT_MS_LANGID_SESOTHO_SA_LEBOA_SOUTH_AFRICA 0x046C
-#define TT_MS_LANGID_BASHKIR_RUSSIA 0x046D
-#define TT_MS_LANGID_LUXEMBOURGISH_LUXEMBOURG 0x046E
-#define TT_MS_LANGID_GREENLANDIC_GREENLAND 0x046F
-#define TT_MS_LANGID_IGBO_NIGERIA 0x0470
-#define TT_MS_LANGID_YI_PRC 0x0478
-#define TT_MS_LANGID_MAPUDUNGUN_CHILE 0x047A
-#define TT_MS_LANGID_MOHAWK_MOHAWK 0x047C
-#define TT_MS_LANGID_BRETON_FRANCE 0x047E
-#define TT_MS_LANGID_UIGHUR_PRC 0x0480
-#define TT_MS_LANGID_MAORI_NEW_ZEALAND 0x0481
-#define TT_MS_LANGID_OCCITAN_FRANCE 0x0482
-#define TT_MS_LANGID_CORSICAN_FRANCE 0x0483
-#define TT_MS_LANGID_ALSATIAN_FRANCE 0x0484
-#define TT_MS_LANGID_YAKUT_RUSSIA 0x0485
-#define TT_MS_LANGID_KICHE_GUATEMALA 0x0486
-#define TT_MS_LANGID_KINYARWANDA_RWANDA 0x0487
-#define TT_MS_LANGID_WOLOF_SENEGAL 0x0488
-#define TT_MS_LANGID_DARI_AFGHANISTAN 0x048C
-
- /* */
-
-
- /* legacy macro definitions not present in OpenType 1.8.1 */
-#define TT_MS_LANGID_ARABIC_GENERAL 0x0001
-#define TT_MS_LANGID_CATALAN_SPAIN \
- TT_MS_LANGID_CATALAN_CATALAN
-#define TT_MS_LANGID_CHINESE_GENERAL 0x0004
-#define TT_MS_LANGID_CHINESE_MACAU \
- TT_MS_LANGID_CHINESE_MACAO
-#define TT_MS_LANGID_GERMAN_LIECHTENSTEI \
- TT_MS_LANGID_GERMAN_LIECHTENSTEIN
-#define TT_MS_LANGID_ENGLISH_GENERAL 0x0009
-#define TT_MS_LANGID_ENGLISH_INDONESIA 0x3809
-#define TT_MS_LANGID_ENGLISH_HONG_KONG 0x3C09
-#define TT_MS_LANGID_SPANISH_SPAIN_INTERNATIONAL_SORT \
- TT_MS_LANGID_SPANISH_SPAIN_MODERN_SORT
-#define TT_MS_LANGID_SPANISH_LATIN_AMERICA 0xE40AU
-#define TT_MS_LANGID_FRENCH_WEST_INDIES 0x1C0C
-#define TT_MS_LANGID_FRENCH_REUNION 0x200C
-#define TT_MS_LANGID_FRENCH_CONGO 0x240C
- /* which was formerly: */
-#define TT_MS_LANGID_FRENCH_ZAIRE \
- TT_MS_LANGID_FRENCH_CONGO
-#define TT_MS_LANGID_FRENCH_SENEGAL 0x280C
-#define TT_MS_LANGID_FRENCH_CAMEROON 0x2C0C
-#define TT_MS_LANGID_FRENCH_COTE_D_IVOIRE 0x300C
-#define TT_MS_LANGID_FRENCH_MALI 0x340C
-#define TT_MS_LANGID_FRENCH_MOROCCO 0x380C
-#define TT_MS_LANGID_FRENCH_HAITI 0x3C0C
-#define TT_MS_LANGID_FRENCH_NORTH_AFRICA 0xE40CU
-#define TT_MS_LANGID_KOREAN_EXTENDED_WANSUNG_KOREA \
- TT_MS_LANGID_KOREAN_KOREA
-#define TT_MS_LANGID_KOREAN_JOHAB_KOREA 0x0812
-#define TT_MS_LANGID_RHAETO_ROMANIC_SWITZERLAND \
- TT_MS_LANGID_ROMANSH_SWITZERLAND
-#define TT_MS_LANGID_MOLDAVIAN_MOLDAVIA 0x0818
-#define TT_MS_LANGID_RUSSIAN_MOLDAVIA 0x0819
-#define TT_MS_LANGID_URDU_INDIA 0x0820
-#define TT_MS_LANGID_CLASSIC_LITHUANIAN_LITHUANIA 0x0827
-#define TT_MS_LANGID_SLOVENE_SLOVENIA \
- TT_MS_LANGID_SLOVENIAN_SLOVENIA
-#define TT_MS_LANGID_FARSI_IRAN 0x0429
-#define TT_MS_LANGID_BASQUE_SPAIN \
- TT_MS_LANGID_BASQUE_BASQUE
-#define TT_MS_LANGID_SORBIAN_GERMANY \
- TT_MS_LANGID_UPPER_SORBIAN_GERMANY
-#define TT_MS_LANGID_SUTU_SOUTH_AFRICA 0x0430
-#define TT_MS_LANGID_TSONGA_SOUTH_AFRICA 0x0431
-#define TT_MS_LANGID_TSWANA_SOUTH_AFRICA \
- TT_MS_LANGID_SETSWANA_SOUTH_AFRICA
-#define TT_MS_LANGID_VENDA_SOUTH_AFRICA 0x0433
-#define TT_MS_LANGID_XHOSA_SOUTH_AFRICA \
- TT_MS_LANGID_ISIXHOSA_SOUTH_AFRICA
-#define TT_MS_LANGID_ZULU_SOUTH_AFRICA \
- TT_MS_LANGID_ISIZULU_SOUTH_AFRICA
-#define TT_MS_LANGID_SAAMI_LAPONIA 0x043B
- /* the next two values are incorrectly inverted */
-#define TT_MS_LANGID_IRISH_GAELIC_IRELAND 0x043C
-#define TT_MS_LANGID_SCOTTISH_GAELIC_UNITED_KINGDOM 0x083C
-#define TT_MS_LANGID_YIDDISH_GERMANY 0x043D
-#define TT_MS_LANGID_KAZAK_KAZAKSTAN \
- TT_MS_LANGID_KAZAKH_KAZAKHSTAN
-#define TT_MS_LANGID_KIRGHIZ_KIRGHIZ_REPUBLIC \
- TT_MS_LANGID_KYRGYZ_KYRGYZSTAN
-#define TT_MS_LANGID_KIRGHIZ_KIRGHIZSTAN \
- TT_MS_LANGID_KYRGYZ_KYRGYZSTAN
-#define TT_MS_LANGID_SWAHILI_KENYA \
- TT_MS_LANGID_KISWAHILI_KENYA
-#define TT_MS_LANGID_TATAR_TATARSTAN \
- TT_MS_LANGID_TATAR_RUSSIA
-#define TT_MS_LANGID_PUNJABI_ARABIC_PAKISTAN 0x0846
-#define TT_MS_LANGID_ORIYA_INDIA \
- TT_MS_LANGID_ODIA_INDIA
-#define TT_MS_LANGID_MONGOLIAN_MONGOLIA_MONGOLIAN \
- TT_MS_LANGID_MONGOLIAN_PRC
-#define TT_MS_LANGID_TIBETAN_CHINA \
- TT_MS_LANGID_TIBETAN_PRC
-#define TT_MS_LANGID_DZONGHKA_BHUTAN 0x0851
-#define TT_MS_LANGID_TIBETAN_BHUTAN \
- TT_MS_LANGID_DZONGHKA_BHUTAN
-#define TT_MS_LANGID_WELSH_WALES \
- TT_MS_LANGID_WELSH_UNITED_KINGDOM
-#define TT_MS_LANGID_BURMESE_MYANMAR 0x0455
-#define TT_MS_LANGID_GALICIAN_SPAIN \
- TT_MS_LANGID_GALICIAN_GALICIAN
-#define TT_MS_LANGID_MANIPURI_INDIA /* Bengali */ 0x0458
-#define TT_MS_LANGID_SINDHI_INDIA /* Arabic */ 0x0459
-#define TT_MS_LANGID_SINDHI_PAKISTAN 0x0859
-#define TT_MS_LANGID_SINHALESE_SRI_LANKA \
- TT_MS_LANGID_SINHALA_SRI_LANKA
-#define TT_MS_LANGID_CHEROKEE_UNITED_STATES 0x045C
-#define TT_MS_LANGID_TAMAZIGHT_MOROCCO /* Arabic */ 0x045F
-#define TT_MS_LANGID_TAMAZIGHT_MOROCCO_LATIN \
- TT_MS_LANGID_TAMAZIGHT_ALGERIA
-#define TT_MS_LANGID_KASHMIRI_PAKISTAN /* Arabic */ 0x0460
-#define TT_MS_LANGID_KASHMIRI_SASIA 0x0860
-#define TT_MS_LANGID_KASHMIRI_INDIA \
- TT_MS_LANGID_KASHMIRI_SASIA
-#define TT_MS_LANGID_NEPALI_INDIA 0x0861
-#define TT_MS_LANGID_DIVEHI_MALDIVES \
- TT_MS_LANGID_DHIVEHI_MALDIVES
-#define TT_MS_LANGID_EDO_NIGERIA 0x0466
-#define TT_MS_LANGID_FULFULDE_NIGERIA 0x0467
-#define TT_MS_LANGID_IBIBIO_NIGERIA 0x0469
-#define TT_MS_LANGID_SEPEDI_SOUTH_AFRICA \
- TT_MS_LANGID_SESOTHO_SA_LEBOA_SOUTH_AFRICA
-#define TT_MS_LANGID_SOTHO_SOUTHERN_SOUTH_AFRICA \
- TT_MS_LANGID_SESOTHO_SA_LEBOA_SOUTH_AFRICA
-#define TT_MS_LANGID_KANURI_NIGERIA 0x0471
-#define TT_MS_LANGID_OROMO_ETHIOPIA 0x0472
-#define TT_MS_LANGID_TIGRIGNA_ETHIOPIA 0x0473
-#define TT_MS_LANGID_TIGRIGNA_ERYTHREA 0x0873
-#define TT_MS_LANGID_TIGRIGNA_ERYTREA \
- TT_MS_LANGID_TIGRIGNA_ERYTHREA
-#define TT_MS_LANGID_GUARANI_PARAGUAY 0x0474
-#define TT_MS_LANGID_HAWAIIAN_UNITED_STATES 0x0475
-#define TT_MS_LANGID_LATIN 0x0476
-#define TT_MS_LANGID_SOMALI_SOMALIA 0x0477
-#define TT_MS_LANGID_YI_CHINA \
- TT_MS_LANGID_YI_PRC
-#define TT_MS_LANGID_PAPIAMENTU_NETHERLANDS_ANTILLES 0x0479
-#define TT_MS_LANGID_UIGHUR_CHINA \
- TT_MS_LANGID_UIGHUR_PRC
-
-
- /**************************************************************************
- *
- * @enum:
- * TT_NAME_ID_XXX
- *
- * @description:
- * Possible values of the 'name' identifier field in the name records of
- * an SFNT 'name' table. These values are platform independent.
- */
-
-#define TT_NAME_ID_COPYRIGHT 0
-#define TT_NAME_ID_FONT_FAMILY 1
-#define TT_NAME_ID_FONT_SUBFAMILY 2
-#define TT_NAME_ID_UNIQUE_ID 3
-#define TT_NAME_ID_FULL_NAME 4
-#define TT_NAME_ID_VERSION_STRING 5
-#define TT_NAME_ID_PS_NAME 6
-#define TT_NAME_ID_TRADEMARK 7
-
- /* the following values are from the OpenType spec */
-#define TT_NAME_ID_MANUFACTURER 8
-#define TT_NAME_ID_DESIGNER 9
-#define TT_NAME_ID_DESCRIPTION 10
-#define TT_NAME_ID_VENDOR_URL 11
-#define TT_NAME_ID_DESIGNER_URL 12
-#define TT_NAME_ID_LICENSE 13
-#define TT_NAME_ID_LICENSE_URL 14
- /* number 15 is reserved */
-#define TT_NAME_ID_TYPOGRAPHIC_FAMILY 16
-#define TT_NAME_ID_TYPOGRAPHIC_SUBFAMILY 17
-#define TT_NAME_ID_MAC_FULL_NAME 18
-
- /* The following code is new as of 2000-01-21 */
-#define TT_NAME_ID_SAMPLE_TEXT 19
-
- /* This is new in OpenType 1.3 */
-#define TT_NAME_ID_CID_FINDFONT_NAME 20
-
- /* This is new in OpenType 1.5 */
-#define TT_NAME_ID_WWS_FAMILY 21
-#define TT_NAME_ID_WWS_SUBFAMILY 22
-
- /* This is new in OpenType 1.7 */
-#define TT_NAME_ID_LIGHT_BACKGROUND 23
-#define TT_NAME_ID_DARK_BACKGROUND 24
-
- /* This is new in OpenType 1.8 */
-#define TT_NAME_ID_VARIATIONS_PREFIX 25
-
- /* these two values are deprecated */
-#define TT_NAME_ID_PREFERRED_FAMILY TT_NAME_ID_TYPOGRAPHIC_FAMILY
-#define TT_NAME_ID_PREFERRED_SUBFAMILY TT_NAME_ID_TYPOGRAPHIC_SUBFAMILY
-
-
- /**************************************************************************
- *
- * @enum:
- * TT_UCR_XXX
- *
- * @description:
- * Possible bit mask values for the `ulUnicodeRangeX` fields in an SFNT
- * 'OS/2' table.
- */
-
- /* ulUnicodeRange1 */
- /* --------------- */
-
- /* Bit 0 Basic Latin */
-#define TT_UCR_BASIC_LATIN (1L << 0) /* U+0020-U+007E */
- /* Bit 1 C1 Controls and Latin-1 Supplement */
-#define TT_UCR_LATIN1_SUPPLEMENT (1L << 1) /* U+0080-U+00FF */
- /* Bit 2 Latin Extended-A */
-#define TT_UCR_LATIN_EXTENDED_A (1L << 2) /* U+0100-U+017F */
- /* Bit 3 Latin Extended-B */
-#define TT_UCR_LATIN_EXTENDED_B (1L << 3) /* U+0180-U+024F */
- /* Bit 4 IPA Extensions */
- /* Phonetic Extensions */
- /* Phonetic Extensions Supplement */
-#define TT_UCR_IPA_EXTENSIONS (1L << 4) /* U+0250-U+02AF */
- /* U+1D00-U+1D7F */
- /* U+1D80-U+1DBF */
- /* Bit 5 Spacing Modifier Letters */
- /* Modifier Tone Letters */
-#define TT_UCR_SPACING_MODIFIER (1L << 5) /* U+02B0-U+02FF */
- /* U+A700-U+A71F */
- /* Bit 6 Combining Diacritical Marks */
- /* Combining Diacritical Marks Supplement */
-#define TT_UCR_COMBINING_DIACRITICAL_MARKS (1L << 6) /* U+0300-U+036F */
- /* U+1DC0-U+1DFF */
- /* Bit 7 Greek and Coptic */
-#define TT_UCR_GREEK (1L << 7) /* U+0370-U+03FF */
- /* Bit 8 Coptic */
-#define TT_UCR_COPTIC (1L << 8) /* U+2C80-U+2CFF */
- /* Bit 9 Cyrillic */
- /* Cyrillic Supplement */
- /* Cyrillic Extended-A */
- /* Cyrillic Extended-B */
-#define TT_UCR_CYRILLIC (1L << 9) /* U+0400-U+04FF */
- /* U+0500-U+052F */
- /* U+2DE0-U+2DFF */
- /* U+A640-U+A69F */
- /* Bit 10 Armenian */
-#define TT_UCR_ARMENIAN (1L << 10) /* U+0530-U+058F */
- /* Bit 11 Hebrew */
-#define TT_UCR_HEBREW (1L << 11) /* U+0590-U+05FF */
- /* Bit 12 Vai */
-#define TT_UCR_VAI (1L << 12) /* U+A500-U+A63F */
- /* Bit 13 Arabic */
- /* Arabic Supplement */
-#define TT_UCR_ARABIC (1L << 13) /* U+0600-U+06FF */
- /* U+0750-U+077F */
- /* Bit 14 NKo */
-#define TT_UCR_NKO (1L << 14) /* U+07C0-U+07FF */
- /* Bit 15 Devanagari */
-#define TT_UCR_DEVANAGARI (1L << 15) /* U+0900-U+097F */
- /* Bit 16 Bengali */
-#define TT_UCR_BENGALI (1L << 16) /* U+0980-U+09FF */
- /* Bit 17 Gurmukhi */
-#define TT_UCR_GURMUKHI (1L << 17) /* U+0A00-U+0A7F */
- /* Bit 18 Gujarati */
-#define TT_UCR_GUJARATI (1L << 18) /* U+0A80-U+0AFF */
- /* Bit 19 Oriya */
-#define TT_UCR_ORIYA (1L << 19) /* U+0B00-U+0B7F */
- /* Bit 20 Tamil */
-#define TT_UCR_TAMIL (1L << 20) /* U+0B80-U+0BFF */
- /* Bit 21 Telugu */
-#define TT_UCR_TELUGU (1L << 21) /* U+0C00-U+0C7F */
- /* Bit 22 Kannada */
-#define TT_UCR_KANNADA (1L << 22) /* U+0C80-U+0CFF */
- /* Bit 23 Malayalam */
-#define TT_UCR_MALAYALAM (1L << 23) /* U+0D00-U+0D7F */
- /* Bit 24 Thai */
-#define TT_UCR_THAI (1L << 24) /* U+0E00-U+0E7F */
- /* Bit 25 Lao */
-#define TT_UCR_LAO (1L << 25) /* U+0E80-U+0EFF */
- /* Bit 26 Georgian */
- /* Georgian Supplement */
-#define TT_UCR_GEORGIAN (1L << 26) /* U+10A0-U+10FF */
- /* U+2D00-U+2D2F */
- /* Bit 27 Balinese */
-#define TT_UCR_BALINESE (1L << 27) /* U+1B00-U+1B7F */
- /* Bit 28 Hangul Jamo */
-#define TT_UCR_HANGUL_JAMO (1L << 28) /* U+1100-U+11FF */
- /* Bit 29 Latin Extended Additional */
- /* Latin Extended-C */
- /* Latin Extended-D */
-#define TT_UCR_LATIN_EXTENDED_ADDITIONAL (1L << 29) /* U+1E00-U+1EFF */
- /* U+2C60-U+2C7F */
- /* U+A720-U+A7FF */
- /* Bit 30 Greek Extended */
-#define TT_UCR_GREEK_EXTENDED (1L << 30) /* U+1F00-U+1FFF */
- /* Bit 31 General Punctuation */
- /* Supplemental Punctuation */
-#define TT_UCR_GENERAL_PUNCTUATION (1L << 31) /* U+2000-U+206F */
- /* U+2E00-U+2E7F */
-
- /* ulUnicodeRange2 */
- /* --------------- */
-
- /* Bit 32 Superscripts And Subscripts */
-#define TT_UCR_SUPERSCRIPTS_SUBSCRIPTS (1L << 0) /* U+2070-U+209F */
- /* Bit 33 Currency Symbols */
-#define TT_UCR_CURRENCY_SYMBOLS (1L << 1) /* U+20A0-U+20CF */
- /* Bit 34 Combining Diacritical Marks For Symbols */
-#define TT_UCR_COMBINING_DIACRITICAL_MARKS_SYMB \
- (1L << 2) /* U+20D0-U+20FF */
- /* Bit 35 Letterlike Symbols */
-#define TT_UCR_LETTERLIKE_SYMBOLS (1L << 3) /* U+2100-U+214F */
- /* Bit 36 Number Forms */
-#define TT_UCR_NUMBER_FORMS (1L << 4) /* U+2150-U+218F */
- /* Bit 37 Arrows */
- /* Supplemental Arrows-A */
- /* Supplemental Arrows-B */
- /* Miscellaneous Symbols and Arrows */
-#define TT_UCR_ARROWS (1L << 5) /* U+2190-U+21FF */
- /* U+27F0-U+27FF */
- /* U+2900-U+297F */
- /* U+2B00-U+2BFF */
- /* Bit 38 Mathematical Operators */
- /* Supplemental Mathematical Operators */
- /* Miscellaneous Mathematical Symbols-A */
- /* Miscellaneous Mathematical Symbols-B */
-#define TT_UCR_MATHEMATICAL_OPERATORS (1L << 6) /* U+2200-U+22FF */
- /* U+2A00-U+2AFF */
- /* U+27C0-U+27EF */
- /* U+2980-U+29FF */
- /* Bit 39 Miscellaneous Technical */
-#define TT_UCR_MISCELLANEOUS_TECHNICAL (1L << 7) /* U+2300-U+23FF */
- /* Bit 40 Control Pictures */
-#define TT_UCR_CONTROL_PICTURES (1L << 8) /* U+2400-U+243F */
- /* Bit 41 Optical Character Recognition */
-#define TT_UCR_OCR (1L << 9) /* U+2440-U+245F */
- /* Bit 42 Enclosed Alphanumerics */
-#define TT_UCR_ENCLOSED_ALPHANUMERICS (1L << 10) /* U+2460-U+24FF */
- /* Bit 43 Box Drawing */
-#define TT_UCR_BOX_DRAWING (1L << 11) /* U+2500-U+257F */
- /* Bit 44 Block Elements */
-#define TT_UCR_BLOCK_ELEMENTS (1L << 12) /* U+2580-U+259F */
- /* Bit 45 Geometric Shapes */
-#define TT_UCR_GEOMETRIC_SHAPES (1L << 13) /* U+25A0-U+25FF */
- /* Bit 46 Miscellaneous Symbols */
-#define TT_UCR_MISCELLANEOUS_SYMBOLS (1L << 14) /* U+2600-U+26FF */
- /* Bit 47 Dingbats */
-#define TT_UCR_DINGBATS (1L << 15) /* U+2700-U+27BF */
- /* Bit 48 CJK Symbols and Punctuation */
-#define TT_UCR_CJK_SYMBOLS (1L << 16) /* U+3000-U+303F */
- /* Bit 49 Hiragana */
-#define TT_UCR_HIRAGANA (1L << 17) /* U+3040-U+309F */
- /* Bit 50 Katakana */
- /* Katakana Phonetic Extensions */
-#define TT_UCR_KATAKANA (1L << 18) /* U+30A0-U+30FF */
- /* U+31F0-U+31FF */
- /* Bit 51 Bopomofo */
- /* Bopomofo Extended */
-#define TT_UCR_BOPOMOFO (1L << 19) /* U+3100-U+312F */
- /* U+31A0-U+31BF */
- /* Bit 52 Hangul Compatibility Jamo */
-#define TT_UCR_HANGUL_COMPATIBILITY_JAMO (1L << 20) /* U+3130-U+318F */
- /* Bit 53 Phags-Pa */
-#define TT_UCR_CJK_MISC (1L << 21) /* U+A840-U+A87F */
-#define TT_UCR_KANBUN TT_UCR_CJK_MISC /* deprecated */
-#define TT_UCR_PHAGSPA
- /* Bit 54 Enclosed CJK Letters and Months */
-#define TT_UCR_ENCLOSED_CJK_LETTERS_MONTHS (1L << 22) /* U+3200-U+32FF */
- /* Bit 55 CJK Compatibility */
-#define TT_UCR_CJK_COMPATIBILITY (1L << 23) /* U+3300-U+33FF */
- /* Bit 56 Hangul Syllables */
-#define TT_UCR_HANGUL (1L << 24) /* U+AC00-U+D7A3 */
- /* Bit 57 High Surrogates */
- /* High Private Use Surrogates */
- /* Low Surrogates */
-
- /* According to OpenType specs v.1.3+, */
- /* setting bit 57 implies that there is */
- /* at least one codepoint beyond the */
- /* Basic Multilingual Plane that is */
- /* supported by this font. So it really */
- /* means >= U+10000. */
-#define TT_UCR_SURROGATES (1L << 25) /* U+D800-U+DB7F */
- /* U+DB80-U+DBFF */
- /* U+DC00-U+DFFF */
-#define TT_UCR_NON_PLANE_0 TT_UCR_SURROGATES
- /* Bit 58 Phoenician */
-#define TT_UCR_PHOENICIAN (1L << 26) /*U+10900-U+1091F*/
- /* Bit 59 CJK Unified Ideographs */
- /* CJK Radicals Supplement */
- /* Kangxi Radicals */
- /* Ideographic Description Characters */
- /* CJK Unified Ideographs Extension A */
- /* CJK Unified Ideographs Extension B */
- /* Kanbun */
-#define TT_UCR_CJK_UNIFIED_IDEOGRAPHS (1L << 27) /* U+4E00-U+9FFF */
- /* U+2E80-U+2EFF */
- /* U+2F00-U+2FDF */
- /* U+2FF0-U+2FFF */
- /* U+3400-U+4DB5 */
- /*U+20000-U+2A6DF*/
- /* U+3190-U+319F */
- /* Bit 60 Private Use */
-#define TT_UCR_PRIVATE_USE (1L << 28) /* U+E000-U+F8FF */
- /* Bit 61 CJK Strokes */
- /* CJK Compatibility Ideographs */
- /* CJK Compatibility Ideographs Supplement */
-#define TT_UCR_CJK_COMPATIBILITY_IDEOGRAPHS (1L << 29) /* U+31C0-U+31EF */
- /* U+F900-U+FAFF */
- /*U+2F800-U+2FA1F*/
- /* Bit 62 Alphabetic Presentation Forms */
-#define TT_UCR_ALPHABETIC_PRESENTATION_FORMS (1L << 30) /* U+FB00-U+FB4F */
- /* Bit 63 Arabic Presentation Forms-A */
-#define TT_UCR_ARABIC_PRESENTATION_FORMS_A (1L << 31) /* U+FB50-U+FDFF */
-
- /* ulUnicodeRange3 */
- /* --------------- */
-
- /* Bit 64 Combining Half Marks */
-#define TT_UCR_COMBINING_HALF_MARKS (1L << 0) /* U+FE20-U+FE2F */
- /* Bit 65 Vertical forms */
- /* CJK Compatibility Forms */
-#define TT_UCR_CJK_COMPATIBILITY_FORMS (1L << 1) /* U+FE10-U+FE1F */
- /* U+FE30-U+FE4F */
- /* Bit 66 Small Form Variants */
-#define TT_UCR_SMALL_FORM_VARIANTS (1L << 2) /* U+FE50-U+FE6F */
- /* Bit 67 Arabic Presentation Forms-B */
-#define TT_UCR_ARABIC_PRESENTATION_FORMS_B (1L << 3) /* U+FE70-U+FEFE */
- /* Bit 68 Halfwidth and Fullwidth Forms */
-#define TT_UCR_HALFWIDTH_FULLWIDTH_FORMS (1L << 4) /* U+FF00-U+FFEF */
- /* Bit 69 Specials */
-#define TT_UCR_SPECIALS (1L << 5) /* U+FFF0-U+FFFD */
- /* Bit 70 Tibetan */
-#define TT_UCR_TIBETAN (1L << 6) /* U+0F00-U+0FFF */
- /* Bit 71 Syriac */
-#define TT_UCR_SYRIAC (1L << 7) /* U+0700-U+074F */
- /* Bit 72 Thaana */
-#define TT_UCR_THAANA (1L << 8) /* U+0780-U+07BF */
- /* Bit 73 Sinhala */
-#define TT_UCR_SINHALA (1L << 9) /* U+0D80-U+0DFF */
- /* Bit 74 Myanmar */
-#define TT_UCR_MYANMAR (1L << 10) /* U+1000-U+109F */
- /* Bit 75 Ethiopic */
- /* Ethiopic Supplement */
- /* Ethiopic Extended */
-#define TT_UCR_ETHIOPIC (1L << 11) /* U+1200-U+137F */
- /* U+1380-U+139F */
- /* U+2D80-U+2DDF */
- /* Bit 76 Cherokee */
-#define TT_UCR_CHEROKEE (1L << 12) /* U+13A0-U+13FF */
- /* Bit 77 Unified Canadian Aboriginal Syllabics */
-#define TT_UCR_CANADIAN_ABORIGINAL_SYLLABICS (1L << 13) /* U+1400-U+167F */
- /* Bit 78 Ogham */
-#define TT_UCR_OGHAM (1L << 14) /* U+1680-U+169F */
- /* Bit 79 Runic */
-#define TT_UCR_RUNIC (1L << 15) /* U+16A0-U+16FF */
- /* Bit 80 Khmer */
- /* Khmer Symbols */
-#define TT_UCR_KHMER (1L << 16) /* U+1780-U+17FF */
- /* U+19E0-U+19FF */
- /* Bit 81 Mongolian */
-#define TT_UCR_MONGOLIAN (1L << 17) /* U+1800-U+18AF */
- /* Bit 82 Braille Patterns */
-#define TT_UCR_BRAILLE (1L << 18) /* U+2800-U+28FF */
- /* Bit 83 Yi Syllables */
- /* Yi Radicals */
-#define TT_UCR_YI (1L << 19) /* U+A000-U+A48F */
- /* U+A490-U+A4CF */
- /* Bit 84 Tagalog */
- /* Hanunoo */
- /* Buhid */
- /* Tagbanwa */
-#define TT_UCR_PHILIPPINE (1L << 20) /* U+1700-U+171F */
- /* U+1720-U+173F */
- /* U+1740-U+175F */
- /* U+1760-U+177F */
- /* Bit 85 Old Italic */
-#define TT_UCR_OLD_ITALIC (1L << 21) /*U+10300-U+1032F*/
- /* Bit 86 Gothic */
-#define TT_UCR_GOTHIC (1L << 22) /*U+10330-U+1034F*/
- /* Bit 87 Deseret */
-#define TT_UCR_DESERET (1L << 23) /*U+10400-U+1044F*/
- /* Bit 88 Byzantine Musical Symbols */
- /* Musical Symbols */
- /* Ancient Greek Musical Notation */
-#define TT_UCR_MUSICAL_SYMBOLS (1L << 24) /*U+1D000-U+1D0FF*/
- /*U+1D100-U+1D1FF*/
- /*U+1D200-U+1D24F*/
- /* Bit 89 Mathematical Alphanumeric Symbols */
-#define TT_UCR_MATH_ALPHANUMERIC_SYMBOLS (1L << 25) /*U+1D400-U+1D7FF*/
- /* Bit 90 Private Use (plane 15) */
- /* Private Use (plane 16) */
-#define TT_UCR_PRIVATE_USE_SUPPLEMENTARY (1L << 26) /*U+F0000-U+FFFFD*/
- /*U+100000-U+10FFFD*/
- /* Bit 91 Variation Selectors */
- /* Variation Selectors Supplement */
-#define TT_UCR_VARIATION_SELECTORS (1L << 27) /* U+FE00-U+FE0F */
- /*U+E0100-U+E01EF*/
- /* Bit 92 Tags */
-#define TT_UCR_TAGS (1L << 28) /*U+E0000-U+E007F*/
- /* Bit 93 Limbu */
-#define TT_UCR_LIMBU (1L << 29) /* U+1900-U+194F */
- /* Bit 94 Tai Le */
-#define TT_UCR_TAI_LE (1L << 30) /* U+1950-U+197F */
- /* Bit 95 New Tai Lue */
-#define TT_UCR_NEW_TAI_LUE (1L << 31) /* U+1980-U+19DF */
-
- /* ulUnicodeRange4 */
- /* --------------- */
-
- /* Bit 96 Buginese */
-#define TT_UCR_BUGINESE (1L << 0) /* U+1A00-U+1A1F */
- /* Bit 97 Glagolitic */
-#define TT_UCR_GLAGOLITIC (1L << 1) /* U+2C00-U+2C5F */
- /* Bit 98 Tifinagh */
-#define TT_UCR_TIFINAGH (1L << 2) /* U+2D30-U+2D7F */
- /* Bit 99 Yijing Hexagram Symbols */
-#define TT_UCR_YIJING (1L << 3) /* U+4DC0-U+4DFF */
- /* Bit 100 Syloti Nagri */
-#define TT_UCR_SYLOTI_NAGRI (1L << 4) /* U+A800-U+A82F */
- /* Bit 101 Linear B Syllabary */
- /* Linear B Ideograms */
- /* Aegean Numbers */
-#define TT_UCR_LINEAR_B (1L << 5) /*U+10000-U+1007F*/
- /*U+10080-U+100FF*/
- /*U+10100-U+1013F*/
- /* Bit 102 Ancient Greek Numbers */
-#define TT_UCR_ANCIENT_GREEK_NUMBERS (1L << 6) /*U+10140-U+1018F*/
- /* Bit 103 Ugaritic */
-#define TT_UCR_UGARITIC (1L << 7) /*U+10380-U+1039F*/
- /* Bit 104 Old Persian */
-#define TT_UCR_OLD_PERSIAN (1L << 8) /*U+103A0-U+103DF*/
- /* Bit 105 Shavian */
-#define TT_UCR_SHAVIAN (1L << 9) /*U+10450-U+1047F*/
- /* Bit 106 Osmanya */
-#define TT_UCR_OSMANYA (1L << 10) /*U+10480-U+104AF*/
- /* Bit 107 Cypriot Syllabary */
-#define TT_UCR_CYPRIOT_SYLLABARY (1L << 11) /*U+10800-U+1083F*/
- /* Bit 108 Kharoshthi */
-#define TT_UCR_KHAROSHTHI (1L << 12) /*U+10A00-U+10A5F*/
- /* Bit 109 Tai Xuan Jing Symbols */
-#define TT_UCR_TAI_XUAN_JING (1L << 13) /*U+1D300-U+1D35F*/
- /* Bit 110 Cuneiform */
- /* Cuneiform Numbers and Punctuation */
-#define TT_UCR_CUNEIFORM (1L << 14) /*U+12000-U+123FF*/
- /*U+12400-U+1247F*/
- /* Bit 111 Counting Rod Numerals */
-#define TT_UCR_COUNTING_ROD_NUMERALS (1L << 15) /*U+1D360-U+1D37F*/
- /* Bit 112 Sundanese */
-#define TT_UCR_SUNDANESE (1L << 16) /* U+1B80-U+1BBF */
- /* Bit 113 Lepcha */
-#define TT_UCR_LEPCHA (1L << 17) /* U+1C00-U+1C4F */
- /* Bit 114 Ol Chiki */
-#define TT_UCR_OL_CHIKI (1L << 18) /* U+1C50-U+1C7F */
- /* Bit 115 Saurashtra */
-#define TT_UCR_SAURASHTRA (1L << 19) /* U+A880-U+A8DF */
- /* Bit 116 Kayah Li */
-#define TT_UCR_KAYAH_LI (1L << 20) /* U+A900-U+A92F */
- /* Bit 117 Rejang */
-#define TT_UCR_REJANG (1L << 21) /* U+A930-U+A95F */
- /* Bit 118 Cham */
-#define TT_UCR_CHAM (1L << 22) /* U+AA00-U+AA5F */
- /* Bit 119 Ancient Symbols */
-#define TT_UCR_ANCIENT_SYMBOLS (1L << 23) /*U+10190-U+101CF*/
- /* Bit 120 Phaistos Disc */
-#define TT_UCR_PHAISTOS_DISC (1L << 24) /*U+101D0-U+101FF*/
- /* Bit 121 Carian */
- /* Lycian */
- /* Lydian */
-#define TT_UCR_OLD_ANATOLIAN (1L << 25) /*U+102A0-U+102DF*/
- /*U+10280-U+1029F*/
- /*U+10920-U+1093F*/
- /* Bit 122 Domino Tiles */
- /* Mahjong Tiles */
-#define TT_UCR_GAME_TILES (1L << 26) /*U+1F030-U+1F09F*/
- /*U+1F000-U+1F02F*/
- /* Bit 123-127 Reserved for process-internal usage */
-
- /* */
-
- /* for backward compatibility with older FreeType versions */
-#define TT_UCR_ARABIC_PRESENTATION_A \
- TT_UCR_ARABIC_PRESENTATION_FORMS_A
-#define TT_UCR_ARABIC_PRESENTATION_B \
- TT_UCR_ARABIC_PRESENTATION_FORMS_B
-
-#define TT_UCR_COMBINING_DIACRITICS \
- TT_UCR_COMBINING_DIACRITICAL_MARKS
-#define TT_UCR_COMBINING_DIACRITICS_SYMB \
- TT_UCR_COMBINING_DIACRITICAL_MARKS_SYMB
-
-
-FT_END_HEADER
-
-#endif /* TTNAMEID_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/tttables.h b/contrib/libs/freetype/include/freetype/tttables.h
deleted file mode 100644
index 2cf0ff1bc6..0000000000
--- a/contrib/libs/freetype/include/freetype/tttables.h
+++ /dev/null
@@ -1,856 +0,0 @@
-/****************************************************************************
- *
- * tttables.h
- *
- * Basic SFNT/TrueType tables definitions and interface
- * (specification only).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef TTTABLES_H_
-#define TTTABLES_H_
-
-
-#include <freetype/freetype.h>
-
-#ifdef FREETYPE_H
-#error "freetype.h of FreeType 1 has been loaded!"
-#error "Please fix the directory search order for header files"
-#error "so that freetype.h of FreeType 2 is found first."
-#endif
-
-
-FT_BEGIN_HEADER
-
- /**************************************************************************
- *
- * @section:
- * truetype_tables
- *
- * @title:
- * TrueType Tables
- *
- * @abstract:
- * TrueType-specific table types and functions.
- *
- * @description:
- * This section contains definitions of some basic tables specific to
- * TrueType and OpenType as well as some routines used to access and
- * process them.
- *
- * @order:
- * TT_Header
- * TT_HoriHeader
- * TT_VertHeader
- * TT_OS2
- * TT_Postscript
- * TT_PCLT
- * TT_MaxProfile
- *
- * FT_Sfnt_Tag
- * FT_Get_Sfnt_Table
- * FT_Load_Sfnt_Table
- * FT_Sfnt_Table_Info
- *
- * FT_Get_CMap_Language_ID
- * FT_Get_CMap_Format
- *
- * FT_PARAM_TAG_UNPATENTED_HINTING
- *
- */
-
-
- /**************************************************************************
- *
- * @struct:
- * TT_Header
- *
- * @description:
- * A structure to model a TrueType font header table. All fields follow
- * the OpenType specification. The 64-bit timestamps are stored in
- * two-element arrays `Created` and `Modified`, first the upper then
- * the lower 32~bits.
- */
- typedef struct TT_Header_
- {
- FT_Fixed Table_Version;
- FT_Fixed Font_Revision;
-
- FT_Long CheckSum_Adjust;
- FT_Long Magic_Number;
-
- FT_UShort Flags;
- FT_UShort Units_Per_EM;
-
- FT_ULong Created [2];
- FT_ULong Modified[2];
-
- FT_Short xMin;
- FT_Short yMin;
- FT_Short xMax;
- FT_Short yMax;
-
- FT_UShort Mac_Style;
- FT_UShort Lowest_Rec_PPEM;
-
- FT_Short Font_Direction;
- FT_Short Index_To_Loc_Format;
- FT_Short Glyph_Data_Format;
-
- } TT_Header;
-
-
- /**************************************************************************
- *
- * @struct:
- * TT_HoriHeader
- *
- * @description:
- * A structure to model a TrueType horizontal header, the 'hhea' table,
- * as well as the corresponding horizontal metrics table, 'hmtx'.
- *
- * @fields:
- * Version ::
- * The table version.
- *
- * Ascender ::
- * The font's ascender, i.e., the distance from the baseline to the
- * top-most of all glyph points found in the font.
- *
- * This value is invalid in many fonts, as it is usually set by the
- * font designer, and often reflects only a portion of the glyphs found
- * in the font (maybe ASCII).
- *
- * You should use the `sTypoAscender` field of the 'OS/2' table instead
- * if you want the correct one.
- *
- * Descender ::
- * The font's descender, i.e., the distance from the baseline to the
- * bottom-most of all glyph points found in the font. It is negative.
- *
- * This value is invalid in many fonts, as it is usually set by the
- * font designer, and often reflects only a portion of the glyphs found
- * in the font (maybe ASCII).
- *
- * You should use the `sTypoDescender` field of the 'OS/2' table
- * instead if you want the correct one.
- *
- * Line_Gap ::
- * The font's line gap, i.e., the distance to add to the ascender and
- * descender to get the BTB, i.e., the baseline-to-baseline distance
- * for the font.
- *
- * advance_Width_Max ::
- * This field is the maximum of all advance widths found in the font.
- * It can be used to compute the maximum width of an arbitrary string
- * of text.
- *
- * min_Left_Side_Bearing ::
- * The minimum left side bearing of all glyphs within the font.
- *
- * min_Right_Side_Bearing ::
- * The minimum right side bearing of all glyphs within the font.
- *
- * xMax_Extent ::
- * The maximum horizontal extent (i.e., the 'width' of a glyph's
- * bounding box) for all glyphs in the font.
- *
- * caret_Slope_Rise ::
- * The rise coefficient of the cursor's slope of the cursor
- * (slope=rise/run).
- *
- * caret_Slope_Run ::
- * The run coefficient of the cursor's slope.
- *
- * caret_Offset ::
- * The cursor's offset for slanted fonts.
- *
- * Reserved ::
- * 8~reserved bytes.
- *
- * metric_Data_Format ::
- * Always~0.
- *
- * number_Of_HMetrics ::
- * Number of HMetrics entries in the 'hmtx' table -- this value can be
- * smaller than the total number of glyphs in the font.
- *
- * long_metrics ::
- * A pointer into the 'hmtx' table.
- *
- * short_metrics ::
- * A pointer into the 'hmtx' table.
- *
- * @note:
- * For an OpenType variation font, the values of the following fields can
- * change after a call to @FT_Set_Var_Design_Coordinates (and friends) if
- * the font contains an 'MVAR' table: `caret_Slope_Rise`,
- * `caret_Slope_Run`, and `caret_Offset`.
- */
- typedef struct TT_HoriHeader_
- {
- FT_Fixed Version;
- FT_Short Ascender;
- FT_Short Descender;
- FT_Short Line_Gap;
-
- FT_UShort advance_Width_Max; /* advance width maximum */
-
- FT_Short min_Left_Side_Bearing; /* minimum left-sb */
- FT_Short min_Right_Side_Bearing; /* minimum right-sb */
- FT_Short xMax_Extent; /* xmax extents */
- FT_Short caret_Slope_Rise;
- FT_Short caret_Slope_Run;
- FT_Short caret_Offset;
-
- FT_Short Reserved[4];
-
- FT_Short metric_Data_Format;
- FT_UShort number_Of_HMetrics;
-
- /* The following fields are not defined by the OpenType specification */
- /* but they are used to connect the metrics header to the relevant */
- /* 'hmtx' table. */
-
- void* long_metrics;
- void* short_metrics;
-
- } TT_HoriHeader;
-
-
- /**************************************************************************
- *
- * @struct:
- * TT_VertHeader
- *
- * @description:
- * A structure used to model a TrueType vertical header, the 'vhea'
- * table, as well as the corresponding vertical metrics table, 'vmtx'.
- *
- * @fields:
- * Version ::
- * The table version.
- *
- * Ascender ::
- * The font's ascender, i.e., the distance from the baseline to the
- * top-most of all glyph points found in the font.
- *
- * This value is invalid in many fonts, as it is usually set by the
- * font designer, and often reflects only a portion of the glyphs found
- * in the font (maybe ASCII).
- *
- * You should use the `sTypoAscender` field of the 'OS/2' table instead
- * if you want the correct one.
- *
- * Descender ::
- * The font's descender, i.e., the distance from the baseline to the
- * bottom-most of all glyph points found in the font. It is negative.
- *
- * This value is invalid in many fonts, as it is usually set by the
- * font designer, and often reflects only a portion of the glyphs found
- * in the font (maybe ASCII).
- *
- * You should use the `sTypoDescender` field of the 'OS/2' table
- * instead if you want the correct one.
- *
- * Line_Gap ::
- * The font's line gap, i.e., the distance to add to the ascender and
- * descender to get the BTB, i.e., the baseline-to-baseline distance
- * for the font.
- *
- * advance_Height_Max ::
- * This field is the maximum of all advance heights found in the font.
- * It can be used to compute the maximum height of an arbitrary string
- * of text.
- *
- * min_Top_Side_Bearing ::
- * The minimum top side bearing of all glyphs within the font.
- *
- * min_Bottom_Side_Bearing ::
- * The minimum bottom side bearing of all glyphs within the font.
- *
- * yMax_Extent ::
- * The maximum vertical extent (i.e., the 'height' of a glyph's
- * bounding box) for all glyphs in the font.
- *
- * caret_Slope_Rise ::
- * The rise coefficient of the cursor's slope of the cursor
- * (slope=rise/run).
- *
- * caret_Slope_Run ::
- * The run coefficient of the cursor's slope.
- *
- * caret_Offset ::
- * The cursor's offset for slanted fonts.
- *
- * Reserved ::
- * 8~reserved bytes.
- *
- * metric_Data_Format ::
- * Always~0.
- *
- * number_Of_VMetrics ::
- * Number of VMetrics entries in the 'vmtx' table -- this value can be
- * smaller than the total number of glyphs in the font.
- *
- * long_metrics ::
- * A pointer into the 'vmtx' table.
- *
- * short_metrics ::
- * A pointer into the 'vmtx' table.
- *
- * @note:
- * For an OpenType variation font, the values of the following fields can
- * change after a call to @FT_Set_Var_Design_Coordinates (and friends) if
- * the font contains an 'MVAR' table: `Ascender`, `Descender`,
- * `Line_Gap`, `caret_Slope_Rise`, `caret_Slope_Run`, and `caret_Offset`.
- */
- typedef struct TT_VertHeader_
- {
- FT_Fixed Version;
- FT_Short Ascender;
- FT_Short Descender;
- FT_Short Line_Gap;
-
- FT_UShort advance_Height_Max; /* advance height maximum */
-
- FT_Short min_Top_Side_Bearing; /* minimum top-sb */
- FT_Short min_Bottom_Side_Bearing; /* minimum bottom-sb */
- FT_Short yMax_Extent; /* ymax extents */
- FT_Short caret_Slope_Rise;
- FT_Short caret_Slope_Run;
- FT_Short caret_Offset;
-
- FT_Short Reserved[4];
-
- FT_Short metric_Data_Format;
- FT_UShort number_Of_VMetrics;
-
- /* The following fields are not defined by the OpenType specification */
- /* but they are used to connect the metrics header to the relevant */
- /* 'vmtx' table. */
-
- void* long_metrics;
- void* short_metrics;
-
- } TT_VertHeader;
-
-
- /**************************************************************************
- *
- * @struct:
- * TT_OS2
- *
- * @description:
- * A structure to model a TrueType 'OS/2' table. All fields comply to
- * the OpenType specification.
- *
- * Note that we now support old Mac fonts that do not include an 'OS/2'
- * table. In this case, the `version` field is always set to 0xFFFF.
- *
- * @note:
- * For an OpenType variation font, the values of the following fields can
- * change after a call to @FT_Set_Var_Design_Coordinates (and friends) if
- * the font contains an 'MVAR' table: `sCapHeight`, `sTypoAscender`,
- * `sTypoDescender`, `sTypoLineGap`, `sxHeight`, `usWinAscent`,
- * `usWinDescent`, `yStrikeoutPosition`, `yStrikeoutSize`,
- * `ySubscriptXOffset`, `ySubScriptXSize`, `ySubscriptYOffset`,
- * `ySubscriptYSize`, `ySuperscriptXOffset`, `ySuperscriptXSize`,
- * `ySuperscriptYOffset`, and `ySuperscriptYSize`.
- *
- * Possible values for bits in the `ulUnicodeRangeX` fields are given by
- * the @TT_UCR_XXX macros.
- */
-
- typedef struct TT_OS2_
- {
- FT_UShort version; /* 0x0001 - more or 0xFFFF */
- FT_Short xAvgCharWidth;
- FT_UShort usWeightClass;
- FT_UShort usWidthClass;
- FT_UShort fsType;
- FT_Short ySubscriptXSize;
- FT_Short ySubscriptYSize;
- FT_Short ySubscriptXOffset;
- FT_Short ySubscriptYOffset;
- FT_Short ySuperscriptXSize;
- FT_Short ySuperscriptYSize;
- FT_Short ySuperscriptXOffset;
- FT_Short ySuperscriptYOffset;
- FT_Short yStrikeoutSize;
- FT_Short yStrikeoutPosition;
- FT_Short sFamilyClass;
-
- FT_Byte panose[10];
-
- FT_ULong ulUnicodeRange1; /* Bits 0-31 */
- FT_ULong ulUnicodeRange2; /* Bits 32-63 */
- FT_ULong ulUnicodeRange3; /* Bits 64-95 */
- FT_ULong ulUnicodeRange4; /* Bits 96-127 */
-
- FT_Char achVendID[4];
-
- FT_UShort fsSelection;
- FT_UShort usFirstCharIndex;
- FT_UShort usLastCharIndex;
- FT_Short sTypoAscender;
- FT_Short sTypoDescender;
- FT_Short sTypoLineGap;
- FT_UShort usWinAscent;
- FT_UShort usWinDescent;
-
- /* only version 1 and higher: */
-
- FT_ULong ulCodePageRange1; /* Bits 0-31 */
- FT_ULong ulCodePageRange2; /* Bits 32-63 */
-
- /* only version 2 and higher: */
-
- FT_Short sxHeight;
- FT_Short sCapHeight;
- FT_UShort usDefaultChar;
- FT_UShort usBreakChar;
- FT_UShort usMaxContext;
-
- /* only version 5 and higher: */
-
- FT_UShort usLowerOpticalPointSize; /* in twips (1/20 points) */
- FT_UShort usUpperOpticalPointSize; /* in twips (1/20 points) */
-
- } TT_OS2;
-
-
- /**************************************************************************
- *
- * @struct:
- * TT_Postscript
- *
- * @description:
- * A structure to model a TrueType 'post' table. All fields comply to
- * the OpenType specification. This structure does not reference a
- * font's PostScript glyph names; use @FT_Get_Glyph_Name to retrieve
- * them.
- *
- * @note:
- * For an OpenType variation font, the values of the following fields can
- * change after a call to @FT_Set_Var_Design_Coordinates (and friends) if
- * the font contains an 'MVAR' table: `underlinePosition` and
- * `underlineThickness`.
- */
- typedef struct TT_Postscript_
- {
- FT_Fixed FormatType;
- FT_Fixed italicAngle;
- FT_Short underlinePosition;
- FT_Short underlineThickness;
- FT_ULong isFixedPitch;
- FT_ULong minMemType42;
- FT_ULong maxMemType42;
- FT_ULong minMemType1;
- FT_ULong maxMemType1;
-
- /* Glyph names follow in the 'post' table, but we don't */
- /* load them by default. */
-
- } TT_Postscript;
-
-
- /**************************************************************************
- *
- * @struct:
- * TT_PCLT
- *
- * @description:
- * A structure to model a TrueType 'PCLT' table. All fields comply to
- * the OpenType specification.
- */
- typedef struct TT_PCLT_
- {
- FT_Fixed Version;
- FT_ULong FontNumber;
- FT_UShort Pitch;
- FT_UShort xHeight;
- FT_UShort Style;
- FT_UShort TypeFamily;
- FT_UShort CapHeight;
- FT_UShort SymbolSet;
- FT_Char TypeFace[16];
- FT_Char CharacterComplement[8];
- FT_Char FileName[6];
- FT_Char StrokeWeight;
- FT_Char WidthType;
- FT_Byte SerifStyle;
- FT_Byte Reserved;
-
- } TT_PCLT;
-
-
- /**************************************************************************
- *
- * @struct:
- * TT_MaxProfile
- *
- * @description:
- * The maximum profile ('maxp') table contains many max values, which can
- * be used to pre-allocate arrays for speeding up glyph loading and
- * hinting.
- *
- * @fields:
- * version ::
- * The version number.
- *
- * numGlyphs ::
- * The number of glyphs in this TrueType font.
- *
- * maxPoints ::
- * The maximum number of points in a non-composite TrueType glyph. See
- * also `maxCompositePoints`.
- *
- * maxContours ::
- * The maximum number of contours in a non-composite TrueType glyph.
- * See also `maxCompositeContours`.
- *
- * maxCompositePoints ::
- * The maximum number of points in a composite TrueType glyph. See
- * also `maxPoints`.
- *
- * maxCompositeContours ::
- * The maximum number of contours in a composite TrueType glyph. See
- * also `maxContours`.
- *
- * maxZones ::
- * The maximum number of zones used for glyph hinting.
- *
- * maxTwilightPoints ::
- * The maximum number of points in the twilight zone used for glyph
- * hinting.
- *
- * maxStorage ::
- * The maximum number of elements in the storage area used for glyph
- * hinting.
- *
- * maxFunctionDefs ::
- * The maximum number of function definitions in the TrueType bytecode
- * for this font.
- *
- * maxInstructionDefs ::
- * The maximum number of instruction definitions in the TrueType
- * bytecode for this font.
- *
- * maxStackElements ::
- * The maximum number of stack elements used during bytecode
- * interpretation.
- *
- * maxSizeOfInstructions ::
- * The maximum number of TrueType opcodes used for glyph hinting.
- *
- * maxComponentElements ::
- * The maximum number of simple (i.e., non-composite) glyphs in a
- * composite glyph.
- *
- * maxComponentDepth ::
- * The maximum nesting depth of composite glyphs.
- *
- * @note:
- * This structure is only used during font loading.
- */
- typedef struct TT_MaxProfile_
- {
- FT_Fixed version;
- FT_UShort numGlyphs;
- FT_UShort maxPoints;
- FT_UShort maxContours;
- FT_UShort maxCompositePoints;
- FT_UShort maxCompositeContours;
- FT_UShort maxZones;
- FT_UShort maxTwilightPoints;
- FT_UShort maxStorage;
- FT_UShort maxFunctionDefs;
- FT_UShort maxInstructionDefs;
- FT_UShort maxStackElements;
- FT_UShort maxSizeOfInstructions;
- FT_UShort maxComponentElements;
- FT_UShort maxComponentDepth;
-
- } TT_MaxProfile;
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_Sfnt_Tag
- *
- * @description:
- * An enumeration to specify indices of SFNT tables loaded and parsed by
- * FreeType during initialization of an SFNT font. Used in the
- * @FT_Get_Sfnt_Table API function.
- *
- * @values:
- * FT_SFNT_HEAD ::
- * To access the font's @TT_Header structure.
- *
- * FT_SFNT_MAXP ::
- * To access the font's @TT_MaxProfile structure.
- *
- * FT_SFNT_OS2 ::
- * To access the font's @TT_OS2 structure.
- *
- * FT_SFNT_HHEA ::
- * To access the font's @TT_HoriHeader structure.
- *
- * FT_SFNT_VHEA ::
- * To access the font's @TT_VertHeader structure.
- *
- * FT_SFNT_POST ::
- * To access the font's @TT_Postscript structure.
- *
- * FT_SFNT_PCLT ::
- * To access the font's @TT_PCLT structure.
- */
- typedef enum FT_Sfnt_Tag_
- {
- FT_SFNT_HEAD,
- FT_SFNT_MAXP,
- FT_SFNT_OS2,
- FT_SFNT_HHEA,
- FT_SFNT_VHEA,
- FT_SFNT_POST,
- FT_SFNT_PCLT,
-
- FT_SFNT_MAX
-
- } FT_Sfnt_Tag;
-
- /* these constants are deprecated; use the corresponding `FT_Sfnt_Tag` */
- /* values instead */
-#define ft_sfnt_head FT_SFNT_HEAD
-#define ft_sfnt_maxp FT_SFNT_MAXP
-#define ft_sfnt_os2 FT_SFNT_OS2
-#define ft_sfnt_hhea FT_SFNT_HHEA
-#define ft_sfnt_vhea FT_SFNT_VHEA
-#define ft_sfnt_post FT_SFNT_POST
-#define ft_sfnt_pclt FT_SFNT_PCLT
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_Sfnt_Table
- *
- * @description:
- * Return a pointer to a given SFNT table stored within a face.
- *
- * @input:
- * face ::
- * A handle to the source.
- *
- * tag ::
- * The index of the SFNT table.
- *
- * @return:
- * A type-less pointer to the table. This will be `NULL` in case of
- * error, or if the corresponding table was not found **OR** loaded from
- * the file.
- *
- * Use a typecast according to `tag` to access the structure elements.
- *
- * @note:
- * The table is owned by the face object and disappears with it.
- *
- * This function is only useful to access SFNT tables that are loaded by
- * the sfnt, truetype, and opentype drivers. See @FT_Sfnt_Tag for a
- * list.
- *
- * @example:
- * Here is an example demonstrating access to the 'vhea' table.
- *
- * ```
- * TT_VertHeader* vert_header;
- *
- *
- * vert_header =
- * (TT_VertHeader*)FT_Get_Sfnt_Table( face, FT_SFNT_VHEA );
- * ```
- */
- FT_EXPORT( void* )
- FT_Get_Sfnt_Table( FT_Face face,
- FT_Sfnt_Tag tag );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Load_Sfnt_Table
- *
- * @description:
- * Load any SFNT font table into client memory.
- *
- * @input:
- * face ::
- * A handle to the source face.
- *
- * tag ::
- * The four-byte tag of the table to load. Use value~0 if you want to
- * access the whole font file. Otherwise, you can use one of the
- * definitions found in the @FT_TRUETYPE_TAGS_H file, or forge a new
- * one with @FT_MAKE_TAG.
- *
- * offset ::
- * The starting offset in the table (or file if tag~==~0).
- *
- * @output:
- * buffer ::
- * The target buffer address. The client must ensure that the memory
- * array is big enough to hold the data.
- *
- * @inout:
- * length ::
- * If the `length` parameter is `NULL`, try to load the whole table.
- * Return an error code if it fails.
- *
- * Else, if `*length` is~0, exit immediately while returning the
- * table's (or file) full size in it.
- *
- * Else the number of bytes to read from the table or file, from the
- * starting offset.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * If you need to determine the table's length you should first call this
- * function with `*length` set to~0, as in the following example:
- *
- * ```
- * FT_ULong length = 0;
- *
- *
- * error = FT_Load_Sfnt_Table( face, tag, 0, NULL, &length );
- * if ( error ) { ... table does not exist ... }
- *
- * buffer = malloc( length );
- * if ( buffer == NULL ) { ... not enough memory ... }
- *
- * error = FT_Load_Sfnt_Table( face, tag, 0, buffer, &length );
- * if ( error ) { ... could not load table ... }
- * ```
- *
- * Note that structures like @TT_Header or @TT_OS2 can't be used with
- * this function; they are limited to @FT_Get_Sfnt_Table. Reason is that
- * those structures depend on the processor architecture, with varying
- * size (e.g. 32bit vs. 64bit) or order (big endian vs. little endian).
- *
- */
- FT_EXPORT( FT_Error )
- FT_Load_Sfnt_Table( FT_Face face,
- FT_ULong tag,
- FT_Long offset,
- FT_Byte* buffer,
- FT_ULong* length );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Sfnt_Table_Info
- *
- * @description:
- * Return information on an SFNT table.
- *
- * @input:
- * face ::
- * A handle to the source face.
- *
- * table_index ::
- * The index of an SFNT table. The function returns
- * FT_Err_Table_Missing for an invalid value.
- *
- * @inout:
- * tag ::
- * The name tag of the SFNT table. If the value is `NULL`,
- * `table_index` is ignored, and `length` returns the number of SFNT
- * tables in the font.
- *
- * @output:
- * length ::
- * The length of the SFNT table (or the number of SFNT tables,
- * depending on `tag`).
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * While parsing fonts, FreeType handles SFNT tables with length zero as
- * missing.
- *
- */
- FT_EXPORT( FT_Error )
- FT_Sfnt_Table_Info( FT_Face face,
- FT_UInt table_index,
- FT_ULong *tag,
- FT_ULong *length );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_CMap_Language_ID
- *
- * @description:
- * Return cmap language ID as specified in the OpenType standard.
- * Definitions of language ID values are in file @FT_TRUETYPE_IDS_H.
- *
- * @input:
- * charmap ::
- * The target charmap.
- *
- * @return:
- * The language ID of `charmap`. If `charmap` doesn't belong to an SFNT
- * face, just return~0 as the default value.
- *
- * For a format~14 cmap (to access Unicode IVS), the return value is
- * 0xFFFFFFFF.
- */
- FT_EXPORT( FT_ULong )
- FT_Get_CMap_Language_ID( FT_CharMap charmap );
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Get_CMap_Format
- *
- * @description:
- * Return the format of an SFNT 'cmap' table.
- *
- * @input:
- * charmap ::
- * The target charmap.
- *
- * @return:
- * The format of `charmap`. If `charmap` doesn't belong to an SFNT face
- * (including the synthetic Unicode charmap sometimes created by
- * FreeType), return -1.
- */
- FT_EXPORT( FT_Long )
- FT_Get_CMap_Format( FT_CharMap charmap );
-
- /* */
-
-
-FT_END_HEADER
-
-#endif /* TTTABLES_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/freetype/tttags.h b/contrib/libs/freetype/include/freetype/tttags.h
deleted file mode 100644
index da0af5d3f2..0000000000
--- a/contrib/libs/freetype/include/freetype/tttags.h
+++ /dev/null
@@ -1,124 +0,0 @@
-/****************************************************************************
- *
- * tttags.h
- *
- * Tags for TrueType and OpenType tables (specification only).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef TTAGS_H_
-#define TTAGS_H_
-
-
-#include <freetype/freetype.h>
-
-#ifdef FREETYPE_H
-#error "freetype.h of FreeType 1 has been loaded!"
-#error "Please fix the directory search order for header files"
-#error "so that freetype.h of FreeType 2 is found first."
-#endif
-
-
-FT_BEGIN_HEADER
-
-
-#define TTAG_avar FT_MAKE_TAG( 'a', 'v', 'a', 'r' )
-#define TTAG_BASE FT_MAKE_TAG( 'B', 'A', 'S', 'E' )
-#define TTAG_bdat FT_MAKE_TAG( 'b', 'd', 'a', 't' )
-#define TTAG_BDF FT_MAKE_TAG( 'B', 'D', 'F', ' ' )
-#define TTAG_bhed FT_MAKE_TAG( 'b', 'h', 'e', 'd' )
-#define TTAG_bloc FT_MAKE_TAG( 'b', 'l', 'o', 'c' )
-#define TTAG_bsln FT_MAKE_TAG( 'b', 's', 'l', 'n' )
-#define TTAG_CBDT FT_MAKE_TAG( 'C', 'B', 'D', 'T' )
-#define TTAG_CBLC FT_MAKE_TAG( 'C', 'B', 'L', 'C' )
-#define TTAG_CFF FT_MAKE_TAG( 'C', 'F', 'F', ' ' )
-#define TTAG_CFF2 FT_MAKE_TAG( 'C', 'F', 'F', '2' )
-#define TTAG_CID FT_MAKE_TAG( 'C', 'I', 'D', ' ' )
-#define TTAG_cmap FT_MAKE_TAG( 'c', 'm', 'a', 'p' )
-#define TTAG_COLR FT_MAKE_TAG( 'C', 'O', 'L', 'R' )
-#define TTAG_CPAL FT_MAKE_TAG( 'C', 'P', 'A', 'L' )
-#define TTAG_cvar FT_MAKE_TAG( 'c', 'v', 'a', 'r' )
-#define TTAG_cvt FT_MAKE_TAG( 'c', 'v', 't', ' ' )
-#define TTAG_DSIG FT_MAKE_TAG( 'D', 'S', 'I', 'G' )
-#define TTAG_EBDT FT_MAKE_TAG( 'E', 'B', 'D', 'T' )
-#define TTAG_EBLC FT_MAKE_TAG( 'E', 'B', 'L', 'C' )
-#define TTAG_EBSC FT_MAKE_TAG( 'E', 'B', 'S', 'C' )
-#define TTAG_feat FT_MAKE_TAG( 'f', 'e', 'a', 't' )
-#define TTAG_FOND FT_MAKE_TAG( 'F', 'O', 'N', 'D' )
-#define TTAG_fpgm FT_MAKE_TAG( 'f', 'p', 'g', 'm' )
-#define TTAG_fvar FT_MAKE_TAG( 'f', 'v', 'a', 'r' )
-#define TTAG_gasp FT_MAKE_TAG( 'g', 'a', 's', 'p' )
-#define TTAG_GDEF FT_MAKE_TAG( 'G', 'D', 'E', 'F' )
-#define TTAG_glyf FT_MAKE_TAG( 'g', 'l', 'y', 'f' )
-#define TTAG_GPOS FT_MAKE_TAG( 'G', 'P', 'O', 'S' )
-#define TTAG_GSUB FT_MAKE_TAG( 'G', 'S', 'U', 'B' )
-#define TTAG_gvar FT_MAKE_TAG( 'g', 'v', 'a', 'r' )
-#define TTAG_HVAR FT_MAKE_TAG( 'H', 'V', 'A', 'R' )
-#define TTAG_hdmx FT_MAKE_TAG( 'h', 'd', 'm', 'x' )
-#define TTAG_head FT_MAKE_TAG( 'h', 'e', 'a', 'd' )
-#define TTAG_hhea FT_MAKE_TAG( 'h', 'h', 'e', 'a' )
-#define TTAG_hmtx FT_MAKE_TAG( 'h', 'm', 't', 'x' )
-#define TTAG_JSTF FT_MAKE_TAG( 'J', 'S', 'T', 'F' )
-#define TTAG_just FT_MAKE_TAG( 'j', 'u', 's', 't' )
-#define TTAG_kern FT_MAKE_TAG( 'k', 'e', 'r', 'n' )
-#define TTAG_lcar FT_MAKE_TAG( 'l', 'c', 'a', 'r' )
-#define TTAG_loca FT_MAKE_TAG( 'l', 'o', 'c', 'a' )
-#define TTAG_LTSH FT_MAKE_TAG( 'L', 'T', 'S', 'H' )
-#define TTAG_LWFN FT_MAKE_TAG( 'L', 'W', 'F', 'N' )
-#define TTAG_MATH FT_MAKE_TAG( 'M', 'A', 'T', 'H' )
-#define TTAG_maxp FT_MAKE_TAG( 'm', 'a', 'x', 'p' )
-#define TTAG_META FT_MAKE_TAG( 'M', 'E', 'T', 'A' )
-#define TTAG_MMFX FT_MAKE_TAG( 'M', 'M', 'F', 'X' )
-#define TTAG_MMSD FT_MAKE_TAG( 'M', 'M', 'S', 'D' )
-#define TTAG_mort FT_MAKE_TAG( 'm', 'o', 'r', 't' )
-#define TTAG_morx FT_MAKE_TAG( 'm', 'o', 'r', 'x' )
-#define TTAG_MVAR FT_MAKE_TAG( 'M', 'V', 'A', 'R' )
-#define TTAG_name FT_MAKE_TAG( 'n', 'a', 'm', 'e' )
-#define TTAG_opbd FT_MAKE_TAG( 'o', 'p', 'b', 'd' )
-#define TTAG_OS2 FT_MAKE_TAG( 'O', 'S', '/', '2' )
-#define TTAG_OTTO FT_MAKE_TAG( 'O', 'T', 'T', 'O' )
-#define TTAG_PCLT FT_MAKE_TAG( 'P', 'C', 'L', 'T' )
-#define TTAG_POST FT_MAKE_TAG( 'P', 'O', 'S', 'T' )
-#define TTAG_post FT_MAKE_TAG( 'p', 'o', 's', 't' )
-#define TTAG_prep FT_MAKE_TAG( 'p', 'r', 'e', 'p' )
-#define TTAG_prop FT_MAKE_TAG( 'p', 'r', 'o', 'p' )
-#define TTAG_sbix FT_MAKE_TAG( 's', 'b', 'i', 'x' )
-#define TTAG_sfnt FT_MAKE_TAG( 's', 'f', 'n', 't' )
-#define TTAG_SING FT_MAKE_TAG( 'S', 'I', 'N', 'G' )
-#define TTAG_SVG FT_MAKE_TAG( 'S', 'V', 'G', ' ' )
-#define TTAG_trak FT_MAKE_TAG( 't', 'r', 'a', 'k' )
-#define TTAG_true FT_MAKE_TAG( 't', 'r', 'u', 'e' )
-#define TTAG_ttc FT_MAKE_TAG( 't', 't', 'c', ' ' )
-#define TTAG_ttcf FT_MAKE_TAG( 't', 't', 'c', 'f' )
-#define TTAG_TYP1 FT_MAKE_TAG( 'T', 'Y', 'P', '1' )
-#define TTAG_typ1 FT_MAKE_TAG( 't', 'y', 'p', '1' )
-#define TTAG_VDMX FT_MAKE_TAG( 'V', 'D', 'M', 'X' )
-#define TTAG_vhea FT_MAKE_TAG( 'v', 'h', 'e', 'a' )
-#define TTAG_vmtx FT_MAKE_TAG( 'v', 'm', 't', 'x' )
-#define TTAG_VVAR FT_MAKE_TAG( 'V', 'V', 'A', 'R' )
-#define TTAG_wOFF FT_MAKE_TAG( 'w', 'O', 'F', 'F' )
-#define TTAG_wOF2 FT_MAKE_TAG( 'w', 'O', 'F', '2' )
-
-/* used by "Keyboard.dfont" on legacy Mac OS X */
-#define TTAG_0xA5kbd FT_MAKE_TAG( 0xA5, 'k', 'b', 'd' )
-
-/* used by "LastResort.dfont" on legacy Mac OS X */
-#define TTAG_0xA5lst FT_MAKE_TAG( 0xA5, 'l', 's', 't' )
-
-
-FT_END_HEADER
-
-#endif /* TTAGS_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/include/ft2build.h b/contrib/libs/freetype/include/ft2build.h
deleted file mode 100644
index d3d7685039..0000000000
--- a/contrib/libs/freetype/include/ft2build.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
- *
- * ft2build.h
- *
- * FreeType 2 build and setup macros.
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /**************************************************************************
- *
- * This is the 'entry point' for FreeType header file inclusions, to be
- * loaded before all other header files.
- *
- * A typical example is
- *
- * ```
- * #include <ft2build.h>
- * #include <freetype/freetype.h>
- * ```
- *
- */
-
-
-#ifndef FT2BUILD_H_
-#define FT2BUILD_H_
-
-#include <freetype/config/ftheader.h>
-
-#endif /* FT2BUILD_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/autofit/afblue.c b/contrib/libs/freetype/src/autofit/afblue.c
deleted file mode 100644
index ea83969cdc..0000000000
--- a/contrib/libs/freetype/src/autofit/afblue.c
+++ /dev/null
@@ -1,779 +0,0 @@
-/* This file has been generated by the Perl script `afblue.pl', */
-/* using data from file `afblue.dat'. */
-
-/****************************************************************************
- *
- * afblue.c
- *
- * Auto-fitter data for blue strings (body).
- *
- * Copyright (C) 2013-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include "aftypes.h"
-
-
- FT_LOCAL_ARRAY_DEF( char )
- af_blue_strings[] =
- {
- /* */
- '\xF0', '\x9E', '\xA4', '\x8C', ' ', '\xF0', '\x9E', '\xA4', '\x85', ' ', '\xF0', '\x9E', '\xA4', '\x88', ' ', '\xF0', '\x9E', '\xA4', '\x8F', ' ', '\xF0', '\x9E', '\xA4', '\x94', ' ', '\xF0', '\x9E', '\xA4', '\x9A', /* 𞤌 𞤅 𞤈 𞤠𞤔 𞤚 */
- '\0',
- '\xF0', '\x9E', '\xA4', '\x82', ' ', '\xF0', '\x9E', '\xA4', '\x96', /* 𞤂 𞤖 */
- '\0',
- '\xF0', '\x9E', '\xA4', '\xAC', ' ', '\xF0', '\x9E', '\xA4', '\xAE', ' ', '\xF0', '\x9E', '\xA4', '\xBB', ' ', '\xF0', '\x9E', '\xA4', '\xBC', ' ', '\xF0', '\x9E', '\xA4', '\xBE', /* 𞤬 𞤮 𞤻 𞤼 𞤾 */
- '\0',
- '\xF0', '\x9E', '\xA4', '\xA4', ' ', '\xF0', '\x9E', '\xA4', '\xA8', ' ', '\xF0', '\x9E', '\xA4', '\xA9', ' ', '\xF0', '\x9E', '\xA4', '\xAD', ' ', '\xF0', '\x9E', '\xA4', '\xB4', ' ', '\xF0', '\x9E', '\xA4', '\xB8', ' ', '\xF0', '\x9E', '\xA4', '\xBA', ' ', '\xF0', '\x9E', '\xA5', '\x80', /* 𞤤 𞤨 𞤩 𞤭 𞤴 𞤸 𞤺 𞥀 */
- '\0',
- '\xD8', '\xA7', ' ', '\xD8', '\xA5', ' ', '\xD9', '\x84', ' ', '\xD9', '\x83', ' ', '\xD8', '\xB7', ' ', '\xD8', '\xB8', /* ا إ ل ك ط ظ */
- '\0',
- '\xD8', '\xAA', ' ', '\xD8', '\xAB', ' ', '\xD8', '\xB7', ' ', '\xD8', '\xB8', ' ', '\xD9', '\x83', /* ت ث ط ظ ك */
- '\0',
- '\xD9', '\x80', /* Ù€ */
- '\0',
- '\xD4', '\xB1', ' ', '\xD5', '\x84', ' ', '\xD5', '\x92', ' ', '\xD5', '\x8D', ' ', '\xD4', '\xB2', ' ', '\xD4', '\xB3', ' ', '\xD4', '\xB4', ' ', '\xD5', '\x95', /* Ô± Õ„ Õ’ Õ Ô² Ô³ Ô´ Õ• */
- '\0',
- '\xD5', '\x92', ' ', '\xD5', '\x88', ' ', '\xD4', '\xB4', ' ', '\xD5', '\x83', ' ', '\xD5', '\x87', ' ', '\xD5', '\x8D', ' ', '\xD5', '\x8F', ' ', '\xD5', '\x95', /* Õ’ Õˆ Ô´ Õƒ Õ‡ Õ Õ Õ• */
- '\0',
- '\xD5', '\xA5', ' ', '\xD5', '\xA7', ' ', '\xD5', '\xAB', ' ', '\xD5', '\xB4', ' ', '\xD5', '\xBE', ' ', '\xD6', '\x86', ' ', '\xD5', '\xB3', /* Õ¥ Õ§ Õ« Õ´ Õ¾ Ö† Õ³ */
- '\0',
- '\xD5', '\xA1', ' ', '\xD5', '\xB5', ' ', '\xD6', '\x82', ' ', '\xD5', '\xBD', ' ', '\xD5', '\xA3', ' ', '\xD5', '\xB7', ' ', '\xD6', '\x80', ' ', '\xD6', '\x85', /* Õ¡ Õµ Ö‚ Õ½ Õ£ Õ· Ö€ Ö… */
- '\0',
- '\xD5', '\xB0', ' ', '\xD5', '\xB8', ' ', '\xD5', '\xB3', ' ', '\xD5', '\xA1', ' ', '\xD5', '\xA5', ' ', '\xD5', '\xAE', ' ', '\xD5', '\xBD', ' ', '\xD6', '\x85', /* Õ° Õ¸ Õ³ Õ¡ Õ¥ Õ® Õ½ Ö… */
- '\0',
- '\xD5', '\xA2', ' ', '\xD5', '\xA8', ' ', '\xD5', '\xAB', ' ', '\xD5', '\xAC', ' ', '\xD5', '\xB2', ' ', '\xD5', '\xBA', ' ', '\xD6', '\x83', ' ', '\xD6', '\x81', /* Õ¢ Õ¨ Õ« Õ¬ Õ² Õº Öƒ Ö */
- '\0',
- '\xF0', '\x90', '\xAC', '\x80', ' ', '\xF0', '\x90', '\xAC', '\x81', ' ', '\xF0', '\x90', '\xAC', '\x90', ' ', '\xF0', '\x90', '\xAC', '\x9B', /* 𬀠ð¬ ð¬ 𬛠*/
- '\0',
- '\xF0', '\x90', '\xAC', '\x80', ' ', '\xF0', '\x90', '\xAC', '\x81', /* 𬀠ð¬ */
- '\0',
- '\xEA', '\x9A', '\xA7', ' ', '\xEA', '\x9A', '\xA8', ' ', '\xEA', '\x9B', '\x9B', ' ', '\xEA', '\x9B', '\x89', ' ', '\xEA', '\x9B', '\x81', ' ', '\xEA', '\x9B', '\x88', ' ', '\xEA', '\x9B', '\xAB', ' ', '\xEA', '\x9B', '\xAF', /* ꚧ ꚨ ê›› ꛉ ê› ê›ˆ ꛫ ꛯ */
- '\0',
- '\xEA', '\x9A', '\xAD', ' ', '\xEA', '\x9A', '\xB3', ' ', '\xEA', '\x9A', '\xB6', ' ', '\xEA', '\x9B', '\xAC', ' ', '\xEA', '\x9A', '\xA2', ' ', '\xEA', '\x9A', '\xBD', ' ', '\xEA', '\x9B', '\xAF', ' ', '\xEA', '\x9B', '\xB2', /* ꚭ ꚳ ꚶ ꛬ ꚢ ꚽ ꛯ ꛲ */
- '\0',
- '\xE0', '\xA6', '\x85', ' ', '\xE0', '\xA6', '\xA1', ' ', '\xE0', '\xA6', '\xA4', ' ', '\xE0', '\xA6', '\xA8', ' ', '\xE0', '\xA6', '\xAC', ' ', '\xE0', '\xA6', '\xAD', ' ', '\xE0', '\xA6', '\xB2', ' ', '\xE0', '\xA6', '\x95', /* অ ড ত ন ব ভ ল ক */
- '\0',
- '\xE0', '\xA6', '\x87', ' ', '\xE0', '\xA6', '\x9F', ' ', '\xE0', '\xA6', '\xA0', ' ', '\xE0', '\xA6', '\xBF', ' ', '\xE0', '\xA7', '\x80', ' ', '\xE0', '\xA7', '\x88', ' ', '\xE0', '\xA7', '\x97', /* ই ট ঠ ি ী ৈ ৗ */
- '\0',
- '\xE0', '\xA6', '\x93', ' ', '\xE0', '\xA6', '\x8F', ' ', '\xE0', '\xA6', '\xA1', ' ', '\xE0', '\xA6', '\xA4', ' ', '\xE0', '\xA6', '\xA8', ' ', '\xE0', '\xA6', '\xAC', ' ', '\xE0', '\xA6', '\xB2', ' ', '\xE0', '\xA6', '\x95', /* ও ঠড ত ন ব ল ক */
- '\0',
- '\xE1', '\x9D', '\x90', ' ', '\xE1', '\x9D', '\x88', /* á ሠ*/
- '\0',
- '\xE1', '\x9D', '\x85', ' ', '\xE1', '\x9D', '\x8A', ' ', '\xE1', '\x9D', '\x8E', /* á… áŠ áŽ */
- '\0',
- '\xE1', '\x9D', '\x82', ' ', '\xE1', '\x9D', '\x83', ' ', '\xE1', '\x9D', '\x89', ' ', '\xE1', '\x9D', '\x8C', /* Ⴀრበጠ*/
- '\0',
- '\xE1', '\x9D', '\x80', ' ', '\xE1', '\x9D', '\x83', ' ', '\xE1', '\x9D', '\x86', ' ', '\xE1', '\x9D', '\x89', ' ', '\xE1', '\x9D', '\x8B', ' ', '\xE1', '\x9D', '\x8F', ' ', '\xE1', '\x9D', '\x91', /* ဠრᆠበዠá á‘ */
- '\0',
- '\xE1', '\x97', '\x9C', ' ', '\xE1', '\x96', '\xB4', ' ', '\xE1', '\x90', '\x81', ' ', '\xE1', '\x92', '\xA3', ' ', '\xE1', '\x91', '\xAB', ' ', '\xE1', '\x91', '\x8E', ' ', '\xE1', '\x94', '\x91', ' ', '\xE1', '\x97', '\xB0', /* á—œ á–´ á á’£ á‘« á‘Ž ᔑ á—° */
- '\0',
- '\xE1', '\x97', '\xB6', ' ', '\xE1', '\x96', '\xB5', ' ', '\xE1', '\x92', '\xA7', ' ', '\xE1', '\x90', '\x83', ' ', '\xE1', '\x91', '\x8C', ' ', '\xE1', '\x92', '\x8D', ' ', '\xE1', '\x94', '\x91', ' ', '\xE1', '\x97', '\xA2', /* ᗶ ᖵ ᒧ რᑌ ᒠᔑ ᗢ */
- '\0',
- '\xE1', '\x93', '\x93', ' ', '\xE1', '\x93', '\x95', ' ', '\xE1', '\x93', '\x80', ' ', '\xE1', '\x93', '\x82', ' ', '\xE1', '\x93', '\x84', ' ', '\xE1', '\x95', '\x84', ' ', '\xE1', '\x95', '\x86', ' ', '\xE1', '\x98', '\xA3', /* ᓓ ᓕ ᓀ ᓂ ᓄ ᕄ ᕆ ᘣ */
- '\0',
- '\xE1', '\x95', '\x83', ' ', '\xE1', '\x93', '\x82', ' ', '\xE1', '\x93', '\x80', ' ', '\xE1', '\x95', '\x82', ' ', '\xE1', '\x93', '\x97', ' ', '\xE1', '\x93', '\x9A', ' ', '\xE1', '\x95', '\x86', ' ', '\xE1', '\x98', '\xA3', /* ᕃ ᓂ ᓀ ᕂ ᓗ ᓚ ᕆ ᘣ */
- '\0',
- '\xE1', '\x90', '\xAA', ' ', '\xE1', '\x99', '\x86', ' ', '\xE1', '\xA3', '\x98', ' ', '\xE1', '\x90', '\xA2', ' ', '\xE1', '\x92', '\xBE', ' ', '\xE1', '\xA3', '\x97', ' ', '\xE1', '\x94', '\x86', /* ᪠ᙆ ᣘ ᢠᒾ ᣗ ᔆ */
- '\0',
- '\xE1', '\x99', '\x86', ' ', '\xE1', '\x97', '\xAE', ' ', '\xE1', '\x92', '\xBB', ' ', '\xE1', '\x90', '\x9E', ' ', '\xE1', '\x94', '\x86', ' ', '\xE1', '\x92', '\xA1', ' ', '\xE1', '\x92', '\xA2', ' ', '\xE1', '\x93', '\x91', /* ᙆ ᗮ ᒻ ហᔆ ᒡ ᒢ ᓑ */
- '\0',
- '\xF0', '\x90', '\x8A', '\xA7', ' ', '\xF0', '\x90', '\x8A', '\xAB', ' ', '\xF0', '\x90', '\x8A', '\xAC', ' ', '\xF0', '\x90', '\x8A', '\xAD', ' ', '\xF0', '\x90', '\x8A', '\xB1', ' ', '\xF0', '\x90', '\x8A', '\xBA', ' ', '\xF0', '\x90', '\x8A', '\xBC', ' ', '\xF0', '\x90', '\x8A', '\xBF', /* ðŠ§ ðŠ« ðŠ¬ ðŠ­ ðŠ± ðŠº ðŠ¼ ðŠ¿ */
- '\0',
- '\xF0', '\x90', '\x8A', '\xA3', ' ', '\xF0', '\x90', '\x8A', '\xA7', ' ', '\xF0', '\x90', '\x8A', '\xB7', ' ', '\xF0', '\x90', '\x8B', '\x80', ' ', '\xF0', '\x90', '\x8A', '\xAB', ' ', '\xF0', '\x90', '\x8A', '\xB8', ' ', '\xF0', '\x90', '\x8B', '\x89', /* ðŠ£ ðŠ§ ðŠ· ð‹€ ðŠ« ðŠ¸ ð‹‰ */
- '\0',
- '\xF0', '\x91', '\x84', '\x83', ' ', '\xF0', '\x91', '\x84', '\x85', ' ', '\xF0', '\x91', '\x84', '\x89', ' ', '\xF0', '\x91', '\x84', '\x99', ' ', '\xF0', '\x91', '\x84', '\x97', /* 𑄃 𑄅 𑄉 𑄙 𑄗 */
- '\0',
- '\xF0', '\x91', '\x84', '\x85', ' ', '\xF0', '\x91', '\x84', '\x9B', ' ', '\xF0', '\x91', '\x84', '\x9D', ' ', '\xF0', '\x91', '\x84', '\x97', ' ', '\xF0', '\x91', '\x84', '\x93', /* ð‘„… ð‘„› ð‘„ ð‘„— ð‘„“ */
- '\0',
- '\xF0', '\x91', '\x84', '\x96', '\xF0', '\x91', '\x84', '\xB3', '\xF0', '\x91', '\x84', '\xA2', ' ', '\xF0', '\x91', '\x84', '\x98', '\xF0', '\x91', '\x84', '\xB3', '\xF0', '\x91', '\x84', '\xA2', ' ', '\xF0', '\x91', '\x84', '\x99', '\xF0', '\x91', '\x84', '\xB3', '\xF0', '\x91', '\x84', '\xA2', ' ', '\xF0', '\x91', '\x84', '\xA4', '\xF0', '\x91', '\x84', '\xB3', '\xF0', '\x91', '\x84', '\xA2', ' ', '\xF0', '\x91', '\x84', '\xA5', '\xF0', '\x91', '\x84', '\xB3', '\xF0', '\x91', '\x84', '\xA2', /* 𑄖𑄳𑄢 𑄘𑄳𑄢 𑄙𑄳𑄢 𑄤𑄳𑄢 𑄥𑄳𑄢 */
- '\0',
- '\xE1', '\x8F', '\x86', ' ', '\xE1', '\x8E', '\xBB', ' ', '\xE1', '\x8E', '\xAC', ' ', '\xE1', '\x8F', '\x83', ' ', '\xE1', '\x8E', '\xA4', ' ', '\xE1', '\x8F', '\xA3', ' ', '\xE1', '\x8E', '\xA6', ' ', '\xE1', '\x8F', '\x95', /* ᆠᎻ Ꭼ რᎤ ᣠᎦ ᕠ*/
- '\0',
- '\xEA', '\xAE', '\x92', ' ', '\xEA', '\xAE', '\xA4', ' ', '\xEA', '\xAE', '\xB6', ' ', '\xEA', '\xAD', '\xB4', ' ', '\xEA', '\xAD', '\xBE', ' ', '\xEA', '\xAE', '\x97', ' ', '\xEA', '\xAE', '\x9D', ' ', '\xEA', '\xAE', '\xBF', /* ê®’ ꮤ ꮶ ê­´ ê­¾ ê®— ê® ê®¿ */
- '\0',
- '\xEA', '\xAE', '\x96', ' ', '\xEA', '\xAD', '\xBC', ' ', '\xEA', '\xAE', '\x93', ' ', '\xEA', '\xAE', '\xA0', ' ', '\xEA', '\xAE', '\xB3', ' ', '\xEA', '\xAD', '\xB6', ' ', '\xEA', '\xAE', '\xA5', ' ', '\xEA', '\xAE', '\xBB', /* ꮖ ꭼ ꮓ ꮠ ꮳ ꭶ ꮥ ꮻ */
- '\0',
- '\xE1', '\x8F', '\xB8', ' ', '\xEA', '\xAE', '\x90', ' ', '\xEA', '\xAD', '\xB9', ' ', '\xEA', '\xAD', '\xBB', /* á¸ ê® ê­¹ ê­» */
- '\0',
- '\xE2', '\xB2', '\x8C', ' ', '\xE2', '\xB2', '\x8E', ' ', '\xE2', '\xB2', '\xA0', ' ', '\xE2', '\xB3', '\x9E', ' ', '\xE2', '\xB2', '\x9E', ' ', '\xE2', '\xB2', '\x90', ' ', '\xE2', '\xB2', '\xA4', ' ', '\xE2', '\xB3', '\x8A', /* Ⲍ Ⲏ Ⲡ Ⳟ Ⲟ ⲠⲤ Ⳋ */
- '\0',
- '\xE2', '\xB3', '\x90', ' ', '\xE2', '\xB3', '\x98', ' ', '\xE2', '\xB3', '\x9E', ' ', '\xE2', '\xB2', '\x8E', ' ', '\xE2', '\xB2', '\x9E', ' ', '\xE2', '\xB2', '\x90', ' ', '\xE2', '\xB3', '\x9C', ' ', '\xE2', '\xB2', '\xB0', /* ⳠⳘ Ⳟ Ⲏ Ⲟ ⲠⳜ Ⲱ */
- '\0',
- '\xE2', '\xB2', '\x8D', ' ', '\xE2', '\xB2', '\x8F', ' ', '\xE2', '\xB2', '\xA1', ' ', '\xE2', '\xB3', '\x9F', ' ', '\xE2', '\xB2', '\x9F', ' ', '\xE2', '\xB2', '\x91', ' ', '\xE2', '\xB2', '\xA5', ' ', '\xE2', '\xB3', '\x8B', /* ⲠⲠⲡ ⳟ ⲟ ⲑ ⲥ ⳋ */
- '\0',
- '\xE2', '\xB3', '\x91', ' ', '\xE2', '\xB3', '\x99', ' ', '\xE2', '\xB3', '\x9F', ' ', '\xE2', '\xB2', '\x8F', ' ', '\xE2', '\xB2', '\x9F', ' ', '\xE2', '\xB2', '\x91', ' ', '\xE2', '\xB3', '\x9D', ' ', '\xE2', '\xB3', '\x92', /* ⳑ ⳙ ⳟ Ⲡⲟ ⲑ ⳠⳒ */
- '\0',
- '\xF0', '\x90', '\xA0', '\x8D', ' ', '\xF0', '\x90', '\xA0', '\x99', ' ', '\xF0', '\x90', '\xA0', '\xB3', ' ', '\xF0', '\x90', '\xA0', '\xB1', ' ', '\xF0', '\x90', '\xA0', '\x85', ' ', '\xF0', '\x90', '\xA0', '\x93', ' ', '\xF0', '\x90', '\xA0', '\xA3', ' ', '\xF0', '\x90', '\xA0', '\xA6', /* ð  ð ™ ð ³ ð ± ð … ð “ ð £ ð ¦ */
- '\0',
- '\xF0', '\x90', '\xA0', '\x83', ' ', '\xF0', '\x90', '\xA0', '\x8A', ' ', '\xF0', '\x90', '\xA0', '\x9B', ' ', '\xF0', '\x90', '\xA0', '\xA3', ' ', '\xF0', '\x90', '\xA0', '\xB3', ' ', '\xF0', '\x90', '\xA0', '\xB5', ' ', '\xF0', '\x90', '\xA0', '\x90', /* ð ƒ ð Š ð › ð £ ð ³ ð µ ð  */
- '\0',
- '\xF0', '\x90', '\xA0', '\x88', ' ', '\xF0', '\x90', '\xA0', '\x8F', ' ', '\xF0', '\x90', '\xA0', '\x96', /* ð ˆ ð  ð – */
- '\0',
- '\xD0', '\x91', ' ', '\xD0', '\x92', ' ', '\xD0', '\x95', ' ', '\xD0', '\x9F', ' ', '\xD0', '\x97', ' ', '\xD0', '\x9E', ' ', '\xD0', '\xA1', ' ', '\xD0', '\xAD', /* Б В Е П З О С Э */
- '\0',
- '\xD0', '\x91', ' ', '\xD0', '\x92', ' ', '\xD0', '\x95', ' ', '\xD0', '\xA8', ' ', '\xD0', '\x97', ' ', '\xD0', '\x9E', ' ', '\xD0', '\xA1', ' ', '\xD0', '\xAD', /* Б В Е Ш З О С Э */
- '\0',
- '\xD1', '\x85', ' ', '\xD0', '\xBF', ' ', '\xD0', '\xBD', ' ', '\xD1', '\x88', ' ', '\xD0', '\xB5', ' ', '\xD0', '\xB7', ' ', '\xD0', '\xBE', ' ', '\xD1', '\x81', /* Ñ… п н ш е з о Ñ */
- '\0',
- '\xD1', '\x80', ' ', '\xD1', '\x83', ' ', '\xD1', '\x84', /* р у ф */
- '\0',
- '\xF0', '\x90', '\x90', '\x82', ' ', '\xF0', '\x90', '\x90', '\x84', ' ', '\xF0', '\x90', '\x90', '\x8B', ' ', '\xF0', '\x90', '\x90', '\x97', ' ', '\xF0', '\x90', '\x90', '\x91', /* ð‚ ð„ ð‹ ð— ð‘ */
- '\0',
- '\xF0', '\x90', '\x90', '\x80', ' ', '\xF0', '\x90', '\x90', '\x82', ' ', '\xF0', '\x90', '\x90', '\x84', ' ', '\xF0', '\x90', '\x90', '\x97', ' ', '\xF0', '\x90', '\x90', '\x9B', /* ð€ ð‚ ð„ ð— ð› */
- '\0',
- '\xF0', '\x90', '\x90', '\xAA', ' ', '\xF0', '\x90', '\x90', '\xAC', ' ', '\xF0', '\x90', '\x90', '\xB3', ' ', '\xF0', '\x90', '\x90', '\xBF', ' ', '\xF0', '\x90', '\x90', '\xB9', /* ðª ð¬ ð³ ð¿ ð¹ */
- '\0',
- '\xF0', '\x90', '\x90', '\xA8', ' ', '\xF0', '\x90', '\x90', '\xAA', ' ', '\xF0', '\x90', '\x90', '\xAC', ' ', '\xF0', '\x90', '\x90', '\xBF', ' ', '\xF0', '\x90', '\x91', '\x83', /* ð¨ ðª ð¬ ð¿ 𑃠*/
- '\0',
- '\xE0', '\xA4', '\x95', ' ', '\xE0', '\xA4', '\xA8', ' ', '\xE0', '\xA4', '\xAE', ' ', '\xE0', '\xA4', '\x89', ' ', '\xE0', '\xA4', '\x9B', ' ', '\xE0', '\xA4', '\x9F', ' ', '\xE0', '\xA4', '\xA0', ' ', '\xE0', '\xA4', '\xA1', /* क न म उ छ ट ठ ड */
- '\0',
- '\xE0', '\xA4', '\x88', ' ', '\xE0', '\xA4', '\x90', ' ', '\xE0', '\xA4', '\x93', ' ', '\xE0', '\xA4', '\x94', ' ', '\xE0', '\xA4', '\xBF', ' ', '\xE0', '\xA5', '\x80', ' ', '\xE0', '\xA5', '\x8B', ' ', '\xE0', '\xA5', '\x8C', /* ई ठओ औ ि ी ो ौ */
- '\0',
- '\xE0', '\xA4', '\x95', ' ', '\xE0', '\xA4', '\xAE', ' ', '\xE0', '\xA4', '\x85', ' ', '\xE0', '\xA4', '\x86', ' ', '\xE0', '\xA4', '\xA5', ' ', '\xE0', '\xA4', '\xA7', ' ', '\xE0', '\xA4', '\xAD', ' ', '\xE0', '\xA4', '\xB6', /* क म अ आ थ ध भ श */
- '\0',
- '\xE0', '\xA5', '\x81', ' ', '\xE0', '\xA5', '\x83', /* ॠृ */
- '\0',
- '\xE1', '\x88', '\x80', ' ', '\xE1', '\x88', '\x83', ' ', '\xE1', '\x8B', '\x98', ' ', '\xE1', '\x8D', '\x90', ' ', '\xE1', '\x88', '\x9B', ' ', '\xE1', '\x89', '\xA0', ' ', '\xE1', '\x8B', '\x8B', ' ', '\xE1', '\x8B', '\x90', /* ሀ ሃ ዘ á ማ በ á‹‹ á‹ */
- '\0',
- '\xE1', '\x88', '\x88', ' ', '\xE1', '\x88', '\x90', ' ', '\xE1', '\x89', '\xA0', ' ', '\xE1', '\x8B', '\x98', ' ', '\xE1', '\x88', '\x80', ' ', '\xE1', '\x88', '\xAA', ' ', '\xE1', '\x8B', '\x90', ' ', '\xE1', '\x8C', '\xA8', /* ለ ሠበ ዘ ሀ ሪ ዠጨ */
- '\0',
- '\xE1', '\x83', '\x92', ' ', '\xE1', '\x83', '\x93', ' ', '\xE1', '\x83', '\x94', ' ', '\xE1', '\x83', '\x95', ' ', '\xE1', '\x83', '\x97', ' ', '\xE1', '\x83', '\x98', ' ', '\xE1', '\x83', '\x9D', ' ', '\xE1', '\x83', '\xA6', /* გ დ ე ვ თ ი რღ */
- '\0',
- '\xE1', '\x83', '\x90', ' ', '\xE1', '\x83', '\x96', ' ', '\xE1', '\x83', '\x9B', ' ', '\xE1', '\x83', '\xA1', ' ', '\xE1', '\x83', '\xA8', ' ', '\xE1', '\x83', '\xAB', ' ', '\xE1', '\x83', '\xAE', ' ', '\xE1', '\x83', '\x9E', /* რზ მ ს შ ძ ხ პ */
- '\0',
- '\xE1', '\x83', '\xA1', ' ', '\xE1', '\x83', '\xAE', ' ', '\xE1', '\x83', '\xA5', ' ', '\xE1', '\x83', '\x96', ' ', '\xE1', '\x83', '\x9B', ' ', '\xE1', '\x83', '\xA8', ' ', '\xE1', '\x83', '\xA9', ' ', '\xE1', '\x83', '\xAC', /* ს ხ ქ ზ მ შ ჩ წ */
- '\0',
- '\xE1', '\x83', '\x94', ' ', '\xE1', '\x83', '\x95', ' ', '\xE1', '\x83', '\x9F', ' ', '\xE1', '\x83', '\xA2', ' ', '\xE1', '\x83', '\xA3', ' ', '\xE1', '\x83', '\xA4', ' ', '\xE1', '\x83', '\xA5', ' ', '\xE1', '\x83', '\xA7', /* ე ვ ჟ ტ უ ფ ქ ყ */
- '\0',
- '\xE1', '\x82', '\xB1', ' ', '\xE1', '\x82', '\xA7', ' ', '\xE1', '\x82', '\xB9', ' ', '\xE1', '\x82', '\xBC', ' ', '\xE1', '\x82', '\xA4', ' ', '\xE1', '\x82', '\xA5', ' ', '\xE1', '\x82', '\xB3', ' ', '\xE1', '\x82', '\xBA', /* Ⴑ Ⴇ Ⴙ Ⴜ Ⴄ Ⴅ Ⴓ Ⴚ */
- '\0',
- '\xE1', '\x82', '\xA4', ' ', '\xE1', '\x82', '\xA5', ' ', '\xE1', '\x82', '\xA7', ' ', '\xE1', '\x82', '\xA8', ' ', '\xE1', '\x82', '\xA6', ' ', '\xE1', '\x82', '\xB1', ' ', '\xE1', '\x82', '\xAA', ' ', '\xE1', '\x82', '\xAB', /* Ⴄ Ⴅ Ⴇ Ⴈ Ⴆ Ⴑ Ⴊ Ⴋ */
- '\0',
- '\xE2', '\xB4', '\x81', ' ', '\xE2', '\xB4', '\x97', ' ', '\xE2', '\xB4', '\x82', ' ', '\xE2', '\xB4', '\x84', ' ', '\xE2', '\xB4', '\x85', ' ', '\xE2', '\xB4', '\x87', ' ', '\xE2', '\xB4', '\x94', ' ', '\xE2', '\xB4', '\x96', /* â´ â´— â´‚ â´„ â´… â´‡ â´” â´– */
- '\0',
- '\xE2', '\xB4', '\x88', ' ', '\xE2', '\xB4', '\x8C', ' ', '\xE2', '\xB4', '\x96', ' ', '\xE2', '\xB4', '\x8E', ' ', '\xE2', '\xB4', '\x83', ' ', '\xE2', '\xB4', '\x86', ' ', '\xE2', '\xB4', '\x8B', ' ', '\xE2', '\xB4', '\xA2', /* ⴈ ⴌ ⴖ ⴎ ⴃ ⴆ ⴋ ⴢ */
- '\0',
- '\xE2', '\xB4', '\x90', ' ', '\xE2', '\xB4', '\x91', ' ', '\xE2', '\xB4', '\x93', ' ', '\xE2', '\xB4', '\x95', ' ', '\xE2', '\xB4', '\x99', ' ', '\xE2', '\xB4', '\x9B', ' ', '\xE2', '\xB4', '\xA1', ' ', '\xE2', '\xB4', '\xA3', /* â´ â´‘ â´“ â´• â´™ â´› â´¡ â´£ */
- '\0',
- '\xE2', '\xB4', '\x84', ' ', '\xE2', '\xB4', '\x85', ' ', '\xE2', '\xB4', '\x94', ' ', '\xE2', '\xB4', '\x95', ' ', '\xE2', '\xB4', '\x81', ' ', '\xE2', '\xB4', '\x82', ' ', '\xE2', '\xB4', '\x98', ' ', '\xE2', '\xB4', '\x9D', /* â´„ â´… â´” â´• â´ â´‚ â´˜ â´ */
- '\0',
- '\xE1', '\xB2', '\x9C', ' ', '\xE1', '\xB2', '\x9F', ' ', '\xE1', '\xB2', '\xB3', ' ', '\xE1', '\xB2', '\xB8', ' ', '\xE1', '\xB2', '\x92', ' ', '\xE1', '\xB2', '\x94', ' ', '\xE1', '\xB2', '\x9D', ' ', '\xE1', '\xB2', '\xB4', /* Ნ Ჟ Ჳ Ჸ Გ Ე ᲠᲴ */
- '\0',
- '\xE1', '\xB2', '\x98', ' ', '\xE1', '\xB2', '\xB2', ' ', '\xE1', '\xB2', '\x9D', ' ', '\xE1', '\xB2', '\xA9', ' ', '\xE1', '\xB2', '\x9B', ' ', '\xE1', '\xB2', '\xA8', ' ', '\xE1', '\xB2', '\xAF', ' ', '\xE1', '\xB2', '\xBD', /* Ი Ჲ ᲠᲩ Მ Შ Ჯ Ჽ */
- '\0',
- '\xE2', '\xB0', '\x85', ' ', '\xE2', '\xB0', '\x94', ' ', '\xE2', '\xB0', '\xAA', ' ', '\xE2', '\xB0', '\x84', ' ', '\xE2', '\xB0', '\x82', ' ', '\xE2', '\xB0', '\x8A', ' ', '\xE2', '\xB0', '\xAB', ' ', '\xE2', '\xB0', '\x8B', /* â°… â°” â°ª â°„ â°‚ â°Š â°« â°‹ */
- '\0',
- '\xE2', '\xB0', '\x85', ' ', '\xE2', '\xB0', '\x84', ' ', '\xE2', '\xB0', '\x82', ' ', '\xE2', '\xB0', '\xAA', ' ', '\xE2', '\xB0', '\x9E', ' ', '\xE2', '\xB0', '\xA1', ' ', '\xE2', '\xB0', '\x8A', ' ', '\xE2', '\xB0', '\x94', /* â°… â°„ â°‚ â°ª â°ž â°¡ â°Š â°” */
- '\0',
- '\xE2', '\xB0', '\xB5', ' ', '\xE2', '\xB1', '\x84', ' ', '\xE2', '\xB1', '\x9A', ' ', '\xE2', '\xB0', '\xB4', ' ', '\xE2', '\xB0', '\xB2', ' ', '\xE2', '\xB0', '\xBA', ' ', '\xE2', '\xB1', '\x9B', ' ', '\xE2', '\xB0', '\xBB', /* ⰵ ⱄ ⱚ ⰴ ⰲ ⰺ ⱛ ⰻ */
- '\0',
- '\xE2', '\xB0', '\xB5', ' ', '\xE2', '\xB0', '\xB4', ' ', '\xE2', '\xB0', '\xB2', ' ', '\xE2', '\xB1', '\x9A', ' ', '\xE2', '\xB1', '\x8E', ' ', '\xE2', '\xB1', '\x91', ' ', '\xE2', '\xB0', '\xBA', ' ', '\xE2', '\xB1', '\x84', /* ⰵ ⰴ ⰲ ⱚ ⱎ ⱑ ⰺ ⱄ */
- '\0',
- '\xF0', '\x90', '\x8C', '\xB2', ' ', '\xF0', '\x90', '\x8C', '\xB6', ' ', '\xF0', '\x90', '\x8D', '\x80', ' ', '\xF0', '\x90', '\x8D', '\x84', ' ', '\xF0', '\x90', '\x8C', '\xB4', ' ', '\xF0', '\x90', '\x8D', '\x83', ' ', '\xF0', '\x90', '\x8D', '\x88', ' ', '\xF0', '\x90', '\x8C', '\xBE', /* ðŒ² ðŒ¶ ð€ ð„ ðŒ´ ðƒ ðˆ ðŒ¾ */
- '\0',
- '\xF0', '\x90', '\x8C', '\xB6', ' ', '\xF0', '\x90', '\x8C', '\xB4', ' ', '\xF0', '\x90', '\x8D', '\x83', ' ', '\xF0', '\x90', '\x8D', '\x88', /* ðŒ¶ ðŒ´ ðƒ ðˆ */
- '\0',
- '\xCE', '\x93', ' ', '\xCE', '\x92', ' ', '\xCE', '\x95', ' ', '\xCE', '\x96', ' ', '\xCE', '\x98', ' ', '\xCE', '\x9F', ' ', '\xCE', '\xA9', /* Γ Β Ε Ζ Θ Ο Ω */
- '\0',
- '\xCE', '\x92', ' ', '\xCE', '\x94', ' ', '\xCE', '\x96', ' ', '\xCE', '\x9E', ' ', '\xCE', '\x98', ' ', '\xCE', '\x9F', /* Β Δ Ζ Ξ Θ Ο */
- '\0',
- '\xCE', '\xB2', ' ', '\xCE', '\xB8', ' ', '\xCE', '\xB4', ' ', '\xCE', '\xB6', ' ', '\xCE', '\xBB', ' ', '\xCE', '\xBE', /* β θ δ ζ λ ξ */
- '\0',
- '\xCE', '\xB1', ' ', '\xCE', '\xB5', ' ', '\xCE', '\xB9', ' ', '\xCE', '\xBF', ' ', '\xCF', '\x80', ' ', '\xCF', '\x83', ' ', '\xCF', '\x84', ' ', '\xCF', '\x89', /* α ε ι ο π σ τ ω */
- '\0',
- '\xCE', '\xB2', ' ', '\xCE', '\xB3', ' ', '\xCE', '\xB7', ' ', '\xCE', '\xBC', ' ', '\xCF', '\x81', ' ', '\xCF', '\x86', ' ', '\xCF', '\x87', ' ', '\xCF', '\x88', /* β γ η μ Ï Ï† χ ψ */
- '\0',
- '\xE0', '\xAA', '\xA4', ' ', '\xE0', '\xAA', '\xA8', ' ', '\xE0', '\xAA', '\x8B', ' ', '\xE0', '\xAA', '\x8C', ' ', '\xE0', '\xAA', '\x9B', ' ', '\xE0', '\xAA', '\x9F', ' ', '\xE0', '\xAA', '\xB0', ' ', '\xE0', '\xAB', '\xA6', /* ત ન ઋ ઌ છ ટ ર ૦ */
- '\0',
- '\xE0', '\xAA', '\x96', ' ', '\xE0', '\xAA', '\x97', ' ', '\xE0', '\xAA', '\x98', ' ', '\xE0', '\xAA', '\x9E', ' ', '\xE0', '\xAA', '\x87', ' ', '\xE0', '\xAA', '\x88', ' ', '\xE0', '\xAA', '\xA0', ' ', '\xE0', '\xAA', '\x9C', /* ખ ગ ઘ ઞ ઇ ઈ ઠ જ */
- '\0',
- '\xE0', '\xAA', '\x88', ' ', '\xE0', '\xAA', '\x8A', ' ', '\xE0', '\xAA', '\xBF', ' ', '\xE0', '\xAB', '\x80', ' ', '\xE0', '\xAA', '\xB2', '\xE0', '\xAB', '\x80', ' ', '\xE0', '\xAA', '\xB6', '\xE0', '\xAB', '\x8D', '\xE0', '\xAA', '\x9A', '\xE0', '\xAA', '\xBF', ' ', '\xE0', '\xAA', '\x9C', '\xE0', '\xAA', '\xBF', ' ', '\xE0', '\xAA', '\xB8', '\xE0', '\xAB', '\x80', /* ઈ ઊ િ à«€ લી શà«àªšàª¿ જિ સી */
- '\0',
- '\xE0', '\xAB', '\x81', ' ', '\xE0', '\xAB', '\x83', ' ', '\xE0', '\xAB', '\x84', ' ', '\xE0', '\xAA', '\x96', '\xE0', '\xAB', '\x81', ' ', '\xE0', '\xAA', '\x9B', '\xE0', '\xAB', '\x83', ' ', '\xE0', '\xAA', '\x9B', '\xE0', '\xAB', '\x84', /* ૠૃ ૄ ખૠછૃ છૄ */
- '\0',
- '\xE0', '\xAB', '\xA6', ' ', '\xE0', '\xAB', '\xA7', ' ', '\xE0', '\xAB', '\xA8', ' ', '\xE0', '\xAB', '\xA9', ' ', '\xE0', '\xAB', '\xAD', /* ૦ ૧ ૨ ૩ ૭ */
- '\0',
- '\xE0', '\xA8', '\x95', ' ', '\xE0', '\xA8', '\x97', ' ', '\xE0', '\xA8', '\x99', ' ', '\xE0', '\xA8', '\x9A', ' ', '\xE0', '\xA8', '\x9C', ' ', '\xE0', '\xA8', '\xA4', ' ', '\xE0', '\xA8', '\xA7', ' ', '\xE0', '\xA8', '\xB8', /* ਕ ਗ ਙ ਚ ਜ ਤ ਧ ਸ */
- '\0',
- '\xE0', '\xA8', '\x95', ' ', '\xE0', '\xA8', '\x97', ' ', '\xE0', '\xA8', '\x99', ' ', '\xE0', '\xA8', '\x9A', ' ', '\xE0', '\xA8', '\x9C', ' ', '\xE0', '\xA8', '\xA4', ' ', '\xE0', '\xA8', '\xA7', ' ', '\xE0', '\xA8', '\xB8', /* ਕ ਗ ਙ ਚ ਜ ਤ ਧ ਸ */
- '\0',
- '\xE0', '\xA8', '\x87', ' ', '\xE0', '\xA8', '\x88', ' ', '\xE0', '\xA8', '\x89', ' ', '\xE0', '\xA8', '\x8F', ' ', '\xE0', '\xA8', '\x93', ' ', '\xE0', '\xA9', '\xB3', ' ', '\xE0', '\xA8', '\xBF', ' ', '\xE0', '\xA9', '\x80', /* ਇ ਈ ਉ ਠਓ ੳ ਿ ੀ */
- '\0',
- '\xE0', '\xA8', '\x85', ' ', '\xE0', '\xA8', '\x8F', ' ', '\xE0', '\xA8', '\x93', ' ', '\xE0', '\xA8', '\x97', ' ', '\xE0', '\xA8', '\x9C', ' ', '\xE0', '\xA8', '\xA0', ' ', '\xE0', '\xA8', '\xB0', ' ', '\xE0', '\xA8', '\xB8', /* ਅ ਠਓ ਗ ਜ ਠ ਰ ਸ */
- '\0',
- '\xE0', '\xA9', '\xA6', ' ', '\xE0', '\xA9', '\xA7', ' ', '\xE0', '\xA9', '\xA8', ' ', '\xE0', '\xA9', '\xA9', ' ', '\xE0', '\xA9', '\xAD', /* ੦ ੧ ੨ ੩ ੭ */
- '\0',
- '\xD7', '\x91', ' ', '\xD7', '\x93', ' ', '\xD7', '\x94', ' ', '\xD7', '\x97', ' ', '\xD7', '\x9A', ' ', '\xD7', '\x9B', ' ', '\xD7', '\x9D', ' ', '\xD7', '\xA1', /* ב ד ×” ×— ך ×› × ×¡ */
- '\0',
- '\xD7', '\x91', ' ', '\xD7', '\x98', ' ', '\xD7', '\x9B', ' ', '\xD7', '\x9D', ' ', '\xD7', '\xA1', ' ', '\xD7', '\xA6', /* ב ט ×› × ×¡ צ */
- '\0',
- '\xD7', '\xA7', ' ', '\xD7', '\x9A', ' ', '\xD7', '\x9F', ' ', '\xD7', '\xA3', ' ', '\xD7', '\xA5', /* ק ך ן ף ץ */
- '\0',
- '\xE0', '\xB2', '\x87', ' ', '\xE0', '\xB2', '\x8A', ' ', '\xE0', '\xB2', '\x90', ' ', '\xE0', '\xB2', '\xA3', ' ', '\xE0', '\xB2', '\xB8', '\xE0', '\xB2', '\xBE', ' ', '\xE0', '\xB2', '\xA8', '\xE0', '\xB2', '\xBE', ' ', '\xE0', '\xB2', '\xA6', '\xE0', '\xB2', '\xBE', ' ', '\xE0', '\xB2', '\xB0', '\xE0', '\xB2', '\xBE', /* ಇ ಊ ಠಣ ಸಾ ನಾ ದಾ ರಾ */
- '\0',
- '\xE0', '\xB2', '\x85', ' ', '\xE0', '\xB2', '\x89', ' ', '\xE0', '\xB2', '\x8E', ' ', '\xE0', '\xB2', '\xB2', ' ', '\xE0', '\xB3', '\xA6', ' ', '\xE0', '\xB3', '\xA8', ' ', '\xE0', '\xB3', '\xAC', ' ', '\xE0', '\xB3', '\xAD', /* ಅ ಉ ಎ ಲ ೦ ೨ ೬ ೭ */
- '\0',
- '\xEA', '\xA4', '\x85', ' ', '\xEA', '\xA4', '\x8F', ' ', '\xEA', '\xA4', '\x81', ' ', '\xEA', '\xA4', '\x8B', ' ', '\xEA', '\xA4', '\x80', ' ', '\xEA', '\xA4', '\x8D', /* ꤅ ê¤ ê¤ ê¤‹ ꤀ ê¤ */
- '\0',
- '\xEA', '\xA4', '\x88', ' ', '\xEA', '\xA4', '\x98', ' ', '\xEA', '\xA4', '\x80', ' ', '\xEA', '\xA4', '\x8D', ' ', '\xEA', '\xA4', '\xA2', /* ꤈ ꤘ ꤀ ê¤ ê¤¢ */
- '\0',
- '\xEA', '\xA4', '\x96', ' ', '\xEA', '\xA4', '\xA1', /* ꤖ ꤡ */
- '\0',
- '\xEA', '\xA4', '\x91', ' ', '\xEA', '\xA4', '\x9C', ' ', '\xEA', '\xA4', '\x9E', /* ꤑ ꤜ ꤞ */
- '\0',
- '\xEA', '\xA4', '\x91', '\xEA', '\xA4', '\xAC', ' ', '\xEA', '\xA4', '\x9C', '\xEA', '\xA4', '\xAD', ' ', '\xEA', '\xA4', '\x94', '\xEA', '\xA4', '\xAC', /* ꤑ꤬ ꤜ꤭ ꤔ꤬ */
- '\0',
- '\xE1', '\x9E', '\x81', ' ', '\xE1', '\x9E', '\x91', ' ', '\xE1', '\x9E', '\x93', ' ', '\xE1', '\x9E', '\xA7', ' ', '\xE1', '\x9E', '\xA9', ' ', '\xE1', '\x9E', '\xB6', /* ហទ ន ឧ ឩ ា */
- '\0',
- '\xE1', '\x9E', '\x80', '\xE1', '\x9F', '\x92', '\xE1', '\x9E', '\x80', ' ', '\xE1', '\x9E', '\x80', '\xE1', '\x9F', '\x92', '\xE1', '\x9E', '\x81', ' ', '\xE1', '\x9E', '\x80', '\xE1', '\x9F', '\x92', '\xE1', '\x9E', '\x82', ' ', '\xE1', '\x9E', '\x80', '\xE1', '\x9F', '\x92', '\xE1', '\x9E', '\x90', /* ក្ក ក្ហក្គ ក្ហ*/
- '\0',
- '\xE1', '\x9E', '\x81', ' ', '\xE1', '\x9E', '\x83', ' ', '\xE1', '\x9E', '\x85', ' ', '\xE1', '\x9E', '\x8B', ' ', '\xE1', '\x9E', '\x94', ' ', '\xE1', '\x9E', '\x98', ' ', '\xE1', '\x9E', '\x99', ' ', '\xE1', '\x9E', '\xB2', /* ហឃ ច ឋ ប ម យ ឲ */
- '\0',
- '\xE1', '\x9E', '\x8F', '\xE1', '\x9F', '\x92', '\xE1', '\x9E', '\x9A', ' ', '\xE1', '\x9E', '\x9A', '\xE1', '\x9F', '\x80', ' ', '\xE1', '\x9E', '\xB2', '\xE1', '\x9F', '\x92', '\xE1', '\x9E', '\x99', ' ', '\xE1', '\x9E', '\xA2', '\xE1', '\x9E', '\xBF', /* ážáŸ’ážš រៀ ឲ្យ អឿ */
- '\0',
- '\xE1', '\x9E', '\x93', '\xE1', '\x9F', '\x92', '\xE1', '\x9E', '\x8F', '\xE1', '\x9F', '\x92', '\xE1', '\x9E', '\x9A', '\xE1', '\x9F', '\x83', ' ', '\xE1', '\x9E', '\x84', '\xE1', '\x9F', '\x92', '\xE1', '\x9E', '\x81', '\xE1', '\x9F', '\x92', '\xE1', '\x9E', '\x99', ' ', '\xE1', '\x9E', '\x80', '\xE1', '\x9F', '\x92', '\xE1', '\x9E', '\x94', '\xE1', '\x9F', '\x80', ' ', '\xE1', '\x9E', '\x85', '\xE1', '\x9F', '\x92', '\xE1', '\x9E', '\x9A', '\xE1', '\x9F', '\x80', ' ', '\xE1', '\x9E', '\x93', '\xE1', '\x9F', '\x92', '\xE1', '\x9E', '\x8F', '\xE1', '\x9E', '\xBF', ' ', '\xE1', '\x9E', '\x9B', '\xE1', '\x9F', '\x92', '\xE1', '\x9E', '\x94', '\xE1', '\x9E', '\xBF', /* ន្ážáŸ’រៃ ង្ážáŸ’áž™ ក្បៀ ច្រៀ ន្ážáž¿ ល្បឿ */
- '\0',
- '\xE1', '\xA7', '\xA0', ' ', '\xE1', '\xA7', '\xA1', /* ᧠ ᧡ */
- '\0',
- '\xE1', '\xA7', '\xB6', ' ', '\xE1', '\xA7', '\xB9', /* ᧶ ᧹ */
- '\0',
- '\xE0', '\xBA', '\xB2', ' ', '\xE0', '\xBA', '\x94', ' ', '\xE0', '\xBA', '\xAD', ' ', '\xE0', '\xBA', '\xA1', ' ', '\xE0', '\xBA', '\xA5', ' ', '\xE0', '\xBA', '\xA7', ' ', '\xE0', '\xBA', '\xA3', ' ', '\xE0', '\xBA', '\x87', /* າ ດ ອ ມ ລ ວ ຣ ງ */
- '\0',
- '\xE0', '\xBA', '\xB2', ' ', '\xE0', '\xBA', '\xAD', ' ', '\xE0', '\xBA', '\x9A', ' ', '\xE0', '\xBA', '\x8D', ' ', '\xE0', '\xBA', '\xA3', ' ', '\xE0', '\xBA', '\xAE', ' ', '\xE0', '\xBA', '\xA7', ' ', '\xE0', '\xBA', '\xA2', /* າ ອ ບ ຠຣ ຮ ວ ຢ */
- '\0',
- '\xE0', '\xBA', '\x9B', ' ', '\xE0', '\xBA', '\xA2', ' ', '\xE0', '\xBA', '\x9F', ' ', '\xE0', '\xBA', '\x9D', /* ປ ຢ ຟ ຠ*/
- '\0',
- '\xE0', '\xBB', '\x82', ' ', '\xE0', '\xBB', '\x84', ' ', '\xE0', '\xBB', '\x83', /* ໂ ໄ ໃ */
- '\0',
- '\xE0', '\xBA', '\x87', ' ', '\xE0', '\xBA', '\x8A', ' ', '\xE0', '\xBA', '\x96', ' ', '\xE0', '\xBA', '\xBD', ' ', '\xE0', '\xBB', '\x86', ' ', '\xE0', '\xBA', '\xAF', /* ງ ຊ ຖ ຽ ໆ ຯ */
- '\0',
- 'T', ' ', 'H', ' ', 'E', ' ', 'Z', ' ', 'O', ' ', 'C', ' ', 'Q', ' ', 'S', /* T H E Z O C Q S */
- '\0',
- 'H', ' ', 'E', ' ', 'Z', ' ', 'L', ' ', 'O', ' ', 'C', ' ', 'U', ' ', 'S', /* H E Z L O C U S */
- '\0',
- 'f', ' ', 'i', ' ', 'j', ' ', 'k', ' ', 'd', ' ', 'b', ' ', 'h', /* f i j k d b h */
- '\0',
- 'u', ' ', 'v', ' ', 'x', ' ', 'z', ' ', 'o', ' ', 'e', ' ', 's', ' ', 'c', /* u v x z o e s c */
- '\0',
- 'n', ' ', 'r', ' ', 'x', ' ', 'z', ' ', 'o', ' ', 'e', ' ', 's', ' ', 'c', /* n r x z o e s c */
- '\0',
- 'p', ' ', 'q', ' ', 'g', ' ', 'j', ' ', 'y', /* p q g j y */
- '\0',
- '\xE2', '\x82', '\x80', ' ', '\xE2', '\x82', '\x83', ' ', '\xE2', '\x82', '\x85', ' ', '\xE2', '\x82', '\x87', ' ', '\xE2', '\x82', '\x88', /* ₀ ₃ ₅ ₇ ₈ */
- '\0',
- '\xE2', '\x82', '\x80', ' ', '\xE2', '\x82', '\x81', ' ', '\xE2', '\x82', '\x82', ' ', '\xE2', '\x82', '\x83', ' ', '\xE2', '\x82', '\x88', /* ₀ ₠₂ ₃ ₈ */
- '\0',
- '\xE1', '\xB5', '\xA2', ' ', '\xE2', '\xB1', '\xBC', ' ', '\xE2', '\x82', '\x95', ' ', '\xE2', '\x82', '\x96', ' ', '\xE2', '\x82', '\x97', /* áµ¢ â±¼ â‚• â‚– â‚— */
- '\0',
- '\xE2', '\x82', '\x90', ' ', '\xE2', '\x82', '\x91', ' ', '\xE2', '\x82', '\x92', ' ', '\xE2', '\x82', '\x93', ' ', '\xE2', '\x82', '\x99', ' ', '\xE2', '\x82', '\x9B', ' ', '\xE1', '\xB5', '\xA5', ' ', '\xE1', '\xB5', '\xA4', ' ', '\xE1', '\xB5', '\xA3', /* ₠ₑ ₒ ₓ ₙ ₛ ᵥ ᵤ ᵣ */
- '\0',
- '\xE1', '\xB5', '\xA6', ' ', '\xE1', '\xB5', '\xA7', ' ', '\xE1', '\xB5', '\xA8', ' ', '\xE1', '\xB5', '\xA9', ' ', '\xE2', '\x82', '\x9A', /* ᵦ ᵧ ᵨ ᵩ ₚ */
- '\0',
- '\xE2', '\x81', '\xB0', ' ', '\xC2', '\xB3', ' ', '\xE2', '\x81', '\xB5', ' ', '\xE2', '\x81', '\xB7', ' ', '\xE1', '\xB5', '\x80', ' ', '\xE1', '\xB4', '\xB4', ' ', '\xE1', '\xB4', '\xB1', ' ', '\xE1', '\xB4', '\xBC', /* Ⱐ³ ⵠⷠᵀ ᴴ ᴱ ᴼ */
- '\0',
- '\xE2', '\x81', '\xB0', ' ', '\xC2', '\xB9', ' ', '\xC2', '\xB2', ' ', '\xC2', '\xB3', ' ', '\xE1', '\xB4', '\xB1', ' ', '\xE1', '\xB4', '\xB8', ' ', '\xE1', '\xB4', '\xBC', ' ', '\xE1', '\xB5', '\x81', /* Ⱐ¹ ² ³ ᴱ ᴸ ᴼ ᵠ*/
- '\0',
- '\xE1', '\xB5', '\x87', ' ', '\xE1', '\xB5', '\x88', ' ', '\xE1', '\xB5', '\x8F', ' ', '\xCA', '\xB0', ' ', '\xCA', '\xB2', ' ', '\xE1', '\xB6', '\xA0', ' ', '\xE2', '\x81', '\xB1', /* ᵇ ᵈ ᵠʰ ʲ ᶠ Ⱡ*/
- '\0',
- '\xE1', '\xB5', '\x89', ' ', '\xE1', '\xB5', '\x92', ' ', '\xCA', '\xB3', ' ', '\xCB', '\xA2', ' ', '\xCB', '\xA3', ' ', '\xE1', '\xB6', '\x9C', ' ', '\xE1', '\xB6', '\xBB', /* ᵉ ᵒ ʳ ˢ ˣ ᶜ ᶻ */
- '\0',
- '\xE1', '\xB5', '\x96', ' ', '\xCA', '\xB8', ' ', '\xE1', '\xB5', '\x8D', /* ᵖ ʸ ᵠ*/
- '\0',
- '\xEA', '\x93', '\xA1', ' ', '\xEA', '\x93', '\xA7', ' ', '\xEA', '\x93', '\xB1', ' ', '\xEA', '\x93', '\xB6', ' ', '\xEA', '\x93', '\xA9', ' ', '\xEA', '\x93', '\x9A', ' ', '\xEA', '\x93', '\xB5', ' ', '\xEA', '\x93', '\xB3', /* ꓡ ꓧ ꓱ ꓶ ꓩ ꓚ ꓵ ꓳ */
- '\0',
- '\xEA', '\x93', '\x95', ' ', '\xEA', '\x93', '\x9C', ' ', '\xEA', '\x93', '\x9E', ' ', '\xEA', '\x93', '\xA1', ' ', '\xEA', '\x93', '\x9B', ' ', '\xEA', '\x93', '\xA2', ' ', '\xEA', '\x93', '\xB3', ' ', '\xEA', '\x93', '\xB4', /* ꓕ ꓜ ꓞ ꓡ ꓛ ꓢ ꓳ ꓴ */
- '\0',
- '\xE0', '\xB4', '\x92', ' ', '\xE0', '\xB4', '\x9F', ' ', '\xE0', '\xB4', '\xA0', ' ', '\xE0', '\xB4', '\xB1', ' ', '\xE0', '\xB4', '\x9A', ' ', '\xE0', '\xB4', '\xAA', ' ', '\xE0', '\xB4', '\x9A', '\xE0', '\xB5', '\x8D', '\xE0', '\xB4', '\x9A', ' ', '\xE0', '\xB4', '\xAA', '\xE0', '\xB5', '\x8D', '\xE0', '\xB4', '\xAA', /* à´’ à´Ÿ à´  à´± à´š à´ª à´šàµà´š à´ªàµà´ª */
- '\0',
- '\xE0', '\xB4', '\x9F', ' ', '\xE0', '\xB4', '\xA0', ' ', '\xE0', '\xB4', '\xA7', ' ', '\xE0', '\xB4', '\xB6', ' ', '\xE0', '\xB4', '\x98', ' ', '\xE0', '\xB4', '\x9A', ' ', '\xE0', '\xB4', '\xA5', ' ', '\xE0', '\xB4', '\xB2', /* à´Ÿ à´  à´§ à´¶ à´˜ à´š à´¥ à´² */
- '\0',
- '\xF0', '\x96', '\xB9', '\x80', ' ', '\xF0', '\x96', '\xB9', '\x81', ' ', '\xF0', '\x96', '\xB9', '\x82', ' ', '\xF0', '\x96', '\xB9', '\x83', ' ', '\xF0', '\x96', '\xB9', '\x8F', ' ', '\xF0', '\x96', '\xB9', '\x9A', ' ', '\xF0', '\x96', '\xB9', '\x9F', /* 𖹀 𖹠𖹂 𖹃 𖹠𖹚 𖹟 */
- '\0',
- '\xF0', '\x96', '\xB9', '\x80', ' ', '\xF0', '\x96', '\xB9', '\x81', ' ', '\xF0', '\x96', '\xB9', '\x82', ' ', '\xF0', '\x96', '\xB9', '\x83', ' ', '\xF0', '\x96', '\xB9', '\x8F', ' ', '\xF0', '\x96', '\xB9', '\x9A', ' ', '\xF0', '\x96', '\xB9', '\x92', ' ', '\xF0', '\x96', '\xB9', '\x93', /* 𖹀 𖹠𖹂 𖹃 𖹠𖹚 𖹒 𖹓 */
- '\0',
- '\xF0', '\x96', '\xB9', '\xA4', ' ', '\xF0', '\x96', '\xB9', '\xAC', ' ', '\xF0', '\x96', '\xB9', '\xA7', ' ', '\xF0', '\x96', '\xB9', '\xB4', ' ', '\xF0', '\x96', '\xB9', '\xB6', ' ', '\xF0', '\x96', '\xB9', '\xBE', /* 𖹤 𖹬 𖹧 𖹴 𖹶 𖹾 */
- '\0',
- '\xF0', '\x96', '\xB9', '\xA0', ' ', '\xF0', '\x96', '\xB9', '\xA1', ' ', '\xF0', '\x96', '\xB9', '\xA2', ' ', '\xF0', '\x96', '\xB9', '\xB9', ' ', '\xF0', '\x96', '\xB9', '\xB3', ' ', '\xF0', '\x96', '\xB9', '\xAE', /* 𖹠 𖹡 𖹢 𖹹 𖹳 𖹮 */
- '\0',
- '\xF0', '\x96', '\xB9', '\xA0', ' ', '\xF0', '\x96', '\xB9', '\xA1', ' ', '\xF0', '\x96', '\xB9', '\xA2', ' ', '\xF0', '\x96', '\xB9', '\xB3', ' ', '\xF0', '\x96', '\xB9', '\xAD', ' ', '\xF0', '\x96', '\xB9', '\xBD', /* 𖹠 𖹡 𖹢 𖹳 𖹭 𖹽 */
- '\0',
- '\xF0', '\x96', '\xB9', '\xA5', ' ', '\xF0', '\x96', '\xB9', '\xA8', ' ', '\xF0', '\x96', '\xB9', '\xA9', /* 𖹥 𖹨 𖹩 */
- '\0',
- '\xF0', '\x96', '\xBA', '\x80', ' ', '\xF0', '\x96', '\xBA', '\x85', ' ', '\xF0', '\x96', '\xBA', '\x88', ' ', '\xF0', '\x96', '\xBA', '\x84', ' ', '\xF0', '\x96', '\xBA', '\x8D', /* 𖺀 𖺅 𖺈 𖺄 𖺠*/
- '\0',
- '\xE1', '\xA0', '\xB3', ' ', '\xE1', '\xA0', '\xB4', ' ', '\xE1', '\xA0', '\xB6', ' ', '\xE1', '\xA0', '\xBD', ' ', '\xE1', '\xA1', '\x82', ' ', '\xE1', '\xA1', '\x8A', ' ', '\xE2', '\x80', '\x8D', '\xE1', '\xA1', '\xA1', '\xE2', '\x80', '\x8D', ' ', '\xE2', '\x80', '\x8D', '\xE1', '\xA1', '\xB3', '\xE2', '\x80', '\x8D', /* á ³ á ´ á ¶ á ½ á¡‚ á¡Š â€á¡¡â€ â€á¡³â€ */
- '\0',
- '\xE1', '\xA1', '\x83', /* ᡃ */
- '\0',
- '\xE1', '\x80', '\x81', ' ', '\xE1', '\x80', '\x82', ' ', '\xE1', '\x80', '\x84', ' ', '\xE1', '\x80', '\x92', ' ', '\xE1', '\x80', '\x9D', ' ', '\xE1', '\x81', '\xA5', ' ', '\xE1', '\x81', '\x8A', ' ', '\xE1', '\x81', '\x8B', /* ဠဂ င ဒ ဠᥠአዠ*/
- '\0',
- '\xE1', '\x80', '\x84', ' ', '\xE1', '\x80', '\x8E', ' ', '\xE1', '\x80', '\x92', ' ', '\xE1', '\x80', '\x95', ' ', '\xE1', '\x80', '\x97', ' ', '\xE1', '\x80', '\x9D', ' ', '\xE1', '\x81', '\x8A', ' ', '\xE1', '\x81', '\x8B', /* င ဎ ဒ ပ ဗ ဠአዠ*/
- '\0',
- '\xE1', '\x80', '\xA9', ' ', '\xE1', '\x80', '\xBC', ' ', '\xE1', '\x81', '\x8D', ' ', '\xE1', '\x81', '\x8F', ' ', '\xE1', '\x81', '\x86', ' ', '\xE1', '\x80', '\xAB', ' ', '\xE1', '\x80', '\xAD', /* ဩ ြ á á ᆠါ ိ */
- '\0',
- '\xE1', '\x80', '\x89', ' ', '\xE1', '\x80', '\x8A', ' ', '\xE1', '\x80', '\xA5', ' ', '\xE1', '\x80', '\xA9', ' ', '\xE1', '\x80', '\xA8', ' ', '\xE1', '\x81', '\x82', ' ', '\xE1', '\x81', '\x85', ' ', '\xE1', '\x81', '\x89', /* ဉ ည ဥ ဩ ဨ á‚ á… á‰ */
- '\0',
- '\xDF', '\x90', ' ', '\xDF', '\x89', ' ', '\xDF', '\x92', ' ', '\xDF', '\x9F', ' ', '\xDF', '\x96', ' ', '\xDF', '\x9C', ' ', '\xDF', '\xA0', ' ', '\xDF', '\xA5', /* ß ß‰ ß’ ߟ ß– ßœ ß  ߥ */
- '\0',
- '\xDF', '\x80', ' ', '\xDF', '\x98', ' ', '\xDF', '\xA1', ' ', '\xDF', '\xA0', ' ', '\xDF', '\xA5', /* ߀ ߘ ߡ ߠ ߥ */
- '\0',
- '\xDF', '\x8F', ' ', '\xDF', '\x9B', ' ', '\xDF', '\x8B', /* ß ß› ß‹ */
- '\0',
- '\xDF', '\x8E', ' ', '\xDF', '\x8F', ' ', '\xDF', '\x9B', ' ', '\xDF', '\x8B', /* ߎ ß ß› ß‹ */
- '\0',
- '\xE1', '\xB1', '\x9B', ' ', '\xE1', '\xB1', '\x9C', ' ', '\xE1', '\xB1', '\x9D', ' ', '\xE1', '\xB1', '\xA1', ' ', '\xE1', '\xB1', '\xA2', ' ', '\xE1', '\xB1', '\xA5', /* ᱛ ᱜ ᱠᱡ ᱢ ᱥ */
- '\0',
- '\xF0', '\x90', '\xB0', '\x97', ' ', '\xF0', '\x90', '\xB0', '\x98', ' ', '\xF0', '\x90', '\xB0', '\xA7', /* ð°— ð°˜ ð°§ */
- '\0',
- '\xF0', '\x90', '\xB0', '\x89', ' ', '\xF0', '\x90', '\xB0', '\x97', ' ', '\xF0', '\x90', '\xB0', '\xA6', ' ', '\xF0', '\x90', '\xB0', '\xA7', /* ð°‰ ð°— ð°¦ ð°§ */
- '\0',
- '\xF0', '\x90', '\x92', '\xBE', ' ', '\xF0', '\x90', '\x93', '\x8D', ' ', '\xF0', '\x90', '\x93', '\x92', ' ', '\xF0', '\x90', '\x93', '\x93', ' ', '\xF0', '\x90', '\x92', '\xBB', ' ', '\xF0', '\x90', '\x93', '\x82', ' ', '\xF0', '\x90', '\x92', '\xB5', ' ', '\xF0', '\x90', '\x93', '\x86', /* ð’¾ ð“ 𓒠𓓠𒻠𓂠𒵠𓆠*/
- '\0',
- '\xF0', '\x90', '\x92', '\xB0', ' ', '\xF0', '\x90', '\x93', '\x8D', ' ', '\xF0', '\x90', '\x93', '\x82', ' ', '\xF0', '\x90', '\x92', '\xBF', ' ', '\xF0', '\x90', '\x93', '\x8E', ' ', '\xF0', '\x90', '\x92', '\xB9', /* ð’° ð“ ð“‚ ð’¿ ð“Ž ð’¹ */
- '\0',
- '\xF0', '\x90', '\x92', '\xBC', ' ', '\xF0', '\x90', '\x92', '\xBD', ' ', '\xF0', '\x90', '\x92', '\xBE', /* ð’¼ ð’½ ð’¾ */
- '\0',
- '\xF0', '\x90', '\x93', '\xB5', ' ', '\xF0', '\x90', '\x93', '\xB6', ' ', '\xF0', '\x90', '\x93', '\xBA', ' ', '\xF0', '\x90', '\x93', '\xBB', ' ', '\xF0', '\x90', '\x93', '\x9D', ' ', '\xF0', '\x90', '\x93', '\xA3', ' ', '\xF0', '\x90', '\x93', '\xAA', ' ', '\xF0', '\x90', '\x93', '\xAE', /* 𓵠𓶠𓺠𓻠ð“ 𓣠𓪠𓮠*/
- '\0',
- '\xF0', '\x90', '\x93', '\x98', ' ', '\xF0', '\x90', '\x93', '\x9A', ' ', '\xF0', '\x90', '\x93', '\xA3', ' ', '\xF0', '\x90', '\x93', '\xB5', ' ', '\xF0', '\x90', '\x93', '\xA1', ' ', '\xF0', '\x90', '\x93', '\xA7', ' ', '\xF0', '\x90', '\x93', '\xAA', ' ', '\xF0', '\x90', '\x93', '\xB6', /* 𓘠𓚠𓣠𓵠𓡠𓧠𓪠𓶠*/
- '\0',
- '\xF0', '\x90', '\x93', '\xA4', ' ', '\xF0', '\x90', '\x93', '\xA6', ' ', '\xF0', '\x90', '\x93', '\xB8', ' ', '\xF0', '\x90', '\x93', '\xB9', ' ', '\xF0', '\x90', '\x93', '\x9B', /* 𓤠𓦠𓸠𓹠𓛠*/
- '\0',
- '\xF0', '\x90', '\x93', '\xA4', ' ', '\xF0', '\x90', '\x93', '\xA5', ' ', '\xF0', '\x90', '\x93', '\xA6', /* 𓤠𓥠𓦠*/
- '\0',
- '\xF0', '\x90', '\x92', '\x86', ' ', '\xF0', '\x90', '\x92', '\x89', ' ', '\xF0', '\x90', '\x92', '\x90', ' ', '\xF0', '\x90', '\x92', '\x92', ' ', '\xF0', '\x90', '\x92', '\x98', ' ', '\xF0', '\x90', '\x92', '\x9B', ' ', '\xF0', '\x90', '\x92', '\xA0', ' ', '\xF0', '\x90', '\x92', '\xA3', /* ð’† ð’‰ ð’ ð’’ ð’˜ ð’› ð’  ð’£ */
- '\0',
- '\xF0', '\x90', '\x92', '\x80', ' ', '\xF0', '\x90', '\x92', '\x82', ' ', '\xF0', '\x90', '\x92', '\x86', ' ', '\xF0', '\x90', '\x92', '\x88', ' ', '\xF0', '\x90', '\x92', '\x8A', ' ', '\xF0', '\x90', '\x92', '\x92', ' ', '\xF0', '\x90', '\x92', '\xA0', ' ', '\xF0', '\x90', '\x92', '\xA9', /* ð’€ ð’‚ ð’† ð’ˆ ð’Š ð’’ ð’  ð’© */
- '\0',
- '\xF0', '\x90', '\xB4', '\x83', ' ', '\xF0', '\x90', '\xB4', '\x80', ' ', '\xF0', '\x90', '\xB4', '\x86', ' ', '\xF0', '\x90', '\xB4', '\x96', ' ', '\xF0', '\x90', '\xB4', '\x95', /* ð´ƒ ð´€ ð´† ð´– ð´• */
- '\0',
- '\xF0', '\x90', '\xB4', '\x94', ' ', '\xF0', '\x90', '\xB4', '\x96', ' ', '\xF0', '\x90', '\xB4', '\x95', ' ', '\xF0', '\x90', '\xB4', '\x91', ' ', '\xF0', '\x90', '\xB4', '\x90', /* ð´” ð´– ð´• ð´‘ ð´ */
- '\0',
- '\xD9', '\x80', /* Ù€ */
- '\0',
- '\xEA', '\xA2', '\x9C', ' ', '\xEA', '\xA2', '\x9E', ' ', '\xEA', '\xA2', '\xB3', ' ', '\xEA', '\xA2', '\x82', ' ', '\xEA', '\xA2', '\x96', ' ', '\xEA', '\xA2', '\x92', ' ', '\xEA', '\xA2', '\x9D', ' ', '\xEA', '\xA2', '\x9B', /* ꢜ ꢞ ꢳ ꢂ ꢖ ꢒ ê¢ ê¢› */
- '\0',
- '\xEA', '\xA2', '\x82', ' ', '\xEA', '\xA2', '\xA8', ' ', '\xEA', '\xA2', '\xBA', ' ', '\xEA', '\xA2', '\xA4', ' ', '\xEA', '\xA2', '\x8E', /* ꢂ ꢨ ꢺ ꢤ ꢎ */
- '\0',
- '\xF0', '\x90', '\x91', '\x95', ' ', '\xF0', '\x90', '\x91', '\x99', /* ð‘• ð‘™ */
- '\0',
- '\xF0', '\x90', '\x91', '\x94', ' ', '\xF0', '\x90', '\x91', '\x96', ' ', '\xF0', '\x90', '\x91', '\x97', ' ', '\xF0', '\x90', '\x91', '\xB9', ' ', '\xF0', '\x90', '\x91', '\xBB', /* 𑔠𑖠𑗠𑹠𑻠*/
- '\0',
- '\xF0', '\x90', '\x91', '\x9F', ' ', '\xF0', '\x90', '\x91', '\xA3', /* ð‘Ÿ ð‘£ */
- '\0',
- '\xF0', '\x90', '\x91', '\xB1', ' ', '\xF0', '\x90', '\x91', '\xB2', ' ', '\xF0', '\x90', '\x91', '\xB3', ' ', '\xF0', '\x90', '\x91', '\xB4', ' ', '\xF0', '\x90', '\x91', '\xB8', ' ', '\xF0', '\x90', '\x91', '\xBA', ' ', '\xF0', '\x90', '\x91', '\xBC', /* 𑱠𑲠𑳠𑴠𑸠𑺠𑼠*/
- '\0',
- '\xF0', '\x90', '\x91', '\xB4', ' ', '\xF0', '\x90', '\x91', '\xBB', ' ', '\xF0', '\x90', '\x91', '\xB9', /* 𑴠𑻠𑹠*/
- '\0',
- '\xE0', '\xB6', '\x89', ' ', '\xE0', '\xB6', '\x9A', ' ', '\xE0', '\xB6', '\x9D', ' ', '\xE0', '\xB6', '\xB3', ' ', '\xE0', '\xB6', '\xB4', ' ', '\xE0', '\xB6', '\xBA', ' ', '\xE0', '\xB6', '\xBD', ' ', '\xE0', '\xB7', '\x86', /* ඉ ක චඳ ප ය ල ෆ */
- '\0',
- '\xE0', '\xB6', '\x91', ' ', '\xE0', '\xB6', '\x94', ' ', '\xE0', '\xB6', '\x9D', ' ', '\xE0', '\xB6', '\xA2', ' ', '\xE0', '\xB6', '\xA7', ' ', '\xE0', '\xB6', '\xAE', ' ', '\xE0', '\xB6', '\xB0', ' ', '\xE0', '\xB6', '\xBB', /* එ ඔ චජ ට ථ ධ ර */
- '\0',
- '\xE0', '\xB6', '\xAF', ' ', '\xE0', '\xB6', '\xB3', ' ', '\xE0', '\xB6', '\x8B', ' ', '\xE0', '\xB6', '\xBD', ' ', '\xE0', '\xB6', '\xAD', '\xE0', '\xB7', '\x96', ' ', '\xE0', '\xB6', '\xAD', '\xE0', '\xB7', '\x94', ' ', '\xE0', '\xB6', '\xB6', '\xE0', '\xB7', '\x94', ' ', '\xE0', '\xB6', '\xAF', '\xE0', '\xB7', '\x94', /* ද ඳ උ ල තූ තු බු දු */
- '\0',
- '\xE1', '\xAE', '\x8B', ' ', '\xE1', '\xAE', '\x9E', ' ', '\xE1', '\xAE', '\xAE', ' ', '\xE1', '\xAE', '\xBD', ' ', '\xE1', '\xAE', '\xB0', ' ', '\xE1', '\xAE', '\x88', /* ᮋ ᮞ ᮮ ᮽ ᮰ ᮈ */
- '\0',
- '\xE1', '\xAE', '\x84', ' ', '\xE1', '\xAE', '\x94', ' ', '\xE1', '\xAE', '\x95', ' ', '\xE1', '\xAE', '\x97', ' ', '\xE1', '\xAE', '\xB0', ' ', '\xE1', '\xAE', '\x86', ' ', '\xE1', '\xAE', '\x88', ' ', '\xE1', '\xAE', '\x89', /* ᮄ ᮔ ᮕ ᮗ ᮰ ᮆ ᮈ ᮉ */
- '\0',
- '\xE1', '\xAE', '\xBC', ' ', '\xE1', '\xB3', '\x84', /* ᮼ ᳄ */
- '\0',
- '\xEA', '\xAA', '\x86', ' ', '\xEA', '\xAA', '\x94', ' ', '\xEA', '\xAA', '\x92', ' ', '\xEA', '\xAA', '\x96', ' ', '\xEA', '\xAA', '\xAB', /* ꪆ ꪔ ꪒ ꪖ ꪫ */
- '\0',
- '\xEA', '\xAA', '\x89', ' ', '\xEA', '\xAA', '\xAB', ' ', '\xEA', '\xAA', '\xAE', /* ꪉ ꪫ ꪮ */
- '\0',
- '\xE0', '\xAE', '\x89', ' ', '\xE0', '\xAE', '\x92', ' ', '\xE0', '\xAE', '\x93', ' ', '\xE0', '\xAE', '\xB1', ' ', '\xE0', '\xAE', '\x88', ' ', '\xE0', '\xAE', '\x95', ' ', '\xE0', '\xAE', '\x99', ' ', '\xE0', '\xAE', '\x9A', /* உ ஒ ஓ ற ஈ க ங ச */
- '\0',
- '\xE0', '\xAE', '\x95', ' ', '\xE0', '\xAE', '\x9A', ' ', '\xE0', '\xAE', '\xB2', ' ', '\xE0', '\xAE', '\xB6', ' ', '\xE0', '\xAE', '\x89', ' ', '\xE0', '\xAE', '\x99', ' ', '\xE0', '\xAE', '\x9F', ' ', '\xE0', '\xAE', '\xAA', /* க ச ல ஶ உ ங ட ப */
- '\0',
- '\xE0', '\xB0', '\x87', ' ', '\xE0', '\xB0', '\x8C', ' ', '\xE0', '\xB0', '\x99', ' ', '\xE0', '\xB0', '\x9E', ' ', '\xE0', '\xB0', '\xA3', ' ', '\xE0', '\xB0', '\xB1', ' ', '\xE0', '\xB1', '\xAF', /* ఇ ఌ ఙ ఞ ణ ఱ ౯ */
- '\0',
- '\xE0', '\xB0', '\x85', ' ', '\xE0', '\xB0', '\x95', ' ', '\xE0', '\xB0', '\x9A', ' ', '\xE0', '\xB0', '\xB0', ' ', '\xE0', '\xB0', '\xBD', ' ', '\xE0', '\xB1', '\xA8', ' ', '\xE0', '\xB1', '\xAC', /* అ క చ ర ఽ ౨ ౬ */
- '\0',
- '\xE0', '\xB8', '\x9A', ' ', '\xE0', '\xB9', '\x80', ' ', '\xE0', '\xB9', '\x81', ' ', '\xE0', '\xB8', '\xAD', ' ', '\xE0', '\xB8', '\x81', ' ', '\xE0', '\xB8', '\xB2', /* บ เ ๠อ ภา */
- '\0',
- '\xE0', '\xB8', '\x9A', ' ', '\xE0', '\xB8', '\x9B', ' ', '\xE0', '\xB8', '\xA9', ' ', '\xE0', '\xB8', '\xAF', ' ', '\xE0', '\xB8', '\xAD', ' ', '\xE0', '\xB8', '\xA2', ' ', '\xE0', '\xB8', '\xAE', /* บ ป ษ ฯ อ ย ฮ */
- '\0',
- '\xE0', '\xB8', '\x9B', ' ', '\xE0', '\xB8', '\x9D', ' ', '\xE0', '\xB8', '\x9F', /* ป ภฟ */
- '\0',
- '\xE0', '\xB9', '\x82', ' ', '\xE0', '\xB9', '\x83', ' ', '\xE0', '\xB9', '\x84', /* โ ใ ไ */
- '\0',
- '\xE0', '\xB8', '\x8E', ' ', '\xE0', '\xB8', '\x8F', ' ', '\xE0', '\xB8', '\xA4', ' ', '\xE0', '\xB8', '\xA6', /* ฎ ภฤ ฦ */
- '\0',
- '\xE0', '\xB8', '\x8D', ' ', '\xE0', '\xB8', '\x90', /* ภภ*/
- '\0',
- '\xE0', '\xB9', '\x90', ' ', '\xE0', '\xB9', '\x91', ' ', '\xE0', '\xB9', '\x93', /* ๠๑ ๓ */
- '\0',
- '\xE2', '\xB5', '\x94', ' ', '\xE2', '\xB5', '\x99', ' ', '\xE2', '\xB5', '\x9B', ' ', '\xE2', '\xB5', '\x9E', ' ', '\xE2', '\xB4', '\xB5', ' ', '\xE2', '\xB4', '\xBC', ' ', '\xE2', '\xB4', '\xB9', ' ', '\xE2', '\xB5', '\x8E', /* ⵔ ⵙ ⵛ ⵞ ⴵ ⴼ ⴹ ⵎ */
- '\0',
- '\xEA', '\x97', '\x8D', ' ', '\xEA', '\x98', '\x96', ' ', '\xEA', '\x98', '\x99', ' ', '\xEA', '\x98', '\x9C', ' ', '\xEA', '\x96', '\x9C', ' ', '\xEA', '\x96', '\x9D', ' ', '\xEA', '\x94', '\x85', ' ', '\xEA', '\x95', '\xA2', /* ê— ê˜– ꘙ ꘜ ê–œ ê– ê”… ê•¢ */
- '\0',
- '\xEA', '\x97', '\x8D', ' ', '\xEA', '\x98', '\x96', ' ', '\xEA', '\x98', '\x99', ' ', '\xEA', '\x97', '\x9E', ' ', '\xEA', '\x94', '\x85', ' ', '\xEA', '\x95', '\xA2', ' ', '\xEA', '\x96', '\x9C', ' ', '\xEA', '\x94', '\x86', /* ê— ê˜– ꘙ ê—ž ê”… ê•¢ ê–œ ꔆ */
-#ifdef AF_CONFIG_OPTION_CJK
- '\0',
- '\xE4', '\xBB', '\x96', ' ', '\xE4', '\xBB', '\xAC', ' ', '\xE4', '\xBD', '\xA0', ' ', '\xE4', '\xBE', '\x86', ' ', '\xE5', '\x80', '\x91', ' ', '\xE5', '\x88', '\xB0', ' ', '\xE5', '\x92', '\x8C', ' ', '\xE5', '\x9C', '\xB0', /* 他 们 你 來 們 到 和 地 */
- ' ', '\xE5', '\xAF', '\xB9', ' ', '\xE5', '\xB0', '\x8D', ' ', '\xE5', '\xB0', '\xB1', ' ', '\xE5', '\xB8', '\xAD', ' ', '\xE6', '\x88', '\x91', ' ', '\xE6', '\x97', '\xB6', ' ', '\xE6', '\x99', '\x82', ' ', '\xE6', '\x9C', '\x83', /* 对 å° å°± 席 我 æ—¶ 時 會 */
- ' ', '\xE6', '\x9D', '\xA5', ' ', '\xE7', '\x82', '\xBA', ' ', '\xE8', '\x83', '\xBD', ' ', '\xE8', '\x88', '\xB0', ' ', '\xE8', '\xAA', '\xAA', ' ', '\xE8', '\xAF', '\xB4', ' ', '\xE8', '\xBF', '\x99', ' ', '\xE9', '\x80', '\x99', /* æ¥ ç‚º 能 舰 說 说 è¿™ 這 */
- ' ', '\xE9', '\xBD', '\x8A', ' ', '|', /* 齊 | */
- ' ', '\xE5', '\x86', '\x9B', ' ', '\xE5', '\x90', '\x8C', ' ', '\xE5', '\xB7', '\xB2', ' ', '\xE6', '\x84', '\xBF', ' ', '\xE6', '\x97', '\xA2', ' ', '\xE6', '\x98', '\x9F', ' ', '\xE6', '\x98', '\xAF', ' ', '\xE6', '\x99', '\xAF', /* 军 åŒ å·² æ„¿ æ—¢ 星 是 景 */
- ' ', '\xE6', '\xB0', '\x91', ' ', '\xE7', '\x85', '\xA7', ' ', '\xE7', '\x8E', '\xB0', ' ', '\xE7', '\x8F', '\xBE', ' ', '\xE7', '\x90', '\x86', ' ', '\xE7', '\x94', '\xA8', ' ', '\xE7', '\xBD', '\xAE', ' ', '\xE8', '\xA6', '\x81', /* æ°‘ ç…§ 现 ç¾ ç† ç”¨ ç½® è¦ */
- ' ', '\xE8', '\xBB', '\x8D', ' ', '\xE9', '\x82', '\xA3', ' ', '\xE9', '\x85', '\x8D', ' ', '\xE9', '\x87', '\x8C', ' ', '\xE9', '\x96', '\x8B', ' ', '\xE9', '\x9B', '\xB7', ' ', '\xE9', '\x9C', '\xB2', ' ', '\xE9', '\x9D', '\xA2', /* è» é‚£ é… é‡Œ é–‹ é›· 露 é¢ */
- ' ', '\xE9', '\xA1', '\xBE', /* 顾 */
- '\0',
- '\xE4', '\xB8', '\xAA', ' ', '\xE4', '\xB8', '\xBA', ' ', '\xE4', '\xBA', '\xBA', ' ', '\xE4', '\xBB', '\x96', ' ', '\xE4', '\xBB', '\xA5', ' ', '\xE4', '\xBB', '\xAC', ' ', '\xE4', '\xBD', '\xA0', ' ', '\xE4', '\xBE', '\x86', /* 个 为 人 他 以 们 你 來 */
- ' ', '\xE5', '\x80', '\x8B', ' ', '\xE5', '\x80', '\x91', ' ', '\xE5', '\x88', '\xB0', ' ', '\xE5', '\x92', '\x8C', ' ', '\xE5', '\xA4', '\xA7', ' ', '\xE5', '\xAF', '\xB9', ' ', '\xE5', '\xB0', '\x8D', ' ', '\xE5', '\xB0', '\xB1', /* 個 們 到 å’Œ 大 对 å° å°± */
- ' ', '\xE6', '\x88', '\x91', ' ', '\xE6', '\x97', '\xB6', ' ', '\xE6', '\x99', '\x82', ' ', '\xE6', '\x9C', '\x89', ' ', '\xE6', '\x9D', '\xA5', ' ', '\xE7', '\x82', '\xBA', ' ', '\xE8', '\xA6', '\x81', ' ', '\xE8', '\xAA', '\xAA', /* 我 æ—¶ 時 有 æ¥ ç‚º è¦ èªª */
- ' ', '\xE8', '\xAF', '\xB4', ' ', '|', /* 说 | */
- ' ', '\xE4', '\xB8', '\xBB', ' ', '\xE4', '\xBA', '\x9B', ' ', '\xE5', '\x9B', '\xA0', ' ', '\xE5', '\xAE', '\x83', ' ', '\xE6', '\x83', '\xB3', ' ', '\xE6', '\x84', '\x8F', ' ', '\xE7', '\x90', '\x86', ' ', '\xE7', '\x94', '\x9F', /* 主 些 å›  它 想 æ„ ç† ç”Ÿ */
- ' ', '\xE7', '\x95', '\xB6', ' ', '\xE7', '\x9C', '\x8B', ' ', '\xE7', '\x9D', '\x80', ' ', '\xE7', '\xBD', '\xAE', ' ', '\xE8', '\x80', '\x85', ' ', '\xE8', '\x87', '\xAA', ' ', '\xE8', '\x91', '\x97', ' ', '\xE8', '\xA3', '\xA1', /* 當 看 ç€ ç½® 者 自 è‘— 裡 */
- ' ', '\xE8', '\xBF', '\x87', ' ', '\xE8', '\xBF', '\x98', ' ', '\xE8', '\xBF', '\x9B', ' ', '\xE9', '\x80', '\xB2', ' ', '\xE9', '\x81', '\x8E', ' ', '\xE9', '\x81', '\x93', ' ', '\xE9', '\x82', '\x84', ' ', '\xE9', '\x87', '\x8C', /* 过 还 è¿› 進 éŽ é“ é‚„ 里 */
- ' ', '\xE9', '\x9D', '\xA2', /* é¢ */
-#ifdef AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT
- '\0',
- ' ', '\xE4', '\xBA', '\x9B', ' ', '\xE4', '\xBB', '\xAC', ' ', '\xE4', '\xBD', '\xA0', ' ', '\xE4', '\xBE', '\x86', ' ', '\xE5', '\x80', '\x91', ' ', '\xE5', '\x88', '\xB0', ' ', '\xE5', '\x92', '\x8C', ' ', '\xE5', '\x9C', '\xB0', /* 些 们 你 來 們 到 和 地 */
- ' ', '\xE5', '\xA5', '\xB9', ' ', '\xE5', '\xB0', '\x86', ' ', '\xE5', '\xB0', '\x87', ' ', '\xE5', '\xB0', '\xB1', ' ', '\xE5', '\xB9', '\xB4', ' ', '\xE5', '\xBE', '\x97', ' ', '\xE6', '\x83', '\x85', ' ', '\xE6', '\x9C', '\x80', /* 她 将 將 就 年 得 情 最 */
- ' ', '\xE6', '\xA0', '\xB7', ' ', '\xE6', '\xA8', '\xA3', ' ', '\xE7', '\x90', '\x86', ' ', '\xE8', '\x83', '\xBD', ' ', '\xE8', '\xAA', '\xAA', ' ', '\xE8', '\xAF', '\xB4', ' ', '\xE8', '\xBF', '\x99', ' ', '\xE9', '\x80', '\x99', /* æ · 樣 ç† èƒ½ 說 说 è¿™ 這 */
- ' ', '\xE9', '\x80', '\x9A', ' ', '|', /* 通 | */
- ' ', '\xE5', '\x8D', '\xB3', ' ', '\xE5', '\x90', '\x97', ' ', '\xE5', '\x90', '\xA7', ' ', '\xE5', '\x90', '\xAC', ' ', '\xE5', '\x91', '\xA2', ' ', '\xE5', '\x93', '\x81', ' ', '\xE5', '\x93', '\x8D', ' ', '\xE5', '\x97', '\x8E', /* å³ å— å§ å¬ å‘¢ å“ å“ å—Ž */
- ' ', '\xE5', '\xB8', '\x88', ' ', '\xE5', '\xB8', '\xAB', ' ', '\xE6', '\x94', '\xB6', ' ', '\xE6', '\x96', '\xAD', ' ', '\xE6', '\x96', '\xB7', ' ', '\xE6', '\x98', '\x8E', ' ', '\xE7', '\x9C', '\xBC', ' ', '\xE9', '\x96', '\x93', /* 师 師 收 断 斷 明 眼 間 */
- ' ', '\xE9', '\x97', '\xB4', ' ', '\xE9', '\x99', '\x85', ' ', '\xE9', '\x99', '\x88', ' ', '\xE9', '\x99', '\x90', ' ', '\xE9', '\x99', '\xA4', ' ', '\xE9', '\x99', '\xB3', ' ', '\xE9', '\x9A', '\x8F', ' ', '\xE9', '\x9A', '\x9B', /* é—´ é™… 陈 é™ é™¤ 陳 éš éš› */
- ' ', '\xE9', '\x9A', '\xA8', /* 隨 */
- '\0',
- '\xE4', '\xBA', '\x8B', ' ', '\xE5', '\x89', '\x8D', ' ', '\xE5', '\xAD', '\xB8', ' ', '\xE5', '\xB0', '\x86', ' ', '\xE5', '\xB0', '\x87', ' ', '\xE6', '\x83', '\x85', ' ', '\xE6', '\x83', '\xB3', ' ', '\xE6', '\x88', '\x96', /* 事 å‰ å­¸ å°† å°‡ 情 想 或 */
- ' ', '\xE6', '\x94', '\xBF', ' ', '\xE6', '\x96', '\xAF', ' ', '\xE6', '\x96', '\xB0', ' ', '\xE6', '\xA0', '\xB7', ' ', '\xE6', '\xA8', '\xA3', ' ', '\xE6', '\xB0', '\x91', ' ', '\xE6', '\xB2', '\x92', ' ', '\xE6', '\xB2', '\xA1', /* 政 斯 新 样 樣 民 沒 没 */
- ' ', '\xE7', '\x84', '\xB6', ' ', '\xE7', '\x89', '\xB9', ' ', '\xE7', '\x8E', '\xB0', ' ', '\xE7', '\x8F', '\xBE', ' ', '\xE7', '\x90', '\x83', ' ', '\xE7', '\xAC', '\xAC', ' ', '\xE7', '\xB6', '\x93', ' ', '\xE8', '\xB0', '\x81', /* 然 特 现 ç¾ çƒ ç¬¬ 經 è° */
- ' ', '\xE8', '\xB5', '\xB7', ' ', '|', /* èµ· | */
- ' ', '\xE4', '\xBE', '\x8B', ' ', '\xE5', '\x88', '\xA5', ' ', '\xE5', '\x88', '\xAB', ' ', '\xE5', '\x88', '\xB6', ' ', '\xE5', '\x8A', '\xA8', ' ', '\xE5', '\x8B', '\x95', ' ', '\xE5', '\x90', '\x97', ' ', '\xE5', '\x97', '\x8E', /* 例 別 别 制 动 å‹• å— å—Ž */
- ' ', '\xE5', '\xA2', '\x9E', ' ', '\xE6', '\x8C', '\x87', ' ', '\xE6', '\x98', '\x8E', ' ', '\xE6', '\x9C', '\x9D', ' ', '\xE6', '\x9C', '\x9F', ' ', '\xE6', '\x9E', '\x84', ' ', '\xE7', '\x89', '\xA9', ' ', '\xE7', '\xA1', '\xAE', /* 增 指 明 æœ æœŸ æž„ 物 ç¡® */
- ' ', '\xE7', '\xA7', '\x8D', ' ', '\xE8', '\xAA', '\xBF', ' ', '\xE8', '\xB0', '\x83', ' ', '\xE8', '\xB2', '\xBB', ' ', '\xE8', '\xB4', '\xB9', ' ', '\xE9', '\x82', '\xA3', ' ', '\xE9', '\x83', '\xBD', ' ', '\xE9', '\x96', '\x93', /* ç§ èª¿ è°ƒ è²» è´¹ é‚£ 都 é–“ */
- ' ', '\xE9', '\x97', '\xB4', /* é—´ */
-#endif /* AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT */
-#endif /* AF_CONFIG_OPTION_CJK */
- '\0',
-
- };
-
-
- /* stringsets are specific to styles */
- FT_LOCAL_ARRAY_DEF( AF_Blue_StringRec )
- af_blue_stringsets[] =
- {
- /* */
- { AF_BLUE_STRING_ADLAM_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_ADLAM_CAPITAL_BOTTOM, 0 },
- { AF_BLUE_STRING_ADLAM_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
- AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
- { AF_BLUE_STRING_ADLAM_SMALL_BOTTOM, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_ARABIC_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_ARABIC_BOTTOM, 0 },
- { AF_BLUE_STRING_ARABIC_JOIN, AF_BLUE_PROPERTY_LATIN_NEUTRAL },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_ARMENIAN_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_ARMENIAN_CAPITAL_BOTTOM, 0 },
- { AF_BLUE_STRING_ARMENIAN_SMALL_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_ARMENIAN_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
- AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
- { AF_BLUE_STRING_ARMENIAN_SMALL_BOTTOM, 0 },
- { AF_BLUE_STRING_ARMENIAN_SMALL_DESCENDER, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_AVESTAN_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_AVESTAN_BOTTOM, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_BAMUM_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_BAMUM_BOTTOM, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_BENGALI_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_BENGALI_HEAD, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_BENGALI_BASE, AF_BLUE_PROPERTY_LATIN_TOP |
- AF_BLUE_PROPERTY_LATIN_NEUTRAL |
- AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
- { AF_BLUE_STRING_BENGALI_BASE, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_BUHID_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_BUHID_LARGE, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_BUHID_SMALL, AF_BLUE_PROPERTY_LATIN_TOP |
- AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
- { AF_BLUE_STRING_BUHID_BOTTOM, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_CHAKMA_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_CHAKMA_BOTTOM, 0 },
- { AF_BLUE_STRING_CHAKMA_DESCENDER, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_CANADIAN_SYLLABICS_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_CANADIAN_SYLLABICS_BOTTOM, 0 },
- { AF_BLUE_STRING_CANADIAN_SYLLABICS_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
- AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
- { AF_BLUE_STRING_CANADIAN_SYLLABICS_SMALL_BOTTOM, 0 },
- { AF_BLUE_STRING_CANADIAN_SYLLABICS_SUPS_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_CANADIAN_SYLLABICS_SUPS_BOTTOM, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_CARIAN_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_CARIAN_BOTTOM, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_CHEROKEE_CAPITAL, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_CHEROKEE_CAPITAL, 0 },
- { AF_BLUE_STRING_CHEROKEE_SMALL_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_CHEROKEE_SMALL, AF_BLUE_PROPERTY_LATIN_TOP |
- AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
- { AF_BLUE_STRING_CHEROKEE_SMALL, 0 },
- { AF_BLUE_STRING_CHEROKEE_SMALL_DESCENDER, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_COPTIC_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_COPTIC_CAPITAL_BOTTOM, 0 },
- { AF_BLUE_STRING_COPTIC_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
- AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
- { AF_BLUE_STRING_COPTIC_SMALL_BOTTOM, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_CYPRIOT_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_CYPRIOT_BOTTOM, 0 },
- { AF_BLUE_STRING_CYPRIOT_SMALL, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_CYPRIOT_SMALL, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_CYRILLIC_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM, 0 },
- { AF_BLUE_STRING_CYRILLIC_SMALL, AF_BLUE_PROPERTY_LATIN_TOP |
- AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
- { AF_BLUE_STRING_CYRILLIC_SMALL, 0 },
- { AF_BLUE_STRING_CYRILLIC_SMALL_DESCENDER, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_DEVANAGARI_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_DEVANAGARI_HEAD, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_DEVANAGARI_BASE, AF_BLUE_PROPERTY_LATIN_TOP |
- AF_BLUE_PROPERTY_LATIN_NEUTRAL |
- AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
- { AF_BLUE_STRING_DEVANAGARI_BASE, 0 },
- { AF_BLUE_STRING_DEVANAGARI_BOTTOM, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_DESERET_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_DESERET_CAPITAL_BOTTOM, 0 },
- { AF_BLUE_STRING_DESERET_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
- AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
- { AF_BLUE_STRING_DESERET_SMALL_BOTTOM, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_ETHIOPIC_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_ETHIOPIC_BOTTOM, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_GEORGIAN_MKHEDRULI_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
- AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
- { AF_BLUE_STRING_GEORGIAN_MKHEDRULI_BOTTOM, 0 },
- { AF_BLUE_STRING_GEORGIAN_MKHEDRULI_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_GEORGIAN_MKHEDRULI_DESCENDER, 0 },
- { AF_BLUE_STRING_GEORGIAN_MTAVRULI_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_GEORGIAN_MTAVRULI_BOTTOM, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_GEORGIAN_ASOMTAVRULI_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_GEORGIAN_ASOMTAVRULI_BOTTOM, 0 },
- { AF_BLUE_STRING_GEORGIAN_NUSKHURI_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
- AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
- { AF_BLUE_STRING_GEORGIAN_NUSKHURI_BOTTOM, 0 },
- { AF_BLUE_STRING_GEORGIAN_NUSKHURI_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_GEORGIAN_NUSKHURI_DESCENDER, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_GLAGOLITIC_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_GLAGOLITIC_CAPITAL_BOTTOM, 0 },
- { AF_BLUE_STRING_GLAGOLITIC_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
- AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
- { AF_BLUE_STRING_GLAGOLITIC_SMALL_BOTTOM, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_GOTHIC_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_GOTHIC_BOTTOM, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_GREEK_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_GREEK_CAPITAL_BOTTOM, 0 },
- { AF_BLUE_STRING_GREEK_SMALL_BETA_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_GREEK_SMALL, AF_BLUE_PROPERTY_LATIN_TOP |
- AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
- { AF_BLUE_STRING_GREEK_SMALL, 0 },
- { AF_BLUE_STRING_GREEK_SMALL_DESCENDER, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_GUJARATI_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
- AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
- { AF_BLUE_STRING_GUJARATI_BOTTOM, 0 },
- { AF_BLUE_STRING_GUJARATI_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_GUJARATI_DESCENDER, 0 },
- { AF_BLUE_STRING_GUJARATI_DIGIT_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_GURMUKHI_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_GURMUKHI_HEAD, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_GURMUKHI_BASE, AF_BLUE_PROPERTY_LATIN_TOP |
- AF_BLUE_PROPERTY_LATIN_NEUTRAL |
- AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
- { AF_BLUE_STRING_GURMUKHI_BOTTOM, 0 },
- { AF_BLUE_STRING_GURMUKHI_DIGIT_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_HEBREW_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
- AF_BLUE_PROPERTY_LATIN_LONG },
- { AF_BLUE_STRING_HEBREW_BOTTOM, 0 },
- { AF_BLUE_STRING_HEBREW_DESCENDER, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_KANNADA_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_KANNADA_BOTTOM, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_KAYAH_LI_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
- AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
- { AF_BLUE_STRING_KAYAH_LI_BOTTOM, 0 },
- { AF_BLUE_STRING_KAYAH_LI_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_KAYAH_LI_DESCENDER, 0 },
- { AF_BLUE_STRING_KAYAH_LI_LARGE_DESCENDER, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_KHMER_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
- AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
- { AF_BLUE_STRING_KHMER_SUBSCRIPT_TOP, AF_BLUE_PROPERTY_LATIN_SUB_TOP },
- { AF_BLUE_STRING_KHMER_BOTTOM, 0 },
- { AF_BLUE_STRING_KHMER_DESCENDER, 0 },
- { AF_BLUE_STRING_KHMER_LARGE_DESCENDER, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_KHMER_SYMBOLS_WAXING_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
- AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
- { AF_BLUE_STRING_KHMER_SYMBOLS_WANING_BOTTOM, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_LAO_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
- AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
- { AF_BLUE_STRING_LAO_BOTTOM, 0 },
- { AF_BLUE_STRING_LAO_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_LAO_LARGE_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_LAO_DESCENDER, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_LATIN_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_LATIN_CAPITAL_BOTTOM, 0 },
- { AF_BLUE_STRING_LATIN_SMALL_F_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_LATIN_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
- AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
- { AF_BLUE_STRING_LATIN_SMALL_BOTTOM, 0 },
- { AF_BLUE_STRING_LATIN_SMALL_DESCENDER, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_LATIN_SUBS_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_LATIN_SUBS_CAPITAL_BOTTOM, 0 },
- { AF_BLUE_STRING_LATIN_SUBS_SMALL_F_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_LATIN_SUBS_SMALL, AF_BLUE_PROPERTY_LATIN_TOP |
- AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
- { AF_BLUE_STRING_LATIN_SUBS_SMALL, 0 },
- { AF_BLUE_STRING_LATIN_SUBS_SMALL_DESCENDER, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_LATIN_SUPS_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_LATIN_SUPS_CAPITAL_BOTTOM, 0 },
- { AF_BLUE_STRING_LATIN_SUPS_SMALL_F_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_LATIN_SUPS_SMALL, AF_BLUE_PROPERTY_LATIN_TOP |
- AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
- { AF_BLUE_STRING_LATIN_SUPS_SMALL, 0 },
- { AF_BLUE_STRING_LATIN_SUPS_SMALL_DESCENDER, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_LISU_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_LISU_BOTTOM, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_MALAYALAM_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_MALAYALAM_BOTTOM, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_MEDEFAIDRIN_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_MEDEFAIDRIN_CAPITAL_BOTTOM, 0 },
- { AF_BLUE_STRING_MEDEFAIDRIN_SMALL_F_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_MEDEFAIDRIN_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
- AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
- { AF_BLUE_STRING_MEDEFAIDRIN_SMALL_BOTTOM, 0 },
- { AF_BLUE_STRING_MEDEFAIDRIN_SMALL_DESCENDER, 0 },
- { AF_BLUE_STRING_MEDEFAIDRIN_DIGIT_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_MONGOLIAN_TOP_BASE, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_MONGOLIAN_BOTTOM_BASE, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_MYANMAR_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
- AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
- { AF_BLUE_STRING_MYANMAR_BOTTOM, 0 },
- { AF_BLUE_STRING_MYANMAR_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_MYANMAR_DESCENDER, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_NKO_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_NKO_BOTTOM, 0 },
- { AF_BLUE_STRING_NKO_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
- AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
- { AF_BLUE_STRING_NKO_SMALL_BOTTOM, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_OL_CHIKI, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_OL_CHIKI, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_OLD_TURKIC_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_OLD_TURKIC_BOTTOM, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_OSAGE_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_OSAGE_CAPITAL_BOTTOM, 0 },
- { AF_BLUE_STRING_OSAGE_CAPITAL_DESCENDER, 0 },
- { AF_BLUE_STRING_OSAGE_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
- AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
- { AF_BLUE_STRING_OSAGE_SMALL_BOTTOM, 0 },
- { AF_BLUE_STRING_OSAGE_SMALL_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_OSAGE_SMALL_DESCENDER, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_OSMANYA_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_OSMANYA_BOTTOM, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_ROHINGYA_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_ROHINGYA_BOTTOM, 0 },
- { AF_BLUE_STRING_ROHINGYA_JOIN, AF_BLUE_PROPERTY_LATIN_NEUTRAL },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_SAURASHTRA_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_SAURASHTRA_BOTTOM, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_SHAVIAN_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_SHAVIAN_BOTTOM, 0 },
- { AF_BLUE_STRING_SHAVIAN_DESCENDER, 0 },
- { AF_BLUE_STRING_SHAVIAN_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
- AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
- { AF_BLUE_STRING_SHAVIAN_SMALL_BOTTOM, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_SINHALA_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_SINHALA_BOTTOM, 0 },
- { AF_BLUE_STRING_SINHALA_DESCENDER, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_SUNDANESE_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_SUNDANESE_BOTTOM, 0 },
- { AF_BLUE_STRING_SUNDANESE_DESCENDER, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_TAMIL_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_TAMIL_BOTTOM, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_TAI_VIET_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_TAI_VIET_BOTTOM, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_TELUGU_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_TELUGU_BOTTOM, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_THAI_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
- AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
- { AF_BLUE_STRING_THAI_BOTTOM, 0 },
- { AF_BLUE_STRING_THAI_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_THAI_LARGE_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_THAI_DESCENDER, 0 },
- { AF_BLUE_STRING_THAI_LARGE_DESCENDER, 0 },
- { AF_BLUE_STRING_THAI_DIGIT_TOP, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_TIFINAGH, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_TIFINAGH, 0 },
- { AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_VAI_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_VAI_BOTTOM, 0 },
- { AF_BLUE_STRING_MAX, 0 },
-#ifdef AF_CONFIG_OPTION_CJK
- { AF_BLUE_STRING_CJK_TOP, AF_BLUE_PROPERTY_CJK_TOP },
- { AF_BLUE_STRING_CJK_BOTTOM, 0 },
-#ifdef AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT
- { AF_BLUE_STRING_CJK_LEFT, AF_BLUE_PROPERTY_CJK_HORIZ },
- { AF_BLUE_STRING_CJK_RIGHT, AF_BLUE_PROPERTY_CJK_HORIZ |
- AF_BLUE_PROPERTY_CJK_RIGHT },
-#endif /* AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT */
- { AF_BLUE_STRING_MAX, 0 },
-#endif /* AF_CONFIG_OPTION_CJK */
-
- };
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/autofit/afblue.h b/contrib/libs/freetype/src/autofit/afblue.h
deleted file mode 100644
index 2aa9d0984e..0000000000
--- a/contrib/libs/freetype/src/autofit/afblue.h
+++ /dev/null
@@ -1,429 +0,0 @@
-/* This file has been generated by the Perl script `afblue.pl', */
-/* using data from file `afblue.dat'. */
-
-/****************************************************************************
- *
- * afblue.h
- *
- * Auto-fitter data for blue strings (specification).
- *
- * Copyright (C) 2013-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef AFBLUE_H_
-#define AFBLUE_H_
-
-
-FT_BEGIN_HEADER
-
-
- /* an auxiliary macro to decode a UTF-8 character -- since we only use */
- /* hard-coded, self-converted data, no error checking is performed */
-#define GET_UTF8_CHAR( ch, p ) \
- do \
- { \
- ch = (unsigned char)*p++; \
- if ( ch >= 0x80 ) \
- { \
- FT_UInt len_; \
- \
- \
- if ( ch < 0xE0 ) \
- { \
- len_ = 1; \
- ch &= 0x1F; \
- } \
- else if ( ch < 0xF0 ) \
- { \
- len_ = 2; \
- ch &= 0x0F; \
- } \
- else \
- { \
- len_ = 3; \
- ch &= 0x07; \
- } \
- \
- for ( ; len_ > 0; len_-- ) \
- ch = ( ch << 6 ) | ( *p++ & 0x3F ); \
- } \
- } while ( 0 )
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** B L U E S T R I N G S *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- /* At the bottommost level, we define strings for finding blue zones. */
-
-
-#define AF_BLUE_STRING_MAX_LEN 51
-
- /* The AF_Blue_String enumeration values are offsets into the */
- /* `af_blue_strings' array. */
-
- typedef enum AF_Blue_String_
- {
- AF_BLUE_STRING_ADLAM_CAPITAL_TOP = 0,
- AF_BLUE_STRING_ADLAM_CAPITAL_BOTTOM = 30,
- AF_BLUE_STRING_ADLAM_SMALL_TOP = 40,
- AF_BLUE_STRING_ADLAM_SMALL_BOTTOM = 65,
- AF_BLUE_STRING_ARABIC_TOP = 105,
- AF_BLUE_STRING_ARABIC_BOTTOM = 123,
- AF_BLUE_STRING_ARABIC_JOIN = 138,
- AF_BLUE_STRING_ARMENIAN_CAPITAL_TOP = 141,
- AF_BLUE_STRING_ARMENIAN_CAPITAL_BOTTOM = 165,
- AF_BLUE_STRING_ARMENIAN_SMALL_ASCENDER = 189,
- AF_BLUE_STRING_ARMENIAN_SMALL_TOP = 210,
- AF_BLUE_STRING_ARMENIAN_SMALL_BOTTOM = 234,
- AF_BLUE_STRING_ARMENIAN_SMALL_DESCENDER = 258,
- AF_BLUE_STRING_AVESTAN_TOP = 282,
- AF_BLUE_STRING_AVESTAN_BOTTOM = 302,
- AF_BLUE_STRING_BAMUM_TOP = 312,
- AF_BLUE_STRING_BAMUM_BOTTOM = 344,
- AF_BLUE_STRING_BENGALI_BASE = 376,
- AF_BLUE_STRING_BENGALI_TOP = 408,
- AF_BLUE_STRING_BENGALI_HEAD = 436,
- AF_BLUE_STRING_BUHID_TOP = 468,
- AF_BLUE_STRING_BUHID_LARGE = 476,
- AF_BLUE_STRING_BUHID_SMALL = 488,
- AF_BLUE_STRING_BUHID_BOTTOM = 504,
- AF_BLUE_STRING_CANADIAN_SYLLABICS_TOP = 532,
- AF_BLUE_STRING_CANADIAN_SYLLABICS_BOTTOM = 564,
- AF_BLUE_STRING_CANADIAN_SYLLABICS_SMALL_TOP = 596,
- AF_BLUE_STRING_CANADIAN_SYLLABICS_SMALL_BOTTOM = 628,
- AF_BLUE_STRING_CANADIAN_SYLLABICS_SUPS_TOP = 660,
- AF_BLUE_STRING_CANADIAN_SYLLABICS_SUPS_BOTTOM = 688,
- AF_BLUE_STRING_CARIAN_TOP = 720,
- AF_BLUE_STRING_CARIAN_BOTTOM = 760,
- AF_BLUE_STRING_CHAKMA_TOP = 795,
- AF_BLUE_STRING_CHAKMA_BOTTOM = 820,
- AF_BLUE_STRING_CHAKMA_DESCENDER = 845,
- AF_BLUE_STRING_CHEROKEE_CAPITAL = 910,
- AF_BLUE_STRING_CHEROKEE_SMALL_ASCENDER = 942,
- AF_BLUE_STRING_CHEROKEE_SMALL = 974,
- AF_BLUE_STRING_CHEROKEE_SMALL_DESCENDER = 1006,
- AF_BLUE_STRING_COPTIC_CAPITAL_TOP = 1022,
- AF_BLUE_STRING_COPTIC_CAPITAL_BOTTOM = 1054,
- AF_BLUE_STRING_COPTIC_SMALL_TOP = 1086,
- AF_BLUE_STRING_COPTIC_SMALL_BOTTOM = 1118,
- AF_BLUE_STRING_CYPRIOT_TOP = 1150,
- AF_BLUE_STRING_CYPRIOT_BOTTOM = 1190,
- AF_BLUE_STRING_CYPRIOT_SMALL = 1225,
- AF_BLUE_STRING_CYRILLIC_CAPITAL_TOP = 1240,
- AF_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM = 1264,
- AF_BLUE_STRING_CYRILLIC_SMALL = 1288,
- AF_BLUE_STRING_CYRILLIC_SMALL_DESCENDER = 1312,
- AF_BLUE_STRING_DESERET_CAPITAL_TOP = 1321,
- AF_BLUE_STRING_DESERET_CAPITAL_BOTTOM = 1346,
- AF_BLUE_STRING_DESERET_SMALL_TOP = 1371,
- AF_BLUE_STRING_DESERET_SMALL_BOTTOM = 1396,
- AF_BLUE_STRING_DEVANAGARI_BASE = 1421,
- AF_BLUE_STRING_DEVANAGARI_TOP = 1453,
- AF_BLUE_STRING_DEVANAGARI_HEAD = 1485,
- AF_BLUE_STRING_DEVANAGARI_BOTTOM = 1517,
- AF_BLUE_STRING_ETHIOPIC_TOP = 1525,
- AF_BLUE_STRING_ETHIOPIC_BOTTOM = 1557,
- AF_BLUE_STRING_GEORGIAN_MKHEDRULI_TOP = 1589,
- AF_BLUE_STRING_GEORGIAN_MKHEDRULI_BOTTOM = 1621,
- AF_BLUE_STRING_GEORGIAN_MKHEDRULI_ASCENDER = 1653,
- AF_BLUE_STRING_GEORGIAN_MKHEDRULI_DESCENDER = 1685,
- AF_BLUE_STRING_GEORGIAN_ASOMTAVRULI_TOP = 1717,
- AF_BLUE_STRING_GEORGIAN_ASOMTAVRULI_BOTTOM = 1749,
- AF_BLUE_STRING_GEORGIAN_NUSKHURI_TOP = 1781,
- AF_BLUE_STRING_GEORGIAN_NUSKHURI_BOTTOM = 1813,
- AF_BLUE_STRING_GEORGIAN_NUSKHURI_ASCENDER = 1845,
- AF_BLUE_STRING_GEORGIAN_NUSKHURI_DESCENDER = 1877,
- AF_BLUE_STRING_GEORGIAN_MTAVRULI_TOP = 1909,
- AF_BLUE_STRING_GEORGIAN_MTAVRULI_BOTTOM = 1941,
- AF_BLUE_STRING_GLAGOLITIC_CAPITAL_TOP = 1973,
- AF_BLUE_STRING_GLAGOLITIC_CAPITAL_BOTTOM = 2005,
- AF_BLUE_STRING_GLAGOLITIC_SMALL_TOP = 2037,
- AF_BLUE_STRING_GLAGOLITIC_SMALL_BOTTOM = 2069,
- AF_BLUE_STRING_GOTHIC_TOP = 2101,
- AF_BLUE_STRING_GOTHIC_BOTTOM = 2141,
- AF_BLUE_STRING_GREEK_CAPITAL_TOP = 2161,
- AF_BLUE_STRING_GREEK_CAPITAL_BOTTOM = 2182,
- AF_BLUE_STRING_GREEK_SMALL_BETA_TOP = 2200,
- AF_BLUE_STRING_GREEK_SMALL = 2218,
- AF_BLUE_STRING_GREEK_SMALL_DESCENDER = 2242,
- AF_BLUE_STRING_GUJARATI_TOP = 2266,
- AF_BLUE_STRING_GUJARATI_BOTTOM = 2298,
- AF_BLUE_STRING_GUJARATI_ASCENDER = 2330,
- AF_BLUE_STRING_GUJARATI_DESCENDER = 2380,
- AF_BLUE_STRING_GUJARATI_DIGIT_TOP = 2413,
- AF_BLUE_STRING_GURMUKHI_BASE = 2433,
- AF_BLUE_STRING_GURMUKHI_HEAD = 2465,
- AF_BLUE_STRING_GURMUKHI_TOP = 2497,
- AF_BLUE_STRING_GURMUKHI_BOTTOM = 2529,
- AF_BLUE_STRING_GURMUKHI_DIGIT_TOP = 2561,
- AF_BLUE_STRING_HEBREW_TOP = 2581,
- AF_BLUE_STRING_HEBREW_BOTTOM = 2605,
- AF_BLUE_STRING_HEBREW_DESCENDER = 2623,
- AF_BLUE_STRING_KANNADA_TOP = 2638,
- AF_BLUE_STRING_KANNADA_BOTTOM = 2682,
- AF_BLUE_STRING_KAYAH_LI_TOP = 2714,
- AF_BLUE_STRING_KAYAH_LI_BOTTOM = 2738,
- AF_BLUE_STRING_KAYAH_LI_ASCENDER = 2758,
- AF_BLUE_STRING_KAYAH_LI_DESCENDER = 2766,
- AF_BLUE_STRING_KAYAH_LI_LARGE_DESCENDER = 2778,
- AF_BLUE_STRING_KHMER_TOP = 2799,
- AF_BLUE_STRING_KHMER_SUBSCRIPT_TOP = 2823,
- AF_BLUE_STRING_KHMER_BOTTOM = 2863,
- AF_BLUE_STRING_KHMER_DESCENDER = 2895,
- AF_BLUE_STRING_KHMER_LARGE_DESCENDER = 2929,
- AF_BLUE_STRING_KHMER_SYMBOLS_WAXING_TOP = 3016,
- AF_BLUE_STRING_KHMER_SYMBOLS_WANING_BOTTOM = 3024,
- AF_BLUE_STRING_LAO_TOP = 3032,
- AF_BLUE_STRING_LAO_BOTTOM = 3064,
- AF_BLUE_STRING_LAO_ASCENDER = 3096,
- AF_BLUE_STRING_LAO_LARGE_ASCENDER = 3112,
- AF_BLUE_STRING_LAO_DESCENDER = 3124,
- AF_BLUE_STRING_LATIN_CAPITAL_TOP = 3148,
- AF_BLUE_STRING_LATIN_CAPITAL_BOTTOM = 3164,
- AF_BLUE_STRING_LATIN_SMALL_F_TOP = 3180,
- AF_BLUE_STRING_LATIN_SMALL_TOP = 3194,
- AF_BLUE_STRING_LATIN_SMALL_BOTTOM = 3210,
- AF_BLUE_STRING_LATIN_SMALL_DESCENDER = 3226,
- AF_BLUE_STRING_LATIN_SUBS_CAPITAL_TOP = 3236,
- AF_BLUE_STRING_LATIN_SUBS_CAPITAL_BOTTOM = 3256,
- AF_BLUE_STRING_LATIN_SUBS_SMALL_F_TOP = 3276,
- AF_BLUE_STRING_LATIN_SUBS_SMALL = 3296,
- AF_BLUE_STRING_LATIN_SUBS_SMALL_DESCENDER = 3332,
- AF_BLUE_STRING_LATIN_SUPS_CAPITAL_TOP = 3352,
- AF_BLUE_STRING_LATIN_SUPS_CAPITAL_BOTTOM = 3383,
- AF_BLUE_STRING_LATIN_SUPS_SMALL_F_TOP = 3412,
- AF_BLUE_STRING_LATIN_SUPS_SMALL = 3438,
- AF_BLUE_STRING_LATIN_SUPS_SMALL_DESCENDER = 3463,
- AF_BLUE_STRING_LISU_TOP = 3474,
- AF_BLUE_STRING_LISU_BOTTOM = 3506,
- AF_BLUE_STRING_MALAYALAM_TOP = 3538,
- AF_BLUE_STRING_MALAYALAM_BOTTOM = 3582,
- AF_BLUE_STRING_MEDEFAIDRIN_CAPITAL_TOP = 3614,
- AF_BLUE_STRING_MEDEFAIDRIN_CAPITAL_BOTTOM = 3649,
- AF_BLUE_STRING_MEDEFAIDRIN_SMALL_F_TOP = 3689,
- AF_BLUE_STRING_MEDEFAIDRIN_SMALL_TOP = 3719,
- AF_BLUE_STRING_MEDEFAIDRIN_SMALL_BOTTOM = 3749,
- AF_BLUE_STRING_MEDEFAIDRIN_SMALL_DESCENDER = 3779,
- AF_BLUE_STRING_MEDEFAIDRIN_DIGIT_TOP = 3794,
- AF_BLUE_STRING_MONGOLIAN_TOP_BASE = 3819,
- AF_BLUE_STRING_MONGOLIAN_BOTTOM_BASE = 3863,
- AF_BLUE_STRING_MYANMAR_TOP = 3867,
- AF_BLUE_STRING_MYANMAR_BOTTOM = 3899,
- AF_BLUE_STRING_MYANMAR_ASCENDER = 3931,
- AF_BLUE_STRING_MYANMAR_DESCENDER = 3959,
- AF_BLUE_STRING_NKO_TOP = 3991,
- AF_BLUE_STRING_NKO_BOTTOM = 4015,
- AF_BLUE_STRING_NKO_SMALL_TOP = 4030,
- AF_BLUE_STRING_NKO_SMALL_BOTTOM = 4039,
- AF_BLUE_STRING_OL_CHIKI = 4051,
- AF_BLUE_STRING_OLD_TURKIC_TOP = 4075,
- AF_BLUE_STRING_OLD_TURKIC_BOTTOM = 4090,
- AF_BLUE_STRING_OSAGE_CAPITAL_TOP = 4110,
- AF_BLUE_STRING_OSAGE_CAPITAL_BOTTOM = 4150,
- AF_BLUE_STRING_OSAGE_CAPITAL_DESCENDER = 4180,
- AF_BLUE_STRING_OSAGE_SMALL_TOP = 4195,
- AF_BLUE_STRING_OSAGE_SMALL_BOTTOM = 4235,
- AF_BLUE_STRING_OSAGE_SMALL_ASCENDER = 4275,
- AF_BLUE_STRING_OSAGE_SMALL_DESCENDER = 4300,
- AF_BLUE_STRING_OSMANYA_TOP = 4315,
- AF_BLUE_STRING_OSMANYA_BOTTOM = 4355,
- AF_BLUE_STRING_ROHINGYA_TOP = 4395,
- AF_BLUE_STRING_ROHINGYA_BOTTOM = 4420,
- AF_BLUE_STRING_ROHINGYA_JOIN = 4445,
- AF_BLUE_STRING_SAURASHTRA_TOP = 4448,
- AF_BLUE_STRING_SAURASHTRA_BOTTOM = 4480,
- AF_BLUE_STRING_SHAVIAN_TOP = 4500,
- AF_BLUE_STRING_SHAVIAN_BOTTOM = 4510,
- AF_BLUE_STRING_SHAVIAN_DESCENDER = 4535,
- AF_BLUE_STRING_SHAVIAN_SMALL_TOP = 4545,
- AF_BLUE_STRING_SHAVIAN_SMALL_BOTTOM = 4580,
- AF_BLUE_STRING_SINHALA_TOP = 4595,
- AF_BLUE_STRING_SINHALA_BOTTOM = 4627,
- AF_BLUE_STRING_SINHALA_DESCENDER = 4659,
- AF_BLUE_STRING_SUNDANESE_TOP = 4703,
- AF_BLUE_STRING_SUNDANESE_BOTTOM = 4727,
- AF_BLUE_STRING_SUNDANESE_DESCENDER = 4759,
- AF_BLUE_STRING_TAI_VIET_TOP = 4767,
- AF_BLUE_STRING_TAI_VIET_BOTTOM = 4787,
- AF_BLUE_STRING_TAMIL_TOP = 4799,
- AF_BLUE_STRING_TAMIL_BOTTOM = 4831,
- AF_BLUE_STRING_TELUGU_TOP = 4863,
- AF_BLUE_STRING_TELUGU_BOTTOM = 4891,
- AF_BLUE_STRING_THAI_TOP = 4919,
- AF_BLUE_STRING_THAI_BOTTOM = 4943,
- AF_BLUE_STRING_THAI_ASCENDER = 4971,
- AF_BLUE_STRING_THAI_LARGE_ASCENDER = 4983,
- AF_BLUE_STRING_THAI_DESCENDER = 4995,
- AF_BLUE_STRING_THAI_LARGE_DESCENDER = 5011,
- AF_BLUE_STRING_THAI_DIGIT_TOP = 5019,
- AF_BLUE_STRING_TIFINAGH = 5031,
- AF_BLUE_STRING_VAI_TOP = 5063,
- AF_BLUE_STRING_VAI_BOTTOM = 5095,
- af_blue_1_1 = 5126,
-#ifdef AF_CONFIG_OPTION_CJK
- AF_BLUE_STRING_CJK_TOP = af_blue_1_1 + 1,
- AF_BLUE_STRING_CJK_BOTTOM = af_blue_1_1 + 203,
- af_blue_1_1_1 = af_blue_1_1 + 404,
-#ifdef AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT
- AF_BLUE_STRING_CJK_LEFT = af_blue_1_1_1 + 1,
- AF_BLUE_STRING_CJK_RIGHT = af_blue_1_1_1 + 204,
- af_blue_1_1_2 = af_blue_1_1_1 + 405,
-#else
- af_blue_1_1_2 = af_blue_1_1_1 + 0,
-#endif /* AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT */
- af_blue_1_2 = af_blue_1_1_2 + 0,
-#else
- af_blue_1_2 = af_blue_1_1 + 0,
-#endif /* AF_CONFIG_OPTION_CJK */
-
-
- AF_BLUE_STRING_MAX /* do not remove */
-
- } AF_Blue_String;
-
-
- FT_LOCAL_ARRAY( char )
- af_blue_strings[];
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** B L U E S T R I N G S E T S *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- /* The next level is to group blue strings into style-specific sets. */
-
-
- /* Properties are specific to a writing system. We assume that a given */
- /* blue string can't be used in more than a single writing system, which */
- /* is a safe bet. */
-#define AF_BLUE_PROPERTY_LATIN_TOP ( 1U << 0 ) /* must have value 1 */
-#define AF_BLUE_PROPERTY_LATIN_SUB_TOP ( 1U << 1 )
-#define AF_BLUE_PROPERTY_LATIN_NEUTRAL ( 1U << 2 )
-#define AF_BLUE_PROPERTY_LATIN_X_HEIGHT ( 1U << 3 )
-#define AF_BLUE_PROPERTY_LATIN_LONG ( 1U << 4 )
-
-#define AF_BLUE_PROPERTY_CJK_TOP ( 1U << 0 ) /* must have value 1 */
-#define AF_BLUE_PROPERTY_CJK_HORIZ ( 1U << 1 ) /* must have value 2 */
-#define AF_BLUE_PROPERTY_CJK_RIGHT AF_BLUE_PROPERTY_CJK_TOP
-
-
-#define AF_BLUE_STRINGSET_MAX_LEN 8
-
- /* The AF_Blue_Stringset enumeration values are offsets into the */
- /* `af_blue_stringsets' array. */
-
- typedef enum AF_Blue_Stringset_
- {
- AF_BLUE_STRINGSET_ADLM = 0,
- AF_BLUE_STRINGSET_ARAB = 5,
- AF_BLUE_STRINGSET_ARMN = 9,
- AF_BLUE_STRINGSET_AVST = 16,
- AF_BLUE_STRINGSET_BAMU = 19,
- AF_BLUE_STRINGSET_BENG = 22,
- AF_BLUE_STRINGSET_BUHD = 27,
- AF_BLUE_STRINGSET_CAKM = 32,
- AF_BLUE_STRINGSET_CANS = 36,
- AF_BLUE_STRINGSET_CARI = 43,
- AF_BLUE_STRINGSET_CHER = 46,
- AF_BLUE_STRINGSET_COPT = 53,
- AF_BLUE_STRINGSET_CPRT = 58,
- AF_BLUE_STRINGSET_CYRL = 63,
- AF_BLUE_STRINGSET_DEVA = 69,
- AF_BLUE_STRINGSET_DSRT = 75,
- AF_BLUE_STRINGSET_ETHI = 80,
- AF_BLUE_STRINGSET_GEOR = 83,
- AF_BLUE_STRINGSET_GEOK = 90,
- AF_BLUE_STRINGSET_GLAG = 97,
- AF_BLUE_STRINGSET_GOTH = 102,
- AF_BLUE_STRINGSET_GREK = 105,
- AF_BLUE_STRINGSET_GUJR = 112,
- AF_BLUE_STRINGSET_GURU = 118,
- AF_BLUE_STRINGSET_HEBR = 124,
- AF_BLUE_STRINGSET_KNDA = 128,
- AF_BLUE_STRINGSET_KALI = 131,
- AF_BLUE_STRINGSET_KHMR = 137,
- AF_BLUE_STRINGSET_KHMS = 143,
- AF_BLUE_STRINGSET_LAO = 146,
- AF_BLUE_STRINGSET_LATN = 152,
- AF_BLUE_STRINGSET_LATB = 159,
- AF_BLUE_STRINGSET_LATP = 166,
- AF_BLUE_STRINGSET_LISU = 173,
- AF_BLUE_STRINGSET_MLYM = 176,
- AF_BLUE_STRINGSET_MEDF = 179,
- AF_BLUE_STRINGSET_MONG = 187,
- AF_BLUE_STRINGSET_MYMR = 190,
- AF_BLUE_STRINGSET_NKOO = 195,
- AF_BLUE_STRINGSET_NONE = 200,
- AF_BLUE_STRINGSET_OLCK = 201,
- AF_BLUE_STRINGSET_ORKH = 204,
- AF_BLUE_STRINGSET_OSGE = 207,
- AF_BLUE_STRINGSET_OSMA = 215,
- AF_BLUE_STRINGSET_ROHG = 218,
- AF_BLUE_STRINGSET_SAUR = 222,
- AF_BLUE_STRINGSET_SHAW = 225,
- AF_BLUE_STRINGSET_SINH = 231,
- AF_BLUE_STRINGSET_SUND = 235,
- AF_BLUE_STRINGSET_TAML = 239,
- AF_BLUE_STRINGSET_TAVT = 242,
- AF_BLUE_STRINGSET_TELU = 245,
- AF_BLUE_STRINGSET_THAI = 248,
- AF_BLUE_STRINGSET_TFNG = 256,
- AF_BLUE_STRINGSET_VAII = 259,
- af_blue_2_1 = 262,
-#ifdef AF_CONFIG_OPTION_CJK
- AF_BLUE_STRINGSET_HANI = af_blue_2_1 + 0,
- af_blue_2_1_1 = af_blue_2_1 + 2,
-#ifdef AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT
- af_blue_2_1_2 = af_blue_2_1_1 + 2,
-#else
- af_blue_2_1_2 = af_blue_2_1_1 + 0,
-#endif /* AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT */
- af_blue_2_2 = af_blue_2_1_2 + 1,
-#else
- af_blue_2_2 = af_blue_2_1 + 0,
-#endif /* AF_CONFIG_OPTION_CJK */
-
-
- AF_BLUE_STRINGSET_MAX /* do not remove */
-
- } AF_Blue_Stringset;
-
-
- typedef struct AF_Blue_StringRec_
- {
- AF_Blue_String string;
- FT_UShort properties;
-
- } AF_Blue_StringRec;
-
-
- FT_LOCAL_ARRAY( AF_Blue_StringRec )
- af_blue_stringsets[];
-
-/* */
-
-FT_END_HEADER
-
-
-#endif /* AFBLUE_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/autofit/afcjk.c b/contrib/libs/freetype/src/autofit/afcjk.c
deleted file mode 100644
index 869b60487c..0000000000
--- a/contrib/libs/freetype/src/autofit/afcjk.c
+++ /dev/null
@@ -1,2383 +0,0 @@
-/****************************************************************************
- *
- * afcjk.c
- *
- * Auto-fitter hinting routines for CJK writing system (body).
- *
- * Copyright (C) 2006-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
- /*
- * The algorithm is based on akito's autohint patch, archived at
- *
- * https://web.archive.org/web/20051219160454/http://www.kde.gr.jp:80/~akito/patch/freetype2/2.1.7/
- *
- */
-
-#include <freetype/ftadvanc.h>
-#include <freetype/internal/ftdebug.h>
-
-#include "afglobal.h"
-#include "aflatin.h"
-#include "afcjk.h"
-
-
-#ifdef AF_CONFIG_OPTION_CJK
-
-#undef AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT
-
-#include "aferrors.h"
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT afcjk
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** C J K G L O B A L M E T R I C S *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /* Basically the Latin version with AF_CJKMetrics */
- /* to replace AF_LatinMetrics. */
-
- FT_LOCAL_DEF( void )
- af_cjk_metrics_init_widths( AF_CJKMetrics metrics,
- FT_Face face )
- {
- /* scan the array of segments in each direction */
- AF_GlyphHintsRec hints[1];
-
-
- FT_TRACE5(( "\n" ));
- FT_TRACE5(( "cjk standard widths computation (style `%s')\n",
- af_style_names[metrics->root.style_class->style] ));
- FT_TRACE5(( "===================================================\n" ));
- FT_TRACE5(( "\n" ));
-
- af_glyph_hints_init( hints, face->memory );
-
- metrics->axis[AF_DIMENSION_HORZ].width_count = 0;
- metrics->axis[AF_DIMENSION_VERT].width_count = 0;
-
- {
- FT_Error error;
- FT_ULong glyph_index;
- int dim;
- AF_CJKMetricsRec dummy[1];
- AF_Scaler scaler = &dummy->root.scaler;
-
- AF_StyleClass style_class = metrics->root.style_class;
- AF_ScriptClass script_class = af_script_classes[style_class->script];
-
- /* If HarfBuzz is not available, we need a pointer to a single */
- /* unsigned long value. */
-#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
- void* shaper_buf;
-#else
- FT_ULong shaper_buf_;
- void* shaper_buf = &shaper_buf_;
-#endif
-
- const char* p;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- FT_ULong ch = 0;
-#endif
-
- p = script_class->standard_charstring;
-
-#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
- shaper_buf = af_shaper_buf_create( face );
-#endif
-
- /* We check a list of standard characters. The first match wins. */
-
- glyph_index = 0;
- while ( *p )
- {
- unsigned int num_idx;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- const char* p_old;
-#endif
-
-
- while ( *p == ' ' )
- p++;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- p_old = p;
- GET_UTF8_CHAR( ch, p_old );
-#endif
-
- /* reject input that maps to more than a single glyph */
- p = af_shaper_get_cluster( p, &metrics->root, shaper_buf, &num_idx );
- if ( num_idx > 1 )
- continue;
-
- /* otherwise exit loop if we have a result */
- glyph_index = af_shaper_get_elem( &metrics->root,
- shaper_buf,
- 0,
- NULL,
- NULL );
- if ( glyph_index )
- break;
- }
-
- af_shaper_buf_destroy( face, shaper_buf );
-
- if ( !glyph_index )
- goto Exit;
-
- if ( !glyph_index )
- goto Exit;
-
- FT_TRACE5(( "standard character: U+%04lX (glyph index %ld)\n",
- ch, glyph_index ));
-
- error = FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_SCALE );
- if ( error || face->glyph->outline.n_points <= 0 )
- goto Exit;
-
- FT_ZERO( dummy );
-
- dummy->units_per_em = metrics->units_per_em;
-
- scaler->x_scale = 0x10000L;
- scaler->y_scale = 0x10000L;
- scaler->x_delta = 0;
- scaler->y_delta = 0;
-
- scaler->face = face;
- scaler->render_mode = FT_RENDER_MODE_NORMAL;
- scaler->flags = 0;
-
- af_glyph_hints_rescale( hints, (AF_StyleMetrics)dummy );
-
- error = af_glyph_hints_reload( hints, &face->glyph->outline );
- if ( error )
- goto Exit;
-
- for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ )
- {
- AF_CJKAxis axis = &metrics->axis[dim];
- AF_AxisHints axhints = &hints->axis[dim];
- AF_Segment seg, limit, link;
- FT_UInt num_widths = 0;
-
-
- error = af_latin_hints_compute_segments( hints,
- (AF_Dimension)dim );
- if ( error )
- goto Exit;
-
- /*
- * We assume that the glyphs selected for the stem width
- * computation are `featureless' enough so that the linking
- * algorithm works fine without adjustments of its scoring
- * function.
- */
- af_latin_hints_link_segments( hints,
- 0,
- NULL,
- (AF_Dimension)dim );
-
- seg = axhints->segments;
- limit = seg + axhints->num_segments;
-
- for ( ; seg < limit; seg++ )
- {
- link = seg->link;
-
- /* we only consider stem segments there! */
- if ( link && link->link == seg && link > seg )
- {
- FT_Pos dist;
-
-
- dist = seg->pos - link->pos;
- if ( dist < 0 )
- dist = -dist;
-
- if ( num_widths < AF_CJK_MAX_WIDTHS )
- axis->widths[num_widths++].org = dist;
- }
- }
-
- /* this also replaces multiple almost identical stem widths */
- /* with a single one (the value 100 is heuristic) */
- af_sort_and_quantize_widths( &num_widths, axis->widths,
- dummy->units_per_em / 100 );
- axis->width_count = num_widths;
- }
-
- Exit:
- for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ )
- {
- AF_CJKAxis axis = &metrics->axis[dim];
- FT_Pos stdw;
-
-
- stdw = ( axis->width_count > 0 ) ? axis->widths[0].org
- : AF_LATIN_CONSTANT( metrics, 50 );
-
- /* let's try 20% of the smallest width */
- axis->edge_distance_threshold = stdw / 5;
- axis->standard_width = stdw;
- axis->extra_light = 0;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- {
- FT_UInt i;
-
-
- FT_TRACE5(( "%s widths:\n",
- dim == AF_DIMENSION_VERT ? "horizontal"
- : "vertical" ));
-
- FT_TRACE5(( " %ld (standard)", axis->standard_width ));
- for ( i = 1; i < axis->width_count; i++ )
- FT_TRACE5(( " %ld", axis->widths[i].org ));
-
- FT_TRACE5(( "\n" ));
- }
-#endif
- }
- }
-
- FT_TRACE5(( "\n" ));
-
- af_glyph_hints_done( hints );
- }
-
-
- /* Find all blue zones. */
-
- static void
- af_cjk_metrics_init_blues( AF_CJKMetrics metrics,
- FT_Face face )
- {
- FT_Pos fills[AF_BLUE_STRING_MAX_LEN];
- FT_Pos flats[AF_BLUE_STRING_MAX_LEN];
-
- FT_UInt num_fills;
- FT_UInt num_flats;
-
- FT_Bool fill;
-
- AF_CJKBlue blue;
- FT_Error error;
- AF_CJKAxis axis;
- FT_Outline outline;
-
- AF_StyleClass sc = metrics->root.style_class;
-
- AF_Blue_Stringset bss = sc->blue_stringset;
- const AF_Blue_StringRec* bs = &af_blue_stringsets[bss];
-
- /* If HarfBuzz is not available, we need a pointer to a single */
- /* unsigned long value. */
-#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
- void* shaper_buf;
-#else
- FT_ULong shaper_buf_;
- void* shaper_buf = &shaper_buf_;
-#endif
-
-
- /* we walk over the blue character strings as specified in the */
- /* style's entry in the `af_blue_stringset' array, computing its */
- /* extremum points (depending on the string properties) */
-
- FT_TRACE5(( "cjk blue zones computation\n" ));
- FT_TRACE5(( "==========================\n" ));
- FT_TRACE5(( "\n" ));
-
-#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
- shaper_buf = af_shaper_buf_create( face );
-#endif
-
- for ( ; bs->string != AF_BLUE_STRING_MAX; bs++ )
- {
- const char* p = &af_blue_strings[bs->string];
- FT_Pos* blue_ref;
- FT_Pos* blue_shoot;
-
-
- if ( AF_CJK_IS_HORIZ_BLUE( bs ) )
- axis = &metrics->axis[AF_DIMENSION_HORZ];
- else
- axis = &metrics->axis[AF_DIMENSION_VERT];
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- {
- FT_String* cjk_blue_name[4] =
- {
- (FT_String*)"bottom", /* -- , -- */
- (FT_String*)"top", /* -- , TOP */
- (FT_String*)"left", /* HORIZ, -- */
- (FT_String*)"right" /* HORIZ, TOP */
- };
-
-
- FT_TRACE5(( "blue zone %d (%s):\n",
- axis->blue_count,
- cjk_blue_name[AF_CJK_IS_HORIZ_BLUE( bs ) |
- AF_CJK_IS_TOP_BLUE( bs ) ] ));
- }
-#endif /* FT_DEBUG_LEVEL_TRACE */
-
- num_fills = 0;
- num_flats = 0;
-
- fill = 1; /* start with characters that define fill values */
- FT_TRACE5(( " [overshoot values]\n" ));
-
- while ( *p )
- {
- FT_ULong glyph_index;
- FT_Pos best_pos; /* same as points.y or points.x, resp. */
- FT_Int best_point;
- FT_Vector* points;
-
- unsigned int num_idx;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- const char* p_old;
- FT_ULong ch;
-#endif
-
-
- while ( *p == ' ' )
- p++;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- p_old = p;
- GET_UTF8_CHAR( ch, p_old );
-#endif
-
- /* switch to characters that define flat values */
- if ( *p == '|' )
- {
- fill = 0;
- FT_TRACE5(( " [reference values]\n" ));
- p++;
- continue;
- }
-
- /* reject input that maps to more than a single glyph */
- p = af_shaper_get_cluster( p, &metrics->root, shaper_buf, &num_idx );
- if ( num_idx > 1 )
- continue;
-
- /* load the character in the face -- skip unknown or empty ones */
- glyph_index = af_shaper_get_elem( &metrics->root,
- shaper_buf,
- 0,
- NULL,
- NULL );
- if ( glyph_index == 0 )
- {
- FT_TRACE5(( " U+%04lX unavailable\n", ch ));
- continue;
- }
-
- error = FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_SCALE );
- outline = face->glyph->outline;
- if ( error || outline.n_points <= 2 )
- {
- FT_TRACE5(( " U+%04lX contains no (usable) outlines\n", ch ));
- continue;
- }
-
- /* now compute min or max point indices and coordinates */
- points = outline.points;
- best_point = -1;
- best_pos = 0; /* make compiler happy */
-
- {
- FT_Int nn;
- FT_Int pp, first, last;
-
-
- last = -1;
- for ( nn = 0; nn < outline.n_contours; nn++ )
- {
- first = last + 1;
- last = outline.contours[nn];
-
- /* Avoid single-point contours since they are never rasterized. */
- /* In some fonts, they correspond to mark attachment points */
- /* which are way outside of the glyph's real outline. */
- if ( last <= first )
- continue;
-
- if ( AF_CJK_IS_HORIZ_BLUE( bs ) )
- {
- if ( AF_CJK_IS_RIGHT_BLUE( bs ) )
- {
- for ( pp = first; pp <= last; pp++ )
- if ( best_point < 0 || points[pp].x > best_pos )
- {
- best_point = pp;
- best_pos = points[pp].x;
- }
- }
- else
- {
- for ( pp = first; pp <= last; pp++ )
- if ( best_point < 0 || points[pp].x < best_pos )
- {
- best_point = pp;
- best_pos = points[pp].x;
- }
- }
- }
- else
- {
- if ( AF_CJK_IS_TOP_BLUE( bs ) )
- {
- for ( pp = first; pp <= last; pp++ )
- if ( best_point < 0 || points[pp].y > best_pos )
- {
- best_point = pp;
- best_pos = points[pp].y;
- }
- }
- else
- {
- for ( pp = first; pp <= last; pp++ )
- if ( best_point < 0 || points[pp].y < best_pos )
- {
- best_point = pp;
- best_pos = points[pp].y;
- }
- }
- }
- }
-
- FT_TRACE5(( " U+%04lX: best_pos = %5ld\n", ch, best_pos ));
- }
-
- if ( fill )
- fills[num_fills++] = best_pos;
- else
- flats[num_flats++] = best_pos;
-
- } /* end while loop */
-
- if ( num_flats == 0 && num_fills == 0 )
- {
- /*
- * we couldn't find a single glyph to compute this blue zone,
- * we will simply ignore it then
- */
- FT_TRACE5(( " empty\n" ));
- continue;
- }
-
- /* we have computed the contents of the `fill' and `flats' tables, */
- /* now determine the reference and overshoot position of the blue -- */
- /* we simply take the median value after a simple sort */
- af_sort_pos( num_fills, fills );
- af_sort_pos( num_flats, flats );
-
- blue = &axis->blues[axis->blue_count];
- blue_ref = &blue->ref.org;
- blue_shoot = &blue->shoot.org;
-
- axis->blue_count++;
-
- if ( num_flats == 0 )
- {
- *blue_ref =
- *blue_shoot = fills[num_fills / 2];
- }
- else if ( num_fills == 0 )
- {
- *blue_ref =
- *blue_shoot = flats[num_flats / 2];
- }
- else
- {
- *blue_ref = fills[num_fills / 2];
- *blue_shoot = flats[num_flats / 2];
- }
-
- /* make sure blue_ref >= blue_shoot for top/right or */
- /* vice versa for bottom/left */
- if ( *blue_shoot != *blue_ref )
- {
- FT_Pos ref = *blue_ref;
- FT_Pos shoot = *blue_shoot;
- FT_Bool under_ref = FT_BOOL( shoot < ref );
-
-
- /* AF_CJK_IS_TOP_BLUE covers `right' and `top' */
- if ( AF_CJK_IS_TOP_BLUE( bs ) ^ under_ref )
- {
- *blue_ref =
- *blue_shoot = ( shoot + ref ) / 2;
-
- FT_TRACE5(( " [reference smaller than overshoot,"
- " taking mean value]\n" ));
- }
- }
-
- blue->flags = 0;
- if ( AF_CJK_IS_TOP_BLUE( bs ) )
- blue->flags |= AF_CJK_BLUE_TOP;
-
- FT_TRACE5(( " -> reference = %ld\n", *blue_ref ));
- FT_TRACE5(( " overshoot = %ld\n", *blue_shoot ));
-
- } /* end for loop */
-
- af_shaper_buf_destroy( face, shaper_buf );
-
- FT_TRACE5(( "\n" ));
-
- return;
- }
-
-
- /* Basically the Latin version with type AF_CJKMetrics for metrics. */
-
- FT_LOCAL_DEF( void )
- af_cjk_metrics_check_digits( AF_CJKMetrics metrics,
- FT_Face face )
- {
- FT_Bool started = 0, same_width = 1;
- FT_Long advance = 0, old_advance = 0;
-
- /* If HarfBuzz is not available, we need a pointer to a single */
- /* unsigned long value. */
-#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
- void* shaper_buf;
-#else
- FT_ULong shaper_buf_;
- void* shaper_buf = &shaper_buf_;
-#endif
-
- /* in all supported charmaps, digits have character codes 0x30-0x39 */
- const char digits[] = "0 1 2 3 4 5 6 7 8 9";
- const char* p;
-
-
- p = digits;
-
-#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
- shaper_buf = af_shaper_buf_create( face );
-#endif
-
- while ( *p )
- {
- FT_ULong glyph_index;
- unsigned int num_idx;
-
-
- /* reject input that maps to more than a single glyph */
- p = af_shaper_get_cluster( p, &metrics->root, shaper_buf, &num_idx );
- if ( num_idx > 1 )
- continue;
-
- glyph_index = af_shaper_get_elem( &metrics->root,
- shaper_buf,
- 0,
- &advance,
- NULL );
- if ( !glyph_index )
- continue;
-
- if ( started )
- {
- if ( advance != old_advance )
- {
- same_width = 0;
- break;
- }
- }
- else
- {
- old_advance = advance;
- started = 1;
- }
- }
-
- af_shaper_buf_destroy( face, shaper_buf );
-
- metrics->root.digits_have_same_width = same_width;
- }
-
-
- /* Initialize global metrics. */
-
- FT_LOCAL_DEF( FT_Error )
- af_cjk_metrics_init( AF_StyleMetrics metrics_, /* AF_CJKMetrics */
- FT_Face face )
- {
- AF_CJKMetrics metrics = (AF_CJKMetrics)metrics_;
- FT_CharMap oldmap = face->charmap;
-
-
- metrics->units_per_em = face->units_per_EM;
-
- if ( !FT_Select_Charmap( face, FT_ENCODING_UNICODE ) )
- {
- af_cjk_metrics_init_widths( metrics, face );
- af_cjk_metrics_init_blues( metrics, face );
- af_cjk_metrics_check_digits( metrics, face );
- }
-
- face->charmap = oldmap;
- return FT_Err_Ok;
- }
-
-
- /* Adjust scaling value, then scale and shift widths */
- /* and blue zones (if applicable) for given dimension. */
-
- static void
- af_cjk_metrics_scale_dim( AF_CJKMetrics metrics,
- AF_Scaler scaler,
- AF_Dimension dim )
- {
- FT_Fixed scale;
- FT_Pos delta;
- AF_CJKAxis axis;
- FT_UInt nn;
-
-
- if ( dim == AF_DIMENSION_HORZ )
- {
- scale = scaler->x_scale;
- delta = scaler->x_delta;
- }
- else
- {
- scale = scaler->y_scale;
- delta = scaler->y_delta;
- }
-
- axis = &metrics->axis[dim];
-
- if ( axis->org_scale == scale && axis->org_delta == delta )
- return;
-
- axis->org_scale = scale;
- axis->org_delta = delta;
-
- axis->scale = scale;
- axis->delta = delta;
-
- /* scale the blue zones */
- for ( nn = 0; nn < axis->blue_count; nn++ )
- {
- AF_CJKBlue blue = &axis->blues[nn];
- FT_Pos dist;
-
-
- blue->ref.cur = FT_MulFix( blue->ref.org, scale ) + delta;
- blue->ref.fit = blue->ref.cur;
- blue->shoot.cur = FT_MulFix( blue->shoot.org, scale ) + delta;
- blue->shoot.fit = blue->shoot.cur;
- blue->flags &= ~AF_CJK_BLUE_ACTIVE;
-
- /* a blue zone is only active if it is less than 3/4 pixels tall */
- dist = FT_MulFix( blue->ref.org - blue->shoot.org, scale );
- if ( dist <= 48 && dist >= -48 )
- {
- FT_Pos delta1, delta2;
-
-
- blue->ref.fit = FT_PIX_ROUND( blue->ref.cur );
-
- /* shoot is under shoot for cjk */
- delta1 = FT_DivFix( blue->ref.fit, scale ) - blue->shoot.org;
- delta2 = delta1;
- if ( delta1 < 0 )
- delta2 = -delta2;
-
- delta2 = FT_MulFix( delta2, scale );
-
- FT_TRACE5(( "delta: %ld", delta1 ));
- if ( delta2 < 32 )
- delta2 = 0;
-#if 0
- else if ( delta2 < 64 )
- delta2 = 32 + ( ( ( delta2 - 32 ) + 16 ) & ~31 );
-#endif
- else
- delta2 = FT_PIX_ROUND( delta2 );
- FT_TRACE5(( "/%ld\n", delta2 ));
-
- if ( delta1 < 0 )
- delta2 = -delta2;
-
- blue->shoot.fit = blue->ref.fit - delta2;
-
- FT_TRACE5(( ">> active cjk blue zone %c%d[%ld/%ld]:\n",
- ( dim == AF_DIMENSION_HORZ ) ? 'H' : 'V',
- nn, blue->ref.org, blue->shoot.org ));
- FT_TRACE5(( " ref: cur=%.2f fit=%.2f\n",
- (double)blue->ref.cur / 64,
- (double)blue->ref.fit / 64 ));
- FT_TRACE5(( " shoot: cur=%.2f fit=%.2f\n",
- (double)blue->shoot.cur / 64,
- (double)blue->shoot.fit / 64 ));
-
- blue->flags |= AF_CJK_BLUE_ACTIVE;
- }
- }
- }
-
-
- /* Scale global values in both directions. */
-
- FT_LOCAL_DEF( void )
- af_cjk_metrics_scale( AF_StyleMetrics metrics_, /* AF_CJKMetrics */
- AF_Scaler scaler )
- {
- AF_CJKMetrics metrics = (AF_CJKMetrics)metrics_;
-
-
- /* we copy the whole structure since the x and y scaling values */
- /* are not modified, contrary to e.g. the `latin' auto-hinter */
- metrics->root.scaler = *scaler;
-
- af_cjk_metrics_scale_dim( metrics, scaler, AF_DIMENSION_HORZ );
- af_cjk_metrics_scale_dim( metrics, scaler, AF_DIMENSION_VERT );
- }
-
-
- /* Extract standard_width from writing system/script specific */
- /* metrics class. */
-
- FT_CALLBACK_DEF( void )
- af_cjk_get_standard_widths( AF_StyleMetrics metrics_, /* AF_CJKMetrics */
- FT_Pos* stdHW,
- FT_Pos* stdVW )
- {
- AF_CJKMetrics metrics = (AF_CJKMetrics)metrics_;
-
-
- if ( stdHW )
- *stdHW = metrics->axis[AF_DIMENSION_VERT].standard_width;
-
- if ( stdVW )
- *stdVW = metrics->axis[AF_DIMENSION_HORZ].standard_width;
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** C J K G L Y P H A N A L Y S I S *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /* Walk over all contours and compute its segments. */
-
- static FT_Error
- af_cjk_hints_compute_segments( AF_GlyphHints hints,
- AF_Dimension dim )
- {
- AF_AxisHints axis = &hints->axis[dim];
- AF_Segment segments = axis->segments;
- AF_Segment segment_limit = FT_OFFSET( segments, axis->num_segments );
- FT_Error error;
- AF_Segment seg;
-
-
- error = af_latin_hints_compute_segments( hints, dim );
- if ( error )
- return error;
-
- /* a segment is round if it doesn't have successive */
- /* on-curve points. */
- for ( seg = segments; seg < segment_limit; seg++ )
- {
- AF_Point pt = seg->first;
- AF_Point last = seg->last;
- FT_UInt f0 = pt->flags & AF_FLAG_CONTROL;
- FT_UInt f1;
-
-
- seg->flags &= ~AF_EDGE_ROUND;
-
- for ( ; pt != last; f0 = f1 )
- {
- pt = pt->next;
- f1 = pt->flags & AF_FLAG_CONTROL;
-
- if ( !f0 && !f1 )
- break;
-
- if ( pt == last )
- seg->flags |= AF_EDGE_ROUND;
- }
- }
-
- return FT_Err_Ok;
- }
-
-
- static void
- af_cjk_hints_link_segments( AF_GlyphHints hints,
- AF_Dimension dim )
- {
- AF_AxisHints axis = &hints->axis[dim];
- AF_Segment segments = axis->segments;
- AF_Segment segment_limit = FT_OFFSET( segments, axis->num_segments );
- AF_Direction major_dir = axis->major_dir;
- AF_Segment seg1, seg2;
- FT_Pos len_threshold;
- FT_Pos dist_threshold;
-
-
- len_threshold = AF_LATIN_CONSTANT( hints->metrics, 8 );
-
- dist_threshold = ( dim == AF_DIMENSION_HORZ ) ? hints->x_scale
- : hints->y_scale;
- dist_threshold = FT_DivFix( 64 * 3, dist_threshold );
-
- /* now compare each segment to the others */
- for ( seg1 = segments; seg1 < segment_limit; seg1++ )
- {
- if ( seg1->dir != major_dir )
- continue;
-
- for ( seg2 = segments; seg2 < segment_limit; seg2++ )
- if ( seg2 != seg1 && seg1->dir + seg2->dir == 0 )
- {
- FT_Pos dist = seg2->pos - seg1->pos;
-
-
- if ( dist < 0 )
- continue;
-
- {
- FT_Pos min = seg1->min_coord;
- FT_Pos max = seg1->max_coord;
- FT_Pos len;
-
-
- if ( min < seg2->min_coord )
- min = seg2->min_coord;
-
- if ( max > seg2->max_coord )
- max = seg2->max_coord;
-
- len = max - min;
- if ( len >= len_threshold )
- {
- if ( dist * 8 < seg1->score * 9 &&
- ( dist * 8 < seg1->score * 7 || seg1->len < len ) )
- {
- seg1->score = dist;
- seg1->len = len;
- seg1->link = seg2;
- }
-
- if ( dist * 8 < seg2->score * 9 &&
- ( dist * 8 < seg2->score * 7 || seg2->len < len ) )
- {
- seg2->score = dist;
- seg2->len = len;
- seg2->link = seg1;
- }
- }
- }
- }
- }
-
- /*
- * now compute the `serif' segments
- *
- * In Hanzi, some strokes are wider on one or both of the ends.
- * We either identify the stems on the ends as serifs or remove
- * the linkage, depending on the length of the stems.
- *
- */
-
- {
- AF_Segment link1, link2;
-
-
- for ( seg1 = segments; seg1 < segment_limit; seg1++ )
- {
- link1 = seg1->link;
- if ( !link1 || link1->link != seg1 || link1->pos <= seg1->pos )
- continue;
-
- if ( seg1->score >= dist_threshold )
- continue;
-
- for ( seg2 = segments; seg2 < segment_limit; seg2++ )
- {
- if ( seg2->pos > seg1->pos || seg1 == seg2 )
- continue;
-
- link2 = seg2->link;
- if ( !link2 || link2->link != seg2 || link2->pos < link1->pos )
- continue;
-
- if ( seg1->pos == seg2->pos && link1->pos == link2->pos )
- continue;
-
- if ( seg2->score <= seg1->score || seg1->score * 4 <= seg2->score )
- continue;
-
- /* seg2 < seg1 < link1 < link2 */
-
- if ( seg1->len >= seg2->len * 3 )
- {
- AF_Segment seg;
-
-
- for ( seg = segments; seg < segment_limit; seg++ )
- {
- AF_Segment link = seg->link;
-
-
- if ( link == seg2 )
- {
- seg->link = NULL;
- seg->serif = link1;
- }
- else if ( link == link2 )
- {
- seg->link = NULL;
- seg->serif = seg1;
- }
- }
- }
- else
- {
- seg1->link = link1->link = NULL;
-
- break;
- }
- }
- }
- }
-
- for ( seg1 = segments; seg1 < segment_limit; seg1++ )
- {
- seg2 = seg1->link;
-
- if ( seg2 )
- {
- if ( seg2->link != seg1 )
- {
- seg1->link = NULL;
-
- if ( seg2->score < dist_threshold || seg1->score < seg2->score * 4 )
- seg1->serif = seg2->link;
- }
- }
- }
- }
-
-
- static FT_Error
- af_cjk_hints_compute_edges( AF_GlyphHints hints,
- AF_Dimension dim )
- {
- AF_AxisHints axis = &hints->axis[dim];
- FT_Error error = FT_Err_Ok;
- FT_Memory memory = hints->memory;
- AF_CJKAxis laxis = &((AF_CJKMetrics)hints->metrics)->axis[dim];
-
- AF_Segment segments = axis->segments;
- AF_Segment segment_limit = FT_OFFSET( segments, axis->num_segments );
- AF_Segment seg;
-
- FT_Fixed scale;
- FT_Pos edge_distance_threshold;
-
-
- axis->num_edges = 0;
-
- scale = ( dim == AF_DIMENSION_HORZ ) ? hints->x_scale
- : hints->y_scale;
-
- /**********************************************************************
- *
- * We begin by generating a sorted table of edges for the current
- * direction. To do so, we simply scan each segment and try to find
- * an edge in our table that corresponds to its position.
- *
- * If no edge is found, we create and insert a new edge in the
- * sorted table. Otherwise, we simply add the segment to the edge's
- * list which is then processed in the second step to compute the
- * edge's properties.
- *
- * Note that the edges table is sorted along the segment/edge
- * position.
- *
- */
-
- edge_distance_threshold = FT_MulFix( laxis->edge_distance_threshold,
- scale );
- if ( edge_distance_threshold > 64 / 4 )
- edge_distance_threshold = FT_DivFix( 64 / 4, scale );
- else
- edge_distance_threshold = laxis->edge_distance_threshold;
-
- for ( seg = segments; seg < segment_limit; seg++ )
- {
- AF_Edge found = NULL;
- FT_Pos best = 0xFFFFU;
- FT_UInt ee;
-
-
- /* look for an edge corresponding to the segment */
- for ( ee = 0; ee < axis->num_edges; ee++ )
- {
- AF_Edge edge = axis->edges + ee;
- FT_Pos dist;
-
-
- if ( edge->dir != seg->dir )
- continue;
-
- dist = seg->pos - edge->fpos;
- if ( dist < 0 )
- dist = -dist;
-
- if ( dist < edge_distance_threshold && dist < best )
- {
- AF_Segment link = seg->link;
-
-
- /* check whether all linked segments of the candidate edge */
- /* can make a single edge. */
- if ( link )
- {
- AF_Segment seg1 = edge->first;
- FT_Pos dist2 = 0;
-
-
- do
- {
- AF_Segment link1 = seg1->link;
-
-
- if ( link1 )
- {
- dist2 = AF_SEGMENT_DIST( link, link1 );
- if ( dist2 >= edge_distance_threshold )
- break;
- }
-
- } while ( ( seg1 = seg1->edge_next ) != edge->first );
-
- if ( dist2 >= edge_distance_threshold )
- continue;
- }
-
- best = dist;
- found = edge;
- }
- }
-
- if ( !found )
- {
- AF_Edge edge;
-
-
- /* insert a new edge in the list and */
- /* sort according to the position */
- error = af_axis_hints_new_edge( axis, seg->pos,
- (AF_Direction)seg->dir, 0,
- memory, &edge );
- if ( error )
- goto Exit;
-
- /* add the segment to the new edge's list */
- FT_ZERO( edge );
-
- edge->first = seg;
- edge->last = seg;
- edge->dir = seg->dir;
- edge->fpos = seg->pos;
- edge->opos = FT_MulFix( seg->pos, scale );
- edge->pos = edge->opos;
- seg->edge_next = seg;
- }
- else
- {
- /* if an edge was found, simply add the segment to the edge's */
- /* list */
- seg->edge_next = found->first;
- found->last->edge_next = seg;
- found->last = seg;
- }
- }
-
- /*******************************************************************
- *
- * Good, we now compute each edge's properties according to the
- * segments found on its position. Basically, these are
- *
- * - the edge's main direction
- * - stem edge, serif edge or both (which defaults to stem then)
- * - rounded edge, straight or both (which defaults to straight)
- * - link for edge
- *
- */
-
- /* first of all, set the `edge' field in each segment -- this is */
- /* required in order to compute edge links */
-
- /*
- * Note that removing this loop and setting the `edge' field of each
- * segment directly in the code above slows down execution speed for
- * some reasons on platforms like the Sun.
- */
- {
- AF_Edge edges = axis->edges;
- AF_Edge edge_limit = FT_OFFSET( edges, axis->num_edges );
- AF_Edge edge;
-
-
- for ( edge = edges; edge < edge_limit; edge++ )
- {
- seg = edge->first;
- if ( seg )
- do
- {
- seg->edge = edge;
- seg = seg->edge_next;
-
- } while ( seg != edge->first );
- }
-
- /* now compute each edge properties */
- for ( edge = edges; edge < edge_limit; edge++ )
- {
- FT_Int is_round = 0; /* does it contain round segments? */
- FT_Int is_straight = 0; /* does it contain straight segments? */
-
-
- seg = edge->first;
- if ( !seg )
- goto Skip_Loop;
-
- do
- {
- FT_Bool is_serif;
-
-
- /* check for roundness of segment */
- if ( seg->flags & AF_EDGE_ROUND )
- is_round++;
- else
- is_straight++;
-
- /* check for links -- if seg->serif is set, then seg->link must */
- /* be ignored */
- is_serif = FT_BOOL( seg->serif && seg->serif->edge != edge );
-
- if ( seg->link || is_serif )
- {
- AF_Edge edge2;
- AF_Segment seg2;
-
-
- edge2 = edge->link;
- seg2 = seg->link;
-
- if ( is_serif )
- {
- seg2 = seg->serif;
- edge2 = edge->serif;
- }
-
- if ( edge2 )
- {
- FT_Pos edge_delta;
- FT_Pos seg_delta;
-
-
- edge_delta = edge->fpos - edge2->fpos;
- if ( edge_delta < 0 )
- edge_delta = -edge_delta;
-
- seg_delta = AF_SEGMENT_DIST( seg, seg2 );
-
- if ( seg_delta < edge_delta )
- edge2 = seg2->edge;
- }
- else
- edge2 = seg2->edge;
-
- if ( is_serif )
- {
- edge->serif = edge2;
- edge2->flags |= AF_EDGE_SERIF;
- }
- else
- edge->link = edge2;
- }
-
- seg = seg->edge_next;
-
- } while ( seg != edge->first );
-
- Skip_Loop:
- /* set the round/straight flags */
- edge->flags = AF_EDGE_NORMAL;
-
- if ( is_round > 0 && is_round >= is_straight )
- edge->flags |= AF_EDGE_ROUND;
-
- /* get rid of serifs if link is set */
- /* XXX: This gets rid of many unpleasant artefacts! */
- /* Example: the `c' in cour.pfa at size 13 */
-
- if ( edge->serif && edge->link )
- edge->serif = NULL;
- }
- }
-
- Exit:
- return error;
- }
-
-
- /* Detect segments and edges for given dimension. */
-
- static FT_Error
- af_cjk_hints_detect_features( AF_GlyphHints hints,
- AF_Dimension dim )
- {
- FT_Error error;
-
-
- error = af_cjk_hints_compute_segments( hints, dim );
- if ( !error )
- {
- af_cjk_hints_link_segments( hints, dim );
-
- error = af_cjk_hints_compute_edges( hints, dim );
- }
- return error;
- }
-
-
- /* Compute all edges which lie within blue zones. */
-
- static void
- af_cjk_hints_compute_blue_edges( AF_GlyphHints hints,
- AF_CJKMetrics metrics,
- AF_Dimension dim )
- {
- AF_AxisHints axis = &hints->axis[dim];
- AF_Edge edge = axis->edges;
- AF_Edge edge_limit = FT_OFFSET( edge, axis->num_edges );
- AF_CJKAxis cjk = &metrics->axis[dim];
- FT_Fixed scale = cjk->scale;
- FT_Pos best_dist0; /* initial threshold */
-
-
- /* compute the initial threshold as a fraction of the EM size */
- best_dist0 = FT_MulFix( metrics->units_per_em / 40, scale );
-
- if ( best_dist0 > 64 / 2 ) /* maximum 1/2 pixel */
- best_dist0 = 64 / 2;
-
- /* compute which blue zones are active, i.e. have their scaled */
- /* size < 3/4 pixels */
-
- /* If the distant between an edge and a blue zone is shorter than */
- /* best_dist0, set the blue zone for the edge. Then search for */
- /* the blue zone with the smallest best_dist to the edge. */
-
- for ( ; edge < edge_limit; edge++ )
- {
- FT_UInt bb;
- AF_Width best_blue = NULL;
- FT_Pos best_dist = best_dist0;
-
-
- for ( bb = 0; bb < cjk->blue_count; bb++ )
- {
- AF_CJKBlue blue = cjk->blues + bb;
- FT_Bool is_top_right_blue, is_major_dir;
-
-
- /* skip inactive blue zones (i.e., those that are too small) */
- if ( !( blue->flags & AF_CJK_BLUE_ACTIVE ) )
- continue;
-
- /* if it is a top zone, check for right edges -- if it is a bottom */
- /* zone, check for left edges */
- /* */
- /* of course, that's for TrueType */
- is_top_right_blue =
- (FT_Byte)( ( blue->flags & AF_CJK_BLUE_TOP ) != 0 );
- is_major_dir =
- FT_BOOL( edge->dir == axis->major_dir );
-
- /* if it is a top zone, the edge must be against the major */
- /* direction; if it is a bottom zone, it must be in the major */
- /* direction */
- if ( is_top_right_blue ^ is_major_dir )
- {
- FT_Pos dist;
- AF_Width compare;
-
-
- /* Compare the edge to the closest blue zone type */
- if ( FT_ABS( edge->fpos - blue->ref.org ) >
- FT_ABS( edge->fpos - blue->shoot.org ) )
- compare = &blue->shoot;
- else
- compare = &blue->ref;
-
- dist = edge->fpos - compare->org;
- if ( dist < 0 )
- dist = -dist;
-
- dist = FT_MulFix( dist, scale );
- if ( dist < best_dist )
- {
- best_dist = dist;
- best_blue = compare;
- }
- }
- }
-
- if ( best_blue )
- edge->blue_edge = best_blue;
- }
- }
-
-
- /* Initalize hinting engine. */
-
- FT_LOCAL_DEF( FT_Error )
- af_cjk_hints_init( AF_GlyphHints hints,
- AF_StyleMetrics metrics_ ) /* AF_CJKMetrics */
- {
- AF_CJKMetrics metrics = (AF_CJKMetrics)metrics_;
- FT_Render_Mode mode;
- FT_UInt32 scaler_flags, other_flags;
-
-
- af_glyph_hints_rescale( hints, (AF_StyleMetrics)metrics );
-
- /*
- * correct x_scale and y_scale when needed, since they may have
- * been modified af_cjk_scale_dim above
- */
- hints->x_scale = metrics->axis[AF_DIMENSION_HORZ].scale;
- hints->x_delta = metrics->axis[AF_DIMENSION_HORZ].delta;
- hints->y_scale = metrics->axis[AF_DIMENSION_VERT].scale;
- hints->y_delta = metrics->axis[AF_DIMENSION_VERT].delta;
-
- /* compute flags depending on render mode, etc. */
- mode = metrics->root.scaler.render_mode;
-
- scaler_flags = hints->scaler_flags;
- other_flags = 0;
-
- /*
- * We snap the width of vertical stems for the monochrome and
- * horizontal LCD rendering targets only.
- */
- if ( mode == FT_RENDER_MODE_MONO || mode == FT_RENDER_MODE_LCD )
- other_flags |= AF_LATIN_HINTS_HORZ_SNAP;
-
- /*
- * We snap the width of horizontal stems for the monochrome and
- * vertical LCD rendering targets only.
- */
- if ( mode == FT_RENDER_MODE_MONO || mode == FT_RENDER_MODE_LCD_V )
- other_flags |= AF_LATIN_HINTS_VERT_SNAP;
-
- /*
- * We adjust stems to full pixels unless in `light' or `lcd' mode.
- */
- if ( mode != FT_RENDER_MODE_LIGHT && mode != FT_RENDER_MODE_LCD )
- other_flags |= AF_LATIN_HINTS_STEM_ADJUST;
-
- if ( mode == FT_RENDER_MODE_MONO )
- other_flags |= AF_LATIN_HINTS_MONO;
-
- scaler_flags |= AF_SCALER_FLAG_NO_ADVANCE;
-
- hints->scaler_flags = scaler_flags;
- hints->other_flags = other_flags;
-
- return FT_Err_Ok;
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** C J K G L Y P H G R I D - F I T T I N G *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- /* Snap a given width in scaled coordinates to one of the */
- /* current standard widths. */
-
- static FT_Pos
- af_cjk_snap_width( AF_Width widths,
- FT_UInt count,
- FT_Pos width )
- {
- FT_UInt n;
- FT_Pos best = 64 + 32 + 2;
- FT_Pos reference = width;
- FT_Pos scaled;
-
-
- for ( n = 0; n < count; n++ )
- {
- FT_Pos w;
- FT_Pos dist;
-
-
- w = widths[n].cur;
- dist = width - w;
- if ( dist < 0 )
- dist = -dist;
- if ( dist < best )
- {
- best = dist;
- reference = w;
- }
- }
-
- scaled = FT_PIX_ROUND( reference );
-
- if ( width >= reference )
- {
- if ( width < scaled + 48 )
- width = reference;
- }
- else
- {
- if ( width > scaled - 48 )
- width = reference;
- }
-
- return width;
- }
-
-
- /* Compute the snapped width of a given stem. */
- /* There is a lot of voodoo in this function; changing the hard-coded */
- /* parameters influence the whole hinting process. */
-
- static FT_Pos
- af_cjk_compute_stem_width( AF_GlyphHints hints,
- AF_Dimension dim,
- FT_Pos width,
- FT_UInt base_flags,
- FT_UInt stem_flags )
- {
- AF_CJKMetrics metrics = (AF_CJKMetrics)hints->metrics;
- AF_CJKAxis axis = &metrics->axis[dim];
- FT_Pos dist = width;
- FT_Int sign = 0;
- FT_Bool vertical = FT_BOOL( dim == AF_DIMENSION_VERT );
-
- FT_UNUSED( base_flags );
- FT_UNUSED( stem_flags );
-
-
- if ( !AF_LATIN_HINTS_DO_STEM_ADJUST( hints ) )
- return width;
-
- if ( dist < 0 )
- {
- dist = -width;
- sign = 1;
- }
-
- if ( ( vertical && !AF_LATIN_HINTS_DO_VERT_SNAP( hints ) ) ||
- ( !vertical && !AF_LATIN_HINTS_DO_HORZ_SNAP( hints ) ) )
- {
- /* smooth hinting process: very lightly quantize the stem width */
-
- if ( axis->width_count > 0 )
- {
- if ( FT_ABS( dist - axis->widths[0].cur ) < 40 )
- {
- dist = axis->widths[0].cur;
- if ( dist < 48 )
- dist = 48;
-
- goto Done_Width;
- }
- }
-
- if ( dist < 54 )
- dist += ( 54 - dist ) / 2;
- else if ( dist < 3 * 64 )
- {
- FT_Pos delta;
-
-
- delta = dist & 63;
- dist &= -64;
-
- if ( delta < 10 )
- dist += delta;
- else if ( delta < 22 )
- dist += 10;
- else if ( delta < 42 )
- dist += delta;
- else if ( delta < 54 )
- dist += 54;
- else
- dist += delta;
- }
- }
- else
- {
- /* strong hinting process: snap the stem width to integer pixels */
-
- dist = af_cjk_snap_width( axis->widths, axis->width_count, dist );
-
- if ( vertical )
- {
- /* in the case of vertical hinting, always round */
- /* the stem heights to integer pixels */
-
- if ( dist >= 64 )
- dist = ( dist + 16 ) & ~63;
- else
- dist = 64;
- }
- else
- {
- if ( AF_LATIN_HINTS_DO_MONO( hints ) )
- {
- /* monochrome horizontal hinting: snap widths to integer pixels */
- /* with a different threshold */
-
- if ( dist < 64 )
- dist = 64;
- else
- dist = ( dist + 32 ) & ~63;
- }
- else
- {
- /* for horizontal anti-aliased hinting, we adopt a more subtle */
- /* approach: we strengthen small stems, round stems whose size */
- /* is between 1 and 2 pixels to an integer, otherwise nothing */
-
- if ( dist < 48 )
- dist = ( dist + 64 ) >> 1;
-
- else if ( dist < 128 )
- dist = ( dist + 22 ) & ~63;
- else
- /* round otherwise to prevent color fringes in LCD mode */
- dist = ( dist + 32 ) & ~63;
- }
- }
- }
-
- Done_Width:
- if ( sign )
- dist = -dist;
-
- return dist;
- }
-
-
- /* Align one stem edge relative to the previous stem edge. */
-
- static void
- af_cjk_align_linked_edge( AF_GlyphHints hints,
- AF_Dimension dim,
- AF_Edge base_edge,
- AF_Edge stem_edge )
- {
- FT_Pos dist = stem_edge->opos - base_edge->opos;
-
- FT_Pos fitted_width = af_cjk_compute_stem_width( hints, dim, dist,
- base_edge->flags,
- stem_edge->flags );
-
-
- stem_edge->pos = base_edge->pos + fitted_width;
-
- FT_TRACE5(( " CJKLINK: edge %td @%d (opos=%.2f) linked to %.2f,"
- " dist was %.2f, now %.2f\n",
- stem_edge - hints->axis[dim].edges, stem_edge->fpos,
- (double)stem_edge->opos / 64,
- (double)stem_edge->pos / 64,
- (double)dist / 64,
- (double)fitted_width / 64 ));
- }
-
-
- /* Shift the coordinates of the `serif' edge by the same amount */
- /* as the corresponding `base' edge has been moved already. */
-
- static void
- af_cjk_align_serif_edge( AF_GlyphHints hints,
- AF_Edge base,
- AF_Edge serif )
- {
- FT_UNUSED( hints );
-
- serif->pos = base->pos + ( serif->opos - base->opos );
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /**** ****/
- /**** E D G E H I N T I N G ****/
- /**** ****/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
-#define AF_LIGHT_MODE_MAX_HORZ_GAP 9
-#define AF_LIGHT_MODE_MAX_VERT_GAP 15
-#define AF_LIGHT_MODE_MAX_DELTA_ABS 14
-
-
- static FT_Pos
- af_hint_normal_stem( AF_GlyphHints hints,
- AF_Edge edge,
- AF_Edge edge2,
- FT_Pos anchor,
- AF_Dimension dim )
- {
- FT_Pos org_len, cur_len, org_center;
- FT_Pos cur_pos1, cur_pos2;
- FT_Pos d_off1, u_off1, d_off2, u_off2, delta;
- FT_Pos offset;
- FT_Pos threshold = 64;
-
-
- if ( !AF_LATIN_HINTS_DO_STEM_ADJUST( hints ) )
- {
- if ( ( edge->flags & AF_EDGE_ROUND ) &&
- ( edge2->flags & AF_EDGE_ROUND ) )
- {
- if ( dim == AF_DIMENSION_VERT )
- threshold = 64 - AF_LIGHT_MODE_MAX_HORZ_GAP;
- else
- threshold = 64 - AF_LIGHT_MODE_MAX_VERT_GAP;
- }
- else
- {
- if ( dim == AF_DIMENSION_VERT )
- threshold = 64 - AF_LIGHT_MODE_MAX_HORZ_GAP / 3;
- else
- threshold = 64 - AF_LIGHT_MODE_MAX_VERT_GAP / 3;
- }
- }
-
- org_len = edge2->opos - edge->opos;
- cur_len = af_cjk_compute_stem_width( hints, dim, org_len,
- edge->flags,
- edge2->flags );
-
- org_center = ( edge->opos + edge2->opos ) / 2 + anchor;
- cur_pos1 = org_center - cur_len / 2;
- cur_pos2 = cur_pos1 + cur_len;
- d_off1 = cur_pos1 - FT_PIX_FLOOR( cur_pos1 );
- d_off2 = cur_pos2 - FT_PIX_FLOOR( cur_pos2 );
- u_off1 = 64 - d_off1;
- u_off2 = 64 - d_off2;
- delta = 0;
-
-
- if ( d_off1 == 0 || d_off2 == 0 )
- goto Exit;
-
- if ( cur_len <= threshold )
- {
- if ( d_off2 < cur_len )
- {
- if ( u_off1 <= d_off2 )
- delta = u_off1;
- else
- delta = -d_off2;
- }
-
- goto Exit;
- }
-
- if ( threshold < 64 )
- {
- if ( d_off1 >= threshold || u_off1 >= threshold ||
- d_off2 >= threshold || u_off2 >= threshold )
- goto Exit;
- }
-
- offset = cur_len & 63;
-
- if ( offset < 32 )
- {
- if ( u_off1 <= offset || d_off2 <= offset )
- goto Exit;
- }
- else
- offset = 64 - threshold;
-
- d_off1 = threshold - u_off1;
- u_off1 = u_off1 - offset;
- u_off2 = threshold - d_off2;
- d_off2 = d_off2 - offset;
-
- if ( d_off1 <= u_off1 )
- u_off1 = -d_off1;
-
- if ( d_off2 <= u_off2 )
- u_off2 = -d_off2;
-
- if ( FT_ABS( u_off1 ) <= FT_ABS( u_off2 ) )
- delta = u_off1;
- else
- delta = u_off2;
-
- Exit:
-
-#if 1
- if ( !AF_LATIN_HINTS_DO_STEM_ADJUST( hints ) )
- {
- if ( delta > AF_LIGHT_MODE_MAX_DELTA_ABS )
- delta = AF_LIGHT_MODE_MAX_DELTA_ABS;
- else if ( delta < -AF_LIGHT_MODE_MAX_DELTA_ABS )
- delta = -AF_LIGHT_MODE_MAX_DELTA_ABS;
- }
-#endif
-
- cur_pos1 += delta;
-
- if ( edge->opos < edge2->opos )
- {
- edge->pos = cur_pos1;
- edge2->pos = cur_pos1 + cur_len;
- }
- else
- {
- edge->pos = cur_pos1 + cur_len;
- edge2->pos = cur_pos1;
- }
-
- return delta;
- }
-
-
- /* The main grid-fitting routine. */
-
- static void
- af_cjk_hint_edges( AF_GlyphHints hints,
- AF_Dimension dim )
- {
- AF_AxisHints axis = &hints->axis[dim];
- AF_Edge edges = axis->edges;
- AF_Edge edge_limit = FT_OFFSET( edges, axis->num_edges );
- FT_PtrDist n_edges;
- AF_Edge edge;
- AF_Edge anchor = NULL;
- FT_Pos delta = 0;
- FT_Int skipped = 0;
- FT_Bool has_last_stem = FALSE;
- FT_Pos last_stem_pos = 0;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- FT_UInt num_actions = 0;
-#endif
-
-
- FT_TRACE5(( "cjk %s edge hinting (style `%s')\n",
- dim == AF_DIMENSION_VERT ? "horizontal" : "vertical",
- af_style_names[hints->metrics->style_class->style] ));
-
- /* we begin by aligning all stems relative to the blue zone */
-
- if ( AF_HINTS_DO_BLUES( hints ) )
- {
- for ( edge = edges; edge < edge_limit; edge++ )
- {
- AF_Width blue;
- AF_Edge edge1, edge2;
-
-
- if ( edge->flags & AF_EDGE_DONE )
- continue;
-
- blue = edge->blue_edge;
- edge1 = NULL;
- edge2 = edge->link;
-
- if ( blue )
- {
- edge1 = edge;
- }
- else if ( edge2 && edge2->blue_edge )
- {
- blue = edge2->blue_edge;
- edge1 = edge2;
- edge2 = edge;
- }
-
- if ( !edge1 )
- continue;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- FT_TRACE5(( " CJKBLUE: edge %td @%d (opos=%.2f) snapped to %.2f,"
- " was %.2f\n",
- edge1 - edges, edge1->fpos, (double)edge1->opos / 64,
- (double)blue->fit / 64, (double)edge1->pos / 64 ));
-
- num_actions++;
-#endif
-
- edge1->pos = blue->fit;
- edge1->flags |= AF_EDGE_DONE;
-
- if ( edge2 && !edge2->blue_edge )
- {
- af_cjk_align_linked_edge( hints, dim, edge1, edge2 );
- edge2->flags |= AF_EDGE_DONE;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- num_actions++;
-#endif
- }
-
- if ( !anchor )
- anchor = edge;
- }
- }
-
- /* now we align all stem edges. */
- for ( edge = edges; edge < edge_limit; edge++ )
- {
- AF_Edge edge2;
-
-
- if ( edge->flags & AF_EDGE_DONE )
- continue;
-
- /* skip all non-stem edges */
- edge2 = edge->link;
- if ( !edge2 )
- {
- skipped++;
- continue;
- }
-
- /* Some CJK characters have so many stems that
- * the hinter is likely to merge two adjacent ones.
- * To solve this problem, if either edge of a stem
- * is too close to the previous one, we avoid
- * aligning the two edges, but rather interpolate
- * their locations at the end of this function in
- * order to preserve the space between the stems.
- */
- if ( has_last_stem &&
- ( edge->pos < last_stem_pos + 64 ||
- edge2->pos < last_stem_pos + 64 ) )
- {
- skipped++;
- continue;
- }
-
- /* now align the stem */
-
- /* this should not happen, but it's better to be safe */
- if ( edge2->blue_edge )
- {
- FT_TRACE5(( "ASSERTION FAILED for edge %td\n", edge2 - edges ));
-
- af_cjk_align_linked_edge( hints, dim, edge2, edge );
- edge->flags |= AF_EDGE_DONE;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- num_actions++;
-#endif
-
- continue;
- }
-
- if ( edge2 < edge )
- {
- af_cjk_align_linked_edge( hints, dim, edge2, edge );
- edge->flags |= AF_EDGE_DONE;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- num_actions++;
-#endif
-
- /* We rarely reaches here it seems;
- * usually the two edges belonging
- * to one stem are marked as DONE together
- */
- has_last_stem = TRUE;
- last_stem_pos = edge->pos;
- continue;
- }
-
- if ( dim != AF_DIMENSION_VERT && !anchor )
- {
-
-#if 0
- if ( fixedpitch )
- {
- AF_Edge left = edge;
- AF_Edge right = edge_limit - 1;
- AF_EdgeRec left1, left2, right1, right2;
- FT_Pos target, center1, center2;
- FT_Pos delta1, delta2, d1, d2;
-
-
- while ( right > left && !right->link )
- right--;
-
- left1 = *left;
- left2 = *left->link;
- right1 = *right->link;
- right2 = *right;
-
- delta = ( ( ( hinter->pp2.x + 32 ) & -64 ) - hinter->pp2.x ) / 2;
- target = left->opos + ( right->opos - left->opos ) / 2 + delta - 16;
-
- delta1 = delta;
- delta1 += af_hint_normal_stem( hints, left, left->link,
- delta1, 0 );
-
- if ( left->link != right )
- af_hint_normal_stem( hints, right->link, right, delta1, 0 );
-
- center1 = left->pos + ( right->pos - left->pos ) / 2;
-
- if ( center1 >= target )
- delta2 = delta - 32;
- else
- delta2 = delta + 32;
-
- delta2 += af_hint_normal_stem( hints, &left1, &left2, delta2, 0 );
-
- if ( delta1 != delta2 )
- {
- if ( left->link != right )
- af_hint_normal_stem( hints, &right1, &right2, delta2, 0 );
-
- center2 = left1.pos + ( right2.pos - left1.pos ) / 2;
-
- d1 = center1 - target;
- d2 = center2 - target;
-
- if ( FT_ABS( d2 ) < FT_ABS( d1 ) )
- {
- left->pos = left1.pos;
- left->link->pos = left2.pos;
-
- if ( left->link != right )
- {
- right->link->pos = right1.pos;
- right->pos = right2.pos;
- }
-
- delta1 = delta2;
- }
- }
-
- delta = delta1;
- right->link->flags |= AF_EDGE_DONE;
- right->flags |= AF_EDGE_DONE;
- }
- else
-
-#endif /* 0 */
-
- delta = af_hint_normal_stem( hints, edge, edge2, 0,
- AF_DIMENSION_HORZ );
- }
- else
- af_hint_normal_stem( hints, edge, edge2, delta, dim );
-
-#if 0
- printf( "stem (%d,%d) adjusted (%.1f,%.1f)\n",
- edge - edges, edge2 - edges,
- (double)( edge->pos - edge->opos ) / 64,
- (double)( edge2->pos - edge2->opos ) / 64 );
-#endif
-
- anchor = edge;
- edge->flags |= AF_EDGE_DONE;
- edge2->flags |= AF_EDGE_DONE;
- has_last_stem = TRUE;
- last_stem_pos = edge2->pos;
- }
-
- /* make sure that lowercase m's maintain their symmetry */
-
- /* In general, lowercase m's have six vertical edges if they are sans */
- /* serif, or twelve if they are with serifs. This implementation is */
- /* based on that assumption, and seems to work very well with most */
- /* faces. However, if for a certain face this assumption is not */
- /* true, the m is just rendered like before. In addition, any stem */
- /* correction will only be applied to symmetrical glyphs (even if the */
- /* glyph is not an m), so the potential for unwanted distortion is */
- /* relatively low. */
-
- /* We don't handle horizontal edges since we can't easily assure that */
- /* the third (lowest) stem aligns with the base line; it might end up */
- /* one pixel higher or lower. */
-
- n_edges = edge_limit - edges;
- if ( dim == AF_DIMENSION_HORZ && ( n_edges == 6 || n_edges == 12 ) )
- {
- AF_Edge edge1, edge2, edge3;
- FT_Pos dist1, dist2, span;
-
-
- if ( n_edges == 6 )
- {
- edge1 = edges;
- edge2 = edges + 2;
- edge3 = edges + 4;
- }
- else
- {
- edge1 = edges + 1;
- edge2 = edges + 5;
- edge3 = edges + 9;
- }
-
- dist1 = edge2->opos - edge1->opos;
- dist2 = edge3->opos - edge2->opos;
-
- span = dist1 - dist2;
- if ( span < 0 )
- span = -span;
-
- if ( edge1->link == edge1 + 1 &&
- edge2->link == edge2 + 1 &&
- edge3->link == edge3 + 1 && span < 8 )
- {
- delta = edge3->pos - ( 2 * edge2->pos - edge1->pos );
- edge3->pos -= delta;
- if ( edge3->link )
- edge3->link->pos -= delta;
-
- /* move the serifs along with the stem */
- if ( n_edges == 12 )
- {
- ( edges + 8 )->pos -= delta;
- ( edges + 11 )->pos -= delta;
- }
-
- edge3->flags |= AF_EDGE_DONE;
- if ( edge3->link )
- edge3->link->flags |= AF_EDGE_DONE;
- }
- }
-
- if ( !skipped )
- goto Exit;
-
- /*
- * now hint the remaining edges (serifs and single) in order
- * to complete our processing
- */
- for ( edge = edges; edge < edge_limit; edge++ )
- {
- if ( edge->flags & AF_EDGE_DONE )
- continue;
-
- if ( edge->serif )
- {
- af_cjk_align_serif_edge( hints, edge->serif, edge );
- edge->flags |= AF_EDGE_DONE;
- skipped--;
- }
- }
-
- if ( !skipped )
- goto Exit;
-
- for ( edge = edges; edge < edge_limit; edge++ )
- {
- AF_Edge before, after;
-
-
- if ( edge->flags & AF_EDGE_DONE )
- continue;
-
- before = after = edge;
-
- while ( --before >= edges )
- if ( before->flags & AF_EDGE_DONE )
- break;
-
- while ( ++after < edge_limit )
- if ( after->flags & AF_EDGE_DONE )
- break;
-
- if ( before >= edges || after < edge_limit )
- {
- if ( before < edges )
- af_cjk_align_serif_edge( hints, after, edge );
- else if ( after >= edge_limit )
- af_cjk_align_serif_edge( hints, before, edge );
- else
- {
- if ( after->fpos == before->fpos )
- edge->pos = before->pos;
- else
- edge->pos = before->pos +
- FT_MulDiv( edge->fpos - before->fpos,
- after->pos - before->pos,
- after->fpos - before->fpos );
- }
- }
- }
-
- Exit:
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( !num_actions )
- FT_TRACE5(( " (none)\n" ));
- FT_TRACE5(( "\n" ));
-#endif
-
- return;
- }
-
-
- static void
- af_cjk_align_edge_points( AF_GlyphHints hints,
- AF_Dimension dim )
- {
- AF_AxisHints axis = & hints->axis[dim];
- AF_Edge edges = axis->edges;
- AF_Edge edge_limit = FT_OFFSET( edges, axis->num_edges );
- AF_Edge edge;
- FT_Bool snapping;
-
-
- snapping = FT_BOOL( ( dim == AF_DIMENSION_HORZ &&
- AF_LATIN_HINTS_DO_HORZ_SNAP( hints ) ) ||
- ( dim == AF_DIMENSION_VERT &&
- AF_LATIN_HINTS_DO_VERT_SNAP( hints ) ) );
-
- for ( edge = edges; edge < edge_limit; edge++ )
- {
- /* move the points of each segment */
- /* in each edge to the edge's position */
- AF_Segment seg = edge->first;
-
-
- if ( snapping )
- {
- do
- {
- AF_Point point = seg->first;
-
-
- for (;;)
- {
- if ( dim == AF_DIMENSION_HORZ )
- {
- point->x = edge->pos;
- point->flags |= AF_FLAG_TOUCH_X;
- }
- else
- {
- point->y = edge->pos;
- point->flags |= AF_FLAG_TOUCH_Y;
- }
-
- if ( point == seg->last )
- break;
-
- point = point->next;
- }
-
- seg = seg->edge_next;
-
- } while ( seg != edge->first );
- }
- else
- {
- FT_Pos delta = edge->pos - edge->opos;
-
-
- do
- {
- AF_Point point = seg->first;
-
-
- for (;;)
- {
- if ( dim == AF_DIMENSION_HORZ )
- {
- point->x += delta;
- point->flags |= AF_FLAG_TOUCH_X;
- }
- else
- {
- point->y += delta;
- point->flags |= AF_FLAG_TOUCH_Y;
- }
-
- if ( point == seg->last )
- break;
-
- point = point->next;
- }
-
- seg = seg->edge_next;
-
- } while ( seg != edge->first );
- }
- }
- }
-
-
- /* Apply the complete hinting algorithm to a CJK glyph. */
-
- FT_LOCAL_DEF( FT_Error )
- af_cjk_hints_apply( FT_UInt glyph_index,
- AF_GlyphHints hints,
- FT_Outline* outline,
- AF_StyleMetrics metrics_ ) /* AF_CJKMetrics */
- {
- AF_CJKMetrics metrics = (AF_CJKMetrics)metrics_;
-
- FT_Error error;
- int dim;
-
- FT_UNUSED( metrics );
- FT_UNUSED( glyph_index );
-
-
- error = af_glyph_hints_reload( hints, outline );
- if ( error )
- goto Exit;
-
- /* analyze glyph outline */
- if ( AF_HINTS_DO_HORIZONTAL( hints ) )
- {
- error = af_cjk_hints_detect_features( hints, AF_DIMENSION_HORZ );
- if ( error )
- goto Exit;
-
- af_cjk_hints_compute_blue_edges( hints, metrics, AF_DIMENSION_HORZ );
- }
-
- if ( AF_HINTS_DO_VERTICAL( hints ) )
- {
- error = af_cjk_hints_detect_features( hints, AF_DIMENSION_VERT );
- if ( error )
- goto Exit;
-
- af_cjk_hints_compute_blue_edges( hints, metrics, AF_DIMENSION_VERT );
- }
-
- /* grid-fit the outline */
- for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ )
- {
- if ( ( dim == AF_DIMENSION_HORZ && AF_HINTS_DO_HORIZONTAL( hints ) ) ||
- ( dim == AF_DIMENSION_VERT && AF_HINTS_DO_VERTICAL( hints ) ) )
- {
- af_cjk_hint_edges( hints, (AF_Dimension)dim );
- af_cjk_align_edge_points( hints, (AF_Dimension)dim );
- af_glyph_hints_align_strong_points( hints, (AF_Dimension)dim );
- af_glyph_hints_align_weak_points( hints, (AF_Dimension)dim );
- }
- }
-
- af_glyph_hints_save( hints, outline );
-
- Exit:
- return error;
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** C J K S C R I P T C L A S S *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- AF_DEFINE_WRITING_SYSTEM_CLASS(
- af_cjk_writing_system_class,
-
- AF_WRITING_SYSTEM_CJK,
-
- sizeof ( AF_CJKMetricsRec ),
-
- (AF_WritingSystem_InitMetricsFunc) af_cjk_metrics_init, /* style_metrics_init */
- (AF_WritingSystem_ScaleMetricsFunc)af_cjk_metrics_scale, /* style_metrics_scale */
- (AF_WritingSystem_DoneMetricsFunc) NULL, /* style_metrics_done */
- (AF_WritingSystem_GetStdWidthsFunc)af_cjk_get_standard_widths, /* style_metrics_getstdw */
-
- (AF_WritingSystem_InitHintsFunc) af_cjk_hints_init, /* style_hints_init */
- (AF_WritingSystem_ApplyHintsFunc) af_cjk_hints_apply /* style_hints_apply */
- )
-
-
-#else /* !AF_CONFIG_OPTION_CJK */
-
-
- AF_DEFINE_WRITING_SYSTEM_CLASS(
- af_cjk_writing_system_class,
-
- AF_WRITING_SYSTEM_CJK,
-
- sizeof ( AF_CJKMetricsRec ),
-
- (AF_WritingSystem_InitMetricsFunc) NULL, /* style_metrics_init */
- (AF_WritingSystem_ScaleMetricsFunc)NULL, /* style_metrics_scale */
- (AF_WritingSystem_DoneMetricsFunc) NULL, /* style_metrics_done */
- (AF_WritingSystem_GetStdWidthsFunc)NULL, /* style_metrics_getstdw */
-
- (AF_WritingSystem_InitHintsFunc) NULL, /* style_hints_init */
- (AF_WritingSystem_ApplyHintsFunc) NULL /* style_hints_apply */
- )
-
-
-#endif /* !AF_CONFIG_OPTION_CJK */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/autofit/afcjk.h b/contrib/libs/freetype/src/autofit/afcjk.h
deleted file mode 100644
index bc5aaf12e6..0000000000
--- a/contrib/libs/freetype/src/autofit/afcjk.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/****************************************************************************
- *
- * afcjk.h
- *
- * Auto-fitter hinting routines for CJK writing system (specification).
- *
- * Copyright (C) 2006-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef AFCJK_H_
-#define AFCJK_H_
-
-#include "afhints.h"
-#include "aflatin.h"
-
-
-FT_BEGIN_HEADER
-
-
- /* the CJK-specific writing system */
-
- AF_DECLARE_WRITING_SYSTEM_CLASS( af_cjk_writing_system_class )
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** C J K G L O B A L M E T R I C S *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /*
- * CJK glyphs tend to fill the square. So we have both vertical and
- * horizontal blue zones. But some glyphs have flat bounding strokes that
- * leave some space between neighbour glyphs.
- */
-
-#define AF_CJK_IS_TOP_BLUE( b ) \
- ( (b)->properties & AF_BLUE_PROPERTY_CJK_TOP )
-#define AF_CJK_IS_HORIZ_BLUE( b ) \
- ( (b)->properties & AF_BLUE_PROPERTY_CJK_HORIZ )
-#define AF_CJK_IS_RIGHT_BLUE AF_CJK_IS_TOP_BLUE
-
-#define AF_CJK_MAX_WIDTHS 16
-
-
-#define AF_CJK_BLUE_ACTIVE ( 1U << 0 ) /* zone height is <= 3/4px */
-#define AF_CJK_BLUE_TOP ( 1U << 1 ) /* result of AF_CJK_IS_TOP_BLUE */
-#define AF_CJK_BLUE_ADJUSTMENT ( 1U << 2 ) /* used for scale adjustment */
- /* optimization */
-
-
- typedef struct AF_CJKBlueRec_
- {
- AF_WidthRec ref;
- AF_WidthRec shoot; /* undershoot */
- FT_UInt flags;
-
- } AF_CJKBlueRec, *AF_CJKBlue;
-
-
- typedef struct AF_CJKAxisRec_
- {
- FT_Fixed scale;
- FT_Pos delta;
-
- FT_UInt width_count; /* number of used widths */
- AF_WidthRec widths[AF_CJK_MAX_WIDTHS]; /* widths array */
- FT_Pos edge_distance_threshold; /* used for creating edges */
- FT_Pos standard_width; /* the default stem thickness */
- FT_Bool extra_light; /* is standard width very light? */
-
- /* used for horizontal metrics too for CJK */
- FT_Bool control_overshoot;
- FT_UInt blue_count;
- AF_CJKBlueRec blues[AF_BLUE_STRINGSET_MAX_LEN];
-
- FT_Fixed org_scale;
- FT_Pos org_delta;
-
- } AF_CJKAxisRec, *AF_CJKAxis;
-
-
- typedef struct AF_CJKMetricsRec_
- {
- AF_StyleMetricsRec root;
- FT_UInt units_per_em;
- AF_CJKAxisRec axis[AF_DIMENSION_MAX];
-
- } AF_CJKMetricsRec, *AF_CJKMetrics;
-
-
-#ifdef AF_CONFIG_OPTION_CJK
- FT_LOCAL( FT_Error )
- af_cjk_metrics_init( AF_StyleMetrics metrics,
- FT_Face face );
-
- FT_LOCAL( void )
- af_cjk_metrics_scale( AF_StyleMetrics metrics,
- AF_Scaler scaler );
-
- FT_LOCAL( FT_Error )
- af_cjk_hints_init( AF_GlyphHints hints,
- AF_StyleMetrics metrics );
-
- FT_LOCAL( FT_Error )
- af_cjk_hints_apply( FT_UInt glyph_index,
- AF_GlyphHints hints,
- FT_Outline* outline,
- AF_StyleMetrics metrics );
-
- /* shared; called from afindic.c */
- FT_LOCAL( void )
- af_cjk_metrics_check_digits( AF_CJKMetrics metrics,
- FT_Face face );
-
- FT_LOCAL( void )
- af_cjk_metrics_init_widths( AF_CJKMetrics metrics,
- FT_Face face );
-#endif /* AF_CONFIG_OPTION_CJK */
-
-
-/* */
-
-FT_END_HEADER
-
-#endif /* AFCJK_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/autofit/afcover.h b/contrib/libs/freetype/src/autofit/afcover.h
deleted file mode 100644
index 7980cf2e97..0000000000
--- a/contrib/libs/freetype/src/autofit/afcover.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/****************************************************************************
- *
- * afcover.h
- *
- * Auto-fitter coverages (specification only).
- *
- * Copyright (C) 2013-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /* This header file can be included multiple times. */
- /* Define `COVERAGE' as needed. */
-
-
- /* Add new coverages here. The first and second arguments are the */
- /* coverage name in lowercase and uppercase, respectively, followed */
- /* by a description string. The last four arguments are the four */
- /* characters defining the corresponding OpenType feature. */
-
-#if 0
- /* XXX: It's not possible to define blue zone characters in advance. */
- COVERAGE( alternative_fractions, ALTERNATIVE_FRACTIONS,
- "alternative fractions",
- 'a', 'f', 'r', 'c' )
-#endif
-
- COVERAGE( petite_capitals_from_capitals, PETITE_CAPITALS_FROM_CAPITALS,
- "petite capitals from capitals",
- 'c', '2', 'c', 'p' )
-
- COVERAGE( small_capitals_from_capitals, SMALL_CAPITALS_FROM_CAPITALS,
- "small capitals from capitals",
- 'c', '2', 's', 'c' )
-
-#if 0
- /* XXX: Only digits are in this coverage, however, both normal style */
- /* and oldstyle representation forms are possible. */
- COVERAGE( denominators, DENOMINATORS,
- "denominators",
- 'd', 'n', 'o', 'm' )
-#endif
-
-#if 0
- /* XXX: It's not possible to define blue zone characters in advance. */
- COVERAGE( fractions, FRACTIONS,
- "fractions",
- 'f', 'r', 'a', 'c' )
-#endif
-
-#if 0
- /* XXX: Only digits are in this coverage, however, both normal style */
- /* and oldstyle representation forms are possible. */
- COVERAGE( numerators, NUMERATORS,
- "numerators",
- 'n', 'u', 'm', 'r' )
-#endif
-
- COVERAGE( ordinals, ORDINALS,
- "ordinals",
- 'o', 'r', 'd', 'n' )
-
- COVERAGE( petite_capitals, PETITE_CAPITALS,
- "petite capitals",
- 'p', 'c', 'a', 'p' )
-
- COVERAGE( ruby, RUBY,
- "ruby",
- 'r', 'u', 'b', 'y' )
-
- COVERAGE( scientific_inferiors, SCIENTIFIC_INFERIORS,
- "scientific inferiors",
- 's', 'i', 'n', 'f' )
-
- COVERAGE( small_capitals, SMALL_CAPITALS,
- "small capitals",
- 's', 'm', 'c', 'p' )
-
- COVERAGE( subscript, SUBSCRIPT,
- "subscript",
- 's', 'u', 'b', 's' )
-
- COVERAGE( superscript, SUPERSCRIPT,
- "superscript",
- 's', 'u', 'p', 's' )
-
- COVERAGE( titling, TITLING,
- "titling",
- 't', 'i', 't', 'l' )
-
-#if 0
- /* to be always excluded */
- COVERAGE(nalt, 'n', 'a', 'l', 't'); /* Alternate Annotation Forms (?) */
- COVERAGE(ornm, 'o', 'r', 'n', 'm'); /* Ornaments (?) */
-#endif
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/autofit/afdummy.c b/contrib/libs/freetype/src/autofit/afdummy.c
deleted file mode 100644
index ad667d2edc..0000000000
--- a/contrib/libs/freetype/src/autofit/afdummy.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/****************************************************************************
- *
- * afdummy.c
- *
- * Auto-fitter dummy routines to be used if no hinting should be
- * performed (body).
- *
- * Copyright (C) 2003-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include "afdummy.h"
-#include "afhints.h"
-#include "aferrors.h"
-
-
- static FT_Error
- af_dummy_hints_init( AF_GlyphHints hints,
- AF_StyleMetrics metrics )
- {
- af_glyph_hints_rescale( hints, metrics );
-
- hints->x_scale = metrics->scaler.x_scale;
- hints->y_scale = metrics->scaler.y_scale;
- hints->x_delta = metrics->scaler.x_delta;
- hints->y_delta = metrics->scaler.y_delta;
-
- return FT_Err_Ok;
- }
-
-
- static FT_Error
- af_dummy_hints_apply( FT_UInt glyph_index,
- AF_GlyphHints hints,
- FT_Outline* outline,
- AF_StyleMetrics metrics )
- {
- FT_Error error;
-
- FT_UNUSED( glyph_index );
- FT_UNUSED( metrics );
-
-
- error = af_glyph_hints_reload( hints, outline );
- if ( !error )
- af_glyph_hints_save( hints, outline );
-
- return error;
- }
-
-
- AF_DEFINE_WRITING_SYSTEM_CLASS(
- af_dummy_writing_system_class,
-
- AF_WRITING_SYSTEM_DUMMY,
-
- sizeof ( AF_StyleMetricsRec ),
-
- (AF_WritingSystem_InitMetricsFunc) NULL, /* style_metrics_init */
- (AF_WritingSystem_ScaleMetricsFunc)NULL, /* style_metrics_scale */
- (AF_WritingSystem_DoneMetricsFunc) NULL, /* style_metrics_done */
- (AF_WritingSystem_GetStdWidthsFunc)NULL, /* style_metrics_getstdw */
-
- (AF_WritingSystem_InitHintsFunc) af_dummy_hints_init, /* style_hints_init */
- (AF_WritingSystem_ApplyHintsFunc) af_dummy_hints_apply /* style_hints_apply */
- )
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/autofit/afdummy.h b/contrib/libs/freetype/src/autofit/afdummy.h
deleted file mode 100644
index 613c2f88a3..0000000000
--- a/contrib/libs/freetype/src/autofit/afdummy.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/****************************************************************************
- *
- * afdummy.h
- *
- * Auto-fitter dummy routines to be used if no hinting should be
- * performed (specification).
- *
- * Copyright (C) 2003-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef AFDUMMY_H_
-#define AFDUMMY_H_
-
-#include "aftypes.h"
-
-
-FT_BEGIN_HEADER
-
- /* A dummy writing system used when no hinting should be performed. */
-
- AF_DECLARE_WRITING_SYSTEM_CLASS( af_dummy_writing_system_class )
-
-/* */
-
-FT_END_HEADER
-
-
-#endif /* AFDUMMY_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/autofit/aferrors.h b/contrib/libs/freetype/src/autofit/aferrors.h
deleted file mode 100644
index ae584ff06d..0000000000
--- a/contrib/libs/freetype/src/autofit/aferrors.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
- *
- * aferrors.h
- *
- * Autofitter error codes (specification only).
- *
- * Copyright (C) 2005-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /**************************************************************************
- *
- * This file is used to define the Autofitter error enumeration
- * constants.
- *
- */
-
-#ifndef AFERRORS_H_
-#define AFERRORS_H_
-
-#include <freetype/ftmoderr.h>
-
-#undef FTERRORS_H_
-
-#undef FT_ERR_PREFIX
-#define FT_ERR_PREFIX AF_Err_
-#define FT_ERR_BASE FT_Mod_Err_Autofit
-
-#include <freetype/fterrors.h>
-
-#endif /* AFERRORS_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/autofit/afglobal.c b/contrib/libs/freetype/src/autofit/afglobal.c
deleted file mode 100644
index b7403fa65e..0000000000
--- a/contrib/libs/freetype/src/autofit/afglobal.c
+++ /dev/null
@@ -1,513 +0,0 @@
-/****************************************************************************
- *
- * afglobal.c
- *
- * Auto-fitter routines to compute global hinting values (body).
- *
- * Copyright (C) 2003-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include "afglobal.h"
-#include "afranges.h"
-#include "afshaper.h"
-#include "afws-decl.h"
-#include <freetype/internal/ftdebug.h>
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT afglobal
-
-
-#include "aferrors.h"
-
-
-#undef SCRIPT
-#define SCRIPT( s, S, d, h, H, ss ) \
- AF_DEFINE_SCRIPT_CLASS( \
- af_ ## s ## _script_class, \
- AF_SCRIPT_ ## S, \
- af_ ## s ## _uniranges, \
- af_ ## s ## _nonbase_uniranges, \
- AF_ ## H, \
- ss )
-
-#include "afscript.h"
-
-
-#undef STYLE
-#define STYLE( s, S, d, ws, sc, ss, c ) \
- AF_DEFINE_STYLE_CLASS( \
- af_ ## s ## _style_class, \
- AF_STYLE_ ## S, \
- ws, \
- sc, \
- ss, \
- c )
-
-#include "afstyles.h"
-
-
-#undef WRITING_SYSTEM
-#define WRITING_SYSTEM( ws, WS ) \
- &af_ ## ws ## _writing_system_class,
-
- FT_LOCAL_ARRAY_DEF( AF_WritingSystemClass )
- af_writing_system_classes[] =
- {
-
-#include "afws-iter.h"
-
- NULL /* do not remove */
- };
-
-
-#undef SCRIPT
-#define SCRIPT( s, S, d, h, H, ss ) \
- &af_ ## s ## _script_class,
-
- FT_LOCAL_ARRAY_DEF( AF_ScriptClass )
- af_script_classes[] =
- {
-
-#include "afscript.h"
-
- NULL /* do not remove */
- };
-
-
-#undef STYLE
-#define STYLE( s, S, d, ws, sc, ss, c ) \
- &af_ ## s ## _style_class,
-
- FT_LOCAL_ARRAY_DEF( AF_StyleClass )
- af_style_classes[] =
- {
-
-#include "afstyles.h"
-
- NULL /* do not remove */
- };
-
-
-#ifdef FT_DEBUG_LEVEL_TRACE
-
-#undef STYLE
-#define STYLE( s, S, d, ws, sc, ss, c ) #s,
-
- FT_LOCAL_ARRAY_DEF( char* )
- af_style_names[] =
- {
-
-#include "afstyles.h"
-
- };
-
-#endif /* FT_DEBUG_LEVEL_TRACE */
-
-
- /* Compute the style index of each glyph within a given face. */
-
- static FT_Error
- af_face_globals_compute_style_coverage( AF_FaceGlobals globals )
- {
- FT_Error error;
- FT_Face face = globals->face;
- FT_CharMap old_charmap = face->charmap;
- FT_UShort* gstyles = globals->glyph_styles;
- FT_UShort ss;
- FT_UShort dflt = 0xFFFFU; /* a non-valid value */
- FT_UInt i;
-
-
- /* the value AF_STYLE_UNASSIGNED means `uncovered glyph' */
- for ( i = 0; i < globals->glyph_count; i++ )
- gstyles[i] = AF_STYLE_UNASSIGNED;
-
- error = FT_Select_Charmap( face, FT_ENCODING_UNICODE );
- if ( error )
- {
- /*
- * Ignore this error; we simply use the fallback style.
- * XXX: Shouldn't we rather disable hinting?
- */
- error = FT_Err_Ok;
- goto Exit;
- }
-
- /* scan each style in a Unicode charmap */
- for ( ss = 0; af_style_classes[ss]; ss++ )
- {
- AF_StyleClass style_class =
- af_style_classes[ss];
- AF_ScriptClass script_class =
- af_script_classes[style_class->script];
- AF_Script_UniRange range;
-
-
- if ( !script_class->script_uni_ranges )
- continue;
-
- /*
- * Scan all Unicode points in the range and set the corresponding
- * glyph style index.
- */
- if ( style_class->coverage == AF_COVERAGE_DEFAULT )
- {
- if ( style_class->script == globals->module->default_script )
- dflt = ss;
-
- for ( range = script_class->script_uni_ranges;
- range->first != 0;
- range++ )
- {
- FT_ULong charcode = range->first;
- FT_UInt gindex;
-
-
- gindex = FT_Get_Char_Index( face, charcode );
-
- if ( gindex != 0 &&
- gindex < globals->glyph_count &&
- ( gstyles[gindex] & AF_STYLE_MASK ) == AF_STYLE_UNASSIGNED )
- gstyles[gindex] = ss;
-
- for (;;)
- {
- charcode = FT_Get_Next_Char( face, charcode, &gindex );
-
- if ( gindex == 0 || charcode > range->last )
- break;
-
- if ( gindex < globals->glyph_count &&
- ( gstyles[gindex] & AF_STYLE_MASK ) == AF_STYLE_UNASSIGNED )
- gstyles[gindex] = ss;
- }
- }
-
- /* do the same for the script's non-base characters */
- for ( range = script_class->script_uni_nonbase_ranges;
- range->first != 0;
- range++ )
- {
- FT_ULong charcode = range->first;
- FT_UInt gindex;
-
-
- gindex = FT_Get_Char_Index( face, charcode );
-
- if ( gindex != 0 &&
- gindex < globals->glyph_count &&
- ( gstyles[gindex] & AF_STYLE_MASK ) == ss )
- gstyles[gindex] |= AF_NONBASE;
-
- for (;;)
- {
- charcode = FT_Get_Next_Char( face, charcode, &gindex );
-
- if ( gindex == 0 || charcode > range->last )
- break;
-
- if ( gindex < globals->glyph_count &&
- ( gstyles[gindex] & AF_STYLE_MASK ) == ss )
- gstyles[gindex] |= AF_NONBASE;
- }
- }
- }
- else
- {
- /* get glyphs not directly addressable by cmap */
- af_shaper_get_coverage( globals, style_class, gstyles, 0 );
- }
- }
-
- /* handle the remaining default OpenType features ... */
- for ( ss = 0; af_style_classes[ss]; ss++ )
- {
- AF_StyleClass style_class = af_style_classes[ss];
-
-
- if ( style_class->coverage == AF_COVERAGE_DEFAULT )
- af_shaper_get_coverage( globals, style_class, gstyles, 0 );
- }
-
- /* ... and finally the default OpenType features of the default script */
- af_shaper_get_coverage( globals, af_style_classes[dflt], gstyles, 1 );
-
- /* mark ASCII digits */
- for ( i = 0x30; i <= 0x39; i++ )
- {
- FT_UInt gindex = FT_Get_Char_Index( face, i );
-
-
- if ( gindex != 0 && gindex < globals->glyph_count )
- gstyles[gindex] |= AF_DIGIT;
- }
-
- Exit:
- /*
- * By default, all uncovered glyphs are set to the fallback style.
- * XXX: Shouldn't we disable hinting or do something similar?
- */
- if ( globals->module->fallback_style != AF_STYLE_UNASSIGNED )
- {
- FT_UInt nn;
-
-
- for ( nn = 0; nn < globals->glyph_count; nn++ )
- {
- if ( ( gstyles[nn] & AF_STYLE_MASK ) == AF_STYLE_UNASSIGNED )
- {
- gstyles[nn] &= ~AF_STYLE_MASK;
- gstyles[nn] |= globals->module->fallback_style;
- }
- }
- }
-
-#ifdef FT_DEBUG_LEVEL_TRACE
-
- FT_TRACE4(( "\n" ));
- FT_TRACE4(( "style coverage\n" ));
- FT_TRACE4(( "==============\n" ));
- FT_TRACE4(( "\n" ));
-
- for ( ss = 0; af_style_classes[ss]; ss++ )
- {
- AF_StyleClass style_class = af_style_classes[ss];
- FT_UInt count = 0;
- FT_UInt idx;
-
-
- FT_TRACE4(( "%s:\n", af_style_names[style_class->style] ));
-
- for ( idx = 0; idx < globals->glyph_count; idx++ )
- {
- if ( ( gstyles[idx] & AF_STYLE_MASK ) == style_class->style )
- {
- if ( !( count % 10 ) )
- FT_TRACE4(( " " ));
-
- FT_TRACE4(( " %d", idx ));
- count++;
-
- if ( !( count % 10 ) )
- FT_TRACE4(( "\n" ));
- }
- }
-
- if ( !count )
- FT_TRACE4(( " (none)\n" ));
- if ( count % 10 )
- FT_TRACE4(( "\n" ));
- }
-
-#endif /* FT_DEBUG_LEVEL_TRACE */
-
- face->charmap = old_charmap;
- return error;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- af_face_globals_new( FT_Face face,
- AF_FaceGlobals *aglobals,
- AF_Module module )
- {
- FT_Error error;
- FT_Memory memory;
- AF_FaceGlobals globals = NULL;
-
-
- memory = face->memory;
-
- /* we allocate an AF_FaceGlobals structure together */
- /* with the glyph_styles array */
- if ( FT_QALLOC( globals,
- sizeof ( *globals ) +
- (FT_ULong)face->num_glyphs * sizeof ( FT_UShort ) ) )
- goto Exit;
-
- FT_ZERO( &globals->metrics );
-
- globals->face = face;
- globals->glyph_count = (FT_UInt)face->num_glyphs;
- /* right after the globals structure come the glyph styles */
- globals->glyph_styles = (FT_UShort*)( globals + 1 );
- globals->module = module;
- globals->stem_darkening_for_ppem = 0;
- globals->darken_x = 0;
- globals->darken_y = 0;
- globals->standard_vertical_width = 0;
- globals->standard_horizontal_width = 0;
- globals->scale_down_factor = 0;
-
-#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
- globals->hb_font = hb_ft_font_create_( face, NULL );
- globals->hb_buf = hb_buffer_create();
-#endif
-
- error = af_face_globals_compute_style_coverage( globals );
- if ( error )
- {
- af_face_globals_free( globals );
- globals = NULL;
- }
- else
- globals->increase_x_height = AF_PROP_INCREASE_X_HEIGHT_MAX;
-
- Exit:
- *aglobals = globals;
- return error;
- }
-
-
- FT_LOCAL_DEF( void )
- af_face_globals_free( void* globals_ )
- {
- AF_FaceGlobals globals = (AF_FaceGlobals)globals_;
-
-
- if ( globals )
- {
- FT_Memory memory = globals->face->memory;
- FT_UInt nn;
-
-
- for ( nn = 0; nn < AF_STYLE_MAX; nn++ )
- {
- if ( globals->metrics[nn] )
- {
- AF_StyleClass style_class =
- af_style_classes[nn];
- AF_WritingSystemClass writing_system_class =
- af_writing_system_classes[style_class->writing_system];
-
-
- if ( writing_system_class->style_metrics_done )
- writing_system_class->style_metrics_done( globals->metrics[nn] );
-
- FT_FREE( globals->metrics[nn] );
- }
- }
-
-#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
- hb_font_destroy( globals->hb_font );
- hb_buffer_destroy( globals->hb_buf );
-#endif
-
- /* no need to free `globals->glyph_styles'; */
- /* it is part of the `globals' array */
- FT_FREE( globals );
- }
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- af_face_globals_get_metrics( AF_FaceGlobals globals,
- FT_UInt gindex,
- FT_UInt options,
- AF_StyleMetrics *ametrics )
- {
- AF_StyleMetrics metrics = NULL;
-
- AF_Style style = (AF_Style)options;
- AF_WritingSystemClass writing_system_class;
- AF_StyleClass style_class;
-
- FT_Error error = FT_Err_Ok;
-
-
- if ( gindex >= globals->glyph_count )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- /* if we have a forced style (via `options'), use it, */
- /* otherwise look into `glyph_styles' array */
- if ( style == AF_STYLE_NONE_DFLT || style + 1 >= AF_STYLE_MAX )
- style = (AF_Style)( globals->glyph_styles[gindex] &
- AF_STYLE_UNASSIGNED );
-
- Again:
- style_class = af_style_classes[style];
- writing_system_class = af_writing_system_classes
- [style_class->writing_system];
-
- metrics = globals->metrics[style];
- if ( !metrics )
- {
- /* create the global metrics object if necessary */
- FT_Memory memory = globals->face->memory;
-
-
- if ( FT_ALLOC( metrics, writing_system_class->style_metrics_size ) )
- goto Exit;
-
- metrics->style_class = style_class;
- metrics->globals = globals;
-
- if ( writing_system_class->style_metrics_init )
- {
- error = writing_system_class->style_metrics_init( metrics,
- globals->face );
- if ( error )
- {
- if ( writing_system_class->style_metrics_done )
- writing_system_class->style_metrics_done( metrics );
-
- FT_FREE( metrics );
-
- /* internal error code -1 indicates */
- /* that no blue zones have been found */
- if ( error == -1 )
- {
- style = (AF_Style)( globals->glyph_styles[gindex] &
- AF_STYLE_UNASSIGNED );
- /* IMPORTANT: Clear the error code, see
- * https://gitlab.freedesktop.org/freetype/freetype/-/issues/1063
- */
- error = FT_Err_Ok;
- goto Again;
- }
-
- goto Exit;
- }
- }
-
- globals->metrics[style] = metrics;
- }
-
- Exit:
- *ametrics = metrics;
-
- return error;
- }
-
-
- FT_LOCAL_DEF( FT_Bool )
- af_face_globals_is_digit( AF_FaceGlobals globals,
- FT_UInt gindex )
- {
- if ( gindex < globals->glyph_count )
- return FT_BOOL( globals->glyph_styles[gindex] & AF_DIGIT );
-
- return FT_BOOL( 0 );
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/autofit/afglobal.h b/contrib/libs/freetype/src/autofit/afglobal.h
deleted file mode 100644
index ddb54c89b2..0000000000
--- a/contrib/libs/freetype/src/autofit/afglobal.h
+++ /dev/null
@@ -1,173 +0,0 @@
-/****************************************************************************
- *
- * afglobal.h
- *
- * Auto-fitter routines to compute global hinting values
- * (specification).
- *
- * Copyright (C) 2003-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef AFGLOBAL_H_
-#define AFGLOBAL_H_
-
-
-#include "aftypes.h"
-#include "afmodule.h"
-#include "afshaper.h"
-
-
-FT_BEGIN_HEADER
-
-
- FT_LOCAL_ARRAY( AF_WritingSystemClass )
- af_writing_system_classes[];
-
-
-#undef SCRIPT
-#define SCRIPT( s, S, d, h, H, ss ) \
- AF_DECLARE_SCRIPT_CLASS( af_ ## s ## _script_class )
-
-#include "afscript.h"
-
- FT_LOCAL_ARRAY( AF_ScriptClass )
- af_script_classes[];
-
-
-#undef STYLE
-#define STYLE( s, S, d, ws, sc, ss, c ) \
- AF_DECLARE_STYLE_CLASS( af_ ## s ## _style_class )
-
-#include "afstyles.h"
-
- FT_LOCAL_ARRAY( AF_StyleClass )
- af_style_classes[];
-
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- FT_LOCAL_ARRAY( char* )
- af_style_names[];
-#endif
-
-
- /*
- * Default values and flags for both autofitter globals (found in
- * AF_ModuleRec) and face globals (in AF_FaceGlobalsRec).
- */
-
- /* index of fallback style in `af_style_classes' */
-#ifdef AF_CONFIG_OPTION_CJK
-#define AF_STYLE_FALLBACK AF_STYLE_HANI_DFLT
-#else
-#define AF_STYLE_FALLBACK AF_STYLE_NONE_DFLT
-#endif
- /* default script for OpenType; ignored if HarfBuzz isn't used */
-#define AF_SCRIPT_DEFAULT AF_SCRIPT_LATN
-
- /* a bit mask for AF_DIGIT and AF_NONBASE */
-#define AF_STYLE_MASK 0x3FFF
- /* an uncovered glyph */
-#define AF_STYLE_UNASSIGNED AF_STYLE_MASK
-
- /* if this flag is set, we have an ASCII digit */
-#define AF_DIGIT 0x8000U
- /* if this flag is set, we have a non-base character */
-#define AF_NONBASE 0x4000U
-
- /* `increase-x-height' property */
-#define AF_PROP_INCREASE_X_HEIGHT_MIN 6
-#define AF_PROP_INCREASE_X_HEIGHT_MAX 0
-
-
- /************************************************************************/
- /************************************************************************/
- /***** *****/
- /***** F A C E G L O B A L S *****/
- /***** *****/
- /************************************************************************/
- /************************************************************************/
-
-
- /*
- * Note that glyph_styles[] maps each glyph to an index into the
- * `af_style_classes' array.
- *
- */
- typedef struct AF_FaceGlobalsRec_
- {
- FT_Face face;
- FT_UInt glyph_count; /* unsigned face->num_glyphs */
- FT_UShort* glyph_styles;
-
-#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
- hb_font_t* hb_font;
- hb_buffer_t* hb_buf; /* for feature comparison */
-#endif
-
- /* per-face auto-hinter properties */
- FT_UInt increase_x_height;
-
- AF_StyleMetrics metrics[AF_STYLE_MAX];
-
- /* Compute darkening amount once per size. Use this to check whether */
- /* darken_{x,y} needs to be recomputed. */
- FT_UShort stem_darkening_for_ppem;
- /* Copy from e.g. AF_LatinMetrics.axis[AF_DIMENSION_HORZ] */
- /* to compute the darkening amount. */
- FT_Pos standard_vertical_width;
- /* Copy from e.g. AF_LatinMetrics.axis[AF_DIMENSION_VERT] */
- /* to compute the darkening amount. */
- FT_Pos standard_horizontal_width;
- /* The actual amount to darken a glyph along the X axis. */
- FT_Pos darken_x;
- /* The actual amount to darken a glyph along the Y axis. */
- FT_Pos darken_y;
- /* Amount to scale down by to keep emboldened points */
- /* on the Y-axis in pre-computed blue zones. */
- FT_Fixed scale_down_factor;
- AF_Module module; /* to access global properties */
-
- } AF_FaceGlobalsRec;
-
-
- /*
- * model the global hints data for a given face, decomposed into
- * style-specific items
- */
-
- FT_LOCAL( FT_Error )
- af_face_globals_new( FT_Face face,
- AF_FaceGlobals *aglobals,
- AF_Module module );
-
- FT_LOCAL( FT_Error )
- af_face_globals_get_metrics( AF_FaceGlobals globals,
- FT_UInt gindex,
- FT_UInt options,
- AF_StyleMetrics *ametrics );
-
- FT_LOCAL( void )
- af_face_globals_free( void* globals );
-
- FT_LOCAL( FT_Bool )
- af_face_globals_is_digit( AF_FaceGlobals globals,
- FT_UInt gindex );
-
- /* */
-
-
-FT_END_HEADER
-
-#endif /* AFGLOBAL_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/autofit/afhints.c b/contrib/libs/freetype/src/autofit/afhints.c
deleted file mode 100644
index 96ffe343aa..0000000000
--- a/contrib/libs/freetype/src/autofit/afhints.c
+++ /dev/null
@@ -1,1796 +0,0 @@
-/****************************************************************************
- *
- * afhints.c
- *
- * Auto-fitter hinting routines (body).
- *
- * Copyright (C) 2003-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include "afhints.h"
-#include "aferrors.h"
-#include <freetype/internal/ftcalc.h>
-#include <freetype/internal/ftdebug.h>
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT afhints
-
-
- FT_LOCAL_DEF( void )
- af_sort_pos( FT_UInt count,
- FT_Pos* table )
- {
- FT_UInt i, j;
- FT_Pos swap;
-
-
- for ( i = 1; i < count; i++ )
- {
- for ( j = i; j > 0; j-- )
- {
- if ( table[j] >= table[j - 1] )
- break;
-
- swap = table[j];
- table[j] = table[j - 1];
- table[j - 1] = swap;
- }
- }
- }
-
-
- FT_LOCAL_DEF( void )
- af_sort_and_quantize_widths( FT_UInt* count,
- AF_Width table,
- FT_Pos threshold )
- {
- FT_UInt i, j;
- FT_UInt cur_idx;
- FT_Pos cur_val;
- FT_Pos sum;
- AF_WidthRec swap;
-
-
- if ( *count == 1 )
- return;
-
- /* sort */
- for ( i = 1; i < *count; i++ )
- {
- for ( j = i; j > 0; j-- )
- {
- if ( table[j].org >= table[j - 1].org )
- break;
-
- swap = table[j];
- table[j] = table[j - 1];
- table[j - 1] = swap;
- }
- }
-
- cur_idx = 0;
- cur_val = table[cur_idx].org;
-
- /* compute and use mean values for clusters not larger than */
- /* `threshold'; this is very primitive and might not yield */
- /* the best result, but normally, using reference character */
- /* `o', `*count' is 2, so the code below is fully sufficient */
- for ( i = 1; i < *count; i++ )
- {
- if ( table[i].org - cur_val > threshold ||
- i == *count - 1 )
- {
- sum = 0;
-
- /* fix loop for end of array */
- if ( table[i].org - cur_val <= threshold &&
- i == *count - 1 )
- i++;
-
- for ( j = cur_idx; j < i; j++ )
- {
- sum += table[j].org;
- table[j].org = 0;
- }
- table[cur_idx].org = sum / (FT_Pos)j;
-
- if ( i < *count - 1 )
- {
- cur_idx = i + 1;
- cur_val = table[cur_idx].org;
- }
- }
- }
-
- cur_idx = 1;
-
- /* compress array to remove zero values */
- for ( i = 1; i < *count; i++ )
- {
- if ( table[i].org )
- table[cur_idx++] = table[i];
- }
-
- *count = cur_idx;
- }
-
- /* Get new segment for given axis. */
-
- FT_LOCAL_DEF( FT_Error )
- af_axis_hints_new_segment( AF_AxisHints axis,
- FT_Memory memory,
- AF_Segment *asegment )
- {
- FT_Error error = FT_Err_Ok;
- AF_Segment segment = NULL;
-
-
- if ( axis->num_segments < AF_SEGMENTS_EMBEDDED )
- {
- if ( !axis->segments )
- {
- axis->segments = axis->embedded.segments;
- axis->max_segments = AF_SEGMENTS_EMBEDDED;
- }
- }
- else if ( axis->num_segments >= axis->max_segments )
- {
- FT_UInt old_max = axis->max_segments;
- FT_UInt new_max = old_max;
- FT_UInt big_max = FT_INT_MAX / sizeof ( *segment );
-
-
- if ( old_max >= big_max )
- {
- error = FT_THROW( Out_Of_Memory );
- goto Exit;
- }
-
- new_max += ( new_max >> 2 ) + 4;
- if ( new_max < old_max || new_max > big_max )
- new_max = big_max;
-
- if ( axis->segments == axis->embedded.segments )
- {
- if ( FT_NEW_ARRAY( axis->segments, new_max ) )
- goto Exit;
- ft_memcpy( axis->segments, axis->embedded.segments,
- sizeof ( axis->embedded.segments ) );
- }
- else
- {
- if ( FT_RENEW_ARRAY( axis->segments, old_max, new_max ) )
- goto Exit;
- }
-
- axis->max_segments = new_max;
- }
-
- segment = axis->segments + axis->num_segments++;
-
- Exit:
- *asegment = segment;
- return error;
- }
-
-
- /* Get new edge for given axis, direction, and position, */
- /* without initializing the edge itself. */
-
- FT_LOCAL_DEF( FT_Error )
- af_axis_hints_new_edge( AF_AxisHints axis,
- FT_Int fpos,
- AF_Direction dir,
- FT_Bool top_to_bottom_hinting,
- FT_Memory memory,
- AF_Edge *anedge )
- {
- FT_Error error = FT_Err_Ok;
- AF_Edge edge = NULL;
- AF_Edge edges;
-
-
- if ( axis->num_edges < AF_EDGES_EMBEDDED )
- {
- if ( !axis->edges )
- {
- axis->edges = axis->embedded.edges;
- axis->max_edges = AF_EDGES_EMBEDDED;
- }
- }
- else if ( axis->num_edges >= axis->max_edges )
- {
- FT_UInt old_max = axis->max_edges;
- FT_UInt new_max = old_max;
- FT_UInt big_max = FT_INT_MAX / sizeof ( *edge );
-
-
- if ( old_max >= big_max )
- {
- error = FT_THROW( Out_Of_Memory );
- goto Exit;
- }
-
- new_max += ( new_max >> 2 ) + 4;
- if ( new_max < old_max || new_max > big_max )
- new_max = big_max;
-
- if ( axis->edges == axis->embedded.edges )
- {
- if ( FT_NEW_ARRAY( axis->edges, new_max ) )
- goto Exit;
- ft_memcpy( axis->edges, axis->embedded.edges,
- sizeof ( axis->embedded.edges ) );
- }
- else
- {
- if ( FT_RENEW_ARRAY( axis->edges, old_max, new_max ) )
- goto Exit;
- }
-
- axis->max_edges = new_max;
- }
-
- edges = axis->edges;
- edge = edges + axis->num_edges;
-
- while ( edge > edges )
- {
- if ( top_to_bottom_hinting ? ( edge[-1].fpos > fpos )
- : ( edge[-1].fpos < fpos ) )
- break;
-
- /* we want the edge with same position and minor direction */
- /* to appear before those in the major one in the list */
- if ( edge[-1].fpos == fpos && dir == axis->major_dir )
- break;
-
- edge[0] = edge[-1];
- edge--;
- }
-
- axis->num_edges++;
-
- Exit:
- *anedge = edge;
- return error;
- }
-
-
-#ifdef FT_DEBUG_AUTOFIT
-
-#include FT_CONFIG_STANDARD_LIBRARY_H
-
- /* The dump functions are used in the `ftgrid' demo program, too. */
-#define AF_DUMP( varformat ) \
- do \
- { \
- if ( to_stdout ) \
- printf varformat; \
- else \
- FT_TRACE7( varformat ); \
- } while ( 0 )
-
-
- static const char*
- af_dir_str( AF_Direction dir )
- {
- const char* result;
-
-
- switch ( dir )
- {
- case AF_DIR_UP:
- result = "up";
- break;
- case AF_DIR_DOWN:
- result = "down";
- break;
- case AF_DIR_LEFT:
- result = "left";
- break;
- case AF_DIR_RIGHT:
- result = "right";
- break;
- default:
- result = "none";
- }
-
- return result;
- }
-
-
-#define AF_INDEX_NUM( ptr, base ) (int)( (ptr) ? ( (ptr) - (base) ) : -1 )
-
-
- static char*
- af_print_idx( char* p,
- size_t n,
- int idx )
- {
- if ( idx == -1 )
- {
- p[0] = '-';
- p[1] = '-';
- p[2] = '\0';
- }
- else
- ft_snprintf( p, n, "%d", idx );
-
- return p;
- }
-
-
- static int
- af_get_segment_index( AF_GlyphHints hints,
- int point_idx,
- int dimension )
- {
- AF_AxisHints axis = &hints->axis[dimension];
- AF_Point point = hints->points + point_idx;
- AF_Segment segments = axis->segments;
- AF_Segment limit = segments + axis->num_segments;
- AF_Segment segment;
-
-
- for ( segment = segments; segment < limit; segment++ )
- {
- if ( segment->first <= segment->last )
- {
- if ( point >= segment->first && point <= segment->last )
- break;
- }
- else
- {
- AF_Point p = segment->first;
-
-
- for (;;)
- {
- if ( point == p )
- goto Exit;
-
- if ( p == segment->last )
- break;
-
- p = p->next;
- }
- }
- }
-
- Exit:
- if ( segment == limit )
- return -1;
-
- return (int)( segment - segments );
- }
-
-
- static int
- af_get_edge_index( AF_GlyphHints hints,
- int segment_idx,
- int dimension )
- {
- AF_AxisHints axis = &hints->axis[dimension];
- AF_Edge edges = axis->edges;
- AF_Segment segment = axis->segments + segment_idx;
-
-
- return segment_idx == -1 ? -1 : AF_INDEX_NUM( segment->edge, edges );
- }
-
-
- static int
- af_get_strong_edge_index( AF_GlyphHints hints,
- AF_Edge* strong_edges,
- int dimension )
- {
- AF_AxisHints axis = &hints->axis[dimension];
- AF_Edge edges = axis->edges;
-
-
- return AF_INDEX_NUM( strong_edges[dimension], edges );
- }
-
-
-#ifdef __cplusplus
- extern "C" {
-#endif
- void
- af_glyph_hints_dump_points( AF_GlyphHints hints,
- FT_Bool to_stdout )
- {
- AF_Point points = hints->points;
- AF_Point limit = points + hints->num_points;
- AF_Point* contour = hints->contours;
- AF_Point* climit = contour + hints->num_contours;
- AF_Point point;
-
-
- AF_DUMP(( "Table of points:\n" ));
-
- if ( hints->num_points )
- {
- AF_DUMP(( " index hedge hseg vedge vseg flags "
- /* " XXXXX XXXXX XXXXX XXXXX XXXXX XXXXXX" */
- " xorg yorg xscale yscale xfit yfit "
- /* " XXXXX XXXXX XXXX.XX XXXX.XX XXXX.XX XXXX.XX" */
- " hbef haft vbef vaft" ));
- /* " XXXXX XXXXX XXXXX XXXXX" */
- }
- else
- AF_DUMP(( " (none)\n" ));
-
- for ( point = points; point < limit; point++ )
- {
- int point_idx = AF_INDEX_NUM( point, points );
- int segment_idx_0 = af_get_segment_index( hints, point_idx, 0 );
- int segment_idx_1 = af_get_segment_index( hints, point_idx, 1 );
-
- char buf1[16], buf2[16], buf3[16], buf4[16];
- char buf5[16], buf6[16], buf7[16], buf8[16];
-
-
- /* insert extra newline at the beginning of a contour */
- if ( contour < climit && *contour == point )
- {
- AF_DUMP(( "\n" ));
- contour++;
- }
-
- AF_DUMP(( " %5d %5s %5s %5s %5s %s"
- " %5d %5d %7.2f %7.2f %7.2f %7.2f"
- " %5s %5s %5s %5s\n",
- point_idx,
- af_print_idx( buf1, 16,
- af_get_edge_index( hints, segment_idx_1, 1 ) ),
- af_print_idx( buf2, 16, segment_idx_1 ),
- af_print_idx( buf3, 16,
- af_get_edge_index( hints, segment_idx_0, 0 ) ),
- af_print_idx( buf4, 16, segment_idx_0 ),
- ( point->flags & AF_FLAG_NEAR )
- ? " near "
- : ( point->flags & AF_FLAG_WEAK_INTERPOLATION )
- ? " weak "
- : "strong",
-
- point->fx,
- point->fy,
- (double)point->ox / 64,
- (double)point->oy / 64,
- (double)point->x / 64,
- (double)point->y / 64,
-
- af_print_idx( buf5, 16,
- af_get_strong_edge_index( hints,
- point->before,
- 1 ) ),
- af_print_idx( buf6, 16,
- af_get_strong_edge_index( hints,
- point->after,
- 1 ) ),
- af_print_idx( buf7, 16,
- af_get_strong_edge_index( hints,
- point->before,
- 0 ) ),
- af_print_idx( buf8, 16,
- af_get_strong_edge_index( hints,
- point->after,
- 0 ) ) ));
- }
- AF_DUMP(( "\n" ));
- }
-#ifdef __cplusplus
- }
-#endif
-
-
- static const char*
- af_edge_flags_to_string( FT_UInt flags )
- {
- static char temp[32];
- int pos = 0;
-
-
- if ( flags & AF_EDGE_ROUND )
- {
- ft_memcpy( temp + pos, "round", 5 );
- pos += 5;
- }
- if ( flags & AF_EDGE_SERIF )
- {
- if ( pos > 0 )
- temp[pos++] = ' ';
- ft_memcpy( temp + pos, "serif", 5 );
- pos += 5;
- }
- if ( pos == 0 )
- return "normal";
-
- temp[pos] = '\0';
-
- return temp;
- }
-
-
- /* Dump the array of linked segments. */
-
-#ifdef __cplusplus
- extern "C" {
-#endif
- void
- af_glyph_hints_dump_segments( AF_GlyphHints hints,
- FT_Bool to_stdout )
- {
- FT_Int dimension;
-
-
- for ( dimension = 1; dimension >= 0; dimension-- )
- {
- AF_AxisHints axis = &hints->axis[dimension];
- AF_Point points = hints->points;
- AF_Edge edges = axis->edges;
- AF_Segment segments = axis->segments;
- AF_Segment limit = segments + axis->num_segments;
- AF_Segment seg;
-
- char buf1[16], buf2[16], buf3[16];
-
-
- AF_DUMP(( "Table of %s segments:\n",
- dimension == AF_DIMENSION_HORZ ? "vertical"
- : "horizontal" ));
- if ( axis->num_segments )
- {
- AF_DUMP(( " index pos delta dir from to "
- /* " XXXXX XXXXX XXXXX XXXXX XXXX XXXX" */
- " link serif edge"
- /* " XXXX XXXXX XXXX" */
- " height extra flags\n" ));
- /* " XXXXXX XXXXX XXXXXXXXXXX" */
- }
- else
- AF_DUMP(( " (none)\n" ));
-
- for ( seg = segments; seg < limit; seg++ )
- AF_DUMP(( " %5d %5d %5d %5s %4d %4d"
- " %4s %5s %4s"
- " %6d %5d %11s\n",
- AF_INDEX_NUM( seg, segments ),
- seg->pos,
- seg->delta,
- af_dir_str( (AF_Direction)seg->dir ),
- AF_INDEX_NUM( seg->first, points ),
- AF_INDEX_NUM( seg->last, points ),
-
- af_print_idx( buf1, 16,
- AF_INDEX_NUM( seg->link, segments ) ),
- af_print_idx( buf2, 16,
- AF_INDEX_NUM( seg->serif, segments ) ),
- af_print_idx( buf3, 16,
- AF_INDEX_NUM( seg->edge, edges ) ),
-
- seg->height,
- seg->height - ( seg->max_coord - seg->min_coord ),
- af_edge_flags_to_string( seg->flags ) ));
- AF_DUMP(( "\n" ));
- }
- }
-#ifdef __cplusplus
- }
-#endif
-
-
- /* Fetch number of segments. */
-
-#ifdef __cplusplus
- extern "C" {
-#endif
- FT_Error
- af_glyph_hints_get_num_segments( AF_GlyphHints hints,
- FT_Int dimension,
- FT_UInt* num_segments )
- {
- AF_Dimension dim;
- AF_AxisHints axis;
-
-
- dim = ( dimension == 0 ) ? AF_DIMENSION_HORZ : AF_DIMENSION_VERT;
-
- axis = &hints->axis[dim];
- *num_segments = axis->num_segments;
-
- return FT_Err_Ok;
- }
-#ifdef __cplusplus
- }
-#endif
-
-
- /* Fetch offset of segments into user supplied offset array. */
-
-#ifdef __cplusplus
- extern "C" {
-#endif
- FT_Error
- af_glyph_hints_get_segment_offset( AF_GlyphHints hints,
- FT_Int dimension,
- FT_UInt idx,
- FT_Pos *offset,
- FT_Bool *is_blue,
- FT_Pos *blue_offset )
- {
- AF_Dimension dim;
- AF_AxisHints axis;
- AF_Segment seg;
-
-
- if ( !offset )
- return FT_THROW( Invalid_Argument );
-
- dim = ( dimension == 0 ) ? AF_DIMENSION_HORZ : AF_DIMENSION_VERT;
-
- axis = &hints->axis[dim];
-
- if ( idx >= axis->num_segments )
- return FT_THROW( Invalid_Argument );
-
- seg = &axis->segments[idx];
- *offset = ( dim == AF_DIMENSION_HORZ ) ? seg->first->fx
- : seg->first->fy;
- if ( seg->edge )
- *is_blue = FT_BOOL( seg->edge->blue_edge );
- else
- *is_blue = FALSE;
-
- if ( *is_blue )
- *blue_offset = seg->edge->blue_edge->org;
- else
- *blue_offset = 0;
-
- return FT_Err_Ok;
- }
-#ifdef __cplusplus
- }
-#endif
-
-
- /* Dump the array of linked edges. */
-
-#ifdef __cplusplus
- extern "C" {
-#endif
- void
- af_glyph_hints_dump_edges( AF_GlyphHints hints,
- FT_Bool to_stdout )
- {
- FT_Int dimension;
-
-
- for ( dimension = 1; dimension >= 0; dimension-- )
- {
- AF_AxisHints axis = &hints->axis[dimension];
- AF_Edge edges = axis->edges;
- AF_Edge limit = edges + axis->num_edges;
- AF_Edge edge;
-
- char buf1[16], buf2[16];
-
-
- /*
- * note: AF_DIMENSION_HORZ corresponds to _vertical_ edges
- * since they have a constant X coordinate.
- */
- if ( dimension == AF_DIMENSION_HORZ )
- AF_DUMP(( "Table of %s edges (1px=%.2fu, 10u=%.2fpx):\n",
- "vertical",
- 65536 * 64 / (double)hints->x_scale,
- 10 * (double)hints->x_scale / 65536 / 64 ));
- else
- AF_DUMP(( "Table of %s edges (1px=%.2fu, 10u=%.2fpx):\n",
- "horizontal",
- 65536 * 64 / (double)hints->y_scale,
- 10 * (double)hints->y_scale / 65536 / 64 ));
-
- if ( axis->num_edges )
- {
- AF_DUMP(( " index pos dir link serif"
- /* " XXXXX XXXX.XX XXXXX XXXX XXXXX" */
- " blue opos pos flags\n" ));
- /* " X XXXX.XX XXXX.XX XXXXXXXXXXX" */
- }
- else
- AF_DUMP(( " (none)\n" ));
-
- for ( edge = edges; edge < limit; edge++ )
- AF_DUMP(( " %5d %7.2f %5s %4s %5s"
- " %c %7.2f %7.2f %11s\n",
- AF_INDEX_NUM( edge, edges ),
- (double)(int)edge->opos / 64,
- af_dir_str( (AF_Direction)edge->dir ),
- af_print_idx( buf1, 16,
- AF_INDEX_NUM( edge->link, edges ) ),
- af_print_idx( buf2, 16,
- AF_INDEX_NUM( edge->serif, edges ) ),
-
- edge->blue_edge ? 'y' : 'n',
- (double)edge->opos / 64,
- (double)edge->pos / 64,
- af_edge_flags_to_string( edge->flags ) ));
- AF_DUMP(( "\n" ));
- }
- }
-#ifdef __cplusplus
- }
-#endif
-
-#undef AF_DUMP
-
-#endif /* !FT_DEBUG_AUTOFIT */
-
-
- /* Compute the direction value of a given vector. */
-
- FT_LOCAL_DEF( AF_Direction )
- af_direction_compute( FT_Pos dx,
- FT_Pos dy )
- {
- FT_Pos ll, ss; /* long and short arm lengths */
- AF_Direction dir; /* candidate direction */
-
-
- if ( dy >= dx )
- {
- if ( dy >= -dx )
- {
- dir = AF_DIR_UP;
- ll = dy;
- ss = dx;
- }
- else
- {
- dir = AF_DIR_LEFT;
- ll = -dx;
- ss = dy;
- }
- }
- else /* dy < dx */
- {
- if ( dy >= -dx )
- {
- dir = AF_DIR_RIGHT;
- ll = dx;
- ss = dy;
- }
- else
- {
- dir = AF_DIR_DOWN;
- ll = -dy;
- ss = dx;
- }
- }
-
- /* return no direction if arm lengths do not differ enough */
- /* (value 14 is heuristic, corresponding to approx. 4.1 degrees) */
- /* the long arm is never negative */
- if ( ll <= 14 * FT_ABS( ss ) )
- dir = AF_DIR_NONE;
-
- return dir;
- }
-
-
- FT_LOCAL_DEF( void )
- af_glyph_hints_init( AF_GlyphHints hints,
- FT_Memory memory )
- {
- /* no need to initialize the embedded items */
- FT_MEM_ZERO( hints, sizeof ( *hints ) - sizeof ( hints->embedded ) );
- hints->memory = memory;
- }
-
-
- FT_LOCAL_DEF( void )
- af_glyph_hints_done( AF_GlyphHints hints )
- {
- FT_Memory memory;
- int dim;
-
-
- if ( !( hints && hints->memory ) )
- return;
-
- memory = hints->memory;
-
- /*
- * note that we don't need to free the segment and edge
- * buffers since they are really within the hints->points array
- */
- for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ )
- {
- AF_AxisHints axis = &hints->axis[dim];
-
-
- axis->num_segments = 0;
- axis->max_segments = 0;
- if ( axis->segments != axis->embedded.segments )
- FT_FREE( axis->segments );
-
- axis->num_edges = 0;
- axis->max_edges = 0;
- if ( axis->edges != axis->embedded.edges )
- FT_FREE( axis->edges );
- }
-
- if ( hints->contours != hints->embedded.contours )
- FT_FREE( hints->contours );
- hints->max_contours = 0;
- hints->num_contours = 0;
-
- if ( hints->points != hints->embedded.points )
- FT_FREE( hints->points );
- hints->max_points = 0;
- hints->num_points = 0;
-
- hints->memory = NULL;
- }
-
-
- /* Reset metrics. */
-
- FT_LOCAL_DEF( void )
- af_glyph_hints_rescale( AF_GlyphHints hints,
- AF_StyleMetrics metrics )
- {
- hints->metrics = metrics;
- hints->scaler_flags = metrics->scaler.flags;
- }
-
-
- /* Recompute all AF_Point in AF_GlyphHints from the definitions */
- /* in a source outline. */
-
- FT_LOCAL_DEF( FT_Error )
- af_glyph_hints_reload( AF_GlyphHints hints,
- FT_Outline* outline )
- {
- FT_Error error = FT_Err_Ok;
- AF_Point points;
- FT_Int old_max, new_max;
- FT_Fixed x_scale = hints->x_scale;
- FT_Fixed y_scale = hints->y_scale;
- FT_Pos x_delta = hints->x_delta;
- FT_Pos y_delta = hints->y_delta;
- FT_Memory memory = hints->memory;
-
-
- hints->num_points = 0;
- hints->num_contours = 0;
-
- hints->axis[0].num_segments = 0;
- hints->axis[0].num_edges = 0;
- hints->axis[1].num_segments = 0;
- hints->axis[1].num_edges = 0;
-
- /* first of all, reallocate the contours array if necessary */
- new_max = outline->n_contours;
- old_max = hints->max_contours;
-
- if ( new_max <= AF_CONTOURS_EMBEDDED )
- {
- if ( !hints->contours )
- {
- hints->contours = hints->embedded.contours;
- hints->max_contours = AF_CONTOURS_EMBEDDED;
- }
- }
- else if ( new_max > old_max )
- {
- if ( hints->contours == hints->embedded.contours )
- hints->contours = NULL;
-
- new_max = ( new_max + 3 ) & ~3; /* round up to a multiple of 4 */
-
- if ( FT_RENEW_ARRAY( hints->contours, old_max, new_max ) )
- goto Exit;
-
- hints->max_contours = new_max;
- }
-
- /*
- * then reallocate the points arrays if necessary --
- * note that we reserve two additional point positions, used to
- * hint metrics appropriately
- */
- new_max = outline->n_points + 2;
- old_max = hints->max_points;
-
- if ( new_max <= AF_POINTS_EMBEDDED )
- {
- if ( !hints->points )
- {
- hints->points = hints->embedded.points;
- hints->max_points = AF_POINTS_EMBEDDED;
- }
- }
- else if ( new_max > old_max )
- {
- if ( hints->points == hints->embedded.points )
- hints->points = NULL;
-
- new_max = ( new_max + 2 + 7 ) & ~7; /* round up to a multiple of 8 */
-
- if ( FT_RENEW_ARRAY( hints->points, old_max, new_max ) )
- goto Exit;
-
- hints->max_points = new_max;
- }
-
- hints->num_points = outline->n_points;
- hints->num_contours = outline->n_contours;
-
- /* We can't rely on the value of `FT_Outline.flags' to know the fill */
- /* direction used for a glyph, given that some fonts are broken (e.g., */
- /* the Arphic ones). We thus recompute it each time we need to. */
- /* */
- hints->axis[AF_DIMENSION_HORZ].major_dir = AF_DIR_UP;
- hints->axis[AF_DIMENSION_VERT].major_dir = AF_DIR_LEFT;
-
- if ( FT_Outline_Get_Orientation( outline ) == FT_ORIENTATION_POSTSCRIPT )
- {
- hints->axis[AF_DIMENSION_HORZ].major_dir = AF_DIR_DOWN;
- hints->axis[AF_DIMENSION_VERT].major_dir = AF_DIR_RIGHT;
- }
-
- hints->x_scale = x_scale;
- hints->y_scale = y_scale;
- hints->x_delta = x_delta;
- hints->y_delta = y_delta;
-
- points = hints->points;
- if ( hints->num_points == 0 )
- goto Exit;
-
- {
- AF_Point point;
- AF_Point point_limit = points + hints->num_points;
-
- /* value 20 in `near_limit' is heuristic */
- FT_UInt units_per_em = hints->metrics->scaler.face->units_per_EM;
- FT_Int near_limit = 20 * units_per_em / 2048;
-
-
- /* compute coordinates & Bezier flags, next and prev */
- {
- FT_Vector* vec = outline->points;
- FT_Byte* tag = outline->tags;
- FT_UShort endpoint = outline->contours[0];
- AF_Point end = points + endpoint;
- AF_Point prev = end;
- FT_Int contour_index = 0;
-
-
- for ( point = points; point < point_limit; point++, vec++, tag++ )
- {
- FT_Pos out_x, out_y;
-
-
- point->in_dir = (FT_Char)AF_DIR_NONE;
- point->out_dir = (FT_Char)AF_DIR_NONE;
-
- point->fx = (FT_Short)vec->x;
- point->fy = (FT_Short)vec->y;
- point->ox = point->x = FT_MulFix( vec->x, x_scale ) + x_delta;
- point->oy = point->y = FT_MulFix( vec->y, y_scale ) + y_delta;
-
- end->fx = (FT_Short)outline->points[endpoint].x;
- end->fy = (FT_Short)outline->points[endpoint].y;
-
- switch ( FT_CURVE_TAG( *tag ) )
- {
- case FT_CURVE_TAG_CONIC:
- point->flags = AF_FLAG_CONIC;
- break;
- case FT_CURVE_TAG_CUBIC:
- point->flags = AF_FLAG_CUBIC;
- break;
- default:
- point->flags = AF_FLAG_NONE;
- }
-
- out_x = point->fx - prev->fx;
- out_y = point->fy - prev->fy;
-
- if ( FT_ABS( out_x ) + FT_ABS( out_y ) < near_limit )
- prev->flags |= AF_FLAG_NEAR;
-
- point->prev = prev;
- prev->next = point;
- prev = point;
-
- if ( point == end )
- {
- if ( ++contour_index < outline->n_contours )
- {
- endpoint = outline->contours[contour_index];
- end = points + endpoint;
- prev = end;
- }
- }
-
-#ifdef FT_DEBUG_AUTOFIT
- point->before[0] = NULL;
- point->before[1] = NULL;
- point->after[0] = NULL;
- point->after[1] = NULL;
-#endif
-
- }
- }
-
- /* set up the contours array */
- {
- AF_Point* contour = hints->contours;
- AF_Point* contour_limit = contour + hints->num_contours;
- FT_UShort* end = outline->contours;
- FT_Int idx = 0;
-
-
- for ( ; contour < contour_limit; contour++, end++ )
- {
- contour[0] = points + idx;
- idx = *end + 1;
- }
- }
-
- {
- /*
- * Compute directions of `in' and `out' vectors.
- *
- * Note that distances between points that are very near to each
- * other are accumulated. In other words, the auto-hinter either
- * prepends the small vectors between near points to the first
- * non-near vector, or the sum of small vector lengths exceeds a
- * threshold, thus `grouping' the small vectors. All intermediate
- * points are tagged as weak; the directions are adjusted also to
- * be equal to the accumulated one.
- */
-
- FT_Int near_limit2 = 2 * near_limit - 1;
-
- AF_Point* contour;
- AF_Point* contour_limit = hints->contours + hints->num_contours;
-
-
- for ( contour = hints->contours; contour < contour_limit; contour++ )
- {
- AF_Point first = *contour;
- AF_Point next, prev, curr;
-
- FT_Pos out_x, out_y;
-
-
- /* since the first point of a contour could be part of a */
- /* series of near points, go backwards to find the first */
- /* non-near point and adjust `first' */
-
- point = first;
- prev = first->prev;
-
- while ( prev != first )
- {
- out_x = point->fx - prev->fx;
- out_y = point->fy - prev->fy;
-
- /*
- * We use Taxicab metrics to measure the vector length.
- *
- * Note that the accumulated distances so far could have the
- * opposite direction of the distance measured here. For this
- * reason we use `near_limit2' for the comparison to get a
- * non-near point even in the worst case.
- */
- if ( FT_ABS( out_x ) + FT_ABS( out_y ) >= near_limit2 )
- break;
-
- point = prev;
- prev = prev->prev;
- }
-
- /* adjust first point */
- first = point;
-
- /* now loop over all points of the contour to get */
- /* `in' and `out' vector directions */
-
- curr = first;
-
- /*
- * We abuse the `u' and `v' fields to store index deltas to the
- * next and previous non-near point, respectively.
- *
- * To avoid problems with not having non-near points, we point to
- * `first' by default as the next non-near point.
- *
- */
- curr->u = (FT_Pos)( first - curr );
- first->v = -curr->u;
-
- out_x = 0;
- out_y = 0;
-
- next = first;
- do
- {
- AF_Direction out_dir;
-
-
- point = next;
- next = point->next;
-
- out_x += next->fx - point->fx;
- out_y += next->fy - point->fy;
-
- if ( FT_ABS( out_x ) + FT_ABS( out_y ) < near_limit )
- {
- next->flags |= AF_FLAG_WEAK_INTERPOLATION;
- continue;
- }
-
- curr->u = (FT_Pos)( next - curr );
- next->v = -curr->u;
-
- out_dir = af_direction_compute( out_x, out_y );
-
- /* adjust directions for all points inbetween; */
- /* the loop also updates position of `curr' */
- curr->out_dir = (FT_Char)out_dir;
- for ( curr = curr->next; curr != next; curr = curr->next )
- {
- curr->in_dir = (FT_Char)out_dir;
- curr->out_dir = (FT_Char)out_dir;
- }
- next->in_dir = (FT_Char)out_dir;
-
- curr->u = (FT_Pos)( first - curr );
- first->v = -curr->u;
-
- out_x = 0;
- out_y = 0;
-
- } while ( next != first );
- }
-
- /*
- * The next step is to `simplify' an outline's topology so that we
- * can identify local extrema more reliably: A series of
- * non-horizontal or non-vertical vectors pointing into the same
- * quadrant are handled as a single, long vector. From a
- * topological point of the view, the intermediate points are of no
- * interest and thus tagged as weak.
- */
-
- for ( point = points; point < point_limit; point++ )
- {
- if ( point->flags & AF_FLAG_WEAK_INTERPOLATION )
- continue;
-
- if ( point->in_dir == AF_DIR_NONE &&
- point->out_dir == AF_DIR_NONE )
- {
- /* check whether both vectors point into the same quadrant */
-
- FT_Pos in_x, in_y;
- FT_Pos out_x, out_y;
-
- AF_Point next_u = point + point->u;
- AF_Point prev_v = point + point->v;
-
-
- in_x = point->fx - prev_v->fx;
- in_y = point->fy - prev_v->fy;
-
- out_x = next_u->fx - point->fx;
- out_y = next_u->fy - point->fy;
-
- if ( ( in_x ^ out_x ) >= 0 && ( in_y ^ out_y ) >= 0 )
- {
- /* yes, so tag current point as weak */
- /* and update index deltas */
-
- point->flags |= AF_FLAG_WEAK_INTERPOLATION;
-
- prev_v->u = (FT_Pos)( next_u - prev_v );
- next_u->v = -prev_v->u;
- }
- }
- }
-
- /*
- * Finally, check for remaining weak points. Everything else not
- * collected in edges so far is then implicitly classified as strong
- * points.
- */
-
- for ( point = points; point < point_limit; point++ )
- {
- if ( point->flags & AF_FLAG_WEAK_INTERPOLATION )
- continue;
-
- if ( point->flags & AF_FLAG_CONTROL )
- {
- /* control points are always weak */
- Is_Weak_Point:
- point->flags |= AF_FLAG_WEAK_INTERPOLATION;
- }
- else if ( point->out_dir == point->in_dir )
- {
- if ( point->out_dir != AF_DIR_NONE )
- {
- /* current point lies on a horizontal or */
- /* vertical segment (but doesn't start or end it) */
- goto Is_Weak_Point;
- }
-
- {
- AF_Point next_u = point + point->u;
- AF_Point prev_v = point + point->v;
-
-
- if ( ft_corner_is_flat( point->fx - prev_v->fx,
- point->fy - prev_v->fy,
- next_u->fx - point->fx,
- next_u->fy - point->fy ) )
- {
- /* either the `in' or the `out' vector is much more */
- /* dominant than the other one, so tag current point */
- /* as weak and update index deltas */
-
- prev_v->u = (FT_Pos)( next_u - prev_v );
- next_u->v = -prev_v->u;
-
- goto Is_Weak_Point;
- }
- }
- }
- else if ( point->in_dir == -point->out_dir )
- {
- /* current point forms a spike */
- goto Is_Weak_Point;
- }
- }
- }
- }
-
- Exit:
- return error;
- }
-
-
- /* Store the hinted outline in an FT_Outline structure. */
-
- FT_LOCAL_DEF( void )
- af_glyph_hints_save( AF_GlyphHints hints,
- FT_Outline* outline )
- {
- AF_Point point = hints->points;
- AF_Point limit = point + hints->num_points;
- FT_Vector* vec = outline->points;
- FT_Byte* tag = outline->tags;
-
-
- for ( ; point < limit; point++, vec++, tag++ )
- {
- vec->x = point->x;
- vec->y = point->y;
-
- if ( point->flags & AF_FLAG_CONIC )
- tag[0] = FT_CURVE_TAG_CONIC;
- else if ( point->flags & AF_FLAG_CUBIC )
- tag[0] = FT_CURVE_TAG_CUBIC;
- else
- tag[0] = FT_CURVE_TAG_ON;
- }
- }
-
-
- /****************************************************************
- *
- * EDGE POINT GRID-FITTING
- *
- ****************************************************************/
-
-
- /* Align all points of an edge to the same coordinate value, */
- /* either horizontally or vertically. */
-
- FT_LOCAL_DEF( void )
- af_glyph_hints_align_edge_points( AF_GlyphHints hints,
- AF_Dimension dim )
- {
- AF_AxisHints axis = & hints->axis[dim];
- AF_Segment segments = axis->segments;
- AF_Segment segment_limit = FT_OFFSET( segments, axis->num_segments );
- AF_Segment seg;
-
-
- if ( dim == AF_DIMENSION_HORZ )
- {
- for ( seg = segments; seg < segment_limit; seg++ )
- {
- AF_Edge edge = seg->edge;
- AF_Point point, first, last;
-
-
- if ( !edge )
- continue;
-
- first = seg->first;
- last = seg->last;
- point = first;
- for (;;)
- {
- point->x = edge->pos;
- point->flags |= AF_FLAG_TOUCH_X;
-
- if ( point == last )
- break;
-
- point = point->next;
- }
- }
- }
- else
- {
- for ( seg = segments; seg < segment_limit; seg++ )
- {
- AF_Edge edge = seg->edge;
- AF_Point point, first, last;
-
-
- if ( !edge )
- continue;
-
- first = seg->first;
- last = seg->last;
- point = first;
- for (;;)
- {
- point->y = edge->pos;
- point->flags |= AF_FLAG_TOUCH_Y;
-
- if ( point == last )
- break;
-
- point = point->next;
- }
- }
- }
- }
-
-
- /****************************************************************
- *
- * STRONG POINT INTERPOLATION
- *
- ****************************************************************/
-
-
- /* Hint the strong points -- this is equivalent to the TrueType `IP' */
- /* hinting instruction. */
-
- FT_LOCAL_DEF( void )
- af_glyph_hints_align_strong_points( AF_GlyphHints hints,
- AF_Dimension dim )
- {
- AF_Point points = hints->points;
- AF_Point point_limit = points + hints->num_points;
- AF_AxisHints axis = &hints->axis[dim];
- AF_Edge edges = axis->edges;
- AF_Edge edge_limit = FT_OFFSET( edges, axis->num_edges );
- FT_UInt touch_flag;
-
-
- if ( dim == AF_DIMENSION_HORZ )
- touch_flag = AF_FLAG_TOUCH_X;
- else
- touch_flag = AF_FLAG_TOUCH_Y;
-
- if ( edges < edge_limit )
- {
- AF_Point point;
- AF_Edge edge;
-
-
- for ( point = points; point < point_limit; point++ )
- {
- FT_Pos u, ou, fu; /* point position */
- FT_Pos delta;
-
-
- if ( point->flags & touch_flag )
- continue;
-
- /* if this point is candidate to weak interpolation, we */
- /* interpolate it after all strong points have been processed */
-
- if ( ( point->flags & AF_FLAG_WEAK_INTERPOLATION ) )
- continue;
-
- if ( dim == AF_DIMENSION_VERT )
- {
- u = point->fy;
- ou = point->oy;
- }
- else
- {
- u = point->fx;
- ou = point->ox;
- }
-
- fu = u;
-
- /* is the point before the first edge? */
- edge = edges;
- delta = edge->fpos - u;
- if ( delta >= 0 )
- {
- u = edge->pos - ( edge->opos - ou );
-
-#ifdef FT_DEBUG_AUTOFIT
- point->before[dim] = edge;
- point->after[dim] = NULL;
-#endif
-
- goto Store_Point;
- }
-
- /* is the point after the last edge? */
- edge = edge_limit - 1;
- delta = u - edge->fpos;
- if ( delta >= 0 )
- {
- u = edge->pos + ( ou - edge->opos );
-
-#ifdef FT_DEBUG_AUTOFIT
- point->before[dim] = NULL;
- point->after[dim] = edge;
-#endif
-
- goto Store_Point;
- }
-
- {
- FT_PtrDist min, max, mid;
- FT_Pos fpos;
-
-
- /* find enclosing edges */
- min = 0;
- max = edge_limit - edges;
-
-#if 1
- /* for a small number of edges, a linear search is better */
- if ( max <= 8 )
- {
- FT_PtrDist nn;
-
-
- for ( nn = 0; nn < max; nn++ )
- if ( edges[nn].fpos >= u )
- break;
-
- if ( edges[nn].fpos == u )
- {
- u = edges[nn].pos;
- goto Store_Point;
- }
- min = nn;
- }
- else
-#endif
- while ( min < max )
- {
- mid = ( max + min ) >> 1;
- edge = edges + mid;
- fpos = edge->fpos;
-
- if ( u < fpos )
- max = mid;
- else if ( u > fpos )
- min = mid + 1;
- else
- {
- /* we are on the edge */
- u = edge->pos;
-
-#ifdef FT_DEBUG_AUTOFIT
- point->before[dim] = NULL;
- point->after[dim] = NULL;
-#endif
-
- goto Store_Point;
- }
- }
-
- /* point is not on an edge */
- {
- AF_Edge before = edges + min - 1;
- AF_Edge after = edges + min + 0;
-
-
-#ifdef FT_DEBUG_AUTOFIT
- point->before[dim] = before;
- point->after[dim] = after;
-#endif
-
- /* assert( before && after && before != after ) */
- if ( before->scale == 0 )
- before->scale = FT_DivFix( after->pos - before->pos,
- after->fpos - before->fpos );
-
- u = before->pos + FT_MulFix( fu - before->fpos,
- before->scale );
- }
- }
-
- Store_Point:
- /* save the point position */
- if ( dim == AF_DIMENSION_HORZ )
- point->x = u;
- else
- point->y = u;
-
- point->flags |= touch_flag;
- }
- }
- }
-
-
- /****************************************************************
- *
- * WEAK POINT INTERPOLATION
- *
- ****************************************************************/
-
-
- /* Shift the original coordinates of all points between `p1' and */
- /* `p2' to get hinted coordinates, using the same difference as */
- /* given by `ref'. */
-
- static void
- af_iup_shift( AF_Point p1,
- AF_Point p2,
- AF_Point ref )
- {
- AF_Point p;
- FT_Pos delta = ref->u - ref->v;
-
-
- if ( delta == 0 )
- return;
-
- for ( p = p1; p < ref; p++ )
- p->u = p->v + delta;
-
- for ( p = ref + 1; p <= p2; p++ )
- p->u = p->v + delta;
- }
-
-
- /* Interpolate the original coordinates of all points between `p1' and */
- /* `p2' to get hinted coordinates, using `ref1' and `ref2' as the */
- /* reference points. The `u' and `v' members are the current and */
- /* original coordinate values, respectively. */
- /* */
- /* Details can be found in the TrueType bytecode specification. */
-
- static void
- af_iup_interp( AF_Point p1,
- AF_Point p2,
- AF_Point ref1,
- AF_Point ref2 )
- {
- AF_Point p;
- FT_Pos u, v1, v2, u1, u2, d1, d2;
-
-
- if ( p1 > p2 )
- return;
-
- if ( ref1->v > ref2->v )
- {
- p = ref1;
- ref1 = ref2;
- ref2 = p;
- }
-
- v1 = ref1->v;
- v2 = ref2->v;
- u1 = ref1->u;
- u2 = ref2->u;
- d1 = u1 - v1;
- d2 = u2 - v2;
-
- if ( u1 == u2 || v1 == v2 )
- {
- for ( p = p1; p <= p2; p++ )
- {
- u = p->v;
-
- if ( u <= v1 )
- u += d1;
- else if ( u >= v2 )
- u += d2;
- else
- u = u1;
-
- p->u = u;
- }
- }
- else
- {
- FT_Fixed scale = FT_DivFix( u2 - u1, v2 - v1 );
-
-
- for ( p = p1; p <= p2; p++ )
- {
- u = p->v;
-
- if ( u <= v1 )
- u += d1;
- else if ( u >= v2 )
- u += d2;
- else
- u = u1 + FT_MulFix( u - v1, scale );
-
- p->u = u;
- }
- }
- }
-
-
- /* Hint the weak points -- this is equivalent to the TrueType `IUP' */
- /* hinting instruction. */
-
- FT_LOCAL_DEF( void )
- af_glyph_hints_align_weak_points( AF_GlyphHints hints,
- AF_Dimension dim )
- {
- AF_Point points = hints->points;
- AF_Point point_limit = points + hints->num_points;
- AF_Point* contour = hints->contours;
- AF_Point* contour_limit = contour + hints->num_contours;
- FT_UInt touch_flag;
- AF_Point point;
- AF_Point end_point;
- AF_Point first_point;
-
-
- /* PASS 1: Move segment points to edge positions */
-
- if ( dim == AF_DIMENSION_HORZ )
- {
- touch_flag = AF_FLAG_TOUCH_X;
-
- for ( point = points; point < point_limit; point++ )
- {
- point->u = point->x;
- point->v = point->ox;
- }
- }
- else
- {
- touch_flag = AF_FLAG_TOUCH_Y;
-
- for ( point = points; point < point_limit; point++ )
- {
- point->u = point->y;
- point->v = point->oy;
- }
- }
-
- for ( ; contour < contour_limit; contour++ )
- {
- AF_Point first_touched, last_touched;
-
-
- point = *contour;
- end_point = point->prev;
- first_point = point;
-
- /* find first touched point */
- for (;;)
- {
- if ( point > end_point ) /* no touched point in contour */
- goto NextContour;
-
- if ( point->flags & touch_flag )
- break;
-
- point++;
- }
-
- first_touched = point;
-
- for (;;)
- {
- FT_ASSERT( point <= end_point &&
- ( point->flags & touch_flag ) != 0 );
-
- /* skip any touched neighbours */
- while ( point < end_point &&
- ( point[1].flags & touch_flag ) != 0 )
- point++;
-
- last_touched = point;
-
- /* find the next touched point, if any */
- point++;
- for (;;)
- {
- if ( point > end_point )
- goto EndContour;
-
- if ( ( point->flags & touch_flag ) != 0 )
- break;
-
- point++;
- }
-
- /* interpolate between last_touched and point */
- af_iup_interp( last_touched + 1, point - 1,
- last_touched, point );
- }
-
- EndContour:
- /* special case: only one point was touched */
- if ( last_touched == first_touched )
- af_iup_shift( first_point, end_point, first_touched );
-
- else /* interpolate the last part */
- {
- if ( last_touched < end_point )
- af_iup_interp( last_touched + 1, end_point,
- last_touched, first_touched );
-
- if ( first_touched > points )
- af_iup_interp( first_point, first_touched - 1,
- last_touched, first_touched );
- }
-
- NextContour:
- ;
- }
-
- /* now save the interpolated values back to x/y */
- if ( dim == AF_DIMENSION_HORZ )
- {
- for ( point = points; point < point_limit; point++ )
- point->x = point->u;
- }
- else
- {
- for ( point = points; point < point_limit; point++ )
- point->y = point->u;
- }
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/autofit/afhints.h b/contrib/libs/freetype/src/autofit/afhints.h
deleted file mode 100644
index 76fe83006a..0000000000
--- a/contrib/libs/freetype/src/autofit/afhints.h
+++ /dev/null
@@ -1,467 +0,0 @@
-/****************************************************************************
- *
- * afhints.h
- *
- * Auto-fitter hinting routines (specification).
- *
- * Copyright (C) 2003-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef AFHINTS_H_
-#define AFHINTS_H_
-
-#include "aftypes.h"
-
-FT_BEGIN_HEADER
-
- /*
- * The definition of outline glyph hints. These are shared by all
- * writing system analysis routines (until now).
- */
-
- typedef enum AF_Dimension_
- {
- AF_DIMENSION_HORZ = 0, /* x coordinates, */
- /* i.e., vertical segments & edges */
- AF_DIMENSION_VERT = 1, /* y coordinates, */
- /* i.e., horizontal segments & edges */
-
- AF_DIMENSION_MAX /* do not remove */
-
- } AF_Dimension;
-
-
- /* hint directions -- the values are computed so that two vectors are */
- /* in opposite directions iff `dir1 + dir2 == 0' */
- typedef enum AF_Direction_
- {
- AF_DIR_NONE = 4,
- AF_DIR_RIGHT = 1,
- AF_DIR_LEFT = -1,
- AF_DIR_UP = 2,
- AF_DIR_DOWN = -2
-
- } AF_Direction;
-
-
- /*
- * The following explanations are mostly taken from the article
- *
- * Real-Time Grid Fitting of Typographic Outlines
- *
- * by David Turner and Werner Lemberg
- *
- * https://www.tug.org/TUGboat/Articles/tb24-3/lemberg.pdf
- *
- * with appropriate updates.
- *
- *
- * Segments
- *
- * `af_{cjk,latin,...}_hints_compute_segments' are the functions to
- * find segments in an outline.
- *
- * A segment is a series of at least two consecutive points that are
- * approximately aligned along a coordinate axis. The analysis to do
- * so is specific to a writing system.
- *
- *
- * Edges
- *
- * `af_{cjk,latin,...}_hints_compute_edges' are the functions to find
- * edges.
- *
- * As soon as segments are defined, the auto-hinter groups them into
- * edges. An edge corresponds to a single position on the main
- * dimension that collects one or more segments (allowing for a small
- * threshold).
- *
- * As an example, the `latin' writing system first tries to grid-fit
- * edges, then to align segments on the edges unless it detects that
- * they form a serif.
- *
- *
- * A H
- * | |
- * | |
- * | |
- * | |
- * C | | F
- * +------<-----+ +-----<------+
- * | B G |
- * | |
- * | |
- * +--------------->------------------+
- * D E
- *
- *
- * Stems
- *
- * Stems are detected by `af_{cjk,latin,...}_hint_edges'.
- *
- * Segments need to be `linked' to other ones in order to detect stems.
- * A stem is made of two segments that face each other in opposite
- * directions and that are sufficiently close to each other. Using
- * vocabulary from the TrueType specification, stem segments form a
- * `black distance'.
- *
- * In the above ASCII drawing, the horizontal segments are BC, DE, and
- * FG; the vertical segments are AB, CD, EF, and GH.
- *
- * Each segment has at most one `best' candidate to form a black
- * distance, or no candidate at all. Notice that two distinct segments
- * can have the same candidate, which frequently means a serif.
- *
- * A stem is recognized by the following condition:
- *
- * best segment_1 = segment_2 && best segment_2 = segment_1
- *
- * The best candidate is stored in field `link' in structure
- * `AF_Segment'.
- *
- * In the above ASCII drawing, the best candidate for both AB and CD is
- * GH, while the best candidate for GH is AB. Similarly, the best
- * candidate for EF and GH is AB, while the best candidate for AB is
- * GH.
- *
- * The detection and handling of stems is dependent on the writing
- * system.
- *
- *
- * Serifs
- *
- * Serifs are detected by `af_{cjk,latin,...}_hint_edges'.
- *
- * In comparison to a stem, a serif (as handled by the auto-hinter
- * module that takes care of the `latin' writing system) has
- *
- * best segment_1 = segment_2 && best segment_2 != segment_1
- *
- * where segment_1 corresponds to the serif segment (CD and EF in the
- * above ASCII drawing).
- *
- * The best candidate is stored in field `serif' in structure
- * `AF_Segment' (and `link' is set to NULL).
- *
- *
- * Touched points
- *
- * A point is called `touched' if it has been processed somehow by the
- * auto-hinter. It basically means that it shouldn't be moved again
- * (or moved only under certain constraints to preserve the already
- * applied processing).
- *
- *
- * Flat and round segments
- *
- * Segments are `round' or `flat', depending on the series of points
- * that define them. A segment is round if the next and previous point
- * of an extremum (which can be either a single point or sequence of
- * points) are both conic or cubic control points. Otherwise, a
- * segment with an extremum is flat.
- *
- *
- * Strong Points
- *
- * Experience has shown that points not part of an edge need to be
- * interpolated linearly between their two closest edges, even if these
- * are not part of the contour of those particular points. Typical
- * candidates for this are
- *
- * - angle points (i.e., points where the `in' and `out' direction
- * differ greatly)
- *
- * - inflection points (i.e., where the `in' and `out' angles are the
- * same, but the curvature changes sign) [currently, such points
- * aren't handled specially in the auto-hinter]
- *
- * `af_glyph_hints_align_strong_points' is the function that takes
- * care of such situations; it is equivalent to the TrueType `IP'
- * hinting instruction.
- *
- *
- * Weak Points
- *
- * Other points in the outline must be interpolated using the
- * coordinates of their previous and next unfitted contour neighbours.
- * These are called `weak points' and are touched by the function
- * `af_glyph_hints_align_weak_points', equivalent to the TrueType `IUP'
- * hinting instruction. Typical candidates are control points and
- * points on the contour without a major direction.
- *
- * The major effect is to reduce possible distortion caused by
- * alignment of edges and strong points, thus weak points are processed
- * after strong points.
- */
-
-
- /* point hint flags */
-#define AF_FLAG_NONE 0
-
- /* point type flags */
-#define AF_FLAG_CONIC ( 1U << 0 )
-#define AF_FLAG_CUBIC ( 1U << 1 )
-#define AF_FLAG_CONTROL ( AF_FLAG_CONIC | AF_FLAG_CUBIC )
-
- /* point touch flags */
-#define AF_FLAG_TOUCH_X ( 1U << 2 )
-#define AF_FLAG_TOUCH_Y ( 1U << 3 )
-
- /* candidates for weak interpolation have this flag set */
-#define AF_FLAG_WEAK_INTERPOLATION ( 1U << 4 )
-
- /* the distance to the next point is very small */
-#define AF_FLAG_NEAR ( 1U << 5 )
-
-
- /* edge hint flags */
-#define AF_EDGE_NORMAL 0
-#define AF_EDGE_ROUND ( 1U << 0 )
-#define AF_EDGE_SERIF ( 1U << 1 )
-#define AF_EDGE_DONE ( 1U << 2 )
-#define AF_EDGE_NEUTRAL ( 1U << 3 ) /* edge aligns to a neutral blue zone */
-
-
- typedef struct AF_PointRec_* AF_Point;
- typedef struct AF_SegmentRec_* AF_Segment;
- typedef struct AF_EdgeRec_* AF_Edge;
-
-
- typedef struct AF_PointRec_
- {
- FT_UShort flags; /* point flags used by hinter */
- FT_Char in_dir; /* direction of inwards vector */
- FT_Char out_dir; /* direction of outwards vector */
-
- FT_Pos ox, oy; /* original, scaled position */
- FT_Short fx, fy; /* original, unscaled position (in font units) */
- FT_Pos x, y; /* current position */
- FT_Pos u, v; /* current (x,y) or (y,x) depending on context */
-
- AF_Point next; /* next point in contour */
- AF_Point prev; /* previous point in contour */
-
-#ifdef FT_DEBUG_AUTOFIT
- /* track `before' and `after' edges for strong points */
- AF_Edge before[2];
- AF_Edge after[2];
-#endif
-
- } AF_PointRec;
-
-
- typedef struct AF_SegmentRec_
- {
- FT_Byte flags; /* edge/segment flags for this segment */
- FT_Char dir; /* segment direction */
- FT_Short pos; /* position of segment */
- FT_Short delta; /* deviation from segment position */
- FT_Short min_coord; /* minimum coordinate of segment */
- FT_Short max_coord; /* maximum coordinate of segment */
- FT_Short height; /* the hinted segment height */
-
- AF_Edge edge; /* the segment's parent edge */
- AF_Segment edge_next; /* link to next segment in parent edge */
-
- AF_Segment link; /* (stem) link segment */
- AF_Segment serif; /* primary segment for serifs */
- FT_Pos score; /* used during stem matching */
- FT_Pos len; /* used during stem matching */
-
- AF_Point first; /* first point in edge segment */
- AF_Point last; /* last point in edge segment */
-
- } AF_SegmentRec;
-
-
- typedef struct AF_EdgeRec_
- {
- FT_Short fpos; /* original, unscaled position (in font units) */
- FT_Pos opos; /* original, scaled position */
- FT_Pos pos; /* current position */
-
- FT_Byte flags; /* edge flags */
- FT_Char dir; /* edge direction */
- FT_Fixed scale; /* used to speed up interpolation between edges */
-
- AF_Width blue_edge; /* non-NULL if this is a blue edge */
- AF_Edge link; /* link edge */
- AF_Edge serif; /* primary edge for serifs */
- FT_Int score; /* used during stem matching */
-
- AF_Segment first; /* first segment in edge */
- AF_Segment last; /* last segment in edge */
-
- } AF_EdgeRec;
-
-#define AF_SEGMENTS_EMBEDDED 18 /* number of embedded segments */
-#define AF_EDGES_EMBEDDED 12 /* number of embedded edges */
-
- typedef struct AF_AxisHintsRec_
- {
- FT_UInt num_segments; /* number of used segments */
- FT_UInt max_segments; /* number of allocated segments */
- AF_Segment segments; /* segments array */
-
- FT_UInt num_edges; /* number of used edges */
- FT_UInt max_edges; /* number of allocated edges */
- AF_Edge edges; /* edges array */
-
- AF_Direction major_dir; /* either vertical or horizontal */
-
- /* two arrays to avoid allocation penalty */
- struct
- {
- AF_SegmentRec segments[AF_SEGMENTS_EMBEDDED];
- AF_EdgeRec edges[AF_EDGES_EMBEDDED];
- } embedded;
-
-
- } AF_AxisHintsRec, *AF_AxisHints;
-
-
-#define AF_POINTS_EMBEDDED 96 /* number of embedded points */
-#define AF_CONTOURS_EMBEDDED 8 /* number of embedded contours */
-
- typedef struct AF_GlyphHintsRec_
- {
- FT_Memory memory;
-
- FT_Fixed x_scale;
- FT_Pos x_delta;
-
- FT_Fixed y_scale;
- FT_Pos y_delta;
-
- FT_Int max_points; /* number of allocated points */
- FT_Int num_points; /* number of used points */
- AF_Point points; /* points array */
-
- FT_Int max_contours; /* number of allocated contours */
- FT_Int num_contours; /* number of used contours */
- AF_Point* contours; /* contours array */
-
- AF_AxisHintsRec axis[AF_DIMENSION_MAX];
-
- FT_UInt32 scaler_flags; /* copy of scaler flags */
- FT_UInt32 other_flags; /* free for style-specific */
- /* implementations */
- AF_StyleMetrics metrics;
-
- /* Two arrays to avoid allocation penalty. */
- /* The `embedded' structure must be the last element! */
- struct
- {
- AF_Point contours[AF_CONTOURS_EMBEDDED];
- AF_PointRec points[AF_POINTS_EMBEDDED];
- } embedded;
-
- } AF_GlyphHintsRec;
-
-
-#define AF_HINTS_TEST_SCALER( h, f ) ( (h)->scaler_flags & (f) )
-#define AF_HINTS_TEST_OTHER( h, f ) ( (h)->other_flags & (f) )
-
-
-#ifdef FT_DEBUG_AUTOFIT
-
-#define AF_HINTS_DO_HORIZONTAL( h ) \
- ( !af_debug_disable_horz_hints_ && \
- !AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_HORIZONTAL ) )
-
-#define AF_HINTS_DO_VERTICAL( h ) \
- ( !af_debug_disable_vert_hints_ && \
- !AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_VERTICAL ) )
-
-#define AF_HINTS_DO_BLUES( h ) ( !af_debug_disable_blue_hints_ )
-
-#else /* !FT_DEBUG_AUTOFIT */
-
-#define AF_HINTS_DO_HORIZONTAL( h ) \
- !AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_HORIZONTAL )
-
-#define AF_HINTS_DO_VERTICAL( h ) \
- !AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_VERTICAL )
-
-#define AF_HINTS_DO_BLUES( h ) 1
-
-#endif /* !FT_DEBUG_AUTOFIT */
-
-
-#define AF_HINTS_DO_ADVANCE( h ) \
- !AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_ADVANCE )
-
-
- FT_LOCAL( AF_Direction )
- af_direction_compute( FT_Pos dx,
- FT_Pos dy );
-
-
- FT_LOCAL( FT_Error )
- af_axis_hints_new_segment( AF_AxisHints axis,
- FT_Memory memory,
- AF_Segment *asegment );
-
- FT_LOCAL( FT_Error)
- af_axis_hints_new_edge( AF_AxisHints axis,
- FT_Int fpos,
- AF_Direction dir,
- FT_Bool top_to_bottom_hinting,
- FT_Memory memory,
- AF_Edge *edge );
-
- FT_LOCAL( void )
- af_glyph_hints_init( AF_GlyphHints hints,
- FT_Memory memory );
-
- FT_LOCAL( void )
- af_glyph_hints_rescale( AF_GlyphHints hints,
- AF_StyleMetrics metrics );
-
- FT_LOCAL( FT_Error )
- af_glyph_hints_reload( AF_GlyphHints hints,
- FT_Outline* outline );
-
- FT_LOCAL( void )
- af_glyph_hints_save( AF_GlyphHints hints,
- FT_Outline* outline );
-
- FT_LOCAL( void )
- af_glyph_hints_align_edge_points( AF_GlyphHints hints,
- AF_Dimension dim );
-
- FT_LOCAL( void )
- af_glyph_hints_align_strong_points( AF_GlyphHints hints,
- AF_Dimension dim );
-
- FT_LOCAL( void )
- af_glyph_hints_align_weak_points( AF_GlyphHints hints,
- AF_Dimension dim );
-
- FT_LOCAL( void )
- af_glyph_hints_done( AF_GlyphHints hints );
-
-/* */
-
-#define AF_SEGMENT_LEN( seg ) ( (seg)->max_coord - (seg)->min_coord )
-
-#define AF_SEGMENT_DIST( seg1, seg2 ) ( ( (seg1)->pos > (seg2)->pos ) \
- ? (seg1)->pos - (seg2)->pos \
- : (seg2)->pos - (seg1)->pos )
-
-
-FT_END_HEADER
-
-#endif /* AFHINTS_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/autofit/afindic.c b/contrib/libs/freetype/src/autofit/afindic.c
deleted file mode 100644
index c6d23efd86..0000000000
--- a/contrib/libs/freetype/src/autofit/afindic.c
+++ /dev/null
@@ -1,157 +0,0 @@
-/****************************************************************************
- *
- * afindic.c
- *
- * Auto-fitter hinting routines for Indic writing system (body).
- *
- * Copyright (C) 2007-2024 by
- * Rahul Bhalerao <rahul.bhalerao@redhat.com>, <b.rahul.pm@gmail.com>.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include "aftypes.h"
-#include "aflatin.h"
-#include "afcjk.h"
-
-
-#ifdef AF_CONFIG_OPTION_INDIC
-
-#include "afindic.h"
-#include "aferrors.h"
-
-
- static FT_Error
- af_indic_metrics_init( AF_StyleMetrics metrics_, /* AF_CJKMetrics */
- FT_Face face )
- {
- AF_CJKMetrics metrics = (AF_CJKMetrics)metrics_;
-
-
- /* skip blue zone init in CJK routines */
- FT_CharMap oldmap = face->charmap;
-
-
- metrics->units_per_em = face->units_per_EM;
-
- if ( FT_Select_Charmap( face, FT_ENCODING_UNICODE ) )
- face->charmap = NULL;
- else
- {
- af_cjk_metrics_init_widths( metrics, face );
-#if 0
- /* either need indic specific blue_chars[] or just skip blue zones */
- af_cjk_metrics_init_blues( metrics, face, af_cjk_blue_chars );
-#endif
- af_cjk_metrics_check_digits( metrics, face );
- }
-
- face->charmap = oldmap;
- return FT_Err_Ok;
- }
-
-
- static void
- af_indic_metrics_scale( AF_StyleMetrics metrics,
- AF_Scaler scaler )
- {
- /* use CJK routines */
- af_cjk_metrics_scale( metrics, scaler );
- }
-
-
- static FT_Error
- af_indic_hints_init( AF_GlyphHints hints,
- AF_StyleMetrics metrics )
- {
- /* use CJK routines */
- return af_cjk_hints_init( hints, metrics );
- }
-
-
- static FT_Error
- af_indic_hints_apply( FT_UInt glyph_index,
- AF_GlyphHints hints,
- FT_Outline* outline,
- AF_StyleMetrics metrics )
- {
- /* use CJK routines */
- return af_cjk_hints_apply( glyph_index, hints, outline, metrics );
- }
-
-
- /* Extract standard_width from writing system/script specific */
- /* metrics class. */
-
- static void
- af_indic_get_standard_widths( AF_StyleMetrics metrics_, /* AF_CJKMetrics */
- FT_Pos* stdHW,
- FT_Pos* stdVW )
- {
- AF_CJKMetrics metrics = (AF_CJKMetrics)metrics_;
-
-
- if ( stdHW )
- *stdHW = metrics->axis[AF_DIMENSION_VERT].standard_width;
-
- if ( stdVW )
- *stdVW = metrics->axis[AF_DIMENSION_HORZ].standard_width;
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** I N D I C S C R I P T C L A S S *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- AF_DEFINE_WRITING_SYSTEM_CLASS(
- af_indic_writing_system_class,
-
- AF_WRITING_SYSTEM_INDIC,
-
- sizeof ( AF_CJKMetricsRec ),
-
- (AF_WritingSystem_InitMetricsFunc) af_indic_metrics_init, /* style_metrics_init */
- (AF_WritingSystem_ScaleMetricsFunc)af_indic_metrics_scale, /* style_metrics_scale */
- (AF_WritingSystem_DoneMetricsFunc) NULL, /* style_metrics_done */
- (AF_WritingSystem_GetStdWidthsFunc)af_indic_get_standard_widths, /* style_metrics_getstdw */
-
- (AF_WritingSystem_InitHintsFunc) af_indic_hints_init, /* style_hints_init */
- (AF_WritingSystem_ApplyHintsFunc) af_indic_hints_apply /* style_hints_apply */
- )
-
-
-#else /* !AF_CONFIG_OPTION_INDIC */
-
-
- AF_DEFINE_WRITING_SYSTEM_CLASS(
- af_indic_writing_system_class,
-
- AF_WRITING_SYSTEM_INDIC,
-
- sizeof ( AF_CJKMetricsRec ),
-
- (AF_WritingSystem_InitMetricsFunc) NULL, /* style_metrics_init */
- (AF_WritingSystem_ScaleMetricsFunc)NULL, /* style_metrics_scale */
- (AF_WritingSystem_DoneMetricsFunc) NULL, /* style_metrics_done */
- (AF_WritingSystem_GetStdWidthsFunc)NULL, /* style_metrics_getstdw */
-
- (AF_WritingSystem_InitHintsFunc) NULL, /* style_hints_init */
- (AF_WritingSystem_ApplyHintsFunc) NULL /* style_hints_apply */
- )
-
-
-#endif /* !AF_CONFIG_OPTION_INDIC */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/autofit/afindic.h b/contrib/libs/freetype/src/autofit/afindic.h
deleted file mode 100644
index a7f73f2515..0000000000
--- a/contrib/libs/freetype/src/autofit/afindic.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/****************************************************************************
- *
- * afindic.h
- *
- * Auto-fitter hinting routines for Indic writing system
- * (specification).
- *
- * Copyright (C) 2007-2024 by
- * Rahul Bhalerao <rahul.bhalerao@redhat.com>, <b.rahul.pm@gmail.com>.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef AFINDIC_H_
-#define AFINDIC_H_
-
-#include "afhints.h"
-
-
-FT_BEGIN_HEADER
-
-
- /* the `indic' writing system */
-
- AF_DECLARE_WRITING_SYSTEM_CLASS( af_indic_writing_system_class )
-
-
-/* */
-
-FT_END_HEADER
-
-#endif /* AFINDIC_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/autofit/aflatin.c b/contrib/libs/freetype/src/autofit/aflatin.c
deleted file mode 100644
index 89287f7ea5..0000000000
--- a/contrib/libs/freetype/src/autofit/aflatin.c
+++ /dev/null
@@ -1,3643 +0,0 @@
-/****************************************************************************
- *
- * aflatin.c
- *
- * Auto-fitter hinting routines for latin writing system (body).
- *
- * Copyright (C) 2003-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/ftadvanc.h>
-#include <freetype/internal/ftdebug.h>
-
-#include "afglobal.h"
-#include "aflatin.h"
-#include "aferrors.h"
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT aflatin
-
-
- /* needed for computation of round vs. flat segments */
-#define FLAT_THRESHOLD( x ) ( x / 14 )
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** L A T I N G L O B A L M E T R I C S *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /* Find segments and links, compute all stem widths, and initialize */
- /* standard width and height for the glyph with given charcode. */
-
- FT_LOCAL_DEF( void )
- af_latin_metrics_init_widths( AF_LatinMetrics metrics,
- FT_Face face )
- {
- /* scan the array of segments in each direction */
- AF_GlyphHintsRec hints[1];
-
-
- FT_TRACE5(( "\n" ));
- FT_TRACE5(( "latin standard widths computation (style `%s')\n",
- af_style_names[metrics->root.style_class->style] ));
- FT_TRACE5(( "=====================================================\n" ));
- FT_TRACE5(( "\n" ));
-
- af_glyph_hints_init( hints, face->memory );
-
- metrics->axis[AF_DIMENSION_HORZ].width_count = 0;
- metrics->axis[AF_DIMENSION_VERT].width_count = 0;
-
- {
- FT_Error error;
- FT_ULong glyph_index;
- int dim;
- AF_LatinMetricsRec dummy[1];
- AF_Scaler scaler = &dummy->root.scaler;
-
- AF_StyleClass style_class = metrics->root.style_class;
- AF_ScriptClass script_class = af_script_classes[style_class->script];
-
- /* If HarfBuzz is not available, we need a pointer to a single */
- /* unsigned long value. */
-#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
- void* shaper_buf;
-#else
- FT_ULong shaper_buf_;
- void* shaper_buf = &shaper_buf_;
-#endif
-
- const char* p;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- FT_ULong ch = 0;
-#endif
-
-
- p = script_class->standard_charstring;
-
-#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
- shaper_buf = af_shaper_buf_create( face );
-#endif
- /*
- * We check a list of standard characters to catch features like
- * `c2sc' (small caps from caps) that don't contain lowercase letters
- * by definition, or other features that mainly operate on numerals.
- * The first match wins.
- */
-
- glyph_index = 0;
- while ( *p )
- {
- unsigned int num_idx;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- const char* p_old;
-#endif
-
-
- while ( *p == ' ' )
- p++;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- p_old = p;
- GET_UTF8_CHAR( ch, p_old );
-#endif
-
- /* reject input that maps to more than a single glyph */
- p = af_shaper_get_cluster( p, &metrics->root, shaper_buf, &num_idx );
- if ( num_idx > 1 )
- continue;
-
- /* otherwise exit loop if we have a result */
- glyph_index = af_shaper_get_elem( &metrics->root,
- shaper_buf,
- 0,
- NULL,
- NULL );
- if ( glyph_index )
- break;
- }
-
- af_shaper_buf_destroy( face, shaper_buf );
-
- if ( !glyph_index )
- {
- FT_TRACE5(( "standard character missing;"
- " using fallback stem widths\n" ));
- goto Exit;
- }
-
- FT_TRACE5(( "standard character: U+%04lX (glyph index %ld)\n",
- ch, glyph_index ));
-
- error = FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_SCALE );
- if ( error || face->glyph->outline.n_points <= 0 )
- goto Exit;
-
- FT_ZERO( dummy );
-
- dummy->units_per_em = metrics->units_per_em;
-
- scaler->x_scale = 0x10000L;
- scaler->y_scale = 0x10000L;
- scaler->x_delta = 0;
- scaler->y_delta = 0;
-
- scaler->face = face;
- scaler->render_mode = FT_RENDER_MODE_NORMAL;
- scaler->flags = 0;
-
- af_glyph_hints_rescale( hints, (AF_StyleMetrics)dummy );
-
- error = af_glyph_hints_reload( hints, &face->glyph->outline );
- if ( error )
- goto Exit;
-
- for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ )
- {
- AF_LatinAxis axis = &metrics->axis[dim];
- AF_AxisHints axhints = &hints->axis[dim];
- AF_Segment seg, limit, link;
- FT_UInt num_widths = 0;
-
-
- error = af_latin_hints_compute_segments( hints,
- (AF_Dimension)dim );
- if ( error )
- goto Exit;
-
- /*
- * We assume that the glyphs selected for the stem width
- * computation are `featureless' enough so that the linking
- * algorithm works fine without adjustments of its scoring
- * function.
- */
- af_latin_hints_link_segments( hints,
- 0,
- NULL,
- (AF_Dimension)dim );
-
- seg = axhints->segments;
- limit = FT_OFFSET( seg, axhints->num_segments );
-
- for ( ; seg < limit; seg++ )
- {
- link = seg->link;
-
- /* we only consider stem segments there! */
- if ( link && link->link == seg && link > seg )
- {
- FT_Pos dist;
-
-
- dist = seg->pos - link->pos;
- if ( dist < 0 )
- dist = -dist;
-
- if ( num_widths < AF_LATIN_MAX_WIDTHS )
- axis->widths[num_widths++].org = dist;
- }
- }
-
- /* this also replaces multiple almost identical stem widths */
- /* with a single one (the value 100 is heuristic) */
- af_sort_and_quantize_widths( &num_widths, axis->widths,
- dummy->units_per_em / 100 );
- axis->width_count = num_widths;
- }
-
- Exit:
- for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ )
- {
- AF_LatinAxis axis = &metrics->axis[dim];
- FT_Pos stdw;
-
-
- stdw = ( axis->width_count > 0 ) ? axis->widths[0].org
- : AF_LATIN_CONSTANT( metrics, 50 );
-
- /* let's try 20% of the smallest width */
- axis->edge_distance_threshold = stdw / 5;
- axis->standard_width = stdw;
- axis->extra_light = 0;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- {
- FT_UInt i;
-
-
- FT_TRACE5(( "%s widths:\n",
- dim == AF_DIMENSION_VERT ? "horizontal"
- : "vertical" ));
-
- FT_TRACE5(( " %ld (standard)", axis->standard_width ));
- for ( i = 1; i < axis->width_count; i++ )
- FT_TRACE5(( " %ld", axis->widths[i].org ));
-
- FT_TRACE5(( "\n" ));
- }
-#endif
- }
- }
-
- FT_TRACE5(( "\n" ));
-
- af_glyph_hints_done( hints );
- }
-
-
- static void
- af_latin_sort_blue( FT_UInt count,
- AF_LatinBlue* table )
- {
- FT_UInt i, j;
- AF_LatinBlue swap;
-
-
- /* we sort from bottom to top */
- for ( i = 1; i < count; i++ )
- {
- for ( j = i; j > 0; j-- )
- {
- FT_Pos a, b;
-
-
- if ( table[j - 1]->flags & ( AF_LATIN_BLUE_TOP |
- AF_LATIN_BLUE_SUB_TOP ) )
- a = table[j - 1]->ref.org;
- else
- a = table[j - 1]->shoot.org;
-
- if ( table[j]->flags & ( AF_LATIN_BLUE_TOP |
- AF_LATIN_BLUE_SUB_TOP ) )
- b = table[j]->ref.org;
- else
- b = table[j]->shoot.org;
-
- if ( b >= a )
- break;
-
- swap = table[j];
- table[j] = table[j - 1];
- table[j - 1] = swap;
- }
- }
- }
-
-
- /* Find all blue zones. Flat segments give the reference points, */
- /* round segments the overshoot positions. */
-
- static int
- af_latin_metrics_init_blues( AF_LatinMetrics metrics,
- FT_Face face )
- {
- FT_Pos flats [AF_BLUE_STRING_MAX_LEN];
- FT_Pos rounds[AF_BLUE_STRING_MAX_LEN];
-
- FT_UInt num_flats;
- FT_UInt num_rounds;
-
- AF_LatinBlue blue;
- FT_Error error;
- AF_LatinAxis axis = &metrics->axis[AF_DIMENSION_VERT];
- FT_Outline outline;
-
- AF_StyleClass sc = metrics->root.style_class;
-
- AF_Blue_Stringset bss = sc->blue_stringset;
- const AF_Blue_StringRec* bs = &af_blue_stringsets[bss];
-
- FT_Pos flat_threshold = FLAT_THRESHOLD( metrics->units_per_em );
-
- /* If HarfBuzz is not available, we need a pointer to a single */
- /* unsigned long value. */
-#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
- void* shaper_buf;
-#else
- FT_ULong shaper_buf_;
- void* shaper_buf = &shaper_buf_;
-#endif
-
-
- /* we walk over the blue character strings as specified in the */
- /* style's entry in the `af_blue_stringset' array */
-
- FT_TRACE5(( "latin blue zones computation\n" ));
- FT_TRACE5(( "============================\n" ));
- FT_TRACE5(( "\n" ));
-
-#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
- shaper_buf = af_shaper_buf_create( face );
-#endif
-
- for ( ; bs->string != AF_BLUE_STRING_MAX; bs++ )
- {
- const char* p = &af_blue_strings[bs->string];
- FT_Pos* blue_ref;
- FT_Pos* blue_shoot;
- FT_Pos ascender;
- FT_Pos descender;
-
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- {
- FT_Bool have_flag = 0;
-
-
- FT_TRACE5(( "blue zone %d", axis->blue_count ));
-
- if ( bs->properties )
- {
- FT_TRACE5(( " (" ));
-
- if ( AF_LATIN_IS_TOP_BLUE( bs ) )
- {
- FT_TRACE5(( "top" ));
- have_flag = 1;
- }
- else if ( AF_LATIN_IS_SUB_TOP_BLUE( bs ) )
- {
- FT_TRACE5(( "sub top" ));
- have_flag = 1;
- }
-
- if ( AF_LATIN_IS_NEUTRAL_BLUE( bs ) )
- {
- if ( have_flag )
- FT_TRACE5(( ", " ));
- FT_TRACE5(( "neutral" ));
- have_flag = 1;
- }
-
- if ( AF_LATIN_IS_X_HEIGHT_BLUE( bs ) )
- {
- if ( have_flag )
- FT_TRACE5(( ", " ));
- FT_TRACE5(( "small top" ));
- have_flag = 1;
- }
-
- if ( AF_LATIN_IS_LONG_BLUE( bs ) )
- {
- if ( have_flag )
- FT_TRACE5(( ", " ));
- FT_TRACE5(( "long" ));
- }
-
- FT_TRACE5(( ")" ));
- }
-
- FT_TRACE5(( ":\n" ));
- }
-#endif /* FT_DEBUG_LEVEL_TRACE */
-
- num_flats = 0;
- num_rounds = 0;
- ascender = 0;
- descender = 0;
-
- while ( *p )
- {
- FT_ULong glyph_index;
- FT_Long y_offset;
- FT_Int best_point, best_contour_first, best_contour_last;
- FT_Vector* points;
-
- FT_Pos best_y_extremum; /* same as points.y */
- FT_Bool best_round = 0;
-
- unsigned int i, num_idx;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- const char* p_old;
- FT_ULong ch;
-#endif
-
-
- while ( *p == ' ' )
- p++;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- p_old = p;
- GET_UTF8_CHAR( ch, p_old );
-#endif
-
- p = af_shaper_get_cluster( p, &metrics->root, shaper_buf, &num_idx );
-
- if ( !num_idx )
- {
- FT_TRACE5(( " U+%04lX unavailable\n", ch ));
- continue;
- }
-
- if ( AF_LATIN_IS_TOP_BLUE( bs ) )
- best_y_extremum = FT_INT_MIN;
- else
- best_y_extremum = FT_INT_MAX;
-
- /* iterate over all glyph elements of the character cluster */
- /* and get the data of the `biggest' one */
- for ( i = 0; i < num_idx; i++ )
- {
- FT_Pos best_y;
- FT_Bool round = 0;
-
-
- /* load the character in the face -- skip unknown or empty ones */
- glyph_index = af_shaper_get_elem( &metrics->root,
- shaper_buf,
- i,
- NULL,
- &y_offset );
- if ( glyph_index == 0 )
- {
- FT_TRACE5(( " U+%04lX unavailable\n", ch ));
- continue;
- }
-
- error = FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_SCALE );
- outline = face->glyph->outline;
- /* reject glyphs that don't produce any rendering */
- if ( error || outline.n_points <= 2 )
- {
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( num_idx == 1 )
- FT_TRACE5(( " U+%04lX contains no (usable) outlines\n", ch ));
- else
- FT_TRACE5(( " component %d of cluster starting with U+%04lX"
- " contains no (usable) outlines\n", i, ch ));
-#endif
- continue;
- }
-
- /* now compute min or max point indices and coordinates */
- points = outline.points;
- best_point = -1;
- best_contour_first = -1;
- best_contour_last = -1;
- best_y = 0; /* make compiler happy */
-
- {
- FT_Int nn;
- FT_Int pp, first, last;
-
-
- last = -1;
- for ( nn = 0; nn < outline.n_contours; nn++ )
- {
- first = last + 1;
- last = outline.contours[nn];
-
- /* Avoid single-point contours since they are never */
- /* rasterized. In some fonts, they correspond to mark */
- /* attachment points that are way outside of the glyph's */
- /* real outline. */
- if ( last <= first )
- continue;
-
- if ( AF_LATIN_IS_TOP_BLUE( bs ) ||
- AF_LATIN_IS_SUB_TOP_BLUE( bs ) )
- {
- for ( pp = first; pp <= last; pp++ )
- {
- if ( best_point < 0 || points[pp].y > best_y )
- {
- best_point = pp;
- best_y = points[pp].y;
- ascender = FT_MAX( ascender, best_y + y_offset );
- }
- else
- descender = FT_MIN( descender, points[pp].y + y_offset );
- }
- }
- else
- {
- for ( pp = first; pp <= last; pp++ )
- {
- if ( best_point < 0 || points[pp].y < best_y )
- {
- best_point = pp;
- best_y = points[pp].y;
- descender = FT_MIN( descender, best_y + y_offset );
- }
- else
- ascender = FT_MAX( ascender, points[pp].y + y_offset );
- }
- }
-
- if ( best_point > best_contour_last )
- {
- best_contour_first = first;
- best_contour_last = last;
- }
- }
- }
-
- /* now check whether the point belongs to a straight or round */
- /* segment; we first need to find in which contour the extremum */
- /* lies, then inspect its previous and next points */
- if ( best_point >= 0 )
- {
- FT_Pos best_x = points[best_point].x;
- FT_Int prev, next;
- FT_Int best_segment_first, best_segment_last;
- FT_Int best_on_point_first, best_on_point_last;
- FT_Pos dist;
-
-
- best_segment_first = best_point;
- best_segment_last = best_point;
-
- if ( FT_CURVE_TAG( outline.tags[best_point] ) == FT_CURVE_TAG_ON )
- {
- best_on_point_first = best_point;
- best_on_point_last = best_point;
- }
- else
- {
- best_on_point_first = -1;
- best_on_point_last = -1;
- }
-
- /* look for the previous and next points on the contour */
- /* that are not on the same Y coordinate, then threshold */
- /* the `closeness'... */
- prev = best_point;
- next = prev;
-
- do
- {
- if ( prev > best_contour_first )
- prev--;
- else
- prev = best_contour_last;
-
- dist = FT_ABS( points[prev].y - best_y );
- /* accept a small distance or a small angle (both values are */
- /* heuristic; value 20 corresponds to approx. 2.9 degrees) */
- if ( dist > 5 )
- if ( FT_ABS( points[prev].x - best_x ) <= 20 * dist )
- break;
-
- best_segment_first = prev;
-
- if ( FT_CURVE_TAG( outline.tags[prev] ) == FT_CURVE_TAG_ON )
- {
- best_on_point_first = prev;
- if ( best_on_point_last < 0 )
- best_on_point_last = prev;
- }
-
- } while ( prev != best_point );
-
- do
- {
- if ( next < best_contour_last )
- next++;
- else
- next = best_contour_first;
-
- dist = FT_ABS( points[next].y - best_y );
- if ( dist > 5 )
- if ( FT_ABS( points[next].x - best_x ) <= 20 * dist )
- break;
-
- best_segment_last = next;
-
- if ( FT_CURVE_TAG( outline.tags[next] ) == FT_CURVE_TAG_ON )
- {
- best_on_point_last = next;
- if ( best_on_point_first < 0 )
- best_on_point_first = next;
- }
-
- } while ( next != best_point );
-
- if ( AF_LATIN_IS_LONG_BLUE( bs ) )
- {
- /* If this flag is set, we have an additional constraint to */
- /* get the blue zone distance: Find a segment of the topmost */
- /* (or bottommost) contour that is longer than a heuristic */
- /* threshold. This ensures that small bumps in the outline */
- /* are ignored (for example, the `vertical serifs' found in */
- /* many Hebrew glyph designs). */
-
- /* If this segment is long enough, we are done. Otherwise, */
- /* search the segment next to the extremum that is long */
- /* enough, has the same direction, and a not too large */
- /* vertical distance from the extremum. Note that the */
- /* algorithm doesn't check whether the found segment is */
- /* actually the one (vertically) nearest to the extremum. */
-
- /* heuristic threshold value */
- FT_Pos length_threshold = metrics->units_per_em / 25;
-
-
- dist = FT_ABS( points[best_segment_last].x -
- points[best_segment_first].x );
-
- if ( dist < length_threshold &&
- best_segment_last - best_segment_first + 2 <=
- best_contour_last - best_contour_first )
- {
- /* heuristic threshold value */
- FT_Pos height_threshold = metrics->units_per_em / 4;
-
- FT_Int first;
- FT_Int last;
- FT_Bool hit;
-
- /* we intentionally declare these two variables */
- /* outside of the loop since various compilers emit */
- /* incorrect warning messages otherwise, talking about */
- /* `possibly uninitialized variables' */
- FT_Int p_first = 0; /* make compiler happy */
- FT_Int p_last = 0;
-
- FT_Bool left2right;
-
-
- /* compute direction */
- prev = best_point;
-
- do
- {
- if ( prev > best_contour_first )
- prev--;
- else
- prev = best_contour_last;
-
- if ( points[prev].x != best_x )
- break;
-
- } while ( prev != best_point );
-
- /* skip glyph for the degenerate case */
- if ( prev == best_point )
- continue;
-
- left2right = FT_BOOL( points[prev].x < points[best_point].x );
-
- first = best_segment_last;
- last = first;
- hit = 0;
-
- do
- {
- FT_Bool l2r;
- FT_Pos d;
-
-
- if ( !hit )
- {
- /* no hit; adjust first point */
- first = last;
-
- /* also adjust first and last on point */
- if ( FT_CURVE_TAG( outline.tags[first] ) ==
- FT_CURVE_TAG_ON )
- {
- p_first = first;
- p_last = first;
- }
- else
- {
- p_first = -1;
- p_last = -1;
- }
-
- hit = 1;
- }
-
- if ( last < best_contour_last )
- last++;
- else
- last = best_contour_first;
-
- if ( FT_ABS( best_y - points[first].y ) > height_threshold )
- {
- /* vertical distance too large */
- hit = 0;
- continue;
- }
-
- /* same test as above */
- dist = FT_ABS( points[last].y - points[first].y );
- if ( dist > 5 )
- if ( FT_ABS( points[last].x - points[first].x ) <=
- 20 * dist )
- {
- hit = 0;
- continue;
- }
-
- if ( FT_CURVE_TAG( outline.tags[last] ) == FT_CURVE_TAG_ON )
- {
- p_last = last;
- if ( p_first < 0 )
- p_first = last;
- }
-
- l2r = FT_BOOL( points[first].x < points[last].x );
- d = FT_ABS( points[last].x - points[first].x );
-
- if ( l2r == left2right &&
- d >= length_threshold )
- {
- /* all constraints are met; update segment after */
- /* finding its end */
- do
- {
- if ( last < best_contour_last )
- last++;
- else
- last = best_contour_first;
-
- d = FT_ABS( points[last].y - points[first].y );
- if ( d > 5 )
- if ( FT_ABS( points[next].x - points[first].x ) <=
- 20 * dist )
- {
- if ( last > best_contour_first )
- last--;
- else
- last = best_contour_last;
- break;
- }
-
- p_last = last;
-
- if ( FT_CURVE_TAG( outline.tags[last] ) ==
- FT_CURVE_TAG_ON )
- {
- p_last = last;
- if ( p_first < 0 )
- p_first = last;
- }
-
- } while ( last != best_segment_first );
-
- best_y = points[first].y;
-
- best_segment_first = first;
- best_segment_last = last;
-
- best_on_point_first = p_first;
- best_on_point_last = p_last;
-
- break;
- }
-
- } while ( last != best_segment_first );
- }
- }
-
- /* for computing blue zones, we add the y offset as returned */
- /* by the currently used OpenType feature -- for example, */
- /* superscript glyphs might be identical to subscript glyphs */
- /* with a vertical shift */
- best_y += y_offset;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( num_idx == 1 )
- FT_TRACE5(( " U+%04lX: best_y = %5ld", ch, best_y ));
- else
- FT_TRACE5(( " component %d of cluster starting with U+%04lX:"
- " best_y = %5ld", i, ch, best_y ));
-#endif
-
- /* now set the `round' flag depending on the segment's kind: */
- /* */
- /* - if the horizontal distance between the first and last */
- /* `on' point is larger than a heuristic threshold */
- /* we have a flat segment */
- /* - if either the first or the last point of the segment is */
- /* an `off' point, the segment is round, otherwise it is */
- /* flat */
- if ( best_on_point_first >= 0 &&
- best_on_point_last >= 0 &&
- ( FT_ABS( points[best_on_point_last].x -
- points[best_on_point_first].x ) ) >
- flat_threshold )
- round = 0;
- else
- round = FT_BOOL(
- FT_CURVE_TAG( outline.tags[best_segment_first] ) !=
- FT_CURVE_TAG_ON ||
- FT_CURVE_TAG( outline.tags[best_segment_last] ) !=
- FT_CURVE_TAG_ON );
-
- if ( round && AF_LATIN_IS_NEUTRAL_BLUE( bs ) )
- {
- /* only use flat segments for a neutral blue zone */
- FT_TRACE5(( " (round, skipped)\n" ));
- continue;
- }
-
- FT_TRACE5(( " (%s)\n", round ? "round" : "flat" ));
- }
-
- if ( AF_LATIN_IS_TOP_BLUE( bs ) )
- {
- if ( best_y > best_y_extremum )
- {
- best_y_extremum = best_y;
- best_round = round;
- }
- }
- else
- {
- if ( best_y < best_y_extremum )
- {
- best_y_extremum = best_y;
- best_round = round;
- }
- }
-
- } /* end for loop */
-
- if ( !( best_y_extremum == FT_INT_MIN ||
- best_y_extremum == FT_INT_MAX ) )
- {
- if ( best_round )
- rounds[num_rounds++] = best_y_extremum;
- else
- flats[num_flats++] = best_y_extremum;
- }
-
- } /* end while loop */
-
- if ( num_flats == 0 && num_rounds == 0 )
- {
- /*
- * we couldn't find a single glyph to compute this blue zone,
- * we will simply ignore it then
- */
- FT_TRACE5(( " empty\n" ));
- continue;
- }
-
- /* we have computed the contents of the `rounds' and `flats' tables, */
- /* now determine the reference and overshoot position of the blue -- */
- /* we simply take the median value after a simple sort */
- af_sort_pos( num_rounds, rounds );
- af_sort_pos( num_flats, flats );
-
- blue = &axis->blues[axis->blue_count];
- blue_ref = &blue->ref.org;
- blue_shoot = &blue->shoot.org;
-
- axis->blue_count++;
-
- if ( num_flats == 0 )
- {
- *blue_ref =
- *blue_shoot = rounds[num_rounds / 2];
- }
- else if ( num_rounds == 0 )
- {
- *blue_ref =
- *blue_shoot = flats[num_flats / 2];
- }
- else
- {
- *blue_ref = flats [num_flats / 2];
- *blue_shoot = rounds[num_rounds / 2];
- }
-
- /* there are sometimes problems: if the overshoot position of top */
- /* zones is under its reference position, or the opposite for bottom */
- /* zones. We must thus check everything there and correct the errors */
- if ( *blue_shoot != *blue_ref )
- {
- FT_Pos ref = *blue_ref;
- FT_Pos shoot = *blue_shoot;
- FT_Bool over_ref = FT_BOOL( shoot > ref );
-
-
- if ( ( AF_LATIN_IS_TOP_BLUE( bs ) ||
- AF_LATIN_IS_SUB_TOP_BLUE( bs) ) ^ over_ref )
- {
- *blue_ref =
- *blue_shoot = ( shoot + ref ) / 2;
-
- FT_TRACE5(( " [overshoot smaller than reference,"
- " taking mean value]\n" ));
- }
- }
-
- blue->ascender = ascender;
- blue->descender = descender;
-
- blue->flags = 0;
- if ( AF_LATIN_IS_TOP_BLUE( bs ) )
- blue->flags |= AF_LATIN_BLUE_TOP;
- if ( AF_LATIN_IS_SUB_TOP_BLUE( bs ) )
- blue->flags |= AF_LATIN_BLUE_SUB_TOP;
- if ( AF_LATIN_IS_NEUTRAL_BLUE( bs ) )
- blue->flags |= AF_LATIN_BLUE_NEUTRAL;
-
- /*
- * The following flag is used later to adjust the y and x scales
- * in order to optimize the pixel grid alignment of the top of small
- * letters.
- */
- if ( AF_LATIN_IS_X_HEIGHT_BLUE( bs ) )
- blue->flags |= AF_LATIN_BLUE_ADJUSTMENT;
-
- FT_TRACE5(( " -> reference = %ld\n", *blue_ref ));
- FT_TRACE5(( " overshoot = %ld\n", *blue_shoot ));
-
- } /* end for loop */
-
- af_shaper_buf_destroy( face, shaper_buf );
-
- if ( axis->blue_count )
- {
- /* we finally check whether blue zones are ordered; */
- /* `ref' and `shoot' values of two blue zones must not overlap */
-
- FT_UInt i;
- AF_LatinBlue blue_sorted[AF_BLUE_STRINGSET_MAX_LEN];
-
-
- for ( i = 0; i < axis->blue_count; i++ )
- blue_sorted[i] = &axis->blues[i];
-
- /* sort bottoms of blue zones... */
- af_latin_sort_blue( axis->blue_count, blue_sorted );
-
- /* ...and adjust top values if necessary */
- for ( i = 0; i < axis->blue_count - 1; i++ )
- {
- FT_Pos* a;
- FT_Pos* b;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- FT_Bool a_is_top = 0;
-#endif
-
-
- if ( blue_sorted[i]->flags & ( AF_LATIN_BLUE_TOP |
- AF_LATIN_BLUE_SUB_TOP ) )
- {
- a = &blue_sorted[i]->shoot.org;
-#ifdef FT_DEBUG_LEVEL_TRACE
- a_is_top = 1;
-#endif
- }
- else
- a = &blue_sorted[i]->ref.org;
-
- if ( blue_sorted[i + 1]->flags & ( AF_LATIN_BLUE_TOP |
- AF_LATIN_BLUE_SUB_TOP ) )
- b = &blue_sorted[i + 1]->shoot.org;
- else
- b = &blue_sorted[i + 1]->ref.org;
-
- if ( *a > *b )
- {
- *a = *b;
- FT_TRACE5(( "blue zone overlap:"
- " adjusting %s %td to %ld\n",
- a_is_top ? "overshoot" : "reference",
- blue_sorted[i] - axis->blues,
- *a ));
- }
- }
-
- FT_TRACE5(( "\n" ));
-
- return 0;
- }
- else
- {
- /* disable hinting for the current style if there are no blue zones */
-
- AF_FaceGlobals globals = metrics->root.globals;
- FT_UShort* gstyles = globals->glyph_styles;
-
- FT_UInt i;
-
-
- FT_TRACE5(( "no blue zones found:"
- " hinting disabled for this style\n" ));
-
- for ( i = 0; i < globals->glyph_count; i++ )
- {
- if ( ( gstyles[i] & AF_STYLE_MASK ) == sc->style )
- gstyles[i] = AF_STYLE_NONE_DFLT;
- }
-
- FT_TRACE5(( "\n" ));
-
- return 1;
- }
- }
-
-
- /* Check whether all ASCII digits have the same advance width. */
-
- FT_LOCAL_DEF( void )
- af_latin_metrics_check_digits( AF_LatinMetrics metrics,
- FT_Face face )
- {
- FT_Bool started = 0, same_width = 1;
- FT_Long advance = 0, old_advance = 0;
-
- /* If HarfBuzz is not available, we need a pointer to a single */
- /* unsigned long value. */
-#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
- void* shaper_buf;
-#else
- FT_ULong shaper_buf_;
- void* shaper_buf = &shaper_buf_;
-#endif
-
- /* in all supported charmaps, digits have character codes 0x30-0x39 */
- const char digits[] = "0 1 2 3 4 5 6 7 8 9";
- const char* p;
-
-
- p = digits;
-
-#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
- shaper_buf = af_shaper_buf_create( face );
-#endif
-
- while ( *p )
- {
- FT_ULong glyph_index;
- unsigned int num_idx;
-
-
- /* reject input that maps to more than a single glyph */
- p = af_shaper_get_cluster( p, &metrics->root, shaper_buf, &num_idx );
- if ( num_idx > 1 )
- continue;
-
- glyph_index = af_shaper_get_elem( &metrics->root,
- shaper_buf,
- 0,
- &advance,
- NULL );
- if ( !glyph_index )
- continue;
-
- if ( started )
- {
- if ( advance != old_advance )
- {
- same_width = 0;
- break;
- }
- }
- else
- {
- old_advance = advance;
- started = 1;
- }
- }
-
- af_shaper_buf_destroy( face, shaper_buf );
-
- metrics->root.digits_have_same_width = same_width;
- }
-
-
- /* Initialize global metrics. */
-
- FT_LOCAL_DEF( FT_Error )
- af_latin_metrics_init( AF_StyleMetrics metrics_, /* AF_LatinMetrics */
- FT_Face face )
- {
- AF_LatinMetrics metrics = (AF_LatinMetrics)metrics_;
-
- FT_Error error = FT_Err_Ok;
-
- FT_CharMap oldmap = face->charmap;
-
-
- metrics->units_per_em = face->units_per_EM;
-
- if ( !FT_Select_Charmap( face, FT_ENCODING_UNICODE ) )
- {
- af_latin_metrics_init_widths( metrics, face );
- if ( af_latin_metrics_init_blues( metrics, face ) )
- {
- /* use internal error code to indicate missing blue zones */
- error = -1;
- goto Exit;
- }
- af_latin_metrics_check_digits( metrics, face );
- }
-
- Exit:
- face->charmap = oldmap;
- return error;
- }
-
-
- /* Adjust scaling value, then scale and shift widths */
- /* and blue zones (if applicable) for given dimension. */
-
- static void
- af_latin_metrics_scale_dim( AF_LatinMetrics metrics,
- AF_Scaler scaler,
- AF_Dimension dim )
- {
- FT_Fixed scale;
- FT_Pos delta;
- AF_LatinAxis axis;
- FT_UInt nn;
-
-
- if ( dim == AF_DIMENSION_HORZ )
- {
- scale = scaler->x_scale;
- delta = scaler->x_delta;
- }
- else
- {
- scale = scaler->y_scale;
- delta = scaler->y_delta;
- }
-
- axis = &metrics->axis[dim];
-
- if ( axis->org_scale == scale && axis->org_delta == delta )
- return;
-
- axis->org_scale = scale;
- axis->org_delta = delta;
-
- /*
- * correct X and Y scale to optimize the alignment of the top of small
- * letters to the pixel grid
- */
- {
- AF_LatinAxis Axis = &metrics->axis[AF_DIMENSION_VERT];
- AF_LatinBlue blue = NULL;
-
-
- for ( nn = 0; nn < Axis->blue_count; nn++ )
- {
- if ( Axis->blues[nn].flags & AF_LATIN_BLUE_ADJUSTMENT )
- {
- blue = &Axis->blues[nn];
- break;
- }
- }
-
- if ( blue )
- {
- FT_Pos scaled;
- FT_Pos threshold;
- FT_Pos fitted;
- FT_UInt limit;
- FT_UInt ppem;
-
-
- scaled = FT_MulFix( blue->shoot.org, scale );
- ppem = metrics->root.scaler.face->size->metrics.x_ppem;
- limit = metrics->root.globals->increase_x_height;
- threshold = 40;
-
- /* if the `increase-x-height' property is active, */
- /* we round up much more often */
- if ( limit &&
- ppem <= limit &&
- ppem >= AF_PROP_INCREASE_X_HEIGHT_MIN )
- threshold = 52;
-
- fitted = ( scaled + threshold ) & ~63;
-
- if ( scaled != fitted )
- {
-#if 0
- if ( dim == AF_DIMENSION_HORZ )
- {
- if ( fitted < scaled )
- scale -= scale / 50; /* scale *= 0.98 */
- }
- else
-#endif
- if ( dim == AF_DIMENSION_VERT )
- {
- FT_Pos max_height;
- FT_Pos dist;
- FT_Fixed new_scale;
-
-
- new_scale = FT_MulDiv( scale, fitted, scaled );
-
- /* the scaling should not change the result by more than two pixels */
- max_height = metrics->units_per_em;
-
- for ( nn = 0; nn < Axis->blue_count; nn++ )
- {
- max_height = FT_MAX( max_height, Axis->blues[nn].ascender );
- max_height = FT_MAX( max_height, -Axis->blues[nn].descender );
- }
-
- dist = FT_MulFix( max_height, new_scale - scale );
-
- if ( -128 < dist && dist < 128 )
- {
- FT_TRACE5(( "af_latin_metrics_scale_dim:"
- " x height alignment (style `%s'):\n",
- af_style_names[metrics->root.style_class->style] ));
- FT_TRACE5(( " "
- " vertical scaling changed"
- " from %.5f to %.5f (by %ld%%)\n",
- (double)scale / 65536,
- (double)new_scale / 65536,
- ( fitted - scaled ) * 100 / scaled ));
- FT_TRACE5(( "\n" ));
-
- scale = new_scale;
- }
-#ifdef FT_DEBUG_LEVEL_TRACE
- else
- {
- FT_TRACE5(( "af_latin_metrics_scale_dim:"
- " x height alignment (style `%s'):\n",
- af_style_names[metrics->root.style_class->style] ));
- FT_TRACE5(( " "
- " excessive vertical scaling abandoned\n" ));
- FT_TRACE5(( "\n" ));
- }
-#endif
- }
- }
- }
- }
-
- axis->scale = scale;
- axis->delta = delta;
-
- if ( dim == AF_DIMENSION_HORZ )
- {
- metrics->root.scaler.x_scale = scale;
- metrics->root.scaler.x_delta = delta;
- }
- else
- {
- metrics->root.scaler.y_scale = scale;
- metrics->root.scaler.y_delta = delta;
- }
-
- FT_TRACE5(( "%s widths (style `%s')\n",
- dim == AF_DIMENSION_HORZ ? "horizontal" : "vertical",
- af_style_names[metrics->root.style_class->style] ));
-
- /* scale the widths */
- for ( nn = 0; nn < axis->width_count; nn++ )
- {
- AF_Width width = axis->widths + nn;
-
-
- width->cur = FT_MulFix( width->org, scale );
- width->fit = width->cur;
-
- FT_TRACE5(( " %ld scaled to %.2f\n",
- width->org,
- (double)width->cur / 64 ));
- }
-
- FT_TRACE5(( "\n" ));
-
- /* an extra-light axis corresponds to a standard width that is */
- /* smaller than 5/8 pixels */
- axis->extra_light =
- FT_BOOL( FT_MulFix( axis->standard_width, scale ) < 32 + 8 );
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( axis->extra_light )
- {
- FT_TRACE5(( "`%s' style is extra light (at current resolution)\n",
- af_style_names[metrics->root.style_class->style] ));
- FT_TRACE5(( "\n" ));
- }
-#endif
-
- if ( dim == AF_DIMENSION_VERT )
- {
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( axis->blue_count )
- FT_TRACE5(( "blue zones (style `%s')\n",
- af_style_names[metrics->root.style_class->style] ));
-#endif
-
- /* scale the blue zones */
- for ( nn = 0; nn < axis->blue_count; nn++ )
- {
- AF_LatinBlue blue = &axis->blues[nn];
- FT_Pos dist;
-
-
- blue->ref.cur = FT_MulFix( blue->ref.org, scale ) + delta;
- blue->ref.fit = blue->ref.cur;
- blue->shoot.cur = FT_MulFix( blue->shoot.org, scale ) + delta;
- blue->shoot.fit = blue->shoot.cur;
- blue->flags &= ~AF_LATIN_BLUE_ACTIVE;
-
- /* a blue zone is only active if it is less than 3/4 pixels tall */
- dist = FT_MulFix( blue->ref.org - blue->shoot.org, scale );
- if ( dist <= 48 && dist >= -48 )
- {
-#if 0
- FT_Pos delta1;
-#endif
- FT_Pos delta2;
-
-
- /* use discrete values for blue zone widths */
-
-#if 0
-
- /* generic, original code */
- delta1 = blue->shoot.org - blue->ref.org;
- delta2 = delta1;
- if ( delta1 < 0 )
- delta2 = -delta2;
-
- delta2 = FT_MulFix( delta2, scale );
-
- if ( delta2 < 32 )
- delta2 = 0;
- else if ( delta2 < 64 )
- delta2 = 32 + ( ( ( delta2 - 32 ) + 16 ) & ~31 );
- else
- delta2 = FT_PIX_ROUND( delta2 );
-
- if ( delta1 < 0 )
- delta2 = -delta2;
-
- blue->ref.fit = FT_PIX_ROUND( blue->ref.cur );
- blue->shoot.fit = blue->ref.fit + delta2;
-
-#else
-
- /* simplified version due to abs(dist) <= 48 */
- delta2 = dist;
- if ( dist < 0 )
- delta2 = -delta2;
-
- if ( delta2 < 32 )
- delta2 = 0;
- else if ( delta2 < 48 )
- delta2 = 32;
- else
- delta2 = 64;
-
- if ( dist < 0 )
- delta2 = -delta2;
-
- blue->ref.fit = FT_PIX_ROUND( blue->ref.cur );
- blue->shoot.fit = blue->ref.fit - delta2;
-
-#endif
-
- blue->flags |= AF_LATIN_BLUE_ACTIVE;
- }
- }
-
- /* use sub-top blue zone only if it doesn't overlap with */
- /* another (non-sup-top) blue zone; otherwise, the */
- /* effect would be similar to a neutral blue zone, which */
- /* is not desired here */
- for ( nn = 0; nn < axis->blue_count; nn++ )
- {
- AF_LatinBlue blue = &axis->blues[nn];
- FT_UInt i;
-
-
- if ( !( blue->flags & AF_LATIN_BLUE_SUB_TOP ) )
- continue;
- if ( !( blue->flags & AF_LATIN_BLUE_ACTIVE ) )
- continue;
-
- for ( i = 0; i < axis->blue_count; i++ )
- {
- AF_LatinBlue b = &axis->blues[i];
-
-
- if ( b->flags & AF_LATIN_BLUE_SUB_TOP )
- continue;
- if ( !( b->flags & AF_LATIN_BLUE_ACTIVE ) )
- continue;
-
- if ( b->ref.fit <= blue->shoot.fit &&
- b->shoot.fit >= blue->ref.fit )
- {
- blue->flags &= ~AF_LATIN_BLUE_ACTIVE;
- break;
- }
- }
- }
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- for ( nn = 0; nn < axis->blue_count; nn++ )
- {
- AF_LatinBlue blue = &axis->blues[nn];
-
-
- FT_TRACE5(( " reference %d: %ld scaled to %.2f%s\n",
- nn,
- blue->ref.org,
- (double)blue->ref.fit / 64,
- ( blue->flags & AF_LATIN_BLUE_ACTIVE ) ? ""
- : " (inactive)" ));
- FT_TRACE5(( " overshoot %d: %ld scaled to %.2f%s\n",
- nn,
- blue->shoot.org,
- (double)blue->shoot.fit / 64,
- ( blue->flags & AF_LATIN_BLUE_ACTIVE ) ? ""
- : " (inactive)" ));
- }
-#endif
- }
- }
-
-
- /* Scale global values in both directions. */
-
- FT_LOCAL_DEF( void )
- af_latin_metrics_scale( AF_StyleMetrics metrics_, /* AF_LatinMetrics */
- AF_Scaler scaler )
- {
- AF_LatinMetrics metrics = (AF_LatinMetrics)metrics_;
-
-
- metrics->root.scaler.render_mode = scaler->render_mode;
- metrics->root.scaler.face = scaler->face;
- metrics->root.scaler.flags = scaler->flags;
-
- af_latin_metrics_scale_dim( metrics, scaler, AF_DIMENSION_HORZ );
- af_latin_metrics_scale_dim( metrics, scaler, AF_DIMENSION_VERT );
- }
-
-
- /* Extract standard_width from writing system/script specific */
- /* metrics class. */
-
- FT_CALLBACK_DEF( void )
- af_latin_get_standard_widths( AF_StyleMetrics metrics_, /* AF_LatinMetrics */
- FT_Pos* stdHW,
- FT_Pos* stdVW )
- {
- AF_LatinMetrics metrics = (AF_LatinMetrics)metrics_;
-
-
- if ( stdHW )
- *stdHW = metrics->axis[AF_DIMENSION_VERT].standard_width;
-
- if ( stdVW )
- *stdVW = metrics->axis[AF_DIMENSION_HORZ].standard_width;
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** L A T I N G L Y P H A N A L Y S I S *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /* Walk over all contours and compute its segments. */
-
- FT_LOCAL_DEF( FT_Error )
- af_latin_hints_compute_segments( AF_GlyphHints hints,
- AF_Dimension dim )
- {
- AF_LatinMetrics metrics = (AF_LatinMetrics)hints->metrics;
- AF_AxisHints axis = &hints->axis[dim];
- FT_Memory memory = hints->memory;
- FT_Error error = FT_Err_Ok;
- AF_Segment segment = NULL;
- AF_SegmentRec seg0;
- AF_Point* contour = hints->contours;
- AF_Point* contour_limit = contour + hints->num_contours;
- AF_Direction major_dir, segment_dir;
-
- FT_Pos flat_threshold = FLAT_THRESHOLD( metrics->units_per_em );
-
-
- FT_ZERO( &seg0 );
- seg0.score = 32000;
- seg0.flags = AF_EDGE_NORMAL;
-
- major_dir = (AF_Direction)FT_ABS( axis->major_dir );
- segment_dir = major_dir;
-
- axis->num_segments = 0;
-
- /* set up (u,v) in each point */
- if ( dim == AF_DIMENSION_HORZ )
- {
- AF_Point point = hints->points;
- AF_Point limit = point + hints->num_points;
-
-
- for ( ; point < limit; point++ )
- {
- point->u = point->fx;
- point->v = point->fy;
- }
- }
- else
- {
- AF_Point point = hints->points;
- AF_Point limit = point + hints->num_points;
-
-
- for ( ; point < limit; point++ )
- {
- point->u = point->fy;
- point->v = point->fx;
- }
- }
-
- /* do each contour separately */
- for ( ; contour < contour_limit; contour++ )
- {
- AF_Point point = contour[0];
- AF_Point last = point->prev;
- int on_edge = 0;
-
- /* we call values measured along a segment (point->v) */
- /* `coordinates', and values orthogonal to it (point->u) */
- /* `positions' */
- FT_Pos min_pos = 32000;
- FT_Pos max_pos = -32000;
- FT_Pos min_coord = 32000;
- FT_Pos max_coord = -32000;
- FT_UShort min_flags = AF_FLAG_NONE;
- FT_UShort max_flags = AF_FLAG_NONE;
- FT_Pos min_on_coord = 32000;
- FT_Pos max_on_coord = -32000;
-
- FT_Bool passed;
-
- AF_Segment prev_segment = NULL;
-
- FT_Pos prev_min_pos = min_pos;
- FT_Pos prev_max_pos = max_pos;
- FT_Pos prev_min_coord = min_coord;
- FT_Pos prev_max_coord = max_coord;
- FT_UShort prev_min_flags = min_flags;
- FT_UShort prev_max_flags = max_flags;
- FT_Pos prev_min_on_coord = min_on_coord;
- FT_Pos prev_max_on_coord = max_on_coord;
-
-
- if ( FT_ABS( last->out_dir ) == major_dir &&
- FT_ABS( point->out_dir ) == major_dir )
- {
- /* we are already on an edge, try to locate its start */
- last = point;
-
- for (;;)
- {
- point = point->prev;
- if ( FT_ABS( point->out_dir ) != major_dir )
- {
- point = point->next;
- break;
- }
- if ( point == last )
- break;
- }
- }
-
- last = point;
- passed = 0;
-
- for (;;)
- {
- FT_Pos u, v;
-
-
- if ( on_edge )
- {
- /* get minimum and maximum position */
- u = point->u;
- if ( u < min_pos )
- min_pos = u;
- if ( u > max_pos )
- max_pos = u;
-
- /* get minimum and maximum coordinate together with flags */
- v = point->v;
- if ( v < min_coord )
- {
- min_coord = v;
- min_flags = point->flags;
- }
- if ( v > max_coord )
- {
- max_coord = v;
- max_flags = point->flags;
- }
-
- /* get minimum and maximum coordinate of `on' points */
- if ( !( point->flags & AF_FLAG_CONTROL ) )
- {
- v = point->v;
- if ( v < min_on_coord )
- min_on_coord = v;
- if ( v > max_on_coord )
- max_on_coord = v;
- }
-
- if ( point->out_dir != segment_dir || point == last )
- {
- /* check whether the new segment's start point is identical to */
- /* the previous segment's end point; for example, this might */
- /* happen for spikes */
-
- if ( !prev_segment || segment->first != prev_segment->last )
- {
- /* points are different: we are just leaving an edge, thus */
- /* record a new segment */
-
- segment->last = point;
- segment->pos = (FT_Short)( ( min_pos + max_pos ) >> 1 );
- segment->delta = (FT_Short)( ( max_pos - min_pos ) >> 1 );
-
- /* a segment is round if either its first or last point */
- /* is a control point, and the length of the on points */
- /* inbetween doesn't exceed a heuristic limit */
- if ( ( min_flags | max_flags ) & AF_FLAG_CONTROL &&
- ( max_on_coord - min_on_coord ) < flat_threshold )
- segment->flags |= AF_EDGE_ROUND;
-
- segment->min_coord = (FT_Short)min_coord;
- segment->max_coord = (FT_Short)max_coord;
- segment->height = segment->max_coord - segment->min_coord;
-
- prev_segment = segment;
- prev_min_pos = min_pos;
- prev_max_pos = max_pos;
- prev_min_coord = min_coord;
- prev_max_coord = max_coord;
- prev_min_flags = min_flags;
- prev_max_flags = max_flags;
- prev_min_on_coord = min_on_coord;
- prev_max_on_coord = max_on_coord;
- }
- else
- {
- /* points are the same: we don't create a new segment but */
- /* merge the current segment with the previous one */
-
- if ( prev_segment->last->in_dir == point->in_dir )
- {
- /* we have identical directions (this can happen for */
- /* degenerate outlines that move zig-zag along the main */
- /* axis without changing the coordinate value of the other */
- /* axis, and where the segments have just been merged): */
- /* unify segments */
-
- /* update constraints */
-
- if ( prev_min_pos < min_pos )
- min_pos = prev_min_pos;
- if ( prev_max_pos > max_pos )
- max_pos = prev_max_pos;
-
- if ( prev_min_coord < min_coord )
- {
- min_coord = prev_min_coord;
- min_flags = prev_min_flags;
- }
- if ( prev_max_coord > max_coord )
- {
- max_coord = prev_max_coord;
- max_flags = prev_max_flags;
- }
-
- if ( prev_min_on_coord < min_on_coord )
- min_on_coord = prev_min_on_coord;
- if ( prev_max_on_coord > max_on_coord )
- max_on_coord = prev_max_on_coord;
-
- prev_segment->last = point;
- prev_segment->pos = (FT_Short)( ( min_pos +
- max_pos ) >> 1 );
- prev_segment->delta = (FT_Short)( ( max_pos -
- min_pos ) >> 1 );
-
- if ( ( min_flags | max_flags ) & AF_FLAG_CONTROL &&
- ( max_on_coord - min_on_coord ) < flat_threshold )
- prev_segment->flags |= AF_EDGE_ROUND;
- else
- prev_segment->flags &= ~AF_EDGE_ROUND;
-
- prev_segment->min_coord = (FT_Short)min_coord;
- prev_segment->max_coord = (FT_Short)max_coord;
- prev_segment->height = prev_segment->max_coord -
- prev_segment->min_coord;
- }
- else
- {
- /* we have different directions; use the properties of the */
- /* longer segment and discard the other one */
-
- if ( FT_ABS( prev_max_coord - prev_min_coord ) >
- FT_ABS( max_coord - min_coord ) )
- {
- /* discard current segment */
-
- if ( min_pos < prev_min_pos )
- prev_min_pos = min_pos;
- if ( max_pos > prev_max_pos )
- prev_max_pos = max_pos;
-
- prev_segment->last = point;
- prev_segment->pos = (FT_Short)( ( prev_min_pos +
- prev_max_pos ) >> 1 );
- prev_segment->delta = (FT_Short)( ( prev_max_pos -
- prev_min_pos ) >> 1 );
- }
- else
- {
- /* discard previous segment */
-
- if ( prev_min_pos < min_pos )
- min_pos = prev_min_pos;
- if ( prev_max_pos > max_pos )
- max_pos = prev_max_pos;
-
- segment->last = point;
- segment->pos = (FT_Short)( ( min_pos + max_pos ) >> 1 );
- segment->delta = (FT_Short)( ( max_pos - min_pos ) >> 1 );
-
- if ( ( min_flags | max_flags ) & AF_FLAG_CONTROL &&
- ( max_on_coord - min_on_coord ) < flat_threshold )
- segment->flags |= AF_EDGE_ROUND;
-
- segment->min_coord = (FT_Short)min_coord;
- segment->max_coord = (FT_Short)max_coord;
- segment->height = segment->max_coord -
- segment->min_coord;
-
- *prev_segment = *segment;
-
- prev_min_pos = min_pos;
- prev_max_pos = max_pos;
- prev_min_coord = min_coord;
- prev_max_coord = max_coord;
- prev_min_flags = min_flags;
- prev_max_flags = max_flags;
- prev_min_on_coord = min_on_coord;
- prev_max_on_coord = max_on_coord;
- }
- }
-
- axis->num_segments--;
- }
-
- on_edge = 0;
- segment = NULL;
-
- /* fall through */
- }
- }
-
- /* now exit if we are at the start/end point */
- if ( point == last )
- {
- if ( passed )
- break;
- passed = 1;
- }
-
- /* if we are not on an edge, check whether the major direction */
- /* coincides with the current point's `out' direction, or */
- /* whether we have a single-point contour */
- if ( !on_edge &&
- ( FT_ABS( point->out_dir ) == major_dir ||
- point == point->prev ) )
- {
- /*
- * For efficiency, we restrict the number of segments to 1000,
- * which is a heuristic value: it is very unlikely that a glyph
- * with so many segments can be hinted in a sensible way.
- * Reasons:
- *
- * - The glyph has really 1000 segments; this implies that it has
- * at least 2000 outline points. Assuming 'normal' fonts that
- * have superfluous points optimized away, viewing such a glyph
- * only makes sense at large magnifications where hinting
- * isn't applied anyway.
- *
- * - We have a broken glyph. Hinting doesn't make sense in this
- * case either.
- */
- if ( axis->num_segments > 1000 )
- {
- FT_TRACE0(( "af_latin_hints_compute_segments:"
- " more than 1000 segments in this glyph;\n" ));
- FT_TRACE0(( " "
- " hinting is suppressed\n" ));
- axis->num_segments = 0;
- return FT_Err_Ok;
- }
-
- /* this is the start of a new segment! */
- segment_dir = (AF_Direction)point->out_dir;
-
- error = af_axis_hints_new_segment( axis, memory, &segment );
- if ( error )
- goto Exit;
-
- /* clear all segment fields */
- segment[0] = seg0;
-
- segment->dir = (FT_Char)segment_dir;
- segment->first = point;
- segment->last = point;
-
- /* `af_axis_hints_new_segment' reallocates memory, */
- /* thus we have to refresh the `prev_segment' pointer */
- if ( prev_segment )
- prev_segment = segment - 1;
-
- min_pos = max_pos = point->u;
- min_coord = max_coord = point->v;
- min_flags = max_flags = point->flags;
-
- if ( point->flags & AF_FLAG_CONTROL )
- {
- min_on_coord = 32000;
- max_on_coord = -32000;
- }
- else
- min_on_coord = max_on_coord = point->v;
-
- on_edge = 1;
-
- if ( point == point->prev )
- {
- /* we have a one-point segment: this is a one-point */
- /* contour with `in' and `out' direction set to */
- /* AF_DIR_NONE */
- segment->pos = (FT_Short)min_pos;
-
- if (point->flags & AF_FLAG_CONTROL)
- segment->flags |= AF_EDGE_ROUND;
-
- segment->min_coord = (FT_Short)point->v;
- segment->max_coord = (FT_Short)point->v;
- segment->height = 0;
-
- on_edge = 0;
- segment = NULL;
- }
- }
-
- point = point->next;
- }
-
- } /* contours */
-
-
- /* now slightly increase the height of segments if this makes */
- /* sense -- this is used to better detect and ignore serifs */
- {
- AF_Segment segments = axis->segments;
- AF_Segment segments_end = FT_OFFSET( segments, axis->num_segments );
-
-
- for ( segment = segments; segment < segments_end; segment++ )
- {
- AF_Point first = segment->first;
- AF_Point last = segment->last;
- FT_Pos first_v = first->v;
- FT_Pos last_v = last->v;
-
-
- if ( first_v < last_v )
- {
- AF_Point p;
-
-
- p = first->prev;
- if ( p->v < first_v )
- segment->height = (FT_Short)( segment->height +
- ( ( first_v - p->v ) >> 1 ) );
-
- p = last->next;
- if ( p->v > last_v )
- segment->height = (FT_Short)( segment->height +
- ( ( p->v - last_v ) >> 1 ) );
- }
- else
- {
- AF_Point p;
-
-
- p = first->prev;
- if ( p->v > first_v )
- segment->height = (FT_Short)( segment->height +
- ( ( p->v - first_v ) >> 1 ) );
-
- p = last->next;
- if ( p->v < last_v )
- segment->height = (FT_Short)( segment->height +
- ( ( last_v - p->v ) >> 1 ) );
- }
- }
- }
-
- Exit:
- return error;
- }
-
-
- /* Link segments to form stems and serifs. If `width_count' and */
- /* `widths' are non-zero, use them to fine-tune the scoring function. */
-
- FT_LOCAL_DEF( void )
- af_latin_hints_link_segments( AF_GlyphHints hints,
- FT_UInt width_count,
- AF_WidthRec* widths,
- AF_Dimension dim )
- {
- AF_AxisHints axis = &hints->axis[dim];
- AF_Segment segments = axis->segments;
- AF_Segment segment_limit = FT_OFFSET( segments, axis->num_segments );
- FT_Pos len_threshold, len_score, dist_score, max_width;
- AF_Segment seg1, seg2;
-
-
- if ( width_count )
- max_width = widths[width_count - 1].org;
- else
- max_width = 0;
-
- /* a heuristic value to set up a minimum value for overlapping */
- len_threshold = AF_LATIN_CONSTANT( hints->metrics, 8 );
- if ( len_threshold == 0 )
- len_threshold = 1;
-
- /* a heuristic value to weight lengths */
- len_score = AF_LATIN_CONSTANT( hints->metrics, 6000 );
-
- /* a heuristic value to weight distances (no call to */
- /* AF_LATIN_CONSTANT needed, since we work on multiples */
- /* of the stem width) */
- dist_score = 3000;
-
- /* now compare each segment to the others */
- for ( seg1 = segments; seg1 < segment_limit; seg1++ )
- {
- if ( seg1->dir != axis->major_dir )
- continue;
-
- /* search for stems having opposite directions, */
- /* with seg1 to the `left' of seg2 */
- for ( seg2 = segments; seg2 < segment_limit; seg2++ )
- {
- FT_Pos pos1 = seg1->pos;
- FT_Pos pos2 = seg2->pos;
-
-
- if ( seg1->dir + seg2->dir == 0 && pos2 > pos1 )
- {
- /* compute distance between the two segments */
- FT_Pos min = seg1->min_coord;
- FT_Pos max = seg1->max_coord;
- FT_Pos len;
-
-
- if ( min < seg2->min_coord )
- min = seg2->min_coord;
-
- if ( max > seg2->max_coord )
- max = seg2->max_coord;
-
- /* compute maximum coordinate difference of the two segments */
- /* (that is, how much they overlap) */
- len = max - min;
- if ( len >= len_threshold )
- {
- /*
- * The score is the sum of two demerits indicating the
- * `badness' of a fit, measured along the segments' main axis
- * and orthogonal to it, respectively.
- *
- * - The less overlapping along the main axis, the worse it
- * is, causing a larger demerit.
- *
- * - The nearer the orthogonal distance to a stem width, the
- * better it is, causing a smaller demerit. For simplicity,
- * however, we only increase the demerit for values that
- * exceed the largest stem width.
- */
-
- FT_Pos dist = pos2 - pos1;
-
- FT_Pos dist_demerit, score;
-
-
- if ( max_width )
- {
- /* distance demerits are based on multiples of `max_width'; */
- /* we scale by 1024 for getting more precision */
- FT_Pos delta = ( dist << 10 ) / max_width - ( 1 << 10 );
-
-
- if ( delta > 10000 )
- dist_demerit = 32000;
- else if ( delta > 0 )
- dist_demerit = delta * delta / dist_score;
- else
- dist_demerit = 0;
- }
- else
- dist_demerit = dist; /* default if no widths available */
-
- score = dist_demerit + len_score / len;
-
- /* and we search for the smallest score */
- if ( score < seg1->score )
- {
- seg1->score = score;
- seg1->link = seg2;
- }
-
- if ( score < seg2->score )
- {
- seg2->score = score;
- seg2->link = seg1;
- }
- }
- }
- }
- }
-
- /* now compute the `serif' segments, cf. explanations in `afhints.h' */
- for ( seg1 = segments; seg1 < segment_limit; seg1++ )
- {
- seg2 = seg1->link;
-
- if ( seg2 )
- {
- if ( seg2->link != seg1 )
- {
- seg1->link = NULL;
- seg1->serif = seg2->link;
- }
- }
- }
- }
-
-
- /* Link segments to edges, using feature analysis for selection. */
-
- FT_LOCAL_DEF( FT_Error )
- af_latin_hints_compute_edges( AF_GlyphHints hints,
- AF_Dimension dim )
- {
- AF_AxisHints axis = &hints->axis[dim];
- FT_Error error = FT_Err_Ok;
- FT_Memory memory = hints->memory;
- AF_LatinAxis laxis = &((AF_LatinMetrics)hints->metrics)->axis[dim];
-
- AF_StyleClass style_class = hints->metrics->style_class;
- AF_ScriptClass script_class = af_script_classes[style_class->script];
-
- FT_Bool top_to_bottom_hinting = 0;
-
- AF_Segment segments = axis->segments;
- AF_Segment segment_limit = FT_OFFSET( segments, axis->num_segments );
- AF_Segment seg;
-
-#if 0
- AF_Direction up_dir;
-#endif
- FT_Fixed scale;
- FT_Pos edge_distance_threshold;
- FT_Pos segment_length_threshold;
- FT_Pos segment_width_threshold;
-
-
- axis->num_edges = 0;
-
- scale = ( dim == AF_DIMENSION_HORZ ) ? hints->x_scale
- : hints->y_scale;
-
-#if 0
- up_dir = ( dim == AF_DIMENSION_HORZ ) ? AF_DIR_UP
- : AF_DIR_RIGHT;
-#endif
-
- if ( dim == AF_DIMENSION_VERT )
- top_to_bottom_hinting = script_class->top_to_bottom_hinting;
-
- /*
- * We ignore all segments that are less than 1 pixel in length
- * to avoid many problems with serif fonts. We compute the
- * corresponding threshold in font units.
- */
- if ( dim == AF_DIMENSION_HORZ )
- segment_length_threshold = FT_DivFix( 64, hints->y_scale );
- else
- segment_length_threshold = 0;
-
- /*
- * Similarly, we ignore segments that have a width delta
- * larger than 0.5px (i.e., a width larger than 1px).
- */
- segment_width_threshold = FT_DivFix( 32, scale );
-
- /**********************************************************************
- *
- * We begin by generating a sorted table of edges for the current
- * direction. To do so, we simply scan each segment and try to find
- * an edge in our table that corresponds to its position.
- *
- * If no edge is found, we create and insert a new edge in the
- * sorted table. Otherwise, we simply add the segment to the edge's
- * list which gets processed in the second step to compute the
- * edge's properties.
- *
- * Note that the table of edges is sorted along the segment/edge
- * position.
- *
- */
-
- /* assure that edge distance threshold is at most 0.25px */
- edge_distance_threshold = FT_MulFix( laxis->edge_distance_threshold,
- scale );
- if ( edge_distance_threshold > 64 / 4 )
- edge_distance_threshold = 64 / 4;
-
- edge_distance_threshold = FT_DivFix( edge_distance_threshold,
- scale );
-
- for ( seg = segments; seg < segment_limit; seg++ )
- {
- AF_Edge found = NULL;
- FT_UInt ee;
-
-
- /* ignore too short segments, too wide ones, and, in this loop, */
- /* one-point segments without a direction */
- if ( seg->height < segment_length_threshold ||
- seg->delta > segment_width_threshold ||
- seg->dir == AF_DIR_NONE )
- continue;
-
- /* A special case for serif edges: If they are smaller than */
- /* 1.5 pixels we ignore them. */
- if ( seg->serif &&
- 2 * seg->height < 3 * segment_length_threshold )
- continue;
-
- /* look for an edge corresponding to the segment */
- for ( ee = 0; ee < axis->num_edges; ee++ )
- {
- AF_Edge edge = axis->edges + ee;
- FT_Pos dist;
-
-
- dist = seg->pos - edge->fpos;
- if ( dist < 0 )
- dist = -dist;
-
- if ( dist < edge_distance_threshold && edge->dir == seg->dir )
- {
- found = edge;
- break;
- }
- }
-
- if ( !found )
- {
- AF_Edge edge;
-
-
- /* insert a new edge in the list and */
- /* sort according to the position */
- error = af_axis_hints_new_edge( axis, seg->pos,
- (AF_Direction)seg->dir,
- top_to_bottom_hinting,
- memory, &edge );
- if ( error )
- goto Exit;
-
- /* add the segment to the new edge's list */
- FT_ZERO( edge );
-
- edge->first = seg;
- edge->last = seg;
- edge->dir = seg->dir;
- edge->fpos = seg->pos;
- edge->opos = FT_MulFix( seg->pos, scale );
- edge->pos = edge->opos;
- seg->edge_next = seg;
- }
- else
- {
- /* if an edge was found, simply add the segment to the edge's */
- /* list */
- seg->edge_next = found->first;
- found->last->edge_next = seg;
- found->last = seg;
- }
- }
-
- /* we loop again over all segments to catch one-point segments */
- /* without a direction: if possible, link them to existing edges */
- for ( seg = segments; seg < segment_limit; seg++ )
- {
- AF_Edge found = NULL;
- FT_UInt ee;
-
-
- if ( seg->dir != AF_DIR_NONE )
- continue;
-
- /* look for an edge corresponding to the segment */
- for ( ee = 0; ee < axis->num_edges; ee++ )
- {
- AF_Edge edge = axis->edges + ee;
- FT_Pos dist;
-
-
- dist = seg->pos - edge->fpos;
- if ( dist < 0 )
- dist = -dist;
-
- if ( dist < edge_distance_threshold )
- {
- found = edge;
- break;
- }
- }
-
- /* one-point segments without a match are ignored */
- if ( found )
- {
- seg->edge_next = found->first;
- found->last->edge_next = seg;
- found->last = seg;
- }
- }
-
-
- /*******************************************************************
- *
- * Good, we now compute each edge's properties according to the
- * segments found on its position. Basically, these are
- *
- * - the edge's main direction
- * - stem edge, serif edge or both (which defaults to stem then)
- * - rounded edge, straight or both (which defaults to straight)
- * - link for edge
- *
- */
-
- /* first of all, set the `edge' field in each segment -- this is */
- /* required in order to compute edge links */
-
- /*
- * Note that removing this loop and setting the `edge' field of each
- * segment directly in the code above slows down execution speed for
- * some reasons on platforms like the Sun.
- */
- {
- AF_Edge edges = axis->edges;
- AF_Edge edge_limit = FT_OFFSET( edges, axis->num_edges );
- AF_Edge edge;
-
-
- for ( edge = edges; edge < edge_limit; edge++ )
- {
- seg = edge->first;
- if ( seg )
- do
- {
- seg->edge = edge;
- seg = seg->edge_next;
-
- } while ( seg != edge->first );
- }
-
- /* now compute each edge properties */
- for ( edge = edges; edge < edge_limit; edge++ )
- {
- FT_Int is_round = 0; /* does it contain round segments? */
- FT_Int is_straight = 0; /* does it contain straight segments? */
-#if 0
- FT_Pos ups = 0; /* number of upwards segments */
- FT_Pos downs = 0; /* number of downwards segments */
-#endif
-
-
- seg = edge->first;
-
- do
- {
- FT_Bool is_serif;
-
-
- /* check for roundness of segment */
- if ( seg->flags & AF_EDGE_ROUND )
- is_round++;
- else
- is_straight++;
-
-#if 0
- /* check for segment direction */
- if ( seg->dir == up_dir )
- ups += seg->max_coord - seg->min_coord;
- else
- downs += seg->max_coord - seg->min_coord;
-#endif
-
- /* check for links -- if seg->serif is set, then seg->link must */
- /* be ignored */
- is_serif = FT_BOOL( seg->serif &&
- seg->serif->edge &&
- seg->serif->edge != edge );
-
- if ( ( seg->link && seg->link->edge ) || is_serif )
- {
- AF_Edge edge2;
- AF_Segment seg2;
-
-
- edge2 = edge->link;
- seg2 = seg->link;
-
- if ( is_serif )
- {
- seg2 = seg->serif;
- edge2 = edge->serif;
- }
-
- if ( edge2 )
- {
- FT_Pos edge_delta;
- FT_Pos seg_delta;
-
-
- edge_delta = edge->fpos - edge2->fpos;
- if ( edge_delta < 0 )
- edge_delta = -edge_delta;
-
- seg_delta = seg->pos - seg2->pos;
- if ( seg_delta < 0 )
- seg_delta = -seg_delta;
-
- if ( seg_delta < edge_delta )
- edge2 = seg2->edge;
- }
- else
- edge2 = seg2->edge;
-
- if ( is_serif )
- {
- edge->serif = edge2;
- edge2->flags |= AF_EDGE_SERIF;
- }
- else
- edge->link = edge2;
- }
-
- seg = seg->edge_next;
-
- } while ( seg != edge->first );
-
- /* set the round/straight flags */
- edge->flags = AF_EDGE_NORMAL;
-
- if ( is_round > 0 && is_round >= is_straight )
- edge->flags |= AF_EDGE_ROUND;
-
-#if 0
- /* set the edge's main direction */
- edge->dir = AF_DIR_NONE;
-
- if ( ups > downs )
- edge->dir = (FT_Char)up_dir;
-
- else if ( ups < downs )
- edge->dir = (FT_Char)-up_dir;
-
- else if ( ups == downs )
- edge->dir = 0; /* both up and down! */
-#endif
-
- /* get rid of serifs if link is set */
- /* XXX: This gets rid of many unpleasant artefacts! */
- /* Example: the `c' in cour.pfa at size 13 */
-
- if ( edge->serif && edge->link )
- edge->serif = NULL;
- }
- }
-
- Exit:
- return error;
- }
-
-
- /* Detect segments and edges for given dimension. */
-
- FT_LOCAL_DEF( FT_Error )
- af_latin_hints_detect_features( AF_GlyphHints hints,
- FT_UInt width_count,
- AF_WidthRec* widths,
- AF_Dimension dim )
- {
- FT_Error error;
-
-
- error = af_latin_hints_compute_segments( hints, dim );
- if ( !error )
- {
- af_latin_hints_link_segments( hints, width_count, widths, dim );
-
- error = af_latin_hints_compute_edges( hints, dim );
- }
-
- return error;
- }
-
-
- /* Compute all edges which lie within blue zones. */
-
- static void
- af_latin_hints_compute_blue_edges( AF_GlyphHints hints,
- AF_LatinMetrics metrics )
- {
- AF_AxisHints axis = &hints->axis[AF_DIMENSION_VERT];
- AF_Edge edge = axis->edges;
- AF_Edge edge_limit = FT_OFFSET( edge, axis->num_edges );
- AF_LatinAxis latin = &metrics->axis[AF_DIMENSION_VERT];
- FT_Fixed scale = latin->scale;
-
-
- /* compute which blue zones are active, i.e. have their scaled */
- /* size < 3/4 pixels */
-
- /* for each horizontal edge search the blue zone which is closest */
- for ( ; edge < edge_limit; edge++ )
- {
- FT_UInt bb;
- AF_Width best_blue = NULL;
- FT_Bool best_blue_is_neutral = 0;
- FT_Pos best_dist; /* initial threshold */
-
-
- /* compute the initial threshold as a fraction of the EM size */
- /* (the value 40 is heuristic) */
- best_dist = FT_MulFix( metrics->units_per_em / 40, scale );
-
- /* assure a minimum distance of 0.5px */
- if ( best_dist > 64 / 2 )
- best_dist = 64 / 2;
-
- for ( bb = 0; bb < latin->blue_count; bb++ )
- {
- AF_LatinBlue blue = latin->blues + bb;
- FT_Bool is_top_blue, is_neutral_blue, is_major_dir;
-
-
- /* skip inactive blue zones (i.e., those that are too large) */
- if ( !( blue->flags & AF_LATIN_BLUE_ACTIVE ) )
- continue;
-
- /* if it is a top zone, check for right edges (against the major */
- /* direction); if it is a bottom zone, check for left edges (in */
- /* the major direction) -- this assumes the TrueType convention */
- /* for the orientation of contours */
- is_top_blue =
- (FT_Byte)( ( blue->flags & ( AF_LATIN_BLUE_TOP |
- AF_LATIN_BLUE_SUB_TOP ) ) != 0 );
- is_neutral_blue =
- (FT_Byte)( ( blue->flags & AF_LATIN_BLUE_NEUTRAL ) != 0);
- is_major_dir =
- FT_BOOL( edge->dir == axis->major_dir );
-
- /* neutral blue zones are handled for both directions */
- if ( is_top_blue ^ is_major_dir || is_neutral_blue )
- {
- FT_Pos dist;
-
-
- /* first of all, compare it to the reference position */
- dist = edge->fpos - blue->ref.org;
- if ( dist < 0 )
- dist = -dist;
-
- dist = FT_MulFix( dist, scale );
- if ( dist < best_dist )
- {
- best_dist = dist;
- best_blue = &blue->ref;
- best_blue_is_neutral = is_neutral_blue;
- }
-
- /* now compare it to the overshoot position and check whether */
- /* the edge is rounded, and whether the edge is over the */
- /* reference position of a top zone, or under the reference */
- /* position of a bottom zone (provided we don't have a */
- /* neutral blue zone) */
- if ( edge->flags & AF_EDGE_ROUND &&
- dist != 0 &&
- !is_neutral_blue )
- {
- FT_Bool is_under_ref = FT_BOOL( edge->fpos < blue->ref.org );
-
-
- if ( is_top_blue ^ is_under_ref )
- {
- dist = edge->fpos - blue->shoot.org;
- if ( dist < 0 )
- dist = -dist;
-
- dist = FT_MulFix( dist, scale );
- if ( dist < best_dist )
- {
- best_dist = dist;
- best_blue = &blue->shoot;
- best_blue_is_neutral = is_neutral_blue;
- }
- }
- }
- }
- }
-
- if ( best_blue )
- {
- edge->blue_edge = best_blue;
- if ( best_blue_is_neutral )
- edge->flags |= AF_EDGE_NEUTRAL;
- }
- }
- }
-
-
- /* Initalize hinting engine. */
-
- static FT_Error
- af_latin_hints_init( AF_GlyphHints hints,
- AF_StyleMetrics metrics_ ) /* AF_LatinMetrics */
- {
- AF_LatinMetrics metrics = (AF_LatinMetrics)metrics_;
-
- FT_Render_Mode mode;
- FT_UInt32 scaler_flags, other_flags;
- FT_Face face = metrics->root.scaler.face;
-
-
- af_glyph_hints_rescale( hints, (AF_StyleMetrics)metrics );
-
- /*
- * correct x_scale and y_scale if needed, since they may have
- * been modified by `af_latin_metrics_scale_dim' above
- */
- hints->x_scale = metrics->axis[AF_DIMENSION_HORZ].scale;
- hints->x_delta = metrics->axis[AF_DIMENSION_HORZ].delta;
- hints->y_scale = metrics->axis[AF_DIMENSION_VERT].scale;
- hints->y_delta = metrics->axis[AF_DIMENSION_VERT].delta;
-
- /* compute flags depending on render mode, etc. */
- mode = metrics->root.scaler.render_mode;
-
- scaler_flags = hints->scaler_flags;
- other_flags = 0;
-
- /*
- * We snap the width of vertical stems for the monochrome and
- * horizontal LCD rendering targets only.
- */
- if ( mode == FT_RENDER_MODE_MONO || mode == FT_RENDER_MODE_LCD )
- other_flags |= AF_LATIN_HINTS_HORZ_SNAP;
-
- /*
- * We snap the width of horizontal stems for the monochrome and
- * vertical LCD rendering targets only.
- */
- if ( mode == FT_RENDER_MODE_MONO || mode == FT_RENDER_MODE_LCD_V )
- other_flags |= AF_LATIN_HINTS_VERT_SNAP;
-
- /*
- * We adjust stems to full pixels unless in `light' or `lcd' mode.
- */
- if ( mode != FT_RENDER_MODE_LIGHT && mode != FT_RENDER_MODE_LCD )
- other_flags |= AF_LATIN_HINTS_STEM_ADJUST;
-
- if ( mode == FT_RENDER_MODE_MONO )
- other_flags |= AF_LATIN_HINTS_MONO;
-
- /*
- * In `light' or `lcd' mode we disable horizontal hinting completely.
- * We also do it if the face is italic.
- *
- * However, if warping is enabled (which only works in `light' hinting
- * mode), advance widths get adjusted, too.
- */
- if ( mode == FT_RENDER_MODE_LIGHT || mode == FT_RENDER_MODE_LCD ||
- ( face->style_flags & FT_STYLE_FLAG_ITALIC ) != 0 )
- scaler_flags |= AF_SCALER_FLAG_NO_HORIZONTAL;
-
- hints->scaler_flags = scaler_flags;
- hints->other_flags = other_flags;
-
- return FT_Err_Ok;
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** L A T I N G L Y P H G R I D - F I T T I N G *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- /* Snap a given width in scaled coordinates to one of the */
- /* current standard widths. */
-
- static FT_Pos
- af_latin_snap_width( AF_Width widths,
- FT_UInt count,
- FT_Pos width )
- {
- FT_UInt n;
- FT_Pos best = 64 + 32 + 2;
- FT_Pos reference = width;
- FT_Pos scaled;
-
-
- for ( n = 0; n < count; n++ )
- {
- FT_Pos w;
- FT_Pos dist;
-
-
- w = widths[n].cur;
- dist = width - w;
- if ( dist < 0 )
- dist = -dist;
- if ( dist < best )
- {
- best = dist;
- reference = w;
- }
- }
-
- scaled = FT_PIX_ROUND( reference );
-
- if ( width >= reference )
- {
- if ( width < scaled + 48 )
- width = reference;
- }
- else
- {
- if ( width > scaled - 48 )
- width = reference;
- }
-
- return width;
- }
-
-
- /* Compute the snapped width of a given stem, ignoring very thin ones. */
- /* There is a lot of voodoo in this function; changing the hard-coded */
- /* parameters influence the whole hinting process. */
-
- static FT_Pos
- af_latin_compute_stem_width( AF_GlyphHints hints,
- AF_Dimension dim,
- FT_Pos width,
- FT_Pos base_delta,
- FT_UInt base_flags,
- FT_UInt stem_flags )
- {
- AF_LatinMetrics metrics = (AF_LatinMetrics)hints->metrics;
- AF_LatinAxis axis = &metrics->axis[dim];
- FT_Pos dist = width;
- FT_Int sign = 0;
- FT_Int vertical = ( dim == AF_DIMENSION_VERT );
-
-
- if ( !AF_LATIN_HINTS_DO_STEM_ADJUST( hints ) ||
- axis->extra_light )
- return width;
-
- if ( dist < 0 )
- {
- dist = -width;
- sign = 1;
- }
-
- if ( ( vertical && !AF_LATIN_HINTS_DO_VERT_SNAP( hints ) ) ||
- ( !vertical && !AF_LATIN_HINTS_DO_HORZ_SNAP( hints ) ) )
- {
- /* smooth hinting process: very lightly quantize the stem width */
-
- /* leave the widths of serifs alone */
- if ( ( stem_flags & AF_EDGE_SERIF ) &&
- vertical &&
- ( dist < 3 * 64 ) )
- goto Done_Width;
-
- else if ( base_flags & AF_EDGE_ROUND )
- {
- if ( dist < 80 )
- dist = 64;
- }
- else if ( dist < 56 )
- dist = 56;
-
- if ( axis->width_count > 0 )
- {
- FT_Pos delta;
-
-
- /* compare to standard width */
- delta = dist - axis->widths[0].cur;
-
- if ( delta < 0 )
- delta = -delta;
-
- if ( delta < 40 )
- {
- dist = axis->widths[0].cur;
- if ( dist < 48 )
- dist = 48;
-
- goto Done_Width;
- }
-
- if ( dist < 3 * 64 )
- {
- delta = dist & 63;
- dist &= -64;
-
- if ( delta < 10 )
- dist += delta;
-
- else if ( delta < 32 )
- dist += 10;
-
- else if ( delta < 54 )
- dist += 54;
-
- else
- dist += delta;
- }
- else
- {
- /* A stem's end position depends on two values: the start */
- /* position and the stem length. The former gets usually */
- /* rounded to the grid, while the latter gets rounded also if it */
- /* exceeds a certain length (see below in this function). This */
- /* `double rounding' can lead to a great difference to the */
- /* original, unhinted position; this normally doesn't matter for */
- /* large PPEM values, but for small sizes it can easily make */
- /* outlines collide. For this reason, we adjust the stem length */
- /* by a small amount depending on the PPEM value in case the */
- /* former and latter rounding both point into the same */
- /* direction. */
-
- FT_Pos bdelta = 0;
-
-
- if ( ( ( width > 0 ) && ( base_delta > 0 ) ) ||
- ( ( width < 0 ) && ( base_delta < 0 ) ) )
- {
- FT_UInt ppem = metrics->root.scaler.face->size->metrics.x_ppem;
-
-
- if ( ppem < 10 )
- bdelta = base_delta;
- else if ( ppem < 30 )
- bdelta = ( base_delta * (FT_Pos)( 30 - ppem ) ) / 20;
-
- if ( bdelta < 0 )
- bdelta = -bdelta;
- }
-
- dist = ( dist - bdelta + 32 ) & ~63;
- }
- }
- }
- else
- {
- /* strong hinting process: snap the stem width to integer pixels */
-
- FT_Pos org_dist = dist;
-
-
- dist = af_latin_snap_width( axis->widths, axis->width_count, dist );
-
- if ( vertical )
- {
- /* in the case of vertical hinting, always round */
- /* the stem heights to integer pixels */
-
- if ( dist >= 64 )
- dist = ( dist + 16 ) & ~63;
- else
- dist = 64;
- }
- else
- {
- if ( AF_LATIN_HINTS_DO_MONO( hints ) )
- {
- /* monochrome horizontal hinting: snap widths to integer pixels */
- /* with a different threshold */
-
- if ( dist < 64 )
- dist = 64;
- else
- dist = ( dist + 32 ) & ~63;
- }
- else
- {
- /* for horizontal anti-aliased hinting, we adopt a more subtle */
- /* approach: we strengthen small stems, round stems whose size */
- /* is between 1 and 2 pixels to an integer, otherwise nothing */
-
- if ( dist < 48 )
- dist = ( dist + 64 ) >> 1;
-
- else if ( dist < 128 )
- {
- /* We only round to an integer width if the corresponding */
- /* distortion is less than 1/4 pixel. Otherwise this */
- /* makes everything worse since the diagonals, which are */
- /* not hinted, appear a lot bolder or thinner than the */
- /* vertical stems. */
-
- FT_Pos delta;
-
-
- dist = ( dist + 22 ) & ~63;
- delta = dist - org_dist;
- if ( delta < 0 )
- delta = -delta;
-
- if ( delta >= 16 )
- {
- dist = org_dist;
- if ( dist < 48 )
- dist = ( dist + 64 ) >> 1;
- }
- }
- else
- /* round otherwise to prevent color fringes in LCD mode */
- dist = ( dist + 32 ) & ~63;
- }
- }
- }
-
- Done_Width:
- if ( sign )
- dist = -dist;
-
- return dist;
- }
-
-
- /* Align one stem edge relative to the previous stem edge. */
-
- static void
- af_latin_align_linked_edge( AF_GlyphHints hints,
- AF_Dimension dim,
- AF_Edge base_edge,
- AF_Edge stem_edge )
- {
- FT_Pos dist, base_delta;
- FT_Pos fitted_width;
-
-
- dist = stem_edge->opos - base_edge->opos;
- base_delta = base_edge->pos - base_edge->opos;
-
- fitted_width = af_latin_compute_stem_width( hints, dim,
- dist, base_delta,
- base_edge->flags,
- stem_edge->flags );
-
-
- stem_edge->pos = base_edge->pos + fitted_width;
-
- FT_TRACE5(( " LINK: edge %td (opos=%.2f) linked to %.2f,"
- " dist was %.2f, now %.2f\n",
- stem_edge - hints->axis[dim].edges,
- (double)stem_edge->opos / 64, (double)stem_edge->pos / 64,
- (double)dist / 64, (double)fitted_width / 64 ));
- }
-
-
- /* Shift the coordinates of the `serif' edge by the same amount */
- /* as the corresponding `base' edge has been moved already. */
-
- static void
- af_latin_align_serif_edge( AF_GlyphHints hints,
- AF_Edge base,
- AF_Edge serif )
- {
- FT_UNUSED( hints );
-
- serif->pos = base->pos + ( serif->opos - base->opos );
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /**** ****/
- /**** E D G E H I N T I N G ****/
- /**** ****/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /* The main grid-fitting routine. */
-
- static void
- af_latin_hint_edges( AF_GlyphHints hints,
- AF_Dimension dim )
- {
- AF_AxisHints axis = &hints->axis[dim];
- AF_Edge edges = axis->edges;
- AF_Edge edge_limit = FT_OFFSET( edges, axis->num_edges );
- FT_PtrDist n_edges;
- AF_Edge edge;
- AF_Edge anchor = NULL;
- FT_Int has_serifs = 0;
-
- AF_StyleClass style_class = hints->metrics->style_class;
- AF_ScriptClass script_class = af_script_classes[style_class->script];
-
- FT_Bool top_to_bottom_hinting = 0;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- FT_UInt num_actions = 0;
-#endif
-
-
- FT_TRACE5(( "latin %s edge hinting (style `%s')\n",
- dim == AF_DIMENSION_VERT ? "horizontal" : "vertical",
- af_style_names[hints->metrics->style_class->style] ));
-
- if ( dim == AF_DIMENSION_VERT )
- top_to_bottom_hinting = script_class->top_to_bottom_hinting;
-
- /* we begin by aligning all stems relative to the blue zone */
- /* if needed -- that's only for horizontal edges */
-
- if ( dim == AF_DIMENSION_VERT && AF_HINTS_DO_BLUES( hints ) )
- {
- for ( edge = edges; edge < edge_limit; edge++ )
- {
- AF_Width blue;
- AF_Edge edge1, edge2; /* these edges form the stem to check */
-
-
- if ( edge->flags & AF_EDGE_DONE )
- continue;
-
- edge1 = NULL;
- edge2 = edge->link;
-
- /*
- * If a stem contains both a neutral and a non-neutral blue zone,
- * skip the neutral one. Otherwise, outlines with different
- * directions might be incorrectly aligned at the same vertical
- * position.
- *
- * If we have two neutral blue zones, skip one of them.
- *
- */
- if ( edge->blue_edge && edge2 && edge2->blue_edge )
- {
- FT_Byte neutral = edge->flags & AF_EDGE_NEUTRAL;
- FT_Byte neutral2 = edge2->flags & AF_EDGE_NEUTRAL;
-
-
- if ( neutral2 )
- {
- edge2->blue_edge = NULL;
- edge2->flags &= ~AF_EDGE_NEUTRAL;
- }
- else if ( neutral )
- {
- edge->blue_edge = NULL;
- edge->flags &= ~AF_EDGE_NEUTRAL;
- }
- }
-
- blue = edge->blue_edge;
- if ( blue )
- edge1 = edge;
-
- /* flip edges if the other edge is aligned to a blue zone */
- else if ( edge2 && edge2->blue_edge )
- {
- blue = edge2->blue_edge;
- edge1 = edge2;
- edge2 = edge;
- }
-
- if ( !edge1 )
- continue;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( !anchor )
- FT_TRACE5(( " BLUE_ANCHOR: edge %td (opos=%.2f) snapped to %.2f,"
- " was %.2f (anchor=edge %td)\n",
- edge1 - edges,
- (double)edge1->opos / 64, (double)blue->fit / 64,
- (double)edge1->pos / 64, edge - edges ));
- else
- FT_TRACE5(( " BLUE: edge %td (opos=%.2f) snapped to %.2f,"
- " was %.2f\n",
- edge1 - edges,
- (double)edge1->opos / 64, (double)blue->fit / 64,
- (double)edge1->pos / 64 ));
-
- num_actions++;
-#endif
-
- edge1->pos = blue->fit;
- edge1->flags |= AF_EDGE_DONE;
-
- if ( edge2 && !edge2->blue_edge )
- {
- af_latin_align_linked_edge( hints, dim, edge1, edge2 );
- edge2->flags |= AF_EDGE_DONE;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- num_actions++;
-#endif
- }
-
- if ( !anchor )
- anchor = edge;
- }
- }
-
- /* now we align all other stem edges, trying to maintain the */
- /* relative order of stems in the glyph */
- for ( edge = edges; edge < edge_limit; edge++ )
- {
- AF_Edge edge2;
-
-
- if ( edge->flags & AF_EDGE_DONE )
- continue;
-
- /* skip all non-stem edges */
- edge2 = edge->link;
- if ( !edge2 )
- {
- has_serifs++;
- continue;
- }
-
- /* now align the stem */
-
- /* this should not happen, but it's better to be safe */
- if ( edge2->blue_edge )
- {
- FT_TRACE5(( " ASSERTION FAILED for edge %td\n", edge2 - edges ));
-
- af_latin_align_linked_edge( hints, dim, edge2, edge );
- edge->flags |= AF_EDGE_DONE;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- num_actions++;
-#endif
- continue;
- }
-
- if ( !anchor )
- {
- /* if we reach this if clause, no stem has been aligned yet */
-
- FT_Pos org_len, org_center, cur_len;
- FT_Pos cur_pos1, error1, error2, u_off, d_off;
-
-
- org_len = edge2->opos - edge->opos;
- cur_len = af_latin_compute_stem_width( hints, dim,
- org_len, 0,
- edge->flags,
- edge2->flags );
-
- /* some voodoo to specially round edges for small stem widths; */
- /* the idea is to align the center of a stem, then shifting */
- /* the stem edges to suitable positions */
- if ( cur_len <= 64 )
- {
- /* width <= 1px */
- u_off = 32;
- d_off = 32;
- }
- else
- {
- /* 1px < width < 1.5px */
- u_off = 38;
- d_off = 26;
- }
-
- if ( cur_len < 96 )
- {
- org_center = edge->opos + ( org_len >> 1 );
- cur_pos1 = FT_PIX_ROUND( org_center );
-
- error1 = org_center - ( cur_pos1 - u_off );
- if ( error1 < 0 )
- error1 = -error1;
-
- error2 = org_center - ( cur_pos1 + d_off );
- if ( error2 < 0 )
- error2 = -error2;
-
- if ( error1 < error2 )
- cur_pos1 -= u_off;
- else
- cur_pos1 += d_off;
-
- edge->pos = cur_pos1 - cur_len / 2;
- edge2->pos = edge->pos + cur_len;
- }
- else
- edge->pos = FT_PIX_ROUND( edge->opos );
-
- anchor = edge;
- edge->flags |= AF_EDGE_DONE;
-
- FT_TRACE5(( " ANCHOR: edge %td (opos=%.2f) and %td (opos=%.2f)"
- " snapped to %.2f and %.2f\n",
- edge - edges, (double)edge->opos / 64,
- edge2 - edges, (double)edge2->opos / 64,
- (double)edge->pos / 64, (double)edge2->pos / 64 ));
-
- af_latin_align_linked_edge( hints, dim, edge, edge2 );
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- num_actions += 2;
-#endif
- }
- else
- {
- FT_Pos org_pos, org_len, org_center, cur_len;
- FT_Pos cur_pos1, cur_pos2, delta1, delta2;
-
-
- org_pos = anchor->pos + ( edge->opos - anchor->opos );
- org_len = edge2->opos - edge->opos;
- org_center = org_pos + ( org_len >> 1 );
-
- cur_len = af_latin_compute_stem_width( hints, dim,
- org_len, 0,
- edge->flags,
- edge2->flags );
-
- if ( edge2->flags & AF_EDGE_DONE )
- {
- FT_TRACE5(( " ADJUST: edge %td (pos=%.2f) moved to %.2f\n",
- edge - edges, (double)edge->pos / 64,
- (double)( edge2->pos - cur_len ) / 64 ));
-
- edge->pos = edge2->pos - cur_len;
- }
-
- else if ( cur_len < 96 )
- {
- FT_Pos u_off, d_off;
-
-
- cur_pos1 = FT_PIX_ROUND( org_center );
-
- if ( cur_len <= 64 )
- {
- u_off = 32;
- d_off = 32;
- }
- else
- {
- u_off = 38;
- d_off = 26;
- }
-
- delta1 = org_center - ( cur_pos1 - u_off );
- if ( delta1 < 0 )
- delta1 = -delta1;
-
- delta2 = org_center - ( cur_pos1 + d_off );
- if ( delta2 < 0 )
- delta2 = -delta2;
-
- if ( delta1 < delta2 )
- cur_pos1 -= u_off;
- else
- cur_pos1 += d_off;
-
- edge->pos = cur_pos1 - cur_len / 2;
- edge2->pos = cur_pos1 + cur_len / 2;
-
- FT_TRACE5(( " STEM: edge %td (opos=%.2f) linked to %td (opos=%.2f)"
- " snapped to %.2f and %.2f\n",
- edge - edges, (double)edge->opos / 64,
- edge2 - edges, (double)edge2->opos / 64,
- (double)edge->pos / 64, (double)edge2->pos / 64 ));
- }
-
- else
- {
- org_pos = anchor->pos + ( edge->opos - anchor->opos );
- org_len = edge2->opos - edge->opos;
- org_center = org_pos + ( org_len >> 1 );
-
- cur_len = af_latin_compute_stem_width( hints, dim,
- org_len, 0,
- edge->flags,
- edge2->flags );
-
- cur_pos1 = FT_PIX_ROUND( org_pos );
- delta1 = cur_pos1 + ( cur_len >> 1 ) - org_center;
- if ( delta1 < 0 )
- delta1 = -delta1;
-
- cur_pos2 = FT_PIX_ROUND( org_pos + org_len ) - cur_len;
- delta2 = cur_pos2 + ( cur_len >> 1 ) - org_center;
- if ( delta2 < 0 )
- delta2 = -delta2;
-
- edge->pos = ( delta1 < delta2 ) ? cur_pos1 : cur_pos2;
- edge2->pos = edge->pos + cur_len;
-
- FT_TRACE5(( " STEM: edge %td (opos=%.2f) linked to %td (opos=%.2f)"
- " snapped to %.2f and %.2f\n",
- edge - edges, (double)edge->opos / 64,
- edge2 - edges, (double)edge2->opos / 64,
- (double)edge->pos / 64, (double)edge2->pos / 64 ));
- }
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- num_actions++;
-#endif
-
- edge->flags |= AF_EDGE_DONE;
- edge2->flags |= AF_EDGE_DONE;
-
- if ( edge > edges &&
- ( top_to_bottom_hinting ? ( edge->pos > edge[-1].pos )
- : ( edge->pos < edge[-1].pos ) ) )
- {
- /* don't move if stem would (almost) disappear otherwise; */
- /* the ad-hoc value 16 corresponds to 1/4px */
- if ( edge->link && FT_ABS( edge->link->pos - edge[-1].pos ) > 16 )
- {
-#ifdef FT_DEBUG_LEVEL_TRACE
- FT_TRACE5(( " BOUND: edge %td (pos=%.2f) moved to %.2f\n",
- edge - edges,
- (double)edge->pos / 64,
- (double)edge[-1].pos / 64 ));
-
- num_actions++;
-#endif
-
- edge->pos = edge[-1].pos;
- }
- }
- }
- }
-
- /* make sure that lowercase m's maintain their symmetry */
-
- /* In general, lowercase m's have six vertical edges if they are sans */
- /* serif, or twelve if they are with serifs. This implementation is */
- /* based on that assumption, and seems to work very well with most */
- /* faces. However, if for a certain face this assumption is not */
- /* true, the m is just rendered like before. In addition, any stem */
- /* correction will only be applied to symmetrical glyphs (even if the */
- /* glyph is not an m), so the potential for unwanted distortion is */
- /* relatively low. */
-
- /* We don't handle horizontal edges since we can't easily assure that */
- /* the third (lowest) stem aligns with the base line; it might end up */
- /* one pixel higher or lower. */
-
- n_edges = edge_limit - edges;
- if ( dim == AF_DIMENSION_HORZ && ( n_edges == 6 || n_edges == 12 ) )
- {
- AF_Edge edge1, edge2, edge3;
- FT_Pos dist1, dist2, span, delta;
-
-
- if ( n_edges == 6 )
- {
- edge1 = edges;
- edge2 = edges + 2;
- edge3 = edges + 4;
- }
- else
- {
- edge1 = edges + 1;
- edge2 = edges + 5;
- edge3 = edges + 9;
- }
-
- dist1 = edge2->opos - edge1->opos;
- dist2 = edge3->opos - edge2->opos;
-
- span = dist1 - dist2;
- if ( span < 0 )
- span = -span;
-
- if ( span < 8 )
- {
- delta = edge3->pos - ( 2 * edge2->pos - edge1->pos );
- edge3->pos -= delta;
- if ( edge3->link )
- edge3->link->pos -= delta;
-
- /* move the serifs along with the stem */
- if ( n_edges == 12 )
- {
- ( edges + 8 )->pos -= delta;
- ( edges + 11 )->pos -= delta;
- }
-
- edge3->flags |= AF_EDGE_DONE;
- if ( edge3->link )
- edge3->link->flags |= AF_EDGE_DONE;
- }
- }
-
- if ( has_serifs || !anchor )
- {
- /*
- * now hint the remaining edges (serifs and single) in order
- * to complete our processing
- */
- for ( edge = edges; edge < edge_limit; edge++ )
- {
- FT_Pos delta;
-
-
- if ( edge->flags & AF_EDGE_DONE )
- continue;
-
- delta = 1000;
-
- if ( edge->serif )
- {
- delta = edge->serif->opos - edge->opos;
- if ( delta < 0 )
- delta = -delta;
- }
-
- if ( delta < 64 + 16 )
- {
- af_latin_align_serif_edge( hints, edge->serif, edge );
- FT_TRACE5(( " SERIF: edge %td (opos=%.2f) serif to %td (opos=%.2f)"
- " aligned to %.2f\n",
- edge - edges, (double)edge->opos / 64,
- edge->serif - edges, (double)edge->serif->opos / 64,
- (double)edge->pos / 64 ));
- }
- else if ( !anchor )
- {
- edge->pos = FT_PIX_ROUND( edge->opos );
- anchor = edge;
- FT_TRACE5(( " SERIF_ANCHOR: edge %td (opos=%.2f)"
- " snapped to %.2f\n",
- edge - edges,
- (double)edge->opos / 64, (double)edge->pos / 64 ));
- }
- else
- {
- AF_Edge before, after;
-
-
- for ( before = edge - 1; before >= edges; before-- )
- if ( before->flags & AF_EDGE_DONE )
- break;
-
- for ( after = edge + 1; after < edge_limit; after++ )
- if ( after->flags & AF_EDGE_DONE )
- break;
-
- if ( before >= edges && before < edge &&
- after < edge_limit && after > edge )
- {
- if ( after->opos == before->opos )
- edge->pos = before->pos;
- else
- edge->pos = before->pos +
- FT_MulDiv( edge->opos - before->opos,
- after->pos - before->pos,
- after->opos - before->opos );
-
- FT_TRACE5(( " SERIF_LINK1: edge %td (opos=%.2f) snapped to %.2f"
- " from %td (opos=%.2f)\n",
- edge - edges, (double)edge->opos / 64,
- (double)edge->pos / 64,
- before - edges, (double)before->opos / 64 ));
- }
- else
- {
- edge->pos = anchor->pos +
- ( ( edge->opos - anchor->opos + 16 ) & ~31 );
- FT_TRACE5(( " SERIF_LINK2: edge %td (opos=%.2f)"
- " snapped to %.2f\n",
- edge - edges,
- (double)edge->opos / 64, (double)edge->pos / 64 ));
- }
- }
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- num_actions++;
-#endif
- edge->flags |= AF_EDGE_DONE;
-
- if ( edge > edges &&
- ( top_to_bottom_hinting ? ( edge->pos > edge[-1].pos )
- : ( edge->pos < edge[-1].pos ) ) )
- {
- /* don't move if stem would (almost) disappear otherwise; */
- /* the ad-hoc value 16 corresponds to 1/4px */
- if ( edge->link && FT_ABS( edge->link->pos - edge[-1].pos ) > 16 )
- {
-#ifdef FT_DEBUG_LEVEL_TRACE
- FT_TRACE5(( " BOUND: edge %td (pos=%.2f) moved to %.2f\n",
- edge - edges,
- (double)edge->pos / 64,
- (double)edge[-1].pos / 64 ));
-
- num_actions++;
-#endif
- edge->pos = edge[-1].pos;
- }
- }
-
- if ( edge + 1 < edge_limit &&
- edge[1].flags & AF_EDGE_DONE &&
- ( top_to_bottom_hinting ? ( edge->pos < edge[1].pos )
- : ( edge->pos > edge[1].pos ) ) )
- {
- /* don't move if stem would (almost) disappear otherwise; */
- /* the ad-hoc value 16 corresponds to 1/4px */
- if ( edge->link && FT_ABS( edge->link->pos - edge[-1].pos ) > 16 )
- {
-#ifdef FT_DEBUG_LEVEL_TRACE
- FT_TRACE5(( " BOUND: edge %td (pos=%.2f) moved to %.2f\n",
- edge - edges,
- (double)edge->pos / 64,
- (double)edge[1].pos / 64 ));
-
- num_actions++;
-#endif
-
- edge->pos = edge[1].pos;
- }
- }
- }
- }
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( !num_actions )
- FT_TRACE5(( " (none)\n" ));
- FT_TRACE5(( "\n" ));
-#endif
- }
-
-
- /* Apply the complete hinting algorithm to a latin glyph. */
-
- static FT_Error
- af_latin_hints_apply( FT_UInt glyph_index,
- AF_GlyphHints hints,
- FT_Outline* outline,
- AF_StyleMetrics metrics_ ) /* AF_LatinMetrics */
- {
- AF_LatinMetrics metrics = (AF_LatinMetrics)metrics_;
-
- FT_Error error;
- int dim;
-
- AF_LatinAxis axis;
-
-
- error = af_glyph_hints_reload( hints, outline );
- if ( error )
- goto Exit;
-
- /* analyze glyph outline */
- if ( AF_HINTS_DO_HORIZONTAL( hints ) )
- {
- axis = &metrics->axis[AF_DIMENSION_HORZ];
- error = af_latin_hints_detect_features( hints,
- axis->width_count,
- axis->widths,
- AF_DIMENSION_HORZ );
- if ( error )
- goto Exit;
- }
-
- if ( AF_HINTS_DO_VERTICAL( hints ) )
- {
- axis = &metrics->axis[AF_DIMENSION_VERT];
- error = af_latin_hints_detect_features( hints,
- axis->width_count,
- axis->widths,
- AF_DIMENSION_VERT );
- if ( error )
- goto Exit;
-
- /* apply blue zones to base characters only */
- if ( !( metrics->root.globals->glyph_styles[glyph_index] & AF_NONBASE ) )
- af_latin_hints_compute_blue_edges( hints, metrics );
- }
-
- /* grid-fit the outline */
- for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ )
- {
- if ( ( dim == AF_DIMENSION_HORZ && AF_HINTS_DO_HORIZONTAL( hints ) ) ||
- ( dim == AF_DIMENSION_VERT && AF_HINTS_DO_VERTICAL( hints ) ) )
- {
- af_latin_hint_edges( hints, (AF_Dimension)dim );
- af_glyph_hints_align_edge_points( hints, (AF_Dimension)dim );
- af_glyph_hints_align_strong_points( hints, (AF_Dimension)dim );
- af_glyph_hints_align_weak_points( hints, (AF_Dimension)dim );
- }
- }
-
- af_glyph_hints_save( hints, outline );
-
- Exit:
- return error;
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** L A T I N S C R I P T C L A S S *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- AF_DEFINE_WRITING_SYSTEM_CLASS(
- af_latin_writing_system_class,
-
- AF_WRITING_SYSTEM_LATIN,
-
- sizeof ( AF_LatinMetricsRec ),
-
- (AF_WritingSystem_InitMetricsFunc) af_latin_metrics_init, /* style_metrics_init */
- (AF_WritingSystem_ScaleMetricsFunc)af_latin_metrics_scale, /* style_metrics_scale */
- (AF_WritingSystem_DoneMetricsFunc) NULL, /* style_metrics_done */
- (AF_WritingSystem_GetStdWidthsFunc)af_latin_get_standard_widths, /* style_metrics_getstdw */
-
- (AF_WritingSystem_InitHintsFunc) af_latin_hints_init, /* style_hints_init */
- (AF_WritingSystem_ApplyHintsFunc) af_latin_hints_apply /* style_hints_apply */
- )
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/autofit/aflatin.h b/contrib/libs/freetype/src/autofit/aflatin.h
deleted file mode 100644
index 54e5061502..0000000000
--- a/contrib/libs/freetype/src/autofit/aflatin.h
+++ /dev/null
@@ -1,194 +0,0 @@
-/****************************************************************************
- *
- * aflatin.h
- *
- * Auto-fitter hinting routines for latin writing system
- * (specification).
- *
- * Copyright (C) 2003-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef AFLATIN_H_
-#define AFLATIN_H_
-
-#include "afhints.h"
-
-
-FT_BEGIN_HEADER
-
- /* the `latin' writing system */
-
- AF_DECLARE_WRITING_SYSTEM_CLASS( af_latin_writing_system_class )
-
-
- /* constants are given with units_per_em == 2048 in mind */
-#define AF_LATIN_CONSTANT( metrics, c ) \
- ( ( (c) * (FT_Long)( (AF_LatinMetrics)(metrics) )->units_per_em ) / 2048 )
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** L A T I N G L O B A L M E T R I C S *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /*
- * The following declarations could be embedded in the file `aflatin.c';
- * they have been made semi-public to allow alternate writing system
- * hinters to re-use some of them.
- */
-
-
-#define AF_LATIN_IS_TOP_BLUE( b ) \
- ( (b)->properties & AF_BLUE_PROPERTY_LATIN_TOP )
-#define AF_LATIN_IS_SUB_TOP_BLUE( b ) \
- ( (b)->properties & AF_BLUE_PROPERTY_LATIN_SUB_TOP )
-#define AF_LATIN_IS_NEUTRAL_BLUE( b ) \
- ( (b)->properties & AF_BLUE_PROPERTY_LATIN_NEUTRAL )
-#define AF_LATIN_IS_X_HEIGHT_BLUE( b ) \
- ( (b)->properties & AF_BLUE_PROPERTY_LATIN_X_HEIGHT )
-#define AF_LATIN_IS_LONG_BLUE( b ) \
- ( (b)->properties & AF_BLUE_PROPERTY_LATIN_LONG )
-
-#define AF_LATIN_MAX_WIDTHS 16
-
-
-#define AF_LATIN_BLUE_ACTIVE ( 1U << 0 ) /* zone height is <= 3/4px */
-#define AF_LATIN_BLUE_TOP ( 1U << 1 ) /* we have a top blue zone */
-#define AF_LATIN_BLUE_SUB_TOP ( 1U << 2 ) /* we have a subscript top */
- /* blue zone */
-#define AF_LATIN_BLUE_NEUTRAL ( 1U << 3 ) /* we have neutral blue zone */
-#define AF_LATIN_BLUE_ADJUSTMENT ( 1U << 4 ) /* used for scale adjustment */
- /* optimization */
-
-
- typedef struct AF_LatinBlueRec_
- {
- AF_WidthRec ref;
- AF_WidthRec shoot;
- FT_Pos ascender;
- FT_Pos descender;
- FT_UInt flags;
-
- } AF_LatinBlueRec, *AF_LatinBlue;
-
-
- typedef struct AF_LatinAxisRec_
- {
- FT_Fixed scale;
- FT_Pos delta;
-
- FT_UInt width_count; /* number of used widths */
- AF_WidthRec widths[AF_LATIN_MAX_WIDTHS]; /* widths array */
- FT_Pos edge_distance_threshold; /* used for creating edges */
- FT_Pos standard_width; /* the default stem thickness */
- FT_Bool extra_light; /* is standard width very light? */
-
- /* ignored for horizontal metrics */
- FT_UInt blue_count;
- AF_LatinBlueRec blues[AF_BLUE_STRINGSET_MAX_LEN];
-
- FT_Fixed org_scale;
- FT_Pos org_delta;
-
- } AF_LatinAxisRec, *AF_LatinAxis;
-
-
- typedef struct AF_LatinMetricsRec_
- {
- AF_StyleMetricsRec root;
- FT_UInt units_per_em;
- AF_LatinAxisRec axis[AF_DIMENSION_MAX];
-
- } AF_LatinMetricsRec, *AF_LatinMetrics;
-
-
- FT_LOCAL( FT_Error )
- af_latin_metrics_init( AF_StyleMetrics metrics,
- FT_Face face );
-
- FT_LOCAL( void )
- af_latin_metrics_scale( AF_StyleMetrics metrics,
- AF_Scaler scaler );
-
- FT_LOCAL( void )
- af_latin_metrics_init_widths( AF_LatinMetrics metrics,
- FT_Face face );
-
- FT_LOCAL( void )
- af_latin_metrics_check_digits( AF_LatinMetrics metrics,
- FT_Face face );
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** L A T I N G L Y P H A N A L Y S I S *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-#define AF_LATIN_HINTS_HORZ_SNAP ( 1U << 0 ) /* stem width snapping */
-#define AF_LATIN_HINTS_VERT_SNAP ( 1U << 1 ) /* stem height snapping */
-#define AF_LATIN_HINTS_STEM_ADJUST ( 1U << 2 ) /* stem width/height */
- /* adjustment */
-#define AF_LATIN_HINTS_MONO ( 1U << 3 ) /* monochrome rendering */
-
-
-#define AF_LATIN_HINTS_DO_HORZ_SNAP( h ) \
- AF_HINTS_TEST_OTHER( h, AF_LATIN_HINTS_HORZ_SNAP )
-
-#define AF_LATIN_HINTS_DO_VERT_SNAP( h ) \
- AF_HINTS_TEST_OTHER( h, AF_LATIN_HINTS_VERT_SNAP )
-
-#define AF_LATIN_HINTS_DO_STEM_ADJUST( h ) \
- AF_HINTS_TEST_OTHER( h, AF_LATIN_HINTS_STEM_ADJUST )
-
-#define AF_LATIN_HINTS_DO_MONO( h ) \
- AF_HINTS_TEST_OTHER( h, AF_LATIN_HINTS_MONO )
-
-
- /*
- * The next functions shouldn't normally be exported. However, other
- * writing systems might like to use these functions as-is.
- */
- FT_LOCAL( FT_Error )
- af_latin_hints_compute_segments( AF_GlyphHints hints,
- AF_Dimension dim );
-
- FT_LOCAL( void )
- af_latin_hints_link_segments( AF_GlyphHints hints,
- FT_UInt width_count,
- AF_WidthRec* widths,
- AF_Dimension dim );
-
- FT_LOCAL( FT_Error )
- af_latin_hints_compute_edges( AF_GlyphHints hints,
- AF_Dimension dim );
-
- FT_LOCAL( FT_Error )
- af_latin_hints_detect_features( AF_GlyphHints hints,
- FT_UInt width_count,
- AF_WidthRec* widths,
- AF_Dimension dim );
-
-/* */
-
-FT_END_HEADER
-
-#endif /* AFLATIN_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/autofit/afloader.c b/contrib/libs/freetype/src/autofit/afloader.c
deleted file mode 100644
index af1d59a689..0000000000
--- a/contrib/libs/freetype/src/autofit/afloader.c
+++ /dev/null
@@ -1,706 +0,0 @@
-/****************************************************************************
- *
- * afloader.c
- *
- * Auto-fitter glyph loading routines (body).
- *
- * Copyright (C) 2003-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include "afglobal.h"
-#include "afloader.h"
-#include "afhints.h"
-#include "aferrors.h"
-#include "afmodule.h"
-
-#include <freetype/internal/ftcalc.h>
-
-
- /* Initialize glyph loader. */
-
- FT_LOCAL_DEF( void )
- af_loader_init( AF_Loader loader,
- AF_GlyphHints hints )
- {
- FT_ZERO( loader );
-
- loader->hints = hints;
- }
-
-
- /* Reset glyph loader and compute globals if necessary. */
-
- FT_LOCAL_DEF( FT_Error )
- af_loader_reset( AF_Loader loader,
- AF_Module module,
- FT_Face face )
- {
- FT_Error error = FT_Err_Ok;
-
-
- loader->face = face;
- loader->globals = (AF_FaceGlobals)face->autohint.data;
-
- if ( !loader->globals )
- {
- error = af_face_globals_new( face, &loader->globals, module );
- if ( !error )
- {
- face->autohint.data = (FT_Pointer)loader->globals;
- face->autohint.finalizer = af_face_globals_free;
- }
- }
-
- return error;
- }
-
-
- /* Finalize glyph loader. */
-
- FT_LOCAL_DEF( void )
- af_loader_done( AF_Loader loader )
- {
- loader->face = NULL;
- loader->globals = NULL;
- loader->hints = NULL;
- }
-
-
-#define af_intToFixed( i ) \
- ( (FT_Fixed)( (FT_UInt32)(i) << 16 ) )
-#define af_fixedToInt( x ) \
- ( (FT_Short)( ( (FT_UInt32)(x) + 0x8000U ) >> 16 ) )
-#define af_floatToFixed( f ) \
- ( (FT_Fixed)( (f) * 65536.0 + 0.5 ) )
-
-
- static FT_Error
- af_loader_embolden_glyph_in_slot( AF_Loader loader,
- FT_Face face,
- AF_StyleMetrics style_metrics )
- {
- FT_Error error = FT_Err_Ok;
-
- FT_GlyphSlot slot = face->glyph;
- AF_FaceGlobals globals = loader->globals;
- AF_WritingSystemClass writing_system_class;
-
- FT_Size_Metrics* size_metrics = &face->size->internal->autohint_metrics;
-
- FT_Pos stdVW = 0;
- FT_Pos stdHW = 0;
-
- FT_Bool size_changed = size_metrics->x_ppem !=
- globals->stem_darkening_for_ppem;
-
- FT_Fixed em_size = af_intToFixed( face->units_per_EM );
-
- FT_Matrix scale_down_matrix = { 0x10000L, 0, 0, 0x10000L };
-
-
- /* Skip stem darkening for broken fonts. */
- if ( !face->units_per_EM )
- {
- error = FT_ERR( Corrupted_Font_Header );
- goto Exit;
- }
-
- /*
- * We depend on the writing system (script analyzers) to supply
- * standard widths for the script of the glyph we are looking at. If
- * it can't deliver, stem darkening is disabled.
- */
- writing_system_class =
- af_writing_system_classes[style_metrics->style_class->writing_system];
-
- if ( writing_system_class->style_metrics_getstdw )
- writing_system_class->style_metrics_getstdw( style_metrics,
- &stdHW,
- &stdVW );
- else
- {
- error = FT_ERR( Unimplemented_Feature );
- goto Exit;
- }
-
- if ( size_changed ||
- ( stdVW > 0 && stdVW != globals->standard_vertical_width ) )
- {
- FT_Fixed darken_by_font_units_x, darken_x;
-
-
- darken_by_font_units_x =
- af_loader_compute_darkening( loader,
- face,
- stdVW ) ;
- darken_x = FT_MulFix( darken_by_font_units_x,
- size_metrics->x_scale );
-
- globals->standard_vertical_width = stdVW;
- globals->stem_darkening_for_ppem = size_metrics->x_ppem;
- globals->darken_x = af_fixedToInt( darken_x );
- }
-
- if ( size_changed ||
- ( stdHW > 0 && stdHW != globals->standard_horizontal_width ) )
- {
- FT_Fixed darken_by_font_units_y, darken_y;
-
-
- darken_by_font_units_y =
- af_loader_compute_darkening( loader,
- face,
- stdHW ) ;
- darken_y = FT_MulFix( darken_by_font_units_y,
- size_metrics->y_scale );
-
- globals->standard_horizontal_width = stdHW;
- globals->stem_darkening_for_ppem = size_metrics->x_ppem;
- globals->darken_y = af_fixedToInt( darken_y );
-
- /*
- * Scale outlines down on the Y-axis to keep them inside their blue
- * zones. The stronger the emboldening, the stronger the downscaling
- * (plus heuristical padding to prevent outlines still falling out
- * their zones due to rounding).
- *
- * Reason: `FT_Outline_Embolden' works by shifting the rightmost
- * points of stems farther to the right, and topmost points farther
- * up. This positions points on the Y-axis outside their
- * pre-computed blue zones and leads to distortion when applying the
- * hints in the code further below. Code outside this emboldening
- * block doesn't know we are presenting it with modified outlines the
- * analyzer didn't see!
- *
- * An unfortunate side effect of downscaling is that the emboldening
- * effect is slightly decreased. The loss becomes more pronounced
- * versus the CFF driver at smaller sizes, e.g., at 9ppem and below.
- */
- globals->scale_down_factor =
- FT_DivFix( em_size - ( darken_by_font_units_y + af_intToFixed( 8 ) ),
- em_size );
- }
-
- FT_Outline_EmboldenXY( &slot->outline,
- globals->darken_x,
- globals->darken_y );
-
- scale_down_matrix.yy = globals->scale_down_factor;
- FT_Outline_Transform( &slot->outline, &scale_down_matrix );
-
- Exit:
- return error;
- }
-
-
- /* Load the glyph at index into the current slot of a face and hint it. */
-
- FT_LOCAL_DEF( FT_Error )
- af_loader_load_glyph( AF_Loader loader,
- AF_Module module,
- FT_Face face,
- FT_UInt glyph_index,
- FT_Int32 load_flags )
- {
- FT_Error error;
-
- FT_Size size = face->size;
- FT_Size_Internal size_internal = size->internal;
- FT_GlyphSlot slot = face->glyph;
- FT_Slot_Internal slot_internal = slot->internal;
- FT_GlyphLoader gloader = slot_internal->loader;
-
- AF_GlyphHints hints = loader->hints;
- AF_ScalerRec scaler;
- AF_StyleMetrics style_metrics;
- FT_UInt style_options = AF_STYLE_NONE_DFLT;
- AF_StyleClass style_class;
- AF_WritingSystemClass writing_system_class;
-
-
- FT_ZERO( &scaler );
-
- if ( !size_internal->autohint_metrics.x_scale ||
- size_internal->autohint_mode != FT_LOAD_TARGET_MODE( load_flags ) )
- {
- /* switching between hinting modes usually means different scaling */
- /* values; this later on enforces recomputation of everything */
- /* related to the current size */
-
- size_internal->autohint_mode = FT_LOAD_TARGET_MODE( load_flags );
- size_internal->autohint_metrics = size->metrics;
-
-#ifdef AF_CONFIG_OPTION_TT_SIZE_METRICS
- {
- FT_Size_Metrics* size_metrics = &size_internal->autohint_metrics;
-
-
- /* set metrics to integer values and adjust scaling accordingly; */
- /* this is the same setup as with TrueType fonts, cf. function */
- /* `tt_size_reset' in file `ttobjs.c' */
- size_metrics->ascender = FT_PIX_ROUND(
- FT_MulFix( face->ascender,
- size_metrics->y_scale ) );
- size_metrics->descender = FT_PIX_ROUND(
- FT_MulFix( face->descender,
- size_metrics->y_scale ) );
- size_metrics->height = FT_PIX_ROUND(
- FT_MulFix( face->height,
- size_metrics->y_scale ) );
-
- size_metrics->x_scale = FT_DivFix( size_metrics->x_ppem << 6,
- face->units_per_EM );
- size_metrics->y_scale = FT_DivFix( size_metrics->y_ppem << 6,
- face->units_per_EM );
- size_metrics->max_advance = FT_PIX_ROUND(
- FT_MulFix( face->max_advance_width,
- size_metrics->x_scale ) );
- }
-#endif /* AF_CONFIG_OPTION_TT_SIZE_METRICS */
- }
-
- /*
- * TODO: This code currently doesn't support fractional advance widths,
- * i.e., placing hinted glyphs at anything other than integer
- * x-positions. This is only relevant for the warper code, which
- * scales and shifts glyphs to optimize blackness of stems (hinting on
- * the x-axis by nature places things on pixel integers, hinting on the
- * y-axis only, i.e., LIGHT mode, doesn't touch the x-axis). The delta
- * values of the scaler would need to be adjusted.
- */
- scaler.face = face;
- scaler.x_scale = size_internal->autohint_metrics.x_scale;
- scaler.x_delta = 0;
- scaler.y_scale = size_internal->autohint_metrics.y_scale;
- scaler.y_delta = 0;
-
- scaler.render_mode = FT_LOAD_TARGET_MODE( load_flags );
- scaler.flags = 0;
-
- /* note that the fallback style can't be changed anymore */
- /* after the first call of `af_loader_load_glyph' */
- error = af_loader_reset( loader, module, face );
- if ( error )
- goto Exit;
-
- /*
- * Glyphs (really code points) are assigned to scripts. Script
- * analysis is done lazily: For each glyph that passes through here,
- * the corresponding script analyzer is called, but returns immediately
- * if it has been run already.
- */
- error = af_face_globals_get_metrics( loader->globals, glyph_index,
- style_options, &style_metrics );
- if ( error )
- goto Exit;
-
- style_class = style_metrics->style_class;
- writing_system_class =
- af_writing_system_classes[style_class->writing_system];
-
- loader->metrics = style_metrics;
-
- if ( writing_system_class->style_metrics_scale )
- writing_system_class->style_metrics_scale( style_metrics, &scaler );
- else
- style_metrics->scaler = scaler;
-
- if ( writing_system_class->style_hints_init )
- {
- error = writing_system_class->style_hints_init( hints,
- style_metrics );
- if ( error )
- goto Exit;
- }
-
- /*
- * Do the main work of `af_loader_load_glyph'. Note that we never have
- * to deal with composite glyphs as those get loaded into
- * FT_GLYPH_FORMAT_OUTLINE by the recursed `FT_Load_Glyph' function.
- * In the rare cases where FT_LOAD_NO_RECURSE is set, it implies
- * FT_LOAD_NO_SCALE and as such the auto-hinter is never called.
- */
- load_flags |= FT_LOAD_NO_SCALE |
- FT_LOAD_IGNORE_TRANSFORM |
- FT_LOAD_LINEAR_DESIGN;
- load_flags &= ~FT_LOAD_RENDER;
-
- error = FT_Load_Glyph( face, glyph_index, load_flags );
- if ( error )
- goto Exit;
-
- /*
- * Apply stem darkening (emboldening) here before hints are applied to
- * the outline. Glyphs are scaled down proportionally to the
- * emboldening so that curve points don't fall outside their
- * precomputed blue zones.
- *
- * Any emboldening done by the font driver (e.g., the CFF driver)
- * doesn't reach here because the autohinter loads the unprocessed
- * glyphs in font units for analysis (functions `af_*_metrics_init_*')
- * and then above to prepare it for the rasterizers by itself,
- * independently of the font driver. So emboldening must be done here,
- * within the autohinter.
- *
- * All glyphs to be autohinted pass through here one by one. The
- * standard widths can therefore change from one glyph to the next,
- * depending on what script a glyph is assigned to (each script has its
- * own set of standard widths and other metrics). The darkening amount
- * must therefore be recomputed for each size and
- * `standard_{vertical,horizontal}_width' change.
- *
- * Ignore errors and carry on without emboldening.
- *
- */
-
- /* stem darkening only works well in `light' mode */
- if ( scaler.render_mode == FT_RENDER_MODE_LIGHT &&
- ( !face->internal->no_stem_darkening ||
- ( face->internal->no_stem_darkening < 0 &&
- !module->no_stem_darkening ) ) )
- af_loader_embolden_glyph_in_slot( loader, face, style_metrics );
-
- loader->transformed = slot_internal->glyph_transformed;
- if ( loader->transformed )
- {
- FT_Matrix inverse;
-
-
- loader->trans_matrix = slot_internal->glyph_matrix;
- loader->trans_delta = slot_internal->glyph_delta;
-
- inverse = loader->trans_matrix;
- if ( !FT_Matrix_Invert( &inverse ) )
- FT_Vector_Transform( &loader->trans_delta, &inverse );
- }
-
- switch ( slot->format )
- {
- case FT_GLYPH_FORMAT_OUTLINE:
- /* translate the loaded glyph when an internal transform is needed */
- if ( loader->transformed )
- FT_Outline_Translate( &slot->outline,
- loader->trans_delta.x,
- loader->trans_delta.y );
-
- /* compute original horizontal phantom points */
- /* (and ignore vertical ones) */
- loader->pp1.x = hints->x_delta;
- loader->pp1.y = hints->y_delta;
- loader->pp2.x = FT_MulFix( slot->metrics.horiAdvance,
- hints->x_scale ) + hints->x_delta;
- loader->pp2.y = hints->y_delta;
-
- /* be sure to check for spacing glyphs */
- if ( slot->outline.n_points == 0 )
- goto Hint_Metrics;
-
- /* now load the slot image into the auto-outline */
- /* and run the automatic hinting process */
- if ( writing_system_class->style_hints_apply )
- {
- error = writing_system_class->style_hints_apply(
- glyph_index,
- hints,
- &gloader->base.outline,
- style_metrics );
- if ( error )
- goto Exit;
- }
-
- /* we now need to adjust the metrics according to the change in */
- /* width/positioning that occurred during the hinting process */
- if ( scaler.render_mode != FT_RENDER_MODE_LIGHT )
- {
- AF_AxisHints axis = &hints->axis[AF_DIMENSION_HORZ];
-
-
- if ( axis->num_edges > 1 && AF_HINTS_DO_ADVANCE( hints ) )
- {
- AF_Edge edge1 = axis->edges; /* leftmost edge */
- AF_Edge edge2 = edge1 +
- axis->num_edges - 1; /* rightmost edge */
-
- FT_Pos old_rsb = loader->pp2.x - edge2->opos;
- /* loader->pp1.x is always zero at this point of time */
- FT_Pos old_lsb = edge1->opos; /* - loader->pp1.x */
- FT_Pos new_lsb = edge1->pos;
-
- /* remember unhinted values to later account */
- /* for rounding errors */
- FT_Pos pp1x_uh = new_lsb - old_lsb;
- FT_Pos pp2x_uh = edge2->pos + old_rsb;
-
-
- /* prefer too much space over too little space */
- /* for very small sizes */
-
- if ( old_lsb < 24 )
- pp1x_uh -= 8;
-
- if ( old_rsb < 24 )
- pp2x_uh += 8;
-
- loader->pp1.x = FT_PIX_ROUND( pp1x_uh );
- loader->pp2.x = FT_PIX_ROUND( pp2x_uh );
-
- if ( loader->pp1.x >= new_lsb && old_lsb > 0 )
- loader->pp1.x -= 64;
-
- if ( loader->pp2.x <= edge2->pos && old_rsb > 0 )
- loader->pp2.x += 64;
-
- slot->lsb_delta = loader->pp1.x - pp1x_uh;
- slot->rsb_delta = loader->pp2.x - pp2x_uh;
- }
- else
- {
- FT_Pos pp1x = loader->pp1.x;
- FT_Pos pp2x = loader->pp2.x;
-
-
- loader->pp1.x = FT_PIX_ROUND( pp1x );
- loader->pp2.x = FT_PIX_ROUND( pp2x );
-
- slot->lsb_delta = loader->pp1.x - pp1x;
- slot->rsb_delta = loader->pp2.x - pp2x;
- }
- }
- /* `light' mode uses integer advance widths */
- /* but sets `lsb_delta' and `rsb_delta' */
- else
- {
- FT_Pos pp1x = loader->pp1.x;
- FT_Pos pp2x = loader->pp2.x;
-
-
- loader->pp1.x = FT_PIX_ROUND( pp1x );
- loader->pp2.x = FT_PIX_ROUND( pp2x );
-
- slot->lsb_delta = loader->pp1.x - pp1x;
- slot->rsb_delta = loader->pp2.x - pp2x;
- }
-
- break;
-
- default:
- /* we don't support other formats (yet?) */
- error = FT_THROW( Unimplemented_Feature );
- }
-
- Hint_Metrics:
- {
- FT_BBox bbox;
- FT_Vector vvector;
-
-
- vvector.x = slot->metrics.vertBearingX - slot->metrics.horiBearingX;
- vvector.y = slot->metrics.vertBearingY - slot->metrics.horiBearingY;
- vvector.x = FT_MulFix( vvector.x, style_metrics->scaler.x_scale );
- vvector.y = FT_MulFix( vvector.y, style_metrics->scaler.y_scale );
-
- /* transform the hinted outline if needed */
- if ( loader->transformed )
- {
- FT_Outline_Transform( &gloader->base.outline, &loader->trans_matrix );
- FT_Vector_Transform( &vvector, &loader->trans_matrix );
- }
-
- /* we must translate our final outline by -pp1.x and compute */
- /* the new metrics */
- if ( loader->pp1.x )
- FT_Outline_Translate( &gloader->base.outline, -loader->pp1.x, 0 );
-
- FT_Outline_Get_CBox( &gloader->base.outline, &bbox );
-
- bbox.xMin = FT_PIX_FLOOR( bbox.xMin );
- bbox.yMin = FT_PIX_FLOOR( bbox.yMin );
- bbox.xMax = FT_PIX_CEIL( bbox.xMax );
- bbox.yMax = FT_PIX_CEIL( bbox.yMax );
-
- slot->metrics.width = bbox.xMax - bbox.xMin;
- slot->metrics.height = bbox.yMax - bbox.yMin;
- slot->metrics.horiBearingX = bbox.xMin;
- slot->metrics.horiBearingY = bbox.yMax;
-
- slot->metrics.vertBearingX = FT_PIX_FLOOR( bbox.xMin + vvector.x );
- slot->metrics.vertBearingY = FT_PIX_FLOOR( bbox.yMax + vvector.y );
-
- /* for mono-width fonts (like Andale, Courier, etc.) we need */
- /* to keep the original rounded advance width; ditto for */
- /* digits if all have the same advance width */
- if ( scaler.render_mode != FT_RENDER_MODE_LIGHT &&
- ( FT_IS_FIXED_WIDTH( slot->face ) ||
- ( af_face_globals_is_digit( loader->globals, glyph_index ) &&
- style_metrics->digits_have_same_width ) ) )
- {
- slot->metrics.horiAdvance =
- FT_MulFix( slot->metrics.horiAdvance,
- style_metrics->scaler.x_scale );
-
- /* Set delta values to 0. Otherwise code that uses them is */
- /* going to ruin the fixed advance width. */
- slot->lsb_delta = 0;
- slot->rsb_delta = 0;
- }
- else
- {
- /* non-spacing glyphs must stay as-is */
- if ( slot->metrics.horiAdvance )
- slot->metrics.horiAdvance = loader->pp2.x - loader->pp1.x;
- }
-
- slot->metrics.vertAdvance = FT_MulFix( slot->metrics.vertAdvance,
- style_metrics->scaler.y_scale );
-
- slot->metrics.horiAdvance = FT_PIX_ROUND( slot->metrics.horiAdvance );
- slot->metrics.vertAdvance = FT_PIX_ROUND( slot->metrics.vertAdvance );
-
- slot->format = FT_GLYPH_FORMAT_OUTLINE;
- }
-
- Exit:
- return error;
- }
-
-
- /*
- * Compute amount of font units the face should be emboldened by, in
- * analogy to the CFF driver's `cf2_computeDarkening' function. See there
- * for details of the algorithm.
- *
- * XXX: Currently a crude adaption of the original algorithm. Do better?
- */
- FT_LOCAL_DEF( FT_Fixed )
- af_loader_compute_darkening( AF_Loader loader,
- FT_Face face,
- FT_Pos standard_width )
- {
- AF_Module module = loader->globals->module;
-
- FT_UShort units_per_EM;
- FT_Fixed ppem, em_ratio;
- FT_Fixed stem_width, stem_width_per_1000, scaled_stem, darken_amount;
- FT_Int log_base_2;
- FT_Int x1, y1, x2, y2, x3, y3, x4, y4;
-
-
- ppem = FT_MAX( af_intToFixed( 4 ),
- af_intToFixed( face->size->metrics.x_ppem ) );
- units_per_EM = face->units_per_EM;
-
- em_ratio = FT_DivFix( af_intToFixed( 1000 ),
- af_intToFixed ( units_per_EM ) );
- if ( em_ratio < af_floatToFixed( .01 ) )
- {
- /* If something goes wrong, don't embolden. */
- return 0;
- }
-
- x1 = module->darken_params[0];
- y1 = module->darken_params[1];
- x2 = module->darken_params[2];
- y2 = module->darken_params[3];
- x3 = module->darken_params[4];
- y3 = module->darken_params[5];
- x4 = module->darken_params[6];
- y4 = module->darken_params[7];
-
- if ( standard_width <= 0 )
- {
- stem_width = af_intToFixed( 75 ); /* taken from cf2font.c */
- stem_width_per_1000 = stem_width;
- }
- else
- {
- stem_width = af_intToFixed( standard_width );
- stem_width_per_1000 = FT_MulFix( stem_width, em_ratio );
- }
-
- log_base_2 = FT_MSB( (FT_UInt32)stem_width_per_1000 ) +
- FT_MSB( (FT_UInt32)ppem );
-
- if ( log_base_2 >= 46 )
- {
- /* possible overflow */
- scaled_stem = af_intToFixed( x4 );
- }
- else
- scaled_stem = FT_MulFix( stem_width_per_1000, ppem );
-
- /* now apply the darkening parameters */
- if ( scaled_stem < af_intToFixed( x1 ) )
- darken_amount = FT_DivFix( af_intToFixed( y1 ), ppem );
-
- else if ( scaled_stem < af_intToFixed( x2 ) )
- {
- FT_Int xdelta = x2 - x1;
- FT_Int ydelta = y2 - y1;
- FT_Int x = stem_width_per_1000 -
- FT_DivFix( af_intToFixed( x1 ), ppem );
-
-
- if ( !xdelta )
- goto Try_x3;
-
- darken_amount = FT_MulDiv( x, ydelta, xdelta ) +
- FT_DivFix( af_intToFixed( y1 ), ppem );
- }
-
- else if ( scaled_stem < af_intToFixed( x3 ) )
- {
- Try_x3:
- {
- FT_Int xdelta = x3 - x2;
- FT_Int ydelta = y3 - y2;
- FT_Int x = stem_width_per_1000 -
- FT_DivFix( af_intToFixed( x2 ), ppem );
-
-
- if ( !xdelta )
- goto Try_x4;
-
- darken_amount = FT_MulDiv( x, ydelta, xdelta ) +
- FT_DivFix( af_intToFixed( y2 ), ppem );
- }
- }
-
- else if ( scaled_stem < af_intToFixed( x4 ) )
- {
- Try_x4:
- {
- FT_Int xdelta = x4 - x3;
- FT_Int ydelta = y4 - y3;
- FT_Int x = stem_width_per_1000 -
- FT_DivFix( af_intToFixed( x3 ), ppem );
-
-
- if ( !xdelta )
- goto Use_y4;
-
- darken_amount = FT_MulDiv( x, ydelta, xdelta ) +
- FT_DivFix( af_intToFixed( y3 ), ppem );
- }
- }
-
- else
- {
- Use_y4:
- darken_amount = FT_DivFix( af_intToFixed( y4 ), ppem );
- }
-
- /* Convert darken_amount from per 1000 em to true character space. */
- return FT_DivFix( darken_amount, em_ratio );
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/autofit/afloader.h b/contrib/libs/freetype/src/autofit/afloader.h
deleted file mode 100644
index 99f0e15f92..0000000000
--- a/contrib/libs/freetype/src/autofit/afloader.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/****************************************************************************
- *
- * afloader.h
- *
- * Auto-fitter glyph loading routines (specification).
- *
- * Copyright (C) 2003-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef AFLOADER_H_
-#define AFLOADER_H_
-
-#include "afhints.h"
-#include "afmodule.h"
-#include "afglobal.h"
-
-
-FT_BEGIN_HEADER
-
- /*
- * The autofitter module's (global) data structure to communicate with
- * actual fonts. If necessary, `local' data like the current face, the
- * current face's auto-hint data, or the current glyph's parameters
- * relevant to auto-hinting are `swapped in'. Cf. functions like
- * `af_loader_reset' and `af_loader_load_g'.
- */
-
- typedef struct AF_LoaderRec_
- {
- /* current face data */
- FT_Face face;
- AF_FaceGlobals globals;
-
- /* current glyph data */
- AF_GlyphHints hints;
- AF_StyleMetrics metrics;
- FT_Bool transformed;
- FT_Matrix trans_matrix;
- FT_Vector trans_delta;
- FT_Vector pp1;
- FT_Vector pp2;
- /* we don't handle vertical phantom points */
-
- } AF_LoaderRec, *AF_Loader;
-
-
- FT_LOCAL( void )
- af_loader_init( AF_Loader loader,
- AF_GlyphHints hints );
-
-
- FT_LOCAL( FT_Error )
- af_loader_reset( AF_Loader loader,
- AF_Module module,
- FT_Face face );
-
-
- FT_LOCAL( void )
- af_loader_done( AF_Loader loader );
-
-
- FT_LOCAL( FT_Error )
- af_loader_load_glyph( AF_Loader loader,
- AF_Module module,
- FT_Face face,
- FT_UInt gindex,
- FT_Int32 load_flags );
-
- FT_LOCAL( FT_Fixed )
- af_loader_compute_darkening( AF_Loader loader,
- FT_Face face,
- FT_Pos standard_width );
-
-/* */
-
-
-FT_END_HEADER
-
-#endif /* AFLOADER_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/autofit/afmodule.c b/contrib/libs/freetype/src/autofit/afmodule.c
deleted file mode 100644
index 726f6ca2b7..0000000000
--- a/contrib/libs/freetype/src/autofit/afmodule.c
+++ /dev/null
@@ -1,527 +0,0 @@
-/****************************************************************************
- *
- * afmodule.c
- *
- * Auto-fitter module implementation (body).
- *
- * Copyright (C) 2003-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include "afglobal.h"
-#include "afmodule.h"
-#include "afloader.h"
-#include "aferrors.h"
-
-#ifdef FT_DEBUG_AUTOFIT
-
-#ifndef FT_MAKE_OPTION_SINGLE_OBJECT
-
-#ifdef __cplusplus
- extern "C" {
-#endif
- extern void
- af_glyph_hints_dump_segments( AF_GlyphHints hints,
- FT_Bool to_stdout );
- extern void
- af_glyph_hints_dump_points( AF_GlyphHints hints,
- FT_Bool to_stdout );
- extern void
- af_glyph_hints_dump_edges( AF_GlyphHints hints,
- FT_Bool to_stdout );
-#ifdef __cplusplus
- }
-#endif
-
-#endif
-
- int af_debug_disable_horz_hints_;
- int af_debug_disable_vert_hints_;
- int af_debug_disable_blue_hints_;
-
- /* we use a global object instead of a local one for debugging */
- static AF_GlyphHintsRec af_debug_hints_rec_[1];
-
- void* af_debug_hints_ = af_debug_hints_rec_;
-#endif
-
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/ftdebug.h>
-#include <freetype/ftdriver.h>
-#include <freetype/internal/services/svprop.h>
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT afmodule
-
-
- static FT_Error
- af_property_get_face_globals( FT_Face face,
- AF_FaceGlobals* aglobals,
- AF_Module module )
- {
- FT_Error error = FT_Err_Ok;
- AF_FaceGlobals globals;
-
-
- if ( !face )
- return FT_THROW( Invalid_Face_Handle );
-
- globals = (AF_FaceGlobals)face->autohint.data;
- if ( !globals )
- {
- /* trigger computation of the global style data */
- /* in case it hasn't been done yet */
- error = af_face_globals_new( face, &globals, module );
- if ( !error )
- {
- face->autohint.data = (FT_Pointer)globals;
- face->autohint.finalizer = af_face_globals_free;
- }
- }
-
- if ( !error )
- *aglobals = globals;
-
- return error;
- }
-
-
- static FT_Error
- af_property_set( FT_Module ft_module,
- const char* property_name,
- const void* value,
- FT_Bool value_is_string )
- {
- FT_Error error = FT_Err_Ok;
- AF_Module module = (AF_Module)ft_module;
-
-#ifndef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
- FT_UNUSED( value_is_string );
-#endif
-
-
- if ( !ft_strcmp( property_name, "fallback-script" ) )
- {
- AF_Script* fallback_script;
- FT_UInt ss;
-
-
-#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
- if ( value_is_string )
- return FT_THROW( Invalid_Argument );
-#endif
-
- fallback_script = (AF_Script*)value;
-
- /* We translate the fallback script to a fallback style that uses */
- /* `fallback-script' as its script and `AF_COVERAGE_NONE' as its */
- /* coverage value. */
- for ( ss = 0; af_style_classes[ss]; ss++ )
- {
- AF_StyleClass style_class = af_style_classes[ss];
-
-
- if ( style_class->script == *fallback_script &&
- style_class->coverage == AF_COVERAGE_DEFAULT )
- {
- module->fallback_style = ss;
- break;
- }
- }
-
- if ( !af_style_classes[ss] )
- {
- FT_TRACE2(( "af_property_set: Invalid value %d for property `%s'\n",
- *fallback_script, property_name ));
- return FT_THROW( Invalid_Argument );
- }
-
- return error;
- }
- else if ( !ft_strcmp( property_name, "default-script" ) )
- {
- AF_Script* default_script;
-
-
-#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
- if ( value_is_string )
- return FT_THROW( Invalid_Argument );
-#endif
-
- default_script = (AF_Script*)value;
-
- module->default_script = *default_script;
-
- return error;
- }
- else if ( !ft_strcmp( property_name, "increase-x-height" ) )
- {
- FT_Prop_IncreaseXHeight* prop;
- AF_FaceGlobals globals;
-
-
-#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
- if ( value_is_string )
- return FT_THROW( Invalid_Argument );
-#endif
-
- prop = (FT_Prop_IncreaseXHeight*)value;
-
- error = af_property_get_face_globals( prop->face, &globals, module );
- if ( !error )
- globals->increase_x_height = prop->limit;
-
- return error;
- }
- else if ( !ft_strcmp( property_name, "darkening-parameters" ) )
- {
- FT_Int* darken_params;
- FT_Int x1, y1, x2, y2, x3, y3, x4, y4;
-
-#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
- FT_Int dp[8];
-
-
- if ( value_is_string )
- {
- const char* s = (const char*)value;
- char* ep;
- int i;
-
-
- /* eight comma-separated numbers */
- for ( i = 0; i < 7; i++ )
- {
- dp[i] = (FT_Int)ft_strtol( s, &ep, 10 );
- if ( *ep != ',' || s == ep )
- return FT_THROW( Invalid_Argument );
-
- s = ep + 1;
- }
-
- dp[7] = (FT_Int)ft_strtol( s, &ep, 10 );
- if ( !( *ep == '\0' || *ep == ' ' ) || s == ep )
- return FT_THROW( Invalid_Argument );
-
- darken_params = dp;
- }
- else
-#endif
- darken_params = (FT_Int*)value;
-
- x1 = darken_params[0];
- y1 = darken_params[1];
- x2 = darken_params[2];
- y2 = darken_params[3];
- x3 = darken_params[4];
- y3 = darken_params[5];
- x4 = darken_params[6];
- y4 = darken_params[7];
-
- if ( x1 < 0 || x2 < 0 || x3 < 0 || x4 < 0 ||
- y1 < 0 || y2 < 0 || y3 < 0 || y4 < 0 ||
- x1 > x2 || x2 > x3 || x3 > x4 ||
- y1 > 500 || y2 > 500 || y3 > 500 || y4 > 500 )
- return FT_THROW( Invalid_Argument );
-
- module->darken_params[0] = x1;
- module->darken_params[1] = y1;
- module->darken_params[2] = x2;
- module->darken_params[3] = y2;
- module->darken_params[4] = x3;
- module->darken_params[5] = y3;
- module->darken_params[6] = x4;
- module->darken_params[7] = y4;
-
- return error;
- }
- else if ( !ft_strcmp( property_name, "no-stem-darkening" ) )
- {
-#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
- if ( value_is_string )
- {
- const char* s = (const char*)value;
- long nsd = ft_strtol( s, NULL, 10 );
-
-
- if ( !nsd )
- module->no_stem_darkening = FALSE;
- else
- module->no_stem_darkening = TRUE;
- }
- else
-#endif
- {
- FT_Bool* no_stem_darkening = (FT_Bool*)value;
-
-
- module->no_stem_darkening = *no_stem_darkening;
- }
-
- return error;
- }
-
- FT_TRACE2(( "af_property_set: missing property `%s'\n",
- property_name ));
- return FT_THROW( Missing_Property );
- }
-
-
- static FT_Error
- af_property_get( FT_Module ft_module,
- const char* property_name,
- void* value )
- {
- FT_Error error = FT_Err_Ok;
- AF_Module module = (AF_Module)ft_module;
-
-
- if ( !ft_strcmp( property_name, "glyph-to-script-map" ) )
- {
- FT_Prop_GlyphToScriptMap* prop = (FT_Prop_GlyphToScriptMap*)value;
- AF_FaceGlobals globals;
-
-
- error = af_property_get_face_globals( prop->face, &globals, module );
- if ( !error )
- prop->map = globals->glyph_styles;
-
- return error;
- }
- else if ( !ft_strcmp( property_name, "fallback-script" ) )
- {
- AF_Script* val = (AF_Script*)value;
-
- AF_StyleClass style_class = af_style_classes[module->fallback_style];
-
-
- *val = style_class->script;
-
- return error;
- }
- else if ( !ft_strcmp( property_name, "default-script" ) )
- {
- AF_Script* val = (AF_Script*)value;
-
-
- *val = module->default_script;
-
- return error;
- }
- else if ( !ft_strcmp( property_name, "increase-x-height" ) )
- {
- FT_Prop_IncreaseXHeight* prop = (FT_Prop_IncreaseXHeight*)value;
- AF_FaceGlobals globals;
-
-
- error = af_property_get_face_globals( prop->face, &globals, module );
- if ( !error )
- prop->limit = globals->increase_x_height;
-
- return error;
- }
- else if ( !ft_strcmp( property_name, "darkening-parameters" ) )
- {
- FT_Int* darken_params = module->darken_params;
- FT_Int* val = (FT_Int*)value;
-
-
- val[0] = darken_params[0];
- val[1] = darken_params[1];
- val[2] = darken_params[2];
- val[3] = darken_params[3];
- val[4] = darken_params[4];
- val[5] = darken_params[5];
- val[6] = darken_params[6];
- val[7] = darken_params[7];
-
- return error;
- }
- else if ( !ft_strcmp( property_name, "no-stem-darkening" ) )
- {
- FT_Bool no_stem_darkening = module->no_stem_darkening;
- FT_Bool* val = (FT_Bool*)value;
-
-
- *val = no_stem_darkening;
-
- return error;
- }
-
- FT_TRACE2(( "af_property_get: missing property `%s'\n",
- property_name ));
- return FT_THROW( Missing_Property );
- }
-
-
- FT_DEFINE_SERVICE_PROPERTIESREC(
- af_service_properties,
-
- af_property_set, /* FT_Properties_SetFunc set_property */
- af_property_get /* FT_Properties_GetFunc get_property */
- )
-
-
- FT_DEFINE_SERVICEDESCREC1(
- af_services,
-
- FT_SERVICE_ID_PROPERTIES, &af_service_properties )
-
-
- FT_CALLBACK_DEF( FT_Module_Interface )
- af_get_interface( FT_Module module,
- const char* module_interface )
- {
- FT_UNUSED( module );
-
- return ft_service_list_lookup( af_services, module_interface );
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- af_autofitter_init( FT_Module ft_module ) /* AF_Module */
- {
- AF_Module module = (AF_Module)ft_module;
-
-
- module->fallback_style = AF_STYLE_FALLBACK;
- module->default_script = AF_SCRIPT_DEFAULT;
- module->no_stem_darkening = TRUE;
-
- module->darken_params[0] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1;
- module->darken_params[1] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1;
- module->darken_params[2] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2;
- module->darken_params[3] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2;
- module->darken_params[4] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3;
- module->darken_params[5] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3;
- module->darken_params[6] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4;
- module->darken_params[7] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4;
-
- return FT_Err_Ok;
- }
-
-
- FT_CALLBACK_DEF( void )
- af_autofitter_done( FT_Module ft_module ) /* AF_Module */
- {
- FT_UNUSED( ft_module );
-
-#ifdef FT_DEBUG_AUTOFIT
- if ( af_debug_hints_rec_->memory )
- af_glyph_hints_done( af_debug_hints_rec_ );
-#endif
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- af_autofitter_load_glyph( FT_AutoHinter module_,
- FT_GlyphSlot slot,
- FT_Size size,
- FT_UInt glyph_index,
- FT_Int32 load_flags )
- {
- AF_Module module = (AF_Module)module_;
-
- FT_Error error = FT_Err_Ok;
- FT_Memory memory = module->root.memory;
-
-#ifdef FT_DEBUG_AUTOFIT
-
- /* in debug mode, we use a global object that survives this routine */
-
- AF_GlyphHints hints = af_debug_hints_rec_;
- AF_LoaderRec loader[1];
-
- FT_UNUSED( size );
-
-
- if ( hints->memory )
- af_glyph_hints_done( hints );
-
- af_glyph_hints_init( hints, memory );
- af_loader_init( loader, hints );
-
- error = af_loader_load_glyph( loader, module, slot->face,
- glyph_index, load_flags );
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( ft_trace_levels[FT_TRACE_COMP( FT_COMPONENT )] )
- {
-#endif
- af_glyph_hints_dump_points( hints, 0 );
- af_glyph_hints_dump_segments( hints, 0 );
- af_glyph_hints_dump_edges( hints, 0 );
-#ifdef FT_DEBUG_LEVEL_TRACE
- }
-#endif
-
- af_loader_done( loader );
-
- return error;
-
-#else /* !FT_DEBUG_AUTOFIT */
-
- AF_GlyphHintsRec hints[1];
- AF_LoaderRec loader[1];
-
- FT_UNUSED( size );
-
-
- af_glyph_hints_init( hints, memory );
- af_loader_init( loader, hints );
-
- error = af_loader_load_glyph( loader, module, slot->face,
- glyph_index, load_flags );
-
- af_loader_done( loader );
- af_glyph_hints_done( hints );
-
- return error;
-
-#endif /* !FT_DEBUG_AUTOFIT */
- }
-
-
- FT_DEFINE_AUTOHINTER_INTERFACE(
- af_autofitter_interface,
-
- NULL, /* FT_AutoHinter_GlobalResetFunc reset_face */
- NULL, /* FT_AutoHinter_GlobalGetFunc get_global_hints */
- NULL, /* FT_AutoHinter_GlobalDoneFunc done_global_hints */
- af_autofitter_load_glyph /* FT_AutoHinter_GlyphLoadFunc load_glyph */
- )
-
- FT_DEFINE_MODULE(
- autofit_module_class,
-
- FT_MODULE_HINTER,
- sizeof ( AF_ModuleRec ),
-
- "autofitter",
- 0x10000L, /* version 1.0 of the autofitter */
- 0x20000L, /* requires FreeType 2.0 or above */
-
- (const void*)&af_autofitter_interface,
-
- af_autofitter_init, /* FT_Module_Constructor module_init */
- af_autofitter_done, /* FT_Module_Destructor module_done */
- af_get_interface /* FT_Module_Requester get_interface */
- )
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/autofit/afmodule.h b/contrib/libs/freetype/src/autofit/afmodule.h
deleted file mode 100644
index 91a1abfef1..0000000000
--- a/contrib/libs/freetype/src/autofit/afmodule.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
- *
- * afmodule.h
- *
- * Auto-fitter module implementation (specification).
- *
- * Copyright (C) 2003-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef AFMODULE_H_
-#define AFMODULE_H_
-
-#include <freetype/internal/ftobjs.h>
-#include <freetype/ftmodapi.h>
-
-
-FT_BEGIN_HEADER
-
-
- /*
- * This is the `extended' FT_Module structure that holds the
- * autofitter's global data.
- */
-
- typedef struct AF_ModuleRec_
- {
- FT_ModuleRec root;
-
- FT_UInt fallback_style;
- AF_Script default_script;
- FT_Bool no_stem_darkening;
- FT_Int darken_params[8];
-
- } AF_ModuleRec, *AF_Module;
-
-
-FT_DECLARE_AUTOHINTER_INTERFACE( af_autofitter_interface )
-FT_DECLARE_MODULE( autofit_module_class )
-
-
-FT_END_HEADER
-
-#endif /* AFMODULE_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/autofit/afranges.c b/contrib/libs/freetype/src/autofit/afranges.c
deleted file mode 100644
index 007b432818..0000000000
--- a/contrib/libs/freetype/src/autofit/afranges.c
+++ /dev/null
@@ -1,1072 +0,0 @@
-/****************************************************************************
- *
- * afranges.c
- *
- * Auto-fitter Unicode script ranges (body).
- *
- * Copyright (C) 2013-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include "afranges.h"
-
- /*
- * The algorithm for assigning properties and styles to the `glyph_styles'
- * array is as follows (cf. the implementation in
- * `af_face_globals_compute_style_coverage').
- *
- * Walk over all scripts (as listed in `afscript.h').
- *
- * For a given script, walk over all styles (as listed in `afstyles.h').
- * The order of styles is important and should be as follows.
- *
- * - First come styles based on OpenType features (small caps, for
- * example). Since features rely on glyph indices, thus completely
- * bypassing character codes, no properties are assigned.
- *
- * - Next comes the default style, using the character ranges as defined
- * below. This also assigns properties.
- *
- * Note that there also exist fallback scripts, mainly covering
- * superscript and subscript glyphs of a script that are not present as
- * OpenType features. Fallback scripts are defined below, also
- * assigning properties; they are applied after the corresponding
- * script.
- *
- */
-
-
- /* XXX Check base character ranges again: */
- /* Right now, they are quickly derived by visual inspection. */
- /* I can imagine that fine-tuning is necessary. */
-
- /* for the auto-hinter, a `non-base character' is something that should */
- /* not be affected by blue zones, regardless of whether this is a */
- /* spacing or no-spacing glyph */
-
- /* the `af_xxxx_nonbase_uniranges' ranges must be strict subsets */
- /* of the corresponding `af_xxxx_uniranges' ranges */
-
-
- const AF_Script_UniRangeRec af_adlm_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x1E900, 0x1E95F ), /* Adlam */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_adlm_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x1D944, 0x1E94A ),
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_arab_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x0600, 0x06FF ), /* Arabic */
- AF_UNIRANGE_REC( 0x0750, 0x07FF ), /* Arabic Supplement */
- AF_UNIRANGE_REC( 0x08A0, 0x08FF ), /* Arabic Extended-A */
- AF_UNIRANGE_REC( 0xFB50, 0xFDFF ), /* Arabic Presentation Forms-A */
- AF_UNIRANGE_REC( 0xFE70, 0xFEFF ), /* Arabic Presentation Forms-B */
- AF_UNIRANGE_REC( 0x1EE00, 0x1EEFF ), /* Arabic Mathematical Alphabetic Symbols */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_arab_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x0600, 0x0605 ),
- AF_UNIRANGE_REC( 0x0610, 0x061A ),
- AF_UNIRANGE_REC( 0x064B, 0x065F ),
- AF_UNIRANGE_REC( 0x0670, 0x0670 ),
- AF_UNIRANGE_REC( 0x06D6, 0x06DC ),
- AF_UNIRANGE_REC( 0x06DF, 0x06E4 ),
- AF_UNIRANGE_REC( 0x06E7, 0x06E8 ),
- AF_UNIRANGE_REC( 0x06EA, 0x06ED ),
- AF_UNIRANGE_REC( 0x08D4, 0x08E1 ),
- AF_UNIRANGE_REC( 0x08D3, 0x08FF ),
- AF_UNIRANGE_REC( 0xFBB2, 0xFBC1 ),
- AF_UNIRANGE_REC( 0xFE70, 0xFE70 ),
- AF_UNIRANGE_REC( 0xFE72, 0xFE72 ),
- AF_UNIRANGE_REC( 0xFE74, 0xFE74 ),
- AF_UNIRANGE_REC( 0xFE76, 0xFE76 ),
- AF_UNIRANGE_REC( 0xFE78, 0xFE78 ),
- AF_UNIRANGE_REC( 0xFE7A, 0xFE7A ),
- AF_UNIRANGE_REC( 0xFE7C, 0xFE7C ),
- AF_UNIRANGE_REC( 0xFE7E, 0xFE7E ),
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_armn_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x0530, 0x058F ), /* Armenian */
- AF_UNIRANGE_REC( 0xFB13, 0xFB17 ), /* Alphab. Present. Forms (Armenian) */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_armn_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x0559, 0x055F ),
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_avst_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x10B00, 0x10B3F ), /* Avestan */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_avst_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x10B39, 0x10B3F ),
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_bamu_uniranges[] =
- {
- AF_UNIRANGE_REC( 0xA6A0, 0xA6FF ), /* Bamum */
-#if 0
- /* The characters in the Bamum supplement are pictograms, */
- /* not (directly) related to the syllabic Bamum script */
- AF_UNIRANGE_REC( 0x16800, 0x16A3F ), /* Bamum Supplement */
-#endif
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_bamu_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0xA6F0, 0xA6F1 ),
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_beng_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x0980, 0x09FF ), /* Bengali */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_beng_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x0981, 0x0981 ),
- AF_UNIRANGE_REC( 0x09BC, 0x09BC ),
- AF_UNIRANGE_REC( 0x09C1, 0x09C4 ),
- AF_UNIRANGE_REC( 0x09CD, 0x09CD ),
- AF_UNIRANGE_REC( 0x09E2, 0x09E3 ),
- AF_UNIRANGE_REC( 0x09FE, 0x09FE ),
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_buhd_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x1740, 0x175F ), /* Buhid */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_buhd_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x1752, 0x1753 ),
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_cakm_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x11100, 0x1114F ), /* Chakma */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_cakm_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x11100, 0x11102 ),
- AF_UNIRANGE_REC( 0x11127, 0x11134 ),
- AF_UNIRANGE_REC( 0x11146, 0x11146 ),
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_cans_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x1400, 0x167F ), /* Unified Canadian Aboriginal Syllabics */
- AF_UNIRANGE_REC( 0x18B0, 0x18FF ), /* Unified Canadian Aboriginal Syllabics Extended */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_cans_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_cari_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x102A0, 0x102DF ), /* Carian */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_cari_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_cher_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x13A0, 0x13FF ), /* Cherokee */
- AF_UNIRANGE_REC( 0xAB70, 0xABBF ), /* Cherokee Supplement */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_cher_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_copt_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x2C80, 0x2CFF ), /* Coptic */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_copt_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x2CEF, 0x2CF1 ),
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_cprt_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x10800, 0x1083F ), /* Cypriot */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_cprt_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_cyrl_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x0400, 0x04FF ), /* Cyrillic */
- AF_UNIRANGE_REC( 0x0500, 0x052F ), /* Cyrillic Supplement */
- AF_UNIRANGE_REC( 0x2DE0, 0x2DFF ), /* Cyrillic Extended-A */
- AF_UNIRANGE_REC( 0xA640, 0xA69F ), /* Cyrillic Extended-B */
- AF_UNIRANGE_REC( 0x1C80, 0x1C8F ), /* Cyrillic Extended-C */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_cyrl_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x0483, 0x0489 ),
- AF_UNIRANGE_REC( 0x2DE0, 0x2DFF ),
- AF_UNIRANGE_REC( 0xA66F, 0xA67F ),
- AF_UNIRANGE_REC( 0xA69E, 0xA69F ),
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- /* There are some characters in the Devanagari Unicode block that are */
- /* generic to Indic scripts; we omit them so that their presence doesn't */
- /* trigger Devanagari. */
-
- const AF_Script_UniRangeRec af_deva_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x0900, 0x093B ), /* Devanagari */
- /* omitting U+093C nukta */
- AF_UNIRANGE_REC( 0x093D, 0x0950 ), /* ... continued */
- /* omitting U+0951 udatta, U+0952 anudatta */
- AF_UNIRANGE_REC( 0x0953, 0x0963 ), /* ... continued */
- /* omitting U+0964 danda, U+0965 double danda */
- AF_UNIRANGE_REC( 0x0966, 0x097F ), /* ... continued */
- AF_UNIRANGE_REC( 0x20B9, 0x20B9 ), /* (new) Rupee sign */
- AF_UNIRANGE_REC( 0xA8E0, 0xA8FF ), /* Devanagari Extended */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_deva_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x0900, 0x0902 ),
- AF_UNIRANGE_REC( 0x093A, 0x093A ),
- AF_UNIRANGE_REC( 0x0941, 0x0948 ),
- AF_UNIRANGE_REC( 0x094D, 0x094D ),
- AF_UNIRANGE_REC( 0x0953, 0x0957 ),
- AF_UNIRANGE_REC( 0x0962, 0x0963 ),
- AF_UNIRANGE_REC( 0xA8E0, 0xA8F1 ),
- AF_UNIRANGE_REC( 0xA8FF, 0xA8FF ),
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_dsrt_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x10400, 0x1044F ), /* Deseret */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_dsrt_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_ethi_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x1200, 0x137F ), /* Ethiopic */
- AF_UNIRANGE_REC( 0x1380, 0x139F ), /* Ethiopic Supplement */
- AF_UNIRANGE_REC( 0x2D80, 0x2DDF ), /* Ethiopic Extended */
- AF_UNIRANGE_REC( 0xAB00, 0xAB2F ), /* Ethiopic Extended-A */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_ethi_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x135D, 0x135F ),
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_geor_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x10D0, 0x10FF ), /* Georgian (Mkhedruli) */
- AF_UNIRANGE_REC( 0x1C90, 0x1CBF ), /* Georgian Extended (Mtavruli) */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_geor_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_geok_uniranges[] =
- {
- /* Khutsuri */
- AF_UNIRANGE_REC( 0x10A0, 0x10CD ), /* Georgian (Asomtavruli) */
- AF_UNIRANGE_REC( 0x2D00, 0x2D2D ), /* Georgian Supplement (Nuskhuri) */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_geok_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_glag_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x2C00, 0x2C5F ), /* Glagolitic */
- AF_UNIRANGE_REC( 0x1E000, 0x1E02F ), /* Glagolitic Supplement */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_glag_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x1E000, 0x1E02F ),
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_goth_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x10330, 0x1034F ), /* Gothic */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_goth_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_grek_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x0370, 0x03FF ), /* Greek and Coptic */
- AF_UNIRANGE_REC( 0x1F00, 0x1FFF ), /* Greek Extended */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_grek_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x037A, 0x037A ),
- AF_UNIRANGE_REC( 0x0384, 0x0385 ),
- AF_UNIRANGE_REC( 0x1FBD, 0x1FC1 ),
- AF_UNIRANGE_REC( 0x1FCD, 0x1FCF ),
- AF_UNIRANGE_REC( 0x1FDD, 0x1FDF ),
- AF_UNIRANGE_REC( 0x1FED, 0x1FEF ),
- AF_UNIRANGE_REC( 0x1FFD, 0x1FFE ),
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_gujr_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x0A80, 0x0AFF ), /* Gujarati */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_gujr_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x0A81, 0x0A82 ),
- AF_UNIRANGE_REC( 0x0ABC, 0x0ABC ),
- AF_UNIRANGE_REC( 0x0AC1, 0x0AC8 ),
- AF_UNIRANGE_REC( 0x0ACD, 0x0ACD ),
- AF_UNIRANGE_REC( 0x0AE2, 0x0AE3 ),
- AF_UNIRANGE_REC( 0x0AFA, 0x0AFF ),
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_guru_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x0A00, 0x0A7F ), /* Gurmukhi */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_guru_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x0A01, 0x0A02 ),
- AF_UNIRANGE_REC( 0x0A3C, 0x0A3C ),
- AF_UNIRANGE_REC( 0x0A41, 0x0A51 ),
- AF_UNIRANGE_REC( 0x0A70, 0x0A71 ),
- AF_UNIRANGE_REC( 0x0A75, 0x0A75 ),
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_hebr_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x0590, 0x05FF ), /* Hebrew */
- AF_UNIRANGE_REC( 0xFB1D, 0xFB4F ), /* Alphab. Present. Forms (Hebrew) */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_hebr_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x0591, 0x05BF ),
- AF_UNIRANGE_REC( 0x05C1, 0x05C2 ),
- AF_UNIRANGE_REC( 0x05C4, 0x05C5 ),
- AF_UNIRANGE_REC( 0x05C7, 0x05C7 ),
- AF_UNIRANGE_REC( 0xFB1E, 0xFB1E ),
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_kali_uniranges[] =
- {
- AF_UNIRANGE_REC( 0xA900, 0xA92F ), /* Kayah Li */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_kali_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0xA926, 0xA92D ),
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_knda_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x0C80, 0x0CFF ), /* Kannada */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_knda_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x0C81, 0x0C81 ),
- AF_UNIRANGE_REC( 0x0CBC, 0x0CBC ),
- AF_UNIRANGE_REC( 0x0CBF, 0x0CBF ),
- AF_UNIRANGE_REC( 0x0CC6, 0x0CC6 ),
- AF_UNIRANGE_REC( 0x0CCC, 0x0CCD ),
- AF_UNIRANGE_REC( 0x0CE2, 0x0CE3 ),
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_khmr_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x1780, 0x17FF ), /* Khmer */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_khmr_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x17B7, 0x17BD ),
- AF_UNIRANGE_REC( 0x17C6, 0x17C6 ),
- AF_UNIRANGE_REC( 0x17C9, 0x17D3 ),
- AF_UNIRANGE_REC( 0x17DD, 0x17DD ),
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_khms_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x19E0, 0x19FF ), /* Khmer Symbols */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_khms_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_lao_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x0E80, 0x0EFF ), /* Lao */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_lao_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x0EB1, 0x0EB1 ),
- AF_UNIRANGE_REC( 0x0EB4, 0x0EBC ),
- AF_UNIRANGE_REC( 0x0EC8, 0x0ECD ),
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_latn_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x0020, 0x007F ), /* Basic Latin (no control chars) */
- AF_UNIRANGE_REC( 0x00A0, 0x00A9 ), /* Latin-1 Supplement (no control chars) */
- AF_UNIRANGE_REC( 0x00AB, 0x00B1 ), /* ... continued */
- AF_UNIRANGE_REC( 0x00B4, 0x00B8 ), /* ... continued */
- AF_UNIRANGE_REC( 0x00BB, 0x00FF ), /* ... continued */
- AF_UNIRANGE_REC( 0x0100, 0x017F ), /* Latin Extended-A */
- AF_UNIRANGE_REC( 0x0180, 0x024F ), /* Latin Extended-B */
- AF_UNIRANGE_REC( 0x0250, 0x02AF ), /* IPA Extensions */
- AF_UNIRANGE_REC( 0x02B9, 0x02DF ), /* Spacing Modifier Letters */
- AF_UNIRANGE_REC( 0x02E5, 0x02FF ), /* ... continued */
- AF_UNIRANGE_REC( 0x0300, 0x036F ), /* Combining Diacritical Marks */
- AF_UNIRANGE_REC( 0x1AB0, 0x1ABE ), /* Combining Diacritical Marks Extended */
- AF_UNIRANGE_REC( 0x1D00, 0x1D2B ), /* Phonetic Extensions */
- AF_UNIRANGE_REC( 0x1D6B, 0x1D77 ), /* ... continued */
- AF_UNIRANGE_REC( 0x1D79, 0x1D7F ), /* ... continued */
- AF_UNIRANGE_REC( 0x1D80, 0x1D9A ), /* Phonetic Extensions Supplement */
- AF_UNIRANGE_REC( 0x1DC0, 0x1DFF ), /* Combining Diacritical Marks Supplement */
- AF_UNIRANGE_REC( 0x1E00, 0x1EFF ), /* Latin Extended Additional */
- AF_UNIRANGE_REC( 0x2000, 0x206F ), /* General Punctuation */
- AF_UNIRANGE_REC( 0x20A0, 0x20B8 ), /* Currency Symbols ... */
- AF_UNIRANGE_REC( 0x20BA, 0x20CF ), /* ... except new Rupee sign */
- AF_UNIRANGE_REC( 0x2150, 0x218F ), /* Number Forms */
- AF_UNIRANGE_REC( 0x2C60, 0x2C7B ), /* Latin Extended-C */
- AF_UNIRANGE_REC( 0x2C7E, 0x2C7F ), /* ... continued */
- AF_UNIRANGE_REC( 0x2E00, 0x2E7F ), /* Supplemental Punctuation */
- AF_UNIRANGE_REC( 0xA720, 0xA76F ), /* Latin Extended-D */
- AF_UNIRANGE_REC( 0xA771, 0xA7F7 ), /* ... continued */
- AF_UNIRANGE_REC( 0xA7FA, 0xA7FF ), /* ... continued */
- AF_UNIRANGE_REC( 0xAB30, 0xAB5B ), /* Latin Extended-E */
- AF_UNIRANGE_REC( 0xAB60, 0xAB6F ), /* ... continued */
- AF_UNIRANGE_REC( 0xFB00, 0xFB06 ), /* Alphab. Present. Forms (Latin Ligs) */
- AF_UNIRANGE_REC( 0x1D400, 0x1D7FF ), /* Mathematical Alphanumeric Symbols */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_latn_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x005E, 0x0060 ),
- AF_UNIRANGE_REC( 0x007E, 0x007E ),
- AF_UNIRANGE_REC( 0x00A8, 0x00A9 ),
- AF_UNIRANGE_REC( 0x00AE, 0x00B0 ),
- AF_UNIRANGE_REC( 0x00B4, 0x00B4 ),
- AF_UNIRANGE_REC( 0x00B8, 0x00B8 ),
- AF_UNIRANGE_REC( 0x00BC, 0x00BE ),
- AF_UNIRANGE_REC( 0x02B9, 0x02DF ),
- AF_UNIRANGE_REC( 0x02E5, 0x02FF ),
- AF_UNIRANGE_REC( 0x0300, 0x036F ),
- AF_UNIRANGE_REC( 0x1AB0, 0x1ABE ),
- AF_UNIRANGE_REC( 0x1DC0, 0x1DFF ),
- AF_UNIRANGE_REC( 0x2017, 0x2017 ),
- AF_UNIRANGE_REC( 0x203E, 0x203E ),
- AF_UNIRANGE_REC( 0xA788, 0xA788 ),
- AF_UNIRANGE_REC( 0xA7F8, 0xA7FA ),
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_latb_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x1D62, 0x1D6A ), /* some small subscript letters */
- AF_UNIRANGE_REC( 0x2080, 0x209C ), /* subscript digits and letters */
- AF_UNIRANGE_REC( 0x2C7C, 0x2C7C ), /* latin subscript small letter j */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_latb_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_latp_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x00AA, 0x00AA ), /* feminine ordinal indicator */
- AF_UNIRANGE_REC( 0x00B2, 0x00B3 ), /* superscript two and three */
- AF_UNIRANGE_REC( 0x00B9, 0x00BA ), /* superscript one, masc. ord. indic. */
- AF_UNIRANGE_REC( 0x02B0, 0x02B8 ), /* some latin superscript mod. letters */
- AF_UNIRANGE_REC( 0x02E0, 0x02E4 ), /* some IPA modifier letters */
- AF_UNIRANGE_REC( 0x1D2C, 0x1D61 ), /* latin superscript modifier letters */
- AF_UNIRANGE_REC( 0x1D78, 0x1D78 ), /* modifier letter cyrillic en */
- AF_UNIRANGE_REC( 0x1D9B, 0x1DBF ), /* more modifier letters */
- AF_UNIRANGE_REC( 0x2070, 0x207F ), /* superscript digits and letters */
- AF_UNIRANGE_REC( 0x2C7D, 0x2C7D ), /* modifier letter capital v */
- AF_UNIRANGE_REC( 0xA770, 0xA770 ), /* modifier letter us */
- AF_UNIRANGE_REC( 0xA7F8, 0xA7F9 ), /* more modifier letters */
- AF_UNIRANGE_REC( 0xAB5C, 0xAB5F ), /* more modifier letters */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_latp_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_lisu_uniranges[] =
- {
- AF_UNIRANGE_REC( 0xA4D0, 0xA4FF ), /* Lisu */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_lisu_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_mlym_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x0D00, 0x0D7F ), /* Malayalam */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_mlym_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x0D00, 0x0D01 ),
- AF_UNIRANGE_REC( 0x0D3B, 0x0D3C ),
- AF_UNIRANGE_REC( 0x0D4D, 0x0D4E ),
- AF_UNIRANGE_REC( 0x0D62, 0x0D63 ),
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_medf_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x16E40, 0x16E9F ), /* Medefaidrin */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_medf_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_mong_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x1800, 0x18AF ), /* Mongolian */
- AF_UNIRANGE_REC( 0x11660, 0x1167F ), /* Mongolian Supplement */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_mong_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x1885, 0x1886 ),
- AF_UNIRANGE_REC( 0x18A9, 0x18A9 ),
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_mymr_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x1000, 0x109F ), /* Myanmar */
- AF_UNIRANGE_REC( 0xA9E0, 0xA9FF ), /* Myanmar Extended-B */
- AF_UNIRANGE_REC( 0xAA60, 0xAA7F ), /* Myanmar Extended-A */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_mymr_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x102D, 0x1030 ),
- AF_UNIRANGE_REC( 0x1032, 0x1037 ),
- AF_UNIRANGE_REC( 0x103A, 0x103A ),
- AF_UNIRANGE_REC( 0x103D, 0x103E ),
- AF_UNIRANGE_REC( 0x1058, 0x1059 ),
- AF_UNIRANGE_REC( 0x105E, 0x1060 ),
- AF_UNIRANGE_REC( 0x1071, 0x1074 ),
- AF_UNIRANGE_REC( 0x1082, 0x1082 ),
- AF_UNIRANGE_REC( 0x1085, 0x1086 ),
- AF_UNIRANGE_REC( 0x108D, 0x108D ),
- AF_UNIRANGE_REC( 0xA9E5, 0xA9E5 ),
- AF_UNIRANGE_REC( 0xAA7C, 0xAA7C ),
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_nkoo_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x07C0, 0x07FF ), /* N'Ko */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_nkoo_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x07EB, 0x07F5 ),
- AF_UNIRANGE_REC( 0x07FD, 0x07FD ),
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_none_uniranges[] =
- {
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_none_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_olck_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x1C50, 0x1C7F ), /* Ol Chiki */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_olck_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_orkh_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x10C00, 0x10C4F ), /* Old Turkic */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_orkh_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_osge_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x104B0, 0x104FF ), /* Osage */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_osge_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_osma_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x10480, 0x104AF ), /* Osmanya */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_osma_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_rohg_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x10D00, 0x10D3F ), /* Hanifi Rohingya */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_rohg_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_saur_uniranges[] =
- {
- AF_UNIRANGE_REC( 0xA880, 0xA8DF ), /* Saurashtra */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_saur_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0xA880, 0xA881 ),
- AF_UNIRANGE_REC( 0xA8B4, 0xA8C5 ),
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_shaw_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x10450, 0x1047F ), /* Shavian */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_shaw_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_sinh_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x0D80, 0x0DFF ), /* Sinhala */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_sinh_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x0DCA, 0x0DCA ),
- AF_UNIRANGE_REC( 0x0DD2, 0x0DD6 ),
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_sund_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x1B80, 0x1BBF ), /* Sundanese */
- AF_UNIRANGE_REC( 0x1CC0, 0x1CCF ), /* Sundanese Supplement */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_sund_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x1B80, 0x1B82 ),
- AF_UNIRANGE_REC( 0x1BA1, 0x1BAD ),
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_taml_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x0B80, 0x0BFF ), /* Tamil */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_taml_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x0B82, 0x0B82 ),
- AF_UNIRANGE_REC( 0x0BC0, 0x0BC2 ),
- AF_UNIRANGE_REC( 0x0BCD, 0x0BCD ),
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_tavt_uniranges[] =
- {
- AF_UNIRANGE_REC( 0xAA80, 0xAADF ), /* Tai Viet */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_tavt_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0xAAB0, 0xAAB0 ),
- AF_UNIRANGE_REC( 0xAAB2, 0xAAB4 ),
- AF_UNIRANGE_REC( 0xAAB7, 0xAAB8 ),
- AF_UNIRANGE_REC( 0xAABE, 0xAABF ),
- AF_UNIRANGE_REC( 0xAAC1, 0xAAC1 ),
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_telu_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x0C00, 0x0C7F ), /* Telugu */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_telu_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x0C00, 0x0C00 ),
- AF_UNIRANGE_REC( 0x0C04, 0x0C04 ),
- AF_UNIRANGE_REC( 0x0C3E, 0x0C40 ),
- AF_UNIRANGE_REC( 0x0C46, 0x0C56 ),
- AF_UNIRANGE_REC( 0x0C62, 0x0C63 ),
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_thai_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x0E00, 0x0E7F ), /* Thai */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_thai_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x0E31, 0x0E31 ),
- AF_UNIRANGE_REC( 0x0E34, 0x0E3A ),
- AF_UNIRANGE_REC( 0x0E47, 0x0E4E ),
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_tfng_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x2D30, 0x2D7F ), /* Tifinagh */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_tfng_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_vaii_uniranges[] =
- {
- AF_UNIRANGE_REC( 0xA500, 0xA63F ), /* Vai */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_vaii_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
-#ifdef AF_CONFIG_OPTION_INDIC
-
- const AF_Script_UniRangeRec af_limb_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x1900, 0x194F ), /* Limbu */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_limb_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x1920, 0x1922 ),
- AF_UNIRANGE_REC( 0x1927, 0x1934 ),
- AF_UNIRANGE_REC( 0x1937, 0x193B ),
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_orya_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x0B00, 0x0B7F ), /* Oriya */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_orya_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x0B01, 0x0B02 ),
- AF_UNIRANGE_REC( 0x0B3C, 0x0B3C ),
- AF_UNIRANGE_REC( 0x0B3F, 0x0B3F ),
- AF_UNIRANGE_REC( 0x0B41, 0x0B44 ),
- AF_UNIRANGE_REC( 0x0B4D, 0x0B56 ),
- AF_UNIRANGE_REC( 0x0B62, 0x0B63 ),
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_sylo_uniranges[] =
- {
- AF_UNIRANGE_REC( 0xA800, 0xA82F ), /* Syloti Nagri */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_sylo_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0xA802, 0xA802 ),
- AF_UNIRANGE_REC( 0xA806, 0xA806 ),
- AF_UNIRANGE_REC( 0xA80B, 0xA80B ),
- AF_UNIRANGE_REC( 0xA825, 0xA826 ),
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-
- const AF_Script_UniRangeRec af_tibt_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x0F00, 0x0FFF ), /* Tibetan */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_tibt_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x0F18, 0x0F19 ),
- AF_UNIRANGE_REC( 0x0F35, 0x0F35 ),
- AF_UNIRANGE_REC( 0x0F37, 0x0F37 ),
- AF_UNIRANGE_REC( 0x0F39, 0x0F39 ),
- AF_UNIRANGE_REC( 0x0F3E, 0x0F3F ),
- AF_UNIRANGE_REC( 0x0F71, 0x0F7E ),
- AF_UNIRANGE_REC( 0x0F80, 0x0F84 ),
- AF_UNIRANGE_REC( 0x0F86, 0x0F87 ),
- AF_UNIRANGE_REC( 0x0F8D, 0x0FBC ),
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-#endif /* !AF_CONFIG_OPTION_INDIC */
-
-#ifdef AF_CONFIG_OPTION_CJK
-
- /* this corresponds to Unicode 6.0 */
-
- const AF_Script_UniRangeRec af_hani_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x1100, 0x11FF ), /* Hangul Jamo */
- AF_UNIRANGE_REC( 0x2E80, 0x2EFF ), /* CJK Radicals Supplement */
- AF_UNIRANGE_REC( 0x2F00, 0x2FDF ), /* Kangxi Radicals */
- AF_UNIRANGE_REC( 0x2FF0, 0x2FFF ), /* Ideographic Description Characters */
- AF_UNIRANGE_REC( 0x3000, 0x303F ), /* CJK Symbols and Punctuation */
- AF_UNIRANGE_REC( 0x3040, 0x309F ), /* Hiragana */
- AF_UNIRANGE_REC( 0x30A0, 0x30FF ), /* Katakana */
- AF_UNIRANGE_REC( 0x3100, 0x312F ), /* Bopomofo */
- AF_UNIRANGE_REC( 0x3130, 0x318F ), /* Hangul Compatibility Jamo */
- AF_UNIRANGE_REC( 0x3190, 0x319F ), /* Kanbun */
- AF_UNIRANGE_REC( 0x31A0, 0x31BF ), /* Bopomofo Extended */
- AF_UNIRANGE_REC( 0x31C0, 0x31EF ), /* CJK Strokes */
- AF_UNIRANGE_REC( 0x31F0, 0x31FF ), /* Katakana Phonetic Extensions */
- AF_UNIRANGE_REC( 0x3300, 0x33FF ), /* CJK Compatibility */
- AF_UNIRANGE_REC( 0x3400, 0x4DBF ), /* CJK Unified Ideographs Extension A */
- AF_UNIRANGE_REC( 0x4DC0, 0x4DFF ), /* Yijing Hexagram Symbols */
- AF_UNIRANGE_REC( 0x4E00, 0x9FFF ), /* CJK Unified Ideographs */
- AF_UNIRANGE_REC( 0xA960, 0xA97F ), /* Hangul Jamo Extended-A */
- AF_UNIRANGE_REC( 0xAC00, 0xD7AF ), /* Hangul Syllables */
- AF_UNIRANGE_REC( 0xD7B0, 0xD7FF ), /* Hangul Jamo Extended-B */
- AF_UNIRANGE_REC( 0xF900, 0xFAFF ), /* CJK Compatibility Ideographs */
- AF_UNIRANGE_REC( 0xFE10, 0xFE1F ), /* Vertical forms */
- AF_UNIRANGE_REC( 0xFE30, 0xFE4F ), /* CJK Compatibility Forms */
- AF_UNIRANGE_REC( 0xFF00, 0xFFEF ), /* Halfwidth and Fullwidth Forms */
- AF_UNIRANGE_REC( 0x1B000, 0x1B0FF ), /* Kana Supplement */
- AF_UNIRANGE_REC( 0x1B100, 0x1B12F ), /* Kana Extended-A */
- AF_UNIRANGE_REC( 0x1D300, 0x1D35F ), /* Tai Xuan Hing Symbols */
- AF_UNIRANGE_REC( 0x20000, 0x2A6DF ), /* CJK Unified Ideographs Extension B */
- AF_UNIRANGE_REC( 0x2A700, 0x2B73F ), /* CJK Unified Ideographs Extension C */
- AF_UNIRANGE_REC( 0x2B740, 0x2B81F ), /* CJK Unified Ideographs Extension D */
- AF_UNIRANGE_REC( 0x2B820, 0x2CEAF ), /* CJK Unified Ideographs Extension E */
- AF_UNIRANGE_REC( 0x2CEB0, 0x2EBEF ), /* CJK Unified Ideographs Extension F */
- AF_UNIRANGE_REC( 0x2F800, 0x2FA1F ), /* CJK Compatibility Ideographs Supplement */
- AF_UNIRANGE_REC( 0, 0 )
- };
-
- const AF_Script_UniRangeRec af_hani_nonbase_uniranges[] =
- {
- AF_UNIRANGE_REC( 0x302A, 0x302F ),
- AF_UNIRANGE_REC( 0x3190, 0x319F ),
- AF_UNIRANGE_REC( 0, 0 )
- };
-
-#endif /* !AF_CONFIG_OPTION_CJK */
-
-/* END */
diff --git a/contrib/libs/freetype/src/autofit/afranges.h b/contrib/libs/freetype/src/autofit/afranges.h
deleted file mode 100644
index 813b3ee78e..0000000000
--- a/contrib/libs/freetype/src/autofit/afranges.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/****************************************************************************
- *
- * afranges.h
- *
- * Auto-fitter Unicode script ranges (specification).
- *
- * Copyright (C) 2013-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef AFRANGES_H_
-#define AFRANGES_H_
-
-
-#include "aftypes.h"
-
-
-FT_BEGIN_HEADER
-
-#undef SCRIPT
-#define SCRIPT( s, S, d, h, H, ss ) \
- extern const AF_Script_UniRangeRec af_ ## s ## _uniranges[];
-
-#include "afscript.h"
-
-#undef SCRIPT
-#define SCRIPT( s, S, d, h, H, ss ) \
- extern const AF_Script_UniRangeRec af_ ## s ## _nonbase_uniranges[];
-
-#include "afscript.h"
-
- /* */
-
-FT_END_HEADER
-
-#endif /* AFRANGES_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/autofit/afscript.h b/contrib/libs/freetype/src/autofit/afscript.h
deleted file mode 100644
index 0a83d77150..0000000000
--- a/contrib/libs/freetype/src/autofit/afscript.h
+++ /dev/null
@@ -1,408 +0,0 @@
-/****************************************************************************
- *
- * afscript.h
- *
- * Auto-fitter scripts (specification only).
- *
- * Copyright (C) 2013-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /* The following part can be included multiple times. */
- /* Define `SCRIPT' as needed. */
-
-
- /* Add new scripts here. The first and second arguments are the */
- /* script name in lowercase and uppercase, respectively, followed */
- /* by a description string. Then comes the corresponding HarfBuzz */
- /* script name tag, followed by a string of standard characters (to */
- /* derive the standard width and height of stems). */
- /* */
- /* Note that fallback scripts only have a default style, thus we */
- /* use `HB_SCRIPT_INVALID' as the HarfBuzz script name tag for */
- /* them. */
-
- SCRIPT( adlm, ADLM,
- "Adlam",
- HB_SCRIPT_ADLAM,
- HINTING_BOTTOM_TO_TOP,
- "\xF0\x9E\xA4\x8C \xF0\x9E\xA4\xAE" ) /* 𞤌 𞤮 */
-
- SCRIPT( arab, ARAB,
- "Arabic",
- HB_SCRIPT_ARABIC,
- HINTING_BOTTOM_TO_TOP,
- "\xD9\x84 \xD8\xAD \xD9\x80" ) /* Ù„ Ø­ Ù€ */
-
- SCRIPT( armn, ARMN,
- "Armenian",
- HB_SCRIPT_ARMENIAN,
- HINTING_BOTTOM_TO_TOP,
- "\xD5\xBD \xD5\x8D" ) /* Õ½ Õ */
-
- SCRIPT( avst, AVST,
- "Avestan",
- HB_SCRIPT_AVESTAN,
- HINTING_BOTTOM_TO_TOP,
- "\xF0\x90\xAC\x9A" ) /* 𬚠*/
-
- SCRIPT( bamu, BAMU,
- "Bamum",
- HB_SCRIPT_BAMUM,
- HINTING_BOTTOM_TO_TOP,
- "\xEA\x9B\x81 \xEA\x9B\xAF" ) /* ê› ê›¯ */
-
- /* there are no simple forms for letters; we thus use two digit shapes */
- SCRIPT( beng, BENG,
- "Bengali",
- HB_SCRIPT_BENGALI,
- HINTING_TOP_TO_BOTTOM,
- "\xE0\xA7\xA6 \xE0\xA7\xAA" ) /* ০ ৪ */
-
- SCRIPT( buhd, BUHD,
- "Buhid",
- HB_SCRIPT_BUHID,
- HINTING_BOTTOM_TO_TOP,
- "\xE1\x9D\x8B \xE1\x9D\x8F" ) /* á‹ á */
-
- SCRIPT( cakm, CAKM,
- "Chakma",
- HB_SCRIPT_CHAKMA,
- HINTING_BOTTOM_TO_TOP,
- "\xF0\x91\x84\xA4 \xF0\x91\x84\x89 \xF0\x91\x84\x9B" ) /* 𑄤 𑄉 𑄛 */
-
- SCRIPT( cans, CANS,
- "Canadian Syllabics",
- HB_SCRIPT_CANADIAN_SYLLABICS,
- HINTING_BOTTOM_TO_TOP,
- "\xE1\x91\x8C \xE1\x93\x9A" ) /* ᑌ ᓚ */
-
- SCRIPT( cari, CARI,
- "Carian",
- HB_SCRIPT_CARIAN,
- HINTING_BOTTOM_TO_TOP,
- "\xF0\x90\x8A\xAB \xF0\x90\x8B\x89" ) /* ðŠ« ð‹‰ */
-
- SCRIPT( cher, CHER,
- "Cherokee",
- HB_SCRIPT_CHEROKEE,
- HINTING_BOTTOM_TO_TOP,
- "\xE1\x8E\xA4 \xE1\x8F\x85 \xEA\xAE\x95" ) /* Ꭴ á… ê®• */
-
- SCRIPT( copt, COPT,
- "Coptic",
- HB_SCRIPT_COPTIC,
- HINTING_BOTTOM_TO_TOP,
- "\xE2\xB2\x9E \xE2\xB2\x9F" ) /* Ⲟ ⲟ */
-
- SCRIPT( cprt, CPRT,
- "Cypriot",
- HB_SCRIPT_CYPRIOT,
- HINTING_BOTTOM_TO_TOP,
- "\xF0\x90\xA0\x85 \xF0\x90\xA0\xA3" ) /* ð … ð £ */
-
- SCRIPT( cyrl, CYRL,
- "Cyrillic",
- HB_SCRIPT_CYRILLIC,
- HINTING_BOTTOM_TO_TOP,
- "\xD0\xBE \xD0\x9E" ) /* о О */
-
- SCRIPT( deva, DEVA,
- "Devanagari",
- HB_SCRIPT_DEVANAGARI,
- HINTING_TOP_TO_BOTTOM,
- "\xE0\xA4\xA0 \xE0\xA4\xB5 \xE0\xA4\x9F" ) /* ठ व ट */
-
- SCRIPT( dsrt, DSRT,
- "Deseret",
- HB_SCRIPT_DESERET,
- HINTING_BOTTOM_TO_TOP,
- "\xF0\x90\x90\x84 \xF0\x90\x90\xAC" ) /* ð„ ð¬ */
-
- SCRIPT( ethi, ETHI,
- "Ethiopic",
- HB_SCRIPT_ETHIOPIC,
- HINTING_BOTTOM_TO_TOP,
- "\xE1\x8B\x90" ) /* á‹ */
-
- SCRIPT( geor, GEOR,
- "Georgian (Mkhedruli)",
- HB_SCRIPT_GEORGIAN,
- HINTING_BOTTOM_TO_TOP,
- "\xE1\x83\x98 \xE1\x83\x94 \xE1\x83\x90 \xE1\xB2\xBF" ) /* ი ე რᲘ */
-
- SCRIPT( geok, GEOK,
- "Georgian (Khutsuri)",
- HB_SCRIPT_INVALID,
- HINTING_BOTTOM_TO_TOP,
- "\xE1\x82\xB6 \xE1\x82\xB1 \xE2\xB4\x99" ) /* Ⴖ Ⴑ ⴙ */
-
- SCRIPT( glag, GLAG,
- "Glagolitic",
- HB_SCRIPT_GLAGOLITIC,
- HINTING_BOTTOM_TO_TOP,
- "\xE2\xB0\x95 \xE2\xB1\x85" ) /* â°• â±… */
-
- SCRIPT( goth, GOTH,
- "Gothic",
- HB_SCRIPT_GOTHIC,
- HINTING_TOP_TO_BOTTOM,
- "\xF0\x90\x8C\xB4 \xF0\x90\x8C\xBE \xF0\x90\x8D\x83" ) /* ðŒ´ ðŒ¾ ðƒ */
-
- SCRIPT( grek, GREK,
- "Greek",
- HB_SCRIPT_GREEK,
- HINTING_BOTTOM_TO_TOP,
- "\xCE\xBF \xCE\x9F" ) /* ο Ο */
-
- SCRIPT( gujr, GUJR,
- "Gujarati",
- HB_SCRIPT_GUJARATI,
- HINTING_BOTTOM_TO_TOP,
- "\xE0\xAA\x9F \xE0\xAB\xA6" ) /* ટ ૦ */
-
- SCRIPT( guru, GURU,
- "Gurmukhi",
- HB_SCRIPT_GURMUKHI,
- HINTING_TOP_TO_BOTTOM,
- "\xE0\xA8\xA0 \xE0\xA8\xB0 \xE0\xA9\xA6" ) /* ਠ ਰ ੦ */
-
- SCRIPT( hebr, HEBR,
- "Hebrew",
- HB_SCRIPT_HEBREW,
- HINTING_BOTTOM_TO_TOP,
- "\xD7\x9D" ) /* × */
-
- SCRIPT( kali, KALI,
- "Kayah Li",
- HB_SCRIPT_KAYAH_LI,
- HINTING_BOTTOM_TO_TOP,
- "\xEA\xA4\x8D \xEA\xA4\x80" ) /* ê¤ ê¤€ */
-
- /* only digit zero has a simple shape in the Khmer script */
- SCRIPT( khmr, KHMR,
- "Khmer",
- HB_SCRIPT_KHMER,
- HINTING_BOTTOM_TO_TOP,
- "\xE1\x9F\xA0" ) /* ០ */
-
- SCRIPT( khms, KHMS,
- "Khmer Symbols",
- HB_SCRIPT_INVALID,
- HINTING_BOTTOM_TO_TOP,
- "\xE1\xA7\xA1 \xE1\xA7\xAA" ) /* ᧡ ᧪ */
-
- SCRIPT( knda, KNDA,
- "Kannada",
- HB_SCRIPT_KANNADA,
- HINTING_BOTTOM_TO_TOP,
- "\xE0\xB3\xA6 \xE0\xB2\xAC" ) /* ೦ ಬ */
-
- /* only digit zero has a simple shape in the Lao script */
- SCRIPT( lao, LAO,
- "Lao",
- HB_SCRIPT_LAO,
- HINTING_BOTTOM_TO_TOP,
- "\xE0\xBB\x90" ) /* à» */
-
- SCRIPT( latn, LATN,
- "Latin",
- HB_SCRIPT_LATIN,
- HINTING_BOTTOM_TO_TOP,
- "o O 0" )
-
- SCRIPT( latb, LATB,
- "Latin Subscript Fallback",
- HB_SCRIPT_INVALID,
- HINTING_BOTTOM_TO_TOP,
- "\xE2\x82\x92 \xE2\x82\x80" ) /* â‚’ â‚€ */
-
- SCRIPT( latp, LATP,
- "Latin Superscript Fallback",
- HB_SCRIPT_INVALID,
- HINTING_BOTTOM_TO_TOP,
- "\xE1\xB5\x92 \xE1\xB4\xBC \xE2\x81\xB0" ) /* áµ’ á´¼ â° */
-
- SCRIPT( lisu, LISU,
- "Lisu",
- HB_SCRIPT_LISU,
- HINTING_BOTTOM_TO_TOP,
- "\xEA\x93\xB3" ) /* ꓳ */
-
- SCRIPT( mlym, MLYM,
- "Malayalam",
- HB_SCRIPT_MALAYALAM,
- HINTING_BOTTOM_TO_TOP,
- "\xE0\xB4\xA0 \xE0\xB4\xB1" ) /* à´  à´± */
-
- SCRIPT( medf, MEDF,
- "Medefaidrin",
- HB_SCRIPT_MEDEFAIDRIN,
- HINTING_BOTTOM_TO_TOP,
- "\xF0\x96\xB9\xA1 \xF0\x96\xB9\x9B \xF0\x96\xB9\xAF" ) /* 𖹡 𖹛 𖹯 */
-
- SCRIPT( mong, MONG,
- "Mongolian",
- HB_SCRIPT_MONGOLIAN,
- HINTING_TOP_TO_BOTTOM,
- "\xE1\xA1\x82 \xE1\xA0\xAA" ) /* á¡‚ á ª */
-
- SCRIPT( mymr, MYMR,
- "Myanmar",
- HB_SCRIPT_MYANMAR,
- HINTING_BOTTOM_TO_TOP,
- "\xE1\x80\x9D \xE1\x80\x84 \xE1\x80\x82" ) /* ဠင ဂ */
-
- SCRIPT( nkoo, NKOO,
- "N'Ko",
- HB_SCRIPT_NKO,
- HINTING_BOTTOM_TO_TOP,
- "\xDF\x8B \xDF\x80" ) /* ߋ ߀ */
-
- SCRIPT( none, NONE,
- "no script",
- HB_SCRIPT_INVALID,
- HINTING_BOTTOM_TO_TOP,
- "" )
-
- SCRIPT( olck, OLCK,
- "Ol Chiki",
- HB_SCRIPT_OL_CHIKI,
- HINTING_BOTTOM_TO_TOP,
- "\xE1\xB1\x9B" ) /* á±› */
-
- SCRIPT( orkh, ORKH,
- "Old Turkic",
- HB_SCRIPT_OLD_TURKIC,
- HINTING_BOTTOM_TO_TOP,
- "\xF0\x90\xB0\x97" ) /* ð°— */
-
- SCRIPT( osge, OSGE,
- "Osage",
- HB_SCRIPT_OSAGE,
- HINTING_BOTTOM_TO_TOP,
- "\xF0\x90\x93\x82 \xF0\x90\x93\xAA" ) /* 𓂠𓪠*/
-
- SCRIPT( osma, OSMA,
- "Osmanya",
- HB_SCRIPT_OSMANYA,
- HINTING_BOTTOM_TO_TOP,
- "\xF0\x90\x92\x86 \xF0\x90\x92\xA0" ) /* ð’† ð’  */
-
- SCRIPT( rohg, ROHG,
- "Hanifi Rohingya",
- HB_SCRIPT_HANIFI_ROHINGYA,
- HINTING_BOTTOM_TO_TOP,
- "\xF0\x90\xB4\xB0" ) /* ð´° */
-
- SCRIPT( saur, SAUR,
- "Saurashtra",
- HB_SCRIPT_SAURASHTRA,
- HINTING_BOTTOM_TO_TOP,
- "\xEA\xA2\x9D \xEA\xA3\x90" ) /* ê¢ ê£ */
-
- SCRIPT( shaw, SHAW,
- "Shavian",
- HB_SCRIPT_SHAVIAN,
- HINTING_BOTTOM_TO_TOP,
- "\xF0\x90\x91\xB4" ) /* ð‘´ */
-
- SCRIPT( sinh, SINH,
- "Sinhala",
- HB_SCRIPT_SINHALA,
- HINTING_BOTTOM_TO_TOP,
- "\xE0\xB6\xA7" ) /* ට */
-
- /* only digit zero has a simple (round) shape in the Sundanese script */
- SCRIPT( sund, SUND,
- "Sundanese",
- HB_SCRIPT_SUNDANESE,
- HINTING_BOTTOM_TO_TOP,
- "\xE1\xAE\xB0" ) /* á®° */
-
- /* only digit zero has a simple (round) shape in the Tamil script */
- SCRIPT( taml, TAML,
- "Tamil",
- HB_SCRIPT_TAMIL,
- HINTING_BOTTOM_TO_TOP,
- "\xE0\xAF\xA6" ) /* ௦ */
-
- SCRIPT( tavt, TAVT,
- "Tai Viet",
- HB_SCRIPT_TAI_VIET,
- HINTING_BOTTOM_TO_TOP,
- "\xEA\xAA\x92 \xEA\xAA\xAB" ) /* ꪒ ꪫ */
-
- /* there are no simple forms for letters; we thus use two digit shapes */
- SCRIPT( telu, TELU,
- "Telugu",
- HB_SCRIPT_TELUGU,
- HINTING_BOTTOM_TO_TOP,
- "\xE0\xB1\xA6 \xE0\xB1\xA7" ) /* ౦ ౧ */
-
- SCRIPT( tfng, TFNG,
- "Tifinagh",
- HB_SCRIPT_TIFINAGH,
- HINTING_BOTTOM_TO_TOP,
- "\xE2\xB5\x94" ) /* âµ” */
-
- SCRIPT( thai, THAI,
- "Thai",
- HB_SCRIPT_THAI,
- HINTING_BOTTOM_TO_TOP,
- "\xE0\xB8\xB2 \xE0\xB9\x85 \xE0\xB9\x90" ) /* า ๅ ๠*/
-
- SCRIPT( vaii, VAII,
- "Vai",
- HB_SCRIPT_VAI,
- HINTING_BOTTOM_TO_TOP,
- "\xEA\x98\x93 \xEA\x96\x9C \xEA\x96\xB4" ) /* ꘓ ꖜ ꖴ */
-
-#ifdef AF_CONFIG_OPTION_INDIC
-
- SCRIPT( limb, LIMB,
- "Limbu",
- HB_SCRIPT_LIMBU,
- HINTING_BOTTOM_TO_TOP,
- "o" ) /* XXX */
-
- SCRIPT( orya, ORYA,
- "Oriya",
- HB_SCRIPT_ORIYA,
- HINTING_BOTTOM_TO_TOP,
- "o" ) /* XXX */
-
- SCRIPT( sylo, SYLO,
- "Syloti Nagri",
- HB_SCRIPT_SYLOTI_NAGRI,
- HINTING_BOTTOM_TO_TOP,
- "o" ) /* XXX */
-
- SCRIPT( tibt, TIBT,
- "Tibetan",
- HB_SCRIPT_TIBETAN,
- HINTING_BOTTOM_TO_TOP,
- "o" ) /* XXX */
-
-#endif /* AF_CONFIG_OPTION_INDIC */
-
-#ifdef AF_CONFIG_OPTION_CJK
-
- SCRIPT( hani, HANI,
- "CJKV ideographs",
- HB_SCRIPT_HAN,
- HINTING_BOTTOM_TO_TOP,
- "\xE7\x94\xB0 \xE5\x9B\x97" ) /* ç”° å›— */
-
-#endif /* AF_CONFIG_OPTION_CJK */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/autofit/afshaper.c b/contrib/libs/freetype/src/autofit/afshaper.c
deleted file mode 100644
index df0f46ada8..0000000000
--- a/contrib/libs/freetype/src/autofit/afshaper.c
+++ /dev/null
@@ -1,690 +0,0 @@
-/****************************************************************************
- *
- * afshaper.c
- *
- * HarfBuzz interface for accessing OpenType features (body).
- *
- * Copyright (C) 2013-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/freetype.h>
-#include <freetype/ftadvanc.h>
-#include "afglobal.h"
-#include "aftypes.h"
-#include "afshaper.h"
-
-#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT afshaper
-
-
- /*
- * We use `sets' (in the HarfBuzz sense, which comes quite near to the
- * usual mathematical meaning) to manage both lookups and glyph indices.
- *
- * 1. For each coverage, collect lookup IDs in a set. Note that an
- * auto-hinter `coverage' is represented by one `feature', and a
- * feature consists of an arbitrary number of (font specific) `lookup's
- * that actually do the mapping job. Please check the OpenType
- * specification for more details on features and lookups.
- *
- * 2. Create glyph ID sets from the corresponding lookup sets.
- *
- * 3. The glyph set corresponding to AF_COVERAGE_DEFAULT is computed
- * with all lookups specific to the OpenType script activated. It
- * relies on the order of AF_DEFINE_STYLE_CLASS entries so that
- * special coverages (like `oldstyle figures') don't get overwritten.
- *
- */
-
-
- /* load coverage tags */
-#undef COVERAGE
-#define COVERAGE( name, NAME, description, \
- tag1, tag2, tag3, tag4 ) \
- static const hb_tag_t name ## _coverage[] = \
- { \
- HB_TAG( tag1, tag2, tag3, tag4 ), \
- HB_TAG_NONE \
- };
-
-
-#include "afcover.h"
-
-
- /* define mapping between coverage tags and AF_Coverage */
-#undef COVERAGE
-#define COVERAGE( name, NAME, description, \
- tag1, tag2, tag3, tag4 ) \
- name ## _coverage,
-
-
- static const hb_tag_t* coverages[] =
- {
-#include "afcover.h"
-
- NULL /* AF_COVERAGE_DEFAULT */
- };
-
-
- /* load HarfBuzz script tags */
-#undef SCRIPT
-#define SCRIPT( s, S, d, h, H, ss ) h,
-
-
- static const hb_script_t scripts[] =
- {
-#include "afscript.h"
- };
-
-
- FT_Error
- af_shaper_get_coverage( AF_FaceGlobals globals,
- AF_StyleClass style_class,
- FT_UShort* gstyles,
- FT_Bool default_script )
- {
- hb_face_t* face;
-
- hb_set_t* gsub_lookups = NULL; /* GSUB lookups for a given script */
- hb_set_t* gsub_glyphs = NULL; /* glyphs covered by GSUB lookups */
- hb_set_t* gpos_lookups = NULL; /* GPOS lookups for a given script */
- hb_set_t* gpos_glyphs = NULL; /* glyphs covered by GPOS lookups */
-
- hb_script_t script;
- const hb_tag_t* coverage_tags;
- hb_tag_t script_tags[] = { HB_TAG_NONE,
- HB_TAG_NONE,
- HB_TAG_NONE,
- HB_TAG_NONE };
-
- hb_codepoint_t idx;
-#ifdef FT_DEBUG_LEVEL_TRACE
- int count;
-#endif
-
-
- if ( !globals || !style_class || !gstyles )
- return FT_THROW( Invalid_Argument );
-
- face = hb_font_get_face( globals->hb_font );
-
- coverage_tags = coverages[style_class->coverage];
- script = scripts[style_class->script];
-
- /* Convert a HarfBuzz script tag into the corresponding OpenType */
- /* tag or tags -- some Indic scripts like Devanagari have an old */
- /* and a new set of features. */
- {
- unsigned int tags_count = 3;
- hb_tag_t tags[3];
-
-
- hb_ot_tags_from_script_and_language( script,
- HB_LANGUAGE_INVALID,
- &tags_count,
- tags,
- NULL,
- NULL );
- script_tags[0] = tags_count > 0 ? tags[0] : HB_TAG_NONE;
- script_tags[1] = tags_count > 1 ? tags[1] : HB_TAG_NONE;
- script_tags[2] = tags_count > 2 ? tags[2] : HB_TAG_NONE;
- }
-
- /* If the second tag is HB_OT_TAG_DEFAULT_SCRIPT, change that to */
- /* HB_TAG_NONE except for the default script. */
- if ( default_script )
- {
- if ( script_tags[0] == HB_TAG_NONE )
- script_tags[0] = HB_OT_TAG_DEFAULT_SCRIPT;
- else
- {
- if ( script_tags[1] == HB_TAG_NONE )
- script_tags[1] = HB_OT_TAG_DEFAULT_SCRIPT;
- else if ( script_tags[1] != HB_OT_TAG_DEFAULT_SCRIPT )
- script_tags[2] = HB_OT_TAG_DEFAULT_SCRIPT;
- }
- }
- else
- {
- /* we use non-standard tags like `khms' for special purposes; */
- /* HarfBuzz maps them to `DFLT', which we don't want to handle here */
- if ( script_tags[0] == HB_OT_TAG_DEFAULT_SCRIPT )
- goto Exit;
- }
-
- gsub_lookups = hb_set_create();
- hb_ot_layout_collect_lookups( face,
- HB_OT_TAG_GSUB,
- script_tags,
- NULL,
- coverage_tags,
- gsub_lookups );
-
- if ( hb_set_is_empty( gsub_lookups ) )
- goto Exit; /* nothing to do */
-
- FT_TRACE4(( "GSUB lookups (style `%s'):\n",
- af_style_names[style_class->style] ));
- FT_TRACE4(( " " ));
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- count = 0;
-#endif
-
- gsub_glyphs = hb_set_create();
- for ( idx = HB_SET_VALUE_INVALID; hb_set_next( gsub_lookups, &idx ); )
- {
-#ifdef FT_DEBUG_LEVEL_TRACE
- FT_TRACE4(( " %d", idx ));
- count++;
-#endif
-
- /* get output coverage of GSUB feature */
- hb_ot_layout_lookup_collect_glyphs( face,
- HB_OT_TAG_GSUB,
- idx,
- NULL,
- NULL,
- NULL,
- gsub_glyphs );
- }
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( !count )
- FT_TRACE4(( " (none)" ));
- FT_TRACE4(( "\n" ));
- FT_TRACE4(( "\n" ));
-#endif
-
- FT_TRACE4(( "GPOS lookups (style `%s'):\n",
- af_style_names[style_class->style] ));
- FT_TRACE4(( " " ));
-
- gpos_lookups = hb_set_create();
- hb_ot_layout_collect_lookups( face,
- HB_OT_TAG_GPOS,
- script_tags,
- NULL,
- coverage_tags,
- gpos_lookups );
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- count = 0;
-#endif
-
- gpos_glyphs = hb_set_create();
- for ( idx = HB_SET_VALUE_INVALID; hb_set_next( gpos_lookups, &idx ); )
- {
-#ifdef FT_DEBUG_LEVEL_TRACE
- FT_TRACE4(( " %d", idx ));
- count++;
-#endif
-
- /* get input coverage of GPOS feature */
- hb_ot_layout_lookup_collect_glyphs( face,
- HB_OT_TAG_GPOS,
- idx,
- NULL,
- gpos_glyphs,
- NULL,
- NULL );
- }
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( !count )
- FT_TRACE4(( " (none)" ));
- FT_TRACE4(( "\n" ));
- FT_TRACE4(( "\n" ));
-#endif
-
- /*
- * We now check whether we can construct blue zones, using glyphs
- * covered by the feature only. In case there is not a single zone
- * (that is, not a single character is covered), we skip this coverage.
- *
- */
- if ( style_class->coverage != AF_COVERAGE_DEFAULT )
- {
- AF_Blue_Stringset bss = style_class->blue_stringset;
- const AF_Blue_StringRec* bs = &af_blue_stringsets[bss];
-
- FT_Bool found = 0;
-
-
- for ( ; bs->string != AF_BLUE_STRING_MAX; bs++ )
- {
- const char* p = &af_blue_strings[bs->string];
-
-
- while ( *p )
- {
- hb_codepoint_t ch;
-
-
- GET_UTF8_CHAR( ch, p );
-
- for ( idx = HB_SET_VALUE_INVALID; hb_set_next( gsub_lookups,
- &idx ); )
- {
- hb_codepoint_t gidx = FT_Get_Char_Index( globals->face, ch );
-
-
- if ( hb_ot_layout_lookup_would_substitute( face, idx,
- &gidx, 1, 1 ) )
- {
- found = 1;
- break;
- }
- }
- }
- }
-
- if ( !found )
- {
- FT_TRACE4(( " no blue characters found; style skipped\n" ));
- goto Exit;
- }
- }
-
- /*
- * Various OpenType features might use the same glyphs at different
- * vertical positions; for example, superscript and subscript glyphs
- * could be the same. However, the auto-hinter is completely
- * agnostic of OpenType features after the feature analysis has been
- * completed: The engine then simply receives a glyph index and returns a
- * hinted and usually rendered glyph.
- *
- * Consider the superscript feature of font `pala.ttf': Some of the
- * glyphs are `real', that is, they have a zero vertical offset, but
- * most of them are small caps glyphs shifted up to the superscript
- * position (that is, the `sups' feature is present in both the GSUB and
- * GPOS tables). The code for blue zones computation actually uses a
- * feature's y offset so that the `real' glyphs get correct hints. But
- * later on it is impossible to decide whether a glyph index belongs to,
- * say, the small caps or superscript feature.
- *
- * For this reason, we don't assign a style to a glyph if the current
- * feature covers the glyph in both the GSUB and the GPOS tables. This
- * is quite a broad condition, assuming that
- *
- * (a) glyphs that get used in multiple features are present in a
- * feature without vertical shift,
- *
- * and
- *
- * (b) a feature's GPOS data really moves the glyph vertically.
- *
- * Not fulfilling condition (a) makes a font larger; it would also
- * reduce the number of glyphs that could be addressed directly without
- * using OpenType features, so this assumption is rather strong.
- *
- * Condition (b) is much weaker, and there might be glyphs which get
- * missed. However, the OpenType features we are going to handle are
- * primarily located in GSUB, and HarfBuzz doesn't provide an API to
- * directly get the necessary information from the GPOS table. A
- * possible solution might be to directly parse the GPOS table to find
- * out whether a glyph gets shifted vertically, but this is something I
- * would like to avoid if not really necessary.
- *
- * Note that we don't follow this logic for the default coverage.
- * Complex scripts like Devanagari have mandatory GPOS features to
- * position many glyph elements, using mark-to-base or mark-to-ligature
- * tables; the number of glyphs missed due to condition (b) would be far
- * too large.
- *
- */
- if ( style_class->coverage != AF_COVERAGE_DEFAULT )
- hb_set_subtract( gsub_glyphs, gpos_glyphs );
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- FT_TRACE4(( " glyphs without GPOS data (`*' means already assigned)" ));
- count = 0;
-#endif
-
- for ( idx = HB_SET_VALUE_INVALID; hb_set_next( gsub_glyphs, &idx ); )
- {
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( !( count % 10 ) )
- {
- FT_TRACE4(( "\n" ));
- FT_TRACE4(( " " ));
- }
-
- FT_TRACE4(( " %d", idx ));
- count++;
-#endif
-
- /* glyph indices returned by `hb_ot_layout_lookup_collect_glyphs' */
- /* can be arbitrary: some fonts use fake indices for processing */
- /* internal to GSUB or GPOS, which is fully valid */
- if ( idx >= (hb_codepoint_t)globals->glyph_count )
- continue;
-
- if ( gstyles[idx] == AF_STYLE_UNASSIGNED )
- gstyles[idx] = (FT_UShort)style_class->style;
-#ifdef FT_DEBUG_LEVEL_TRACE
- else
- FT_TRACE4(( "*" ));
-#endif
- }
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( !count )
- {
- FT_TRACE4(( "\n" ));
- FT_TRACE4(( " (none)" ));
- }
- FT_TRACE4(( "\n" ));
- FT_TRACE4(( "\n" ));
-#endif
-
- Exit:
- hb_set_destroy( gsub_lookups );
- hb_set_destroy( gsub_glyphs );
- hb_set_destroy( gpos_lookups );
- hb_set_destroy( gpos_glyphs );
-
- return FT_Err_Ok;
- }
-
-
- /* construct HarfBuzz features */
-#undef COVERAGE
-#define COVERAGE( name, NAME, description, \
- tag1, tag2, tag3, tag4 ) \
- static const hb_feature_t name ## _feature[] = \
- { \
- { \
- HB_TAG( tag1, tag2, tag3, tag4 ), \
- 1, 0, (unsigned int)-1 \
- } \
- };
-
-
-#include "afcover.h"
-
-
- /* define mapping between HarfBuzz features and AF_Coverage */
-#undef COVERAGE
-#define COVERAGE( name, NAME, description, \
- tag1, tag2, tag3, tag4 ) \
- name ## _feature,
-
-
- static const hb_feature_t* features[] =
- {
-#include "afcover.h"
-
- NULL /* AF_COVERAGE_DEFAULT */
- };
-
-
- void*
- af_shaper_buf_create( FT_Face face )
- {
- FT_UNUSED( face );
-
- return (void*)hb_buffer_create();
- }
-
-
- void
- af_shaper_buf_destroy( FT_Face face,
- void* buf )
- {
- FT_UNUSED( face );
-
- hb_buffer_destroy( (hb_buffer_t*)buf );
- }
-
-
- const char*
- af_shaper_get_cluster( const char* p,
- AF_StyleMetrics metrics,
- void* buf_,
- unsigned int* count )
- {
- AF_StyleClass style_class;
- const hb_feature_t* feature;
- FT_Int upem;
- const char* q;
- int len;
-
- hb_buffer_t* buf = (hb_buffer_t*)buf_;
- hb_font_t* font;
- hb_codepoint_t dummy;
-
-
- upem = (FT_Int)metrics->globals->face->units_per_EM;
- style_class = metrics->style_class;
- feature = features[style_class->coverage];
-
- font = metrics->globals->hb_font;
-
- /* we shape at a size of units per EM; this means font units */
- hb_font_set_scale( font, upem, upem );
-
- while ( *p == ' ' )
- p++;
-
- /* count bytes up to next space (or end of buffer) */
- q = p;
- while ( !( *q == ' ' || *q == '\0' ) )
- GET_UTF8_CHAR( dummy, q );
- len = (int)( q - p );
-
- /* feed character(s) to the HarfBuzz buffer */
- hb_buffer_clear_contents( buf );
- hb_buffer_add_utf8( buf, p, len, 0, len );
-
- /* we let HarfBuzz guess the script and writing direction */
- hb_buffer_guess_segment_properties( buf );
-
- /* shape buffer, which means conversion from character codes to */
- /* glyph indices, possibly applying a feature */
- hb_shape( font, buf, feature, feature ? 1 : 0 );
-
- if ( feature )
- {
- hb_buffer_t* hb_buf = metrics->globals->hb_buf;
-
- unsigned int gcount;
- hb_glyph_info_t* ginfo;
-
- unsigned int hb_gcount;
- hb_glyph_info_t* hb_ginfo;
-
-
- /* we have to check whether applying a feature does actually change */
- /* glyph indices; otherwise the affected glyph or glyphs aren't */
- /* available at all in the feature */
-
- hb_buffer_clear_contents( hb_buf );
- hb_buffer_add_utf8( hb_buf, p, len, 0, len );
- hb_buffer_guess_segment_properties( hb_buf );
- hb_shape( font, hb_buf, NULL, 0 );
-
- ginfo = hb_buffer_get_glyph_infos( buf, &gcount );
- hb_ginfo = hb_buffer_get_glyph_infos( hb_buf, &hb_gcount );
-
- if ( gcount == hb_gcount )
- {
- unsigned int i;
-
-
- for (i = 0; i < gcount; i++ )
- if ( ginfo[i].codepoint != hb_ginfo[i].codepoint )
- break;
-
- if ( i == gcount )
- {
- /* both buffers have identical glyph indices */
- hb_buffer_clear_contents( buf );
- }
- }
- }
-
- *count = hb_buffer_get_length( buf );
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( feature && *count > 1 )
- FT_TRACE1(( "af_shaper_get_cluster:"
- " input character mapped to multiple glyphs\n" ));
-#endif
-
- return q;
- }
-
-
- FT_ULong
- af_shaper_get_elem( AF_StyleMetrics metrics,
- void* buf_,
- unsigned int idx,
- FT_Long* advance,
- FT_Long* y_offset )
- {
- hb_buffer_t* buf = (hb_buffer_t*)buf_;
- hb_glyph_info_t* ginfo;
- hb_glyph_position_t* gpos;
- unsigned int gcount;
-
- FT_UNUSED( metrics );
-
-
- ginfo = hb_buffer_get_glyph_infos( buf, &gcount );
- gpos = hb_buffer_get_glyph_positions( buf, &gcount );
-
- if ( idx >= gcount )
- return 0;
-
- if ( advance )
- *advance = gpos[idx].x_advance;
- if ( y_offset )
- *y_offset = gpos[idx].y_offset;
-
- return ginfo[idx].codepoint;
- }
-
-
-#else /* !FT_CONFIG_OPTION_USE_HARFBUZZ */
-
-
- FT_Error
- af_shaper_get_coverage( AF_FaceGlobals globals,
- AF_StyleClass style_class,
- FT_UShort* gstyles,
- FT_Bool default_script )
- {
- FT_UNUSED( globals );
- FT_UNUSED( style_class );
- FT_UNUSED( gstyles );
- FT_UNUSED( default_script );
-
- return FT_Err_Ok;
- }
-
-
- void*
- af_shaper_buf_create( FT_Face face )
- {
- FT_UNUSED( face );
-
- return NULL;
- }
-
-
- void
- af_shaper_buf_destroy( FT_Face face,
- void* buf )
- {
- FT_UNUSED( face );
- FT_UNUSED( buf );
- }
-
-
- const char*
- af_shaper_get_cluster( const char* p,
- AF_StyleMetrics metrics,
- void* buf_,
- unsigned int* count )
- {
- FT_Face face = metrics->globals->face;
- FT_ULong ch, dummy = 0;
- FT_ULong* buf = (FT_ULong*)buf_;
-
-
- while ( *p == ' ' )
- p++;
-
- GET_UTF8_CHAR( ch, p );
-
- /* since we don't have an engine to handle clusters, */
- /* we scan the characters but return zero */
- while ( !( *p == ' ' || *p == '\0' ) )
- GET_UTF8_CHAR( dummy, p );
-
- if ( dummy )
- {
- *buf = 0;
- *count = 0;
- }
- else
- {
- *buf = FT_Get_Char_Index( face, ch );
- *count = 1;
- }
-
- return p;
- }
-
-
- FT_ULong
- af_shaper_get_elem( AF_StyleMetrics metrics,
- void* buf_,
- unsigned int idx,
- FT_Long* advance,
- FT_Long* y_offset )
- {
- FT_Face face = metrics->globals->face;
- FT_ULong glyph_index = *(FT_ULong*)buf_;
-
- FT_UNUSED( idx );
-
-
- if ( advance )
- FT_Get_Advance( face,
- glyph_index,
- FT_LOAD_NO_SCALE |
- FT_LOAD_NO_HINTING |
- FT_LOAD_IGNORE_TRANSFORM,
- advance );
-
- if ( y_offset )
- *y_offset = 0;
-
- return glyph_index;
- }
-
-
-#endif /* !FT_CONFIG_OPTION_USE_HARFBUZZ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/autofit/afshaper.h b/contrib/libs/freetype/src/autofit/afshaper.h
deleted file mode 100644
index a40ba3ce74..0000000000
--- a/contrib/libs/freetype/src/autofit/afshaper.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/****************************************************************************
- *
- * afshaper.h
- *
- * HarfBuzz interface for accessing OpenType features (specification).
- *
- * Copyright (C) 2013-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef AFSHAPER_H_
-#define AFSHAPER_H_
-
-
-#include <freetype/freetype.h>
-
-
-#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
-
-#error #include <hb.h>
-#error #include <hb-ot.h>
-#error #include "ft-hb.h"
-
-#endif
-
-
-FT_BEGIN_HEADER
-
- FT_Error
- af_shaper_get_coverage( AF_FaceGlobals globals,
- AF_StyleClass style_class,
- FT_UShort* gstyles,
- FT_Bool default_script );
-
-
- void*
- af_shaper_buf_create( FT_Face face );
-
- void
- af_shaper_buf_destroy( FT_Face face,
- void* buf );
-
- const char*
- af_shaper_get_cluster( const char* p,
- AF_StyleMetrics metrics,
- void* buf_,
- unsigned int* count );
-
- FT_ULong
- af_shaper_get_elem( AF_StyleMetrics metrics,
- void* buf_,
- unsigned int idx,
- FT_Long* x_advance,
- FT_Long* y_offset );
-
- /* */
-
-FT_END_HEADER
-
-#endif /* AFSHAPER_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/autofit/afstyles.h b/contrib/libs/freetype/src/autofit/afstyles.h
deleted file mode 100644
index 7a33f37a85..0000000000
--- a/contrib/libs/freetype/src/autofit/afstyles.h
+++ /dev/null
@@ -1,487 +0,0 @@
-/****************************************************************************
- *
- * afstyles.h
- *
- * Auto-fitter styles (specification only).
- *
- * Copyright (C) 2013-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /* The following part can be included multiple times. */
- /* Define `STYLE' as needed. */
-
-
- /* Add new styles here. The first and second arguments are the */
- /* style name in lowercase and uppercase, respectively, followed */
- /* by a description string. The next arguments are the */
- /* corresponding writing system, script, blue stringset, and */
- /* coverage. */
- /* */
- /* Note that styles using `AF_COVERAGE_DEFAULT' should always */
- /* come after styles with other coverages. Also note that */
- /* fallback scripts only use `AF_COVERAGE_DEFAULT' for its */
- /* style. */
- /* */
- /* Example: */
- /* */
- /* STYLE( cyrl_dflt, CYRL_DFLT, */
- /* "Cyrillic default style", */
- /* AF_WRITING_SYSTEM_LATIN, */
- /* AF_SCRIPT_CYRL, */
- /* AF_BLUE_STRINGSET_CYRL, */
- /* AF_COVERAGE_DEFAULT ) */
-
-#undef STYLE_LATIN
-#define STYLE_LATIN( s, S, f, F, ds, df, C ) \
- STYLE( s ## _ ## f, S ## _ ## F, \
- ds " " df " style", \
- AF_WRITING_SYSTEM_LATIN, \
- AF_SCRIPT_ ## S, \
- AF_BLUE_STRINGSET_ ## S, \
- AF_COVERAGE_ ## C )
-
-#undef META_STYLE_LATIN
-#define META_STYLE_LATIN( s, S, ds ) \
- STYLE_LATIN( s, S, c2cp, C2CP, ds, \
- "petite capitals from capitals", \
- PETITE_CAPITALS_FROM_CAPITALS ) \
- STYLE_LATIN( s, S, c2sc, C2SC, ds, \
- "small capitals from capitals", \
- SMALL_CAPITALS_FROM_CAPITALS ) \
- STYLE_LATIN( s, S, ordn, ORDN, ds, \
- "ordinals", \
- ORDINALS ) \
- STYLE_LATIN( s, S, pcap, PCAP, ds, \
- "petite capitals", \
- PETITE_CAPITALS ) \
- STYLE_LATIN( s, S, sinf, SINF, ds, \
- "scientific inferiors", \
- SCIENTIFIC_INFERIORS ) \
- STYLE_LATIN( s, S, smcp, SMCP, ds, \
- "small capitals", \
- SMALL_CAPITALS ) \
- STYLE_LATIN( s, S, subs, SUBS, ds, \
- "subscript", \
- SUBSCRIPT ) \
- STYLE_LATIN( s, S, sups, SUPS, ds, \
- "superscript", \
- SUPERSCRIPT ) \
- STYLE_LATIN( s, S, titl, TITL, ds, \
- "titling", \
- TITLING ) \
- STYLE_LATIN( s, S, dflt, DFLT, ds, \
- "default", \
- DEFAULT )
-
-
- STYLE( adlm_dflt, ADLM_DFLT,
- "Adlam default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_ADLM,
- AF_BLUE_STRINGSET_ADLM,
- AF_COVERAGE_DEFAULT )
-
- STYLE( arab_dflt, ARAB_DFLT,
- "Arabic default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_ARAB,
- AF_BLUE_STRINGSET_ARAB,
- AF_COVERAGE_DEFAULT )
-
- STYLE( armn_dflt, ARMN_DFLT,
- "Armenian default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_ARMN,
- AF_BLUE_STRINGSET_ARMN,
- AF_COVERAGE_DEFAULT )
-
- STYLE( avst_dflt, AVST_DFLT,
- "Avestan default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_AVST,
- AF_BLUE_STRINGSET_AVST,
- AF_COVERAGE_DEFAULT )
-
- STYLE( bamu_dflt, BAMU_DFLT,
- "Bamum default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_BAMU,
- AF_BLUE_STRINGSET_BAMU,
- AF_COVERAGE_DEFAULT )
-
- STYLE( beng_dflt, BENG_DFLT,
- "Bengali default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_BENG,
- AF_BLUE_STRINGSET_BENG,
- AF_COVERAGE_DEFAULT )
-
- STYLE( buhd_dflt, BUHD_DFLT,
- "Buhid default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_BUHD,
- AF_BLUE_STRINGSET_BUHD,
- AF_COVERAGE_DEFAULT )
-
- STYLE( cakm_dflt, CAKM_DFLT,
- "Chakma default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_CAKM,
- AF_BLUE_STRINGSET_CAKM,
- AF_COVERAGE_DEFAULT )
-
- STYLE( cans_dflt, CANS_DFLT,
- "Canadian Syllabics default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_CANS,
- AF_BLUE_STRINGSET_CANS,
- AF_COVERAGE_DEFAULT )
-
- STYLE( cari_dflt, CARI_DFLT,
- "Carian default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_CARI,
- AF_BLUE_STRINGSET_CARI,
- AF_COVERAGE_DEFAULT )
-
- STYLE( cher_dflt, CHER_DFLT,
- "Cherokee default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_CHER,
- AF_BLUE_STRINGSET_CHER,
- AF_COVERAGE_DEFAULT )
-
- STYLE( copt_dflt, COPT_DFLT,
- "Coptic default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_COPT,
- AF_BLUE_STRINGSET_COPT,
- AF_COVERAGE_DEFAULT )
-
- STYLE( cprt_dflt, CPRT_DFLT,
- "Cypriot default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_CPRT,
- AF_BLUE_STRINGSET_CPRT,
- AF_COVERAGE_DEFAULT )
-
- META_STYLE_LATIN( cyrl, CYRL, "Cyrillic" )
-
- STYLE( deva_dflt, DEVA_DFLT,
- "Devanagari default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_DEVA,
- AF_BLUE_STRINGSET_DEVA,
- AF_COVERAGE_DEFAULT )
-
- STYLE( dsrt_dflt, DSRT_DFLT,
- "Deseret default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_DSRT,
- AF_BLUE_STRINGSET_DSRT,
- AF_COVERAGE_DEFAULT )
-
- STYLE( ethi_dflt, ETHI_DFLT,
- "Ethiopic default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_ETHI,
- AF_BLUE_STRINGSET_ETHI,
- AF_COVERAGE_DEFAULT )
-
- STYLE( geor_dflt, GEOR_DFLT,
- "Georgian (Mkhedruli) default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_GEOR,
- AF_BLUE_STRINGSET_GEOR,
- AF_COVERAGE_DEFAULT )
-
- STYLE( geok_dflt, GEOK_DFLT,
- "Georgian (Khutsuri) default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_GEOK,
- AF_BLUE_STRINGSET_GEOK,
- AF_COVERAGE_DEFAULT )
-
- STYLE( glag_dflt, GLAG_DFLT,
- "Glagolitic default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_GLAG,
- AF_BLUE_STRINGSET_GLAG,
- AF_COVERAGE_DEFAULT )
-
- STYLE( goth_dflt, GOTH_DFLT,
- "Gothic default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_GOTH,
- AF_BLUE_STRINGSET_GOTH,
- AF_COVERAGE_DEFAULT )
-
- META_STYLE_LATIN( grek, GREK, "Greek" )
-
- STYLE( gujr_dflt, GUJR_DFLT,
- "Gujarati default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_GUJR,
- AF_BLUE_STRINGSET_GUJR,
- AF_COVERAGE_DEFAULT )
-
- STYLE( guru_dflt, GURU_DFLT,
- "Gurmukhi default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_GURU,
- AF_BLUE_STRINGSET_GURU,
- AF_COVERAGE_DEFAULT )
-
- STYLE( hebr_dflt, HEBR_DFLT,
- "Hebrew default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_HEBR,
- AF_BLUE_STRINGSET_HEBR,
- AF_COVERAGE_DEFAULT )
-
- STYLE( kali_dflt, KALI_DFLT,
- "Kayah Li default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_KALI,
- AF_BLUE_STRINGSET_KALI,
- AF_COVERAGE_DEFAULT )
-
- STYLE( khmr_dflt, KHMR_DFLT,
- "Khmer default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_KHMR,
- AF_BLUE_STRINGSET_KHMR,
- AF_COVERAGE_DEFAULT )
-
- STYLE( khms_dflt, KHMS_DFLT,
- "Khmer Symbols default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_KHMS,
- AF_BLUE_STRINGSET_KHMS,
- AF_COVERAGE_DEFAULT )
-
- STYLE( knda_dflt, KNDA_DFLT,
- "Kannada default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_KNDA,
- AF_BLUE_STRINGSET_KNDA,
- AF_COVERAGE_DEFAULT )
-
- STYLE( lao_dflt, LAO_DFLT,
- "Lao default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_LAO,
- AF_BLUE_STRINGSET_LAO,
- AF_COVERAGE_DEFAULT )
-
- META_STYLE_LATIN( latn, LATN, "Latin" )
-
- STYLE( latb_dflt, LATB_DFLT,
- "Latin subscript fallback default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_LATB,
- AF_BLUE_STRINGSET_LATB,
- AF_COVERAGE_DEFAULT )
-
- STYLE( latp_dflt, LATP_DFLT,
- "Latin superscript fallback default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_LATP,
- AF_BLUE_STRINGSET_LATP,
- AF_COVERAGE_DEFAULT )
-
- STYLE( lisu_dflt, LISU_DFLT,
- "Lisu default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_LISU,
- AF_BLUE_STRINGSET_LISU,
- AF_COVERAGE_DEFAULT )
-
- STYLE( mlym_dflt, MLYM_DFLT,
- "Malayalam default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_MLYM,
- AF_BLUE_STRINGSET_MLYM,
- AF_COVERAGE_DEFAULT )
-
- STYLE( medf_dflt, MEDF_DFLT,
- "Medefaidrin default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_MEDF,
- AF_BLUE_STRINGSET_MEDF,
- AF_COVERAGE_DEFAULT )
-
- STYLE( mong_dflt, MONG_DFLT,
- "Mongolian default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_MONG,
- AF_BLUE_STRINGSET_MONG,
- AF_COVERAGE_DEFAULT )
-
- STYLE( mymr_dflt, MYMR_DFLT,
- "Myanmar default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_MYMR,
- AF_BLUE_STRINGSET_MYMR,
- AF_COVERAGE_DEFAULT )
-
- STYLE( nkoo_dflt, NKOO_DFLT,
- "N'Ko default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_NKOO,
- AF_BLUE_STRINGSET_NKOO,
- AF_COVERAGE_DEFAULT )
-
- STYLE( none_dflt, NONE_DFLT,
- "no style",
- AF_WRITING_SYSTEM_DUMMY,
- AF_SCRIPT_NONE,
- AF_BLUE_STRINGSET_NONE,
- AF_COVERAGE_DEFAULT )
-
- STYLE( olck_dflt, OLCK_DFLT,
- "Ol Chiki default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_OLCK,
- AF_BLUE_STRINGSET_OLCK,
- AF_COVERAGE_DEFAULT )
-
- STYLE( orkh_dflt, ORKH_DFLT,
- "Old Turkic default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_ORKH,
- AF_BLUE_STRINGSET_ORKH,
- AF_COVERAGE_DEFAULT )
-
- STYLE( osge_dflt, OSGE_DFLT,
- "Osage default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_OSGE,
- AF_BLUE_STRINGSET_OSGE,
- AF_COVERAGE_DEFAULT )
-
- STYLE( osma_dflt, OSMA_DFLT,
- "Osmanya default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_OSMA,
- AF_BLUE_STRINGSET_OSMA,
- AF_COVERAGE_DEFAULT )
-
- STYLE( rohg_dflt, ROHG_DFLT,
- "Hanifi Rohingya default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_ROHG,
- AF_BLUE_STRINGSET_ROHG,
- AF_COVERAGE_DEFAULT )
-
- STYLE( saur_dflt, SAUR_DFLT,
- "Saurashtra default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_SAUR,
- AF_BLUE_STRINGSET_SAUR,
- AF_COVERAGE_DEFAULT )
-
- STYLE( shaw_dflt, SHAW_DFLT,
- "Shavian default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_SHAW,
- AF_BLUE_STRINGSET_SHAW,
- AF_COVERAGE_DEFAULT )
-
- STYLE( sinh_dflt, SINH_DFLT,
- "Sinhala default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_SINH,
- AF_BLUE_STRINGSET_SINH,
- AF_COVERAGE_DEFAULT )
-
- STYLE( sund_dflt, SUND_DFLT,
- "Sundanese default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_SUND,
- AF_BLUE_STRINGSET_SUND,
- AF_COVERAGE_DEFAULT )
-
- STYLE( taml_dflt, TAML_DFLT,
- "Tamil default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_TAML,
- AF_BLUE_STRINGSET_TAML,
- AF_COVERAGE_DEFAULT )
-
- STYLE( tavt_dflt, TAVT_DFLT,
- "Tai Viet default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_TAVT,
- AF_BLUE_STRINGSET_TAVT,
- AF_COVERAGE_DEFAULT )
-
- STYLE( telu_dflt, TELU_DFLT,
- "Telugu default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_TELU,
- AF_BLUE_STRINGSET_TELU,
- AF_COVERAGE_DEFAULT )
-
- STYLE( tfng_dflt, TFNG_DFLT,
- "Tifinagh default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_TFNG,
- AF_BLUE_STRINGSET_TFNG,
- AF_COVERAGE_DEFAULT )
-
- STYLE( thai_dflt, THAI_DFLT,
- "Thai default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_THAI,
- AF_BLUE_STRINGSET_THAI,
- AF_COVERAGE_DEFAULT )
-
- STYLE( vaii_dflt, VAII_DFLT,
- "Vai default style",
- AF_WRITING_SYSTEM_LATIN,
- AF_SCRIPT_VAII,
- AF_BLUE_STRINGSET_VAII,
- AF_COVERAGE_DEFAULT )
-
-#ifdef AF_CONFIG_OPTION_INDIC
-
- /* no blue stringset support for the Indic writing system yet */
-#undef STYLE_DEFAULT_INDIC
-#define STYLE_DEFAULT_INDIC( s, S, d ) \
- STYLE( s ## _dflt, S ## _DFLT, \
- d " default style", \
- AF_WRITING_SYSTEM_INDIC, \
- AF_SCRIPT_ ## S, \
- (AF_Blue_Stringset)0, \
- AF_COVERAGE_DEFAULT )
-
- STYLE_DEFAULT_INDIC( limb, LIMB, "Limbu" )
- STYLE_DEFAULT_INDIC( orya, ORYA, "Oriya" )
- STYLE_DEFAULT_INDIC( sylo, SYLO, "Syloti Nagri" )
- STYLE_DEFAULT_INDIC( tibt, TIBT, "Tibetan" )
-
-#endif /* AF_CONFIG_OPTION_INDIC */
-
-#ifdef AF_CONFIG_OPTION_CJK
-
- STYLE( hani_dflt, HANI_DFLT,
- "CJKV ideographs default style",
- AF_WRITING_SYSTEM_CJK,
- AF_SCRIPT_HANI,
- AF_BLUE_STRINGSET_HANI,
- AF_COVERAGE_DEFAULT )
-
-#endif /* AF_CONFIG_OPTION_CJK */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/autofit/aftypes.h b/contrib/libs/freetype/src/autofit/aftypes.h
deleted file mode 100644
index 27e4185e9f..0000000000
--- a/contrib/libs/freetype/src/autofit/aftypes.h
+++ /dev/null
@@ -1,511 +0,0 @@
-/****************************************************************************
- *
- * aftypes.h
- *
- * Auto-fitter types (specification only).
- *
- * Copyright (C) 2003-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /*************************************************************************
- *
- * The auto-fitter is a complete rewrite of the old auto-hinter.
- * Its main feature is the ability to differentiate between different
- * writing systems and scripts in order to apply specific rules.
- *
- * The code has also been compartmentalized into several entities that
- * should make algorithmic experimentation easier than with the old
- * code.
- *
- *************************************************************************/
-
-
-#ifndef AFTYPES_H_
-#define AFTYPES_H_
-
-
-#include <freetype/freetype.h>
-#include <freetype/ftoutln.h>
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/ftdebug.h>
-
-#include "afblue.h"
-
-#ifdef FT_DEBUG_AUTOFIT
-#include FT_CONFIG_STANDARD_LIBRARY_H
-#endif
-
-
-FT_BEGIN_HEADER
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** D E B U G G I N G *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-#ifdef FT_DEBUG_AUTOFIT
-
-extern int af_debug_disable_horz_hints_;
-extern int af_debug_disable_vert_hints_;
-extern int af_debug_disable_blue_hints_;
-extern void* af_debug_hints_;
-
-#endif /* FT_DEBUG_AUTOFIT */
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** U T I L I T Y S T U F F *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- typedef struct AF_WidthRec_
- {
- FT_Pos org; /* original position/width in font units */
- FT_Pos cur; /* current/scaled position/width in device subpixels */
- FT_Pos fit; /* current/fitted position/width in device subpixels */
-
- } AF_WidthRec, *AF_Width;
-
-
- FT_LOCAL( void )
- af_sort_pos( FT_UInt count,
- FT_Pos* table );
-
- FT_LOCAL( void )
- af_sort_and_quantize_widths( FT_UInt* count,
- AF_Width widths,
- FT_Pos threshold );
-
-
- /*
- * opaque handle to glyph-specific hints -- see `afhints.h' for more
- * details
- */
- typedef struct AF_GlyphHintsRec_* AF_GlyphHints;
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** S C A L E R S *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- /*
- * A scaler models the target pixel device that will receive the
- * auto-hinted glyph image.
- */
-
-#define AF_SCALER_FLAG_NO_HORIZONTAL 1U /* disable horizontal hinting */
-#define AF_SCALER_FLAG_NO_VERTICAL 2U /* disable vertical hinting */
-#define AF_SCALER_FLAG_NO_ADVANCE 4U /* disable advance hinting */
-
-
- typedef struct AF_ScalerRec_
- {
- FT_Face face; /* source font face */
- FT_Fixed x_scale; /* from font units to 1/64 device pixels */
- FT_Fixed y_scale; /* from font units to 1/64 device pixels */
- FT_Pos x_delta; /* in 1/64 device pixels */
- FT_Pos y_delta; /* in 1/64 device pixels */
- FT_Render_Mode render_mode; /* monochrome, anti-aliased, LCD, etc. */
- FT_UInt32 flags; /* additional control flags, see above */
-
- } AF_ScalerRec, *AF_Scaler;
-
-
-#define AF_SCALER_EQUAL_SCALES( a, b ) \
- ( (a)->x_scale == (b)->x_scale && \
- (a)->y_scale == (b)->y_scale && \
- (a)->x_delta == (b)->x_delta && \
- (a)->y_delta == (b)->y_delta )
-
-
- typedef struct AF_StyleMetricsRec_* AF_StyleMetrics;
-
- /*
- * This function parses an FT_Face to compute global metrics for
- * a specific style.
- */
- typedef FT_Error
- (*AF_WritingSystem_InitMetricsFunc)( AF_StyleMetrics metrics,
- FT_Face face );
-
- typedef void
- (*AF_WritingSystem_ScaleMetricsFunc)( AF_StyleMetrics metrics,
- AF_Scaler scaler );
-
- typedef void
- (*AF_WritingSystem_DoneMetricsFunc)( AF_StyleMetrics metrics );
-
- typedef void
- (*AF_WritingSystem_GetStdWidthsFunc)( AF_StyleMetrics metrics,
- FT_Pos* stdHW,
- FT_Pos* stdVW );
-
-
- typedef FT_Error
- (*AF_WritingSystem_InitHintsFunc)( AF_GlyphHints hints,
- AF_StyleMetrics metrics );
-
- typedef FT_Error
- (*AF_WritingSystem_ApplyHintsFunc)( FT_UInt glyph_index,
- AF_GlyphHints hints,
- FT_Outline* outline,
- AF_StyleMetrics metrics );
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** W R I T I N G S Y S T E M S *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- /*
- * For the auto-hinter, a writing system consists of multiple scripts that
- * can be handled similarly *in a typographical way*; the relationship is
- * not based on history. For example, both the Greek and the unrelated
- * Armenian scripts share the same features like ascender, descender,
- * x-height, etc. Essentially, a writing system is covered by a
- * submodule of the auto-fitter; it contains
- *
- * - a specific global analyzer that computes global metrics specific to
- * the script (based on script-specific characters to identify ascender
- * height, x-height, etc.),
- *
- * - a specific glyph analyzer that computes segments and edges for each
- * glyph covered by the script,
- *
- * - a specific grid-fitting algorithm that distorts the scaled glyph
- * outline according to the results of the glyph analyzer.
- */
-
-#undef WRITING_SYSTEM
-#define WRITING_SYSTEM( ws, WS ) \
- AF_WRITING_SYSTEM_ ## WS,
-
- /* The list of known writing systems. */
- typedef enum AF_WritingSystem_
- {
-
-#include "afws-iter.h"
-
- AF_WRITING_SYSTEM_MAX /* do not remove */
-
- } AF_WritingSystem;
-
-
- typedef struct AF_WritingSystemClassRec_
- {
- AF_WritingSystem writing_system;
-
- FT_Offset style_metrics_size;
- AF_WritingSystem_InitMetricsFunc style_metrics_init;
- AF_WritingSystem_ScaleMetricsFunc style_metrics_scale;
- AF_WritingSystem_DoneMetricsFunc style_metrics_done;
- AF_WritingSystem_GetStdWidthsFunc style_metrics_getstdw;
-
- AF_WritingSystem_InitHintsFunc style_hints_init;
- AF_WritingSystem_ApplyHintsFunc style_hints_apply;
-
- } AF_WritingSystemClassRec;
-
- typedef const AF_WritingSystemClassRec* AF_WritingSystemClass;
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** S C R I P T S *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- /*
- * Each script is associated with two sets of Unicode ranges to test
- * whether the font face supports the script, and which non-base
- * characters the script contains.
- *
- * We use four-letter script tags from the OpenType specification,
- * extended by `NONE', which indicates `no script'.
- */
-
-#undef SCRIPT
-#define SCRIPT( s, S, d, h, H, ss ) \
- AF_SCRIPT_ ## S,
-
- /* The list of known scripts. */
- typedef enum AF_Script_
- {
-
-#include "afscript.h"
-
- AF_SCRIPT_MAX /* do not remove */
-
- } AF_Script;
-
-
- typedef struct AF_Script_UniRangeRec_
- {
- FT_UInt32 first;
- FT_UInt32 last;
-
- } AF_Script_UniRangeRec;
-
-#define AF_UNIRANGE_REC( a, b ) { (FT_UInt32)(a), (FT_UInt32)(b) }
-
- typedef const AF_Script_UniRangeRec* AF_Script_UniRange;
-
-
- typedef struct AF_ScriptClassRec_
- {
- AF_Script script;
-
- /* last element in the ranges must be { 0, 0 } */
- AF_Script_UniRange script_uni_ranges;
- AF_Script_UniRange script_uni_nonbase_ranges;
-
- FT_Bool top_to_bottom_hinting;
-
- const char* standard_charstring; /* for default width and height */
-
- } AF_ScriptClassRec;
-
- typedef const AF_ScriptClassRec* AF_ScriptClass;
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** C O V E R A G E S *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- /*
- * Usually, a font contains more glyphs than can be addressed by its
- * character map.
- *
- * In the PostScript font world, encoding vectors specific to a given
- * task are used to select such glyphs, and these glyphs can be often
- * recognized by having a suffix in its glyph names. For example, a
- * superscript glyph `A' might be called `A.sup'. Unfortunately, this
- * naming scheme is not standardized and thus unusable for us.
- *
- * In the OpenType world, a better solution was invented, namely
- * `features', which cleanly separate a character's input encoding from
- * the corresponding glyph's appearance, and which don't use glyph names
- * at all. For our purposes, and slightly generalized, an OpenType
- * feature is a name of a mapping that maps character codes to
- * non-standard glyph indices (features get used for other things also).
- * For example, the `sups' feature provides superscript glyphs, thus
- * mapping character codes like `A' or `B' to superscript glyph
- * representation forms. How this mapping happens is completely
- * uninteresting to us.
- *
- * For the auto-hinter, a `coverage' represents all glyphs of an OpenType
- * feature collected in a set (as listed below) that can be hinted
- * together. To continue the above example, superscript glyphs must not
- * be hinted together with normal glyphs because the blue zones
- * completely differ.
- *
- * Note that FreeType itself doesn't compute coverages; it only provides
- * the glyphs addressable by the default Unicode character map. Instead,
- * we use the HarfBuzz library (if available), which has many functions
- * exactly for this purpose.
- *
- * AF_COVERAGE_DEFAULT is special: It should cover everything that isn't
- * listed separately (including the glyphs addressable by the character
- * map). In case HarfBuzz isn't available, it exactly covers the glyphs
- * addressable by the character map.
- *
- */
-
-#undef COVERAGE
-#define COVERAGE( name, NAME, description, \
- tag1, tag2, tag3, tag4 ) \
- AF_COVERAGE_ ## NAME,
-
-
- typedef enum AF_Coverage_
- {
-#include "afcover.h"
-
- AF_COVERAGE_DEFAULT
-
- } AF_Coverage;
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** S T Y L E S *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- /*
- * The topmost structure for modelling the auto-hinter glyph input data
- * is a `style class', grouping everything together.
- */
-
-#undef STYLE
-#define STYLE( s, S, d, ws, sc, ss, c ) \
- AF_STYLE_ ## S,
-
- /* The list of known styles. */
- typedef enum AF_Style_
- {
-
-#include "afstyles.h"
-
- AF_STYLE_MAX /* do not remove */
-
- } AF_Style;
-
-
- typedef struct AF_StyleClassRec_
- {
- AF_Style style;
-
- AF_WritingSystem writing_system;
- AF_Script script;
- AF_Blue_Stringset blue_stringset;
- AF_Coverage coverage;
-
- } AF_StyleClassRec;
-
- typedef const AF_StyleClassRec* AF_StyleClass;
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** S T Y L E M E T R I C S *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- typedef struct AF_FaceGlobalsRec_* AF_FaceGlobals;
-
- /* This is the main structure that combines everything. Autofit modules */
- /* specific to writing systems derive their structures from it, for */
- /* example `AF_LatinMetrics'. */
-
- typedef struct AF_StyleMetricsRec_
- {
- AF_StyleClass style_class;
- AF_ScalerRec scaler;
- FT_Bool digits_have_same_width;
-
- AF_FaceGlobals globals; /* to access properties */
-
- } AF_StyleMetricsRec;
-
-
-#define AF_HINTING_BOTTOM_TO_TOP 0
-#define AF_HINTING_TOP_TO_BOTTOM 1
-
-
- /* Declare and define vtables for classes */
-#define AF_DECLARE_WRITING_SYSTEM_CLASS( writing_system_class ) \
- FT_CALLBACK_TABLE const AF_WritingSystemClassRec \
- writing_system_class;
-
-#define AF_DEFINE_WRITING_SYSTEM_CLASS( \
- writing_system_class, \
- system, \
- m_size, \
- m_init, \
- m_scale, \
- m_done, \
- m_stdw, \
- h_init, \
- h_apply ) \
- FT_CALLBACK_TABLE_DEF \
- const AF_WritingSystemClassRec writing_system_class = \
- { \
- system, \
- \
- m_size, \
- \
- m_init, \
- m_scale, \
- m_done, \
- m_stdw, \
- \
- h_init, \
- h_apply \
- };
-
-
-#define AF_DECLARE_SCRIPT_CLASS( script_class ) \
- FT_CALLBACK_TABLE const AF_ScriptClassRec \
- script_class;
-
-#define AF_DEFINE_SCRIPT_CLASS( \
- script_class, \
- script, \
- ranges, \
- nonbase_ranges, \
- top_to_bottom, \
- std_charstring ) \
- FT_CALLBACK_TABLE_DEF \
- const AF_ScriptClassRec script_class = \
- { \
- script, \
- ranges, \
- nonbase_ranges, \
- top_to_bottom, \
- std_charstring, \
- };
-
-
-#define AF_DECLARE_STYLE_CLASS( style_class ) \
- FT_CALLBACK_TABLE const AF_StyleClassRec \
- style_class;
-
-#define AF_DEFINE_STYLE_CLASS( \
- style_class, \
- style, \
- writing_system, \
- script, \
- blue_stringset, \
- coverage ) \
- FT_CALLBACK_TABLE_DEF \
- const AF_StyleClassRec style_class = \
- { \
- style, \
- writing_system, \
- script, \
- blue_stringset, \
- coverage \
- };
-
-/* */
-
-
-FT_END_HEADER
-
-#endif /* AFTYPES_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/autofit/afws-decl.h b/contrib/libs/freetype/src/autofit/afws-decl.h
deleted file mode 100644
index b78745af74..0000000000
--- a/contrib/libs/freetype/src/autofit/afws-decl.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/****************************************************************************
- *
- * afws-decl.h
- *
- * Auto-fitter writing system declarations (specification only).
- *
- * Copyright (C) 2013-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef AFWS_DECL_H_
-#define AFWS_DECL_H_
-
- /* Since preprocessor directives can't create other preprocessor */
- /* directives, we have to include the header files manually. */
-
-#include "afdummy.h"
-#include "aflatin.h"
-#include "afcjk.h"
-#include "afindic.h"
-
-#endif /* AFWS_DECL_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/autofit/afws-iter.h b/contrib/libs/freetype/src/autofit/afws-iter.h
deleted file mode 100644
index c86d609a35..0000000000
--- a/contrib/libs/freetype/src/autofit/afws-iter.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/****************************************************************************
- *
- * afws-iter.h
- *
- * Auto-fitter writing systems iterator (specification only).
- *
- * Copyright (C) 2013-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
- /* This header may be included multiple times. */
- /* Define `WRITING_SYSTEM' as needed. */
-
-
- /* Add new writing systems here. The arguments are the writing system */
- /* name in lowercase and uppercase, respectively. */
-
- WRITING_SYSTEM( dummy, DUMMY )
- WRITING_SYSTEM( latin, LATIN )
- WRITING_SYSTEM( cjk, CJK )
- WRITING_SYSTEM( indic, INDIC )
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/autofit/autofit.c b/contrib/libs/freetype/src/autofit/autofit.c
deleted file mode 100644
index de5ec7c7c5..0000000000
--- a/contrib/libs/freetype/src/autofit/autofit.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/****************************************************************************
- *
- * autofit.c
- *
- * Auto-fitter module (body).
- *
- * Copyright (C) 2003-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#define FT_MAKE_OPTION_SINGLE_OBJECT
-
-#include "ft-hb.c"
-#include "afblue.c"
-#include "afcjk.c"
-#include "afdummy.c"
-#include "afglobal.c"
-#include "afhints.c"
-#include "afindic.c"
-#include "aflatin.c"
-#include "afloader.c"
-#include "afmodule.c"
-#include "afranges.c"
-#include "afshaper.c"
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/autofit/ft-hb.c b/contrib/libs/freetype/src/autofit/ft-hb.c
deleted file mode 100644
index 4debb131d6..0000000000
--- a/contrib/libs/freetype/src/autofit/ft-hb.c
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright © 2009, 2023 Red Hat, Inc.
- * Copyright © 2015 Google, Inc.
- *
- * Permission is hereby granted, without written agreement and without
- * license or royalty fees, to use, copy, modify, and distribute this
- * software and its documentation for any purpose, provided that the
- * above copyright notice and the following two paragraphs appear in
- * all copies of this software.
- *
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * Red Hat Author(s): Behdad Esfahbod, Matthias Clasen
- * Google Author(s): Behdad Esfahbod
- */
-
-#include <freetype/freetype.h>
-#include <freetype/tttables.h>
-
-#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
-
-#error #include "ft-hb.h"
-
-/* The following three functions are a more or less verbatim
- * copy of corresponding HarfBuzz code from hb-ft.cc
- */
-
-static hb_blob_t *
-hb_ft_reference_table_ (hb_face_t *face, hb_tag_t tag, void *user_data)
-{
- FT_Face ft_face = (FT_Face) user_data;
- FT_Byte *buffer;
- FT_ULong length = 0;
- FT_Error error;
-
- FT_UNUSED (face);
-
- /* Note: FreeType like HarfBuzz uses the NONE tag for fetching the entire blob */
-
- error = FT_Load_Sfnt_Table (ft_face, tag, 0, NULL, &length);
- if (error)
- return NULL;
-
- buffer = (FT_Byte *) ft_smalloc (length);
- if (!buffer)
- return NULL;
-
- error = FT_Load_Sfnt_Table (ft_face, tag, 0, buffer, &length);
- if (error)
- {
- free (buffer);
- return NULL;
- }
-
- return hb_blob_create ((const char *) buffer, length,
- HB_MEMORY_MODE_WRITABLE,
- buffer, ft_sfree);
-}
-
-static hb_face_t *
-hb_ft_face_create_ (FT_Face ft_face,
- hb_destroy_func_t destroy)
-{
- hb_face_t *face;
-
- if (!ft_face->stream->read) {
- hb_blob_t *blob;
-
- blob = hb_blob_create ((const char *) ft_face->stream->base,
- (unsigned int) ft_face->stream->size,
- HB_MEMORY_MODE_READONLY,
- ft_face, destroy);
- face = hb_face_create (blob, ft_face->face_index);
- hb_blob_destroy (blob);
- } else {
- face = hb_face_create_for_tables (hb_ft_reference_table_, ft_face, destroy);
- }
-
- hb_face_set_index (face, ft_face->face_index);
- hb_face_set_upem (face, ft_face->units_per_EM);
-
- return face;
-}
-
-FT_LOCAL_DEF(hb_font_t *)
-hb_ft_font_create_ (FT_Face ft_face,
- hb_destroy_func_t destroy)
-{
- hb_font_t *font;
- hb_face_t *face;
-
- face = hb_ft_face_create_ (ft_face, destroy);
- font = hb_font_create (face);
- hb_face_destroy (face);
- return font;
-}
-
-#else /* !FT_CONFIG_OPTION_USE_HARFBUZZ */
-
-/* ANSI C doesn't like empty source files */
-typedef int ft_hb_dummy_;
-
-#endif /* !FT_CONFIG_OPTION_USE_HARFBUZZ */
-
-/* END */
diff --git a/contrib/libs/freetype/src/base/ftadvanc.c b/contrib/libs/freetype/src/base/ftadvanc.c
deleted file mode 100644
index 717f7d08b3..0000000000
--- a/contrib/libs/freetype/src/base/ftadvanc.c
+++ /dev/null
@@ -1,174 +0,0 @@
-/****************************************************************************
- *
- * ftadvanc.c
- *
- * Quick computation of advance widths (body).
- *
- * Copyright (C) 2008-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftdebug.h>
-
-#include <freetype/ftadvanc.h>
-#include <freetype/internal/ftobjs.h>
-
-
- static FT_Error
- ft_face_scale_advances_( FT_Face face,
- FT_Fixed* advances,
- FT_UInt count,
- FT_Int32 flags )
- {
- FT_Fixed scale;
- FT_UInt nn;
-
-
- if ( flags & FT_LOAD_NO_SCALE )
- return FT_Err_Ok;
-
- if ( !face->size )
- return FT_THROW( Invalid_Size_Handle );
-
- if ( flags & FT_LOAD_VERTICAL_LAYOUT )
- scale = face->size->metrics.y_scale;
- else
- scale = face->size->metrics.x_scale;
-
- /* this must be the same scaling as to get linear{Hori,Vert}Advance */
- /* (see `FT_Load_Glyph' implementation in src/base/ftobjs.c) */
-
- for ( nn = 0; nn < count; nn++ )
- advances[nn] = FT_MulDiv( advances[nn], scale, 64 );
-
- return FT_Err_Ok;
- }
-
-
- /* at the moment, we can perform fast advance retrieval only in */
- /* the following cases: */
- /* */
- /* - unscaled load */
- /* - unhinted load */
- /* - light-hinted load */
- /* - if a variations font, it must have an `HVAR' or `VVAR' */
- /* table (thus the old MM or GX fonts don't qualify; this */
- /* gets checked by the driver-specific functions) */
-
-#define LOAD_ADVANCE_FAST_CHECK( face, flags ) \
- ( flags & ( FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING ) || \
- FT_LOAD_TARGET_MODE( flags ) == FT_RENDER_MODE_LIGHT )
-
-
- /* documentation is in ftadvanc.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Get_Advance( FT_Face face,
- FT_UInt gindex,
- FT_Int32 flags,
- FT_Fixed *padvance )
- {
- FT_Face_GetAdvancesFunc func;
-
-
- if ( !face )
- return FT_THROW( Invalid_Face_Handle );
-
- if ( !padvance )
- return FT_THROW( Invalid_Argument );
-
- if ( gindex >= (FT_UInt)face->num_glyphs )
- return FT_THROW( Invalid_Glyph_Index );
-
- func = face->driver->clazz->get_advances;
- if ( func && LOAD_ADVANCE_FAST_CHECK( face, flags ) )
- {
- FT_Error error;
-
-
- error = func( face, gindex, 1, flags, padvance );
- if ( !error )
- return ft_face_scale_advances_( face, padvance, 1, flags );
-
- if ( FT_ERR_NEQ( error, Unimplemented_Feature ) )
- return error;
- }
-
- return FT_Get_Advances( face, gindex, 1, flags, padvance );
- }
-
-
- /* documentation is in ftadvanc.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Get_Advances( FT_Face face,
- FT_UInt start,
- FT_UInt count,
- FT_Int32 flags,
- FT_Fixed *padvances )
- {
- FT_Error error = FT_Err_Ok;
-
- FT_Face_GetAdvancesFunc func;
-
- FT_UInt num, end, nn;
- FT_Int factor;
-
-
- if ( !face )
- return FT_THROW( Invalid_Face_Handle );
-
- if ( !padvances )
- return FT_THROW( Invalid_Argument );
-
- num = (FT_UInt)face->num_glyphs;
- end = start + count;
- if ( start >= num || end < start || end > num )
- return FT_THROW( Invalid_Glyph_Index );
-
- if ( count == 0 )
- return FT_Err_Ok;
-
- func = face->driver->clazz->get_advances;
- if ( func && LOAD_ADVANCE_FAST_CHECK( face, flags ) )
- {
- error = func( face, start, count, flags, padvances );
- if ( !error )
- return ft_face_scale_advances_( face, padvances, count, flags );
-
- if ( FT_ERR_NEQ( error, Unimplemented_Feature ) )
- return error;
- }
-
- error = FT_Err_Ok;
-
- if ( flags & FT_ADVANCE_FLAG_FAST_ONLY )
- return FT_THROW( Unimplemented_Feature );
-
- flags |= (FT_UInt32)FT_LOAD_ADVANCE_ONLY;
- factor = ( flags & FT_LOAD_NO_SCALE ) ? 1 : 1024;
- for ( nn = 0; nn < count; nn++ )
- {
- error = FT_Load_Glyph( face, start + nn, flags );
- if ( error )
- break;
-
- /* scale from 26.6 to 16.16, unless NO_SCALE was requested */
- padvances[nn] = ( flags & FT_LOAD_VERTICAL_LAYOUT )
- ? face->glyph->advance.y * factor
- : face->glyph->advance.x * factor;
- }
-
- return error;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/base/ftbase.c b/contrib/libs/freetype/src/base/ftbase.c
deleted file mode 100644
index 50805ccec4..0000000000
--- a/contrib/libs/freetype/src/base/ftbase.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/****************************************************************************
- *
- * ftbase.c
- *
- * Single object library component (body only).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#define FT_MAKE_OPTION_SINGLE_OBJECT
-
-#include "ftadvanc.c"
-#include "ftcalc.c"
-#include "ftcolor.c"
-#include "ftdbgmem.c"
-#include "fterrors.c"
-#include "ftfntfmt.c"
-#include "ftgloadr.c"
-#include "fthash.c"
-#include "ftlcdfil.c"
-#include "ftmac.c"
-#include "ftobjs.c"
-#include "ftoutln.c"
-#include "ftpsprop.c"
-#include "ftrfork.c"
-#include "ftsnames.c"
-#include "ftstream.c"
-#include "fttrigon.c"
-#include "ftutil.c"
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/base/ftbase.h b/contrib/libs/freetype/src/base/ftbase.h
deleted file mode 100644
index 1d98b26dd5..0000000000
--- a/contrib/libs/freetype/src/base/ftbase.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
- *
- * ftbase.h
- *
- * Private functions used in the `base' module (specification).
- *
- * Copyright (C) 2008-2024 by
- * David Turner, Robert Wilhelm, Werner Lemberg, and suzuki toshiya.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTBASE_H_
-#define FTBASE_H_
-
-
-#include <freetype/internal/ftobjs.h>
-
-
-FT_BEGIN_HEADER
-
-
- FT_DECLARE_GLYPH( ft_bitmap_glyph_class )
- FT_DECLARE_GLYPH( ft_outline_glyph_class )
- FT_DECLARE_GLYPH( ft_svg_glyph_class )
-
-
-#ifdef FT_CONFIG_OPTION_MAC_FONTS
-
- /* MacOS resource fork cannot exceed 16MB at least for Carbon code; */
- /* see https://support.microsoft.com/en-us/kb/130437 */
-#define FT_MAC_RFORK_MAX_LEN 0x00FFFFFFUL
-
-
- /* Assume the stream is sfnt-wrapped PS Type1 or sfnt-wrapped CID-keyed */
- /* font, and try to load a face specified by the face_index. */
- FT_LOCAL( FT_Error )
- open_face_PS_from_sfnt_stream( FT_Library library,
- FT_Stream stream,
- FT_Long face_index,
- FT_Int num_params,
- FT_Parameter *params,
- FT_Face *aface );
-
-
- /* Create a new FT_Face given a buffer and a driver name. */
- /* From ftmac.c. */
- FT_LOCAL( FT_Error )
- open_face_from_buffer( FT_Library library,
- FT_Byte* base,
- FT_ULong size,
- FT_Long face_index,
- const char* driver_name,
- FT_Face *aface );
-
-
-#if defined( FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK ) && \
- !defined( FT_MACINTOSH )
- /* Mac OS X/Darwin kernel often changes recommended method to access */
- /* the resource fork and older methods makes the kernel issue the */
- /* warning of deprecated method. To calm it down, the methods based */
- /* on Darwin VFS should be grouped and skip the rest methods after */
- /* the case the resource is opened but found to lack a font in it. */
- FT_LOCAL( FT_Bool )
- ft_raccess_rule_by_darwin_vfs( FT_Library library, FT_UInt rule_index );
-#endif
-
-#endif /* FT_CONFIG_OPTION_MAC_FONTS */
-
-
-FT_END_HEADER
-
-#endif /* FTBASE_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/base/ftbbox.c b/contrib/libs/freetype/src/base/ftbbox.c
deleted file mode 100644
index d6aa5d56df..0000000000
--- a/contrib/libs/freetype/src/base/ftbbox.c
+++ /dev/null
@@ -1,542 +0,0 @@
-/****************************************************************************
- *
- * ftbbox.c
- *
- * FreeType bbox computation (body).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used
- * modified and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /**************************************************************************
- *
- * This component has a _single_ role: to compute exact outline bounding
- * boxes.
- *
- */
-
-
-#include <freetype/internal/ftdebug.h>
-
-#include <freetype/ftbbox.h>
-#include <freetype/ftimage.h>
-#include <freetype/ftoutln.h>
-#include <freetype/internal/ftcalc.h>
-#include <freetype/internal/ftobjs.h>
-
-
- typedef struct TBBox_Rec_
- {
- FT_Vector last;
- FT_BBox bbox;
-
- } TBBox_Rec;
-
-
-#define FT_UPDATE_BBOX( p, bbox ) \
- FT_BEGIN_STMNT \
- if ( p->x < bbox.xMin ) \
- bbox.xMin = p->x; \
- if ( p->x > bbox.xMax ) \
- bbox.xMax = p->x; \
- if ( p->y < bbox.yMin ) \
- bbox.yMin = p->y; \
- if ( p->y > bbox.yMax ) \
- bbox.yMax = p->y; \
- FT_END_STMNT
-
-#define CHECK_X( p, bbox ) \
- ( p->x < bbox.xMin || p->x > bbox.xMax )
-
-#define CHECK_Y( p, bbox ) \
- ( p->y < bbox.yMin || p->y > bbox.yMax )
-
-
- /**************************************************************************
- *
- * @Function:
- * BBox_Move_To
- *
- * @Description:
- * This function is used as a `move_to' emitter during
- * FT_Outline_Decompose(). It simply records the destination point
- * in `user->last'. We also update bbox in case contour starts with
- * an implicit `on' point.
- *
- * @Input:
- * to ::
- * A pointer to the destination vector.
- *
- * @InOut:
- * user ::
- * A pointer to the current walk context.
- *
- * @Return:
- * Always 0. Needed for the interface only.
- */
- FT_CALLBACK_DEF( int )
- BBox_Move_To( const FT_Vector* to,
- void* user_ )
- {
- TBBox_Rec* user = (TBBox_Rec*)user_;
-
-
- FT_UPDATE_BBOX( to, user->bbox );
-
- user->last = *to;
-
- return 0;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * BBox_Line_To
- *
- * @Description:
- * This function is used as a `line_to' emitter during
- * FT_Outline_Decompose(). It simply records the destination point
- * in `user->last'; no further computations are necessary because
- * bbox already contains both explicit ends of the line segment.
- *
- * @Input:
- * to ::
- * A pointer to the destination vector.
- *
- * @InOut:
- * user ::
- * A pointer to the current walk context.
- *
- * @Return:
- * Always 0. Needed for the interface only.
- */
- FT_CALLBACK_DEF( int )
- BBox_Line_To( const FT_Vector* to,
- void* user_ )
- {
- TBBox_Rec* user = (TBBox_Rec*)user_;
-
-
- user->last = *to;
-
- return 0;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * BBox_Conic_Check
- *
- * @Description:
- * Find the extrema of a 1-dimensional conic Bezier curve and update
- * a bounding range. This version uses direct computation, as it
- * doesn't need square roots.
- *
- * @Input:
- * y1 ::
- * The start coordinate.
- *
- * y2 ::
- * The coordinate of the control point.
- *
- * y3 ::
- * The end coordinate.
- *
- * @InOut:
- * min ::
- * The address of the current minimum.
- *
- * max ::
- * The address of the current maximum.
- */
- static void
- BBox_Conic_Check( FT_Pos y1,
- FT_Pos y2,
- FT_Pos y3,
- FT_Pos* min,
- FT_Pos* max )
- {
- /* This function is only called when a control off-point is outside */
- /* the bbox that contains all on-points. It finds a local extremum */
- /* within the segment, equal to (y1*y3 - y2*y2)/(y1 - 2*y2 + y3). */
- /* Or, offsetting from y2, we get */
-
- y1 -= y2;
- y3 -= y2;
- y2 += FT_MulDiv( y1, y3, y1 + y3 );
-
- if ( y2 < *min )
- *min = y2;
- if ( y2 > *max )
- *max = y2;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * BBox_Conic_To
- *
- * @Description:
- * This function is used as a `conic_to' emitter during
- * FT_Outline_Decompose(). It checks a conic Bezier curve with the
- * current bounding box, and computes its extrema if necessary to
- * update it.
- *
- * @Input:
- * control ::
- * A pointer to a control point.
- *
- * to ::
- * A pointer to the destination vector.
- *
- * @InOut:
- * user ::
- * The address of the current walk context.
- *
- * @Return:
- * Always 0. Needed for the interface only.
- *
- * @Note:
- * In the case of a non-monotonous arc, we compute directly the
- * extremum coordinates, as it is sufficiently fast.
- */
- FT_CALLBACK_DEF( int )
- BBox_Conic_To( const FT_Vector* control,
- const FT_Vector* to,
- void* user_ )
- {
- TBBox_Rec* user = (TBBox_Rec*)user_;
-
-
- /* in case `to' is implicit and not included in bbox yet */
- FT_UPDATE_BBOX( to, user->bbox );
-
- if ( CHECK_X( control, user->bbox ) )
- BBox_Conic_Check( user->last.x,
- control->x,
- to->x,
- &user->bbox.xMin,
- &user->bbox.xMax );
-
- if ( CHECK_Y( control, user->bbox ) )
- BBox_Conic_Check( user->last.y,
- control->y,
- to->y,
- &user->bbox.yMin,
- &user->bbox.yMax );
-
- user->last = *to;
-
- return 0;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * BBox_Cubic_Check
- *
- * @Description:
- * Find the extrema of a 1-dimensional cubic Bezier curve and
- * update a bounding range. This version uses iterative splitting
- * because it is faster than the exact solution with square roots.
- *
- * @Input:
- * p1 ::
- * The start coordinate.
- *
- * p2 ::
- * The coordinate of the first control point.
- *
- * p3 ::
- * The coordinate of the second control point.
- *
- * p4 ::
- * The end coordinate.
- *
- * @InOut:
- * min ::
- * The address of the current minimum.
- *
- * max ::
- * The address of the current maximum.
- */
- static FT_Pos
- cubic_peak( FT_Pos q1,
- FT_Pos q2,
- FT_Pos q3,
- FT_Pos q4 )
- {
- FT_Pos peak = 0;
- FT_Int shift;
-
-
- /* This function finds a peak of a cubic segment if it is above 0 */
- /* using iterative bisection of the segment, or returns 0. */
- /* The fixed-point arithmetic of bisection is inherently stable */
- /* but may loose accuracy in the two lowest bits. To compensate, */
- /* we upscale the segment if there is room. Large values may need */
- /* to be downscaled to avoid overflows during bisection. */
- /* It is called with either q2 or q3 positive, which is necessary */
- /* for the peak to exist and avoids undefined FT_MSB. */
-
- shift = 27 - FT_MSB( (FT_UInt32)( FT_ABS( q1 ) |
- FT_ABS( q2 ) |
- FT_ABS( q3 ) |
- FT_ABS( q4 ) ) );
-
- if ( shift > 0 )
- {
- /* upscaling too much just wastes time */
- if ( shift > 2 )
- shift = 2;
-
- q1 *= 1 << shift;
- q2 *= 1 << shift;
- q3 *= 1 << shift;
- q4 *= 1 << shift;
- }
- else
- {
- q1 >>= -shift;
- q2 >>= -shift;
- q3 >>= -shift;
- q4 >>= -shift;
- }
-
- /* for a peak to exist above 0, the cubic segment must have */
- /* at least one of its control off-points above 0. */
- while ( q2 > 0 || q3 > 0 )
- {
- /* determine which half contains the maximum and split */
- if ( q1 + q2 > q3 + q4 ) /* first half */
- {
- q4 = q4 + q3;
- q3 = q3 + q2;
- q2 = q2 + q1;
- q4 = q4 + q3;
- q3 = q3 + q2;
- q4 = ( q4 + q3 ) >> 3;
- q3 = q3 >> 2;
- q2 = q2 >> 1;
- }
- else /* second half */
- {
- q1 = q1 + q2;
- q2 = q2 + q3;
- q3 = q3 + q4;
- q1 = q1 + q2;
- q2 = q2 + q3;
- q1 = ( q1 + q2 ) >> 3;
- q2 = q2 >> 2;
- q3 = q3 >> 1;
- }
-
- /* check whether either end reached the maximum */
- if ( q1 == q2 && q1 >= q3 )
- {
- peak = q1;
- break;
- }
- if ( q3 == q4 && q2 <= q4 )
- {
- peak = q4;
- break;
- }
- }
-
- if ( shift > 0 )
- peak >>= shift;
- else
- peak <<= -shift;
-
- return peak;
- }
-
-
- static void
- BBox_Cubic_Check( FT_Pos p1,
- FT_Pos p2,
- FT_Pos p3,
- FT_Pos p4,
- FT_Pos* min,
- FT_Pos* max )
- {
- /* This function is only called when a control off-point is outside */
- /* the bbox that contains all on-points. So at least one of the */
- /* conditions below holds and cubic_peak is called with at least one */
- /* non-zero argument. */
-
- if ( p2 > *max || p3 > *max )
- *max += cubic_peak( p1 - *max, p2 - *max, p3 - *max, p4 - *max );
-
- /* now flip the signs to update the minimum */
- if ( p2 < *min || p3 < *min )
- *min -= cubic_peak( *min - p1, *min - p2, *min - p3, *min - p4 );
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * BBox_Cubic_To
- *
- * @Description:
- * This function is used as a `cubic_to' emitter during
- * FT_Outline_Decompose(). It checks a cubic Bezier curve with the
- * current bounding box, and computes its extrema if necessary to
- * update it.
- *
- * @Input:
- * control1 ::
- * A pointer to the first control point.
- *
- * control2 ::
- * A pointer to the second control point.
- *
- * to ::
- * A pointer to the destination vector.
- *
- * @InOut:
- * user ::
- * The address of the current walk context.
- *
- * @Return:
- * Always 0. Needed for the interface only.
- *
- * @Note:
- * In the case of a non-monotonous arc, we don't compute directly
- * extremum coordinates, we subdivide instead.
- */
- FT_CALLBACK_DEF( int )
- BBox_Cubic_To( const FT_Vector* control1,
- const FT_Vector* control2,
- const FT_Vector* to,
- void* user_ )
- {
- TBBox_Rec* user = (TBBox_Rec*)user_;
-
-
- /* We don't need to check `to' since it is always an on-point, */
- /* thus within the bbox. Only segments with an off-point outside */
- /* the bbox can possibly reach new extreme values. */
-
- if ( CHECK_X( control1, user->bbox ) ||
- CHECK_X( control2, user->bbox ) )
- BBox_Cubic_Check( user->last.x,
- control1->x,
- control2->x,
- to->x,
- &user->bbox.xMin,
- &user->bbox.xMax );
-
- if ( CHECK_Y( control1, user->bbox ) ||
- CHECK_Y( control2, user->bbox ) )
- BBox_Cubic_Check( user->last.y,
- control1->y,
- control2->y,
- to->y,
- &user->bbox.yMin,
- &user->bbox.yMax );
-
- user->last = *to;
-
- return 0;
- }
-
-
- FT_DEFINE_OUTLINE_FUNCS(
- bbox_interface,
-
- (FT_Outline_MoveTo_Func) BBox_Move_To, /* move_to */
- (FT_Outline_LineTo_Func) BBox_Line_To, /* line_to */
- (FT_Outline_ConicTo_Func)BBox_Conic_To, /* conic_to */
- (FT_Outline_CubicTo_Func)BBox_Cubic_To, /* cubic_to */
- 0, /* shift */
- 0 /* delta */
- )
-
-
- /* documentation is in ftbbox.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Outline_Get_BBox( FT_Outline* outline,
- FT_BBox *abbox )
- {
- FT_BBox cbox = { 0x7FFFFFFFL, 0x7FFFFFFFL,
- -0x7FFFFFFFL, -0x7FFFFFFFL };
- FT_BBox bbox = { 0x7FFFFFFFL, 0x7FFFFFFFL,
- -0x7FFFFFFFL, -0x7FFFFFFFL };
- FT_Vector* vec;
- FT_UShort n;
-
-
- if ( !abbox )
- return FT_THROW( Invalid_Argument );
-
- if ( !outline )
- return FT_THROW( Invalid_Outline );
-
- /* if outline is empty, return (0,0,0,0) */
- if ( outline->n_points == 0 || outline->n_contours == 0 )
- {
- abbox->xMin = abbox->xMax = 0;
- abbox->yMin = abbox->yMax = 0;
-
- return 0;
- }
-
- /* We compute the control box as well as the bounding box of */
- /* all `on' points in the outline. Then, if the two boxes */
- /* coincide, we exit immediately. */
-
- vec = outline->points;
-
- for ( n = 0; n < outline->n_points; n++ )
- {
- FT_UPDATE_BBOX( vec, cbox );
-
- if ( FT_CURVE_TAG( outline->tags[n] ) == FT_CURVE_TAG_ON )
- FT_UPDATE_BBOX( vec, bbox );
-
- vec++;
- }
-
- /* test two boxes for equality */
- if ( cbox.xMin < bbox.xMin || cbox.xMax > bbox.xMax ||
- cbox.yMin < bbox.yMin || cbox.yMax > bbox.yMax )
- {
- /* the two boxes are different, now walk over the outline to */
- /* get the Bezier arc extrema. */
-
- FT_Error error;
- TBBox_Rec user;
-
-
- user.bbox = bbox;
-
- error = FT_Outline_Decompose( outline, &bbox_interface, &user );
- if ( error )
- return error;
-
- *abbox = user.bbox;
- }
- else
- *abbox = bbox;
-
- return FT_Err_Ok;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/base/ftbdf.c b/contrib/libs/freetype/src/base/ftbdf.c
deleted file mode 100644
index d8e9fd7eaf..0000000000
--- a/contrib/libs/freetype/src/base/ftbdf.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/****************************************************************************
- *
- * ftbdf.c
- *
- * FreeType API for accessing BDF-specific strings (body).
- *
- * Copyright (C) 2002-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftdebug.h>
-
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/services/svbdf.h>
-
-
- /* documentation is in ftbdf.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Get_BDF_Charset_ID( FT_Face face,
- const char* *acharset_encoding,
- const char* *acharset_registry )
- {
- FT_Error error;
- const char* encoding = NULL;
- const char* registry = NULL;
-
- FT_Service_BDF service;
-
-
- if ( !face )
- return FT_THROW( Invalid_Face_Handle );
-
- FT_FACE_FIND_SERVICE( face, service, BDF );
-
- if ( service && service->get_charset_id )
- error = service->get_charset_id( face, &encoding, &registry );
- else
- error = FT_THROW( Invalid_Argument );
-
- if ( acharset_encoding )
- *acharset_encoding = encoding;
-
- if ( acharset_registry )
- *acharset_registry = registry;
-
- return error;
- }
-
-
- /* documentation is in ftbdf.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Get_BDF_Property( FT_Face face,
- const char* prop_name,
- BDF_PropertyRec *aproperty )
- {
- FT_Error error;
-
- FT_Service_BDF service;
-
-
- if ( !face )
- return FT_THROW( Invalid_Face_Handle );
-
- if ( !aproperty )
- return FT_THROW( Invalid_Argument );
-
- aproperty->type = BDF_PROPERTY_TYPE_NONE;
-
- FT_FACE_FIND_SERVICE( face, service, BDF );
-
- if ( service && service->get_property )
- error = service->get_property( face, prop_name, aproperty );
- else
- error = FT_THROW( Invalid_Argument );
-
- return error;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/base/ftbitmap.c b/contrib/libs/freetype/src/base/ftbitmap.c
deleted file mode 100644
index 4be145679f..0000000000
--- a/contrib/libs/freetype/src/base/ftbitmap.c
+++ /dev/null
@@ -1,1144 +0,0 @@
-/****************************************************************************
- *
- * ftbitmap.c
- *
- * FreeType utility functions for bitmaps (body).
- *
- * Copyright (C) 2004-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftdebug.h>
-
-#include <freetype/ftbitmap.h>
-#include <freetype/ftimage.h>
-#include <freetype/internal/ftobjs.h>
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT bitmap
-
-
- static
- const FT_Bitmap null_bitmap = { 0, 0, 0, NULL, 0, 0, 0, NULL };
-
-
- /* documentation is in ftbitmap.h */
-
- FT_EXPORT_DEF( void )
- FT_Bitmap_Init( FT_Bitmap *abitmap )
- {
- if ( abitmap )
- *abitmap = null_bitmap;
- }
-
-
- /* deprecated function name; retained for ABI compatibility */
-
- FT_EXPORT_DEF( void )
- FT_Bitmap_New( FT_Bitmap *abitmap )
- {
- if ( abitmap )
- *abitmap = null_bitmap;
- }
-
-
- /* documentation is in ftbitmap.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Bitmap_Copy( FT_Library library,
- const FT_Bitmap *source,
- FT_Bitmap *target)
- {
- FT_Memory memory;
- FT_Error error = FT_Err_Ok;
- FT_Int pitch;
- FT_Int flip;
-
-
- if ( !library )
- return FT_THROW( Invalid_Library_Handle );
-
- if ( !source || !target )
- return FT_THROW( Invalid_Argument );
-
- if ( source == target )
- return FT_Err_Ok;
-
- flip = ( source->pitch < 0 && target->pitch > 0 ) ||
- ( source->pitch > 0 && target->pitch < 0 );
-
- memory = library->memory;
- FT_FREE( target->buffer );
-
- *target = *source;
-
- if ( flip )
- target->pitch = -target->pitch;
-
- if ( !source->buffer )
- return FT_Err_Ok;
-
- pitch = source->pitch;
- if ( pitch < 0 )
- pitch = -pitch;
-
- FT_MEM_QALLOC_MULT( target->buffer, target->rows, pitch );
-
- if ( !error )
- {
- if ( flip )
- {
- /* take care of bitmap flow */
- FT_UInt i;
- FT_Byte* s = source->buffer;
- FT_Byte* t = target->buffer;
-
-
- t += (FT_ULong)pitch * ( target->rows - 1 );
-
- for ( i = target->rows; i > 0; i-- )
- {
- FT_ARRAY_COPY( t, s, pitch );
-
- s += pitch;
- t -= pitch;
- }
- }
- else
- FT_MEM_COPY( target->buffer, source->buffer,
- (FT_Long)source->rows * pitch );
- }
-
- return error;
- }
-
-
- /* Enlarge `bitmap' horizontally and vertically by `xpixels' */
- /* and `ypixels', respectively. */
-
- static FT_Error
- ft_bitmap_assure_buffer( FT_Memory memory,
- FT_Bitmap* bitmap,
- FT_UInt xpixels,
- FT_UInt ypixels )
- {
- FT_Error error;
- unsigned int pitch;
- unsigned int new_pitch;
- FT_UInt bpp;
- FT_UInt width, height;
- unsigned char* buffer = NULL;
-
-
- width = bitmap->width;
- height = bitmap->rows;
- pitch = (unsigned int)FT_ABS( bitmap->pitch );
-
- switch ( bitmap->pixel_mode )
- {
- case FT_PIXEL_MODE_MONO:
- bpp = 1;
- new_pitch = ( width + xpixels + 7 ) >> 3;
- break;
- case FT_PIXEL_MODE_GRAY2:
- bpp = 2;
- new_pitch = ( width + xpixels + 3 ) >> 2;
- break;
- case FT_PIXEL_MODE_GRAY4:
- bpp = 4;
- new_pitch = ( width + xpixels + 1 ) >> 1;
- break;
- case FT_PIXEL_MODE_GRAY:
- case FT_PIXEL_MODE_LCD:
- case FT_PIXEL_MODE_LCD_V:
- bpp = 8;
- new_pitch = width + xpixels;
- break;
- default:
- return FT_THROW( Invalid_Glyph_Format );
- }
-
- /* if no need to allocate memory */
- if ( ypixels == 0 && new_pitch <= pitch )
- {
- /* zero the padding */
- FT_UInt bit_width = pitch * 8;
- FT_UInt bit_last = ( width + xpixels ) * bpp;
-
-
- if ( bit_last < bit_width )
- {
- FT_Byte* line = bitmap->buffer + ( bit_last >> 3 );
- FT_Byte* end = bitmap->buffer + pitch;
- FT_UInt shift = bit_last & 7;
- FT_UInt mask = 0xFF00U >> shift;
- FT_UInt count = height;
-
-
- for ( ; count > 0; count--, line += pitch, end += pitch )
- {
- FT_Byte* write = line;
-
-
- if ( shift > 0 )
- {
- write[0] = (FT_Byte)( write[0] & mask );
- write++;
- }
- if ( write < end )
- FT_MEM_ZERO( write, end - write );
- }
- }
-
- return FT_Err_Ok;
- }
-
- /* otherwise allocate new buffer */
- if ( FT_QALLOC_MULT( buffer, bitmap->rows + ypixels, new_pitch ) )
- return error;
-
- /* new rows get added at the top of the bitmap, */
- /* thus take care of the flow direction */
- if ( bitmap->pitch > 0 )
- {
- FT_UInt len = ( width * bpp + 7 ) >> 3;
-
- unsigned char* in = bitmap->buffer;
- unsigned char* out = buffer;
-
- unsigned char* limit = bitmap->buffer + pitch * bitmap->rows;
- unsigned int delta = new_pitch - len;
-
-
- FT_MEM_ZERO( out, new_pitch * ypixels );
- out += new_pitch * ypixels;
-
- while ( in < limit )
- {
- FT_MEM_COPY( out, in, len );
- in += pitch;
- out += len;
-
- /* we use FT_QALLOC_MULT, which doesn't zero out the buffer; */
- /* consequently, we have to manually zero out the remaining bytes */
- FT_MEM_ZERO( out, delta );
- out += delta;
- }
- }
- else
- {
- FT_UInt len = ( width * bpp + 7 ) >> 3;
-
- unsigned char* in = bitmap->buffer;
- unsigned char* out = buffer;
-
- unsigned char* limit = bitmap->buffer + pitch * bitmap->rows;
- unsigned int delta = new_pitch - len;
-
-
- while ( in < limit )
- {
- FT_MEM_COPY( out, in, len );
- in += pitch;
- out += len;
-
- FT_MEM_ZERO( out, delta );
- out += delta;
- }
-
- FT_MEM_ZERO( out, new_pitch * ypixels );
- }
-
- FT_FREE( bitmap->buffer );
- bitmap->buffer = buffer;
-
- /* set pitch only, width and height are left untouched */
- if ( bitmap->pitch < 0 )
- bitmap->pitch = -(int)new_pitch;
- else
- bitmap->pitch = (int)new_pitch;
-
- return FT_Err_Ok;
- }
-
-
- /* documentation is in ftbitmap.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Bitmap_Embolden( FT_Library library,
- FT_Bitmap* bitmap,
- FT_Pos xStrength,
- FT_Pos yStrength )
- {
- FT_Error error;
- unsigned char* p;
- FT_Int i, x, pitch;
- FT_UInt y;
- FT_Int xstr, ystr;
-
-
- if ( !library )
- return FT_THROW( Invalid_Library_Handle );
-
- if ( !bitmap || !bitmap->buffer )
- return FT_THROW( Invalid_Argument );
-
- if ( ( ( FT_PIX_ROUND( xStrength ) >> 6 ) > FT_INT_MAX ) ||
- ( ( FT_PIX_ROUND( yStrength ) >> 6 ) > FT_INT_MAX ) )
- return FT_THROW( Invalid_Argument );
-
- xstr = (FT_Int)FT_PIX_ROUND( xStrength ) >> 6;
- ystr = (FT_Int)FT_PIX_ROUND( yStrength ) >> 6;
-
- if ( xstr == 0 && ystr == 0 )
- return FT_Err_Ok;
- else if ( xstr < 0 || ystr < 0 )
- return FT_THROW( Invalid_Argument );
-
- switch ( bitmap->pixel_mode )
- {
- case FT_PIXEL_MODE_GRAY2:
- case FT_PIXEL_MODE_GRAY4:
- {
- FT_Bitmap tmp;
-
-
- /* convert to 8bpp */
- FT_Bitmap_Init( &tmp );
- error = FT_Bitmap_Convert( library, bitmap, &tmp, 1 );
- if ( error )
- return error;
-
- FT_Bitmap_Done( library, bitmap );
- *bitmap = tmp;
- }
- break;
-
- case FT_PIXEL_MODE_MONO:
- if ( xstr > 8 )
- xstr = 8;
- break;
-
- case FT_PIXEL_MODE_LCD:
- xstr *= 3;
- break;
-
- case FT_PIXEL_MODE_LCD_V:
- ystr *= 3;
- break;
-
- case FT_PIXEL_MODE_BGRA:
- /* We don't embolden color glyphs. */
- return FT_Err_Ok;
- }
-
- error = ft_bitmap_assure_buffer( library->memory, bitmap,
- (FT_UInt)xstr, (FT_UInt)ystr );
- if ( error )
- return error;
-
- /* take care of bitmap flow */
- pitch = bitmap->pitch;
- if ( pitch > 0 )
- p = bitmap->buffer + pitch * ystr;
- else
- {
- pitch = -pitch;
- p = bitmap->buffer + (FT_UInt)pitch * ( bitmap->rows - 1 );
- }
-
- /* for each row */
- for ( y = 0; y < bitmap->rows; y++ )
- {
- /*
- * Horizontally:
- *
- * From the last pixel on, make each pixel or'ed with the
- * `xstr' pixels before it.
- */
- for ( x = pitch - 1; x >= 0; x-- )
- {
- unsigned char tmp;
-
-
- tmp = p[x];
- for ( i = 1; i <= xstr; i++ )
- {
- if ( bitmap->pixel_mode == FT_PIXEL_MODE_MONO )
- {
- p[x] |= tmp >> i;
-
- /* the maximum value of 8 for `xstr' comes from here */
- if ( x > 0 )
- p[x] |= p[x - 1] << ( 8 - i );
-
-#if 0
- if ( p[x] == 0xFF )
- break;
-#endif
- }
- else
- {
- if ( x - i >= 0 )
- {
- if ( p[x] + p[x - i] > bitmap->num_grays - 1 )
- {
- p[x] = (unsigned char)( bitmap->num_grays - 1 );
- break;
- }
- else
- {
- p[x] = (unsigned char)( p[x] + p[x - i] );
- if ( p[x] == bitmap->num_grays - 1 )
- break;
- }
- }
- else
- break;
- }
- }
- }
-
- /*
- * Vertically:
- *
- * Make the above `ystr' rows or'ed with it.
- */
- for ( x = 1; x <= ystr; x++ )
- {
- unsigned char* q;
-
-
- q = p - bitmap->pitch * x;
- for ( i = 0; i < pitch; i++ )
- q[i] |= p[i];
- }
-
- p += bitmap->pitch;
- }
-
- bitmap->width += (FT_UInt)xstr;
- bitmap->rows += (FT_UInt)ystr;
-
- return FT_Err_Ok;
- }
-
-
- static FT_Byte
- ft_gray_for_premultiplied_srgb_bgra( const FT_Byte* bgra )
- {
- FT_UInt a = bgra[3];
- FT_UInt l;
-
-
- /* Short-circuit transparent color to avoid division by zero. */
- if ( !a )
- return 0;
-
- /*
- * Luminosity for sRGB is defined using ~0.2126,0.7152,0.0722
- * coefficients for RGB channels *on the linear colors*.
- * A gamma of 2.2 is fair to assume. And then, we need to
- * undo the premultiplication too.
- *
- * http://www.brucelindbloom.com/index.html?WorkingSpaceInfo.html#SideNotes
- *
- * We do the computation with integers only, applying a gamma of 2.0.
- * We guarantee 32-bit arithmetic to avoid overflow but the resulting
- * luminosity fits into 16 bits.
- *
- */
-
- l = ( 4731UL /* 0.072186 * 65536 */ * bgra[0] * bgra[0] +
- 46868UL /* 0.715158 * 65536 */ * bgra[1] * bgra[1] +
- 13937UL /* 0.212656 * 65536 */ * bgra[2] * bgra[2] ) >> 16;
-
- /*
- * Final transparency can be determined as follows.
- *
- * - If alpha is zero, we want 0.
- * - If alpha is zero and luminosity is zero, we want 255.
- * - If alpha is zero and luminosity is one, we want 0.
- *
- * So the formula is a * (1 - l) = a - l * a.
- *
- * We still need to undo premultiplication by dividing l by a*a.
- *
- */
-
- return (FT_Byte)( a - l / a );
- }
-
-
- /* documentation is in ftbitmap.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Bitmap_Convert( FT_Library library,
- const FT_Bitmap *source,
- FT_Bitmap *target,
- FT_Int alignment )
- {
- FT_Error error = FT_Err_Ok;
- FT_Memory memory;
-
- FT_Byte* s;
- FT_Byte* t;
-
-
- if ( !library )
- return FT_THROW( Invalid_Library_Handle );
-
- if ( !source || !target )
- return FT_THROW( Invalid_Argument );
-
- memory = library->memory;
-
- switch ( source->pixel_mode )
- {
- case FT_PIXEL_MODE_MONO:
- case FT_PIXEL_MODE_GRAY:
- case FT_PIXEL_MODE_GRAY2:
- case FT_PIXEL_MODE_GRAY4:
- case FT_PIXEL_MODE_LCD:
- case FT_PIXEL_MODE_LCD_V:
- case FT_PIXEL_MODE_BGRA:
- {
- FT_Int width = (FT_Int)source->width;
- FT_Int neg = ( target->pitch == 0 && source->pitch < 0 ) ||
- target->pitch < 0;
-
-
- FT_Bitmap_Done( library, target );
-
- target->pixel_mode = FT_PIXEL_MODE_GRAY;
- target->rows = source->rows;
- target->width = source->width;
-
- if ( alignment )
- {
- FT_Int rem = width % alignment;
-
-
- if ( rem )
- width = alignment > 0 ? width - rem + alignment
- : width - rem - alignment;
- }
-
- if ( FT_QALLOC_MULT( target->buffer, target->rows, width ) )
- return error;
-
- target->pitch = neg ? -width : width;
- }
- break;
-
- default:
- error = FT_THROW( Invalid_Argument );
- }
-
- s = source->buffer;
- t = target->buffer;
-
- /* take care of bitmap flow */
- if ( source->pitch < 0 )
- s -= source->pitch * (FT_Int)( source->rows - 1 );
- if ( target->pitch < 0 )
- t -= target->pitch * (FT_Int)( target->rows - 1 );
-
- switch ( source->pixel_mode )
- {
- case FT_PIXEL_MODE_MONO:
- {
- FT_UInt i;
-
-
- target->num_grays = 2;
-
- for ( i = source->rows; i > 0; i-- )
- {
- FT_Byte* ss = s;
- FT_Byte* tt = t;
- FT_UInt j;
-
-
- /* get the full bytes */
- for ( j = source->width >> 3; j > 0; j-- )
- {
- FT_Int val = ss[0]; /* avoid a byte->int cast on each line */
-
-
- tt[0] = (FT_Byte)( ( val & 0x80 ) >> 7 );
- tt[1] = (FT_Byte)( ( val & 0x40 ) >> 6 );
- tt[2] = (FT_Byte)( ( val & 0x20 ) >> 5 );
- tt[3] = (FT_Byte)( ( val & 0x10 ) >> 4 );
- tt[4] = (FT_Byte)( ( val & 0x08 ) >> 3 );
- tt[5] = (FT_Byte)( ( val & 0x04 ) >> 2 );
- tt[6] = (FT_Byte)( ( val & 0x02 ) >> 1 );
- tt[7] = (FT_Byte)( val & 0x01 );
-
- tt += 8;
- ss += 1;
- }
-
- /* get remaining pixels (if any) */
- j = source->width & 7;
- if ( j > 0 )
- {
- FT_Int val = *ss;
-
-
- for ( ; j > 0; j-- )
- {
- tt[0] = (FT_Byte)( ( val & 0x80 ) >> 7);
- val <<= 1;
- tt += 1;
- }
- }
-
- s += source->pitch;
- t += target->pitch;
- }
- }
- break;
-
-
- case FT_PIXEL_MODE_GRAY:
- case FT_PIXEL_MODE_LCD:
- case FT_PIXEL_MODE_LCD_V:
- {
- FT_UInt width = source->width;
- FT_UInt i;
-
-
- target->num_grays = 256;
-
- for ( i = source->rows; i > 0; i-- )
- {
- FT_ARRAY_COPY( t, s, width );
-
- s += source->pitch;
- t += target->pitch;
- }
- }
- break;
-
-
- case FT_PIXEL_MODE_GRAY2:
- {
- FT_UInt i;
-
-
- target->num_grays = 4;
-
- for ( i = source->rows; i > 0; i-- )
- {
- FT_Byte* ss = s;
- FT_Byte* tt = t;
- FT_UInt j;
-
-
- /* get the full bytes */
- for ( j = source->width >> 2; j > 0; j-- )
- {
- FT_Int val = ss[0];
-
-
- tt[0] = (FT_Byte)( ( val & 0xC0 ) >> 6 );
- tt[1] = (FT_Byte)( ( val & 0x30 ) >> 4 );
- tt[2] = (FT_Byte)( ( val & 0x0C ) >> 2 );
- tt[3] = (FT_Byte)( ( val & 0x03 ) );
-
- ss += 1;
- tt += 4;
- }
-
- j = source->width & 3;
- if ( j > 0 )
- {
- FT_Int val = ss[0];
-
-
- for ( ; j > 0; j-- )
- {
- tt[0] = (FT_Byte)( ( val & 0xC0 ) >> 6 );
- val <<= 2;
- tt += 1;
- }
- }
-
- s += source->pitch;
- t += target->pitch;
- }
- }
- break;
-
-
- case FT_PIXEL_MODE_GRAY4:
- {
- FT_UInt i;
-
-
- target->num_grays = 16;
-
- for ( i = source->rows; i > 0; i-- )
- {
- FT_Byte* ss = s;
- FT_Byte* tt = t;
- FT_UInt j;
-
-
- /* get the full bytes */
- for ( j = source->width >> 1; j > 0; j-- )
- {
- FT_Int val = ss[0];
-
-
- tt[0] = (FT_Byte)( ( val & 0xF0 ) >> 4 );
- tt[1] = (FT_Byte)( ( val & 0x0F ) );
-
- ss += 1;
- tt += 2;
- }
-
- if ( source->width & 1 )
- tt[0] = (FT_Byte)( ( ss[0] & 0xF0 ) >> 4 );
-
- s += source->pitch;
- t += target->pitch;
- }
- }
- break;
-
-
- case FT_PIXEL_MODE_BGRA:
- {
- FT_UInt i;
-
-
- target->num_grays = 256;
-
- for ( i = source->rows; i > 0; i-- )
- {
- FT_Byte* ss = s;
- FT_Byte* tt = t;
- FT_UInt j;
-
-
- for ( j = source->width; j > 0; j-- )
- {
- tt[0] = ft_gray_for_premultiplied_srgb_bgra( ss );
-
- ss += 4;
- tt += 1;
- }
-
- s += source->pitch;
- t += target->pitch;
- }
- }
- break;
-
- default:
- ;
- }
-
- return error;
- }
-
-
- /* documentation is in ftbitmap.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Bitmap_Blend( FT_Library library,
- const FT_Bitmap* source_,
- const FT_Vector source_offset_,
- FT_Bitmap* target,
- FT_Vector *atarget_offset,
- FT_Color color )
- {
- FT_Error error = FT_Err_Ok;
- FT_Memory memory;
-
- FT_Bitmap source_bitmap;
- const FT_Bitmap* source;
-
- FT_Vector source_offset;
- FT_Vector target_offset;
-
- FT_Bool free_source_bitmap = 0;
- FT_Bool free_target_bitmap_on_error = 0;
-
- FT_Pos source_llx, source_lly, source_urx, source_ury;
- FT_Pos target_llx, target_lly, target_urx, target_ury;
- FT_Pos final_llx, final_lly, final_urx, final_ury;
-
- unsigned int final_rows, final_width;
- long x, y;
-
-
- if ( !library || !target || !source_ || !atarget_offset )
- return FT_THROW( Invalid_Argument );
-
- memory = library->memory;
-
- if ( !( target->pixel_mode == FT_PIXEL_MODE_NONE ||
- ( target->pixel_mode == FT_PIXEL_MODE_BGRA &&
- target->buffer ) ) )
- return FT_THROW( Invalid_Argument );
-
- if ( source_->pixel_mode == FT_PIXEL_MODE_NONE )
- return FT_Err_Ok; /* nothing to do */
-
- /* pitches must have the same sign */
- if ( target->pixel_mode == FT_PIXEL_MODE_BGRA &&
- ( source_->pitch ^ target->pitch ) < 0 )
- return FT_THROW( Invalid_Argument );
-
- if ( !( source_->width && source_->rows ) )
- return FT_Err_Ok; /* nothing to do */
-
- /* assure integer pixel offsets */
- source_offset.x = FT_PIX_FLOOR( source_offset_.x );
- source_offset.y = FT_PIX_FLOOR( source_offset_.y );
- target_offset.x = FT_PIX_FLOOR( atarget_offset->x );
- target_offset.y = FT_PIX_FLOOR( atarget_offset->y );
-
- /* get source bitmap dimensions */
- source_llx = source_offset.x;
- if ( FT_LONG_MIN + (FT_Pos)( source_->rows << 6 ) + 64 > source_offset.y )
- {
- FT_TRACE5((
- "FT_Bitmap_Blend: y coordinate overflow in source bitmap\n" ));
- return FT_THROW( Invalid_Argument );
- }
- source_lly = source_offset.y - ( source_->rows << 6 );
-
- if ( FT_LONG_MAX - (FT_Pos)( source_->width << 6 ) - 64 < source_llx )
- {
- FT_TRACE5((
- "FT_Bitmap_Blend: x coordinate overflow in source bitmap\n" ));
- return FT_THROW( Invalid_Argument );
- }
- source_urx = source_llx + ( source_->width << 6 );
- source_ury = source_offset.y;
-
- /* get target bitmap dimensions */
- if ( target->width && target->rows )
- {
- target_llx = target_offset.x;
- if ( FT_LONG_MIN + (FT_Pos)( target->rows << 6 ) > target_offset.y )
- {
- FT_TRACE5((
- "FT_Bitmap_Blend: y coordinate overflow in target bitmap\n" ));
- return FT_THROW( Invalid_Argument );
- }
- target_lly = target_offset.y - ( target->rows << 6 );
-
- if ( FT_LONG_MAX - (FT_Pos)( target->width << 6 ) < target_llx )
- {
- FT_TRACE5((
- "FT_Bitmap_Blend: x coordinate overflow in target bitmap\n" ));
- return FT_THROW( Invalid_Argument );
- }
- target_urx = target_llx + ( target->width << 6 );
- target_ury = target_offset.y;
- }
- else
- {
- target_llx = FT_LONG_MAX;
- target_lly = FT_LONG_MAX;
- target_urx = FT_LONG_MIN;
- target_ury = FT_LONG_MIN;
- }
-
- /* compute final bitmap dimensions */
- final_llx = FT_MIN( source_llx, target_llx );
- final_lly = FT_MIN( source_lly, target_lly );
- final_urx = FT_MAX( source_urx, target_urx );
- final_ury = FT_MAX( source_ury, target_ury );
-
- final_width = ( final_urx - final_llx ) >> 6;
- final_rows = ( final_ury - final_lly ) >> 6;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- FT_TRACE5(( "FT_Bitmap_Blend:\n" ));
- FT_TRACE5(( " source bitmap: (%ld, %ld) -- (%ld, %ld); %d x %d\n",
- source_llx / 64, source_lly / 64,
- source_urx / 64, source_ury / 64,
- source_->width, source_->rows ));
-
- if ( target->width && target->rows )
- FT_TRACE5(( " target bitmap: (%ld, %ld) -- (%ld, %ld); %d x %d\n",
- target_llx / 64, target_lly / 64,
- target_urx / 64, target_ury / 64,
- target->width, target->rows ));
- else
- FT_TRACE5(( " target bitmap: empty\n" ));
-
- if ( final_width && final_rows )
- FT_TRACE5(( " final bitmap: (%ld, %ld) -- (%ld, %ld); %d x %d\n",
- final_llx / 64, final_lly / 64,
- final_urx / 64, final_ury / 64,
- final_width, final_rows ));
- else
- FT_TRACE5(( " final bitmap: empty\n" ));
-#endif /* FT_DEBUG_LEVEL_TRACE */
-
- if ( !( final_width && final_rows ) )
- return FT_Err_Ok; /* nothing to do */
-
- /* for blending, set offset vector of final bitmap */
- /* temporarily to (0,0) */
- source_llx -= final_llx;
- source_lly -= final_lly;
-
- if ( target->width && target->rows )
- {
- target_llx -= final_llx;
- target_lly -= final_lly;
- }
-
- /* set up target bitmap */
- if ( target->pixel_mode == FT_PIXEL_MODE_NONE )
- {
- /* create new empty bitmap */
- target->width = final_width;
- target->rows = final_rows;
- target->pixel_mode = FT_PIXEL_MODE_BGRA;
- target->pitch = (int)final_width * 4;
- target->num_grays = 256;
-
- if ( FT_LONG_MAX / target->pitch < (int)target->rows )
- {
- FT_TRACE5(( "FT_Blend_Bitmap: target bitmap too large (%d x %d)\n",
- final_width, final_rows ));
- return FT_THROW( Invalid_Argument );
- }
-
- if ( FT_ALLOC( target->buffer, target->pitch * (int)target->rows ) )
- return error;
-
- free_target_bitmap_on_error = 1;
- }
- else if ( target->width != final_width ||
- target->rows != final_rows )
- {
- /* adjust old bitmap to enlarged size */
- int pitch, new_pitch;
-
- unsigned char* buffer = NULL;
-
-
- pitch = target->pitch;
-
- if ( pitch < 0 )
- pitch = -pitch;
-
- new_pitch = (int)final_width * 4;
-
- if ( FT_LONG_MAX / new_pitch < (int)final_rows )
- {
- FT_TRACE5(( "FT_Blend_Bitmap: target bitmap too large (%d x %d)\n",
- final_width, final_rows ));
- return FT_THROW( Invalid_Argument );
- }
-
- /* TODO: provide an in-buffer solution for large bitmaps */
- /* to avoid allocation of a new buffer */
- if ( FT_ALLOC( buffer, new_pitch * (int)final_rows ) )
- goto Error;
-
- /* copy data to new buffer */
- x = target_llx >> 6;
- y = target_lly >> 6;
-
- /* the bitmap flow is from top to bottom, */
- /* but y is measured from bottom to top */
- if ( target->pitch < 0 )
- {
- /* XXX */
- }
- else
- {
- unsigned char* p =
- target->buffer;
- unsigned char* q =
- buffer +
- ( final_rows - y - target->rows ) * new_pitch +
- x * 4;
- unsigned char* limit_p =
- p + pitch * (int)target->rows;
-
-
- while ( p < limit_p )
- {
- FT_MEM_COPY( q, p, pitch );
-
- p += pitch;
- q += new_pitch;
- }
- }
-
- FT_FREE( target->buffer );
-
- target->width = final_width;
- target->rows = final_rows;
-
- if ( target->pitch < 0 )
- target->pitch = -new_pitch;
- else
- target->pitch = new_pitch;
-
- target->buffer = buffer;
- }
-
- /* adjust source bitmap if necessary */
- if ( source_->pixel_mode != FT_PIXEL_MODE_GRAY )
- {
- FT_Bitmap_Init( &source_bitmap );
- error = FT_Bitmap_Convert( library, source_, &source_bitmap, 1 );
- if ( error )
- goto Error;
-
- source = &source_bitmap;
- free_source_bitmap = 1;
- }
- else
- source = source_;
-
- /* do blending; the code below returns pre-multiplied channels, */
- /* similar to what FreeType gets from `CBDT' tables */
- x = source_llx >> 6;
- y = source_lly >> 6;
-
- /* the bitmap flow is from top to bottom, */
- /* but y is measured from bottom to top */
- if ( target->pitch < 0 )
- {
- /* XXX */
- }
- else
- {
- unsigned char* p =
- source->buffer;
- unsigned char* q =
- target->buffer +
- ( target->rows - y - source->rows ) * target->pitch +
- x * 4;
- unsigned char* limit_p =
- p + source->pitch * (int)source->rows;
-
-
- while ( p < limit_p )
- {
- unsigned char* r = p;
- unsigned char* s = q;
- unsigned char* limit_r = r + source->width;
-
-
- while ( r < limit_r )
- {
- int aa = *r++;
- int fa = color.alpha * aa / 255;
-
- int fb = color.blue * fa / 255;
- int fg = color.green * fa / 255;
- int fr = color.red * fa / 255;
-
- int ba2 = 255 - fa;
-
- int bb = s[0];
- int bg = s[1];
- int br = s[2];
- int ba = s[3];
-
-
- *s++ = (unsigned char)( bb * ba2 / 255 + fb );
- *s++ = (unsigned char)( bg * ba2 / 255 + fg );
- *s++ = (unsigned char)( br * ba2 / 255 + fr );
- *s++ = (unsigned char)( ba * ba2 / 255 + fa );
- }
-
- p += source->pitch;
- q += target->pitch;
- }
- }
-
- atarget_offset->x = final_llx;
- atarget_offset->y = final_lly + ( final_rows << 6 );
-
- Error:
- if ( error && free_target_bitmap_on_error )
- FT_Bitmap_Done( library, target );
-
- if ( free_source_bitmap )
- FT_Bitmap_Done( library, &source_bitmap );
-
- return error;
- }
-
-
- /* documentation is in ftbitmap.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_GlyphSlot_Own_Bitmap( FT_GlyphSlot slot )
- {
- if ( slot && slot->format == FT_GLYPH_FORMAT_BITMAP &&
- !( slot->internal->flags & FT_GLYPH_OWN_BITMAP ) )
- {
- FT_Bitmap bitmap;
- FT_Error error;
-
-
- FT_Bitmap_Init( &bitmap );
- error = FT_Bitmap_Copy( slot->library, &slot->bitmap, &bitmap );
- if ( error )
- return error;
-
- slot->bitmap = bitmap;
- slot->internal->flags |= FT_GLYPH_OWN_BITMAP;
- }
-
- return FT_Err_Ok;
- }
-
-
- /* documentation is in ftbitmap.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Bitmap_Done( FT_Library library,
- FT_Bitmap *bitmap )
- {
- FT_Memory memory;
-
-
- if ( !library )
- return FT_THROW( Invalid_Library_Handle );
-
- if ( !bitmap )
- return FT_THROW( Invalid_Argument );
-
- memory = library->memory;
-
- FT_FREE( bitmap->buffer );
- *bitmap = null_bitmap;
-
- return FT_Err_Ok;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/base/ftcalc.c b/contrib/libs/freetype/src/base/ftcalc.c
deleted file mode 100644
index 92de09ed87..0000000000
--- a/contrib/libs/freetype/src/base/ftcalc.c
+++ /dev/null
@@ -1,1126 +0,0 @@
-/****************************************************************************
- *
- * ftcalc.c
- *
- * Arithmetic computations (body).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
- /**************************************************************************
- *
- * Support for 1-complement arithmetic has been totally dropped in this
- * release. You can still write your own code if you need it.
- *
- */
-
- /**************************************************************************
- *
- * Implementing basic computation routines.
- *
- * FT_MulDiv(), FT_MulFix(), FT_DivFix(), FT_RoundFix(), FT_CeilFix(),
- * and FT_FloorFix() are declared in freetype.h.
- *
- */
-
-
-#include <freetype/ftglyph.h>
-#include <freetype/fttrigon.h>
-#include <freetype/internal/ftcalc.h>
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftobjs.h>
-
-
-#ifdef FT_MULFIX_ASSEMBLER
-#undef FT_MulFix
-#endif
-
-/* we need to emulate a 64-bit data type if a real one isn't available */
-
-#ifndef FT_INT64
-
- typedef struct FT_Int64_
- {
- FT_UInt32 lo;
- FT_UInt32 hi;
-
- } FT_Int64;
-
-#endif /* !FT_INT64 */
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT calc
-
-
- /* transfer sign, leaving a positive number; */
- /* we need an unsigned value to safely negate INT_MIN (or LONG_MIN) */
-#define FT_MOVE_SIGN( utype, x, x_unsigned, s ) \
- FT_BEGIN_STMNT \
- if ( x < 0 ) \
- { \
- x_unsigned = 0U - (utype)x; \
- s = -s; \
- } \
- else \
- x_unsigned = (utype)x; \
- FT_END_STMNT
-
- /* The following three functions are available regardless of whether */
- /* FT_INT64 is defined. */
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Fixed )
- FT_RoundFix( FT_Fixed a )
- {
- return ( ADD_LONG( a, 0x8000L - ( a < 0 ) ) ) & ~0xFFFFL;
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Fixed )
- FT_CeilFix( FT_Fixed a )
- {
- return ( ADD_LONG( a, 0xFFFFL ) ) & ~0xFFFFL;
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Fixed )
- FT_FloorFix( FT_Fixed a )
- {
- return a & ~0xFFFFL;
- }
-
-#ifndef FT_MSB
-
- FT_BASE_DEF( FT_Int )
- FT_MSB( FT_UInt32 z )
- {
- FT_Int shift = 0;
-
-
- /* determine msb bit index in `shift' */
- if ( z & 0xFFFF0000UL )
- {
- z >>= 16;
- shift += 16;
- }
- if ( z & 0x0000FF00UL )
- {
- z >>= 8;
- shift += 8;
- }
- if ( z & 0x000000F0UL )
- {
- z >>= 4;
- shift += 4;
- }
- if ( z & 0x0000000CUL )
- {
- z >>= 2;
- shift += 2;
- }
- if ( z & 0x00000002UL )
- {
- /* z >>= 1; */
- shift += 1;
- }
-
- return shift;
- }
-
-#endif /* !FT_MSB */
-
-
- /* documentation is in ftcalc.h */
-
- FT_BASE_DEF( FT_Fixed )
- FT_Hypot( FT_Fixed x,
- FT_Fixed y )
- {
- FT_Vector v;
-
-
- v.x = x;
- v.y = y;
-
- return FT_Vector_Length( &v );
- }
-
-
-#ifdef FT_INT64
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Long )
- FT_MulDiv( FT_Long a_,
- FT_Long b_,
- FT_Long c_ )
- {
- FT_Int s = 1;
- FT_UInt64 a, b, c, d;
- FT_Long d_;
-
-
- FT_MOVE_SIGN( FT_UInt64, a_, a, s );
- FT_MOVE_SIGN( FT_UInt64, b_, b, s );
- FT_MOVE_SIGN( FT_UInt64, c_, c, s );
-
- d = c > 0 ? ( a * b + ( c >> 1 ) ) / c
- : 0x7FFFFFFFUL;
-
- d_ = (FT_Long)d;
-
- return s < 0 ? NEG_LONG( d_ ) : d_;
- }
-
-
- /* documentation is in ftcalc.h */
-
- FT_BASE_DEF( FT_Long )
- FT_MulDiv_No_Round( FT_Long a_,
- FT_Long b_,
- FT_Long c_ )
- {
- FT_Int s = 1;
- FT_UInt64 a, b, c, d;
- FT_Long d_;
-
-
- FT_MOVE_SIGN( FT_UInt64, a_, a, s );
- FT_MOVE_SIGN( FT_UInt64, b_, b, s );
- FT_MOVE_SIGN( FT_UInt64, c_, c, s );
-
- d = c > 0 ? a * b / c
- : 0x7FFFFFFFUL;
-
- d_ = (FT_Long)d;
-
- return s < 0 ? NEG_LONG( d_ ) : d_;
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Long )
- FT_MulFix( FT_Long a_,
- FT_Long b_ )
- {
-#ifdef FT_MULFIX_ASSEMBLER
-
- return FT_MULFIX_ASSEMBLER( (FT_Int32)a_, (FT_Int32)b_ );
-
-#else
-
- FT_Int64 ab = (FT_Int64)a_ * (FT_Int64)b_;
-
- /* this requires arithmetic right shift of signed numbers */
- return (FT_Long)( ( ab + 0x8000L - ( ab < 0 ) ) >> 16 );
-
-#endif /* FT_MULFIX_ASSEMBLER */
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Long )
- FT_DivFix( FT_Long a_,
- FT_Long b_ )
- {
- FT_Int s = 1;
- FT_UInt64 a, b, q;
- FT_Long q_;
-
-
- FT_MOVE_SIGN( FT_UInt64, a_, a, s );
- FT_MOVE_SIGN( FT_UInt64, b_, b, s );
-
- q = b > 0 ? ( ( a << 16 ) + ( b >> 1 ) ) / b
- : 0x7FFFFFFFUL;
-
- q_ = (FT_Long)q;
-
- return s < 0 ? NEG_LONG( q_ ) : q_;
- }
-
-
-#else /* !FT_INT64 */
-
-
- static void
- ft_multo64( FT_UInt32 x,
- FT_UInt32 y,
- FT_Int64 *z )
- {
- FT_UInt32 lo1, hi1, lo2, hi2, lo, hi, i1, i2;
-
-
- lo1 = x & 0x0000FFFFU; hi1 = x >> 16;
- lo2 = y & 0x0000FFFFU; hi2 = y >> 16;
-
- lo = lo1 * lo2;
- i1 = lo1 * hi2;
- i2 = lo2 * hi1;
- hi = hi1 * hi2;
-
- /* Check carry overflow of i1 + i2 */
- i1 += i2;
- hi += (FT_UInt32)( i1 < i2 ) << 16;
-
- hi += i1 >> 16;
- i1 = i1 << 16;
-
- /* Check carry overflow of i1 + lo */
- lo += i1;
- hi += ( lo < i1 );
-
- z->lo = lo;
- z->hi = hi;
- }
-
-
- static FT_UInt32
- ft_div64by32( FT_UInt32 hi,
- FT_UInt32 lo,
- FT_UInt32 y )
- {
- FT_UInt32 r, q;
- FT_Int i;
-
-
- if ( hi >= y )
- return (FT_UInt32)0x7FFFFFFFL;
-
- /* We shift as many bits as we can into the high register, perform */
- /* 32-bit division with modulo there, then work through the remaining */
- /* bits with long division. This optimization is especially noticeable */
- /* for smaller dividends that barely use the high register. */
-
- i = 31 - FT_MSB( hi );
- r = ( hi << i ) | ( lo >> ( 32 - i ) ); lo <<= i; /* left 64-bit shift */
- q = r / y;
- r -= q * y; /* remainder */
-
- i = 32 - i; /* bits remaining in low register */
- do
- {
- q <<= 1;
- r = ( r << 1 ) | ( lo >> 31 ); lo <<= 1;
-
- if ( r >= y )
- {
- r -= y;
- q |= 1;
- }
- } while ( --i );
-
- return q;
- }
-
-
- static void
- FT_Add64( FT_Int64* x,
- FT_Int64* y,
- FT_Int64 *z )
- {
- FT_UInt32 lo, hi;
-
-
- lo = x->lo + y->lo;
- hi = x->hi + y->hi + ( lo < x->lo );
-
- z->lo = lo;
- z->hi = hi;
- }
-
-
- /* The FT_MulDiv function has been optimized thanks to ideas from */
- /* Graham Asher and Alexei Podtelezhnikov. The trick is to optimize */
- /* a rather common case when everything fits within 32-bits. */
- /* */
- /* We compute 'a*b+c/2', then divide it by 'c' (all positive values). */
- /* */
- /* The product of two positive numbers never exceeds the square of */
- /* its mean values. Therefore, we always avoid the overflow by */
- /* imposing */
- /* */
- /* (a + b) / 2 <= sqrt(X - c/2) , */
- /* */
- /* where X = 2^32 - 1, the maximum unsigned 32-bit value, and using */
- /* unsigned arithmetic. Now we replace `sqrt' with a linear function */
- /* that is smaller or equal for all values of c in the interval */
- /* [0;X/2]; it should be equal to sqrt(X) and sqrt(3X/4) at the */
- /* endpoints. Substituting the linear solution and explicit numbers */
- /* we get */
- /* */
- /* a + b <= 131071.99 - c / 122291.84 . */
- /* */
- /* In practice, we should use a faster and even stronger inequality */
- /* */
- /* a + b <= 131071 - (c >> 16) */
- /* */
- /* or, alternatively, */
- /* */
- /* a + b <= 129894 - (c >> 17) . */
- /* */
- /* FT_MulFix, on the other hand, is optimized for a small value of */
- /* the first argument, when the second argument can be much larger. */
- /* This can be achieved by scaling the second argument and the limit */
- /* in the above inequalities. For example, */
- /* */
- /* a + (b >> 8) <= (131071 >> 4) */
- /* */
- /* covers the practical range of use. The actual test below is a bit */
- /* tighter to avoid the border case overflows. */
- /* */
- /* In the case of FT_DivFix, the exact overflow check */
- /* */
- /* a << 16 <= X - c/2 */
- /* */
- /* is scaled down by 2^16 and we use */
- /* */
- /* a <= 65535 - (c >> 17) . */
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Long )
- FT_MulDiv( FT_Long a_,
- FT_Long b_,
- FT_Long c_ )
- {
- FT_Int s = 1;
- FT_UInt32 a, b, c;
-
-
- /* XXX: this function does not allow 64-bit arguments */
-
- FT_MOVE_SIGN( FT_UInt32, a_, a, s );
- FT_MOVE_SIGN( FT_UInt32, b_, b, s );
- FT_MOVE_SIGN( FT_UInt32, c_, c, s );
-
- if ( c == 0 )
- a = 0x7FFFFFFFUL;
-
- else if ( a + b <= 129894UL - ( c >> 17 ) )
- a = ( a * b + ( c >> 1 ) ) / c;
-
- else
- {
- FT_Int64 temp, temp2;
-
-
- ft_multo64( a, b, &temp );
-
- temp2.hi = 0;
- temp2.lo = c >> 1;
-
- FT_Add64( &temp, &temp2, &temp );
-
- /* last attempt to ditch long division */
- a = ( temp.hi == 0 ) ? temp.lo / c
- : ft_div64by32( temp.hi, temp.lo, c );
- }
-
- a_ = (FT_Long)a;
-
- return s < 0 ? NEG_LONG( a_ ) : a_;
- }
-
-
- FT_BASE_DEF( FT_Long )
- FT_MulDiv_No_Round( FT_Long a_,
- FT_Long b_,
- FT_Long c_ )
- {
- FT_Int s = 1;
- FT_UInt32 a, b, c;
-
-
- /* XXX: this function does not allow 64-bit arguments */
-
- FT_MOVE_SIGN( FT_UInt32, a_, a, s );
- FT_MOVE_SIGN( FT_UInt32, b_, b, s );
- FT_MOVE_SIGN( FT_UInt32, c_, c, s );
-
- if ( c == 0 )
- a = 0x7FFFFFFFUL;
-
- else if ( a + b <= 131071UL )
- a = a * b / c;
-
- else
- {
- FT_Int64 temp;
-
-
- ft_multo64( a, b, &temp );
-
- /* last attempt to ditch long division */
- a = ( temp.hi == 0 ) ? temp.lo / c
- : ft_div64by32( temp.hi, temp.lo, c );
- }
-
- a_ = (FT_Long)a;
-
- return s < 0 ? NEG_LONG( a_ ) : a_;
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Long )
- FT_MulFix( FT_Long a_,
- FT_Long b_ )
- {
-#ifdef FT_MULFIX_ASSEMBLER
-
- return FT_MULFIX_ASSEMBLER( a_, b_ );
-
-#elif 0
-
- /*
- * This code is nonportable. See comment below.
- *
- * However, on a platform where right-shift of a signed quantity fills
- * the leftmost bits by copying the sign bit, it might be faster.
- */
-
- FT_Long sa, sb;
- FT_UInt32 a, b;
-
-
- /*
- * This is a clever way of converting a signed number `a' into its
- * absolute value (stored back into `a') and its sign. The sign is
- * stored in `sa'; 0 means `a' was positive or zero, and -1 means `a'
- * was negative. (Similarly for `b' and `sb').
- *
- * Unfortunately, it doesn't work (at least not portably).
- *
- * It makes the assumption that right-shift on a negative signed value
- * fills the leftmost bits by copying the sign bit. This is wrong.
- * According to K&R 2nd ed, section `A7.8 Shift Operators' on page 206,
- * the result of right-shift of a negative signed value is
- * implementation-defined. At least one implementation fills the
- * leftmost bits with 0s (i.e., it is exactly the same as an unsigned
- * right shift). This means that when `a' is negative, `sa' ends up
- * with the value 1 rather than -1. After that, everything else goes
- * wrong.
- */
- sa = ( a_ >> ( sizeof ( a_ ) * 8 - 1 ) );
- a = ( a_ ^ sa ) - sa;
- sb = ( b_ >> ( sizeof ( b_ ) * 8 - 1 ) );
- b = ( b_ ^ sb ) - sb;
-
- a = (FT_UInt32)a_;
- b = (FT_UInt32)b_;
-
- if ( a + ( b >> 8 ) <= 8190UL )
- a = ( a * b + 0x8000U ) >> 16;
- else
- {
- FT_UInt32 al = a & 0xFFFFUL;
-
-
- a = ( a >> 16 ) * b + al * ( b >> 16 ) +
- ( ( al * ( b & 0xFFFFUL ) + 0x8000UL ) >> 16 );
- }
-
- sa ^= sb;
- a = ( a ^ sa ) - sa;
-
- return (FT_Long)a;
-
-#else /* 0 */
-
- FT_Int s = 1;
- FT_UInt32 a, b;
-
-
- /* XXX: this function does not allow 64-bit arguments */
-
- FT_MOVE_SIGN( FT_UInt32, a_, a, s );
- FT_MOVE_SIGN( FT_UInt32, b_, b, s );
-
- if ( a + ( b >> 8 ) <= 8190UL )
- a = ( a * b + 0x8000UL ) >> 16;
- else
- {
- FT_UInt32 al = a & 0xFFFFUL;
-
-
- a = ( a >> 16 ) * b + al * ( b >> 16 ) +
- ( ( al * ( b & 0xFFFFUL ) + 0x8000UL ) >> 16 );
- }
-
- a_ = (FT_Long)a;
-
- return s < 0 ? NEG_LONG( a_ ) : a_;
-
-#endif /* 0 */
-
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Long )
- FT_DivFix( FT_Long a_,
- FT_Long b_ )
- {
- FT_Int s = 1;
- FT_UInt32 a, b, q;
- FT_Long q_;
-
-
- /* XXX: this function does not allow 64-bit arguments */
-
- FT_MOVE_SIGN( FT_UInt32, a_, a, s );
- FT_MOVE_SIGN( FT_UInt32, b_, b, s );
-
- if ( b == 0 )
- {
- /* check for division by 0 */
- q = 0x7FFFFFFFUL;
- }
- else if ( a <= 65535UL - ( b >> 17 ) )
- {
- /* compute result directly */
- q = ( ( a << 16 ) + ( b >> 1 ) ) / b;
- }
- else
- {
- /* we need more bits; we have to do it by hand */
- FT_Int64 temp, temp2;
-
-
- temp.hi = a >> 16;
- temp.lo = a << 16;
- temp2.hi = 0;
- temp2.lo = b >> 1;
-
- FT_Add64( &temp, &temp2, &temp );
- q = ft_div64by32( temp.hi, temp.lo, b );
- }
-
- q_ = (FT_Long)q;
-
- return s < 0 ? NEG_LONG( q_ ) : q_;
- }
-
-
-#endif /* !FT_INT64 */
-
-
- /* documentation is in ftglyph.h */
-
- FT_EXPORT_DEF( void )
- FT_Matrix_Multiply( const FT_Matrix* a,
- FT_Matrix *b )
- {
- FT_Fixed xx, xy, yx, yy;
-
-
- if ( !a || !b )
- return;
-
- xx = ADD_LONG( FT_MulFix( a->xx, b->xx ),
- FT_MulFix( a->xy, b->yx ) );
- xy = ADD_LONG( FT_MulFix( a->xx, b->xy ),
- FT_MulFix( a->xy, b->yy ) );
- yx = ADD_LONG( FT_MulFix( a->yx, b->xx ),
- FT_MulFix( a->yy, b->yx ) );
- yy = ADD_LONG( FT_MulFix( a->yx, b->xy ),
- FT_MulFix( a->yy, b->yy ) );
-
- b->xx = xx;
- b->xy = xy;
- b->yx = yx;
- b->yy = yy;
- }
-
-
- /* documentation is in ftglyph.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Matrix_Invert( FT_Matrix* matrix )
- {
- FT_Pos delta, xx, yy;
-
-
- if ( !matrix )
- return FT_THROW( Invalid_Argument );
-
- /* compute discriminant */
- delta = FT_MulFix( matrix->xx, matrix->yy ) -
- FT_MulFix( matrix->xy, matrix->yx );
-
- if ( !delta )
- return FT_THROW( Invalid_Argument ); /* matrix can't be inverted */
-
- matrix->xy = -FT_DivFix( matrix->xy, delta );
- matrix->yx = -FT_DivFix( matrix->yx, delta );
-
- xx = matrix->xx;
- yy = matrix->yy;
-
- matrix->xx = FT_DivFix( yy, delta );
- matrix->yy = FT_DivFix( xx, delta );
-
- return FT_Err_Ok;
- }
-
-
- /* documentation is in ftcalc.h */
-
- FT_BASE_DEF( void )
- FT_Matrix_Multiply_Scaled( const FT_Matrix* a,
- FT_Matrix *b,
- FT_Long scaling )
- {
- FT_Fixed xx, xy, yx, yy;
-
- FT_Long val = 0x10000L * scaling;
-
-
- if ( !a || !b )
- return;
-
- xx = ADD_LONG( FT_MulDiv( a->xx, b->xx, val ),
- FT_MulDiv( a->xy, b->yx, val ) );
- xy = ADD_LONG( FT_MulDiv( a->xx, b->xy, val ),
- FT_MulDiv( a->xy, b->yy, val ) );
- yx = ADD_LONG( FT_MulDiv( a->yx, b->xx, val ),
- FT_MulDiv( a->yy, b->yx, val ) );
- yy = ADD_LONG( FT_MulDiv( a->yx, b->xy, val ),
- FT_MulDiv( a->yy, b->yy, val ) );
-
- b->xx = xx;
- b->xy = xy;
- b->yx = yx;
- b->yy = yy;
- }
-
-
- /* documentation is in ftcalc.h */
-
- FT_BASE_DEF( FT_Bool )
- FT_Matrix_Check( const FT_Matrix* matrix )
- {
- FT_Fixed xx, xy, yx, yy;
- FT_Fixed val;
- FT_Int shift;
- FT_ULong temp1, temp2;
-
-
- if ( !matrix )
- return 0;
-
- xx = matrix->xx;
- xy = matrix->xy;
- yx = matrix->yx;
- yy = matrix->yy;
- val = FT_ABS( xx ) | FT_ABS( xy ) | FT_ABS( yx ) | FT_ABS( yy );
-
- /* we only handle non-zero 32-bit values */
- if ( !val || val > 0x7FFFFFFFL )
- return 0;
-
- /* Scale matrix to avoid the temp1 overflow, which is */
- /* more stringent than avoiding the temp2 overflow. */
-
- shift = FT_MSB( val ) - 12;
-
- if ( shift > 0 )
- {
- xx >>= shift;
- xy >>= shift;
- yx >>= shift;
- yy >>= shift;
- }
-
- temp1 = 32U * (FT_ULong)FT_ABS( xx * yy - xy * yx );
- temp2 = (FT_ULong)( xx * xx ) + (FT_ULong)( xy * xy ) +
- (FT_ULong)( yx * yx ) + (FT_ULong)( yy * yy );
-
- if ( temp1 <= temp2 )
- return 0;
-
- return 1;
- }
-
-
- /* documentation is in ftcalc.h */
-
- FT_BASE_DEF( void )
- FT_Vector_Transform_Scaled( FT_Vector* vector,
- const FT_Matrix* matrix,
- FT_Long scaling )
- {
- FT_Pos xz, yz;
-
- FT_Long val = 0x10000L * scaling;
-
-
- if ( !vector || !matrix )
- return;
-
- xz = ADD_LONG( FT_MulDiv( vector->x, matrix->xx, val ),
- FT_MulDiv( vector->y, matrix->xy, val ) );
- yz = ADD_LONG( FT_MulDiv( vector->x, matrix->yx, val ),
- FT_MulDiv( vector->y, matrix->yy, val ) );
-
- vector->x = xz;
- vector->y = yz;
- }
-
-
- /* documentation is in ftcalc.h */
-
- FT_BASE_DEF( FT_UInt32 )
- FT_Vector_NormLen( FT_Vector* vector )
- {
- FT_Int32 x_ = vector->x;
- FT_Int32 y_ = vector->y;
- FT_Int32 b, z;
- FT_UInt32 x, y, u, v, l;
- FT_Int sx = 1, sy = 1, shift;
-
-
- FT_MOVE_SIGN( FT_UInt32, x_, x, sx );
- FT_MOVE_SIGN( FT_UInt32, y_, y, sy );
-
- /* trivial cases */
- if ( x == 0 )
- {
- if ( y > 0 )
- vector->y = sy * 0x10000;
- return y;
- }
- else if ( y == 0 )
- {
- if ( x > 0 )
- vector->x = sx * 0x10000;
- return x;
- }
-
- /* Estimate length and prenormalize by shifting so that */
- /* the new approximate length is between 2/3 and 4/3. */
- /* The magic constant 0xAAAAAAAAUL (2/3 of 2^32) helps */
- /* achieve this in 16.16 fixed-point representation. */
- l = x > y ? x + ( y >> 1 )
- : y + ( x >> 1 );
-
- shift = 31 - FT_MSB( l );
- shift -= 15 + ( l >= ( 0xAAAAAAAAUL >> shift ) );
-
- if ( shift > 0 )
- {
- x <<= shift;
- y <<= shift;
-
- /* re-estimate length for tiny vectors */
- l = x > y ? x + ( y >> 1 )
- : y + ( x >> 1 );
- }
- else
- {
- x >>= -shift;
- y >>= -shift;
- l >>= -shift;
- }
-
- /* lower linear approximation for reciprocal length minus one */
- b = 0x10000 - (FT_Int32)l;
-
- x_ = (FT_Int32)x;
- y_ = (FT_Int32)y;
-
- /* Newton's iterations */
- do
- {
- u = (FT_UInt32)( x_ + ( x_ * b >> 16 ) );
- v = (FT_UInt32)( y_ + ( y_ * b >> 16 ) );
-
- /* Normalized squared length in the parentheses approaches 2^32. */
- /* On two's complement systems, converting to signed gives the */
- /* difference with 2^32 even if the expression wraps around. */
- z = -(FT_Int32)( u * u + v * v ) / 0x200;
- z = z * ( ( 0x10000 + b ) >> 8 ) / 0x10000;
-
- b += z;
-
- } while ( z > 0 );
-
- vector->x = sx < 0 ? -(FT_Pos)u : (FT_Pos)u;
- vector->y = sy < 0 ? -(FT_Pos)v : (FT_Pos)v;
-
- /* Conversion to signed helps to recover from likely wrap around */
- /* in calculating the prenormalized length, because it gives the */
- /* correct difference with 2^32 on two's complement systems. */
- l = (FT_UInt32)( 0x10000 + (FT_Int32)( u * x + v * y ) / 0x10000 );
- if ( shift > 0 )
- l = ( l + ( 1 << ( shift - 1 ) ) ) >> shift;
- else
- l <<= -shift;
-
- return l;
- }
-
-
- /* documentation is in ftcalc.h */
-
- FT_BASE_DEF( FT_UInt32 )
- FT_SqrtFixed( FT_UInt32 v )
- {
- if ( v == 0 )
- return 0;
-
-#ifndef FT_INT64
-
- /* Algorithm by Christophe Meessen (1993) with overflow fixed and */
- /* rounding added. Any unsigned fixed 16.16 argument is acceptable. */
- /* However, this algorithm is slower than the Babylonian method with */
- /* a good initial guess. We only use it for large 32-bit values when */
- /* 64-bit computations are not desirable. */
- else if ( v > 0x10000U )
- {
- FT_UInt32 r = v >> 1;
- FT_UInt32 q = ( v & 1 ) << 15;
- FT_UInt32 b = 0x20000000;
- FT_UInt32 t;
-
-
- do
- {
- t = q + b;
- if ( r >= t )
- {
- r -= t;
- q = t + b; /* equivalent to q += 2*b */
- }
- r <<= 1;
- b >>= 1;
-
- } while ( b > 0x10 ); /* exactly 25 cycles */
-
- return ( q + 0x40 ) >> 7;
- }
- else
- {
- FT_UInt32 r = ( v << 16 ) - 1;
-
-#else /* FT_INT64 */
-
- else
- {
- FT_UInt64 r = ( (FT_UInt64)v << 16 ) - 1;
-
-#endif /* FT_INT64 */
-
- FT_UInt32 q = 1 << ( ( 17 + FT_MSB( v ) ) >> 1 );
- FT_UInt32 t;
-
-
- /* Babylonian method with rounded-up division */
- do
- {
- t = q;
- q = ( t + (FT_UInt32)( r / t ) + 1 ) >> 1;
-
- } while ( q != t ); /* less than 6 cycles */
-
- return q;
- }
- }
-
-
- /* documentation is in ftcalc.h */
-
- FT_BASE_DEF( FT_Int )
- ft_corner_orientation( FT_Pos in_x,
- FT_Pos in_y,
- FT_Pos out_x,
- FT_Pos out_y )
- {
- /* we silently ignore overflow errors since such large values */
- /* lead to even more (harmless) rendering errors later on */
-
-#ifdef FT_INT64
-
- FT_Int64 delta = SUB_INT64( MUL_INT64( in_x, out_y ),
- MUL_INT64( in_y, out_x ) );
-
-
- return ( delta > 0 ) - ( delta < 0 );
-
-#else
-
- FT_Int result;
-
-
- if ( ADD_LONG( FT_ABS( in_x ), FT_ABS( out_y ) ) <= 131071L &&
- ADD_LONG( FT_ABS( in_y ), FT_ABS( out_x ) ) <= 131071L )
- {
- FT_Long z1 = MUL_LONG( in_x, out_y );
- FT_Long z2 = MUL_LONG( in_y, out_x );
-
-
- if ( z1 > z2 )
- result = +1;
- else if ( z1 < z2 )
- result = -1;
- else
- result = 0;
- }
- else /* products might overflow 32 bits */
- {
- FT_Int64 z1, z2;
-
-
- /* XXX: this function does not allow 64-bit arguments */
- ft_multo64( (FT_UInt32)in_x, (FT_UInt32)out_y, &z1 );
- ft_multo64( (FT_UInt32)in_y, (FT_UInt32)out_x, &z2 );
-
- if ( z1.hi > z2.hi )
- result = +1;
- else if ( z1.hi < z2.hi )
- result = -1;
- else if ( z1.lo > z2.lo )
- result = +1;
- else if ( z1.lo < z2.lo )
- result = -1;
- else
- result = 0;
- }
-
- /* XXX: only the sign of return value, +1/0/-1 must be used */
- return result;
-
-#endif
- }
-
-
- /* documentation is in ftcalc.h */
-
- FT_BASE_DEF( FT_Int )
- ft_corner_is_flat( FT_Pos in_x,
- FT_Pos in_y,
- FT_Pos out_x,
- FT_Pos out_y )
- {
- FT_Pos ax = in_x + out_x;
- FT_Pos ay = in_y + out_y;
-
- FT_Pos d_in, d_out, d_hypot;
-
-
- /* The idea of this function is to compare the length of the */
- /* hypotenuse with the `in' and `out' length. The `corner' */
- /* represented by `in' and `out' is flat if the hypotenuse's */
- /* length isn't too large. */
- /* */
- /* This approach has the advantage that the angle between */
- /* `in' and `out' is not checked. In case one of the two */
- /* vectors is `dominant', that is, much larger than the */
- /* other vector, we thus always have a flat corner. */
- /* */
- /* hypotenuse */
- /* x---------------------------x */
- /* \ / */
- /* \ / */
- /* in \ / out */
- /* \ / */
- /* o */
- /* Point */
-
- d_in = FT_HYPOT( in_x, in_y );
- d_out = FT_HYPOT( out_x, out_y );
- d_hypot = FT_HYPOT( ax, ay );
-
- /* now do a simple length comparison: */
- /* */
- /* d_in + d_out < 17/16 d_hypot */
-
- return ( d_in + d_out - d_hypot ) < ( d_hypot >> 4 );
- }
-
-
- FT_BASE_DEF( FT_Int32 )
- FT_MulAddFix( FT_Fixed* s,
- FT_Int32* f,
- FT_UInt count )
- {
- FT_UInt i;
- FT_Int64 temp;
-
-
-#ifdef FT_INT64
- temp = 0;
-
- for ( i = 0; i < count; ++i )
- temp += (FT_Int64)s[i] * f[i];
-
- return (FT_Int32)( ( temp + 0x8000 ) >> 16 );
-#else
- temp.hi = 0;
- temp.lo = 0;
-
- for ( i = 0; i < count; ++i )
- {
- FT_Int64 multResult;
-
- FT_Int sign = 1;
- FT_UInt32 carry = 0;
-
- FT_UInt32 scalar;
- FT_UInt32 factor;
-
-
- FT_MOVE_SIGN( FT_UInt32, s[i], scalar, sign );
- FT_MOVE_SIGN( FT_UInt32, f[i], factor, sign );
-
- ft_multo64( scalar, factor, &multResult );
-
- if ( sign < 0 )
- {
- /* Emulated `FT_Int64` negation. */
- carry = ( multResult.lo == 0 );
-
- multResult.lo = ~multResult.lo + 1;
- multResult.hi = ~multResult.hi + carry;
- }
-
- FT_Add64( &temp, &multResult, &temp );
- }
-
- /* Shift and round value. */
- return (FT_Int32)( ( ( temp.hi << 16 ) | ( temp.lo >> 16 ) )
- + ( 1 & ( temp.lo >> 15 ) ) );
-
-
-#endif /* !FT_INT64 */
-
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/base/ftcid.c b/contrib/libs/freetype/src/base/ftcid.c
deleted file mode 100644
index 4f2deb19a0..0000000000
--- a/contrib/libs/freetype/src/base/ftcid.c
+++ /dev/null
@@ -1,117 +0,0 @@
-/****************************************************************************
- *
- * ftcid.c
- *
- * FreeType API for accessing CID font information.
- *
- * Copyright (C) 2007-2024 by
- * Derek Clegg and Michael Toftdal.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/ftcid.h>
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/services/svcid.h>
-
-
- /* documentation is in ftcid.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Get_CID_Registry_Ordering_Supplement( FT_Face face,
- const char* *registry,
- const char* *ordering,
- FT_Int *supplement)
- {
- FT_Error error;
- const char* r = NULL;
- const char* o = NULL;
- FT_Int s = 0;
-
-
- error = FT_ERR( Invalid_Argument );
-
- if ( face )
- {
- FT_Service_CID service;
-
-
- FT_FACE_FIND_SERVICE( face, service, CID );
-
- if ( service && service->get_ros )
- error = service->get_ros( face, &r, &o, &s );
- }
-
- if ( registry )
- *registry = r;
-
- if ( ordering )
- *ordering = o;
-
- if ( supplement )
- *supplement = s;
-
- return error;
- }
-
-
- FT_EXPORT_DEF( FT_Error )
- FT_Get_CID_Is_Internally_CID_Keyed( FT_Face face,
- FT_Bool *is_cid )
- {
- FT_Error error = FT_ERR( Invalid_Argument );
- FT_Bool ic = 0;
-
-
- if ( face )
- {
- FT_Service_CID service;
-
-
- FT_FACE_FIND_SERVICE( face, service, CID );
-
- if ( service && service->get_is_cid )
- error = service->get_is_cid( face, &ic);
- }
-
- if ( is_cid )
- *is_cid = ic;
-
- return error;
- }
-
-
- FT_EXPORT_DEF( FT_Error )
- FT_Get_CID_From_Glyph_Index( FT_Face face,
- FT_UInt glyph_index,
- FT_UInt *cid )
- {
- FT_Error error = FT_ERR( Invalid_Argument );
- FT_UInt c = 0;
-
-
- if ( face )
- {
- FT_Service_CID service;
-
-
- FT_FACE_FIND_SERVICE( face, service, CID );
-
- if ( service && service->get_cid_from_glyph_index )
- error = service->get_cid_from_glyph_index( face, glyph_index, &c);
- }
-
- if ( cid )
- *cid = c;
-
- return error;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/base/ftcolor.c b/contrib/libs/freetype/src/base/ftcolor.c
deleted file mode 100644
index c6bf2a3cd1..0000000000
--- a/contrib/libs/freetype/src/base/ftcolor.c
+++ /dev/null
@@ -1,156 +0,0 @@
-/****************************************************************************
- *
- * ftcolor.c
- *
- * FreeType's glyph color management (body).
- *
- * Copyright (C) 2018-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/sfnt.h>
-#include <freetype/internal/tttypes.h>
-#include <freetype/ftcolor.h>
-
-
-#ifdef TT_CONFIG_OPTION_COLOR_LAYERS
-
- static
- const FT_Palette_Data null_palette_data = { 0, NULL, NULL, 0, NULL };
-
-
- /* documentation is in ftcolor.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Palette_Data_Get( FT_Face face,
- FT_Palette_Data *apalette_data )
- {
- if ( !face )
- return FT_THROW( Invalid_Face_Handle );
- if ( !apalette_data)
- return FT_THROW( Invalid_Argument );
-
- if ( FT_IS_SFNT( face ) )
- *apalette_data = ( (TT_Face)face )->palette_data;
- else
- *apalette_data = null_palette_data;
-
- return FT_Err_Ok;
- }
-
-
- /* documentation is in ftcolor.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Palette_Select( FT_Face face,
- FT_UShort palette_index,
- FT_Color* *apalette )
- {
- FT_Error error;
-
- TT_Face ttface;
- SFNT_Service sfnt;
-
-
- if ( !face )
- return FT_THROW( Invalid_Face_Handle );
-
- if ( !FT_IS_SFNT( face ) )
- {
- if ( apalette )
- *apalette = NULL;
-
- return FT_Err_Ok;
- }
-
- ttface = (TT_Face)face;
- sfnt = (SFNT_Service)ttface->sfnt;
-
- error = sfnt->set_palette( ttface, palette_index );
- if ( error )
- return error;
-
- ttface->palette_index = palette_index;
-
- if ( apalette )
- *apalette = ttface->palette;
-
- return FT_Err_Ok;
- }
-
-
- /* documentation is in ftcolor.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Palette_Set_Foreground_Color( FT_Face face,
- FT_Color foreground_color )
- {
- TT_Face ttface;
-
-
- if ( !face )
- return FT_THROW( Invalid_Face_Handle );
-
- if ( !FT_IS_SFNT( face ) )
- return FT_Err_Ok;
-
- ttface = (TT_Face)face;
-
- ttface->foreground_color = foreground_color;
- ttface->have_foreground_color = 1;
-
- return FT_Err_Ok;
- }
-
-#else /* !TT_CONFIG_OPTION_COLOR_LAYERS */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Palette_Data_Get( FT_Face face,
- FT_Palette_Data *apalette_data )
- {
- FT_UNUSED( face );
- FT_UNUSED( apalette_data );
-
-
- return FT_THROW( Unimplemented_Feature );
- }
-
-
- FT_EXPORT_DEF( FT_Error )
- FT_Palette_Select( FT_Face face,
- FT_UShort palette_index,
- FT_Color* *apalette )
- {
- FT_UNUSED( face );
- FT_UNUSED( palette_index );
- FT_UNUSED( apalette );
-
-
- return FT_THROW( Unimplemented_Feature );
- }
-
-
- FT_EXPORT_DEF( FT_Error )
- FT_Palette_Set_Foreground_Color( FT_Face face,
- FT_Color foreground_color )
- {
- FT_UNUSED( face );
- FT_UNUSED( foreground_color );
-
-
- return FT_THROW( Unimplemented_Feature );
- }
-
-#endif /* !TT_CONFIG_OPTION_COLOR_LAYERS */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/base/ftdbgmem.c b/contrib/libs/freetype/src/base/ftdbgmem.c
deleted file mode 100644
index 902a5dc8bb..0000000000
--- a/contrib/libs/freetype/src/base/ftdbgmem.c
+++ /dev/null
@@ -1,971 +0,0 @@
-/****************************************************************************
- *
- * ftdbgmem.c
- *
- * Memory debugger (body).
- *
- * Copyright (C) 2001-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <ft2build.h>
-#include FT_CONFIG_CONFIG_H
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftmemory.h>
-#include <freetype/ftsystem.h>
-#include <freetype/fterrors.h>
-#include <freetype/fttypes.h>
-
-
-#ifdef FT_DEBUG_MEMORY
-
-#define KEEPALIVE /* `Keep alive' means that freed blocks aren't released
- * to the heap. This is useful to detect double-frees
- * or weird heap corruption, but it uses large amounts of
- * memory, however.
- */
-
-#include FT_CONFIG_STANDARD_LIBRARY_H
-
- FT_BASE_DEF( const char* ) ft_debug_file_ = NULL;
- FT_BASE_DEF( long ) ft_debug_lineno_ = 0;
-
- extern void
- FT_DumpMemory( FT_Memory memory );
-
-
- typedef struct FT_MemSourceRec_* FT_MemSource;
- typedef struct FT_MemNodeRec_* FT_MemNode;
- typedef struct FT_MemTableRec_* FT_MemTable;
-
-
-#define FT_MEM_VAL( addr ) ( (FT_PtrDist)(FT_Pointer)( addr ) )
-
- /*
- * This structure holds statistics for a single allocation/release
- * site. This is useful to know where memory operations happen the
- * most.
- */
- typedef struct FT_MemSourceRec_
- {
- const char* file_name;
- long line_no;
-
- FT_Long cur_blocks; /* current number of allocated blocks */
- FT_Long max_blocks; /* max. number of allocated blocks */
- FT_Long all_blocks; /* total number of blocks allocated */
-
- FT_Long cur_size; /* current cumulative allocated size */
- FT_Long max_size; /* maximum cumulative allocated size */
- FT_Long all_size; /* total cumulative allocated size */
-
- FT_Long cur_max; /* current maximum allocated size */
-
- FT_UInt32 hash;
- FT_MemSource link;
-
- } FT_MemSourceRec;
-
-
- /*
- * We don't need a resizable array for the memory sources because
- * their number is pretty limited within FreeType.
- */
-#define FT_MEM_SOURCE_BUCKETS 128
-
- /*
- * This structure holds information related to a single allocated
- * memory block. If KEEPALIVE is defined, blocks that are freed by
- * FreeType are never released to the system. Instead, their `size'
- * field is set to `-size'. This is mainly useful to detect double
- * frees, at the price of a large memory footprint during execution.
- */
- typedef struct FT_MemNodeRec_
- {
- FT_Byte* address;
- FT_Long size; /* < 0 if the block was freed */
-
- FT_MemSource source;
-
-#ifdef KEEPALIVE
- const char* free_file_name;
- FT_Long free_line_no;
-#endif
-
- FT_MemNode link;
-
- } FT_MemNodeRec;
-
-
- /*
- * The global structure, containing compound statistics and all hash
- * tables.
- */
- typedef struct FT_MemTableRec_
- {
- FT_Long size;
- FT_Long nodes;
- FT_MemNode* buckets;
-
- FT_Long alloc_total;
- FT_Long alloc_current;
- FT_Long alloc_max;
- FT_Long alloc_count;
-
- FT_Bool bound_total;
- FT_Long alloc_total_max;
-
- FT_Bool bound_count;
- FT_Long alloc_count_max;
-
- FT_MemSource sources[FT_MEM_SOURCE_BUCKETS];
-
- FT_Bool keep_alive;
-
- FT_Memory memory;
- FT_Pointer memory_user;
- FT_Alloc_Func alloc;
- FT_Free_Func free;
- FT_Realloc_Func realloc;
-
- } FT_MemTableRec;
-
-
-#define FT_MEM_SIZE_MIN 7
-#define FT_MEM_SIZE_MAX 13845163
-
-#define FT_FILENAME( x ) ( (x) ? (x) : "unknown file" )
-
-
- /*
- * Prime numbers are ugly to handle. It would be better to implement
- * L-Hashing, which is 10% faster and doesn't require divisions.
- */
- static const FT_Int ft_mem_primes[] =
- {
- 7,
- 11,
- 19,
- 37,
- 73,
- 109,
- 163,
- 251,
- 367,
- 557,
- 823,
- 1237,
- 1861,
- 2777,
- 4177,
- 6247,
- 9371,
- 14057,
- 21089,
- 31627,
- 47431,
- 71143,
- 106721,
- 160073,
- 240101,
- 360163,
- 540217,
- 810343,
- 1215497,
- 1823231,
- 2734867,
- 4102283,
- 6153409,
- 9230113,
- 13845163,
- };
-
-
- static FT_Long
- ft_mem_closest_prime( FT_Long num )
- {
- size_t i;
-
-
- for ( i = 0;
- i < sizeof ( ft_mem_primes ) / sizeof ( ft_mem_primes[0] ); i++ )
- if ( ft_mem_primes[i] > num )
- return ft_mem_primes[i];
-
- return FT_MEM_SIZE_MAX;
- }
-
-
- static void
- ft_mem_debug_panic( const char* fmt,
- ... )
- {
- va_list ap;
-
-
- printf( "FreeType.Debug: " );
-
- va_start( ap, fmt );
- vprintf( fmt, ap );
- va_end( ap );
-
- printf( "\n" );
- exit( EXIT_FAILURE );
- }
-
-
- static FT_Pointer
- ft_mem_table_alloc( FT_MemTable table,
- FT_Long size )
- {
- FT_Memory memory = table->memory;
- FT_Pointer block;
-
-
- memory->user = table->memory_user;
- block = table->alloc( memory, size );
- memory->user = table;
-
- return block;
- }
-
-
- static void
- ft_mem_table_free( FT_MemTable table,
- FT_Pointer block )
- {
- FT_Memory memory = table->memory;
-
-
- memory->user = table->memory_user;
- table->free( memory, block );
- memory->user = table;
- }
-
-
- static void
- ft_mem_table_resize( FT_MemTable table )
- {
- FT_Long new_size;
-
-
- new_size = ft_mem_closest_prime( table->nodes );
- if ( new_size != table->size )
- {
- FT_MemNode* new_buckets;
- FT_Long i;
-
-
- new_buckets = (FT_MemNode *)
- ft_mem_table_alloc(
- table,
- new_size * (FT_Long)sizeof ( FT_MemNode ) );
- if ( !new_buckets )
- return;
-
- FT_ARRAY_ZERO( new_buckets, new_size );
-
- for ( i = 0; i < table->size; i++ )
- {
- FT_MemNode node, next, *pnode;
- FT_PtrDist hash;
-
-
- node = table->buckets[i];
- while ( node )
- {
- next = node->link;
- hash = FT_MEM_VAL( node->address ) % (FT_PtrDist)new_size;
- pnode = new_buckets + hash;
-
- node->link = pnode[0];
- pnode[0] = node;
-
- node = next;
- }
- }
-
- if ( table->buckets )
- ft_mem_table_free( table, table->buckets );
-
- table->buckets = new_buckets;
- table->size = new_size;
- }
- }
-
-
- static void
- ft_mem_table_destroy( FT_MemTable table )
- {
- FT_Long i;
- FT_Long leak_count = 0;
- FT_Long leaks = 0;
-
-
- /* remove all blocks from the table, revealing leaked ones */
- for ( i = 0; i < table->size; i++ )
- {
- FT_MemNode *pnode = table->buckets + i, next, node = *pnode;
-
-
- while ( node )
- {
- next = node->link;
- node->link = NULL;
-
- if ( node->size > 0 )
- {
- printf(
- "leaked memory block at address %p, size %8ld in (%s:%ld)\n",
- (void*)node->address,
- node->size,
- FT_FILENAME( node->source->file_name ),
- node->source->line_no );
-
- leak_count++;
- leaks += node->size;
-
- ft_mem_table_free( table, node->address );
- }
-
- node->address = NULL;
- node->size = 0;
-
- ft_mem_table_free( table, node );
- node = next;
- }
- table->buckets[i] = NULL;
- }
-
- ft_mem_table_free( table, table->buckets );
- table->buckets = NULL;
-
- table->size = 0;
- table->nodes = 0;
-
- /* remove all sources */
- for ( i = 0; i < FT_MEM_SOURCE_BUCKETS; i++ )
- {
- FT_MemSource source, next;
-
-
- for ( source = table->sources[i]; source != NULL; source = next )
- {
- next = source->link;
- ft_mem_table_free( table, source );
- }
-
- table->sources[i] = NULL;
- }
-
- printf( "FreeType: total memory allocations = %ld\n",
- table->alloc_total );
- printf( "FreeType: maximum memory footprint = %ld\n",
- table->alloc_max );
-
- if ( leak_count > 0 )
- ft_mem_debug_panic(
- "FreeType: %ld bytes of memory leaked in %ld blocks\n",
- leaks, leak_count );
-
- printf( "FreeType: no memory leaks detected\n" );
- }
-
-
- static FT_MemNode*
- ft_mem_table_get_nodep( FT_MemTable table,
- FT_Byte* address )
- {
- FT_PtrDist hash;
- FT_MemNode *pnode, node;
-
-
- hash = FT_MEM_VAL( address );
- pnode = table->buckets + ( hash % (FT_PtrDist)table->size );
-
- for (;;)
- {
- node = pnode[0];
- if ( !node )
- break;
-
- if ( node->address == address )
- break;
-
- pnode = &node->link;
- }
- return pnode;
- }
-
-
- static FT_MemSource
- ft_mem_table_get_source( FT_MemTable table )
- {
- FT_UInt32 hash;
- FT_MemSource node, *pnode;
-
-
- /* cast to FT_PtrDist first since void* can be larger */
- /* than FT_UInt32 and GCC 4.1.1 emits a warning */
- hash = (FT_UInt32)(FT_PtrDist)(void*)ft_debug_file_ +
- (FT_UInt32)( 5 * ft_debug_lineno_ );
- pnode = &table->sources[hash % FT_MEM_SOURCE_BUCKETS];
-
- for (;;)
- {
- node = *pnode;
- if ( !node )
- break;
-
- if ( node->file_name == ft_debug_file_ &&
- node->line_no == ft_debug_lineno_ )
- goto Exit;
-
- pnode = &node->link;
- }
-
- node = (FT_MemSource)ft_mem_table_alloc( table, sizeof ( *node ) );
- if ( !node )
- ft_mem_debug_panic(
- "not enough memory to perform memory debugging\n" );
-
- node->file_name = ft_debug_file_;
- node->line_no = ft_debug_lineno_;
-
- node->cur_blocks = 0;
- node->max_blocks = 0;
- node->all_blocks = 0;
-
- node->cur_size = 0;
- node->max_size = 0;
- node->all_size = 0;
-
- node->cur_max = 0;
-
- node->link = NULL;
- node->hash = hash;
- *pnode = node;
-
- Exit:
- return node;
- }
-
-
- static void
- ft_mem_table_set( FT_MemTable table,
- FT_Byte* address,
- FT_Long size,
- FT_Long delta )
- {
- FT_MemNode *pnode, node;
-
-
- if ( table )
- {
- FT_MemSource source;
-
-
- pnode = ft_mem_table_get_nodep( table, address );
- node = *pnode;
- if ( node )
- {
- if ( node->size < 0 )
- {
- /* This block was already freed. Our memory is now completely */
- /* corrupted! */
- /* This can only happen in keep-alive mode. */
- ft_mem_debug_panic(
- "memory heap corrupted (allocating freed block)" );
- }
- else
- {
- /* This block was already allocated. This means that our memory */
- /* is also corrupted! */
- ft_mem_debug_panic(
- "memory heap corrupted (re-allocating allocated block at"
- " %p, of size %ld)\n"
- "org=%s:%d new=%s:%d\n",
- node->address, node->size,
- FT_FILENAME( node->source->file_name ), node->source->line_no,
- FT_FILENAME( ft_debug_file_ ), ft_debug_lineno_ );
- }
- }
-
- /* we need to create a new node in this table */
- node = (FT_MemNode)ft_mem_table_alloc( table, sizeof ( *node ) );
- if ( !node )
- ft_mem_debug_panic( "not enough memory to run memory tests" );
-
- node->address = address;
- node->size = size;
- node->source = source = ft_mem_table_get_source( table );
-
- if ( delta == 0 )
- {
- /* this is an allocation */
- source->all_blocks++;
- source->cur_blocks++;
- if ( source->cur_blocks > source->max_blocks )
- source->max_blocks = source->cur_blocks;
- }
-
- if ( size > source->cur_max )
- source->cur_max = size;
-
- if ( delta != 0 )
- {
- /* we are growing or shrinking a reallocated block */
- source->cur_size += delta;
- table->alloc_current += delta;
- }
- else
- {
- /* we are allocating a new block */
- source->cur_size += size;
- table->alloc_current += size;
- }
-
- source->all_size += size;
-
- if ( source->cur_size > source->max_size )
- source->max_size = source->cur_size;
-
- node->free_file_name = NULL;
- node->free_line_no = 0;
-
- node->link = pnode[0];
-
- pnode[0] = node;
- table->nodes++;
-
- table->alloc_total += size;
-
- if ( table->alloc_current > table->alloc_max )
- table->alloc_max = table->alloc_current;
-
- if ( table->nodes * 3 < table->size ||
- table->size * 3 < table->nodes )
- ft_mem_table_resize( table );
- }
- }
-
-
- static void
- ft_mem_table_remove( FT_MemTable table,
- FT_Byte* address,
- FT_Long delta )
- {
- if ( table )
- {
- FT_MemNode *pnode, node;
-
-
- pnode = ft_mem_table_get_nodep( table, address );
- node = *pnode;
- if ( node )
- {
- FT_MemSource source;
-
-
- if ( node->size < 0 )
- ft_mem_debug_panic(
- "freeing memory block at %p more than once\n"
- " at (%s:%ld)!\n"
- " Block was allocated at (%s:%ld)\n"
- " and released at (%s:%ld).",
- address,
- FT_FILENAME( ft_debug_file_ ), ft_debug_lineno_,
- FT_FILENAME( node->source->file_name ), node->source->line_no,
- FT_FILENAME( node->free_file_name ), node->free_line_no );
-
- /* scramble the node's content for additional safety */
- FT_MEM_SET( address, 0xF3, node->size );
-
- if ( delta == 0 )
- {
- source = node->source;
-
- source->cur_blocks--;
- source->cur_size -= node->size;
-
- table->alloc_current -= node->size;
- }
-
- if ( table->keep_alive )
- {
- /* we simply invert the node's size to indicate that the node */
- /* was freed. */
- node->size = -node->size;
- node->free_file_name = ft_debug_file_;
- node->free_line_no = ft_debug_lineno_;
- }
- else
- {
- table->nodes--;
-
- *pnode = node->link;
-
- node->size = 0;
- node->source = NULL;
-
- ft_mem_table_free( table, node );
-
- if ( table->nodes * 3 < table->size ||
- table->size * 3 < table->nodes )
- ft_mem_table_resize( table );
- }
- }
- else
- ft_mem_debug_panic(
- "trying to free unknown block at %p in (%s:%ld)\n",
- address,
- FT_FILENAME( ft_debug_file_ ), ft_debug_lineno_ );
- }
- }
-
-
- static FT_Pointer
- ft_mem_debug_alloc( FT_Memory memory,
- FT_Long size )
- {
- FT_MemTable table = (FT_MemTable)memory->user;
- FT_Byte* block;
-
-
- if ( size <= 0 )
- ft_mem_debug_panic( "negative block size allocation (%ld)", size );
-
- /* return NULL if the maximum number of allocations was reached */
- if ( table->bound_count &&
- table->alloc_count >= table->alloc_count_max )
- return NULL;
-
- /* return NULL if this allocation would overflow the maximum heap size */
- if ( table->bound_total &&
- table->alloc_total_max - table->alloc_current > size )
- return NULL;
-
- block = (FT_Byte *)ft_mem_table_alloc( table, size );
- if ( block )
- {
- ft_mem_table_set( table, block, size, 0 );
-
- table->alloc_count++;
- }
-
- ft_debug_file_ = "<unknown>";
- ft_debug_lineno_ = 0;
-
- return (FT_Pointer)block;
- }
-
-
- static void
- ft_mem_debug_free( FT_Memory memory,
- FT_Pointer block )
- {
- FT_MemTable table = (FT_MemTable)memory->user;
-
-
- if ( !block )
- ft_mem_debug_panic( "trying to free NULL in (%s:%ld)",
- FT_FILENAME( ft_debug_file_ ),
- ft_debug_lineno_ );
-
- ft_mem_table_remove( table, (FT_Byte*)block, 0 );
-
- if ( !table->keep_alive )
- ft_mem_table_free( table, block );
-
- table->alloc_count--;
-
- ft_debug_file_ = "<unknown>";
- ft_debug_lineno_ = 0;
- }
-
-
- static FT_Pointer
- ft_mem_debug_realloc( FT_Memory memory,
- FT_Long cur_size,
- FT_Long new_size,
- FT_Pointer block )
- {
- FT_MemTable table = (FT_MemTable)memory->user;
- FT_MemNode node, *pnode;
- FT_Pointer new_block;
- FT_Long delta;
-
- const char* file_name = FT_FILENAME( ft_debug_file_ );
- FT_Long line_no = ft_debug_lineno_;
-
-
- /* unlikely, but possible */
- if ( new_size == cur_size )
- return block;
-
- /* the following is valid according to ANSI C */
-#if 0
- if ( !block || !cur_size )
- ft_mem_debug_panic( "trying to reallocate NULL in (%s:%ld)",
- file_name, line_no );
-#endif
-
- /* while the following is allowed in ANSI C also, we abort since */
- /* such case should be handled by FreeType. */
- if ( new_size <= 0 )
- ft_mem_debug_panic(
- "trying to reallocate %p to size 0 (current is %ld) in (%s:%ld)",
- block, cur_size, file_name, line_no );
-
- /* check `cur_size' value */
- pnode = ft_mem_table_get_nodep( table, (FT_Byte*)block );
- node = *pnode;
- if ( !node )
- ft_mem_debug_panic(
- "trying to reallocate unknown block at %p in (%s:%ld)",
- block, file_name, line_no );
-
- if ( node->size <= 0 )
- ft_mem_debug_panic(
- "trying to reallocate freed block at %p in (%s:%ld)",
- block, file_name, line_no );
-
- if ( node->size != cur_size )
- ft_mem_debug_panic( "invalid ft_realloc request for %p. cur_size is "
- "%ld instead of %ld in (%s:%ld)",
- block, cur_size, node->size, file_name, line_no );
-
- /* return NULL if the maximum number of allocations was reached */
- if ( table->bound_count &&
- table->alloc_count >= table->alloc_count_max )
- return NULL;
-
- delta = new_size - cur_size;
-
- /* return NULL if this allocation would overflow the maximum heap size */
- if ( delta > 0 &&
- table->bound_total &&
- table->alloc_current + delta > table->alloc_total_max )
- return NULL;
-
- new_block = (FT_Pointer)ft_mem_table_alloc( table, new_size );
- if ( !new_block )
- return NULL;
-
- ft_mem_table_set( table, (FT_Byte*)new_block, new_size, delta );
-
- ft_memcpy( new_block, block, cur_size < new_size ? (size_t)cur_size
- : (size_t)new_size );
-
- ft_mem_table_remove( table, (FT_Byte*)block, delta );
-
- ft_debug_file_ = "<unknown>";
- ft_debug_lineno_ = 0;
-
- if ( !table->keep_alive )
- ft_mem_table_free( table, block );
-
- return new_block;
- }
-
-
- extern void
- ft_mem_debug_init( FT_Memory memory )
- {
- FT_MemTable table;
-
-
- if ( !ft_getenv( "FT2_DEBUG_MEMORY" ) )
- return;
-
- table = (FT_MemTable)memory->alloc( memory, sizeof ( *table ) );
-
- if ( table )
- {
- FT_ZERO( table );
-
- table->memory = memory;
- table->memory_user = memory->user;
- table->alloc = memory->alloc;
- table->realloc = memory->realloc;
- table->free = memory->free;
-
- ft_mem_table_resize( table );
-
- if ( table->size )
- {
- const char* p;
-
-
- memory->user = table;
- memory->alloc = ft_mem_debug_alloc;
- memory->realloc = ft_mem_debug_realloc;
- memory->free = ft_mem_debug_free;
-
- p = ft_getenv( "FT2_ALLOC_TOTAL_MAX" );
- if ( p )
- {
- FT_Long total_max = ft_strtol( p, NULL, 10 );
-
-
- if ( total_max > 0 )
- {
- table->bound_total = 1;
- table->alloc_total_max = total_max;
- }
- }
-
- p = ft_getenv( "FT2_ALLOC_COUNT_MAX" );
- if ( p )
- {
- FT_Long total_count = ft_strtol( p, NULL, 10 );
-
-
- if ( total_count > 0 )
- {
- table->bound_count = 1;
- table->alloc_count_max = total_count;
- }
- }
-
- p = ft_getenv( "FT2_KEEP_ALIVE" );
- if ( p )
- {
- FT_Long keep_alive = ft_strtol( p, NULL, 10 );
-
-
- if ( keep_alive > 0 )
- table->keep_alive = 1;
- }
- }
- else
- memory->free( memory, table );
- }
- }
-
-
- extern void
- ft_mem_debug_done( FT_Memory memory )
- {
- if ( memory->free == ft_mem_debug_free )
- {
- FT_MemTable table = (FT_MemTable)memory->user;
-
-
- FT_DumpMemory( memory );
-
- ft_mem_table_destroy( table );
-
- memory->free = table->free;
- memory->realloc = table->realloc;
- memory->alloc = table->alloc;
- memory->user = table->memory_user;
-
- memory->free( memory, table );
- }
- }
-
-
- FT_COMPARE_DEF( int )
- ft_mem_source_compare( const void* p1,
- const void* p2 )
- {
- FT_MemSource s1 = *(FT_MemSource*)p1;
- FT_MemSource s2 = *(FT_MemSource*)p2;
-
-
- if ( s2->max_size > s1->max_size )
- return 1;
- else if ( s2->max_size < s1->max_size )
- return -1;
- else
- return 0;
- }
-
-
- extern void
- FT_DumpMemory( FT_Memory memory )
- {
- if ( memory->free == ft_mem_debug_free )
- {
- FT_MemTable table = (FT_MemTable)memory->user;
- FT_MemSource* bucket = table->sources;
- FT_MemSource* limit = bucket + FT_MEM_SOURCE_BUCKETS;
- FT_MemSource* sources;
- FT_Int nn, count;
- const char* fmt;
-
-
- count = 0;
- for ( ; bucket < limit; bucket++ )
- {
- FT_MemSource source = *bucket;
-
-
- for ( ; source; source = source->link )
- count++;
- }
-
- sources = (FT_MemSource*)
- ft_mem_table_alloc(
- table, count * (FT_Long)sizeof ( *sources ) );
-
- count = 0;
- for ( bucket = table->sources; bucket < limit; bucket++ )
- {
- FT_MemSource source = *bucket;
-
-
- for ( ; source; source = source->link )
- sources[count++] = source;
- }
-
- ft_qsort( sources,
- (size_t)count,
- sizeof ( *sources ),
- ft_mem_source_compare );
-
- printf( "FreeType Memory Dump: "
- "current=%ld max=%ld total=%ld count=%ld\n",
- table->alloc_current, table->alloc_max,
- table->alloc_total, table->alloc_count );
- printf( " block block sizes sizes sizes source\n" );
- printf( " count high sum highsum max location\n" );
- printf( "-------------------------------------------------\n" );
-
- fmt = "%6ld %6ld %8ld %8ld %8ld %s:%d\n";
-
- for ( nn = 0; nn < count; nn++ )
- {
- FT_MemSource source = sources[nn];
-
-
- printf( fmt,
- source->cur_blocks, source->max_blocks,
- source->cur_size, source->max_size, source->cur_max,
- FT_FILENAME( source->file_name ),
- source->line_no );
- }
- printf( "------------------------------------------------\n" );
-
- ft_mem_table_free( table, sources );
- }
- }
-
-#else /* !FT_DEBUG_MEMORY */
-
- /* ANSI C doesn't like empty source files */
- typedef int debug_mem_dummy_;
-
-#endif /* !FT_DEBUG_MEMORY */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/base/ftdebug.c b/contrib/libs/freetype/src/base/ftdebug.c
deleted file mode 100644
index 11307eaace..0000000000
--- a/contrib/libs/freetype/src/base/ftdebug.c
+++ /dev/null
@@ -1,644 +0,0 @@
-/****************************************************************************
- *
- * ftdebug.c
- *
- * Debugging and logging component (body).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /**************************************************************************
- *
- * This component contains various macros and functions used to ease the
- * debugging of the FreeType engine. Its main purpose is in assertion
- * checking, tracing, and error detection.
- *
- * There are now three debugging modes:
- *
- * - trace mode
- *
- * Error and trace messages are sent to the log file (which can be the
- * standard error output).
- *
- * - error mode
- *
- * Only error messages are generated.
- *
- * - release mode:
- *
- * No error message is sent or generated. The code is free from any
- * debugging parts.
- *
- */
-
-
-#include <freetype/freetype.h>
-#include <freetype/ftlogging.h>
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftobjs.h>
-
-
-#ifdef FT_DEBUG_LOGGING
-
- /**************************************************************************
- *
- * Variables used to control logging.
- *
- * 1. `ft_default_trace_level` stores the value of trace levels, which are
- * provided to FreeType using the `FT2_DEBUG` environment variable.
- *
- * 2. `ft_fileptr` stores the `FILE*` handle.
- *
- * 3. `ft_component` is a string that holds the name of `FT_COMPONENT`.
- *
- * 4. The flag `ft_component_flag` prints the name of `FT_COMPONENT` along
- * with the actual log message if set to true.
- *
- * 5. The flag `ft_timestamp_flag` prints time along with the actual log
- * message if set to ture.
- *
- * 6. `ft_have_newline_char` is used to differentiate between a log
- * message with and without a trailing newline character.
- *
- * 7. `ft_custom_trace_level` stores the custom trace level value, which
- * is provided by the user at run-time.
- *
- * We use `static` to avoid 'unused variable' warnings.
- *
- */
- static const char* ft_default_trace_level = NULL;
- static FILE* ft_fileptr = NULL;
- static const char* ft_component = NULL;
- static FT_Bool ft_component_flag = FALSE;
- static FT_Bool ft_timestamp_flag = FALSE;
- static FT_Bool ft_have_newline_char = TRUE;
- static const char* ft_custom_trace_level = NULL;
-
- /* declared in ftdebug.h */
-
- dlg_handler ft_default_log_handler = NULL;
- FT_Custom_Log_Handler custom_output_handler = NULL;
-
-#endif /* FT_DEBUG_LOGGING */
-
-
-#ifdef FT_DEBUG_LEVEL_ERROR
-
- /* documentation is in ftdebug.h */
-
- FT_BASE_DEF( void )
- FT_Message( const char* fmt,
- ... )
- {
- va_list ap;
-
-
- va_start( ap, fmt );
- vfprintf( stderr, fmt, ap );
- va_end( ap );
- }
-
-
- /* documentation is in ftdebug.h */
-
- FT_BASE_DEF( void )
- FT_Panic( const char* fmt,
- ... )
- {
- va_list ap;
-
-
- va_start( ap, fmt );
- vfprintf( stderr, fmt, ap );
- va_end( ap );
-
- exit( EXIT_FAILURE );
- }
-
-
- /* documentation is in ftdebug.h */
-
- FT_BASE_DEF( int )
- FT_Throw( FT_Error error,
- int line,
- const char* file )
- {
-#if 0
- /* activating the code in this block makes FreeType very chatty */
- fprintf( stderr,
- "%s:%d: error 0x%02x: %s\n",
- file,
- line,
- error,
- FT_Error_String( error ) );
-#else
- FT_UNUSED( error );
- FT_UNUSED( line );
- FT_UNUSED( file );
-#endif
-
- return 0;
- }
-
-#endif /* FT_DEBUG_LEVEL_ERROR */
-
-
-#ifdef FT_DEBUG_LEVEL_TRACE
-
- /* array of trace levels, initialized to 0; */
- /* this gets adjusted at run-time */
- static int ft_trace_levels_enabled[trace_count];
-
- /* array of trace levels, always initialized to 0 */
- static int ft_trace_levels_disabled[trace_count];
-
- /* a pointer to either `ft_trace_levels_enabled' */
- /* or `ft_trace_levels_disabled' */
- int* ft_trace_levels;
-
- /* define array of trace toggle names */
-#define FT_TRACE_DEF( x ) #x ,
-
- static const char* ft_trace_toggles[trace_count + 1] =
- {
-#include <freetype/internal/fttrace.h>
- NULL
- };
-
-#undef FT_TRACE_DEF
-
-
- /* documentation is in ftdebug.h */
-
- FT_BASE_DEF( FT_Int )
- FT_Trace_Get_Count( void )
- {
- return trace_count;
- }
-
-
- /* documentation is in ftdebug.h */
-
- FT_BASE_DEF( const char * )
- FT_Trace_Get_Name( FT_Int idx )
- {
- int max = FT_Trace_Get_Count();
-
-
- if ( idx < max )
- return ft_trace_toggles[idx];
- else
- return NULL;
- }
-
-
- /* documentation is in ftdebug.h */
-
- FT_BASE_DEF( void )
- FT_Trace_Disable( void )
- {
- ft_trace_levels = ft_trace_levels_disabled;
- }
-
-
- /* documentation is in ftdebug.h */
-
- FT_BASE_DEF( void )
- FT_Trace_Enable( void )
- {
- ft_trace_levels = ft_trace_levels_enabled;
- }
-
-
- /**************************************************************************
- *
- * Initialize the tracing sub-system. This is done by retrieving the
- * value of the `FT2_DEBUG' environment variable. It must be a list of
- * toggles, separated by spaces, `;', or `,'. Example:
- *
- * export FT2_DEBUG="any:3 memory:7 stream:5"
- *
- * This requests that all levels be set to 3, except the trace level for
- * the memory and stream components which are set to 7 and 5,
- * respectively.
- *
- * See the file `include/freetype/internal/fttrace.h' for details of
- * the available toggle names.
- *
- * The level must be between 0 and 7; 0 means quiet (except for serious
- * runtime errors), and 7 means _very_ verbose.
- */
- FT_BASE_DEF( void )
- ft_debug_init( void )
- {
- const char* ft2_debug = NULL;
-
-
-#ifdef FT_DEBUG_LOGGING
- if ( ft_custom_trace_level != NULL )
- ft2_debug = ft_custom_trace_level;
- else
- ft2_debug = ft_default_trace_level;
-#else
- ft2_debug = ft_getenv( "FT2_DEBUG" );
-#endif
-
- if ( ft2_debug )
- {
- const char* p = ft2_debug;
- const char* q;
-
-
- for ( ; *p; p++ )
- {
- /* skip leading whitespace and separators */
- if ( *p == ' ' || *p == '\t' || *p == ',' || *p == ';' || *p == '=' )
- continue;
-
-#ifdef FT_DEBUG_LOGGING
-
- /* check extra arguments for logging */
- if ( *p == '-' )
- {
- const char* r = ++p;
-
-
- if ( *r == 'v' )
- {
- const char* s = ++r;
-
-
- ft_component_flag = TRUE;
-
- if ( *s == 't' )
- {
- ft_timestamp_flag = TRUE;
- p++;
- }
-
- p++;
- }
-
- else if ( *r == 't' )
- {
- const char* s = ++r;
-
-
- ft_timestamp_flag = TRUE;
-
- if ( *s == 'v' )
- {
- ft_component_flag = TRUE;
- p++;
- }
-
- p++;
- }
- }
-
-#endif /* FT_DEBUG_LOGGING */
-
- /* read toggle name, followed by ':' */
- q = p;
- while ( *p && *p != ':' )
- p++;
-
- if ( !*p )
- break;
-
- if ( *p == ':' && p > q )
- {
- FT_Int n, i, len = (FT_Int)( p - q );
- FT_Int level = -1, found = -1;
-
-
- for ( n = 0; n < trace_count; n++ )
- {
- const char* toggle = ft_trace_toggles[n];
-
-
- for ( i = 0; i < len; i++ )
- {
- if ( toggle[i] != q[i] )
- break;
- }
-
- if ( i == len && toggle[i] == 0 )
- {
- found = n;
- break;
- }
- }
-
- /* read level */
- p++;
- if ( *p )
- {
- level = *p - '0';
- if ( level < 0 || level > 7 )
- level = -1;
- }
-
- if ( found >= 0 && level >= 0 )
- {
- if ( found == trace_any )
- {
- /* special case for `any' */
- for ( n = 0; n < trace_count; n++ )
- ft_trace_levels_enabled[n] = level;
- }
- else
- ft_trace_levels_enabled[found] = level;
- }
- }
- }
- }
-
- ft_trace_levels = ft_trace_levels_enabled;
- }
-
-
-#else /* !FT_DEBUG_LEVEL_TRACE */
-
-
- FT_BASE_DEF( void )
- ft_debug_init( void )
- {
- /* nothing */
- }
-
-
- FT_BASE_DEF( FT_Int )
- FT_Trace_Get_Count( void )
- {
- return 0;
- }
-
-
- FT_BASE_DEF( const char * )
- FT_Trace_Get_Name( FT_Int idx )
- {
- FT_UNUSED( idx );
-
- return NULL;
- }
-
-
- FT_BASE_DEF( void )
- FT_Trace_Disable( void )
- {
- /* nothing */
- }
-
-
- /* documentation is in ftdebug.h */
-
- FT_BASE_DEF( void )
- FT_Trace_Enable( void )
- {
- /* nothing */
- }
-
-#endif /* !FT_DEBUG_LEVEL_TRACE */
-
-
-#ifdef FT_DEBUG_LOGGING
-
- /**************************************************************************
- *
- * Initialize and de-initialize 'dlg' library.
- *
- */
-
- FT_BASE_DEF( void )
- ft_logging_init( void )
- {
- ft_default_log_handler = ft_log_handler;
- ft_default_trace_level = ft_getenv( "FT2_DEBUG" );
-
- if ( ft_getenv( "FT_LOGGING_FILE" ) )
- ft_fileptr = ft_fopen( ft_getenv( "FT_LOGGING_FILE" ), "w" );
- else
- ft_fileptr = stderr;
-
- ft_debug_init();
-
- /* Set the default output handler for 'dlg'. */
- dlg_set_handler( ft_default_log_handler, NULL );
- }
-
-
- FT_BASE_DEF( void )
- ft_logging_deinit( void )
- {
- if ( ft_fileptr != stderr )
- ft_fclose( ft_fileptr );
- }
-
-
- /**************************************************************************
- *
- * An output log handler for FreeType.
- *
- */
- FT_BASE_DEF( void )
- ft_log_handler( const struct dlg_origin* origin,
- const char* string,
- void* data )
- {
- char features_buf[128];
- char* bufp = features_buf;
-
- FT_UNUSED( data );
-
-
- if ( ft_have_newline_char )
- {
- const char* features = NULL;
- size_t features_length = 0;
-
-
-#define FEATURES_TIMESTAMP "[%h:%m] "
-#define FEATURES_COMPONENT "[%t] "
-#define FEATURES_TIMESTAMP_COMPONENT "[%h:%m %t] "
-
- if ( ft_timestamp_flag && ft_component_flag )
- {
- features = FEATURES_TIMESTAMP_COMPONENT;
- features_length = sizeof ( FEATURES_TIMESTAMP_COMPONENT );
- }
- else if ( ft_timestamp_flag )
- {
- features = FEATURES_TIMESTAMP;
- features_length = sizeof ( FEATURES_TIMESTAMP );
- }
- else if ( ft_component_flag )
- {
- features = FEATURES_COMPONENT;
- features_length = sizeof ( FEATURES_COMPONENT );
- }
-
- if ( ft_component_flag || ft_timestamp_flag )
- {
- ft_strncpy( features_buf, features, features_length );
- bufp += features_length - 1;
- }
-
- if ( ft_component_flag )
- {
- size_t tag_length = ft_strlen( *origin->tags );
- size_t i;
-
-
- /* To vertically align tracing messages we compensate the */
- /* different FT_COMPONENT string lengths by inserting an */
- /* appropriate amount of space characters. */
- for ( i = 0;
- i < FT_MAX_TRACE_LEVEL_LENGTH - tag_length;
- i++ )
- *bufp++ = ' ';
- }
- }
-
- /* Finally add the format string for the tracing message. */
- *bufp++ = '%';
- *bufp++ = 'c';
- *bufp = '\0';
-
- dlg_generic_outputf_stream( ft_fileptr,
- (const char*)features_buf,
- origin,
- string,
- dlg_default_output_styles,
- true );
-
- if ( ft_strrchr( string, '\n' ) )
- ft_have_newline_char = TRUE;
- else
- ft_have_newline_char = FALSE;
- }
-
-
- /* documentation is in ftdebug.h */
- FT_BASE_DEF( void )
- ft_add_tag( const char* tag )
- {
- ft_component = tag;
-
- dlg_add_tag( tag, NULL );
- }
-
-
- /* documentation is in ftdebug.h */
- FT_BASE_DEF( void )
- ft_remove_tag( const char* tag )
- {
- dlg_remove_tag( tag, NULL );
- }
-
-
- /* documentation is in ftlogging.h */
-
- FT_EXPORT_DEF( void )
- FT_Trace_Set_Level( const char* level )
- {
- ft_component_flag = FALSE;
- ft_timestamp_flag = FALSE;
- ft_custom_trace_level = level;
-
- ft_debug_init();
- }
-
-
- /* documentation is in ftlogging.h */
-
- FT_EXPORT_DEF( void )
- FT_Trace_Set_Default_Level( void )
- {
- ft_component_flag = FALSE;
- ft_timestamp_flag = FALSE;
- ft_custom_trace_level = NULL;
-
- ft_debug_init();
- }
-
-
- /**************************************************************************
- *
- * Functions to handle a custom log handler.
- *
- */
-
- /* documentation is in ftlogging.h */
-
- FT_EXPORT_DEF( void )
- FT_Set_Log_Handler( FT_Custom_Log_Handler handler )
- {
- custom_output_handler = handler;
- }
-
-
- /* documentation is in ftlogging.h */
-
- FT_EXPORT_DEF( void )
- FT_Set_Default_Log_Handler( void )
- {
- custom_output_handler = NULL;
- }
-
-
- /* documentation is in ftdebug.h */
- FT_BASE_DEF( void )
- FT_Logging_Callback( const char* fmt,
- ... )
- {
- va_list ap;
-
-
- va_start( ap, fmt );
- custom_output_handler( ft_component, fmt, ap );
- va_end( ap );
- }
-
-#else /* !FT_DEBUG_LOGGING */
-
- FT_EXPORT_DEF( void )
- FT_Trace_Set_Level( const char* level )
- {
- FT_UNUSED( level );
- }
-
-
- FT_EXPORT_DEF( void )
- FT_Trace_Set_Default_Level( void )
- {
- /* nothing */
- }
-
-
- FT_EXPORT_DEF( void )
- FT_Set_Log_Handler( FT_Custom_Log_Handler handler )
- {
- FT_UNUSED( handler );
- }
-
-
- FT_EXPORT_DEF( void )
- FT_Set_Default_Log_Handler( void )
- {
- /* nothing */
- }
-
-#endif /* !FT_DEBUG_LOGGING */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/base/fterrors.c b/contrib/libs/freetype/src/base/fterrors.c
deleted file mode 100644
index 61041a37c1..0000000000
--- a/contrib/libs/freetype/src/base/fterrors.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/****************************************************************************
- *
- * fterrors.c
- *
- * FreeType API for error code handling.
- *
- * Copyright (C) 2018-2024 by
- * Armin Hasitzka, David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftdebug.h>
-#include <freetype/fterrors.h>
-
-
- /* documentation is in fterrors.h */
-
- FT_EXPORT_DEF( const char* )
- FT_Error_String( FT_Error error_code )
- {
- if ( error_code < 0 ||
- error_code >= FT_ERR_CAT( FT_ERR_PREFIX, Max ) )
- return NULL;
-
-#if defined( FT_CONFIG_OPTION_ERROR_STRINGS ) || \
- defined( FT_DEBUG_LEVEL_ERROR )
-
-#undef FTERRORS_H_
-#define FT_ERROR_START_LIST switch ( FT_ERROR_BASE( error_code ) ) {
-#define FT_ERRORDEF( e, v, s ) case v: return s;
-#define FT_ERROR_END_LIST }
-
-#include <freetype/fterrors.h>
-
-#endif /* defined( FT_CONFIG_OPTION_ERROR_STRINGS ) || ... */
-
- return NULL;
- }
diff --git a/contrib/libs/freetype/src/base/ftfntfmt.c b/contrib/libs/freetype/src/base/ftfntfmt.c
deleted file mode 100644
index 77b4089e7e..0000000000
--- a/contrib/libs/freetype/src/base/ftfntfmt.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/****************************************************************************
- *
- * ftfntfmt.c
- *
- * FreeType utility file for font formats (body).
- *
- * Copyright (C) 2002-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/ftfntfmt.h>
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/services/svfntfmt.h>
-
-
- /* documentation is in ftfntfmt.h */
-
- FT_EXPORT_DEF( const char* )
- FT_Get_Font_Format( FT_Face face )
- {
- const char* result = NULL;
-
-
- if ( face )
- FT_FACE_FIND_SERVICE( face, result, FONT_FORMAT );
-
- return result;
- }
-
-
- /* deprecated function name; retained for ABI compatibility */
-
- FT_EXPORT_DEF( const char* )
- FT_Get_X11_Font_Format( FT_Face face )
- {
- const char* result = NULL;
-
-
- if ( face )
- FT_FACE_FIND_SERVICE( face, result, FONT_FORMAT );
-
- return result;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/base/ftfstype.c b/contrib/libs/freetype/src/base/ftfstype.c
deleted file mode 100644
index 1565c3b7e2..0000000000
--- a/contrib/libs/freetype/src/base/ftfstype.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/****************************************************************************
- *
- * ftfstype.c
- *
- * FreeType utility file to access FSType data (body).
- *
- * Copyright (C) 2008-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-#include <freetype/t1tables.h>
-#include <freetype/tttables.h>
-#include <freetype/internal/ftserv.h>
-#include <freetype/internal/services/svpsinfo.h>
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_UShort )
- FT_Get_FSType_Flags( FT_Face face )
- {
- TT_OS2* os2;
-
-
- /* first, try to get the fs_type directly from the font */
- if ( face )
- {
- FT_Service_PsInfo service = NULL;
-
-
- FT_FACE_FIND_SERVICE( face, service, POSTSCRIPT_INFO );
-
- if ( service && service->ps_get_font_extra )
- {
- PS_FontExtraRec extra;
-
-
- if ( !service->ps_get_font_extra( face, &extra ) &&
- extra.fs_type != 0 )
- return extra.fs_type;
- }
- }
-
- /* look at FSType before fsType for Type42 */
-
- if ( ( os2 = (TT_OS2*)FT_Get_Sfnt_Table( face, FT_SFNT_OS2 ) ) != NULL &&
- os2->version != 0xFFFFU )
- return os2->fsType;
-
- return 0;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/base/ftgasp.c b/contrib/libs/freetype/src/base/ftgasp.c
deleted file mode 100644
index c63d30e978..0000000000
--- a/contrib/libs/freetype/src/base/ftgasp.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/****************************************************************************
- *
- * ftgasp.c
- *
- * Access of TrueType's `gasp' table (body).
- *
- * Copyright (C) 2007-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/ftgasp.h>
-#include <freetype/internal/tttypes.h>
-
-
- FT_EXPORT_DEF( FT_Int )
- FT_Get_Gasp( FT_Face face,
- FT_UInt ppem )
- {
- FT_Int result = FT_GASP_NO_TABLE;
-
-
- if ( face && FT_IS_SFNT( face ) )
- {
- TT_Face ttface = (TT_Face)face;
-
-
- if ( ttface->gasp.numRanges > 0 )
- {
- TT_GaspRange range = ttface->gasp.gaspRanges;
- TT_GaspRange range_end = range + ttface->gasp.numRanges;
-
-
- while ( ppem > range->maxPPEM )
- {
- range++;
- if ( range >= range_end )
- goto Exit;
- }
-
- result = range->gaspFlag;
-
- /* ensure that we don't have spurious bits */
- if ( ttface->gasp.version == 0 )
- result &= 3;
- }
- }
- Exit:
- return result;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/base/ftgloadr.c b/contrib/libs/freetype/src/base/ftgloadr.c
deleted file mode 100644
index 484d98f172..0000000000
--- a/contrib/libs/freetype/src/base/ftgloadr.c
+++ /dev/null
@@ -1,383 +0,0 @@
-/****************************************************************************
- *
- * ftgloadr.c
- *
- * The FreeType glyph loader (body).
- *
- * Copyright (C) 2002-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftgloadr.h>
-#include <freetype/internal/ftmemory.h>
-#include <freetype/internal/ftobjs.h>
-
-#undef FT_COMPONENT
-#define FT_COMPONENT gloader
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** *****/
- /***** G L Y P H L O A D E R *****/
- /***** *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
- /**************************************************************************
- *
- * The glyph loader is a simple object which is used to load a set of
- * glyphs easily. It is critical for the correct loading of composites.
- *
- * Ideally, one can see it as a stack of abstract `glyph' objects.
- *
- * loader.base Is really the bottom of the stack. It describes a
- * single glyph image made of the juxtaposition of
- * several glyphs (those `in the stack').
- *
- * loader.current Describes the top of the stack, on which a new
- * glyph can be loaded.
- *
- * Rewind Clears the stack.
- * Prepare Set up `loader.current' for addition of a new glyph
- * image.
- * Add Add the `current' glyph image to the `base' one,
- * and prepare for another one.
- *
- * The glyph loader is now a base object. Each driver used to
- * re-implement it in one way or the other, which wasted code and
- * energy.
- *
- */
-
-
- /* create a new glyph loader */
- FT_BASE_DEF( FT_Error )
- FT_GlyphLoader_New( FT_Memory memory,
- FT_GlyphLoader *aloader )
- {
- FT_GlyphLoader loader = NULL;
- FT_Error error;
-
-
- if ( !FT_NEW( loader ) )
- {
- loader->memory = memory;
- *aloader = loader;
- }
- return error;
- }
-
-
- /* rewind the glyph loader - reset counters to 0 */
- FT_BASE_DEF( void )
- FT_GlyphLoader_Rewind( FT_GlyphLoader loader )
- {
- FT_GlyphLoad base = &loader->base;
- FT_GlyphLoad current = &loader->current;
-
-
- base->outline.n_points = 0;
- base->outline.n_contours = 0;
- base->outline.flags = 0;
- base->num_subglyphs = 0;
-
- *current = *base;
- }
-
-
- /* reset glyph loader, free all allocated tables, */
- /* and start from zero */
- FT_BASE_DEF( void )
- FT_GlyphLoader_Reset( FT_GlyphLoader loader )
- {
- FT_Memory memory = loader->memory;
-
-
- FT_FREE( loader->base.outline.points );
- FT_FREE( loader->base.outline.tags );
- FT_FREE( loader->base.outline.contours );
- FT_FREE( loader->base.extra_points );
- FT_FREE( loader->base.subglyphs );
-
- loader->base.extra_points2 = NULL;
-
- loader->max_points = 0;
- loader->max_contours = 0;
- loader->max_subglyphs = 0;
-
- FT_GlyphLoader_Rewind( loader );
- }
-
-
- /* delete a glyph loader */
- FT_BASE_DEF( void )
- FT_GlyphLoader_Done( FT_GlyphLoader loader )
- {
- if ( loader )
- {
- FT_Memory memory = loader->memory;
-
-
- FT_GlyphLoader_Reset( loader );
- FT_FREE( loader );
- }
- }
-
-
- /* re-adjust the `current' outline fields */
- static void
- FT_GlyphLoader_Adjust_Points( FT_GlyphLoader loader )
- {
- FT_Outline* base = &loader->base.outline;
- FT_Outline* current = &loader->current.outline;
-
-
- current->points = FT_OFFSET( base->points, base->n_points );
- current->tags = FT_OFFSET( base->tags, base->n_points );
- current->contours = FT_OFFSET( base->contours, base->n_contours );
-
- /* handle extra points table - if any */
- if ( loader->use_extra )
- {
- loader->current.extra_points = loader->base.extra_points +
- base->n_points;
-
- loader->current.extra_points2 = loader->base.extra_points2 +
- base->n_points;
- }
- }
-
-
- FT_BASE_DEF( FT_Error )
- FT_GlyphLoader_CreateExtra( FT_GlyphLoader loader )
- {
- FT_Error error;
- FT_Memory memory = loader->memory;
-
-
- if ( loader->max_points == 0 ||
- loader->base.extra_points != NULL )
- return FT_Err_Ok;
-
- if ( !FT_NEW_ARRAY( loader->base.extra_points, 2 * loader->max_points ) )
- {
- loader->use_extra = 1;
- loader->base.extra_points2 = loader->base.extra_points +
- loader->max_points;
-
- FT_GlyphLoader_Adjust_Points( loader );
- }
- return error;
- }
-
-
- /* re-adjust the `current' subglyphs field */
- static void
- FT_GlyphLoader_Adjust_Subglyphs( FT_GlyphLoader loader )
- {
- FT_GlyphLoad base = &loader->base;
- FT_GlyphLoad current = &loader->current;
-
-
- current->subglyphs = FT_OFFSET( base->subglyphs, base->num_subglyphs );
- }
-
-
- /* Ensure that we can add `n_points' and `n_contours' to our glyph. */
- /* This function reallocates its outline tables if necessary. Note that */
- /* it DOESN'T change the number of points within the loader! */
- /* */
- FT_BASE_DEF( FT_Error )
- FT_GlyphLoader_CheckPoints( FT_GlyphLoader loader,
- FT_UInt n_points,
- FT_UInt n_contours )
- {
- FT_Memory memory = loader->memory;
- FT_Error error = FT_Err_Ok;
- FT_Outline* base = &loader->base.outline;
- FT_Outline* current = &loader->current.outline;
- FT_Bool adjust = 0;
-
- FT_UInt new_max, old_max, min_new_max;
-
-
- error = FT_GlyphLoader_CreateExtra( loader );
- if ( error )
- goto Exit;
-
- /* check points & tags */
- new_max = (FT_UInt)base->n_points + (FT_UInt)current->n_points +
- n_points;
- old_max = loader->max_points;
-
- if ( new_max > old_max )
- {
- if ( new_max > FT_OUTLINE_POINTS_MAX )
- {
- error = FT_THROW( Array_Too_Large );
- goto Exit;
- }
-
- min_new_max = old_max + ( old_max >> 1 );
- if ( new_max < min_new_max )
- new_max = min_new_max;
- new_max = FT_PAD_CEIL( new_max, 8 );
- if ( new_max > FT_OUTLINE_POINTS_MAX )
- new_max = FT_OUTLINE_POINTS_MAX;
-
- if ( FT_RENEW_ARRAY( base->points, old_max, new_max ) ||
- FT_RENEW_ARRAY( base->tags, old_max, new_max ) )
- goto Exit;
-
- if ( loader->use_extra )
- {
- if ( FT_RENEW_ARRAY( loader->base.extra_points,
- old_max * 2, new_max * 2 ) )
- goto Exit;
-
- FT_ARRAY_MOVE( loader->base.extra_points + new_max,
- loader->base.extra_points + old_max,
- old_max );
-
- loader->base.extra_points2 = loader->base.extra_points + new_max;
- }
-
- adjust = 1;
- loader->max_points = new_max;
- }
-
- error = FT_GlyphLoader_CreateExtra( loader );
- if ( error )
- goto Exit;
-
- /* check contours */
- old_max = loader->max_contours;
- new_max = (FT_UInt)base->n_contours + (FT_UInt)current->n_contours +
- n_contours;
- if ( new_max > old_max )
- {
- if ( new_max > FT_OUTLINE_CONTOURS_MAX )
- {
- error = FT_THROW( Array_Too_Large );
- goto Exit;
- }
-
- min_new_max = old_max + ( old_max >> 1 );
- if ( new_max < min_new_max )
- new_max = min_new_max;
- new_max = FT_PAD_CEIL( new_max, 4 );
- if ( new_max > FT_OUTLINE_CONTOURS_MAX )
- new_max = FT_OUTLINE_CONTOURS_MAX;
-
- if ( FT_RENEW_ARRAY( base->contours, old_max, new_max ) )
- goto Exit;
-
- adjust = 1;
- loader->max_contours = new_max;
- }
-
- if ( adjust )
- FT_GlyphLoader_Adjust_Points( loader );
-
- Exit:
- if ( error )
- FT_GlyphLoader_Reset( loader );
-
- return error;
- }
-
-
- /* Ensure that we can add `n_subglyphs' to our glyph. this function */
- /* reallocates its subglyphs table if necessary. Note that it DOES */
- /* NOT change the number of subglyphs within the loader! */
- /* */
- FT_BASE_DEF( FT_Error )
- FT_GlyphLoader_CheckSubGlyphs( FT_GlyphLoader loader,
- FT_UInt n_subs )
- {
- FT_Memory memory = loader->memory;
- FT_Error error = FT_Err_Ok;
- FT_UInt new_max, old_max;
-
- FT_GlyphLoad base = &loader->base;
- FT_GlyphLoad current = &loader->current;
-
-
- new_max = base->num_subglyphs + current->num_subglyphs + n_subs;
- old_max = loader->max_subglyphs;
- if ( new_max > old_max )
- {
- new_max = FT_PAD_CEIL( new_max, 2 );
- if ( FT_RENEW_ARRAY( base->subglyphs, old_max, new_max ) )
- goto Exit;
-
- loader->max_subglyphs = new_max;
-
- FT_GlyphLoader_Adjust_Subglyphs( loader );
- }
-
- Exit:
- return error;
- }
-
-
- /* prepare loader for the addition of a new glyph on top of the base one */
- FT_BASE_DEF( void )
- FT_GlyphLoader_Prepare( FT_GlyphLoader loader )
- {
- FT_GlyphLoad current = &loader->current;
-
-
- current->outline.n_points = 0;
- current->outline.n_contours = 0;
- current->num_subglyphs = 0;
-
- FT_GlyphLoader_Adjust_Points ( loader );
- FT_GlyphLoader_Adjust_Subglyphs( loader );
- }
-
-
- /* add current glyph to the base image -- and prepare for another */
- FT_BASE_DEF( void )
- FT_GlyphLoader_Add( FT_GlyphLoader loader )
- {
- FT_Outline* base;
- FT_Outline* current;
- FT_Int n;
-
-
- if ( !loader )
- return;
-
- base = &loader->base.outline;
- current = &loader->current.outline;
-
- /* adjust contours count in newest outline */
- for ( n = 0; n < current->n_contours; n++ )
- current->contours[n] += base->n_points;
-
- base->n_points += current->n_points;
- base->n_contours += current->n_contours;
-
- loader->base.num_subglyphs += loader->current.num_subglyphs;
-
- /* prepare for another new glyph image */
- FT_GlyphLoader_Prepare( loader );
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/base/ftglyph.c b/contrib/libs/freetype/src/base/ftglyph.c
deleted file mode 100644
index 1b5849f99a..0000000000
--- a/contrib/libs/freetype/src/base/ftglyph.c
+++ /dev/null
@@ -1,911 +0,0 @@
-/****************************************************************************
- *
- * ftglyph.c
- *
- * FreeType convenience functions to handle glyphs (body).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
- /**************************************************************************
- *
- * This file contains the definition of several convenience functions
- * that can be used by client applications to easily retrieve glyph
- * bitmaps and outlines from a given face.
- *
- * These functions should be optional if you are writing a font server
- * or text layout engine on top of FreeType. However, they are pretty
- * handy for many other simple uses of the library.
- *
- */
-
-
-#include <freetype/internal/ftdebug.h>
-
-#include <freetype/ftglyph.h>
-#include <freetype/ftoutln.h>
-#include <freetype/ftbitmap.h>
-#include <freetype/internal/ftobjs.h>
-#include <freetype/otsvg.h>
-
-#include "ftbase.h"
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT glyph
-
-
- /*************************************************************************/
- /*************************************************************************/
- /**** ****/
- /**** FT_BitmapGlyph support ****/
- /**** ****/
- /*************************************************************************/
- /*************************************************************************/
-
- FT_CALLBACK_DEF( FT_Error )
- ft_bitmap_glyph_init( FT_Glyph bitmap_glyph,
- FT_GlyphSlot slot )
- {
- FT_BitmapGlyph glyph = (FT_BitmapGlyph)bitmap_glyph;
- FT_Error error = FT_Err_Ok;
- FT_Library library = FT_GLYPH( glyph )->library;
-
-
- if ( slot->format != FT_GLYPH_FORMAT_BITMAP )
- {
- error = FT_THROW( Invalid_Glyph_Format );
- goto Exit;
- }
-
- glyph->left = slot->bitmap_left;
- glyph->top = slot->bitmap_top;
-
- /* do lazy copying whenever possible */
- if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
- {
- glyph->bitmap = slot->bitmap;
- slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
- }
- else
- {
- FT_Bitmap_Init( &glyph->bitmap );
- error = FT_Bitmap_Copy( library, &slot->bitmap, &glyph->bitmap );
- }
-
- Exit:
- return error;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- ft_bitmap_glyph_copy( FT_Glyph bitmap_source,
- FT_Glyph bitmap_target )
- {
- FT_Library library = bitmap_source->library;
- FT_BitmapGlyph source = (FT_BitmapGlyph)bitmap_source;
- FT_BitmapGlyph target = (FT_BitmapGlyph)bitmap_target;
-
-
- target->left = source->left;
- target->top = source->top;
-
- return FT_Bitmap_Copy( library, &source->bitmap, &target->bitmap );
- }
-
-
- FT_CALLBACK_DEF( void )
- ft_bitmap_glyph_done( FT_Glyph bitmap_glyph )
- {
- FT_BitmapGlyph glyph = (FT_BitmapGlyph)bitmap_glyph;
- FT_Library library = FT_GLYPH( glyph )->library;
-
-
- FT_Bitmap_Done( library, &glyph->bitmap );
- }
-
-
- FT_CALLBACK_DEF( void )
- ft_bitmap_glyph_bbox( FT_Glyph bitmap_glyph,
- FT_BBox* cbox )
- {
- FT_BitmapGlyph glyph = (FT_BitmapGlyph)bitmap_glyph;
-
-
- cbox->xMin = glyph->left * 64;
- cbox->xMax = cbox->xMin + (FT_Pos)( glyph->bitmap.width * 64 );
- cbox->yMax = glyph->top * 64;
- cbox->yMin = cbox->yMax - (FT_Pos)( glyph->bitmap.rows * 64 );
- }
-
-
- FT_DEFINE_GLYPH(
- ft_bitmap_glyph_class,
-
- sizeof ( FT_BitmapGlyphRec ),
- FT_GLYPH_FORMAT_BITMAP,
-
- ft_bitmap_glyph_init, /* FT_Glyph_InitFunc glyph_init */
- ft_bitmap_glyph_done, /* FT_Glyph_DoneFunc glyph_done */
- ft_bitmap_glyph_copy, /* FT_Glyph_CopyFunc glyph_copy */
- NULL, /* FT_Glyph_TransformFunc glyph_transform */
- ft_bitmap_glyph_bbox, /* FT_Glyph_GetBBoxFunc glyph_bbox */
- NULL /* FT_Glyph_PrepareFunc glyph_prepare */
- )
-
-
- /*************************************************************************/
- /*************************************************************************/
- /**** ****/
- /**** FT_OutlineGlyph support ****/
- /**** ****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- FT_CALLBACK_DEF( FT_Error )
- ft_outline_glyph_init( FT_Glyph outline_glyph,
- FT_GlyphSlot slot )
- {
- FT_OutlineGlyph glyph = (FT_OutlineGlyph)outline_glyph;
- FT_Error error = FT_Err_Ok;
- FT_Library library = FT_GLYPH( glyph )->library;
- FT_Outline* source = &slot->outline;
- FT_Outline* target = &glyph->outline;
-
-
- /* check format in glyph slot */
- if ( slot->format != FT_GLYPH_FORMAT_OUTLINE )
- {
- error = FT_THROW( Invalid_Glyph_Format );
- goto Exit;
- }
-
- /* allocate new outline */
- error = FT_Outline_New( library,
- (FT_UInt)source->n_points,
- source->n_contours,
- &glyph->outline );
- if ( error )
- goto Exit;
-
- FT_Outline_Copy( source, target );
-
- Exit:
- return error;
- }
-
-
- FT_CALLBACK_DEF( void )
- ft_outline_glyph_done( FT_Glyph outline_glyph )
- {
- FT_OutlineGlyph glyph = (FT_OutlineGlyph)outline_glyph;
-
-
- FT_Outline_Done( FT_GLYPH( glyph )->library, &glyph->outline );
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- ft_outline_glyph_copy( FT_Glyph outline_source,
- FT_Glyph outline_target )
- {
- FT_OutlineGlyph source = (FT_OutlineGlyph)outline_source;
- FT_OutlineGlyph target = (FT_OutlineGlyph)outline_target;
- FT_Error error;
- FT_Library library = FT_GLYPH( source )->library;
-
-
- error = FT_Outline_New( library,
- (FT_UInt)source->outline.n_points,
- source->outline.n_contours,
- &target->outline );
- if ( !error )
- FT_Outline_Copy( &source->outline, &target->outline );
-
- return error;
- }
-
-
- FT_CALLBACK_DEF( void )
- ft_outline_glyph_transform( FT_Glyph outline_glyph,
- const FT_Matrix* matrix,
- const FT_Vector* delta )
- {
- FT_OutlineGlyph glyph = (FT_OutlineGlyph)outline_glyph;
-
-
- if ( matrix )
- FT_Outline_Transform( &glyph->outline, matrix );
-
- if ( delta )
- FT_Outline_Translate( &glyph->outline, delta->x, delta->y );
- }
-
-
- FT_CALLBACK_DEF( void )
- ft_outline_glyph_bbox( FT_Glyph outline_glyph,
- FT_BBox* bbox )
- {
- FT_OutlineGlyph glyph = (FT_OutlineGlyph)outline_glyph;
-
-
- FT_Outline_Get_CBox( &glyph->outline, bbox );
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- ft_outline_glyph_prepare( FT_Glyph outline_glyph,
- FT_GlyphSlot slot )
- {
- FT_OutlineGlyph glyph = (FT_OutlineGlyph)outline_glyph;
-
-
- slot->format = FT_GLYPH_FORMAT_OUTLINE;
- slot->outline = glyph->outline;
- slot->outline.flags &= ~FT_OUTLINE_OWNER;
-
- return FT_Err_Ok;
- }
-
-
- FT_DEFINE_GLYPH(
- ft_outline_glyph_class,
-
- sizeof ( FT_OutlineGlyphRec ),
- FT_GLYPH_FORMAT_OUTLINE,
-
- ft_outline_glyph_init, /* FT_Glyph_InitFunc glyph_init */
- ft_outline_glyph_done, /* FT_Glyph_DoneFunc glyph_done */
- ft_outline_glyph_copy, /* FT_Glyph_CopyFunc glyph_copy */
- ft_outline_glyph_transform, /* FT_Glyph_TransformFunc glyph_transform */
- ft_outline_glyph_bbox, /* FT_Glyph_GetBBoxFunc glyph_bbox */
- ft_outline_glyph_prepare /* FT_Glyph_PrepareFunc glyph_prepare */
- )
-
-
-#ifdef FT_CONFIG_OPTION_SVG
-
- /*************************************************************************/
- /*************************************************************************/
- /**** ****/
- /**** FT_SvgGlyph support ****/
- /**** ****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- FT_CALLBACK_DEF( FT_Error )
- ft_svg_glyph_init( FT_Glyph svg_glyph,
- FT_GlyphSlot slot )
- {
- FT_ULong doc_length;
- FT_SVG_Document document;
- FT_SvgGlyph glyph = (FT_SvgGlyph)svg_glyph;
-
- FT_Error error = FT_Err_Ok;
- FT_Memory memory = FT_GLYPH( glyph )->library->memory;
-
-
- if ( slot->format != FT_GLYPH_FORMAT_SVG )
- {
- error = FT_THROW( Invalid_Glyph_Format );
- goto Exit;
- }
-
- if ( slot->other == NULL )
- {
- error = FT_THROW( Invalid_Slot_Handle );
- goto Exit;
- }
-
- document = (FT_SVG_Document)slot->other;
-
- if ( document->svg_document_length == 0 )
- {
- error = FT_THROW( Invalid_Slot_Handle );
- goto Exit;
- }
-
- /* allocate a new document */
- doc_length = document->svg_document_length;
- if ( FT_QALLOC( glyph->svg_document, doc_length ) )
- goto Exit;
- glyph->svg_document_length = doc_length;
-
- glyph->glyph_index = slot->glyph_index;
-
- glyph->metrics = document->metrics;
- glyph->units_per_EM = document->units_per_EM;
-
- glyph->start_glyph_id = document->start_glyph_id;
- glyph->end_glyph_id = document->end_glyph_id;
-
- glyph->transform = document->transform;
- glyph->delta = document->delta;
-
- /* copy the document into glyph */
- FT_MEM_COPY( glyph->svg_document, document->svg_document, doc_length );
-
- Exit:
- return error;
- }
-
-
- FT_CALLBACK_DEF( void )
- ft_svg_glyph_done( FT_Glyph svg_glyph )
- {
- FT_SvgGlyph glyph = (FT_SvgGlyph)svg_glyph;
- FT_Memory memory = svg_glyph->library->memory;
-
-
- /* just free the memory */
- FT_FREE( glyph->svg_document );
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- ft_svg_glyph_copy( FT_Glyph svg_source,
- FT_Glyph svg_target )
- {
- FT_SvgGlyph source = (FT_SvgGlyph)svg_source;
- FT_SvgGlyph target = (FT_SvgGlyph)svg_target;
-
- FT_Error error = FT_Err_Ok;
- FT_Memory memory = FT_GLYPH( source )->library->memory;
-
-
- if ( svg_source->format != FT_GLYPH_FORMAT_SVG )
- {
- error = FT_THROW( Invalid_Glyph_Format );
- goto Exit;
- }
-
- if ( source->svg_document_length == 0 )
- {
- error = FT_THROW( Invalid_Slot_Handle );
- goto Exit;
- }
-
- target->glyph_index = source->glyph_index;
-
- target->svg_document_length = source->svg_document_length;
-
- target->metrics = source->metrics;
- target->units_per_EM = source->units_per_EM;
-
- target->start_glyph_id = source->start_glyph_id;
- target->end_glyph_id = source->end_glyph_id;
-
- target->transform = source->transform;
- target->delta = source->delta;
-
- /* allocate space for the SVG document */
- if ( FT_QALLOC( target->svg_document, target->svg_document_length ) )
- goto Exit;
-
- /* copy the document */
- FT_MEM_COPY( target->svg_document,
- source->svg_document,
- target->svg_document_length );
-
- Exit:
- return error;
- }
-
-
- FT_CALLBACK_DEF( void )
- ft_svg_glyph_transform( FT_Glyph svg_glyph,
- const FT_Matrix* _matrix,
- const FT_Vector* _delta )
- {
- FT_SvgGlyph glyph = (FT_SvgGlyph)svg_glyph;
- FT_Matrix* matrix = (FT_Matrix*)_matrix;
- FT_Vector* delta = (FT_Vector*)_delta;
-
- FT_Matrix tmp_matrix;
- FT_Vector tmp_delta;
-
- FT_Matrix a, b;
- FT_Pos x, y;
-
-
- if ( !matrix )
- {
- tmp_matrix.xx = 0x10000;
- tmp_matrix.xy = 0;
- tmp_matrix.yx = 0;
- tmp_matrix.yy = 0x10000;
-
- matrix = &tmp_matrix;
- }
-
- if ( !delta )
- {
- tmp_delta.x = 0;
- tmp_delta.y = 0;
-
- delta = &tmp_delta;
- }
-
- a = glyph->transform;
- b = *matrix;
- FT_Matrix_Multiply( &b, &a );
-
- x = ADD_LONG( ADD_LONG( FT_MulFix( matrix->xx, glyph->delta.x ),
- FT_MulFix( matrix->xy, glyph->delta.y ) ),
- delta->x );
- y = ADD_LONG( ADD_LONG( FT_MulFix( matrix->yx, glyph->delta.x ),
- FT_MulFix( matrix->yy, glyph->delta.y ) ),
- delta->y );
-
- glyph->delta.x = x;
- glyph->delta.y = y;
-
- glyph->transform = a;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- ft_svg_glyph_prepare( FT_Glyph svg_glyph,
- FT_GlyphSlot slot )
- {
- FT_SvgGlyph glyph = (FT_SvgGlyph)svg_glyph;
-
- FT_Error error = FT_Err_Ok;
- FT_Memory memory = svg_glyph->library->memory;
-
- FT_SVG_Document document = NULL;
-
-
- if ( FT_NEW( document ) )
- return error;
-
- document->svg_document = glyph->svg_document;
- document->svg_document_length = glyph->svg_document_length;
-
- document->metrics = glyph->metrics;
- document->units_per_EM = glyph->units_per_EM;
-
- document->start_glyph_id = glyph->start_glyph_id;
- document->end_glyph_id = glyph->end_glyph_id;
-
- document->transform = glyph->transform;
- document->delta = glyph->delta;
-
- slot->format = FT_GLYPH_FORMAT_SVG;
- slot->glyph_index = glyph->glyph_index;
- slot->other = document;
-
- return error;
- }
-
-
- FT_DEFINE_GLYPH(
- ft_svg_glyph_class,
-
- sizeof ( FT_SvgGlyphRec ),
- FT_GLYPH_FORMAT_SVG,
-
- ft_svg_glyph_init, /* FT_Glyph_InitFunc glyph_init */
- ft_svg_glyph_done, /* FT_Glyph_DoneFunc glyph_done */
- ft_svg_glyph_copy, /* FT_Glyph_CopyFunc glyph_copy */
- ft_svg_glyph_transform, /* FT_Glyph_TransformFunc glyph_transform */
- NULL, /* FT_Glyph_GetBBoxFunc glyph_bbox */
- ft_svg_glyph_prepare /* FT_Glyph_PrepareFunc glyph_prepare */
- )
-
-#endif /* FT_CONFIG_OPTION_SVG */
-
-
- /*************************************************************************/
- /*************************************************************************/
- /**** ****/
- /**** FT_Glyph class and API ****/
- /**** ****/
- /*************************************************************************/
- /*************************************************************************/
-
- static FT_Error
- ft_new_glyph( FT_Library library,
- const FT_Glyph_Class* clazz,
- FT_Glyph* aglyph )
- {
- FT_Memory memory = library->memory;
- FT_Error error;
- FT_Glyph glyph = NULL;
-
-
- *aglyph = NULL;
-
- if ( !FT_ALLOC( glyph, clazz->glyph_size ) )
- {
- glyph->library = library;
- glyph->clazz = clazz;
- glyph->format = clazz->glyph_format;
-
- *aglyph = glyph;
- }
-
- return error;
- }
-
-
- /* documentation is in ftglyph.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Glyph_Copy( FT_Glyph source,
- FT_Glyph *target )
- {
- FT_Glyph copy;
- FT_Error error;
- const FT_Glyph_Class* clazz;
-
-
- /* check arguments */
- if ( !target || !source || !source->clazz )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- *target = NULL;
-
- if ( !source || !source->clazz )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- clazz = source->clazz;
- error = ft_new_glyph( source->library, clazz, &copy );
- if ( error )
- goto Exit;
-
- copy->advance = source->advance;
- copy->format = source->format;
-
- if ( clazz->glyph_copy )
- error = clazz->glyph_copy( source, copy );
-
- if ( error )
- FT_Done_Glyph( copy );
- else
- *target = copy;
-
- Exit:
- return error;
- }
-
-
- /* documentation is in ftglyph.h */
-
- FT_EXPORT( FT_Error )
- FT_New_Glyph( FT_Library library,
- FT_Glyph_Format format,
- FT_Glyph *aglyph )
- {
- const FT_Glyph_Class* clazz = NULL;
-
- if ( !library || !aglyph )
- return FT_THROW( Invalid_Argument );
-
- /* if it is a bitmap, that's easy :-) */
- if ( format == FT_GLYPH_FORMAT_BITMAP )
- clazz = &ft_bitmap_glyph_class;
-
- /* if it is an outline */
- else if ( format == FT_GLYPH_FORMAT_OUTLINE )
- clazz = &ft_outline_glyph_class;
-
-#ifdef FT_CONFIG_OPTION_SVG
- /* if it is an SVG glyph */
- else if ( format == FT_GLYPH_FORMAT_SVG )
- clazz = &ft_svg_glyph_class;
-#endif
-
- else
- {
- /* try to find a renderer that supports the glyph image format */
- FT_Renderer render = FT_Lookup_Renderer( library, format, 0 );
-
-
- if ( render )
- clazz = &render->glyph_class;
- }
-
- if ( !clazz )
- return FT_THROW( Invalid_Glyph_Format );
-
- /* create FT_Glyph object */
- return ft_new_glyph( library, clazz, aglyph );
- }
-
-
- /* documentation is in ftglyph.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Get_Glyph( FT_GlyphSlot slot,
- FT_Glyph *aglyph )
- {
- FT_Error error;
- FT_Glyph glyph;
-
-
- if ( !slot )
- return FT_THROW( Invalid_Slot_Handle );
-
- if ( !aglyph )
- return FT_THROW( Invalid_Argument );
-
- /* create FT_Glyph object */
- error = FT_New_Glyph( slot->library, slot->format, &glyph );
- if ( error )
- goto Exit;
-
- /* copy advance while converting 26.6 to 16.16 format */
- if ( slot->advance.x >= 0x8000L * 64 ||
- slot->advance.x <= -0x8000L * 64 )
- {
- FT_ERROR(( "FT_Get_Glyph: advance width too large\n" ));
- error = FT_THROW( Invalid_Argument );
- goto Exit2;
- }
- if ( slot->advance.y >= 0x8000L * 64 ||
- slot->advance.y <= -0x8000L * 64 )
- {
- FT_ERROR(( "FT_Get_Glyph: advance height too large\n" ));
- error = FT_THROW( Invalid_Argument );
- goto Exit2;
- }
-
- glyph->advance.x = slot->advance.x * 1024;
- glyph->advance.y = slot->advance.y * 1024;
-
- /* now import the image from the glyph slot */
- error = glyph->clazz->glyph_init( glyph, slot );
-
- Exit2:
- /* if an error occurred, destroy the glyph */
- if ( error )
- {
- FT_Done_Glyph( glyph );
- *aglyph = NULL;
- }
- else
- *aglyph = glyph;
-
- Exit:
- return error;
- }
-
-
- /* documentation is in ftglyph.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Glyph_Transform( FT_Glyph glyph,
- const FT_Matrix* matrix,
- const FT_Vector* delta )
- {
- FT_Error error = FT_Err_Ok;
-
-
- if ( !glyph || !glyph->clazz )
- error = FT_THROW( Invalid_Argument );
- else
- {
- const FT_Glyph_Class* clazz = glyph->clazz;
-
-
- if ( clazz->glyph_transform )
- {
- /* transform glyph image */
- clazz->glyph_transform( glyph, matrix, delta );
-
- /* transform advance vector */
- if ( matrix )
- FT_Vector_Transform( &glyph->advance, matrix );
- }
- else
- error = FT_THROW( Invalid_Glyph_Format );
- }
- return error;
- }
-
-
- /* documentation is in ftglyph.h */
-
- FT_EXPORT_DEF( void )
- FT_Glyph_Get_CBox( FT_Glyph glyph,
- FT_UInt bbox_mode,
- FT_BBox *acbox )
- {
- const FT_Glyph_Class* clazz;
-
-
- if ( !acbox )
- return;
-
- acbox->xMin = acbox->yMin = acbox->xMax = acbox->yMax = 0;
-
- if ( !glyph || !glyph->clazz )
- return;
-
- clazz = glyph->clazz;
- if ( !clazz->glyph_bbox )
- return;
-
- /* retrieve bbox in 26.6 coordinates */
- clazz->glyph_bbox( glyph, acbox );
-
- /* perform grid fitting if needed */
- if ( bbox_mode == FT_GLYPH_BBOX_GRIDFIT ||
- bbox_mode == FT_GLYPH_BBOX_PIXELS )
- {
- acbox->xMin = FT_PIX_FLOOR( acbox->xMin );
- acbox->yMin = FT_PIX_FLOOR( acbox->yMin );
- acbox->xMax = FT_PIX_CEIL_LONG( acbox->xMax );
- acbox->yMax = FT_PIX_CEIL_LONG( acbox->yMax );
- }
-
- /* convert to integer pixels if needed */
- if ( bbox_mode == FT_GLYPH_BBOX_TRUNCATE ||
- bbox_mode == FT_GLYPH_BBOX_PIXELS )
- {
- acbox->xMin >>= 6;
- acbox->yMin >>= 6;
- acbox->xMax >>= 6;
- acbox->yMax >>= 6;
- }
- }
-
-
- /* documentation is in ftglyph.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Glyph_To_Bitmap( FT_Glyph* the_glyph,
- FT_Render_Mode render_mode,
- const FT_Vector* origin,
- FT_Bool destroy )
- {
- FT_GlyphSlotRec dummy;
- FT_GlyphSlot_InternalRec dummy_internal;
- FT_Error error = FT_Err_Ok;
- FT_Glyph b, glyph;
- FT_BitmapGlyph bitmap = NULL;
- const FT_Glyph_Class* clazz;
-
- FT_Library library;
-
-
- /* check argument */
- if ( !the_glyph )
- goto Bad;
- glyph = *the_glyph;
- if ( !glyph )
- goto Bad;
-
- clazz = glyph->clazz;
- library = glyph->library;
- if ( !library || !clazz )
- goto Bad;
-
- /* when called with a bitmap glyph, do nothing and return successfully */
- if ( clazz == &ft_bitmap_glyph_class )
- goto Exit;
-
- if ( !clazz->glyph_prepare )
- goto Bad;
-
- /* we render the glyph into a glyph bitmap using a `dummy' glyph slot */
- /* then calling FT_Render_Glyph_Internal() */
-
- FT_ZERO( &dummy );
- FT_ZERO( &dummy_internal );
- dummy.internal = &dummy_internal;
- dummy.library = library;
- dummy.format = clazz->glyph_format;
-
- /* create result bitmap glyph */
- error = ft_new_glyph( library, &ft_bitmap_glyph_class, &b );
- if ( error )
- goto Exit;
- bitmap = (FT_BitmapGlyph)b;
-
-#if 1
- /* if `origin' is set, translate the glyph image */
- if ( origin )
- FT_Glyph_Transform( glyph, NULL, origin );
-#else
- FT_UNUSED( origin );
-#endif
-
- /* prepare dummy slot for rendering */
- error = clazz->glyph_prepare( glyph, &dummy );
- if ( !error )
- error = FT_Render_Glyph_Internal( glyph->library, &dummy, render_mode );
-
-#ifdef FT_CONFIG_OPTION_SVG
- if ( clazz == &ft_svg_glyph_class )
- {
- FT_Memory memory = library->memory;
-
-
- FT_FREE( dummy.other );
- }
-#endif
-
-#if 1
- if ( !destroy && origin )
- {
- FT_Vector v;
-
-
- v.x = -origin->x;
- v.y = -origin->y;
- FT_Glyph_Transform( glyph, NULL, &v );
- }
-#endif
-
- if ( error )
- goto Exit;
-
- /* in case of success, copy the bitmap to the glyph bitmap */
- error = ft_bitmap_glyph_init( (FT_Glyph)bitmap, &dummy );
- if ( error )
- goto Exit;
-
- /* copy advance */
- bitmap->root.advance = glyph->advance;
-
- if ( destroy )
- FT_Done_Glyph( glyph );
-
- *the_glyph = FT_GLYPH( bitmap );
-
- Exit:
- if ( error && bitmap )
- FT_Done_Glyph( FT_GLYPH( bitmap ) );
-
- return error;
-
- Bad:
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
-
- /* documentation is in ftglyph.h */
-
- FT_EXPORT_DEF( void )
- FT_Done_Glyph( FT_Glyph glyph )
- {
- if ( glyph )
- {
- FT_Memory memory = glyph->library->memory;
- const FT_Glyph_Class* clazz = glyph->clazz;
-
-
- if ( clazz->glyph_done )
- clazz->glyph_done( glyph );
-
- FT_FREE( glyph );
- }
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/base/ftgxval.c b/contrib/libs/freetype/src/base/ftgxval.c
deleted file mode 100644
index 6e38cb5ba9..0000000000
--- a/contrib/libs/freetype/src/base/ftgxval.c
+++ /dev/null
@@ -1,141 +0,0 @@
-/****************************************************************************
- *
- * ftgxval.c
- *
- * FreeType API for validating TrueTypeGX/AAT tables (body).
- *
- * Copyright (C) 2004-2024 by
- * Masatake YAMATO, Redhat K.K,
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-/****************************************************************************
- *
- * gxvalid is derived from both gxlayout module and otvalid module.
- * Development of gxlayout is supported by the Information-technology
- * Promotion Agency(IPA), Japan.
- *
- */
-
-
-#include <freetype/internal/ftdebug.h>
-
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/services/svgxval.h>
-
-
- /* documentation is in ftgxval.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_TrueTypeGX_Validate( FT_Face face,
- FT_UInt validation_flags,
- FT_Bytes tables[FT_VALIDATE_GX_LENGTH],
- FT_UInt table_length )
- {
- FT_Service_GXvalidate service;
- FT_Error error;
-
-
- if ( !face )
- {
- error = FT_THROW( Invalid_Face_Handle );
- goto Exit;
- }
-
- if ( !tables )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- FT_FACE_FIND_GLOBAL_SERVICE( face, service, GX_VALIDATE );
-
- if ( service )
- error = service->validate( face,
- validation_flags,
- tables,
- table_length );
- else
- error = FT_THROW( Unimplemented_Feature );
-
- Exit:
- return error;
- }
-
-
- FT_EXPORT_DEF( void )
- FT_TrueTypeGX_Free( FT_Face face,
- FT_Bytes table )
- {
- FT_Memory memory;
-
-
- if ( !face )
- return;
-
- memory = FT_FACE_MEMORY( face );
-
- FT_FREE( table );
- }
-
-
- FT_EXPORT_DEF( FT_Error )
- FT_ClassicKern_Validate( FT_Face face,
- FT_UInt validation_flags,
- FT_Bytes *ckern_table )
- {
- FT_Service_CKERNvalidate service;
- FT_Error error;
-
-
- if ( !face )
- {
- error = FT_THROW( Invalid_Face_Handle );
- goto Exit;
- }
-
- if ( !ckern_table )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- FT_FACE_FIND_GLOBAL_SERVICE( face, service, CLASSICKERN_VALIDATE );
-
- if ( service )
- error = service->validate( face,
- validation_flags,
- ckern_table );
- else
- error = FT_THROW( Unimplemented_Feature );
-
- Exit:
- return error;
- }
-
-
- FT_EXPORT_DEF( void )
- FT_ClassicKern_Free( FT_Face face,
- FT_Bytes table )
- {
- FT_Memory memory;
-
-
- if ( !face )
- return;
-
- memory = FT_FACE_MEMORY( face );
-
-
- FT_FREE( table );
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/base/fthash.c b/contrib/libs/freetype/src/base/fthash.c
deleted file mode 100644
index 313bbbb4b2..0000000000
--- a/contrib/libs/freetype/src/base/fthash.c
+++ /dev/null
@@ -1,338 +0,0 @@
-/****************************************************************************
- *
- * fthash.c
- *
- * Hashing functions (body).
- *
- */
-
-/*
- * Copyright 2000 Computing Research Labs, New Mexico State University
- * Copyright 2001-2015
- * Francesco Zappa Nardelli
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COMPUTING RESEARCH LAB OR NEW MEXICO STATE UNIVERSITY BE LIABLE FOR ANY
- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
- * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
- * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
- /**************************************************************************
- *
- * This file is based on code from bdf.c,v 1.22 2000/03/16 20:08:50
- *
- * taken from Mark Leisher's xmbdfed package
- *
- */
-
-
-#include <freetype/internal/fthash.h>
-#include <freetype/internal/ftmemory.h>
-
-
-#define INITIAL_HT_SIZE 241
-
-
- static FT_ULong
- hash_str_lookup( FT_Hashkey* key )
- {
- const char* kp = key->str;
- FT_ULong res = 0;
-
-
- /* Mocklisp hash function. */
- while ( *kp )
- res = ( res << 5 ) - res + (FT_ULong)*kp++;
-
- return res;
- }
-
-
- static FT_ULong
- hash_num_lookup( FT_Hashkey* key )
- {
- FT_ULong num = (FT_ULong)key->num;
- FT_ULong res;
-
-
- /* Mocklisp hash function. */
- res = num & 0xFF;
- res = ( res << 5 ) - res + ( ( num >> 8 ) & 0xFF );
- res = ( res << 5 ) - res + ( ( num >> 16 ) & 0xFF );
- res = ( res << 5 ) - res + ( ( num >> 24 ) & 0xFF );
-
- return res;
- }
-
-
- static FT_Bool
- hash_str_compare( FT_Hashkey* a,
- FT_Hashkey* b )
- {
- if ( a->str[0] == b->str[0] &&
- ft_strcmp( a->str, b->str ) == 0 )
- return 1;
-
- return 0;
- }
-
-
- static FT_Bool
- hash_num_compare( FT_Hashkey* a,
- FT_Hashkey* b )
- {
- if ( a->num == b->num )
- return 1;
-
- return 0;
- }
-
-
- static FT_Hashnode*
- hash_bucket( FT_Hashkey key,
- FT_Hash hash )
- {
- FT_ULong res = 0;
- FT_Hashnode* bp = hash->table;
- FT_Hashnode* ndp;
-
-
- res = (hash->lookup)( &key );
-
- ndp = bp + ( res % hash->size );
- while ( *ndp )
- {
- if ( (hash->compare)( &(*ndp)->key, &key ) )
- break;
-
- ndp--;
- if ( ndp < bp )
- ndp = bp + ( hash->size - 1 );
- }
-
- return ndp;
- }
-
-
- static FT_Error
- hash_rehash( FT_Hash hash,
- FT_Memory memory )
- {
- FT_Hashnode* obp = hash->table;
- FT_Hashnode* bp;
- FT_Hashnode* nbp;
-
- FT_UInt i, sz = hash->size;
- FT_Error error = FT_Err_Ok;
-
-
- hash->size <<= 1;
- hash->limit = hash->size / 3;
-
- if ( FT_NEW_ARRAY( hash->table, hash->size ) )
- goto Exit;
-
- for ( i = 0, bp = obp; i < sz; i++, bp++ )
- {
- if ( *bp )
- {
- nbp = hash_bucket( (*bp)->key, hash );
- *nbp = *bp;
- }
- }
-
- FT_FREE( obp );
-
- Exit:
- return error;
- }
-
-
- static FT_Error
- hash_init( FT_Hash hash,
- FT_Bool is_num,
- FT_Memory memory )
- {
- FT_UInt sz = INITIAL_HT_SIZE;
- FT_Error error;
-
-
- hash->size = sz;
- hash->limit = sz / 3;
- hash->used = 0;
-
- if ( is_num )
- {
- hash->lookup = hash_num_lookup;
- hash->compare = hash_num_compare;
- }
- else
- {
- hash->lookup = hash_str_lookup;
- hash->compare = hash_str_compare;
- }
-
- FT_MEM_NEW_ARRAY( hash->table, sz );
-
- return error;
- }
-
-
- FT_Error
- ft_hash_str_init( FT_Hash hash,
- FT_Memory memory )
- {
- return hash_init( hash, 0, memory );
- }
-
-
- FT_Error
- ft_hash_num_init( FT_Hash hash,
- FT_Memory memory )
- {
- return hash_init( hash, 1, memory );
- }
-
-
- void
- ft_hash_str_free( FT_Hash hash,
- FT_Memory memory )
- {
- if ( hash )
- {
- FT_UInt sz = hash->size;
- FT_Hashnode* bp = hash->table;
- FT_UInt i;
-
-
- for ( i = 0; i < sz; i++, bp++ )
- FT_FREE( *bp );
-
- FT_FREE( hash->table );
- }
- }
-
-
- /* `ft_hash_num_free' is the same as `ft_hash_str_free' */
-
-
- static FT_Error
- hash_insert( FT_Hashkey key,
- size_t data,
- FT_Hash hash,
- FT_Memory memory )
- {
- FT_Hashnode nn;
- FT_Hashnode* bp = hash_bucket( key, hash );
- FT_Error error = FT_Err_Ok;
-
-
- nn = *bp;
- if ( !nn )
- {
- if ( FT_QNEW( nn ) )
- goto Exit;
- *bp = nn;
-
- nn->key = key;
- nn->data = data;
-
- if ( hash->used >= hash->limit )
- {
- error = hash_rehash( hash, memory );
- if ( error )
- goto Exit;
- }
-
- hash->used++;
- }
- else
- nn->data = data;
-
- Exit:
- return error;
- }
-
-
- FT_Error
- ft_hash_str_insert( const char* key,
- size_t data,
- FT_Hash hash,
- FT_Memory memory )
- {
- FT_Hashkey hk;
-
-
- hk.str = key;
-
- return hash_insert( hk, data, hash, memory );
- }
-
-
- FT_Error
- ft_hash_num_insert( FT_Int num,
- size_t data,
- FT_Hash hash,
- FT_Memory memory )
- {
- FT_Hashkey hk;
-
-
- hk.num = num;
-
- return hash_insert( hk, data, hash, memory );
- }
-
-
- static size_t*
- hash_lookup( FT_Hashkey key,
- FT_Hash hash )
- {
- FT_Hashnode* np = hash_bucket( key, hash );
-
-
- return (*np) ? &(*np)->data
- : NULL;
- }
-
-
- size_t*
- ft_hash_str_lookup( const char* key,
- FT_Hash hash )
- {
- FT_Hashkey hk;
-
-
- hk.str = key;
-
- return hash_lookup( hk, hash );
- }
-
-
- size_t*
- ft_hash_num_lookup( FT_Int num,
- FT_Hash hash )
- {
- FT_Hashkey hk;
-
-
- hk.num = num;
-
- return hash_lookup( hk, hash );
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/base/ftinit.c b/contrib/libs/freetype/src/base/ftinit.c
deleted file mode 100644
index 9a6c00e13e..0000000000
--- a/contrib/libs/freetype/src/base/ftinit.c
+++ /dev/null
@@ -1,263 +0,0 @@
-/****************************************************************************
- *
- * ftinit.c
- *
- * FreeType initialization layer (body).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
- /**************************************************************************
- *
- * The purpose of this file is to implement the following two
- * functions:
- *
- * FT_Add_Default_Modules():
- * This function is used to add the set of default modules to a
- * fresh new library object. The set is taken from the header file
- * `freetype/config/ftmodule.h'. See the document `FreeType 2.0
- * Build System' for more information.
- *
- * FT_Init_FreeType():
- * This function creates a system object for the current platform,
- * builds a library out of it, then calls FT_Default_Drivers().
- *
- * Note that even if FT_Init_FreeType() uses the implementation of the
- * system object defined at build time, client applications are still
- * able to provide their own `ftsystem.c'.
- *
- */
-
-
-#include <ft2build.h>
-#include FT_CONFIG_CONFIG_H
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/ftdebug.h>
-#include <freetype/ftmodapi.h>
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT init
-
-
-#undef FT_USE_MODULE
-#ifdef __cplusplus
-#define FT_USE_MODULE( type, x ) extern "C" const type x;
-#else
-#define FT_USE_MODULE( type, x ) extern const type x;
-#endif
-
-#include FT_CONFIG_MODULES_H
-
-#undef FT_USE_MODULE
-#define FT_USE_MODULE( type, x ) (const FT_Module_Class*)&(x),
-
- static
- const FT_Module_Class* const ft_default_modules[] =
- {
-#include FT_CONFIG_MODULES_H
- 0
- };
-
-
- /* documentation is in ftmodapi.h */
-
- FT_EXPORT_DEF( void )
- FT_Add_Default_Modules( FT_Library library )
- {
- FT_Error error;
- const FT_Module_Class* const* cur;
-
-
- /* GCC 4.6 warns the type difference:
- * FT_Module_Class** != const FT_Module_Class* const*
- */
- cur = (const FT_Module_Class* const*)ft_default_modules;
-
- /* test for valid `library' delayed to FT_Add_Module() */
- while ( *cur )
- {
- error = FT_Add_Module( library, *cur );
- /* notify errors, but don't stop */
- if ( error )
- FT_TRACE0(( "FT_Add_Default_Module:"
- " Cannot install `%s', error = 0x%x\n",
- (*cur)->module_name, error ));
- cur++;
- }
- }
-
-
-#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
-
-#define MAX_LENGTH 128
-
- /* documentation is in ftmodapi.h */
-
- FT_EXPORT_DEF( void )
- FT_Set_Default_Properties( FT_Library library )
- {
- const char* env;
- const char* p;
- const char* q;
-
- char module_name[MAX_LENGTH + 1];
- char property_name[MAX_LENGTH + 1];
- char property_value[MAX_LENGTH + 1];
-
- int i;
-
-
- env = ft_getenv( "FREETYPE_PROPERTIES" );
- if ( !env )
- return;
-
- for ( p = env; *p; p++ )
- {
- /* skip leading whitespace and separators */
- if ( *p == ' ' || *p == '\t' )
- continue;
-
- /* read module name, followed by `:' */
- q = p;
- for ( i = 0; i < MAX_LENGTH; i++ )
- {
- if ( !*p || *p == ':' )
- break;
- module_name[i] = *p++;
- }
- module_name[i] = '\0';
-
- if ( !*p || *p != ':' || p == q )
- break;
-
- /* read property name, followed by `=' */
- q = ++p;
- for ( i = 0; i < MAX_LENGTH; i++ )
- {
- if ( !*p || *p == '=' )
- break;
- property_name[i] = *p++;
- }
- property_name[i] = '\0';
-
- if ( !*p || *p != '=' || p == q )
- break;
-
- /* read property value, followed by whitespace (if any) */
- q = ++p;
- for ( i = 0; i < MAX_LENGTH; i++ )
- {
- if ( !*p || *p == ' ' || *p == '\t' )
- break;
- property_value[i] = *p++;
- }
- property_value[i] = '\0';
-
- if ( !( *p == '\0' || *p == ' ' || *p == '\t' ) || p == q )
- break;
-
- /* we completely ignore errors */
- ft_property_string_set( library,
- module_name,
- property_name,
- property_value );
-
- if ( !*p )
- break;
- }
- }
-
-#else
-
- FT_EXPORT_DEF( void )
- FT_Set_Default_Properties( FT_Library library )
- {
- FT_UNUSED( library );
- }
-
-#endif
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Init_FreeType( FT_Library *alibrary )
- {
- FT_Error error;
- FT_Memory memory;
-
-
-#ifdef FT_DEBUG_LOGGING
- ft_logging_init();
-#endif
-
- /* check of `alibrary' delayed to `FT_New_Library' */
-
- /* First of all, allocate a new system object -- this function is part */
- /* of the system-specific component, i.e. `ftsystem.c'. */
-
- memory = FT_New_Memory();
- if ( !memory )
- {
- FT_ERROR(( "FT_Init_FreeType: cannot find memory manager\n" ));
- return FT_THROW( Unimplemented_Feature );
- }
-
- /* build a library out of it, then fill it with the set of */
- /* default drivers. */
-
- error = FT_New_Library( memory, alibrary );
- if ( error )
- FT_Done_Memory( memory );
- else
- FT_Add_Default_Modules( *alibrary );
-
- FT_Set_Default_Properties( *alibrary );
-
- return error;
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Done_FreeType( FT_Library library )
- {
- FT_Memory memory;
-
-
- if ( !library )
- return FT_THROW( Invalid_Library_Handle );
-
- memory = library->memory;
-
- /* Discard the library object */
- FT_Done_Library( library );
-
- /* discard memory manager */
- FT_Done_Memory( memory );
-
-#ifdef FT_DEBUG_LOGGING
- ft_logging_deinit();
-#endif
-
- return FT_Err_Ok;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/base/ftlcdfil.c b/contrib/libs/freetype/src/base/ftlcdfil.c
deleted file mode 100644
index 1e69d4da70..0000000000
--- a/contrib/libs/freetype/src/base/ftlcdfil.c
+++ /dev/null
@@ -1,437 +0,0 @@
-/****************************************************************************
- *
- * ftlcdfil.c
- *
- * FreeType API for color filtering of subpixel bitmap glyphs (body).
- *
- * Copyright (C) 2006-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftdebug.h>
-
-#include <freetype/ftlcdfil.h>
-#include <freetype/ftimage.h>
-#include <freetype/internal/ftobjs.h>
-
-
-#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
-
-/* define USE_LEGACY to implement the legacy filter */
-#define USE_LEGACY
-
-#define FT_SHIFTCLAMP( x ) ( x >>= 8, (FT_Byte)( x > 255 ? 255 : x ) )
-
-
- /* add padding according to filter weights */
- FT_BASE_DEF( void )
- ft_lcd_padding( FT_BBox* cbox,
- FT_GlyphSlot slot,
- FT_Render_Mode mode )
- {
- FT_Byte* lcd_weights;
- FT_Bitmap_LcdFilterFunc lcd_filter_func;
-
-
- /* Per-face LCD filtering takes priority if set up. */
- if ( slot->face && slot->face->internal->lcd_filter_func )
- {
- lcd_weights = slot->face->internal->lcd_weights;
- lcd_filter_func = slot->face->internal->lcd_filter_func;
- }
- else
- {
- lcd_weights = slot->library->lcd_weights;
- lcd_filter_func = slot->library->lcd_filter_func;
- }
-
- if ( lcd_filter_func == ft_lcd_filter_fir )
- {
- if ( mode == FT_RENDER_MODE_LCD )
- {
- cbox->xMin -= lcd_weights[0] ? 43 :
- lcd_weights[1] ? 22 : 0;
- cbox->xMax += lcd_weights[4] ? 43 :
- lcd_weights[3] ? 22 : 0;
- }
- else if ( mode == FT_RENDER_MODE_LCD_V )
- {
- cbox->yMin -= lcd_weights[0] ? 43 :
- lcd_weights[1] ? 22 : 0;
- cbox->yMax += lcd_weights[4] ? 43 :
- lcd_weights[3] ? 22 : 0;
- }
- }
- }
-
-
- /* FIR filter used by the default and light filters */
- FT_BASE_DEF( void )
- ft_lcd_filter_fir( FT_Bitmap* bitmap,
- FT_LcdFiveTapFilter weights )
- {
- FT_UInt width = (FT_UInt)bitmap->width;
- FT_UInt height = (FT_UInt)bitmap->rows;
- FT_Int pitch = bitmap->pitch;
- FT_Byte* origin = bitmap->buffer;
- FT_Byte mode = bitmap->pixel_mode;
-
-
- /* take care of bitmap flow */
- if ( pitch > 0 && height > 0 )
- origin += pitch * (FT_Int)( height - 1 );
-
- /* horizontal in-place FIR filter */
- if ( mode == FT_PIXEL_MODE_LCD && width >= 2 )
- {
- FT_Byte* line = origin;
-
-
- /* `fir' must be at least 32 bit wide, since the sum of */
- /* the values in `weights' can exceed 0xFF */
-
- for ( ; height > 0; height--, line -= pitch )
- {
- FT_UInt fir[5];
- FT_UInt val, xx;
-
-
- val = line[0];
- fir[2] = weights[2] * val;
- fir[3] = weights[3] * val;
- fir[4] = weights[4] * val;
-
- val = line[1];
- fir[1] = fir[2] + weights[1] * val;
- fir[2] = fir[3] + weights[2] * val;
- fir[3] = fir[4] + weights[3] * val;
- fir[4] = weights[4] * val;
-
- for ( xx = 2; xx < width; xx++ )
- {
- val = line[xx];
- fir[0] = fir[1] + weights[0] * val;
- fir[1] = fir[2] + weights[1] * val;
- fir[2] = fir[3] + weights[2] * val;
- fir[3] = fir[4] + weights[3] * val;
- fir[4] = weights[4] * val;
-
- line[xx - 2] = FT_SHIFTCLAMP( fir[0] );
- }
-
- line[xx - 2] = FT_SHIFTCLAMP( fir[1] );
- line[xx - 1] = FT_SHIFTCLAMP( fir[2] );
- }
- }
-
- /* vertical in-place FIR filter */
- else if ( mode == FT_PIXEL_MODE_LCD_V && height >= 2 )
- {
- FT_Byte* column = origin;
-
-
- for ( ; width > 0; width--, column++ )
- {
- FT_Byte* col = column;
- FT_UInt fir[5];
- FT_UInt val, yy;
-
-
- val = col[0];
- fir[2] = weights[2] * val;
- fir[3] = weights[3] * val;
- fir[4] = weights[4] * val;
- col -= pitch;
-
- val = col[0];
- fir[1] = fir[2] + weights[1] * val;
- fir[2] = fir[3] + weights[2] * val;
- fir[3] = fir[4] + weights[3] * val;
- fir[4] = weights[4] * val;
- col -= pitch;
-
- for ( yy = 2; yy < height; yy++, col -= pitch )
- {
- val = col[0];
- fir[0] = fir[1] + weights[0] * val;
- fir[1] = fir[2] + weights[1] * val;
- fir[2] = fir[3] + weights[2] * val;
- fir[3] = fir[4] + weights[3] * val;
- fir[4] = weights[4] * val;
-
- col[pitch * 2] = FT_SHIFTCLAMP( fir[0] );
- }
-
- col[pitch * 2] = FT_SHIFTCLAMP( fir[1] );
- col[pitch] = FT_SHIFTCLAMP( fir[2] );
- }
- }
- }
-
-
-#ifdef USE_LEGACY
-
- /* intra-pixel filter used by the legacy filter */
- static void
- _ft_lcd_filter_legacy( FT_Bitmap* bitmap,
- FT_Byte* weights )
- {
- FT_UInt width = (FT_UInt)bitmap->width;
- FT_UInt height = (FT_UInt)bitmap->rows;
- FT_Int pitch = bitmap->pitch;
- FT_Byte* origin = bitmap->buffer;
- FT_Byte mode = bitmap->pixel_mode;
-
- static const unsigned int filters[3][3] =
- {
- { 65538 * 9/13, 65538 * 1/6, 65538 * 1/13 },
- { 65538 * 3/13, 65538 * 4/6, 65538 * 3/13 },
- { 65538 * 1/13, 65538 * 1/6, 65538 * 9/13 }
- };
-
- FT_UNUSED( weights );
-
-
- /* take care of bitmap flow */
- if ( pitch > 0 && height > 0 )
- origin += pitch * (FT_Int)( height - 1 );
-
- /* horizontal in-place intra-pixel filter */
- if ( mode == FT_PIXEL_MODE_LCD && width >= 3 )
- {
- FT_Byte* line = origin;
-
-
- for ( ; height > 0; height--, line -= pitch )
- {
- FT_UInt xx;
-
-
- for ( xx = 0; xx < width; xx += 3 )
- {
- FT_UInt r, g, b;
- FT_UInt p;
-
-
- p = line[xx];
- r = filters[0][0] * p;
- g = filters[0][1] * p;
- b = filters[0][2] * p;
-
- p = line[xx + 1];
- r += filters[1][0] * p;
- g += filters[1][1] * p;
- b += filters[1][2] * p;
-
- p = line[xx + 2];
- r += filters[2][0] * p;
- g += filters[2][1] * p;
- b += filters[2][2] * p;
-
- line[xx] = (FT_Byte)( r / 65536 );
- line[xx + 1] = (FT_Byte)( g / 65536 );
- line[xx + 2] = (FT_Byte)( b / 65536 );
- }
- }
- }
- else if ( mode == FT_PIXEL_MODE_LCD_V && height >= 3 )
- {
- FT_Byte* column = origin;
-
-
- for ( ; width > 0; width--, column++ )
- {
- FT_Byte* col = column - 2 * pitch;
-
-
- for ( ; height > 0; height -= 3, col -= 3 * pitch )
- {
- FT_UInt r, g, b;
- FT_UInt p;
-
-
- p = col[0];
- r = filters[0][0] * p;
- g = filters[0][1] * p;
- b = filters[0][2] * p;
-
- p = col[pitch];
- r += filters[1][0] * p;
- g += filters[1][1] * p;
- b += filters[1][2] * p;
-
- p = col[pitch * 2];
- r += filters[2][0] * p;
- g += filters[2][1] * p;
- b += filters[2][2] * p;
-
- col[0] = (FT_Byte)( r / 65536 );
- col[pitch] = (FT_Byte)( g / 65536 );
- col[pitch * 2] = (FT_Byte)( b / 65536 );
- }
- }
- }
- }
-
-#endif /* USE_LEGACY */
-
-
- /* documentation in ftlcdfil.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Library_SetLcdFilterWeights( FT_Library library,
- unsigned char *weights )
- {
- if ( !library )
- return FT_THROW( Invalid_Library_Handle );
-
- if ( !weights )
- return FT_THROW( Invalid_Argument );
-
- ft_memcpy( library->lcd_weights, weights, FT_LCD_FILTER_FIVE_TAPS );
- library->lcd_filter_func = ft_lcd_filter_fir;
-
- return FT_Err_Ok;
- }
-
-
- /* documentation in ftlcdfil.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Library_SetLcdFilter( FT_Library library,
- FT_LcdFilter filter )
- {
- static const FT_LcdFiveTapFilter default_weights =
- { 0x08, 0x4d, 0x56, 0x4d, 0x08 };
- static const FT_LcdFiveTapFilter light_weights =
- { 0x00, 0x55, 0x56, 0x55, 0x00 };
-
-
- if ( !library )
- return FT_THROW( Invalid_Library_Handle );
-
- switch ( filter )
- {
- case FT_LCD_FILTER_NONE:
- library->lcd_filter_func = NULL;
- break;
-
- case FT_LCD_FILTER_DEFAULT:
- ft_memcpy( library->lcd_weights,
- default_weights,
- FT_LCD_FILTER_FIVE_TAPS );
- library->lcd_filter_func = ft_lcd_filter_fir;
- break;
-
- case FT_LCD_FILTER_LIGHT:
- ft_memcpy( library->lcd_weights,
- light_weights,
- FT_LCD_FILTER_FIVE_TAPS );
- library->lcd_filter_func = ft_lcd_filter_fir;
- break;
-
-#ifdef USE_LEGACY
-
- case FT_LCD_FILTER_LEGACY:
- case FT_LCD_FILTER_LEGACY1:
- library->lcd_filter_func = _ft_lcd_filter_legacy;
- break;
-
-#endif
-
- default:
- return FT_THROW( Invalid_Argument );
- }
-
- return FT_Err_Ok;
- }
-
-
- FT_EXPORT_DEF( FT_Error )
- FT_Library_SetLcdGeometry( FT_Library library,
- FT_Vector sub[3] )
- {
- FT_UNUSED( library );
- FT_UNUSED( sub );
-
- return FT_THROW( Unimplemented_Feature );
- }
-
-#else /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
-
- /* add padding to accommodate outline shifts */
- FT_BASE_DEF( void )
- ft_lcd_padding( FT_BBox* cbox,
- FT_GlyphSlot slot,
- FT_Render_Mode mode )
- {
- FT_Vector* sub = slot->library->lcd_geometry;
-
- if ( mode == FT_RENDER_MODE_LCD )
- {
- cbox->xMin -= FT_MAX( FT_MAX( sub[0].x, sub[1].x ), sub[2].x );
- cbox->xMax -= FT_MIN( FT_MIN( sub[0].x, sub[1].x ), sub[2].x );
- cbox->yMin -= FT_MAX( FT_MAX( sub[0].y, sub[1].y ), sub[2].y );
- cbox->yMax -= FT_MIN( FT_MIN( sub[0].y, sub[1].y ), sub[2].y );
- }
- else if ( mode == FT_RENDER_MODE_LCD_V )
- {
- cbox->xMin -= FT_MAX( FT_MAX( sub[0].y, sub[1].y ), sub[2].y );
- cbox->xMax -= FT_MIN( FT_MIN( sub[0].y, sub[1].y ), sub[2].y );
- cbox->yMin += FT_MIN( FT_MIN( sub[0].x, sub[1].x ), sub[2].x );
- cbox->yMax += FT_MAX( FT_MAX( sub[0].x, sub[1].x ), sub[2].x );
- }
- }
-
-
- FT_EXPORT_DEF( FT_Error )
- FT_Library_SetLcdFilterWeights( FT_Library library,
- unsigned char *weights )
- {
- FT_UNUSED( library );
- FT_UNUSED( weights );
-
- return FT_THROW( Unimplemented_Feature );
- }
-
-
- FT_EXPORT_DEF( FT_Error )
- FT_Library_SetLcdFilter( FT_Library library,
- FT_LcdFilter filter )
- {
- FT_UNUSED( library );
- FT_UNUSED( filter );
-
- return FT_THROW( Unimplemented_Feature );
- }
-
-
- /* documentation in ftlcdfil.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Library_SetLcdGeometry( FT_Library library,
- FT_Vector sub[3] )
- {
- if ( !library )
- return FT_THROW( Invalid_Library_Handle );
-
- if ( !sub )
- return FT_THROW( Invalid_Argument );
-
- ft_memcpy( library->lcd_geometry, sub, 3 * sizeof( FT_Vector ) );
-
- return FT_Err_Ok;
- }
-
-#endif /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/base/ftmac.c b/contrib/libs/freetype/src/base/ftmac.c
deleted file mode 100644
index e8e35627b5..0000000000
--- a/contrib/libs/freetype/src/base/ftmac.c
+++ /dev/null
@@ -1,1099 +0,0 @@
-/****************************************************************************
- *
- * ftmac.c
- *
- * Mac FOND support. Written by just@letterror.com.
- * Heavily modified by mpsuzuki, George Williams, and Sean McBride.
- *
- * This file is for Mac OS X only; see builds/mac/ftoldmac.c for
- * classic platforms built by MPW.
- *
- * Copyright (C) 1996-2024 by
- * Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /*
- Notes
-
- Mac suitcase files can (and often do!) contain multiple fonts. To
- support this I use the face_index argument of FT_(Open|New)_Face()
- functions, and pretend the suitcase file is a collection.
-
- Warning: fbit and NFNT bitmap resources are not supported yet. In old
- sfnt fonts, bitmap glyph data for each size is stored in each `NFNT'
- resources instead of the `bdat' table in the sfnt resource. Therefore,
- face->num_fixed_sizes is set to 0, because bitmap data in `NFNT'
- resource is unavailable at present.
-
- The Mac FOND support works roughly like this:
-
- - Check whether the offered stream points to a Mac suitcase file. This
- is done by checking the file type: it has to be 'FFIL' or 'tfil'. The
- stream that gets passed to our init_face() routine is a stdio stream,
- which isn't usable for us, since the FOND resources live in the
- resource fork. So we just grab the stream->pathname field.
-
- - Read the FOND resource into memory, then check whether there is a
- TrueType font and/or(!) a Type 1 font available.
-
- - If there is a Type 1 font available (as a separate `LWFN' file), read
- its data into memory, massage it slightly so it becomes PFB data, wrap
- it into a memory stream, load the Type 1 driver and delegate the rest
- of the work to it by calling FT_Open_Face(). (XXX TODO: after this
- has been done, the kerning data from the FOND resource should be
- appended to the face: On the Mac there are usually no AFM files
- available. However, this is tricky since we need to map Mac char
- codes to ps glyph names to glyph ID's...)
-
- - If there is a TrueType font (an `sfnt' resource), read it into memory,
- wrap it into a memory stream, load the TrueType driver and delegate
- the rest of the work to it, by calling FT_Open_Face().
-
- - Some suitcase fonts (notably Onyx) might point the `LWFN' file to
- itself, even though it doesn't contains `POST' resources. To handle
- this special case without opening the file an extra time, we just
- ignore errors from the `LWFN' and fallback to the `sfnt' if both are
- available.
- */
-
-
-#include <freetype/freetype.h>
-#include <freetype/tttags.h>
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftstream.h>
-#include "ftbase.h"
-
-
-#ifdef FT_MACINTOSH
-
- /* This is for Mac OS X. Without redefinition, OS_INLINE */
- /* expands to `static inline' which doesn't survive the */
- /* -ansi compilation flag of GCC. */
-#if !HAVE_ANSI_OS_INLINE
-#undef OS_INLINE
-#define OS_INLINE static __inline__
-#endif
-
- /* `configure' checks the availability of `ResourceIndex' strictly */
- /* and sets HAVE_TYPE_RESOURCE_INDEX 1 or 0 always. If it is */
- /* not set (e.g., a build without `configure'), the availability */
- /* is guessed from the SDK version. */
-#ifndef HAVE_TYPE_RESOURCE_INDEX
-#if !defined( MAC_OS_X_VERSION_10_5 ) || \
- ( MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5 )
-#define HAVE_TYPE_RESOURCE_INDEX 0
-#else
-#define HAVE_TYPE_RESOURCE_INDEX 1
-#endif
-#endif /* !HAVE_TYPE_RESOURCE_INDEX */
-
-#if ( HAVE_TYPE_RESOURCE_INDEX == 0 )
- typedef short ResourceIndex;
-#endif
-
-#include <CoreServices/CoreServices.h>
-#include <ApplicationServices/ApplicationServices.h>
-#include <sys/syslimits.h> /* PATH_MAX */
-
- /* Don't want warnings about our own use of deprecated functions. */
-#define FT_DEPRECATED_ATTRIBUTE
-
-#include <freetype/ftmac.h>
-
-#ifndef kATSOptionFlagsUnRestrictedScope /* since Mac OS X 10.1 */
-#define kATSOptionFlagsUnRestrictedScope kATSOptionFlagsDefault
-#endif
-
-
- /* Set PREFER_LWFN to 1 if LWFN (Type 1) is preferred over
- TrueType in case *both* are available (this is not common,
- but it *is* possible). */
-#ifndef PREFER_LWFN
-#define PREFER_LWFN 1
-#endif
-
-
- /* This function is deprecated because FSSpec is deprecated in Mac OS X */
- FT_EXPORT_DEF( FT_Error )
- FT_GetFile_From_Mac_Name( const char* fontName,
- FSSpec* pathSpec,
- FT_Long* face_index )
- {
- FT_UNUSED( fontName );
- FT_UNUSED( pathSpec );
- FT_UNUSED( face_index );
-
- return FT_THROW( Unimplemented_Feature );
- }
-
-
- /* Private function. */
- /* The FSSpec type has been discouraged for a long time, */
- /* unfortunately an FSRef replacement API for */
- /* ATSFontGetFileSpecification() is only available in */
- /* Mac OS X 10.5 and later. */
- static OSStatus
- FT_ATSFontGetFileReference( ATSFontRef ats_font_id,
- FSRef* ats_font_ref )
- {
-#if defined( MAC_OS_X_VERSION_10_5 ) && \
- ( MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 )
-
- OSStatus err;
-
- err = ATSFontGetFileReference( ats_font_id, ats_font_ref );
-
- return err;
-#elif __LP64__ /* No 64bit Carbon API on legacy platforms */
- FT_UNUSED( ats_font_id );
- FT_UNUSED( ats_font_ref );
-
-
- return fnfErr;
-#else /* 32bit Carbon API on legacy platforms */
- OSStatus err;
- FSSpec spec;
-
-
- err = ATSFontGetFileSpecification( ats_font_id, &spec );
- if ( noErr == err )
- err = FSpMakeFSRef( &spec, ats_font_ref );
-
- return err;
-#endif
- }
-
-
- static FT_Error
- FT_GetFileRef_From_Mac_ATS_Name( const char* fontName,
- FSRef* ats_font_ref,
- FT_Long* face_index )
- {
- CFStringRef cf_fontName;
- ATSFontRef ats_font_id;
-
-
- *face_index = 0;
-
- cf_fontName = CFStringCreateWithCString( NULL, fontName,
- kCFStringEncodingMacRoman );
- ats_font_id = ATSFontFindFromName( cf_fontName,
- kATSOptionFlagsUnRestrictedScope );
- CFRelease( cf_fontName );
-
- if ( ats_font_id == 0 || ats_font_id == 0xFFFFFFFFUL )
- return FT_THROW( Unknown_File_Format );
-
- if ( noErr != FT_ATSFontGetFileReference( ats_font_id, ats_font_ref ) )
- return FT_THROW( Unknown_File_Format );
-
- /* face_index calculation by searching preceding fontIDs */
- /* with same FSRef */
- {
- ATSFontRef id2 = ats_font_id - 1;
- FSRef ref2;
-
-
- while ( id2 > 0 )
- {
- if ( noErr != FT_ATSFontGetFileReference( id2, &ref2 ) )
- break;
- if ( noErr != FSCompareFSRefs( ats_font_ref, &ref2 ) )
- break;
-
- id2 --;
- }
- *face_index = ats_font_id - ( id2 + 1 );
- }
-
- return FT_Err_Ok;
- }
-
-
- FT_EXPORT_DEF( FT_Error )
- FT_GetFilePath_From_Mac_ATS_Name( const char* fontName,
- UInt8* path,
- UInt32 maxPathSize,
- FT_Long* face_index )
- {
- FSRef ref;
- FT_Error err;
-
-
- if ( !fontName || !face_index )
- return FT_THROW( Invalid_Argument);
-
- err = FT_GetFileRef_From_Mac_ATS_Name( fontName, &ref, face_index );
- if ( err )
- return err;
-
- if ( noErr != FSRefMakePath( &ref, path, maxPathSize ) )
- return FT_THROW( Unknown_File_Format );
-
- return FT_Err_Ok;
- }
-
-
- /* This function is deprecated because FSSpec is deprecated in Mac OS X */
- FT_EXPORT_DEF( FT_Error )
- FT_GetFile_From_Mac_ATS_Name( const char* fontName,
- FSSpec* pathSpec,
- FT_Long* face_index )
- {
-#if ( __LP64__ ) || ( defined( MAC_OS_X_VERSION_10_5 ) && \
- ( MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 ) )
- FT_UNUSED( fontName );
- FT_UNUSED( pathSpec );
- FT_UNUSED( face_index );
-
- return FT_THROW( Unimplemented_Feature );
-#else
- FSRef ref;
- FT_Error err;
-
-
- if ( !fontName || !face_index )
- return FT_THROW( Invalid_Argument );
-
- err = FT_GetFileRef_From_Mac_ATS_Name( fontName, &ref, face_index );
- if ( err )
- return err;
-
- if ( noErr != FSGetCatalogInfo( &ref, kFSCatInfoNone, NULL, NULL,
- pathSpec, NULL ) )
- return FT_THROW( Unknown_File_Format );
-
- return FT_Err_Ok;
-#endif
- }
-
-
- static OSErr
- FT_FSPathMakeRes( const UInt8* pathname,
- ResFileRefNum* res )
- {
- OSErr err;
- FSRef ref;
-
-
- if ( noErr != FSPathMakeRef( pathname, &ref, FALSE ) )
- return FT_THROW( Cannot_Open_Resource );
-
- /* at present, no support for dfont format */
- err = FSOpenResourceFile( &ref, 0, NULL, fsRdPerm, res );
- if ( noErr == err )
- return err;
-
- /* fallback to original resource-fork font */
- *res = FSOpenResFile( &ref, fsRdPerm );
- err = ResError();
-
- return err;
- }
-
-
- /* Return the file type for given pathname */
- static OSType
- get_file_type_from_path( const UInt8* pathname )
- {
- FSRef ref;
- FSCatalogInfo info;
-
-
- if ( noErr != FSPathMakeRef( pathname, &ref, FALSE ) )
- return ( OSType ) 0;
-
- if ( noErr != FSGetCatalogInfo( &ref, kFSCatInfoFinderInfo, &info,
- NULL, NULL, NULL ) )
- return ( OSType ) 0;
-
- return ( (FInfo *)( info.finderInfo ) )->fdType;
- }
-
-
- /* Given a PostScript font name, create the Macintosh LWFN file name. */
- static void
- create_lwfn_name( char* ps_name,
- Str255 lwfn_file_name )
- {
- int max = 5, count = 0;
- FT_Byte* p = lwfn_file_name;
- FT_Byte* q = (FT_Byte*)ps_name;
-
-
- lwfn_file_name[0] = 0;
-
- while ( *q )
- {
- if ( ft_isupper( *q ) )
- {
- if ( count )
- max = 3;
- count = 0;
- }
- if ( count < max && ( ft_isalnum( *q ) || *q == '_' ) )
- {
- *++p = *q;
- lwfn_file_name[0]++;
- count++;
- }
- q++;
- }
- }
-
-
- static short
- count_faces_sfnt( char* fond_data )
- {
- /* The count is 1 greater than the value in the FOND. */
- /* Isn't that cute? :-) */
-
- return EndianS16_BtoN( *( (short*)( fond_data +
- sizeof ( FamRec ) ) ) ) + 1;
- }
-
-
- static short
- count_faces_scalable( char* fond_data )
- {
- AsscEntry* assoc;
- short i, face, face_all;
-
-
- face_all = EndianS16_BtoN( *( (short *)( fond_data +
- sizeof ( FamRec ) ) ) ) + 1;
- assoc = (AsscEntry*)( fond_data + sizeof ( FamRec ) + 2 );
- face = 0;
-
- for ( i = 0; i < face_all; i++ )
- {
- if ( 0 == EndianS16_BtoN( assoc[i].fontSize ) )
- face++;
- }
- return face;
- }
-
-
- /* Look inside the FOND data, answer whether there should be an SFNT
- resource, and answer the name of a possible LWFN Type 1 file.
-
- Thanks to Paul Miller (paulm@profoundeffects.com) for the fix
- to load a face OTHER than the first one in the FOND!
- */
-
-
- static void
- parse_fond( char* fond_data,
- short* have_sfnt,
- ResID* sfnt_id,
- Str255 lwfn_file_name,
- short face_index )
- {
- AsscEntry* assoc;
- AsscEntry* base_assoc;
- FamRec* fond;
-
-
- *sfnt_id = 0;
- *have_sfnt = 0;
- lwfn_file_name[0] = 0;
-
- fond = (FamRec*)fond_data;
- assoc = (AsscEntry*)( fond_data + sizeof ( FamRec ) + 2 );
- base_assoc = assoc;
-
- /* the maximum faces in a FOND is 48, size of StyleTable.indexes[] */
- if ( 47 < face_index )
- return;
-
- /* Let's do a little range checking before we get too excited here */
- if ( face_index < count_faces_sfnt( fond_data ) )
- {
- assoc += face_index; /* add on the face_index! */
-
- /* if the face at this index is not scalable,
- fall back to the first one (old behavior) */
- if ( EndianS16_BtoN( assoc->fontSize ) == 0 )
- {
- *have_sfnt = 1;
- *sfnt_id = EndianS16_BtoN( assoc->fontID );
- }
- else if ( base_assoc->fontSize == 0 )
- {
- *have_sfnt = 1;
- *sfnt_id = EndianS16_BtoN( base_assoc->fontID );
- }
- }
-
- if ( EndianS32_BtoN( fond->ffStylOff ) )
- {
- unsigned char* p = (unsigned char*)fond_data;
- StyleTable* style;
- unsigned short string_count;
- char ps_name[256];
- unsigned char* names[64];
- int i;
-
-
- p += EndianS32_BtoN( fond->ffStylOff );
- style = (StyleTable*)p;
- p += sizeof ( StyleTable );
- string_count = EndianS16_BtoN( *(short*)(p) );
- string_count = FT_MIN( 64, string_count );
- p += sizeof ( short );
-
- for ( i = 0; i < string_count; i++ )
- {
- names[i] = p;
- p += names[i][0];
- p++;
- }
-
- {
- size_t ps_name_len = (size_t)names[0][0];
-
-
- if ( ps_name_len != 0 )
- {
- ft_memcpy( ps_name, names[0] + 1, ps_name_len );
- ps_name[ps_name_len] = 0;
- }
- if ( style->indexes[face_index] > 1 &&
- style->indexes[face_index] <= string_count )
- {
- unsigned char* suffixes = names[style->indexes[face_index] - 1];
-
-
- for ( i = 1; i <= suffixes[0]; i++ )
- {
- unsigned char* s;
- size_t j = suffixes[i] - 1;
-
-
- if ( j < string_count && ( s = names[j] ) != NULL )
- {
- size_t s_len = (size_t)s[0];
-
-
- if ( s_len != 0 && ps_name_len + s_len < sizeof ( ps_name ) )
- {
- ft_memcpy( ps_name + ps_name_len, s + 1, s_len );
- ps_name_len += s_len;
- ps_name[ps_name_len] = 0;
- }
- }
- }
- }
- }
-
- create_lwfn_name( ps_name, lwfn_file_name );
- }
- }
-
-
- static FT_Error
- lookup_lwfn_by_fond( const UInt8* path_fond,
- ConstStr255Param base_lwfn,
- UInt8* path_lwfn,
- size_t path_size )
- {
- FSRef ref, par_ref;
- size_t dirname_len;
-
-
- /* Pathname for FSRef can be in various formats: HFS, HFS+, and POSIX. */
- /* We should not extract parent directory by string manipulation. */
-
- if ( noErr != FSPathMakeRef( path_fond, &ref, FALSE ) )
- return FT_THROW( Invalid_Argument );
-
- if ( noErr != FSGetCatalogInfo( &ref, kFSCatInfoNone,
- NULL, NULL, NULL, &par_ref ) )
- return FT_THROW( Invalid_Argument );
-
- if ( noErr != FSRefMakePath( &par_ref, path_lwfn, path_size ) )
- return FT_THROW( Invalid_Argument );
-
- if ( ft_strlen( (char *)path_lwfn ) + 1 + base_lwfn[0] > path_size )
- return FT_THROW( Invalid_Argument );
-
- /* now we have absolute dirname in path_lwfn */
- ft_strcat( (char *)path_lwfn, "/" );
- dirname_len = ft_strlen( (char *)path_lwfn );
- ft_strcat( (char *)path_lwfn, (char *)base_lwfn + 1 );
- path_lwfn[dirname_len + base_lwfn[0]] = '\0';
-
- if ( noErr != FSPathMakeRef( path_lwfn, &ref, FALSE ) )
- return FT_THROW( Cannot_Open_Resource );
-
- if ( noErr != FSGetCatalogInfo( &ref, kFSCatInfoNone,
- NULL, NULL, NULL, NULL ) )
- return FT_THROW( Cannot_Open_Resource );
-
- return FT_Err_Ok;
- }
-
-
- static short
- count_faces( Handle fond,
- const UInt8* pathname )
- {
- ResID sfnt_id;
- short have_sfnt, have_lwfn;
- Str255 lwfn_file_name;
- UInt8 buff[PATH_MAX];
- FT_Error err;
- short num_faces;
-
-
- have_sfnt = have_lwfn = 0;
-
- parse_fond( *fond, &have_sfnt, &sfnt_id, lwfn_file_name, 0 );
-
- if ( lwfn_file_name[0] )
- {
- err = lookup_lwfn_by_fond( pathname, lwfn_file_name,
- buff, sizeof ( buff ) );
- if ( !err )
- have_lwfn = 1;
- }
-
- if ( have_lwfn && ( !have_sfnt || PREFER_LWFN ) )
- num_faces = 1;
- else
- num_faces = count_faces_scalable( *fond );
-
- return num_faces;
- }
-
-
- /* Read Type 1 data from the POST resources inside the LWFN file,
- return a PFB buffer. This is somewhat convoluted because the FT2
- PFB parser wants the ASCII header as one chunk, and the LWFN
- chunks are often not organized that way, so we glue chunks
- of the same type together. */
- static FT_Error
- read_lwfn( FT_Memory memory,
- ResFileRefNum res,
- FT_Byte** pfb_data,
- FT_ULong* size )
- {
- FT_Error error = FT_Err_Ok;
- ResID res_id;
- unsigned char *buffer, *p, *size_p = NULL;
- FT_ULong total_size = 0;
- FT_ULong old_total_size = 0;
- FT_ULong post_size, pfb_chunk_size;
- Handle post_data;
- char code, last_code;
-
-
- UseResFile( res );
-
- /* First pass: load all POST resources, and determine the size of */
- /* the output buffer. */
- res_id = 501;
- last_code = -1;
-
- for (;;)
- {
- post_data = Get1Resource( TTAG_POST, res_id++ );
- if ( !post_data )
- break; /* we are done */
-
- code = (*post_data)[0];
-
- if ( code != last_code )
- {
- if ( code == 5 )
- total_size += 2; /* just the end code */
- else
- total_size += 6; /* code + 4 bytes chunk length */
- }
-
- total_size += (FT_ULong)GetHandleSize( post_data ) - 2;
- last_code = code;
-
- /* detect resource fork overflow */
- if ( FT_MAC_RFORK_MAX_LEN < total_size )
- {
- error = FT_THROW( Array_Too_Large );
- goto Error;
- }
-
- old_total_size = total_size;
- }
-
- if ( FT_QALLOC( buffer, (FT_Long)total_size ) )
- goto Error;
-
- /* Second pass: append all POST data to the buffer, add PFB fields. */
- /* Glue all consecutive chunks of the same type together. */
- p = buffer;
- res_id = 501;
- last_code = -1;
- pfb_chunk_size = 0;
-
- for (;;)
- {
- post_data = Get1Resource( TTAG_POST, res_id++ );
- if ( !post_data )
- break; /* we are done */
-
- post_size = (FT_ULong)GetHandleSize( post_data ) - 2;
- code = (*post_data)[0];
-
- if ( code != last_code )
- {
- if ( last_code != -1 )
- {
- /* we are done adding a chunk, fill in the size field */
- if ( size_p )
- {
- *size_p++ = (FT_Byte)( pfb_chunk_size & 0xFF );
- *size_p++ = (FT_Byte)( ( pfb_chunk_size >> 8 ) & 0xFF );
- *size_p++ = (FT_Byte)( ( pfb_chunk_size >> 16 ) & 0xFF );
- *size_p++ = (FT_Byte)( ( pfb_chunk_size >> 24 ) & 0xFF );
- }
- pfb_chunk_size = 0;
- }
-
- *p++ = 0x80;
- if ( code == 5 )
- *p++ = 0x03; /* the end */
- else if ( code == 2 )
- *p++ = 0x02; /* binary segment */
- else
- *p++ = 0x01; /* ASCII segment */
-
- if ( code != 5 )
- {
- size_p = p; /* save for later */
- p += 4; /* make space for size field */
- }
- }
-
- ft_memcpy( p, *post_data + 2, post_size );
- pfb_chunk_size += post_size;
- p += post_size;
- last_code = code;
- }
-
- *pfb_data = buffer;
- *size = total_size;
-
- Error:
- CloseResFile( res );
- return error;
- }
-
-
- /* Create a new FT_Face from a file path to an LWFN file. */
- static FT_Error
- FT_New_Face_From_LWFN( FT_Library library,
- const UInt8* pathname,
- FT_Long face_index,
- FT_Face* aface )
- {
- FT_Byte* pfb_data;
- FT_ULong pfb_size;
- FT_Error error;
- ResFileRefNum res;
-
-
- if ( noErr != FT_FSPathMakeRes( pathname, &res ) )
- return FT_THROW( Cannot_Open_Resource );
-
- pfb_data = NULL;
- pfb_size = 0;
- error = read_lwfn( library->memory, res, &pfb_data, &pfb_size );
- CloseResFile( res ); /* PFB is already loaded, useless anymore */
- if ( error )
- return error;
-
- return open_face_from_buffer( library,
- pfb_data,
- pfb_size,
- face_index,
- "type1",
- aface );
- }
-
-
- /* Create a new FT_Face from an SFNT resource, specified by res ID. */
- static FT_Error
- FT_New_Face_From_SFNT( FT_Library library,
- ResID sfnt_id,
- FT_Long face_index,
- FT_Face* aface )
- {
- Handle sfnt = NULL;
- FT_Byte* sfnt_data;
- size_t sfnt_size;
- FT_Error error = FT_Err_Ok;
- FT_Memory memory = library->memory;
- int is_cff, is_sfnt_ps;
-
-
- sfnt = GetResource( TTAG_sfnt, sfnt_id );
- if ( !sfnt )
- return FT_THROW( Invalid_Handle );
-
- sfnt_size = (FT_ULong)GetHandleSize( sfnt );
-
- /* detect resource fork overflow */
- if ( FT_MAC_RFORK_MAX_LEN < sfnt_size )
- return FT_THROW( Array_Too_Large );
-
- if ( FT_QALLOC( sfnt_data, (FT_Long)sfnt_size ) )
- {
- ReleaseResource( sfnt );
- return error;
- }
-
- ft_memcpy( sfnt_data, *sfnt, sfnt_size );
- ReleaseResource( sfnt );
-
- is_cff = sfnt_size > 4 && !ft_memcmp( sfnt_data, "OTTO", 4 );
- is_sfnt_ps = sfnt_size > 4 && !ft_memcmp( sfnt_data, "typ1", 4 );
-
- if ( is_sfnt_ps )
- {
- FT_Stream stream;
-
-
- if ( FT_NEW( stream ) )
- goto Try_OpenType;
-
- FT_Stream_OpenMemory( stream, sfnt_data, sfnt_size );
- if ( !open_face_PS_from_sfnt_stream( library,
- stream,
- face_index,
- 0, NULL,
- aface ) )
- {
- FT_Stream_Close( stream );
- FT_FREE( stream );
- FT_FREE( sfnt_data );
- goto Exit;
- }
-
- FT_FREE( stream );
- }
- Try_OpenType:
- error = open_face_from_buffer( library,
- sfnt_data,
- sfnt_size,
- face_index,
- is_cff ? "cff" : "truetype",
- aface );
- Exit:
- return error;
- }
-
-
- /* Create a new FT_Face from a file path to a suitcase file. */
- static FT_Error
- FT_New_Face_From_Suitcase( FT_Library library,
- const UInt8* pathname,
- FT_Long face_index,
- FT_Face* aface )
- {
- FT_Error error = FT_ERR( Cannot_Open_Resource );
- ResFileRefNum res_ref;
- ResourceIndex res_index;
- Handle fond;
- short num_faces_in_res;
- FT_Long count;
-
-
- if ( noErr != FT_FSPathMakeRes( pathname, &res_ref ) )
- return FT_THROW( Cannot_Open_Resource );
-
- UseResFile( res_ref );
- if ( ResError() )
- return FT_THROW( Cannot_Open_Resource );
-
- res_index = 1;
- num_faces_in_res = 0;
- count = face_index;
- while ( count >= 0 )
- {
- short num_faces_in_fond;
-
-
- fond = Get1IndResource( TTAG_FOND, res_index );
- if ( ResError() )
- break;
-
- num_faces_in_fond = count_faces( fond, pathname );
- num_faces_in_res += num_faces_in_fond;
-
- if ( count < num_faces_in_fond )
- error = FT_New_Face_From_FOND( library, fond, count, aface );
-
- res_index++;
- count -= num_faces_in_fond;
- }
-
- CloseResFile( res_ref );
-
- if ( !error && aface && *aface )
- {
- (*aface)->num_faces = num_faces_in_res;
- (*aface)->face_index = face_index;
- }
-
- return error;
- }
-
-
- /* documentation is in ftmac.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_New_Face_From_FOND( FT_Library library,
- Handle fond,
- FT_Long face_index,
- FT_Face* aface )
- {
- short have_sfnt, have_lwfn = 0;
- ResID sfnt_id, fond_id;
- OSType fond_type;
- Str255 fond_name;
- Str255 lwfn_file_name;
- UInt8 path_lwfn[PATH_MAX];
- OSErr err;
- FT_Error error = FT_Err_Ok;
-
-
- /* check of `library' and `aface' delayed to `FT_New_Face_From_XXX' */
-
- GetResInfo( fond, &fond_id, &fond_type, fond_name );
- if ( ResError() != noErr || fond_type != TTAG_FOND )
- return FT_THROW( Invalid_File_Format );
-
- parse_fond( *fond, &have_sfnt, &sfnt_id, lwfn_file_name, face_index );
-
- if ( lwfn_file_name[0] )
- {
- ResFileRefNum res;
-
-
- res = HomeResFile( fond );
- if ( noErr != ResError() )
- goto found_no_lwfn_file;
-
- {
- UInt8 path_fond[PATH_MAX];
- FSRef ref;
-
-
- err = FSGetForkCBInfo( res, kFSInvalidVolumeRefNum,
- NULL, NULL, NULL, &ref, NULL );
- if ( noErr != err )
- goto found_no_lwfn_file;
-
- err = FSRefMakePath( &ref, path_fond, sizeof ( path_fond ) );
- if ( noErr != err )
- goto found_no_lwfn_file;
-
- error = lookup_lwfn_by_fond( path_fond, lwfn_file_name,
- path_lwfn, sizeof ( path_lwfn ) );
- if ( !error )
- have_lwfn = 1;
- }
- }
-
- if ( have_lwfn && ( !have_sfnt || PREFER_LWFN ) )
- error = FT_New_Face_From_LWFN( library,
- path_lwfn,
- face_index,
- aface );
- else
- error = FT_THROW( Unknown_File_Format );
-
- found_no_lwfn_file:
- if ( have_sfnt && error )
- error = FT_New_Face_From_SFNT( library,
- sfnt_id,
- face_index,
- aface );
-
- return error;
- }
-
-
- /* Common function to load a new FT_Face from a resource file. */
- static FT_Error
- FT_New_Face_From_Resource( FT_Library library,
- const UInt8* pathname,
- FT_Long face_index,
- FT_Face* aface )
- {
- OSType file_type;
- FT_Error error;
-
-
- /* LWFN is a (very) specific file format, check for it explicitly */
- file_type = get_file_type_from_path( pathname );
- if ( file_type == TTAG_LWFN )
- return FT_New_Face_From_LWFN( library, pathname, face_index, aface );
-
- /* Otherwise the file type doesn't matter (there are more than */
- /* `FFIL' and `tfil'). Just try opening it as a font suitcase; */
- /* if it works, fine. */
-
- error = FT_New_Face_From_Suitcase( library, pathname, face_index, aface );
- if ( error )
- {
- /* let it fall through to normal loader (.ttf, .otf, etc.); */
- /* we signal this by returning no error and no FT_Face */
- *aface = NULL;
- }
-
- return FT_Err_Ok;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * FT_New_Face
- *
- * @Description:
- * This is the Mac-specific implementation of FT_New_Face. In
- * addition to the standard FT_New_Face() functionality, it also
- * accepts pathnames to Mac suitcase files. For further
- * documentation see the original FT_New_Face() in freetype.h.
- */
- FT_EXPORT_DEF( FT_Error )
- FT_New_Face( FT_Library library,
- const char* pathname,
- FT_Long face_index,
- FT_Face* aface )
- {
- FT_Open_Args args;
- FT_Error error;
-
-
- /* test for valid `library' and `aface' delayed to FT_Open_Face() */
- if ( !pathname )
- return FT_THROW( Invalid_Argument );
-
- *aface = NULL;
-
- /* try resourcefork based font: LWFN, FFIL */
- error = FT_New_Face_From_Resource( library, (UInt8 *)pathname,
- face_index, aface );
- if ( error || *aface )
- return error;
-
- /* let it fall through to normal loader (.ttf, .otf, etc.) */
- args.flags = FT_OPEN_PATHNAME;
- args.pathname = (char*)pathname;
-
- return FT_Open_Face( library, &args, face_index, aface );
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * FT_New_Face_From_FSRef
- *
- * @Description:
- * FT_New_Face_From_FSRef is identical to FT_New_Face except it
- * accepts an FSRef instead of a path.
- *
- * This function is deprecated because Carbon data types (FSRef)
- * are not cross-platform, and thus not suitable for the FreeType API.
- */
- FT_EXPORT_DEF( FT_Error )
- FT_New_Face_From_FSRef( FT_Library library,
- const FSRef* ref,
- FT_Long face_index,
- FT_Face* aface )
- {
- FT_Error error;
- FT_Open_Args args;
-
- OSErr err;
- UInt8 pathname[PATH_MAX];
-
-
- /* check of `library' and `aface' delayed to */
- /* `FT_New_Face_From_Resource' */
-
- if ( !ref )
- return FT_THROW( Invalid_Argument );
-
- err = FSRefMakePath( ref, pathname, sizeof ( pathname ) );
- if ( err )
- error = FT_THROW( Cannot_Open_Resource );
-
- error = FT_New_Face_From_Resource( library, pathname, face_index, aface );
- if ( error || *aface )
- return error;
-
- /* fallback to datafork font */
- args.flags = FT_OPEN_PATHNAME;
- args.pathname = (char*)pathname;
- return FT_Open_Face( library, &args, face_index, aface );
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * FT_New_Face_From_FSSpec
- *
- * @Description:
- * FT_New_Face_From_FSSpec is identical to FT_New_Face except it
- * accepts an FSSpec instead of a path.
- *
- * This function is deprecated because FSSpec is deprecated in Mac OS X
- */
- FT_EXPORT_DEF( FT_Error )
- FT_New_Face_From_FSSpec( FT_Library library,
- const FSSpec* spec,
- FT_Long face_index,
- FT_Face* aface )
- {
-#if ( __LP64__ ) || ( defined( MAC_OS_X_VERSION_10_5 ) && \
- ( MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 ) )
- FT_UNUSED( library );
- FT_UNUSED( spec );
- FT_UNUSED( face_index );
- FT_UNUSED( aface );
-
- return FT_THROW( Unimplemented_Feature );
-#else
- FSRef ref;
-
-
- /* check of `library' and `aface' delayed to `FT_New_Face_From_FSRef' */
-
- if ( !spec || FSpMakeFSRef( spec, &ref ) != noErr )
- return FT_THROW( Invalid_Argument );
- else
- return FT_New_Face_From_FSRef( library, &ref, face_index, aface );
-#endif
- }
-
-#else /* !FT_MACINTOSH */
-
- /* ANSI C doesn't like empty source files */
- typedef int ft_mac_dummy_;
-
-#endif /* !FT_MACINTOSH */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/base/ftmm.c b/contrib/libs/freetype/src/base/ftmm.c
deleted file mode 100644
index cc4ca22fba..0000000000
--- a/contrib/libs/freetype/src/base/ftmm.c
+++ /dev/null
@@ -1,704 +0,0 @@
-/****************************************************************************
- *
- * ftmm.c
- *
- * Multiple Master font support (body).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftdebug.h>
-
-#include <freetype/ftmm.h>
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/services/svmm.h>
-#include <freetype/internal/services/svmetric.h>
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT mm
-
-
- static FT_Error
- ft_face_get_mm_service( FT_Face face,
- FT_Service_MultiMasters *aservice )
- {
- FT_Error error;
-
-
- *aservice = NULL;
-
- if ( !face )
- return FT_THROW( Invalid_Face_Handle );
-
- error = FT_ERR( Invalid_Argument );
-
- if ( FT_HAS_MULTIPLE_MASTERS( face ) )
- {
- FT_FACE_LOOKUP_SERVICE( face,
- *aservice,
- MULTI_MASTERS );
-
- if ( *aservice )
- error = FT_Err_Ok;
- }
-
- return error;
- }
-
-
- static FT_Error
- ft_face_get_mvar_service( FT_Face face,
- FT_Service_MetricsVariations *aservice )
- {
- FT_Error error;
-
-
- *aservice = NULL;
-
- if ( !face )
- return FT_THROW( Invalid_Face_Handle );
-
- error = FT_ERR( Invalid_Argument );
-
- if ( FT_HAS_MULTIPLE_MASTERS( face ) )
- {
- FT_FACE_LOOKUP_SERVICE( face,
- *aservice,
- METRICS_VARIATIONS );
-
- if ( *aservice )
- error = FT_Err_Ok;
- }
-
- return error;
- }
-
-
- /* documentation is in ftmm.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Get_Multi_Master( FT_Face face,
- FT_Multi_Master *amaster )
- {
- FT_Error error;
- FT_Service_MultiMasters service;
-
-
- /* check of `face' delayed to `ft_face_get_mm_service' */
-
- if ( !amaster )
- return FT_THROW( Invalid_Argument );
-
- error = ft_face_get_mm_service( face, &service );
- if ( !error )
- {
- error = FT_ERR( Invalid_Argument );
- if ( service->get_mm )
- error = service->get_mm( face, amaster );
- }
-
- return error;
- }
-
-
- /* documentation is in ftmm.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Get_MM_Var( FT_Face face,
- FT_MM_Var* *amaster )
- {
- FT_Error error;
- FT_Service_MultiMasters service;
-
-
- /* check of `face' delayed to `ft_face_get_mm_service' */
-
- if ( !amaster )
- return FT_THROW( Invalid_Argument );
-
- error = ft_face_get_mm_service( face, &service );
- if ( !error )
- {
- error = FT_ERR( Invalid_Argument );
- if ( service->get_mm_var )
- error = service->get_mm_var( face, amaster );
- }
-
- return error;
- }
-
-
- /* documentation is in ftmm.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Done_MM_Var( FT_Library library,
- FT_MM_Var* amaster )
- {
- FT_Memory memory;
-
-
- if ( !library )
- return FT_THROW( Invalid_Library_Handle );
-
- memory = library->memory;
- FT_FREE( amaster );
-
- return FT_Err_Ok;
- }
-
-
- /* documentation is in ftmm.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Set_MM_Design_Coordinates( FT_Face face,
- FT_UInt num_coords,
- FT_Long* coords )
- {
- FT_Error error;
- FT_Service_MultiMasters service;
-
-
- /* check of `face' delayed to `ft_face_get_mm_service' */
-
- if ( num_coords && !coords )
- return FT_THROW( Invalid_Argument );
-
- error = ft_face_get_mm_service( face, &service );
- if ( !error )
- {
- error = FT_ERR( Invalid_Argument );
- if ( service->set_mm_design )
- error = service->set_mm_design( face, num_coords, coords );
-
- if ( !error )
- {
- if ( num_coords )
- face->face_flags |= FT_FACE_FLAG_VARIATION;
- else
- face->face_flags &= ~FT_FACE_FLAG_VARIATION;
- }
- }
-
- /* enforce recomputation of auto-hinting data */
- if ( !error && face->autohint.finalizer )
- {
- face->autohint.finalizer( face->autohint.data );
- face->autohint.data = NULL;
- }
-
- return error;
- }
-
-
- /* documentation is in ftmm.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Set_MM_WeightVector( FT_Face face,
- FT_UInt len,
- FT_Fixed* weightvector )
- {
- FT_Error error;
- FT_Service_MultiMasters service;
-
-
- /* check of `face' delayed to `ft_face_get_mm_service' */
-
- if ( len && !weightvector )
- return FT_THROW( Invalid_Argument );
-
- error = ft_face_get_mm_service( face, &service );
- if ( !error )
- {
- error = FT_ERR( Invalid_Argument );
- if ( service->set_mm_weightvector )
- error = service->set_mm_weightvector( face, len, weightvector );
-
- if ( !error )
- {
- if ( len )
- face->face_flags |= FT_FACE_FLAG_VARIATION;
- else
- face->face_flags &= ~FT_FACE_FLAG_VARIATION;
- }
- }
-
- /* enforce recomputation of auto-hinting data */
- if ( !error && face->autohint.finalizer )
- {
- face->autohint.finalizer( face->autohint.data );
- face->autohint.data = NULL;
- }
-
- return error;
- }
-
-
- FT_EXPORT_DEF( FT_Error )
- FT_Get_MM_WeightVector( FT_Face face,
- FT_UInt* len,
- FT_Fixed* weightvector )
- {
- FT_Error error;
- FT_Service_MultiMasters service;
-
-
- /* check of `face' delayed to `ft_face_get_mm_service' */
-
- if ( len && !weightvector )
- return FT_THROW( Invalid_Argument );
-
- error = ft_face_get_mm_service( face, &service );
- if ( !error )
- {
- error = FT_ERR( Invalid_Argument );
- if ( service->get_mm_weightvector )
- error = service->get_mm_weightvector( face, len, weightvector );
- }
-
- return error;
- }
-
-
- /* documentation is in ftmm.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Set_Var_Design_Coordinates( FT_Face face,
- FT_UInt num_coords,
- FT_Fixed* coords )
- {
- FT_Error error;
- FT_Service_MultiMasters service_mm = NULL;
- FT_Service_MetricsVariations service_mvar = NULL;
-
-
- /* check of `face' delayed to `ft_face_get_mm_service' */
-
- if ( num_coords && !coords )
- return FT_THROW( Invalid_Argument );
-
- error = ft_face_get_mm_service( face, &service_mm );
- if ( !error )
- {
- error = FT_ERR( Invalid_Argument );
- if ( service_mm->set_var_design )
- error = service_mm->set_var_design( face, num_coords, coords );
-
- if ( !error || error == -1 )
- {
- FT_Bool is_variation_old = FT_IS_VARIATION( face );
-
-
- if ( num_coords )
- face->face_flags |= FT_FACE_FLAG_VARIATION;
- else
- face->face_flags &= ~FT_FACE_FLAG_VARIATION;
-
- if ( service_mm->construct_ps_name )
- {
- if ( error == -1 )
- {
- /* The PS name of a named instance and a non-named instance */
- /* usually differs, even if the axis values are identical. */
- if ( is_variation_old != FT_IS_VARIATION( face ) )
- service_mm->construct_ps_name( face );
- }
- else
- service_mm->construct_ps_name( face );
- }
- }
-
- /* internal error code -1 means `no change'; we can exit immediately */
- if ( error == -1 )
- return FT_Err_Ok;
- }
-
- if ( !error )
- {
- (void)ft_face_get_mvar_service( face, &service_mvar );
-
- if ( service_mvar && service_mvar->metrics_adjust )
- service_mvar->metrics_adjust( face );
- }
-
- /* enforce recomputation of auto-hinting data */
- if ( !error && face->autohint.finalizer )
- {
- face->autohint.finalizer( face->autohint.data );
- face->autohint.data = NULL;
- }
-
- return error;
- }
-
-
- /* documentation is in ftmm.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Get_Var_Design_Coordinates( FT_Face face,
- FT_UInt num_coords,
- FT_Fixed* coords )
- {
- FT_Error error;
- FT_Service_MultiMasters service;
-
-
- /* check of `face' delayed to `ft_face_get_mm_service' */
-
- if ( !coords )
- return FT_THROW( Invalid_Argument );
-
- error = ft_face_get_mm_service( face, &service );
- if ( !error )
- {
- error = FT_ERR( Invalid_Argument );
- if ( service->get_var_design )
- error = service->get_var_design( face, num_coords, coords );
- }
-
- return error;
- }
-
-
- /* documentation is in ftmm.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Set_MM_Blend_Coordinates( FT_Face face,
- FT_UInt num_coords,
- FT_Fixed* coords )
- {
- FT_Error error;
- FT_Service_MultiMasters service_mm = NULL;
- FT_Service_MetricsVariations service_mvar = NULL;
-
-
- /* check of `face' delayed to `ft_face_get_mm_service' */
-
- if ( num_coords && !coords )
- return FT_THROW( Invalid_Argument );
-
- error = ft_face_get_mm_service( face, &service_mm );
- if ( !error )
- {
- error = FT_ERR( Invalid_Argument );
- if ( service_mm->set_mm_blend )
- error = service_mm->set_mm_blend( face, num_coords, coords );
-
- if ( !error || error == -1 )
- {
- FT_Bool is_variation_old = FT_IS_VARIATION( face );
-
-
- if ( num_coords )
- face->face_flags |= FT_FACE_FLAG_VARIATION;
- else
- face->face_flags &= ~FT_FACE_FLAG_VARIATION;
-
- if ( service_mm->construct_ps_name )
- {
- if ( error == -1 )
- {
- /* The PS name of a named instance and a non-named instance */
- /* usually differs, even if the axis values are identical. */
- if ( is_variation_old != FT_IS_VARIATION( face ) )
- service_mm->construct_ps_name( face );
- }
- else
- service_mm->construct_ps_name( face );
- }
- }
-
- /* internal error code -1 means `no change'; we can exit immediately */
- if ( error == -1 )
- return FT_Err_Ok;
- }
-
- if ( !error )
- {
- (void)ft_face_get_mvar_service( face, &service_mvar );
-
- if ( service_mvar && service_mvar->metrics_adjust )
- service_mvar->metrics_adjust( face );
- }
-
- /* enforce recomputation of auto-hinting data */
- if ( !error && face->autohint.finalizer )
- {
- face->autohint.finalizer( face->autohint.data );
- face->autohint.data = NULL;
- }
-
- return error;
- }
-
-
- /* documentation is in ftmm.h */
-
- /* This is exactly the same as the previous function. It exists for */
- /* orthogonality. */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Set_Var_Blend_Coordinates( FT_Face face,
- FT_UInt num_coords,
- FT_Fixed* coords )
- {
- FT_Error error;
- FT_Service_MultiMasters service_mm = NULL;
- FT_Service_MetricsVariations service_mvar = NULL;
-
-
- /* check of `face' delayed to `ft_face_get_mm_service' */
-
- if ( num_coords && !coords )
- return FT_THROW( Invalid_Argument );
-
- error = ft_face_get_mm_service( face, &service_mm );
- if ( !error )
- {
- error = FT_ERR( Invalid_Argument );
- if ( service_mm->set_mm_blend )
- error = service_mm->set_mm_blend( face, num_coords, coords );
-
- if ( !error || error == -1 )
- {
- FT_Bool is_variation_old = FT_IS_VARIATION( face );
-
-
- if ( num_coords )
- face->face_flags |= FT_FACE_FLAG_VARIATION;
- else
- face->face_flags &= ~FT_FACE_FLAG_VARIATION;
-
- if ( service_mm->construct_ps_name )
- {
- if ( error == -1 )
- {
- /* The PS name of a named instance and a non-named instance */
- /* usually differs, even if the axis values are identical. */
- if ( is_variation_old != FT_IS_VARIATION( face ) )
- service_mm->construct_ps_name( face );
- }
- else
- service_mm->construct_ps_name( face );
- }
- }
-
- /* internal error code -1 means `no change'; we can exit immediately */
- if ( error == -1 )
- return FT_Err_Ok;
- }
-
- if ( !error )
- {
- (void)ft_face_get_mvar_service( face, &service_mvar );
-
- if ( service_mvar && service_mvar->metrics_adjust )
- service_mvar->metrics_adjust( face );
- }
-
- /* enforce recomputation of auto-hinting data */
- if ( !error && face->autohint.finalizer )
- {
- face->autohint.finalizer( face->autohint.data );
- face->autohint.data = NULL;
- }
-
- return error;
- }
-
-
- /* documentation is in ftmm.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Get_MM_Blend_Coordinates( FT_Face face,
- FT_UInt num_coords,
- FT_Fixed* coords )
- {
- FT_Error error;
- FT_Service_MultiMasters service;
-
-
- /* check of `face' delayed to `ft_face_get_mm_service' */
-
- if ( !coords )
- return FT_THROW( Invalid_Argument );
-
- error = ft_face_get_mm_service( face, &service );
- if ( !error )
- {
- error = FT_ERR( Invalid_Argument );
- if ( service->get_mm_blend )
- error = service->get_mm_blend( face, num_coords, coords );
- }
-
- return error;
- }
-
-
- /* documentation is in ftmm.h */
-
- /* This is exactly the same as the previous function. It exists for */
- /* orthogonality. */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Get_Var_Blend_Coordinates( FT_Face face,
- FT_UInt num_coords,
- FT_Fixed* coords )
- {
- FT_Error error;
- FT_Service_MultiMasters service;
-
-
- /* check of `face' delayed to `ft_face_get_mm_service' */
-
- if ( !coords )
- return FT_THROW( Invalid_Argument );
-
- error = ft_face_get_mm_service( face, &service );
- if ( !error )
- {
- error = FT_ERR( Invalid_Argument );
- if ( service->get_mm_blend )
- error = service->get_mm_blend( face, num_coords, coords );
- }
-
- return error;
- }
-
-
- /* documentation is in ftmm.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Get_Var_Axis_Flags( FT_MM_Var* master,
- FT_UInt axis_index,
- FT_UInt* flags )
- {
- FT_UShort* axis_flags;
-
-
- if ( !master || !flags )
- return FT_THROW( Invalid_Argument );
-
- if ( axis_index >= master->num_axis )
- return FT_THROW( Invalid_Argument );
-
- /* the axis flags array immediately follows the data of `master' */
- axis_flags = (FT_UShort*)&( master[1] );
- *flags = axis_flags[axis_index];
-
- return FT_Err_Ok;
- }
-
-
- /* documentation is in ftmm.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Set_Named_Instance( FT_Face face,
- FT_UInt instance_index )
- {
- FT_Error error;
-
- FT_Service_MultiMasters service_mm = NULL;
- FT_Service_MetricsVariations service_mvar = NULL;
-
-
- /* check of `face' delayed to `ft_face_get_mm_service' */
-
- error = ft_face_get_mm_service( face, &service_mm );
- if ( !error )
- {
- error = FT_ERR( Invalid_Argument );
- if ( service_mm->set_named_instance )
- error = service_mm->set_named_instance( face, instance_index );
-
- if ( !error || error == -1 )
- {
- FT_Bool is_variation_old = FT_IS_VARIATION( face );
-
-
- face->face_flags &= ~FT_FACE_FLAG_VARIATION;
- face->face_index = ( instance_index << 16 ) |
- ( face->face_index & 0xFFFFL );
-
- if ( service_mm->construct_ps_name )
- {
- if ( error == -1 )
- {
- /* The PS name of a named instance and a non-named instance */
- /* usually differs, even if the axis values are identical. */
- if ( is_variation_old != FT_IS_VARIATION( face ) )
- service_mm->construct_ps_name( face );
- }
- else
- service_mm->construct_ps_name( face );
- }
- }
-
- /* internal error code -1 means `no change'; we can exit immediately */
- if ( error == -1 )
- return FT_Err_Ok;
- }
-
- if ( !error )
- {
- (void)ft_face_get_mvar_service( face, &service_mvar );
-
- if ( service_mvar && service_mvar->metrics_adjust )
- service_mvar->metrics_adjust( face );
- }
-
- /* enforce recomputation of auto-hinting data */
- if ( !error && face->autohint.finalizer )
- {
- face->autohint.finalizer( face->autohint.data );
- face->autohint.data = NULL;
- }
-
- return error;
- }
-
-
- /* documentation is in ftmm.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Get_Default_Named_Instance( FT_Face face,
- FT_UInt *instance_index )
- {
- FT_Error error;
-
- FT_Service_MultiMasters service_mm = NULL;
-
-
- /* check of `face' delayed to `ft_face_get_mm_service' */
-
- error = ft_face_get_mm_service( face, &service_mm );
- if ( !error )
- {
- /* no error if `get_default_named_instance` is not available */
- if ( service_mm->get_default_named_instance )
- error = service_mm->get_default_named_instance( face,
- instance_index );
- else
- error = FT_Err_Ok;
- }
-
- return error;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/base/ftobjs.c b/contrib/libs/freetype/src/base/ftobjs.c
deleted file mode 100644
index 9b97820c37..0000000000
--- a/contrib/libs/freetype/src/base/ftobjs.c
+++ /dev/null
@@ -1,5917 +0,0 @@
-/****************************************************************************
- *
- * ftobjs.c
- *
- * The FreeType private base classes (body).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/ftlist.h>
-#include <freetype/ftoutln.h>
-#include <freetype/ftfntfmt.h>
-#include <freetype/otsvg.h>
-
-#include <freetype/internal/ftvalid.h>
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftrfork.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/internal/sfnt.h> /* for SFNT_Load_Table_Func */
-#include <freetype/internal/psaux.h> /* for PS_Driver */
-#include <freetype/internal/svginterface.h>
-
-#include <freetype/tttables.h>
-#include <freetype/tttags.h>
-#include <freetype/ttnameid.h>
-
-#include <freetype/internal/services/svprop.h>
-#include <freetype/internal/services/svsfnt.h>
-#include <freetype/internal/services/svpostnm.h>
-#include <freetype/internal/services/svgldict.h>
-#include <freetype/internal/services/svttcmap.h>
-#include <freetype/internal/services/svkern.h>
-#include <freetype/internal/services/svtteng.h>
-
-#include <freetype/ftdriver.h>
-
-#ifdef FT_CONFIG_OPTION_MAC_FONTS
-#include "ftbase.h"
-#endif
-
-
-#ifdef FT_DEBUG_LEVEL_TRACE
-
-#include <freetype/ftbitmap.h>
-
-#if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */
- /* We disable the warning `conversion from XXX to YYY, */
- /* possible loss of data' in order to compile cleanly with */
- /* the maximum level of warnings: `md5.c' is non-FreeType */
- /* code, and it gets used during development builds only. */
-#pragma warning( push )
-#pragma warning( disable : 4244 )
-#endif /* _MSC_VER */
-
- /* It's easiest to include `md5.c' directly. However, since OpenSSL */
- /* also provides the same functions, there might be conflicts if */
- /* both FreeType and OpenSSL are built as static libraries. For */
- /* this reason, we put the MD5 stuff into the `FT_' namespace. */
-#define MD5_u32plus FT_MD5_u32plus
-#define MD5_CTX FT_MD5_CTX
-#define MD5_Init FT_MD5_Init
-#define MD5_Update FT_MD5_Update
-#define MD5_Final FT_MD5_Final
-
-#undef HAVE_OPENSSL
-
-#include "md5.c"
-
-#if defined( _MSC_VER )
-#pragma warning( pop )
-#endif
-
- /* This array must stay in sync with the @FT_Pixel_Mode enumeration */
- /* (in file `ftimage.h`). */
-
- static const char* const pixel_modes[] =
- {
- "none",
- "monochrome bitmap",
- "gray 8-bit bitmap",
- "gray 2-bit bitmap",
- "gray 4-bit bitmap",
- "LCD 8-bit bitmap",
- "vertical LCD 8-bit bitmap",
- "BGRA 32-bit color image bitmap",
- "SDF 8-bit bitmap"
- };
-
-#endif /* FT_DEBUG_LEVEL_TRACE */
-
-
-#define GRID_FIT_METRICS
-
-
- /* forward declaration */
- static FT_Error
- ft_open_face_internal( FT_Library library,
- const FT_Open_Args* args,
- FT_Long face_index,
- FT_Face *aface,
- FT_Bool test_mac_fonts );
-
-
- FT_BASE_DEF( FT_Pointer )
- ft_service_list_lookup( FT_ServiceDesc service_descriptors,
- const char* service_id )
- {
- FT_Pointer result = NULL;
- FT_ServiceDesc desc = service_descriptors;
-
-
- if ( desc && service_id )
- {
- for ( ; desc->serv_id != NULL; desc++ )
- {
- if ( ft_strcmp( desc->serv_id, service_id ) == 0 )
- {
- result = (FT_Pointer)desc->serv_data;
- break;
- }
- }
- }
-
- return result;
- }
-
-
- FT_BASE_DEF( void )
- ft_validator_init( FT_Validator valid,
- const FT_Byte* base,
- const FT_Byte* limit,
- FT_ValidationLevel level )
- {
- valid->base = base;
- valid->limit = limit;
- valid->level = level;
- valid->error = FT_Err_Ok;
- }
-
-
- FT_BASE_DEF( FT_Int )
- ft_validator_run( FT_Validator valid )
- {
- /* This function doesn't work! None should call it. */
- FT_UNUSED( valid );
-
- return -1;
- }
-
-
- FT_BASE_DEF( void )
- ft_validator_error( FT_Validator valid,
- FT_Error error )
- {
- /* since the cast below also disables the compiler's */
- /* type check, we introduce a dummy variable, which */
- /* will be optimized away */
- volatile ft_jmp_buf* jump_buffer = &valid->jump_buffer;
-
-
- valid->error = error;
-
- /* throw away volatileness; use `jump_buffer' or the */
- /* compiler may warn about an unused local variable */
- ft_longjmp( *(ft_jmp_buf*) jump_buffer, 1 );
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /**** ****/
- /**** ****/
- /**** S T R E A M ****/
- /**** ****/
- /**** ****/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /* create a new input stream from an FT_Open_Args structure */
- /* */
- FT_BASE_DEF( FT_Error )
- FT_Stream_New( FT_Library library,
- const FT_Open_Args* args,
- FT_Stream *astream )
- {
- FT_Error error;
- FT_Memory memory;
- FT_Stream stream = NULL;
- FT_UInt mode;
-
-
- *astream = NULL;
-
- if ( !library )
- return FT_THROW( Invalid_Library_Handle );
-
- if ( !args )
- return FT_THROW( Invalid_Argument );
-
- memory = library->memory;
- mode = args->flags &
- ( FT_OPEN_MEMORY | FT_OPEN_STREAM | FT_OPEN_PATHNAME );
-
- if ( mode == FT_OPEN_MEMORY )
- {
- /* create a memory-based stream */
- if ( FT_NEW( stream ) )
- goto Exit;
-
- FT_Stream_OpenMemory( stream,
- (const FT_Byte*)args->memory_base,
- (FT_ULong)args->memory_size );
- stream->memory = memory;
- }
-
-#ifndef FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT
-
- else if ( mode == FT_OPEN_PATHNAME )
- {
- /* create a normal system stream */
- if ( FT_NEW( stream ) )
- goto Exit;
-
- stream->memory = memory;
- error = FT_Stream_Open( stream, args->pathname );
- if ( error )
- FT_FREE( stream );
- }
- else if ( ( mode == FT_OPEN_STREAM ) && args->stream )
- {
- /* use an existing, user-provided stream */
-
- /* in this case, we do not need to allocate a new stream object */
- /* since the caller is responsible for closing it himself */
- stream = args->stream;
- stream->memory = memory;
- error = FT_Err_Ok;
- }
-
-#endif
-
- else
- {
- error = FT_THROW( Invalid_Argument );
- if ( ( args->flags & FT_OPEN_STREAM ) && args->stream )
- FT_Stream_Close( args->stream );
- }
-
- if ( !error )
- *astream = stream;
-
- Exit:
- return error;
- }
-
-
- FT_BASE_DEF( void )
- FT_Stream_Free( FT_Stream stream,
- FT_Int external )
- {
- if ( stream )
- {
- FT_Memory memory = stream->memory;
-
-
- FT_Stream_Close( stream );
-
- if ( !external )
- FT_FREE( stream );
- }
- }
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT objs
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /**** ****/
- /**** ****/
- /**** FACE, SIZE & GLYPH SLOT OBJECTS ****/
- /**** ****/
- /**** ****/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
- static FT_Error
- ft_glyphslot_init( FT_GlyphSlot slot )
- {
- FT_Driver driver = slot->face->driver;
- FT_Driver_Class clazz = driver->clazz;
- FT_Memory memory = driver->root.memory;
- FT_Error error = FT_Err_Ok;
- FT_Slot_Internal internal = NULL;
-
-
- slot->library = driver->root.library;
-
- if ( FT_NEW( internal ) )
- goto Exit;
-
- slot->internal = internal;
-
- if ( FT_DRIVER_USES_OUTLINES( driver ) )
- error = FT_GlyphLoader_New( memory, &internal->loader );
-
- if ( !error && clazz->init_slot )
- error = clazz->init_slot( slot );
-
-#ifdef FT_CONFIG_OPTION_SVG
- /* if SVG table exists, allocate the space in `slot->other` */
- if ( slot->face->face_flags & FT_FACE_FLAG_SVG )
- {
- FT_SVG_Document document = NULL;
-
-
- if ( FT_NEW( document ) )
- goto Exit;
- slot->other = document;
- }
-#endif
-
- Exit:
- return error;
- }
-
-
- FT_BASE_DEF( void )
- ft_glyphslot_free_bitmap( FT_GlyphSlot slot )
- {
- if ( slot->internal && ( slot->internal->flags & FT_GLYPH_OWN_BITMAP ) )
- {
- FT_Memory memory = FT_FACE_MEMORY( slot->face );
-
-
- FT_FREE( slot->bitmap.buffer );
- slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
- }
- else
- {
- /* assume that the bitmap buffer was stolen or not */
- /* allocated from the heap */
- slot->bitmap.buffer = NULL;
- }
- }
-
-
- /* overflow-resistant presetting of bitmap position and dimensions; */
- /* also check whether the size is too large for rendering */
- FT_BASE_DEF( FT_Bool )
- ft_glyphslot_preset_bitmap( FT_GlyphSlot slot,
- FT_Render_Mode mode,
- const FT_Vector* origin )
- {
- FT_Outline* outline = &slot->outline;
- FT_Bitmap* bitmap = &slot->bitmap;
-
- FT_Pixel_Mode pixel_mode;
-
- FT_BBox cbox, pbox;
- FT_Pos x_shift = 0;
- FT_Pos y_shift = 0;
- FT_Pos x_left, y_top;
- FT_Pos width, height, pitch;
-
-
- if ( slot->format == FT_GLYPH_FORMAT_SVG )
- {
- FT_Module module;
- SVG_Service svg_service;
-
-
- module = FT_Get_Module( slot->library, "ot-svg" );
- svg_service = (SVG_Service)module->clazz->module_interface;
-
- return (FT_Bool)svg_service->preset_slot( module, slot, FALSE );
- }
- else if ( slot->format != FT_GLYPH_FORMAT_OUTLINE )
- return 1;
-
- if ( origin )
- {
- x_shift = origin->x;
- y_shift = origin->y;
- }
-
- /* compute the control box, and grid-fit it, */
- /* taking into account the origin shift */
- FT_Outline_Get_CBox( outline, &cbox );
-
- /* rough estimate of pixel box */
- pbox.xMin = ( cbox.xMin >> 6 ) + ( x_shift >> 6 );
- pbox.yMin = ( cbox.yMin >> 6 ) + ( y_shift >> 6 );
- pbox.xMax = ( cbox.xMax >> 6 ) + ( x_shift >> 6 );
- pbox.yMax = ( cbox.yMax >> 6 ) + ( y_shift >> 6 );
-
- /* tiny remainder box */
- cbox.xMin = ( cbox.xMin & 63 ) + ( x_shift & 63 );
- cbox.yMin = ( cbox.yMin & 63 ) + ( y_shift & 63 );
- cbox.xMax = ( cbox.xMax & 63 ) + ( x_shift & 63 );
- cbox.yMax = ( cbox.yMax & 63 ) + ( y_shift & 63 );
-
- switch ( mode )
- {
- case FT_RENDER_MODE_MONO:
- pixel_mode = FT_PIXEL_MODE_MONO;
-#if 1
- /* x */
-
- /* undocumented but confirmed: bbox values get rounded; */
- /* we do asymmetric rounding so that the center of a pixel */
- /* gets always included */
-
- pbox.xMin += ( cbox.xMin + 31 ) >> 6;
- pbox.xMax += ( cbox.xMax + 32 ) >> 6;
-
- /* if the bbox collapsed, we add a pixel based on the total */
- /* rounding remainder to cover most of the original cbox */
-
- if ( pbox.xMin == pbox.xMax )
- {
- if ( ( ( cbox.xMin + 31 ) & 63 ) - 31 +
- ( ( cbox.xMax + 32 ) & 63 ) - 32 < 0 )
- pbox.xMin -= 1;
- else
- pbox.xMax += 1;
- }
-
- /* y */
-
- pbox.yMin += ( cbox.yMin + 31 ) >> 6;
- pbox.yMax += ( cbox.yMax + 32 ) >> 6;
-
- if ( pbox.yMin == pbox.yMax )
- {
- if ( ( ( cbox.yMin + 31 ) & 63 ) - 31 +
- ( ( cbox.yMax + 32 ) & 63 ) - 32 < 0 )
- pbox.yMin -= 1;
- else
- pbox.yMax += 1;
- }
-
- break;
-#else
- goto Adjust;
-#endif
-
- case FT_RENDER_MODE_LCD:
- pixel_mode = FT_PIXEL_MODE_LCD;
- ft_lcd_padding( &cbox, slot, mode );
- goto Adjust;
-
- case FT_RENDER_MODE_LCD_V:
- pixel_mode = FT_PIXEL_MODE_LCD_V;
- ft_lcd_padding( &cbox, slot, mode );
- goto Adjust;
-
- case FT_RENDER_MODE_NORMAL:
- case FT_RENDER_MODE_LIGHT:
- default:
- pixel_mode = FT_PIXEL_MODE_GRAY;
- Adjust:
- pbox.xMin += cbox.xMin >> 6;
- pbox.yMin += cbox.yMin >> 6;
- pbox.xMax += ( cbox.xMax + 63 ) >> 6;
- pbox.yMax += ( cbox.yMax + 63 ) >> 6;
- }
-
- x_left = pbox.xMin;
- y_top = pbox.yMax;
-
- width = pbox.xMax - pbox.xMin;
- height = pbox.yMax - pbox.yMin;
-
- switch ( pixel_mode )
- {
- case FT_PIXEL_MODE_MONO:
- pitch = ( ( width + 15 ) >> 4 ) << 1;
- break;
-
- case FT_PIXEL_MODE_LCD:
- width *= 3;
- pitch = FT_PAD_CEIL( width, 4 );
- break;
-
- case FT_PIXEL_MODE_LCD_V:
- height *= 3;
- FALL_THROUGH;
-
- case FT_PIXEL_MODE_GRAY:
- default:
- pitch = width;
- }
-
- slot->bitmap_left = (FT_Int)x_left;
- slot->bitmap_top = (FT_Int)y_top;
-
- bitmap->pixel_mode = (unsigned char)pixel_mode;
- bitmap->num_grays = 256;
- bitmap->width = (unsigned int)width;
- bitmap->rows = (unsigned int)height;
- bitmap->pitch = pitch;
-
- if ( pbox.xMin < -0x8000 || pbox.xMax > 0x7FFF ||
- pbox.yMin < -0x8000 || pbox.yMax > 0x7FFF )
- {
- FT_TRACE3(( "ft_glyphslot_preset_bitmap: [%ld %ld %ld %ld]\n",
- pbox.xMin, pbox.yMin, pbox.xMax, pbox.yMax ));
- return 1;
- }
-
- return 0;
- }
-
-
- FT_BASE_DEF( void )
- ft_glyphslot_set_bitmap( FT_GlyphSlot slot,
- FT_Byte* buffer )
- {
- ft_glyphslot_free_bitmap( slot );
-
- slot->bitmap.buffer = buffer;
-
- FT_ASSERT( (slot->internal->flags & FT_GLYPH_OWN_BITMAP) == 0 );
- }
-
-
- FT_BASE_DEF( FT_Error )
- ft_glyphslot_alloc_bitmap( FT_GlyphSlot slot,
- FT_ULong size )
- {
- FT_Memory memory = FT_FACE_MEMORY( slot->face );
- FT_Error error;
-
-
- if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
- FT_FREE( slot->bitmap.buffer );
- else
- slot->internal->flags |= FT_GLYPH_OWN_BITMAP;
-
- FT_MEM_ALLOC( slot->bitmap.buffer, size );
- return error;
- }
-
-
- static void
- ft_glyphslot_clear( FT_GlyphSlot slot )
- {
- /* free bitmap if needed */
- ft_glyphslot_free_bitmap( slot );
-
- /* clear all public fields in the glyph slot */
- slot->glyph_index = 0;
-
- FT_ZERO( &slot->metrics );
- FT_ZERO( &slot->outline );
-
- slot->bitmap.width = 0;
- slot->bitmap.rows = 0;
- slot->bitmap.pitch = 0;
- slot->bitmap.pixel_mode = 0;
- /* `slot->bitmap.buffer' has been handled by ft_glyphslot_free_bitmap */
-
- slot->bitmap_left = 0;
- slot->bitmap_top = 0;
- slot->num_subglyphs = 0;
- slot->subglyphs = NULL;
- slot->control_data = NULL;
- slot->control_len = 0;
-
-#ifndef FT_CONFIG_OPTION_SVG
- slot->other = NULL;
-#else
- if ( !( slot->face->face_flags & FT_FACE_FLAG_SVG ) )
- slot->other = NULL;
- else
- {
- if ( slot->internal->flags & FT_GLYPH_OWN_GZIP_SVG )
- {
- FT_Memory memory = slot->face->memory;
- FT_SVG_Document doc = (FT_SVG_Document)slot->other;
-
-
- FT_FREE( doc->svg_document );
- slot->internal->flags &= ~FT_GLYPH_OWN_GZIP_SVG;
- }
- }
-#endif
-
- slot->format = FT_GLYPH_FORMAT_NONE;
-
- slot->linearHoriAdvance = 0;
- slot->linearVertAdvance = 0;
- slot->advance.x = 0;
- slot->advance.y = 0;
- slot->lsb_delta = 0;
- slot->rsb_delta = 0;
- }
-
-
- static void
- ft_glyphslot_done( FT_GlyphSlot slot )
- {
- FT_Driver driver = slot->face->driver;
- FT_Driver_Class clazz = driver->clazz;
- FT_Memory memory = driver->root.memory;
-
-#ifdef FT_CONFIG_OPTION_SVG
- if ( slot->face->face_flags & FT_FACE_FLAG_SVG )
- {
- /* Free memory in case SVG was there. */
- /* `slot->internal` might be NULL in out-of-memory situations. */
- if ( slot->internal && slot->internal->flags & FT_GLYPH_OWN_GZIP_SVG )
- {
- FT_SVG_Document doc = (FT_SVG_Document)slot->other;
-
-
- FT_FREE( doc->svg_document );
-
- slot->internal->flags &= ~FT_GLYPH_OWN_GZIP_SVG;
- }
-
- FT_FREE( slot->other );
- }
-#endif
-
- if ( clazz->done_slot )
- clazz->done_slot( slot );
-
- /* free bitmap buffer if needed */
- ft_glyphslot_free_bitmap( slot );
-
- /* slot->internal might be NULL in out-of-memory situations */
- if ( slot->internal )
- {
- /* free glyph loader */
- if ( FT_DRIVER_USES_OUTLINES( driver ) )
- {
- FT_GlyphLoader_Done( slot->internal->loader );
- slot->internal->loader = NULL;
- }
-
- FT_FREE( slot->internal );
- }
- }
-
-
- /* documentation is in ftobjs.h */
-
- FT_BASE_DEF( FT_Error )
- FT_New_GlyphSlot( FT_Face face,
- FT_GlyphSlot *aslot )
- {
- FT_Error error;
- FT_Driver driver;
- FT_Driver_Class clazz;
- FT_Memory memory;
- FT_GlyphSlot slot = NULL;
-
-
- if ( !face )
- return FT_THROW( Invalid_Face_Handle );
-
- if ( !face->driver )
- return FT_THROW( Invalid_Argument );
-
- driver = face->driver;
- clazz = driver->clazz;
- memory = driver->root.memory;
-
- FT_TRACE4(( "FT_New_GlyphSlot: Creating new slot object\n" ));
- if ( !FT_ALLOC( slot, clazz->slot_object_size ) )
- {
- slot->face = face;
-
- error = ft_glyphslot_init( slot );
- if ( error )
- {
- ft_glyphslot_done( slot );
- FT_FREE( slot );
- goto Exit;
- }
-
- slot->next = face->glyph;
- face->glyph = slot;
-
- if ( aslot )
- *aslot = slot;
- }
- else if ( aslot )
- *aslot = NULL;
-
-
- Exit:
- FT_TRACE4(( "FT_New_GlyphSlot: Return 0x%x\n", error ));
-
- return error;
- }
-
-
- /* documentation is in ftobjs.h */
-
- FT_BASE_DEF( void )
- FT_Done_GlyphSlot( FT_GlyphSlot slot )
- {
- if ( slot )
- {
- FT_Driver driver = slot->face->driver;
- FT_Memory memory = driver->root.memory;
- FT_GlyphSlot prev;
- FT_GlyphSlot cur;
-
-
- /* Remove slot from its parent face's list */
- prev = NULL;
- cur = slot->face->glyph;
-
- while ( cur )
- {
- if ( cur == slot )
- {
- if ( !prev )
- slot->face->glyph = cur->next;
- else
- prev->next = cur->next;
-
- /* finalize client-specific data */
- if ( slot->generic.finalizer )
- slot->generic.finalizer( slot );
-
- ft_glyphslot_done( slot );
- FT_FREE( slot );
- break;
- }
- prev = cur;
- cur = cur->next;
- }
- }
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( void )
- FT_Set_Transform( FT_Face face,
- FT_Matrix* matrix,
- FT_Vector* delta )
- {
- FT_Face_Internal internal;
-
-
- if ( !face )
- return;
-
- internal = face->internal;
-
- internal->transform_flags = 0;
-
- if ( !matrix )
- {
- internal->transform_matrix.xx = 0x10000L;
- internal->transform_matrix.xy = 0;
- internal->transform_matrix.yx = 0;
- internal->transform_matrix.yy = 0x10000L;
-
- matrix = &internal->transform_matrix;
- }
- else
- internal->transform_matrix = *matrix;
-
- /* set transform_flags bit flag 0 if `matrix' isn't the identity */
- if ( ( matrix->xy | matrix->yx ) ||
- matrix->xx != 0x10000L ||
- matrix->yy != 0x10000L )
- internal->transform_flags |= 1;
-
- if ( !delta )
- {
- internal->transform_delta.x = 0;
- internal->transform_delta.y = 0;
-
- delta = &internal->transform_delta;
- }
- else
- internal->transform_delta = *delta;
-
- /* set transform_flags bit flag 1 if `delta' isn't the null vector */
- if ( delta->x | delta->y )
- internal->transform_flags |= 2;
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( void )
- FT_Get_Transform( FT_Face face,
- FT_Matrix* matrix,
- FT_Vector* delta )
- {
- FT_Face_Internal internal;
-
-
- if ( !face )
- return;
-
- internal = face->internal;
-
- if ( matrix )
- *matrix = internal->transform_matrix;
-
- if ( delta )
- *delta = internal->transform_delta;
- }
-
-
- static FT_Renderer
- ft_lookup_glyph_renderer( FT_GlyphSlot slot );
-
-
-#ifdef GRID_FIT_METRICS
- static void
- ft_glyphslot_grid_fit_metrics( FT_GlyphSlot slot,
- FT_Bool vertical )
- {
- FT_Glyph_Metrics* metrics = &slot->metrics;
- FT_Pos right, bottom;
-
-
- if ( vertical )
- {
- metrics->horiBearingX = FT_PIX_FLOOR( metrics->horiBearingX );
- metrics->horiBearingY = FT_PIX_CEIL_LONG( metrics->horiBearingY );
-
- right = FT_PIX_CEIL_LONG( ADD_LONG( metrics->vertBearingX,
- metrics->width ) );
- bottom = FT_PIX_CEIL_LONG( ADD_LONG( metrics->vertBearingY,
- metrics->height ) );
-
- metrics->vertBearingX = FT_PIX_FLOOR( metrics->vertBearingX );
- metrics->vertBearingY = FT_PIX_FLOOR( metrics->vertBearingY );
-
- metrics->width = SUB_LONG( right,
- metrics->vertBearingX );
- metrics->height = SUB_LONG( bottom,
- metrics->vertBearingY );
- }
- else
- {
- metrics->vertBearingX = FT_PIX_FLOOR( metrics->vertBearingX );
- metrics->vertBearingY = FT_PIX_FLOOR( metrics->vertBearingY );
-
- right = FT_PIX_CEIL_LONG( ADD_LONG( metrics->horiBearingX,
- metrics->width ) );
- bottom = FT_PIX_FLOOR( SUB_LONG( metrics->horiBearingY,
- metrics->height ) );
-
- metrics->horiBearingX = FT_PIX_FLOOR( metrics->horiBearingX );
- metrics->horiBearingY = FT_PIX_CEIL_LONG( metrics->horiBearingY );
-
- metrics->width = SUB_LONG( right,
- metrics->horiBearingX );
- metrics->height = SUB_LONG( metrics->horiBearingY,
- bottom );
- }
-
- metrics->horiAdvance = FT_PIX_ROUND_LONG( metrics->horiAdvance );
- metrics->vertAdvance = FT_PIX_ROUND_LONG( metrics->vertAdvance );
- }
-#endif /* GRID_FIT_METRICS */
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Load_Glyph( FT_Face face,
- FT_UInt glyph_index,
- FT_Int32 load_flags )
- {
- FT_Error error;
- FT_Driver driver;
- FT_GlyphSlot slot;
- FT_Library library;
- FT_Bool autohint = FALSE;
- FT_Module hinter;
- TT_Face ttface = (TT_Face)face;
-
-
- if ( !face || !face->size || !face->glyph )
- return FT_THROW( Invalid_Face_Handle );
-
- /* The validity test for `glyph_index' is performed by the */
- /* font drivers. */
-
- slot = face->glyph;
- ft_glyphslot_clear( slot );
-
- driver = face->driver;
- library = driver->root.library;
- hinter = library->auto_hinter;
-
- /* undefined scale means no scale */
- if ( face->size->metrics.x_ppem == 0 ||
- face->size->metrics.y_ppem == 0 )
- load_flags |= FT_LOAD_NO_SCALE;
-
- /* resolve load flags dependencies */
-
- if ( load_flags & FT_LOAD_NO_RECURSE )
- load_flags |= FT_LOAD_NO_SCALE |
- FT_LOAD_IGNORE_TRANSFORM;
-
- if ( load_flags & FT_LOAD_NO_SCALE )
- {
- load_flags |= FT_LOAD_NO_HINTING |
- FT_LOAD_NO_BITMAP;
-
- load_flags &= ~FT_LOAD_RENDER;
- }
-
- if ( load_flags & FT_LOAD_BITMAP_METRICS_ONLY )
- load_flags &= ~FT_LOAD_RENDER;
-
- /*
- * Determine whether we need to auto-hint or not.
- * The general rules are:
- *
- * - Do only auto-hinting if we have
- *
- * - a hinter module,
- * - a scalable font,
- * - not a tricky font, and
- * - no transforms except simple slants and/or rotations by
- * integer multiples of 90 degrees.
- *
- * - Then, auto-hint if FT_LOAD_FORCE_AUTOHINT is set or if we don't
- * have a native font hinter.
- *
- * - Otherwise, auto-hint for LIGHT hinting mode or if there isn't
- * any hinting bytecode in the TrueType/OpenType font.
- *
- * - Exception: The font is `tricky' and requires the native hinter to
- * load properly.
- */
-
- if ( hinter &&
- !( load_flags & FT_LOAD_NO_HINTING ) &&
- !( load_flags & FT_LOAD_NO_AUTOHINT ) &&
- FT_IS_SCALABLE( face ) &&
- !FT_IS_TRICKY( face ) &&
- ( ( load_flags & FT_LOAD_IGNORE_TRANSFORM ) ||
- ( face->internal->transform_matrix.yx == 0 &&
- face->internal->transform_matrix.xx != 0 ) ||
- ( face->internal->transform_matrix.xx == 0 &&
- face->internal->transform_matrix.yx != 0 ) ) )
- {
- if ( ( load_flags & FT_LOAD_FORCE_AUTOHINT ) ||
- !FT_DRIVER_HAS_HINTER( driver ) )
- autohint = TRUE;
- else
- {
- FT_Render_Mode mode = FT_LOAD_TARGET_MODE( load_flags );
- FT_Bool is_light_type1;
-
-
- /* only the new Adobe engine (for both CFF and Type 1) is `light'; */
- /* we use `strstr' to catch both `Type 1' and `CID Type 1' */
- is_light_type1 =
- ft_strstr( FT_Get_Font_Format( face ), "Type 1" ) != NULL &&
- ((PS_Driver)driver)->hinting_engine == FT_HINTING_ADOBE;
-
- /* the check for `num_locations' assures that we actually */
- /* test for instructions in a TTF and not in a CFF-based OTF */
- /* */
- /* since `maxSizeOfInstructions' might be unreliable, we */
- /* check the size of the `fpgm' and `prep' tables, too -- */
- /* the assumption is that there don't exist real TTFs where */
- /* both `fpgm' and `prep' tables are missing */
- if ( ( mode == FT_RENDER_MODE_LIGHT &&
- ( !FT_DRIVER_HINTS_LIGHTLY( driver ) &&
- !is_light_type1 ) ) ||
- ( FT_IS_SFNT( face ) &&
- ttface->num_locations &&
- ttface->max_profile.maxSizeOfInstructions == 0 &&
- ttface->font_program_size == 0 &&
- ttface->cvt_program_size == 0 ) )
- autohint = TRUE;
- }
- }
-
- if ( autohint )
- {
- FT_AutoHinter_Interface hinting;
-
-
- /* XXX: The use of the `FT_LOAD_XXX_ONLY` flags is not very */
- /* elegant. */
-
- /* try to load SVG documents if available */
- if ( ( load_flags & FT_LOAD_NO_SVG ) == 0 &&
- FT_HAS_SVG( face ) )
- {
- error = driver->clazz->load_glyph( slot, face->size,
- glyph_index,
- load_flags | FT_LOAD_SVG_ONLY );
-
- if ( !error && slot->format == FT_GLYPH_FORMAT_SVG )
- goto Load_Ok;
- }
-
- /* try to load embedded bitmaps if available */
- if ( FT_HAS_FIXED_SIZES( face ) &&
- ( load_flags & FT_LOAD_NO_BITMAP ) == 0 )
- {
- error = driver->clazz->load_glyph( slot, face->size,
- glyph_index,
- load_flags | FT_LOAD_SBITS_ONLY );
-
- if ( !error && slot->format == FT_GLYPH_FORMAT_BITMAP )
- goto Load_Ok;
- }
-
- {
- FT_Face_Internal internal = face->internal;
- FT_Int transform_flags = internal->transform_flags;
-
-
- /* since the auto-hinter calls FT_Load_Glyph by itself, */
- /* make sure that glyphs aren't transformed */
- internal->transform_flags = 0;
-
- /* load auto-hinted outline */
- hinting = (FT_AutoHinter_Interface)hinter->clazz->module_interface;
-
- error = hinting->load_glyph( (FT_AutoHinter)hinter,
- slot, face->size,
- glyph_index, load_flags );
-
- internal->transform_flags = transform_flags;
- }
- }
- else
- {
- error = driver->clazz->load_glyph( slot,
- face->size,
- glyph_index,
- load_flags );
- if ( error )
- goto Exit;
-
- if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
- {
- /* check that the loaded outline is correct */
- error = FT_Outline_Check( &slot->outline );
- if ( error )
- goto Exit;
-
-#ifdef GRID_FIT_METRICS
- if ( !( load_flags & FT_LOAD_NO_HINTING ) )
- ft_glyphslot_grid_fit_metrics(
- slot,
- FT_BOOL( load_flags & FT_LOAD_VERTICAL_LAYOUT ) );
-#endif
- }
- }
-
- Load_Ok:
- /* compute the advance */
- if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
- {
- slot->advance.x = 0;
- slot->advance.y = slot->metrics.vertAdvance;
- }
- else
- {
- slot->advance.x = slot->metrics.horiAdvance;
- slot->advance.y = 0;
- }
-
- /* compute the linear advance in 16.16 pixels */
- if ( ( load_flags & FT_LOAD_LINEAR_DESIGN ) == 0 &&
- FT_IS_SCALABLE( face ) )
- {
- FT_Size_Metrics* metrics = &face->size->metrics;
-
-
- /* it's tricky! */
- slot->linearHoriAdvance = FT_MulDiv( slot->linearHoriAdvance,
- metrics->x_scale, 64 );
-
- slot->linearVertAdvance = FT_MulDiv( slot->linearVertAdvance,
- metrics->y_scale, 64 );
- }
-
- if ( ( load_flags & FT_LOAD_IGNORE_TRANSFORM ) == 0 )
- {
- FT_Face_Internal internal = face->internal;
-
-
- /* now, transform the glyph image if needed */
- if ( internal->transform_flags )
- {
- /* get renderer */
- FT_Renderer renderer = ft_lookup_glyph_renderer( slot );
-
-
- if ( renderer )
- error = renderer->clazz->transform_glyph(
- renderer, slot,
- &internal->transform_matrix,
- &internal->transform_delta );
- else if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
- {
- /* apply `standard' transformation if no renderer is available */
- if ( internal->transform_flags & 1 )
- FT_Outline_Transform( &slot->outline,
- &internal->transform_matrix );
-
- if ( internal->transform_flags & 2 )
- FT_Outline_Translate( &slot->outline,
- internal->transform_delta.x,
- internal->transform_delta.y );
- }
-
- /* transform advance */
- FT_Vector_Transform( &slot->advance, &internal->transform_matrix );
- }
- }
-
- slot->glyph_index = glyph_index;
- slot->internal->load_flags = load_flags;
-
- /* do we need to render the image or preset the bitmap now? */
- if ( !error &&
- ( load_flags & FT_LOAD_NO_SCALE ) == 0 &&
- slot->format != FT_GLYPH_FORMAT_BITMAP &&
- slot->format != FT_GLYPH_FORMAT_COMPOSITE )
- {
- FT_Render_Mode mode = FT_LOAD_TARGET_MODE( load_flags );
-
-
- if ( mode == FT_RENDER_MODE_NORMAL &&
- load_flags & FT_LOAD_MONOCHROME )
- mode = FT_RENDER_MODE_MONO;
-
- if ( load_flags & FT_LOAD_RENDER )
- error = FT_Render_Glyph( slot, mode );
- else
- ft_glyphslot_preset_bitmap( slot, mode, NULL );
- }
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- FT_TRACE5(( "FT_Load_Glyph: index %d, flags 0x%x\n",
- glyph_index, load_flags ));
- FT_TRACE5(( " bitmap %dx%d %s, %s (mode %d)\n",
- slot->bitmap.width,
- slot->bitmap.rows,
- slot->outline.points ?
- slot->bitmap.buffer ? "rendered"
- : "preset"
- :
- slot->internal->flags & FT_GLYPH_OWN_BITMAP ? "owned"
- : "unowned",
- pixel_modes[slot->bitmap.pixel_mode],
- slot->bitmap.pixel_mode ));
- FT_TRACE5(( "\n" ));
- FT_TRACE5(( " x advance: %f\n", (double)slot->advance.x / 64 ));
- FT_TRACE5(( " y advance: %f\n", (double)slot->advance.y / 64 ));
- FT_TRACE5(( " linear x advance: %f\n",
- (double)slot->linearHoriAdvance / 65536 ));
- FT_TRACE5(( " linear y advance: %f\n",
- (double)slot->linearVertAdvance / 65536 ));
-
- {
- FT_Glyph_Metrics* metrics = &slot->metrics;
-
-
- FT_TRACE5(( " metrics:\n" ));
- FT_TRACE5(( " width: %f\n", (double)metrics->width / 64 ));
- FT_TRACE5(( " height: %f\n", (double)metrics->height / 64 ));
- FT_TRACE5(( "\n" ));
- FT_TRACE5(( " horiBearingX: %f\n",
- (double)metrics->horiBearingX / 64 ));
- FT_TRACE5(( " horiBearingY: %f\n",
- (double)metrics->horiBearingY / 64 ));
- FT_TRACE5(( " horiAdvance: %f\n",
- (double)metrics->horiAdvance / 64 ));
- FT_TRACE5(( "\n" ));
- FT_TRACE5(( " vertBearingX: %f\n",
- (double)metrics->vertBearingX / 64 ));
- FT_TRACE5(( " vertBearingY: %f\n",
- (double)metrics->vertBearingY / 64 ));
- FT_TRACE5(( " vertAdvance: %f\n",
- (double)metrics->vertAdvance / 64 ));
- }
-#endif
-
- Exit:
- return error;
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Load_Char( FT_Face face,
- FT_ULong char_code,
- FT_Int32 load_flags )
- {
- FT_UInt glyph_index;
-
-
- if ( !face )
- return FT_THROW( Invalid_Face_Handle );
-
- glyph_index = (FT_UInt)char_code;
- if ( face->charmap )
- glyph_index = FT_Get_Char_Index( face, char_code );
-
- return FT_Load_Glyph( face, glyph_index, load_flags );
- }
-
-
- /* destructor for sizes list */
- static void
- destroy_size( FT_Memory memory,
- void* size_,
- void* driver_ )
- {
- FT_Size size = (FT_Size)size_;
- FT_Driver driver = (FT_Driver)driver_;
-
-
- /* finalize client-specific data */
- if ( size->generic.finalizer )
- size->generic.finalizer( size );
-
- /* finalize format-specific stuff */
- if ( driver->clazz->done_size )
- driver->clazz->done_size( size );
-
- FT_FREE( size->internal );
- FT_FREE( size );
- }
-
-
- static void
- ft_cmap_done_internal( FT_CMap cmap );
-
-
- static void
- destroy_charmaps( FT_Face face,
- FT_Memory memory )
- {
- FT_Int n;
-
-
- if ( !face )
- return;
-
- for ( n = 0; n < face->num_charmaps; n++ )
- {
- FT_CMap cmap = FT_CMAP( face->charmaps[n] );
-
-
- ft_cmap_done_internal( cmap );
-
- face->charmaps[n] = NULL;
- }
-
- FT_FREE( face->charmaps );
- face->num_charmaps = 0;
- }
-
-
- /* destructor for faces list */
- static void
- destroy_face( FT_Memory memory,
- void* face_,
- void* driver_ )
- {
- FT_Face face = (FT_Face)face_;
- FT_Driver driver = (FT_Driver)driver_;
- FT_Driver_Class clazz = driver->clazz;
-
-
- /* discard auto-hinting data */
- if ( face->autohint.finalizer )
- face->autohint.finalizer( face->autohint.data );
-
- /* Discard glyph slots for this face. */
- /* Beware! FT_Done_GlyphSlot() changes the field `face->glyph' */
- while ( face->glyph )
- FT_Done_GlyphSlot( face->glyph );
-
- /* discard all sizes for this face */
- FT_List_Finalize( &face->sizes_list,
- destroy_size,
- memory,
- driver );
- face->size = NULL;
-
- /* now discard client data */
- if ( face->generic.finalizer )
- face->generic.finalizer( face );
-
- /* discard charmaps */
- destroy_charmaps( face, memory );
-
- /* finalize format-specific stuff */
- if ( clazz->done_face )
- clazz->done_face( face );
-
- /* close the stream for this face if needed */
- FT_Stream_Free(
- face->stream,
- ( face->face_flags & FT_FACE_FLAG_EXTERNAL_STREAM ) != 0 );
-
- face->stream = NULL;
-
- /* get rid of it */
- if ( face->internal )
- {
- FT_FREE( face->internal );
- }
- FT_FREE( face );
- }
-
-
- static void
- Destroy_Driver( FT_Driver driver )
- {
- FT_List_Finalize( &driver->faces_list,
- destroy_face,
- driver->root.memory,
- driver );
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * find_unicode_charmap
- *
- * @Description:
- * This function finds a Unicode charmap, if there is one.
- * And if there is more than one, it tries to favour the more
- * extensive one, i.e., one that supports UCS-4 against those which
- * are limited to the BMP (said UCS-2 encoding.)
- *
- * This function is called from open_face() (just below), and also
- * from FT_Select_Charmap( ..., FT_ENCODING_UNICODE ).
- */
- static FT_Error
- find_unicode_charmap( FT_Face face )
- {
- FT_CharMap* first;
- FT_CharMap* cur;
-
-
- /* caller should have already checked that `face' is valid */
- FT_ASSERT( face );
-
- first = face->charmaps;
-
- if ( !first )
- return FT_THROW( Invalid_CharMap_Handle );
-
- /*
- * The original TrueType specification(s) only specified charmap
- * formats that are capable of mapping 8 or 16 bit character codes to
- * glyph indices.
- *
- * However, recent updates to the Apple and OpenType specifications
- * introduced new formats that are capable of mapping 32-bit character
- * codes as well. And these are already used on some fonts, mainly to
- * map non-BMP Asian ideographs as defined in Unicode.
- *
- * For compatibility purposes, these fonts generally come with
- * *several* Unicode charmaps:
- *
- * - One of them in the "old" 16-bit format, that cannot access
- * all glyphs in the font.
- *
- * - Another one in the "new" 32-bit format, that can access all
- * the glyphs.
- *
- * This function has been written to always favor a 32-bit charmap
- * when found. Otherwise, a 16-bit one is returned when found.
- */
-
- /* Since the `interesting' table, with IDs (3,10), is normally the */
- /* last one, we loop backwards. This loses with type1 fonts with */
- /* non-BMP characters (<.0001%), this wins with .ttf with non-BMP */
- /* chars (.01% ?), and this is the same about 99.99% of the time! */
-
- cur = first + face->num_charmaps; /* points after the last one */
-
- for ( ; --cur >= first; )
- {
- if ( cur[0]->encoding == FT_ENCODING_UNICODE )
- {
- /* XXX If some new encodings to represent UCS-4 are added, */
- /* they should be added here. */
- if ( ( cur[0]->platform_id == TT_PLATFORM_MICROSOFT &&
- cur[0]->encoding_id == TT_MS_ID_UCS_4 ) ||
- ( cur[0]->platform_id == TT_PLATFORM_APPLE_UNICODE &&
- cur[0]->encoding_id == TT_APPLE_ID_UNICODE_32 ) )
- {
- face->charmap = cur[0];
- return FT_Err_Ok;
- }
- }
- }
-
- /* We do not have any UCS-4 charmap. */
- /* Do the loop again and search for UCS-2 charmaps. */
- cur = first + face->num_charmaps;
-
- for ( ; --cur >= first; )
- {
- if ( cur[0]->encoding == FT_ENCODING_UNICODE )
- {
- face->charmap = cur[0];
- return FT_Err_Ok;
- }
- }
-
- return FT_THROW( Invalid_CharMap_Handle );
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * find_variant_selector_charmap
- *
- * @Description:
- * This function finds the variant selector charmap, if there is one.
- * There can only be one (platform=0, specific=5, format=14).
- */
- static FT_CharMap
- find_variant_selector_charmap( FT_Face face )
- {
- FT_CharMap* first;
- FT_CharMap* end;
- FT_CharMap* cur;
-
-
- /* caller should have already checked that `face' is valid */
- FT_ASSERT( face );
-
- first = face->charmaps;
-
- if ( !first )
- return NULL;
-
- end = first + face->num_charmaps; /* points after the last one */
-
- for ( cur = first; cur < end; cur++ )
- {
- if ( cur[0]->platform_id == TT_PLATFORM_APPLE_UNICODE &&
- cur[0]->encoding_id == TT_APPLE_ID_VARIANT_SELECTOR &&
- FT_Get_CMap_Format( cur[0] ) == 14 )
- return cur[0];
- }
-
- return NULL;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * open_face
- *
- * @Description:
- * This function does some work for FT_Open_Face().
- */
- static FT_Error
- open_face( FT_Driver driver,
- FT_Stream *astream,
- FT_Bool *anexternal_stream,
- FT_Long face_index,
- FT_Int num_params,
- FT_Parameter* params,
- FT_Face *aface )
- {
- FT_Memory memory;
- FT_Driver_Class clazz;
- FT_Face face = NULL;
- FT_Face_Internal internal = NULL;
-
- FT_Error error, error2;
-
-
- clazz = driver->clazz;
- memory = driver->root.memory;
-
- /* allocate the face object and perform basic initialization */
- if ( FT_ALLOC( face, clazz->face_object_size ) )
- goto Fail;
-
- face->driver = driver;
- face->memory = memory;
- face->stream = *astream;
-
- /* set the FT_FACE_FLAG_EXTERNAL_STREAM bit for FT_Done_Face */
- if ( *anexternal_stream )
- face->face_flags |= FT_FACE_FLAG_EXTERNAL_STREAM;
-
- if ( FT_NEW( internal ) )
- goto Fail;
-
- face->internal = internal;
-
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- {
- int i;
-
-
- face->internal->incremental_interface = NULL;
- for ( i = 0; i < num_params && !face->internal->incremental_interface;
- i++ )
- if ( params[i].tag == FT_PARAM_TAG_INCREMENTAL )
- face->internal->incremental_interface =
- (FT_Incremental_Interface)params[i].data;
- }
-#endif
-
- face->internal->random_seed = -1;
-
- if ( clazz->init_face )
- error = clazz->init_face( *astream,
- face,
- (FT_Int)face_index,
- num_params,
- params );
- /* Stream may have been changed. */
- *astream = face->stream;
- *anexternal_stream =
- ( face->face_flags & FT_FACE_FLAG_EXTERNAL_STREAM ) != 0;
- if ( error )
- goto Fail;
-
- /* select Unicode charmap by default */
- error2 = find_unicode_charmap( face );
-
- /* if no Unicode charmap can be found, FT_Err_Invalid_CharMap_Handle */
- /* is returned. */
-
- /* no error should happen, but we want to play safe */
- if ( error2 && FT_ERR_NEQ( error2, Invalid_CharMap_Handle ) )
- {
- error = error2;
- goto Fail;
- }
-
- *aface = face;
-
- Fail:
- if ( error )
- {
- destroy_charmaps( face, memory );
- if ( clazz->done_face )
- clazz->done_face( face );
- FT_FREE( internal );
- FT_FREE( face );
- *aface = NULL;
- }
-
- return error;
- }
-
-
- /* there's a Mac-specific extended implementation of FT_New_Face() */
- /* in src/base/ftmac.c */
-
-#ifndef FT_MACINTOSH
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_New_Face( FT_Library library,
- const char* pathname,
- FT_Long face_index,
- FT_Face *aface )
- {
- FT_Open_Args args;
-
-
- /* test for valid `library' and `aface' delayed to `FT_Open_Face' */
- if ( !pathname )
- return FT_THROW( Invalid_Argument );
-
- args.flags = FT_OPEN_PATHNAME;
- args.pathname = (char*)pathname;
- args.stream = NULL;
-
- return ft_open_face_internal( library, &args, face_index, aface, 1 );
- }
-
-#endif
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_New_Memory_Face( FT_Library library,
- const FT_Byte* file_base,
- FT_Long file_size,
- FT_Long face_index,
- FT_Face *aface )
- {
- FT_Open_Args args;
-
-
- /* test for valid `library' and `face' delayed to `FT_Open_Face' */
- if ( !file_base )
- return FT_THROW( Invalid_Argument );
-
- args.flags = FT_OPEN_MEMORY;
- args.memory_base = file_base;
- args.memory_size = file_size;
- args.stream = NULL;
-
- return ft_open_face_internal( library, &args, face_index, aface, 1 );
- }
-
-
-#ifdef FT_CONFIG_OPTION_MAC_FONTS
-
- /* The behavior here is very similar to that in base/ftmac.c, but it */
- /* is designed to work on non-mac systems, so no mac specific calls. */
- /* */
- /* We look at the file and determine if it is a mac dfont file or a mac */
- /* resource file, or a macbinary file containing a mac resource file. */
- /* */
- /* Unlike ftmac I'm not going to look at a `FOND'. I don't really see */
- /* the point, especially since there may be multiple `FOND' resources. */
- /* Instead I'll just look for `sfnt' and `POST' resources, ordered as */
- /* they occur in the file. */
- /* */
- /* Note that multiple `POST' resources do not mean multiple postscript */
- /* fonts; they all get jammed together to make what is essentially a */
- /* pfb file. */
- /* */
- /* We aren't interested in `NFNT' or `FONT' bitmap resources. */
- /* */
- /* As soon as we get an `sfnt' load it into memory and pass it off to */
- /* FT_Open_Face. */
- /* */
- /* If we have a (set of) `POST' resources, massage them into a (memory) */
- /* pfb file and pass that to FT_Open_Face. (As with ftmac.c I'm not */
- /* going to try to save the kerning info. After all that lives in the */
- /* `FOND' which isn't in the file containing the `POST' resources so */
- /* we don't really have access to it. */
-
-
- /* Finalizer for a memory stream; gets called by FT_Done_Face(). */
- /* It frees the memory it uses. */
- /* From `ftmac.c'. */
- static void
- memory_stream_close( FT_Stream stream )
- {
- FT_Memory memory = (FT_Memory)stream->descriptor.pointer;
-
-
- FT_FREE( stream->base );
- stream->size = 0;
- stream->close = NULL;
- FT_FREE( stream );
- }
-
-
- /* Create a new memory stream from a buffer and a size. */
- /* From `ftmac.c'. */
- static FT_Error
- new_memory_stream( FT_Library library,
- FT_Byte* base,
- FT_ULong size,
- FT_Stream_CloseFunc close,
- FT_Stream *astream )
- {
- FT_Error error;
- FT_Memory memory;
- FT_Stream stream = NULL;
-
-
- if ( !library )
- return FT_THROW( Invalid_Library_Handle );
-
- if ( !base )
- return FT_THROW( Invalid_Argument );
-
- *astream = NULL;
- memory = library->memory;
- if ( FT_NEW( stream ) )
- goto Exit;
-
- FT_Stream_OpenMemory( stream, base, size );
-
- stream->descriptor.pointer = memory;
- stream->close = close;
-
- *astream = stream;
-
- Exit:
- return error;
- }
-
-
- /* Create a new FT_Face given a buffer and a driver name. */
- /* From `ftmac.c'. */
- FT_LOCAL_DEF( FT_Error )
- open_face_from_buffer( FT_Library library,
- FT_Byte* base,
- FT_ULong size,
- FT_Long face_index,
- const char* driver_name,
- FT_Face *aface )
- {
- FT_Open_Args args;
- FT_Error error;
- FT_Memory memory = library->memory;
-
-
- args.driver = NULL;
- args.flags = 0;
-
- if ( driver_name )
- {
- args.driver = FT_Get_Module( library, driver_name );
- if ( !args.driver )
- {
- FT_FREE( base );
- return FT_THROW( Missing_Module );
- }
-
- args.flags = args.flags | FT_OPEN_DRIVER;
- }
-
- /* `memory_stream_close` also frees the stream object. */
- error = new_memory_stream( library,
- base,
- size,
- memory_stream_close,
- &args.stream );
- if ( error )
- {
- FT_FREE( base );
- return error;
- }
-
- args.flags |= FT_OPEN_STREAM;
-
-#ifdef FT_MACINTOSH
- /* At this point, the face index has served its purpose; */
- /* whoever calls this function has already used it to */
- /* locate the correct font data. We should not propagate */
- /* this index to FT_Open_Face() (unless it is negative). */
-
- if ( face_index > 0 )
- face_index &= 0x7FFF0000L; /* retain GX data */
-#endif
-
- return ft_open_face_internal( library, &args, face_index, aface, 0 );
- }
-
-
- /* Look up `TYP1' or `CID ' table from sfnt table directory. */
- /* `offset' and `length' must exclude the binary header in tables. */
-
- /* Type 1 and CID-keyed font drivers should recognize sfnt-wrapped */
- /* format too. Here, since we can't expect that the TrueType font */
- /* driver is loaded unconditionally, we must parse the font by */
- /* ourselves. We are only interested in the name of the table and */
- /* the offset. */
-
- static FT_Error
- ft_lookup_PS_in_sfnt_stream( FT_Stream stream,
- FT_Long face_index,
- FT_ULong* offset,
- FT_ULong* length,
- FT_Bool* is_sfnt_cid )
- {
- FT_Error error;
- FT_UShort numTables;
- FT_Long pstable_index;
- FT_ULong tag;
- int i;
-
-
- *offset = 0;
- *length = 0;
- *is_sfnt_cid = FALSE;
-
- /* TODO: support for sfnt-wrapped PS/CID in TTC format */
-
- /* version check for 'typ1' (should be ignored?) */
- if ( FT_READ_ULONG( tag ) )
- return error;
- if ( tag != TTAG_typ1 )
- return FT_THROW( Unknown_File_Format );
-
- if ( FT_READ_USHORT( numTables ) )
- return error;
- if ( FT_STREAM_SKIP( 2 * 3 ) ) /* skip binary search header */
- return error;
-
- pstable_index = -1;
- *is_sfnt_cid = FALSE;
-
- for ( i = 0; i < numTables; i++ )
- {
- if ( FT_READ_ULONG( tag ) || FT_STREAM_SKIP( 4 ) ||
- FT_READ_ULONG( *offset ) || FT_READ_ULONG( *length ) )
- return error;
-
- if ( tag == TTAG_CID )
- {
- pstable_index++;
- *offset += 22;
- *length -= 22;
- *is_sfnt_cid = TRUE;
- if ( face_index < 0 )
- return FT_Err_Ok;
- }
- else if ( tag == TTAG_TYP1 )
- {
- pstable_index++;
- *offset += 24;
- *length -= 24;
- *is_sfnt_cid = FALSE;
- if ( face_index < 0 )
- return FT_Err_Ok;
- }
- if ( face_index >= 0 && pstable_index == face_index )
- return FT_Err_Ok;
- }
-
- return FT_THROW( Table_Missing );
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- open_face_PS_from_sfnt_stream( FT_Library library,
- FT_Stream stream,
- FT_Long face_index,
- FT_Int num_params,
- FT_Parameter *params,
- FT_Face *aface )
- {
- FT_Error error;
- FT_Memory memory = library->memory;
- FT_ULong offset, length;
- FT_ULong pos;
- FT_Bool is_sfnt_cid;
- FT_Byte* sfnt_ps = NULL;
-
- FT_UNUSED( num_params );
- FT_UNUSED( params );
-
-
- /* ignore GX stuff */
- if ( face_index > 0 )
- face_index &= 0xFFFFL;
-
- pos = FT_STREAM_POS();
-
- error = ft_lookup_PS_in_sfnt_stream( stream,
- face_index,
- &offset,
- &length,
- &is_sfnt_cid );
- if ( error )
- goto Exit;
-
- if ( offset > stream->size )
- {
- FT_TRACE2(( "open_face_PS_from_sfnt_stream: invalid table offset\n" ));
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
- else if ( length > stream->size - offset )
- {
- FT_TRACE2(( "open_face_PS_from_sfnt_stream: invalid table length\n" ));
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- error = FT_Stream_Seek( stream, pos + offset );
- if ( error )
- goto Exit;
-
- if ( FT_QALLOC( sfnt_ps, (FT_Long)length ) )
- goto Exit;
-
- error = FT_Stream_Read( stream, (FT_Byte *)sfnt_ps, length );
- if ( error )
- {
- FT_FREE( sfnt_ps );
- goto Exit;
- }
-
- error = open_face_from_buffer( library,
- sfnt_ps,
- length,
- FT_MIN( face_index, 0 ),
- is_sfnt_cid ? "t1cid" : "type1",
- aface );
- Exit:
- {
- FT_Error error1;
-
-
- if ( FT_ERR_EQ( error, Unknown_File_Format ) )
- {
- error1 = FT_Stream_Seek( stream, pos );
- if ( error1 )
- return error1;
- }
-
- return error;
- }
- }
-
-
-#ifndef FT_MACINTOSH
-
- /* The resource header says we've got resource_cnt `POST' (type1) */
- /* resources in this file. They all need to be coalesced into */
- /* one lump which gets passed on to the type1 driver. */
- /* Here can be only one PostScript font in a file so face_index */
- /* must be 0 (or -1). */
- /* */
- static FT_Error
- Mac_Read_POST_Resource( FT_Library library,
- FT_Stream stream,
- FT_Long *offsets,
- FT_Long resource_cnt,
- FT_Long face_index,
- FT_Face *aface )
- {
- FT_Error error = FT_ERR( Cannot_Open_Resource );
- FT_Memory memory = library->memory;
-
- FT_Byte* pfb_data = NULL;
- int i, type, flags;
- FT_ULong len;
- FT_ULong pfb_len, pfb_pos, pfb_lenpos;
- FT_ULong rlen, temp;
-
-
- if ( face_index == -1 )
- face_index = 0;
- if ( face_index != 0 )
- return error;
-
- /* Find the length of all the POST resources, concatenated. Assume */
- /* worst case (each resource in its own section). */
- pfb_len = 0;
- for ( i = 0; i < resource_cnt; i++ )
- {
- error = FT_Stream_Seek( stream, (FT_ULong)offsets[i] );
- if ( error )
- goto Exit;
- if ( FT_READ_ULONG( temp ) ) /* actually LONG */
- goto Exit;
-
- /* FT2 allocator takes signed long buffer length,
- * too large value causing overflow should be checked
- */
- FT_TRACE4(( " POST fragment #%d: length=0x%08lx"
- " total pfb_len=0x%08lx\n",
- i, temp, pfb_len + temp + 6 ));
-
- if ( FT_MAC_RFORK_MAX_LEN < temp ||
- FT_MAC_RFORK_MAX_LEN - temp < pfb_len + 6 )
- {
- FT_TRACE2(( " MacOS resource length cannot exceed"
- " 0x%08lx\n",
- FT_MAC_RFORK_MAX_LEN ));
-
- error = FT_THROW( Invalid_Offset );
- goto Exit;
- }
-
- pfb_len += temp + 6;
- }
-
- FT_TRACE2(( " total buffer size to concatenate"
- " %ld POST fragments: 0x%08lx\n",
- resource_cnt, pfb_len + 2 ));
-
- if ( pfb_len + 2 < 6 )
- {
- FT_TRACE2(( " too long fragment length makes"
- " pfb_len confused: pfb_len=0x%08lx\n",
- pfb_len ));
-
- error = FT_THROW( Array_Too_Large );
- goto Exit;
- }
-
- if ( FT_QALLOC( pfb_data, (FT_Long)pfb_len + 2 ) )
- goto Exit;
-
- pfb_data[0] = 0x80;
- pfb_data[1] = 1; /* Ascii section */
- pfb_data[2] = 0; /* 4-byte length, fill in later */
- pfb_data[3] = 0;
- pfb_data[4] = 0;
- pfb_data[5] = 0;
- pfb_pos = 6;
- pfb_lenpos = 2;
-
- len = 0;
- type = 1;
-
- for ( i = 0; i < resource_cnt; i++ )
- {
- error = FT_Stream_Seek( stream, (FT_ULong)offsets[i] );
- if ( error )
- goto Exit2;
- if ( FT_READ_ULONG( rlen ) )
- goto Exit2;
-
- /* FT2 allocator takes signed long buffer length,
- * too large fragment length causing overflow should be checked
- */
- if ( 0x7FFFFFFFUL < rlen )
- {
- error = FT_THROW( Invalid_Offset );
- goto Exit2;
- }
-
- if ( FT_READ_USHORT( flags ) )
- goto Exit2;
-
- FT_TRACE3(( "POST fragment[%d]:"
- " offsets=0x%08lx, rlen=0x%08lx, flags=0x%04x\n",
- i, offsets[i], rlen, flags ));
-
- error = FT_ERR( Array_Too_Large );
-
- /* postpone the check of `rlen longer than buffer' */
- /* until `FT_Stream_Read' */
-
- if ( ( flags >> 8 ) == 0 ) /* Comment, should not be loaded */
- {
- FT_TRACE3(( " Skip POST fragment #%d because it is a comment\n",
- i ));
- continue;
- }
-
- /* the flags are part of the resource, so rlen >= 2, */
- /* but some fonts declare rlen = 0 for empty fragment */
- if ( rlen > 2 )
- rlen -= 2;
- else
- rlen = 0;
-
- if ( ( flags >> 8 ) == type )
- len += rlen;
- else
- {
- FT_TRACE3(( " Write POST fragment #%d header (4-byte) to buffer"
- " %p + 0x%08lx\n",
- i, (void*)pfb_data, pfb_lenpos ));
-
- if ( pfb_lenpos + 3 > pfb_len + 2 )
- goto Exit2;
-
- pfb_data[pfb_lenpos ] = (FT_Byte)( len );
- pfb_data[pfb_lenpos + 1] = (FT_Byte)( len >> 8 );
- pfb_data[pfb_lenpos + 2] = (FT_Byte)( len >> 16 );
- pfb_data[pfb_lenpos + 3] = (FT_Byte)( len >> 24 );
-
- if ( ( flags >> 8 ) == 5 ) /* End of font mark */
- break;
-
- FT_TRACE3(( " Write POST fragment #%d header (6-byte) to buffer"
- " %p + 0x%08lx\n",
- i, (void*)pfb_data, pfb_pos ));
-
- if ( pfb_pos + 6 > pfb_len + 2 )
- goto Exit2;
-
- pfb_data[pfb_pos++] = 0x80;
-
- type = flags >> 8;
- len = rlen;
-
- pfb_data[pfb_pos++] = (FT_Byte)type;
- pfb_lenpos = pfb_pos;
- pfb_data[pfb_pos++] = 0; /* 4-byte length, fill in later */
- pfb_data[pfb_pos++] = 0;
- pfb_data[pfb_pos++] = 0;
- pfb_data[pfb_pos++] = 0;
- }
-
- if ( pfb_pos > pfb_len || pfb_pos + rlen > pfb_len )
- goto Exit2;
-
- FT_TRACE3(( " Load POST fragment #%d (%ld byte) to buffer"
- " %p + 0x%08lx\n",
- i, rlen, (void*)pfb_data, pfb_pos ));
-
- error = FT_Stream_Read( stream, (FT_Byte *)pfb_data + pfb_pos, rlen );
- if ( error )
- goto Exit2;
-
- pfb_pos += rlen;
- }
-
- error = FT_ERR( Array_Too_Large );
-
- if ( pfb_pos + 2 > pfb_len + 2 )
- goto Exit2;
- pfb_data[pfb_pos++] = 0x80;
- pfb_data[pfb_pos++] = 3;
-
- if ( pfb_lenpos + 3 > pfb_len + 2 )
- goto Exit2;
- pfb_data[pfb_lenpos ] = (FT_Byte)( len );
- pfb_data[pfb_lenpos + 1] = (FT_Byte)( len >> 8 );
- pfb_data[pfb_lenpos + 2] = (FT_Byte)( len >> 16 );
- pfb_data[pfb_lenpos + 3] = (FT_Byte)( len >> 24 );
-
- return open_face_from_buffer( library,
- pfb_data,
- pfb_pos,
- face_index,
- "type1",
- aface );
-
- Exit2:
- if ( FT_ERR_EQ( error, Array_Too_Large ) )
- FT_TRACE2(( " Abort due to too-short buffer to store"
- " all POST fragments\n" ));
- else if ( FT_ERR_EQ( error, Invalid_Offset ) )
- FT_TRACE2(( " Abort due to invalid offset in a POST fragment\n" ));
-
- if ( error )
- error = FT_ERR( Cannot_Open_Resource );
- FT_FREE( pfb_data );
-
- Exit:
- return error;
- }
-
-
- /* The resource header says we've got resource_cnt `sfnt' */
- /* (TrueType/OpenType) resources in this file. Look through */
- /* them for the one indicated by face_index, load it into mem, */
- /* pass it on to the truetype driver, and return it. */
- /* */
- static FT_Error
- Mac_Read_sfnt_Resource( FT_Library library,
- FT_Stream stream,
- FT_Long *offsets,
- FT_Long resource_cnt,
- FT_Long face_index,
- FT_Face *aface )
- {
- FT_Memory memory = library->memory;
- FT_Byte* sfnt_data = NULL;
- FT_Error error;
- FT_ULong flag_offset;
- FT_ULong rlen;
- int is_cff;
- FT_Long face_index_in_resource = 0;
-
-
- if ( face_index < 0 )
- face_index = -face_index - 1;
- if ( face_index >= resource_cnt )
- return FT_THROW( Cannot_Open_Resource );
-
- flag_offset = (FT_ULong)offsets[face_index];
- error = FT_Stream_Seek( stream, flag_offset );
- if ( error )
- goto Exit;
-
- if ( FT_READ_ULONG( rlen ) )
- goto Exit;
- if ( !rlen )
- return FT_THROW( Cannot_Open_Resource );
- if ( rlen > FT_MAC_RFORK_MAX_LEN )
- return FT_THROW( Invalid_Offset );
-
- error = open_face_PS_from_sfnt_stream( library,
- stream,
- face_index,
- 0, NULL,
- aface );
- if ( !error )
- goto Exit;
-
- /* rewind sfnt stream before open_face_PS_from_sfnt_stream() */
- error = FT_Stream_Seek( stream, flag_offset + 4 );
- if ( error )
- goto Exit;
-
- if ( FT_QALLOC( sfnt_data, rlen ) )
- return error;
- error = FT_Stream_Read( stream, (FT_Byte *)sfnt_data, rlen );
- if ( error )
- {
- FT_FREE( sfnt_data );
- goto Exit;
- }
-
- is_cff = rlen > 4 && !ft_memcmp( sfnt_data, "OTTO", 4 );
- error = open_face_from_buffer( library,
- sfnt_data,
- rlen,
- face_index_in_resource,
- is_cff ? "cff" : "truetype",
- aface );
-
- Exit:
- return error;
- }
-
-
- /* Check for a valid resource fork header, or a valid dfont */
- /* header. In a resource fork the first 16 bytes are repeated */
- /* at the location specified by bytes 4-7. In a dfont bytes */
- /* 4-7 point to 16 bytes of zeroes instead. */
- /* */
- static FT_Error
- IsMacResource( FT_Library library,
- FT_Stream stream,
- FT_Long resource_offset,
- FT_Long face_index,
- FT_Face *aface )
- {
- FT_Memory memory = library->memory;
- FT_Error error;
- FT_Long map_offset, rdata_pos;
- FT_Long *data_offsets;
- FT_Long count;
-
-
- error = FT_Raccess_Get_HeaderInfo( library, stream, resource_offset,
- &map_offset, &rdata_pos );
- if ( error )
- return error;
-
- /* POST resources must be sorted to concatenate properly */
- error = FT_Raccess_Get_DataOffsets( library, stream,
- map_offset, rdata_pos,
- TTAG_POST, TRUE,
- &data_offsets, &count );
- if ( !error )
- {
- error = Mac_Read_POST_Resource( library, stream, data_offsets, count,
- face_index, aface );
- FT_FREE( data_offsets );
- /* POST exists in an LWFN providing a single face */
- if ( !error )
- (*aface)->num_faces = 1;
- return error;
- }
-
- /* sfnt resources should not be sorted to preserve the face order by
- QuickDraw API */
- error = FT_Raccess_Get_DataOffsets( library, stream,
- map_offset, rdata_pos,
- TTAG_sfnt, FALSE,
- &data_offsets, &count );
- if ( !error )
- {
- FT_Long face_index_internal = face_index % count;
-
-
- error = Mac_Read_sfnt_Resource( library, stream, data_offsets, count,
- face_index_internal, aface );
- FT_FREE( data_offsets );
- if ( !error )
- {
- (*aface)->num_faces = count;
- (*aface)->face_index = face_index_internal;
- }
- }
-
- return error;
- }
-
-
- /* Check for a valid macbinary header, and if we find one */
- /* check that the (flattened) resource fork in it is valid. */
- /* */
- static FT_Error
- IsMacBinary( FT_Library library,
- FT_Stream stream,
- FT_Long face_index,
- FT_Face *aface )
- {
- unsigned char header[128];
- FT_Error error;
- FT_Long dlen, offset;
-
-
- if ( !stream )
- return FT_THROW( Invalid_Stream_Operation );
-
- error = FT_Stream_Seek( stream, 0 );
- if ( error )
- goto Exit;
-
- error = FT_Stream_Read( stream, (FT_Byte*)header, 128 );
- if ( error )
- goto Exit;
-
- if ( header[ 0] != 0 ||
- header[74] != 0 ||
- header[82] != 0 ||
- header[ 1] == 0 ||
- header[ 1] > 33 ||
- header[63] != 0 ||
- header[2 + header[1]] != 0 ||
- header[0x53] > 0x7F )
- return FT_THROW( Unknown_File_Format );
-
- dlen = ( header[0x53] << 24 ) |
- ( header[0x54] << 16 ) |
- ( header[0x55] << 8 ) |
- header[0x56];
-#if 0
- rlen = ( header[0x57] << 24 ) |
- ( header[0x58] << 16 ) |
- ( header[0x59] << 8 ) |
- header[0x5A];
-#endif /* 0 */
- offset = 128 + ( ( dlen + 127 ) & ~127 );
-
- return IsMacResource( library, stream, offset, face_index, aface );
-
- Exit:
- return error;
- }
-
-
- static FT_Error
- load_face_in_embedded_rfork( FT_Library library,
- FT_Stream stream,
- FT_Long face_index,
- FT_Face *aface,
- const FT_Open_Args *args )
- {
-
-#undef FT_COMPONENT
-#define FT_COMPONENT raccess
-
- FT_Memory memory = library->memory;
- FT_Error error = FT_ERR( Unknown_File_Format );
- FT_UInt i;
-
- char* file_names[FT_RACCESS_N_RULES];
- FT_Long offsets[FT_RACCESS_N_RULES];
- FT_Error errors[FT_RACCESS_N_RULES];
- FT_Bool is_darwin_vfs, vfs_rfork_has_no_font = FALSE; /* not tested */
-
- FT_Open_Args args2;
- FT_Stream stream2 = NULL;
-
-
- FT_Raccess_Guess( library, stream,
- args->pathname, file_names, offsets, errors );
-
- for ( i = 0; i < FT_RACCESS_N_RULES; i++ )
- {
- is_darwin_vfs = ft_raccess_rule_by_darwin_vfs( library, i );
- if ( is_darwin_vfs && vfs_rfork_has_no_font )
- {
- FT_TRACE3(( "Skip rule %d: darwin vfs resource fork"
- " is already checked and"
- " no font is found\n",
- i ));
- continue;
- }
-
- if ( errors[i] )
- {
- FT_TRACE3(( "Error 0x%x has occurred in rule %d\n",
- errors[i], i ));
- continue;
- }
-
- args2.flags = FT_OPEN_PATHNAME;
- args2.pathname = file_names[i] ? file_names[i] : args->pathname;
-
- FT_TRACE3(( "Try rule %d: %s (offset=%ld) ...",
- i, args2.pathname, offsets[i] ));
-
- error = FT_Stream_New( library, &args2, &stream2 );
- if ( is_darwin_vfs && FT_ERR_EQ( error, Cannot_Open_Stream ) )
- vfs_rfork_has_no_font = TRUE;
-
- if ( error )
- {
- FT_TRACE3(( "failed\n" ));
- continue;
- }
-
- error = IsMacResource( library, stream2, offsets[i],
- face_index, aface );
- FT_Stream_Free( stream2, 0 );
-
- FT_TRACE3(( "%s\n", error ? "failed": "successful" ));
-
- if ( !error )
- break;
- else if ( is_darwin_vfs )
- vfs_rfork_has_no_font = TRUE;
- }
-
- for (i = 0; i < FT_RACCESS_N_RULES; i++)
- {
- if ( file_names[i] )
- FT_FREE( file_names[i] );
- }
-
- /* Caller (load_mac_face) requires FT_Err_Unknown_File_Format. */
- if ( error )
- error = FT_ERR( Unknown_File_Format );
-
- return error;
-
-#undef FT_COMPONENT
-#define FT_COMPONENT objs
-
- }
-
-
- /* Check for some macintosh formats without Carbon framework. */
- /* Is this a macbinary file? If so look at the resource fork. */
- /* Is this a mac dfont file? */
- /* Is this an old style resource fork? (in data) */
- /* Else call load_face_in_embedded_rfork to try extra rules */
- /* (defined in `ftrfork.c'). */
- /* */
- static FT_Error
- load_mac_face( FT_Library library,
- FT_Stream stream,
- FT_Long face_index,
- FT_Face *aface,
- const FT_Open_Args *args )
- {
- FT_Error error;
- FT_UNUSED( args );
-
-
- error = IsMacBinary( library, stream, face_index, aface );
- if ( FT_ERR_EQ( error, Unknown_File_Format ) )
- {
-
-#undef FT_COMPONENT
-#define FT_COMPONENT raccess
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- FT_TRACE3(( "Try as dfont: " ));
- if ( !( args->flags & FT_OPEN_MEMORY ) )
- FT_TRACE3(( "%s ...", args->pathname ));
-#endif
-
- error = IsMacResource( library, stream, 0, face_index, aface );
-
- FT_TRACE3(( "%s\n", error ? "failed" : "successful" ));
-
-#undef FT_COMPONENT
-#define FT_COMPONENT objs
-
- }
-
- if ( ( FT_ERR_EQ( error, Unknown_File_Format ) ||
- FT_ERR_EQ( error, Invalid_Stream_Operation ) ) &&
- ( args->flags & FT_OPEN_PATHNAME ) )
- error = load_face_in_embedded_rfork( library, stream,
- face_index, aface, args );
- return error;
- }
-#endif
-
-#endif /* !FT_MACINTOSH && FT_CONFIG_OPTION_MAC_FONTS */
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Open_Face( FT_Library library,
- const FT_Open_Args* args,
- FT_Long face_index,
- FT_Face *aface )
- {
- return ft_open_face_internal( library, args, face_index, aface, 1 );
- }
-
-
- static FT_Error
- ft_open_face_internal( FT_Library library,
- const FT_Open_Args* args,
- FT_Long face_index,
- FT_Face *aface,
- FT_Bool test_mac_fonts )
- {
- FT_Error error;
- FT_Driver driver = NULL;
- FT_Memory memory = NULL;
- FT_Stream stream = NULL;
- FT_Face face = NULL;
- FT_ListNode node = NULL;
- FT_Bool external_stream;
- FT_Module* cur;
- FT_Module* limit;
-
-#ifndef FT_CONFIG_OPTION_MAC_FONTS
- FT_UNUSED( test_mac_fonts );
-#endif
-
-
- /* only use lower 31 bits together with sign bit */
- if ( face_index > 0 )
- face_index &= 0x7FFFFFFFL;
- else
- {
- face_index = -face_index;
- face_index &= 0x7FFFFFFFL;
- face_index = -face_index;
- }
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- FT_TRACE3(( "FT_Open_Face: " ));
- if ( face_index < 0 )
- FT_TRACE3(( "Requesting number of faces and named instances\n"));
- else
- {
- FT_TRACE3(( "Requesting face %ld", face_index & 0xFFFFL ));
- if ( face_index & 0x7FFF0000L )
- FT_TRACE3(( ", named instance %ld", face_index >> 16 ));
- FT_TRACE3(( "\n" ));
- }
-#endif
-
- /* test for valid `library' delayed to `FT_Stream_New' */
-
- if ( !args )
- return FT_THROW( Invalid_Argument );
-
- external_stream = FT_BOOL( ( args->flags & FT_OPEN_STREAM ) &&
- args->stream );
-
- /* create input stream */
- error = FT_Stream_New( library, args, &stream );
- if ( error )
- goto Fail3;
-
- /* Do this error check after `FT_Stream_New` to ensure that the */
- /* 'close' callback is called. */
- if ( !aface && face_index >= 0 )
- {
- error = FT_THROW( Invalid_Argument );
- goto Fail3;
- }
-
- memory = library->memory;
-
- /* If the font driver is specified in the `args' structure, use */
- /* it. Otherwise, we scan the list of registered drivers. */
- if ( ( args->flags & FT_OPEN_DRIVER ) && args->driver )
- {
- driver = FT_DRIVER( args->driver );
-
- /* not all modules are drivers, so check... */
- if ( FT_MODULE_IS_DRIVER( driver ) )
- {
- FT_Int num_params = 0;
- FT_Parameter* params = NULL;
-
-
- if ( args->flags & FT_OPEN_PARAMS )
- {
- num_params = args->num_params;
- params = args->params;
- }
-
- error = open_face( driver, &stream, &external_stream, face_index,
- num_params, params, &face );
- if ( !error )
- goto Success;
- }
- else
- error = FT_THROW( Invalid_Handle );
-
- FT_Stream_Free( stream, external_stream );
- goto Fail;
- }
- else
- {
- error = FT_ERR( Missing_Module );
-
- /* check each font driver for an appropriate format */
- cur = library->modules;
- limit = cur + library->num_modules;
-
- for ( ; cur < limit; cur++ )
- {
- /* not all modules are font drivers, so check... */
- if ( FT_MODULE_IS_DRIVER( cur[0] ) )
- {
- FT_Int num_params = 0;
- FT_Parameter* params = NULL;
-
-
- driver = FT_DRIVER( cur[0] );
-
- if ( args->flags & FT_OPEN_PARAMS )
- {
- num_params = args->num_params;
- params = args->params;
- }
-
- error = open_face( driver, &stream, &external_stream, face_index,
- num_params, params, &face );
- if ( !error )
- goto Success;
-
-#ifdef FT_CONFIG_OPTION_MAC_FONTS
- if ( test_mac_fonts &&
- ft_strcmp( cur[0]->clazz->module_name, "truetype" ) == 0 &&
- FT_ERR_EQ( error, Table_Missing ) )
- {
- /* TrueType but essential tables are missing */
- error = FT_Stream_Seek( stream, 0 );
- if ( error )
- break;
-
- error = open_face_PS_from_sfnt_stream( library,
- stream,
- face_index,
- num_params,
- params,
- aface );
- if ( !error )
- {
- FT_Stream_Free( stream, external_stream );
- return error;
- }
- }
-#endif
-
- if ( FT_ERR_NEQ( error, Unknown_File_Format ) )
- goto Fail3;
- }
- }
-
- Fail3:
- /* If we are on the mac, and we get an */
- /* FT_Err_Invalid_Stream_Operation it may be because we have an */
- /* empty data fork, so we need to check the resource fork. */
- if ( FT_ERR_NEQ( error, Cannot_Open_Stream ) &&
- FT_ERR_NEQ( error, Unknown_File_Format ) &&
- FT_ERR_NEQ( error, Invalid_Stream_Operation ) )
- goto Fail2;
-
-#if !defined( FT_MACINTOSH ) && defined( FT_CONFIG_OPTION_MAC_FONTS )
- if ( test_mac_fonts )
- {
- error = load_mac_face( library, stream, face_index, aface, args );
- if ( !error )
- {
- /* We don't want to go to Success here. We've already done */
- /* that. On the other hand, if we succeeded we still need to */
- /* close this stream (we opened a different stream which */
- /* extracted the interesting information out of this stream */
- /* here. That stream will still be open and the face will */
- /* point to it). */
- FT_Stream_Free( stream, external_stream );
- return error;
- }
- }
-
- if ( FT_ERR_NEQ( error, Unknown_File_Format ) )
- goto Fail2;
-#endif /* !FT_MACINTOSH && FT_CONFIG_OPTION_MAC_FONTS */
-
- /* no driver is able to handle this format */
- error = FT_THROW( Unknown_File_Format );
-
- Fail2:
- FT_Stream_Free( stream, external_stream );
- goto Fail;
- }
-
- Success:
- FT_TRACE4(( "FT_Open_Face: New face object, adding to list\n" ));
-
- /* add the face object to its driver's list */
- if ( FT_QNEW( node ) )
- goto Fail;
-
- node->data = face;
- /* don't assume driver is the same as face->driver, so use */
- /* face->driver instead. */
- FT_List_Add( &face->driver->faces_list, node );
-
- /* now allocate a glyph slot object for the face */
- FT_TRACE4(( "FT_Open_Face: Creating glyph slot\n" ));
-
- if ( face_index >= 0 )
- {
- error = FT_New_GlyphSlot( face, NULL );
- if ( error )
- goto Fail;
-
- /* finally, allocate a size object for the face */
- {
- FT_Size size;
-
-
- FT_TRACE4(( "FT_Open_Face: Creating size object\n" ));
-
- error = FT_New_Size( face, &size );
- if ( error )
- goto Fail;
-
- face->size = size;
- }
- }
-
- /* some checks */
-
- if ( FT_IS_SCALABLE( face ) )
- {
- if ( face->height < 0 )
- face->height = (FT_Short)-face->height;
-
- if ( !FT_HAS_VERTICAL( face ) )
- face->max_advance_height = (FT_Short)face->height;
- }
-
- if ( FT_HAS_FIXED_SIZES( face ) )
- {
- FT_Int i;
-
-
- for ( i = 0; i < face->num_fixed_sizes; i++ )
- {
- FT_Bitmap_Size* bsize = face->available_sizes + i;
-
-
- if ( bsize->height < 0 )
- bsize->height = -bsize->height;
- if ( bsize->x_ppem < 0 )
- bsize->x_ppem = -bsize->x_ppem;
- if ( bsize->y_ppem < 0 )
- bsize->y_ppem = -bsize->y_ppem;
-
- /* check whether negation actually has worked */
- if ( bsize->height < 0 || bsize->x_ppem < 0 || bsize->y_ppem < 0 )
- {
- FT_TRACE0(( "FT_Open_Face:"
- " Invalid bitmap dimensions for strike %d,"
- " now disabled\n", i ));
- bsize->width = 0;
- bsize->height = 0;
- bsize->size = 0;
- bsize->x_ppem = 0;
- bsize->y_ppem = 0;
- }
- }
- }
-
- /* initialize internal face data */
- {
- FT_Face_Internal internal = face->internal;
-
-
- internal->transform_matrix.xx = 0x10000L;
- internal->transform_matrix.xy = 0;
- internal->transform_matrix.yx = 0;
- internal->transform_matrix.yy = 0x10000L;
-
- internal->transform_delta.x = 0;
- internal->transform_delta.y = 0;
-
- internal->refcount = 1;
-
- internal->no_stem_darkening = -1;
-
-#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
- /* Per-face filtering can only be set up by FT_Face_Properties */
- internal->lcd_filter_func = NULL;
-#endif
- }
-
- if ( aface )
- *aface = face;
- else
- FT_Done_Face( face );
-
- goto Exit;
-
- Fail:
- if ( node )
- FT_Done_Face( face ); /* face must be in the driver's list */
- else if ( face )
- destroy_face( memory, face, driver );
-
- Exit:
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( !error && face_index < 0 )
- {
- FT_TRACE3(( "FT_Open_Face: The font has %ld face%s\n",
- face->num_faces,
- face->num_faces == 1 ? "" : "s" ));
- FT_TRACE3(( " and %ld named instance%s for face %ld\n",
- face->style_flags >> 16,
- ( face->style_flags >> 16 ) == 1 ? "" : "s",
- -face_index - 1 ));
- }
-#endif
-
- FT_TRACE4(( "FT_Open_Face: Return 0x%x\n", error ));
-
- return error;
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Attach_File( FT_Face face,
- const char* filepathname )
- {
- FT_Open_Args open;
-
-
- /* test for valid `face' delayed to `FT_Attach_Stream' */
-
- if ( !filepathname )
- return FT_THROW( Invalid_Argument );
-
- open.stream = NULL;
- open.flags = FT_OPEN_PATHNAME;
- open.pathname = (char*)filepathname;
-
- return FT_Attach_Stream( face, &open );
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Attach_Stream( FT_Face face,
- const FT_Open_Args* parameters )
- {
- FT_Stream stream;
- FT_Error error;
- FT_Driver driver;
-
- FT_Driver_Class clazz;
-
-
- /* test for valid `parameters' delayed to `FT_Stream_New' */
-
- if ( !face )
- return FT_THROW( Invalid_Face_Handle );
-
- driver = face->driver;
- if ( !driver )
- return FT_THROW( Invalid_Driver_Handle );
-
- error = FT_Stream_New( driver->root.library, parameters, &stream );
- if ( error )
- goto Exit;
-
- /* we implement FT_Attach_Stream in each driver through the */
- /* `attach_file' interface */
-
- error = FT_ERR( Unimplemented_Feature );
- clazz = driver->clazz;
- if ( clazz->attach_file )
- error = clazz->attach_file( face, stream );
-
- /* close the attached stream */
- FT_Stream_Free( stream,
- FT_BOOL( parameters->stream &&
- ( parameters->flags & FT_OPEN_STREAM ) ) );
-
- Exit:
- return error;
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Reference_Face( FT_Face face )
- {
- if ( !face )
- return FT_THROW( Invalid_Face_Handle );
-
- face->internal->refcount++;
-
- return FT_Err_Ok;
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Done_Face( FT_Face face )
- {
- FT_Error error;
- FT_Driver driver;
- FT_Memory memory;
- FT_ListNode node;
-
-
- error = FT_ERR( Invalid_Face_Handle );
- if ( face && face->driver )
- {
- face->internal->refcount--;
- if ( face->internal->refcount > 0 )
- error = FT_Err_Ok;
- else
- {
- driver = face->driver;
- memory = driver->root.memory;
-
- /* find face in driver's list */
- node = FT_List_Find( &driver->faces_list, face );
- if ( node )
- {
- /* remove face object from the driver's list */
- FT_List_Remove( &driver->faces_list, node );
- FT_FREE( node );
-
- /* now destroy the object proper */
- destroy_face( memory, face, driver );
- error = FT_Err_Ok;
- }
- }
- }
-
- return error;
- }
-
-
- /* documentation is in ftobjs.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_New_Size( FT_Face face,
- FT_Size *asize )
- {
- FT_Error error;
- FT_Memory memory;
- FT_Driver driver;
- FT_Driver_Class clazz;
-
- FT_Size size = NULL;
- FT_ListNode node = NULL;
-
- FT_Size_Internal internal = NULL;
-
-
- if ( !face )
- return FT_THROW( Invalid_Face_Handle );
-
- if ( !asize )
- return FT_THROW( Invalid_Argument );
-
- if ( !face->driver )
- return FT_THROW( Invalid_Driver_Handle );
-
- *asize = NULL;
-
- driver = face->driver;
- clazz = driver->clazz;
- memory = face->memory;
-
- /* Allocate new size object and perform basic initialisation */
- if ( FT_ALLOC( size, clazz->size_object_size ) || FT_QNEW( node ) )
- goto Exit;
-
- size->face = face;
-
- if ( FT_NEW( internal ) )
- goto Exit;
-
- size->internal = internal;
-
- if ( clazz->init_size )
- error = clazz->init_size( size );
-
- /* in case of success, add to the face's list */
- if ( !error )
- {
- *asize = size;
- node->data = size;
- FT_List_Add( &face->sizes_list, node );
- }
-
- Exit:
- if ( error )
- {
- FT_FREE( node );
- if ( size )
- FT_FREE( size->internal );
- FT_FREE( size );
- }
-
- return error;
- }
-
-
- /* documentation is in ftobjs.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Done_Size( FT_Size size )
- {
- FT_Error error;
- FT_Driver driver;
- FT_Memory memory;
- FT_Face face;
- FT_ListNode node;
-
-
- if ( !size )
- return FT_THROW( Invalid_Size_Handle );
-
- face = size->face;
- if ( !face )
- return FT_THROW( Invalid_Face_Handle );
-
- driver = face->driver;
- if ( !driver )
- return FT_THROW( Invalid_Driver_Handle );
-
- memory = driver->root.memory;
-
- error = FT_Err_Ok;
- node = FT_List_Find( &face->sizes_list, size );
- if ( node )
- {
- FT_List_Remove( &face->sizes_list, node );
- FT_FREE( node );
-
- if ( face->size == size )
- {
- face->size = NULL;
- if ( face->sizes_list.head )
- face->size = (FT_Size)(face->sizes_list.head->data);
- }
-
- destroy_size( memory, size, driver );
- }
- else
- error = FT_THROW( Invalid_Size_Handle );
-
- return error;
- }
-
-
- /* documentation is in ftobjs.h */
-
- FT_BASE_DEF( FT_Error )
- FT_Match_Size( FT_Face face,
- FT_Size_Request req,
- FT_Bool ignore_width,
- FT_ULong* size_index )
- {
- FT_Int i;
- FT_Long w, h;
-
-
- if ( !FT_HAS_FIXED_SIZES( face ) )
- return FT_THROW( Invalid_Face_Handle );
-
- /* FT_Bitmap_Size doesn't provide enough info... */
- if ( req->type != FT_SIZE_REQUEST_TYPE_NOMINAL )
- return FT_THROW( Unimplemented_Feature );
-
- w = FT_REQUEST_WIDTH ( req );
- h = FT_REQUEST_HEIGHT( req );
-
- if ( req->width && !req->height )
- h = w;
- else if ( !req->width && req->height )
- w = h;
-
- w = FT_PIX_ROUND( w );
- h = FT_PIX_ROUND( h );
-
- if ( !w || !h )
- return FT_THROW( Invalid_Pixel_Size );
-
- for ( i = 0; i < face->num_fixed_sizes; i++ )
- {
- FT_Bitmap_Size* bsize = face->available_sizes + i;
-
-
- if ( h != FT_PIX_ROUND( bsize->y_ppem ) )
- continue;
-
- if ( w == FT_PIX_ROUND( bsize->x_ppem ) || ignore_width )
- {
- FT_TRACE3(( "FT_Match_Size: bitmap strike %d matches\n", i ));
-
- if ( size_index )
- *size_index = (FT_ULong)i;
-
- return FT_Err_Ok;
- }
- }
-
- FT_TRACE3(( "FT_Match_Size: no matching bitmap strike\n" ));
-
- return FT_THROW( Invalid_Pixel_Size );
- }
-
-
- /* documentation is in ftobjs.h */
-
- FT_BASE_DEF( void )
- ft_synthesize_vertical_metrics( FT_Glyph_Metrics* metrics,
- FT_Pos advance )
- {
- FT_Pos height = metrics->height;
-
-
- /* compensate for glyph with bbox above/below the baseline */
- if ( metrics->horiBearingY < 0 )
- {
- if ( height < metrics->horiBearingY )
- height = metrics->horiBearingY;
- }
- else if ( metrics->horiBearingY > 0 )
- height -= metrics->horiBearingY;
-
- /* the factor 1.2 is a heuristical value */
- if ( !advance )
- advance = height * 12 / 10;
-
- metrics->vertBearingX = metrics->horiBearingX - metrics->horiAdvance / 2;
- metrics->vertBearingY = ( advance - height ) / 2;
- metrics->vertAdvance = advance;
- }
-
-
- static void
- ft_recompute_scaled_metrics( FT_Face face,
- FT_Size_Metrics* metrics )
- {
- /* Compute root ascender, descender, test height, and max_advance */
-
-#ifdef GRID_FIT_METRICS
- metrics->ascender = FT_PIX_CEIL( FT_MulFix( face->ascender,
- metrics->y_scale ) );
-
- metrics->descender = FT_PIX_FLOOR( FT_MulFix( face->descender,
- metrics->y_scale ) );
-
- metrics->height = FT_PIX_ROUND( FT_MulFix( face->height,
- metrics->y_scale ) );
-
- metrics->max_advance = FT_PIX_ROUND( FT_MulFix( face->max_advance_width,
- metrics->x_scale ) );
-#else /* !GRID_FIT_METRICS */
- metrics->ascender = FT_MulFix( face->ascender,
- metrics->y_scale );
-
- metrics->descender = FT_MulFix( face->descender,
- metrics->y_scale );
-
- metrics->height = FT_MulFix( face->height,
- metrics->y_scale );
-
- metrics->max_advance = FT_MulFix( face->max_advance_width,
- metrics->x_scale );
-#endif /* !GRID_FIT_METRICS */
- }
-
-
- FT_BASE_DEF( void )
- FT_Select_Metrics( FT_Face face,
- FT_ULong strike_index )
- {
- FT_Size_Metrics* metrics;
- FT_Bitmap_Size* bsize;
-
-
- metrics = &face->size->metrics;
- bsize = face->available_sizes + strike_index;
-
- metrics->x_ppem = (FT_UShort)( ( bsize->x_ppem + 32 ) >> 6 );
- metrics->y_ppem = (FT_UShort)( ( bsize->y_ppem + 32 ) >> 6 );
-
- if ( FT_IS_SCALABLE( face ) )
- {
- metrics->x_scale = FT_DivFix( bsize->x_ppem,
- face->units_per_EM );
- metrics->y_scale = FT_DivFix( bsize->y_ppem,
- face->units_per_EM );
-
- ft_recompute_scaled_metrics( face, metrics );
- }
- else
- {
- metrics->x_scale = 1L << 16;
- metrics->y_scale = 1L << 16;
- metrics->ascender = bsize->y_ppem;
- metrics->descender = 0;
- metrics->height = bsize->height << 6;
- metrics->max_advance = bsize->x_ppem;
- }
- }
-
-
- FT_BASE_DEF( FT_Error )
- FT_Request_Metrics( FT_Face face,
- FT_Size_Request req )
- {
- FT_Error error = FT_Err_Ok;
-
- FT_Size_Metrics* metrics;
-
-
- metrics = &face->size->metrics;
-
- if ( FT_IS_SCALABLE( face ) )
- {
- FT_Long w = 0, h = 0, scaled_w = 0, scaled_h = 0;
-
-
- switch ( req->type )
- {
- case FT_SIZE_REQUEST_TYPE_NOMINAL:
- w = h = face->units_per_EM;
- break;
-
- case FT_SIZE_REQUEST_TYPE_REAL_DIM:
- w = h = face->ascender - face->descender;
- break;
-
- case FT_SIZE_REQUEST_TYPE_BBOX:
- w = face->bbox.xMax - face->bbox.xMin;
- h = face->bbox.yMax - face->bbox.yMin;
- break;
-
- case FT_SIZE_REQUEST_TYPE_CELL:
- w = face->max_advance_width;
- h = face->ascender - face->descender;
- break;
-
- case FT_SIZE_REQUEST_TYPE_SCALES:
- metrics->x_scale = (FT_Fixed)req->width;
- metrics->y_scale = (FT_Fixed)req->height;
- if ( !metrics->x_scale )
- metrics->x_scale = metrics->y_scale;
- else if ( !metrics->y_scale )
- metrics->y_scale = metrics->x_scale;
- goto Calculate_Ppem;
-
- case FT_SIZE_REQUEST_TYPE_MAX:
- break;
- }
-
- /* to be on the safe side */
- if ( w < 0 )
- w = -w;
-
- if ( h < 0 )
- h = -h;
-
- scaled_w = FT_REQUEST_WIDTH ( req );
- scaled_h = FT_REQUEST_HEIGHT( req );
-
- /* determine scales */
- if ( req->height || !req->width )
- {
- if ( h == 0 )
- {
- FT_ERROR(( "FT_Request_Metrics: Divide by zero\n" ));
- error = FT_ERR( Divide_By_Zero );
- goto Exit;
- }
-
- metrics->y_scale = FT_DivFix( scaled_h, h );
- }
-
- if ( req->width )
- {
- if ( w == 0 )
- {
- FT_ERROR(( "FT_Request_Metrics: Divide by zero\n" ));
- error = FT_ERR( Divide_By_Zero );
- goto Exit;
- }
-
- metrics->x_scale = FT_DivFix( scaled_w, w );
- }
- else
- {
- metrics->x_scale = metrics->y_scale;
- scaled_w = FT_MulDiv( scaled_h, w, h );
- }
-
- if ( !req->height )
- {
- metrics->y_scale = metrics->x_scale;
- scaled_h = FT_MulDiv( scaled_w, h, w );
- }
-
- if ( req->type == FT_SIZE_REQUEST_TYPE_CELL )
- {
- if ( metrics->y_scale > metrics->x_scale )
- metrics->y_scale = metrics->x_scale;
- else
- metrics->x_scale = metrics->y_scale;
- }
-
- Calculate_Ppem:
- /* calculate the ppems */
- if ( req->type != FT_SIZE_REQUEST_TYPE_NOMINAL )
- {
- scaled_w = FT_MulFix( face->units_per_EM, metrics->x_scale );
- scaled_h = FT_MulFix( face->units_per_EM, metrics->y_scale );
- }
-
- scaled_w = ( scaled_w + 32 ) >> 6;
- scaled_h = ( scaled_h + 32 ) >> 6;
- if ( scaled_w > (FT_Long)FT_USHORT_MAX ||
- scaled_h > (FT_Long)FT_USHORT_MAX )
- {
- FT_ERROR(( "FT_Request_Metrics: Resulting ppem size too large\n" ));
- error = FT_ERR( Invalid_Pixel_Size );
- goto Exit;
- }
-
- metrics->x_ppem = (FT_UShort)scaled_w;
- metrics->y_ppem = (FT_UShort)scaled_h;
-
- ft_recompute_scaled_metrics( face, metrics );
- }
- else
- {
- FT_ZERO( metrics );
- metrics->x_scale = 1L << 16;
- metrics->y_scale = 1L << 16;
- }
-
- Exit:
- return error;
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Select_Size( FT_Face face,
- FT_Int strike_index )
- {
- FT_Error error = FT_Err_Ok;
- FT_Driver_Class clazz;
-
-
- if ( !face || !FT_HAS_FIXED_SIZES( face ) )
- return FT_THROW( Invalid_Face_Handle );
-
- if ( strike_index < 0 || strike_index >= face->num_fixed_sizes )
- return FT_THROW( Invalid_Argument );
-
- clazz = face->driver->clazz;
-
- if ( clazz->select_size )
- {
- error = clazz->select_size( face->size, (FT_ULong)strike_index );
-
- FT_TRACE5(( "FT_Select_Size (%s driver):\n",
- face->driver->root.clazz->module_name ));
- }
- else
- {
- FT_Select_Metrics( face, (FT_ULong)strike_index );
-
- FT_TRACE5(( "FT_Select_Size:\n" ));
- }
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- {
- FT_Size_Metrics* metrics = &face->size->metrics;
-
-
- FT_TRACE5(( " x scale: %ld (%f)\n",
- metrics->x_scale, (double)metrics->x_scale / 65536 ));
- FT_TRACE5(( " y scale: %ld (%f)\n",
- metrics->y_scale, (double)metrics->y_scale / 65536 ));
- FT_TRACE5(( " ascender: %f\n",
- (double)metrics->ascender / 64 ));
- FT_TRACE5(( " descender: %f\n",
- (double)metrics->descender / 64 ));
- FT_TRACE5(( " height: %f\n",
- (double)metrics->height / 64 ));
- FT_TRACE5(( " max advance: %f\n",
- (double)metrics->max_advance / 64 ));
- FT_TRACE5(( " x ppem: %d\n", metrics->x_ppem ));
- FT_TRACE5(( " y ppem: %d\n", metrics->y_ppem ));
- }
-#endif
-
- return error;
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Request_Size( FT_Face face,
- FT_Size_Request req )
- {
- FT_Error error;
- FT_Driver_Class clazz;
- FT_ULong strike_index;
-
-
- if ( !face )
- return FT_THROW( Invalid_Face_Handle );
-
- if ( !face->size )
- return FT_THROW( Invalid_Size_Handle );
-
- if ( !req || req->width < 0 || req->height < 0 ||
- req->type >= FT_SIZE_REQUEST_TYPE_MAX )
- return FT_THROW( Invalid_Argument );
-
- /* signal the auto-hinter to recompute its size metrics */
- /* (if requested) */
- face->size->internal->autohint_metrics.x_scale = 0;
-
- clazz = face->driver->clazz;
-
- if ( clazz->request_size )
- {
- error = clazz->request_size( face->size, req );
-
- FT_TRACE5(( "FT_Request_Size (%s driver):\n",
- face->driver->root.clazz->module_name ));
- }
- else if ( !FT_IS_SCALABLE( face ) && FT_HAS_FIXED_SIZES( face ) )
- {
- /*
- * The reason that a driver doesn't have `request_size' defined is
- * either that the scaling here suffices or that the supported formats
- * are bitmap-only and size matching is not implemented.
- *
- * In the latter case, a simple size matching is done.
- */
- error = FT_Match_Size( face, req, 0, &strike_index );
- if ( error )
- goto Exit;
-
- return FT_Select_Size( face, (FT_Int)strike_index );
- }
- else
- {
- error = FT_Request_Metrics( face, req );
- if ( error )
- goto Exit;
-
- FT_TRACE5(( "FT_Request_Size:\n" ));
- }
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- {
- FT_Size_Metrics* metrics = &face->size->metrics;
-
-
- FT_TRACE5(( " x scale: %ld (%f)\n",
- metrics->x_scale, (double)metrics->x_scale / 65536 ));
- FT_TRACE5(( " y scale: %ld (%f)\n",
- metrics->y_scale, (double)metrics->y_scale / 65536 ));
- FT_TRACE5(( " ascender: %f\n",
- (double)metrics->ascender / 64 ));
- FT_TRACE5(( " descender: %f\n",
- (double)metrics->descender / 64 ));
- FT_TRACE5(( " height: %f\n",
- (double)metrics->height / 64 ));
- FT_TRACE5(( " max advance: %f\n",
- (double)metrics->max_advance / 64 ));
- FT_TRACE5(( " x ppem: %d\n", metrics->x_ppem ));
- FT_TRACE5(( " y ppem: %d\n", metrics->y_ppem ));
- }
-#endif
-
- Exit:
- return error;
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Set_Char_Size( FT_Face face,
- FT_F26Dot6 char_width,
- FT_F26Dot6 char_height,
- FT_UInt horz_resolution,
- FT_UInt vert_resolution )
- {
- FT_Size_RequestRec req;
-
-
- /* check of `face' delayed to `FT_Request_Size' */
-
- if ( !char_width )
- char_width = char_height;
- else if ( !char_height )
- char_height = char_width;
-
- if ( !horz_resolution )
- horz_resolution = vert_resolution;
- else if ( !vert_resolution )
- vert_resolution = horz_resolution;
-
- if ( char_width < 1 * 64 )
- char_width = 1 * 64;
- if ( char_height < 1 * 64 )
- char_height = 1 * 64;
-
- if ( !horz_resolution )
- horz_resolution = vert_resolution = 72;
-
- req.type = FT_SIZE_REQUEST_TYPE_NOMINAL;
- req.width = char_width;
- req.height = char_height;
- req.horiResolution = horz_resolution;
- req.vertResolution = vert_resolution;
-
- return FT_Request_Size( face, &req );
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Set_Pixel_Sizes( FT_Face face,
- FT_UInt pixel_width,
- FT_UInt pixel_height )
- {
- FT_Size_RequestRec req;
-
-
- /* check of `face' delayed to `FT_Request_Size' */
-
- if ( pixel_width == 0 )
- pixel_width = pixel_height;
- else if ( pixel_height == 0 )
- pixel_height = pixel_width;
-
- if ( pixel_width < 1 )
- pixel_width = 1;
- if ( pixel_height < 1 )
- pixel_height = 1;
-
- /* use `>=' to avoid potential compiler warning on 16bit platforms */
- if ( pixel_width >= 0xFFFFU )
- pixel_width = 0xFFFFU;
- if ( pixel_height >= 0xFFFFU )
- pixel_height = 0xFFFFU;
-
- req.type = FT_SIZE_REQUEST_TYPE_NOMINAL;
- req.width = (FT_Long)( pixel_width << 6 );
- req.height = (FT_Long)( pixel_height << 6 );
- req.horiResolution = 0;
- req.vertResolution = 0;
-
- return FT_Request_Size( face, &req );
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Get_Kerning( FT_Face face,
- FT_UInt left_glyph,
- FT_UInt right_glyph,
- FT_UInt kern_mode,
- FT_Vector *akerning )
- {
- FT_Error error = FT_Err_Ok;
- FT_Driver driver;
-
-
- if ( !face )
- return FT_THROW( Invalid_Face_Handle );
-
- if ( !akerning )
- return FT_THROW( Invalid_Argument );
-
- driver = face->driver;
-
- akerning->x = 0;
- akerning->y = 0;
-
- if ( driver->clazz->get_kerning )
- {
- error = driver->clazz->get_kerning( face,
- left_glyph,
- right_glyph,
- akerning );
- if ( !error )
- {
- if ( kern_mode != FT_KERNING_UNSCALED )
- {
- akerning->x = FT_MulFix( akerning->x, face->size->metrics.x_scale );
- akerning->y = FT_MulFix( akerning->y, face->size->metrics.y_scale );
-
- if ( kern_mode != FT_KERNING_UNFITTED )
- {
- FT_Pos orig_x = akerning->x;
- FT_Pos orig_y = akerning->y;
-
-
- /* we scale down kerning values for small ppem values */
- /* to avoid that rounding makes them too big. */
- /* `25' has been determined heuristically. */
- if ( face->size->metrics.x_ppem < 25 )
- akerning->x = FT_MulDiv( orig_x,
- face->size->metrics.x_ppem, 25 );
- if ( face->size->metrics.y_ppem < 25 )
- akerning->y = FT_MulDiv( orig_y,
- face->size->metrics.y_ppem, 25 );
-
- akerning->x = FT_PIX_ROUND( akerning->x );
- akerning->y = FT_PIX_ROUND( akerning->y );
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- {
- FT_Pos orig_x_rounded = FT_PIX_ROUND( orig_x );
- FT_Pos orig_y_rounded = FT_PIX_ROUND( orig_y );
-
-
- if ( akerning->x != orig_x_rounded ||
- akerning->y != orig_y_rounded )
- FT_TRACE5(( "FT_Get_Kerning: horizontal kerning"
- " (%ld, %ld) scaled down to (%ld, %ld) pixels\n",
- orig_x_rounded / 64, orig_y_rounded / 64,
- akerning->x / 64, akerning->y / 64 ));
- }
-#endif
- }
- }
- }
- }
-
- return error;
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Get_Track_Kerning( FT_Face face,
- FT_Fixed point_size,
- FT_Int degree,
- FT_Fixed* akerning )
- {
- FT_Service_Kerning service;
- FT_Error error = FT_Err_Ok;
-
-
- if ( !face )
- return FT_THROW( Invalid_Face_Handle );
-
- if ( !akerning )
- return FT_THROW( Invalid_Argument );
-
- FT_FACE_FIND_SERVICE( face, service, KERNING );
- if ( !service )
- return FT_THROW( Unimplemented_Feature );
-
- error = service->get_track( face,
- point_size,
- degree,
- akerning );
-
- return error;
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Select_Charmap( FT_Face face,
- FT_Encoding encoding )
- {
- FT_CharMap* cur;
- FT_CharMap* limit;
-
-
- if ( !face )
- return FT_THROW( Invalid_Face_Handle );
-
- /* FT_ENCODING_NONE is a valid encoding for BDF, PCF, and Windows FNT */
- if ( encoding == FT_ENCODING_NONE && !face->num_charmaps )
- return FT_THROW( Invalid_Argument );
-
- /* FT_ENCODING_UNICODE is special. We try to find the `best' Unicode */
- /* charmap available, i.e., one with UCS-4 characters, if possible. */
- /* */
- /* This is done by find_unicode_charmap() above, to share code. */
- if ( encoding == FT_ENCODING_UNICODE )
- return find_unicode_charmap( face );
-
- cur = face->charmaps;
- if ( !cur )
- return FT_THROW( Invalid_CharMap_Handle );
-
- limit = cur + face->num_charmaps;
-
- for ( ; cur < limit; cur++ )
- {
- if ( cur[0]->encoding == encoding )
- {
- face->charmap = cur[0];
- return FT_Err_Ok;
- }
- }
-
- return FT_THROW( Invalid_Argument );
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Set_Charmap( FT_Face face,
- FT_CharMap charmap )
- {
- FT_CharMap* cur;
- FT_CharMap* limit;
-
-
- if ( !face )
- return FT_THROW( Invalid_Face_Handle );
-
- cur = face->charmaps;
- if ( !cur || !charmap )
- return FT_THROW( Invalid_CharMap_Handle );
-
- limit = cur + face->num_charmaps;
-
- for ( ; cur < limit; cur++ )
- {
- if ( cur[0] == charmap &&
- FT_Get_CMap_Format ( charmap ) != 14 )
- {
- face->charmap = cur[0];
- return FT_Err_Ok;
- }
- }
-
- return FT_THROW( Invalid_Argument );
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Int )
- FT_Get_Charmap_Index( FT_CharMap charmap )
- {
- FT_Int i;
-
-
- if ( !charmap || !charmap->face )
- return -1;
-
- for ( i = 0; i < charmap->face->num_charmaps; i++ )
- if ( charmap->face->charmaps[i] == charmap )
- break;
-
- FT_ASSERT( i < charmap->face->num_charmaps );
-
- return i;
- }
-
-
- static void
- ft_cmap_done_internal( FT_CMap cmap )
- {
- FT_CMap_Class clazz = cmap->clazz;
- FT_Face face = cmap->charmap.face;
- FT_Memory memory = FT_FACE_MEMORY( face );
-
-
- if ( clazz->done )
- clazz->done( cmap );
-
- FT_FREE( cmap );
- }
-
-
- FT_BASE_DEF( void )
- FT_CMap_Done( FT_CMap cmap )
- {
- if ( cmap )
- {
- FT_Face face = cmap->charmap.face;
- FT_Memory memory = FT_FACE_MEMORY( face );
- FT_Error error;
- FT_Int i, j;
-
-
- for ( i = 0; i < face->num_charmaps; i++ )
- {
- if ( (FT_CMap)face->charmaps[i] == cmap )
- {
- FT_CharMap last_charmap = face->charmaps[face->num_charmaps - 1];
-
-
- if ( FT_QRENEW_ARRAY( face->charmaps,
- face->num_charmaps,
- face->num_charmaps - 1 ) )
- return;
-
- /* remove it from our list of charmaps */
- for ( j = i + 1; j < face->num_charmaps; j++ )
- {
- if ( j == face->num_charmaps - 1 )
- face->charmaps[j - 1] = last_charmap;
- else
- face->charmaps[j - 1] = face->charmaps[j];
- }
-
- face->num_charmaps--;
-
- if ( (FT_CMap)face->charmap == cmap )
- face->charmap = NULL;
-
- ft_cmap_done_internal( cmap );
-
- break;
- }
- }
- }
- }
-
-
- FT_BASE_DEF( FT_Error )
- FT_CMap_New( FT_CMap_Class clazz,
- FT_Pointer init_data,
- FT_CharMap charmap,
- FT_CMap *acmap )
- {
- FT_Error error;
- FT_Face face;
- FT_Memory memory;
- FT_CMap cmap = NULL;
-
-
- if ( !clazz || !charmap || !charmap->face )
- return FT_THROW( Invalid_Argument );
-
- face = charmap->face;
- memory = FT_FACE_MEMORY( face );
-
- if ( !FT_ALLOC( cmap, clazz->size ) )
- {
- cmap->charmap = *charmap;
- cmap->clazz = clazz;
-
- if ( clazz->init )
- {
- error = clazz->init( cmap, init_data );
- if ( error )
- goto Fail;
- }
-
- /* add it to our list of charmaps */
- if ( FT_QRENEW_ARRAY( face->charmaps,
- face->num_charmaps,
- face->num_charmaps + 1 ) )
- goto Fail;
-
- face->charmaps[face->num_charmaps++] = (FT_CharMap)cmap;
- }
-
- Exit:
- if ( acmap )
- *acmap = cmap;
-
- return error;
-
- Fail:
- ft_cmap_done_internal( cmap );
- cmap = NULL;
- goto Exit;
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_UInt )
- FT_Get_Char_Index( FT_Face face,
- FT_ULong charcode )
- {
- FT_UInt result = 0;
-
-
- if ( face && face->charmap )
- {
- FT_CMap cmap = FT_CMAP( face->charmap );
-
-
- if ( charcode > 0xFFFFFFFFUL )
- {
- FT_TRACE1(( "FT_Get_Char_Index: too large charcode" ));
- FT_TRACE1(( " 0x%lx is truncated\n", charcode ));
- }
-
- result = cmap->clazz->char_index( cmap, (FT_UInt32)charcode );
- if ( result >= (FT_UInt)face->num_glyphs )
- result = 0;
- }
-
- return result;
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_ULong )
- FT_Get_First_Char( FT_Face face,
- FT_UInt *agindex )
- {
- FT_ULong result = 0;
- FT_UInt gindex = 0;
-
-
- /* only do something if we have a charmap, and we have glyphs at all */
- if ( face && face->charmap && face->num_glyphs )
- {
- gindex = FT_Get_Char_Index( face, 0 );
- if ( gindex == 0 )
- result = FT_Get_Next_Char( face, 0, &gindex );
- }
-
- if ( agindex )
- *agindex = gindex;
-
- return result;
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_ULong )
- FT_Get_Next_Char( FT_Face face,
- FT_ULong charcode,
- FT_UInt *agindex )
- {
- FT_ULong result = 0;
- FT_UInt gindex = 0;
-
-
- if ( face && face->charmap && face->num_glyphs )
- {
- FT_UInt32 code = (FT_UInt32)charcode;
- FT_CMap cmap = FT_CMAP( face->charmap );
-
-
- do
- {
- gindex = cmap->clazz->char_next( cmap, &code );
-
- } while ( gindex >= (FT_UInt)face->num_glyphs );
-
- result = ( gindex == 0 ) ? 0 : code;
- }
-
- if ( agindex )
- *agindex = gindex;
-
- return result;
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Face_Properties( FT_Face face,
- FT_UInt num_properties,
- FT_Parameter* properties )
- {
- FT_Error error = FT_Err_Ok;
-
-
- if ( num_properties > 0 && !properties )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- for ( ; num_properties > 0; num_properties-- )
- {
- if ( properties->tag == FT_PARAM_TAG_STEM_DARKENING )
- {
- if ( properties->data )
- {
- if ( *( (FT_Bool*)properties->data ) == TRUE )
- face->internal->no_stem_darkening = FALSE;
- else
- face->internal->no_stem_darkening = TRUE;
- }
- else
- {
- /* use module default */
- face->internal->no_stem_darkening = -1;
- }
- }
- else if ( properties->tag == FT_PARAM_TAG_LCD_FILTER_WEIGHTS )
- {
-#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
- if ( properties->data )
- {
- ft_memcpy( face->internal->lcd_weights,
- properties->data,
- FT_LCD_FILTER_FIVE_TAPS );
- face->internal->lcd_filter_func = ft_lcd_filter_fir;
- }
-#else
- error = FT_THROW( Unimplemented_Feature );
- goto Exit;
-#endif
- }
- else if ( properties->tag == FT_PARAM_TAG_RANDOM_SEED )
- {
- if ( properties->data )
- {
- face->internal->random_seed = *( (FT_Int32*)properties->data );
- if ( face->internal->random_seed < 0 )
- face->internal->random_seed = 0;
- }
- else
- {
- /* use module default */
- face->internal->random_seed = -1;
- }
- }
- else
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- if ( error )
- break;
-
- properties++;
- }
-
- Exit:
- return error;
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_UInt )
- FT_Face_GetCharVariantIndex( FT_Face face,
- FT_ULong charcode,
- FT_ULong variantSelector )
- {
- FT_UInt result = 0;
-
-
- if ( face &&
- face->charmap &&
- face->charmap->encoding == FT_ENCODING_UNICODE )
- {
- FT_CharMap charmap = find_variant_selector_charmap( face );
- FT_CMap ucmap = FT_CMAP( face->charmap );
-
-
- if ( charmap )
- {
- FT_CMap vcmap = FT_CMAP( charmap );
-
-
- if ( charcode > 0xFFFFFFFFUL )
- {
- FT_TRACE1(( "FT_Face_GetCharVariantIndex:"
- " too large charcode" ));
- FT_TRACE1(( " 0x%lx is truncated\n", charcode ));
- }
- if ( variantSelector > 0xFFFFFFFFUL )
- {
- FT_TRACE1(( "FT_Face_GetCharVariantIndex:"
- " too large variantSelector" ));
- FT_TRACE1(( " 0x%lx is truncated\n", variantSelector ));
- }
-
- result = vcmap->clazz->char_var_index( vcmap, ucmap,
- (FT_UInt32)charcode,
- (FT_UInt32)variantSelector );
- }
- }
-
- return result;
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Int )
- FT_Face_GetCharVariantIsDefault( FT_Face face,
- FT_ULong charcode,
- FT_ULong variantSelector )
- {
- FT_Int result = -1;
-
-
- if ( face )
- {
- FT_CharMap charmap = find_variant_selector_charmap( face );
-
-
- if ( charmap )
- {
- FT_CMap vcmap = FT_CMAP( charmap );
-
-
- if ( charcode > 0xFFFFFFFFUL )
- {
- FT_TRACE1(( "FT_Face_GetCharVariantIsDefault:"
- " too large charcode" ));
- FT_TRACE1(( " 0x%lx is truncated\n", charcode ));
- }
- if ( variantSelector > 0xFFFFFFFFUL )
- {
- FT_TRACE1(( "FT_Face_GetCharVariantIsDefault:"
- " too large variantSelector" ));
- FT_TRACE1(( " 0x%lx is truncated\n", variantSelector ));
- }
-
- result = vcmap->clazz->char_var_default( vcmap,
- (FT_UInt32)charcode,
- (FT_UInt32)variantSelector );
- }
- }
-
- return result;
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_UInt32* )
- FT_Face_GetVariantSelectors( FT_Face face )
- {
- FT_UInt32 *result = NULL;
-
-
- if ( face )
- {
- FT_CharMap charmap = find_variant_selector_charmap( face );
-
-
- if ( charmap )
- {
- FT_CMap vcmap = FT_CMAP( charmap );
- FT_Memory memory = FT_FACE_MEMORY( face );
-
-
- result = vcmap->clazz->variant_list( vcmap, memory );
- }
- }
-
- return result;
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_UInt32* )
- FT_Face_GetVariantsOfChar( FT_Face face,
- FT_ULong charcode )
- {
- FT_UInt32 *result = NULL;
-
-
- if ( face )
- {
- FT_CharMap charmap = find_variant_selector_charmap( face );
-
-
- if ( charmap )
- {
- FT_CMap vcmap = FT_CMAP( charmap );
- FT_Memory memory = FT_FACE_MEMORY( face );
-
-
- if ( charcode > 0xFFFFFFFFUL )
- {
- FT_TRACE1(( "FT_Face_GetVariantsOfChar: too large charcode" ));
- FT_TRACE1(( " 0x%lx is truncated\n", charcode ));
- }
-
- result = vcmap->clazz->charvariant_list( vcmap, memory,
- (FT_UInt32)charcode );
- }
- }
- return result;
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_UInt32* )
- FT_Face_GetCharsOfVariant( FT_Face face,
- FT_ULong variantSelector )
- {
- FT_UInt32 *result = NULL;
-
-
- if ( face )
- {
- FT_CharMap charmap = find_variant_selector_charmap( face );
-
-
- if ( charmap )
- {
- FT_CMap vcmap = FT_CMAP( charmap );
- FT_Memory memory = FT_FACE_MEMORY( face );
-
-
- if ( variantSelector > 0xFFFFFFFFUL )
- {
- FT_TRACE1(( "FT_Get_Char_Index: too large variantSelector" ));
- FT_TRACE1(( " 0x%lx is truncated\n", variantSelector ));
- }
-
- result = vcmap->clazz->variantchar_list( vcmap, memory,
- (FT_UInt32)variantSelector );
- }
- }
-
- return result;
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_UInt )
- FT_Get_Name_Index( FT_Face face,
- const FT_String* glyph_name )
- {
- FT_UInt result = 0;
-
-
- if ( face &&
- FT_HAS_GLYPH_NAMES( face ) &&
- glyph_name )
- {
- FT_Service_GlyphDict service;
-
-
- FT_FACE_LOOKUP_SERVICE( face,
- service,
- GLYPH_DICT );
-
- if ( service && service->name_index )
- result = service->name_index( face, glyph_name );
- }
-
- return result;
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Get_Glyph_Name( FT_Face face,
- FT_UInt glyph_index,
- FT_Pointer buffer,
- FT_UInt buffer_max )
- {
- FT_Error error;
- FT_Service_GlyphDict service;
-
-
- if ( !face )
- return FT_THROW( Invalid_Face_Handle );
-
- if ( !buffer || buffer_max == 0 )
- return FT_THROW( Invalid_Argument );
-
- /* clean up buffer */
- ((FT_Byte*)buffer)[0] = '\0';
-
- if ( (FT_Long)glyph_index >= face->num_glyphs )
- return FT_THROW( Invalid_Glyph_Index );
-
- if ( !FT_HAS_GLYPH_NAMES( face ) )
- return FT_THROW( Invalid_Argument );
-
- FT_FACE_LOOKUP_SERVICE( face, service, GLYPH_DICT );
- if ( service && service->get_name )
- error = service->get_name( face, glyph_index, buffer, buffer_max );
- else
- error = FT_THROW( Invalid_Argument );
-
- return error;
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( const char* )
- FT_Get_Postscript_Name( FT_Face face )
- {
- const char* result = NULL;
-
-
- if ( !face )
- goto Exit;
-
- if ( !result )
- {
- FT_Service_PsFontName service;
-
-
- FT_FACE_LOOKUP_SERVICE( face,
- service,
- POSTSCRIPT_FONT_NAME );
-
- if ( service && service->get_ps_font_name )
- result = service->get_ps_font_name( face );
- }
-
- Exit:
- return result;
- }
-
-
- /* documentation is in tttables.h */
-
- FT_EXPORT_DEF( void* )
- FT_Get_Sfnt_Table( FT_Face face,
- FT_Sfnt_Tag tag )
- {
- void* table = NULL;
- FT_Service_SFNT_Table service;
-
-
- if ( face && FT_IS_SFNT( face ) )
- {
- FT_FACE_FIND_SERVICE( face, service, SFNT_TABLE );
- if ( service )
- table = service->get_table( face, tag );
- }
-
- return table;
- }
-
-
- /* documentation is in tttables.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Load_Sfnt_Table( FT_Face face,
- FT_ULong tag,
- FT_Long offset,
- FT_Byte* buffer,
- FT_ULong* length )
- {
- FT_Service_SFNT_Table service;
-
-
- if ( !face || !FT_IS_SFNT( face ) )
- return FT_THROW( Invalid_Face_Handle );
-
- FT_FACE_FIND_SERVICE( face, service, SFNT_TABLE );
- if ( !service )
- return FT_THROW( Unimplemented_Feature );
-
- return service->load_table( face, tag, offset, buffer, length );
- }
-
-
- /* documentation is in tttables.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Sfnt_Table_Info( FT_Face face,
- FT_UInt table_index,
- FT_ULong *tag,
- FT_ULong *length )
- {
- FT_Service_SFNT_Table service;
- FT_ULong offset;
-
-
- /* test for valid `length' delayed to `service->table_info' */
-
- if ( !face || !FT_IS_SFNT( face ) )
- return FT_THROW( Invalid_Face_Handle );
-
- FT_FACE_FIND_SERVICE( face, service, SFNT_TABLE );
- if ( !service )
- return FT_THROW( Unimplemented_Feature );
-
- return service->table_info( face, table_index, tag, &offset, length );
- }
-
-
- /* documentation is in tttables.h */
-
- FT_EXPORT_DEF( FT_ULong )
- FT_Get_CMap_Language_ID( FT_CharMap charmap )
- {
- FT_Service_TTCMaps service;
- FT_Face face;
- TT_CMapInfo cmap_info;
-
-
- if ( !charmap || !charmap->face )
- return 0;
-
- face = charmap->face;
- FT_FACE_FIND_SERVICE( face, service, TT_CMAP );
- if ( !service )
- return 0;
- if ( service->get_cmap_info( charmap, &cmap_info ))
- return 0;
-
- return cmap_info.language;
- }
-
-
- /* documentation is in tttables.h */
-
- FT_EXPORT_DEF( FT_Long )
- FT_Get_CMap_Format( FT_CharMap charmap )
- {
- FT_Service_TTCMaps service;
- FT_Face face;
- TT_CMapInfo cmap_info;
-
-
- if ( !charmap || !charmap->face )
- return -1;
-
- face = charmap->face;
- FT_FACE_FIND_SERVICE( face, service, TT_CMAP );
- if ( !service )
- return -1;
- if ( service->get_cmap_info( charmap, &cmap_info ))
- return -1;
-
- return cmap_info.format;
- }
-
-
- /* documentation is in ftsizes.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Activate_Size( FT_Size size )
- {
- FT_Face face;
-
-
- if ( !size )
- return FT_THROW( Invalid_Size_Handle );
-
- face = size->face;
- if ( !face || !face->driver )
- return FT_THROW( Invalid_Face_Handle );
-
- /* we don't need anything more complex than that; all size objects */
- /* are already listed by the face */
- face->size = size;
-
- return FT_Err_Ok;
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /**** ****/
- /**** ****/
- /**** R E N D E R E R S ****/
- /**** ****/
- /**** ****/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
- /* lookup a renderer by glyph format in the library's list */
- FT_BASE_DEF( FT_Renderer )
- FT_Lookup_Renderer( FT_Library library,
- FT_Glyph_Format format,
- FT_ListNode* node )
- {
- FT_ListNode cur;
- FT_Renderer result = NULL;
-
-
- if ( !library )
- goto Exit;
-
- cur = library->renderers.head;
-
- if ( node )
- {
- if ( *node )
- cur = (*node)->next;
- *node = NULL;
- }
-
- while ( cur )
- {
- FT_Renderer renderer = FT_RENDERER( cur->data );
-
-
- if ( renderer->glyph_format == format )
- {
- if ( node )
- *node = cur;
-
- result = renderer;
- break;
- }
- cur = cur->next;
- }
-
- Exit:
- return result;
- }
-
-
- static FT_Renderer
- ft_lookup_glyph_renderer( FT_GlyphSlot slot )
- {
- FT_Face face = slot->face;
- FT_Library library = FT_FACE_LIBRARY( face );
- FT_Renderer result = library->cur_renderer;
-
-
- if ( !result || result->glyph_format != slot->format )
- result = FT_Lookup_Renderer( library, slot->format, 0 );
-
- return result;
- }
-
-
- static void
- ft_set_current_renderer( FT_Library library )
- {
- FT_Renderer renderer;
-
-
- renderer = FT_Lookup_Renderer( library, FT_GLYPH_FORMAT_OUTLINE, 0 );
- library->cur_renderer = renderer;
- }
-
-
- static FT_Error
- ft_add_renderer( FT_Module module )
- {
- FT_Library library = module->library;
- FT_Memory memory = library->memory;
- FT_Error error;
- FT_ListNode node = NULL;
-
-
- if ( FT_QNEW( node ) )
- goto Exit;
-
- {
- FT_Renderer render = FT_RENDERER( module );
- FT_Renderer_Class* clazz = (FT_Renderer_Class*)module->clazz;
-
-
- render->clazz = clazz;
- render->glyph_format = clazz->glyph_format;
-
- /* allocate raster object if needed */
- if ( clazz->raster_class && clazz->raster_class->raster_new )
- {
- error = clazz->raster_class->raster_new( memory, &render->raster );
- if ( error )
- goto Fail;
-
- render->raster_render = clazz->raster_class->raster_render;
- render->render = clazz->render_glyph;
- }
-
-#ifdef FT_CONFIG_OPTION_SVG
- if ( clazz->glyph_format == FT_GLYPH_FORMAT_SVG )
- render->render = clazz->render_glyph;
-#endif
-
- /* add to list */
- node->data = module;
- FT_List_Add( &library->renderers, node );
-
- ft_set_current_renderer( library );
- }
-
- Fail:
- if ( error )
- FT_FREE( node );
-
- Exit:
- return error;
- }
-
-
- static void
- ft_remove_renderer( FT_Module module )
- {
- FT_Library library;
- FT_Memory memory;
- FT_ListNode node;
-
-
- library = module->library;
- if ( !library )
- return;
-
- memory = library->memory;
-
- node = FT_List_Find( &library->renderers, module );
- if ( node )
- {
- FT_Renderer render = FT_RENDERER( module );
-
-
- /* release raster object, if any */
- if ( render->raster )
- render->clazz->raster_class->raster_done( render->raster );
-
- /* remove from list */
- FT_List_Remove( &library->renderers, node );
- FT_FREE( node );
-
- ft_set_current_renderer( library );
- }
- }
-
-
- /* documentation is in ftrender.h */
-
- FT_EXPORT_DEF( FT_Renderer )
- FT_Get_Renderer( FT_Library library,
- FT_Glyph_Format format )
- {
- /* test for valid `library' delayed to `FT_Lookup_Renderer' */
-
- return FT_Lookup_Renderer( library, format, 0 );
- }
-
-
- /* documentation is in ftrender.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Set_Renderer( FT_Library library,
- FT_Renderer renderer,
- FT_UInt num_params,
- FT_Parameter* parameters )
- {
- FT_ListNode node;
- FT_Error error = FT_Err_Ok;
-
- FT_Renderer_SetModeFunc set_mode;
-
-
- if ( !library )
- {
- error = FT_THROW( Invalid_Library_Handle );
- goto Exit;
- }
-
- if ( !renderer )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- if ( num_params > 0 && !parameters )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- node = FT_List_Find( &library->renderers, renderer );
- if ( !node )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- FT_List_Up( &library->renderers, node );
-
- if ( renderer->glyph_format == FT_GLYPH_FORMAT_OUTLINE )
- library->cur_renderer = renderer;
-
- set_mode = renderer->clazz->set_mode;
-
- for ( ; num_params > 0; num_params-- )
- {
- error = set_mode( renderer, parameters->tag, parameters->data );
- if ( error )
- break;
- parameters++;
- }
-
- Exit:
- return error;
- }
-
-
- FT_BASE_DEF( FT_Error )
- FT_Render_Glyph_Internal( FT_Library library,
- FT_GlyphSlot slot,
- FT_Render_Mode render_mode )
- {
- FT_Error error = FT_Err_Ok;
- FT_Face face = slot->face;
- FT_Renderer renderer;
-
-
- switch ( slot->format )
- {
- default:
- if ( slot->internal->load_flags & FT_LOAD_COLOR )
- {
- FT_LayerIterator iterator;
-
- FT_UInt base_glyph = slot->glyph_index;
-
- FT_Bool have_layers;
- FT_UInt glyph_index;
- FT_UInt color_index;
-
-
- /* check whether we have colored glyph layers */
- iterator.p = NULL;
- have_layers = FT_Get_Color_Glyph_Layer( face,
- base_glyph,
- &glyph_index,
- &color_index,
- &iterator );
- if ( have_layers )
- {
- error = FT_New_GlyphSlot( face, NULL );
- if ( !error )
- {
- TT_Face ttface = (TT_Face)face;
- SFNT_Service sfnt = (SFNT_Service)ttface->sfnt;
-
-
- do
- {
- FT_Int32 load_flags = slot->internal->load_flags;
-
-
- /* disable the `FT_LOAD_COLOR' flag to avoid recursion */
- /* right here in this function */
- load_flags &= ~FT_LOAD_COLOR;
-
- /* render into the new `face->glyph' glyph slot */
- load_flags |= FT_LOAD_RENDER;
-
- error = FT_Load_Glyph( face, glyph_index, load_flags );
- if ( error )
- break;
-
- /* blend new `face->glyph' into old `slot'; */
- /* at the first call, `slot' is still empty */
- error = sfnt->colr_blend( ttface,
- color_index,
- slot,
- face->glyph );
- if ( error )
- break;
-
- } while ( FT_Get_Color_Glyph_Layer( face,
- base_glyph,
- &glyph_index,
- &color_index,
- &iterator ) );
-
- if ( !error )
- slot->format = FT_GLYPH_FORMAT_BITMAP;
-
- /* this call also restores `slot' as the glyph slot */
- FT_Done_GlyphSlot( face->glyph );
- }
-
- if ( !error )
- return error;
-
- /* Failed to do the colored layer. Draw outline instead. */
- slot->format = FT_GLYPH_FORMAT_OUTLINE;
- }
- }
-
- {
- FT_ListNode node = NULL;
-
-
- /* small shortcut for the very common case */
- if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
- {
- renderer = library->cur_renderer;
- node = library->renderers.head;
- }
- else
- renderer = FT_Lookup_Renderer( library, slot->format, &node );
-
- error = FT_ERR( Cannot_Render_Glyph );
- while ( renderer )
- {
- error = renderer->render( renderer, slot, render_mode, NULL );
- if ( !error ||
- FT_ERR_NEQ( error, Cannot_Render_Glyph ) )
- break;
-
- /* FT_Err_Cannot_Render_Glyph is returned if the render mode */
- /* is unsupported by the current renderer for this glyph image */
- /* format. */
-
- /* now, look for another renderer that supports the same */
- /* format. */
- renderer = FT_Lookup_Renderer( library, slot->format, &node );
- }
-
- /* it is not an error if we cannot render a bitmap glyph */
- if ( FT_ERR_EQ( error, Cannot_Render_Glyph ) &&
- slot->format == FT_GLYPH_FORMAT_BITMAP )
- error = FT_Err_Ok;
- }
- }
-
-#ifdef FT_DEBUG_LEVEL_TRACE
-
-#undef FT_COMPONENT
-#define FT_COMPONENT checksum
-
- /*
- * Computing the MD5 checksum is expensive, unnecessarily distorting a
- * possible profiling of FreeType if compiled with tracing support. For
- * this reason, we execute the following code only if explicitly
- * requested.
- */
-
- /* we use FT_TRACE3 in this block */
- if ( !error &&
- ft_trace_levels[trace_checksum] >= 3 &&
- slot->bitmap.buffer )
- {
- FT_Bitmap bitmap;
- FT_Error err;
-
-
- FT_Bitmap_Init( &bitmap );
-
- /* we convert to a single bitmap format for computing the checksum */
- /* this also converts the bitmap flow to `down' (i.e., pitch > 0) */
- err = FT_Bitmap_Convert( library, &slot->bitmap, &bitmap, 1 );
- if ( !err )
- {
- MD5_CTX ctx;
- unsigned char md5[16];
- unsigned long coverage = 0;
- int i, j;
- int rows = (int)bitmap.rows;
- int pitch = bitmap.pitch;
-
-
- FT_TRACE3(( "FT_Render_Glyph: bitmap %dx%d, %s (mode %d)\n",
- pitch,
- rows,
- pixel_modes[slot->bitmap.pixel_mode],
- slot->bitmap.pixel_mode ));
-
- for ( i = 0; i < rows; i++ )
- for ( j = 0; j < pitch; j++ )
- coverage += bitmap.buffer[i * pitch + j];
-
- FT_TRACE3(( " Total coverage: %lu\n", coverage ));
-
- MD5_Init( &ctx );
- if ( bitmap.buffer )
- MD5_Update( &ctx, bitmap.buffer,
- (unsigned long)rows * (unsigned long)pitch );
- MD5_Final( md5, &ctx );
-
- FT_TRACE3(( " MD5 checksum: " ));
- for ( i = 0; i < 16; i++ )
- FT_TRACE3(( "%02X", md5[i] ));
- FT_TRACE3(( "\n" ));
- }
-
- FT_Bitmap_Done( library, &bitmap );
- }
-
- /*
- * Dump bitmap in Netpbm format (PBM or PGM).
- */
-
- /* we use FT_TRACE7 in this block */
- if ( !error &&
- ft_trace_levels[trace_checksum] >= 7 &&
- slot->bitmap.buffer )
- {
- if ( slot->bitmap.rows < 128U &&
- slot->bitmap.width < 128U )
- {
- int rows = (int)slot->bitmap.rows;
- int width = (int)slot->bitmap.width;
- int pitch = slot->bitmap.pitch;
- int i, j, m;
-
- unsigned char* topleft = slot->bitmap.buffer;
-
-
- if ( pitch < 0 )
- topleft -= pitch * ( rows - 1 );
-
- FT_TRACE7(( "Netpbm image: start\n" ));
- switch ( slot->bitmap.pixel_mode )
- {
- case FT_PIXEL_MODE_MONO:
- FT_TRACE7(( "P1 %d %d\n", width, rows ));
- for ( i = 0; i < rows; i++ )
- {
- for ( j = 0; j < width; )
- for ( m = 128; m > 0 && j < width; m >>= 1, j++ )
- FT_TRACE7(( " %d",
- ( topleft[i * pitch + j / 8] & m ) != 0 ));
- FT_TRACE7(( "\n" ));
- }
- break;
-
- default:
- FT_TRACE7(( "P2 %d %d 255\n", width, rows ));
- for ( i = 0; i < rows; i++ )
- {
- for ( j = 0; j < width; j += 1 )
- FT_TRACE7(( " %3u", topleft[i * pitch + j] ));
- FT_TRACE7(( "\n" ));
- }
- }
- FT_TRACE7(( "Netpbm image: end\n" ));
- }
- else
- FT_TRACE7(( "Netpbm image: too large, omitted\n" ));
- }
-
-#undef FT_COMPONENT
-#define FT_COMPONENT objs
-
-#endif /* FT_DEBUG_LEVEL_TRACE */
-
- return error;
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Render_Glyph( FT_GlyphSlot slot,
- FT_Render_Mode render_mode )
- {
- FT_Library library;
-
-
- if ( !slot || !slot->face )
- return FT_THROW( Invalid_Argument );
-
- library = FT_FACE_LIBRARY( slot->face );
-
- return FT_Render_Glyph_Internal( library, slot, render_mode );
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /**** ****/
- /**** ****/
- /**** M O D U L E S ****/
- /**** ****/
- /**** ****/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /**************************************************************************
- *
- * @Function:
- * Destroy_Module
- *
- * @Description:
- * Destroys a given module object. For drivers, this also destroys
- * all child faces.
- *
- * @InOut:
- * module ::
- * A handle to the target driver object.
- *
- * @Note:
- * The driver _must_ be LOCKED!
- */
- static void
- Destroy_Module( FT_Module module )
- {
- FT_Memory memory = module->memory;
- FT_Module_Class* clazz = module->clazz;
- FT_Library library = module->library;
-
-
- if ( library && library->auto_hinter == module )
- library->auto_hinter = NULL;
-
- /* if the module is a renderer */
- if ( FT_MODULE_IS_RENDERER( module ) )
- ft_remove_renderer( module );
-
- /* if the module is a font driver, add some steps */
- if ( FT_MODULE_IS_DRIVER( module ) )
- Destroy_Driver( FT_DRIVER( module ) );
-
- /* finalize the module object */
- if ( clazz->module_done )
- clazz->module_done( module );
-
- /* discard it */
- FT_FREE( module );
- }
-
-
- /* documentation is in ftmodapi.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Add_Module( FT_Library library,
- const FT_Module_Class* clazz )
- {
- FT_Error error;
- FT_Memory memory;
- FT_Module module = NULL;
- FT_UInt nn;
-
-
-#define FREETYPE_VER_FIXED ( ( (FT_Long)FREETYPE_MAJOR << 16 ) | \
- FREETYPE_MINOR )
-
- if ( !library )
- return FT_THROW( Invalid_Library_Handle );
-
- if ( !clazz )
- return FT_THROW( Invalid_Argument );
-
- /* check FreeType version */
- if ( clazz->module_requires > FREETYPE_VER_FIXED )
- return FT_THROW( Invalid_Version );
-
- /* look for a module with the same name in the library's table */
- for ( nn = 0; nn < library->num_modules; nn++ )
- {
- module = library->modules[nn];
- if ( ft_strcmp( module->clazz->module_name, clazz->module_name ) == 0 )
- {
- /* this installed module has the same name, compare their versions */
- if ( clazz->module_version <= module->clazz->module_version )
- return FT_THROW( Lower_Module_Version );
-
- /* remove the module from our list, then exit the loop to replace */
- /* it by our new version.. */
- FT_Remove_Module( library, module );
- break;
- }
- }
-
- memory = library->memory;
- error = FT_Err_Ok;
-
- if ( library->num_modules >= FT_MAX_MODULES )
- {
- error = FT_THROW( Too_Many_Drivers );
- goto Exit;
- }
-
- /* allocate module object */
- if ( FT_ALLOC( module, clazz->module_size ) )
- goto Exit;
-
- /* base initialization */
- module->library = library;
- module->memory = memory;
- module->clazz = (FT_Module_Class*)clazz;
-
- /* check whether the module is a renderer - this must be performed */
- /* before the normal module initialization */
- if ( FT_MODULE_IS_RENDERER( module ) )
- {
- /* add to the renderers list */
- error = ft_add_renderer( module );
- if ( error )
- goto Fail;
- }
-
- /* is the module a auto-hinter? */
- if ( FT_MODULE_IS_HINTER( module ) )
- library->auto_hinter = module;
-
- /* if the module is a font driver */
- if ( FT_MODULE_IS_DRIVER( module ) )
- {
- FT_Driver driver = FT_DRIVER( module );
-
-
- driver->clazz = (FT_Driver_Class)module->clazz;
- }
-
- if ( clazz->module_init )
- {
- error = clazz->module_init( module );
- if ( error )
- goto Fail;
- }
-
- /* add module to the library's table */
- library->modules[library->num_modules++] = module;
-
- Exit:
- return error;
-
- Fail:
- if ( FT_MODULE_IS_RENDERER( module ) )
- {
- FT_Renderer renderer = FT_RENDERER( module );
-
-
- if ( renderer->clazz &&
- renderer->clazz->glyph_format == FT_GLYPH_FORMAT_OUTLINE &&
- renderer->raster )
- renderer->clazz->raster_class->raster_done( renderer->raster );
- }
-
- FT_FREE( module );
- goto Exit;
- }
-
-
- /* documentation is in ftmodapi.h */
-
- FT_EXPORT_DEF( FT_Module )
- FT_Get_Module( FT_Library library,
- const char* module_name )
- {
- FT_Module result = NULL;
- FT_Module* cur;
- FT_Module* limit;
-
-
- if ( !library || !module_name )
- return result;
-
- cur = library->modules;
- limit = cur + library->num_modules;
-
- for ( ; cur < limit; cur++ )
- if ( ft_strcmp( cur[0]->clazz->module_name, module_name ) == 0 )
- {
- result = cur[0];
- break;
- }
-
- return result;
- }
-
-
- /* documentation is in ftobjs.h */
-
- FT_BASE_DEF( const void* )
- FT_Get_Module_Interface( FT_Library library,
- const char* mod_name )
- {
- FT_Module module;
-
-
- /* test for valid `library' delayed to FT_Get_Module() */
-
- module = FT_Get_Module( library, mod_name );
-
- return module ? module->clazz->module_interface : 0;
- }
-
-
- FT_BASE_DEF( FT_Pointer )
- ft_module_get_service( FT_Module module,
- const char* service_id,
- FT_Bool global )
- {
- FT_Pointer result = NULL;
-
-
- if ( module )
- {
- FT_ASSERT( module->clazz && module->clazz->get_interface );
-
- /* first, look for the service in the module */
- if ( module->clazz->get_interface )
- result = module->clazz->get_interface( module, service_id );
-
- if ( global && !result )
- {
- /* we didn't find it, look in all other modules then */
- FT_Library library = module->library;
- FT_Module* cur = library->modules;
- FT_Module* limit = cur + library->num_modules;
-
-
- for ( ; cur < limit; cur++ )
- {
- if ( cur[0] != module )
- {
- FT_ASSERT( cur[0]->clazz );
-
- if ( cur[0]->clazz->get_interface )
- {
- result = cur[0]->clazz->get_interface( cur[0], service_id );
- if ( result )
- break;
- }
- }
- }
- }
- }
-
- return result;
- }
-
-
- /* documentation is in ftmodapi.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Remove_Module( FT_Library library,
- FT_Module module )
- {
- /* try to find the module from the table, then remove it from there */
-
- if ( !library )
- return FT_THROW( Invalid_Library_Handle );
-
- if ( module )
- {
- FT_Module* cur = library->modules;
- FT_Module* limit = cur + library->num_modules;
-
-
- for ( ; cur < limit; cur++ )
- {
- if ( cur[0] == module )
- {
- /* remove it from the table */
- library->num_modules--;
- limit--;
- while ( cur < limit )
- {
- cur[0] = cur[1];
- cur++;
- }
- limit[0] = NULL;
-
- /* destroy the module */
- Destroy_Module( module );
-
- return FT_Err_Ok;
- }
- }
- }
- return FT_THROW( Invalid_Driver_Handle );
- }
-
-
- static FT_Error
- ft_property_do( FT_Library library,
- const FT_String* module_name,
- const FT_String* property_name,
- void* value,
- FT_Bool set,
- FT_Bool value_is_string )
- {
- FT_Module* cur;
- FT_Module* limit;
- FT_Module_Interface interface;
-
- FT_Service_Properties service;
-
-#ifdef FT_DEBUG_LEVEL_ERROR
- const FT_String* set_name = "FT_Property_Set";
- const FT_String* get_name = "FT_Property_Get";
- const FT_String* func_name = set ? set_name : get_name;
-#endif
-
- FT_Bool missing_func;
-
-
- if ( !library )
- return FT_THROW( Invalid_Library_Handle );
-
- if ( !module_name || !property_name || !value )
- return FT_THROW( Invalid_Argument );
-
- cur = library->modules;
- limit = cur + library->num_modules;
-
- /* search module */
- for ( ; cur < limit; cur++ )
- if ( !ft_strcmp( cur[0]->clazz->module_name, module_name ) )
- break;
-
- if ( cur == limit )
- {
- FT_TRACE2(( "%s: can't find module `%s'\n",
- func_name, module_name ));
- return FT_THROW( Missing_Module );
- }
-
- /* check whether we have a service interface */
- if ( !cur[0]->clazz->get_interface )
- {
- FT_TRACE2(( "%s: module `%s' doesn't support properties\n",
- func_name, module_name ));
- return FT_THROW( Unimplemented_Feature );
- }
-
- /* search property service */
- interface = cur[0]->clazz->get_interface( cur[0],
- FT_SERVICE_ID_PROPERTIES );
- if ( !interface )
- {
- FT_TRACE2(( "%s: module `%s' doesn't support properties\n",
- func_name, module_name ));
- return FT_THROW( Unimplemented_Feature );
- }
-
- service = (FT_Service_Properties)interface;
-
- if ( set )
- missing_func = FT_BOOL( !service->set_property );
- else
- missing_func = FT_BOOL( !service->get_property );
-
- if ( missing_func )
- {
- FT_TRACE2(( "%s: property service of module `%s' is broken\n",
- func_name, module_name ));
- return FT_THROW( Unimplemented_Feature );
- }
-
- return set ? service->set_property( cur[0],
- property_name,
- value,
- value_is_string )
- : service->get_property( cur[0],
- property_name,
- value );
- }
-
-
- /* documentation is in ftmodapi.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Property_Set( FT_Library library,
- const FT_String* module_name,
- const FT_String* property_name,
- const void* value )
- {
- return ft_property_do( library,
- module_name,
- property_name,
- (void*)value,
- TRUE,
- FALSE );
- }
-
-
- /* documentation is in ftmodapi.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Property_Get( FT_Library library,
- const FT_String* module_name,
- const FT_String* property_name,
- void* value )
- {
- return ft_property_do( library,
- module_name,
- property_name,
- value,
- FALSE,
- FALSE );
- }
-
-
-#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
-
- /* this variant is used for handling the FREETYPE_PROPERTIES */
- /* environment variable */
-
- FT_BASE_DEF( FT_Error )
- ft_property_string_set( FT_Library library,
- const FT_String* module_name,
- const FT_String* property_name,
- FT_String* value )
- {
- return ft_property_do( library,
- module_name,
- property_name,
- (void*)value,
- TRUE,
- TRUE );
- }
-
-#endif
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /**** ****/
- /**** ****/
- /**** L I B R A R Y ****/
- /**** ****/
- /**** ****/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /* documentation is in ftmodapi.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Reference_Library( FT_Library library )
- {
- if ( !library )
- return FT_THROW( Invalid_Library_Handle );
-
- library->refcount++;
-
- return FT_Err_Ok;
- }
-
-
- /* documentation is in ftmodapi.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_New_Library( FT_Memory memory,
- FT_Library *alibrary )
- {
- FT_Library library = NULL;
- FT_Error error;
-
-
- if ( !memory || !alibrary )
- return FT_THROW( Invalid_Argument );
-
-#ifndef FT_DEBUG_LOGGING
-#ifdef FT_DEBUG_LEVEL_ERROR
- /* init debugging support */
- ft_debug_init();
-#endif /* FT_DEBUG_LEVEL_ERROR */
-#endif /* !FT_DEBUG_LOGGING */
-
- /* first of all, allocate the library object */
- if ( FT_NEW( library ) )
- return error;
-
- library->memory = memory;
-
- library->version_major = FREETYPE_MAJOR;
- library->version_minor = FREETYPE_MINOR;
- library->version_patch = FREETYPE_PATCH;
-
- library->refcount = 1;
-
- /* That's ok now */
- *alibrary = library;
-
- return FT_Err_Ok;
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( void )
- FT_Library_Version( FT_Library library,
- FT_Int *amajor,
- FT_Int *aminor,
- FT_Int *apatch )
- {
- FT_Int major = 0;
- FT_Int minor = 0;
- FT_Int patch = 0;
-
-
- if ( library )
- {
- major = library->version_major;
- minor = library->version_minor;
- patch = library->version_patch;
- }
-
- if ( amajor )
- *amajor = major;
-
- if ( aminor )
- *aminor = minor;
-
- if ( apatch )
- *apatch = patch;
- }
-
-
- /* documentation is in ftmodapi.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Done_Library( FT_Library library )
- {
- FT_Memory memory;
-
-
- if ( !library )
- return FT_THROW( Invalid_Library_Handle );
-
- library->refcount--;
- if ( library->refcount > 0 )
- goto Exit;
-
- memory = library->memory;
-
- /*
- * Close all faces in the library. If we don't do this, we can have
- * some subtle memory leaks.
- *
- * Example:
- *
- * - the cff font driver uses the pshinter module in cff_size_done
- * - if the pshinter module is destroyed before the cff font driver,
- * opened FT_Face objects managed by the driver are not properly
- * destroyed, resulting in a memory leak
- *
- * Some faces are dependent on other faces, like Type42 faces that
- * depend on TrueType faces synthesized internally.
- *
- * The order of drivers should be specified in driver_name[].
- */
- {
- FT_UInt m, n;
- const char* driver_name[] = { "type42", NULL };
-
-
- for ( m = 0;
- m < sizeof ( driver_name ) / sizeof ( driver_name[0] );
- m++ )
- {
- for ( n = 0; n < library->num_modules; n++ )
- {
- FT_Module module = library->modules[n];
- const char* module_name = module->clazz->module_name;
- FT_List faces;
-
-
- if ( driver_name[m] &&
- ft_strcmp( module_name, driver_name[m] ) != 0 )
- continue;
-
- if ( ( module->clazz->module_flags & FT_MODULE_FONT_DRIVER ) == 0 )
- continue;
-
- FT_TRACE7(( "FT_Done_Library: close faces for %s\n", module_name ));
-
- faces = &FT_DRIVER( module )->faces_list;
- while ( faces->head )
- {
- FT_Done_Face( FT_FACE( faces->head->data ) );
- if ( faces->head )
- FT_TRACE0(( "FT_Done_Library: failed to free some faces\n" ));
- }
- }
- }
- }
-
- /* Close all other modules in the library */
-#if 1
- /* XXX Modules are removed in the reversed order so that */
- /* type42 module is removed before truetype module. This */
- /* avoids double free in some occasions. It is a hack. */
- while ( library->num_modules > 0 )
- FT_Remove_Module( library,
- library->modules[library->num_modules - 1] );
-#else
- {
- FT_UInt n;
-
-
- for ( n = 0; n < library->num_modules; n++ )
- {
- FT_Module module = library->modules[n];
-
-
- if ( module )
- {
- Destroy_Module( module );
- library->modules[n] = NULL;
- }
- }
- }
-#endif
-
- FT_FREE( library );
-
- Exit:
- return FT_Err_Ok;
- }
-
-
- /* documentation is in ftmodapi.h */
-
- FT_EXPORT_DEF( void )
- FT_Set_Debug_Hook( FT_Library library,
- FT_UInt hook_index,
- FT_DebugHook_Func debug_hook )
- {
- if ( library && debug_hook &&
- hook_index <
- ( sizeof ( library->debug_hooks ) / sizeof ( void* ) ) )
- library->debug_hooks[hook_index] = debug_hook;
- }
-
-
- /* documentation is in ftmodapi.h */
-
- FT_EXPORT_DEF( FT_TrueTypeEngineType )
- FT_Get_TrueType_Engine_Type( FT_Library library )
- {
- FT_TrueTypeEngineType result = FT_TRUETYPE_ENGINE_TYPE_NONE;
-
-
- if ( library )
- {
- FT_Module module = FT_Get_Module( library, "truetype" );
-
-
- if ( module )
- {
- FT_Service_TrueTypeEngine service;
-
-
- service = (FT_Service_TrueTypeEngine)
- ft_module_get_service( module,
- FT_SERVICE_ID_TRUETYPE_ENGINE,
- 0 );
- if ( service )
- result = service->engine_type;
- }
- }
-
- return result;
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Get_SubGlyph_Info( FT_GlyphSlot glyph,
- FT_UInt sub_index,
- FT_Int *p_index,
- FT_UInt *p_flags,
- FT_Int *p_arg1,
- FT_Int *p_arg2,
- FT_Matrix *p_transform )
- {
- FT_Error error = FT_ERR( Invalid_Argument );
-
-
- if ( glyph &&
- glyph->subglyphs &&
- glyph->format == FT_GLYPH_FORMAT_COMPOSITE &&
- sub_index < glyph->num_subglyphs )
- {
- FT_SubGlyph subg = glyph->subglyphs + sub_index;
-
-
- *p_index = subg->index;
- *p_flags = subg->flags;
- *p_arg1 = subg->arg1;
- *p_arg2 = subg->arg2;
- *p_transform = subg->transform;
-
- error = FT_Err_Ok;
- }
-
- return error;
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Bool )
- FT_Get_Color_Glyph_Layer( FT_Face face,
- FT_UInt base_glyph,
- FT_UInt *aglyph_index,
- FT_UInt *acolor_index,
- FT_LayerIterator* iterator )
- {
- TT_Face ttface;
- SFNT_Service sfnt;
-
-
- if ( !face ||
- !aglyph_index ||
- !acolor_index ||
- !iterator ||
- base_glyph >= (FT_UInt)face->num_glyphs )
- return 0;
-
- if ( !FT_IS_SFNT( face ) )
- return 0;
-
- ttface = (TT_Face)face;
- sfnt = (SFNT_Service)ttface->sfnt;
-
- if ( sfnt->get_colr_layer )
- return sfnt->get_colr_layer( ttface,
- base_glyph,
- aglyph_index,
- acolor_index,
- iterator );
- else
- return 0;
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Bool )
- FT_Get_Color_Glyph_Paint( FT_Face face,
- FT_UInt base_glyph,
- FT_Color_Root_Transform root_transform,
- FT_OpaquePaint* paint )
- {
- TT_Face ttface;
- SFNT_Service sfnt;
-
-
- if ( !face || !paint )
- return 0;
-
- if ( !FT_IS_SFNT( face ) )
- return 0;
-
- ttface = (TT_Face)face;
- sfnt = (SFNT_Service)ttface->sfnt;
-
- if ( sfnt->get_colr_glyph_paint )
- return sfnt->get_colr_glyph_paint( ttface,
- base_glyph,
- root_transform,
- paint );
- else
- return 0;
- }
-
-
- /* documentation is in ftcolor.h */
-
- FT_EXPORT_DEF( FT_Bool )
- FT_Get_Color_Glyph_ClipBox( FT_Face face,
- FT_UInt base_glyph,
- FT_ClipBox* clip_box )
- {
- TT_Face ttface;
- SFNT_Service sfnt;
-
-
- if ( !face || !clip_box )
- return 0;
-
- if ( !FT_IS_SFNT( face ) )
- return 0;
-
- ttface = (TT_Face)face;
- sfnt = (SFNT_Service)ttface->sfnt;
-
- if ( sfnt->get_color_glyph_clipbox )
- return sfnt->get_color_glyph_clipbox( ttface,
- base_glyph,
- clip_box );
- else
- return 0;
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Bool )
- FT_Get_Paint_Layers( FT_Face face,
- FT_LayerIterator* layer_iterator,
- FT_OpaquePaint* paint )
- {
- TT_Face ttface;
- SFNT_Service sfnt;
-
-
- if ( !face || !paint || !layer_iterator )
- return 0;
-
- if ( !FT_IS_SFNT( face ) )
- return 0;
-
- ttface = (TT_Face)face;
- sfnt = (SFNT_Service)ttface->sfnt;
-
- if ( sfnt->get_paint_layers )
- return sfnt->get_paint_layers( ttface, layer_iterator, paint );
- else
- return 0;
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Bool )
- FT_Get_Paint( FT_Face face,
- FT_OpaquePaint opaque_paint,
- FT_COLR_Paint* paint )
- {
- TT_Face ttface;
- SFNT_Service sfnt;
-
-
- if ( !face || !paint )
- return 0;
-
- if ( !FT_IS_SFNT( face ) )
- return 0;
-
- ttface = (TT_Face)face;
- sfnt = (SFNT_Service)ttface->sfnt;
-
- if ( sfnt->get_paint )
- return sfnt->get_paint( ttface, opaque_paint, paint );
- else
- return 0;
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Bool )
- FT_Get_Colorline_Stops ( FT_Face face,
- FT_ColorStop * color_stop,
- FT_ColorStopIterator *iterator )
- {
- TT_Face ttface;
- SFNT_Service sfnt;
-
-
- if ( !face || !color_stop || !iterator )
- return 0;
-
- if ( !FT_IS_SFNT( face ) )
- return 0;
-
- ttface = (TT_Face)face;
- sfnt = (SFNT_Service)ttface->sfnt;
-
- if ( sfnt->get_colorline_stops )
- return sfnt->get_colorline_stops ( ttface, color_stop, iterator );
- else
- return 0;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/base/ftotval.c b/contrib/libs/freetype/src/base/ftotval.c
deleted file mode 100644
index aed9eef343..0000000000
--- a/contrib/libs/freetype/src/base/ftotval.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/****************************************************************************
- *
- * ftotval.c
- *
- * FreeType API for validating OpenType tables (body).
- *
- * Copyright (C) 2004-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-#include <freetype/internal/ftdebug.h>
-
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/services/svotval.h>
-#include <freetype/ftotval.h>
-
-
- /* documentation is in ftotval.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_OpenType_Validate( FT_Face face,
- FT_UInt validation_flags,
- FT_Bytes *BASE_table,
- FT_Bytes *GDEF_table,
- FT_Bytes *GPOS_table,
- FT_Bytes *GSUB_table,
- FT_Bytes *JSTF_table )
- {
- FT_Service_OTvalidate service;
- FT_Error error;
-
-
- if ( !face )
- {
- error = FT_THROW( Invalid_Face_Handle );
- goto Exit;
- }
-
- if ( !( BASE_table &&
- GDEF_table &&
- GPOS_table &&
- GSUB_table &&
- JSTF_table ) )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- FT_FACE_FIND_GLOBAL_SERVICE( face, service, OPENTYPE_VALIDATE );
-
- if ( service )
- error = service->validate( face,
- validation_flags,
- BASE_table,
- GDEF_table,
- GPOS_table,
- GSUB_table,
- JSTF_table );
- else
- error = FT_THROW( Unimplemented_Feature );
-
- Exit:
- return error;
- }
-
-
- FT_EXPORT_DEF( void )
- FT_OpenType_Free( FT_Face face,
- FT_Bytes table )
- {
- FT_Memory memory;
-
-
- if ( !face )
- return;
-
- memory = FT_FACE_MEMORY( face );
-
- FT_FREE( table );
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/base/ftoutln.c b/contrib/libs/freetype/src/base/ftoutln.c
deleted file mode 100644
index ef699b3c7c..0000000000
--- a/contrib/libs/freetype/src/base/ftoutln.c
+++ /dev/null
@@ -1,1120 +0,0 @@
-/****************************************************************************
- *
- * ftoutln.c
- *
- * FreeType outline management (body).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/ftoutln.h>
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/ftcalc.h>
-#include <freetype/internal/ftdebug.h>
-#include <freetype/fttrigon.h>
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT outline
-
-
- static
- const FT_Outline null_outline = { 0, 0, NULL, NULL, NULL, 0 };
-
-
- /* documentation is in ftoutln.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Outline_Decompose( FT_Outline* outline,
- const FT_Outline_Funcs* func_interface,
- void* user )
- {
-#undef SCALED
-#define SCALED( x ) ( (x) * ( 1L << shift ) - delta )
-
- FT_Vector v_last;
- FT_Vector v_control;
- FT_Vector v_start;
-
- FT_Vector* point;
- FT_Vector* limit;
- FT_Byte* tags;
-
- FT_Error error;
-
- FT_Int n; /* index of contour in outline */
- FT_Int first; /* index of first point in contour */
- FT_Int last; /* index of last point in contour */
-
- FT_Int tag; /* current point's state */
-
- FT_Int shift;
- FT_Pos delta;
-
-
- if ( !outline )
- return FT_THROW( Invalid_Outline );
-
- if ( !func_interface )
- return FT_THROW( Invalid_Argument );
-
- shift = func_interface->shift;
- delta = func_interface->delta;
-
- last = -1;
- for ( n = 0; n < outline->n_contours; n++ )
- {
- FT_TRACE5(( "FT_Outline_Decompose: Contour %d\n", n ));
-
- first = last + 1;
- last = outline->contours[n];
- if ( last < first )
- goto Invalid_Outline;
-
- limit = outline->points + last;
-
- v_start = outline->points[first];
- v_start.x = SCALED( v_start.x );
- v_start.y = SCALED( v_start.y );
-
- v_last = outline->points[last];
- v_last.x = SCALED( v_last.x );
- v_last.y = SCALED( v_last.y );
-
- v_control = v_start;
-
- point = outline->points + first;
- tags = outline->tags + first;
- tag = FT_CURVE_TAG( tags[0] );
-
- /* A contour cannot start with a cubic control point! */
- if ( tag == FT_CURVE_TAG_CUBIC )
- goto Invalid_Outline;
-
- /* check first point to determine origin */
- if ( tag == FT_CURVE_TAG_CONIC )
- {
- /* first point is conic control. Yes, this happens. */
- if ( FT_CURVE_TAG( outline->tags[last] ) == FT_CURVE_TAG_ON )
- {
- /* start at last point if it is on the curve */
- v_start = v_last;
- limit--;
- }
- else
- {
- /* if both first and last points are conic, */
- /* start at their middle and record its position */
- /* for closure */
- v_start.x = ( v_start.x + v_last.x ) / 2;
- v_start.y = ( v_start.y + v_last.y ) / 2;
-
- /* v_last = v_start; */
- }
- point--;
- tags--;
- }
-
- FT_TRACE5(( " move to (%.2f, %.2f)\n",
- (double)v_start.x / 64, (double)v_start.y / 64 ));
- error = func_interface->move_to( &v_start, user );
- if ( error )
- goto Exit;
-
- while ( point < limit )
- {
- point++;
- tags++;
-
- tag = FT_CURVE_TAG( tags[0] );
- switch ( tag )
- {
- case FT_CURVE_TAG_ON: /* emit a single line_to */
- {
- FT_Vector vec;
-
-
- vec.x = SCALED( point->x );
- vec.y = SCALED( point->y );
-
- FT_TRACE5(( " line to (%.2f, %.2f)\n",
- (double)vec.x / 64, (double)vec.y / 64 ));
- error = func_interface->line_to( &vec, user );
- if ( error )
- goto Exit;
- continue;
- }
-
- case FT_CURVE_TAG_CONIC: /* consume conic arcs */
- v_control.x = SCALED( point->x );
- v_control.y = SCALED( point->y );
-
- Do_Conic:
- if ( point < limit )
- {
- FT_Vector vec;
- FT_Vector v_middle;
-
-
- point++;
- tags++;
- tag = FT_CURVE_TAG( tags[0] );
-
- vec.x = SCALED( point->x );
- vec.y = SCALED( point->y );
-
- if ( tag == FT_CURVE_TAG_ON )
- {
- FT_TRACE5(( " conic to (%.2f, %.2f)"
- " with control (%.2f, %.2f)\n",
- (double)vec.x / 64,
- (double)vec.y / 64,
- (double)v_control.x / 64,
- (double)v_control.y / 64 ));
- error = func_interface->conic_to( &v_control, &vec, user );
- if ( error )
- goto Exit;
- continue;
- }
-
- if ( tag != FT_CURVE_TAG_CONIC )
- goto Invalid_Outline;
-
- v_middle.x = ( v_control.x + vec.x ) / 2;
- v_middle.y = ( v_control.y + vec.y ) / 2;
-
- FT_TRACE5(( " conic to (%.2f, %.2f)"
- " with control (%.2f, %.2f)\n",
- (double)v_middle.x / 64,
- (double)v_middle.y / 64,
- (double)v_control.x / 64,
- (double)v_control.y / 64 ));
- error = func_interface->conic_to( &v_control, &v_middle, user );
- if ( error )
- goto Exit;
-
- v_control = vec;
- goto Do_Conic;
- }
-
- FT_TRACE5(( " conic to (%.2f, %.2f)"
- " with control (%.2f, %.2f)\n",
- (double)v_start.x / 64,
- (double)v_start.y / 64,
- (double)v_control.x / 64,
- (double)v_control.y / 64 ));
- error = func_interface->conic_to( &v_control, &v_start, user );
- goto Close;
-
- default: /* FT_CURVE_TAG_CUBIC */
- {
- FT_Vector vec1, vec2;
-
-
- if ( point + 1 > limit ||
- FT_CURVE_TAG( tags[1] ) != FT_CURVE_TAG_CUBIC )
- goto Invalid_Outline;
-
- point += 2;
- tags += 2;
-
- vec1.x = SCALED( point[-2].x );
- vec1.y = SCALED( point[-2].y );
-
- vec2.x = SCALED( point[-1].x );
- vec2.y = SCALED( point[-1].y );
-
- if ( point <= limit )
- {
- FT_Vector vec;
-
-
- vec.x = SCALED( point->x );
- vec.y = SCALED( point->y );
-
- FT_TRACE5(( " cubic to (%.2f, %.2f)"
- " with controls (%.2f, %.2f) and (%.2f, %.2f)\n",
- (double)vec.x / 64,
- (double)vec.y / 64,
- (double)vec1.x / 64,
- (double)vec1.y / 64,
- (double)vec2.x / 64,
- (double)vec2.y / 64 ));
- error = func_interface->cubic_to( &vec1, &vec2, &vec, user );
- if ( error )
- goto Exit;
- continue;
- }
-
- FT_TRACE5(( " cubic to (%.2f, %.2f)"
- " with controls (%.2f, %.2f) and (%.2f, %.2f)\n",
- (double)v_start.x / 64,
- (double)v_start.y / 64,
- (double)vec1.x / 64,
- (double)vec1.y / 64,
- (double)vec2.x / 64,
- (double)vec2.y / 64 ));
- error = func_interface->cubic_to( &vec1, &vec2, &v_start, user );
- goto Close;
- }
- }
- }
-
- /* close the contour with a line segment */
- FT_TRACE5(( " line to (%.2f, %.2f)\n",
- (double)v_start.x / 64, (double)v_start.y / 64 ));
- error = func_interface->line_to( &v_start, user );
-
- Close:
- if ( error )
- goto Exit;
- }
-
- FT_TRACE5(( "FT_Outline_Decompose: Done\n" ));
- return FT_Err_Ok;
-
- Invalid_Outline:
- error = FT_THROW( Invalid_Outline );
- /* fall through */
-
- Exit:
- FT_TRACE5(( "FT_Outline_Decompose: Error 0x%x\n", error ));
- return error;
- }
-
-
- /* documentation is in ftoutln.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Outline_New( FT_Library library,
- FT_UInt numPoints,
- FT_Int numContours,
- FT_Outline *anoutline )
- {
- FT_Error error;
- FT_Memory memory;
-
-
- if ( !library )
- return FT_THROW( Invalid_Library_Handle );
-
- memory = library->memory;
-
- if ( !anoutline || !memory )
- return FT_THROW( Invalid_Argument );
-
- *anoutline = null_outline;
-
- if ( numContours < 0 ||
- (FT_UInt)numContours > numPoints )
- return FT_THROW( Invalid_Argument );
-
- if ( numPoints > FT_OUTLINE_POINTS_MAX )
- return FT_THROW( Array_Too_Large );
-
- if ( FT_NEW_ARRAY( anoutline->points, numPoints ) ||
- FT_NEW_ARRAY( anoutline->tags, numPoints ) ||
- FT_NEW_ARRAY( anoutline->contours, numContours ) )
- goto Fail;
-
- anoutline->n_points = (FT_UShort)numPoints;
- anoutline->n_contours = (FT_UShort)numContours;
- anoutline->flags |= FT_OUTLINE_OWNER;
-
- return FT_Err_Ok;
-
- Fail:
- anoutline->flags |= FT_OUTLINE_OWNER;
- FT_Outline_Done( library, anoutline );
-
- return error;
- }
-
-
- /* documentation is in ftoutln.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Outline_Check( FT_Outline* outline )
- {
- if ( outline )
- {
- FT_Int n_points = outline->n_points;
- FT_Int n_contours = outline->n_contours;
- FT_Int end0, end;
- FT_Int n;
-
-
- FT_TRACE5(( "FT_Outline_Check: contours = %d, points = %d\n",
- n_contours, n_points ));
- /* empty glyph? */
- if ( n_points == 0 && n_contours == 0 )
- return FT_Err_Ok;
-
- /* check point and contour counts */
- if ( n_points == 0 || n_contours == 0 )
- goto Bad;
-
- end0 = -1;
- for ( n = 0; n < n_contours; n++ )
- {
- end = outline->contours[n];
-
- /* note that we don't accept empty contours */
- if ( end <= end0 || end >= n_points )
- goto Bad;
-
- end0 = end;
- }
-
- if ( end0 != n_points - 1 )
- goto Bad;
-
- /* XXX: check the tags array */
- return FT_Err_Ok;
- }
-
- Bad:
- return FT_THROW( Invalid_Outline );
- }
-
-
- /* documentation is in ftoutln.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Outline_Copy( const FT_Outline* source,
- FT_Outline *target )
- {
- FT_Int is_owner;
-
-
- if ( !source || !target )
- return FT_THROW( Invalid_Outline );
-
- if ( source->n_points != target->n_points ||
- source->n_contours != target->n_contours )
- return FT_THROW( Invalid_Argument );
-
- if ( source == target )
- return FT_Err_Ok;
-
- if ( source->n_points )
- {
- FT_ARRAY_COPY( target->points, source->points, source->n_points );
- FT_ARRAY_COPY( target->tags, source->tags, source->n_points );
- }
-
- if ( source->n_contours )
- FT_ARRAY_COPY( target->contours, source->contours, source->n_contours );
-
- /* copy all flags, except the `FT_OUTLINE_OWNER' one */
- is_owner = target->flags & FT_OUTLINE_OWNER;
- target->flags = source->flags;
-
- target->flags &= ~FT_OUTLINE_OWNER;
- target->flags |= is_owner;
-
- return FT_Err_Ok;
- }
-
-
- /* documentation is in ftoutln.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Outline_Done( FT_Library library,
- FT_Outline* outline )
- {
- FT_Memory memory;
-
-
- if ( !library )
- return FT_THROW( Invalid_Library_Handle );
-
- if ( !outline )
- return FT_THROW( Invalid_Outline );
-
- memory = library->memory;
-
- if ( !memory )
- return FT_THROW( Invalid_Argument );
-
- if ( outline->flags & FT_OUTLINE_OWNER )
- {
- FT_FREE( outline->points );
- FT_FREE( outline->tags );
- FT_FREE( outline->contours );
- }
- *outline = null_outline;
-
- return FT_Err_Ok;
- }
-
-
- /* documentation is in ftoutln.h */
-
- FT_EXPORT_DEF( void )
- FT_Outline_Get_CBox( const FT_Outline* outline,
- FT_BBox *acbox )
- {
- FT_Pos xMin, yMin, xMax, yMax;
-
-
- if ( outline && acbox )
- {
- if ( outline->n_points == 0 )
- {
- xMin = 0;
- yMin = 0;
- xMax = 0;
- yMax = 0;
- }
- else
- {
- FT_Vector* vec = outline->points;
- FT_Vector* limit = vec + outline->n_points;
-
-
- xMin = xMax = vec->x;
- yMin = yMax = vec->y;
- vec++;
-
- for ( ; vec < limit; vec++ )
- {
- FT_Pos x, y;
-
-
- x = vec->x;
- if ( x < xMin ) xMin = x;
- if ( x > xMax ) xMax = x;
-
- y = vec->y;
- if ( y < yMin ) yMin = y;
- if ( y > yMax ) yMax = y;
- }
- }
- acbox->xMin = xMin;
- acbox->xMax = xMax;
- acbox->yMin = yMin;
- acbox->yMax = yMax;
- }
- }
-
-
- /* documentation is in ftoutln.h */
-
- FT_EXPORT_DEF( void )
- FT_Outline_Translate( const FT_Outline* outline,
- FT_Pos xOffset,
- FT_Pos yOffset )
- {
- FT_UShort n;
- FT_Vector* vec;
-
-
- if ( !outline )
- return;
-
- vec = outline->points;
-
- for ( n = 0; n < outline->n_points; n++ )
- {
- vec->x = ADD_LONG( vec->x, xOffset );
- vec->y = ADD_LONG( vec->y, yOffset );
- vec++;
- }
- }
-
-
- /* documentation is in ftoutln.h */
-
- FT_EXPORT_DEF( void )
- FT_Outline_Reverse( FT_Outline* outline )
- {
- FT_UShort n;
- FT_Int first, last;
-
-
- if ( !outline )
- return;
-
- last = -1;
- for ( n = 0; n < outline->n_contours; n++ )
- {
- /* keep the first contour point as is and swap points around it */
- /* to guarantee that the cubic arches stay valid after reverse */
- first = last + 2;
- last = outline->contours[n];
-
- /* reverse point table */
- {
- FT_Vector* p = outline->points + first;
- FT_Vector* q = outline->points + last;
- FT_Vector swap;
-
-
- while ( p < q )
- {
- swap = *p;
- *p = *q;
- *q = swap;
- p++;
- q--;
- }
- }
-
- /* reverse tags table */
- {
- FT_Byte* p = outline->tags + first;
- FT_Byte* q = outline->tags + last;
-
-
- while ( p < q )
- {
- FT_Byte swap;
-
-
- swap = *p;
- *p = *q;
- *q = swap;
- p++;
- q--;
- }
- }
- }
-
- outline->flags ^= FT_OUTLINE_REVERSE_FILL;
- }
-
-
- /* documentation is in ftoutln.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Outline_Render( FT_Library library,
- FT_Outline* outline,
- FT_Raster_Params* params )
- {
- FT_Error error;
- FT_Renderer renderer;
- FT_ListNode node;
- FT_BBox cbox;
-
-
- if ( !library )
- return FT_THROW( Invalid_Library_Handle );
-
- if ( !outline )
- return FT_THROW( Invalid_Outline );
-
- if ( !params )
- return FT_THROW( Invalid_Argument );
-
- FT_Outline_Get_CBox( outline, &cbox );
- if ( cbox.xMin < -0x1000000L || cbox.yMin < -0x1000000L ||
- cbox.xMax > 0x1000000L || cbox.yMax > 0x1000000L )
- return FT_THROW( Invalid_Outline );
-
- renderer = library->cur_renderer;
- node = library->renderers.head;
-
- params->source = (void*)outline;
-
- /* preset clip_box for direct mode */
- if ( params->flags & FT_RASTER_FLAG_DIRECT &&
- !( params->flags & FT_RASTER_FLAG_CLIP ) )
- {
- params->clip_box.xMin = cbox.xMin >> 6;
- params->clip_box.yMin = cbox.yMin >> 6;
- params->clip_box.xMax = ( cbox.xMax + 63 ) >> 6;
- params->clip_box.yMax = ( cbox.yMax + 63 ) >> 6;
- }
-
- error = FT_ERR( Cannot_Render_Glyph );
- while ( renderer )
- {
- error = renderer->raster_render( renderer->raster, params );
- if ( !error || FT_ERR_NEQ( error, Cannot_Render_Glyph ) )
- break;
-
- /* FT_Err_Cannot_Render_Glyph is returned if the render mode */
- /* is unsupported by the current renderer for this glyph image */
- /* format */
-
- /* now, look for another renderer that supports the same */
- /* format */
- renderer = FT_Lookup_Renderer( library, FT_GLYPH_FORMAT_OUTLINE,
- &node );
- }
-
- return error;
- }
-
-
- /* documentation is in ftoutln.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Outline_Get_Bitmap( FT_Library library,
- FT_Outline* outline,
- const FT_Bitmap *abitmap )
- {
- FT_Raster_Params params;
-
-
- if ( !abitmap )
- return FT_THROW( Invalid_Argument );
-
- /* other checks are delayed to `FT_Outline_Render' */
-
- params.target = abitmap;
- params.flags = 0;
-
- if ( abitmap->pixel_mode == FT_PIXEL_MODE_GRAY ||
- abitmap->pixel_mode == FT_PIXEL_MODE_LCD ||
- abitmap->pixel_mode == FT_PIXEL_MODE_LCD_V )
- params.flags |= FT_RASTER_FLAG_AA;
-
- return FT_Outline_Render( library, outline, &params );
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( void )
- FT_Vector_Transform( FT_Vector* vector,
- const FT_Matrix* matrix )
- {
- FT_Pos xz, yz;
-
-
- if ( !vector || !matrix )
- return;
-
- xz = FT_MulFix( vector->x, matrix->xx ) +
- FT_MulFix( vector->y, matrix->xy );
-
- yz = FT_MulFix( vector->x, matrix->yx ) +
- FT_MulFix( vector->y, matrix->yy );
-
- vector->x = xz;
- vector->y = yz;
- }
-
-
- /* documentation is in ftoutln.h */
-
- FT_EXPORT_DEF( void )
- FT_Outline_Transform( const FT_Outline* outline,
- const FT_Matrix* matrix )
- {
- FT_Vector* vec;
- FT_Vector* limit;
-
-
- if ( !outline || !matrix || !outline->points )
- return;
-
- vec = outline->points;
- limit = vec + outline->n_points;
-
- for ( ; vec < limit; vec++ )
- FT_Vector_Transform( vec, matrix );
- }
-
-
-#if 0
-
-#define FT_OUTLINE_GET_CONTOUR( outline, c, first, last ) \
- do \
- { \
- (first) = ( c > 0 ) ? (outline)->points + \
- (outline)->contours[c - 1] + 1 \
- : (outline)->points; \
- (last) = (outline)->points + (outline)->contours[c]; \
- } while ( 0 )
-
-
- /* Is a point in some contour? */
- /* */
- /* We treat every point of the contour as if it */
- /* it were ON. That is, we allow false positives, */
- /* but disallow false negatives. (XXX really?) */
- static FT_Bool
- ft_contour_has( FT_Outline* outline,
- FT_Short c,
- FT_Vector* point )
- {
- FT_Vector* first;
- FT_Vector* last;
- FT_Vector* a;
- FT_Vector* b;
- FT_UInt n = 0;
-
-
- FT_OUTLINE_GET_CONTOUR( outline, c, first, last );
-
- for ( a = first; a <= last; a++ )
- {
- FT_Pos x;
- FT_Int intersect;
-
-
- b = ( a == last ) ? first : a + 1;
-
- intersect = ( a->y - point->y ) ^ ( b->y - point->y );
-
- /* a and b are on the same side */
- if ( intersect >= 0 )
- {
- if ( intersect == 0 && a->y == point->y )
- {
- if ( ( a->x <= point->x && b->x >= point->x ) ||
- ( a->x >= point->x && b->x <= point->x ) )
- return 1;
- }
-
- continue;
- }
-
- x = a->x + ( b->x - a->x ) * (point->y - a->y ) / ( b->y - a->y );
-
- if ( x < point->x )
- n++;
- else if ( x == point->x )
- return 1;
- }
-
- return n & 1;
- }
-
-
- static FT_Bool
- ft_contour_enclosed( FT_Outline* outline,
- FT_UShort c )
- {
- FT_Vector* first;
- FT_Vector* last;
- FT_Short i;
-
-
- FT_OUTLINE_GET_CONTOUR( outline, c, first, last );
-
- for ( i = 0; i < outline->n_contours; i++ )
- {
- if ( i != c && ft_contour_has( outline, i, first ) )
- {
- FT_Vector* pt;
-
-
- for ( pt = first + 1; pt <= last; pt++ )
- if ( !ft_contour_has( outline, i, pt ) )
- return 0;
-
- return 1;
- }
- }
-
- return 0;
- }
-
-
- /* This version differs from the public one in that each */
- /* part (contour not enclosed in another contour) of the */
- /* outline is checked for orientation. This is */
- /* necessary for some buggy CJK fonts. */
- static FT_Orientation
- ft_outline_get_orientation( FT_Outline* outline )
- {
- FT_Short i;
- FT_Vector* first;
- FT_Vector* last;
- FT_Orientation orient = FT_ORIENTATION_NONE;
-
-
- first = outline->points;
- for ( i = 0; i < outline->n_contours; i++, first = last + 1 )
- {
- FT_Vector* point;
- FT_Vector* xmin_point;
- FT_Pos xmin;
-
-
- last = outline->points + outline->contours[i];
-
- /* skip degenerate contours */
- if ( last < first + 2 )
- continue;
-
- if ( ft_contour_enclosed( outline, i ) )
- continue;
-
- xmin = first->x;
- xmin_point = first;
-
- for ( point = first + 1; point <= last; point++ )
- {
- if ( point->x < xmin )
- {
- xmin = point->x;
- xmin_point = point;
- }
- }
-
- /* check the orientation of the contour */
- {
- FT_Vector* prev;
- FT_Vector* next;
- FT_Orientation o;
-
-
- prev = ( xmin_point == first ) ? last : xmin_point - 1;
- next = ( xmin_point == last ) ? first : xmin_point + 1;
-
- if ( FT_Atan2( prev->x - xmin_point->x, prev->y - xmin_point->y ) >
- FT_Atan2( next->x - xmin_point->x, next->y - xmin_point->y ) )
- o = FT_ORIENTATION_POSTSCRIPT;
- else
- o = FT_ORIENTATION_TRUETYPE;
-
- if ( orient == FT_ORIENTATION_NONE )
- orient = o;
- else if ( orient != o )
- return FT_ORIENTATION_NONE;
- }
- }
-
- return orient;
- }
-
-#endif /* 0 */
-
-
- /* documentation is in ftoutln.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Outline_Embolden( FT_Outline* outline,
- FT_Pos strength )
- {
- return FT_Outline_EmboldenXY( outline, strength, strength );
- }
-
-
- /* documentation is in ftoutln.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Outline_EmboldenXY( FT_Outline* outline,
- FT_Pos xstrength,
- FT_Pos ystrength )
- {
- FT_Vector* points;
- FT_Int c, first, last;
- FT_Orientation orientation;
-
-
- if ( !outline )
- return FT_THROW( Invalid_Outline );
-
- xstrength /= 2;
- ystrength /= 2;
- if ( xstrength == 0 && ystrength == 0 )
- return FT_Err_Ok;
-
- orientation = FT_Outline_Get_Orientation( outline );
- if ( orientation == FT_ORIENTATION_NONE )
- {
- if ( outline->n_contours )
- return FT_THROW( Invalid_Argument );
- else
- return FT_Err_Ok;
- }
-
- points = outline->points;
-
- last = -1;
- for ( c = 0; c < outline->n_contours; c++ )
- {
- FT_Vector in, out, anchor, shift;
- FT_Fixed l_in, l_out, l_anchor = 0, l, q, d;
- FT_Int i, j, k;
-
-
- first = last + 1;
- last = outline->contours[c];
- l_in = 0;
-
- /* pacify compiler */
- in.x = in.y = anchor.x = anchor.y = 0;
-
- /* Counter j cycles though the points; counter i advances only */
- /* when points are moved; anchor k marks the first moved point. */
- for ( i = last, j = first, k = -1;
- j != i && i != k;
- j = j < last ? j + 1 : first )
- {
- if ( j != k )
- {
- out.x = points[j].x - points[i].x;
- out.y = points[j].y - points[i].y;
- l_out = (FT_Fixed)FT_Vector_NormLen( &out );
-
- if ( l_out == 0 )
- continue;
- }
- else
- {
- out = anchor;
- l_out = l_anchor;
- }
-
- if ( l_in != 0 )
- {
- if ( k < 0 )
- {
- k = i;
- anchor = in;
- l_anchor = l_in;
- }
-
- d = FT_MulFix( in.x, out.x ) + FT_MulFix( in.y, out.y );
-
- /* shift only if turn is less than ~160 degrees */
- if ( d > -0xF000L )
- {
- d = d + 0x10000L;
-
- /* shift components along lateral bisector in proper orientation */
- shift.x = in.y + out.y;
- shift.y = in.x + out.x;
-
- if ( orientation == FT_ORIENTATION_TRUETYPE )
- shift.x = -shift.x;
- else
- shift.y = -shift.y;
-
- /* restrict shift magnitude to better handle collapsing segments */
- q = FT_MulFix( out.x, in.y ) - FT_MulFix( out.y, in.x );
- if ( orientation == FT_ORIENTATION_TRUETYPE )
- q = -q;
-
- l = FT_MIN( l_in, l_out );
-
- /* non-strict inequalities avoid divide-by-zero when q == l == 0 */
- if ( FT_MulFix( xstrength, q ) <= FT_MulFix( l, d ) )
- shift.x = FT_MulDiv( shift.x, xstrength, d );
- else
- shift.x = FT_MulDiv( shift.x, l, q );
-
-
- if ( FT_MulFix( ystrength, q ) <= FT_MulFix( l, d ) )
- shift.y = FT_MulDiv( shift.y, ystrength, d );
- else
- shift.y = FT_MulDiv( shift.y, l, q );
- }
- else
- shift.x = shift.y = 0;
-
- for ( ;
- i != j;
- i = i < last ? i + 1 : first )
- {
- points[i].x += xstrength + shift.x;
- points[i].y += ystrength + shift.y;
- }
- }
- else
- i = j;
-
- in = out;
- l_in = l_out;
- }
- }
-
- return FT_Err_Ok;
- }
-
-
- /* documentation is in ftoutln.h */
-
- FT_EXPORT_DEF( FT_Orientation )
- FT_Outline_Get_Orientation( FT_Outline* outline )
- {
- FT_BBox cbox = { 0, 0, 0, 0 };
- FT_Int xshift, yshift;
- FT_Vector* points;
- FT_Vector v_prev, v_cur;
- FT_Int c, n, first, last;
- FT_Pos area = 0;
-
-
- if ( !outline || outline->n_points <= 0 )
- return FT_ORIENTATION_TRUETYPE;
-
- /* We use the nonzero winding rule to find the orientation. */
- /* Since glyph outlines behave much more `regular' than arbitrary */
- /* cubic or quadratic curves, this test deals with the polygon */
- /* only that is spanned up by the control points. */
-
- FT_Outline_Get_CBox( outline, &cbox );
-
- /* Handle collapsed outlines to avoid undefined FT_MSB. */
- if ( cbox.xMin == cbox.xMax || cbox.yMin == cbox.yMax )
- return FT_ORIENTATION_NONE;
-
- /* Reject values large outlines. */
- if ( cbox.xMin < -0x1000000L || cbox.yMin < -0x1000000L ||
- cbox.xMax > 0x1000000L || cbox.yMax > 0x1000000L )
- return FT_ORIENTATION_NONE;
-
- xshift = FT_MSB( (FT_UInt32)( FT_ABS( cbox.xMax ) |
- FT_ABS( cbox.xMin ) ) ) - 14;
- xshift = FT_MAX( xshift, 0 );
-
- yshift = FT_MSB( (FT_UInt32)( cbox.yMax - cbox.yMin ) ) - 14;
- yshift = FT_MAX( yshift, 0 );
-
- points = outline->points;
-
- last = -1;
- for ( c = 0; c < outline->n_contours; c++ )
- {
- first = last + 1;
- last = outline->contours[c];
-
- v_prev.x = points[last].x >> xshift;
- v_prev.y = points[last].y >> yshift;
-
- for ( n = first; n <= last; n++ )
- {
- v_cur.x = points[n].x >> xshift;
- v_cur.y = points[n].y >> yshift;
-
- area = ADD_LONG( area,
- MUL_LONG( v_cur.y - v_prev.y,
- v_cur.x + v_prev.x ) );
-
- v_prev = v_cur;
- }
- }
-
- if ( area > 0 )
- return FT_ORIENTATION_POSTSCRIPT;
- else if ( area < 0 )
- return FT_ORIENTATION_TRUETYPE;
- else
- return FT_ORIENTATION_NONE;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/base/ftpatent.c b/contrib/libs/freetype/src/base/ftpatent.c
deleted file mode 100644
index 2055757e02..0000000000
--- a/contrib/libs/freetype/src/base/ftpatent.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/****************************************************************************
- *
- * ftpatent.c
- *
- * FreeType API for checking patented TrueType bytecode instructions
- * (body). Obsolete, retained for backward compatibility.
- *
- * Copyright (C) 2007-2024 by
- * David Turner.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-#include <freetype/freetype.h>
-#include <freetype/tttags.h>
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/internal/services/svsfnt.h>
-#include <freetype/internal/services/svttglyf.h>
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Bool )
- FT_Face_CheckTrueTypePatents( FT_Face face )
- {
- FT_UNUSED( face );
-
- return FALSE;
- }
-
-
- /* documentation is in freetype.h */
-
- FT_EXPORT_DEF( FT_Bool )
- FT_Face_SetUnpatentedHinting( FT_Face face,
- FT_Bool value )
- {
- FT_UNUSED( face );
- FT_UNUSED( value );
-
- return FALSE;
- }
-
-/* END */
diff --git a/contrib/libs/freetype/src/base/ftpfr.c b/contrib/libs/freetype/src/base/ftpfr.c
deleted file mode 100644
index 0caa9d1d58..0000000000
--- a/contrib/libs/freetype/src/base/ftpfr.c
+++ /dev/null
@@ -1,152 +0,0 @@
-/****************************************************************************
- *
- * ftpfr.c
- *
- * FreeType API for accessing PFR-specific data (body).
- *
- * Copyright (C) 2002-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-#include <freetype/internal/ftdebug.h>
-
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/services/svpfr.h>
-
-
- /* check the format */
- static FT_Service_PfrMetrics
- ft_pfr_check( FT_Face face )
- {
- FT_Service_PfrMetrics service = NULL;
-
-
- if ( face )
- FT_FACE_LOOKUP_SERVICE( face, service, PFR_METRICS );
-
- return service;
- }
-
-
- /* documentation is in ftpfr.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Get_PFR_Metrics( FT_Face face,
- FT_UInt *aoutline_resolution,
- FT_UInt *ametrics_resolution,
- FT_Fixed *ametrics_x_scale,
- FT_Fixed *ametrics_y_scale )
- {
- FT_Error error = FT_Err_Ok;
- FT_Service_PfrMetrics service;
-
-
- if ( !face )
- return FT_THROW( Invalid_Face_Handle );
-
- service = ft_pfr_check( face );
- if ( service )
- {
- error = service->get_metrics( face,
- aoutline_resolution,
- ametrics_resolution,
- ametrics_x_scale,
- ametrics_y_scale );
- }
- else
- {
- FT_Fixed x_scale, y_scale;
-
-
- /* this is not a PFR font */
- if ( aoutline_resolution )
- *aoutline_resolution = face->units_per_EM;
-
- if ( ametrics_resolution )
- *ametrics_resolution = face->units_per_EM;
-
- x_scale = y_scale = 0x10000L;
- if ( face->size )
- {
- x_scale = face->size->metrics.x_scale;
- y_scale = face->size->metrics.y_scale;
- }
-
- if ( ametrics_x_scale )
- *ametrics_x_scale = x_scale;
-
- if ( ametrics_y_scale )
- *ametrics_y_scale = y_scale;
-
- error = FT_THROW( Unknown_File_Format );
- }
-
- return error;
- }
-
-
- /* documentation is in ftpfr.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Get_PFR_Kerning( FT_Face face,
- FT_UInt left,
- FT_UInt right,
- FT_Vector *avector )
- {
- FT_Error error;
- FT_Service_PfrMetrics service;
-
-
- if ( !face )
- return FT_THROW( Invalid_Face_Handle );
-
- if ( !avector )
- return FT_THROW( Invalid_Argument );
-
- service = ft_pfr_check( face );
- if ( service )
- error = service->get_kerning( face, left, right, avector );
- else
- error = FT_Get_Kerning( face, left, right,
- FT_KERNING_UNSCALED, avector );
-
- return error;
- }
-
-
- /* documentation is in ftpfr.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Get_PFR_Advance( FT_Face face,
- FT_UInt gindex,
- FT_Pos *aadvance )
- {
- FT_Error error;
- FT_Service_PfrMetrics service;
-
-
- if ( !face )
- return FT_THROW( Invalid_Face_Handle );
-
- if ( !aadvance )
- return FT_THROW( Invalid_Argument );
-
- service = ft_pfr_check( face );
- if ( service )
- error = service->get_advance( face, gindex, aadvance );
- else
- /* XXX: TODO: PROVIDE ADVANCE-LOADING METHOD TO ALL FONT DRIVERS */
- error = FT_THROW( Invalid_Argument );
-
- return error;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/base/ftpsprop.c b/contrib/libs/freetype/src/base/ftpsprop.c
deleted file mode 100644
index 37a6cee6cc..0000000000
--- a/contrib/libs/freetype/src/base/ftpsprop.c
+++ /dev/null
@@ -1,284 +0,0 @@
-/****************************************************************************
- *
- * ftpsprop.c
- *
- * Get and set properties of PostScript drivers (body).
- * See `ftdriver.h' for available properties.
- *
- * Copyright (C) 2017-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/ftdriver.h>
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/psaux.h>
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/ftpsprop.h>
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT psprops
-
-
- FT_BASE_CALLBACK_DEF( FT_Error )
- ps_property_set( FT_Module module, /* PS_Driver */
- const char* property_name,
- const void* value,
- FT_Bool value_is_string )
- {
- FT_Error error = FT_Err_Ok;
- PS_Driver driver = (PS_Driver)module;
-
-#ifndef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
- FT_UNUSED( value_is_string );
-#endif
-
-
- if ( !ft_strcmp( property_name, "darkening-parameters" ) )
- {
- FT_Int* darken_params;
- FT_Int x1, y1, x2, y2, x3, y3, x4, y4;
-
-#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
- FT_Int dp[8];
-
-
- if ( value_is_string )
- {
- const char* s = (const char*)value;
- char* ep;
- int i;
-
-
- /* eight comma-separated numbers */
- for ( i = 0; i < 7; i++ )
- {
- dp[i] = (FT_Int)ft_strtol( s, &ep, 10 );
- if ( *ep != ',' || s == ep )
- return FT_THROW( Invalid_Argument );
-
- s = ep + 1;
- }
-
- dp[7] = (FT_Int)ft_strtol( s, &ep, 10 );
- if ( !( *ep == '\0' || *ep == ' ' ) || s == ep )
- return FT_THROW( Invalid_Argument );
-
- darken_params = dp;
- }
- else
-#endif
- darken_params = (FT_Int*)value;
-
- x1 = darken_params[0];
- y1 = darken_params[1];
- x2 = darken_params[2];
- y2 = darken_params[3];
- x3 = darken_params[4];
- y3 = darken_params[5];
- x4 = darken_params[6];
- y4 = darken_params[7];
-
- if ( x1 < 0 || x2 < 0 || x3 < 0 || x4 < 0 ||
- y1 < 0 || y2 < 0 || y3 < 0 || y4 < 0 ||
- x1 > x2 || x2 > x3 || x3 > x4 ||
- y1 > 500 || y2 > 500 || y3 > 500 || y4 > 500 )
- return FT_THROW( Invalid_Argument );
-
- driver->darken_params[0] = x1;
- driver->darken_params[1] = y1;
- driver->darken_params[2] = x2;
- driver->darken_params[3] = y2;
- driver->darken_params[4] = x3;
- driver->darken_params[5] = y3;
- driver->darken_params[6] = x4;
- driver->darken_params[7] = y4;
-
- return error;
- }
-
- else if ( !ft_strcmp( property_name, "hinting-engine" ) )
- {
-#if defined( CFF_CONFIG_OPTION_OLD_ENGINE ) || \
- defined( T1_CONFIG_OPTION_OLD_ENGINE )
- const char* module_name = module->clazz->module_name;
-#endif
-
-
-#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
- if ( value_is_string )
- {
- const char* s = (const char*)value;
-
-
- if ( !ft_strcmp( s, "adobe" ) )
- driver->hinting_engine = FT_HINTING_ADOBE;
-
-#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
- else if ( !ft_strcmp( module_name, "cff" ) &&
- !ft_strcmp( s, "freetype" ) )
- driver->hinting_engine = FT_HINTING_FREETYPE;
-#endif
-
-#ifdef T1_CONFIG_OPTION_OLD_ENGINE
- else if ( ( !ft_strcmp( module_name, "type1" ) ||
- !ft_strcmp( module_name, "t1cid" ) ) &&
- !ft_strcmp( s, "freetype" ) )
- driver->hinting_engine = FT_HINTING_FREETYPE;
-#endif
-
- else
- return FT_THROW( Invalid_Argument );
- }
- else
-#endif /* FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES */
- {
- FT_UInt* hinting_engine = (FT_UInt*)value;
-
-
- if ( *hinting_engine == FT_HINTING_ADOBE
-#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
- || ( *hinting_engine == FT_HINTING_FREETYPE &&
- !ft_strcmp( module_name, "cff" ) )
-#endif
-#ifdef T1_CONFIG_OPTION_OLD_ENGINE
- || ( *hinting_engine == FT_HINTING_FREETYPE &&
- ( !ft_strcmp( module_name, "type1" ) ||
- !ft_strcmp( module_name, "t1cid" ) ) )
-#endif
- )
- driver->hinting_engine = *hinting_engine;
- else
- error = FT_ERR( Unimplemented_Feature );
- }
-
- return error;
- }
-
- else if ( !ft_strcmp( property_name, "no-stem-darkening" ) )
- {
-#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
- if ( value_is_string )
- {
- const char* s = (const char*)value;
- long nsd = ft_strtol( s, NULL, 10 );
-
-
- if ( !nsd )
- driver->no_stem_darkening = FALSE;
- else
- driver->no_stem_darkening = TRUE;
- }
- else
-#endif
- {
- FT_Bool* no_stem_darkening = (FT_Bool*)value;
-
-
- driver->no_stem_darkening = *no_stem_darkening;
- }
-
- return error;
- }
-
- else if ( !ft_strcmp( property_name, "random-seed" ) )
- {
- FT_Int32 random_seed;
-
-
-#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
- if ( value_is_string )
- {
- const char* s = (const char*)value;
-
-
- random_seed = (FT_Int32)ft_strtol( s, NULL, 10 );
- }
- else
-#endif
- random_seed = *(FT_Int32*)value;
-
- if ( random_seed < 0 )
- random_seed = 0;
-
- driver->random_seed = random_seed;
-
- return error;
- }
-
- FT_TRACE2(( "ps_property_set: missing property `%s'\n",
- property_name ));
- return FT_THROW( Missing_Property );
- }
-
-
- FT_BASE_CALLBACK_DEF( FT_Error )
- ps_property_get( FT_Module module, /* PS_Driver */
- const char* property_name,
- void* value )
- {
- FT_Error error = FT_Err_Ok;
- PS_Driver driver = (PS_Driver)module;
-
-
- if ( !ft_strcmp( property_name, "darkening-parameters" ) )
- {
- FT_Int* darken_params = driver->darken_params;
- FT_Int* val = (FT_Int*)value;
-
-
- val[0] = darken_params[0];
- val[1] = darken_params[1];
- val[2] = darken_params[2];
- val[3] = darken_params[3];
- val[4] = darken_params[4];
- val[5] = darken_params[5];
- val[6] = darken_params[6];
- val[7] = darken_params[7];
-
- return error;
- }
-
- else if ( !ft_strcmp( property_name, "hinting-engine" ) )
- {
- FT_UInt hinting_engine = driver->hinting_engine;
- FT_UInt* val = (FT_UInt*)value;
-
-
- *val = hinting_engine;
-
- return error;
- }
-
- else if ( !ft_strcmp( property_name, "no-stem-darkening" ) )
- {
- FT_Bool no_stem_darkening = driver->no_stem_darkening;
- FT_Bool* val = (FT_Bool*)value;
-
-
- *val = no_stem_darkening;
-
- return error;
- }
-
- FT_TRACE2(( "ps_property_get: missing property `%s'\n",
- property_name ));
- return FT_THROW( Missing_Property );
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/base/ftrfork.c b/contrib/libs/freetype/src/base/ftrfork.c
deleted file mode 100644
index dc9b043d8b..0000000000
--- a/contrib/libs/freetype/src/base/ftrfork.c
+++ /dev/null
@@ -1,934 +0,0 @@
-/****************************************************************************
- *
- * ftrfork.c
- *
- * Embedded resource forks accessor (body).
- *
- * Copyright (C) 2004-2024 by
- * Masatake YAMATO and Redhat K.K.
- *
- * FT_Raccess_Get_HeaderInfo() and raccess_guess_darwin_hfsplus() are
- * derived from ftobjs.c.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-/****************************************************************************
- * Development of the code in this file is support of
- * Information-technology Promotion Agency, Japan.
- */
-
-
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/internal/ftrfork.h>
-
-#include "ftbase.h"
-
-#undef FT_COMPONENT
-#define FT_COMPONENT raccess
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /**** ****/
- /**** ****/
- /**** Resource fork directory access ****/
- /**** ****/
- /**** ****/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
- FT_BASE_DEF( FT_Error )
- FT_Raccess_Get_HeaderInfo( FT_Library library,
- FT_Stream stream,
- FT_Long rfork_offset,
- FT_Long *map_offset,
- FT_Long *rdata_pos )
- {
- FT_Error error;
- unsigned char head[16], head2[16];
- FT_Long map_pos, map_len, rdata_len;
- int allzeros, allmatch, i;
- FT_Long type_list;
-
- FT_UNUSED( library );
-
-
- error = FT_Stream_Seek( stream, (FT_ULong)rfork_offset );
- if ( error )
- return error;
-
- error = FT_Stream_Read( stream, (FT_Byte*)head, 16 );
- if ( error )
- return error;
-
- /* ensure positive values */
- if ( head[0] >= 0x80 ||
- head[4] >= 0x80 ||
- head[8] >= 0x80 ||
- head[12] >= 0x80 )
- return FT_THROW( Unknown_File_Format );
-
- *rdata_pos = ( head[ 0] << 24 ) |
- ( head[ 1] << 16 ) |
- ( head[ 2] << 8 ) |
- head[ 3];
- map_pos = ( head[ 4] << 24 ) |
- ( head[ 5] << 16 ) |
- ( head[ 6] << 8 ) |
- head[ 7];
- rdata_len = ( head[ 8] << 24 ) |
- ( head[ 9] << 16 ) |
- ( head[10] << 8 ) |
- head[11];
- map_len = ( head[12] << 24 ) |
- ( head[13] << 16 ) |
- ( head[14] << 8 ) |
- head[15];
-
- /* the map must not be empty */
- if ( !map_pos )
- return FT_THROW( Unknown_File_Format );
-
- /* check whether rdata and map overlap */
- if ( *rdata_pos < map_pos )
- {
- if ( *rdata_pos > map_pos - rdata_len )
- return FT_THROW( Unknown_File_Format );
- }
- else
- {
- if ( map_pos > *rdata_pos - map_len )
- return FT_THROW( Unknown_File_Format );
- }
-
- /* check whether end of rdata or map exceeds stream size */
- if ( FT_LONG_MAX - rdata_len < *rdata_pos ||
- FT_LONG_MAX - map_len < map_pos ||
-
- FT_LONG_MAX - ( *rdata_pos + rdata_len ) < rfork_offset ||
- FT_LONG_MAX - ( map_pos + map_len ) < rfork_offset ||
-
- (FT_ULong)( rfork_offset + *rdata_pos + rdata_len ) > stream->size ||
- (FT_ULong)( rfork_offset + map_pos + map_len ) > stream->size )
- return FT_THROW( Unknown_File_Format );
-
- *rdata_pos += rfork_offset;
- map_pos += rfork_offset;
-
- error = FT_Stream_Seek( stream, (FT_ULong)map_pos );
- if ( error )
- return error;
-
- head2[15] = (FT_Byte)( head[15] + 1 ); /* make it be different */
-
- error = FT_Stream_Read( stream, (FT_Byte*)head2, 16 );
- if ( error )
- return error;
-
- allzeros = 1;
- allmatch = 1;
- for ( i = 0; i < 16; i++ )
- {
- if ( head2[i] != 0 )
- allzeros = 0;
- if ( head2[i] != head[i] )
- allmatch = 0;
- }
- if ( !allzeros && !allmatch )
- return FT_THROW( Unknown_File_Format );
-
- /* If we have reached this point then it is probably a mac resource */
- /* file. Now, does it contain any interesting resources? */
-
- (void)FT_STREAM_SKIP( 4 /* skip handle to next resource map */
- + 2 /* skip file resource number */
- + 2 ); /* skip attributes */
-
- if ( FT_READ_SHORT( type_list ) )
- return error;
- if ( type_list < 0 )
- return FT_THROW( Unknown_File_Format );
-
- error = FT_Stream_Seek( stream, (FT_ULong)( map_pos + type_list ) );
- if ( error )
- return error;
-
- *map_offset = map_pos + type_list;
- return FT_Err_Ok;
- }
-
-
- FT_COMPARE_DEF( int )
- ft_raccess_sort_ref_by_id( const void* a,
- const void* b )
- {
- return ( (FT_RFork_Ref*)a )->res_id - ( (FT_RFork_Ref*)b )->res_id;
- }
-
-
- FT_BASE_DEF( FT_Error )
- FT_Raccess_Get_DataOffsets( FT_Library library,
- FT_Stream stream,
- FT_Long map_offset,
- FT_Long rdata_pos,
- FT_Long tag,
- FT_Bool sort_by_res_id,
- FT_Long **offsets,
- FT_Long *count )
- {
- FT_Error error;
- int i, j, cnt, subcnt;
- FT_Long tag_internal, rpos;
- FT_Memory memory = library->memory;
- FT_Long temp;
- FT_Long *offsets_internal = NULL;
- FT_RFork_Ref *ref = NULL;
-
-
- FT_TRACE3(( "\n" ));
- error = FT_Stream_Seek( stream, (FT_ULong)map_offset );
- if ( error )
- return error;
-
- if ( FT_READ_SHORT( cnt ) )
- return error;
- cnt++;
-
- /* `rpos' is a signed 16bit integer offset to resource records; the */
- /* size of a resource record is 12 bytes. The map header is 28 bytes, */
- /* and a type list needs 10 bytes or more. If we assume that the name */
- /* list is empty and we have only a single entry in the type list, */
- /* there can be at most */
- /* */
- /* (32768 - 28 - 10) / 12 = 2727 */
- /* */
- /* resources. */
- /* */
- /* A type list starts with a two-byte counter, followed by 10-byte */
- /* type records. Assuming that there are no resources, the number of */
- /* type records can be at most */
- /* */
- /* (32768 - 28 - 2) / 8 = 4079 */
- /* */
- if ( cnt > 4079 )
- return FT_THROW( Invalid_Table );
-
- for ( i = 0; i < cnt; i++ )
- {
- if ( FT_READ_LONG( tag_internal ) ||
- FT_READ_SHORT( subcnt ) ||
- FT_READ_SHORT( rpos ) )
- return error;
-
- FT_TRACE2(( "Resource tags: %c%c%c%c\n",
- (char)( 0xFF & ( tag_internal >> 24 ) ),
- (char)( 0xFF & ( tag_internal >> 16 ) ),
- (char)( 0xFF & ( tag_internal >> 8 ) ),
- (char)( 0xFF & ( tag_internal >> 0 ) ) ));
- FT_TRACE3(( " : subcount=%d, suboffset=0x%04lx\n",
- subcnt, rpos ));
-
- if ( tag_internal == tag )
- {
- *count = subcnt + 1;
- rpos += map_offset;
-
- /* a zero count might be valid in the resource specification, */
- /* however, it is completely useless to us */
- if ( *count < 1 || *count > 2727 )
- return FT_THROW( Invalid_Table );
-
- error = FT_Stream_Seek( stream, (FT_ULong)rpos );
- if ( error )
- return error;
-
- if ( FT_QNEW_ARRAY( ref, *count ) )
- return error;
-
- for ( j = 0; j < *count; j++ )
- {
- if ( FT_READ_SHORT( ref[j].res_id ) )
- goto Exit;
- if ( FT_STREAM_SKIP( 2 ) ) /* resource name offset */
- goto Exit;
- if ( FT_READ_LONG( temp ) ) /* attributes (8bit), offset (24bit) */
- goto Exit;
- if ( FT_STREAM_SKIP( 4 ) ) /* mbz */
- goto Exit;
-
- /*
- * According to Inside Macintosh: More Macintosh Toolbox,
- * "Resource IDs" (1-46), there are some reserved IDs.
- * However, FreeType2 is not a font synthesizer, no need
- * to check the acceptable resource ID.
- */
- if ( temp < 0 )
- {
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- ref[j].offset = temp & 0xFFFFFFL;
-
- FT_TRACE3(( " [%d]:"
- " resource_id=0x%04x, offset=0x%08lx\n",
- j, (FT_UShort)ref[j].res_id, ref[j].offset ));
- }
-
- if ( sort_by_res_id )
- {
- ft_qsort( ref,
- (size_t)*count,
- sizeof ( FT_RFork_Ref ),
- ft_raccess_sort_ref_by_id );
-
- FT_TRACE3(( " -- sort resources by their ids --\n" ));
-
- for ( j = 0; j < *count; j++ )
- FT_TRACE3(( " [%d]:"
- " resource_id=0x%04x, offset=0x%08lx\n",
- j, ref[j].res_id, ref[j].offset ));
- }
-
- if ( FT_QNEW_ARRAY( offsets_internal, *count ) )
- goto Exit;
-
- /* XXX: duplicated reference ID,
- * gap between reference IDs are acceptable?
- * further investigation on Apple implementation is needed.
- */
- for ( j = 0; j < *count; j++ )
- offsets_internal[j] = rdata_pos + ref[j].offset;
-
- *offsets = offsets_internal;
- error = FT_Err_Ok;
-
- Exit:
- FT_FREE( ref );
- return error;
- }
- }
-
- return FT_THROW( Cannot_Open_Resource );
- }
-
-
-#ifdef FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /**** ****/
- /**** ****/
- /**** Guessing functions ****/
- /**** ****/
- /**** When you add a new guessing function, ****/
- /**** update FT_RACCESS_N_RULES in ftrfork.h. ****/
- /**** ****/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
- static FT_Error
- raccess_guess_apple_double( FT_Library library,
- FT_Stream stream,
- char *base_file_name,
- char **result_file_name,
- FT_Long *result_offset );
-
- static FT_Error
- raccess_guess_apple_single( FT_Library library,
- FT_Stream stream,
- char *base_file_name,
- char **result_file_name,
- FT_Long *result_offset );
-
- static FT_Error
- raccess_guess_darwin_ufs_export( FT_Library library,
- FT_Stream stream,
- char *base_file_name,
- char **result_file_name,
- FT_Long *result_offset );
-
- static FT_Error
- raccess_guess_darwin_newvfs( FT_Library library,
- FT_Stream stream,
- char *base_file_name,
- char **result_file_name,
- FT_Long *result_offset );
-
- static FT_Error
- raccess_guess_darwin_hfsplus( FT_Library library,
- FT_Stream stream,
- char *base_file_name,
- char **result_file_name,
- FT_Long *result_offset );
-
- static FT_Error
- raccess_guess_vfat( FT_Library library,
- FT_Stream stream,
- char *base_file_name,
- char **result_file_name,
- FT_Long *result_offset );
-
- static FT_Error
- raccess_guess_linux_cap( FT_Library library,
- FT_Stream stream,
- char *base_file_name,
- char **result_file_name,
- FT_Long *result_offset );
-
- static FT_Error
- raccess_guess_linux_double( FT_Library library,
- FT_Stream stream,
- char *base_file_name,
- char **result_file_name,
- FT_Long *result_offset );
-
- static FT_Error
- raccess_guess_linux_netatalk( FT_Library library,
- FT_Stream stream,
- char *base_file_name,
- char **result_file_name,
- FT_Long *result_offset );
-
-
- CONST_FT_RFORK_RULE_ARRAY_BEGIN( ft_raccess_guess_table,
- ft_raccess_guess_rec )
- CONST_FT_RFORK_RULE_ARRAY_ENTRY( apple_double, apple_double )
- CONST_FT_RFORK_RULE_ARRAY_ENTRY( apple_single, apple_single )
- CONST_FT_RFORK_RULE_ARRAY_ENTRY( darwin_ufs_export, darwin_ufs_export )
- CONST_FT_RFORK_RULE_ARRAY_ENTRY( darwin_newvfs, darwin_newvfs )
- CONST_FT_RFORK_RULE_ARRAY_ENTRY( darwin_hfsplus, darwin_hfsplus )
- CONST_FT_RFORK_RULE_ARRAY_ENTRY( vfat, vfat )
- CONST_FT_RFORK_RULE_ARRAY_ENTRY( linux_cap, linux_cap )
- CONST_FT_RFORK_RULE_ARRAY_ENTRY( linux_double, linux_double )
- CONST_FT_RFORK_RULE_ARRAY_ENTRY( linux_netatalk, linux_netatalk )
- CONST_FT_RFORK_RULE_ARRAY_END
-
-
- /*************************************************************************/
- /**** ****/
- /**** Helper functions ****/
- /**** ****/
- /*************************************************************************/
-
- static FT_Error
- raccess_guess_apple_generic( FT_Library library,
- FT_Stream stream,
- char *base_file_name,
- FT_Int32 magic,
- FT_Long *result_offset );
-
- static FT_Error
- raccess_guess_linux_double_from_file_name( FT_Library library,
- char* file_name,
- FT_Long *result_offset );
-
- static char *
- raccess_make_file_name( FT_Memory memory,
- const char *original_name,
- const char *insertion );
-
- FT_BASE_DEF( void )
- FT_Raccess_Guess( FT_Library library,
- FT_Stream stream,
- char* base_name,
- char **new_names,
- FT_Long *offsets,
- FT_Error *errors )
- {
- FT_Int i;
-
-
- for ( i = 0; i < FT_RACCESS_N_RULES; i++ )
- {
- new_names[i] = NULL;
- if ( NULL != stream )
- errors[i] = FT_Stream_Seek( stream, 0 );
- else
- errors[i] = FT_Err_Ok;
-
- if ( errors[i] )
- continue;
-
- errors[i] = ft_raccess_guess_table[i].func( library,
- stream, base_name,
- &(new_names[i]),
- &(offsets[i]) );
- }
-
- return;
- }
-
-
-#if defined( FT_CONFIG_OPTION_MAC_FONTS ) && !defined( FT_MACINTOSH )
- static FT_RFork_Rule
- raccess_get_rule_type_from_rule_index( FT_Library library,
- FT_UInt rule_index )
- {
- FT_UNUSED( library );
-
- if ( rule_index >= FT_RACCESS_N_RULES )
- return FT_RFork_Rule_invalid;
-
- return ft_raccess_guess_table[rule_index].type;
- }
-
-
- /*
- * For this function, refer ftbase.h.
- */
- FT_LOCAL_DEF( FT_Bool )
- ft_raccess_rule_by_darwin_vfs( FT_Library library,
- FT_UInt rule_index )
- {
- switch( raccess_get_rule_type_from_rule_index( library, rule_index ) )
- {
- case FT_RFork_Rule_darwin_newvfs:
- case FT_RFork_Rule_darwin_hfsplus:
- return TRUE;
-
- default:
- return FALSE;
- }
- }
-#endif
-
-
- static FT_Error
- raccess_guess_apple_double( FT_Library library,
- FT_Stream stream,
- char *base_file_name,
- char **result_file_name,
- FT_Long *result_offset )
- {
- FT_Int32 magic = ( 0x00 << 24 ) |
- ( 0x05 << 16 ) |
- ( 0x16 << 8 ) |
- 0x07;
-
-
- *result_file_name = NULL;
- if ( NULL == stream )
- return FT_THROW( Cannot_Open_Stream );
-
- return raccess_guess_apple_generic( library, stream, base_file_name,
- magic, result_offset );
- }
-
-
- static FT_Error
- raccess_guess_apple_single( FT_Library library,
- FT_Stream stream,
- char *base_file_name,
- char **result_file_name,
- FT_Long *result_offset )
- {
- FT_Int32 magic = ( 0x00 << 24 ) |
- ( 0x05 << 16 ) |
- ( 0x16 << 8 ) |
- 0x00;
-
-
- *result_file_name = NULL;
- if ( NULL == stream )
- return FT_THROW( Cannot_Open_Stream );
-
- return raccess_guess_apple_generic( library, stream, base_file_name,
- magic, result_offset );
- }
-
-
- static FT_Error
- raccess_guess_darwin_ufs_export( FT_Library library,
- FT_Stream stream,
- char *base_file_name,
- char **result_file_name,
- FT_Long *result_offset )
- {
- char* newpath;
- FT_Error error;
- FT_Memory memory;
-
- FT_UNUSED( stream );
-
-
- memory = library->memory;
- newpath = raccess_make_file_name( memory, base_file_name, "._" );
- if ( !newpath )
- return FT_THROW( Out_Of_Memory );
-
- error = raccess_guess_linux_double_from_file_name( library, newpath,
- result_offset );
- if ( !error )
- *result_file_name = newpath;
- else
- FT_FREE( newpath );
-
- return error;
- }
-
-
- static FT_Error
- raccess_guess_darwin_hfsplus( FT_Library library,
- FT_Stream stream,
- char *base_file_name,
- char **result_file_name,
- FT_Long *result_offset )
- {
- /*
- Only meaningful on systems with hfs+ drivers (or Macs).
- */
- FT_Error error;
- char* newpath = NULL;
- FT_Memory memory;
- FT_Long base_file_len = (FT_Long)ft_strlen( base_file_name );
-
- FT_UNUSED( stream );
-
-
- memory = library->memory;
-
- if ( base_file_len + 6 > FT_INT_MAX )
- return FT_THROW( Array_Too_Large );
-
- if ( FT_QALLOC( newpath, base_file_len + 6 ) )
- return error;
-
- FT_MEM_COPY( newpath, base_file_name, base_file_len );
- FT_MEM_COPY( newpath + base_file_len, "/rsrc", 6 );
-
- *result_file_name = newpath;
- *result_offset = 0;
-
- return FT_Err_Ok;
- }
-
-
- static FT_Error
- raccess_guess_darwin_newvfs( FT_Library library,
- FT_Stream stream,
- char *base_file_name,
- char **result_file_name,
- FT_Long *result_offset )
- {
- /*
- Only meaningful on systems with Mac OS X (> 10.1).
- */
- FT_Error error;
- char* newpath = NULL;
- FT_Memory memory;
- FT_Long base_file_len = (FT_Long)ft_strlen( base_file_name );
-
- FT_UNUSED( stream );
-
-
- memory = library->memory;
-
- if ( base_file_len + 18 > FT_INT_MAX )
- return FT_THROW( Array_Too_Large );
-
- if ( FT_QALLOC( newpath, base_file_len + 18 ) )
- return error;
-
- FT_MEM_COPY( newpath, base_file_name, base_file_len );
- FT_MEM_COPY( newpath + base_file_len, "/..namedfork/rsrc", 18 );
-
- *result_file_name = newpath;
- *result_offset = 0;
-
- return FT_Err_Ok;
- }
-
-
- static FT_Error
- raccess_guess_vfat( FT_Library library,
- FT_Stream stream,
- char *base_file_name,
- char **result_file_name,
- FT_Long *result_offset )
- {
- char* newpath;
- FT_Memory memory;
-
- FT_UNUSED( stream );
-
-
- memory = library->memory;
-
- newpath = raccess_make_file_name( memory, base_file_name,
- "resource.frk/" );
- if ( !newpath )
- return FT_THROW( Out_Of_Memory );
-
- *result_file_name = newpath;
- *result_offset = 0;
-
- return FT_Err_Ok;
- }
-
-
- static FT_Error
- raccess_guess_linux_cap( FT_Library library,
- FT_Stream stream,
- char *base_file_name,
- char **result_file_name,
- FT_Long *result_offset )
- {
- char* newpath;
- FT_Memory memory;
-
- FT_UNUSED( stream );
-
-
- memory = library->memory;
-
- newpath = raccess_make_file_name( memory, base_file_name, ".resource/" );
- if ( !newpath )
- return FT_THROW( Out_Of_Memory );
-
- *result_file_name = newpath;
- *result_offset = 0;
-
- return FT_Err_Ok;
- }
-
-
- static FT_Error
- raccess_guess_linux_double( FT_Library library,
- FT_Stream stream,
- char *base_file_name,
- char **result_file_name,
- FT_Long *result_offset )
- {
- char* newpath;
- FT_Error error;
- FT_Memory memory;
-
- FT_UNUSED( stream );
-
-
- memory = library->memory;
-
- newpath = raccess_make_file_name( memory, base_file_name, "%" );
- if ( !newpath )
- return FT_THROW( Out_Of_Memory );
-
- error = raccess_guess_linux_double_from_file_name( library, newpath,
- result_offset );
- if ( !error )
- *result_file_name = newpath;
- else
- FT_FREE( newpath );
-
- return error;
- }
-
-
- static FT_Error
- raccess_guess_linux_netatalk( FT_Library library,
- FT_Stream stream,
- char *base_file_name,
- char **result_file_name,
- FT_Long *result_offset )
- {
- char* newpath;
- FT_Error error;
- FT_Memory memory;
-
- FT_UNUSED( stream );
-
-
- memory = library->memory;
-
- newpath = raccess_make_file_name( memory, base_file_name,
- ".AppleDouble/" );
- if ( !newpath )
- return FT_THROW( Out_Of_Memory );
-
- error = raccess_guess_linux_double_from_file_name( library, newpath,
- result_offset );
- if ( !error )
- *result_file_name = newpath;
- else
- FT_FREE( newpath );
-
- return error;
- }
-
-
- static FT_Error
- raccess_guess_apple_generic( FT_Library library,
- FT_Stream stream,
- char *base_file_name,
- FT_Int32 magic,
- FT_Long *result_offset )
- {
- FT_Int32 magic_from_stream;
- FT_Error error;
- FT_Int32 version_number = 0;
- FT_UShort n_of_entries;
-
- int i;
- FT_Int32 entry_id, entry_offset, entry_length = 0;
-
- const FT_Int32 resource_fork_entry_id = 0x2;
-
- FT_UNUSED( library );
- FT_UNUSED( base_file_name );
- FT_UNUSED( version_number );
- FT_UNUSED( entry_length );
-
-
- if ( FT_READ_LONG( magic_from_stream ) )
- return error;
- if ( magic_from_stream != magic )
- return FT_THROW( Unknown_File_Format );
-
- if ( FT_READ_LONG( version_number ) )
- return error;
-
- /* filler */
- error = FT_Stream_Skip( stream, 16 );
- if ( error )
- return error;
-
- if ( FT_READ_USHORT( n_of_entries ) )
- return error;
- if ( n_of_entries == 0 )
- return FT_THROW( Unknown_File_Format );
-
- for ( i = 0; i < n_of_entries; i++ )
- {
- if ( FT_READ_LONG( entry_id ) )
- return error;
- if ( entry_id == resource_fork_entry_id )
- {
- if ( FT_READ_LONG( entry_offset ) ||
- FT_READ_LONG( entry_length ) )
- continue;
- *result_offset = entry_offset;
-
- return FT_Err_Ok;
- }
- else
- {
- error = FT_Stream_Skip( stream, 4 + 4 ); /* offset + length */
- if ( error )
- return error;
- }
- }
-
- return FT_THROW( Unknown_File_Format );
- }
-
-
- static FT_Error
- raccess_guess_linux_double_from_file_name( FT_Library library,
- char *file_name,
- FT_Long *result_offset )
- {
- FT_Open_Args args2;
- FT_Stream stream2;
- char* nouse = NULL;
- FT_Error error;
-
-
- args2.flags = FT_OPEN_PATHNAME;
- args2.pathname = file_name;
- error = FT_Stream_New( library, &args2, &stream2 );
- if ( error )
- return error;
-
- error = raccess_guess_apple_double( library, stream2, file_name,
- &nouse, result_offset );
-
- FT_Stream_Free( stream2, 0 );
-
- return error;
- }
-
-
- static char*
- raccess_make_file_name( FT_Memory memory,
- const char *original_name,
- const char *insertion )
- {
- char* new_name = NULL;
- const char* tmp;
- const char* slash;
- size_t new_length;
- FT_Error error;
-
-
- new_length = ft_strlen( original_name ) + ft_strlen( insertion );
- if ( FT_QALLOC( new_name, new_length + 1 ) )
- return NULL;
-
- tmp = ft_strrchr( original_name, '/' );
- if ( tmp )
- {
- ft_strncpy( new_name,
- original_name,
- (size_t)( tmp - original_name + 1 ) );
- new_name[tmp - original_name + 1] = '\0';
- slash = tmp + 1;
- }
- else
- {
- slash = original_name;
- new_name[0] = '\0';
- }
-
- ft_strcat( new_name, insertion );
- ft_strcat( new_name, slash );
-
- return new_name;
- }
-
-
-#else /* !FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK */
-
-
- /**************************************************************************
- * Dummy function; just sets errors
- */
-
- FT_BASE_DEF( void )
- FT_Raccess_Guess( FT_Library library,
- FT_Stream stream,
- char *base_name,
- char **new_names,
- FT_Long *offsets,
- FT_Error *errors )
- {
- FT_Int i;
-
- FT_UNUSED( library );
- FT_UNUSED( stream );
- FT_UNUSED( base_name );
-
-
- for ( i = 0; i < FT_RACCESS_N_RULES; i++ )
- {
- new_names[i] = NULL;
- offsets[i] = 0;
- errors[i] = FT_ERR( Unimplemented_Feature );
- }
- }
-
-
-#endif /* !FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/base/ftsnames.c b/contrib/libs/freetype/src/base/ftsnames.c
deleted file mode 100644
index f7231fd61c..0000000000
--- a/contrib/libs/freetype/src/base/ftsnames.c
+++ /dev/null
@@ -1,185 +0,0 @@
-/****************************************************************************
- *
- * ftsnames.c
- *
- * Simple interface to access SFNT name tables (which are used
- * to hold font names, copyright info, notices, etc.) (body).
- *
- * This is _not_ used to retrieve glyph names!
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftdebug.h>
-
-#include <freetype/ftsnames.h>
-#include <freetype/internal/tttypes.h>
-#include <freetype/internal/ftstream.h>
-
-
-#ifdef TT_CONFIG_OPTION_SFNT_NAMES
-
-
- /* documentation is in ftsnames.h */
-
- FT_EXPORT_DEF( FT_UInt )
- FT_Get_Sfnt_Name_Count( FT_Face face )
- {
- return ( face && FT_IS_SFNT( face ) ) ? ((TT_Face)face)->num_names : 0;
- }
-
-
- /* documentation is in ftsnames.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Get_Sfnt_Name( FT_Face face,
- FT_UInt idx,
- FT_SfntName *aname )
- {
- FT_Error error = FT_ERR( Invalid_Argument );
-
-
- if ( aname && face && FT_IS_SFNT( face ) )
- {
- TT_Face ttface = (TT_Face)face;
-
-
- if ( idx < (FT_UInt)ttface->num_names )
- {
- TT_Name entry = ttface->name_table.names + idx;
-
-
- /* load name on demand */
- if ( entry->stringLength > 0 && !entry->string )
- {
- FT_Memory memory = face->memory;
- FT_Stream stream = face->stream;
-
-
- if ( FT_QNEW_ARRAY ( entry->string, entry->stringLength ) ||
- FT_STREAM_SEEK( entry->stringOffset ) ||
- FT_STREAM_READ( entry->string, entry->stringLength ) )
- {
- FT_FREE( entry->string );
- entry->stringLength = 0;
- }
- }
-
- aname->platform_id = entry->platformID;
- aname->encoding_id = entry->encodingID;
- aname->language_id = entry->languageID;
- aname->name_id = entry->nameID;
- aname->string = (FT_Byte*)entry->string;
- aname->string_len = entry->stringLength;
-
- error = FT_Err_Ok;
- }
- }
-
- return error;
- }
-
-
- /* documentation is in ftsnames.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Get_Sfnt_LangTag( FT_Face face,
- FT_UInt langID,
- FT_SfntLangTag *alangTag )
- {
- FT_Error error = FT_ERR( Invalid_Argument );
-
-
- if ( alangTag && face && FT_IS_SFNT( face ) )
- {
- TT_Face ttface = (TT_Face)face;
-
-
- if ( ttface->name_table.format != 1 )
- return FT_THROW( Invalid_Table );
-
- if ( langID > 0x8000U &&
- langID - 0x8000U < ttface->name_table.numLangTagRecords )
- {
- TT_LangTag entry = ttface->name_table.langTags +
- ( langID - 0x8000U );
-
-
- /* load name on demand */
- if ( entry->stringLength > 0 && !entry->string )
- {
- FT_Memory memory = face->memory;
- FT_Stream stream = face->stream;
-
-
- if ( FT_QNEW_ARRAY ( entry->string, entry->stringLength ) ||
- FT_STREAM_SEEK( entry->stringOffset ) ||
- FT_STREAM_READ( entry->string, entry->stringLength ) )
- {
- FT_FREE( entry->string );
- entry->stringLength = 0;
- }
- }
-
- alangTag->string = (FT_Byte*)entry->string;
- alangTag->string_len = entry->stringLength;
-
- error = FT_Err_Ok;
- }
- }
-
- return error;
- }
-
-
-#else /* !TT_CONFIG_OPTION_SFNT_NAMES */
-
-
- FT_EXPORT_DEF( FT_UInt )
- FT_Get_Sfnt_Name_Count( FT_Face face )
- {
- FT_UNUSED( face );
-
- return 0;
- }
-
-
- FT_EXPORT_DEF( FT_Error )
- FT_Get_Sfnt_Name( FT_Face face,
- FT_UInt idx,
- FT_SfntName *aname )
- {
- FT_UNUSED( face );
- FT_UNUSED( idx );
- FT_UNUSED( aname );
-
- return FT_THROW( Unimplemented_Feature );
- }
-
-
- FT_EXPORT_DEF( FT_Error )
- FT_Get_Sfnt_LangTag( FT_Face face,
- FT_UInt langID,
- FT_SfntLangTag *alangTag )
- {
- FT_UNUSED( face );
- FT_UNUSED( langID );
- FT_UNUSED( alangTag );
-
- return FT_THROW( Unimplemented_Feature );
- }
-
-
-#endif /* !TT_CONFIG_OPTION_SFNT_NAMES */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/base/ftstream.c b/contrib/libs/freetype/src/base/ftstream.c
deleted file mode 100644
index 6672224612..0000000000
--- a/contrib/libs/freetype/src/base/ftstream.c
+++ /dev/null
@@ -1,872 +0,0 @@
-/****************************************************************************
- *
- * ftstream.c
- *
- * I/O stream support (body).
- *
- * Copyright (C) 2000-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftstream.h>
-#include <freetype/internal/ftdebug.h>
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT stream
-
-
- FT_BASE_DEF( void )
- FT_Stream_OpenMemory( FT_Stream stream,
- const FT_Byte* base,
- FT_ULong size )
- {
- stream->base = (FT_Byte*) base;
- stream->size = size;
- stream->pos = 0;
- stream->cursor = NULL;
- stream->read = NULL;
- stream->close = NULL;
- }
-
-
- FT_BASE_DEF( void )
- FT_Stream_Close( FT_Stream stream )
- {
- if ( stream && stream->close )
- stream->close( stream );
- }
-
-
- FT_BASE_DEF( FT_Error )
- FT_Stream_Seek( FT_Stream stream,
- FT_ULong pos )
- {
- FT_Error error = FT_Err_Ok;
-
-
- if ( stream->read )
- {
- if ( stream->read( stream, pos, NULL, 0 ) )
- {
- FT_ERROR(( "FT_Stream_Seek:"
- " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
- pos, stream->size ));
-
- error = FT_THROW( Invalid_Stream_Operation );
- }
- }
- /* note that seeking to the first position after the file is valid */
- else if ( pos > stream->size )
- {
- FT_ERROR(( "FT_Stream_Seek:"
- " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
- pos, stream->size ));
-
- error = FT_THROW( Invalid_Stream_Operation );
- }
-
- if ( !error )
- stream->pos = pos;
-
- return error;
- }
-
-
- FT_BASE_DEF( FT_Error )
- FT_Stream_Skip( FT_Stream stream,
- FT_Long distance )
- {
- if ( distance < 0 )
- return FT_THROW( Invalid_Stream_Operation );
-
- return FT_Stream_Seek( stream, stream->pos + (FT_ULong)distance );
- }
-
-
- FT_BASE_DEF( FT_ULong )
- FT_Stream_Pos( FT_Stream stream )
- {
- return stream->pos;
- }
-
-
- FT_BASE_DEF( FT_Error )
- FT_Stream_Read( FT_Stream stream,
- FT_Byte* buffer,
- FT_ULong count )
- {
- return FT_Stream_ReadAt( stream, stream->pos, buffer, count );
- }
-
-
- FT_BASE_DEF( FT_Error )
- FT_Stream_ReadAt( FT_Stream stream,
- FT_ULong pos,
- FT_Byte* buffer,
- FT_ULong count )
- {
- FT_Error error = FT_Err_Ok;
- FT_ULong read_bytes;
-
-
- if ( pos >= stream->size )
- {
- FT_ERROR(( "FT_Stream_ReadAt:"
- " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
- pos, stream->size ));
-
- return FT_THROW( Invalid_Stream_Operation );
- }
-
- if ( stream->read )
- read_bytes = stream->read( stream, pos, buffer, count );
- else
- {
- read_bytes = stream->size - pos;
- if ( read_bytes > count )
- read_bytes = count;
-
- /* Allow "reading" zero bytes without UB even if buffer is NULL */
- if ( count )
- FT_MEM_COPY( buffer, stream->base + pos, read_bytes );
- }
-
- stream->pos = pos + read_bytes;
-
- if ( read_bytes < count )
- {
- FT_ERROR(( "FT_Stream_ReadAt:"
- " invalid read; expected %lu bytes, got %lu\n",
- count, read_bytes ));
-
- error = FT_THROW( Invalid_Stream_Operation );
- }
-
- return error;
- }
-
-
- FT_BASE_DEF( FT_ULong )
- FT_Stream_TryRead( FT_Stream stream,
- FT_Byte* buffer,
- FT_ULong count )
- {
- FT_ULong read_bytes = 0;
-
-
- if ( stream->pos >= stream->size )
- goto Exit;
-
- if ( stream->read )
- read_bytes = stream->read( stream, stream->pos, buffer, count );
- else
- {
- read_bytes = stream->size - stream->pos;
- if ( read_bytes > count )
- read_bytes = count;
-
- /* Allow "reading" zero bytes without UB even if buffer is NULL */
- if ( count )
- FT_MEM_COPY( buffer, stream->base + stream->pos, read_bytes );
- }
-
- stream->pos += read_bytes;
-
- Exit:
- return read_bytes;
- }
-
-
- FT_BASE_DEF( FT_Error )
- FT_Stream_ExtractFrame( FT_Stream stream,
- FT_ULong count,
- FT_Byte** pbytes )
- {
- FT_Error error;
-
-
- error = FT_Stream_EnterFrame( stream, count );
- if ( !error )
- {
- *pbytes = (FT_Byte*)stream->cursor;
-
- /* equivalent to FT_Stream_ExitFrame(), with no memory block release */
- stream->cursor = NULL;
- stream->limit = NULL;
- }
-
- return error;
- }
-
-
- FT_BASE_DEF( void )
- FT_Stream_ReleaseFrame( FT_Stream stream,
- FT_Byte** pbytes )
- {
- if ( stream && stream->read )
- {
- FT_Memory memory = stream->memory;
-
-
-#ifdef FT_DEBUG_MEMORY
- ft_mem_free( memory, *pbytes );
-#else
- FT_FREE( *pbytes );
-#endif
- }
-
- *pbytes = NULL;
- }
-
-
- FT_BASE_DEF( FT_Error )
- FT_Stream_EnterFrame( FT_Stream stream,
- FT_ULong count )
- {
- FT_Error error = FT_Err_Ok;
- FT_ULong read_bytes;
-
-
- FT_TRACE7(( "FT_Stream_EnterFrame: %ld bytes\n", count ));
-
- /* check for nested frame access */
- FT_ASSERT( stream && stream->cursor == 0 );
-
- if ( stream->read )
- {
- /* allocate the frame in memory */
- FT_Memory memory = stream->memory;
-
-
- /* simple sanity check */
- if ( count > stream->size )
- {
- FT_ERROR(( "FT_Stream_EnterFrame:"
- " frame size (%lu) larger than stream size (%lu)\n",
- count, stream->size ));
-
- error = FT_THROW( Invalid_Stream_Operation );
- goto Exit;
- }
-
-#ifdef FT_DEBUG_MEMORY
- /* assume `ft_debug_file_` and `ft_debug_lineno_` are already set */
- stream->base = (unsigned char*)ft_mem_qalloc( memory,
- (FT_Long)count,
- &error );
- if ( error )
- goto Exit;
-#else
- if ( FT_QALLOC( stream->base, count ) )
- goto Exit;
-#endif
- /* read it */
- read_bytes = stream->read( stream, stream->pos,
- stream->base, count );
- if ( read_bytes < count )
- {
- FT_ERROR(( "FT_Stream_EnterFrame:"
- " invalid read; expected %lu bytes, got %lu\n",
- count, read_bytes ));
-
- FT_FREE( stream->base );
- error = FT_THROW( Invalid_Stream_Operation );
- }
-
- stream->cursor = stream->base;
- stream->limit = FT_OFFSET( stream->cursor, count );
- stream->pos += read_bytes;
- }
- else
- {
- /* check current and new position */
- if ( stream->pos >= stream->size ||
- stream->size - stream->pos < count )
- {
- FT_ERROR(( "FT_Stream_EnterFrame:"
- " invalid i/o; pos = 0x%lx, count = %lu, size = 0x%lx\n",
- stream->pos, count, stream->size ));
-
- error = FT_THROW( Invalid_Stream_Operation );
- goto Exit;
- }
-
- /* set cursor */
- stream->cursor = stream->base + stream->pos;
- stream->limit = stream->cursor + count;
- stream->pos += count;
- }
-
- Exit:
- return error;
- }
-
-
- FT_BASE_DEF( void )
- FT_Stream_ExitFrame( FT_Stream stream )
- {
- /* IMPORTANT: The assertion stream->cursor != 0 was removed, given */
- /* that it is possible to access a frame of length 0 in */
- /* some weird fonts (usually, when accessing an array of */
- /* 0 records, like in some strange kern tables). */
- /* */
- /* In this case, the loader code handles the 0-length table */
- /* gracefully; however, stream.cursor is really set to 0 by the */
- /* FT_Stream_EnterFrame() call, and this is not an error. */
-
- FT_TRACE7(( "FT_Stream_ExitFrame\n" ));
-
- FT_ASSERT( stream );
-
- if ( stream->read )
- {
- FT_Memory memory = stream->memory;
-
-
-#ifdef FT_DEBUG_MEMORY
- ft_mem_free( memory, stream->base );
- stream->base = NULL;
-#else
- FT_FREE( stream->base );
-#endif
- }
-
- stream->cursor = NULL;
- stream->limit = NULL;
- }
-
-
- FT_BASE_DEF( FT_Byte )
- FT_Stream_GetByte( FT_Stream stream )
- {
- FT_Byte result;
-
-
- FT_ASSERT( stream && stream->cursor );
-
- result = 0;
- if ( stream->cursor < stream->limit )
- result = *stream->cursor++;
-
- return result;
- }
-
-
- FT_BASE_DEF( FT_UInt16 )
- FT_Stream_GetUShort( FT_Stream stream )
- {
- FT_Byte* p;
- FT_UInt16 result;
-
-
- FT_ASSERT( stream && stream->cursor );
-
- result = 0;
- p = stream->cursor;
- if ( p + 1 < stream->limit )
- result = FT_NEXT_USHORT( p );
- stream->cursor = p;
-
- return result;
- }
-
-
- FT_BASE_DEF( FT_UInt16 )
- FT_Stream_GetUShortLE( FT_Stream stream )
- {
- FT_Byte* p;
- FT_UInt16 result;
-
-
- FT_ASSERT( stream && stream->cursor );
-
- result = 0;
- p = stream->cursor;
- if ( p + 1 < stream->limit )
- result = FT_NEXT_USHORT_LE( p );
- stream->cursor = p;
-
- return result;
- }
-
-
- FT_BASE_DEF( FT_UInt32 )
- FT_Stream_GetUOffset( FT_Stream stream )
- {
- FT_Byte* p;
- FT_UInt32 result;
-
-
- FT_ASSERT( stream && stream->cursor );
-
- result = 0;
- p = stream->cursor;
- if ( p + 2 < stream->limit )
- result = FT_NEXT_UOFF3( p );
- stream->cursor = p;
- return result;
- }
-
-
- FT_BASE_DEF( FT_UInt32 )
- FT_Stream_GetULong( FT_Stream stream )
- {
- FT_Byte* p;
- FT_UInt32 result;
-
-
- FT_ASSERT( stream && stream->cursor );
-
- result = 0;
- p = stream->cursor;
- if ( p + 3 < stream->limit )
- result = FT_NEXT_ULONG( p );
- stream->cursor = p;
- return result;
- }
-
-
- FT_BASE_DEF( FT_UInt32 )
- FT_Stream_GetULongLE( FT_Stream stream )
- {
- FT_Byte* p;
- FT_UInt32 result;
-
-
- FT_ASSERT( stream && stream->cursor );
-
- result = 0;
- p = stream->cursor;
- if ( p + 3 < stream->limit )
- result = FT_NEXT_ULONG_LE( p );
- stream->cursor = p;
- return result;
- }
-
-
- FT_BASE_DEF( FT_Byte )
- FT_Stream_ReadByte( FT_Stream stream,
- FT_Error* error )
- {
- FT_Byte result = 0;
-
-
- FT_ASSERT( stream );
-
- if ( stream->pos < stream->size )
- {
- if ( stream->read )
- {
- if ( stream->read( stream, stream->pos, &result, 1L ) != 1L )
- goto Fail;
- }
- else
- result = stream->base[stream->pos];
- }
- else
- goto Fail;
-
- stream->pos++;
-
- *error = FT_Err_Ok;
-
- return result;
-
- Fail:
- *error = FT_THROW( Invalid_Stream_Operation );
- FT_ERROR(( "FT_Stream_ReadByte:"
- " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
- stream->pos, stream->size ));
-
- return result;
- }
-
-
- FT_BASE_DEF( FT_UInt16 )
- FT_Stream_ReadUShort( FT_Stream stream,
- FT_Error* error )
- {
- FT_Byte reads[2];
- FT_Byte* p;
- FT_UInt16 result = 0;
-
-
- FT_ASSERT( stream );
-
- if ( stream->pos + 1 < stream->size )
- {
- if ( stream->read )
- {
- if ( stream->read( stream, stream->pos, reads, 2L ) != 2L )
- goto Fail;
-
- p = reads;
- }
- else
- p = stream->base + stream->pos;
-
- if ( p )
- result = FT_NEXT_USHORT( p );
- }
- else
- goto Fail;
-
- stream->pos += 2;
-
- *error = FT_Err_Ok;
-
- return result;
-
- Fail:
- *error = FT_THROW( Invalid_Stream_Operation );
- FT_ERROR(( "FT_Stream_ReadUShort:"
- " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
- stream->pos, stream->size ));
-
- return result;
- }
-
-
- FT_BASE_DEF( FT_UInt16 )
- FT_Stream_ReadUShortLE( FT_Stream stream,
- FT_Error* error )
- {
- FT_Byte reads[2];
- FT_Byte* p;
- FT_UInt16 result = 0;
-
-
- FT_ASSERT( stream );
-
- if ( stream->pos + 1 < stream->size )
- {
- if ( stream->read )
- {
- if ( stream->read( stream, stream->pos, reads, 2L ) != 2L )
- goto Fail;
-
- p = reads;
- }
- else
- p = stream->base + stream->pos;
-
- if ( p )
- result = FT_NEXT_USHORT_LE( p );
- }
- else
- goto Fail;
-
- stream->pos += 2;
-
- *error = FT_Err_Ok;
-
- return result;
-
- Fail:
- *error = FT_THROW( Invalid_Stream_Operation );
- FT_ERROR(( "FT_Stream_ReadUShortLE:"
- " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
- stream->pos, stream->size ));
-
- return result;
- }
-
-
- FT_BASE_DEF( FT_ULong )
- FT_Stream_ReadUOffset( FT_Stream stream,
- FT_Error* error )
- {
- FT_Byte reads[3];
- FT_Byte* p;
- FT_ULong result = 0;
-
-
- FT_ASSERT( stream );
-
- if ( stream->pos + 2 < stream->size )
- {
- if ( stream->read )
- {
- if (stream->read( stream, stream->pos, reads, 3L ) != 3L )
- goto Fail;
-
- p = reads;
- }
- else
- p = stream->base + stream->pos;
-
- if ( p )
- result = FT_NEXT_UOFF3( p );
- }
- else
- goto Fail;
-
- stream->pos += 3;
-
- *error = FT_Err_Ok;
-
- return result;
-
- Fail:
- *error = FT_THROW( Invalid_Stream_Operation );
- FT_ERROR(( "FT_Stream_ReadUOffset:"
- " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
- stream->pos, stream->size ));
-
- return result;
- }
-
-
- FT_BASE_DEF( FT_UInt32 )
- FT_Stream_ReadULong( FT_Stream stream,
- FT_Error* error )
- {
- FT_Byte reads[4];
- FT_Byte* p;
- FT_UInt32 result = 0;
-
-
- FT_ASSERT( stream );
-
- if ( stream->pos + 3 < stream->size )
- {
- if ( stream->read )
- {
- if ( stream->read( stream, stream->pos, reads, 4L ) != 4L )
- goto Fail;
-
- p = reads;
- }
- else
- p = stream->base + stream->pos;
-
- if ( p )
- result = FT_NEXT_ULONG( p );
- }
- else
- goto Fail;
-
- stream->pos += 4;
-
- *error = FT_Err_Ok;
-
- return result;
-
- Fail:
- *error = FT_THROW( Invalid_Stream_Operation );
- FT_ERROR(( "FT_Stream_ReadULong:"
- " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
- stream->pos, stream->size ));
-
- return result;
- }
-
-
- FT_BASE_DEF( FT_UInt32 )
- FT_Stream_ReadULongLE( FT_Stream stream,
- FT_Error* error )
- {
- FT_Byte reads[4];
- FT_Byte* p;
- FT_UInt32 result = 0;
-
-
- FT_ASSERT( stream );
-
- if ( stream->pos + 3 < stream->size )
- {
- if ( stream->read )
- {
- if ( stream->read( stream, stream->pos, reads, 4L ) != 4L )
- goto Fail;
-
- p = reads;
- }
- else
- p = stream->base + stream->pos;
-
- if ( p )
- result = FT_NEXT_ULONG_LE( p );
- }
- else
- goto Fail;
-
- stream->pos += 4;
-
- *error = FT_Err_Ok;
-
- return result;
-
- Fail:
- *error = FT_THROW( Invalid_Stream_Operation );
- FT_ERROR(( "FT_Stream_ReadULongLE:"
- " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
- stream->pos, stream->size ));
-
- return result;
- }
-
-
- FT_BASE_DEF( FT_Error )
- FT_Stream_ReadFields( FT_Stream stream,
- const FT_Frame_Field* fields,
- void* structure )
- {
- FT_Error error;
- FT_Bool frame_accessed = 0;
- FT_Byte* cursor;
-
-
- if ( !fields )
- return FT_THROW( Invalid_Argument );
-
- if ( !stream )
- return FT_THROW( Invalid_Stream_Handle );
-
- cursor = stream->cursor;
-
- error = FT_Err_Ok;
- do
- {
- FT_ULong value;
- FT_Int sign_shift;
- FT_Byte* p;
-
-
- switch ( fields->value )
- {
- case ft_frame_start: /* access a new frame */
- error = FT_Stream_EnterFrame( stream, fields->offset );
- if ( error )
- goto Exit;
-
- frame_accessed = 1;
- cursor = stream->cursor;
- fields++;
- continue; /* loop! */
-
- case ft_frame_bytes: /* read a byte sequence */
- case ft_frame_skip: /* skip some bytes */
- {
- FT_Offset len = fields->size;
-
-
- if ( len > (FT_Offset)( stream->limit - cursor ) )
- {
- error = FT_THROW( Invalid_Stream_Operation );
- goto Exit;
- }
-
- if ( fields->value == ft_frame_bytes )
- {
- p = (FT_Byte*)structure + fields->offset;
- FT_MEM_COPY( p, cursor, len );
- }
- cursor += len;
- fields++;
- continue;
- }
-
- case ft_frame_byte:
- case ft_frame_schar: /* read a single byte */
- value = FT_NEXT_BYTE( cursor );
- sign_shift = 24;
- break;
-
- case ft_frame_short_be:
- case ft_frame_ushort_be: /* read a 2-byte big-endian short */
- value = FT_NEXT_USHORT( cursor );
- sign_shift = 16;
- break;
-
- case ft_frame_short_le:
- case ft_frame_ushort_le: /* read a 2-byte little-endian short */
- value = FT_NEXT_USHORT_LE( cursor );
- sign_shift = 16;
- break;
-
- case ft_frame_long_be:
- case ft_frame_ulong_be: /* read a 4-byte big-endian long */
- value = FT_NEXT_ULONG( cursor );
- sign_shift = 0;
- break;
-
- case ft_frame_long_le:
- case ft_frame_ulong_le: /* read a 4-byte little-endian long */
- value = FT_NEXT_ULONG_LE( cursor );
- sign_shift = 0;
- break;
-
- case ft_frame_off3_be:
- case ft_frame_uoff3_be: /* read a 3-byte big-endian long */
- value = FT_NEXT_UOFF3( cursor );
- sign_shift = 8;
- break;
-
- case ft_frame_off3_le:
- case ft_frame_uoff3_le: /* read a 3-byte little-endian long */
- value = FT_NEXT_UOFF3_LE( cursor );
- sign_shift = 8;
- break;
-
- default:
- /* otherwise, exit the loop */
- stream->cursor = cursor;
- goto Exit;
- }
-
- /* now, compute the signed value if necessary */
- if ( fields->value & FT_FRAME_OP_SIGNED )
- value = (FT_ULong)( (FT_Int32)( value << sign_shift ) >> sign_shift );
-
- /* finally, store the value in the object */
-
- p = (FT_Byte*)structure + fields->offset;
- switch ( fields->size )
- {
- case ( 8 / FT_CHAR_BIT ):
- *(FT_Byte*)p = (FT_Byte)value;
- break;
-
- case ( 16 / FT_CHAR_BIT ):
- *(FT_UShort*)p = (FT_UShort)value;
- break;
-
- case ( 32 / FT_CHAR_BIT ):
- *(FT_UInt32*)p = (FT_UInt32)value;
- break;
-
- default: /* for 64-bit systems */
- *(FT_ULong*)p = (FT_ULong)value;
- }
-
- /* go to next field */
- fields++;
- }
- while ( 1 );
-
- Exit:
- /* close the frame if it was opened by this read */
- if ( frame_accessed )
- FT_Stream_ExitFrame( stream );
-
- return error;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/base/ftstroke.c b/contrib/libs/freetype/src/base/ftstroke.c
deleted file mode 100644
index 64f46ce43e..0000000000
--- a/contrib/libs/freetype/src/base/ftstroke.c
+++ /dev/null
@@ -1,2403 +0,0 @@
-/****************************************************************************
- *
- * ftstroke.c
- *
- * FreeType path stroker (body).
- *
- * Copyright (C) 2002-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/ftstroke.h>
-#include <freetype/fttrigon.h>
-#include <freetype/ftoutln.h>
-#include <freetype/internal/ftmemory.h>
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftobjs.h>
-
-
- /* declare an extern to access `ft_outline_glyph_class' globally */
- /* allocated in `ftglyph.c' */
- FT_CALLBACK_TABLE const FT_Glyph_Class ft_outline_glyph_class;
-
-
- /* documentation is in ftstroke.h */
-
- FT_EXPORT_DEF( FT_StrokerBorder )
- FT_Outline_GetInsideBorder( FT_Outline* outline )
- {
- FT_Orientation o = FT_Outline_Get_Orientation( outline );
-
-
- return o == FT_ORIENTATION_TRUETYPE ? FT_STROKER_BORDER_RIGHT
- : FT_STROKER_BORDER_LEFT;
- }
-
-
- /* documentation is in ftstroke.h */
-
- FT_EXPORT_DEF( FT_StrokerBorder )
- FT_Outline_GetOutsideBorder( FT_Outline* outline )
- {
- FT_Orientation o = FT_Outline_Get_Orientation( outline );
-
-
- return o == FT_ORIENTATION_TRUETYPE ? FT_STROKER_BORDER_LEFT
- : FT_STROKER_BORDER_RIGHT;
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** BEZIER COMPUTATIONS *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-#define FT_SMALL_CONIC_THRESHOLD ( FT_ANGLE_PI / 6 )
-#define FT_SMALL_CUBIC_THRESHOLD ( FT_ANGLE_PI / 8 )
-
-#define FT_EPSILON 2
-
-#define FT_IS_SMALL( x ) ( (x) > -FT_EPSILON && (x) < FT_EPSILON )
-
-
- static FT_Pos
- ft_pos_abs( FT_Pos x )
- {
- return x >= 0 ? x : -x;
- }
-
-
- static void
- ft_conic_split( FT_Vector* base )
- {
- FT_Pos a, b;
-
-
- base[4].x = base[2].x;
- a = base[0].x + base[1].x;
- b = base[1].x + base[2].x;
- base[3].x = b >> 1;
- base[2].x = ( a + b ) >> 2;
- base[1].x = a >> 1;
-
- base[4].y = base[2].y;
- a = base[0].y + base[1].y;
- b = base[1].y + base[2].y;
- base[3].y = b >> 1;
- base[2].y = ( a + b ) >> 2;
- base[1].y = a >> 1;
- }
-
-
- static FT_Bool
- ft_conic_is_small_enough( FT_Vector* base,
- FT_Angle *angle_in,
- FT_Angle *angle_out )
- {
- FT_Vector d1, d2;
- FT_Angle theta;
- FT_Int close1, close2;
-
-
- d1.x = base[1].x - base[2].x;
- d1.y = base[1].y - base[2].y;
- d2.x = base[0].x - base[1].x;
- d2.y = base[0].y - base[1].y;
-
- close1 = FT_IS_SMALL( d1.x ) && FT_IS_SMALL( d1.y );
- close2 = FT_IS_SMALL( d2.x ) && FT_IS_SMALL( d2.y );
-
- if ( close1 )
- {
- if ( close2 )
- {
- /* basically a point; */
- /* do nothing to retain original direction */
- }
- else
- {
- *angle_in =
- *angle_out = FT_Atan2( d2.x, d2.y );
- }
- }
- else /* !close1 */
- {
- if ( close2 )
- {
- *angle_in =
- *angle_out = FT_Atan2( d1.x, d1.y );
- }
- else
- {
- *angle_in = FT_Atan2( d1.x, d1.y );
- *angle_out = FT_Atan2( d2.x, d2.y );
- }
- }
-
- theta = ft_pos_abs( FT_Angle_Diff( *angle_in, *angle_out ) );
-
- return FT_BOOL( theta < FT_SMALL_CONIC_THRESHOLD );
- }
-
-
- static void
- ft_cubic_split( FT_Vector* base )
- {
- FT_Pos a, b, c;
-
-
- base[6].x = base[3].x;
- a = base[0].x + base[1].x;
- b = base[1].x + base[2].x;
- c = base[2].x + base[3].x;
- base[5].x = c >> 1;
- c += b;
- base[4].x = c >> 2;
- base[1].x = a >> 1;
- a += b;
- base[2].x = a >> 2;
- base[3].x = ( a + c ) >> 3;
-
- base[6].y = base[3].y;
- a = base[0].y + base[1].y;
- b = base[1].y + base[2].y;
- c = base[2].y + base[3].y;
- base[5].y = c >> 1;
- c += b;
- base[4].y = c >> 2;
- base[1].y = a >> 1;
- a += b;
- base[2].y = a >> 2;
- base[3].y = ( a + c ) >> 3;
- }
-
-
- /* Return the average of `angle1' and `angle2'. */
- /* This gives correct result even if `angle1' and `angle2' */
- /* have opposite signs. */
- static FT_Angle
- ft_angle_mean( FT_Angle angle1,
- FT_Angle angle2 )
- {
- return angle1 + FT_Angle_Diff( angle1, angle2 ) / 2;
- }
-
-
- static FT_Bool
- ft_cubic_is_small_enough( FT_Vector* base,
- FT_Angle *angle_in,
- FT_Angle *angle_mid,
- FT_Angle *angle_out )
- {
- FT_Vector d1, d2, d3;
- FT_Angle theta1, theta2;
- FT_Int close1, close2, close3;
-
-
- d1.x = base[2].x - base[3].x;
- d1.y = base[2].y - base[3].y;
- d2.x = base[1].x - base[2].x;
- d2.y = base[1].y - base[2].y;
- d3.x = base[0].x - base[1].x;
- d3.y = base[0].y - base[1].y;
-
- close1 = FT_IS_SMALL( d1.x ) && FT_IS_SMALL( d1.y );
- close2 = FT_IS_SMALL( d2.x ) && FT_IS_SMALL( d2.y );
- close3 = FT_IS_SMALL( d3.x ) && FT_IS_SMALL( d3.y );
-
- if ( close1 )
- {
- if ( close2 )
- {
- if ( close3 )
- {
- /* basically a point; */
- /* do nothing to retain original direction */
- }
- else /* !close3 */
- {
- *angle_in =
- *angle_mid =
- *angle_out = FT_Atan2( d3.x, d3.y );
- }
- }
- else /* !close2 */
- {
- if ( close3 )
- {
- *angle_in =
- *angle_mid =
- *angle_out = FT_Atan2( d2.x, d2.y );
- }
- else /* !close3 */
- {
- *angle_in =
- *angle_mid = FT_Atan2( d2.x, d2.y );
- *angle_out = FT_Atan2( d3.x, d3.y );
- }
- }
- }
- else /* !close1 */
- {
- if ( close2 )
- {
- if ( close3 )
- {
- *angle_in =
- *angle_mid =
- *angle_out = FT_Atan2( d1.x, d1.y );
- }
- else /* !close3 */
- {
- *angle_in = FT_Atan2( d1.x, d1.y );
- *angle_out = FT_Atan2( d3.x, d3.y );
- *angle_mid = ft_angle_mean( *angle_in, *angle_out );
- }
- }
- else /* !close2 */
- {
- if ( close3 )
- {
- *angle_in = FT_Atan2( d1.x, d1.y );
- *angle_mid =
- *angle_out = FT_Atan2( d2.x, d2.y );
- }
- else /* !close3 */
- {
- *angle_in = FT_Atan2( d1.x, d1.y );
- *angle_mid = FT_Atan2( d2.x, d2.y );
- *angle_out = FT_Atan2( d3.x, d3.y );
- }
- }
- }
-
- theta1 = ft_pos_abs( FT_Angle_Diff( *angle_in, *angle_mid ) );
- theta2 = ft_pos_abs( FT_Angle_Diff( *angle_mid, *angle_out ) );
-
- return FT_BOOL( theta1 < FT_SMALL_CUBIC_THRESHOLD &&
- theta2 < FT_SMALL_CUBIC_THRESHOLD );
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** STROKE BORDERS *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- typedef enum FT_StrokeTags_
- {
- FT_STROKE_TAG_ON = 1, /* on-curve point */
- FT_STROKE_TAG_CUBIC = 2, /* cubic off-point */
- FT_STROKE_TAG_BEGIN = 4, /* sub-path start */
- FT_STROKE_TAG_END = 8 /* sub-path end */
-
- } FT_StrokeTags;
-
-#define FT_STROKE_TAG_BEGIN_END ( FT_STROKE_TAG_BEGIN | FT_STROKE_TAG_END )
-
- typedef struct FT_StrokeBorderRec_
- {
- FT_UInt num_points;
- FT_UInt max_points;
- FT_Vector* points;
- FT_Byte* tags;
- FT_Bool movable; /* TRUE for ends of lineto borders */
- FT_Int start; /* index of current sub-path start point */
- FT_Memory memory;
- FT_Bool valid;
-
- } FT_StrokeBorderRec, *FT_StrokeBorder;
-
-
- static FT_Error
- ft_stroke_border_grow( FT_StrokeBorder border,
- FT_UInt new_points )
- {
- FT_UInt old_max = border->max_points;
- FT_UInt new_max = border->num_points + new_points;
- FT_Error error = FT_Err_Ok;
-
-
- if ( new_max > old_max )
- {
- FT_UInt cur_max = old_max;
- FT_Memory memory = border->memory;
-
-
- while ( cur_max < new_max )
- cur_max += ( cur_max >> 1 ) + 16;
-
- if ( FT_RENEW_ARRAY( border->points, old_max, cur_max ) ||
- FT_RENEW_ARRAY( border->tags, old_max, cur_max ) )
- goto Exit;
-
- border->max_points = cur_max;
- }
-
- Exit:
- return error;
- }
-
-
- static void
- ft_stroke_border_close( FT_StrokeBorder border,
- FT_Bool reverse )
- {
- FT_UInt start = (FT_UInt)border->start;
- FT_UInt count = border->num_points;
-
-
- FT_ASSERT( border->start >= 0 );
-
- /* don't record empty paths! */
- if ( count <= start + 1U )
- border->num_points = start;
- else
- {
- /* copy the last point to the start of this sub-path, since */
- /* it contains the `adjusted' starting coordinates */
- border->num_points = --count;
- border->points[start] = border->points[count];
- border->tags[start] = border->tags[count];
-
- if ( reverse )
- {
- /* reverse the points */
- {
- FT_Vector* vec1 = border->points + start + 1;
- FT_Vector* vec2 = border->points + count - 1;
-
-
- for ( ; vec1 < vec2; vec1++, vec2-- )
- {
- FT_Vector tmp;
-
-
- tmp = *vec1;
- *vec1 = *vec2;
- *vec2 = tmp;
- }
- }
-
- /* then the tags */
- {
- FT_Byte* tag1 = border->tags + start + 1;
- FT_Byte* tag2 = border->tags + count - 1;
-
-
- for ( ; tag1 < tag2; tag1++, tag2-- )
- {
- FT_Byte tmp;
-
-
- tmp = *tag1;
- *tag1 = *tag2;
- *tag2 = tmp;
- }
- }
- }
-
- border->tags[start ] |= FT_STROKE_TAG_BEGIN;
- border->tags[count - 1] |= FT_STROKE_TAG_END;
- }
-
- border->start = -1;
- border->movable = FALSE;
- }
-
-
- static FT_Error
- ft_stroke_border_lineto( FT_StrokeBorder border,
- FT_Vector* to,
- FT_Bool movable )
- {
- FT_Error error = FT_Err_Ok;
-
-
- FT_ASSERT( border->start >= 0 );
-
- if ( border->movable )
- {
- /* move last point */
- border->points[border->num_points - 1] = *to;
- }
- else
- {
- /* don't add zero-length lineto, but always add moveto */
- if ( border->num_points > (FT_UInt)border->start &&
- FT_IS_SMALL( border->points[border->num_points - 1].x - to->x ) &&
- FT_IS_SMALL( border->points[border->num_points - 1].y - to->y ) )
- return error;
-
- /* add one point */
- error = ft_stroke_border_grow( border, 1 );
- if ( !error )
- {
- FT_Vector* vec = border->points + border->num_points;
- FT_Byte* tag = border->tags + border->num_points;
-
-
- vec[0] = *to;
- tag[0] = FT_STROKE_TAG_ON;
-
- border->num_points += 1;
- }
- }
- border->movable = movable;
- return error;
- }
-
-
- static FT_Error
- ft_stroke_border_conicto( FT_StrokeBorder border,
- FT_Vector* control,
- FT_Vector* to )
- {
- FT_Error error;
-
-
- FT_ASSERT( border->start >= 0 );
-
- error = ft_stroke_border_grow( border, 2 );
- if ( !error )
- {
- FT_Vector* vec = border->points + border->num_points;
- FT_Byte* tag = border->tags + border->num_points;
-
-
- vec[0] = *control;
- vec[1] = *to;
-
- tag[0] = 0;
- tag[1] = FT_STROKE_TAG_ON;
-
- border->num_points += 2;
- }
-
- border->movable = FALSE;
-
- return error;
- }
-
-
- static FT_Error
- ft_stroke_border_cubicto( FT_StrokeBorder border,
- FT_Vector* control1,
- FT_Vector* control2,
- FT_Vector* to )
- {
- FT_Error error;
-
-
- FT_ASSERT( border->start >= 0 );
-
- error = ft_stroke_border_grow( border, 3 );
- if ( !error )
- {
- FT_Vector* vec = border->points + border->num_points;
- FT_Byte* tag = border->tags + border->num_points;
-
-
- vec[0] = *control1;
- vec[1] = *control2;
- vec[2] = *to;
-
- tag[0] = FT_STROKE_TAG_CUBIC;
- tag[1] = FT_STROKE_TAG_CUBIC;
- tag[2] = FT_STROKE_TAG_ON;
-
- border->num_points += 3;
- }
-
- border->movable = FALSE;
-
- return error;
- }
-
-
-#define FT_ARC_CUBIC_ANGLE ( FT_ANGLE_PI / 2 )
-
-
- static FT_Error
- ft_stroke_border_arcto( FT_StrokeBorder border,
- FT_Vector* center,
- FT_Fixed radius,
- FT_Angle angle_start,
- FT_Angle angle_diff )
- {
- FT_Fixed coef;
- FT_Vector a0, a1, a2, a3;
- FT_Int i, arcs = 1;
- FT_Error error = FT_Err_Ok;
-
-
- /* number of cubic arcs to draw */
- while ( angle_diff > FT_ARC_CUBIC_ANGLE * arcs ||
- -angle_diff > FT_ARC_CUBIC_ANGLE * arcs )
- arcs++;
-
- /* control tangents */
- coef = FT_Tan( angle_diff / ( 4 * arcs ) );
- coef += coef / 3;
-
- /* compute start and first control point */
- FT_Vector_From_Polar( &a0, radius, angle_start );
- a1.x = FT_MulFix( -a0.y, coef );
- a1.y = FT_MulFix( a0.x, coef );
-
- a0.x += center->x;
- a0.y += center->y;
- a1.x += a0.x;
- a1.y += a0.y;
-
- for ( i = 1; i <= arcs; i++ )
- {
- /* compute end and second control point */
- FT_Vector_From_Polar( &a3, radius,
- angle_start + i * angle_diff / arcs );
- a2.x = FT_MulFix( a3.y, coef );
- a2.y = FT_MulFix( -a3.x, coef );
-
- a3.x += center->x;
- a3.y += center->y;
- a2.x += a3.x;
- a2.y += a3.y;
-
- /* add cubic arc */
- error = ft_stroke_border_cubicto( border, &a1, &a2, &a3 );
- if ( error )
- break;
-
- /* a0 = a3; */
- a1.x = a3.x - a2.x + a3.x;
- a1.y = a3.y - a2.y + a3.y;
- }
-
- return error;
- }
-
-
- static FT_Error
- ft_stroke_border_moveto( FT_StrokeBorder border,
- FT_Vector* to )
- {
- /* close current open path if any ? */
- if ( border->start >= 0 )
- ft_stroke_border_close( border, FALSE );
-
- border->start = (FT_Int)border->num_points;
- border->movable = FALSE;
-
- return ft_stroke_border_lineto( border, to, FALSE );
- }
-
-
- static void
- ft_stroke_border_init( FT_StrokeBorder border,
- FT_Memory memory )
- {
- border->memory = memory;
- border->points = NULL;
- border->tags = NULL;
-
- border->num_points = 0;
- border->max_points = 0;
- border->start = -1;
- border->valid = FALSE;
- }
-
-
- static void
- ft_stroke_border_reset( FT_StrokeBorder border )
- {
- border->num_points = 0;
- border->start = -1;
- border->valid = FALSE;
- }
-
-
- static void
- ft_stroke_border_done( FT_StrokeBorder border )
- {
- FT_Memory memory = border->memory;
-
-
- FT_FREE( border->points );
- FT_FREE( border->tags );
-
- border->num_points = 0;
- border->max_points = 0;
- border->start = -1;
- border->valid = FALSE;
- }
-
-
- static FT_Error
- ft_stroke_border_get_counts( FT_StrokeBorder border,
- FT_UInt *anum_points,
- FT_UInt *anum_contours )
- {
- FT_Error error = FT_Err_Ok;
- FT_UInt num_points = 0;
- FT_UInt num_contours = 0;
-
- FT_UInt count = border->num_points;
- FT_Vector* point = border->points;
- FT_Byte* tags = border->tags;
- FT_Int in_contour = 0;
-
-
- for ( ; count > 0; count--, num_points++, point++, tags++ )
- {
- if ( tags[0] & FT_STROKE_TAG_BEGIN )
- {
- if ( in_contour != 0 )
- goto Fail;
-
- in_contour = 1;
- }
- else if ( in_contour == 0 )
- goto Fail;
-
- if ( tags[0] & FT_STROKE_TAG_END )
- {
- in_contour = 0;
- num_contours++;
- }
- }
-
- if ( in_contour != 0 )
- goto Fail;
-
- border->valid = TRUE;
-
- Exit:
- *anum_points = num_points;
- *anum_contours = num_contours;
- return error;
-
- Fail:
- num_points = 0;
- num_contours = 0;
- goto Exit;
- }
-
-
- static void
- ft_stroke_border_export( FT_StrokeBorder border,
- FT_Outline* outline )
- {
- /* copy point locations */
- if ( border->num_points )
- FT_ARRAY_COPY( outline->points + outline->n_points,
- border->points,
- border->num_points );
-
- /* copy tags */
- {
- FT_UInt count = border->num_points;
- FT_Byte* read = border->tags;
- FT_Byte* write = outline->tags + outline->n_points;
-
-
- for ( ; count > 0; count--, read++, write++ )
- {
- if ( *read & FT_STROKE_TAG_ON )
- *write = FT_CURVE_TAG_ON;
- else if ( *read & FT_STROKE_TAG_CUBIC )
- *write = FT_CURVE_TAG_CUBIC;
- else
- *write = FT_CURVE_TAG_CONIC;
- }
- }
-
- /* copy contours */
- {
- FT_UInt count = border->num_points;
- FT_Byte* tags = border->tags;
- FT_UShort* write = outline->contours + outline->n_contours;
- FT_UShort idx = outline->n_points;
-
-
- for ( ; count > 0; count--, tags++, idx++ )
- {
- if ( *tags & FT_STROKE_TAG_END )
- {
- *write++ = idx;
- outline->n_contours++;
- }
- }
- }
-
- outline->n_points += (FT_UShort)border->num_points;
-
- FT_ASSERT( FT_Outline_Check( outline ) == 0 );
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** STROKER *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-#define FT_SIDE_TO_ROTATE( s ) ( FT_ANGLE_PI2 - (s) * FT_ANGLE_PI )
-
- typedef struct FT_StrokerRec_
- {
- FT_Angle angle_in; /* direction into curr join */
- FT_Angle angle_out; /* direction out of join */
- FT_Vector center; /* current position */
- FT_Fixed line_length; /* length of last lineto */
- FT_Bool first_point; /* is this the start? */
- FT_Bool subpath_open; /* is the subpath open? */
- FT_Angle subpath_angle; /* subpath start direction */
- FT_Vector subpath_start; /* subpath start position */
- FT_Fixed subpath_line_length; /* subpath start lineto len */
- FT_Bool handle_wide_strokes; /* use wide strokes logic? */
-
- FT_Stroker_LineCap line_cap;
- FT_Stroker_LineJoin line_join;
- FT_Stroker_LineJoin line_join_saved;
- FT_Fixed miter_limit;
- FT_Fixed radius;
-
- FT_StrokeBorderRec borders[2];
- FT_Library library;
-
- } FT_StrokerRec;
-
-
- /* documentation is in ftstroke.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Stroker_New( FT_Library library,
- FT_Stroker *astroker )
- {
- FT_Error error; /* assigned in FT_NEW */
- FT_Memory memory;
- FT_Stroker stroker = NULL;
-
-
- if ( !library )
- return FT_THROW( Invalid_Library_Handle );
-
- if ( !astroker )
- return FT_THROW( Invalid_Argument );
-
- memory = library->memory;
-
- if ( !FT_NEW( stroker ) )
- {
- stroker->library = library;
-
- ft_stroke_border_init( &stroker->borders[0], memory );
- ft_stroke_border_init( &stroker->borders[1], memory );
- }
-
- *astroker = stroker;
-
- return error;
- }
-
-
- /* documentation is in ftstroke.h */
-
- FT_EXPORT_DEF( void )
- FT_Stroker_Set( FT_Stroker stroker,
- FT_Fixed radius,
- FT_Stroker_LineCap line_cap,
- FT_Stroker_LineJoin line_join,
- FT_Fixed miter_limit )
- {
- if ( !stroker )
- return;
-
- stroker->radius = radius;
- stroker->line_cap = line_cap;
- stroker->line_join = line_join;
- stroker->miter_limit = miter_limit;
-
- /* ensure miter limit has sensible value */
- if ( stroker->miter_limit < 0x10000L )
- stroker->miter_limit = 0x10000L;
-
- /* save line join style: */
- /* line join style can be temporarily changed when stroking curves */
- stroker->line_join_saved = line_join;
-
- FT_Stroker_Rewind( stroker );
- }
-
-
- /* documentation is in ftstroke.h */
-
- FT_EXPORT_DEF( void )
- FT_Stroker_Rewind( FT_Stroker stroker )
- {
- if ( stroker )
- {
- ft_stroke_border_reset( &stroker->borders[0] );
- ft_stroke_border_reset( &stroker->borders[1] );
- }
- }
-
-
- /* documentation is in ftstroke.h */
-
- FT_EXPORT_DEF( void )
- FT_Stroker_Done( FT_Stroker stroker )
- {
- if ( stroker )
- {
- FT_Memory memory = stroker->library->memory;
-
-
- ft_stroke_border_done( &stroker->borders[0] );
- ft_stroke_border_done( &stroker->borders[1] );
-
- stroker->library = NULL;
- FT_FREE( stroker );
- }
- }
-
-
- /* create a circular arc at a corner or cap */
- static FT_Error
- ft_stroker_arcto( FT_Stroker stroker,
- FT_Int side )
- {
- FT_Angle total, rotate;
- FT_Fixed radius = stroker->radius;
- FT_Error error = FT_Err_Ok;
- FT_StrokeBorder border = stroker->borders + side;
-
-
- rotate = FT_SIDE_TO_ROTATE( side );
-
- total = FT_Angle_Diff( stroker->angle_in, stroker->angle_out );
- if ( total == FT_ANGLE_PI )
- total = -rotate * 2;
-
- error = ft_stroke_border_arcto( border,
- &stroker->center,
- radius,
- stroker->angle_in + rotate,
- total );
- border->movable = FALSE;
- return error;
- }
-
-
- /* add a cap at the end of an opened path */
- static FT_Error
- ft_stroker_cap( FT_Stroker stroker,
- FT_Angle angle,
- FT_Int side )
- {
- FT_Error error = FT_Err_Ok;
-
-
- if ( stroker->line_cap == FT_STROKER_LINECAP_ROUND )
- {
- /* add a round cap */
- stroker->angle_in = angle;
- stroker->angle_out = angle + FT_ANGLE_PI;
-
- error = ft_stroker_arcto( stroker, side );
- }
- else
- {
- /* add a square or butt cap */
- FT_Vector middle, delta;
- FT_Fixed radius = stroker->radius;
- FT_StrokeBorder border = stroker->borders + side;
-
-
- /* compute middle point and first angle point */
- FT_Vector_From_Polar( &middle, radius, angle );
- delta.x = side ? middle.y : -middle.y;
- delta.y = side ? -middle.x : middle.x;
-
- if ( stroker->line_cap == FT_STROKER_LINECAP_SQUARE )
- {
- middle.x += stroker->center.x;
- middle.y += stroker->center.y;
- }
- else /* FT_STROKER_LINECAP_BUTT */
- {
- middle.x = stroker->center.x;
- middle.y = stroker->center.y;
- }
-
- delta.x += middle.x;
- delta.y += middle.y;
-
- error = ft_stroke_border_lineto( border, &delta, FALSE );
- if ( error )
- goto Exit;
-
- /* compute second angle point */
- delta.x = middle.x - delta.x + middle.x;
- delta.y = middle.y - delta.y + middle.y;
-
- error = ft_stroke_border_lineto( border, &delta, FALSE );
- }
-
- Exit:
- return error;
- }
-
-
- /* process an inside corner, i.e. compute intersection */
- static FT_Error
- ft_stroker_inside( FT_Stroker stroker,
- FT_Int side,
- FT_Fixed line_length )
- {
- FT_StrokeBorder border = stroker->borders + side;
- FT_Angle phi, theta, rotate;
- FT_Fixed length;
- FT_Vector sigma = { 0, 0 };
- FT_Vector delta;
- FT_Error error = FT_Err_Ok;
- FT_Bool intersect; /* use intersection of lines? */
-
-
- rotate = FT_SIDE_TO_ROTATE( side );
-
- theta = FT_Angle_Diff( stroker->angle_in, stroker->angle_out ) / 2;
-
- /* Only intersect borders if between two lineto's and both */
- /* lines are long enough (line_length is zero for curves). */
- /* Also avoid U-turns of nearly 180 degree. */
- if ( !border->movable || line_length == 0 ||
- theta > 0x59C000 || theta < -0x59C000 )
- intersect = FALSE;
- else
- {
- /* compute minimum required length of lines */
- FT_Fixed min_length;
-
-
- FT_Vector_Unit( &sigma, theta );
- min_length =
- ft_pos_abs( FT_MulDiv( stroker->radius, sigma.y, sigma.x ) );
-
- intersect = FT_BOOL( min_length &&
- stroker->line_length >= min_length &&
- line_length >= min_length );
- }
-
- if ( !intersect )
- {
- FT_Vector_From_Polar( &delta, stroker->radius,
- stroker->angle_out + rotate );
- delta.x += stroker->center.x;
- delta.y += stroker->center.y;
-
- border->movable = FALSE;
- }
- else
- {
- /* compute median angle */
- phi = stroker->angle_in + theta + rotate;
-
- length = FT_DivFix( stroker->radius, sigma.x );
-
- FT_Vector_From_Polar( &delta, length, phi );
- delta.x += stroker->center.x;
- delta.y += stroker->center.y;
- }
-
- error = ft_stroke_border_lineto( border, &delta, FALSE );
-
- return error;
- }
-
-
- /* process an outside corner, i.e. compute bevel/miter/round */
- static FT_Error
- ft_stroker_outside( FT_Stroker stroker,
- FT_Int side,
- FT_Fixed line_length )
- {
- FT_StrokeBorder border = stroker->borders + side;
- FT_Error error;
- FT_Angle rotate;
-
-
- if ( stroker->line_join == FT_STROKER_LINEJOIN_ROUND )
- error = ft_stroker_arcto( stroker, side );
- else
- {
- /* this is a mitered (pointed) or beveled (truncated) corner */
- FT_Fixed radius = stroker->radius;
- FT_Vector sigma = { 0, 0 };
- FT_Angle theta = 0, phi = 0;
- FT_Bool bevel, fixed_bevel;
-
-
- rotate = FT_SIDE_TO_ROTATE( side );
-
- bevel =
- FT_BOOL( stroker->line_join == FT_STROKER_LINEJOIN_BEVEL );
-
- fixed_bevel =
- FT_BOOL( stroker->line_join != FT_STROKER_LINEJOIN_MITER_VARIABLE );
-
- /* check miter limit first */
- if ( !bevel )
- {
- theta = FT_Angle_Diff( stroker->angle_in, stroker->angle_out ) / 2;
-
- if ( theta == FT_ANGLE_PI2 )
- theta = -rotate;
-
- phi = stroker->angle_in + theta + rotate;
-
- FT_Vector_From_Polar( &sigma, stroker->miter_limit, theta );
-
- /* is miter limit exceeded? */
- if ( sigma.x < 0x10000L )
- {
- /* don't create variable bevels for very small deviations; */
- /* FT_Sin(x) = 0 for x <= 57 */
- if ( fixed_bevel || ft_pos_abs( theta ) > 57 )
- bevel = TRUE;
- }
- }
-
- if ( bevel ) /* this is a bevel (broken angle) */
- {
- if ( fixed_bevel )
- {
- /* the outer corners are simply joined together */
- FT_Vector delta;
-
-
- /* add bevel */
- FT_Vector_From_Polar( &delta,
- radius,
- stroker->angle_out + rotate );
- delta.x += stroker->center.x;
- delta.y += stroker->center.y;
-
- border->movable = FALSE;
- error = ft_stroke_border_lineto( border, &delta, FALSE );
- }
- else /* variable bevel or clipped miter */
- {
- /* the miter is truncated */
- FT_Vector middle, delta;
- FT_Fixed coef;
-
-
- /* compute middle point and first angle point */
- FT_Vector_From_Polar( &middle,
- FT_MulFix( radius, stroker->miter_limit ),
- phi );
-
- coef = FT_DivFix( 0x10000L - sigma.x, sigma.y );
- delta.x = FT_MulFix( middle.y, coef );
- delta.y = FT_MulFix( -middle.x, coef );
-
- middle.x += stroker->center.x;
- middle.y += stroker->center.y;
- delta.x += middle.x;
- delta.y += middle.y;
-
- error = ft_stroke_border_lineto( border, &delta, FALSE );
- if ( error )
- goto Exit;
-
- /* compute second angle point */
- delta.x = middle.x - delta.x + middle.x;
- delta.y = middle.y - delta.y + middle.y;
-
- error = ft_stroke_border_lineto( border, &delta, FALSE );
- if ( error )
- goto Exit;
-
- /* finally, add an end point; only needed if not lineto */
- /* (line_length is zero for curves) */
- if ( line_length == 0 )
- {
- FT_Vector_From_Polar( &delta,
- radius,
- stroker->angle_out + rotate );
-
- delta.x += stroker->center.x;
- delta.y += stroker->center.y;
-
- error = ft_stroke_border_lineto( border, &delta, FALSE );
- }
- }
- }
- else /* this is a miter (intersection) */
- {
- FT_Fixed length;
- FT_Vector delta;
-
-
- length = FT_MulDiv( stroker->radius, stroker->miter_limit, sigma.x );
-
- FT_Vector_From_Polar( &delta, length, phi );
- delta.x += stroker->center.x;
- delta.y += stroker->center.y;
-
- error = ft_stroke_border_lineto( border, &delta, FALSE );
- if ( error )
- goto Exit;
-
- /* now add an end point; only needed if not lineto */
- /* (line_length is zero for curves) */
- if ( line_length == 0 )
- {
- FT_Vector_From_Polar( &delta,
- stroker->radius,
- stroker->angle_out + rotate );
- delta.x += stroker->center.x;
- delta.y += stroker->center.y;
-
- error = ft_stroke_border_lineto( border, &delta, FALSE );
- }
- }
- }
-
- Exit:
- return error;
- }
-
-
- static FT_Error
- ft_stroker_process_corner( FT_Stroker stroker,
- FT_Fixed line_length )
- {
- FT_Error error = FT_Err_Ok;
- FT_Angle turn;
- FT_Int inside_side;
-
-
- turn = FT_Angle_Diff( stroker->angle_in, stroker->angle_out );
-
- /* no specific corner processing is required if the turn is 0 */
- if ( turn == 0 )
- goto Exit;
-
- /* when we turn to the right, the inside side is 0 */
- /* otherwise, the inside side is 1 */
- inside_side = ( turn < 0 );
-
- /* process the inside side */
- error = ft_stroker_inside( stroker, inside_side, line_length );
- if ( error )
- goto Exit;
-
- /* process the outside side */
- error = ft_stroker_outside( stroker, !inside_side, line_length );
-
- Exit:
- return error;
- }
-
-
- /* add two points to the left and right borders corresponding to the */
- /* start of the subpath */
- static FT_Error
- ft_stroker_subpath_start( FT_Stroker stroker,
- FT_Angle start_angle,
- FT_Fixed line_length )
- {
- FT_Vector delta;
- FT_Vector point;
- FT_Error error;
- FT_StrokeBorder border;
-
-
- FT_Vector_From_Polar( &delta, stroker->radius,
- start_angle + FT_ANGLE_PI2 );
-
- point.x = stroker->center.x + delta.x;
- point.y = stroker->center.y + delta.y;
-
- border = stroker->borders;
- error = ft_stroke_border_moveto( border, &point );
- if ( error )
- goto Exit;
-
- point.x = stroker->center.x - delta.x;
- point.y = stroker->center.y - delta.y;
-
- border++;
- error = ft_stroke_border_moveto( border, &point );
-
- /* save angle, position, and line length for last join */
- /* (line_length is zero for curves) */
- stroker->subpath_angle = start_angle;
- stroker->first_point = FALSE;
- stroker->subpath_line_length = line_length;
-
- Exit:
- return error;
- }
-
-
- /* documentation is in ftstroke.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Stroker_LineTo( FT_Stroker stroker,
- FT_Vector* to )
- {
- FT_Error error = FT_Err_Ok;
- FT_StrokeBorder border;
- FT_Vector delta;
- FT_Angle angle;
- FT_Int side;
- FT_Fixed line_length;
-
-
- if ( !stroker || !to )
- return FT_THROW( Invalid_Argument );
-
- delta.x = to->x - stroker->center.x;
- delta.y = to->y - stroker->center.y;
-
- /* a zero-length lineto is a no-op; avoid creating a spurious corner */
- if ( delta.x == 0 && delta.y == 0 )
- goto Exit;
-
- /* compute length of line */
- line_length = FT_Vector_Length( &delta );
-
- angle = FT_Atan2( delta.x, delta.y );
- FT_Vector_From_Polar( &delta, stroker->radius, angle + FT_ANGLE_PI2 );
-
- /* process corner if necessary */
- if ( stroker->first_point )
- {
- /* This is the first segment of a subpath. We need to */
- /* add a point to each border at their respective starting */
- /* point locations. */
- error = ft_stroker_subpath_start( stroker, angle, line_length );
- if ( error )
- goto Exit;
- }
- else
- {
- /* process the current corner */
- stroker->angle_out = angle;
- error = ft_stroker_process_corner( stroker, line_length );
- if ( error )
- goto Exit;
- }
-
- /* now add a line segment to both the `inside' and `outside' paths */
- for ( border = stroker->borders, side = 1; side >= 0; side--, border++ )
- {
- FT_Vector point;
-
-
- point.x = to->x + delta.x;
- point.y = to->y + delta.y;
-
- /* the ends of lineto borders are movable */
- error = ft_stroke_border_lineto( border, &point, TRUE );
- if ( error )
- goto Exit;
-
- delta.x = -delta.x;
- delta.y = -delta.y;
- }
-
- stroker->angle_in = angle;
- stroker->center = *to;
- stroker->line_length = line_length;
-
- Exit:
- return error;
- }
-
-
- /* documentation is in ftstroke.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Stroker_ConicTo( FT_Stroker stroker,
- FT_Vector* control,
- FT_Vector* to )
- {
- FT_Error error = FT_Err_Ok;
- FT_Vector bez_stack[34];
- FT_Vector* arc;
- FT_Vector* limit = bez_stack + 30;
- FT_Bool first_arc = TRUE;
-
-
- if ( !stroker || !control || !to )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- /* if all control points are coincident, this is a no-op; */
- /* avoid creating a spurious corner */
- if ( FT_IS_SMALL( stroker->center.x - control->x ) &&
- FT_IS_SMALL( stroker->center.y - control->y ) &&
- FT_IS_SMALL( control->x - to->x ) &&
- FT_IS_SMALL( control->y - to->y ) )
- {
- stroker->center = *to;
- goto Exit;
- }
-
- arc = bez_stack;
- arc[0] = *to;
- arc[1] = *control;
- arc[2] = stroker->center;
-
- while ( arc >= bez_stack )
- {
- FT_Angle angle_in, angle_out;
-
-
- /* initialize with current direction */
- angle_in = angle_out = stroker->angle_in;
-
- if ( arc < limit &&
- !ft_conic_is_small_enough( arc, &angle_in, &angle_out ) )
- {
- if ( stroker->first_point )
- stroker->angle_in = angle_in;
-
- ft_conic_split( arc );
- arc += 2;
- continue;
- }
-
- if ( first_arc )
- {
- first_arc = FALSE;
-
- /* process corner if necessary */
- if ( stroker->first_point )
- error = ft_stroker_subpath_start( stroker, angle_in, 0 );
- else
- {
- stroker->angle_out = angle_in;
- error = ft_stroker_process_corner( stroker, 0 );
- }
- }
- else if ( ft_pos_abs( FT_Angle_Diff( stroker->angle_in, angle_in ) ) >
- FT_SMALL_CONIC_THRESHOLD / 4 )
- {
- /* if the deviation from one arc to the next is too great, */
- /* add a round corner */
- stroker->center = arc[2];
- stroker->angle_out = angle_in;
- stroker->line_join = FT_STROKER_LINEJOIN_ROUND;
-
- error = ft_stroker_process_corner( stroker, 0 );
-
- /* reinstate line join style */
- stroker->line_join = stroker->line_join_saved;
- }
-
- if ( error )
- goto Exit;
-
- /* the arc's angle is small enough; we can add it directly to each */
- /* border */
- {
- FT_Vector ctrl, end;
- FT_Angle theta, phi, rotate, alpha0 = 0;
- FT_Fixed length;
- FT_StrokeBorder border;
- FT_Int side;
-
-
- theta = FT_Angle_Diff( angle_in, angle_out ) / 2;
- phi = angle_in + theta;
- length = FT_DivFix( stroker->radius, FT_Cos( theta ) );
-
- /* compute direction of original arc */
- if ( stroker->handle_wide_strokes )
- alpha0 = FT_Atan2( arc[0].x - arc[2].x, arc[0].y - arc[2].y );
-
- for ( border = stroker->borders, side = 0;
- side <= 1;
- side++, border++ )
- {
- rotate = FT_SIDE_TO_ROTATE( side );
-
- /* compute control point */
- FT_Vector_From_Polar( &ctrl, length, phi + rotate );
- ctrl.x += arc[1].x;
- ctrl.y += arc[1].y;
-
- /* compute end point */
- FT_Vector_From_Polar( &end, stroker->radius, angle_out + rotate );
- end.x += arc[0].x;
- end.y += arc[0].y;
-
- if ( stroker->handle_wide_strokes )
- {
- FT_Vector start;
- FT_Angle alpha1;
-
-
- /* determine whether the border radius is greater than the */
- /* radius of curvature of the original arc */
- start = border->points[border->num_points - 1];
-
- alpha1 = FT_Atan2( end.x - start.x, end.y - start.y );
-
- /* is the direction of the border arc opposite to */
- /* that of the original arc? */
- if ( ft_pos_abs( FT_Angle_Diff( alpha0, alpha1 ) ) >
- FT_ANGLE_PI / 2 )
- {
- FT_Angle beta, gamma;
- FT_Vector bvec, delta;
- FT_Fixed blen, sinA, sinB, alen;
-
-
- /* use the sine rule to find the intersection point */
- beta = FT_Atan2( arc[2].x - start.x, arc[2].y - start.y );
- gamma = FT_Atan2( arc[0].x - end.x, arc[0].y - end.y );
-
- bvec.x = end.x - start.x;
- bvec.y = end.y - start.y;
-
- blen = FT_Vector_Length( &bvec );
-
- sinA = ft_pos_abs( FT_Sin( alpha1 - gamma ) );
- sinB = ft_pos_abs( FT_Sin( beta - gamma ) );
-
- alen = FT_MulDiv( blen, sinA, sinB );
-
- FT_Vector_From_Polar( &delta, alen, beta );
- delta.x += start.x;
- delta.y += start.y;
-
- /* circumnavigate the negative sector backwards */
- border->movable = FALSE;
- error = ft_stroke_border_lineto( border, &delta, FALSE );
- if ( error )
- goto Exit;
- error = ft_stroke_border_lineto( border, &end, FALSE );
- if ( error )
- goto Exit;
- error = ft_stroke_border_conicto( border, &ctrl, &start );
- if ( error )
- goto Exit;
- /* and then move to the endpoint */
- error = ft_stroke_border_lineto( border, &end, FALSE );
- if ( error )
- goto Exit;
-
- continue;
- }
-
- /* else fall through */
- }
-
- /* simply add an arc */
- error = ft_stroke_border_conicto( border, &ctrl, &end );
- if ( error )
- goto Exit;
- }
- }
-
- arc -= 2;
-
- stroker->angle_in = angle_out;
- }
-
- stroker->center = *to;
- stroker->line_length = 0;
-
- Exit:
- return error;
- }
-
-
- /* documentation is in ftstroke.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Stroker_CubicTo( FT_Stroker stroker,
- FT_Vector* control1,
- FT_Vector* control2,
- FT_Vector* to )
- {
- FT_Error error = FT_Err_Ok;
- FT_Vector bez_stack[37];
- FT_Vector* arc;
- FT_Vector* limit = bez_stack + 32;
- FT_Bool first_arc = TRUE;
-
-
- if ( !stroker || !control1 || !control2 || !to )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- /* if all control points are coincident, this is a no-op; */
- /* avoid creating a spurious corner */
- if ( FT_IS_SMALL( stroker->center.x - control1->x ) &&
- FT_IS_SMALL( stroker->center.y - control1->y ) &&
- FT_IS_SMALL( control1->x - control2->x ) &&
- FT_IS_SMALL( control1->y - control2->y ) &&
- FT_IS_SMALL( control2->x - to->x ) &&
- FT_IS_SMALL( control2->y - to->y ) )
- {
- stroker->center = *to;
- goto Exit;
- }
-
- arc = bez_stack;
- arc[0] = *to;
- arc[1] = *control2;
- arc[2] = *control1;
- arc[3] = stroker->center;
-
- while ( arc >= bez_stack )
- {
- FT_Angle angle_in, angle_mid, angle_out;
-
-
- /* initialize with current direction */
- angle_in = angle_out = angle_mid = stroker->angle_in;
-
- if ( arc < limit &&
- !ft_cubic_is_small_enough( arc, &angle_in,
- &angle_mid, &angle_out ) )
- {
- if ( stroker->first_point )
- stroker->angle_in = angle_in;
-
- ft_cubic_split( arc );
- arc += 3;
- continue;
- }
-
- if ( first_arc )
- {
- first_arc = FALSE;
-
- /* process corner if necessary */
- if ( stroker->first_point )
- error = ft_stroker_subpath_start( stroker, angle_in, 0 );
- else
- {
- stroker->angle_out = angle_in;
- error = ft_stroker_process_corner( stroker, 0 );
- }
- }
- else if ( ft_pos_abs( FT_Angle_Diff( stroker->angle_in, angle_in ) ) >
- FT_SMALL_CUBIC_THRESHOLD / 4 )
- {
- /* if the deviation from one arc to the next is too great, */
- /* add a round corner */
- stroker->center = arc[3];
- stroker->angle_out = angle_in;
- stroker->line_join = FT_STROKER_LINEJOIN_ROUND;
-
- error = ft_stroker_process_corner( stroker, 0 );
-
- /* reinstate line join style */
- stroker->line_join = stroker->line_join_saved;
- }
-
- if ( error )
- goto Exit;
-
- /* the arc's angle is small enough; we can add it directly to each */
- /* border */
- {
- FT_Vector ctrl1, ctrl2, end;
- FT_Angle theta1, phi1, theta2, phi2, rotate, alpha0 = 0;
- FT_Fixed length1, length2;
- FT_StrokeBorder border;
- FT_Int side;
-
-
- theta1 = FT_Angle_Diff( angle_in, angle_mid ) / 2;
- theta2 = FT_Angle_Diff( angle_mid, angle_out ) / 2;
- phi1 = ft_angle_mean( angle_in, angle_mid );
- phi2 = ft_angle_mean( angle_mid, angle_out );
- length1 = FT_DivFix( stroker->radius, FT_Cos( theta1 ) );
- length2 = FT_DivFix( stroker->radius, FT_Cos( theta2 ) );
-
- /* compute direction of original arc */
- if ( stroker->handle_wide_strokes )
- alpha0 = FT_Atan2( arc[0].x - arc[3].x, arc[0].y - arc[3].y );
-
- for ( border = stroker->borders, side = 0;
- side <= 1;
- side++, border++ )
- {
- rotate = FT_SIDE_TO_ROTATE( side );
-
- /* compute control points */
- FT_Vector_From_Polar( &ctrl1, length1, phi1 + rotate );
- ctrl1.x += arc[2].x;
- ctrl1.y += arc[2].y;
-
- FT_Vector_From_Polar( &ctrl2, length2, phi2 + rotate );
- ctrl2.x += arc[1].x;
- ctrl2.y += arc[1].y;
-
- /* compute end point */
- FT_Vector_From_Polar( &end, stroker->radius, angle_out + rotate );
- end.x += arc[0].x;
- end.y += arc[0].y;
-
- if ( stroker->handle_wide_strokes )
- {
- FT_Vector start;
- FT_Angle alpha1;
-
-
- /* determine whether the border radius is greater than the */
- /* radius of curvature of the original arc */
- start = border->points[border->num_points - 1];
-
- alpha1 = FT_Atan2( end.x - start.x, end.y - start.y );
-
- /* is the direction of the border arc opposite to */
- /* that of the original arc? */
- if ( ft_pos_abs( FT_Angle_Diff( alpha0, alpha1 ) ) >
- FT_ANGLE_PI / 2 )
- {
- FT_Angle beta, gamma;
- FT_Vector bvec, delta;
- FT_Fixed blen, sinA, sinB, alen;
-
-
- /* use the sine rule to find the intersection point */
- beta = FT_Atan2( arc[3].x - start.x, arc[3].y - start.y );
- gamma = FT_Atan2( arc[0].x - end.x, arc[0].y - end.y );
-
- bvec.x = end.x - start.x;
- bvec.y = end.y - start.y;
-
- blen = FT_Vector_Length( &bvec );
-
- sinA = ft_pos_abs( FT_Sin( alpha1 - gamma ) );
- sinB = ft_pos_abs( FT_Sin( beta - gamma ) );
-
- alen = FT_MulDiv( blen, sinA, sinB );
-
- FT_Vector_From_Polar( &delta, alen, beta );
- delta.x += start.x;
- delta.y += start.y;
-
- /* circumnavigate the negative sector backwards */
- border->movable = FALSE;
- error = ft_stroke_border_lineto( border, &delta, FALSE );
- if ( error )
- goto Exit;
- error = ft_stroke_border_lineto( border, &end, FALSE );
- if ( error )
- goto Exit;
- error = ft_stroke_border_cubicto( border,
- &ctrl2,
- &ctrl1,
- &start );
- if ( error )
- goto Exit;
- /* and then move to the endpoint */
- error = ft_stroke_border_lineto( border, &end, FALSE );
- if ( error )
- goto Exit;
-
- continue;
- }
-
- /* else fall through */
- }
-
- /* simply add an arc */
- error = ft_stroke_border_cubicto( border, &ctrl1, &ctrl2, &end );
- if ( error )
- goto Exit;
- }
- }
-
- arc -= 3;
-
- stroker->angle_in = angle_out;
- }
-
- stroker->center = *to;
- stroker->line_length = 0;
-
- Exit:
- return error;
- }
-
-
- /* documentation is in ftstroke.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Stroker_BeginSubPath( FT_Stroker stroker,
- FT_Vector* to,
- FT_Bool open )
- {
- if ( !stroker || !to )
- return FT_THROW( Invalid_Argument );
-
- /* We cannot process the first point, because there is not enough */
- /* information regarding its corner/cap. The latter will be processed */
- /* in the `FT_Stroker_EndSubPath' routine. */
- /* */
- stroker->first_point = TRUE;
- stroker->center = *to;
- stroker->subpath_open = open;
-
- /* Determine if we need to check whether the border radius is greater */
- /* than the radius of curvature of a curve, to handle this case */
- /* specially. This is only required if bevel joins or butt caps may */
- /* be created, because round & miter joins and round & square caps */
- /* cover the negative sector created with wide strokes. */
- stroker->handle_wide_strokes =
- FT_BOOL( stroker->line_join != FT_STROKER_LINEJOIN_ROUND ||
- ( stroker->subpath_open &&
- stroker->line_cap == FT_STROKER_LINECAP_BUTT ) );
-
- /* record the subpath start point for each border */
- stroker->subpath_start = *to;
-
- stroker->angle_in = 0;
-
- return FT_Err_Ok;
- }
-
-
- static FT_Error
- ft_stroker_add_reverse_left( FT_Stroker stroker,
- FT_Bool open )
- {
- FT_StrokeBorder right = stroker->borders + 0;
- FT_StrokeBorder left = stroker->borders + 1;
- FT_Int new_points;
- FT_Error error = FT_Err_Ok;
-
-
- FT_ASSERT( left->start >= 0 );
-
- new_points = (FT_Int)left->num_points - left->start;
- if ( new_points > 0 )
- {
- error = ft_stroke_border_grow( right, (FT_UInt)new_points );
- if ( error )
- goto Exit;
-
- {
- FT_Vector* dst_point = right->points + right->num_points;
- FT_Byte* dst_tag = right->tags + right->num_points;
- FT_Vector* src_point = left->points + left->num_points - 1;
- FT_Byte* src_tag = left->tags + left->num_points - 1;
-
-
- while ( src_point >= left->points + left->start )
- {
- *dst_point = *src_point;
- *dst_tag = *src_tag;
-
- if ( open )
- dst_tag[0] &= ~FT_STROKE_TAG_BEGIN_END;
- else
- {
- FT_Byte ttag =
- (FT_Byte)( dst_tag[0] & FT_STROKE_TAG_BEGIN_END );
-
-
- /* switch begin/end tags if necessary */
- if ( ttag == FT_STROKE_TAG_BEGIN ||
- ttag == FT_STROKE_TAG_END )
- dst_tag[0] ^= FT_STROKE_TAG_BEGIN_END;
- }
-
- src_point--;
- src_tag--;
- dst_point++;
- dst_tag++;
- }
- }
-
- left->num_points = (FT_UInt)left->start;
- right->num_points += (FT_UInt)new_points;
-
- right->movable = FALSE;
- left->movable = FALSE;
- }
-
- Exit:
- return error;
- }
-
-
- /* documentation is in ftstroke.h */
-
- /* there's a lot of magic in this function! */
- FT_EXPORT_DEF( FT_Error )
- FT_Stroker_EndSubPath( FT_Stroker stroker )
- {
- FT_Error error = FT_Err_Ok;
-
-
- if ( !stroker )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- if ( stroker->subpath_open )
- {
- FT_StrokeBorder right = stroker->borders;
-
-
- /* All right, this is an opened path, we need to add a cap between */
- /* right & left, add the reverse of left, then add a final cap */
- /* between left & right. */
- error = ft_stroker_cap( stroker, stroker->angle_in, 0 );
- if ( error )
- goto Exit;
-
- /* add reversed points from `left' to `right' */
- error = ft_stroker_add_reverse_left( stroker, TRUE );
- if ( error )
- goto Exit;
-
- /* now add the final cap */
- stroker->center = stroker->subpath_start;
- error = ft_stroker_cap( stroker,
- stroker->subpath_angle + FT_ANGLE_PI, 0 );
- if ( error )
- goto Exit;
-
- /* Now end the right subpath accordingly. The left one is */
- /* rewind and doesn't need further processing. */
- ft_stroke_border_close( right, FALSE );
- }
- else
- {
- /* close the path if needed */
- if ( !FT_IS_SMALL( stroker->center.x - stroker->subpath_start.x ) ||
- !FT_IS_SMALL( stroker->center.y - stroker->subpath_start.y ) )
- {
- error = FT_Stroker_LineTo( stroker, &stroker->subpath_start );
- if ( error )
- goto Exit;
- }
-
- /* process the corner */
- stroker->angle_out = stroker->subpath_angle;
-
- error = ft_stroker_process_corner( stroker,
- stroker->subpath_line_length );
- if ( error )
- goto Exit;
-
- /* then end our two subpaths */
- ft_stroke_border_close( stroker->borders + 0, FALSE );
- ft_stroke_border_close( stroker->borders + 1, TRUE );
- }
-
- Exit:
- return error;
- }
-
-
- /* documentation is in ftstroke.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Stroker_GetBorderCounts( FT_Stroker stroker,
- FT_StrokerBorder border,
- FT_UInt *anum_points,
- FT_UInt *anum_contours )
- {
- FT_UInt num_points = 0, num_contours = 0;
- FT_Error error;
-
-
- if ( !stroker || border > 1 )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- error = ft_stroke_border_get_counts( stroker->borders + border,
- &num_points, &num_contours );
- Exit:
- if ( anum_points )
- *anum_points = num_points;
-
- if ( anum_contours )
- *anum_contours = num_contours;
-
- return error;
- }
-
-
- /* documentation is in ftstroke.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Stroker_GetCounts( FT_Stroker stroker,
- FT_UInt *anum_points,
- FT_UInt *anum_contours )
- {
- FT_UInt count1, count2, num_points = 0;
- FT_UInt count3, count4, num_contours = 0;
- FT_Error error;
-
-
- if ( !stroker )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- error = ft_stroke_border_get_counts( stroker->borders + 0,
- &count1, &count2 );
- if ( error )
- goto Exit;
-
- error = ft_stroke_border_get_counts( stroker->borders + 1,
- &count3, &count4 );
- if ( error )
- goto Exit;
-
- num_points = count1 + count3;
- num_contours = count2 + count4;
-
- Exit:
- if ( anum_points )
- *anum_points = num_points;
-
- if ( anum_contours )
- *anum_contours = num_contours;
-
- return error;
- }
-
-
- /* documentation is in ftstroke.h */
-
- FT_EXPORT_DEF( void )
- FT_Stroker_ExportBorder( FT_Stroker stroker,
- FT_StrokerBorder border,
- FT_Outline* outline )
- {
- if ( !stroker || !outline )
- return;
-
- if ( border == FT_STROKER_BORDER_LEFT ||
- border == FT_STROKER_BORDER_RIGHT )
- {
- FT_StrokeBorder sborder = & stroker->borders[border];
-
-
- if ( sborder->valid )
- ft_stroke_border_export( sborder, outline );
- }
- }
-
-
- /* documentation is in ftstroke.h */
-
- FT_EXPORT_DEF( void )
- FT_Stroker_Export( FT_Stroker stroker,
- FT_Outline* outline )
- {
- FT_Stroker_ExportBorder( stroker, FT_STROKER_BORDER_LEFT, outline );
- FT_Stroker_ExportBorder( stroker, FT_STROKER_BORDER_RIGHT, outline );
- }
-
-
- /* documentation is in ftstroke.h */
-
- /*
- * The following is very similar to FT_Outline_Decompose, except
- * that we do support opened paths, and do not scale the outline.
- */
- FT_EXPORT_DEF( FT_Error )
- FT_Stroker_ParseOutline( FT_Stroker stroker,
- FT_Outline* outline,
- FT_Bool opened )
- {
- FT_Vector v_last;
- FT_Vector v_control;
- FT_Vector v_start;
-
- FT_Vector* point;
- FT_Vector* limit;
- FT_Byte* tags;
-
- FT_Error error;
-
- FT_Int n; /* index of contour in outline */
- FT_Int first; /* index of first point in contour */
- FT_Int last; /* index of last point in contour */
-
- FT_Int tag; /* current point's state */
-
-
- if ( !outline )
- return FT_THROW( Invalid_Outline );
-
- if ( !stroker )
- return FT_THROW( Invalid_Argument );
-
- FT_Stroker_Rewind( stroker );
-
- last = -1;
- for ( n = 0; n < outline->n_contours; n++ )
- {
- first = last + 1;
- last = outline->contours[n];
-
- /* skip empty points; we don't stroke these */
- if ( last <= first )
- continue;
-
- limit = outline->points + last;
-
- v_start = outline->points[first];
- v_last = outline->points[last];
-
- v_control = v_start;
-
- point = outline->points + first;
- tags = outline->tags + first;
- tag = FT_CURVE_TAG( tags[0] );
-
- /* A contour cannot start with a cubic control point! */
- if ( tag == FT_CURVE_TAG_CUBIC )
- goto Invalid_Outline;
-
- /* check first point to determine origin */
- if ( tag == FT_CURVE_TAG_CONIC )
- {
- /* First point is conic control. Yes, this happens. */
- if ( FT_CURVE_TAG( outline->tags[last] ) == FT_CURVE_TAG_ON )
- {
- /* start at last point if it is on the curve */
- v_start = v_last;
- limit--;
- }
- else
- {
- /* if both first and last points are conic, */
- /* start at their middle */
- v_start.x = ( v_start.x + v_last.x ) / 2;
- v_start.y = ( v_start.y + v_last.y ) / 2;
- }
- point--;
- tags--;
- }
-
- error = FT_Stroker_BeginSubPath( stroker, &v_start, opened );
- if ( error )
- goto Exit;
-
- while ( point < limit )
- {
- point++;
- tags++;
-
- tag = FT_CURVE_TAG( tags[0] );
- switch ( tag )
- {
- case FT_CURVE_TAG_ON: /* emit a single line_to */
- {
- FT_Vector vec;
-
-
- vec.x = point->x;
- vec.y = point->y;
-
- error = FT_Stroker_LineTo( stroker, &vec );
- if ( error )
- goto Exit;
- continue;
- }
-
- case FT_CURVE_TAG_CONIC: /* consume conic arcs */
- v_control.x = point->x;
- v_control.y = point->y;
-
- Do_Conic:
- if ( point < limit )
- {
- FT_Vector vec;
- FT_Vector v_middle;
-
-
- point++;
- tags++;
- tag = FT_CURVE_TAG( tags[0] );
-
- vec = point[0];
-
- if ( tag == FT_CURVE_TAG_ON )
- {
- error = FT_Stroker_ConicTo( stroker, &v_control, &vec );
- if ( error )
- goto Exit;
- continue;
- }
-
- if ( tag != FT_CURVE_TAG_CONIC )
- goto Invalid_Outline;
-
- v_middle.x = ( v_control.x + vec.x ) / 2;
- v_middle.y = ( v_control.y + vec.y ) / 2;
-
- error = FT_Stroker_ConicTo( stroker, &v_control, &v_middle );
- if ( error )
- goto Exit;
-
- v_control = vec;
- goto Do_Conic;
- }
-
- error = FT_Stroker_ConicTo( stroker, &v_control, &v_start );
- goto Close;
-
- default: /* FT_CURVE_TAG_CUBIC */
- {
- FT_Vector vec1, vec2;
-
-
- if ( point + 1 > limit ||
- FT_CURVE_TAG( tags[1] ) != FT_CURVE_TAG_CUBIC )
- goto Invalid_Outline;
-
- point += 2;
- tags += 2;
-
- vec1 = point[-2];
- vec2 = point[-1];
-
- if ( point <= limit )
- {
- FT_Vector vec;
-
-
- vec = point[0];
-
- error = FT_Stroker_CubicTo( stroker, &vec1, &vec2, &vec );
- if ( error )
- goto Exit;
- continue;
- }
-
- error = FT_Stroker_CubicTo( stroker, &vec1, &vec2, &v_start );
- goto Close;
- }
- }
- }
-
- Close:
- if ( error )
- goto Exit;
-
- /* don't try to end the path if no segments have been generated */
- if ( !stroker->first_point )
- {
- error = FT_Stroker_EndSubPath( stroker );
- if ( error )
- goto Exit;
- }
- }
-
- return FT_Err_Ok;
-
- Exit:
- return error;
-
- Invalid_Outline:
- return FT_THROW( Invalid_Outline );
- }
-
-
- /* documentation is in ftstroke.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Glyph_Stroke( FT_Glyph *pglyph,
- FT_Stroker stroker,
- FT_Bool destroy )
- {
- FT_Error error = FT_ERR( Invalid_Argument );
- FT_Glyph glyph = NULL;
-
-
- if ( !pglyph )
- goto Exit;
-
- glyph = *pglyph;
- if ( !glyph || glyph->clazz != &ft_outline_glyph_class )
- goto Exit;
-
- {
- FT_Glyph copy;
-
-
- error = FT_Glyph_Copy( glyph, &copy );
- if ( error )
- goto Exit;
-
- glyph = copy;
- }
-
- {
- FT_OutlineGlyph oglyph = (FT_OutlineGlyph)glyph;
- FT_Outline* outline = &oglyph->outline;
- FT_UInt num_points, num_contours;
-
-
- error = FT_Stroker_ParseOutline( stroker, outline, FALSE );
- if ( error )
- goto Fail;
-
- FT_Stroker_GetCounts( stroker, &num_points, &num_contours );
-
- FT_Outline_Done( glyph->library, outline );
-
- error = FT_Outline_New( glyph->library,
- num_points,
- (FT_Int)num_contours,
- outline );
- if ( error )
- goto Fail;
-
- outline->n_points = 0;
- outline->n_contours = 0;
-
- FT_Stroker_Export( stroker, outline );
- }
-
- if ( destroy )
- FT_Done_Glyph( *pglyph );
-
- *pglyph = glyph;
- goto Exit;
-
- Fail:
- FT_Done_Glyph( glyph );
- glyph = NULL;
-
- if ( !destroy )
- *pglyph = NULL;
-
- Exit:
- return error;
- }
-
-
- /* documentation is in ftstroke.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Glyph_StrokeBorder( FT_Glyph *pglyph,
- FT_Stroker stroker,
- FT_Bool inside,
- FT_Bool destroy )
- {
- FT_Error error = FT_ERR( Invalid_Argument );
- FT_Glyph glyph = NULL;
-
-
- if ( !pglyph )
- goto Exit;
-
- glyph = *pglyph;
- if ( !glyph || glyph->clazz != &ft_outline_glyph_class )
- goto Exit;
-
- {
- FT_Glyph copy;
-
-
- error = FT_Glyph_Copy( glyph, &copy );
- if ( error )
- goto Exit;
-
- glyph = copy;
- }
-
- {
- FT_OutlineGlyph oglyph = (FT_OutlineGlyph)glyph;
- FT_StrokerBorder border;
- FT_Outline* outline = &oglyph->outline;
- FT_UInt num_points, num_contours;
-
-
- border = FT_Outline_GetOutsideBorder( outline );
- if ( inside )
- {
- if ( border == FT_STROKER_BORDER_LEFT )
- border = FT_STROKER_BORDER_RIGHT;
- else
- border = FT_STROKER_BORDER_LEFT;
- }
-
- error = FT_Stroker_ParseOutline( stroker, outline, FALSE );
- if ( error )
- goto Fail;
-
- FT_Stroker_GetBorderCounts( stroker, border,
- &num_points, &num_contours );
-
- FT_Outline_Done( glyph->library, outline );
-
- error = FT_Outline_New( glyph->library,
- num_points,
- (FT_Int)num_contours,
- outline );
- if ( error )
- goto Fail;
-
- outline->n_points = 0;
- outline->n_contours = 0;
-
- FT_Stroker_ExportBorder( stroker, border, outline );
- }
-
- if ( destroy )
- FT_Done_Glyph( *pglyph );
-
- *pglyph = glyph;
- goto Exit;
-
- Fail:
- FT_Done_Glyph( glyph );
- glyph = NULL;
-
- if ( !destroy )
- *pglyph = NULL;
-
- Exit:
- return error;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/base/ftsynth.c b/contrib/libs/freetype/src/base/ftsynth.c
deleted file mode 100644
index ec05bce33a..0000000000
--- a/contrib/libs/freetype/src/base/ftsynth.c
+++ /dev/null
@@ -1,180 +0,0 @@
-/****************************************************************************
- *
- * ftsynth.c
- *
- * FreeType synthesizing code for emboldening and slanting (body).
- *
- * Copyright (C) 2000-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/ftsynth.h>
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftobjs.h>
-#include <freetype/ftoutln.h>
-#include <freetype/ftbitmap.h>
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT synth
-
-
- /*************************************************************************/
- /*************************************************************************/
- /**** ****/
- /**** EXPERIMENTAL OBLIQUING SUPPORT ****/
- /**** ****/
- /*************************************************************************/
- /*************************************************************************/
-
- /* documentation is in ftsynth.h */
-
- FT_EXPORT_DEF( void )
- FT_GlyphSlot_Oblique( FT_GlyphSlot slot )
- {
- /* Value '0x0366A' corresponds to a shear angle of about 12 degrees. */
- FT_GlyphSlot_Slant( slot, 0x0366A, 0 );
- }
-
-
- /* documentation is in ftsynth.h */
-
- FT_EXPORT_DEF( void )
- FT_GlyphSlot_Slant( FT_GlyphSlot slot,
- FT_Fixed xslant,
- FT_Fixed yslant )
- {
- FT_Matrix transform;
- FT_Outline* outline;
-
-
- if ( !slot )
- return;
-
- outline = &slot->outline;
-
- /* only oblique outline glyphs */
- if ( slot->format != FT_GLYPH_FORMAT_OUTLINE )
- return;
-
- /* we don't touch the advance width */
-
- /* For italic, simply apply a shear transform */
- transform.xx = 0x10000L;
- transform.yx = -yslant;
-
- transform.xy = xslant;
- transform.yy = 0x10000L;
-
- FT_Outline_Transform( outline, &transform );
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /**** ****/
- /**** EXPERIMENTAL EMBOLDENING SUPPORT ****/
- /**** ****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /* documentation is in ftsynth.h */
-
- FT_EXPORT_DEF( void )
- FT_GlyphSlot_Embolden( FT_GlyphSlot slot )
- {
- FT_GlyphSlot_AdjustWeight( slot, 0x0AAA, 0x0AAA );
- }
-
-
- FT_EXPORT_DEF( void )
- FT_GlyphSlot_AdjustWeight( FT_GlyphSlot slot,
- FT_Fixed xdelta,
- FT_Fixed ydelta )
- {
- FT_Library library;
- FT_Size size;
- FT_Error error;
- FT_Pos xstr, ystr;
-
-
- if ( !slot )
- return;
-
- library = slot->library;
- size = slot->face->size;
-
- if ( slot->format != FT_GLYPH_FORMAT_OUTLINE &&
- slot->format != FT_GLYPH_FORMAT_BITMAP )
- return;
-
- /* express deltas in pixels in 26.6 format */
- xstr = (FT_Pos)size->metrics.x_ppem * xdelta / 1024;
- ystr = (FT_Pos)size->metrics.y_ppem * ydelta / 1024;
-
- if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
- FT_Outline_EmboldenXY( &slot->outline, xstr, ystr );
-
- else /* slot->format == FT_GLYPH_FORMAT_BITMAP */
- {
- /* round to full pixels */
- xstr &= ~63;
- if ( xstr == 0 )
- xstr = 1 << 6;
- ystr &= ~63;
-
- /*
- * XXX: overflow check for 16-bit system, for compatibility
- * with FT_GlyphSlot_Embolden() since FreeType 2.1.10.
- * unfortunately, this function return no informations
- * about the cause of error.
- */
- if ( ( ystr >> 6 ) > FT_INT_MAX || ( ystr >> 6 ) < FT_INT_MIN )
- {
- FT_TRACE1(( "FT_GlyphSlot_Embolden:" ));
- FT_TRACE1(( "too strong emboldening parameter ystr=%ld\n", ystr ));
- return;
- }
- error = FT_GlyphSlot_Own_Bitmap( slot );
- if ( error )
- return;
-
- error = FT_Bitmap_Embolden( library, &slot->bitmap, xstr, ystr );
- if ( error )
- return;
- }
-
- if ( slot->advance.x )
- slot->advance.x += xstr;
-
- if ( slot->advance.y )
- slot->advance.y += ystr;
-
- slot->metrics.width += xstr;
- slot->metrics.height += ystr;
- slot->metrics.horiAdvance += xstr;
- slot->metrics.vertAdvance += ystr;
- slot->metrics.horiBearingY += ystr;
-
- /* XXX: 16-bit overflow case must be excluded before here */
- if ( slot->format == FT_GLYPH_FORMAT_BITMAP )
- slot->bitmap_top += (FT_Int)( ystr >> 6 );
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/base/ftsystem.c b/contrib/libs/freetype/src/base/ftsystem.c
deleted file mode 100644
index eee3642334..0000000000
--- a/contrib/libs/freetype/src/base/ftsystem.c
+++ /dev/null
@@ -1,338 +0,0 @@
-/****************************************************************************
- *
- * ftsystem.c
- *
- * ANSI-specific FreeType low-level system interface (body).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
- /**************************************************************************
- *
- * This file contains the default interface used by FreeType to access
- * low-level, i.e. memory management, i/o access as well as thread
- * synchronisation. It can be replaced by user-specific routines if
- * necessary.
- *
- */
-
-
-#include <ft2build.h>
-#include FT_CONFIG_CONFIG_H
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/ftsystem.h>
-#include <freetype/fterrors.h>
-#include <freetype/fttypes.h>
-
-
- /**************************************************************************
- *
- * MEMORY MANAGEMENT INTERFACE
- *
- */
-
- /**************************************************************************
- *
- * It is not necessary to do any error checking for the
- * allocation-related functions. This will be done by the higher level
- * routines like ft_mem_alloc() or ft_mem_realloc().
- *
- */
-
-
- /**************************************************************************
- *
- * @Function:
- * ft_alloc
- *
- * @Description:
- * The memory allocation function.
- *
- * @Input:
- * memory ::
- * A pointer to the memory object.
- *
- * size ::
- * The requested size in bytes.
- *
- * @Return:
- * The address of newly allocated block.
- */
- FT_CALLBACK_DEF( void* )
- ft_alloc( FT_Memory memory,
- long size )
- {
- FT_UNUSED( memory );
-
- return ft_smalloc( (size_t)size );
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * ft_realloc
- *
- * @Description:
- * The memory reallocation function.
- *
- * @Input:
- * memory ::
- * A pointer to the memory object.
- *
- * cur_size ::
- * The current size of the allocated memory block.
- *
- * new_size ::
- * The newly requested size in bytes.
- *
- * block ::
- * The current address of the block in memory.
- *
- * @Return:
- * The address of the reallocated memory block.
- */
- FT_CALLBACK_DEF( void* )
- ft_realloc( FT_Memory memory,
- long cur_size,
- long new_size,
- void* block )
- {
- FT_UNUSED( memory );
- FT_UNUSED( cur_size );
-
- return ft_srealloc( block, (size_t)new_size );
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * ft_free
- *
- * @Description:
- * The memory release function.
- *
- * @Input:
- * memory ::
- * A pointer to the memory object.
- *
- * block ::
- * The address of block in memory to be freed.
- */
- FT_CALLBACK_DEF( void )
- ft_free( FT_Memory memory,
- void* block )
- {
- FT_UNUSED( memory );
-
- ft_sfree( block );
- }
-
-
- /**************************************************************************
- *
- * RESOURCE MANAGEMENT INTERFACE
- *
- */
-
-#ifndef FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT io
-
- /* We use the macro STREAM_FILE for convenience to extract the */
- /* system-specific stream handle from a given FreeType stream object */
-#define STREAM_FILE( stream ) ( (FT_FILE*)stream->descriptor.pointer )
-
-
- /**************************************************************************
- *
- * @Function:
- * ft_ansi_stream_close
- *
- * @Description:
- * The function to close a stream.
- *
- * @Input:
- * stream ::
- * A pointer to the stream object.
- */
- FT_CALLBACK_DEF( void )
- ft_ansi_stream_close( FT_Stream stream )
- {
- ft_fclose( STREAM_FILE( stream ) );
-
- stream->descriptor.pointer = NULL;
- stream->size = 0;
- stream->base = NULL;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * ft_ansi_stream_io
- *
- * @Description:
- * The function to open a stream.
- *
- * @Input:
- * stream ::
- * A pointer to the stream object.
- *
- * offset ::
- * The position in the data stream to start reading.
- *
- * buffer ::
- * The address of buffer to store the read data.
- *
- * count ::
- * The number of bytes to read from the stream.
- *
- * @Return:
- * The number of bytes actually read. If `count' is zero (that is,
- * the function is used for seeking), a non-zero return value
- * indicates an error.
- */
- FT_CALLBACK_DEF( unsigned long )
- ft_ansi_stream_io( FT_Stream stream,
- unsigned long offset,
- unsigned char* buffer,
- unsigned long count )
- {
- FT_FILE* file;
-
-
- if ( offset > stream->size && !count )
- return 1;
-
- file = STREAM_FILE( stream );
-
- if ( stream->pos != offset )
- ft_fseek( file, (long)offset, SEEK_SET );
-
- /* Avoid calling `fread` with `buffer=NULL` and `count=0`, */
- /* which is undefined behaviour. */
- if ( !count )
- return 0;
-
- return (unsigned long)ft_fread( buffer, 1, count, file );
- }
-
-
- /* documentation is in ftstream.h */
-
- FT_BASE_DEF( FT_Error )
- FT_Stream_Open( FT_Stream stream,
- const char* filepathname )
- {
- FT_FILE* file;
-
-
- if ( !stream )
- return FT_THROW( Invalid_Stream_Handle );
-
- stream->descriptor.pointer = NULL;
- stream->pathname.pointer = (char*)filepathname;
- stream->base = NULL;
- stream->pos = 0;
- stream->read = NULL;
- stream->close = NULL;
-
- file = ft_fopen( filepathname, "rb" );
- if ( !file )
- {
- FT_ERROR(( "FT_Stream_Open:"
- " could not open `%s'\n", filepathname ));
-
- return FT_THROW( Cannot_Open_Resource );
- }
-
- ft_fseek( file, 0, SEEK_END );
- stream->size = (unsigned long)ft_ftell( file );
- if ( !stream->size )
- {
- FT_ERROR(( "FT_Stream_Open:" ));
- FT_ERROR(( " opened `%s' but zero-sized\n", filepathname ));
- ft_fclose( file );
- return FT_THROW( Cannot_Open_Stream );
- }
- ft_fseek( file, 0, SEEK_SET );
-
- stream->descriptor.pointer = file;
- stream->read = ft_ansi_stream_io;
- stream->close = ft_ansi_stream_close;
-
- FT_TRACE1(( "FT_Stream_Open:" ));
- FT_TRACE1(( " opened `%s' (%ld bytes) successfully\n",
- filepathname, stream->size ));
-
- return FT_Err_Ok;
- }
-
-#endif /* !FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT */
-
-#ifdef FT_DEBUG_MEMORY
-
- extern FT_Int
- ft_mem_debug_init( FT_Memory memory );
-
- extern void
- ft_mem_debug_done( FT_Memory memory );
-
-#endif
-
-
- /* documentation is in ftobjs.h */
-
- FT_BASE_DEF( FT_Memory )
- FT_New_Memory( void )
- {
- FT_Memory memory;
-
-
- memory = (FT_Memory)ft_smalloc( sizeof ( *memory ) );
- if ( memory )
- {
- memory->user = NULL;
- memory->alloc = ft_alloc;
- memory->realloc = ft_realloc;
- memory->free = ft_free;
-#ifdef FT_DEBUG_MEMORY
- ft_mem_debug_init( memory );
-#endif
- }
-
- return memory;
- }
-
-
- /* documentation is in ftobjs.h */
-
- FT_BASE_DEF( void )
- FT_Done_Memory( FT_Memory memory )
- {
-#ifdef FT_DEBUG_MEMORY
- ft_mem_debug_done( memory );
-#endif
- ft_sfree( memory );
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/base/fttrigon.c b/contrib/libs/freetype/src/base/fttrigon.c
deleted file mode 100644
index 4b1aced1cb..0000000000
--- a/contrib/libs/freetype/src/base/fttrigon.c
+++ /dev/null
@@ -1,517 +0,0 @@
-/****************************************************************************
- *
- * fttrigon.c
- *
- * FreeType trigonometric functions (body).
- *
- * Copyright (C) 2001-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
- /**************************************************************************
- *
- * This is a fixed-point CORDIC implementation of trigonometric
- * functions as well as transformations between Cartesian and polar
- * coordinates. The angles are represented as 16.16 fixed-point values
- * in degrees, i.e., the angular resolution is 2^-16 degrees. Note that
- * only vectors longer than 2^16*180/pi (or at least 22 bits) on a
- * discrete Cartesian grid can have the same or better angular
- * resolution. Therefore, to maintain this precision, some functions
- * require an interim upscaling of the vectors, whereas others operate
- * with 24-bit long vectors directly.
- *
- */
-
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/ftcalc.h>
-#include <freetype/fttrigon.h>
-
-
- /* the Cordic shrink factor 0.858785336480436 * 2^32 */
-#define FT_TRIG_SCALE 0xDBD95B16UL
-
- /* the highest bit in overflow-safe vector components, */
- /* MSB of 0.858785336480436 * sqrt(0.5) * 2^30 */
-#define FT_TRIG_SAFE_MSB 29
-
- /* this table was generated for FT_PI = 180L << 16, i.e. degrees */
-#define FT_TRIG_MAX_ITERS 23
-
- static const FT_Angle
- ft_trig_arctan_table[] =
- {
- 1740967L, 919879L, 466945L, 234379L, 117304L, 58666L, 29335L,
- 14668L, 7334L, 3667L, 1833L, 917L, 458L, 229L, 115L,
- 57L, 29L, 14L, 7L, 4L, 2L, 1L
- };
-
-
-#ifdef FT_INT64
-
- /* multiply a given value by the CORDIC shrink factor */
- static FT_Fixed
- ft_trig_downscale( FT_Fixed val )
- {
- FT_Int s = 1;
-
-
- if ( val < 0 )
- {
- val = -val;
- s = -1;
- }
-
- /* 0x40000000 comes from regression analysis between true */
- /* and CORDIC hypotenuse, so it minimizes the error */
- val = (FT_Fixed)(
- ( (FT_UInt64)val * FT_TRIG_SCALE + 0x40000000UL ) >> 32 );
-
- return s < 0 ? -val : val;
- }
-
-#else /* !FT_INT64 */
-
- /* multiply a given value by the CORDIC shrink factor */
- static FT_Fixed
- ft_trig_downscale( FT_Fixed val )
- {
- FT_Int s = 1;
- FT_UInt32 lo1, hi1, lo2, hi2, lo, hi, i1, i2;
-
-
- if ( val < 0 )
- {
- val = -val;
- s = -1;
- }
-
- lo1 = (FT_UInt32)val & 0x0000FFFFU;
- hi1 = (FT_UInt32)val >> 16;
- lo2 = FT_TRIG_SCALE & 0x0000FFFFU;
- hi2 = FT_TRIG_SCALE >> 16;
-
- lo = lo1 * lo2;
- i1 = lo1 * hi2;
- i2 = lo2 * hi1;
- hi = hi1 * hi2;
-
- /* Check carry overflow of i1 + i2 */
- i1 += i2;
- hi += (FT_UInt32)( i1 < i2 ) << 16;
-
- hi += i1 >> 16;
- i1 = i1 << 16;
-
- /* Check carry overflow of i1 + lo */
- lo += i1;
- hi += ( lo < i1 );
-
- /* 0x40000000 comes from regression analysis between true */
- /* and CORDIC hypotenuse, so it minimizes the error */
-
- /* Check carry overflow of lo + 0x40000000 */
- lo += 0x40000000UL;
- hi += ( lo < 0x40000000UL );
-
- val = (FT_Fixed)hi;
-
- return s < 0 ? -val : val;
- }
-
-#endif /* !FT_INT64 */
-
-
- /* undefined and never called for zero vector */
- static FT_Int
- ft_trig_prenorm( FT_Vector* vec )
- {
- FT_Pos x, y;
- FT_Int shift;
-
-
- x = vec->x;
- y = vec->y;
-
- shift = FT_MSB( (FT_UInt32)( FT_ABS( x ) | FT_ABS( y ) ) );
-
- if ( shift <= FT_TRIG_SAFE_MSB )
- {
- shift = FT_TRIG_SAFE_MSB - shift;
- vec->x = (FT_Pos)( (FT_ULong)x << shift );
- vec->y = (FT_Pos)( (FT_ULong)y << shift );
- }
- else
- {
- shift -= FT_TRIG_SAFE_MSB;
- vec->x = x >> shift;
- vec->y = y >> shift;
- shift = -shift;
- }
-
- return shift;
- }
-
-
- static void
- ft_trig_pseudo_rotate( FT_Vector* vec,
- FT_Angle theta )
- {
- FT_Int i;
- FT_Fixed x, y, xtemp, b;
- const FT_Angle *arctanptr;
-
-
- x = vec->x;
- y = vec->y;
-
- /* Rotate inside [-PI/4,PI/4] sector */
- while ( theta < -FT_ANGLE_PI4 )
- {
- xtemp = y;
- y = -x;
- x = xtemp;
- theta += FT_ANGLE_PI2;
- }
-
- while ( theta > FT_ANGLE_PI4 )
- {
- xtemp = -y;
- y = x;
- x = xtemp;
- theta -= FT_ANGLE_PI2;
- }
-
- arctanptr = ft_trig_arctan_table;
-
- /* Pseudorotations, with right shifts */
- for ( i = 1, b = 1; i < FT_TRIG_MAX_ITERS; b <<= 1, i++ )
- {
- if ( theta < 0 )
- {
- xtemp = x + ( ( y + b ) >> i );
- y = y - ( ( x + b ) >> i );
- x = xtemp;
- theta += *arctanptr++;
- }
- else
- {
- xtemp = x - ( ( y + b ) >> i );
- y = y + ( ( x + b ) >> i );
- x = xtemp;
- theta -= *arctanptr++;
- }
- }
-
- vec->x = x;
- vec->y = y;
- }
-
-
- static void
- ft_trig_pseudo_polarize( FT_Vector* vec )
- {
- FT_Angle theta;
- FT_Int i;
- FT_Fixed x, y, xtemp, b;
- const FT_Angle *arctanptr;
-
-
- x = vec->x;
- y = vec->y;
-
- /* Get the vector into [-PI/4,PI/4] sector */
- if ( y > x )
- {
- if ( y > -x )
- {
- theta = FT_ANGLE_PI2;
- xtemp = y;
- y = -x;
- x = xtemp;
- }
- else
- {
- theta = y > 0 ? FT_ANGLE_PI : -FT_ANGLE_PI;
- x = -x;
- y = -y;
- }
- }
- else
- {
- if ( y < -x )
- {
- theta = -FT_ANGLE_PI2;
- xtemp = -y;
- y = x;
- x = xtemp;
- }
- else
- {
- theta = 0;
- }
- }
-
- arctanptr = ft_trig_arctan_table;
-
- /* Pseudorotations, with right shifts */
- for ( i = 1, b = 1; i < FT_TRIG_MAX_ITERS; b <<= 1, i++ )
- {
- if ( y > 0 )
- {
- xtemp = x + ( ( y + b ) >> i );
- y = y - ( ( x + b ) >> i );
- x = xtemp;
- theta += *arctanptr++;
- }
- else
- {
- xtemp = x - ( ( y + b ) >> i );
- y = y + ( ( x + b ) >> i );
- x = xtemp;
- theta -= *arctanptr++;
- }
- }
-
- /* round theta to acknowledge its error that mostly comes */
- /* from accumulated rounding errors in the arctan table */
- if ( theta >= 0 )
- theta = FT_PAD_ROUND( theta, 16 );
- else
- theta = -FT_PAD_ROUND( -theta, 16 );
-
- vec->x = x;
- vec->y = theta;
- }
-
-
- /* documentation is in fttrigon.h */
-
- FT_EXPORT_DEF( FT_Fixed )
- FT_Cos( FT_Angle angle )
- {
- FT_Vector v;
-
-
- FT_Vector_Unit( &v, angle );
-
- return v.x;
- }
-
-
- /* documentation is in fttrigon.h */
-
- FT_EXPORT_DEF( FT_Fixed )
- FT_Sin( FT_Angle angle )
- {
- FT_Vector v;
-
-
- FT_Vector_Unit( &v, angle );
-
- return v.y;
- }
-
-
- /* documentation is in fttrigon.h */
-
- FT_EXPORT_DEF( FT_Fixed )
- FT_Tan( FT_Angle angle )
- {
- FT_Vector v = { 1 << 24, 0 };
-
-
- ft_trig_pseudo_rotate( &v, angle );
-
- return FT_DivFix( v.y, v.x );
- }
-
-
- /* documentation is in fttrigon.h */
-
- FT_EXPORT_DEF( FT_Angle )
- FT_Atan2( FT_Fixed dx,
- FT_Fixed dy )
- {
- FT_Vector v;
-
-
- if ( dx == 0 && dy == 0 )
- return 0;
-
- v.x = dx;
- v.y = dy;
- ft_trig_prenorm( &v );
- ft_trig_pseudo_polarize( &v );
-
- return v.y;
- }
-
-
- /* documentation is in fttrigon.h */
-
- FT_EXPORT_DEF( void )
- FT_Vector_Unit( FT_Vector* vec,
- FT_Angle angle )
- {
- if ( !vec )
- return;
-
- vec->x = FT_TRIG_SCALE >> 8;
- vec->y = 0;
- ft_trig_pseudo_rotate( vec, angle );
- vec->x = ( vec->x + 0x80L ) >> 8;
- vec->y = ( vec->y + 0x80L ) >> 8;
- }
-
-
- /* documentation is in fttrigon.h */
-
- FT_EXPORT_DEF( void )
- FT_Vector_Rotate( FT_Vector* vec,
- FT_Angle angle )
- {
- FT_Int shift;
- FT_Vector v;
-
-
- if ( !vec || !angle )
- return;
-
- v = *vec;
-
- if ( v.x == 0 && v.y == 0 )
- return;
-
- shift = ft_trig_prenorm( &v );
- ft_trig_pseudo_rotate( &v, angle );
- v.x = ft_trig_downscale( v.x );
- v.y = ft_trig_downscale( v.y );
-
- if ( shift > 0 )
- {
- FT_Int32 half = (FT_Int32)1L << ( shift - 1 );
-
-
- vec->x = ( v.x + half - ( v.x < 0 ) ) >> shift;
- vec->y = ( v.y + half - ( v.y < 0 ) ) >> shift;
- }
- else
- {
- shift = -shift;
- vec->x = (FT_Pos)( (FT_ULong)v.x << shift );
- vec->y = (FT_Pos)( (FT_ULong)v.y << shift );
- }
- }
-
-
- /* documentation is in fttrigon.h */
-
- FT_EXPORT_DEF( FT_Fixed )
- FT_Vector_Length( FT_Vector* vec )
- {
- FT_Int shift;
- FT_Vector v;
-
-
- if ( !vec )
- return 0;
-
- v = *vec;
-
- /* handle trivial cases */
- if ( v.x == 0 )
- {
- return FT_ABS( v.y );
- }
- else if ( v.y == 0 )
- {
- return FT_ABS( v.x );
- }
-
- /* general case */
- shift = ft_trig_prenorm( &v );
- ft_trig_pseudo_polarize( &v );
-
- v.x = ft_trig_downscale( v.x );
-
- if ( shift > 0 )
- return ( v.x + ( 1L << ( shift - 1 ) ) ) >> shift;
-
- return (FT_Fixed)( (FT_UInt32)v.x << -shift );
- }
-
-
- /* documentation is in fttrigon.h */
-
- FT_EXPORT_DEF( void )
- FT_Vector_Polarize( FT_Vector* vec,
- FT_Fixed *length,
- FT_Angle *angle )
- {
- FT_Int shift;
- FT_Vector v;
-
-
- if ( !vec || !length || !angle )
- return;
-
- v = *vec;
-
- if ( v.x == 0 && v.y == 0 )
- return;
-
- shift = ft_trig_prenorm( &v );
- ft_trig_pseudo_polarize( &v );
-
- v.x = ft_trig_downscale( v.x );
-
- *length = shift >= 0 ? ( v.x >> shift )
- : (FT_Fixed)( (FT_UInt32)v.x << -shift );
- *angle = v.y;
- }
-
-
- /* documentation is in fttrigon.h */
-
- FT_EXPORT_DEF( void )
- FT_Vector_From_Polar( FT_Vector* vec,
- FT_Fixed length,
- FT_Angle angle )
- {
- if ( !vec )
- return;
-
- vec->x = length;
- vec->y = 0;
-
- FT_Vector_Rotate( vec, angle );
- }
-
-
- /* documentation is in fttrigon.h */
-
- FT_EXPORT_DEF( FT_Angle )
- FT_Angle_Diff( FT_Angle angle1,
- FT_Angle angle2 )
- {
- FT_Angle delta = angle2 - angle1;
-
-
- while ( delta <= -FT_ANGLE_PI )
- delta += FT_ANGLE_2PI;
-
- while ( delta > FT_ANGLE_PI )
- delta -= FT_ANGLE_2PI;
-
- return delta;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/base/fttype1.c b/contrib/libs/freetype/src/base/fttype1.c
deleted file mode 100644
index cedf7c4050..0000000000
--- a/contrib/libs/freetype/src/base/fttype1.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/****************************************************************************
- *
- * fttype1.c
- *
- * FreeType utility file for PS names support (body).
- *
- * Copyright (C) 2002-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/ftserv.h>
-#include <freetype/internal/services/svpsinfo.h>
-
-
- /* documentation is in t1tables.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Get_PS_Font_Info( FT_Face face,
- PS_FontInfoRec* afont_info )
- {
- FT_Error error;
- FT_Service_PsInfo service;
-
-
- if ( !face )
- return FT_THROW( Invalid_Face_Handle );
-
- if ( !afont_info )
- return FT_THROW( Invalid_Argument );
-
- FT_FACE_FIND_SERVICE( face, service, POSTSCRIPT_INFO );
-
- if ( service && service->ps_get_font_info )
- error = service->ps_get_font_info( face, afont_info );
- else
- error = FT_THROW( Invalid_Argument );
-
- return error;
- }
-
-
- /* documentation is in t1tables.h */
-
- FT_EXPORT_DEF( FT_Int )
- FT_Has_PS_Glyph_Names( FT_Face face )
- {
- FT_Int result = 0;
- FT_Service_PsInfo service;
-
-
- if ( face )
- {
- FT_FACE_FIND_SERVICE( face, service, POSTSCRIPT_INFO );
-
- if ( service && service->ps_has_glyph_names )
- result = service->ps_has_glyph_names( face );
- }
-
- return result;
- }
-
-
- /* documentation is in t1tables.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Get_PS_Font_Private( FT_Face face,
- PS_PrivateRec* afont_private )
- {
- FT_Error error;
- FT_Service_PsInfo service;
-
-
- if ( !face )
- return FT_THROW( Invalid_Face_Handle );
-
- if ( !afont_private )
- return FT_THROW( Invalid_Argument );
-
- FT_FACE_FIND_SERVICE( face, service, POSTSCRIPT_INFO );
-
- if ( service && service->ps_get_font_private )
- error = service->ps_get_font_private( face, afont_private );
- else
- error = FT_THROW( Invalid_Argument );
-
- return error;
- }
-
-
- /* documentation is in t1tables.h */
-
- FT_EXPORT_DEF( FT_Long )
- FT_Get_PS_Font_Value( FT_Face face,
- PS_Dict_Keys key,
- FT_UInt idx,
- void *value,
- FT_Long value_len )
- {
- FT_Int result = 0;
- FT_Service_PsInfo service = NULL;
-
-
- if ( face )
- {
- FT_FACE_FIND_SERVICE( face, service, POSTSCRIPT_INFO );
-
- if ( service && service->ps_get_font_value )
- result = service->ps_get_font_value( face, key, idx,
- value, value_len );
- }
-
- return result;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/base/ftutil.c b/contrib/libs/freetype/src/base/ftutil.c
deleted file mode 100644
index b13512f870..0000000000
--- a/contrib/libs/freetype/src/base/ftutil.c
+++ /dev/null
@@ -1,442 +0,0 @@
-/****************************************************************************
- *
- * ftutil.c
- *
- * FreeType utility file for memory and list management (body).
- *
- * Copyright (C) 2002-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftmemory.h>
-#include <freetype/internal/ftobjs.h>
-#include <freetype/ftlist.h>
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT memory
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** *****/
- /***** M E M O R Y M A N A G E M E N T *****/
- /***** *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
- FT_BASE_DEF( FT_Pointer )
- ft_mem_alloc( FT_Memory memory,
- FT_Long size,
- FT_Error *p_error )
- {
- FT_Error error;
- FT_Pointer block = ft_mem_qalloc( memory, size, &error );
-
- if ( !error && block && size > 0 )
- FT_MEM_ZERO( block, size );
-
- *p_error = error;
- return block;
- }
-
-
- FT_BASE_DEF( FT_Pointer )
- ft_mem_qalloc( FT_Memory memory,
- FT_Long size,
- FT_Error *p_error )
- {
- FT_Error error = FT_Err_Ok;
- FT_Pointer block = NULL;
-
-
- if ( size > 0 )
- {
- block = memory->alloc( memory, size );
- if ( !block )
- error = FT_THROW( Out_Of_Memory );
- }
- else if ( size < 0 )
- {
- /* may help catch/prevent security issues */
- error = FT_THROW( Invalid_Argument );
- }
-
- *p_error = error;
- return block;
- }
-
-
- FT_BASE_DEF( FT_Pointer )
- ft_mem_realloc( FT_Memory memory,
- FT_Long item_size,
- FT_Long cur_count,
- FT_Long new_count,
- void* block,
- FT_Error *p_error )
- {
- FT_Error error = FT_Err_Ok;
-
-
- block = ft_mem_qrealloc( memory, item_size,
- cur_count, new_count, block, &error );
- if ( !error && block && new_count > cur_count )
- FT_MEM_ZERO( (char*)block + cur_count * item_size,
- ( new_count - cur_count ) * item_size );
-
- *p_error = error;
- return block;
- }
-
-
- FT_BASE_DEF( FT_Pointer )
- ft_mem_qrealloc( FT_Memory memory,
- FT_Long item_size,
- FT_Long cur_count,
- FT_Long new_count,
- void* block,
- FT_Error *p_error )
- {
- FT_Error error = FT_Err_Ok;
-
-
- /* Note that we now accept `item_size == 0' as a valid parameter, in
- * order to cover very weird cases where an ALLOC_MULT macro would be
- * called.
- */
- if ( cur_count < 0 || new_count < 0 || item_size < 0 )
- {
- /* may help catch/prevent nasty security issues */
- error = FT_THROW( Invalid_Argument );
- }
- else if ( new_count == 0 || item_size == 0 )
- {
- ft_mem_free( memory, block );
- block = NULL;
- }
- else if ( new_count > FT_INT_MAX / item_size )
- {
- error = FT_THROW( Array_Too_Large );
- }
- else if ( cur_count == 0 )
- {
- FT_ASSERT( !block );
-
- block = memory->alloc( memory, new_count * item_size );
- if ( block == NULL )
- error = FT_THROW( Out_Of_Memory );
- }
- else
- {
- FT_Pointer block2;
- FT_Long cur_size = cur_count * item_size;
- FT_Long new_size = new_count * item_size;
-
-
- block2 = memory->realloc( memory, cur_size, new_size, block );
- if ( !block2 )
- error = FT_THROW( Out_Of_Memory );
- else
- block = block2;
- }
-
- *p_error = error;
- return block;
- }
-
-
- FT_BASE_DEF( void )
- ft_mem_free( FT_Memory memory,
- const void *P )
- {
- if ( P )
- memory->free( memory, (void*)P );
- }
-
-
- FT_BASE_DEF( FT_Pointer )
- ft_mem_dup( FT_Memory memory,
- const void* address,
- FT_ULong size,
- FT_Error *p_error )
- {
- FT_Error error;
- FT_Pointer p = ft_mem_qalloc( memory, (FT_Long)size, &error );
-
-
- if ( !error && address && size > 0 )
- ft_memcpy( p, address, size );
-
- *p_error = error;
- return p;
- }
-
-
- FT_BASE_DEF( FT_Pointer )
- ft_mem_strdup( FT_Memory memory,
- const char* str,
- FT_Error *p_error )
- {
- FT_ULong len = str ? (FT_ULong)ft_strlen( str ) + 1
- : 0;
-
-
- return ft_mem_dup( memory, str, len, p_error );
- }
-
-
- FT_BASE_DEF( FT_Int )
- ft_mem_strcpyn( char* dst,
- const char* src,
- FT_ULong size )
- {
- while ( size > 1 && *src != 0 )
- {
- *dst++ = *src++;
- size--;
- }
-
- *dst = 0; /* always zero-terminate */
-
- return *src != 0;
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** *****/
- /***** D O U B L Y L I N K E D L I S T S *****/
- /***** *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-#undef FT_COMPONENT
-#define FT_COMPONENT list
-
- /* documentation is in ftlist.h */
-
- FT_EXPORT_DEF( FT_ListNode )
- FT_List_Find( FT_List list,
- void* data )
- {
- FT_ListNode cur;
-
-
- if ( !list )
- return NULL;
-
- cur = list->head;
- while ( cur )
- {
- if ( cur->data == data )
- return cur;
-
- cur = cur->next;
- }
-
- return NULL;
- }
-
-
- /* documentation is in ftlist.h */
-
- FT_EXPORT_DEF( void )
- FT_List_Add( FT_List list,
- FT_ListNode node )
- {
- FT_ListNode before;
-
-
- if ( !list || !node )
- return;
-
- before = list->tail;
-
- node->next = NULL;
- node->prev = before;
-
- if ( before )
- before->next = node;
- else
- list->head = node;
-
- list->tail = node;
- }
-
-
- /* documentation is in ftlist.h */
-
- FT_EXPORT_DEF( void )
- FT_List_Insert( FT_List list,
- FT_ListNode node )
- {
- FT_ListNode after;
-
-
- if ( !list || !node )
- return;
-
- after = list->head;
-
- node->next = after;
- node->prev = NULL;
-
- if ( !after )
- list->tail = node;
- else
- after->prev = node;
-
- list->head = node;
- }
-
-
- /* documentation is in ftlist.h */
-
- FT_EXPORT_DEF( void )
- FT_List_Remove( FT_List list,
- FT_ListNode node )
- {
- FT_ListNode before, after;
-
-
- if ( !list || !node )
- return;
-
- before = node->prev;
- after = node->next;
-
- if ( before )
- before->next = after;
- else
- list->head = after;
-
- if ( after )
- after->prev = before;
- else
- list->tail = before;
- }
-
-
- /* documentation is in ftlist.h */
-
- FT_EXPORT_DEF( void )
- FT_List_Up( FT_List list,
- FT_ListNode node )
- {
- FT_ListNode before, after;
-
-
- if ( !list || !node )
- return;
-
- before = node->prev;
- after = node->next;
-
- /* check whether we are already on top of the list */
- if ( !before )
- return;
-
- before->next = after;
-
- if ( after )
- after->prev = before;
- else
- list->tail = before;
-
- node->prev = NULL;
- node->next = list->head;
- list->head->prev = node;
- list->head = node;
- }
-
-
- /* documentation is in ftlist.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_List_Iterate( FT_List list,
- FT_List_Iterator iterator,
- void* user )
- {
- FT_ListNode cur;
- FT_Error error = FT_Err_Ok;
-
-
- if ( !list || !iterator )
- return FT_THROW( Invalid_Argument );
-
- cur = list->head;
-
- while ( cur )
- {
- FT_ListNode next = cur->next;
-
-
- error = iterator( cur, user );
- if ( error )
- break;
-
- cur = next;
- }
-
- return error;
- }
-
-
- /* documentation is in ftlist.h */
-
- FT_EXPORT_DEF( void )
- FT_List_Finalize( FT_List list,
- FT_List_Destructor destroy,
- FT_Memory memory,
- void* user )
- {
- FT_ListNode cur;
-
-
- if ( !list || !memory )
- return;
-
- cur = list->head;
- while ( cur )
- {
- FT_ListNode next = cur->next;
- void* data = cur->data;
-
-
- if ( destroy )
- destroy( memory, data, user );
-
- FT_FREE( cur );
- cur = next;
- }
-
- list->head = NULL;
- list->tail = NULL;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/base/ftwinfnt.c b/contrib/libs/freetype/src/base/ftwinfnt.c
deleted file mode 100644
index e849a15f42..0000000000
--- a/contrib/libs/freetype/src/base/ftwinfnt.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/****************************************************************************
- *
- * ftwinfnt.c
- *
- * FreeType API for accessing Windows FNT specific info (body).
- *
- * Copyright (C) 2003-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftdebug.h>
-#include <freetype/ftwinfnt.h>
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/services/svwinfnt.h>
-
-
- /* documentation is in ftwinfnt.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Get_WinFNT_Header( FT_Face face,
- FT_WinFNT_HeaderRec *header )
- {
- FT_Service_WinFnt service;
- FT_Error error;
-
-
- if ( !face )
- return FT_THROW( Invalid_Face_Handle );
-
- if ( !header )
- return FT_THROW( Invalid_Argument );
-
- FT_FACE_LOOKUP_SERVICE( face, service, WINFNT );
-
- if ( service )
- error = service->get_header( face, header );
- else
- error = FT_THROW( Invalid_Argument );
-
- return error;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/base/md5.c b/contrib/libs/freetype/src/base/md5.c
deleted file mode 100644
index b235e17a56..0000000000
--- a/contrib/libs/freetype/src/base/md5.c
+++ /dev/null
@@ -1,291 +0,0 @@
-/*
- * This is an OpenSSL-compatible implementation of the RSA Data Security, Inc.
- * MD5 Message-Digest Algorithm (RFC 1321).
- *
- * Homepage:
- * http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5
- *
- * Author:
- * Alexander Peslyak, better known as Solar Designer <solar at openwall.com>
- *
- * This software was written by Alexander Peslyak in 2001. No copyright is
- * claimed, and the software is hereby placed in the public domain.
- * In case this attempt to disclaim copyright and place the software in the
- * public domain is deemed null and void, then the software is
- * Copyright (c) 2001 Alexander Peslyak and it is hereby released to the
- * general public under the following terms:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted.
- *
- * There's ABSOLUTELY NO WARRANTY, express or implied.
- *
- * (This is a heavily cut-down "BSD license".)
- *
- * This differs from Colin Plumb's older public domain implementation in that
- * no exactly 32-bit integer data type is required (any 32-bit or wider
- * unsigned integer data type will do), there's no compile-time endianness
- * configuration, and the function prototypes match OpenSSL's. No code from
- * Colin Plumb's implementation has been reused; this comment merely compares
- * the properties of the two independent implementations.
- *
- * The primary goals of this implementation are portability and ease of use.
- * It is meant to be fast, but not as fast as possible. Some known
- * optimizations are not included to reduce source code size and avoid
- * compile-time configuration.
- */
-
-#ifndef HAVE_OPENSSL
-
-#include <string.h>
-
-#include "md5.h"
-
-/*
- * The basic MD5 functions.
- *
- * F and G are optimized compared to their RFC 1321 definitions for
- * architectures that lack an AND-NOT instruction, just like in Colin Plumb's
- * implementation.
- */
-#define F(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
-#define G(x, y, z) ((y) ^ ((z) & ((x) ^ (y))))
-#define H(x, y, z) (((x) ^ (y)) ^ (z))
-#define H2(x, y, z) ((x) ^ ((y) ^ (z)))
-#define I(x, y, z) ((y) ^ ((x) | ~(z)))
-
-/*
- * The MD5 transformation for all four rounds.
- */
-#define STEP(f, a, b, c, d, x, t, s) \
- (a) += f((b), (c), (d)) + (x) + (t); \
- (a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s)))); \
- (a) += (b);
-
-/*
- * SET reads 4 input bytes in little-endian byte order and stores them in a
- * properly aligned word in host byte order.
- *
- * The check for little-endian architectures that tolerate unaligned memory
- * accesses is just an optimization. Nothing will break if it fails to detect
- * a suitable architecture.
- *
- * Unfortunately, this optimization may be a C strict aliasing rules violation
- * if the caller's data buffer has effective type that cannot be aliased by
- * MD5_u32plus. In practice, this problem may occur if these MD5 routines are
- * inlined into a calling function, or with future and dangerously advanced
- * link-time optimizations. For the time being, keeping these MD5 routines in
- * their own translation unit avoids the problem.
- */
-#if defined(__i386__) || defined(__x86_64__) || defined(__vax__)
-#define SET(n) \
- (*(MD5_u32plus *)&ptr[(n) * 4])
-#define GET(n) \
- SET(n)
-#else
-#define SET(n) \
- (ctx->block[(n)] = \
- (MD5_u32plus)ptr[(n) * 4] | \
- ((MD5_u32plus)ptr[(n) * 4 + 1] << 8) | \
- ((MD5_u32plus)ptr[(n) * 4 + 2] << 16) | \
- ((MD5_u32plus)ptr[(n) * 4 + 3] << 24))
-#define GET(n) \
- (ctx->block[(n)])
-#endif
-
-/*
- * This processes one or more 64-byte data blocks, but does NOT update the bit
- * counters. There are no alignment requirements.
- */
-static const void *body(MD5_CTX *ctx, const void *data, unsigned long size)
-{
- const unsigned char *ptr;
- MD5_u32plus a, b, c, d;
- MD5_u32plus saved_a, saved_b, saved_c, saved_d;
-
- ptr = (const unsigned char *)data;
-
- a = ctx->a;
- b = ctx->b;
- c = ctx->c;
- d = ctx->d;
-
- do {
- saved_a = a;
- saved_b = b;
- saved_c = c;
- saved_d = d;
-
-/* Round 1 */
- STEP(F, a, b, c, d, SET(0), 0xd76aa478, 7)
- STEP(F, d, a, b, c, SET(1), 0xe8c7b756, 12)
- STEP(F, c, d, a, b, SET(2), 0x242070db, 17)
- STEP(F, b, c, d, a, SET(3), 0xc1bdceee, 22)
- STEP(F, a, b, c, d, SET(4), 0xf57c0faf, 7)
- STEP(F, d, a, b, c, SET(5), 0x4787c62a, 12)
- STEP(F, c, d, a, b, SET(6), 0xa8304613, 17)
- STEP(F, b, c, d, a, SET(7), 0xfd469501, 22)
- STEP(F, a, b, c, d, SET(8), 0x698098d8, 7)
- STEP(F, d, a, b, c, SET(9), 0x8b44f7af, 12)
- STEP(F, c, d, a, b, SET(10), 0xffff5bb1, 17)
- STEP(F, b, c, d, a, SET(11), 0x895cd7be, 22)
- STEP(F, a, b, c, d, SET(12), 0x6b901122, 7)
- STEP(F, d, a, b, c, SET(13), 0xfd987193, 12)
- STEP(F, c, d, a, b, SET(14), 0xa679438e, 17)
- STEP(F, b, c, d, a, SET(15), 0x49b40821, 22)
-
-/* Round 2 */
- STEP(G, a, b, c, d, GET(1), 0xf61e2562, 5)
- STEP(G, d, a, b, c, GET(6), 0xc040b340, 9)
- STEP(G, c, d, a, b, GET(11), 0x265e5a51, 14)
- STEP(G, b, c, d, a, GET(0), 0xe9b6c7aa, 20)
- STEP(G, a, b, c, d, GET(5), 0xd62f105d, 5)
- STEP(G, d, a, b, c, GET(10), 0x02441453, 9)
- STEP(G, c, d, a, b, GET(15), 0xd8a1e681, 14)
- STEP(G, b, c, d, a, GET(4), 0xe7d3fbc8, 20)
- STEP(G, a, b, c, d, GET(9), 0x21e1cde6, 5)
- STEP(G, d, a, b, c, GET(14), 0xc33707d6, 9)
- STEP(G, c, d, a, b, GET(3), 0xf4d50d87, 14)
- STEP(G, b, c, d, a, GET(8), 0x455a14ed, 20)
- STEP(G, a, b, c, d, GET(13), 0xa9e3e905, 5)
- STEP(G, d, a, b, c, GET(2), 0xfcefa3f8, 9)
- STEP(G, c, d, a, b, GET(7), 0x676f02d9, 14)
- STEP(G, b, c, d, a, GET(12), 0x8d2a4c8a, 20)
-
-/* Round 3 */
- STEP(H, a, b, c, d, GET(5), 0xfffa3942, 4)
- STEP(H2, d, a, b, c, GET(8), 0x8771f681, 11)
- STEP(H, c, d, a, b, GET(11), 0x6d9d6122, 16)
- STEP(H2, b, c, d, a, GET(14), 0xfde5380c, 23)
- STEP(H, a, b, c, d, GET(1), 0xa4beea44, 4)
- STEP(H2, d, a, b, c, GET(4), 0x4bdecfa9, 11)
- STEP(H, c, d, a, b, GET(7), 0xf6bb4b60, 16)
- STEP(H2, b, c, d, a, GET(10), 0xbebfbc70, 23)
- STEP(H, a, b, c, d, GET(13), 0x289b7ec6, 4)
- STEP(H2, d, a, b, c, GET(0), 0xeaa127fa, 11)
- STEP(H, c, d, a, b, GET(3), 0xd4ef3085, 16)
- STEP(H2, b, c, d, a, GET(6), 0x04881d05, 23)
- STEP(H, a, b, c, d, GET(9), 0xd9d4d039, 4)
- STEP(H2, d, a, b, c, GET(12), 0xe6db99e5, 11)
- STEP(H, c, d, a, b, GET(15), 0x1fa27cf8, 16)
- STEP(H2, b, c, d, a, GET(2), 0xc4ac5665, 23)
-
-/* Round 4 */
- STEP(I, a, b, c, d, GET(0), 0xf4292244, 6)
- STEP(I, d, a, b, c, GET(7), 0x432aff97, 10)
- STEP(I, c, d, a, b, GET(14), 0xab9423a7, 15)
- STEP(I, b, c, d, a, GET(5), 0xfc93a039, 21)
- STEP(I, a, b, c, d, GET(12), 0x655b59c3, 6)
- STEP(I, d, a, b, c, GET(3), 0x8f0ccc92, 10)
- STEP(I, c, d, a, b, GET(10), 0xffeff47d, 15)
- STEP(I, b, c, d, a, GET(1), 0x85845dd1, 21)
- STEP(I, a, b, c, d, GET(8), 0x6fa87e4f, 6)
- STEP(I, d, a, b, c, GET(15), 0xfe2ce6e0, 10)
- STEP(I, c, d, a, b, GET(6), 0xa3014314, 15)
- STEP(I, b, c, d, a, GET(13), 0x4e0811a1, 21)
- STEP(I, a, b, c, d, GET(4), 0xf7537e82, 6)
- STEP(I, d, a, b, c, GET(11), 0xbd3af235, 10)
- STEP(I, c, d, a, b, GET(2), 0x2ad7d2bb, 15)
- STEP(I, b, c, d, a, GET(9), 0xeb86d391, 21)
-
- a += saved_a;
- b += saved_b;
- c += saved_c;
- d += saved_d;
-
- ptr += 64;
- } while (size -= 64);
-
- ctx->a = a;
- ctx->b = b;
- ctx->c = c;
- ctx->d = d;
-
- return ptr;
-}
-
-void MD5_Init(MD5_CTX *ctx)
-{
- ctx->a = 0x67452301;
- ctx->b = 0xefcdab89;
- ctx->c = 0x98badcfe;
- ctx->d = 0x10325476;
-
- ctx->lo = 0;
- ctx->hi = 0;
-}
-
-void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size)
-{
- MD5_u32plus saved_lo;
- unsigned long used, available;
-
- saved_lo = ctx->lo;
- if ((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo)
- ctx->hi++;
- ctx->hi += size >> 29;
-
- used = saved_lo & 0x3f;
-
- if (used) {
- available = 64 - used;
-
- if (size < available) {
- memcpy(&ctx->buffer[used], data, size);
- return;
- }
-
- memcpy(&ctx->buffer[used], data, available);
- data = (const unsigned char *)data + available;
- size -= available;
- body(ctx, ctx->buffer, 64);
- }
-
- if (size >= 64) {
- data = body(ctx, data, size & ~(unsigned long)0x3f);
- size &= 0x3f;
- }
-
- memcpy(ctx->buffer, data, size);
-}
-
-#define OUT(dst, src) \
- (dst)[0] = (unsigned char)(src); \
- (dst)[1] = (unsigned char)((src) >> 8); \
- (dst)[2] = (unsigned char)((src) >> 16); \
- (dst)[3] = (unsigned char)((src) >> 24);
-
-void MD5_Final(unsigned char *result, MD5_CTX *ctx)
-{
- unsigned long used, available;
-
- used = ctx->lo & 0x3f;
-
- ctx->buffer[used++] = 0x80;
-
- available = 64 - used;
-
- if (available < 8) {
- memset(&ctx->buffer[used], 0, available);
- body(ctx, ctx->buffer, 64);
- used = 0;
- available = 64;
- }
-
- memset(&ctx->buffer[used], 0, available - 8);
-
- ctx->lo <<= 3;
- OUT(&ctx->buffer[56], ctx->lo)
- OUT(&ctx->buffer[60], ctx->hi)
-
- body(ctx, ctx->buffer, 64);
-
- OUT(&result[0], ctx->a)
- OUT(&result[4], ctx->b)
- OUT(&result[8], ctx->c)
- OUT(&result[12], ctx->d)
-
- memset(ctx, 0, sizeof(*ctx));
-}
-
-#endif
diff --git a/contrib/libs/freetype/src/base/md5.h b/contrib/libs/freetype/src/base/md5.h
deleted file mode 100644
index 31f0c452ef..0000000000
--- a/contrib/libs/freetype/src/base/md5.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * This is an OpenSSL-compatible implementation of the RSA Data Security, Inc.
- * MD5 Message-Digest Algorithm (RFC 1321).
- *
- * Homepage:
- * http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5
- *
- * Author:
- * Alexander Peslyak, better known as Solar Designer <solar at openwall.com>
- *
- * This software was written by Alexander Peslyak in 2001. No copyright is
- * claimed, and the software is hereby placed in the public domain.
- * In case this attempt to disclaim copyright and place the software in the
- * public domain is deemed null and void, then the software is
- * Copyright (c) 2001 Alexander Peslyak and it is hereby released to the
- * general public under the following terms:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted.
- *
- * There's ABSOLUTELY NO WARRANTY, express or implied.
- *
- * See md5.c for more information.
- */
-
-#ifdef HAVE_OPENSSL
-#error #include <openssl/md5.h>
-#elif !defined(_MD5_H)
-#define _MD5_H
-
-/* Any 32-bit or wider unsigned integer data type will do */
-typedef unsigned int MD5_u32plus;
-
-typedef struct {
- MD5_u32plus lo, hi;
- MD5_u32plus a, b, c, d;
- unsigned char buffer[64];
- MD5_u32plus block[16];
-} MD5_CTX;
-
-extern void MD5_Init(MD5_CTX *ctx);
-extern void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size);
-extern void MD5_Final(unsigned char *result, MD5_CTX *ctx);
-
-#endif
diff --git a/contrib/libs/freetype/src/bdf/README b/contrib/libs/freetype/src/bdf/README
deleted file mode 100644
index d7cb8c14ef..0000000000
--- a/contrib/libs/freetype/src/bdf/README
+++ /dev/null
@@ -1,152 +0,0 @@
- FreeType font driver for BDF fonts
-
- Francesco Zappa Nardelli
- <francesco.zappa.nardelli@ens.fr>
-
-
-Introduction
-************
-
-BDF (Bitmap Distribution Format) is a bitmap font format defined by Adobe,
-which is intended to be easily understood by both humans and computers.
-This code implements a BDF driver for the FreeType library, following the
-Adobe Specification V 2.2. The specification of the BDF font format is
-available from Adobe's web site:
-
- https://adobe-type-tools.github.io/font-tech-notes/pdfs/5005.BDF_Spec.pdf
-
-Many good bitmap fonts in bdf format come with XFree86 (www.XFree86.org).
-They do not define vertical metrics, because the X Consortium BDF
-specification has removed them.
-
-
-Encodings
-*********
-
-[This section is out of date, retained for historical reasons. BDF
- properties can be retrieved with `FT_Get_BDF_Property`, character set ID
- values with `FT_Get_BDF_Charset_ID`.]
-
-The variety of encodings that accompanies bdf fonts appears to encompass the
-small set defined in freetype.h. On the other hand, two properties that
-specify encoding and registry are usually defined in bdf fonts.
-
-I decided to make these two properties directly accessible, leaving to the
-client application the work of interpreting them. For instance:
-
-
- #include FT_INTERNAL_BDF_TYPES_H
-
- FT_Face face;
- BDF_Public_Face bdfface;
-
-
- FT_New_Face( library, ..., &face );
-
- bdfface = (BDF_Public_Face)face;
-
- if ( ( bdfface->charset_registry == "ISO10646" ) &&
- ( bdfface->charset_encoding == "1" ) )
- [..]
-
-
-Thus the driver always exports `ft_encoding_none' as face->charmap.encoding.
-FT_Get_Char_Index's behavior is unmodified, that is, it converts the ULong
-value given as argument into the corresponding glyph number.
-
-If the two properties are not available, Adobe Standard Encoding should be
-assumed.
-
-
-Anti-Aliased Bitmaps
-********************
-
-The driver supports an extension to the BDF format as used in Mark Leisher's
-xmbdfed bitmap font editor. Microsoft's SBIT tool expects bitmap fonts in
-that format for adding anti-aliased them to TrueType fonts. It introduces a
-fourth field to the `SIZE' keyword which gives the bpp value (bits per
-pixel) of the glyph data in the font. Possible values are 1 (the default),
-2 (four gray levels), 4 (16 gray levels), and 8 (256 gray levels). The
-driver returns either a bitmap with 1 bit per pixel or a pixmap with 8bits
-per pixel (using 4, 16, and 256 gray levels, respectively).
-
-
-Known problems
-**************
-
-- A font is entirely loaded into memory. Obviously, this is not the Right
- Thing(TM). If you have big fonts I suggest you convert them into PCF
- format (using the bdftopcf utility): the PCF font drive of FreeType can
- perform incremental glyph loading.
-
-When I have some time, I will implement on-demand glyph parsing.
-
-- Except for encodings properties, client applications have no visibility of
- the PCF_Face object. This means that applications cannot directly access
- font tables and must trust FreeType.
-
-- Currently, glyph names are ignored.
-
- I plan to give full visibility of the BDF_Face object in an upcoming
- revision of the driver, thus implementing also glyph names.
-
-- As I have never seen a BDF font that defines vertical metrics, vertical
- metrics are (parsed and) discarded. If you own a BDF font that defines
- vertical metrics, please let me know (I will implement them in 5-10
- minutes).
-
-
-License
-*******
-
-Copyright (C) 2001-2002 by Francesco Zappa Nardelli
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-*** Portions of the driver (that is, bdflib.c and bdf.h):
-
-Copyright 2000 Computing Research Labs, New Mexico State University
-Copyright 2001-2002, 2011 Francesco Zappa Nardelli
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the "Software"),
-to deal in the Software without restriction, including without limitation
-the rights to use, copy, modify, merge, publish, distribute, sublicense,
-and/or sell copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-THE COMPUTING RESEARCH LAB OR NEW MEXICO STATE UNIVERSITY BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
-OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
-THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-
-Credits
-*******
-
-This driver is based on excellent Mark Leisher's bdf library. If you
-find something good in this driver you should probably thank him, not
-me.
diff --git a/contrib/libs/freetype/src/bdf/bdf.c b/contrib/libs/freetype/src/bdf/bdf.c
deleted file mode 100644
index 249012e590..0000000000
--- a/contrib/libs/freetype/src/bdf/bdf.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/* bdf.c
-
- FreeType font driver for bdf files
-
- Copyright (C) 2001, 2002 by
- Francesco Zappa Nardelli
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-*/
-
-
-#define FT_MAKE_OPTION_SINGLE_OBJECT
-
-#include "bdflib.c"
-#include "bdfdrivr.c"
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/bdf/bdf.h b/contrib/libs/freetype/src/bdf/bdf.h
deleted file mode 100644
index e2cb52c10a..0000000000
--- a/contrib/libs/freetype/src/bdf/bdf.h
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- * Copyright 2000 Computing Research Labs, New Mexico State University
- * Copyright 2001-2004, 2011 Francesco Zappa Nardelli
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COMPUTING RESEARCH LAB OR NEW MEXICO STATE UNIVERSITY BE LIABLE FOR ANY
- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
- * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
- * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-
-#ifndef BDF_H_
-#define BDF_H_
-
-
-/*
- * Based on bdf.h,v 1.16 2000/03/16 20:08:51 mleisher
- */
-
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/internal/fthash.h>
-
-
-FT_BEGIN_HEADER
-
-
-/* Imported from bdfP.h */
-
-#define _bdf_glyph_modified( map, e ) \
- ( (map)[(e) >> 5] & ( 1UL << ( (e) & 31 ) ) )
-#define _bdf_set_glyph_modified( map, e ) \
- ( (map)[(e) >> 5] |= ( 1UL << ( (e) & 31 ) ) )
-#define _bdf_clear_glyph_modified( map, e ) \
- ( (map)[(e) >> 5] &= ~( 1UL << ( (e) & 31 ) ) )
-
-/* end of bdfP.h */
-
-
- /**************************************************************************
- *
- * BDF font options macros and types.
- *
- */
-
-
-#define BDF_CORRECT_METRICS 0x01 /* Correct invalid metrics when loading. */
-#define BDF_KEEP_COMMENTS 0x02 /* Preserve the font comments. */
-#define BDF_KEEP_UNENCODED 0x04 /* Keep the unencoded glyphs. */
-#define BDF_PROPORTIONAL 0x08 /* Font has proportional spacing. */
-#define BDF_MONOWIDTH 0x10 /* Font has mono width. */
-#define BDF_CHARCELL 0x20 /* Font has charcell spacing. */
-
-#define BDF_ALL_SPACING ( BDF_PROPORTIONAL | \
- BDF_MONOWIDTH | \
- BDF_CHARCELL )
-
-#define BDF_DEFAULT_LOAD_OPTIONS ( BDF_CORRECT_METRICS | \
- BDF_KEEP_COMMENTS | \
- BDF_KEEP_UNENCODED | \
- BDF_PROPORTIONAL )
-
-
- typedef struct bdf_options_t_
- {
- int correct_metrics;
- int keep_unencoded;
- int keep_comments;
- int font_spacing;
-
- } bdf_options_t;
-
-
- /* Callback function type for unknown configuration options. */
- typedef int
- (*bdf_options_callback_t)( bdf_options_t* opts,
- char** params,
- unsigned long nparams,
- void* client_data );
-
-
- /**************************************************************************
- *
- * BDF font property macros and types.
- *
- */
-
-
-#define BDF_ATOM 1
-#define BDF_INTEGER 2
-#define BDF_CARDINAL 3
-
-
- /* This structure represents a particular property of a font. */
- /* There are a set of defaults and each font has their own. */
- typedef struct bdf_property_t_
- {
- const char* name; /* Name of the property. */
- int format; /* Format of the property. */
- int builtin; /* A builtin property. */
- union
- {
- char* atom;
- long l;
- unsigned long ul;
-
- } value; /* Value of the property. */
-
- } bdf_property_t;
-
-
- /**************************************************************************
- *
- * BDF font metric and glyph types.
- *
- */
-
-
- typedef struct bdf_bbx_t_
- {
- unsigned short width;
- unsigned short height;
-
- short x_offset;
- short y_offset;
-
- short ascent;
- short descent;
-
- } bdf_bbx_t;
-
-
- typedef struct bdf_glyph_t_
- {
- char* name; /* Glyph name. */
- unsigned long encoding; /* Glyph encoding. */
- unsigned short swidth; /* Scalable width. */
- unsigned short dwidth; /* Device width. */
- bdf_bbx_t bbx; /* Glyph bounding box. */
- unsigned char* bitmap; /* Glyph bitmap. */
- unsigned long bpr; /* Number of bytes used per row. */
- unsigned short bytes; /* Number of bytes used for the bitmap. */
-
- } bdf_glyph_t;
-
-
- typedef struct bdf_font_t_
- {
- char* name; /* Name of the font. */
- bdf_bbx_t bbx; /* Font bounding box. */
-
- unsigned long point_size; /* Point size of the font. */
- unsigned long resolution_x; /* Font horizontal resolution. */
- unsigned long resolution_y; /* Font vertical resolution. */
-
- int spacing; /* Font spacing value. */
-
- unsigned short monowidth; /* Logical width for monowidth font. */
-
- unsigned long default_char; /* Encoding of the default glyph. */
-
- long font_ascent; /* Font ascent. */
- long font_descent; /* Font descent. */
-
- unsigned long glyphs_size; /* Glyph structures allocated. */
- unsigned long glyphs_used; /* Glyph structures used. */
- bdf_glyph_t* glyphs; /* Glyphs themselves. */
-
- unsigned long unencoded_size; /* Unencoded glyph struct. allocated. */
- unsigned long unencoded_used; /* Unencoded glyph struct. used. */
- bdf_glyph_t* unencoded; /* Unencoded glyphs themselves. */
-
- unsigned long props_size; /* Font properties allocated. */
- unsigned long props_used; /* Font properties used. */
- bdf_property_t* props; /* Font properties themselves. */
-
- char* comments; /* Font comments. */
- unsigned long comments_len; /* Length of comment string. */
-
- void* internal; /* Internal data for the font. */
-
- unsigned short bpp; /* Bits per pixel. */
-
- FT_Memory memory;
-
- bdf_property_t* user_props;
- unsigned long nuser_props;
- FT_HashRec proptbl;
-
- } bdf_font_t;
-
-
- /**************************************************************************
- *
- * Types for load/save callbacks.
- *
- */
-
-
- /* Error codes. */
-#define BDF_MISSING_START -1
-#define BDF_MISSING_FONTNAME -2
-#define BDF_MISSING_SIZE -3
-#define BDF_MISSING_CHARS -4
-#define BDF_MISSING_STARTCHAR -5
-#define BDF_MISSING_ENCODING -6
-#define BDF_MISSING_BBX -7
-
-#define BDF_OUT_OF_MEMORY -20
-
-#define BDF_INVALID_LINE -100
-
-
- /**************************************************************************
- *
- * BDF font API.
- *
- */
-
- FT_LOCAL( FT_Error )
- bdf_load_font( FT_Stream stream,
- FT_Memory memory,
- bdf_options_t* opts,
- bdf_font_t* *font );
-
- FT_LOCAL( void )
- bdf_free_font( bdf_font_t* font );
-
- FT_LOCAL( bdf_property_t * )
- bdf_get_font_property( bdf_font_t* font,
- const char* name );
-
-
-FT_END_HEADER
-
-
-#endif /* BDF_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/bdf/bdfdrivr.c b/contrib/libs/freetype/src/bdf/bdfdrivr.c
deleted file mode 100644
index 4b9d6347fa..0000000000
--- a/contrib/libs/freetype/src/bdf/bdfdrivr.c
+++ /dev/null
@@ -1,1013 +0,0 @@
-/* bdfdrivr.c
-
- FreeType font driver for bdf files
-
- Copyright (C) 2001-2008, 2011, 2013, 2014 by
- Francesco Zappa Nardelli
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-*/
-
-
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/internal/ftobjs.h>
-#include <freetype/ftbdf.h>
-#include <freetype/ttnameid.h>
-
-#include <freetype/internal/services/svbdf.h>
-#include <freetype/internal/services/svfntfmt.h>
-
-#include "bdf.h"
-#include "bdfdrivr.h"
-
-#include "bdferror.h"
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT bdfdriver
-
-
- typedef struct BDF_CMapRec_
- {
- FT_CMapRec cmap;
- FT_ULong num_encodings; /* ftobjs.h: FT_CMap->clazz->size */
- BDF_encoding_el* encodings;
-
- } BDF_CMapRec, *BDF_CMap;
-
-
- FT_CALLBACK_DEF( FT_Error )
- bdf_cmap_init( FT_CMap bdfcmap,
- FT_Pointer init_data )
- {
- BDF_CMap cmap = (BDF_CMap)bdfcmap;
- BDF_Face face = (BDF_Face)FT_CMAP_FACE( cmap );
- FT_UNUSED( init_data );
-
-
- cmap->num_encodings = face->bdffont->glyphs_used;
- cmap->encodings = face->en_table;
-
- return FT_Err_Ok;
- }
-
-
- FT_CALLBACK_DEF( void )
- bdf_cmap_done( FT_CMap bdfcmap )
- {
- BDF_CMap cmap = (BDF_CMap)bdfcmap;
-
-
- cmap->encodings = NULL;
- cmap->num_encodings = 0;
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- bdf_cmap_char_index( FT_CMap bdfcmap,
- FT_UInt32 charcode )
- {
- BDF_CMap cmap = (BDF_CMap)bdfcmap;
- BDF_encoding_el* encodings = cmap->encodings;
- FT_UShort result = 0; /* encodings->glyph */
-
- FT_ULong min = 0;
- FT_ULong max = cmap->num_encodings;
- FT_ULong mid = ( min + max ) >> 1;
-
-
- while ( min < max )
- {
- FT_ULong code = encodings[mid].enc;
-
-
- if ( charcode == code )
- {
- /* increase glyph index by 1 -- */
- /* we reserve slot 0 for the undefined glyph */
- result = encodings[mid].glyph + 1;
- break;
- }
-
- if ( charcode < code )
- max = mid;
- else
- min = mid + 1;
-
- /* reasonable prediction in a continuous block */
- mid += charcode - code;
- if ( mid >= max || mid < min )
- mid = ( min + max ) >> 1;
- }
-
- return result;
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- bdf_cmap_char_next( FT_CMap bdfcmap,
- FT_UInt32 *acharcode )
- {
- BDF_CMap cmap = (BDF_CMap)bdfcmap;
- BDF_encoding_el* encodings = cmap->encodings;
- FT_UShort result = 0; /* encodings->glyph */
- FT_ULong charcode = *acharcode + 1;
-
- FT_ULong min = 0;
- FT_ULong max = cmap->num_encodings;
- FT_ULong mid = ( min + max ) >> 1;
-
-
- while ( min < max )
- {
- FT_ULong code = encodings[mid].enc;
-
-
- if ( charcode == code )
- {
- /* increase glyph index by 1 -- */
- /* we reserve slot 0 for the undefined glyph */
- result = encodings[mid].glyph + 1;
- goto Exit;
- }
-
- if ( charcode < code )
- max = mid;
- else
- min = mid + 1;
-
- /* prediction in a continuous block */
- mid += charcode - code;
- if ( mid >= max || mid < min )
- mid = ( min + max ) >> 1;
- }
-
- charcode = 0;
- if ( min < cmap->num_encodings )
- {
- charcode = encodings[min].enc;
- result = encodings[min].glyph + 1;
- }
-
- Exit:
- if ( charcode > 0xFFFFFFFFUL )
- {
- FT_TRACE1(( "bdf_cmap_char_next: charcode 0x%lx > 32bit API",
- charcode ));
- *acharcode = 0;
- /* XXX: result should be changed to indicate an overflow error */
- }
- else
- *acharcode = (FT_UInt32)charcode;
- return result;
- }
-
-
- static
- const FT_CMap_ClassRec bdf_cmap_class =
- {
- sizeof ( BDF_CMapRec ),
- bdf_cmap_init,
- bdf_cmap_done,
- bdf_cmap_char_index,
- bdf_cmap_char_next,
-
- NULL, NULL, NULL, NULL, NULL
- };
-
-
- static FT_Error
- bdf_interpret_style( BDF_Face bdf )
- {
- FT_Error error = FT_Err_Ok;
- FT_Face face = FT_FACE( bdf );
- FT_Memory memory = face->memory;
- bdf_font_t* font = bdf->bdffont;
- bdf_property_t* prop;
-
- const char* strings[4] = { NULL, NULL, NULL, NULL };
- size_t lengths[4], nn, len;
-
-
- face->style_flags = 0;
-
- prop = bdf_get_font_property( font, "SLANT" );
- if ( prop && prop->format == BDF_ATOM &&
- prop->value.atom &&
- ( *(prop->value.atom) == 'O' || *(prop->value.atom) == 'o' ||
- *(prop->value.atom) == 'I' || *(prop->value.atom) == 'i' ) )
- {
- face->style_flags |= FT_STYLE_FLAG_ITALIC;
- strings[2] = ( *(prop->value.atom) == 'O' || *(prop->value.atom) == 'o' )
- ? "Oblique"
- : "Italic";
- }
-
- prop = bdf_get_font_property( font, "WEIGHT_NAME" );
- if ( prop && prop->format == BDF_ATOM &&
- prop->value.atom &&
- ( *(prop->value.atom) == 'B' || *(prop->value.atom) == 'b' ) )
- {
- face->style_flags |= FT_STYLE_FLAG_BOLD;
- strings[1] = "Bold";
- }
-
- prop = bdf_get_font_property( font, "SETWIDTH_NAME" );
- if ( prop && prop->format == BDF_ATOM &&
- prop->value.atom && *(prop->value.atom) &&
- !( *(prop->value.atom) == 'N' || *(prop->value.atom) == 'n' ) )
- strings[3] = (const char *)(prop->value.atom);
-
- prop = bdf_get_font_property( font, "ADD_STYLE_NAME" );
- if ( prop && prop->format == BDF_ATOM &&
- prop->value.atom && *(prop->value.atom) &&
- !( *(prop->value.atom) == 'N' || *(prop->value.atom) == 'n' ) )
- strings[0] = (const char *)(prop->value.atom);
-
- for ( len = 0, nn = 0; nn < 4; nn++ )
- {
- lengths[nn] = 0;
- if ( strings[nn] )
- {
- lengths[nn] = ft_strlen( strings[nn] );
- len += lengths[nn] + 1;
- }
- }
-
- if ( len == 0 )
- {
- strings[0] = "Regular";
- lengths[0] = ft_strlen( strings[0] );
- len = lengths[0] + 1;
- }
-
- {
- char* s;
-
-
- if ( FT_QALLOC( face->style_name, len ) )
- return error;
-
- s = face->style_name;
-
- for ( nn = 0; nn < 4; nn++ )
- {
- const char* src = strings[nn];
-
-
- len = lengths[nn];
-
- if ( !src )
- continue;
-
- /* separate elements with a space */
- if ( s != face->style_name )
- *s++ = ' ';
-
- ft_memcpy( s, src, len );
-
- /* need to convert spaces to dashes for */
- /* add_style_name and setwidth_name */
- if ( nn == 0 || nn == 3 )
- {
- size_t mm;
-
-
- for ( mm = 0; mm < len; mm++ )
- if ( s[mm] == ' ' )
- s[mm] = '-';
- }
-
- s += len;
- }
- *s = 0;
- }
-
- return error;
- }
-
-
- FT_CALLBACK_DEF( void )
- BDF_Face_Done( FT_Face face ) /* BDF_Face */
- {
- BDF_Face bdfface = (BDF_Face)face;
- FT_Memory memory;
-
-
- if ( !face )
- return;
-
- memory = FT_FACE_MEMORY( face );
-
- bdf_free_font( bdfface->bdffont );
-
- FT_FREE( bdfface->en_table );
-
- FT_FREE( bdfface->charset_encoding );
- FT_FREE( bdfface->charset_registry );
- FT_FREE( face->family_name );
- FT_FREE( face->style_name );
-
- FT_FREE( face->available_sizes );
-
- FT_FREE( bdfface->bdffont );
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- BDF_Face_Init( FT_Stream stream,
- FT_Face face, /* BDF_Face */
- FT_Int face_index,
- FT_Int num_params,
- FT_Parameter* params )
- {
- FT_Error error = FT_Err_Ok;
- BDF_Face bdfface = (BDF_Face)face;
- FT_Memory memory = FT_FACE_MEMORY( face );
-
- bdf_font_t* font = NULL;
- bdf_options_t options;
-
- FT_UNUSED( num_params );
- FT_UNUSED( params );
-
-
- FT_TRACE2(( "BDF driver\n" ));
-
- if ( FT_STREAM_SEEK( 0 ) )
- goto Exit;
-
- options.correct_metrics = 1; /* FZ XXX: options semantics */
- options.keep_unencoded = 1;
- options.keep_comments = 0;
- options.font_spacing = BDF_PROPORTIONAL;
-
- error = bdf_load_font( stream, memory, &options, &font );
- if ( FT_ERR_EQ( error, Missing_Startfont_Field ) )
- {
- FT_TRACE2(( " not a BDF file\n" ));
- goto Fail;
- }
- else if ( error )
- goto Exit;
-
- /* we have a bdf font: let's construct the face object */
- bdfface->bdffont = font;
-
- /* BDF cannot have multiple faces in a single font file.
- * XXX: non-zero face_index is already invalid argument, but
- * Type1, Type42 driver has a convention to return
- * an invalid argument error when the font could be
- * opened by the specified driver.
- */
- if ( face_index > 0 && ( face_index & 0xFFFF ) > 0 )
- {
- FT_ERROR(( "BDF_Face_Init: invalid face index\n" ));
- BDF_Face_Done( face );
- return FT_THROW( Invalid_Argument );
- }
-
- {
- bdf_property_t* prop = NULL;
-
-
- FT_TRACE4(( " number of glyphs: allocated %ld (used %ld)\n",
- font->glyphs_size,
- font->glyphs_used ));
- FT_TRACE4(( " number of unencoded glyphs: allocated %ld (used %ld)\n",
- font->unencoded_size,
- font->unencoded_used ));
-
- face->num_faces = 1;
- face->face_index = 0;
-
- face->face_flags |= FT_FACE_FLAG_FIXED_SIZES |
- FT_FACE_FLAG_HORIZONTAL;
-
- prop = bdf_get_font_property( font, "SPACING" );
- if ( prop && prop->format == BDF_ATOM &&
- prop->value.atom &&
- ( *(prop->value.atom) == 'M' || *(prop->value.atom) == 'm' ||
- *(prop->value.atom) == 'C' || *(prop->value.atom) == 'c' ) )
- face->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
-
- /* FZ XXX: TO DO: FT_FACE_FLAGS_VERTICAL */
- /* FZ XXX: I need a font to implement this */
-
- prop = bdf_get_font_property( font, "FAMILY_NAME" );
- if ( prop && prop->value.atom )
- {
- if ( FT_STRDUP( face->family_name, prop->value.atom ) )
- goto Exit;
- }
- else
- face->family_name = NULL;
-
- if ( FT_SET_ERROR( bdf_interpret_style( bdfface ) ) )
- goto Exit;
-
- /* the number of glyphs (with one slot for the undefined glyph */
- /* at position 0 and all unencoded glyphs) */
- face->num_glyphs = (FT_Long)( font->glyphs_size + 1 );
-
- face->num_fixed_sizes = 1;
- if ( FT_NEW( face->available_sizes ) )
- goto Exit;
-
- {
- FT_Bitmap_Size* bsize = face->available_sizes;
- FT_Short resolution_x = 0;
- FT_Short resolution_y = 0;
- long value;
-
-
- /* sanity checks */
- if ( font->font_ascent > 0x7FFF || font->font_ascent < -0x7FFF )
- {
- font->font_ascent = font->font_ascent < 0 ? -0x7FFF : 0x7FFF;
- FT_TRACE0(( "BDF_Face_Init: clamping font ascent to value %ld\n",
- font->font_ascent ));
- }
- if ( font->font_descent > 0x7FFF || font->font_descent < -0x7FFF )
- {
- font->font_descent = font->font_descent < 0 ? -0x7FFF : 0x7FFF;
- FT_TRACE0(( "BDF_Face_Init: clamping font descent to value %ld\n",
- font->font_descent ));
- }
-
- bsize->height = (FT_Short)( font->font_ascent + font->font_descent );
-
- prop = bdf_get_font_property( font, "AVERAGE_WIDTH" );
- if ( prop )
- {
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( prop->value.l < 0 )
- FT_TRACE0(( "BDF_Face_Init: negative average width\n" ));
-#endif
- if ( prop->value.l > 0x7FFFL * 10 - 5 ||
- prop->value.l < -( 0x7FFFL * 10 - 5 ) )
- {
- bsize->width = 0x7FFF;
- FT_TRACE0(( "BDF_Face_Init: clamping average width to value %d\n",
- bsize->width ));
- }
- else
- bsize->width = FT_ABS( (FT_Short)( ( prop->value.l + 5 ) / 10 ) );
- }
- else
- {
- /* this is a heuristical value */
- bsize->width = ( bsize->height * 2 + 1 ) / 3;
- }
-
- prop = bdf_get_font_property( font, "POINT_SIZE" );
- if ( prop )
- {
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( prop->value.l < 0 )
- FT_TRACE0(( "BDF_Face_Init: negative point size\n" ));
-#endif
- /* convert from 722.7 decipoints to 72 points per inch */
- if ( prop->value.l > 0x504C2L || /* 0x7FFF * 72270/7200 */
- prop->value.l < -0x504C2L )
- {
- bsize->size = 0x7FFF;
- FT_TRACE0(( "BDF_Face_Init: clamping point size to value %ld\n",
- bsize->size ));
- }
- else
- bsize->size = FT_MulDiv( FT_ABS( prop->value.l ),
- 64 * 7200,
- 72270L );
- }
- else if ( font->point_size )
- {
- if ( font->point_size > 0x7FFF )
- {
- bsize->size = 0x7FFF;
- FT_TRACE0(( "BDF_Face_Init: clamping point size to value %ld\n",
- bsize->size ));
- }
- else
- bsize->size = (FT_Pos)font->point_size << 6;
- }
- else
- {
- /* this is a heuristical value */
- bsize->size = bsize->width * 64;
- }
-
- prop = bdf_get_font_property( font, "PIXEL_SIZE" );
- if ( prop )
- {
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( prop->value.l < 0 )
- FT_TRACE0(( "BDF_Face_Init: negative pixel size\n" ));
-#endif
- if ( prop->value.l > 0x7FFF || prop->value.l < -0x7FFF )
- {
- bsize->y_ppem = 0x7FFF << 6;
- FT_TRACE0(( "BDF_Face_Init: clamping pixel size to value %ld\n",
- bsize->y_ppem ));
- }
- else
- bsize->y_ppem = FT_ABS( (FT_Short)prop->value.l ) << 6;
- }
-
- prop = bdf_get_font_property( font, "RESOLUTION_X" );
- if ( prop )
- value = prop->value.l;
- else
- value = (long)font->resolution_x;
- if ( value )
- {
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( value < 0 )
- FT_TRACE0(( "BDF_Face_Init: negative X resolution\n" ));
-#endif
- if ( value > 0x7FFF || value < -0x7FFF )
- {
- resolution_x = 0x7FFF;
- FT_TRACE0(( "BDF_Face_Init: clamping X resolution to value %d\n",
- resolution_x ));
- }
- else
- resolution_x = FT_ABS( (FT_Short)value );
- }
-
- prop = bdf_get_font_property( font, "RESOLUTION_Y" );
- if ( prop )
- value = prop->value.l;
- else
- value = (long)font->resolution_y;
- if ( value )
- {
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( value < 0 )
- FT_TRACE0(( "BDF_Face_Init: negative Y resolution\n" ));
-#endif
- if ( value > 0x7FFF || value < -0x7FFF )
- {
- resolution_y = 0x7FFF;
- FT_TRACE0(( "BDF_Face_Init: clamping Y resolution to value %d\n",
- resolution_y ));
- }
- else
- resolution_y = FT_ABS( (FT_Short)value );
- }
-
- if ( bsize->y_ppem == 0 )
- {
- bsize->y_ppem = bsize->size;
- if ( resolution_y )
- bsize->y_ppem = FT_MulDiv( bsize->y_ppem, resolution_y, 72 );
- }
- if ( resolution_x && resolution_y )
- bsize->x_ppem = FT_MulDiv( bsize->y_ppem,
- resolution_x,
- resolution_y );
- else
- bsize->x_ppem = bsize->y_ppem;
- }
-
- /* encoding table */
- {
- bdf_glyph_t* cur = font->glyphs;
- unsigned long n;
-
-
- if ( FT_QNEW_ARRAY( bdfface->en_table, font->glyphs_size ) )
- goto Exit;
-
- bdfface->default_glyph = 0;
- for ( n = 0; n < font->glyphs_size; n++ )
- {
- (bdfface->en_table[n]).enc = cur[n].encoding;
- FT_TRACE4(( " idx %ld, val 0x%lX\n", n, cur[n].encoding ));
- (bdfface->en_table[n]).glyph = (FT_UShort)n;
-
- if ( cur[n].encoding == font->default_char )
- {
- if ( n < FT_UINT_MAX )
- bdfface->default_glyph = (FT_UInt)n;
- else
- FT_TRACE1(( "BDF_Face_Init:"
- " idx %ld is too large for this system\n", n ));
- }
- }
- }
-
- /* charmaps */
- {
- bdf_property_t *charset_registry, *charset_encoding;
- FT_Bool unicode_charmap = 0;
-
-
- charset_registry =
- bdf_get_font_property( font, "CHARSET_REGISTRY" );
- charset_encoding =
- bdf_get_font_property( font, "CHARSET_ENCODING" );
- if ( charset_registry && charset_encoding )
- {
- if ( charset_registry->format == BDF_ATOM &&
- charset_encoding->format == BDF_ATOM &&
- charset_registry->value.atom &&
- charset_encoding->value.atom )
- {
- const char* s;
-
-
- if ( FT_STRDUP( bdfface->charset_encoding,
- charset_encoding->value.atom ) ||
- FT_STRDUP( bdfface->charset_registry,
- charset_registry->value.atom ) )
- goto Exit;
-
- /* Uh, oh, compare first letters manually to avoid dependency */
- /* on locales. */
- s = bdfface->charset_registry;
- if ( ( s[0] == 'i' || s[0] == 'I' ) &&
- ( s[1] == 's' || s[1] == 'S' ) &&
- ( s[2] == 'o' || s[2] == 'O' ) )
- {
- s += 3;
- if ( !ft_strcmp( s, "10646" ) ||
- ( !ft_strcmp( s, "8859" ) &&
- !ft_strcmp( bdfface->charset_encoding, "1" ) ) )
- unicode_charmap = 1;
- /* another name for ASCII */
- else if ( !ft_strcmp( s, "646.1991" ) &&
- !ft_strcmp( bdfface->charset_encoding, "IRV" ) )
- unicode_charmap = 1;
- }
-
- {
- FT_CharMapRec charmap;
-
-
- charmap.face = face;
- charmap.encoding = FT_ENCODING_NONE;
- /* initial platform/encoding should indicate unset status? */
- charmap.platform_id = TT_PLATFORM_APPLE_UNICODE;
- charmap.encoding_id = TT_APPLE_ID_DEFAULT;
-
- if ( unicode_charmap )
- {
- charmap.encoding = FT_ENCODING_UNICODE;
- charmap.platform_id = TT_PLATFORM_MICROSOFT;
- charmap.encoding_id = TT_MS_ID_UNICODE_CS;
- }
-
- error = FT_CMap_New( &bdf_cmap_class, NULL, &charmap, NULL );
- }
-
- goto Exit;
- }
- }
-
- /* otherwise assume Adobe standard encoding */
-
- {
- FT_CharMapRec charmap;
-
-
- charmap.face = face;
- charmap.encoding = FT_ENCODING_ADOBE_STANDARD;
- charmap.platform_id = TT_PLATFORM_ADOBE;
- charmap.encoding_id = TT_ADOBE_ID_STANDARD;
-
- error = FT_CMap_New( &bdf_cmap_class, NULL, &charmap, NULL );
-
- /* Select default charmap */
- if ( face->num_charmaps )
- face->charmap = face->charmaps[0];
- }
- }
- }
-
- Exit:
- return error;
-
- Fail:
- BDF_Face_Done( face );
- return FT_THROW( Unknown_File_Format );
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- BDF_Size_Select( FT_Size size,
- FT_ULong strike_index )
- {
- bdf_font_t* bdffont = ( (BDF_Face)size->face )->bdffont;
-
-
- FT_Select_Metrics( size->face, strike_index );
-
- size->metrics.ascender = bdffont->font_ascent * 64;
- size->metrics.descender = -bdffont->font_descent * 64;
- size->metrics.max_advance = bdffont->bbx.width * 64;
-
- return FT_Err_Ok;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- BDF_Size_Request( FT_Size size,
- FT_Size_Request req )
- {
- FT_Face face = size->face;
- FT_Bitmap_Size* bsize = face->available_sizes;
- bdf_font_t* bdffont = ( (BDF_Face)face )->bdffont;
- FT_Error error = FT_ERR( Invalid_Pixel_Size );
- FT_Long height;
-
-
- height = FT_REQUEST_HEIGHT( req );
- height = ( height + 32 ) >> 6;
-
- switch ( req->type )
- {
- case FT_SIZE_REQUEST_TYPE_NOMINAL:
- if ( height == ( ( bsize->y_ppem + 32 ) >> 6 ) )
- error = FT_Err_Ok;
- break;
-
- case FT_SIZE_REQUEST_TYPE_REAL_DIM:
- if ( height == ( bdffont->font_ascent +
- bdffont->font_descent ) )
- error = FT_Err_Ok;
- break;
-
- default:
- error = FT_THROW( Unimplemented_Feature );
- break;
- }
-
- if ( error )
- return error;
- else
- return BDF_Size_Select( size, 0 );
- }
-
-
-
- FT_CALLBACK_DEF( FT_Error )
- BDF_Glyph_Load( FT_GlyphSlot slot,
- FT_Size size,
- FT_UInt glyph_index,
- FT_Int32 load_flags )
- {
- FT_Face face = size->face;
- BDF_Face bdf = (BDF_Face)face;
- FT_Error error = FT_Err_Ok;
- FT_Bitmap* bitmap = &slot->bitmap;
- bdf_glyph_t glyph;
- int bpp = bdf->bdffont->bpp;
-
- FT_UNUSED( load_flags );
-
-
- if ( !face )
- {
- error = FT_THROW( Invalid_Face_Handle );
- goto Exit;
- }
-
- if ( glyph_index >= (FT_UInt)face->num_glyphs )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- FT_TRACE1(( "BDF_Glyph_Load: glyph index %d\n", glyph_index ));
-
- /* index 0 is the undefined glyph */
- if ( glyph_index == 0 )
- glyph_index = bdf->default_glyph;
- else
- glyph_index--;
-
- /* slot, bitmap => freetype, glyph => bdflib */
- glyph = bdf->bdffont->glyphs[glyph_index];
-
- bitmap->rows = glyph.bbx.height;
- bitmap->width = glyph.bbx.width;
- if ( glyph.bpr > FT_INT_MAX )
- FT_TRACE1(( "BDF_Glyph_Load: too large pitch %ld is truncated\n",
- glyph.bpr ));
- bitmap->pitch = (int)glyph.bpr; /* same as FT_Bitmap.pitch */
-
- /* note: we don't allocate a new array to hold the bitmap; */
- /* we can simply point to it */
- ft_glyphslot_set_bitmap( slot, glyph.bitmap );
-
- switch ( bpp )
- {
- case 1:
- bitmap->pixel_mode = FT_PIXEL_MODE_MONO;
- break;
- case 2:
- bitmap->pixel_mode = FT_PIXEL_MODE_GRAY2;
- break;
- case 4:
- bitmap->pixel_mode = FT_PIXEL_MODE_GRAY4;
- break;
- case 8:
- bitmap->pixel_mode = FT_PIXEL_MODE_GRAY;
- bitmap->num_grays = 256;
- break;
- }
-
- slot->format = FT_GLYPH_FORMAT_BITMAP;
- slot->bitmap_left = glyph.bbx.x_offset;
- slot->bitmap_top = glyph.bbx.ascent;
-
- slot->metrics.horiAdvance = (FT_Pos)( glyph.dwidth * 64 );
- slot->metrics.horiBearingX = (FT_Pos)( glyph.bbx.x_offset * 64 );
- slot->metrics.horiBearingY = (FT_Pos)( glyph.bbx.ascent * 64 );
- slot->metrics.width = (FT_Pos)( bitmap->width * 64 );
- slot->metrics.height = (FT_Pos)( bitmap->rows * 64 );
-
- /*
- * XXX DWIDTH1 and VVECTOR should be parsed and
- * used here, provided such fonts do exist.
- */
- ft_synthesize_vertical_metrics( &slot->metrics,
- bdf->bdffont->bbx.height * 64 );
-
- Exit:
- return error;
- }
-
-
- /*
- *
- * BDF SERVICE
- *
- */
-
- FT_CALLBACK_DEF( FT_Error )
- bdf_get_bdf_property( FT_Face face, /* BDF_Face */
- const char* prop_name,
- BDF_PropertyRec *aproperty )
- {
- BDF_Face bdfface = (BDF_Face)face;
- bdf_property_t* prop;
-
-
- FT_ASSERT( bdfface && bdfface->bdffont );
-
- prop = bdf_get_font_property( bdfface->bdffont, prop_name );
- if ( prop )
- {
- switch ( prop->format )
- {
- case BDF_ATOM:
- aproperty->type = BDF_PROPERTY_TYPE_ATOM;
- aproperty->u.atom = prop->value.atom;
- break;
-
- case BDF_INTEGER:
- if ( prop->value.l > 0x7FFFFFFFL || prop->value.l < ( -1 - 0x7FFFFFFFL ) )
- {
- FT_TRACE1(( "bdf_get_bdf_property:"
- " too large integer 0x%lx is truncated\n",
- prop->value.l ));
- }
- aproperty->type = BDF_PROPERTY_TYPE_INTEGER;
- aproperty->u.integer = (FT_Int32)prop->value.l;
- break;
-
- case BDF_CARDINAL:
- if ( prop->value.ul > 0xFFFFFFFFUL )
- {
- FT_TRACE1(( "bdf_get_bdf_property:"
- " too large cardinal 0x%lx is truncated\n",
- prop->value.ul ));
- }
- aproperty->type = BDF_PROPERTY_TYPE_CARDINAL;
- aproperty->u.cardinal = (FT_UInt32)prop->value.ul;
- break;
-
- default:
- goto Fail;
- }
- return 0;
- }
-
- Fail:
- return FT_THROW( Invalid_Argument );
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- bdf_get_charset_id( FT_Face face, /* BDF_Face */
- const char* *acharset_encoding,
- const char* *acharset_registry )
- {
- BDF_Face bdfface = (BDF_Face)face;
-
-
- *acharset_encoding = bdfface->charset_encoding;
- *acharset_registry = bdfface->charset_registry;
-
- return 0;
- }
-
-
- static const FT_Service_BDFRec bdf_service_bdf =
- {
- (FT_BDF_GetCharsetIdFunc)bdf_get_charset_id, /* get_charset_id */
- (FT_BDF_GetPropertyFunc) bdf_get_bdf_property /* get_property */
- };
-
-
- /*
- *
- * SERVICES LIST
- *
- */
-
- static const FT_ServiceDescRec bdf_services[] =
- {
- { FT_SERVICE_ID_BDF, &bdf_service_bdf },
- { FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_BDF },
- { NULL, NULL }
- };
-
-
- FT_CALLBACK_DEF( FT_Module_Interface )
- bdf_driver_requester( FT_Module module,
- const char* name )
- {
- FT_UNUSED( module );
-
- return ft_service_list_lookup( bdf_services, name );
- }
-
-
- FT_CALLBACK_TABLE_DEF
- const FT_Driver_ClassRec bdf_driver_class =
- {
- {
- FT_MODULE_FONT_DRIVER |
- FT_MODULE_DRIVER_NO_OUTLINES,
- sizeof ( FT_DriverRec ),
-
- "bdf",
- 0x10000L,
- 0x20000L,
-
- NULL, /* module-specific interface */
-
- NULL, /* FT_Module_Constructor module_init */
- NULL, /* FT_Module_Destructor module_done */
- bdf_driver_requester /* FT_Module_Requester get_interface */
- },
-
- sizeof ( BDF_FaceRec ),
- sizeof ( FT_SizeRec ),
- sizeof ( FT_GlyphSlotRec ),
-
- BDF_Face_Init, /* FT_Face_InitFunc init_face */
- BDF_Face_Done, /* FT_Face_DoneFunc done_face */
- NULL, /* FT_Size_InitFunc init_size */
- NULL, /* FT_Size_DoneFunc done_size */
- NULL, /* FT_Slot_InitFunc init_slot */
- NULL, /* FT_Slot_DoneFunc done_slot */
-
- BDF_Glyph_Load, /* FT_Slot_LoadFunc load_glyph */
-
- NULL, /* FT_Face_GetKerningFunc get_kerning */
- NULL, /* FT_Face_AttachFunc attach_file */
- NULL, /* FT_Face_GetAdvancesFunc get_advances */
-
- BDF_Size_Request, /* FT_Size_RequestFunc request_size */
- BDF_Size_Select /* FT_Size_SelectFunc select_size */
- };
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/bdf/bdfdrivr.h b/contrib/libs/freetype/src/bdf/bdfdrivr.h
deleted file mode 100644
index 54aaa3353c..0000000000
--- a/contrib/libs/freetype/src/bdf/bdfdrivr.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/* bdfdrivr.h
-
- FreeType font driver for bdf fonts
-
- Copyright (C) 2001, 2002, 2003, 2004 by
- Francesco Zappa Nardelli
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-*/
-
-
-#ifndef BDFDRIVR_H_
-#define BDFDRIVR_H_
-
-#include <freetype/internal/ftdrv.h>
-
-#include "bdf.h"
-
-
-FT_BEGIN_HEADER
-
-
- typedef struct BDF_encoding_el_
- {
- FT_ULong enc;
- FT_UShort glyph;
-
- } BDF_encoding_el;
-
-
- typedef struct BDF_FaceRec_
- {
- FT_FaceRec root;
-
- char* charset_encoding;
- char* charset_registry;
-
- bdf_font_t* bdffont;
-
- BDF_encoding_el* en_table;
-
- FT_UInt default_glyph;
-
- } BDF_FaceRec, *BDF_Face;
-
-
- FT_EXPORT_VAR( const FT_Driver_ClassRec ) bdf_driver_class;
-
-
-FT_END_HEADER
-
-
-#endif /* BDFDRIVR_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/bdf/bdferror.h b/contrib/libs/freetype/src/bdf/bdferror.h
deleted file mode 100644
index c1b5444871..0000000000
--- a/contrib/libs/freetype/src/bdf/bdferror.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2001, 2002, 2012 Francesco Zappa Nardelli
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COMPUTING RESEARCH LAB OR NEW MEXICO STATE UNIVERSITY BE LIABLE FOR ANY
- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
- * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
- * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
- /**************************************************************************
- *
- * This file is used to define the BDF error enumeration constants.
- *
- */
-
-#ifndef BDFERROR_H_
-#define BDFERROR_H_
-
-#include <freetype/ftmoderr.h>
-
-#undef FTERRORS_H_
-
-#undef FT_ERR_PREFIX
-#define FT_ERR_PREFIX BDF_Err_
-#define FT_ERR_BASE FT_Mod_Err_BDF
-
-#include <freetype/fterrors.h>
-
-#endif /* BDFERROR_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/bdf/bdflib.c b/contrib/libs/freetype/src/bdf/bdflib.c
deleted file mode 100644
index 813a4d839c..0000000000
--- a/contrib/libs/freetype/src/bdf/bdflib.c
+++ /dev/null
@@ -1,2378 +0,0 @@
-/*
- * Copyright 2000 Computing Research Labs, New Mexico State University
- * Copyright 2001-2014
- * Francesco Zappa Nardelli
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COMPUTING RESEARCH LAB OR NEW MEXICO STATE UNIVERSITY BE LIABLE FOR ANY
- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
- * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
- * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
- /**************************************************************************
- *
- * This file is based on bdf.c,v 1.22 2000/03/16 20:08:50
- *
- * taken from Mark Leisher's xmbdfed package
- *
- */
-
-
-
-#include <freetype/freetype.h>
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/internal/ftobjs.h>
-
-#include "bdf.h"
-#include "bdferror.h"
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT bdflib
-
-
-#define BUFSIZE 128
-
-
- /**************************************************************************
- *
- * Default BDF font options.
- *
- */
-
-
- static const bdf_options_t bdf_opts_ =
- {
- 1, /* Correct metrics. */
- 1, /* Preserve unencoded glyphs. */
- 0, /* Preserve comments. */
- BDF_PROPORTIONAL /* Default spacing. */
- };
-
-
- /**************************************************************************
- *
- * Builtin BDF font properties.
- *
- */
-
- /* List of most properties that might appear in a font. Doesn't include */
- /* the RAW_* and AXIS_* properties in X11R6 polymorphic fonts. */
-
- static const bdf_property_t bdf_properties_[] =
- {
- { "ADD_STYLE_NAME", BDF_ATOM, 1, { 0 } },
- { "AVERAGE_WIDTH", BDF_INTEGER, 1, { 0 } },
- { "AVG_CAPITAL_WIDTH", BDF_INTEGER, 1, { 0 } },
- { "AVG_LOWERCASE_WIDTH", BDF_INTEGER, 1, { 0 } },
- { "CAP_HEIGHT", BDF_INTEGER, 1, { 0 } },
- { "CHARSET_COLLECTIONS", BDF_ATOM, 1, { 0 } },
- { "CHARSET_ENCODING", BDF_ATOM, 1, { 0 } },
- { "CHARSET_REGISTRY", BDF_ATOM, 1, { 0 } },
- { "COMMENT", BDF_ATOM, 1, { 0 } },
- { "COPYRIGHT", BDF_ATOM, 1, { 0 } },
- { "DEFAULT_CHAR", BDF_CARDINAL, 1, { 0 } },
- { "DESTINATION", BDF_CARDINAL, 1, { 0 } },
- { "DEVICE_FONT_NAME", BDF_ATOM, 1, { 0 } },
- { "END_SPACE", BDF_INTEGER, 1, { 0 } },
- { "FACE_NAME", BDF_ATOM, 1, { 0 } },
- { "FAMILY_NAME", BDF_ATOM, 1, { 0 } },
- { "FIGURE_WIDTH", BDF_INTEGER, 1, { 0 } },
- { "FONT", BDF_ATOM, 1, { 0 } },
- { "FONTNAME_REGISTRY", BDF_ATOM, 1, { 0 } },
- { "FONT_ASCENT", BDF_INTEGER, 1, { 0 } },
- { "FONT_DESCENT", BDF_INTEGER, 1, { 0 } },
- { "FOUNDRY", BDF_ATOM, 1, { 0 } },
- { "FULL_NAME", BDF_ATOM, 1, { 0 } },
- { "ITALIC_ANGLE", BDF_INTEGER, 1, { 0 } },
- { "MAX_SPACE", BDF_INTEGER, 1, { 0 } },
- { "MIN_SPACE", BDF_INTEGER, 1, { 0 } },
- { "NORM_SPACE", BDF_INTEGER, 1, { 0 } },
- { "NOTICE", BDF_ATOM, 1, { 0 } },
- { "PIXEL_SIZE", BDF_INTEGER, 1, { 0 } },
- { "POINT_SIZE", BDF_INTEGER, 1, { 0 } },
- { "QUAD_WIDTH", BDF_INTEGER, 1, { 0 } },
- { "RAW_ASCENT", BDF_INTEGER, 1, { 0 } },
- { "RAW_AVERAGE_WIDTH", BDF_INTEGER, 1, { 0 } },
- { "RAW_AVG_CAPITAL_WIDTH", BDF_INTEGER, 1, { 0 } },
- { "RAW_AVG_LOWERCASE_WIDTH", BDF_INTEGER, 1, { 0 } },
- { "RAW_CAP_HEIGHT", BDF_INTEGER, 1, { 0 } },
- { "RAW_DESCENT", BDF_INTEGER, 1, { 0 } },
- { "RAW_END_SPACE", BDF_INTEGER, 1, { 0 } },
- { "RAW_FIGURE_WIDTH", BDF_INTEGER, 1, { 0 } },
- { "RAW_MAX_SPACE", BDF_INTEGER, 1, { 0 } },
- { "RAW_MIN_SPACE", BDF_INTEGER, 1, { 0 } },
- { "RAW_NORM_SPACE", BDF_INTEGER, 1, { 0 } },
- { "RAW_PIXEL_SIZE", BDF_INTEGER, 1, { 0 } },
- { "RAW_POINT_SIZE", BDF_INTEGER, 1, { 0 } },
- { "RAW_PIXELSIZE", BDF_INTEGER, 1, { 0 } },
- { "RAW_POINTSIZE", BDF_INTEGER, 1, { 0 } },
- { "RAW_QUAD_WIDTH", BDF_INTEGER, 1, { 0 } },
- { "RAW_SMALL_CAP_SIZE", BDF_INTEGER, 1, { 0 } },
- { "RAW_STRIKEOUT_ASCENT", BDF_INTEGER, 1, { 0 } },
- { "RAW_STRIKEOUT_DESCENT", BDF_INTEGER, 1, { 0 } },
- { "RAW_SUBSCRIPT_SIZE", BDF_INTEGER, 1, { 0 } },
- { "RAW_SUBSCRIPT_X", BDF_INTEGER, 1, { 0 } },
- { "RAW_SUBSCRIPT_Y", BDF_INTEGER, 1, { 0 } },
- { "RAW_SUPERSCRIPT_SIZE", BDF_INTEGER, 1, { 0 } },
- { "RAW_SUPERSCRIPT_X", BDF_INTEGER, 1, { 0 } },
- { "RAW_SUPERSCRIPT_Y", BDF_INTEGER, 1, { 0 } },
- { "RAW_UNDERLINE_POSITION", BDF_INTEGER, 1, { 0 } },
- { "RAW_UNDERLINE_THICKNESS", BDF_INTEGER, 1, { 0 } },
- { "RAW_X_HEIGHT", BDF_INTEGER, 1, { 0 } },
- { "RELATIVE_SETWIDTH", BDF_CARDINAL, 1, { 0 } },
- { "RELATIVE_WEIGHT", BDF_CARDINAL, 1, { 0 } },
- { "RESOLUTION", BDF_INTEGER, 1, { 0 } },
- { "RESOLUTION_X", BDF_CARDINAL, 1, { 0 } },
- { "RESOLUTION_Y", BDF_CARDINAL, 1, { 0 } },
- { "SETWIDTH_NAME", BDF_ATOM, 1, { 0 } },
- { "SLANT", BDF_ATOM, 1, { 0 } },
- { "SMALL_CAP_SIZE", BDF_INTEGER, 1, { 0 } },
- { "SPACING", BDF_ATOM, 1, { 0 } },
- { "STRIKEOUT_ASCENT", BDF_INTEGER, 1, { 0 } },
- { "STRIKEOUT_DESCENT", BDF_INTEGER, 1, { 0 } },
- { "SUBSCRIPT_SIZE", BDF_INTEGER, 1, { 0 } },
- { "SUBSCRIPT_X", BDF_INTEGER, 1, { 0 } },
- { "SUBSCRIPT_Y", BDF_INTEGER, 1, { 0 } },
- { "SUPERSCRIPT_SIZE", BDF_INTEGER, 1, { 0 } },
- { "SUPERSCRIPT_X", BDF_INTEGER, 1, { 0 } },
- { "SUPERSCRIPT_Y", BDF_INTEGER, 1, { 0 } },
- { "UNDERLINE_POSITION", BDF_INTEGER, 1, { 0 } },
- { "UNDERLINE_THICKNESS", BDF_INTEGER, 1, { 0 } },
- { "WEIGHT", BDF_CARDINAL, 1, { 0 } },
- { "WEIGHT_NAME", BDF_ATOM, 1, { 0 } },
- { "X_HEIGHT", BDF_INTEGER, 1, { 0 } },
- { "_MULE_BASELINE_OFFSET", BDF_INTEGER, 1, { 0 } },
- { "_MULE_RELATIVE_COMPOSE", BDF_INTEGER, 1, { 0 } },
- };
-
- static const unsigned long
- num_bdf_properties_ = sizeof ( bdf_properties_ ) /
- sizeof ( bdf_properties_[0] );
-
-
- /* An auxiliary macro to parse properties, to be used in conditionals. */
- /* It behaves like `strncmp' but also tests the following character */
- /* whether it is a whitespace or null. */
- /* `property' is a constant string of length `n' to compare with. */
-#define _bdf_strncmp( name, property, n ) \
- ( ft_strncmp( name, property, n ) || \
- !( name[n] == ' ' || \
- name[n] == '\0' || \
- name[n] == '\n' || \
- name[n] == '\r' || \
- name[n] == '\t' ) )
-
- /* Auto correction messages. */
-#define ACMSG1 "FONT_ASCENT property missing. " \
- "Added `FONT_ASCENT %hd'.\n"
-#define ACMSG2 "FONT_DESCENT property missing. " \
- "Added `FONT_DESCENT %hd'.\n"
-#define ACMSG3 "Font width != actual width. Old: %d New: %d.\n"
-#define ACMSG4 "Font left bearing != actual left bearing. " \
- "Old: %hd New: %hd.\n"
-#define ACMSG5 "Font ascent != actual ascent. Old: %hd New: %hd.\n"
-#define ACMSG6 "Font descent != actual descent. Old: %d New: %d.\n"
-#define ACMSG7 "Font height != actual height. Old: %d New: %d.\n"
-#define ACMSG8 "Glyph scalable width (SWIDTH) adjustments made.\n"
-#define ACMSG9 "SWIDTH field missing at line %ld. Set automatically.\n"
-#define ACMSG10 "DWIDTH field missing at line %ld. Set to glyph width.\n"
-#define ACMSG11 "SIZE bits per pixel field adjusted to %hd.\n"
-#define ACMSG13 "Glyph %lu extra rows removed.\n"
-#define ACMSG14 "Glyph %lu extra columns removed.\n"
-#define ACMSG15 "Incorrect glyph count: %ld indicated but %ld found.\n"
-#define ACMSG16 "Glyph %lu missing columns padded with zero bits.\n"
-#define ACMSG17 "Adjusting number of glyphs to %ld.\n"
-
- /* Error messages. */
-#define ERRMSG1 "[line %ld] Missing `%s' line.\n"
-#define ERRMSG2 "[line %ld] Font header corrupted or missing fields.\n"
-#define ERRMSG3 "[line %ld] Font glyphs corrupted or missing fields.\n"
-#define ERRMSG4 "[line %ld] BBX too big.\n"
-#define ERRMSG5 "[line %ld] `%s' value too big.\n"
-#define ERRMSG6 "[line %ld] Input line too long.\n"
-#define ERRMSG7 "[line %ld] Font name too long.\n"
-#define ERRMSG8 "[line %ld] Invalid `%s' value.\n"
-#define ERRMSG9 "[line %ld] Invalid keyword.\n"
-
- /* Debug messages. */
-#define DBGMSG1 " [%6ld] %s" /* no \n */
-#define DBGMSG2 " (0x%lX)\n"
-
-
- /**************************************************************************
- *
- * Utility types and functions.
- *
- */
-
-
- /* Function type for parsing lines of a BDF font. */
-
- typedef FT_Error
- (*bdf_line_func_t_)( char* line,
- unsigned long linelen,
- unsigned long lineno,
- void* call_data,
- void* client_data );
-
-
- /* List structure for splitting lines into fields. */
-
- typedef struct bdf_list_t__
- {
- char** field;
- unsigned long size;
- unsigned long used;
- FT_Memory memory;
-
- } bdf_list_t_;
-
-
- /* Structure used while loading BDF fonts. */
-
- typedef struct bdf_parse_t__
- {
- unsigned long flags;
- unsigned long cnt;
- unsigned long row;
-
- short minlb;
- short maxlb;
- short maxrb;
- short maxas;
- short maxds;
-
- short rbearing;
-
- char* glyph_name;
- long glyph_enc;
-
- bdf_font_t* font;
- bdf_options_t* opts;
-
- bdf_list_t_ list;
-
- FT_Memory memory;
- unsigned long size; /* the stream size */
-
- } bdf_parse_t_;
-
-
-#define setsbit( m, cc ) \
- ( m[(FT_Byte)(cc) >> 3] |= (FT_Byte)( 1 << ( (cc) & 7 ) ) )
-#define sbitset( m, cc ) \
- ( m[(FT_Byte)(cc) >> 3] & ( 1 << ( (cc) & 7 ) ) )
-
-
- static void
- bdf_list_init_( bdf_list_t_* list,
- FT_Memory memory )
- {
- FT_ZERO( list );
- list->memory = memory;
- }
-
-
- static void
- bdf_list_done_( bdf_list_t_* list )
- {
- FT_Memory memory = list->memory;
-
-
- if ( memory )
- {
- FT_FREE( list->field );
- FT_ZERO( list );
- }
- }
-
-
- static FT_Error
- bdf_list_ensure_( bdf_list_t_* list,
- unsigned long num_items ) /* same as bdf_list_t_.used */
- {
- FT_Error error = FT_Err_Ok;
-
-
- if ( num_items > list->size )
- {
- unsigned long oldsize = list->size; /* same as bdf_list_t_.size */
- unsigned long newsize = oldsize + ( oldsize >> 1 ) + 5;
- unsigned long bigsize = (unsigned long)( FT_INT_MAX / sizeof ( char* ) );
- FT_Memory memory = list->memory;
-
-
- if ( oldsize == bigsize )
- {
- error = FT_THROW( Out_Of_Memory );
- goto Exit;
- }
- else if ( newsize < oldsize || newsize > bigsize )
- newsize = bigsize;
-
- if ( FT_QRENEW_ARRAY( list->field, oldsize, newsize ) )
- goto Exit;
-
- list->size = newsize;
- }
-
- Exit:
- return error;
- }
-
-
- static void
- bdf_list_shift_( bdf_list_t_* list,
- unsigned long n )
- {
- unsigned long i, u;
-
-
- if ( list == NULL || list->used == 0 || n == 0 )
- return;
-
- if ( n >= list->used )
- {
- list->used = 0;
- return;
- }
-
- for ( u = n, i = 0; u < list->used; i++, u++ )
- list->field[i] = list->field[u];
- list->used -= n;
- }
-
-
- /* An empty string for empty fields. */
-
- static const char empty[] = ""; /* XXX eliminate this */
-
-
- static char *
- bdf_list_join_( bdf_list_t_* list,
- int c,
- unsigned long *alen )
- {
- unsigned long i, j;
- char* dp;
-
-
- *alen = 0;
-
- if ( list == NULL || list->used == 0 )
- return NULL;
-
- dp = list->field[0];
- for ( i = j = 0; i < list->used; i++ )
- {
- char* fp = list->field[i];
-
-
- while ( *fp )
- dp[j++] = *fp++;
-
- if ( i + 1 < list->used )
- dp[j++] = (char)c;
- }
- if ( dp != empty )
- dp[j] = 0;
-
- *alen = j;
- return dp;
- }
-
-
- /* The code below ensures that we have at least 4 + 1 `field' */
- /* elements in `list' (which are possibly NULL) so that we */
- /* don't have to check the number of fields in most cases. */
-
- static FT_Error
- bdf_list_split_( bdf_list_t_* list,
- const char* separators,
- char* line,
- unsigned long linelen )
- {
- unsigned long final_empty;
- int mult;
- const char *sp, *end;
- char *ep;
- char seps[32];
- FT_Error error = FT_Err_Ok;
-
-
- /* Initialize the list. */
- list->used = 0;
- if ( list->size )
- {
- list->field[0] = (char*)empty;
- list->field[1] = (char*)empty;
- list->field[2] = (char*)empty;
- list->field[3] = (char*)empty;
- list->field[4] = (char*)empty;
- }
-
- /* If the line is empty, then simply return. */
- if ( linelen == 0 || line[0] == 0 )
- goto Exit;
-
- /* In the original code, if the `separators' parameter is NULL or */
- /* empty, the list is split into individual bytes. We don't need */
- /* this, so an error is signaled. */
- if ( separators == NULL || *separators == 0 )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- /* Prepare the separator bitmap. */
- FT_MEM_ZERO( seps, 32 );
-
- /* If the very last character of the separator string is a plus, then */
- /* set the `mult' flag to indicate that multiple separators should be */
- /* collapsed into one. */
- for ( mult = 0, sp = separators; sp && *sp; sp++ )
- {
- if ( *sp == '+' && *( sp + 1 ) == 0 )
- mult = 1;
- else
- setsbit( seps, *sp );
- }
-
- /* Break the line up into fields. */
- for ( final_empty = 0, sp = ep = line, end = sp + linelen;
- sp < end && *sp; )
- {
- /* Collect everything that is not a separator. */
- for ( ; *ep && !sbitset( seps, *ep ); ep++ )
- ;
-
- /* Resize the list if necessary. */
- if ( list->used == list->size )
- {
- error = bdf_list_ensure_( list, list->used + 1 );
- if ( error )
- goto Exit;
- }
-
- /* Assign the field appropriately. */
- list->field[list->used++] = ( ep > sp ) ? (char*)sp : (char*)empty;
-
- sp = ep;
-
- if ( mult )
- {
- /* If multiple separators should be collapsed, do it now by */
- /* setting all the separator characters to 0. */
- for ( ; *ep && sbitset( seps, *ep ); ep++ )
- *ep = 0;
- }
- else if ( *ep != 0 )
- /* Don't collapse multiple separators by making them 0, so just */
- /* make the one encountered 0. */
- *ep++ = 0;
-
- final_empty = ( ep > sp && *ep == 0 );
- sp = ep;
- }
-
- /* Finally, NULL-terminate the list. */
- if ( list->used + final_empty >= list->size )
- {
- error = bdf_list_ensure_( list, list->used + final_empty + 1 );
- if ( error )
- goto Exit;
- }
-
- if ( final_empty )
- list->field[list->used++] = (char*)empty;
-
- list->field[list->used] = NULL;
-
- Exit:
- return error;
- }
-
-
-#define NO_SKIP 256 /* this value cannot be stored in a 'char' */
-
-
- static FT_Error
- bdf_readstream_( FT_Stream stream,
- bdf_line_func_t_ callback,
- void* client_data,
- unsigned long *lno )
- {
- bdf_line_func_t_ cb;
- unsigned long lineno, buf_size;
- int refill, hold, to_skip;
- ptrdiff_t bytes, start, end, cursor, avail;
- char* buf = NULL;
- FT_Memory memory = stream->memory;
- FT_Error error = FT_Err_Ok;
-
-
- if ( callback == NULL )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- /* initial size and allocation of the input buffer */
- buf_size = 1024;
-
- if ( FT_QALLOC( buf, buf_size ) )
- goto Exit;
-
- cb = callback;
- lineno = 1;
- buf[0] = 0;
- start = 0;
- avail = 0;
- cursor = 0;
- refill = 1;
- to_skip = NO_SKIP;
- bytes = 0; /* make compiler happy */
-
- for (;;)
- {
- if ( refill )
- {
- bytes = (ptrdiff_t)FT_Stream_TryRead(
- stream, (FT_Byte*)buf + cursor,
- buf_size - (unsigned long)cursor );
- avail = cursor + bytes;
- cursor = 0;
- refill = 0;
- }
-
- end = start;
-
- /* should we skip an optional character like \n or \r? */
- if ( start < avail && buf[start] == to_skip )
- {
- start += 1;
- to_skip = NO_SKIP;
- continue;
- }
-
- /* try to find the end of the line */
- while ( end < avail && buf[end] != '\n' && buf[end] != '\r' )
- end++;
-
- /* if we hit the end of the buffer, try shifting its content */
- /* or even resizing it */
- if ( end >= avail )
- {
- if ( bytes == 0 )
- {
- /* last line in file doesn't end in \r or \n; */
- /* ignore it then exit */
- if ( lineno == 1 )
- error = FT_THROW( Missing_Startfont_Field );
- break;
- }
-
- if ( start == 0 )
- {
- /* this line is definitely too long; try resizing the input */
- /* buffer a bit to handle it. */
- FT_ULong new_size;
-
-
- if ( buf_size >= 65536UL ) /* limit ourselves to 64KByte */
- {
- if ( lineno == 1 )
- error = FT_THROW( Missing_Startfont_Field );
- else
- {
- FT_ERROR(( "bdf_readstream_: " ERRMSG6, lineno ));
- error = FT_THROW( Invalid_Argument );
- }
- goto Exit;
- }
-
- new_size = buf_size * 2;
- if ( FT_QREALLOC( buf, buf_size, new_size ) )
- goto Exit;
-
- cursor = avail;
- buf_size = new_size;
- }
- else
- {
- bytes = avail - start;
-
- FT_MEM_MOVE( buf, buf + start, bytes );
-
- cursor = bytes;
- start = 0;
- }
- refill = 1;
- continue;
- }
-
- /* Temporarily NUL-terminate the line. */
- hold = buf[end];
- buf[end] = 0;
-
- /* XXX: Use encoding independent value for 0x1A */
- if ( buf[start] != '#' && buf[start] != 0x1A && end > start )
- {
- error = (*cb)( buf + start, (unsigned long)( end - start ), lineno,
- (void*)&cb, client_data );
- /* Redo if we have encountered CHARS without properties. */
- if ( error == -1 )
- error = (*cb)( buf + start, (unsigned long)( end - start ), lineno,
- (void*)&cb, client_data );
- if ( error )
- break;
- }
-
- lineno += 1;
- buf[end] = (char)hold;
- start = end + 1;
-
- if ( hold == '\n' )
- to_skip = '\r';
- else if ( hold == '\r' )
- to_skip = '\n';
- else
- to_skip = NO_SKIP;
- }
-
- *lno = lineno;
-
- Exit:
- FT_FREE( buf );
- return error;
- }
-
-
- /* XXX: make this work with EBCDIC also */
-
- static const unsigned char a2i[128] =
- {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
- };
-
- static const unsigned char ddigits[32] =
- {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x03,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- };
-
- static const unsigned char hdigits[32] =
- {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x03,
- 0x7E, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- };
-
-
- /* Routine to convert a decimal ASCII string to an unsigned long integer. */
- static unsigned long
- bdf_atoul_( const char* s )
- {
- unsigned long v;
-
-
- if ( s == NULL || *s == 0 )
- return 0;
-
- for ( v = 0; sbitset( ddigits, *s ); s++ )
- {
- if ( v < ( FT_ULONG_MAX - 9 ) / 10 )
- v = v * 10 + a2i[(int)*s];
- else
- {
- v = FT_ULONG_MAX;
- break;
- }
- }
-
- return v;
- }
-
-
- /* Routine to convert a decimal ASCII string to a signed long integer. */
- static long
- bdf_atol_( const char* s )
- {
- long v, neg;
-
-
- if ( s == NULL || *s == 0 )
- return 0;
-
- /* Check for a minus sign. */
- neg = 0;
- if ( *s == '-' )
- {
- s++;
- neg = 1;
- }
-
- for ( v = 0; sbitset( ddigits, *s ); s++ )
- {
- if ( v < ( FT_LONG_MAX - 9 ) / 10 )
- v = v * 10 + a2i[(int)*s];
- else
- {
- v = FT_LONG_MAX;
- break;
- }
- }
-
- return ( !neg ) ? v : -v;
- }
-
-
- /* Routine to convert a decimal ASCII string to an unsigned short integer. */
- static unsigned short
- bdf_atous_( const char* s )
- {
- unsigned short v;
-
-
- if ( s == NULL || *s == 0 )
- return 0;
-
- for ( v = 0; sbitset( ddigits, *s ); s++ )
- {
- if ( v < ( FT_USHORT_MAX - 9 ) / 10 )
- v = (unsigned short)( v * 10 + a2i[(int)*s] );
- else
- {
- v = FT_USHORT_MAX;
- break;
- }
- }
-
- return v;
- }
-
-
- /* Routine to convert a decimal ASCII string to a signed short integer. */
- static short
- bdf_atos_( const char* s )
- {
- short v, neg;
-
-
- if ( s == NULL || *s == 0 )
- return 0;
-
- /* Check for a minus. */
- neg = 0;
- if ( *s == '-' )
- {
- s++;
- neg = 1;
- }
-
- for ( v = 0; sbitset( ddigits, *s ); s++ )
- {
- if ( v < ( SHRT_MAX - 9 ) / 10 )
- v = (short)( v * 10 + a2i[(int)*s] );
- else
- {
- v = SHRT_MAX;
- break;
- }
- }
-
- return (short)( ( !neg ) ? v : -v );
- }
-
-
- /* Routine to compare two glyphs by encoding so they can be sorted. */
- FT_COMPARE_DEF( int )
- by_encoding( const void* a,
- const void* b )
- {
- bdf_glyph_t *c1, *c2;
-
-
- c1 = (bdf_glyph_t *)a;
- c2 = (bdf_glyph_t *)b;
-
- if ( c1->encoding < c2->encoding )
- return -1;
-
- if ( c1->encoding > c2->encoding )
- return 1;
-
- return 0;
- }
-
-
- static FT_Error
- bdf_create_property( const char* name,
- int format,
- bdf_font_t* font )
- {
- size_t n;
- bdf_property_t* p;
- FT_Memory memory = font->memory;
- FT_Error error = FT_Err_Ok;
-
-
- /* First check whether the property has */
- /* already been added or not. If it has, then */
- /* simply ignore it. */
- if ( ft_hash_str_lookup( name, &(font->proptbl) ) )
- goto Exit;
-
- if ( FT_QRENEW_ARRAY( font->user_props,
- font->nuser_props,
- font->nuser_props + 1 ) )
- goto Exit;
-
- p = font->user_props + font->nuser_props;
-
- if ( FT_STRDUP( p->name, name ) )
- goto Exit;
-
- p->format = format;
- p->builtin = 0;
- p->value.atom = NULL; /* nothing is ever stored here */
-
- n = num_bdf_properties_ + font->nuser_props;
-
- error = ft_hash_str_insert( p->name, n, &(font->proptbl), memory );
- if ( error )
- goto Exit;
-
- font->nuser_props++;
-
- Exit:
- return error;
- }
-
-
- static bdf_property_t*
- bdf_get_property( const char* name,
- bdf_font_t* font )
- {
- size_t* propid;
-
-
- if ( name == NULL || *name == 0 )
- return NULL;
-
- if ( ( propid = ft_hash_str_lookup( name, &(font->proptbl) ) ) == NULL )
- return NULL;
-
- if ( *propid >= num_bdf_properties_ )
- return font->user_props + ( *propid - num_bdf_properties_ );
-
- return (bdf_property_t*)bdf_properties_ + *propid;
- }
-
-
- /**************************************************************************
- *
- * BDF font file parsing flags and functions.
- *
- */
-
-
- /* Parse flags. */
-
-#define BDF_START_ 0x0001U
-#define BDF_FONT_NAME_ 0x0002U
-#define BDF_SIZE_ 0x0004U
-#define BDF_FONT_BBX_ 0x0008U
-#define BDF_PROPS_ 0x0010U
-#define BDF_GLYPHS_ 0x0020U
-#define BDF_GLYPH_ 0x0040U
-#define BDF_ENCODING_ 0x0080U
-#define BDF_SWIDTH_ 0x0100U
-#define BDF_DWIDTH_ 0x0200U
-#define BDF_BBX_ 0x0400U
-#define BDF_BITMAP_ 0x0800U
-
-#define BDF_SWIDTH_ADJ_ 0x1000U
-
-#define BDF_GLYPH_BITS_ ( BDF_GLYPH_ | \
- BDF_ENCODING_ | \
- BDF_SWIDTH_ | \
- BDF_DWIDTH_ | \
- BDF_BBX_ | \
- BDF_BITMAP_ )
-
-#define BDF_GLYPH_WIDTH_CHECK_ 0x40000000UL
-#define BDF_GLYPH_HEIGHT_CHECK_ 0x80000000UL
-
-
- static FT_Error
- bdf_add_comment_( bdf_font_t* font,
- const char* comment,
- unsigned long len )
- {
- char* cp;
- FT_Memory memory = font->memory;
- FT_Error error = FT_Err_Ok;
-
-
- if ( FT_QRENEW_ARRAY( font->comments,
- font->comments_len,
- font->comments_len + len + 1 ) )
- goto Exit;
-
- cp = font->comments + font->comments_len;
-
- FT_MEM_COPY( cp, comment, len );
- cp[len] = '\0';
-
- font->comments_len += len + 1;
-
- Exit:
- return error;
- }
-
-
- /* Set the spacing from the font name if it exists, or set it to the */
- /* default specified in the options. */
- static FT_Error
- bdf_set_default_spacing_( bdf_font_t* font,
- bdf_options_t* opts,
- unsigned long lineno )
- {
- size_t len;
- char name[256];
- bdf_list_t_ list;
- FT_Memory memory;
- FT_Error error = FT_Err_Ok;
-
- FT_UNUSED( lineno ); /* only used in debug mode */
-
-
- if ( font == NULL || font->name == NULL || font->name[0] == 0 )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- memory = font->memory;
-
- bdf_list_init_( &list, memory );
-
- font->spacing = opts->font_spacing;
-
- len = ft_strlen( font->name ) + 1;
- /* Limit ourselves to 256 characters in the font name. */
- if ( len >= 256 )
- {
- FT_ERROR(( "bdf_set_default_spacing_: " ERRMSG7, lineno ));
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- FT_MEM_COPY( name, font->name, len );
-
- error = bdf_list_split_( &list, "-", name, (unsigned long)len );
- if ( error )
- goto Fail;
-
- if ( list.used == 15 )
- {
- switch ( list.field[11][0] )
- {
- case 'C':
- case 'c':
- font->spacing = BDF_CHARCELL;
- break;
- case 'M':
- case 'm':
- font->spacing = BDF_MONOWIDTH;
- break;
- case 'P':
- case 'p':
- font->spacing = BDF_PROPORTIONAL;
- break;
- }
- }
-
- Fail:
- bdf_list_done_( &list );
-
- Exit:
- return error;
- }
-
-
- /* Determine whether the property is an atom or not. If it is, then */
- /* clean it up so the double quotes are removed if they exist. */
- static int
- bdf_is_atom_( char* line,
- unsigned long linelen,
- char** name,
- char** value,
- bdf_font_t* font )
- {
- int hold;
- char *sp, *ep;
- bdf_property_t* p;
-
-
- sp = ep = line;
-
- while ( *ep && *ep != ' ' && *ep != '\t' )
- ep++;
-
- hold = *ep;
- *ep = '\0';
-
- p = bdf_get_property( sp, font );
-
- /* If the property exists and is not an atom, just return here. */
- if ( p && p->format != BDF_ATOM )
- {
- *ep = (char)hold; /* Undo NUL-termination. */
- return 0;
- }
-
- *name = sp;
-
- /* The property is an atom. Trim all leading and trailing whitespace */
- /* and double quotes for the atom value. */
- sp = ep;
- ep = line + linelen;
-
- /* Trim the leading whitespace if it exists. */
- if ( sp < ep )
- do
- sp++;
- while ( *sp == ' ' || *sp == '\t' );
-
- /* Trim the leading double quote if it exists. */
- if ( *sp == '"' )
- sp++;
-
- *value = sp;
-
- /* Trim the trailing whitespace if it exists. */
- if ( sp < ep )
- do
- *ep-- = '\0';
- while ( *ep == ' ' || *ep == '\t' );
-
- /* Trim the trailing double quote if it exists. */
- if ( *ep == '"' )
- *ep = '\0';
-
- return 1;
- }
-
-
- static FT_Error
- bdf_add_property_( bdf_font_t* font,
- const char* name,
- char* value,
- unsigned long lineno )
- {
- size_t* propid;
- bdf_property_t *prop, *fp;
- FT_Memory memory = font->memory;
- FT_Error error = FT_Err_Ok;
-
- FT_UNUSED( lineno ); /* only used in debug mode */
-
-
- /* First, check whether the property already exists in the font. */
- if ( ( propid = ft_hash_str_lookup( name,
- (FT_Hash)font->internal ) ) != NULL )
- {
- /* The property already exists in the font, so simply replace */
- /* the value of the property with the current value. */
- fp = font->props + *propid;
-
- switch ( fp->format )
- {
- case BDF_ATOM:
- /* Delete the current atom if it exists. */
- FT_FREE( fp->value.atom );
-
- if ( value && value[0] != 0 )
- {
- if ( FT_STRDUP( fp->value.atom, value ) )
- goto Exit;
- }
- break;
-
- case BDF_INTEGER:
- fp->value.l = bdf_atol_( value );
- break;
-
- case BDF_CARDINAL:
- fp->value.ul = bdf_atoul_( value );
- break;
-
- default:
- ;
- }
-
- goto Exit;
- }
-
- /* See whether this property type exists yet or not. */
- /* If not, create it. */
- propid = ft_hash_str_lookup( name, &(font->proptbl) );
- if ( !propid )
- {
- error = bdf_create_property( name, BDF_ATOM, font );
- if ( error )
- goto Exit;
- propid = ft_hash_str_lookup( name, &(font->proptbl) );
- }
-
- /* Allocate another property if this is overflowing. */
- if ( font->props_used == font->props_size )
- {
- if ( FT_QRENEW_ARRAY( font->props,
- font->props_size,
- font->props_size + 1 ) )
- goto Exit;
-
- font->props_size++;
- }
-
- if ( *propid >= num_bdf_properties_ )
- prop = font->user_props + ( *propid - num_bdf_properties_ );
- else
- prop = (bdf_property_t*)bdf_properties_ + *propid;
-
- fp = font->props + font->props_used;
-
- fp->name = prop->name;
- fp->format = prop->format;
- fp->builtin = prop->builtin;
-
- switch ( prop->format )
- {
- case BDF_ATOM:
- fp->value.atom = NULL;
- if ( value && value[0] )
- {
- if ( FT_STRDUP( fp->value.atom, value ) )
- goto Exit;
- }
- break;
-
- case BDF_INTEGER:
- fp->value.l = bdf_atol_( value );
- break;
-
- case BDF_CARDINAL:
- fp->value.ul = bdf_atoul_( value );
- break;
- }
-
- /* If the property happens to be a comment, then it doesn't need */
- /* to be added to the internal hash table. */
- if ( _bdf_strncmp( name, "COMMENT", 7 ) != 0 )
- {
- /* Add the property to the font property table. */
- error = ft_hash_str_insert( fp->name,
- font->props_used,
- (FT_Hash)font->internal,
- memory );
- if ( error )
- goto Exit;
- }
-
- font->props_used++;
-
- /* Some special cases need to be handled here. The DEFAULT_CHAR */
- /* property needs to be located if it exists in the property list, the */
- /* FONT_ASCENT and FONT_DESCENT need to be assigned if they are */
- /* present, and the SPACING property should override the default */
- /* spacing. */
- if ( _bdf_strncmp( name, "DEFAULT_CHAR", 12 ) == 0 )
- font->default_char = fp->value.ul;
- else if ( _bdf_strncmp( name, "FONT_ASCENT", 11 ) == 0 )
- font->font_ascent = fp->value.l;
- else if ( _bdf_strncmp( name, "FONT_DESCENT", 12 ) == 0 )
- font->font_descent = fp->value.l;
- else if ( _bdf_strncmp( name, "SPACING", 7 ) == 0 )
- {
- if ( !fp->value.atom )
- {
- FT_ERROR(( "bdf_add_property_: " ERRMSG8, lineno, "SPACING" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- if ( fp->value.atom[0] == 'p' || fp->value.atom[0] == 'P' )
- font->spacing = BDF_PROPORTIONAL;
- else if ( fp->value.atom[0] == 'm' || fp->value.atom[0] == 'M' )
- font->spacing = BDF_MONOWIDTH;
- else if ( fp->value.atom[0] == 'c' || fp->value.atom[0] == 'C' )
- font->spacing = BDF_CHARCELL;
- }
-
- Exit:
- return error;
- }
-
-
- static const unsigned char nibble_mask[8] =
- {
- 0xFF, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE
- };
-
-
- static FT_Error
- bdf_parse_end_( char* line,
- unsigned long linelen,
- unsigned long lineno,
- void* call_data,
- void* client_data )
- {
- /* a no-op; we ignore everything after `ENDFONT' */
-
- FT_UNUSED( line );
- FT_UNUSED( linelen );
- FT_UNUSED( lineno );
- FT_UNUSED( call_data );
- FT_UNUSED( client_data );
-
- return FT_Err_Ok;
- }
-
-
- /* Actually parse the glyph info and bitmaps. */
- static FT_Error
- bdf_parse_glyphs_( char* line,
- unsigned long linelen,
- unsigned long lineno,
- void* call_data,
- void* client_data )
- {
- int c, mask_index;
- char* s;
- unsigned char* bp;
- unsigned long i, slen, nibbles;
-
- bdf_line_func_t_* next;
- bdf_parse_t_* p;
- bdf_glyph_t* glyph;
- bdf_font_t* font;
-
- FT_Memory memory;
- FT_Error error = FT_Err_Ok;
-
- FT_UNUSED( lineno ); /* only used in debug mode */
-
-
- next = (bdf_line_func_t_ *)call_data;
- p = (bdf_parse_t_ *) client_data;
-
- font = p->font;
- memory = font->memory;
-
- /* Check for a comment. */
- if ( _bdf_strncmp( line, "COMMENT", 7 ) == 0 )
- {
- if ( p->opts->keep_comments )
- {
- linelen -= 7;
-
- s = line + 7;
- if ( *s != 0 )
- {
- s++;
- linelen--;
- }
- error = bdf_add_comment_( p->font, s, linelen );
- }
- goto Exit;
- }
-
- /* The very first thing expected is the number of glyphs. */
- if ( !( p->flags & BDF_GLYPHS_ ) )
- {
- if ( _bdf_strncmp( line, "CHARS", 5 ) != 0 )
- {
- FT_ERROR(( "bdf_parse_glyphs_: " ERRMSG1, lineno, "CHARS" ));
- error = FT_THROW( Missing_Chars_Field );
- goto Exit;
- }
-
- error = bdf_list_split_( &p->list, " +", line, linelen );
- if ( error )
- goto Exit;
- p->cnt = font->glyphs_size = bdf_atoul_( p->list.field[1] );
-
- /* We need at least 20 bytes per glyph. */
- if ( p->cnt > p->size / 20 )
- {
- p->cnt = font->glyphs_size = p->size / 20;
- FT_TRACE2(( "bdf_parse_glyphs_: " ACMSG17, p->cnt ));
- }
-
- /* Make sure the number of glyphs is non-zero. */
- if ( p->cnt == 0 )
- font->glyphs_size = 64;
-
- /* Limit ourselves to 1,114,112 glyphs in the font (this is the */
- /* number of code points available in Unicode). */
- if ( p->cnt >= 0x110000UL )
- {
- FT_ERROR(( "bdf_parse_glyphs_: " ERRMSG5, lineno, "CHARS" ));
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- if ( FT_NEW_ARRAY( font->glyphs, font->glyphs_size ) )
- goto Exit;
-
- p->flags |= BDF_GLYPHS_;
-
- goto Exit;
- }
-
- /* Check for the ENDFONT field. */
- if ( _bdf_strncmp( line, "ENDFONT", 7 ) == 0 )
- {
- if ( p->flags & BDF_GLYPH_BITS_ )
- {
- /* Missing ENDCHAR field. */
- FT_ERROR(( "bdf_parse_glyphs_: " ERRMSG1, lineno, "ENDCHAR" ));
- error = FT_THROW( Corrupted_Font_Glyphs );
- goto Exit;
- }
-
- /* Sort the glyphs by encoding. */
- ft_qsort( (char *)font->glyphs,
- font->glyphs_used,
- sizeof ( bdf_glyph_t ),
- by_encoding );
-
- p->flags &= ~BDF_START_;
- *next = bdf_parse_end_;
-
- goto Exit;
- }
-
- /* Check for the ENDCHAR field. */
- if ( _bdf_strncmp( line, "ENDCHAR", 7 ) == 0 )
- {
- p->glyph_enc = 0;
- p->flags &= ~BDF_GLYPH_BITS_;
-
- goto Exit;
- }
-
- /* Check whether a glyph is being scanned but should be */
- /* ignored because it is an unencoded glyph. */
- if ( ( p->flags & BDF_GLYPH_ ) &&
- p->glyph_enc == -1 &&
- p->opts->keep_unencoded == 0 )
- goto Exit;
-
- /* Check for the STARTCHAR field. */
- if ( _bdf_strncmp( line, "STARTCHAR", 9 ) == 0 )
- {
- if ( p->flags & BDF_GLYPH_BITS_ )
- {
- /* Missing ENDCHAR field. */
- FT_ERROR(( "bdf_parse_glyphs_: " ERRMSG1, lineno, "ENDCHAR" ));
- error = FT_THROW( Missing_Startchar_Field );
- goto Exit;
- }
-
- /* Set the character name in the parse info first until the */
- /* encoding can be checked for an unencoded character. */
- FT_FREE( p->glyph_name );
-
- error = bdf_list_split_( &p->list, " +", line, linelen );
- if ( error )
- goto Exit;
-
- bdf_list_shift_( &p->list, 1 );
-
- s = bdf_list_join_( &p->list, ' ', &slen );
-
- if ( !s )
- {
- FT_ERROR(( "bdf_parse_glyphs_: " ERRMSG8, lineno, "STARTCHAR" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- if ( FT_DUP( p->glyph_name, s, slen + 1 ) )
- goto Exit;
-
- p->flags |= BDF_GLYPH_;
-
- FT_TRACE4(( DBGMSG1, lineno, s ));
-
- goto Exit;
- }
-
- /* Check for the ENCODING field. */
- if ( _bdf_strncmp( line, "ENCODING", 8 ) == 0 )
- {
- if ( !( p->flags & BDF_GLYPH_ ) )
- {
- /* Missing STARTCHAR field. */
- FT_ERROR(( "bdf_parse_glyphs_: " ERRMSG1, lineno, "STARTCHAR" ));
- error = FT_THROW( Missing_Startchar_Field );
- goto Exit;
- }
-
- error = bdf_list_split_( &p->list, " +", line, linelen );
- if ( error )
- goto Exit;
-
- p->glyph_enc = bdf_atol_( p->list.field[1] );
-
- /* Normalize negative encoding values. The specification only */
- /* allows -1, but we can be more generous here. */
- if ( p->glyph_enc < -1 )
- p->glyph_enc = -1;
-
- /* Check for alternative encoding format. */
- if ( p->glyph_enc == -1 && p->list.used > 2 )
- p->glyph_enc = bdf_atol_( p->list.field[2] );
-
- if ( p->glyph_enc < -1 || p->glyph_enc >= 0x110000L )
- p->glyph_enc = -1;
-
- FT_TRACE4(( DBGMSG2, p->glyph_enc ));
-
- if ( p->glyph_enc >= 0 )
- {
- /* Make sure there are enough glyphs allocated in case the */
- /* number of characters happen to be wrong. */
- if ( font->glyphs_used == font->glyphs_size )
- {
- if ( FT_RENEW_ARRAY( font->glyphs,
- font->glyphs_size,
- font->glyphs_size + 64 ) )
- goto Exit;
-
- font->glyphs_size += 64;
- }
-
- glyph = font->glyphs + font->glyphs_used++;
- glyph->name = p->glyph_name;
- glyph->encoding = (unsigned long)p->glyph_enc;
-
- /* Reset the initial glyph info. */
- p->glyph_name = NULL;
- }
- else
- {
- /* Unencoded glyph. Check whether it should */
- /* be added or not. */
- if ( p->opts->keep_unencoded )
- {
- /* Allocate the next unencoded glyph. */
- if ( font->unencoded_used == font->unencoded_size )
- {
- if ( FT_RENEW_ARRAY( font->unencoded ,
- font->unencoded_size,
- font->unencoded_size + 4 ) )
- goto Exit;
-
- font->unencoded_size += 4;
- }
-
- glyph = font->unencoded + font->unencoded_used;
- glyph->name = p->glyph_name;
- glyph->encoding = font->unencoded_used++;
-
- /* Reset the initial glyph info. */
- p->glyph_name = NULL;
- }
- else
- {
- /* Free up the glyph name if the unencoded shouldn't be */
- /* kept. */
- FT_FREE( p->glyph_name );
- }
- }
-
- /* Clear the flags that might be added when width and height are */
- /* checked for consistency. */
- p->flags &= ~( BDF_GLYPH_WIDTH_CHECK_ | BDF_GLYPH_HEIGHT_CHECK_ );
-
- p->flags |= BDF_ENCODING_;
-
- goto Exit;
- }
-
- if ( !( p->flags & BDF_ENCODING_ ) )
- goto Missing_Encoding;
-
- /* Point at the glyph being constructed. */
- if ( p->glyph_enc == -1 )
- glyph = font->unencoded + ( font->unencoded_used - 1 );
- else
- glyph = font->glyphs + ( font->glyphs_used - 1 );
-
- /* Check whether a bitmap is being constructed. */
- if ( p->flags & BDF_BITMAP_ )
- {
- /* If there are more rows than are specified in the glyph metrics, */
- /* ignore the remaining lines. */
- if ( p->row >= (unsigned long)glyph->bbx.height )
- {
- if ( !( p->flags & BDF_GLYPH_HEIGHT_CHECK_ ) )
- {
- FT_TRACE2(( "bdf_parse_glyphs_: " ACMSG13, glyph->encoding ));
- p->flags |= BDF_GLYPH_HEIGHT_CHECK_;
- }
-
- goto Exit;
- }
-
- /* Only collect the number of nibbles indicated by the glyph */
- /* metrics. If there are more columns, they are simply ignored. */
- nibbles = glyph->bpr << 1;
- bp = glyph->bitmap + p->row * glyph->bpr;
-
- for ( i = 0; i < nibbles; i++ )
- {
- c = line[i];
- if ( !sbitset( hdigits, c ) )
- break;
- *bp = (FT_Byte)( ( *bp << 4 ) + a2i[c] );
- if ( i + 1 < nibbles && ( i & 1 ) )
- *++bp = 0;
- }
-
- /* If any line has not enough columns, */
- /* indicate they have been padded with zero bits. */
- if ( i < nibbles &&
- !( p->flags & BDF_GLYPH_WIDTH_CHECK_ ) )
- {
- FT_TRACE2(( "bdf_parse_glyphs_: " ACMSG16, glyph->encoding ));
- p->flags |= BDF_GLYPH_WIDTH_CHECK_;
- }
-
- /* Remove possible garbage at the right. */
- mask_index = ( glyph->bbx.width * p->font->bpp ) & 7;
- if ( glyph->bbx.width )
- *bp &= nibble_mask[mask_index];
-
- /* If any line has extra columns, indicate they have been removed. */
- if ( i == nibbles &&
- sbitset( hdigits, line[nibbles] ) &&
- !( p->flags & BDF_GLYPH_WIDTH_CHECK_ ) )
- {
- FT_TRACE2(( "bdf_parse_glyphs_: " ACMSG14, glyph->encoding ));
- p->flags |= BDF_GLYPH_WIDTH_CHECK_;
- }
-
- p->row++;
- goto Exit;
- }
-
- /* Expect the SWIDTH (scalable width) field next. */
- if ( _bdf_strncmp( line, "SWIDTH", 6 ) == 0 )
- {
- error = bdf_list_split_( &p->list, " +", line, linelen );
- if ( error )
- goto Exit;
-
- glyph->swidth = bdf_atous_( p->list.field[1] );
- p->flags |= BDF_SWIDTH_;
-
- goto Exit;
- }
-
- /* Expect the DWIDTH (device width) field next. */
- if ( _bdf_strncmp( line, "DWIDTH", 6 ) == 0 )
- {
- error = bdf_list_split_( &p->list, " +", line, linelen );
- if ( error )
- goto Exit;
-
- glyph->dwidth = bdf_atous_( p->list.field[1] );
-
- if ( !( p->flags & BDF_SWIDTH_ ) )
- {
- /* Missing SWIDTH field. Emit an auto correction message and set */
- /* the scalable width from the device width. */
- FT_TRACE2(( "bdf_parse_glyphs_: " ACMSG9, lineno ));
-
- glyph->swidth = (unsigned short)FT_MulDiv(
- glyph->dwidth, 72000L,
- (FT_Long)( font->point_size *
- font->resolution_x ) );
- }
-
- p->flags |= BDF_DWIDTH_;
- goto Exit;
- }
-
- /* Expect the BBX field next. */
- if ( _bdf_strncmp( line, "BBX", 3 ) == 0 )
- {
- error = bdf_list_split_( &p->list, " +", line, linelen );
- if ( error )
- goto Exit;
-
- glyph->bbx.width = bdf_atous_( p->list.field[1] );
- glyph->bbx.height = bdf_atous_( p->list.field[2] );
- glyph->bbx.x_offset = bdf_atos_( p->list.field[3] );
- glyph->bbx.y_offset = bdf_atos_( p->list.field[4] );
-
- /* Generate the ascent and descent of the character. */
- glyph->bbx.ascent = (short)( glyph->bbx.height + glyph->bbx.y_offset );
- glyph->bbx.descent = (short)( -glyph->bbx.y_offset );
-
- /* Determine the overall font bounding box as the characters are */
- /* loaded so corrections can be done later if indicated. */
- p->maxas = (short)FT_MAX( glyph->bbx.ascent, p->maxas );
- p->maxds = (short)FT_MAX( glyph->bbx.descent, p->maxds );
-
- p->rbearing = (short)( glyph->bbx.width + glyph->bbx.x_offset );
-
- p->maxrb = (short)FT_MAX( p->rbearing, p->maxrb );
- p->minlb = (short)FT_MIN( glyph->bbx.x_offset, p->minlb );
- p->maxlb = (short)FT_MAX( glyph->bbx.x_offset, p->maxlb );
-
- if ( !( p->flags & BDF_DWIDTH_ ) )
- {
- /* Missing DWIDTH field. Emit an auto correction message and set */
- /* the device width to the glyph width. */
- FT_TRACE2(( "bdf_parse_glyphs_: " ACMSG10, lineno ));
- glyph->dwidth = glyph->bbx.width;
- }
-
- /* If the BDF_CORRECT_METRICS flag is set, then adjust the SWIDTH */
- /* value if necessary. */
- if ( p->opts->correct_metrics )
- {
- /* Determine the point size of the glyph. */
- unsigned short sw = (unsigned short)FT_MulDiv(
- glyph->dwidth, 72000L,
- (FT_Long)( font->point_size *
- font->resolution_x ) );
-
-
- if ( sw != glyph->swidth )
- {
- glyph->swidth = sw;
-
- p->flags |= BDF_SWIDTH_ADJ_;
- }
- }
-
- p->flags |= BDF_BBX_;
- goto Exit;
- }
-
- /* And finally, gather up the bitmap. */
- if ( _bdf_strncmp( line, "BITMAP", 6 ) == 0 )
- {
- unsigned long bitmap_size;
-
-
- if ( !( p->flags & BDF_BBX_ ) )
- {
- /* Missing BBX field. */
- FT_ERROR(( "bdf_parse_glyphs_: " ERRMSG1, lineno, "BBX" ));
- error = FT_THROW( Missing_Bbx_Field );
- goto Exit;
- }
-
- /* Allocate enough space for the bitmap. */
- glyph->bpr = ( glyph->bbx.width * p->font->bpp + 7 ) >> 3;
-
- bitmap_size = glyph->bpr * glyph->bbx.height;
- if ( glyph->bpr > 0xFFFFU || bitmap_size > 0xFFFFU )
- {
- FT_ERROR(( "bdf_parse_glyphs_: " ERRMSG4, lineno ));
- error = FT_THROW( Bbx_Too_Big );
- goto Exit;
- }
- else
- glyph->bytes = (unsigned short)bitmap_size;
-
- if ( FT_ALLOC( glyph->bitmap, glyph->bytes ) )
- goto Exit;
-
- p->row = 0;
- p->flags |= BDF_BITMAP_;
-
- goto Exit;
- }
-
- FT_ERROR(( "bdf_parse_glyphs_: " ERRMSG9, lineno ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
-
- Missing_Encoding:
- /* Missing ENCODING field. */
- FT_ERROR(( "bdf_parse_glyphs_: " ERRMSG1, lineno, "ENCODING" ));
- error = FT_THROW( Missing_Encoding_Field );
-
- Exit:
- if ( error && ( p->flags & BDF_GLYPH_ ) )
- FT_FREE( p->glyph_name );
-
- return error;
- }
-
-
- /* Load the font properties. */
- static FT_Error
- bdf_parse_properties_( char* line,
- unsigned long linelen,
- unsigned long lineno,
- void* call_data,
- void* client_data )
- {
- unsigned long vlen;
- bdf_line_func_t_* next;
- bdf_parse_t_* p;
- char* name;
- char* value;
- char nbuf[BUFSIZE];
- FT_Error error = FT_Err_Ok;
-
- FT_UNUSED( lineno );
-
-
- next = (bdf_line_func_t_ *)call_data;
- p = (bdf_parse_t_ *) client_data;
-
- /* Check for the end of the properties. */
- if ( _bdf_strncmp( line, "ENDPROPERTIES", 13 ) == 0 )
- {
- /* If the FONT_ASCENT or FONT_DESCENT properties have not been */
- /* encountered yet, then make sure they are added as properties and */
- /* make sure they are set from the font bounding box info. */
- /* */
- /* This is *always* done regardless of the options, because X11 */
- /* requires these two fields to compile fonts. */
- if ( bdf_get_font_property( p->font, "FONT_ASCENT" ) == 0 )
- {
- p->font->font_ascent = p->font->bbx.ascent;
- ft_snprintf( nbuf, BUFSIZE, "%hd", p->font->bbx.ascent );
- error = bdf_add_property_( p->font, "FONT_ASCENT",
- nbuf, lineno );
- if ( error )
- goto Exit;
-
- FT_TRACE2(( "bdf_parse_properties_: " ACMSG1, p->font->bbx.ascent ));
- }
-
- if ( bdf_get_font_property( p->font, "FONT_DESCENT" ) == 0 )
- {
- p->font->font_descent = p->font->bbx.descent;
- ft_snprintf( nbuf, BUFSIZE, "%hd", p->font->bbx.descent );
- error = bdf_add_property_( p->font, "FONT_DESCENT",
- nbuf, lineno );
- if ( error )
- goto Exit;
-
- FT_TRACE2(( "bdf_parse_properties_: " ACMSG2, p->font->bbx.descent ));
- }
-
- p->flags &= ~BDF_PROPS_;
- *next = bdf_parse_glyphs_;
-
- goto Exit;
- }
-
- /* Ignore the _XFREE86_GLYPH_RANGES properties. */
- if ( _bdf_strncmp( line, "_XFREE86_GLYPH_RANGES", 21 ) == 0 )
- goto Exit;
-
- /* Handle COMMENT fields and properties in a special way to preserve */
- /* the spacing. */
- if ( _bdf_strncmp( line, "COMMENT", 7 ) == 0 )
- {
- name = value = line;
- value += 7;
- if ( *value )
- *value++ = 0;
- error = bdf_add_property_( p->font, name, value, lineno );
- if ( error )
- goto Exit;
- }
- else if ( bdf_is_atom_( line, linelen, &name, &value, p->font ) )
- {
- error = bdf_add_property_( p->font, name, value, lineno );
- if ( error )
- goto Exit;
- }
- else
- {
- error = bdf_list_split_( &p->list, " +", line, linelen );
- if ( error )
- goto Exit;
- name = p->list.field[0];
-
- bdf_list_shift_( &p->list, 1 );
- value = bdf_list_join_( &p->list, ' ', &vlen );
-
- error = bdf_add_property_( p->font, name, value, lineno );
- if ( error )
- goto Exit;
- }
-
- Exit:
- return error;
- }
-
-
- /* Load the font header. */
- static FT_Error
- bdf_parse_start_( char* line,
- unsigned long linelen,
- unsigned long lineno,
- void* call_data,
- void* client_data )
- {
- unsigned long slen;
- bdf_line_func_t_* next;
- bdf_parse_t_* p;
- bdf_font_t* font;
- char *s;
-
- FT_Memory memory = NULL;
- FT_Error error = FT_Err_Ok;
-
- FT_UNUSED( lineno ); /* only used in debug mode */
-
-
- next = (bdf_line_func_t_ *)call_data;
- p = (bdf_parse_t_ *) client_data;
-
- if ( p->font )
- memory = p->font->memory;
-
- /* Check for a comment. This is done to handle those fonts that have */
- /* comments before the STARTFONT line for some reason. */
- if ( _bdf_strncmp( line, "COMMENT", 7 ) == 0 )
- {
- if ( p->opts->keep_comments && p->font )
- {
- linelen -= 7;
-
- s = line + 7;
- if ( *s != 0 )
- {
- s++;
- linelen--;
- }
- error = bdf_add_comment_( p->font, s, linelen );
- }
- goto Exit;
- }
-
- if ( !( p->flags & BDF_START_ ) )
- {
- memory = p->memory;
-
- if ( _bdf_strncmp( line, "STARTFONT", 9 ) != 0 )
- {
- /* we don't emit an error message since this code gets */
- /* explicitly caught one level higher */
- error = FT_THROW( Missing_Startfont_Field );
- goto Exit;
- }
-
- p->flags = BDF_START_;
- font = p->font = NULL;
-
- if ( FT_NEW( font ) )
- goto Exit;
- p->font = font;
-
- font->memory = p->memory;
-
- { /* setup */
- size_t i;
- bdf_property_t* prop;
-
-
- error = ft_hash_str_init( &(font->proptbl), memory );
- if ( error )
- goto Exit;
- for ( i = 0, prop = (bdf_property_t*)bdf_properties_;
- i < num_bdf_properties_; i++, prop++ )
- {
- error = ft_hash_str_insert( prop->name, i,
- &(font->proptbl), memory );
- if ( error )
- goto Exit;
- }
- }
-
- if ( FT_QALLOC( p->font->internal, sizeof ( FT_HashRec ) ) )
- goto Exit;
- error = ft_hash_str_init( (FT_Hash)p->font->internal, memory );
- if ( error )
- goto Exit;
- p->font->spacing = p->opts->font_spacing;
- p->font->default_char = ~0UL;
-
- goto Exit;
- }
-
- /* Check for the start of the properties. */
- if ( _bdf_strncmp( line, "STARTPROPERTIES", 15 ) == 0 )
- {
- if ( !( p->flags & BDF_FONT_BBX_ ) )
- {
- /* Missing the FONTBOUNDINGBOX field. */
- FT_ERROR(( "bdf_parse_start_: " ERRMSG1, lineno, "FONTBOUNDINGBOX" ));
- error = FT_THROW( Missing_Fontboundingbox_Field );
- goto Exit;
- }
-
- error = bdf_list_split_( &p->list, " +", line, linelen );
- if ( error )
- goto Exit;
-
- /* at this point, `p->font' can't be NULL */
- p->cnt = p->font->props_size = bdf_atoul_( p->list.field[1] );
- /* We need at least 4 bytes per property. */
- if ( p->cnt > p->size / 4 )
- {
- p->font->props_size = 0;
-
- FT_ERROR(( "bdf_parse_glyphs_: " ERRMSG5, lineno, "STARTPROPERTIES" ));
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- if ( FT_NEW_ARRAY( p->font->props, p->cnt ) )
- {
- p->font->props_size = 0;
- goto Exit;
- }
-
- p->flags |= BDF_PROPS_;
- *next = bdf_parse_properties_;
-
- goto Exit;
- }
-
- /* Check for the FONTBOUNDINGBOX field. */
- if ( _bdf_strncmp( line, "FONTBOUNDINGBOX", 15 ) == 0 )
- {
- if ( !( p->flags & BDF_SIZE_ ) )
- {
- /* Missing the SIZE field. */
- FT_ERROR(( "bdf_parse_start_: " ERRMSG1, lineno, "SIZE" ));
- error = FT_THROW( Missing_Size_Field );
- goto Exit;
- }
-
- error = bdf_list_split_( &p->list, " +", line, linelen );
- if ( error )
- goto Exit;
-
- p->font->bbx.width = bdf_atous_( p->list.field[1] );
- p->font->bbx.height = bdf_atous_( p->list.field[2] );
-
- p->font->bbx.x_offset = bdf_atos_( p->list.field[3] );
- p->font->bbx.y_offset = bdf_atos_( p->list.field[4] );
-
- p->font->bbx.ascent = (short)( p->font->bbx.height +
- p->font->bbx.y_offset );
-
- p->font->bbx.descent = (short)( -p->font->bbx.y_offset );
-
- p->flags |= BDF_FONT_BBX_;
-
- goto Exit;
- }
-
- /* The next thing to check for is the FONT field. */
- if ( _bdf_strncmp( line, "FONT", 4 ) == 0 )
- {
- error = bdf_list_split_( &p->list, " +", line, linelen );
- if ( error )
- goto Exit;
- bdf_list_shift_( &p->list, 1 );
-
- s = bdf_list_join_( &p->list, ' ', &slen );
-
- if ( !s )
- {
- FT_ERROR(( "bdf_parse_start_: " ERRMSG8, lineno, "FONT" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- /* Allowing multiple `FONT' lines (which is invalid) doesn't hurt... */
- FT_FREE( p->font->name );
-
- if ( FT_DUP( p->font->name, s, slen + 1 ) )
- goto Exit;
-
- /* If the font name is an XLFD name, set the spacing to the one in */
- /* the font name. If there is no spacing fall back on the default. */
- error = bdf_set_default_spacing_( p->font, p->opts, lineno );
- if ( error )
- goto Exit;
-
- p->flags |= BDF_FONT_NAME_;
-
- goto Exit;
- }
-
- /* Check for the SIZE field. */
- if ( _bdf_strncmp( line, "SIZE", 4 ) == 0 )
- {
- if ( !( p->flags & BDF_FONT_NAME_ ) )
- {
- /* Missing the FONT field. */
- FT_ERROR(( "bdf_parse_start_: " ERRMSG1, lineno, "FONT" ));
- error = FT_THROW( Missing_Font_Field );
- goto Exit;
- }
-
- error = bdf_list_split_( &p->list, " +", line, linelen );
- if ( error )
- goto Exit;
-
- p->font->point_size = bdf_atoul_( p->list.field[1] );
- p->font->resolution_x = bdf_atoul_( p->list.field[2] );
- p->font->resolution_y = bdf_atoul_( p->list.field[3] );
-
- /* Check for the bits per pixel field. */
- if ( p->list.used == 5 )
- {
- unsigned short bpp;
-
-
- bpp = bdf_atous_( p->list.field[4] );
-
- /* Only values 1, 2, 4, 8 are allowed for greymap fonts. */
- if ( bpp > 4 )
- p->font->bpp = 8;
- else if ( bpp > 2 )
- p->font->bpp = 4;
- else if ( bpp > 1 )
- p->font->bpp = 2;
- else
- p->font->bpp = 1;
-
- if ( p->font->bpp != bpp )
- FT_TRACE2(( "bdf_parse_start_: " ACMSG11, p->font->bpp ));
- }
- else
- p->font->bpp = 1;
-
- p->flags |= BDF_SIZE_;
-
- goto Exit;
- }
-
- /* Check for the CHARS field -- font properties are optional */
- if ( _bdf_strncmp( line, "CHARS", 5 ) == 0 )
- {
- char nbuf[BUFSIZE];
-
-
- if ( !( p->flags & BDF_FONT_BBX_ ) )
- {
- /* Missing the FONTBOUNDINGBOX field. */
- FT_ERROR(( "bdf_parse_start_: " ERRMSG1, lineno, "FONTBOUNDINGBOX" ));
- error = FT_THROW( Missing_Fontboundingbox_Field );
- goto Exit;
- }
-
- /* Add the two standard X11 properties which are required */
- /* for compiling fonts. */
- p->font->font_ascent = p->font->bbx.ascent;
- ft_snprintf( nbuf, BUFSIZE, "%hd", p->font->bbx.ascent );
- error = bdf_add_property_( p->font, "FONT_ASCENT",
- nbuf, lineno );
- if ( error )
- goto Exit;
- FT_TRACE2(( "bdf_parse_properties_: " ACMSG1, p->font->bbx.ascent ));
-
- p->font->font_descent = p->font->bbx.descent;
- ft_snprintf( nbuf, BUFSIZE, "%hd", p->font->bbx.descent );
- error = bdf_add_property_( p->font, "FONT_DESCENT",
- nbuf, lineno );
- if ( error )
- goto Exit;
- FT_TRACE2(( "bdf_parse_properties_: " ACMSG2, p->font->bbx.descent ));
-
- *next = bdf_parse_glyphs_;
-
- /* A special return value. */
- error = -1;
- goto Exit;
- }
-
- FT_ERROR(( "bdf_parse_start_: " ERRMSG9, lineno ));
- error = FT_THROW( Invalid_File_Format );
-
- Exit:
- return error;
- }
-
-
- /**************************************************************************
- *
- * API.
- *
- */
-
-
- FT_LOCAL_DEF( FT_Error )
- bdf_load_font( FT_Stream stream,
- FT_Memory memory,
- bdf_options_t* opts,
- bdf_font_t* *font )
- {
- unsigned long lineno = 0; /* make compiler happy */
- bdf_parse_t_ *p = NULL;
-
- FT_Error error = FT_Err_Ok;
-
-
- if ( FT_NEW( p ) )
- goto Exit;
-
- p->opts = (bdf_options_t*)( opts ? opts : &bdf_opts_ );
- p->minlb = 32767;
- p->size = stream->size;
- p->memory = memory; /* only during font creation */
-
- bdf_list_init_( &p->list, memory );
-
- error = bdf_readstream_( stream, bdf_parse_start_,
- (void *)p, &lineno );
- if ( error )
- goto Fail;
-
- if ( p->font )
- {
- /* If the font is not proportional, set the font's monowidth */
- /* field to the width of the font bounding box. */
-
- if ( p->font->spacing != BDF_PROPORTIONAL )
- p->font->monowidth = p->font->bbx.width;
-
- /* If the number of glyphs loaded is not that of the original count, */
- /* indicate the difference. */
- if ( p->cnt != p->font->glyphs_used + p->font->unencoded_used )
- {
- FT_TRACE2(( "bdf_load_font: " ACMSG15, p->cnt,
- p->font->glyphs_used + p->font->unencoded_used ));
- }
-
- /* Once the font has been loaded, adjust the overall font metrics if */
- /* necessary. */
- if ( p->opts->correct_metrics != 0 &&
- ( p->font->glyphs_used > 0 || p->font->unencoded_used > 0 ) )
- {
- if ( p->maxrb - p->minlb != p->font->bbx.width )
- {
- FT_TRACE2(( "bdf_load_font: " ACMSG3,
- p->font->bbx.width, p->maxrb - p->minlb ));
- p->font->bbx.width = (unsigned short)( p->maxrb - p->minlb );
- }
-
- if ( p->font->bbx.x_offset != p->minlb )
- {
- FT_TRACE2(( "bdf_load_font: " ACMSG4,
- p->font->bbx.x_offset, p->minlb ));
- p->font->bbx.x_offset = p->minlb;
- }
-
- if ( p->font->bbx.ascent != p->maxas )
- {
- FT_TRACE2(( "bdf_load_font: " ACMSG5,
- p->font->bbx.ascent, p->maxas ));
- p->font->bbx.ascent = p->maxas;
- }
-
- if ( p->font->bbx.descent != p->maxds )
- {
- FT_TRACE2(( "bdf_load_font: " ACMSG6,
- p->font->bbx.descent, p->maxds ));
- p->font->bbx.descent = p->maxds;
- p->font->bbx.y_offset = (short)( -p->maxds );
- }
-
- if ( p->maxas + p->maxds != p->font->bbx.height )
- {
- FT_TRACE2(( "bdf_load_font: " ACMSG7,
- p->font->bbx.height, p->maxas + p->maxds ));
- p->font->bbx.height = (unsigned short)( p->maxas + p->maxds );
- }
-
- if ( p->flags & BDF_SWIDTH_ADJ_ )
- FT_TRACE2(( "bdf_load_font: " ACMSG8 ));
- }
- }
-
- if ( p->flags & BDF_START_ )
- {
- /* The ENDFONT field was never reached or did not exist. */
- if ( !( p->flags & BDF_GLYPHS_ ) )
- {
- /* Error happened while parsing header. */
- FT_ERROR(( "bdf_load_font: " ERRMSG2, lineno ));
- error = FT_THROW( Corrupted_Font_Header );
- goto Fail;
- }
- else
- {
- /* Error happened when parsing glyphs. */
- FT_ERROR(( "bdf_load_font: " ERRMSG3, lineno ));
- error = FT_THROW( Corrupted_Font_Glyphs );
- goto Fail;
- }
- }
-
- if ( !p->font && !error )
- error = FT_THROW( Invalid_File_Format );
-
- *font = p->font;
-
- Exit:
- if ( p )
- {
- bdf_list_done_( &p->list );
-
- FT_FREE( p->glyph_name );
- FT_FREE( p );
- }
-
- return error;
-
- Fail:
- bdf_free_font( p->font );
-
- FT_FREE( p->font );
-
- goto Exit;
- }
-
-
- FT_LOCAL_DEF( void )
- bdf_free_font( bdf_font_t* font )
- {
- bdf_property_t* prop;
- unsigned long i;
- bdf_glyph_t* glyphs;
- FT_Memory memory;
-
-
- if ( font == NULL )
- return;
-
- memory = font->memory;
-
- FT_FREE( font->name );
-
- /* Free up the internal hash table of property names. */
- if ( font->internal )
- {
- ft_hash_str_free( (FT_Hash)font->internal, memory );
- FT_FREE( font->internal );
- }
-
- /* Free up the comment info. */
- FT_FREE( font->comments );
-
- /* Free up the properties. */
- for ( i = 0; i < font->props_size; i++ )
- {
- if ( font->props[i].format == BDF_ATOM )
- FT_FREE( font->props[i].value.atom );
- }
-
- FT_FREE( font->props );
-
- /* Free up the character info. */
- for ( i = 0, glyphs = font->glyphs;
- i < font->glyphs_used; i++, glyphs++ )
- {
- FT_FREE( glyphs->name );
- FT_FREE( glyphs->bitmap );
- }
-
- for ( i = 0, glyphs = font->unencoded; i < font->unencoded_used;
- i++, glyphs++ )
- {
- FT_FREE( glyphs->name );
- FT_FREE( glyphs->bitmap );
- }
-
- FT_FREE( font->glyphs );
- FT_FREE( font->unencoded );
-
- /* bdf_cleanup */
- ft_hash_str_free( &(font->proptbl), memory );
-
- /* Free up the user defined properties. */
- for ( prop = font->user_props, i = 0;
- i < font->nuser_props; i++, prop++ )
- FT_FREE( prop->name );
-
- FT_FREE( font->user_props );
-
- /* FREE( font ); */ /* XXX Fixme */
- }
-
-
- FT_LOCAL_DEF( bdf_property_t * )
- bdf_get_font_property( bdf_font_t* font,
- const char* name )
- {
- size_t* propid;
-
-
- if ( font == NULL || font->props_size == 0 || name == NULL || *name == 0 )
- return 0;
-
- propid = ft_hash_str_lookup( name, (FT_Hash)font->internal );
-
- return propid ? ( font->props + *propid ) : 0;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/bzip2/ftbzip2.c b/contrib/libs/freetype/src/bzip2/ftbzip2.c
deleted file mode 100644
index 06359cb352..0000000000
--- a/contrib/libs/freetype/src/bzip2/ftbzip2.c
+++ /dev/null
@@ -1,535 +0,0 @@
-/****************************************************************************
- *
- * ftbzip2.c
- *
- * FreeType support for .bz2 compressed files.
- *
- * This optional component relies on libbz2. It should mainly be used to
- * parse compressed PCF fonts, as found with many X11 server
- * distributions.
- *
- * Copyright (C) 2010-2024 by
- * Joel Klinghed.
- *
- * based on `src/gzip/ftgzip.c'
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftmemory.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/internal/ftdebug.h>
-#include <freetype/ftbzip2.h>
-#include FT_CONFIG_STANDARD_LIBRARY_H
-
-
-#include <freetype/ftmoderr.h>
-
-#undef FTERRORS_H_
-
-#undef FT_ERR_PREFIX
-#define FT_ERR_PREFIX Bzip2_Err_
-#define FT_ERR_BASE FT_Mod_Err_Bzip2
-
-#include <freetype/fterrors.h>
-
-
-#ifdef FT_CONFIG_OPTION_USE_BZIP2
-
-#define BZ_NO_STDIO /* Do not need FILE */
-#error #include <bzlib.h>
-
-
-/***************************************************************************/
-/***************************************************************************/
-/***** *****/
-/***** B Z I P 2 M E M O R Y M A N A G E M E N T *****/
-/***** *****/
-/***************************************************************************/
-/***************************************************************************/
-
- /* it is better to use FreeType memory routines instead of raw
- 'malloc/free' */
-
- typedef void* (*alloc_func)( void*, int, int );
- typedef void (*free_func) ( void*, void* );
-
-
- static void*
- ft_bzip2_alloc( void* memory_, /* FT_Memory */
- int items,
- int size )
- {
- FT_Memory memory = (FT_Memory)memory_;
-
- FT_ULong sz = (FT_ULong)size * (FT_ULong)items;
- FT_Error error;
- FT_Pointer p = NULL;
-
-
- FT_MEM_QALLOC( p, sz );
- return p;
- }
-
-
- static void
- ft_bzip2_free( void* memory_, /* FT_Memory */
- void* address )
- {
- FT_Memory memory = (FT_Memory)memory_;
-
-
- FT_MEM_FREE( address );
- }
-
-
-/***************************************************************************/
-/***************************************************************************/
-/***** *****/
-/***** B Z I P 2 F I L E D E S C R I P T O R *****/
-/***** *****/
-/***************************************************************************/
-/***************************************************************************/
-
-#define FT_BZIP2_BUFFER_SIZE 4096
-
- typedef struct FT_BZip2FileRec_
- {
- FT_Stream source; /* parent/source stream */
- FT_Stream stream; /* embedding stream */
- FT_Memory memory; /* memory allocator */
- bz_stream bzstream; /* bzlib input stream */
-
- FT_Byte input[FT_BZIP2_BUFFER_SIZE]; /* input read buffer */
-
- FT_Byte buffer[FT_BZIP2_BUFFER_SIZE]; /* output buffer */
- FT_ULong pos; /* position in output */
- FT_Byte* cursor;
- FT_Byte* limit;
- FT_Bool reset; /* reset before next read */
-
- } FT_BZip2FileRec, *FT_BZip2File;
-
-
- /* check and skip .bz2 header - we don't support `transparent' compression */
- static FT_Error
- ft_bzip2_check_header( FT_Stream stream )
- {
- FT_Error error = FT_Err_Ok;
- FT_Byte head[4];
-
-
- if ( FT_STREAM_SEEK( 0 ) ||
- FT_STREAM_READ( head, 4 ) )
- goto Exit;
-
- /* head[0] && head[1] are the magic numbers; */
- /* head[2] is the version, and head[3] the blocksize */
- if ( head[0] != 0x42 ||
- head[1] != 0x5A ||
- head[2] != 0x68 ) /* only support bzip2 (huffman) */
- {
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- Exit:
- return error;
- }
-
-
- static FT_Error
- ft_bzip2_file_init( FT_BZip2File zip,
- FT_Stream stream,
- FT_Stream source )
- {
- bz_stream* bzstream = &zip->bzstream;
- FT_Error error = FT_Err_Ok;
-
-
- zip->stream = stream;
- zip->source = source;
- zip->memory = stream->memory;
-
- zip->limit = zip->buffer + FT_BZIP2_BUFFER_SIZE;
- zip->cursor = zip->limit;
- zip->pos = 0;
- zip->reset = 0;
-
- /* check .bz2 header */
- {
- stream = source;
-
- error = ft_bzip2_check_header( stream );
- if ( error )
- goto Exit;
-
- if ( FT_STREAM_SEEK( 0 ) )
- goto Exit;
- }
-
- /* initialize bzlib */
- bzstream->bzalloc = ft_bzip2_alloc;
- bzstream->bzfree = ft_bzip2_free;
- bzstream->opaque = zip->memory;
-
- bzstream->avail_in = 0;
- bzstream->next_in = (char*)zip->buffer;
-
- if ( BZ2_bzDecompressInit( bzstream, 0, 0 ) != BZ_OK ||
- !bzstream->next_in )
- error = FT_THROW( Invalid_File_Format );
-
- Exit:
- return error;
- }
-
-
- static void
- ft_bzip2_file_done( FT_BZip2File zip )
- {
- bz_stream* bzstream = &zip->bzstream;
-
-
- BZ2_bzDecompressEnd( bzstream );
-
- /* clear the rest */
- bzstream->bzalloc = NULL;
- bzstream->bzfree = NULL;
- bzstream->opaque = NULL;
- bzstream->next_in = NULL;
- bzstream->next_out = NULL;
- bzstream->avail_in = 0;
- bzstream->avail_out = 0;
-
- zip->memory = NULL;
- zip->source = NULL;
- zip->stream = NULL;
- }
-
-
- static FT_Error
- ft_bzip2_file_reset( FT_BZip2File zip )
- {
- FT_Stream stream = zip->source;
- FT_Error error;
-
-
- if ( !FT_STREAM_SEEK( 0 ) )
- {
- bz_stream* bzstream = &zip->bzstream;
-
-
- BZ2_bzDecompressEnd( bzstream );
-
- bzstream->avail_in = 0;
- bzstream->next_in = (char*)zip->input;
- bzstream->avail_out = 0;
- bzstream->next_out = (char*)zip->buffer;
-
- zip->limit = zip->buffer + FT_BZIP2_BUFFER_SIZE;
- zip->cursor = zip->limit;
- zip->pos = 0;
- zip->reset = 0;
-
- BZ2_bzDecompressInit( bzstream, 0, 0 );
- }
-
- return error;
- }
-
-
- static FT_Error
- ft_bzip2_file_fill_input( FT_BZip2File zip )
- {
- bz_stream* bzstream = &zip->bzstream;
- FT_Stream stream = zip->source;
- FT_ULong size;
-
-
- if ( stream->read )
- {
- size = stream->read( stream, stream->pos, zip->input,
- FT_BZIP2_BUFFER_SIZE );
- if ( size == 0 )
- {
- zip->limit = zip->cursor;
- return FT_THROW( Invalid_Stream_Operation );
- }
- }
- else
- {
- size = stream->size - stream->pos;
- if ( size > FT_BZIP2_BUFFER_SIZE )
- size = FT_BZIP2_BUFFER_SIZE;
-
- if ( size == 0 )
- {
- zip->limit = zip->cursor;
- return FT_THROW( Invalid_Stream_Operation );
- }
-
- FT_MEM_COPY( zip->input, stream->base + stream->pos, size );
- }
- stream->pos += size;
-
- bzstream->next_in = (char*)zip->input;
- bzstream->avail_in = size;
-
- return FT_Err_Ok;
- }
-
-
- static FT_Error
- ft_bzip2_file_fill_output( FT_BZip2File zip )
- {
- bz_stream* bzstream = &zip->bzstream;
- FT_Error error = FT_Err_Ok;
-
-
- zip->cursor = zip->buffer;
- bzstream->next_out = (char*)zip->cursor;
- bzstream->avail_out = FT_BZIP2_BUFFER_SIZE;
-
- while ( bzstream->avail_out > 0 )
- {
- int err;
-
-
- if ( bzstream->avail_in == 0 )
- {
- error = ft_bzip2_file_fill_input( zip );
- if ( error )
- break;
- }
-
- err = BZ2_bzDecompress( bzstream );
-
- if ( err != BZ_OK )
- {
- zip->reset = 1;
-
- if ( err == BZ_STREAM_END )
- {
- zip->limit = (FT_Byte*)bzstream->next_out;
- if ( zip->limit == zip->cursor )
- error = FT_THROW( Invalid_Stream_Operation );
- break;
- }
- else
- {
- zip->limit = zip->cursor;
- error = FT_THROW( Invalid_Stream_Operation );
- break;
- }
- }
- }
-
- return error;
- }
-
-
- /* fill output buffer; `count' must be <= FT_BZIP2_BUFFER_SIZE */
- static FT_Error
- ft_bzip2_file_skip_output( FT_BZip2File zip,
- FT_ULong count )
- {
- FT_Error error = FT_Err_Ok;
-
-
- for (;;)
- {
- FT_ULong delta = (FT_ULong)( zip->limit - zip->cursor );
-
-
- if ( delta >= count )
- delta = count;
-
- zip->cursor += delta;
- zip->pos += delta;
-
- count -= delta;
- if ( count == 0 )
- break;
-
- error = ft_bzip2_file_fill_output( zip );
- if ( error )
- break;
- }
-
- return error;
- }
-
-
- static FT_ULong
- ft_bzip2_file_io( FT_BZip2File zip,
- FT_ULong pos,
- FT_Byte* buffer,
- FT_ULong count )
- {
- FT_ULong result = 0;
- FT_Error error;
-
-
- /* Reset inflate stream if seeking backwards or bzip reported an error. */
- /* Yes, that is not too efficient, but it saves memory :-) */
- if ( pos < zip->pos || zip->reset )
- {
- error = ft_bzip2_file_reset( zip );
- if ( error )
- goto Exit;
- }
-
- /* skip unwanted bytes */
- if ( pos > zip->pos )
- {
- error = ft_bzip2_file_skip_output( zip, (FT_ULong)( pos - zip->pos ) );
- if ( error )
- goto Exit;
- }
-
- if ( count == 0 )
- goto Exit;
-
- /* now read the data */
- for (;;)
- {
- FT_ULong delta;
-
-
- delta = (FT_ULong)( zip->limit - zip->cursor );
- if ( delta >= count )
- delta = count;
-
- FT_MEM_COPY( buffer, zip->cursor, delta );
- buffer += delta;
- result += delta;
- zip->cursor += delta;
- zip->pos += delta;
-
- count -= delta;
- if ( count == 0 )
- break;
-
- error = ft_bzip2_file_fill_output( zip );
- if ( error )
- break;
- }
-
- Exit:
- return result;
- }
-
-
-/***************************************************************************/
-/***************************************************************************/
-/***** *****/
-/***** B Z E M B E D D I N G S T R E A M *****/
-/***** *****/
-/***************************************************************************/
-/***************************************************************************/
-
- static void
- ft_bzip2_stream_close( FT_Stream stream )
- {
- FT_BZip2File zip = (FT_BZip2File)stream->descriptor.pointer;
- FT_Memory memory = stream->memory;
-
-
- if ( zip )
- {
- /* finalize bzip file descriptor */
- ft_bzip2_file_done( zip );
-
- FT_FREE( zip );
-
- stream->descriptor.pointer = NULL;
- }
- }
-
-
- static unsigned long
- ft_bzip2_stream_io( FT_Stream stream,
- unsigned long offset,
- unsigned char* buffer,
- unsigned long count )
- {
- FT_BZip2File zip = (FT_BZip2File)stream->descriptor.pointer;
-
-
- return ft_bzip2_file_io( zip, offset, buffer, count );
- }
-
-
- FT_EXPORT_DEF( FT_Error )
- FT_Stream_OpenBzip2( FT_Stream stream,
- FT_Stream source )
- {
- FT_Error error;
- FT_Memory memory;
- FT_BZip2File zip = NULL;
-
-
- if ( !stream || !source )
- {
- error = FT_THROW( Invalid_Stream_Handle );
- goto Exit;
- }
-
- memory = source->memory;
-
- /*
- * check the header right now; this prevents allocating unnecessary
- * objects when we don't need them
- */
- error = ft_bzip2_check_header( source );
- if ( error )
- goto Exit;
-
- FT_ZERO( stream );
- stream->memory = memory;
-
- if ( !FT_QNEW( zip ) )
- {
- error = ft_bzip2_file_init( zip, stream, source );
- if ( error )
- {
- FT_FREE( zip );
- goto Exit;
- }
-
- stream->descriptor.pointer = zip;
- }
-
- stream->size = 0x7FFFFFFFL; /* don't know the real size! */
- stream->pos = 0;
- stream->base = NULL;
- stream->read = ft_bzip2_stream_io;
- stream->close = ft_bzip2_stream_close;
-
- Exit:
- return error;
- }
-
-#else /* !FT_CONFIG_OPTION_USE_BZIP2 */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Stream_OpenBzip2( FT_Stream stream,
- FT_Stream source )
- {
- FT_UNUSED( stream );
- FT_UNUSED( source );
-
- return FT_THROW( Unimplemented_Feature );
- }
-
-#endif /* !FT_CONFIG_OPTION_USE_BZIP2 */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cache/ftcache.c b/contrib/libs/freetype/src/cache/ftcache.c
deleted file mode 100644
index 81e0347af9..0000000000
--- a/contrib/libs/freetype/src/cache/ftcache.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/****************************************************************************
- *
- * ftcache.c
- *
- * The FreeType Caching sub-system (body only).
- *
- * Copyright (C) 2000-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#define FT_MAKE_OPTION_SINGLE_OBJECT
-
-#include "ftcbasic.c"
-#include "ftccache.c"
-#include "ftccmap.c"
-#include "ftcglyph.c"
-#include "ftcimage.c"
-#include "ftcmanag.c"
-#include "ftcmru.c"
-#include "ftcsbits.c"
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cache/ftcbasic.c b/contrib/libs/freetype/src/cache/ftcbasic.c
deleted file mode 100644
index 7102d3d2d8..0000000000
--- a/contrib/libs/freetype/src/cache/ftcbasic.c
+++ /dev/null
@@ -1,598 +0,0 @@
-/****************************************************************************
- *
- * ftcbasic.c
- *
- * The FreeType basic cache interface (body).
- *
- * Copyright (C) 2003-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/ftdebug.h>
-#include <freetype/ftcache.h>
-#include "ftcglyph.h"
-#include "ftcimage.h"
-#include "ftcsbits.h"
-
-#include "ftccback.h"
-#include "ftcerror.h"
-
-#undef FT_COMPONENT
-#define FT_COMPONENT cache
-
-
- /*
- * Basic Families
- *
- */
- typedef struct FTC_BasicAttrRec_
- {
- FTC_ScalerRec scaler;
- FT_Int32 load_flags;
-
- } FTC_BasicAttrRec, *FTC_BasicAttrs;
-
-#define FTC_BASIC_ATTR_COMPARE( a, b ) \
- FT_BOOL( FTC_SCALER_COMPARE( &(a)->scaler, &(b)->scaler ) && \
- (a)->load_flags == (b)->load_flags )
-
-#define FTC_BASIC_ATTR_HASH( a ) \
- ( FTC_SCALER_HASH( &(a)->scaler ) + \
- (FT_Offset)( 31 * (a)->load_flags ) )
-
-
- typedef struct FTC_BasicQueryRec_
- {
- FTC_GQueryRec gquery;
- FTC_BasicAttrRec attrs;
-
- } FTC_BasicQueryRec, *FTC_BasicQuery;
-
-
- typedef struct FTC_BasicFamilyRec_
- {
- FTC_FamilyRec family;
- FTC_BasicAttrRec attrs;
-
- } FTC_BasicFamilyRec, *FTC_BasicFamily;
-
-
- FT_CALLBACK_DEF( FT_Bool )
- ftc_basic_family_compare( FTC_MruNode ftcfamily,
- FT_Pointer ftcquery )
- {
- FTC_BasicFamily family = (FTC_BasicFamily)ftcfamily;
- FTC_BasicQuery query = (FTC_BasicQuery)ftcquery;
-
-
- return FTC_BASIC_ATTR_COMPARE( &family->attrs, &query->attrs );
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- ftc_basic_family_init( FTC_MruNode ftcfamily,
- FT_Pointer ftcquery,
- FT_Pointer ftccache )
- {
- FTC_BasicFamily family = (FTC_BasicFamily)ftcfamily;
- FTC_BasicQuery query = (FTC_BasicQuery)ftcquery;
- FTC_Cache cache = (FTC_Cache)ftccache;
-
-
- FTC_Family_Init( FTC_FAMILY( family ), cache );
- family->attrs = query->attrs;
- return 0;
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- ftc_basic_family_get_count( FTC_Family ftcfamily,
- FTC_Manager manager )
- {
- FTC_BasicFamily family = (FTC_BasicFamily)ftcfamily;
- FT_Error error;
- FT_Face face;
- FT_UInt result = 0;
-
-
- error = FTC_Manager_LookupFace( manager, family->attrs.scaler.face_id,
- &face );
-
- if ( error || !face )
- return result;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( (FT_ULong)face->num_glyphs > FT_UINT_MAX || 0 > face->num_glyphs )
- {
- FT_TRACE1(( "ftc_basic_family_get_count:"
- " the number of glyphs in this face is %ld,\n",
- face->num_glyphs ));
- FT_TRACE1(( " "
- " which is too much and thus truncated\n" ));
- }
-#endif
-
- result = (FT_UInt)face->num_glyphs;
-
- return result;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- ftc_basic_family_load_bitmap( FTC_Family ftcfamily,
- FT_UInt gindex,
- FTC_Manager manager,
- FT_Face *aface )
- {
- FTC_BasicFamily family = (FTC_BasicFamily)ftcfamily;
- FT_Error error;
- FT_Size size;
-
-
- error = FTC_Manager_LookupSize( manager, &family->attrs.scaler, &size );
- if ( !error )
- {
- FT_Face face = size->face;
-
-
- error = FT_Load_Glyph( face,
- gindex,
- family->attrs.load_flags | FT_LOAD_RENDER );
- if ( !error )
- *aface = face;
- }
-
- return error;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- ftc_basic_family_load_glyph( FTC_Family ftcfamily,
- FT_UInt gindex,
- FTC_Cache cache,
- FT_Glyph *aglyph )
- {
- FTC_BasicFamily family = (FTC_BasicFamily)ftcfamily;
- FT_Error error;
- FTC_Scaler scaler = &family->attrs.scaler;
- FT_Face face;
- FT_Size size;
-
-
- /* we will now load the glyph image */
- error = FTC_Manager_LookupSize( cache->manager,
- scaler,
- &size );
- if ( !error )
- {
- face = size->face;
-
- error = FT_Load_Glyph( face, gindex, family->attrs.load_flags );
- if ( !error )
- {
- if ( face->glyph->format == FT_GLYPH_FORMAT_BITMAP ||
- face->glyph->format == FT_GLYPH_FORMAT_OUTLINE ||
- face->glyph->format == FT_GLYPH_FORMAT_SVG )
- {
- /* ok, copy it */
- FT_Glyph glyph;
-
-
- error = FT_Get_Glyph( face->glyph, &glyph );
- if ( !error )
- {
- *aglyph = glyph;
- goto Exit;
- }
- }
- else
- error = FT_THROW( Invalid_Argument );
- }
- }
-
- Exit:
- return error;
- }
-
-
- FT_CALLBACK_DEF( FT_Bool )
- ftc_basic_gnode_compare_faceid( FTC_Node ftcgnode,
- FT_Pointer ftcface_id,
- FTC_Cache cache,
- FT_Bool* list_changed )
- {
- FTC_GNode gnode = (FTC_GNode)ftcgnode;
- FTC_FaceID face_id = (FTC_FaceID)ftcface_id;
- FTC_BasicFamily family = (FTC_BasicFamily)gnode->family;
- FT_Bool result;
-
-
- if ( list_changed )
- *list_changed = FALSE;
- result = FT_BOOL( family->attrs.scaler.face_id == face_id );
- if ( result )
- {
- /* we must call this function to avoid this node from appearing
- * in later lookups with the same face_id!
- */
- FTC_GNode_UnselectFamily( gnode, cache );
- }
- return result;
- }
-
-
- /*
- *
- * basic image cache
- *
- */
-
- static
- const FTC_IFamilyClassRec ftc_basic_image_family_class =
- {
- {
- sizeof ( FTC_BasicFamilyRec ),
-
- ftc_basic_family_compare, /* FTC_MruNode_CompareFunc node_compare */
- ftc_basic_family_init, /* FTC_MruNode_InitFunc node_init */
- NULL /* FTC_MruNode_DoneFunc node_done */
- },
-
- ftc_basic_family_load_glyph /* FTC_IFamily_LoadGlyphFunc family_load_glyph */
- };
-
-
- static
- const FTC_GCacheClassRec ftc_basic_image_cache_class =
- {
- {
- ftc_inode_new, /* FTC_Node_NewFunc node_new */
- ftc_inode_weight, /* FTC_Node_WeightFunc node_weight */
- ftc_gnode_compare, /* FTC_Node_CompareFunc node_compare */
- ftc_basic_gnode_compare_faceid, /* FTC_Node_CompareFunc node_remove_faceid */
- ftc_inode_free, /* FTC_Node_FreeFunc node_free */
-
- sizeof ( FTC_GCacheRec ),
- ftc_gcache_init, /* FTC_Cache_InitFunc cache_init */
- ftc_gcache_done /* FTC_Cache_DoneFunc cache_done */
- },
-
- (FTC_MruListClass)&ftc_basic_image_family_class
- };
-
-
- /* documentation is in ftcache.h */
-
- FT_EXPORT_DEF( FT_Error )
- FTC_ImageCache_New( FTC_Manager manager,
- FTC_ImageCache *acache )
- {
- return FTC_GCache_New( manager, &ftc_basic_image_cache_class,
- (FTC_GCache*)acache );
- }
-
-
- /* documentation is in ftcache.h */
-
- FT_EXPORT_DEF( FT_Error )
- FTC_ImageCache_Lookup( FTC_ImageCache cache,
- FTC_ImageType type,
- FT_UInt gindex,
- FT_Glyph *aglyph,
- FTC_Node *anode )
- {
- FT_Error error;
- FTC_BasicQueryRec query;
- FTC_Node node = NULL; /* make compiler happy */
- FT_Offset hash;
-
-
- /* other argument checks delayed to `FTC_Cache_Lookup' */
- if ( !aglyph )
- return FT_THROW( Invalid_Argument );
-
- *aglyph = NULL;
- if ( anode )
- *anode = NULL;
-
- query.attrs.scaler.face_id = type->face_id;
- query.attrs.scaler.width = type->width;
- query.attrs.scaler.height = type->height;
- query.attrs.load_flags = type->flags;
-
- query.attrs.scaler.pixel = 1;
- query.attrs.scaler.x_res = 0; /* make compilers happy */
- query.attrs.scaler.y_res = 0;
-
- hash = FTC_BASIC_ATTR_HASH( &query.attrs ) + gindex;
-
-#ifdef FTC_INLINE /* inlining is about 50% faster! */
- FTC_GCACHE_LOOKUP_CMP( cache,
- ftc_basic_family_compare,
- ftc_gnode_compare,
- hash, gindex,
- &query,
- node,
- error );
-#else
- error = FTC_GCache_Lookup( FTC_GCACHE( cache ),
- hash, gindex,
- FTC_GQUERY( &query ),
- &node );
-#endif
- if ( !error )
- {
- *aglyph = FTC_INODE( node )->glyph;
-
- if ( anode )
- {
- *anode = node;
- node->ref_count++;
- }
- }
-
- return error;
- }
-
-
- /* documentation is in ftcache.h */
-
- FT_EXPORT_DEF( FT_Error )
- FTC_ImageCache_LookupScaler( FTC_ImageCache cache,
- FTC_Scaler scaler,
- FT_ULong load_flags,
- FT_UInt gindex,
- FT_Glyph *aglyph,
- FTC_Node *anode )
- {
- FT_Error error;
- FTC_BasicQueryRec query;
- FTC_Node node = NULL; /* make compiler happy */
- FT_Offset hash;
-
-
- /* other argument checks delayed to `FTC_Cache_Lookup' */
- if ( !aglyph || !scaler )
- return FT_THROW( Invalid_Argument );
-
- *aglyph = NULL;
- if ( anode )
- *anode = NULL;
-
- /*
- * Internal `FTC_BasicAttr->load_flags' is of type `FT_Int32',
- * but public `FT_Face->face_flags' is of type `FT_Long'.
- *
- * On long > int systems, higher bits of load_flags cannot be handled.
- */
-#if FT_ULONG_MAX > 0xFFFFFFFFUL
- if ( load_flags > 0xFFFFFFFFUL )
- FT_TRACE1(( "FTC_ImageCache_LookupScaler:"
- " higher bits in load_flags 0x%lx are dropped\n",
- load_flags & ~0xFFFFFFFFUL ));
-#endif
-
- query.attrs.scaler = scaler[0];
- query.attrs.load_flags = (FT_Int32)load_flags;
-
- hash = FTC_BASIC_ATTR_HASH( &query.attrs ) + gindex;
-
- FTC_GCACHE_LOOKUP_CMP( cache,
- ftc_basic_family_compare,
- ftc_gnode_compare,
- hash, gindex,
- &query,
- node,
- error );
- if ( !error )
- {
- *aglyph = FTC_INODE( node )->glyph;
-
- if ( anode )
- {
- *anode = node;
- node->ref_count++;
- }
- }
-
- return error;
- }
-
-
- /*
- *
- * basic small bitmap cache
- *
- */
-
- static
- const FTC_SFamilyClassRec ftc_basic_sbit_family_class =
- {
- {
- sizeof ( FTC_BasicFamilyRec ),
- ftc_basic_family_compare, /* FTC_MruNode_CompareFunc node_compare */
- ftc_basic_family_init, /* FTC_MruNode_InitFunc node_init */
- NULL /* FTC_MruNode_DoneFunc node_done */
- },
-
- ftc_basic_family_get_count,
- ftc_basic_family_load_bitmap
- };
-
-
- static
- const FTC_GCacheClassRec ftc_basic_sbit_cache_class =
- {
- {
- ftc_snode_new, /* FTC_Node_NewFunc node_new */
- ftc_snode_weight, /* FTC_Node_WeightFunc node_weight */
- ftc_snode_compare, /* FTC_Node_CompareFunc node_compare */
- ftc_basic_gnode_compare_faceid, /* FTC_Node_CompareFunc node_remove_faceid */
- ftc_snode_free, /* FTC_Node_FreeFunc node_free */
-
- sizeof ( FTC_GCacheRec ),
- ftc_gcache_init, /* FTC_Cache_InitFunc cache_init */
- ftc_gcache_done /* FTC_Cache_DoneFunc cache_done */
- },
-
- (FTC_MruListClass)&ftc_basic_sbit_family_class
- };
-
-
- /* documentation is in ftcache.h */
-
- FT_EXPORT_DEF( FT_Error )
- FTC_SBitCache_New( FTC_Manager manager,
- FTC_SBitCache *acache )
- {
- return FTC_GCache_New( manager, &ftc_basic_sbit_cache_class,
- (FTC_GCache*)acache );
- }
-
-
- /* documentation is in ftcache.h */
-
- FT_EXPORT_DEF( FT_Error )
- FTC_SBitCache_Lookup( FTC_SBitCache cache,
- FTC_ImageType type,
- FT_UInt gindex,
- FTC_SBit *ansbit,
- FTC_Node *anode )
- {
- FT_Error error;
- FTC_BasicQueryRec query;
- FTC_Node node = NULL; /* make compiler happy */
- FT_Offset hash;
-
-
- /* other argument checks delayed to `FTC_Cache_Lookup' */
- if ( !ansbit )
- return FT_THROW( Invalid_Argument );
-
- *ansbit = NULL;
- if ( anode )
- *anode = NULL;
-
- query.attrs.scaler.face_id = type->face_id;
- query.attrs.scaler.width = type->width;
- query.attrs.scaler.height = type->height;
- query.attrs.load_flags = type->flags;
-
- query.attrs.scaler.pixel = 1;
- query.attrs.scaler.x_res = 0; /* make compilers happy */
- query.attrs.scaler.y_res = 0;
-
- /* beware, the hash must be the same for all glyph ranges! */
- hash = FTC_BASIC_ATTR_HASH( &query.attrs ) +
- gindex / FTC_SBIT_ITEMS_PER_NODE;
-
-#ifdef FTC_INLINE /* inlining is about 50% faster! */
- FTC_GCACHE_LOOKUP_CMP( cache,
- ftc_basic_family_compare,
- ftc_snode_compare,
- hash, gindex,
- &query,
- node,
- error );
-#else
- error = FTC_GCache_Lookup( FTC_GCACHE( cache ),
- hash,
- gindex,
- FTC_GQUERY( &query ),
- &node );
-#endif
- if ( error )
- goto Exit;
-
- *ansbit = FTC_SNODE( node )->sbits +
- ( gindex - FTC_GNODE( node )->gindex );
-
- if ( anode )
- {
- *anode = node;
- node->ref_count++;
- }
-
- Exit:
- return error;
- }
-
-
- /* documentation is in ftcache.h */
-
- FT_EXPORT_DEF( FT_Error )
- FTC_SBitCache_LookupScaler( FTC_SBitCache cache,
- FTC_Scaler scaler,
- FT_ULong load_flags,
- FT_UInt gindex,
- FTC_SBit *ansbit,
- FTC_Node *anode )
- {
- FT_Error error;
- FTC_BasicQueryRec query;
- FTC_Node node = NULL; /* make compiler happy */
- FT_Offset hash;
-
-
- /* other argument checks delayed to `FTC_Cache_Lookup' */
- if ( !ansbit || !scaler )
- return FT_THROW( Invalid_Argument );
-
- *ansbit = NULL;
- if ( anode )
- *anode = NULL;
-
- /*
- * Internal `FTC_BasicAttr->load_flags' is of type `FT_Int32',
- * but public `FT_Face->face_flags' is of type `FT_Long'.
- *
- * On long > int systems, higher bits of load_flags cannot be handled.
- */
-#if FT_ULONG_MAX > 0xFFFFFFFFUL
- if ( load_flags > 0xFFFFFFFFUL )
- FT_TRACE1(( "FTC_ImageCache_LookupScaler:"
- " higher bits in load_flags 0x%lx are dropped\n",
- load_flags & ~0xFFFFFFFFUL ));
-#endif
-
- query.attrs.scaler = scaler[0];
- query.attrs.load_flags = (FT_Int32)load_flags;
-
- /* beware, the hash must be the same for all glyph ranges! */
- hash = FTC_BASIC_ATTR_HASH( &query.attrs ) +
- gindex / FTC_SBIT_ITEMS_PER_NODE;
-
- FTC_GCACHE_LOOKUP_CMP( cache,
- ftc_basic_family_compare,
- ftc_snode_compare,
- hash, gindex,
- &query,
- node,
- error );
- if ( error )
- goto Exit;
-
- *ansbit = FTC_SNODE( node )->sbits +
- ( gindex - FTC_GNODE( node )->gindex );
-
- if ( anode )
- {
- *anode = node;
- node->ref_count++;
- }
-
- Exit:
- return error;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cache/ftccache.c b/contrib/libs/freetype/src/cache/ftccache.c
deleted file mode 100644
index 8a3d887f96..0000000000
--- a/contrib/libs/freetype/src/cache/ftccache.c
+++ /dev/null
@@ -1,584 +0,0 @@
-/****************************************************************************
- *
- * ftccache.c
- *
- * The FreeType internal cache interface (body).
- *
- * Copyright (C) 2000-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include "ftcmanag.h"
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/ftdebug.h>
-
-#include "ftccback.h"
-#include "ftcerror.h"
-
-#undef FT_COMPONENT
-#define FT_COMPONENT cache
-
-
-#define FTC_HASH_MAX_LOAD 2
-#define FTC_HASH_MIN_LOAD 1
-#define FTC_HASH_SUB_LOAD ( FTC_HASH_MAX_LOAD - FTC_HASH_MIN_LOAD )
-
- /* this one _must_ be a power of 2! */
-#define FTC_HASH_INITIAL_SIZE 8
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** CACHE NODE DEFINITIONS *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- /* add a new node to the head of the manager's circular MRU list */
- static void
- ftc_node_mru_link( FTC_Node node,
- FTC_Manager manager )
- {
- void *nl = &manager->nodes_list;
-
-
- FTC_MruNode_Prepend( (FTC_MruNode*)nl,
- (FTC_MruNode)node );
- manager->num_nodes++;
- }
-
-
- /* remove a node from the manager's MRU list */
- static void
- ftc_node_mru_unlink( FTC_Node node,
- FTC_Manager manager )
- {
- void *nl = &manager->nodes_list;
-
-
- FTC_MruNode_Remove( (FTC_MruNode*)nl,
- (FTC_MruNode)node );
- manager->num_nodes--;
- }
-
-
-#ifndef FTC_INLINE
-
- /* move a node to the head of the manager's MRU list */
- static void
- ftc_node_mru_up( FTC_Node node,
- FTC_Manager manager )
- {
- FTC_MruNode_Up( (FTC_MruNode*)&manager->nodes_list,
- (FTC_MruNode)node );
- }
-
-
- /* get a top bucket for specified hash from cache,
- * body for FTC_NODE_TOP_FOR_HASH( cache, hash )
- */
- FT_LOCAL_DEF( FTC_Node* )
- ftc_get_top_node_for_hash( FTC_Cache cache,
- FT_Offset hash )
- {
- FT_Offset idx;
-
-
- idx = hash & cache->mask;
- if ( idx >= cache->p )
- idx = hash & ( cache->mask >> 1 );
-
- return cache->buckets + idx;
- }
-
-#endif /* !FTC_INLINE */
-
-
- /* Note that this function cannot fail. If we cannot re-size the
- * buckets array appropriately, we simply degrade the hash table's
- * performance!
- */
- static void
- ftc_cache_resize( FTC_Cache cache )
- {
- for (;;)
- {
- FTC_Node node, *pnode;
- FT_UFast p = cache->p;
- FT_UFast size = cache->mask + 1; /* available size */
- FT_UFast half = size >> 1;
-
-
- /* do we need to expand the buckets array? */
- if ( cache->slack < 0 )
- {
- FTC_Node new_list = NULL;
-
-
- /* try to expand the buckets array _before_ splitting
- * the bucket lists
- */
- if ( p == size )
- {
- FT_Memory memory = cache->memory;
- FT_Error error;
-
-
- /* if we can't expand the array, leave immediately */
- if ( FT_QRENEW_ARRAY( cache->buckets, size, size * 2 ) )
- break;
-
- cache->mask = 2 * size - 1;
- half = size;
- }
-
- /* the bucket to split */
- pnode = cache->buckets + p - half;
-
- for (;;)
- {
- node = *pnode;
- if ( !node )
- break;
-
- if ( node->hash & half )
- {
- *pnode = node->link;
- node->link = new_list;
- new_list = node;
- }
- else
- pnode = &node->link;
- }
-
- cache->buckets[p] = new_list;
-
- cache->slack += FTC_HASH_MAX_LOAD;
- cache->p = p + 1;
-
- FT_TRACE2(( "ftc_cache_resize: cache %u increased to %u hashes\n",
- cache->index, cache->p ));
- }
-
- /* do we need to shrink the buckets array? */
- else if ( cache->slack > (FT_Long)p * FTC_HASH_SUB_LOAD )
- {
- FTC_Node old_list = cache->buckets[--p];
-
-
- if ( p < FTC_HASH_INITIAL_SIZE )
- break;
-
- if ( p == half )
- {
- FT_Memory memory = cache->memory;
- FT_Error error;
-
-
- /* if we can't shrink the array, leave immediately */
- if ( FT_QRENEW_ARRAY( cache->buckets, size, half ) )
- break;
-
- cache->mask = half - 1;
- }
-
- /* the bucket to merge */
- pnode = cache->buckets + p - half;
-
- while ( *pnode )
- pnode = &(*pnode)->link;
-
- *pnode = old_list;
-
- cache->slack -= FTC_HASH_MAX_LOAD;
- cache->p = p;
-
- FT_TRACE2(( "ftc_cache_resize: cache %u decreased to %u hashes\n",
- cache->index, cache->p ));
- }
-
- /* otherwise, the hash table is balanced */
- else
- break;
- }
- }
-
-
- /* remove a node from its cache's hash table */
- static void
- ftc_node_hash_unlink( FTC_Node node0,
- FTC_Cache cache )
- {
- FTC_Node *pnode = FTC_NODE_TOP_FOR_HASH( cache, node0->hash );
-
-
- for (;;)
- {
- FTC_Node node = *pnode;
-
-
- if ( !node )
- {
- FT_TRACE0(( "ftc_node_hash_unlink: unknown node\n" ));
- return;
- }
-
- if ( node == node0 )
- break;
-
- pnode = &node->link;
- }
-
- *pnode = node0->link;
- node0->link = NULL;
-
- cache->slack++;
- ftc_cache_resize( cache );
- }
-
-
- /* add a node to the `top' of its cache's hash table */
- static void
- ftc_node_hash_link( FTC_Node node,
- FTC_Cache cache )
- {
- FTC_Node *pnode = FTC_NODE_TOP_FOR_HASH( cache, node->hash );
-
-
- node->link = *pnode;
- *pnode = node;
-
- cache->slack--;
- ftc_cache_resize( cache );
- }
-
-
- /* remove a node from the cache manager */
- FT_LOCAL_DEF( void )
- ftc_node_destroy( FTC_Node node,
- FTC_Manager manager )
- {
- FTC_Cache cache;
-
-
-#ifdef FT_DEBUG_ERROR
- /* find node's cache */
- if ( node->cache_index >= manager->num_caches )
- {
- FT_TRACE0(( "ftc_node_destroy: invalid node handle\n" ));
- return;
- }
-#endif
-
- cache = manager->caches[node->cache_index];
-
-#ifdef FT_DEBUG_ERROR
- if ( !cache )
- {
- FT_TRACE0(( "ftc_node_destroy: invalid node handle\n" ));
- return;
- }
-#endif
-
- manager->cur_weight -= cache->clazz.node_weight( node, cache );
-
- /* remove node from mru list */
- ftc_node_mru_unlink( node, manager );
-
- /* remove node from cache's hash table */
- ftc_node_hash_unlink( node, cache );
-
- /* now finalize it */
- cache->clazz.node_free( node, cache );
-
-#if 0
- /* check, just in case of general corruption :-) */
- if ( manager->num_nodes == 0 )
- FT_TRACE0(( "ftc_node_destroy: invalid cache node count (%u)\n",
- manager->num_nodes ));
-#endif
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** ABSTRACT CACHE CLASS *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- FT_LOCAL_DEF( FT_Error )
- ftc_cache_init( FTC_Cache cache )
- {
- FT_Memory memory = cache->memory;
- FT_Error error;
-
-
- cache->p = FTC_HASH_INITIAL_SIZE;
- cache->mask = FTC_HASH_INITIAL_SIZE - 1;
- cache->slack = FTC_HASH_INITIAL_SIZE * FTC_HASH_MAX_LOAD;
-
- FT_MEM_NEW_ARRAY( cache->buckets, FTC_HASH_INITIAL_SIZE );
- return error;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- FTC_Cache_Init( FTC_Cache cache )
- {
- return ftc_cache_init( cache );
- }
-
-
- FT_LOCAL_DEF( void )
- ftc_cache_done( FTC_Cache cache )
- {
- FT_Memory memory = cache->memory;
-
-
- if ( cache->buckets )
- {
- FTC_Manager manager = cache->manager;
- FT_UFast count = cache->p;
- FT_UFast i;
-
-
- for ( i = 0; i < count; i++ )
- {
- FTC_Node node = cache->buckets[i], next;
-
-
- while ( node )
- {
- next = node->link;
- node->link = NULL;
-
- /* remove node from mru list */
- ftc_node_mru_unlink( node, manager );
-
- /* now finalize it */
- manager->cur_weight -= cache->clazz.node_weight( node, cache );
-
- cache->clazz.node_free( node, cache );
- node = next;
- }
- }
- }
-
- FT_FREE( cache->buckets );
-
- cache->p = 0;
- cache->mask = 0;
- cache->slack = 0;
- }
-
-
- FT_LOCAL_DEF( void )
- FTC_Cache_Done( FTC_Cache cache )
- {
- ftc_cache_done( cache );
- }
-
-
- static void
- ftc_cache_add( FTC_Cache cache,
- FT_Offset hash,
- FTC_Node node )
- {
- node->hash = hash;
- node->cache_index = (FT_UShort)cache->index;
- node->ref_count = 0;
-
- ftc_node_hash_link( node, cache );
- ftc_node_mru_link( node, cache->manager );
-
- {
- FTC_Manager manager = cache->manager;
-
-
- manager->cur_weight += cache->clazz.node_weight( node, cache );
-
- if ( manager->cur_weight >= manager->max_weight )
- {
- node->ref_count++;
- FTC_Manager_Compress( manager );
- node->ref_count--;
- }
- }
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- FTC_Cache_NewNode( FTC_Cache cache,
- FT_Offset hash,
- FT_Pointer query,
- FTC_Node *anode )
- {
- FT_Error error;
- FTC_Node node;
-
-
- /*
- * We use the FTC_CACHE_TRYLOOP macros to support out-of-memory
- * errors (OOM) correctly, i.e., by flushing the cache progressively
- * in order to make more room.
- */
-
- FTC_CACHE_TRYLOOP( cache )
- {
- error = cache->clazz.node_new( &node, query, cache );
- }
- FTC_CACHE_TRYLOOP_END( NULL )
-
- if ( error )
- node = NULL;
- else
- {
- /* don't assume that the cache has the same number of buckets, since
- * our allocation request might have triggered global cache flushing
- */
- ftc_cache_add( cache, hash, node );
- }
-
- *anode = node;
- return error;
- }
-
-
-#ifndef FTC_INLINE
-
- FT_LOCAL_DEF( FT_Error )
- FTC_Cache_Lookup( FTC_Cache cache,
- FT_Offset hash,
- FT_Pointer query,
- FTC_Node *anode )
- {
- FTC_Node* bucket;
- FTC_Node* pnode;
- FTC_Node node;
- FT_Error error = FT_Err_Ok;
- FT_Bool list_changed = FALSE;
-
- FTC_Node_CompareFunc compare = cache->clazz.node_compare;
-
-
- if ( !cache || !anode )
- return FT_THROW( Invalid_Argument );
-
- /* Go to the `top' node of the list sharing same masked hash */
- bucket = pnode = FTC_NODE_TOP_FOR_HASH( cache, hash );
-
- /* Lookup a node with exactly same hash and queried properties. */
- /* NOTE: _nodcomp() may change the linked list to reduce memory. */
- for (;;)
- {
- node = *pnode;
- if ( !node )
- goto NewNode;
-
- if ( node->hash == hash &&
- compare( node, query, cache, &list_changed ) )
- break;
-
- pnode = &node->link;
- }
-
- if ( list_changed )
- {
- /* Update bucket by modified linked list */
- bucket = pnode = FTC_NODE_TOP_FOR_HASH( cache, hash );
-
- /* Update pnode by modified linked list */
- while ( *pnode != node )
- {
- if ( !*pnode )
- {
- FT_ERROR(( "FTC_Cache_Lookup: oops!!! node missing\n" ));
- goto NewNode;
- }
- else
- pnode = &(*pnode)->link;
- }
- }
-
- /* Reorder the list to move the found node to the `top' */
- if ( node != *bucket )
- {
- *pnode = node->link;
- node->link = *bucket;
- *bucket = node;
- }
-
- /* move to head of MRU list */
- {
- FTC_Manager manager = cache->manager;
-
-
- if ( node != manager->nodes_list )
- ftc_node_mru_up( node, manager );
- }
- *anode = node;
-
- return error;
-
- NewNode:
- return FTC_Cache_NewNode( cache, hash, query, anode );
- }
-
-#endif /* !FTC_INLINE */
-
-
- FT_LOCAL_DEF( void )
- FTC_Cache_RemoveFaceID( FTC_Cache cache,
- FTC_FaceID face_id )
- {
- FTC_Manager manager = cache->manager;
- FT_UFast count = cache->p;
- FT_UFast i;
-
-
- for ( i = 0; i < count; i++ )
- {
- FTC_Node* pnode = cache->buckets + i;
-
-
- for (;;)
- {
- FTC_Node node = *pnode;
-
-
- if ( !node )
- break;
-
- if ( cache->clazz.node_remove_faceid( node, face_id, cache, NULL ) )
- {
- *pnode = node->link;
-
- manager->cur_weight -= cache->clazz.node_weight( node, cache );
- ftc_node_mru_unlink( node, manager );
-
- cache->clazz.node_free( node, cache );
-
- cache->slack++;
- }
- else
- pnode = &node->link;
- }
- }
-
- ftc_cache_resize( cache );
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cache/ftccache.h b/contrib/libs/freetype/src/cache/ftccache.h
deleted file mode 100644
index 85d321c12c..0000000000
--- a/contrib/libs/freetype/src/cache/ftccache.h
+++ /dev/null
@@ -1,359 +0,0 @@
-/****************************************************************************
- *
- * ftccache.h
- *
- * FreeType internal cache interface (specification).
- *
- * Copyright (C) 2000-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTCCACHE_H_
-#define FTCCACHE_H_
-
-#include <freetype/internal/compiler-macros.h>
-#include "ftcmru.h"
-
-FT_BEGIN_HEADER
-
-#define FTC_FACE_ID_HASH( i ) \
- ( ( (FT_Offset)(i) >> 3 ) ^ ( (FT_Offset)(i) << 7 ) )
-
- /* handle to cache object */
- typedef struct FTC_CacheRec_* FTC_Cache;
-
- /* handle to cache class */
- typedef const struct FTC_CacheClassRec_* FTC_CacheClass;
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** CACHE NODE DEFINITIONS *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- /**************************************************************************
- *
- * Each cache controls one or more cache nodes. Each node is part of
- * the global_lru list of the manager. Its `data' field however is used
- * as a reference count for now.
- *
- * A node can be anything, depending on the type of information held by
- * the cache. It can be an individual glyph image, a set of bitmaps
- * glyphs for a given size, some metrics, etc.
- *
- */
-
- /* structure size should be 20 bytes on 32-bits machines */
- typedef struct FTC_NodeRec_
- {
- FTC_MruNodeRec mru; /* circular mru list pointer */
- FTC_Node link; /* used for hashing */
- FT_Offset hash; /* used for hashing too */
- FT_UShort cache_index; /* index of cache the node belongs to */
- FT_Short ref_count; /* reference count for this node */
-
- } FTC_NodeRec;
-
-
-#define FTC_NODE( x ) ( (FTC_Node)(x) )
-#define FTC_NODE_P( x ) ( (FTC_Node*)(x) )
-
-#define FTC_NODE_NEXT( x ) FTC_NODE( (x)->mru.next )
-#define FTC_NODE_PREV( x ) FTC_NODE( (x)->mru.prev )
-
- /* address the hash table entries */
-#ifdef FTC_INLINE
-#define FTC_NODE_TOP_FOR_HASH( cache, hash ) \
- ( ( cache )->buckets + \
- ( ( ( ( hash ) & ( cache )->mask ) >= ( cache )->p ) \
- ? ( ( hash ) & ( ( cache )->mask >> 1 ) ) \
- : ( ( hash ) & ( cache )->mask ) ) )
-#else
- FT_LOCAL( FTC_Node* )
- ftc_get_top_node_for_hash( FTC_Cache cache,
- FT_Offset hash );
-#define FTC_NODE_TOP_FOR_HASH( cache, hash ) \
- ftc_get_top_node_for_hash( ( cache ), ( hash ) )
-#endif
-
- FT_LOCAL( void )
- ftc_node_destroy( FTC_Node node,
- FTC_Manager manager );
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** CACHE DEFINITIONS *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- /* initialize a new cache node */
- typedef FT_Error
- (*FTC_Node_NewFunc)( FTC_Node *pnode,
- FT_Pointer query,
- FTC_Cache cache );
-
- typedef FT_Offset
- (*FTC_Node_WeightFunc)( FTC_Node node,
- FTC_Cache cache );
-
- /* compare a node to a given key pair */
- typedef FT_Bool
- (*FTC_Node_CompareFunc)( FTC_Node node,
- FT_Pointer key,
- FTC_Cache cache,
- FT_Bool* list_changed );
-
-
- typedef void
- (*FTC_Node_FreeFunc)( FTC_Node node,
- FTC_Cache cache );
-
- typedef FT_Error
- (*FTC_Cache_InitFunc)( FTC_Cache cache );
-
- typedef void
- (*FTC_Cache_DoneFunc)( FTC_Cache cache );
-
-
- typedef struct FTC_CacheClassRec_
- {
- FTC_Node_NewFunc node_new;
- FTC_Node_WeightFunc node_weight;
- FTC_Node_CompareFunc node_compare;
- FTC_Node_CompareFunc node_remove_faceid;
- FTC_Node_FreeFunc node_free;
-
- FT_Offset cache_size;
- FTC_Cache_InitFunc cache_init;
- FTC_Cache_DoneFunc cache_done;
-
- } FTC_CacheClassRec;
-
-
- /* each cache really implements a hash table to manage its nodes */
- /* the number of the table entries (buckets) can change dynamically */
- /* each bucket contains a linked lists of nodes for a given hash */
- typedef struct FTC_CacheRec_
- {
- FT_UFast p; /* hash table counter */
- FT_UFast mask; /* hash table index range */
- FT_Long slack;
- FTC_Node* buckets;
-
- FTC_CacheClassRec clazz; /* local copy, for speed */
-
- FTC_Manager manager;
- FT_Memory memory;
- FT_UInt index; /* in manager's table */
-
- FTC_CacheClass org_class; /* original class pointer */
-
- } FTC_CacheRec;
-
-
-#define FTC_CACHE( x ) ( (FTC_Cache)(x) )
-#define FTC_CACHE_P( x ) ( (FTC_Cache*)(x) )
-
-
- /* default cache initialize */
- FT_LOCAL( FT_Error )
- FTC_Cache_Init( FTC_Cache cache );
-
- /* default cache finalizer */
- FT_LOCAL( void )
- FTC_Cache_Done( FTC_Cache cache );
-
- /* Call this function to look up the cache. If no corresponding
- * node is found, a new one is automatically created. This function
- * is capable of flushing the cache adequately to make room for the
- * new cache object.
- */
-
-#ifndef FTC_INLINE
- FT_LOCAL( FT_Error )
- FTC_Cache_Lookup( FTC_Cache cache,
- FT_Offset hash,
- FT_Pointer query,
- FTC_Node *anode );
-#endif
-
- FT_LOCAL( FT_Error )
- FTC_Cache_NewNode( FTC_Cache cache,
- FT_Offset hash,
- FT_Pointer query,
- FTC_Node *anode );
-
- /* Remove all nodes that relate to a given face_id. This is useful
- * when un-installing fonts. Note that if a cache node relates to
- * the face_id but is locked (i.e., has `ref_count > 0'), the node
- * will _not_ be destroyed, but its internal face_id reference will
- * be modified.
- *
- * The final result will be that the node will never come back
- * in further lookup requests, and will be flushed on demand from
- * the cache normally when its reference count reaches 0.
- */
- FT_LOCAL( void )
- FTC_Cache_RemoveFaceID( FTC_Cache cache,
- FTC_FaceID face_id );
-
-
-#ifdef FTC_INLINE
-
-#define FTC_CACHE_LOOKUP_CMP( cache, nodecmp, hash, query, node, error ) \
- FT_BEGIN_STMNT \
- FTC_Node *_bucket, *_pnode, _node; \
- FTC_Cache _cache = FTC_CACHE( cache ); \
- FT_Offset _hash = (FT_Offset)(hash); \
- FTC_Node_CompareFunc _nodcomp = (FTC_Node_CompareFunc)(nodecmp); \
- FT_Bool _list_changed = FALSE; \
- \
- \
- error = FT_Err_Ok; \
- node = NULL; \
- \
- /* Go to the `top' node of the list sharing same masked hash */ \
- _bucket = _pnode = FTC_NODE_TOP_FOR_HASH( _cache, _hash ); \
- \
- /* Look up a node with identical hash and queried properties. */ \
- /* NOTE: _nodcomp() may change the linked list to reduce memory. */ \
- for (;;) \
- { \
- _node = *_pnode; \
- if ( !_node ) \
- goto NewNode_; \
- \
- if ( _node->hash == _hash && \
- _nodcomp( _node, query, _cache, &_list_changed ) ) \
- break; \
- \
- _pnode = &_node->link; \
- } \
- \
- if ( _list_changed ) \
- { \
- /* Update _bucket by possibly modified linked list */ \
- _bucket = _pnode = FTC_NODE_TOP_FOR_HASH( _cache, _hash ); \
- \
- /* Update _pnode by possibly modified linked list */ \
- while ( *_pnode != _node ) \
- { \
- if ( !*_pnode ) \
- { \
- FT_ERROR(( "FTC_CACHE_LOOKUP_CMP: oops!!! node missing\n" )); \
- goto NewNode_; \
- } \
- else \
- _pnode = &(*_pnode)->link; \
- } \
- } \
- \
- /* Reorder the list to move the found node to the `top' */ \
- if ( _node != *_bucket ) \
- { \
- *_pnode = _node->link; \
- _node->link = *_bucket; \
- *_bucket = _node; \
- } \
- \
- /* Update MRU list */ \
- { \
- FTC_Manager _manager = _cache->manager; \
- void* _nl = &_manager->nodes_list; \
- \
- \
- if ( _node != _manager->nodes_list ) \
- FTC_MruNode_Up( (FTC_MruNode*)_nl, \
- (FTC_MruNode)_node ); \
- } \
- goto Ok_; \
- \
- NewNode_: \
- error = FTC_Cache_NewNode( _cache, _hash, query, &_node ); \
- \
- Ok_: \
- node = _node; \
- FT_END_STMNT
-
-#else /* !FTC_INLINE */
-
-#define FTC_CACHE_LOOKUP_CMP( cache, nodecmp, hash, query, node, error ) \
- FT_BEGIN_STMNT \
- error = FTC_Cache_Lookup( FTC_CACHE( cache ), hash, query, \
- (FTC_Node*)&(node) ); \
- FT_END_STMNT
-
-#endif /* !FTC_INLINE */
-
-
- /*
- * This macro, together with FTC_CACHE_TRYLOOP_END, defines a retry
- * loop to flush the cache repeatedly in case of memory overflows.
- *
- * It is used when creating a new cache node, or within a lookup
- * that needs to allocate data (e.g. the sbit cache lookup).
- *
- * Example:
- *
- * {
- * FTC_CACHE_TRYLOOP( cache )
- * error = load_data( ... );
- * FTC_CACHE_TRYLOOP_END()
- * }
- *
- */
-#define FTC_CACHE_TRYLOOP( cache ) \
- { \
- FTC_Manager _try_manager = FTC_CACHE( cache )->manager; \
- FT_UInt _try_count = 4; \
- \
- \
- for (;;) \
- { \
- FT_UInt _try_done;
-
-
-#define FTC_CACHE_TRYLOOP_END( list_changed ) \
- if ( !error || FT_ERR_NEQ( error, Out_Of_Memory ) ) \
- break; \
- \
- _try_done = FTC_Manager_FlushN( _try_manager, _try_count ); \
- if ( _try_done > 0 && list_changed != NULL ) \
- *(FT_Bool*)( list_changed ) = TRUE; \
- \
- if ( _try_done == 0 ) \
- break; \
- \
- if ( _try_done == _try_count ) \
- { \
- _try_count *= 2; \
- if ( _try_count < _try_done || \
- _try_count > _try_manager->num_nodes ) \
- _try_count = _try_manager->num_nodes; \
- } \
- } \
- }
-
- /* */
-
-FT_END_HEADER
-
-
-#endif /* FTCCACHE_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cache/ftccback.h b/contrib/libs/freetype/src/cache/ftccback.h
deleted file mode 100644
index a1d76baa74..0000000000
--- a/contrib/libs/freetype/src/cache/ftccback.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
- *
- * ftccback.h
- *
- * Callback functions of the caching sub-system (specification only).
- *
- * Copyright (C) 2004-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-#ifndef FTCCBACK_H_
-#define FTCCBACK_H_
-
-#include <freetype/ftcache.h>
-#include "ftccache.h"
-
-FT_BEGIN_HEADER
-
- FT_LOCAL( void )
- ftc_inode_free( FTC_Node inode,
- FTC_Cache cache );
-
- FT_LOCAL( FT_Error )
- ftc_inode_new( FTC_Node *pinode,
- FT_Pointer gquery,
- FTC_Cache cache );
-
- FT_LOCAL( FT_Offset )
- ftc_inode_weight( FTC_Node inode,
- FTC_Cache cache );
-
-
- FT_LOCAL( void )
- ftc_snode_free( FTC_Node snode,
- FTC_Cache cache );
-
- FT_LOCAL( FT_Error )
- ftc_snode_new( FTC_Node *psnode,
- FT_Pointer gquery,
- FTC_Cache cache );
-
- FT_LOCAL( FT_Offset )
- ftc_snode_weight( FTC_Node snode,
- FTC_Cache cache );
-
- FT_LOCAL( FT_Bool )
- ftc_snode_compare( FTC_Node snode,
- FT_Pointer gquery,
- FTC_Cache cache,
- FT_Bool* list_changed );
-
-
- FT_LOCAL( FT_Bool )
- ftc_gnode_compare( FTC_Node gnode,
- FT_Pointer gquery,
- FTC_Cache cache,
- FT_Bool* list_changed );
-
-
- FT_LOCAL( FT_Error )
- ftc_gcache_init( FTC_Cache cache );
-
- FT_LOCAL( void )
- ftc_gcache_done( FTC_Cache cache );
-
-
- FT_LOCAL( FT_Error )
- ftc_cache_init( FTC_Cache cache );
-
- FT_LOCAL( void )
- ftc_cache_done( FTC_Cache cache );
-
-FT_END_HEADER
-
-#endif /* FTCCBACK_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cache/ftccmap.c b/contrib/libs/freetype/src/cache/ftccmap.c
deleted file mode 100644
index b5c61e8160..0000000000
--- a/contrib/libs/freetype/src/cache/ftccmap.c
+++ /dev/null
@@ -1,323 +0,0 @@
-/****************************************************************************
- *
- * ftccmap.c
- *
- * FreeType CharMap cache (body)
- *
- * Copyright (C) 2000-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/freetype.h>
-#include <freetype/ftcache.h>
-#include "ftcmanag.h"
-#include <freetype/internal/ftmemory.h>
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/ftdebug.h>
-
-#include "ftccback.h"
-#include "ftcerror.h"
-
-#undef FT_COMPONENT
-#define FT_COMPONENT cache
-
-
- /**************************************************************************
- *
- * Each FTC_CMapNode contains a simple array to map a range of character
- * codes to equivalent glyph indices.
- *
- * For now, the implementation is very basic: Each node maps a range of
- * 128 consecutive character codes to their corresponding glyph indices.
- *
- * We could do more complex things, but I don't think it is really very
- * useful.
- *
- */
-
-
- /* number of glyph indices / character code per node */
-#define FTC_CMAP_INDICES_MAX 128
-
- /* compute a query/node hash */
-#define FTC_CMAP_HASH( faceid, index, charcode ) \
- ( FTC_FACE_ID_HASH( faceid ) + 211 * (index) + \
- ( (charcode) / FTC_CMAP_INDICES_MAX ) )
-
- /* the charmap query */
- typedef struct FTC_CMapQueryRec_
- {
- FTC_FaceID face_id;
- FT_UInt cmap_index;
- FT_UInt32 char_code;
-
- } FTC_CMapQueryRec, *FTC_CMapQuery;
-
-#define FTC_CMAP_QUERY( x ) ((FTC_CMapQuery)(x))
-
- /* the cmap cache node */
- typedef struct FTC_CMapNodeRec_
- {
- FTC_NodeRec node;
- FTC_FaceID face_id;
- FT_UInt cmap_index;
- FT_UInt32 first; /* first character in node */
- FT_UInt16 indices[FTC_CMAP_INDICES_MAX]; /* array of glyph indices */
-
- } FTC_CMapNodeRec, *FTC_CMapNode;
-
-#define FTC_CMAP_NODE( x ) ( (FTC_CMapNode)( x ) )
-
- /* if (indices[n] == FTC_CMAP_UNKNOWN), we assume that the corresponding */
- /* glyph indices haven't been queried through FT_Get_Glyph_Index() yet */
-#define FTC_CMAP_UNKNOWN (FT_UInt16)~0
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** CHARMAP NODES *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- FT_CALLBACK_DEF( void )
- ftc_cmap_node_free( FTC_Node ftcnode,
- FTC_Cache cache )
- {
- FTC_CMapNode node = (FTC_CMapNode)ftcnode;
- FT_Memory memory = cache->memory;
-
-
- FT_FREE( node );
- }
-
-
- /* initialize a new cmap node */
- FT_CALLBACK_DEF( FT_Error )
- ftc_cmap_node_new( FTC_Node *ftcanode,
- FT_Pointer ftcquery,
- FTC_Cache cache )
- {
- FTC_CMapNode *anode = (FTC_CMapNode*)ftcanode;
- FTC_CMapQuery query = (FTC_CMapQuery)ftcquery;
- FT_Error error;
- FT_Memory memory = cache->memory;
- FTC_CMapNode node = NULL;
- FT_UInt nn;
-
-
- if ( !FT_QNEW( node ) )
- {
- node->face_id = query->face_id;
- node->cmap_index = query->cmap_index;
- node->first = (query->char_code / FTC_CMAP_INDICES_MAX) *
- FTC_CMAP_INDICES_MAX;
-
- for ( nn = 0; nn < FTC_CMAP_INDICES_MAX; nn++ )
- node->indices[nn] = FTC_CMAP_UNKNOWN;
- }
-
- *anode = node;
- return error;
- }
-
-
- /* compute the weight of a given cmap node */
- FT_CALLBACK_DEF( FT_Offset )
- ftc_cmap_node_weight( FTC_Node cnode,
- FTC_Cache cache )
- {
- FT_UNUSED( cnode );
- FT_UNUSED( cache );
-
- return sizeof ( *cnode );
- }
-
-
- /* compare a cmap node to a given query */
- FT_CALLBACK_DEF( FT_Bool )
- ftc_cmap_node_compare( FTC_Node ftcnode,
- FT_Pointer ftcquery,
- FTC_Cache cache,
- FT_Bool* list_changed )
- {
- FTC_CMapNode node = (FTC_CMapNode)ftcnode;
- FTC_CMapQuery query = (FTC_CMapQuery)ftcquery;
- FT_UNUSED( cache );
-
-
- if ( list_changed )
- *list_changed = FALSE;
- if ( node->face_id == query->face_id &&
- node->cmap_index == query->cmap_index )
- {
- FT_UInt32 offset = (FT_UInt32)( query->char_code - node->first );
-
-
- return FT_BOOL( offset < FTC_CMAP_INDICES_MAX );
- }
-
- return 0;
- }
-
-
- FT_CALLBACK_DEF( FT_Bool )
- ftc_cmap_node_remove_faceid( FTC_Node ftcnode,
- FT_Pointer ftcface_id,
- FTC_Cache cache,
- FT_Bool* list_changed )
- {
- FTC_CMapNode node = (FTC_CMapNode)ftcnode;
- FTC_FaceID face_id = (FTC_FaceID)ftcface_id;
- FT_UNUSED( cache );
-
-
- if ( list_changed )
- *list_changed = FALSE;
- return FT_BOOL( node->face_id == face_id );
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** GLYPH IMAGE CACHE *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- static
- const FTC_CacheClassRec ftc_cmap_cache_class =
- {
- ftc_cmap_node_new, /* FTC_Node_NewFunc node_new */
- ftc_cmap_node_weight, /* FTC_Node_WeightFunc node_weight */
- ftc_cmap_node_compare, /* FTC_Node_CompareFunc node_compare */
- ftc_cmap_node_remove_faceid, /* FTC_Node_CompareFunc node_remove_faceid */
- ftc_cmap_node_free, /* FTC_Node_FreeFunc node_free */
-
- sizeof ( FTC_CacheRec ),
- ftc_cache_init, /* FTC_Cache_InitFunc cache_init */
- ftc_cache_done, /* FTC_Cache_DoneFunc cache_done */
- };
-
-
- /* documentation is in ftcache.h */
-
- FT_EXPORT_DEF( FT_Error )
- FTC_CMapCache_New( FTC_Manager manager,
- FTC_CMapCache *acache )
- {
- return FTC_Manager_RegisterCache( manager,
- &ftc_cmap_cache_class,
- FTC_CACHE_P( acache ) );
- }
-
-
- /* documentation is in ftcache.h */
-
- FT_EXPORT_DEF( FT_UInt )
- FTC_CMapCache_Lookup( FTC_CMapCache cmap_cache,
- FTC_FaceID face_id,
- FT_Int cmap_index,
- FT_UInt32 char_code )
- {
- FTC_Cache cache = FTC_CACHE( cmap_cache );
- FTC_CMapQueryRec query;
- FTC_Node node;
- FT_Error error;
- FT_UInt gindex = 0;
- FT_Offset hash;
- FT_Int no_cmap_change = 0;
-
-
- if ( cmap_index < 0 )
- {
- /* Treat a negative cmap index as a special value, meaning that you */
- /* don't want to change the FT_Face's character map through this */
- /* call. This can be useful if the face requester callback already */
- /* sets the face's charmap to the appropriate value. */
-
- no_cmap_change = 1;
- cmap_index = 0;
- }
-
- if ( !cache )
- {
- FT_TRACE0(( "FTC_CMapCache_Lookup: bad arguments, returning 0\n" ));
- return 0;
- }
-
- query.face_id = face_id;
- query.cmap_index = (FT_UInt)cmap_index;
- query.char_code = char_code;
-
- hash = FTC_CMAP_HASH( face_id, (FT_UInt)cmap_index, char_code );
-
-#ifdef FTC_INLINE
- FTC_CACHE_LOOKUP_CMP( cache, ftc_cmap_node_compare, hash, &query,
- node, error );
-#else
- error = FTC_Cache_Lookup( cache, hash, &query, &node );
-#endif
- if ( error )
- goto Exit;
-
- FT_ASSERT( char_code - FTC_CMAP_NODE( node )->first <
- FTC_CMAP_INDICES_MAX );
-
- /* something rotten can happen with rogue clients */
- if ( char_code - FTC_CMAP_NODE( node )->first >= FTC_CMAP_INDICES_MAX )
- return 0; /* XXX: should return appropriate error */
-
- gindex = FTC_CMAP_NODE( node )->indices[char_code -
- FTC_CMAP_NODE( node )->first];
- if ( gindex == FTC_CMAP_UNKNOWN )
- {
- FT_Face face;
-
-
- gindex = 0;
-
- error = FTC_Manager_LookupFace( cache->manager,
- FTC_CMAP_NODE( node )->face_id,
- &face );
- if ( error )
- goto Exit;
-
- if ( cmap_index < face->num_charmaps )
- {
- FT_CharMap old = face->charmap;
- FT_CharMap cmap = face->charmaps[cmap_index];
-
-
- if ( !no_cmap_change )
- face->charmap = cmap;
-
- gindex = FT_Get_Char_Index( face, char_code );
-
- if ( !no_cmap_change )
- face->charmap = old;
- }
-
- FTC_CMAP_NODE( node )->indices[char_code -
- FTC_CMAP_NODE( node )->first]
- = (FT_UShort)gindex;
- }
-
- Exit:
- return gindex;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cache/ftcerror.h b/contrib/libs/freetype/src/cache/ftcerror.h
deleted file mode 100644
index daabcc6121..0000000000
--- a/contrib/libs/freetype/src/cache/ftcerror.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
- *
- * ftcerror.h
- *
- * Caching sub-system error codes (specification only).
- *
- * Copyright (C) 2001-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /**************************************************************************
- *
- * This file is used to define the caching sub-system error enumeration
- * constants.
- *
- */
-
-#ifndef FTCERROR_H_
-#define FTCERROR_H_
-
-#include <freetype/ftmoderr.h>
-
-#undef FTERRORS_H_
-
-#undef FT_ERR_PREFIX
-#define FT_ERR_PREFIX FTC_Err_
-#define FT_ERR_BASE FT_Mod_Err_Cache
-
-#include <freetype/fterrors.h>
-
-#endif /* FTCERROR_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cache/ftcglyph.c b/contrib/libs/freetype/src/cache/ftcglyph.c
deleted file mode 100644
index 5e7856378a..0000000000
--- a/contrib/libs/freetype/src/cache/ftcglyph.c
+++ /dev/null
@@ -1,204 +0,0 @@
-/****************************************************************************
- *
- * ftcglyph.c
- *
- * FreeType Glyph Image (FT_Glyph) cache (body).
- *
- * Copyright (C) 2000-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftobjs.h>
-#include <freetype/ftcache.h>
-#include "ftcglyph.h"
-#include <freetype/fterrors.h>
-
-#include "ftccback.h"
-#include "ftcerror.h"
-
-
- /* create a new chunk node, setting its cache index and ref count */
- FT_LOCAL_DEF( void )
- FTC_GNode_Init( FTC_GNode gnode,
- FT_UInt gindex,
- FTC_Family family )
- {
- gnode->family = family;
- gnode->gindex = gindex;
- family->num_nodes++;
- }
-
-
- FT_LOCAL_DEF( void )
- FTC_GNode_UnselectFamily( FTC_GNode gnode,
- FTC_Cache cache )
- {
- FTC_Family family = gnode->family;
-
-
- gnode->family = NULL;
- if ( family && --family->num_nodes == 0 )
- FTC_FAMILY_FREE( family, cache );
- }
-
-
- FT_LOCAL_DEF( void )
- FTC_GNode_Done( FTC_GNode gnode,
- FTC_Cache cache )
- {
- /* finalize the node */
- gnode->gindex = 0;
-
- FTC_GNode_UnselectFamily( gnode, cache );
- }
-
-
- FT_LOCAL_DEF( FT_Bool )
- ftc_gnode_compare( FTC_Node ftcgnode,
- FT_Pointer ftcgquery,
- FTC_Cache cache,
- FT_Bool* list_changed )
- {
- FTC_GNode gnode = (FTC_GNode)ftcgnode;
- FTC_GQuery gquery = (FTC_GQuery)ftcgquery;
- FT_UNUSED( cache );
-
-
- if ( list_changed )
- *list_changed = FALSE;
- return FT_BOOL( gnode->family == gquery->family &&
- gnode->gindex == gquery->gindex );
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** CHUNK SETS *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- FT_LOCAL_DEF( void )
- FTC_Family_Init( FTC_Family family,
- FTC_Cache cache )
- {
- FTC_GCacheClass clazz = FTC_CACHE_GCACHE_CLASS( cache );
-
-
- family->clazz = clazz->family_class;
- family->num_nodes = 0;
- family->cache = cache;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- ftc_gcache_init( FTC_Cache cache )
- {
- FTC_GCache gcache = (FTC_GCache)cache;
- FT_Error error;
-
-
- error = FTC_Cache_Init( cache );
- if ( !error )
- {
- FTC_GCacheClass clazz = (FTC_GCacheClass)cache->org_class;
-
- FTC_MruList_Init( &gcache->families,
- clazz->family_class,
- 0, /* no maximum here! */
- cache,
- cache->memory );
- }
-
- return error;
- }
-
-
-#if 0
-
- FT_LOCAL_DEF( FT_Error )
- FTC_GCache_Init( FTC_GCache gcache )
- {
- return ftc_gcache_init( FTC_CACHE( gcache ) );
- }
-
-#endif /* 0 */
-
-
- FT_LOCAL_DEF( void )
- ftc_gcache_done( FTC_Cache cache )
- {
- FTC_GCache gcache = (FTC_GCache)cache;
-
-
- FTC_Cache_Done( cache );
- FTC_MruList_Done( &gcache->families );
- }
-
-
-#if 0
-
- FT_LOCAL_DEF( void )
- FTC_GCache_Done( FTC_GCache gcache )
- {
- ftc_gcache_done( FTC_CACHE( gcache ) );
- }
-
-#endif /* 0 */
-
-
- FT_LOCAL_DEF( FT_Error )
- FTC_GCache_New( FTC_Manager manager,
- FTC_GCacheClass clazz,
- FTC_GCache *acache )
- {
- return FTC_Manager_RegisterCache( manager, (FTC_CacheClass)clazz,
- (FTC_Cache*)acache );
- }
-
-
-#ifndef FTC_INLINE
-
- FT_LOCAL_DEF( FT_Error )
- FTC_GCache_Lookup( FTC_GCache gcache,
- FT_Offset hash,
- FT_UInt gindex,
- FTC_GQuery query,
- FTC_Node *anode )
- {
- FT_Error error;
-
-
- query->gindex = gindex;
-
- FTC_MRULIST_LOOKUP( &gcache->families, query, query->family, error );
- if ( !error )
- {
- FTC_Family family = query->family;
-
-
- /* prevent the family from being destroyed too early when an */
- /* out-of-memory condition occurs during glyph node initialization. */
- family->num_nodes++;
-
- error = FTC_Cache_Lookup( FTC_CACHE( gcache ), hash, query, anode );
-
- if ( --family->num_nodes == 0 )
- FTC_FAMILY_FREE( family, FTC_CACHE( gcache ) );
- }
- return error;
- }
-
-#endif /* !FTC_INLINE */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cache/ftcglyph.h b/contrib/libs/freetype/src/cache/ftcglyph.h
deleted file mode 100644
index b1a96da8ec..0000000000
--- a/contrib/libs/freetype/src/cache/ftcglyph.h
+++ /dev/null
@@ -1,314 +0,0 @@
-/****************************************************************************
- *
- * ftcglyph.h
- *
- * FreeType abstract glyph cache (specification).
- *
- * Copyright (C) 2000-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /*
- *
- * FTC_GCache is an _abstract_ cache object optimized to store glyph
- * data. It works as follows:
- *
- * - It manages FTC_GNode objects. Each one of them can hold one or more
- * glyph `items'. Item types are not specified in the FTC_GCache but
- * in classes that extend it.
- *
- * - Glyph attributes, like face ID, character size, render mode, etc.,
- * can be grouped into abstract `glyph families'. This avoids storing
- * the attributes within the FTC_GCache, since it is likely that many
- * FTC_GNodes will belong to the same family in typical uses.
- *
- * - Each FTC_GNode is thus an FTC_Node with two additional fields:
- *
- * * gindex: A glyph index, or the first index in a glyph range.
- * * family: A pointer to a glyph `family'.
- *
- * - Family types are not fully specific in the FTC_Family type, but
- * by classes that extend it.
- *
- * Note that both FTC_ImageCache and FTC_SBitCache extend FTC_GCache.
- * They share an FTC_Family sub-class called FTC_BasicFamily which is
- * used to store the following data: face ID, pixel/point sizes, load
- * flags. For more details see the file `src/cache/ftcbasic.c'.
- *
- * Client applications can extend FTC_GNode with their own FTC_GNode
- * and FTC_Family sub-classes to implement more complex caches (e.g.,
- * handling automatic synthesis, like obliquing & emboldening, colored
- * glyphs, etc.).
- *
- * See also the FTC_ICache & FTC_SCache classes in `ftcimage.h' and
- * `ftcsbits.h', which both extend FTC_GCache with additional
- * optimizations.
- *
- * A typical FTC_GCache implementation must provide at least the
- * following:
- *
- * - FTC_GNode sub-class, e.g. MyNode, with relevant methods:
- * my_node_new (must call FTC_GNode_Init)
- * my_node_free (must call FTC_GNode_Done)
- * my_node_compare (must call ftc_gnode_compare)
- * my_node_remove_faceid (must call ftc_gnode_unselect in case
- * of match)
- *
- * - FTC_Family sub-class, e.g. MyFamily, with relevant methods:
- * my_family_compare
- * my_family_init
- * my_family_done
- *
- * - FTC_GQuery sub-class, e.g. MyQuery, to hold cache-specific query
- * data.
- *
- * - Constant structures for a FTC_GNodeClass.
- *
- * - MyCacheNew() can be implemented easily as a call to the convenience
- * function FTC_GCache_New.
- *
- * - MyCacheLookup with a call to FTC_GCache_Lookup. This function will
- * automatically:
- *
- * - Search for the corresponding family in the cache, or create
- * a new one if necessary. Put it in FTC_GQUERY(myquery).family
- *
- * - Call FTC_Cache_Lookup.
- *
- * If it returns NULL, you should create a new node, then call
- * ftc_cache_add as usual.
- */
-
-
- /**************************************************************************
- *
- * Important: The functions defined in this file are only used to
- * implement an abstract glyph cache class. You need to
- * provide additional logic to implement a complete cache.
- *
- */
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /********* *********/
- /********* WARNING, THIS IS BETA CODE. *********/
- /********* *********/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
-#ifndef FTCGLYPH_H_
-#define FTCGLYPH_H_
-
-
-#include "ftcmanag.h"
-
-
-FT_BEGIN_HEADER
-
-
- /*
- * We can group glyphs into `families'. Each family correspond to a
- * given face ID, character size, transform, etc.
- *
- * Families are implemented as MRU list nodes. They are
- * reference-counted.
- */
-
- typedef struct FTC_FamilyRec_
- {
- FTC_MruNodeRec mrunode;
- FT_UInt num_nodes; /* current number of nodes in this family */
- FTC_Cache cache;
- FTC_MruListClass clazz;
-
- } FTC_FamilyRec, *FTC_Family;
-
-#define FTC_FAMILY( x ) ( (FTC_Family)(x) )
-#define FTC_FAMILY_P( x ) ( (FTC_Family*)(x) )
-
-
- typedef struct FTC_GNodeRec_
- {
- FTC_NodeRec node;
- FTC_Family family;
- FT_UInt gindex;
-
- } FTC_GNodeRec, *FTC_GNode;
-
-#define FTC_GNODE( x ) ( (FTC_GNode)(x) )
-#define FTC_GNODE_P( x ) ( (FTC_GNode*)(x) )
-
-
- typedef struct FTC_GQueryRec_
- {
- FT_UInt gindex;
- FTC_Family family;
-
- } FTC_GQueryRec, *FTC_GQuery;
-
-#define FTC_GQUERY( x ) ( (FTC_GQuery)(x) )
-
-
- /**************************************************************************
- *
- * These functions are exported so that they can be called from
- * user-provided cache classes; otherwise, they are really part of the
- * cache sub-system internals.
- */
-
- /* must be called by derived FTC_Node_InitFunc routines */
- FT_LOCAL( void )
- FTC_GNode_Init( FTC_GNode node,
- FT_UInt gindex, /* glyph index for node */
- FTC_Family family );
-
- /* call this function to clear a node's family -- this is necessary */
- /* to implement the `node_remove_faceid' cache method correctly */
- FT_LOCAL( void )
- FTC_GNode_UnselectFamily( FTC_GNode gnode,
- FTC_Cache cache );
-
- /* must be called by derived FTC_Node_DoneFunc routines */
- FT_LOCAL( void )
- FTC_GNode_Done( FTC_GNode node,
- FTC_Cache cache );
-
-
- FT_LOCAL( void )
- FTC_Family_Init( FTC_Family family,
- FTC_Cache cache );
-
- typedef struct FTC_GCacheRec_
- {
- FTC_CacheRec cache;
- FTC_MruListRec families;
-
- } FTC_GCacheRec, *FTC_GCache;
-
-#define FTC_GCACHE( x ) ((FTC_GCache)(x))
-
-
-#if 0
- /* can be used as @FTC_Cache_InitFunc */
- FT_LOCAL( FT_Error )
- FTC_GCache_Init( FTC_GCache cache );
-#endif
-
-
-#if 0
- /* can be used as @FTC_Cache_DoneFunc */
- FT_LOCAL( void )
- FTC_GCache_Done( FTC_GCache cache );
-#endif
-
-
- /* the glyph cache class adds fields for the family implementation */
- typedef struct FTC_GCacheClassRec_
- {
- FTC_CacheClassRec clazz;
- FTC_MruListClass family_class;
-
- } FTC_GCacheClassRec;
-
- typedef const FTC_GCacheClassRec* FTC_GCacheClass;
-
-#define FTC_GCACHE_CLASS( x ) ((FTC_GCacheClass)(x))
-
-#define FTC_CACHE_GCACHE_CLASS( x ) \
- FTC_GCACHE_CLASS( FTC_CACHE( x )->org_class )
-#define FTC_CACHE_FAMILY_CLASS( x ) \
- ( (FTC_MruListClass)FTC_CACHE_GCACHE_CLASS( x )->family_class )
-
-
- /* convenience function; use it instead of FTC_Manager_Register_Cache */
- FT_LOCAL( FT_Error )
- FTC_GCache_New( FTC_Manager manager,
- FTC_GCacheClass clazz,
- FTC_GCache *acache );
-
-#ifndef FTC_INLINE
- FT_LOCAL( FT_Error )
- FTC_GCache_Lookup( FTC_GCache cache,
- FT_Offset hash,
- FT_UInt gindex,
- FTC_GQuery query,
- FTC_Node *anode );
-#endif
-
-
- /* */
-
-
-#define FTC_FAMILY_FREE( family, cache ) \
- FTC_MruList_Remove( &FTC_GCACHE((cache))->families, \
- (FTC_MruNode)(family) )
-
-
-#ifdef FTC_INLINE
-
-#define FTC_GCACHE_LOOKUP_CMP( cache, famcmp, nodecmp, hash, \
- gindex, query, node, error ) \
- FT_BEGIN_STMNT \
- FTC_GCache _gcache = FTC_GCACHE( cache ); \
- FTC_GQuery _gquery = (FTC_GQuery)( query ); \
- FTC_MruNode_CompareFunc _fcompare = (FTC_MruNode_CompareFunc)(famcmp); \
- FTC_MruNode _mrunode; \
- \
- \
- _gquery->gindex = (gindex); \
- \
- FTC_MRULIST_LOOKUP_CMP( &_gcache->families, _gquery, _fcompare, \
- _mrunode, error ); \
- _gquery->family = FTC_FAMILY( _mrunode ); \
- if ( !error ) \
- { \
- FTC_Family _gqfamily = _gquery->family; \
- \
- \
- _gqfamily->num_nodes++; \
- \
- FTC_CACHE_LOOKUP_CMP( cache, nodecmp, hash, query, node, error ); \
- \
- if ( --_gqfamily->num_nodes == 0 ) \
- FTC_FAMILY_FREE( _gqfamily, _gcache ); \
- } \
- FT_END_STMNT
- /* */
-
-#else /* !FTC_INLINE */
-
-#define FTC_GCACHE_LOOKUP_CMP( cache, famcmp, nodecmp, hash, \
- gindex, query, node, error ) \
- FT_BEGIN_STMNT \
- \
- error = FTC_GCache_Lookup( FTC_GCACHE( cache ), hash, gindex, \
- FTC_GQUERY( query ), &node ); \
- \
- FT_END_STMNT
-
-#endif /* !FTC_INLINE */
-
-
-FT_END_HEADER
-
-
-#endif /* FTCGLYPH_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cache/ftcimage.c b/contrib/libs/freetype/src/cache/ftcimage.c
deleted file mode 100644
index 1463064050..0000000000
--- a/contrib/libs/freetype/src/cache/ftcimage.c
+++ /dev/null
@@ -1,158 +0,0 @@
-/****************************************************************************
- *
- * ftcimage.c
- *
- * FreeType Image cache (body).
- *
- * Copyright (C) 2000-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/ftcache.h>
-#include "ftcimage.h"
-#include <freetype/internal/ftmemory.h>
-#include <freetype/internal/ftobjs.h>
-
-#include "ftccback.h"
-#include "ftcerror.h"
-
-
- /* finalize a given glyph image node */
- FT_LOCAL_DEF( void )
- ftc_inode_free( FTC_Node ftcinode,
- FTC_Cache cache )
- {
- FTC_INode inode = (FTC_INode)ftcinode;
- FT_Memory memory = cache->memory;
-
-
- FT_Done_Glyph( inode->glyph );
-
- FTC_GNode_Done( FTC_GNODE( inode ), cache );
- FT_FREE( inode );
- }
-
-
- FT_LOCAL_DEF( void )
- FTC_INode_Free( FTC_INode inode,
- FTC_Cache cache )
- {
- ftc_inode_free( FTC_NODE( inode ), cache );
- }
-
-
- /* initialize a new glyph image node */
- FT_LOCAL_DEF( FT_Error )
- FTC_INode_New( FTC_INode *pinode,
- FTC_GQuery gquery,
- FTC_Cache cache )
- {
- FT_Memory memory = cache->memory;
- FT_Error error;
- FTC_INode inode = NULL;
-
-
- if ( !FT_QNEW( inode ) )
- {
- FTC_GNode gnode = FTC_GNODE( inode );
- FTC_Family family = gquery->family;
- FT_UInt gindex = gquery->gindex;
- FTC_IFamilyClass clazz = FTC_CACHE_IFAMILY_CLASS( cache );
-
-
- /* initialize its inner fields */
- FTC_GNode_Init( gnode, gindex, family );
- inode->glyph = NULL;
-
- /* we will now load the glyph image */
- error = clazz->family_load_glyph( family, gindex, cache,
- &inode->glyph );
- if ( error )
- {
- FTC_INode_Free( inode, cache );
- inode = NULL;
- }
- }
-
- *pinode = inode;
- return error;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- ftc_inode_new( FTC_Node *ftcpinode,
- FT_Pointer ftcgquery,
- FTC_Cache cache )
- {
- FTC_INode *pinode = (FTC_INode*)ftcpinode;
- FTC_GQuery gquery = (FTC_GQuery)ftcgquery;
-
-
- return FTC_INode_New( pinode, gquery, cache );
- }
-
-
- FT_LOCAL_DEF( FT_Offset )
- ftc_inode_weight( FTC_Node ftcinode,
- FTC_Cache ftccache )
- {
- FTC_INode inode = (FTC_INode)ftcinode;
- FT_Offset size = 0;
- FT_Glyph glyph = inode->glyph;
-
- FT_UNUSED( ftccache );
-
-
- switch ( glyph->format )
- {
- case FT_GLYPH_FORMAT_BITMAP:
- {
- FT_BitmapGlyph bitg = (FT_BitmapGlyph)glyph;
-
-
- size = bitg->bitmap.rows * (FT_Offset)FT_ABS( bitg->bitmap.pitch ) +
- sizeof ( *bitg );
- }
- break;
-
- case FT_GLYPH_FORMAT_OUTLINE:
- {
- FT_OutlineGlyph outg = (FT_OutlineGlyph)glyph;
-
-
- size = (FT_Offset)outg->outline.n_points *
- ( sizeof ( FT_Vector ) + sizeof ( FT_Byte ) ) +
- (FT_Offset)outg->outline.n_contours * sizeof ( FT_Short ) +
- sizeof ( *outg );
- }
- break;
-
- default:
- ;
- }
-
- size += sizeof ( *inode );
- return size;
- }
-
-
-#if 0
-
- FT_LOCAL_DEF( FT_Offset )
- FTC_INode_Weight( FTC_INode inode )
- {
- return ftc_inode_weight( FTC_NODE( inode ), NULL );
- }
-
-#endif /* 0 */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cache/ftcimage.h b/contrib/libs/freetype/src/cache/ftcimage.h
deleted file mode 100644
index a0c4a97259..0000000000
--- a/contrib/libs/freetype/src/cache/ftcimage.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/****************************************************************************
- *
- * ftcimage.h
- *
- * FreeType Generic Image cache (specification)
- *
- * Copyright (C) 2000-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /*
- * FTC_ICache is an _abstract_ cache used to store a single FT_Glyph
- * image per cache node.
- *
- * FTC_ICache extends FTC_GCache. For an implementation example,
- * see FTC_ImageCache in `src/cache/ftbasic.c'.
- */
-
-
- /**************************************************************************
- *
- * Each image cache really manages FT_Glyph objects.
- *
- */
-
-
-#ifndef FTCIMAGE_H_
-#define FTCIMAGE_H_
-
-
-#include <freetype/ftcache.h>
-#include "ftcglyph.h"
-
-FT_BEGIN_HEADER
-
-
- /* the FT_Glyph image node type - we store only 1 glyph per node */
- typedef struct FTC_INodeRec_
- {
- FTC_GNodeRec gnode;
- FT_Glyph glyph;
-
- } FTC_INodeRec, *FTC_INode;
-
-#define FTC_INODE( x ) ( (FTC_INode)( x ) )
-#define FTC_INODE_GINDEX( x ) FTC_GNODE( x )->gindex
-#define FTC_INODE_FAMILY( x ) FTC_GNODE( x )->family
-
- typedef FT_Error
- (*FTC_IFamily_LoadGlyphFunc)( FTC_Family family,
- FT_UInt gindex,
- FTC_Cache cache,
- FT_Glyph *aglyph );
-
- typedef struct FTC_IFamilyClassRec_
- {
- FTC_MruListClassRec clazz;
- FTC_IFamily_LoadGlyphFunc family_load_glyph;
-
- } FTC_IFamilyClassRec;
-
- typedef const FTC_IFamilyClassRec* FTC_IFamilyClass;
-
-#define FTC_IFAMILY_CLASS( x ) ((FTC_IFamilyClass)(x))
-
-#define FTC_CACHE_IFAMILY_CLASS( x ) \
- FTC_IFAMILY_CLASS( FTC_CACHE_GCACHE_CLASS( x )->family_class )
-
-
- /* can be used as a @FTC_Node_FreeFunc */
- FT_LOCAL( void )
- FTC_INode_Free( FTC_INode inode,
- FTC_Cache cache );
-
- /* Can be used as @FTC_Node_NewFunc. `gquery.index' and `gquery.family'
- * must be set correctly. This function will call the `family_load_glyph'
- * method to load the FT_Glyph into the cache node.
- */
- FT_LOCAL( FT_Error )
- FTC_INode_New( FTC_INode *pinode,
- FTC_GQuery gquery,
- FTC_Cache cache );
-
-#if 0
- /* can be used as @FTC_Node_WeightFunc */
- FT_LOCAL( FT_ULong )
- FTC_INode_Weight( FTC_INode inode );
-#endif
-
-
- /* */
-
-FT_END_HEADER
-
-#endif /* FTCIMAGE_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cache/ftcmanag.c b/contrib/libs/freetype/src/cache/ftcmanag.c
deleted file mode 100644
index c0a48a53b7..0000000000
--- a/contrib/libs/freetype/src/cache/ftcmanag.c
+++ /dev/null
@@ -1,677 +0,0 @@
-/****************************************************************************
- *
- * ftcmanag.c
- *
- * FreeType Cache Manager (body).
- *
- * Copyright (C) 2000-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/ftcache.h>
-#include "ftcmanag.h"
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/ftdebug.h>
-#include <freetype/ftsizes.h>
-
-#include "ftcerror.h"
-
-
-#undef FT_COMPONENT
-#define FT_COMPONENT cache
-
-
- static FT_Error
- ftc_scaler_lookup_size( FTC_Manager manager,
- FTC_Scaler scaler,
- FT_Size *asize )
- {
- FT_Face face;
- FT_Size size = NULL;
- FT_Error error;
-
-
- error = FTC_Manager_LookupFace( manager, scaler->face_id, &face );
- if ( error )
- goto Exit;
-
- error = FT_New_Size( face, &size );
- if ( error )
- goto Exit;
-
- FT_Activate_Size( size );
-
- if ( scaler->pixel )
- error = FT_Set_Pixel_Sizes( face, scaler->width, scaler->height );
- else
- error = FT_Set_Char_Size( face,
- (FT_F26Dot6)scaler->width,
- (FT_F26Dot6)scaler->height,
- scaler->x_res,
- scaler->y_res );
- if ( error )
- {
- FT_Done_Size( size );
- size = NULL;
- }
-
- Exit:
- *asize = size;
- return error;
- }
-
-
- typedef struct FTC_SizeNodeRec_
- {
- FTC_MruNodeRec node;
- FT_Size size;
- FTC_ScalerRec scaler;
-
- } FTC_SizeNodeRec, *FTC_SizeNode;
-
-#define FTC_SIZE_NODE( x ) ( (FTC_SizeNode)( x ) )
-
-
- FT_CALLBACK_DEF( void )
- ftc_size_node_done( FTC_MruNode ftcnode,
- FT_Pointer data )
- {
- FTC_SizeNode node = (FTC_SizeNode)ftcnode;
- FT_UNUSED( data );
-
-
- FT_Done_Size( node->size );
- }
-
-
- FT_CALLBACK_DEF( FT_Bool )
- ftc_size_node_compare( FTC_MruNode ftcnode,
- FT_Pointer ftcscaler )
- {
- FTC_SizeNode node = (FTC_SizeNode)ftcnode;
- FTC_Scaler scaler = (FTC_Scaler)ftcscaler;
- FTC_Scaler scaler0 = &node->scaler;
-
-
- if ( FTC_SCALER_COMPARE( scaler0, scaler ) )
- {
- FT_Activate_Size( node->size );
- return 1;
- }
- return 0;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- ftc_size_node_init( FTC_MruNode ftcnode,
- FT_Pointer ftcscaler,
- FT_Pointer ftcmanager )
- {
- FT_Error error;
- FT_Size size;
- FTC_SizeNode node = (FTC_SizeNode)ftcnode;
- FTC_Scaler scaler = (FTC_Scaler)ftcscaler;
- FTC_Manager manager = (FTC_Manager)ftcmanager;
-
-
- error = ftc_scaler_lookup_size( manager, scaler, &size );
- if ( !error )
- {
- node->size = size;
- node->scaler = scaler[0];
- }
-
- return error;
- }
-
-
- static
- const FTC_MruListClassRec ftc_size_list_class =
- {
- sizeof ( FTC_SizeNodeRec ),
-
- ftc_size_node_compare, /* FTC_MruNode_CompareFunc node_compare */
- ftc_size_node_init, /* FTC_MruNode_InitFunc node_init */
- ftc_size_node_done /* FTC_MruNode_DoneFunc node_done */
- };
-
-
- /* helper function used by ftc_face_node_done */
- static FT_Bool
- ftc_size_node_compare_faceid( FTC_MruNode ftcnode,
- FT_Pointer ftcface_id )
- {
- FTC_SizeNode node = (FTC_SizeNode)ftcnode;
- FTC_FaceID face_id = (FTC_FaceID)ftcface_id;
-
-
- return FT_BOOL( node->scaler.face_id == face_id );
- }
-
-
- /* documentation is in ftcache.h */
-
- FT_EXPORT_DEF( FT_Error )
- FTC_Manager_LookupSize( FTC_Manager manager,
- FTC_Scaler scaler,
- FT_Size *asize )
- {
- FT_Error error;
- FTC_MruNode mrunode;
-
-
- if ( !asize || !scaler )
- return FT_THROW( Invalid_Argument );
-
- *asize = NULL;
-
- if ( !manager )
- return FT_THROW( Invalid_Cache_Handle );
-
-#ifdef FTC_INLINE
-
- FTC_MRULIST_LOOKUP_CMP( &manager->sizes, scaler, ftc_size_node_compare,
- mrunode, error );
-
-#else
- error = FTC_MruList_Lookup( &manager->sizes, scaler, &mrunode );
-#endif
-
- if ( !error )
- *asize = FTC_SIZE_NODE( mrunode )->size;
-
- return error;
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** FACE MRU IMPLEMENTATION *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- typedef struct FTC_FaceNodeRec_
- {
- FTC_MruNodeRec node;
- FTC_FaceID face_id;
- FT_Face face;
-
- } FTC_FaceNodeRec, *FTC_FaceNode;
-
-#define FTC_FACE_NODE( x ) ( ( FTC_FaceNode )( x ) )
-
-
- FT_CALLBACK_DEF( FT_Error )
- ftc_face_node_init( FTC_MruNode ftcnode,
- FT_Pointer ftcface_id,
- FT_Pointer ftcmanager )
- {
- FT_Error error;
- FT_Face face;
- FTC_FaceNode node = (FTC_FaceNode)ftcnode;
- FTC_FaceID face_id = (FTC_FaceID)ftcface_id;
- FTC_Manager manager = (FTC_Manager)ftcmanager;
-
-
- error = manager->request_face( face_id,
- manager->library,
- manager->request_data,
- &face );
- if ( !error )
- {
- /* destroy initial size object; it will be re-created later */
- if ( face->size )
- FT_Done_Size( face->size );
-
- node->face = face;
- node->face_id = face_id;
- }
-
- return error;
- }
-
-
- FT_CALLBACK_DEF( void )
- ftc_face_node_done( FTC_MruNode ftcnode,
- FT_Pointer ftcmanager )
- {
- FTC_FaceNode node = (FTC_FaceNode)ftcnode;
- FTC_Manager manager = (FTC_Manager)ftcmanager;
-
-
- /* we must begin by removing all scalers for the target face */
- /* from the manager's list */
- FTC_MruList_RemoveSelection( &manager->sizes,
- ftc_size_node_compare_faceid,
- node->face_id );
-
- /* all right, we can discard the face now */
- FT_Done_Face( node->face );
- node->face = NULL;
- node->face_id = NULL;
- }
-
-
- FT_CALLBACK_DEF( FT_Bool )
- ftc_face_node_compare( FTC_MruNode ftcnode,
- FT_Pointer ftcface_id )
- {
- FTC_FaceNode node = (FTC_FaceNode)ftcnode;
- FTC_FaceID face_id = (FTC_FaceID)ftcface_id;
-
-
- return FT_BOOL( node->face_id == face_id );
- }
-
-
- static
- const FTC_MruListClassRec ftc_face_list_class =
- {
- sizeof ( FTC_FaceNodeRec),
-
- ftc_face_node_compare, /* FTC_MruNode_CompareFunc node_compare */
- ftc_face_node_init, /* FTC_MruNode_InitFunc node_init */
- ftc_face_node_done /* FTC_MruNode_DoneFunc node_done */
- };
-
-
- /* documentation is in ftcache.h */
-
- FT_EXPORT_DEF( FT_Error )
- FTC_Manager_LookupFace( FTC_Manager manager,
- FTC_FaceID face_id,
- FT_Face *aface )
- {
- FT_Error error;
- FTC_MruNode mrunode;
-
-
- if ( !aface )
- return FT_THROW( Invalid_Argument );
-
- *aface = NULL;
-
- if ( !manager )
- return FT_THROW( Invalid_Cache_Handle );
-
- /* we break encapsulation for the sake of speed */
-#ifdef FTC_INLINE
-
- FTC_MRULIST_LOOKUP_CMP( &manager->faces, face_id, ftc_face_node_compare,
- mrunode, error );
-
-#else
- error = FTC_MruList_Lookup( &manager->faces, face_id, &mrunode );
-#endif
-
- if ( !error )
- *aface = FTC_FACE_NODE( mrunode )->face;
-
- return error;
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** CACHE MANAGER ROUTINES *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /* documentation is in ftcache.h */
-
- FT_EXPORT_DEF( FT_Error )
- FTC_Manager_New( FT_Library library,
- FT_UInt max_faces,
- FT_UInt max_sizes,
- FT_ULong max_bytes,
- FTC_Face_Requester requester,
- FT_Pointer req_data,
- FTC_Manager *amanager )
- {
- FT_Error error;
- FT_Memory memory;
- FTC_Manager manager = NULL;
-
-
- if ( !library )
- return FT_THROW( Invalid_Library_Handle );
-
- if ( !amanager || !requester )
- return FT_THROW( Invalid_Argument );
-
- memory = library->memory;
-
- if ( FT_QNEW( manager ) )
- goto Exit;
-
- if ( max_faces == 0 )
- max_faces = FTC_MAX_FACES_DEFAULT;
-
- if ( max_sizes == 0 )
- max_sizes = FTC_MAX_SIZES_DEFAULT;
-
- if ( max_bytes == 0 )
- max_bytes = FTC_MAX_BYTES_DEFAULT;
-
- manager->library = library;
- manager->memory = memory;
- manager->max_weight = max_bytes;
- manager->cur_weight = 0;
-
- manager->request_face = requester;
- manager->request_data = req_data;
-
- FTC_MruList_Init( &manager->faces,
- &ftc_face_list_class,
- max_faces,
- manager,
- memory );
-
- FTC_MruList_Init( &manager->sizes,
- &ftc_size_list_class,
- max_sizes,
- manager,
- memory );
-
- manager->nodes_list = NULL;
- manager->num_nodes = 0;
- manager->num_caches = 0;
-
- *amanager = manager;
-
- Exit:
- return error;
- }
-
-
- /* documentation is in ftcache.h */
-
- FT_EXPORT_DEF( void )
- FTC_Manager_Done( FTC_Manager manager )
- {
- FT_Memory memory;
- FT_UInt idx;
-
-
- if ( !manager || !manager->library )
- return;
-
- memory = manager->memory;
-
- /* now discard all caches */
- for ( idx = manager->num_caches; idx-- > 0; )
- {
- FTC_Cache cache = manager->caches[idx];
-
-
- if ( cache )
- {
- cache->clazz.cache_done( cache );
- FT_FREE( cache );
- }
- }
-
- /* discard faces and sizes */
- FTC_MruList_Done( &manager->sizes );
- FTC_MruList_Done( &manager->faces );
-
- FT_FREE( manager );
- }
-
-
- /* documentation is in ftcache.h */
-
- FT_EXPORT_DEF( void )
- FTC_Manager_Reset( FTC_Manager manager )
- {
- if ( !manager )
- return;
-
- FTC_MruList_Reset( &manager->sizes );
- FTC_MruList_Reset( &manager->faces );
-
- FTC_Manager_FlushN( manager, manager->num_nodes );
- }
-
-
-#ifdef FT_DEBUG_ERROR
-
- static void
- FTC_Manager_Check( FTC_Manager manager )
- {
- FTC_Node node, first;
-
-
- first = manager->nodes_list;
-
- /* check node weights */
- if ( first )
- {
- FT_Offset weight = 0;
-
-
- node = first;
-
- do
- {
- FTC_Cache cache = manager->caches[node->cache_index];
-
-
- if ( node->cache_index >= manager->num_caches )
- FT_TRACE0(( "FTC_Manager_Check: invalid node (cache index = %hu\n",
- node->cache_index ));
- else
- weight += cache->clazz.node_weight( node, cache );
-
- node = FTC_NODE_NEXT( node );
-
- } while ( node != first );
-
- if ( weight != manager->cur_weight )
- FT_TRACE0(( "FTC_Manager_Check: invalid weight %ld instead of %ld\n",
- manager->cur_weight, weight ));
- }
-
- /* check circular list */
- if ( first )
- {
- FT_UFast count = 0;
-
-
- node = first;
- do
- {
- count++;
- node = FTC_NODE_NEXT( node );
-
- } while ( node != first );
-
- if ( count != manager->num_nodes )
- FT_TRACE0(( "FTC_Manager_Check:"
- " invalid cache node count %u instead of %u\n",
- manager->num_nodes, count ));
- }
- }
-
-#endif /* FT_DEBUG_ERROR */
-
-
- /* `Compress' the manager's data, i.e., get rid of old cache nodes */
- /* that are not referenced anymore in order to limit the total */
- /* memory used by the cache. */
-
- /* documentation is in ftcmanag.h */
-
- FT_LOCAL_DEF( void )
- FTC_Manager_Compress( FTC_Manager manager )
- {
- FTC_Node node, prev, first;
-
-
- if ( !manager )
- return;
-
- first = manager->nodes_list;
-
-#ifdef FT_DEBUG_ERROR
- FTC_Manager_Check( manager );
-
- FT_TRACE0(( "compressing, weight = %ld, max = %ld, nodes = %u\n",
- manager->cur_weight, manager->max_weight,
- manager->num_nodes ));
-#endif
-
- if ( manager->cur_weight < manager->max_weight || !first )
- return;
-
- /* go to last node -- it's a circular list */
- prev = FTC_NODE_PREV( first );
- do
- {
- node = prev;
- prev = FTC_NODE_PREV( node );
-
- if ( node->ref_count <= 0 )
- ftc_node_destroy( node, manager );
-
- } while ( node != first && manager->cur_weight > manager->max_weight );
- }
-
-
- /* documentation is in ftcmanag.h */
-
- FT_LOCAL_DEF( FT_Error )
- FTC_Manager_RegisterCache( FTC_Manager manager,
- FTC_CacheClass clazz,
- FTC_Cache *acache )
- {
- FT_Error error = FT_ERR( Invalid_Argument );
- FTC_Cache cache = NULL;
-
-
- if ( manager && clazz && acache )
- {
- FT_Memory memory = manager->memory;
-
-
- if ( manager->num_caches >= FTC_MAX_CACHES )
- {
- error = FT_THROW( Too_Many_Caches );
- FT_ERROR(( "FTC_Manager_RegisterCache:"
- " too many registered caches\n" ));
- goto Exit;
- }
-
- if ( !FT_QALLOC( cache, clazz->cache_size ) )
- {
- cache->manager = manager;
- cache->memory = memory;
- cache->clazz = clazz[0];
- cache->org_class = clazz;
-
- /* THIS IS VERY IMPORTANT! IT WILL WRETCH THE MANAGER */
- /* IF IT IS NOT SET CORRECTLY */
- cache->index = manager->num_caches;
-
- error = clazz->cache_init( cache );
- if ( error )
- {
- clazz->cache_done( cache );
- FT_FREE( cache );
- goto Exit;
- }
-
- manager->caches[manager->num_caches++] = cache;
- }
- }
-
- Exit:
- if ( acache )
- *acache = cache;
- return error;
- }
-
-
- FT_LOCAL_DEF( FT_UInt )
- FTC_Manager_FlushN( FTC_Manager manager,
- FT_UInt count )
- {
- FTC_Node first = manager->nodes_list;
- FTC_Node prev, node;
- FT_UInt result = 0;
-
-
- /* try to remove `count' nodes from the list */
- if ( !first || !count )
- return result;
-
- /* go to last node -- it's a circular list */
- prev = FTC_NODE_PREV( first );
- do
- {
- node = prev;
- prev = FTC_NODE_PREV( node );
-
- /* don't touch locked nodes */
- if ( node->ref_count <= 0 )
- {
- ftc_node_destroy( node, manager );
- result++;
- }
- } while ( node != first && result < count );
-
- return result;
- }
-
-
- /* documentation is in ftcache.h */
-
- FT_EXPORT_DEF( void )
- FTC_Manager_RemoveFaceID( FTC_Manager manager,
- FTC_FaceID face_id )
- {
- FT_UInt nn;
-
-
- if ( !manager )
- return;
-
- /* this will remove all FTC_SizeNode that correspond to
- * the face_id as well
- */
- FTC_MruList_RemoveSelection( &manager->faces,
- ftc_face_node_compare,
- face_id );
-
- for ( nn = 0; nn < manager->num_caches; nn++ )
- FTC_Cache_RemoveFaceID( manager->caches[nn], face_id );
- }
-
-
- /* documentation is in ftcache.h */
-
- FT_EXPORT_DEF( void )
- FTC_Node_Unref( FTC_Node node,
- FTC_Manager manager )
- {
- if ( node &&
- manager &&
- node->cache_index < manager->num_caches )
- node->ref_count--;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cache/ftcmanag.h b/contrib/libs/freetype/src/cache/ftcmanag.h
deleted file mode 100644
index bd158f5ffb..0000000000
--- a/contrib/libs/freetype/src/cache/ftcmanag.h
+++ /dev/null
@@ -1,175 +0,0 @@
-/****************************************************************************
- *
- * ftcmanag.h
- *
- * FreeType Cache Manager (specification).
- *
- * Copyright (C) 2000-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /**************************************************************************
- *
- * A cache manager is in charge of the following:
- *
- * - Maintain a mapping between generic FTC_FaceIDs and live FT_Face
- * objects. The mapping itself is performed through a user-provided
- * callback. However, the manager maintains a small cache of FT_Face
- * and FT_Size objects in order to speed up things considerably.
- *
- * - Manage one or more cache objects. Each cache is in charge of
- * holding a varying number of `cache nodes'. Each cache node
- * represents a minimal amount of individually accessible cached
- * data. For example, a cache node can be an FT_Glyph image
- * containing a vector outline, or some glyph metrics, or anything
- * else.
- *
- * Each cache node has a certain size in bytes that is added to the
- * total amount of `cache memory' within the manager.
- *
- * All cache nodes are located in a global LRU list, where the oldest
- * node is at the tail of the list.
- *
- * Each node belongs to a single cache, and includes a reference
- * count to avoid destroying it (due to caching).
- *
- */
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /********* *********/
- /********* WARNING, THIS IS BETA CODE. *********/
- /********* *********/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
-#ifndef FTCMANAG_H_
-#define FTCMANAG_H_
-
-
-#include <freetype/ftcache.h>
-#include "ftcmru.h"
-#include "ftccache.h"
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @Section:
- * cache_subsystem
- *
- */
-
-
-#define FTC_MAX_FACES_DEFAULT 2
-#define FTC_MAX_SIZES_DEFAULT 4
-#define FTC_MAX_BYTES_DEFAULT 200000L /* ~200kByte by default */
-
- /* maximum number of caches registered in a single manager */
-#define FTC_MAX_CACHES 16
-
-
- typedef struct FTC_ManagerRec_
- {
- FT_Library library;
- FT_Memory memory;
-
- FTC_Node nodes_list;
- FT_Offset max_weight;
- FT_Offset cur_weight;
- FT_UInt num_nodes;
-
- FTC_Cache caches[FTC_MAX_CACHES];
- FT_UInt num_caches;
-
- FTC_MruListRec faces;
- FTC_MruListRec sizes;
-
- FT_Pointer request_data;
- FTC_Face_Requester request_face;
-
- } FTC_ManagerRec;
-
-
- /**************************************************************************
- *
- * @Function:
- * FTC_Manager_Compress
- *
- * @Description:
- * This function is used to check the state of the cache manager if
- * its `num_bytes' field is greater than its `max_bytes' field. It
- * will flush as many old cache nodes as possible (ignoring cache
- * nodes with a non-zero reference count).
- *
- * @InOut:
- * manager ::
- * A handle to the cache manager.
- *
- * @Note:
- * Client applications should not call this function directly. It is
- * normally invoked by specific cache implementations.
- *
- * The reason this function is exported is to allow client-specific
- * cache classes.
- */
- FT_LOCAL( void )
- FTC_Manager_Compress( FTC_Manager manager );
-
-
- /* try to flush `count' old nodes from the cache; return the number
- * of really flushed nodes
- */
- FT_LOCAL( FT_UInt )
- FTC_Manager_FlushN( FTC_Manager manager,
- FT_UInt count );
-
-
- /* this must be used internally for the moment */
- FT_LOCAL( FT_Error )
- FTC_Manager_RegisterCache( FTC_Manager manager,
- FTC_CacheClass clazz,
- FTC_Cache *acache );
-
- /* */
-
-#define FTC_SCALER_COMPARE( a, b ) \
- ( (a)->face_id == (b)->face_id && \
- (a)->width == (b)->width && \
- (a)->height == (b)->height && \
- ((a)->pixel != 0) == ((b)->pixel != 0) && \
- ( (a)->pixel || \
- ( (a)->x_res == (b)->x_res && \
- (a)->y_res == (b)->y_res ) ) )
-
-#define FTC_SCALER_HASH( q ) \
- ( FTC_FACE_ID_HASH( (q)->face_id ) + \
- (q)->width + (q)->height*7 + \
- ( (q)->pixel ? 0 : ( (q)->x_res*33 ^ (q)->y_res*61 ) ) )
-
- /* */
-
-FT_END_HEADER
-
-#endif /* FTCMANAG_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cache/ftcmru.c b/contrib/libs/freetype/src/cache/ftcmru.c
deleted file mode 100644
index f908eb25a6..0000000000
--- a/contrib/libs/freetype/src/cache/ftcmru.c
+++ /dev/null
@@ -1,341 +0,0 @@
-/****************************************************************************
- *
- * ftcmru.c
- *
- * FreeType MRU support (body).
- *
- * Copyright (C) 2003-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/ftcache.h>
-#include "ftcmru.h"
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/ftdebug.h>
-
-#include "ftcerror.h"
-
-
- FT_LOCAL_DEF( void )
- FTC_MruNode_Prepend( FTC_MruNode *plist,
- FTC_MruNode node )
- {
- FTC_MruNode first = *plist;
-
-
- if ( first )
- {
- FTC_MruNode last = first->prev;
-
-
-#ifdef FT_DEBUG_ERROR
- {
- FTC_MruNode cnode = first;
-
-
- do
- {
- if ( cnode == node )
- {
- fprintf( stderr, "FTC_MruNode_Prepend: invalid action\n" );
- exit( 2 );
- }
- cnode = cnode->next;
-
- } while ( cnode != first );
- }
-#endif
-
- first->prev = node;
- last->next = node;
- node->next = first;
- node->prev = last;
- }
- else
- {
- node->next = node;
- node->prev = node;
- }
- *plist = node;
- }
-
-
- FT_LOCAL_DEF( void )
- FTC_MruNode_Up( FTC_MruNode *plist,
- FTC_MruNode node )
- {
- FTC_MruNode first = *plist;
-
-
- FT_ASSERT( first );
-
- if ( first != node )
- {
- FTC_MruNode prev, next, last;
-
-
-#ifdef FT_DEBUG_ERROR
- {
- FTC_MruNode cnode = first;
- do
- {
- if ( cnode == node )
- goto Ok;
- cnode = cnode->next;
-
- } while ( cnode != first );
-
- fprintf( stderr, "FTC_MruNode_Up: invalid action\n" );
- exit( 2 );
- Ok:
- }
-#endif
- prev = node->prev;
- next = node->next;
-
- prev->next = next;
- next->prev = prev;
-
- last = first->prev;
-
- last->next = node;
- first->prev = node;
-
- node->next = first;
- node->prev = last;
-
- *plist = node;
- }
- }
-
-
- FT_LOCAL_DEF( void )
- FTC_MruNode_Remove( FTC_MruNode *plist,
- FTC_MruNode node )
- {
- FTC_MruNode first = *plist;
- FTC_MruNode prev, next;
-
-
- FT_ASSERT( first );
-
-#ifdef FT_DEBUG_ERROR
- {
- FTC_MruNode cnode = first;
-
-
- do
- {
- if ( cnode == node )
- goto Ok;
- cnode = cnode->next;
-
- } while ( cnode != first );
-
- fprintf( stderr, "FTC_MruNode_Remove: invalid action\n" );
- exit( 2 );
- Ok:
- }
-#endif
-
- prev = node->prev;
- next = node->next;
-
- prev->next = next;
- next->prev = prev;
-
- if ( node == next )
- {
- FT_ASSERT( first == node );
- FT_ASSERT( prev == node );
-
- *plist = NULL;
- }
- else if ( node == first )
- *plist = next;
- }
-
-
- FT_LOCAL_DEF( void )
- FTC_MruList_Init( FTC_MruList list,
- FTC_MruListClass clazz,
- FT_UInt max_nodes,
- FT_Pointer data,
- FT_Memory memory )
- {
- list->num_nodes = 0;
- list->max_nodes = max_nodes;
- list->nodes = NULL;
- list->clazz = *clazz;
- list->data = data;
- list->memory = memory;
- }
-
-
- FT_LOCAL_DEF( void )
- FTC_MruList_Reset( FTC_MruList list )
- {
- while ( list->nodes )
- FTC_MruList_Remove( list, list->nodes );
-
- FT_ASSERT( list->num_nodes == 0 );
- }
-
-
- FT_LOCAL_DEF( void )
- FTC_MruList_Done( FTC_MruList list )
- {
- FTC_MruList_Reset( list );
- }
-
-
-#ifndef FTC_INLINE
- FT_LOCAL_DEF( FTC_MruNode )
- FTC_MruList_Find( FTC_MruList list,
- FT_Pointer key )
- {
- FTC_MruNode_CompareFunc compare = list->clazz.node_compare;
- FTC_MruNode first, node;
-
-
- first = list->nodes;
- node = NULL;
-
- if ( first )
- {
- node = first;
- do
- {
- if ( compare( node, key ) )
- {
- if ( node != first )
- FTC_MruNode_Up( &list->nodes, node );
-
- return node;
- }
-
- node = node->next;
-
- } while ( node != first);
- }
-
- return NULL;
- }
-#endif
-
- FT_LOCAL_DEF( FT_Error )
- FTC_MruList_New( FTC_MruList list,
- FT_Pointer key,
- FTC_MruNode *anode )
- {
- FT_Error error;
- FTC_MruNode node = NULL;
- FTC_MruNode prev = NULL;
- FT_Memory memory = list->memory;
-
-
- /* zero new node in case of node_init failure */
- if ( FT_ALLOC( node, list->clazz.node_size ) )
- goto Exit;
-
- error = list->clazz.node_init( node, key, list->data );
- if ( error )
- {
- prev = node;
- node = NULL;
-
- goto Clean;
- }
- else if ( list->max_nodes > 0 && list->num_nodes >= list->max_nodes )
- prev = list->nodes->prev;
-
- FTC_MruNode_Prepend( &list->nodes, node );
- list->num_nodes++;
-
- if ( !prev )
- goto Exit;
-
- FTC_MruNode_Remove( &list->nodes, prev );
- list->num_nodes--;
-
- Clean:
- if ( list->clazz.node_done )
- list->clazz.node_done( prev, list->data );
-
- FT_FREE( prev );
-
- Exit:
- *anode = node;
- return error;
- }
-
-
-#ifndef FTC_INLINE
- FT_LOCAL_DEF( FT_Error )
- FTC_MruList_Lookup( FTC_MruList list,
- FT_Pointer key,
- FTC_MruNode *anode )
- {
- FTC_MruNode node;
-
-
- node = FTC_MruList_Find( list, key );
- if ( !node )
- return FTC_MruList_New( list, key, anode );
-
- *anode = node;
- return 0;
- }
-#endif /* FTC_INLINE */
-
- FT_LOCAL_DEF( void )
- FTC_MruList_Remove( FTC_MruList list,
- FTC_MruNode node )
- {
- FT_Memory memory = list->memory;
-
-
- FTC_MruNode_Remove( &list->nodes, node );
- list->num_nodes--;
-
- if ( list->clazz.node_done )
- list->clazz.node_done( node, list->data );
-
- FT_FREE( node );
- }
-
-
- FT_LOCAL_DEF( void )
- FTC_MruList_RemoveSelection( FTC_MruList list,
- FTC_MruNode_CompareFunc selection,
- FT_Pointer key )
- {
- FTC_MruNode first = list->nodes;
- FTC_MruNode prev, node;
-
-
- if ( !first || !selection )
- return;
-
- prev = first->prev;
- do
- {
- node = prev;
- prev = node->prev;
-
- if ( selection( node, key ) )
- FTC_MruList_Remove( list, node );
-
- } while ( node != first );
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cache/ftcmru.h b/contrib/libs/freetype/src/cache/ftcmru.h
deleted file mode 100644
index 68faab9847..0000000000
--- a/contrib/libs/freetype/src/cache/ftcmru.h
+++ /dev/null
@@ -1,242 +0,0 @@
-/****************************************************************************
- *
- * ftcmru.h
- *
- * Simple MRU list-cache (specification).
- *
- * Copyright (C) 2000-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /**************************************************************************
- *
- * An MRU is a list that cannot hold more than a certain number of
- * elements (`max_elements'). All elements in the list are sorted in
- * least-recently-used order, i.e., the `oldest' element is at the tail
- * of the list.
- *
- * When doing a lookup (either through `Lookup()' or `Lookup_Node()'),
- * the list is searched for an element with the corresponding key. If
- * it is found, the element is moved to the head of the list and is
- * returned.
- *
- * If no corresponding element is found, the lookup routine will try to
- * obtain a new element with the relevant key. If the list is already
- * full, the oldest element from the list is discarded and replaced by a
- * new one; a new element is added to the list otherwise.
- *
- * Note that it is possible to pre-allocate the element list nodes.
- * This is handy if `max_elements' is sufficiently small, as it saves
- * allocations/releases during the lookup process.
- *
- */
-
-
-#ifndef FTCMRU_H_
-#define FTCMRU_H_
-
-
-#include <freetype/freetype.h>
-#include <freetype/internal/compiler-macros.h>
-
-#ifdef FREETYPE_H
-#error "freetype.h of FreeType 1 has been loaded!"
-#error "Please fix the directory search order for header files"
-#error "so that freetype.h of FreeType 2 is found first."
-#endif
-
-#define xxFT_DEBUG_ERROR
-#define FTC_INLINE
-
-FT_BEGIN_HEADER
-
- typedef struct FTC_MruNodeRec_* FTC_MruNode;
-
- typedef struct FTC_MruNodeRec_
- {
- FTC_MruNode next;
- FTC_MruNode prev;
-
- } FTC_MruNodeRec;
-
-
- FT_LOCAL( void )
- FTC_MruNode_Prepend( FTC_MruNode *plist,
- FTC_MruNode node );
-
- FT_LOCAL( void )
- FTC_MruNode_Up( FTC_MruNode *plist,
- FTC_MruNode node );
-
- FT_LOCAL( void )
- FTC_MruNode_Remove( FTC_MruNode *plist,
- FTC_MruNode node );
-
-
- typedef struct FTC_MruListRec_* FTC_MruList;
-
- typedef struct FTC_MruListClassRec_ const * FTC_MruListClass;
-
-
- typedef FT_Bool
- (*FTC_MruNode_CompareFunc)( FTC_MruNode node,
- FT_Pointer key );
-
- typedef FT_Error
- (*FTC_MruNode_InitFunc)( FTC_MruNode node,
- FT_Pointer key,
- FT_Pointer data );
-
- typedef void
- (*FTC_MruNode_DoneFunc)( FTC_MruNode node,
- FT_Pointer data );
-
-
- typedef struct FTC_MruListClassRec_
- {
- FT_Offset node_size;
-
- FTC_MruNode_CompareFunc node_compare;
- FTC_MruNode_InitFunc node_init;
- FTC_MruNode_DoneFunc node_done;
-
- } FTC_MruListClassRec;
-
-
- typedef struct FTC_MruListRec_
- {
- FT_UInt num_nodes;
- FT_UInt max_nodes;
- FTC_MruNode nodes;
- FT_Pointer data;
- FTC_MruListClassRec clazz;
- FT_Memory memory;
-
- } FTC_MruListRec;
-
-
- FT_LOCAL( void )
- FTC_MruList_Init( FTC_MruList list,
- FTC_MruListClass clazz,
- FT_UInt max_nodes,
- FT_Pointer data,
- FT_Memory memory );
-
- FT_LOCAL( void )
- FTC_MruList_Reset( FTC_MruList list );
-
-
- FT_LOCAL( void )
- FTC_MruList_Done( FTC_MruList list );
-
-
- FT_LOCAL( FT_Error )
- FTC_MruList_New( FTC_MruList list,
- FT_Pointer key,
- FTC_MruNode *anode );
-
- FT_LOCAL( void )
- FTC_MruList_Remove( FTC_MruList list,
- FTC_MruNode node );
-
- FT_LOCAL( void )
- FTC_MruList_RemoveSelection( FTC_MruList list,
- FTC_MruNode_CompareFunc selection,
- FT_Pointer key );
-
-
-#ifdef FTC_INLINE
-
-#define FTC_MRULIST_LOOKUP_CMP( list, key, compare, node, error ) \
- FT_BEGIN_STMNT \
- FTC_MruNode* _pfirst = &(list)->nodes; \
- FTC_MruNode_CompareFunc _compare = (FTC_MruNode_CompareFunc)(compare); \
- FTC_MruNode _first, _node; \
- \
- \
- error = FT_Err_Ok; \
- _first = *(_pfirst); \
- _node = NULL; \
- \
- if ( _first ) \
- { \
- _node = _first; \
- do \
- { \
- if ( _compare( _node, (key) ) ) \
- { \
- if ( _node != _first ) \
- FTC_MruNode_Up( _pfirst, _node ); \
- \
- node = _node; \
- goto MruOk_; \
- } \
- _node = _node->next; \
- \
- } while ( _node != _first); \
- } \
- \
- error = FTC_MruList_New( (list), (key), (FTC_MruNode*)(void*)&(node) ); \
- MruOk_: \
- ; \
- FT_END_STMNT
-
-#define FTC_MRULIST_LOOKUP( list, key, node, error ) \
- FTC_MRULIST_LOOKUP_CMP( list, key, (list)->clazz.node_compare, node, error )
-
-#else /* !FTC_INLINE */
-
- FT_LOCAL( FTC_MruNode )
- FTC_MruList_Find( FTC_MruList list,
- FT_Pointer key );
-
- FT_LOCAL( FT_Error )
- FTC_MruList_Lookup( FTC_MruList list,
- FT_Pointer key,
- FTC_MruNode *pnode );
-
-#define FTC_MRULIST_LOOKUP( list, key, node, error ) \
- error = FTC_MruList_Lookup( (list), (key), (FTC_MruNode*)&(node) )
-
-#endif /* !FTC_INLINE */
-
-
-#define FTC_MRULIST_LOOP( list, node ) \
- FT_BEGIN_STMNT \
- FTC_MruNode _first = (list)->nodes; \
- \
- \
- if ( _first ) \
- { \
- FTC_MruNode _node = _first; \
- \
- \
- do \
- { \
- *(FTC_MruNode*)&(node) = _node;
-
-
-#define FTC_MRULIST_LOOP_END() \
- _node = _node->next; \
- \
- } while ( _node != _first ); \
- } \
- FT_END_STMNT
-
- /* */
-
-FT_END_HEADER
-
-
-#endif /* FTCMRU_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cache/ftcsbits.c b/contrib/libs/freetype/src/cache/ftcsbits.c
deleted file mode 100644
index 19f3ef04d6..0000000000
--- a/contrib/libs/freetype/src/cache/ftcsbits.c
+++ /dev/null
@@ -1,413 +0,0 @@
-/****************************************************************************
- *
- * ftcsbits.c
- *
- * FreeType sbits manager (body).
- *
- * Copyright (C) 2000-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/ftcache.h>
-#include "ftcsbits.h"
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/ftdebug.h>
-#include <freetype/fterrors.h>
-
-#include "ftccback.h"
-#include "ftcerror.h"
-
-#undef FT_COMPONENT
-#define FT_COMPONENT cache
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** SBIT CACHE NODES *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- static FT_Error
- ftc_sbit_copy_bitmap( FTC_SBit sbit,
- FT_Bitmap* bitmap,
- FT_Memory memory )
- {
- FT_Error error;
- FT_Int pitch = bitmap->pitch;
- FT_ULong size;
-
-
- if ( pitch < 0 )
- pitch = -pitch;
-
- size = (FT_ULong)pitch * bitmap->rows;
-
- FT_MEM_DUP( sbit->buffer, bitmap->buffer, size );
-
- return error;
- }
-
-
- FT_LOCAL_DEF( void )
- ftc_snode_free( FTC_Node ftcsnode,
- FTC_Cache cache )
- {
- FTC_SNode snode = (FTC_SNode)ftcsnode;
- FTC_SBit sbit = snode->sbits;
- FT_UInt count = snode->count;
- FT_Memory memory = cache->memory;
-
-
- for ( ; count > 0; sbit++, count-- )
- FT_FREE( sbit->buffer );
-
- FTC_GNode_Done( FTC_GNODE( snode ), cache );
-
- FT_FREE( snode );
- }
-
-
- FT_LOCAL_DEF( void )
- FTC_SNode_Free( FTC_SNode snode,
- FTC_Cache cache )
- {
- ftc_snode_free( FTC_NODE( snode ), cache );
- }
-
-
- /*
- * This function tries to load a small bitmap within a given FTC_SNode.
- * Note that it returns a non-zero error code _only_ in the case of
- * out-of-memory condition. For all other errors (e.g., corresponding
- * to a bad font file), this function will mark the sbit as `unavailable'
- * and return a value of 0.
- *
- * You should also read the comment within the @ftc_snode_compare
- * function below to see how out-of-memory is handled during a lookup.
- */
- static FT_Error
- ftc_snode_load( FTC_SNode snode,
- FTC_Manager manager,
- FT_UInt gindex,
- FT_ULong *asize )
- {
- FT_Error error;
- FTC_GNode gnode = FTC_GNODE( snode );
- FTC_Family family = gnode->family;
- FT_Face face;
- FTC_SBit sbit;
- FTC_SFamilyClass clazz;
-
-
- if ( gindex - gnode->gindex >= snode->count )
- {
- FT_ERROR(( "ftc_snode_load: invalid glyph index" ));
- return FT_THROW( Invalid_Argument );
- }
-
- sbit = snode->sbits + ( gindex - gnode->gindex );
- clazz = (FTC_SFamilyClass)family->clazz;
-
- error = clazz->family_load_glyph( family, gindex, manager, &face );
- if ( error )
- goto BadGlyph;
-
- {
- FT_Int temp;
- FT_GlyphSlot slot = face->glyph;
- FT_Bitmap* bitmap = &slot->bitmap;
- FT_Pos xadvance, yadvance; /* FT_GlyphSlot->advance.{x|y} */
-
-
- if ( slot->format != FT_GLYPH_FORMAT_BITMAP )
- {
- FT_TRACE0(( "ftc_snode_load:"
- " glyph loaded didn't return a bitmap\n" ));
- goto BadGlyph;
- }
-
- /* Check whether our values fit into 8/16-bit containers! */
- /* If this is not the case, our bitmap is too large */
- /* and we will leave it as `missing' with sbit.buffer = 0 */
-
-#define CHECK_CHAR( d ) ( temp = (FT_Char)d, (FT_Int) temp == (FT_Int) d )
-#define CHECK_BYTE( d ) ( temp = (FT_Byte)d, (FT_UInt)temp == (FT_UInt)d )
-#define CHECK_SHRT( d ) ( temp = (FT_Short)d, (FT_Int)temp == (FT_Int) d )
-
- /* horizontal advance in pixels */
- xadvance = ( slot->advance.x + 32 ) >> 6;
- yadvance = ( slot->advance.y + 32 ) >> 6;
-
- if ( !CHECK_BYTE( bitmap->rows ) ||
- !CHECK_BYTE( bitmap->width ) ||
- !CHECK_SHRT( bitmap->pitch ) ||
- !CHECK_CHAR( slot->bitmap_left ) ||
- !CHECK_CHAR( slot->bitmap_top ) ||
- !CHECK_CHAR( xadvance ) ||
- !CHECK_CHAR( yadvance ) )
- {
- FT_TRACE2(( "ftc_snode_load:"
- " glyph too large for small bitmap cache\n"));
- goto BadGlyph;
- }
-
- sbit->width = (FT_Byte)bitmap->width;
- sbit->height = (FT_Byte)bitmap->rows;
- sbit->pitch = (FT_Short)bitmap->pitch;
- sbit->left = (FT_Char)slot->bitmap_left;
- sbit->top = (FT_Char)slot->bitmap_top;
- sbit->xadvance = (FT_Char)xadvance;
- sbit->yadvance = (FT_Char)yadvance;
- sbit->format = (FT_Byte)bitmap->pixel_mode;
- sbit->max_grays = (FT_Byte)( bitmap->num_grays - 1 );
-
- if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
- {
- /* take the bitmap ownership */
- sbit->buffer = bitmap->buffer;
- slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
- }
- else
- {
- /* copy the bitmap into a new buffer -- ignore error */
- error = ftc_sbit_copy_bitmap( sbit, bitmap, manager->memory );
- }
-
- /* now, compute size */
- if ( asize )
- *asize = (FT_ULong)FT_ABS( sbit->pitch ) * sbit->height;
-
- } /* glyph loading successful */
-
- /* ignore the errors that might have occurred -- */
- /* we mark unloaded glyphs with `sbit.buffer == 0' */
- /* and `width == 255', `height == 0' */
- /* */
- if ( error && FT_ERR_NEQ( error, Out_Of_Memory ) )
- {
- BadGlyph:
- sbit->width = 255;
- sbit->height = 0;
- sbit->buffer = NULL;
- error = FT_Err_Ok;
- if ( asize )
- *asize = 0;
- }
-
- return error;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- FTC_SNode_New( FTC_SNode *psnode,
- FTC_GQuery gquery,
- FTC_Cache cache )
- {
- FT_Memory memory = cache->memory;
- FT_Error error;
- FTC_SNode snode = NULL;
- FT_UInt gindex = gquery->gindex;
- FTC_Family family = gquery->family;
-
- FTC_SFamilyClass clazz = FTC_CACHE_SFAMILY_CLASS( cache );
- FT_UInt total;
- FT_UInt node_count;
-
-
- total = clazz->family_get_count( family, cache->manager );
- if ( total == 0 || gindex >= total )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- if ( !FT_QNEW( snode ) )
- {
- FT_UInt count, start;
-
-
- start = gindex - ( gindex % FTC_SBIT_ITEMS_PER_NODE );
- count = total - start;
- if ( count > FTC_SBIT_ITEMS_PER_NODE )
- count = FTC_SBIT_ITEMS_PER_NODE;
-
- FTC_GNode_Init( FTC_GNODE( snode ), start, family );
-
- snode->count = count;
- for ( node_count = 0; node_count < count; node_count++ )
- {
- snode->sbits[node_count].width = 255;
- snode->sbits[node_count].height = 0;
- snode->sbits[node_count].buffer = NULL;
- }
-
- error = ftc_snode_load( snode,
- cache->manager,
- gindex,
- NULL );
- if ( error )
- {
- FTC_SNode_Free( snode, cache );
- snode = NULL;
- }
- }
-
- Exit:
- *psnode = snode;
- return error;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- ftc_snode_new( FTC_Node *ftcpsnode,
- FT_Pointer ftcgquery,
- FTC_Cache cache )
- {
- FTC_SNode *psnode = (FTC_SNode*)ftcpsnode;
- FTC_GQuery gquery = (FTC_GQuery)ftcgquery;
-
-
- return FTC_SNode_New( psnode, gquery, cache );
- }
-
-
- FT_LOCAL_DEF( FT_Offset )
- ftc_snode_weight( FTC_Node ftcsnode,
- FTC_Cache cache )
- {
- FTC_SNode snode = (FTC_SNode)ftcsnode;
- FT_UInt count = snode->count;
- FTC_SBit sbit = snode->sbits;
- FT_Int pitch;
- FT_Offset size;
-
- FT_UNUSED( cache );
-
-
- FT_ASSERT( snode->count <= FTC_SBIT_ITEMS_PER_NODE );
-
- /* the node itself */
- size = sizeof ( *snode );
-
- for ( ; count > 0; count--, sbit++ )
- {
- if ( sbit->buffer )
- {
- pitch = sbit->pitch;
- if ( pitch < 0 )
- pitch = -pitch;
-
- /* add the size of a given glyph image */
- size += (FT_Offset)pitch * sbit->height;
- }
- }
-
- return size;
- }
-
-
-#if 0
-
- FT_LOCAL_DEF( FT_Offset )
- FTC_SNode_Weight( FTC_SNode snode )
- {
- return ftc_snode_weight( FTC_NODE( snode ), NULL );
- }
-
-#endif /* 0 */
-
-
- FT_LOCAL_DEF( FT_Bool )
- ftc_snode_compare( FTC_Node ftcsnode,
- FT_Pointer ftcgquery,
- FTC_Cache cache,
- FT_Bool* list_changed )
- {
- FTC_SNode snode = (FTC_SNode)ftcsnode;
- FTC_GQuery gquery = (FTC_GQuery)ftcgquery;
- FTC_GNode gnode = FTC_GNODE( snode );
- FT_UInt gindex = gquery->gindex;
- FT_Bool result;
-
-
- if ( list_changed )
- *list_changed = FALSE;
- result = FT_BOOL( gnode->family == gquery->family &&
- gindex - gnode->gindex < snode->count );
- if ( result )
- {
- /* check if we need to load the glyph bitmap now */
- FTC_SBit sbit = snode->sbits + ( gindex - gnode->gindex );
-
-
- /*
- * The following code illustrates what to do when you want to
- * perform operations that may fail within a lookup function.
- *
- * Here, we want to load a small bitmap on-demand; we thus
- * need to call the `ftc_snode_load' function which may return
- * a non-zero error code only when we are out of memory (OOM).
- *
- * The correct thing to do is to use @FTC_CACHE_TRYLOOP and
- * @FTC_CACHE_TRYLOOP_END in order to implement a retry loop
- * that is capable of flushing the cache incrementally when
- * an OOM errors occur.
- *
- * However, we need to `lock' the node before this operation to
- * prevent it from being flushed within the loop.
- *
- * When we exit the loop, we unlock the node, then check the `error'
- * variable. If it is non-zero, this means that the cache was
- * completely flushed and that no usable memory was found to load
- * the bitmap.
- *
- * We then prefer to return a value of 0 (i.e., NO MATCH). This
- * ensures that the caller will try to allocate a new node.
- * This operation consequently _fail_ and the lookup function
- * returns the appropriate OOM error code.
- *
- * Note that `buffer == NULL && width == 255' is a hack used to
- * tag `unavailable' bitmaps in the array. We should never try
- * to load these.
- *
- */
-
- if ( !sbit->buffer && sbit->width == 255 )
- {
- FT_ULong size;
- FT_Error error;
-
-
- ftcsnode->ref_count++; /* lock node to prevent flushing */
- /* in retry loop */
-
- FTC_CACHE_TRYLOOP( cache )
- {
- error = ftc_snode_load( snode, cache->manager, gindex, &size );
- }
- FTC_CACHE_TRYLOOP_END( list_changed )
-
- ftcsnode->ref_count--; /* unlock the node */
-
- if ( error )
- result = 0;
- else
- cache->manager->cur_weight += size;
- }
- }
-
- return result;
- }
-
-/* END */
diff --git a/contrib/libs/freetype/src/cache/ftcsbits.h b/contrib/libs/freetype/src/cache/ftcsbits.h
deleted file mode 100644
index d7c4a36475..0000000000
--- a/contrib/libs/freetype/src/cache/ftcsbits.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/****************************************************************************
- *
- * ftcsbits.h
- *
- * A small-bitmap cache (specification).
- *
- * Copyright (C) 2000-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTCSBITS_H_
-#define FTCSBITS_H_
-
-
-#include <freetype/ftcache.h>
-#include "ftcglyph.h"
-
-
-FT_BEGIN_HEADER
-
-#define FTC_SBIT_ITEMS_PER_NODE 16
-
- typedef struct FTC_SNodeRec_
- {
- FTC_GNodeRec gnode;
- FT_UInt count;
- FTC_SBitRec sbits[FTC_SBIT_ITEMS_PER_NODE];
-
- } FTC_SNodeRec, *FTC_SNode;
-
-
-#define FTC_SNODE( x ) ( (FTC_SNode)( x ) )
-#define FTC_SNODE_GINDEX( x ) FTC_GNODE( x )->gindex
-#define FTC_SNODE_FAMILY( x ) FTC_GNODE( x )->family
-
- typedef FT_UInt
- (*FTC_SFamily_GetCountFunc)( FTC_Family family,
- FTC_Manager manager );
-
- typedef FT_Error
- (*FTC_SFamily_LoadGlyphFunc)( FTC_Family family,
- FT_UInt gindex,
- FTC_Manager manager,
- FT_Face *aface );
-
- typedef struct FTC_SFamilyClassRec_
- {
- FTC_MruListClassRec clazz;
- FTC_SFamily_GetCountFunc family_get_count;
- FTC_SFamily_LoadGlyphFunc family_load_glyph;
-
- } FTC_SFamilyClassRec;
-
- typedef const FTC_SFamilyClassRec* FTC_SFamilyClass;
-
-#define FTC_SFAMILY_CLASS( x ) ( (FTC_SFamilyClass)(x) )
-
-#define FTC_CACHE_SFAMILY_CLASS( x ) \
- FTC_SFAMILY_CLASS( FTC_CACHE_GCACHE_CLASS( x )->family_class )
-
-
- FT_LOCAL( void )
- FTC_SNode_Free( FTC_SNode snode,
- FTC_Cache cache );
-
- FT_LOCAL( FT_Error )
- FTC_SNode_New( FTC_SNode *psnode,
- FTC_GQuery gquery,
- FTC_Cache cache );
-
-#if 0
- FT_LOCAL( FT_ULong )
- FTC_SNode_Weight( FTC_SNode inode );
-#endif
-
- /* */
-
-FT_END_HEADER
-
-#endif /* FTCSBITS_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cff/cff.c b/contrib/libs/freetype/src/cff/cff.c
deleted file mode 100644
index e3e009699d..0000000000
--- a/contrib/libs/freetype/src/cff/cff.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/****************************************************************************
- *
- * cff.c
- *
- * FreeType OpenType driver component (body only).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#define FT_MAKE_OPTION_SINGLE_OBJECT
-
-#include "cffcmap.c"
-#include "cffdrivr.c"
-#include "cffgload.c"
-#include "cffparse.c"
-#include "cffload.c"
-#include "cffobjs.c"
-
-/* END */
diff --git a/contrib/libs/freetype/src/cff/cffcmap.c b/contrib/libs/freetype/src/cff/cffcmap.c
deleted file mode 100644
index ea5f8ed288..0000000000
--- a/contrib/libs/freetype/src/cff/cffcmap.c
+++ /dev/null
@@ -1,230 +0,0 @@
-/****************************************************************************
- *
- * cffcmap.c
- *
- * CFF character mapping table (cmap) support (body).
- *
- * Copyright (C) 2002-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftdebug.h>
-#include "cffcmap.h"
-#include "cffload.h"
-
-#include "cfferrs.h"
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** CFF STANDARD (AND EXPERT) ENCODING CMAPS *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- FT_CALLBACK_DEF( FT_Error )
- cff_cmap_encoding_init( FT_CMap cmap,
- FT_Pointer pointer )
- {
- CFF_CMapStd cffcmap = (CFF_CMapStd)cmap;
- TT_Face face = (TT_Face)FT_CMAP_FACE( cmap );
- CFF_Font cff = (CFF_Font)face->extra.data;
- CFF_Encoding encoding = &cff->encoding;
-
- FT_UNUSED( pointer );
-
-
- cffcmap->gids = encoding->codes;
-
- return 0;
- }
-
-
- FT_CALLBACK_DEF( void )
- cff_cmap_encoding_done( FT_CMap cmap )
- {
- CFF_CMapStd cffcmap = (CFF_CMapStd)cmap;
-
-
- cffcmap->gids = NULL;
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- cff_cmap_encoding_char_index( FT_CMap cmap,
- FT_UInt32 char_code )
- {
- CFF_CMapStd cffcmap = (CFF_CMapStd)cmap;
- FT_UInt result = 0;
-
-
- if ( char_code < 256 )
- result = cffcmap->gids[char_code];
-
- return result;
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- cff_cmap_encoding_char_next( FT_CMap cmap,
- FT_UInt32 *pchar_code )
- {
- CFF_CMapStd cffcmap = (CFF_CMapStd)cmap;
- FT_UInt result = 0;
- FT_UInt32 char_code = *pchar_code;
-
-
- while ( char_code < 255 )
- {
- result = cffcmap->gids[++char_code];
- if ( result )
- {
- *pchar_code = char_code;
- break;
- }
- }
-
- return result;
- }
-
-
- FT_DEFINE_CMAP_CLASS(
- cff_cmap_encoding_class_rec,
-
- sizeof ( CFF_CMapStdRec ),
-
- (FT_CMap_InitFunc) cff_cmap_encoding_init, /* init */
- (FT_CMap_DoneFunc) cff_cmap_encoding_done, /* done */
- (FT_CMap_CharIndexFunc)cff_cmap_encoding_char_index, /* char_index */
- (FT_CMap_CharNextFunc) cff_cmap_encoding_char_next, /* char_next */
-
- (FT_CMap_CharVarIndexFunc) NULL, /* char_var_index */
- (FT_CMap_CharVarIsDefaultFunc)NULL, /* char_var_default */
- (FT_CMap_VariantListFunc) NULL, /* variant_list */
- (FT_CMap_CharVariantListFunc) NULL, /* charvariant_list */
- (FT_CMap_VariantCharListFunc) NULL /* variantchar_list */
- )
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** CFF SYNTHETIC UNICODE ENCODING CMAP *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- FT_CALLBACK_DEF( const char* )
- cff_sid_to_glyph_name( void* face_, /* TT_Face */
- FT_UInt idx )
- {
- TT_Face face = (TT_Face)face_;
- CFF_Font cff = (CFF_Font)face->extra.data;
- CFF_Charset charset = &cff->charset;
- FT_UInt sid = charset->sids[idx];
-
-
- return cff_index_get_sid_string( cff, sid );
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- cff_cmap_unicode_init( FT_CMap cmap, /* PS_Unicodes */
- FT_Pointer pointer )
- {
- PS_Unicodes unicodes = (PS_Unicodes)cmap;
- TT_Face face = (TT_Face)FT_CMAP_FACE( cmap );
- FT_Memory memory = FT_FACE_MEMORY( face );
- CFF_Font cff = (CFF_Font)face->extra.data;
- CFF_Charset charset = &cff->charset;
- FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)cff->psnames;
-
- FT_UNUSED( pointer );
-
-
- /* can't build Unicode map for CID-keyed font */
- /* because we don't know glyph names. */
- if ( !charset->sids )
- return FT_THROW( No_Unicode_Glyph_Name );
-
- if ( !psnames->unicodes_init )
- return FT_THROW( Unimplemented_Feature );
-
- return psnames->unicodes_init( memory,
- unicodes,
- cff->num_glyphs,
- &cff_sid_to_glyph_name,
- (PS_FreeGlyphNameFunc)NULL,
- (FT_Pointer)face );
- }
-
-
- FT_CALLBACK_DEF( void )
- cff_cmap_unicode_done( FT_CMap cmap ) /* PS_Unicodes */
- {
- PS_Unicodes unicodes = (PS_Unicodes)cmap;
- FT_Face face = FT_CMAP_FACE( cmap );
- FT_Memory memory = FT_FACE_MEMORY( face );
-
-
- FT_FREE( unicodes->maps );
- unicodes->num_maps = 0;
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- cff_cmap_unicode_char_index( FT_CMap cmap, /* PS_Unicodes */
- FT_UInt32 char_code )
- {
- PS_Unicodes unicodes = (PS_Unicodes)cmap;
- TT_Face face = (TT_Face)FT_CMAP_FACE( cmap );
- CFF_Font cff = (CFF_Font)face->extra.data;
- FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)cff->psnames;
-
-
- return psnames->unicodes_char_index( unicodes, char_code );
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- cff_cmap_unicode_char_next( FT_CMap cmap, /* PS_Unicodes */
- FT_UInt32 *pchar_code )
- {
- PS_Unicodes unicodes = (PS_Unicodes)cmap;
- TT_Face face = (TT_Face)FT_CMAP_FACE( cmap );
- CFF_Font cff = (CFF_Font)face->extra.data;
- FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)cff->psnames;
-
-
- return psnames->unicodes_char_next( unicodes, pchar_code );
- }
-
-
- FT_DEFINE_CMAP_CLASS(
- cff_cmap_unicode_class_rec,
-
- sizeof ( PS_UnicodesRec ),
-
- (FT_CMap_InitFunc) cff_cmap_unicode_init, /* init */
- (FT_CMap_DoneFunc) cff_cmap_unicode_done, /* done */
- (FT_CMap_CharIndexFunc)cff_cmap_unicode_char_index, /* char_index */
- (FT_CMap_CharNextFunc) cff_cmap_unicode_char_next, /* char_next */
-
- (FT_CMap_CharVarIndexFunc) NULL, /* char_var_index */
- (FT_CMap_CharVarIsDefaultFunc)NULL, /* char_var_default */
- (FT_CMap_VariantListFunc) NULL, /* variant_list */
- (FT_CMap_CharVariantListFunc) NULL, /* charvariant_list */
- (FT_CMap_VariantCharListFunc) NULL /* variantchar_list */
- )
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cff/cffcmap.h b/contrib/libs/freetype/src/cff/cffcmap.h
deleted file mode 100644
index 1dd8700cd8..0000000000
--- a/contrib/libs/freetype/src/cff/cffcmap.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/****************************************************************************
- *
- * cffcmap.h
- *
- * CFF character mapping table (cmap) support (specification).
- *
- * Copyright (C) 2002-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef CFFCMAP_H_
-#define CFFCMAP_H_
-
-#include <freetype/internal/cffotypes.h>
-
-FT_BEGIN_HEADER
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** TYPE1 STANDARD (AND EXPERT) ENCODING CMAPS *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- /* standard (and expert) encoding cmaps */
- typedef struct CFF_CMapStdRec_* CFF_CMapStd;
-
- typedef struct CFF_CMapStdRec_
- {
- FT_CMapRec cmap;
- FT_UShort* gids; /* up to 256 elements */
-
- } CFF_CMapStdRec;
-
-
- FT_DECLARE_CMAP_CLASS( cff_cmap_encoding_class_rec )
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** CFF SYNTHETIC UNICODE ENCODING CMAP *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- /* unicode (synthetic) cmaps */
-
- FT_DECLARE_CMAP_CLASS( cff_cmap_unicode_class_rec )
-
-
-FT_END_HEADER
-
-#endif /* CFFCMAP_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cff/cffdrivr.c b/contrib/libs/freetype/src/cff/cffdrivr.c
deleted file mode 100644
index f6ebdb3810..0000000000
--- a/contrib/libs/freetype/src/cff/cffdrivr.c
+++ /dev/null
@@ -1,1263 +0,0 @@
-/****************************************************************************
- *
- * cffdrivr.c
- *
- * OpenType font driver implementation (body).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, Werner Lemberg, and Dominik Röttsches.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/freetype.h>
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/internal/sfnt.h>
-#include <freetype/internal/psaux.h>
-#include <freetype/internal/ftpsprop.h>
-#include <freetype/internal/services/svcid.h>
-#include <freetype/internal/services/svpsinfo.h>
-#include <freetype/internal/services/svpostnm.h>
-#include <freetype/internal/services/svttcmap.h>
-#include <freetype/internal/services/svcfftl.h>
-
-#include "cffdrivr.h"
-#include "cffgload.h"
-#include "cffload.h"
-#include "cffcmap.h"
-#include "cffparse.h"
-#include "cffobjs.h"
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
-#include <freetype/internal/services/svmm.h>
-#include <freetype/internal/services/svmetric.h>
-#endif
-
-#include "cfferrs.h"
-
-#include <freetype/internal/services/svfntfmt.h>
-#include <freetype/internal/services/svgldict.h>
-#include <freetype/internal/services/svprop.h>
-#include <freetype/ftdriver.h>
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT cffdriver
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /**** ****/
- /**** ****/
- /**** F A C E S ****/
- /**** ****/
- /**** ****/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /**************************************************************************
- *
- * @Function:
- * cff_get_kerning
- *
- * @Description:
- * A driver method used to return the kerning vector between two
- * glyphs of the same face.
- *
- * @Input:
- * face ::
- * A handle to the source face object.
- *
- * left_glyph ::
- * The index of the left glyph in the kern pair.
- *
- * right_glyph ::
- * The index of the right glyph in the kern pair.
- *
- * @Output:
- * kerning ::
- * The kerning vector. This is in font units for
- * scalable formats, and in pixels for fixed-sizes
- * formats.
- *
- * @Return:
- * FreeType error code. 0 means success.
- *
- * @Note:
- * Only horizontal layouts (left-to-right & right-to-left) are
- * supported by this function. Other layouts, or more sophisticated
- * kernings, are out of scope of this method (the basic driver
- * interface is meant to be simple).
- *
- * They can be implemented by format-specific interfaces.
- */
- FT_CALLBACK_DEF( FT_Error )
- cff_get_kerning( FT_Face face, /* CFF_Face */
- FT_UInt left_glyph,
- FT_UInt right_glyph,
- FT_Vector* kerning )
- {
- CFF_Face cffface = (CFF_Face)face;
- SFNT_Service sfnt = (SFNT_Service)cffface->sfnt;
-
-
- kerning->x = 0;
- kerning->y = 0;
-
- if ( sfnt )
- kerning->x = sfnt->get_kerning( cffface, left_glyph, right_glyph );
-
- return FT_Err_Ok;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * cff_glyph_load
- *
- * @Description:
- * A driver method used to load a glyph within a given glyph slot.
- *
- * @Input:
- * slot ::
- * A handle to the target slot object where the glyph
- * will be loaded.
- *
- * size ::
- * A handle to the source face size at which the glyph
- * must be scaled, loaded, etc.
- *
- * glyph_index ::
- * The index of the glyph in the font file.
- *
- * load_flags ::
- * A flag indicating what to load for this glyph. The
- * FT_LOAD_??? constants can be used to control the
- * glyph loading process (e.g., whether the outline
- * should be scaled, whether to load bitmaps or not,
- * whether to hint the outline, etc).
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
- FT_CALLBACK_DEF( FT_Error )
- cff_glyph_load( FT_GlyphSlot slot, /* CFF_GlyphSlot */
- FT_Size size, /* CFF_Size */
- FT_UInt glyph_index,
- FT_Int32 load_flags )
- {
- FT_Error error;
- CFF_GlyphSlot cffslot = (CFF_GlyphSlot)slot;
- CFF_Size cffsize = (CFF_Size)size;
-
-
- if ( !cffslot )
- return FT_THROW( Invalid_Slot_Handle );
-
- FT_TRACE1(( "cff_glyph_load: glyph index %d\n", glyph_index ));
-
- /* check whether we want a scaled outline or bitmap */
- if ( !cffsize )
- load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
-
- /* reset the size object if necessary */
- if ( load_flags & FT_LOAD_NO_SCALE )
- size = NULL;
-
- if ( size )
- {
- /* these two objects must have the same parent */
- if ( size->face != slot->face )
- return FT_THROW( Invalid_Face_Handle );
- }
-
- /* now load the glyph outline if necessary */
- error = cff_slot_load( cffslot, cffsize, glyph_index, load_flags );
-
- /* force drop-out mode to 2 - irrelevant now */
- /* slot->outline.dropout_mode = 2; */
-
- return error;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- cff_get_advances( FT_Face face,
- FT_UInt start,
- FT_UInt count,
- FT_Int32 flags,
- FT_Fixed* advances )
- {
- FT_UInt nn;
- FT_Error error = FT_Err_Ok;
- FT_GlyphSlot slot = face->glyph;
-
-
- if ( FT_IS_SFNT( face ) )
- {
- /* OpenType 1.7 mandates that the data from `hmtx' table be used; */
- /* it is no longer necessary that those values are identical to */
- /* the values in the `CFF' table */
-
- CFF_Face cffface = (CFF_Face)face;
- FT_Short dummy;
-
-
- if ( flags & FT_LOAD_VERTICAL_LAYOUT )
- {
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- /* no fast retrieval for blended MM fonts without VVAR table */
- if ( ( FT_IS_NAMED_INSTANCE( face ) || FT_IS_VARIATION( face ) ) &&
- !( cffface->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) )
- return FT_THROW( Unimplemented_Feature );
-#endif
-
- /* check whether we have data from the `vmtx' table at all; */
- /* otherwise we extract the info from the CFF glyphstrings */
- /* (instead of synthesizing a global value using the `OS/2' */
- /* table) */
- if ( !cffface->vertical_info )
- goto Missing_Table;
-
- for ( nn = 0; nn < count; nn++ )
- {
- FT_UShort ah;
-
-
- ( (SFNT_Service)cffface->sfnt )->get_metrics( cffface,
- 1,
- start + nn,
- &dummy,
- &ah );
-
- FT_TRACE5(( " idx %d: advance height %d font unit%s\n",
- start + nn,
- ah,
- ah == 1 ? "" : "s" ));
- advances[nn] = ah;
- }
- }
- else
- {
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- /* no fast retrieval for blended MM fonts without HVAR table */
- if ( ( FT_IS_NAMED_INSTANCE( face ) || FT_IS_VARIATION( face ) ) &&
- !( cffface->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) )
- return FT_THROW( Unimplemented_Feature );
-#endif
-
- /* check whether we have data from the `hmtx' table at all */
- if ( !cffface->horizontal.number_Of_HMetrics )
- goto Missing_Table;
-
- for ( nn = 0; nn < count; nn++ )
- {
- FT_UShort aw;
-
-
- ( (SFNT_Service)cffface->sfnt )->get_metrics( cffface,
- 0,
- start + nn,
- &dummy,
- &aw );
-
- FT_TRACE5(( " idx %d: advance width %d font unit%s\n",
- start + nn,
- aw,
- aw == 1 ? "" : "s" ));
- advances[nn] = aw;
- }
- }
-
- return error;
- }
-
- Missing_Table:
- flags |= (FT_UInt32)FT_LOAD_ADVANCE_ONLY;
-
- for ( nn = 0; nn < count; nn++ )
- {
- error = cff_glyph_load( slot, face->size, start + nn, flags );
- if ( error )
- break;
-
- advances[nn] = ( flags & FT_LOAD_VERTICAL_LAYOUT )
- ? slot->linearVertAdvance
- : slot->linearHoriAdvance;
- }
-
- return error;
- }
-
-
- /*
- * GLYPH DICT SERVICE
- *
- */
-
- FT_CALLBACK_DEF( FT_Error )
- cff_get_glyph_name( FT_Face face, /* CFF_Face */
- FT_UInt glyph_index,
- FT_Pointer buffer,
- FT_UInt buffer_max )
- {
- CFF_Face cffface = (CFF_Face)face;
- CFF_Font font = (CFF_Font)cffface->extra.data;
- FT_String* gname;
- FT_UShort sid;
- FT_Error error;
-
-
- /* CFF2 table does not have glyph names; */
- /* we need to use `post' table method */
- if ( font->version_major == 2 )
- {
- FT_Library library = FT_FACE_LIBRARY( face );
- FT_Module sfnt_module = FT_Get_Module( library, "sfnt" );
- FT_Service_GlyphDict service =
- (FT_Service_GlyphDict)ft_module_get_service(
- sfnt_module,
- FT_SERVICE_ID_GLYPH_DICT,
- 0 );
-
-
- if ( service && service->get_name )
- return service->get_name( face, glyph_index, buffer, buffer_max );
- else
- {
- FT_ERROR(( "cff_get_glyph_name:"
- " cannot get glyph name from a CFF2 font\n" ));
- FT_ERROR(( " "
- " without the `psnames' module\n" ));
- error = FT_THROW( Missing_Module );
- goto Exit;
- }
- }
-
- if ( !font->psnames )
- {
- FT_ERROR(( "cff_get_glyph_name:"
- " cannot get glyph name from CFF & CEF fonts\n" ));
- FT_ERROR(( " "
- " without the `psnames' module\n" ));
- error = FT_THROW( Missing_Module );
- goto Exit;
- }
-
- /* first, locate the sid in the charset table */
- sid = font->charset.sids[glyph_index];
-
- /* now, look up the name itself */
- gname = cff_index_get_sid_string( font, sid );
-
- if ( gname )
- FT_STRCPYN( buffer, gname, buffer_max );
-
- error = FT_Err_Ok;
-
- Exit:
- return error;
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- cff_get_name_index( FT_Face face, /* CFF_Face */
- const FT_String* glyph_name )
- {
- CFF_Face cffface = (CFF_Face)face;
- CFF_Font cff = (CFF_Font)cffface->extra.data;
- CFF_Charset charset = &cff->charset;
- FT_Service_PsCMaps psnames;
- FT_String* name;
- FT_UShort sid;
- FT_UInt i;
-
-
- /* CFF2 table does not have glyph names; */
- /* we need to use `post' table method */
- if ( cff->version_major == 2 )
- {
- FT_Library library = FT_FACE_LIBRARY( face );
- FT_Module sfnt_module = FT_Get_Module( library, "sfnt" );
- FT_Service_GlyphDict service =
- (FT_Service_GlyphDict)ft_module_get_service(
- sfnt_module,
- FT_SERVICE_ID_GLYPH_DICT,
- 0 );
-
-
- if ( service && service->name_index )
- return service->name_index( face, glyph_name );
- else
- {
- FT_ERROR(( "cff_get_name_index:"
- " cannot get glyph index from a CFF2 font\n" ));
- FT_ERROR(( " "
- " without the `psnames' module\n" ));
- return 0;
- }
- }
-
- FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS );
- if ( !psnames )
- return 0;
-
- for ( i = 0; i < cff->num_glyphs; i++ )
- {
- sid = charset->sids[i];
-
- if ( sid > 390 )
- name = cff_index_get_string( cff, sid - 391 );
- else
- name = (FT_String *)psnames->adobe_std_strings( sid );
-
- if ( !name )
- continue;
-
- if ( !ft_strcmp( glyph_name, name ) )
- return i;
- }
-
- return 0;
- }
-
-
- FT_DEFINE_SERVICE_GLYPHDICTREC(
- cff_service_glyph_dict,
-
- cff_get_glyph_name, /* FT_GlyphDict_GetNameFunc get_name */
- cff_get_name_index /* FT_GlyphDict_NameIndexFunc name_index */
- )
-
-
- /*
- * POSTSCRIPT INFO SERVICE
- *
- */
-
- FT_CALLBACK_DEF( FT_Int )
- cff_ps_has_glyph_names( FT_Face face )
- {
- return ( face->face_flags & FT_FACE_FLAG_GLYPH_NAMES ) > 0;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- cff_ps_get_font_info( FT_Face face, /* CFF_Face */
- PS_FontInfoRec* afont_info )
- {
- CFF_Face cffface = (CFF_Face)face;
- CFF_Font cff = (CFF_Font)cffface->extra.data;
- FT_Error error = FT_Err_Ok;
-
-
- if ( cffface->is_cff2 )
- {
- error = FT_THROW( Invalid_Argument );
- goto Fail;
- }
-
- if ( cff && !cff->font_info )
- {
- CFF_FontRecDict dict = &cff->top_font.font_dict;
- FT_Memory memory = FT_FACE_MEMORY( face );
- PS_FontInfoRec* font_info = NULL;
-
-
- if ( FT_QNEW( font_info ) )
- goto Fail;
-
- font_info->version = cff_index_get_sid_string( cff,
- dict->version );
- font_info->notice = cff_index_get_sid_string( cff,
- dict->notice );
- font_info->full_name = cff_index_get_sid_string( cff,
- dict->full_name );
- font_info->family_name = cff_index_get_sid_string( cff,
- dict->family_name );
- font_info->weight = cff_index_get_sid_string( cff,
- dict->weight );
- font_info->italic_angle = dict->italic_angle;
- font_info->is_fixed_pitch = dict->is_fixed_pitch;
- font_info->underline_position = (FT_Short)dict->underline_position;
- font_info->underline_thickness = (FT_UShort)dict->underline_thickness;
-
- cff->font_info = font_info;
- }
-
- if ( cff )
- *afont_info = *cff->font_info;
-
- Fail:
- return error;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- cff_ps_get_font_extra( FT_Face face, /* CFF_Face */
- PS_FontExtraRec* afont_extra )
- {
- CFF_Face cffface = (CFF_Face)face;
- CFF_Font cff = (CFF_Font)cffface->extra.data;
- FT_Error error = FT_Err_Ok;
-
-
- if ( cff && !cff->font_extra )
- {
- CFF_FontRecDict dict = &cff->top_font.font_dict;
- FT_Memory memory = FT_FACE_MEMORY( face );
- PS_FontExtraRec* font_extra = NULL;
- FT_String* embedded_postscript;
-
-
- if ( FT_QNEW( font_extra ) )
- goto Fail;
-
- font_extra->fs_type = 0U;
-
- embedded_postscript = cff_index_get_sid_string(
- cff,
- dict->embedded_postscript );
- if ( embedded_postscript )
- {
- FT_String* start_fstype;
- FT_String* start_def;
-
-
- /* Identify the XYZ integer in `/FSType XYZ def' substring. */
- if ( ( start_fstype = ft_strstr( embedded_postscript,
- "/FSType" ) ) != NULL &&
- ( start_def = ft_strstr( start_fstype +
- sizeof ( "/FSType" ) - 1,
- "def" ) ) != NULL )
- {
- FT_String* s;
-
-
- for ( s = start_fstype + sizeof ( "/FSType" ) - 1;
- s != start_def;
- s++ )
- {
- if ( *s >= '0' && *s <= '9' )
- {
- if ( font_extra->fs_type >= ( FT_USHORT_MAX - 9 ) / 10 )
- {
- /* Overflow - ignore the FSType value. */
- font_extra->fs_type = 0U;
- break;
- }
-
- font_extra->fs_type *= 10;
- font_extra->fs_type += (FT_UShort)( *s - '0' );
- }
- else if ( *s != ' ' && *s != '\n' && *s != '\r' )
- {
- /* Non-whitespace character between `/FSType' and next `def' */
- /* - ignore the FSType value. */
- font_extra->fs_type = 0U;
- break;
- }
- }
- }
- }
-
- cff->font_extra = font_extra;
- }
-
- if ( cff )
- *afont_extra = *cff->font_extra;
-
- Fail:
- return error;
- }
-
-
- FT_DEFINE_SERVICE_PSINFOREC(
- cff_service_ps_info,
-
- cff_ps_get_font_info, /* PS_GetFontInfoFunc ps_get_font_info */
- cff_ps_get_font_extra, /* PS_GetFontExtraFunc ps_get_font_extra */
- cff_ps_has_glyph_names, /* PS_HasGlyphNamesFunc ps_has_glyph_names */
- /* unsupported with CFF fonts */
- NULL, /* PS_GetFontPrivateFunc ps_get_font_private */
- /* not implemented */
- NULL /* PS_GetFontValueFunc ps_get_font_value */
- )
-
-
- /*
- * POSTSCRIPT NAME SERVICE
- *
- */
-
- FT_CALLBACK_DEF( const char* )
- cff_get_ps_name( FT_Face face ) /* CFF_Face */
- {
- CFF_Face cffface = (CFF_Face)face;
- CFF_Font cff = (CFF_Font)cffface->extra.data;
- SFNT_Service sfnt = (SFNT_Service)cffface->sfnt;
-
-
- /* following the OpenType specification 1.7, we return the name stored */
- /* in the `name' table for a CFF wrapped into an SFNT container */
-
- if ( FT_IS_SFNT( face ) && sfnt )
- {
- FT_Library library = FT_FACE_LIBRARY( face );
- FT_Module sfnt_module = FT_Get_Module( library, "sfnt" );
- FT_Service_PsFontName service =
- (FT_Service_PsFontName)ft_module_get_service(
- sfnt_module,
- FT_SERVICE_ID_POSTSCRIPT_FONT_NAME,
- 0 );
-
-
- if ( service && service->get_ps_font_name )
- return service->get_ps_font_name( face );
- }
-
- return cff ? (const char*)cff->font_name : NULL;
- }
-
-
- FT_DEFINE_SERVICE_PSFONTNAMEREC(
- cff_service_ps_name,
-
- cff_get_ps_name /* FT_PsName_GetFunc get_ps_font_name */
- )
-
-
- /*
- * TT CMAP INFO
- *
- * If the charmap is a synthetic Unicode encoding cmap or
- * a Type 1 standard (or expert) encoding cmap, hide TT CMAP INFO
- * service defined in SFNT module.
- *
- * Otherwise call the service function in the sfnt module.
- *
- */
- FT_CALLBACK_DEF( FT_Error )
- cff_get_cmap_info( FT_CharMap charmap,
- TT_CMapInfo *cmap_info )
- {
- FT_CMap cmap = FT_CMAP( charmap );
- FT_Error error = FT_Err_Ok;
-
- FT_Face face = FT_CMAP_FACE( cmap );
- FT_Library library = FT_FACE_LIBRARY( face );
-
-
- if ( cmap->clazz != &cff_cmap_encoding_class_rec &&
- cmap->clazz != &cff_cmap_unicode_class_rec )
- {
- FT_Module sfnt = FT_Get_Module( library, "sfnt" );
- FT_Service_TTCMaps service =
- (FT_Service_TTCMaps)ft_module_get_service( sfnt,
- FT_SERVICE_ID_TT_CMAP,
- 0 );
-
-
- if ( service && service->get_cmap_info )
- error = service->get_cmap_info( charmap, cmap_info );
- }
- else
- error = FT_THROW( Invalid_CharMap_Format );
-
- return error;
- }
-
-
- FT_DEFINE_SERVICE_TTCMAPSREC(
- cff_service_get_cmap_info,
-
- cff_get_cmap_info /* TT_CMap_Info_GetFunc get_cmap_info */
- )
-
-
- /*
- * CID INFO SERVICE
- *
- */
- FT_CALLBACK_DEF( FT_Error )
- cff_get_ros( FT_Face face, /* FT_Face */
- const char* *registry,
- const char* *ordering,
- FT_Int *supplement )
- {
- FT_Error error = FT_Err_Ok;
- CFF_Face cffface = (CFF_Face)face;
- CFF_Font cff = (CFF_Font)cffface->extra.data;
-
-
- if ( cff )
- {
- CFF_FontRecDict dict = &cff->top_font.font_dict;
-
-
- if ( dict->cid_registry == 0xFFFFU )
- {
- error = FT_THROW( Invalid_Argument );
- goto Fail;
- }
-
- if ( registry )
- {
- if ( !cff->registry )
- cff->registry = cff_index_get_sid_string( cff,
- dict->cid_registry );
- *registry = cff->registry;
- }
-
- if ( ordering )
- {
- if ( !cff->ordering )
- cff->ordering = cff_index_get_sid_string( cff,
- dict->cid_ordering );
- *ordering = cff->ordering;
- }
-
- /*
- * XXX: According to Adobe TechNote #5176, the supplement in CFF
- * can be a real number. We truncate it to fit public API
- * since freetype-2.3.6.
- */
- if ( supplement )
- {
- if ( dict->cid_supplement < FT_INT_MIN ||
- dict->cid_supplement > FT_INT_MAX )
- FT_TRACE1(( "cff_get_ros: too large supplement %ld is truncated\n",
- dict->cid_supplement ));
- *supplement = (FT_Int)dict->cid_supplement;
- }
- }
-
- Fail:
- return error;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- cff_get_is_cid( FT_Face face, /* CFF_Face */
- FT_Bool *is_cid )
- {
- FT_Error error = FT_Err_Ok;
- CFF_Face cffface = (CFF_Face)face;
- CFF_Font cff = (CFF_Font)cffface->extra.data;
-
-
- *is_cid = 0;
-
- if ( cff )
- {
- CFF_FontRecDict dict = &cff->top_font.font_dict;
-
-
- if ( dict->cid_registry != 0xFFFFU )
- *is_cid = 1;
- }
-
- return error;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- cff_get_cid_from_glyph_index( FT_Face face, /* CFF_Face */
- FT_UInt glyph_index,
- FT_UInt *cid )
- {
- FT_Error error = FT_Err_Ok;
- CFF_Face cffface = (CFF_Face)face;
- CFF_Font cff = (CFF_Font)cffface->extra.data;
-
-
- if ( cff )
- {
- FT_UInt c;
- CFF_FontRecDict dict = &cff->top_font.font_dict;
-
-
- if ( dict->cid_registry == 0xFFFFU )
- {
- error = FT_THROW( Invalid_Argument );
- goto Fail;
- }
-
- if ( glyph_index >= cff->num_glyphs )
- {
- error = FT_THROW( Invalid_Argument );
- goto Fail;
- }
-
- c = cff->charset.sids[glyph_index];
-
- if ( cid )
- *cid = c;
- }
-
- Fail:
- return error;
- }
-
-
- FT_DEFINE_SERVICE_CIDREC(
- cff_service_cid_info,
-
- cff_get_ros,
- /* FT_CID_GetRegistryOrderingSupplementFunc get_ros */
- cff_get_is_cid,
- /* FT_CID_GetIsInternallyCIDKeyedFunc get_is_cid */
- cff_get_cid_from_glyph_index
- /* FT_CID_GetCIDFromGlyphIndexFunc get_cid_from_glyph_index */
- )
-
-
- /*
- * PROPERTY SERVICE
- *
- */
-
- FT_DEFINE_SERVICE_PROPERTIESREC(
- cff_service_properties,
-
- ps_property_set, /* FT_Properties_SetFunc set_property */
- ps_property_get /* FT_Properties_GetFunc get_property */
- )
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
-
- /*
- * MULTIPLE MASTER SERVICE
- *
- */
-
- FT_CALLBACK_DEF( FT_Error )
- cff_set_mm_blend( FT_Face face, /* CFF_Face */
- FT_UInt num_coords,
- FT_Fixed* coords )
- {
- CFF_Face cffface = (CFF_Face)face;
- FT_Service_MultiMasters mm = (FT_Service_MultiMasters)cffface->mm;
-
-
- return mm->set_mm_blend( face, num_coords, coords );
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- cff_get_mm_blend( FT_Face face, /* CFF_Face */
- FT_UInt num_coords,
- FT_Fixed* coords )
- {
- CFF_Face cffface = (CFF_Face)face;
- FT_Service_MultiMasters mm = (FT_Service_MultiMasters)cffface->mm;
-
-
- return mm->get_mm_blend( face, num_coords, coords );
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- cff_set_mm_weightvector( FT_Face face, /* CFF_Face */
- FT_UInt len,
- FT_Fixed* weightvector )
- {
- CFF_Face cffface = (CFF_Face)face;
- FT_Service_MultiMasters mm = (FT_Service_MultiMasters)cffface->mm;
-
-
- return mm->set_mm_weightvector( face, len, weightvector );
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- cff_get_mm_weightvector( FT_Face face, /* CFF_Face */
- FT_UInt* len,
- FT_Fixed* weightvector )
- {
- CFF_Face cffface = (CFF_Face)face;
- FT_Service_MultiMasters mm = (FT_Service_MultiMasters)cffface->mm;
-
-
- return mm->get_mm_weightvector( face, len, weightvector );
- }
-
-
- FT_CALLBACK_DEF( void )
- cff_construct_ps_name( FT_Face face ) /* CFF_Face */
- {
- CFF_Face cffface = (CFF_Face)face;
- FT_Service_MultiMasters mm = (FT_Service_MultiMasters)cffface->mm;
-
-
- mm->construct_ps_name( face );
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- cff_get_mm_var( FT_Face face, /* CFF_Face */
- FT_MM_Var* *master )
- {
- CFF_Face cffface = (CFF_Face)face;
- FT_Service_MultiMasters mm = (FT_Service_MultiMasters)cffface->mm;
-
-
- return mm->get_mm_var( face, master );
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- cff_set_var_design( FT_Face face, /* CFF_Face */
- FT_UInt num_coords,
- FT_Fixed* coords )
- {
- CFF_Face cffface = (CFF_Face)face;
- FT_Service_MultiMasters mm = (FT_Service_MultiMasters)cffface->mm;
-
-
- return mm->set_var_design( face, num_coords, coords );
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- cff_get_var_design( FT_Face face, /* CFF_Face */
- FT_UInt num_coords,
- FT_Fixed* coords )
- {
- CFF_Face cffface = (CFF_Face)face;
- FT_Service_MultiMasters mm = (FT_Service_MultiMasters)cffface->mm;
-
-
- return mm->get_var_design( face, num_coords, coords );
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- cff_set_named_instance( FT_Face face, /* CFF_Face */
- FT_UInt instance_index )
- {
- CFF_Face cffface = (CFF_Face)face;
- FT_Service_MultiMasters mm = (FT_Service_MultiMasters)cffface->mm;
-
-
- return mm->set_named_instance( face, instance_index );
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- cff_get_default_named_instance( FT_Face face, /* CFF_Face */
- FT_UInt *instance_index )
- {
- CFF_Face cffface = (CFF_Face)face;
- FT_Service_MultiMasters mm = (FT_Service_MultiMasters)cffface->mm;
-
-
- return mm->get_default_named_instance( face, instance_index );
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- cff_load_item_variation_store( FT_Face face, /* CFF_Face */
- FT_ULong offset,
- GX_ItemVarStore itemStore )
- {
- CFF_Face cffface = (CFF_Face)face;
- FT_Service_MultiMasters mm = (FT_Service_MultiMasters)cffface->mm;
-
-
- return mm->load_item_var_store( face, offset, itemStore );
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- cff_load_delta_set_index_mapping( FT_Face face, /* CFF_Face */
- FT_ULong offset,
- GX_DeltaSetIdxMap map,
- GX_ItemVarStore itemStore,
- FT_ULong table_len )
- {
- CFF_Face cffface = (CFF_Face)face;
- FT_Service_MultiMasters mm = (FT_Service_MultiMasters)cffface->mm;
-
-
- return mm->load_delta_set_idx_map( face, offset, map,
- itemStore, table_len );
- }
-
-
- FT_CALLBACK_DEF( FT_Int )
- cff_get_item_delta( FT_Face face, /* CFF_Face */
- GX_ItemVarStore itemStore,
- FT_UInt outerIndex,
- FT_UInt innerIndex )
- {
- CFF_Face cffface = (CFF_Face)face;
- FT_Service_MultiMasters mm = (FT_Service_MultiMasters)cffface->mm;
-
-
- return mm->get_item_delta( face, itemStore, outerIndex, innerIndex );
- }
-
-
- FT_CALLBACK_DEF( void )
- cff_done_item_variation_store( FT_Face face, /* CFF_Face */
- GX_ItemVarStore itemStore )
- {
- CFF_Face cffface = (CFF_Face)face;
- FT_Service_MultiMasters mm = (FT_Service_MultiMasters)cffface->mm;
-
-
- mm->done_item_var_store( face, itemStore );
- }
-
-
- FT_CALLBACK_DEF( void )
- cff_done_delta_set_index_map( FT_Face face, /* CFF_Face */
- GX_DeltaSetIdxMap deltaSetIdxMap )
- {
- CFF_Face cffface = (CFF_Face)face;
- FT_Service_MultiMasters mm = (FT_Service_MultiMasters)cffface->mm;
-
-
- mm->done_delta_set_idx_map( face, deltaSetIdxMap );
- }
-
-
-
- FT_DEFINE_SERVICE_MULTIMASTERSREC(
- cff_service_multi_masters,
-
- NULL, /* FT_Get_MM_Func get_mm */
- NULL, /* FT_Set_MM_Design_Func set_mm_design */
- cff_set_mm_blend, /* FT_Set_MM_Blend_Func set_mm_blend */
- cff_get_mm_blend, /* FT_Get_MM_Blend_Func get_mm_blend */
- cff_get_mm_var, /* FT_Get_MM_Var_Func get_mm_var */
- cff_set_var_design, /* FT_Set_Var_Design_Func set_var_design */
- cff_get_var_design, /* FT_Get_Var_Design_Func get_var_design */
- cff_set_named_instance,
- /* FT_Set_Named_Instance_Func set_named_instance */
- cff_get_default_named_instance,
- /* FT_Get_Default_Named_Instance_Func get_default_named_instance */
- cff_set_mm_weightvector,
- /* FT_Set_MM_WeightVector_Func set_mm_weightvector */
- cff_get_mm_weightvector,
- /* FT_Get_MM_WeightVector_Func get_mm_weightvector */
- cff_construct_ps_name,
- /* FT_Construct_PS_Name_Func construct_ps_name */
- cff_load_delta_set_index_mapping,
- /* FT_Var_Load_Delta_Set_Idx_Map_Func load_delta_set_idx_map */
- cff_load_item_variation_store,
- /* FT_Var_Load_Item_Var_Store_Func load_item_variation_store */
- cff_get_item_delta,
- /* FT_Var_Get_Item_Delta_Func get_item_delta */
- cff_done_item_variation_store,
- /* FT_Var_Done_Item_Var_Store_Func done_item_variation_store */
- cff_done_delta_set_index_map,
- /* FT_Var_Done_Delta_Set_Idx_Map_Func done_delta_set_index_map */
- cff_get_var_blend, /* FT_Get_Var_Blend_Func get_var_blend */
- cff_done_blend /* FT_Done_Blend_Func done_blend */
- )
-
-
- /*
- * METRICS VARIATIONS SERVICE
- *
- */
-
- FT_CALLBACK_DEF( FT_Error )
- cff_hadvance_adjust( FT_Face face, /* CFF_Face */
- FT_UInt gindex,
- FT_Int *avalue )
- {
- CFF_Face cffface = (CFF_Face)face;
- FT_Service_MetricsVariations
- var = (FT_Service_MetricsVariations)cffface->tt_var;
-
-
- return var->hadvance_adjust( face, gindex, avalue );
- }
-
-
- FT_CALLBACK_DEF( void )
- cff_metrics_adjust( FT_Face face ) /* CFF_Face */
- {
- CFF_Face cffface = (CFF_Face)face;
- FT_Service_MetricsVariations
- var = (FT_Service_MetricsVariations)cffface->tt_var;
-
-
- var->metrics_adjust( face );
- }
-
-
- FT_DEFINE_SERVICE_METRICSVARIATIONSREC(
- cff_service_metrics_variations,
-
- cff_hadvance_adjust, /* FT_HAdvance_Adjust_Func hadvance_adjust */
- NULL, /* FT_LSB_Adjust_Func lsb_adjust */
- NULL, /* FT_RSB_Adjust_Func rsb_adjust */
-
- NULL, /* FT_VAdvance_Adjust_Func vadvance_adjust */
- NULL, /* FT_TSB_Adjust_Func tsb_adjust */
- NULL, /* FT_BSB_Adjust_Func bsb_adjust */
- NULL, /* FT_VOrg_Adjust_Func vorg_adjust */
-
- cff_metrics_adjust, /* FT_Metrics_Adjust_Func metrics_adjust */
- NULL /* FT_Size_Reset_Func size_reset */
- )
-#endif
-
-
- /*
- * CFFLOAD SERVICE
- *
- */
-
- FT_DEFINE_SERVICE_CFFLOADREC(
- cff_service_cff_load,
-
- cff_get_standard_encoding, /* FT_Get_Standard_Encoding_Func get_standard_encoding */
- cff_load_private_dict, /* FT_Load_Private_Dict_Func load_private_dict */
- cff_fd_select_get, /* FT_FD_Select_Get_Func fd_select_get */
- cff_blend_check_vector, /* FT_Blend_Check_Vector_Func blend_check_vector */
- cff_blend_build_vector /* FT_Blend_Build_Vector_Func blend_build_vector */
- )
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /**** ****/
- /**** ****/
- /**** D R I V E R I N T E R F A C E ****/
- /**** ****/
- /**** ****/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-#if defined TT_CONFIG_OPTION_GX_VAR_SUPPORT
- FT_DEFINE_SERVICEDESCREC10(
- cff_services,
-
- FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF,
- FT_SERVICE_ID_MULTI_MASTERS, &cff_service_multi_masters,
- FT_SERVICE_ID_METRICS_VARIATIONS, &cff_service_metrics_variations,
- FT_SERVICE_ID_POSTSCRIPT_INFO, &cff_service_ps_info,
- FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &cff_service_ps_name,
- FT_SERVICE_ID_GLYPH_DICT, &cff_service_glyph_dict,
- FT_SERVICE_ID_TT_CMAP, &cff_service_get_cmap_info,
- FT_SERVICE_ID_CID, &cff_service_cid_info,
- FT_SERVICE_ID_PROPERTIES, &cff_service_properties,
- FT_SERVICE_ID_CFF_LOAD, &cff_service_cff_load
- )
-#else
- FT_DEFINE_SERVICEDESCREC8(
- cff_services,
-
- FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF,
- FT_SERVICE_ID_POSTSCRIPT_INFO, &cff_service_ps_info,
- FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &cff_service_ps_name,
- FT_SERVICE_ID_GLYPH_DICT, &cff_service_glyph_dict,
- FT_SERVICE_ID_TT_CMAP, &cff_service_get_cmap_info,
- FT_SERVICE_ID_CID, &cff_service_cid_info,
- FT_SERVICE_ID_PROPERTIES, &cff_service_properties,
- FT_SERVICE_ID_CFF_LOAD, &cff_service_cff_load
- )
-#endif
-
-
- FT_CALLBACK_DEF( FT_Module_Interface )
- cff_get_interface( FT_Module driver, /* CFF_Driver */
- const char* module_interface )
- {
- FT_Library library;
- FT_Module sfnt;
- FT_Module_Interface result;
-
-
- result = ft_service_list_lookup( cff_services, module_interface );
- if ( result )
- return result;
-
- /* `driver' is not yet evaluated */
- if ( !driver )
- return NULL;
- library = driver->library;
- if ( !library )
- return NULL;
-
- /* we pass our request to the `sfnt' module */
- sfnt = FT_Get_Module( library, "sfnt" );
-
- return sfnt ? sfnt->clazz->get_interface( sfnt, module_interface ) : 0;
- }
-
-
- /* The FT_DriverInterface structure is defined in ftdriver.h. */
-
-#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
-#define CFF_SIZE_SELECT cff_size_select
-#else
-#define CFF_SIZE_SELECT 0
-#endif
-
- FT_DEFINE_DRIVER(
- cff_driver_class,
-
- FT_MODULE_FONT_DRIVER |
- FT_MODULE_DRIVER_SCALABLE |
- FT_MODULE_DRIVER_HAS_HINTER |
- FT_MODULE_DRIVER_HINTS_LIGHTLY,
-
- sizeof ( PS_DriverRec ),
- "cff",
- 0x10000L,
- 0x20000L,
-
- NULL, /* module-specific interface */
-
- cff_driver_init, /* FT_Module_Constructor module_init */
- cff_driver_done, /* FT_Module_Destructor module_done */
- cff_get_interface, /* FT_Module_Requester get_interface */
-
- sizeof ( TT_FaceRec ),
- sizeof ( CFF_SizeRec ),
- sizeof ( CFF_GlyphSlotRec ),
-
- cff_face_init, /* FT_Face_InitFunc init_face */
- cff_face_done, /* FT_Face_DoneFunc done_face */
- cff_size_init, /* FT_Size_InitFunc init_size */
- cff_size_done, /* FT_Size_DoneFunc done_size */
- cff_slot_init, /* FT_Slot_InitFunc init_slot */
- cff_slot_done, /* FT_Slot_DoneFunc done_slot */
-
- cff_glyph_load, /* FT_Slot_LoadFunc load_glyph */
-
- cff_get_kerning, /* FT_Face_GetKerningFunc get_kerning */
- NULL, /* FT_Face_AttachFunc attach_file */
- cff_get_advances, /* FT_Face_GetAdvancesFunc get_advances */
-
- cff_size_request, /* FT_Size_RequestFunc request_size */
- CFF_SIZE_SELECT /* FT_Size_SelectFunc select_size */
- )
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cff/cffdrivr.h b/contrib/libs/freetype/src/cff/cffdrivr.h
deleted file mode 100644
index fd5bc37ecd..0000000000
--- a/contrib/libs/freetype/src/cff/cffdrivr.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/****************************************************************************
- *
- * cffdrivr.h
- *
- * High-level OpenType driver interface (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef CFFDRIVER_H_
-#define CFFDRIVER_H_
-
-
-#include <freetype/internal/ftdrv.h>
-
-
-FT_BEGIN_HEADER
-
- FT_DECLARE_DRIVER( cff_driver_class )
-
-FT_END_HEADER
-
-#endif /* CFFDRIVER_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cff/cfferrs.h b/contrib/libs/freetype/src/cff/cfferrs.h
deleted file mode 100644
index 128adc3b71..0000000000
--- a/contrib/libs/freetype/src/cff/cfferrs.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
- *
- * cfferrs.h
- *
- * CFF error codes (specification only).
- *
- * Copyright (C) 2001-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /**************************************************************************
- *
- * This file is used to define the CFF error enumeration constants.
- *
- */
-
-#ifndef CFFERRS_H_
-#define CFFERRS_H_
-
-#include <freetype/ftmoderr.h>
-
-#undef FTERRORS_H_
-
-#undef FT_ERR_PREFIX
-#define FT_ERR_PREFIX CFF_Err_
-#define FT_ERR_BASE FT_Mod_Err_CFF
-
-
-#include <freetype/fterrors.h>
-
-#endif /* CFFERRS_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cff/cffgload.c b/contrib/libs/freetype/src/cff/cffgload.c
deleted file mode 100644
index cbb071abdf..0000000000
--- a/contrib/libs/freetype/src/cff/cffgload.c
+++ /dev/null
@@ -1,762 +0,0 @@
-/****************************************************************************
- *
- * cffgload.c
- *
- * OpenType Glyph Loader (body).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/internal/sfnt.h>
-#include <freetype/internal/ftcalc.h>
-#include <freetype/internal/psaux.h>
-#include <freetype/ftoutln.h>
-#include <freetype/ftdriver.h>
-
-#include "cffload.h"
-#include "cffgload.h"
-
-#include "cfferrs.h"
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
-#define IS_DEFAULT_INSTANCE( _face ) \
- ( !( FT_IS_NAMED_INSTANCE( _face ) || \
- FT_IS_VARIATION( _face ) ) )
-#else
-#define IS_DEFAULT_INSTANCE( _face ) 1
-#endif
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT cffgload
-
-
- FT_LOCAL_DEF( FT_Error )
- cff_get_glyph_data( TT_Face face,
- FT_UInt glyph_index,
- FT_Byte** pointer,
- FT_ULong* length )
- {
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- /* For incremental fonts get the character data using the */
- /* callback function. */
- if ( face->root.internal->incremental_interface )
- {
- FT_Data data;
- FT_Error error =
- face->root.internal->incremental_interface->funcs->get_glyph_data(
- face->root.internal->incremental_interface->object,
- glyph_index, &data );
-
-
- *pointer = (FT_Byte*)data.pointer;
- *length = data.length;
-
- return error;
- }
- else
-#endif /* FT_CONFIG_OPTION_INCREMENTAL */
-
- {
- CFF_Font cff = (CFF_Font)( face->extra.data );
-
-
- return cff_index_access_element( &cff->charstrings_index, glyph_index,
- pointer, length );
- }
- }
-
-
- FT_LOCAL_DEF( void )
- cff_free_glyph_data( TT_Face face,
- FT_Byte** pointer,
- FT_ULong length )
- {
-#ifndef FT_CONFIG_OPTION_INCREMENTAL
- FT_UNUSED( length );
-#endif
-
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- /* For incremental fonts get the character data using the */
- /* callback function. */
- if ( face->root.internal->incremental_interface )
- {
- FT_Data data;
-
-
- data.pointer = *pointer;
- data.length = (FT_UInt)length;
-
- face->root.internal->incremental_interface->funcs->free_glyph_data(
- face->root.internal->incremental_interface->object, &data );
- }
- else
-#endif /* FT_CONFIG_OPTION_INCREMENTAL */
-
- {
- CFF_Font cff = (CFF_Font)( face->extra.data );
-
-
- cff_index_forget_element( &cff->charstrings_index, pointer );
- }
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /********** *********/
- /********** *********/
- /********** COMPUTE THE MAXIMUM ADVANCE WIDTH *********/
- /********** *********/
- /********** The following code is in charge of computing *********/
- /********** the maximum advance width of the font. It *********/
- /********** quickly processes each glyph charstring to *********/
- /********** extract the value from either a `sbw' or `seac' *********/
- /********** operator. *********/
- /********** *********/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
-#if 0 /* unused until we support pure CFF fonts */
-
-
- FT_LOCAL_DEF( FT_Error )
- cff_compute_max_advance( TT_Face face,
- FT_Int* max_advance )
- {
- FT_Error error = FT_Err_Ok;
- CFF_Decoder decoder;
- FT_Int glyph_index;
- CFF_Font cff = (CFF_Font)face->other;
-
- PSAux_Service psaux = (PSAux_Service)face->psaux;
- const CFF_Decoder_Funcs decoder_funcs = psaux->cff_decoder_funcs;
-
-
- *max_advance = 0;
-
- /* Initialize load decoder */
- decoder_funcs->init( &decoder, face, 0, 0, 0, 0, 0, 0 );
-
- decoder.builder.metrics_only = 1;
- decoder.builder.load_points = 0;
-
- /* For each glyph, parse the glyph charstring and extract */
- /* the advance width. */
- for ( glyph_index = 0; glyph_index < face->root.num_glyphs;
- glyph_index++ )
- {
- FT_Byte* charstring;
- FT_ULong charstring_len;
-
-
- /* now get load the unscaled outline */
- error = cff_get_glyph_data( face, glyph_index,
- &charstring, &charstring_len );
- if ( !error )
- {
- error = decoder_funcs->prepare( &decoder, size, glyph_index );
- if ( !error )
- error = decoder_funcs->parse_charstrings_old( &decoder,
- charstring,
- charstring_len,
- 0 );
-
- cff_free_glyph_data( face, &charstring, &charstring_len );
- }
-
- /* ignore the error if one has occurred -- skip to next glyph */
- error = FT_Err_Ok;
- }
-
- *max_advance = decoder.builder.advance.x;
-
- return FT_Err_Ok;
- }
-
-
-#endif /* 0 */
-
-
- FT_LOCAL_DEF( FT_Error )
- cff_slot_load( CFF_GlyphSlot glyph,
- CFF_Size size,
- FT_UInt glyph_index,
- FT_Int32 load_flags )
- {
- FT_Error error;
- CFF_Decoder decoder;
- PS_Decoder psdecoder;
- TT_Face face = (TT_Face)glyph->root.face;
- FT_Bool hinting, scaled, force_scaling;
- CFF_Font cff = (CFF_Font)face->extra.data;
-
- PSAux_Service psaux = (PSAux_Service)face->psaux;
- const CFF_Decoder_Funcs decoder_funcs = psaux->cff_decoder_funcs;
-
- FT_Matrix font_matrix;
- FT_Vector font_offset;
-
-
- force_scaling = FALSE;
-
- /* in a CID-keyed font, consider `glyph_index' as a CID and map */
- /* it immediately to the real glyph_index -- if it isn't a */
- /* subsetted font, glyph_indices and CIDs are identical, though */
- if ( cff->top_font.font_dict.cid_registry != 0xFFFFU &&
- cff->charset.cids )
- {
- /* don't handle CID 0 (.notdef) which is directly mapped to GID 0 */
- if ( glyph_index != 0 )
- {
- glyph_index = cff_charset_cid_to_gindex( &cff->charset,
- glyph_index );
- if ( glyph_index == 0 )
- return FT_THROW( Invalid_Argument );
- }
- }
- else if ( glyph_index >= cff->num_glyphs )
- return FT_THROW( Invalid_Argument );
-
- if ( load_flags & FT_LOAD_NO_RECURSE )
- load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
-
- glyph->x_scale = 0x10000L;
- glyph->y_scale = 0x10000L;
- if ( size )
- {
- glyph->x_scale = size->root.metrics.x_scale;
- glyph->y_scale = size->root.metrics.y_scale;
- }
-
-#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
-
- /* try to load embedded bitmap if any */
- /* */
- /* XXX: The convention should be emphasized in */
- /* the documents because it can be confusing. */
- if ( size )
- {
- CFF_Face cff_face = (CFF_Face)size->root.face;
- SFNT_Service sfnt = (SFNT_Service)cff_face->sfnt;
- FT_Stream stream = cff_face->root.stream;
-
-
- if ( size->strike_index != 0xFFFFFFFFUL &&
- ( load_flags & FT_LOAD_NO_BITMAP ) == 0 &&
- IS_DEFAULT_INSTANCE( size->root.face ) )
- {
- TT_SBit_MetricsRec metrics;
-
-
- error = sfnt->load_sbit_image( face,
- size->strike_index,
- glyph_index,
- (FT_UInt)load_flags,
- stream,
- &glyph->root.bitmap,
- &metrics );
-
- if ( !error )
- {
- FT_Bool has_vertical_info;
- FT_UShort advance;
- FT_Short dummy;
-
-
- glyph->root.outline.n_points = 0;
- glyph->root.outline.n_contours = 0;
-
- glyph->root.metrics.width = (FT_Pos)metrics.width * 64;
- glyph->root.metrics.height = (FT_Pos)metrics.height * 64;
-
- glyph->root.metrics.horiBearingX = (FT_Pos)metrics.horiBearingX * 64;
- glyph->root.metrics.horiBearingY = (FT_Pos)metrics.horiBearingY * 64;
- glyph->root.metrics.horiAdvance = (FT_Pos)metrics.horiAdvance * 64;
-
- glyph->root.metrics.vertBearingX = (FT_Pos)metrics.vertBearingX * 64;
- glyph->root.metrics.vertBearingY = (FT_Pos)metrics.vertBearingY * 64;
- glyph->root.metrics.vertAdvance = (FT_Pos)metrics.vertAdvance * 64;
-
- glyph->root.format = FT_GLYPH_FORMAT_BITMAP;
-
- if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
- {
- glyph->root.bitmap_left = metrics.vertBearingX;
- glyph->root.bitmap_top = metrics.vertBearingY;
- }
- else
- {
- glyph->root.bitmap_left = metrics.horiBearingX;
- glyph->root.bitmap_top = metrics.horiBearingY;
- }
-
- /* compute linear advance widths */
-
- (void)( (SFNT_Service)face->sfnt )->get_metrics( face, 0,
- glyph_index,
- &dummy,
- &advance );
- glyph->root.linearHoriAdvance = advance;
-
- has_vertical_info = FT_BOOL(
- face->vertical_info &&
- face->vertical.number_Of_VMetrics > 0 );
-
- /* get the vertical metrics from the vmtx table if we have one */
- if ( has_vertical_info )
- {
- (void)( (SFNT_Service)face->sfnt )->get_metrics( face, 1,
- glyph_index,
- &dummy,
- &advance );
- glyph->root.linearVertAdvance = advance;
- }
- else
- {
- /* make up vertical ones */
- if ( face->os2.version != 0xFFFFU )
- glyph->root.linearVertAdvance = (FT_Pos)
- ( face->os2.sTypoAscender - face->os2.sTypoDescender );
- else
- glyph->root.linearVertAdvance = (FT_Pos)
- ( face->horizontal.Ascender - face->horizontal.Descender );
- }
-
- return error;
- }
- }
- }
-
-#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
-
- /* return immediately if we only want the embedded bitmaps */
- if ( load_flags & FT_LOAD_SBITS_ONLY )
- return FT_THROW( Invalid_Argument );
-
-#ifdef FT_CONFIG_OPTION_SVG
- /* check for OT-SVG */
- if ( ( load_flags & FT_LOAD_NO_SVG ) == 0 &&
- ( load_flags & FT_LOAD_COLOR ) &&
- face->svg )
- {
- /*
- * We load the SVG document and try to grab the advances from the
- * table. For the bearings we rely on the presetting hook to do that.
- */
-
- SFNT_Service sfnt = (SFNT_Service)face->sfnt;
-
-
- if ( size && (size->root.metrics.x_ppem < 1 ||
- size->root.metrics.y_ppem < 1 ) )
- {
- error = FT_THROW( Invalid_Size_Handle );
- return error;
- }
-
- FT_TRACE3(( "Trying to load SVG glyph\n" ));
-
- error = sfnt->load_svg_doc( (FT_GlyphSlot)glyph, glyph_index );
- if ( !error )
- {
- FT_Fixed x_scale = size->root.metrics.x_scale;
- FT_Fixed y_scale = size->root.metrics.y_scale;
-
- FT_Short dummy;
- FT_UShort advanceX;
- FT_UShort advanceY;
-
-
- FT_TRACE3(( "Successfully loaded SVG glyph\n" ));
-
- glyph->root.format = FT_GLYPH_FORMAT_SVG;
-
- /*
- * If horizontal or vertical advances are not present in the table,
- * this is a problem with the font since the standard requires them.
- * However, we are graceful and calculate the values by ourselves
- * for the vertical case.
- */
- sfnt->get_metrics( face,
- FALSE,
- glyph_index,
- &dummy,
- &advanceX );
- sfnt->get_metrics( face,
- TRUE,
- glyph_index,
- &dummy,
- &advanceY );
-
- glyph->root.linearHoriAdvance = advanceX;
- glyph->root.linearVertAdvance = advanceY;
-
- glyph->root.metrics.horiAdvance = FT_MulFix( advanceX, x_scale );
- glyph->root.metrics.vertAdvance = FT_MulFix( advanceY, y_scale );
-
- return error;
- }
-
- FT_TRACE3(( "Failed to load SVG glyph\n" ));
- }
-
-#endif /* FT_CONFIG_OPTION_SVG */
-
- /* if we have a CID subfont, use its matrix (which has already */
- /* been multiplied with the root matrix) */
-
- /* this scaling is only relevant if the PS hinter isn't active */
- if ( cff->num_subfonts )
- {
- FT_Long top_upm, sub_upm;
- FT_Byte fd_index = cff_fd_select_get( &cff->fd_select,
- glyph_index );
-
-
- if ( fd_index >= cff->num_subfonts )
- fd_index = (FT_Byte)( cff->num_subfonts - 1 );
-
- top_upm = (FT_Long)cff->top_font.font_dict.units_per_em;
- sub_upm = (FT_Long)cff->subfonts[fd_index]->font_dict.units_per_em;
-
- font_matrix = cff->subfonts[fd_index]->font_dict.font_matrix;
- font_offset = cff->subfonts[fd_index]->font_dict.font_offset;
-
- if ( top_upm != sub_upm )
- {
- glyph->x_scale = FT_MulDiv( glyph->x_scale, top_upm, sub_upm );
- glyph->y_scale = FT_MulDiv( glyph->y_scale, top_upm, sub_upm );
-
- force_scaling = TRUE;
- }
- }
- else
- {
- font_matrix = cff->top_font.font_dict.font_matrix;
- font_offset = cff->top_font.font_dict.font_offset;
- }
-
- glyph->root.outline.n_points = 0;
- glyph->root.outline.n_contours = 0;
-
- /* top-level code ensures that FT_LOAD_NO_HINTING is set */
- /* if FT_LOAD_NO_SCALE is active */
- hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_HINTING ) == 0 );
- scaled = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 );
-
- glyph->hint = hinting;
- glyph->scaled = scaled;
- glyph->root.format = FT_GLYPH_FORMAT_OUTLINE; /* by default */
-
- {
-#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
- PS_Driver driver = (PS_Driver)FT_FACE_DRIVER( face );
-#endif
-
- FT_Byte* charstring;
- FT_ULong charstring_len;
-
-
- decoder_funcs->init( &decoder, face, size, glyph, hinting,
- FT_LOAD_TARGET_MODE( load_flags ),
- cff_get_glyph_data,
- cff_free_glyph_data );
-
- /* this is for pure CFFs */
- if ( load_flags & FT_LOAD_ADVANCE_ONLY )
- decoder.width_only = TRUE;
-
- decoder.builder.no_recurse =
- FT_BOOL( load_flags & FT_LOAD_NO_RECURSE );
-
- /* this function also checks for a valid subfont index */
- error = decoder_funcs->prepare( &decoder, size, glyph_index );
- if ( error )
- goto Glyph_Build_Finished;
-
- /* now load the unscaled outline */
- error = cff_get_glyph_data( face, glyph_index,
- &charstring, &charstring_len );
- if ( error )
- goto Glyph_Build_Finished;
-
-#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
- /* choose which CFF renderer to use */
- if ( driver->hinting_engine == FT_HINTING_FREETYPE )
- error = decoder_funcs->parse_charstrings_old( &decoder,
- charstring,
- charstring_len,
- 0 );
- else
-#endif
- {
- psaux->ps_decoder_init( &psdecoder, &decoder, FALSE );
-
- error = decoder_funcs->parse_charstrings( &psdecoder,
- charstring,
- charstring_len );
-
- /* Adobe's engine uses 16.16 numbers everywhere; */
- /* as a consequence, glyphs larger than 2000ppem get rejected */
- if ( FT_ERR_EQ( error, Glyph_Too_Big ) )
- {
- /* this time, we retry unhinted and scale up the glyph later on */
- /* (the engine uses and sets the hardcoded value 0x10000 / 64 = */
- /* 0x400 for both `x_scale' and `y_scale' in this case) */
- hinting = FALSE;
- force_scaling = TRUE;
- glyph->hint = hinting;
-
- error = decoder_funcs->parse_charstrings( &psdecoder,
- charstring,
- charstring_len );
- }
- }
-
- cff_free_glyph_data( face, &charstring, charstring_len );
-
- if ( error )
- goto Glyph_Build_Finished;
-
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- /* Control data and length may not be available for incremental */
- /* fonts. */
- if ( face->root.internal->incremental_interface )
- {
- glyph->root.control_data = NULL;
- glyph->root.control_len = 0;
- }
- else
-#endif /* FT_CONFIG_OPTION_INCREMENTAL */
-
- /* We set control_data and control_len if charstrings is loaded. */
- /* See how charstring loads at cff_index_access_element() in */
- /* cffload.c. */
- {
- CFF_Index csindex = &cff->charstrings_index;
-
-
- if ( csindex->offsets )
- {
- glyph->root.control_data = csindex->bytes +
- csindex->offsets[glyph_index] - 1;
- glyph->root.control_len = (FT_Long)charstring_len;
- }
- }
-
- Glyph_Build_Finished:
- /* save new glyph tables, if no error */
- if ( !error )
- decoder.builder.funcs.done( &decoder.builder );
- /* XXX: anything to do for broken glyph entry? */
- }
-
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
-
- /* Incremental fonts can optionally override the metrics. */
- if ( !error &&
- face->root.internal->incremental_interface &&
- face->root.internal->incremental_interface->funcs->get_glyph_metrics )
- {
- FT_Incremental_MetricsRec metrics;
-
-
- metrics.bearing_x = decoder.builder.left_bearing.x;
- metrics.bearing_y = 0;
- metrics.advance = decoder.builder.advance.x;
- metrics.advance_v = decoder.builder.advance.y;
-
- error = face->root.internal->incremental_interface->funcs->get_glyph_metrics(
- face->root.internal->incremental_interface->object,
- glyph_index, FALSE, &metrics );
-
- decoder.builder.left_bearing.x = metrics.bearing_x;
- decoder.builder.advance.x = metrics.advance;
- decoder.builder.advance.y = metrics.advance_v;
- }
-
-#endif /* FT_CONFIG_OPTION_INCREMENTAL */
-
- if ( !error )
- {
- /* Now, set the metrics -- this is rather simple, as */
- /* the left side bearing is the xMin, and the top side */
- /* bearing the yMax. */
-
- /* For composite glyphs, return only left side bearing and */
- /* advance width. */
- if ( load_flags & FT_LOAD_NO_RECURSE )
- {
- FT_Slot_Internal internal = glyph->root.internal;
-
-
- glyph->root.metrics.horiBearingX = decoder.builder.left_bearing.x;
- glyph->root.metrics.horiAdvance = decoder.glyph_width;
- internal->glyph_matrix = font_matrix;
- internal->glyph_delta = font_offset;
- internal->glyph_transformed = 1;
- }
- else
- {
- FT_BBox cbox;
- FT_Glyph_Metrics* metrics = &glyph->root.metrics;
- FT_Bool has_vertical_info;
-
-
- if ( face->horizontal.number_Of_HMetrics )
- {
- FT_Short horiBearingX = 0;
- FT_UShort horiAdvance = 0;
-
-
- ( (SFNT_Service)face->sfnt )->get_metrics( face, 0,
- glyph_index,
- &horiBearingX,
- &horiAdvance );
- metrics->horiAdvance = horiAdvance;
- metrics->horiBearingX = horiBearingX;
- glyph->root.linearHoriAdvance = horiAdvance;
- }
- else
- {
- /* copy the _unscaled_ advance width */
- metrics->horiAdvance = decoder.glyph_width;
- glyph->root.linearHoriAdvance = decoder.glyph_width;
- }
-
- glyph->root.internal->glyph_transformed = 0;
-
- has_vertical_info = FT_BOOL( face->vertical_info &&
- face->vertical.number_Of_VMetrics > 0 );
-
- /* get the vertical metrics from the vmtx table if we have one */
- if ( has_vertical_info )
- {
- FT_Short vertBearingY = 0;
- FT_UShort vertAdvance = 0;
-
-
- ( (SFNT_Service)face->sfnt )->get_metrics( face, 1,
- glyph_index,
- &vertBearingY,
- &vertAdvance );
- metrics->vertBearingY = vertBearingY;
- metrics->vertAdvance = vertAdvance;
- }
- else
- {
- /* make up vertical ones */
- if ( face->os2.version != 0xFFFFU )
- metrics->vertAdvance = (FT_Pos)( face->os2.sTypoAscender -
- face->os2.sTypoDescender );
- else
- metrics->vertAdvance = (FT_Pos)( face->horizontal.Ascender -
- face->horizontal.Descender );
- }
-
- glyph->root.linearVertAdvance = metrics->vertAdvance;
-
- glyph->root.format = FT_GLYPH_FORMAT_OUTLINE;
-
- glyph->root.outline.flags = 0;
- if ( size && size->root.metrics.y_ppem < 24 )
- glyph->root.outline.flags |= FT_OUTLINE_HIGH_PRECISION;
-
- glyph->root.outline.flags |= FT_OUTLINE_REVERSE_FILL;
-
- /* apply the font matrix, if any */
- if ( font_matrix.xx != 0x10000L || font_matrix.yy != 0x10000L ||
- font_matrix.xy != 0 || font_matrix.yx != 0 )
- {
- FT_Outline_Transform( &glyph->root.outline, &font_matrix );
-
- metrics->horiAdvance = FT_MulFix( metrics->horiAdvance,
- font_matrix.xx );
- metrics->vertAdvance = FT_MulFix( metrics->vertAdvance,
- font_matrix.yy );
- }
-
- if ( font_offset.x || font_offset.y )
- {
- FT_Outline_Translate( &glyph->root.outline,
- font_offset.x,
- font_offset.y );
-
- metrics->horiAdvance += font_offset.x;
- metrics->vertAdvance += font_offset.y;
- }
-
- if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 || force_scaling )
- {
- /* scale the outline and the metrics */
- FT_Int n;
- FT_Outline* cur = &glyph->root.outline;
- FT_Vector* vec = cur->points;
- FT_Fixed x_scale = glyph->x_scale;
- FT_Fixed y_scale = glyph->y_scale;
-
-
- /* First of all, scale the points */
- if ( !hinting || !decoder.builder.hints_funcs )
- for ( n = cur->n_points; n > 0; n--, vec++ )
- {
- vec->x = FT_MulFix( vec->x, x_scale );
- vec->y = FT_MulFix( vec->y, y_scale );
- }
-
- /* Then scale the metrics */
- metrics->horiAdvance = FT_MulFix( metrics->horiAdvance, x_scale );
- metrics->vertAdvance = FT_MulFix( metrics->vertAdvance, y_scale );
- }
-
- /* compute the other metrics */
- FT_Outline_Get_CBox( &glyph->root.outline, &cbox );
-
- metrics->width = cbox.xMax - cbox.xMin;
- metrics->height = cbox.yMax - cbox.yMin;
-
- metrics->horiBearingX = cbox.xMin;
- metrics->horiBearingY = cbox.yMax;
-
- if ( has_vertical_info )
- {
- metrics->vertBearingX = metrics->horiBearingX -
- metrics->horiAdvance / 2;
- metrics->vertBearingY = FT_MulFix( metrics->vertBearingY,
- glyph->y_scale );
- }
- else
- {
- if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
- ft_synthesize_vertical_metrics( metrics,
- metrics->vertAdvance );
- }
- }
- }
-
- return error;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cff/cffgload.h b/contrib/libs/freetype/src/cff/cffgload.h
deleted file mode 100644
index 346d4b11c3..0000000000
--- a/contrib/libs/freetype/src/cff/cffgload.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/****************************************************************************
- *
- * cffgload.h
- *
- * OpenType Glyph Loader (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef CFFGLOAD_H_
-#define CFFGLOAD_H_
-
-
-#include <freetype/freetype.h>
-#include <freetype/internal/cffotypes.h>
-
-
-FT_BEGIN_HEADER
-
- FT_LOCAL( FT_Error )
- cff_get_glyph_data( TT_Face face,
- FT_UInt glyph_index,
- FT_Byte** pointer,
- FT_ULong* length );
- FT_LOCAL( void )
- cff_free_glyph_data( TT_Face face,
- FT_Byte** pointer,
- FT_ULong length );
-
-
-#if 0 /* unused until we support pure CFF fonts */
-
- /* Compute the maximum advance width of a font through quick parsing */
- FT_LOCAL( FT_Error )
- cff_compute_max_advance( TT_Face face,
- FT_Int* max_advance );
-
-#endif /* 0 */
-
-
- FT_LOCAL( FT_Error )
- cff_slot_load( CFF_GlyphSlot glyph,
- CFF_Size size,
- FT_UInt glyph_index,
- FT_Int32 load_flags );
-
-
-FT_END_HEADER
-
-#endif /* CFFGLOAD_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cff/cffload.c b/contrib/libs/freetype/src/cff/cffload.c
deleted file mode 100644
index 979fd45f6c..0000000000
--- a/contrib/libs/freetype/src/cff/cffload.c
+++ /dev/null
@@ -1,2570 +0,0 @@
-/****************************************************************************
- *
- * cffload.c
- *
- * OpenType and CFF data/program tables loader (body).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/tttags.h>
-#include <freetype/t1tables.h>
-#include <freetype/internal/psaux.h>
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
-#include <freetype/ftmm.h>
-#include <freetype/internal/services/svmm.h>
-#endif
-
-#include "cffload.h"
-#include "cffparse.h"
-
-#include "cfferrs.h"
-
-
-#define FT_FIXED_ONE ( (FT_Fixed)0x10000 )
-
-
-#if 1
-
- static const FT_UShort cff_isoadobe_charset[229] =
- {
- 0, 1, 2, 3, 4, 5, 6, 7,
- 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23,
- 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39,
- 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 55,
- 56, 57, 58, 59, 60, 61, 62, 63,
- 64, 65, 66, 67, 68, 69, 70, 71,
- 72, 73, 74, 75, 76, 77, 78, 79,
- 80, 81, 82, 83, 84, 85, 86, 87,
- 88, 89, 90, 91, 92, 93, 94, 95,
- 96, 97, 98, 99, 100, 101, 102, 103,
- 104, 105, 106, 107, 108, 109, 110, 111,
- 112, 113, 114, 115, 116, 117, 118, 119,
- 120, 121, 122, 123, 124, 125, 126, 127,
- 128, 129, 130, 131, 132, 133, 134, 135,
- 136, 137, 138, 139, 140, 141, 142, 143,
- 144, 145, 146, 147, 148, 149, 150, 151,
- 152, 153, 154, 155, 156, 157, 158, 159,
- 160, 161, 162, 163, 164, 165, 166, 167,
- 168, 169, 170, 171, 172, 173, 174, 175,
- 176, 177, 178, 179, 180, 181, 182, 183,
- 184, 185, 186, 187, 188, 189, 190, 191,
- 192, 193, 194, 195, 196, 197, 198, 199,
- 200, 201, 202, 203, 204, 205, 206, 207,
- 208, 209, 210, 211, 212, 213, 214, 215,
- 216, 217, 218, 219, 220, 221, 222, 223,
- 224, 225, 226, 227, 228
- };
-
- static const FT_UShort cff_expert_charset[166] =
- {
- 0, 1, 229, 230, 231, 232, 233, 234,
- 235, 236, 237, 238, 13, 14, 15, 99,
- 239, 240, 241, 242, 243, 244, 245, 246,
- 247, 248, 27, 28, 249, 250, 251, 252,
- 253, 254, 255, 256, 257, 258, 259, 260,
- 261, 262, 263, 264, 265, 266, 109, 110,
- 267, 268, 269, 270, 271, 272, 273, 274,
- 275, 276, 277, 278, 279, 280, 281, 282,
- 283, 284, 285, 286, 287, 288, 289, 290,
- 291, 292, 293, 294, 295, 296, 297, 298,
- 299, 300, 301, 302, 303, 304, 305, 306,
- 307, 308, 309, 310, 311, 312, 313, 314,
- 315, 316, 317, 318, 158, 155, 163, 319,
- 320, 321, 322, 323, 324, 325, 326, 150,
- 164, 169, 327, 328, 329, 330, 331, 332,
- 333, 334, 335, 336, 337, 338, 339, 340,
- 341, 342, 343, 344, 345, 346, 347, 348,
- 349, 350, 351, 352, 353, 354, 355, 356,
- 357, 358, 359, 360, 361, 362, 363, 364,
- 365, 366, 367, 368, 369, 370, 371, 372,
- 373, 374, 375, 376, 377, 378
- };
-
- static const FT_UShort cff_expertsubset_charset[87] =
- {
- 0, 1, 231, 232, 235, 236, 237, 238,
- 13, 14, 15, 99, 239, 240, 241, 242,
- 243, 244, 245, 246, 247, 248, 27, 28,
- 249, 250, 251, 253, 254, 255, 256, 257,
- 258, 259, 260, 261, 262, 263, 264, 265,
- 266, 109, 110, 267, 268, 269, 270, 272,
- 300, 301, 302, 305, 314, 315, 158, 155,
- 163, 320, 321, 322, 323, 324, 325, 326,
- 150, 164, 169, 327, 328, 329, 330, 331,
- 332, 333, 334, 335, 336, 337, 338, 339,
- 340, 341, 342, 343, 344, 345, 346
- };
-
- static const FT_UShort cff_standard_encoding[256] =
- {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 1, 2, 3, 4, 5, 6, 7, 8,
- 9, 10, 11, 12, 13, 14, 15, 16,
- 17, 18, 19, 20, 21, 22, 23, 24,
- 25, 26, 27, 28, 29, 30, 31, 32,
- 33, 34, 35, 36, 37, 38, 39, 40,
- 41, 42, 43, 44, 45, 46, 47, 48,
- 49, 50, 51, 52, 53, 54, 55, 56,
- 57, 58, 59, 60, 61, 62, 63, 64,
- 65, 66, 67, 68, 69, 70, 71, 72,
- 73, 74, 75, 76, 77, 78, 79, 80,
- 81, 82, 83, 84, 85, 86, 87, 88,
- 89, 90, 91, 92, 93, 94, 95, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 96, 97, 98, 99, 100, 101, 102,
- 103, 104, 105, 106, 107, 108, 109, 110,
- 0, 111, 112, 113, 114, 0, 115, 116,
- 117, 118, 119, 120, 121, 122, 0, 123,
- 0, 124, 125, 126, 127, 128, 129, 130,
- 131, 0, 132, 133, 0, 134, 135, 136,
- 137, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 138, 0, 139, 0, 0, 0, 0,
- 140, 141, 142, 143, 0, 0, 0, 0,
- 0, 144, 0, 0, 0, 145, 0, 0,
- 146, 147, 148, 149, 0, 0, 0, 0
- };
-
- static const FT_UShort cff_expert_encoding[256] =
- {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 1, 229, 230, 0, 231, 232, 233, 234,
- 235, 236, 237, 238, 13, 14, 15, 99,
- 239, 240, 241, 242, 243, 244, 245, 246,
- 247, 248, 27, 28, 249, 250, 251, 252,
- 0, 253, 254, 255, 256, 257, 0, 0,
- 0, 258, 0, 0, 259, 260, 261, 262,
- 0, 0, 263, 264, 265, 0, 266, 109,
- 110, 267, 268, 269, 0, 270, 271, 272,
- 273, 274, 275, 276, 277, 278, 279, 280,
- 281, 282, 283, 284, 285, 286, 287, 288,
- 289, 290, 291, 292, 293, 294, 295, 296,
- 297, 298, 299, 300, 301, 302, 303, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 304, 305, 306, 0, 0, 307, 308,
- 309, 310, 311, 0, 312, 0, 0, 312,
- 0, 0, 314, 315, 0, 0, 316, 317,
- 318, 0, 0, 0, 158, 155, 163, 319,
- 320, 321, 322, 323, 324, 325, 0, 0,
- 326, 150, 164, 169, 327, 328, 329, 330,
- 331, 332, 333, 334, 335, 336, 337, 338,
- 339, 340, 341, 342, 343, 344, 345, 346,
- 347, 348, 349, 350, 351, 352, 353, 354,
- 355, 356, 357, 358, 359, 360, 361, 362,
- 363, 364, 365, 366, 367, 368, 369, 370,
- 371, 372, 373, 374, 375, 376, 377, 378
- };
-
-#endif /* 1 */
-
-
- FT_LOCAL_DEF( FT_UShort )
- cff_get_standard_encoding( FT_UInt charcode )
- {
- return (FT_UShort)( charcode < 256 ? cff_standard_encoding[charcode]
- : 0 );
- }
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT cffload
-
-
- /* read an offset from the index's stream current position */
- static FT_ULong
- cff_index_read_offset( CFF_Index idx,
- FT_Error *errorp )
- {
- FT_Error error;
- FT_Stream stream = idx->stream;
- FT_Byte tmp[4];
- FT_ULong result = 0;
-
-
- if ( !FT_STREAM_READ( tmp, idx->off_size ) )
- {
- FT_Int nn;
-
-
- for ( nn = 0; nn < idx->off_size; nn++ )
- result = ( result << 8 ) | tmp[nn];
- }
-
- *errorp = error;
- return result;
- }
-
-
- static FT_Error
- cff_index_init( CFF_Index idx,
- FT_Stream stream,
- FT_Bool load,
- FT_Bool cff2 )
- {
- FT_Error error;
- FT_Memory memory = stream->memory;
- FT_UInt count;
-
-
- FT_ZERO( idx );
-
- idx->stream = stream;
- idx->start = FT_STREAM_POS();
-
- if ( cff2 )
- {
- if ( FT_READ_ULONG( count ) )
- goto Exit;
- idx->hdr_size = 5;
- }
- else
- {
- if ( FT_READ_USHORT( count ) )
- goto Exit;
- idx->hdr_size = 3;
- }
-
- if ( count > 0 )
- {
- FT_Byte offsize;
- FT_ULong size;
-
-
- /* there is at least one element; read the offset size, */
- /* then access the offset table to compute the index's total size */
- if ( FT_READ_BYTE( offsize ) )
- goto Exit;
-
- if ( offsize < 1 || offsize > 4 )
- {
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- idx->count = count;
- idx->off_size = offsize;
- size = (FT_ULong)( count + 1 ) * offsize;
-
- idx->data_offset = idx->start + idx->hdr_size + size;
-
- if ( FT_STREAM_SKIP( size - offsize ) )
- goto Exit;
-
- size = cff_index_read_offset( idx, &error );
- if ( error )
- goto Exit;
-
- if ( size == 0 )
- {
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- idx->data_size = --size;
-
- if ( load )
- {
- /* load the data */
- if ( FT_FRAME_EXTRACT( size, idx->bytes ) )
- goto Exit;
- }
- else
- {
- /* skip the data */
- if ( FT_STREAM_SKIP( size ) )
- goto Exit;
- }
- }
-
- Exit:
- if ( error )
- FT_FREE( idx->offsets );
-
- return error;
- }
-
-
- static void
- cff_index_done( CFF_Index idx )
- {
- if ( idx->stream )
- {
- FT_Stream stream = idx->stream;
- FT_Memory memory = stream->memory;
-
-
- if ( idx->bytes )
- FT_FRAME_RELEASE( idx->bytes );
-
- FT_FREE( idx->offsets );
- FT_ZERO( idx );
- }
- }
-
-
- static FT_Error
- cff_index_load_offsets( CFF_Index idx )
- {
- FT_Error error = FT_Err_Ok;
- FT_Stream stream = idx->stream;
- FT_Memory memory = stream->memory;
-
-
- if ( idx->count > 0 && !idx->offsets )
- {
- FT_Byte offsize = idx->off_size;
- FT_ULong data_size;
- FT_Byte* p;
- FT_Byte* p_end;
- FT_ULong* poff;
-
-
- data_size = (FT_ULong)( idx->count + 1 ) * offsize;
-
- if ( FT_QNEW_ARRAY( idx->offsets, idx->count + 1 ) ||
- FT_STREAM_SEEK( idx->start + idx->hdr_size ) ||
- FT_FRAME_ENTER( data_size ) )
- goto Exit;
-
- poff = idx->offsets;
- p = (FT_Byte*)stream->cursor;
- p_end = p + data_size;
-
- switch ( offsize )
- {
- case 1:
- for ( ; p < p_end; p++, poff++ )
- poff[0] = p[0];
- break;
-
- case 2:
- for ( ; p < p_end; p += 2, poff++ )
- poff[0] = FT_PEEK_USHORT( p );
- break;
-
- case 3:
- for ( ; p < p_end; p += 3, poff++ )
- poff[0] = FT_PEEK_UOFF3( p );
- break;
-
- default:
- for ( ; p < p_end; p += 4, poff++ )
- poff[0] = FT_PEEK_ULONG( p );
- }
-
- FT_FRAME_EXIT();
- }
-
- Exit:
- if ( error )
- FT_FREE( idx->offsets );
-
- return error;
- }
-
-
- /* Allocate a table containing pointers to an index's elements. */
- /* The `pool' argument makes this function convert the index */
- /* entries to C-style strings (that is, null-terminated). */
- static FT_Error
- cff_index_get_pointers( CFF_Index idx,
- FT_Byte*** table,
- FT_Byte** pool,
- FT_ULong* pool_size )
- {
- FT_Error error = FT_Err_Ok;
- FT_Memory memory = idx->stream->memory;
-
- FT_Byte** tbl = NULL;
- FT_Byte* new_bytes = NULL;
- FT_ULong new_size;
-
-
- *table = NULL;
-
- if ( !idx->offsets )
- {
- error = cff_index_load_offsets( idx );
- if ( error )
- goto Exit;
- }
-
- new_size = idx->data_size + idx->count;
-
- if ( idx->count > 0 &&
- !FT_QNEW_ARRAY( tbl, idx->count + 1 ) &&
- ( !pool || !FT_ALLOC( new_bytes, new_size ) ) )
- {
- FT_ULong n, cur_offset;
- FT_ULong extra = 0;
- FT_Byte* org_bytes = idx->bytes;
-
-
- /* at this point, `idx->offsets' can't be NULL */
- cur_offset = idx->offsets[0] - 1;
-
- /* sanity check */
- if ( cur_offset != 0 )
- {
- FT_TRACE0(( "cff_index_get_pointers:"
- " invalid first offset value %ld set to zero\n",
- cur_offset ));
- cur_offset = 0;
- }
-
- if ( !pool )
- tbl[0] = org_bytes + cur_offset;
- else
- tbl[0] = new_bytes + cur_offset;
-
- for ( n = 1; n <= idx->count; n++ )
- {
- FT_ULong next_offset = idx->offsets[n] - 1;
-
-
- /* two sanity checks for invalid offset tables */
- if ( next_offset < cur_offset )
- next_offset = cur_offset;
- else if ( next_offset > idx->data_size )
- next_offset = idx->data_size;
-
- if ( !pool )
- tbl[n] = org_bytes + next_offset;
- else
- {
- tbl[n] = new_bytes + next_offset + extra;
-
- if ( next_offset != cur_offset )
- {
- FT_MEM_COPY( tbl[n - 1],
- org_bytes + cur_offset,
- tbl[n] - tbl[n - 1] );
- tbl[n][0] = '\0';
- tbl[n] += 1;
- extra++;
- }
- }
-
- cur_offset = next_offset;
- }
- *table = tbl;
-
- if ( pool )
- *pool = new_bytes;
- if ( pool_size )
- *pool_size = new_size;
- }
-
- Exit:
- if ( error && new_bytes )
- FT_FREE( new_bytes );
- if ( error && tbl )
- FT_FREE( tbl );
-
- return error;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- cff_index_access_element( CFF_Index idx,
- FT_UInt element,
- FT_Byte** pbytes,
- FT_ULong* pbyte_len )
- {
- FT_Error error = FT_Err_Ok;
-
-
- if ( idx && idx->count > element )
- {
- /* compute start and end offsets */
- FT_Stream stream = idx->stream;
- FT_ULong off1, off2 = 0;
-
-
- /* load offsets from file or the offset table */
- if ( !idx->offsets )
- {
- FT_ULong pos = element * idx->off_size;
-
-
- if ( FT_STREAM_SEEK( idx->start + idx->hdr_size + pos ) )
- goto Exit;
-
- off1 = cff_index_read_offset( idx, &error );
- if ( error )
- goto Exit;
-
- if ( off1 != 0 )
- {
- do
- {
- element++;
- off2 = cff_index_read_offset( idx, &error );
-
- } while ( off2 == 0 && element < idx->count );
- }
- }
- else /* use offsets table */
- {
- off1 = idx->offsets[element];
- if ( off1 )
- {
- do
- {
- element++;
- off2 = idx->offsets[element];
-
- } while ( off2 == 0 && element < idx->count );
- }
- }
-
- /* XXX: should check off2 does not exceed the end of this entry; */
- /* at present, only truncate off2 at the end of this stream */
- if ( off2 > stream->size + 1 ||
- idx->data_offset > stream->size - off2 + 1 )
- {
- FT_ERROR(( "cff_index_access_element:"
- " offset to next entry (%ld)"
- " exceeds the end of stream (%ld)\n",
- off2, stream->size - idx->data_offset + 1 ));
- off2 = stream->size - idx->data_offset + 1;
- }
-
- /* access element */
- if ( off1 && off2 > off1 )
- {
- *pbyte_len = off2 - off1;
-
- if ( idx->bytes )
- {
- /* this index was completely loaded in memory, that's easy */
- *pbytes = idx->bytes + off1 - 1;
- }
- else
- {
- /* this index is still on disk/file, access it through a frame */
- if ( FT_STREAM_SEEK( idx->data_offset + off1 - 1 ) ||
- FT_FRAME_EXTRACT( off2 - off1, *pbytes ) )
- goto Exit;
- }
- }
- else
- {
- /* empty index element */
- *pbytes = 0;
- *pbyte_len = 0;
- }
- }
- else
- error = FT_THROW( Invalid_Argument );
-
- Exit:
- return error;
- }
-
-
- FT_LOCAL_DEF( void )
- cff_index_forget_element( CFF_Index idx,
- FT_Byte** pbytes )
- {
- if ( idx->bytes == 0 )
- {
- FT_Stream stream = idx->stream;
-
-
- FT_FRAME_RELEASE( *pbytes );
- }
- }
-
-
- /* get an entry from Name INDEX */
- FT_LOCAL_DEF( FT_String* )
- cff_index_get_name( CFF_Font font,
- FT_UInt element )
- {
- CFF_Index idx = &font->name_index;
- FT_Memory memory;
- FT_Byte* bytes;
- FT_ULong byte_len;
- FT_Error error;
- FT_String* name = NULL;
-
-
- if ( !idx->stream ) /* CFF2 does not include a name index */
- goto Exit;
-
- memory = idx->stream->memory;
-
- error = cff_index_access_element( idx, element, &bytes, &byte_len );
- if ( error )
- goto Exit;
-
- if ( !FT_QALLOC( name, byte_len + 1 ) )
- {
- FT_MEM_COPY( name, bytes, byte_len );
- name[byte_len] = 0;
- }
- cff_index_forget_element( idx, &bytes );
-
- Exit:
- return name;
- }
-
-
- /* get an entry from String INDEX */
- FT_LOCAL_DEF( FT_String* )
- cff_index_get_string( CFF_Font font,
- FT_UInt element )
- {
- return ( element < font->num_strings )
- ? (FT_String*)font->strings[element]
- : NULL;
- }
-
-
- FT_LOCAL_DEF( FT_String* )
- cff_index_get_sid_string( CFF_Font font,
- FT_UInt sid )
- {
- /* value 0xFFFFU indicates a missing dictionary entry */
- if ( sid == 0xFFFFU )
- return NULL;
-
- /* if it is not a standard string, return it */
- if ( sid > 390 )
- return cff_index_get_string( font, sid - 391 );
-
- /* CID-keyed CFF fonts don't have glyph names */
- if ( !font->psnames )
- return NULL;
-
- /* this is a standard string */
- return (FT_String *)font->psnames->adobe_std_strings( sid );
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*** ***/
- /*** FD Select table support ***/
- /*** ***/
- /*************************************************************************/
- /*************************************************************************/
-
-
- static void
- CFF_Done_FD_Select( CFF_FDSelect fdselect,
- FT_Stream stream )
- {
- if ( fdselect->data )
- FT_FRAME_RELEASE( fdselect->data );
-
- fdselect->data_size = 0;
- fdselect->format = 0;
- fdselect->range_count = 0;
- }
-
-
- static FT_Error
- CFF_Load_FD_Select( CFF_FDSelect fdselect,
- FT_UInt num_glyphs,
- FT_Stream stream,
- FT_ULong offset )
- {
- FT_Error error;
- FT_Byte format;
- FT_UInt num_ranges;
-
-
- /* read format */
- if ( FT_STREAM_SEEK( offset ) || FT_READ_BYTE( format ) )
- goto Exit;
-
- fdselect->format = format;
- fdselect->cache_count = 0; /* clear cache */
-
- switch ( format )
- {
- case 0: /* format 0, that's simple */
- fdselect->data_size = num_glyphs;
- goto Load_Data;
-
- case 3: /* format 3, a tad more complex */
- if ( FT_READ_USHORT( num_ranges ) )
- goto Exit;
-
- if ( !num_ranges )
- {
- FT_TRACE0(( "CFF_Load_FD_Select: empty FDSelect array\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- fdselect->data_size = num_ranges * 3 + 2;
-
- Load_Data:
- if ( FT_FRAME_EXTRACT( fdselect->data_size, fdselect->data ) )
- goto Exit;
- break;
-
- default: /* hmm... that's wrong */
- error = FT_THROW( Invalid_File_Format );
- }
-
- Exit:
- return error;
- }
-
-
- FT_LOCAL_DEF( FT_Byte )
- cff_fd_select_get( CFF_FDSelect fdselect,
- FT_UInt glyph_index )
- {
- FT_Byte fd = 0;
-
-
- /* if there is no FDSelect, return zero */
- /* Note: CFF2 with just one Font Dict has no FDSelect */
- if ( !fdselect->data )
- goto Exit;
-
- switch ( fdselect->format )
- {
- case 0:
- fd = fdselect->data[glyph_index];
- break;
-
- case 3:
- /* first, compare to the cache */
- if ( glyph_index - fdselect->cache_first < fdselect->cache_count )
- {
- fd = fdselect->cache_fd;
- break;
- }
-
- /* then, look up the ranges array */
- {
- FT_Byte* p = fdselect->data;
- FT_Byte* p_limit = p + fdselect->data_size;
- FT_Byte fd2;
- FT_UInt first, limit;
-
-
- first = FT_NEXT_USHORT( p );
- do
- {
- if ( glyph_index < first )
- break;
-
- fd2 = *p++;
- limit = FT_NEXT_USHORT( p );
-
- if ( glyph_index < limit )
- {
- fd = fd2;
-
- /* update cache */
- fdselect->cache_first = first;
- fdselect->cache_count = limit - first;
- fdselect->cache_fd = fd2;
- break;
- }
- first = limit;
-
- } while ( p < p_limit );
- }
- break;
-
- default:
- ;
- }
-
- Exit:
- return fd;
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*** ***/
- /*** CFF font support ***/
- /*** ***/
- /*************************************************************************/
- /*************************************************************************/
-
- static FT_Error
- cff_charset_compute_cids( CFF_Charset charset,
- FT_UInt num_glyphs,
- FT_Memory memory )
- {
- FT_Error error = FT_Err_Ok;
- FT_UInt i;
- FT_UShort max_cid = 0;
-
-
- if ( charset->max_cid > 0 )
- goto Exit;
-
- for ( i = 0; i < num_glyphs; i++ )
- {
- if ( charset->sids[i] > max_cid )
- max_cid = charset->sids[i];
- }
-
- if ( FT_NEW_ARRAY( charset->cids, (FT_ULong)max_cid + 1 ) )
- goto Exit;
-
- /* When multiple GIDs map to the same CID, we choose the lowest */
- /* GID. This is not described in any spec, but it matches the */
- /* behaviour of recent Acroread versions. The loop stops when */
- /* the unsigned index wraps around after reaching zero. */
- for ( i = num_glyphs - 1; i < num_glyphs; i-- )
- charset->cids[charset->sids[i]] = (FT_UShort)i;
-
- charset->max_cid = max_cid;
- charset->num_glyphs = num_glyphs;
-
- Exit:
- return error;
- }
-
-
- FT_LOCAL_DEF( FT_UInt )
- cff_charset_cid_to_gindex( CFF_Charset charset,
- FT_UInt cid )
- {
- FT_UInt result = 0;
-
-
- if ( cid <= charset->max_cid )
- result = charset->cids[cid];
-
- return result;
- }
-
-
- static void
- cff_charset_free_cids( CFF_Charset charset,
- FT_Memory memory )
- {
- FT_FREE( charset->cids );
- charset->max_cid = 0;
- }
-
-
- static void
- cff_charset_done( CFF_Charset charset,
- FT_Stream stream )
- {
- FT_Memory memory = stream->memory;
-
-
- cff_charset_free_cids( charset, memory );
-
- FT_FREE( charset->sids );
- charset->format = 0;
- charset->offset = 0;
- }
-
-
- static FT_Error
- cff_charset_load( CFF_Charset charset,
- FT_UInt num_glyphs,
- FT_Stream stream,
- FT_ULong base_offset,
- FT_ULong offset,
- FT_Bool invert )
- {
- FT_Memory memory = stream->memory;
- FT_Error error = FT_Err_Ok;
- FT_UShort glyph_sid;
-
-
- /* If the offset is greater than 2, we have to parse the charset */
- /* table. */
- if ( offset > 2 )
- {
- FT_UInt j;
-
-
- charset->offset = base_offset + offset;
-
- /* Get the format of the table. */
- if ( FT_STREAM_SEEK( charset->offset ) ||
- FT_READ_BYTE( charset->format ) )
- goto Exit;
-
- /* Allocate memory for sids. */
- if ( FT_QNEW_ARRAY( charset->sids, num_glyphs ) )
- goto Exit;
-
- /* assign the .notdef glyph */
- charset->sids[0] = 0;
-
- switch ( charset->format )
- {
- case 0:
- if ( num_glyphs > 0 )
- {
- if ( FT_FRAME_ENTER( ( num_glyphs - 1 ) * 2 ) )
- goto Exit;
-
- for ( j = 1; j < num_glyphs; j++ )
- charset->sids[j] = FT_GET_USHORT();
-
- FT_FRAME_EXIT();
- }
- break;
-
- case 1:
- case 2:
- {
- FT_UInt nleft;
- FT_UInt i;
-
-
- j = 1;
-
- while ( j < num_glyphs )
- {
- /* Read the first glyph sid of the range. */
- if ( FT_READ_USHORT( glyph_sid ) )
- goto Exit;
-
- /* Read the number of glyphs in the range. */
- if ( charset->format == 2 )
- {
- if ( FT_READ_USHORT( nleft ) )
- goto Exit;
- }
- else
- {
- if ( FT_READ_BYTE( nleft ) )
- goto Exit;
- }
-
- /* try to rescue some of the SIDs if `nleft' is too large */
- if ( glyph_sid > 0xFFFFL - nleft )
- {
- FT_ERROR(( "cff_charset_load: invalid SID range trimmed"
- " nleft=%d -> %ld\n", nleft, 0xFFFFL - glyph_sid ));
- nleft = ( FT_UInt )( 0xFFFFL - glyph_sid );
- }
-
- /* Fill in the range of sids -- `nleft + 1' glyphs. */
- for ( i = 0; j < num_glyphs && i <= nleft; i++, j++, glyph_sid++ )
- charset->sids[j] = glyph_sid;
- }
- }
- break;
-
- default:
- FT_ERROR(( "cff_charset_load: invalid table format\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
- }
- else
- {
- /* Parse default tables corresponding to offset == 0, 1, or 2. */
- /* CFF specification intimates the following: */
- /* */
- /* In order to use a predefined charset, the following must be */
- /* true: The charset constructed for the glyphs in the font's */
- /* charstrings dictionary must match the predefined charset in */
- /* the first num_glyphs. */
-
- charset->offset = offset; /* record charset type */
-
- switch ( (FT_UInt)offset )
- {
- case 0:
- if ( num_glyphs > 229 )
- {
- FT_ERROR(( "cff_charset_load: implicit charset larger than\n" ));
- FT_ERROR(( "predefined charset (Adobe ISO-Latin)\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- /* Allocate memory for sids. */
- if ( FT_QNEW_ARRAY( charset->sids, num_glyphs ) )
- goto Exit;
-
- /* Copy the predefined charset into the allocated memory. */
- FT_ARRAY_COPY( charset->sids, cff_isoadobe_charset, num_glyphs );
-
- break;
-
- case 1:
- if ( num_glyphs > 166 )
- {
- FT_ERROR(( "cff_charset_load: implicit charset larger than\n" ));
- FT_ERROR(( "predefined charset (Adobe Expert)\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- /* Allocate memory for sids. */
- if ( FT_QNEW_ARRAY( charset->sids, num_glyphs ) )
- goto Exit;
-
- /* Copy the predefined charset into the allocated memory. */
- FT_ARRAY_COPY( charset->sids, cff_expert_charset, num_glyphs );
-
- break;
-
- case 2:
- if ( num_glyphs > 87 )
- {
- FT_ERROR(( "cff_charset_load: implicit charset larger than\n" ));
- FT_ERROR(( "predefined charset (Adobe Expert Subset)\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- /* Allocate memory for sids. */
- if ( FT_QNEW_ARRAY( charset->sids, num_glyphs ) )
- goto Exit;
-
- /* Copy the predefined charset into the allocated memory. */
- FT_ARRAY_COPY( charset->sids, cff_expertsubset_charset, num_glyphs );
-
- break;
-
- default:
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
- }
-
- /* we have to invert the `sids' array for subsetted CID-keyed fonts */
- if ( invert )
- error = cff_charset_compute_cids( charset, num_glyphs, memory );
-
- Exit:
- /* Clean up if there was an error. */
- if ( error )
- {
- FT_FREE( charset->sids );
- FT_FREE( charset->cids );
- charset->format = 0;
- charset->offset = 0;
- }
-
- return error;
- }
-
-
- static void
- cff_vstore_done( CFF_VStoreRec* vstore,
- FT_Memory memory )
- {
- FT_UInt i;
-
-
- /* free regionList and axisLists */
- if ( vstore->varRegionList )
- {
- for ( i = 0; i < vstore->regionCount; i++ )
- FT_FREE( vstore->varRegionList[i].axisList );
- }
- FT_FREE( vstore->varRegionList );
-
- /* free varData and indices */
- if ( vstore->varData )
- {
- for ( i = 0; i < vstore->dataCount; i++ )
- FT_FREE( vstore->varData[i].regionIndices );
- }
- FT_FREE( vstore->varData );
- }
-
-
- /* convert 2.14 to Fixed */
- #define FT_fdot14ToFixed( x ) ( (FT_Fixed)( (FT_ULong)(x) << 2 ) )
-
-
- static FT_Error
- cff_vstore_load( CFF_VStoreRec* vstore,
- FT_Stream stream,
- FT_ULong base_offset,
- FT_ULong offset )
- {
- FT_Memory memory = stream->memory;
- FT_Error error = FT_ERR( Invalid_File_Format );
-
- FT_ULong* dataOffsetArray = NULL;
- FT_UInt i, j;
-
-
- /* no offset means no vstore to parse */
- if ( offset )
- {
- FT_UInt vsOffset;
- FT_UInt format;
- FT_UInt dataCount;
- FT_UInt regionCount;
- FT_ULong regionListOffset;
-
-
- /* we need to parse the table to determine its size; */
- /* skip table length */
- if ( FT_STREAM_SEEK( base_offset + offset ) ||
- FT_STREAM_SKIP( 2 ) )
- goto Exit;
-
- /* actual variation store begins after the length */
- vsOffset = FT_STREAM_POS();
-
- /* check the header */
- if ( FT_READ_USHORT( format ) )
- goto Exit;
- if ( format != 1 )
- {
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- /* read top level fields */
- if ( FT_READ_ULONG( regionListOffset ) ||
- FT_READ_USHORT( dataCount ) )
- goto Exit;
-
- /* make temporary copy of item variation data offsets; */
- /* we'll parse region list first, then come back */
- if ( FT_QNEW_ARRAY( dataOffsetArray, dataCount ) )
- goto Exit;
-
- for ( i = 0; i < dataCount; i++ )
- {
- if ( FT_READ_ULONG( dataOffsetArray[i] ) )
- goto Exit;
- }
-
- /* parse regionList and axisLists */
- if ( FT_STREAM_SEEK( vsOffset + regionListOffset ) ||
- FT_READ_USHORT( vstore->axisCount ) ||
- FT_READ_USHORT( regionCount ) )
- goto Exit;
-
- vstore->regionCount = 0;
- if ( FT_QNEW_ARRAY( vstore->varRegionList, regionCount ) )
- goto Exit;
-
- for ( i = 0; i < regionCount; i++ )
- {
- CFF_VarRegion* region = &vstore->varRegionList[i];
-
-
- if ( FT_QNEW_ARRAY( region->axisList, vstore->axisCount ) )
- goto Exit;
-
- /* keep track of how many axisList to deallocate on error */
- vstore->regionCount++;
-
- for ( j = 0; j < vstore->axisCount; j++ )
- {
- CFF_AxisCoords* axis = &region->axisList[j];
-
- FT_Int start, peak, end;
-
-
- if ( FT_READ_SHORT( start ) ||
- FT_READ_SHORT( peak ) ||
- FT_READ_SHORT( end ) )
- goto Exit;
-
- /* immediately tag invalid ranges with special peak = 0 */
- if ( ( start < 0 && end > 0 ) || start > peak || peak > end )
- peak = 0;
-
- axis->startCoord = FT_fdot14ToFixed( start );
- axis->peakCoord = FT_fdot14ToFixed( peak );
- axis->endCoord = FT_fdot14ToFixed( end );
- }
- }
-
- /* use dataOffsetArray now to parse varData items */
- vstore->dataCount = 0;
- if ( FT_QNEW_ARRAY( vstore->varData, dataCount ) )
- goto Exit;
-
- for ( i = 0; i < dataCount; i++ )
- {
- CFF_VarData* data = &vstore->varData[i];
-
-
- if ( FT_STREAM_SEEK( vsOffset + dataOffsetArray[i] ) )
- goto Exit;
-
- /* ignore `itemCount' and `shortDeltaCount' */
- /* because CFF2 has no delta sets */
- if ( FT_STREAM_SKIP( 4 ) )
- goto Exit;
-
- /* Note: just record values; consistency is checked later */
- /* by cff_blend_build_vector when it consumes `vstore' */
-
- if ( FT_READ_USHORT( data->regionIdxCount ) )
- goto Exit;
-
- if ( FT_QNEW_ARRAY( data->regionIndices, data->regionIdxCount ) )
- goto Exit;
-
- /* keep track of how many regionIndices to deallocate on error */
- vstore->dataCount++;
-
- for ( j = 0; j < data->regionIdxCount; j++ )
- {
- if ( FT_READ_USHORT( data->regionIndices[j] ) )
- goto Exit;
- }
- }
- }
-
- error = FT_Err_Ok;
-
- Exit:
- FT_FREE( dataOffsetArray );
- if ( error )
- cff_vstore_done( vstore, memory );
-
- return error;
- }
-
-
- /* Clear blend stack (after blend values are consumed). */
- /* */
- /* TODO: Should do this in cff_run_parse, but subFont */
- /* ref is not available there. */
- /* */
- /* Allocation is not changed when stack is cleared. */
- FT_LOCAL_DEF( void )
- cff_blend_clear( CFF_SubFont subFont )
- {
- subFont->blend_top = subFont->blend_stack;
- subFont->blend_used = 0;
- }
-
-
- /* Blend numOperands on the stack, */
- /* store results into the first numBlends values, */
- /* then pop remaining arguments. */
- /* */
- /* This is comparable to `cf2_doBlend' but */
- /* the cffparse stack is different and can't be written. */
- /* Blended values are written to a different buffer, */
- /* using reserved operator 255. */
- /* */
- /* Blend calculation is done in 16.16 fixed-point. */
- FT_LOCAL_DEF( FT_Error )
- cff_blend_doBlend( CFF_SubFont subFont,
- CFF_Parser parser,
- FT_UInt numBlends )
- {
- FT_UInt delta;
- FT_UInt base;
- FT_UInt i, j;
- FT_UInt size;
-
- CFF_Blend blend = &subFont->blend;
-
- FT_Memory memory = subFont->blend.font->memory; /* for FT_REALLOC */
- FT_Error error = FT_Err_Ok; /* for FT_REALLOC */
-
- /* compute expected number of operands for this blend */
- FT_UInt numOperands = (FT_UInt)( numBlends * blend->lenBV );
- FT_UInt count = (FT_UInt)( parser->top - 1 - parser->stack );
-
-
- if ( numOperands > count )
- {
- FT_TRACE4(( " cff_blend_doBlend: Stack underflow %d argument%s\n",
- count,
- count == 1 ? "" : "s" ));
-
- error = FT_THROW( Stack_Underflow );
- goto Exit;
- }
-
- /* check whether we have room for `numBlends' values at `blend_top' */
- size = 5 * numBlends; /* add 5 bytes per entry */
- if ( subFont->blend_used + size > subFont->blend_alloc )
- {
- FT_Byte* blend_stack_old = subFont->blend_stack;
- FT_Byte* blend_top_old = subFont->blend_top;
-
-
- /* increase or allocate `blend_stack' and reset `blend_top'; */
- /* prepare to append `numBlends' values to the buffer */
- if ( FT_QREALLOC( subFont->blend_stack,
- subFont->blend_alloc,
- subFont->blend_alloc + size ) )
- goto Exit;
-
- subFont->blend_top = subFont->blend_stack + subFont->blend_used;
- subFont->blend_alloc += size;
-
- /* iterate over the parser stack and adjust pointers */
- /* if the reallocated buffer has a different address */
- if ( blend_stack_old &&
- subFont->blend_stack != blend_stack_old )
- {
- FT_PtrDist offset = subFont->blend_stack - blend_stack_old;
- FT_Byte** p;
-
-
- for ( p = parser->stack; p < parser->top; p++ )
- {
- if ( *p >= blend_stack_old && *p < blend_top_old )
- *p += offset;
- }
- }
- }
- subFont->blend_used += size;
-
- base = count - numOperands; /* index of first blend arg */
- delta = base + numBlends; /* index of first delta arg */
-
- for ( i = 0; i < numBlends; i++ )
- {
- const FT_Int32* weight = &blend->BV[1];
- FT_Fixed sum;
-
-
- /* convert inputs to 16.16 fixed point */
- sum = cff_parse_fixed( parser, &parser->stack[i + base] );
-
- for ( j = 1; j < blend->lenBV; j++ )
- sum += FT_MulFix( cff_parse_fixed( parser, &parser->stack[delta++] ),
- *weight++ );
-
- /* point parser stack to new value on blend_stack */
- parser->stack[i + base] = subFont->blend_top;
-
- /* Push blended result as Type 2 5-byte fixed-point number. This */
- /* will not conflict with actual DICTs because 255 is a reserved */
- /* opcode in both CFF and CFF2 DICTs. See `cff_parse_num' for */
- /* decode of this, which rounds to an integer. */
- *subFont->blend_top++ = 255;
- *subFont->blend_top++ = (FT_Byte)( (FT_UInt32)sum >> 24 );
- *subFont->blend_top++ = (FT_Byte)( (FT_UInt32)sum >> 16 );
- *subFont->blend_top++ = (FT_Byte)( (FT_UInt32)sum >> 8 );
- *subFont->blend_top++ = (FT_Byte)( (FT_UInt32)sum );
- }
-
- /* leave only numBlends results on parser stack */
- parser->top = &parser->stack[base + numBlends];
-
- Exit:
- return error;
- }
-
-
- /* Compute a blend vector from variation store index and normalized */
- /* vector based on pseudo-code in OpenType Font Variations Overview. */
- /* */
- /* Note: lenNDV == 0 produces a default blend vector, (1,0,0,...). */
- FT_LOCAL_DEF( FT_Error )
- cff_blend_build_vector( CFF_Blend blend,
- FT_UInt vsindex,
- FT_UInt lenNDV,
- FT_Fixed* NDV )
- {
- FT_Error error = FT_Err_Ok; /* for FT_REALLOC */
- FT_Memory memory = blend->font->memory; /* for FT_REALLOC */
-
- FT_UInt len;
- CFF_VStore vs;
- CFF_VarData* varData;
- FT_UInt master;
-
-
- /* protect against malformed fonts */
- if ( !( lenNDV == 0 || NDV ) )
- {
- FT_TRACE4(( " cff_blend_build_vector:"
- " Malformed Normalize Design Vector data\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- blend->builtBV = FALSE;
-
- vs = &blend->font->vstore;
-
- /* VStore and fvar must be consistent */
- if ( lenNDV != 0 && lenNDV != vs->axisCount )
- {
- FT_TRACE4(( " cff_blend_build_vector: Axis count mismatch\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- if ( vsindex >= vs->dataCount )
- {
- FT_TRACE4(( " cff_blend_build_vector: vsindex out of range\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- /* select the item variation data structure */
- varData = &vs->varData[vsindex];
-
- /* prepare buffer for the blend vector */
- len = varData->regionIdxCount + 1; /* add 1 for default component */
- if ( FT_QRENEW_ARRAY( blend->BV, blend->lenBV, len ) )
- goto Exit;
-
- blend->lenBV = len;
-
- /* outer loop steps through master designs to be blended */
- for ( master = 0; master < len; master++ )
- {
- FT_UInt j;
- FT_UInt idx;
- CFF_VarRegion* varRegion;
-
-
- /* default factor is always one */
- if ( master == 0 )
- {
- blend->BV[master] = FT_FIXED_ONE;
- FT_TRACE4(( " build blend vector len %d\n", len ));
- FT_TRACE4(( " [ %f ", blend->BV[master] / 65536.0 ));
- continue;
- }
-
- /* VStore array does not include default master, so subtract one */
- idx = varData->regionIndices[master - 1];
- varRegion = &vs->varRegionList[idx];
-
- if ( idx >= vs->regionCount )
- {
- FT_TRACE4(( " cff_blend_build_vector:"
- " region index out of range\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- /* Note: `lenNDV' could be zero. */
- /* In that case, build default blend vector (1,0,0...). */
- if ( !lenNDV )
- {
- blend->BV[master] = 0;
- continue;
- }
-
- /* In the normal case, initialize each component to 1 */
- /* before inner loop. */
- blend->BV[master] = FT_FIXED_ONE; /* default */
-
- /* inner loop steps through axes in this region */
- for ( j = 0; j < lenNDV; j++ )
- {
- CFF_AxisCoords* axis = &varRegion->axisList[j];
-
-
- /* compute the scalar contribution of this axis */
- /* with peak of 0 used for invalid axes */
- if ( axis->peakCoord == NDV[j] ||
- axis->peakCoord == 0 )
- continue;
-
- /* ignore this region if coords are out of range */
- else if ( NDV[j] <= axis->startCoord ||
- NDV[j] >= axis->endCoord )
- {
- blend->BV[master] = 0;
- break;
- }
-
- /* adjust proportionally */
- else if ( NDV[j] < axis->peakCoord )
- blend->BV[master] = FT_MulDiv( blend->BV[master],
- NDV[j] - axis->startCoord,
- axis->peakCoord - axis->startCoord );
- else /* NDV[j] > axis->peakCoord ) */
- blend->BV[master] = FT_MulDiv( blend->BV[master],
- axis->endCoord - NDV[j],
- axis->endCoord - axis->peakCoord );
- }
-
- FT_TRACE4(( ", %f ",
- blend->BV[master] / 65536.0 ));
- }
-
- FT_TRACE4(( "]\n" ));
-
- /* record the parameters used to build the blend vector */
- blend->lastVsindex = vsindex;
-
- if ( lenNDV != 0 )
- {
- /* user has set a normalized vector */
- if ( FT_QRENEW_ARRAY( blend->lastNDV, blend->lenNDV, lenNDV ) )
- goto Exit;
-
- FT_MEM_COPY( blend->lastNDV,
- NDV,
- lenNDV * sizeof ( *NDV ) );
- }
-
- blend->lenNDV = lenNDV;
- blend->builtBV = TRUE;
-
- Exit:
- return error;
- }
-
-
- /* `lenNDV' is zero for default vector; */
- /* return TRUE if blend vector needs to be built. */
- FT_LOCAL_DEF( FT_Bool )
- cff_blend_check_vector( CFF_Blend blend,
- FT_UInt vsindex,
- FT_UInt lenNDV,
- FT_Fixed* NDV )
- {
- if ( !blend->builtBV ||
- blend->lastVsindex != vsindex ||
- blend->lenNDV != lenNDV ||
- ( lenNDV &&
- ft_memcmp( NDV,
- blend->lastNDV,
- lenNDV * sizeof ( *NDV ) ) != 0 ) )
- {
- /* need to build blend vector */
- return TRUE;
- }
-
- return FALSE;
- }
-
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
-
- FT_LOCAL_DEF( FT_Error )
- cff_get_var_blend( FT_Face face, /* CFF_Face */
- FT_UInt *num_coords,
- FT_Fixed* *coords,
- FT_Fixed* *normalizedcoords,
- FT_MM_Var* *mm_var )
- {
- CFF_Face cffface = (CFF_Face)face;
- FT_Service_MultiMasters mm = (FT_Service_MultiMasters)cffface->mm;
-
-
- return mm->get_var_blend( face,
- num_coords,
- coords,
- normalizedcoords,
- mm_var );
- }
-
-
- FT_LOCAL_DEF( void )
- cff_done_blend( FT_Face face ) /* CFF_Face */
- {
- CFF_Face cffface = (CFF_Face)face;
- FT_Service_MultiMasters mm = (FT_Service_MultiMasters)cffface->mm;
-
-
- if ( mm )
- mm->done_blend( face );
- }
-
-#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
-
-
- static void
- cff_encoding_done( CFF_Encoding encoding )
- {
- encoding->format = 0;
- encoding->offset = 0;
- encoding->count = 0;
- }
-
-
- static FT_Error
- cff_encoding_load( CFF_Encoding encoding,
- CFF_Charset charset,
- FT_UInt num_glyphs,
- FT_Stream stream,
- FT_ULong base_offset,
- FT_ULong offset )
- {
- FT_Error error = FT_Err_Ok;
- FT_UInt count;
- FT_UInt j;
- FT_UShort glyph_sid;
- FT_UInt glyph_code;
-
-
- /* Check for charset->sids. If we do not have this, we fail. */
- if ( !charset->sids )
- {
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- /* Note: The encoding table in a CFF font is indexed by glyph index; */
- /* the first encoded glyph index is 1. Hence, we read the character */
- /* code (`glyph_code') at index j and make the assignment: */
- /* */
- /* encoding->codes[glyph_code] = j + 1 */
- /* */
- /* We also make the assignment: */
- /* */
- /* encoding->sids[glyph_code] = charset->sids[j + 1] */
- /* */
- /* This gives us both a code to GID and a code to SID mapping. */
-
- if ( offset > 1 )
- {
- /* Zero out the code to gid/sid mappings. */
- FT_ARRAY_ZERO( encoding->sids, 256 );
- FT_ARRAY_ZERO( encoding->codes, 256 );
-
- encoding->offset = base_offset + offset;
-
- /* we need to parse the table to determine its size */
- if ( FT_STREAM_SEEK( encoding->offset ) ||
- FT_READ_BYTE( encoding->format ) ||
- FT_READ_BYTE( count ) )
- goto Exit;
-
- switch ( encoding->format & 0x7F )
- {
- case 0:
- {
- FT_Byte* p;
-
-
- /* By convention, GID 0 is always ".notdef" and is never */
- /* coded in the font. Hence, the number of codes found */
- /* in the table is `count+1'. */
- /* */
- encoding->count = count + 1;
-
- if ( FT_FRAME_ENTER( count ) )
- goto Exit;
-
- p = (FT_Byte*)stream->cursor;
-
- for ( j = 1; j <= count; j++ )
- {
- glyph_code = *p++;
-
- /* Make sure j is not too big. */
- if ( j < num_glyphs )
- {
- /* Assign code to GID mapping. */
- encoding->codes[glyph_code] = (FT_UShort)j;
-
- /* Assign code to SID mapping. */
- encoding->sids[glyph_code] = charset->sids[j];
- }
- }
-
- FT_FRAME_EXIT();
- }
- break;
-
- case 1:
- {
- FT_UInt nleft;
- FT_UInt i = 1;
- FT_UInt k;
-
-
- encoding->count = 0;
-
- /* Parse the Format1 ranges. */
- for ( j = 0; j < count; j++, i += nleft )
- {
- /* Read the first glyph code of the range. */
- if ( FT_READ_BYTE( glyph_code ) )
- goto Exit;
-
- /* Read the number of codes in the range. */
- if ( FT_READ_BYTE( nleft ) )
- goto Exit;
-
- /* Increment nleft, so we read `nleft + 1' codes/sids. */
- nleft++;
-
- /* compute max number of character codes */
- if ( (FT_UInt)nleft > encoding->count )
- encoding->count = nleft;
-
- /* Fill in the range of codes/sids. */
- for ( k = i; k < nleft + i; k++, glyph_code++ )
- {
- /* Make sure k is not too big. */
- if ( k < num_glyphs && glyph_code < 256 )
- {
- /* Assign code to GID mapping. */
- encoding->codes[glyph_code] = (FT_UShort)k;
-
- /* Assign code to SID mapping. */
- encoding->sids[glyph_code] = charset->sids[k];
- }
- }
- }
-
- /* simple check; one never knows what can be found in a font */
- if ( encoding->count > 256 )
- encoding->count = 256;
- }
- break;
-
- default:
- FT_ERROR(( "cff_encoding_load: invalid table format\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- /* Parse supplemental encodings, if any. */
- if ( encoding->format & 0x80 )
- {
- FT_UInt gindex;
-
-
- /* count supplements */
- if ( FT_READ_BYTE( count ) )
- goto Exit;
-
- for ( j = 0; j < count; j++ )
- {
- /* Read supplemental glyph code. */
- if ( FT_READ_BYTE( glyph_code ) )
- goto Exit;
-
- /* Read the SID associated with this glyph code. */
- if ( FT_READ_USHORT( glyph_sid ) )
- goto Exit;
-
- /* Assign code to SID mapping. */
- encoding->sids[glyph_code] = glyph_sid;
-
- /* First, look up GID which has been assigned to */
- /* SID glyph_sid. */
- for ( gindex = 0; gindex < num_glyphs; gindex++ )
- {
- if ( charset->sids[gindex] == glyph_sid )
- {
- encoding->codes[glyph_code] = (FT_UShort)gindex;
- break;
- }
- }
- }
- }
- }
- else
- {
- /* We take into account the fact a CFF font can use a predefined */
- /* encoding without containing all of the glyphs encoded by this */
- /* encoding (see the note at the end of section 12 in the CFF */
- /* specification). */
-
- switch ( (FT_UInt)offset )
- {
- case 0:
- /* First, copy the code to SID mapping. */
- FT_ARRAY_COPY( encoding->sids, cff_standard_encoding, 256 );
- goto Populate;
-
- case 1:
- /* First, copy the code to SID mapping. */
- FT_ARRAY_COPY( encoding->sids, cff_expert_encoding, 256 );
-
- Populate:
- /* Construct code to GID mapping from code to SID mapping */
- /* and charset. */
-
- encoding->offset = offset; /* used in cff_face_init */
- encoding->count = 0;
-
- error = cff_charset_compute_cids( charset, num_glyphs,
- stream->memory );
- if ( error )
- goto Exit;
-
- for ( j = 0; j < 256; j++ )
- {
- FT_UInt sid = encoding->sids[j];
- FT_UInt gid = 0;
-
-
- if ( sid )
- gid = cff_charset_cid_to_gindex( charset, sid );
-
- if ( gid != 0 )
- {
- encoding->codes[j] = (FT_UShort)gid;
- encoding->count = j + 1;
- }
- else
- {
- encoding->codes[j] = 0;
- encoding->sids [j] = 0;
- }
- }
- break;
-
- default:
- FT_ERROR(( "cff_encoding_load: invalid table format\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
- }
-
- Exit:
-
- /* Clean up if there was an error. */
- return error;
- }
-
-
- /* Parse private dictionary; first call is always from `cff_face_init', */
- /* so NDV has not been set for CFF2 variation. */
- /* */
- /* `cff_slot_load' must call this function each time NDV changes. */
- FT_LOCAL_DEF( FT_Error )
- cff_load_private_dict( CFF_Font font,
- CFF_SubFont subfont,
- FT_UInt lenNDV,
- FT_Fixed* NDV )
- {
- FT_Error error = FT_Err_Ok;
- CFF_ParserRec parser;
- CFF_FontRecDict top = &subfont->font_dict;
- CFF_Private priv = &subfont->private_dict;
- FT_Stream stream = font->stream;
- FT_UInt stackSize;
-
-
- /* store handle needed to access memory, vstore for blend; */
- /* we need this for clean-up even if there is no private DICT */
- subfont->blend.font = font;
- subfont->blend.usedBV = FALSE; /* clear state */
-
- if ( !top->private_offset || !top->private_size )
- goto Exit2; /* no private DICT, do nothing */
-
- /* set defaults */
- FT_ZERO( priv );
-
- priv->blue_shift = 7;
- priv->blue_fuzz = 1;
- priv->lenIV = -1;
- priv->expansion_factor = (FT_Fixed)( 0.06 * 0x10000L );
- priv->blue_scale = (FT_Fixed)( 0.039625 * 0x10000L * 1000 );
-
- /* provide inputs for blend calculations */
- priv->subfont = subfont;
- subfont->lenNDV = lenNDV;
- subfont->NDV = NDV;
-
- /* add 1 for the operator */
- stackSize = font->cff2 ? font->top_font.font_dict.maxstack + 1
- : CFF_MAX_STACK_DEPTH + 1;
-
- if ( cff_parser_init( &parser,
- font->cff2 ? CFF2_CODE_PRIVATE : CFF_CODE_PRIVATE,
- priv,
- font->library,
- stackSize,
- top->num_designs,
- top->num_axes ) )
- goto Exit;
-
- if ( FT_STREAM_SEEK( font->base_offset + top->private_offset ) ||
- FT_FRAME_ENTER( top->private_size ) )
- goto Exit;
-
- FT_TRACE4(( " private dictionary:\n" ));
- error = cff_parser_run( &parser,
- (FT_Byte*)stream->cursor,
- (FT_Byte*)stream->limit );
- FT_FRAME_EXIT();
-
- if ( error )
- goto Exit;
-
- /* ensure that `num_blue_values' is even */
- priv->num_blue_values &= ~1;
-
- /* sanitize `initialRandomSeed' to be a positive value, if necessary; */
- /* this is not mandated by the specification but by our implementation */
- if ( priv->initial_random_seed < 0 )
- priv->initial_random_seed = -priv->initial_random_seed;
- else if ( priv->initial_random_seed == 0 )
- priv->initial_random_seed = 987654321;
-
- /* some sanitizing to avoid overflows later on; */
- /* the upper limits are ad-hoc values */
- if ( priv->blue_shift > 1000 || priv->blue_shift < 0 )
- {
- FT_TRACE2(( "cff_load_private_dict:"
- " setting unlikely BlueShift value %ld to default (7)\n",
- priv->blue_shift ));
- priv->blue_shift = 7;
- }
-
- if ( priv->blue_fuzz > 1000 || priv->blue_fuzz < 0 )
- {
- FT_TRACE2(( "cff_load_private_dict:"
- " setting unlikely BlueFuzz value %ld to default (1)\n",
- priv->blue_fuzz ));
- priv->blue_fuzz = 1;
- }
-
- Exit:
- /* clean up */
- cff_blend_clear( subfont ); /* clear blend stack */
- cff_parser_done( &parser ); /* free parser stack */
-
- Exit2:
- /* no clean up (parser not initialized) */
- return error;
- }
-
-
- /* There are 3 ways to call this function, distinguished by code. */
- /* */
- /* . CFF_CODE_TOPDICT for either a CFF Top DICT or a CFF Font DICT */
- /* . CFF2_CODE_TOPDICT for CFF2 Top DICT */
- /* . CFF2_CODE_FONTDICT for CFF2 Font DICT */
-
- static FT_Error
- cff_subfont_load( CFF_SubFont subfont,
- CFF_Index idx,
- FT_UInt font_index,
- FT_Stream stream,
- FT_ULong base_offset,
- FT_UInt code,
- CFF_Font font,
- CFF_Face face )
- {
- FT_Error error;
- CFF_ParserRec parser;
- FT_Byte* dict = NULL;
- FT_ULong dict_len;
- CFF_FontRecDict top = &subfont->font_dict;
- CFF_Private priv = &subfont->private_dict;
-
- PSAux_Service psaux = (PSAux_Service)face->psaux;
-
- FT_Bool cff2 = FT_BOOL( code == CFF2_CODE_TOPDICT ||
- code == CFF2_CODE_FONTDICT );
- FT_UInt stackSize = cff2 ? CFF2_DEFAULT_STACK
- : CFF_MAX_STACK_DEPTH;
-
-
- /* Note: We use default stack size for CFF2 Font DICT because */
- /* Top and Font DICTs are not allowed to have blend operators. */
- error = cff_parser_init( &parser,
- code,
- top,
- font->library,
- stackSize,
- 0,
- 0 );
- if ( error )
- goto Exit;
-
- /* set defaults */
- FT_ZERO( top );
-
- top->underline_position = -( 100L << 16 );
- top->underline_thickness = 50L << 16;
- top->charstring_type = 2;
- top->font_matrix.xx = 0x10000L;
- top->font_matrix.yy = 0x10000L;
- top->cid_count = 8720;
-
- /* we use the implementation specific SID value 0xFFFF to indicate */
- /* missing entries */
- top->version = 0xFFFFU;
- top->notice = 0xFFFFU;
- top->copyright = 0xFFFFU;
- top->full_name = 0xFFFFU;
- top->family_name = 0xFFFFU;
- top->weight = 0xFFFFU;
- top->embedded_postscript = 0xFFFFU;
-
- top->cid_registry = 0xFFFFU;
- top->cid_ordering = 0xFFFFU;
- top->cid_font_name = 0xFFFFU;
-
- /* set default stack size */
- top->maxstack = cff2 ? CFF2_DEFAULT_STACK : 48;
-
- if ( idx->count ) /* count is nonzero for a real index */
- error = cff_index_access_element( idx, font_index, &dict, &dict_len );
- else
- {
- /* CFF2 has a fake top dict index; */
- /* simulate `cff_index_access_element' */
-
- /* Note: macros implicitly use `stream' and set `error' */
- if ( FT_STREAM_SEEK( idx->data_offset ) ||
- FT_FRAME_EXTRACT( idx->data_size, dict ) )
- goto Exit;
-
- dict_len = idx->data_size;
- }
-
- if ( !error )
- {
- FT_TRACE4(( " top dictionary:\n" ));
- error = cff_parser_run( &parser, dict, FT_OFFSET( dict, dict_len ) );
- }
-
- /* clean up regardless of error */
- if ( idx->count )
- cff_index_forget_element( idx, &dict );
- else
- FT_FRAME_RELEASE( dict );
-
- if ( error )
- goto Exit;
-
- /* if it is a CID font, we stop there */
- if ( top->cid_registry != 0xFFFFU )
- goto Exit;
-
- /* Parse the private dictionary, if any. */
- /* */
- /* CFF2 does not have a private dictionary in the Top DICT */
- /* but may have one in a Font DICT. We need to parse */
- /* the latter here in order to load any local subrs. */
- error = cff_load_private_dict( font, subfont, 0, 0 );
- if ( error )
- goto Exit;
-
- if ( !cff2 )
- {
- /*
- * Initialize the random number generator.
- *
- * - If we have a face-specific seed, use it.
- * If non-zero, update it to a positive value.
- *
- * - Otherwise, use the seed from the CFF driver.
- * If non-zero, update it to a positive value.
- *
- * - If the random value is zero, use the seed given by the subfont's
- * `initialRandomSeed' value.
- *
- */
- if ( face->root.internal->random_seed == -1 )
- {
- PS_Driver driver = (PS_Driver)FT_FACE_DRIVER( face );
-
-
- subfont->random = (FT_UInt32)driver->random_seed;
- if ( driver->random_seed )
- {
- do
- {
- driver->random_seed =
- (FT_Int32)psaux->cff_random( (FT_UInt32)driver->random_seed );
-
- } while ( driver->random_seed < 0 );
- }
- }
- else
- {
- subfont->random = (FT_UInt32)face->root.internal->random_seed;
- if ( face->root.internal->random_seed )
- {
- do
- {
- face->root.internal->random_seed =
- (FT_Int32)psaux->cff_random(
- (FT_UInt32)face->root.internal->random_seed );
-
- } while ( face->root.internal->random_seed < 0 );
- }
- }
-
- if ( !subfont->random )
- subfont->random = (FT_UInt32)priv->initial_random_seed;
- }
-
- /* read the local subrs, if any */
- if ( priv->local_subrs_offset )
- {
- if ( FT_STREAM_SEEK( base_offset + top->private_offset +
- priv->local_subrs_offset ) )
- goto Exit;
-
- error = cff_index_init( &subfont->local_subrs_index, stream, 1, cff2 );
- if ( error )
- goto Exit;
-
- error = cff_index_get_pointers( &subfont->local_subrs_index,
- &subfont->local_subrs, NULL, NULL );
- if ( error )
- goto Exit;
- }
-
- Exit:
- cff_parser_done( &parser ); /* free parser stack */
-
- return error;
- }
-
-
- static void
- cff_subfont_done( FT_Memory memory,
- CFF_SubFont subfont )
- {
- if ( subfont )
- {
- cff_index_done( &subfont->local_subrs_index );
- FT_FREE( subfont->local_subrs );
-
- FT_FREE( subfont->blend.lastNDV );
- FT_FREE( subfont->blend.BV );
- FT_FREE( subfont->blend_stack );
- }
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- cff_font_load( FT_Library library,
- FT_Stream stream,
- FT_Int face_index,
- CFF_Font font,
- CFF_Face face,
- FT_Bool pure_cff,
- FT_Bool cff2 )
- {
- static const FT_Frame_Field cff_header_fields[] =
- {
-#undef FT_STRUCTURE
-#define FT_STRUCTURE CFF_FontRec
-
- FT_FRAME_START( 3 ),
- FT_FRAME_BYTE( version_major ),
- FT_FRAME_BYTE( version_minor ),
- FT_FRAME_BYTE( header_size ),
- FT_FRAME_END
- };
-
- FT_Error error;
- FT_Memory memory = stream->memory;
- FT_ULong base_offset;
- CFF_FontRecDict dict;
- CFF_IndexRec string_index;
- FT_UInt subfont_index;
-
-
- FT_ZERO( font );
- FT_ZERO( &string_index );
-
- dict = &font->top_font.font_dict;
- base_offset = FT_STREAM_POS();
-
- font->library = library;
- font->stream = stream;
- font->memory = memory;
- font->cff2 = cff2;
- font->base_offset = base_offset;
-
- /* read CFF font header */
- if ( FT_STREAM_READ_FIELDS( cff_header_fields, font ) )
- goto Exit;
-
- if ( cff2 )
- {
- if ( font->version_major != 2 ||
- font->header_size < 5 )
- {
- FT_TRACE2(( " not a CFF2 font header\n" ));
- error = FT_THROW( Unknown_File_Format );
- goto Exit;
- }
-
- if ( FT_READ_USHORT( font->top_dict_length ) )
- goto Exit;
- }
- else
- {
- FT_Byte absolute_offset;
-
-
- if ( FT_READ_BYTE( absolute_offset ) )
- goto Exit;
-
- if ( font->version_major != 1 ||
- font->header_size < 4 ||
- absolute_offset > 4 )
- {
- FT_TRACE2(( " not a CFF font header\n" ));
- error = FT_THROW( Unknown_File_Format );
- goto Exit;
- }
- }
-
- /* skip the rest of the header */
- if ( FT_STREAM_SEEK( base_offset + font->header_size ) )
- {
- /* For pure CFFs we have read only four bytes so far. Contrary to */
- /* other formats like SFNT those bytes doesn't define a signature; */
- /* it is thus possible that the font isn't a CFF at all. */
- if ( pure_cff )
- {
- FT_TRACE2(( " not a CFF file\n" ));
- error = FT_THROW( Unknown_File_Format );
- }
- goto Exit;
- }
-
- if ( cff2 )
- {
- /* For CFF2, the top dict data immediately follow the header */
- /* and the length is stored in the header `offSize' field; */
- /* there is no index for it. */
- /* */
- /* Use the `font_dict_index' to save the current position */
- /* and length of data, but leave count at zero as an indicator. */
- FT_ZERO( &font->font_dict_index );
-
- font->font_dict_index.data_offset = FT_STREAM_POS();
- font->font_dict_index.data_size = font->top_dict_length;
-
- /* skip the top dict data for now, we will parse it later */
- if ( FT_STREAM_SKIP( font->top_dict_length ) )
- goto Exit;
-
- /* next, read the global subrs index */
- if ( FT_SET_ERROR( cff_index_init( &font->global_subrs_index,
- stream, 1, cff2 ) ) )
- goto Exit;
- }
- else
- {
- /* for CFF, read the name, top dict, string and global subrs index */
- if ( FT_SET_ERROR( cff_index_init( &font->name_index,
- stream, 0, cff2 ) ) )
- {
- if ( pure_cff )
- {
- FT_TRACE2(( " not a CFF file\n" ));
- error = FT_THROW( Unknown_File_Format );
- }
- goto Exit;
- }
-
- /* if we have an empty font name, */
- /* it must be the only font in the CFF */
- if ( font->name_index.count > 1 &&
- font->name_index.data_size < font->name_index.count )
- {
- /* for pure CFFs, we still haven't checked enough bytes */
- /* to be sure that it is a CFF at all */
- error = pure_cff ? FT_THROW( Unknown_File_Format )
- : FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- if ( FT_SET_ERROR( cff_index_init( &font->font_dict_index,
- stream, 0, cff2 ) ) ||
- FT_SET_ERROR( cff_index_init( &string_index,
- stream, 1, cff2 ) ) ||
- FT_SET_ERROR( cff_index_init( &font->global_subrs_index,
- stream, 1, cff2 ) ) ||
- FT_SET_ERROR( cff_index_get_pointers( &string_index,
- &font->strings,
- &font->string_pool,
- &font->string_pool_size ) ) )
- goto Exit;
-
- /* there must be a Top DICT index entry for each name index entry */
- if ( font->name_index.count > font->font_dict_index.count )
- {
- FT_ERROR(( "cff_font_load:"
- " not enough entries in Top DICT index\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
- }
-
- font->num_strings = string_index.count;
-
- if ( pure_cff )
- {
- /* well, we don't really forget the `disabled' fonts... */
- subfont_index = (FT_UInt)( face_index & 0xFFFF );
-
- if ( face_index > 0 && subfont_index >= font->name_index.count )
- {
- FT_ERROR(( "cff_font_load:"
- " invalid subfont index for pure CFF font (%d)\n",
- subfont_index ));
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- font->num_faces = font->name_index.count;
- }
- else
- {
- subfont_index = 0;
-
- if ( font->name_index.count > 1 )
- {
- FT_ERROR(( "cff_font_load:"
- " invalid CFF font with multiple subfonts\n" ));
- FT_ERROR(( " "
- " in SFNT wrapper\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
- }
-
- /* in case of a font format check, simply exit now */
- if ( face_index < 0 )
- goto Exit;
-
- /* now, parse the top-level font dictionary */
- FT_TRACE4(( "parsing top-level\n" ));
- error = cff_subfont_load( &font->top_font,
- &font->font_dict_index,
- subfont_index,
- stream,
- base_offset,
- cff2 ? CFF2_CODE_TOPDICT : CFF_CODE_TOPDICT,
- font,
- face );
- if ( error )
- goto Exit;
-
- if ( FT_STREAM_SEEK( base_offset + dict->charstrings_offset ) )
- goto Exit;
-
- error = cff_index_init( &font->charstrings_index, stream, 0, cff2 );
- if ( error )
- goto Exit;
-
- /* now, check for a CID or CFF2 font */
- if ( dict->cid_registry != 0xFFFFU ||
- cff2 )
- {
- CFF_IndexRec fd_index;
- CFF_SubFont sub = NULL;
- FT_UInt idx;
-
-
- /* for CFF2, read the Variation Store if available; */
- /* this must follow the Top DICT parse and precede any Private DICT */
- error = cff_vstore_load( &font->vstore,
- stream,
- base_offset,
- dict->vstore_offset );
- if ( error )
- goto Exit;
-
- /* this is a CID-keyed font, we must now allocate a table of */
- /* sub-fonts, then load each of them separately */
- if ( FT_STREAM_SEEK( base_offset + dict->cid_fd_array_offset ) )
- goto Exit;
-
- error = cff_index_init( &fd_index, stream, 0, cff2 );
- if ( error )
- goto Exit;
-
- /* Font Dicts are not limited to 256 for CFF2. */
- /* TODO: support this for CFF2 */
- if ( fd_index.count > CFF_MAX_CID_FONTS )
- {
- FT_TRACE0(( "cff_font_load: FD array too large in CID font\n" ));
- goto Fail_CID;
- }
-
- /* allocate & read each font dict independently */
- font->num_subfonts = fd_index.count;
- if ( FT_NEW_ARRAY( sub, fd_index.count ) )
- goto Fail_CID;
-
- /* set up pointer table */
- for ( idx = 0; idx < fd_index.count; idx++ )
- font->subfonts[idx] = sub + idx;
-
- /* now load each subfont independently */
- for ( idx = 0; idx < fd_index.count; idx++ )
- {
- sub = font->subfonts[idx];
- FT_TRACE4(( "parsing subfont %u\n", idx ));
- error = cff_subfont_load( sub,
- &fd_index,
- idx,
- stream,
- base_offset,
- cff2 ? CFF2_CODE_FONTDICT
- : CFF_CODE_TOPDICT,
- font,
- face );
- if ( error )
- goto Fail_CID;
- }
-
- /* now load the FD Select array; */
- /* CFF2 omits FDSelect if there is only one FD */
- if ( !cff2 || fd_index.count > 1 )
- error = CFF_Load_FD_Select( &font->fd_select,
- font->charstrings_index.count,
- stream,
- base_offset + dict->cid_fd_select_offset );
-
- Fail_CID:
- cff_index_done( &fd_index );
-
- if ( error )
- goto Exit;
- }
- else
- font->num_subfonts = 0;
-
- /* read the charstrings index now */
- if ( dict->charstrings_offset == 0 )
- {
- FT_ERROR(( "cff_font_load: no charstrings offset\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- font->num_glyphs = font->charstrings_index.count;
-
- error = cff_index_get_pointers( &font->global_subrs_index,
- &font->global_subrs, NULL, NULL );
-
- if ( error )
- goto Exit;
-
- /* read the Charset and Encoding tables if available */
- if ( !cff2 && font->num_glyphs > 0 )
- {
- FT_Bool invert = FT_BOOL( dict->cid_registry != 0xFFFFU && pure_cff );
-
-
- error = cff_charset_load( &font->charset, font->num_glyphs, stream,
- base_offset, dict->charset_offset, invert );
- if ( error )
- goto Exit;
-
- /* CID-keyed CFFs don't have an encoding */
- if ( dict->cid_registry == 0xFFFFU )
- {
- error = cff_encoding_load( &font->encoding,
- &font->charset,
- font->num_glyphs,
- stream,
- base_offset,
- dict->encoding_offset );
- if ( error )
- goto Exit;
- }
- }
-
- /* get the font name (/CIDFontName for CID-keyed fonts, */
- /* /FontName otherwise) */
- font->font_name = cff_index_get_name( font, subfont_index );
-
- Exit:
- cff_index_done( &string_index );
-
- return error;
- }
-
-
- FT_LOCAL_DEF( void )
- cff_font_done( CFF_Font font )
- {
- FT_Memory memory = font->memory;
- FT_UInt idx;
-
-
- cff_index_done( &font->global_subrs_index );
- cff_index_done( &font->font_dict_index );
- cff_index_done( &font->name_index );
- cff_index_done( &font->charstrings_index );
-
- /* release font dictionaries, but only if working with */
- /* a CID keyed CFF font or a CFF2 font */
- if ( font->num_subfonts > 0 )
- {
- for ( idx = 0; idx < font->num_subfonts; idx++ )
- cff_subfont_done( memory, font->subfonts[idx] );
-
- /* the subfonts array has been allocated as a single block */
- FT_FREE( font->subfonts[0] );
- }
-
- cff_encoding_done( &font->encoding );
- cff_charset_done( &font->charset, font->stream );
- cff_vstore_done( &font->vstore, memory );
-
- cff_subfont_done( memory, &font->top_font );
-
- CFF_Done_FD_Select( &font->fd_select, font->stream );
-
- FT_FREE( font->font_info );
-
- FT_FREE( font->font_name );
- FT_FREE( font->global_subrs );
- FT_FREE( font->strings );
- FT_FREE( font->string_pool );
-
- if ( font->cf2_instance.finalizer )
- {
- font->cf2_instance.finalizer( font->cf2_instance.data );
- FT_FREE( font->cf2_instance.data );
- }
-
- FT_FREE( font->font_extra );
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cff/cffload.h b/contrib/libs/freetype/src/cff/cffload.h
deleted file mode 100644
index 0220924542..0000000000
--- a/contrib/libs/freetype/src/cff/cffload.h
+++ /dev/null
@@ -1,124 +0,0 @@
-/****************************************************************************
- *
- * cffload.h
- *
- * OpenType & CFF data/program tables loader (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef CFFLOAD_H_
-#define CFFLOAD_H_
-
-
-#include <freetype/internal/cfftypes.h>
-#include "cffparse.h"
-#include <freetype/internal/cffotypes.h> /* for CFF_Face */
-
-
-FT_BEGIN_HEADER
-
- FT_LOCAL( FT_UShort )
- cff_get_standard_encoding( FT_UInt charcode );
-
-
- FT_LOCAL( FT_String* )
- cff_index_get_string( CFF_Font font,
- FT_UInt element );
-
- FT_LOCAL( FT_String* )
- cff_index_get_sid_string( CFF_Font font,
- FT_UInt sid );
-
-
- FT_LOCAL( FT_Error )
- cff_index_access_element( CFF_Index idx,
- FT_UInt element,
- FT_Byte** pbytes,
- FT_ULong* pbyte_len );
-
- FT_LOCAL( void )
- cff_index_forget_element( CFF_Index idx,
- FT_Byte** pbytes );
-
- FT_LOCAL( FT_String* )
- cff_index_get_name( CFF_Font font,
- FT_UInt element );
-
-
- FT_LOCAL( FT_UInt )
- cff_charset_cid_to_gindex( CFF_Charset charset,
- FT_UInt cid );
-
-
- FT_LOCAL( FT_Error )
- cff_font_load( FT_Library library,
- FT_Stream stream,
- FT_Int face_index,
- CFF_Font font,
- CFF_Face face,
- FT_Bool pure_cff,
- FT_Bool cff2 );
-
- FT_LOCAL( void )
- cff_font_done( CFF_Font font );
-
-
- FT_LOCAL( FT_Error )
- cff_load_private_dict( CFF_Font font,
- CFF_SubFont subfont,
- FT_UInt lenNDV,
- FT_Fixed* NDV );
-
- FT_LOCAL( FT_Byte )
- cff_fd_select_get( CFF_FDSelect fdselect,
- FT_UInt glyph_index );
-
- FT_LOCAL( FT_Bool )
- cff_blend_check_vector( CFF_Blend blend,
- FT_UInt vsindex,
- FT_UInt lenNDV,
- FT_Fixed* NDV );
-
- FT_LOCAL( FT_Error )
- cff_blend_build_vector( CFF_Blend blend,
- FT_UInt vsindex,
- FT_UInt lenNDV,
- FT_Fixed* NDV );
-
- FT_LOCAL( void )
- cff_blend_clear( CFF_SubFont subFont );
-
- FT_LOCAL( FT_Error )
- cff_blend_doBlend( CFF_SubFont subfont,
- CFF_Parser parser,
- FT_UInt numBlends );
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- FT_LOCAL( FT_Error )
- cff_get_var_blend( FT_Face face,
- FT_UInt *num_coords,
- FT_Fixed* *coords,
- FT_Fixed* *normalizedcoords,
- FT_MM_Var* *mm_var );
-
- FT_LOCAL( void )
- cff_done_blend( FT_Face face );
-#endif
-
-
-FT_END_HEADER
-
-#endif /* CFFLOAD_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cff/cffobjs.c b/contrib/libs/freetype/src/cff/cffobjs.c
deleted file mode 100644
index 7c6713739a..0000000000
--- a/contrib/libs/freetype/src/cff/cffobjs.c
+++ /dev/null
@@ -1,1175 +0,0 @@
-/****************************************************************************
- *
- * cffobjs.c
- *
- * OpenType objects manager (body).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftcalc.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/fterrors.h>
-#include <freetype/ttnameid.h>
-#include <freetype/tttags.h>
-#include <freetype/internal/sfnt.h>
-#include <freetype/ftdriver.h>
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
-#include <freetype/ftmm.h>
-#include <freetype/internal/services/svmm.h>
-#include <freetype/internal/services/svmetric.h>
-#endif
-
-#include <freetype/internal/cffotypes.h>
-#include "cffobjs.h"
-#include "cffload.h"
-#include "cffcmap.h"
-
-#include "cfferrs.h"
-
-#include <freetype/internal/psaux.h>
-#include <freetype/internal/services/svcfftl.h>
-
-#define CFF_fixedToInt( x ) \
- ( (FT_Short)( ( (x) + 0x8000U ) >> 16 ) )
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT cffobjs
-
-
- /**************************************************************************
- *
- * SIZE FUNCTIONS
- *
- */
-
-
- static PSH_Globals_Funcs
- cff_size_get_globals_funcs( CFF_Size size )
- {
- CFF_Face face = (CFF_Face)size->root.face;
- CFF_Font font = (CFF_Font)face->extra.data;
- PSHinter_Service pshinter = font->pshinter;
- FT_Module module;
-
-
- module = FT_Get_Module( font->library, "pshinter" );
-
- return ( module && pshinter && pshinter->get_globals_funcs )
- ? pshinter->get_globals_funcs( module )
- : 0;
- }
-
-
- FT_LOCAL_DEF( void )
- cff_size_done( FT_Size cffsize ) /* CFF_Size */
- {
- FT_Memory memory = cffsize->face->memory;
- CFF_Size size = (CFF_Size)cffsize;
- CFF_Face face = (CFF_Face)size->root.face;
- CFF_Font font = (CFF_Font)face->extra.data;
- CFF_Internal internal = (CFF_Internal)cffsize->internal->module_data;
-
-
- if ( internal )
- {
- PSH_Globals_Funcs funcs;
-
-
- funcs = cff_size_get_globals_funcs( size );
- if ( funcs )
- {
- FT_UInt i;
-
-
- funcs->destroy( internal->topfont );
-
- for ( i = font->num_subfonts; i > 0; i-- )
- funcs->destroy( internal->subfonts[i - 1] );
- }
-
- FT_FREE( internal );
- }
- }
-
-
- /* CFF and Type 1 private dictionaries have slightly different */
- /* structures; we need to synthesize a Type 1 dictionary on the fly */
-
- static void
- cff_make_private_dict( CFF_SubFont subfont,
- PS_Private priv )
- {
- CFF_Private cpriv = &subfont->private_dict;
- FT_UInt n, count;
-
-
- FT_ZERO( priv );
-
- count = priv->num_blue_values = cpriv->num_blue_values;
- for ( n = 0; n < count; n++ )
- priv->blue_values[n] = CFF_fixedToInt( cpriv->blue_values[n] );
-
- count = priv->num_other_blues = cpriv->num_other_blues;
- for ( n = 0; n < count; n++ )
- priv->other_blues[n] = CFF_fixedToInt( cpriv->other_blues[n] );
-
- count = priv->num_family_blues = cpriv->num_family_blues;
- for ( n = 0; n < count; n++ )
- priv->family_blues[n] = CFF_fixedToInt( cpriv->family_blues[n] );
-
- count = priv->num_family_other_blues = cpriv->num_family_other_blues;
- for ( n = 0; n < count; n++ )
- priv->family_other_blues[n] =
- CFF_fixedToInt( cpriv->family_other_blues[n] );
-
- priv->blue_scale = cpriv->blue_scale;
- priv->blue_shift = (FT_Int)cpriv->blue_shift;
- priv->blue_fuzz = (FT_Int)cpriv->blue_fuzz;
-
- priv->standard_width[0] = (FT_UShort)cpriv->standard_width;
- priv->standard_height[0] = (FT_UShort)cpriv->standard_height;
-
- count = priv->num_snap_widths = cpriv->num_snap_widths;
- for ( n = 0; n < count; n++ )
- priv->snap_widths[n] = (FT_Short)cpriv->snap_widths[n];
-
- count = priv->num_snap_heights = cpriv->num_snap_heights;
- for ( n = 0; n < count; n++ )
- priv->snap_heights[n] = (FT_Short)cpriv->snap_heights[n];
-
- priv->force_bold = cpriv->force_bold;
- priv->language_group = cpriv->language_group;
- priv->lenIV = cpriv->lenIV;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- cff_size_init( FT_Size cffsize ) /* CFF_Size */
- {
- CFF_Size size = (CFF_Size)cffsize;
- FT_Error error = FT_Err_Ok;
- PSH_Globals_Funcs funcs = cff_size_get_globals_funcs( size );
-
- FT_Memory memory = cffsize->face->memory;
- CFF_Internal internal = NULL;
- CFF_Face face = (CFF_Face)cffsize->face;
- CFF_Font font = (CFF_Font)face->extra.data;
-
- PS_PrivateRec priv;
-
- FT_UInt i;
-
- if ( !funcs )
- goto Exit;
-
- if ( FT_NEW( internal ) )
- goto Exit;
-
- cff_make_private_dict( &font->top_font, &priv );
- error = funcs->create( memory, &priv, &internal->topfont );
- if ( error )
- goto Exit;
-
- for ( i = font->num_subfonts; i > 0; i-- )
- {
- CFF_SubFont sub = font->subfonts[i - 1];
-
-
- cff_make_private_dict( sub, &priv );
- error = funcs->create( memory, &priv, &internal->subfonts[i - 1] );
- if ( error )
- goto Exit;
- }
-
- cffsize->internal->module_data = internal;
-
- size->strike_index = 0xFFFFFFFFUL;
-
- Exit:
- if ( error )
- {
- if ( internal )
- {
- for ( i = font->num_subfonts; i > 0; i-- )
- FT_FREE( internal->subfonts[i - 1] );
- FT_FREE( internal->topfont );
- }
-
- FT_FREE( internal );
- }
-
- return error;
- }
-
-
-#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
-
- FT_LOCAL_DEF( FT_Error )
- cff_size_select( FT_Size size,
- FT_ULong strike_index )
- {
- CFF_Size cffsize = (CFF_Size)size;
- PSH_Globals_Funcs funcs;
-
-
- cffsize->strike_index = strike_index;
-
- FT_Select_Metrics( size->face, strike_index );
-
- funcs = cff_size_get_globals_funcs( cffsize );
-
- if ( funcs )
- {
- CFF_Face face = (CFF_Face)size->face;
- CFF_Font font = (CFF_Font)face->extra.data;
- CFF_Internal internal = (CFF_Internal)size->internal->module_data;
-
- FT_Long top_upm = (FT_Long)font->top_font.font_dict.units_per_em;
- FT_UInt i;
-
-
- funcs->set_scale( internal->topfont,
- size->metrics.x_scale, size->metrics.y_scale,
- 0, 0 );
-
- for ( i = font->num_subfonts; i > 0; i-- )
- {
- CFF_SubFont sub = font->subfonts[i - 1];
- FT_Long sub_upm = (FT_Long)sub->font_dict.units_per_em;
- FT_Pos x_scale, y_scale;
-
-
- if ( top_upm != sub_upm )
- {
- x_scale = FT_MulDiv( size->metrics.x_scale, top_upm, sub_upm );
- y_scale = FT_MulDiv( size->metrics.y_scale, top_upm, sub_upm );
- }
- else
- {
- x_scale = size->metrics.x_scale;
- y_scale = size->metrics.y_scale;
- }
-
- funcs->set_scale( internal->subfonts[i - 1],
- x_scale, y_scale, 0, 0 );
- }
- }
-
- return FT_Err_Ok;
- }
-
-#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
-
-
- FT_LOCAL_DEF( FT_Error )
- cff_size_request( FT_Size size,
- FT_Size_Request req )
- {
- FT_Error error;
-
- CFF_Size cffsize = (CFF_Size)size;
- PSH_Globals_Funcs funcs;
-
-
-#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
-
- if ( FT_HAS_FIXED_SIZES( size->face ) )
- {
- CFF_Face cffface = (CFF_Face)size->face;
- SFNT_Service sfnt = (SFNT_Service)cffface->sfnt;
- FT_ULong strike_index;
-
-
- if ( sfnt->set_sbit_strike( cffface, req, &strike_index ) )
- cffsize->strike_index = 0xFFFFFFFFUL;
- else
- return cff_size_select( size, strike_index );
- }
-
-#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
-
- error = FT_Request_Metrics( size->face, req );
- if ( error )
- goto Exit;
-
- funcs = cff_size_get_globals_funcs( cffsize );
-
- if ( funcs )
- {
- CFF_Face cffface = (CFF_Face)size->face;
- CFF_Font font = (CFF_Font)cffface->extra.data;
- CFF_Internal internal = (CFF_Internal)size->internal->module_data;
-
- FT_Long top_upm = (FT_Long)font->top_font.font_dict.units_per_em;
- FT_UInt i;
-
-
- funcs->set_scale( internal->topfont,
- size->metrics.x_scale, size->metrics.y_scale,
- 0, 0 );
-
- for ( i = font->num_subfonts; i > 0; i-- )
- {
- CFF_SubFont sub = font->subfonts[i - 1];
- FT_Long sub_upm = (FT_Long)sub->font_dict.units_per_em;
- FT_Pos x_scale, y_scale;
-
-
- if ( top_upm != sub_upm )
- {
- x_scale = FT_MulDiv( size->metrics.x_scale, top_upm, sub_upm );
- y_scale = FT_MulDiv( size->metrics.y_scale, top_upm, sub_upm );
- }
- else
- {
- x_scale = size->metrics.x_scale;
- y_scale = size->metrics.y_scale;
- }
-
- funcs->set_scale( internal->subfonts[i - 1],
- x_scale, y_scale, 0, 0 );
- }
- }
-
- Exit:
- return error;
- }
-
-
- /**************************************************************************
- *
- * SLOT FUNCTIONS
- *
- */
-
- FT_LOCAL_DEF( void )
- cff_slot_done( FT_GlyphSlot slot )
- {
- if ( slot->internal )
- slot->internal->glyph_hints = NULL;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- cff_slot_init( FT_GlyphSlot slot )
- {
- CFF_Face face = (CFF_Face)slot->face;
- CFF_Font font = (CFF_Font)face->extra.data;
- PSHinter_Service pshinter = font->pshinter;
-
-
- if ( pshinter )
- {
- FT_Module module;
-
-
- module = FT_Get_Module( slot->library, "pshinter" );
- if ( module )
- {
- T2_Hints_Funcs funcs;
-
-
- funcs = pshinter->get_t2_funcs( module );
- slot->internal->glyph_hints = (void*)funcs;
- }
- }
-
- return FT_Err_Ok;
- }
-
-
- /**************************************************************************
- *
- * FACE FUNCTIONS
- *
- */
-
- static FT_String*
- cff_strcpy( FT_Memory memory,
- const FT_String* source )
- {
- FT_Error error;
- FT_String* result;
-
-
- FT_MEM_STRDUP( result, source );
-
- return result;
- }
-
-
- /* Strip all subset prefixes of the form `ABCDEF+'. Usually, there */
- /* is only one, but font names like `APCOOG+JFABTD+FuturaBQ-Bold' */
- /* have been seen in the wild. */
-
- static void
- remove_subset_prefix( FT_String* name )
- {
- FT_UInt32 i = 0, idx = 0;
-
-
- /* six ASCII uppercase letters followed by a plus sign */
- while ( 'A' <= name[i] && name[i++] <= 'Z' &&
- 'A' <= name[i] && name[i++] <= 'Z' &&
- 'A' <= name[i] && name[i++] <= 'Z' &&
- 'A' <= name[i] && name[i++] <= 'Z' &&
- 'A' <= name[i] && name[i++] <= 'Z' &&
- 'A' <= name[i] && name[i++] <= 'Z' &&
- name[i++] == '+' )
- {
- idx = i;
- }
-
- if ( idx )
- FT_MEM_MOVE( name, name + idx, ft_strlen( name + idx ) + 1 );
- }
-
-
- /* Remove the style part from the family name (if present). */
-
- static void
- remove_style( FT_String* family_name,
- const FT_String* style_name )
- {
- FT_String* f = family_name + ft_strlen( family_name );
- const FT_String* s = style_name + ft_strlen( style_name );
-
-
- /* compare strings moving backwards */
- while ( s > style_name )
- if ( f == family_name || *--s != *--f )
- return;
-
- /* terminate and remove special characters */
- do
- *f = '\0';
- while ( f-- > family_name &&
- ( *f == '-' || *f == ' ' || *f == '_' || *f == '+' ) );
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- cff_face_init( FT_Stream stream,
- FT_Face cffface, /* CFF_Face */
- FT_Int face_index,
- FT_Int num_params,
- FT_Parameter* params )
- {
- CFF_Face face = (CFF_Face)cffface;
- FT_Error error;
- SFNT_Service sfnt;
- FT_Service_PsCMaps psnames;
- PSHinter_Service pshinter;
- PSAux_Service psaux;
- FT_Service_CFFLoad cffload;
- FT_Bool pure_cff = 1;
- FT_Bool cff2 = 0;
- FT_Bool sfnt_format = 0;
- FT_Library library = cffface->driver->root.library;
-
-
- sfnt = (SFNT_Service)FT_Get_Module_Interface( library,
- "sfnt" );
- if ( !sfnt )
- {
- FT_ERROR(( "cff_face_init: cannot access `sfnt' module\n" ));
- error = FT_THROW( Missing_Module );
- goto Exit;
- }
-
- FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS );
-
- pshinter = (PSHinter_Service)FT_Get_Module_Interface( library,
- "pshinter" );
-
- psaux = (PSAux_Service)FT_Get_Module_Interface( library,
- "psaux" );
- if ( !psaux )
- {
- FT_ERROR(( "cff_face_init: cannot access `psaux' module\n" ));
- error = FT_THROW( Missing_Module );
- goto Exit;
- }
- face->psaux = psaux;
-
- FT_FACE_FIND_GLOBAL_SERVICE( face, cffload, CFF_LOAD );
-
- FT_TRACE2(( "CFF driver\n" ));
-
- /* create input stream from resource */
- if ( FT_STREAM_SEEK( 0 ) )
- goto Exit;
-
- /* check whether we have a valid OpenType file */
- FT_TRACE2(( " " ));
- error = sfnt->init_face( stream, face, face_index, num_params, params );
- if ( !error )
- {
- if ( face->format_tag != TTAG_OTTO ) /* `OTTO'; OpenType/CFF font */
- {
- FT_TRACE2(( " not an OpenType/CFF font\n" ));
- error = FT_THROW( Unknown_File_Format );
- goto Exit;
- }
-
- /* if we are performing a simple font format check, exit immediately */
- if ( face_index < 0 )
- return FT_Err_Ok;
-
- sfnt_format = 1;
-
- /* now, the font can be either an OpenType/CFF font, or an SVG CEF */
- /* font; in the latter case it doesn't have a `head' table */
- error = face->goto_table( face, TTAG_head, stream, 0 );
- if ( !error )
- {
- pure_cff = 0;
-
- /* load font directory */
- error = sfnt->load_face( stream, face, face_index,
- num_params, params );
- if ( error )
- goto Exit;
- }
- else
- {
- /* load the `cmap' table explicitly */
- error = sfnt->load_cmap( face, stream );
- if ( error )
- goto Exit;
- }
-
- /* now load the CFF part of the file; */
- /* give priority to CFF2 */
- error = face->goto_table( face, TTAG_CFF2, stream, 0 );
- if ( !error )
- {
- cff2 = 1;
- face->is_cff2 = cff2;
- }
-
- if ( FT_ERR_EQ( error, Table_Missing ) )
- error = face->goto_table( face, TTAG_CFF, stream, 0 );
-
- if ( error )
- goto Exit;
- }
- else
- {
- /* rewind to start of file; we are going to load a pure-CFF font */
- if ( FT_STREAM_SEEK( 0 ) )
- goto Exit;
- error = FT_Err_Ok;
- }
-
- /* now load and parse the CFF table in the file */
- {
- CFF_Font cff = NULL;
- CFF_FontRecDict dict;
- FT_Memory memory = cffface->memory;
- FT_Int32 flags;
- FT_UInt i;
-
-
- if ( FT_NEW( cff ) )
- goto Exit;
-
- face->extra.data = cff;
- error = cff_font_load( library,
- stream,
- face_index,
- cff,
- face,
- pure_cff,
- cff2 );
- if ( error )
- goto Exit;
-
- /* if we are performing a simple font format check, exit immediately */
- /* (this is here for pure CFF) */
- if ( face_index < 0 )
- {
- cffface->num_faces = (FT_Long)cff->num_faces;
- return FT_Err_Ok;
- }
-
- cff->pshinter = pshinter;
- cff->psnames = psnames;
- cff->cffload = cffload;
-
- cffface->face_index = face_index & 0xFFFF;
-
- /* Complement the root flags with some interesting information. */
- /* Note that this is only necessary for pure CFF and CEF fonts; */
- /* SFNT based fonts use the `name' table instead. */
-
- cffface->num_glyphs = (FT_Long)cff->num_glyphs;
-
- dict = &cff->top_font.font_dict;
-
- /* we need the `psnames' module for CFF and CEF formats */
- /* which aren't CID-keyed */
- if ( dict->cid_registry == 0xFFFFU && !psnames )
- {
- FT_ERROR(( "cff_face_init:"
- " cannot open CFF & CEF fonts\n" ));
- FT_ERROR(( " "
- " without the `psnames' module\n" ));
- error = FT_THROW( Missing_Module );
- goto Exit;
- }
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- {
- FT_UInt idx;
- FT_String* s;
-
-
- FT_TRACE4(( "SIDs\n" ));
-
- /* dump string index, including default strings for convenience */
- for ( idx = 0; idx <= 390; idx++ )
- {
- s = cff_index_get_sid_string( cff, idx );
- if ( s )
- FT_TRACE4(( " %5d %s\n", idx, s ));
- }
-
- /* In Multiple Master CFFs, two SIDs hold the Normalize Design */
- /* Vector (NDV) and Convert Design Vector (CDV) charstrings, */
- /* which may contain null bytes in the middle of the data, too. */
- /* We thus access `cff->strings' directly. */
- for ( idx = 1; idx < cff->num_strings; idx++ )
- {
- FT_Byte* s1 = cff->strings[idx - 1];
- FT_Byte* s2 = cff->strings[idx];
- FT_PtrDist s1len = s2 - s1 - 1; /* without the final null byte */
- FT_PtrDist l;
-
-
- FT_TRACE4(( " %5d ", idx + 390 ));
- for ( l = 0; l < s1len; l++ )
- FT_TRACE4(( "%c", s1[l] ));
- FT_TRACE4(( "\n" ));
- }
-
- /* print last element */
- if ( cff->num_strings )
- {
- FT_Byte* s1 = cff->strings[cff->num_strings - 1];
- FT_Byte* s2 = cff->string_pool + cff->string_pool_size;
- FT_PtrDist s1len = s2 - s1 - 1;
- FT_PtrDist l;
-
-
- FT_TRACE4(( " %5d ", cff->num_strings + 390 ));
- for ( l = 0; l < s1len; l++ )
- FT_TRACE4(( "%c", s1[l] ));
- FT_TRACE4(( "\n" ));
- }
- }
-#endif /* FT_DEBUG_LEVEL_TRACE */
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- {
- FT_UInt instance_index = (FT_UInt)face_index >> 16;
-
-
- if ( FT_HAS_MULTIPLE_MASTERS( cffface ) )
- {
- error = FT_Set_Named_Instance( cffface, instance_index );
- if ( error )
- goto Exit;
- }
- }
-#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
-
- if ( !dict->has_font_matrix )
- dict->units_per_em = pure_cff ? 1000 : face->root.units_per_EM;
-
- /* Normalize the font matrix so that `matrix->yy' is 1; if */
- /* it is zero, we use `matrix->yx' instead. The scaling is */
- /* done with `units_per_em' then (at this point, it already */
- /* contains the scaling factor, but without normalization */
- /* of the matrix). */
- /* */
- /* Note that the offsets must be expressed in integer font */
- /* units. */
-
- {
- FT_Matrix* matrix = &dict->font_matrix;
- FT_Vector* offset = &dict->font_offset;
- FT_ULong* upm = &dict->units_per_em;
- FT_Fixed temp;
-
-
- temp = matrix->yy ? FT_ABS( matrix->yy )
- : FT_ABS( matrix->yx );
-
- if ( temp != 0x10000L )
- {
- *upm = (FT_ULong)FT_DivFix( (FT_Long)*upm, temp );
-
- matrix->xx = FT_DivFix( matrix->xx, temp );
- matrix->yx = FT_DivFix( matrix->yx, temp );
- matrix->xy = FT_DivFix( matrix->xy, temp );
- matrix->yy = FT_DivFix( matrix->yy, temp );
- offset->x = FT_DivFix( offset->x, temp );
- offset->y = FT_DivFix( offset->y, temp );
- }
-
- offset->x >>= 16;
- offset->y >>= 16;
- }
-
- for ( i = cff->num_subfonts; i > 0; i-- )
- {
- CFF_FontRecDict sub = &cff->subfonts[i - 1]->font_dict;
- CFF_FontRecDict top = &cff->top_font.font_dict;
-
- FT_Matrix* matrix;
- FT_Vector* offset;
- FT_ULong* upm;
- FT_Fixed temp;
-
-
- if ( sub->has_font_matrix )
- {
- FT_Long scaling;
-
-
- /* if we have a top-level matrix, */
- /* concatenate the subfont matrix */
-
- if ( top->has_font_matrix )
- {
- if ( top->units_per_em > 1 && sub->units_per_em > 1 )
- scaling = (FT_Long)FT_MIN( top->units_per_em,
- sub->units_per_em );
- else
- scaling = 1;
-
- FT_Matrix_Multiply_Scaled( &top->font_matrix,
- &sub->font_matrix,
- scaling );
- FT_Vector_Transform_Scaled( &sub->font_offset,
- &top->font_matrix,
- scaling );
-
- sub->units_per_em = (FT_ULong)
- FT_MulDiv( (FT_Long)sub->units_per_em,
- (FT_Long)top->units_per_em,
- scaling );
- }
- }
- else
- {
- sub->font_matrix = top->font_matrix;
- sub->font_offset = top->font_offset;
-
- sub->units_per_em = top->units_per_em;
- }
-
- matrix = &sub->font_matrix;
- offset = &sub->font_offset;
- upm = &sub->units_per_em;
-
- temp = matrix->yy ? FT_ABS( matrix->yy )
- : FT_ABS( matrix->yx );
-
-
- if ( temp != 0x10000L )
- {
- *upm = (FT_ULong)FT_DivFix( (FT_Long)*upm, temp );
-
- matrix->xx = FT_DivFix( matrix->xx, temp );
- matrix->yx = FT_DivFix( matrix->yx, temp );
- matrix->xy = FT_DivFix( matrix->xy, temp );
- matrix->yy = FT_DivFix( matrix->yy, temp );
- offset->x = FT_DivFix( offset->x, temp );
- offset->y = FT_DivFix( offset->y, temp );
- }
-
- offset->x >>= 16;
- offset->y >>= 16;
- }
-
- if ( pure_cff )
- {
- char* style_name = NULL;
-
-
- /* set up num_faces */
- cffface->num_faces = (FT_Long)cff->num_faces;
-
- /* compute number of glyphs */
- if ( dict->cid_registry != 0xFFFFU )
- cffface->num_glyphs = (FT_Long)( cff->charset.max_cid + 1 );
- else
- cffface->num_glyphs = (FT_Long)cff->charstrings_index.count;
-
- /* set global bbox, as well as EM size */
- cffface->bbox.xMin = dict->font_bbox.xMin >> 16;
- cffface->bbox.yMin = dict->font_bbox.yMin >> 16;
- /* no `U' suffix here to 0xFFFF! */
- cffface->bbox.xMax = ( dict->font_bbox.xMax + 0xFFFF ) >> 16;
- cffface->bbox.yMax = ( dict->font_bbox.yMax + 0xFFFF ) >> 16;
-
- cffface->units_per_EM = (FT_UShort)( dict->units_per_em );
-
- cffface->ascender = (FT_Short)( cffface->bbox.yMax );
- cffface->descender = (FT_Short)( cffface->bbox.yMin );
-
- cffface->height = (FT_Short)( ( cffface->units_per_EM * 12 ) / 10 );
- if ( cffface->height < cffface->ascender - cffface->descender )
- cffface->height = (FT_Short)( cffface->ascender -
- cffface->descender );
-
- cffface->underline_position =
- (FT_Short)( dict->underline_position >> 16 );
- cffface->underline_thickness =
- (FT_Short)( dict->underline_thickness >> 16 );
-
- /* retrieve font family & style name */
- if ( dict->family_name )
- {
- char* family_name;
-
-
- family_name = cff_index_get_sid_string( cff, dict->family_name );
- if ( family_name )
- cffface->family_name = cff_strcpy( memory, family_name );
- }
-
- if ( !cffface->family_name )
- {
- cffface->family_name = cff_index_get_name(
- cff,
- (FT_UInt)( face_index & 0xFFFF ) );
- if ( cffface->family_name )
- remove_subset_prefix( cffface->family_name );
- }
-
- if ( cffface->family_name )
- {
- char* full = cff_index_get_sid_string( cff,
- dict->full_name );
- char* fullp = full;
- char* family = cffface->family_name;
-
-
- /* We try to extract the style name from the full name. */
- /* We need to ignore spaces and dashes during the search. */
- if ( full && family )
- {
- while ( *fullp )
- {
- /* skip common characters at the start of both strings */
- if ( *fullp == *family )
- {
- family++;
- fullp++;
- continue;
- }
-
- /* ignore spaces and dashes in full name during comparison */
- if ( *fullp == ' ' || *fullp == '-' )
- {
- fullp++;
- continue;
- }
-
- /* ignore spaces and dashes in family name during comparison */
- if ( *family == ' ' || *family == '-' )
- {
- family++;
- continue;
- }
-
- if ( !*family && *fullp )
- {
- /* The full name begins with the same characters as the */
- /* family name, with spaces and dashes removed. In this */
- /* case, the remaining string in `fullp' will be used as */
- /* the style name. */
- style_name = cff_strcpy( memory, fullp );
-
- /* remove the style part from the family name (if present) */
- if ( style_name )
- remove_style( cffface->family_name, style_name );
- }
- break;
- }
- }
- }
- else
- {
- char *cid_font_name =
- cff_index_get_sid_string( cff,
- dict->cid_font_name );
-
-
- /* do we have a `/FontName' for a CID-keyed font? */
- if ( cid_font_name )
- cffface->family_name = cff_strcpy( memory, cid_font_name );
- }
-
- if ( style_name )
- cffface->style_name = style_name;
- else
- /* assume "Regular" style if we don't know better */
- cffface->style_name = cff_strcpy( memory, "Regular" );
-
- /********************************************************************
- *
- * Compute face flags.
- */
- flags = FT_FACE_FLAG_SCALABLE | /* scalable outlines */
- FT_FACE_FLAG_HORIZONTAL | /* horizontal data */
- FT_FACE_FLAG_HINTER; /* has native hinter */
-
- if ( sfnt_format )
- flags |= FT_FACE_FLAG_SFNT;
-
- /* fixed width font? */
- if ( dict->is_fixed_pitch )
- flags |= FT_FACE_FLAG_FIXED_WIDTH;
-
- /* XXX: WE DO NOT SUPPORT KERNING METRICS IN THE GPOS TABLE FOR NOW */
-#if 0
- /* kerning available? */
- if ( face->kern_pairs )
- flags |= FT_FACE_FLAG_KERNING;
-#endif
-
- cffface->face_flags |= flags;
-
- /********************************************************************
- *
- * Compute style flags.
- */
- flags = 0;
-
- if ( dict->italic_angle )
- flags |= FT_STYLE_FLAG_ITALIC;
-
- {
- char *weight = cff_index_get_sid_string( cff,
- dict->weight );
-
-
- if ( weight )
- if ( !ft_strcmp( weight, "Bold" ) ||
- !ft_strcmp( weight, "Black" ) )
- flags |= FT_STYLE_FLAG_BOLD;
- }
-
- /* double check */
- if ( !(flags & FT_STYLE_FLAG_BOLD) && cffface->style_name )
- if ( !ft_strncmp( cffface->style_name, "Bold", 4 ) ||
- !ft_strncmp( cffface->style_name, "Black", 5 ) )
- flags |= FT_STYLE_FLAG_BOLD;
-
- cffface->style_flags = flags;
- }
-
- /* CID-keyed CFF or CFF2 fonts don't have glyph names -- the SFNT */
- /* loader has unset this flag because of the 3.0 `post' table. */
- if ( dict->cid_registry == 0xFFFFU && !cff2 )
- cffface->face_flags |= FT_FACE_FLAG_GLYPH_NAMES;
-
- if ( dict->cid_registry != 0xFFFFU && pure_cff )
- cffface->face_flags |= FT_FACE_FLAG_CID_KEYED;
-
- /********************************************************************
- *
- * Compute char maps.
- */
-
- /* Try to synthesize a Unicode charmap if there is none available */
- /* already. If an OpenType font contains a Unicode "cmap", we */
- /* will use it, whatever be in the CFF part of the file. */
- {
- FT_CharMapRec cmaprec;
- FT_CharMap cmap;
- FT_Int nn;
- CFF_Encoding encoding = &cff->encoding;
-
-
- for ( nn = 0; nn < cffface->num_charmaps; nn++ )
- {
- cmap = cffface->charmaps[nn];
-
- /* Windows Unicode? */
- if ( cmap->platform_id == TT_PLATFORM_MICROSOFT &&
- cmap->encoding_id == TT_MS_ID_UNICODE_CS )
- goto Skip_Unicode;
-
- /* Apple Unicode platform id? */
- if ( cmap->platform_id == TT_PLATFORM_APPLE_UNICODE )
- goto Skip_Unicode; /* Apple Unicode */
- }
-
- /* since CID-keyed fonts don't contain glyph names, we can't */
- /* construct a cmap */
- if ( pure_cff && cff->top_font.font_dict.cid_registry != 0xFFFFU )
- goto Exit;
-
- /* we didn't find a Unicode charmap -- synthesize one */
- cmaprec.face = cffface;
- cmaprec.platform_id = TT_PLATFORM_MICROSOFT;
- cmaprec.encoding_id = TT_MS_ID_UNICODE_CS;
- cmaprec.encoding = FT_ENCODING_UNICODE;
-
- nn = cffface->num_charmaps;
-
- error = FT_CMap_New( &cff_cmap_unicode_class_rec, NULL,
- &cmaprec, NULL );
- if ( error &&
- FT_ERR_NEQ( error, No_Unicode_Glyph_Name ) &&
- FT_ERR_NEQ( error, Unimplemented_Feature ) )
- goto Exit;
- error = FT_Err_Ok;
-
- /* if no Unicode charmap was previously selected, select this one */
- if ( !cffface->charmap && nn != cffface->num_charmaps )
- cffface->charmap = cffface->charmaps[nn];
-
- Skip_Unicode:
- if ( encoding->count > 0 )
- {
- FT_CMap_Class clazz;
-
-
- cmaprec.face = cffface;
- cmaprec.platform_id = TT_PLATFORM_ADOBE; /* Adobe platform id */
-
- if ( encoding->offset == 0 )
- {
- cmaprec.encoding_id = TT_ADOBE_ID_STANDARD;
- cmaprec.encoding = FT_ENCODING_ADOBE_STANDARD;
- clazz = &cff_cmap_encoding_class_rec;
- }
- else if ( encoding->offset == 1 )
- {
- cmaprec.encoding_id = TT_ADOBE_ID_EXPERT;
- cmaprec.encoding = FT_ENCODING_ADOBE_EXPERT;
- clazz = &cff_cmap_encoding_class_rec;
- }
- else
- {
- cmaprec.encoding_id = TT_ADOBE_ID_CUSTOM;
- cmaprec.encoding = FT_ENCODING_ADOBE_CUSTOM;
- clazz = &cff_cmap_encoding_class_rec;
- }
-
- error = FT_CMap_New( clazz, NULL, &cmaprec, NULL );
- }
- }
- }
-
- Exit:
- return error;
- }
-
-
- FT_LOCAL_DEF( void )
- cff_face_done( FT_Face cffface ) /* CFF_Face */
- {
- CFF_Face face = (CFF_Face)cffface;
- FT_Memory memory;
- SFNT_Service sfnt;
-
-
- if ( !face )
- return;
-
- memory = cffface->memory;
- sfnt = (SFNT_Service)face->sfnt;
-
- if ( sfnt )
- sfnt->done_face( face );
-
- {
- CFF_Font cff = (CFF_Font)face->extra.data;
-
-
- if ( cff )
- {
- cff_font_done( cff );
- FT_FREE( face->extra.data );
- }
- }
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- cff_done_blend( cffface );
- face->blend = NULL;
-#endif
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- cff_driver_init( FT_Module module ) /* CFF_Driver */
- {
- PS_Driver driver = (PS_Driver)module;
-
- FT_UInt32 seed;
-
-
- /* set default property values, cf. `ftcffdrv.h' */
- driver->hinting_engine = FT_HINTING_ADOBE;
-
- driver->no_stem_darkening = TRUE;
-
- driver->darken_params[0] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1;
- driver->darken_params[1] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1;
- driver->darken_params[2] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2;
- driver->darken_params[3] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2;
- driver->darken_params[4] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3;
- driver->darken_params[5] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3;
- driver->darken_params[6] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4;
- driver->darken_params[7] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4;
-
- /* compute random seed from some memory addresses */
- seed = (FT_UInt32)( (FT_Offset)(char*)&seed ^
- (FT_Offset)(char*)&module ^
- (FT_Offset)(char*)module->memory );
- seed = seed ^ ( seed >> 10 ) ^ ( seed >> 20 );
-
- driver->random_seed = (FT_Int32)seed;
- if ( driver->random_seed < 0 )
- driver->random_seed = -driver->random_seed;
- else if ( driver->random_seed == 0 )
- driver->random_seed = 123456789;
-
- return FT_Err_Ok;
- }
-
-
- FT_LOCAL_DEF( void )
- cff_driver_done( FT_Module module ) /* CFF_Driver */
- {
- FT_UNUSED( module );
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cff/cffobjs.h b/contrib/libs/freetype/src/cff/cffobjs.h
deleted file mode 100644
index 91ad83b1cd..0000000000
--- a/contrib/libs/freetype/src/cff/cffobjs.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************
- *
- * cffobjs.h
- *
- * OpenType objects manager (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef CFFOBJS_H_
-#define CFFOBJS_H_
-
-
-
-
-FT_BEGIN_HEADER
-
-
- FT_LOCAL( FT_Error )
- cff_size_init( FT_Size size ); /* CFF_Size */
-
- FT_LOCAL( void )
- cff_size_done( FT_Size size ); /* CFF_Size */
-
- FT_LOCAL( FT_Error )
- cff_size_request( FT_Size size,
- FT_Size_Request req );
-
-#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
-
- FT_LOCAL( FT_Error )
- cff_size_select( FT_Size size,
- FT_ULong strike_index );
-
-#endif
-
- FT_LOCAL( void )
- cff_slot_done( FT_GlyphSlot slot );
-
- FT_LOCAL( FT_Error )
- cff_slot_init( FT_GlyphSlot slot );
-
-
- /**************************************************************************
- *
- * Face functions
- */
- FT_LOCAL( FT_Error )
- cff_face_init( FT_Stream stream,
- FT_Face face, /* CFF_Face */
- FT_Int face_index,
- FT_Int num_params,
- FT_Parameter* params );
-
- FT_LOCAL( void )
- cff_face_done( FT_Face face ); /* CFF_Face */
-
-
- /**************************************************************************
- *
- * Driver functions
- */
- FT_LOCAL( FT_Error )
- cff_driver_init( FT_Module module ); /* PS_Driver */
-
- FT_LOCAL( void )
- cff_driver_done( FT_Module module ); /* PS_Driver */
-
-
-FT_END_HEADER
-
-#endif /* CFFOBJS_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cff/cffparse.c b/contrib/libs/freetype/src/cff/cffparse.c
deleted file mode 100644
index 92a69c3b51..0000000000
--- a/contrib/libs/freetype/src/cff/cffparse.c
+++ /dev/null
@@ -1,1550 +0,0 @@
-/****************************************************************************
- *
- * cffparse.c
- *
- * CFF token stream parser (body)
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include "cffparse.h"
-#include <freetype/internal/ftstream.h>
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftcalc.h>
-#include <freetype/internal/psaux.h>
-#include <freetype/ftlist.h>
-
-#include "cfferrs.h"
-#include "cffload.h"
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT cffparse
-
-
- FT_LOCAL_DEF( FT_Error )
- cff_parser_init( CFF_Parser parser,
- FT_UInt code,
- void* object,
- FT_Library library,
- FT_UInt stackSize,
- FT_UShort num_designs,
- FT_UShort num_axes )
- {
- FT_Memory memory = library->memory; /* for FT_NEW_ARRAY */
- FT_Error error; /* for FT_NEW_ARRAY */
-
-
- FT_ZERO( parser );
-
-#if 0
- parser->top = parser->stack;
-#endif
- parser->object_code = code;
- parser->object = object;
- parser->library = library;
- parser->num_designs = num_designs;
- parser->num_axes = num_axes;
-
- /* allocate the stack buffer */
- if ( FT_QNEW_ARRAY( parser->stack, stackSize ) )
- goto Exit;
-
- parser->stackSize = stackSize;
- parser->top = parser->stack; /* empty stack */
-
- Exit:
- return error;
- }
-
-
- FT_LOCAL_DEF( void )
- cff_parser_done( CFF_Parser parser )
- {
- FT_Memory memory = parser->library->memory; /* for FT_FREE */
-
-
- FT_FREE( parser->stack );
-
-#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
- FT_List_Finalize( &parser->t2_strings, NULL, memory, NULL );
-#endif
- }
-
-
- /* The parser limit checks in the next two functions are supposed */
- /* to detect the immediate crossing of the stream boundary. They */
- /* shall not be triggered from the distant t2_strings buffers. */
-
- /* read an integer */
- static FT_Long
- cff_parse_integer( FT_Byte* start,
- FT_Byte* limit )
- {
- FT_Byte* p = start;
- FT_Int v = *p++;
- FT_Long val = 0;
-
-
- if ( v == 28 )
- {
- if ( p + 2 > limit && limit >= p )
- goto Bad;
-
- val = (FT_Short)( ( (FT_UShort)p[0] << 8 ) | p[1] );
- }
- else if ( v == 29 )
- {
- if ( p + 4 > limit && limit >= p )
- goto Bad;
-
- val = (FT_Long)( ( (FT_ULong)p[0] << 24 ) |
- ( (FT_ULong)p[1] << 16 ) |
- ( (FT_ULong)p[2] << 8 ) |
- (FT_ULong)p[3] );
- }
- else if ( v < 247 )
- {
- val = v - 139;
- }
- else if ( v < 251 )
- {
- if ( p + 1 > limit && limit >= p )
- goto Bad;
-
- val = ( v - 247 ) * 256 + p[0] + 108;
- }
- else
- {
- if ( p + 1 > limit && limit >= p )
- goto Bad;
-
- val = -( v - 251 ) * 256 - p[0] - 108;
- }
-
- Exit:
- return val;
-
- Bad:
- val = 0;
- FT_TRACE4(( "!!!END OF DATA:!!!" ));
- goto Exit;
- }
-
-
- static const FT_Long power_tens[] =
- {
- 1L,
- 10L,
- 100L,
- 1000L,
- 10000L,
- 100000L,
- 1000000L,
- 10000000L,
- 100000000L,
- 1000000000L
- };
-
- /* maximum values allowed for multiplying */
- /* with the corresponding `power_tens' element */
- static const FT_Long power_ten_limits[] =
- {
- FT_LONG_MAX / 1L,
- FT_LONG_MAX / 10L,
- FT_LONG_MAX / 100L,
- FT_LONG_MAX / 1000L,
- FT_LONG_MAX / 10000L,
- FT_LONG_MAX / 100000L,
- FT_LONG_MAX / 1000000L,
- FT_LONG_MAX / 10000000L,
- FT_LONG_MAX / 100000000L,
- FT_LONG_MAX / 1000000000L,
- };
-
-
- /* read a real */
- static FT_Fixed
- cff_parse_real( FT_Byte* start,
- FT_Byte* limit,
- FT_Long power_ten,
- FT_Long* scaling )
- {
- FT_Byte* p = start;
- FT_Int nib;
- FT_UInt phase;
-
- FT_Long result, number, exponent;
- FT_Int sign = 0, exponent_sign = 0, have_overflow = 0;
- FT_Long exponent_add, integer_length, fraction_length;
-
-
- if ( scaling )
- *scaling = 0;
-
- result = 0;
-
- number = 0;
- exponent = 0;
-
- exponent_add = 0;
- integer_length = 0;
- fraction_length = 0;
-
- /* First of all, read the integer part. */
- phase = 4;
-
- for (;;)
- {
- /* If we entered this iteration with phase == 4, we need to */
- /* read a new byte. This also skips past the initial 0x1E. */
- if ( phase )
- {
- p++;
-
- /* Make sure we don't read past the end. */
- if ( p + 1 > limit && limit >= p )
- goto Bad;
- }
-
- /* Get the nibble. */
- nib = (FT_Int)( p[0] >> phase ) & 0xF;
- phase = 4 - phase;
-
- if ( nib == 0xE )
- sign = 1;
- else if ( nib > 9 )
- break;
- else
- {
- /* Increase exponent if we can't add the digit. */
- if ( number >= 0xCCCCCCCL )
- exponent_add++;
- /* Skip leading zeros. */
- else if ( nib || number )
- {
- integer_length++;
- number = number * 10 + nib;
- }
- }
- }
-
- /* Read fraction part, if any. */
- if ( nib == 0xA )
- for (;;)
- {
- /* If we entered this iteration with phase == 4, we need */
- /* to read a new byte. */
- if ( phase )
- {
- p++;
-
- /* Make sure we don't read past the end. */
- if ( p + 1 > limit && limit >= p )
- goto Bad;
- }
-
- /* Get the nibble. */
- nib = ( p[0] >> phase ) & 0xF;
- phase = 4 - phase;
- if ( nib >= 10 )
- break;
-
- /* Skip leading zeros if possible. */
- if ( !nib && !number )
- exponent_add--;
- /* Only add digit if we don't overflow. */
- else if ( number < 0xCCCCCCCL && fraction_length < 9 )
- {
- fraction_length++;
- number = number * 10 + nib;
- }
- }
-
- /* Read exponent, if any. */
- if ( nib == 12 )
- {
- exponent_sign = 1;
- nib = 11;
- }
-
- if ( nib == 11 )
- {
- for (;;)
- {
- /* If we entered this iteration with phase == 4, */
- /* we need to read a new byte. */
- if ( phase )
- {
- p++;
-
- /* Make sure we don't read past the end. */
- if ( p + 1 > limit && limit >= p )
- goto Bad;
- }
-
- /* Get the nibble. */
- nib = ( p[0] >> phase ) & 0xF;
- phase = 4 - phase;
- if ( nib >= 10 )
- break;
-
- /* Arbitrarily limit exponent. */
- if ( exponent > 1000 )
- have_overflow = 1;
- else
- exponent = exponent * 10 + nib;
- }
-
- if ( exponent_sign )
- exponent = -exponent;
- }
-
- if ( !number )
- goto Exit;
-
- if ( have_overflow )
- {
- if ( exponent_sign )
- goto Underflow;
- else
- goto Overflow;
- }
-
- /* We don't check `power_ten' and `exponent_add'. */
- exponent += power_ten + exponent_add;
-
- if ( scaling )
- {
- /* Only use `fraction_length'. */
- fraction_length += integer_length;
- exponent += integer_length;
-
- if ( fraction_length <= 5 )
- {
- if ( number > 0x7FFFL )
- {
- result = FT_DivFix( number, 10 );
- *scaling = exponent - fraction_length + 1;
- }
- else
- {
- if ( exponent > 0 )
- {
- FT_Long new_fraction_length, shift;
-
-
- /* Make `scaling' as small as possible. */
- new_fraction_length = FT_MIN( exponent, 5 );
- shift = new_fraction_length - fraction_length;
-
- if ( shift > 0 )
- {
- exponent -= new_fraction_length;
- number *= power_tens[shift];
- if ( number > 0x7FFFL )
- {
- number /= 10;
- exponent += 1;
- }
- }
- else
- exponent -= fraction_length;
- }
- else
- exponent -= fraction_length;
-
- result = (FT_Long)( (FT_ULong)number << 16 );
- *scaling = exponent;
- }
- }
- else
- {
- if ( ( number / power_tens[fraction_length - 5] ) > 0x7FFFL )
- {
- result = FT_DivFix( number, power_tens[fraction_length - 4] );
- *scaling = exponent - 4;
- }
- else
- {
- result = FT_DivFix( number, power_tens[fraction_length - 5] );
- *scaling = exponent - 5;
- }
- }
- }
- else
- {
- integer_length += exponent;
- fraction_length -= exponent;
-
- if ( integer_length > 5 )
- goto Overflow;
- if ( integer_length < -5 )
- goto Underflow;
-
- /* Remove non-significant digits. */
- if ( integer_length < 0 )
- {
- number /= power_tens[-integer_length];
- fraction_length += integer_length;
- }
-
- /* this can only happen if exponent was non-zero */
- if ( fraction_length == 10 )
- {
- number /= 10;
- fraction_length -= 1;
- }
-
- /* Convert into 16.16 format. */
- if ( fraction_length > 0 )
- {
- if ( ( number / power_tens[fraction_length] ) > 0x7FFFL )
- goto Exit;
-
- result = FT_DivFix( number, power_tens[fraction_length] );
- }
- else
- {
- number *= power_tens[-fraction_length];
-
- if ( number > 0x7FFFL )
- goto Overflow;
-
- result = (FT_Long)( (FT_ULong)number << 16 );
- }
- }
-
- Exit:
- if ( sign )
- result = -result;
-
- return result;
-
- Overflow:
- result = 0x7FFFFFFFL;
- FT_TRACE4(( "!!!OVERFLOW:!!!" ));
- goto Exit;
-
- Underflow:
- result = 0;
- FT_TRACE4(( "!!!UNDERFLOW:!!!" ));
- goto Exit;
-
- Bad:
- result = 0;
- FT_TRACE4(( "!!!END OF DATA:!!!" ));
- goto Exit;
- }
-
-
- /* read a number, either integer or real */
- FT_LOCAL_DEF( FT_Long )
- cff_parse_num( CFF_Parser parser,
- FT_Byte** d )
- {
- if ( **d == 30 )
- {
- /* binary-coded decimal is truncated to integer */
- return cff_parse_real( *d, parser->limit, 0, NULL ) >> 16;
- }
-
- else if ( **d == 255 )
- {
- /* 16.16 fixed-point is used internally for CFF2 blend results. */
- /* Since these are trusted values, a limit check is not needed. */
-
- /* After the 255, 4 bytes give the number. */
- /* The blend value is converted to integer, with rounding; */
- /* due to the right-shift we don't need the lowest byte. */
-#if 0
- return (FT_Short)(
- ( ( ( (FT_UInt32)*( d[0] + 1 ) << 24 ) |
- ( (FT_UInt32)*( d[0] + 2 ) << 16 ) |
- ( (FT_UInt32)*( d[0] + 3 ) << 8 ) |
- (FT_UInt32)*( d[0] + 4 ) ) + 0x8000U ) >> 16 );
-#else
- return (FT_Short)(
- ( ( ( (FT_UInt32)*( d[0] + 1 ) << 16 ) |
- ( (FT_UInt32)*( d[0] + 2 ) << 8 ) |
- (FT_UInt32)*( d[0] + 3 ) ) + 0x80U ) >> 8 );
-#endif
- }
-
- else
- return cff_parse_integer( *d, parser->limit );
- }
-
-
- /* read a floating point number, either integer or real */
- static FT_Fixed
- do_fixed( CFF_Parser parser,
- FT_Byte** d,
- FT_Long scaling )
- {
- if ( **d == 30 )
- return cff_parse_real( *d, parser->limit, scaling, NULL );
- else if ( **d == 255 )
- {
- FT_Fixed val = (FT_Int32)( ( ( (FT_UInt32)*( d[0] + 1 ) << 24 ) |
- ( (FT_UInt32)*( d[0] + 2 ) << 16 ) |
- ( (FT_UInt32)*( d[0] + 3 ) << 8 ) |
- (FT_UInt32)*( d[0] + 4 ) ) );
-
- if ( scaling )
- {
- if ( FT_ABS( val ) > power_ten_limits[scaling] )
- {
- FT_TRACE4(( "!!!OVERFLOW:!!!" ));
- return val > 0 ? 0x7FFFFFFFL : -0x7FFFFFFFL;
- }
- val *= power_tens[scaling];
- }
- return val;
- }
- else
- {
- FT_Long val = cff_parse_integer( *d, parser->limit );
-
-
- if ( scaling )
- {
- if ( ( FT_ABS( val ) << 16 ) > power_ten_limits[scaling] )
- {
- val = val > 0 ? 0x7FFFFFFFL : -0x7FFFFFFFL;
- goto Overflow;
- }
-
- val *= power_tens[scaling];
- }
-
- if ( val > 0x7FFF )
- {
- val = 0x7FFFFFFFL;
- goto Overflow;
- }
- else if ( val < -0x7FFF )
- {
- val = -0x7FFFFFFFL;
- goto Overflow;
- }
-
- return (FT_Long)( (FT_ULong)val << 16 );
-
- Overflow:
- FT_TRACE4(( "!!!OVERFLOW:!!!" ));
- return val;
- }
- }
-
-
- /* read a floating point number, either integer or real */
- FT_LOCAL_DEF( FT_Fixed )
- cff_parse_fixed( CFF_Parser parser,
- FT_Byte** d )
- {
- return do_fixed( parser, d, 0 );
- }
-
-
- /* read a floating point number, either integer or real, */
- /* but return `10^scaling' times the number read in */
- static FT_Fixed
- cff_parse_fixed_scaled( CFF_Parser parser,
- FT_Byte** d,
- FT_Long scaling )
- {
- return do_fixed( parser, d, scaling );
- }
-
-
- /* read a floating point number, either integer or real, */
- /* and return it as precise as possible -- `scaling' returns */
- /* the scaling factor (as a power of 10) */
- static FT_Fixed
- cff_parse_fixed_dynamic( CFF_Parser parser,
- FT_Byte** d,
- FT_Long* scaling )
- {
- FT_ASSERT( scaling );
-
- if ( **d == 30 )
- return cff_parse_real( *d, parser->limit, 0, scaling );
- else
- {
- FT_Long number;
- FT_Int integer_length;
-
-
- number = cff_parse_integer( *d, parser->limit );
-
- if ( number > 0x7FFFL )
- {
- for ( integer_length = 5; integer_length < 10; integer_length++ )
- if ( number < power_tens[integer_length] )
- break;
-
- if ( ( number / power_tens[integer_length - 5] ) > 0x7FFFL )
- {
- *scaling = integer_length - 4;
- return FT_DivFix( number, power_tens[integer_length - 4] );
- }
- else
- {
- *scaling = integer_length - 5;
- return FT_DivFix( number, power_tens[integer_length - 5] );
- }
- }
- else
- {
- *scaling = 0;
- return (FT_Long)( (FT_ULong)number << 16 );
- }
- }
- }
-
-
- static FT_Error
- cff_parse_font_matrix( CFF_Parser parser )
- {
- CFF_FontRecDict dict = (CFF_FontRecDict)parser->object;
- FT_Matrix* matrix = &dict->font_matrix;
- FT_Vector* offset = &dict->font_offset;
- FT_ULong* upm = &dict->units_per_em;
- FT_Byte** data = parser->stack;
-
-
- if ( parser->top >= parser->stack + 6 )
- {
- FT_Fixed values[6];
- FT_Long scalings[6];
-
- FT_Long min_scaling, max_scaling;
- int i;
-
-
- dict->has_font_matrix = TRUE;
-
- /* We expect a well-formed font matrix, that is, the matrix elements */
- /* `xx' and `yy' are of approximately the same magnitude. To avoid */
- /* loss of precision, we use the magnitude of the largest matrix */
- /* element to scale all other elements. The scaling factor is then */
- /* contained in the `units_per_em' value. */
-
- max_scaling = FT_LONG_MIN;
- min_scaling = FT_LONG_MAX;
-
- for ( i = 0; i < 6; i++ )
- {
- values[i] = cff_parse_fixed_dynamic( parser, data++, &scalings[i] );
- if ( values[i] )
- {
- if ( scalings[i] > max_scaling )
- max_scaling = scalings[i];
- if ( scalings[i] < min_scaling )
- min_scaling = scalings[i];
- }
- }
-
- if ( max_scaling < -9 ||
- max_scaling > 0 ||
- ( max_scaling - min_scaling ) < 0 ||
- ( max_scaling - min_scaling ) > 9 )
- {
- FT_TRACE1(( "cff_parse_font_matrix:"
- " strange scaling values (minimum %ld, maximum %ld),\n",
- min_scaling, max_scaling ));
- FT_TRACE1(( " "
- " using default matrix\n" ));
- goto Unlikely;
- }
-
- for ( i = 0; i < 6; i++ )
- {
- FT_Fixed value = values[i];
- FT_Long divisor, half_divisor;
-
-
- if ( !value )
- continue;
-
- divisor = power_tens[max_scaling - scalings[i]];
- half_divisor = divisor >> 1;
-
- if ( value < 0 )
- {
- if ( FT_LONG_MIN + half_divisor < value )
- values[i] = ( value - half_divisor ) / divisor;
- else
- values[i] = FT_LONG_MIN / divisor;
- }
- else
- {
- if ( FT_LONG_MAX - half_divisor > value )
- values[i] = ( value + half_divisor ) / divisor;
- else
- values[i] = FT_LONG_MAX / divisor;
- }
- }
-
- matrix->xx = values[0];
- matrix->yx = values[1];
- matrix->xy = values[2];
- matrix->yy = values[3];
- offset->x = values[4];
- offset->y = values[5];
-
- *upm = (FT_ULong)power_tens[-max_scaling];
-
- FT_TRACE4(( " [%f %f %f %f %f %f]\n",
- (double)matrix->xx / (double)*upm / 65536,
- (double)matrix->xy / (double)*upm / 65536,
- (double)matrix->yx / (double)*upm / 65536,
- (double)matrix->yy / (double)*upm / 65536,
- (double)offset->x / (double)*upm / 65536,
- (double)offset->y / (double)*upm / 65536 ));
-
- if ( !FT_Matrix_Check( matrix ) )
- {
- FT_TRACE1(( "cff_parse_font_matrix:"
- " degenerate values, using default matrix\n" ));
- goto Unlikely;
- }
-
- return FT_Err_Ok;
- }
- else
- return FT_THROW( Stack_Underflow );
-
- Unlikely:
- /* Return default matrix in case of unlikely values. */
-
- matrix->xx = 0x10000L;
- matrix->yx = 0;
- matrix->xy = 0;
- matrix->yy = 0x10000L;
- offset->x = 0;
- offset->y = 0;
- *upm = 1;
-
- return FT_Err_Ok;
- }
-
-
- static FT_Error
- cff_parse_font_bbox( CFF_Parser parser )
- {
- CFF_FontRecDict dict = (CFF_FontRecDict)parser->object;
- FT_BBox* bbox = &dict->font_bbox;
- FT_Byte** data = parser->stack;
- FT_Error error;
-
-
- error = FT_ERR( Stack_Underflow );
-
- if ( parser->top >= parser->stack + 4 )
- {
- bbox->xMin = FT_RoundFix( cff_parse_fixed( parser, data++ ) );
- bbox->yMin = FT_RoundFix( cff_parse_fixed( parser, data++ ) );
- bbox->xMax = FT_RoundFix( cff_parse_fixed( parser, data++ ) );
- bbox->yMax = FT_RoundFix( cff_parse_fixed( parser, data ) );
- error = FT_Err_Ok;
-
- FT_TRACE4(( " [%ld %ld %ld %ld]\n",
- bbox->xMin / 65536,
- bbox->yMin / 65536,
- bbox->xMax / 65536,
- bbox->yMax / 65536 ));
- }
-
- return error;
- }
-
-
- static FT_Error
- cff_parse_private_dict( CFF_Parser parser )
- {
- CFF_FontRecDict dict = (CFF_FontRecDict)parser->object;
- FT_Byte** data = parser->stack;
- FT_Error error;
-
-
- error = FT_ERR( Stack_Underflow );
-
- if ( parser->top >= parser->stack + 2 )
- {
- FT_Long tmp;
-
-
- tmp = cff_parse_num( parser, data++ );
- if ( tmp < 0 )
- {
- FT_ERROR(( "cff_parse_private_dict: Invalid dictionary size\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Fail;
- }
- dict->private_size = (FT_ULong)tmp;
-
- tmp = cff_parse_num( parser, data );
- if ( tmp < 0 )
- {
- FT_ERROR(( "cff_parse_private_dict: Invalid dictionary offset\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Fail;
- }
- dict->private_offset = (FT_ULong)tmp;
-
- FT_TRACE4(( " %lu %lu\n",
- dict->private_size, dict->private_offset ));
-
- error = FT_Err_Ok;
- }
-
- Fail:
- return error;
- }
-
-
- /* The `MultipleMaster' operator comes before any */
- /* top DICT operators that contain T2 charstrings. */
-
- static FT_Error
- cff_parse_multiple_master( CFF_Parser parser )
- {
- CFF_FontRecDict dict = (CFF_FontRecDict)parser->object;
- FT_Error error;
-
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- /* beautify tracing message */
- if ( ft_trace_levels[FT_TRACE_COMP( FT_COMPONENT )] < 4 )
- FT_TRACE1(( "Multiple Master CFFs not supported yet,"
- " handling first master design only\n" ));
- else
- FT_TRACE1(( " (not supported yet,"
- " handling first master design only)\n" ));
-#endif
-
- error = FT_ERR( Stack_Underflow );
-
- /* currently, we handle only the first argument */
- if ( parser->top >= parser->stack + 5 )
- {
- FT_Long num_designs = cff_parse_num( parser, parser->stack );
-
-
- if ( num_designs > 16 || num_designs < 2 )
- {
- FT_ERROR(( "cff_parse_multiple_master:"
- " Invalid number of designs\n" ));
- error = FT_THROW( Invalid_File_Format );
- }
- else
- {
- dict->num_designs = (FT_UShort)num_designs;
- dict->num_axes = (FT_UShort)( parser->top - parser->stack - 4 );
-
- parser->num_designs = dict->num_designs;
- parser->num_axes = dict->num_axes;
-
- error = FT_Err_Ok;
- }
- }
-
- return error;
- }
-
-
- static FT_Error
- cff_parse_cid_ros( CFF_Parser parser )
- {
- CFF_FontRecDict dict = (CFF_FontRecDict)parser->object;
- FT_Byte** data = parser->stack;
- FT_Error error;
-
-
- error = FT_ERR( Stack_Underflow );
-
- if ( parser->top >= parser->stack + 3 )
- {
- dict->cid_registry = (FT_UInt)cff_parse_num( parser, data++ );
- dict->cid_ordering = (FT_UInt)cff_parse_num( parser, data++ );
- if ( **data == 30 )
- FT_TRACE1(( "cff_parse_cid_ros: real supplement is rounded\n" ));
- dict->cid_supplement = cff_parse_num( parser, data );
- if ( dict->cid_supplement < 0 )
- FT_TRACE1(( "cff_parse_cid_ros: negative supplement %ld is found\n",
- dict->cid_supplement ));
- error = FT_Err_Ok;
-
- FT_TRACE4(( " %d %d %ld\n",
- dict->cid_registry,
- dict->cid_ordering,
- dict->cid_supplement ));
- }
-
- return error;
- }
-
-
- static FT_Error
- cff_parse_vsindex( CFF_Parser parser )
- {
- /* vsindex operator can only be used in a Private DICT */
- CFF_Private priv = (CFF_Private)parser->object;
- FT_Byte** data = parser->stack;
- CFF_Blend blend;
- FT_Error error;
-
-
- if ( !priv || !priv->subfont )
- {
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- blend = &priv->subfont->blend;
-
- if ( blend->usedBV )
- {
- FT_ERROR(( " cff_parse_vsindex: vsindex not allowed after blend\n" ));
- error = FT_THROW( Syntax_Error );
- goto Exit;
- }
-
- priv->vsindex = (FT_UInt)cff_parse_num( parser, data++ );
-
- FT_TRACE4(( " %d\n", priv->vsindex ));
-
- error = FT_Err_Ok;
-
- Exit:
- return error;
- }
-
-
- static FT_Error
- cff_parse_blend( CFF_Parser parser )
- {
- /* blend operator can only be used in a Private DICT */
- CFF_Private priv = (CFF_Private)parser->object;
- CFF_SubFont subFont;
- CFF_Blend blend;
- FT_UInt numBlends;
- FT_Error error;
-
-
- if ( !priv || !priv->subfont )
- {
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- subFont = priv->subfont;
- blend = &subFont->blend;
-
- if ( cff_blend_check_vector( blend,
- priv->vsindex,
- subFont->lenNDV,
- subFont->NDV ) )
- {
- error = cff_blend_build_vector( blend,
- priv->vsindex,
- subFont->lenNDV,
- subFont->NDV );
- if ( error )
- goto Exit;
- }
-
- numBlends = (FT_UInt)cff_parse_num( parser, parser->top - 1 );
- if ( numBlends > parser->stackSize )
- {
- FT_ERROR(( "cff_parse_blend: Invalid number of blends\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- FT_TRACE4(( " %d value%s blended\n",
- numBlends,
- numBlends == 1 ? "" : "s" ));
-
- error = cff_blend_doBlend( subFont, parser, numBlends );
-
- blend->usedBV = TRUE;
-
- Exit:
- return error;
- }
-
-
- /* maxstack operator increases parser and operand stacks for CFF2 */
- static FT_Error
- cff_parse_maxstack( CFF_Parser parser )
- {
- /* maxstack operator can only be used in a Top DICT */
- CFF_FontRecDict dict = (CFF_FontRecDict)parser->object;
- FT_Byte** data = parser->stack;
- FT_Error error = FT_Err_Ok;
-
-
- if ( !dict )
- {
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- dict->maxstack = (FT_UInt)cff_parse_num( parser, data++ );
- if ( dict->maxstack > CFF2_MAX_STACK )
- dict->maxstack = CFF2_MAX_STACK;
- if ( dict->maxstack < CFF2_DEFAULT_STACK )
- dict->maxstack = CFF2_DEFAULT_STACK;
-
- FT_TRACE4(( " %d\n", dict->maxstack ));
-
- Exit:
- return error;
- }
-
-
-#define CFF_FIELD_NUM( code, name, id ) \
- CFF_FIELD( code, name, id, cff_kind_num )
-#define CFF_FIELD_FIXED( code, name, id ) \
- CFF_FIELD( code, name, id, cff_kind_fixed )
-#define CFF_FIELD_FIXED_1000( code, name, id ) \
- CFF_FIELD( code, name, id, cff_kind_fixed_thousand )
-#define CFF_FIELD_STRING( code, name, id ) \
- CFF_FIELD( code, name, id, cff_kind_string )
-#define CFF_FIELD_BOOL( code, name, id ) \
- CFF_FIELD( code, name, id, cff_kind_bool )
-#define CFF_FIELD_DELTA( code, name, max, id ) \
- CFF_FIELD_DELTA_KIND( code, name, max, id, cff_kind_delta )
-#define CFF_FIELD_DELTA_FIXED( code, name, max, id ) \
- CFF_FIELD_DELTA_KIND( code, name, max, id, cff_kind_delta_fixed )
-
-
-#undef CFF_FIELD
-#undef CFF_FIELD_DELTA_KIND
-
-
-#ifndef FT_DEBUG_LEVEL_TRACE
-
-
-#define CFF_FIELD_CALLBACK( code, name, id ) \
- { \
- cff_kind_callback, \
- code | CFFCODE, \
- 0, 0, \
- cff_parse_ ## name, \
- 0, 0 \
- },
-
-#define CFF_FIELD_BLEND( code, id ) \
- { \
- cff_kind_blend, \
- code | CFFCODE, \
- 0, 0, \
- cff_parse_blend, \
- 0, 0 \
- },
-
-#define CFF_FIELD( code, name, id, kind ) \
- { \
- kind, \
- code | CFFCODE, \
- FT_FIELD_OFFSET( name ), \
- FT_FIELD_SIZE( name ), \
- NULL, 0, 0 \
- },
-
-#define CFF_FIELD_DELTA_KIND( code, name, max, id, kind ) \
- { \
- kind, \
- code | CFFCODE, \
- FT_FIELD_OFFSET( name ), \
- FT_FIELD_SIZE_DELTA( name ), \
- NULL, \
- max, \
- FT_FIELD_OFFSET( num_ ## name ) \
- },
-
- static const CFF_Field_Handler cff_field_handlers[] =
- {
-
-#include "cfftoken.h"
-
- { 0, 0, 0, 0, NULL, 0, 0 }
- };
-
-
-#else /* FT_DEBUG_LEVEL_TRACE */
-
-
-
-#define CFF_FIELD_CALLBACK( code, name, id ) \
- { \
- cff_kind_callback, \
- code | CFFCODE, \
- 0, 0, \
- cff_parse_ ## name, \
- 0, 0, \
- id \
- },
-
-#define CFF_FIELD_BLEND( code, id ) \
- { \
- cff_kind_blend, \
- code | CFFCODE, \
- 0, 0, \
- cff_parse_blend, \
- 0, 0, \
- id \
- },
-
-#define CFF_FIELD( code, name, id, kind ) \
- { \
- kind, \
- code | CFFCODE, \
- FT_FIELD_OFFSET( name ), \
- FT_FIELD_SIZE( name ), \
- NULL, 0, 0, \
- id \
- },
-
-#define CFF_FIELD_DELTA_KIND( code, name, max, id, kind ) \
- { \
- kind, \
- code | CFFCODE, \
- FT_FIELD_OFFSET( name ), \
- FT_FIELD_SIZE_DELTA( name ), \
- NULL, \
- max, \
- FT_FIELD_OFFSET( num_ ## name ), \
- id \
- },
-
- static const CFF_Field_Handler cff_field_handlers[] =
- {
-
-#include "cfftoken.h"
-
- { 0, 0, 0, 0, NULL, 0, 0, NULL }
- };
-
-
-#endif /* FT_DEBUG_LEVEL_TRACE */
-
-
- FT_LOCAL_DEF( FT_Error )
- cff_parser_run( CFF_Parser parser,
- FT_Byte* start,
- FT_Byte* limit )
- {
- FT_Byte* p = start;
- FT_Error error = FT_Err_Ok;
-
-#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
- PSAux_Service psaux;
-
- FT_Library library = parser->library;
- FT_Memory memory = library->memory;
-#endif
-
- parser->top = parser->stack;
- parser->start = start;
- parser->limit = limit;
- parser->cursor = start;
-
- while ( p < limit )
- {
- FT_UInt v = *p;
-
-
- /* Opcode 31 is legacy MM T2 operator, not a number. */
- /* Opcode 255 is reserved and should not appear in fonts; */
- /* it is used internally for CFF2 blends. */
- if ( v >= 27 && v != 31 && v != 255 )
- {
- /* it's a number; we will push its position on the stack */
- if ( (FT_UInt)( parser->top - parser->stack ) >= parser->stackSize )
- goto Stack_Overflow;
-
- *parser->top++ = p;
-
- /* now, skip it */
- if ( v == 30 )
- {
- /* skip real number */
- p++;
- for (;;)
- {
- /* An unterminated floating point number at the */
- /* end of a dictionary is invalid but harmless. */
- if ( p >= limit )
- goto Exit;
- v = p[0] >> 4;
- if ( v == 15 )
- break;
- v = p[0] & 0xF;
- if ( v == 15 )
- break;
- p++;
- }
- }
- else if ( v == 28 )
- p += 2;
- else if ( v == 29 )
- p += 4;
- else if ( v > 246 )
- p += 1;
- }
-#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
- else if ( v == 31 )
- {
- /* a Type 2 charstring */
-
- CFF_Decoder decoder;
- CFF_FontRec cff_rec;
- FT_Byte* charstring_base;
- FT_ULong charstring_len;
-
- FT_Fixed* stack;
- FT_Byte* q = NULL;
-
-
- charstring_base = ++p;
-
- /* search `endchar' operator */
- for (;;)
- {
- if ( p >= limit )
- goto Exit;
- if ( *p == 14 )
- break;
- p++;
- }
-
- charstring_len = (FT_ULong)( p - charstring_base ) + 1;
-
- /* construct CFF_Decoder object */
- FT_ZERO( &decoder );
- FT_ZERO( &cff_rec );
-
- cff_rec.top_font.font_dict.num_designs = parser->num_designs;
- cff_rec.top_font.font_dict.num_axes = parser->num_axes;
- decoder.cff = &cff_rec;
-
- psaux = (PSAux_Service)FT_Get_Module_Interface( library, "psaux" );
- if ( !psaux )
- {
- FT_ERROR(( "cff_parser_run: cannot access `psaux' module\n" ));
- error = FT_THROW( Missing_Module );
- goto Exit;
- }
-
- error = psaux->cff_decoder_funcs->parse_charstrings_old(
- &decoder, charstring_base, charstring_len, 1 );
- if ( error )
- goto Exit;
-
- /* Now copy the stack data in the temporary decoder object, */
- /* converting it back to charstring number representations */
- /* (this is ugly, I know). */
- /* The maximum required size is 5 bytes per stack element. */
- if ( FT_QALLOC( q, (FT_Long)( 2 * sizeof ( FT_ListNode ) ) +
- 5 * ( decoder.top - decoder.stack ) ) )
- goto Exit;
-
- FT_List_Add( &parser->t2_strings, (FT_ListNode)q );
-
- q += 2 * sizeof ( FT_ListNode );
-
- for ( stack = decoder.stack; stack < decoder.top; stack++ )
- {
- FT_Long num = *stack;
-
-
- if ( (FT_UInt)( parser->top - parser->stack ) >= parser->stackSize )
- goto Stack_Overflow;
-
- *parser->top++ = q;
-
- if ( num & 0xFFFFU )
- {
- *q++ = 255;
- *q++ = (FT_Byte)( ( num >> 24 ) & 0xFF );
- *q++ = (FT_Byte)( ( num >> 16 ) & 0xFF );
- *q++ = (FT_Byte)( ( num >> 8 ) & 0xFF );
- *q++ = (FT_Byte)( ( num ) & 0xFF );
- }
- else
- {
- num >>= 16;
-
- if ( -107 <= num && num <= 107 )
- *q++ = (FT_Byte)( num + 139 );
- else if ( 108 <= num && num <= 1131 )
- {
- *q++ = (FT_Byte)( ( ( num - 108 ) >> 8 ) + 247 );
- *q++ = (FT_Byte)( ( num - 108 ) & 0xFF );
- }
- else if ( -1131 <= num && num <= -108 )
- {
- *q++ = (FT_Byte)( ( ( -num - 108 ) >> 8 ) + 251 );
- *q++ = (FT_Byte)( ( -num - 108) & 0xFF );
- }
- else
- {
- *q++ = 28;
- *q++ = (FT_Byte)( num >> 8 );
- *q++ = (FT_Byte)( num & 0xFF );
- }
- }
- }
- }
-#endif /* CFF_CONFIG_OPTION_OLD_ENGINE */
- else
- {
- /* This is not a number, hence it's an operator. Compute its code */
- /* and look for it in our current list. */
-
- FT_UInt code;
- FT_UInt num_args;
- const CFF_Field_Handler* field;
-
-
- if ( (FT_UInt)( parser->top - parser->stack ) >= parser->stackSize )
- goto Stack_Overflow;
-
- num_args = (FT_UInt)( parser->top - parser->stack );
- *parser->top = p;
- code = v;
-
- if ( v == 12 )
- {
- /* two byte operator */
- p++;
- if ( p >= limit )
- goto Syntax_Error;
-
- code = 0x100 | p[0];
- }
- code = code | parser->object_code;
-
- for ( field = cff_field_handlers; field->kind; field++ )
- {
- if ( field->code == (FT_Int)code )
- {
- /* we found our field's handler; read it */
- FT_Long val;
- FT_Byte* q = (FT_Byte*)parser->object + field->offset;
-
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- FT_TRACE4(( " %s", field->id ));
-#endif
-
- /* check that we have enough arguments -- except for */
- /* delta encoded arrays, which can be empty */
- if ( field->kind != cff_kind_delta &&
- field->kind != cff_kind_delta_fixed && num_args < 1 )
- goto Stack_Underflow;
-
- switch ( field->kind )
- {
- case cff_kind_bool:
- case cff_kind_string:
- case cff_kind_num:
- val = cff_parse_num( parser, parser->stack );
- goto Store_Number;
-
- case cff_kind_fixed:
- val = cff_parse_fixed( parser, parser->stack );
- goto Store_Number;
-
- case cff_kind_fixed_thousand:
- val = cff_parse_fixed_scaled( parser, parser->stack, 3 );
-
- Store_Number:
- switch ( field->size )
- {
- case (8 / FT_CHAR_BIT):
- *(FT_Byte*)q = (FT_Byte)val;
- break;
-
- case (16 / FT_CHAR_BIT):
- *(FT_Short*)q = (FT_Short)val;
- break;
-
- case (32 / FT_CHAR_BIT):
- *(FT_Int32*)q = (FT_Int)val;
- break;
-
- default: /* for 64-bit systems */
- *(FT_Long*)q = val;
- }
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- switch ( field->kind )
- {
- case cff_kind_bool:
- FT_TRACE4(( " %s\n", val ? "true" : "false" ));
- break;
-
- case cff_kind_string:
- FT_TRACE4(( " %ld (SID)\n", val ));
- break;
-
- case cff_kind_num:
- FT_TRACE4(( " %ld\n", val ));
- break;
-
- case cff_kind_fixed:
- FT_TRACE4(( " %f\n", (double)val / 65536 ));
- break;
-
- case cff_kind_fixed_thousand:
- FT_TRACE4(( " %f\n", (double)val / 65536 / 1000 ));
- break;
-
- default:
- ; /* never reached */
- }
-#endif
-
- break;
-
- case cff_kind_delta:
- {
- FT_Byte* qcount = (FT_Byte*)parser->object +
- field->count_offset;
-
- FT_Byte** data = parser->stack;
-
-
- if ( num_args > field->array_max )
- num_args = field->array_max;
-
- FT_TRACE4(( " [" ));
-
- /* store count */
- *qcount = (FT_Byte)num_args;
-
- val = 0;
- while ( num_args > 0 )
- {
- val = ADD_LONG( val, cff_parse_num( parser, data++ ) );
- switch ( field->size )
- {
- case (8 / FT_CHAR_BIT):
- *(FT_Byte*)q = (FT_Byte)val;
- break;
-
- case (16 / FT_CHAR_BIT):
- *(FT_Short*)q = (FT_Short)val;
- break;
-
- case (32 / FT_CHAR_BIT):
- *(FT_Int32*)q = (FT_Int)val;
- break;
-
- default: /* for 64-bit systems */
- *(FT_Long*)q = val;
- }
-
- FT_TRACE4(( " %ld", val ));
-
- q += field->size;
- num_args--;
- }
-
- FT_TRACE4(( "]\n" ));
- }
- break;
-
- case cff_kind_delta_fixed:
- {
- FT_Byte* qcount = (FT_Byte*)parser->object +
- field->count_offset;
-
- FT_Byte** data = parser->stack;
-
-
- if ( num_args > field->array_max )
- num_args = field->array_max;
-
- FT_TRACE4(( " [" ));
-
- /* store count */
- *qcount = (FT_Byte)num_args;
-
- val = 0;
- while ( num_args > 0 )
- {
- val = ADD_LONG( val, cff_parse_fixed( parser, data++ ) );
- *(FT_Long*)q = val;
-
- FT_TRACE4(( " %f\n", (double)val / 65536 ));
-
- q += field->size;
- num_args--;
- }
-
- FT_TRACE4(( "]\n" ));
- }
- break;
-
- default: /* callback or blend */
- error = field->reader( parser );
- if ( error )
- goto Exit;
- }
- goto Found;
- }
- }
-
- /* this is an unknown operator, or it is unsupported; */
- /* we will ignore it for now. */
-
- Found:
- /* clear stack */
- /* TODO: could clear blend stack here, */
- /* but we don't have access to subFont */
- if ( field->kind != cff_kind_blend )
- parser->top = parser->stack;
- }
- p++;
- } /* while ( p < limit ) */
-
- Exit:
- return error;
-
- Stack_Overflow:
- error = FT_THROW( Invalid_Argument );
- goto Exit;
-
- Stack_Underflow:
- error = FT_THROW( Invalid_Argument );
- goto Exit;
-
- Syntax_Error:
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cff/cffparse.h b/contrib/libs/freetype/src/cff/cffparse.h
deleted file mode 100644
index ca6b18af6a..0000000000
--- a/contrib/libs/freetype/src/cff/cffparse.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/****************************************************************************
- *
- * cffparse.h
- *
- * CFF token stream parser (specification)
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef CFFPARSE_H_
-#define CFFPARSE_H_
-
-
-#include <freetype/internal/cfftypes.h>
-#include <freetype/internal/ftobjs.h>
-
-
-FT_BEGIN_HEADER
-
-
- /* CFF uses constant parser stack size; */
- /* CFF2 can increase from default 193 */
-#define CFF_MAX_STACK_DEPTH 96
-
- /*
- * There are plans to remove the `maxstack' operator in a forthcoming
- * revision of the CFF2 specification, increasing the (then static) stack
- * size to 513. By making the default stack size equal to the maximum
- * stack size, the operator is essentially disabled, which has the
- * desired effect in FreeType.
- */
-#define CFF2_MAX_STACK 513
-#define CFF2_DEFAULT_STACK 513
-
-#define CFF_CODE_TOPDICT 0x1000
-#define CFF_CODE_PRIVATE 0x2000
-#define CFF2_CODE_TOPDICT 0x3000
-#define CFF2_CODE_FONTDICT 0x4000
-#define CFF2_CODE_PRIVATE 0x5000
-
-
- typedef struct CFF_ParserRec_
- {
- FT_Library library;
- FT_Byte* start;
- FT_Byte* limit;
- FT_Byte* cursor;
-
- FT_Byte** stack;
- FT_Byte** top;
- FT_UInt stackSize; /* allocated size */
-
-#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
- FT_ListRec t2_strings;
-#endif /* CFF_CONFIG_OPTION_OLD_ENGINE */
-
- FT_UInt object_code;
- void* object;
-
- FT_UShort num_designs; /* a copy of `CFF_FontRecDict->num_designs' */
- FT_UShort num_axes; /* a copy of `CFF_FontRecDict->num_axes' */
-
- } CFF_ParserRec, *CFF_Parser;
-
-
- FT_LOCAL( FT_Long )
- cff_parse_num( CFF_Parser parser,
- FT_Byte** d );
-
- FT_LOCAL( FT_Fixed )
- cff_parse_fixed( CFF_Parser parser,
- FT_Byte** d );
-
- FT_LOCAL( FT_Error )
- cff_parser_init( CFF_Parser parser,
- FT_UInt code,
- void* object,
- FT_Library library,
- FT_UInt stackSize,
- FT_UShort num_designs,
- FT_UShort num_axes );
-
- FT_LOCAL( void )
- cff_parser_done( CFF_Parser parser );
-
- FT_LOCAL( FT_Error )
- cff_parser_run( CFF_Parser parser,
- FT_Byte* start,
- FT_Byte* limit );
-
-
- enum
- {
- cff_kind_none = 0,
- cff_kind_num,
- cff_kind_fixed,
- cff_kind_fixed_thousand,
- cff_kind_string,
- cff_kind_bool,
- cff_kind_delta,
- cff_kind_delta_fixed,
- cff_kind_callback,
- cff_kind_blend,
-
- cff_kind_max /* do not remove */
- };
-
-
- /* now generate handlers for the most simple fields */
- typedef FT_Error (*CFF_Field_Reader)( CFF_Parser parser );
-
- typedef struct CFF_Field_Handler_
- {
- int kind;
- int code;
- FT_UInt offset;
- FT_Byte size;
- CFF_Field_Reader reader;
- FT_UInt array_max;
- FT_UInt count_offset;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- const char* id;
-#endif
-
- } CFF_Field_Handler;
-
-
-FT_END_HEADER
-
-
-#endif /* CFFPARSE_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cff/cfftoken.h b/contrib/libs/freetype/src/cff/cfftoken.h
deleted file mode 100644
index da45faa7f4..0000000000
--- a/contrib/libs/freetype/src/cff/cfftoken.h
+++ /dev/null
@@ -1,150 +0,0 @@
-/****************************************************************************
- *
- * cfftoken.h
- *
- * CFF token definitions (specification only).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#undef FT_STRUCTURE
-#define FT_STRUCTURE CFF_FontRecDictRec
-
-#undef CFFCODE
-#define CFFCODE CFF_CODE_TOPDICT
-
- CFF_FIELD_STRING ( 0, version, "Version" )
- CFF_FIELD_STRING ( 1, notice, "Notice" )
- CFF_FIELD_STRING ( 0x100, copyright, "Copyright" )
- CFF_FIELD_STRING ( 2, full_name, "FullName" )
- CFF_FIELD_STRING ( 3, family_name, "FamilyName" )
- CFF_FIELD_STRING ( 4, weight, "Weight" )
- CFF_FIELD_BOOL ( 0x101, is_fixed_pitch, "isFixedPitch" )
- CFF_FIELD_FIXED ( 0x102, italic_angle, "ItalicAngle" )
- CFF_FIELD_FIXED ( 0x103, underline_position, "UnderlinePosition" )
- CFF_FIELD_FIXED ( 0x104, underline_thickness, "UnderlineThickness" )
- CFF_FIELD_NUM ( 0x105, paint_type, "PaintType" )
- CFF_FIELD_NUM ( 0x106, charstring_type, "CharstringType" )
- CFF_FIELD_CALLBACK( 0x107, font_matrix, "FontMatrix" )
- CFF_FIELD_NUM ( 13, unique_id, "UniqueID" )
- CFF_FIELD_CALLBACK( 5, font_bbox, "FontBBox" )
- CFF_FIELD_NUM ( 0x108, stroke_width, "StrokeWidth" )
-#if 0
- CFF_FIELD_DELTA ( 14, xuid, 16, "XUID" )
-#endif
- CFF_FIELD_NUM ( 15, charset_offset, "charset" )
- CFF_FIELD_NUM ( 16, encoding_offset, "Encoding" )
- CFF_FIELD_NUM ( 17, charstrings_offset, "CharStrings" )
- CFF_FIELD_CALLBACK( 18, private_dict, "Private" )
- CFF_FIELD_NUM ( 0x114, synthetic_base, "SyntheticBase" )
- CFF_FIELD_STRING ( 0x115, embedded_postscript, "PostScript" )
-
-#if 0
- CFF_FIELD_STRING ( 0x116, base_font_name, "BaseFontName" )
- CFF_FIELD_DELTA ( 0x117, base_font_blend, 16, "BaseFontBlend" )
-#endif
-
- /* the next two operators were removed from the Type2 specification */
- /* in version 16-March-2000 */
- CFF_FIELD_CALLBACK( 0x118, multiple_master, "MultipleMaster" )
-#if 0
- CFF_FIELD_CALLBACK( 0x11A, blend_axis_types, "BlendAxisTypes" )
-#endif
-
- CFF_FIELD_CALLBACK( 0x11E, cid_ros, "ROS" )
- CFF_FIELD_NUM ( 0x11F, cid_font_version, "CIDFontVersion" )
- CFF_FIELD_NUM ( 0x120, cid_font_revision, "CIDFontRevision" )
- CFF_FIELD_NUM ( 0x121, cid_font_type, "CIDFontType" )
- CFF_FIELD_NUM ( 0x122, cid_count, "CIDCount" )
- CFF_FIELD_NUM ( 0x123, cid_uid_base, "UIDBase" )
- CFF_FIELD_NUM ( 0x124, cid_fd_array_offset, "FDArray" )
- CFF_FIELD_NUM ( 0x125, cid_fd_select_offset, "FDSelect" )
- CFF_FIELD_STRING ( 0x126, cid_font_name, "FontName" )
-
-#if 0
- CFF_FIELD_NUM ( 0x127, chameleon, "Chameleon" )
-#endif
-
-
-#undef FT_STRUCTURE
-#define FT_STRUCTURE CFF_PrivateRec
-#undef CFFCODE
-#define CFFCODE CFF_CODE_PRIVATE
-
- CFF_FIELD_DELTA_FIXED( 6, blue_values, 14, "BlueValues" )
- CFF_FIELD_DELTA_FIXED( 7, other_blues, 10, "OtherBlues" )
- CFF_FIELD_DELTA_FIXED( 8, family_blues, 14, "FamilyBlues" )
- CFF_FIELD_DELTA_FIXED( 9, family_other_blues, 10, "FamilyOtherBlues" )
- CFF_FIELD_FIXED_1000 ( 0x109, blue_scale, "BlueScale" )
- CFF_FIELD_NUM ( 0x10A, blue_shift, "BlueShift" )
- CFF_FIELD_NUM ( 0x10B, blue_fuzz, "BlueFuzz" )
- CFF_FIELD_NUM ( 10, standard_width, "StdHW" )
- CFF_FIELD_NUM ( 11, standard_height, "StdVW" )
- CFF_FIELD_DELTA ( 0x10C, snap_widths, 13, "StemSnapH" )
- CFF_FIELD_DELTA ( 0x10D, snap_heights, 13, "StemSnapV" )
- CFF_FIELD_BOOL ( 0x10E, force_bold, "ForceBold" )
- CFF_FIELD_FIXED ( 0x10F, force_bold_threshold, "ForceBoldThreshold" )
- CFF_FIELD_NUM ( 0x110, lenIV, "lenIV" )
- CFF_FIELD_NUM ( 0x111, language_group, "LanguageGroup" )
- CFF_FIELD_FIXED ( 0x112, expansion_factor, "ExpansionFactor" )
- CFF_FIELD_NUM ( 0x113, initial_random_seed, "initialRandomSeed" )
- CFF_FIELD_NUM ( 19, local_subrs_offset, "Subrs" )
- CFF_FIELD_NUM ( 20, default_width, "defaultWidthX" )
- CFF_FIELD_NUM ( 21, nominal_width, "nominalWidthX" )
-
-
-#undef FT_STRUCTURE
-#define FT_STRUCTURE CFF_FontRecDictRec
-#undef CFFCODE
-#define CFFCODE CFF2_CODE_TOPDICT
-
- CFF_FIELD_CALLBACK( 0x107, font_matrix, "FontMatrix" )
- CFF_FIELD_NUM ( 17, charstrings_offset, "CharStrings" )
- CFF_FIELD_NUM ( 0x124, cid_fd_array_offset, "FDArray" )
- CFF_FIELD_NUM ( 0x125, cid_fd_select_offset, "FDSelect" )
- CFF_FIELD_NUM ( 24, vstore_offset, "vstore" )
- CFF_FIELD_CALLBACK( 25, maxstack, "maxstack" )
-
-
-#undef FT_STRUCTURE
-#define FT_STRUCTURE CFF_FontRecDictRec
-#undef CFFCODE
-#define CFFCODE CFF2_CODE_FONTDICT
-
- CFF_FIELD_CALLBACK( 18, private_dict, "Private" )
- CFF_FIELD_CALLBACK( 0x107, font_matrix, "FontMatrix" )
-
-
-#undef FT_STRUCTURE
-#define FT_STRUCTURE CFF_PrivateRec
-#undef CFFCODE
-#define CFFCODE CFF2_CODE_PRIVATE
-
- CFF_FIELD_DELTA_FIXED( 6, blue_values, 14, "BlueValues" )
- CFF_FIELD_DELTA_FIXED( 7, other_blues, 10, "OtherBlues" )
- CFF_FIELD_DELTA_FIXED( 8, family_blues, 14, "FamilyBlues" )
- CFF_FIELD_DELTA_FIXED( 9, family_other_blues, 10, "FamilyOtherBlues" )
- CFF_FIELD_FIXED_1000 ( 0x109, blue_scale, "BlueScale" )
- CFF_FIELD_NUM ( 0x10A, blue_shift, "BlueShift" )
- CFF_FIELD_NUM ( 0x10B, blue_fuzz, "BlueFuzz" )
- CFF_FIELD_NUM ( 10, standard_width, "StdHW" )
- CFF_FIELD_NUM ( 11, standard_height, "StdVW" )
- CFF_FIELD_DELTA ( 0x10C, snap_widths, 13, "StemSnapH" )
- CFF_FIELD_DELTA ( 0x10D, snap_heights, 13, "StemSnapV" )
- CFF_FIELD_NUM ( 0x111, language_group, "LanguageGroup" )
- CFF_FIELD_FIXED ( 0x112, expansion_factor, "ExpansionFactor" )
- CFF_FIELD_CALLBACK ( 22, vsindex, "vsindex" )
- CFF_FIELD_BLEND ( 23, "blend" )
- CFF_FIELD_NUM ( 19, local_subrs_offset, "Subrs" )
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cid/ciderrs.h b/contrib/libs/freetype/src/cid/ciderrs.h
deleted file mode 100644
index c439a8c4a0..0000000000
--- a/contrib/libs/freetype/src/cid/ciderrs.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/****************************************************************************
- *
- * ciderrs.h
- *
- * CID error codes (specification only).
- *
- * Copyright (C) 2001-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /**************************************************************************
- *
- * This file is used to define the CID error enumeration constants.
- *
- */
-
-#ifndef CIDERRS_H_
-#define CIDERRS_H_
-
-#include <freetype/ftmoderr.h>
-
-#undef FTERRORS_H_
-
-#undef FT_ERR_PREFIX
-#define FT_ERR_PREFIX CID_Err_
-#define FT_ERR_BASE FT_Mod_Err_CID
-
-#include <freetype/fterrors.h>
-
-#endif /* CIDERRS_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cid/cidgload.c b/contrib/libs/freetype/src/cid/cidgload.c
deleted file mode 100644
index 7b571322d4..0000000000
--- a/contrib/libs/freetype/src/cid/cidgload.c
+++ /dev/null
@@ -1,618 +0,0 @@
-/****************************************************************************
- *
- * cidgload.c
- *
- * CID-keyed Type1 Glyph Loader (body).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include "cidload.h"
-#include "cidgload.h"
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/ftoutln.h>
-#include <freetype/internal/ftcalc.h>
-
-#include <freetype/internal/psaux.h>
-#include <freetype/internal/cfftypes.h>
-#include <freetype/ftdriver.h>
-
-#include "ciderrs.h"
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT cidgload
-
-
- /*
- * A helper function to compute FD number (`fd_select`), the offset to the
- * head of the glyph data (`off1`), and the offset to the and of the glyph
- * data (`off2`).
- *
- * The number how many times `cid_get_offset` is invoked can be controlled
- * by the number of non-NULL arguments. If `fd_select` is non-NULL but
- * `off1` and `off2` are NULL, `cid_get_offset` is invoked only for
- * `fd_select`; `off1` and `off2` are not validated.
- *
- */
- FT_LOCAL_DEF( FT_Error )
- cid_compute_fd_and_offsets( CID_Face face,
- FT_UInt glyph_index,
- FT_ULong* fd_select_p,
- FT_ULong* off1_p,
- FT_ULong* off2_p )
- {
- FT_Error error = FT_Err_Ok;
-
- CID_FaceInfo cid = &face->cid;
- FT_Stream stream = face->cid_stream;
- FT_UInt entry_len = cid->fd_bytes + cid->gd_bytes;
-
- FT_Byte* p;
- FT_Bool need_frame_exit = 0;
- FT_ULong fd_select, off1, off2;
-
-
- /* For ordinary fonts, read the CID font dictionary index */
- /* and charstring offset from the CIDMap. */
-
- if ( FT_STREAM_SEEK( cid->data_offset + cid->cidmap_offset +
- glyph_index * entry_len ) ||
- FT_FRAME_ENTER( 2 * entry_len ) )
- goto Exit;
-
- need_frame_exit = 1;
-
- p = (FT_Byte*)stream->cursor;
- fd_select = cid_get_offset( &p, cid->fd_bytes );
- off1 = cid_get_offset( &p, cid->gd_bytes );
-
- p += cid->fd_bytes;
- off2 = cid_get_offset( &p, cid->gd_bytes );
-
- if ( fd_select_p )
- *fd_select_p = fd_select;
- if ( off1_p )
- *off1_p = off1;
- if ( off2_p )
- *off2_p = off2;
-
- if ( fd_select >= cid->num_dicts )
- {
- /*
- * fd_select == 0xFF is often used to indicate that the CID
- * has no charstring to be rendered, similar to GID = 0xFFFF
- * in TrueType fonts.
- */
- if ( ( cid->fd_bytes == 1 && fd_select == 0xFFU ) ||
- ( cid->fd_bytes == 2 && fd_select == 0xFFFFU ) )
- {
- FT_TRACE1(( "cid_load_glyph: fail for glyph index %d:\n",
- glyph_index ));
- FT_TRACE1(( " FD number %ld is the maximum\n",
- fd_select ));
- FT_TRACE1(( " integer fitting into %d byte%s\n",
- cid->fd_bytes, cid->fd_bytes == 1 ? "" : "s" ));
- }
- else
- {
- FT_TRACE0(( "cid_load_glyph: fail for glyph index %d:\n",
- glyph_index ));
- FT_TRACE0(( " FD number %ld is larger\n",
- fd_select ));
- FT_TRACE0(( " than number of dictionaries (%d)\n",
- cid->num_dicts ));
- }
-
- error = FT_THROW( Invalid_Offset );
- goto Exit;
- }
- else if ( off2 > stream->size )
- {
- FT_TRACE0(( "cid_load_glyph: fail for glyph index %d:\n",
- glyph_index ));
- FT_TRACE0(( " end of the glyph data\n" ));
- FT_TRACE0(( " is beyond the data stream\n" ));
-
- error = FT_THROW( Invalid_Offset );
- goto Exit;
- }
- else if ( off1 > off2 )
- {
- FT_TRACE0(( "cid_load_glyph: fail for glyph index %d:\n",
- glyph_index ));
- FT_TRACE0(( " the end position of glyph data\n" ));
- FT_TRACE0(( " is set before the start position\n" ));
-
- error = FT_THROW( Invalid_Offset );
- }
-
- Exit:
- if ( need_frame_exit )
- FT_FRAME_EXIT();
-
- return error;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- cid_load_glyph( T1_Decoder decoder,
- FT_UInt glyph_index )
- {
- CID_Face face = (CID_Face)decoder->builder.face;
- CID_FaceInfo cid = &face->cid;
- FT_Byte* p;
- FT_ULong fd_select;
- FT_Stream stream = face->cid_stream;
- FT_Error error = FT_Err_Ok;
- FT_Byte* charstring = NULL;
- FT_Memory memory = face->root.memory;
- FT_ULong glyph_length = 0;
- PSAux_Service psaux = (PSAux_Service)face->psaux;
-
- FT_Bool force_scaling = FALSE;
-
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- FT_Incremental_InterfaceRec *inc =
- face->root.internal->incremental_interface;
-#endif
-
-
- FT_TRACE1(( "cid_load_glyph: glyph index %u\n", glyph_index ));
-
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
-
- /* For incremental fonts get the character data using */
- /* the callback function. */
- if ( inc )
- {
- FT_Data glyph_data;
-
-
- error = inc->funcs->get_glyph_data( inc->object,
- glyph_index, &glyph_data );
- if ( error || glyph_data.length < cid->fd_bytes )
- goto Exit;
-
- p = (FT_Byte*)glyph_data.pointer;
- fd_select = cid_get_offset( &p, cid->fd_bytes );
-
- glyph_length = glyph_data.length - cid->fd_bytes;
-
- if ( !FT_QALLOC( charstring, glyph_length ) )
- FT_MEM_COPY( charstring, glyph_data.pointer + cid->fd_bytes,
- glyph_length );
-
- inc->funcs->free_glyph_data( inc->object, &glyph_data );
-
- if ( error )
- goto Exit;
- }
-
- else
-
-#endif /* FT_CONFIG_OPTION_INCREMENTAL */
- {
- FT_ULong off1, off2;
-
-
- error = cid_compute_fd_and_offsets( face, glyph_index,
- &fd_select, &off1, &off2 );
- if ( error )
- goto Exit;
-
- glyph_length = off2 - off1;
-
- if ( glyph_length == 0 ||
- FT_QALLOC( charstring, glyph_length ) ||
- FT_STREAM_READ_AT( cid->data_offset + off1,
- charstring, glyph_length ) )
- goto Exit;
- }
-
- /* Now set up the subrs array and parse the charstrings. */
- {
- CID_FaceDict dict;
- CID_Subrs cid_subrs = face->subrs + fd_select;
- FT_UInt cs_offset;
-
-
- /* Set up subrs */
- decoder->num_subrs = cid_subrs->num_subrs;
- decoder->subrs = cid_subrs->code;
- decoder->subrs_len = 0;
- decoder->subrs_hash = NULL;
-
- /* Set up font matrix */
- dict = cid->font_dicts + fd_select;
-
- decoder->font_matrix = dict->font_matrix;
- decoder->font_offset = dict->font_offset;
- decoder->lenIV = dict->private_dict.lenIV;
-
- /* Decode the charstring. */
-
- /* Adjustment for seed bytes. */
- cs_offset = decoder->lenIV >= 0 ? (FT_UInt)decoder->lenIV : 0;
- if ( cs_offset > glyph_length )
- {
- FT_TRACE0(( "cid_load_glyph: fail for glyph_index=%d, "
- "offset to the charstring is beyond glyph length\n",
- glyph_index ));
- error = FT_THROW( Invalid_Offset );
- goto Exit;
- }
-
- /* Decrypt only if lenIV >= 0. */
- if ( decoder->lenIV >= 0 )
- psaux->t1_decrypt( charstring, glyph_length, 4330 );
-
- /* choose which renderer to use */
-#ifdef T1_CONFIG_OPTION_OLD_ENGINE
- if ( ( (PS_Driver)FT_FACE_DRIVER( face ) )->hinting_engine ==
- FT_HINTING_FREETYPE ||
- decoder->builder.metrics_only )
- error = psaux->t1_decoder_funcs->parse_charstrings_old(
- decoder,
- charstring + cs_offset,
- glyph_length - cs_offset );
-#else
- if ( decoder->builder.metrics_only )
- error = psaux->t1_decoder_funcs->parse_metrics(
- decoder,
- charstring + cs_offset,
- glyph_length - cs_offset );
-#endif
- else
- {
- PS_Decoder psdecoder;
- CFF_SubFontRec subfont;
-
-
- psaux->ps_decoder_init( &psdecoder, decoder, TRUE );
-
- psaux->t1_make_subfont( FT_FACE( face ),
- &dict->private_dict,
- &subfont );
- psdecoder.current_subfont = &subfont;
-
- error = psaux->t1_decoder_funcs->parse_charstrings(
- &psdecoder,
- charstring + cs_offset,
- glyph_length - cs_offset );
-
- /* Adobe's engine uses 16.16 numbers everywhere; */
- /* as a consequence, glyphs larger than 2000ppem get rejected */
- if ( FT_ERR_EQ( error, Glyph_Too_Big ) )
- {
- /* this time, we retry unhinted and scale up the glyph later on */
- /* (the engine uses and sets the hardcoded value 0x10000 / 64 = */
- /* 0x400 for both `x_scale' and `y_scale' in this case) */
- ((CID_GlyphSlot)decoder->builder.glyph)->hint = FALSE;
-
- force_scaling = TRUE;
-
- error = psaux->t1_decoder_funcs->parse_charstrings(
- &psdecoder,
- charstring + cs_offset,
- glyph_length - cs_offset );
- }
- }
- }
-
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
-
- /* Incremental fonts can optionally override the metrics. */
- if ( !error && inc && inc->funcs->get_glyph_metrics )
- {
- FT_Incremental_MetricsRec metrics;
-
-
- metrics.bearing_x = FIXED_TO_INT( decoder->builder.left_bearing.x );
- metrics.bearing_y = 0;
- metrics.advance = FIXED_TO_INT( decoder->builder.advance.x );
- metrics.advance_v = FIXED_TO_INT( decoder->builder.advance.y );
-
- error = inc->funcs->get_glyph_metrics( inc->object,
- glyph_index, FALSE, &metrics );
-
- decoder->builder.left_bearing.x = INT_TO_FIXED( metrics.bearing_x );
- decoder->builder.advance.x = INT_TO_FIXED( metrics.advance );
- decoder->builder.advance.y = INT_TO_FIXED( metrics.advance_v );
- }
-
-#endif /* FT_CONFIG_OPTION_INCREMENTAL */
-
- Exit:
- FT_FREE( charstring );
-
- ((CID_GlyphSlot)decoder->builder.glyph)->scaled = force_scaling;
-
- return error;
- }
-
-
-#if 0
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /********** *********/
- /********** *********/
- /********** COMPUTE THE MAXIMUM ADVANCE WIDTH *********/
- /********** *********/
- /********** The following code is in charge of computing *********/
- /********** the maximum advance width of the font. It *********/
- /********** quickly processes each glyph charstring to *********/
- /********** extract the value from either a `sbw' or `seac' *********/
- /********** operator. *********/
- /********** *********/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
- FT_LOCAL_DEF( FT_Error )
- cid_face_compute_max_advance( CID_Face face,
- FT_Int* max_advance )
- {
- FT_Error error;
- T1_DecoderRec decoder;
- FT_Int glyph_index;
-
- PSAux_Service psaux = (PSAux_Service)face->psaux;
-
-
- *max_advance = 0;
-
- /* Initialize load decoder */
- error = psaux->t1_decoder_funcs->init( &decoder,
- (FT_Face)face,
- 0, /* size */
- 0, /* glyph slot */
- 0, /* glyph names! XXX */
- 0, /* blend == 0 */
- 0, /* hinting == 0 */
- cid_load_glyph );
- if ( error )
- return error;
-
- /* TODO: initialize decoder.len_buildchar and decoder.buildchar */
- /* if we ever support CID-keyed multiple master fonts */
-
- decoder.builder.metrics_only = 1;
- decoder.builder.load_points = 0;
-
- /* for each glyph, parse the glyph charstring and extract */
- /* the advance width */
- for ( glyph_index = 0; glyph_index < face->root.num_glyphs;
- glyph_index++ )
- {
- /* now get load the unscaled outline */
- error = cid_load_glyph( &decoder, glyph_index );
- /* ignore the error if one occurred - skip to next glyph */
- }
-
- *max_advance = FIXED_TO_INT( decoder.builder.advance.x );
-
- psaux->t1_decoder_funcs->done( &decoder );
-
- return FT_Err_Ok;
- }
-
-
-#endif /* 0 */
-
-
- FT_LOCAL_DEF( FT_Error )
- cid_slot_load_glyph( FT_GlyphSlot cidglyph, /* CID_GlyphSlot */
- FT_Size cidsize, /* CID_Size */
- FT_UInt glyph_index,
- FT_Int32 load_flags )
- {
- CID_GlyphSlot glyph = (CID_GlyphSlot)cidglyph;
- FT_Error error;
- T1_DecoderRec decoder;
- CID_Face face = (CID_Face)cidglyph->face;
- FT_Bool hinting;
- FT_Bool scaled;
-
- PSAux_Service psaux = (PSAux_Service)face->psaux;
- FT_Matrix font_matrix;
- FT_Vector font_offset;
- FT_Bool must_finish_decoder = FALSE;
-
-
- if ( glyph_index >= (FT_UInt)face->root.num_glyphs )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- if ( load_flags & FT_LOAD_NO_RECURSE )
- load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
-
- glyph->x_scale = cidsize->metrics.x_scale;
- glyph->y_scale = cidsize->metrics.y_scale;
-
- cidglyph->outline.n_points = 0;
- cidglyph->outline.n_contours = 0;
-
- hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 &&
- ( load_flags & FT_LOAD_NO_HINTING ) == 0 );
- scaled = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 );
-
- glyph->hint = hinting;
- glyph->scaled = scaled;
- cidglyph->format = FT_GLYPH_FORMAT_OUTLINE;
-
- error = psaux->t1_decoder_funcs->init( &decoder,
- cidglyph->face,
- cidsize,
- cidglyph,
- 0, /* glyph names -- XXX */
- 0, /* blend == 0 */
- hinting,
- FT_LOAD_TARGET_MODE( load_flags ),
- cid_load_glyph );
- if ( error )
- goto Exit;
-
- /* TODO: initialize decoder.len_buildchar and decoder.buildchar */
- /* if we ever support CID-keyed multiple master fonts */
-
- must_finish_decoder = TRUE;
-
- /* set up the decoder */
- decoder.builder.no_recurse = FT_BOOL( load_flags & FT_LOAD_NO_RECURSE );
-
- error = cid_load_glyph( &decoder, glyph_index );
- if ( error )
- goto Exit;
-
- /* copy flags back for forced scaling */
- hinting = glyph->hint;
- scaled = glyph->scaled;
-
- font_matrix = decoder.font_matrix;
- font_offset = decoder.font_offset;
-
- /* save new glyph tables */
- psaux->t1_decoder_funcs->done( &decoder );
-
- must_finish_decoder = FALSE;
-
- /* now set the metrics -- this is rather simple, as */
- /* the left side bearing is the xMin, and the top side */
- /* bearing the yMax */
- cidglyph->outline.flags &= FT_OUTLINE_OWNER;
- cidglyph->outline.flags |= FT_OUTLINE_REVERSE_FILL;
-
- /* for composite glyphs, return only left side bearing and */
- /* advance width */
- if ( load_flags & FT_LOAD_NO_RECURSE )
- {
- FT_Slot_Internal internal = cidglyph->internal;
-
-
- cidglyph->metrics.horiBearingX =
- FIXED_TO_INT( decoder.builder.left_bearing.x );
- cidglyph->metrics.horiAdvance =
- FIXED_TO_INT( decoder.builder.advance.x );
-
- internal->glyph_matrix = font_matrix;
- internal->glyph_delta = font_offset;
- internal->glyph_transformed = 1;
- }
- else
- {
- FT_BBox cbox;
- FT_Glyph_Metrics* metrics = &cidglyph->metrics;
-
-
- /* copy the _unscaled_ advance width */
- metrics->horiAdvance =
- FIXED_TO_INT( decoder.builder.advance.x );
- cidglyph->linearHoriAdvance =
- FIXED_TO_INT( decoder.builder.advance.x );
- cidglyph->internal->glyph_transformed = 0;
-
- /* make up vertical ones */
- metrics->vertAdvance = ( face->cid.font_bbox.yMax -
- face->cid.font_bbox.yMin ) >> 16;
- cidglyph->linearVertAdvance = metrics->vertAdvance;
-
- cidglyph->format = FT_GLYPH_FORMAT_OUTLINE;
-
- if ( cidsize->metrics.y_ppem < 24 )
- cidglyph->outline.flags |= FT_OUTLINE_HIGH_PRECISION;
-
- /* apply the font matrix, if any */
- if ( font_matrix.xx != 0x10000L || font_matrix.yy != 0x10000L ||
- font_matrix.xy != 0 || font_matrix.yx != 0 )
- {
- FT_Outline_Transform( &cidglyph->outline, &font_matrix );
-
- metrics->horiAdvance = FT_MulFix( metrics->horiAdvance,
- font_matrix.xx );
- metrics->vertAdvance = FT_MulFix( metrics->vertAdvance,
- font_matrix.yy );
- }
-
- if ( font_offset.x || font_offset.y )
- {
- FT_Outline_Translate( &cidglyph->outline,
- font_offset.x,
- font_offset.y );
-
- metrics->horiAdvance += font_offset.x;
- metrics->vertAdvance += font_offset.y;
- }
-
- if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 || scaled )
- {
- /* scale the outline and the metrics */
- FT_Int n;
- FT_Outline* cur = decoder.builder.base;
- FT_Vector* vec = cur->points;
- FT_Fixed x_scale = glyph->x_scale;
- FT_Fixed y_scale = glyph->y_scale;
-
-
- /* First of all, scale the points */
- if ( !hinting || !decoder.builder.hints_funcs )
- for ( n = cur->n_points; n > 0; n--, vec++ )
- {
- vec->x = FT_MulFix( vec->x, x_scale );
- vec->y = FT_MulFix( vec->y, y_scale );
- }
-
- /* Then scale the metrics */
- metrics->horiAdvance = FT_MulFix( metrics->horiAdvance, x_scale );
- metrics->vertAdvance = FT_MulFix( metrics->vertAdvance, y_scale );
- }
-
- /* compute the other metrics */
- FT_Outline_Get_CBox( &cidglyph->outline, &cbox );
-
- metrics->width = cbox.xMax - cbox.xMin;
- metrics->height = cbox.yMax - cbox.yMin;
-
- metrics->horiBearingX = cbox.xMin;
- metrics->horiBearingY = cbox.yMax;
-
- if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
- {
- /* make up vertical ones */
- ft_synthesize_vertical_metrics( metrics,
- metrics->vertAdvance );
- }
- }
-
- Exit:
-
- if ( must_finish_decoder )
- psaux->t1_decoder_funcs->done( &decoder );
-
- return error;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cid/cidgload.h b/contrib/libs/freetype/src/cid/cidgload.h
deleted file mode 100644
index 9fdc9db589..0000000000
--- a/contrib/libs/freetype/src/cid/cidgload.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/****************************************************************************
- *
- * cidgload.h
- *
- * OpenType Glyph Loader (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef CIDGLOAD_H_
-#define CIDGLOAD_H_
-
-
-#include "cidobjs.h"
-
-
-FT_BEGIN_HEADER
-
-
-#if 0
-
- /* Compute the maximum advance width of a font through quick parsing */
- FT_LOCAL( FT_Error )
- cid_face_compute_max_advance( CID_Face face,
- FT_Int* max_advance );
-
-#endif /* 0 */
-
- FT_LOCAL( FT_Error )
- cid_slot_load_glyph( FT_GlyphSlot glyph, /* CID_Glyph_Slot */
- FT_Size size, /* CID_Size */
- FT_UInt glyph_index,
- FT_Int32 load_flags );
-
-
- FT_LOCAL( FT_Error )
- cid_compute_fd_and_offsets( CID_Face face,
- FT_UInt glyph_index,
- FT_ULong* fd_select_p,
- FT_ULong* off1_p,
- FT_ULong* off2_p );
-
-
-FT_END_HEADER
-
-#endif /* CIDGLOAD_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cid/cidload.c b/contrib/libs/freetype/src/cid/cidload.c
deleted file mode 100644
index 722f5a34dd..0000000000
--- a/contrib/libs/freetype/src/cid/cidload.c
+++ /dev/null
@@ -1,937 +0,0 @@
-/****************************************************************************
- *
- * cidload.c
- *
- * CID-keyed Type1 font loader (body).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <ft2build.h>
-#include <freetype/internal/ftdebug.h>
-#include FT_CONFIG_CONFIG_H
-#include <freetype/ftmm.h>
-#include <freetype/internal/t1types.h>
-#include <freetype/internal/psaux.h>
-
-#include "cidload.h"
-
-#include "ciderrs.h"
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT cidload
-
-
- /* read a single offset */
- FT_LOCAL_DEF( FT_ULong )
- cid_get_offset( FT_Byte* *start,
- FT_UInt offsize )
- {
- FT_ULong result;
- FT_Byte* p = *start;
-
-
- for ( result = 0; offsize > 0; offsize-- )
- {
- result <<= 8;
- result |= *p++;
- }
-
- *start = p;
- return result;
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** TYPE 1 SYMBOL PARSING *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- static FT_Error
- cid_load_keyword( CID_Face face,
- CID_Loader* loader,
- const T1_Field keyword )
- {
- FT_Error error;
- CID_Parser* parser = &loader->parser;
- FT_Byte* object;
- void* dummy_object;
- CID_FaceInfo cid = &face->cid;
-
-
- /* if the keyword has a dedicated callback, call it */
- if ( keyword->type == T1_FIELD_TYPE_CALLBACK )
- {
- FT_TRACE4(( " %s", keyword->ident ));
-
- keyword->reader( (FT_Face)face, parser );
- error = parser->root.error;
- goto Exit;
- }
-
- /* we must now compute the address of our target object */
- switch ( keyword->location )
- {
- case T1_FIELD_LOCATION_CID_INFO:
- object = (FT_Byte*)cid;
- break;
-
- case T1_FIELD_LOCATION_FONT_INFO:
- object = (FT_Byte*)&cid->font_info;
- break;
-
- case T1_FIELD_LOCATION_FONT_EXTRA:
- object = (FT_Byte*)&face->font_extra;
- break;
-
- case T1_FIELD_LOCATION_BBOX:
- object = (FT_Byte*)&cid->font_bbox;
- break;
-
- default:
- {
- CID_FaceDict dict;
-
-
- if ( parser->num_dict >= cid->num_dicts )
- {
- FT_ERROR(( "cid_load_keyword: invalid use of `%s'\n",
- keyword->ident ));
- error = FT_THROW( Syntax_Error );
- goto Exit;
- }
-
- dict = cid->font_dicts + parser->num_dict;
- switch ( keyword->location )
- {
- case T1_FIELD_LOCATION_PRIVATE:
- object = (FT_Byte*)&dict->private_dict;
- break;
-
- default:
- object = (FT_Byte*)dict;
- }
- }
- }
-
- FT_TRACE4(( " %s", keyword->ident ));
-
- dummy_object = object;
-
- /* now, load the keyword data in the object's field(s) */
- if ( keyword->type == T1_FIELD_TYPE_INTEGER_ARRAY ||
- keyword->type == T1_FIELD_TYPE_FIXED_ARRAY )
- error = cid_parser_load_field_table( &loader->parser, keyword,
- &dummy_object );
- else
- error = cid_parser_load_field( &loader->parser,
- keyword, &dummy_object );
-
- FT_TRACE4(( "\n" ));
-
- Exit:
- return error;
- }
-
-
- FT_CALLBACK_DEF( void )
- cid_parse_font_matrix( FT_Face face, /* CID_Face */
- void* parser_ )
- {
- CID_Face cidface = (CID_Face)face;
- CID_Parser* parser = (CID_Parser*)parser_;
- CID_FaceDict dict;
- FT_Fixed temp[6];
- FT_Fixed temp_scale;
-
-
- if ( parser->num_dict < cidface->cid.num_dicts )
- {
- FT_Matrix* matrix;
- FT_Vector* offset;
- FT_Int result;
-
-
- dict = cidface->cid.font_dicts + parser->num_dict;
- matrix = &dict->font_matrix;
- offset = &dict->font_offset;
-
- /* input is scaled by 1000 to accommodate default FontMatrix */
- result = cid_parser_to_fixed_array( parser, 6, temp, 3 );
-
- if ( result < 6 )
- {
- FT_ERROR(( "cid_parse_font_matrix: not enough matrix elements\n" ));
- goto Exit;
- }
-
- FT_TRACE4(( " [%f %f %f %f %f %f]\n",
- (double)temp[0] / 65536 / 1000,
- (double)temp[1] / 65536 / 1000,
- (double)temp[2] / 65536 / 1000,
- (double)temp[3] / 65536 / 1000,
- (double)temp[4] / 65536 / 1000,
- (double)temp[5] / 65536 / 1000 ));
-
- temp_scale = FT_ABS( temp[3] );
-
- if ( temp_scale == 0 )
- {
- FT_ERROR(( "cid_parse_font_matrix: invalid font matrix\n" ));
- goto Exit;
- }
-
- /* atypical case */
- if ( temp_scale != 0x10000L )
- {
- /* set units per EM based on FontMatrix values */
- face->units_per_EM = (FT_UShort)FT_DivFix( 1000, temp_scale );
-
- temp[0] = FT_DivFix( temp[0], temp_scale );
- temp[1] = FT_DivFix( temp[1], temp_scale );
- temp[2] = FT_DivFix( temp[2], temp_scale );
- temp[4] = FT_DivFix( temp[4], temp_scale );
- temp[5] = FT_DivFix( temp[5], temp_scale );
- temp[3] = temp[3] < 0 ? -0x10000L : 0x10000L;
- }
-
- matrix->xx = temp[0];
- matrix->yx = temp[1];
- matrix->xy = temp[2];
- matrix->yy = temp[3];
-
- if ( !FT_Matrix_Check( matrix ) )
- {
- FT_ERROR(( "t1_parse_font_matrix: invalid font matrix\n" ));
- parser->root.error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- /* note that the font offsets are expressed in integer font units */
- offset->x = temp[4] >> 16;
- offset->y = temp[5] >> 16;
- }
-
- Exit:
- return;
- }
-
-
- FT_CALLBACK_DEF( void )
- parse_fd_array( FT_Face face, /* CID_Face */
- void* parser_ )
- {
- CID_Face cidface = (CID_Face)face;
- CID_Parser* parser = (CID_Parser*)parser_;
- CID_FaceInfo cid = &cidface->cid;
- FT_Memory memory = FT_FACE_MEMORY( face );
- FT_Stream stream = parser->stream;
- FT_Error error = FT_Err_Ok;
- FT_Long num_dicts, max_dicts;
-
-
- num_dicts = cid_parser_to_int( parser );
- if ( num_dicts < 0 || num_dicts > FT_INT_MAX )
- {
- FT_ERROR(( "parse_fd_array: invalid number of dictionaries\n" ));
- goto Exit;
- }
-
- FT_TRACE4(( " %ld\n", num_dicts ));
-
- /*
- * A single entry in the FDArray must (at least) contain the following
- * structure elements.
- *
- * %ADOBeginFontDict 18
- * X dict begin 13
- * /FontMatrix [X X X X] 22
- * /Private X dict begin 22
- * end 4
- * end 4
- * %ADOEndFontDict 16
- *
- * This needs 18+13+22+22+4+4+16=99 bytes or more. Normally, you also
- * need a `dup X' at the very beginning and a `put' at the end, so a
- * rough guess using 100 bytes as the minimum is justified.
- */
- max_dicts = (FT_Long)( stream->size / 100 );
- if ( num_dicts > max_dicts )
- {
- FT_TRACE0(( "parse_fd_array: adjusting FDArray size"
- " (from %ld to %ld)\n",
- num_dicts, max_dicts ));
- num_dicts = max_dicts;
- }
-
- if ( !cid->font_dicts )
- {
- FT_UInt n;
-
-
- if ( FT_NEW_ARRAY( cid->font_dicts, num_dicts ) )
- goto Exit;
-
- cid->num_dicts = num_dicts;
-
- /* set some default values (the same as for Type 1 fonts) */
- for ( n = 0; n < cid->num_dicts; n++ )
- {
- CID_FaceDict dict = cid->font_dicts + n;
-
-
- dict->private_dict.blue_shift = 7;
- dict->private_dict.blue_fuzz = 1;
- dict->private_dict.lenIV = 4;
- dict->private_dict.expansion_factor = (FT_Fixed)( 0.06 * 0x10000L );
- dict->private_dict.blue_scale = (FT_Fixed)(
- 0.039625 * 0x10000L * 1000 );
- }
- }
-
- Exit:
- return;
- }
-
-
- /* By mistake, `expansion_factor' appears both in PS_PrivateRec */
- /* and CID_FaceDictRec (both are public header files and can't */
- /* be thus changed). We simply copy the value. */
-
- FT_CALLBACK_DEF( void )
- parse_expansion_factor( FT_Face face, /* CID_Face */
- void* parser_ )
- {
- CID_Face cidface = (CID_Face)face;
- CID_Parser* parser = (CID_Parser*)parser_;
- CID_FaceDict dict;
-
-
- if ( parser->num_dict < cidface->cid.num_dicts )
- {
- dict = cidface->cid.font_dicts + parser->num_dict;
-
- dict->expansion_factor = cid_parser_to_fixed( parser, 0 );
- dict->private_dict.expansion_factor = dict->expansion_factor;
-
- FT_TRACE4(( "%ld\n", dict->expansion_factor ));
- }
-
- return;
- }
-
-
- /* By mistake, `CID_FaceDictRec' doesn't contain a field for the */
- /* `FontName' keyword. FreeType doesn't need it, but it is nice */
- /* to catch it for producing better trace output. */
-
- FT_CALLBACK_DEF( void )
- parse_font_name( FT_Face face, /* CID_Face */
- void* parser_ )
- {
-#ifdef FT_DEBUG_LEVEL_TRACE
- CID_Face cidface = (CID_Face)face;
- CID_Parser* parser = (CID_Parser*)parser_;
-
-
- if ( parser->num_dict < cidface->cid.num_dicts )
- {
- T1_TokenRec token;
- FT_UInt len;
-
-
- cid_parser_to_token( parser, &token );
-
- len = (FT_UInt)( token.limit - token.start );
- if ( len )
- FT_TRACE4(( " %.*s\n", len, token.start ));
- else
- FT_TRACE4(( " <no value>\n" ));
- }
-#else
- FT_UNUSED( face );
- FT_UNUSED( parser_ );
-#endif
-
- return;
- }
-
-
- static
- const T1_FieldRec cid_field_records[] =
- {
-
-#include "cidtoken.h"
-
- T1_FIELD_CALLBACK( "FDArray", parse_fd_array, 0 )
- T1_FIELD_CALLBACK( "FontMatrix", cid_parse_font_matrix, 0 )
- T1_FIELD_CALLBACK( "ExpansionFactor", parse_expansion_factor, 0 )
- T1_FIELD_CALLBACK( "FontName", parse_font_name, 0 )
-
- T1_FIELD_ZERO
- };
-
-
- static FT_Error
- cid_parse_dict( CID_Face face,
- CID_Loader* loader,
- FT_Byte* base,
- FT_ULong size )
- {
- CID_Parser* parser = &loader->parser;
-
-
- parser->root.cursor = base;
- parser->root.limit = base + size;
- parser->root.error = FT_Err_Ok;
-
- {
- FT_Byte* cur = base;
- FT_Byte* limit = cur + size;
-
-
- for (;;)
- {
- FT_Byte* newlimit;
-
-
- parser->root.cursor = cur;
- cid_parser_skip_spaces( parser );
-
- if ( parser->root.cursor >= limit )
- newlimit = limit - 1 - 17;
- else
- newlimit = parser->root.cursor - 17;
-
- /* look for `%ADOBeginFontDict' */
- for ( ; cur < newlimit; cur++ )
- {
- if ( *cur == '%' &&
- ft_strncmp( (char*)cur, "%ADOBeginFontDict", 17 ) == 0 )
- {
- /* if /FDArray was found, then cid->num_dicts is > 0, and */
- /* we can start increasing parser->num_dict */
- if ( face->cid.num_dicts > 0 )
- {
- parser->num_dict++;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- FT_TRACE4(( " FontDict %u", parser->num_dict ));
- if ( parser->num_dict > face->cid.num_dicts )
- FT_TRACE4(( " (ignored)" ));
- FT_TRACE4(( "\n" ));
-#endif
- }
- }
- }
-
- cur = parser->root.cursor;
- /* no error can occur in cid_parser_skip_spaces */
- if ( cur >= limit )
- break;
-
- cid_parser_skip_PS_token( parser );
- if ( parser->root.cursor >= limit || parser->root.error )
- break;
-
- /* look for immediates */
- if ( *cur == '/' && cur + 2 < limit )
- {
- FT_UInt len;
-
-
- cur++;
- len = (FT_UInt)( parser->root.cursor - cur );
-
- if ( len > 0 && len < 22 )
- {
- /* now compare the immediate name to the keyword table */
- T1_Field keyword = (T1_Field)cid_field_records;
-
-
- while ( keyword->len )
- {
- FT_Byte* name = (FT_Byte*)keyword->ident;
-
-
- if ( keyword->len == len &&
- ft_memcmp( cur, name, len ) == 0 )
- {
- /* we found it - run the parsing callback */
- parser->root.error = cid_load_keyword( face,
- loader,
- keyword );
- if ( parser->root.error )
- return parser->root.error;
- break;
- }
-
- keyword++;
- }
- }
- }
-
- cur = parser->root.cursor;
- }
-
- if ( !face->cid.num_dicts )
- {
- FT_ERROR(( "cid_parse_dict: No font dictionary found\n" ));
- return FT_THROW( Invalid_File_Format );
- }
- }
-
- return parser->root.error;
- }
-
-
- /* read the subrmap and the subrs of each font dict */
- static FT_Error
- cid_read_subrs( CID_Face face )
- {
- CID_FaceInfo cid = &face->cid;
- FT_Memory memory = face->root.memory;
- FT_Stream stream = face->cid_stream;
- FT_Error error;
- FT_UInt n;
- CID_Subrs subr;
- FT_UInt max_offsets = 0;
- FT_ULong* offsets = NULL;
- PSAux_Service psaux = (PSAux_Service)face->psaux;
-
-
- if ( FT_NEW_ARRAY( face->subrs, cid->num_dicts ) )
- goto Exit;
-
- subr = face->subrs;
- for ( n = 0; n < cid->num_dicts; n++, subr++ )
- {
- CID_FaceDict dict = cid->font_dicts + n;
- FT_Int lenIV = dict->private_dict.lenIV;
- FT_UInt count, num_subrs = dict->num_subrs;
- FT_ULong data_len;
- FT_Byte* p;
-
-
- if ( !num_subrs )
- continue;
-
- /* reallocate offsets array if needed */
- if ( num_subrs + 1 > max_offsets )
- {
- FT_UInt new_max = FT_PAD_CEIL( num_subrs + 1, 4 );
-
-
- if ( new_max <= max_offsets )
- {
- error = FT_THROW( Syntax_Error );
- goto Fail;
- }
-
- if ( FT_QRENEW_ARRAY( offsets, max_offsets, new_max ) )
- goto Fail;
-
- max_offsets = new_max;
- }
-
- /* read the subrmap's offsets */
- if ( FT_STREAM_SEEK( cid->data_offset + dict->subrmap_offset ) ||
- FT_FRAME_ENTER( ( num_subrs + 1 ) * dict->sd_bytes ) )
- goto Fail;
-
- p = (FT_Byte*)stream->cursor;
- for ( count = 0; count <= num_subrs; count++ )
- offsets[count] = cid_get_offset( &p, dict->sd_bytes );
-
- FT_FRAME_EXIT();
-
- /* offsets must be ordered */
- for ( count = 1; count <= num_subrs; count++ )
- if ( offsets[count - 1] > offsets[count] )
- {
- FT_ERROR(( "cid_read_subrs: offsets are not ordered\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Fail;
- }
-
- if ( offsets[num_subrs] > stream->size - cid->data_offset )
- {
- FT_ERROR(( "cid_read_subrs: too large `subrs' offsets\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Fail;
- }
-
- /* now, compute the size of subrs charstrings, */
- /* allocate, and read them */
- data_len = offsets[num_subrs] - offsets[0];
-
- if ( FT_QNEW_ARRAY( subr->code, num_subrs + 1 ) ||
- FT_QALLOC( subr->code[0], data_len ) )
- goto Fail;
-
- if ( FT_STREAM_SEEK( cid->data_offset + offsets[0] ) ||
- FT_STREAM_READ( subr->code[0], data_len ) )
- goto Fail;
-
- /* set up pointers */
- for ( count = 1; count <= num_subrs; count++ )
- {
- FT_ULong len;
-
-
- len = offsets[count] - offsets[count - 1];
- subr->code[count] = subr->code[count - 1] + len;
- }
-
- /* decrypt subroutines, but only if lenIV >= 0 */
- if ( lenIV >= 0 )
- {
- for ( count = 0; count < num_subrs; count++ )
- {
- FT_ULong len;
-
-
- len = offsets[count + 1] - offsets[count];
- psaux->t1_decrypt( subr->code[count], len, 4330 );
- }
- }
-
- subr->num_subrs = (FT_Int)num_subrs;
- }
-
- Exit:
- FT_FREE( offsets );
- return error;
-
- Fail:
- if ( face->subrs )
- {
- for ( n = 0; n < cid->num_dicts; n++ )
- {
- if ( face->subrs[n].code )
- FT_FREE( face->subrs[n].code[0] );
-
- FT_FREE( face->subrs[n].code );
- }
- FT_FREE( face->subrs );
- }
- goto Exit;
- }
-
-
- static void
- cid_init_loader( CID_Loader* loader,
- CID_Face face )
- {
- FT_UNUSED( face );
-
- FT_ZERO( loader );
- }
-
-
- static void
- cid_done_loader( CID_Loader* loader )
- {
- CID_Parser* parser = &loader->parser;
-
-
- /* finalize parser */
- cid_parser_done( parser );
- }
-
-
- static FT_Error
- cid_hex_to_binary( FT_Byte* data,
- FT_ULong data_len,
- FT_ULong offset,
- CID_Face face,
- FT_ULong* data_written )
- {
- FT_Stream stream = face->root.stream;
- FT_Error error;
-
- FT_Byte buffer[256];
- FT_Byte *p, *plimit;
- FT_Byte *d = data, *dlimit;
- FT_Byte val;
-
- FT_Bool upper_nibble, done;
-
-
- if ( FT_STREAM_SEEK( offset ) )
- goto Exit;
-
- dlimit = d + data_len;
- p = buffer;
- plimit = p;
-
- upper_nibble = 1;
- done = 0;
-
- while ( d < dlimit )
- {
- if ( p >= plimit )
- {
- FT_ULong oldpos = FT_STREAM_POS();
- FT_ULong size = stream->size - oldpos;
-
-
- if ( size == 0 )
- {
- error = FT_THROW( Syntax_Error );
- goto Exit;
- }
-
- if ( FT_STREAM_READ( buffer, 256 > size ? size : 256 ) )
- goto Exit;
- p = buffer;
- plimit = p + FT_STREAM_POS() - oldpos;
- }
-
- if ( ft_isdigit( *p ) )
- val = (FT_Byte)( *p - '0' );
- else if ( *p >= 'a' && *p <= 'f' )
- val = (FT_Byte)( *p - 'a' + 10 );
- else if ( *p >= 'A' && *p <= 'F' )
- val = (FT_Byte)( *p - 'A' + 10 );
- else if ( *p == ' ' ||
- *p == '\t' ||
- *p == '\r' ||
- *p == '\n' ||
- *p == '\f' ||
- *p == '\0' )
- {
- p++;
- continue;
- }
- else if ( *p == '>' )
- {
- val = 0;
- done = 1;
- }
- else
- {
- error = FT_THROW( Syntax_Error );
- goto Exit;
- }
-
- if ( upper_nibble )
- *d = (FT_Byte)( val << 4 );
- else
- {
- *d = (FT_Byte)( *d + val );
- d++;
- }
-
- upper_nibble = (FT_Byte)( 1 - upper_nibble );
-
- if ( done )
- break;
-
- p++;
- }
-
- error = FT_Err_Ok;
-
- Exit:
- *data_written = (FT_ULong)( d - data );
- return error;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- cid_face_open( CID_Face face,
- FT_Int face_index )
- {
- CID_Loader loader;
- CID_Parser* parser;
- FT_Memory memory = face->root.memory;
- FT_Error error;
- FT_UInt n;
-
- CID_FaceInfo cid = &face->cid;
-
- FT_ULong binary_length;
-
-
- cid_init_loader( &loader, face );
-
- parser = &loader.parser;
- error = cid_parser_new( parser, face->root.stream, face->root.memory,
- (PSAux_Service)face->psaux );
- if ( error )
- goto Exit;
-
- error = cid_parse_dict( face, &loader,
- parser->postscript,
- parser->postscript_len );
- if ( error )
- goto Exit;
-
- if ( face_index < 0 )
- goto Exit;
-
- if ( FT_NEW( face->cid_stream ) )
- goto Exit;
-
- if ( parser->binary_length )
- {
- if ( parser->binary_length >
- face->root.stream->size - parser->data_offset )
- {
- FT_TRACE0(( "cid_face_open: adjusting length of binary data\n" ));
- FT_TRACE0(( " (from %lu to %lu bytes)\n",
- parser->binary_length,
- face->root.stream->size - parser->data_offset ));
- parser->binary_length = face->root.stream->size -
- parser->data_offset;
- }
-
- /* we must convert the data section from hexadecimal to binary */
- if ( FT_QALLOC( face->binary_data, parser->binary_length ) ||
- FT_SET_ERROR( cid_hex_to_binary( face->binary_data,
- parser->binary_length,
- parser->data_offset,
- face,
- &binary_length ) ) )
- goto Exit;
-
- FT_Stream_OpenMemory( face->cid_stream,
- face->binary_data, binary_length );
- cid->data_offset = 0;
- }
- else
- {
- *face->cid_stream = *face->root.stream;
- cid->data_offset = loader.parser.data_offset;
- }
-
- /* sanity tests */
-
- if ( cid->gd_bytes == 0 )
- {
- FT_ERROR(( "cid_face_open:"
- " Invalid `GDBytes' value\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- /* allow at most 32bit offsets */
- if ( cid->fd_bytes > 4 || cid->gd_bytes > 4 )
- {
- FT_ERROR(( "cid_face_open:"
- " Values of `FDBytes' or `GDBytes' larger than 4\n" ));
- FT_ERROR(( " "
- " are not supported\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- binary_length = face->cid_stream->size - cid->data_offset;
-
- if ( cid->cidmap_offset > binary_length )
- {
- FT_ERROR(( "cid_face_open: Invalid `CIDMapOffset' value\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- /* the initial pre-check prevents the multiplication overflow */
- if ( cid->cid_count > FT_ULONG_MAX / 8 ||
- cid->cid_count * ( cid->fd_bytes + cid->gd_bytes ) >
- binary_length - cid->cidmap_offset )
- {
- FT_ERROR(( "cid_face_open: Invalid `CIDCount' value\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
-
- for ( n = 0; n < cid->num_dicts; n++ )
- {
- CID_FaceDict dict = cid->font_dicts + n;
-
-
- /* the upper limits are ad-hoc values */
- if ( dict->private_dict.blue_shift > 1000 ||
- dict->private_dict.blue_shift < 0 )
- {
- FT_TRACE2(( "cid_face_open:"
- " setting unlikely BlueShift value %d to default (7)\n",
- dict->private_dict.blue_shift ));
- dict->private_dict.blue_shift = 7;
- }
-
- if ( dict->private_dict.blue_fuzz > 1000 ||
- dict->private_dict.blue_fuzz < 0 )
- {
- FT_TRACE2(( "cid_face_open:"
- " setting unlikely BlueFuzz value %d to default (1)\n",
- dict->private_dict.blue_fuzz ));
- dict->private_dict.blue_fuzz = 1;
- }
-
- if ( dict->num_subrs && dict->sd_bytes == 0 )
- {
- FT_ERROR(( "cid_face_open: Invalid `SDBytes' value\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- if ( dict->sd_bytes > 4 )
- {
- FT_ERROR(( "cid_face_open:"
- " Values of `SDBytes' larger than 4"
- " are not supported\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- if ( dict->subrmap_offset > binary_length )
- {
- FT_ERROR(( "cid_face_open: Invalid `SubrMapOffset' value\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- /* the initial pre-check prevents the multiplication overflow */
- if ( dict->num_subrs > FT_UINT_MAX / 4 ||
- dict->num_subrs * dict->sd_bytes >
- binary_length - dict->subrmap_offset )
- {
- FT_ERROR(( "cid_face_open: Invalid `SubrCount' value\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
- }
-
- /* we can now safely proceed */
- error = cid_read_subrs( face );
-
- Exit:
- cid_done_loader( &loader );
- return error;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cid/cidload.h b/contrib/libs/freetype/src/cid/cidload.h
deleted file mode 100644
index 7f030b32df..0000000000
--- a/contrib/libs/freetype/src/cid/cidload.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/****************************************************************************
- *
- * cidload.h
- *
- * CID-keyed Type1 font loader (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef CIDLOAD_H_
-#define CIDLOAD_H_
-
-
-#include <freetype/internal/ftstream.h>
-#include "cidparse.h"
-
-
-FT_BEGIN_HEADER
-
-
- typedef struct CID_Loader_
- {
- CID_Parser parser; /* parser used to read the stream */
- FT_Int num_chars; /* number of characters in encoding */
-
- } CID_Loader;
-
-
- FT_LOCAL( FT_ULong )
- cid_get_offset( FT_Byte** start,
- FT_UInt offsize );
-
- FT_LOCAL( FT_Error )
- cid_face_open( CID_Face face,
- FT_Int face_index );
-
-
-FT_END_HEADER
-
-#endif /* CIDLOAD_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cid/cidobjs.c b/contrib/libs/freetype/src/cid/cidobjs.c
deleted file mode 100644
index 8d337c4112..0000000000
--- a/contrib/libs/freetype/src/cid/cidobjs.c
+++ /dev/null
@@ -1,543 +0,0 @@
-/****************************************************************************
- *
- * cidobjs.c
- *
- * CID objects manager (body).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftstream.h>
-
-#include "cidgload.h"
-#include "cidload.h"
-
-#include <freetype/internal/services/svpscmap.h>
-#include <freetype/internal/psaux.h>
-#include <freetype/internal/pshints.h>
-#include <freetype/ftdriver.h>
-
-#include "ciderrs.h"
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT cidobjs
-
-
- /**************************************************************************
- *
- * SLOT FUNCTIONS
- *
- */
-
- FT_LOCAL_DEF( void )
- cid_slot_done( FT_GlyphSlot slot )
- {
- if ( slot->internal )
- slot->internal->glyph_hints = NULL;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- cid_slot_init( FT_GlyphSlot slot )
- {
- CID_Face face;
- PSHinter_Service pshinter;
-
-
- face = (CID_Face)slot->face;
- pshinter = (PSHinter_Service)face->pshinter;
-
- if ( pshinter )
- {
- FT_Module module;
-
-
- module = FT_Get_Module( slot->library, "pshinter" );
- if ( module )
- {
- T1_Hints_Funcs funcs;
-
-
- funcs = pshinter->get_t1_funcs( module );
- slot->internal->glyph_hints = (void*)funcs;
- }
- }
-
- return 0;
- }
-
-
- /**************************************************************************
- *
- * SIZE FUNCTIONS
- *
- */
-
-
- static PSH_Globals_Funcs
- cid_size_get_globals_funcs( CID_Size size )
- {
- CID_Face face = (CID_Face)size->root.face;
- PSHinter_Service pshinter = (PSHinter_Service)face->pshinter;
- FT_Module module;
-
-
- module = FT_Get_Module( size->root.face->driver->root.library,
- "pshinter" );
- return ( module && pshinter && pshinter->get_globals_funcs )
- ? pshinter->get_globals_funcs( module )
- : 0;
- }
-
-
- FT_LOCAL_DEF( void )
- cid_size_done( FT_Size cidsize ) /* CID_Size */
- {
- CID_Size size = (CID_Size)cidsize;
-
-
- if ( cidsize->internal->module_data )
- {
- PSH_Globals_Funcs funcs;
-
-
- funcs = cid_size_get_globals_funcs( size );
- if ( funcs )
- funcs->destroy( (PSH_Globals)cidsize->internal->module_data );
-
- cidsize->internal->module_data = NULL;
- }
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- cid_size_init( FT_Size cidsize ) /* CID_Size */
- {
- CID_Size size = (CID_Size)cidsize;
- FT_Error error = FT_Err_Ok;
- PSH_Globals_Funcs funcs = cid_size_get_globals_funcs( size );
-
-
- if ( funcs )
- {
- PSH_Globals globals;
- CID_Face face = (CID_Face)cidsize->face;
- CID_FaceDict dict = face->cid.font_dicts + face->root.face_index;
- PS_Private priv = &dict->private_dict;
-
-
- error = funcs->create( cidsize->face->memory, priv, &globals );
- if ( !error )
- cidsize->internal->module_data = globals;
- }
-
- return error;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- cid_size_request( FT_Size size,
- FT_Size_Request req )
- {
- FT_Error error;
-
- PSH_Globals_Funcs funcs;
-
-
- error = FT_Request_Metrics( size->face, req );
- if ( error )
- goto Exit;
-
- funcs = cid_size_get_globals_funcs( (CID_Size)size );
-
- if ( funcs )
- funcs->set_scale( (PSH_Globals)size->internal->module_data,
- size->metrics.x_scale,
- size->metrics.y_scale,
- 0, 0 );
-
- Exit:
- return error;
- }
-
-
- /**************************************************************************
- *
- * FACE FUNCTIONS
- *
- */
-
- /**************************************************************************
- *
- * @Function:
- * cid_face_done
- *
- * @Description:
- * Finalizes a given face object.
- *
- * @Input:
- * face ::
- * A pointer to the face object to destroy.
- */
- FT_LOCAL_DEF( void )
- cid_face_done( FT_Face cidface ) /* CID_Face */
- {
- CID_Face face = (CID_Face)cidface;
- FT_Memory memory;
- CID_FaceInfo cid;
- PS_FontInfo info;
-
-
- if ( !face )
- return;
-
- cid = &face->cid;
- info = &cid->font_info;
- memory = cidface->memory;
-
- /* release subrs */
- if ( face->subrs )
- {
- FT_UInt n;
-
-
- for ( n = 0; n < cid->num_dicts; n++ )
- {
- CID_Subrs subr = face->subrs + n;
-
-
- if ( subr->code )
- {
- FT_FREE( subr->code[0] );
- FT_FREE( subr->code );
- }
- }
-
- FT_FREE( face->subrs );
- }
-
- /* release FontInfo strings */
- FT_FREE( info->version );
- FT_FREE( info->notice );
- FT_FREE( info->full_name );
- FT_FREE( info->family_name );
- FT_FREE( info->weight );
-
- /* release font dictionaries */
- FT_FREE( cid->font_dicts );
- cid->num_dicts = 0;
-
- /* release other strings */
- FT_FREE( cid->cid_font_name );
- FT_FREE( cid->registry );
- FT_FREE( cid->ordering );
-
- cidface->family_name = NULL;
- cidface->style_name = NULL;
-
- FT_FREE( face->binary_data );
- FT_FREE( face->cid_stream );
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * cid_face_init
- *
- * @Description:
- * Initializes a given CID face object.
- *
- * @Input:
- * stream ::
- * Dummy argument for compatibility with the `FT_Face_InitFunc` API.
- * Ignored. The stream should be passed through `face->root.stream`.
- *
- * face_index ::
- * The index of the font face in the resource.
- *
- * num_params ::
- * Number of additional generic parameters. Ignored.
- *
- * params ::
- * Additional generic parameters. Ignored.
- *
- * @InOut:
- * face ::
- * The newly built face object.
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
- FT_LOCAL_DEF( FT_Error )
- cid_face_init( FT_Stream stream,
- FT_Face cidface, /* CID_Face */
- FT_Int face_index,
- FT_Int num_params,
- FT_Parameter* params )
- {
- CID_Face face = (CID_Face)cidface;
- FT_Error error;
- PSAux_Service psaux;
- PSHinter_Service pshinter;
-
- FT_UNUSED( num_params );
- FT_UNUSED( params );
- FT_UNUSED( stream );
-
-
- cidface->num_faces = 1;
-
- psaux = (PSAux_Service)face->psaux;
- if ( !psaux )
- {
- psaux = (PSAux_Service)FT_Get_Module_Interface(
- FT_FACE_LIBRARY( face ), "psaux" );
-
- if ( !psaux )
- {
- FT_ERROR(( "cid_face_init: cannot access `psaux' module\n" ));
- error = FT_THROW( Missing_Module );
- goto Exit;
- }
-
- face->psaux = psaux;
- }
-
- pshinter = (PSHinter_Service)face->pshinter;
- if ( !pshinter )
- {
- pshinter = (PSHinter_Service)FT_Get_Module_Interface(
- FT_FACE_LIBRARY( face ), "pshinter" );
-
- face->pshinter = pshinter;
- }
-
- FT_TRACE2(( "CID driver\n" ));
-
- /* open the tokenizer; this will also check the font format */
- if ( FT_STREAM_SEEK( 0 ) )
- goto Exit;
-
- error = cid_face_open( face, face_index );
- if ( error )
- goto Exit;
-
- /* if we just wanted to check the format, leave successfully now */
- if ( face_index < 0 )
- goto Exit;
-
- /* check the face index */
- /* XXX: handle CID fonts with more than a single face */
- if ( ( face_index & 0xFFFF ) != 0 )
- {
- FT_ERROR(( "cid_face_init: invalid face index\n" ));
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- /* now load the font program into the face object */
-
- /* initialize the face object fields */
-
- /* set up root face fields */
- {
- CID_FaceInfo cid = &face->cid;
- PS_FontInfo info = &cid->font_info;
-
-
- cidface->num_glyphs = (FT_Long)cid->cid_count;
- cidface->num_charmaps = 0;
-
- cidface->face_index = face_index & 0xFFFF;
-
- cidface->face_flags |= FT_FACE_FLAG_SCALABLE | /* scalable outlines */
- FT_FACE_FLAG_HORIZONTAL | /* horizontal data */
- FT_FACE_FLAG_HINTER; /* has native hinter */
-
- if ( info->is_fixed_pitch )
- cidface->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
-
- /*
- * For the sfnt-wrapped CID fonts for MacOS, currently,
- * its `cmap' tables are ignored, and the content in
- * its `CID ' table is treated the same as naked CID-keyed
- * font. See ft_lookup_PS_in_sfnt_stream().
- */
- cidface->face_flags |= FT_FACE_FLAG_CID_KEYED;
-
- /* XXX: TODO: add kerning with .afm support */
-
- /* get style name -- be careful, some broken fonts only */
- /* have a /FontName dictionary entry! */
- cidface->family_name = info->family_name;
- /* assume "Regular" style if we don't know better */
- cidface->style_name = (char *)"Regular";
- if ( cidface->family_name )
- {
- char* full = info->full_name;
- char* family = cidface->family_name;
-
-
- if ( full )
- {
- while ( *full )
- {
- if ( *full == *family )
- {
- family++;
- full++;
- }
- else
- {
- if ( *full == ' ' || *full == '-' )
- full++;
- else if ( *family == ' ' || *family == '-' )
- family++;
- else
- {
- if ( !*family )
- cidface->style_name = full;
- break;
- }
- }
- }
- }
- }
- else
- {
- /* do we have a `/FontName'? */
- if ( cid->cid_font_name )
- cidface->family_name = cid->cid_font_name;
- }
-
- /* compute style flags */
- cidface->style_flags = 0;
- if ( info->italic_angle )
- cidface->style_flags |= FT_STYLE_FLAG_ITALIC;
- if ( info->weight )
- {
- if ( !ft_strcmp( info->weight, "Bold" ) ||
- !ft_strcmp( info->weight, "Black" ) )
- cidface->style_flags |= FT_STYLE_FLAG_BOLD;
- }
-
- /* no embedded bitmap support */
- cidface->num_fixed_sizes = 0;
- cidface->available_sizes = NULL;
-
- cidface->bbox.xMin = cid->font_bbox.xMin >> 16;
- cidface->bbox.yMin = cid->font_bbox.yMin >> 16;
- /* no `U' suffix here to 0xFFFF! */
- cidface->bbox.xMax = ( cid->font_bbox.xMax + 0xFFFF ) >> 16;
- cidface->bbox.yMax = ( cid->font_bbox.yMax + 0xFFFF ) >> 16;
-
- if ( !cidface->units_per_EM )
- cidface->units_per_EM = 1000;
-
- cidface->ascender = (FT_Short)( cidface->bbox.yMax );
- cidface->descender = (FT_Short)( cidface->bbox.yMin );
-
- cidface->height = (FT_Short)( ( cidface->units_per_EM * 12 ) / 10 );
- if ( cidface->height < cidface->ascender - cidface->descender )
- cidface->height = (FT_Short)( cidface->ascender - cidface->descender );
-
- cidface->underline_position = (FT_Short)info->underline_position;
- cidface->underline_thickness = (FT_Short)info->underline_thickness;
- }
-
- Exit:
- return error;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * cid_driver_init
- *
- * @Description:
- * Initializes a given CID driver object.
- *
- * @Input:
- * driver ::
- * A handle to the target driver object.
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
- FT_LOCAL_DEF( FT_Error )
- cid_driver_init( FT_Module module )
- {
- PS_Driver driver = (PS_Driver)module;
-
- FT_UInt32 seed;
-
-
- /* set default property values, cf. `ftt1drv.h' */
- driver->hinting_engine = FT_HINTING_ADOBE;
-
- driver->no_stem_darkening = TRUE;
-
- driver->darken_params[0] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1;
- driver->darken_params[1] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1;
- driver->darken_params[2] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2;
- driver->darken_params[3] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2;
- driver->darken_params[4] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3;
- driver->darken_params[5] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3;
- driver->darken_params[6] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4;
- driver->darken_params[7] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4;
-
- /* compute random seed from some memory addresses */
- seed = (FT_UInt32)( (FT_Offset)(char*)&seed ^
- (FT_Offset)(char*)&module ^
- (FT_Offset)(char*)module->memory );
- seed = seed ^ ( seed >> 10 ) ^ ( seed >> 20 );
-
- driver->random_seed = (FT_Int32)seed;
- if ( driver->random_seed < 0 )
- driver->random_seed = -driver->random_seed;
- else if ( driver->random_seed == 0 )
- driver->random_seed = 123456789;
-
- return FT_Err_Ok;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * cid_driver_done
- *
- * @Description:
- * Finalizes a given CID driver.
- *
- * @Input:
- * driver ::
- * A handle to the target CID driver.
- */
- FT_LOCAL_DEF( void )
- cid_driver_done( FT_Module driver )
- {
- FT_UNUSED( driver );
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cid/cidobjs.h b/contrib/libs/freetype/src/cid/cidobjs.h
deleted file mode 100644
index d371cbe995..0000000000
--- a/contrib/libs/freetype/src/cid/cidobjs.h
+++ /dev/null
@@ -1,154 +0,0 @@
-/****************************************************************************
- *
- * cidobjs.h
- *
- * CID objects manager (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef CIDOBJS_H_
-#define CIDOBJS_H_
-
-
-#include <ft2build.h>
-#include <freetype/internal/ftobjs.h>
-#include FT_CONFIG_CONFIG_H
-#include <freetype/internal/t1types.h>
-
-
-FT_BEGIN_HEADER
-
-
- /* The following structures must be defined by the hinter */
- typedef struct CID_Size_Hints_ CID_Size_Hints;
- typedef struct CID_Glyph_Hints_ CID_Glyph_Hints;
-
-
- /**************************************************************************
- *
- * @Type:
- * CID_Driver
- *
- * @Description:
- * A handle to a Type 1 driver object.
- */
- typedef struct CID_DriverRec_* CID_Driver;
-
-
- /**************************************************************************
- *
- * @Type:
- * CID_Size
- *
- * @Description:
- * A handle to a Type 1 size object.
- */
- typedef struct CID_SizeRec_* CID_Size;
-
-
- /**************************************************************************
- *
- * @Type:
- * CID_GlyphSlot
- *
- * @Description:
- * A handle to a Type 1 glyph slot object.
- */
- typedef struct CID_GlyphSlotRec_* CID_GlyphSlot;
-
-
- /**************************************************************************
- *
- * @Type:
- * CID_CharMap
- *
- * @Description:
- * A handle to a Type 1 character mapping object.
- *
- * @Note:
- * The Type 1 format doesn't use a charmap but an encoding table.
- * The driver is responsible for making up charmap objects
- * corresponding to these tables.
- */
- typedef struct CID_CharMapRec_* CID_CharMap;
-
-
- /**************************************************************************
- *
- * HERE BEGINS THE TYPE 1 SPECIFIC STUFF
- *
- */
-
-
- typedef struct CID_SizeRec_
- {
- FT_SizeRec root;
- FT_Bool valid;
-
- } CID_SizeRec;
-
-
- typedef struct CID_GlyphSlotRec_
- {
- FT_GlyphSlotRec root;
-
- FT_Bool hint;
- FT_Bool scaled;
-
- FT_Fixed x_scale;
- FT_Fixed y_scale;
-
- } CID_GlyphSlotRec;
-
-
- FT_LOCAL( void )
- cid_slot_done( FT_GlyphSlot slot );
-
- FT_LOCAL( FT_Error )
- cid_slot_init( FT_GlyphSlot slot );
-
-
- FT_LOCAL( void )
- cid_size_done( FT_Size size ); /* CID_Size */
-
- FT_LOCAL( FT_Error )
- cid_size_init( FT_Size size ); /* CID_Size */
-
- FT_LOCAL( FT_Error )
- cid_size_request( FT_Size size, /* CID_Size */
- FT_Size_Request req );
-
- FT_LOCAL( FT_Error )
- cid_face_init( FT_Stream stream,
- FT_Face face, /* CID_Face */
- FT_Int face_index,
- FT_Int num_params,
- FT_Parameter* params );
-
- FT_LOCAL( void )
- cid_face_done( FT_Face face ); /* CID_Face */
-
-
- FT_LOCAL( FT_Error )
- cid_driver_init( FT_Module driver );
-
- FT_LOCAL( void )
- cid_driver_done( FT_Module driver );
-
-
-FT_END_HEADER
-
-#endif /* CIDOBJS_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cid/cidparse.c b/contrib/libs/freetype/src/cid/cidparse.c
deleted file mode 100644
index 73a3ade893..0000000000
--- a/contrib/libs/freetype/src/cid/cidparse.c
+++ /dev/null
@@ -1,311 +0,0 @@
-/****************************************************************************
- *
- * cidparse.c
- *
- * CID-keyed Type1 parser (body).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/ftstream.h>
-
-#include "cidparse.h"
-
-#include "ciderrs.h"
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT cidparse
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** INPUT STREAM PARSER *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
-#define STARTDATA "StartData"
-#define STARTDATA_LEN ( sizeof ( STARTDATA ) - 1 )
-#define SFNTS "/sfnts"
-#define SFNTS_LEN ( sizeof ( SFNTS ) - 1 )
-
-
- FT_LOCAL_DEF( FT_Error )
- cid_parser_new( CID_Parser* parser,
- FT_Stream stream,
- FT_Memory memory,
- PSAux_Service psaux )
- {
- FT_Error error;
- FT_ULong base_offset, offset, ps_len;
- FT_Byte *cur, *limit;
- FT_Byte *arg1, *arg2;
-
-
- FT_ZERO( parser );
- psaux->ps_parser_funcs->init( &parser->root, 0, 0, memory );
-
- parser->stream = stream;
-
- base_offset = FT_STREAM_POS();
-
- /* first of all, check the font format in the header */
- if ( FT_FRAME_ENTER( 31 ) )
- {
- FT_TRACE2(( " not a CID-keyed font\n" ));
- error = FT_THROW( Unknown_File_Format );
- goto Exit;
- }
-
- if ( ft_strncmp( (char *)stream->cursor,
- "%!PS-Adobe-3.0 Resource-CIDFont", 31 ) )
- {
- FT_TRACE2(( " not a CID-keyed font\n" ));
- error = FT_THROW( Unknown_File_Format );
- }
-
- FT_FRAME_EXIT();
- if ( error )
- goto Exit;
-
- if ( !stream->read ) {
- /* just parse memory-based streams */
- offset = stream->size;
- }
- else
- {
- /* Find the last `StartData` or `/sfnts`. The parser requires */
- /* contiguous memory; attempt to pin as little as necessary. */
-
- /*
- * The algorithm is as follows (omitting the case with less than 256
- * bytes to fill for simplicity).
- *
- * 1. Fill the buffer with 256 + STARTDATA_LEN bytes.
- *
- * 2. Search for the STARTDATA and SFNTS strings at positions
- * buffer[0], buffer[1], ...,
- * buffer[255 + STARTDATA_LEN - SFNTS_LEN].
- *
- * 3. Move the last STARTDATA_LEN bytes to buffer[0].
- *
- * 4. Fill the buffer with 256 bytes, starting at STARTDATA_LEN.
- *
- * 5. Repeat with step 2.
- *
- */
- FT_Byte buffer[256 + STARTDATA_LEN + 1];
-
- /* values for the first loop */
- FT_ULong read_len = 256 + STARTDATA_LEN;
- FT_ULong read_offset = 0;
- FT_Byte* p = buffer;
-
-
- offset = 0;
- while ( 1 )
- {
- FT_ULong stream_len;
-
-
- stream_len = stream->size - FT_STREAM_POS();
-
- read_len = FT_MIN( read_len, stream_len );
- if ( read_len && FT_STREAM_READ( p, read_len ) )
- goto Exit;
-
- /* ensure that we do not compare with data beyond the buffer */
- p[read_len] = '\0';
-
- limit = p + read_len - SFNTS_LEN;
-
- for ( p = buffer; p < limit; p++ )
- {
- if ( p[0] == 'S' &&
- ft_strncmp( (char*)p, STARTDATA, STARTDATA_LEN ) == 0 )
- {
- /* save offset of binary data after `StartData' */
- offset = FT_STREAM_POS() - read_len - read_offset
- + (FT_ULong)( p - buffer ) + STARTDATA_LEN + 1;
- }
- else if ( p[1] == 's' &&
- ft_strncmp( (char*)p, SFNTS, SFNTS_LEN ) == 0 )
- {
- offset = FT_STREAM_POS() - read_len - read_offset
- + (FT_ULong)( p - buffer ) + SFNTS_LEN + 1;
- }
- }
-
- if ( read_offset + read_len <= STARTDATA_LEN )
- {
- if ( offset )
- goto Found;
-
- FT_TRACE2(( "cid_parser_new: no `StartData` keyword found\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- FT_MEM_MOVE( buffer,
- buffer + read_offset + read_len - STARTDATA_LEN,
- STARTDATA_LEN );
-
- /* values for the next loop */
- read_len = 256;
- read_offset = STARTDATA_LEN;
- p = buffer + read_offset;
- }
- }
-
- Found:
- /* We have found an efficient range to look for the binary data or */
- /* `/sfnts' token. Now rewind and extract the frame corresponding to */
- /* this PostScript section. */
-
- ps_len = offset - base_offset;
- if ( FT_STREAM_SEEK( base_offset ) ||
- FT_FRAME_EXTRACT( ps_len, parser->postscript ) )
- goto Exit;
-
- parser->data_offset = offset;
- parser->postscript_len = ps_len;
- parser->root.base = parser->postscript;
- parser->root.cursor = parser->postscript;
- parser->root.limit = parser->root.cursor + ps_len;
- parser->num_dict = FT_UINT_MAX;
-
- /* Find the first real `StartData' or `/sfnts' -- the last one */
- /* could be in a comment or string. We also get the arguments */
- /* of `StartData' to find out whether the data is represented in */
- /* binary or hex format. */
-
- arg1 = parser->root.cursor;
- cid_parser_skip_PS_token( parser );
- cid_parser_skip_spaces ( parser );
- arg2 = parser->root.cursor;
- cid_parser_skip_PS_token( parser );
- cid_parser_skip_spaces ( parser );
-
- limit = parser->root.limit;
- cur = parser->root.cursor;
-
- while ( cur <= limit - SFNTS_LEN )
- {
- if ( parser->root.error )
- {
- error = parser->root.error;
- goto Exit;
- }
-
- if ( cur[0] == 'S' &&
- cur <= limit - STARTDATA_LEN &&
- ft_strncmp( (char*)cur, STARTDATA, STARTDATA_LEN ) == 0 )
- {
- T1_TokenRec type_token;
- FT_Long binary_length;
- FT_ULong found_offset;
-
-
- parser->root.cursor = arg1;
- cid_parser_to_token( parser, &type_token );
- if ( type_token.limit - type_token.start == 5 &&
- ft_memcmp( (char*)type_token.start, "(Hex)", 5 ) == 0 )
- {
- parser->root.cursor = arg2;
- binary_length = cid_parser_to_int( parser );
- if ( binary_length < 0 )
- {
- FT_ERROR(( "cid_parser_new: invalid length of hex data\n" ));
- error = FT_THROW( Invalid_File_Format );
- }
- else
- parser->binary_length = (FT_ULong)binary_length;
- }
-
- /* set the real values for the parser, if different */
- found_offset = (FT_ULong)( cur - parser->postscript )
- + STARTDATA_LEN + 1;
- if ( found_offset != offset )
- {
- FT_FRAME_RELEASE( parser->postscript );
-
- ps_len = found_offset - base_offset;
- if ( FT_STREAM_SEEK( base_offset ) ||
- FT_FRAME_EXTRACT( ps_len, parser->postscript ) )
- goto Exit;
-
- parser->data_offset = found_offset;
- parser->postscript_len = ps_len;
- parser->root.base = parser->postscript;
- parser->root.cursor = parser->postscript;
- parser->root.limit = parser->root.cursor + ps_len;
- }
- goto Exit;
- }
- else if ( cur[1] == 's' &&
- ft_strncmp( (char*)cur, SFNTS, SFNTS_LEN ) == 0 )
- {
- FT_TRACE2(( "cid_parser_new: cannot handle Type 11 fonts\n" ));
- error = FT_THROW( Unknown_File_Format );
- goto Exit;
- }
-
- cid_parser_skip_PS_token( parser );
- cid_parser_skip_spaces ( parser );
- arg1 = arg2;
- arg2 = cur;
- cur = parser->root.cursor;
- }
-
- FT_TRACE2(( "cid_parser_new: no `StartData` token found\n" ));
- error = FT_THROW( Invalid_File_Format );
-
- Exit:
- return error;
- }
-
-
-#undef STARTDATA
-#undef STARTDATA_LEN
-#undef SFNTS
-#undef SFNTS_LEN
-
-
- FT_LOCAL_DEF( void )
- cid_parser_done( CID_Parser* parser )
- {
- /* always free the private dictionary */
- if ( parser->postscript )
- {
- FT_Stream stream = parser->stream;
-
-
- FT_FRAME_RELEASE( parser->postscript );
- }
- parser->root.funcs.done( &parser->root );
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cid/cidparse.h b/contrib/libs/freetype/src/cid/cidparse.h
deleted file mode 100644
index 0f5baddcb9..0000000000
--- a/contrib/libs/freetype/src/cid/cidparse.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/****************************************************************************
- *
- * cidparse.h
- *
- * CID-keyed Type1 parser (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef CIDPARSE_H_
-#define CIDPARSE_H_
-
-
-#include <freetype/internal/t1types.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/internal/psaux.h>
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @Struct:
- * CID_Parser
- *
- * @Description:
- * A CID_Parser is an object used to parse a Type 1 fonts very
- * quickly.
- *
- * @Fields:
- * root ::
- * The root PS_ParserRec fields.
- *
- * stream ::
- * The current input stream.
- *
- * postscript ::
- * A pointer to the data to be parsed.
- *
- * postscript_len ::
- * The length of the data to be parsed.
- *
- * data_offset ::
- * The start position of the binary data (i.e., the
- * end of the data to be parsed.
- *
- * binary_length ::
- * The length of the data after the `StartData'
- * command if the data format is hexadecimal.
- *
- * cid ::
- * A structure which holds the information about
- * the current font.
- *
- * num_dict ::
- * The number of font dictionaries.
- */
- typedef struct CID_Parser_
- {
- PS_ParserRec root;
- FT_Stream stream;
-
- FT_Byte* postscript;
- FT_ULong postscript_len;
-
- FT_ULong data_offset;
-
- FT_ULong binary_length;
-
- CID_FaceInfo cid;
- FT_UInt num_dict;
-
- } CID_Parser;
-
-
- FT_LOCAL( FT_Error )
- cid_parser_new( CID_Parser* parser,
- FT_Stream stream,
- FT_Memory memory,
- PSAux_Service psaux );
-
- FT_LOCAL( void )
- cid_parser_done( CID_Parser* parser );
-
-
- /**************************************************************************
- *
- * PARSING ROUTINES
- *
- */
-
-#define cid_parser_skip_spaces( p ) \
- (p)->root.funcs.skip_spaces( &(p)->root )
-#define cid_parser_skip_PS_token( p ) \
- (p)->root.funcs.skip_PS_token( &(p)->root )
-
-#define cid_parser_to_int( p ) (p)->root.funcs.to_int( &(p)->root )
-#define cid_parser_to_fixed( p, t ) (p)->root.funcs.to_fixed( &(p)->root, t )
-
-#define cid_parser_to_coord_array( p, m, c ) \
- (p)->root.funcs.to_coord_array( &(p)->root, m, c )
-#define cid_parser_to_fixed_array( p, m, f, t ) \
- (p)->root.funcs.to_fixed_array( &(p)->root, m, f, t )
-#define cid_parser_to_token( p, t ) \
- (p)->root.funcs.to_token( &(p)->root, t )
-#define cid_parser_to_token_array( p, t, m, c ) \
- (p)->root.funcs.to_token_array( &(p)->root, t, m, c )
-
-#define cid_parser_load_field( p, f, o ) \
- (p)->root.funcs.load_field( &(p)->root, f, o, 0, 0 )
-#define cid_parser_load_field_table( p, f, o ) \
- (p)->root.funcs.load_field_table( &(p)->root, f, o, 0, 0 )
-
-
-FT_END_HEADER
-
-#endif /* CIDPARSE_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cid/cidriver.c b/contrib/libs/freetype/src/cid/cidriver.c
deleted file mode 100644
index 4be8a5c00d..0000000000
--- a/contrib/libs/freetype/src/cid/cidriver.c
+++ /dev/null
@@ -1,274 +0,0 @@
-/****************************************************************************
- *
- * cidriver.c
- *
- * CID driver interface (body).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include "cidriver.h"
-#include "cidgload.h"
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftpsprop.h>
-
-#include "ciderrs.h"
-
-#include <freetype/internal/services/svpostnm.h>
-#include <freetype/internal/services/svfntfmt.h>
-#include <freetype/internal/services/svpsinfo.h>
-#include <freetype/internal/services/svcid.h>
-#include <freetype/internal/services/svprop.h>
-#include <freetype/ftdriver.h>
-
-#include <freetype/internal/psaux.h>
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT ciddriver
-
-
- /*
- * POSTSCRIPT NAME SERVICE
- *
- */
-
- FT_CALLBACK_DEF( const char* )
- cid_get_postscript_name( FT_Face face ) /* CID_Face */
- {
- CID_Face cidface = (CID_Face)face;
- const char* result = cidface->cid.cid_font_name;
-
-
- if ( result && result[0] == '/' )
- result++;
-
- return result;
- }
-
-
- static const FT_Service_PsFontNameRec cid_service_ps_name =
- {
- (FT_PsName_GetFunc)cid_get_postscript_name /* get_ps_font_name */
- };
-
-
- /*
- * POSTSCRIPT INFO SERVICE
- *
- */
-
- FT_CALLBACK_DEF( FT_Error )
- cid_ps_get_font_info( FT_Face face, /* CID_Face */
- PS_FontInfoRec* afont_info )
- {
- *afont_info = ( (CID_Face)face )->cid.font_info;
-
- return FT_Err_Ok;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- cid_ps_get_font_extra( FT_Face face, /* CID_Face */
- PS_FontExtraRec* afont_extra )
- {
- *afont_extra = ( (CID_Face)face )->font_extra;
-
- return FT_Err_Ok;
- }
-
-
- static const FT_Service_PsInfoRec cid_service_ps_info =
- {
- cid_ps_get_font_info, /* PS_GetFontInfoFunc ps_get_font_info */
- cid_ps_get_font_extra, /* PS_GetFontExtraFunc ps_get_font_extra */
- /* unsupported with CID fonts */
- NULL, /* PS_HasGlyphNamesFunc ps_has_glyph_names */
- /* unsupported */
- NULL, /* PS_GetFontPrivateFunc ps_get_font_private */
- /* not implemented */
- NULL /* PS_GetFontValueFunc ps_get_font_value */
- };
-
-
- /*
- * CID INFO SERVICE
- *
- */
- FT_CALLBACK_DEF( FT_Error )
- cid_get_ros( FT_Face face, /* CID_Face */
- const char* *registry,
- const char* *ordering,
- FT_Int *supplement )
- {
- CID_Face cidface = (CID_Face)face;
- CID_FaceInfo cid = &cidface->cid;
-
-
- if ( registry )
- *registry = cid->registry;
-
- if ( ordering )
- *ordering = cid->ordering;
-
- if ( supplement )
- *supplement = cid->supplement;
-
- return FT_Err_Ok;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- cid_get_is_cid( FT_Face face, /* CID_Face */
- FT_Bool *is_cid )
- {
- FT_Error error = FT_Err_Ok;
- FT_UNUSED( face );
-
-
- /*
- * XXX: If the ROS is Adobe-Identity-H or -V,
- * the font has no reliable information about
- * its glyph collection. Should we not set
- * *is_cid in such cases?
- */
- if ( is_cid )
- *is_cid = 1;
-
- return error;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- cid_get_cid_from_glyph_index( FT_Face face, /* CID_Face */
- FT_UInt glyph_index,
- FT_UInt *cid )
- {
- FT_Error error = FT_Err_Ok;
- CID_Face cidface = (CID_Face)face;
-
-
- /*
- * Currently, FreeType does not support incrementally-defined, CID-keyed
- * fonts that store the glyph description data in a `/GlyphDirectory`
- * array or dictionary. Fonts loaded by the incremental loading feature
- * are thus not handled here.
- */
- error = cid_compute_fd_and_offsets( cidface, glyph_index,
- NULL, NULL, NULL );
- if ( error )
- *cid = 0;
- else
- *cid = glyph_index;
-
- return error;
- }
-
-
- static const FT_Service_CIDRec cid_service_cid_info =
- {
- cid_get_ros,
- /* FT_CID_GetRegistryOrderingSupplementFunc get_ros */
- cid_get_is_cid,
- /* FT_CID_GetIsInternallyCIDKeyedFunc get_is_cid */
- cid_get_cid_from_glyph_index
- /* FT_CID_GetCIDFromGlyphIndexFunc get_cid_from_glyph_index */
- };
-
-
- /*
- * PROPERTY SERVICE
- *
- */
-
- FT_DEFINE_SERVICE_PROPERTIESREC(
- cid_service_properties,
-
- ps_property_set, /* FT_Properties_SetFunc set_property */
- ps_property_get /* FT_Properties_GetFunc get_property */
- )
-
- /*
- * SERVICE LIST
- *
- */
-
- static const FT_ServiceDescRec cid_services[] =
- {
- { FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CID },
- { FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &cid_service_ps_name },
- { FT_SERVICE_ID_POSTSCRIPT_INFO, &cid_service_ps_info },
- { FT_SERVICE_ID_CID, &cid_service_cid_info },
- { FT_SERVICE_ID_PROPERTIES, &cid_service_properties },
- { NULL, NULL }
- };
-
-
- FT_CALLBACK_DEF( FT_Module_Interface )
- cid_get_interface( FT_Module module,
- const char* cid_interface )
- {
- FT_UNUSED( module );
-
- return ft_service_list_lookup( cid_services, cid_interface );
- }
-
-
- FT_CALLBACK_TABLE_DEF
- const FT_Driver_ClassRec t1cid_driver_class =
- {
- {
- FT_MODULE_FONT_DRIVER |
- FT_MODULE_DRIVER_SCALABLE |
- FT_MODULE_DRIVER_HAS_HINTER,
- sizeof ( PS_DriverRec ),
-
- "t1cid", /* module name */
- 0x10000L, /* version 1.0 of driver */
- 0x20000L, /* requires FreeType 2.0 */
-
- NULL, /* module-specific interface */
-
- cid_driver_init, /* FT_Module_Constructor module_init */
- cid_driver_done, /* FT_Module_Destructor module_done */
- cid_get_interface /* FT_Module_Requester get_interface */
- },
-
- sizeof ( CID_FaceRec ),
- sizeof ( CID_SizeRec ),
- sizeof ( CID_GlyphSlotRec ),
-
- cid_face_init, /* FT_Face_InitFunc init_face */
- cid_face_done, /* FT_Face_DoneFunc done_face */
- cid_size_init, /* FT_Size_InitFunc init_size */
- cid_size_done, /* FT_Size_DoneFunc done_size */
- cid_slot_init, /* FT_Slot_InitFunc init_slot */
- cid_slot_done, /* FT_Slot_DoneFunc done_slot */
-
- cid_slot_load_glyph, /* FT_Slot_LoadFunc load_glyph */
-
- NULL, /* FT_Face_GetKerningFunc get_kerning */
- NULL, /* FT_Face_AttachFunc attach_file */
- NULL, /* FT_Face_GetAdvancesFunc get_advances */
-
- cid_size_request, /* FT_Size_RequestFunc request_size */
- NULL /* FT_Size_SelectFunc select_size */
- };
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cid/cidriver.h b/contrib/libs/freetype/src/cid/cidriver.h
deleted file mode 100644
index 7ddce431c5..0000000000
--- a/contrib/libs/freetype/src/cid/cidriver.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/****************************************************************************
- *
- * cidriver.h
- *
- * High-level CID driver interface (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef CIDRIVER_H_
-#define CIDRIVER_H_
-
-
-#include <freetype/internal/ftdrv.h>
-
-
-FT_BEGIN_HEADER
-
- FT_CALLBACK_TABLE
- const FT_Driver_ClassRec t1cid_driver_class;
-
-FT_END_HEADER
-
-#endif /* CIDRIVER_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cid/cidtoken.h b/contrib/libs/freetype/src/cid/cidtoken.h
deleted file mode 100644
index 160897d144..0000000000
--- a/contrib/libs/freetype/src/cid/cidtoken.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/****************************************************************************
- *
- * cidtoken.h
- *
- * CID token definitions (specification only).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#undef FT_STRUCTURE
-#define FT_STRUCTURE CID_FaceInfoRec
-#undef T1CODE
-#define T1CODE T1_FIELD_LOCATION_CID_INFO
-
- T1_FIELD_KEY ( "CIDFontName", cid_font_name, 0 )
- T1_FIELD_FIXED ( "CIDFontVersion", cid_version, 0 )
- T1_FIELD_NUM ( "CIDFontType", cid_font_type, 0 )
- T1_FIELD_STRING ( "Registry", registry, 0 )
- T1_FIELD_STRING ( "Ordering", ordering, 0 )
- T1_FIELD_NUM ( "Supplement", supplement, 0 )
- T1_FIELD_NUM ( "UIDBase", uid_base, 0 )
-
- T1_FIELD_NUM_TABLE( "XUID", xuid, 16, 0 )
-
- T1_FIELD_NUM ( "CIDMapOffset", cidmap_offset, 0 )
- T1_FIELD_NUM ( "FDBytes", fd_bytes, 0 )
- T1_FIELD_NUM ( "GDBytes", gd_bytes, 0 )
- T1_FIELD_NUM ( "CIDCount", cid_count, 0 )
-
-
-#undef FT_STRUCTURE
-#define FT_STRUCTURE PS_FontInfoRec
-#undef T1CODE
-#define T1CODE T1_FIELD_LOCATION_FONT_INFO
-
- T1_FIELD_STRING( "version", version, 0 )
- T1_FIELD_STRING( "Notice", notice, 0 )
- T1_FIELD_STRING( "FullName", full_name, 0 )
- T1_FIELD_STRING( "FamilyName", family_name, 0 )
- T1_FIELD_STRING( "Weight", weight, 0 )
- T1_FIELD_NUM ( "ItalicAngle", italic_angle, 0 )
- T1_FIELD_BOOL ( "isFixedPitch", is_fixed_pitch, 0 )
- T1_FIELD_NUM ( "UnderlinePosition", underline_position, 0 )
- T1_FIELD_NUM ( "UnderlineThickness", underline_thickness, 0 )
-
-#undef FT_STRUCTURE
-#define FT_STRUCTURE PS_FontExtraRec
-#undef T1CODE
-#define T1CODE T1_FIELD_LOCATION_FONT_EXTRA
-
- T1_FIELD_NUM ( "FSType", fs_type, 0 )
-
-
-#undef FT_STRUCTURE
-#define FT_STRUCTURE CID_FaceDictRec
-#undef T1CODE
-#define T1CODE T1_FIELD_LOCATION_FONT_DICT
-
- T1_FIELD_NUM ( "PaintType", paint_type, 0 )
- T1_FIELD_NUM ( "FontType", font_type, 0 )
- T1_FIELD_NUM ( "SubrMapOffset", subrmap_offset, 0 )
- T1_FIELD_NUM ( "SDBytes", sd_bytes, 0 )
- T1_FIELD_NUM ( "SubrCount", num_subrs, 0 )
- T1_FIELD_NUM ( "lenBuildCharArray", len_buildchar, 0 )
- T1_FIELD_FIXED( "ForceBoldThreshold", forcebold_threshold, 0 )
- T1_FIELD_FIXED( "StrokeWidth", stroke_width, 0 )
-
-
-#undef FT_STRUCTURE
-#define FT_STRUCTURE PS_PrivateRec
-#undef T1CODE
-#define T1CODE T1_FIELD_LOCATION_PRIVATE
-
- T1_FIELD_NUM ( "UniqueID", unique_id, 0 )
- T1_FIELD_NUM ( "lenIV", lenIV, 0 )
- T1_FIELD_NUM ( "LanguageGroup", language_group, 0 )
- T1_FIELD_NUM ( "password", password, 0 )
-
- T1_FIELD_FIXED_1000( "BlueScale", blue_scale, 0 )
- T1_FIELD_NUM ( "BlueShift", blue_shift, 0 )
- T1_FIELD_NUM ( "BlueFuzz", blue_fuzz, 0 )
-
- T1_FIELD_NUM_TABLE ( "BlueValues", blue_values, 14, 0 )
- T1_FIELD_NUM_TABLE ( "OtherBlues", other_blues, 10, 0 )
- T1_FIELD_NUM_TABLE ( "FamilyBlues", family_blues, 14, 0 )
- T1_FIELD_NUM_TABLE ( "FamilyOtherBlues", family_other_blues, 10, 0 )
-
- T1_FIELD_NUM_TABLE2( "StdHW", standard_width, 1, 0 )
- T1_FIELD_NUM_TABLE2( "StdVW", standard_height, 1, 0 )
- T1_FIELD_NUM_TABLE2( "MinFeature", min_feature, 2, 0 )
-
- T1_FIELD_NUM_TABLE ( "StemSnapH", snap_widths, 12, 0 )
- T1_FIELD_NUM_TABLE ( "StemSnapV", snap_heights, 12, 0 )
-
- T1_FIELD_BOOL ( "ForceBold", force_bold, 0 )
-
-
-#undef FT_STRUCTURE
-#define FT_STRUCTURE FT_BBox
-#undef T1CODE
-#define T1CODE T1_FIELD_LOCATION_BBOX
-
- T1_FIELD_BBOX( "FontBBox", xMin, 0 )
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/cid/type1cid.c b/contrib/libs/freetype/src/cid/type1cid.c
deleted file mode 100644
index 890a3ac549..0000000000
--- a/contrib/libs/freetype/src/cid/type1cid.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/****************************************************************************
- *
- * type1cid.c
- *
- * FreeType OpenType driver component (body only).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#define FT_MAKE_OPTION_SINGLE_OBJECT
-
-#include "cidgload.c"
-#include "cidload.c"
-#include "cidobjs.c"
-#include "cidparse.c"
-#include "cidriver.c"
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/dlg/dlg.c b/contrib/libs/freetype/src/dlg/dlg.c
deleted file mode 100644
index 0e6bc74b6c..0000000000
--- a/contrib/libs/freetype/src/dlg/dlg.c
+++ /dev/null
@@ -1,803 +0,0 @@
-// Copyright (c) 2019 nyorain
-// Distributed under the Boost Software License, Version 1.0.
-// See accompanying file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt
-
-#define _XOPEN_SOURCE 600
-#define _POSIX_C_SOURCE 200809L
-#define _WIN32_WINNT 0x0600
-
-// Needed on windows so that we can use sprintf without warning.
-#define _CRT_SECURE_NO_WARNINGS
-
-#include <dlg/output.h>
-#include <dlg/dlg.h>
-#include <wchar.h>
-#include <time.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-const char* const dlg_reset_sequence = "\033[0m";
-const struct dlg_style dlg_default_output_styles[] = {
- {dlg_text_style_italic, dlg_color_green, dlg_color_none},
- {dlg_text_style_dim, dlg_color_gray, dlg_color_none},
- {dlg_text_style_none, dlg_color_cyan, dlg_color_none},
- {dlg_text_style_none, dlg_color_yellow, dlg_color_none},
- {dlg_text_style_none, dlg_color_red, dlg_color_none},
- {dlg_text_style_bold, dlg_color_red, dlg_color_none}
-};
-
-static void* xalloc(size_t size) {
- void* ret = calloc(size, 1);
- if(!ret) fprintf(stderr, "dlg: calloc returned NULL, probably crashing (size: %zu)\n", size);
- return ret;
-}
-
-static void* xrealloc(void* ptr, size_t size) {
- void* ret = realloc(ptr, size);
- if(!ret) fprintf(stderr, "dlg: realloc returned NULL, probably crashing (size: %zu)\n", size);
- return ret;
-}
-
-struct dlg_tag_func_pair {
- const char* tag;
- const char* func;
-};
-
-struct dlg_data {
- const char** tags; // vec
- struct dlg_tag_func_pair* pairs; // vec
- char* buffer;
- size_t buffer_size;
-};
-
-static dlg_handler g_handler = dlg_default_output;
-static void* g_data = NULL;
-
-static void dlg_free_data(void* data);
-static struct dlg_data* dlg_create_data(void);
-
-// platform-specific
-#if defined(__unix__) || defined(__unix) || defined(__linux__) || defined(__APPLE__) || defined(__MACH__)
- #define DLG_OS_UNIX
- #include <unistd.h>
- #include <pthread.h>
- #include <sys/time.h>
-
- static pthread_key_t dlg_data_key;
-
- static void dlg_main_cleanup(void) {
- void* data = pthread_getspecific(dlg_data_key);
- if(data) {
- dlg_free_data(data);
- pthread_setspecific(dlg_data_key, NULL);
- }
- }
-
- static void init_data_key(void) {
- pthread_key_create(&dlg_data_key, dlg_free_data);
- atexit(dlg_main_cleanup);
- }
-
- static struct dlg_data* dlg_data(void) {
- static pthread_once_t key_once = PTHREAD_ONCE_INIT;
- pthread_once(&key_once, init_data_key);
-
- void* data = pthread_getspecific(dlg_data_key);
- if(!data) {
- data = dlg_create_data();
- pthread_setspecific(dlg_data_key, data);
- }
-
- return (struct dlg_data*) data;
- }
-
- static void lock_file(FILE* file) {
- flockfile(file);
- }
-
- static void unlock_file(FILE* file) {
- funlockfile(file);
- }
-
- bool dlg_is_tty(FILE* stream) {
- return isatty(fileno(stream));
- }
-
- static unsigned get_msecs(void) {
- struct timeval tv;
- gettimeofday(&tv, NULL);
- return tv.tv_usec;
- }
-
-// platform switch -- end unix
-#elif defined(WIN32) || defined(_WIN32) || defined(_WIN64)
- #define DLG_OS_WIN
- #define WIN32_LEAN_AND_MEAN
- #define DEFINE_CONSOLEV2_PROPERTIES
- #include <windows.h>
- #include <io.h>
-
- // thanks for nothing, microsoft
- #ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING
- #define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
- #endif
-
- // the max buffer size we will convert on the stack
- #define DLG_MAX_STACK_BUF_SIZE 1024
-
- static void WINAPI dlg_fls_destructor(void* data) {
- dlg_free_data(data);
- }
-
- // TODO: error handling
- static BOOL CALLBACK dlg_init_fls(PINIT_ONCE io, void* param, void** lpContext) {
- (void) io;
- (void) param;
- **((DWORD**) lpContext) = FlsAlloc(dlg_fls_destructor);
- return true;
- }
-
- static struct dlg_data* dlg_data(void) {
- static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT;
- static DWORD fls = 0;
- void* flsp = (void*) &fls;
- InitOnceExecuteOnce(&init_once, dlg_init_fls, NULL, &flsp);
- void* data = FlsGetValue(fls);
- if(!data) {
- data = dlg_create_data();
- FlsSetValue(fls, data);
- }
-
- return (struct dlg_data*) data;
- }
-
- static void lock_file(FILE* file) {
- _lock_file(file);
- }
-
- static void unlock_file(FILE* file) {
- _unlock_file(file);
- }
-
- bool dlg_is_tty(FILE* stream) {
- return _isatty(_fileno(stream));
- }
-
-#ifdef DLG_WIN_CONSOLE
- static bool init_ansi_console(void) {
- HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE);
- HANDLE err = GetStdHandle(STD_ERROR_HANDLE);
- if(out == INVALID_HANDLE_VALUE || err == INVALID_HANDLE_VALUE)
- return false;
-
- DWORD outMode, errMode;
- if(!GetConsoleMode(out, &outMode) || !GetConsoleMode(err, &errMode))
- return false;
-
- outMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
- errMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
- if(!SetConsoleMode(out, outMode) || !SetConsoleMode(out, errMode))
- return false;
-
- return true;
- }
-
- static bool win_write_heap(void* handle, int needed, const char* format, va_list args) {
- char* buf1 = xalloc(3 * needed + 3 + (needed % 2));
- wchar_t* buf2 = (wchar_t*) (buf1 + needed + 1 + (needed % 2));
- vsnprintf(buf1, needed + 1, format, args);
- needed = MultiByteToWideChar(CP_UTF8, 0, buf1, needed, buf2, needed + 1);
- bool ret = (needed != 0 && WriteConsoleW(handle, buf2, needed, NULL, NULL) != 0);
- free(buf1);
- return ret;
- }
-
- static bool win_write_stack(void* handle, int needed, const char* format, va_list args) {
- char buf1[DLG_MAX_STACK_BUF_SIZE];
- wchar_t buf2[DLG_MAX_STACK_BUF_SIZE];
- vsnprintf(buf1, needed + 1, format, args);
- needed = MultiByteToWideChar(CP_UTF8, 0, buf1, needed, buf2, needed + 1);
- return (needed != 0 && WriteConsoleW(handle, buf2, needed, NULL, NULL) != 0);
- }
-#endif // DLG_WIN_CONSOLE
-
- static unsigned get_msecs() {
- SYSTEMTIME st;
- GetSystemTime(&st);
- return st.wMilliseconds;
- }
-
-#else // platform switch -- end windows
- #error Cannot determine platform (needed for color and utf-8 and stuff)
-#endif
-
-// general
-void dlg_escape_sequence(struct dlg_style style, char buf[12]) {
- int nums[3];
- unsigned int count = 0;
-
- if(style.fg != dlg_color_none) {
- nums[count++] = style.fg + 30;
- }
-
- if(style.bg != dlg_color_none) {
- nums[count++] = style.fg + 40;
- }
-
- if(style.style != dlg_text_style_none) {
- nums[count++] = style.style;
- }
-
- switch(count) {
- case 1: snprintf(buf, 12, "\033[%dm", nums[0]); break;
- case 2: snprintf(buf, 12, "\033[%d;%dm", nums[0], nums[1]); break;
- case 3: snprintf(buf, 12, "\033[%d;%d;%dm", nums[0], nums[1], nums[2]); break;
- default: buf[0] = '\0'; break;
- }
-}
-
-int dlg_vfprintf(FILE* stream, const char* format, va_list args) {
-#if defined(DLG_OS_WIN) && defined(DLG_WIN_CONSOLE)
- void* handle = NULL;
- if(stream == stdout) {
- handle = GetStdHandle(STD_OUTPUT_HANDLE);
- } else if(stream == stderr) {
- handle = GetStdHandle(STD_ERROR_HANDLE);
- }
-
- if(handle) {
- va_list args_copy;
- va_copy(args_copy, args);
- int needed = vsnprintf(NULL, 0, format, args_copy);
- va_end(args_copy);
-
- if(needed < 0) {
- return needed;
- }
-
- // We don't allocate too much on the stack
- // but we also don't want to call alloc every logging call
- // or use another cached buffer
- if(needed >= DLG_MAX_STACK_BUF_SIZE) {
- if(win_write_heap(handle, needed, format, args)) {
- return needed;
- }
- } else {
- if(win_write_stack(handle, needed, format, args)) {
- return needed;
- }
- }
- }
-#endif
-
- return vfprintf(stream, format, args);
-}
-
-int dlg_fprintf(FILE* stream, const char* format, ...) {
- va_list args;
- va_start(args, format);
- int ret = dlg_vfprintf(stream, format, args);
- va_end(args);
- return ret;
-}
-
-int dlg_styled_fprintf(FILE* stream, struct dlg_style style, const char* format, ...) {
- char buf[12];
- dlg_escape_sequence(style, buf);
-
- fprintf(stream, "%s", buf);
- va_list args;
- va_start(args, format);
- int ret = dlg_vfprintf(stream, format, args);
- va_end(args);
- fprintf(stream, "%s", dlg_reset_sequence);
- return ret;
-}
-
-void dlg_generic_output(dlg_generic_output_handler output, void* data,
- unsigned int features, const struct dlg_origin* origin, const char* string,
- const struct dlg_style styles[6]) {
- // We never print any dynamic content below so we can be sure at compile
- // time that a buffer of size 64 is large enough.
- char format_buf[64];
- char* format = format_buf;
-
- if(features & dlg_output_style) {
- format += sprintf(format, "%%s");
- }
-
- if(features & (dlg_output_time | dlg_output_file_line | dlg_output_tags | dlg_output_func)) {
- format += sprintf(format, "[");
- }
-
- bool first_meta = true;
- if(features & dlg_output_time) {
- format += sprintf(format, "%%h");
- first_meta = false;
- }
-
- if(features & dlg_output_time_msecs) {
- if(!first_meta) {
- format += sprintf(format, ":");
- }
-
- format += sprintf(format, "%%m");
- first_meta = false;
- }
-
- if(features & dlg_output_file_line) {
- if(!first_meta) {
- format += sprintf(format, " ");
- }
-
- format += sprintf(format, "%%o");
- first_meta = false;
- }
-
- if(features & dlg_output_func) {
- if(!first_meta) {
- format += sprintf(format, " ");
- }
-
- format += sprintf(format, "%%f");
- first_meta = false;
- }
-
- if(features & dlg_output_tags) {
- if(!first_meta) {
- format += sprintf(format, " ");
- }
-
- format += sprintf(format, "{%%t}");
- first_meta = false;
- }
-
- if(features & (dlg_output_time | dlg_output_file_line | dlg_output_tags | dlg_output_func)) {
- format += sprintf(format, "] ");
- }
-
- format += sprintf(format, "%%c");
-
- if(features & dlg_output_newline) {
- format += sprintf(format, "\n");
- }
-
- *format = '\0';
- dlg_generic_outputf(output, data, format_buf, origin, string, styles);
-}
-
-void dlg_generic_outputf(dlg_generic_output_handler output, void* data,
- const char* format_string, const struct dlg_origin* origin, const char* string,
- const struct dlg_style styles[6]) {
- bool reset_style = false;
- for(const char* it = format_string; *it; it++) {
- if(*it != '%') {
- output(data, "%c", *it);
- continue;
- }
-
- char next = *(it + 1); // must be valid since *it is not '\0'
- if(next == 'h') {
- time_t t = time(NULL);
- struct tm tm_info;
-
- #ifdef DLG_OS_WIN
- if(localtime_s(&tm_info, &t)) {
- #else
- if(!localtime_r(&t, &tm_info)) {
- #endif
- output(data, "<DATE ERROR>");
- } else {
- char timebuf[32];
- strftime(timebuf, sizeof(timebuf), "%H:%M:%S", &tm_info);
- output(data, "%s", timebuf);
- }
- it++;
- } else if(next == 'm') {
- output(data, "%06d", get_msecs());
- it++;
- } else if(next == 't') {
- bool first_tag = true;
- for(const char** tags = origin->tags; *tags; ++tags) {
- if(!first_tag) {
- output(data, ", ");
- }
-
- output(data, "%s", *tags);
- first_tag = false;
- }
- ++it;
- } else if(next == 'f') {
- output(data, "%s", origin->func);
- ++it;
- } else if(next == 'o') {
- output(data, "%s:%u", origin->file, origin->line);
- ++it;
- } else if(next == 's') {
- char buf[12];
- dlg_escape_sequence(styles[origin->level], buf);
- output(data, "%s", buf);
- reset_style = true;
- ++it;
- } else if(next == 'r') {
- output(data, "%s", dlg_reset_sequence);
- reset_style = false;
- ++it;
- } else if(next == 'c') {
- if(origin->expr && string) {
- output(data, "assertion '%s' failed: '%s'", origin->expr, string);
- } else if(origin->expr) {
- output(data, "assertion '%s' failed", origin->expr);
- } else if(string) {
- output(data, "%s", string);
- }
- ++it;
- } else if(next == '%') {
- output(data, "%s", "%");
- ++it;
- } else {
- // in this case it's a '%' without known format specifier following
- output(data, "%s", "%");
- }
- }
-
- if(reset_style) {
- output(data, "%s", dlg_reset_sequence);
- }
-}
-
-struct buf {
- char* buf;
- size_t* size;
-};
-
-static void print_size(void* size, const char* format, ...) {
- va_list args;
- va_start(args, format);
-
- int ret = vsnprintf(NULL, 0, format, args);
- va_end(args);
-
- if(ret > 0) {
- *((size_t*) size) += ret;
- }
-}
-
-static void print_buf(void* dbuf, const char* format, ...) {
- struct buf* buf = (struct buf*) dbuf;
- va_list args;
- va_start(args, format);
-
- int printed = vsnprintf(buf->buf, *buf->size, format, args);
- va_end(args);
-
- if(printed > 0) {
- *buf->size -= printed;
- buf->buf += printed;
- }
-}
-
-void dlg_generic_output_buf(char* buf, size_t* size, unsigned int features,
- const struct dlg_origin* origin, const char* string,
- const struct dlg_style styles[6]) {
- if(buf) {
- struct buf mbuf;
- mbuf.buf = buf;
- mbuf.size = size;
- dlg_generic_output(print_buf, &mbuf, features, origin, string, styles);
- } else {
- *size = 0;
- dlg_generic_output(print_size, size, features, origin, string, styles);
- }
-}
-
-void dlg_generic_outputf_buf(char* buf, size_t* size, const char* format_string,
- const struct dlg_origin* origin, const char* string,
- const struct dlg_style styles[6]) {
- if(buf) {
- struct buf mbuf;
- mbuf.buf = buf;
- mbuf.size = size;
- dlg_generic_outputf(print_buf, &mbuf, format_string, origin, string, styles);
- } else {
- *size = 0;
- dlg_generic_outputf(print_size, size, format_string, origin, string, styles);
- }
-}
-
-static void print_stream(void* stream, const char* format, ...) {
- va_list args;
- va_start(args, format);
- dlg_vfprintf((FILE*) stream, format, args);
- va_end(args);
-}
-
-void dlg_generic_output_stream(FILE* stream, unsigned int features,
- const struct dlg_origin* origin, const char* string,
- const struct dlg_style styles[6]) {
- stream = stream ? stream : stdout;
- if(features & dlg_output_threadsafe) {
- lock_file(stream);
- }
-
- dlg_generic_output(print_stream, stream, features, origin, string, styles);
- if(features & dlg_output_threadsafe) {
- unlock_file(stream);
- }
-}
-
-void dlg_generic_outputf_stream(FILE* stream, const char* format_string,
- const struct dlg_origin* origin, const char* string,
- const struct dlg_style styles[6], bool lock_stream) {
- stream = stream ? stream : stdout;
- if(lock_stream) {
- lock_file(stream);
- }
-
- dlg_generic_outputf(print_stream, stream, format_string, origin, string, styles);
- if(lock_stream) {
- unlock_file(stream);
- }
-}
-
-void dlg_default_output(const struct dlg_origin* origin, const char* string, void* data) {
- FILE* stream = data ? (FILE*) data : stdout;
- unsigned int features = dlg_output_file_line |
- dlg_output_newline |
- dlg_output_threadsafe;
-
-#ifdef DLG_DEFAULT_OUTPUT_ALWAYS_COLOR
- dlg_win_init_ansi();
- features |= dlg_output_style;
-#else
- if(dlg_is_tty(stream) && dlg_win_init_ansi()) {
- features |= dlg_output_style;
- }
-#endif
-
- dlg_generic_output_stream(stream, features, origin, string, dlg_default_output_styles);
- fflush(stream);
-}
-
-bool dlg_win_init_ansi(void) {
-#if defined(DLG_OS_WIN) && defined(DLG_WIN_CONSOLE)
- // TODO: use init once
- static volatile LONG status = 0;
- LONG res = InterlockedCompareExchange(&status, 1, 0);
- if(res == 0) { // not initialized
- InterlockedExchange(&status, 3 + init_ansi_console());
- }
-
- while(status == 1); // currently initialized in another thread, spinlock
- return (status == 4);
-#else
- return true;
-#endif
-}
-
-// small dynamic vec/array implementation
-// Since the macros vec_init and vec_add[c]/vec_push might
-// change the pointers value it must not be referenced somewhere else.
-#define vec__raw(vec) (((unsigned int*) vec) - 2)
-
-static void* vec_do_create(unsigned int typesize, unsigned int cap, unsigned int size) {
- unsigned long a = (size > cap) ? size : cap;
- void* ptr = xalloc(2 * sizeof(unsigned int) + a * typesize);
- unsigned int* begin = (unsigned int*) ptr;
- begin[0] = size * typesize;
- begin[1] = a * typesize;
- return begin + 2;
-}
-
-// NOTE: can be more efficient if we are allowed to reorder vector
-static void vec_do_erase(void* vec, unsigned int pos, unsigned int size) {
- unsigned int* begin = vec__raw(vec);
- begin[0] -= size;
- char* buf = (char*) vec;
- memcpy(buf + pos, buf + pos + size, size);
-}
-
-static void* vec_do_add(void** vec, unsigned int size) {
- unsigned int* begin = vec__raw(*vec);
- unsigned int needed = begin[0] + size;
- if(needed >= begin[1]) {
- void* ptr = xrealloc(begin, sizeof(unsigned int) * 2 + needed * 2);
- begin = (unsigned int*) ptr;
- begin[1] = needed * 2;
- (*vec) = begin + 2;
- }
-
- void* ptr = ((char*) (*vec)) + begin[0];
- begin[0] += size;
- return ptr;
-}
-
-#define vec_create(type, size) (type*) vec_do_create(sizeof(type), size * 2, size)
-#define vec_create_reserve(type, size, capacity) (type*) vec_do_create(sizeof(type), capcity, size)
-#define vec_init(array, size) array = vec_do_create(sizeof(*array), size * 2, size)
-#define vec_init_reserve(array, size, capacity) *((void**) &array) = vec_do_create(sizeof(*array), capacity, size)
-#define vec_free(vec) (free((vec) ? vec__raw(vec) : NULL), vec = NULL)
-#define vec_erase_range(vec, pos, count) vec_do_erase(vec, pos * sizeof(*vec), count * sizeof(*vec))
-#define vec_erase(vec, pos) vec_do_erase(vec, pos * sizeof(*vec), sizeof(*vec))
-#define vec_size(vec) (vec__raw(vec)[0] / sizeof(*vec))
-#define vec_capacity(vec) (vec_raw(vec)[1] / sizeof(*vec))
-#define vec_add(vec) vec_do_add((void**) &vec, sizeof(*vec))
-#define vec_addc(vec, count) (vec_do_add((void**) &vec, sizeof(*vec) * count))
-#define vec_push(vec, value) (vec_do_add((void**) &vec, sizeof(*vec)), vec_last(vec) = (value))
-#define vec_pop(vec) (vec__raw(vec)[0] -= sizeof(*vec))
-#define vec_popc(vec, count) (vec__raw(vec)[0] -= sizeof(*vec) * count)
-#define vec_clear(vec) (vec__raw(vec)[0] = 0)
-#define vec_last(vec) (vec[vec_size(vec) - 1])
-
-static struct dlg_data* dlg_create_data(void) {
- struct dlg_data* data = (struct dlg_data*) xalloc(sizeof(struct dlg_data));
- vec_init_reserve(data->tags, 0, 20);
- vec_init_reserve(data->pairs, 0, 20);
- data->buffer_size = 100;
- data->buffer = (char*) xalloc(data->buffer_size);
- return data;
-}
-
-static void dlg_free_data(void* ddata) {
- struct dlg_data* data = (struct dlg_data*) ddata;
- if(data) {
- vec_free(data->pairs);
- vec_free(data->tags);
- free(data->buffer);
- free(data);
- }
-}
-
-void dlg_add_tag(const char* tag, const char* func) {
- struct dlg_data* data = dlg_data();
- struct dlg_tag_func_pair* pair =
- (struct dlg_tag_func_pair*) vec_add(data->pairs);
- pair->tag = tag;
- pair->func = func;
-}
-
-bool dlg_remove_tag(const char* tag, const char* func) {
- struct dlg_data* data = dlg_data();
- for(unsigned int i = 0; i < vec_size(data->pairs); ++i) {
- if(data->pairs[i].func == func && data->pairs[i].tag == tag) {
- vec_erase(data->pairs, i);
- return true;
- }
- }
-
- return false;
-}
-
-char** dlg_thread_buffer(size_t** size) {
- struct dlg_data* data = dlg_data();
- if(size) {
- *size = &data->buffer_size;
- }
- return &data->buffer;
-}
-
-void dlg_set_handler(dlg_handler handler, void* data) {
- g_handler = handler;
- g_data = data;
-}
-
-dlg_handler dlg_get_handler(void** data) {
- *data = g_data;
- return g_handler;
-}
-
-const char* dlg__printf_format(const char* str, ...) {
- va_list vlist;
- va_start(vlist, str);
-
- va_list vlistcopy;
- va_copy(vlistcopy, vlist);
- int needed = vsnprintf(NULL, 0, str, vlist);
- if(needed < 0) {
- printf("dlg__printf_format: invalid format given\n");
- va_end(vlist);
- va_end(vlistcopy);
- return NULL;
- }
-
- va_end(vlist);
-
- size_t* buf_size;
- char** buf = dlg_thread_buffer(&buf_size);
- if(*buf_size <= (unsigned int) needed) {
- *buf_size = (needed + 1) * 2;
- *buf = (char*) xrealloc(*buf, *buf_size);
- }
-
- vsnprintf(*buf, *buf_size, str, vlistcopy);
- va_end(vlistcopy);
-
- return *buf;
-}
-
-void dlg__do_log(enum dlg_level lvl, const char* const* tags, const char* file, int line,
- const char* func, const char* string, const char* expr) {
- struct dlg_data* data = dlg_data();
- unsigned int tag_count = 0;
-
- // push default tags
- while(tags[tag_count]) {
- vec_push(data->tags, tags[tag_count++]);
- }
-
- // push current global tags
- for(size_t i = 0; i < vec_size(data->pairs); ++i) {
- const struct dlg_tag_func_pair pair = data->pairs[i];
- if(pair.func == NULL || !strcmp(pair.func, func)) {
- vec_push(data->tags, pair.tag);
- }
- }
-
- // push call-specific tags, skip first terminating NULL
- ++tag_count;
- while(tags[tag_count]) {
- vec_push(data->tags, tags[tag_count++]);
- }
-
- vec_push(data->tags, NULL); // terminating NULL
- struct dlg_origin origin;
- origin.level = lvl;
- origin.file = file;
- origin.line = line;
- origin.func = func;
- origin.expr = expr;
- origin.tags = data->tags;
-
- g_handler(&origin, string, g_data);
- vec_clear(data->tags);
-}
-
-#ifdef _MSC_VER
-// shitty msvc compatbility
-// meson gives us sane paths (separated by '/') while on MSVC,
-// __FILE__ contains a '\\' separator.
-static bool path_same(char a, char b) {
- return (a == b) ||
- (a == '/' && b == '\\') ||
- (a == '\\' && b == '/');
-}
-#else
-
-static inline bool path_same(char a, char b) {
- return a == b;
-}
-
-#endif
-
-const char* dlg__strip_root_path(const char* file, const char* base) {
- if(!file) {
- return NULL;
- }
-
- const char* saved = file;
- if(*file == '.') { // relative path detected
- while(*(++file) == '.' || *file == '/' || *file == '\\');
- if(*file == '\0') { // weird case: purely relative path without file
- return saved;
- }
-
- return file;
- }
-
- // strip base from file if it is given
- if(base) {
- char fn = *file;
- char bn = *base;
- while(bn != '\0' && path_same(fn, bn)) {
- fn = *(++file);
- bn = *(++base);
- }
-
- if(fn == '\0' || bn != '\0') { // weird case: base isn't prefix of file
- return saved;
- }
- }
-
- return file;
-}
diff --git a/contrib/libs/freetype/src/dlg/dlgwrap.c b/contrib/libs/freetype/src/dlg/dlgwrap.c
deleted file mode 100644
index e6053cd5bc..0000000000
--- a/contrib/libs/freetype/src/dlg/dlgwrap.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/****************************************************************************
- *
- * dlgwrap.c
- *
- * Wrapper file for the 'dlg' library (body only)
- *
- * Copyright (C) 2020-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <ft2build.h>
-#include FT_CONFIG_OPTIONS_H
-
-
-#ifdef FT_DEBUG_LOGGING
-#define DLG_STATIC
-#include "dlg.c"
-#else
- /* ANSI C doesn't like empty source files */
- typedef int dlg_dummy_;
-#endif
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/gzip/README.freetype b/contrib/libs/freetype/src/gzip/README.freetype
deleted file mode 100644
index 29304308fd..0000000000
--- a/contrib/libs/freetype/src/gzip/README.freetype
+++ /dev/null
@@ -1,22 +0,0 @@
-Name: zlib
-Short Name: zlib
-URL: http://zlib.net/
-Version: 1.3
-License: see `zlib.h`
-
-Description:
-"A massively spiffy yet delicately unobtrusive compression library."
-
-'zlib' is a free, general-purpose, legally unencumbered lossless
-data-compression library. 'zlib' implements the "deflate" compression
-algorithm described by RFC 1951, which combines the LZ77 (Lempel-Ziv)
-algorithm with Huffman coding. zlib also implements the zlib (RFC 1950) and
-gzip (RFC 1952) wrapper formats.
-
-Local Modifications:
-The files in this directory have been prepared as follows.
-
- - Take the unmodified source code files from the zlib distribution that are
- included by `ftgzip.c`.
- - Copy `zconf.h` to `ftzconf.h` (which stays unmodified otherwise).
- - Apply the diff file(s) in the `patches` folder.
diff --git a/contrib/libs/freetype/src/gzip/ftgzip.c b/contrib/libs/freetype/src/gzip/ftgzip.c
deleted file mode 100644
index ba4ea32e9c..0000000000
--- a/contrib/libs/freetype/src/gzip/ftgzip.c
+++ /dev/null
@@ -1,805 +0,0 @@
-/****************************************************************************
- *
- * ftgzip.c
- *
- * FreeType support for .gz compressed files.
- *
- * This optional component relies on zlib. It should mainly be used to
- * parse compressed PCF fonts, as found with many X11 server
- * distributions.
- *
- * Copyright (C) 2002-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftmemory.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/internal/ftdebug.h>
-#include <freetype/ftgzip.h>
-#include FT_CONFIG_STANDARD_LIBRARY_H
-
-
-#include <freetype/ftmoderr.h>
-
-#undef FTERRORS_H_
-
-#undef FT_ERR_PREFIX
-#define FT_ERR_PREFIX Gzip_Err_
-#define FT_ERR_BASE FT_Mod_Err_Gzip
-
-#include <freetype/fterrors.h>
-
-
-#ifdef FT_CONFIG_OPTION_USE_ZLIB
-
-#ifdef FT_CONFIG_OPTION_SYSTEM_ZLIB
-
-#include <zlib.h>
-
-#else /* !FT_CONFIG_OPTION_SYSTEM_ZLIB */
-
- /* In this case, we include our own modified sources of the ZLib */
- /* within the `gzip' component. The modifications were necessary */
- /* to #include all files without conflicts, as well as preventing */
- /* the definition of `extern' functions that may cause linking */
- /* conflicts when a program is linked with both FreeType and the */
- /* original ZLib. */
-
-#ifndef USE_ZLIB_ZCALLOC
-#define MY_ZCALLOC /* prevent all zcalloc() & zfree() in zutil.c */
-#endif
-
- /* Note that our `zlib.h' includes `ftzconf.h' instead of `zconf.h'; */
- /* the main reason is that even a global `zlib.h' includes `zconf.h' */
- /* with */
- /* */
- /* #include "zconf.h" */
- /* */
- /* instead of the expected */
- /* */
- /* #include <zconf.h> */
- /* */
- /* so that configuration with `FT_CONFIG_OPTION_SYSTEM_ZLIB' might */
- /* include the wrong `zconf.h' file, leading to errors. */
-
-#define ZEXPORT
- /* prevent zlib functions from being visible outside their object files */
-#define ZEXTERN static
-
-#define HAVE_MEMCPY 1
-#define Z_SOLO 1
-#define Z_FREETYPE 1
-
-#if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */
- /* We disable the warning `conversion from XXX to YYY, */
- /* possible loss of data' in order to compile cleanly with */
- /* the maximum level of warnings: zlib is non-FreeType */
- /* code. */
-#pragma warning( push )
-#pragma warning( disable : 4244 )
-#endif /* _MSC_VER */
-
-#if defined( __GNUC__ )
-#pragma GCC diagnostic push
-#ifndef __cplusplus
-#pragma GCC diagnostic ignored "-Wstrict-prototypes"
-#endif
-#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
-#pragma GCC diagnostic ignored "-Wredundant-decls"
-#endif
-
-#error #include "zutil.c"
-#error #include "inffast.c"
-#error #include "inflate.c"
-#error #include "inftrees.c"
-#error #include "adler32.c"
-#error #include "crc32.c"
-
-#if defined( __GNUC__ )
-#pragma GCC diagnostic pop
-#endif
-
-#if defined( _MSC_VER )
-#pragma warning( pop )
-#endif
-
-#endif /* !FT_CONFIG_OPTION_SYSTEM_ZLIB */
-
-
-/***************************************************************************/
-/***************************************************************************/
-/***** *****/
-/***** Z L I B M E M O R Y M A N A G E M E N T *****/
-/***** *****/
-/***************************************************************************/
-/***************************************************************************/
-
- /* it is better to use FreeType memory routines instead of raw
- 'malloc/free' */
-
- static voidpf
- ft_gzip_alloc( voidpf opaque,
- uInt items,
- uInt size )
- {
- FT_Memory memory = (FT_Memory)opaque;
- FT_ULong sz = (FT_ULong)size * items;
- FT_Error error;
- FT_Pointer p = NULL;
-
-
- /* allocate and zero out */
- FT_MEM_ALLOC( p, sz );
- return p;
- }
-
-
- static void
- ft_gzip_free( voidpf opaque,
- voidpf address )
- {
- FT_Memory memory = (FT_Memory)opaque;
-
-
- FT_MEM_FREE( address );
- }
-
-/***************************************************************************/
-/***************************************************************************/
-/***** *****/
-/***** Z L I B F I L E D E S C R I P T O R *****/
-/***** *****/
-/***************************************************************************/
-/***************************************************************************/
-
-#define FT_GZIP_BUFFER_SIZE 4096
-
- typedef struct FT_GZipFileRec_
- {
- FT_Stream source; /* parent/source stream */
- FT_Stream stream; /* embedding stream */
- FT_Memory memory; /* memory allocator */
- z_stream zstream; /* zlib input stream */
-
- FT_ULong start; /* starting position, after .gz header */
- FT_Byte input[FT_GZIP_BUFFER_SIZE]; /* input read buffer */
-
- FT_Byte buffer[FT_GZIP_BUFFER_SIZE]; /* output buffer */
- FT_ULong pos; /* position in output */
- FT_Byte* cursor;
- FT_Byte* limit;
-
- } FT_GZipFileRec, *FT_GZipFile;
-
-
- /* gzip flag byte */
-#define FT_GZIP_ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */
-#define FT_GZIP_HEAD_CRC 0x02 /* bit 1 set: header CRC present */
-#define FT_GZIP_EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
-#define FT_GZIP_ORIG_NAME 0x08 /* bit 3 set: original file name present */
-#define FT_GZIP_COMMENT 0x10 /* bit 4 set: file comment present */
-#define FT_GZIP_RESERVED 0xE0 /* bits 5..7: reserved */
-
-
- /* check and skip .gz header - we don't support `transparent' compression */
- static FT_Error
- ft_gzip_check_header( FT_Stream stream )
- {
- FT_Error error;
- FT_Byte head[4];
-
-
- if ( FT_STREAM_SEEK( 0 ) ||
- FT_STREAM_READ( head, 4 ) )
- goto Exit;
-
- /* head[0] && head[1] are the magic numbers; */
- /* head[2] is the method, and head[3] the flags */
- if ( head[0] != 0x1F ||
- head[1] != 0x8B ||
- head[2] != Z_DEFLATED ||
- (head[3] & FT_GZIP_RESERVED) )
- {
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- /* skip time, xflags and os code */
- (void)FT_STREAM_SKIP( 6 );
-
- /* skip the extra field */
- if ( head[3] & FT_GZIP_EXTRA_FIELD )
- {
- FT_UInt len;
-
-
- if ( FT_READ_USHORT_LE( len ) ||
- FT_STREAM_SKIP( len ) )
- goto Exit;
- }
-
- /* skip original file name */
- if ( head[3] & FT_GZIP_ORIG_NAME )
- for (;;)
- {
- FT_UInt c;
-
-
- if ( FT_READ_BYTE( c ) )
- goto Exit;
-
- if ( c == 0 )
- break;
- }
-
- /* skip .gz comment */
- if ( head[3] & FT_GZIP_COMMENT )
- for (;;)
- {
- FT_UInt c;
-
-
- if ( FT_READ_BYTE( c ) )
- goto Exit;
-
- if ( c == 0 )
- break;
- }
-
- /* skip CRC */
- if ( head[3] & FT_GZIP_HEAD_CRC )
- if ( FT_STREAM_SKIP( 2 ) )
- goto Exit;
-
- Exit:
- return error;
- }
-
-
- static FT_Error
- ft_gzip_file_init( FT_GZipFile zip,
- FT_Stream stream,
- FT_Stream source )
- {
- z_stream* zstream = &zip->zstream;
- FT_Error error = FT_Err_Ok;
-
-
- zip->stream = stream;
- zip->source = source;
- zip->memory = stream->memory;
-
- zip->limit = zip->buffer + FT_GZIP_BUFFER_SIZE;
- zip->cursor = zip->limit;
- zip->pos = 0;
-
- /* check and skip .gz header */
- {
- stream = source;
-
- error = ft_gzip_check_header( stream );
- if ( error )
- goto Exit;
-
- zip->start = FT_STREAM_POS();
- }
-
- /* initialize zlib -- there is no zlib header in the compressed stream */
- zstream->zalloc = ft_gzip_alloc;
- zstream->zfree = ft_gzip_free;
- zstream->opaque = stream->memory;
-
- zstream->avail_in = 0;
- zstream->next_in = zip->buffer;
-
- if ( inflateInit2( zstream, -MAX_WBITS ) != Z_OK ||
- !zstream->next_in )
- error = FT_THROW( Invalid_File_Format );
-
- Exit:
- return error;
- }
-
-
- static void
- ft_gzip_file_done( FT_GZipFile zip )
- {
- z_stream* zstream = &zip->zstream;
-
-
- inflateEnd( zstream );
-
- /* clear the rest */
- zstream->zalloc = NULL;
- zstream->zfree = NULL;
- zstream->opaque = NULL;
- zstream->next_in = NULL;
- zstream->next_out = NULL;
- zstream->avail_in = 0;
- zstream->avail_out = 0;
-
- zip->memory = NULL;
- zip->source = NULL;
- zip->stream = NULL;
- }
-
-
- static FT_Error
- ft_gzip_file_reset( FT_GZipFile zip )
- {
- FT_Stream stream = zip->source;
- FT_Error error;
-
-
- if ( !FT_STREAM_SEEK( zip->start ) )
- {
- z_stream* zstream = &zip->zstream;
-
-
- inflateReset( zstream );
-
- zstream->avail_in = 0;
- zstream->next_in = zip->input;
- zstream->avail_out = 0;
- zstream->next_out = zip->buffer;
-
- zip->limit = zip->buffer + FT_GZIP_BUFFER_SIZE;
- zip->cursor = zip->limit;
- zip->pos = 0;
- }
-
- return error;
- }
-
-
- static FT_Error
- ft_gzip_file_fill_input( FT_GZipFile zip )
- {
- z_stream* zstream = &zip->zstream;
- FT_Stream stream = zip->source;
- FT_ULong size;
-
-
- if ( stream->read )
- {
- size = stream->read( stream, stream->pos, zip->input,
- FT_GZIP_BUFFER_SIZE );
- if ( size == 0 )
- {
- zip->limit = zip->cursor;
- return FT_THROW( Invalid_Stream_Operation );
- }
- }
- else
- {
- size = stream->size - stream->pos;
- if ( size > FT_GZIP_BUFFER_SIZE )
- size = FT_GZIP_BUFFER_SIZE;
-
- if ( size == 0 )
- {
- zip->limit = zip->cursor;
- return FT_THROW( Invalid_Stream_Operation );
- }
-
- FT_MEM_COPY( zip->input, stream->base + stream->pos, size );
- }
- stream->pos += size;
-
- zstream->next_in = zip->input;
- zstream->avail_in = size;
-
- return FT_Err_Ok;
- }
-
-
- static FT_Error
- ft_gzip_file_fill_output( FT_GZipFile zip )
- {
- z_stream* zstream = &zip->zstream;
- FT_Error error = FT_Err_Ok;
-
-
- zip->cursor = zip->buffer;
- zstream->next_out = zip->cursor;
- zstream->avail_out = FT_GZIP_BUFFER_SIZE;
-
- while ( zstream->avail_out > 0 )
- {
- int err;
-
-
- if ( zstream->avail_in == 0 )
- {
- error = ft_gzip_file_fill_input( zip );
- if ( error )
- break;
- }
-
- err = inflate( zstream, Z_NO_FLUSH );
-
- if ( err == Z_STREAM_END )
- {
- zip->limit = zstream->next_out;
- if ( zip->limit == zip->cursor )
- error = FT_THROW( Invalid_Stream_Operation );
- break;
- }
- else if ( err != Z_OK )
- {
- zip->limit = zip->cursor;
- error = FT_THROW( Invalid_Stream_Operation );
- break;
- }
- }
-
- return error;
- }
-
-
- /* fill output buffer; `count' must be <= FT_GZIP_BUFFER_SIZE */
- static FT_Error
- ft_gzip_file_skip_output( FT_GZipFile zip,
- FT_ULong count )
- {
- FT_Error error = FT_Err_Ok;
-
-
- for (;;)
- {
- FT_ULong delta = (FT_ULong)( zip->limit - zip->cursor );
-
-
- if ( delta >= count )
- delta = count;
-
- zip->cursor += delta;
- zip->pos += delta;
-
- count -= delta;
- if ( count == 0 )
- break;
-
- error = ft_gzip_file_fill_output( zip );
- if ( error )
- break;
- }
-
- return error;
- }
-
-
- static FT_ULong
- ft_gzip_file_io( FT_GZipFile zip,
- FT_ULong pos,
- FT_Byte* buffer,
- FT_ULong count )
- {
- FT_ULong result = 0;
- FT_Error error;
-
-
- /* Reset inflate stream if we're seeking backwards. */
- /* Yes, that is not too efficient, but it saves memory :-) */
- if ( pos < zip->pos )
- {
- error = ft_gzip_file_reset( zip );
- if ( error )
- goto Exit;
- }
-
- /* skip unwanted bytes */
- if ( pos > zip->pos )
- {
- error = ft_gzip_file_skip_output( zip, (FT_ULong)( pos - zip->pos ) );
- if ( error )
- goto Exit;
- }
-
- if ( count == 0 )
- goto Exit;
-
- /* now read the data */
- for (;;)
- {
- FT_ULong delta;
-
-
- delta = (FT_ULong)( zip->limit - zip->cursor );
- if ( delta >= count )
- delta = count;
-
- FT_MEM_COPY( buffer, zip->cursor, delta );
- buffer += delta;
- result += delta;
- zip->cursor += delta;
- zip->pos += delta;
-
- count -= delta;
- if ( count == 0 )
- break;
-
- error = ft_gzip_file_fill_output( zip );
- if ( error )
- break;
- }
-
- Exit:
- return result;
- }
-
-
-/***************************************************************************/
-/***************************************************************************/
-/***** *****/
-/***** G Z E M B E D D I N G S T R E A M *****/
-/***** *****/
-/***************************************************************************/
-/***************************************************************************/
-
- static void
- ft_gzip_stream_close( FT_Stream stream )
- {
- FT_GZipFile zip = (FT_GZipFile)stream->descriptor.pointer;
- FT_Memory memory = stream->memory;
-
-
- if ( zip )
- {
- /* finalize gzip file descriptor */
- ft_gzip_file_done( zip );
-
- FT_FREE( zip );
-
- stream->descriptor.pointer = NULL;
- }
-
- if ( !stream->read )
- FT_FREE( stream->base );
- }
-
-
- static unsigned long
- ft_gzip_stream_io( FT_Stream stream,
- unsigned long offset,
- unsigned char* buffer,
- unsigned long count )
- {
- FT_GZipFile zip = (FT_GZipFile)stream->descriptor.pointer;
-
-
- return ft_gzip_file_io( zip, offset, buffer, count );
- }
-
-
- static FT_ULong
- ft_gzip_get_uncompressed_size( FT_Stream stream )
- {
- FT_Error error;
- FT_ULong old_pos;
- FT_ULong result = 0;
-
-
- old_pos = stream->pos;
- if ( !FT_Stream_Seek( stream, stream->size - 4 ) )
- {
- result = FT_Stream_ReadULongLE( stream, &error );
- if ( error )
- result = 0;
-
- (void)FT_Stream_Seek( stream, old_pos );
- }
-
- return result;
- }
-
-
- /* documentation is in ftgzip.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Stream_OpenGzip( FT_Stream stream,
- FT_Stream source )
- {
- FT_Error error;
- FT_Memory memory;
- FT_GZipFile zip = NULL;
-
-
- if ( !stream || !source )
- {
- error = FT_THROW( Invalid_Stream_Handle );
- goto Exit;
- }
-
- memory = source->memory;
-
- /*
- * check the header right now; this prevents allocating un-necessary
- * objects when we don't need them
- */
- error = ft_gzip_check_header( source );
- if ( error )
- goto Exit;
-
- FT_ZERO( stream );
- stream->memory = memory;
-
- if ( !FT_QNEW( zip ) )
- {
- error = ft_gzip_file_init( zip, stream, source );
- if ( error )
- {
- FT_FREE( zip );
- goto Exit;
- }
-
- stream->descriptor.pointer = zip;
- }
-
- /*
- * We use the following trick to try to dramatically improve the
- * performance while dealing with small files. If the original stream
- * size is less than a certain threshold, we try to load the whole font
- * file into memory. This saves us from using the 32KB buffer needed
- * to inflate the file, plus the two 4KB intermediate input/output
- * buffers used in the `FT_GZipFile' structure.
- */
- {
- FT_ULong zip_size = ft_gzip_get_uncompressed_size( source );
-
-
- if ( zip_size != 0 && zip_size < 40 * 1024 )
- {
- FT_Byte* zip_buff = NULL;
-
-
- if ( !FT_QALLOC( zip_buff, zip_size ) )
- {
- FT_ULong count;
-
-
- count = ft_gzip_file_io( zip, 0, zip_buff, zip_size );
- if ( count == zip_size )
- {
- ft_gzip_file_done( zip );
- FT_FREE( zip );
-
- stream->descriptor.pointer = NULL;
-
- stream->size = zip_size;
- stream->pos = 0;
- stream->base = zip_buff;
- stream->read = NULL;
- stream->close = ft_gzip_stream_close;
-
- goto Exit;
- }
-
- ft_gzip_file_io( zip, 0, NULL, 0 );
- FT_FREE( zip_buff );
- }
- error = FT_Err_Ok;
- }
-
- if ( zip_size )
- stream->size = zip_size;
- else
- stream->size = 0x7FFFFFFFL; /* don't know the real size! */
- }
-
- stream->pos = 0;
- stream->base = NULL;
- stream->read = ft_gzip_stream_io;
- stream->close = ft_gzip_stream_close;
-
- Exit:
- return error;
- }
-
-
- /* documentation is in ftgzip.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Gzip_Uncompress( FT_Memory memory,
- FT_Byte* output,
- FT_ULong* output_len,
- const FT_Byte* input,
- FT_ULong input_len )
- {
- z_stream stream;
- int err;
-
-
- /* check for `input' delayed to `inflate' */
-
- if ( !memory || !output_len || !output )
- return FT_THROW( Invalid_Argument );
-
- /* this function is modeled after zlib's `uncompress' function */
-
- stream.next_in = (Bytef*)input;
- stream.avail_in = (uInt)input_len;
-
- stream.next_out = output;
- stream.avail_out = (uInt)*output_len;
-
- stream.zalloc = ft_gzip_alloc;
- stream.zfree = ft_gzip_free;
- stream.opaque = memory;
-
- err = inflateInit2( &stream, MAX_WBITS|32 );
-
- if ( err != Z_OK )
- return FT_THROW( Invalid_Argument );
-
- err = inflate( &stream, Z_FINISH );
- if ( err != Z_STREAM_END )
- {
- inflateEnd( &stream );
- if ( err == Z_OK )
- err = Z_BUF_ERROR;
- }
- else
- {
- *output_len = stream.total_out;
-
- err = inflateEnd( &stream );
- }
-
- if ( err == Z_MEM_ERROR )
- return FT_THROW( Out_Of_Memory );
-
- if ( err == Z_BUF_ERROR )
- return FT_THROW( Array_Too_Large );
-
- if ( err == Z_DATA_ERROR )
- return FT_THROW( Invalid_Table );
-
- if ( err == Z_NEED_DICT )
- return FT_THROW( Invalid_Table );
-
- return FT_Err_Ok;
- }
-
-
-#else /* !FT_CONFIG_OPTION_USE_ZLIB */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Stream_OpenGzip( FT_Stream stream,
- FT_Stream source )
- {
- FT_UNUSED( stream );
- FT_UNUSED( source );
-
- return FT_THROW( Unimplemented_Feature );
- }
-
-
- FT_EXPORT_DEF( FT_Error )
- FT_Gzip_Uncompress( FT_Memory memory,
- FT_Byte* output,
- FT_ULong* output_len,
- const FT_Byte* input,
- FT_ULong input_len )
- {
- FT_UNUSED( memory );
- FT_UNUSED( output );
- FT_UNUSED( output_len );
- FT_UNUSED( input );
- FT_UNUSED( input_len );
-
- return FT_THROW( Unimplemented_Feature );
- }
-
-#endif /* !FT_CONFIG_OPTION_USE_ZLIB */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/lzw/ftlzw.c b/contrib/libs/freetype/src/lzw/ftlzw.c
deleted file mode 100644
index e1acf22eee..0000000000
--- a/contrib/libs/freetype/src/lzw/ftlzw.c
+++ /dev/null
@@ -1,415 +0,0 @@
-/****************************************************************************
- *
- * ftlzw.c
- *
- * FreeType support for .Z compressed files.
- *
- * This optional component relies on NetBSD's zopen(). It should mainly
- * be used to parse compressed PCF fonts, as found with many X11 server
- * distributions.
- *
- * Copyright (C) 2004-2024 by
- * Albert Chin-A-Young.
- *
- * based on code in `src/gzip/ftgzip.c'
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-#include <freetype/internal/ftmemory.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/internal/ftdebug.h>
-#include <freetype/ftlzw.h>
-#include FT_CONFIG_STANDARD_LIBRARY_H
-
-
-#include <freetype/ftmoderr.h>
-
-#undef FTERRORS_H_
-
-#undef FT_ERR_PREFIX
-#define FT_ERR_PREFIX LZW_Err_
-#define FT_ERR_BASE FT_Mod_Err_LZW
-
-#include <freetype/fterrors.h>
-
-
-#ifdef FT_CONFIG_OPTION_USE_LZW
-
-#include "ftzopen.h"
-
-
-/***************************************************************************/
-/***************************************************************************/
-/***** *****/
-/***** M E M O R Y M A N A G E M E N T *****/
-/***** *****/
-/***************************************************************************/
-/***************************************************************************/
-
-/***************************************************************************/
-/***************************************************************************/
-/***** *****/
-/***** F I L E D E S C R I P T O R *****/
-/***** *****/
-/***************************************************************************/
-/***************************************************************************/
-
-#define FT_LZW_BUFFER_SIZE 4096
-
- typedef struct FT_LZWFileRec_
- {
- FT_Stream source; /* parent/source stream */
- FT_Stream stream; /* embedding stream */
- FT_Memory memory; /* memory allocator */
- FT_LzwStateRec lzw; /* lzw decompressor state */
-
- FT_Byte buffer[FT_LZW_BUFFER_SIZE]; /* output buffer */
- FT_ULong pos; /* position in output */
- FT_Byte* cursor;
- FT_Byte* limit;
-
- } FT_LZWFileRec, *FT_LZWFile;
-
-
- /* check and skip .Z header */
- static FT_Error
- ft_lzw_check_header( FT_Stream stream )
- {
- FT_Error error;
- FT_Byte head[2];
-
-
- if ( FT_STREAM_SEEK( 0 ) ||
- FT_STREAM_READ( head, 2 ) )
- goto Exit;
-
- /* head[0] && head[1] are the magic numbers */
- if ( head[0] != 0x1F ||
- head[1] != 0x9D )
- error = FT_THROW( Invalid_File_Format );
-
- Exit:
- return error;
- }
-
-
- static FT_Error
- ft_lzw_file_init( FT_LZWFile zip,
- FT_Stream stream,
- FT_Stream source )
- {
- FT_LzwState lzw = &zip->lzw;
- FT_Error error;
-
-
- zip->stream = stream;
- zip->source = source;
- zip->memory = stream->memory;
-
- zip->limit = zip->buffer + FT_LZW_BUFFER_SIZE;
- zip->cursor = zip->limit;
- zip->pos = 0;
-
- /* check and skip .Z header */
- error = ft_lzw_check_header( source );
- if ( error )
- goto Exit;
-
- /* initialize internal lzw variable */
- ft_lzwstate_init( lzw, source );
-
- Exit:
- return error;
- }
-
-
- static void
- ft_lzw_file_done( FT_LZWFile zip )
- {
- /* clear the rest */
- ft_lzwstate_done( &zip->lzw );
-
- zip->memory = NULL;
- zip->source = NULL;
- zip->stream = NULL;
- }
-
-
- static FT_Error
- ft_lzw_file_reset( FT_LZWFile zip )
- {
- FT_Stream stream = zip->source;
- FT_Error error;
-
-
- if ( !FT_STREAM_SEEK( 0 ) )
- {
- ft_lzwstate_reset( &zip->lzw );
-
- zip->limit = zip->buffer + FT_LZW_BUFFER_SIZE;
- zip->cursor = zip->limit;
- zip->pos = 0;
- }
-
- return error;
- }
-
-
- static FT_Error
- ft_lzw_file_fill_output( FT_LZWFile zip )
- {
- FT_LzwState lzw = &zip->lzw;
- FT_ULong count;
- FT_Error error = FT_Err_Ok;
-
-
- zip->cursor = zip->buffer;
-
- count = ft_lzwstate_io( lzw, zip->buffer, FT_LZW_BUFFER_SIZE );
-
- zip->limit = zip->cursor + count;
-
- if ( count == 0 )
- error = FT_THROW( Invalid_Stream_Operation );
-
- return error;
- }
-
-
- /* fill output buffer; `count' must be <= FT_LZW_BUFFER_SIZE */
- static FT_Error
- ft_lzw_file_skip_output( FT_LZWFile zip,
- FT_ULong count )
- {
- FT_Error error = FT_Err_Ok;
-
-
- /* first, we skip what we can from the output buffer */
- {
- FT_ULong delta = (FT_ULong)( zip->limit - zip->cursor );
-
-
- if ( delta >= count )
- delta = count;
-
- zip->cursor += delta;
- zip->pos += delta;
-
- count -= delta;
- }
-
- /* next, we skip as many bytes remaining as possible */
- while ( count > 0 )
- {
- FT_ULong delta = FT_LZW_BUFFER_SIZE;
- FT_ULong numread;
-
-
- if ( delta > count )
- delta = count;
-
- numread = ft_lzwstate_io( &zip->lzw, NULL, delta );
- if ( numread < delta )
- {
- /* not enough bytes */
- error = FT_THROW( Invalid_Stream_Operation );
- break;
- }
-
- zip->pos += delta;
- count -= delta;
- }
-
- return error;
- }
-
-
- static FT_ULong
- ft_lzw_file_io( FT_LZWFile zip,
- FT_ULong pos,
- FT_Byte* buffer,
- FT_ULong count )
- {
- FT_ULong result = 0;
- FT_Error error;
-
-
- /* seeking backwards. */
- if ( pos < zip->pos )
- {
- /* If the new position is within the output buffer, simply */
- /* decrement pointers, otherwise we reset the stream completely! */
- if ( ( zip->pos - pos ) <= (FT_ULong)( zip->cursor - zip->buffer ) )
- {
- zip->cursor -= zip->pos - pos;
- zip->pos = pos;
- }
- else
- {
- error = ft_lzw_file_reset( zip );
- if ( error )
- goto Exit;
- }
- }
-
- /* skip unwanted bytes */
- if ( pos > zip->pos )
- {
- error = ft_lzw_file_skip_output( zip, (FT_ULong)( pos - zip->pos ) );
- if ( error )
- goto Exit;
- }
-
- if ( count == 0 )
- goto Exit;
-
- /* now read the data */
- for (;;)
- {
- FT_ULong delta;
-
-
- delta = (FT_ULong)( zip->limit - zip->cursor );
- if ( delta >= count )
- delta = count;
-
- FT_MEM_COPY( buffer + result, zip->cursor, delta );
- result += delta;
- zip->cursor += delta;
- zip->pos += delta;
-
- count -= delta;
- if ( count == 0 )
- break;
-
- error = ft_lzw_file_fill_output( zip );
- if ( error )
- break;
- }
-
- Exit:
- return result;
- }
-
-
-/***************************************************************************/
-/***************************************************************************/
-/***** *****/
-/***** L Z W E M B E D D I N G S T R E A M *****/
-/***** *****/
-/***************************************************************************/
-/***************************************************************************/
-
- static void
- ft_lzw_stream_close( FT_Stream stream )
- {
- FT_LZWFile zip = (FT_LZWFile)stream->descriptor.pointer;
- FT_Memory memory = stream->memory;
-
-
- if ( zip )
- {
- /* finalize lzw file descriptor */
- ft_lzw_file_done( zip );
-
- FT_FREE( zip );
-
- stream->descriptor.pointer = NULL;
- }
- }
-
-
- static unsigned long
- ft_lzw_stream_io( FT_Stream stream,
- unsigned long offset,
- unsigned char* buffer,
- unsigned long count )
- {
- FT_LZWFile zip = (FT_LZWFile)stream->descriptor.pointer;
-
-
- return ft_lzw_file_io( zip, offset, buffer, count );
- }
-
-
- FT_EXPORT_DEF( FT_Error )
- FT_Stream_OpenLZW( FT_Stream stream,
- FT_Stream source )
- {
- FT_Error error;
- FT_Memory memory;
- FT_LZWFile zip = NULL;
-
-
- if ( !stream || !source )
- {
- error = FT_THROW( Invalid_Stream_Handle );
- goto Exit;
- }
-
- memory = source->memory;
-
- /*
- * Check the header right now; this prevents allocation of a huge
- * LZWFile object (400 KByte of heap memory) if not necessary.
- *
- * Did I mention that you should never use .Z compressed font
- * files?
- */
- error = ft_lzw_check_header( source );
- if ( error )
- goto Exit;
-
- FT_ZERO( stream );
- stream->memory = memory;
-
- if ( !FT_QNEW( zip ) )
- {
- error = ft_lzw_file_init( zip, stream, source );
- if ( error )
- {
- FT_FREE( zip );
- goto Exit;
- }
-
- stream->descriptor.pointer = zip;
- }
-
- stream->size = 0x7FFFFFFFL; /* don't know the real size! */
- stream->pos = 0;
- stream->base = NULL;
- stream->read = ft_lzw_stream_io;
- stream->close = ft_lzw_stream_close;
-
- Exit:
- return error;
- }
-
-
-#include "ftzopen.c"
-
-
-#else /* !FT_CONFIG_OPTION_USE_LZW */
-
-
- FT_EXPORT_DEF( FT_Error )
- FT_Stream_OpenLZW( FT_Stream stream,
- FT_Stream source )
- {
- FT_UNUSED( stream );
- FT_UNUSED( source );
-
- return FT_THROW( Unimplemented_Feature );
- }
-
-
-#endif /* !FT_CONFIG_OPTION_USE_LZW */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/lzw/ftzopen.c b/contrib/libs/freetype/src/lzw/ftzopen.c
deleted file mode 100644
index e42332466f..0000000000
--- a/contrib/libs/freetype/src/lzw/ftzopen.c
+++ /dev/null
@@ -1,429 +0,0 @@
-/****************************************************************************
- *
- * ftzopen.c
- *
- * FreeType support for .Z compressed files.
- *
- * This optional component relies on NetBSD's zopen(). It should mainly
- * be used to parse compressed PCF fonts, as found with many X11 server
- * distributions.
- *
- * Copyright (C) 2005-2024 by
- * David Turner.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-#include "ftzopen.h"
-#include <freetype/internal/ftmemory.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/internal/ftdebug.h>
-
-
- static int
- ft_lzwstate_refill( FT_LzwState state )
- {
- FT_ULong count;
-
-
- if ( state->in_eof )
- return -1;
-
- count = FT_Stream_TryRead( state->source,
- state->buf_tab,
- state->num_bits ); /* WHY? */
-
- state->buf_size = (FT_UInt)count;
- state->buf_total += count;
- state->in_eof = FT_BOOL( count < state->num_bits );
- state->buf_offset = 0;
-
- state->buf_size <<= 3;
- if ( state->buf_size > state->num_bits )
- state->buf_size -= state->num_bits - 1;
- else
- return -1; /* not enough data */
-
- if ( count == 0 ) /* end of file */
- return -1;
-
- return 0;
- }
-
-
- static FT_Int32
- ft_lzwstate_get_code( FT_LzwState state )
- {
- FT_UInt num_bits = state->num_bits;
- FT_UInt offset = state->buf_offset;
- FT_Byte* p;
- FT_Int result;
-
-
- if ( state->buf_clear ||
- offset >= state->buf_size ||
- state->free_ent >= state->free_bits )
- {
- if ( state->free_ent >= state->free_bits )
- {
- state->num_bits = ++num_bits;
- if ( num_bits > LZW_MAX_BITS )
- return -1;
-
- state->free_bits = state->num_bits < state->max_bits
- ? (FT_UInt)( ( 1UL << num_bits ) - 256 )
- : state->max_free + 1;
- }
-
- if ( state->buf_clear )
- {
- state->num_bits = num_bits = LZW_INIT_BITS;
- state->free_bits = (FT_UInt)( ( 1UL << num_bits ) - 256 );
- state->buf_clear = 0;
- }
-
- if ( ft_lzwstate_refill( state ) < 0 )
- return -1;
-
- offset = 0;
- }
-
- state->buf_offset = offset + num_bits;
-
- p = &state->buf_tab[offset >> 3];
- offset &= 7;
- result = *p++ >> offset;
- offset = 8 - offset;
- num_bits -= offset;
-
- if ( num_bits >= 8 )
- {
- result |= *p++ << offset;
- offset += 8;
- num_bits -= 8;
- }
- if ( num_bits > 0 )
- result |= ( *p & LZW_MASK( num_bits ) ) << offset;
-
- return result;
- }
-
-
- /* grow the character stack */
- static int
- ft_lzwstate_stack_grow( FT_LzwState state )
- {
- if ( state->stack_top >= state->stack_size )
- {
- FT_Memory memory = state->memory;
- FT_Error error;
- FT_Offset old_size = state->stack_size;
- FT_Offset new_size = old_size;
-
- new_size = new_size + ( new_size >> 1 ) + 4;
-
- /* if relocating to heap */
- if ( state->stack == state->stack_0 )
- {
- state->stack = NULL;
- old_size = 0;
- }
-
- /* requirement of the character stack larger than 1<<LZW_MAX_BITS */
- /* implies bug in the decompression code */
- if ( new_size > ( 1 << LZW_MAX_BITS ) )
- {
- new_size = 1 << LZW_MAX_BITS;
- if ( new_size == old_size )
- return -1;
- }
-
- if ( FT_QREALLOC( state->stack, old_size, new_size ) )
- return -1;
-
- /* if relocating to heap */
- if ( old_size == 0 )
- FT_MEM_COPY( state->stack, state->stack_0, FT_LZW_DEFAULT_STACK_SIZE );
-
- state->stack_size = new_size;
- }
- return 0;
- }
-
-
- /* grow the prefix/suffix arrays */
- static int
- ft_lzwstate_prefix_grow( FT_LzwState state )
- {
- FT_UInt old_size = state->prefix_size;
- FT_UInt new_size = old_size;
- FT_Memory memory = state->memory;
- FT_Error error;
-
-
- if ( new_size == 0 ) /* first allocation -> 9 bits */
- new_size = 512;
- else
- new_size += new_size >> 2; /* don't grow too fast */
-
- /*
- * Note that the `suffix' array is located in the same memory block
- * pointed to by `prefix'.
- *
- * I know that sizeof(FT_Byte) == 1 by definition, but it is clearer
- * to write it literally.
- *
- */
- if ( FT_REALLOC_MULT( state->prefix, old_size, new_size,
- sizeof ( FT_UShort ) + sizeof ( FT_Byte ) ) )
- return -1;
-
- /* now adjust `suffix' and move the data accordingly */
- state->suffix = (FT_Byte*)( state->prefix + new_size );
-
- FT_MEM_MOVE( state->suffix,
- state->prefix + old_size,
- old_size * sizeof ( FT_Byte ) );
-
- state->prefix_size = new_size;
- return 0;
- }
-
-
- FT_LOCAL_DEF( void )
- ft_lzwstate_reset( FT_LzwState state )
- {
- state->in_eof = 0;
- state->buf_offset = 0;
- state->buf_size = 0;
- state->buf_clear = 0;
- state->buf_total = 0;
- state->stack_top = 0;
- state->num_bits = LZW_INIT_BITS;
- state->phase = FT_LZW_PHASE_START;
- }
-
-
- FT_LOCAL_DEF( void )
- ft_lzwstate_init( FT_LzwState state,
- FT_Stream source )
- {
- FT_ZERO( state );
-
- state->source = source;
- state->memory = source->memory;
-
- state->prefix = NULL;
- state->suffix = NULL;
- state->prefix_size = 0;
-
- state->stack = state->stack_0;
- state->stack_size = sizeof ( state->stack_0 );
-
- ft_lzwstate_reset( state );
- }
-
-
- FT_LOCAL_DEF( void )
- ft_lzwstate_done( FT_LzwState state )
- {
- FT_Memory memory = state->memory;
-
-
- ft_lzwstate_reset( state );
-
- if ( state->stack != state->stack_0 )
- FT_FREE( state->stack );
-
- FT_FREE( state->prefix );
- state->suffix = NULL;
-
- FT_ZERO( state );
- }
-
-
-#define FTLZW_STACK_PUSH( c ) \
- FT_BEGIN_STMNT \
- if ( state->stack_top >= state->stack_size && \
- ft_lzwstate_stack_grow( state ) < 0 ) \
- goto Eof; \
- \
- state->stack[state->stack_top++] = (FT_Byte)(c); \
- FT_END_STMNT
-
-
- FT_LOCAL_DEF( FT_ULong )
- ft_lzwstate_io( FT_LzwState state,
- FT_Byte* buffer,
- FT_ULong out_size )
- {
- FT_ULong result = 0;
-
- FT_UInt old_char = state->old_char;
- FT_UInt old_code = state->old_code;
- FT_UInt in_code = state->in_code;
-
-
- if ( out_size == 0 )
- goto Exit;
-
- switch ( state->phase )
- {
- case FT_LZW_PHASE_START:
- {
- FT_Byte max_bits;
- FT_Int32 c;
-
-
- /* skip magic bytes, and read max_bits + block_flag */
- if ( FT_Stream_Seek( state->source, 2 ) != 0 ||
- FT_Stream_TryRead( state->source, &max_bits, 1 ) != 1 )
- goto Eof;
-
- state->max_bits = max_bits & LZW_BIT_MASK;
- state->block_mode = max_bits & LZW_BLOCK_MASK;
- state->max_free = (FT_UInt)( ( 1UL << state->max_bits ) - 256 );
-
- if ( state->max_bits > LZW_MAX_BITS )
- goto Eof;
-
- state->num_bits = LZW_INIT_BITS;
- state->free_ent = ( state->block_mode ? LZW_FIRST
- : LZW_CLEAR ) - 256;
- in_code = 0;
-
- state->free_bits = state->num_bits < state->max_bits
- ? (FT_UInt)( ( 1UL << state->num_bits ) - 256 )
- : state->max_free + 1;
-
- c = ft_lzwstate_get_code( state );
- if ( c < 0 || c > 255 )
- goto Eof;
-
- old_code = old_char = (FT_UInt)c;
-
- if ( buffer )
- buffer[result] = (FT_Byte)old_char;
-
- if ( ++result >= out_size )
- goto Exit;
-
- state->phase = FT_LZW_PHASE_CODE;
- }
- FALL_THROUGH;
-
- case FT_LZW_PHASE_CODE:
- {
- FT_Int32 c;
- FT_UInt code;
-
-
- NextCode:
- c = ft_lzwstate_get_code( state );
- if ( c < 0 )
- goto Eof;
-
- code = (FT_UInt)c;
-
- if ( code == LZW_CLEAR && state->block_mode )
- {
- /* why not LZW_FIRST-256 ? */
- state->free_ent = ( LZW_FIRST - 1 ) - 256;
- state->buf_clear = 1;
-
- /* not quite right, but at least more predictable */
- old_code = 0;
- old_char = 0;
-
- goto NextCode;
- }
-
- in_code = code; /* save code for later */
-
- if ( code >= 256U )
- {
- /* special case for KwKwKwK */
- if ( code - 256U >= state->free_ent )
- {
- /* corrupted LZW stream */
- if ( code - 256U > state->free_ent )
- goto Eof;
-
- FTLZW_STACK_PUSH( old_char );
- code = old_code;
- }
-
- while ( code >= 256U )
- {
- if ( !state->prefix )
- goto Eof;
-
- FTLZW_STACK_PUSH( state->suffix[code - 256] );
- code = state->prefix[code - 256];
- }
- }
-
- old_char = code;
- FTLZW_STACK_PUSH( old_char );
-
- state->phase = FT_LZW_PHASE_STACK;
- }
- FALL_THROUGH;
-
- case FT_LZW_PHASE_STACK:
- {
- while ( state->stack_top > 0 )
- {
- state->stack_top--;
-
- if ( buffer )
- buffer[result] = state->stack[state->stack_top];
-
- if ( ++result == out_size )
- goto Exit;
- }
-
- /* now create new entry */
- if ( state->free_ent < state->max_free )
- {
- if ( state->free_ent >= state->prefix_size &&
- ft_lzwstate_prefix_grow( state ) < 0 )
- goto Eof;
-
- FT_ASSERT( state->free_ent < state->prefix_size );
-
- state->prefix[state->free_ent] = (FT_UShort)old_code;
- state->suffix[state->free_ent] = (FT_Byte) old_char;
-
- state->free_ent += 1;
- }
-
- old_code = in_code;
-
- state->phase = FT_LZW_PHASE_CODE;
- goto NextCode;
- }
-
- default: /* state == EOF */
- ;
- }
-
- Exit:
- state->old_code = old_code;
- state->old_char = old_char;
- state->in_code = in_code;
-
- return result;
-
- Eof:
- state->phase = FT_LZW_PHASE_EOF;
- goto Exit;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/lzw/ftzopen.h b/contrib/libs/freetype/src/lzw/ftzopen.h
deleted file mode 100644
index 6915218292..0000000000
--- a/contrib/libs/freetype/src/lzw/ftzopen.h
+++ /dev/null
@@ -1,174 +0,0 @@
-/****************************************************************************
- *
- * ftzopen.h
- *
- * FreeType support for .Z compressed files.
- *
- * This optional component relies on NetBSD's zopen(). It should mainly
- * be used to parse compressed PCF fonts, as found with many X11 server
- * distributions.
- *
- * Copyright (C) 2005-2024 by
- * David Turner.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-#ifndef FTZOPEN_H_
-#define FTZOPEN_H_
-
-#include <freetype/freetype.h>
-
-FT_BEGIN_HEADER
-
- /*
- * This is a complete re-implementation of the LZW file reader,
- * since the old one was incredibly badly written, using
- * 400 KByte of heap memory before decompressing anything.
- *
- */
-
-#define FT_LZW_IN_BUFF_SIZE 64
-#define FT_LZW_DEFAULT_STACK_SIZE 64
-
-#define LZW_INIT_BITS 9
-#define LZW_MAX_BITS 16
-
-#define LZW_CLEAR 256
-#define LZW_FIRST 257
-
-#define LZW_BIT_MASK 0x1F
-#define LZW_BLOCK_MASK 0x80
-#define LZW_MASK( n ) ( ( 1U << (n) ) - 1U )
-
-
- typedef enum FT_LzwPhase_
- {
- FT_LZW_PHASE_START = 0,
- FT_LZW_PHASE_CODE,
- FT_LZW_PHASE_STACK,
- FT_LZW_PHASE_EOF
-
- } FT_LzwPhase;
-
-
- /*
- * state of LZW decompressor
- *
- * small technical note
- * --------------------
- *
- * We use a few tricks in this implementation that are explained here to
- * ease debugging and maintenance.
- *
- * - First of all, the `prefix' and `suffix' arrays contain the suffix
- * and prefix for codes over 256; this means that
- *
- * prefix_of(code) == state->prefix[code-256]
- * suffix_of(code) == state->suffix[code-256]
- *
- * Each prefix is a 16-bit code, and each suffix an 8-bit byte.
- *
- * Both arrays are stored in a single memory block, pointed to by
- * `state->prefix'. This means that the following equality is always
- * true:
- *
- * state->suffix == (FT_Byte*)(state->prefix + state->prefix_size)
- *
- * Of course, state->prefix_size is the number of prefix/suffix slots
- * in the arrays, corresponding to codes 256..255+prefix_size.
- *
- * - `free_ent' is the index of the next free entry in the `prefix'
- * and `suffix' arrays. This means that the corresponding `next free
- * code' is really `256+free_ent'.
- *
- * Moreover, `max_free' is the maximum value that `free_ent' can reach.
- *
- * `max_free' corresponds to `(1 << max_bits) - 256'. Note that this
- * value is always <= 0xFF00, which means that both `free_ent' and
- * `max_free' can be stored in an FT_UInt variable, even on 16-bit
- * machines.
- *
- * If `free_ent == max_free', you cannot add new codes to the
- * prefix/suffix table.
- *
- * - `num_bits' is the current number of code bits, starting at 9 and
- * growing each time `free_ent' reaches the value of `free_bits'. The
- * latter is computed as follows
- *
- * if num_bits < max_bits:
- * free_bits = (1 << num_bits)-256
- * else:
- * free_bits = max_free + 1
- *
- * Since the value of `max_free + 1' can never be reached by
- * `free_ent', `num_bits' cannot grow larger than `max_bits'.
- */
-
- typedef struct FT_LzwStateRec_
- {
- FT_LzwPhase phase;
- FT_Int in_eof;
-
- FT_Byte buf_tab[16];
- FT_UInt buf_offset;
- FT_UInt buf_size;
- FT_Bool buf_clear;
- FT_Offset buf_total;
-
- FT_UInt max_bits; /* max code bits, from file header */
- FT_Int block_mode; /* block mode flag, from file header */
- FT_UInt max_free; /* (1 << max_bits) - 256 */
-
- FT_UInt num_bits; /* current code bit number */
- FT_UInt free_ent; /* index of next free entry */
- FT_UInt free_bits; /* if reached by free_ent, increment num_bits */
- FT_UInt old_code;
- FT_UInt old_char;
- FT_UInt in_code;
-
- FT_UShort* prefix; /* always dynamically allocated / reallocated */
- FT_Byte* suffix; /* suffix = (FT_Byte*)(prefix + prefix_size) */
- FT_UInt prefix_size; /* number of slots in `prefix' or `suffix' */
-
- FT_Byte* stack; /* character stack */
- FT_UInt stack_top;
- FT_Offset stack_size;
- FT_Byte stack_0[FT_LZW_DEFAULT_STACK_SIZE]; /* minimize heap alloc */
-
- FT_Stream source; /* source stream */
- FT_Memory memory;
-
- } FT_LzwStateRec, *FT_LzwState;
-
-
- FT_LOCAL( void )
- ft_lzwstate_init( FT_LzwState state,
- FT_Stream source );
-
- FT_LOCAL( void )
- ft_lzwstate_done( FT_LzwState state );
-
-
- FT_LOCAL( void )
- ft_lzwstate_reset( FT_LzwState state );
-
-
- FT_LOCAL( FT_ULong )
- ft_lzwstate_io( FT_LzwState state,
- FT_Byte* buffer,
- FT_ULong out_size );
-
-/* */
-
-FT_END_HEADER
-
-#endif /* FTZOPEN_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/pcf/README b/contrib/libs/freetype/src/pcf/README
deleted file mode 100644
index 09ea970eda..0000000000
--- a/contrib/libs/freetype/src/pcf/README
+++ /dev/null
@@ -1,96 +0,0 @@
- FreeType font driver for PCF fonts
-
- Francesco Zappa Nardelli
- <francesco.zappa.nardelli@ens.fr>
-
-
-Introduction
-************
-
-PCF (Portable Compiled Format) is a binary bitmap font format, largely used
-in X world. This code implements a PCF driver for the FreeType library.
-Glyph images are loaded into memory only on demand, thus leading to a small
-memory footprint.
-
-Information on the PCF font format can only be worked out from
-`pcfread.c', and `pcfwrite.c', to be found, for instance, in the XFree86
-(www.xfree86.org) source tree (xc/lib/font/bitmap/).
-
-Many good bitmap fonts in bdf format come with XFree86: they can be
-compiled into the pcf format using the `bdftopcf' utility.
-
-
-Supported hardware
-******************
-
-The driver has been tested on linux/x86 and sunos5.5/sparc. In both
-cases the compiler was gcc. When back in Paris, I will test it also
-on linux/alpha.
-
-
-Encodings
-*********
-
-Use `FT_Get_BDF_Charset_ID' to access the encoding and registry.
-
-The driver always exports `ft_encoding_none' as face->charmap.encoding.
-FT_Get_Char_Index() behavior is unmodified, that is, it converts the ULong
-value given as argument into the corresponding glyph number.
-
-
-Known problems
-**************
-
-- dealing explicitly with encodings breaks the uniformity of FreeType 2
- API.
-
-- except for encodings properties, client applications have no
- visibility of the PCF_Face object. This means that applications
- cannot directly access font tables and are obliged to trust
- FreeType.
-
-- currently, glyph names and ink_metrics are ignored.
-
-I plan to give full visibility of the PCF_Face object in the next
-release of the driver, thus implementing also glyph names and
-ink_metrics.
-
-- height is defined as (ascent - descent). Is this correct?
-
-- if unable to read size information from the font, PCF_Init_Face
- sets available_size->width and available_size->height to 12.
-
-- too many english grammar errors in the readme file :-(
-
-
-License
-*******
-
-Copyright (C) 2000 by Francesco Zappa Nardelli
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-
-Credits
-*******
-
-Keith Packard wrote the pcf driver found in XFree86. His work is at
-the same time the specification and the sample implementation of the
-PCF format. Undoubtedly, this driver is inspired from his work.
diff --git a/contrib/libs/freetype/src/pcf/pcf.c b/contrib/libs/freetype/src/pcf/pcf.c
deleted file mode 100644
index 6b30fb249a..0000000000
--- a/contrib/libs/freetype/src/pcf/pcf.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/* pcf.c
-
- FreeType font driver for pcf fonts
-
- Copyright 2000-2001, 2003 by
- Francesco Zappa Nardelli
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-*/
-
-
-#define FT_MAKE_OPTION_SINGLE_OBJECT
-
-#include "pcfdrivr.c"
-#include "pcfread.c"
-#include "pcfutil.c"
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/pcf/pcf.h b/contrib/libs/freetype/src/pcf/pcf.h
deleted file mode 100644
index 3134cc355b..0000000000
--- a/contrib/libs/freetype/src/pcf/pcf.h
+++ /dev/null
@@ -1,251 +0,0 @@
-/* pcf.h
-
- FreeType font driver for pcf fonts
-
- Copyright (C) 2000, 2001, 2002, 2003, 2006, 2010 by
- Francesco Zappa Nardelli
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-*/
-
-
-#ifndef PCF_H_
-#define PCF_H_
-
-
-#include <freetype/internal/ftdrv.h>
-#include <freetype/internal/ftstream.h>
-
-
-FT_BEGIN_HEADER
-
- typedef struct PCF_TableRec_
- {
- FT_ULong type;
- FT_ULong format;
- FT_ULong size;
- FT_ULong offset;
-
- } PCF_TableRec, *PCF_Table;
-
-
- typedef struct PCF_TocRec_
- {
- FT_ULong version;
- FT_ULong count;
- PCF_Table tables;
-
- } PCF_TocRec, *PCF_Toc;
-
-
- typedef struct PCF_ParsePropertyRec_
- {
- FT_Long name;
- FT_Byte isString;
- FT_Long value;
-
- } PCF_ParsePropertyRec, *PCF_ParseProperty;
-
-
- typedef struct PCF_PropertyRec_
- {
- FT_String* name;
- FT_Byte isString;
-
- union
- {
- FT_String* atom;
- FT_Long l;
- FT_ULong ul;
-
- } value;
-
- } PCF_PropertyRec, *PCF_Property;
-
-
- typedef struct PCF_Compressed_MetricRec_
- {
- FT_Byte leftSideBearing;
- FT_Byte rightSideBearing;
- FT_Byte characterWidth;
- FT_Byte ascent;
- FT_Byte descent;
-
- } PCF_Compressed_MetricRec, *PCF_Compressed_Metric;
-
-
- typedef struct PCF_MetricRec_
- {
- FT_Short leftSideBearing;
- FT_Short rightSideBearing;
- FT_Short characterWidth;
- FT_Short ascent;
- FT_Short descent;
- FT_Short attributes;
-
- FT_ULong bits; /* offset into the PCF_BITMAPS table */
-
- } PCF_MetricRec, *PCF_Metric;
-
-
- typedef struct PCF_EncRec_
- {
- FT_UShort firstCol;
- FT_UShort lastCol;
- FT_UShort firstRow;
- FT_UShort lastRow;
- FT_UShort defaultChar;
-
- FT_UShort* offset;
-
- } PCF_EncRec, *PCF_Enc;
-
-
- typedef struct PCF_AccelRec_
- {
- FT_Byte noOverlap;
- FT_Byte constantMetrics;
- FT_Byte terminalFont;
- FT_Byte constantWidth;
- FT_Byte inkInside;
- FT_Byte inkMetrics;
- FT_Byte drawDirection;
- FT_Long fontAscent;
- FT_Long fontDescent;
- FT_Long maxOverlap;
- PCF_MetricRec minbounds;
- PCF_MetricRec maxbounds;
- PCF_MetricRec ink_minbounds;
- PCF_MetricRec ink_maxbounds;
-
- } PCF_AccelRec, *PCF_Accel;
-
-
- /*
- * This file uses X11 terminology for PCF data; an `encoding' in X11 speak
- * is the same as a `character code' in FreeType speak.
- */
- typedef struct PCF_FaceRec_
- {
- FT_FaceRec root;
-
- FT_StreamRec comp_stream;
- FT_Stream comp_source;
-
- char* charset_encoding;
- char* charset_registry;
-
- PCF_TocRec toc;
- PCF_AccelRec accel;
-
- int nprops;
- PCF_Property properties;
-
- FT_ULong nmetrics;
- PCF_Metric metrics;
-
- PCF_EncRec enc;
-
- FT_ULong bitmapsFormat;
-
- } PCF_FaceRec, *PCF_Face;
-
-
- typedef struct PCF_DriverRec_
- {
- FT_DriverRec root;
-
- FT_Bool no_long_family_names;
-
- } PCF_DriverRec, *PCF_Driver;
-
-
- /* macros for pcf font format */
-
-#define LSBFirst 0
-#define MSBFirst 1
-
-#define PCF_FILE_VERSION ( ( 'p' << 24 ) | \
- ( 'c' << 16 ) | \
- ( 'f' << 8 ) | 1 )
-#define PCF_FORMAT_MASK 0xFFFFFF00UL
-
-#define PCF_DEFAULT_FORMAT 0x00000000UL
-#define PCF_INKBOUNDS 0x00000200UL
-#define PCF_ACCEL_W_INKBOUNDS 0x00000100UL
-#define PCF_COMPRESSED_METRICS 0x00000100UL
-
-#define PCF_FORMAT_MATCH( a, b ) \
- ( ( (a) & PCF_FORMAT_MASK ) == ( (b) & PCF_FORMAT_MASK ) )
-
-#define PCF_GLYPH_PAD_MASK ( 3 << 0 )
-#define PCF_BYTE_MASK ( 1 << 2 )
-#define PCF_BIT_MASK ( 1 << 3 )
-#define PCF_SCAN_UNIT_MASK ( 3 << 4 )
-
-#define PCF_BYTE_ORDER( f ) \
- ( ( (f) & PCF_BYTE_MASK ) ? MSBFirst : LSBFirst )
-#define PCF_BIT_ORDER( f ) \
- ( ( (f) & PCF_BIT_MASK ) ? MSBFirst : LSBFirst )
-#define PCF_GLYPH_PAD_INDEX( f ) \
- ( (f) & PCF_GLYPH_PAD_MASK )
-#define PCF_GLYPH_PAD( f ) \
- ( 1 << PCF_GLYPH_PAD_INDEX( f ) )
-#define PCF_SCAN_UNIT_INDEX( f ) \
- ( ( (f) & PCF_SCAN_UNIT_MASK ) >> 4 )
-#define PCF_SCAN_UNIT( f ) \
- ( 1 << PCF_SCAN_UNIT_INDEX( f ) )
-#define PCF_FORMAT_BITS( f ) \
- ( (f) & ( PCF_GLYPH_PAD_MASK | \
- PCF_BYTE_MASK | \
- PCF_BIT_MASK | \
- PCF_SCAN_UNIT_MASK ) )
-
-#define PCF_SIZE_TO_INDEX( s ) ( (s) == 4 ? 2 : (s) == 2 ? 1 : 0 )
-#define PCF_INDEX_TO_SIZE( b ) ( 1 << b )
-
-#define PCF_FORMAT( bit, byte, glyph, scan ) \
- ( ( PCF_SIZE_TO_INDEX( scan ) << 4 ) | \
- ( ( (bit) == MSBFirst ? 1 : 0 ) << 3 ) | \
- ( ( (byte) == MSBFirst ? 1 : 0 ) << 2 ) | \
- ( PCF_SIZE_TO_INDEX( glyph ) << 0 ) )
-
-#define PCF_PROPERTIES ( 1 << 0 )
-#define PCF_ACCELERATORS ( 1 << 1 )
-#define PCF_METRICS ( 1 << 2 )
-#define PCF_BITMAPS ( 1 << 3 )
-#define PCF_INK_METRICS ( 1 << 4 )
-#define PCF_BDF_ENCODINGS ( 1 << 5 )
-#define PCF_SWIDTHS ( 1 << 6 )
-#define PCF_GLYPH_NAMES ( 1 << 7 )
-#define PCF_BDF_ACCELERATORS ( 1 << 8 )
-
-#define GLYPHPADOPTIONS 4 /* I'm not sure about this */
-
- FT_LOCAL( FT_Error )
- pcf_load_font( FT_Stream stream,
- PCF_Face face,
- FT_Long face_index );
-
-FT_END_HEADER
-
-#endif /* PCF_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/pcf/pcfdrivr.c b/contrib/libs/freetype/src/pcf/pcfdrivr.c
deleted file mode 100644
index 93632f17c4..0000000000
--- a/contrib/libs/freetype/src/pcf/pcfdrivr.c
+++ /dev/null
@@ -1,836 +0,0 @@
-/* pcfdrivr.c
-
- FreeType font driver for pcf files
-
- Copyright (C) 2000-2004, 2006-2011, 2013, 2014 by
- Francesco Zappa Nardelli
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-*/
-
-
-
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/internal/ftobjs.h>
-#include <freetype/ftgzip.h>
-#include <freetype/ftlzw.h>
-#include <freetype/ftbzip2.h>
-#include <freetype/fterrors.h>
-#include <freetype/ftbdf.h>
-#include <freetype/ttnameid.h>
-
-#include "pcf.h"
-#include "pcfdrivr.h"
-#include "pcfread.h"
-
-#include "pcferror.h"
-#include "pcfutil.h"
-
-#undef FT_COMPONENT
-#define FT_COMPONENT pcfread
-
-#include <freetype/internal/services/svbdf.h>
-#include <freetype/internal/services/svfntfmt.h>
-#include <freetype/internal/services/svprop.h>
-#include <freetype/ftdriver.h>
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT pcfdriver
-
-
- /*
- * This file uses X11 terminology for PCF data; an `encoding' in X11 speak
- * is the same as a `character code' in FreeType speak.
- */
- typedef struct PCF_CMapRec_
- {
- FT_CMapRec root;
- PCF_Enc enc;
-
- } PCF_CMapRec, *PCF_CMap;
-
-
- FT_CALLBACK_DEF( FT_Error )
- pcf_cmap_init( FT_CMap cmap, /* PCF_CMap */
- FT_Pointer init_data )
- {
- PCF_CMap pcfcmap = (PCF_CMap)cmap;
- PCF_Face face = (PCF_Face)FT_CMAP_FACE( cmap );
-
- FT_UNUSED( init_data );
-
-
- pcfcmap->enc = &face->enc;
-
- return FT_Err_Ok;
- }
-
-
- FT_CALLBACK_DEF( void )
- pcf_cmap_done( FT_CMap cmap ) /* PCF_CMap */
- {
- PCF_CMap pcfcmap = (PCF_CMap)cmap;
-
-
- pcfcmap->enc = NULL;
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- pcf_cmap_char_index( FT_CMap cmap, /* PCF_CMap */
- FT_UInt32 charcode )
- {
- PCF_Enc enc = ( (PCF_CMap)cmap )->enc;
-
- FT_UInt32 i = ( charcode >> 8 ) - enc->firstRow;
- FT_UInt32 j = ( charcode & 0xFF ) - enc->firstCol;
- FT_UInt32 h = enc->lastRow - enc->firstRow + 1;
- FT_UInt32 w = enc->lastCol - enc->firstCol + 1;
-
-
- /* wrapped around "negative" values are also rejected */
- if ( i >= h || j >= w )
- return 0;
-
- return (FT_UInt)enc->offset[i * w + j];
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- pcf_cmap_char_next( FT_CMap cmap, /* PCF_CMap */
- FT_UInt32 *acharcode )
- {
- PCF_Enc enc = ( (PCF_CMap)cmap )->enc;
- FT_UInt32 charcode = *acharcode + 1;
-
- FT_UInt32 i = ( charcode >> 8 ) - enc->firstRow;
- FT_UInt32 j = ( charcode & 0xFF ) - enc->firstCol;
- FT_UInt32 h = enc->lastRow - enc->firstRow + 1;
- FT_UInt32 w = enc->lastCol - enc->firstCol + 1;
-
- FT_UInt result = 0;
-
-
- /* adjust wrapped around "negative" values */
- if ( (FT_Int32)i < 0 )
- i = 0;
- if ( (FT_Int32)j < 0 )
- j = 0;
-
- for ( ; i < h; i++, j = 0 )
- for ( ; j < w; j++ )
- {
- result = (FT_UInt)enc->offset[i * w + j];
- if ( result != 0xFFFFU )
- goto Exit;
- }
-
- Exit:
- *acharcode = ( ( i + enc->firstRow ) << 8 ) | ( j + enc->firstCol );
-
- return result;
- }
-
-
- static
- const FT_CMap_ClassRec pcf_cmap_class =
- {
- sizeof ( PCF_CMapRec ),
- pcf_cmap_init,
- pcf_cmap_done,
- pcf_cmap_char_index,
- pcf_cmap_char_next,
-
- NULL, NULL, NULL, NULL, NULL
- };
-
-
- FT_CALLBACK_DEF( void )
- PCF_Face_Done( FT_Face face ) /* PCF_Face */
- {
- PCF_Face pcfface = (PCF_Face)face;
- FT_Memory memory;
-
-
- if ( !face )
- return;
-
- memory = FT_FACE_MEMORY( face );
-
- FT_FREE( pcfface->metrics );
- FT_FREE( pcfface->enc.offset );
-
- /* free properties */
- if ( pcfface->properties )
- {
- FT_Int i;
-
-
- for ( i = 0; i < pcfface->nprops; i++ )
- {
- PCF_Property prop = &pcfface->properties[i];
-
-
- if ( prop )
- {
- FT_FREE( prop->name );
- if ( prop->isString )
- FT_FREE( prop->value.atom );
- }
- }
-
- FT_FREE( pcfface->properties );
- }
-
- FT_FREE( pcfface->toc.tables );
- FT_FREE( face->family_name );
- FT_FREE( face->style_name );
- FT_FREE( face->available_sizes );
- FT_FREE( pcfface->charset_encoding );
- FT_FREE( pcfface->charset_registry );
-
- /* close compressed stream if any */
- if ( face->stream == &pcfface->comp_stream )
- {
- FT_Stream_Close( &pcfface->comp_stream );
- face->stream = pcfface->comp_source;
- }
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- PCF_Face_Init( FT_Stream stream,
- FT_Face face, /* PCF_Face */
- FT_Int face_index,
- FT_Int num_params,
- FT_Parameter* params )
- {
- PCF_Face pcfface = (PCF_Face)face;
- FT_Error error;
-
- FT_UNUSED( num_params );
- FT_UNUSED( params );
-
-
- FT_TRACE2(( "PCF driver\n" ));
-
- error = pcf_load_font( stream, pcfface, face_index );
- if ( error )
- {
- PCF_Face_Done( face );
-
-#if defined( FT_CONFIG_OPTION_USE_ZLIB ) || \
- defined( FT_CONFIG_OPTION_USE_LZW ) || \
- defined( FT_CONFIG_OPTION_USE_BZIP2 )
-
-#ifdef FT_CONFIG_OPTION_USE_ZLIB
- {
- FT_Error error2;
-
-
- /* this didn't work, try gzip support! */
- FT_TRACE2(( " ... try gzip stream\n" ));
- error2 = FT_Stream_OpenGzip( &pcfface->comp_stream, stream );
- if ( FT_ERR_EQ( error2, Unimplemented_Feature ) )
- goto Fail;
-
- error = error2;
- }
-#endif /* FT_CONFIG_OPTION_USE_ZLIB */
-
-#ifdef FT_CONFIG_OPTION_USE_LZW
- if ( error )
- {
- FT_Error error3;
-
-
- /* this didn't work, try LZW support! */
- FT_TRACE2(( " ... try LZW stream\n" ));
- error3 = FT_Stream_OpenLZW( &pcfface->comp_stream, stream );
- if ( FT_ERR_EQ( error3, Unimplemented_Feature ) )
- goto Fail;
-
- error = error3;
- }
-#endif /* FT_CONFIG_OPTION_USE_LZW */
-
-#ifdef FT_CONFIG_OPTION_USE_BZIP2
- if ( error )
- {
- FT_Error error4;
-
-
- /* this didn't work, try Bzip2 support! */
- FT_TRACE2(( " ... try Bzip2 stream\n" ));
- error4 = FT_Stream_OpenBzip2( &pcfface->comp_stream, stream );
- if ( FT_ERR_EQ( error4, Unimplemented_Feature ) )
- goto Fail;
-
- error = error4;
- }
-#endif /* FT_CONFIG_OPTION_USE_BZIP2 */
-
- if ( error )
- goto Fail;
-
- pcfface->comp_source = stream;
- face->stream = &pcfface->comp_stream;
-
- stream = face->stream;
-
- error = pcf_load_font( stream, pcfface, face_index );
- if ( error )
- goto Fail;
-
-#else /* !(FT_CONFIG_OPTION_USE_ZLIB ||
- FT_CONFIG_OPTION_USE_LZW ||
- FT_CONFIG_OPTION_USE_BZIP2) */
-
- goto Fail;
-
-#endif
- }
-
- /* PCF cannot have multiple faces in a single font file.
- * XXX: A non-zero face_index is already an invalid argument, but
- * Type1, Type42 drivers have a convention to return
- * an invalid argument error when the font could be
- * opened by the specified driver.
- */
- if ( face_index < 0 )
- goto Exit;
- else if ( face_index > 0 && ( face_index & 0xFFFF ) > 0 )
- {
- FT_ERROR(( "PCF_Face_Init: invalid face index\n" ));
- PCF_Face_Done( face );
- return FT_THROW( Invalid_Argument );
- }
-
- /* set up charmap */
- {
- FT_String *charset_registry = pcfface->charset_registry;
- FT_String *charset_encoding = pcfface->charset_encoding;
- FT_Bool unicode_charmap = 0;
-
-
- if ( charset_registry && charset_encoding )
- {
- char* s = charset_registry;
-
-
- /* Uh, oh, compare first letters manually to avoid dependency
- on locales. */
- if ( ( s[0] == 'i' || s[0] == 'I' ) &&
- ( s[1] == 's' || s[1] == 'S' ) &&
- ( s[2] == 'o' || s[2] == 'O' ) )
- {
- s += 3;
- if ( !ft_strcmp( s, "10646" ) ||
- ( !ft_strcmp( s, "8859" ) &&
- !ft_strcmp( pcfface->charset_encoding, "1" ) ) )
- unicode_charmap = 1;
- /* another name for ASCII */
- else if ( !ft_strcmp( s, "646.1991" ) &&
- !ft_strcmp( pcfface->charset_encoding, "IRV" ) )
- unicode_charmap = 1;
- }
- }
-
- {
- FT_CharMapRec charmap;
-
-
- charmap.face = face;
- charmap.encoding = FT_ENCODING_NONE;
- /* initial platform/encoding should indicate unset status? */
- charmap.platform_id = TT_PLATFORM_APPLE_UNICODE;
- charmap.encoding_id = TT_APPLE_ID_DEFAULT;
-
- if ( unicode_charmap )
- {
- charmap.encoding = FT_ENCODING_UNICODE;
- charmap.platform_id = TT_PLATFORM_MICROSOFT;
- charmap.encoding_id = TT_MS_ID_UNICODE_CS;
- }
-
- error = FT_CMap_New( &pcf_cmap_class, NULL, &charmap, NULL );
- }
- }
-
- Exit:
- return error;
-
- Fail:
- FT_TRACE2(( " not a PCF file\n" ));
- PCF_Face_Done( face );
- error = FT_THROW( Unknown_File_Format ); /* error */
- goto Exit;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- PCF_Size_Select( FT_Size size,
- FT_ULong strike_index )
- {
- PCF_Accel accel = &( (PCF_Face)size->face )->accel;
-
-
- FT_Select_Metrics( size->face, strike_index );
-
- size->metrics.ascender = accel->fontAscent * 64;
- size->metrics.descender = -accel->fontDescent * 64;
- size->metrics.max_advance = accel->maxbounds.characterWidth * 64;
-
- return FT_Err_Ok;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- PCF_Size_Request( FT_Size size,
- FT_Size_Request req )
- {
- PCF_Face face = (PCF_Face)size->face;
- FT_Bitmap_Size* bsize = size->face->available_sizes;
- FT_Error error = FT_ERR( Invalid_Pixel_Size );
- FT_Long height;
-
-
- height = FT_REQUEST_HEIGHT( req );
- height = ( height + 32 ) >> 6;
-
- switch ( req->type )
- {
- case FT_SIZE_REQUEST_TYPE_NOMINAL:
- if ( height == ( ( bsize->y_ppem + 32 ) >> 6 ) )
- error = FT_Err_Ok;
- break;
-
- case FT_SIZE_REQUEST_TYPE_REAL_DIM:
- if ( height == ( face->accel.fontAscent +
- face->accel.fontDescent ) )
- error = FT_Err_Ok;
- break;
-
- default:
- error = FT_THROW( Unimplemented_Feature );
- break;
- }
-
- if ( error )
- return error;
- else
- return PCF_Size_Select( size, 0 );
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- PCF_Glyph_Load( FT_GlyphSlot slot,
- FT_Size size,
- FT_UInt glyph_index,
- FT_Int32 load_flags )
- {
- PCF_Face face = (PCF_Face)size->face;
- FT_Stream stream;
- FT_Error error = FT_Err_Ok;
- FT_Bitmap* bitmap = &slot->bitmap;
- PCF_Metric metric;
- FT_ULong bytes;
-
-
- FT_TRACE1(( "PCF_Glyph_Load: glyph index %d\n", glyph_index ));
-
- if ( !face )
- {
- error = FT_THROW( Invalid_Face_Handle );
- goto Exit;
- }
-
- if ( glyph_index >= (FT_UInt)face->root.num_glyphs )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- stream = face->root.stream;
-
- metric = face->metrics + glyph_index;
-
- bitmap->rows = (unsigned int)( metric->ascent +
- metric->descent );
- bitmap->width = (unsigned int)( metric->rightSideBearing -
- metric->leftSideBearing );
- bitmap->num_grays = 1;
- bitmap->pixel_mode = FT_PIXEL_MODE_MONO;
-
- switch ( PCF_GLYPH_PAD( face->bitmapsFormat ) )
- {
- case 1:
- bitmap->pitch = (int)( ( bitmap->width + 7 ) >> 3 );
- break;
-
- case 2:
- bitmap->pitch = (int)( ( ( bitmap->width + 15 ) >> 4 ) << 1 );
- break;
-
- case 4:
- bitmap->pitch = (int)( ( ( bitmap->width + 31 ) >> 5 ) << 2 );
- break;
-
- case 8:
- bitmap->pitch = (int)( ( ( bitmap->width + 63 ) >> 6 ) << 3 );
- break;
-
- default:
- return FT_THROW( Invalid_File_Format );
- }
-
- slot->format = FT_GLYPH_FORMAT_BITMAP;
- slot->bitmap_left = metric->leftSideBearing;
- slot->bitmap_top = metric->ascent;
-
- slot->metrics.horiAdvance = (FT_Pos)( metric->characterWidth * 64 );
- slot->metrics.horiBearingX = (FT_Pos)( metric->leftSideBearing * 64 );
- slot->metrics.horiBearingY = (FT_Pos)( metric->ascent * 64 );
- slot->metrics.width = (FT_Pos)( ( metric->rightSideBearing -
- metric->leftSideBearing ) * 64 );
- slot->metrics.height = (FT_Pos)( bitmap->rows * 64 );
-
- ft_synthesize_vertical_metrics( &slot->metrics,
- ( face->accel.fontAscent +
- face->accel.fontDescent ) * 64 );
-
- if ( load_flags & FT_LOAD_BITMAP_METRICS_ONLY )
- goto Exit;
-
- /* XXX: to do: are there cases that need repadding the bitmap? */
- bytes = (FT_ULong)bitmap->pitch * bitmap->rows;
-
- error = ft_glyphslot_alloc_bitmap( slot, (FT_ULong)bytes );
- if ( error )
- goto Exit;
-
- if ( FT_STREAM_SEEK( metric->bits ) ||
- FT_STREAM_READ( bitmap->buffer, bytes ) )
- goto Exit;
-
- if ( PCF_BIT_ORDER( face->bitmapsFormat ) != MSBFirst )
- BitOrderInvert( bitmap->buffer, bytes );
-
- if ( ( PCF_BYTE_ORDER( face->bitmapsFormat ) !=
- PCF_BIT_ORDER( face->bitmapsFormat ) ) )
- {
- switch ( PCF_SCAN_UNIT( face->bitmapsFormat ) )
- {
- case 1:
- break;
-
- case 2:
- TwoByteSwap( bitmap->buffer, bytes );
- break;
-
- case 4:
- FourByteSwap( bitmap->buffer, bytes );
- break;
- }
- }
-
- Exit:
- return error;
- }
-
-
- /*
- *
- * BDF SERVICE
- *
- */
-
- FT_CALLBACK_DEF( FT_Error )
- pcf_get_bdf_property( FT_Face face, /* PCF_Face */
- const char* prop_name,
- BDF_PropertyRec *aproperty )
- {
- PCF_Face pcfface = (PCF_Face)face;
- PCF_Property prop;
-
-
- prop = pcf_find_property( pcfface, prop_name );
- if ( prop )
- {
- if ( prop->isString )
- {
- aproperty->type = BDF_PROPERTY_TYPE_ATOM;
- aproperty->u.atom = prop->value.atom;
- }
- else
- {
- if ( prop->value.l > 0x7FFFFFFFL ||
- prop->value.l < ( -1 - 0x7FFFFFFFL ) )
- {
- FT_TRACE2(( "pcf_get_bdf_property:"
- " too large integer 0x%lx is truncated\n",
- prop->value.l ));
- }
-
- /*
- * The PCF driver loads all properties as signed integers.
- * This really doesn't seem to be a problem, because this is
- * sufficient for any meaningful values.
- */
- aproperty->type = BDF_PROPERTY_TYPE_INTEGER;
- aproperty->u.integer = (FT_Int32)prop->value.l;
- }
-
- return FT_Err_Ok;
- }
-
- return FT_THROW( Invalid_Argument );
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- pcf_get_charset_id( FT_Face face, /* PCF_Face */
- const char* *acharset_encoding,
- const char* *acharset_registry )
- {
- PCF_Face pcfface = (PCF_Face)face;
-
-
- *acharset_encoding = pcfface->charset_encoding;
- *acharset_registry = pcfface->charset_registry;
-
- return FT_Err_Ok;
- }
-
-
- static const FT_Service_BDFRec pcf_service_bdf =
- {
- (FT_BDF_GetCharsetIdFunc)pcf_get_charset_id, /* get_charset_id */
- (FT_BDF_GetPropertyFunc) pcf_get_bdf_property /* get_property */
- };
-
-
- /*
- * PROPERTY SERVICE
- *
- */
- FT_CALLBACK_DEF( FT_Error )
- pcf_property_set( FT_Module module, /* PCF_Driver */
- const char* property_name,
- const void* value,
- FT_Bool value_is_string )
- {
-#ifdef PCF_CONFIG_OPTION_LONG_FAMILY_NAMES
-
- FT_Error error = FT_Err_Ok;
- PCF_Driver driver = (PCF_Driver)module;
-
-#ifndef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
- FT_UNUSED( value_is_string );
-#endif
-
-
- if ( !ft_strcmp( property_name, "no-long-family-names" ) )
- {
-#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
- if ( value_is_string )
- {
- const char* s = (const char*)value;
- long lfn = ft_strtol( s, NULL, 10 );
-
-
- if ( lfn == 0 )
- driver->no_long_family_names = 0;
- else if ( lfn == 1 )
- driver->no_long_family_names = 1;
- else
- return FT_THROW( Invalid_Argument );
- }
- else
-#endif
- {
- FT_Bool* no_long_family_names = (FT_Bool*)value;
-
-
- driver->no_long_family_names = *no_long_family_names;
- }
-
- return error;
- }
-
-#else /* !PCF_CONFIG_OPTION_LONG_FAMILY_NAMES */
-
- FT_UNUSED( module );
- FT_UNUSED( value );
- FT_UNUSED( value_is_string );
-#ifndef FT_DEBUG_LEVEL_TRACE
- FT_UNUSED( property_name );
-#endif
-
-#endif /* !PCF_CONFIG_OPTION_LONG_FAMILY_NAMES */
-
- FT_TRACE2(( "pcf_property_set: missing property `%s'\n",
- property_name ));
- return FT_THROW( Missing_Property );
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- pcf_property_get( FT_Module module, /* PCF_Driver */
- const char* property_name,
- void* value )
- {
-#ifdef PCF_CONFIG_OPTION_LONG_FAMILY_NAMES
-
- FT_Error error = FT_Err_Ok;
- PCF_Driver driver = (PCF_Driver)module;
-
-
- if ( !ft_strcmp( property_name, "no-long-family-names" ) )
- {
- FT_Bool no_long_family_names = driver->no_long_family_names;
- FT_Bool* val = (FT_Bool*)value;
-
-
- *val = no_long_family_names;
-
- return error;
- }
-
-#else /* !PCF_CONFIG_OPTION_LONG_FAMILY_NAMES */
-
- FT_UNUSED( module );
- FT_UNUSED( value );
-#ifndef FT_DEBUG_LEVEL_TRACE
- FT_UNUSED( property_name );
-#endif
-
-#endif /* !PCF_CONFIG_OPTION_LONG_FAMILY_NAMES */
-
- FT_TRACE2(( "pcf_property_get: missing property `%s'\n",
- property_name ));
- return FT_THROW( Missing_Property );
- }
-
-
- FT_DEFINE_SERVICE_PROPERTIESREC(
- pcf_service_properties,
-
- (FT_Properties_SetFunc)pcf_property_set, /* set_property */
- (FT_Properties_GetFunc)pcf_property_get ) /* get_property */
-
-
- /*
- *
- * SERVICE LIST
- *
- */
-
- static const FT_ServiceDescRec pcf_services[] =
- {
- { FT_SERVICE_ID_BDF, &pcf_service_bdf },
- { FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_PCF },
- { FT_SERVICE_ID_PROPERTIES, &pcf_service_properties },
- { NULL, NULL }
- };
-
-
- FT_CALLBACK_DEF( FT_Module_Interface )
- pcf_driver_requester( FT_Module module,
- const char* name )
- {
- FT_UNUSED( module );
-
- return ft_service_list_lookup( pcf_services, name );
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- pcf_driver_init( FT_Module module ) /* PCF_Driver */
- {
-#ifdef PCF_CONFIG_OPTION_LONG_FAMILY_NAMES
- PCF_Driver driver = (PCF_Driver)module;
-
-
- driver->no_long_family_names = 0;
-#else
- FT_UNUSED( module );
-#endif
-
- return FT_Err_Ok;
- }
-
-
- FT_CALLBACK_DEF( void )
- pcf_driver_done( FT_Module module ) /* PCF_Driver */
- {
- FT_UNUSED( module );
- }
-
-
- FT_CALLBACK_TABLE_DEF
- const FT_Driver_ClassRec pcf_driver_class =
- {
- {
- FT_MODULE_FONT_DRIVER |
- FT_MODULE_DRIVER_NO_OUTLINES,
-
- sizeof ( PCF_DriverRec ),
- "pcf",
- 0x10000L,
- 0x20000L,
-
- NULL, /* module-specific interface */
-
- pcf_driver_init, /* FT_Module_Constructor module_init */
- pcf_driver_done, /* FT_Module_Destructor module_done */
- pcf_driver_requester /* FT_Module_Requester get_interface */
- },
-
- sizeof ( PCF_FaceRec ),
- sizeof ( FT_SizeRec ),
- sizeof ( FT_GlyphSlotRec ),
-
- PCF_Face_Init, /* FT_Face_InitFunc init_face */
- PCF_Face_Done, /* FT_Face_DoneFunc done_face */
- NULL, /* FT_Size_InitFunc init_size */
- NULL, /* FT_Size_DoneFunc done_size */
- NULL, /* FT_Slot_InitFunc init_slot */
- NULL, /* FT_Slot_DoneFunc done_slot */
-
- PCF_Glyph_Load, /* FT_Slot_LoadFunc load_glyph */
-
- NULL, /* FT_Face_GetKerningFunc get_kerning */
- NULL, /* FT_Face_AttachFunc attach_file */
- NULL, /* FT_Face_GetAdvancesFunc get_advances */
-
- PCF_Size_Request, /* FT_Size_RequestFunc request_size */
- PCF_Size_Select /* FT_Size_SelectFunc select_size */
- };
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/pcf/pcfdrivr.h b/contrib/libs/freetype/src/pcf/pcfdrivr.h
deleted file mode 100644
index d465393743..0000000000
--- a/contrib/libs/freetype/src/pcf/pcfdrivr.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* pcfdrivr.h
-
- FreeType font driver for pcf fonts
-
- Copyright 2000-2001, 2002 by
- Francesco Zappa Nardelli
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-*/
-
-
-#ifndef PCFDRIVR_H_
-#define PCFDRIVR_H_
-
-#include <freetype/internal/ftdrv.h>
-
-
-FT_BEGIN_HEADER
-
- FT_EXPORT_VAR( const FT_Driver_ClassRec ) pcf_driver_class;
-
-FT_END_HEADER
-
-
-#endif /* PCFDRIVR_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/pcf/pcferror.h b/contrib/libs/freetype/src/pcf/pcferror.h
deleted file mode 100644
index 8b9e9902a3..0000000000
--- a/contrib/libs/freetype/src/pcf/pcferror.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/****************************************************************************
- *
- * pcferror.h
- *
- * PCF error codes (specification only).
- *
- * Copyright 2001, 2012 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /**************************************************************************
- *
- * This file is used to define the PCF error enumeration constants.
- *
- */
-
-#ifndef PCFERROR_H_
-#define PCFERROR_H_
-
-#include <freetype/ftmoderr.h>
-
-#undef FTERRORS_H_
-
-#undef FT_ERR_PREFIX
-#define FT_ERR_PREFIX PCF_Err_
-#define FT_ERR_BASE FT_Mod_Err_PCF
-
-#include <freetype/fterrors.h>
-
-#endif /* PCFERROR_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/pcf/pcfread.c b/contrib/libs/freetype/src/pcf/pcfread.c
deleted file mode 100644
index f167bcb8ae..0000000000
--- a/contrib/libs/freetype/src/pcf/pcfread.c
+++ /dev/null
@@ -1,1731 +0,0 @@
-/* pcfread.c
-
- FreeType font driver for pcf fonts
-
- Copyright 2000-2010, 2012-2014 by
- Francesco Zappa Nardelli
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-*/
-
-
-
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/internal/ftobjs.h>
-
-#include "pcf.h"
-#include "pcfread.h"
-
-#include "pcferror.h"
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT pcfread
-
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- static const char* const tableNames[] =
- {
- "properties",
- "accelerators",
- "metrics",
- "bitmaps",
- "ink metrics",
- "encodings",
- "swidths",
- "glyph names",
- "BDF accelerators"
- };
-#endif
-
-
- static
- const FT_Frame_Field pcf_toc_header[] =
- {
-#undef FT_STRUCTURE
-#define FT_STRUCTURE PCF_TocRec
-
- FT_FRAME_START( 8 ),
- FT_FRAME_ULONG_LE( version ),
- FT_FRAME_ULONG_LE( count ),
- FT_FRAME_END
- };
-
-
- static
- const FT_Frame_Field pcf_table_header[] =
- {
-#undef FT_STRUCTURE
-#define FT_STRUCTURE PCF_TableRec
-
- FT_FRAME_START( 16 ),
- FT_FRAME_ULONG_LE( type ),
- FT_FRAME_ULONG_LE( format ),
- FT_FRAME_ULONG_LE( size ), /* rounded up to a multiple of 4 */
- FT_FRAME_ULONG_LE( offset ),
- FT_FRAME_END
- };
-
-
- static FT_Error
- pcf_read_TOC( FT_Stream stream,
- PCF_Face face )
- {
- FT_Error error;
- PCF_Toc toc = &face->toc;
- PCF_Table tables;
-
- FT_Memory memory = FT_FACE( face )->memory;
- FT_UInt n;
-
- FT_ULong size;
-
-
- if ( FT_STREAM_SEEK( 0 ) ||
- FT_STREAM_READ_FIELDS( pcf_toc_header, toc ) )
- return FT_THROW( Cannot_Open_Resource );
-
- if ( toc->version != PCF_FILE_VERSION ||
- toc->count == 0 )
- return FT_THROW( Invalid_File_Format );
-
- if ( stream->size < 16 )
- return FT_THROW( Invalid_File_Format );
-
- /* we need 16 bytes per TOC entry, */
- /* and there can be most 9 tables */
- if ( toc->count > ( stream->size >> 4 ) ||
- toc->count > 9 )
- {
- FT_TRACE0(( "pcf_read_TOC: adjusting number of tables"
- " (from %ld to %ld)\n",
- toc->count,
- FT_MIN( stream->size >> 4, 9 ) ));
- toc->count = FT_MIN( stream->size >> 4, 9 );
- }
-
- if ( FT_QNEW_ARRAY( face->toc.tables, toc->count ) )
- return error;
-
- tables = face->toc.tables;
- for ( n = 0; n < toc->count; n++ )
- {
- if ( FT_STREAM_READ_FIELDS( pcf_table_header, tables ) )
- goto Exit;
- tables++;
- }
-
- /* Sort tables and check for overlaps. Because they are almost */
- /* always ordered already, an in-place bubble sort with simultaneous */
- /* boundary checking seems appropriate. */
- tables = face->toc.tables;
-
- for ( n = 0; n < toc->count - 1; n++ )
- {
- FT_UInt i, have_change;
-
-
- have_change = 0;
-
- for ( i = 0; i < toc->count - 1 - n; i++ )
- {
- PCF_TableRec tmp;
-
-
- if ( tables[i].offset > tables[i + 1].offset )
- {
- tmp = tables[i];
- tables[i] = tables[i + 1];
- tables[i + 1] = tmp;
-
- have_change = 1;
- }
-
- if ( ( tables[i].size > tables[i + 1].offset ) ||
- ( tables[i].offset > tables[i + 1].offset - tables[i].size ) )
- {
- error = FT_THROW( Invalid_Offset );
- goto Exit;
- }
- }
-
- if ( !have_change )
- break;
- }
-
- /*
- * We now check whether the `size' and `offset' values are reasonable:
- * `offset' + `size' must not exceed the stream size.
- *
- * Note, however, that X11's `pcfWriteFont' routine (used by the
- * `bdftopcf' program to create PCF font files) has two special
- * features.
- *
- * - It always assigns the accelerator table a size of 100 bytes in the
- * TOC, regardless of its real size, which can vary between 34 and 72
- * bytes.
- *
- * - Due to the way the routine is designed, it ships out the last font
- * table with its real size, ignoring the TOC's size value. Since
- * the TOC size values are always rounded up to a multiple of 4, the
- * difference can be up to three bytes for all tables except the
- * accelerator table, for which the difference can be as large as 66
- * bytes.
- *
- */
-
- tables = face->toc.tables;
- size = stream->size;
-
- for ( n = 0; n < toc->count - 1; n++ )
- {
- /* we need two checks to avoid overflow */
- if ( ( tables->size > size ) ||
- ( tables->offset > size - tables->size ) )
- {
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
- tables++;
- }
-
- /* only check `tables->offset' for last table element ... */
- if ( ( tables->offset > size ) )
- {
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
- /* ... and adjust `tables->size' to the real value if necessary */
- if ( tables->size > size - tables->offset )
- tables->size = size - tables->offset;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
-
- {
- FT_UInt i, j;
- const char* name = "?";
-
-
- FT_TRACE4(( "pcf_read_TOC:\n" ));
-
- FT_TRACE4(( " number of tables: %ld\n", face->toc.count ));
-
- tables = face->toc.tables;
- for ( i = 0; i < toc->count; i++ )
- {
- for ( j = 0; j < sizeof ( tableNames ) / sizeof ( tableNames[0] );
- j++ )
- if ( tables[i].type == 1UL << j )
- name = tableNames[j];
-
- FT_TRACE4(( " %d: type=%s, format=0x%lX,"
- " size=%ld (0x%lX), offset=%ld (0x%lX)\n",
- i, name,
- tables[i].format,
- tables[i].size, tables[i].size,
- tables[i].offset, tables[i].offset ));
- }
- }
-
-#endif
-
- return FT_Err_Ok;
-
- Exit:
- FT_FREE( face->toc.tables );
- return error;
- }
-
-
-#define PCF_METRIC_SIZE 12
-
- static
- const FT_Frame_Field pcf_metric_header[] =
- {
-#undef FT_STRUCTURE
-#define FT_STRUCTURE PCF_MetricRec
-
- FT_FRAME_START( PCF_METRIC_SIZE ),
- FT_FRAME_SHORT_LE( leftSideBearing ),
- FT_FRAME_SHORT_LE( rightSideBearing ),
- FT_FRAME_SHORT_LE( characterWidth ),
- FT_FRAME_SHORT_LE( ascent ),
- FT_FRAME_SHORT_LE( descent ),
- FT_FRAME_SHORT_LE( attributes ),
- FT_FRAME_END
- };
-
-
- static
- const FT_Frame_Field pcf_metric_msb_header[] =
- {
-#undef FT_STRUCTURE
-#define FT_STRUCTURE PCF_MetricRec
-
- FT_FRAME_START( PCF_METRIC_SIZE ),
- FT_FRAME_SHORT( leftSideBearing ),
- FT_FRAME_SHORT( rightSideBearing ),
- FT_FRAME_SHORT( characterWidth ),
- FT_FRAME_SHORT( ascent ),
- FT_FRAME_SHORT( descent ),
- FT_FRAME_SHORT( attributes ),
- FT_FRAME_END
- };
-
-
-#define PCF_COMPRESSED_METRIC_SIZE 5
-
- static
- const FT_Frame_Field pcf_compressed_metric_header[] =
- {
-#undef FT_STRUCTURE
-#define FT_STRUCTURE PCF_Compressed_MetricRec
-
- FT_FRAME_START( PCF_COMPRESSED_METRIC_SIZE ),
- FT_FRAME_BYTE( leftSideBearing ),
- FT_FRAME_BYTE( rightSideBearing ),
- FT_FRAME_BYTE( characterWidth ),
- FT_FRAME_BYTE( ascent ),
- FT_FRAME_BYTE( descent ),
- FT_FRAME_END
- };
-
-
- static FT_Error
- pcf_get_metric( FT_Stream stream,
- FT_ULong format,
- PCF_Metric metric )
- {
- FT_Error error = FT_Err_Ok;
-
-
- if ( PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) )
- {
- const FT_Frame_Field* fields;
-
-
- /* parsing normal metrics */
- fields = ( PCF_BYTE_ORDER( format ) == MSBFirst )
- ? pcf_metric_msb_header
- : pcf_metric_header;
-
- /* the following sets `error' but doesn't return in case of failure */
- (void)FT_STREAM_READ_FIELDS( fields, metric );
- }
- else
- {
- PCF_Compressed_MetricRec compr;
-
-
- /* parsing compressed metrics */
- if ( FT_STREAM_READ_FIELDS( pcf_compressed_metric_header, &compr ) )
- goto Exit;
-
- metric->leftSideBearing = (FT_Short)( compr.leftSideBearing - 0x80 );
- metric->rightSideBearing = (FT_Short)( compr.rightSideBearing - 0x80 );
- metric->characterWidth = (FT_Short)( compr.characterWidth - 0x80 );
- metric->ascent = (FT_Short)( compr.ascent - 0x80 );
- metric->descent = (FT_Short)( compr.descent - 0x80 );
- metric->attributes = 0;
- }
-
- FT_TRACE5(( " width=%d,"
- " lsb=%d, rsb=%d,"
- " ascent=%d, descent=%d,"
- " attributes=%d\n",
- metric->characterWidth,
- metric->leftSideBearing,
- metric->rightSideBearing,
- metric->ascent,
- metric->descent,
- metric->attributes ));
-
- Exit:
- return error;
- }
-
-
- static FT_Error
- pcf_seek_to_table_type( FT_Stream stream,
- PCF_Table tables,
- FT_ULong ntables, /* same as PCF_Toc->count */
- FT_ULong type,
- FT_ULong *aformat,
- FT_ULong *asize )
- {
- FT_Error error = FT_ERR( Invalid_File_Format );
- FT_ULong i;
-
-
- for ( i = 0; i < ntables; i++ )
- if ( tables[i].type == type )
- {
- if ( stream->pos > tables[i].offset )
- {
- error = FT_THROW( Invalid_Stream_Skip );
- goto Fail;
- }
-
- if ( FT_STREAM_SKIP( tables[i].offset - stream->pos ) )
- {
- error = FT_THROW( Invalid_Stream_Skip );
- goto Fail;
- }
-
- *asize = tables[i].size;
- *aformat = tables[i].format;
-
- return FT_Err_Ok;
- }
-
- Fail:
- *asize = 0;
- return error;
- }
-
-
- static FT_Bool
- pcf_has_table_type( PCF_Table tables,
- FT_ULong ntables, /* same as PCF_Toc->count */
- FT_ULong type )
- {
- FT_ULong i;
-
-
- for ( i = 0; i < ntables; i++ )
- if ( tables[i].type == type )
- return TRUE;
-
- return FALSE;
- }
-
-
-#define PCF_PROPERTY_SIZE 9
-
- static
- const FT_Frame_Field pcf_property_header[] =
- {
-#undef FT_STRUCTURE
-#define FT_STRUCTURE PCF_ParsePropertyRec
-
- FT_FRAME_START( PCF_PROPERTY_SIZE ),
- FT_FRAME_LONG_LE( name ),
- FT_FRAME_BYTE ( isString ),
- FT_FRAME_LONG_LE( value ),
- FT_FRAME_END
- };
-
-
- static
- const FT_Frame_Field pcf_property_msb_header[] =
- {
-#undef FT_STRUCTURE
-#define FT_STRUCTURE PCF_ParsePropertyRec
-
- FT_FRAME_START( PCF_PROPERTY_SIZE ),
- FT_FRAME_LONG( name ),
- FT_FRAME_BYTE( isString ),
- FT_FRAME_LONG( value ),
- FT_FRAME_END
- };
-
-
- FT_LOCAL_DEF( PCF_Property )
- pcf_find_property( PCF_Face face,
- const FT_String* prop )
- {
- PCF_Property properties = face->properties;
- FT_Bool found = 0;
- int i;
-
-
- for ( i = 0; i < face->nprops && !found; i++ )
- {
- if ( !ft_strcmp( properties[i].name, prop ) )
- found = 1;
- }
-
- if ( found )
- return properties + i - 1;
- else
- return NULL;
- }
-
-
- static FT_Error
- pcf_get_properties( FT_Stream stream,
- PCF_Face face )
- {
- PCF_ParseProperty props = NULL;
- PCF_Property properties = NULL;
- FT_ULong nprops, orig_nprops, i;
- FT_ULong format, size;
- FT_Error error;
- FT_Memory memory = FT_FACE( face )->memory;
- FT_ULong string_size;
- FT_String* strings = NULL;
-
-
- error = pcf_seek_to_table_type( stream,
- face->toc.tables,
- face->toc.count,
- PCF_PROPERTIES,
- &format,
- &size );
- if ( error )
- goto Bail;
-
- if ( FT_READ_ULONG_LE( format ) )
- goto Bail;
-
- FT_TRACE4(( "pcf_get_properties:\n" ));
- FT_TRACE4(( " format: 0x%lX (%s)\n",
- format,
- PCF_BYTE_ORDER( format ) == MSBFirst ? "MSB" : "LSB" ));
-
- if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) )
- goto Bail;
-
- if ( PCF_BYTE_ORDER( format ) == MSBFirst )
- (void)FT_READ_ULONG( orig_nprops );
- else
- (void)FT_READ_ULONG_LE( orig_nprops );
- if ( error )
- goto Bail;
-
- FT_TRACE4(( " number of properties: %ld\n", orig_nprops ));
-
- /* rough estimate */
- if ( orig_nprops > size / PCF_PROPERTY_SIZE )
- {
- error = FT_THROW( Invalid_Table );
- goto Bail;
- }
-
- /* as a heuristic limit to avoid excessive allocation in */
- /* gzip bombs (i.e., very small, invalid input data that */
- /* pretends to expand to an insanely large file) we only */
- /* load the first 256 properties */
- if ( orig_nprops > 256 )
- {
- FT_TRACE0(( "pcf_get_properties:"
- " only loading first 256 properties\n" ));
- nprops = 256;
- }
- else
- nprops = orig_nprops;
-
- face->nprops = (int)nprops;
-
- if ( FT_QNEW_ARRAY( props, nprops ) )
- goto Bail;
-
- for ( i = 0; i < nprops; i++ )
- {
- if ( PCF_BYTE_ORDER( format ) == MSBFirst )
- {
- if ( FT_STREAM_READ_FIELDS( pcf_property_msb_header, props + i ) )
- goto Bail;
- }
- else
- {
- if ( FT_STREAM_READ_FIELDS( pcf_property_header, props + i ) )
- goto Bail;
- }
- }
-
- /* this skip will only work if we really have an extremely large */
- /* number of properties; it will fail for fake data, avoiding an */
- /* unnecessarily large allocation later on */
- if ( FT_STREAM_SKIP( ( orig_nprops - nprops ) * PCF_PROPERTY_SIZE ) )
- {
- error = FT_THROW( Invalid_Stream_Skip );
- goto Bail;
- }
-
- /* pad the property array */
- /* */
- /* clever here - nprops is the same as the number of odd-units read, */
- /* as only isStringProp are odd length (Keith Packard) */
- /* */
- if ( orig_nprops & 3 )
- {
- i = 4 - ( orig_nprops & 3 );
- if ( FT_STREAM_SKIP( i ) )
- {
- error = FT_THROW( Invalid_Stream_Skip );
- goto Bail;
- }
- }
-
- if ( PCF_BYTE_ORDER( format ) == MSBFirst )
- (void)FT_READ_ULONG( string_size );
- else
- (void)FT_READ_ULONG_LE( string_size );
- if ( error )
- goto Bail;
-
- FT_TRACE4(( " string size: %ld\n", string_size ));
-
- /* rough estimate */
- if ( string_size > size - orig_nprops * PCF_PROPERTY_SIZE )
- {
- error = FT_THROW( Invalid_Table );
- goto Bail;
- }
-
- /* the strings in the `strings' array are PostScript strings, */
- /* which can have a maximum length of 65536 characters each */
- if ( string_size > 16777472 ) /* 256 * (65536 + 1) */
- {
- FT_TRACE0(( "pcf_get_properties:"
- " loading only 16777472 bytes of strings array\n" ));
- string_size = 16777472;
- }
-
- /* allocate one more byte so that we have a final null byte */
- if ( FT_QALLOC( strings, string_size + 1 ) ||
- FT_STREAM_READ( strings, string_size ) )
- goto Bail;
-
- strings[string_size] = '\0';
-
- /* zero out in case of failure */
- if ( FT_NEW_ARRAY( properties, nprops ) )
- goto Bail;
-
- face->properties = properties;
-
- FT_TRACE4(( "\n" ));
- for ( i = 0; i < nprops; i++ )
- {
- FT_Long name_offset = props[i].name;
-
-
- if ( ( name_offset < 0 ) ||
- ( (FT_ULong)name_offset > string_size ) )
- {
- error = FT_THROW( Invalid_Offset );
- goto Bail;
- }
-
- if ( FT_STRDUP( properties[i].name, strings + name_offset ) )
- goto Bail;
-
- FT_TRACE4(( " %s:", properties[i].name ));
-
- properties[i].isString = props[i].isString;
-
- if ( props[i].isString )
- {
- FT_Long value_offset = props[i].value;
-
-
- if ( ( value_offset < 0 ) ||
- ( (FT_ULong)value_offset > string_size ) )
- {
- error = FT_THROW( Invalid_Offset );
- goto Bail;
- }
-
- if ( FT_STRDUP( properties[i].value.atom, strings + value_offset ) )
- goto Bail;
-
- FT_TRACE4(( " `%s'\n", properties[i].value.atom ));
- }
- else
- {
- properties[i].value.l = props[i].value;
-
- FT_TRACE4(( " %ld\n", properties[i].value.l ));
- }
- }
-
- error = FT_Err_Ok;
-
- Bail:
- FT_FREE( props );
- FT_FREE( strings );
-
- return error;
- }
-
-
- static FT_Error
- pcf_get_metrics( FT_Stream stream,
- PCF_Face face )
- {
- FT_Error error;
- FT_Memory memory = FT_FACE( face )->memory;
- FT_ULong format, size;
- PCF_Metric metrics = NULL;
- FT_ULong nmetrics, orig_nmetrics, i;
-
-
- error = pcf_seek_to_table_type( stream,
- face->toc.tables,
- face->toc.count,
- PCF_METRICS,
- &format,
- &size );
- if ( error )
- return error;
-
- if ( FT_READ_ULONG_LE( format ) )
- goto Bail;
-
- FT_TRACE4(( "pcf_get_metrics:\n" ));
- FT_TRACE4(( " format: 0x%lX (%s, %s)\n",
- format,
- PCF_BYTE_ORDER( format ) == MSBFirst ? "MSB" : "LSB",
- PCF_FORMAT_MATCH( format, PCF_COMPRESSED_METRICS ) ?
- "compressed" : "uncompressed" ));
-
- if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) &&
- !PCF_FORMAT_MATCH( format, PCF_COMPRESSED_METRICS ) )
- return FT_THROW( Invalid_File_Format );
-
- if ( PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) )
- {
- if ( PCF_BYTE_ORDER( format ) == MSBFirst )
- (void)FT_READ_ULONG( orig_nmetrics );
- else
- (void)FT_READ_ULONG_LE( orig_nmetrics );
- }
- else
- {
- if ( PCF_BYTE_ORDER( format ) == MSBFirst )
- (void)FT_READ_USHORT( orig_nmetrics );
- else
- (void)FT_READ_USHORT_LE( orig_nmetrics );
- }
- if ( error )
- return FT_THROW( Invalid_File_Format );
-
- FT_TRACE4(( " number of metrics: %ld\n", orig_nmetrics ));
-
- /* rough estimate */
- if ( PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) )
- {
- if ( orig_nmetrics > size / PCF_METRIC_SIZE )
- return FT_THROW( Invalid_Table );
- }
- else
- {
- if ( orig_nmetrics > size / PCF_COMPRESSED_METRIC_SIZE )
- return FT_THROW( Invalid_Table );
- }
-
- if ( !orig_nmetrics )
- return FT_THROW( Invalid_Table );
-
- /*
- * PCF is a format from ancient times; Unicode was in its infancy, and
- * widely used two-byte character sets for CJK scripts (Big 5, GB 2312,
- * JIS X 0208, etc.) did have at most 15000 characters. Even the more
- * exotic CNS 11643 and CCCII standards, which were essentially
- * three-byte character sets, provided less then 65536 assigned
- * characters.
- *
- * While technically possible to have a larger number of glyphs in PCF
- * files, we thus limit the number to 65535, taking into account that we
- * synthesize the metrics of glyph 0 to be a copy of the `default
- * character', and that 0xFFFF in the encodings array indicates a
- * missing glyph.
- */
- if ( orig_nmetrics > 65534 )
- {
- FT_TRACE0(( "pcf_get_metrics:"
- " only loading first 65534 metrics\n" ));
- nmetrics = 65534;
- }
- else
- nmetrics = orig_nmetrics;
-
- face->nmetrics = nmetrics + 1;
-
- if ( FT_QNEW_ARRAY( face->metrics, face->nmetrics ) )
- return error;
-
- /* we handle glyph index 0 later on */
- metrics = face->metrics + 1;
-
- FT_TRACE4(( "\n" ));
- for ( i = 1; i < face->nmetrics; i++, metrics++ )
- {
- FT_TRACE5(( " idx %ld:", i ));
- error = pcf_get_metric( stream, format, metrics );
-
- metrics->bits = 0;
-
- if ( error )
- break;
-
- /* sanity checks -- those values are used in `PCF_Glyph_Load' to */
- /* compute a glyph's bitmap dimensions, thus setting them to zero in */
- /* case of an error disables this particular glyph only */
- if ( metrics->rightSideBearing < metrics->leftSideBearing ||
- metrics->ascent < -metrics->descent )
- {
- metrics->characterWidth = 0;
- metrics->leftSideBearing = 0;
- metrics->rightSideBearing = 0;
- metrics->ascent = 0;
- metrics->descent = 0;
-
- FT_TRACE0(( "pcf_get_metrics:"
- " invalid metrics for glyph %ld\n", i ));
- }
- }
-
- if ( error )
- FT_FREE( face->metrics );
-
- Bail:
- return error;
- }
-
-
- static FT_Error
- pcf_get_bitmaps( FT_Stream stream,
- PCF_Face face )
- {
- FT_Error error;
- FT_ULong bitmapSizes[GLYPHPADOPTIONS];
- FT_ULong format, size, pos;
- FT_ULong nbitmaps, orig_nbitmaps, i, sizebitmaps = 0;
-
-
- error = pcf_seek_to_table_type( stream,
- face->toc.tables,
- face->toc.count,
- PCF_BITMAPS,
- &format,
- &size );
- if ( error )
- return error;
-
- error = FT_Stream_EnterFrame( stream, 8 );
- if ( error )
- return error;
-
- format = FT_GET_ULONG_LE();
- if ( PCF_BYTE_ORDER( format ) == MSBFirst )
- orig_nbitmaps = FT_GET_ULONG();
- else
- orig_nbitmaps = FT_GET_ULONG_LE();
-
- FT_Stream_ExitFrame( stream );
-
- FT_TRACE4(( "pcf_get_bitmaps:\n" ));
- FT_TRACE4(( " format: 0x%lX\n", format ));
- FT_TRACE4(( " (%s, %s,\n",
- PCF_BYTE_ORDER( format ) == MSBFirst
- ? "most significant byte first"
- : "least significant byte first",
- PCF_BIT_ORDER( format ) == MSBFirst
- ? "most significant bit first"
- : "least significant bit first" ));
- FT_TRACE4(( " padding=%d bit%s, scanning=%d bit%s)\n",
- 8 << PCF_GLYPH_PAD_INDEX( format ),
- ( 8 << PCF_GLYPH_PAD_INDEX( format ) ) == 1 ? "" : "s",
- 8 << PCF_SCAN_UNIT_INDEX( format ),
- ( 8 << PCF_SCAN_UNIT_INDEX( format ) ) == 1 ? "" : "s" ));
-
- if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) )
- return FT_THROW( Invalid_File_Format );
-
- FT_TRACE4(( " number of bitmaps: %ld\n", orig_nbitmaps ));
-
- /* see comment in `pcf_get_metrics' */
- if ( orig_nbitmaps > 65534 )
- {
- FT_TRACE0(( "pcf_get_bitmaps:"
- " only loading first 65534 bitmaps\n" ));
- nbitmaps = 65534;
- }
- else
- nbitmaps = orig_nbitmaps;
-
- /* no extra bitmap for glyph 0 */
- if ( nbitmaps != face->nmetrics - 1 )
- return FT_THROW( Invalid_File_Format );
-
- /* start position of bitmap data */
- pos = stream->pos + nbitmaps * 4 + 4 * 4;
-
- FT_TRACE5(( "\n" ));
- for ( i = 1; i <= nbitmaps; i++ )
- {
- FT_ULong offset;
-
-
- if ( PCF_BYTE_ORDER( format ) == MSBFirst )
- (void)FT_READ_ULONG( offset );
- else
- (void)FT_READ_ULONG_LE( offset );
-
- FT_TRACE5(( " bitmap %lu: offset %lu (0x%lX)\n",
- i, offset, offset ));
-
- /* right now, we only check the offset with a rough estimate; */
- /* actual bitmaps are only loaded on demand */
- if ( offset > size )
- {
- FT_TRACE0(( "pcf_get_bitmaps:"
- " invalid offset to bitmap data of glyph %lu\n", i ));
- face->metrics[i].bits = pos;
- }
- else
- face->metrics[i].bits = pos + offset;
- }
- if ( error )
- goto Bail;
-
- for ( i = 0; i < GLYPHPADOPTIONS; i++ )
- {
- if ( PCF_BYTE_ORDER( format ) == MSBFirst )
- (void)FT_READ_ULONG( bitmapSizes[i] );
- else
- (void)FT_READ_ULONG_LE( bitmapSizes[i] );
- if ( error )
- goto Bail;
-
- sizebitmaps = bitmapSizes[PCF_GLYPH_PAD_INDEX( format )];
-
- FT_TRACE4(( " %d-bit padding implies a size of %lu\n",
- 8 << i, bitmapSizes[i] ));
- }
-
- FT_TRACE4(( " %lu bitmaps, using %d-bit padding\n",
- nbitmaps,
- 8 << PCF_GLYPH_PAD_INDEX( format ) ));
- FT_TRACE4(( " bitmap size: %lu\n", sizebitmaps ));
-
- FT_UNUSED( sizebitmaps ); /* only used for debugging */
-
- face->bitmapsFormat = format;
-
- Bail:
- return error;
- }
-
-
- /*
- * This file uses X11 terminology for PCF data; an `encoding' in X11 speak
- * is the same as a character code in FreeType speak.
- */
-#define PCF_ENC_SIZE 10
-
- static
- const FT_Frame_Field pcf_enc_header[] =
- {
-#undef FT_STRUCTURE
-#define FT_STRUCTURE PCF_EncRec
-
- FT_FRAME_START( PCF_ENC_SIZE ),
- FT_FRAME_USHORT_LE( firstCol ),
- FT_FRAME_USHORT_LE( lastCol ),
- FT_FRAME_USHORT_LE( firstRow ),
- FT_FRAME_USHORT_LE( lastRow ),
- FT_FRAME_USHORT_LE( defaultChar ),
- FT_FRAME_END
- };
-
-
- static
- const FT_Frame_Field pcf_enc_msb_header[] =
- {
-#undef FT_STRUCTURE
-#define FT_STRUCTURE PCF_EncRec
-
- FT_FRAME_START( PCF_ENC_SIZE ),
- FT_FRAME_USHORT( firstCol ),
- FT_FRAME_USHORT( lastCol ),
- FT_FRAME_USHORT( firstRow ),
- FT_FRAME_USHORT( lastRow ),
- FT_FRAME_USHORT( defaultChar ),
- FT_FRAME_END
- };
-
-
- static FT_Error
- pcf_get_encodings( FT_Stream stream,
- PCF_Face face )
- {
- FT_Error error;
- FT_Memory memory = FT_FACE( face )->memory;
- FT_ULong format, size;
- PCF_Enc enc = &face->enc;
- FT_ULong nencoding;
- FT_UShort* offset;
- FT_UShort defaultCharRow, defaultCharCol;
- FT_UShort encodingOffset, defaultCharEncodingOffset;
- FT_UShort i, j;
- FT_Byte* pos;
-
-
- error = pcf_seek_to_table_type( stream,
- face->toc.tables,
- face->toc.count,
- PCF_BDF_ENCODINGS,
- &format,
- &size );
- if ( error )
- goto Bail;
-
- if ( FT_READ_ULONG_LE( format ) )
- goto Bail;
-
- FT_TRACE4(( "pcf_get_encodings:\n" ));
- FT_TRACE4(( " format: 0x%lX (%s)\n",
- format,
- PCF_BYTE_ORDER( format ) == MSBFirst ? "MSB" : "LSB" ));
-
- if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) &&
- !PCF_FORMAT_MATCH( format, PCF_BDF_ENCODINGS ) )
- return FT_THROW( Invalid_File_Format );
-
- if ( PCF_BYTE_ORDER( format ) == MSBFirst )
- {
- if ( FT_STREAM_READ_FIELDS( pcf_enc_msb_header, enc ) )
- goto Bail;
- }
- else
- {
- if ( FT_STREAM_READ_FIELDS( pcf_enc_header, enc ) )
- goto Bail;
- }
-
- FT_TRACE4(( " firstCol 0x%X, lastCol 0x%X\n",
- enc->firstCol, enc->lastCol ));
- FT_TRACE4(( " firstRow 0x%X, lastRow 0x%X\n",
- enc->firstRow, enc->lastRow ));
- FT_TRACE4(( " defaultChar 0x%X\n",
- enc->defaultChar ));
-
- /* sanity checks; we limit numbers of rows and columns to 256 */
- if ( enc->firstCol > enc->lastCol ||
- enc->lastCol > 0xFF ||
- enc->firstRow > enc->lastRow ||
- enc->lastRow > 0xFF )
- return FT_THROW( Invalid_Table );
-
- FT_TRACE5(( "\n" ));
-
- defaultCharRow = enc->defaultChar >> 8;
- defaultCharCol = enc->defaultChar & 0xFF;
-
- /* validate default character */
- if ( defaultCharRow < enc->firstRow ||
- defaultCharRow > enc->lastRow ||
- defaultCharCol < enc->firstCol ||
- defaultCharCol > enc->lastCol )
- {
- enc->defaultChar = enc->firstRow * 256U + enc->firstCol;
- FT_TRACE0(( "pcf_get_encodings:"
- " Invalid default character set to %u\n",
- enc->defaultChar ));
-
- defaultCharRow = enc->firstRow;
- defaultCharCol = enc->firstCol;
- }
-
- nencoding = (FT_ULong)( enc->lastCol - enc->firstCol + 1 ) *
- (FT_ULong)( enc->lastRow - enc->firstRow + 1 );
-
- error = FT_Stream_EnterFrame( stream, 2 * nencoding );
- if ( error )
- goto Bail;
-
- /*
- * FreeType mandates that glyph index 0 is the `undefined glyph', which
- * PCF calls the `default character'. However, FreeType needs glyph
- * index 0 to be used for the undefined glyph only, which is is not the
- * case for PCF. For this reason, we add one slot for glyph index 0 and
- * simply copy the default character to it.
- *
- * `stream->cursor' still points to the beginning of the frame; we can
- * thus easily get the offset to the default character.
- */
- pos = stream->cursor +
- 2 * ( ( defaultCharRow - enc->firstRow ) *
- ( enc->lastCol - enc->firstCol + 1 ) +
- defaultCharCol - enc->firstCol );
-
- if ( PCF_BYTE_ORDER( format ) == MSBFirst )
- defaultCharEncodingOffset = FT_PEEK_USHORT( pos );
- else
- defaultCharEncodingOffset = FT_PEEK_USHORT_LE( pos );
-
- if ( defaultCharEncodingOffset == 0xFFFF )
- {
- FT_TRACE0(( "pcf_get_encodings:"
- " No glyph for default character,\n" ));
- FT_TRACE0(( " "
- " setting it to the first glyph of the font\n" ));
- defaultCharEncodingOffset = 1;
- }
- else
- {
- defaultCharEncodingOffset++;
-
- if ( defaultCharEncodingOffset >= face->nmetrics )
- {
- FT_TRACE0(( "pcf_get_encodings:"
- " Invalid glyph index for default character,\n" ));
- FT_TRACE0(( " "
- " setting it to the first glyph of the font\n" ));
- defaultCharEncodingOffset = 1;
- }
- }
-
- /* copy metrics of default character to index 0 */
- face->metrics[0] = face->metrics[defaultCharEncodingOffset];
-
- if ( FT_QNEW_ARRAY( enc->offset, nencoding ) )
- goto Bail;
-
- /* now loop over all values */
- offset = enc->offset;
- for ( i = enc->firstRow; i <= enc->lastRow; i++ )
- {
- for ( j = enc->firstCol; j <= enc->lastCol; j++ )
- {
- /* X11's reference implementation uses the equivalent to */
- /* `FT_GET_SHORT', however PCF fonts with more than 32768 */
- /* characters (e.g., `unifont.pcf') clearly show that an */
- /* unsigned value is needed. */
- if ( PCF_BYTE_ORDER( format ) == MSBFirst )
- encodingOffset = FT_GET_USHORT();
- else
- encodingOffset = FT_GET_USHORT_LE();
-
- /* everything is off by 1 due to the artificial glyph 0 */
- *offset++ = encodingOffset == 0xFFFF ? 0xFFFF
- : encodingOffset + 1;
- }
- }
- FT_Stream_ExitFrame( stream );
-
- Bail:
- return error;
- }
-
-
- static
- const FT_Frame_Field pcf_accel_header[] =
- {
-#undef FT_STRUCTURE
-#define FT_STRUCTURE PCF_AccelRec
-
- FT_FRAME_START( 20 ),
- FT_FRAME_BYTE ( noOverlap ),
- FT_FRAME_BYTE ( constantMetrics ),
- FT_FRAME_BYTE ( terminalFont ),
- FT_FRAME_BYTE ( constantWidth ),
- FT_FRAME_BYTE ( inkInside ),
- FT_FRAME_BYTE ( inkMetrics ),
- FT_FRAME_BYTE ( drawDirection ),
- FT_FRAME_SKIP_BYTES( 1 ),
- FT_FRAME_LONG_LE ( fontAscent ),
- FT_FRAME_LONG_LE ( fontDescent ),
- FT_FRAME_LONG_LE ( maxOverlap ),
- FT_FRAME_END
- };
-
-
- static
- const FT_Frame_Field pcf_accel_msb_header[] =
- {
-#undef FT_STRUCTURE
-#define FT_STRUCTURE PCF_AccelRec
-
- FT_FRAME_START( 20 ),
- FT_FRAME_BYTE ( noOverlap ),
- FT_FRAME_BYTE ( constantMetrics ),
- FT_FRAME_BYTE ( terminalFont ),
- FT_FRAME_BYTE ( constantWidth ),
- FT_FRAME_BYTE ( inkInside ),
- FT_FRAME_BYTE ( inkMetrics ),
- FT_FRAME_BYTE ( drawDirection ),
- FT_FRAME_SKIP_BYTES( 1 ),
- FT_FRAME_LONG ( fontAscent ),
- FT_FRAME_LONG ( fontDescent ),
- FT_FRAME_LONG ( maxOverlap ),
- FT_FRAME_END
- };
-
-
- static FT_Error
- pcf_get_accel( FT_Stream stream,
- PCF_Face face,
- FT_ULong type )
- {
- FT_ULong format, size;
- FT_Error error;
- PCF_Accel accel = &face->accel;
-
-
- error = pcf_seek_to_table_type( stream,
- face->toc.tables,
- face->toc.count,
- type,
- &format,
- &size );
- if ( error )
- goto Bail;
-
- if ( FT_READ_ULONG_LE( format ) )
- goto Bail;
-
- FT_TRACE4(( "pcf_get_accel%s:\n",
- type == PCF_BDF_ACCELERATORS ? " (getting BDF accelerators)"
- : "" ));
- FT_TRACE4(( " format: 0x%lX (%s, %s)\n",
- format,
- PCF_BYTE_ORDER( format ) == MSBFirst ? "MSB" : "LSB",
- PCF_FORMAT_MATCH( format, PCF_ACCEL_W_INKBOUNDS ) ?
- "accelerated" : "not accelerated" ));
-
- if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) &&
- !PCF_FORMAT_MATCH( format, PCF_ACCEL_W_INKBOUNDS ) )
- goto Bail;
-
- if ( PCF_BYTE_ORDER( format ) == MSBFirst )
- {
- if ( FT_STREAM_READ_FIELDS( pcf_accel_msb_header, accel ) )
- goto Bail;
- }
- else
- {
- if ( FT_STREAM_READ_FIELDS( pcf_accel_header, accel ) )
- goto Bail;
- }
-
- FT_TRACE5(( " noOverlap=%s, constantMetrics=%s,"
- " terminalFont=%s, constantWidth=%s\n",
- accel->noOverlap ? "yes" : "no",
- accel->constantMetrics ? "yes" : "no",
- accel->terminalFont ? "yes" : "no",
- accel->constantWidth ? "yes" : "no" ));
- FT_TRACE5(( " inkInside=%s, inkMetrics=%s, drawDirection=%s\n",
- accel->inkInside ? "yes" : "no",
- accel->inkMetrics ? "yes" : "no",
- accel->drawDirection ? "RTL" : "LTR" ));
- FT_TRACE5(( " fontAscent=%ld, fontDescent=%ld, maxOverlap=%ld\n",
- accel->fontAscent,
- accel->fontDescent,
- accel->maxOverlap ));
-
- /* sanity checks */
- if ( FT_ABS( accel->fontAscent ) > 0x7FFF )
- {
- accel->fontAscent = accel->fontAscent < 0 ? -0x7FFF : 0x7FFF;
- FT_TRACE0(( "pfc_get_accel: clamping font ascent to value %ld\n",
- accel->fontAscent ));
- }
- if ( FT_ABS( accel->fontDescent ) > 0x7FFF )
- {
- accel->fontDescent = accel->fontDescent < 0 ? -0x7FFF : 0x7FFF;
- FT_TRACE0(( "pfc_get_accel: clamping font descent to value %ld\n",
- accel->fontDescent ));
- }
-
- FT_TRACE5(( " minbounds:" ));
- error = pcf_get_metric( stream,
- format & ( ~PCF_FORMAT_MASK ),
- &(accel->minbounds) );
- if ( error )
- goto Bail;
-
- FT_TRACE5(( " maxbounds:" ));
- error = pcf_get_metric( stream,
- format & ( ~PCF_FORMAT_MASK ),
- &(accel->maxbounds) );
- if ( error )
- goto Bail;
-
- if ( PCF_FORMAT_MATCH( format, PCF_ACCEL_W_INKBOUNDS ) )
- {
- FT_TRACE5(( " ink minbounds:" ));
- error = pcf_get_metric( stream,
- format & ( ~PCF_FORMAT_MASK ),
- &(accel->ink_minbounds) );
- if ( error )
- goto Bail;
-
- FT_TRACE5(( " ink maxbounds:" ));
- error = pcf_get_metric( stream,
- format & ( ~PCF_FORMAT_MASK ),
- &(accel->ink_maxbounds) );
- if ( error )
- goto Bail;
- }
- else
- {
- accel->ink_minbounds = accel->minbounds;
- accel->ink_maxbounds = accel->maxbounds;
- }
-
- Bail:
- return error;
- }
-
-
- static FT_Error
- pcf_interpret_style( PCF_Face pcf )
- {
- FT_Error error = FT_Err_Ok;
- FT_Face face = FT_FACE( pcf );
- FT_Memory memory = face->memory;
-
- PCF_Property prop;
-
- const char* strings[4] = { NULL, NULL, NULL, NULL };
- size_t lengths[4], nn, len;
-
-
- face->style_flags = 0;
-
- prop = pcf_find_property( pcf, "SLANT" );
- if ( prop && prop->isString &&
- ( *(prop->value.atom) == 'O' || *(prop->value.atom) == 'o' ||
- *(prop->value.atom) == 'I' || *(prop->value.atom) == 'i' ) )
- {
- face->style_flags |= FT_STYLE_FLAG_ITALIC;
- strings[2] = ( *(prop->value.atom) == 'O' ||
- *(prop->value.atom) == 'o' ) ? "Oblique"
- : "Italic";
- }
-
- prop = pcf_find_property( pcf, "WEIGHT_NAME" );
- if ( prop && prop->isString &&
- ( *(prop->value.atom) == 'B' || *(prop->value.atom) == 'b' ) )
- {
- face->style_flags |= FT_STYLE_FLAG_BOLD;
- strings[1] = "Bold";
- }
-
- prop = pcf_find_property( pcf, "SETWIDTH_NAME" );
- if ( prop && prop->isString &&
- *(prop->value.atom) &&
- !( *(prop->value.atom) == 'N' || *(prop->value.atom) == 'n' ) )
- strings[3] = (const char*)( prop->value.atom );
-
- prop = pcf_find_property( pcf, "ADD_STYLE_NAME" );
- if ( prop && prop->isString &&
- *(prop->value.atom) &&
- !( *(prop->value.atom) == 'N' || *(prop->value.atom) == 'n' ) )
- strings[0] = (const char*)( prop->value.atom );
-
- for ( len = 0, nn = 0; nn < 4; nn++ )
- {
- lengths[nn] = 0;
- if ( strings[nn] )
- {
- lengths[nn] = ft_strlen( strings[nn] );
- len += lengths[nn] + 1;
- }
- }
-
- if ( len == 0 )
- {
- strings[0] = "Regular";
- lengths[0] = ft_strlen( strings[0] );
- len = lengths[0] + 1;
- }
-
- {
- char* s;
-
-
- if ( FT_QALLOC( face->style_name, len ) )
- return error;
-
- s = face->style_name;
-
- for ( nn = 0; nn < 4; nn++ )
- {
- const char* src = strings[nn];
-
-
- len = lengths[nn];
-
- if ( !src )
- continue;
-
- /* separate elements with a space */
- if ( s != face->style_name )
- *s++ = ' ';
-
- ft_memcpy( s, src, len );
-
- /* need to convert spaces to dashes for */
- /* add_style_name and setwidth_name */
- if ( nn == 0 || nn == 3 )
- {
- size_t mm;
-
-
- for ( mm = 0; mm < len; mm++ )
- if ( s[mm] == ' ' )
- s[mm] = '-';
- }
-
- s += len;
- }
- *s = 0;
- }
-
- return error;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- pcf_load_font( FT_Stream stream,
- PCF_Face face,
- FT_Long face_index )
- {
- FT_Face root = FT_FACE( face );
- FT_Error error;
- FT_Memory memory = FT_FACE( face )->memory;
- FT_Bool hasBDFAccelerators;
-
-
- error = pcf_read_TOC( stream, face );
- if ( error )
- goto Exit;
-
- root->num_faces = 1;
- root->face_index = 0;
-
- /* If we are performing a simple font format check, exit immediately. */
- if ( face_index < 0 )
- return FT_Err_Ok;
-
- error = pcf_get_properties( stream, face );
- if ( error )
- goto Exit;
-
- /* Use the old accelerators if no BDF accelerators are in the file. */
- hasBDFAccelerators = pcf_has_table_type( face->toc.tables,
- face->toc.count,
- PCF_BDF_ACCELERATORS );
- if ( !hasBDFAccelerators )
- {
- error = pcf_get_accel( stream, face, PCF_ACCELERATORS );
- if ( error )
- goto Exit;
- }
-
- /* metrics */
- error = pcf_get_metrics( stream, face );
- if ( error )
- goto Exit;
-
- /* bitmaps */
- error = pcf_get_bitmaps( stream, face );
- if ( error )
- goto Exit;
-
- /* encodings */
- error = pcf_get_encodings( stream, face );
- if ( error )
- goto Exit;
-
- /* BDF style accelerators (i.e. bounds based on encoded glyphs) */
- if ( hasBDFAccelerators )
- {
- error = pcf_get_accel( stream, face, PCF_BDF_ACCELERATORS );
- if ( error )
- goto Exit;
- }
-
- /* XXX: TO DO: inkmetrics and glyph_names are missing */
-
- /* now construct the face object */
- {
- PCF_Property prop;
-
-
- root->face_flags |= FT_FACE_FLAG_FIXED_SIZES |
- FT_FACE_FLAG_HORIZONTAL;
-
- if ( face->accel.constantWidth )
- root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
-
- if ( FT_SET_ERROR( pcf_interpret_style( face ) ) )
- goto Exit;
-
- prop = pcf_find_property( face, "FAMILY_NAME" );
- if ( prop && prop->isString )
- {
-
-#ifdef PCF_CONFIG_OPTION_LONG_FAMILY_NAMES
-
- PCF_Driver driver = (PCF_Driver)FT_FACE_DRIVER( face );
-
-
- if ( !driver->no_long_family_names )
- {
- /* Prepend the foundry name plus a space to the family name. */
- /* There are many fonts just called `Fixed' which look */
- /* completely different, and which have nothing to do with each */
- /* other. When selecting `Fixed' in KDE or Gnome one gets */
- /* results that appear rather random, the style changes often if */
- /* one changes the size and one cannot select some fonts at all. */
- /* */
- /* We also check whether we have `wide' characters; all put */
- /* together, we get family names like `Sony Fixed' or `Misc */
- /* Fixed Wide'. */
-
- PCF_Property foundry_prop, point_size_prop, average_width_prop;
-
- int l = ft_strlen( prop->value.atom ) + 1;
- int wide = 0;
-
-
- foundry_prop = pcf_find_property( face, "FOUNDRY" );
- point_size_prop = pcf_find_property( face, "POINT_SIZE" );
- average_width_prop = pcf_find_property( face, "AVERAGE_WIDTH" );
-
- if ( point_size_prop && average_width_prop )
- {
- if ( average_width_prop->value.l >= point_size_prop->value.l )
- {
- /* This font is at least square shaped or even wider */
- wide = 1;
- l += ft_strlen( " Wide" );
- }
- }
-
- if ( foundry_prop && foundry_prop->isString )
- {
- l += ft_strlen( foundry_prop->value.atom ) + 1;
-
- if ( FT_QALLOC( root->family_name, l ) )
- goto Exit;
-
- ft_strcpy( root->family_name, foundry_prop->value.atom );
- ft_strcat( root->family_name, " " );
- ft_strcat( root->family_name, prop->value.atom );
- }
- else
- {
- if ( FT_QALLOC( root->family_name, l ) )
- goto Exit;
-
- ft_strcpy( root->family_name, prop->value.atom );
- }
-
- if ( wide )
- ft_strcat( root->family_name, " Wide" );
- }
- else
-
-#endif /* PCF_CONFIG_OPTION_LONG_FAMILY_NAMES */
-
- {
- if ( FT_STRDUP( root->family_name, prop->value.atom ) )
- goto Exit;
- }
- }
- else
- root->family_name = NULL;
-
- root->num_glyphs = (FT_Long)face->nmetrics;
-
- root->num_fixed_sizes = 1;
- if ( FT_NEW( root->available_sizes ) )
- goto Exit;
-
- {
- FT_Bitmap_Size* bsize = root->available_sizes;
- FT_Short resolution_x = 0, resolution_y = 0;
-
-
- /* for simplicity, we take absolute values of integer properties */
-
-#if 0
- bsize->height = face->accel.maxbounds.ascent << 6;
-#endif
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( face->accel.fontAscent + face->accel.fontDescent < 0 )
- FT_TRACE0(( "pcf_load_font: negative height\n" ));
-#endif
- if ( FT_ABS( face->accel.fontAscent +
- face->accel.fontDescent ) > 0x7FFF )
- {
- bsize->height = 0x7FFF;
- FT_TRACE0(( "pcf_load_font: clamping height to value %d\n",
- bsize->height ));
- }
- else
- bsize->height = FT_ABS( (FT_Short)( face->accel.fontAscent +
- face->accel.fontDescent ) );
-
- prop = pcf_find_property( face, "AVERAGE_WIDTH" );
- if ( prop )
- {
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( prop->value.l < 0 )
- FT_TRACE0(( "pcf_load_font: negative average width\n" ));
-#endif
- if ( ( FT_ABS( prop->value.l ) > 0x7FFFL * 10 - 5 ) )
- {
- bsize->width = 0x7FFF;
- FT_TRACE0(( "pcf_load_font: clamping average width to value %d\n",
- bsize->width ));
- }
- else
- bsize->width = FT_ABS( (FT_Short)( ( prop->value.l + 5 ) / 10 ) );
- }
- else
- {
- /* this is a heuristical value */
- bsize->width = ( bsize->height * 2 + 1 ) / 3;
- }
-
- prop = pcf_find_property( face, "POINT_SIZE" );
- if ( prop )
- {
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( prop->value.l < 0 )
- FT_TRACE0(( "pcf_load_font: negative point size\n" ));
-#endif
- /* convert from 722.7 decipoints to 72 points per inch */
- if ( FT_ABS( prop->value.l ) > 0x504C2L ) /* 0x7FFF * 72270/7200 */
- {
- bsize->size = 0x7FFF;
- FT_TRACE0(( "pcf_load_font: clamping point size to value %ld\n",
- bsize->size ));
- }
- else
- bsize->size = FT_MulDiv( FT_ABS( prop->value.l ),
- 64 * 7200,
- 72270L );
- }
-
- prop = pcf_find_property( face, "PIXEL_SIZE" );
- if ( prop )
- {
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( prop->value.l < 0 )
- FT_TRACE0(( "pcf_load_font: negative pixel size\n" ));
-#endif
- if ( FT_ABS( prop->value.l ) > 0x7FFF )
- {
- bsize->y_ppem = 0x7FFF << 6;
- FT_TRACE0(( "pcf_load_font: clamping pixel size to value %ld\n",
- bsize->y_ppem ));
- }
- else
- bsize->y_ppem = FT_ABS( (FT_Short)prop->value.l ) << 6;
- }
-
- prop = pcf_find_property( face, "RESOLUTION_X" );
- if ( prop )
- {
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( prop->value.l < 0 )
- FT_TRACE0(( "pcf_load_font: negative X resolution\n" ));
-#endif
- if ( FT_ABS( prop->value.l ) > 0x7FFF )
- {
- resolution_x = 0x7FFF;
- FT_TRACE0(( "pcf_load_font: clamping X resolution to value %d\n",
- resolution_x ));
- }
- else
- resolution_x = FT_ABS( (FT_Short)prop->value.l );
- }
-
- prop = pcf_find_property( face, "RESOLUTION_Y" );
- if ( prop )
- {
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( prop->value.l < 0 )
- FT_TRACE0(( "pcf_load_font: negative Y resolution\n" ));
-#endif
- if ( FT_ABS( prop->value.l ) > 0x7FFF )
- {
- resolution_y = 0x7FFF;
- FT_TRACE0(( "pcf_load_font: clamping Y resolution to value %d\n",
- resolution_y ));
- }
- else
- resolution_y = FT_ABS( (FT_Short)prop->value.l );
- }
-
- if ( bsize->y_ppem == 0 )
- {
- bsize->y_ppem = bsize->size;
- if ( resolution_y )
- bsize->y_ppem = FT_MulDiv( bsize->y_ppem, resolution_y, 72 );
- }
- if ( resolution_x && resolution_y )
- bsize->x_ppem = FT_MulDiv( bsize->y_ppem,
- resolution_x,
- resolution_y );
- else
- bsize->x_ppem = bsize->y_ppem;
- }
-
- /* set up charset */
- {
- PCF_Property charset_registry, charset_encoding;
-
-
- charset_registry = pcf_find_property( face, "CHARSET_REGISTRY" );
- charset_encoding = pcf_find_property( face, "CHARSET_ENCODING" );
-
- if ( charset_registry && charset_registry->isString &&
- charset_encoding && charset_encoding->isString )
- {
- if ( FT_STRDUP( face->charset_encoding,
- charset_encoding->value.atom ) ||
- FT_STRDUP( face->charset_registry,
- charset_registry->value.atom ) )
- goto Exit;
- }
- }
- }
-
- Exit:
- if ( error )
- {
- /* This is done to respect the behaviour of the original */
- /* PCF font driver. */
- error = FT_THROW( Invalid_File_Format );
- }
-
- return error;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/pcf/pcfread.h b/contrib/libs/freetype/src/pcf/pcfread.h
deleted file mode 100644
index a54648fbf9..0000000000
--- a/contrib/libs/freetype/src/pcf/pcfread.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* pcfread.h
-
- FreeType font driver for pcf fonts
-
- Copyright 2003 by
- Francesco Zappa Nardelli
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-*/
-
-
-#ifndef PCFREAD_H_
-#define PCFREAD_H_
-
-
-
-FT_BEGIN_HEADER
-
- FT_LOCAL( PCF_Property )
- pcf_find_property( PCF_Face face,
- const FT_String* prop );
-
-FT_END_HEADER
-
-#endif /* PCFREAD_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/pcf/pcfutil.c b/contrib/libs/freetype/src/pcf/pcfutil.c
deleted file mode 100644
index cd26c77cad..0000000000
--- a/contrib/libs/freetype/src/pcf/pcfutil.c
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
-
-Copyright 1990, 1994, 1998 The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-*/
-/* $XFree86: xc/lib/font/util/utilbitmap.c,v 1.3 1999/08/22 08:58:58 dawes Exp $ */
-
-/*
- * Author: Keith Packard, MIT X Consortium
- */
-
-/* Modified for use with FreeType */
-
-
-#include "pcfutil.h"
-
-
- /*
- * Invert bit order within each BYTE of an array.
- */
-
- FT_LOCAL_DEF( void )
- BitOrderInvert( unsigned char* buf,
- size_t nbytes )
- {
- for ( ; nbytes > 0; nbytes--, buf++ )
- {
- unsigned int val = *buf;
-
-
- val = ( ( val >> 1 ) & 0x55 ) | ( ( val << 1 ) & 0xAA );
- val = ( ( val >> 2 ) & 0x33 ) | ( ( val << 2 ) & 0xCC );
- val = ( ( val >> 4 ) & 0x0F ) | ( ( val << 4 ) & 0xF0 );
-
- *buf = (unsigned char)val;
- }
- }
-
-
-#if ( defined( __clang_major__ ) && __clang_major__ >= 5 ) || \
- ( defined( __GNUC__ ) && \
- ( __GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 8 ) ) )
-
-#define BSWAP16( x ) __builtin_bswap16( x )
-#define BSWAP32( x ) __builtin_bswap32( x )
-
-#elif defined( _MSC_VER ) && _MSC_VER >= 1300
-
-#pragma intrinsic( _byteswap_ushort )
-#pragma intrinsic( _byteswap_ulong )
-
-#define BSWAP16( x ) _byteswap_ushort( x )
-#define BSWAP32( x ) _byteswap_ulong( x )
-
-#else
-
-#define BSWAP16( x ) \
- (FT_UInt16)( ( ( ( x ) >> 8 ) & 0xff ) | \
- ( ( ( x ) & 0xff ) << 8 ) )
-#define BSWAP32( x ) \
- (FT_UInt32)( ( ( ( x ) & 0xff000000u ) >> 24 ) | \
- ( ( ( x ) & 0x00ff0000u ) >> 8 ) | \
- ( ( ( x ) & 0x0000ff00u ) << 8 ) | \
- ( ( ( x ) & 0x000000ffu ) << 24 ) )
-
-#endif
-
- /*
- * Invert byte order within each 16-bits of an array.
- */
-
- FT_LOCAL_DEF( void )
- TwoByteSwap( unsigned char* buf,
- size_t nbytes )
- {
- FT_UInt16* b = (FT_UInt16*)buf;
-
-
- for ( ; nbytes >= 2; nbytes -= 2, b++ )
- *b = BSWAP16( *b );
- }
-
- /*
- * Invert byte order within each 32-bits of an array.
- */
-
- FT_LOCAL_DEF( void )
- FourByteSwap( unsigned char* buf,
- size_t nbytes )
- {
- FT_UInt32* b = (FT_UInt32*)buf;
-
-
- for ( ; nbytes >= 4; nbytes -= 4, b++ )
- *b = BSWAP32( *b );
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/pcf/pcfutil.h b/contrib/libs/freetype/src/pcf/pcfutil.h
deleted file mode 100644
index a197c15595..0000000000
--- a/contrib/libs/freetype/src/pcf/pcfutil.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* pcfutil.h
-
- FreeType font driver for pcf fonts
-
- Copyright 2000, 2001, 2004 by
- Francesco Zappa Nardelli
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-*/
-
-
-#ifndef PCFUTIL_H_
-#define PCFUTIL_H_
-
-
-#include <ft2build.h>
-#include FT_CONFIG_CONFIG_H
-#include <freetype/internal/compiler-macros.h>
-
-FT_BEGIN_HEADER
-
- FT_LOCAL( void )
- BitOrderInvert( unsigned char* buf,
- size_t nbytes );
-
- FT_LOCAL( void )
- TwoByteSwap( unsigned char* buf,
- size_t nbytes );
-
- FT_LOCAL( void )
- FourByteSwap( unsigned char* buf,
- size_t nbytes );
-
-FT_END_HEADER
-
-#endif /* PCFUTIL_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/pfr/pfr.c b/contrib/libs/freetype/src/pfr/pfr.c
deleted file mode 100644
index 71b57930b3..0000000000
--- a/contrib/libs/freetype/src/pfr/pfr.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/****************************************************************************
- *
- * pfr.c
- *
- * FreeType PFR driver component.
- *
- * Copyright (C) 2002-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#define FT_MAKE_OPTION_SINGLE_OBJECT
-
-#include "pfrcmap.c"
-#include "pfrdrivr.c"
-#include "pfrgload.c"
-#include "pfrload.c"
-#include "pfrobjs.c"
-#include "pfrsbit.c"
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/pfr/pfrcmap.c b/contrib/libs/freetype/src/pfr/pfrcmap.c
deleted file mode 100644
index cd701661f1..0000000000
--- a/contrib/libs/freetype/src/pfr/pfrcmap.c
+++ /dev/null
@@ -1,188 +0,0 @@
-/****************************************************************************
- *
- * pfrcmap.c
- *
- * FreeType PFR cmap handling (body).
- *
- * Copyright (C) 2002-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftdebug.h>
-#include "pfrcmap.h"
-#include "pfrobjs.h"
-
-#include "pfrerror.h"
-
-
- FT_CALLBACK_DEF( FT_Error )
- pfr_cmap_init( FT_CMap cmap, /* PFR_CMap */
- FT_Pointer pointer )
- {
- PFR_CMap pfrcmap = (PFR_CMap)cmap;
- FT_Error error = FT_Err_Ok;
- PFR_Face face = (PFR_Face)FT_CMAP_FACE( cmap );
-
- FT_UNUSED( pointer );
-
-
- pfrcmap->num_chars = face->phy_font.num_chars;
- pfrcmap->chars = face->phy_font.chars;
-
- /* just for safety, check that the character entries are correctly */
- /* sorted in increasing character code order */
- {
- FT_UInt n;
-
-
- for ( n = 1; n < pfrcmap->num_chars; n++ )
- {
- if ( pfrcmap->chars[n - 1].char_code >= pfrcmap->chars[n].char_code )
- {
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
- }
- }
-
- Exit:
- return error;
- }
-
-
- FT_CALLBACK_DEF( void )
- pfr_cmap_done( FT_CMap cmap ) /* PFR_CMap */
- {
- PFR_CMap pfrcmap = (PFR_CMap)cmap;
-
-
- pfrcmap->chars = NULL;
- pfrcmap->num_chars = 0;
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- pfr_cmap_char_index( FT_CMap cmap, /* PFR_CMap */
- FT_UInt32 char_code )
- {
- PFR_CMap pfrcmap = (PFR_CMap)cmap;
- FT_UInt min = 0;
- FT_UInt max = pfrcmap->num_chars;
- FT_UInt mid = min + ( max - min ) / 2;
- PFR_Char gchar;
-
-
- while ( min < max )
- {
- gchar = pfrcmap->chars + mid;
-
- if ( gchar->char_code == char_code )
- return mid + 1;
-
- if ( gchar->char_code < char_code )
- min = mid + 1;
- else
- max = mid;
-
- /* reasonable prediction in a continuous block */
- mid += char_code - gchar->char_code;
- if ( mid >= max || mid < min )
- mid = min + ( max - min ) / 2;
- }
- return 0;
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- pfr_cmap_char_next( FT_CMap cmap, /* PFR_CMap */
- FT_UInt32 *pchar_code )
- {
- PFR_CMap pfrcmap = (PFR_CMap)cmap;
- FT_UInt result = 0;
- FT_UInt32 char_code = *pchar_code + 1;
-
-
- Restart:
- {
- FT_UInt min = 0;
- FT_UInt max = pfrcmap->num_chars;
- FT_UInt mid = min + ( max - min ) / 2;
- PFR_Char gchar;
-
-
- while ( min < max )
- {
- gchar = pfrcmap->chars + mid;
-
- if ( gchar->char_code == char_code )
- {
- result = mid;
- if ( result != 0 )
- {
- result++;
- goto Exit;
- }
-
- char_code++;
- goto Restart;
- }
-
- if ( gchar->char_code < char_code )
- min = mid + 1;
- else
- max = mid;
-
- /* reasonable prediction in a continuous block */
- mid += char_code - gchar->char_code;
- if ( mid >= max || mid < min )
- mid = min + ( max - min ) / 2;
- }
-
- /* we didn't find it, but we have a pair just above it */
- char_code = 0;
-
- if ( min < pfrcmap->num_chars )
- {
- gchar = pfrcmap->chars + min;
- result = min;
- if ( result != 0 )
- {
- result++;
- char_code = gchar->char_code;
- }
- }
- }
-
- Exit:
- *pchar_code = char_code;
- return result;
- }
-
-
- FT_CALLBACK_TABLE_DEF const FT_CMap_ClassRec
- pfr_cmap_class_rec =
- {
- sizeof ( PFR_CMapRec ),
-
- (FT_CMap_InitFunc) pfr_cmap_init, /* init */
- (FT_CMap_DoneFunc) pfr_cmap_done, /* done */
- (FT_CMap_CharIndexFunc)pfr_cmap_char_index, /* char_index */
- (FT_CMap_CharNextFunc) pfr_cmap_char_next, /* char_next */
-
- (FT_CMap_CharVarIndexFunc) NULL, /* char_var_index */
- (FT_CMap_CharVarIsDefaultFunc)NULL, /* char_var_default */
- (FT_CMap_VariantListFunc) NULL, /* variant_list */
- (FT_CMap_CharVariantListFunc) NULL, /* charvariant_list */
- (FT_CMap_VariantCharListFunc) NULL /* variantchar_list */
- };
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/pfr/pfrcmap.h b/contrib/libs/freetype/src/pfr/pfrcmap.h
deleted file mode 100644
index ab7913575d..0000000000
--- a/contrib/libs/freetype/src/pfr/pfrcmap.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/****************************************************************************
- *
- * pfrcmap.h
- *
- * FreeType PFR cmap handling (specification).
- *
- * Copyright (C) 2002-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef PFRCMAP_H_
-#define PFRCMAP_H_
-
-#include <freetype/internal/ftobjs.h>
-#include "pfrtypes.h"
-
-
-FT_BEGIN_HEADER
-
- typedef struct PFR_CMapRec_
- {
- FT_CMapRec cmap;
- FT_UInt num_chars;
- PFR_Char chars;
-
- } PFR_CMapRec, *PFR_CMap;
-
-
- FT_CALLBACK_TABLE const FT_CMap_ClassRec pfr_cmap_class_rec;
-
-FT_END_HEADER
-
-
-#endif /* PFRCMAP_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/pfr/pfrdrivr.c b/contrib/libs/freetype/src/pfr/pfrdrivr.c
deleted file mode 100644
index ffd822273f..0000000000
--- a/contrib/libs/freetype/src/pfr/pfrdrivr.c
+++ /dev/null
@@ -1,212 +0,0 @@
-/****************************************************************************
- *
- * pfrdrivr.c
- *
- * FreeType PFR driver interface (body).
- *
- * Copyright (C) 2002-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/internal/services/svpfr.h>
-#include <freetype/internal/services/svfntfmt.h>
-#include "pfrdrivr.h"
-#include "pfrobjs.h"
-
-#include "pfrerror.h"
-
-
- FT_CALLBACK_DEF( FT_Error )
- pfr_get_kerning( FT_Face face, /* PFR_Face */
- FT_UInt left,
- FT_UInt right,
- FT_Vector *avector )
- {
- PFR_Face pfrface = (PFR_Face)face;
- PFR_PhyFont phys = &pfrface->phy_font;
-
-
- (void)pfr_face_get_kerning( face, left, right, avector );
-
- /* convert from metrics to outline units when necessary */
- if ( phys->outline_resolution != phys->metrics_resolution )
- {
- if ( avector->x != 0 )
- avector->x = FT_MulDiv( avector->x,
- (FT_Long)phys->outline_resolution,
- (FT_Long)phys->metrics_resolution );
-
- if ( avector->y != 0 )
- avector->y = FT_MulDiv( avector->y,
- (FT_Long)phys->outline_resolution,
- (FT_Long)phys->metrics_resolution );
- }
-
- return FT_Err_Ok;
- }
-
-
- /*
- * PFR METRICS SERVICE
- *
- */
-
- FT_CALLBACK_DEF( FT_Error )
- pfr_get_advance( FT_Face face, /* PFR_Face */
- FT_UInt gindex,
- FT_Pos *anadvance )
- {
- PFR_Face pfrface = (PFR_Face)face;
- FT_Error error = FT_ERR( Invalid_Argument );
-
-
- *anadvance = 0;
-
- if ( !gindex )
- goto Exit;
-
- gindex--;
-
- if ( pfrface )
- {
- PFR_PhyFont phys = &pfrface->phy_font;
-
-
- if ( gindex < phys->num_chars )
- {
- *anadvance = phys->chars[gindex].advance;
- error = FT_Err_Ok;
- }
- }
-
- Exit:
- return error;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- pfr_get_metrics( FT_Face face, /* PFR_Face */
- FT_UInt *anoutline_resolution,
- FT_UInt *ametrics_resolution,
- FT_Fixed *ametrics_x_scale,
- FT_Fixed *ametrics_y_scale )
- {
- PFR_Face pfrface = (PFR_Face)face;
- PFR_PhyFont phys = &pfrface->phy_font;
- FT_Fixed x_scale, y_scale;
- FT_Size size = pfrface->root.size;
-
-
- if ( anoutline_resolution )
- *anoutline_resolution = phys->outline_resolution;
-
- if ( ametrics_resolution )
- *ametrics_resolution = phys->metrics_resolution;
-
- x_scale = 0x10000L;
- y_scale = 0x10000L;
-
- if ( size )
- {
- x_scale = FT_DivFix( size->metrics.x_ppem << 6,
- (FT_Long)phys->metrics_resolution );
-
- y_scale = FT_DivFix( size->metrics.y_ppem << 6,
- (FT_Long)phys->metrics_resolution );
- }
-
- if ( ametrics_x_scale )
- *ametrics_x_scale = x_scale;
-
- if ( ametrics_y_scale )
- *ametrics_y_scale = y_scale;
-
- return FT_Err_Ok;
- }
-
-
- static
- const FT_Service_PfrMetricsRec pfr_metrics_service_rec =
- {
- pfr_get_metrics, /* get_metrics */
- pfr_face_get_kerning, /* get_kerning */
- pfr_get_advance /* get_advance */
- };
-
-
- /*
- * SERVICE LIST
- *
- */
-
- static const FT_ServiceDescRec pfr_services[] =
- {
- { FT_SERVICE_ID_PFR_METRICS, &pfr_metrics_service_rec },
- { FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_PFR },
- { NULL, NULL }
- };
-
-
- FT_CALLBACK_DEF( FT_Module_Interface )
- pfr_get_service( FT_Module module,
- const FT_String* service_id )
- {
- FT_UNUSED( module );
-
- return ft_service_list_lookup( pfr_services, service_id );
- }
-
-
- FT_CALLBACK_TABLE_DEF
- const FT_Driver_ClassRec pfr_driver_class =
- {
- {
- FT_MODULE_FONT_DRIVER |
- FT_MODULE_DRIVER_SCALABLE,
-
- sizeof ( FT_DriverRec ),
-
- "pfr",
- 0x10000L,
- 0x20000L,
-
- NULL, /* module-specific interface */
-
- NULL, /* FT_Module_Constructor module_init */
- NULL, /* FT_Module_Destructor module_done */
- pfr_get_service /* FT_Module_Requester get_interface */
- },
-
- sizeof ( PFR_FaceRec ),
- sizeof ( PFR_SizeRec ),
- sizeof ( PFR_SlotRec ),
-
- pfr_face_init, /* FT_Face_InitFunc init_face */
- pfr_face_done, /* FT_Face_DoneFunc done_face */
- NULL, /* FT_Size_InitFunc init_size */
- NULL, /* FT_Size_DoneFunc done_size */
- pfr_slot_init, /* FT_Slot_InitFunc init_slot */
- pfr_slot_done, /* FT_Slot_DoneFunc done_slot */
-
- pfr_slot_load, /* FT_Slot_LoadFunc load_glyph */
-
- pfr_get_kerning, /* FT_Face_GetKerningFunc get_kerning */
- NULL, /* FT_Face_AttachFunc attach_file */
- NULL, /* FT_Face_GetAdvancesFunc get_advances */
-
- NULL, /* FT_Size_RequestFunc request_size */
- NULL, /* FT_Size_SelectFunc select_size */
- };
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/pfr/pfrdrivr.h b/contrib/libs/freetype/src/pfr/pfrdrivr.h
deleted file mode 100644
index 58954a9af0..0000000000
--- a/contrib/libs/freetype/src/pfr/pfrdrivr.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/****************************************************************************
- *
- * pfrdrivr.h
- *
- * High-level Type PFR driver interface (specification).
- *
- * Copyright (C) 2002-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef PFRDRIVR_H_
-#define PFRDRIVR_H_
-
-
-#include <freetype/internal/ftdrv.h>
-
-
-FT_BEGIN_HEADER
-
- FT_EXPORT_VAR( const FT_Driver_ClassRec ) pfr_driver_class;
-
-FT_END_HEADER
-
-
-#endif /* PFRDRIVR_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/pfr/pfrerror.h b/contrib/libs/freetype/src/pfr/pfrerror.h
deleted file mode 100644
index af0ddaf184..0000000000
--- a/contrib/libs/freetype/src/pfr/pfrerror.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/****************************************************************************
- *
- * pfrerror.h
- *
- * PFR error codes (specification only).
- *
- * Copyright (C) 2002-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /**************************************************************************
- *
- * This file is used to define the PFR error enumeration constants.
- *
- */
-
-#ifndef PFRERROR_H_
-#define PFRERROR_H_
-
-#include <freetype/ftmoderr.h>
-
-#undef FTERRORS_H_
-
-#undef FT_ERR_PREFIX
-#define FT_ERR_PREFIX PFR_Err_
-#define FT_ERR_BASE FT_Mod_Err_PFR
-
-#include <freetype/fterrors.h>
-
-#endif /* PFRERROR_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/pfr/pfrgload.c b/contrib/libs/freetype/src/pfr/pfrgload.c
deleted file mode 100644
index e850075527..0000000000
--- a/contrib/libs/freetype/src/pfr/pfrgload.c
+++ /dev/null
@@ -1,849 +0,0 @@
-/****************************************************************************
- *
- * pfrgload.c
- *
- * FreeType PFR glyph loader (body).
- *
- * Copyright (C) 2002-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include "pfrgload.h"
-#include "pfrsbit.h"
-#include "pfrload.h" /* for macro definitions */
-#include <freetype/internal/ftdebug.h>
-
-#include "pfrerror.h"
-
-#undef FT_COMPONENT
-#define FT_COMPONENT pfr
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** PFR GLYPH BUILDER *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- FT_LOCAL_DEF( void )
- pfr_glyph_init( PFR_Glyph glyph,
- FT_GlyphLoader loader )
- {
- FT_ZERO( glyph );
-
- glyph->loader = loader;
-
- FT_GlyphLoader_Rewind( loader );
- }
-
-
- FT_LOCAL_DEF( void )
- pfr_glyph_done( PFR_Glyph glyph )
- {
- FT_Memory memory = glyph->loader->memory;
-
-
- FT_FREE( glyph->x_control );
- glyph->y_control = NULL;
-
- glyph->max_xy_control = 0;
-#if 0
- glyph->num_x_control = 0;
- glyph->num_y_control = 0;
-#endif
-
- FT_FREE( glyph->subs );
-
- glyph->max_subs = 0;
- glyph->num_subs = 0;
-
- glyph->loader = NULL;
- glyph->path_begun = 0;
- }
-
-
- /* close current contour, if any */
- static void
- pfr_glyph_close_contour( PFR_Glyph glyph )
- {
- FT_GlyphLoader loader = glyph->loader;
- FT_Outline* outline = &loader->current.outline;
- FT_Int last, first;
-
-
- if ( !glyph->path_begun )
- return;
-
- /* compute first and last point indices in current glyph outline */
- last = outline->n_points - 1;
- first = 0;
- if ( outline->n_contours > 0 )
- first = outline->contours[outline->n_contours - 1];
-
- /* if the last point falls on the same location as the first one */
- /* we need to delete it */
- if ( last > first )
- {
- FT_Vector* p1 = outline->points + first;
- FT_Vector* p2 = outline->points + last;
-
-
- if ( p1->x == p2->x && p1->y == p2->y )
- {
- outline->n_points--;
- last--;
- }
- }
-
- /* don't add empty contours */
- if ( last >= first )
- outline->contours[outline->n_contours++] = (FT_UShort)last;
-
- glyph->path_begun = 0;
- }
-
-
- /* reset glyph to start the loading of a new glyph */
- static void
- pfr_glyph_start( PFR_Glyph glyph )
- {
- glyph->path_begun = 0;
- }
-
-
- static FT_Error
- pfr_glyph_line_to( PFR_Glyph glyph,
- FT_Vector* to )
- {
- FT_GlyphLoader loader = glyph->loader;
- FT_Outline* outline = &loader->current.outline;
- FT_Error error;
-
-
- /* check that we have begun a new path */
- if ( !glyph->path_begun )
- {
- error = FT_THROW( Invalid_Table );
- FT_ERROR(( "pfr_glyph_line_to: invalid glyph data\n" ));
- goto Exit;
- }
-
- error = FT_GLYPHLOADER_CHECK_POINTS( loader, 1, 0 );
- if ( !error )
- {
- FT_Int n = outline->n_points;
-
-
- outline->points[n] = *to;
- outline->tags [n] = FT_CURVE_TAG_ON;
-
- outline->n_points++;
- }
-
- Exit:
- return error;
- }
-
-
- static FT_Error
- pfr_glyph_curve_to( PFR_Glyph glyph,
- FT_Vector* control1,
- FT_Vector* control2,
- FT_Vector* to )
- {
- FT_GlyphLoader loader = glyph->loader;
- FT_Outline* outline = &loader->current.outline;
- FT_Error error;
-
-
- /* check that we have begun a new path */
- if ( !glyph->path_begun )
- {
- error = FT_THROW( Invalid_Table );
- FT_ERROR(( "pfr_glyph_line_to: invalid glyph data\n" ));
- goto Exit;
- }
-
- error = FT_GLYPHLOADER_CHECK_POINTS( loader, 3, 0 );
- if ( !error )
- {
- FT_Vector* vec = outline->points + outline->n_points;
- FT_Byte* tag = outline->tags + outline->n_points;
-
-
- vec[0] = *control1;
- vec[1] = *control2;
- vec[2] = *to;
- tag[0] = FT_CURVE_TAG_CUBIC;
- tag[1] = FT_CURVE_TAG_CUBIC;
- tag[2] = FT_CURVE_TAG_ON;
-
- outline->n_points += 3;
- }
-
- Exit:
- return error;
- }
-
-
- static FT_Error
- pfr_glyph_move_to( PFR_Glyph glyph,
- FT_Vector* to )
- {
- FT_GlyphLoader loader = glyph->loader;
- FT_Error error;
-
-
- /* close current contour if any */
- pfr_glyph_close_contour( glyph );
-
- /* indicate that a new contour has started */
- glyph->path_begun = 1;
-
- /* check that there is space for a new contour and a new point */
- error = FT_GLYPHLOADER_CHECK_POINTS( loader, 1, 1 );
- if ( !error )
- {
- /* add new start point */
- error = pfr_glyph_line_to( glyph, to );
- }
-
- return error;
- }
-
-
- static void
- pfr_glyph_end( PFR_Glyph glyph )
- {
- /* close current contour if any */
- pfr_glyph_close_contour( glyph );
-
- /* merge the current glyph into the stack */
- FT_GlyphLoader_Add( glyph->loader );
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** PFR GLYPH LOADER *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /* load a simple glyph */
- static FT_Error
- pfr_glyph_load_simple( PFR_Glyph glyph,
- FT_Byte* p,
- FT_Byte* limit )
- {
- FT_Error error = FT_Err_Ok;
- FT_Memory memory = glyph->loader->memory;
- FT_UInt flags, x_count, y_count, i, count, mask;
- FT_Int x;
-
-
- PFR_CHECK( 1 );
- flags = PFR_NEXT_BYTE( p );
-
- /* test for composite glyphs */
- if ( flags & PFR_GLYPH_IS_COMPOUND )
- goto Failure;
-
- x_count = 0;
- y_count = 0;
-
- if ( flags & PFR_GLYPH_1BYTE_XYCOUNT )
- {
- PFR_CHECK( 1 );
- count = PFR_NEXT_BYTE( p );
- x_count = count & 15;
- y_count = count >> 4;
- }
- else
- {
- if ( flags & PFR_GLYPH_XCOUNT )
- {
- PFR_CHECK( 1 );
- x_count = PFR_NEXT_BYTE( p );
- }
-
- if ( flags & PFR_GLYPH_YCOUNT )
- {
- PFR_CHECK( 1 );
- y_count = PFR_NEXT_BYTE( p );
- }
- }
-
- count = x_count + y_count;
-
- /* re-allocate array when necessary */
- if ( count > glyph->max_xy_control )
- {
- FT_UInt new_max = FT_PAD_CEIL( count, 8 );
-
-
- if ( FT_RENEW_ARRAY( glyph->x_control,
- glyph->max_xy_control,
- new_max ) )
- goto Exit;
-
- glyph->max_xy_control = new_max;
- }
-
- glyph->y_control = glyph->x_control + x_count;
-
- mask = 0;
- x = 0;
-
- for ( i = 0; i < count; i++ )
- {
- if ( ( i & 7 ) == 0 )
- {
- PFR_CHECK( 1 );
- mask = PFR_NEXT_BYTE( p );
- }
-
- if ( mask & 1 )
- {
- PFR_CHECK( 2 );
- x = PFR_NEXT_SHORT( p );
- }
- else
- {
- PFR_CHECK( 1 );
- x += PFR_NEXT_BYTE( p );
- }
-
- glyph->x_control[i] = x;
-
- mask >>= 1;
- }
-
- /* XXX: we ignore the secondary stroke and edge definitions */
- /* since we don't support native PFR hinting */
- /* */
- if ( flags & PFR_GLYPH_SINGLE_EXTRA_ITEMS )
- {
- error = pfr_extra_items_skip( &p, limit );
- if ( error )
- goto Exit;
- }
-
- pfr_glyph_start( glyph );
-
- /* now load a simple glyph */
- {
- FT_Vector pos[4];
- FT_Vector* cur;
-
-
- pos[0].x = pos[0].y = 0;
- pos[3] = pos[0];
-
- for (;;)
- {
- FT_UInt format, format_low, args_format = 0, args_count, n;
-
-
- /****************************************************************
- * read instruction
- */
- PFR_CHECK( 1 );
- format = PFR_NEXT_BYTE( p );
- format_low = format & 15;
-
- switch ( format >> 4 )
- {
- case 0: /* end glyph */
- FT_TRACE6(( "- end glyph" ));
- args_count = 0;
- break;
-
- case 1: /* general line operation */
- FT_TRACE6(( "- general line" ));
- goto Line1;
-
- case 4: /* move to inside contour */
- FT_TRACE6(( "- move to inside" ));
- goto Line1;
-
- case 5: /* move to outside contour */
- FT_TRACE6(( "- move to outside" ));
- Line1:
- args_format = format_low;
- args_count = 1;
- break;
-
- case 2: /* horizontal line to */
- FT_TRACE6(( "- horizontal line to cx.%d", format_low ));
- if ( format_low >= x_count )
- goto Failure;
- pos[0].x = glyph->x_control[format_low];
- pos[0].y = pos[3].y;
- pos[3] = pos[0];
- args_count = 0;
- break;
-
- case 3: /* vertical line to */
- FT_TRACE6(( "- vertical line to cy.%d", format_low ));
- if ( format_low >= y_count )
- goto Failure;
- pos[0].x = pos[3].x;
- pos[0].y = glyph->y_control[format_low];
- pos[3] = pos[0];
- args_count = 0;
- break;
-
- case 6: /* horizontal to vertical curve */
- FT_TRACE6(( "- hv curve" ));
- args_format = 0xB8E;
- args_count = 3;
- break;
-
- case 7: /* vertical to horizontal curve */
- FT_TRACE6(( "- vh curve" ));
- args_format = 0xE2B;
- args_count = 3;
- break;
-
- default: /* general curve to */
- FT_TRACE6(( "- general curve" ));
- args_count = 4;
- args_format = format_low;
- }
-
- /************************************************************
- * now read arguments
- */
- cur = pos;
- for ( n = 0; n < args_count; n++ )
- {
- FT_UInt idx;
- FT_Int delta;
-
-
- /* read the X argument */
- switch ( args_format & 3 )
- {
- case 0: /* 8-bit index */
- PFR_CHECK( 1 );
- idx = PFR_NEXT_BYTE( p );
- if ( idx >= x_count )
- goto Failure;
- cur->x = glyph->x_control[idx];
- FT_TRACE7(( " cx#%d", idx ));
- break;
-
- case 1: /* 16-bit absolute value */
- PFR_CHECK( 2 );
- cur->x = PFR_NEXT_SHORT( p );
- FT_TRACE7(( " x.%ld", cur->x ));
- break;
-
- case 2: /* 8-bit delta */
- PFR_CHECK( 1 );
- delta = PFR_NEXT_INT8( p );
- cur->x = pos[3].x + delta;
- FT_TRACE7(( " dx.%d", delta ));
- break;
-
- default:
- FT_TRACE7(( " |" ));
- cur->x = pos[3].x;
- }
-
- /* read the Y argument */
- switch ( ( args_format >> 2 ) & 3 )
- {
- case 0: /* 8-bit index */
- PFR_CHECK( 1 );
- idx = PFR_NEXT_BYTE( p );
- if ( idx >= y_count )
- goto Failure;
- cur->y = glyph->y_control[idx];
- FT_TRACE7(( " cy#%d", idx ));
- break;
-
- case 1: /* 16-bit absolute value */
- PFR_CHECK( 2 );
- cur->y = PFR_NEXT_SHORT( p );
- FT_TRACE7(( " y.%ld", cur->y ));
- break;
-
- case 2: /* 8-bit delta */
- PFR_CHECK( 1 );
- delta = PFR_NEXT_INT8( p );
- cur->y = pos[3].y + delta;
- FT_TRACE7(( " dy.%d", delta ));
- break;
-
- default:
- FT_TRACE7(( " -" ));
- cur->y = pos[3].y;
- }
-
- /* read the additional format flag for the general curve */
- if ( n == 0 && args_count == 4 )
- {
- PFR_CHECK( 1 );
- args_format = PFR_NEXT_BYTE( p );
- args_count--;
- }
- else
- args_format >>= 4;
-
- /* save the previous point */
- pos[3] = cur[0];
- cur++;
- }
-
- FT_TRACE7(( "\n" ));
-
- /************************************************************
- * finally, execute instruction
- */
- switch ( format >> 4 )
- {
- case 0: /* end glyph => EXIT */
- pfr_glyph_end( glyph );
- goto Exit;
-
- case 1: /* line operations */
- case 2:
- case 3:
- error = pfr_glyph_line_to( glyph, pos );
- goto Test_Error;
-
- case 4: /* move to inside contour */
- case 5: /* move to outside contour */
- error = pfr_glyph_move_to( glyph, pos );
- goto Test_Error;
-
- default: /* curve operations */
- error = pfr_glyph_curve_to( glyph, pos, pos + 1, pos + 2 );
-
- Test_Error: /* test error condition */
- if ( error )
- goto Exit;
- }
- } /* for (;;) */
- }
-
- Exit:
- return error;
-
- Failure:
- Too_Short:
- error = FT_THROW( Invalid_Table );
- FT_ERROR(( "pfr_glyph_load_simple: invalid glyph data\n" ));
- goto Exit;
- }
-
-
- /* load a composite/compound glyph */
- static FT_Error
- pfr_glyph_load_compound( PFR_Glyph glyph,
- FT_Byte* p,
- FT_Byte* limit )
- {
- FT_Error error = FT_Err_Ok;
- FT_Memory memory = glyph->loader->memory;
- PFR_SubGlyph subglyph;
- FT_UInt flags, i, count, org_count;
- FT_Int x_pos, y_pos;
-
-
- PFR_CHECK( 1 );
- flags = PFR_NEXT_BYTE( p );
-
- /* test for composite glyphs */
- if ( !( flags & PFR_GLYPH_IS_COMPOUND ) )
- goto Failure;
-
- count = flags & 0x3F;
-
- /* ignore extra items when present */
- /* */
- if ( flags & PFR_GLYPH_COMPOUND_EXTRA_ITEMS )
- {
- error = pfr_extra_items_skip( &p, limit );
- if ( error )
- goto Exit;
- }
-
- /* we can't rely on the FT_GlyphLoader to load sub-glyphs, because */
- /* the PFR format is dumb, using direct file offsets to point to the */
- /* sub-glyphs (instead of glyph indices). Sigh. */
- /* */
- /* For now, we load the list of sub-glyphs into a different array */
- /* but this will prevent us from using the auto-hinter at its best */
- /* quality. */
- /* */
- org_count = glyph->num_subs;
-
- if ( org_count + count > glyph->max_subs )
- {
- FT_UInt new_max = ( org_count + count + 3 ) & (FT_UInt)-4;
-
-
- /* we arbitrarily limit the number of subglyphs */
- /* to avoid endless recursion */
- if ( new_max > 64 )
- {
- error = FT_THROW( Invalid_Table );
- FT_ERROR(( "pfr_glyph_load_compound:"
- " too many compound glyphs components\n" ));
- goto Exit;
- }
-
- if ( FT_RENEW_ARRAY( glyph->subs, glyph->max_subs, new_max ) )
- goto Exit;
-
- glyph->max_subs = new_max;
- }
-
- subglyph = glyph->subs + org_count;
-
- for ( i = 0; i < count; i++, subglyph++ )
- {
- FT_UInt format;
-
-
- x_pos = 0;
- y_pos = 0;
-
- PFR_CHECK( 1 );
- format = PFR_NEXT_BYTE( p );
-
- /* read scale when available */
- subglyph->x_scale = 0x10000L;
- if ( format & PFR_SUBGLYPH_XSCALE )
- {
- PFR_CHECK( 2 );
- subglyph->x_scale = PFR_NEXT_SHORT( p ) * 16;
- }
-
- subglyph->y_scale = 0x10000L;
- if ( format & PFR_SUBGLYPH_YSCALE )
- {
- PFR_CHECK( 2 );
- subglyph->y_scale = PFR_NEXT_SHORT( p ) * 16;
- }
-
- /* read offset */
- switch ( format & 3 )
- {
- case 1:
- PFR_CHECK( 2 );
- x_pos = PFR_NEXT_SHORT( p );
- break;
-
- case 2:
- PFR_CHECK( 1 );
- x_pos += PFR_NEXT_INT8( p );
- break;
-
- default:
- ;
- }
-
- switch ( ( format >> 2 ) & 3 )
- {
- case 1:
- PFR_CHECK( 2 );
- y_pos = PFR_NEXT_SHORT( p );
- break;
-
- case 2:
- PFR_CHECK( 1 );
- y_pos += PFR_NEXT_INT8( p );
- break;
-
- default:
- ;
- }
-
- subglyph->x_delta = x_pos;
- subglyph->y_delta = y_pos;
-
- /* read glyph position and size now */
- if ( format & PFR_SUBGLYPH_2BYTE_SIZE )
- {
- PFR_CHECK( 2 );
- subglyph->gps_size = PFR_NEXT_USHORT( p );
- }
- else
- {
- PFR_CHECK( 1 );
- subglyph->gps_size = PFR_NEXT_BYTE( p );
- }
-
- if ( format & PFR_SUBGLYPH_3BYTE_OFFSET )
- {
- PFR_CHECK( 3 );
- subglyph->gps_offset = PFR_NEXT_ULONG( p );
- }
- else
- {
- PFR_CHECK( 2 );
- subglyph->gps_offset = PFR_NEXT_USHORT( p );
- }
-
- glyph->num_subs++;
- }
-
- Exit:
- return error;
-
- Failure:
- Too_Short:
- error = FT_THROW( Invalid_Table );
- FT_ERROR(( "pfr_glyph_load_compound: invalid glyph data\n" ));
- goto Exit;
- }
-
-
- static FT_Error
- pfr_glyph_load_rec( PFR_Glyph glyph,
- FT_Stream stream,
- FT_ULong gps_offset,
- FT_ULong offset,
- FT_ULong size )
- {
- FT_Error error;
- FT_Byte* p;
- FT_Byte* limit;
-
-
- if ( FT_STREAM_SEEK( gps_offset + offset ) ||
- FT_FRAME_ENTER( size ) )
- goto Exit;
-
- p = (FT_Byte*)stream->cursor;
- limit = p + size;
-
- if ( size > 0 && *p & PFR_GLYPH_IS_COMPOUND )
- {
- FT_UInt n, old_count, count;
- FT_GlyphLoader loader = glyph->loader;
- FT_Outline* base = &loader->base.outline;
-
-
- old_count = glyph->num_subs;
-
- /* this is a compound glyph - load it */
- error = pfr_glyph_load_compound( glyph, p, limit );
-
- FT_FRAME_EXIT();
-
- if ( error )
- goto Exit;
-
- count = glyph->num_subs - old_count;
-
- FT_TRACE4(( "compound glyph with %d element%s (offset %lu):\n",
- count,
- count == 1 ? "" : "s",
- offset ));
-
- /* now, load each individual glyph */
- for ( n = 0; n < count; n++ )
- {
- FT_Int i, old_points, num_points;
- PFR_SubGlyph subglyph;
-
-
- FT_TRACE4(( " subglyph %d:\n", n ));
-
- subglyph = glyph->subs + old_count + n;
- old_points = base->n_points;
-
- error = pfr_glyph_load_rec( glyph, stream, gps_offset,
- subglyph->gps_offset,
- subglyph->gps_size );
- if ( error )
- break;
-
- /* note that `glyph->subs' might have been re-allocated */
- subglyph = glyph->subs + old_count + n;
- num_points = base->n_points - old_points;
-
- /* translate and eventually scale the new glyph points */
- if ( subglyph->x_scale != 0x10000L || subglyph->y_scale != 0x10000L )
- {
- FT_Vector* vec = base->points + old_points;
-
-
- for ( i = 0; i < num_points; i++, vec++ )
- {
- vec->x = FT_MulFix( vec->x, subglyph->x_scale ) +
- subglyph->x_delta;
- vec->y = FT_MulFix( vec->y, subglyph->y_scale ) +
- subglyph->y_delta;
- }
- }
- else
- {
- FT_Vector* vec = loader->base.outline.points + old_points;
-
-
- for ( i = 0; i < num_points; i++, vec++ )
- {
- vec->x += subglyph->x_delta;
- vec->y += subglyph->y_delta;
- }
- }
-
- /* proceed to next sub-glyph */
- }
-
- FT_TRACE4(( "end compound glyph with %d element%s\n",
- count,
- count == 1 ? "" : "s" ));
- }
- else
- {
- FT_TRACE4(( "simple glyph (offset %lu)\n", offset ));
-
- /* load a simple glyph */
- error = pfr_glyph_load_simple( glyph, p, limit );
-
- FT_FRAME_EXIT();
- }
-
- Exit:
- return error;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- pfr_glyph_load( PFR_Glyph glyph,
- FT_Stream stream,
- FT_ULong gps_offset,
- FT_ULong offset,
- FT_ULong size )
- {
- /* initialize glyph loader */
- FT_GlyphLoader_Rewind( glyph->loader );
-
- glyph->num_subs = 0;
-
- /* load the glyph, recursively when needed */
- return pfr_glyph_load_rec( glyph, stream, gps_offset, offset, size );
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/pfr/pfrgload.h b/contrib/libs/freetype/src/pfr/pfrgload.h
deleted file mode 100644
index d86549fbe4..0000000000
--- a/contrib/libs/freetype/src/pfr/pfrgload.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/****************************************************************************
- *
- * pfrgload.h
- *
- * FreeType PFR glyph loader (specification).
- *
- * Copyright (C) 2002-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef PFRGLOAD_H_
-#define PFRGLOAD_H_
-
-#include "pfrtypes.h"
-
-FT_BEGIN_HEADER
-
-
- FT_LOCAL( void )
- pfr_glyph_init( PFR_Glyph glyph,
- FT_GlyphLoader loader );
-
- FT_LOCAL( void )
- pfr_glyph_done( PFR_Glyph glyph );
-
-
- FT_LOCAL( FT_Error )
- pfr_glyph_load( PFR_Glyph glyph,
- FT_Stream stream,
- FT_ULong gps_offset,
- FT_ULong offset,
- FT_ULong size );
-
-
-FT_END_HEADER
-
-
-#endif /* PFRGLOAD_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/pfr/pfrload.c b/contrib/libs/freetype/src/pfr/pfrload.c
deleted file mode 100644
index 358af5c78a..0000000000
--- a/contrib/libs/freetype/src/pfr/pfrload.c
+++ /dev/null
@@ -1,1062 +0,0 @@
-/****************************************************************************
- *
- * pfrload.c
- *
- * FreeType PFR loader (body).
- *
- * Copyright (C) 2002-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include "pfrload.h"
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftstream.h>
-
-#include "pfrerror.h"
-
-#undef FT_COMPONENT
-#define FT_COMPONENT pfr
-
-
- /*
- * The overall structure of a PFR file is as follows.
- *
- * PFR header
- * 58 bytes (contains nPhysFonts)
- *
- * Logical font directory (size at most 2^16 bytes)
- * 2 bytes (nLogFonts)
- * + nLogFonts * 5 bytes
- *
- * ==> nLogFonts <= 13106
- *
- * Logical font section (size at most 2^24 bytes)
- * nLogFonts * logFontRecord
- *
- * logFontRecord (size at most 2^16 bytes)
- * 12 bytes (fontMatrix)
- * + 1 byte (flags)
- * + 0-5 bytes (depending on `flags')
- * + 0-(1+255*(2+255)) = 0-65536 (depending on `flags')
- * + 5 bytes (physical font info)
- * + 0-1 bytes (depending on PFR header)
- *
- * ==> minimum size 18 bytes
- *
- * Physical font section (size at most 2^24 bytes)
- * nPhysFonts * (physFontRecord
- * + nBitmapSizes * nBmapChars * bmapCharRecord)
- *
- * physFontRecord (size at most 2^24 bytes)
- * 14 bytes (font info)
- * + 1 byte (flags)
- * + 0-2 (depending on `flags')
- * + 0-? (structure too complicated to be shown here; depending on
- * `flags'; contains `nBitmapSizes' and `nBmapChars')
- * + 3 bytes (nAuxBytes)
- * + nAuxBytes
- * + 1 byte (nBlueValues)
- * + 2 * nBlueValues
- * + 6 bytes (hinting data)
- * + 2 bytes (nCharacters)
- * + nCharacters * (4-10 bytes) (depending on `flags')
- *
- * ==> minimum size 27 bytes
- *
- * bmapCharRecord
- * 4-7 bytes
- *
- * Glyph program strings (three possible types: simpleGps, compoundGps,
- * and bitmapGps; size at most 2^24 bytes)
- * simpleGps (size at most 2^16 bytes)
- * 1 byte (flags)
- * 1-2 bytes (n[XY]orus, depending on `flags')
- * 0-(64+512*2) = 0-1088 bytes (depending on `n[XY]orus')
- * 0-? (structure too complicated to be shown here; depending on
- * `flags')
- * 1-? glyph data (faintly resembling PS Type 1 charstrings)
- *
- * ==> minimum size 3 bytes
- *
- * compoundGps (size at most 2^16 bytes)
- * 1 byte (nElements <= 63, flags)
- * + 0-(1+255*(2+255)) = 0-65536 (depending on `flags')
- * + nElements * (6-14 bytes)
- *
- * bitmapGps (size at most 2^16 bytes)
- * 1 byte (flags)
- * 3-13 bytes (position info, depending on `flags')
- * 0-? bitmap data
- *
- * ==> minimum size 4 bytes
- *
- * PFR trailer
- * 8 bytes
- *
- *
- * ==> minimum size of a valid PFR:
- * 58 (header)
- * + 2 (nLogFonts)
- * + 27 (1 physFontRecord)
- * + 8 (trailer)
- * -----
- * 95 bytes
- *
- */
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** EXTRA ITEMS *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- FT_LOCAL_DEF( FT_Error )
- pfr_extra_items_skip( FT_Byte* *pp,
- FT_Byte* limit )
- {
- return pfr_extra_items_parse( pp, limit, NULL, NULL );
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- pfr_extra_items_parse( FT_Byte* *pp,
- FT_Byte* limit,
- PFR_ExtraItem item_list,
- FT_Pointer item_data )
- {
- FT_Error error = FT_Err_Ok;
- FT_Byte* p = *pp;
- FT_UInt num_items, item_type, item_size;
-
-
- PFR_CHECK( 1 );
- num_items = PFR_NEXT_BYTE( p );
-
- for ( ; num_items > 0; num_items-- )
- {
- PFR_CHECK( 2 );
- item_size = PFR_NEXT_BYTE( p );
- item_type = PFR_NEXT_BYTE( p );
-
- PFR_CHECK( item_size );
-
- if ( item_list )
- {
- PFR_ExtraItem extra = item_list;
-
-
- for ( extra = item_list; extra->parser != NULL; extra++ )
- {
- if ( extra->type == item_type )
- {
- error = extra->parser( p, p + item_size, item_data );
- if ( error )
- goto Exit;
-
- break;
- }
- }
- }
-
- p += item_size;
- }
-
- Exit:
- *pp = p;
- return error;
-
- Too_Short:
- FT_ERROR(( "pfr_extra_items_parse: invalid extra items table\n" ));
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** PFR HEADER *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- static const FT_Frame_Field pfr_header_fields[] =
- {
-#undef FT_STRUCTURE
-#define FT_STRUCTURE PFR_HeaderRec
-
- FT_FRAME_START( 58 ),
- FT_FRAME_ULONG ( signature ),
- FT_FRAME_USHORT( version ),
- FT_FRAME_USHORT( signature2 ),
- FT_FRAME_USHORT( header_size ),
-
- FT_FRAME_USHORT( log_dir_size ),
- FT_FRAME_USHORT( log_dir_offset ),
-
- FT_FRAME_USHORT( log_font_max_size ),
- FT_FRAME_UOFF3 ( log_font_section_size ),
- FT_FRAME_UOFF3 ( log_font_section_offset ),
-
- FT_FRAME_USHORT( phy_font_max_size ),
- FT_FRAME_UOFF3 ( phy_font_section_size ),
- FT_FRAME_UOFF3 ( phy_font_section_offset ),
-
- FT_FRAME_USHORT( gps_max_size ),
- FT_FRAME_UOFF3 ( gps_section_size ),
- FT_FRAME_UOFF3 ( gps_section_offset ),
-
- FT_FRAME_BYTE ( max_blue_values ),
- FT_FRAME_BYTE ( max_x_orus ),
- FT_FRAME_BYTE ( max_y_orus ),
-
- FT_FRAME_BYTE ( phy_font_max_size_high ),
- FT_FRAME_BYTE ( color_flags ),
-
- FT_FRAME_UOFF3 ( bct_max_size ),
- FT_FRAME_UOFF3 ( bct_set_max_size ),
- FT_FRAME_UOFF3 ( phy_bct_set_max_size ),
-
- FT_FRAME_USHORT( num_phy_fonts ),
- FT_FRAME_BYTE ( max_vert_stem_snap ),
- FT_FRAME_BYTE ( max_horz_stem_snap ),
- FT_FRAME_USHORT( max_chars ),
- FT_FRAME_END
- };
-
-
- FT_LOCAL_DEF( FT_Error )
- pfr_header_load( PFR_Header header,
- FT_Stream stream )
- {
- FT_Error error;
-
-
- /* read header directly */
- if ( !FT_STREAM_SEEK( 0 ) &&
- !FT_STREAM_READ_FIELDS( pfr_header_fields, header ) )
- {
- /* make a few adjustments to the header */
- header->phy_font_max_size +=
- (FT_UInt32)header->phy_font_max_size_high << 16;
- }
-
- return error;
- }
-
-
- FT_LOCAL_DEF( FT_Bool )
- pfr_header_check( PFR_Header header )
- {
- FT_Bool result = 1;
-
-
- /* check signature and header size */
- if ( header->signature != 0x50465230L || /* "PFR0" */
- header->version > 4 ||
- header->header_size < 58 ||
- header->signature2 != 0x0D0A ) /* CR/LF */
- result = 0;
-
- return result;
- }
-
-
- /***********************************************************************/
- /***********************************************************************/
- /***** *****/
- /***** PFR LOGICAL FONTS *****/
- /***** *****/
- /***********************************************************************/
- /***********************************************************************/
-
-
- FT_LOCAL_DEF( FT_Error )
- pfr_log_font_count( FT_Stream stream,
- FT_UInt32 section_offset,
- FT_Long *acount )
- {
- FT_Error error;
- FT_UInt count;
- FT_UInt result = 0;
-
-
- if ( FT_STREAM_SEEK( section_offset ) ||
- FT_READ_USHORT( count ) )
- goto Exit;
-
- /* check maximum value and a rough minimum size: */
- /* - no more than 13106 log fonts */
- /* - we need 5 bytes for a log header record */
- /* - we need at least 18 bytes for a log font record */
- /* - the overall size is at least 95 bytes plus the */
- /* log header and log font records */
- if ( count > ( ( 1 << 16 ) - 2 ) / 5 ||
- 2 + count * 5 >= stream->size - section_offset ||
- 95 + count * ( 5 + 18 ) >= stream->size )
- {
- FT_ERROR(( "pfr_log_font_count:"
- " invalid number of logical fonts\n" ));
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- result = count;
-
- Exit:
- *acount = (FT_Long)result;
- return error;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- pfr_log_font_load( PFR_LogFont log_font,
- FT_Stream stream,
- FT_UInt idx,
- FT_UInt32 section_offset,
- FT_Bool size_increment )
- {
- FT_UInt num_log_fonts;
- FT_UInt flags;
- FT_UInt32 offset;
- FT_UInt32 size;
- FT_Error error;
-
-
- if ( FT_STREAM_SEEK( section_offset ) ||
- FT_READ_USHORT( num_log_fonts ) )
- goto Exit;
-
- if ( idx >= num_log_fonts )
- return FT_THROW( Invalid_Argument );
-
- if ( FT_STREAM_SKIP( idx * 5 ) ||
- FT_READ_USHORT( size ) ||
- FT_READ_UOFF3 ( offset ) )
- goto Exit;
-
- /* save logical font size and offset */
- log_font->size = size;
- log_font->offset = offset;
-
- /* now, check the rest of the table before loading it */
- {
- FT_Byte* p;
- FT_Byte* limit;
- FT_UInt local;
-
-
- if ( FT_STREAM_SEEK( offset ) ||
- FT_FRAME_ENTER( size ) )
- goto Exit;
-
- p = stream->cursor;
- limit = p + size;
-
- PFR_CHECK( 13 );
-
- log_font->matrix[0] = PFR_NEXT_LONG( p );
- log_font->matrix[1] = PFR_NEXT_LONG( p );
- log_font->matrix[2] = PFR_NEXT_LONG( p );
- log_font->matrix[3] = PFR_NEXT_LONG( p );
-
- flags = PFR_NEXT_BYTE( p );
-
- local = 0;
- if ( flags & PFR_LOG_STROKE )
- {
- local++;
- if ( flags & PFR_LOG_2BYTE_STROKE )
- local++;
-
- if ( ( flags & PFR_LINE_JOIN_MASK ) == PFR_LINE_JOIN_MITER )
- local += 3;
- }
- if ( flags & PFR_LOG_BOLD )
- {
- local++;
- if ( flags & PFR_LOG_2BYTE_BOLD )
- local++;
- }
-
- PFR_CHECK( local );
-
- if ( flags & PFR_LOG_STROKE )
- {
- log_font->stroke_thickness = ( flags & PFR_LOG_2BYTE_STROKE )
- ? PFR_NEXT_SHORT( p )
- : PFR_NEXT_BYTE( p );
-
- if ( ( flags & PFR_LINE_JOIN_MASK ) == PFR_LINE_JOIN_MITER )
- log_font->miter_limit = PFR_NEXT_LONG( p );
- }
-
- if ( flags & PFR_LOG_BOLD )
- log_font->bold_thickness = ( flags & PFR_LOG_2BYTE_BOLD )
- ? PFR_NEXT_SHORT( p )
- : PFR_NEXT_BYTE( p );
-
- if ( flags & PFR_LOG_EXTRA_ITEMS )
- {
- error = pfr_extra_items_skip( &p, limit );
- if ( error )
- goto Fail;
- }
-
- PFR_CHECK( 5 );
- log_font->phys_size = PFR_NEXT_USHORT( p );
- log_font->phys_offset = PFR_NEXT_ULONG( p );
- if ( size_increment )
- {
- PFR_CHECK( 1 );
- log_font->phys_size += (FT_UInt32)PFR_NEXT_BYTE( p ) << 16;
- }
- }
-
- Fail:
- FT_FRAME_EXIT();
-
- Exit:
- return error;
-
- Too_Short:
- FT_ERROR(( "pfr_log_font_load: invalid logical font table\n" ));
- error = FT_THROW( Invalid_Table );
- goto Fail;
- }
-
-
- /***********************************************************************/
- /***********************************************************************/
- /***** *****/
- /***** PFR PHYSICAL FONTS *****/
- /***** *****/
- /***********************************************************************/
- /***********************************************************************/
-
-
- /* load bitmap strikes lists */
- FT_CALLBACK_DEF( FT_Error )
- pfr_extra_item_load_bitmap_info( FT_Byte* p,
- FT_Byte* limit,
- void* phy_font_ )
- {
- PFR_PhyFont phy_font = (PFR_PhyFont)phy_font_;
- FT_Memory memory = phy_font->memory;
- PFR_Strike strike;
- FT_UInt flags0;
- FT_UInt n, count, size1;
- FT_Error error = FT_Err_Ok;
-
-
- PFR_CHECK( 5 );
-
- p += 3; /* skip bctSize */
- flags0 = PFR_NEXT_BYTE( p );
- count = PFR_NEXT_BYTE( p );
-
- /* re-allocate when needed */
- if ( phy_font->num_strikes + count > phy_font->max_strikes )
- {
- FT_UInt new_max = FT_PAD_CEIL( phy_font->num_strikes + count, 4 );
-
-
- if ( FT_RENEW_ARRAY( phy_font->strikes,
- phy_font->num_strikes,
- new_max ) )
- goto Exit;
-
- phy_font->max_strikes = new_max;
- }
-
- size1 = 1 + 1 + 1 + 2 + 2 + 1;
- if ( flags0 & PFR_STRIKE_2BYTE_XPPM )
- size1++;
-
- if ( flags0 & PFR_STRIKE_2BYTE_YPPM )
- size1++;
-
- if ( flags0 & PFR_STRIKE_3BYTE_SIZE )
- size1++;
-
- if ( flags0 & PFR_STRIKE_3BYTE_OFFSET )
- size1++;
-
- if ( flags0 & PFR_STRIKE_2BYTE_COUNT )
- size1++;
-
- strike = phy_font->strikes + phy_font->num_strikes;
-
- PFR_CHECK( count * size1 );
-
- for ( n = 0; n < count; n++, strike++ )
- {
- strike->x_ppm = ( flags0 & PFR_STRIKE_2BYTE_XPPM )
- ? PFR_NEXT_USHORT( p )
- : PFR_NEXT_BYTE( p );
-
- strike->y_ppm = ( flags0 & PFR_STRIKE_2BYTE_YPPM )
- ? PFR_NEXT_USHORT( p )
- : PFR_NEXT_BYTE( p );
-
- strike->flags = PFR_NEXT_BYTE( p );
-
- strike->bct_size = ( flags0 & PFR_STRIKE_3BYTE_SIZE )
- ? PFR_NEXT_ULONG( p )
- : PFR_NEXT_USHORT( p );
-
- strike->bct_offset = ( flags0 & PFR_STRIKE_3BYTE_OFFSET )
- ? PFR_NEXT_ULONG( p )
- : PFR_NEXT_USHORT( p );
-
- strike->num_bitmaps = ( flags0 & PFR_STRIKE_2BYTE_COUNT )
- ? PFR_NEXT_USHORT( p )
- : PFR_NEXT_BYTE( p );
- }
-
- phy_font->num_strikes += count;
-
- Exit:
- return error;
-
- Too_Short:
- error = FT_THROW( Invalid_Table );
- FT_ERROR(( "pfr_extra_item_load_bitmap_info:"
- " invalid bitmap info table\n" ));
- goto Exit;
- }
-
-
- /* Load font ID. This is a so-called `unique' name that is rather
- * long and descriptive (like `Tiresias ScreenFont v7.51').
- *
- * Note that a PFR font's family name is contained in an *undocumented*
- * string of the `auxiliary data' portion of a physical font record. This
- * may also contain the `real' style name!
- *
- * If no family name is present, the font ID is used instead for the
- * family.
- */
- FT_CALLBACK_DEF( FT_Error )
- pfr_extra_item_load_font_id( FT_Byte* p,
- FT_Byte* limit,
- void* phy_font_ )
- {
- PFR_PhyFont phy_font = (PFR_PhyFont)phy_font_;
- FT_Error error = FT_Err_Ok;
- FT_Memory memory = phy_font->memory;
- FT_UInt len = (FT_UInt)( limit - p );
-
-
- if ( phy_font->font_id )
- goto Exit;
-
- if ( FT_QALLOC( phy_font->font_id, len + 1 ) )
- goto Exit;
-
- /* copy font ID name, and terminate it for safety */
- FT_MEM_COPY( phy_font->font_id, p, len );
- phy_font->font_id[len] = 0;
-
- Exit:
- return error;
- }
-
-
- /* load stem snap tables */
- FT_CALLBACK_DEF( FT_Error )
- pfr_extra_item_load_stem_snaps( FT_Byte* p,
- FT_Byte* limit,
- void* phy_font_ )
- {
- PFR_PhyFont phy_font = (PFR_PhyFont)phy_font_;
- FT_UInt count, num_vert, num_horz;
- FT_Int* snaps = NULL;
- FT_Error error = FT_Err_Ok;
- FT_Memory memory = phy_font->memory;
-
-
- if ( phy_font->vertical.stem_snaps )
- goto Exit;
-
- PFR_CHECK( 1 );
- count = PFR_NEXT_BYTE( p );
-
- num_vert = count & 15;
- num_horz = count >> 4;
- count = num_vert + num_horz;
-
- PFR_CHECK( count * 2 );
-
- if ( FT_QNEW_ARRAY( snaps, count ) )
- goto Exit;
-
- phy_font->vertical.stem_snaps = snaps;
- phy_font->horizontal.stem_snaps = snaps + num_vert;
-
- for ( ; count > 0; count--, snaps++ )
- *snaps = FT_NEXT_SHORT( p );
-
- Exit:
- return error;
-
- Too_Short:
- error = FT_THROW( Invalid_Table );
- FT_ERROR(( "pfr_extra_item_load_stem_snaps:"
- " invalid stem snaps table\n" ));
- goto Exit;
- }
-
-
- /* load kerning pair data */
- FT_CALLBACK_DEF( FT_Error )
- pfr_extra_item_load_kerning_pairs( FT_Byte* p,
- FT_Byte* limit,
- void* phy_font_ )
- {
- PFR_PhyFont phy_font = (PFR_PhyFont)phy_font_;
- PFR_KernItem item = NULL;
- FT_Error error = FT_Err_Ok;
- FT_Memory memory = phy_font->memory;
-
-
- if ( FT_NEW( item ) )
- goto Exit;
-
- PFR_CHECK( 4 );
-
- item->pair_count = PFR_NEXT_BYTE( p );
- item->base_adj = PFR_NEXT_SHORT( p );
- item->flags = PFR_NEXT_BYTE( p );
- item->offset = phy_font->offset +
- (FT_Offset)( p - phy_font->cursor );
-
-#ifndef PFR_CONFIG_NO_CHECKS
- item->pair_size = 3;
-
- if ( item->flags & PFR_KERN_2BYTE_CHAR )
- item->pair_size += 2;
-
- if ( item->flags & PFR_KERN_2BYTE_ADJ )
- item->pair_size += 1;
-
- PFR_CHECK( item->pair_count * item->pair_size );
-#endif
-
- /* load first and last pairs into the item to speed up */
- /* lookup later... */
- if ( item->pair_count > 0 )
- {
- FT_UInt char1, char2;
- FT_Byte* q;
-
-
- if ( item->flags & PFR_KERN_2BYTE_CHAR )
- {
- q = p;
- char1 = PFR_NEXT_USHORT( q );
- char2 = PFR_NEXT_USHORT( q );
-
- item->pair1 = PFR_KERN_INDEX( char1, char2 );
-
- q = p + item->pair_size * ( item->pair_count - 1 );
- char1 = PFR_NEXT_USHORT( q );
- char2 = PFR_NEXT_USHORT( q );
-
- item->pair2 = PFR_KERN_INDEX( char1, char2 );
- }
- else
- {
- q = p;
- char1 = PFR_NEXT_BYTE( q );
- char2 = PFR_NEXT_BYTE( q );
-
- item->pair1 = PFR_KERN_INDEX( char1, char2 );
-
- q = p + item->pair_size * ( item->pair_count - 1 );
- char1 = PFR_NEXT_BYTE( q );
- char2 = PFR_NEXT_BYTE( q );
-
- item->pair2 = PFR_KERN_INDEX( char1, char2 );
- }
-
- /* add new item to the current list */
- item->next = NULL;
- *phy_font->kern_items_tail = item;
- phy_font->kern_items_tail = &item->next;
- phy_font->num_kern_pairs += item->pair_count;
- }
- else
- {
- /* empty item! */
- FT_FREE( item );
- }
-
- Exit:
- return error;
-
- Too_Short:
- FT_FREE( item );
-
- error = FT_THROW( Invalid_Table );
- FT_ERROR(( "pfr_extra_item_load_kerning_pairs:"
- " invalid kerning pairs table\n" ));
- goto Exit;
- }
-
-
- static const PFR_ExtraItemRec pfr_phy_font_extra_items[] =
- {
- { 1, pfr_extra_item_load_bitmap_info },
- { 2, pfr_extra_item_load_font_id },
- { 3, pfr_extra_item_load_stem_snaps },
- { 4, pfr_extra_item_load_kerning_pairs },
- { 0, NULL }
- };
-
-
- /*
- * Load a name from the auxiliary data. Since this extracts undocumented
- * strings from the font file, we need to be careful here.
- */
- static FT_Error
- pfr_aux_name_load( FT_Byte* p,
- FT_UInt len,
- FT_Memory memory,
- FT_String* *astring )
- {
- FT_Error error = FT_Err_Ok;
- FT_String* result = NULL;
- FT_UInt n, ok;
-
-
- if ( *astring )
- FT_FREE( *astring );
-
- if ( len > 0 && p[len - 1] == 0 )
- len--;
-
- /* check that each character is ASCII */
- /* for making sure not to load garbage */
- ok = ( len > 0 );
- for ( n = 0; n < len; n++ )
- if ( p[n] < 32 || p[n] > 127 )
- {
- ok = 0;
- break;
- }
-
- if ( ok )
- {
- if ( FT_QALLOC( result, len + 1 ) )
- goto Exit;
-
- FT_MEM_COPY( result, p, len );
- result[len] = 0;
- }
-
- Exit:
- *astring = result;
- return error;
- }
-
-
- FT_LOCAL_DEF( void )
- pfr_phy_font_done( PFR_PhyFont phy_font,
- FT_Memory memory )
- {
- FT_FREE( phy_font->font_id );
- FT_FREE( phy_font->family_name );
- FT_FREE( phy_font->style_name );
-
- FT_FREE( phy_font->vertical.stem_snaps );
- phy_font->vertical.num_stem_snaps = 0;
-
- phy_font->horizontal.stem_snaps = NULL;
- phy_font->horizontal.num_stem_snaps = 0;
-
- FT_FREE( phy_font->strikes );
- phy_font->num_strikes = 0;
- phy_font->max_strikes = 0;
-
- FT_FREE( phy_font->chars );
- phy_font->num_chars = 0;
- phy_font->chars_offset = 0;
-
- FT_FREE( phy_font->blue_values );
- phy_font->num_blue_values = 0;
-
- {
- PFR_KernItem item, next;
-
-
- item = phy_font->kern_items;
- while ( item )
- {
- next = item->next;
- FT_FREE( item );
- item = next;
- }
- phy_font->kern_items = NULL;
- phy_font->kern_items_tail = NULL;
- }
-
- phy_font->num_kern_pairs = 0;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- pfr_phy_font_load( PFR_PhyFont phy_font,
- FT_Stream stream,
- FT_UInt32 offset,
- FT_UInt32 size )
- {
- FT_Error error;
- FT_Memory memory = stream->memory;
- FT_UInt flags;
- FT_ULong num_aux;
- FT_Byte* p;
- FT_Byte* limit;
-
-
- phy_font->memory = memory;
- phy_font->offset = offset;
-
- phy_font->kern_items = NULL;
- phy_font->kern_items_tail = &phy_font->kern_items;
-
- if ( FT_STREAM_SEEK( offset ) ||
- FT_FRAME_ENTER( size ) )
- goto Exit;
-
- phy_font->cursor = stream->cursor;
-
- p = stream->cursor;
- limit = p + size;
-
- PFR_CHECK( 15 );
- phy_font->font_ref_number = PFR_NEXT_USHORT( p );
- phy_font->outline_resolution = PFR_NEXT_USHORT( p );
- phy_font->metrics_resolution = PFR_NEXT_USHORT( p );
- phy_font->bbox.xMin = PFR_NEXT_SHORT( p );
- phy_font->bbox.yMin = PFR_NEXT_SHORT( p );
- phy_font->bbox.xMax = PFR_NEXT_SHORT( p );
- phy_font->bbox.yMax = PFR_NEXT_SHORT( p );
- phy_font->flags = flags = PFR_NEXT_BYTE( p );
-
- if ( !phy_font->outline_resolution ||
- !phy_font->metrics_resolution )
- {
- error = FT_THROW( Invalid_Table );
- FT_ERROR(( "pfr_phy_font_load: invalid resolution\n" ));
- goto Fail;
- }
-
- /* get the standard advance for non-proportional fonts */
- if ( !( flags & PFR_PHY_PROPORTIONAL ) )
- {
- PFR_CHECK( 2 );
- phy_font->standard_advance = PFR_NEXT_SHORT( p );
- }
-
- /* load the extra items when present */
- if ( flags & PFR_PHY_EXTRA_ITEMS )
- {
- error = pfr_extra_items_parse( &p, limit,
- pfr_phy_font_extra_items, phy_font );
- if ( error )
- goto Fail;
- }
-
- /* In certain fonts, the auxiliary bytes contain interesting */
- /* information. These are not in the specification but can be */
- /* guessed by looking at the content of a few 'PFR0' fonts. */
- PFR_CHECK( 3 );
- num_aux = PFR_NEXT_ULONG( p );
-
- if ( num_aux > 0 )
- {
- FT_Byte* q = p;
- FT_Byte* q2;
-
-
- PFR_CHECK_SIZE( num_aux );
- p += num_aux;
-
- while ( num_aux > 0 )
- {
- FT_UInt length, type;
-
-
- if ( q + 4 > p )
- break;
-
- length = PFR_NEXT_USHORT( q );
- if ( length < 4 || length > num_aux )
- break;
-
- q2 = q + length - 2;
- type = PFR_NEXT_USHORT( q );
-
- switch ( type )
- {
- case 1:
- /* this seems to correspond to the font's family name, padded to */
- /* an even number of bytes with a zero byte appended if needed */
- error = pfr_aux_name_load( q, length - 4U, memory,
- &phy_font->family_name );
- if ( error )
- goto Exit;
- break;
-
- case 2:
- if ( q + 32 > q2 )
- break;
-
- q += 10;
- phy_font->ascent = PFR_NEXT_SHORT( q );
- phy_font->descent = PFR_NEXT_SHORT( q );
- phy_font->leading = PFR_NEXT_SHORT( q );
- break;
-
- case 3:
- /* this seems to correspond to the font's style name, padded to */
- /* an even number of bytes with a zero byte appended if needed */
- error = pfr_aux_name_load( q, length - 4U, memory,
- &phy_font->style_name );
- if ( error )
- goto Exit;
- break;
-
- default:
- ;
- }
-
- q = q2;
- num_aux -= length;
- }
- }
-
- /* read the blue values */
- {
- FT_UInt n, count;
-
-
- PFR_CHECK( 1 );
- phy_font->num_blue_values = count = PFR_NEXT_BYTE( p );
-
- PFR_CHECK( count * 2 );
-
- if ( FT_QNEW_ARRAY( phy_font->blue_values, count ) )
- goto Fail;
-
- for ( n = 0; n < count; n++ )
- phy_font->blue_values[n] = PFR_NEXT_SHORT( p );
- }
-
- PFR_CHECK( 8 );
- phy_font->blue_fuzz = PFR_NEXT_BYTE( p );
- phy_font->blue_scale = PFR_NEXT_BYTE( p );
-
- phy_font->vertical.standard = PFR_NEXT_USHORT( p );
- phy_font->horizontal.standard = PFR_NEXT_USHORT( p );
-
- /* read the character descriptors */
- {
- FT_UInt n, count, Size;
-
-
- phy_font->num_chars = count = PFR_NEXT_USHORT( p );
- phy_font->chars_offset = offset + (FT_Offset)( p - stream->cursor );
-
- if ( !phy_font->num_chars )
- {
- error = FT_THROW( Invalid_Table );
- FT_ERROR(( "pfr_phy_font_load: no glyphs\n" ));
- goto Fail;
- }
-
- Size = 1 + 1 + 2;
- if ( flags & PFR_PHY_2BYTE_CHARCODE )
- Size += 1;
-
- if ( flags & PFR_PHY_PROPORTIONAL )
- Size += 2;
-
- if ( flags & PFR_PHY_ASCII_CODE )
- Size += 1;
-
- if ( flags & PFR_PHY_2BYTE_GPS_SIZE )
- Size += 1;
-
- if ( flags & PFR_PHY_3BYTE_GPS_OFFSET )
- Size += 1;
-
- PFR_CHECK_SIZE( count * Size );
-
- if ( FT_QNEW_ARRAY( phy_font->chars, count ) )
- goto Fail;
-
- for ( n = 0; n < count; n++ )
- {
- PFR_Char cur = &phy_font->chars[n];
-
-
- cur->char_code = ( flags & PFR_PHY_2BYTE_CHARCODE )
- ? PFR_NEXT_USHORT( p )
- : PFR_NEXT_BYTE( p );
-
- cur->advance = ( flags & PFR_PHY_PROPORTIONAL )
- ? PFR_NEXT_SHORT( p )
- : phy_font->standard_advance;
-
-#if 0
- cur->ascii = ( flags & PFR_PHY_ASCII_CODE )
- ? PFR_NEXT_BYTE( p )
- : 0;
-#else
- if ( flags & PFR_PHY_ASCII_CODE )
- p += 1;
-#endif
- cur->gps_size = ( flags & PFR_PHY_2BYTE_GPS_SIZE )
- ? PFR_NEXT_USHORT( p )
- : PFR_NEXT_BYTE( p );
-
- cur->gps_offset = ( flags & PFR_PHY_3BYTE_GPS_OFFSET )
- ? PFR_NEXT_ULONG( p )
- : PFR_NEXT_USHORT( p );
- }
- }
-
- /* that's it! */
-
- Fail:
- FT_FRAME_EXIT();
-
- /* save position of bitmap info */
- phy_font->bct_offset = FT_STREAM_POS();
- phy_font->cursor = NULL;
-
- Exit:
- return error;
-
- Too_Short:
- error = FT_THROW( Invalid_Table );
- FT_ERROR(( "pfr_phy_font_load: invalid physical font table\n" ));
- goto Fail;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/pfr/pfrload.h b/contrib/libs/freetype/src/pfr/pfrload.h
deleted file mode 100644
index 7390296d4a..0000000000
--- a/contrib/libs/freetype/src/pfr/pfrload.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/****************************************************************************
- *
- * pfrload.h
- *
- * FreeType PFR loader (specification).
- *
- * Copyright (C) 2002-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef PFRLOAD_H_
-#define PFRLOAD_H_
-
-#include "pfrobjs.h"
-#include <freetype/internal/ftstream.h>
-
-
-FT_BEGIN_HEADER
-
- /* some size checks should be always done (mainly to prevent */
- /* excessive allocation for malformed data), ... */
-#define PFR_CHECK_SIZE( x ) do \
- { \
- if ( p + (x) > limit ) \
- goto Too_Short; \
- } while ( 0 )
-
- /* ... and some only if intensive checking is explicitly requested */
-#ifdef PFR_CONFIG_NO_CHECKS
-#define PFR_CHECK( x ) do { } while ( 0 )
-#else
-#define PFR_CHECK PFR_CHECK_SIZE
-#endif
-
-#define PFR_NEXT_BYTE( p ) FT_NEXT_BYTE( p )
-#define PFR_NEXT_INT8( p ) FT_NEXT_CHAR( p )
-#define PFR_NEXT_SHORT( p ) FT_NEXT_SHORT( p )
-#define PFR_NEXT_USHORT( p ) FT_NEXT_USHORT( p )
-#define PFR_NEXT_LONG( p ) FT_NEXT_OFF3( p )
-#define PFR_NEXT_ULONG( p ) FT_NEXT_UOFF3( p )
-
-
- /* handling extra items */
-
- typedef FT_Error
- (*PFR_ExtraItem_ParseFunc)( FT_Byte* p,
- FT_Byte* limit,
- FT_Pointer data );
-
- typedef struct PFR_ExtraItemRec_
- {
- FT_UInt type;
- PFR_ExtraItem_ParseFunc parser;
-
- } PFR_ExtraItemRec;
-
- typedef const struct PFR_ExtraItemRec_* PFR_ExtraItem;
-
-
- FT_LOCAL( FT_Error )
- pfr_extra_items_skip( FT_Byte* *pp,
- FT_Byte* limit );
-
- FT_LOCAL( FT_Error )
- pfr_extra_items_parse( FT_Byte* *pp,
- FT_Byte* limit,
- PFR_ExtraItem item_list,
- FT_Pointer item_data );
-
-
- /* load a PFR header */
- FT_LOCAL( FT_Error )
- pfr_header_load( PFR_Header header,
- FT_Stream stream );
-
- /* check a PFR header */
- FT_LOCAL( FT_Bool )
- pfr_header_check( PFR_Header header );
-
-
- /* return number of logical fonts in this file */
- FT_LOCAL( FT_Error )
- pfr_log_font_count( FT_Stream stream,
- FT_UInt32 log_section_offset,
- FT_Long *acount );
-
- /* load a pfr logical font entry */
- FT_LOCAL( FT_Error )
- pfr_log_font_load( PFR_LogFont log_font,
- FT_Stream stream,
- FT_UInt face_index,
- FT_UInt32 section_offset,
- FT_Bool size_increment );
-
-
- /* load a physical font entry */
- FT_LOCAL( FT_Error )
- pfr_phy_font_load( PFR_PhyFont phy_font,
- FT_Stream stream,
- FT_UInt32 offset,
- FT_UInt32 size );
-
- /* finalize a physical font */
- FT_LOCAL( void )
- pfr_phy_font_done( PFR_PhyFont phy_font,
- FT_Memory memory );
-
- /* */
-
-FT_END_HEADER
-
-#endif /* PFRLOAD_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/pfr/pfrobjs.c b/contrib/libs/freetype/src/pfr/pfrobjs.c
deleted file mode 100644
index 084d2ef5a1..0000000000
--- a/contrib/libs/freetype/src/pfr/pfrobjs.c
+++ /dev/null
@@ -1,603 +0,0 @@
-/****************************************************************************
- *
- * pfrobjs.c
- *
- * FreeType PFR object methods (body).
- *
- * Copyright (C) 2002-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include "pfrobjs.h"
-#include "pfrload.h"
-#include "pfrgload.h"
-#include "pfrcmap.h"
-#include "pfrsbit.h"
-#include <freetype/ftoutln.h>
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftcalc.h>
-#include <freetype/ttnameid.h>
-
-#include "pfrerror.h"
-
-#undef FT_COMPONENT
-#define FT_COMPONENT pfr
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** FACE OBJECT METHODS *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- FT_LOCAL_DEF( void )
- pfr_face_done( FT_Face pfrface ) /* PFR_Face */
- {
- PFR_Face face = (PFR_Face)pfrface;
- FT_Memory memory;
-
-
- if ( !face )
- return;
-
- memory = pfrface->memory;
-
- /* we don't want dangling pointers */
- pfrface->family_name = NULL;
- pfrface->style_name = NULL;
-
- /* finalize the physical font record */
- pfr_phy_font_done( &face->phy_font, memory );
-
- /* no need to finalize the logical font or the header */
- FT_FREE( pfrface->available_sizes );
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- pfr_face_init( FT_Stream stream,
- FT_Face pfrface,
- FT_Int face_index,
- FT_Int num_params,
- FT_Parameter* params )
- {
- PFR_Face face = (PFR_Face)pfrface;
- FT_Error error;
-
- FT_UNUSED( num_params );
- FT_UNUSED( params );
-
-
- FT_TRACE2(( "PFR driver\n" ));
-
- /* load the header and check it */
- error = pfr_header_load( &face->header, stream );
- if ( error )
- {
- FT_TRACE2(( " not a PFR font\n" ));
- error = FT_THROW( Unknown_File_Format );
- goto Exit;
- }
-
- if ( !pfr_header_check( &face->header ) )
- {
- FT_TRACE2(( " not a PFR font\n" ));
- error = FT_THROW( Unknown_File_Format );
- goto Exit;
- }
-
- /* check face index */
- {
- FT_Long num_faces;
-
-
- error = pfr_log_font_count( stream,
- face->header.log_dir_offset,
- &num_faces );
- if ( error )
- goto Exit;
-
- pfrface->num_faces = num_faces;
- }
-
- if ( face_index < 0 )
- goto Exit;
-
- if ( ( face_index & 0xFFFF ) >= pfrface->num_faces )
- {
- FT_ERROR(( "pfr_face_init: invalid face index\n" ));
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- /* load the face */
- error = pfr_log_font_load(
- &face->log_font,
- stream,
- (FT_UInt)( face_index & 0xFFFF ),
- face->header.log_dir_offset,
- FT_BOOL( face->header.phy_font_max_size_high ) );
- if ( error )
- goto Exit;
-
- /* load the physical font descriptor */
- error = pfr_phy_font_load( &face->phy_font, stream,
- face->log_font.phys_offset,
- face->log_font.phys_size );
- if ( error )
- goto Exit;
-
- /* set up all root face fields */
- {
- PFR_PhyFont phy_font = &face->phy_font;
-
-
- pfrface->face_index = face_index & 0xFFFF;
- pfrface->num_glyphs = (FT_Long)phy_font->num_chars + 1;
-
- pfrface->face_flags |= FT_FACE_FLAG_SCALABLE;
-
- /* if gps_offset == 0 for all characters, we */
- /* assume that the font only contains bitmaps */
- {
- FT_UInt nn;
-
-
- for ( nn = 0; nn < phy_font->num_chars; nn++ )
- if ( phy_font->chars[nn].gps_offset != 0 )
- break;
-
- if ( nn == phy_font->num_chars )
- {
- if ( phy_font->num_strikes > 0 )
- pfrface->face_flags &= ~FT_FACE_FLAG_SCALABLE;
- else
- {
- FT_ERROR(( "pfr_face_init: font doesn't contain glyphs\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
- }
- }
-
- if ( !( phy_font->flags & PFR_PHY_PROPORTIONAL ) )
- pfrface->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
-
- if ( phy_font->flags & PFR_PHY_VERTICAL )
- pfrface->face_flags |= FT_FACE_FLAG_VERTICAL;
- else
- pfrface->face_flags |= FT_FACE_FLAG_HORIZONTAL;
-
- if ( phy_font->num_strikes > 0 )
- pfrface->face_flags |= FT_FACE_FLAG_FIXED_SIZES;
-
- if ( phy_font->num_kern_pairs > 0 )
- pfrface->face_flags |= FT_FACE_FLAG_KERNING;
-
- /* If no family name was found in the `undocumented' auxiliary
- * data, use the font ID instead. This sucks but is better than
- * nothing.
- */
- pfrface->family_name = phy_font->family_name;
- if ( !pfrface->family_name )
- pfrface->family_name = phy_font->font_id;
-
- /* note that the style name can be NULL in certain PFR fonts,
- * probably meaning `Regular'
- */
- pfrface->style_name = phy_font->style_name;
-
- pfrface->num_fixed_sizes = 0;
- pfrface->available_sizes = NULL;
-
- pfrface->bbox = phy_font->bbox;
- pfrface->units_per_EM = (FT_UShort)phy_font->outline_resolution;
- pfrface->ascender = (FT_Short) phy_font->bbox.yMax;
- pfrface->descender = (FT_Short) phy_font->bbox.yMin;
-
- pfrface->height = (FT_Short)( ( pfrface->units_per_EM * 12 ) / 10 );
- if ( pfrface->height < pfrface->ascender - pfrface->descender )
- pfrface->height = (FT_Short)( pfrface->ascender - pfrface->descender );
-
- if ( phy_font->num_strikes > 0 )
- {
- FT_UInt n, count = phy_font->num_strikes;
- FT_Bitmap_Size* size;
- PFR_Strike strike;
- FT_Memory memory = pfrface->memory;
-
-
- if ( FT_QNEW_ARRAY( pfrface->available_sizes, count ) )
- goto Exit;
-
- size = pfrface->available_sizes;
- strike = phy_font->strikes;
- for ( n = 0; n < count; n++, size++, strike++ )
- {
- size->height = (FT_Short)strike->y_ppm;
- size->width = (FT_Short)strike->x_ppm;
- size->size = (FT_Pos)( strike->y_ppm << 6 );
- size->x_ppem = (FT_Pos)( strike->x_ppm << 6 );
- size->y_ppem = (FT_Pos)( strike->y_ppm << 6 );
- }
- pfrface->num_fixed_sizes = (FT_Int)count;
- }
-
- /* now compute maximum advance width */
- if ( ( phy_font->flags & PFR_PHY_PROPORTIONAL ) == 0 )
- pfrface->max_advance_width = (FT_Short)phy_font->standard_advance;
- else
- {
- FT_Int max = 0;
- FT_UInt count = phy_font->num_chars;
- PFR_Char gchar = phy_font->chars;
-
-
- for ( ; count > 0; count--, gchar++ )
- {
- if ( max < gchar->advance )
- max = gchar->advance;
- }
-
- pfrface->max_advance_width = (FT_Short)max;
- }
-
- pfrface->max_advance_height = pfrface->height;
-
- pfrface->underline_position = (FT_Short)( -pfrface->units_per_EM / 10 );
- pfrface->underline_thickness = (FT_Short)( pfrface->units_per_EM / 30 );
-
- /* create charmap */
- {
- FT_CharMapRec charmap;
-
-
- charmap.face = pfrface;
- charmap.platform_id = TT_PLATFORM_MICROSOFT;
- charmap.encoding_id = TT_MS_ID_UNICODE_CS;
- charmap.encoding = FT_ENCODING_UNICODE;
-
- error = FT_CMap_New( &pfr_cmap_class_rec, NULL, &charmap, NULL );
- }
-
- /* check whether we have loaded any kerning pairs */
- if ( phy_font->num_kern_pairs )
- pfrface->face_flags |= FT_FACE_FLAG_KERNING;
- }
-
- Exit:
- return error;
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** SLOT OBJECT METHOD *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- FT_LOCAL_DEF( FT_Error )
- pfr_slot_init( FT_GlyphSlot pfrslot ) /* PFR_Slot */
- {
- PFR_Slot slot = (PFR_Slot)pfrslot;
- FT_GlyphLoader loader = pfrslot->internal->loader;
-
-
- pfr_glyph_init( &slot->glyph, loader );
-
- return 0;
- }
-
-
- FT_LOCAL_DEF( void )
- pfr_slot_done( FT_GlyphSlot pfrslot ) /* PFR_Slot */
- {
- PFR_Slot slot = (PFR_Slot)pfrslot;
-
-
- pfr_glyph_done( &slot->glyph );
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- pfr_slot_load( FT_GlyphSlot pfrslot, /* PFR_Slot */
- FT_Size pfrsize, /* PFR_Size */
- FT_UInt gindex,
- FT_Int32 load_flags )
- {
- PFR_Slot slot = (PFR_Slot)pfrslot;
- PFR_Size size = (PFR_Size)pfrsize;
- FT_Error error;
- PFR_Face face = (PFR_Face)pfrslot->face;
- PFR_Char gchar;
- FT_Outline* outline = &pfrslot->outline;
- FT_ULong gps_offset;
-
-
- FT_TRACE1(( "pfr_slot_load: glyph index %d\n", gindex ));
-
- if ( gindex > 0 )
- gindex--;
-
- if ( !face || gindex >= face->phy_font.num_chars )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- /* try to load an embedded bitmap */
- if ( !( load_flags & ( FT_LOAD_NO_SCALE | FT_LOAD_NO_BITMAP ) ) )
- {
- error = pfr_slot_load_bitmap(
- slot,
- size,
- gindex,
- ( load_flags & FT_LOAD_BITMAP_METRICS_ONLY ) != 0 );
- if ( !error )
- goto Exit;
- }
-
- if ( load_flags & FT_LOAD_SBITS_ONLY )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- gchar = face->phy_font.chars + gindex;
- pfrslot->format = FT_GLYPH_FORMAT_OUTLINE;
- outline->n_points = 0;
- outline->n_contours = 0;
- gps_offset = face->header.gps_section_offset;
-
- /* load the glyph outline (FT_LOAD_NO_RECURSE isn't supported) */
- error = pfr_glyph_load( &slot->glyph, face->root.stream,
- gps_offset, gchar->gps_offset, gchar->gps_size );
-
- if ( !error )
- {
- FT_BBox cbox;
- FT_Glyph_Metrics* metrics = &pfrslot->metrics;
- FT_Pos advance;
- FT_UInt em_metrics, em_outline;
- FT_Bool scaling;
-
-
- scaling = FT_BOOL( !( load_flags & FT_LOAD_NO_SCALE ) );
-
- /* copy outline data */
- *outline = slot->glyph.loader->base.outline;
-
- outline->flags &= ~FT_OUTLINE_OWNER;
- outline->flags |= FT_OUTLINE_REVERSE_FILL;
-
- if ( pfrsize->metrics.y_ppem < 24 )
- outline->flags |= FT_OUTLINE_HIGH_PRECISION;
-
- /* compute the advance vector */
- metrics->horiAdvance = 0;
- metrics->vertAdvance = 0;
-
- advance = gchar->advance;
- em_metrics = face->phy_font.metrics_resolution;
- em_outline = face->phy_font.outline_resolution;
-
- if ( em_metrics != em_outline )
- advance = FT_MulDiv( advance,
- (FT_Long)em_outline,
- (FT_Long)em_metrics );
-
- if ( face->phy_font.flags & PFR_PHY_VERTICAL )
- metrics->vertAdvance = advance;
- else
- metrics->horiAdvance = advance;
-
- pfrslot->linearHoriAdvance = metrics->horiAdvance;
- pfrslot->linearVertAdvance = metrics->vertAdvance;
-
- /* make up vertical metrics(?) */
- metrics->vertBearingX = 0;
- metrics->vertBearingY = 0;
-
-#if 0 /* some fonts seem to be broken here! */
-
- /* Apply the font matrix, if any. */
- /* TODO: Test existing fonts with unusual matrix */
- /* whether we have to adjust Units per EM. */
- {
- FT_Matrix font_matrix;
-
-
- font_matrix.xx = face->log_font.matrix[0] << 8;
- font_matrix.yx = face->log_font.matrix[1] << 8;
- font_matrix.xy = face->log_font.matrix[2] << 8;
- font_matrix.yy = face->log_font.matrix[3] << 8;
-
- FT_Outline_Transform( outline, &font_matrix );
- }
-#endif
-
- /* scale when needed */
- if ( scaling )
- {
- FT_Int n;
- FT_Fixed x_scale = pfrsize->metrics.x_scale;
- FT_Fixed y_scale = pfrsize->metrics.y_scale;
- FT_Vector* vec = outline->points;
-
-
- /* scale outline points */
- for ( n = 0; n < outline->n_points; n++, vec++ )
- {
- vec->x = FT_MulFix( vec->x, x_scale );
- vec->y = FT_MulFix( vec->y, y_scale );
- }
-
- /* scale the advance */
- metrics->horiAdvance = FT_MulFix( metrics->horiAdvance, x_scale );
- metrics->vertAdvance = FT_MulFix( metrics->vertAdvance, y_scale );
- }
-
- /* compute the rest of the metrics */
- FT_Outline_Get_CBox( outline, &cbox );
-
- metrics->width = cbox.xMax - cbox.xMin;
- metrics->height = cbox.yMax - cbox.yMin;
- metrics->horiBearingX = cbox.xMin;
- metrics->horiBearingY = cbox.yMax - metrics->height;
- }
-
- Exit:
- return error;
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** KERNING METHOD *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- FT_LOCAL_DEF( FT_Error )
- pfr_face_get_kerning( FT_Face pfrface, /* PFR_Face */
- FT_UInt glyph1,
- FT_UInt glyph2,
- FT_Vector* kerning )
- {
- PFR_Face face = (PFR_Face)pfrface;
- FT_Error error = FT_Err_Ok;
- PFR_PhyFont phy_font = &face->phy_font;
- FT_UInt32 code1, code2, pair;
-
-
- kerning->x = 0;
- kerning->y = 0;
-
- /* PFR indexing skips .notdef, which becomes UINT_MAX */
- glyph1--;
- glyph2--;
-
- /* check the array bounds, .notdef is automatically out */
- if ( glyph1 >= phy_font->num_chars ||
- glyph2 >= phy_font->num_chars )
- goto Exit;
-
- /* convert glyph indices to character codes */
- code1 = phy_font->chars[glyph1].char_code;
- code2 = phy_font->chars[glyph2].char_code;
- pair = PFR_KERN_INDEX( code1, code2 );
-
- /* now search the list of kerning items */
- {
- PFR_KernItem item = phy_font->kern_items;
- FT_Stream stream = pfrface->stream;
-
-
- for ( ; item; item = item->next )
- {
- if ( pair >= item->pair1 && pair <= item->pair2 )
- goto FoundPair;
- }
- goto Exit;
-
- FoundPair: /* we found an item, now parse it and find the value if any */
- if ( FT_STREAM_SEEK( item->offset ) ||
- FT_FRAME_ENTER( item->pair_count * item->pair_size ) )
- goto Exit;
-
- {
- FT_UInt count = item->pair_count;
- FT_UInt size = item->pair_size;
- FT_UInt power = 1 << FT_MSB( count );
- FT_UInt probe = power * size;
- FT_UInt extra = count - power;
- FT_Byte* base = stream->cursor;
- FT_Bool twobytes = FT_BOOL( item->flags & PFR_KERN_2BYTE_CHAR );
- FT_Bool twobyte_adj = FT_BOOL( item->flags & PFR_KERN_2BYTE_ADJ );
- FT_Byte* p;
- FT_UInt32 cpair;
-
-
- if ( extra > 0 )
- {
- p = base + extra * size;
-
- if ( twobytes )
- cpair = FT_NEXT_ULONG( p );
- else
- cpair = PFR_NEXT_KPAIR( p );
-
- if ( cpair == pair )
- goto Found;
-
- if ( cpair < pair )
- {
- if ( twobyte_adj )
- p += 2;
- else
- p++;
- base = p;
- }
- }
-
- while ( probe > size )
- {
- probe >>= 1;
- p = base + probe;
-
- if ( twobytes )
- cpair = FT_NEXT_ULONG( p );
- else
- cpair = PFR_NEXT_KPAIR( p );
-
- if ( cpair == pair )
- goto Found;
-
- if ( cpair < pair )
- base += probe;
- }
-
- p = base;
-
- if ( twobytes )
- cpair = FT_NEXT_ULONG( p );
- else
- cpair = PFR_NEXT_KPAIR( p );
-
- if ( cpair == pair )
- {
- FT_Int value;
-
-
- Found:
- if ( twobyte_adj )
- value = FT_PEEK_SHORT( p );
- else
- value = p[0];
-
- kerning->x = item->base_adj + value;
- }
- }
-
- FT_FRAME_EXIT();
- }
-
- Exit:
- return error;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/pfr/pfrobjs.h b/contrib/libs/freetype/src/pfr/pfrobjs.h
deleted file mode 100644
index 1b548a1bc2..0000000000
--- a/contrib/libs/freetype/src/pfr/pfrobjs.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/****************************************************************************
- *
- * pfrobjs.h
- *
- * FreeType PFR object methods (specification).
- *
- * Copyright (C) 2002-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef PFROBJS_H_
-#define PFROBJS_H_
-
-#include "pfrtypes.h"
-
-
-FT_BEGIN_HEADER
-
- typedef struct PFR_FaceRec_* PFR_Face;
-
- typedef struct PFR_SizeRec_* PFR_Size;
-
- typedef struct PFR_SlotRec_* PFR_Slot;
-
-
- typedef struct PFR_FaceRec_
- {
- FT_FaceRec root;
- PFR_HeaderRec header;
- PFR_LogFontRec log_font;
- PFR_PhyFontRec phy_font;
-
- } PFR_FaceRec;
-
-
- typedef struct PFR_SizeRec_
- {
- FT_SizeRec root;
-
- } PFR_SizeRec;
-
-
- typedef struct PFR_SlotRec_
- {
- FT_GlyphSlotRec root;
- PFR_GlyphRec glyph;
-
- } PFR_SlotRec;
-
-
- FT_LOCAL( FT_Error )
- pfr_face_init( FT_Stream stream,
- FT_Face face, /* PFR_Face */
- FT_Int face_index,
- FT_Int num_params,
- FT_Parameter* params );
-
- FT_LOCAL( void )
- pfr_face_done( FT_Face face ); /* PFR_Face */
-
-
- FT_LOCAL( FT_Error )
- pfr_face_get_kerning( FT_Face face, /* PFR_Face */
- FT_UInt glyph1,
- FT_UInt glyph2,
- FT_Vector* kerning );
-
-
- FT_LOCAL( FT_Error )
- pfr_slot_init( FT_GlyphSlot slot ); /* PFR_Slot */
-
- FT_LOCAL( void )
- pfr_slot_done( FT_GlyphSlot slot ); /* PFR_Slot */
-
-
- FT_LOCAL( FT_Error )
- pfr_slot_load( FT_GlyphSlot slot, /* PFR_Slot */
- FT_Size size, /* PFR_Size */
- FT_UInt gindex,
- FT_Int32 load_flags );
-
-
-FT_END_HEADER
-
-#endif /* PFROBJS_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/pfr/pfrsbit.c b/contrib/libs/freetype/src/pfr/pfrsbit.c
deleted file mode 100644
index 96cc7fecec..0000000000
--- a/contrib/libs/freetype/src/pfr/pfrsbit.c
+++ /dev/null
@@ -1,813 +0,0 @@
-/****************************************************************************
- *
- * pfrsbit.c
- *
- * FreeType PFR bitmap loader (body).
- *
- * Copyright (C) 2002-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include "pfrsbit.h"
-#include "pfrload.h"
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftstream.h>
-
-#include "pfrerror.h"
-
-#undef FT_COMPONENT
-#define FT_COMPONENT pfr
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** PFR BIT WRITER *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- typedef struct PFR_BitWriter_
- {
- FT_Byte* line; /* current line start */
- FT_Int pitch; /* line size in bytes */
- FT_UInt width; /* width in pixels/bits */
- FT_UInt rows; /* number of remaining rows to scan */
- FT_UInt total; /* total number of bits to draw */
-
- } PFR_BitWriterRec, *PFR_BitWriter;
-
-
- static void
- pfr_bitwriter_init( PFR_BitWriter writer,
- FT_Bitmap* target,
- FT_Bool decreasing )
- {
- writer->line = target->buffer;
- writer->pitch = target->pitch;
- writer->width = target->width;
- writer->rows = target->rows;
- writer->total = writer->width * writer->rows;
-
- if ( !decreasing )
- {
- writer->line += writer->pitch * (FT_Int)( target->rows - 1 );
- writer->pitch = -writer->pitch;
- }
- }
-
-
- static void
- pfr_bitwriter_decode_bytes( PFR_BitWriter writer,
- FT_Byte* p,
- FT_Byte* limit )
- {
- FT_UInt n, reload;
- FT_UInt left = writer->width;
- FT_Byte* cur = writer->line;
- FT_UInt mask = 0x80;
- FT_UInt val = 0;
- FT_UInt c = 0;
-
-
- n = (FT_UInt)( limit - p ) * 8;
- if ( n > writer->total )
- n = writer->total;
-
- reload = n & 7;
-
- for ( ; n > 0; n-- )
- {
- if ( ( n & 7 ) == reload )
- val = *p++;
-
- if ( val & 0x80 )
- c |= mask;
-
- val <<= 1;
- mask >>= 1;
-
- if ( --left <= 0 )
- {
- cur[0] = (FT_Byte)c;
- left = writer->width;
- mask = 0x80;
-
- writer->line += writer->pitch;
- cur = writer->line;
- c = 0;
- }
- else if ( mask == 0 )
- {
- cur[0] = (FT_Byte)c;
- mask = 0x80;
- c = 0;
- cur++;
- }
- }
-
- if ( mask != 0x80 )
- cur[0] = (FT_Byte)c;
- }
-
-
- static void
- pfr_bitwriter_decode_rle1( PFR_BitWriter writer,
- FT_Byte* p,
- FT_Byte* limit )
- {
- FT_Int phase, count, counts[2];
- FT_UInt n, reload;
- FT_UInt left = writer->width;
- FT_Byte* cur = writer->line;
- FT_UInt mask = 0x80;
- FT_UInt c = 0;
-
-
- n = writer->total;
-
- phase = 1;
- counts[0] = 0;
- counts[1] = 0;
- count = 0;
- reload = 1;
-
- for ( ; n > 0; n-- )
- {
- if ( reload )
- {
- do
- {
- if ( phase )
- {
- FT_Int v;
-
-
- if ( p >= limit )
- break;
-
- v = *p++;
- counts[0] = v >> 4;
- counts[1] = v & 15;
- phase = 0;
- count = counts[0];
- }
- else
- {
- phase = 1;
- count = counts[1];
- }
-
- } while ( count == 0 );
- }
-
- if ( phase )
- c |= mask;
-
- mask >>= 1;
-
- if ( --left <= 0 )
- {
- cur[0] = (FT_Byte)c;
- left = writer->width;
- mask = 0x80;
-
- writer->line += writer->pitch;
- cur = writer->line;
- c = 0;
- }
- else if ( mask == 0 )
- {
- cur[0] = (FT_Byte)c;
- mask = 0x80;
- c = 0;
- cur++;
- }
-
- reload = ( --count <= 0 );
- }
-
- if ( mask != 0x80 )
- cur[0] = (FT_Byte) c;
- }
-
-
- static void
- pfr_bitwriter_decode_rle2( PFR_BitWriter writer,
- FT_Byte* p,
- FT_Byte* limit )
- {
- FT_Int phase, count;
- FT_UInt n, reload;
- FT_UInt left = writer->width;
- FT_Byte* cur = writer->line;
- FT_UInt mask = 0x80;
- FT_UInt c = 0;
-
-
- n = writer->total;
-
- phase = 1;
- count = 0;
- reload = 1;
-
- for ( ; n > 0; n-- )
- {
- if ( reload )
- {
- do
- {
- if ( p >= limit )
- break;
-
- count = *p++;
- phase = phase ^ 1;
-
- } while ( count == 0 );
- }
-
- if ( phase )
- c |= mask;
-
- mask >>= 1;
-
- if ( --left <= 0 )
- {
- cur[0] = (FT_Byte)c;
- c = 0;
- mask = 0x80;
- left = writer->width;
-
- writer->line += writer->pitch;
- cur = writer->line;
- }
- else if ( mask == 0 )
- {
- cur[0] = (FT_Byte)c;
- c = 0;
- mask = 0x80;
- cur++;
- }
-
- reload = ( --count <= 0 );
- }
-
- if ( mask != 0x80 )
- cur[0] = (FT_Byte) c;
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** BITMAP DATA DECODING *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- static void
- pfr_lookup_bitmap_data( FT_Byte* base,
- FT_Byte* limit,
- FT_UInt count,
- FT_UInt* flags,
- FT_UInt char_code,
- FT_ULong* found_offset,
- FT_ULong* found_size )
- {
- FT_UInt min, max, mid, char_len;
- FT_Bool two = FT_BOOL( *flags & PFR_BITMAP_2BYTE_CHARCODE );
- FT_Byte* buff;
-
-
- char_len = 4;
- if ( two )
- char_len += 1;
- if ( *flags & PFR_BITMAP_2BYTE_SIZE )
- char_len += 1;
- if ( *flags & PFR_BITMAP_3BYTE_OFFSET )
- char_len += 1;
-
- if ( !( *flags & PFR_BITMAP_CHARCODES_VALIDATED ) )
- {
- FT_Byte* p;
- FT_Byte* lim;
- FT_UInt code;
- FT_Long prev_code;
-
-
- *flags |= PFR_BITMAP_VALID_CHARCODES;
- prev_code = -1;
- lim = base + count * char_len;
-
- if ( lim > limit )
- {
- FT_TRACE0(( "pfr_lookup_bitmap_data:"
- " number of bitmap records too large,\n" ));
- FT_TRACE0(( " "
- " thus ignoring all bitmaps in this strike\n" ));
- *flags &= ~PFR_BITMAP_VALID_CHARCODES;
- }
- else
- {
- /* check whether records are sorted by code */
- for ( p = base; p < lim; p += char_len )
- {
- if ( two )
- code = FT_PEEK_USHORT( p );
- else
- code = *p;
-
- if ( (FT_Long)code <= prev_code )
- {
- FT_TRACE0(( "pfr_lookup_bitmap_data:"
- " bitmap records are not sorted,\n" ));
- FT_TRACE0(( " "
- " thus ignoring all bitmaps in this strike\n" ));
- *flags &= ~PFR_BITMAP_VALID_CHARCODES;
- break;
- }
-
- prev_code = code;
- }
- }
-
- *flags |= PFR_BITMAP_CHARCODES_VALIDATED;
- }
-
- /* ignore bitmaps in case table is not valid */
- /* (this might be sanitized, but PFR is dead...) */
- if ( !( *flags & PFR_BITMAP_VALID_CHARCODES ) )
- goto Fail;
-
- min = 0;
- max = count;
- mid = min + ( max - min ) / 2;
-
- /* binary search */
- while ( min < max )
- {
- FT_UInt code;
-
-
- buff = base + mid * char_len;
-
- if ( two )
- code = PFR_NEXT_USHORT( buff );
- else
- code = PFR_NEXT_BYTE( buff );
-
- if ( char_code < code )
- max = mid;
- else if ( char_code > code )
- min = mid + 1;
- else
- goto Found_It;
-
- /* reasonable prediction in a continuous block */
- mid += char_code - code;
- if ( mid >= max || mid < min )
- mid = min + ( max - min ) / 2;
- }
-
- Fail:
- /* Not found */
- *found_size = 0;
- *found_offset = 0;
- return;
-
- Found_It:
- if ( *flags & PFR_BITMAP_2BYTE_SIZE )
- *found_size = PFR_NEXT_USHORT( buff );
- else
- *found_size = PFR_NEXT_BYTE( buff );
-
- if ( *flags & PFR_BITMAP_3BYTE_OFFSET )
- *found_offset = PFR_NEXT_ULONG( buff );
- else
- *found_offset = PFR_NEXT_USHORT( buff );
- }
-
-
- /* load bitmap metrics. `*aadvance' must be set to the default value */
- /* before calling this function */
- /* */
- static FT_Error
- pfr_load_bitmap_metrics( FT_Byte** pdata,
- FT_Byte* limit,
- FT_Long scaled_advance,
- FT_Long *axpos,
- FT_Long *aypos,
- FT_UInt *axsize,
- FT_UInt *aysize,
- FT_Long *aadvance,
- FT_UInt *aformat )
- {
- FT_Error error = FT_Err_Ok;
- FT_Byte flags;
- FT_Byte b;
- FT_Byte* p = *pdata;
- FT_Long xpos, ypos, advance;
- FT_UInt xsize, ysize;
-
-
- PFR_CHECK( 1 );
- flags = PFR_NEXT_BYTE( p );
-
- xpos = 0;
- ypos = 0;
- xsize = 0;
- ysize = 0;
- advance = 0;
-
- switch ( flags & 3 )
- {
- case 0:
- PFR_CHECK( 1 );
- b = PFR_NEXT_BYTE( p );
- xpos = (FT_Char)b >> 4;
- ypos = ( (FT_Char)( b << 4 ) ) >> 4;
- break;
-
- case 1:
- PFR_CHECK( 2 );
- xpos = PFR_NEXT_INT8( p );
- ypos = PFR_NEXT_INT8( p );
- break;
-
- case 2:
- PFR_CHECK( 4 );
- xpos = PFR_NEXT_SHORT( p );
- ypos = PFR_NEXT_SHORT( p );
- break;
-
- case 3:
- PFR_CHECK( 6 );
- xpos = PFR_NEXT_LONG( p );
- ypos = PFR_NEXT_LONG( p );
- break;
-
- default:
- ;
- }
-
- flags >>= 2;
- switch ( flags & 3 )
- {
- case 0:
- /* blank image */
- xsize = 0;
- ysize = 0;
- break;
-
- case 1:
- PFR_CHECK( 1 );
- b = PFR_NEXT_BYTE( p );
- xsize = ( b >> 4 ) & 0xF;
- ysize = b & 0xF;
- break;
-
- case 2:
- PFR_CHECK( 2 );
- xsize = PFR_NEXT_BYTE( p );
- ysize = PFR_NEXT_BYTE( p );
- break;
-
- case 3:
- PFR_CHECK( 4 );
- xsize = PFR_NEXT_USHORT( p );
- ysize = PFR_NEXT_USHORT( p );
- break;
-
- default:
- ;
- }
-
- flags >>= 2;
- switch ( flags & 3 )
- {
- case 0:
- advance = scaled_advance;
- break;
-
- case 1:
- PFR_CHECK( 1 );
- advance = PFR_NEXT_INT8( p ) * 256;
- break;
-
- case 2:
- PFR_CHECK( 2 );
- advance = PFR_NEXT_SHORT( p );
- break;
-
- case 3:
- PFR_CHECK( 3 );
- advance = PFR_NEXT_LONG( p );
- break;
-
- default:
- ;
- }
-
- *axpos = xpos;
- *aypos = ypos;
- *axsize = xsize;
- *aysize = ysize;
- *aadvance = advance;
- *aformat = flags >> 2;
- *pdata = p;
-
- Exit:
- return error;
-
- Too_Short:
- error = FT_THROW( Invalid_Table );
- FT_ERROR(( "pfr_load_bitmap_metrics: invalid glyph data\n" ));
- goto Exit;
- }
-
-
- static FT_Error
- pfr_load_bitmap_bits( FT_Byte* p,
- FT_Byte* limit,
- FT_UInt format,
- FT_Bool decreasing,
- FT_Bitmap* target )
- {
- FT_Error error = FT_Err_Ok;
- PFR_BitWriterRec writer;
-
-
- if ( target->rows > 0 && target->width > 0 )
- {
- pfr_bitwriter_init( &writer, target, decreasing );
-
- switch ( format )
- {
- case 0: /* packed bits */
- pfr_bitwriter_decode_bytes( &writer, p, limit );
- break;
-
- case 1: /* RLE1 */
- pfr_bitwriter_decode_rle1( &writer, p, limit );
- break;
-
- case 2: /* RLE2 */
- pfr_bitwriter_decode_rle2( &writer, p, limit );
- break;
-
- default:
- ;
- }
- }
-
- return error;
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** BITMAP LOADING *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- FT_LOCAL_DEF( FT_Error )
- pfr_slot_load_bitmap( PFR_Slot glyph,
- PFR_Size size,
- FT_UInt glyph_index,
- FT_Bool metrics_only )
- {
- FT_Error error;
- PFR_Face face = (PFR_Face) glyph->root.face;
- FT_Stream stream = face->root.stream;
- PFR_PhyFont phys = &face->phy_font;
- FT_ULong gps_offset;
- FT_ULong gps_size;
- PFR_Char character;
- PFR_Strike strike;
-
-
- character = &phys->chars[glyph_index];
-
- /* look up a bitmap strike corresponding to the current */
- /* character dimensions */
- {
- FT_UInt n;
-
-
- strike = phys->strikes;
- for ( n = 0; n < phys->num_strikes; n++ )
- {
- if ( strike->x_ppm == (FT_UInt)size->root.metrics.x_ppem &&
- strike->y_ppm == (FT_UInt)size->root.metrics.y_ppem )
- goto Found_Strike;
-
- strike++;
- }
-
- /* couldn't find it */
- return FT_THROW( Invalid_Argument );
- }
-
- Found_Strike:
-
- /* now look up the glyph's position within the file */
- {
- FT_UInt char_len;
-
-
- char_len = 4;
- if ( strike->flags & PFR_BITMAP_2BYTE_CHARCODE )
- char_len += 1;
- if ( strike->flags & PFR_BITMAP_2BYTE_SIZE )
- char_len += 1;
- if ( strike->flags & PFR_BITMAP_3BYTE_OFFSET )
- char_len += 1;
-
- /* access data directly in the frame to speed up lookups */
- if ( FT_STREAM_SEEK( phys->bct_offset + strike->bct_offset ) ||
- FT_FRAME_ENTER( char_len * strike->num_bitmaps ) )
- goto Exit;
-
- pfr_lookup_bitmap_data( stream->cursor,
- stream->limit,
- strike->num_bitmaps,
- &strike->flags,
- character->char_code,
- &gps_offset,
- &gps_size );
-
- FT_FRAME_EXIT();
-
- if ( gps_size == 0 )
- {
- /* could not find a bitmap program string for this glyph */
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
- }
-
- /* get the bitmap metrics */
- {
- FT_Long xpos = 0, ypos = 0, advance = 0;
- FT_UInt xsize = 0, ysize = 0, format = 0;
- FT_Byte* p;
-
-
- /* compute linear advance */
- advance = character->advance;
- if ( phys->metrics_resolution != phys->outline_resolution )
- advance = FT_MulDiv( advance,
- (FT_Long)phys->outline_resolution,
- (FT_Long)phys->metrics_resolution );
-
- glyph->root.linearHoriAdvance = advance;
-
- /* compute default advance, i.e., scaled advance; this can be */
- /* overridden in the bitmap header of certain glyphs */
- advance = FT_MulDiv( (FT_Fixed)size->root.metrics.x_ppem << 8,
- character->advance,
- (FT_Long)phys->metrics_resolution );
-
- if ( FT_STREAM_SEEK( face->header.gps_section_offset + gps_offset ) ||
- FT_FRAME_ENTER( gps_size ) )
- goto Exit;
-
- p = stream->cursor;
- error = pfr_load_bitmap_metrics( &p, stream->limit,
- advance,
- &xpos, &ypos,
- &xsize, &ysize,
- &advance, &format );
- if ( error )
- goto Exit1;
-
- /*
- * Before allocating the target bitmap, we check whether the given
- * bitmap dimensions are valid, depending on the image format.
- *
- * Format 0: We have a stream of pixels (with 8 pixels per byte).
- *
- * (xsize * ysize + 7) / 8 <= gps_size
- *
- * Format 1: Run-length encoding; the high nibble holds the number of
- * white bits, the low nibble the number of black bits. In
- * other words, a single byte can represent at most 15
- * pixels.
- *
- * xsize * ysize <= 15 * gps_size
- *
- * Format 2: Run-length encoding; the high byte holds the number of
- * white bits, the low byte the number of black bits. In
- * other words, two bytes can represent at most 255 pixels.
- *
- * xsize * ysize <= 255 * (gps_size + 1) / 2
- */
- switch ( format )
- {
- case 0:
- if ( ( (FT_ULong)xsize * ysize + 7 ) / 8 > gps_size )
- error = FT_THROW( Invalid_Table );
- break;
- case 1:
- if ( (FT_ULong)xsize * ysize > 15 * gps_size )
- error = FT_THROW( Invalid_Table );
- break;
- case 2:
- if ( (FT_ULong)xsize * ysize > 255 * ( ( gps_size + 1 ) / 2 ) )
- error = FT_THROW( Invalid_Table );
- break;
- default:
- FT_ERROR(( "pfr_slot_load_bitmap: invalid image type\n" ));
- error = FT_THROW( Invalid_Table );
- }
-
- if ( error )
- {
- if ( FT_ERR_EQ( error, Invalid_Table ) )
- FT_ERROR(( "pfr_slot_load_bitmap: invalid bitmap dimensions\n" ));
- goto Exit1;
- }
-
- /*
- * XXX: on 16bit systems we return an error for huge bitmaps
- * that cause size truncation, because truncated
- * size properties make bitmap glyphs broken.
- */
- if ( xpos > FT_INT_MAX ||
- xpos < FT_INT_MIN ||
- ysize > FT_INT_MAX ||
- ypos > FT_INT_MAX - (FT_Long)ysize ||
- ypos + (FT_Long)ysize < FT_INT_MIN )
- {
- FT_TRACE1(( "pfr_slot_load_bitmap:"
- " huge bitmap glyph %ldx%ld over FT_GlyphSlot\n",
- xpos, ypos ));
- error = FT_THROW( Invalid_Pixel_Size );
- }
-
- if ( !error )
- {
- glyph->root.format = FT_GLYPH_FORMAT_BITMAP;
-
- /* Set up glyph bitmap and metrics */
-
- /* XXX: needs casts to fit FT_Bitmap.{width|rows|pitch} */
- glyph->root.bitmap.width = xsize;
- glyph->root.bitmap.rows = ysize;
- glyph->root.bitmap.pitch = (FT_Int)( xsize + 7 ) >> 3;
- glyph->root.bitmap.pixel_mode = FT_PIXEL_MODE_MONO;
-
- /* XXX: needs casts to fit FT_Glyph_Metrics.{width|height} */
- glyph->root.metrics.width = (FT_Pos)xsize << 6;
- glyph->root.metrics.height = (FT_Pos)ysize << 6;
- glyph->root.metrics.horiBearingX = xpos * 64;
- glyph->root.metrics.horiBearingY = ypos * 64;
- glyph->root.metrics.horiAdvance = FT_PIX_ROUND( ( advance >> 2 ) );
- glyph->root.metrics.vertBearingX = - glyph->root.metrics.width >> 1;
- glyph->root.metrics.vertBearingY = 0;
- glyph->root.metrics.vertAdvance = size->root.metrics.height;
-
- /* XXX: needs casts fit FT_GlyphSlotRec.bitmap_{left|top} */
- glyph->root.bitmap_left = (FT_Int)xpos;
- glyph->root.bitmap_top = (FT_Int)( ypos + (FT_Long)ysize );
-
- if ( metrics_only )
- goto Exit1;
-
- /* Allocate and read bitmap data */
- {
- FT_ULong len = (FT_ULong)glyph->root.bitmap.pitch * ysize;
-
-
- error = ft_glyphslot_alloc_bitmap( &glyph->root, len );
- if ( !error )
- error = pfr_load_bitmap_bits(
- p,
- stream->limit,
- format,
- FT_BOOL( face->header.color_flags &
- PFR_FLAG_INVERT_BITMAP ),
- &glyph->root.bitmap );
- }
- }
-
- Exit1:
- FT_FRAME_EXIT();
- }
-
- Exit:
- return error;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/pfr/pfrsbit.h b/contrib/libs/freetype/src/pfr/pfrsbit.h
deleted file mode 100644
index 105a2991c2..0000000000
--- a/contrib/libs/freetype/src/pfr/pfrsbit.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/****************************************************************************
- *
- * pfrsbit.h
- *
- * FreeType PFR bitmap loader (specification).
- *
- * Copyright (C) 2002-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef PFRSBIT_H_
-#define PFRSBIT_H_
-
-#include "pfrobjs.h"
-
-FT_BEGIN_HEADER
-
- FT_LOCAL( FT_Error )
- pfr_slot_load_bitmap( PFR_Slot glyph,
- PFR_Size size,
- FT_UInt glyph_index,
- FT_Bool metrics_only );
-
-FT_END_HEADER
-
-#endif /* PFRSBIT_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/pfr/pfrtypes.h b/contrib/libs/freetype/src/pfr/pfrtypes.h
deleted file mode 100644
index 435a77c8f2..0000000000
--- a/contrib/libs/freetype/src/pfr/pfrtypes.h
+++ /dev/null
@@ -1,331 +0,0 @@
-/****************************************************************************
- *
- * pfrtypes.h
- *
- * FreeType PFR data structures (specification only).
- *
- * Copyright (C) 2002-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef PFRTYPES_H_
-#define PFRTYPES_H_
-
-#include <freetype/internal/ftobjs.h>
-
-FT_BEGIN_HEADER
-
- /************************************************************************/
-
- /* the PFR Header structure */
- typedef struct PFR_HeaderRec_
- {
- FT_UInt32 signature;
- FT_UInt version;
- FT_UInt signature2;
- FT_UInt header_size;
-
- FT_UInt log_dir_size;
- FT_UInt log_dir_offset;
-
- FT_UInt log_font_max_size;
- FT_UInt32 log_font_section_size;
- FT_UInt32 log_font_section_offset;
-
- FT_UInt32 phy_font_max_size;
- FT_UInt32 phy_font_section_size;
- FT_UInt32 phy_font_section_offset;
-
- FT_UInt gps_max_size;
- FT_UInt32 gps_section_size;
- FT_UInt32 gps_section_offset;
-
- FT_UInt max_blue_values;
- FT_UInt max_x_orus;
- FT_UInt max_y_orus;
-
- FT_UInt phy_font_max_size_high;
- FT_UInt color_flags;
-
- FT_UInt32 bct_max_size;
- FT_UInt32 bct_set_max_size;
- FT_UInt32 phy_bct_set_max_size;
-
- FT_UInt num_phy_fonts;
- FT_UInt max_vert_stem_snap;
- FT_UInt max_horz_stem_snap;
- FT_UInt max_chars;
-
- } PFR_HeaderRec, *PFR_Header;
-
-
- /* used in `color_flags' field of the PFR_Header */
-#define PFR_FLAG_BLACK_PIXEL 0x01U
-#define PFR_FLAG_INVERT_BITMAP 0x02U
-
-
- /************************************************************************/
-
- typedef struct PFR_LogFontRec_
- {
- FT_UInt32 size;
- FT_UInt32 offset;
-
- FT_Int32 matrix[4];
- FT_UInt stroke_flags;
- FT_Int stroke_thickness;
- FT_Int bold_thickness;
- FT_Int32 miter_limit;
-
- FT_UInt32 phys_size;
- FT_UInt32 phys_offset;
-
- } PFR_LogFontRec, *PFR_LogFont;
-
-
-#define PFR_LINE_JOIN_MITER 0x00U
-#define PFR_LINE_JOIN_ROUND 0x01U
-#define PFR_LINE_JOIN_BEVEL 0x02U
-#define PFR_LINE_JOIN_MASK ( PFR_LINE_JOIN_ROUND | PFR_LINE_JOIN_BEVEL )
-
-#define PFR_LOG_STROKE 0x04U
-#define PFR_LOG_2BYTE_STROKE 0x08U
-#define PFR_LOG_BOLD 0x10U
-#define PFR_LOG_2BYTE_BOLD 0x20U
-#define PFR_LOG_EXTRA_ITEMS 0x40U
-
-
- /************************************************************************/
-
-#define PFR_BITMAP_2BYTE_CHARCODE 0x01U
-#define PFR_BITMAP_2BYTE_SIZE 0x02U
-#define PFR_BITMAP_3BYTE_OFFSET 0x04U
-
- /* not part of the specification but used for implementation */
-#define PFR_BITMAP_CHARCODES_VALIDATED 0x40U
-#define PFR_BITMAP_VALID_CHARCODES 0x80U
-
-
- typedef struct PFR_BitmapCharRec_
- {
- FT_UInt char_code;
- FT_UInt gps_size;
- FT_UInt32 gps_offset;
-
- } PFR_BitmapCharRec, *PFR_BitmapChar;
-
-
-#define PFR_STRIKE_2BYTE_XPPM 0x01U
-#define PFR_STRIKE_2BYTE_YPPM 0x02U
-#define PFR_STRIKE_3BYTE_SIZE 0x04U
-#define PFR_STRIKE_3BYTE_OFFSET 0x08U
-#define PFR_STRIKE_2BYTE_COUNT 0x10U
-
-
- typedef struct PFR_StrikeRec_
- {
- FT_UInt x_ppm;
- FT_UInt y_ppm;
- FT_UInt flags;
-
- FT_UInt32 gps_size;
- FT_UInt32 gps_offset;
-
- FT_UInt32 bct_size;
- FT_UInt32 bct_offset;
-
- /* optional */
- FT_UInt num_bitmaps;
- PFR_BitmapChar bitmaps;
-
- } PFR_StrikeRec, *PFR_Strike;
-
-
- /************************************************************************/
-
- typedef struct PFR_CharRec_
- {
- FT_UInt char_code;
- FT_Int advance;
- FT_UInt gps_size;
- FT_UInt32 gps_offset;
-
- } PFR_CharRec, *PFR_Char;
-
-
- /************************************************************************/
-
- typedef struct PFR_DimensionRec_
- {
- FT_UInt standard;
- FT_UInt num_stem_snaps;
- FT_Int* stem_snaps;
-
- } PFR_DimensionRec, *PFR_Dimension;
-
- /************************************************************************/
-
- typedef struct PFR_KernItemRec_* PFR_KernItem;
-
- typedef struct PFR_KernItemRec_
- {
- PFR_KernItem next;
- FT_Byte pair_count;
- FT_Byte flags;
- FT_Short base_adj;
- FT_UInt pair_size;
- FT_Offset offset;
- FT_UInt32 pair1;
- FT_UInt32 pair2;
-
- } PFR_KernItemRec;
-
-
-#define PFR_KERN_INDEX( g1, g2 ) \
- ( ( (FT_UInt32)(g1) << 16 ) | (FT_UInt16)(g2) )
-
-#define PFR_KERN_PAIR_INDEX( pair ) \
- PFR_KERN_INDEX( (pair)->glyph1, (pair)->glyph2 )
-
-#define PFR_NEXT_KPAIR( p ) ( p += 2, \
- ( (FT_UInt32)p[-2] << 16 ) | p[-1] )
-
-
- /************************************************************************/
-
- typedef struct PFR_PhyFontRec_
- {
- FT_Memory memory;
- FT_UInt32 offset;
-
- FT_UInt font_ref_number;
- FT_UInt outline_resolution;
- FT_UInt metrics_resolution;
- FT_BBox bbox;
- FT_UInt flags;
- FT_Int standard_advance;
-
- FT_Int ascent; /* optional, bbox.yMax if not present */
- FT_Int descent; /* optional, bbox.yMin if not present */
- FT_Int leading; /* optional, 0 if not present */
-
- PFR_DimensionRec horizontal;
- PFR_DimensionRec vertical;
-
- FT_String* font_id;
- FT_String* family_name;
- FT_String* style_name;
-
- FT_UInt num_strikes;
- FT_UInt max_strikes;
- PFR_StrikeRec* strikes;
-
- FT_UInt num_blue_values;
- FT_Int *blue_values;
- FT_UInt blue_fuzz;
- FT_UInt blue_scale;
-
- FT_UInt num_chars;
- FT_Offset chars_offset;
- PFR_Char chars;
-
- FT_UInt num_kern_pairs;
- PFR_KernItem kern_items;
- PFR_KernItem* kern_items_tail;
-
- /* not part of the spec, but used during load */
- FT_ULong bct_offset;
- FT_Byte* cursor;
-
- } PFR_PhyFontRec, *PFR_PhyFont;
-
-
-#define PFR_PHY_VERTICAL 0x01U
-#define PFR_PHY_2BYTE_CHARCODE 0x02U
-#define PFR_PHY_PROPORTIONAL 0x04U
-#define PFR_PHY_ASCII_CODE 0x08U
-#define PFR_PHY_2BYTE_GPS_SIZE 0x10U
-#define PFR_PHY_3BYTE_GPS_OFFSET 0x20U
-#define PFR_PHY_EXTRA_ITEMS 0x80U
-
-
-#define PFR_KERN_2BYTE_CHAR 0x01U
-#define PFR_KERN_2BYTE_ADJ 0x02U
-
-
- /************************************************************************/
-
-#define PFR_GLYPH_YCOUNT 0x01U
-#define PFR_GLYPH_XCOUNT 0x02U
-#define PFR_GLYPH_1BYTE_XYCOUNT 0x04U
-
-#define PFR_GLYPH_SINGLE_EXTRA_ITEMS 0x08U
-#define PFR_GLYPH_COMPOUND_EXTRA_ITEMS 0x40U
-
-#define PFR_GLYPH_IS_COMPOUND 0x80U
-
-
- /* controlled coordinate */
- typedef struct PFR_CoordRec_
- {
- FT_UInt org;
- FT_UInt cur;
-
- } PFR_CoordRec, *PFR_Coord;
-
-
- typedef struct PFR_SubGlyphRec_
- {
- FT_Fixed x_scale;
- FT_Fixed y_scale;
- FT_Int x_delta;
- FT_Int y_delta;
- FT_UInt32 gps_offset;
- FT_UInt gps_size;
-
- } PFR_SubGlyphRec, *PFR_SubGlyph;
-
-
-#define PFR_SUBGLYPH_XSCALE 0x10U
-#define PFR_SUBGLYPH_YSCALE 0x20U
-#define PFR_SUBGLYPH_2BYTE_SIZE 0x40U
-#define PFR_SUBGLYPH_3BYTE_OFFSET 0x80U
-
-
- typedef struct PFR_GlyphRec_
- {
- FT_Byte format;
-
-#if 0
- FT_UInt num_x_control;
- FT_UInt num_y_control;
-#endif
- FT_UInt max_xy_control;
- FT_Pos* x_control;
- FT_Pos* y_control;
-
-
- FT_UInt num_subs;
- FT_UInt max_subs;
- PFR_SubGlyphRec* subs;
-
- FT_GlyphLoader loader;
- FT_Bool path_begun;
-
- } PFR_GlyphRec, *PFR_Glyph;
-
-
-FT_END_HEADER
-
-#endif /* PFRTYPES_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/psaux/afmparse.c b/contrib/libs/freetype/src/psaux/afmparse.c
deleted file mode 100644
index e2f6a8e5ad..0000000000
--- a/contrib/libs/freetype/src/psaux/afmparse.c
+++ /dev/null
@@ -1,1094 +0,0 @@
-/****************************************************************************
- *
- * afmparse.c
- *
- * AFM parser (body).
- *
- * Copyright (C) 2006-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-#include <freetype/freetype.h>
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/psaux.h>
-
-#ifndef T1_CONFIG_OPTION_NO_AFM
-
-#include "afmparse.h"
-#include "psconv.h"
-
-#include "psauxerr.h"
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT afmparse
-
-
- /**************************************************************************
- *
- * AFM_Stream
- *
- * The use of AFM_Stream is largely inspired by parseAFM.[ch] from t1lib.
- *
- */
-
- enum
- {
- AFM_STREAM_STATUS_NORMAL,
- AFM_STREAM_STATUS_EOC,
- AFM_STREAM_STATUS_EOL,
- AFM_STREAM_STATUS_EOF
- };
-
-
- typedef struct AFM_StreamRec_
- {
- FT_Byte* cursor;
- FT_Byte* base;
- FT_Byte* limit;
-
- FT_Int status;
-
- } AFM_StreamRec;
-
-
-#ifndef EOF
-#define EOF -1
-#endif
-
-
- /* this works because empty lines are ignored */
-#define AFM_IS_NEWLINE( ch ) ( (ch) == '\r' || (ch) == '\n' )
-
-#define AFM_IS_EOF( ch ) ( (ch) == EOF || (ch) == '\x1a' )
-#define AFM_IS_SPACE( ch ) ( (ch) == ' ' || (ch) == '\t' )
-
- /* column separator; there is no `column' in the spec actually */
-#define AFM_IS_SEP( ch ) ( (ch) == ';' )
-
-#define AFM_GETC() \
- ( ( (stream)->cursor < (stream)->limit ) ? *(stream)->cursor++ \
- : EOF )
-
-#define AFM_STREAM_KEY_BEGIN( stream ) \
- (char*)( (stream)->cursor - 1 )
-
-#define AFM_STREAM_KEY_LEN( stream, key ) \
- (FT_Offset)( (char*)(stream)->cursor - key - 1 )
-
-#define AFM_STATUS_EOC( stream ) \
- ( (stream)->status >= AFM_STREAM_STATUS_EOC )
-
-#define AFM_STATUS_EOL( stream ) \
- ( (stream)->status >= AFM_STREAM_STATUS_EOL )
-
-#define AFM_STATUS_EOF( stream ) \
- ( (stream)->status >= AFM_STREAM_STATUS_EOF )
-
-
- static int
- afm_stream_skip_spaces( AFM_Stream stream )
- {
- int ch = 0; /* make stupid compiler happy */
-
-
- if ( AFM_STATUS_EOC( stream ) )
- return ';';
-
- while ( 1 )
- {
- ch = AFM_GETC();
- if ( !AFM_IS_SPACE( ch ) )
- break;
- }
-
- if ( AFM_IS_NEWLINE( ch ) )
- stream->status = AFM_STREAM_STATUS_EOL;
- else if ( AFM_IS_SEP( ch ) )
- stream->status = AFM_STREAM_STATUS_EOC;
- else if ( AFM_IS_EOF( ch ) )
- stream->status = AFM_STREAM_STATUS_EOF;
-
- return ch;
- }
-
-
- /* read a key or value in current column */
- static char*
- afm_stream_read_one( AFM_Stream stream )
- {
- char* str;
-
-
- afm_stream_skip_spaces( stream );
- if ( AFM_STATUS_EOC( stream ) )
- return NULL;
-
- str = AFM_STREAM_KEY_BEGIN( stream );
-
- while ( 1 )
- {
- int ch = AFM_GETC();
-
-
- if ( AFM_IS_SPACE( ch ) )
- break;
- else if ( AFM_IS_NEWLINE( ch ) )
- {
- stream->status = AFM_STREAM_STATUS_EOL;
- break;
- }
- else if ( AFM_IS_SEP( ch ) )
- {
- stream->status = AFM_STREAM_STATUS_EOC;
- break;
- }
- else if ( AFM_IS_EOF( ch ) )
- {
- stream->status = AFM_STREAM_STATUS_EOF;
- break;
- }
- }
-
- return str;
- }
-
-
- /* read a string (i.e., read to EOL) */
- static char*
- afm_stream_read_string( AFM_Stream stream )
- {
- char* str;
-
-
- afm_stream_skip_spaces( stream );
- if ( AFM_STATUS_EOL( stream ) )
- return NULL;
-
- str = AFM_STREAM_KEY_BEGIN( stream );
-
- /* scan to eol */
- while ( 1 )
- {
- int ch = AFM_GETC();
-
-
- if ( AFM_IS_NEWLINE( ch ) )
- {
- stream->status = AFM_STREAM_STATUS_EOL;
- break;
- }
- else if ( AFM_IS_EOF( ch ) )
- {
- stream->status = AFM_STREAM_STATUS_EOF;
- break;
- }
- }
-
- return str;
- }
-
-
- /**************************************************************************
- *
- * AFM_Parser
- *
- */
-
- /* all keys defined in Ch. 7-10 of 5004.AFM_Spec.pdf */
- typedef enum AFM_Token_
- {
- AFM_TOKEN_ASCENDER,
- AFM_TOKEN_AXISLABEL,
- AFM_TOKEN_AXISTYPE,
- AFM_TOKEN_B,
- AFM_TOKEN_BLENDAXISTYPES,
- AFM_TOKEN_BLENDDESIGNMAP,
- AFM_TOKEN_BLENDDESIGNPOSITIONS,
- AFM_TOKEN_C,
- AFM_TOKEN_CC,
- AFM_TOKEN_CH,
- AFM_TOKEN_CAPHEIGHT,
- AFM_TOKEN_CHARWIDTH,
- AFM_TOKEN_CHARACTERSET,
- AFM_TOKEN_CHARACTERS,
- AFM_TOKEN_DESCENDER,
- AFM_TOKEN_ENCODINGSCHEME,
- AFM_TOKEN_ENDAXIS,
- AFM_TOKEN_ENDCHARMETRICS,
- AFM_TOKEN_ENDCOMPOSITES,
- AFM_TOKEN_ENDDIRECTION,
- AFM_TOKEN_ENDFONTMETRICS,
- AFM_TOKEN_ENDKERNDATA,
- AFM_TOKEN_ENDKERNPAIRS,
- AFM_TOKEN_ENDTRACKKERN,
- AFM_TOKEN_ESCCHAR,
- AFM_TOKEN_FAMILYNAME,
- AFM_TOKEN_FONTBBOX,
- AFM_TOKEN_FONTNAME,
- AFM_TOKEN_FULLNAME,
- AFM_TOKEN_ISBASEFONT,
- AFM_TOKEN_ISCIDFONT,
- AFM_TOKEN_ISFIXEDPITCH,
- AFM_TOKEN_ISFIXEDV,
- AFM_TOKEN_ITALICANGLE,
- AFM_TOKEN_KP,
- AFM_TOKEN_KPH,
- AFM_TOKEN_KPX,
- AFM_TOKEN_KPY,
- AFM_TOKEN_L,
- AFM_TOKEN_MAPPINGSCHEME,
- AFM_TOKEN_METRICSSETS,
- AFM_TOKEN_N,
- AFM_TOKEN_NOTICE,
- AFM_TOKEN_PCC,
- AFM_TOKEN_STARTAXIS,
- AFM_TOKEN_STARTCHARMETRICS,
- AFM_TOKEN_STARTCOMPOSITES,
- AFM_TOKEN_STARTDIRECTION,
- AFM_TOKEN_STARTFONTMETRICS,
- AFM_TOKEN_STARTKERNDATA,
- AFM_TOKEN_STARTKERNPAIRS,
- AFM_TOKEN_STARTKERNPAIRS0,
- AFM_TOKEN_STARTKERNPAIRS1,
- AFM_TOKEN_STARTTRACKKERN,
- AFM_TOKEN_STDHW,
- AFM_TOKEN_STDVW,
- AFM_TOKEN_TRACKKERN,
- AFM_TOKEN_UNDERLINEPOSITION,
- AFM_TOKEN_UNDERLINETHICKNESS,
- AFM_TOKEN_VV,
- AFM_TOKEN_VVECTOR,
- AFM_TOKEN_VERSION,
- AFM_TOKEN_W,
- AFM_TOKEN_W0,
- AFM_TOKEN_W0X,
- AFM_TOKEN_W0Y,
- AFM_TOKEN_W1,
- AFM_TOKEN_W1X,
- AFM_TOKEN_W1Y,
- AFM_TOKEN_WX,
- AFM_TOKEN_WY,
- AFM_TOKEN_WEIGHT,
- AFM_TOKEN_WEIGHTVECTOR,
- AFM_TOKEN_XHEIGHT,
- N_AFM_TOKENS,
- AFM_TOKEN_UNKNOWN
-
- } AFM_Token;
-
-
- static const char* const afm_key_table[N_AFM_TOKENS] =
- {
- "Ascender",
- "AxisLabel",
- "AxisType",
- "B",
- "BlendAxisTypes",
- "BlendDesignMap",
- "BlendDesignPositions",
- "C",
- "CC",
- "CH",
- "CapHeight",
- "CharWidth",
- "CharacterSet",
- "Characters",
- "Descender",
- "EncodingScheme",
- "EndAxis",
- "EndCharMetrics",
- "EndComposites",
- "EndDirection",
- "EndFontMetrics",
- "EndKernData",
- "EndKernPairs",
- "EndTrackKern",
- "EscChar",
- "FamilyName",
- "FontBBox",
- "FontName",
- "FullName",
- "IsBaseFont",
- "IsCIDFont",
- "IsFixedPitch",
- "IsFixedV",
- "ItalicAngle",
- "KP",
- "KPH",
- "KPX",
- "KPY",
- "L",
- "MappingScheme",
- "MetricsSets",
- "N",
- "Notice",
- "PCC",
- "StartAxis",
- "StartCharMetrics",
- "StartComposites",
- "StartDirection",
- "StartFontMetrics",
- "StartKernData",
- "StartKernPairs",
- "StartKernPairs0",
- "StartKernPairs1",
- "StartTrackKern",
- "StdHW",
- "StdVW",
- "TrackKern",
- "UnderlinePosition",
- "UnderlineThickness",
- "VV",
- "VVector",
- "Version",
- "W",
- "W0",
- "W0X",
- "W0Y",
- "W1",
- "W1X",
- "W1Y",
- "WX",
- "WY",
- "Weight",
- "WeightVector",
- "XHeight"
- };
-
-
- /*
- * `afm_parser_read_vals' and `afm_parser_next_key' provide
- * high-level operations to an AFM_Stream. The rest of the
- * parser functions should use them without accessing the
- * AFM_Stream directly.
- */
-
- FT_LOCAL_DEF( FT_Int )
- afm_parser_read_vals( AFM_Parser parser,
- AFM_Value vals,
- FT_Int n )
- {
- AFM_Stream stream = parser->stream;
- char* str;
- FT_Int i;
-
-
- if ( n > AFM_MAX_ARGUMENTS )
- return 0;
-
- for ( i = 0; i < n; i++ )
- {
- FT_Offset len;
- AFM_Value val = vals + i;
-
-
- if ( val->type == AFM_VALUE_TYPE_STRING )
- str = afm_stream_read_string( stream );
- else
- str = afm_stream_read_one( stream );
-
- if ( !str )
- break;
-
- len = AFM_STREAM_KEY_LEN( stream, str );
-
- switch ( val->type )
- {
- case AFM_VALUE_TYPE_STRING:
- case AFM_VALUE_TYPE_NAME:
- {
- FT_Memory memory = parser->memory;
- FT_Error error;
-
-
- if ( !FT_QALLOC( val->u.s, len + 1 ) )
- {
- ft_memcpy( val->u.s, str, len );
- val->u.s[len] = '\0';
- }
- }
- break;
-
- case AFM_VALUE_TYPE_FIXED:
- val->u.f = PS_Conv_ToFixed( (FT_Byte**)(void*)&str,
- (FT_Byte*)str + len, 0 );
- break;
-
- case AFM_VALUE_TYPE_INTEGER:
- val->u.i = PS_Conv_ToInt( (FT_Byte**)(void*)&str,
- (FT_Byte*)str + len );
- break;
-
- case AFM_VALUE_TYPE_BOOL:
- val->u.b = FT_BOOL( len == 4 &&
- !ft_strncmp( str, "true", 4 ) );
- break;
-
- case AFM_VALUE_TYPE_INDEX:
- if ( parser->get_index )
- val->u.i = parser->get_index( str, len, parser->user_data );
- else
- val->u.i = 0;
- break;
- }
- }
-
- return i;
- }
-
-
- FT_LOCAL_DEF( char* )
- afm_parser_next_key( AFM_Parser parser,
- FT_Bool line,
- FT_Offset* len )
- {
- AFM_Stream stream = parser->stream;
- char* key = NULL; /* make stupid compiler happy */
-
-
- if ( line )
- {
- while ( 1 )
- {
- /* skip current line */
- if ( !AFM_STATUS_EOL( stream ) )
- afm_stream_read_string( stream );
-
- stream->status = AFM_STREAM_STATUS_NORMAL;
- key = afm_stream_read_one( stream );
-
- /* skip empty line */
- if ( !key &&
- !AFM_STATUS_EOF( stream ) &&
- AFM_STATUS_EOL( stream ) )
- continue;
-
- break;
- }
- }
- else
- {
- while ( 1 )
- {
- /* skip current column */
- while ( !AFM_STATUS_EOC( stream ) )
- afm_stream_read_one( stream );
-
- stream->status = AFM_STREAM_STATUS_NORMAL;
- key = afm_stream_read_one( stream );
-
- /* skip empty column */
- if ( !key &&
- !AFM_STATUS_EOF( stream ) &&
- AFM_STATUS_EOC( stream ) )
- continue;
-
- break;
- }
- }
-
- if ( len )
- *len = ( key ) ? (FT_Offset)AFM_STREAM_KEY_LEN( stream, key )
- : 0;
-
- return key;
- }
-
-
- static AFM_Token
- afm_tokenize( const char* key,
- FT_Offset len )
- {
- int n;
-
-
- for ( n = 0; n < N_AFM_TOKENS; n++ )
- {
- if ( *( afm_key_table[n] ) == *key )
- {
- for ( ; n < N_AFM_TOKENS; n++ )
- {
- if ( *( afm_key_table[n] ) != *key )
- return AFM_TOKEN_UNKNOWN;
-
- if ( ft_strncmp( afm_key_table[n], key, len ) == 0 )
- return (AFM_Token) n;
- }
- }
- }
-
- return AFM_TOKEN_UNKNOWN;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- afm_parser_init( AFM_Parser parser,
- FT_Memory memory,
- FT_Byte* base,
- FT_Byte* limit )
- {
- AFM_Stream stream = NULL;
- FT_Error error;
-
-
- if ( FT_NEW( stream ) )
- return error;
-
- stream->cursor = stream->base = base;
- stream->limit = limit;
-
- /* don't skip the first line during the first call */
- stream->status = AFM_STREAM_STATUS_EOL;
-
- parser->memory = memory;
- parser->stream = stream;
- parser->FontInfo = NULL;
- parser->get_index = NULL;
-
- return FT_Err_Ok;
- }
-
-
- FT_LOCAL_DEF( void )
- afm_parser_done( AFM_Parser parser )
- {
- FT_Memory memory = parser->memory;
-
-
- FT_FREE( parser->stream );
- }
-
-
- static FT_Error
- afm_parser_read_int( AFM_Parser parser,
- FT_Int* aint )
- {
- AFM_ValueRec val;
-
-
- val.type = AFM_VALUE_TYPE_INTEGER;
-
- if ( afm_parser_read_vals( parser, &val, 1 ) == 1 )
- {
- *aint = val.u.i;
-
- return FT_Err_Ok;
- }
- else
- return FT_THROW( Syntax_Error );
- }
-
-
- static FT_Error
- afm_parse_track_kern( AFM_Parser parser )
- {
- AFM_FontInfo fi = parser->FontInfo;
- AFM_Stream stream = parser->stream;
- AFM_TrackKern tk;
-
- char* key;
- FT_Offset len;
- int n = -1;
- FT_Int tmp;
-
-
- if ( afm_parser_read_int( parser, &tmp ) )
- goto Fail;
-
- if ( tmp < 0 )
- {
- FT_ERROR(( "afm_parse_track_kern: invalid number of track kerns\n" ));
- goto Fail;
- }
-
- fi->NumTrackKern = (FT_UInt)tmp;
- FT_TRACE3(( "afm_parse_track_kern: %u track kern%s expected\n",
- fi->NumTrackKern,
- fi->NumTrackKern == 1 ? "" : "s" ));
-
- /* Rough sanity check: The minimum line length of the `TrackKern` */
- /* command is 20 characters (including the EOL character). */
- if ( (FT_ULong)( stream->limit - stream->cursor ) / 20 <
- fi->NumTrackKern )
- {
- FT_ERROR(( "afm_parse_track_kern:"
- " number of track kern entries exceeds stream size\n" ));
- goto Fail;
- }
-
- if ( fi->NumTrackKern )
- {
- FT_Memory memory = parser->memory;
- FT_Error error;
-
-
- if ( FT_QNEW_ARRAY( fi->TrackKerns, fi->NumTrackKern ) )
- return error;
- }
-
- while ( ( key = afm_parser_next_key( parser, 1, &len ) ) != 0 )
- {
- AFM_ValueRec shared_vals[5];
-
-
- switch ( afm_tokenize( key, len ) )
- {
- case AFM_TOKEN_TRACKKERN:
- n++;
-
- if ( n >= (int)fi->NumTrackKern )
- {
- FT_ERROR(( "afm_parse_track_kern: too many track kern data\n" ));
- goto Fail;
- }
-
- tk = fi->TrackKerns + n;
-
- shared_vals[0].type = AFM_VALUE_TYPE_INTEGER;
- shared_vals[1].type = AFM_VALUE_TYPE_FIXED;
- shared_vals[2].type = AFM_VALUE_TYPE_FIXED;
- shared_vals[3].type = AFM_VALUE_TYPE_FIXED;
- shared_vals[4].type = AFM_VALUE_TYPE_FIXED;
- if ( afm_parser_read_vals( parser, shared_vals, 5 ) != 5 )
- {
- FT_ERROR(( "afm_parse_track_kern:"
- " insufficient number of parameters for entry %d\n",
- n ));
- goto Fail;
- }
-
- tk->degree = shared_vals[0].u.i;
- tk->min_ptsize = shared_vals[1].u.f;
- tk->min_kern = shared_vals[2].u.f;
- tk->max_ptsize = shared_vals[3].u.f;
- tk->max_kern = shared_vals[4].u.f;
-
- break;
-
- case AFM_TOKEN_ENDTRACKKERN:
- case AFM_TOKEN_ENDKERNDATA:
- case AFM_TOKEN_ENDFONTMETRICS:
- tmp = n + 1;
- if ( (FT_UInt)tmp != fi->NumTrackKern )
- {
- FT_TRACE1(( "afm_parse_track_kern: %s%d track kern entr%s seen\n",
- tmp == 0 ? "" : "only ",
- tmp,
- tmp == 1 ? "y" : "ies" ));
- fi->NumTrackKern = (FT_UInt)tmp;
- }
- else
- FT_TRACE3(( "afm_parse_track_kern: %d track kern entr%s seen\n",
- tmp,
- tmp == 1 ? "y" : "ies" ));
- return FT_Err_Ok;
-
- case AFM_TOKEN_UNKNOWN:
- break;
-
- default:
- goto Fail;
- }
- }
-
- Fail:
- return FT_THROW( Syntax_Error );
- }
-
-
-#undef KERN_INDEX
-#define KERN_INDEX( g1, g2 ) ( ( (FT_ULong)g1 << 16 ) | g2 )
-
-
- /* compare two kerning pairs */
- FT_COMPARE_DEF( int )
- afm_compare_kern_pairs( const void* a,
- const void* b )
- {
- AFM_KernPair kp1 = (AFM_KernPair)a;
- AFM_KernPair kp2 = (AFM_KernPair)b;
-
- FT_ULong index1 = KERN_INDEX( kp1->index1, kp1->index2 );
- FT_ULong index2 = KERN_INDEX( kp2->index1, kp2->index2 );
-
-
- if ( index1 > index2 )
- return 1;
- else if ( index1 < index2 )
- return -1;
- else
- return 0;
- }
-
-
- static FT_Error
- afm_parse_kern_pairs( AFM_Parser parser )
- {
- AFM_FontInfo fi = parser->FontInfo;
- AFM_Stream stream = parser->stream;
- AFM_KernPair kp;
- char* key;
- FT_Offset len;
- int n = -1;
- FT_Int tmp;
-
-
- if ( afm_parser_read_int( parser, &tmp ) )
- goto Fail;
-
- if ( tmp < 0 )
- {
- FT_ERROR(( "afm_parse_kern_pairs: invalid number of kern pairs\n" ));
- goto Fail;
- }
-
- fi->NumKernPair = (FT_UInt)tmp;
- FT_TRACE3(( "afm_parse_kern_pairs: %u kern pair%s expected\n",
- fi->NumKernPair,
- fi->NumKernPair == 1 ? "" : "s" ));
-
- /* Rough sanity check: The minimum line length of the `KP`, */
- /* `KPH`,`KPX`, and `KPY` commands is 10 characters (including */
- /* the EOL character). */
- if ( (FT_ULong)( stream->limit - stream->cursor ) / 10 <
- fi->NumKernPair )
- {
- FT_ERROR(( "afm_parse_kern_pairs:"
- " number of kern pairs exceeds stream size\n" ));
- goto Fail;
- }
-
- if ( fi->NumKernPair )
- {
- FT_Memory memory = parser->memory;
- FT_Error error;
-
-
- if ( FT_QNEW_ARRAY( fi->KernPairs, fi->NumKernPair ) )
- return error;
- }
-
- while ( ( key = afm_parser_next_key( parser, 1, &len ) ) != 0 )
- {
- AFM_Token token = afm_tokenize( key, len );
-
-
- switch ( token )
- {
- case AFM_TOKEN_KP:
- case AFM_TOKEN_KPX:
- case AFM_TOKEN_KPY:
- {
- FT_Int r;
- AFM_ValueRec shared_vals[4];
-
-
- n++;
-
- if ( n >= (int)fi->NumKernPair )
- {
- FT_ERROR(( "afm_parse_kern_pairs: too many kern pairs\n" ));
- goto Fail;
- }
-
- kp = fi->KernPairs + n;
-
- shared_vals[0].type = AFM_VALUE_TYPE_INDEX;
- shared_vals[1].type = AFM_VALUE_TYPE_INDEX;
- shared_vals[2].type = AFM_VALUE_TYPE_INTEGER;
- shared_vals[3].type = AFM_VALUE_TYPE_INTEGER;
- r = afm_parser_read_vals( parser, shared_vals, 4 );
- if ( r < 3 )
- {
- FT_ERROR(( "afm_parse_kern_pairs:"
- " insufficient number of parameters for entry %d\n",
- n ));
- goto Fail;
- }
-
- /* index values can't be negative */
- kp->index1 = shared_vals[0].u.u;
- kp->index2 = shared_vals[1].u.u;
- if ( token == AFM_TOKEN_KPY )
- {
- kp->x = 0;
- kp->y = shared_vals[2].u.i;
- }
- else
- {
- kp->x = shared_vals[2].u.i;
- kp->y = ( token == AFM_TOKEN_KP && r == 4 )
- ? shared_vals[3].u.i : 0;
- }
- }
- break;
-
- case AFM_TOKEN_ENDKERNPAIRS:
- case AFM_TOKEN_ENDKERNDATA:
- case AFM_TOKEN_ENDFONTMETRICS:
- tmp = n + 1;
- if ( (FT_UInt)tmp != fi->NumKernPair )
- {
- FT_TRACE1(( "afm_parse_kern_pairs: %s%d kern pair%s seen\n",
- tmp == 0 ? "" : "only ",
- tmp,
- tmp == 1 ? "" : "s" ));
- fi->NumKernPair = (FT_UInt)tmp;
- }
- else
- FT_TRACE3(( "afm_parse_kern_pairs: %d kern pair%s seen\n",
- tmp,
- tmp == 1 ? "" : "s" ));
-
- ft_qsort( fi->KernPairs, fi->NumKernPair,
- sizeof ( AFM_KernPairRec ),
- afm_compare_kern_pairs );
- return FT_Err_Ok;
-
- case AFM_TOKEN_UNKNOWN:
- break;
-
- default:
- goto Fail;
- }
- }
-
- Fail:
- return FT_THROW( Syntax_Error );
- }
-
-
- static FT_Error
- afm_parse_kern_data( AFM_Parser parser )
- {
- FT_Error error;
- char* key;
- FT_Offset len;
-
- int have_trackkern = 0;
- int have_kernpairs = 0;
-
-
- while ( ( key = afm_parser_next_key( parser, 1, &len ) ) != 0 )
- {
- switch ( afm_tokenize( key, len ) )
- {
- case AFM_TOKEN_STARTTRACKKERN:
- if ( have_trackkern )
- {
- FT_ERROR(( "afm_parse_kern_data:"
- " invalid second horizontal track kern section\n" ));
- goto Fail;
- }
-
- error = afm_parse_track_kern( parser );
- if ( error )
- return error;
-
- have_trackkern = 1;
- break;
-
- case AFM_TOKEN_STARTKERNPAIRS:
- case AFM_TOKEN_STARTKERNPAIRS0:
- if ( have_kernpairs )
- {
- FT_ERROR(( "afm_parse_kern_data:"
- " invalid second horizontal kern pair section\n" ));
- goto Fail;
- }
-
- error = afm_parse_kern_pairs( parser );
- if ( error )
- return error;
-
- have_kernpairs = 1;
- break;
-
- case AFM_TOKEN_ENDKERNDATA:
- case AFM_TOKEN_ENDFONTMETRICS:
- return FT_Err_Ok;
-
- case AFM_TOKEN_UNKNOWN:
- break;
-
- default:
- goto Fail;
- }
- }
-
- Fail:
- return FT_THROW( Syntax_Error );
- }
-
-
- static FT_Error
- afm_parser_skip_section( AFM_Parser parser,
- FT_Int n,
- AFM_Token end_section )
- {
- char* key;
- FT_Offset len;
-
-
- while ( n-- > 0 )
- {
- key = afm_parser_next_key( parser, 1, NULL );
- if ( !key )
- goto Fail;
- }
-
- while ( ( key = afm_parser_next_key( parser, 1, &len ) ) != 0 )
- {
- AFM_Token token = afm_tokenize( key, len );
-
-
- if ( token == end_section || token == AFM_TOKEN_ENDFONTMETRICS )
- return FT_Err_Ok;
- }
-
- Fail:
- return FT_THROW( Syntax_Error );
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- afm_parser_parse( AFM_Parser parser )
- {
- FT_Memory memory = parser->memory;
- AFM_FontInfo fi = parser->FontInfo;
- FT_Error error = FT_ERR( Syntax_Error );
- char* key;
- FT_Offset len;
- FT_Int metrics_sets = 0;
-
-
- if ( !fi )
- return FT_THROW( Invalid_Argument );
-
- key = afm_parser_next_key( parser, 1, &len );
- if ( !key || len != 16 ||
- ft_strncmp( key, "StartFontMetrics", 16 ) != 0 )
- return FT_THROW( Unknown_File_Format );
-
- while ( ( key = afm_parser_next_key( parser, 1, &len ) ) != 0 )
- {
- AFM_ValueRec shared_vals[4];
-
-
- switch ( afm_tokenize( key, len ) )
- {
- case AFM_TOKEN_METRICSSETS:
- if ( afm_parser_read_int( parser, &metrics_sets ) )
- goto Fail;
-
- if ( metrics_sets != 0 && metrics_sets != 2 )
- {
- error = FT_THROW( Unimplemented_Feature );
-
- goto Fail;
- }
- break;
-
- case AFM_TOKEN_ISCIDFONT:
- shared_vals[0].type = AFM_VALUE_TYPE_BOOL;
- if ( afm_parser_read_vals( parser, shared_vals, 1 ) != 1 )
- goto Fail;
-
- fi->IsCIDFont = shared_vals[0].u.b;
- break;
-
- case AFM_TOKEN_FONTBBOX:
- shared_vals[0].type = AFM_VALUE_TYPE_FIXED;
- shared_vals[1].type = AFM_VALUE_TYPE_FIXED;
- shared_vals[2].type = AFM_VALUE_TYPE_FIXED;
- shared_vals[3].type = AFM_VALUE_TYPE_FIXED;
- if ( afm_parser_read_vals( parser, shared_vals, 4 ) != 4 )
- goto Fail;
-
- fi->FontBBox.xMin = shared_vals[0].u.f;
- fi->FontBBox.yMin = shared_vals[1].u.f;
- fi->FontBBox.xMax = shared_vals[2].u.f;
- fi->FontBBox.yMax = shared_vals[3].u.f;
- break;
-
- case AFM_TOKEN_ASCENDER:
- shared_vals[0].type = AFM_VALUE_TYPE_FIXED;
- if ( afm_parser_read_vals( parser, shared_vals, 1 ) != 1 )
- goto Fail;
-
- fi->Ascender = shared_vals[0].u.f;
- break;
-
- case AFM_TOKEN_DESCENDER:
- shared_vals[0].type = AFM_VALUE_TYPE_FIXED;
- if ( afm_parser_read_vals( parser, shared_vals, 1 ) != 1 )
- goto Fail;
-
- fi->Descender = shared_vals[0].u.f;
- break;
-
- case AFM_TOKEN_STARTCHARMETRICS:
- {
- FT_Int n = 0;
-
-
- if ( afm_parser_read_int( parser, &n ) )
- goto Fail;
-
- error = afm_parser_skip_section( parser, n,
- AFM_TOKEN_ENDCHARMETRICS );
- if ( error )
- return error;
- }
- break;
-
- case AFM_TOKEN_STARTKERNDATA:
- error = afm_parse_kern_data( parser );
- if ( error )
- goto Fail;
- /* we only support kern data, so ... */
- FALL_THROUGH;
-
- case AFM_TOKEN_ENDFONTMETRICS:
- return FT_Err_Ok;
-
- default:
- break;
- }
- }
-
- Fail:
- FT_FREE( fi->TrackKerns );
- fi->NumTrackKern = 0;
-
- FT_FREE( fi->KernPairs );
- fi->NumKernPair = 0;
-
- fi->IsCIDFont = 0;
-
- return error;
- }
-
-#else /* T1_CONFIG_OPTION_NO_AFM */
-
- /* ANSI C doesn't like empty source files */
- typedef int afm_parse_dummy_;
-
-#endif /* T1_CONFIG_OPTION_NO_AFM */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/psaux/afmparse.h b/contrib/libs/freetype/src/psaux/afmparse.h
deleted file mode 100644
index b776637282..0000000000
--- a/contrib/libs/freetype/src/psaux/afmparse.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/****************************************************************************
- *
- * afmparse.h
- *
- * AFM parser (specification).
- *
- * Copyright (C) 2006-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef AFMPARSE_H_
-#define AFMPARSE_H_
-
-
-#include <freetype/internal/psaux.h>
-
-
-FT_BEGIN_HEADER
-
-
- FT_LOCAL( FT_Error )
- afm_parser_init( AFM_Parser parser,
- FT_Memory memory,
- FT_Byte* base,
- FT_Byte* limit );
-
-
- FT_LOCAL( void )
- afm_parser_done( AFM_Parser parser );
-
-
- FT_LOCAL( FT_Error )
- afm_parser_parse( AFM_Parser parser );
-
-
- enum AFM_ValueType_
- {
- AFM_VALUE_TYPE_STRING,
- AFM_VALUE_TYPE_NAME,
- AFM_VALUE_TYPE_FIXED, /* real number */
- AFM_VALUE_TYPE_INTEGER,
- AFM_VALUE_TYPE_BOOL,
- AFM_VALUE_TYPE_INDEX /* glyph index */
- };
-
-
- typedef struct AFM_ValueRec_
- {
- enum AFM_ValueType_ type;
- union
- {
- char* s;
- FT_Fixed f;
- FT_Int i;
- FT_UInt u;
- FT_Bool b;
-
- } u;
-
- } AFM_ValueRec, *AFM_Value;
-
-#define AFM_MAX_ARGUMENTS 5
-
- FT_LOCAL( FT_Int )
- afm_parser_read_vals( AFM_Parser parser,
- AFM_Value vals,
- FT_Int n );
-
- /* read the next key from the next line or column */
- FT_LOCAL( char* )
- afm_parser_next_key( AFM_Parser parser,
- FT_Bool line,
- FT_Offset* len );
-
-FT_END_HEADER
-
-#endif /* AFMPARSE_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/psaux/cffdecode.c b/contrib/libs/freetype/src/psaux/cffdecode.c
deleted file mode 100644
index 9556e11a58..0000000000
--- a/contrib/libs/freetype/src/psaux/cffdecode.c
+++ /dev/null
@@ -1,2411 +0,0 @@
-/****************************************************************************
- *
- * cffdecode.c
- *
- * PostScript CFF (Type 2) decoding routines (body).
- *
- * Copyright (C) 2017-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/freetype.h>
-#include <freetype/internal/ftcalc.h>
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftserv.h>
-#include <freetype/internal/services/svcfftl.h>
-
-#include "cffdecode.h"
-#include "psobjs.h"
-
-#include "psauxerr.h"
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT cffdecode
-
-
-#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
-
- typedef enum CFF_Operator_
- {
- cff_op_unknown = 0,
-
- cff_op_rmoveto,
- cff_op_hmoveto,
- cff_op_vmoveto,
-
- cff_op_rlineto,
- cff_op_hlineto,
- cff_op_vlineto,
-
- cff_op_rrcurveto,
- cff_op_hhcurveto,
- cff_op_hvcurveto,
- cff_op_rcurveline,
- cff_op_rlinecurve,
- cff_op_vhcurveto,
- cff_op_vvcurveto,
-
- cff_op_flex,
- cff_op_hflex,
- cff_op_hflex1,
- cff_op_flex1,
-
- cff_op_endchar,
-
- cff_op_hstem,
- cff_op_vstem,
- cff_op_hstemhm,
- cff_op_vstemhm,
-
- cff_op_hintmask,
- cff_op_cntrmask,
- cff_op_dotsection, /* deprecated, acts as no-op */
-
- cff_op_abs,
- cff_op_add,
- cff_op_sub,
- cff_op_div,
- cff_op_neg,
- cff_op_random,
- cff_op_mul,
- cff_op_sqrt,
-
- cff_op_blend,
-
- cff_op_drop,
- cff_op_exch,
- cff_op_index,
- cff_op_roll,
- cff_op_dup,
-
- cff_op_put,
- cff_op_get,
- cff_op_store,
- cff_op_load,
-
- cff_op_and,
- cff_op_or,
- cff_op_not,
- cff_op_eq,
- cff_op_ifelse,
-
- cff_op_callsubr,
- cff_op_callgsubr,
- cff_op_return,
-
- /* Type 1 opcodes: invalid but seen in real life */
- cff_op_hsbw,
- cff_op_closepath,
- cff_op_callothersubr,
- cff_op_pop,
- cff_op_seac,
- cff_op_sbw,
- cff_op_setcurrentpoint,
-
- /* do not remove */
- cff_op_max
-
- } CFF_Operator;
-
-
-#define CFF_COUNT_CHECK_WIDTH 0x80
-#define CFF_COUNT_EXACT 0x40
-#define CFF_COUNT_CLEAR_STACK 0x20
-
- /* count values which have the `CFF_COUNT_CHECK_WIDTH' flag set are */
- /* used for checking the width and requested numbers of arguments */
- /* only; they are set to zero afterwards */
-
- /* the other two flags are informative only and unused currently */
-
- static const FT_Byte cff_argument_counts[] =
- {
- 0, /* unknown */
-
- 2 | CFF_COUNT_CHECK_WIDTH | CFF_COUNT_EXACT, /* rmoveto */
- 1 | CFF_COUNT_CHECK_WIDTH | CFF_COUNT_EXACT,
- 1 | CFF_COUNT_CHECK_WIDTH | CFF_COUNT_EXACT,
-
- 0 | CFF_COUNT_CLEAR_STACK, /* rlineto */
- 0 | CFF_COUNT_CLEAR_STACK,
- 0 | CFF_COUNT_CLEAR_STACK,
-
- 0 | CFF_COUNT_CLEAR_STACK, /* rrcurveto */
- 0 | CFF_COUNT_CLEAR_STACK,
- 0 | CFF_COUNT_CLEAR_STACK,
- 0 | CFF_COUNT_CLEAR_STACK,
- 0 | CFF_COUNT_CLEAR_STACK,
- 0 | CFF_COUNT_CLEAR_STACK,
- 0 | CFF_COUNT_CLEAR_STACK,
-
- 13, /* flex */
- 7,
- 9,
- 11,
-
- 0 | CFF_COUNT_CHECK_WIDTH, /* endchar */
-
- 2 | CFF_COUNT_CHECK_WIDTH, /* hstem */
- 2 | CFF_COUNT_CHECK_WIDTH,
- 2 | CFF_COUNT_CHECK_WIDTH,
- 2 | CFF_COUNT_CHECK_WIDTH,
-
- 0 | CFF_COUNT_CHECK_WIDTH, /* hintmask */
- 0 | CFF_COUNT_CHECK_WIDTH, /* cntrmask */
- 0, /* dotsection */
-
- 1, /* abs */
- 2,
- 2,
- 2,
- 1,
- 0,
- 2,
- 1,
-
- 1, /* blend */
-
- 1, /* drop */
- 2,
- 1,
- 2,
- 1,
-
- 2, /* put */
- 1,
- 4,
- 3,
-
- 2, /* and */
- 2,
- 1,
- 2,
- 4,
-
- 1, /* callsubr */
- 1,
- 0,
-
- 2, /* hsbw */
- 0,
- 0,
- 0,
- 5, /* seac */
- 4, /* sbw */
- 2 /* setcurrentpoint */
- };
-
-
- static FT_Error
- cff_operator_seac( CFF_Decoder* decoder,
- FT_Pos asb,
- FT_Pos adx,
- FT_Pos ady,
- FT_Int bchar,
- FT_Int achar )
- {
- FT_Error error;
- CFF_Builder* builder = &decoder->builder;
- FT_Int bchar_index, achar_index;
- TT_Face face = decoder->builder.face;
- FT_Vector left_bearing, advance;
- FT_Byte* charstring;
- FT_ULong charstring_len;
- FT_Pos glyph_width;
-
-
- if ( decoder->seac )
- {
- FT_ERROR(( "cff_operator_seac: invalid nested seac\n" ));
- return FT_THROW( Syntax_Error );
- }
-
- adx = ADD_LONG( adx, decoder->builder.left_bearing.x );
- ady = ADD_LONG( ady, decoder->builder.left_bearing.y );
-
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- /* Incremental fonts don't necessarily have valid charsets. */
- /* They use the character code, not the glyph index, in this case. */
- if ( face->root.internal->incremental_interface )
- {
- bchar_index = bchar;
- achar_index = achar;
- }
- else
-#endif /* FT_CONFIG_OPTION_INCREMENTAL */
- {
- CFF_Font cff = (CFF_Font)( face->extra.data );
-
-
- bchar_index = cff_lookup_glyph_by_stdcharcode( cff, bchar );
- achar_index = cff_lookup_glyph_by_stdcharcode( cff, achar );
- }
-
- if ( bchar_index < 0 || achar_index < 0 )
- {
- FT_ERROR(( "cff_operator_seac:"
- " invalid seac character code arguments\n" ));
- return FT_THROW( Syntax_Error );
- }
-
- /* If we are trying to load a composite glyph, do not load the */
- /* accent character and return the array of subglyphs. */
- if ( builder->no_recurse )
- {
- FT_GlyphSlot glyph = (FT_GlyphSlot)builder->glyph;
- FT_GlyphLoader loader = glyph->internal->loader;
- FT_SubGlyph subg;
-
-
- /* reallocate subglyph array if necessary */
- error = FT_GlyphLoader_CheckSubGlyphs( loader, 2 );
- if ( error )
- goto Exit;
-
- subg = loader->current.subglyphs;
-
- /* subglyph 0 = base character */
- subg->index = bchar_index;
- subg->flags = FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES |
- FT_SUBGLYPH_FLAG_USE_MY_METRICS;
- subg->arg1 = 0;
- subg->arg2 = 0;
- subg++;
-
- /* subglyph 1 = accent character */
- subg->index = achar_index;
- subg->flags = FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES;
- subg->arg1 = (FT_Int)( adx >> 16 );
- subg->arg2 = (FT_Int)( ady >> 16 );
-
- /* set up remaining glyph fields */
- glyph->num_subglyphs = 2;
- glyph->subglyphs = loader->base.subglyphs;
- glyph->format = FT_GLYPH_FORMAT_COMPOSITE;
-
- loader->current.num_subglyphs = 2;
- }
-
- FT_GlyphLoader_Prepare( builder->loader );
-
- /* First load `bchar' in builder */
- error = decoder->get_glyph_callback( face, (FT_UInt)bchar_index,
- &charstring, &charstring_len );
- if ( !error )
- {
- /* the seac operator must not be nested */
- decoder->seac = TRUE;
- error = cff_decoder_parse_charstrings( decoder, charstring,
- charstring_len, 0 );
- decoder->seac = FALSE;
-
- decoder->free_glyph_callback( face, &charstring, charstring_len );
-
- if ( error )
- goto Exit;
- }
-
- /* Save the left bearing, advance and glyph width of the base */
- /* character as they will be erased by the next load. */
-
- left_bearing = builder->left_bearing;
- advance = builder->advance;
- glyph_width = decoder->glyph_width;
-
- builder->left_bearing.x = 0;
- builder->left_bearing.y = 0;
-
- builder->pos_x = SUB_LONG( adx, asb );
- builder->pos_y = ady;
-
- /* Now load `achar' on top of the base outline. */
- error = decoder->get_glyph_callback( face, (FT_UInt)achar_index,
- &charstring, &charstring_len );
- if ( !error )
- {
- /* the seac operator must not be nested */
- decoder->seac = TRUE;
- error = cff_decoder_parse_charstrings( decoder, charstring,
- charstring_len, 0 );
- decoder->seac = FALSE;
-
- decoder->free_glyph_callback( face, &charstring, charstring_len );
-
- if ( error )
- goto Exit;
- }
-
- /* Restore the left side bearing, advance and glyph width */
- /* of the base character. */
- builder->left_bearing = left_bearing;
- builder->advance = advance;
- decoder->glyph_width = glyph_width;
-
- builder->pos_x = 0;
- builder->pos_y = 0;
-
- Exit:
- return error;
- }
-
-#endif /* CFF_CONFIG_OPTION_OLD_ENGINE */
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /********** *********/
- /********** *********/
- /********** GENERIC CHARSTRING PARSING *********/
- /********** *********/
- /********** *********/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
- /**************************************************************************
- *
- * @Function:
- * cff_compute_bias
- *
- * @Description:
- * Computes the bias value in dependence of the number of glyph
- * subroutines.
- *
- * @Input:
- * in_charstring_type ::
- * The `CharstringType' value of the top DICT
- * dictionary.
- *
- * num_subrs ::
- * The number of glyph subroutines.
- *
- * @Return:
- * The bias value.
- */
- static FT_Int
- cff_compute_bias( FT_Int in_charstring_type,
- FT_UInt num_subrs )
- {
- FT_Int result;
-
-
- if ( in_charstring_type == 1 )
- result = 0;
- else if ( num_subrs < 1240 )
- result = 107;
- else if ( num_subrs < 33900U )
- result = 1131;
- else
- result = 32768U;
-
- return result;
- }
-
-
- FT_LOCAL_DEF( FT_Int )
- cff_lookup_glyph_by_stdcharcode( CFF_Font cff,
- FT_Int charcode )
- {
- FT_UInt n;
- FT_UShort glyph_sid;
-
- FT_Service_CFFLoad cffload;
-
-
- /* CID-keyed fonts don't have glyph names */
- if ( !cff->charset.sids )
- return -1;
-
- /* check range of standard char code */
- if ( charcode < 0 || charcode > 255 )
- return -1;
-
-#if 0
- /* retrieve cffload from list of current modules */
- FT_Service_CFFLoad cffload;
-
-
- FT_FACE_FIND_GLOBAL_SERVICE( face, cffload, CFF_LOAD );
- if ( !cffload )
- {
- FT_ERROR(( "cff_lookup_glyph_by_stdcharcode:"
- " the `cffload' module is not available\n" ));
- return FT_THROW( Unimplemented_Feature );
- }
-#endif
-
- cffload = (FT_Service_CFFLoad)cff->cffload;
-
- /* Get code to SID mapping from `cff_standard_encoding'. */
- glyph_sid = cffload->get_standard_encoding( (FT_UInt)charcode );
-
- for ( n = 0; n < cff->num_glyphs; n++ )
- {
- if ( cff->charset.sids[n] == glyph_sid )
- return (FT_Int)n;
- }
-
- return -1;
- }
-
-
-#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
-
- /**************************************************************************
- *
- * @Function:
- * cff_decoder_parse_charstrings
- *
- * @Description:
- * Parses a given Type 2 charstrings program.
- *
- * @InOut:
- * decoder ::
- * The current Type 1 decoder.
- *
- * @Input:
- * charstring_base ::
- * The base of the charstring stream.
- *
- * charstring_len ::
- * The length in bytes of the charstring stream.
- *
- * in_dict ::
- * Set to 1 if function is called from top or
- * private DICT (needed for Multiple Master CFFs).
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
- FT_LOCAL_DEF( FT_Error )
- cff_decoder_parse_charstrings( CFF_Decoder* decoder,
- FT_Byte* charstring_base,
- FT_ULong charstring_len,
- FT_Bool in_dict )
- {
- FT_Error error;
- CFF_Decoder_Zone* zone;
- FT_Byte* ip;
- FT_Byte* limit;
- CFF_Builder* builder = &decoder->builder;
- FT_Pos x, y;
- FT_Fixed* stack;
- FT_Int charstring_type =
- decoder->cff->top_font.font_dict.charstring_type;
- FT_UShort num_designs =
- decoder->cff->top_font.font_dict.num_designs;
- FT_UShort num_axes =
- decoder->cff->top_font.font_dict.num_axes;
-
- T2_Hints_Funcs hinter;
-
-
- /* set default width */
- decoder->num_hints = 0;
- decoder->read_width = 1;
-
- /* initialize the decoder */
- decoder->top = decoder->stack;
- decoder->zone = decoder->zones;
- zone = decoder->zones;
- stack = decoder->top;
-
- hinter = (T2_Hints_Funcs)builder->hints_funcs;
-
- builder->path_begun = 0;
-
- if ( !charstring_base )
- return FT_Err_Ok;
-
- zone->base = charstring_base;
- limit = zone->limit = charstring_base + charstring_len;
- ip = zone->cursor = zone->base;
-
- error = FT_Err_Ok;
-
- x = builder->pos_x;
- y = builder->pos_y;
-
- /* begin hints recording session, if any */
- if ( hinter )
- hinter->open( hinter->hints );
-
- /* now execute loop */
- while ( ip < limit )
- {
- CFF_Operator op;
- FT_Byte v;
-
-
- /*********************************************************************
- *
- * Decode operator or operand
- */
- v = *ip++;
- if ( v >= 32 || v == 28 )
- {
- FT_Int shift = 16;
- FT_Int32 val;
-
-
- /* this is an operand, push it on the stack */
-
- /* if we use shifts, all computations are done with unsigned */
- /* values; the conversion to a signed value is the last step */
- if ( v == 28 )
- {
- if ( ip + 1 >= limit )
- goto Syntax_Error;
- val = (FT_Short)( ( (FT_UShort)ip[0] << 8 ) | ip[1] );
- ip += 2;
- }
- else if ( v < 247 )
- val = (FT_Int32)v - 139;
- else if ( v < 251 )
- {
- if ( ip >= limit )
- goto Syntax_Error;
- val = ( (FT_Int32)v - 247 ) * 256 + *ip++ + 108;
- }
- else if ( v < 255 )
- {
- if ( ip >= limit )
- goto Syntax_Error;
- val = -( (FT_Int32)v - 251 ) * 256 - *ip++ - 108;
- }
- else
- {
- if ( ip + 3 >= limit )
- goto Syntax_Error;
- val = (FT_Int32)( ( (FT_UInt32)ip[0] << 24 ) |
- ( (FT_UInt32)ip[1] << 16 ) |
- ( (FT_UInt32)ip[2] << 8 ) |
- (FT_UInt32)ip[3] );
- ip += 4;
- if ( charstring_type == 2 )
- shift = 0;
- }
- if ( decoder->top - stack >= CFF_MAX_OPERANDS )
- goto Stack_Overflow;
-
- val = (FT_Int32)( (FT_UInt32)val << shift );
- *decoder->top++ = val;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( !( val & 0xFFFFL ) )
- FT_TRACE4(( " %hd", (FT_Short)( (FT_UInt32)val >> 16 ) ));
- else
- FT_TRACE4(( " %.5f", val / 65536.0 ));
-#endif
-
- }
- else
- {
- /* The specification says that normally arguments are to be taken */
- /* from the bottom of the stack. However, this seems not to be */
- /* correct, at least for Acroread 7.0.8 on GNU/Linux: It pops the */
- /* arguments similar to a PS interpreter. */
-
- FT_Fixed* args = decoder->top;
- FT_Int num_args = (FT_Int)( args - decoder->stack );
- FT_Int req_args;
-
-
- /* find operator */
- op = cff_op_unknown;
-
- switch ( v )
- {
- case 1:
- op = cff_op_hstem;
- break;
- case 3:
- op = cff_op_vstem;
- break;
- case 4:
- op = cff_op_vmoveto;
- break;
- case 5:
- op = cff_op_rlineto;
- break;
- case 6:
- op = cff_op_hlineto;
- break;
- case 7:
- op = cff_op_vlineto;
- break;
- case 8:
- op = cff_op_rrcurveto;
- break;
- case 9:
- op = cff_op_closepath;
- break;
- case 10:
- op = cff_op_callsubr;
- break;
- case 11:
- op = cff_op_return;
- break;
- case 12:
- if ( ip >= limit )
- goto Syntax_Error;
- v = *ip++;
-
- switch ( v )
- {
- case 0:
- op = cff_op_dotsection;
- break;
- case 1: /* this is actually the Type1 vstem3 operator */
- op = cff_op_vstem;
- break;
- case 2: /* this is actually the Type1 hstem3 operator */
- op = cff_op_hstem;
- break;
- case 3:
- op = cff_op_and;
- break;
- case 4:
- op = cff_op_or;
- break;
- case 5:
- op = cff_op_not;
- break;
- case 6:
- op = cff_op_seac;
- break;
- case 7:
- op = cff_op_sbw;
- break;
- case 8:
- op = cff_op_store;
- break;
- case 9:
- op = cff_op_abs;
- break;
- case 10:
- op = cff_op_add;
- break;
- case 11:
- op = cff_op_sub;
- break;
- case 12:
- op = cff_op_div;
- break;
- case 13:
- op = cff_op_load;
- break;
- case 14:
- op = cff_op_neg;
- break;
- case 15:
- op = cff_op_eq;
- break;
- case 16:
- op = cff_op_callothersubr;
- break;
- case 17:
- op = cff_op_pop;
- break;
- case 18:
- op = cff_op_drop;
- break;
- case 20:
- op = cff_op_put;
- break;
- case 21:
- op = cff_op_get;
- break;
- case 22:
- op = cff_op_ifelse;
- break;
- case 23:
- op = cff_op_random;
- break;
- case 24:
- op = cff_op_mul;
- break;
- case 26:
- op = cff_op_sqrt;
- break;
- case 27:
- op = cff_op_dup;
- break;
- case 28:
- op = cff_op_exch;
- break;
- case 29:
- op = cff_op_index;
- break;
- case 30:
- op = cff_op_roll;
- break;
- case 33:
- op = cff_op_setcurrentpoint;
- break;
- case 34:
- op = cff_op_hflex;
- break;
- case 35:
- op = cff_op_flex;
- break;
- case 36:
- op = cff_op_hflex1;
- break;
- case 37:
- op = cff_op_flex1;
- break;
- default:
- FT_TRACE4(( " unknown op (12, %d)\n", v ));
- break;
- }
- break;
- case 13:
- op = cff_op_hsbw;
- break;
- case 14:
- op = cff_op_endchar;
- break;
- case 16:
- op = cff_op_blend;
- break;
- case 18:
- op = cff_op_hstemhm;
- break;
- case 19:
- op = cff_op_hintmask;
- break;
- case 20:
- op = cff_op_cntrmask;
- break;
- case 21:
- op = cff_op_rmoveto;
- break;
- case 22:
- op = cff_op_hmoveto;
- break;
- case 23:
- op = cff_op_vstemhm;
- break;
- case 24:
- op = cff_op_rcurveline;
- break;
- case 25:
- op = cff_op_rlinecurve;
- break;
- case 26:
- op = cff_op_vvcurveto;
- break;
- case 27:
- op = cff_op_hhcurveto;
- break;
- case 29:
- op = cff_op_callgsubr;
- break;
- case 30:
- op = cff_op_vhcurveto;
- break;
- case 31:
- op = cff_op_hvcurveto;
- break;
- default:
- FT_TRACE4(( " unknown op (%d)\n", v ));
- break;
- }
-
- if ( op == cff_op_unknown )
- continue;
-
- /* in Multiple Master CFFs, T2 charstrings can appear in */
- /* dictionaries, but some operators are prohibited */
- if ( in_dict )
- {
- switch ( op )
- {
- case cff_op_hstem:
- case cff_op_vstem:
- case cff_op_vmoveto:
- case cff_op_rlineto:
- case cff_op_hlineto:
- case cff_op_vlineto:
- case cff_op_rrcurveto:
- case cff_op_hstemhm:
- case cff_op_hintmask:
- case cff_op_cntrmask:
- case cff_op_rmoveto:
- case cff_op_hmoveto:
- case cff_op_vstemhm:
- case cff_op_rcurveline:
- case cff_op_rlinecurve:
- case cff_op_vvcurveto:
- case cff_op_hhcurveto:
- case cff_op_vhcurveto:
- case cff_op_hvcurveto:
- case cff_op_hflex:
- case cff_op_flex:
- case cff_op_hflex1:
- case cff_op_flex1:
- case cff_op_callsubr:
- case cff_op_callgsubr:
- /* deprecated opcodes */
- case cff_op_dotsection:
- /* invalid Type 1 opcodes */
- case cff_op_hsbw:
- case cff_op_closepath:
- case cff_op_callothersubr:
- case cff_op_seac:
- case cff_op_sbw:
- case cff_op_setcurrentpoint:
- goto MM_Error;
-
- default:
- break;
- }
- }
-
- /* check arguments */
- req_args = cff_argument_counts[op];
- if ( req_args & CFF_COUNT_CHECK_WIDTH )
- {
- if ( num_args > 0 && decoder->read_width )
- {
- /* If `nominal_width' is non-zero, the number is really a */
- /* difference against `nominal_width'. Else, the number here */
- /* is truly a width, not a difference against `nominal_width'. */
- /* If the font does not set `nominal_width', then */
- /* `nominal_width' defaults to zero, and so we can set */
- /* `glyph_width' to `nominal_width' plus number on the stack */
- /* -- for either case. */
-
- FT_Int set_width_ok;
-
-
- switch ( op )
- {
- case cff_op_hmoveto:
- case cff_op_vmoveto:
- set_width_ok = num_args & 2;
- break;
-
- case cff_op_hstem:
- case cff_op_vstem:
- case cff_op_hstemhm:
- case cff_op_vstemhm:
- case cff_op_rmoveto:
- case cff_op_hintmask:
- case cff_op_cntrmask:
- set_width_ok = num_args & 1;
- break;
-
- case cff_op_endchar:
- /* If there is a width specified for endchar, we either have */
- /* 1 argument or 5 arguments. We like to argue. */
- set_width_ok = in_dict
- ? 0
- : ( ( num_args == 5 ) || ( num_args == 1 ) );
- break;
-
- default:
- set_width_ok = 0;
- break;
- }
-
- if ( set_width_ok )
- {
- decoder->glyph_width = decoder->nominal_width +
- ( stack[0] >> 16 );
-
- if ( decoder->width_only )
- {
- /* we only want the advance width; stop here */
- break;
- }
-
- /* Consumed an argument. */
- num_args--;
- }
- }
-
- decoder->read_width = 0;
- req_args = 0;
- }
-
- req_args &= 0x000F;
- if ( num_args < req_args )
- goto Stack_Underflow;
- args -= req_args;
- num_args -= req_args;
-
- /* At this point, `args' points to the first argument of the */
- /* operand in case `req_args' isn't zero. Otherwise, we have */
- /* to adjust `args' manually. */
-
- /* Note that we only pop arguments from the stack which we */
- /* really need and can digest so that we can continue in case */
- /* of superfluous stack elements. */
-
- switch ( op )
- {
- case cff_op_hstem:
- case cff_op_vstem:
- case cff_op_hstemhm:
- case cff_op_vstemhm:
- /* the number of arguments is always even here */
- FT_TRACE4(( "%s\n",
- op == cff_op_hstem ? " hstem" :
- ( op == cff_op_vstem ? " vstem" :
- ( op == cff_op_hstemhm ? " hstemhm" : " vstemhm" ) ) ));
-
- if ( hinter )
- hinter->stems( hinter->hints,
- ( op == cff_op_hstem || op == cff_op_hstemhm ),
- num_args / 2,
- args - ( num_args & ~1 ) );
-
- decoder->num_hints += num_args / 2;
- args = stack;
- break;
-
- case cff_op_hintmask:
- case cff_op_cntrmask:
- FT_TRACE4(( "%s", op == cff_op_hintmask ? " hintmask"
- : " cntrmask" ));
-
- /* implement vstem when needed -- */
- /* the specification doesn't say it, but this also works */
- /* with the 'cntrmask' operator */
- /* */
- if ( num_args > 0 )
- {
- if ( hinter )
- hinter->stems( hinter->hints,
- 0,
- num_args / 2,
- args - ( num_args & ~1 ) );
-
- decoder->num_hints += num_args / 2;
- }
-
- /* In a valid charstring there must be at least one byte */
- /* after `hintmask' or `cntrmask' (e.g., for a `return' */
- /* instruction). Additionally, there must be space for */
- /* `num_hints' bits. */
-
- if ( ( ip + ( ( decoder->num_hints + 7 ) >> 3 ) ) >= limit )
- goto Syntax_Error;
-
- if ( hinter )
- {
- if ( op == cff_op_hintmask )
- hinter->hintmask( hinter->hints,
- (FT_UInt)builder->current->n_points,
- (FT_UInt)decoder->num_hints,
- ip );
- else
- hinter->counter( hinter->hints,
- (FT_UInt)decoder->num_hints,
- ip );
- }
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- {
- FT_UInt maskbyte;
-
-
- FT_TRACE4(( " (maskbytes:" ));
-
- for ( maskbyte = 0;
- maskbyte < (FT_UInt)( ( decoder->num_hints + 7 ) >> 3 );
- maskbyte++, ip++ )
- FT_TRACE4(( " 0x%02X", *ip ));
-
- FT_TRACE4(( ")\n" ));
- }
-#else
- ip += ( decoder->num_hints + 7 ) >> 3;
-#endif
- args = stack;
- break;
-
- case cff_op_rmoveto:
- FT_TRACE4(( " rmoveto\n" ));
-
- cff_builder_close_contour( builder );
- builder->path_begun = 0;
- x = ADD_LONG( x, args[-2] );
- y = ADD_LONG( y, args[-1] );
- args = stack;
- break;
-
- case cff_op_vmoveto:
- FT_TRACE4(( " vmoveto\n" ));
-
- cff_builder_close_contour( builder );
- builder->path_begun = 0;
- y = ADD_LONG( y, args[-1] );
- args = stack;
- break;
-
- case cff_op_hmoveto:
- FT_TRACE4(( " hmoveto\n" ));
-
- cff_builder_close_contour( builder );
- builder->path_begun = 0;
- x = ADD_LONG( x, args[-1] );
- args = stack;
- break;
-
- case cff_op_rlineto:
- FT_TRACE4(( " rlineto\n" ));
-
- if ( cff_builder_start_point( builder, x, y ) ||
- cff_check_points( builder, num_args / 2 ) )
- goto Fail;
-
- if ( num_args < 2 )
- goto Stack_Underflow;
-
- args -= num_args & ~1;
- while ( args < decoder->top )
- {
- x = ADD_LONG( x, args[0] );
- y = ADD_LONG( y, args[1] );
- cff_builder_add_point( builder, x, y, 1 );
- args += 2;
- }
- args = stack;
- break;
-
- case cff_op_hlineto:
- case cff_op_vlineto:
- {
- FT_Int phase = ( op == cff_op_hlineto );
-
-
- FT_TRACE4(( "%s\n", op == cff_op_hlineto ? " hlineto"
- : " vlineto" ));
-
- if ( num_args < 0 )
- goto Stack_Underflow;
-
- /* there exist subsetted fonts (found in PDFs) */
- /* which call `hlineto' without arguments */
- if ( num_args == 0 )
- break;
-
- if ( cff_builder_start_point( builder, x, y ) ||
- cff_check_points( builder, num_args ) )
- goto Fail;
-
- args = stack;
- while ( args < decoder->top )
- {
- if ( phase )
- x = ADD_LONG( x, args[0] );
- else
- y = ADD_LONG( y, args[0] );
-
- if ( cff_builder_add_point1( builder, x, y ) )
- goto Fail;
-
- args++;
- phase ^= 1;
- }
- args = stack;
- }
- break;
-
- case cff_op_rrcurveto:
- {
- FT_Int nargs;
-
-
- FT_TRACE4(( " rrcurveto\n" ));
-
- if ( num_args < 6 )
- goto Stack_Underflow;
-
- nargs = num_args - num_args % 6;
-
- if ( cff_builder_start_point( builder, x, y ) ||
- cff_check_points( builder, nargs / 2 ) )
- goto Fail;
-
- args -= nargs;
- while ( args < decoder->top )
- {
- x = ADD_LONG( x, args[0] );
- y = ADD_LONG( y, args[1] );
- cff_builder_add_point( builder, x, y, 0 );
-
- x = ADD_LONG( x, args[2] );
- y = ADD_LONG( y, args[3] );
- cff_builder_add_point( builder, x, y, 0 );
-
- x = ADD_LONG( x, args[4] );
- y = ADD_LONG( y, args[5] );
- cff_builder_add_point( builder, x, y, 1 );
-
- args += 6;
- }
- args = stack;
- }
- break;
-
- case cff_op_vvcurveto:
- {
- FT_Int nargs;
-
-
- FT_TRACE4(( " vvcurveto\n" ));
-
- if ( num_args < 4 )
- goto Stack_Underflow;
-
- /* if num_args isn't of the form 4n or 4n+1, */
- /* we enforce it by clearing the second bit */
-
- nargs = num_args & ~2;
-
- if ( cff_builder_start_point( builder, x, y ) )
- goto Fail;
-
- args -= nargs;
-
- if ( nargs & 1 )
- {
- x = ADD_LONG( x, args[0] );
- args++;
- nargs--;
- }
-
- if ( cff_check_points( builder, 3 * ( nargs / 4 ) ) )
- goto Fail;
-
- while ( args < decoder->top )
- {
- y = ADD_LONG( y, args[0] );
- cff_builder_add_point( builder, x, y, 0 );
-
- x = ADD_LONG( x, args[1] );
- y = ADD_LONG( y, args[2] );
- cff_builder_add_point( builder, x, y, 0 );
-
- y = ADD_LONG( y, args[3] );
- cff_builder_add_point( builder, x, y, 1 );
-
- args += 4;
- }
- args = stack;
- }
- break;
-
- case cff_op_hhcurveto:
- {
- FT_Int nargs;
-
-
- FT_TRACE4(( " hhcurveto\n" ));
-
- if ( num_args < 4 )
- goto Stack_Underflow;
-
- /* if num_args isn't of the form 4n or 4n+1, */
- /* we enforce it by clearing the second bit */
-
- nargs = num_args & ~2;
-
- if ( cff_builder_start_point( builder, x, y ) )
- goto Fail;
-
- args -= nargs;
- if ( nargs & 1 )
- {
- y = ADD_LONG( y, args[0] );
- args++;
- nargs--;
- }
-
- if ( cff_check_points( builder, 3 * ( nargs / 4 ) ) )
- goto Fail;
-
- while ( args < decoder->top )
- {
- x = ADD_LONG( x, args[0] );
- cff_builder_add_point( builder, x, y, 0 );
-
- x = ADD_LONG( x, args[1] );
- y = ADD_LONG( y, args[2] );
- cff_builder_add_point( builder, x, y, 0 );
-
- x = ADD_LONG( x, args[3] );
- cff_builder_add_point( builder, x, y, 1 );
-
- args += 4;
- }
- args = stack;
- }
- break;
-
- case cff_op_vhcurveto:
- case cff_op_hvcurveto:
- {
- FT_Int phase;
- FT_Int nargs;
-
-
- FT_TRACE4(( "%s\n", op == cff_op_vhcurveto ? " vhcurveto"
- : " hvcurveto" ));
-
- if ( cff_builder_start_point( builder, x, y ) )
- goto Fail;
-
- if ( num_args < 4 )
- goto Stack_Underflow;
-
- /* if num_args isn't of the form 8n, 8n+1, 8n+4, or 8n+5, */
- /* we enforce it by clearing the second bit */
-
- nargs = num_args & ~2;
-
- args -= nargs;
- if ( cff_check_points( builder, ( nargs / 4 ) * 3 ) )
- goto Stack_Underflow;
-
- phase = ( op == cff_op_hvcurveto );
-
- while ( nargs >= 4 )
- {
- nargs -= 4;
- if ( phase )
- {
- x = ADD_LONG( x, args[0] );
- cff_builder_add_point( builder, x, y, 0 );
-
- x = ADD_LONG( x, args[1] );
- y = ADD_LONG( y, args[2] );
- cff_builder_add_point( builder, x, y, 0 );
-
- y = ADD_LONG( y, args[3] );
- if ( nargs == 1 )
- x = ADD_LONG( x, args[4] );
- cff_builder_add_point( builder, x, y, 1 );
- }
- else
- {
- y = ADD_LONG( y, args[0] );
- cff_builder_add_point( builder, x, y, 0 );
-
- x = ADD_LONG( x, args[1] );
- y = ADD_LONG( y, args[2] );
- cff_builder_add_point( builder, x, y, 0 );
-
- x = ADD_LONG( x, args[3] );
- if ( nargs == 1 )
- y = ADD_LONG( y, args[4] );
- cff_builder_add_point( builder, x, y, 1 );
- }
- args += 4;
- phase ^= 1;
- }
- args = stack;
- }
- break;
-
- case cff_op_rlinecurve:
- {
- FT_Int num_lines;
- FT_Int nargs;
-
-
- FT_TRACE4(( " rlinecurve\n" ));
-
- if ( num_args < 8 )
- goto Stack_Underflow;
-
- nargs = num_args & ~1;
- num_lines = ( nargs - 6 ) / 2;
-
- if ( cff_builder_start_point( builder, x, y ) ||
- cff_check_points( builder, num_lines + 3 ) )
- goto Fail;
-
- args -= nargs;
-
- /* first, add the line segments */
- while ( num_lines > 0 )
- {
- x = ADD_LONG( x, args[0] );
- y = ADD_LONG( y, args[1] );
- cff_builder_add_point( builder, x, y, 1 );
-
- args += 2;
- num_lines--;
- }
-
- /* then the curve */
- x = ADD_LONG( x, args[0] );
- y = ADD_LONG( y, args[1] );
- cff_builder_add_point( builder, x, y, 0 );
-
- x = ADD_LONG( x, args[2] );
- y = ADD_LONG( y, args[3] );
- cff_builder_add_point( builder, x, y, 0 );
-
- x = ADD_LONG( x, args[4] );
- y = ADD_LONG( y, args[5] );
- cff_builder_add_point( builder, x, y, 1 );
-
- args = stack;
- }
- break;
-
- case cff_op_rcurveline:
- {
- FT_Int num_curves;
- FT_Int nargs;
-
-
- FT_TRACE4(( " rcurveline\n" ));
-
- if ( num_args < 8 )
- goto Stack_Underflow;
-
- nargs = num_args - 2;
- nargs = nargs - nargs % 6 + 2;
- num_curves = ( nargs - 2 ) / 6;
-
- if ( cff_builder_start_point( builder, x, y ) ||
- cff_check_points( builder, num_curves * 3 + 2 ) )
- goto Fail;
-
- args -= nargs;
-
- /* first, add the curves */
- while ( num_curves > 0 )
- {
- x = ADD_LONG( x, args[0] );
- y = ADD_LONG( y, args[1] );
- cff_builder_add_point( builder, x, y, 0 );
-
- x = ADD_LONG( x, args[2] );
- y = ADD_LONG( y, args[3] );
- cff_builder_add_point( builder, x, y, 0 );
-
- x = ADD_LONG( x, args[4] );
- y = ADD_LONG( y, args[5] );
- cff_builder_add_point( builder, x, y, 1 );
-
- args += 6;
- num_curves--;
- }
-
- /* then the final line */
- x = ADD_LONG( x, args[0] );
- y = ADD_LONG( y, args[1] );
- cff_builder_add_point( builder, x, y, 1 );
-
- args = stack;
- }
- break;
-
- case cff_op_hflex1:
- {
- FT_Pos start_y;
-
-
- FT_TRACE4(( " hflex1\n" ));
-
- /* adding five more points: 4 control points, 1 on-curve point */
- /* -- make sure we have enough space for the start point if it */
- /* needs to be added */
- if ( cff_builder_start_point( builder, x, y ) ||
- cff_check_points( builder, 6 ) )
- goto Fail;
-
- /* record the starting point's y position for later use */
- start_y = y;
-
- /* first control point */
- x = ADD_LONG( x, args[0] );
- y = ADD_LONG( y, args[1] );
- cff_builder_add_point( builder, x, y, 0 );
-
- /* second control point */
- x = ADD_LONG( x, args[2] );
- y = ADD_LONG( y, args[3] );
- cff_builder_add_point( builder, x, y, 0 );
-
- /* join point; on curve, with y-value the same as the last */
- /* control point's y-value */
- x = ADD_LONG( x, args[4] );
- cff_builder_add_point( builder, x, y, 1 );
-
- /* third control point, with y-value the same as the join */
- /* point's y-value */
- x = ADD_LONG( x, args[5] );
- cff_builder_add_point( builder, x, y, 0 );
-
- /* fourth control point */
- x = ADD_LONG( x, args[6] );
- y = ADD_LONG( y, args[7] );
- cff_builder_add_point( builder, x, y, 0 );
-
- /* ending point, with y-value the same as the start */
- x = ADD_LONG( x, args[8] );
- y = start_y;
- cff_builder_add_point( builder, x, y, 1 );
-
- args = stack;
- break;
- }
-
- case cff_op_hflex:
- {
- FT_Pos start_y;
-
-
- FT_TRACE4(( " hflex\n" ));
-
- /* adding six more points; 4 control points, 2 on-curve points */
- if ( cff_builder_start_point( builder, x, y ) ||
- cff_check_points( builder, 6 ) )
- goto Fail;
-
- /* record the starting point's y-position for later use */
- start_y = y;
-
- /* first control point */
- x = ADD_LONG( x, args[0] );
- cff_builder_add_point( builder, x, y, 0 );
-
- /* second control point */
- x = ADD_LONG( x, args[1] );
- y = ADD_LONG( y, args[2] );
- cff_builder_add_point( builder, x, y, 0 );
-
- /* join point; on curve, with y-value the same as the last */
- /* control point's y-value */
- x = ADD_LONG( x, args[3] );
- cff_builder_add_point( builder, x, y, 1 );
-
- /* third control point, with y-value the same as the join */
- /* point's y-value */
- x = ADD_LONG( x, args[4] );
- cff_builder_add_point( builder, x, y, 0 );
-
- /* fourth control point */
- x = ADD_LONG( x, args[5] );
- y = start_y;
- cff_builder_add_point( builder, x, y, 0 );
-
- /* ending point, with y-value the same as the start point's */
- /* y-value -- we don't add this point, though */
- x = ADD_LONG( x, args[6] );
- cff_builder_add_point( builder, x, y, 1 );
-
- args = stack;
- break;
- }
-
- case cff_op_flex1:
- {
- FT_Pos start_x, start_y; /* record start x, y values for */
- /* alter use */
- FT_Fixed dx = 0, dy = 0; /* used in horizontal/vertical */
- /* algorithm below */
- FT_Int horizontal, count;
- FT_Fixed* temp;
-
-
- FT_TRACE4(( " flex1\n" ));
-
- /* adding six more points; 4 control points, 2 on-curve points */
- if ( cff_builder_start_point( builder, x, y ) ||
- cff_check_points( builder, 6 ) )
- goto Fail;
-
- /* record the starting point's x, y position for later use */
- start_x = x;
- start_y = y;
-
- /* XXX: figure out whether this is supposed to be a horizontal */
- /* or vertical flex; the Type 2 specification is vague... */
-
- temp = args;
-
- /* grab up to the last argument */
- for ( count = 5; count > 0; count-- )
- {
- dx = ADD_LONG( dx, temp[0] );
- dy = ADD_LONG( dy, temp[1] );
- temp += 2;
- }
-
- if ( dx < 0 )
- dx = NEG_LONG( dx );
- if ( dy < 0 )
- dy = NEG_LONG( dy );
-
- /* strange test, but here it is... */
- horizontal = ( dx > dy );
-
- for ( count = 5; count > 0; count-- )
- {
- x = ADD_LONG( x, args[0] );
- y = ADD_LONG( y, args[1] );
- cff_builder_add_point( builder, x, y,
- FT_BOOL( count == 3 ) );
- args += 2;
- }
-
- /* is last operand an x- or y-delta? */
- if ( horizontal )
- {
- x = ADD_LONG( x, args[0] );
- y = start_y;
- }
- else
- {
- x = start_x;
- y = ADD_LONG( y, args[0] );
- }
-
- cff_builder_add_point( builder, x, y, 1 );
-
- args = stack;
- break;
- }
-
- case cff_op_flex:
- {
- FT_UInt count;
-
-
- FT_TRACE4(( " flex\n" ));
-
- if ( cff_builder_start_point( builder, x, y ) ||
- cff_check_points( builder, 6 ) )
- goto Fail;
-
- for ( count = 6; count > 0; count-- )
- {
- x = ADD_LONG( x, args[0] );
- y = ADD_LONG( y, args[1] );
- cff_builder_add_point( builder, x, y,
- FT_BOOL( count == 4 || count == 1 ) );
- args += 2;
- }
-
- args = stack;
- }
- break;
-
- case cff_op_seac:
- FT_TRACE4(( " seac\n" ));
-
- error = cff_operator_seac( decoder,
- args[0], args[1], args[2],
- (FT_Int)( args[3] >> 16 ),
- (FT_Int)( args[4] >> 16 ) );
-
- /* add current outline to the glyph slot */
- FT_GlyphLoader_Add( builder->loader );
-
- /* return now! */
- FT_TRACE4(( "\n" ));
- return error;
-
- case cff_op_endchar:
- /* in dictionaries, `endchar' simply indicates end of data */
- if ( in_dict )
- return error;
-
- FT_TRACE4(( " endchar\n" ));
-
- /* We are going to emulate the seac operator. */
- if ( num_args >= 4 )
- {
- /* Save glyph width so that the subglyphs don't overwrite it. */
- FT_Pos glyph_width = decoder->glyph_width;
-
-
- error = cff_operator_seac( decoder,
- 0L, args[-4], args[-3],
- (FT_Int)( args[-2] >> 16 ),
- (FT_Int)( args[-1] >> 16 ) );
-
- decoder->glyph_width = glyph_width;
- }
- else
- {
- cff_builder_close_contour( builder );
-
- /* close hints recording session */
- if ( hinter )
- {
- if ( hinter->close( hinter->hints,
- (FT_UInt)builder->current->n_points ) )
- goto Syntax_Error;
-
- /* apply hints to the loaded glyph outline now */
- error = hinter->apply( hinter->hints,
- builder->current,
- (PSH_Globals)builder->hints_globals,
- decoder->hint_mode );
- if ( error )
- goto Fail;
- }
-
- /* add current outline to the glyph slot */
- FT_GlyphLoader_Add( builder->loader );
- }
-
- /* return now! */
- FT_TRACE4(( "\n" ));
- return error;
-
- case cff_op_abs:
- FT_TRACE4(( " abs\n" ));
-
- if ( args[0] < 0 )
- {
- if ( args[0] == FT_LONG_MIN )
- args[0] = FT_LONG_MAX;
- else
- args[0] = -args[0];
- }
- args++;
- break;
-
- case cff_op_add:
- FT_TRACE4(( " add\n" ));
-
- args[0] = ADD_LONG( args[0], args[1] );
- args++;
- break;
-
- case cff_op_sub:
- FT_TRACE4(( " sub\n" ));
-
- args[0] = SUB_LONG( args[0], args[1] );
- args++;
- break;
-
- case cff_op_div:
- FT_TRACE4(( " div\n" ));
-
- args[0] = FT_DivFix( args[0], args[1] );
- args++;
- break;
-
- case cff_op_neg:
- FT_TRACE4(( " neg\n" ));
-
- if ( args[0] == FT_LONG_MIN )
- args[0] = FT_LONG_MAX;
- args[0] = -args[0];
- args++;
- break;
-
- case cff_op_random:
- {
- FT_UInt32* randval = in_dict ? &decoder->cff->top_font.random
- : &decoder->current_subfont->random;
-
-
- FT_TRACE4(( " random\n" ));
-
- /* only use the lower 16 bits of `random' */
- /* to generate a number in the range (0;1] */
- args[0] = (FT_Fixed)( ( *randval & 0xFFFF ) + 1 );
- args++;
-
- *randval = cff_random( *randval );
- }
- break;
-
- case cff_op_mul:
- FT_TRACE4(( " mul\n" ));
-
- args[0] = FT_MulFix( args[0], args[1] );
- args++;
- break;
-
- case cff_op_sqrt:
- FT_TRACE4(( " sqrt\n" ));
-
- /* without upper limit the loop below might not finish */
- if ( args[0] > 0x7FFFFFFFL )
- args[0] = 0xB504F4L; /* sqrt( 32768.0044 ) */
- else if ( args[0] > 0 )
- args[0] = (FT_Fixed)FT_SqrtFixed( args[0] );
- else
- args[0] = 0;
- args++;
- break;
-
- case cff_op_drop:
- /* nothing */
- FT_TRACE4(( " drop\n" ));
-
- break;
-
- case cff_op_exch:
- {
- FT_Fixed tmp;
-
-
- FT_TRACE4(( " exch\n" ));
-
- tmp = args[0];
- args[0] = args[1];
- args[1] = tmp;
- args += 2;
- }
- break;
-
- case cff_op_index:
- {
- FT_Int idx = (FT_Int)( args[0] >> 16 );
-
-
- FT_TRACE4(( " index\n" ));
-
- if ( idx < 0 )
- idx = 0;
- else if ( idx > num_args - 2 )
- idx = num_args - 2;
- args[0] = args[-( idx + 1 )];
- args++;
- }
- break;
-
- case cff_op_roll:
- {
- FT_Int count = (FT_Int)( args[0] >> 16 );
- FT_Int idx = (FT_Int)( args[1] >> 16 );
-
-
- FT_TRACE4(( " roll\n" ));
-
- if ( count <= 0 )
- count = 1;
-
- args -= count;
- if ( args < stack )
- goto Stack_Underflow;
-
- if ( idx >= 0 )
- {
- idx = idx % count;
- while ( idx > 0 )
- {
- FT_Fixed tmp = args[count - 1];
- FT_Int i;
-
-
- for ( i = count - 2; i >= 0; i-- )
- args[i + 1] = args[i];
- args[0] = tmp;
- idx--;
- }
- }
- else
- {
- /* before C99 it is implementation-defined whether */
- /* the result of `%' is negative if the first operand */
- /* is negative */
- idx = -( NEG_INT( idx ) % count );
- while ( idx < 0 )
- {
- FT_Fixed tmp = args[0];
- FT_Int i;
-
-
- for ( i = 0; i < count - 1; i++ )
- args[i] = args[i + 1];
- args[count - 1] = tmp;
- idx++;
- }
- }
- args += count;
- }
- break;
-
- case cff_op_dup:
- FT_TRACE4(( " dup\n" ));
-
- args[1] = args[0];
- args += 2;
- break;
-
- case cff_op_put:
- {
- FT_Fixed val = args[0];
- FT_UInt idx = (FT_UInt)( args[1] >> 16 );
-
-
- FT_TRACE4(( " put\n" ));
-
- /* the Type2 specification before version 16-March-2000 */
- /* didn't give a hard-coded size limit of the temporary */
- /* storage array; instead, an argument of the */
- /* `MultipleMaster' operator set the size */
- if ( idx < CFF_MAX_TRANS_ELEMENTS )
- decoder->buildchar[idx] = val;
- }
- break;
-
- case cff_op_get:
- {
- FT_UInt idx = (FT_UInt)( args[0] >> 16 );
- FT_Fixed val = 0;
-
-
- FT_TRACE4(( " get\n" ));
-
- if ( idx < CFF_MAX_TRANS_ELEMENTS )
- val = decoder->buildchar[idx];
-
- args[0] = val;
- args++;
- }
- break;
-
- case cff_op_store:
- /* this operator was removed from the Type2 specification */
- /* in version 16-March-2000 */
-
- /* since we currently don't handle interpolation of multiple */
- /* master fonts, this is a no-op */
- FT_TRACE4(( " store\n" ));
- break;
-
- case cff_op_load:
- /* this operator was removed from the Type2 specification */
- /* in version 16-March-2000 */
- {
- FT_UInt reg_idx = (FT_UInt)args[0];
- FT_UInt idx = (FT_UInt)args[1];
- FT_UInt count = (FT_UInt)args[2];
-
-
- FT_TRACE4(( " load\n" ));
-
- /* since we currently don't handle interpolation of multiple */
- /* master fonts, we store a vector [1 0 0 ...] in the */
- /* temporary storage array regardless of the Registry index */
- if ( reg_idx <= 2 &&
- idx < CFF_MAX_TRANS_ELEMENTS &&
- count <= num_axes )
- {
- FT_UInt end, i;
-
-
- end = FT_MIN( idx + count, CFF_MAX_TRANS_ELEMENTS );
-
- if ( idx < end )
- decoder->buildchar[idx] = 1 << 16;
-
- for ( i = idx + 1; i < end; i++ )
- decoder->buildchar[i] = 0;
- }
- }
- break;
-
- case cff_op_blend:
- /* this operator was removed from the Type2 specification */
- /* in version 16-March-2000 */
- if ( num_designs )
- {
- FT_Int num_results = (FT_Int)( args[0] >> 16 );
-
-
- FT_TRACE4(( " blend\n" ));
-
- if ( num_results < 0 )
- goto Syntax_Error;
-
- if ( num_results > num_args ||
- num_results * (FT_Int)num_designs > num_args )
- goto Stack_Underflow;
-
- /* since we currently don't handle interpolation of multiple */
- /* master fonts, return the `num_results' values of the */
- /* first master */
- args -= num_results * ( num_designs - 1 );
- num_args -= num_results * ( num_designs - 1 );
- }
- else
- goto Syntax_Error;
- break;
-
- case cff_op_dotsection:
- /* this operator is deprecated and ignored by the parser */
- FT_TRACE4(( " dotsection\n" ));
- break;
-
- case cff_op_closepath:
- /* this is an invalid Type 2 operator; however, there */
- /* exist fonts which are incorrectly converted from probably */
- /* Type 1 to CFF, and some parsers seem to accept it */
-
- FT_TRACE4(( " closepath (invalid op)\n" ));
-
- args = stack;
- break;
-
- case cff_op_hsbw:
- /* this is an invalid Type 2 operator; however, there */
- /* exist fonts which are incorrectly converted from probably */
- /* Type 1 to CFF, and some parsers seem to accept it */
-
- FT_TRACE4(( " hsbw (invalid op)\n" ));
-
- decoder->glyph_width =
- ADD_LONG( decoder->nominal_width, ( args[1] >> 16 ) );
-
- decoder->builder.left_bearing.x = args[0];
- decoder->builder.left_bearing.y = 0;
-
- x = ADD_LONG( decoder->builder.pos_x, args[0] );
- y = decoder->builder.pos_y;
- args = stack;
- break;
-
- case cff_op_sbw:
- /* this is an invalid Type 2 operator; however, there */
- /* exist fonts which are incorrectly converted from probably */
- /* Type 1 to CFF, and some parsers seem to accept it */
-
- FT_TRACE4(( " sbw (invalid op)\n" ));
-
- decoder->glyph_width =
- ADD_LONG( decoder->nominal_width, ( args[2] >> 16 ) );
-
- decoder->builder.left_bearing.x = args[0];
- decoder->builder.left_bearing.y = args[1];
-
- x = ADD_LONG( decoder->builder.pos_x, args[0] );
- y = ADD_LONG( decoder->builder.pos_y, args[1] );
- args = stack;
- break;
-
- case cff_op_setcurrentpoint:
- /* this is an invalid Type 2 operator; however, there */
- /* exist fonts which are incorrectly converted from probably */
- /* Type 1 to CFF, and some parsers seem to accept it */
-
- FT_TRACE4(( " setcurrentpoint (invalid op)\n" ));
-
- x = ADD_LONG( decoder->builder.pos_x, args[0] );
- y = ADD_LONG( decoder->builder.pos_y, args[1] );
- args = stack;
- break;
-
- case cff_op_callothersubr:
- {
- FT_Fixed arg;
-
-
- /* this is an invalid Type 2 operator; however, there */
- /* exist fonts which are incorrectly converted from */
- /* probably Type 1 to CFF, and some parsers seem to accept */
- /* it */
-
- FT_TRACE4(( " callothersubr (invalid op)\n" ));
-
- /* subsequent `pop' operands should add the arguments, */
- /* this is the implementation described for `unknown' */
- /* other subroutines in the Type1 spec. */
- /* */
- /* XXX Fix return arguments (see discussion below). */
-
- arg = 2 + ( args[-2] >> 16 );
- if ( arg >= CFF_MAX_OPERANDS )
- goto Stack_Underflow;
-
- args -= arg;
- if ( args < stack )
- goto Stack_Underflow;
- }
- break;
-
- case cff_op_pop:
- /* this is an invalid Type 2 operator; however, there */
- /* exist fonts which are incorrectly converted from probably */
- /* Type 1 to CFF, and some parsers seem to accept it */
-
- FT_TRACE4(( " pop (invalid op)\n" ));
-
- /* XXX Increasing `args' is wrong: After a certain number of */
- /* `pop's we get a stack overflow. Reason for doing it is */
- /* code like this (actually found in a CFF font): */
- /* */
- /* 17 1 3 callothersubr */
- /* pop */
- /* callsubr */
- /* */
- /* Since we handle `callothersubr' as a no-op, and */
- /* `callsubr' needs at least one argument, `pop' can't be a */
- /* no-op too as it basically should be. */
- /* */
- /* The right solution would be to provide real support for */
- /* `callothersubr' as done in `t1decode.c', however, given */
- /* the fact that CFF fonts with `pop' are invalid, it is */
- /* questionable whether it is worth the time. */
- args++;
- break;
-
- case cff_op_and:
- {
- FT_Fixed cond = ( args[0] && args[1] );
-
-
- FT_TRACE4(( " and\n" ));
-
- args[0] = cond ? 0x10000L : 0;
- args++;
- }
- break;
-
- case cff_op_or:
- {
- FT_Fixed cond = ( args[0] || args[1] );
-
-
- FT_TRACE4(( " or\n" ));
-
- args[0] = cond ? 0x10000L : 0;
- args++;
- }
- break;
-
- case cff_op_not:
- {
- FT_Fixed cond = !args[0];
-
-
- FT_TRACE4(( " not\n" ));
-
- args[0] = cond ? 0x10000L : 0;
- args++;
- }
- break;
-
- case cff_op_eq:
- {
- FT_Fixed cond = ( args[0] == args[1] );
-
-
- FT_TRACE4(( " eq\n" ));
-
- args[0] = cond ? 0x10000L : 0;
- args++;
- }
- break;
-
- case cff_op_ifelse:
- {
- FT_Fixed cond = ( args[2] <= args[3] );
-
-
- FT_TRACE4(( " ifelse\n" ));
-
- if ( !cond )
- args[0] = args[1];
- args++;
- }
- break;
-
- case cff_op_callsubr:
- {
- FT_UInt idx = (FT_UInt)( ( args[0] >> 16 ) +
- decoder->locals_bias );
-
-
- FT_TRACE4(( " callsubr (idx %d, entering level %td)\n",
- idx,
- zone - decoder->zones + 1 ));
-
- if ( idx >= decoder->num_locals )
- {
- FT_ERROR(( "cff_decoder_parse_charstrings:"
- " invalid local subr index\n" ));
- goto Syntax_Error;
- }
-
- if ( zone - decoder->zones >= CFF_MAX_SUBRS_CALLS )
- {
- FT_ERROR(( "cff_decoder_parse_charstrings:"
- " too many nested subrs\n" ));
- goto Syntax_Error;
- }
-
- zone->cursor = ip; /* save current instruction pointer */
-
- zone++;
- zone->base = decoder->locals[idx];
- zone->limit = decoder->locals[idx + 1];
- zone->cursor = zone->base;
-
- if ( !zone->base || zone->limit == zone->base )
- {
- FT_ERROR(( "cff_decoder_parse_charstrings:"
- " invoking empty subrs\n" ));
- goto Syntax_Error;
- }
-
- decoder->zone = zone;
- ip = zone->base;
- limit = zone->limit;
- }
- break;
-
- case cff_op_callgsubr:
- {
- FT_UInt idx = (FT_UInt)( ( args[0] >> 16 ) +
- decoder->globals_bias );
-
-
- FT_TRACE4(( " callgsubr (idx %d, entering level %td)\n",
- idx,
- zone - decoder->zones + 1 ));
-
- if ( idx >= decoder->num_globals )
- {
- FT_ERROR(( "cff_decoder_parse_charstrings:"
- " invalid global subr index\n" ));
- goto Syntax_Error;
- }
-
- if ( zone - decoder->zones >= CFF_MAX_SUBRS_CALLS )
- {
- FT_ERROR(( "cff_decoder_parse_charstrings:"
- " too many nested subrs\n" ));
- goto Syntax_Error;
- }
-
- zone->cursor = ip; /* save current instruction pointer */
-
- zone++;
- zone->base = decoder->globals[idx];
- zone->limit = decoder->globals[idx + 1];
- zone->cursor = zone->base;
-
- if ( !zone->base || zone->limit == zone->base )
- {
- FT_ERROR(( "cff_decoder_parse_charstrings:"
- " invoking empty subrs\n" ));
- goto Syntax_Error;
- }
-
- decoder->zone = zone;
- ip = zone->base;
- limit = zone->limit;
- }
- break;
-
- case cff_op_return:
- FT_TRACE4(( " return (leaving level %td)\n",
- decoder->zone - decoder->zones ));
-
- if ( decoder->zone <= decoder->zones )
- {
- FT_ERROR(( "cff_decoder_parse_charstrings:"
- " unexpected return\n" ));
- goto Syntax_Error;
- }
-
- decoder->zone--;
- zone = decoder->zone;
- ip = zone->cursor;
- limit = zone->limit;
- break;
-
- default:
- FT_ERROR(( "Unimplemented opcode: %d", ip[-1] ));
-
- if ( ip[-1] == 12 )
- FT_ERROR(( " %d", ip[0] ));
- FT_ERROR(( "\n" ));
-
- return FT_THROW( Unimplemented_Feature );
- }
-
- decoder->top = args;
-
- if ( decoder->top - stack >= CFF_MAX_OPERANDS )
- goto Stack_Overflow;
-
- } /* general operator processing */
-
- } /* while ip < limit */
-
- FT_TRACE4(( "..end..\n" ));
- FT_TRACE4(( "\n" ));
-
- Fail:
- return error;
-
- MM_Error:
- FT_TRACE4(( "cff_decoder_parse_charstrings:"
- " invalid opcode found in top DICT charstring\n"));
- return FT_THROW( Invalid_File_Format );
-
- Syntax_Error:
- FT_TRACE4(( "cff_decoder_parse_charstrings: syntax error\n" ));
- return FT_THROW( Invalid_File_Format );
-
- Stack_Underflow:
- FT_TRACE4(( "cff_decoder_parse_charstrings: stack underflow\n" ));
- return FT_THROW( Too_Few_Arguments );
-
- Stack_Overflow:
- FT_TRACE4(( "cff_decoder_parse_charstrings: stack overflow\n" ));
- return FT_THROW( Stack_Overflow );
- }
-
-#endif /* CFF_CONFIG_OPTION_OLD_ENGINE */
-
-
- /**************************************************************************
- *
- * @Function:
- * cff_decoder_init
- *
- * @Description:
- * Initializes a given glyph decoder.
- *
- * @InOut:
- * decoder ::
- * A pointer to the glyph builder to initialize.
- *
- * @Input:
- * face ::
- * The current face object.
- *
- * size ::
- * The current size object.
- *
- * slot ::
- * The current glyph object.
- *
- * hinting ::
- * Whether hinting is active.
- *
- * hint_mode ::
- * The hinting mode.
- */
- FT_LOCAL_DEF( void )
- cff_decoder_init( CFF_Decoder* decoder,
- TT_Face face,
- CFF_Size size,
- CFF_GlyphSlot slot,
- FT_Bool hinting,
- FT_Render_Mode hint_mode,
- CFF_Decoder_Get_Glyph_Callback get_callback,
- CFF_Decoder_Free_Glyph_Callback free_callback )
- {
- CFF_Font cff = (CFF_Font)face->extra.data;
-
-
- /* clear everything */
- FT_ZERO( decoder );
-
- /* initialize builder */
- cff_builder_init( &decoder->builder, face, size, slot, hinting );
-
- /* initialize Type2 decoder */
- decoder->cff = cff;
- decoder->num_globals = cff->global_subrs_index.count;
- decoder->globals = cff->global_subrs;
- decoder->globals_bias = cff_compute_bias(
- cff->top_font.font_dict.charstring_type,
- decoder->num_globals );
-
- decoder->hint_mode = hint_mode;
-
- decoder->get_glyph_callback = get_callback;
- decoder->free_glyph_callback = free_callback;
- }
-
-
- /* this function is used to select the subfont */
- /* and the locals subrs array */
- FT_LOCAL_DEF( FT_Error )
- cff_decoder_prepare( CFF_Decoder* decoder,
- CFF_Size size,
- FT_UInt glyph_index )
- {
- CFF_Builder *builder = &decoder->builder;
- CFF_Font cff = (CFF_Font)builder->face->extra.data;
- CFF_SubFont sub = &cff->top_font;
- FT_Error error = FT_Err_Ok;
-
- FT_Service_CFFLoad cffload = (FT_Service_CFFLoad)cff->cffload;
-
-
- /* manage CID fonts */
- if ( cff->num_subfonts )
- {
- FT_Byte fd_index = cffload->fd_select_get( &cff->fd_select,
- glyph_index );
-
-
- if ( fd_index >= cff->num_subfonts )
- {
- FT_TRACE4(( "cff_decoder_prepare: invalid CID subfont index\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- FT_TRACE3(( " in subfont %d:\n", fd_index ));
-
- sub = cff->subfonts[fd_index];
-
- if ( builder->hints_funcs && size )
- {
- FT_Size ftsize = FT_SIZE( size );
- CFF_Internal internal = (CFF_Internal)ftsize->internal->module_data;
-
-
- /* for CFFs without subfonts, this value has already been set */
- builder->hints_globals = (void *)internal->subfonts[fd_index];
- }
- }
-
- decoder->num_locals = sub->local_subrs_index.count;
- decoder->locals = sub->local_subrs;
- decoder->locals_bias = cff_compute_bias(
- decoder->cff->top_font.font_dict.charstring_type,
- decoder->num_locals );
-
- decoder->glyph_width = sub->private_dict.default_width;
- decoder->nominal_width = sub->private_dict.nominal_width;
-
- decoder->current_subfont = sub;
-
- Exit:
- return error;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/psaux/cffdecode.h b/contrib/libs/freetype/src/psaux/cffdecode.h
deleted file mode 100644
index 038f7235c3..0000000000
--- a/contrib/libs/freetype/src/psaux/cffdecode.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
- *
- * cffdecode.h
- *
- * PostScript CFF (Type 2) decoding routines (specification).
- *
- * Copyright (C) 2017-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef CFFDECODE_H_
-#define CFFDECODE_H_
-
-
-#include <freetype/internal/psaux.h>
-
-
-FT_BEGIN_HEADER
-
- FT_LOCAL( void )
- cff_decoder_init( CFF_Decoder* decoder,
- TT_Face face,
- CFF_Size size,
- CFF_GlyphSlot slot,
- FT_Bool hinting,
- FT_Render_Mode hint_mode,
- CFF_Decoder_Get_Glyph_Callback get_callback,
- CFF_Decoder_Free_Glyph_Callback free_callback );
-
- FT_LOCAL( FT_Error )
- cff_decoder_prepare( CFF_Decoder* decoder,
- CFF_Size size,
- FT_UInt glyph_index );
-
-
- FT_LOCAL( FT_Int )
- cff_lookup_glyph_by_stdcharcode( CFF_Font cff,
- FT_Int charcode );
-
-
-#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
- FT_LOCAL( FT_Error )
- cff_decoder_parse_charstrings( CFF_Decoder* decoder,
- FT_Byte* charstring_base,
- FT_ULong charstring_len,
- FT_Bool in_dict );
-#endif
-
-
-FT_END_HEADER
-
-#endif
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/psaux/psarrst.c b/contrib/libs/freetype/src/psaux/psarrst.c
deleted file mode 100644
index 70313d283a..0000000000
--- a/contrib/libs/freetype/src/psaux/psarrst.c
+++ /dev/null
@@ -1,240 +0,0 @@
-/****************************************************************************
- *
- * psarrst.c
- *
- * Adobe's code for Array Stacks (body).
- *
- * Copyright 2007-2013 Adobe Systems Incorporated.
- *
- * This software, and all works of authorship, whether in source or
- * object code form as indicated by the copyright notice(s) included
- * herein (collectively, the "Work") is made available, and may only be
- * used, modified, and distributed under the FreeType Project License,
- * LICENSE.TXT. Additionally, subject to the terms and conditions of the
- * FreeType Project License, each contributor to the Work hereby grants
- * to any individual or legal entity exercising permissions granted by
- * the FreeType Project License and this section (hereafter, "You" or
- * "Your") a perpetual, worldwide, non-exclusive, no-charge,
- * royalty-free, irrevocable (except as stated in this section) patent
- * license to make, have made, use, offer to sell, sell, import, and
- * otherwise transfer the Work, where such license applies only to those
- * patent claims licensable by such contributor that are necessarily
- * infringed by their contribution(s) alone or by combination of their
- * contribution(s) with the Work to which such contribution(s) was
- * submitted. If You institute patent litigation against any entity
- * (including a cross-claim or counterclaim in a lawsuit) alleging that
- * the Work or a contribution incorporated within the Work constitutes
- * direct or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate as of
- * the date such litigation is filed.
- *
- * By using, modifying, or distributing the Work you indicate that you
- * have read and understood the terms and conditions of the
- * FreeType Project License as well as those provided in this section,
- * and you accept them fully.
- *
- */
-
-
-#include "psft.h"
-#include <freetype/internal/ftdebug.h>
-
-#include "psglue.h"
-#include "psarrst.h"
-
-#include "pserror.h"
-
-
- /*
- * CF2_ArrStack uses an error pointer, to enable shared errors.
- * Shared errors are necessary when multiple objects allow the program
- * to continue after detecting errors. Only the first error should be
- * recorded.
- */
-
- FT_LOCAL_DEF( void )
- cf2_arrstack_init( CF2_ArrStack arrstack,
- FT_Memory memory,
- FT_Error* error,
- size_t sizeItem )
- {
- FT_ASSERT( arrstack );
-
- /* initialize the structure */
- arrstack->memory = memory;
- arrstack->error = error;
- arrstack->sizeItem = sizeItem;
- arrstack->allocated = 0;
- arrstack->count = 0;
- arrstack->totalSize = 0;
- arrstack->ptr = NULL;
- }
-
-
- FT_LOCAL_DEF( void )
- cf2_arrstack_finalize( CF2_ArrStack arrstack )
- {
- FT_Memory memory = arrstack->memory; /* for FT_FREE */
-
-
- FT_ASSERT( arrstack );
-
- arrstack->allocated = 0;
- arrstack->count = 0;
- arrstack->totalSize = 0;
-
- /* free the data buffer */
- FT_FREE( arrstack->ptr );
- }
-
-
- /* allocate or reallocate the buffer size; */
- /* return false on memory error */
- static FT_Bool
- cf2_arrstack_setNumElements( CF2_ArrStack arrstack,
- size_t numElements )
- {
- FT_ASSERT( arrstack );
-
- {
- FT_Error error = FT_Err_Ok; /* for FT_REALLOC */
- FT_Memory memory = arrstack->memory; /* for FT_REALLOC */
-
- size_t newSize = numElements * arrstack->sizeItem;
-
-
- if ( numElements > FT_LONG_MAX / arrstack->sizeItem )
- goto exit;
-
-
- FT_ASSERT( newSize > 0 ); /* avoid realloc with zero size */
-
- if ( !FT_QREALLOC( arrstack->ptr, arrstack->totalSize, newSize ) )
- {
- arrstack->allocated = numElements;
- arrstack->totalSize = newSize;
-
- if ( arrstack->count > numElements )
- {
- /* we truncated the list! */
- CF2_SET_ERROR( arrstack->error, Stack_Overflow );
- arrstack->count = numElements;
- return FALSE;
- }
-
- return TRUE; /* success */
- }
- }
-
- exit:
- /* if there's not already an error, store this one */
- CF2_SET_ERROR( arrstack->error, Out_Of_Memory );
-
- return FALSE;
- }
-
-
- /* set the count, ensuring allocation is sufficient */
- FT_LOCAL_DEF( void )
- cf2_arrstack_setCount( CF2_ArrStack arrstack,
- size_t numElements )
- {
- FT_ASSERT( arrstack );
-
- if ( numElements > arrstack->allocated )
- {
- /* expand the allocation first */
- if ( !cf2_arrstack_setNumElements( arrstack, numElements ) )
- return;
- }
-
- arrstack->count = numElements;
- }
-
-
- /* clear the count */
- FT_LOCAL_DEF( void )
- cf2_arrstack_clear( CF2_ArrStack arrstack )
- {
- FT_ASSERT( arrstack );
-
- arrstack->count = 0;
- }
-
-
- /* current number of items */
- FT_LOCAL_DEF( size_t )
- cf2_arrstack_size( const CF2_ArrStack arrstack )
- {
- FT_ASSERT( arrstack );
-
- return arrstack->count;
- }
-
-
- FT_LOCAL_DEF( void* )
- cf2_arrstack_getBuffer( const CF2_ArrStack arrstack )
- {
- FT_ASSERT( arrstack );
-
- return arrstack->ptr;
- }
-
-
- /* return pointer to the given element */
- FT_LOCAL_DEF( void* )
- cf2_arrstack_getPointer( const CF2_ArrStack arrstack,
- size_t idx )
- {
- void* newPtr;
-
-
- FT_ASSERT( arrstack );
-
- if ( idx >= arrstack->count )
- {
- /* overflow */
- CF2_SET_ERROR( arrstack->error, Stack_Overflow );
- idx = 0; /* choose safe default */
- }
-
- newPtr = (FT_Byte*)arrstack->ptr + idx * arrstack->sizeItem;
-
- return newPtr;
- }
-
-
- /* push (append) an element at the end of the list; */
- /* return false on memory error */
- /* TODO: should there be a length param for extra checking? */
- FT_LOCAL_DEF( void )
- cf2_arrstack_push( CF2_ArrStack arrstack,
- const void* ptr )
- {
- FT_ASSERT( arrstack );
-
- if ( arrstack->count == arrstack->allocated )
- {
- /* increase the buffer size */
- if ( !cf2_arrstack_setNumElements(
- arrstack, arrstack->allocated * 2 + 16 ) )
- {
- /* on error, ignore the push */
- return;
- }
- }
-
- FT_ASSERT( ptr );
-
- {
- size_t offset = arrstack->count * arrstack->sizeItem;
- void* newPtr = (FT_Byte*)arrstack->ptr + offset;
-
-
- FT_MEM_COPY( newPtr, ptr, arrstack->sizeItem );
- arrstack->count += 1;
- }
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/psaux/psarrst.h b/contrib/libs/freetype/src/psaux/psarrst.h
deleted file mode 100644
index 31e5330cc3..0000000000
--- a/contrib/libs/freetype/src/psaux/psarrst.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/****************************************************************************
- *
- * psarrst.h
- *
- * Adobe's code for Array Stacks (specification).
- *
- * Copyright 2007-2013 Adobe Systems Incorporated.
- *
- * This software, and all works of authorship, whether in source or
- * object code form as indicated by the copyright notice(s) included
- * herein (collectively, the "Work") is made available, and may only be
- * used, modified, and distributed under the FreeType Project License,
- * LICENSE.TXT. Additionally, subject to the terms and conditions of the
- * FreeType Project License, each contributor to the Work hereby grants
- * to any individual or legal entity exercising permissions granted by
- * the FreeType Project License and this section (hereafter, "You" or
- * "Your") a perpetual, worldwide, non-exclusive, no-charge,
- * royalty-free, irrevocable (except as stated in this section) patent
- * license to make, have made, use, offer to sell, sell, import, and
- * otherwise transfer the Work, where such license applies only to those
- * patent claims licensable by such contributor that are necessarily
- * infringed by their contribution(s) alone or by combination of their
- * contribution(s) with the Work to which such contribution(s) was
- * submitted. If You institute patent litigation against any entity
- * (including a cross-claim or counterclaim in a lawsuit) alleging that
- * the Work or a contribution incorporated within the Work constitutes
- * direct or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate as of
- * the date such litigation is filed.
- *
- * By using, modifying, or distributing the Work you indicate that you
- * have read and understood the terms and conditions of the
- * FreeType Project License as well as those provided in this section,
- * and you accept them fully.
- *
- */
-
-
-#ifndef PSARRST_H_
-#define PSARRST_H_
-
-
-#include "pserror.h"
-
-
-FT_BEGIN_HEADER
-
-
- /* need to define the struct here (not opaque) so it can be allocated by */
- /* clients */
- typedef struct CF2_ArrStackRec_
- {
- FT_Memory memory;
- FT_Error* error;
-
- size_t sizeItem; /* bytes per element */
- size_t allocated; /* items allocated */
- size_t count; /* number of elements allocated */
- size_t totalSize; /* total bytes allocated */
-
- void* ptr; /* ptr to data */
-
- } CF2_ArrStackRec, *CF2_ArrStack;
-
-
- FT_LOCAL( void )
- cf2_arrstack_init( CF2_ArrStack arrstack,
- FT_Memory memory,
- FT_Error* error,
- size_t sizeItem );
- FT_LOCAL( void )
- cf2_arrstack_finalize( CF2_ArrStack arrstack );
-
- FT_LOCAL( void )
- cf2_arrstack_setCount( CF2_ArrStack arrstack,
- size_t numElements );
- FT_LOCAL( void )
- cf2_arrstack_clear( CF2_ArrStack arrstack );
- FT_LOCAL( size_t )
- cf2_arrstack_size( const CF2_ArrStack arrstack );
-
- FT_LOCAL( void* )
- cf2_arrstack_getBuffer( const CF2_ArrStack arrstack );
- FT_LOCAL( void* )
- cf2_arrstack_getPointer( const CF2_ArrStack arrstack,
- size_t idx );
-
- FT_LOCAL( void )
- cf2_arrstack_push( CF2_ArrStack arrstack,
- const void* ptr );
-
-
-FT_END_HEADER
-
-
-#endif /* PSARRST_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/psaux/psaux.c b/contrib/libs/freetype/src/psaux/psaux.c
deleted file mode 100644
index ffe89cd624..0000000000
--- a/contrib/libs/freetype/src/psaux/psaux.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/****************************************************************************
- *
- * psaux.c
- *
- * FreeType auxiliary PostScript driver component (body only).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#define FT_MAKE_OPTION_SINGLE_OBJECT
-
-#include "afmparse.c"
-#include "psauxmod.c"
-#include "psconv.c"
-#include "psobjs.c"
-#include "t1cmap.c"
-#include "t1decode.c"
-#include "cffdecode.c"
-
-#include "psarrst.c"
-#include "psblues.c"
-#include "pserror.c"
-#include "psfont.c"
-#include "psft.c"
-#include "pshints.c"
-#include "psintrp.c"
-#include "psread.c"
-#include "psstack.c"
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/psaux/psauxerr.h b/contrib/libs/freetype/src/psaux/psauxerr.h
deleted file mode 100644
index 18428c40d5..0000000000
--- a/contrib/libs/freetype/src/psaux/psauxerr.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
- *
- * psauxerr.h
- *
- * PS auxiliary module error codes (specification only).
- *
- * Copyright (C) 2001-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /**************************************************************************
- *
- * This file is used to define the PS auxiliary module error enumeration
- * constants.
- *
- */
-
-#ifndef PSAUXERR_H_
-#define PSAUXERR_H_
-
-#include <freetype/ftmoderr.h>
-
-#undef FTERRORS_H_
-
-#undef FT_ERR_PREFIX
-#define FT_ERR_PREFIX PSaux_Err_
-#define FT_ERR_BASE FT_Mod_Err_PSaux
-
-#include <freetype/fterrors.h>
-
-#endif /* PSAUXERR_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/psaux/psauxmod.c b/contrib/libs/freetype/src/psaux/psauxmod.c
deleted file mode 100644
index 6826f9d8d3..0000000000
--- a/contrib/libs/freetype/src/psaux/psauxmod.c
+++ /dev/null
@@ -1,190 +0,0 @@
-/****************************************************************************
- *
- * psauxmod.c
- *
- * FreeType auxiliary PostScript module implementation (body).
- *
- * Copyright (C) 2000-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include "psauxmod.h"
-#include "psobjs.h"
-#include "t1decode.h"
-#include "t1cmap.h"
-#include "psft.h"
-#include "cffdecode.h"
-
-#ifndef T1_CONFIG_OPTION_NO_AFM
-#include "afmparse.h"
-#endif
-
-
- FT_CALLBACK_TABLE_DEF
- const PS_Table_FuncsRec ps_table_funcs =
- {
- ps_table_new, /* init */
- ps_table_done, /* done */
- ps_table_add, /* add */
- ps_table_release /* release */
- };
-
-
- FT_CALLBACK_TABLE_DEF
- const PS_Parser_FuncsRec ps_parser_funcs =
- {
- ps_parser_init, /* init */
- ps_parser_done, /* done */
-
- ps_parser_skip_spaces, /* skip_spaces */
- ps_parser_skip_PS_token, /* skip_PS_token */
-
- ps_parser_to_int, /* to_int */
- ps_parser_to_fixed, /* to_fixed */
- ps_parser_to_bytes, /* to_bytes */
- ps_parser_to_coord_array, /* to_coord_array */
- ps_parser_to_fixed_array, /* to_fixed_array */
- ps_parser_to_token, /* to_token */
- ps_parser_to_token_array, /* to_token_array */
-
- ps_parser_load_field, /* load_field */
- ps_parser_load_field_table /* load_field_table */
- };
-
-
- FT_CALLBACK_TABLE_DEF
- const PS_Builder_FuncsRec ps_builder_funcs =
- {
- ps_builder_init, /* init */
- ps_builder_done /* done */
- };
-
-
- FT_CALLBACK_TABLE_DEF
- const T1_Builder_FuncsRec t1_builder_funcs =
- {
- t1_builder_init, /* init */
- t1_builder_done, /* done */
-
- t1_builder_check_points, /* check_points */
- t1_builder_add_point, /* add_point */
- t1_builder_add_point1, /* add_point1 */
- t1_builder_add_contour, /* add_contour */
- t1_builder_start_point, /* start_point */
- t1_builder_close_contour /* close_contour */
- };
-
-
- FT_CALLBACK_TABLE_DEF
- const T1_Decoder_FuncsRec t1_decoder_funcs =
- {
- t1_decoder_init, /* init */
- t1_decoder_done, /* done */
-#ifdef T1_CONFIG_OPTION_OLD_ENGINE
- t1_decoder_parse_charstrings, /* parse_charstrings_old */
-#else
- t1_decoder_parse_metrics, /* parse_metrics */
-#endif
- cf2_decoder_parse_charstrings /* parse_charstrings */
- };
-
-
-#ifndef T1_CONFIG_OPTION_NO_AFM
- FT_CALLBACK_TABLE_DEF
- const AFM_Parser_FuncsRec afm_parser_funcs =
- {
- afm_parser_init, /* init */
- afm_parser_done, /* done */
- afm_parser_parse /* parse */
- };
-#endif
-
-
- FT_CALLBACK_TABLE_DEF
- const T1_CMap_ClassesRec t1_cmap_classes =
- {
- &t1_cmap_standard_class_rec,
- &t1_cmap_expert_class_rec,
- &t1_cmap_custom_class_rec,
- &t1_cmap_unicode_class_rec
- };
-
-
- FT_CALLBACK_TABLE_DEF
- const CFF_Builder_FuncsRec cff_builder_funcs =
- {
- cff_builder_init, /* init */
- cff_builder_done, /* done */
-
- cff_check_points, /* check_points */
- cff_builder_add_point, /* add_point */
- cff_builder_add_point1, /* add_point1 */
- cff_builder_add_contour, /* add_contour */
- cff_builder_start_point, /* start_point */
- cff_builder_close_contour /* close_contour */
- };
-
-
- FT_CALLBACK_TABLE_DEF
- const CFF_Decoder_FuncsRec cff_decoder_funcs =
- {
- cff_decoder_init, /* init */
- cff_decoder_prepare, /* prepare */
-
-#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
- cff_decoder_parse_charstrings, /* parse_charstrings_old */
-#endif
- cf2_decoder_parse_charstrings /* parse_charstrings */
- };
-
-
- static
- const PSAux_Interface psaux_interface =
- {
- &ps_table_funcs,
- &ps_parser_funcs,
- &t1_builder_funcs,
- &t1_decoder_funcs,
- t1_decrypt,
- cff_random,
- ps_decoder_init,
- t1_make_subfont,
-
- (const T1_CMap_ClassesRec*) &t1_cmap_classes,
-
-#ifndef T1_CONFIG_OPTION_NO_AFM
- &afm_parser_funcs,
-#else
- 0,
-#endif
-
- &cff_decoder_funcs,
- };
-
-
- FT_DEFINE_MODULE(
- psaux_module_class,
-
- 0,
- sizeof ( FT_ModuleRec ),
- "psaux",
- 0x20000L,
- 0x20000L,
-
- &psaux_interface, /* module-specific interface */
-
- (FT_Module_Constructor)NULL, /* module_init */
- (FT_Module_Destructor) NULL, /* module_done */
- (FT_Module_Requester) NULL /* get_interface */
- )
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/psaux/psauxmod.h b/contrib/libs/freetype/src/psaux/psauxmod.h
deleted file mode 100644
index 82d7e348af..0000000000
--- a/contrib/libs/freetype/src/psaux/psauxmod.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/****************************************************************************
- *
- * psauxmod.h
- *
- * FreeType auxiliary PostScript module implementation (specification).
- *
- * Copyright (C) 2000-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef PSAUXMOD_H_
-#define PSAUXMOD_H_
-
-
-#include <freetype/ftmodapi.h>
-
-#include <freetype/internal/psaux.h>
-
-
-FT_BEGIN_HEADER
-
-
- FT_CALLBACK_TABLE
- const CFF_Builder_FuncsRec cff_builder_funcs;
-
- FT_CALLBACK_TABLE
- const PS_Builder_FuncsRec ps_builder_funcs;
-
-#ifndef T1_CONFIG_OPTION_NO_AFM
- FT_CALLBACK_TABLE
- const AFM_Parser_FuncsRec afm_parser_funcs;
-#endif
-
- FT_CALLBACK_TABLE
- const T1_CMap_ClassesRec t1_cmap_classes;
-
- FT_CALLBACK_TABLE
- const CFF_Decoder_FuncsRec cff_decoder_funcs;
-
-
- FT_EXPORT_VAR( const FT_Module_Class ) psaux_driver_class;
-
-
- FT_DECLARE_MODULE( psaux_module_class )
-
-
-FT_END_HEADER
-
-#endif /* PSAUXMOD_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/psaux/psblues.c b/contrib/libs/freetype/src/psaux/psblues.c
deleted file mode 100644
index 213b943b46..0000000000
--- a/contrib/libs/freetype/src/psaux/psblues.c
+++ /dev/null
@@ -1,571 +0,0 @@
-/****************************************************************************
- *
- * psblues.c
- *
- * Adobe's code for handling Blue Zones (body).
- *
- * Copyright 2009-2014 Adobe Systems Incorporated.
- *
- * This software, and all works of authorship, whether in source or
- * object code form as indicated by the copyright notice(s) included
- * herein (collectively, the "Work") is made available, and may only be
- * used, modified, and distributed under the FreeType Project License,
- * LICENSE.TXT. Additionally, subject to the terms and conditions of the
- * FreeType Project License, each contributor to the Work hereby grants
- * to any individual or legal entity exercising permissions granted by
- * the FreeType Project License and this section (hereafter, "You" or
- * "Your") a perpetual, worldwide, non-exclusive, no-charge,
- * royalty-free, irrevocable (except as stated in this section) patent
- * license to make, have made, use, offer to sell, sell, import, and
- * otherwise transfer the Work, where such license applies only to those
- * patent claims licensable by such contributor that are necessarily
- * infringed by their contribution(s) alone or by combination of their
- * contribution(s) with the Work to which such contribution(s) was
- * submitted. If You institute patent litigation against any entity
- * (including a cross-claim or counterclaim in a lawsuit) alleging that
- * the Work or a contribution incorporated within the Work constitutes
- * direct or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate as of
- * the date such litigation is filed.
- *
- * By using, modifying, or distributing the Work you indicate that you
- * have read and understood the terms and conditions of the
- * FreeType Project License as well as those provided in this section,
- * and you accept them fully.
- *
- */
-
-
-#include "psft.h"
-#include <freetype/internal/ftdebug.h>
-
-#include "psblues.h"
-#include "pshints.h"
-#include "psfont.h"
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT cf2blues
-
-
- FT_LOCAL_DEF( void )
- cf2_blues_init( CF2_Blues blues,
- CF2_Font font )
- {
- /* pointer to parsed font object */
- PS_Decoder* decoder = font->decoder;
-
- CF2_Fixed zoneHeight;
- CF2_Fixed maxZoneHeight = 0;
- CF2_Fixed csUnitsPerPixel;
-
- size_t numBlueValues;
- size_t numOtherBlues;
- size_t numFamilyBlues;
- size_t numFamilyOtherBlues;
-
- FT_Fixed* blueValues;
- FT_Fixed* otherBlues;
- FT_Fixed* familyBlues;
- FT_Fixed* familyOtherBlues;
-
- size_t i;
- CF2_Fixed emBoxBottom, emBoxTop;
-
-#if 0
- CF2_Int unitsPerEm = font->unitsPerEm;
-
-
- if ( unitsPerEm == 0 )
- unitsPerEm = 1000;
-#endif
-
- FT_ZERO( blues );
- blues->scale = font->innerTransform.d;
-
- cf2_getBlueMetrics( decoder,
- &blues->blueScale,
- &blues->blueShift,
- &blues->blueFuzz );
-
- cf2_getBlueValues( decoder, &numBlueValues, &blueValues );
- cf2_getOtherBlues( decoder, &numOtherBlues, &otherBlues );
- cf2_getFamilyBlues( decoder, &numFamilyBlues, &familyBlues );
- cf2_getFamilyOtherBlues( decoder, &numFamilyOtherBlues, &familyOtherBlues );
-
- /*
- * synthetic em box hint heuristic
- *
- * Apply this when ideographic dictionary (LanguageGroup 1) has no
- * real alignment zones. Adobe tools generate dummy zones at -250 and
- * 1100 for a 1000 unit em. Fonts with ICF-based alignment zones
- * should not enable the heuristic. When the heuristic is enabled,
- * the font's blue zones are ignored.
- *
- */
-
- /* get em box from OS/2 typoAscender/Descender */
- /* TODO: FreeType does not parse these metrics. Skip them for now. */
-#if 0
- FCM_getHorizontalLineMetrics( &e,
- font->font,
- &ascender,
- &descender,
- &linegap );
- if ( ascender - descender == unitsPerEm )
- {
- emBoxBottom = cf2_intToFixed( descender );
- emBoxTop = cf2_intToFixed( ascender );
- }
- else
-#endif
- {
- emBoxBottom = CF2_ICF_Bottom;
- emBoxTop = CF2_ICF_Top;
- }
-
- if ( cf2_getLanguageGroup( decoder ) == 1 &&
- ( numBlueValues == 0 ||
- ( numBlueValues == 4 &&
- blueValues[0] < emBoxBottom &&
- blueValues[1] < emBoxBottom &&
- blueValues[2] > emBoxTop &&
- blueValues[3] > emBoxTop ) ) )
- {
- /*
- * Construct hint edges suitable for synthetic ghost hints at top
- * and bottom of em box. +-CF2_MIN_COUNTER allows for unhinted
- * features above or below the last hinted edge. This also gives a
- * net 1 pixel boost to the height of ideographic glyphs.
- *
- * Note: Adjust synthetic hints outward by epsilon (0x.0001) to
- * avoid interference. E.g., some fonts have real hints at
- * 880 and -120.
- */
-
- blues->emBoxBottomEdge.csCoord = emBoxBottom - CF2_FIXED_EPSILON;
- blues->emBoxBottomEdge.dsCoord = cf2_fixedRound(
- FT_MulFix(
- blues->emBoxBottomEdge.csCoord,
- blues->scale ) ) -
- CF2_MIN_COUNTER;
- blues->emBoxBottomEdge.scale = blues->scale;
- blues->emBoxBottomEdge.flags = CF2_GhostBottom |
- CF2_Locked |
- CF2_Synthetic;
-
- blues->emBoxTopEdge.csCoord = emBoxTop + CF2_FIXED_EPSILON +
- 2 * font->darkenY;
- blues->emBoxTopEdge.dsCoord = cf2_fixedRound(
- FT_MulFix(
- blues->emBoxTopEdge.csCoord,
- blues->scale ) ) +
- CF2_MIN_COUNTER;
- blues->emBoxTopEdge.scale = blues->scale;
- blues->emBoxTopEdge.flags = CF2_GhostTop |
- CF2_Locked |
- CF2_Synthetic;
-
- blues->doEmBoxHints = TRUE; /* enable the heuristic */
-
- return;
- }
-
- /* copy `BlueValues' and `OtherBlues' to a combined array of top and */
- /* bottom zones */
- for ( i = 0; i < numBlueValues; i += 2 )
- {
- blues->zone[blues->count].csBottomEdge = blueValues[i];
- blues->zone[blues->count].csTopEdge = blueValues[i + 1];
-
- zoneHeight = SUB_INT32( blues->zone[blues->count].csTopEdge,
- blues->zone[blues->count].csBottomEdge );
-
- if ( zoneHeight < 0 )
- {
- FT_TRACE4(( "cf2_blues_init: ignoring negative zone height\n" ));
- continue; /* reject this zone */
- }
-
- if ( zoneHeight > maxZoneHeight )
- {
- /* take maximum before darkening adjustment */
- /* so overshoot suppression point doesn't change */
- maxZoneHeight = zoneHeight;
- }
-
- /* adjust both edges of top zone upward by twice darkening amount */
- if ( i != 0 )
- {
- blues->zone[blues->count].csTopEdge += 2 * font->darkenY;
- blues->zone[blues->count].csBottomEdge += 2 * font->darkenY;
- }
-
- /* first `BlueValue' is bottom zone; others are top */
- if ( i == 0 )
- {
- blues->zone[blues->count].bottomZone =
- TRUE;
- blues->zone[blues->count].csFlatEdge =
- blues->zone[blues->count].csTopEdge;
- }
- else
- {
- blues->zone[blues->count].bottomZone =
- FALSE;
- blues->zone[blues->count].csFlatEdge =
- blues->zone[blues->count].csBottomEdge;
- }
-
- blues->count += 1;
- }
-
- for ( i = 0; i < numOtherBlues; i += 2 )
- {
- blues->zone[blues->count].csBottomEdge = otherBlues[i];
- blues->zone[blues->count].csTopEdge = otherBlues[i + 1];
-
- zoneHeight = SUB_INT32( blues->zone[blues->count].csTopEdge,
- blues->zone[blues->count].csBottomEdge );
-
- if ( zoneHeight < 0 )
- {
- FT_TRACE4(( "cf2_blues_init: ignoring negative zone height\n" ));
- continue; /* reject this zone */
- }
-
- if ( zoneHeight > maxZoneHeight )
- {
- /* take maximum before darkening adjustment */
- /* so overshoot suppression point doesn't change */
- maxZoneHeight = zoneHeight;
- }
-
- /* Note: bottom zones are not adjusted for darkening amount */
-
- /* all OtherBlues are bottom zone */
- blues->zone[blues->count].bottomZone =
- TRUE;
- blues->zone[blues->count].csFlatEdge =
- blues->zone[blues->count].csTopEdge;
-
- blues->count += 1;
- }
-
- /* Adjust for FamilyBlues */
-
- /* Search for the nearest flat edge in `FamilyBlues' or */
- /* `FamilyOtherBlues'. According to the Black Book, any matching edge */
- /* must be within one device pixel */
-
- csUnitsPerPixel = FT_DivFix( cf2_intToFixed( 1 ), blues->scale );
-
- /* loop on all zones in this font */
- for ( i = 0; i < blues->count; i++ )
- {
- size_t j;
- CF2_Fixed minDiff;
- CF2_Fixed flatFamilyEdge, diff;
- /* value for this font */
- CF2_Fixed flatEdge = blues->zone[i].csFlatEdge;
-
-
- if ( blues->zone[i].bottomZone )
- {
- /* In a bottom zone, the top edge is the flat edge. */
- /* Search `FamilyOtherBlues' for bottom zones; look for closest */
- /* Family edge that is within the one pixel threshold. */
-
- minDiff = CF2_FIXED_MAX;
-
- for ( j = 0; j < numFamilyOtherBlues; j += 2 )
- {
- /* top edge */
- flatFamilyEdge = familyOtherBlues[j + 1];
-
- diff = cf2_fixedAbs( SUB_INT32( flatEdge, flatFamilyEdge ) );
-
- if ( diff < minDiff && diff < csUnitsPerPixel )
- {
- blues->zone[i].csFlatEdge = flatFamilyEdge;
- minDiff = diff;
-
- if ( diff == 0 )
- break;
- }
- }
-
- /* check the first member of FamilyBlues, which is a bottom zone */
- if ( numFamilyBlues >= 2 )
- {
- /* top edge */
- flatFamilyEdge = familyBlues[1];
-
- diff = cf2_fixedAbs( SUB_INT32( flatEdge, flatFamilyEdge ) );
-
- if ( diff < minDiff && diff < csUnitsPerPixel )
- blues->zone[i].csFlatEdge = flatFamilyEdge;
- }
- }
- else
- {
- /* In a top zone, the bottom edge is the flat edge. */
- /* Search `FamilyBlues' for top zones; skip first zone, which is a */
- /* bottom zone; look for closest Family edge that is within the */
- /* one pixel threshold */
-
- minDiff = CF2_FIXED_MAX;
-
- for ( j = 2; j < numFamilyBlues; j += 2 )
- {
- /* bottom edge */
- flatFamilyEdge = familyBlues[j];
-
- /* adjust edges of top zone upward by twice darkening amount */
- flatFamilyEdge += 2 * font->darkenY; /* bottom edge */
-
- diff = cf2_fixedAbs( SUB_INT32( flatEdge, flatFamilyEdge ) );
-
- if ( diff < minDiff && diff < csUnitsPerPixel )
- {
- blues->zone[i].csFlatEdge = flatFamilyEdge;
- minDiff = diff;
-
- if ( diff == 0 )
- break;
- }
- }
- }
- }
-
- /* TODO: enforce separation of zones, including BlueFuzz */
-
- /* Adjust BlueScale; similar to AdjustBlueScale() in coretype */
- /* `bcsetup.c'. */
-
- if ( maxZoneHeight > 0 )
- {
- if ( blues->blueScale > FT_DivFix( cf2_intToFixed( 1 ),
- maxZoneHeight ) )
- {
- /* clamp at maximum scale */
- blues->blueScale = FT_DivFix( cf2_intToFixed( 1 ),
- maxZoneHeight );
- }
-
- /*
- * TODO: Revisit the bug fix for 613448. The minimum scale
- * requirement catches a number of library fonts. For
- * example, with default BlueScale (.039625) and 0.4 minimum,
- * the test below catches any font with maxZoneHeight < 10.1.
- * There are library fonts ranging from 2 to 10 that get
- * caught, including e.g., Eurostile LT Std Medium with
- * maxZoneHeight of 6.
- *
- */
-#if 0
- if ( blueScale < .4 / maxZoneHeight )
- {
- tetraphilia_assert( 0 );
- /* clamp at minimum scale, per bug 0613448 fix */
- blueScale = .4 / maxZoneHeight;
- }
-#endif
-
- }
-
- /*
- * Suppress overshoot and boost blue zones at small sizes. Boost
- * amount varies linearly from 0.5 pixel near 0 to 0 pixel at
- * blueScale cutoff.
- * Note: This boost amount is different from the coretype heuristic.
- *
- */
-
- if ( blues->scale < blues->blueScale )
- {
- blues->suppressOvershoot = TRUE;
-
- /* Change rounding threshold for `dsFlatEdge'. */
- /* Note: constant changed from 0.5 to 0.6 to avoid a problem with */
- /* 10ppem Arial */
-
- blues->boost = cf2_doubleToFixed( .6 ) -
- FT_MulDiv( cf2_doubleToFixed ( .6 ),
- blues->scale,
- blues->blueScale );
- if ( blues->boost > 0x7FFF )
- {
- /* boost must remain less than 0.5, or baseline could go negative */
- blues->boost = 0x7FFF;
- }
- }
-
- /* boost and darkening have similar effects; don't do both */
- if ( font->stemDarkened )
- blues->boost = 0;
-
- /* set device space alignment for each zone; */
- /* apply boost amount before rounding flat edge */
-
- for ( i = 0; i < blues->count; i++ )
- {
- if ( blues->zone[i].bottomZone )
- blues->zone[i].dsFlatEdge = cf2_fixedRound(
- FT_MulFix(
- blues->zone[i].csFlatEdge,
- blues->scale ) -
- blues->boost );
- else
- blues->zone[i].dsFlatEdge = cf2_fixedRound(
- FT_MulFix(
- blues->zone[i].csFlatEdge,
- blues->scale ) +
- blues->boost );
- }
- }
-
-
- /*
- * Check whether `stemHint' is captured by one of the blue zones.
- *
- * Zero, one or both edges may be valid; only valid edges can be
- * captured. For compatibility with CoolType, search top and bottom
- * zones in the same pass (see `BlueLock'). If a hint is captured,
- * return true and position the edge(s) in one of 3 ways:
- *
- * 1) If `BlueScale' suppresses overshoot, position the captured edge
- * at the flat edge of the zone.
- * 2) If overshoot is not suppressed and `BlueShift' requires
- * overshoot, position the captured edge a minimum of 1 device pixel
- * from the flat edge.
- * 3) If overshoot is not suppressed or required, position the captured
- * edge at the nearest device pixel.
- *
- */
- FT_LOCAL_DEF( FT_Bool )
- cf2_blues_capture( const CF2_Blues blues,
- CF2_Hint bottomHintEdge,
- CF2_Hint topHintEdge )
- {
- /* TODO: validate? */
- CF2_Fixed csFuzz = blues->blueFuzz;
-
- /* new position of captured edge */
- CF2_Fixed dsNew;
-
- /* amount that hint is moved when positioned */
- CF2_Fixed dsMove = 0;
-
- FT_Bool captured = FALSE;
- CF2_UInt i;
-
-
- /* assert edge flags are consistent */
- FT_ASSERT( !cf2_hint_isTop( bottomHintEdge ) &&
- !cf2_hint_isBottom( topHintEdge ) );
-
- /* TODO: search once without blue fuzz for compatibility with coretype? */
- for ( i = 0; i < blues->count; i++ )
- {
- if ( blues->zone[i].bottomZone &&
- cf2_hint_isBottom( bottomHintEdge ) )
- {
- if ( SUB_INT32( blues->zone[i].csBottomEdge, csFuzz ) <=
- bottomHintEdge->csCoord &&
- bottomHintEdge->csCoord <=
- ADD_INT32( blues->zone[i].csTopEdge, csFuzz ) )
- {
- /* bottom edge captured by bottom zone */
-
- if ( blues->suppressOvershoot )
- dsNew = blues->zone[i].dsFlatEdge;
-
- else if ( SUB_INT32( blues->zone[i].csTopEdge,
- bottomHintEdge->csCoord ) >=
- blues->blueShift )
- {
- /* guarantee minimum of 1 pixel overshoot */
- dsNew = FT_MIN(
- cf2_fixedRound( bottomHintEdge->dsCoord ),
- SUB_INT32( blues->zone[i].dsFlatEdge,
- cf2_intToFixed( 1 ) ) );
- }
-
- else
- {
- /* simply round captured edge */
- dsNew = cf2_fixedRound( bottomHintEdge->dsCoord );
- }
-
- dsMove = SUB_INT32( dsNew, bottomHintEdge->dsCoord );
- captured = TRUE;
-
- break;
- }
- }
-
- if ( !blues->zone[i].bottomZone && cf2_hint_isTop( topHintEdge ) )
- {
- if ( SUB_INT32( blues->zone[i].csBottomEdge, csFuzz ) <=
- topHintEdge->csCoord &&
- topHintEdge->csCoord <=
- ADD_INT32( blues->zone[i].csTopEdge, csFuzz ) )
- {
- /* top edge captured by top zone */
-
- if ( blues->suppressOvershoot )
- dsNew = blues->zone[i].dsFlatEdge;
-
- else if ( SUB_INT32( topHintEdge->csCoord,
- blues->zone[i].csBottomEdge ) >=
- blues->blueShift )
- {
- /* guarantee minimum of 1 pixel overshoot */
- dsNew = FT_MAX(
- cf2_fixedRound( topHintEdge->dsCoord ),
- blues->zone[i].dsFlatEdge + cf2_intToFixed( 1 ) );
- }
-
- else
- {
- /* simply round captured edge */
- dsNew = cf2_fixedRound( topHintEdge->dsCoord );
- }
-
- dsMove = SUB_INT32( dsNew, topHintEdge->dsCoord );
- captured = TRUE;
-
- break;
- }
- }
- }
-
- if ( captured )
- {
- /* move both edges and flag them `locked' */
- if ( cf2_hint_isValid( bottomHintEdge ) )
- {
- bottomHintEdge->dsCoord = ADD_INT32( bottomHintEdge->dsCoord,
- dsMove );
- cf2_hint_lock( bottomHintEdge );
- }
-
- if ( cf2_hint_isValid( topHintEdge ) )
- {
- topHintEdge->dsCoord = ADD_INT32( topHintEdge->dsCoord, dsMove );
- cf2_hint_lock( topHintEdge );
- }
- }
-
- return captured;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/psaux/psblues.h b/contrib/libs/freetype/src/psaux/psblues.h
deleted file mode 100644
index 55fb88ecdd..0000000000
--- a/contrib/libs/freetype/src/psaux/psblues.h
+++ /dev/null
@@ -1,185 +0,0 @@
-/****************************************************************************
- *
- * psblues.h
- *
- * Adobe's code for handling Blue Zones (specification).
- *
- * Copyright 2009-2013 Adobe Systems Incorporated.
- *
- * This software, and all works of authorship, whether in source or
- * object code form as indicated by the copyright notice(s) included
- * herein (collectively, the "Work") is made available, and may only be
- * used, modified, and distributed under the FreeType Project License,
- * LICENSE.TXT. Additionally, subject to the terms and conditions of the
- * FreeType Project License, each contributor to the Work hereby grants
- * to any individual or legal entity exercising permissions granted by
- * the FreeType Project License and this section (hereafter, "You" or
- * "Your") a perpetual, worldwide, non-exclusive, no-charge,
- * royalty-free, irrevocable (except as stated in this section) patent
- * license to make, have made, use, offer to sell, sell, import, and
- * otherwise transfer the Work, where such license applies only to those
- * patent claims licensable by such contributor that are necessarily
- * infringed by their contribution(s) alone or by combination of their
- * contribution(s) with the Work to which such contribution(s) was
- * submitted. If You institute patent litigation against any entity
- * (including a cross-claim or counterclaim in a lawsuit) alleging that
- * the Work or a contribution incorporated within the Work constitutes
- * direct or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate as of
- * the date such litigation is filed.
- *
- * By using, modifying, or distributing the Work you indicate that you
- * have read and understood the terms and conditions of the
- * FreeType Project License as well as those provided in this section,
- * and you accept them fully.
- *
- */
-
-
- /*
- * A `CF2_Blues' object stores the blue zones (horizontal alignment
- * zones) of a font. These are specified in the CFF private dictionary
- * by `BlueValues', `OtherBlues', `FamilyBlues', and `FamilyOtherBlues'.
- * Each zone is defined by a top and bottom edge in character space.
- * Further, each zone is either a top zone or a bottom zone, as recorded
- * by `bottomZone'.
- *
- * The maximum number of `BlueValues' and `FamilyBlues' is 7 each.
- * However, these are combined to produce a total of 7 zones.
- * Similarly, the maximum number of `OtherBlues' and `FamilyOtherBlues'
- * is 5 and these are combined to produce an additional 5 zones.
- *
- * Blue zones are used to `capture' hints and force them to a common
- * alignment point. This alignment is recorded in device space in
- * `dsFlatEdge'. Except for this value, a `CF2_Blues' object could be
- * constructed independently of scaling. Construction may occur once
- * the matrix is known. Other features implemented in the Capture
- * method are overshoot suppression, overshoot enforcement, and Blue
- * Boost.
- *
- * Capture is determined by `BlueValues' and `OtherBlues', but the
- * alignment point may be adjusted to the scaled flat edge of
- * `FamilyBlues' or `FamilyOtherBlues'. No alignment is done to the
- * curved edge of a zone.
- *
- */
-
-
-#ifndef PSBLUES_H_
-#define PSBLUES_H_
-
-
-#include "psglue.h"
-
-
-FT_BEGIN_HEADER
-
-
- /*
- * `CF2_Hint' is shared by `cf2hints.h' and
- * `cf2blues.h', but `cf2blues.h' depends on
- * `cf2hints.h', so define it here. Note: The typedef is in
- * `cf2glue.h'.
- *
- */
- enum
- {
- CF2_GhostBottom = 0x1, /* a single bottom edge */
- CF2_GhostTop = 0x2, /* a single top edge */
- CF2_PairBottom = 0x4, /* the bottom edge of a stem hint */
- CF2_PairTop = 0x8, /* the top edge of a stem hint */
- CF2_Locked = 0x10, /* this edge has been aligned */
- /* by a blue zone */
- CF2_Synthetic = 0x20 /* this edge was synthesized */
- };
-
-
- /*
- * Default value for OS/2 typoAscender/Descender when their difference
- * is not equal to `unitsPerEm'. The default is based on -250 and 1100
- * in `CF2_Blues', assuming 1000 units per em here.
- *
- */
- enum
- {
- CF2_ICF_Top = cf2_intToFixed( 880 ),
- CF2_ICF_Bottom = cf2_intToFixed( -120 )
- };
-
-
- /*
- * Constant used for hint adjustment and for synthetic em box hint
- * placement.
- */
-#define CF2_MIN_COUNTER cf2_doubleToFixed( 0.5 )
-
-
- /* shared typedef is in cf2glue.h */
- struct CF2_HintRec_
- {
- CF2_UInt flags; /* attributes of the edge */
- size_t index; /* index in original stem hint array */
- /* (if not synthetic) */
- CF2_Fixed csCoord;
- CF2_Fixed dsCoord;
- CF2_Fixed scale;
- };
-
-
- typedef struct CF2_BlueRec_
- {
- CF2_Fixed csBottomEdge;
- CF2_Fixed csTopEdge;
- CF2_Fixed csFlatEdge; /* may be from either local or Family zones */
- CF2_Fixed dsFlatEdge; /* top edge of bottom zone or bottom edge */
- /* of top zone (rounded) */
- FT_Bool bottomZone;
-
- } CF2_BlueRec;
-
-
- /* max total blue zones is 12 */
- enum
- {
- CF2_MAX_BLUES = 7,
- CF2_MAX_OTHERBLUES = 5
- };
-
-
- typedef struct CF2_BluesRec_
- {
- CF2_Fixed scale;
- CF2_UInt count;
- FT_Bool suppressOvershoot;
- FT_Bool doEmBoxHints;
-
- CF2_Fixed blueScale;
- CF2_Fixed blueShift;
- CF2_Fixed blueFuzz;
-
- CF2_Fixed boost;
-
- CF2_HintRec emBoxTopEdge;
- CF2_HintRec emBoxBottomEdge;
-
- CF2_BlueRec zone[CF2_MAX_BLUES + CF2_MAX_OTHERBLUES];
-
- } CF2_BluesRec, *CF2_Blues;
-
-
- FT_LOCAL( void )
- cf2_blues_init( CF2_Blues blues,
- CF2_Font font );
- FT_LOCAL( FT_Bool )
- cf2_blues_capture( const CF2_Blues blues,
- CF2_Hint bottomHintEdge,
- CF2_Hint topHintEdge );
-
-
-FT_END_HEADER
-
-
-#endif /* PSBLUES_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/psaux/psconv.c b/contrib/libs/freetype/src/psaux/psconv.c
deleted file mode 100644
index 56c0ecd1d7..0000000000
--- a/contrib/libs/freetype/src/psaux/psconv.c
+++ /dev/null
@@ -1,610 +0,0 @@
-/****************************************************************************
- *
- * psconv.c
- *
- * Some convenience conversions (body).
- *
- * Copyright (C) 2006-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/psaux.h>
-#include <freetype/internal/ftdebug.h>
-
-#include "psconv.h"
-#include "psauxerr.h"
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT psconv
-
-
- /* The following array is used by various functions to quickly convert */
- /* digits (both decimal and non-decimal) into numbers. */
-
-#if 'A' == 65
- /* ASCII */
-
- static const FT_Char ft_char_table[128] =
- {
- /* 0x00 */
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1,
- -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
- 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1,
- -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
- 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1,
- };
-
- /* no character >= 0x80 can represent a valid number */
-#define OP >=
-
-#endif /* 'A' == 65 */
-
-#if 'A' == 193
- /* EBCDIC */
-
- static const FT_Char ft_char_table[128] =
- {
- /* 0x80 */
- -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, -1, -1, -1, -1, -1, -1,
- -1, 19, 20, 21, 22, 23, 24, 25, 26, 27, -1, -1, -1, -1, -1, -1,
- -1, -1, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, -1, -1, -1, -1, -1, -1,
- -1, 19, 20, 21, 22, 23, 24, 25, 26, 27, -1, -1, -1, -1, -1, -1,
- -1, -1, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, -1,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1,
- };
-
- /* no character < 0x80 can represent a valid number */
-#define OP <
-
-#endif /* 'A' == 193 */
-
-
- FT_LOCAL_DEF( FT_Long )
- PS_Conv_Strtol( FT_Byte** cursor,
- FT_Byte* limit,
- FT_Long base )
- {
- FT_Byte* p = *cursor;
-
- FT_Long num = 0;
- FT_Bool sign = 0;
- FT_Bool have_overflow = 0;
-
- FT_Long num_limit;
- FT_Char c_limit;
-
-
- if ( p >= limit )
- goto Bad;
-
- if ( base < 2 || base > 36 )
- {
- FT_TRACE4(( "!!!INVALID BASE:!!!" ));
- return 0;
- }
-
- if ( *p == '-' || *p == '+' )
- {
- sign = FT_BOOL( *p == '-' );
-
- p++;
- if ( p == limit )
- goto Bad;
-
- /* only a single sign is allowed */
- if ( *p == '-' || *p == '+' )
- return 0;
- }
-
- num_limit = 0x7FFFFFFFL / base;
- c_limit = (FT_Char)( 0x7FFFFFFFL % base );
-
- for ( ; p < limit; p++ )
- {
- FT_Char c;
-
-
- if ( IS_PS_SPACE( *p ) || *p OP 0x80 )
- break;
-
- c = ft_char_table[*p & 0x7F];
-
- if ( c < 0 || c >= base )
- break;
-
- if ( num > num_limit || ( num == num_limit && c > c_limit ) )
- have_overflow = 1;
- else
- num = num * base + c;
- }
-
- *cursor = p;
-
- if ( have_overflow )
- {
- num = 0x7FFFFFFFL;
- FT_TRACE4(( "!!!OVERFLOW:!!!" ));
- }
-
- if ( sign )
- num = -num;
-
- return num;
-
- Bad:
- FT_TRACE4(( "!!!END OF DATA:!!!" ));
- return 0;
- }
-
-
- FT_LOCAL_DEF( FT_Long )
- PS_Conv_ToInt( FT_Byte** cursor,
- FT_Byte* limit )
-
- {
- FT_Byte* p = *cursor;
- FT_Byte* curp;
-
- FT_Long num;
-
-
- curp = p;
- num = PS_Conv_Strtol( &p, limit, 10 );
-
- if ( p == curp )
- return 0;
-
- if ( p < limit && *p == '#' )
- {
- p++;
-
- curp = p;
- num = PS_Conv_Strtol( &p, limit, num );
-
- if ( p == curp )
- return 0;
- }
-
- *cursor = p;
-
- return num;
- }
-
-
- FT_LOCAL_DEF( FT_Fixed )
- PS_Conv_ToFixed( FT_Byte** cursor,
- FT_Byte* limit,
- FT_Long power_ten )
- {
- FT_Byte* p = *cursor;
- FT_Byte* curp;
-
- FT_Fixed integral = 0;
- FT_Long decimal = 0;
- FT_Long divider = 1;
-
- FT_Bool sign = 0;
- FT_Bool have_overflow = 0;
- FT_Bool have_underflow = 0;
-
-
- if ( p >= limit )
- goto Bad;
-
- if ( *p == '-' || *p == '+' )
- {
- sign = FT_BOOL( *p == '-' );
-
- p++;
- if ( p == limit )
- goto Bad;
-
- /* only a single sign is allowed */
- if ( *p == '-' || *p == '+' )
- return 0;
- }
-
- /* read the integer part */
- if ( *p != '.' )
- {
- curp = p;
- integral = PS_Conv_ToInt( &p, limit );
-
- if ( p == curp )
- return 0;
-
- if ( integral > 0x7FFF )
- have_overflow = 1;
- else
- integral = (FT_Fixed)( (FT_UInt32)integral << 16 );
- }
-
- /* read the decimal part */
- if ( p < limit && *p == '.' )
- {
- p++;
-
- for ( ; p < limit; p++ )
- {
- FT_Char c;
-
-
- if ( IS_PS_SPACE( *p ) || *p OP 0x80 )
- break;
-
- c = ft_char_table[*p & 0x7F];
-
- if ( c < 0 || c >= 10 )
- break;
-
- /* only add digit if we don't overflow */
- if ( divider < 0xCCCCCCCL && decimal < 0xCCCCCCCL )
- {
- decimal = decimal * 10 + c;
-
- if ( !integral && power_ten > 0 )
- power_ten--;
- else
- divider *= 10;
- }
- }
- }
-
- /* read exponent, if any */
- if ( p + 1 < limit && ( *p == 'e' || *p == 'E' ) )
- {
- FT_Long exponent;
-
-
- p++;
-
- curp = p;
- exponent = PS_Conv_ToInt( &p, limit );
-
- if ( curp == p )
- return 0;
-
- /* arbitrarily limit exponent */
- if ( exponent > 1000 )
- have_overflow = 1;
- else if ( exponent < -1000 )
- have_underflow = 1;
- else
- power_ten += exponent;
- }
-
- *cursor = p;
-
- if ( !integral && !decimal )
- return 0;
-
- if ( have_overflow )
- goto Overflow;
- if ( have_underflow )
- goto Underflow;
-
- while ( power_ten > 0 )
- {
- if ( integral >= 0xCCCCCCCL )
- goto Overflow;
- integral *= 10;
-
- if ( decimal >= 0xCCCCCCCL )
- {
- if ( divider == 1 )
- goto Overflow;
- divider /= 10;
- }
- else
- decimal *= 10;
-
- power_ten--;
- }
-
- while ( power_ten < 0 )
- {
- integral /= 10;
- if ( divider < 0xCCCCCCCL )
- divider *= 10;
- else
- decimal /= 10;
-
- if ( !integral && !decimal )
- goto Underflow;
-
- power_ten++;
- }
-
- if ( decimal )
- {
- decimal = FT_DivFix( decimal, divider );
- /* it's not necessary to check this addition for overflow */
- /* due to the structure of the real number representation */
- integral += decimal;
- }
-
- Exit:
- if ( sign )
- integral = -integral;
-
- return integral;
-
- Bad:
- FT_TRACE4(( "!!!END OF DATA:!!!" ));
- return 0;
-
- Overflow:
- integral = 0x7FFFFFFFL;
- FT_TRACE4(( "!!!OVERFLOW:!!!" ));
- goto Exit;
-
- Underflow:
- FT_TRACE4(( "!!!UNDERFLOW:!!!" ));
- return 0;
- }
-
-
-#if 0
- FT_LOCAL_DEF( FT_UInt )
- PS_Conv_StringDecode( FT_Byte** cursor,
- FT_Byte* limit,
- FT_Byte* buffer,
- FT_Offset n )
- {
- FT_Byte* p;
- FT_UInt r = 0;
-
-
- for ( p = *cursor; r < n && p < limit; p++ )
- {
- FT_Byte b;
-
-
- if ( *p != '\\' )
- {
- buffer[r++] = *p;
-
- continue;
- }
-
- p++;
-
- switch ( *p )
- {
- case 'n':
- b = '\n';
- break;
- case 'r':
- b = '\r';
- break;
- case 't':
- b = '\t';
- break;
- case 'b':
- b = '\b';
- break;
- case 'f':
- b = '\f';
- break;
- case '\r':
- p++;
- if ( *p != '\n' )
- {
- b = *p;
-
- break;
- }
- /* no break */
- case '\n':
- continue;
- break;
- default:
- if ( IS_PS_DIGIT( *p ) )
- {
- b = *p - '0';
-
- p++;
-
- if ( IS_PS_DIGIT( *p ) )
- {
- b = b * 8 + *p - '0';
-
- p++;
-
- if ( IS_PS_DIGIT( *p ) )
- b = b * 8 + *p - '0';
- else
- {
- buffer[r++] = b;
- b = *p;
- }
- }
- else
- {
- buffer[r++] = b;
- b = *p;
- }
- }
- else
- b = *p;
- break;
- }
-
- buffer[r++] = b;
- }
-
- *cursor = p;
-
- return r;
- }
-#endif /* 0 */
-
-
- FT_LOCAL_DEF( FT_UInt )
- PS_Conv_ASCIIHexDecode( FT_Byte** cursor,
- FT_Byte* limit,
- FT_Byte* buffer,
- FT_Offset n )
- {
- FT_Byte* p;
- FT_UInt r = 0;
- FT_UInt w = 0;
- FT_UInt pad = 0x01;
-
-
- n *= 2;
-
-#if 1
-
- p = *cursor;
-
- if ( p >= limit )
- return 0;
-
- if ( n > (FT_UInt)( limit - p ) )
- n = (FT_UInt)( limit - p );
-
- /* we try to process two nibbles at a time to be as fast as possible */
- for ( ; r < n; r++ )
- {
- FT_UInt c = p[r];
-
-
- if ( IS_PS_SPACE( c ) )
- continue;
-
- if ( c OP 0x80 )
- break;
-
- c = (FT_UInt)ft_char_table[c & 0x7F];
- if ( c >= 16 )
- break;
-
- pad = ( pad << 4 ) | c;
- if ( pad & 0x100 )
- {
- buffer[w++] = (FT_Byte)pad;
- pad = 0x01;
- }
- }
-
- if ( pad != 0x01 )
- buffer[w++] = (FT_Byte)( pad << 4 );
-
- *cursor = p + r;
-
- return w;
-
-#else /* 0 */
-
- for ( r = 0; r < n; r++ )
- {
- FT_Char c;
-
-
- if ( IS_PS_SPACE( *p ) )
- continue;
-
- if ( *p OP 0x80 )
- break;
-
- c = ft_char_table[*p & 0x7F];
-
- if ( (unsigned)c >= 16 )
- break;
-
- if ( r & 1 )
- {
- *buffer = (FT_Byte)( *buffer + c );
- buffer++;
- }
- else
- *buffer = (FT_Byte)( c << 4 );
-
- r++;
- }
-
- *cursor = p;
-
- return ( r + 1 ) / 2;
-
-#endif /* 0 */
-
- }
-
-
- FT_LOCAL_DEF( FT_UInt )
- PS_Conv_EexecDecode( FT_Byte** cursor,
- FT_Byte* limit,
- FT_Byte* buffer,
- FT_Offset n,
- FT_UShort* seed )
- {
- FT_Byte* p;
- FT_UInt r;
- FT_UInt s = *seed;
-
-
-#if 1
-
- p = *cursor;
-
- if ( p >= limit )
- return 0;
-
- if ( n > (FT_UInt)( limit - p ) )
- n = (FT_UInt)( limit - p );
-
- for ( r = 0; r < n; r++ )
- {
- FT_UInt val = p[r];
- FT_UInt b = ( val ^ ( s >> 8 ) );
-
-
- s = ( (val + s)*52845U + 22719 ) & 0xFFFFU;
- buffer[r] = (FT_Byte) b;
- }
-
- *cursor = p + n;
- *seed = (FT_UShort)s;
-
-#else /* 0 */
-
- for ( r = 0, p = *cursor; r < n && p < limit; r++, p++ )
- {
- FT_Byte b = (FT_Byte)( *p ^ ( s >> 8 ) );
-
-
- s = (FT_UShort)( ( *p + s ) * 52845U + 22719 );
- *buffer++ = b;
- }
- *cursor = p;
- *seed = s;
-
-#endif /* 0 */
-
- return r;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/psaux/psconv.h b/contrib/libs/freetype/src/psaux/psconv.h
deleted file mode 100644
index 91fcd15a1c..0000000000
--- a/contrib/libs/freetype/src/psaux/psconv.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/****************************************************************************
- *
- * psconv.h
- *
- * Some convenience conversions (specification).
- *
- * Copyright (C) 2006-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef PSCONV_H_
-#define PSCONV_H_
-
-
-#include <freetype/internal/psaux.h>
-
-FT_BEGIN_HEADER
-
-
- FT_LOCAL( FT_Long )
- PS_Conv_Strtol( FT_Byte** cursor,
- FT_Byte* limit,
- FT_Long base );
-
-
- FT_LOCAL( FT_Long )
- PS_Conv_ToInt( FT_Byte** cursor,
- FT_Byte* limit );
-
- FT_LOCAL( FT_Fixed )
- PS_Conv_ToFixed( FT_Byte** cursor,
- FT_Byte* limit,
- FT_Long power_ten );
-
-#if 0
- FT_LOCAL( FT_UInt )
- PS_Conv_StringDecode( FT_Byte** cursor,
- FT_Byte* limit,
- FT_Byte* buffer,
- FT_Offset n );
-#endif
-
- FT_LOCAL( FT_UInt )
- PS_Conv_ASCIIHexDecode( FT_Byte** cursor,
- FT_Byte* limit,
- FT_Byte* buffer,
- FT_Offset n );
-
- FT_LOCAL( FT_UInt )
- PS_Conv_EexecDecode( FT_Byte** cursor,
- FT_Byte* limit,
- FT_Byte* buffer,
- FT_Offset n,
- FT_UShort* seed );
-
-
-FT_END_HEADER
-
-#endif /* PSCONV_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/psaux/pserror.c b/contrib/libs/freetype/src/psaux/pserror.c
deleted file mode 100644
index 98cebcf74d..0000000000
--- a/contrib/libs/freetype/src/psaux/pserror.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/****************************************************************************
- *
- * pserror.c
- *
- * Adobe's code for error handling (body).
- *
- * Copyright 2006-2013 Adobe Systems Incorporated.
- *
- * This software, and all works of authorship, whether in source or
- * object code form as indicated by the copyright notice(s) included
- * herein (collectively, the "Work") is made available, and may only be
- * used, modified, and distributed under the FreeType Project License,
- * LICENSE.TXT. Additionally, subject to the terms and conditions of the
- * FreeType Project License, each contributor to the Work hereby grants
- * to any individual or legal entity exercising permissions granted by
- * the FreeType Project License and this section (hereafter, "You" or
- * "Your") a perpetual, worldwide, non-exclusive, no-charge,
- * royalty-free, irrevocable (except as stated in this section) patent
- * license to make, have made, use, offer to sell, sell, import, and
- * otherwise transfer the Work, where such license applies only to those
- * patent claims licensable by such contributor that are necessarily
- * infringed by their contribution(s) alone or by combination of their
- * contribution(s) with the Work to which such contribution(s) was
- * submitted. If You institute patent litigation against any entity
- * (including a cross-claim or counterclaim in a lawsuit) alleging that
- * the Work or a contribution incorporated within the Work constitutes
- * direct or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate as of
- * the date such litigation is filed.
- *
- * By using, modifying, or distributing the Work you indicate that you
- * have read and understood the terms and conditions of the
- * FreeType Project License as well as those provided in this section,
- * and you accept them fully.
- *
- */
-
-
-#include "psft.h"
-#include "pserror.h"
-
-
- FT_LOCAL_DEF( void )
- cf2_setError( FT_Error* error,
- FT_Error value )
- {
- if ( error && !*error )
- *error = value;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/psaux/pserror.h b/contrib/libs/freetype/src/psaux/pserror.h
deleted file mode 100644
index 5738853fac..0000000000
--- a/contrib/libs/freetype/src/psaux/pserror.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/****************************************************************************
- *
- * pserror.h
- *
- * Adobe's code for error handling (specification).
- *
- * Copyright 2006-2013 Adobe Systems Incorporated.
- *
- * This software, and all works of authorship, whether in source or
- * object code form as indicated by the copyright notice(s) included
- * herein (collectively, the "Work") is made available, and may only be
- * used, modified, and distributed under the FreeType Project License,
- * LICENSE.TXT. Additionally, subject to the terms and conditions of the
- * FreeType Project License, each contributor to the Work hereby grants
- * to any individual or legal entity exercising permissions granted by
- * the FreeType Project License and this section (hereafter, "You" or
- * "Your") a perpetual, worldwide, non-exclusive, no-charge,
- * royalty-free, irrevocable (except as stated in this section) patent
- * license to make, have made, use, offer to sell, sell, import, and
- * otherwise transfer the Work, where such license applies only to those
- * patent claims licensable by such contributor that are necessarily
- * infringed by their contribution(s) alone or by combination of their
- * contribution(s) with the Work to which such contribution(s) was
- * submitted. If You institute patent litigation against any entity
- * (including a cross-claim or counterclaim in a lawsuit) alleging that
- * the Work or a contribution incorporated within the Work constitutes
- * direct or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate as of
- * the date such litigation is filed.
- *
- * By using, modifying, or distributing the Work you indicate that you
- * have read and understood the terms and conditions of the
- * FreeType Project License as well as those provided in this section,
- * and you accept them fully.
- *
- */
-
-
-#ifndef PSERROR_H_
-#define PSERROR_H_
-
-
-#include <freetype/ftmoderr.h>
-
-#undef FTERRORS_H_
-
-#undef FT_ERR_PREFIX
-#define FT_ERR_PREFIX CF2_Err_
-#define FT_ERR_BASE FT_Mod_Err_CF2
-
-
-#include <freetype/fterrors.h>
-#include <freetype/internal/compiler-macros.h>
-#include "psft.h"
-
-
-FT_BEGIN_HEADER
-
-
- /*
- * A poor-man error facility.
- *
- * This code being written in vanilla C, doesn't have the luxury of a
- * language-supported exception mechanism such as the one available in
- * Java. Instead, we are stuck with using error codes that must be
- * carefully managed and preserved. However, it is convenient for us to
- * model our error mechanism on a Java-like exception mechanism.
- * When we assign an error code we are thus `throwing' an error.
- *
- * The preservation of an error code is done by coding convention.
- * Upon a function call if the error code is anything other than
- * `FT_Err_Ok', which is guaranteed to be zero, we
- * will return without altering that error. This will allow the
- * error to propagate and be handled at the appropriate location in
- * the code.
- *
- * This allows a style of code where the error code is initialized
- * up front and a block of calls are made with the error code only
- * being checked after the block. If a new error occurs, the original
- * error will be preserved and a functional no-op should result in any
- * subsequent function that has an initial error code not equal to
- * `FT_Err_Ok'.
- *
- * Errors are encoded by calling the `FT_THROW' macro. For example,
- *
- * {
- * FT_Error e;
- *
- *
- * ...
- * e = FT_THROW( Out_Of_Memory );
- * }
- *
- */
-
-
- /* Set error code to a particular value. */
- FT_LOCAL( void )
- cf2_setError( FT_Error* error,
- FT_Error value );
-
-
- /*
- * A macro that conditionally sets an error code.
- *
- * This macro will first check whether `error' is set;
- * if not, it will set it to `e'.
- *
- */
-#define CF2_SET_ERROR( error, e ) \
- cf2_setError( error, FT_THROW( e ) )
-
-
-FT_END_HEADER
-
-
-#endif /* PSERROR_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/psaux/psfixed.h b/contrib/libs/freetype/src/psaux/psfixed.h
deleted file mode 100644
index 299d076370..0000000000
--- a/contrib/libs/freetype/src/psaux/psfixed.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/****************************************************************************
- *
- * psfixed.h
- *
- * Adobe's code for Fixed-Point Mathematics (specification only).
- *
- * Copyright 2007-2013 Adobe Systems Incorporated.
- *
- * This software, and all works of authorship, whether in source or
- * object code form as indicated by the copyright notice(s) included
- * herein (collectively, the "Work") is made available, and may only be
- * used, modified, and distributed under the FreeType Project License,
- * LICENSE.TXT. Additionally, subject to the terms and conditions of the
- * FreeType Project License, each contributor to the Work hereby grants
- * to any individual or legal entity exercising permissions granted by
- * the FreeType Project License and this section (hereafter, "You" or
- * "Your") a perpetual, worldwide, non-exclusive, no-charge,
- * royalty-free, irrevocable (except as stated in this section) patent
- * license to make, have made, use, offer to sell, sell, import, and
- * otherwise transfer the Work, where such license applies only to those
- * patent claims licensable by such contributor that are necessarily
- * infringed by their contribution(s) alone or by combination of their
- * contribution(s) with the Work to which such contribution(s) was
- * submitted. If You institute patent litigation against any entity
- * (including a cross-claim or counterclaim in a lawsuit) alleging that
- * the Work or a contribution incorporated within the Work constitutes
- * direct or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate as of
- * the date such litigation is filed.
- *
- * By using, modifying, or distributing the Work you indicate that you
- * have read and understood the terms and conditions of the
- * FreeType Project License as well as those provided in this section,
- * and you accept them fully.
- *
- */
-
-
-#ifndef PSFIXED_H_
-#define PSFIXED_H_
-
-
-FT_BEGIN_HEADER
-
-
- /* rasterizer integer and fixed-point arithmetic must be 32-bit */
-
-#define CF2_Fixed CF2_F16Dot16
- typedef FT_Int32 CF2_Frac; /* 2.30 fixed-point */
-
-
-#define CF2_FIXED_MAX ( (CF2_Fixed)0x7FFFFFFFL )
-#define CF2_FIXED_MIN ( (CF2_Fixed)0x80000000L )
-#define CF2_FIXED_ONE ( (CF2_Fixed)0x10000L )
-#define CF2_FIXED_EPSILON ( (CF2_Fixed)0x0001 )
-
- /* in C 89, left and right shift of negative numbers is */
- /* implementation specific behaviour in the general case */
-
-#define cf2_intToFixed( i ) \
- ( (CF2_Fixed)( (FT_UInt32)(i) << 16 ) )
-#define cf2_fixedToInt( x ) \
- ( (FT_Short)( ( (FT_UInt32)(x) + 0x8000U ) >> 16 ) )
-#define cf2_fixedRound( x ) \
- ( (CF2_Fixed)( ( (FT_UInt32)(x) + 0x8000U ) & 0xFFFF0000UL ) )
-#define cf2_doubleToFixed( f ) \
- ( (CF2_Fixed)( (f) * 65536.0 + 0.5 ) )
-#define cf2_fixedAbs( x ) \
- ( (x) < 0 ? NEG_INT32( x ) : (x) )
-#define cf2_fixedFloor( x ) \
- ( (CF2_Fixed)( (FT_UInt32)(x) & 0xFFFF0000UL ) )
-#define cf2_fixedFraction( x ) \
- ( (x) - cf2_fixedFloor( x ) )
-#define cf2_fracToFixed( x ) \
- ( ( (x) + 0x2000 - ( (x) < 0 ) ) >> 14 )
-
-
- /* signed numeric types */
- typedef enum CF2_NumberType_
- {
- CF2_NumberFixed, /* 16.16 */
- CF2_NumberFrac, /* 2.30 */
- CF2_NumberInt /* 32.0 */
-
- } CF2_NumberType;
-
-
-FT_END_HEADER
-
-
-#endif /* PSFIXED_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/psaux/psfont.c b/contrib/libs/freetype/src/psaux/psfont.c
deleted file mode 100644
index 0db1f0c5bc..0000000000
--- a/contrib/libs/freetype/src/psaux/psfont.c
+++ /dev/null
@@ -1,566 +0,0 @@
-/****************************************************************************
- *
- * psfont.c
- *
- * Adobe's code for font instances (body).
- *
- * Copyright 2007-2014 Adobe Systems Incorporated.
- *
- * This software, and all works of authorship, whether in source or
- * object code form as indicated by the copyright notice(s) included
- * herein (collectively, the "Work") is made available, and may only be
- * used, modified, and distributed under the FreeType Project License,
- * LICENSE.TXT. Additionally, subject to the terms and conditions of the
- * FreeType Project License, each contributor to the Work hereby grants
- * to any individual or legal entity exercising permissions granted by
- * the FreeType Project License and this section (hereafter, "You" or
- * "Your") a perpetual, worldwide, non-exclusive, no-charge,
- * royalty-free, irrevocable (except as stated in this section) patent
- * license to make, have made, use, offer to sell, sell, import, and
- * otherwise transfer the Work, where such license applies only to those
- * patent claims licensable by such contributor that are necessarily
- * infringed by their contribution(s) alone or by combination of their
- * contribution(s) with the Work to which such contribution(s) was
- * submitted. If You institute patent litigation against any entity
- * (including a cross-claim or counterclaim in a lawsuit) alleging that
- * the Work or a contribution incorporated within the Work constitutes
- * direct or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate as of
- * the date such litigation is filed.
- *
- * By using, modifying, or distributing the Work you indicate that you
- * have read and understood the terms and conditions of the
- * FreeType Project License as well as those provided in this section,
- * and you accept them fully.
- *
- */
-
-
-#include <freetype/internal/ftcalc.h>
-
-#include "psft.h"
-
-#include "psglue.h"
-#include "psfont.h"
-#include "pserror.h"
-#include "psintrp.h"
-
-
- /* Compute a stem darkening amount in character space. */
- static void
- cf2_computeDarkening( CF2_Fixed emRatio,
- CF2_Fixed ppem,
- CF2_Fixed stemWidth,
- CF2_Fixed* darkenAmount,
- CF2_Fixed boldenAmount,
- FT_Bool stemDarkened,
- FT_Int* darkenParams )
- {
- /*
- * Total darkening amount is computed in 1000 unit character space
- * using the modified 5 part curve as Adobe's Avalon rasterizer.
- * The darkening amount is smaller for thicker stems.
- * It becomes zero when the stem is thicker than 2.333 pixels.
- *
- * By default, we use
- *
- * darkenAmount = 0.4 pixels if scaledStem <= 0.5 pixels,
- * darkenAmount = 0.275 pixels if 1 <= scaledStem <= 1.667 pixels,
- * darkenAmount = 0 pixel if scaledStem >= 2.333 pixels,
- *
- * and piecewise linear in-between:
- *
- *
- * darkening
- * ^
- * |
- * | (x1,y1)
- * |--------+
- * | \
- * | \
- * | \ (x3,y3)
- * | +----------+
- * | (x2,y2) \
- * | \
- * | \
- * | +-----------------
- * | (x4,y4)
- * +---------------------------------------------> stem
- * thickness
- *
- *
- * This corresponds to the following values for the
- * `darkening-parameters' property:
- *
- * (x1, y1) = (500, 400)
- * (x2, y2) = (1000, 275)
- * (x3, y3) = (1667, 275)
- * (x4, y4) = (2333, 0)
- *
- */
-
- /* Internal calculations are done in units per thousand for */
- /* convenience. The x axis is scaled stem width in */
- /* thousandths of a pixel. That is, 1000 is 1 pixel. */
- /* The y axis is darkening amount in thousandths of a pixel.*/
- /* In the code, below, dividing by ppem and */
- /* adjusting for emRatio converts darkenAmount to character */
- /* space (font units). */
- CF2_Fixed stemWidthPer1000, scaledStem;
- FT_Int logBase2;
-
-
- *darkenAmount = 0;
-
- if ( boldenAmount == 0 && !stemDarkened )
- return;
-
- /* protect against range problems and divide by zero */
- if ( emRatio < cf2_doubleToFixed( .01 ) )
- return;
-
- if ( stemDarkened )
- {
- FT_Int x1 = darkenParams[0];
- FT_Int y1 = darkenParams[1];
- FT_Int x2 = darkenParams[2];
- FT_Int y2 = darkenParams[3];
- FT_Int x3 = darkenParams[4];
- FT_Int y3 = darkenParams[5];
- FT_Int x4 = darkenParams[6];
- FT_Int y4 = darkenParams[7];
-
-
- /* convert from true character space to 1000 unit character space; */
- /* add synthetic emboldening effect */
-
- /* `stemWidthPer1000' will not overflow for a legitimate font */
-
- stemWidthPer1000 = FT_MulFix( stemWidth + boldenAmount, emRatio );
-
- /* `scaledStem' can easily overflow, so we must clamp its maximum */
- /* value; the test doesn't need to be precise, but must be */
- /* conservative. The clamp value (default 2333) where */
- /* `darkenAmount' is zero is well below the overflow value of */
- /* 32767. */
- /* */
- /* FT_MSB computes the integer part of the base 2 logarithm. The */
- /* number of bits for the product is 1 or 2 more than the sum of */
- /* logarithms; remembering that the 16 lowest bits of the fraction */
- /* are dropped this is correct to within a factor of almost 4. */
- /* For example, 0x80.0000 * 0x80.0000 = 0x4000.0000 is 23+23 and */
- /* is flagged as possible overflow because 0xFF.FFFF * 0xFF.FFFF = */
- /* 0xFFFF.FE00 is also 23+23. */
-
- logBase2 = FT_MSB( (FT_UInt32)stemWidthPer1000 ) +
- FT_MSB( (FT_UInt32)ppem );
-
- if ( logBase2 >= 46 )
- /* possible overflow */
- scaledStem = cf2_intToFixed( x4 );
- else
- scaledStem = FT_MulFix( stemWidthPer1000, ppem );
-
- /* now apply the darkening parameters */
-
- if ( scaledStem < cf2_intToFixed( x1 ) )
- *darkenAmount = FT_DivFix( cf2_intToFixed( y1 ), ppem );
-
- else if ( scaledStem < cf2_intToFixed( x2 ) )
- {
- FT_Int xdelta = x2 - x1;
- FT_Int ydelta = y2 - y1;
- FT_Int x = stemWidthPer1000 -
- FT_DivFix( cf2_intToFixed( x1 ), ppem );
-
-
- if ( !xdelta )
- goto Try_x3;
-
- *darkenAmount = FT_MulDiv( x, ydelta, xdelta ) +
- FT_DivFix( cf2_intToFixed( y1 ), ppem );
- }
-
- else if ( scaledStem < cf2_intToFixed( x3 ) )
- {
- Try_x3:
- {
- FT_Int xdelta = x3 - x2;
- FT_Int ydelta = y3 - y2;
- FT_Int x = stemWidthPer1000 -
- FT_DivFix( cf2_intToFixed( x2 ), ppem );
-
-
- if ( !xdelta )
- goto Try_x4;
-
- *darkenAmount = FT_MulDiv( x, ydelta, xdelta ) +
- FT_DivFix( cf2_intToFixed( y2 ), ppem );
- }
- }
-
- else if ( scaledStem < cf2_intToFixed( x4 ) )
- {
- Try_x4:
- {
- FT_Int xdelta = x4 - x3;
- FT_Int ydelta = y4 - y3;
- FT_Int x = stemWidthPer1000 -
- FT_DivFix( cf2_intToFixed( x3 ), ppem );
-
-
- if ( !xdelta )
- goto Use_y4;
-
- *darkenAmount = FT_MulDiv( x, ydelta, xdelta ) +
- FT_DivFix( cf2_intToFixed( y3 ), ppem );
- }
- }
-
- else
- {
- Use_y4:
- *darkenAmount = FT_DivFix( cf2_intToFixed( y4 ), ppem );
- }
-
- /* use half the amount on each side and convert back to true */
- /* character space */
- *darkenAmount = FT_DivFix( *darkenAmount, 2 * emRatio );
- }
-
- /* add synthetic emboldening effect in character space */
- *darkenAmount += boldenAmount / 2;
- }
-
-
- /* set up values for the current FontDict and matrix; */
- /* called for each glyph to be rendered */
-
- /* caller's transform is adjusted for subpixel positioning */
- static void
- cf2_font_setup( CF2_Font font,
- const CF2_Matrix* transform )
- {
- /* pointer to parsed font object */
- PS_Decoder* decoder = font->decoder;
-
- FT_Bool needExtraSetup = FALSE;
-
- CFF_VStoreRec* vstore;
- FT_Bool hasVariations = FALSE;
-
- /* character space units */
- CF2_Fixed boldenX = font->syntheticEmboldeningAmountX;
- CF2_Fixed boldenY = font->syntheticEmboldeningAmountY;
-
- CFF_SubFont subFont;
- CF2_Fixed ppem;
-
- CF2_UInt lenNormalizedV = 0;
- FT_Fixed* normalizedV = NULL;
-
- /* clear previous error */
- font->error = FT_Err_Ok;
-
- /* if a CID fontDict has changed, we need to recompute some cached */
- /* data */
- subFont = cf2_getSubfont( decoder );
- if ( font->lastSubfont != subFont )
- {
- font->lastSubfont = subFont;
- needExtraSetup = TRUE;
- }
-
- if ( !font->isT1 )
- {
- /* check for variation vectors */
- vstore = cf2_getVStore( decoder );
- hasVariations = ( vstore->dataCount != 0 );
-
- if ( hasVariations )
- {
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- FT_Service_CFFLoad cffload = (FT_Service_CFFLoad)font->cffload;
-
-
- /* check whether Private DICT in this subfont needs to be reparsed */
- font->error = cf2_getNormalizedVector( decoder,
- &lenNormalizedV,
- &normalizedV );
- if ( font->error )
- return;
-
- if ( cffload->blend_check_vector( &subFont->blend,
- subFont->private_dict.vsindex,
- lenNormalizedV,
- normalizedV ) )
- {
- /* blend has changed, reparse */
- cffload->load_private_dict( decoder->cff,
- subFont,
- lenNormalizedV,
- normalizedV );
- needExtraSetup = TRUE;
- }
-#endif
-
- /* copy from subfont */
- font->blend.font = subFont->blend.font;
-
- /* clear state of charstring blend */
- font->blend.usedBV = FALSE;
-
- /* initialize value for charstring */
- font->vsindex = subFont->private_dict.vsindex;
-
- /* store vector inputs for blends in charstring */
- font->lenNDV = lenNormalizedV;
- font->NDV = normalizedV;
- }
- }
-
- /* if ppem has changed, we need to recompute some cached data */
- /* note: because of CID font matrix concatenation, ppem and transform */
- /* do not necessarily track. */
- ppem = cf2_getPpemY( decoder );
- if ( font->ppem != ppem )
- {
- font->ppem = ppem;
- needExtraSetup = TRUE;
- }
-
- /* copy hinted flag on each call */
- font->hinted = FT_BOOL( font->renderingFlags & CF2_FlagsHinted );
-
- /* determine if transform has changed; */
- /* include Fontmatrix but ignore translation */
- if ( ft_memcmp( transform,
- &font->currentTransform,
- 4 * sizeof ( CF2_Fixed ) ) != 0 )
- {
- /* save `key' information for `cache of one' matrix data; */
- /* save client transform, without the translation */
- font->currentTransform = *transform;
- font->currentTransform.tx =
- font->currentTransform.ty = cf2_intToFixed( 0 );
-
- /* TODO: FreeType transform is simple scalar; for now, use identity */
- /* for outer */
- font->innerTransform = *transform;
- font->outerTransform.a =
- font->outerTransform.d = cf2_intToFixed( 1 );
- font->outerTransform.b =
- font->outerTransform.c = cf2_intToFixed( 0 );
-
- needExtraSetup = TRUE;
- }
-
- /*
- * font->darkened is set to true if there is a stem darkening request or
- * the font is synthetic emboldened.
- * font->darkened controls whether to adjust blue zones, winding order,
- * and hinting.
- *
- */
- if ( font->stemDarkened != ( font->renderingFlags & CF2_FlagsDarkened ) )
- {
- font->stemDarkened =
- FT_BOOL( font->renderingFlags & CF2_FlagsDarkened );
-
- /* blue zones depend on darkened flag */
- needExtraSetup = TRUE;
- }
-
- /* recompute variables that are dependent on transform or FontDict or */
- /* darken flag */
- if ( needExtraSetup )
- {
- /* StdVW is found in the private dictionary; */
- /* recompute darkening amounts whenever private dictionary or */
- /* transform change */
- /* Note: a rendering flag turns darkening on or off, so we want to */
- /* store the `on' amounts; */
- /* darkening amount is computed in character space */
- /* TODO: testing size-dependent darkening here; */
- /* what to do for rotations? */
-
- CF2_Fixed emRatio;
- CF2_Fixed stdHW;
- CF2_Int unitsPerEm = font->unitsPerEm;
-
-
- if ( unitsPerEm == 0 )
- unitsPerEm = 1000;
-
- ppem = FT_MAX( cf2_intToFixed( 4 ),
- font->ppem ); /* use minimum ppem of 4 */
-
-#if 0
- /* since vstem is measured in the x-direction, we use the `a' member */
- /* of the fontMatrix */
- emRatio = cf2_fixedFracMul( cf2_intToFixed( 1000 ), fontMatrix->a );
-#endif
-
- /* Freetype does not preserve the fontMatrix when parsing; use */
- /* unitsPerEm instead. */
- /* TODO: check precision of this */
- emRatio = cf2_intToFixed( 1000 ) / unitsPerEm;
- font->stdVW = cf2_getStdVW( decoder );
-
- if ( font->stdVW <= 0 )
- font->stdVW = FT_DivFix( cf2_intToFixed( 75 ), emRatio );
-
- if ( boldenX > 0 )
- {
- /* Ensure that boldenX is at least 1 pixel for synthetic bold font */
- /* (similar to what Avalon does) */
- boldenX = FT_MAX( boldenX,
- FT_DivFix( cf2_intToFixed( unitsPerEm ), ppem ) );
-
- /* Synthetic emboldening adds at least 1 pixel to darkenX, while */
- /* stem darkening adds at most half pixel. Since the purpose of */
- /* stem darkening (readability at small sizes) is met with */
- /* synthetic emboldening, no need to add stem darkening for a */
- /* synthetic bold font. */
- cf2_computeDarkening( emRatio,
- ppem,
- font->stdVW,
- &font->darkenX,
- boldenX,
- FALSE,
- font->darkenParams );
- }
- else
- cf2_computeDarkening( emRatio,
- ppem,
- font->stdVW,
- &font->darkenX,
- 0,
- font->stemDarkened,
- font->darkenParams );
-
-#if 0
- /* since hstem is measured in the y-direction, we use the `d' member */
- /* of the fontMatrix */
- /* TODO: use the same units per em as above; check this */
- emRatio = cf2_fixedFracMul( cf2_intToFixed( 1000 ), fontMatrix->d );
-#endif
-
- /* set the default stem width, because it must be the same for all */
- /* family members; */
- /* choose a constant for StdHW that depends on font contrast */
- stdHW = cf2_getStdHW( decoder );
-
- if ( stdHW > 0 && font->stdVW > MUL_INT32( 2, stdHW ) )
- font->stdHW = FT_DivFix( cf2_intToFixed( 75 ), emRatio );
- else
- {
- /* low contrast font gets less hstem darkening */
- font->stdHW = FT_DivFix( cf2_intToFixed( 110 ), emRatio );
- }
-
- cf2_computeDarkening( emRatio,
- ppem,
- font->stdHW,
- &font->darkenY,
- boldenY,
- font->stemDarkened,
- font->darkenParams );
-
- if ( font->darkenX != 0 || font->darkenY != 0 )
- font->darkened = TRUE;
- else
- font->darkened = FALSE;
-
- font->reverseWinding = FALSE; /* initial expectation is CCW */
-
- /* compute blue zones for this instance */
- cf2_blues_init( &font->blues, font );
-
- } /* needExtraSetup */
- }
-
-
- /* equivalent to AdobeGetOutline */
- FT_LOCAL_DEF( FT_Error )
- cf2_getGlyphOutline( CF2_Font font,
- CF2_Buffer charstring,
- const CF2_Matrix* transform,
- CF2_F16Dot16* glyphWidth )
- {
- FT_Error lastError = FT_Err_Ok;
-
- FT_Vector translation;
-
-#if 0
- FT_Vector advancePoint;
-#endif
-
- CF2_Fixed advWidth = 0;
- FT_Bool needWinding;
-
-
- /* Note: use both integer and fraction for outlines. This allows bbox */
- /* to come out directly. */
-
- translation.x = transform->tx;
- translation.y = transform->ty;
-
- /* set up values based on transform */
- cf2_font_setup( font, transform );
- if ( font->error )
- goto exit; /* setup encountered an error */
-
- /* reset darken direction */
- font->reverseWinding = FALSE;
-
- /* winding order only affects darkening */
- needWinding = font->darkened;
-
- while ( 1 )
- {
- /* reset output buffer */
- cf2_outline_reset( &font->outline );
-
- /* build the outline, passing the full translation */
- cf2_interpT2CharString( font,
- charstring,
- (CF2_OutlineCallbacks)&font->outline,
- &translation,
- FALSE,
- 0,
- 0,
- &advWidth );
-
- if ( font->error )
- goto exit;
-
- if ( !needWinding )
- break;
-
- /* check winding order */
- if ( font->outline.root.windingMomentum >= 0 ) /* CFF is CCW */
- break;
-
- /* invert darkening and render again */
- /* TODO: this should be a parameter to getOutline-computeOffset */
- font->reverseWinding = TRUE;
-
- needWinding = FALSE; /* exit after next iteration */
- }
-
- /* finish storing client outline */
- cf2_outline_close( &font->outline );
-
- exit:
- /* FreeType just wants the advance width; there is no translation */
- *glyphWidth = advWidth;
-
- /* free resources and collect errors from objects we've used */
- cf2_setError( &font->error, lastError );
-
- return font->error;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/psaux/psfont.h b/contrib/libs/freetype/src/psaux/psfont.h
deleted file mode 100644
index 836fce4e4d..0000000000
--- a/contrib/libs/freetype/src/psaux/psfont.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/****************************************************************************
- *
- * psfont.h
- *
- * Adobe's code for font instances (specification).
- *
- * Copyright 2007-2013 Adobe Systems Incorporated.
- *
- * This software, and all works of authorship, whether in source or
- * object code form as indicated by the copyright notice(s) included
- * herein (collectively, the "Work") is made available, and may only be
- * used, modified, and distributed under the FreeType Project License,
- * LICENSE.TXT. Additionally, subject to the terms and conditions of the
- * FreeType Project License, each contributor to the Work hereby grants
- * to any individual or legal entity exercising permissions granted by
- * the FreeType Project License and this section (hereafter, "You" or
- * "Your") a perpetual, worldwide, non-exclusive, no-charge,
- * royalty-free, irrevocable (except as stated in this section) patent
- * license to make, have made, use, offer to sell, sell, import, and
- * otherwise transfer the Work, where such license applies only to those
- * patent claims licensable by such contributor that are necessarily
- * infringed by their contribution(s) alone or by combination of their
- * contribution(s) with the Work to which such contribution(s) was
- * submitted. If You institute patent litigation against any entity
- * (including a cross-claim or counterclaim in a lawsuit) alleging that
- * the Work or a contribution incorporated within the Work constitutes
- * direct or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate as of
- * the date such litigation is filed.
- *
- * By using, modifying, or distributing the Work you indicate that you
- * have read and understood the terms and conditions of the
- * FreeType Project License as well as those provided in this section,
- * and you accept them fully.
- *
- */
-
-
-#ifndef PSFONT_H_
-#define PSFONT_H_
-
-
-#include <freetype/internal/services/svcfftl.h>
-
-#include "psft.h"
-#include "psblues.h"
-
-
-FT_BEGIN_HEADER
-
-
-#define CF2_OPERAND_STACK_SIZE 48
-#define CF2_MAX_SUBR 16 /* maximum subroutine nesting; */
- /* only 10 are allowed but there exist */
- /* fonts like `HiraKakuProN-W3.ttf' */
- /* (Hiragino Kaku Gothic ProN W3; */
- /* 8.2d6e1; 2014-12-19) that exceed */
- /* this limit */
-#define CF2_STORAGE_SIZE 32
-
-
- /* typedef is in `cf2glue.h' */
- struct CF2_FontRec_
- {
- FT_Memory memory;
- FT_Error error; /* shared error for this instance */
-
- FT_Bool isT1;
- FT_Bool isCFF2;
- CF2_RenderingFlags renderingFlags;
-
- /* variables that depend on Transform: */
- /* the following have zero translation; */
- /* inner * outer = font * original */
-
- CF2_Matrix currentTransform; /* original client matrix */
- CF2_Matrix innerTransform; /* for hinting; erect, scaled */
- CF2_Matrix outerTransform; /* post hinting; includes rotations */
- CF2_Fixed ppem; /* transform-dependent */
-
- /* variation data */
- CFF_BlendRec blend; /* cached charstring blend vector */
- CF2_UInt vsindex; /* current vsindex */
- CF2_UInt lenNDV; /* current length NDV or zero */
- FT_Fixed* NDV; /* ptr to current NDV or NULL */
-
- CF2_Int unitsPerEm;
-
- CF2_Fixed syntheticEmboldeningAmountX; /* character space units */
- CF2_Fixed syntheticEmboldeningAmountY; /* character space units */
-
- /* FreeType related members */
- CF2_OutlineRec outline; /* freetype glyph outline functions */
- PS_Decoder* decoder;
- CFF_SubFont lastSubfont; /* FreeType parsed data; */
- /* top font or subfont */
-
- /* these flags can vary from one call to the next */
- FT_Bool hinted;
- FT_Bool darkened; /* true if stemDarkened or synthetic bold */
- /* i.e. darkenX != 0 || darkenY != 0 */
- FT_Bool stemDarkened;
-
- FT_Int darkenParams[8]; /* 1000 unit character space */
-
- /* variables that depend on both FontDict and Transform */
- CF2_Fixed stdVW; /* in character space; depends on dict entry */
- CF2_Fixed stdHW; /* in character space; depends on dict entry */
- CF2_Fixed darkenX; /* character space units */
- CF2_Fixed darkenY; /* depends on transform */
- /* and private dict (StdVW) */
- FT_Bool reverseWinding; /* darken assuming */
- /* counterclockwise winding */
-
- CF2_BluesRec blues; /* computed zone data */
-
- FT_Service_CFFLoad cffload; /* pointer to cff functions */
- };
-
-
- FT_LOCAL( FT_Error )
- cf2_getGlyphOutline( CF2_Font font,
- CF2_Buffer charstring,
- const CF2_Matrix* transform,
- CF2_F16Dot16* glyphWidth );
-
-
-FT_END_HEADER
-
-
-#endif /* PSFONT_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/psaux/psft.c b/contrib/libs/freetype/src/psaux/psft.c
deleted file mode 100644
index fd0abe1715..0000000000
--- a/contrib/libs/freetype/src/psaux/psft.c
+++ /dev/null
@@ -1,895 +0,0 @@
-/****************************************************************************
- *
- * psft.c
- *
- * FreeType Glue Component to Adobe's Interpreter (body).
- *
- * Copyright 2013-2014 Adobe Systems Incorporated.
- *
- * This software, and all works of authorship, whether in source or
- * object code form as indicated by the copyright notice(s) included
- * herein (collectively, the "Work") is made available, and may only be
- * used, modified, and distributed under the FreeType Project License,
- * LICENSE.TXT. Additionally, subject to the terms and conditions of the
- * FreeType Project License, each contributor to the Work hereby grants
- * to any individual or legal entity exercising permissions granted by
- * the FreeType Project License and this section (hereafter, "You" or
- * "Your") a perpetual, worldwide, non-exclusive, no-charge,
- * royalty-free, irrevocable (except as stated in this section) patent
- * license to make, have made, use, offer to sell, sell, import, and
- * otherwise transfer the Work, where such license applies only to those
- * patent claims licensable by such contributor that are necessarily
- * infringed by their contribution(s) alone or by combination of their
- * contribution(s) with the Work to which such contribution(s) was
- * submitted. If You institute patent litigation against any entity
- * (including a cross-claim or counterclaim in a lawsuit) alleging that
- * the Work or a contribution incorporated within the Work constitutes
- * direct or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate as of
- * the date such litigation is filed.
- *
- * By using, modifying, or distributing the Work you indicate that you
- * have read and understood the terms and conditions of the
- * FreeType Project License as well as those provided in this section,
- * and you accept them fully.
- *
- */
-
-
-#include "psft.h"
-#include <freetype/internal/ftdebug.h>
-
-#include "psfont.h"
-#include "pserror.h"
-#include "psobjs.h"
-#include "cffdecode.h"
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
-#include <freetype/ftmm.h>
-#include <freetype/internal/services/svmm.h>
-#endif
-
-#include <freetype/internal/services/svcfftl.h>
-
-
-#define CF2_MAX_SIZE cf2_intToFixed( 2000 ) /* max ppem */
-
-
- /*
- * This check should avoid most internal overflow cases. Clients should
- * generally respond to `Glyph_Too_Big' by getting a glyph outline
- * at EM size, scaling it and filling it as a graphics operation.
- *
- */
- static FT_Error
- cf2_checkTransform( const CF2_Matrix* transform,
- CF2_Int unitsPerEm )
- {
- CF2_Fixed maxScale;
-
-
- if ( transform->a <= 0 || transform->d <= 0 )
- return FT_THROW( Invalid_Size_Handle );
-
- FT_ASSERT( unitsPerEm > 0 );
- FT_ASSERT( transform->b == 0 && transform->c == 0 );
- FT_ASSERT( transform->tx == 0 && transform->ty == 0 );
-
- if ( unitsPerEm > 0x7FFF )
- return FT_THROW( Glyph_Too_Big );
-
- maxScale = FT_DivFix( CF2_MAX_SIZE, cf2_intToFixed( unitsPerEm ) );
-
- if ( transform->a > maxScale || transform->d > maxScale )
- return FT_THROW( Glyph_Too_Big );
-
- return FT_Err_Ok;
- }
-
-
- static void
- cf2_setGlyphWidth( CF2_Outline outline,
- CF2_Fixed width )
- {
- PS_Decoder* decoder = outline->decoder;
-
-
- FT_ASSERT( decoder );
-
- if ( !decoder->builder.is_t1 )
- *decoder->glyph_width = cf2_fixedToInt( width );
- }
-
-
- /* Clean up font instance. */
- static void
- cf2_free_instance( void* ptr )
- {
- CF2_Font font = (CF2_Font)ptr;
-
-
- if ( font )
- {
- FT_Memory memory = font->memory;
-
-
- FT_FREE( font->blend.lastNDV );
- FT_FREE( font->blend.BV );
- }
- }
-
-
- /*********************************************
- *
- * functions for handling client outline;
- * FreeType uses coordinates in 26.6 format
- *
- */
-
- static void
- cf2_builder_moveTo( CF2_OutlineCallbacks callbacks,
- const CF2_CallbackParams params )
- {
- /* downcast the object pointer */
- CF2_Outline outline = (CF2_Outline)callbacks;
- PS_Builder* builder;
-
- (void)params; /* only used in debug mode */
-
-
- FT_ASSERT( outline && outline->decoder );
- FT_ASSERT( params->op == CF2_PathOpMoveTo );
-
- builder = &outline->decoder->builder;
-
- /* note: two successive moves simply close the contour twice */
- ps_builder_close_contour( builder );
- builder->path_begun = 0;
- }
-
-
- static void
- cf2_builder_lineTo( CF2_OutlineCallbacks callbacks,
- const CF2_CallbackParams params )
- {
- FT_Error error;
-
- /* downcast the object pointer */
- CF2_Outline outline = (CF2_Outline)callbacks;
- PS_Builder* builder;
-
-
- FT_ASSERT( outline && outline->decoder );
- FT_ASSERT( params->op == CF2_PathOpLineTo );
-
- builder = &outline->decoder->builder;
-
- if ( !builder->path_begun )
- {
- /* record the move before the line; also check points and set */
- /* `path_begun' */
- error = ps_builder_start_point( builder,
- params->pt0.x,
- params->pt0.y );
- if ( error )
- {
- if ( !*callbacks->error )
- *callbacks->error = error;
- return;
- }
- }
-
- /* `ps_builder_add_point1' includes a check_points call for one point */
- error = ps_builder_add_point1( builder,
- params->pt1.x,
- params->pt1.y );
- if ( error )
- {
- if ( !*callbacks->error )
- *callbacks->error = error;
- return;
- }
- }
-
-
- static void
- cf2_builder_cubeTo( CF2_OutlineCallbacks callbacks,
- const CF2_CallbackParams params )
- {
- FT_Error error;
-
- /* downcast the object pointer */
- CF2_Outline outline = (CF2_Outline)callbacks;
- PS_Builder* builder;
-
-
- FT_ASSERT( outline && outline->decoder );
- FT_ASSERT( params->op == CF2_PathOpCubeTo );
-
- builder = &outline->decoder->builder;
-
- if ( !builder->path_begun )
- {
- /* record the move before the line; also check points and set */
- /* `path_begun' */
- error = ps_builder_start_point( builder,
- params->pt0.x,
- params->pt0.y );
- if ( error )
- {
- if ( !*callbacks->error )
- *callbacks->error = error;
- return;
- }
- }
-
- /* prepare room for 3 points: 2 off-curve, 1 on-curve */
- error = ps_builder_check_points( builder, 3 );
- if ( error )
- {
- if ( !*callbacks->error )
- *callbacks->error = error;
- return;
- }
-
- ps_builder_add_point( builder,
- params->pt1.x,
- params->pt1.y, 0 );
- ps_builder_add_point( builder,
- params->pt2.x,
- params->pt2.y, 0 );
- ps_builder_add_point( builder,
- params->pt3.x,
- params->pt3.y, 1 );
- }
-
-
- static void
- cf2_outline_init( CF2_Outline outline,
- FT_Memory memory,
- FT_Error* error )
- {
- FT_ZERO( outline );
-
- outline->root.memory = memory;
- outline->root.error = error;
-
- outline->root.moveTo = cf2_builder_moveTo;
- outline->root.lineTo = cf2_builder_lineTo;
- outline->root.cubeTo = cf2_builder_cubeTo;
- }
-
-
- /* get scaling and hint flag from GlyphSlot */
- static void
- cf2_getScaleAndHintFlag( PS_Decoder* decoder,
- CF2_Fixed* x_scale,
- CF2_Fixed* y_scale,
- FT_Bool* hinted,
- FT_Bool* scaled )
- {
- FT_ASSERT( decoder && decoder->builder.glyph );
-
- /* note: FreeType scale includes a factor of 64 */
- *hinted = decoder->builder.glyph->hint;
- *scaled = decoder->builder.glyph->scaled;
-
- if ( *hinted )
- {
- *x_scale = ADD_INT32( decoder->builder.glyph->x_scale, 32 ) / 64;
- *y_scale = ADD_INT32( decoder->builder.glyph->y_scale, 32 ) / 64;
- }
- else
- {
- /* for unhinted outlines, `cff_slot_load' does the scaling, */
- /* thus render at `unity' scale */
-
- *x_scale = 0x0400; /* 1/64 as 16.16 */
- *y_scale = 0x0400;
- }
- }
-
-
- /* get units per em from `FT_Face' */
- /* TODO: should handle font matrix concatenation? */
- static FT_UShort
- cf2_getUnitsPerEm( PS_Decoder* decoder )
- {
- FT_ASSERT( decoder && decoder->builder.face );
-
- return decoder->builder.face->units_per_EM;
- }
-
-
- /* Main entry point: Render one glyph. */
- FT_LOCAL_DEF( FT_Error )
- cf2_decoder_parse_charstrings( PS_Decoder* decoder,
- FT_Byte* charstring_base,
- FT_ULong charstring_len )
- {
- FT_Memory memory;
- FT_Error error = FT_Err_Ok;
- CF2_Font font;
-
- FT_Bool is_t1 = decoder->builder.is_t1;
-
-
- FT_ASSERT( decoder &&
- ( is_t1 || decoder->cff ) );
-
- if ( is_t1 && !decoder->current_subfont )
- {
- FT_ERROR(( "cf2_decoder_parse_charstrings (Type 1): "
- "SubFont missing. Use `t1_make_subfont' first\n" ));
- return FT_THROW( Invalid_Table );
- }
-
- memory = decoder->builder.memory;
-
- /* CF2 data is saved here across glyphs */
- font = (CF2_Font)decoder->cf2_instance->data;
-
- /* on first glyph, allocate instance structure */
- if ( !decoder->cf2_instance->data )
- {
- decoder->cf2_instance->finalizer =
- (FT_Generic_Finalizer)cf2_free_instance;
-
- if ( FT_ALLOC( decoder->cf2_instance->data,
- sizeof ( CF2_FontRec ) ) )
- return FT_THROW( Out_Of_Memory );
-
- font = (CF2_Font)decoder->cf2_instance->data;
-
- font->memory = memory;
-
- if ( !is_t1 )
- font->cffload = (FT_Service_CFFLoad)decoder->cff->cffload;
-
- /* initialize a client outline, to be shared by each glyph rendered */
- cf2_outline_init( &font->outline, font->memory, &font->error );
- }
-
- /* save decoder; it is a stack variable and will be different on each */
- /* call */
- font->decoder = decoder;
- font->outline.decoder = decoder;
-
- {
- /* build parameters for Adobe engine */
-
- PS_Builder* builder = &decoder->builder;
- PS_Driver driver = (PS_Driver)FT_FACE_DRIVER( builder->face );
-
- FT_Bool no_stem_darkening_driver =
- driver->no_stem_darkening;
- FT_Char no_stem_darkening_font =
- builder->face->internal->no_stem_darkening;
-
- /* local error */
- FT_Error error2 = FT_Err_Ok;
- CF2_BufferRec buf;
- CF2_Matrix transform;
- CF2_F16Dot16 glyphWidth;
-
- FT_Bool hinted;
- FT_Bool scaled;
-
-
- /* FreeType has already looked up the GID; convert to */
- /* `RegionBuffer', assuming that the input has been validated */
- FT_ASSERT( charstring_base + charstring_len >= charstring_base );
-
- FT_ZERO( &buf );
- buf.start =
- buf.ptr = charstring_base;
- buf.end = FT_OFFSET( charstring_base, charstring_len );
-
- FT_ZERO( &transform );
-
- cf2_getScaleAndHintFlag( decoder,
- &transform.a,
- &transform.d,
- &hinted,
- &scaled );
-
- if ( is_t1 )
- font->isCFF2 = FALSE;
- else
- {
- /* copy isCFF2 boolean from TT_Face to CF2_Font */
- font->isCFF2 = ((TT_Face)builder->face)->is_cff2;
- }
- font->isT1 = is_t1;
-
- font->renderingFlags = 0;
- if ( hinted )
- font->renderingFlags |= CF2_FlagsHinted;
- if ( scaled && ( !no_stem_darkening_font ||
- ( no_stem_darkening_font < 0 &&
- !no_stem_darkening_driver ) ) )
- font->renderingFlags |= CF2_FlagsDarkened;
-
- font->darkenParams[0] = driver->darken_params[0];
- font->darkenParams[1] = driver->darken_params[1];
- font->darkenParams[2] = driver->darken_params[2];
- font->darkenParams[3] = driver->darken_params[3];
- font->darkenParams[4] = driver->darken_params[4];
- font->darkenParams[5] = driver->darken_params[5];
- font->darkenParams[6] = driver->darken_params[6];
- font->darkenParams[7] = driver->darken_params[7];
-
- /* now get an outline for this glyph; */
- /* also get units per em to validate scale */
- font->unitsPerEm = (CF2_Int)cf2_getUnitsPerEm( decoder );
-
- if ( scaled )
- {
- error2 = cf2_checkTransform( &transform, font->unitsPerEm );
- if ( error2 )
- return error2;
- }
-
- error2 = cf2_getGlyphOutline( font, &buf, &transform, &glyphWidth );
- if ( error2 )
- return FT_ERR( Invalid_File_Format );
-
- cf2_setGlyphWidth( &font->outline, glyphWidth );
-
- return FT_Err_Ok;
- }
- }
-
-
- /* get pointer to current FreeType subfont (based on current glyphID) */
- FT_LOCAL_DEF( CFF_SubFont )
- cf2_getSubfont( PS_Decoder* decoder )
- {
- FT_ASSERT( decoder && decoder->current_subfont );
-
- return decoder->current_subfont;
- }
-
-
- /* get pointer to VStore structure */
- FT_LOCAL_DEF( CFF_VStore )
- cf2_getVStore( PS_Decoder* decoder )
- {
- FT_ASSERT( decoder && decoder->cff );
-
- return &decoder->cff->vstore;
- }
-
-
- /* get maxstack value from CFF2 Top DICT */
- FT_LOCAL_DEF( FT_UInt )
- cf2_getMaxstack( PS_Decoder* decoder )
- {
- FT_ASSERT( decoder && decoder->cff );
-
- return decoder->cff->top_font.font_dict.maxstack;
- }
-
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- /* Get normalized design vector for current render request; */
- /* return pointer and length. */
- /* */
- /* Note: Uses FT_Fixed not CF2_Fixed for the vector. */
- FT_LOCAL_DEF( FT_Error )
- cf2_getNormalizedVector( PS_Decoder* decoder,
- CF2_UInt *len,
- FT_Fixed* *vec )
- {
- TT_Face face;
- FT_Service_MultiMasters mm;
-
-
- FT_ASSERT( decoder && decoder->builder.face );
- FT_ASSERT( vec && len );
- FT_ASSERT( !decoder->builder.is_t1 );
-
- face = (TT_Face)decoder->builder.face;
- mm = (FT_Service_MultiMasters)face->mm;
-
- return mm->get_var_blend( FT_FACE( face ), len, NULL, vec, NULL );
- }
-#endif
-
-
- /* get `y_ppem' from `CFF_Size' */
- FT_LOCAL_DEF( CF2_Fixed )
- cf2_getPpemY( PS_Decoder* decoder )
- {
- FT_ASSERT( decoder &&
- decoder->builder.face &&
- decoder->builder.face->size );
-
- /*
- * Note that `y_ppem' can be zero if there wasn't a call to
- * `FT_Set_Char_Size' or something similar. However, this isn't a
- * problem since we come to this place in the code only if
- * FT_LOAD_NO_SCALE is set (the other case gets caught by
- * `cf2_checkTransform'). The ppem value is needed to compute the stem
- * darkening, which is disabled for getting the unscaled outline.
- *
- */
- return cf2_intToFixed(
- decoder->builder.face->size->metrics.y_ppem );
- }
-
-
- /* get standard stem widths for the current subfont; */
- /* FreeType stores these as integer font units */
- /* (note: variable names seem swapped) */
- FT_LOCAL_DEF( CF2_Fixed )
- cf2_getStdVW( PS_Decoder* decoder )
- {
- FT_ASSERT( decoder && decoder->current_subfont );
-
- return cf2_intToFixed(
- decoder->current_subfont->private_dict.standard_height );
- }
-
-
- FT_LOCAL_DEF( CF2_Fixed )
- cf2_getStdHW( PS_Decoder* decoder )
- {
- FT_ASSERT( decoder && decoder->current_subfont );
-
- return cf2_intToFixed(
- decoder->current_subfont->private_dict.standard_width );
- }
-
-
- /* note: FreeType stores 1000 times the actual value for `BlueScale' */
- FT_LOCAL_DEF( void )
- cf2_getBlueMetrics( PS_Decoder* decoder,
- CF2_Fixed* blueScale,
- CF2_Fixed* blueShift,
- CF2_Fixed* blueFuzz )
- {
- FT_ASSERT( decoder && decoder->current_subfont );
-
- *blueScale = FT_DivFix(
- decoder->current_subfont->private_dict.blue_scale,
- cf2_intToFixed( 1000 ) );
- *blueShift = cf2_intToFixed(
- decoder->current_subfont->private_dict.blue_shift );
- *blueFuzz = cf2_intToFixed(
- decoder->current_subfont->private_dict.blue_fuzz );
- }
-
-
- /* get blue values counts and arrays; the FreeType parser has validated */
- /* the counts and verified that each is an even number */
- FT_LOCAL_DEF( void )
- cf2_getBlueValues( PS_Decoder* decoder,
- size_t* count,
- FT_Fixed* *data )
- {
- FT_ASSERT( decoder && decoder->current_subfont );
-
- *count = decoder->current_subfont->private_dict.num_blue_values;
- *data = (FT_Fixed*)
- &decoder->current_subfont->private_dict.blue_values;
- }
-
-
- FT_LOCAL_DEF( void )
- cf2_getOtherBlues( PS_Decoder* decoder,
- size_t* count,
- FT_Fixed* *data )
- {
- FT_ASSERT( decoder && decoder->current_subfont );
-
- *count = decoder->current_subfont->private_dict.num_other_blues;
- *data = (FT_Fixed*)
- &decoder->current_subfont->private_dict.other_blues;
- }
-
-
- FT_LOCAL_DEF( void )
- cf2_getFamilyBlues( PS_Decoder* decoder,
- size_t* count,
- FT_Fixed* *data )
- {
- FT_ASSERT( decoder && decoder->current_subfont );
-
- *count = decoder->current_subfont->private_dict.num_family_blues;
- *data = (FT_Fixed*)
- &decoder->current_subfont->private_dict.family_blues;
- }
-
-
- FT_LOCAL_DEF( void )
- cf2_getFamilyOtherBlues( PS_Decoder* decoder,
- size_t* count,
- FT_Fixed* *data )
- {
- FT_ASSERT( decoder && decoder->current_subfont );
-
- *count = decoder->current_subfont->private_dict.num_family_other_blues;
- *data = (FT_Fixed*)
- &decoder->current_subfont->private_dict.family_other_blues;
- }
-
-
- FT_LOCAL_DEF( CF2_Int )
- cf2_getLanguageGroup( PS_Decoder* decoder )
- {
- FT_ASSERT( decoder && decoder->current_subfont );
-
- return decoder->current_subfont->private_dict.language_group;
- }
-
-
- /* convert unbiased subroutine index to `CF2_Buffer' and */
- /* return 0 on success */
- FT_LOCAL_DEF( CF2_Int )
- cf2_initGlobalRegionBuffer( PS_Decoder* decoder,
- CF2_Int subrNum,
- CF2_Buffer buf )
- {
- CF2_UInt idx;
-
-
- FT_ASSERT( decoder );
-
- FT_ZERO( buf );
-
- idx = (CF2_UInt)( subrNum + decoder->globals_bias );
- if ( idx >= decoder->num_globals )
- return TRUE; /* error */
-
- FT_ASSERT( decoder->globals );
-
- buf->start =
- buf->ptr = decoder->globals[idx];
- buf->end = decoder->globals[idx + 1];
-
- return FALSE; /* success */
- }
-
-
- /* convert AdobeStandardEncoding code to CF2_Buffer; */
- /* used for seac component */
- FT_LOCAL_DEF( FT_Error )
- cf2_getSeacComponent( PS_Decoder* decoder,
- CF2_Int code,
- CF2_Buffer buf )
- {
- CF2_Int gid;
- FT_Byte* charstring;
- FT_ULong len;
- FT_Error error;
-
-
- FT_ASSERT( decoder );
- FT_ASSERT( !decoder->builder.is_t1 );
-
- FT_ZERO( buf );
-
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- /* Incremental fonts don't necessarily have valid charsets. */
- /* They use the character code, not the glyph index, in this case. */
- if ( decoder->builder.face->internal->incremental_interface )
- gid = code;
- else
-#endif /* FT_CONFIG_OPTION_INCREMENTAL */
- {
- gid = cff_lookup_glyph_by_stdcharcode( decoder->cff, code );
- if ( gid < 0 )
- return FT_THROW( Invalid_Glyph_Format );
- }
-
- error = decoder->get_glyph_callback( (TT_Face)decoder->builder.face,
- (CF2_UInt)gid,
- &charstring,
- &len );
- /* TODO: for now, just pass the FreeType error through */
- if ( error )
- return error;
-
- /* assume input has been validated */
- FT_ASSERT( charstring + len >= charstring );
-
- buf->start = charstring;
- buf->end = FT_OFFSET( charstring, len );
- buf->ptr = buf->start;
-
- return FT_Err_Ok;
- }
-
-
- FT_LOCAL_DEF( void )
- cf2_freeSeacComponent( PS_Decoder* decoder,
- CF2_Buffer buf )
- {
- FT_ASSERT( decoder );
- FT_ASSERT( !decoder->builder.is_t1 );
-
- decoder->free_glyph_callback( (TT_Face)decoder->builder.face,
- (FT_Byte**)&buf->start,
- (FT_ULong)( buf->end - buf->start ) );
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- cf2_getT1SeacComponent( PS_Decoder* decoder,
- FT_UInt glyph_index,
- CF2_Buffer buf )
- {
- FT_Data glyph_data;
- FT_Error error = FT_Err_Ok;
- T1_Face face = (T1_Face)decoder->builder.face;
- T1_Font type1 = &face->type1;
-
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- FT_Incremental_InterfaceRec *inc =
- face->root.internal->incremental_interface;
-
-
- /* For incremental fonts get the character data using the */
- /* callback function. */
- if ( inc )
- error = inc->funcs->get_glyph_data( inc->object,
- glyph_index, &glyph_data );
- else
-#endif
- /* For ordinary fonts get the character data stored in the face record. */
- {
- glyph_data.pointer = type1->charstrings[glyph_index];
- glyph_data.length = type1->charstrings_len[glyph_index];
- }
-
- if ( !error )
- {
- FT_Byte* charstring_base = (FT_Byte*)glyph_data.pointer;
- FT_ULong charstring_len = glyph_data.length;
-
-
- FT_ASSERT( charstring_base + charstring_len >= charstring_base );
-
- FT_ZERO( buf );
- buf->start =
- buf->ptr = charstring_base;
- buf->end = charstring_base + charstring_len;
- }
-
- return error;
- }
-
-
- FT_LOCAL_DEF( void )
- cf2_freeT1SeacComponent( PS_Decoder* decoder,
- CF2_Buffer buf )
- {
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
-
- T1_Face face;
- FT_Data data;
-
-
- FT_ASSERT( decoder );
-
- face = (T1_Face)decoder->builder.face;
-
- data.pointer = buf->start;
- data.length = (FT_UInt)( buf->end - buf->start );
-
- if ( face->root.internal->incremental_interface )
- face->root.internal->incremental_interface->funcs->free_glyph_data(
- face->root.internal->incremental_interface->object,
- &data );
-
-#else /* !FT_CONFIG_OPTION_INCREMENTAL */
-
- FT_UNUSED( decoder );
- FT_UNUSED( buf );
-
-#endif /* !FT_CONFIG_OPTION_INCREMENTAL */
- }
-
-
- FT_LOCAL_DEF( CF2_Int )
- cf2_initLocalRegionBuffer( PS_Decoder* decoder,
- CF2_Int subrNum,
- CF2_Buffer buf )
- {
- CF2_UInt idx;
-
-
- FT_ASSERT( decoder );
-
- FT_ZERO( buf );
-
- idx = (CF2_UInt)( subrNum + decoder->locals_bias );
- if ( idx >= decoder->num_locals )
- return TRUE; /* error */
-
- FT_ASSERT( decoder->locals );
-
- buf->start = decoder->locals[idx];
-
- if ( decoder->builder.is_t1 )
- {
- /* The Type 1 driver stores subroutines without the seed bytes. */
- /* The CID driver stores subroutines with seed bytes. This */
- /* case is taken care of when decoder->subrs_len == 0. */
- if ( decoder->locals_len )
- buf->end = FT_OFFSET( buf->start, decoder->locals_len[idx] );
- else
- {
- /* We are using subroutines from a CID font. We must adjust */
- /* for the seed bytes. */
- buf->start += ( decoder->lenIV >= 0 ? decoder->lenIV : 0 );
- buf->end = decoder->locals[idx + 1];
- }
-
- if ( !buf->start )
- {
- FT_ERROR(( "cf2_initLocalRegionBuffer (Type 1 mode):"
- " invoking empty subrs\n" ));
- }
- }
- else
- {
- buf->end = decoder->locals[idx + 1];
- }
-
- buf->ptr = buf->start;
-
- return FALSE; /* success */
- }
-
-
- FT_LOCAL_DEF( CF2_Fixed )
- cf2_getDefaultWidthX( PS_Decoder* decoder )
- {
- FT_ASSERT( decoder && decoder->current_subfont );
-
- return cf2_intToFixed(
- decoder->current_subfont->private_dict.default_width );
- }
-
-
- FT_LOCAL_DEF( CF2_Fixed )
- cf2_getNominalWidthX( PS_Decoder* decoder )
- {
- FT_ASSERT( decoder && decoder->current_subfont );
-
- return cf2_intToFixed(
- decoder->current_subfont->private_dict.nominal_width );
- }
-
-
- FT_LOCAL_DEF( void )
- cf2_outline_reset( CF2_Outline outline )
- {
- PS_Decoder* decoder = outline->decoder;
-
-
- FT_ASSERT( decoder );
-
- outline->root.windingMomentum = 0;
-
- FT_GlyphLoader_Rewind( decoder->builder.loader );
- }
-
-
- FT_LOCAL_DEF( void )
- cf2_outline_close( CF2_Outline outline )
- {
- PS_Decoder* decoder = outline->decoder;
-
-
- FT_ASSERT( decoder );
-
- ps_builder_close_contour( &decoder->builder );
-
- FT_GlyphLoader_Add( decoder->builder.loader );
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/psaux/psft.h b/contrib/libs/freetype/src/psaux/psft.h
deleted file mode 100644
index d9082f3a2b..0000000000
--- a/contrib/libs/freetype/src/psaux/psft.h
+++ /dev/null
@@ -1,167 +0,0 @@
-/****************************************************************************
- *
- * psft.h
- *
- * FreeType Glue Component to Adobe's Interpreter (specification).
- *
- * Copyright 2013 Adobe Systems Incorporated.
- *
- * This software, and all works of authorship, whether in source or
- * object code form as indicated by the copyright notice(s) included
- * herein (collectively, the "Work") is made available, and may only be
- * used, modified, and distributed under the FreeType Project License,
- * LICENSE.TXT. Additionally, subject to the terms and conditions of the
- * FreeType Project License, each contributor to the Work hereby grants
- * to any individual or legal entity exercising permissions granted by
- * the FreeType Project License and this section (hereafter, "You" or
- * "Your") a perpetual, worldwide, non-exclusive, no-charge,
- * royalty-free, irrevocable (except as stated in this section) patent
- * license to make, have made, use, offer to sell, sell, import, and
- * otherwise transfer the Work, where such license applies only to those
- * patent claims licensable by such contributor that are necessarily
- * infringed by their contribution(s) alone or by combination of their
- * contribution(s) with the Work to which such contribution(s) was
- * submitted. If You institute patent litigation against any entity
- * (including a cross-claim or counterclaim in a lawsuit) alleging that
- * the Work or a contribution incorporated within the Work constitutes
- * direct or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate as of
- * the date such litigation is filed.
- *
- * By using, modifying, or distributing the Work you indicate that you
- * have read and understood the terms and conditions of the
- * FreeType Project License as well as those provided in this section,
- * and you accept them fully.
- *
- */
-
-
-#ifndef PSFT_H_
-#define PSFT_H_
-
-
-#include <freetype/internal/compiler-macros.h>
-#include "pstypes.h"
-
- /* TODO: disable asserts for now */
-#define CF2_NDEBUG
-
-
-#include <freetype/ftsystem.h>
-
-#include "psglue.h"
-#include <freetype/internal/psaux.h> /* for PS_Decoder */
-
-
-FT_BEGIN_HEADER
-
-
- FT_LOCAL( FT_Error )
- cf2_decoder_parse_charstrings( PS_Decoder* decoder,
- FT_Byte* charstring_base,
- FT_ULong charstring_len );
-
- FT_LOCAL( CFF_SubFont )
- cf2_getSubfont( PS_Decoder* decoder );
-
- FT_LOCAL( CFF_VStore )
- cf2_getVStore( PS_Decoder* decoder );
-
- FT_LOCAL( FT_UInt )
- cf2_getMaxstack( PS_Decoder* decoder );
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- FT_LOCAL( FT_Error )
- cf2_getNormalizedVector( PS_Decoder* decoder,
- CF2_UInt *len,
- FT_Fixed* *vec );
-#endif
-
- FT_LOCAL( CF2_Fixed )
- cf2_getPpemY( PS_Decoder* decoder );
- FT_LOCAL( CF2_Fixed )
- cf2_getStdVW( PS_Decoder* decoder );
- FT_LOCAL( CF2_Fixed )
- cf2_getStdHW( PS_Decoder* decoder );
-
- FT_LOCAL( void )
- cf2_getBlueMetrics( PS_Decoder* decoder,
- CF2_Fixed* blueScale,
- CF2_Fixed* blueShift,
- CF2_Fixed* blueFuzz );
- FT_LOCAL( void )
- cf2_getBlueValues( PS_Decoder* decoder,
- size_t* count,
- FT_Fixed* *data );
- FT_LOCAL( void )
- cf2_getOtherBlues( PS_Decoder* decoder,
- size_t* count,
- FT_Fixed* *data );
- FT_LOCAL( void )
- cf2_getFamilyBlues( PS_Decoder* decoder,
- size_t* count,
- FT_Fixed* *data );
- FT_LOCAL( void )
- cf2_getFamilyOtherBlues( PS_Decoder* decoder,
- size_t* count,
- FT_Fixed* *data );
-
- FT_LOCAL( CF2_Int )
- cf2_getLanguageGroup( PS_Decoder* decoder );
-
- FT_LOCAL( CF2_Int )
- cf2_initGlobalRegionBuffer( PS_Decoder* decoder,
- CF2_Int subrNum,
- CF2_Buffer buf );
- FT_LOCAL( FT_Error )
- cf2_getSeacComponent( PS_Decoder* decoder,
- CF2_Int code,
- CF2_Buffer buf );
- FT_LOCAL( void )
- cf2_freeSeacComponent( PS_Decoder* decoder,
- CF2_Buffer buf );
- FT_LOCAL( CF2_Int )
- cf2_initLocalRegionBuffer( PS_Decoder* decoder,
- CF2_Int subrNum,
- CF2_Buffer buf );
-
- FT_LOCAL( CF2_Fixed )
- cf2_getDefaultWidthX( PS_Decoder* decoder );
- FT_LOCAL( CF2_Fixed )
- cf2_getNominalWidthX( PS_Decoder* decoder );
-
-
- FT_LOCAL( FT_Error )
- cf2_getT1SeacComponent( PS_Decoder* decoder,
- FT_UInt glyph_index,
- CF2_Buffer buf );
- FT_LOCAL( void )
- cf2_freeT1SeacComponent( PS_Decoder* decoder,
- CF2_Buffer buf );
-
- /*
- * FreeType client outline
- *
- * process output from the charstring interpreter
- */
- typedef struct CF2_OutlineRec_
- {
- CF2_OutlineCallbacksRec root; /* base class must be first */
- PS_Decoder* decoder;
-
- } CF2_OutlineRec, *CF2_Outline;
-
-
- FT_LOCAL( void )
- cf2_outline_reset( CF2_Outline outline );
- FT_LOCAL( void )
- cf2_outline_close( CF2_Outline outline );
-
-
-FT_END_HEADER
-
-
-#endif /* PSFT_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/psaux/psglue.h b/contrib/libs/freetype/src/psaux/psglue.h
deleted file mode 100644
index 63085d71cf..0000000000
--- a/contrib/libs/freetype/src/psaux/psglue.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/****************************************************************************
- *
- * psglue.h
- *
- * Adobe's code for shared stuff (specification only).
- *
- * Copyright 2007-2013 Adobe Systems Incorporated.
- *
- * This software, and all works of authorship, whether in source or
- * object code form as indicated by the copyright notice(s) included
- * herein (collectively, the "Work") is made available, and may only be
- * used, modified, and distributed under the FreeType Project License,
- * LICENSE.TXT. Additionally, subject to the terms and conditions of the
- * FreeType Project License, each contributor to the Work hereby grants
- * to any individual or legal entity exercising permissions granted by
- * the FreeType Project License and this section (hereafter, "You" or
- * "Your") a perpetual, worldwide, non-exclusive, no-charge,
- * royalty-free, irrevocable (except as stated in this section) patent
- * license to make, have made, use, offer to sell, sell, import, and
- * otherwise transfer the Work, where such license applies only to those
- * patent claims licensable by such contributor that are necessarily
- * infringed by their contribution(s) alone or by combination of their
- * contribution(s) with the Work to which such contribution(s) was
- * submitted. If You institute patent litigation against any entity
- * (including a cross-claim or counterclaim in a lawsuit) alleging that
- * the Work or a contribution incorporated within the Work constitutes
- * direct or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate as of
- * the date such litigation is filed.
- *
- * By using, modifying, or distributing the Work you indicate that you
- * have read and understood the terms and conditions of the
- * FreeType Project License as well as those provided in this section,
- * and you accept them fully.
- *
- */
-
-
-#ifndef PSGLUE_H_
-#define PSGLUE_H_
-
-
-/* common includes for other modules */
-#include "pserror.h"
-#include "psfixed.h"
-#include "psarrst.h"
-#include "psread.h"
-
-
-FT_BEGIN_HEADER
-
-
- /* rendering parameters */
-
- /* apply hints to rendered glyphs */
-#define CF2_FlagsHinted 1
- /* for testing */
-#define CF2_FlagsDarkened 2
-
- /* type for holding the flags */
- typedef CF2_Int CF2_RenderingFlags;
-
-
- /* elements of a glyph outline */
- typedef enum CF2_PathOp_
- {
- CF2_PathOpMoveTo = 1, /* change the current point */
- CF2_PathOpLineTo = 2, /* line */
- CF2_PathOpQuadTo = 3, /* quadratic curve */
- CF2_PathOpCubeTo = 4 /* cubic curve */
-
- } CF2_PathOp;
-
-
- /* a matrix of fixed-point values */
- typedef struct CF2_Matrix_
- {
- CF2_F16Dot16 a;
- CF2_F16Dot16 b;
- CF2_F16Dot16 c;
- CF2_F16Dot16 d;
- CF2_F16Dot16 tx;
- CF2_F16Dot16 ty;
-
- } CF2_Matrix;
-
-
- /* these typedefs are needed by more than one header file */
- /* and gcc compiler doesn't allow redefinition */
- typedef struct CF2_FontRec_ CF2_FontRec, *CF2_Font;
- typedef struct CF2_HintRec_ CF2_HintRec, *CF2_Hint;
-
-
- /* A common structure for all callback parameters. */
- /* */
- /* Some members may be unused. For example, `pt0' is not used for */
- /* `moveTo' and `pt3' is not used for `quadTo'. The initial point `pt0' */
- /* is included for each path element for generality; curve conversions */
- /* need it. The `op' parameter allows one function to handle multiple */
- /* element types. */
-
- typedef struct CF2_CallbackParamsRec_
- {
- FT_Vector pt0;
- FT_Vector pt1;
- FT_Vector pt2;
- FT_Vector pt3;
-
- CF2_Int op;
-
- } CF2_CallbackParamsRec, *CF2_CallbackParams;
-
-
- /* forward reference */
- typedef struct CF2_OutlineCallbacksRec_ CF2_OutlineCallbacksRec,
- *CF2_OutlineCallbacks;
-
- /* callback function pointers */
- typedef void
- (*CF2_Callback_Type)( CF2_OutlineCallbacks callbacks,
- const CF2_CallbackParams params );
-
-
- struct CF2_OutlineCallbacksRec_
- {
- CF2_Callback_Type moveTo;
- CF2_Callback_Type lineTo;
- CF2_Callback_Type quadTo;
- CF2_Callback_Type cubeTo;
-
- CF2_Int windingMomentum; /* for winding order detection */
-
- FT_Memory memory;
- FT_Error* error;
- };
-
-
-FT_END_HEADER
-
-
-#endif /* PSGLUE_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/psaux/pshints.c b/contrib/libs/freetype/src/psaux/pshints.c
deleted file mode 100644
index 7bd08a9c9b..0000000000
--- a/contrib/libs/freetype/src/psaux/pshints.c
+++ /dev/null
@@ -1,1952 +0,0 @@
-/****************************************************************************
- *
- * pshints.c
- *
- * Adobe's code for handling CFF hints (body).
- *
- * Copyright 2007-2014 Adobe Systems Incorporated.
- *
- * This software, and all works of authorship, whether in source or
- * object code form as indicated by the copyright notice(s) included
- * herein (collectively, the "Work") is made available, and may only be
- * used, modified, and distributed under the FreeType Project License,
- * LICENSE.TXT. Additionally, subject to the terms and conditions of the
- * FreeType Project License, each contributor to the Work hereby grants
- * to any individual or legal entity exercising permissions granted by
- * the FreeType Project License and this section (hereafter, "You" or
- * "Your") a perpetual, worldwide, non-exclusive, no-charge,
- * royalty-free, irrevocable (except as stated in this section) patent
- * license to make, have made, use, offer to sell, sell, import, and
- * otherwise transfer the Work, where such license applies only to those
- * patent claims licensable by such contributor that are necessarily
- * infringed by their contribution(s) alone or by combination of their
- * contribution(s) with the Work to which such contribution(s) was
- * submitted. If You institute patent litigation against any entity
- * (including a cross-claim or counterclaim in a lawsuit) alleging that
- * the Work or a contribution incorporated within the Work constitutes
- * direct or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate as of
- * the date such litigation is filed.
- *
- * By using, modifying, or distributing the Work you indicate that you
- * have read and understood the terms and conditions of the
- * FreeType Project License as well as those provided in this section,
- * and you accept them fully.
- *
- */
-
-
-#include "psft.h"
-#include <freetype/internal/ftdebug.h>
-
-#include "psglue.h"
-#include "psfont.h"
-#include "pshints.h"
-#include "psintrp.h"
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT cf2hints
-
-
- typedef struct CF2_HintMoveRec_
- {
- size_t j; /* index of upper hint map edge */
- CF2_Fixed moveUp; /* adjustment to optimum position */
-
- } CF2_HintMoveRec, *CF2_HintMove;
-
-
- /* Compute angular momentum for winding order detection. It is called */
- /* for all lines and curves, but not necessarily in element order. */
- static CF2_Int
- cf2_getWindingMomentum( CF2_Fixed x1,
- CF2_Fixed y1,
- CF2_Fixed x2,
- CF2_Fixed y2 )
- {
- /* cross product of pt1 position from origin with pt2 position from */
- /* pt1; we reduce the precision so that the result fits into 32 bits */
-
- return ( x1 >> 16 ) * ( SUB_INT32( y2, y1 ) >> 16 ) -
- ( y1 >> 16 ) * ( SUB_INT32( x2, x1 ) >> 16 );
- }
-
-
- /*
- * Construct from a StemHint; this is used as a parameter to
- * `cf2_blues_capture'.
- * `hintOrigin' is the character space displacement of a seac accent.
- * Adjust stem hint for darkening here.
- *
- */
- static void
- cf2_hint_init( CF2_Hint hint,
- const CF2_ArrStack stemHintArray,
- size_t indexStemHint,
- const CF2_Font font,
- CF2_Fixed hintOrigin,
- CF2_Fixed scale,
- FT_Bool bottom )
- {
- CF2_Fixed width;
- const CF2_StemHintRec* stemHint;
-
-
- FT_ZERO( hint );
-
- stemHint = (const CF2_StemHintRec*)cf2_arrstack_getPointer(
- stemHintArray,
- indexStemHint );
-
- width = SUB_INT32( stemHint->max, stemHint->min );
-
- if ( width == cf2_intToFixed( -21 ) )
- {
- /* ghost bottom */
-
- if ( bottom )
- {
- hint->csCoord = stemHint->max;
- hint->flags = CF2_GhostBottom;
- }
- else
- hint->flags = 0;
- }
-
- else if ( width == cf2_intToFixed( -20 ) )
- {
- /* ghost top */
-
- if ( bottom )
- hint->flags = 0;
- else
- {
- hint->csCoord = stemHint->min;
- hint->flags = CF2_GhostTop;
- }
- }
-
- else if ( width < 0 )
- {
- /* inverted pair */
-
- /*
- * Hints with negative widths were produced by an early version of a
- * non-Adobe font tool. The Type 2 spec allows edge (ghost) hints
- * with negative widths, but says
- *
- * All other negative widths have undefined meaning.
- *
- * CoolType has a silent workaround that negates the hint width; for
- * permissive mode, we do the same here.
- *
- * Note: Such fonts cannot use ghost hints, but should otherwise work.
- * Note: Some poor hints in our faux fonts can produce negative
- * widths at some blends. For example, see a light weight of
- * `u' in ASerifMM.
- *
- */
- if ( bottom )
- {
- hint->csCoord = stemHint->max;
- hint->flags = CF2_PairBottom;
- }
- else
- {
- hint->csCoord = stemHint->min;
- hint->flags = CF2_PairTop;
- }
- }
-
- else
- {
- /* normal pair */
-
- if ( bottom )
- {
- hint->csCoord = stemHint->min;
- hint->flags = CF2_PairBottom;
- }
- else
- {
- hint->csCoord = stemHint->max;
- hint->flags = CF2_PairTop;
- }
- }
-
- /* Now that ghost hints have been detected, adjust this edge for */
- /* darkening. Bottoms are not changed; tops are incremented by twice */
- /* `darkenY'. */
- if ( cf2_hint_isTop( hint ) )
- hint->csCoord = ADD_INT32( hint->csCoord, 2 * font->darkenY );
-
- hint->csCoord = ADD_INT32( hint->csCoord, hintOrigin );
- hint->scale = scale;
- hint->index = indexStemHint; /* index in original stem hint array */
-
- /* if original stem hint has been used, use the same position */
- if ( hint->flags != 0 && stemHint->used )
- {
- if ( cf2_hint_isTop( hint ) )
- hint->dsCoord = stemHint->maxDS;
- else
- hint->dsCoord = stemHint->minDS;
-
- cf2_hint_lock( hint );
- }
- else
- hint->dsCoord = FT_MulFix( hint->csCoord, scale );
- }
-
-
- /* initialize an invalid hint map element */
- static void
- cf2_hint_initZero( CF2_Hint hint )
- {
- FT_ZERO( hint );
- }
-
-
- FT_LOCAL_DEF( FT_Bool )
- cf2_hint_isValid( const CF2_Hint hint )
- {
- return FT_BOOL( hint->flags );
- }
-
-
- static FT_Bool
- cf2_hint_isPair( const CF2_Hint hint )
- {
- return FT_BOOL( hint->flags & ( CF2_PairBottom | CF2_PairTop ) );
- }
-
-
- static FT_Bool
- cf2_hint_isPairTop( const CF2_Hint hint )
- {
- return FT_BOOL( hint->flags & CF2_PairTop );
- }
-
-
- FT_LOCAL_DEF( FT_Bool )
- cf2_hint_isTop( const CF2_Hint hint )
- {
- return FT_BOOL( hint->flags & ( CF2_PairTop | CF2_GhostTop ) );
- }
-
-
- FT_LOCAL_DEF( FT_Bool )
- cf2_hint_isBottom( const CF2_Hint hint )
- {
- return FT_BOOL( hint->flags & ( CF2_PairBottom | CF2_GhostBottom ) );
- }
-
-
- static FT_Bool
- cf2_hint_isLocked( const CF2_Hint hint )
- {
- return FT_BOOL( hint->flags & CF2_Locked );
- }
-
-
- static FT_Bool
- cf2_hint_isSynthetic( const CF2_Hint hint )
- {
- return FT_BOOL( hint->flags & CF2_Synthetic );
- }
-
-
- FT_LOCAL_DEF( void )
- cf2_hint_lock( CF2_Hint hint )
- {
- hint->flags |= CF2_Locked;
- }
-
-
- FT_LOCAL_DEF( void )
- cf2_hintmap_init( CF2_HintMap hintmap,
- CF2_Font font,
- CF2_HintMap initialMap,
- CF2_ArrStack hintMoves,
- CF2_Fixed scale )
- {
- FT_ZERO( hintmap );
-
- /* copy parameters from font instance */
- hintmap->hinted = font->hinted;
- hintmap->scale = scale;
- hintmap->font = font;
- hintmap->initialHintMap = initialMap;
- /* will clear in `cf2_hintmap_adjustHints' */
- hintmap->hintMoves = hintMoves;
- }
-
-
- static FT_Bool
- cf2_hintmap_isValid( const CF2_HintMap hintmap )
- {
- return hintmap->isValid;
- }
-
-
- static void
- cf2_hintmap_dump( CF2_HintMap hintmap )
- {
-#ifdef FT_DEBUG_LEVEL_TRACE
- CF2_UInt i;
-
-
- FT_TRACE6(( " index csCoord dsCoord scale flags\n" ));
-
- for ( i = 0; i < hintmap->count; i++ )
- {
- CF2_Hint hint = &hintmap->edge[i];
-
-
- FT_TRACE6(( " %3zu %7.2f %7.2f %5d %s%s%s%s\n",
- hint->index,
- hint->csCoord / 65536.0,
- hint->dsCoord / ( hint->scale * 1.0 ),
- hint->scale,
- ( cf2_hint_isPair( hint ) ? "p" : "g" ),
- ( cf2_hint_isTop( hint ) ? "t" : "b" ),
- ( cf2_hint_isLocked( hint ) ? "L" : ""),
- ( cf2_hint_isSynthetic( hint ) ? "S" : "" ) ));
- }
-#else
- FT_UNUSED( hintmap );
-#endif
- }
-
-
- /* transform character space coordinate to device space using hint map */
- static CF2_Fixed
- cf2_hintmap_map( CF2_HintMap hintmap,
- CF2_Fixed csCoord )
- {
- if ( hintmap->count == 0 || !hintmap->hinted )
- {
- /* there are no hints; use uniform scale and zero offset */
- return FT_MulFix( csCoord, hintmap->scale );
- }
- else
- {
- /* start linear search from last hit */
- CF2_UInt i = hintmap->lastIndex;
-
-
- FT_ASSERT( hintmap->lastIndex < CF2_MAX_HINT_EDGES );
-
- /* search up */
- while ( i < hintmap->count - 1 &&
- csCoord >= hintmap->edge[i + 1].csCoord )
- i += 1;
-
- /* search down */
- while ( i > 0 && csCoord < hintmap->edge[i].csCoord )
- i -= 1;
-
- hintmap->lastIndex = i;
-
- if ( i == 0 && csCoord < hintmap->edge[0].csCoord )
- {
- /* special case for points below first edge: use uniform scale */
- return ADD_INT32( FT_MulFix( SUB_INT32( csCoord,
- hintmap->edge[0].csCoord ),
- hintmap->scale ),
- hintmap->edge[0].dsCoord );
- }
- else
- {
- /*
- * Note: entries with duplicate csCoord are allowed.
- * Use edge[i], the highest entry where csCoord >= entry[i].csCoord
- */
- return ADD_INT32( FT_MulFix( SUB_INT32( csCoord,
- hintmap->edge[i].csCoord ),
- hintmap->edge[i].scale ),
- hintmap->edge[i].dsCoord );
- }
- }
- }
-
-
- /*
- * This hinting policy moves a hint pair in device space so that one of
- * its two edges is on a device pixel boundary (its fractional part is
- * zero). `cf2_hintmap_insertHint' guarantees no overlap in CS
- * space. Ensure here that there is no overlap in DS.
- *
- * In the first pass, edges are adjusted relative to adjacent hints.
- * Those that are below have already been adjusted. Those that are
- * above have not yet been adjusted. If a hint above blocks an
- * adjustment to an optimal position, we will try again in a second
- * pass. The second pass is top-down.
- *
- */
-
- static void
- cf2_hintmap_adjustHints( CF2_HintMap hintmap )
- {
- size_t i, j;
-
-
- cf2_arrstack_clear( hintmap->hintMoves ); /* working storage */
-
- /*
- * First pass is bottom-up (font hint order) without look-ahead.
- * Locked edges are already adjusted.
- * Unlocked edges begin with dsCoord from `initialHintMap'.
- * Save edges that are not optimally adjusted in `hintMoves' array,
- * and process them in second pass.
- */
-
- for ( i = 0; i < hintmap->count; i++ )
- {
- FT_Bool isPair = cf2_hint_isPair( &hintmap->edge[i] );
-
- /* final amount to move edge or edge pair */
- CF2_Fixed move = 0;
-
- CF2_Fixed dsCoord_i;
- CF2_Fixed dsCoord_j;
-
-
- /* index of upper edge (same value for ghost hint) */
- j = isPair ? i + 1 : i;
-
- FT_ASSERT( j < hintmap->count );
- FT_ASSERT( cf2_hint_isValid( &hintmap->edge[i] ) );
- FT_ASSERT( cf2_hint_isValid( &hintmap->edge[j] ) );
- FT_ASSERT( cf2_hint_isLocked( &hintmap->edge[i] ) ==
- cf2_hint_isLocked( &hintmap->edge[j] ) );
-
- dsCoord_i = hintmap->edge[i].dsCoord;
- dsCoord_j = hintmap->edge[j].dsCoord;
-
- if ( !cf2_hint_isLocked( &hintmap->edge[i] ) )
- {
- /* hint edge is not locked, we can adjust it */
- CF2_Fixed fracDown = cf2_fixedFraction( dsCoord_i );
- CF2_Fixed fracUp = cf2_fixedFraction( dsCoord_j );
-
- /* calculate all four possibilities; moves down are negative */
- CF2_Fixed downMoveDown = 0 - fracDown;
- CF2_Fixed upMoveDown = 0 - fracUp;
- CF2_Fixed downMoveUp = ( fracDown == 0 )
- ? 0
- : cf2_intToFixed( 1 ) - fracDown;
- CF2_Fixed upMoveUp = ( fracUp == 0 )
- ? 0
- : cf2_intToFixed( 1 ) - fracUp;
-
- /* smallest move up */
- CF2_Fixed moveUp = FT_MIN( downMoveUp, upMoveUp );
- /* smallest move down */
- CF2_Fixed moveDown = FT_MAX( downMoveDown, upMoveDown );
-
- CF2_Fixed downMinCounter = CF2_MIN_COUNTER;
- CF2_Fixed upMinCounter = CF2_MIN_COUNTER;
- FT_Bool saveEdge = FALSE;
-
-
- /* minimum counter constraint doesn't apply when adjacent edges */
- /* are synthetic */
- /* TODO: doesn't seem a big effect; for now, reduce the code */
-#if 0
- if ( i == 0 ||
- cf2_hint_isSynthetic( &hintmap->edge[i - 1] ) )
- downMinCounter = 0;
-
- if ( j >= hintmap->count - 1 ||
- cf2_hint_isSynthetic( &hintmap->edge[j + 1] ) )
- upMinCounter = 0;
-#endif
-
- /* is there room to move up? */
- /* there is if we are at top of array or the next edge is at or */
- /* beyond proposed move up? */
- if ( j >= hintmap->count - 1 ||
- hintmap->edge[j + 1].dsCoord >=
- ADD_INT32( dsCoord_j, moveUp + upMinCounter ) )
- {
- /* there is room to move up; is there also room to move down? */
- if ( i == 0 ||
- hintmap->edge[i - 1].dsCoord <=
- ADD_INT32( dsCoord_i, moveDown - downMinCounter ) )
- {
- /* move smaller absolute amount */
- move = ( -moveDown < moveUp ) ? moveDown : moveUp; /* optimum */
- }
- else
- move = moveUp;
- }
- else
- {
- /* is there room to move down? */
- if ( i == 0 ||
- hintmap->edge[i - 1].dsCoord <=
- ADD_INT32( dsCoord_i, moveDown - downMinCounter ) )
- {
- move = moveDown;
- /* true if non-optimum move */
- saveEdge = FT_BOOL( moveUp < -moveDown );
- }
- else
- {
- /* no room to move either way without overlapping or reducing */
- /* the counter too much */
- move = 0;
- saveEdge = TRUE;
- }
- }
-
- /* Identify non-moves and moves down that aren't optimal, and save */
- /* them for second pass. */
- /* Do this only if there is an unlocked edge above (which could */
- /* possibly move). */
- if ( saveEdge &&
- j < hintmap->count - 1 &&
- !cf2_hint_isLocked( &hintmap->edge[j + 1] ) )
- {
- CF2_HintMoveRec savedMove;
-
-
- savedMove.j = j;
- /* desired adjustment in second pass */
- savedMove.moveUp = moveUp - move;
-
- cf2_arrstack_push( hintmap->hintMoves, &savedMove );
- }
-
- /* move the edge(s) */
- hintmap->edge[i].dsCoord = ADD_INT32( dsCoord_i, move );
- if ( isPair )
- hintmap->edge[j].dsCoord = ADD_INT32( dsCoord_j, move );
- }
-
- /* assert there are no overlaps in device space; */
- /* ignore tests if there was overflow (that is, if */
- /* operands have the same sign but the sum does not) */
- FT_ASSERT( i == 0 ||
- ( ( dsCoord_i ^ move ) >= 0 &&
- ( dsCoord_i ^ hintmap->edge[i].dsCoord ) < 0 ) ||
- hintmap->edge[i - 1].dsCoord <= hintmap->edge[i].dsCoord );
- FT_ASSERT( i < j ||
- ( ( dsCoord_j ^ move ) >= 0 &&
- ( dsCoord_j ^ hintmap->edge[j].dsCoord ) < 0 ) ||
- hintmap->edge[i].dsCoord <= hintmap->edge[j].dsCoord );
-
- /* adjust the scales, avoiding divide by zero */
- if ( i > 0 )
- {
- if ( hintmap->edge[i].csCoord != hintmap->edge[i - 1].csCoord )
- hintmap->edge[i - 1].scale =
- FT_DivFix( SUB_INT32( hintmap->edge[i].dsCoord,
- hintmap->edge[i - 1].dsCoord ),
- SUB_INT32( hintmap->edge[i].csCoord,
- hintmap->edge[i - 1].csCoord ) );
- }
-
- if ( isPair )
- {
- if ( hintmap->edge[j].csCoord != hintmap->edge[j - 1].csCoord )
- hintmap->edge[j - 1].scale =
- FT_DivFix( SUB_INT32( hintmap->edge[j].dsCoord,
- hintmap->edge[j - 1].dsCoord ),
- SUB_INT32( hintmap->edge[j].csCoord,
- hintmap->edge[j - 1].csCoord ) );
-
- i += 1; /* skip upper edge on next loop */
- }
- }
-
- /* second pass tries to move non-optimal hints up, in case there is */
- /* room now */
- for ( i = cf2_arrstack_size( hintmap->hintMoves ); i > 0; i-- )
- {
- CF2_HintMove hintMove = (CF2_HintMove)
- cf2_arrstack_getPointer( hintmap->hintMoves, i - 1 );
-
-
- j = hintMove->j;
-
- /* this was tested before the push, above */
- FT_ASSERT( j < hintmap->count - 1 );
-
- /* is there room to move up? */
- if ( hintmap->edge[j + 1].dsCoord >=
- ADD_INT32( hintmap->edge[j].dsCoord,
- hintMove->moveUp + CF2_MIN_COUNTER ) )
- {
- /* there is more room now, move edge up */
- hintmap->edge[j].dsCoord = ADD_INT32( hintmap->edge[j].dsCoord,
- hintMove->moveUp );
-
- if ( cf2_hint_isPair( &hintmap->edge[j] ) )
- {
- FT_ASSERT( j > 0 );
- hintmap->edge[j - 1].dsCoord =
- ADD_INT32( hintmap->edge[j - 1].dsCoord, hintMove->moveUp );
- }
- }
- }
- }
-
-
- /* insert hint edges into map, sorted by csCoord */
- static void
- cf2_hintmap_insertHint( CF2_HintMap hintmap,
- CF2_Hint bottomHintEdge,
- CF2_Hint topHintEdge )
- {
- CF2_UInt indexInsert;
-
- /* set default values, then check for edge hints */
- FT_Bool isPair = TRUE;
- CF2_Hint firstHintEdge = bottomHintEdge;
- CF2_Hint secondHintEdge = topHintEdge;
-
-
- /* one or none of the input params may be invalid when dealing with */
- /* edge hints; at least one edge must be valid */
- FT_ASSERT( cf2_hint_isValid( bottomHintEdge ) ||
- cf2_hint_isValid( topHintEdge ) );
-
- /* determine how many and which edges to insert */
- if ( !cf2_hint_isValid( bottomHintEdge ) )
- {
- /* insert only the top edge */
- firstHintEdge = topHintEdge;
- isPair = FALSE;
- }
- else if ( !cf2_hint_isValid( topHintEdge ) )
- {
- /* insert only the bottom edge */
- isPair = FALSE;
- }
-
- /* paired edges must be in proper order */
- if ( isPair &&
- topHintEdge->csCoord < bottomHintEdge->csCoord )
- return;
-
- /* linear search to find index value of insertion point */
- indexInsert = 0;
- for ( ; indexInsert < hintmap->count; indexInsert++ )
- {
- if ( hintmap->edge[indexInsert].csCoord >= firstHintEdge->csCoord )
- break;
- }
-
- FT_TRACE7(( " Got hint at %.2f (%.2f)\n",
- firstHintEdge->csCoord / 65536.0,
- firstHintEdge->dsCoord / 65536.0 ));
- if ( isPair )
- FT_TRACE7(( " Got hint at %.2f (%.2f)\n",
- secondHintEdge->csCoord / 65536.0,
- secondHintEdge->dsCoord / 65536.0 ));
-
- /*
- * Discard any hints that overlap in character space. Most often, this
- * is while building the initial map, where captured hints from all
- * zones are combined. Define overlap to include hints that `touch'
- * (overlap zero). Hiragino Sans/Gothic fonts have numerous hints that
- * touch. Some fonts have non-ideographic glyphs that overlap our
- * synthetic hints.
- *
- * Overlap also occurs when darkening stem hints that are close.
- *
- */
- if ( indexInsert < hintmap->count )
- {
- /* we are inserting before an existing edge: */
- /* verify that an existing edge is not the same */
- if ( hintmap->edge[indexInsert].csCoord == firstHintEdge->csCoord )
- return; /* ignore overlapping stem hint */
-
- /* verify that a new pair does not straddle the next edge */
- if ( isPair &&
- hintmap->edge[indexInsert].csCoord <= secondHintEdge->csCoord )
- return; /* ignore overlapping stem hint */
-
- /* verify that we are not inserting between paired edges */
- if ( cf2_hint_isPairTop( &hintmap->edge[indexInsert] ) )
- return; /* ignore overlapping stem hint */
- }
-
- /* recompute device space locations using initial hint map */
- if ( cf2_hintmap_isValid( hintmap->initialHintMap ) &&
- !cf2_hint_isLocked( firstHintEdge ) )
- {
- if ( isPair )
- {
- /* Use hint map to position the center of stem, and nominal scale */
- /* to position the two edges. This preserves the stem width. */
- CF2_Fixed midpoint =
- cf2_hintmap_map(
- hintmap->initialHintMap,
- ADD_INT32(
- firstHintEdge->csCoord,
- SUB_INT32 ( secondHintEdge->csCoord,
- firstHintEdge->csCoord ) / 2 ) );
- CF2_Fixed halfWidth =
- FT_MulFix( SUB_INT32( secondHintEdge->csCoord,
- firstHintEdge->csCoord ) / 2,
- hintmap->scale );
-
-
- firstHintEdge->dsCoord = SUB_INT32( midpoint, halfWidth );
- secondHintEdge->dsCoord = ADD_INT32( midpoint, halfWidth );
- }
- else
- firstHintEdge->dsCoord = cf2_hintmap_map( hintmap->initialHintMap,
- firstHintEdge->csCoord );
- }
-
- /*
- * Discard any hints that overlap in device space; this can occur
- * because locked hints have been moved to align with blue zones.
- *
- * TODO: Although we might correct this later during adjustment, we
- * don't currently have a way to delete a conflicting hint once it has
- * been inserted. See v2.030 MinionPro-Regular, 12 ppem darkened,
- * initial hint map for second path, glyph 945 (the perispomeni (tilde)
- * in U+1F6E, Greek omega with psili and perispomeni). Darkening is
- * 25. Pair 667,747 initially conflicts in design space with top edge
- * 660. This is because 667 maps to 7.87, and the top edge was
- * captured by a zone at 8.0. The pair is later successfully inserted
- * in a zone without the top edge. In this zone it is adjusted to 8.0,
- * and no longer conflicts with the top edge in design space. This
- * means it can be included in yet a later zone which does have the top
- * edge hint. This produces a small mismatch between the first and
- * last points of this path, even though the hint masks are the same.
- * The density map difference is tiny (1/256).
- *
- */
-
- if ( indexInsert > 0 )
- {
- /* we are inserting after an existing edge */
- if ( firstHintEdge->dsCoord < hintmap->edge[indexInsert - 1].dsCoord )
- return;
- }
-
- if ( indexInsert < hintmap->count )
- {
- /* we are inserting before an existing edge */
- if ( isPair )
- {
- if ( secondHintEdge->dsCoord > hintmap->edge[indexInsert].dsCoord )
- return;
- }
- else
- {
- if ( firstHintEdge->dsCoord > hintmap->edge[indexInsert].dsCoord )
- return;
- }
- }
-
- /* make room to insert */
- {
- CF2_UInt iSrc = hintmap->count - 1;
- CF2_UInt iDst = isPair ? hintmap->count + 1 : hintmap->count;
-
- CF2_UInt count = hintmap->count - indexInsert;
-
-
- if ( iDst >= CF2_MAX_HINT_EDGES )
- {
- FT_TRACE4(( "cf2_hintmap_insertHint: too many hintmaps\n" ));
- return;
- }
-
- while ( count-- )
- hintmap->edge[iDst--] = hintmap->edge[iSrc--];
-
- /* insert first edge */
- hintmap->edge[indexInsert] = *firstHintEdge; /* copy struct */
- hintmap->count += 1;
-
- FT_TRACE7(( " Inserting hint %.2f (%.2f)\n",
- firstHintEdge->csCoord / 65536.0,
- firstHintEdge->dsCoord / 65536.0 ));
-
- if ( isPair )
- {
- /* insert second edge */
- hintmap->edge[indexInsert + 1] = *secondHintEdge; /* copy struct */
- hintmap->count += 1;
-
- FT_TRACE7(( " Inserting hint %.2f (%.2f)\n",
- secondHintEdge->csCoord / 65536.0,
- secondHintEdge->dsCoord / 65536.0 ));
-
- }
- }
-
- return;
- }
-
-
- /*
- * Build a map from hints and mask.
- *
- * This function may recur one level if `hintmap->initialHintMap' is not yet
- * valid.
- * If `initialMap' is true, simply build initial map.
- *
- * Synthetic hints are used in two ways. A hint at zero is inserted, if
- * needed, in the initial hint map, to prevent translations from
- * propagating across the origin. If synthetic em box hints are enabled
- * for ideographic dictionaries, then they are inserted in all hint
- * maps, including the initial one.
- *
- */
- FT_LOCAL_DEF( void )
- cf2_hintmap_build( CF2_HintMap hintmap,
- CF2_ArrStack hStemHintArray,
- CF2_ArrStack vStemHintArray,
- CF2_HintMask hintMask,
- CF2_Fixed hintOrigin,
- FT_Bool initialMap )
- {
- FT_Byte* maskPtr;
-
- CF2_Font font = hintmap->font;
- CF2_HintMaskRec tempHintMask;
-
- size_t bitCount, i;
- FT_Byte maskByte;
-
-
- /* check whether initial map is constructed */
- if ( !initialMap && !cf2_hintmap_isValid( hintmap->initialHintMap ) )
- {
- /* make recursive call with initialHintMap and temporary mask; */
- /* temporary mask will get all bits set, below */
- cf2_hintmask_init( &tempHintMask, hintMask->error );
- cf2_hintmap_build( hintmap->initialHintMap,
- hStemHintArray,
- vStemHintArray,
- &tempHintMask,
- hintOrigin,
- TRUE );
- }
-
- if ( !cf2_hintmask_isValid( hintMask ) )
- {
- /* without a hint mask, assume all hints are active */
- cf2_hintmask_setAll( hintMask,
- cf2_arrstack_size( hStemHintArray ) +
- cf2_arrstack_size( vStemHintArray ) );
- if ( !cf2_hintmask_isValid( hintMask ) )
- {
- if ( font->isT1 )
- {
- /* no error, just continue unhinted */
- *hintMask->error = FT_Err_Ok;
- hintmap->hinted = FALSE;
- }
- return; /* too many stem hints */
- }
- }
-
- /* begin by clearing the map */
- hintmap->count = 0;
- hintmap->lastIndex = 0;
-
- /* make a copy of the hint mask so we can modify it */
- tempHintMask = *hintMask;
- maskPtr = cf2_hintmask_getMaskPtr( &tempHintMask );
-
- /* use the hStem hints only, which are first in the mask */
- bitCount = cf2_arrstack_size( hStemHintArray );
-
- /* Defense-in-depth. Should never return here. */
- if ( bitCount > hintMask->bitCount )
- return;
-
- /* synthetic embox hints get highest priority */
- if ( font->blues.doEmBoxHints )
- {
- CF2_HintRec dummy;
-
-
- cf2_hint_initZero( &dummy ); /* invalid hint map element */
-
- /* ghost bottom */
- cf2_hintmap_insertHint( hintmap,
- &font->blues.emBoxBottomEdge,
- &dummy );
- /* ghost top */
- cf2_hintmap_insertHint( hintmap,
- &dummy,
- &font->blues.emBoxTopEdge );
- }
-
- /* insert hints captured by a blue zone or already locked (higher */
- /* priority) */
- for ( i = 0, maskByte = 0x80; i < bitCount; i++ )
- {
- if ( maskByte & *maskPtr )
- {
- /* expand StemHint into two `CF2_Hint' elements */
- CF2_HintRec bottomHintEdge, topHintEdge;
-
-
- cf2_hint_init( &bottomHintEdge,
- hStemHintArray,
- i,
- font,
- hintOrigin,
- hintmap->scale,
- TRUE /* bottom */ );
- cf2_hint_init( &topHintEdge,
- hStemHintArray,
- i,
- font,
- hintOrigin,
- hintmap->scale,
- FALSE /* top */ );
-
- if ( cf2_hint_isLocked( &bottomHintEdge ) ||
- cf2_hint_isLocked( &topHintEdge ) ||
- cf2_blues_capture( &font->blues,
- &bottomHintEdge,
- &topHintEdge ) )
- {
- /* insert captured hint into map */
- cf2_hintmap_insertHint( hintmap, &bottomHintEdge, &topHintEdge );
-
- *maskPtr &= ~maskByte; /* turn off the bit for this hint */
- }
- }
-
- if ( ( i & 7 ) == 7 )
- {
- /* move to next mask byte */
- maskPtr++;
- maskByte = 0x80;
- }
- else
- maskByte >>= 1;
- }
-
- /* initial hint map includes only captured hints plus maybe one at 0 */
-
- /*
- * TODO: There is a problem here because we are trying to build a
- * single hint map containing all captured hints. It is
- * possible for there to be conflicts between captured hints,
- * either because of darkening or because the hints are in
- * separate hint zones (we are ignoring hint zones for the
- * initial map). An example of the latter is MinionPro-Regular
- * v2.030 glyph 883 (Greek Capital Alpha with Psili) at 15ppem.
- * A stem hint for the psili conflicts with the top edge hint
- * for the base character. The stem hint gets priority because
- * of its sort order. In glyph 884 (Greek Capital Alpha with
- * Psili and Oxia), the top of the base character gets a stem
- * hint, and the psili does not. This creates different initial
- * maps for the two glyphs resulting in different renderings of
- * the base character. Will probably defer this either as not
- * worth the cost or as a font bug. I don't think there is any
- * good reason for an accent to be captured by an alignment
- * zone. -darnold 2/12/10
- */
-
- if ( initialMap )
- {
- /* Apply a heuristic that inserts a point for (0,0), unless it's */
- /* already covered by a mapping. This locks the baseline for glyphs */
- /* that have no baseline hints. */
-
- if ( hintmap->count == 0 ||
- hintmap->edge[0].csCoord > 0 ||
- hintmap->edge[hintmap->count - 1].csCoord < 0 )
- {
- /* all edges are above 0 or all edges are below 0; */
- /* construct a locked edge hint at 0 */
-
- CF2_HintRec edge, invalid;
-
-
- cf2_hint_initZero( &edge );
-
- edge.flags = CF2_GhostBottom |
- CF2_Locked |
- CF2_Synthetic;
- edge.scale = hintmap->scale;
-
- cf2_hint_initZero( &invalid );
- cf2_hintmap_insertHint( hintmap, &edge, &invalid );
- }
- }
- else
- {
- /* insert remaining hints */
-
- maskPtr = cf2_hintmask_getMaskPtr( &tempHintMask );
-
- for ( i = 0, maskByte = 0x80; i < bitCount; i++ )
- {
- if ( maskByte & *maskPtr )
- {
- CF2_HintRec bottomHintEdge, topHintEdge;
-
-
- cf2_hint_init( &bottomHintEdge,
- hStemHintArray,
- i,
- font,
- hintOrigin,
- hintmap->scale,
- TRUE /* bottom */ );
- cf2_hint_init( &topHintEdge,
- hStemHintArray,
- i,
- font,
- hintOrigin,
- hintmap->scale,
- FALSE /* top */ );
-
- cf2_hintmap_insertHint( hintmap, &bottomHintEdge, &topHintEdge );
- }
-
- if ( ( i & 7 ) == 7 )
- {
- /* move to next mask byte */
- maskPtr++;
- maskByte = 0x80;
- }
- else
- maskByte >>= 1;
- }
- }
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( initialMap )
- {
- FT_TRACE6(( "flags: [p]air [g]host [t]op"
- " [b]ottom [L]ocked [S]ynthetic\n" ));
- FT_TRACE6(( "Initial hintmap:\n" ));
- }
- else
- FT_TRACE6(( "Hints:\n" ));
-#endif
-
- cf2_hintmap_dump( hintmap );
-
- /*
- * Note: The following line is a convenient place to break when
- * debugging hinting. Examine `hintmap->edge' for the list of
- * enabled hints, then step over the call to see the effect of
- * adjustment. We stop here first on the recursive call that
- * creates the initial map, and then on each counter group and
- * hint zone.
- */
-
- /* adjust positions of hint edges that are not locked to blue zones */
- cf2_hintmap_adjustHints( hintmap );
-
- FT_TRACE6(( "Hints adjusted:\n" ));
- cf2_hintmap_dump( hintmap );
-
- /* save the position of all hints that were used in this hint map; */
- /* if we use them again, we'll locate them in the same position */
- if ( !initialMap )
- {
- for ( i = 0; i < hintmap->count; i++ )
- {
- if ( !cf2_hint_isSynthetic( &hintmap->edge[i] ) )
- {
- /* Note: include both valid and invalid edges */
- /* Note: top and bottom edges are copied back separately */
- CF2_StemHint stemhint = (CF2_StemHint)
- cf2_arrstack_getPointer( hStemHintArray,
- hintmap->edge[i].index );
-
-
- if ( cf2_hint_isTop( &hintmap->edge[i] ) )
- stemhint->maxDS = hintmap->edge[i].dsCoord;
- else
- stemhint->minDS = hintmap->edge[i].dsCoord;
-
- stemhint->used = TRUE;
- }
- }
- }
-
- /* hint map is ready to use */
- hintmap->isValid = TRUE;
-
- /* remember this mask has been used */
- cf2_hintmask_setNew( hintMask, FALSE );
- }
-
-
- FT_LOCAL_DEF( void )
- cf2_glyphpath_init( CF2_GlyphPath glyphpath,
- CF2_Font font,
- CF2_OutlineCallbacks callbacks,
- CF2_Fixed scaleY,
- /* CF2_Fixed hShift, */
- CF2_ArrStack hStemHintArray,
- CF2_ArrStack vStemHintArray,
- CF2_HintMask hintMask,
- CF2_Fixed hintOriginY,
- const CF2_Blues blues,
- const FT_Vector* fractionalTranslation )
- {
- FT_ZERO( glyphpath );
-
- glyphpath->font = font;
- glyphpath->callbacks = callbacks;
-
- cf2_arrstack_init( &glyphpath->hintMoves,
- font->memory,
- &font->error,
- sizeof ( CF2_HintMoveRec ) );
-
- cf2_hintmap_init( &glyphpath->initialHintMap,
- font,
- &glyphpath->initialHintMap,
- &glyphpath->hintMoves,
- scaleY );
- cf2_hintmap_init( &glyphpath->firstHintMap,
- font,
- &glyphpath->initialHintMap,
- &glyphpath->hintMoves,
- scaleY );
- cf2_hintmap_init( &glyphpath->hintMap,
- font,
- &glyphpath->initialHintMap,
- &glyphpath->hintMoves,
- scaleY );
-
- glyphpath->scaleX = font->innerTransform.a;
- glyphpath->scaleC = font->innerTransform.c;
- glyphpath->scaleY = font->innerTransform.d;
-
- glyphpath->fractionalTranslation = *fractionalTranslation;
-
-#if 0
- glyphpath->hShift = hShift; /* for fauxing */
-#endif
-
- glyphpath->hStemHintArray = hStemHintArray;
- glyphpath->vStemHintArray = vStemHintArray;
- glyphpath->hintMask = hintMask; /* ptr to current mask */
- glyphpath->hintOriginY = hintOriginY;
- glyphpath->blues = blues;
- glyphpath->darken = font->darkened; /* TODO: should we make copies? */
- glyphpath->xOffset = font->darkenX;
- glyphpath->yOffset = font->darkenY;
- glyphpath->miterLimit = 2 * FT_MAX(
- cf2_fixedAbs( glyphpath->xOffset ),
- cf2_fixedAbs( glyphpath->yOffset ) );
-
- /* .1 character space unit */
- glyphpath->snapThreshold = cf2_doubleToFixed( 0.1 );
-
- glyphpath->moveIsPending = TRUE;
- glyphpath->pathIsOpen = FALSE;
- glyphpath->pathIsClosing = FALSE;
- glyphpath->elemIsQueued = FALSE;
- }
-
-
- FT_LOCAL_DEF( void )
- cf2_glyphpath_finalize( CF2_GlyphPath glyphpath )
- {
- cf2_arrstack_finalize( &glyphpath->hintMoves );
- }
-
-
- /*
- * Hint point in y-direction and apply outerTransform.
- * Input `current' hint map (which is actually delayed by one element).
- * Input x,y point in Character Space.
- * Output x,y point in Device Space, including translation.
- */
- static void
- cf2_glyphpath_hintPoint( CF2_GlyphPath glyphpath,
- CF2_HintMap hintmap,
- FT_Vector* ppt,
- CF2_Fixed x,
- CF2_Fixed y )
- {
- FT_Vector pt; /* hinted point in upright DS */
-
-
- pt.x = ADD_INT32( FT_MulFix( glyphpath->scaleX, x ),
- FT_MulFix( glyphpath->scaleC, y ) );
- pt.y = cf2_hintmap_map( hintmap, y );
-
- ppt->x = ADD_INT32(
- FT_MulFix( glyphpath->font->outerTransform.a, pt.x ),
- ADD_INT32(
- FT_MulFix( glyphpath->font->outerTransform.c, pt.y ),
- glyphpath->fractionalTranslation.x ) );
- ppt->y = ADD_INT32(
- FT_MulFix( glyphpath->font->outerTransform.b, pt.x ),
- ADD_INT32(
- FT_MulFix( glyphpath->font->outerTransform.d, pt.y ),
- glyphpath->fractionalTranslation.y ) );
- }
-
-
- /*
- * From two line segments, (u1,u2) and (v1,v2), compute a point of
- * intersection on the corresponding lines.
- * Return false if no intersection is found, or if the intersection is
- * too far away from the ends of the line segments, u2 and v1.
- *
- */
- static FT_Bool
- cf2_glyphpath_computeIntersection( CF2_GlyphPath glyphpath,
- const FT_Vector* u1,
- const FT_Vector* u2,
- const FT_Vector* v1,
- const FT_Vector* v2,
- FT_Vector* intersection )
- {
- /*
- * Let `u' be a zero-based vector from the first segment, `v' from the
- * second segment.
- * Let `w 'be the zero-based vector from `u1' to `v1'.
- * `perp' is the `perpendicular dot product'; see
- * https://mathworld.wolfram.com/PerpDotProduct.html.
- * `s' is the parameter for the parametric line for the first segment
- * (`u').
- *
- * See notation in
- * http://geomalgorithms.com/a05-_intersect-1.html.
- * Calculations are done in 16.16, but must handle the squaring of
- * line lengths in character space. We scale all vectors by 1/32 to
- * avoid overflow. This allows values up to 4095 to be squared. The
- * scale factor cancels in the divide.
- *
- * TODO: the scale factor could be computed from UnitsPerEm.
- *
- */
-
-#define cf2_perp( a, b ) \
- ( FT_MulFix( a.x, b.y ) - FT_MulFix( a.y, b.x ) )
-
- /* round and divide by 32 */
-#define CF2_CS_SCALE( x ) \
- ( ( (x) + 0x10 ) >> 5 )
-
- FT_Vector u, v, w; /* scaled vectors */
- CF2_Fixed denominator, s;
-
-
- u.x = CF2_CS_SCALE( SUB_INT32( u2->x, u1->x ) );
- u.y = CF2_CS_SCALE( SUB_INT32( u2->y, u1->y ) );
- v.x = CF2_CS_SCALE( SUB_INT32( v2->x, v1->x ) );
- v.y = CF2_CS_SCALE( SUB_INT32( v2->y, v1->y ) );
- w.x = CF2_CS_SCALE( SUB_INT32( v1->x, u1->x ) );
- w.y = CF2_CS_SCALE( SUB_INT32( v1->y, u1->y ) );
-
- denominator = cf2_perp( u, v );
-
- if ( denominator == 0 )
- return FALSE; /* parallel or coincident lines */
-
- s = FT_DivFix( cf2_perp( w, v ), denominator );
-
- intersection->x = ADD_INT32( u1->x,
- FT_MulFix( s, SUB_INT32( u2->x, u1->x ) ) );
- intersection->y = ADD_INT32( u1->y,
- FT_MulFix( s, SUB_INT32( u2->y, u1->y ) ) );
-
-
- /*
- * Special case snapping for horizontal and vertical lines.
- * This cleans up intersections and reduces problems with winding
- * order detection.
- * Sample case is sbc cd KozGoPr6N-Medium.otf 20 16685.
- * Note: these calculations are in character space.
- *
- */
-
- if ( u1->x == u2->x &&
- cf2_fixedAbs( SUB_INT32( intersection->x,
- u1->x ) ) < glyphpath->snapThreshold )
- intersection->x = u1->x;
- if ( u1->y == u2->y &&
- cf2_fixedAbs( SUB_INT32( intersection->y,
- u1->y ) ) < glyphpath->snapThreshold )
- intersection->y = u1->y;
-
- if ( v1->x == v2->x &&
- cf2_fixedAbs( SUB_INT32( intersection->x,
- v1->x ) ) < glyphpath->snapThreshold )
- intersection->x = v1->x;
- if ( v1->y == v2->y &&
- cf2_fixedAbs( SUB_INT32( intersection->y,
- v1->y ) ) < glyphpath->snapThreshold )
- intersection->y = v1->y;
-
- /* limit the intersection distance from midpoint of u2 and v1 */
- if ( cf2_fixedAbs( intersection->x - ADD_INT32( u2->x, v1->x ) / 2 ) >
- glyphpath->miterLimit ||
- cf2_fixedAbs( intersection->y - ADD_INT32( u2->y, v1->y ) / 2 ) >
- glyphpath->miterLimit )
- return FALSE;
-
- return TRUE;
- }
-
-
- /*
- * Push the cached element (glyphpath->prevElem*) to the outline
- * consumer. When a darkening offset is used, the end point of the
- * cached element may be adjusted to an intersection point or we may
- * synthesize a connecting line to the current element. If we are
- * closing a subpath, we may also generate a connecting line to the start
- * point.
- *
- * This is where Character Space (CS) is converted to Device Space (DS)
- * using a hint map. This calculation must use a HintMap that was valid
- * at the time the element was saved. For the first point in a subpath,
- * that is a saved HintMap. For most elements, it just means the caller
- * has delayed building a HintMap from the current HintMask.
- *
- * Transform each point with outerTransform and call the outline
- * callbacks. This is a general 3x3 transform:
- *
- * x' = a*x + c*y + tx, y' = b*x + d*y + ty
- *
- * but it uses 4 elements from CF2_Font and the translation part
- * from CF2_GlyphPath.
- *
- */
- static void
- cf2_glyphpath_pushPrevElem( CF2_GlyphPath glyphpath,
- CF2_HintMap hintmap,
- FT_Vector* nextP0,
- FT_Vector nextP1,
- FT_Bool close )
- {
- CF2_CallbackParamsRec params;
-
- FT_Vector* prevP0;
- FT_Vector* prevP1;
-
- FT_Vector intersection = { 0, 0 };
- FT_Bool useIntersection = FALSE;
-
-
- FT_ASSERT( glyphpath->prevElemOp == CF2_PathOpLineTo ||
- glyphpath->prevElemOp == CF2_PathOpCubeTo );
-
- if ( glyphpath->prevElemOp == CF2_PathOpLineTo )
- {
- prevP0 = &glyphpath->prevElemP0;
- prevP1 = &glyphpath->prevElemP1;
- }
- else
- {
- prevP0 = &glyphpath->prevElemP2;
- prevP1 = &glyphpath->prevElemP3;
- }
-
- /* optimization: if previous and next elements are offset by the same */
- /* amount, then there will be no gap, and no need to compute an */
- /* intersection. */
- if ( prevP1->x != nextP0->x || prevP1->y != nextP0->y )
- {
- /* previous element does not join next element: */
- /* adjust end point of previous element to the intersection */
- useIntersection = cf2_glyphpath_computeIntersection( glyphpath,
- prevP0,
- prevP1,
- nextP0,
- &nextP1,
- &intersection );
- if ( useIntersection )
- {
- /* modify the last point of the cached element (either line or */
- /* curve) */
- *prevP1 = intersection;
- }
- }
-
- params.pt0 = glyphpath->currentDS;
-
- switch( glyphpath->prevElemOp )
- {
- case CF2_PathOpLineTo:
- params.op = CF2_PathOpLineTo;
-
- /* note: pt2 and pt3 are unused */
-
- if ( close )
- {
- /* use first hint map if closing */
- cf2_glyphpath_hintPoint( glyphpath,
- &glyphpath->firstHintMap,
- &params.pt1,
- glyphpath->prevElemP1.x,
- glyphpath->prevElemP1.y );
- }
- else
- {
- cf2_glyphpath_hintPoint( glyphpath,
- hintmap,
- &params.pt1,
- glyphpath->prevElemP1.x,
- glyphpath->prevElemP1.y );
- }
-
- /* output only non-zero length lines */
- if ( params.pt0.x != params.pt1.x || params.pt0.y != params.pt1.y )
- {
- glyphpath->callbacks->lineTo( glyphpath->callbacks, &params );
-
- glyphpath->currentDS = params.pt1;
- }
- break;
-
- case CF2_PathOpCubeTo:
- params.op = CF2_PathOpCubeTo;
-
- /* TODO: should we intersect the interior joins (p1-p2 and p2-p3)? */
- cf2_glyphpath_hintPoint( glyphpath,
- hintmap,
- &params.pt1,
- glyphpath->prevElemP1.x,
- glyphpath->prevElemP1.y );
- cf2_glyphpath_hintPoint( glyphpath,
- hintmap,
- &params.pt2,
- glyphpath->prevElemP2.x,
- glyphpath->prevElemP2.y );
- cf2_glyphpath_hintPoint( glyphpath,
- hintmap,
- &params.pt3,
- glyphpath->prevElemP3.x,
- glyphpath->prevElemP3.y );
-
- glyphpath->callbacks->cubeTo( glyphpath->callbacks, &params );
-
- glyphpath->currentDS = params.pt3;
-
- break;
- }
-
- if ( !useIntersection || close )
- {
- /* insert connecting line between end of previous element and start */
- /* of current one */
- /* note: at the end of a subpath, we might do both, so use `nextP0' */
- /* before we change it, below */
-
- if ( close )
- {
- /* if we are closing the subpath, then nextP0 is in the first */
- /* hint zone */
- cf2_glyphpath_hintPoint( glyphpath,
- &glyphpath->firstHintMap,
- &params.pt1,
- nextP0->x,
- nextP0->y );
- }
- else
- {
- cf2_glyphpath_hintPoint( glyphpath,
- hintmap,
- &params.pt1,
- nextP0->x,
- nextP0->y );
- }
-
- if ( params.pt1.x != glyphpath->currentDS.x ||
- params.pt1.y != glyphpath->currentDS.y )
- {
- /* length is nonzero */
- params.op = CF2_PathOpLineTo;
- params.pt0 = glyphpath->currentDS;
-
- /* note: pt2 and pt3 are unused */
- glyphpath->callbacks->lineTo( glyphpath->callbacks, &params );
-
- glyphpath->currentDS = params.pt1;
- }
- }
-
- if ( useIntersection )
- {
- /* return intersection point to caller */
- *nextP0 = intersection;
- }
- }
-
-
- /* push a MoveTo element based on current point and offset of current */
- /* element */
- static void
- cf2_glyphpath_pushMove( CF2_GlyphPath glyphpath,
- FT_Vector start )
- {
- CF2_CallbackParamsRec params;
-
-
- params.op = CF2_PathOpMoveTo;
- params.pt0 = glyphpath->currentDS;
-
- /* Test if move has really happened yet; it would have called */
- /* `cf2_hintmap_build' to set `isValid'. */
- if ( !cf2_hintmap_isValid( &glyphpath->hintMap ) )
- {
- /* we are here iff first subpath is missing a moveto operator: */
- /* synthesize first moveTo to finish initialization of hintMap */
- cf2_glyphpath_moveTo( glyphpath,
- glyphpath->start.x,
- glyphpath->start.y );
- }
-
- cf2_glyphpath_hintPoint( glyphpath,
- &glyphpath->hintMap,
- &params.pt1,
- start.x,
- start.y );
-
- /* note: pt2 and pt3 are unused */
- glyphpath->callbacks->moveTo( glyphpath->callbacks, &params );
-
- glyphpath->currentDS = params.pt1;
- glyphpath->offsetStart0 = start;
- }
-
-
- /*
- * All coordinates are in character space.
- * On input, (x1, y1) and (x2, y2) give line segment.
- * On output, (x, y) give offset vector.
- * We use a piecewise approximation to trig functions.
- *
- * TODO: Offset true perpendicular and proper length
- * supply the y-translation for hinting here, too,
- * that adds yOffset unconditionally to *y.
- */
- static void
- cf2_glyphpath_computeOffset( CF2_GlyphPath glyphpath,
- CF2_Fixed x1,
- CF2_Fixed y1,
- CF2_Fixed x2,
- CF2_Fixed y2,
- CF2_Fixed* x,
- CF2_Fixed* y )
- {
- CF2_Fixed dx = SUB_INT32( x2, x1 );
- CF2_Fixed dy = SUB_INT32( y2, y1 );
-
-
- /* note: negative offsets don't work here; negate deltas to change */
- /* quadrants, below */
- if ( glyphpath->font->reverseWinding )
- {
- dx = NEG_INT32( dx );
- dy = NEG_INT32( dy );
- }
-
- *x = *y = 0;
-
- if ( !glyphpath->darken )
- return;
-
- /* add momentum for this path element */
- glyphpath->callbacks->windingMomentum =
- ADD_INT32( glyphpath->callbacks->windingMomentum,
- cf2_getWindingMomentum( x1, y1, x2, y2 ) );
-
- /* note: allow mixed integer and fixed multiplication here */
- if ( dx >= 0 )
- {
- if ( dy >= 0 )
- {
- /* first quadrant, +x +y */
-
- if ( dx > MUL_INT32( 2, dy ) )
- {
- /* +x */
- *x = 0;
- *y = 0;
- }
- else if ( dy > MUL_INT32( 2, dx ) )
- {
- /* +y */
- *x = glyphpath->xOffset;
- *y = glyphpath->yOffset;
- }
- else
- {
- /* +x +y */
- *x = FT_MulFix( cf2_doubleToFixed( 0.7 ),
- glyphpath->xOffset );
- *y = FT_MulFix( cf2_doubleToFixed( 1.0 - 0.7 ),
- glyphpath->yOffset );
- }
- }
- else
- {
- /* fourth quadrant, +x -y */
-
- if ( dx > MUL_INT32( -2, dy ) )
- {
- /* +x */
- *x = 0;
- *y = 0;
- }
- else if ( NEG_INT32( dy ) > MUL_INT32( 2, dx ) )
- {
- /* -y */
- *x = NEG_INT32( glyphpath->xOffset );
- *y = glyphpath->yOffset;
- }
- else
- {
- /* +x -y */
- *x = FT_MulFix( cf2_doubleToFixed( -0.7 ),
- glyphpath->xOffset );
- *y = FT_MulFix( cf2_doubleToFixed( 1.0 - 0.7 ),
- glyphpath->yOffset );
- }
- }
- }
- else
- {
- if ( dy >= 0 )
- {
- /* second quadrant, -x +y */
-
- if ( NEG_INT32( dx ) > MUL_INT32( 2, dy ) )
- {
- /* -x */
- *x = 0;
- *y = MUL_INT32( 2, glyphpath->yOffset );
- }
- else if ( dy > MUL_INT32( -2, dx ) )
- {
- /* +y */
- *x = glyphpath->xOffset;
- *y = glyphpath->yOffset;
- }
- else
- {
- /* -x +y */
- *x = FT_MulFix( cf2_doubleToFixed( 0.7 ),
- glyphpath->xOffset );
- *y = FT_MulFix( cf2_doubleToFixed( 1.0 + 0.7 ),
- glyphpath->yOffset );
- }
- }
- else
- {
- /* third quadrant, -x -y */
-
- if ( NEG_INT32( dx ) > MUL_INT32( -2, dy ) )
- {
- /* -x */
- *x = 0;
- *y = MUL_INT32( 2, glyphpath->yOffset );
- }
- else if ( NEG_INT32( dy ) > MUL_INT32( -2, dx ) )
- {
- /* -y */
- *x = NEG_INT32( glyphpath->xOffset );
- *y = glyphpath->yOffset;
- }
- else
- {
- /* -x -y */
- *x = FT_MulFix( cf2_doubleToFixed( -0.7 ),
- glyphpath->xOffset );
- *y = FT_MulFix( cf2_doubleToFixed( 1.0 + 0.7 ),
- glyphpath->yOffset );
- }
- }
- }
- }
-
-
- /*
- * The functions cf2_glyphpath_{moveTo,lineTo,curveTo,closeOpenPath} are
- * called by the interpreter with Character Space (CS) coordinates. Each
- * path element is placed into a queue of length one to await the
- * calculation of the following element. At that time, the darkening
- * offset of the following element is known and joins can be computed,
- * including possible modification of this element, before mapping to
- * Device Space (DS) and passing it on to the outline consumer.
- *
- */
- FT_LOCAL_DEF( void )
- cf2_glyphpath_moveTo( CF2_GlyphPath glyphpath,
- CF2_Fixed x,
- CF2_Fixed y )
- {
- cf2_glyphpath_closeOpenPath( glyphpath );
-
- /* save the parameters of the move for later, when we'll know how to */
- /* offset it; */
- /* also save last move point */
- glyphpath->currentCS.x = glyphpath->start.x = x;
- glyphpath->currentCS.y = glyphpath->start.y = y;
-
- glyphpath->moveIsPending = TRUE;
-
- /* ensure we have a valid map with current mask */
- if ( !cf2_hintmap_isValid( &glyphpath->hintMap ) ||
- cf2_hintmask_isNew( glyphpath->hintMask ) )
- cf2_hintmap_build( &glyphpath->hintMap,
- glyphpath->hStemHintArray,
- glyphpath->vStemHintArray,
- glyphpath->hintMask,
- glyphpath->hintOriginY,
- FALSE );
-
- /* save a copy of current HintMap to use when drawing initial point */
- glyphpath->firstHintMap = glyphpath->hintMap; /* structure copy */
- }
-
-
- FT_LOCAL_DEF( void )
- cf2_glyphpath_lineTo( CF2_GlyphPath glyphpath,
- CF2_Fixed x,
- CF2_Fixed y )
- {
- CF2_Fixed xOffset, yOffset;
- FT_Vector P0, P1;
- FT_Bool newHintMap;
-
- /*
- * New hints will be applied after cf2_glyphpath_pushPrevElem has run.
- * In case this is a synthesized closing line, any new hints should be
- * delayed until this path is closed (`cf2_hintmask_isNew' will be
- * called again before the next line or curve).
- */
-
- /* true if new hint map not on close */
- newHintMap = cf2_hintmask_isNew( glyphpath->hintMask ) &&
- !glyphpath->pathIsClosing;
-
- /*
- * Zero-length lines may occur in the charstring. Because we cannot
- * compute darkening offsets or intersections from zero-length lines,
- * it is best to remove them and avoid artifacts. However, zero-length
- * lines in CS at the start of a new hint map can generate non-zero
- * lines in DS due to hint substitution. We detect a change in hint
- * map here and pass those zero-length lines along.
- */
-
- /*
- * Note: Find explicitly closed paths here with a conditional
- * breakpoint using
- *
- * !gp->pathIsClosing && gp->start.x == x && gp->start.y == y
- *
- */
-
- if ( glyphpath->currentCS.x == x &&
- glyphpath->currentCS.y == y &&
- !newHintMap )
- /*
- * Ignore zero-length lines in CS where the hint map is the same
- * because the line in DS will also be zero length.
- *
- * Ignore zero-length lines when we synthesize a closing line because
- * the close will be handled in cf2_glyphPath_pushPrevElem.
- */
- return;
-
- cf2_glyphpath_computeOffset( glyphpath,
- glyphpath->currentCS.x,
- glyphpath->currentCS.y,
- x,
- y,
- &xOffset,
- &yOffset );
-
- /* construct offset points */
- P0.x = ADD_INT32( glyphpath->currentCS.x, xOffset );
- P0.y = ADD_INT32( glyphpath->currentCS.y, yOffset );
- P1.x = ADD_INT32( x, xOffset );
- P1.y = ADD_INT32( y, yOffset );
-
- if ( glyphpath->moveIsPending )
- {
- /* emit offset 1st point as MoveTo */
- cf2_glyphpath_pushMove( glyphpath, P0 );
-
- glyphpath->moveIsPending = FALSE; /* adjust state machine */
- glyphpath->pathIsOpen = TRUE;
-
- glyphpath->offsetStart1 = P1; /* record second point */
- }
-
- if ( glyphpath->elemIsQueued )
- {
- FT_ASSERT( cf2_hintmap_isValid( &glyphpath->hintMap ) ||
- glyphpath->hintMap.count == 0 );
-
- cf2_glyphpath_pushPrevElem( glyphpath,
- &glyphpath->hintMap,
- &P0,
- P1,
- FALSE );
- }
-
- /* queue the current element with offset points */
- glyphpath->elemIsQueued = TRUE;
- glyphpath->prevElemOp = CF2_PathOpLineTo;
- glyphpath->prevElemP0 = P0;
- glyphpath->prevElemP1 = P1;
-
- /* update current map */
- if ( newHintMap )
- cf2_hintmap_build( &glyphpath->hintMap,
- glyphpath->hStemHintArray,
- glyphpath->vStemHintArray,
- glyphpath->hintMask,
- glyphpath->hintOriginY,
- FALSE );
-
- glyphpath->currentCS.x = x; /* pre-offset current point */
- glyphpath->currentCS.y = y;
- }
-
-
- FT_LOCAL_DEF( void )
- cf2_glyphpath_curveTo( CF2_GlyphPath glyphpath,
- CF2_Fixed x1,
- CF2_Fixed y1,
- CF2_Fixed x2,
- CF2_Fixed y2,
- CF2_Fixed x3,
- CF2_Fixed y3 )
- {
- CF2_Fixed xOffset1, yOffset1, xOffset3, yOffset3;
- FT_Vector P0, P1, P2, P3;
-
-
- /* TODO: ignore zero length portions of curve?? */
- cf2_glyphpath_computeOffset( glyphpath,
- glyphpath->currentCS.x,
- glyphpath->currentCS.y,
- x1,
- y1,
- &xOffset1,
- &yOffset1 );
- cf2_glyphpath_computeOffset( glyphpath,
- x2,
- y2,
- x3,
- y3,
- &xOffset3,
- &yOffset3 );
-
- /* add momentum from the middle segment */
- glyphpath->callbacks->windingMomentum =
- ADD_INT32( glyphpath->callbacks->windingMomentum,
- cf2_getWindingMomentum( x1, y1, x2, y2 ) );
-
- /* construct offset points */
- P0.x = ADD_INT32( glyphpath->currentCS.x, xOffset1 );
- P0.y = ADD_INT32( glyphpath->currentCS.y, yOffset1 );
- P1.x = ADD_INT32( x1, xOffset1 );
- P1.y = ADD_INT32( y1, yOffset1 );
- /* note: preserve angle of final segment by using offset3 at both ends */
- P2.x = ADD_INT32( x2, xOffset3 );
- P2.y = ADD_INT32( y2, yOffset3 );
- P3.x = ADD_INT32( x3, xOffset3 );
- P3.y = ADD_INT32( y3, yOffset3 );
-
- if ( glyphpath->moveIsPending )
- {
- /* emit offset 1st point as MoveTo */
- cf2_glyphpath_pushMove( glyphpath, P0 );
-
- glyphpath->moveIsPending = FALSE;
- glyphpath->pathIsOpen = TRUE;
-
- glyphpath->offsetStart1 = P1; /* record second point */
- }
-
- if ( glyphpath->elemIsQueued )
- {
- FT_ASSERT( cf2_hintmap_isValid( &glyphpath->hintMap ) ||
- glyphpath->hintMap.count == 0 );
-
- cf2_glyphpath_pushPrevElem( glyphpath,
- &glyphpath->hintMap,
- &P0,
- P1,
- FALSE );
- }
-
- /* queue the current element with offset points */
- glyphpath->elemIsQueued = TRUE;
- glyphpath->prevElemOp = CF2_PathOpCubeTo;
- glyphpath->prevElemP0 = P0;
- glyphpath->prevElemP1 = P1;
- glyphpath->prevElemP2 = P2;
- glyphpath->prevElemP3 = P3;
-
- /* update current map */
- if ( cf2_hintmask_isNew( glyphpath->hintMask ) )
- cf2_hintmap_build( &glyphpath->hintMap,
- glyphpath->hStemHintArray,
- glyphpath->vStemHintArray,
- glyphpath->hintMask,
- glyphpath->hintOriginY,
- FALSE );
-
- glyphpath->currentCS.x = x3; /* pre-offset current point */
- glyphpath->currentCS.y = y3;
- }
-
-
- FT_LOCAL_DEF( void )
- cf2_glyphpath_closeOpenPath( CF2_GlyphPath glyphpath )
- {
- if ( glyphpath->pathIsOpen )
- {
- /*
- * A closing line in Character Space line is always generated below
- * with `cf2_glyphPath_lineTo'. It may be ignored later if it turns
- * out to be zero length in Device Space.
- */
- glyphpath->pathIsClosing = TRUE;
-
- cf2_glyphpath_lineTo( glyphpath,
- glyphpath->start.x,
- glyphpath->start.y );
-
- /* empty the final element from the queue and close the path */
- if ( glyphpath->elemIsQueued )
- cf2_glyphpath_pushPrevElem( glyphpath,
- &glyphpath->hintMap,
- &glyphpath->offsetStart0,
- glyphpath->offsetStart1,
- TRUE );
-
- /* reset state machine */
- glyphpath->moveIsPending = TRUE;
- glyphpath->pathIsOpen = FALSE;
- glyphpath->pathIsClosing = FALSE;
- glyphpath->elemIsQueued = FALSE;
- }
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/psaux/pshints.h b/contrib/libs/freetype/src/psaux/pshints.h
deleted file mode 100644
index 31a8230364..0000000000
--- a/contrib/libs/freetype/src/psaux/pshints.h
+++ /dev/null
@@ -1,288 +0,0 @@
-/****************************************************************************
- *
- * pshints.h
- *
- * Adobe's code for handling CFF hints (body).
- *
- * Copyright 2007-2013 Adobe Systems Incorporated.
- *
- * This software, and all works of authorship, whether in source or
- * object code form as indicated by the copyright notice(s) included
- * herein (collectively, the "Work") is made available, and may only be
- * used, modified, and distributed under the FreeType Project License,
- * LICENSE.TXT. Additionally, subject to the terms and conditions of the
- * FreeType Project License, each contributor to the Work hereby grants
- * to any individual or legal entity exercising permissions granted by
- * the FreeType Project License and this section (hereafter, "You" or
- * "Your") a perpetual, worldwide, non-exclusive, no-charge,
- * royalty-free, irrevocable (except as stated in this section) patent
- * license to make, have made, use, offer to sell, sell, import, and
- * otherwise transfer the Work, where such license applies only to those
- * patent claims licensable by such contributor that are necessarily
- * infringed by their contribution(s) alone or by combination of their
- * contribution(s) with the Work to which such contribution(s) was
- * submitted. If You institute patent litigation against any entity
- * (including a cross-claim or counterclaim in a lawsuit) alleging that
- * the Work or a contribution incorporated within the Work constitutes
- * direct or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate as of
- * the date such litigation is filed.
- *
- * By using, modifying, or distributing the Work you indicate that you
- * have read and understood the terms and conditions of the
- * FreeType Project License as well as those provided in this section,
- * and you accept them fully.
- *
- */
-
-
-#ifndef PSHINT_H_
-#define PSHINT_H_
-
-FT_BEGIN_HEADER
-
-
- enum
- {
- CF2_MAX_HINTS = 96 /* maximum # of hints */
- };
-
-
- /*
- * A HintMask object stores a bit mask that specifies which hints in the
- * charstring are active at a given time. Hints in CFF must be declared
- * at the start, before any drawing operators, with horizontal hints
- * preceding vertical hints. The HintMask is ordered the same way, with
- * horizontal hints immediately followed by vertical hints. Clients are
- * responsible for knowing how many of each type are present.
- *
- * The maximum total number of hints is 96, as specified by the CFF
- * specification.
- *
- * A HintMask is built 0 or more times while interpreting a charstring, by
- * the HintMask operator. There is only one HintMask, but it is built or
- * rebuilt each time there is a hint substitution (HintMask operator) in
- * the charstring. A default HintMask with all bits set is built if there
- * has been no HintMask operator prior to the first drawing operator.
- *
- */
-
- typedef struct CF2_HintMaskRec_
- {
- FT_Error* error;
-
- FT_Bool isValid;
- FT_Bool isNew;
-
- size_t bitCount;
- size_t byteCount;
-
- FT_Byte mask[( CF2_MAX_HINTS + 7 ) / 8];
-
- } CF2_HintMaskRec, *CF2_HintMask;
-
-
- typedef struct CF2_StemHintRec_
- {
- FT_Bool used; /* DS positions are valid */
-
- CF2_Fixed min; /* original character space value */
- CF2_Fixed max;
-
- CF2_Fixed minDS; /* DS position after first use */
- CF2_Fixed maxDS;
-
- } CF2_StemHintRec, *CF2_StemHint;
-
-
- /*
- * A HintMap object stores a piecewise linear function for mapping
- * y-coordinates from character space to device space, providing
- * appropriate pixel alignment to stem edges.
- *
- * The map is implemented as an array of `CF2_Hint' elements, each
- * representing an edge. When edges are paired, as from stem hints, the
- * bottom edge must immediately precede the top edge in the array.
- * Element character space AND device space positions must both increase
- * monotonically in the array. `CF2_Hint' elements are also used as
- * parameters to `cf2_blues_capture'.
- *
- * The `cf2_hintmap_build' method must be called before any drawing
- * operation (beginning with a Move operator) and at each hint
- * substitution (HintMask operator).
- *
- * The `cf2_hintmap_map' method is called to transform y-coordinates at
- * each drawing operation (move, line, curve).
- *
- */
-
- /* TODO: make this a CF2_ArrStack and add a deep copy method */
- enum
- {
- CF2_MAX_HINT_EDGES = CF2_MAX_HINTS * 2
- };
-
-
- typedef struct CF2_HintMapRec_
- {
- CF2_Font font;
-
- /* initial map based on blue zones */
- struct CF2_HintMapRec_* initialHintMap;
-
- /* working storage for 2nd pass adjustHints */
- CF2_ArrStack hintMoves;
-
- FT_Bool isValid;
- FT_Bool hinted;
-
- CF2_Fixed scale;
- CF2_UInt count;
-
- /* start search from this index */
- CF2_UInt lastIndex;
-
- CF2_HintRec edge[CF2_MAX_HINT_EDGES]; /* 192 */
-
- } CF2_HintMapRec, *CF2_HintMap;
-
-
- FT_LOCAL( FT_Bool )
- cf2_hint_isValid( const CF2_Hint hint );
- FT_LOCAL( FT_Bool )
- cf2_hint_isTop( const CF2_Hint hint );
- FT_LOCAL( FT_Bool )
- cf2_hint_isBottom( const CF2_Hint hint );
- FT_LOCAL( void )
- cf2_hint_lock( CF2_Hint hint );
-
-
- FT_LOCAL( void )
- cf2_hintmap_init( CF2_HintMap hintmap,
- CF2_Font font,
- CF2_HintMap initialMap,
- CF2_ArrStack hintMoves,
- CF2_Fixed scale );
- FT_LOCAL( void )
- cf2_hintmap_build( CF2_HintMap hintmap,
- CF2_ArrStack hStemHintArray,
- CF2_ArrStack vStemHintArray,
- CF2_HintMask hintMask,
- CF2_Fixed hintOrigin,
- FT_Bool initialMap );
-
-
- /*
- * GlyphPath is a wrapper for drawing operations that scales the
- * coordinates according to the render matrix and HintMap. It also tracks
- * open paths to control ClosePath and to insert MoveTo for broken fonts.
- *
- */
- typedef struct CF2_GlyphPathRec_
- {
- /* TODO: gather some of these into a hinting context */
-
- CF2_Font font; /* font instance */
- CF2_OutlineCallbacks callbacks; /* outline consumer */
-
-
- CF2_HintMapRec hintMap; /* current hint map */
- CF2_HintMapRec firstHintMap; /* saved copy */
- CF2_HintMapRec initialHintMap; /* based on all captured hints */
-
- CF2_ArrStackRec hintMoves; /* list of hint moves for 2nd pass */
-
- CF2_Fixed scaleX; /* matrix a */
- CF2_Fixed scaleC; /* matrix c */
- CF2_Fixed scaleY; /* matrix d */
-
- FT_Vector fractionalTranslation; /* including deviceXScale */
-#if 0
- CF2_Fixed hShift; /* character space horizontal shift */
- /* (for fauxing) */
-#endif
-
- FT_Bool pathIsOpen; /* true after MoveTo */
- FT_Bool pathIsClosing; /* true when synthesizing closepath line */
- FT_Bool darken; /* true if stem darkening */
- FT_Bool moveIsPending; /* true between MoveTo and offset MoveTo */
-
- /* references used to call `cf2_hintmap_build', if necessary */
- CF2_ArrStack hStemHintArray;
- CF2_ArrStack vStemHintArray;
- CF2_HintMask hintMask; /* ptr to the current mask */
- CF2_Fixed hintOriginY; /* copy of current origin */
- const CF2_BluesRec* blues;
-
- CF2_Fixed xOffset; /* character space offsets */
- CF2_Fixed yOffset;
-
- /* character space miter limit threshold */
- CF2_Fixed miterLimit;
- /* vertical/horizontal snap distance in character space */
- CF2_Fixed snapThreshold;
-
- FT_Vector offsetStart0; /* first and second points of first */
- FT_Vector offsetStart1; /* element with offset applied */
-
- /* current point, character space, before offset */
- FT_Vector currentCS;
- /* current point, device space */
- FT_Vector currentDS;
- /* start point of subpath, character space */
- FT_Vector start;
-
- /* the following members constitute the `queue' of one element */
- FT_Bool elemIsQueued;
- CF2_Int prevElemOp;
-
- FT_Vector prevElemP0;
- FT_Vector prevElemP1;
- FT_Vector prevElemP2;
- FT_Vector prevElemP3;
-
- } CF2_GlyphPathRec, *CF2_GlyphPath;
-
-
- FT_LOCAL( void )
- cf2_glyphpath_init( CF2_GlyphPath glyphpath,
- CF2_Font font,
- CF2_OutlineCallbacks callbacks,
- CF2_Fixed scaleY,
- /* CF2_Fixed hShift, */
- CF2_ArrStack hStemHintArray,
- CF2_ArrStack vStemHintArray,
- CF2_HintMask hintMask,
- CF2_Fixed hintOrigin,
- const CF2_Blues blues,
- const FT_Vector* fractionalTranslation );
- FT_LOCAL( void )
- cf2_glyphpath_finalize( CF2_GlyphPath glyphpath );
-
- FT_LOCAL( void )
- cf2_glyphpath_moveTo( CF2_GlyphPath glyphpath,
- CF2_Fixed x,
- CF2_Fixed y );
- FT_LOCAL( void )
- cf2_glyphpath_lineTo( CF2_GlyphPath glyphpath,
- CF2_Fixed x,
- CF2_Fixed y );
- FT_LOCAL( void )
- cf2_glyphpath_curveTo( CF2_GlyphPath glyphpath,
- CF2_Fixed x1,
- CF2_Fixed y1,
- CF2_Fixed x2,
- CF2_Fixed y2,
- CF2_Fixed x3,
- CF2_Fixed y3 );
- FT_LOCAL( void )
- cf2_glyphpath_closeOpenPath( CF2_GlyphPath glyphpath );
-
-
-FT_END_HEADER
-
-
-#endif /* PSHINT_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/psaux/psintrp.c b/contrib/libs/freetype/src/psaux/psintrp.c
deleted file mode 100644
index 7572e225e3..0000000000
--- a/contrib/libs/freetype/src/psaux/psintrp.c
+++ /dev/null
@@ -1,3050 +0,0 @@
-/****************************************************************************
- *
- * psintrp.c
- *
- * Adobe's CFF Interpreter (body).
- *
- * Copyright 2007-2014 Adobe Systems Incorporated.
- *
- * This software, and all works of authorship, whether in source or
- * object code form as indicated by the copyright notice(s) included
- * herein (collectively, the "Work") is made available, and may only be
- * used, modified, and distributed under the FreeType Project License,
- * LICENSE.TXT. Additionally, subject to the terms and conditions of the
- * FreeType Project License, each contributor to the Work hereby grants
- * to any individual or legal entity exercising permissions granted by
- * the FreeType Project License and this section (hereafter, "You" or
- * "Your") a perpetual, worldwide, non-exclusive, no-charge,
- * royalty-free, irrevocable (except as stated in this section) patent
- * license to make, have made, use, offer to sell, sell, import, and
- * otherwise transfer the Work, where such license applies only to those
- * patent claims licensable by such contributor that are necessarily
- * infringed by their contribution(s) alone or by combination of their
- * contribution(s) with the Work to which such contribution(s) was
- * submitted. If You institute patent litigation against any entity
- * (including a cross-claim or counterclaim in a lawsuit) alleging that
- * the Work or a contribution incorporated within the Work constitutes
- * direct or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate as of
- * the date such litigation is filed.
- *
- * By using, modifying, or distributing the Work you indicate that you
- * have read and understood the terms and conditions of the
- * FreeType Project License as well as those provided in this section,
- * and you accept them fully.
- *
- */
-
-
-#include "psft.h"
-#include <freetype/internal/ftcalc.h>
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/services/svcfftl.h>
-
-#include "psglue.h"
-#include "psfont.h"
-#include "psstack.h"
-#include "pshints.h"
-#include "psintrp.h"
-
-#include "pserror.h"
-
-#include "psobjs.h" /* for cff_random */
-#include "t1decode.h" /* for t1 seac */
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT cf2interp
-
-
- FT_LOCAL_DEF( void )
- cf2_hintmask_init( CF2_HintMask hintmask,
- FT_Error* error )
- {
- FT_ZERO( hintmask );
-
- hintmask->error = error;
- }
-
-
- FT_LOCAL_DEF( FT_Bool )
- cf2_hintmask_isValid( const CF2_HintMask hintmask )
- {
- return hintmask->isValid;
- }
-
-
- FT_LOCAL_DEF( FT_Bool )
- cf2_hintmask_isNew( const CF2_HintMask hintmask )
- {
- return hintmask->isNew;
- }
-
-
- FT_LOCAL_DEF( void )
- cf2_hintmask_setNew( CF2_HintMask hintmask,
- FT_Bool val )
- {
- hintmask->isNew = val;
- }
-
-
- /* clients call `getMaskPtr' in order to iterate */
- /* through hint mask */
-
- FT_LOCAL_DEF( FT_Byte* )
- cf2_hintmask_getMaskPtr( CF2_HintMask hintmask )
- {
- return hintmask->mask;
- }
-
-
- static size_t
- cf2_hintmask_setCounts( CF2_HintMask hintmask,
- size_t bitCount )
- {
- if ( bitCount > CF2_MAX_HINTS )
- {
- /* total of h and v stems must be <= 96 */
- CF2_SET_ERROR( hintmask->error, Invalid_Glyph_Format );
- return 0;
- }
-
- hintmask->bitCount = bitCount;
- hintmask->byteCount = ( hintmask->bitCount + 7 ) / 8;
-
- hintmask->isValid = TRUE;
- hintmask->isNew = TRUE;
-
- return bitCount;
- }
-
-
- /* consume the hintmask bytes from the charstring, advancing the src */
- /* pointer */
- static void
- cf2_hintmask_read( CF2_HintMask hintmask,
- CF2_Buffer charstring,
- size_t bitCount )
- {
- size_t i;
-
-#ifndef CF2_NDEBUG
- /* these are the bits in the final mask byte that should be zero */
- /* Note: this variable is only used in an assert expression below */
- /* and then only if CF2_NDEBUG is not defined */
- CF2_UInt mask = ( 1 << ( -(CF2_Int)bitCount & 7 ) ) - 1;
-#endif
-
-
- /* initialize counts and isValid */
- if ( cf2_hintmask_setCounts( hintmask, bitCount ) == 0 )
- return;
-
- FT_ASSERT( hintmask->byteCount > 0 );
-
- FT_TRACE4(( " (maskbytes:" ));
-
- /* set mask and advance interpreter's charstring pointer */
- for ( i = 0; i < hintmask->byteCount; i++ )
- {
- hintmask->mask[i] = (FT_Byte)cf2_buf_readByte( charstring );
- FT_TRACE4(( " 0x%02X", hintmask->mask[i] ));
- }
-
- FT_TRACE4(( ")\n" ));
-
- /* assert any unused bits in last byte are zero unless there's a prior */
- /* error */
- /* bitCount -> mask, 0 -> 0, 1 -> 7f, 2 -> 3f, ... 6 -> 3, 7 -> 1 */
-#ifndef CF2_NDEBUG
- FT_ASSERT( ( hintmask->mask[hintmask->byteCount - 1] & mask ) == 0 ||
- *hintmask->error );
-#endif
- }
-
-
- FT_LOCAL_DEF( void )
- cf2_hintmask_setAll( CF2_HintMask hintmask,
- size_t bitCount )
- {
- size_t i;
- CF2_UInt mask = ( 1 << ( -(CF2_Int)bitCount & 7 ) ) - 1;
-
-
- /* initialize counts and isValid */
- if ( cf2_hintmask_setCounts( hintmask, bitCount ) == 0 )
- return;
-
- FT_ASSERT( hintmask->byteCount > 0 );
- FT_ASSERT( hintmask->byteCount <=
- sizeof ( hintmask->mask ) / sizeof ( hintmask->mask[0] ) );
-
- /* set mask to all ones */
- for ( i = 0; i < hintmask->byteCount; i++ )
- hintmask->mask[i] = 0xFF;
-
- /* clear unused bits */
- /* bitCount -> mask, 0 -> 0, 1 -> 7f, 2 -> 3f, ... 6 -> 3, 7 -> 1 */
- hintmask->mask[hintmask->byteCount - 1] &= ~mask;
- }
-
-
- /* Type2 charstring opcodes */
- enum
- {
- cf2_cmdRESERVED_0, /* 0 */
- cf2_cmdHSTEM, /* 1 */
- cf2_cmdRESERVED_2, /* 2 */
- cf2_cmdVSTEM, /* 3 */
- cf2_cmdVMOVETO, /* 4 */
- cf2_cmdRLINETO, /* 5 */
- cf2_cmdHLINETO, /* 6 */
- cf2_cmdVLINETO, /* 7 */
- cf2_cmdRRCURVETO, /* 8 */
- cf2_cmdCLOSEPATH, /* 9 T1 only */
- cf2_cmdCALLSUBR, /* 10 */
- cf2_cmdRETURN, /* 11 */
- cf2_cmdESC, /* 12 */
- cf2_cmdHSBW, /* 13 T1 only */
- cf2_cmdENDCHAR, /* 14 */
- cf2_cmdVSINDEX, /* 15 */
- cf2_cmdBLEND, /* 16 */
- cf2_cmdRESERVED_17, /* 17 */
- cf2_cmdHSTEMHM, /* 18 */
- cf2_cmdHINTMASK, /* 19 */
- cf2_cmdCNTRMASK, /* 20 */
- cf2_cmdRMOVETO, /* 21 */
- cf2_cmdHMOVETO, /* 22 */
- cf2_cmdVSTEMHM, /* 23 */
- cf2_cmdRCURVELINE, /* 24 */
- cf2_cmdRLINECURVE, /* 25 */
- cf2_cmdVVCURVETO, /* 26 */
- cf2_cmdHHCURVETO, /* 27 */
- cf2_cmdEXTENDEDNMBR, /* 28 */
- cf2_cmdCALLGSUBR, /* 29 */
- cf2_cmdVHCURVETO, /* 30 */
- cf2_cmdHVCURVETO /* 31 */
- };
-
- enum
- {
- cf2_escDOTSECTION, /* 0 */
- cf2_escVSTEM3, /* 1 T1 only */
- cf2_escHSTEM3, /* 2 T1 only */
- cf2_escAND, /* 3 */
- cf2_escOR, /* 4 */
- cf2_escNOT, /* 5 */
- cf2_escSEAC, /* 6 T1 only */
- cf2_escSBW, /* 7 T1 only */
- cf2_escRESERVED_8, /* 8 */
- cf2_escABS, /* 9 */
- cf2_escADD, /* 10 like otherADD */
- cf2_escSUB, /* 11 like otherSUB */
- cf2_escDIV, /* 12 */
- cf2_escRESERVED_13, /* 13 */
- cf2_escNEG, /* 14 */
- cf2_escEQ, /* 15 */
- cf2_escCALLOTHERSUBR,/* 16 T1 only */
- cf2_escPOP, /* 17 T1 only */
- cf2_escDROP, /* 18 */
- cf2_escRESERVED_19, /* 19 */
- cf2_escPUT, /* 20 like otherPUT */
- cf2_escGET, /* 21 like otherGET */
- cf2_escIFELSE, /* 22 like otherIFELSE */
- cf2_escRANDOM, /* 23 like otherRANDOM */
- cf2_escMUL, /* 24 like otherMUL */
- cf2_escRESERVED_25, /* 25 */
- cf2_escSQRT, /* 26 */
- cf2_escDUP, /* 27 like otherDUP */
- cf2_escEXCH, /* 28 like otherEXCH */
- cf2_escINDEX, /* 29 */
- cf2_escROLL, /* 30 */
- cf2_escRESERVED_31, /* 31 */
- cf2_escRESERVED_32, /* 32 */
- cf2_escSETCURRENTPT, /* 33 T1 only */
- cf2_escHFLEX, /* 34 */
- cf2_escFLEX, /* 35 */
- cf2_escHFLEX1, /* 36 */
- cf2_escFLEX1, /* 37 */
- cf2_escRESERVED_38 /* 38 & all higher */
- };
-
-
- /* `stemHintArray' does not change once we start drawing the outline. */
- static void
- cf2_doStems( const CF2_Font font,
- CF2_Stack opStack,
- CF2_ArrStack stemHintArray,
- CF2_Fixed* width,
- FT_Bool* haveWidth,
- CF2_Fixed hintOffset )
- {
- CF2_UInt i;
- CF2_UInt count = cf2_stack_count( opStack );
- FT_Bool hasWidthArg = FT_BOOL( count & 1 );
-
- /* variable accumulates delta values from operand stack */
- CF2_Fixed position = hintOffset;
-
- if ( font->isT1 && !font->decoder->flex_state && !*haveWidth )
- FT_ERROR(( "cf2_doStems (Type 1 mode):"
- " No width. Use hsbw/sbw as first op\n" ));
-
- if ( !font->isT1 && hasWidthArg && !*haveWidth )
- *width = ADD_INT32( cf2_stack_getReal( opStack, 0 ),
- cf2_getNominalWidthX( font->decoder ) );
-
- if ( font->decoder->width_only )
- goto exit;
-
- for ( i = hasWidthArg ? 1 : 0; i < count; i += 2 )
- {
- /* construct a CF2_StemHint and push it onto the list */
- CF2_StemHintRec stemhint;
-
-
- stemhint.min =
- position = ADD_INT32( position,
- cf2_stack_getReal( opStack, i ) );
- stemhint.max =
- position = ADD_INT32( position,
- cf2_stack_getReal( opStack, i + 1 ) );
-
- stemhint.used = FALSE;
- stemhint.maxDS =
- stemhint.minDS = 0;
-
- cf2_arrstack_push( stemHintArray, &stemhint ); /* defer error check */
- }
-
- cf2_stack_clear( opStack );
-
- exit:
- /* cf2_doStems must define a width (may be default) */
- *haveWidth = TRUE;
- }
-
-
- static void
- cf2_doFlex( CF2_Stack opStack,
- CF2_Fixed* curX,
- CF2_Fixed* curY,
- CF2_GlyphPath glyphPath,
- const FT_Bool* readFromStack,
- FT_Bool doConditionalLastRead )
- {
- CF2_Fixed vals[14];
- CF2_UInt idx;
- FT_Bool isHFlex;
- CF2_Int top, i, j;
-
-
- vals[0] = *curX;
- vals[1] = *curY;
- idx = 0;
- isHFlex = FT_BOOL( readFromStack[9] == FALSE );
- top = isHFlex ? 9 : 10;
-
- for ( i = 0; i < top; i++ )
- {
- vals[i + 2] = vals[i];
- if ( readFromStack[i] )
- vals[i + 2] = ADD_INT32( vals[i + 2], cf2_stack_getReal( opStack,
- idx++ ) );
- }
-
- if ( isHFlex )
- vals[9 + 2] = *curY;
-
- if ( doConditionalLastRead )
- {
- FT_Bool lastIsX = FT_BOOL(
- cf2_fixedAbs( SUB_INT32( vals[10], *curX ) ) >
- cf2_fixedAbs( SUB_INT32( vals[11], *curY ) ) );
- CF2_Fixed lastVal = cf2_stack_getReal( opStack, idx );
-
-
- if ( lastIsX )
- {
- vals[12] = ADD_INT32( vals[10], lastVal );
- vals[13] = *curY;
- }
- else
- {
- vals[12] = *curX;
- vals[13] = ADD_INT32( vals[11], lastVal );
- }
- }
- else
- {
- if ( readFromStack[10] )
- vals[12] = ADD_INT32( vals[10],
- cf2_stack_getReal( opStack, idx++ ) );
- else
- vals[12] = *curX;
-
- if ( readFromStack[11] )
- vals[13] = ADD_INT32( vals[11],
- cf2_stack_getReal( opStack, idx ) );
- else
- vals[13] = *curY;
- }
-
- for ( j = 0; j < 2; j++ )
- cf2_glyphpath_curveTo( glyphPath, vals[j * 6 + 2],
- vals[j * 6 + 3],
- vals[j * 6 + 4],
- vals[j * 6 + 5],
- vals[j * 6 + 6],
- vals[j * 6 + 7] );
-
- cf2_stack_clear( opStack );
-
- *curX = vals[12];
- *curY = vals[13];
- }
-
-
- /* Blend numOperands on the stack, */
- /* store results into the first numBlends values, */
- /* then pop remaining arguments. */
- static void
- cf2_doBlend( const CFF_Blend blend,
- CF2_Stack opStack,
- CF2_UInt numBlends )
- {
- CF2_UInt delta;
- CF2_UInt base;
- CF2_UInt i, j;
- CF2_UInt numOperands = (CF2_UInt)( numBlends * blend->lenBV );
-
-
- base = cf2_stack_count( opStack ) - numOperands;
- delta = base + numBlends;
-
- FT_TRACE6(( " (" ));
-
- for ( i = 0; i < numBlends; i++ )
- {
- const CF2_Fixed* weight = &blend->BV[1];
-
- /* start with first term */
- CF2_Fixed sum = cf2_stack_getReal( opStack, i + base );
-
-
- for ( j = 1; j < blend->lenBV; j++ )
- sum = ADD_INT32( sum,
- FT_MulFix( *weight++,
- cf2_stack_getReal( opStack,
- delta++ ) ) );
-
- FT_TRACE6(( "%f ", (double)sum / 65536 ));
-
- /* store blended result */
- cf2_stack_setReal( opStack, i + base, sum );
- }
-
- FT_TRACE6(( "blended)\n" ));
-
- /* leave only `numBlends' results on stack */
- cf2_stack_pop( opStack, numOperands - numBlends );
- }
-
-
- /*
- * `error' is a shared error code used by many objects in this
- * routine. Before the code continues from an error, it must check and
- * record the error in `*error'. The idea is that this shared
- * error code will record the first error encountered. If testing
- * for an error anyway, the cost of `goto exit' is small, so we do it,
- * even if continuing would be safe. In this case, `lastError' is
- * set, so the testing and storing can be done in one place, at `exit'.
- *
- * Continuing after an error is intended for objects which do their own
- * testing of `*error', e.g., array stack functions. This allows us to
- * avoid an extra test after the call.
- *
- * Unimplemented opcodes are ignored.
- *
- */
- FT_LOCAL_DEF( void )
- cf2_interpT2CharString( CF2_Font font,
- const CF2_Buffer buf,
- CF2_OutlineCallbacks callbacks,
- const FT_Vector* translation,
- FT_Bool doingSeac,
- CF2_Fixed curX,
- CF2_Fixed curY,
- CF2_Fixed* width )
- {
- /* lastError is used for errors that are immediately tested */
- FT_Error lastError = FT_Err_Ok;
-
- /* pointer to parsed font object */
- PS_Decoder* decoder = font->decoder;
-
- FT_Error* error = &font->error;
- FT_Memory memory = font->memory;
-
- CF2_Fixed scaleY = font->innerTransform.d;
- CF2_Fixed nominalWidthX = cf2_getNominalWidthX( decoder );
-
- /* stuff for Type 1 */
- FT_Int known_othersubr_result_cnt = 0;
- FT_Bool large_int = FALSE;
- FT_Bool initial_map_ready = FALSE;
-
-#define PS_STORAGE_SIZE 3
- CF2_F16Dot16 results[PS_STORAGE_SIZE]; /* for othersubr results */
- FT_Int result_cnt = 0;
-
- /* save this for hinting seac accents */
- CF2_Fixed hintOriginY = curY;
-
- CF2_Stack opStack = NULL;
- FT_UInt stackSize;
- FT_Byte op1; /* first opcode byte */
-
- CF2_F16Dot16 storage[CF2_STORAGE_SIZE]; /* for `put' and `get' */
- CF2_F16Dot16 flexStore[6]; /* for Type 1 flex */
-
- /* instruction limit; 20,000,000 matches Avalon */
- FT_UInt32 instructionLimit = 20000000UL;
-
- CF2_ArrStackRec subrStack;
-
- FT_Bool haveWidth;
- CF2_Buffer charstring = NULL;
-
- CF2_Int charstringIndex = -1; /* initialize to empty */
-
- /* TODO: placeholders for hint structures */
-
- /* objects used for hinting */
- CF2_ArrStackRec hStemHintArray;
- CF2_ArrStackRec vStemHintArray;
-
- CF2_HintMaskRec hintMask;
- CF2_GlyphPathRec glyphPath;
-
-
- FT_ZERO( &storage );
- FT_ZERO( &results );
- FT_ZERO( &flexStore );
-
- /* initialize the remaining objects */
- cf2_arrstack_init( &subrStack,
- memory,
- error,
- sizeof ( CF2_BufferRec ) );
- cf2_arrstack_init( &hStemHintArray,
- memory,
- error,
- sizeof ( CF2_StemHintRec ) );
- cf2_arrstack_init( &vStemHintArray,
- memory,
- error,
- sizeof ( CF2_StemHintRec ) );
-
- /* initialize CF2_StemHint arrays */
- cf2_hintmask_init( &hintMask, error );
-
- /* initialize path map to manage drawing operations */
-
- /* Note: last 4 params are used to handle `MoveToPermissive', which */
- /* may need to call `hintMap.Build' */
- /* TODO: MoveToPermissive is gone; are these still needed? */
- cf2_glyphpath_init( &glyphPath,
- font,
- callbacks,
- scaleY,
- /* hShift, */
- &hStemHintArray,
- &vStemHintArray,
- &hintMask,
- hintOriginY,
- &font->blues,
- translation );
-
- /*
- * Initialize state for width parsing. From the CFF Spec:
- *
- * The first stack-clearing operator, which must be one of hstem,
- * hstemhm, vstem, vstemhm, cntrmask, hintmask, hmoveto, vmoveto,
- * rmoveto, or endchar, takes an additional argument - the width (as
- * described earlier), which may be expressed as zero or one numeric
- * argument.
- *
- * What we implement here uses the first validly specified width, but
- * does not detect errors for specifying more than one width.
- *
- * If one of the above operators occurs without explicitly specifying
- * a width, we assume the default width.
- *
- * CFF2 charstrings always return the default width (0).
- *
- */
- haveWidth = font->isCFF2 ? TRUE : FALSE;
- *width = cf2_getDefaultWidthX( decoder );
-
- /*
- * Note: At this point, all pointers to resources must be NULL
- * and all local objects must be initialized.
- * There must be no branches to `exit:' above this point.
- *
- */
-
- /* allocate an operand stack */
- stackSize = font->isCFF2 ? cf2_getMaxstack( decoder )
- : CF2_OPERAND_STACK_SIZE;
- opStack = cf2_stack_init( memory, error, stackSize );
-
- if ( !opStack )
- {
- lastError = FT_THROW( Out_Of_Memory );
- goto exit;
- }
-
- /* initialize subroutine stack by placing top level charstring as */
- /* first element (max depth plus one for the charstring) */
- /* Note: Caller owns and must finalize the first charstring. */
- /* Our copy of it does not change that requirement. */
- cf2_arrstack_setCount( &subrStack, CF2_MAX_SUBR + 1 );
-
- charstring = (CF2_Buffer)cf2_arrstack_getBuffer( &subrStack );
-
- /* catch errors so far */
- if ( *error )
- goto exit;
-
- *charstring = *buf; /* structure copy */
- charstringIndex = 0; /* entry is valid now */
-
- /* main interpreter loop */
- while ( 1 )
- {
- if ( font->isT1 )
- FT_ASSERT( known_othersubr_result_cnt == 0 ||
- result_cnt == 0 );
-
- if ( cf2_buf_isEnd( charstring ) )
- {
- /* If we've reached the end of the charstring, simulate a */
- /* cf2_cmdRETURN or cf2_cmdENDCHAR. */
- /* We do this for both CFF and CFF2. */
- if ( charstringIndex )
- op1 = cf2_cmdRETURN; /* end of buffer for subroutine */
- else
- op1 = cf2_cmdENDCHAR; /* end of buffer for top level charstring */
- }
- else
- {
- op1 = (FT_Byte)cf2_buf_readByte( charstring );
-
- /* Explicit RETURN and ENDCHAR in CFF2 should be ignored. */
- /* Note: Trace message will report 0 instead of 11 or 14. */
- if ( ( op1 == cf2_cmdRETURN || op1 == cf2_cmdENDCHAR ) &&
- font->isCFF2 )
- op1 = cf2_cmdRESERVED_0;
- }
-
- if ( font->isT1 )
- {
- if ( !initial_map_ready &&
- !( op1 == cf2_cmdHSTEM ||
- op1 == cf2_cmdVSTEM ||
- op1 == cf2_cmdHSBW ||
- op1 == cf2_cmdCALLSUBR ||
- op1 == cf2_cmdRETURN ||
- op1 == cf2_cmdESC ||
- op1 == cf2_cmdENDCHAR ||
- op1 >= 32 /* Numbers */ ) )
- {
- /* Skip outline commands first time round. */
- /* `endchar' will trigger initial hintmap build */
- /* and rewind the charstring. */
- FT_TRACE4(( " <outline command skipped>\n" ));
- cf2_stack_clear( opStack );
- continue;
- }
-
- if ( result_cnt > 0 &&
- !( op1 == cf2_cmdCALLSUBR ||
- op1 == cf2_cmdRETURN ||
- op1 == cf2_cmdESC ||
- op1 >= 32 /* Numbers */ ) )
- {
- /* all operands have been transferred by previous pops */
- result_cnt = 0;
- }
-
- if ( large_int && !( op1 >= 32 || op1 == cf2_escDIV ) )
- {
- FT_ERROR(( "cf2_interpT2CharString (Type 1 mode):"
- " no `div' after large integer\n" ));
-
- large_int = FALSE;
- }
- }
-
- /* check for errors once per loop */
- if ( *error )
- goto exit;
-
- instructionLimit--;
- if ( instructionLimit == 0 )
- {
- lastError = FT_THROW( Invalid_Glyph_Format );
- goto exit;
- }
-
- switch( op1 )
- {
- case cf2_cmdRESERVED_0:
- case cf2_cmdRESERVED_2:
- case cf2_cmdRESERVED_17:
- /* we may get here if we have a prior error */
- FT_TRACE4(( " unknown op (%d)\n", op1 ));
- break;
-
- case cf2_cmdVSINDEX:
- FT_TRACE4(( " vsindex\n" ));
-
- if ( !font->isCFF2 )
- break; /* clear stack & ignore */
-
- if ( font->blend.usedBV )
- {
- /* vsindex not allowed after blend */
- lastError = FT_THROW( Invalid_Glyph_Format );
- goto exit;
- }
-
- {
- FT_Int temp = cf2_stack_popInt( opStack );
-
-
- if ( temp >= 0 )
- font->vsindex = (FT_UInt)temp;
- }
- break;
-
- case cf2_cmdBLEND:
- {
- FT_UInt numBlends;
-
-
- FT_TRACE4(( " blend" ));
-
- if ( !font->isCFF2 )
- break; /* clear stack & ignore */
-
- /* do we have a `blend' op in a non-variant font? */
- if ( !font->blend.font )
- {
- lastError = FT_THROW( Invalid_Glyph_Format );
- goto exit;
- }
-
- /* check cached blend vector */
- if ( font->cffload->blend_check_vector( &font->blend,
- font->vsindex,
- font->lenNDV,
- font->NDV ) )
- {
- lastError = font->cffload->blend_build_vector( &font->blend,
- font->vsindex,
- font->lenNDV,
- font->NDV );
- if ( lastError )
- goto exit;
- }
-
- /* do the blend */
- numBlends = (FT_UInt)cf2_stack_popInt( opStack );
- if ( numBlends > stackSize )
- {
- lastError = FT_THROW( Invalid_Glyph_Format );
- goto exit;
- }
-
- cf2_doBlend( &font->blend, opStack, numBlends );
-
- font->blend.usedBV = TRUE;
- }
- continue; /* do not clear the stack */
-
- case cf2_cmdHSTEMHM:
- case cf2_cmdHSTEM:
- FT_TRACE4(( "%s\n", op1 == cf2_cmdHSTEMHM ? " hstemhm"
- : " hstem" ));
-
- if ( !font->isT1 )
- {
- /* never add hints after the mask is computed */
- /* except if in Type 1 mode (no hintmask op) */
- if ( cf2_hintmask_isValid( &hintMask ) )
- {
- FT_TRACE4(( "cf2_interpT2CharString:"
- " invalid horizontal hint mask\n" ));
- break;
- }
- }
-
- /* add left-sidebearing correction in Type 1 mode */
- cf2_doStems( font,
- opStack,
- &hStemHintArray,
- width,
- &haveWidth,
- font->isT1 ? decoder->builder.left_bearing->y
- : 0 );
-
- if ( decoder->width_only )
- goto exit;
-
- break;
-
- case cf2_cmdVSTEMHM:
- case cf2_cmdVSTEM:
- FT_TRACE4(( "%s\n", op1 == cf2_cmdVSTEMHM ? " vstemhm"
- : " vstem" ));
-
- if ( !font->isT1 )
- {
- /* never add hints after the mask is computed */
- /* except if in Type 1 mode (no hintmask op) */
- if ( cf2_hintmask_isValid( &hintMask ) )
- {
- FT_TRACE4(( "cf2_interpT2CharString:"
- " invalid vertical hint mask\n" ));
- break;
- }
- }
-
- /* add left-sidebearing correction in Type 1 mode */
- cf2_doStems( font,
- opStack,
- &vStemHintArray,
- width,
- &haveWidth,
- font->isT1 ? decoder->builder.left_bearing->x
- : 0 );
-
- if ( decoder->width_only )
- goto exit;
-
- break;
-
- case cf2_cmdVMOVETO:
- FT_TRACE4(( " vmoveto\n" ));
-
- if ( font->isT1 && !decoder->flex_state && !haveWidth )
- FT_ERROR(( "cf2_interpT2CharString (Type 1 mode):"
- " No width. Use hsbw/sbw as first op\n" ));
-
- if ( cf2_stack_count( opStack ) > 1 && !haveWidth )
- *width = ADD_INT32( cf2_stack_getReal( opStack, 0 ),
- nominalWidthX );
-
- /* width is defined or default after this */
- haveWidth = TRUE;
-
- if ( decoder->width_only )
- goto exit;
-
- curY = ADD_INT32( curY, cf2_stack_popFixed( opStack ) );
-
- if ( !decoder->flex_state )
- cf2_glyphpath_moveTo( &glyphPath, curX, curY );
-
- break;
-
- case cf2_cmdRLINETO:
- {
- CF2_UInt idx;
- CF2_UInt count = cf2_stack_count( opStack );
-
-
- FT_TRACE4(( " rlineto\n" ));
-
- for ( idx = 0; idx < count; idx += 2 )
- {
- curX = ADD_INT32( curX, cf2_stack_getReal( opStack,
- idx + 0 ) );
- curY = ADD_INT32( curY, cf2_stack_getReal( opStack,
- idx + 1 ) );
-
- cf2_glyphpath_lineTo( &glyphPath, curX, curY );
- }
-
- cf2_stack_clear( opStack );
- }
- continue; /* no need to clear stack again */
-
- case cf2_cmdHLINETO:
- case cf2_cmdVLINETO:
- {
- CF2_UInt idx;
- CF2_UInt count = cf2_stack_count( opStack );
-
- FT_Bool isX = FT_BOOL( op1 == cf2_cmdHLINETO );
-
-
- FT_TRACE4(( "%s\n", isX ? " hlineto" : " vlineto" ));
-
- for ( idx = 0; idx < count; idx++ )
- {
- CF2_Fixed v = cf2_stack_getReal( opStack, idx );
-
-
- if ( isX )
- curX = ADD_INT32( curX, v );
- else
- curY = ADD_INT32( curY, v );
-
- isX = !isX;
-
- cf2_glyphpath_lineTo( &glyphPath, curX, curY );
- }
-
- cf2_stack_clear( opStack );
- }
- continue;
-
- case cf2_cmdRCURVELINE:
- case cf2_cmdRRCURVETO:
- {
- CF2_UInt count = cf2_stack_count( opStack );
- CF2_UInt idx = 0;
-
-
- FT_TRACE4(( "%s\n", op1 == cf2_cmdRCURVELINE ? " rcurveline"
- : " rrcurveto" ));
-
- while ( idx + 6 <= count )
- {
- CF2_Fixed x1, y1, x2, y2, x3, y3;
-
-
- x1 = ADD_INT32( cf2_stack_getReal( opStack, idx + 0 ), curX );
- y1 = ADD_INT32( cf2_stack_getReal( opStack, idx + 1 ), curY );
- x2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 2 ), x1 );
- y2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 3 ), y1 );
- x3 = ADD_INT32( cf2_stack_getReal( opStack, idx + 4 ), x2 );
- y3 = ADD_INT32( cf2_stack_getReal( opStack, idx + 5 ), y2 );
-
- cf2_glyphpath_curveTo( &glyphPath, x1, y1, x2, y2, x3, y3 );
-
- curX = x3;
- curY = y3;
- idx += 6;
- }
-
- if ( op1 == cf2_cmdRCURVELINE )
- {
- curX = ADD_INT32( curX, cf2_stack_getReal( opStack,
- idx + 0 ) );
- curY = ADD_INT32( curY, cf2_stack_getReal( opStack,
- idx + 1 ) );
-
- cf2_glyphpath_lineTo( &glyphPath, curX, curY );
- }
-
- cf2_stack_clear( opStack );
- }
- continue; /* no need to clear stack again */
-
- case cf2_cmdCLOSEPATH:
- if ( !font->isT1 )
- FT_TRACE4(( " unknown op (%d)\n", op1 ));
- else
- {
- FT_TRACE4(( " closepath\n" ));
-
- /* if there is no path, `closepath' is a no-op */
- cf2_glyphpath_closeOpenPath( &glyphPath );
-
- haveWidth = TRUE;
- }
- break;
-
- case cf2_cmdCALLGSUBR:
- case cf2_cmdCALLSUBR:
- {
- CF2_Int subrNum;
-
-
- FT_TRACE4(( "%s", op1 == cf2_cmdCALLGSUBR ? " callgsubr"
- : " callsubr" ));
-
- if ( ( !font->isT1 && charstringIndex > CF2_MAX_SUBR ) ||
- ( font->isT1 && charstringIndex > T1_MAX_SUBRS_CALLS ) )
- {
- /* max subr plus one for charstring */
- lastError = FT_THROW( Invalid_Glyph_Format );
- goto exit; /* overflow of stack */
- }
-
- /* push our current CFF charstring region on subrStack */
- charstring = (CF2_Buffer)
- cf2_arrstack_getPointer(
- &subrStack,
- (size_t)charstringIndex + 1 );
-
- /* set up the new CFF region and pointer */
- subrNum = cf2_stack_popInt( opStack );
-
- if ( font->isT1 && decoder->locals_hash )
- {
- size_t* val = ft_hash_num_lookup( subrNum,
- decoder->locals_hash );
-
-
- if ( val )
- subrNum = *val;
- else
- subrNum = -1;
- }
-
- switch ( op1 )
- {
- case cf2_cmdCALLGSUBR:
- FT_TRACE4(( " (idx %d, entering level %d)\n",
- subrNum + decoder->globals_bias,
- charstringIndex + 1 ));
-
- if ( cf2_initGlobalRegionBuffer( decoder,
- subrNum,
- charstring ) )
- {
- lastError = FT_THROW( Invalid_Glyph_Format );
- goto exit; /* subroutine lookup or stream error */
- }
- break;
-
- default:
- /* cf2_cmdCALLSUBR */
- FT_TRACE4(( " (idx %d, entering level %d)\n",
- subrNum + decoder->locals_bias,
- charstringIndex + 1 ));
-
- if ( cf2_initLocalRegionBuffer( decoder,
- subrNum,
- charstring ) )
- {
- lastError = FT_THROW( Invalid_Glyph_Format );
- goto exit; /* subroutine lookup or stream error */
- }
- }
-
- charstringIndex += 1; /* entry is valid now */
- }
- continue; /* do not clear the stack */
-
- case cf2_cmdRETURN:
- FT_TRACE4(( " return (leaving level %d)\n", charstringIndex ));
-
- if ( charstringIndex < 1 )
- {
- /* Note: cannot return from top charstring */
- lastError = FT_THROW( Invalid_Glyph_Format );
- goto exit; /* underflow of stack */
- }
-
- /* restore position in previous charstring */
- charstring = (CF2_Buffer)
- cf2_arrstack_getPointer(
- &subrStack,
- (CF2_UInt)--charstringIndex );
- continue; /* do not clear the stack */
-
- case cf2_cmdESC:
- {
- FT_Byte op2 = (FT_Byte)cf2_buf_readByte( charstring );
-
-
- /* first switch for 2-byte operators handles CFF2 */
- /* and opcodes that are reserved for both CFF and CFF2 */
- switch ( op2 )
- {
- case cf2_escHFLEX:
- {
- static const FT_Bool readFromStack[12] =
- {
- TRUE /* dx1 */, FALSE /* dy1 */,
- TRUE /* dx2 */, TRUE /* dy2 */,
- TRUE /* dx3 */, FALSE /* dy3 */,
- TRUE /* dx4 */, FALSE /* dy4 */,
- TRUE /* dx5 */, FALSE /* dy5 */,
- TRUE /* dx6 */, FALSE /* dy6 */
- };
-
-
- FT_TRACE4(( " hflex\n" ));
-
- cf2_doFlex( opStack,
- &curX,
- &curY,
- &glyphPath,
- readFromStack,
- FALSE /* doConditionalLastRead */ );
- }
- continue;
-
- case cf2_escFLEX:
- {
- static const FT_Bool readFromStack[12] =
- {
- TRUE /* dx1 */, TRUE /* dy1 */,
- TRUE /* dx2 */, TRUE /* dy2 */,
- TRUE /* dx3 */, TRUE /* dy3 */,
- TRUE /* dx4 */, TRUE /* dy4 */,
- TRUE /* dx5 */, TRUE /* dy5 */,
- TRUE /* dx6 */, TRUE /* dy6 */
- };
-
-
- FT_TRACE4(( " flex\n" ));
-
- cf2_doFlex( opStack,
- &curX,
- &curY,
- &glyphPath,
- readFromStack,
- FALSE /* doConditionalLastRead */ );
- }
- break; /* TODO: why is this not a continue? */
-
- case cf2_escHFLEX1:
- {
- static const FT_Bool readFromStack[12] =
- {
- TRUE /* dx1 */, TRUE /* dy1 */,
- TRUE /* dx2 */, TRUE /* dy2 */,
- TRUE /* dx3 */, FALSE /* dy3 */,
- TRUE /* dx4 */, FALSE /* dy4 */,
- TRUE /* dx5 */, TRUE /* dy5 */,
- TRUE /* dx6 */, FALSE /* dy6 */
- };
-
-
- FT_TRACE4(( " hflex1\n" ));
-
- cf2_doFlex( opStack,
- &curX,
- &curY,
- &glyphPath,
- readFromStack,
- FALSE /* doConditionalLastRead */ );
- }
- continue;
-
- case cf2_escFLEX1:
- {
- static const FT_Bool readFromStack[12] =
- {
- TRUE /* dx1 */, TRUE /* dy1 */,
- TRUE /* dx2 */, TRUE /* dy2 */,
- TRUE /* dx3 */, TRUE /* dy3 */,
- TRUE /* dx4 */, TRUE /* dy4 */,
- TRUE /* dx5 */, TRUE /* dy5 */,
- FALSE /* dx6 */, FALSE /* dy6 */
- };
-
-
- FT_TRACE4(( " flex1\n" ));
-
- cf2_doFlex( opStack,
- &curX,
- &curY,
- &glyphPath,
- readFromStack,
- TRUE /* doConditionalLastRead */ );
- }
- continue;
-
- /* these opcodes are always reserved */
- case cf2_escRESERVED_8:
- case cf2_escRESERVED_13:
- case cf2_escRESERVED_19:
- case cf2_escRESERVED_25:
- case cf2_escRESERVED_31:
- case cf2_escRESERVED_32:
- FT_TRACE4(( " unknown op (12, %d)\n", op2 ));
- break;
-
- default:
- {
- if ( font->isCFF2 || op2 >= cf2_escRESERVED_38 )
- FT_TRACE4(( " unknown op (12, %d)\n", op2 ));
- else if ( font->isT1 && result_cnt > 0 && op2 != cf2_escPOP )
- {
- /* all operands have been transferred by previous pops */
- result_cnt = 0;
- }
- else
- {
- /* second switch for 2-byte operators handles */
- /* CFF and Type 1 */
- switch ( op2 )
- {
-
- case cf2_escDOTSECTION:
- /* something about `flip type of locking' -- ignore it */
- FT_TRACE4(( " dotsection\n" ));
-
- break;
-
- case cf2_escVSTEM3:
- case cf2_escHSTEM3:
- /*
- * Type 1: Type 2:
- * x0 dx0 x1 dx1 x2 dx2 vstem3 x dx {dxa dxb}* vstem
- * y0 dy0 y1 dy1 y2 dy2 hstem3 y dy {dya dyb}* hstem
- * relative to lsb point relative to zero
- *
- */
- {
- if ( !font->isT1 )
- FT_TRACE4(( " unknown op (12, %d)\n", op2 ));
- else
- {
- CF2_F16Dot16 v0, v1, v2;
-
- FT_Bool isV = FT_BOOL( op2 == cf2_escVSTEM3 );
-
-
- FT_TRACE4(( "%s\n", isV ? " vstem3"
- : " hstem3" ));
-
- FT_ASSERT( cf2_stack_count( opStack ) == 6 );
-
- v0 = cf2_stack_getReal( opStack, 0 );
- v1 = cf2_stack_getReal( opStack, 2 );
- v2 = cf2_stack_getReal( opStack, 4 );
-
- cf2_stack_setReal(
- opStack, 2,
- SUB_INT32( SUB_INT32( v1, v0 ),
- cf2_stack_getReal( opStack, 1 ) ) );
- cf2_stack_setReal(
- opStack, 4,
- SUB_INT32( SUB_INT32( v2, v1 ),
- cf2_stack_getReal( opStack, 3 ) ) );
-
- /* add left-sidebearing correction */
- cf2_doStems( font,
- opStack,
- isV ? &vStemHintArray : &hStemHintArray,
- width,
- &haveWidth,
- isV ? decoder->builder.left_bearing->x
- : decoder->builder.left_bearing->y );
-
- if ( decoder->width_only )
- goto exit;
- }
- }
- break;
-
- case cf2_escAND:
- {
- CF2_F16Dot16 arg1;
- CF2_F16Dot16 arg2;
-
-
- FT_TRACE4(( " and\n" ));
-
- arg2 = cf2_stack_popFixed( opStack );
- arg1 = cf2_stack_popFixed( opStack );
-
- cf2_stack_pushInt( opStack, arg1 && arg2 );
- }
- continue; /* do not clear the stack */
-
- case cf2_escOR:
- {
- CF2_F16Dot16 arg1;
- CF2_F16Dot16 arg2;
-
-
- FT_TRACE4(( " or\n" ));
-
- arg2 = cf2_stack_popFixed( opStack );
- arg1 = cf2_stack_popFixed( opStack );
-
- cf2_stack_pushInt( opStack, arg1 || arg2 );
- }
- continue; /* do not clear the stack */
-
- case cf2_escNOT:
- {
- CF2_F16Dot16 arg;
-
-
- FT_TRACE4(( " not\n" ));
-
- arg = cf2_stack_popFixed( opStack );
-
- cf2_stack_pushInt( opStack, !arg );
- }
- continue; /* do not clear the stack */
-
- case cf2_escSEAC:
- if ( !font->isT1 )
- FT_TRACE4(( " unknown op (12, %d)\n", op2 ));
- else
- {
- FT_Error error2;
- CF2_Int bchar_index, achar_index;
- FT_Vector left_bearing, advance;
-
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- T1_Face face = (T1_Face)decoder->builder.face;
-#endif
- CF2_BufferRec component;
- CF2_Fixed dummyWidth;
-
- CF2_Int achar = cf2_stack_popInt( opStack );
- CF2_Int bchar = cf2_stack_popInt( opStack );
-
- FT_Pos ady = cf2_stack_popFixed ( opStack );
- FT_Pos adx = cf2_stack_popFixed ( opStack );
- FT_Pos asb = cf2_stack_popFixed ( opStack );
-
-
- FT_TRACE4(( " seac\n" ));
-
- if ( doingSeac )
- {
- FT_ERROR(( " nested seac\n" ));
- lastError = FT_THROW( Invalid_Glyph_Format );
- goto exit; /* nested seac */
- }
-
- if ( decoder->builder.metrics_only )
- {
- FT_ERROR(( " unexpected seac\n" ));
- lastError = FT_THROW( Invalid_Glyph_Format );
- goto exit; /* unexpected seac */
- }
-
- /* `glyph_names' is set to 0 for CID fonts which do */
- /* not include an encoding. How can we deal with */
- /* these? */
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- if ( decoder->glyph_names == 0 &&
- !face->root.internal->incremental_interface )
-#else
- if ( decoder->glyph_names == 0 )
-#endif /* FT_CONFIG_OPTION_INCREMENTAL */
- {
- FT_ERROR(( "cf2_interpT2CharString:\n" ));
- FT_ERROR(( " (Type 1 seac) glyph names table"
- " not available in this font\n" ));
- lastError = FT_THROW( Invalid_Glyph_Format );
- goto exit;
- }
-
- /* seac weirdness */
- adx += decoder->builder.left_bearing->x;
-
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- if ( face->root.internal->incremental_interface )
- {
- /* the caller must handle the font encoding also */
- bchar_index = bchar;
- achar_index = achar;
- }
- else
-#endif
- {
- bchar_index = t1_lookup_glyph_by_stdcharcode_ps(
- decoder, bchar );
- achar_index = t1_lookup_glyph_by_stdcharcode_ps(
- decoder, achar );
- }
-
- if ( bchar_index < 0 || achar_index < 0 )
- {
- FT_ERROR(( "cf2_interpT2CharString:\n" ));
- FT_ERROR(( " (Type 1 seac) invalid"
- " seac character code arguments\n" ));
- lastError = FT_THROW( Invalid_Glyph_Format );
- goto exit;
- }
-
- /* if we are trying to load a composite glyph, */
- /* do not load the accent character and return */
- /* the array of subglyphs. */
- if ( decoder->builder.no_recurse )
- {
- FT_GlyphSlot glyph = (FT_GlyphSlot)decoder->builder.glyph;
- FT_GlyphLoader loader = glyph->internal->loader;
- FT_SubGlyph subg;
-
-
- /* reallocate subglyph array if necessary */
- error2 = FT_GlyphLoader_CheckSubGlyphs( loader, 2 );
- if ( error2 )
- {
- lastError = error2; /* pass FreeType error through */
- goto exit;
- }
-
- subg = loader->current.subglyphs;
-
- /* subglyph 0 = base character */
- subg->index = bchar_index;
- subg->flags = FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES |
- FT_SUBGLYPH_FLAG_USE_MY_METRICS;
- subg->arg1 = 0;
- subg->arg2 = 0;
- subg++;
-
- /* subglyph 1 = accent character */
- subg->index = achar_index;
- subg->flags = FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES;
- subg->arg1 = (FT_Int)FIXED_TO_INT( adx - asb );
- subg->arg2 = (FT_Int)FIXED_TO_INT( ady );
-
- /* set up remaining glyph fields */
- glyph->num_subglyphs = 2;
- glyph->subglyphs = loader->base.subglyphs;
- glyph->format = FT_GLYPH_FORMAT_COMPOSITE;
-
- loader->current.num_subglyphs = 2;
-
- goto exit;
- }
-
- /* First load `bchar' in builder */
- /* now load the unscaled outline */
-
- /* prepare loader */
- FT_GlyphLoader_Prepare( decoder->builder.loader );
-
- error2 = cf2_getT1SeacComponent( decoder,
- (FT_UInt)bchar_index,
- &component );
- if ( error2 )
- {
- lastError = error2; /* pass FreeType error through */
- goto exit;
- }
-
- /* save the left bearing and width of the SEAC */
- /* glyph as they will be erased by the next load */
-
- left_bearing = *decoder->builder.left_bearing;
- advance = *decoder->builder.advance;
-
- cf2_interpT2CharString( font,
- &component,
- callbacks,
- translation,
- TRUE,
- 0,
- 0,
- &dummyWidth );
- cf2_freeT1SeacComponent( decoder, &component );
-
- /* If the SEAC glyph doesn't have a (H)SBW of its */
- /* own use the values from the base glyph. */
-
- if ( !haveWidth )
- {
- left_bearing = *decoder->builder.left_bearing;
- advance = *decoder->builder.advance;
- }
-
- decoder->builder.left_bearing->x = 0;
- decoder->builder.left_bearing->y = 0;
-
- /* Now load `achar' on top of */
- /* the base outline */
-
- error2 = cf2_getT1SeacComponent( decoder,
- (FT_UInt)achar_index,
- &component );
- if ( error2 )
- {
- lastError = error2; /* pass FreeType error through */
- goto exit;
- }
- cf2_interpT2CharString( font,
- &component,
- callbacks,
- translation,
- TRUE,
- adx - asb,
- ady,
- &dummyWidth );
- cf2_freeT1SeacComponent( decoder, &component );
-
- /* restore the left side bearing and advance width */
- /* of the SEAC glyph or base character (saved above) */
-
- *decoder->builder.left_bearing = left_bearing;
- *decoder->builder.advance = advance;
-
- goto exit;
- }
- break;
-
- case cf2_escSBW:
- if ( !font->isT1 )
- FT_TRACE4(( " unknown op (12, %d)\n", op2 ));
- else
- {
- CF2_Fixed lsb_x, lsb_y;
- PS_Builder* builder;
-
-
- FT_TRACE4(( " sbw" ));
-
- builder = &decoder->builder;
-
- builder->advance->y = cf2_stack_popFixed( opStack );
- builder->advance->x = cf2_stack_popFixed( opStack );
-
- lsb_y = cf2_stack_popFixed( opStack );
- lsb_x = cf2_stack_popFixed( opStack );
-
- builder->left_bearing->x =
- ADD_INT32( builder->left_bearing->x, lsb_x );
- builder->left_bearing->y =
- ADD_INT32( builder->left_bearing->y, lsb_y );
-
- haveWidth = TRUE;
-
- /* the `metrics_only' indicates that we only want */
- /* to compute the glyph's metrics (lsb + advance */
- /* width), not load the rest of it; so exit */
- /* immediately */
- if ( builder->metrics_only )
- goto exit;
-
- if ( initial_map_ready )
- {
- curX = ADD_INT32( curX, lsb_x );
- curY = ADD_INT32( curY, lsb_y );
- }
- }
- break;
-
- case cf2_escABS:
- {
- CF2_F16Dot16 arg;
-
-
- FT_TRACE4(( " abs\n" ));
-
- arg = cf2_stack_popFixed( opStack );
-
- if ( arg < -CF2_FIXED_MAX )
- cf2_stack_pushFixed( opStack, CF2_FIXED_MAX );
- else
- cf2_stack_pushFixed( opStack, FT_ABS( arg ) );
- }
- continue; /* do not clear the stack */
-
- case cf2_escADD:
- {
- CF2_F16Dot16 summand1;
- CF2_F16Dot16 summand2;
-
-
- FT_TRACE4(( " add\n" ));
-
- summand2 = cf2_stack_popFixed( opStack );
- summand1 = cf2_stack_popFixed( opStack );
-
- cf2_stack_pushFixed( opStack,
- ADD_INT32( summand1,
- summand2 ) );
- }
- continue; /* do not clear the stack */
-
- case cf2_escSUB:
- {
- CF2_F16Dot16 minuend;
- CF2_F16Dot16 subtrahend;
-
-
- FT_TRACE4(( " sub\n" ));
-
- subtrahend = cf2_stack_popFixed( opStack );
- minuend = cf2_stack_popFixed( opStack );
-
- cf2_stack_pushFixed( opStack,
- SUB_INT32( minuend, subtrahend ) );
- }
- continue; /* do not clear the stack */
-
- case cf2_escDIV:
- {
- CF2_F16Dot16 dividend;
- CF2_F16Dot16 divisor;
-
-
- FT_TRACE4(( " div\n" ));
-
- if ( font->isT1 && large_int )
- {
- divisor = (CF2_F16Dot16)cf2_stack_popInt( opStack );
- dividend = (CF2_F16Dot16)cf2_stack_popInt( opStack );
-
- large_int = FALSE;
- }
- else
- {
- divisor = cf2_stack_popFixed( opStack );
- dividend = cf2_stack_popFixed( opStack );
- }
-
- cf2_stack_pushFixed( opStack,
- FT_DivFix( dividend, divisor ) );
-
- }
- continue; /* do not clear the stack */
-
- case cf2_escNEG:
- {
- CF2_F16Dot16 arg;
-
-
- FT_TRACE4(( " neg\n" ));
-
- arg = cf2_stack_popFixed( opStack );
-
- if ( arg < -CF2_FIXED_MAX )
- cf2_stack_pushFixed( opStack, CF2_FIXED_MAX );
- else
- cf2_stack_pushFixed( opStack, -arg );
- }
- continue; /* do not clear the stack */
-
- case cf2_escEQ:
- {
- CF2_F16Dot16 arg1;
- CF2_F16Dot16 arg2;
-
-
- FT_TRACE4(( " eq\n" ));
-
- arg2 = cf2_stack_popFixed( opStack );
- arg1 = cf2_stack_popFixed( opStack );
-
- cf2_stack_pushInt( opStack, arg1 == arg2 );
- }
- continue; /* do not clear the stack */
-
- case cf2_escCALLOTHERSUBR:
- if ( !font->isT1 )
- FT_TRACE4(( " unknown op (12, %d)\n", op2 ));
- else
- {
- CF2_Int subr_no;
- CF2_Int arg_cnt;
- CF2_UInt count;
- CF2_UInt opIdx = 0;
-
-
- FT_TRACE4(( " callothersubr\n" ));
-
- subr_no = cf2_stack_popInt( opStack );
- arg_cnt = cf2_stack_popInt( opStack );
-
- /********************************************************
- *
- * remove all operands to callothersubr from the stack
- *
- * for handled othersubrs, where we know the number of
- * arguments, we increase the stack by the value of
- * known_othersubr_result_cnt
- *
- * for unhandled othersubrs the following pops adjust
- * the stack pointer as necessary
- */
-
- count = cf2_stack_count( opStack );
- if ( (CF2_UInt)arg_cnt > count )
- {
- FT_ERROR(( "cf2_interpT2CharString (Type 1 mode):"
- " stack underflow\n" ));
- lastError = FT_THROW( Invalid_Glyph_Format );
- goto exit;
- }
-
- opIdx += count - (CF2_UInt)arg_cnt;
-
- known_othersubr_result_cnt = 0;
- result_cnt = 0;
-
- /* XXX TODO: The checks to `arg_count == <whatever>' */
- /* might not be correct; an othersubr expects a */
- /* certain number of operands on the PostScript stack */
- /* (as opposed to the T1 stack) but it doesn't have to */
- /* put them there by itself; previous othersubrs might */
- /* have left the operands there if they were not */
- /* followed by an appropriate number of pops */
- /* */
- /* On the other hand, Adobe Reader 7.0.8 for Linux */
- /* doesn't accept a font that contains charstrings */
- /* like */
- /* */
- /* 100 200 2 20 callothersubr */
- /* 300 1 20 callothersubr pop */
- /* */
- /* Perhaps this is the reason why BuildCharArray */
- /* exists. */
-
- switch ( subr_no )
- {
- case 0: /* end flex feature */
- if ( arg_cnt != 3 )
- goto Unexpected_OtherSubr;
-
- if ( initial_map_ready &&
- ( !decoder->flex_state ||
- decoder->num_flex_vectors != 7 ) )
- {
- FT_ERROR(( "cf2_interpT2CharString (Type 1 mode):"
- " unexpected flex end\n" ));
- lastError = FT_THROW( Invalid_Glyph_Format );
- goto exit;
- }
-
- /* the two `results' are popped */
- /* by the following setcurrentpoint */
- cf2_stack_pushFixed( opStack, curX );
- cf2_stack_pushFixed( opStack, curY );
- known_othersubr_result_cnt = 2;
- break;
-
- case 1: /* start flex feature */
- if ( arg_cnt != 0 )
- goto Unexpected_OtherSubr;
-
- if ( !initial_map_ready )
- break;
-
- if ( ps_builder_check_points( &decoder->builder, 6 ) )
- goto exit;
-
- decoder->flex_state = 1;
- decoder->num_flex_vectors = 0;
- break;
-
- case 2: /* add flex vectors */
- {
- FT_Int idx;
- FT_Int idx2;
-
-
- if ( arg_cnt != 0 )
- goto Unexpected_OtherSubr;
-
- if ( !initial_map_ready )
- break;
-
- if ( !decoder->flex_state )
- {
- FT_ERROR(( "cf2_interpT2CharString (Type 1 mode):"
- " missing flex start\n" ));
- lastError = FT_THROW( Invalid_Glyph_Format );
- goto exit;
- }
-
- /* note that we should not add a point for */
- /* index 0; this will move our current position */
- /* to the flex point without adding any point */
- /* to the outline */
- idx = decoder->num_flex_vectors++;
- if ( idx > 0 && idx < 7 )
- {
- /* in malformed fonts it is possible to have */
- /* other opcodes in the middle of a flex (which */
- /* don't increase `num_flex_vectors'); we thus */
- /* have to check whether we can add a point */
-
- if ( ps_builder_check_points( &decoder->builder,
- 1 ) )
- {
- lastError = FT_THROW( Invalid_Glyph_Format );
- goto exit;
- }
-
- /* map: 1->2 2->4 3->6 4->2 5->4 6->6 */
- idx2 = ( idx > 3 ? idx - 3 : idx ) * 2;
-
- flexStore[idx2 - 2] = curX;
- flexStore[idx2 - 1] = curY;
-
- if ( idx == 3 || idx == 6 )
- cf2_glyphpath_curveTo( &glyphPath,
- flexStore[0],
- flexStore[1],
- flexStore[2],
- flexStore[3],
- flexStore[4],
- flexStore[5] );
- }
- }
- break;
-
- case 3: /* change hints */
- if ( arg_cnt != 1 )
- goto Unexpected_OtherSubr;
-
- if ( initial_map_ready )
- {
- /* do not clear hints if initial hintmap */
- /* is not ready - we need to collate all */
- cf2_arrstack_clear( &vStemHintArray );
- cf2_arrstack_clear( &hStemHintArray );
-
- cf2_hintmask_init( &hintMask, error );
- hintMask.isValid = FALSE;
- hintMask.isNew = TRUE;
- }
-
- known_othersubr_result_cnt = 1;
- break;
-
- case 12:
- case 13:
- /* counter control hints, clear stack */
- cf2_stack_clear( opStack );
- break;
-
- case 14:
- case 15:
- case 16:
- case 17:
- case 18: /* multiple masters */
- {
- PS_Blend blend = decoder->blend;
- FT_UInt num_points, nn, mm;
- CF2_UInt delta;
- CF2_UInt values;
-
-
- if ( !blend )
- {
- FT_ERROR((
- "cf2_interpT2CharString:"
- " unexpected multiple masters operator\n" ));
- lastError = FT_THROW( Invalid_Glyph_Format );
- goto exit;
- }
-
- num_points = (FT_UInt)subr_no - 13 +
- ( subr_no == 18 );
- if ( arg_cnt != (FT_Int)( num_points *
- blend->num_designs ) )
- {
- FT_ERROR((
- "cf2_interpT2CharString:"
- " incorrect number of multiple masters arguments\n" ));
- lastError = FT_THROW( Invalid_Glyph_Format );
- goto exit;
- }
-
- /* We want to compute */
- /* */
- /* a0*w0 + a1*w1 + ... + ak*wk */
- /* */
- /* but we only have a0, a1-a0, a2-a0, ..., ak-a0. */
- /* */
- /* However, given that w0 + w1 + ... + wk == 1, we */
- /* can rewrite it easily as */
- /* */
- /* a0 + (a1-a0)*w1 + (a2-a0)*w2 + ... + (ak-a0)*wk */
- /* */
- /* where k == num_designs-1. */
- /* */
- /* I guess that's why it's written in this `compact' */
- /* form. */
- /* */
- delta = opIdx + num_points;
- values = opIdx;
- for ( nn = 0; nn < num_points; nn++ )
- {
- CF2_Fixed tmp = cf2_stack_getReal( opStack,
- values );
-
-
- for ( mm = 1; mm < blend->num_designs; mm++ )
- tmp = ADD_INT32( tmp,
- FT_MulFix(
- cf2_stack_getReal( opStack,
- delta++ ),
- blend->weight_vector[mm] ) );
-
- cf2_stack_setReal( opStack, values++, tmp );
- }
- cf2_stack_pop( opStack,
- (CF2_UInt)arg_cnt - num_points );
-
- known_othersubr_result_cnt = (FT_Int)num_points;
- break;
- }
-
- case 19:
- /* <idx> 1 19 callothersubr */
- /* ==> replace elements starting from index */
- /* cvi( <idx> ) of BuildCharArray with */
- /* WeightVector */
- {
- FT_UInt idx;
- PS_Blend blend = decoder->blend;
- FT_UInt len_buildchar = decoder->len_buildchar;
-
-
- if ( arg_cnt != 1 || !blend )
- goto Unexpected_OtherSubr;
-
- idx = (FT_UInt)cf2_stack_popInt( opStack );
-
- if ( len_buildchar < blend->num_designs ||
- len_buildchar - blend->num_designs < idx )
- goto Unexpected_OtherSubr;
-
- if ( decoder->buildchar && blend->weight_vector )
- ft_memcpy( &decoder->buildchar[idx],
- blend->weight_vector,
- blend->num_designs *
- sizeof ( blend->weight_vector[0] ) );
- }
- break;
-
- case 20:
- /* <arg1> <arg2> 2 20 callothersubr pop */
- /* ==> push <arg1> + <arg2> onto T1 stack */
- {
- CF2_F16Dot16 summand1;
- CF2_F16Dot16 summand2;
-
-
- if ( arg_cnt != 2 )
- goto Unexpected_OtherSubr;
-
- summand2 = cf2_stack_popFixed( opStack );
- summand1 = cf2_stack_popFixed( opStack );
-
- cf2_stack_pushFixed( opStack,
- ADD_INT32( summand1,
- summand2 ) );
- known_othersubr_result_cnt = 1;
- }
- break;
-
- case 21:
- /* <arg1> <arg2> 2 21 callothersubr pop */
- /* ==> push <arg1> - <arg2> onto T1 stack */
- {
- CF2_F16Dot16 minuend;
- CF2_F16Dot16 subtrahend;
-
-
- if ( arg_cnt != 2 )
- goto Unexpected_OtherSubr;
-
- subtrahend = cf2_stack_popFixed( opStack );
- minuend = cf2_stack_popFixed( opStack );
-
- cf2_stack_pushFixed( opStack,
- SUB_INT32( minuend,
- subtrahend ) );
- known_othersubr_result_cnt = 1;
- }
- break;
-
- case 22:
- /* <arg1> <arg2> 2 22 callothersubr pop */
- /* ==> push <arg1> * <arg2> onto T1 stack */
- {
- CF2_F16Dot16 factor1;
- CF2_F16Dot16 factor2;
-
-
- if ( arg_cnt != 2 )
- goto Unexpected_OtherSubr;
-
- factor2 = cf2_stack_popFixed( opStack );
- factor1 = cf2_stack_popFixed( opStack );
-
- cf2_stack_pushFixed( opStack,
- FT_MulFix( factor1, factor2 ) );
- known_othersubr_result_cnt = 1;
- }
- break;
-
- case 23:
- /* <arg1> <arg2> 2 23 callothersubr pop */
- /* ==> push <arg1> / <arg2> onto T1 stack */
- {
- CF2_F16Dot16 dividend;
- CF2_F16Dot16 divisor;
-
-
- if ( arg_cnt != 2 )
- goto Unexpected_OtherSubr;
-
- divisor = cf2_stack_popFixed( opStack );
- dividend = cf2_stack_popFixed( opStack );
-
- if ( divisor == 0 )
- goto Unexpected_OtherSubr;
-
- cf2_stack_pushFixed( opStack,
- FT_DivFix( dividend,
- divisor ) );
- known_othersubr_result_cnt = 1;
- }
- break;
-
- case 24:
- /* <val> <idx> 2 24 callothersubr */
- /* ==> set BuildCharArray[cvi( <idx> )] = <val> */
- {
- CF2_UInt idx;
- PS_Blend blend = decoder->blend;
-
-
- if ( arg_cnt != 2 || !blend )
- goto Unexpected_OtherSubr;
-
- idx = (CF2_UInt)cf2_stack_popInt( opStack );
-
- if ( idx >= decoder->len_buildchar )
- goto Unexpected_OtherSubr;
-
- decoder->buildchar[idx] =
- cf2_stack_popFixed( opStack );
- }
- break;
-
- case 25:
- /* <idx> 1 25 callothersubr pop */
- /* ==> push BuildCharArray[cvi( idx )] */
- /* onto T1 stack */
- {
- CF2_UInt idx;
- PS_Blend blend = decoder->blend;
-
-
- if ( arg_cnt != 1 || !blend )
- goto Unexpected_OtherSubr;
-
- idx = (CF2_UInt)cf2_stack_popInt( opStack );
-
- if ( idx >= decoder->len_buildchar )
- goto Unexpected_OtherSubr;
-
- cf2_stack_pushFixed( opStack,
- decoder->buildchar[idx] );
- known_othersubr_result_cnt = 1;
- }
- break;
-
-#if 0
- case 26:
- /* <val> mark <idx> */
- /* ==> set BuildCharArray[cvi( <idx> )] = <val>, */
- /* leave mark on T1 stack */
- /* <val> <idx> */
- /* ==> set BuildCharArray[cvi( <idx> )] = <val> */
- XXX which routine has left its mark on the
- XXX (PostScript) stack?;
- break;
-#endif
-
- case 27:
- /* <res1> <res2> <val1> <val2> 4 27 callothersubr pop */
- /* ==> push <res1> onto T1 stack if <val1> <= <val2>, */
- /* otherwise push <res2> */
- {
- CF2_F16Dot16 arg1;
- CF2_F16Dot16 arg2;
- CF2_F16Dot16 cond1;
- CF2_F16Dot16 cond2;
-
-
- if ( arg_cnt != 4 )
- goto Unexpected_OtherSubr;
-
- cond2 = cf2_stack_popFixed( opStack );
- cond1 = cf2_stack_popFixed( opStack );
- arg2 = cf2_stack_popFixed( opStack );
- arg1 = cf2_stack_popFixed( opStack );
-
- cf2_stack_pushFixed( opStack,
- cond1 <= cond2 ? arg1 : arg2 );
- known_othersubr_result_cnt = 1;
- }
- break;
-
- case 28:
- /* 0 28 callothersubr pop */
- /* ==> push random value from interval [0, 1) */
- /* onto stack */
- {
- CF2_F16Dot16 r;
-
-
- if ( arg_cnt != 0 )
- goto Unexpected_OtherSubr;
-
- /* only use the lower 16 bits of `random' */
- /* to generate a number in the range (0;1] */
- r = (CF2_F16Dot16)
- ( ( decoder->current_subfont->random & 0xFFFF ) + 1 );
-
- decoder->current_subfont->random =
- cff_random( decoder->current_subfont->random );
-
- cf2_stack_pushFixed( opStack, r );
- known_othersubr_result_cnt = 1;
- }
- break;
-
- default:
- if ( arg_cnt >= 0 && subr_no >= 0 )
- {
- FT_Int i;
-
-
- FT_ERROR((
- "cf2_interpT2CharString (Type 1 mode):"
- " unknown othersubr [%d %d], wish me luck\n",
- arg_cnt, subr_no ));
-
- /* store the unused args */
- /* for this unhandled OtherSubr */
-
- if ( arg_cnt > PS_STORAGE_SIZE )
- arg_cnt = PS_STORAGE_SIZE;
- result_cnt = arg_cnt;
-
- for ( i = 1; i <= arg_cnt; i++ )
- results[result_cnt - i] =
- cf2_stack_popFixed( opStack );
-
- break;
- }
- /* fall through */
-
- Unexpected_OtherSubr:
- FT_ERROR(( "cf2_interpT2CharString (Type 1 mode):"
- " invalid othersubr [%d %d]\n",
- arg_cnt, subr_no ));
- lastError = FT_THROW( Invalid_Glyph_Format );
- goto exit;
- }
- }
- continue; /* do not clear the stack */
-
- case cf2_escPOP:
- if ( !font->isT1 )
- FT_TRACE4(( " unknown op (12, %d)\n", op2 ));
- else
- {
- FT_TRACE4(( " pop" ));
-
- if ( known_othersubr_result_cnt > 0 )
- {
- known_othersubr_result_cnt--;
- /* ignore, we pushed the operands ourselves */
- continue;
- }
-
- if ( result_cnt == 0 )
- {
- FT_ERROR(( "cf2_interpT2CharString (Type 1 mode):"
- " no more operands for othersubr\n" ));
- lastError = FT_THROW( Invalid_Glyph_Format );
- goto exit;
- }
-
- result_cnt--;
- cf2_stack_pushFixed( opStack, results[result_cnt] );
- }
- continue; /* do not clear the stack */
-
- case cf2_escDROP:
- FT_TRACE4(( " drop\n" ));
-
- (void)cf2_stack_popFixed( opStack );
- continue; /* do not clear the stack */
-
- case cf2_escPUT:
- {
- CF2_F16Dot16 val;
- CF2_UInt idx;
-
-
- FT_TRACE4(( " put\n" ));
-
- idx = (CF2_UInt)cf2_stack_popInt( opStack );
- val = cf2_stack_popFixed( opStack );
-
- if ( idx < CF2_STORAGE_SIZE )
- storage[idx] = val;
- }
- continue; /* do not clear the stack */
-
- case cf2_escGET:
- {
- CF2_UInt idx;
-
-
- FT_TRACE4(( " get\n" ));
-
- idx = (CF2_UInt)cf2_stack_popInt( opStack );
-
- if ( idx < CF2_STORAGE_SIZE )
- cf2_stack_pushFixed( opStack, storage[idx] );
- }
- continue; /* do not clear the stack */
-
- case cf2_escIFELSE:
- {
- CF2_F16Dot16 arg1;
- CF2_F16Dot16 arg2;
- CF2_F16Dot16 cond1;
- CF2_F16Dot16 cond2;
-
-
- FT_TRACE4(( " ifelse\n" ));
-
- cond2 = cf2_stack_popFixed( opStack );
- cond1 = cf2_stack_popFixed( opStack );
- arg2 = cf2_stack_popFixed( opStack );
- arg1 = cf2_stack_popFixed( opStack );
-
- cf2_stack_pushFixed( opStack,
- cond1 <= cond2 ? arg1 : arg2 );
- }
- continue; /* do not clear the stack */
-
- case cf2_escRANDOM: /* in spec */
- {
- CF2_F16Dot16 r;
-
-
- FT_TRACE4(( " random\n" ));
-
- /* only use the lower 16 bits of `random' */
- /* to generate a number in the range (0;1] */
- r = (CF2_F16Dot16)
- ( ( decoder->current_subfont->random & 0xFFFF ) + 1 );
-
- decoder->current_subfont->random =
- cff_random( decoder->current_subfont->random );
-
- cf2_stack_pushFixed( opStack, r );
- }
- continue; /* do not clear the stack */
-
- case cf2_escMUL:
- {
- CF2_F16Dot16 factor1;
- CF2_F16Dot16 factor2;
-
-
- FT_TRACE4(( " mul\n" ));
-
- factor2 = cf2_stack_popFixed( opStack );
- factor1 = cf2_stack_popFixed( opStack );
-
- cf2_stack_pushFixed( opStack,
- FT_MulFix( factor1, factor2 ) );
- }
- continue; /* do not clear the stack */
-
- case cf2_escSQRT:
- {
- CF2_F16Dot16 arg;
-
-
- FT_TRACE4(( " sqrt\n" ));
-
- arg = cf2_stack_popFixed( opStack );
- if ( arg > 0 )
- arg = (CF2_F16Dot16)FT_SqrtFixed( (FT_UInt32)arg );
- else
- arg = 0;
-
- cf2_stack_pushFixed( opStack, arg );
- }
- continue; /* do not clear the stack */
-
- case cf2_escDUP:
- {
- CF2_F16Dot16 arg;
-
-
- FT_TRACE4(( " dup\n" ));
-
- arg = cf2_stack_popFixed( opStack );
-
- cf2_stack_pushFixed( opStack, arg );
- cf2_stack_pushFixed( opStack, arg );
- }
- continue; /* do not clear the stack */
-
- case cf2_escEXCH:
- {
- CF2_F16Dot16 arg1;
- CF2_F16Dot16 arg2;
-
-
- FT_TRACE4(( " exch\n" ));
-
- arg2 = cf2_stack_popFixed( opStack );
- arg1 = cf2_stack_popFixed( opStack );
-
- cf2_stack_pushFixed( opStack, arg2 );
- cf2_stack_pushFixed( opStack, arg1 );
- }
- continue; /* do not clear the stack */
-
- case cf2_escINDEX:
- {
- CF2_Int idx;
- CF2_UInt size;
-
-
- FT_TRACE4(( " index\n" ));
-
- idx = cf2_stack_popInt( opStack );
- size = cf2_stack_count( opStack );
-
- if ( size > 0 )
- {
- /* for `cf2_stack_getReal', */
- /* index 0 is bottom of stack */
- CF2_UInt gr_idx;
-
-
- if ( idx < 0 )
- gr_idx = size - 1;
- else if ( (CF2_UInt)idx >= size )
- gr_idx = 0;
- else
- gr_idx = size - 1 - (CF2_UInt)idx;
-
- cf2_stack_pushFixed( opStack,
- cf2_stack_getReal( opStack,
- gr_idx ) );
- }
- }
- continue; /* do not clear the stack */
-
- case cf2_escROLL:
- {
- CF2_Int idx;
- CF2_Int count;
-
-
- FT_TRACE4(( " roll\n" ));
-
- idx = cf2_stack_popInt( opStack );
- count = cf2_stack_popInt( opStack );
-
- cf2_stack_roll( opStack, count, idx );
- }
- continue; /* do not clear the stack */
-
- case cf2_escSETCURRENTPT:
- if ( !font->isT1 )
- FT_TRACE4(( " unknown op (12, %d)\n", op2 ));
- else
- {
- FT_TRACE4(( " setcurrentpoint" ));
-
- if ( !initial_map_ready )
- break;
-
- /* From the T1 specification, section 6.4: */
- /* */
- /* The setcurrentpoint command is used only in */
- /* conjunction with results from OtherSubrs */
- /* procedures. */
-
- /* known_othersubr_result_cnt != 0 is already handled */
- /* above. */
-
- /* Note, however, that both Ghostscript and Adobe */
- /* Distiller handle this situation by silently */
- /* ignoring the inappropriate `setcurrentpoint' */
- /* instruction. So we do the same. */
-#if 0
-
- if ( decoder->flex_state != 1 )
- {
- FT_ERROR(( "cf2_interpT2CharString:"
- " unexpected `setcurrentpoint'\n" ));
- goto Syntax_Error;
- }
- else
- ...
-#endif
-
- curY = cf2_stack_popFixed( opStack );
- curX = cf2_stack_popFixed( opStack );
-
- decoder->flex_state = 0;
- }
- break;
-
- } /* end of 2nd switch checking op2 */
- }
- }
- } /* end of 1st switch checking op2 */
- } /* case cf2_cmdESC */
-
- break;
-
- case cf2_cmdHSBW:
- if ( !font->isT1 )
- FT_TRACE4(( " unknown op (%d)\n", op1 ));
- else
- {
- CF2_Fixed lsb_x;
- PS_Builder* builder;
-
-
- FT_TRACE4(( " hsbw\n" ));
-
- builder = &decoder->builder;
-
- builder->advance->x = cf2_stack_popFixed( opStack );
- builder->advance->y = 0;
-
- lsb_x = cf2_stack_popFixed( opStack );
-
- builder->left_bearing->x = ADD_INT32( builder->left_bearing->x,
- lsb_x );
-
- haveWidth = TRUE;
-
- /* the `metrics_only' indicates that we only want to compute */
- /* the glyph's metrics (lsb + advance width), not load the */
- /* rest of it; so exit immediately */
- if ( builder->metrics_only )
- goto exit;
-
- if ( initial_map_ready )
- curX = ADD_INT32( curX, lsb_x );
- }
- break;
-
- case cf2_cmdENDCHAR:
- FT_TRACE4(( " endchar\n" ));
-
- if ( font->isT1 && !initial_map_ready )
- {
- FT_TRACE5(( "cf2_interpT2CharString (Type 1 mode): "
- "Build initial hintmap, rewinding...\n" ));
-
- /* trigger initial hintmap build */
- cf2_glyphpath_moveTo( &glyphPath, curX, curY );
-
- initial_map_ready = TRUE;
-
- /* change hints routine - clear for rewind */
- cf2_arrstack_clear( &vStemHintArray );
- cf2_arrstack_clear( &hStemHintArray );
-
- cf2_hintmask_init( &hintMask, error );
- hintMask.isValid = FALSE;
- hintMask.isNew = TRUE;
-
- /* rewind charstring */
- /* some charstrings use endchar from a final subroutine call */
- /* without returning, detect these and exit to the top level */
- /* charstring */
- while ( charstringIndex > 0 )
- {
- FT_TRACE4(( " return (leaving level %d)\n", charstringIndex ));
-
- /* restore position in previous charstring */
- charstring = (CF2_Buffer)
- cf2_arrstack_getPointer(
- &subrStack,
- (CF2_UInt)--charstringIndex );
- }
- charstring->ptr = charstring->start;
-
- break;
- }
-
- if ( cf2_stack_count( opStack ) == 1 ||
- cf2_stack_count( opStack ) == 5 )
- {
- if ( !haveWidth )
- *width = ADD_INT32( cf2_stack_getReal( opStack, 0 ),
- nominalWidthX );
- }
-
- /* width is defined or default after this */
- haveWidth = TRUE;
-
- if ( decoder->width_only )
- goto exit;
-
- /* close path if still open */
- cf2_glyphpath_closeOpenPath( &glyphPath );
-
- /* disable seac for CFF2 and Type1 */
- /* (charstring ending with args on stack) */
- if ( !font->isCFF2 && !font->isT1 && cf2_stack_count( opStack ) > 1 )
- {
- /* must be either 4 or 5 -- */
- /* this is a (deprecated) implied `seac' operator */
-
- CF2_Int achar;
- CF2_Int bchar;
- CF2_BufferRec component;
- CF2_Fixed dummyWidth; /* ignore component width */
- FT_Error error2;
-
-
- if ( doingSeac )
- {
- lastError = FT_THROW( Invalid_Glyph_Format );
- goto exit; /* nested seac */
- }
-
- achar = cf2_stack_popInt( opStack );
- bchar = cf2_stack_popInt( opStack );
-
- curY = cf2_stack_popFixed( opStack );
- curX = cf2_stack_popFixed( opStack );
-
- error2 = cf2_getSeacComponent( decoder, achar, &component );
- if ( error2 )
- {
- lastError = error2; /* pass FreeType error through */
- goto exit;
- }
- cf2_interpT2CharString( font,
- &component,
- callbacks,
- translation,
- TRUE,
- curX,
- curY,
- &dummyWidth );
- cf2_freeSeacComponent( decoder, &component );
-
- error2 = cf2_getSeacComponent( decoder, bchar, &component );
- if ( error2 )
- {
- lastError = error2; /* pass FreeType error through */
- goto exit;
- }
- cf2_interpT2CharString( font,
- &component,
- callbacks,
- translation,
- TRUE,
- 0,
- 0,
- &dummyWidth );
- cf2_freeSeacComponent( decoder, &component );
- }
- goto exit;
-
- case cf2_cmdCNTRMASK:
- case cf2_cmdHINTMASK:
- /* the final \n in the tracing message gets added in */
- /* `cf2_hintmask_read' (which also traces the mask bytes) */
- FT_TRACE4(( "%s", op1 == cf2_cmdCNTRMASK ? " cntrmask" : " hintmask" ));
-
- /* never add hints after the mask is computed */
- if ( cf2_stack_count( opStack ) > 1 &&
- cf2_hintmask_isValid( &hintMask ) )
- {
- FT_TRACE4(( "cf2_interpT2CharString: invalid hint mask\n" ));
- break;
- }
-
- /* if there are arguments on the stack, there this is an */
- /* implied cf2_cmdVSTEMHM */
- cf2_doStems( font,
- opStack,
- &vStemHintArray,
- width,
- &haveWidth,
- 0 );
-
- if ( decoder->width_only )
- goto exit;
-
- if ( op1 == cf2_cmdHINTMASK )
- {
- /* consume the hint mask bytes which follow the operator */
- cf2_hintmask_read( &hintMask,
- charstring,
- cf2_arrstack_size( &hStemHintArray ) +
- cf2_arrstack_size( &vStemHintArray ) );
- }
- else
- {
- /*
- * Consume the counter mask bytes which follow the operator:
- * Build a temporary hint map, just to place and lock those
- * stems participating in the counter mask. These are most
- * likely the dominant hstems, and are grouped together in a
- * few counter groups, not necessarily in correspondence
- * with the hint groups. This reduces the chances of
- * conflicts between hstems that are initially placed in
- * separate hint groups and then brought together. The
- * positions are copied back to `hStemHintArray', so we can
- * discard `counterMask' and `counterHintMap'.
- *
- */
- CF2_HintMapRec counterHintMap;
- CF2_HintMaskRec counterMask;
-
-
- cf2_hintmap_init( &counterHintMap,
- font,
- &glyphPath.initialHintMap,
- &glyphPath.hintMoves,
- scaleY );
- cf2_hintmask_init( &counterMask, error );
-
- cf2_hintmask_read( &counterMask,
- charstring,
- cf2_arrstack_size( &hStemHintArray ) +
- cf2_arrstack_size( &vStemHintArray ) );
- cf2_hintmap_build( &counterHintMap,
- &hStemHintArray,
- &vStemHintArray,
- &counterMask,
- 0,
- FALSE );
- }
- break;
-
- case cf2_cmdRMOVETO:
- FT_TRACE4(( " rmoveto\n" ));
-
- if ( font->isT1 && !decoder->flex_state && !haveWidth )
- FT_ERROR(( "cf2_interpT2CharString (Type 1 mode):"
- " No width. Use hsbw/sbw as first op\n" ));
-
- if ( cf2_stack_count( opStack ) > 2 && !haveWidth )
- *width = ADD_INT32( cf2_stack_getReal( opStack, 0 ),
- nominalWidthX );
-
- /* width is defined or default after this */
- haveWidth = TRUE;
-
- if ( decoder->width_only )
- goto exit;
-
- curY = ADD_INT32( curY, cf2_stack_popFixed( opStack ) );
- curX = ADD_INT32( curX, cf2_stack_popFixed( opStack ) );
-
- if ( !decoder->flex_state )
- cf2_glyphpath_moveTo( &glyphPath, curX, curY );
-
- break;
-
- case cf2_cmdHMOVETO:
- FT_TRACE4(( " hmoveto\n" ));
-
- if ( font->isT1 && !decoder->flex_state && !haveWidth )
- FT_ERROR(( "cf2_interpT2CharString (Type 1 mode):"
- " No width. Use hsbw/sbw as first op\n" ));
-
- if ( cf2_stack_count( opStack ) > 1 && !haveWidth )
- *width = ADD_INT32( cf2_stack_getReal( opStack, 0 ),
- nominalWidthX );
-
- /* width is defined or default after this */
- haveWidth = TRUE;
-
- if ( decoder->width_only )
- goto exit;
-
- curX = ADD_INT32( curX, cf2_stack_popFixed( opStack ) );
-
- if ( !decoder->flex_state )
- cf2_glyphpath_moveTo( &glyphPath, curX, curY );
-
- break;
-
- case cf2_cmdRLINECURVE:
- {
- CF2_UInt count = cf2_stack_count( opStack );
- CF2_UInt idx = 0;
-
-
- FT_TRACE4(( " rlinecurve\n" ));
-
- while ( idx + 6 < count )
- {
- curX = ADD_INT32( curX, cf2_stack_getReal( opStack,
- idx + 0 ) );
- curY = ADD_INT32( curY, cf2_stack_getReal( opStack,
- idx + 1 ) );
-
- cf2_glyphpath_lineTo( &glyphPath, curX, curY );
- idx += 2;
- }
-
- while ( idx < count )
- {
- CF2_Fixed x1, y1, x2, y2, x3, y3;
-
-
- x1 = ADD_INT32( cf2_stack_getReal( opStack, idx + 0 ), curX );
- y1 = ADD_INT32( cf2_stack_getReal( opStack, idx + 1 ), curY );
- x2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 2 ), x1 );
- y2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 3 ), y1 );
- x3 = ADD_INT32( cf2_stack_getReal( opStack, idx + 4 ), x2 );
- y3 = ADD_INT32( cf2_stack_getReal( opStack, idx + 5 ), y2 );
-
- cf2_glyphpath_curveTo( &glyphPath, x1, y1, x2, y2, x3, y3 );
-
- curX = x3;
- curY = y3;
- idx += 6;
- }
-
- cf2_stack_clear( opStack );
- }
- continue; /* no need to clear stack again */
-
- case cf2_cmdVVCURVETO:
- {
- CF2_UInt count, count1 = cf2_stack_count( opStack );
- CF2_UInt idx = 0;
-
-
- /* if `cf2_stack_count' isn't of the form 4n or 4n+1, */
- /* we enforce it by clearing the second bit */
- /* (and sorting the stack indexing to suit) */
- count = count1 & ~2U;
- idx += count1 - count;
-
- FT_TRACE4(( " vvcurveto\n" ));
-
- while ( idx < count )
- {
- CF2_Fixed x1, y1, x2, y2, x3, y3;
-
-
- if ( ( count - idx ) & 1 )
- {
- x1 = ADD_INT32( cf2_stack_getReal( opStack, idx ), curX );
-
- idx++;
- }
- else
- x1 = curX;
-
- y1 = ADD_INT32( cf2_stack_getReal( opStack, idx + 0 ), curY );
- x2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 1 ), x1 );
- y2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 2 ), y1 );
- x3 = x2;
- y3 = ADD_INT32( cf2_stack_getReal( opStack, idx + 3 ), y2 );
-
- cf2_glyphpath_curveTo( &glyphPath, x1, y1, x2, y2, x3, y3 );
-
- curX = x3;
- curY = y3;
- idx += 4;
- }
-
- cf2_stack_clear( opStack );
- }
- continue; /* no need to clear stack again */
-
- case cf2_cmdHHCURVETO:
- {
- CF2_UInt count, count1 = cf2_stack_count( opStack );
- CF2_UInt idx = 0;
-
-
- /* if `cf2_stack_count' isn't of the form 4n or 4n+1, */
- /* we enforce it by clearing the second bit */
- /* (and sorting the stack indexing to suit) */
- count = count1 & ~2U;
- idx += count1 - count;
-
- FT_TRACE4(( " hhcurveto\n" ));
-
- while ( idx < count )
- {
- CF2_Fixed x1, y1, x2, y2, x3, y3;
-
-
- if ( ( count - idx ) & 1 )
- {
- y1 = ADD_INT32( cf2_stack_getReal( opStack, idx ), curY );
-
- idx++;
- }
- else
- y1 = curY;
-
- x1 = ADD_INT32( cf2_stack_getReal( opStack, idx + 0 ), curX );
- x2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 1 ), x1 );
- y2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 2 ), y1 );
- x3 = ADD_INT32( cf2_stack_getReal( opStack, idx + 3 ), x2 );
- y3 = y2;
-
- cf2_glyphpath_curveTo( &glyphPath, x1, y1, x2, y2, x3, y3 );
-
- curX = x3;
- curY = y3;
- idx += 4;
- }
-
- cf2_stack_clear( opStack );
- }
- continue; /* no need to clear stack again */
-
- case cf2_cmdVHCURVETO:
- case cf2_cmdHVCURVETO:
- {
- CF2_UInt count, count1 = cf2_stack_count( opStack );
- CF2_UInt idx = 0;
-
- FT_Bool alternate = FT_BOOL( op1 == cf2_cmdHVCURVETO );
-
-
- /* if `cf2_stack_count' isn't of the form 8n, 8n+1, */
- /* 8n+4, or 8n+5, we enforce it by clearing the */
- /* second bit */
- /* (and sorting the stack indexing to suit) */
- count = count1 & ~2U;
- idx += count1 - count;
-
- FT_TRACE4(( "%s\n", alternate ? " hvcurveto" : " vhcurveto" ));
-
- while ( idx < count )
- {
- CF2_Fixed x1, x2, x3, y1, y2, y3;
-
-
- if ( alternate )
- {
- x1 = ADD_INT32( cf2_stack_getReal( opStack, idx + 0 ), curX );
- y1 = curY;
- x2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 1 ), x1 );
- y2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 2 ), y1 );
- y3 = ADD_INT32( cf2_stack_getReal( opStack, idx + 3 ), y2 );
-
- if ( count - idx == 5 )
- {
- x3 = ADD_INT32( cf2_stack_getReal( opStack, idx + 4 ), x2 );
-
- idx++;
- }
- else
- x3 = x2;
-
- alternate = FALSE;
- }
- else
- {
- x1 = curX;
- y1 = ADD_INT32( cf2_stack_getReal( opStack, idx + 0 ), curY );
- x2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 1 ), x1 );
- y2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 2 ), y1 );
- x3 = ADD_INT32( cf2_stack_getReal( opStack, idx + 3 ), x2 );
-
- if ( count - idx == 5 )
- {
- y3 = ADD_INT32( cf2_stack_getReal( opStack, idx + 4 ), y2 );
-
- idx++;
- }
- else
- y3 = y2;
-
- alternate = TRUE;
- }
-
- cf2_glyphpath_curveTo( &glyphPath, x1, y1, x2, y2, x3, y3 );
-
- curX = x3;
- curY = y3;
- idx += 4;
- }
-
- cf2_stack_clear( opStack );
- }
- continue; /* no need to clear stack again */
-
- case cf2_cmdEXTENDEDNMBR:
- {
- CF2_Int v;
-
- CF2_Int byte1 = cf2_buf_readByte( charstring );
- CF2_Int byte2 = cf2_buf_readByte( charstring );
-
-
- v = (FT_Short)( ( byte1 << 8 ) |
- byte2 );
-
- FT_TRACE4(( " %d", v ));
-
- cf2_stack_pushInt( opStack, v );
- }
- continue;
-
- default:
- /* numbers */
- {
- if ( /* op1 >= 32 && */ op1 <= 246 )
- {
- CF2_Int v;
-
-
- v = op1 - 139;
-
- FT_TRACE4(( " %d", v ));
-
- /* -107 .. 107 */
- cf2_stack_pushInt( opStack, v );
- }
-
- else if ( /* op1 >= 247 && */ op1 <= 250 )
- {
- CF2_Int v;
-
-
- v = op1;
- v -= 247;
- v *= 256;
- v += cf2_buf_readByte( charstring );
- v += 108;
-
- FT_TRACE4(( " %d", v ));
-
- /* 108 .. 1131 */
- cf2_stack_pushInt( opStack, v );
- }
-
- else if ( /* op1 >= 251 && */ op1 <= 254 )
- {
- CF2_Int v;
-
-
- v = op1;
- v -= 251;
- v *= 256;
- v += cf2_buf_readByte( charstring );
- v = -v - 108;
-
- FT_TRACE4(( " %d", v ));
-
- /* -1131 .. -108 */
- cf2_stack_pushInt( opStack, v );
- }
-
- else /* op1 == 255 */
- {
- CF2_Fixed v;
-
- FT_UInt32 byte1 = (FT_UInt32)cf2_buf_readByte( charstring );
- FT_UInt32 byte2 = (FT_UInt32)cf2_buf_readByte( charstring );
- FT_UInt32 byte3 = (FT_UInt32)cf2_buf_readByte( charstring );
- FT_UInt32 byte4 = (FT_UInt32)cf2_buf_readByte( charstring );
-
-
- v = (CF2_Fixed)( ( byte1 << 24 ) |
- ( byte2 << 16 ) |
- ( byte3 << 8 ) |
- byte4 );
-
- /*
- * For Type 1:
- *
- * According to the specification, values > 32000 or < -32000
- * must be followed by a `div' operator to make the result be
- * in the range [-32000;32000]. We expect that the second
- * argument of `div' is not a large number. Additionally, we
- * don't handle stuff like `<large1> <large2> <num> div <num>
- * div' or <large1> <large2> <num> div div'. This is probably
- * not allowed anyway.
- *
- * <large> <num> <num>+ div is not checked but should not be
- * allowed as the large value remains untouched.
- *
- */
- if ( font->isT1 )
- {
- if ( v > 32000 || v < -32000 )
- {
- if ( large_int )
- FT_ERROR(( "cf2_interpT2CharString (Type 1 mode):"
- " no `div' after large integer\n" ));
- else
- large_int = TRUE;
- }
-
- FT_TRACE4(( " %d", v ));
-
- cf2_stack_pushInt( opStack, (CF2_Int)v );
- }
- else
- {
- FT_TRACE4(( " %.5fF", v / 65536.0 ));
-
- cf2_stack_pushFixed( opStack, v );
- }
- }
- }
- continue; /* don't clear stack */
-
- } /* end of switch statement checking `op1' */
-
- cf2_stack_clear( opStack );
-
- } /* end of main interpreter loop */
-
- /* we get here if the charstring ends without cf2_cmdENDCHAR */
- FT_TRACE4(( "cf2_interpT2CharString:"
- " charstring ends without ENDCHAR\n" ));
-
- exit:
- /* check whether last error seen is also the first one */
- cf2_setError( error, lastError );
-
- if ( *error )
- FT_TRACE4(( "charstring error %d\n", *error ));
-
- /* free resources from objects we've used */
- cf2_glyphpath_finalize( &glyphPath );
- cf2_arrstack_finalize( &vStemHintArray );
- cf2_arrstack_finalize( &hStemHintArray );
- cf2_arrstack_finalize( &subrStack );
- cf2_stack_free( opStack );
-
- FT_TRACE4(( "\n" ));
-
- return;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/psaux/psintrp.h b/contrib/libs/freetype/src/psaux/psintrp.h
deleted file mode 100644
index d8b9342ecb..0000000000
--- a/contrib/libs/freetype/src/psaux/psintrp.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************************
- *
- * psintrp.h
- *
- * Adobe's CFF Interpreter (specification).
- *
- * Copyright 2007-2013 Adobe Systems Incorporated.
- *
- * This software, and all works of authorship, whether in source or
- * object code form as indicated by the copyright notice(s) included
- * herein (collectively, the "Work") is made available, and may only be
- * used, modified, and distributed under the FreeType Project License,
- * LICENSE.TXT. Additionally, subject to the terms and conditions of the
- * FreeType Project License, each contributor to the Work hereby grants
- * to any individual or legal entity exercising permissions granted by
- * the FreeType Project License and this section (hereafter, "You" or
- * "Your") a perpetual, worldwide, non-exclusive, no-charge,
- * royalty-free, irrevocable (except as stated in this section) patent
- * license to make, have made, use, offer to sell, sell, import, and
- * otherwise transfer the Work, where such license applies only to those
- * patent claims licensable by such contributor that are necessarily
- * infringed by their contribution(s) alone or by combination of their
- * contribution(s) with the Work to which such contribution(s) was
- * submitted. If You institute patent litigation against any entity
- * (including a cross-claim or counterclaim in a lawsuit) alleging that
- * the Work or a contribution incorporated within the Work constitutes
- * direct or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate as of
- * the date such litigation is filed.
- *
- * By using, modifying, or distributing the Work you indicate that you
- * have read and understood the terms and conditions of the
- * FreeType Project License as well as those provided in this section,
- * and you accept them fully.
- *
- */
-
-
-#ifndef PSINTRP_H_
-#define PSINTRP_H_
-
-
-#include "psft.h"
-#include "pshints.h"
-
-
-FT_BEGIN_HEADER
-
-
- FT_LOCAL( void )
- cf2_hintmask_init( CF2_HintMask hintmask,
- FT_Error* error );
- FT_LOCAL( FT_Bool )
- cf2_hintmask_isValid( const CF2_HintMask hintmask );
- FT_LOCAL( FT_Bool )
- cf2_hintmask_isNew( const CF2_HintMask hintmask );
- FT_LOCAL( void )
- cf2_hintmask_setNew( CF2_HintMask hintmask,
- FT_Bool val );
- FT_LOCAL( FT_Byte* )
- cf2_hintmask_getMaskPtr( CF2_HintMask hintmask );
- FT_LOCAL( void )
- cf2_hintmask_setAll( CF2_HintMask hintmask,
- size_t bitCount );
-
- FT_LOCAL( void )
- cf2_interpT2CharString( CF2_Font font,
- const CF2_Buffer buf,
- CF2_OutlineCallbacks callbacks,
- const FT_Vector* translation,
- FT_Bool doingSeac,
- CF2_Fixed curX,
- CF2_Fixed curY,
- CF2_Fixed* width );
-
-
-FT_END_HEADER
-
-
-#endif /* PSINTRP_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/psaux/psobjs.c b/contrib/libs/freetype/src/psaux/psobjs.c
deleted file mode 100644
index eca465f009..0000000000
--- a/contrib/libs/freetype/src/psaux/psobjs.c
+++ /dev/null
@@ -1,2560 +0,0 @@
-/****************************************************************************
- *
- * psobjs.c
- *
- * Auxiliary functions for PostScript fonts (body).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/psaux.h>
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftcalc.h>
-#include <freetype/ftdriver.h>
-
-#include "psobjs.h"
-#include "psconv.h"
-#include "psft.h"
-
-#include "psauxerr.h"
-#include "psauxmod.h"
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT psobjs
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** PS_TABLE *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- /**************************************************************************
- *
- * @Function:
- * ps_table_new
- *
- * @Description:
- * Initializes a PS_Table.
- *
- * @InOut:
- * table ::
- * The address of the target table.
- *
- * @Input:
- * count ::
- * The table size = the maximum number of elements.
- *
- * memory ::
- * The memory object to use for all subsequent
- * reallocations.
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
- FT_LOCAL_DEF( FT_Error )
- ps_table_new( PS_Table table,
- FT_Int count,
- FT_Memory memory )
- {
- FT_Error error;
-
-
- table->memory = memory;
- if ( FT_NEW_ARRAY( table->elements, count ) ||
- FT_NEW_ARRAY( table->lengths, count ) )
- goto Exit;
-
- table->max_elems = count;
- table->init = 0xDEADBEEFUL;
- table->block = NULL;
- table->capacity = 0;
- table->cursor = 0;
-
- *(PS_Table_FuncsRec*)&table->funcs = ps_table_funcs;
-
- Exit:
- if ( error )
- FT_FREE( table->elements );
-
- return error;
- }
-
-
- static FT_Error
- ps_table_realloc( PS_Table table,
- FT_Offset new_size )
- {
- FT_Memory memory = table->memory;
- FT_Byte* old_base = table->block;
- FT_Error error;
-
-
- /* (re)allocate the base block */
- if ( FT_REALLOC( table->block, table->capacity, new_size ) )
- return error;
-
- /* rebase offsets if necessary */
- if ( old_base && table->block != old_base )
- {
- FT_Byte** offset = table->elements;
- FT_Byte** limit = offset + table->max_elems;
-
-
- for ( ; offset < limit; offset++ )
- {
- if ( *offset )
- *offset = table->block + ( *offset - old_base );
- }
- }
-
- table->capacity = new_size;
-
- return FT_Err_Ok;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * ps_table_add
- *
- * @Description:
- * Adds an object to a PS_Table, possibly growing its memory block.
- *
- * @InOut:
- * table ::
- * The target table.
- *
- * @Input:
- * idx ::
- * The index of the object in the table.
- *
- * object ::
- * The address of the object to copy in memory.
- *
- * length ::
- * The length in bytes of the source object.
- *
- * @Return:
- * FreeType error code. 0 means success. An error is returned if a
- * reallocation fails.
- */
- FT_LOCAL_DEF( FT_Error )
- ps_table_add( PS_Table table,
- FT_Int idx,
- const void* object,
- FT_UInt length )
- {
- if ( idx < 0 || idx >= table->max_elems )
- {
- FT_ERROR(( "ps_table_add: invalid index\n" ));
- return FT_THROW( Invalid_Argument );
- }
-
- /* grow the base block if needed */
- if ( table->cursor + length > table->capacity )
- {
- FT_Error error;
- FT_Offset new_size = table->capacity;
- FT_PtrDist in_offset;
-
-
- in_offset = (FT_Byte*)object - table->block;
- if ( in_offset < 0 || (FT_Offset)in_offset >= table->capacity )
- in_offset = -1;
-
- while ( new_size < table->cursor + length )
- {
- /* increase size by 25% and round up to the nearest multiple
- of 1024 */
- new_size += ( new_size >> 2 ) + 1;
- new_size = FT_PAD_CEIL( new_size, 1024 );
- }
-
- error = ps_table_realloc( table, new_size );
- if ( error )
- return error;
-
- if ( in_offset >= 0 )
- object = table->block + in_offset;
- }
-
- /* add the object to the base block and adjust offset */
- table->elements[idx] = FT_OFFSET( table->block, table->cursor );
- table->lengths [idx] = length;
- /* length == 0 also implies a NULL destination, so skip the copy call */
- if ( length > 0 )
- FT_MEM_COPY( table->block + table->cursor, object, length );
-
- table->cursor += length;
- return FT_Err_Ok;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * ps_table_done
- *
- * @Description:
- * Finalizes a PS_TableRec (i.e., reallocate it to its current
- * cursor).
- *
- * @InOut:
- * table ::
- * The target table.
- */
- FT_LOCAL_DEF( void )
- ps_table_done( PS_Table table )
- {
- /* no problem if shrinking fails */
- ps_table_realloc( table, table->cursor );
- }
-
-
- FT_LOCAL_DEF( void )
- ps_table_release( PS_Table table )
- {
- FT_Memory memory = table->memory;
-
-
- if ( table->init == 0xDEADBEEFUL )
- {
- FT_FREE( table->block );
- FT_FREE( table->elements );
- FT_FREE( table->lengths );
- table->init = 0;
- }
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** T1 PARSER *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /* first character must be already part of the comment */
-
- static void
- skip_comment( FT_Byte* *acur,
- FT_Byte* limit )
- {
- FT_Byte* cur = *acur;
-
-
- while ( cur < limit )
- {
- if ( IS_PS_NEWLINE( *cur ) )
- break;
- cur++;
- }
-
- *acur = cur;
- }
-
-
- static void
- skip_spaces( FT_Byte* *acur,
- FT_Byte* limit )
- {
- FT_Byte* cur = *acur;
-
-
- while ( cur < limit )
- {
- if ( !IS_PS_SPACE( *cur ) )
- {
- if ( *cur == '%' )
- /* According to the PLRM, a comment is equal to a space. */
- skip_comment( &cur, limit );
- else
- break;
- }
- cur++;
- }
-
- *acur = cur;
- }
-
-
-#define IS_OCTAL_DIGIT( c ) ( '0' <= (c) && (c) <= '7' )
-
-
- /* first character must be `('; */
- /* *acur is positioned at the character after the closing `)' */
-
- static FT_Error
- skip_literal_string( FT_Byte* *acur,
- FT_Byte* limit )
- {
- FT_Byte* cur = *acur;
- FT_Int embed = 0;
- FT_Error error = FT_ERR( Invalid_File_Format );
- unsigned int i;
-
-
- while ( cur < limit )
- {
- FT_Byte c = *cur;
-
-
- cur++;
-
- if ( c == '\\' )
- {
- /* Red Book 3rd ed., section `Literal Text Strings', p. 29: */
- /* A backslash can introduce three different types */
- /* of escape sequences: */
- /* - a special escaped char like \r, \n, etc. */
- /* - a one-, two-, or three-digit octal number */
- /* - none of the above in which case the backslash is ignored */
-
- if ( cur == limit )
- /* error (or to be ignored?) */
- break;
-
- switch ( *cur )
- {
- /* skip `special' escape */
- case 'n':
- case 'r':
- case 't':
- case 'b':
- case 'f':
- case '\\':
- case '(':
- case ')':
- cur++;
- break;
-
- default:
- /* skip octal escape or ignore backslash */
- for ( i = 0; i < 3 && cur < limit; i++ )
- {
- if ( !IS_OCTAL_DIGIT( *cur ) )
- break;
-
- cur++;
- }
- }
- }
- else if ( c == '(' )
- embed++;
- else if ( c == ')' )
- {
- embed--;
- if ( embed == 0 )
- {
- error = FT_Err_Ok;
- break;
- }
- }
- }
-
- *acur = cur;
-
- return error;
- }
-
-
- /* first character must be `<' */
-
- static FT_Error
- skip_string( FT_Byte* *acur,
- FT_Byte* limit )
- {
- FT_Byte* cur = *acur;
- FT_Error err = FT_Err_Ok;
-
-
- while ( ++cur < limit )
- {
- /* All whitespace characters are ignored. */
- skip_spaces( &cur, limit );
- if ( cur >= limit )
- break;
-
- if ( !IS_PS_XDIGIT( *cur ) )
- break;
- }
-
- if ( cur < limit && *cur != '>' )
- {
- FT_ERROR(( "skip_string: missing closing delimiter `>'\n" ));
- err = FT_THROW( Invalid_File_Format );
- }
- else
- cur++;
-
- *acur = cur;
- return err;
- }
-
-
- /* first character must be the opening brace that */
- /* starts the procedure */
-
- /* NB: [ and ] need not match: */
- /* `/foo {[} def' is a valid PostScript fragment, */
- /* even within a Type1 font */
-
- static FT_Error
- skip_procedure( FT_Byte* *acur,
- FT_Byte* limit )
- {
- FT_Byte* cur;
- FT_Int embed = 0;
- FT_Error error = FT_Err_Ok;
-
-
- FT_ASSERT( **acur == '{' );
-
- for ( cur = *acur; cur < limit && error == FT_Err_Ok; cur++ )
- {
- switch ( *cur )
- {
- case '{':
- embed++;
- break;
-
- case '}':
- embed--;
- if ( embed == 0 )
- {
- cur++;
- goto end;
- }
- break;
-
- case '(':
- error = skip_literal_string( &cur, limit );
- break;
-
- case '<':
- error = skip_string( &cur, limit );
- break;
-
- case '%':
- skip_comment( &cur, limit );
- break;
- }
- }
-
- end:
- if ( embed != 0 )
- error = FT_THROW( Invalid_File_Format );
-
- *acur = cur;
-
- return error;
- }
-
-
- /************************************************************************
- *
- * All exported parsing routines handle leading whitespace and stop at
- * the first character which isn't part of the just handled token.
- *
- */
-
-
- FT_LOCAL_DEF( void )
- ps_parser_skip_PS_token( PS_Parser parser )
- {
- /* Note: PostScript allows any non-delimiting, non-whitespace */
- /* character in a name (PS Ref Manual, 3rd ed, p31). */
- /* PostScript delimiters are (, ), <, >, [, ], {, }, /, and %. */
-
- FT_Byte* cur = parser->cursor;
- FT_Byte* limit = parser->limit;
- FT_Error error = FT_Err_Ok;
-
-
- skip_spaces( &cur, limit ); /* this also skips comments */
- if ( cur >= limit )
- goto Exit;
-
- /* self-delimiting, single-character tokens */
- if ( *cur == '[' || *cur == ']' )
- {
- cur++;
- goto Exit;
- }
-
- /* skip balanced expressions (procedures and strings) */
-
- if ( *cur == '{' ) /* {...} */
- {
- error = skip_procedure( &cur, limit );
- goto Exit;
- }
-
- if ( *cur == '(' ) /* (...) */
- {
- error = skip_literal_string( &cur, limit );
- goto Exit;
- }
-
- if ( *cur == '<' ) /* <...> */
- {
- if ( cur + 1 < limit && *( cur + 1 ) == '<' ) /* << */
- {
- cur++;
- cur++;
- }
- else
- error = skip_string( &cur, limit );
-
- goto Exit;
- }
-
- if ( *cur == '>' )
- {
- cur++;
- if ( cur >= limit || *cur != '>' ) /* >> */
- {
- FT_ERROR(( "ps_parser_skip_PS_token:"
- " unexpected closing delimiter `>'\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
- cur++;
- goto Exit;
- }
-
- if ( *cur == '/' )
- cur++;
-
- /* anything else */
- while ( cur < limit )
- {
- /* *cur might be invalid (e.g., ')' or '}'), but this */
- /* is handled by the test `cur == parser->cursor' below */
- if ( IS_PS_DELIM( *cur ) )
- break;
-
- cur++;
- }
-
- Exit:
- if ( cur < limit && cur == parser->cursor )
- {
- FT_ERROR(( "ps_parser_skip_PS_token:"
- " current token is `%c' which is self-delimiting\n",
- *cur ));
- FT_ERROR(( " "
- " but invalid at this point\n" ));
-
- error = FT_THROW( Invalid_File_Format );
- }
-
- if ( cur > limit )
- cur = limit;
-
- parser->error = error;
- parser->cursor = cur;
- }
-
-
- FT_LOCAL_DEF( void )
- ps_parser_skip_spaces( PS_Parser parser )
- {
- skip_spaces( &parser->cursor, parser->limit );
- }
-
-
- /* `token' here means either something between balanced delimiters */
- /* or the next token; the delimiters are not removed. */
-
- FT_LOCAL_DEF( void )
- ps_parser_to_token( PS_Parser parser,
- T1_Token token )
- {
- FT_Byte* cur;
- FT_Byte* limit;
- FT_Int embed;
-
-
- token->type = T1_TOKEN_TYPE_NONE;
- token->start = NULL;
- token->limit = NULL;
-
- /* first of all, skip leading whitespace */
- ps_parser_skip_spaces( parser );
-
- cur = parser->cursor;
- limit = parser->limit;
-
- if ( cur >= limit )
- return;
-
- switch ( *cur )
- {
- /************* check for literal string *****************/
- case '(':
- token->type = T1_TOKEN_TYPE_STRING;
- token->start = cur;
-
- if ( skip_literal_string( &cur, limit ) == FT_Err_Ok )
- token->limit = cur;
- break;
-
- /************* check for programs/array *****************/
- case '{':
- token->type = T1_TOKEN_TYPE_ARRAY;
- token->start = cur;
-
- if ( skip_procedure( &cur, limit ) == FT_Err_Ok )
- token->limit = cur;
- break;
-
- /************* check for table/array ********************/
- /* XXX: in theory we should also look for "<<" */
- /* since this is semantically equivalent to "["; */
- /* in practice it doesn't matter (?) */
- case '[':
- token->type = T1_TOKEN_TYPE_ARRAY;
- embed = 1;
- token->start = cur++;
-
- /* we need this to catch `[ ]' */
- parser->cursor = cur;
- ps_parser_skip_spaces( parser );
- cur = parser->cursor;
-
- while ( cur < limit && !parser->error )
- {
- /* XXX: this is wrong because it does not */
- /* skip comments, procedures, and strings */
- if ( *cur == '[' )
- embed++;
- else if ( *cur == ']' )
- {
- embed--;
- if ( embed <= 0 )
- {
- token->limit = ++cur;
- break;
- }
- }
-
- parser->cursor = cur;
- ps_parser_skip_PS_token( parser );
- /* we need this to catch `[XXX ]' */
- ps_parser_skip_spaces ( parser );
- cur = parser->cursor;
- }
- break;
-
- /* ************ otherwise, it is any token **************/
- default:
- token->start = cur;
- token->type = ( *cur == '/' ) ? T1_TOKEN_TYPE_KEY : T1_TOKEN_TYPE_ANY;
- ps_parser_skip_PS_token( parser );
- cur = parser->cursor;
- if ( !parser->error )
- token->limit = cur;
- }
-
- if ( !token->limit )
- {
- token->start = NULL;
- token->type = T1_TOKEN_TYPE_NONE;
- }
-
- parser->cursor = cur;
- }
-
-
- /* NB: `tokens' can be NULL if we only want to count */
- /* the number of array elements */
-
- FT_LOCAL_DEF( void )
- ps_parser_to_token_array( PS_Parser parser,
- T1_Token tokens,
- FT_UInt max_tokens,
- FT_Int* pnum_tokens )
- {
- T1_TokenRec master;
-
-
- *pnum_tokens = -1;
-
- /* this also handles leading whitespace */
- ps_parser_to_token( parser, &master );
-
- if ( master.type == T1_TOKEN_TYPE_ARRAY )
- {
- FT_Byte* old_cursor = parser->cursor;
- FT_Byte* old_limit = parser->limit;
- T1_Token cur = tokens;
- T1_Token limit = cur + max_tokens;
-
-
- /* don't include outermost delimiters */
- parser->cursor = master.start + 1;
- parser->limit = master.limit - 1;
-
- while ( parser->cursor < parser->limit )
- {
- T1_TokenRec token;
-
-
- ps_parser_to_token( parser, &token );
- if ( !token.type )
- break;
-
- if ( tokens && cur < limit )
- *cur = token;
-
- cur++;
- }
-
- *pnum_tokens = (FT_Int)( cur - tokens );
-
- parser->cursor = old_cursor;
- parser->limit = old_limit;
- }
- }
-
-
- /* first character must be a delimiter or a part of a number */
- /* NB: `coords' can be NULL if we just want to skip the */
- /* array; in this case we ignore `max_coords' */
-
- static FT_Int
- ps_tocoordarray( FT_Byte* *acur,
- FT_Byte* limit,
- FT_Int max_coords,
- FT_Short* coords )
- {
- FT_Byte* cur = *acur;
- FT_Int count = 0;
- FT_Byte c, ender;
-
-
- if ( cur >= limit )
- goto Exit;
-
- /* check for the beginning of an array; otherwise, only one number */
- /* will be read */
- c = *cur;
- ender = 0;
-
- if ( c == '[' )
- ender = ']';
- else if ( c == '{' )
- ender = '}';
-
- if ( ender )
- cur++;
-
- /* now, read the coordinates */
- while ( cur < limit )
- {
- FT_Short dummy;
- FT_Byte* old_cur;
-
-
- /* skip whitespace in front of data */
- skip_spaces( &cur, limit );
- if ( cur >= limit )
- goto Exit;
-
- if ( *cur == ender )
- {
- cur++;
- break;
- }
-
- old_cur = cur;
-
- if ( coords && count >= max_coords )
- break;
-
- /* call PS_Conv_ToFixed() even if coords == NULL */
- /* to properly parse number at `cur' */
- *( coords ? &coords[count] : &dummy ) =
- (FT_Short)( PS_Conv_ToFixed( &cur, limit, 0 ) >> 16 );
-
- if ( old_cur == cur )
- {
- count = -1;
- goto Exit;
- }
- else
- count++;
-
- if ( !ender )
- break;
- }
-
- Exit:
- *acur = cur;
- return count;
- }
-
-
- /* first character must be a delimiter or a part of a number */
- /* NB: `values' can be NULL if we just want to skip the */
- /* array; in this case we ignore `max_values' */
- /* */
- /* return number of successfully parsed values */
-
- static FT_Int
- ps_tofixedarray( FT_Byte* *acur,
- FT_Byte* limit,
- FT_Int max_values,
- FT_Fixed* values,
- FT_Int power_ten )
- {
- FT_Byte* cur = *acur;
- FT_Int count = 0;
- FT_Byte c, ender;
-
-
- if ( cur >= limit )
- goto Exit;
-
- /* Check for the beginning of an array. Otherwise, only one number */
- /* will be read. */
- c = *cur;
- ender = 0;
-
- if ( c == '[' )
- ender = ']';
- else if ( c == '{' )
- ender = '}';
-
- if ( ender )
- cur++;
-
- /* now, read the values */
- while ( cur < limit )
- {
- FT_Fixed dummy;
- FT_Byte* old_cur;
-
-
- /* skip whitespace in front of data */
- skip_spaces( &cur, limit );
- if ( cur >= limit )
- goto Exit;
-
- if ( *cur == ender )
- {
- cur++;
- break;
- }
-
- old_cur = cur;
-
- if ( values && count >= max_values )
- break;
-
- /* call PS_Conv_ToFixed() even if coords == NULL */
- /* to properly parse number at `cur' */
- *( values ? &values[count] : &dummy ) =
- PS_Conv_ToFixed( &cur, limit, power_ten );
-
- if ( old_cur == cur )
- {
- count = -1;
- goto Exit;
- }
- else
- count++;
-
- if ( !ender )
- break;
- }
-
- Exit:
- *acur = cur;
- return count;
- }
-
-
-#if 0
-
- static FT_String*
- ps_tostring( FT_Byte** cursor,
- FT_Byte* limit,
- FT_Memory memory )
- {
- FT_Byte* cur = *cursor;
- FT_UInt len = 0;
- FT_Int count;
- FT_String* result;
- FT_Error error;
-
-
- /* XXX: some stupid fonts have a `Notice' or `Copyright' string */
- /* that simply doesn't begin with an opening parenthesis, even */
- /* though they have a closing one! E.g. "amuncial.pfb" */
- /* */
- /* We must deal with these ill-fated cases there. Note that */
- /* these fonts didn't work with the old Type 1 driver as the */
- /* notice/copyright was not recognized as a valid string token */
- /* and made the old token parser commit errors. */
-
- while ( cur < limit && ( *cur == ' ' || *cur == '\t' ) )
- cur++;
- if ( cur + 1 >= limit )
- return 0;
-
- if ( *cur == '(' )
- cur++; /* skip the opening parenthesis, if there is one */
-
- *cursor = cur;
- count = 0;
-
- /* then, count its length */
- for ( ; cur < limit; cur++ )
- {
- if ( *cur == '(' )
- count++;
-
- else if ( *cur == ')' )
- {
- count--;
- if ( count < 0 )
- break;
- }
- }
-
- len = (FT_UInt)( cur - *cursor );
- if ( cur >= limit || FT_QALLOC( result, len + 1 ) )
- return 0;
-
- /* now copy the string */
- FT_MEM_COPY( result, *cursor, len );
- result[len] = '\0';
- *cursor = cur;
- return result;
- }
-
-#endif /* 0 */
-
-
- static int
- ps_tobool( FT_Byte* *acur,
- FT_Byte* limit )
- {
- FT_Byte* cur = *acur;
- FT_Bool result = 0;
-
-
- /* return 1 if we find `true', 0 otherwise */
- if ( cur + 3 < limit &&
- cur[0] == 't' &&
- cur[1] == 'r' &&
- cur[2] == 'u' &&
- cur[3] == 'e' )
- {
- result = 1;
- cur += 5;
- }
- else if ( cur + 4 < limit &&
- cur[0] == 'f' &&
- cur[1] == 'a' &&
- cur[2] == 'l' &&
- cur[3] == 's' &&
- cur[4] == 'e' )
- {
- result = 0;
- cur += 6;
- }
-
- *acur = cur;
- return result;
- }
-
-
- /* load a simple field (i.e. non-table) into the current list of objects */
-
- FT_LOCAL_DEF( FT_Error )
- ps_parser_load_field( PS_Parser parser,
- const T1_Field field,
- void** objects,
- FT_UInt max_objects,
- FT_ULong* pflags )
- {
- T1_TokenRec token;
- FT_Byte* cur;
- FT_Byte* limit;
- FT_UInt count;
- FT_UInt idx;
- FT_Error error;
- T1_FieldType type;
-
-
- /* this also skips leading whitespace */
- ps_parser_to_token( parser, &token );
- if ( !token.type )
- goto Fail;
-
- count = 1;
- idx = 0;
- cur = token.start;
- limit = token.limit;
-
- type = field->type;
-
- /* we must detect arrays in /FontBBox */
- if ( type == T1_FIELD_TYPE_BBOX )
- {
- T1_TokenRec token2;
- FT_Byte* old_cur = parser->cursor;
- FT_Byte* old_limit = parser->limit;
-
-
- /* don't include delimiters */
- parser->cursor = token.start + 1;
- parser->limit = token.limit - 1;
-
- ps_parser_to_token( parser, &token2 );
- parser->cursor = old_cur;
- parser->limit = old_limit;
-
- if ( token2.type == T1_TOKEN_TYPE_ARRAY )
- {
- type = T1_FIELD_TYPE_MM_BBOX;
- goto FieldArray;
- }
- }
- else if ( token.type == T1_TOKEN_TYPE_ARRAY )
- {
- count = max_objects;
-
- FieldArray:
- /* if this is an array and we have no blend, an error occurs */
- if ( max_objects == 0 )
- goto Fail;
-
- idx = 1;
-
- /* don't include delimiters */
- cur++;
- limit--;
- }
-
- for ( ; count > 0; count--, idx++ )
- {
- FT_Byte* q = (FT_Byte*)objects[idx] + field->offset;
- FT_Long val;
-
-
- skip_spaces( &cur, limit );
-
- switch ( type )
- {
- case T1_FIELD_TYPE_BOOL:
- val = ps_tobool( &cur, limit );
- FT_TRACE4(( " %s", val ? "true" : "false" ));
- goto Store_Integer;
-
- case T1_FIELD_TYPE_FIXED:
- val = PS_Conv_ToFixed( &cur, limit, 0 );
- FT_TRACE4(( " %f", (double)val / 65536 ));
- goto Store_Integer;
-
- case T1_FIELD_TYPE_FIXED_1000:
- val = PS_Conv_ToFixed( &cur, limit, 3 );
- FT_TRACE4(( " %f", (double)val / 65536 / 1000 ));
- goto Store_Integer;
-
- case T1_FIELD_TYPE_INTEGER:
- val = PS_Conv_ToInt( &cur, limit );
- FT_TRACE4(( " %ld", val ));
- /* fall through */
-
- Store_Integer:
- switch ( field->size )
- {
- case (8 / FT_CHAR_BIT):
- *(FT_Byte*)q = (FT_Byte)val;
- break;
-
- case (16 / FT_CHAR_BIT):
- *(FT_UShort*)q = (FT_UShort)val;
- break;
-
- case (32 / FT_CHAR_BIT):
- *(FT_UInt32*)q = (FT_UInt32)val;
- break;
-
- default: /* for 64-bit systems */
- *(FT_Long*)q = val;
- }
- break;
-
- case T1_FIELD_TYPE_STRING:
- case T1_FIELD_TYPE_KEY:
- {
- FT_Memory memory = parser->memory;
- FT_UInt len = (FT_UInt)( limit - cur );
- FT_String* string = NULL;
-
-
- if ( cur >= limit )
- break;
-
- /* we allow both a string or a name */
- /* for cases like /FontName (foo) def */
- if ( token.type == T1_TOKEN_TYPE_KEY )
- {
- /* don't include leading `/' */
- len--;
- cur++;
- }
- else if ( token.type == T1_TOKEN_TYPE_STRING )
- {
- /* don't include delimiting parentheses */
- /* XXX we don't handle <<...>> here */
- /* XXX should we convert octal escapes? */
- /* if so, what encoding should we use? */
- cur++;
- len -= 2;
- }
- else
- {
- FT_ERROR(( "ps_parser_load_field:"
- " expected a name or string\n" ));
- FT_ERROR(( " "
- " but found token of type %d instead\n",
- token.type ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- /* for this to work (FT_String**)q must have been */
- /* initialized to NULL */
- if ( *(FT_String**)q )
- {
- FT_TRACE0(( "ps_parser_load_field: overwriting field %s\n",
- field->ident ));
- FT_FREE( *(FT_String**)q );
- }
-
- if ( FT_QALLOC( string, len + 1 ) )
- goto Exit;
-
- FT_MEM_COPY( string, cur, len );
- string[len] = 0;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( token.type == T1_TOKEN_TYPE_STRING )
- FT_TRACE4(( " (%s)", string ));
- else
- FT_TRACE4(( " /%s", string ));
-#endif
-
- *(FT_String**)q = string;
- }
- break;
-
- case T1_FIELD_TYPE_BBOX:
- {
- FT_Fixed temp[4];
- FT_BBox* bbox = (FT_BBox*)q;
- FT_Int result;
-
-
- result = ps_tofixedarray( &cur, limit, 4, temp, 0 );
-
- if ( result < 4 )
- {
- FT_ERROR(( "ps_parser_load_field:"
- " expected four integers in bounding box\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- bbox->xMin = FT_RoundFix( temp[0] );
- bbox->yMin = FT_RoundFix( temp[1] );
- bbox->xMax = FT_RoundFix( temp[2] );
- bbox->yMax = FT_RoundFix( temp[3] );
-
- FT_TRACE4(( " [%ld %ld %ld %ld]",
- bbox->xMin / 65536,
- bbox->yMin / 65536,
- bbox->xMax / 65536,
- bbox->yMax / 65536 ));
- }
- break;
-
- case T1_FIELD_TYPE_MM_BBOX:
- {
- FT_Memory memory = parser->memory;
- FT_Fixed* temp = NULL;
- FT_Int result;
- FT_UInt i;
-
-
- if ( FT_QNEW_ARRAY( temp, max_objects * 4 ) )
- goto Exit;
-
- for ( i = 0; i < 4; i++ )
- {
- result = ps_tofixedarray( &cur, limit, (FT_Int)max_objects,
- temp + i * max_objects, 0 );
- if ( result < 0 || (FT_UInt)result < max_objects )
- {
- FT_ERROR(( "ps_parser_load_field:"
- " expected %d integer%s in the %s subarray\n",
- max_objects, max_objects > 1 ? "s" : "",
- i == 0 ? "first"
- : ( i == 1 ? "second"
- : ( i == 2 ? "third"
- : "fourth" ) ) ));
- FT_ERROR(( " "
- " of /FontBBox in the /Blend dictionary\n" ));
- error = FT_THROW( Invalid_File_Format );
-
- FT_FREE( temp );
- goto Exit;
- }
-
- skip_spaces( &cur, limit );
- }
-
- FT_TRACE4(( " [" ));
- for ( i = 0; i < max_objects; i++ )
- {
- FT_BBox* bbox = (FT_BBox*)objects[i];
-
-
- bbox->xMin = FT_RoundFix( temp[i ] );
- bbox->yMin = FT_RoundFix( temp[i + max_objects] );
- bbox->xMax = FT_RoundFix( temp[i + 2 * max_objects] );
- bbox->yMax = FT_RoundFix( temp[i + 3 * max_objects] );
-
- FT_TRACE4(( " [%ld %ld %ld %ld]",
- bbox->xMin / 65536,
- bbox->yMin / 65536,
- bbox->xMax / 65536,
- bbox->yMax / 65536 ));
- }
- FT_TRACE4(( "]" ));
-
- FT_FREE( temp );
- }
- break;
-
- default:
- /* an error occurred */
- goto Fail;
- }
- }
-
-#if 0 /* obsolete -- keep for reference */
- if ( pflags )
- *pflags |= 1L << field->flag_bit;
-#else
- FT_UNUSED( pflags );
-#endif
-
- error = FT_Err_Ok;
-
- Exit:
- return error;
-
- Fail:
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
-
-#define T1_MAX_TABLE_ELEMENTS 32
-
-
- FT_LOCAL_DEF( FT_Error )
- ps_parser_load_field_table( PS_Parser parser,
- const T1_Field field,
- void** objects,
- FT_UInt max_objects,
- FT_ULong* pflags )
- {
- T1_TokenRec elements[T1_MAX_TABLE_ELEMENTS];
- T1_Token token;
- FT_Int num_elements;
- FT_Error error = FT_Err_Ok;
- FT_Byte* old_cursor;
- FT_Byte* old_limit;
- T1_FieldRec fieldrec = *(T1_Field)field;
-
-
- fieldrec.type = T1_FIELD_TYPE_INTEGER;
- if ( field->type == T1_FIELD_TYPE_FIXED_ARRAY ||
- field->type == T1_FIELD_TYPE_BBOX )
- fieldrec.type = T1_FIELD_TYPE_FIXED;
-
- ps_parser_to_token_array( parser, elements,
- T1_MAX_TABLE_ELEMENTS, &num_elements );
- if ( num_elements < 0 )
- {
- error = FT_ERR( Ignore );
- goto Exit;
- }
- if ( (FT_UInt)num_elements > field->array_max )
- num_elements = (FT_Int)field->array_max;
-
- old_cursor = parser->cursor;
- old_limit = parser->limit;
-
- /* we store the elements count if necessary; */
- /* we further assume that `count_offset' can't be zero */
- if ( field->type != T1_FIELD_TYPE_BBOX && field->count_offset != 0 )
- *(FT_Byte*)( (FT_Byte*)objects[0] + field->count_offset ) =
- (FT_Byte)num_elements;
-
- FT_TRACE4(( " [" ));
-
- /* we now load each element, adjusting the field.offset on each one */
- token = elements;
- for ( ; num_elements > 0; num_elements--, token++ )
- {
- parser->cursor = token->start;
- parser->limit = token->limit;
-
- error = ps_parser_load_field( parser,
- &fieldrec,
- objects,
- max_objects,
- 0 );
- if ( error )
- break;
-
- fieldrec.offset += fieldrec.size;
- }
-
- FT_TRACE4(( "]" ));
-
-#if 0 /* obsolete -- keep for reference */
- if ( pflags )
- *pflags |= 1L << field->flag_bit;
-#else
- FT_UNUSED( pflags );
-#endif
-
- parser->cursor = old_cursor;
- parser->limit = old_limit;
-
- Exit:
- return error;
- }
-
-
- FT_LOCAL_DEF( FT_Long )
- ps_parser_to_int( PS_Parser parser )
- {
- ps_parser_skip_spaces( parser );
- return PS_Conv_ToInt( &parser->cursor, parser->limit );
- }
-
-
- /* first character must be `<' if `delimiters' is non-zero */
-
- FT_LOCAL_DEF( FT_Error )
- ps_parser_to_bytes( PS_Parser parser,
- FT_Byte* bytes,
- FT_Offset max_bytes,
- FT_ULong* pnum_bytes,
- FT_Bool delimiters )
- {
- FT_Error error = FT_Err_Ok;
- FT_Byte* cur;
-
-
- ps_parser_skip_spaces( parser );
- cur = parser->cursor;
-
- if ( cur >= parser->limit )
- goto Exit;
-
- if ( delimiters )
- {
- if ( *cur != '<' )
- {
- FT_ERROR(( "ps_parser_to_bytes: Missing starting delimiter `<'\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- cur++;
- }
-
- *pnum_bytes = PS_Conv_ASCIIHexDecode( &cur,
- parser->limit,
- bytes,
- max_bytes );
-
- parser->cursor = cur;
-
- if ( delimiters )
- {
- if ( cur < parser->limit && *cur != '>' )
- {
- FT_ERROR(( "ps_parser_to_bytes: Missing closing delimiter `>'\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- parser->cursor++;
- }
-
- Exit:
- return error;
- }
-
-
- FT_LOCAL_DEF( FT_Fixed )
- ps_parser_to_fixed( PS_Parser parser,
- FT_Int power_ten )
- {
- ps_parser_skip_spaces( parser );
- return PS_Conv_ToFixed( &parser->cursor, parser->limit, power_ten );
- }
-
-
- FT_LOCAL_DEF( FT_Int )
- ps_parser_to_coord_array( PS_Parser parser,
- FT_Int max_coords,
- FT_Short* coords )
- {
- ps_parser_skip_spaces( parser );
- return ps_tocoordarray( &parser->cursor, parser->limit,
- max_coords, coords );
- }
-
-
- FT_LOCAL_DEF( FT_Int )
- ps_parser_to_fixed_array( PS_Parser parser,
- FT_Int max_values,
- FT_Fixed* values,
- FT_Int power_ten )
- {
- ps_parser_skip_spaces( parser );
- return ps_tofixedarray( &parser->cursor, parser->limit,
- max_values, values, power_ten );
- }
-
-
-#if 0
-
- FT_LOCAL_DEF( FT_String* )
- T1_ToString( PS_Parser parser )
- {
- return ps_tostring( &parser->cursor, parser->limit, parser->memory );
- }
-
-
- FT_LOCAL_DEF( FT_Bool )
- T1_ToBool( PS_Parser parser )
- {
- return ps_tobool( &parser->cursor, parser->limit );
- }
-
-#endif /* 0 */
-
-
- FT_LOCAL_DEF( void )
- ps_parser_init( PS_Parser parser,
- FT_Byte* base,
- FT_Byte* limit,
- FT_Memory memory )
- {
- parser->error = FT_Err_Ok;
- parser->base = base;
- parser->limit = limit;
- parser->cursor = base;
- parser->memory = memory;
- parser->funcs = ps_parser_funcs;
- }
-
-
- FT_LOCAL_DEF( void )
- ps_parser_done( PS_Parser parser )
- {
- FT_UNUSED( parser );
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** T1 BUILDER *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- /**************************************************************************
- *
- * @Function:
- * t1_builder_init
- *
- * @Description:
- * Initializes a given glyph builder.
- *
- * @InOut:
- * builder ::
- * A pointer to the glyph builder to initialize.
- *
- * @Input:
- * face ::
- * The current face object.
- *
- * size ::
- * The current size object.
- *
- * glyph ::
- * The current glyph object.
- *
- * hinting ::
- * Whether hinting should be applied.
- */
- FT_LOCAL_DEF( void )
- t1_builder_init( T1_Builder builder,
- FT_Face face,
- FT_Size size,
- FT_GlyphSlot glyph,
- FT_Bool hinting )
- {
- builder->parse_state = T1_Parse_Start;
- builder->load_points = 1;
-
- builder->face = face;
- builder->glyph = glyph;
- builder->memory = face->memory;
-
- if ( glyph )
- {
- FT_GlyphLoader loader = glyph->internal->loader;
-
-
- builder->loader = loader;
- builder->base = &loader->base.outline;
- builder->current = &loader->current.outline;
- FT_GlyphLoader_Rewind( loader );
-
- builder->hints_globals = size->internal->module_data;
- builder->hints_funcs = NULL;
-
- if ( hinting )
- builder->hints_funcs = glyph->internal->glyph_hints;
- }
-
- builder->pos_x = 0;
- builder->pos_y = 0;
-
- builder->left_bearing.x = 0;
- builder->left_bearing.y = 0;
- builder->advance.x = 0;
- builder->advance.y = 0;
-
- builder->funcs = t1_builder_funcs;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * t1_builder_done
- *
- * @Description:
- * Finalizes a given glyph builder. Its contents can still be used
- * after the call, but the function saves important information
- * within the corresponding glyph slot.
- *
- * @Input:
- * builder ::
- * A pointer to the glyph builder to finalize.
- */
- FT_LOCAL_DEF( void )
- t1_builder_done( T1_Builder builder )
- {
- FT_GlyphSlot glyph = builder->glyph;
-
-
- if ( glyph )
- glyph->outline = *builder->base;
- }
-
-
- /* check that there is enough space for `count' more points */
- FT_LOCAL_DEF( FT_Error )
- t1_builder_check_points( T1_Builder builder,
- FT_Int count )
- {
- return FT_GLYPHLOADER_CHECK_POINTS( builder->loader, count, 0 );
- }
-
-
- /* add a new point, do not check space */
- FT_LOCAL_DEF( void )
- t1_builder_add_point( T1_Builder builder,
- FT_Pos x,
- FT_Pos y,
- FT_Byte flag )
- {
- FT_Outline* outline = builder->current;
-
-
- if ( builder->load_points )
- {
- FT_Vector* point = outline->points + outline->n_points;
- FT_Byte* control = outline->tags + outline->n_points;
-
-
- point->x = FIXED_TO_INT( x );
- point->y = FIXED_TO_INT( y );
- *control = (FT_Byte)( flag ? FT_CURVE_TAG_ON : FT_CURVE_TAG_CUBIC );
- }
- outline->n_points++;
- }
-
-
- /* check space for a new on-curve point, then add it */
- FT_LOCAL_DEF( FT_Error )
- t1_builder_add_point1( T1_Builder builder,
- FT_Pos x,
- FT_Pos y )
- {
- FT_Error error;
-
-
- error = t1_builder_check_points( builder, 1 );
- if ( !error )
- t1_builder_add_point( builder, x, y, 1 );
-
- return error;
- }
-
-
- /* check space for a new contour, then add it */
- FT_LOCAL_DEF( FT_Error )
- t1_builder_add_contour( T1_Builder builder )
- {
- FT_Outline* outline = builder->current;
- FT_Error error;
-
-
- /* this might happen in invalid fonts */
- if ( !outline )
- {
- FT_ERROR(( "t1_builder_add_contour: no outline to add points to\n" ));
- return FT_THROW( Invalid_File_Format );
- }
-
- if ( !builder->load_points )
- {
- outline->n_contours++;
- return FT_Err_Ok;
- }
-
- error = FT_GLYPHLOADER_CHECK_POINTS( builder->loader, 0, 1 );
- if ( !error )
- {
- if ( outline->n_contours > 0 )
- outline->contours[outline->n_contours - 1] = outline->n_points - 1;
-
- outline->n_contours++;
- }
-
- return error;
- }
-
-
- /* if a path was begun, add its first on-curve point */
- FT_LOCAL_DEF( FT_Error )
- t1_builder_start_point( T1_Builder builder,
- FT_Pos x,
- FT_Pos y )
- {
- FT_Error error = FT_ERR( Invalid_File_Format );
-
-
- /* test whether we are building a new contour */
-
- if ( builder->parse_state == T1_Parse_Have_Path )
- error = FT_Err_Ok;
- else
- {
- builder->parse_state = T1_Parse_Have_Path;
- error = t1_builder_add_contour( builder );
- if ( !error )
- error = t1_builder_add_point1( builder, x, y );
- }
-
- return error;
- }
-
-
- /* close the current contour */
- FT_LOCAL_DEF( void )
- t1_builder_close_contour( T1_Builder builder )
- {
- FT_Outline* outline = builder->current;
- FT_Int first;
-
-
- if ( !outline )
- return;
-
- first = outline->n_contours <= 1
- ? 0 : outline->contours[outline->n_contours - 2] + 1;
-
- /* in malformed fonts it can happen that a contour was started */
- /* but no points were added */
- if ( outline->n_contours && first == outline->n_points )
- {
- outline->n_contours--;
- return;
- }
-
- /* We must not include the last point in the path if it */
- /* is located on the first point. */
- if ( outline->n_points > 1 )
- {
- FT_Vector* p1 = outline->points + first;
- FT_Vector* p2 = outline->points + outline->n_points - 1;
- FT_Byte* control = outline->tags + outline->n_points - 1;
-
-
- /* `delete' last point only if it coincides with the first */
- /* point and it is not a control point (which can happen). */
- if ( p1->x == p2->x && p1->y == p2->y )
- if ( *control == FT_CURVE_TAG_ON )
- outline->n_points--;
- }
-
- if ( outline->n_contours > 0 )
- {
- /* Don't add contours only consisting of one point, i.e., */
- /* check whether the first and the last point is the same. */
- if ( first == outline->n_points - 1 )
- {
- outline->n_contours--;
- outline->n_points--;
- }
- else
- outline->contours[outline->n_contours - 1] = outline->n_points - 1;
- }
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** CFF BUILDER *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /**************************************************************************
- *
- * @Function:
- * cff_builder_init
- *
- * @Description:
- * Initializes a given glyph builder.
- *
- * @InOut:
- * builder ::
- * A pointer to the glyph builder to initialize.
- *
- * @Input:
- * face ::
- * The current face object.
- *
- * size ::
- * The current size object.
- *
- * glyph ::
- * The current glyph object.
- *
- * hinting ::
- * Whether hinting is active.
- */
- FT_LOCAL_DEF( void )
- cff_builder_init( CFF_Builder* builder,
- TT_Face face,
- CFF_Size size,
- CFF_GlyphSlot glyph,
- FT_Bool hinting )
- {
- builder->path_begun = 0;
- builder->load_points = 1;
-
- builder->face = face;
- builder->glyph = glyph;
- builder->memory = face->root.memory;
-
- if ( glyph )
- {
- FT_GlyphLoader loader = glyph->root.internal->loader;
-
-
- builder->loader = loader;
- builder->base = &loader->base.outline;
- builder->current = &loader->current.outline;
- FT_GlyphLoader_Rewind( loader );
-
- builder->hints_globals = NULL;
- builder->hints_funcs = NULL;
-
- if ( hinting && size )
- {
- FT_Size ftsize = FT_SIZE( size );
- CFF_Internal internal = (CFF_Internal)ftsize->internal->module_data;
-
- if ( internal )
- {
- builder->hints_globals = (void *)internal->topfont;
- builder->hints_funcs = glyph->root.internal->glyph_hints;
- }
- }
- }
-
- builder->pos_x = 0;
- builder->pos_y = 0;
-
- builder->left_bearing.x = 0;
- builder->left_bearing.y = 0;
- builder->advance.x = 0;
- builder->advance.y = 0;
-
- builder->funcs = cff_builder_funcs;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * cff_builder_done
- *
- * @Description:
- * Finalizes a given glyph builder. Its contents can still be used
- * after the call, but the function saves important information
- * within the corresponding glyph slot.
- *
- * @Input:
- * builder ::
- * A pointer to the glyph builder to finalize.
- */
- FT_LOCAL_DEF( void )
- cff_builder_done( CFF_Builder* builder )
- {
- CFF_GlyphSlot glyph = builder->glyph;
-
-
- if ( glyph )
- glyph->root.outline = *builder->base;
- }
-
-
- /* check that there is enough space for `count' more points */
- FT_LOCAL_DEF( FT_Error )
- cff_check_points( CFF_Builder* builder,
- FT_Int count )
- {
- return FT_GLYPHLOADER_CHECK_POINTS( builder->loader, count, 0 );
- }
-
-
- /* add a new point, do not check space */
- FT_LOCAL_DEF( void )
- cff_builder_add_point( CFF_Builder* builder,
- FT_Pos x,
- FT_Pos y,
- FT_Byte flag )
- {
- FT_Outline* outline = builder->current;
-
-
- if ( builder->load_points )
- {
- FT_Vector* point = outline->points + outline->n_points;
- FT_Byte* control = outline->tags + outline->n_points;
-
-#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
- PS_Driver driver = (PS_Driver)FT_FACE_DRIVER( builder->face );
-
-
- if ( driver->hinting_engine == FT_HINTING_FREETYPE )
- {
- point->x = x >> 16;
- point->y = y >> 16;
- }
- else
-#endif
- {
- /* cf2_decoder_parse_charstrings uses 16.16 coordinates */
- point->x = x >> 10;
- point->y = y >> 10;
- }
- *control = (FT_Byte)( flag ? FT_CURVE_TAG_ON : FT_CURVE_TAG_CUBIC );
- }
-
- outline->n_points++;
- }
-
-
- /* check space for a new on-curve point, then add it */
- FT_LOCAL_DEF( FT_Error )
- cff_builder_add_point1( CFF_Builder* builder,
- FT_Pos x,
- FT_Pos y )
- {
- FT_Error error;
-
-
- error = cff_check_points( builder, 1 );
- if ( !error )
- cff_builder_add_point( builder, x, y, 1 );
-
- return error;
- }
-
-
- /* check space for a new contour, then add it */
- FT_LOCAL_DEF( FT_Error )
- cff_builder_add_contour( CFF_Builder* builder )
- {
- FT_Outline* outline = builder->current;
- FT_Error error;
-
-
- if ( !builder->load_points )
- {
- outline->n_contours++;
- return FT_Err_Ok;
- }
-
- error = FT_GLYPHLOADER_CHECK_POINTS( builder->loader, 0, 1 );
- if ( !error )
- {
- if ( outline->n_contours > 0 )
- outline->contours[outline->n_contours - 1] = outline->n_points - 1;
-
- outline->n_contours++;
- }
-
- return error;
- }
-
-
- /* if a path was begun, add its first on-curve point */
- FT_LOCAL_DEF( FT_Error )
- cff_builder_start_point( CFF_Builder* builder,
- FT_Pos x,
- FT_Pos y )
- {
- FT_Error error = FT_Err_Ok;
-
-
- /* test whether we are building a new contour */
- if ( !builder->path_begun )
- {
- builder->path_begun = 1;
- error = cff_builder_add_contour( builder );
- if ( !error )
- error = cff_builder_add_point1( builder, x, y );
- }
-
- return error;
- }
-
-
- /* close the current contour */
- FT_LOCAL_DEF( void )
- cff_builder_close_contour( CFF_Builder* builder )
- {
- FT_Outline* outline = builder->current;
- FT_Int first;
-
-
- if ( !outline )
- return;
-
- first = outline->n_contours <= 1
- ? 0 : outline->contours[outline->n_contours - 2] + 1;
-
- /* in malformed fonts it can happen that a contour was started */
- /* but no points were added */
- if ( outline->n_contours && first == outline->n_points )
- {
- outline->n_contours--;
- return;
- }
-
- /* We must not include the last point in the path if it */
- /* is located on the first point. */
- if ( outline->n_points > 1 )
- {
- FT_Vector* p1 = outline->points + first;
- FT_Vector* p2 = outline->points + outline->n_points - 1;
- FT_Byte* control = outline->tags + outline->n_points - 1;
-
-
- /* `delete' last point only if it coincides with the first */
- /* point and if it is not a control point (which can happen). */
- if ( p1->x == p2->x && p1->y == p2->y )
- if ( *control == FT_CURVE_TAG_ON )
- outline->n_points--;
- }
-
- if ( outline->n_contours > 0 )
- {
- /* Don't add contours only consisting of one point, i.e., */
- /* check whether begin point and last point are the same. */
- if ( first == outline->n_points - 1 )
- {
- outline->n_contours--;
- outline->n_points--;
- }
- else
- outline->contours[outline->n_contours - 1] = outline->n_points - 1;
- }
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** PS BUILDER *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- /**************************************************************************
- *
- * @Function:
- * ps_builder_init
- *
- * @Description:
- * Initializes a given glyph builder.
- *
- * @InOut:
- * builder ::
- * A pointer to the glyph builder to initialize.
- *
- * @Input:
- * face ::
- * The current face object.
- *
- * size ::
- * The current size object.
- *
- * glyph ::
- * The current glyph object.
- *
- * hinting ::
- * Whether hinting should be applied.
- */
- FT_LOCAL_DEF( void )
- ps_builder_init( PS_Builder* ps_builder,
- void* builder,
- FT_Bool is_t1 )
- {
- FT_ZERO( ps_builder );
-
- if ( is_t1 )
- {
- T1_Builder t1builder = (T1_Builder)builder;
-
-
- ps_builder->memory = t1builder->memory;
- ps_builder->face = (FT_Face)t1builder->face;
- ps_builder->glyph = (CFF_GlyphSlot)t1builder->glyph;
- ps_builder->loader = t1builder->loader;
- ps_builder->base = t1builder->base;
- ps_builder->current = t1builder->current;
-
- ps_builder->pos_x = &t1builder->pos_x;
- ps_builder->pos_y = &t1builder->pos_y;
-
- ps_builder->left_bearing = &t1builder->left_bearing;
- ps_builder->advance = &t1builder->advance;
-
- ps_builder->bbox = &t1builder->bbox;
- ps_builder->path_begun = 0;
- ps_builder->load_points = t1builder->load_points;
- ps_builder->no_recurse = t1builder->no_recurse;
-
- ps_builder->metrics_only = t1builder->metrics_only;
- }
- else
- {
- CFF_Builder* cffbuilder = (CFF_Builder*)builder;
-
-
- ps_builder->memory = cffbuilder->memory;
- ps_builder->face = (FT_Face)cffbuilder->face;
- ps_builder->glyph = cffbuilder->glyph;
- ps_builder->loader = cffbuilder->loader;
- ps_builder->base = cffbuilder->base;
- ps_builder->current = cffbuilder->current;
-
- ps_builder->pos_x = &cffbuilder->pos_x;
- ps_builder->pos_y = &cffbuilder->pos_y;
-
- ps_builder->left_bearing = &cffbuilder->left_bearing;
- ps_builder->advance = &cffbuilder->advance;
-
- ps_builder->bbox = &cffbuilder->bbox;
- ps_builder->path_begun = cffbuilder->path_begun;
- ps_builder->load_points = cffbuilder->load_points;
- ps_builder->no_recurse = cffbuilder->no_recurse;
-
- ps_builder->metrics_only = cffbuilder->metrics_only;
- }
-
- ps_builder->is_t1 = is_t1;
- ps_builder->funcs = ps_builder_funcs;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * ps_builder_done
- *
- * @Description:
- * Finalizes a given glyph builder. Its contents can still be used
- * after the call, but the function saves important information
- * within the corresponding glyph slot.
- *
- * @Input:
- * builder ::
- * A pointer to the glyph builder to finalize.
- */
- FT_LOCAL_DEF( void )
- ps_builder_done( PS_Builder* builder )
- {
- CFF_GlyphSlot glyph = builder->glyph;
-
-
- if ( glyph )
- glyph->root.outline = *builder->base;
- }
-
-
- /* check that there is enough space for `count' more points */
- FT_LOCAL_DEF( FT_Error )
- ps_builder_check_points( PS_Builder* builder,
- FT_Int count )
- {
- return FT_GLYPHLOADER_CHECK_POINTS( builder->loader, count, 0 );
- }
-
-
- /* add a new point, do not check space */
- FT_LOCAL_DEF( void )
- ps_builder_add_point( PS_Builder* builder,
- FT_Pos x,
- FT_Pos y,
- FT_Byte flag )
- {
- FT_Outline* outline = builder->current;
-
-
- if ( builder->load_points )
- {
- FT_Vector* point = outline->points + outline->n_points;
- FT_Byte* control = outline->tags + outline->n_points;
-
-#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
- PS_Driver driver = (PS_Driver)FT_FACE_DRIVER( builder->face );
-
-
- if ( !builder->is_t1 &&
- driver->hinting_engine == FT_HINTING_FREETYPE )
- {
- point->x = x >> 16;
- point->y = y >> 16;
- }
- else
-#endif
-#ifdef T1_CONFIG_OPTION_OLD_ENGINE
-#ifndef CFF_CONFIG_OPTION_OLD_ENGINE
- PS_Driver driver = (PS_Driver)FT_FACE_DRIVER( builder->face );
-#endif
- if ( builder->is_t1 &&
- driver->hinting_engine == FT_HINTING_FREETYPE )
- {
- point->x = FIXED_TO_INT( x );
- point->y = FIXED_TO_INT( y );
- }
- else
-#endif
- {
- /* cf2_decoder_parse_charstrings uses 16.16 coordinates */
- point->x = x >> 10;
- point->y = y >> 10;
- }
- *control = (FT_Byte)( flag ? FT_CURVE_TAG_ON : FT_CURVE_TAG_CUBIC );
- }
- outline->n_points++;
- }
-
-
- /* check space for a new on-curve point, then add it */
- FT_LOCAL_DEF( FT_Error )
- ps_builder_add_point1( PS_Builder* builder,
- FT_Pos x,
- FT_Pos y )
- {
- FT_Error error;
-
-
- error = ps_builder_check_points( builder, 1 );
- if ( !error )
- ps_builder_add_point( builder, x, y, 1 );
-
- return error;
- }
-
-
- /* check space for a new contour, then add it */
- FT_LOCAL_DEF( FT_Error )
- ps_builder_add_contour( PS_Builder* builder )
- {
- FT_Outline* outline = builder->current;
- FT_Error error;
-
-
- /* this might happen in invalid fonts */
- if ( !outline )
- {
- FT_ERROR(( "ps_builder_add_contour: no outline to add points to\n" ));
- return FT_THROW( Invalid_File_Format );
- }
-
- if ( !builder->load_points )
- {
- outline->n_contours++;
- return FT_Err_Ok;
- }
-
- error = FT_GLYPHLOADER_CHECK_POINTS( builder->loader, 0, 1 );
- if ( !error )
- {
- if ( outline->n_contours > 0 )
- outline->contours[outline->n_contours - 1] = outline->n_points - 1;
-
- outline->n_contours++;
- }
-
- return error;
- }
-
-
- /* if a path was begun, add its first on-curve point */
- FT_LOCAL_DEF( FT_Error )
- ps_builder_start_point( PS_Builder* builder,
- FT_Pos x,
- FT_Pos y )
- {
- FT_Error error = FT_Err_Ok;
-
-
- /* test whether we are building a new contour */
- if ( !builder->path_begun )
- {
- builder->path_begun = 1;
- error = ps_builder_add_contour( builder );
- if ( !error )
- error = ps_builder_add_point1( builder, x, y );
- }
-
- return error;
- }
-
-
- /* close the current contour */
- FT_LOCAL_DEF( void )
- ps_builder_close_contour( PS_Builder* builder )
- {
- FT_Outline* outline = builder->current;
- FT_Int first;
-
-
- if ( !outline )
- return;
-
- first = outline->n_contours <= 1
- ? 0 : outline->contours[outline->n_contours - 2] + 1;
-
- /* in malformed fonts it can happen that a contour was started */
- /* but no points were added */
- if ( outline->n_contours && first == outline->n_points )
- {
- outline->n_contours--;
- return;
- }
-
- /* We must not include the last point in the path if it */
- /* is located on the first point. */
- if ( outline->n_points > 1 )
- {
- FT_Vector* p1 = outline->points + first;
- FT_Vector* p2 = outline->points + outline->n_points - 1;
- FT_Byte* control = outline->tags + outline->n_points - 1;
-
-
- /* `delete' last point only if it coincides with the first */
- /* point and it is not a control point (which can happen). */
- if ( p1->x == p2->x && p1->y == p2->y )
- if ( *control == FT_CURVE_TAG_ON )
- outline->n_points--;
- }
-
- if ( outline->n_contours > 0 )
- {
- /* Don't add contours only consisting of one point, i.e., */
- /* check whether the first and the last point is the same. */
- if ( first == outline->n_points - 1 )
- {
- outline->n_contours--;
- outline->n_points--;
- }
- else
- outline->contours[outline->n_contours - 1] = outline->n_points - 1;
- }
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** OTHER *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /**************************************************************************
- *
- * @Function:
- * ps_decoder_init
- *
- * @Description:
- * Creates a wrapper decoder for use in the combined
- * Type 1 / CFF interpreter.
- *
- * @InOut:
- * ps_decoder ::
- * A pointer to the decoder to initialize.
- *
- * @Input:
- * decoder ::
- * A pointer to the original decoder.
- *
- * is_t1 ::
- * Flag indicating Type 1 or CFF
- */
- FT_LOCAL_DEF( void )
- ps_decoder_init( PS_Decoder* ps_decoder,
- void* decoder,
- FT_Bool is_t1 )
- {
- FT_ZERO( ps_decoder );
-
- if ( is_t1 )
- {
- T1_Decoder t1_decoder = (T1_Decoder)decoder;
-
-
- ps_builder_init( &ps_decoder->builder,
- &t1_decoder->builder,
- is_t1 );
-
- ps_decoder->cf2_instance = &t1_decoder->cf2_instance;
- ps_decoder->psnames = t1_decoder->psnames;
-
- ps_decoder->num_glyphs = t1_decoder->num_glyphs;
- ps_decoder->glyph_names = t1_decoder->glyph_names;
- ps_decoder->hint_mode = t1_decoder->hint_mode;
- ps_decoder->blend = t1_decoder->blend;
-
- ps_decoder->num_locals = (FT_UInt)t1_decoder->num_subrs;
- ps_decoder->locals = t1_decoder->subrs;
- ps_decoder->locals_len = t1_decoder->subrs_len;
- ps_decoder->locals_hash = t1_decoder->subrs_hash;
-
- ps_decoder->buildchar = t1_decoder->buildchar;
- ps_decoder->len_buildchar = t1_decoder->len_buildchar;
-
- ps_decoder->lenIV = t1_decoder->lenIV;
- }
- else
- {
- CFF_Decoder* cff_decoder = (CFF_Decoder*)decoder;
-
-
- ps_builder_init( &ps_decoder->builder,
- &cff_decoder->builder,
- is_t1 );
-
- ps_decoder->cff = cff_decoder->cff;
- ps_decoder->cf2_instance = &cff_decoder->cff->cf2_instance;
- ps_decoder->current_subfont = cff_decoder->current_subfont;
-
- ps_decoder->num_globals = cff_decoder->num_globals;
- ps_decoder->globals = cff_decoder->globals;
- ps_decoder->globals_bias = cff_decoder->globals_bias;
- ps_decoder->num_locals = cff_decoder->num_locals;
- ps_decoder->locals = cff_decoder->locals;
- ps_decoder->locals_bias = cff_decoder->locals_bias;
-
- ps_decoder->glyph_width = &cff_decoder->glyph_width;
- ps_decoder->width_only = cff_decoder->width_only;
-
- ps_decoder->hint_mode = cff_decoder->hint_mode;
-
- ps_decoder->get_glyph_callback = cff_decoder->get_glyph_callback;
- ps_decoder->free_glyph_callback = cff_decoder->free_glyph_callback;
- }
- }
-
-
- /* Synthesize a SubFont object for Type 1 fonts, for use in the */
- /* new interpreter to access Private dict data. */
- FT_LOCAL_DEF( void )
- t1_make_subfont( FT_Face face,
- PS_Private priv,
- CFF_SubFont subfont )
- {
- CFF_Private cpriv = &subfont->private_dict;
- FT_UInt n, count;
-
-
- FT_ZERO( subfont );
- FT_ZERO( cpriv );
-
- count = cpriv->num_blue_values = priv->num_blue_values;
- for ( n = 0; n < count; n++ )
- cpriv->blue_values[n] = cf2_intToFixed( priv->blue_values[n] );
-
- count = cpriv->num_other_blues = priv->num_other_blues;
- for ( n = 0; n < count; n++ )
- cpriv->other_blues[n] = cf2_intToFixed( priv->other_blues[n] );
-
- count = cpriv->num_family_blues = priv->num_family_blues;
- for ( n = 0; n < count; n++ )
- cpriv->family_blues[n] = cf2_intToFixed( priv->family_blues[n] );
-
- count = cpriv->num_family_other_blues = priv->num_family_other_blues;
- for ( n = 0; n < count; n++ )
- cpriv->family_other_blues[n] =
- cf2_intToFixed( priv->family_other_blues[n] );
-
- cpriv->blue_scale = priv->blue_scale;
- cpriv->blue_shift = (FT_Pos)priv->blue_shift;
- cpriv->blue_fuzz = (FT_Pos)priv->blue_fuzz;
-
- cpriv->standard_width = (FT_Pos)priv->standard_width[0];
- cpriv->standard_height = (FT_Pos)priv->standard_height[0];
-
- count = cpriv->num_snap_widths = priv->num_snap_widths;
- for ( n = 0; n < count; n++ )
- cpriv->snap_widths[n] = (FT_Pos)priv->snap_widths[n];
-
- count = cpriv->num_snap_heights = priv->num_snap_heights;
- for ( n = 0; n < count; n++ )
- cpriv->snap_heights[n] = (FT_Pos)priv->snap_heights[n];
-
- cpriv->force_bold = priv->force_bold;
- cpriv->lenIV = priv->lenIV;
- cpriv->language_group = priv->language_group;
- cpriv->expansion_factor = priv->expansion_factor;
-
- cpriv->subfont = subfont;
-
-
- /* Initialize the random number generator. */
- if ( face->internal->random_seed != -1 )
- {
- /* If we have a face-specific seed, use it. */
- /* If non-zero, update it to a positive value. */
- subfont->random = (FT_UInt32)face->internal->random_seed;
- if ( face->internal->random_seed )
- {
- do
- {
- face->internal->random_seed = (FT_Int32)cff_random(
- (FT_UInt32)face->internal->random_seed );
-
- } while ( face->internal->random_seed < 0 );
- }
- }
- if ( !subfont->random )
- {
- FT_UInt32 seed;
-
-
- /* compute random seed from some memory addresses */
- seed = (FT_UInt32)( (FT_Offset)(char*)&seed ^
- (FT_Offset)(char*)&face ^
- (FT_Offset)(char*)&subfont );
- seed = seed ^ ( seed >> 10 ) ^ ( seed >> 20 );
- if ( seed == 0 )
- seed = 0x7384;
-
- subfont->random = seed;
- }
- }
-
-
- FT_LOCAL_DEF( void )
- t1_decrypt( FT_Byte* buffer,
- FT_Offset length,
- FT_UShort seed )
- {
- PS_Conv_EexecDecode( &buffer,
- FT_OFFSET( buffer, length ),
- buffer,
- length,
- &seed );
- }
-
-
- FT_LOCAL_DEF( FT_UInt32 )
- cff_random( FT_UInt32 r )
- {
- /* a 32bit version of the `xorshift' algorithm */
- r ^= r << 13;
- r ^= r >> 17;
- r ^= r << 5;
-
- return r;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/psaux/psobjs.h b/contrib/libs/freetype/src/psaux/psobjs.h
deleted file mode 100644
index 345fc8a733..0000000000
--- a/contrib/libs/freetype/src/psaux/psobjs.h
+++ /dev/null
@@ -1,312 +0,0 @@
-/****************************************************************************
- *
- * psobjs.h
- *
- * Auxiliary functions for PostScript fonts (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef PSOBJS_H_
-#define PSOBJS_H_
-
-
-#include <freetype/internal/psaux.h>
-#include <freetype/internal/cffotypes.h>
-
-
-FT_BEGIN_HEADER
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** T1_TABLE *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- FT_CALLBACK_TABLE
- const PS_Table_FuncsRec ps_table_funcs;
-
- FT_CALLBACK_TABLE
- const PS_Parser_FuncsRec ps_parser_funcs;
-
- FT_CALLBACK_TABLE
- const T1_Builder_FuncsRec t1_builder_funcs;
-
-
- FT_LOCAL( FT_Error )
- ps_table_new( PS_Table table,
- FT_Int count,
- FT_Memory memory );
-
- FT_LOCAL( FT_Error )
- ps_table_add( PS_Table table,
- FT_Int idx,
- const void* object,
- FT_UInt length );
-
- FT_LOCAL( void )
- ps_table_done( PS_Table table );
-
-
- FT_LOCAL( void )
- ps_table_release( PS_Table table );
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** T1 PARSER *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- FT_LOCAL( void )
- ps_parser_skip_spaces( PS_Parser parser );
-
- FT_LOCAL( void )
- ps_parser_skip_PS_token( PS_Parser parser );
-
- FT_LOCAL( void )
- ps_parser_to_token( PS_Parser parser,
- T1_Token token );
-
- FT_LOCAL( void )
- ps_parser_to_token_array( PS_Parser parser,
- T1_Token tokens,
- FT_UInt max_tokens,
- FT_Int* pnum_tokens );
-
- FT_LOCAL( FT_Error )
- ps_parser_load_field( PS_Parser parser,
- const T1_Field field,
- void** objects,
- FT_UInt max_objects,
- FT_ULong* pflags );
-
- FT_LOCAL( FT_Error )
- ps_parser_load_field_table( PS_Parser parser,
- const T1_Field field,
- void** objects,
- FT_UInt max_objects,
- FT_ULong* pflags );
-
- FT_LOCAL( FT_Long )
- ps_parser_to_int( PS_Parser parser );
-
-
- FT_LOCAL( FT_Error )
- ps_parser_to_bytes( PS_Parser parser,
- FT_Byte* bytes,
- FT_Offset max_bytes,
- FT_ULong* pnum_bytes,
- FT_Bool delimiters );
-
-
- FT_LOCAL( FT_Fixed )
- ps_parser_to_fixed( PS_Parser parser,
- FT_Int power_ten );
-
-
- FT_LOCAL( FT_Int )
- ps_parser_to_coord_array( PS_Parser parser,
- FT_Int max_coords,
- FT_Short* coords );
-
- FT_LOCAL( FT_Int )
- ps_parser_to_fixed_array( PS_Parser parser,
- FT_Int max_values,
- FT_Fixed* values,
- FT_Int power_ten );
-
-
- FT_LOCAL( void )
- ps_parser_init( PS_Parser parser,
- FT_Byte* base,
- FT_Byte* limit,
- FT_Memory memory );
-
- FT_LOCAL( void )
- ps_parser_done( PS_Parser parser );
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** T1 BUILDER *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- FT_LOCAL( void )
- t1_builder_init( T1_Builder builder,
- FT_Face face,
- FT_Size size,
- FT_GlyphSlot glyph,
- FT_Bool hinting );
-
- FT_LOCAL( void )
- t1_builder_done( T1_Builder builder );
-
- FT_LOCAL( FT_Error )
- t1_builder_check_points( T1_Builder builder,
- FT_Int count );
-
- FT_LOCAL( void )
- t1_builder_add_point( T1_Builder builder,
- FT_Pos x,
- FT_Pos y,
- FT_Byte flag );
-
- FT_LOCAL( FT_Error )
- t1_builder_add_point1( T1_Builder builder,
- FT_Pos x,
- FT_Pos y );
-
- FT_LOCAL( FT_Error )
- t1_builder_add_contour( T1_Builder builder );
-
-
- FT_LOCAL( FT_Error )
- t1_builder_start_point( T1_Builder builder,
- FT_Pos x,
- FT_Pos y );
-
-
- FT_LOCAL( void )
- t1_builder_close_contour( T1_Builder builder );
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** CFF BUILDER *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- FT_LOCAL( void )
- cff_builder_init( CFF_Builder* builder,
- TT_Face face,
- CFF_Size size,
- CFF_GlyphSlot glyph,
- FT_Bool hinting );
-
- FT_LOCAL( void )
- cff_builder_done( CFF_Builder* builder );
-
- FT_LOCAL( FT_Error )
- cff_check_points( CFF_Builder* builder,
- FT_Int count );
-
- FT_LOCAL( void )
- cff_builder_add_point( CFF_Builder* builder,
- FT_Pos x,
- FT_Pos y,
- FT_Byte flag );
- FT_LOCAL( FT_Error )
- cff_builder_add_point1( CFF_Builder* builder,
- FT_Pos x,
- FT_Pos y );
- FT_LOCAL( FT_Error )
- cff_builder_start_point( CFF_Builder* builder,
- FT_Pos x,
- FT_Pos y );
- FT_LOCAL( void )
- cff_builder_close_contour( CFF_Builder* builder );
-
- FT_LOCAL( FT_Error )
- cff_builder_add_contour( CFF_Builder* builder );
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** PS BUILDER *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- FT_LOCAL( void )
- ps_builder_init( PS_Builder* ps_builder,
- void* builder,
- FT_Bool is_t1 );
-
-
- FT_LOCAL( void )
- ps_builder_done( PS_Builder* builder );
-
- FT_LOCAL( FT_Error )
- ps_builder_check_points( PS_Builder* builder,
- FT_Int count );
-
- FT_LOCAL( void )
- ps_builder_add_point( PS_Builder* builder,
- FT_Pos x,
- FT_Pos y,
- FT_Byte flag );
-
- FT_LOCAL( FT_Error )
- ps_builder_add_point1( PS_Builder* builder,
- FT_Pos x,
- FT_Pos y );
-
- FT_LOCAL( FT_Error )
- ps_builder_add_contour( PS_Builder* builder );
-
- FT_LOCAL( FT_Error )
- ps_builder_start_point( PS_Builder* builder,
- FT_Pos x,
- FT_Pos y );
-
- FT_LOCAL( void )
- ps_builder_close_contour( PS_Builder* builder );
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** OTHER *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- FT_LOCAL( void )
- ps_decoder_init( PS_Decoder* ps_decoder,
- void* decoder,
- FT_Bool is_t1 );
-
- FT_LOCAL( void )
- t1_make_subfont( FT_Face face,
- PS_Private priv,
- CFF_SubFont subfont );
-
- FT_LOCAL( void )
- t1_decrypt( FT_Byte* buffer,
- FT_Offset length,
- FT_UShort seed );
-
-
- FT_LOCAL( FT_UInt32 )
- cff_random( FT_UInt32 r );
-
-
-FT_END_HEADER
-
-#endif /* PSOBJS_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/psaux/psread.c b/contrib/libs/freetype/src/psaux/psread.c
deleted file mode 100644
index 7f657f2cdc..0000000000
--- a/contrib/libs/freetype/src/psaux/psread.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/****************************************************************************
- *
- * psread.c
- *
- * Adobe's code for stream handling (body).
- *
- * Copyright 2007-2013 Adobe Systems Incorporated.
- *
- * This software, and all works of authorship, whether in source or
- * object code form as indicated by the copyright notice(s) included
- * herein (collectively, the "Work") is made available, and may only be
- * used, modified, and distributed under the FreeType Project License,
- * LICENSE.TXT. Additionally, subject to the terms and conditions of the
- * FreeType Project License, each contributor to the Work hereby grants
- * to any individual or legal entity exercising permissions granted by
- * the FreeType Project License and this section (hereafter, "You" or
- * "Your") a perpetual, worldwide, non-exclusive, no-charge,
- * royalty-free, irrevocable (except as stated in this section) patent
- * license to make, have made, use, offer to sell, sell, import, and
- * otherwise transfer the Work, where such license applies only to those
- * patent claims licensable by such contributor that are necessarily
- * infringed by their contribution(s) alone or by combination of their
- * contribution(s) with the Work to which such contribution(s) was
- * submitted. If You institute patent litigation against any entity
- * (including a cross-claim or counterclaim in a lawsuit) alleging that
- * the Work or a contribution incorporated within the Work constitutes
- * direct or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate as of
- * the date such litigation is filed.
- *
- * By using, modifying, or distributing the Work you indicate that you
- * have read and understood the terms and conditions of the
- * FreeType Project License as well as those provided in this section,
- * and you accept them fully.
- *
- */
-
-
-#include "psft.h"
-#include <freetype/internal/ftdebug.h>
-
-#include "psglue.h"
-
-#include "pserror.h"
-
-
- /* Define CF2_IO_FAIL as 1 to enable random errors and random */
- /* value errors in I/O. */
-#define CF2_IO_FAIL 0
-
-
-#if CF2_IO_FAIL
-
- /* set the .00 value to a nonzero probability */
- static int
- randomError2( void )
- {
- /* for region buffer ReadByte (interp) function */
- return (double)rand() / RAND_MAX < .00;
- }
-
- /* set the .00 value to a nonzero probability */
- static CF2_Int
- randomValue()
- {
- return (double)rand() / RAND_MAX < .00 ? rand() : 0;
- }
-
-#endif /* CF2_IO_FAIL */
-
-
- /* Region Buffer */
- /* */
- /* Can be constructed from a copied buffer managed by */
- /* `FCM_getDatablock'. */
- /* Reads bytes with check for end of buffer. */
-
- /* reading past the end of the buffer sets error and returns zero */
- FT_LOCAL_DEF( CF2_Int )
- cf2_buf_readByte( CF2_Buffer buf )
- {
- if ( buf->ptr < buf->end )
- {
-#if CF2_IO_FAIL
- if ( randomError2() )
- {
- CF2_SET_ERROR( buf->error, Invalid_Stream_Operation );
- return 0;
- }
-
- return *(buf->ptr)++ + randomValue();
-#else
- return *(buf->ptr)++;
-#endif
- }
- else
- {
- CF2_SET_ERROR( buf->error, Invalid_Stream_Operation );
- return 0;
- }
- }
-
-
- /* note: end condition can occur without error */
- FT_LOCAL_DEF( FT_Bool )
- cf2_buf_isEnd( CF2_Buffer buf )
- {
- return FT_BOOL( buf->ptr >= buf->end );
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/psaux/psread.h b/contrib/libs/freetype/src/psaux/psread.h
deleted file mode 100644
index 9e55fe0447..0000000000
--- a/contrib/libs/freetype/src/psaux/psread.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/****************************************************************************
- *
- * psread.h
- *
- * Adobe's code for stream handling (specification).
- *
- * Copyright 2007-2013 Adobe Systems Incorporated.
- *
- * This software, and all works of authorship, whether in source or
- * object code form as indicated by the copyright notice(s) included
- * herein (collectively, the "Work") is made available, and may only be
- * used, modified, and distributed under the FreeType Project License,
- * LICENSE.TXT. Additionally, subject to the terms and conditions of the
- * FreeType Project License, each contributor to the Work hereby grants
- * to any individual or legal entity exercising permissions granted by
- * the FreeType Project License and this section (hereafter, "You" or
- * "Your") a perpetual, worldwide, non-exclusive, no-charge,
- * royalty-free, irrevocable (except as stated in this section) patent
- * license to make, have made, use, offer to sell, sell, import, and
- * otherwise transfer the Work, where such license applies only to those
- * patent claims licensable by such contributor that are necessarily
- * infringed by their contribution(s) alone or by combination of their
- * contribution(s) with the Work to which such contribution(s) was
- * submitted. If You institute patent litigation against any entity
- * (including a cross-claim or counterclaim in a lawsuit) alleging that
- * the Work or a contribution incorporated within the Work constitutes
- * direct or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate as of
- * the date such litigation is filed.
- *
- * By using, modifying, or distributing the Work you indicate that you
- * have read and understood the terms and conditions of the
- * FreeType Project License as well as those provided in this section,
- * and you accept them fully.
- *
- */
-
-
-#ifndef PSREAD_H_
-#define PSREAD_H_
-
-
-FT_BEGIN_HEADER
-
-
- typedef struct CF2_BufferRec_
- {
- FT_Error* error;
- const FT_Byte* start;
- const FT_Byte* end;
- const FT_Byte* ptr;
-
- } CF2_BufferRec, *CF2_Buffer;
-
-
- FT_LOCAL( CF2_Int )
- cf2_buf_readByte( CF2_Buffer buf );
- FT_LOCAL( FT_Bool )
- cf2_buf_isEnd( CF2_Buffer buf );
-
-
-FT_END_HEADER
-
-
-#endif /* PSREAD_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/psaux/psstack.c b/contrib/libs/freetype/src/psaux/psstack.c
deleted file mode 100644
index 797486588a..0000000000
--- a/contrib/libs/freetype/src/psaux/psstack.c
+++ /dev/null
@@ -1,329 +0,0 @@
-/****************************************************************************
- *
- * psstack.c
- *
- * Adobe's code for emulating a CFF stack (body).
- *
- * Copyright 2007-2013 Adobe Systems Incorporated.
- *
- * This software, and all works of authorship, whether in source or
- * object code form as indicated by the copyright notice(s) included
- * herein (collectively, the "Work") is made available, and may only be
- * used, modified, and distributed under the FreeType Project License,
- * LICENSE.TXT. Additionally, subject to the terms and conditions of the
- * FreeType Project License, each contributor to the Work hereby grants
- * to any individual or legal entity exercising permissions granted by
- * the FreeType Project License and this section (hereafter, "You" or
- * "Your") a perpetual, worldwide, non-exclusive, no-charge,
- * royalty-free, irrevocable (except as stated in this section) patent
- * license to make, have made, use, offer to sell, sell, import, and
- * otherwise transfer the Work, where such license applies only to those
- * patent claims licensable by such contributor that are necessarily
- * infringed by their contribution(s) alone or by combination of their
- * contribution(s) with the Work to which such contribution(s) was
- * submitted. If You institute patent litigation against any entity
- * (including a cross-claim or counterclaim in a lawsuit) alleging that
- * the Work or a contribution incorporated within the Work constitutes
- * direct or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate as of
- * the date such litigation is filed.
- *
- * By using, modifying, or distributing the Work you indicate that you
- * have read and understood the terms and conditions of the
- * FreeType Project License as well as those provided in this section,
- * and you accept them fully.
- *
- */
-
-
-#include "psft.h"
-#include <freetype/internal/ftdebug.h>
-
-#include "psglue.h"
-#include "psfont.h"
-#include "psstack.h"
-
-#include "pserror.h"
-
-
- /* Allocate and initialize an instance of CF2_Stack. */
- /* Note: This function returns NULL on error (does not set */
- /* `error'). */
- FT_LOCAL_DEF( CF2_Stack )
- cf2_stack_init( FT_Memory memory,
- FT_Error* e,
- FT_UInt stackSize )
- {
- FT_Error error; /* for FT_QNEW */
- CF2_Stack stack = NULL;
-
-
- if ( FT_QNEW( stack ) )
- return NULL;
-
- stack->memory = memory;
- stack->error = e;
-
- /* allocate the stack buffer */
- if ( FT_QNEW_ARRAY( stack->buffer, stackSize ) )
- {
- FT_FREE( stack );
- return NULL;
- }
-
- stack->stackSize = stackSize;
- stack->top = stack->buffer; /* empty stack */
-
- return stack;
- }
-
-
- FT_LOCAL_DEF( void )
- cf2_stack_free( CF2_Stack stack )
- {
- if ( stack )
- {
- FT_Memory memory = stack->memory;
-
- /* free the buffer */
- FT_FREE( stack->buffer );
-
- /* free the main structure */
- FT_FREE( stack );
- }
- }
-
-
- FT_LOCAL_DEF( CF2_UInt )
- cf2_stack_count( CF2_Stack stack )
- {
- return (CF2_UInt)( stack->top - stack->buffer );
- }
-
-
- FT_LOCAL_DEF( void )
- cf2_stack_pushInt( CF2_Stack stack,
- CF2_Int val )
- {
- if ( stack->top == stack->buffer + stack->stackSize )
- {
- CF2_SET_ERROR( stack->error, Stack_Overflow );
- return; /* stack overflow */
- }
-
- stack->top->u.i = val;
- stack->top->type = CF2_NumberInt;
- stack->top++;
- }
-
-
- FT_LOCAL_DEF( void )
- cf2_stack_pushFixed( CF2_Stack stack,
- CF2_Fixed val )
- {
- if ( stack->top == stack->buffer + stack->stackSize )
- {
- CF2_SET_ERROR( stack->error, Stack_Overflow );
- return; /* stack overflow */
- }
-
- stack->top->u.r = val;
- stack->top->type = CF2_NumberFixed;
- stack->top++;
- }
-
-
- /* this function is only allowed to pop an integer type */
- FT_LOCAL_DEF( CF2_Int )
- cf2_stack_popInt( CF2_Stack stack )
- {
- if ( stack->top == stack->buffer )
- {
- CF2_SET_ERROR( stack->error, Stack_Underflow );
- return 0; /* underflow */
- }
- if ( stack->top[-1].type != CF2_NumberInt )
- {
- CF2_SET_ERROR( stack->error, Syntax_Error );
- return 0; /* type mismatch */
- }
-
- stack->top--;
-
- return stack->top->u.i;
- }
-
-
- /* Note: type mismatch is silently cast */
- /* TODO: check this */
- FT_LOCAL_DEF( CF2_Fixed )
- cf2_stack_popFixed( CF2_Stack stack )
- {
- if ( stack->top == stack->buffer )
- {
- CF2_SET_ERROR( stack->error, Stack_Underflow );
- return cf2_intToFixed( 0 ); /* underflow */
- }
-
- stack->top--;
-
- switch ( stack->top->type )
- {
- case CF2_NumberInt:
- return cf2_intToFixed( stack->top->u.i );
- case CF2_NumberFrac:
- return cf2_fracToFixed( stack->top->u.f );
- default:
- return stack->top->u.r;
- }
- }
-
-
- /* Note: type mismatch is silently cast */
- /* TODO: check this */
- FT_LOCAL_DEF( CF2_Fixed )
- cf2_stack_getReal( CF2_Stack stack,
- CF2_UInt idx )
- {
- FT_ASSERT( cf2_stack_count( stack ) <= stack->stackSize );
-
- if ( idx >= cf2_stack_count( stack ) )
- {
- CF2_SET_ERROR( stack->error, Stack_Overflow );
- return cf2_intToFixed( 0 ); /* bounds error */
- }
-
- switch ( stack->buffer[idx].type )
- {
- case CF2_NumberInt:
- return cf2_intToFixed( stack->buffer[idx].u.i );
- case CF2_NumberFrac:
- return cf2_fracToFixed( stack->buffer[idx].u.f );
- default:
- return stack->buffer[idx].u.r;
- }
- }
-
-
- /* provide random access to stack */
- FT_LOCAL_DEF( void )
- cf2_stack_setReal( CF2_Stack stack,
- CF2_UInt idx,
- CF2_Fixed val )
- {
- if ( idx > cf2_stack_count( stack ) )
- {
- CF2_SET_ERROR( stack->error, Stack_Overflow );
- return;
- }
-
- stack->buffer[idx].u.r = val;
- stack->buffer[idx].type = CF2_NumberFixed;
- }
-
-
- /* discard (pop) num values from stack */
- FT_LOCAL_DEF( void )
- cf2_stack_pop( CF2_Stack stack,
- CF2_UInt num )
- {
- if ( num > cf2_stack_count( stack ) )
- {
- CF2_SET_ERROR( stack->error, Stack_Underflow );
- return;
- }
- stack->top -= num;
- }
-
-
- FT_LOCAL_DEF( void )
- cf2_stack_roll( CF2_Stack stack,
- CF2_Int count,
- CF2_Int shift )
- {
- /* we initialize this variable to avoid compiler warnings */
- CF2_StackNumber last = { { 0 }, CF2_NumberInt };
-
- CF2_Int start_idx, idx, i;
-
-
- if ( count < 2 )
- return; /* nothing to do (values 0 and 1), or undefined value */
-
- if ( (CF2_UInt)count > cf2_stack_count( stack ) )
- {
- CF2_SET_ERROR( stack->error, Stack_Overflow );
- return;
- }
-
- /* before C99 it is implementation-defined whether */
- /* the result of `%' is negative if the first operand */
- /* is negative */
- if ( shift < 0 )
- shift = -( ( -shift ) % count );
- else
- shift %= count;
-
- if ( shift == 0 )
- return; /* nothing to do */
-
- /* We use the following algorithm to do the rolling, */
- /* which needs two temporary variables only. */
- /* */
- /* Example: */
- /* */
- /* count = 8 */
- /* shift = 2 */
- /* */
- /* stack indices before roll: 7 6 5 4 3 2 1 0 */
- /* stack indices after roll: 1 0 7 6 5 4 3 2 */
- /* */
- /* The value of index 0 gets moved to index 2, while */
- /* the old value of index 2 gets moved to index 4, */
- /* and so on. We thus have the following copying */
- /* chains for shift value 2. */
- /* */
- /* 0 -> 2 -> 4 -> 6 -> 0 */
- /* 1 -> 3 -> 5 -> 7 -> 1 */
- /* */
- /* If `count' and `shift' are incommensurable, we */
- /* have a single chain only. Otherwise, increase */
- /* the start index by 1 after the first chain, then */
- /* do the next chain until all elements in all */
- /* chains are handled. */
-
- start_idx = -1;
- idx = -1;
- for ( i = 0; i < count; i++ )
- {
- CF2_StackNumber tmp;
-
-
- if ( start_idx == idx )
- {
- start_idx++;
- idx = start_idx;
- last = stack->buffer[idx];
- }
-
- idx += shift;
- if ( idx >= count )
- idx -= count;
- else if ( idx < 0 )
- idx += count;
-
- tmp = stack->buffer[idx];
- stack->buffer[idx] = last;
- last = tmp;
- }
- }
-
-
- FT_LOCAL_DEF( void )
- cf2_stack_clear( CF2_Stack stack )
- {
- stack->top = stack->buffer;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/psaux/psstack.h b/contrib/libs/freetype/src/psaux/psstack.h
deleted file mode 100644
index 907b424000..0000000000
--- a/contrib/libs/freetype/src/psaux/psstack.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/****************************************************************************
- *
- * psstack.h
- *
- * Adobe's code for emulating a CFF stack (specification).
- *
- * Copyright 2007-2013 Adobe Systems Incorporated.
- *
- * This software, and all works of authorship, whether in source or
- * object code form as indicated by the copyright notice(s) included
- * herein (collectively, the "Work") is made available, and may only be
- * used, modified, and distributed under the FreeType Project License,
- * LICENSE.TXT. Additionally, subject to the terms and conditions of the
- * FreeType Project License, each contributor to the Work hereby grants
- * to any individual or legal entity exercising permissions granted by
- * the FreeType Project License and this section (hereafter, "You" or
- * "Your") a perpetual, worldwide, non-exclusive, no-charge,
- * royalty-free, irrevocable (except as stated in this section) patent
- * license to make, have made, use, offer to sell, sell, import, and
- * otherwise transfer the Work, where such license applies only to those
- * patent claims licensable by such contributor that are necessarily
- * infringed by their contribution(s) alone or by combination of their
- * contribution(s) with the Work to which such contribution(s) was
- * submitted. If You institute patent litigation against any entity
- * (including a cross-claim or counterclaim in a lawsuit) alleging that
- * the Work or a contribution incorporated within the Work constitutes
- * direct or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate as of
- * the date such litigation is filed.
- *
- * By using, modifying, or distributing the Work you indicate that you
- * have read and understood the terms and conditions of the
- * FreeType Project License as well as those provided in this section,
- * and you accept them fully.
- *
- */
-
-
-#ifndef PSSTACK_H_
-#define PSSTACK_H_
-
-#include <freetype/internal/compiler-macros.h>
-
-FT_BEGIN_HEADER
-
-
- /* CFF operand stack; specified maximum of 48 or 192 values */
- typedef struct CF2_StackNumber_
- {
- union
- {
- CF2_Fixed r; /* 16.16 fixed-point */
- CF2_Frac f; /* 2.30 fixed-point (for font matrix) */
- CF2_Int i;
- } u;
-
- CF2_NumberType type;
-
- } CF2_StackNumber;
-
-
- typedef struct CF2_StackRec_
- {
- FT_Memory memory;
- FT_Error* error;
- CF2_StackNumber* buffer;
- CF2_StackNumber* top;
- FT_UInt stackSize;
-
- } CF2_StackRec, *CF2_Stack;
-
-
- FT_LOCAL( CF2_Stack )
- cf2_stack_init( FT_Memory memory,
- FT_Error* error,
- FT_UInt stackSize );
- FT_LOCAL( void )
- cf2_stack_free( CF2_Stack stack );
-
- FT_LOCAL( CF2_UInt )
- cf2_stack_count( CF2_Stack stack );
-
- FT_LOCAL( void )
- cf2_stack_pushInt( CF2_Stack stack,
- CF2_Int val );
- FT_LOCAL( void )
- cf2_stack_pushFixed( CF2_Stack stack,
- CF2_Fixed val );
-
- FT_LOCAL( CF2_Int )
- cf2_stack_popInt( CF2_Stack stack );
- FT_LOCAL( CF2_Fixed )
- cf2_stack_popFixed( CF2_Stack stack );
-
- FT_LOCAL( CF2_Fixed )
- cf2_stack_getReal( CF2_Stack stack,
- CF2_UInt idx );
- FT_LOCAL( void )
- cf2_stack_setReal( CF2_Stack stack,
- CF2_UInt idx,
- CF2_Fixed val );
-
- FT_LOCAL( void )
- cf2_stack_pop( CF2_Stack stack,
- CF2_UInt num );
-
- FT_LOCAL( void )
- cf2_stack_roll( CF2_Stack stack,
- CF2_Int count,
- CF2_Int idx );
-
- FT_LOCAL( void )
- cf2_stack_clear( CF2_Stack stack );
-
-
-FT_END_HEADER
-
-
-#endif /* PSSTACK_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/psaux/pstypes.h b/contrib/libs/freetype/src/psaux/pstypes.h
deleted file mode 100644
index 435ef7e1fe..0000000000
--- a/contrib/libs/freetype/src/psaux/pstypes.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/****************************************************************************
- *
- * pstypes.h
- *
- * Adobe's code for defining data types (specification only).
- *
- * Copyright 2011-2013 Adobe Systems Incorporated.
- *
- * This software, and all works of authorship, whether in source or
- * object code form as indicated by the copyright notice(s) included
- * herein (collectively, the "Work") is made available, and may only be
- * used, modified, and distributed under the FreeType Project License,
- * LICENSE.TXT. Additionally, subject to the terms and conditions of the
- * FreeType Project License, each contributor to the Work hereby grants
- * to any individual or legal entity exercising permissions granted by
- * the FreeType Project License and this section (hereafter, "You" or
- * "Your") a perpetual, worldwide, non-exclusive, no-charge,
- * royalty-free, irrevocable (except as stated in this section) patent
- * license to make, have made, use, offer to sell, sell, import, and
- * otherwise transfer the Work, where such license applies only to those
- * patent claims licensable by such contributor that are necessarily
- * infringed by their contribution(s) alone or by combination of their
- * contribution(s) with the Work to which such contribution(s) was
- * submitted. If You institute patent litigation against any entity
- * (including a cross-claim or counterclaim in a lawsuit) alleging that
- * the Work or a contribution incorporated within the Work constitutes
- * direct or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate as of
- * the date such litigation is filed.
- *
- * By using, modifying, or distributing the Work you indicate that you
- * have read and understood the terms and conditions of the
- * FreeType Project License as well as those provided in this section,
- * and you accept them fully.
- *
- */
-
-
-#ifndef PSTYPES_H_
-#define PSTYPES_H_
-
-#include <freetype/freetype.h>
-
-
-FT_BEGIN_HEADER
-
-
- /*
- * The data models that we expect to support are as follows:
- *
- * name char short int long long-long pointer example
- * -----------------------------------------------------
- * ILP32 8 16 32 32 64* 32 32-bit MacOS, x86
- * LLP64 8 16 32 32 64 64 x64
- * LP64 8 16 32 64 64 64 64-bit MacOS
- *
- * *) type may be supported by emulation on a 32-bit architecture
- *
- */
-
-
- /* integers at least 32 bits wide */
-#define CF2_UInt FT_UFast
-#define CF2_Int FT_Fast
-
-
- /* fixed-float numbers */
- typedef FT_Int32 CF2_F16Dot16;
-
-
-FT_END_HEADER
-
-
-#endif /* PSTYPES_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/psaux/t1cmap.c b/contrib/libs/freetype/src/psaux/t1cmap.c
deleted file mode 100644
index 5681c3bd0f..0000000000
--- a/contrib/libs/freetype/src/psaux/t1cmap.c
+++ /dev/null
@@ -1,393 +0,0 @@
-/****************************************************************************
- *
- * t1cmap.c
- *
- * Type 1 character map support (body).
- *
- * Copyright (C) 2002-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include "t1cmap.h"
-
-#include <freetype/internal/ftdebug.h>
-
-#include "psauxerr.h"
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** TYPE1 STANDARD (AND EXPERT) ENCODING CMAPS *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- static void
- t1_cmap_std_init( T1_CMapStd cmap,
- FT_Int is_expert )
- {
- T1_Face face = (T1_Face)FT_CMAP_FACE( cmap );
- FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)face->psnames;
-
-
- cmap->num_glyphs = (FT_UInt)face->type1.num_glyphs;
- cmap->glyph_names = (const char* const*)face->type1.glyph_names;
- cmap->sid_to_string = psnames->adobe_std_strings;
- cmap->code_to_sid = is_expert ? psnames->adobe_expert_encoding
- : psnames->adobe_std_encoding;
-
- FT_ASSERT( cmap->code_to_sid );
- }
-
-
- FT_CALLBACK_DEF( void )
- t1_cmap_std_done( FT_CMap cmap_ ) /* T1_CMapStd */
- {
- T1_CMapStd cmap = (T1_CMapStd)cmap_;
-
-
- cmap->num_glyphs = 0;
- cmap->glyph_names = NULL;
- cmap->sid_to_string = NULL;
- cmap->code_to_sid = NULL;
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- t1_cmap_std_char_index( FT_CMap cmap, /* T1_CMapStd */
- FT_UInt32 char_code )
- {
- T1_CMapStd t1cmap = (T1_CMapStd)cmap;
- FT_UInt result = 0;
-
-
- if ( char_code < 256 )
- {
- FT_UInt code, n;
- const char* glyph_name;
-
-
- /* convert character code to Adobe SID string */
- code = t1cmap->code_to_sid[char_code];
- glyph_name = t1cmap->sid_to_string( code );
-
- /* look for the corresponding glyph name */
- for ( n = 0; n < t1cmap->num_glyphs; n++ )
- {
- const char* gname = t1cmap->glyph_names[n];
-
-
- if ( gname && gname[0] == glyph_name[0] &&
- ft_strcmp( gname, glyph_name ) == 0 )
- {
- result = n;
- break;
- }
- }
- }
-
- return result;
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- t1_cmap_std_char_next( FT_CMap cmap,
- FT_UInt32 *pchar_code )
- {
- FT_UInt result = 0;
- FT_UInt32 char_code = *pchar_code + 1;
-
-
- while ( char_code < 256 )
- {
- result = t1_cmap_std_char_index( cmap, char_code );
- if ( result != 0 )
- goto Exit;
-
- char_code++;
- }
- char_code = 0;
-
- Exit:
- *pchar_code = char_code;
- return result;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- t1_cmap_standard_init( FT_CMap cmap, /* T1_CMapStd */
- FT_Pointer pointer )
- {
- T1_CMapStd t1cmap = (T1_CMapStd)cmap;
- FT_UNUSED( pointer );
-
-
- t1_cmap_std_init( t1cmap, 0 );
- return 0;
- }
-
-
- FT_CALLBACK_TABLE_DEF const FT_CMap_ClassRec
- t1_cmap_standard_class_rec =
- {
- sizeof ( T1_CMapStdRec ),
-
- (FT_CMap_InitFunc) t1_cmap_standard_init, /* init */
- (FT_CMap_DoneFunc) t1_cmap_std_done, /* done */
- (FT_CMap_CharIndexFunc)t1_cmap_std_char_index, /* char_index */
- (FT_CMap_CharNextFunc) t1_cmap_std_char_next, /* char_next */
-
- (FT_CMap_CharVarIndexFunc) NULL, /* char_var_index */
- (FT_CMap_CharVarIsDefaultFunc)NULL, /* char_var_default */
- (FT_CMap_VariantListFunc) NULL, /* variant_list */
- (FT_CMap_CharVariantListFunc) NULL, /* charvariant_list */
- (FT_CMap_VariantCharListFunc) NULL /* variantchar_list */
- };
-
-
- FT_CALLBACK_DEF( FT_Error )
- t1_cmap_expert_init( FT_CMap cmap, /* T1_CMapStd */
- FT_Pointer pointer )
- {
- T1_CMapStd t1cmap = (T1_CMapStd)cmap;
- FT_UNUSED( pointer );
-
-
- t1_cmap_std_init( t1cmap, 1 );
- return 0;
- }
-
- FT_CALLBACK_TABLE_DEF const FT_CMap_ClassRec
- t1_cmap_expert_class_rec =
- {
- sizeof ( T1_CMapStdRec ),
-
- (FT_CMap_InitFunc) t1_cmap_expert_init, /* init */
- (FT_CMap_DoneFunc) t1_cmap_std_done, /* done */
- (FT_CMap_CharIndexFunc)t1_cmap_std_char_index, /* char_index */
- (FT_CMap_CharNextFunc) t1_cmap_std_char_next, /* char_next */
-
- (FT_CMap_CharVarIndexFunc) NULL, /* char_var_index */
- (FT_CMap_CharVarIsDefaultFunc)NULL, /* char_var_default */
- (FT_CMap_VariantListFunc) NULL, /* variant_list */
- (FT_CMap_CharVariantListFunc) NULL, /* charvariant_list */
- (FT_CMap_VariantCharListFunc) NULL /* variantchar_list */
- };
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** TYPE1 CUSTOM ENCODING CMAP *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- FT_CALLBACK_DEF( FT_Error )
- t1_cmap_custom_init( FT_CMap cmap, /* T1_CMapCustom */
- FT_Pointer pointer )
- {
- T1_CMapCustom t1cmap = (T1_CMapCustom)cmap;
- T1_Face face = (T1_Face)FT_CMAP_FACE( cmap );
- T1_Encoding encoding = &face->type1.encoding;
-
- FT_UNUSED( pointer );
-
-
- t1cmap->first = (FT_UInt)encoding->code_first;
- t1cmap->count = (FT_UInt)encoding->code_last - t1cmap->first;
- t1cmap->indices = encoding->char_index;
-
- FT_ASSERT( t1cmap->indices );
- FT_ASSERT( encoding->code_first <= encoding->code_last );
-
- return 0;
- }
-
-
- FT_CALLBACK_DEF( void )
- t1_cmap_custom_done( FT_CMap cmap ) /* T1_CMapCustom */
- {
- T1_CMapCustom t1cmap = (T1_CMapCustom)cmap;
-
-
- t1cmap->indices = NULL;
- t1cmap->first = 0;
- t1cmap->count = 0;
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- t1_cmap_custom_char_index( FT_CMap cmap, /* T1_CMapCustom */
- FT_UInt32 char_code )
- {
- T1_CMapCustom t1cmap = (T1_CMapCustom)cmap;
- FT_UInt result = 0;
-
-
- if ( char_code >= t1cmap->first &&
- char_code < ( t1cmap->first + t1cmap->count ) )
- result = t1cmap->indices[char_code];
-
- return result;
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- t1_cmap_custom_char_next( FT_CMap cmap, /* T1_CMapCustom */
- FT_UInt32 *pchar_code )
- {
- T1_CMapCustom t1cmap = (T1_CMapCustom)cmap;
- FT_UInt result = 0;
- FT_UInt32 char_code = *pchar_code;
-
-
- char_code++;
-
- if ( char_code < t1cmap->first )
- char_code = t1cmap->first;
-
- for ( ; char_code < ( t1cmap->first + t1cmap->count ); char_code++ )
- {
- result = t1cmap->indices[char_code];
- if ( result != 0 )
- goto Exit;
- }
-
- char_code = 0;
-
- Exit:
- *pchar_code = char_code;
- return result;
- }
-
-
- FT_CALLBACK_TABLE_DEF const FT_CMap_ClassRec
- t1_cmap_custom_class_rec =
- {
- sizeof ( T1_CMapCustomRec ),
-
- (FT_CMap_InitFunc) t1_cmap_custom_init, /* init */
- (FT_CMap_DoneFunc) t1_cmap_custom_done, /* done */
- (FT_CMap_CharIndexFunc)t1_cmap_custom_char_index, /* char_index */
- (FT_CMap_CharNextFunc) t1_cmap_custom_char_next, /* char_next */
-
- (FT_CMap_CharVarIndexFunc) NULL, /* char_var_index */
- (FT_CMap_CharVarIsDefaultFunc)NULL, /* char_var_default */
- (FT_CMap_VariantListFunc) NULL, /* variant_list */
- (FT_CMap_CharVariantListFunc) NULL, /* charvariant_list */
- (FT_CMap_VariantCharListFunc) NULL /* variantchar_list */
- };
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** TYPE1 SYNTHETIC UNICODE ENCODING CMAP *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- FT_CALLBACK_DEF( const char * )
- psaux_get_glyph_name( void* face_,
- FT_UInt idx )
- {
- T1_Face face = (T1_Face)face_;
-
-
- return face->type1.glyph_names[idx];
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- t1_cmap_unicode_init( FT_CMap cmap, /* PS_Unicodes */
- FT_Pointer pointer )
- {
- PS_Unicodes unicodes = (PS_Unicodes)cmap;
- T1_Face face = (T1_Face)FT_CMAP_FACE( cmap );
- FT_Memory memory = FT_FACE_MEMORY( face );
- FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)face->psnames;
-
- FT_UNUSED( pointer );
-
-
- if ( !psnames->unicodes_init )
- return FT_THROW( Unimplemented_Feature );
-
- return psnames->unicodes_init( memory,
- unicodes,
- (FT_UInt)face->type1.num_glyphs,
- &psaux_get_glyph_name,
- (PS_FreeGlyphNameFunc)NULL,
- (FT_Pointer)face );
- }
-
-
- FT_CALLBACK_DEF( void )
- t1_cmap_unicode_done( FT_CMap cmap ) /* PS_Unicodes */
- {
- PS_Unicodes unicodes = (PS_Unicodes)cmap;
- FT_Face face = FT_CMAP_FACE( cmap );
- FT_Memory memory = FT_FACE_MEMORY( face );
-
-
- FT_FREE( unicodes->maps );
- unicodes->num_maps = 0;
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- t1_cmap_unicode_char_index( FT_CMap cmap, /* PS_Unicodes */
- FT_UInt32 char_code )
- {
- PS_Unicodes unicodes = (PS_Unicodes)cmap;
- T1_Face face = (T1_Face)FT_CMAP_FACE( cmap );
- FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)face->psnames;
-
-
- return psnames->unicodes_char_index( unicodes, char_code );
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- t1_cmap_unicode_char_next( FT_CMap cmap, /* PS_Unicodes */
- FT_UInt32 *pchar_code )
- {
- PS_Unicodes unicodes = (PS_Unicodes)cmap;
- T1_Face face = (T1_Face)FT_CMAP_FACE( cmap );
- FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)face->psnames;
-
-
- return psnames->unicodes_char_next( unicodes, pchar_code );
- }
-
-
- FT_CALLBACK_TABLE_DEF const FT_CMap_ClassRec
- t1_cmap_unicode_class_rec =
- {
- sizeof ( PS_UnicodesRec ),
-
- (FT_CMap_InitFunc) t1_cmap_unicode_init, /* init */
- (FT_CMap_DoneFunc) t1_cmap_unicode_done, /* done */
- (FT_CMap_CharIndexFunc)t1_cmap_unicode_char_index, /* char_index */
- (FT_CMap_CharNextFunc) t1_cmap_unicode_char_next, /* char_next */
-
- (FT_CMap_CharVarIndexFunc) NULL, /* char_var_index */
- (FT_CMap_CharVarIsDefaultFunc)NULL, /* char_var_default */
- (FT_CMap_VariantListFunc) NULL, /* variant_list */
- (FT_CMap_CharVariantListFunc) NULL, /* charvariant_list */
- (FT_CMap_VariantCharListFunc) NULL /* variantchar_list */
- };
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/psaux/t1cmap.h b/contrib/libs/freetype/src/psaux/t1cmap.h
deleted file mode 100644
index 445e6a2784..0000000000
--- a/contrib/libs/freetype/src/psaux/t1cmap.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/****************************************************************************
- *
- * t1cmap.h
- *
- * Type 1 character map support (specification).
- *
- * Copyright (C) 2002-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef T1CMAP_H_
-#define T1CMAP_H_
-
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/t1types.h>
-
-FT_BEGIN_HEADER
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** TYPE1 STANDARD (AND EXPERT) ENCODING CMAPS *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- /* standard (and expert) encoding cmaps */
- typedef struct T1_CMapStdRec_* T1_CMapStd;
-
- typedef struct T1_CMapStdRec_
- {
- FT_CMapRec cmap;
-
- const FT_UShort* code_to_sid;
- PS_Adobe_Std_StringsFunc sid_to_string;
-
- FT_UInt num_glyphs;
- const char* const* glyph_names;
-
- } T1_CMapStdRec;
-
-
- FT_CALLBACK_TABLE const FT_CMap_ClassRec
- t1_cmap_standard_class_rec;
-
- FT_CALLBACK_TABLE const FT_CMap_ClassRec
- t1_cmap_expert_class_rec;
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** TYPE1 CUSTOM ENCODING CMAP *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- typedef struct T1_CMapCustomRec_* T1_CMapCustom;
-
- typedef struct T1_CMapCustomRec_
- {
- FT_CMapRec cmap;
- FT_UInt first;
- FT_UInt count;
- FT_UShort* indices;
-
- } T1_CMapCustomRec;
-
-
- FT_CALLBACK_TABLE const FT_CMap_ClassRec
- t1_cmap_custom_class_rec;
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** TYPE1 SYNTHETIC UNICODE ENCODING CMAP *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- /* unicode (synthetic) cmaps */
-
- FT_CALLBACK_TABLE const FT_CMap_ClassRec
- t1_cmap_unicode_class_rec;
-
- /* */
-
-
-FT_END_HEADER
-
-#endif /* T1CMAP_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/psaux/t1decode.c b/contrib/libs/freetype/src/psaux/t1decode.c
deleted file mode 100644
index c74baa8038..0000000000
--- a/contrib/libs/freetype/src/psaux/t1decode.c
+++ /dev/null
@@ -1,2159 +0,0 @@
-/****************************************************************************
- *
- * t1decode.c
- *
- * PostScript Type 1 decoding routines (body).
- *
- * Copyright (C) 2000-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftcalc.h>
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/pshints.h>
-#include <freetype/internal/fthash.h>
-#include <freetype/ftoutln.h>
-
-#include "t1decode.h"
-#include "psobjs.h"
-
-#include "psauxerr.h"
-
-
-/* ensure proper sign extension */
-#define Fix2Int( f ) ( (FT_Int) (FT_Short)( (f) >> 16 ) )
-#define Fix2UInt( f ) ( (FT_UInt)(FT_Short)( (f) >> 16 ) )
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT t1decode
-
-
- typedef enum T1_Operator_
- {
- op_none = 0,
- op_endchar,
- op_hsbw,
- op_seac,
- op_sbw,
- op_closepath,
- op_hlineto,
- op_hmoveto,
- op_hvcurveto,
- op_rlineto,
- op_rmoveto,
- op_rrcurveto,
- op_vhcurveto,
- op_vlineto,
- op_vmoveto,
- op_dotsection,
- op_hstem,
- op_hstem3,
- op_vstem,
- op_vstem3,
- op_div,
- op_callothersubr,
- op_callsubr,
- op_pop,
- op_return,
- op_setcurrentpoint,
- op_unknown15,
-
- op_max /* never remove this one */
-
- } T1_Operator;
-
-
- static
- const FT_Int t1_args_count[op_max] =
- {
- 0, /* none */
- 0, /* endchar */
- 2, /* hsbw */
- 5, /* seac */
- 4, /* sbw */
- 0, /* closepath */
- 1, /* hlineto */
- 1, /* hmoveto */
- 4, /* hvcurveto */
- 2, /* rlineto */
- 2, /* rmoveto */
- 6, /* rrcurveto */
- 4, /* vhcurveto */
- 1, /* vlineto */
- 1, /* vmoveto */
- 0, /* dotsection */
- 2, /* hstem */
- 6, /* hstem3 */
- 2, /* vstem */
- 6, /* vstem3 */
- 2, /* div */
- -1, /* callothersubr */
- 1, /* callsubr */
- 0, /* pop */
- 0, /* return */
- 2, /* setcurrentpoint */
- 2 /* opcode 15 (undocumented and obsolete) */
- };
-
-
- /**************************************************************************
- *
- * @Function:
- * t1_lookup_glyph_by_stdcharcode_ps
- *
- * @Description:
- * Looks up a given glyph by its StandardEncoding charcode. Used to
- * implement the SEAC Type 1 operator in the Adobe engine
- *
- * @Input:
- * face ::
- * The current face object.
- *
- * charcode ::
- * The character code to look for.
- *
- * @Return:
- * A glyph index in the font face. Returns -1 if the corresponding
- * glyph wasn't found.
- */
- FT_LOCAL_DEF( FT_Int )
- t1_lookup_glyph_by_stdcharcode_ps( PS_Decoder* decoder,
- FT_Int charcode )
- {
- FT_UInt n;
- const FT_String* glyph_name;
- FT_Service_PsCMaps psnames = decoder->psnames;
-
-
- /* check range of standard char code */
- if ( charcode < 0 || charcode > 255 )
- return -1;
-
- glyph_name = psnames->adobe_std_strings(
- psnames->adobe_std_encoding[charcode]);
-
- for ( n = 0; n < decoder->num_glyphs; n++ )
- {
- FT_String* name = (FT_String*)decoder->glyph_names[n];
-
-
- if ( name &&
- name[0] == glyph_name[0] &&
- ft_strcmp( name, glyph_name ) == 0 )
- return (FT_Int)n;
- }
-
- return -1;
- }
-
-
-#ifdef T1_CONFIG_OPTION_OLD_ENGINE
-
- /**************************************************************************
- *
- * @Function:
- * t1_lookup_glyph_by_stdcharcode
- *
- * @Description:
- * Looks up a given glyph by its StandardEncoding charcode. Used to
- * implement the SEAC Type 1 operator.
- *
- * @Input:
- * face ::
- * The current face object.
- *
- * charcode ::
- * The character code to look for.
- *
- * @Return:
- * A glyph index in the font face. Returns -1 if the corresponding
- * glyph wasn't found.
- */
- static FT_Int
- t1_lookup_glyph_by_stdcharcode( T1_Decoder decoder,
- FT_Int charcode )
- {
- FT_UInt n;
- const FT_String* glyph_name;
- FT_Service_PsCMaps psnames = decoder->psnames;
-
-
- /* check range of standard char code */
- if ( charcode < 0 || charcode > 255 )
- return -1;
-
- glyph_name = psnames->adobe_std_strings(
- psnames->adobe_std_encoding[charcode]);
-
- for ( n = 0; n < decoder->num_glyphs; n++ )
- {
- FT_String* name = (FT_String*)decoder->glyph_names[n];
-
-
- if ( name &&
- name[0] == glyph_name[0] &&
- ft_strcmp( name, glyph_name ) == 0 )
- return (FT_Int)n;
- }
-
- return -1;
- }
-
-
- /* parse a single Type 1 glyph */
- FT_LOCAL_DEF( FT_Error )
- t1_decoder_parse_glyph( T1_Decoder decoder,
- FT_UInt glyph )
- {
- return decoder->parse_callback( decoder, glyph );
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * t1operator_seac
- *
- * @Description:
- * Implements the `seac' Type 1 operator for a Type 1 decoder.
- *
- * @Input:
- * decoder ::
- * The current CID decoder.
- *
- * asb ::
- * The accent's side bearing.
- *
- * adx ::
- * The horizontal offset of the accent.
- *
- * ady ::
- * The vertical offset of the accent.
- *
- * bchar ::
- * The base character's StandardEncoding charcode.
- *
- * achar ::
- * The accent character's StandardEncoding charcode.
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
- static FT_Error
- t1operator_seac( T1_Decoder decoder,
- FT_Pos asb,
- FT_Pos adx,
- FT_Pos ady,
- FT_Int bchar,
- FT_Int achar )
- {
- FT_Error error;
- FT_Int bchar_index, achar_index;
-#if 0
- FT_Int n_base_points;
- FT_Outline* base = decoder->builder.base;
-#endif
- FT_Vector left_bearing, advance;
-
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- T1_Face face = (T1_Face)decoder->builder.face;
-#endif
-
-
- if ( decoder->seac )
- {
- FT_ERROR(( "t1operator_seac: invalid nested seac\n" ));
- return FT_THROW( Syntax_Error );
- }
-
- if ( decoder->builder.metrics_only )
- {
- FT_ERROR(( "t1operator_seac: unexpected seac\n" ));
- return FT_THROW( Syntax_Error );
- }
-
- /* seac weirdness */
- adx += decoder->builder.left_bearing.x;
-
- /* `glyph_names' is set to 0 for CID fonts which do not */
- /* include an encoding. How can we deal with these? */
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- if ( decoder->glyph_names == 0 &&
- !face->root.internal->incremental_interface )
-#else
- if ( decoder->glyph_names == 0 )
-#endif /* FT_CONFIG_OPTION_INCREMENTAL */
- {
- FT_ERROR(( "t1operator_seac:"
- " glyph names table not available in this font\n" ));
- return FT_THROW( Syntax_Error );
- }
-
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- if ( face->root.internal->incremental_interface )
- {
- /* the caller must handle the font encoding also */
- bchar_index = bchar;
- achar_index = achar;
- }
- else
-#endif
- {
- bchar_index = t1_lookup_glyph_by_stdcharcode( decoder, bchar );
- achar_index = t1_lookup_glyph_by_stdcharcode( decoder, achar );
- }
-
- if ( bchar_index < 0 || achar_index < 0 )
- {
- FT_ERROR(( "t1operator_seac:"
- " invalid seac character code arguments\n" ));
- return FT_THROW( Syntax_Error );
- }
-
- /* if we are trying to load a composite glyph, do not load the */
- /* accent character and return the array of subglyphs. */
- if ( decoder->builder.no_recurse )
- {
- FT_GlyphSlot glyph = (FT_GlyphSlot)decoder->builder.glyph;
- FT_GlyphLoader loader = glyph->internal->loader;
- FT_SubGlyph subg;
-
-
- /* reallocate subglyph array if necessary */
- error = FT_GlyphLoader_CheckSubGlyphs( loader, 2 );
- if ( error )
- goto Exit;
-
- subg = loader->current.subglyphs;
-
- /* subglyph 0 = base character */
- subg->index = bchar_index;
- subg->flags = FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES |
- FT_SUBGLYPH_FLAG_USE_MY_METRICS;
- subg->arg1 = 0;
- subg->arg2 = 0;
- subg++;
-
- /* subglyph 1 = accent character */
- subg->index = achar_index;
- subg->flags = FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES;
- subg->arg1 = (FT_Int)FIXED_TO_INT( adx - asb );
- subg->arg2 = (FT_Int)FIXED_TO_INT( ady );
-
- /* set up remaining glyph fields */
- glyph->num_subglyphs = 2;
- glyph->subglyphs = loader->base.subglyphs;
- glyph->format = FT_GLYPH_FORMAT_COMPOSITE;
-
- loader->current.num_subglyphs = 2;
- goto Exit;
- }
-
- /* First load `bchar' in builder */
- /* now load the unscaled outline */
-
- FT_GlyphLoader_Prepare( decoder->builder.loader ); /* prepare loader */
-
- /* save the left bearing and width of the SEAC */
- /* glyph as they will be erased by the next load */
-
- left_bearing = decoder->builder.left_bearing;
- advance = decoder->builder.advance;
-
- /* the seac operator must not be nested */
- decoder->seac = TRUE;
- error = t1_decoder_parse_glyph( decoder, (FT_UInt)bchar_index );
- decoder->seac = FALSE;
- if ( error )
- goto Exit;
-
- /* If the SEAC glyph doesn't have a (H)SBW of its */
- /* own use the values from the base glyph. */
-
- if ( decoder->builder.parse_state != T1_Parse_Have_Width )
- {
- left_bearing = decoder->builder.left_bearing;
- advance = decoder->builder.advance;
- }
-
- decoder->builder.left_bearing.x = 0;
- decoder->builder.left_bearing.y = 0;
-
- decoder->builder.pos_x = adx - asb;
- decoder->builder.pos_y = ady;
-
- /* Now load `achar' on top of */
- /* the base outline */
-
- /* the seac operator must not be nested */
- decoder->seac = TRUE;
- error = t1_decoder_parse_glyph( decoder, (FT_UInt)achar_index );
- decoder->seac = FALSE;
- if ( error )
- goto Exit;
-
- /* restore the left side bearing and advance width */
- /* of the SEAC glyph or base character (saved above) */
-
- decoder->builder.left_bearing = left_bearing;
- decoder->builder.advance = advance;
-
- decoder->builder.pos_x = 0;
- decoder->builder.pos_y = 0;
-
- Exit:
- return error;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * t1_decoder_parse_charstrings
- *
- * @Description:
- * Parses a given Type 1 charstrings program.
- *
- * @Input:
- * decoder ::
- * The current Type 1 decoder.
- *
- * charstring_base ::
- * The base address of the charstring stream.
- *
- * charstring_len ::
- * The length in bytes of the charstring stream.
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
- FT_LOCAL_DEF( FT_Error )
- t1_decoder_parse_charstrings( T1_Decoder decoder,
- FT_Byte* charstring_base,
- FT_UInt charstring_len )
- {
- FT_Error error;
- T1_Decoder_Zone zone;
- FT_Byte* ip;
- FT_Byte* limit;
- T1_Builder builder = &decoder->builder;
- FT_Pos x, y, orig_x, orig_y;
- FT_Int known_othersubr_result_cnt = 0;
- FT_Int unknown_othersubr_result_cnt = 0;
- FT_Bool large_int;
- FT_Fixed seed;
-
- T1_Hints_Funcs hinter;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- FT_Bool bol = TRUE;
-#endif
-
-
- /* compute random seed from stack address of parameter */
- seed = (FT_Fixed)( ( (FT_Offset)(char*)&seed ^
- (FT_Offset)(char*)&decoder ^
- (FT_Offset)(char*)&charstring_base ) &
- FT_ULONG_MAX );
- seed = ( seed ^ ( seed >> 10 ) ^ ( seed >> 20 ) ) & 0xFFFFL;
- if ( seed == 0 )
- seed = 0x7384;
-
- /* First of all, initialize the decoder */
- decoder->top = decoder->stack;
- decoder->zone = decoder->zones;
- zone = decoder->zones;
-
- builder->parse_state = T1_Parse_Start;
-
- hinter = (T1_Hints_Funcs)builder->hints_funcs;
-
- /* a font that reads BuildCharArray without setting */
- /* its values first is buggy, but ... */
- FT_ASSERT( ( decoder->len_buildchar == 0 ) ==
- ( decoder->buildchar == NULL ) );
-
- if ( decoder->buildchar && decoder->len_buildchar > 0 )
- FT_ARRAY_ZERO( decoder->buildchar, decoder->len_buildchar );
-
- zone->base = charstring_base;
- limit = zone->limit = charstring_base + charstring_len;
- ip = zone->cursor = zone->base;
-
- error = FT_Err_Ok;
-
- x = orig_x = builder->pos_x;
- y = orig_y = builder->pos_y;
-
- /* begin hints recording session, if any */
- if ( hinter )
- hinter->open( hinter->hints );
-
- large_int = FALSE;
-
- /* now, execute loop */
- while ( ip < limit )
- {
- FT_Long* top = decoder->top;
- T1_Operator op = op_none;
- FT_Int32 value = 0;
-
-
- FT_ASSERT( known_othersubr_result_cnt == 0 ||
- unknown_othersubr_result_cnt == 0 );
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( bol )
- {
- FT_TRACE5(( " (%td)", decoder->top - decoder->stack ));
- bol = FALSE;
- }
-#endif
-
- /**********************************************************************
- *
- * Decode operator or operand
- *
- */
-
- /* first of all, decompress operator or value */
- switch ( *ip++ )
- {
- case 1:
- op = op_hstem;
- break;
-
- case 3:
- op = op_vstem;
- break;
- case 4:
- op = op_vmoveto;
- break;
- case 5:
- op = op_rlineto;
- break;
- case 6:
- op = op_hlineto;
- break;
- case 7:
- op = op_vlineto;
- break;
- case 8:
- op = op_rrcurveto;
- break;
- case 9:
- op = op_closepath;
- break;
- case 10:
- op = op_callsubr;
- break;
- case 11:
- op = op_return;
- break;
-
- case 13:
- op = op_hsbw;
- break;
- case 14:
- op = op_endchar;
- break;
-
- case 15: /* undocumented, obsolete operator */
- op = op_unknown15;
- break;
-
- case 21:
- op = op_rmoveto;
- break;
- case 22:
- op = op_hmoveto;
- break;
-
- case 30:
- op = op_vhcurveto;
- break;
- case 31:
- op = op_hvcurveto;
- break;
-
- case 12:
- if ( ip >= limit )
- {
- FT_ERROR(( "t1_decoder_parse_charstrings:"
- " invalid escape (12+EOF)\n" ));
- goto Syntax_Error;
- }
-
- switch ( *ip++ )
- {
- case 0:
- op = op_dotsection;
- break;
- case 1:
- op = op_vstem3;
- break;
- case 2:
- op = op_hstem3;
- break;
- case 6:
- op = op_seac;
- break;
- case 7:
- op = op_sbw;
- break;
- case 12:
- op = op_div;
- break;
- case 16:
- op = op_callothersubr;
- break;
- case 17:
- op = op_pop;
- break;
- case 33:
- op = op_setcurrentpoint;
- break;
-
- default:
- FT_ERROR(( "t1_decoder_parse_charstrings:"
- " invalid escape (12+%d)\n",
- ip[-1] ));
- goto Syntax_Error;
- }
- break;
-
- case 255: /* four bytes integer */
- if ( ip + 4 > limit )
- {
- FT_ERROR(( "t1_decoder_parse_charstrings:"
- " unexpected EOF in integer\n" ));
- goto Syntax_Error;
- }
-
- value = (FT_Int32)( ( (FT_UInt32)ip[0] << 24 ) |
- ( (FT_UInt32)ip[1] << 16 ) |
- ( (FT_UInt32)ip[2] << 8 ) |
- (FT_UInt32)ip[3] );
- ip += 4;
-
- /* According to the specification, values > 32000 or < -32000 must */
- /* be followed by a `div' operator to make the result be in the */
- /* range [-32000;32000]. We expect that the second argument of */
- /* `div' is not a large number. Additionally, we don't handle */
- /* stuff like `<large1> <large2> <num> div <num> div' or */
- /* <large1> <large2> <num> div div'. This is probably not allowed */
- /* anyway. */
- if ( value > 32000 || value < -32000 )
- {
- if ( large_int )
- FT_ERROR(( "t1_decoder_parse_charstrings:"
- " no `div' after large integer\n" ));
- else
- large_int = TRUE;
- }
- else
- {
- if ( !large_int )
- value = (FT_Int32)( (FT_UInt32)value << 16 );
- }
-
- break;
-
- default:
- if ( ip[-1] >= 32 )
- {
- if ( ip[-1] < 247 )
- value = (FT_Int32)ip[-1] - 139;
- else
- {
- if ( ++ip > limit )
- {
- FT_ERROR(( "t1_decoder_parse_charstrings:"
- " unexpected EOF in integer\n" ));
- goto Syntax_Error;
- }
-
- if ( ip[-2] < 251 )
- value = ( ( ip[-2] - 247 ) * 256 ) + ip[-1] + 108;
- else
- value = -( ( ( ip[-2] - 251 ) * 256 ) + ip[-1] + 108 );
- }
-
- if ( !large_int )
- value = (FT_Int32)( (FT_UInt32)value << 16 );
- }
- else
- {
- FT_ERROR(( "t1_decoder_parse_charstrings:"
- " invalid byte (%d)\n", ip[-1] ));
- goto Syntax_Error;
- }
- }
-
- if ( unknown_othersubr_result_cnt > 0 )
- {
- switch ( op )
- {
- case op_callsubr:
- case op_return:
- case op_none:
- case op_pop:
- break;
-
- default:
- /* all operands have been transferred by previous pops */
- unknown_othersubr_result_cnt = 0;
- break;
- }
- }
-
- if ( large_int && !( op == op_none || op == op_div ) )
- {
- FT_ERROR(( "t1_decoder_parse_charstrings:"
- " no `div' after large integer\n" ));
-
- large_int = FALSE;
- }
-
- /**********************************************************************
- *
- * Push value on stack, or process operator
- *
- */
- if ( op == op_none )
- {
- if ( top - decoder->stack >= T1_MAX_CHARSTRINGS_OPERANDS )
- {
- FT_ERROR(( "t1_decoder_parse_charstrings: stack overflow\n" ));
- goto Syntax_Error;
- }
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( large_int )
- FT_TRACE4(( " %d", value ));
- else
- FT_TRACE4(( " %d", value / 65536 ));
-#endif
-
- *top++ = value;
- decoder->top = top;
- }
- else if ( op == op_callothersubr ) /* callothersubr */
- {
- FT_Int subr_no;
- FT_Int arg_cnt;
-
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- FT_TRACE4(( " callothersubr\n" ));
- bol = TRUE;
-#endif
-
- if ( top - decoder->stack < 2 )
- goto Stack_Underflow;
-
- top -= 2;
-
- subr_no = Fix2Int( top[1] );
- arg_cnt = Fix2Int( top[0] );
-
- /************************************************************
- *
- * remove all operands to callothersubr from the stack
- *
- * for handled othersubrs, where we know the number of
- * arguments, we increase the stack by the value of
- * known_othersubr_result_cnt
- *
- * for unhandled othersubrs the following pops adjust the
- * stack pointer as necessary
- */
-
- if ( arg_cnt > top - decoder->stack )
- goto Stack_Underflow;
-
- top -= arg_cnt;
-
- known_othersubr_result_cnt = 0;
- unknown_othersubr_result_cnt = 0;
-
- /* XXX TODO: The checks to `arg_count == <whatever>' */
- /* might not be correct; an othersubr expects a certain */
- /* number of operands on the PostScript stack (as opposed */
- /* to the T1 stack) but it doesn't have to put them there */
- /* by itself; previous othersubrs might have left the */
- /* operands there if they were not followed by an */
- /* appropriate number of pops */
- /* */
- /* On the other hand, Adobe Reader 7.0.8 for Linux doesn't */
- /* accept a font that contains charstrings like */
- /* */
- /* 100 200 2 20 callothersubr */
- /* 300 1 20 callothersubr pop */
- /* */
- /* Perhaps this is the reason why BuildCharArray exists. */
-
- switch ( subr_no )
- {
- case 0: /* end flex feature */
- if ( arg_cnt != 3 )
- goto Unexpected_OtherSubr;
-
- if ( !decoder->flex_state ||
- decoder->num_flex_vectors != 7 )
- {
- FT_ERROR(( "t1_decoder_parse_charstrings:"
- " unexpected flex end\n" ));
- goto Syntax_Error;
- }
-
- /* the two `results' are popped by the following setcurrentpoint */
- top[0] = x;
- top[1] = y;
- known_othersubr_result_cnt = 2;
- break;
-
- case 1: /* start flex feature */
- if ( arg_cnt != 0 )
- goto Unexpected_OtherSubr;
-
- if ( FT_SET_ERROR( t1_builder_start_point( builder, x, y ) ) ||
- FT_SET_ERROR( t1_builder_check_points( builder, 6 ) ) )
- goto Fail;
-
- decoder->flex_state = 1;
- decoder->num_flex_vectors = 0;
- break;
-
- case 2: /* add flex vectors */
- {
- FT_Int idx;
-
-
- if ( arg_cnt != 0 )
- goto Unexpected_OtherSubr;
-
- if ( !decoder->flex_state )
- {
- FT_ERROR(( "t1_decoder_parse_charstrings:"
- " missing flex start\n" ));
- goto Syntax_Error;
- }
-
- /* note that we should not add a point for index 0; */
- /* this will move our current position to the flex */
- /* point without adding any point to the outline */
- idx = decoder->num_flex_vectors++;
- if ( idx > 0 && idx < 7 )
- {
- /* in malformed fonts it is possible to have other */
- /* opcodes in the middle of a flex (which don't */
- /* increase `num_flex_vectors'); we thus have to */
- /* check whether we can add a point */
- if ( FT_SET_ERROR( t1_builder_check_points( builder, 1 ) ) )
- goto Syntax_Error;
-
- t1_builder_add_point( builder,
- x,
- y,
- (FT_Byte)( idx == 3 || idx == 6 ) );
- }
- }
- break;
-
- case 3: /* change hints */
- if ( arg_cnt != 1 )
- goto Unexpected_OtherSubr;
-
- known_othersubr_result_cnt = 1;
-
- if ( hinter )
- hinter->reset( hinter->hints,
- (FT_UInt)builder->current->n_points );
- break;
-
- case 12:
- case 13:
- /* counter control hints, clear stack */
- top = decoder->stack;
- break;
-
- case 14:
- case 15:
- case 16:
- case 17:
- case 18: /* multiple masters */
- {
- PS_Blend blend = decoder->blend;
- FT_UInt num_points, nn, mm;
- FT_Long* delta;
- FT_Long* values;
-
-
- if ( !blend )
- {
- FT_ERROR(( "t1_decoder_parse_charstrings:"
- " unexpected multiple masters operator\n" ));
- goto Syntax_Error;
- }
-
- num_points = (FT_UInt)subr_no - 13 + ( subr_no == 18 );
- if ( arg_cnt != (FT_Int)( num_points * blend->num_designs ) )
- {
- FT_ERROR(( "t1_decoder_parse_charstrings:"
- " incorrect number of multiple masters arguments\n" ));
- goto Syntax_Error;
- }
-
- /* We want to compute */
- /* */
- /* a0*w0 + a1*w1 + ... + ak*wk */
- /* */
- /* but we only have a0, a1-a0, a2-a0, ..., ak-a0. */
- /* */
- /* However, given that w0 + w1 + ... + wk == 1, we can */
- /* rewrite it easily as */
- /* */
- /* a0 + (a1-a0)*w1 + (a2-a0)*w2 + ... + (ak-a0)*wk */
- /* */
- /* where k == num_designs-1. */
- /* */
- /* I guess that's why it's written in this `compact' */
- /* form. */
- /* */
- delta = top + num_points;
- values = top;
- for ( nn = 0; nn < num_points; nn++ )
- {
- FT_Long tmp = values[0];
-
-
- for ( mm = 1; mm < blend->num_designs; mm++ )
- tmp = ADD_LONG( tmp,
- FT_MulFix( *delta++,
- blend->weight_vector[mm] ) );
-
- *values++ = tmp;
- }
-
- known_othersubr_result_cnt = (FT_Int)num_points;
- break;
- }
-
- case 19:
- /* <idx> 1 19 callothersubr */
- /* => replace elements starting from index cvi( <idx> ) */
- /* of BuildCharArray with WeightVector */
- {
- FT_Int idx;
- PS_Blend blend = decoder->blend;
-
-
- if ( arg_cnt != 1 || !blend )
- goto Unexpected_OtherSubr;
-
- idx = Fix2Int( top[0] );
-
- if ( idx < 0 ||
- (FT_UInt)idx + blend->num_designs > decoder->len_buildchar )
- goto Unexpected_OtherSubr;
-
- ft_memcpy( &decoder->buildchar[idx],
- blend->weight_vector,
- blend->num_designs *
- sizeof ( blend->weight_vector[0] ) );
- }
- break;
-
- case 20:
- /* <arg1> <arg2> 2 20 callothersubr pop */
- /* ==> push <arg1> + <arg2> onto T1 stack */
- if ( arg_cnt != 2 )
- goto Unexpected_OtherSubr;
-
- top[0] = ADD_LONG( top[0], top[1] );
-
- known_othersubr_result_cnt = 1;
- break;
-
- case 21:
- /* <arg1> <arg2> 2 21 callothersubr pop */
- /* ==> push <arg1> - <arg2> onto T1 stack */
- if ( arg_cnt != 2 )
- goto Unexpected_OtherSubr;
-
- top[0] = SUB_LONG( top[0], top[1] );
-
- known_othersubr_result_cnt = 1;
- break;
-
- case 22:
- /* <arg1> <arg2> 2 22 callothersubr pop */
- /* ==> push <arg1> * <arg2> onto T1 stack */
- if ( arg_cnt != 2 )
- goto Unexpected_OtherSubr;
-
- top[0] = FT_MulFix( top[0], top[1] );
-
- known_othersubr_result_cnt = 1;
- break;
-
- case 23:
- /* <arg1> <arg2> 2 23 callothersubr pop */
- /* ==> push <arg1> / <arg2> onto T1 stack */
- if ( arg_cnt != 2 || top[1] == 0 )
- goto Unexpected_OtherSubr;
-
- top[0] = FT_DivFix( top[0], top[1] );
-
- known_othersubr_result_cnt = 1;
- break;
-
- case 24:
- /* <val> <idx> 2 24 callothersubr */
- /* ==> set BuildCharArray[cvi( <idx> )] = <val> */
- {
- FT_UInt idx;
- PS_Blend blend = decoder->blend;
-
-
- if ( arg_cnt != 2 || !blend )
- goto Unexpected_OtherSubr;
-
- idx = Fix2UInt( top[1] );
-
- if ( idx >= decoder->len_buildchar )
- goto Unexpected_OtherSubr;
-
- decoder->buildchar[idx] = top[0];
- }
- break;
-
- case 25:
- /* <idx> 1 25 callothersubr pop */
- /* ==> push BuildCharArray[cvi( idx )] */
- /* onto T1 stack */
- {
- FT_UInt idx;
- PS_Blend blend = decoder->blend;
-
-
- if ( arg_cnt != 1 || !blend )
- goto Unexpected_OtherSubr;
-
- idx = Fix2UInt( top[0] );
-
- if ( idx >= decoder->len_buildchar )
- goto Unexpected_OtherSubr;
-
- top[0] = decoder->buildchar[idx];
- }
-
- known_othersubr_result_cnt = 1;
- break;
-
-#if 0
- case 26:
- /* <val> mark <idx> ==> set BuildCharArray[cvi( <idx> )] = <val>, */
- /* leave mark on T1 stack */
- /* <val> <idx> ==> set BuildCharArray[cvi( <idx> )] = <val> */
- XXX which routine has left its mark on the (PostScript) stack?;
- break;
-#endif
-
- case 27:
- /* <res1> <res2> <val1> <val2> 4 27 callothersubr pop */
- /* ==> push <res1> onto T1 stack if <val1> <= <val2>, */
- /* otherwise push <res2> */
- if ( arg_cnt != 4 )
- goto Unexpected_OtherSubr;
-
- if ( top[2] > top[3] )
- top[0] = top[1];
-
- known_othersubr_result_cnt = 1;
- break;
-
- case 28:
- /* 0 28 callothersubr pop */
- /* => push random value from interval [0, 1) onto stack */
- if ( arg_cnt != 0 )
- goto Unexpected_OtherSubr;
-
- {
- FT_Fixed Rand;
-
-
- Rand = seed;
- if ( Rand >= 0x8000L )
- Rand++;
-
- top[0] = Rand;
-
- seed = FT_MulFix( seed, 0x10000L - seed );
- if ( seed == 0 )
- seed += 0x2873;
- }
-
- known_othersubr_result_cnt = 1;
- break;
-
- default:
- if ( arg_cnt >= 0 && subr_no >= 0 )
- {
- FT_ERROR(( "t1_decoder_parse_charstrings:"
- " unknown othersubr [%d %d], wish me luck\n",
- arg_cnt, subr_no ));
- unknown_othersubr_result_cnt = arg_cnt;
- break;
- }
- /* fall through */
-
- Unexpected_OtherSubr:
- FT_ERROR(( "t1_decoder_parse_charstrings:"
- " invalid othersubr [%d %d]\n", arg_cnt, subr_no ));
- goto Syntax_Error;
- }
-
- top += known_othersubr_result_cnt;
-
- decoder->top = top;
- }
- else /* general operator */
- {
- FT_Int num_args = t1_args_count[op];
-
-
- FT_ASSERT( num_args >= 0 );
-
- if ( top - decoder->stack < num_args )
- goto Stack_Underflow;
-
- /* XXX Operators usually take their operands from the */
- /* bottom of the stack, i.e., the operands are */
- /* decoder->stack[0], ..., decoder->stack[num_args - 1]; */
- /* only div, callsubr, and callothersubr are different. */
- /* In practice it doesn't matter (?). */
-
-#ifdef FT_DEBUG_LEVEL_TRACE
-
- switch ( op )
- {
- case op_callsubr:
- case op_div:
- case op_callothersubr:
- case op_pop:
- case op_return:
- break;
-
- default:
- if ( top - decoder->stack != num_args )
- FT_TRACE0(( "t1_decoder_parse_charstrings:"
- " too much operands on the stack"
- " (seen %td, expected %d)\n",
- top - decoder->stack, num_args ));
- break;
- }
-
-#endif /* FT_DEBUG_LEVEL_TRACE */
-
- top -= num_args;
-
- switch ( op )
- {
- case op_endchar:
- FT_TRACE4(( " endchar\n" ));
-
- t1_builder_close_contour( builder );
-
- /* close hints recording session */
- if ( hinter )
- {
- if ( hinter->close( hinter->hints,
- (FT_UInt)builder->current->n_points ) )
- goto Syntax_Error;
-
- /* apply hints to the loaded glyph outline now */
- error = hinter->apply( hinter->hints,
- builder->current,
- (PSH_Globals)builder->hints_globals,
- decoder->hint_mode );
- if ( error )
- goto Fail;
- }
-
- /* add current outline to the glyph slot */
- FT_GlyphLoader_Add( builder->loader );
-
- /* the compiler should optimize away this empty loop but ... */
-
-#ifdef FT_DEBUG_LEVEL_TRACE
-
- if ( decoder->len_buildchar > 0 )
- {
- FT_UInt i;
-
-
- FT_TRACE4(( "BuildCharArray = [ " ));
-
- for ( i = 0; i < decoder->len_buildchar; i++ )
- FT_TRACE4(( "%ld ", decoder->buildchar[i] ));
-
- FT_TRACE4(( "]\n" ));
- }
-
-#endif /* FT_DEBUG_LEVEL_TRACE */
-
- FT_TRACE4(( "\n" ));
-
- /* return now! */
- return FT_Err_Ok;
-
- case op_hsbw:
- FT_TRACE4(( " hsbw" ));
-
- builder->parse_state = T1_Parse_Have_Width;
-
- builder->left_bearing.x = ADD_LONG( builder->left_bearing.x,
- top[0] );
-
- builder->advance.x = top[1];
- builder->advance.y = 0;
-
- orig_x = x = ADD_LONG( builder->pos_x, top[0] );
- orig_y = y = builder->pos_y;
-
- FT_UNUSED( orig_y );
-
- /* `metrics_only' indicates that we only want to compute the */
- /* glyph's metrics (lsb + advance width) without loading the */
- /* rest of it; so exit immediately */
- if ( builder->metrics_only )
- {
- FT_TRACE4(( "\n" ));
- return FT_Err_Ok;
- }
-
- break;
-
- case op_seac:
- return t1operator_seac( decoder,
- top[0],
- top[1],
- top[2],
- Fix2Int( top[3] ),
- Fix2Int( top[4] ) );
-
- case op_sbw:
- FT_TRACE4(( " sbw" ));
-
- builder->parse_state = T1_Parse_Have_Width;
-
- builder->left_bearing.x = ADD_LONG( builder->left_bearing.x,
- top[0] );
- builder->left_bearing.y = ADD_LONG( builder->left_bearing.y,
- top[1] );
-
- builder->advance.x = top[2];
- builder->advance.y = top[3];
-
- x = ADD_LONG( builder->pos_x, top[0] );
- y = ADD_LONG( builder->pos_y, top[1] );
-
- /* `metrics_only' indicates that we only want to compute the */
- /* glyph's metrics (lsb + advance width) without loading the */
- /* rest of it; so exit immediately */
- if ( builder->metrics_only )
- {
- FT_TRACE4(( "\n" ));
- return FT_Err_Ok;
- }
-
- break;
-
- case op_closepath:
- FT_TRACE4(( " closepath" ));
-
- /* if there is no path, `closepath' is a no-op */
- if ( builder->parse_state == T1_Parse_Have_Path ||
- builder->parse_state == T1_Parse_Have_Moveto )
- t1_builder_close_contour( builder );
-
- builder->parse_state = T1_Parse_Have_Width;
- break;
-
- case op_hlineto:
- FT_TRACE4(( " hlineto" ));
-
- if ( FT_SET_ERROR( t1_builder_start_point( builder, x, y ) ) )
- goto Fail;
-
- x = ADD_LONG( x, top[0] );
- goto Add_Line;
-
- case op_hmoveto:
- FT_TRACE4(( " hmoveto" ));
-
- x = ADD_LONG( x, top[0] );
-
- if ( !decoder->flex_state )
- {
- if ( builder->parse_state == T1_Parse_Start )
- goto Syntax_Error;
- builder->parse_state = T1_Parse_Have_Moveto;
- }
- break;
-
- case op_hvcurveto:
- FT_TRACE4(( " hvcurveto" ));
-
- if ( FT_SET_ERROR( t1_builder_start_point( builder, x, y ) ) ||
- FT_SET_ERROR( t1_builder_check_points( builder, 3 ) ) )
- goto Fail;
-
- x = ADD_LONG( x, top[0] );
- t1_builder_add_point( builder, x, y, 0 );
-
- x = ADD_LONG( x, top[1] );
- y = ADD_LONG( y, top[2] );
- t1_builder_add_point( builder, x, y, 0 );
-
- y = ADD_LONG( y, top[3] );
- t1_builder_add_point( builder, x, y, 1 );
- break;
-
- case op_rlineto:
- FT_TRACE4(( " rlineto" ));
-
- if ( FT_SET_ERROR( t1_builder_start_point( builder, x, y ) ) )
- goto Fail;
-
- x = ADD_LONG( x, top[0] );
- y = ADD_LONG( y, top[1] );
-
- Add_Line:
- if ( FT_SET_ERROR( t1_builder_add_point1( builder, x, y ) ) )
- goto Fail;
- break;
-
- case op_rmoveto:
- FT_TRACE4(( " rmoveto" ));
-
- x = ADD_LONG( x, top[0] );
- y = ADD_LONG( y, top[1] );
-
- if ( !decoder->flex_state )
- {
- if ( builder->parse_state == T1_Parse_Start )
- goto Syntax_Error;
- builder->parse_state = T1_Parse_Have_Moveto;
- }
- break;
-
- case op_rrcurveto:
- FT_TRACE4(( " rrcurveto" ));
-
- if ( FT_SET_ERROR( t1_builder_start_point( builder, x, y ) ) ||
- FT_SET_ERROR( t1_builder_check_points( builder, 3 ) ) )
- goto Fail;
-
- x = ADD_LONG( x, top[0] );
- y = ADD_LONG( y, top[1] );
- t1_builder_add_point( builder, x, y, 0 );
-
- x = ADD_LONG( x, top[2] );
- y = ADD_LONG( y, top[3] );
- t1_builder_add_point( builder, x, y, 0 );
-
- x = ADD_LONG( x, top[4] );
- y = ADD_LONG( y, top[5] );
- t1_builder_add_point( builder, x, y, 1 );
- break;
-
- case op_vhcurveto:
- FT_TRACE4(( " vhcurveto" ));
-
- if ( FT_SET_ERROR( t1_builder_start_point( builder, x, y ) ) ||
- FT_SET_ERROR( t1_builder_check_points( builder, 3 ) ) )
- goto Fail;
-
- y = ADD_LONG( y, top[0] );
- t1_builder_add_point( builder, x, y, 0 );
-
- x = ADD_LONG( x, top[1] );
- y = ADD_LONG( y, top[2] );
- t1_builder_add_point( builder, x, y, 0 );
-
- x = ADD_LONG( x, top[3] );
- t1_builder_add_point( builder, x, y, 1 );
- break;
-
- case op_vlineto:
- FT_TRACE4(( " vlineto" ));
-
- if ( FT_SET_ERROR( t1_builder_start_point( builder, x, y ) ) )
- goto Fail;
-
- y = ADD_LONG( y, top[0] );
- goto Add_Line;
-
- case op_vmoveto:
- FT_TRACE4(( " vmoveto" ));
-
- y = ADD_LONG( y, top[0] );
-
- if ( !decoder->flex_state )
- {
- if ( builder->parse_state == T1_Parse_Start )
- goto Syntax_Error;
- builder->parse_state = T1_Parse_Have_Moveto;
- }
- break;
-
- case op_div:
- FT_TRACE4(( " div" ));
-
- /* if `large_int' is set, we divide unscaled numbers; */
- /* otherwise, we divide numbers in 16.16 format -- */
- /* in both cases, it is the same operation */
- *top = FT_DivFix( top[0], top[1] );
- top++;
-
- large_int = FALSE;
- break;
-
- case op_callsubr:
- {
- FT_Int idx;
-
-
- FT_TRACE4(( " callsubr" ));
-
- idx = Fix2Int( top[0] );
-
- if ( decoder->subrs_hash )
- {
- size_t* val = ft_hash_num_lookup( idx,
- decoder->subrs_hash );
-
-
- if ( val )
- idx = *val;
- else
- idx = -1;
- }
-
- if ( idx < 0 || idx >= decoder->num_subrs )
- {
- FT_ERROR(( "t1_decoder_parse_charstrings:"
- " invalid subrs index\n" ));
- goto Syntax_Error;
- }
-
- if ( zone - decoder->zones >= T1_MAX_SUBRS_CALLS )
- {
- FT_ERROR(( "t1_decoder_parse_charstrings:"
- " too many nested subrs\n" ));
- goto Syntax_Error;
- }
-
- zone->cursor = ip; /* save current instruction pointer */
-
- zone++;
-
- /* The Type 1 driver stores subroutines without the seed bytes. */
- /* The CID driver stores subroutines with seed bytes. This */
- /* case is taken care of when decoder->subrs_len == 0. */
- zone->base = decoder->subrs[idx];
-
- if ( decoder->subrs_len )
- zone->limit = zone->base + decoder->subrs_len[idx];
- else
- {
- /* We are using subroutines from a CID font. We must adjust */
- /* for the seed bytes. */
- zone->base += ( decoder->lenIV >= 0 ? decoder->lenIV : 0 );
- zone->limit = decoder->subrs[idx + 1];
- }
-
- zone->cursor = zone->base;
-
- if ( !zone->base )
- {
- FT_ERROR(( "t1_decoder_parse_charstrings:"
- " invoking empty subrs\n" ));
- goto Syntax_Error;
- }
-
- decoder->zone = zone;
- ip = zone->base;
- limit = zone->limit;
- break;
- }
-
- case op_pop:
- FT_TRACE4(( " pop" ));
-
- if ( known_othersubr_result_cnt > 0 )
- {
- known_othersubr_result_cnt--;
- /* ignore, we pushed the operands ourselves */
- break;
- }
-
- if ( unknown_othersubr_result_cnt == 0 )
- {
- FT_ERROR(( "t1_decoder_parse_charstrings:"
- " no more operands for othersubr\n" ));
- goto Syntax_Error;
- }
-
- unknown_othersubr_result_cnt--;
- top++; /* `push' the operand to callothersubr onto the stack */
- break;
-
- case op_return:
- FT_TRACE4(( " return" ));
-
- if ( zone <= decoder->zones )
- {
- FT_ERROR(( "t1_decoder_parse_charstrings:"
- " unexpected return\n" ));
- goto Syntax_Error;
- }
-
- zone--;
- ip = zone->cursor;
- limit = zone->limit;
- decoder->zone = zone;
- break;
-
- case op_dotsection:
- FT_TRACE4(( " dotsection" ));
-
- break;
-
- case op_hstem:
- FT_TRACE4(( " hstem" ));
-
- /* record horizontal hint */
- if ( hinter )
- {
- /* top[0] += builder->left_bearing.y; */
- hinter->stem( hinter->hints, 1, top );
- }
- break;
-
- case op_hstem3:
- FT_TRACE4(( " hstem3" ));
-
- /* record horizontal counter-controlled hints */
- if ( hinter )
- hinter->stem3( hinter->hints, 1, top );
- break;
-
- case op_vstem:
- FT_TRACE4(( " vstem" ));
-
- /* record vertical hint */
- if ( hinter )
- {
- top[0] = ADD_LONG( top[0], orig_x );
- hinter->stem( hinter->hints, 0, top );
- }
- break;
-
- case op_vstem3:
- FT_TRACE4(( " vstem3" ));
-
- /* record vertical counter-controlled hints */
- if ( hinter )
- {
- FT_Pos dx = orig_x;
-
-
- top[0] = ADD_LONG( top[0], dx );
- top[2] = ADD_LONG( top[2], dx );
- top[4] = ADD_LONG( top[4], dx );
- hinter->stem3( hinter->hints, 0, top );
- }
- break;
-
- case op_setcurrentpoint:
- FT_TRACE4(( " setcurrentpoint" ));
-
- /* From the T1 specification, section 6.4: */
- /* */
- /* The setcurrentpoint command is used only in */
- /* conjunction with results from OtherSubrs procedures. */
-
- /* known_othersubr_result_cnt != 0 is already handled */
- /* above. */
-
- /* Note, however, that both Ghostscript and Adobe */
- /* Distiller handle this situation by silently ignoring */
- /* the inappropriate `setcurrentpoint' instruction. So */
- /* we do the same. */
-#if 0
-
- if ( decoder->flex_state != 1 )
- {
- FT_ERROR(( "t1_decoder_parse_charstrings:"
- " unexpected `setcurrentpoint'\n" ));
- goto Syntax_Error;
- }
- else
- ...
-#endif
-
- x = top[0];
- y = top[1];
- decoder->flex_state = 0;
- break;
-
- case op_unknown15:
- FT_TRACE4(( " opcode_15" ));
- /* nothing to do except to pop the two arguments */
- break;
-
- default:
- FT_ERROR(( "t1_decoder_parse_charstrings:"
- " unhandled opcode %d\n", op ));
- goto Syntax_Error;
- }
-
- /* XXX Operators usually clear the operand stack; */
- /* only div, callsubr, callothersubr, pop, and */
- /* return are different. */
- /* In practice it doesn't matter (?). */
-
- decoder->top = top;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- FT_TRACE4(( "\n" ));
- bol = TRUE;
-#endif
-
- } /* general operator processing */
-
- } /* while ip < limit */
-
- FT_TRACE4(( "..end..\n" ));
- FT_TRACE4(( "\n" ));
-
- Fail:
- return error;
-
- Syntax_Error:
- return FT_THROW( Syntax_Error );
-
- Stack_Underflow:
- return FT_THROW( Stack_Underflow );
- }
-
-
-#else /* !T1_CONFIG_OPTION_OLD_ENGINE */
-
-
- /**************************************************************************
- *
- * @Function:
- * t1_decoder_parse_metrics
- *
- * @Description:
- * Parses a given Type 1 charstrings program to extract width
- *
- * @Input:
- * decoder ::
- * The current Type 1 decoder.
- *
- * charstring_base ::
- * The base address of the charstring stream.
- *
- * charstring_len ::
- * The length in bytes of the charstring stream.
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
- FT_LOCAL_DEF( FT_Error )
- t1_decoder_parse_metrics( T1_Decoder decoder,
- FT_Byte* charstring_base,
- FT_UInt charstring_len )
- {
- T1_Decoder_Zone zone;
- FT_Byte* ip;
- FT_Byte* limit;
- T1_Builder builder = &decoder->builder;
- FT_Bool large_int;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- FT_Bool bol = TRUE;
-#endif
-
-
- /* First of all, initialize the decoder */
- decoder->top = decoder->stack;
- decoder->zone = decoder->zones;
- zone = decoder->zones;
-
- builder->parse_state = T1_Parse_Start;
-
- zone->base = charstring_base;
- limit = zone->limit = charstring_base + charstring_len;
- ip = zone->cursor = zone->base;
-
- large_int = FALSE;
-
- /* now, execute loop */
- while ( ip < limit )
- {
- FT_Long* top = decoder->top;
- T1_Operator op = op_none;
- FT_Int32 value = 0;
-
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( bol )
- {
- FT_TRACE5(( " (%ld)", decoder->top - decoder->stack ));
- bol = FALSE;
- }
-#endif
-
- /**********************************************************************
- *
- * Decode operator or operand
- *
- */
-
- /* first of all, decompress operator or value */
- switch ( *ip++ )
- {
- case 1:
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- case 8:
- case 9:
- case 14:
- case 15:
- case 21:
- case 22:
- case 30:
- case 31:
- goto No_Width;
-
- case 10:
- op = op_callsubr;
- break;
- case 11:
- op = op_return;
- break;
-
- case 13:
- op = op_hsbw;
- break;
-
- case 12:
- if ( ip >= limit )
- {
- FT_ERROR(( "t1_decoder_parse_metrics:"
- " invalid escape (12+EOF)\n" ));
- goto Syntax_Error;
- }
-
- switch ( *ip++ )
- {
- case 7:
- op = op_sbw;
- break;
- case 12:
- op = op_div;
- break;
-
- default:
- goto No_Width;
- }
- break;
-
- case 255: /* four bytes integer */
- if ( ip + 4 > limit )
- {
- FT_ERROR(( "t1_decoder_parse_metrics:"
- " unexpected EOF in integer\n" ));
- goto Syntax_Error;
- }
-
- value = (FT_Int32)( ( (FT_UInt32)ip[0] << 24 ) |
- ( (FT_UInt32)ip[1] << 16 ) |
- ( (FT_UInt32)ip[2] << 8 ) |
- (FT_UInt32)ip[3] );
- ip += 4;
-
- /* According to the specification, values > 32000 or < -32000 must */
- /* be followed by a `div' operator to make the result be in the */
- /* range [-32000;32000]. We expect that the second argument of */
- /* `div' is not a large number. Additionally, we don't handle */
- /* stuff like `<large1> <large2> <num> div <num> div' or */
- /* <large1> <large2> <num> div div'. This is probably not allowed */
- /* anyway. */
- if ( value > 32000 || value < -32000 )
- {
- if ( large_int )
- {
- FT_ERROR(( "t1_decoder_parse_metrics:"
- " no `div' after large integer\n" ));
- goto Syntax_Error;
- }
- else
- large_int = TRUE;
- }
- else
- {
- if ( !large_int )
- value = (FT_Int32)( (FT_UInt32)value << 16 );
- }
-
- break;
-
- default:
- if ( ip[-1] >= 32 )
- {
- if ( ip[-1] < 247 )
- value = (FT_Int32)ip[-1] - 139;
- else
- {
- if ( ++ip > limit )
- {
- FT_ERROR(( "t1_decoder_parse_metrics:"
- " unexpected EOF in integer\n" ));
- goto Syntax_Error;
- }
-
- if ( ip[-2] < 251 )
- value = ( ( ip[-2] - 247 ) * 256 ) + ip[-1] + 108;
- else
- value = -( ( ( ip[-2] - 251 ) * 256 ) + ip[-1] + 108 );
- }
-
- if ( !large_int )
- value = (FT_Int32)( (FT_UInt32)value << 16 );
- }
- else
- {
- FT_ERROR(( "t1_decoder_parse_metrics:"
- " invalid byte (%d)\n", ip[-1] ));
- goto Syntax_Error;
- }
- }
-
- if ( large_int && !( op == op_none || op == op_div ) )
- {
- FT_ERROR(( "t1_decoder_parse_metrics:"
- " no `div' after large integer\n" ));
- goto Syntax_Error;
- }
-
- /**********************************************************************
- *
- * Push value on stack, or process operator
- *
- */
- if ( op == op_none )
- {
- if ( top - decoder->stack >= T1_MAX_CHARSTRINGS_OPERANDS )
- {
- FT_ERROR(( "t1_decoder_parse_metrics: stack overflow\n" ));
- goto Syntax_Error;
- }
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( large_int )
- FT_TRACE4(( " %d", value ));
- else
- FT_TRACE4(( " %d", value / 65536 ));
-#endif
-
- *top++ = value;
- decoder->top = top;
- }
- else /* general operator */
- {
- FT_Int num_args = t1_args_count[op];
-
-
- FT_ASSERT( num_args >= 0 );
-
- if ( top - decoder->stack < num_args )
- goto Stack_Underflow;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
-
- switch ( op )
- {
- case op_callsubr:
- case op_div:
- case op_return:
- break;
-
- default:
- if ( top - decoder->stack != num_args )
- FT_TRACE0(( "t1_decoder_parse_metrics:"
- " too much operands on the stack"
- " (seen %ld, expected %d)\n",
- top - decoder->stack, num_args ));
- break;
- }
-
-#endif /* FT_DEBUG_LEVEL_TRACE */
-
- top -= num_args;
-
- switch ( op )
- {
- case op_hsbw:
- FT_TRACE4(( " hsbw" ));
-
- builder->parse_state = T1_Parse_Have_Width;
-
- builder->left_bearing.x = ADD_LONG( builder->left_bearing.x,
- top[0] );
-
- builder->advance.x = top[1];
- builder->advance.y = 0;
-
- /* we only want to compute the glyph's metrics */
- /* (lsb + advance width) without loading the */
- /* rest of it; so exit immediately */
- FT_TRACE4(( "\n" ));
- return FT_Err_Ok;
-
- case op_sbw:
- FT_TRACE4(( " sbw" ));
-
- builder->parse_state = T1_Parse_Have_Width;
-
- builder->left_bearing.x = ADD_LONG( builder->left_bearing.x,
- top[0] );
- builder->left_bearing.y = ADD_LONG( builder->left_bearing.y,
- top[1] );
-
- builder->advance.x = top[2];
- builder->advance.y = top[3];
-
- /* we only want to compute the glyph's metrics */
- /* (lsb + advance width), without loading the */
- /* rest of it; so exit immediately */
- FT_TRACE4(( "\n" ));
- return FT_Err_Ok;
-
- case op_div:
- FT_TRACE4(( " div" ));
-
- /* if `large_int' is set, we divide unscaled numbers; */
- /* otherwise, we divide numbers in 16.16 format -- */
- /* in both cases, it is the same operation */
- *top = FT_DivFix( top[0], top[1] );
- top++;
-
- large_int = FALSE;
- break;
-
- case op_callsubr:
- {
- FT_Int idx;
-
-
- FT_TRACE4(( " callsubr" ));
-
- idx = Fix2Int( top[0] );
-
- if ( decoder->subrs_hash )
- {
- size_t* val = ft_hash_num_lookup( idx,
- decoder->subrs_hash );
-
-
- if ( val )
- idx = *val;
- else
- idx = -1;
- }
-
- if ( idx < 0 || idx >= decoder->num_subrs )
- {
- FT_ERROR(( "t1_decoder_parse_metrics:"
- " invalid subrs index\n" ));
- goto Syntax_Error;
- }
-
- if ( zone - decoder->zones >= T1_MAX_SUBRS_CALLS )
- {
- FT_ERROR(( "t1_decoder_parse_metrics:"
- " too many nested subrs\n" ));
- goto Syntax_Error;
- }
-
- zone->cursor = ip; /* save current instruction pointer */
-
- zone++;
-
- /* The Type 1 driver stores subroutines without the seed bytes. */
- /* The CID driver stores subroutines with seed bytes. This */
- /* case is taken care of when decoder->subrs_len == 0. */
- zone->base = decoder->subrs[idx];
-
- if ( decoder->subrs_len )
- zone->limit = zone->base + decoder->subrs_len[idx];
- else
- {
- /* We are using subroutines from a CID font. We must adjust */
- /* for the seed bytes. */
- zone->base += ( decoder->lenIV >= 0 ? decoder->lenIV : 0 );
- zone->limit = decoder->subrs[idx + 1];
- }
-
- zone->cursor = zone->base;
-
- if ( !zone->base )
- {
- FT_ERROR(( "t1_decoder_parse_metrics:"
- " invoking empty subrs\n" ));
- goto Syntax_Error;
- }
-
- decoder->zone = zone;
- ip = zone->base;
- limit = zone->limit;
- break;
- }
-
- case op_return:
- FT_TRACE4(( " return" ));
-
- if ( zone <= decoder->zones )
- {
- FT_ERROR(( "t1_decoder_parse_metrics:"
- " unexpected return\n" ));
- goto Syntax_Error;
- }
-
- zone--;
- ip = zone->cursor;
- limit = zone->limit;
- decoder->zone = zone;
- break;
-
- default:
- FT_ERROR(( "t1_decoder_parse_metrics:"
- " unhandled opcode %d\n", op ));
- goto Syntax_Error;
- }
-
- decoder->top = top;
-
- } /* general operator processing */
-
- } /* while ip < limit */
-
- FT_TRACE4(( "..end..\n" ));
- FT_TRACE4(( "\n" ));
-
- No_Width:
- FT_ERROR(( "t1_decoder_parse_metrics:"
- " no width, found op %d instead\n",
- ip[-1] ));
- Syntax_Error:
- return FT_THROW( Syntax_Error );
-
- Stack_Underflow:
- return FT_THROW( Stack_Underflow );
- }
-
-#endif /* !T1_CONFIG_OPTION_OLD_ENGINE */
-
-
- /* initialize T1 decoder */
- FT_LOCAL_DEF( FT_Error )
- t1_decoder_init( T1_Decoder decoder,
- FT_Face face,
- FT_Size size,
- FT_GlyphSlot slot,
- FT_Byte** glyph_names,
- PS_Blend blend,
- FT_Bool hinting,
- FT_Render_Mode hint_mode,
- T1_Decoder_Callback parse_callback )
- {
- FT_ZERO( decoder );
-
- /* retrieve `psnames' interface from list of current modules */
- {
- FT_Service_PsCMaps psnames;
-
-
- FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS );
- if ( !psnames )
- {
- FT_ERROR(( "t1_decoder_init:"
- " the `psnames' module is not available\n" ));
- return FT_THROW( Unimplemented_Feature );
- }
-
- decoder->psnames = psnames;
- }
-
- t1_builder_init( &decoder->builder, face, size, slot, hinting );
-
- /* decoder->buildchar and decoder->len_buildchar have to be */
- /* initialized by the caller since we cannot know the length */
- /* of the BuildCharArray */
-
- decoder->num_glyphs = (FT_UInt)face->num_glyphs;
- decoder->glyph_names = glyph_names;
- decoder->hint_mode = hint_mode;
- decoder->blend = blend;
- decoder->parse_callback = parse_callback;
-
- decoder->funcs = t1_decoder_funcs;
-
- return FT_Err_Ok;
- }
-
-
- /* finalize T1 decoder */
- FT_LOCAL_DEF( void )
- t1_decoder_done( T1_Decoder decoder )
- {
- FT_Memory memory = decoder->builder.memory;
-
-
- t1_builder_done( &decoder->builder );
-
- if ( decoder->cf2_instance.finalizer )
- {
- decoder->cf2_instance.finalizer( decoder->cf2_instance.data );
- FT_FREE( decoder->cf2_instance.data );
- }
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/psaux/t1decode.h b/contrib/libs/freetype/src/psaux/t1decode.h
deleted file mode 100644
index 16203b8f73..0000000000
--- a/contrib/libs/freetype/src/psaux/t1decode.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/****************************************************************************
- *
- * t1decode.h
- *
- * PostScript Type 1 decoding routines (specification).
- *
- * Copyright (C) 2000-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef T1DECODE_H_
-#define T1DECODE_H_
-
-
-#include <freetype/internal/psaux.h>
-#include <freetype/internal/t1types.h>
-
-
-FT_BEGIN_HEADER
-
-
- FT_CALLBACK_TABLE
- const T1_Decoder_FuncsRec t1_decoder_funcs;
-
- FT_LOCAL( FT_Int )
- t1_lookup_glyph_by_stdcharcode_ps( PS_Decoder* decoder,
- FT_Int charcode );
-
-#ifdef T1_CONFIG_OPTION_OLD_ENGINE
- FT_LOCAL( FT_Error )
- t1_decoder_parse_glyph( T1_Decoder decoder,
- FT_UInt glyph_index );
-
- FT_LOCAL( FT_Error )
- t1_decoder_parse_charstrings( T1_Decoder decoder,
- FT_Byte* base,
- FT_UInt len );
-#else
- FT_LOCAL( FT_Error )
- t1_decoder_parse_metrics( T1_Decoder decoder,
- FT_Byte* charstring_base,
- FT_UInt charstring_len );
-#endif
-
- FT_LOCAL( FT_Error )
- t1_decoder_init( T1_Decoder decoder,
- FT_Face face,
- FT_Size size,
- FT_GlyphSlot slot,
- FT_Byte** glyph_names,
- PS_Blend blend,
- FT_Bool hinting,
- FT_Render_Mode hint_mode,
- T1_Decoder_Callback parse_glyph );
-
- FT_LOCAL( void )
- t1_decoder_done( T1_Decoder decoder );
-
-
-FT_END_HEADER
-
-#endif /* T1DECODE_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/pshinter/pshalgo.c b/contrib/libs/freetype/src/pshinter/pshalgo.c
deleted file mode 100644
index 967767b348..0000000000
--- a/contrib/libs/freetype/src/pshinter/pshalgo.c
+++ /dev/null
@@ -1,2191 +0,0 @@
-/****************************************************************************
- *
- * pshalgo.c
- *
- * PostScript hinting algorithm (body).
- *
- * Copyright (C) 2001-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used
- * modified and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftcalc.h>
-#include "pshalgo.h"
-
-#include "pshnterr.h"
-
-
-#undef FT_COMPONENT
-#define FT_COMPONENT pshalgo
-
-
-#ifdef DEBUG_HINTER
- PSH_Hint_Table ps_debug_hint_table = NULL;
- PSH_HintFunc ps_debug_hint_func = NULL;
- PSH_Glyph ps_debug_glyph = NULL;
-#endif
-
-
-#define COMPUTE_INFLEXS /* compute inflection points to optimize `S' */
- /* and similar glyphs */
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** BASIC HINTS RECORDINGS *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- /* return true if two stem hints overlap */
- static FT_Int
- psh_hint_overlap( PSH_Hint hint1,
- PSH_Hint hint2 )
- {
- return ADD_INT( hint1->org_pos, hint1->org_len ) >= hint2->org_pos &&
- ADD_INT( hint2->org_pos, hint2->org_len ) >= hint1->org_pos;
- }
-
-
- /* destroy hints table */
- static void
- psh_hint_table_done( PSH_Hint_Table table,
- FT_Memory memory )
- {
- FT_FREE( table->zones );
- table->num_zones = 0;
- table->zone = NULL;
-
- FT_FREE( table->sort );
- FT_FREE( table->hints );
- table->num_hints = 0;
- table->max_hints = 0;
- table->sort_global = NULL;
- }
-
-
- /* deactivate all hints in a table */
- static void
- psh_hint_table_deactivate( PSH_Hint_Table table )
- {
- FT_UInt count = table->max_hints;
- PSH_Hint hint = table->hints;
-
-
- for ( ; count > 0; count--, hint++ )
- {
- psh_hint_deactivate( hint );
- hint->order = -1;
- }
- }
-
-
- /* internal function to record a new hint */
- static void
- psh_hint_table_record( PSH_Hint_Table table,
- FT_UInt idx )
- {
- PSH_Hint hint = table->hints + idx;
-
-
- if ( idx >= table->max_hints )
- {
- FT_TRACE0(( "psh_hint_table_record: invalid hint index %d\n", idx ));
- return;
- }
-
- /* ignore active hints */
- if ( psh_hint_is_active( hint ) )
- return;
-
- psh_hint_activate( hint );
-
- /* now scan the current active hint set to check */
- /* whether `hint' overlaps with another hint */
- {
- PSH_Hint* sorted = table->sort_global;
- FT_UInt count = table->num_hints;
- PSH_Hint hint2;
-
-
- hint->parent = NULL;
- for ( ; count > 0; count--, sorted++ )
- {
- hint2 = sorted[0];
-
- if ( psh_hint_overlap( hint, hint2 ) )
- {
- hint->parent = hint2;
- break;
- }
- }
- }
-
- if ( table->num_hints < table->max_hints )
- table->sort_global[table->num_hints++] = hint;
- else
- FT_TRACE0(( "psh_hint_table_record: too many sorted hints! BUG!\n" ));
- }
-
-
- static void
- psh_hint_table_record_mask( PSH_Hint_Table table,
- PS_Mask hint_mask )
- {
- FT_Int mask = 0, val = 0;
- FT_Byte* cursor = hint_mask->bytes;
- FT_UInt idx, limit;
-
-
- limit = hint_mask->num_bits;
-
- for ( idx = 0; idx < limit; idx++ )
- {
- if ( mask == 0 )
- {
- val = *cursor++;
- mask = 0x80;
- }
-
- if ( val & mask )
- psh_hint_table_record( table, idx );
-
- mask >>= 1;
- }
- }
-
-
- /* create hints table */
- static FT_Error
- psh_hint_table_init( PSH_Hint_Table table,
- PS_Hint_Table hints,
- PS_Mask_Table hint_masks,
- PS_Mask_Table counter_masks,
- FT_Memory memory )
- {
- FT_UInt count;
- FT_Error error;
-
- FT_UNUSED( counter_masks );
-
-
- count = hints->num_hints;
-
- /* allocate our tables */
- if ( FT_QNEW_ARRAY( table->sort, 2 * count ) ||
- FT_QNEW_ARRAY( table->hints, count ) ||
- FT_QNEW_ARRAY( table->zones, 2 * count + 1 ) )
- goto Exit;
-
- table->max_hints = count;
- table->sort_global = FT_OFFSET( table->sort, count );
- table->num_hints = 0;
- table->num_zones = 0;
- table->zone = NULL;
-
- /* initialize the `table->hints' array */
- {
- PSH_Hint write = table->hints;
- PS_Hint read = hints->hints;
-
-
- for ( ; count > 0; count--, write++, read++ )
- {
- write->org_pos = read->pos;
- write->org_len = read->len;
- write->flags = read->flags;
- }
- }
-
- /* we now need to determine the initial `parent' stems; first */
- /* activate the hints that are given by the initial hint masks */
- if ( hint_masks )
- {
- PS_Mask mask = hint_masks->masks;
-
-
- count = hint_masks->num_masks;
- table->hint_masks = hint_masks;
-
- for ( ; count > 0; count--, mask++ )
- psh_hint_table_record_mask( table, mask );
- }
-
- /* finally, do a linear parse in case some hints were left alone */
- if ( table->num_hints != table->max_hints )
- {
- FT_UInt idx;
-
-
- FT_TRACE0(( "psh_hint_table_init: missing/incorrect hint masks\n" ));
-
- count = table->max_hints;
- for ( idx = 0; idx < count; idx++ )
- psh_hint_table_record( table, idx );
- }
-
- Exit:
- return error;
- }
-
-
- static void
- psh_hint_table_activate_mask( PSH_Hint_Table table,
- PS_Mask hint_mask )
- {
- FT_Int mask = 0, val = 0;
- FT_Byte* cursor = hint_mask->bytes;
- FT_UInt idx, limit, count;
-
-
- limit = hint_mask->num_bits;
- count = 0;
-
- psh_hint_table_deactivate( table );
-
- for ( idx = 0; idx < limit; idx++ )
- {
- if ( mask == 0 )
- {
- val = *cursor++;
- mask = 0x80;
- }
-
- if ( val & mask )
- {
- PSH_Hint hint = &table->hints[idx];
-
-
- if ( !psh_hint_is_active( hint ) )
- {
- FT_UInt count2;
-
-#if 0
- PSH_Hint* sort = table->sort;
- PSH_Hint hint2;
-
-
- for ( count2 = count; count2 > 0; count2--, sort++ )
- {
- hint2 = sort[0];
- if ( psh_hint_overlap( hint, hint2 ) )
- FT_TRACE0(( "psh_hint_table_activate_mask:"
- " found overlapping hints\n" ))
- }
-#else
- count2 = 0;
-#endif
-
- if ( count2 == 0 )
- {
- psh_hint_activate( hint );
- if ( count < table->max_hints )
- table->sort[count++] = hint;
- else
- FT_TRACE0(( "psh_hint_tableactivate_mask:"
- " too many active hints\n" ));
- }
- }
- }
-
- mask >>= 1;
- }
- table->num_hints = count;
-
- /* now, sort the hints; they are guaranteed to not overlap */
- /* so we can compare their "org_pos" field directly */
- {
- FT_UInt i1, i2;
- PSH_Hint hint1, hint2;
- PSH_Hint* sort = table->sort;
-
-
- /* a simple bubble sort will do, since in 99% of cases, the hints */
- /* will be already sorted -- and the sort will be linear */
- for ( i1 = 1; i1 < count; i1++ )
- {
- hint1 = sort[i1];
- /* this loop stops when i2 wraps around after reaching 0 */
- for ( i2 = i1 - 1; i2 < i1; i2-- )
- {
- hint2 = sort[i2];
-
- if ( hint2->org_pos < hint1->org_pos )
- break;
-
- sort[i2 + 1] = hint2;
- sort[i2] = hint1;
- }
- }
- }
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** HINTS GRID-FITTING AND OPTIMIZATION *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-#if 1
- static FT_Pos
- psh_dimension_quantize_len( PSH_Dimension dim,
- FT_Pos len,
- FT_Bool do_snapping )
- {
- if ( len <= 64 )
- len = 64;
- else
- {
- FT_Pos delta = len - dim->stdw.widths[0].cur;
-
-
- if ( delta < 0 )
- delta = -delta;
-
- if ( delta < 40 )
- {
- len = dim->stdw.widths[0].cur;
- if ( len < 48 )
- len = 48;
- }
-
- if ( len < 3 * 64 )
- {
- delta = ( len & 63 );
- len &= -64;
-
- if ( delta < 10 )
- len += delta;
-
- else if ( delta < 32 )
- len += 10;
-
- else if ( delta < 54 )
- len += 54;
-
- else
- len += delta;
- }
- else
- len = FT_PIX_ROUND( len );
- }
-
- if ( do_snapping )
- len = FT_PIX_ROUND( len );
-
- return len;
- }
-#endif /* 0 */
-
-
-#ifdef DEBUG_HINTER
-
- static void
- ps_simple_scale( PSH_Hint_Table table,
- FT_Fixed scale,
- FT_Fixed delta,
- FT_Int dimension )
- {
- FT_UInt count;
-
-
- for ( count = 0; count < table->max_hints; count++ )
- {
- PSH_Hint hint = table->hints + count;
-
-
- hint->cur_pos = FT_MulFix( hint->org_pos, scale ) + delta;
- hint->cur_len = FT_MulFix( hint->org_len, scale );
-
- if ( ps_debug_hint_func )
- ps_debug_hint_func( hint, dimension );
- }
- }
-
-#endif /* DEBUG_HINTER */
-
-
- static FT_Fixed
- psh_hint_snap_stem_side_delta( FT_Fixed pos,
- FT_Fixed len )
- {
- FT_Fixed delta1 = FT_PIX_ROUND( pos ) - pos;
- FT_Fixed delta2 = FT_PIX_ROUND( pos + len ) - pos - len;
-
-
- if ( FT_ABS( delta1 ) <= FT_ABS( delta2 ) )
- return delta1;
- else
- return delta2;
- }
-
-
- static void
- psh_hint_align( PSH_Hint hint,
- PSH_Globals globals,
- FT_Int dimension,
- PSH_Glyph glyph )
- {
- PSH_Dimension dim = &globals->dimension[dimension];
- FT_Fixed scale = dim->scale_mult;
- FT_Fixed delta = dim->scale_delta;
-
-
- if ( !psh_hint_is_fitted( hint ) )
- {
- FT_Pos pos = FT_MulFix( hint->org_pos, scale ) + delta;
- FT_Pos len = FT_MulFix( hint->org_len, scale );
-
- FT_Int do_snapping;
- FT_Pos fit_len;
- PSH_AlignmentRec align;
-
-
- /* ignore stem alignments when requested through the hint flags */
- if ( ( dimension == 0 && !glyph->do_horz_hints ) ||
- ( dimension == 1 && !glyph->do_vert_hints ) )
- {
- hint->cur_pos = pos;
- hint->cur_len = len;
-
- psh_hint_set_fitted( hint );
- return;
- }
-
- /* perform stem snapping when requested - this is necessary
- * for monochrome and LCD hinting modes only
- */
- do_snapping = ( dimension == 0 && glyph->do_horz_snapping ) ||
- ( dimension == 1 && glyph->do_vert_snapping );
-
- hint->cur_len = fit_len = len;
-
- /* check blue zones for horizontal stems */
- align.align = PSH_BLUE_ALIGN_NONE;
- align.align_bot = align.align_top = 0;
-
- if ( dimension == 1 )
- psh_blues_snap_stem( &globals->blues,
- ADD_INT( hint->org_pos, hint->org_len ),
- hint->org_pos,
- &align );
-
- switch ( align.align )
- {
- case PSH_BLUE_ALIGN_TOP:
- /* the top of the stem is aligned against a blue zone */
- hint->cur_pos = align.align_top - fit_len;
- break;
-
- case PSH_BLUE_ALIGN_BOT:
- /* the bottom of the stem is aligned against a blue zone */
- hint->cur_pos = align.align_bot;
- break;
-
- case PSH_BLUE_ALIGN_TOP | PSH_BLUE_ALIGN_BOT:
- /* both edges of the stem are aligned against blue zones */
- hint->cur_pos = align.align_bot;
- hint->cur_len = align.align_top - align.align_bot;
- break;
-
- default:
- {
- PSH_Hint parent = hint->parent;
-
-
- if ( parent )
- {
- FT_Pos par_org_center, par_cur_center;
- FT_Pos cur_org_center, cur_delta;
-
-
- /* ensure that parent is already fitted */
- if ( !psh_hint_is_fitted( parent ) )
- psh_hint_align( parent, globals, dimension, glyph );
-
- /* keep original relation between hints, that is, use the */
- /* scaled distance between the centers of the hints to */
- /* compute the new position */
- par_org_center = parent->org_pos + ( parent->org_len >> 1 );
- par_cur_center = parent->cur_pos + ( parent->cur_len >> 1 );
- cur_org_center = hint->org_pos + ( hint->org_len >> 1 );
-
- cur_delta = FT_MulFix( cur_org_center - par_org_center, scale );
- pos = par_cur_center + cur_delta - ( len >> 1 );
- }
-
- hint->cur_pos = pos;
- hint->cur_len = fit_len;
-
- /* Stem adjustment tries to snap stem widths to standard
- * ones. This is important to prevent unpleasant rounding
- * artefacts.
- */
- if ( glyph->do_stem_adjust )
- {
- if ( len <= 64 )
- {
- /* the stem is less than one pixel; we will center it
- * around the nearest pixel center
- */
- if ( len >= 32 )
- {
- /* This is a special case where we also widen the stem
- * and align it to the pixel grid.
- *
- * stem_center = pos + (len/2)
- * nearest_pixel_center = FT_ROUND(stem_center-32)+32
- * new_pos = nearest_pixel_center-32
- * = FT_ROUND(stem_center-32)
- * = FT_FLOOR(stem_center-32+32)
- * = FT_FLOOR(stem_center)
- * new_len = 64
- */
- pos = FT_PIX_FLOOR( pos + ( len >> 1 ) );
- len = 64;
- }
- else if ( len > 0 )
- {
- /* This is a very small stem; we simply align it to the
- * pixel grid, trying to find the minimum displacement.
- *
- * left = pos
- * right = pos + len
- * left_nearest_edge = ROUND(pos)
- * right_nearest_edge = ROUND(right)
- *
- * if ( ABS(left_nearest_edge - left) <=
- * ABS(right_nearest_edge - right) )
- * new_pos = left
- * else
- * new_pos = right
- */
- FT_Pos left_nearest = FT_PIX_ROUND( pos );
- FT_Pos right_nearest = FT_PIX_ROUND( pos + len );
- FT_Pos left_disp = left_nearest - pos;
- FT_Pos right_disp = right_nearest - ( pos + len );
-
-
- if ( left_disp < 0 )
- left_disp = -left_disp;
- if ( right_disp < 0 )
- right_disp = -right_disp;
- if ( left_disp <= right_disp )
- pos = left_nearest;
- else
- pos = right_nearest;
- }
- else
- {
- /* this is a ghost stem; we simply round it */
- pos = FT_PIX_ROUND( pos );
- }
- }
- else
- {
- len = psh_dimension_quantize_len( dim, len, 0 );
- }
- }
-
- /* now that we have a good hinted stem width, try to position */
- /* the stem along a pixel grid integer coordinate */
- hint->cur_pos = pos + psh_hint_snap_stem_side_delta( pos, len );
- hint->cur_len = len;
- }
- }
-
- if ( do_snapping )
- {
- pos = hint->cur_pos;
- len = hint->cur_len;
-
- if ( len < 64 )
- len = 64;
- else
- len = FT_PIX_ROUND( len );
-
- switch ( align.align )
- {
- case PSH_BLUE_ALIGN_TOP:
- hint->cur_pos = align.align_top - len;
- hint->cur_len = len;
- break;
-
- case PSH_BLUE_ALIGN_BOT:
- hint->cur_len = len;
- break;
-
- case PSH_BLUE_ALIGN_BOT | PSH_BLUE_ALIGN_TOP:
- /* don't touch */
- break;
-
-
- default:
- hint->cur_len = len;
- if ( len & 64 )
- pos = FT_PIX_FLOOR( pos + ( len >> 1 ) ) + 32;
- else
- pos = FT_PIX_ROUND( pos + ( len >> 1 ) );
-
- hint->cur_pos = pos - ( len >> 1 );
- hint->cur_len = len;
- }
- }
-
- psh_hint_set_fitted( hint );
-
-#ifdef DEBUG_HINTER
- if ( ps_debug_hint_func )
- ps_debug_hint_func( hint, dimension );
-#endif
- }
- }
-
-
-#if 0 /* not used for now, experimental */
-
- /*
- * A variant to perform "light" hinting (i.e. FT_RENDER_MODE_LIGHT)
- * of stems
- */
- static void
- psh_hint_align_light( PSH_Hint hint,
- PSH_Globals globals,
- FT_Int dimension,
- PSH_Glyph glyph )
- {
- PSH_Dimension dim = &globals->dimension[dimension];
- FT_Fixed scale = dim->scale_mult;
- FT_Fixed delta = dim->scale_delta;
-
-
- if ( !psh_hint_is_fitted( hint ) )
- {
- FT_Pos pos = FT_MulFix( hint->org_pos, scale ) + delta;
- FT_Pos len = FT_MulFix( hint->org_len, scale );
-
- FT_Pos fit_len;
-
- PSH_AlignmentRec align;
-
-
- /* ignore stem alignments when requested through the hint flags */
- if ( ( dimension == 0 && !glyph->do_horz_hints ) ||
- ( dimension == 1 && !glyph->do_vert_hints ) )
- {
- hint->cur_pos = pos;
- hint->cur_len = len;
-
- psh_hint_set_fitted( hint );
- return;
- }
-
- fit_len = len;
-
- hint->cur_len = fit_len;
-
- /* check blue zones for horizontal stems */
- align.align = PSH_BLUE_ALIGN_NONE;
- align.align_bot = align.align_top = 0;
-
- if ( dimension == 1 )
- psh_blues_snap_stem( &globals->blues,
- ADD_INT( hint->org_pos, hint->org_len ),
- hint->org_pos,
- &align );
-
- switch ( align.align )
- {
- case PSH_BLUE_ALIGN_TOP:
- /* the top of the stem is aligned against a blue zone */
- hint->cur_pos = align.align_top - fit_len;
- break;
-
- case PSH_BLUE_ALIGN_BOT:
- /* the bottom of the stem is aligned against a blue zone */
- hint->cur_pos = align.align_bot;
- break;
-
- case PSH_BLUE_ALIGN_TOP | PSH_BLUE_ALIGN_BOT:
- /* both edges of the stem are aligned against blue zones */
- hint->cur_pos = align.align_bot;
- hint->cur_len = align.align_top - align.align_bot;
- break;
-
- default:
- {
- PSH_Hint parent = hint->parent;
-
-
- if ( parent )
- {
- FT_Pos par_org_center, par_cur_center;
- FT_Pos cur_org_center, cur_delta;
-
-
- /* ensure that parent is already fitted */
- if ( !psh_hint_is_fitted( parent ) )
- psh_hint_align_light( parent, globals, dimension, glyph );
-
- par_org_center = parent->org_pos + ( parent->org_len / 2 );
- par_cur_center = parent->cur_pos + ( parent->cur_len / 2 );
- cur_org_center = hint->org_pos + ( hint->org_len / 2 );
-
- cur_delta = FT_MulFix( cur_org_center - par_org_center, scale );
- pos = par_cur_center + cur_delta - ( len >> 1 );
- }
-
- /* Stems less than one pixel wide are easy -- we want to
- * make them as dark as possible, so they must fall within
- * one pixel. If the stem is split between two pixels
- * then snap the edge that is nearer to the pixel boundary
- * to the pixel boundary.
- */
- if ( len <= 64 )
- {
- if ( ( pos + len + 63 ) / 64 != pos / 64 + 1 )
- pos += psh_hint_snap_stem_side_delta ( pos, len );
- }
-
- /* Position stems other to minimize the amount of mid-grays.
- * There are, in general, two positions that do this,
- * illustrated as A) and B) below.
- *
- * + + + +
- *
- * A) |--------------------------------|
- * B) |--------------------------------|
- * C) |--------------------------------|
- *
- * Position A) (split the excess stem equally) should be better
- * for stems of width N + f where f < 0.5.
- *
- * Position B) (split the deficiency equally) should be better
- * for stems of width N + f where f > 0.5.
- *
- * It turns out though that minimizing the total number of lit
- * pixels is also important, so position C), with one edge
- * aligned with a pixel boundary is actually preferable
- * to A). There are also more possible positions for C) than
- * for A) or B), so it involves less distortion of the overall
- * character shape.
- */
- else /* len > 64 */
- {
- FT_Fixed frac_len = len & 63;
- FT_Fixed center = pos + ( len >> 1 );
- FT_Fixed delta_a, delta_b;
-
-
- if ( ( len / 64 ) & 1 )
- {
- delta_a = FT_PIX_FLOOR( center ) + 32 - center;
- delta_b = FT_PIX_ROUND( center ) - center;
- }
- else
- {
- delta_a = FT_PIX_ROUND( center ) - center;
- delta_b = FT_PIX_FLOOR( center ) + 32 - center;
- }
-
- /* We choose between B) and C) above based on the amount
- * of fractional stem width; for small amounts, choose
- * C) always, for large amounts, B) always, and inbetween,
- * pick whichever one involves less stem movement.
- */
- if ( frac_len < 32 )
- {
- pos += psh_hint_snap_stem_side_delta ( pos, len );
- }
- else if ( frac_len < 48 )
- {
- FT_Fixed side_delta = psh_hint_snap_stem_side_delta ( pos,
- len );
-
- if ( FT_ABS( side_delta ) < FT_ABS( delta_b ) )
- pos += side_delta;
- else
- pos += delta_b;
- }
- else
- {
- pos += delta_b;
- }
- }
-
- hint->cur_pos = pos;
- }
- } /* switch */
-
- psh_hint_set_fitted( hint );
-
-#ifdef DEBUG_HINTER
- if ( ps_debug_hint_func )
- ps_debug_hint_func( hint, dimension );
-#endif
- }
- }
-
-#endif /* 0 */
-
-
- static void
- psh_hint_table_align_hints( PSH_Hint_Table table,
- PSH_Globals globals,
- FT_Int dimension,
- PSH_Glyph glyph )
- {
- PSH_Hint hint;
- FT_UInt count;
-
-#ifdef DEBUG_HINTER
-
- PSH_Dimension dim = &globals->dimension[dimension];
- FT_Fixed scale = dim->scale_mult;
- FT_Fixed delta = dim->scale_delta;
-
-
- if ( ps_debug_no_vert_hints && dimension == 0 )
- {
- ps_simple_scale( table, scale, delta, dimension );
- return;
- }
-
- if ( ps_debug_no_horz_hints && dimension == 1 )
- {
- ps_simple_scale( table, scale, delta, dimension );
- return;
- }
-
-#endif /* DEBUG_HINTER */
-
- hint = table->hints;
- count = table->max_hints;
-
- for ( ; count > 0; count--, hint++ )
- psh_hint_align( hint, globals, dimension, glyph );
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** POINTS INTERPOLATION ROUTINES *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-#define xxDEBUG_ZONES
-
-
-#ifdef DEBUG_ZONES
-
-#include FT_CONFIG_STANDARD_LIBRARY_H
-
- static void
- psh_print_zone( PSH_Zone zone )
- {
- printf( "zone [scale,delta,min,max] = [%.5f,%.2f,%d,%d]\n",
- zone->scale / 65536.0,
- zone->delta / 64.0,
- zone->min,
- zone->max );
- }
-
-#endif /* DEBUG_ZONES */
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** HINTER GLYPH MANAGEMENT *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-#define psh_corner_is_flat ft_corner_is_flat
-#define psh_corner_orientation ft_corner_orientation
-
-
-#ifdef COMPUTE_INFLEXS
-
- /* compute all inflex points in a given glyph */
- static void
- psh_glyph_compute_inflections( PSH_Glyph glyph )
- {
- FT_UInt n;
-
-
- for ( n = 0; n < glyph->num_contours; n++ )
- {
- PSH_Point first, start, end, before, after;
- FT_Pos in_x, in_y, out_x, out_y;
- FT_Int orient_prev, orient_cur;
- FT_Int finished = 0;
-
-
- /* we need at least 4 points to create an inflection point */
- if ( glyph->contours[n].count < 4 )
- continue;
-
- /* compute first segment in contour */
- first = glyph->contours[n].start;
-
- start = end = first;
- do
- {
- end = end->next;
- if ( end == first )
- goto Skip;
-
- in_x = end->org_u - start->org_u;
- in_y = end->org_v - start->org_v;
-
- } while ( in_x == 0 && in_y == 0 );
-
- /* extend the segment start whenever possible */
- before = start;
- do
- {
- do
- {
- start = before;
- before = before->prev;
- if ( before == first )
- goto Skip;
-
- out_x = start->org_u - before->org_u;
- out_y = start->org_v - before->org_v;
-
- } while ( out_x == 0 && out_y == 0 );
-
- orient_prev = psh_corner_orientation( in_x, in_y, out_x, out_y );
-
- } while ( orient_prev == 0 );
-
- first = start;
- in_x = out_x;
- in_y = out_y;
-
- /* now, process all segments in the contour */
- do
- {
- /* first, extend current segment's end whenever possible */
- after = end;
- do
- {
- do
- {
- end = after;
- after = after->next;
- if ( after == first )
- finished = 1;
-
- out_x = after->org_u - end->org_u;
- out_y = after->org_v - end->org_v;
-
- } while ( out_x == 0 && out_y == 0 );
-
- orient_cur = psh_corner_orientation( in_x, in_y, out_x, out_y );
-
- } while ( orient_cur == 0 );
-
- if ( ( orient_cur ^ orient_prev ) < 0 )
- {
- do
- {
- psh_point_set_inflex( start );
- start = start->next;
- }
- while ( start != end );
-
- psh_point_set_inflex( start );
- }
-
- start = end;
- end = after;
- orient_prev = orient_cur;
- in_x = out_x;
- in_y = out_y;
-
- } while ( !finished );
-
- Skip:
- ;
- }
- }
-
-#endif /* COMPUTE_INFLEXS */
-
-
- static void
- psh_glyph_done( PSH_Glyph glyph )
- {
- FT_Memory memory = glyph->memory;
-
-
- psh_hint_table_done( &glyph->hint_tables[1], memory );
- psh_hint_table_done( &glyph->hint_tables[0], memory );
-
- FT_FREE( glyph->points );
- FT_FREE( glyph->contours );
-
- glyph->num_points = 0;
- glyph->num_contours = 0;
-
- glyph->memory = NULL;
- }
-
-
- static PSH_Dir
- psh_compute_dir( FT_Pos dx,
- FT_Pos dy )
- {
- FT_Pos ax, ay;
- PSH_Dir result = PSH_DIR_NONE;
-
-
- ax = FT_ABS( dx );
- ay = FT_ABS( dy );
-
- if ( ay * 12 < ax )
- {
- /* |dy| <<< |dx| means a near-horizontal segment */
- result = ( dx >= 0 ) ? PSH_DIR_RIGHT : PSH_DIR_LEFT;
- }
- else if ( ax * 12 < ay )
- {
- /* |dx| <<< |dy| means a near-vertical segment */
- result = ( dy >= 0 ) ? PSH_DIR_UP : PSH_DIR_DOWN;
- }
-
- return result;
- }
-
-
- /* load outline point coordinates into hinter glyph */
- static void
- psh_glyph_load_points( PSH_Glyph glyph,
- FT_Int dimension )
- {
- FT_Vector* vec = glyph->outline->points;
- PSH_Point point = glyph->points;
- FT_UInt count = glyph->num_points;
-
-
- for ( ; count > 0; count--, point++, vec++ )
- {
- point->flags2 = 0;
- point->hint = NULL;
- if ( dimension == 0 )
- {
- point->org_u = vec->x;
- point->org_v = vec->y;
- }
- else
- {
- point->org_u = vec->y;
- point->org_v = vec->x;
- }
-
-#ifdef DEBUG_HINTER
- point->org_x = vec->x;
- point->org_y = vec->y;
-#endif
-
- }
- }
-
-
- /* save hinted point coordinates back to outline */
- static void
- psh_glyph_save_points( PSH_Glyph glyph,
- FT_Int dimension )
- {
- FT_UInt n;
- PSH_Point point = glyph->points;
- FT_Vector* vec = glyph->outline->points;
- FT_Byte* tags = glyph->outline->tags;
-
-
- for ( n = 0; n < glyph->num_points; n++ )
- {
- if ( dimension == 0 )
- vec[n].x = point->cur_u;
- else
- vec[n].y = point->cur_u;
-
- if ( psh_point_is_strong( point ) )
- tags[n] |= (char)( ( dimension == 0 ) ? 32 : 64 );
-
-#ifdef DEBUG_HINTER
-
- if ( dimension == 0 )
- {
- point->cur_x = point->cur_u;
- point->flags_x = point->flags2 | point->flags;
- }
- else
- {
- point->cur_y = point->cur_u;
- point->flags_y = point->flags2 | point->flags;
- }
-
-#endif
-
- point++;
- }
- }
-
-
- static FT_Error
- psh_glyph_init( PSH_Glyph glyph,
- FT_Outline* outline,
- PS_Hints ps_hints,
- PSH_Globals globals )
- {
- FT_Error error;
- FT_Memory memory;
-
-
- /* clear all fields */
- FT_ZERO( glyph );
-
- memory = glyph->memory = globals->memory;
-
- /* allocate and setup points + contours arrays */
- if ( FT_QNEW_ARRAY( glyph->points, outline->n_points ) ||
- FT_QNEW_ARRAY( glyph->contours, outline->n_contours ) )
- goto Exit;
-
- glyph->num_points = outline->n_points;
- glyph->num_contours = outline->n_contours;
-
- {
- FT_UInt first = 0, next, n;
- PSH_Point points = glyph->points;
- PSH_Contour contour = glyph->contours;
-
-
- for ( n = 0; n < glyph->num_contours; n++ )
- {
- FT_UInt count;
- PSH_Point point;
-
-
- next = outline->contours[n] + 1;
- count = next - first;
-
- contour->start = points + first;
- contour->count = count;
-
- if ( count > 0 )
- {
- point = points + first;
-
- point->prev = points + next - 1;
- point->contour = contour;
-
- for ( ; count > 1; count-- )
- {
- point[0].next = point + 1;
- point[1].prev = point;
- point++;
- point->contour = contour;
- }
- point->next = points + first;
- }
-
- contour++;
- first = next;
- }
- }
-
- {
- PSH_Point points = glyph->points;
- PSH_Point point = points;
- FT_Vector* vec = outline->points;
- FT_UInt n;
-
-
- for ( n = 0; n < glyph->num_points; n++, point++ )
- {
- FT_Int n_prev = (FT_Int)( point->prev - points );
- FT_Int n_next = (FT_Int)( point->next - points );
- FT_Pos dxi, dyi, dxo, dyo;
-
-
- point->flags = 0;
- if ( !( outline->tags[n] & FT_CURVE_TAG_ON ) )
- psh_point_set_off( point );
-
- dxi = vec[n].x - vec[n_prev].x;
- dyi = vec[n].y - vec[n_prev].y;
-
- point->dir_in = psh_compute_dir( dxi, dyi );
-
- dxo = vec[n_next].x - vec[n].x;
- dyo = vec[n_next].y - vec[n].y;
-
- point->dir_out = psh_compute_dir( dxo, dyo );
-
- /* detect smooth points */
- if ( psh_point_is_off( point ) )
- psh_point_set_smooth( point );
-
- else if ( point->dir_in == point->dir_out )
- {
- if ( point->dir_out != PSH_DIR_NONE ||
- psh_corner_is_flat( dxi, dyi, dxo, dyo ) )
- psh_point_set_smooth( point );
- }
- }
- }
-
- glyph->outline = outline;
- glyph->globals = globals;
-
-#ifdef COMPUTE_INFLEXS
- psh_glyph_load_points( glyph, 0 );
- psh_glyph_compute_inflections( glyph );
-#endif /* COMPUTE_INFLEXS */
-
- /* now deal with hints tables */
- error = psh_hint_table_init( &glyph->hint_tables [0],
- &ps_hints->dimension[0].hints,
- &ps_hints->dimension[0].masks,
- &ps_hints->dimension[0].counters,
- memory );
- if ( error )
- goto Exit;
-
- error = psh_hint_table_init( &glyph->hint_tables [1],
- &ps_hints->dimension[1].hints,
- &ps_hints->dimension[1].masks,
- &ps_hints->dimension[1].counters,
- memory );
- if ( error )
- goto Exit;
-
- Exit:
- return error;
- }
-
-
- /* compute all extrema in a glyph for a given dimension */
- static void
- psh_glyph_compute_extrema( PSH_Glyph glyph )
- {
- FT_UInt n;
-
-
- /* first of all, compute all local extrema */
- for ( n = 0; n < glyph->num_contours; n++ )
- {
- PSH_Point first = glyph->contours[n].start;
- PSH_Point point, before, after;
-
-
- if ( glyph->contours[n].count == 0 )
- continue;
-
- point = first;
- before = point;
-
- do
- {
- before = before->prev;
- if ( before == first )
- goto Skip;
-
- } while ( before->org_u == point->org_u );
-
- first = point = before->next;
-
- for (;;)
- {
- after = point;
- do
- {
- after = after->next;
- if ( after == first )
- goto Next;
-
- } while ( after->org_u == point->org_u );
-
- if ( before->org_u < point->org_u )
- {
- if ( after->org_u < point->org_u )
- {
- /* local maximum */
- goto Extremum;
- }
- }
- else /* before->org_u > point->org_u */
- {
- if ( after->org_u > point->org_u )
- {
- /* local minimum */
- Extremum:
- do
- {
- psh_point_set_extremum( point );
- point = point->next;
-
- } while ( point != after );
- }
- }
-
- before = after->prev;
- point = after;
-
- } /* for */
-
- Next:
- ;
- }
-
- /* for each extremum, determine its direction along the */
- /* orthogonal axis */
- for ( n = 0; n < glyph->num_points; n++ )
- {
- PSH_Point point, before, after;
-
-
- point = &glyph->points[n];
- before = point;
- after = point;
-
- if ( psh_point_is_extremum( point ) )
- {
- do
- {
- before = before->prev;
- if ( before == point )
- goto Skip;
-
- } while ( before->org_v == point->org_v );
-
- do
- {
- after = after->next;
- if ( after == point )
- goto Skip;
-
- } while ( after->org_v == point->org_v );
- }
-
- if ( before->org_v < point->org_v &&
- after->org_v > point->org_v )
- {
- psh_point_set_positive( point );
- }
- else if ( before->org_v > point->org_v &&
- after->org_v < point->org_v )
- {
- psh_point_set_negative( point );
- }
-
- Skip:
- ;
- }
- }
-
-
- /* the min and max are based on contour orientation and fill rule */
- static void
- psh_hint_table_find_strong_points( PSH_Hint_Table table,
- PSH_Point point,
- FT_UInt count,
- FT_Int threshold,
- PSH_Dir major_dir )
- {
- PSH_Hint* sort = table->sort;
- FT_UInt num_hints = table->num_hints;
-
-
- for ( ; count > 0; count--, point++ )
- {
- PSH_Dir point_dir;
- FT_Pos org_u = point->org_u;
-
-
- if ( psh_point_is_strong( point ) )
- continue;
-
- point_dir =
- (PSH_Dir)( ( point->dir_in | point->dir_out ) & major_dir );
-
- if ( point_dir & ( PSH_DIR_DOWN | PSH_DIR_RIGHT ) )
- {
- FT_UInt nn;
-
-
- for ( nn = 0; nn < num_hints; nn++ )
- {
- PSH_Hint hint = sort[nn];
- FT_Pos d = org_u - hint->org_pos;
-
-
- if ( d < threshold && -d < threshold )
- {
- psh_point_set_strong( point );
- point->flags2 |= PSH_POINT_EDGE_MIN;
- point->hint = hint;
- break;
- }
- }
- }
- else if ( point_dir & ( PSH_DIR_UP | PSH_DIR_LEFT ) )
- {
- FT_UInt nn;
-
-
- for ( nn = 0; nn < num_hints; nn++ )
- {
- PSH_Hint hint = sort[nn];
- FT_Pos d = org_u - hint->org_pos - hint->org_len;
-
-
- if ( d < threshold && -d < threshold )
- {
- psh_point_set_strong( point );
- point->flags2 |= PSH_POINT_EDGE_MAX;
- point->hint = hint;
- break;
- }
- }
- }
-
-#if 1
- else if ( psh_point_is_extremum( point ) )
- {
- /* treat extrema as special cases for stem edge alignment */
- FT_UInt nn, min_flag, max_flag;
-
-
- if ( major_dir == PSH_DIR_HORIZONTAL )
- {
- min_flag = PSH_POINT_POSITIVE;
- max_flag = PSH_POINT_NEGATIVE;
- }
- else
- {
- min_flag = PSH_POINT_NEGATIVE;
- max_flag = PSH_POINT_POSITIVE;
- }
-
- if ( point->flags2 & min_flag )
- {
- for ( nn = 0; nn < num_hints; nn++ )
- {
- PSH_Hint hint = sort[nn];
- FT_Pos d = org_u - hint->org_pos;
-
-
- if ( d < threshold && -d < threshold )
- {
- point->flags2 |= PSH_POINT_EDGE_MIN;
- point->hint = hint;
- psh_point_set_strong( point );
- break;
- }
- }
- }
- else if ( point->flags2 & max_flag )
- {
- for ( nn = 0; nn < num_hints; nn++ )
- {
- PSH_Hint hint = sort[nn];
- FT_Pos d = org_u - hint->org_pos - hint->org_len;
-
-
- if ( d < threshold && -d < threshold )
- {
- point->flags2 |= PSH_POINT_EDGE_MAX;
- point->hint = hint;
- psh_point_set_strong( point );
- break;
- }
- }
- }
-
- if ( !point->hint )
- {
- for ( nn = 0; nn < num_hints; nn++ )
- {
- PSH_Hint hint = sort[nn];
-
-
- if ( org_u >= hint->org_pos &&
- org_u <= ADD_INT( hint->org_pos, hint->org_len ) )
- {
- point->hint = hint;
- break;
- }
- }
- }
- }
-
-#endif /* 1 */
- }
- }
-
-
- /* the accepted shift for strong points in fractional pixels */
-#define PSH_STRONG_THRESHOLD 32
-
- /* the maximum shift value in font units tuned to distinguish */
- /* between stems and serifs in URW+ font collection */
-#define PSH_STRONG_THRESHOLD_MAXIMUM 12
-
-
- /* find strong points in a glyph */
- static void
- psh_glyph_find_strong_points( PSH_Glyph glyph,
- FT_Int dimension )
- {
- /* a point is `strong' if it is located on a stem edge and */
- /* has an `in' or `out' tangent parallel to the hint's direction */
-
- PSH_Hint_Table table = &glyph->hint_tables[dimension];
- PS_Mask mask = table->hint_masks->masks;
- FT_UInt num_masks = table->hint_masks->num_masks;
- FT_UInt first = 0;
- PSH_Dir major_dir = ( dimension == 0 ) ? PSH_DIR_VERTICAL
- : PSH_DIR_HORIZONTAL;
- PSH_Dimension dim = &glyph->globals->dimension[dimension];
- FT_Fixed scale = dim->scale_mult;
- FT_Int threshold;
-
-
- threshold = (FT_Int)FT_DivFix( PSH_STRONG_THRESHOLD, scale );
- if ( threshold > PSH_STRONG_THRESHOLD_MAXIMUM )
- threshold = PSH_STRONG_THRESHOLD_MAXIMUM;
-
- /* process secondary hints to `selected' points */
- if ( num_masks > 1 && glyph->num_points > 0 )
- {
- /* the `endchar' op can reduce the number of points */
- first = mask->end_point > glyph->num_points
- ? glyph->num_points
- : mask->end_point;
- mask++;
- for ( ; num_masks > 1; num_masks--, mask++ )
- {
- FT_UInt next = FT_MIN( mask->end_point, glyph->num_points );
-
-
- if ( next > first )
- {
- FT_UInt count = next - first;
- PSH_Point point = glyph->points + first;
-
-
- psh_hint_table_activate_mask( table, mask );
-
- psh_hint_table_find_strong_points( table, point, count,
- threshold, major_dir );
- }
- first = next;
- }
- }
-
- /* process primary hints for all points */
- if ( num_masks == 1 )
- {
- FT_UInt count = glyph->num_points;
- PSH_Point point = glyph->points;
-
-
- psh_hint_table_activate_mask( table, table->hint_masks->masks );
-
- psh_hint_table_find_strong_points( table, point, count,
- threshold, major_dir );
- }
-
- /* now, certain points may have been attached to a hint and */
- /* not marked as strong; update their flags then */
- {
- FT_UInt count = glyph->num_points;
- PSH_Point point = glyph->points;
-
-
- for ( ; count > 0; count--, point++ )
- if ( point->hint && !psh_point_is_strong( point ) )
- psh_point_set_strong( point );
- }
- }
-
-
- /* find points in a glyph which are in a blue zone and have `in' or */
- /* `out' tangents parallel to the horizontal axis */
- static void
- psh_glyph_find_blue_points( PSH_Blues blues,
- PSH_Glyph glyph )
- {
- PSH_Blue_Table table;
- PSH_Blue_Zone zone;
- FT_UInt glyph_count = glyph->num_points;
- FT_UInt blue_count;
- PSH_Point point = glyph->points;
-
-
- for ( ; glyph_count > 0; glyph_count--, point++ )
- {
- FT_Pos y;
-
-
- /* check tangents */
- if ( !( point->dir_in & PSH_DIR_HORIZONTAL ) &&
- !( point->dir_out & PSH_DIR_HORIZONTAL ) )
- continue;
-
- /* skip strong points */
- if ( psh_point_is_strong( point ) )
- continue;
-
- y = point->org_u;
-
- /* look up top zones */
- table = &blues->normal_top;
- blue_count = table->count;
- zone = table->zones;
-
- for ( ; blue_count > 0; blue_count--, zone++ )
- {
- FT_Pos delta = y - zone->org_bottom;
-
-
- if ( delta < -blues->blue_fuzz )
- break;
-
- if ( y <= zone->org_top + blues->blue_fuzz )
- if ( blues->no_overshoots || delta <= blues->blue_threshold )
- {
- point->cur_u = zone->cur_bottom;
- psh_point_set_strong( point );
- psh_point_set_fitted( point );
- }
- }
-
- /* look up bottom zones */
- table = &blues->normal_bottom;
- blue_count = table->count;
- zone = table->zones + blue_count - 1;
-
- for ( ; blue_count > 0; blue_count--, zone-- )
- {
- FT_Pos delta = zone->org_top - y;
-
-
- if ( delta < -blues->blue_fuzz )
- break;
-
- if ( y >= zone->org_bottom - blues->blue_fuzz )
- if ( blues->no_overshoots || delta < blues->blue_threshold )
- {
- point->cur_u = zone->cur_top;
- psh_point_set_strong( point );
- psh_point_set_fitted( point );
- }
- }
- }
- }
-
-
- /* interpolate strong points with the help of hinted coordinates */
- static void
- psh_glyph_interpolate_strong_points( PSH_Glyph glyph,
- FT_Int dimension )
- {
- PSH_Dimension dim = &glyph->globals->dimension[dimension];
- FT_Fixed scale = dim->scale_mult;
-
- FT_UInt count = glyph->num_points;
- PSH_Point point = glyph->points;
-
-
- for ( ; count > 0; count--, point++ )
- {
- PSH_Hint hint = point->hint;
-
-
- if ( hint )
- {
- FT_Pos delta;
-
-
- if ( psh_point_is_edge_min( point ) )
- point->cur_u = hint->cur_pos;
-
- else if ( psh_point_is_edge_max( point ) )
- point->cur_u = hint->cur_pos + hint->cur_len;
-
- else
- {
- delta = point->org_u - hint->org_pos;
-
- if ( delta <= 0 )
- point->cur_u = hint->cur_pos + FT_MulFix( delta, scale );
-
- else if ( delta >= hint->org_len )
- point->cur_u = hint->cur_pos + hint->cur_len +
- FT_MulFix( delta - hint->org_len, scale );
-
- else /* hint->org_len > 0 */
- point->cur_u = hint->cur_pos +
- FT_MulDiv( delta, hint->cur_len,
- hint->org_len );
- }
- psh_point_set_fitted( point );
- }
- }
- }
-
-
-#define PSH_MAX_STRONG_INTERNAL 16
-
- static void
- psh_glyph_interpolate_normal_points( PSH_Glyph glyph,
- FT_Int dimension )
- {
-
-#if 1
- /* first technique: a point is strong if it is a local extremum */
-
- PSH_Dimension dim = &glyph->globals->dimension[dimension];
- FT_Fixed scale = dim->scale_mult;
- FT_Memory memory = glyph->memory;
-
- PSH_Point* strongs = NULL;
- PSH_Point strongs_0[PSH_MAX_STRONG_INTERNAL];
- FT_UInt num_strongs = 0;
-
- PSH_Point points = glyph->points;
- PSH_Point points_end = points + glyph->num_points;
- PSH_Point point;
-
-
- /* first count the number of strong points */
- for ( point = points; point < points_end; point++ )
- {
- if ( psh_point_is_strong( point ) )
- num_strongs++;
- }
-
- if ( num_strongs == 0 ) /* nothing to do here */
- return;
-
- /* allocate an array to store a list of points, */
- /* stored in increasing org_u order */
- if ( num_strongs <= PSH_MAX_STRONG_INTERNAL )
- strongs = strongs_0;
- else
- {
- FT_Error error;
-
-
- if ( FT_QNEW_ARRAY( strongs, num_strongs ) )
- return;
- }
-
- num_strongs = 0;
- for ( point = points; point < points_end; point++ )
- {
- PSH_Point* insert;
-
-
- if ( !psh_point_is_strong( point ) )
- continue;
-
- for ( insert = strongs + num_strongs; insert > strongs; insert-- )
- {
- if ( insert[-1]->org_u <= point->org_u )
- break;
-
- insert[0] = insert[-1];
- }
- insert[0] = point;
- num_strongs++;
- }
-
- /* now try to interpolate all normal points */
- for ( point = points; point < points_end; point++ )
- {
- if ( psh_point_is_strong( point ) )
- continue;
-
- /* sometimes, some local extrema are smooth points */
- if ( psh_point_is_smooth( point ) )
- {
- if ( point->dir_in == PSH_DIR_NONE ||
- point->dir_in != point->dir_out )
- continue;
-
- if ( !psh_point_is_extremum( point ) &&
- !psh_point_is_inflex( point ) )
- continue;
-
- point->flags &= ~PSH_POINT_SMOOTH;
- }
-
- /* find best enclosing point coordinates then interpolate */
- {
- PSH_Point before, after;
- FT_UInt nn;
-
-
- for ( nn = 0; nn < num_strongs; nn++ )
- if ( strongs[nn]->org_u > point->org_u )
- break;
-
- if ( nn == 0 ) /* point before the first strong point */
- {
- after = strongs[0];
-
- point->cur_u = after->cur_u +
- FT_MulFix( point->org_u - after->org_u,
- scale );
- }
- else
- {
- before = strongs[nn - 1];
-
- for ( nn = num_strongs; nn > 0; nn-- )
- if ( strongs[nn - 1]->org_u < point->org_u )
- break;
-
- if ( nn == num_strongs ) /* point is after last strong point */
- {
- before = strongs[nn - 1];
-
- point->cur_u = before->cur_u +
- FT_MulFix( point->org_u - before->org_u,
- scale );
- }
- else
- {
- FT_Pos u;
-
-
- after = strongs[nn];
-
- /* now interpolate point between before and after */
- u = point->org_u;
-
- if ( u == before->org_u )
- point->cur_u = before->cur_u;
-
- else if ( u == after->org_u )
- point->cur_u = after->cur_u;
-
- else
- point->cur_u = before->cur_u +
- FT_MulDiv( u - before->org_u,
- after->cur_u - before->cur_u,
- after->org_u - before->org_u );
- }
- }
- psh_point_set_fitted( point );
- }
- }
-
- if ( strongs != strongs_0 )
- FT_FREE( strongs );
-
-#endif /* 1 */
-
- }
-
-
- /* interpolate other points */
- static void
- psh_glyph_interpolate_other_points( PSH_Glyph glyph,
- FT_Int dimension )
- {
- PSH_Dimension dim = &glyph->globals->dimension[dimension];
- FT_Fixed scale = dim->scale_mult;
- FT_Fixed delta = dim->scale_delta;
- PSH_Contour contour = glyph->contours;
- FT_UInt num_contours = glyph->num_contours;
-
-
- for ( ; num_contours > 0; num_contours--, contour++ )
- {
- PSH_Point start = contour->start;
- PSH_Point first, next, point;
- FT_UInt fit_count;
-
-
- /* count the number of strong points in this contour */
- next = start + contour->count;
- fit_count = 0;
- first = NULL;
-
- for ( point = start; point < next; point++ )
- if ( psh_point_is_fitted( point ) )
- {
- if ( !first )
- first = point;
-
- fit_count++;
- }
-
- /* if there are less than 2 fitted points in the contour, we */
- /* simply scale and eventually translate the contour points */
- if ( fit_count < 2 )
- {
- if ( fit_count == 1 )
- delta = first->cur_u - FT_MulFix( first->org_u, scale );
-
- for ( point = start; point < next; point++ )
- if ( point != first )
- point->cur_u = FT_MulFix( point->org_u, scale ) + delta;
-
- goto Next_Contour;
- }
-
- /* there are more than 2 strong points in this contour; we */
- /* need to interpolate weak points between them */
- start = first;
- do
- {
- /* skip consecutive fitted points */
- for (;;)
- {
- next = first->next;
- if ( next == start )
- goto Next_Contour;
-
- if ( !psh_point_is_fitted( next ) )
- break;
-
- first = next;
- }
-
- /* find next fitted point after unfitted one */
- for (;;)
- {
- next = next->next;
- if ( psh_point_is_fitted( next ) )
- break;
- }
-
- /* now interpolate between them */
- {
- FT_Pos org_a, org_ab, cur_a, cur_ab;
- FT_Pos org_c, org_ac, cur_c;
- FT_Fixed scale_ab;
-
-
- if ( first->org_u <= next->org_u )
- {
- org_a = first->org_u;
- cur_a = first->cur_u;
- org_ab = next->org_u - org_a;
- cur_ab = next->cur_u - cur_a;
- }
- else
- {
- org_a = next->org_u;
- cur_a = next->cur_u;
- org_ab = first->org_u - org_a;
- cur_ab = first->cur_u - cur_a;
- }
-
- scale_ab = 0x10000L;
- if ( org_ab > 0 )
- scale_ab = FT_DivFix( cur_ab, org_ab );
-
- point = first->next;
- do
- {
- org_c = point->org_u;
- org_ac = org_c - org_a;
-
- if ( org_ac <= 0 )
- {
- /* on the left of the interpolation zone */
- cur_c = cur_a + FT_MulFix( org_ac, scale );
- }
- else if ( org_ac >= org_ab )
- {
- /* on the right on the interpolation zone */
- cur_c = cur_a + cur_ab + FT_MulFix( org_ac - org_ab, scale );
- }
- else
- {
- /* within the interpolation zone */
- cur_c = cur_a + FT_MulFix( org_ac, scale_ab );
- }
-
- point->cur_u = cur_c;
-
- point = point->next;
-
- } while ( point != next );
- }
-
- /* keep going until all points in the contours have been processed */
- first = next;
-
- } while ( first != start );
-
- Next_Contour:
- ;
- }
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** HIGH-LEVEL INTERFACE *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- FT_Error
- ps_hints_apply( PS_Hints ps_hints,
- FT_Outline* outline,
- PSH_Globals globals,
- FT_Render_Mode hint_mode )
- {
- PSH_GlyphRec glyphrec;
- PSH_Glyph glyph = &glyphrec;
- FT_Error error;
-#ifdef DEBUG_HINTER
- FT_Memory memory;
-#endif
- FT_Int dimension;
-
-
- /* something to do? */
- if ( outline->n_points == 0 || outline->n_contours == 0 )
- return FT_Err_Ok;
-
-#ifdef DEBUG_HINTER
-
- memory = globals->memory;
-
- if ( ps_debug_glyph )
- {
- psh_glyph_done( ps_debug_glyph );
- FT_FREE( ps_debug_glyph );
- }
-
- if ( FT_NEW( glyph ) )
- return error;
-
- ps_debug_glyph = glyph;
-
-#endif /* DEBUG_HINTER */
-
- error = psh_glyph_init( glyph, outline, ps_hints, globals );
- if ( error )
- goto Exit;
-
- /* try to optimize the y_scale so that the top of non-capital letters
- * is aligned on a pixel boundary whenever possible
- */
- {
- PSH_Dimension dim_x = &glyph->globals->dimension[0];
- PSH_Dimension dim_y = &glyph->globals->dimension[1];
-
- FT_Fixed x_scale = dim_x->scale_mult;
- FT_Fixed y_scale = dim_y->scale_mult;
-
- FT_Fixed old_x_scale = x_scale;
- FT_Fixed old_y_scale = y_scale;
-
- FT_Fixed scaled = 0;
- FT_Fixed fitted = 0;
-
- FT_Bool rescale = FALSE;
-
-
- if ( globals->blues.normal_top.count )
- {
- scaled = FT_MulFix( globals->blues.normal_top.zones->org_ref, y_scale );
- fitted = FT_PIX_ROUND( scaled );
- }
-
- if ( fitted != 0 && scaled != fitted )
- {
- rescale = TRUE;
-
- y_scale = FT_MulDiv( y_scale, fitted, scaled );
-
- if ( fitted < scaled )
- x_scale -= x_scale / 50;
-
- psh_globals_set_scale( glyph->globals, x_scale, y_scale, 0, 0 );
- }
-
- glyph->do_horz_hints = 1;
- glyph->do_vert_hints = 1;
-
- glyph->do_horz_snapping = FT_BOOL( hint_mode == FT_RENDER_MODE_MONO ||
- hint_mode == FT_RENDER_MODE_LCD );
-
- glyph->do_vert_snapping = FT_BOOL( hint_mode == FT_RENDER_MODE_MONO ||
- hint_mode == FT_RENDER_MODE_LCD_V );
-
- glyph->do_stem_adjust = FT_BOOL( hint_mode != FT_RENDER_MODE_LIGHT );
-
- for ( dimension = 0; dimension < 2; dimension++ )
- {
- /* load outline coordinates into glyph */
- psh_glyph_load_points( glyph, dimension );
-
- /* compute local extrema */
- psh_glyph_compute_extrema( glyph );
-
- /* compute aligned stem/hints positions */
- psh_hint_table_align_hints( &glyph->hint_tables[dimension],
- glyph->globals,
- dimension,
- glyph );
-
- /* find strong points, align them, then interpolate others */
- psh_glyph_find_strong_points( glyph, dimension );
- if ( dimension == 1 )
- psh_glyph_find_blue_points( &globals->blues, glyph );
- psh_glyph_interpolate_strong_points( glyph, dimension );
- psh_glyph_interpolate_normal_points( glyph, dimension );
- psh_glyph_interpolate_other_points( glyph, dimension );
-
- /* save hinted coordinates back to outline */
- psh_glyph_save_points( glyph, dimension );
-
- if ( rescale )
- psh_globals_set_scale( glyph->globals,
- old_x_scale, old_y_scale, 0, 0 );
- }
- }
-
- Exit:
-
-#ifndef DEBUG_HINTER
- psh_glyph_done( glyph );
-#endif
-
- return error;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/pshinter/pshalgo.h b/contrib/libs/freetype/src/pshinter/pshalgo.h
deleted file mode 100644
index fb362f061b..0000000000
--- a/contrib/libs/freetype/src/pshinter/pshalgo.h
+++ /dev/null
@@ -1,233 +0,0 @@
-/****************************************************************************
- *
- * pshalgo.h
- *
- * PostScript hinting algorithm (specification).
- *
- * Copyright (C) 2001-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef PSHALGO_H_
-#define PSHALGO_H_
-
-
-#include "pshrec.h"
-#include "pshglob.h"
-
-
-FT_BEGIN_HEADER
-
-
- /* handle to Hint structure */
- typedef struct PSH_HintRec_* PSH_Hint;
-
-
- /* hint bit-flags */
-#define PSH_HINT_GHOST PS_HINT_FLAG_GHOST
-#define PSH_HINT_BOTTOM PS_HINT_FLAG_BOTTOM
-#define PSH_HINT_ACTIVE 4U
-#define PSH_HINT_FITTED 8U
-
-
-#define psh_hint_is_active( x ) ( ( (x)->flags & PSH_HINT_ACTIVE ) != 0 )
-#define psh_hint_is_ghost( x ) ( ( (x)->flags & PSH_HINT_GHOST ) != 0 )
-#define psh_hint_is_fitted( x ) ( ( (x)->flags & PSH_HINT_FITTED ) != 0 )
-
-#define psh_hint_activate( x ) (x)->flags |= PSH_HINT_ACTIVE
-#define psh_hint_deactivate( x ) (x)->flags &= ~PSH_HINT_ACTIVE
-#define psh_hint_set_fitted( x ) (x)->flags |= PSH_HINT_FITTED
-
-
- /* hint structure */
- typedef struct PSH_HintRec_
- {
- FT_Int org_pos;
- FT_Int org_len;
- FT_Pos cur_pos;
- FT_Pos cur_len;
- FT_UInt flags;
- PSH_Hint parent;
- FT_Int order;
-
- } PSH_HintRec;
-
-
- /* this is an interpolation zone used for strong points; */
- /* weak points are interpolated according to their strong */
- /* neighbours */
- typedef struct PSH_ZoneRec_
- {
- FT_Fixed scale;
- FT_Fixed delta;
- FT_Pos min;
- FT_Pos max;
-
- } PSH_ZoneRec, *PSH_Zone;
-
-
- typedef struct PSH_Hint_TableRec_
- {
- FT_UInt max_hints;
- FT_UInt num_hints;
- PSH_Hint hints;
- PSH_Hint* sort;
- PSH_Hint* sort_global;
- FT_UInt num_zones;
- PSH_ZoneRec* zones;
- PSH_Zone zone;
- PS_Mask_Table hint_masks;
- PS_Mask_Table counter_masks;
-
- } PSH_Hint_TableRec, *PSH_Hint_Table;
-
-
- typedef struct PSH_PointRec_* PSH_Point;
- typedef struct PSH_ContourRec_* PSH_Contour;
-
- typedef enum PSH_Dir_
- {
- PSH_DIR_NONE = 0,
- PSH_DIR_UP = 1,
- PSH_DIR_DOWN = 2,
- PSH_DIR_VERTICAL = 1 | 2,
- PSH_DIR_LEFT = 4,
- PSH_DIR_RIGHT = 8,
- PSH_DIR_HORIZONTAL = 4 | 8
-
- } PSH_Dir;
-
-
- /* the following bit-flags are computed once by the glyph */
- /* analyzer, for both dimensions */
-#define PSH_POINT_OFF 1U /* point is off the curve */
-#define PSH_POINT_SMOOTH 2U /* point is smooth */
-#define PSH_POINT_INFLEX 4U /* point is inflection */
-
-
-#define psh_point_is_smooth( p ) ( (p)->flags & PSH_POINT_SMOOTH )
-#define psh_point_is_off( p ) ( (p)->flags & PSH_POINT_OFF )
-#define psh_point_is_inflex( p ) ( (p)->flags & PSH_POINT_INFLEX )
-
-#define psh_point_set_smooth( p ) (p)->flags |= PSH_POINT_SMOOTH
-#define psh_point_set_off( p ) (p)->flags |= PSH_POINT_OFF
-#define psh_point_set_inflex( p ) (p)->flags |= PSH_POINT_INFLEX
-
-
- /* the following bit-flags are re-computed for each dimension */
-#define PSH_POINT_STRONG 16U /* point is strong */
-#define PSH_POINT_FITTED 32U /* point is already fitted */
-#define PSH_POINT_EXTREMUM 64U /* point is local extremum */
-#define PSH_POINT_POSITIVE 128U /* extremum has positive contour flow */
-#define PSH_POINT_NEGATIVE 256U /* extremum has negative contour flow */
-#define PSH_POINT_EDGE_MIN 512U /* point is aligned to left/bottom stem edge */
-#define PSH_POINT_EDGE_MAX 1024U /* point is aligned to top/right stem edge */
-
-
-#define psh_point_is_strong( p ) ( (p)->flags2 & PSH_POINT_STRONG )
-#define psh_point_is_fitted( p ) ( (p)->flags2 & PSH_POINT_FITTED )
-#define psh_point_is_extremum( p ) ( (p)->flags2 & PSH_POINT_EXTREMUM )
-#define psh_point_is_positive( p ) ( (p)->flags2 & PSH_POINT_POSITIVE )
-#define psh_point_is_negative( p ) ( (p)->flags2 & PSH_POINT_NEGATIVE )
-#define psh_point_is_edge_min( p ) ( (p)->flags2 & PSH_POINT_EDGE_MIN )
-#define psh_point_is_edge_max( p ) ( (p)->flags2 & PSH_POINT_EDGE_MAX )
-
-#define psh_point_set_strong( p ) (p)->flags2 |= PSH_POINT_STRONG
-#define psh_point_set_fitted( p ) (p)->flags2 |= PSH_POINT_FITTED
-#define psh_point_set_extremum( p ) (p)->flags2 |= PSH_POINT_EXTREMUM
-#define psh_point_set_positive( p ) (p)->flags2 |= PSH_POINT_POSITIVE
-#define psh_point_set_negative( p ) (p)->flags2 |= PSH_POINT_NEGATIVE
-#define psh_point_set_edge_min( p ) (p)->flags2 |= PSH_POINT_EDGE_MIN
-#define psh_point_set_edge_max( p ) (p)->flags2 |= PSH_POINT_EDGE_MAX
-
-
- typedef struct PSH_PointRec_
- {
- PSH_Point prev;
- PSH_Point next;
- PSH_Contour contour;
- FT_UInt flags;
- FT_UInt flags2;
- PSH_Dir dir_in;
- PSH_Dir dir_out;
- PSH_Hint hint;
- FT_Pos org_u;
- FT_Pos org_v;
- FT_Pos cur_u;
-#ifdef DEBUG_HINTER
- FT_Pos org_x;
- FT_Pos cur_x;
- FT_Pos org_y;
- FT_Pos cur_y;
- FT_UInt flags_x;
- FT_UInt flags_y;
-#endif
-
- } PSH_PointRec;
-
-
- typedef struct PSH_ContourRec_
- {
- PSH_Point start;
- FT_UInt count;
-
- } PSH_ContourRec;
-
-
- typedef struct PSH_GlyphRec_
- {
- FT_UInt num_points;
- FT_UInt num_contours;
-
- PSH_Point points;
- PSH_Contour contours;
-
- FT_Memory memory;
- FT_Outline* outline;
- PSH_Globals globals;
- PSH_Hint_TableRec hint_tables[2];
-
- FT_Bool do_horz_hints;
- FT_Bool do_vert_hints;
- FT_Bool do_horz_snapping;
- FT_Bool do_vert_snapping;
- FT_Bool do_stem_adjust;
-
- } PSH_GlyphRec, *PSH_Glyph;
-
-
-#ifdef DEBUG_HINTER
- extern PSH_Hint_Table ps_debug_hint_table;
-
- typedef void
- (*PSH_HintFunc)( PSH_Hint hint,
- FT_Bool vertical );
-
- extern PSH_HintFunc ps_debug_hint_func;
-
- extern PSH_Glyph ps_debug_glyph;
-#endif
-
-
- extern FT_Error
- ps_hints_apply( PS_Hints ps_hints,
- FT_Outline* outline,
- PSH_Globals globals,
- FT_Render_Mode hint_mode );
-
-
-FT_END_HEADER
-
-
-#endif /* PSHALGO_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/pshinter/pshglob.c b/contrib/libs/freetype/src/pshinter/pshglob.c
deleted file mode 100644
index 435f45838f..0000000000
--- a/contrib/libs/freetype/src/pshinter/pshglob.c
+++ /dev/null
@@ -1,795 +0,0 @@
-/****************************************************************************
- *
- * pshglob.c
- *
- * PostScript hinter global hinting management (body).
- * Inspired by the new auto-hinter module.
- *
- * Copyright (C) 2001-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used
- * modified and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/freetype.h>
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/ftcalc.h>
-#include "pshglob.h"
-
-#ifdef DEBUG_HINTER
- PSH_Globals ps_debug_globals = NULL;
-#endif
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** STANDARD WIDTHS *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /* scale the widths/heights table */
- static void
- psh_globals_scale_widths( PSH_Globals globals,
- FT_UInt direction )
- {
- PSH_Dimension dim = &globals->dimension[direction];
- PSH_Widths stdw = &dim->stdw;
- FT_UInt count = stdw->count;
- PSH_Width width = stdw->widths;
- PSH_Width stand = width; /* standard width/height */
- FT_Fixed scale = dim->scale_mult;
-
-
- if ( count > 0 )
- {
- width->cur = FT_MulFix( width->org, scale );
- width->fit = FT_PIX_ROUND( width->cur );
-
- width++;
- count--;
-
- for ( ; count > 0; count--, width++ )
- {
- FT_Pos w, dist;
-
-
- w = FT_MulFix( width->org, scale );
- dist = w - stand->cur;
-
- if ( dist < 0 )
- dist = -dist;
-
- if ( dist < 128 )
- w = stand->cur;
-
- width->cur = w;
- width->fit = FT_PIX_ROUND( w );
- }
- }
- }
-
-
-#if 0
-
- /* org_width is in font units, result in device pixels, 26.6 format */
- FT_LOCAL_DEF( FT_Pos )
- psh_dimension_snap_width( PSH_Dimension dimension,
- FT_Int org_width )
- {
- FT_UInt n;
- FT_Pos width = FT_MulFix( org_width, dimension->scale_mult );
- FT_Pos best = 64 + 32 + 2;
- FT_Pos reference = width;
-
-
- for ( n = 0; n < dimension->stdw.count; n++ )
- {
- FT_Pos w;
- FT_Pos dist;
-
-
- w = dimension->stdw.widths[n].cur;
- dist = width - w;
- if ( dist < 0 )
- dist = -dist;
- if ( dist < best )
- {
- best = dist;
- reference = w;
- }
- }
-
- if ( width >= reference )
- {
- width -= 0x21;
- if ( width < reference )
- width = reference;
- }
- else
- {
- width += 0x21;
- if ( width > reference )
- width = reference;
- }
-
- return width;
- }
-
-#endif /* 0 */
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** BLUE ZONES *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- static void
- psh_blues_set_zones_0( PSH_Blues target,
- FT_Bool is_others,
- FT_UInt read_count,
- FT_Short* read,
- PSH_Blue_Table top_table,
- PSH_Blue_Table bot_table )
- {
- FT_UInt count_top = top_table->count;
- FT_UInt count_bot = bot_table->count;
- FT_Bool first = 1;
-
- FT_UNUSED( target );
-
-
- for ( ; read_count > 1; read_count -= 2 )
- {
- FT_Int reference, delta;
- FT_UInt count;
- PSH_Blue_Zone zones, zone;
- FT_Bool top;
-
-
- /* read blue zone entry, and select target top/bottom zone */
- top = 0;
- if ( first || is_others )
- {
- reference = read[1];
- delta = read[0] - reference;
-
- zones = bot_table->zones;
- count = count_bot;
- first = 0;
- }
- else
- {
- reference = read[0];
- delta = read[1] - reference;
-
- zones = top_table->zones;
- count = count_top;
- top = 1;
- }
-
- /* insert into sorted table */
- zone = zones;
- for ( ; count > 0; count--, zone++ )
- {
- if ( reference < zone->org_ref )
- break;
-
- if ( reference == zone->org_ref )
- {
- FT_Int delta0 = zone->org_delta;
-
-
- /* we have two zones on the same reference position -- */
- /* only keep the largest one */
- if ( delta < 0 )
- {
- if ( delta < delta0 )
- zone->org_delta = delta;
- }
- else
- {
- if ( delta > delta0 )
- zone->org_delta = delta;
- }
- goto Skip;
- }
- }
-
- for ( ; count > 0; count-- )
- zone[count] = zone[count-1];
-
- zone->org_ref = reference;
- zone->org_delta = delta;
-
- if ( top )
- count_top++;
- else
- count_bot++;
-
- Skip:
- read += 2;
- }
-
- top_table->count = count_top;
- bot_table->count = count_bot;
- }
-
-
- /* Re-read blue zones from the original fonts and store them into our */
- /* private structure. This function re-orders, sanitizes, and */
- /* fuzz-expands the zones as well. */
- static void
- psh_blues_set_zones( PSH_Blues target,
- FT_UInt count,
- FT_Short* blues,
- FT_UInt count_others,
- FT_Short* other_blues,
- FT_Int fuzz,
- FT_Int family )
- {
- PSH_Blue_Table top_table, bot_table;
- FT_UInt count_top, count_bot;
-
-
- if ( family )
- {
- top_table = &target->family_top;
- bot_table = &target->family_bottom;
- }
- else
- {
- top_table = &target->normal_top;
- bot_table = &target->normal_bottom;
- }
-
- /* read the input blue zones, and build two sorted tables */
- /* (one for the top zones, the other for the bottom zones) */
- top_table->count = 0;
- bot_table->count = 0;
-
- /* first, the blues */
- psh_blues_set_zones_0( target, 0,
- count, blues, top_table, bot_table );
- psh_blues_set_zones_0( target, 1,
- count_others, other_blues, top_table, bot_table );
-
- count_top = top_table->count;
- count_bot = bot_table->count;
-
- /* sanitize top table */
- if ( count_top > 0 )
- {
- PSH_Blue_Zone zone = top_table->zones;
-
-
- for ( count = count_top; count > 0; count--, zone++ )
- {
- FT_Int delta;
-
-
- if ( count > 1 )
- {
- delta = zone[1].org_ref - zone[0].org_ref;
- if ( zone->org_delta > delta )
- zone->org_delta = delta;
- }
-
- zone->org_bottom = zone->org_ref;
- zone->org_top = zone->org_delta + zone->org_ref;
- }
- }
-
- /* sanitize bottom table */
- if ( count_bot > 0 )
- {
- PSH_Blue_Zone zone = bot_table->zones;
-
-
- for ( count = count_bot; count > 0; count--, zone++ )
- {
- FT_Int delta;
-
-
- if ( count > 1 )
- {
- delta = zone[0].org_ref - zone[1].org_ref;
- if ( zone->org_delta < delta )
- zone->org_delta = delta;
- }
-
- zone->org_top = zone->org_ref;
- zone->org_bottom = zone->org_delta + zone->org_ref;
- }
- }
-
- /* expand top and bottom tables with blue fuzz */
- {
- FT_Int dim, top, bot, delta;
- PSH_Blue_Zone zone;
-
-
- zone = top_table->zones;
- count = count_top;
-
- for ( dim = 1; dim >= 0; dim-- )
- {
- if ( count > 0 )
- {
- /* expand the bottom of the lowest zone normally */
- zone->org_bottom -= fuzz;
-
- /* expand the top and bottom of intermediate zones; */
- /* checking that the interval is smaller than the fuzz */
- top = zone->org_top;
-
- for ( count--; count > 0; count-- )
- {
- bot = zone[1].org_bottom;
- delta = bot - top;
-
- if ( delta / 2 < fuzz )
- zone[0].org_top = zone[1].org_bottom = top + delta / 2;
- else
- {
- zone[0].org_top = top + fuzz;
- zone[1].org_bottom = bot - fuzz;
- }
-
- zone++;
- top = zone->org_top;
- }
-
- /* expand the top of the highest zone normally */
- zone->org_top = top + fuzz;
- }
- zone = bot_table->zones;
- count = count_bot;
- }
- }
- }
-
-
- /* reset the blues table when the device transform changes */
- static void
- psh_blues_scale_zones( PSH_Blues blues,
- FT_Fixed scale,
- FT_Pos delta )
- {
- FT_UInt count;
- FT_UInt num;
- PSH_Blue_Table table = NULL;
-
- /* */
- /* Determine whether we need to suppress overshoots or */
- /* not. We simply need to compare the vertical scale */
- /* parameter to the raw bluescale value. Here is why: */
- /* */
- /* We need to suppress overshoots for all pointsizes. */
- /* At 300dpi that satisfies: */
- /* */
- /* pointsize < 240*bluescale + 0.49 */
- /* */
- /* This corresponds to: */
- /* */
- /* pixelsize < 1000*bluescale + 49/24 */
- /* */
- /* scale*EM_Size < 1000*bluescale + 49/24 */
- /* */
- /* However, for normal Type 1 fonts, EM_Size is 1000! */
- /* We thus only check: */
- /* */
- /* scale < bluescale + 49/24000 */
- /* */
- /* which we shorten to */
- /* */
- /* "scale < bluescale" */
- /* */
- /* Note that `blue_scale' is stored 1000 times its real */
- /* value, and that `scale' converts from font units to */
- /* fractional pixels. */
- /* */
-
- /* 1000 / 64 = 125 / 8 */
- if ( scale >= 0x20C49BAL )
- blues->no_overshoots = FT_BOOL( scale < blues->blue_scale * 8 / 125 );
- else
- blues->no_overshoots = FT_BOOL( scale * 125 < blues->blue_scale * 8 );
-
- /* */
- /* The blue threshold is the font units distance under */
- /* which overshoots are suppressed due to the BlueShift */
- /* even if the scale is greater than BlueScale. */
- /* */
- /* It is the smallest distance such that */
- /* */
- /* dist <= BlueShift && dist*scale <= 0.5 pixels */
- /* */
- {
- FT_Int threshold = blues->blue_shift;
-
-
- while ( threshold > 0 && FT_MulFix( threshold, scale ) > 32 )
- threshold--;
-
- blues->blue_threshold = threshold;
- }
-
- for ( num = 0; num < 4; num++ )
- {
- PSH_Blue_Zone zone;
-
-
- switch ( num )
- {
- case 0:
- table = &blues->normal_top;
- break;
- case 1:
- table = &blues->normal_bottom;
- break;
- case 2:
- table = &blues->family_top;
- break;
- default:
- table = &blues->family_bottom;
- break;
- }
-
- zone = table->zones;
- count = table->count;
- for ( ; count > 0; count--, zone++ )
- {
- zone->cur_top = FT_MulFix( zone->org_top, scale ) + delta;
- zone->cur_bottom = FT_MulFix( zone->org_bottom, scale ) + delta;
- zone->cur_ref = FT_MulFix( zone->org_ref, scale ) + delta;
- zone->cur_delta = FT_MulFix( zone->org_delta, scale );
-
- /* round scaled reference position */
- zone->cur_ref = FT_PIX_ROUND( zone->cur_ref );
-
-#if 0
- if ( zone->cur_ref > zone->cur_top )
- zone->cur_ref -= 64;
- else if ( zone->cur_ref < zone->cur_bottom )
- zone->cur_ref += 64;
-#endif
- }
- }
-
- /* process the families now */
-
- for ( num = 0; num < 2; num++ )
- {
- PSH_Blue_Zone zone1, zone2;
- FT_UInt count1, count2;
- PSH_Blue_Table normal, family;
-
-
- switch ( num )
- {
- case 0:
- normal = &blues->normal_top;
- family = &blues->family_top;
- break;
-
- default:
- normal = &blues->normal_bottom;
- family = &blues->family_bottom;
- }
-
- zone1 = normal->zones;
- count1 = normal->count;
-
- for ( ; count1 > 0; count1--, zone1++ )
- {
- /* try to find a family zone whose reference position is less */
- /* than 1 pixel far from the current zone */
- zone2 = family->zones;
- count2 = family->count;
-
- for ( ; count2 > 0; count2--, zone2++ )
- {
- FT_Pos Delta;
-
-
- Delta = zone1->org_ref - zone2->org_ref;
- if ( Delta < 0 )
- Delta = -Delta;
-
- if ( FT_MulFix( Delta, scale ) < 64 )
- {
- zone1->cur_top = zone2->cur_top;
- zone1->cur_bottom = zone2->cur_bottom;
- zone1->cur_ref = zone2->cur_ref;
- zone1->cur_delta = zone2->cur_delta;
- break;
- }
- }
- }
- }
- }
-
-
- /* calculate the maximum height of given blue zones */
- static FT_Short
- psh_calc_max_height( FT_UInt num,
- const FT_Short* values,
- FT_Short cur_max )
- {
- FT_UInt count;
-
-
- for ( count = 0; count < num; count += 2 )
- {
- FT_Short cur_height = values[count + 1] - values[count];
-
-
- if ( cur_height > cur_max )
- cur_max = cur_height;
- }
-
- return cur_max;
- }
-
-
- FT_LOCAL_DEF( void )
- psh_blues_snap_stem( PSH_Blues blues,
- FT_Int stem_top,
- FT_Int stem_bot,
- PSH_Alignment alignment )
- {
- PSH_Blue_Table table;
- FT_UInt count;
- FT_Pos delta;
- PSH_Blue_Zone zone;
- FT_Int no_shoots;
-
-
- alignment->align = PSH_BLUE_ALIGN_NONE;
-
- no_shoots = blues->no_overshoots;
-
- /* look up stem top in top zones table */
- table = &blues->normal_top;
- count = table->count;
- zone = table->zones;
-
- for ( ; count > 0; count--, zone++ )
- {
- delta = SUB_LONG( stem_top, zone->org_bottom );
- if ( delta < -blues->blue_fuzz )
- break;
-
- if ( stem_top <= zone->org_top + blues->blue_fuzz )
- {
- if ( no_shoots || delta <= blues->blue_threshold )
- {
- alignment->align |= PSH_BLUE_ALIGN_TOP;
- alignment->align_top = zone->cur_ref;
- }
- break;
- }
- }
-
- /* look up stem bottom in bottom zones table */
- table = &blues->normal_bottom;
- count = table->count;
- zone = table->zones + count-1;
-
- for ( ; count > 0; count--, zone-- )
- {
- delta = SUB_LONG( zone->org_top, stem_bot );
- if ( delta < -blues->blue_fuzz )
- break;
-
- if ( stem_bot >= zone->org_bottom - blues->blue_fuzz )
- {
- if ( no_shoots || delta < blues->blue_threshold )
- {
- alignment->align |= PSH_BLUE_ALIGN_BOT;
- alignment->align_bot = zone->cur_ref;
- }
- break;
- }
- }
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** GLOBAL HINTS *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- static void
- psh_globals_destroy( PSH_Globals globals )
- {
- if ( globals )
- {
- FT_Memory memory;
-
-
- memory = globals->memory;
- globals->dimension[0].stdw.count = 0;
- globals->dimension[1].stdw.count = 0;
-
- globals->blues.normal_top.count = 0;
- globals->blues.normal_bottom.count = 0;
- globals->blues.family_top.count = 0;
- globals->blues.family_bottom.count = 0;
-
- FT_FREE( globals );
-
-#ifdef DEBUG_HINTER
- ps_debug_globals = NULL;
-#endif
- }
- }
-
-
- static FT_Error
- psh_globals_new( FT_Memory memory,
- T1_Private* priv,
- PSH_Globals *aglobals )
- {
- PSH_Globals globals = NULL;
- FT_Error error;
-
-
- if ( !FT_QNEW( globals ) )
- {
- FT_UInt count;
- FT_Short* read;
-
-
- globals->memory = memory;
-
- /* copy standard widths */
- {
- PSH_Dimension dim = &globals->dimension[1];
- PSH_Width write = dim->stdw.widths;
-
-
- write->org = priv->standard_width[0];
- write++;
-
- read = priv->snap_widths;
- for ( count = priv->num_snap_widths; count > 0; count-- )
- {
- write->org = *read;
- write++;
- read++;
- }
-
- dim->stdw.count = priv->num_snap_widths + 1;
- }
-
- /* copy standard heights */
- {
- PSH_Dimension dim = &globals->dimension[0];
- PSH_Width write = dim->stdw.widths;
-
-
- write->org = priv->standard_height[0];
- write++;
- read = priv->snap_heights;
- for ( count = priv->num_snap_heights; count > 0; count-- )
- {
- write->org = *read;
- write++;
- read++;
- }
-
- dim->stdw.count = priv->num_snap_heights + 1;
- }
-
- /* copy blue zones */
- psh_blues_set_zones( &globals->blues, priv->num_blue_values,
- priv->blue_values, priv->num_other_blues,
- priv->other_blues, priv->blue_fuzz, 0 );
-
- psh_blues_set_zones( &globals->blues, priv->num_family_blues,
- priv->family_blues, priv->num_family_other_blues,
- priv->family_other_blues, priv->blue_fuzz, 1 );
-
- /* limit the BlueScale value to `1 / max_of_blue_zone_heights' */
- {
- FT_Fixed max_scale;
- FT_Short max_height = 1;
-
-
- max_height = psh_calc_max_height( priv->num_blue_values,
- priv->blue_values,
- max_height );
- max_height = psh_calc_max_height( priv->num_other_blues,
- priv->other_blues,
- max_height );
- max_height = psh_calc_max_height( priv->num_family_blues,
- priv->family_blues,
- max_height );
- max_height = psh_calc_max_height( priv->num_family_other_blues,
- priv->family_other_blues,
- max_height );
-
- /* BlueScale is scaled 1000 times */
- max_scale = FT_DivFix( 1000, max_height );
- globals->blues.blue_scale = priv->blue_scale < max_scale
- ? priv->blue_scale
- : max_scale;
- }
-
- globals->blues.blue_shift = priv->blue_shift;
- globals->blues.blue_fuzz = priv->blue_fuzz;
-
- globals->dimension[0].scale_mult = 0;
- globals->dimension[0].scale_delta = 0;
- globals->dimension[1].scale_mult = 0;
- globals->dimension[1].scale_delta = 0;
-
-#ifdef DEBUG_HINTER
- ps_debug_globals = globals;
-#endif
- }
-
- *aglobals = globals;
- return error;
- }
-
-
- FT_LOCAL_DEF( void )
- psh_globals_set_scale( PSH_Globals globals,
- FT_Fixed x_scale,
- FT_Fixed y_scale,
- FT_Fixed x_delta,
- FT_Fixed y_delta )
- {
- PSH_Dimension dim;
-
-
- dim = &globals->dimension[0];
- if ( x_scale != dim->scale_mult ||
- x_delta != dim->scale_delta )
- {
- dim->scale_mult = x_scale;
- dim->scale_delta = x_delta;
-
- psh_globals_scale_widths( globals, 0 );
- }
-
- dim = &globals->dimension[1];
- if ( y_scale != dim->scale_mult ||
- y_delta != dim->scale_delta )
- {
- dim->scale_mult = y_scale;
- dim->scale_delta = y_delta;
-
- psh_globals_scale_widths( globals, 1 );
- psh_blues_scale_zones( &globals->blues, y_scale, y_delta );
- }
- }
-
-
- FT_LOCAL_DEF( void )
- psh_globals_funcs_init( PSH_Globals_FuncsRec* funcs )
- {
- funcs->create = psh_globals_new;
- funcs->set_scale = psh_globals_set_scale;
- funcs->destroy = psh_globals_destroy;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/pshinter/pshglob.h b/contrib/libs/freetype/src/pshinter/pshglob.h
deleted file mode 100644
index c5a5c91316..0000000000
--- a/contrib/libs/freetype/src/pshinter/pshglob.h
+++ /dev/null
@@ -1,196 +0,0 @@
-/****************************************************************************
- *
- * pshglob.h
- *
- * PostScript hinter global hinting management.
- *
- * Copyright (C) 2001-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef PSHGLOB_H_
-#define PSHGLOB_H_
-
-
-#include <freetype/freetype.h>
-#include <freetype/internal/pshints.h>
-
-
-FT_BEGIN_HEADER
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** GLOBAL HINTS INTERNALS *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /**************************************************************************
- *
- * @constant:
- * PS_GLOBALS_MAX_BLUE_ZONES
- *
- * @description:
- * The maximum number of blue zones in a font global hints structure.
- * See @PS_Globals_BluesRec.
- */
-#define PS_GLOBALS_MAX_BLUE_ZONES 16
-
-
- /**************************************************************************
- *
- * @constant:
- * PS_GLOBALS_MAX_STD_WIDTHS
- *
- * @description:
- * The maximum number of standard and snap widths in either the
- * horizontal or vertical direction. See @PS_Globals_WidthsRec.
- */
-#define PS_GLOBALS_MAX_STD_WIDTHS 16
-
-
- /* standard and snap width */
- typedef struct PSH_WidthRec_
- {
- FT_Int org;
- FT_Pos cur;
- FT_Pos fit;
-
- } PSH_WidthRec, *PSH_Width;
-
-
- /* standard and snap widths table */
- typedef struct PSH_WidthsRec_
- {
- FT_UInt count;
- PSH_WidthRec widths[PS_GLOBALS_MAX_STD_WIDTHS];
-
- } PSH_WidthsRec, *PSH_Widths;
-
-
- typedef struct PSH_DimensionRec_
- {
- PSH_WidthsRec stdw;
- FT_Fixed scale_mult;
- FT_Fixed scale_delta;
-
- } PSH_DimensionRec, *PSH_Dimension;
-
-
- /* blue zone descriptor */
- typedef struct PSH_Blue_ZoneRec_
- {
- FT_Int org_ref;
- FT_Int org_delta;
- FT_Int org_top;
- FT_Int org_bottom;
-
- FT_Pos cur_ref;
- FT_Pos cur_delta;
- FT_Pos cur_bottom;
- FT_Pos cur_top;
-
- } PSH_Blue_ZoneRec, *PSH_Blue_Zone;
-
-
- typedef struct PSH_Blue_TableRec_
- {
- FT_UInt count;
- PSH_Blue_ZoneRec zones[PS_GLOBALS_MAX_BLUE_ZONES];
-
- } PSH_Blue_TableRec, *PSH_Blue_Table;
-
-
- /* blue zones table */
- typedef struct PSH_BluesRec_
- {
- PSH_Blue_TableRec normal_top;
- PSH_Blue_TableRec normal_bottom;
- PSH_Blue_TableRec family_top;
- PSH_Blue_TableRec family_bottom;
-
- FT_Fixed blue_scale;
- FT_Int blue_shift;
- FT_Int blue_threshold;
- FT_Int blue_fuzz;
- FT_Bool no_overshoots;
-
- } PSH_BluesRec, *PSH_Blues;
-
-
- /* font globals. */
- /* dimension 0 => X coordinates + vertical hints/stems */
- /* dimension 1 => Y coordinates + horizontal hints/stems */
- typedef struct PSH_GlobalsRec_
- {
- FT_Memory memory;
- PSH_DimensionRec dimension[2];
- PSH_BluesRec blues;
-
- } PSH_GlobalsRec;
-
-
-#define PSH_BLUE_ALIGN_NONE 0
-#define PSH_BLUE_ALIGN_TOP 1
-#define PSH_BLUE_ALIGN_BOT 2
-
-
- typedef struct PSH_AlignmentRec_
- {
- int align;
- FT_Pos align_top;
- FT_Pos align_bot;
-
- } PSH_AlignmentRec, *PSH_Alignment;
-
-
- FT_LOCAL( void )
- psh_globals_funcs_init( PSH_Globals_FuncsRec* funcs );
-
-
-#if 0
- /* snap a stem width to fitter coordinates. `org_width' is in font */
- /* units. The result is in device pixels (26.6 format). */
- FT_LOCAL( FT_Pos )
- psh_dimension_snap_width( PSH_Dimension dimension,
- FT_Int org_width );
-#endif
-
- FT_LOCAL( void )
- psh_globals_set_scale( PSH_Globals globals,
- FT_Fixed x_scale,
- FT_Fixed y_scale,
- FT_Fixed x_delta,
- FT_Fixed y_delta );
-
- /* snap a stem to one or two blue zones */
- FT_LOCAL( void )
- psh_blues_snap_stem( PSH_Blues blues,
- FT_Int stem_top,
- FT_Int stem_bot,
- PSH_Alignment alignment );
- /* */
-
-#ifdef DEBUG_HINTER
- extern PSH_Globals ps_debug_globals;
-#endif
-
-
-FT_END_HEADER
-
-
-#endif /* PSHGLOB_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/pshinter/pshinter.c b/contrib/libs/freetype/src/pshinter/pshinter.c
deleted file mode 100644
index ae2b53fee5..0000000000
--- a/contrib/libs/freetype/src/pshinter/pshinter.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/****************************************************************************
- *
- * pshinter.c
- *
- * FreeType PostScript Hinting module
- *
- * Copyright (C) 2001-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#define FT_MAKE_OPTION_SINGLE_OBJECT
-
-#include "pshalgo.c"
-#include "pshglob.c"
-#include "pshmod.c"
-#include "pshrec.c"
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/pshinter/pshmod.c b/contrib/libs/freetype/src/pshinter/pshmod.c
deleted file mode 100644
index 9965d5b16b..0000000000
--- a/contrib/libs/freetype/src/pshinter/pshmod.c
+++ /dev/null
@@ -1,125 +0,0 @@
-/****************************************************************************
- *
- * pshmod.c
- *
- * FreeType PostScript hinter module implementation (body).
- *
- * Copyright (C) 2001-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftobjs.h>
-#include "pshrec.h"
-#include "pshalgo.h"
-#include "pshmod.h"
-
-
- /* the Postscript Hinter module structure */
- typedef struct PS_Hinter_Module_Rec_
- {
- FT_ModuleRec root;
- PS_HintsRec ps_hints;
-
- PSH_Globals_FuncsRec globals_funcs;
- T1_Hints_FuncsRec t1_funcs;
- T2_Hints_FuncsRec t2_funcs;
-
- } PS_Hinter_ModuleRec, *PS_Hinter_Module;
-
-
- /* finalize module */
- FT_CALLBACK_DEF( void )
- ps_hinter_done( FT_Module module_ ) /* PS_Hinter_Module */
- {
- PS_Hinter_Module module = (PS_Hinter_Module)module_;
-
-
- module->t1_funcs.hints = NULL;
- module->t2_funcs.hints = NULL;
-
- ps_hints_done( &module->ps_hints );
- }
-
-
- /* initialize module, create hints recorder and the interface */
- FT_CALLBACK_DEF( FT_Error )
- ps_hinter_init( FT_Module module_ ) /* PS_Hinter_Module */
- {
- PS_Hinter_Module module = (PS_Hinter_Module)module_;
-
- FT_Memory memory = module->root.memory;
- void* ph = &module->ps_hints;
-
-
- ps_hints_init( &module->ps_hints, memory );
-
- psh_globals_funcs_init( &module->globals_funcs );
-
- t1_hints_funcs_init( &module->t1_funcs );
- module->t1_funcs.hints = (T1_Hints)ph;
-
- t2_hints_funcs_init( &module->t2_funcs );
- module->t2_funcs.hints = (T2_Hints)ph;
-
- return 0;
- }
-
-
- /* returns global hints interface */
- FT_CALLBACK_DEF( PSH_Globals_Funcs )
- pshinter_get_globals_funcs( FT_Module module )
- {
- return &((PS_Hinter_Module)module)->globals_funcs;
- }
-
-
- /* return Type 1 hints interface */
- FT_CALLBACK_DEF( T1_Hints_Funcs )
- pshinter_get_t1_funcs( FT_Module module )
- {
- return &((PS_Hinter_Module)module)->t1_funcs;
- }
-
-
- /* return Type 2 hints interface */
- FT_CALLBACK_DEF( T2_Hints_Funcs )
- pshinter_get_t2_funcs( FT_Module module )
- {
- return &((PS_Hinter_Module)module)->t2_funcs;
- }
-
-
- FT_DEFINE_PSHINTER_INTERFACE(
- pshinter_interface,
-
- pshinter_get_globals_funcs,
- pshinter_get_t1_funcs,
- pshinter_get_t2_funcs
- )
-
-
- FT_DEFINE_MODULE(
- pshinter_module_class,
-
- 0,
- sizeof ( PS_Hinter_ModuleRec ),
- "pshinter",
- 0x10000L,
- 0x20000L,
-
- &pshinter_interface, /* module-specific interface */
-
- (FT_Module_Constructor)ps_hinter_init, /* module_init */
- (FT_Module_Destructor) ps_hinter_done, /* module_done */
- (FT_Module_Requester) NULL /* get_interface */
- )
-
-/* END */
diff --git a/contrib/libs/freetype/src/pshinter/pshmod.h b/contrib/libs/freetype/src/pshinter/pshmod.h
deleted file mode 100644
index 62ac0a60fd..0000000000
--- a/contrib/libs/freetype/src/pshinter/pshmod.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/****************************************************************************
- *
- * pshmod.h
- *
- * PostScript hinter module interface (specification).
- *
- * Copyright (C) 2001-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef PSHMOD_H_
-#define PSHMOD_H_
-
-
-#include <freetype/ftmodapi.h>
-
-
-FT_BEGIN_HEADER
-
-
- FT_DECLARE_MODULE( pshinter_module_class )
-
-
-FT_END_HEADER
-
-
-#endif /* PSHMOD_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/pshinter/pshnterr.h b/contrib/libs/freetype/src/pshinter/pshnterr.h
deleted file mode 100644
index e9641340e5..0000000000
--- a/contrib/libs/freetype/src/pshinter/pshnterr.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/****************************************************************************
- *
- * pshnterr.h
- *
- * PS Hinter error codes (specification only).
- *
- * Copyright (C) 2003-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /**************************************************************************
- *
- * This file is used to define the PSHinter error enumeration constants.
- *
- */
-
-#ifndef PSHNTERR_H_
-#define PSHNTERR_H_
-
-#include <freetype/ftmoderr.h>
-
-#undef FTERRORS_H_
-
-#undef FT_ERR_PREFIX
-#define FT_ERR_PREFIX PSH_Err_
-#define FT_ERR_BASE FT_Mod_Err_PShinter
-
-#include <freetype/fterrors.h>
-
-#endif /* PSHNTERR_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/pshinter/pshrec.c b/contrib/libs/freetype/src/pshinter/pshrec.c
deleted file mode 100644
index 0b2b549fc2..0000000000
--- a/contrib/libs/freetype/src/pshinter/pshrec.c
+++ /dev/null
@@ -1,1224 +0,0 @@
-/****************************************************************************
- *
- * pshrec.c
- *
- * FreeType PostScript hints recorder (body).
- *
- * Copyright (C) 2001-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/freetype.h>
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftcalc.h>
-
-#include "pshrec.h"
-#include "pshalgo.h"
-
-#include "pshnterr.h"
-
-#undef FT_COMPONENT
-#define FT_COMPONENT pshrec
-
-#ifdef DEBUG_HINTER
- PS_Hints ps_debug_hints = NULL;
- int ps_debug_no_horz_hints = 0;
- int ps_debug_no_vert_hints = 0;
-#endif
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** PS_HINT MANAGEMENT *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- /* destroy hints table */
- static void
- ps_hint_table_done( PS_Hint_Table table,
- FT_Memory memory )
- {
- FT_FREE( table->hints );
- table->num_hints = 0;
- table->max_hints = 0;
- }
-
-
- /* ensure that a table can contain "count" elements */
- static FT_Error
- ps_hint_table_ensure( PS_Hint_Table table,
- FT_UInt count,
- FT_Memory memory )
- {
- FT_UInt old_max = table->max_hints;
- FT_UInt new_max = count;
- FT_Error error;
-
-
- /* try to grow the table */
- new_max = FT_PAD_CEIL( new_max, 8 );
- if ( !FT_QRENEW_ARRAY( table->hints, old_max, new_max ) )
- table->max_hints = new_max;
-
- return error;
- }
-
-
- static FT_Error
- ps_hint_table_alloc( PS_Hint_Table table,
- FT_Memory memory,
- PS_Hint *ahint )
- {
- FT_Error error = FT_Err_Ok;
- FT_UInt count;
- PS_Hint hint = NULL;
-
-
- count = table->num_hints;
- count++;
-
- if ( count > table->max_hints )
- {
- error = ps_hint_table_ensure( table, count, memory );
- if ( error )
- goto Exit;
- }
-
- hint = table->hints + count - 1; /* initialized upstream */
-
- table->num_hints = count;
-
- Exit:
- *ahint = hint;
- return error;
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** PS_MASK MANAGEMENT *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- /* destroy mask */
- static void
- ps_mask_done( PS_Mask mask,
- FT_Memory memory )
- {
- FT_FREE( mask->bytes );
- mask->num_bits = 0;
- mask->max_bits = 0;
- mask->end_point = 0;
- }
-
-
- /* ensure that a mask can contain "count" bits */
- static FT_Error
- ps_mask_ensure( PS_Mask mask,
- FT_UInt count,
- FT_Memory memory )
- {
- FT_UInt old_max = mask->max_bits >> 3;
- FT_UInt new_max = ( count + 7 ) >> 3;
- FT_Error error = FT_Err_Ok;
-
-
- if ( new_max > old_max )
- {
- new_max = FT_PAD_CEIL( new_max, 8 );
- /* added bytes are zeroed here */
- if ( !FT_RENEW_ARRAY( mask->bytes, old_max, new_max ) )
- mask->max_bits = new_max * 8;
- }
- return error;
- }
-
-
- /* test a bit value in a given mask */
- static FT_Int
- ps_mask_test_bit( PS_Mask mask,
- FT_UInt idx )
- {
- if ( idx >= mask->num_bits )
- return 0;
-
- return mask->bytes[idx >> 3] & ( 0x80 >> ( idx & 7 ) );
- }
-
-
- /* set a given bit, possibly grow the mask */
- static FT_Error
- ps_mask_set_bit( PS_Mask mask,
- FT_UInt idx,
- FT_Memory memory )
- {
- FT_Error error = FT_Err_Ok;
- FT_Byte* p;
-
-
- if ( idx >= mask->num_bits )
- {
- error = ps_mask_ensure( mask, idx + 1, memory );
- if ( error )
- goto Exit;
-
- mask->num_bits = idx + 1;
- }
-
- p = mask->bytes + ( idx >> 3 );
- p[0] = (FT_Byte)( p[0] | ( 0x80 >> ( idx & 7 ) ) );
-
- Exit:
- return error;
- }
-
-
- /* destroy mask table */
- static void
- ps_mask_table_done( PS_Mask_Table table,
- FT_Memory memory )
- {
- FT_UInt count = table->max_masks;
- PS_Mask mask = table->masks;
-
-
- for ( ; count > 0; count--, mask++ )
- ps_mask_done( mask, memory );
-
- FT_FREE( table->masks );
- table->num_masks = 0;
- table->max_masks = 0;
- }
-
-
- /* ensure that a mask table can contain "count" masks */
- static FT_Error
- ps_mask_table_ensure( PS_Mask_Table table,
- FT_UInt count,
- FT_Memory memory )
- {
- FT_UInt old_max = table->max_masks;
- FT_UInt new_max = count;
- FT_Error error = FT_Err_Ok;
-
-
- if ( new_max > old_max )
- {
- new_max = FT_PAD_CEIL( new_max, 8 );
- if ( !FT_RENEW_ARRAY( table->masks, old_max, new_max ) )
- table->max_masks = new_max;
- }
- return error;
- }
-
-
- /* allocate a new mask in a table */
- static FT_Error
- ps_mask_table_alloc( PS_Mask_Table table,
- FT_Memory memory,
- PS_Mask *amask )
- {
- FT_UInt count;
- FT_Error error = FT_Err_Ok;
- PS_Mask mask = NULL;
-
-
- count = table->num_masks;
- count++;
-
- if ( count > table->max_masks )
- {
- error = ps_mask_table_ensure( table, count, memory );
- if ( error )
- goto Exit;
- }
-
- mask = table->masks + count - 1;
- mask->num_bits = 0;
- mask->end_point = 0;
- /* reused mask must be cleared */
- if ( mask->max_bits )
- FT_MEM_ZERO( mask->bytes, mask->max_bits >> 3 );
-
- table->num_masks = count;
-
- Exit:
- *amask = mask;
- return error;
- }
-
-
- /* return last hint mask in a table, create one if the table is empty */
- static FT_Error
- ps_mask_table_last( PS_Mask_Table table,
- FT_Memory memory,
- PS_Mask *amask )
- {
- FT_Error error = FT_Err_Ok;
- FT_UInt count;
- PS_Mask mask;
-
-
- count = table->num_masks;
- if ( count == 0 )
- {
- error = ps_mask_table_alloc( table, memory, &mask );
- if ( error )
- goto Exit;
- }
- else
- mask = table->masks + count - 1;
-
- Exit:
- *amask = mask;
- return error;
- }
-
-
- /* set a new mask to a given bit range */
- static FT_Error
- ps_mask_table_set_bits( PS_Mask_Table table,
- const FT_Byte* source,
- FT_UInt bit_pos,
- FT_UInt bit_count,
- FT_Memory memory )
- {
- FT_Error error;
- PS_Mask mask;
-
-
- error = ps_mask_table_last( table, memory, &mask );
- if ( error )
- goto Exit;
-
- error = ps_mask_ensure( mask, bit_count, memory );
- if ( error )
- goto Exit;
-
- mask->num_bits = bit_count;
-
- /* now, copy bits */
- {
- FT_Byte* read = (FT_Byte*)source + ( bit_pos >> 3 );
- FT_Int rmask = 0x80 >> ( bit_pos & 7 );
- FT_Byte* write = mask->bytes;
- FT_Int wmask = 0x80;
- FT_Int val;
-
-
- for ( ; bit_count > 0; bit_count-- )
- {
- val = write[0] & ~wmask;
-
- if ( read[0] & rmask )
- val |= wmask;
-
- write[0] = (FT_Byte)val;
-
- rmask >>= 1;
- if ( rmask == 0 )
- {
- read++;
- rmask = 0x80;
- }
-
- wmask >>= 1;
- if ( wmask == 0 )
- {
- write++;
- wmask = 0x80;
- }
- }
- }
-
- Exit:
- return error;
- }
-
-
- /* test whether two masks in a table intersect */
- static FT_Int
- ps_mask_table_test_intersect( PS_Mask_Table table,
- FT_UInt index1,
- FT_UInt index2 )
- {
- PS_Mask mask1 = table->masks + index1;
- PS_Mask mask2 = table->masks + index2;
- FT_Byte* p1 = mask1->bytes;
- FT_Byte* p2 = mask2->bytes;
- FT_UInt count1 = mask1->num_bits;
- FT_UInt count2 = mask2->num_bits;
- FT_UInt count;
-
-
- count = FT_MIN( count1, count2 );
- for ( ; count >= 8; count -= 8 )
- {
- if ( p1[0] & p2[0] )
- return 1;
-
- p1++;
- p2++;
- }
-
- if ( count == 0 )
- return 0;
-
- return ( p1[0] & p2[0] ) & ~( 0xFF >> count );
- }
-
-
- /* merge two masks, used by ps_mask_table_merge_all */
- static FT_Error
- ps_mask_table_merge( PS_Mask_Table table,
- FT_UInt index1,
- FT_UInt index2,
- FT_Memory memory )
- {
- FT_Error error = FT_Err_Ok;
-
-
- /* swap index1 and index2 so that index1 < index2 */
- if ( index1 > index2 )
- {
- FT_UInt temp;
-
-
- temp = index1;
- index1 = index2;
- index2 = temp;
- }
-
- if ( index1 < index2 && index2 < table->num_masks )
- {
- /* we need to merge the bitsets of index1 and index2 with a */
- /* simple union */
- PS_Mask mask1 = table->masks + index1;
- PS_Mask mask2 = table->masks + index2;
- FT_UInt count1 = mask1->num_bits;
- FT_UInt count2 = mask2->num_bits;
- FT_UInt delta;
-
-
- if ( count2 > 0 )
- {
- FT_UInt pos;
- FT_Byte* read;
- FT_Byte* write;
-
-
- /* if "count2" is greater than "count1", we need to grow the */
- /* first bitset */
- if ( count2 > count1 )
- {
- error = ps_mask_ensure( mask1, count2, memory );
- if ( error )
- goto Exit;
-
- mask1->num_bits = count2;
- }
-
- /* merge (unite) the bitsets */
- read = mask2->bytes;
- write = mask1->bytes;
- pos = ( count2 + 7 ) >> 3;
-
- for ( ; pos > 0; pos-- )
- {
- write[0] = (FT_Byte)( write[0] | read[0] );
- write++;
- read++;
- }
- }
-
- /* Now, remove "mask2" from the list. We need to keep the masks */
- /* sorted in order of importance, so move table elements. */
- mask2->num_bits = 0;
- mask2->end_point = 0;
-
- /* number of masks to move */
- delta = table->num_masks - 1 - index2;
- if ( delta > 0 )
- {
- /* move to end of table for reuse */
- PS_MaskRec dummy = *mask2;
-
-
- ft_memmove( mask2,
- mask2 + 1,
- delta * sizeof ( PS_MaskRec ) );
-
- mask2[delta] = dummy;
- }
-
- table->num_masks--;
- }
- else
- FT_TRACE0(( "ps_mask_table_merge: ignoring invalid indices (%d,%d)\n",
- index1, index2 ));
-
- Exit:
- return error;
- }
-
-
- /* Try to merge all masks in a given table. This is used to merge */
- /* all counter masks into independent counter "paths". */
- /* */
- static FT_Error
- ps_mask_table_merge_all( PS_Mask_Table table,
- FT_Memory memory )
- {
- FT_UInt index1, index2;
- FT_Error error = FT_Err_Ok;
-
-
- /* the loops stop when unsigned indices wrap around after 0 */
- for ( index1 = table->num_masks - 1; index1 < table->num_masks; index1-- )
- {
- for ( index2 = index1 - 1; index2 < index1; index2-- )
- {
- if ( ps_mask_table_test_intersect( table, index1, index2 ) )
- {
- error = ps_mask_table_merge( table, index2, index1, memory );
- if ( error )
- goto Exit;
-
- break;
- }
- }
- }
-
- Exit:
- return error;
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** PS_DIMENSION MANAGEMENT *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /* finalize a given dimension */
- static void
- ps_dimension_done( PS_Dimension dimension,
- FT_Memory memory )
- {
- ps_mask_table_done( &dimension->counters, memory );
- ps_mask_table_done( &dimension->masks, memory );
- ps_hint_table_done( &dimension->hints, memory );
- }
-
-
- /* initialize a given dimension */
- static void
- ps_dimension_init( PS_Dimension dimension )
- {
- dimension->hints.num_hints = 0;
- dimension->masks.num_masks = 0;
- dimension->counters.num_masks = 0;
- }
-
-
-#if 0
-
- /* set a bit at a given index in the current hint mask */
- static FT_Error
- ps_dimension_set_mask_bit( PS_Dimension dim,
- FT_UInt idx,
- FT_Memory memory )
- {
- PS_Mask mask;
- FT_Error error = FT_Err_Ok;
-
-
- /* get last hint mask */
- error = ps_mask_table_last( &dim->masks, memory, &mask );
- if ( error )
- goto Exit;
-
- error = ps_mask_set_bit( mask, idx, memory );
-
- Exit:
- return error;
- }
-
-#endif
-
- /* set the end point in a mask, called from "End" & "Reset" methods */
- static void
- ps_dimension_end_mask( PS_Dimension dim,
- FT_UInt end_point )
- {
- FT_UInt count = dim->masks.num_masks;
-
-
- if ( count > 0 )
- {
- PS_Mask mask = dim->masks.masks + count - 1;
-
-
- mask->end_point = end_point;
- }
- }
-
-
- /* set the end point in the current mask, then create a new empty one */
- /* (called by "Reset" method) */
- static FT_Error
- ps_dimension_reset_mask( PS_Dimension dim,
- FT_UInt end_point,
- FT_Memory memory )
- {
- PS_Mask mask;
-
-
- /* end current mask */
- ps_dimension_end_mask( dim, end_point );
-
- /* allocate new one */
- return ps_mask_table_alloc( &dim->masks, memory, &mask );
- }
-
-
- /* set a new mask, called from the "T2Stem" method */
- static FT_Error
- ps_dimension_set_mask_bits( PS_Dimension dim,
- const FT_Byte* source,
- FT_UInt source_pos,
- FT_UInt source_bits,
- FT_UInt end_point,
- FT_Memory memory )
- {
- FT_Error error;
-
-
- /* reset current mask, if any */
- error = ps_dimension_reset_mask( dim, end_point, memory );
- if ( error )
- goto Exit;
-
- /* set bits in new mask */
- error = ps_mask_table_set_bits( &dim->masks, source,
- source_pos, source_bits, memory );
-
- Exit:
- return error;
- }
-
-
- /* add a new single stem (called from "T1Stem" method) */
- static FT_Error
- ps_dimension_add_t1stem( PS_Dimension dim,
- FT_Int pos,
- FT_Int len,
- FT_Memory memory,
- FT_UInt *aindex )
- {
- FT_Error error = FT_Err_Ok;
- FT_UInt flags = 0;
-
-
- /* detect ghost stem */
- if ( len < 0 )
- {
- flags |= PS_HINT_FLAG_GHOST;
- if ( len == -21 )
- {
- flags |= PS_HINT_FLAG_BOTTOM;
- pos = ADD_INT( pos, len );
- }
- len = 0;
- }
-
- /* now, lookup stem in the current hints table */
- {
- PS_Mask mask;
- FT_UInt idx;
- FT_UInt max = dim->hints.num_hints;
- PS_Hint hint = dim->hints.hints;
-
-
- for ( idx = 0; idx < max; idx++, hint++ )
- {
- if ( hint->pos == pos && hint->len == len )
- break;
- }
-
- /* we need to create a new hint in the table */
- if ( idx >= max )
- {
- error = ps_hint_table_alloc( &dim->hints, memory, &hint );
- if ( error )
- goto Exit;
-
- hint->pos = pos;
- hint->len = len;
- hint->flags = flags;
- }
-
- /* now, store the hint in the current mask */
- error = ps_mask_table_last( &dim->masks, memory, &mask );
- if ( error )
- goto Exit;
-
- error = ps_mask_set_bit( mask, idx, memory );
- if ( error )
- goto Exit;
-
- if ( aindex )
- *aindex = idx;
- }
-
- Exit:
- return error;
- }
-
-
- /* add a "hstem3/vstem3" counter to our dimension table */
- static FT_Error
- ps_dimension_add_counter( PS_Dimension dim,
- FT_UInt hint1,
- FT_UInt hint2,
- FT_UInt hint3,
- FT_Memory memory )
- {
- FT_Error error = FT_Err_Ok;
- FT_UInt count = dim->counters.num_masks;
- PS_Mask counter = dim->counters.masks;
-
-
- /* try to find an existing counter mask that already uses */
- /* one of these stems here */
- for ( ; count > 0; count--, counter++ )
- {
- if ( ps_mask_test_bit( counter, hint1 ) ||
- ps_mask_test_bit( counter, hint2 ) ||
- ps_mask_test_bit( counter, hint3 ) )
- break;
- }
-
- /* create a new counter when needed */
- if ( count == 0 )
- {
- error = ps_mask_table_alloc( &dim->counters, memory, &counter );
- if ( error )
- goto Exit;
- }
-
- /* now, set the bits for our hints in the counter mask */
- error = ps_mask_set_bit( counter, hint1, memory );
- if ( error )
- goto Exit;
-
- error = ps_mask_set_bit( counter, hint2, memory );
- if ( error )
- goto Exit;
-
- error = ps_mask_set_bit( counter, hint3, memory );
- if ( error )
- goto Exit;
-
- Exit:
- return error;
- }
-
-
- /* end of recording session for a given dimension */
- static FT_Error
- ps_dimension_end( PS_Dimension dim,
- FT_UInt end_point,
- FT_Memory memory )
- {
- /* end hint mask table */
- ps_dimension_end_mask( dim, end_point );
-
- /* merge all counter masks into independent "paths" */
- return ps_mask_table_merge_all( &dim->counters, memory );
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** PS_RECORDER MANAGEMENT *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /* destroy hints */
- FT_LOCAL_DEF( void )
- ps_hints_done( PS_Hints hints )
- {
- FT_Memory memory = hints->memory;
-
-
- ps_dimension_done( &hints->dimension[0], memory );
- ps_dimension_done( &hints->dimension[1], memory );
-
- hints->error = FT_Err_Ok;
- hints->memory = NULL;
- }
-
-
- FT_LOCAL_DEF( void )
- ps_hints_init( PS_Hints hints,
- FT_Memory memory )
- {
- FT_ZERO( hints );
- hints->memory = memory;
- }
-
-
- /* initialize a hints for a new session */
- static void
- ps_hints_open( PS_Hints hints,
- PS_Hint_Type hint_type )
- {
- hints->error = FT_Err_Ok;
- hints->hint_type = hint_type;
-
- ps_dimension_init( &hints->dimension[0] );
- ps_dimension_init( &hints->dimension[1] );
- }
-
-
- /* add one or more stems to the current hints table */
- static void
- ps_hints_stem( PS_Hints hints,
- FT_UInt dimension,
- FT_Int count,
- FT_Pos* stems )
- {
- PS_Dimension dim;
-
-
- if ( hints->error )
- return;
-
- /* limit "dimension" to 0..1 */
- if ( dimension > 1 )
- {
- FT_TRACE0(( "ps_hints_stem: invalid dimension (%d) used\n",
- dimension ));
- dimension = ( dimension != 0 );
- }
-
- /* record the stems in the current hints/masks table */
- /* (Type 1 & 2's `hstem' or `vstem' operators) */
- dim = &hints->dimension[dimension];
-
- for ( ; count > 0; count--, stems += 2 )
- {
- FT_Error error;
- FT_Memory memory = hints->memory;
-
-
- error = ps_dimension_add_t1stem( dim,
- (FT_Int)stems[0],
- (FT_Int)stems[1],
- memory,
- NULL );
- if ( error )
- {
- FT_ERROR(( "ps_hints_stem: could not add stem"
- " (%ld,%ld) to hints table\n", stems[0], stems[1] ));
-
- hints->error = error;
- return;
- }
- }
- }
-
-
- /* add one Type1 counter stem to the current hints table */
- static void
- ps_hints_t1stem3( T1_Hints hints_, /* PS_Hints */
- FT_UInt dimension,
- FT_Fixed* stems )
- {
- PS_Hints hints = (PS_Hints)hints_;
- FT_Error error = FT_Err_Ok;
-
-
- if ( !hints->error )
- {
- PS_Dimension dim;
- FT_Memory memory = hints->memory;
- FT_Int count;
- FT_UInt idx[3];
-
-
- /* limit "dimension" to 0..1 */
- if ( dimension > 1 )
- {
- FT_TRACE0(( "ps_hints_t1stem3: invalid dimension (%d) used\n",
- dimension ));
- dimension = ( dimension != 0 );
- }
-
- dim = &hints->dimension[dimension];
-
- /* there must be 6 elements in the 'stem' array */
- if ( hints->hint_type == PS_HINT_TYPE_1 )
- {
- /* add the three stems to our hints/masks table */
- for ( count = 0; count < 3; count++, stems += 2 )
- {
- error = ps_dimension_add_t1stem( dim,
- (FT_Int)FIXED_TO_INT( stems[0] ),
- (FT_Int)FIXED_TO_INT( stems[1] ),
- memory, &idx[count] );
- if ( error )
- goto Fail;
- }
-
- /* now, add the hints to the counters table */
- error = ps_dimension_add_counter( dim, idx[0], idx[1], idx[2],
- memory );
- if ( error )
- goto Fail;
- }
- else
- {
- FT_ERROR(( "ps_hints_t1stem3: called with invalid hint type\n" ));
- error = FT_THROW( Invalid_Argument );
- goto Fail;
- }
- }
-
- return;
-
- Fail:
- FT_ERROR(( "ps_hints_t1stem3: could not add counter stems to table\n" ));
- hints->error = error;
- }
-
-
- /* reset hints (only with Type 1 hints) */
- static void
- ps_hints_t1reset( T1_Hints hints_, /* PS_Hints */
- FT_UInt end_point )
- {
- PS_Hints hints = (PS_Hints)hints_;
- FT_Error error = FT_Err_Ok;
-
-
- if ( !hints->error )
- {
- FT_Memory memory = hints->memory;
-
-
- if ( hints->hint_type == PS_HINT_TYPE_1 )
- {
- error = ps_dimension_reset_mask( &hints->dimension[0],
- end_point, memory );
- if ( error )
- goto Fail;
-
- error = ps_dimension_reset_mask( &hints->dimension[1],
- end_point, memory );
- if ( error )
- goto Fail;
- }
- else
- {
- /* invalid hint type */
- error = FT_THROW( Invalid_Argument );
- goto Fail;
- }
- }
- return;
-
- Fail:
- hints->error = error;
- }
-
-
- /* Type2 "hintmask" operator, add a new hintmask to each direction */
- static void
- ps_hints_t2mask( T2_Hints hints_, /* PS_Hints */
- FT_UInt end_point,
- FT_UInt bit_count,
- const FT_Byte* bytes )
- {
- PS_Hints hints = (PS_Hints)hints_;
- FT_Error error;
-
-
- if ( !hints->error )
- {
- PS_Dimension dim = hints->dimension;
- FT_Memory memory = hints->memory;
- FT_UInt count1 = dim[0].hints.num_hints;
- FT_UInt count2 = dim[1].hints.num_hints;
-
-
- /* check bit count; must be equal to current total hint count */
- if ( bit_count != count1 + count2 )
- {
- FT_TRACE0(( "ps_hints_t2mask:"
- " called with invalid bitcount %d (instead of %d)\n",
- bit_count, count1 + count2 ));
-
- /* simply ignore the operator */
- return;
- }
-
- /* set-up new horizontal and vertical hint mask now */
- error = ps_dimension_set_mask_bits( &dim[0], bytes, count2, count1,
- end_point, memory );
- if ( error )
- goto Fail;
-
- error = ps_dimension_set_mask_bits( &dim[1], bytes, 0, count2,
- end_point, memory );
- if ( error )
- goto Fail;
- }
- return;
-
- Fail:
- hints->error = error;
- }
-
-
- static void
- ps_hints_t2counter( T2_Hints hints_, /* PS_Hints */
- FT_UInt bit_count,
- const FT_Byte* bytes )
- {
- PS_Hints hints = (PS_Hints)hints_;
- FT_Error error;
-
-
- if ( !hints->error )
- {
- PS_Dimension dim = hints->dimension;
- FT_Memory memory = hints->memory;
- FT_UInt count1 = dim[0].hints.num_hints;
- FT_UInt count2 = dim[1].hints.num_hints;
-
-
- /* check bit count, must be equal to current total hint count */
- if ( bit_count != count1 + count2 )
- {
- FT_TRACE0(( "ps_hints_t2counter:"
- " called with invalid bitcount %d (instead of %d)\n",
- bit_count, count1 + count2 ));
-
- /* simply ignore the operator */
- return;
- }
-
- /* set-up new horizontal and vertical hint mask now */
- error = ps_dimension_set_mask_bits( &dim[0], bytes, 0, count1,
- 0, memory );
- if ( error )
- goto Fail;
-
- error = ps_dimension_set_mask_bits( &dim[1], bytes, count1, count2,
- 0, memory );
- if ( error )
- goto Fail;
- }
- return;
-
- Fail:
- hints->error = error;
- }
-
-
- /* end recording session */
- static FT_Error
- ps_hints_close( PS_Hints hints,
- FT_UInt end_point )
- {
- FT_Error error;
-
-
- error = hints->error;
- if ( !error )
- {
- FT_Memory memory = hints->memory;
- PS_Dimension dim = hints->dimension;
-
-
- error = ps_dimension_end( &dim[0], end_point, memory );
- if ( !error )
- {
- error = ps_dimension_end( &dim[1], end_point, memory );
- }
- }
-
-#ifdef DEBUG_HINTER
- if ( !error )
- ps_debug_hints = hints;
-#endif
- return error;
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** TYPE 1 HINTS RECORDING INTERFACE *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- static void
- t1_hints_open( T1_Hints hints )
- {
- ps_hints_open( (PS_Hints)hints, PS_HINT_TYPE_1 );
- }
-
- static FT_Error
- t1_hints_close( T1_Hints hints,
- FT_UInt end_point )
- {
- return ps_hints_close( (PS_Hints)hints, end_point );
- }
-
- static void
- t1_hints_stem( T1_Hints hints,
- FT_UInt dimension,
- FT_Fixed* coords )
- {
- FT_Pos stems[2];
-
-
- stems[0] = FIXED_TO_INT( coords[0] );
- stems[1] = FIXED_TO_INT( coords[1] );
-
- ps_hints_stem( (PS_Hints)hints, dimension, 1, stems );
- }
-
-
- static FT_Error
- t1_hints_apply( T1_Hints hints,
- FT_Outline* outline,
- PSH_Globals globals,
- FT_Render_Mode hint_mode )
- {
- return ps_hints_apply( (PS_Hints)hints, outline, globals, hint_mode );
- }
-
-
- FT_LOCAL_DEF( void )
- t1_hints_funcs_init( T1_Hints_FuncsRec* funcs )
- {
- FT_ZERO( funcs );
-
- funcs->open = (T1_Hints_OpenFunc) t1_hints_open;
- funcs->close = (T1_Hints_CloseFunc) t1_hints_close;
- funcs->stem = (T1_Hints_SetStemFunc) t1_hints_stem;
- funcs->stem3 = (T1_Hints_SetStem3Func)ps_hints_t1stem3;
- funcs->reset = (T1_Hints_ResetFunc) ps_hints_t1reset;
- funcs->apply = (T1_Hints_ApplyFunc) t1_hints_apply;
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** TYPE 2 HINTS RECORDING INTERFACE *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- static void
- t2_hints_open( T2_Hints hints )
- {
- ps_hints_open( (PS_Hints)hints, PS_HINT_TYPE_2 );
- }
-
-
- static FT_Error
- t2_hints_close( T2_Hints hints,
- FT_UInt end_point )
- {
- return ps_hints_close( (PS_Hints)hints, end_point );
- }
-
-
- static void
- t2_hints_stems( T2_Hints hints,
- FT_UInt dimension,
- FT_Int count,
- FT_Fixed* coords )
- {
- FT_Pos stems[32], y;
- FT_Int total = count, n;
-
-
- y = 0;
- while ( total > 0 )
- {
- /* determine number of stems to write */
- count = total;
- if ( count > 16 )
- count = 16;
-
- /* compute integer stem positions in font units */
- for ( n = 0; n < count * 2; n++ )
- {
- y = ADD_LONG( y, coords[n] );
- stems[n] = FIXED_TO_INT( y );
- }
-
- /* compute lengths */
- for ( n = 0; n < count * 2; n += 2 )
- stems[n + 1] = stems[n + 1] - stems[n];
-
- /* add them to the current dimension */
- ps_hints_stem( (PS_Hints)hints, dimension, count, stems );
-
- total -= count;
- }
- }
-
-
- static FT_Error
- t2_hints_apply( T2_Hints hints,
- FT_Outline* outline,
- PSH_Globals globals,
- FT_Render_Mode hint_mode )
- {
- return ps_hints_apply( (PS_Hints)hints, outline, globals, hint_mode );
- }
-
-
- FT_LOCAL_DEF( void )
- t2_hints_funcs_init( T2_Hints_FuncsRec* funcs )
- {
- FT_ZERO( funcs );
-
- funcs->open = (T2_Hints_OpenFunc) t2_hints_open;
- funcs->close = (T2_Hints_CloseFunc) t2_hints_close;
- funcs->stems = (T2_Hints_StemsFunc) t2_hints_stems;
- funcs->hintmask = (T2_Hints_MaskFunc) ps_hints_t2mask;
- funcs->counter = (T2_Hints_CounterFunc)ps_hints_t2counter;
- funcs->apply = (T2_Hints_ApplyFunc) t2_hints_apply;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/pshinter/pshrec.h b/contrib/libs/freetype/src/pshinter/pshrec.h
deleted file mode 100644
index 7e375af7ba..0000000000
--- a/contrib/libs/freetype/src/pshinter/pshrec.h
+++ /dev/null
@@ -1,171 +0,0 @@
-/****************************************************************************
- *
- * pshrec.h
- *
- * Postscript (Type1/Type2) hints recorder (specification).
- *
- * Copyright (C) 2001-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /***************************************************************************
- *
- * The functions defined here are called from the Type 1, CID and CFF
- * font drivers to record the hints of a given character/glyph.
- *
- * The hints are recorded in a unified format, and are later processed
- * by the `optimizer' and `fitter' to adjust the outlines to the pixel
- * grid.
- *
- */
-
-
-#ifndef PSHREC_H_
-#define PSHREC_H_
-
-
-#include <freetype/internal/pshints.h>
-#include "pshglob.h"
-
-
-FT_BEGIN_HEADER
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** GLYPH HINTS RECORDER INTERNALS *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- /* handle to hint record */
- typedef struct PS_HintRec_* PS_Hint;
-
- /* hint types */
- typedef enum PS_Hint_Type_
- {
- PS_HINT_TYPE_1 = 1,
- PS_HINT_TYPE_2 = 2
-
- } PS_Hint_Type;
-
-
- /* hint flags */
-#define PS_HINT_FLAG_GHOST 1U
-#define PS_HINT_FLAG_BOTTOM 2U
-
-
- /* hint descriptor */
- typedef struct PS_HintRec_
- {
- FT_Int pos;
- FT_Int len;
- FT_UInt flags;
-
- } PS_HintRec;
-
-
-#define ps_hint_is_active( x ) ( (x)->flags & PS_HINT_FLAG_ACTIVE )
-#define ps_hint_is_ghost( x ) ( (x)->flags & PS_HINT_FLAG_GHOST )
-#define ps_hint_is_bottom( x ) ( (x)->flags & PS_HINT_FLAG_BOTTOM )
-
-
- /* hints table descriptor */
- typedef struct PS_Hint_TableRec_
- {
- FT_UInt num_hints;
- FT_UInt max_hints;
- PS_Hint hints;
-
- } PS_Hint_TableRec, *PS_Hint_Table;
-
-
- /* hint and counter mask descriptor */
- typedef struct PS_MaskRec_
- {
- FT_UInt num_bits;
- FT_UInt max_bits;
- FT_Byte* bytes;
- FT_UInt end_point;
-
- } PS_MaskRec, *PS_Mask;
-
-
- /* masks and counters table descriptor */
- typedef struct PS_Mask_TableRec_
- {
- FT_UInt num_masks;
- FT_UInt max_masks;
- PS_Mask masks;
-
- } PS_Mask_TableRec, *PS_Mask_Table;
-
-
- /* dimension-specific hints descriptor */
- typedef struct PS_DimensionRec_
- {
- PS_Hint_TableRec hints;
- PS_Mask_TableRec masks;
- PS_Mask_TableRec counters;
-
- } PS_DimensionRec, *PS_Dimension;
-
-
- /* glyph hints descriptor */
- /* dimension 0 => X coordinates + vertical hints/stems */
- /* dimension 1 => Y coordinates + horizontal hints/stems */
- typedef struct PS_HintsRec_
- {
- FT_Memory memory;
- FT_Error error;
- FT_UInt32 magic;
- PS_Hint_Type hint_type;
- PS_DimensionRec dimension[2];
-
- } PS_HintsRec, *PS_Hints;
-
- /* */
-
- /* initialize hints recorder */
- FT_LOCAL( void )
- ps_hints_init( PS_Hints hints,
- FT_Memory memory );
-
- /* finalize hints recorder */
- FT_LOCAL( void )
- ps_hints_done( PS_Hints hints );
-
- /* initialize Type1 hints recorder interface */
- FT_LOCAL( void )
- t1_hints_funcs_init( T1_Hints_FuncsRec* funcs );
-
- /* initialize Type2 hints recorder interface */
- FT_LOCAL( void )
- t2_hints_funcs_init( T2_Hints_FuncsRec* funcs );
-
-
-#ifdef DEBUG_HINTER
- extern PS_Hints ps_debug_hints;
- extern int ps_debug_no_horz_hints;
- extern int ps_debug_no_vert_hints;
-#endif
-
- /* */
-
-
-FT_END_HEADER
-
-
-#endif /* PSHREC_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/psnames/psmodule.c b/contrib/libs/freetype/src/psnames/psmodule.c
deleted file mode 100644
index 35d054d1cf..0000000000
--- a/contrib/libs/freetype/src/psnames/psmodule.c
+++ /dev/null
@@ -1,621 +0,0 @@
-/****************************************************************************
- *
- * psmodule.c
- *
- * psnames module implementation (body).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/services/svpscmap.h>
-
-#include "psmodule.h"
-
- /*
- * The file `pstables.h' with its arrays and its function
- * `ft_get_adobe_glyph_index' is useful for other projects also (for
- * example, `pdfium' is using it). However, if used as a C++ header,
- * including it in two different source files makes it necessary to use
- * `extern const' for the declaration of its arrays, otherwise the data
- * would be duplicated as mandated by the C++ standard.
- *
- * For this reason, we use `DEFINE_PS_TABLES' to guard the function
- * definitions, and `DEFINE_PS_TABLES_DATA' to provide both proper array
- * declarations and definitions.
- */
-#include "pstables.h"
-#define DEFINE_PS_TABLES
-#define DEFINE_PS_TABLES_DATA
-#include "pstables.h"
-
-#include "psnamerr.h"
-
-
-#ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
-
-
-#ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST
-
-
-#define VARIANT_BIT 0x80000000UL
-#define BASE_GLYPH( code ) ( (FT_UInt32)( (code) & ~VARIANT_BIT ) )
-
-
- /* Return the Unicode value corresponding to a given glyph. Note that */
- /* we do deal with glyph variants by detecting a non-initial dot in */
- /* the name, as in `A.swash' or `e.final'; in this case, the */
- /* VARIANT_BIT is set in the return value. */
- /* */
- FT_CALLBACK_DEF( FT_UInt32 )
- ps_unicode_value( const char* glyph_name )
- {
- /* If the name begins with `uni', then the glyph name may be a */
- /* hard-coded unicode character code. */
- if ( glyph_name[0] == 'u' &&
- glyph_name[1] == 'n' &&
- glyph_name[2] == 'i' )
- {
- /* determine whether the next four characters following are */
- /* hexadecimal. */
-
- /* XXX: Add code to deal with ligatures, i.e. glyph names like */
- /* `uniXXXXYYYYZZZZ'... */
-
- FT_Int count;
- FT_UInt32 value = 0;
- const char* p = glyph_name + 3;
-
-
- for ( count = 4; count > 0; count--, p++ )
- {
- char c = *p;
- unsigned int d;
-
-
- d = (unsigned char)c - '0';
- if ( d >= 10 )
- {
- d = (unsigned char)c - 'A';
- if ( d >= 6 )
- d = 16;
- else
- d += 10;
- }
-
- /* Exit if a non-uppercase hexadecimal character was found */
- /* -- this also catches character codes below `0' since such */
- /* negative numbers cast to `unsigned int' are far too big. */
- if ( d >= 16 )
- break;
-
- value = ( value << 4 ) + d;
- }
-
- /* there must be exactly four hex digits */
- if ( count == 0 )
- {
- if ( *p == '\0' )
- return value;
- if ( *p == '.' )
- return (FT_UInt32)( value | VARIANT_BIT );
- }
- }
-
- /* If the name begins with `u', followed by four to six uppercase */
- /* hexadecimal digits, it is a hard-coded unicode character code. */
- if ( glyph_name[0] == 'u' )
- {
- FT_Int count;
- FT_UInt32 value = 0;
- const char* p = glyph_name + 1;
-
-
- for ( count = 6; count > 0; count--, p++ )
- {
- char c = *p;
- unsigned int d;
-
-
- d = (unsigned char)c - '0';
- if ( d >= 10 )
- {
- d = (unsigned char)c - 'A';
- if ( d >= 6 )
- d = 16;
- else
- d += 10;
- }
-
- if ( d >= 16 )
- break;
-
- value = ( value << 4 ) + d;
- }
-
- if ( count <= 2 )
- {
- if ( *p == '\0' )
- return value;
- if ( *p == '.' )
- return (FT_UInt32)( value | VARIANT_BIT );
- }
- }
-
- /* Look for a non-initial dot in the glyph name in order to */
- /* find variants like `A.swash', `e.final', etc. */
- {
- FT_UInt32 value = 0;
- const char* p = glyph_name;
-
-
- for ( ; *p && *p != '.'; p++ )
- ;
-
- /* now look up the glyph in the Adobe Glyph List; */
- /* `.notdef', `.null' and the empty name are short cut */
- if ( p > glyph_name )
- {
- value = (FT_UInt32)ft_get_adobe_glyph_index( glyph_name, p );
-
- if ( *p == '.' )
- value |= (FT_UInt32)VARIANT_BIT;
- }
-
- return value;
- }
- }
-
-
- /* ft_qsort callback to sort the unicode map */
- FT_COMPARE_DEF( int )
- compare_uni_maps( const void* a,
- const void* b )
- {
- PS_UniMap* map1 = (PS_UniMap*)a;
- PS_UniMap* map2 = (PS_UniMap*)b;
- FT_UInt32 unicode1 = BASE_GLYPH( map1->unicode );
- FT_UInt32 unicode2 = BASE_GLYPH( map2->unicode );
-
-
- /* sort base glyphs before glyph variants */
- if ( unicode1 == unicode2 )
- {
- if ( map1->unicode > map2->unicode )
- return 1;
- else if ( map1->unicode < map2->unicode )
- return -1;
- else
- return 0;
- }
- else
- {
- if ( unicode1 > unicode2 )
- return 1;
- else if ( unicode1 < unicode2 )
- return -1;
- else
- return 0;
- }
- }
-
-
- /* support for extra glyphs not handled (well) in AGL; */
- /* we add extra mappings for them if necessary */
-
-#define EXTRA_GLYPH_LIST_SIZE 10
-
- static const FT_UInt32 ft_extra_glyph_unicodes[EXTRA_GLYPH_LIST_SIZE] =
- {
- /* WGL 4 */
- 0x0394,
- 0x03A9,
- 0x2215,
- 0x00AD,
- 0x02C9,
- 0x03BC,
- 0x2219,
- 0x00A0,
- /* Romanian */
- 0x021A,
- 0x021B
- };
-
- static const char ft_extra_glyph_names[] =
- {
- 'D','e','l','t','a',0,
- 'O','m','e','g','a',0,
- 'f','r','a','c','t','i','o','n',0,
- 'h','y','p','h','e','n',0,
- 'm','a','c','r','o','n',0,
- 'm','u',0,
- 'p','e','r','i','o','d','c','e','n','t','e','r','e','d',0,
- 's','p','a','c','e',0,
- 'T','c','o','m','m','a','a','c','c','e','n','t',0,
- 't','c','o','m','m','a','a','c','c','e','n','t',0
- };
-
- static const FT_Int
- ft_extra_glyph_name_offsets[EXTRA_GLYPH_LIST_SIZE] =
- {
- 0,
- 6,
- 12,
- 21,
- 28,
- 35,
- 38,
- 53,
- 59,
- 72
- };
-
-
- static void
- ps_check_extra_glyph_name( const char* gname,
- FT_UInt glyph,
- FT_UInt* extra_glyphs,
- FT_UInt *states )
- {
- FT_UInt n;
-
-
- for ( n = 0; n < EXTRA_GLYPH_LIST_SIZE; n++ )
- {
- if ( ft_strcmp( ft_extra_glyph_names +
- ft_extra_glyph_name_offsets[n], gname ) == 0 )
- {
- if ( states[n] == 0 )
- {
- /* mark this extra glyph as a candidate for the cmap */
- states[n] = 1;
- extra_glyphs[n] = glyph;
- }
-
- return;
- }
- }
- }
-
-
- static void
- ps_check_extra_glyph_unicode( FT_UInt32 uni_char,
- FT_UInt *states )
- {
- FT_UInt n;
-
-
- for ( n = 0; n < EXTRA_GLYPH_LIST_SIZE; n++ )
- {
- if ( uni_char == ft_extra_glyph_unicodes[n] )
- {
- /* disable this extra glyph from being added to the cmap */
- states[n] = 2;
-
- return;
- }
- }
- }
-
-
- /* Build a table that maps Unicode values to glyph indices. */
- FT_CALLBACK_DEF( FT_Error )
- ps_unicodes_init( FT_Memory memory,
- PS_Unicodes table,
- FT_UInt num_glyphs,
- PS_GetGlyphNameFunc get_glyph_name,
- PS_FreeGlyphNameFunc free_glyph_name,
- FT_Pointer glyph_data )
- {
- FT_Error error;
-
- FT_UInt extra_glyph_list_states[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- FT_UInt extra_glyphs[EXTRA_GLYPH_LIST_SIZE];
-
-
- /* we first allocate the table */
- table->num_maps = 0;
-
- if ( !FT_QNEW_ARRAY( table->maps, num_glyphs + EXTRA_GLYPH_LIST_SIZE ) )
- {
- FT_UInt n;
- FT_UInt count;
- PS_UniMap* map;
- FT_UInt32 uni_char;
-
-
- map = table->maps;
-
- for ( n = 0; n < num_glyphs; n++ )
- {
- const char* gname = get_glyph_name( glyph_data, n );
-
-
- if ( gname && *gname )
- {
- ps_check_extra_glyph_name( gname, n,
- extra_glyphs, extra_glyph_list_states );
- uni_char = ps_unicode_value( gname );
-
- if ( BASE_GLYPH( uni_char ) != 0 )
- {
- ps_check_extra_glyph_unicode( uni_char,
- extra_glyph_list_states );
- map->unicode = uni_char;
- map->glyph_index = n;
- map++;
- }
-
- if ( free_glyph_name )
- free_glyph_name( glyph_data, gname );
- }
- }
-
- for ( n = 0; n < EXTRA_GLYPH_LIST_SIZE; n++ )
- {
- if ( extra_glyph_list_states[n] == 1 )
- {
- /* This glyph name has an additional representation. */
- /* Add it to the cmap. */
-
- map->unicode = ft_extra_glyph_unicodes[n];
- map->glyph_index = extra_glyphs[n];
- map++;
- }
- }
-
- /* now compress the table a bit */
- count = (FT_UInt)( map - table->maps );
-
- if ( count == 0 )
- {
- /* No unicode chars here! */
- FT_FREE( table->maps );
- if ( !error )
- error = FT_THROW( No_Unicode_Glyph_Name );
- }
- else
- {
- /* Reallocate if the number of used entries is much smaller. */
- if ( count < num_glyphs / 2 )
- {
- FT_MEM_QRENEW_ARRAY( table->maps,
- num_glyphs + EXTRA_GLYPH_LIST_SIZE,
- count );
- error = FT_Err_Ok;
- }
-
- /* Sort the table in increasing order of unicode values, */
- /* taking care of glyph variants. */
- ft_qsort( table->maps, count, sizeof ( PS_UniMap ),
- compare_uni_maps );
- }
-
- table->num_maps = count;
- }
-
- return error;
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- ps_unicodes_char_index( PS_Unicodes table,
- FT_UInt32 unicode )
- {
- PS_UniMap *result = NULL;
- PS_UniMap *min = table->maps;
- PS_UniMap *max = min + table->num_maps;
- PS_UniMap *mid = min + ( ( max - min ) >> 1 );
-
-
- /* Perform a binary search on the table. */
- while ( min < max )
- {
- FT_UInt32 base_glyph;
-
-
- if ( mid->unicode == unicode )
- {
- result = mid;
- break;
- }
-
- base_glyph = BASE_GLYPH( mid->unicode );
-
- if ( base_glyph == unicode )
- result = mid; /* remember match but continue search for base glyph */
-
- if ( base_glyph < unicode )
- min = mid + 1;
- else
- max = mid;
-
- /* reasonable prediction in a continuous block */
- mid += unicode - base_glyph;
- if ( mid >= max || mid < min )
- mid = min + ( ( max - min ) >> 1 );
- }
-
- if ( result )
- return result->glyph_index;
- else
- return 0;
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- ps_unicodes_char_next( PS_Unicodes table,
- FT_UInt32 *unicode )
- {
- FT_UInt result = 0;
- FT_UInt32 char_code = *unicode + 1;
-
-
- {
- FT_UInt min = 0;
- FT_UInt max = table->num_maps;
- FT_UInt mid = min + ( ( max - min ) >> 1 );
- PS_UniMap* map;
- FT_UInt32 base_glyph;
-
-
- while ( min < max )
- {
- map = table->maps + mid;
-
- if ( map->unicode == char_code )
- {
- result = map->glyph_index;
- goto Exit;
- }
-
- base_glyph = BASE_GLYPH( map->unicode );
-
- if ( base_glyph == char_code )
- result = map->glyph_index;
-
- if ( base_glyph < char_code )
- min = mid + 1;
- else
- max = mid;
-
- /* reasonable prediction in a continuous block */
- mid += char_code - base_glyph;
- if ( mid >= max || mid < min )
- mid = min + ( max - min ) / 2;
- }
-
- if ( result )
- goto Exit; /* we have a variant glyph */
-
- /* we didn't find it; check whether we have a map just above it */
- char_code = 0;
-
- if ( min < table->num_maps )
- {
- map = table->maps + min;
- result = map->glyph_index;
- char_code = BASE_GLYPH( map->unicode );
- }
- }
-
- Exit:
- *unicode = char_code;
- return result;
- }
-
-
-#endif /* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST */
-
-
- FT_CALLBACK_DEF( const char* )
- ps_get_macintosh_name( FT_UInt name_index )
- {
- if ( name_index >= FT_NUM_MAC_NAMES )
- name_index = 0;
-
- return ft_standard_glyph_names + ft_mac_names[name_index];
- }
-
-
- FT_CALLBACK_DEF( const char* )
- ps_get_standard_strings( FT_UInt sid )
- {
- if ( sid >= FT_NUM_SID_NAMES )
- return 0;
-
- return ft_standard_glyph_names + ft_sid_names[sid];
- }
-
-
-#ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST
-
- FT_DEFINE_SERVICE_PSCMAPSREC(
- pscmaps_interface,
-
- ps_unicode_value, /* PS_Unicode_ValueFunc unicode_value */
- ps_unicodes_init, /* PS_Unicodes_InitFunc unicodes_init */
- ps_unicodes_char_index, /* PS_Unicodes_CharIndexFunc unicodes_char_index */
- ps_unicodes_char_next, /* PS_Unicodes_CharNextFunc unicodes_char_next */
-
- ps_get_macintosh_name, /* PS_Macintosh_NameFunc macintosh_name */
- ps_get_standard_strings, /* PS_Adobe_Std_StringsFunc adobe_std_strings */
-
- t1_standard_encoding, /* adobe_std_encoding */
- t1_expert_encoding /* adobe_expert_encoding */
- )
-
-#else
-
- FT_DEFINE_SERVICE_PSCMAPSREC(
- pscmaps_interface,
-
- NULL, /* PS_Unicode_ValueFunc unicode_value */
- NULL, /* PS_Unicodes_InitFunc unicodes_init */
- NULL, /* PS_Unicodes_CharIndexFunc unicodes_char_index */
- NULL, /* PS_Unicodes_CharNextFunc unicodes_char_next */
-
- ps_get_macintosh_name, /* PS_Macintosh_NameFunc macintosh_name */
- ps_get_standard_strings, /* PS_Adobe_Std_StringsFunc adobe_std_strings */
-
- t1_standard_encoding, /* adobe_std_encoding */
- t1_expert_encoding /* adobe_expert_encoding */
- )
-
-#endif /* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST */
-
-
- FT_DEFINE_SERVICEDESCREC1(
- pscmaps_services,
-
- FT_SERVICE_ID_POSTSCRIPT_CMAPS, &pscmaps_interface )
-
-
- static FT_Pointer
- psnames_get_service( FT_Module module,
- const char* service_id )
- {
- FT_UNUSED( module );
-
- return ft_service_list_lookup( pscmaps_services, service_id );
- }
-
-#endif /* FT_CONFIG_OPTION_POSTSCRIPT_NAMES */
-
-
-#ifndef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
-#define PUT_PS_NAMES_SERVICE( a ) NULL
-#else
-#define PUT_PS_NAMES_SERVICE( a ) a
-#endif
-
- FT_DEFINE_MODULE(
- psnames_module_class,
-
- 0, /* this is not a font driver, nor a renderer */
- sizeof ( FT_ModuleRec ),
-
- "psnames", /* driver name */
- 0x10000L, /* driver version */
- 0x20000L, /* driver requires FreeType 2 or above */
-
- PUT_PS_NAMES_SERVICE(
- (void*)&pscmaps_interface ), /* module specific interface */
-
- NULL, /* FT_Module_Constructor module_init */
- NULL, /* FT_Module_Destructor module_done */
- PUT_PS_NAMES_SERVICE( psnames_get_service ) /* FT_Module_Requester get_interface */
- )
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/psnames/psmodule.h b/contrib/libs/freetype/src/psnames/psmodule.h
deleted file mode 100644
index 770458316b..0000000000
--- a/contrib/libs/freetype/src/psnames/psmodule.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/****************************************************************************
- *
- * psmodule.h
- *
- * High-level psnames module interface (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef PSMODULE_H_
-#define PSMODULE_H_
-
-
-#include <freetype/ftmodapi.h>
-
-
-FT_BEGIN_HEADER
-
-
- FT_DECLARE_MODULE( psnames_module_class )
-
-
-FT_END_HEADER
-
-#endif /* PSMODULE_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/psnames/psnamerr.h b/contrib/libs/freetype/src/psnames/psnamerr.h
deleted file mode 100644
index e123eb65e3..0000000000
--- a/contrib/libs/freetype/src/psnames/psnamerr.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
- *
- * psnamerr.h
- *
- * PS names module error codes (specification only).
- *
- * Copyright (C) 2001-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /**************************************************************************
- *
- * This file is used to define the PS names module error enumeration
- * constants.
- *
- */
-
-#ifndef PSNAMERR_H_
-#define PSNAMERR_H_
-
-#include <freetype/ftmoderr.h>
-
-#undef FTERRORS_H_
-
-#undef FT_ERR_PREFIX
-#define FT_ERR_PREFIX PSnames_Err_
-#define FT_ERR_BASE FT_Mod_Err_PSnames
-
-#include <freetype/fterrors.h>
-
-#endif /* PSNAMERR_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/psnames/psnames.c b/contrib/libs/freetype/src/psnames/psnames.c
deleted file mode 100644
index 2933af1bf5..0000000000
--- a/contrib/libs/freetype/src/psnames/psnames.c
+++ /dev/null
@@ -1,24 +0,0 @@
-/****************************************************************************
- *
- * psnames.c
- *
- * FreeType psnames module component (body only).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#define FT_MAKE_OPTION_SINGLE_OBJECT
-
-#include "psmodule.c"
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/psnames/pstables.h b/contrib/libs/freetype/src/psnames/pstables.h
deleted file mode 100644
index 2a941b0460..0000000000
--- a/contrib/libs/freetype/src/psnames/pstables.h
+++ /dev/null
@@ -1,4238 +0,0 @@
-/****************************************************************************
- *
- * pstables.h
- *
- * PostScript glyph names.
- *
- * Copyright (C) 2005-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /* This file has been generated automatically -- do not edit! */
-
-
-#ifndef DEFINE_PS_TABLES_DATA
-#ifdef __cplusplus
- extern "C"
-#else
- extern
-#endif
-#endif
- const char ft_standard_glyph_names[3696]
-#ifdef DEFINE_PS_TABLES_DATA
- =
- {
- '.','n','u','l','l', 0,
- 'n','o','n','m','a','r','k','i','n','g','r','e','t','u','r','n', 0,
- 'n','o','t','e','q','u','a','l', 0,
- 'i','n','f','i','n','i','t','y', 0,
- 'l','e','s','s','e','q','u','a','l', 0,
- 'g','r','e','a','t','e','r','e','q','u','a','l', 0,
- 'p','a','r','t','i','a','l','d','i','f','f', 0,
- 's','u','m','m','a','t','i','o','n', 0,
- 'p','r','o','d','u','c','t', 0,
- 'p','i', 0,
- 'i','n','t','e','g','r','a','l', 0,
- 'O','m','e','g','a', 0,
- 'r','a','d','i','c','a','l', 0,
- 'a','p','p','r','o','x','e','q','u','a','l', 0,
- 'D','e','l','t','a', 0,
- 'n','o','n','b','r','e','a','k','i','n','g','s','p','a','c','e', 0,
- 'l','o','z','e','n','g','e', 0,
- 'a','p','p','l','e', 0,
- 'f','r','a','n','c', 0,
- 'G','b','r','e','v','e', 0,
- 'g','b','r','e','v','e', 0,
- 'I','d','o','t','a','c','c','e','n','t', 0,
- 'S','c','e','d','i','l','l','a', 0,
- 's','c','e','d','i','l','l','a', 0,
- 'C','a','c','u','t','e', 0,
- 'c','a','c','u','t','e', 0,
- 'C','c','a','r','o','n', 0,
- 'c','c','a','r','o','n', 0,
- 'd','c','r','o','a','t', 0,
- '.','n','o','t','d','e','f', 0,
- 's','p','a','c','e', 0,
- 'e','x','c','l','a','m', 0,
- 'q','u','o','t','e','d','b','l', 0,
- 'n','u','m','b','e','r','s','i','g','n', 0,
- 'd','o','l','l','a','r', 0,
- 'p','e','r','c','e','n','t', 0,
- 'a','m','p','e','r','s','a','n','d', 0,
- 'q','u','o','t','e','r','i','g','h','t', 0,
- 'p','a','r','e','n','l','e','f','t', 0,
- 'p','a','r','e','n','r','i','g','h','t', 0,
- 'a','s','t','e','r','i','s','k', 0,
- 'p','l','u','s', 0,
- 'c','o','m','m','a', 0,
- 'h','y','p','h','e','n', 0,
- 'p','e','r','i','o','d', 0,
- 's','l','a','s','h', 0,
- 'z','e','r','o', 0,
- 'o','n','e', 0,
- 't','w','o', 0,
- 't','h','r','e','e', 0,
- 'f','o','u','r', 0,
- 'f','i','v','e', 0,
- 's','i','x', 0,
- 's','e','v','e','n', 0,
- 'e','i','g','h','t', 0,
- 'n','i','n','e', 0,
- 'c','o','l','o','n', 0,
- 's','e','m','i','c','o','l','o','n', 0,
- 'l','e','s','s', 0,
- 'e','q','u','a','l', 0,
- 'g','r','e','a','t','e','r', 0,
- 'q','u','e','s','t','i','o','n', 0,
- 'a','t', 0,
- 'A', 0,
- 'B', 0,
- 'C', 0,
- 'D', 0,
- 'E', 0,
- 'F', 0,
- 'G', 0,
- 'H', 0,
- 'I', 0,
- 'J', 0,
- 'K', 0,
- 'L', 0,
- 'M', 0,
- 'N', 0,
- 'O', 0,
- 'P', 0,
- 'Q', 0,
- 'R', 0,
- 'S', 0,
- 'T', 0,
- 'U', 0,
- 'V', 0,
- 'W', 0,
- 'X', 0,
- 'Y', 0,
- 'Z', 0,
- 'b','r','a','c','k','e','t','l','e','f','t', 0,
- 'b','a','c','k','s','l','a','s','h', 0,
- 'b','r','a','c','k','e','t','r','i','g','h','t', 0,
- 'a','s','c','i','i','c','i','r','c','u','m', 0,
- 'u','n','d','e','r','s','c','o','r','e', 0,
- 'q','u','o','t','e','l','e','f','t', 0,
- 'a', 0,
- 'b', 0,
- 'c', 0,
- 'd', 0,
- 'e', 0,
- 'f', 0,
- 'g', 0,
- 'h', 0,
- 'i', 0,
- 'j', 0,
- 'k', 0,
- 'l', 0,
- 'm', 0,
- 'n', 0,
- 'o', 0,
- 'p', 0,
- 'q', 0,
- 'r', 0,
- 's', 0,
- 't', 0,
- 'u', 0,
- 'v', 0,
- 'w', 0,
- 'x', 0,
- 'y', 0,
- 'z', 0,
- 'b','r','a','c','e','l','e','f','t', 0,
- 'b','a','r', 0,
- 'b','r','a','c','e','r','i','g','h','t', 0,
- 'a','s','c','i','i','t','i','l','d','e', 0,
- 'e','x','c','l','a','m','d','o','w','n', 0,
- 'c','e','n','t', 0,
- 's','t','e','r','l','i','n','g', 0,
- 'f','r','a','c','t','i','o','n', 0,
- 'y','e','n', 0,
- 'f','l','o','r','i','n', 0,
- 's','e','c','t','i','o','n', 0,
- 'c','u','r','r','e','n','c','y', 0,
- 'q','u','o','t','e','s','i','n','g','l','e', 0,
- 'q','u','o','t','e','d','b','l','l','e','f','t', 0,
- 'g','u','i','l','l','e','m','o','t','l','e','f','t', 0,
- 'g','u','i','l','s','i','n','g','l','l','e','f','t', 0,
- 'g','u','i','l','s','i','n','g','l','r','i','g','h','t', 0,
- 'f','i', 0,
- 'f','l', 0,
- 'e','n','d','a','s','h', 0,
- 'd','a','g','g','e','r', 0,
- 'd','a','g','g','e','r','d','b','l', 0,
- 'p','e','r','i','o','d','c','e','n','t','e','r','e','d', 0,
- 'p','a','r','a','g','r','a','p','h', 0,
- 'b','u','l','l','e','t', 0,
- 'q','u','o','t','e','s','i','n','g','l','b','a','s','e', 0,
- 'q','u','o','t','e','d','b','l','b','a','s','e', 0,
- 'q','u','o','t','e','d','b','l','r','i','g','h','t', 0,
- 'g','u','i','l','l','e','m','o','t','r','i','g','h','t', 0,
- 'e','l','l','i','p','s','i','s', 0,
- 'p','e','r','t','h','o','u','s','a','n','d', 0,
- 'q','u','e','s','t','i','o','n','d','o','w','n', 0,
- 'g','r','a','v','e', 0,
- 'a','c','u','t','e', 0,
- 'c','i','r','c','u','m','f','l','e','x', 0,
- 't','i','l','d','e', 0,
- 'm','a','c','r','o','n', 0,
- 'b','r','e','v','e', 0,
- 'd','o','t','a','c','c','e','n','t', 0,
- 'd','i','e','r','e','s','i','s', 0,
- 'r','i','n','g', 0,
- 'c','e','d','i','l','l','a', 0,
- 'h','u','n','g','a','r','u','m','l','a','u','t', 0,
- 'o','g','o','n','e','k', 0,
- 'c','a','r','o','n', 0,
- 'e','m','d','a','s','h', 0,
- 'A','E', 0,
- 'o','r','d','f','e','m','i','n','i','n','e', 0,
- 'L','s','l','a','s','h', 0,
- 'O','s','l','a','s','h', 0,
- 'O','E', 0,
- 'o','r','d','m','a','s','c','u','l','i','n','e', 0,
- 'a','e', 0,
- 'd','o','t','l','e','s','s','i', 0,
- 'l','s','l','a','s','h', 0,
- 'o','s','l','a','s','h', 0,
- 'o','e', 0,
- 'g','e','r','m','a','n','d','b','l','s', 0,
- 'o','n','e','s','u','p','e','r','i','o','r', 0,
- 'l','o','g','i','c','a','l','n','o','t', 0,
- 'm','u', 0,
- 't','r','a','d','e','m','a','r','k', 0,
- 'E','t','h', 0,
- 'o','n','e','h','a','l','f', 0,
- 'p','l','u','s','m','i','n','u','s', 0,
- 'T','h','o','r','n', 0,
- 'o','n','e','q','u','a','r','t','e','r', 0,
- 'd','i','v','i','d','e', 0,
- 'b','r','o','k','e','n','b','a','r', 0,
- 'd','e','g','r','e','e', 0,
- 't','h','o','r','n', 0,
- 't','h','r','e','e','q','u','a','r','t','e','r','s', 0,
- 't','w','o','s','u','p','e','r','i','o','r', 0,
- 'r','e','g','i','s','t','e','r','e','d', 0,
- 'm','i','n','u','s', 0,
- 'e','t','h', 0,
- 'm','u','l','t','i','p','l','y', 0,
- 't','h','r','e','e','s','u','p','e','r','i','o','r', 0,
- 'c','o','p','y','r','i','g','h','t', 0,
- 'A','a','c','u','t','e', 0,
- 'A','c','i','r','c','u','m','f','l','e','x', 0,
- 'A','d','i','e','r','e','s','i','s', 0,
- 'A','g','r','a','v','e', 0,
- 'A','r','i','n','g', 0,
- 'A','t','i','l','d','e', 0,
- 'C','c','e','d','i','l','l','a', 0,
- 'E','a','c','u','t','e', 0,
- 'E','c','i','r','c','u','m','f','l','e','x', 0,
- 'E','d','i','e','r','e','s','i','s', 0,
- 'E','g','r','a','v','e', 0,
- 'I','a','c','u','t','e', 0,
- 'I','c','i','r','c','u','m','f','l','e','x', 0,
- 'I','d','i','e','r','e','s','i','s', 0,
- 'I','g','r','a','v','e', 0,
- 'N','t','i','l','d','e', 0,
- 'O','a','c','u','t','e', 0,
- 'O','c','i','r','c','u','m','f','l','e','x', 0,
- 'O','d','i','e','r','e','s','i','s', 0,
- 'O','g','r','a','v','e', 0,
- 'O','t','i','l','d','e', 0,
- 'S','c','a','r','o','n', 0,
- 'U','a','c','u','t','e', 0,
- 'U','c','i','r','c','u','m','f','l','e','x', 0,
- 'U','d','i','e','r','e','s','i','s', 0,
- 'U','g','r','a','v','e', 0,
- 'Y','a','c','u','t','e', 0,
- 'Y','d','i','e','r','e','s','i','s', 0,
- 'Z','c','a','r','o','n', 0,
- 'a','a','c','u','t','e', 0,
- 'a','c','i','r','c','u','m','f','l','e','x', 0,
- 'a','d','i','e','r','e','s','i','s', 0,
- 'a','g','r','a','v','e', 0,
- 'a','r','i','n','g', 0,
- 'a','t','i','l','d','e', 0,
- 'c','c','e','d','i','l','l','a', 0,
- 'e','a','c','u','t','e', 0,
- 'e','c','i','r','c','u','m','f','l','e','x', 0,
- 'e','d','i','e','r','e','s','i','s', 0,
- 'e','g','r','a','v','e', 0,
- 'i','a','c','u','t','e', 0,
- 'i','c','i','r','c','u','m','f','l','e','x', 0,
- 'i','d','i','e','r','e','s','i','s', 0,
- 'i','g','r','a','v','e', 0,
- 'n','t','i','l','d','e', 0,
- 'o','a','c','u','t','e', 0,
- 'o','c','i','r','c','u','m','f','l','e','x', 0,
- 'o','d','i','e','r','e','s','i','s', 0,
- 'o','g','r','a','v','e', 0,
- 'o','t','i','l','d','e', 0,
- 's','c','a','r','o','n', 0,
- 'u','a','c','u','t','e', 0,
- 'u','c','i','r','c','u','m','f','l','e','x', 0,
- 'u','d','i','e','r','e','s','i','s', 0,
- 'u','g','r','a','v','e', 0,
- 'y','a','c','u','t','e', 0,
- 'y','d','i','e','r','e','s','i','s', 0,
- 'z','c','a','r','o','n', 0,
- 'e','x','c','l','a','m','s','m','a','l','l', 0,
- 'H','u','n','g','a','r','u','m','l','a','u','t','s','m','a','l','l', 0,
- 'd','o','l','l','a','r','o','l','d','s','t','y','l','e', 0,
- 'd','o','l','l','a','r','s','u','p','e','r','i','o','r', 0,
- 'a','m','p','e','r','s','a','n','d','s','m','a','l','l', 0,
- 'A','c','u','t','e','s','m','a','l','l', 0,
- 'p','a','r','e','n','l','e','f','t','s','u','p','e','r','i','o','r', 0,
- 'p','a','r','e','n','r','i','g','h','t','s','u','p','e','r','i','o','r', 0,
- 't','w','o','d','o','t','e','n','l','e','a','d','e','r', 0,
- 'o','n','e','d','o','t','e','n','l','e','a','d','e','r', 0,
- 'z','e','r','o','o','l','d','s','t','y','l','e', 0,
- 'o','n','e','o','l','d','s','t','y','l','e', 0,
- 't','w','o','o','l','d','s','t','y','l','e', 0,
- 't','h','r','e','e','o','l','d','s','t','y','l','e', 0,
- 'f','o','u','r','o','l','d','s','t','y','l','e', 0,
- 'f','i','v','e','o','l','d','s','t','y','l','e', 0,
- 's','i','x','o','l','d','s','t','y','l','e', 0,
- 's','e','v','e','n','o','l','d','s','t','y','l','e', 0,
- 'e','i','g','h','t','o','l','d','s','t','y','l','e', 0,
- 'n','i','n','e','o','l','d','s','t','y','l','e', 0,
- 'c','o','m','m','a','s','u','p','e','r','i','o','r', 0,
- 't','h','r','e','e','q','u','a','r','t','e','r','s','e','m','d','a','s','h', 0,
- 'p','e','r','i','o','d','s','u','p','e','r','i','o','r', 0,
- 'q','u','e','s','t','i','o','n','s','m','a','l','l', 0,
- 'a','s','u','p','e','r','i','o','r', 0,
- 'b','s','u','p','e','r','i','o','r', 0,
- 'c','e','n','t','s','u','p','e','r','i','o','r', 0,
- 'd','s','u','p','e','r','i','o','r', 0,
- 'e','s','u','p','e','r','i','o','r', 0,
- 'i','s','u','p','e','r','i','o','r', 0,
- 'l','s','u','p','e','r','i','o','r', 0,
- 'm','s','u','p','e','r','i','o','r', 0,
- 'n','s','u','p','e','r','i','o','r', 0,
- 'o','s','u','p','e','r','i','o','r', 0,
- 'r','s','u','p','e','r','i','o','r', 0,
- 's','s','u','p','e','r','i','o','r', 0,
- 't','s','u','p','e','r','i','o','r', 0,
- 'f','f', 0,
- 'f','f','i', 0,
- 'f','f','l', 0,
- 'p','a','r','e','n','l','e','f','t','i','n','f','e','r','i','o','r', 0,
- 'p','a','r','e','n','r','i','g','h','t','i','n','f','e','r','i','o','r', 0,
- 'C','i','r','c','u','m','f','l','e','x','s','m','a','l','l', 0,
- 'h','y','p','h','e','n','s','u','p','e','r','i','o','r', 0,
- 'G','r','a','v','e','s','m','a','l','l', 0,
- 'A','s','m','a','l','l', 0,
- 'B','s','m','a','l','l', 0,
- 'C','s','m','a','l','l', 0,
- 'D','s','m','a','l','l', 0,
- 'E','s','m','a','l','l', 0,
- 'F','s','m','a','l','l', 0,
- 'G','s','m','a','l','l', 0,
- 'H','s','m','a','l','l', 0,
- 'I','s','m','a','l','l', 0,
- 'J','s','m','a','l','l', 0,
- 'K','s','m','a','l','l', 0,
- 'L','s','m','a','l','l', 0,
- 'M','s','m','a','l','l', 0,
- 'N','s','m','a','l','l', 0,
- 'O','s','m','a','l','l', 0,
- 'P','s','m','a','l','l', 0,
- 'Q','s','m','a','l','l', 0,
- 'R','s','m','a','l','l', 0,
- 'S','s','m','a','l','l', 0,
- 'T','s','m','a','l','l', 0,
- 'U','s','m','a','l','l', 0,
- 'V','s','m','a','l','l', 0,
- 'W','s','m','a','l','l', 0,
- 'X','s','m','a','l','l', 0,
- 'Y','s','m','a','l','l', 0,
- 'Z','s','m','a','l','l', 0,
- 'c','o','l','o','n','m','o','n','e','t','a','r','y', 0,
- 'o','n','e','f','i','t','t','e','d', 0,
- 'r','u','p','i','a','h', 0,
- 'T','i','l','d','e','s','m','a','l','l', 0,
- 'e','x','c','l','a','m','d','o','w','n','s','m','a','l','l', 0,
- 'c','e','n','t','o','l','d','s','t','y','l','e', 0,
- 'L','s','l','a','s','h','s','m','a','l','l', 0,
- 'S','c','a','r','o','n','s','m','a','l','l', 0,
- 'Z','c','a','r','o','n','s','m','a','l','l', 0,
- 'D','i','e','r','e','s','i','s','s','m','a','l','l', 0,
- 'B','r','e','v','e','s','m','a','l','l', 0,
- 'C','a','r','o','n','s','m','a','l','l', 0,
- 'D','o','t','a','c','c','e','n','t','s','m','a','l','l', 0,
- 'M','a','c','r','o','n','s','m','a','l','l', 0,
- 'f','i','g','u','r','e','d','a','s','h', 0,
- 'h','y','p','h','e','n','i','n','f','e','r','i','o','r', 0,
- 'O','g','o','n','e','k','s','m','a','l','l', 0,
- 'R','i','n','g','s','m','a','l','l', 0,
- 'C','e','d','i','l','l','a','s','m','a','l','l', 0,
- 'q','u','e','s','t','i','o','n','d','o','w','n','s','m','a','l','l', 0,
- 'o','n','e','e','i','g','h','t','h', 0,
- 't','h','r','e','e','e','i','g','h','t','h','s', 0,
- 'f','i','v','e','e','i','g','h','t','h','s', 0,
- 's','e','v','e','n','e','i','g','h','t','h','s', 0,
- 'o','n','e','t','h','i','r','d', 0,
- 't','w','o','t','h','i','r','d','s', 0,
- 'z','e','r','o','s','u','p','e','r','i','o','r', 0,
- 'f','o','u','r','s','u','p','e','r','i','o','r', 0,
- 'f','i','v','e','s','u','p','e','r','i','o','r', 0,
- 's','i','x','s','u','p','e','r','i','o','r', 0,
- 's','e','v','e','n','s','u','p','e','r','i','o','r', 0,
- 'e','i','g','h','t','s','u','p','e','r','i','o','r', 0,
- 'n','i','n','e','s','u','p','e','r','i','o','r', 0,
- 'z','e','r','o','i','n','f','e','r','i','o','r', 0,
- 'o','n','e','i','n','f','e','r','i','o','r', 0,
- 't','w','o','i','n','f','e','r','i','o','r', 0,
- 't','h','r','e','e','i','n','f','e','r','i','o','r', 0,
- 'f','o','u','r','i','n','f','e','r','i','o','r', 0,
- 'f','i','v','e','i','n','f','e','r','i','o','r', 0,
- 's','i','x','i','n','f','e','r','i','o','r', 0,
- 's','e','v','e','n','i','n','f','e','r','i','o','r', 0,
- 'e','i','g','h','t','i','n','f','e','r','i','o','r', 0,
- 'n','i','n','e','i','n','f','e','r','i','o','r', 0,
- 'c','e','n','t','i','n','f','e','r','i','o','r', 0,
- 'd','o','l','l','a','r','i','n','f','e','r','i','o','r', 0,
- 'p','e','r','i','o','d','i','n','f','e','r','i','o','r', 0,
- 'c','o','m','m','a','i','n','f','e','r','i','o','r', 0,
- 'A','g','r','a','v','e','s','m','a','l','l', 0,
- 'A','a','c','u','t','e','s','m','a','l','l', 0,
- 'A','c','i','r','c','u','m','f','l','e','x','s','m','a','l','l', 0,
- 'A','t','i','l','d','e','s','m','a','l','l', 0,
- 'A','d','i','e','r','e','s','i','s','s','m','a','l','l', 0,
- 'A','r','i','n','g','s','m','a','l','l', 0,
- 'A','E','s','m','a','l','l', 0,
- 'C','c','e','d','i','l','l','a','s','m','a','l','l', 0,
- 'E','g','r','a','v','e','s','m','a','l','l', 0,
- 'E','a','c','u','t','e','s','m','a','l','l', 0,
- 'E','c','i','r','c','u','m','f','l','e','x','s','m','a','l','l', 0,
- 'E','d','i','e','r','e','s','i','s','s','m','a','l','l', 0,
- 'I','g','r','a','v','e','s','m','a','l','l', 0,
- 'I','a','c','u','t','e','s','m','a','l','l', 0,
- 'I','c','i','r','c','u','m','f','l','e','x','s','m','a','l','l', 0,
- 'I','d','i','e','r','e','s','i','s','s','m','a','l','l', 0,
- 'E','t','h','s','m','a','l','l', 0,
- 'N','t','i','l','d','e','s','m','a','l','l', 0,
- 'O','g','r','a','v','e','s','m','a','l','l', 0,
- 'O','a','c','u','t','e','s','m','a','l','l', 0,
- 'O','c','i','r','c','u','m','f','l','e','x','s','m','a','l','l', 0,
- 'O','t','i','l','d','e','s','m','a','l','l', 0,
- 'O','d','i','e','r','e','s','i','s','s','m','a','l','l', 0,
- 'O','E','s','m','a','l','l', 0,
- 'O','s','l','a','s','h','s','m','a','l','l', 0,
- 'U','g','r','a','v','e','s','m','a','l','l', 0,
- 'U','a','c','u','t','e','s','m','a','l','l', 0,
- 'U','c','i','r','c','u','m','f','l','e','x','s','m','a','l','l', 0,
- 'U','d','i','e','r','e','s','i','s','s','m','a','l','l', 0,
- 'Y','a','c','u','t','e','s','m','a','l','l', 0,
- 'T','h','o','r','n','s','m','a','l','l', 0,
- 'Y','d','i','e','r','e','s','i','s','s','m','a','l','l', 0,
- '0','0','1','.','0','0','0', 0,
- '0','0','1','.','0','0','1', 0,
- '0','0','1','.','0','0','2', 0,
- '0','0','1','.','0','0','3', 0,
- 'B','l','a','c','k', 0,
- 'B','o','l','d', 0,
- 'B','o','o','k', 0,
- 'L','i','g','h','t', 0,
- 'M','e','d','i','u','m', 0,
- 'R','e','g','u','l','a','r', 0,
- 'R','o','m','a','n', 0,
- 'S','e','m','i','b','o','l','d', 0,
- }
-#endif /* DEFINE_PS_TABLES_DATA */
- ;
-
-
-#define FT_NUM_MAC_NAMES 258
-
- /* Values are offsets into the `ft_standard_glyph_names' table */
-
-#ifndef DEFINE_PS_TABLES_DATA
-#ifdef __cplusplus
- extern "C"
-#else
- extern
-#endif
-#endif
- const short ft_mac_names[FT_NUM_MAC_NAMES]
-#ifdef DEFINE_PS_TABLES_DATA
- =
- {
- 253, 0, 6, 261, 267, 274, 283, 294, 301, 309, 758, 330, 340, 351,
- 360, 365, 371, 378, 385, 391, 396, 400, 404, 410, 415, 420, 424, 430,
- 436, 441, 447, 457, 462, 468, 476, 485, 488, 490, 492, 494, 496, 498,
- 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, 526,
- 528, 530, 532, 534, 536, 538, 540, 552, 562, 575, 587, 979, 608, 610,
- 612, 614, 616, 618, 620, 622, 624, 626, 628, 630, 632, 634, 636, 638,
- 640, 642, 644, 646, 648, 650, 652, 654, 656, 658, 660, 670, 674, 685,
- 1375,1392,1405,1414,1486,1512,1562,1603,1632,1610,1622,1645,1639,1652,
- 1661,1690,1668,1680,1697,1726,1704,1716,1733,1740,1769,1747,1759,1776,
- 1790,1819,1797,1809, 839,1263, 707, 712, 741, 881, 871,1160,1302,1346,
- 1197, 985,1031, 23,1086,1108, 32,1219, 41, 51, 730,1194, 64, 76,
- 86, 94, 97,1089,1118, 106,1131,1150, 966, 696,1183, 112, 734, 120,
- 132, 783, 930, 945, 138,1385,1398,1529,1115,1157, 832,1079, 770, 916,
- 598, 319,1246, 155,1833,1586, 721, 749, 797, 811, 826, 829, 846, 856,
- 888, 903, 954,1363,1421,1356,1433,1443,1450,1457,1469,1479,1493,1500,
- 163,1522,1543,1550,1572,1134, 991,1002,1008,1015,1021,1040,1045,1053,
- 1066,1073,1101,1143,1536,1783,1596,1843,1253,1207,1319,1579,1826,1229,
- 1270,1313,1323,1171,1290,1332,1211,1235,1276, 169, 175, 182, 189, 200,
- 209, 218, 225, 232, 239, 246
- }
-#endif /* DEFINE_PS_TABLES_DATA */
- ;
-
-
-#define FT_NUM_SID_NAMES 391
-
- /* Values are offsets into the `ft_standard_glyph_names' table */
-
-#ifndef DEFINE_PS_TABLES_DATA
-#ifdef __cplusplus
- extern "C"
-#else
- extern
-#endif
-#endif
- const short ft_sid_names[FT_NUM_SID_NAMES]
-#ifdef DEFINE_PS_TABLES_DATA
- =
- {
- 253, 261, 267, 274, 283, 294, 301, 309, 319, 330, 340, 351, 360, 365,
- 371, 378, 385, 391, 396, 400, 404, 410, 415, 420, 424, 430, 436, 441,
- 447, 457, 462, 468, 476, 485, 488, 490, 492, 494, 496, 498, 500, 502,
- 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, 526, 528, 530,
- 532, 534, 536, 538, 540, 552, 562, 575, 587, 598, 608, 610, 612, 614,
- 616, 618, 620, 622, 624, 626, 628, 630, 632, 634, 636, 638, 640, 642,
- 644, 646, 648, 650, 652, 654, 656, 658, 660, 670, 674, 685, 696, 707,
- 712, 721, 730, 734, 741, 749, 758, 770, 783, 797, 811, 826, 829, 832,
- 839, 846, 856, 871, 881, 888, 903, 916, 930, 945, 954, 966, 979, 985,
- 991,1002,1008,1015,1021,1031,1040,1045,1053,1066,1073,1079,1086,1089,
- 1101,1108,1115,1118,1131,1134,1143,1150,1157,1160,1171,1183,1194,1197,
- 1207,1211,1219,1229,1235,1246,1253,1263,1270,1276,1290,1302,1313,1319,
- 1323,1332,1346,1356,1363,1375,1385,1392,1398,1405,1414,1421,1433,1443,
- 1450,1457,1469,1479,1486,1493,1500,1512,1522,1529,1536,1543,1550,1562,
- 1572,1579,1586,1596,1603,1610,1622,1632,1639,1645,1652,1661,1668,1680,
- 1690,1697,1704,1716,1726,1733,1740,1747,1759,1769,1776,1783,1790,1797,
- 1809,1819,1826,1833,1843,1850,1862,1880,1895,1910,1925,1936,1954,1973,
- 1988,2003,2016,2028,2040,2054,2067,2080,2092,2106,2120,2133,2147,2167,
- 2182,2196,2206,2216,2229,2239,2249,2259,2269,2279,2289,2299,2309,2319,
- 2329,2332,2336,2340,2358,2377,2393,2408,2419,2426,2433,2440,2447,2454,
- 2461,2468,2475,2482,2489,2496,2503,2510,2517,2524,2531,2538,2545,2552,
- 2559,2566,2573,2580,2587,2594,2601,2615,2625,2632,2643,2659,2672,2684,
- 2696,2708,2722,2733,2744,2759,2771,2782,2797,2809,2819,2832,2850,2860,
- 2873,2885,2898,2907,2917,2930,2943,2956,2968,2982,2996,3009,3022,3034,
- 3046,3060,3073,3086,3098,3112,3126,3139,3152,3167,3182,3196,3208,3220,
- 3237,3249,3264,3275,3283,3297,3309,3321,3338,3353,3365,3377,3394,3409,
- 3418,3430,3442,3454,3471,3483,3498,3506,3518,3530,3542,3559,3574,3586,
- 3597,3612,3620,3628,3636,3644,3650,3655,3660,3666,3673,3681,3687
- }
-#endif /* DEFINE_PS_TABLES_DATA */
- ;
-
-
- /* the following are indices into the SID name table */
-#ifndef DEFINE_PS_TABLES_DATA
-#ifdef __cplusplus
- extern "C"
-#else
- extern
-#endif
-#endif
- const unsigned short t1_standard_encoding[256]
-#ifdef DEFINE_PS_TABLES_DATA
- =
- {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
- 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
- 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
- 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
- 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
- 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,
- 0,111,112,113,114, 0,115,116,117,118,119,120,121,122, 0,123,
- 0,124,125,126,127,128,129,130,131, 0,132,133, 0,134,135,136,
- 137, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0,138, 0,139, 0, 0, 0, 0,140,141,142,143, 0, 0, 0, 0,
- 0,144, 0, 0, 0,145, 0, 0,146,147,148,149, 0, 0, 0, 0
- }
-#endif /* DEFINE_PS_TABLES_DATA */
- ;
-
-
- /* the following are indices into the SID name table */
-#ifndef DEFINE_PS_TABLES_DATA
-#ifdef __cplusplus
- extern "C"
-#else
- extern
-#endif
-#endif
- const unsigned short t1_expert_encoding[256]
-#ifdef DEFINE_PS_TABLES_DATA
- =
- {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 1,229,230, 0,231,232,233,234,235,236,237,238, 13, 14, 15, 99,
- 239,240,241,242,243,244,245,246,247,248, 27, 28,249,250,251,252,
- 0,253,254,255,256,257, 0, 0, 0,258, 0, 0,259,260,261,262,
- 0, 0,263,264,265, 0,266,109,110,267,268,269, 0,270,271,272,
- 273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,
- 289,290,291,292,293,294,295,296,297,298,299,300,301,302,303, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0,304,305,306, 0, 0,307,308,309,310,311, 0,312, 0, 0,313,
- 0, 0,314,315, 0, 0,316,317,318, 0, 0, 0,158,155,163,319,
- 320,321,322,323,324,325, 0, 0,326,150,164,169,327,328,329,330,
- 331,332,333,334,335,336,337,338,339,340,341,342,343,344,345,346,
- 347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362,
- 363,364,365,366,367,368,369,370,371,372,373,374,375,376,377,378
- }
-#endif /* DEFINE_PS_TABLES_DATA */
- ;
-
-
- /*
- * This table is a compressed version of the Adobe Glyph List (AGL),
- * optimized for efficient searching. It has been generated by the
- * `glnames.py' python script located in the `src/tools' directory.
- *
- * The lookup function to get the Unicode value for a given string
- * is defined below the table.
- */
-
-#ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST
-
-#ifndef DEFINE_PS_TABLES_DATA
-#ifdef __cplusplus
- extern "C"
-#else
- extern
-#endif
-#endif
- const unsigned char ft_adobe_glyph_list[55997L]
-#ifdef DEFINE_PS_TABLES_DATA
- =
- {
- 0, 52, 0,106, 2,167, 3, 63, 4,220, 6,125, 9,143, 10, 23,
- 11,137, 12,199, 14,246, 15, 87, 16,233, 17,219, 18,104, 19, 88,
- 22,110, 23, 32, 23, 71, 24, 77, 27,156, 29, 73, 31,247, 32,107,
- 32,222, 33, 55, 34,154, 35,218, 58, 10, 64,122, 72,188, 80,109,
- 88,104, 93, 61, 98,168,106, 91,114,111,115,237,122,180,127,255,
- 135,164,143,132,149,213,158,108,161,115,168,175,183,147,197,199,
- 202, 25,204,166,208,209,209, 81,215, 26, 65,143, 0, 65, 0,140,
- 0,175, 0,193, 1, 15, 1,147, 1,233, 1,251, 2, 7, 2, 40,
- 2, 57, 2, 82, 2, 91, 2,128, 2,136, 2,154, 69,131, 0,198,
- 0,150, 0,158, 0,167,225,227,245,244,101,128, 1,252,237,225,
- 227,242,239,110,128, 1,226,243,237,225,236,108,128,247,230,225,
- 227,245,244,101,129, 0,193, 0,185,243,237,225,236,108,128,247,
- 225,226,242,229,246,101,134, 1, 2, 0,213, 0,221, 0,232, 0,
- 243, 0,251, 1, 7,225,227,245,244,101,128, 30,174,227,249,242,
- 233,236,236,233, 99,128, 4,208,228,239,244,226,229,236,239,119,
- 128, 30,182,231,242,225,246,101,128, 30,176,232,239,239,235,225,
- 226,239,246,101,128, 30,178,244,233,236,228,101,128, 30,180, 99,
- 4, 1, 25, 1, 32, 1,121, 1,137,225,242,239,110,128, 1,205,
- 233,242, 99, 2, 1, 40, 1, 45,236,101,128, 36,182,245,237,230,
- 236,229,120,134, 0,194, 1, 66, 1, 74, 1, 85, 1, 93, 1,105,
- 1,113,225,227,245,244,101,128, 30,164,228,239,244,226,229,236,
- 239,119,128, 30,172,231,242,225,246,101,128, 30,166,232,239,239,
- 235,225,226,239,246,101,128, 30,168,243,237,225,236,108,128,247,
- 226,244,233,236,228,101,128, 30,170,245,244,101,129,246,201, 1,
- 129,243,237,225,236,108,128,247,180,249,242,233,236,236,233, 99,
- 128, 4, 16,100, 3, 1,155, 1,165, 1,209,226,236,231,242,225,
- 246,101,128, 2, 0,233,229,242,229,243,233,115,131, 0,196, 1,
- 181, 1,192, 1,201,227,249,242,233,236,236,233, 99,128, 4,210,
- 237,225,227,242,239,110,128, 1,222,243,237,225,236,108,128,247,
- 228,239,116, 2, 1,216, 1,224,226,229,236,239,119,128, 30,160,
- 237,225,227,242,239,110,128, 1,224,231,242,225,246,101,129, 0,
- 192, 1,243,243,237,225,236,108,128,247,224,232,239,239,235,225,
- 226,239,246,101,128, 30,162,105, 2, 2, 13, 2, 25,229,227,249,
- 242,233,236,236,233, 99,128, 4,212,238,246,229,242,244,229,228,
- 226,242,229,246,101,128, 2, 2,236,240,232, 97,129, 3,145, 2,
- 49,244,239,238,239,115,128, 3,134,109, 2, 2, 63, 2, 71,225,
- 227,242,239,110,128, 1, 0,239,238,239,243,240,225,227,101,128,
- 255, 33,239,231,239,238,229,107,128, 1, 4,242,233,238,103,131,
- 0,197, 2,104, 2,112, 2,120,225,227,245,244,101,128, 1,250,
- 226,229,236,239,119,128, 30, 0,243,237,225,236,108,128,247,229,
- 243,237,225,236,108,128,247, 97,244,233,236,228,101,129, 0,195,
- 2,146,243,237,225,236,108,128,247,227,249,226,225,242,237,229,
- 238,233,225,110,128, 5, 49, 66,137, 0, 66, 2,189, 2,198, 2,
- 223, 3, 3, 3, 10, 3, 22, 3, 34, 3, 46, 3, 54,227,233,242,
- 227,236,101,128, 36,183,228,239,116, 2, 2,206, 2,215,225,227,
- 227,229,238,116,128, 30, 2,226,229,236,239,119,128, 30, 4,101,
- 3, 2,231, 2,242, 2,254,227,249,242,233,236,236,233, 99,128,
- 4, 17,238,225,242,237,229,238,233,225,110,128, 5, 50,244, 97,
- 128, 3,146,232,239,239,107,128, 1,129,236,233,238,229,226,229,
- 236,239,119,128, 30, 6,237,239,238,239,243,240,225,227,101,128,
- 255, 34,242,229,246,229,243,237,225,236,108,128,246,244,243,237,
- 225,236,108,128,247, 98,244,239,240,226,225,114,128, 1,130, 67,
- 137, 0, 67, 3, 85, 3,127, 3,193, 3,210, 3,224, 4,171, 4,
- 188, 4,200, 4,212, 97, 3, 3, 93, 3,104, 3,111,225,242,237,
- 229,238,233,225,110,128, 5, 62,227,245,244,101,128, 1, 6,242,
- 239,110,129,246,202, 3,119,243,237,225,236,108,128,246,245, 99,
- 3, 3,135, 3,142, 3,171,225,242,239,110,128, 1, 12,229,228,
- 233,236,236, 97,130, 0,199, 3,155, 3,163,225,227,245,244,101,
- 128, 30, 8,243,237,225,236,108,128,247,231,233,242, 99, 2, 3,
- 179, 3,184,236,101,128, 36,184,245,237,230,236,229,120,128, 1,
- 8,228,239,116,129, 1, 10, 3,201,225,227,227,229,238,116,128,
- 1, 10,229,228,233,236,236,225,243,237,225,236,108,128,247,184,
- 104, 4, 3,234, 3,246, 4,161, 4,165,225,225,242,237,229,238,
- 233,225,110,128, 5, 73,101, 6, 4, 4, 4, 24, 4, 35, 4,103,
- 4,115, 4,136,225,226,235,232,225,243,233,225,238,227,249,242,
- 233,236,236,233, 99,128, 4,188,227,249,242,233,236,236,233, 99,
- 128, 4, 39,100, 2, 4, 41, 4, 85,229,243,227,229,238,228,229,
- 114, 2, 4, 54, 4, 74,225,226,235,232,225,243,233,225,238,227,
- 249,242,233,236,236,233, 99,128, 4,190,227,249,242,233,236,236,
- 233, 99,128, 4,182,233,229,242,229,243,233,243,227,249,242,233,
- 236,236,233, 99,128, 4,244,232,225,242,237,229,238,233,225,110,
- 128, 5, 67,235,232,225,235,225,243,243,233,225,238,227,249,242,
- 233,236,236,233, 99,128, 4,203,246,229,242,244,233,227,225,236,
- 243,244,242,239,235,229,227,249,242,233,236,236,233, 99,128, 4,
- 184,105,128, 3,167,239,239,107,128, 1,135,233,242,227,245,237,
- 230,236,229,248,243,237,225,236,108,128,246,246,237,239,238,239,
- 243,240,225,227,101,128,255, 35,239,225,242,237,229,238,233,225,
- 110,128, 5, 81,243,237,225,236,108,128,247, 99, 68,142, 0, 68,
- 4,252, 5, 10, 5, 36, 5, 96, 5,121, 5,166, 5,173, 5,231,
- 5,244, 6, 0, 6, 12, 6, 28, 6, 48, 6, 57, 90,129, 1,241,
- 5, 2,227,225,242,239,110,128, 1,196, 97, 2, 5, 16, 5, 27,
- 225,242,237,229,238,233,225,110,128, 5, 52,230,242,233,227,225,
- 110,128, 1,137, 99, 4, 5, 46, 5, 53, 5, 62, 5, 89,225,242,
- 239,110,128, 1, 14,229,228,233,236,236, 97,128, 30, 16,233,242,
- 99, 2, 5, 70, 5, 75,236,101,128, 36,185,245,237,230,236,229,
- 248,226,229,236,239,119,128, 30, 18,242,239,225,116,128, 1, 16,
- 228,239,116, 2, 5,104, 5,113,225,227,227,229,238,116,128, 30,
- 10,226,229,236,239,119,128, 30, 12,101, 3, 5,129, 5,140, 5,
- 150,227,249,242,233,236,236,233, 99,128, 4, 20,233,227,239,240,
- 244,233, 99,128, 3,238,236,244, 97,129, 34, 6, 5,158,231,242,
- 229,229,107,128, 3,148,232,239,239,107,128, 1,138,105, 2, 5,
- 179, 5,218,229,242,229,243,233,115,131,246,203, 5,194, 5,202,
- 5,210,193,227,245,244,101,128,246,204,199,242,225,246,101,128,
- 246,205,243,237,225,236,108,128,247,168,231,225,237,237,225,231,
- 242,229,229,107,128, 3,220,234,229,227,249,242,233,236,236,233,
- 99,128, 4, 2,236,233,238,229,226,229,236,239,119,128, 30, 14,
- 237,239,238,239,243,240,225,227,101,128,255, 36,239,244,225,227,
- 227,229,238,244,243,237,225,236,108,128,246,247,115, 2, 6, 34,
- 6, 41,236,225,243,104,128, 1, 16,237,225,236,108,128,247,100,
- 244,239,240,226,225,114,128, 1,139,122,131, 1,242, 6, 67, 6,
- 75, 6,112,227,225,242,239,110,128, 1,197,101, 2, 6, 81, 6,
- 101,225,226,235,232,225,243,233,225,238,227,249,242,233,236,236,
- 233, 99,128, 4,224,227,249,242,233,236,236,233, 99,128, 4, 5,
- 232,229,227,249,242,233,236,236,233, 99,128, 4, 15, 69,146, 0,
- 69, 6,165, 6,183, 6,191, 7, 89, 7,153, 7,165, 7,183, 7,
- 211, 8, 7, 8, 36, 8, 94, 8,169, 8,189, 8,208, 8,248, 9,
- 44, 9,109, 9,115,225,227,245,244,101,129, 0,201, 6,175,243,
- 237,225,236,108,128,247,233,226,242,229,246,101,128, 1, 20, 99,
- 5, 6,203, 6,210, 6,224, 6,236, 7, 79,225,242,239,110,128,
- 1, 26,229,228,233,236,236,225,226,242,229,246,101,128, 30, 28,
- 232,225,242,237,229,238,233,225,110,128, 5, 53,233,242, 99, 2,
- 6,244, 6,249,236,101,128, 36,186,245,237,230,236,229,120,135,
- 0,202, 7, 16, 7, 24, 7, 32, 7, 43, 7, 51, 7, 63, 7, 71,
- 225,227,245,244,101,128, 30,190,226,229,236,239,119,128, 30, 24,
- 228,239,244,226,229,236,239,119,128, 30,198,231,242,225,246,101,
- 128, 30,192,232,239,239,235,225,226,239,246,101,128, 30,194,243,
- 237,225,236,108,128,247,234,244,233,236,228,101,128, 30,196,249,
- 242,233,236,236,233, 99,128, 4, 4,100, 3, 7, 97, 7,107, 7,
- 127,226,236,231,242,225,246,101,128, 2, 4,233,229,242,229,243,
- 233,115,129, 0,203, 7,119,243,237,225,236,108,128,247,235,239,
- 116,130, 1, 22, 7,136, 7,145,225,227,227,229,238,116,128, 1,
- 22,226,229,236,239,119,128, 30,184,230,227,249,242,233,236,236,
- 233, 99,128, 4, 36,231,242,225,246,101,129, 0,200, 7,175,243,
- 237,225,236,108,128,247,232,104, 2, 7,189, 7,200,225,242,237,
- 229,238,233,225,110,128, 5, 55,239,239,235,225,226,239,246,101,
- 128, 30,186,105, 3, 7,219, 7,230, 7,245,231,232,244,242,239,
- 237,225,110,128, 33,103,238,246,229,242,244,229,228,226,242,229,
- 246,101,128, 2, 6,239,244,233,230,233,229,228,227,249,242,233,
- 236,236,233, 99,128, 4,100,108, 2, 8, 13, 8, 24,227,249,242,
- 233,236,236,233, 99,128, 4, 27,229,246,229,238,242,239,237,225,
- 110,128, 33,106,109, 3, 8, 44, 8, 72, 8, 83,225,227,242,239,
- 110,130, 1, 18, 8, 56, 8, 64,225,227,245,244,101,128, 30, 22,
- 231,242,225,246,101,128, 30, 20,227,249,242,233,236,236,233, 99,
- 128, 4, 28,239,238,239,243,240,225,227,101,128,255, 37,110, 4,
- 8,104, 8,115, 8,135, 8,154,227,249,242,233,236,236,233, 99,
- 128, 4, 29,228,229,243,227,229,238,228,229,242,227,249,242,233,
- 236,236,233, 99,128, 4,162,103,129, 1, 74, 8,141,232,229,227,
- 249,242,233,236,236,233, 99,128, 4,164,232,239,239,235,227,249,
- 242,233,236,236,233, 99,128, 4,199,111, 2, 8,175, 8,183,231,
- 239,238,229,107,128, 1, 24,240,229,110,128, 1,144,240,243,233,
- 236,239,110,129, 3,149, 8,200,244,239,238,239,115,128, 3,136,
- 114, 2, 8,214, 8,225,227,249,242,233,236,236,233, 99,128, 4,
- 32,229,246,229,242,243,229,100,129, 1,142, 8,237,227,249,242,
- 233,236,236,233, 99,128, 4, 45,115, 4, 9, 2, 9, 13, 9, 33,
- 9, 37,227,249,242,233,236,236,233, 99,128, 4, 33,228,229,243,
- 227,229,238,228,229,242,227,249,242,233,236,236,233, 99,128, 4,
- 170,104,128, 1,169,237,225,236,108,128,247,101,116, 3, 9, 52,
- 9, 78, 9, 92, 97,130, 3,151, 9, 60, 9, 70,242,237,229,238,
- 233,225,110,128, 5, 56,244,239,238,239,115,128, 3,137,104,129,
- 0,208, 9, 84,243,237,225,236,108,128,247,240,233,236,228,101,
- 129, 30,188, 9,101,226,229,236,239,119,128, 30, 26,245,242,111,
- 128, 32,172,250,104,130, 1,183, 9,124, 9,132,227,225,242,239,
- 110,128, 1,238,242,229,246,229,242,243,229,100,128, 1,184, 70,
- 136, 0, 70, 9,163, 9,172, 9,184, 9,212, 9,219, 9,248, 10,
- 4, 10, 15,227,233,242,227,236,101,128, 36,187,228,239,244,225,
- 227,227,229,238,116,128, 30, 30,101, 2, 9,190, 9,202,232,225,
- 242,237,229,238,233,225,110,128, 5, 86,233,227,239,240,244,233,
- 99,128, 3,228,232,239,239,107,128, 1,145,105, 2, 9,225, 9,
- 238,244,225,227,249,242,233,236,236,233, 99,128, 4,114,246,229,
- 242,239,237,225,110,128, 33,100,237,239,238,239,243,240,225,227,
- 101,128,255, 38,239,245,242,242,239,237,225,110,128, 33, 99,243,
- 237,225,236,108,128,247,102, 71,140, 0, 71, 10, 51, 10, 61, 10,
- 107, 10,115, 10,176, 10,193, 10,205, 11, 39, 11, 52, 11, 65, 11,
- 90, 11,107,194,243,241,245,225,242,101,128, 51,135, 97, 3, 10,
- 69, 10, 76, 10, 94,227,245,244,101,128, 1,244,237,237, 97,129,
- 3,147, 10, 84,225,230,242,233,227,225,110,128, 1,148,238,231,
- 233,225,227,239,240,244,233, 99,128, 3,234,226,242,229,246,101,
- 128, 1, 30, 99, 4, 10,125, 10,132, 10,141, 10,163,225,242,239,
- 110,128, 1,230,229,228,233,236,236, 97,128, 1, 34,233,242, 99,
- 2, 10,149, 10,154,236,101,128, 36,188,245,237,230,236,229,120,
- 128, 1, 28,239,237,237,225,225,227,227,229,238,116,128, 1, 34,
- 228,239,116,129, 1, 32, 10,184,225,227,227,229,238,116,128, 1,
- 32,229,227,249,242,233,236,236,233, 99,128, 4, 19,104, 3, 10,
- 213, 10,226, 11, 33,225,228,225,242,237,229,238,233,225,110,128,
- 5, 66,101, 3, 10,234, 10,255, 11, 16,237,233,228,228,236,229,
- 232,239,239,235,227,249,242,233,236,236,233, 99,128, 4,148,243,
- 244,242,239,235,229,227,249,242,233,236,236,233, 99,128, 4,146,
- 245,240,244,245,242,238,227,249,242,233,236,236,233, 99,128, 4,
- 144,239,239,107,128, 1,147,233,237,225,242,237,229,238,233,225,
- 110,128, 5, 51,234,229,227,249,242,233,236,236,233, 99,128, 4,
- 3,109, 2, 11, 71, 11, 79,225,227,242,239,110,128, 30, 32,239,
- 238,239,243,240,225,227,101,128,255, 39,242,225,246,101,129,246,
- 206, 11, 99,243,237,225,236,108,128,247, 96,115, 2, 11,113, 11,
- 129,237,225,236,108,129,247,103, 11,122,232,239,239,107,128, 2,
- 155,244,242,239,235,101,128, 1,228, 72,140, 0, 72, 11,165, 11,
- 190, 11,198, 11,208, 12, 17, 12, 40, 12, 77, 12,117, 12,129, 12,
- 157, 12,165, 12,189,177,184, 53, 3, 11,175, 11,180, 11,185,179,
- 51,128, 37,207,180, 51,128, 37,170,181, 49,128, 37,171,178,178,
- 176,183, 51,128, 37,161,208,243,241,245,225,242,101,128, 51,203,
- 97, 3, 11,216, 11,236, 12, 0,225,226,235,232,225,243,233,225,
- 238,227,249,242,233,236,236,233, 99,128, 4,168,228,229,243,227,
- 229,238,228,229,242,227,249,242,233,236,236,233, 99,128, 4,178,
- 242,228,243,233,231,238,227,249,242,233,236,236,233, 99,128, 4,
- 42, 98, 2, 12, 23, 12, 28,225,114,128, 1, 38,242,229,246,229,
- 226,229,236,239,119,128, 30, 42, 99, 2, 12, 46, 12, 55,229,228,
- 233,236,236, 97,128, 30, 40,233,242, 99, 2, 12, 63, 12, 68,236,
- 101,128, 36,189,245,237,230,236,229,120,128, 1, 36,100, 2, 12,
- 83, 12, 93,233,229,242,229,243,233,115,128, 30, 38,239,116, 2,
- 12,100, 12,109,225,227,227,229,238,116,128, 30, 34,226,229,236,
- 239,119,128, 30, 36,237,239,238,239,243,240,225,227,101,128,255,
- 40,111, 2, 12,135, 12,146,225,242,237,229,238,233,225,110,128,
- 5, 64,242,233,227,239,240,244,233, 99,128, 3,232,243,237,225,
- 236,108,128,247,104,245,238,231,225,242,245,237,236,225,245,116,
- 129,246,207, 12,181,243,237,225,236,108,128,246,248,250,243,241,
- 245,225,242,101,128, 51,144, 73,146, 0, 73, 12,239, 12,251, 12,
- 255, 13, 11, 13, 29, 13, 37, 13, 94, 13,181, 13,214, 13,224, 13,
- 242, 13,254, 14, 48, 14, 86, 14, 99, 14,166, 14,187, 14,205,193,
- 227,249,242,233,236,236,233, 99,128, 4, 47, 74,128, 1, 50,213,
- 227,249,242,233,236,236,233, 99,128, 4, 46,225,227,245,244,101,
- 129, 0,205, 13, 21,243,237,225,236,108,128,247,237,226,242,229,
- 246,101,128, 1, 44, 99, 3, 13, 45, 13, 52, 13, 84,225,242,239,
- 110,128, 1,207,233,242, 99, 2, 13, 60, 13, 65,236,101,128, 36,
- 190,245,237,230,236,229,120,129, 0,206, 13, 76,243,237,225,236,
- 108,128,247,238,249,242,233,236,236,233, 99,128, 4, 6,100, 3,
- 13,102, 13,112, 13,155,226,236,231,242,225,246,101,128, 2, 8,
- 233,229,242,229,243,233,115,131, 0,207, 13,128, 13,136, 13,147,
- 225,227,245,244,101,128, 30, 46,227,249,242,233,236,236,233, 99,
- 128, 4,228,243,237,225,236,108,128,247,239,239,116,130, 1, 48,
- 13,164, 13,173,225,227,227,229,238,116,128, 1, 48,226,229,236,
- 239,119,128, 30,202,101, 2, 13,187, 13,203,226,242,229,246,229,
- 227,249,242,233,236,236,233, 99,128, 4,214,227,249,242,233,236,
- 236,233, 99,128, 4, 21,230,242,225,235,244,245,114,128, 33, 17,
- 231,242,225,246,101,129, 0,204, 13,234,243,237,225,236,108,128,
- 247,236,232,239,239,235,225,226,239,246,101,128, 30,200,105, 3,
- 14, 6, 14, 17, 14, 32,227,249,242,233,236,236,233, 99,128, 4,
- 24,238,246,229,242,244,229,228,226,242,229,246,101,128, 2, 10,
- 243,232,239,242,244,227,249,242,233,236,236,233, 99,128, 4, 25,
- 109, 2, 14, 54, 14, 75,225,227,242,239,110,129, 1, 42, 14, 64,
- 227,249,242,233,236,236,233, 99,128, 4,226,239,238,239,243,240,
- 225,227,101,128,255, 41,238,233,225,242,237,229,238,233,225,110,
- 128, 5, 59,111, 3, 14,107, 14,118, 14,126,227,249,242,233,236,
- 236,233, 99,128, 4, 1,231,239,238,229,107,128, 1, 46,244, 97,
- 131, 3,153, 14,137, 14,147, 14,158,225,230,242,233,227,225,110,
- 128, 1,150,228,233,229,242,229,243,233,115,128, 3,170,244,239,
- 238,239,115,128, 3,138,115, 2, 14,172, 14,179,237,225,236,108,
- 128,247,105,244,242,239,235,101,128, 1,151,244,233,236,228,101,
- 129, 1, 40, 14,197,226,229,236,239,119,128, 30, 44,250,232,233,
- 244,243, 97, 2, 14,216, 14,227,227,249,242,233,236,236,233, 99,
- 128, 4,116,228,226,236,231,242,225,246,229,227,249,242,233,236,
- 236,233, 99,128, 4,118, 74,134, 0, 74, 15, 6, 15, 18, 15, 41,
- 15, 53, 15, 67, 15, 79,225,225,242,237,229,238,233,225,110,128,
- 5, 65,227,233,242, 99, 2, 15, 27, 15, 32,236,101,128, 36,191,
- 245,237,230,236,229,120,128, 1, 52,229,227,249,242,233,236,236,
- 233, 99,128, 4, 8,232,229,232,225,242,237,229,238,233,225,110,
- 128, 5, 75,237,239,238,239,243,240,225,227,101,128,255, 42,243,
- 237,225,236,108,128,247,106, 75,140, 0, 75, 15,115, 15,125, 15,
- 135, 16, 18, 16, 65, 16, 76, 16,106, 16,143, 16,156, 16,168, 16,
- 180, 16,208,194,243,241,245,225,242,101,128, 51,133,203,243,241,
- 245,225,242,101,128, 51,205, 97, 7, 15,151, 15,169, 15,191, 15,
- 211, 15,226, 15,232, 15,249,226,225,243,232,235,233,242,227,249,
- 242,233,236,236,233, 99,128, 4,160, 99, 2, 15,175, 15,181,245,
- 244,101,128, 30, 48,249,242,233,236,236,233, 99,128, 4, 26,228,
- 229,243,227,229,238,228,229,242,227,249,242,233,236,236,233, 99,
- 128, 4,154,232,239,239,235,227,249,242,233,236,236,233, 99,128,
- 4,195,240,240, 97,128, 3,154,243,244,242,239,235,229,227,249,
- 242,233,236,236,233, 99,128, 4,158,246,229,242,244,233,227,225,
- 236,243,244,242,239,235,229,227,249,242,233,236,236,233, 99,128,
- 4,156, 99, 4, 16, 28, 16, 35, 16, 44, 16, 52,225,242,239,110,
- 128, 1,232,229,228,233,236,236, 97,128, 1, 54,233,242,227,236,
- 101,128, 36,192,239,237,237,225,225,227,227,229,238,116,128, 1,
- 54,228,239,244,226,229,236,239,119,128, 30, 50,101, 2, 16, 82,
- 16, 94,232,225,242,237,229,238,233,225,110,128, 5, 84,238,225,
- 242,237,229,238,233,225,110,128, 5, 63,104, 3, 16,114, 16,126,
- 16,137,225,227,249,242,233,236,236,233, 99,128, 4, 37,229,233,
- 227,239,240,244,233, 99,128, 3,230,239,239,107,128, 1,152,234,
- 229,227,249,242,233,236,236,233, 99,128, 4, 12,236,233,238,229,
- 226,229,236,239,119,128, 30, 52,237,239,238,239,243,240,225,227,
- 101,128,255, 43,239,240,240, 97, 2, 16,189, 16,200,227,249,242,
- 233,236,236,233, 99,128, 4,128,231,242,229,229,107,128, 3,222,
- 115, 2, 16,214, 16,226,233,227,249,242,233,236,236,233, 99,128,
- 4,110,237,225,236,108,128,247,107, 76,138, 0, 76, 17, 1, 17,
- 5, 17, 9, 17, 29, 17, 95, 17,133, 17,147, 17,165, 17,177, 17,
- 189, 74,128, 1,199, 76,128,246,191, 97, 2, 17, 15, 17, 22,227,
- 245,244,101,128, 1, 57,237,226,228, 97,128, 3,155, 99, 4, 17,
- 39, 17, 46, 17, 55, 17, 82,225,242,239,110,128, 1, 61,229,228,
- 233,236,236, 97,128, 1, 59,233,242, 99, 2, 17, 63, 17, 68,236,
- 101,128, 36,193,245,237,230,236,229,248,226,229,236,239,119,128,
- 30, 60,239,237,237,225,225,227,227,229,238,116,128, 1, 59,228,
- 239,116,130, 1, 63, 17,105, 17,114,225,227,227,229,238,116,128,
- 1, 63,226,229,236,239,119,129, 30, 54, 17,124,237,225,227,242,
- 239,110,128, 30, 56,233,247,238,225,242,237,229,238,233,225,110,
- 128, 5, 60,106,129, 1,200, 17,153,229,227,249,242,233,236,236,
- 233, 99,128, 4, 9,236,233,238,229,226,229,236,239,119,128, 30,
- 58,237,239,238,239,243,240,225,227,101,128,255, 44,115, 2, 17,
- 195, 17,212,236,225,243,104,129, 1, 65, 17,204,243,237,225,236,
- 108,128,246,249,237,225,236,108,128,247,108, 77,137, 0, 77, 17,
- 241, 17,251, 18, 24, 18, 33, 18, 58, 18, 71, 18, 83, 18, 91, 18,
- 100,194,243,241,245,225,242,101,128, 51,134,225, 99, 2, 18, 2,
- 18, 18,242,239,110,129,246,208, 18, 10,243,237,225,236,108,128,
- 247,175,245,244,101,128, 30, 62,227,233,242,227,236,101,128, 36,
- 194,228,239,116, 2, 18, 41, 18, 50,225,227,227,229,238,116,128,
- 30, 64,226,229,236,239,119,128, 30, 66,229,238,225,242,237,229,
- 238,233,225,110,128, 5, 68,237,239,238,239,243,240,225,227,101,
- 128,255, 45,243,237,225,236,108,128,247,109,244,245,242,238,229,
- 100,128, 1,156,117,128, 3,156, 78,141, 0, 78, 18,134, 18,138,
- 18,146, 18,212, 18,237, 18,248, 19, 3, 19, 21, 19, 33, 19, 45,
- 19, 58, 19, 66, 19, 84, 74,128, 1,202,225,227,245,244,101,128,
- 1, 67, 99, 4, 18,156, 18,163, 18,172, 18,199,225,242,239,110,
- 128, 1, 71,229,228,233,236,236, 97,128, 1, 69,233,242, 99, 2,
- 18,180, 18,185,236,101,128, 36,195,245,237,230,236,229,248,226,
- 229,236,239,119,128, 30, 74,239,237,237,225,225,227,227,229,238,
- 116,128, 1, 69,228,239,116, 2, 18,220, 18,229,225,227,227,229,
- 238,116,128, 30, 68,226,229,236,239,119,128, 30, 70,232,239,239,
- 235,236,229,230,116,128, 1,157,233,238,229,242,239,237,225,110,
- 128, 33,104,106,129, 1,203, 19, 9,229,227,249,242,233,236,236,
- 233, 99,128, 4, 10,236,233,238,229,226,229,236,239,119,128, 30,
- 72,237,239,238,239,243,240,225,227,101,128,255, 46,239,247,225,
- 242,237,229,238,233,225,110,128, 5, 70,243,237,225,236,108,128,
- 247,110,244,233,236,228,101,129, 0,209, 19, 76,243,237,225,236,
- 108,128,247,241,117,128, 3,157, 79,141, 0, 79, 19,118, 19,132,
- 19,150, 19,203, 20, 78, 20,152, 20,187, 21, 48, 21, 69, 21,213,
- 21,223, 21,254, 22, 53, 69,129, 1, 82, 19,124,243,237,225,236,
- 108,128,246,250,225,227,245,244,101,129, 0,211, 19,142,243,237,
- 225,236,108,128,247,243, 98, 2, 19,156, 19,196,225,242,242,229,
- 100, 2, 19,166, 19,177,227,249,242,233,236,236,233, 99,128, 4,
- 232,228,233,229,242,229,243,233,243,227,249,242,233,236,236,233,
- 99,128, 4,234,242,229,246,101,128, 1, 78, 99, 4, 19,213, 19,
- 220, 19,235, 20, 68,225,242,239,110,128, 1,209,229,238,244,229,
- 242,229,228,244,233,236,228,101,128, 1,159,233,242, 99, 2, 19,
- 243, 19,248,236,101,128, 36,196,245,237,230,236,229,120,134, 0,
- 212, 20, 13, 20, 21, 20, 32, 20, 40, 20, 52, 20, 60,225,227,245,
- 244,101,128, 30,208,228,239,244,226,229,236,239,119,128, 30,216,
- 231,242,225,246,101,128, 30,210,232,239,239,235,225,226,239,246,
- 101,128, 30,212,243,237,225,236,108,128,247,244,244,233,236,228,
- 101,128, 30,214,249,242,233,236,236,233, 99,128, 4, 30,100, 3,
- 20, 86, 20,109, 20,142,226,108, 2, 20, 93, 20,101,225,227,245,
- 244,101,128, 1, 80,231,242,225,246,101,128, 2, 12,233,229,242,
- 229,243,233,115,130, 0,214, 20,123, 20,134,227,249,242,233,236,
- 236,233, 99,128, 4,230,243,237,225,236,108,128,247,246,239,244,
- 226,229,236,239,119,128, 30,204,103, 2, 20,158, 20,170,239,238,
- 229,235,243,237,225,236,108,128,246,251,242,225,246,101,129, 0,
- 210, 20,179,243,237,225,236,108,128,247,242,104, 4, 20,197, 20,
- 208, 20,212, 21, 34,225,242,237,229,238,233,225,110,128, 5, 85,
- 109,128, 33, 38,111, 2, 20,218, 20,228,239,235,225,226,239,246,
- 101,128, 30,206,242,110,133, 1,160, 20,243, 20,251, 21, 6, 21,
- 14, 21, 26,225,227,245,244,101,128, 30,218,228,239,244,226,229,
- 236,239,119,128, 30,226,231,242,225,246,101,128, 30,220,232,239,
- 239,235,225,226,239,246,101,128, 30,222,244,233,236,228,101,128,
- 30,224,245,238,231,225,242,245,237,236,225,245,116,128, 1, 80,
- 105,129, 1,162, 21, 54,238,246,229,242,244,229,228,226,242,229,
- 246,101,128, 2, 14,109, 4, 21, 79, 21,107, 21,184, 21,202,225,
- 227,242,239,110,130, 1, 76, 21, 91, 21, 99,225,227,245,244,101,
- 128, 30, 82,231,242,225,246,101,128, 30, 80,229,231, 97,132, 33,
- 38, 21,121, 21,132, 21,140, 21,156,227,249,242,233,236,236,233,
- 99,128, 4, 96,231,242,229,229,107,128, 3,169,242,239,245,238,
- 228,227,249,242,233,236,236,233, 99,128, 4,122,116, 2, 21,162,
- 21,177,233,244,236,239,227,249,242,233,236,236,233, 99,128, 4,
- 124,239,238,239,115,128, 3,143,233,227,242,239,110,129, 3,159,
- 21,194,244,239,238,239,115,128, 3,140,239,238,239,243,240,225,
- 227,101,128,255, 47,238,229,242,239,237,225,110,128, 33, 96,111,
- 2, 21,229, 21,248,231,239,238,229,107,129, 1,234, 21,239,237,
- 225,227,242,239,110,128, 1,236,240,229,110,128, 1,134,115, 3,
- 22, 6, 22, 33, 22, 40,236,225,243,104,130, 0,216, 22, 17, 22,
- 25,225,227,245,244,101,128, 1,254,243,237,225,236,108,128,247,
- 248,237,225,236,108,128,247,111,244,242,239,235,229,225,227,245,
- 244,101,128, 1,254,116, 2, 22, 59, 22, 70,227,249,242,233,236,
- 236,233, 99,128, 4,126,233,236,228,101,131, 0,213, 22, 83, 22,
- 91, 22,102,225,227,245,244,101,128, 30, 76,228,233,229,242,229,
- 243,233,115,128, 30, 78,243,237,225,236,108,128,247,245, 80,136,
- 0, 80, 22,130, 22,138, 22,147, 22,159, 22,211, 22,227, 22,246,
- 23, 2,225,227,245,244,101,128, 30, 84,227,233,242,227,236,101,
- 128, 36,197,228,239,244,225,227,227,229,238,116,128, 30, 86,101,
- 3, 22,167, 22,178, 22,190,227,249,242,233,236,236,233, 99,128,
- 4, 31,232,225,242,237,229,238,233,225,110,128, 5, 74,237,233,
- 228,228,236,229,232,239,239,235,227,249,242,233,236,236,233, 99,
- 128, 4,166,104, 2, 22,217, 22,221,105,128, 3,166,239,239,107,
- 128, 1,164,105,129, 3,160, 22,233,247,242,225,242,237,229,238,
- 233,225,110,128, 5, 83,237,239,238,239,243,240,225,227,101,128,
- 255, 48,115, 2, 23, 8, 23, 25,105,129, 3,168, 23, 14,227,249,
- 242,233,236,236,233, 99,128, 4,112,237,225,236,108,128,247,112,
- 81,131, 0, 81, 23, 42, 23, 51, 23, 63,227,233,242,227,236,101,
- 128, 36,198,237,239,238,239,243,240,225,227,101,128,255, 49,243,
- 237,225,236,108,128,247,113, 82,138, 0, 82, 23, 95, 23,119, 23,
- 166, 23,217, 23,230, 23,240, 23,245, 24, 19, 24, 31, 24, 43, 97,
- 2, 23,101, 23,112,225,242,237,229,238,233,225,110,128, 5, 76,
- 227,245,244,101,128, 1, 84, 99, 4, 23,129, 23,136, 23,145, 23,
- 153,225,242,239,110,128, 1, 88,229,228,233,236,236, 97,128, 1,
- 86,233,242,227,236,101,128, 36,199,239,237,237,225,225,227,227,
- 229,238,116,128, 1, 86,100, 2, 23,172, 23,182,226,236,231,242,
- 225,246,101,128, 2, 16,239,116, 2, 23,189, 23,198,225,227,227,
- 229,238,116,128, 30, 88,226,229,236,239,119,129, 30, 90, 23,208,
- 237,225,227,242,239,110,128, 30, 92,229,232,225,242,237,229,238,
- 233,225,110,128, 5, 80,230,242,225,235,244,245,114,128, 33, 28,
- 232,111,128, 3,161,233,110, 2, 23,252, 24, 5,231,243,237,225,
- 236,108,128,246,252,246,229,242,244,229,228,226,242,229,246,101,
- 128, 2, 18,236,233,238,229,226,229,236,239,119,128, 30, 94,237,
- 239,238,239,243,240,225,227,101,128,255, 50,243,237,225,236,108,
- 129,247,114, 24, 53,233,238,246,229,242,244,229,100,129, 2,129,
- 24, 66,243,245,240,229,242,233,239,114,128, 2,182, 83,139, 0,
- 83, 24,103, 26, 17, 26, 55, 26,182, 26,221, 26,250, 27, 84, 27,
- 105, 27,117, 27,135, 27,143, 70, 6, 24,117, 24,209, 24,241, 25,
- 77, 25,119, 25,221, 48, 9, 24,137, 24,145, 24,153, 24,161, 24,
- 169, 24,177, 24,185, 24,193, 24,201,177,176,176,176, 48,128, 37,
- 12,178,176,176,176, 48,128, 37, 20,179,176,176,176, 48,128, 37,
- 16,180,176,176,176, 48,128, 37, 24,181,176,176,176, 48,128, 37,
- 60,182,176,176,176, 48,128, 37, 44,183,176,176,176, 48,128, 37,
- 52,184,176,176,176, 48,128, 37, 28,185,176,176,176, 48,128, 37,
- 36, 49, 3, 24,217, 24,225, 24,233,176,176,176,176, 48,128, 37,
- 0,177,176,176,176, 48,128, 37, 2,185,176,176,176, 48,128, 37,
- 97, 50, 9, 25, 5, 25, 13, 25, 21, 25, 29, 25, 37, 25, 45, 25,
- 53, 25, 61, 25, 69,176,176,176,176, 48,128, 37, 98,177,176,176,
- 176, 48,128, 37, 86,178,176,176,176, 48,128, 37, 85,179,176,176,
- 176, 48,128, 37, 99,180,176,176,176, 48,128, 37, 81,181,176,176,
- 176, 48,128, 37, 87,182,176,176,176, 48,128, 37, 93,183,176,176,
- 176, 48,128, 37, 92,184,176,176,176, 48,128, 37, 91, 51, 4, 25,
- 87, 25, 95, 25,103, 25,111,182,176,176,176, 48,128, 37, 94,183,
- 176,176,176, 48,128, 37, 95,184,176,176,176, 48,128, 37, 90,185,
- 176,176,176, 48,128, 37, 84, 52, 10, 25,141, 25,149, 25,157, 25,
- 165, 25,173, 25,181, 25,189, 25,197, 25,205, 25,213,176,176,176,
- 176, 48,128, 37,105,177,176,176,176, 48,128, 37,102,178,176,176,
- 176, 48,128, 37, 96,179,176,176,176, 48,128, 37, 80,180,176,176,
- 176, 48,128, 37,108,181,176,176,176, 48,128, 37,103,182,176,176,
- 176, 48,128, 37,104,183,176,176,176, 48,128, 37,100,184,176,176,
- 176, 48,128, 37,101,185,176,176,176, 48,128, 37, 89, 53, 5, 25,
- 233, 25,241, 25,249, 26, 1, 26, 9,176,176,176,176, 48,128, 37,
- 88,177,176,176,176, 48,128, 37, 82,178,176,176,176, 48,128, 37,
- 83,179,176,176,176, 48,128, 37,107,180,176,176,176, 48,128, 37,
- 106, 97, 2, 26, 23, 26, 44,227,245,244,101,129, 1, 90, 26, 32,
- 228,239,244,225,227,227,229,238,116,128, 30,100,237,240,233,231,
- 242,229,229,107,128, 3,224, 99, 5, 26, 67, 26, 98, 26,107, 26,
- 147, 26,169,225,242,239,110,130, 1, 96, 26, 78, 26, 90,228,239,
- 244,225,227,227,229,238,116,128, 30,102,243,237,225,236,108,128,
- 246,253,229,228,233,236,236, 97,128, 1, 94,232,247, 97,130, 1,
- 143, 26,117, 26,128,227,249,242,233,236,236,233, 99,128, 4,216,
- 228,233,229,242,229,243,233,243,227,249,242,233,236,236,233, 99,
- 128, 4,218,233,242, 99, 2, 26,155, 26,160,236,101,128, 36,200,
- 245,237,230,236,229,120,128, 1, 92,239,237,237,225,225,227,227,
- 229,238,116,128, 2, 24,228,239,116, 2, 26,190, 26,199,225,227,
- 227,229,238,116,128, 30, 96,226,229,236,239,119,129, 30, 98, 26,
- 209,228,239,244,225,227,227,229,238,116,128, 30,104,101, 2, 26,
- 227, 26,239,232,225,242,237,229,238,233,225,110,128, 5, 77,246,
- 229,238,242,239,237,225,110,128, 33,102,104, 5, 27, 6, 27, 34,
- 27, 48, 27, 59, 27, 72, 97, 2, 27, 12, 27, 23,225,242,237,229,
- 238,233,225,110,128, 5, 71,227,249,242,233,236,236,233, 99,128,
- 4, 40,227,232,225,227,249,242,233,236,236,233, 99,128, 4, 41,
- 229,233,227,239,240,244,233, 99,128, 3,226,232,225,227,249,242,
- 233,236,236,233, 99,128, 4,186,233,237,225,227,239,240,244,233,
- 99,128, 3,236,105, 2, 27, 90, 27, 96,231,237, 97,128, 3,163,
- 248,242,239,237,225,110,128, 33,101,237,239,238,239,243,240,225,
- 227,101,128,255, 51,239,230,244,243,233,231,238,227,249,242,233,
- 236,236,233, 99,128, 4, 44,243,237,225,236,108,128,247,115,244,
- 233,231,237,225,231,242,229,229,107,128, 3,218, 84,141, 0, 84,
- 27,186, 27,191, 27,197, 28, 7, 28, 32, 28, 96, 28,147, 28,177,
- 28,189, 28,201, 28,246, 29, 6, 29, 46,225,117,128, 3,164,226,
- 225,114,128, 1,102, 99, 4, 27,207, 27,214, 27,223, 27,250,225,
- 242,239,110,128, 1,100,229,228,233,236,236, 97,128, 1, 98,233,
- 242, 99, 2, 27,231, 27,236,236,101,128, 36,201,245,237,230,236,
- 229,248,226,229,236,239,119,128, 30,112,239,237,237,225,225,227,
- 227,229,238,116,128, 1, 98,228,239,116, 2, 28, 15, 28, 24,225,
- 227,227,229,238,116,128, 30,106,226,229,236,239,119,128, 30,108,
- 101, 4, 28, 42, 28, 53, 28, 73, 28, 82,227,249,242,233,236,236,
- 233, 99,128, 4, 34,228,229,243,227,229,238,228,229,242,227,249,
- 242,233,236,236,233, 99,128, 4,172,238,242,239,237,225,110,128,
- 33,105,244,243,229,227,249,242,233,236,236,233, 99,128, 4,180,
- 104, 3, 28,104, 28,110, 28,136,229,244, 97,128, 3,152,111, 2,
- 28,116, 28,121,239,107,128, 1,172,242,110,129, 0,222, 28,128,
- 243,237,225,236,108,128,247,254,242,229,229,242,239,237,225,110,
- 128, 33, 98,105, 2, 28,153, 28,164,236,228,229,243,237,225,236,
- 108,128,246,254,247,238,225,242,237,229,238,233,225,110,128, 5,
- 79,236,233,238,229,226,229,236,239,119,128, 30,110,237,239,238,
- 239,243,240,225,227,101,128,255, 52,111, 2, 28,207, 28,218,225,
- 242,237,229,238,233,225,110,128, 5, 57,238,101, 3, 28,227, 28,
- 234, 28,240,230,233,246,101,128, 1,188,243,233,120,128, 1,132,
- 244,247,111,128, 1,167,242,229,244,242,239,230,236,229,248,232,
- 239,239,107,128, 1,174,115, 3, 29, 14, 29, 26, 29, 39,229,227,
- 249,242,233,236,236,233, 99,128, 4, 38,232,229,227,249,242,233,
- 236,236,233, 99,128, 4, 11,237,225,236,108,128,247,116,119, 2,
- 29, 52, 29, 64,229,236,246,229,242,239,237,225,110,128, 33,107,
- 239,242,239,237,225,110,128, 33, 97, 85,142, 0, 85, 29,105, 29,
- 123, 29,131, 29,198, 30, 69, 30, 87, 30,198, 30,214, 30,226, 31,
- 21, 31, 30, 31,142, 31,149, 31,219,225,227,245,244,101,129, 0,
- 218, 29,115,243,237,225,236,108,128,247,250,226,242,229,246,101,
- 128, 1,108, 99, 3, 29,139, 29,146, 29,188,225,242,239,110,128,
- 1,211,233,242, 99, 2, 29,154, 29,159,236,101,128, 36,202,245,
- 237,230,236,229,120,130, 0,219, 29,172, 29,180,226,229,236,239,
- 119,128, 30,118,243,237,225,236,108,128,247,251,249,242,233,236,
- 236,233, 99,128, 4, 35,100, 3, 29,206, 29,229, 30, 59,226,108,
- 2, 29,213, 29,221,225,227,245,244,101,128, 1,112,231,242,225,
- 246,101,128, 2, 20,233,229,242,229,243,233,115,134, 0,220, 29,
- 251, 30, 3, 30, 11, 30, 34, 30, 42, 30, 51,225,227,245,244,101,
- 128, 1,215,226,229,236,239,119,128, 30,114, 99, 2, 30, 17, 30,
- 24,225,242,239,110,128, 1,217,249,242,233,236,236,233, 99,128,
- 4,240,231,242,225,246,101,128, 1,219,237,225,227,242,239,110,
- 128, 1,213,243,237,225,236,108,128,247,252,239,244,226,229,236,
- 239,119,128, 30,228,231,242,225,246,101,129, 0,217, 30, 79,243,
- 237,225,236,108,128,247,249,104, 2, 30, 93, 30,171,111, 2, 30,
- 99, 30,109,239,235,225,226,239,246,101,128, 30,230,242,110,133,
- 1,175, 30,124, 30,132, 30,143, 30,151, 30,163,225,227,245,244,
- 101,128, 30,232,228,239,244,226,229,236,239,119,128, 30,240,231,
- 242,225,246,101,128, 30,234,232,239,239,235,225,226,239,246,101,
- 128, 30,236,244,233,236,228,101,128, 30,238,245,238,231,225,242,
- 245,237,236,225,245,116,129, 1,112, 30,187,227,249,242,233,236,
- 236,233, 99,128, 4,242,233,238,246,229,242,244,229,228,226,242,
- 229,246,101,128, 2, 22,235,227,249,242,233,236,236,233, 99,128,
- 4,120,109, 2, 30,232, 31, 10,225,227,242,239,110,130, 1,106,
- 30,244, 30,255,227,249,242,233,236,236,233, 99,128, 4,238,228,
- 233,229,242,229,243,233,115,128, 30,122,239,238,239,243,240,225,
- 227,101,128,255, 53,239,231,239,238,229,107,128, 1,114,240,243,
- 233,236,239,110,133, 3,165, 31, 49, 31, 53, 31, 90, 31,121, 31,
- 134, 49,128, 3,210, 97, 2, 31, 59, 31, 81,227,245,244,229,232,
- 239,239,235,243,249,237,226,239,236,231,242,229,229,107,128, 3,
- 211,230,242,233,227,225,110,128, 1,177,228,233,229,242,229,243,
- 233,115,129, 3,171, 31,103,232,239,239,235,243,249,237,226,239,
- 236,231,242,229,229,107,128, 3,212,232,239,239,235,243,249,237,
- 226,239,108,128, 3,210,244,239,238,239,115,128, 3,142,242,233,
- 238,103,128, 1,110,115, 3, 31,157, 31,172, 31,179,232,239,242,
- 244,227,249,242,233,236,236,233, 99,128, 4, 14,237,225,236,108,
- 128,247,117,244,242,225,233,231,232,116, 2, 31,191, 31,202,227,
- 249,242,233,236,236,233, 99,128, 4,174,243,244,242,239,235,229,
- 227,249,242,233,236,236,233, 99,128, 4,176,244,233,236,228,101,
- 130, 1,104, 31,231, 31,239,225,227,245,244,101,128, 30,120,226,
- 229,236,239,119,128, 30,116, 86,136, 0, 86, 32, 11, 32, 20, 32,
- 31, 32, 60, 32, 67, 32, 79, 32, 91, 32, 99,227,233,242,227,236,
- 101,128, 36,203,228,239,244,226,229,236,239,119,128, 30,126,101,
- 2, 32, 37, 32, 48,227,249,242,233,236,236,233, 99,128, 4, 18,
- 247,225,242,237,229,238,233,225,110,128, 5, 78,232,239,239,107,
- 128, 1,178,237,239,238,239,243,240,225,227,101,128,255, 54,239,
- 225,242,237,229,238,233,225,110,128, 5, 72,243,237,225,236,108,
- 128,247,118,244,233,236,228,101,128, 30,124, 87,134, 0, 87, 32,
- 123, 32,131, 32,154, 32,194, 32,202, 32,214,225,227,245,244,101,
- 128, 30,130,227,233,242, 99, 2, 32,140, 32,145,236,101,128, 36,
- 204,245,237,230,236,229,120,128, 1,116,100, 2, 32,160, 32,170,
- 233,229,242,229,243,233,115,128, 30,132,239,116, 2, 32,177, 32,
- 186,225,227,227,229,238,116,128, 30,134,226,229,236,239,119,128,
- 30,136,231,242,225,246,101,128, 30,128,237,239,238,239,243,240,
- 225,227,101,128,255, 55,243,237,225,236,108,128,247,119, 88,134,
- 0, 88, 32,238, 32,247, 33, 18, 33, 31, 33, 35, 33, 47,227,233,
- 242,227,236,101,128, 36,205,100, 2, 32,253, 33, 7,233,229,242,
- 229,243,233,115,128, 30,140,239,244,225,227,227,229,238,116,128,
- 30,138,229,232,225,242,237,229,238,233,225,110,128, 5, 61,105,
- 128, 3,158,237,239,238,239,243,240,225,227,101,128,255, 56,243,
- 237,225,236,108,128,247,120, 89,139, 0, 89, 33, 81, 33,116, 33,
- 139, 33,189, 33,228, 33,236, 33,253, 34, 40, 34, 52, 34, 60, 34,
- 68, 97, 2, 33, 87, 33,104,227,245,244,101,129, 0,221, 33, 96,
- 243,237,225,236,108,128,247,253,244,227,249,242,233,236,236,233,
- 99,128, 4, 98,227,233,242, 99, 2, 33,125, 33,130,236,101,128,
- 36,206,245,237,230,236,229,120,128, 1,118,100, 2, 33,145, 33,
- 165,233,229,242,229,243,233,115,129, 1,120, 33,157,243,237,225,
- 236,108,128,247,255,239,116, 2, 33,172, 33,181,225,227,227,229,
- 238,116,128, 30,142,226,229,236,239,119,128, 30,244,229,114, 2,
- 33,196, 33,208,233,227,249,242,233,236,236,233, 99,128, 4, 43,
- 245,228,233,229,242,229,243,233,243,227,249,242,233,236,236,233,
- 99,128, 4,248,231,242,225,246,101,128, 30,242,232,239,239,107,
- 129, 1,179, 33,245,225,226,239,246,101,128, 30,246,105, 3, 34,
- 5, 34, 16, 34, 27,225,242,237,229,238,233,225,110,128, 5, 69,
- 227,249,242,233,236,236,233, 99,128, 4, 7,247,238,225,242,237,
- 229,238,233,225,110,128, 5, 82,237,239,238,239,243,240,225,227,
- 101,128,255, 57,243,237,225,236,108,128,247,121,244,233,236,228,
- 101,128, 30,248,245,115, 2, 34, 75, 34,113,226,233,103, 2, 34,
- 83, 34, 94,227,249,242,233,236,236,233, 99,128, 4,106,233,239,
- 244,233,230,233,229,228,227,249,242,233,236,236,233, 99,128, 4,
- 108,236,233,244,244,236,101, 2, 34,124, 34,135,227,249,242,233,
- 236,236,233, 99,128, 4,102,233,239,244,233,230,233,229,228,227,
- 249,242,233,236,236,233, 99,128, 4,104, 90,136, 0, 90, 34,174,
- 34,198, 34,243, 35, 14, 35, 81, 35,173, 35,185, 35,197, 97, 2,
- 34,180, 34,191,225,242,237,229,238,233,225,110,128, 5, 54,227,
- 245,244,101,128, 1,121, 99, 2, 34,204, 34,221,225,242,239,110,
- 129, 1,125, 34,213,243,237,225,236,108,128,246,255,233,242, 99,
- 2, 34,229, 34,234,236,101,128, 36,207,245,237,230,236,229,120,
- 128, 30,144,228,239,116,130, 1,123, 34,253, 35, 6,225,227,227,
- 229,238,116,128, 1,123,226,229,236,239,119,128, 30,146,101, 3,
- 35, 22, 35, 33, 35, 76,227,249,242,233,236,236,233, 99,128, 4,
- 23,100, 2, 35, 39, 35, 58,229,243,227,229,238,228,229,242,227,
- 249,242,233,236,236,233, 99,128, 4,152,233,229,242,229,243,233,
- 243,227,249,242,233,236,236,233, 99,128, 4,222,244, 97,128, 3,
- 150,232,101, 4, 35, 92, 35,103, 35,119, 35,130,225,242,237,229,
- 238,233,225,110,128, 5, 58,226,242,229,246,229,227,249,242,233,
- 236,236,233, 99,128, 4,193,227,249,242,233,236,236,233, 99,128,
- 4, 22,100, 2, 35,136, 35,155,229,243,227,229,238,228,229,242,
- 227,249,242,233,236,236,233, 99,128, 4,150,233,229,242,229,243,
- 233,243,227,249,242,233,236,236,233, 99,128, 4,220,236,233,238,
- 229,226,229,236,239,119,128, 30,148,237,239,238,239,243,240,225,
- 227,101,128,255, 58,115, 2, 35,203, 35,210,237,225,236,108,128,
- 247,122,244,242,239,235,101,128, 1,181, 97,158, 0, 97, 36, 26,
- 38,154, 39, 4, 39, 68, 39,132, 39,196, 40, 4, 40, 68, 40,126,
- 40,190, 41, 70, 41,217, 42,137, 42,237, 43, 17, 49,192, 49,229,
- 50, 0, 50,225, 51, 7, 52, 96, 52,168, 53,123, 53,132, 54, 5,
- 56, 13, 57, 3, 57, 50, 57,201, 57,215, 49,138, 39, 1, 36, 50,
- 36,114, 36,154, 36,218, 37, 26, 37, 90, 37,154, 37,218, 38, 26,
- 38, 90, 48,138, 39, 33, 36, 74, 36, 78, 36, 82, 36, 86, 36, 90,
- 36, 94, 36, 98, 36,102, 36,106, 36,110, 48,128, 39, 94, 49,128,
- 39, 97, 50,128, 39, 98, 51,128, 39, 99, 52,128, 39,100, 53,128,
- 39, 16, 54,128, 39,101, 55,128, 39,102, 56,128, 39,103, 57,128,
- 38, 96, 49,134, 38, 27, 36,130, 36,134, 36,138, 36,142, 36,146,
- 36,150, 48,128, 38,101, 49,128, 38,102, 50,128, 38, 99, 55,128,
- 39, 9, 56,128, 39, 8, 57,128, 39, 7, 50,138, 38, 30, 36,178,
- 36,182, 36,186, 36,190, 36,194, 36,198, 36,202, 36,206, 36,210,
- 36,214, 48,128, 36, 96, 49,128, 36, 97, 50,128, 36, 98, 51,128,
- 36, 99, 52,128, 36,100, 53,128, 36,101, 54,128, 36,102, 55,128,
- 36,103, 56,128, 36,104, 57,128, 36,105, 51,138, 39, 12, 36,242,
- 36,246, 36,250, 36,254, 37, 2, 37, 6, 37, 10, 37, 14, 37, 18,
- 37, 22, 48,128, 39,118, 49,128, 39,119, 50,128, 39,120, 51,128,
- 39,121, 52,128, 39,122, 53,128, 39,123, 54,128, 39,124, 55,128,
- 39,125, 56,128, 39,126, 57,128, 39,127, 52,138, 39, 13, 37, 50,
- 37, 54, 37, 58, 37, 62, 37, 66, 37, 70, 37, 74, 37, 78, 37, 82,
- 37, 86, 48,128, 39,128, 49,128, 39,129, 50,128, 39,130, 51,128,
- 39,131, 52,128, 39,132, 53,128, 39,133, 54,128, 39,134, 55,128,
- 39,135, 56,128, 39,136, 57,128, 39,137, 53,138, 39, 14, 37,114,
- 37,118, 37,122, 37,126, 37,130, 37,134, 37,138, 37,142, 37,146,
- 37,150, 48,128, 39,138, 49,128, 39,139, 50,128, 39,140, 51,128,
- 39,141, 52,128, 39,142, 53,128, 39,143, 54,128, 39,144, 55,128,
- 39,145, 56,128, 39,146, 57,128, 39,147, 54,138, 39, 15, 37,178,
- 37,182, 37,186, 37,190, 37,194, 37,198, 37,202, 37,206, 37,210,
- 37,214, 48,128, 39,148, 49,128, 33,146, 50,128, 39,163, 51,128,
- 33,148, 52,128, 33,149, 53,128, 39,153, 54,128, 39,155, 55,128,
- 39,156, 56,128, 39,157, 57,128, 39,158, 55,138, 39, 17, 37,242,
- 37,246, 37,250, 37,254, 38, 2, 38, 6, 38, 10, 38, 14, 38, 18,
- 38, 22, 48,128, 39,159, 49,128, 39,160, 50,128, 39,161, 51,128,
- 39,162, 52,128, 39,164, 53,128, 39,165, 54,128, 39,166, 55,128,
- 39,167, 56,128, 39,168, 57,128, 39,169, 56,138, 39, 18, 38, 50,
- 38, 54, 38, 58, 38, 62, 38, 66, 38, 70, 38, 74, 38, 78, 38, 82,
- 38, 86, 48,128, 39,171, 49,128, 39,173, 50,128, 39,175, 51,128,
- 39,178, 52,128, 39,179, 53,128, 39,181, 54,128, 39,184, 55,128,
- 39,186, 56,128, 39,187, 57,128, 39,188, 57,138, 39, 19, 38,114,
- 38,118, 38,122, 38,126, 38,130, 38,134, 38,138, 38,142, 38,146,
- 38,150, 48,128, 39,189, 49,128, 39,190, 50,128, 39,154, 51,128,
- 39,170, 52,128, 39,182, 53,128, 39,185, 54,128, 39,152, 55,128,
- 39,180, 56,128, 39,183, 57,128, 39,172, 50,138, 39, 2, 38,178,
- 38,224, 38,228, 38,232, 38,236, 38,240, 38,244, 38,248, 38,252,
- 39, 0, 48,135, 39, 20, 38,196, 38,200, 38,204, 38,208, 38,212,
- 38,216, 38,220, 48,128, 39,174, 49,128, 39,177, 50,128, 39, 3,
- 51,128, 39, 80, 52,128, 39, 82, 53,128, 39,110, 54,128, 39,112,
- 49,128, 39, 21, 50,128, 39, 22, 51,128, 39, 23, 52,128, 39, 24,
- 53,128, 39, 25, 54,128, 39, 26, 55,128, 39, 27, 56,128, 39, 28,
- 57,128, 39, 34, 51,138, 39, 4, 39, 28, 39, 32, 39, 36, 39, 40,
- 39, 44, 39, 48, 39, 52, 39, 56, 39, 60, 39, 64, 48,128, 39, 35,
- 49,128, 39, 36, 50,128, 39, 37, 51,128, 39, 38, 52,128, 39, 39,
- 53,128, 38, 5, 54,128, 39, 41, 55,128, 39, 42, 56,128, 39, 43,
- 57,128, 39, 44, 52,138, 38, 14, 39, 92, 39, 96, 39,100, 39,104,
- 39,108, 39,112, 39,116, 39,120, 39,124, 39,128, 48,128, 39, 45,
- 49,128, 39, 46, 50,128, 39, 47, 51,128, 39, 48, 52,128, 39, 49,
- 53,128, 39, 50, 54,128, 39, 51, 55,128, 39, 52, 56,128, 39, 53,
- 57,128, 39, 54, 53,138, 39, 6, 39,156, 39,160, 39,164, 39,168,
- 39,172, 39,176, 39,180, 39,184, 39,188, 39,192, 48,128, 39, 55,
- 49,128, 39, 56, 50,128, 39, 57, 51,128, 39, 58, 52,128, 39, 59,
- 53,128, 39, 60, 54,128, 39, 61, 55,128, 39, 62, 56,128, 39, 63,
- 57,128, 39, 64, 54,138, 39, 29, 39,220, 39,224, 39,228, 39,232,
- 39,236, 39,240, 39,244, 39,248, 39,252, 40, 0, 48,128, 39, 65,
- 49,128, 39, 66, 50,128, 39, 67, 51,128, 39, 68, 52,128, 39, 69,
- 53,128, 39, 70, 54,128, 39, 71, 55,128, 39, 72, 56,128, 39, 73,
- 57,128, 39, 74, 55,138, 39, 30, 40, 28, 40, 32, 40, 36, 40, 40,
- 40, 44, 40, 48, 40, 52, 40, 56, 40, 60, 40, 64, 48,128, 39, 75,
- 49,128, 37,207, 50,128, 39, 77, 51,128, 37,160, 52,128, 39, 79,
- 53,128, 39, 81, 54,128, 37,178, 55,128, 37,188, 56,128, 37,198,
- 57,128, 39, 86, 56,137, 39, 31, 40, 90, 40, 94, 40, 98, 40,102,
- 40,106, 40,110, 40,114, 40,118, 40,122, 49,128, 37,215, 50,128,
- 39, 88, 51,128, 39, 89, 52,128, 39, 90, 53,128, 39,111, 54,128,
- 39,113, 55,128, 39,114, 56,128, 39,115, 57,128, 39,104, 57,138,
- 39, 32, 40,150, 40,154, 40,158, 40,162, 40,166, 40,170, 40,174,
- 40,178, 40,182, 40,186, 48,128, 39,105, 49,128, 39,108, 50,128,
- 39,109, 51,128, 39,106, 52,128, 39,107, 53,128, 39,116, 54,128,
- 39,117, 55,128, 39, 91, 56,128, 39, 92, 57,128, 39, 93, 97, 7,
- 40,206, 40,216, 40,223, 40,230, 40,255, 41, 15, 41, 26,226,229,
- 238,231,225,236,105,128, 9,134,227,245,244,101,128, 0,225,228,
- 229,246, 97,128, 9, 6,231,117, 2, 40,237, 40,246,234,225,242,
- 225,244,105,128, 10,134,242,237,245,235,232,105,128, 10, 6,237,
- 225,244,242,225,231,245,242,237,245,235,232,105,128, 10, 62,242,
- 245,243,241,245,225,242,101,128, 51, 3,246,239,247,229,236,243,
- 233,231,110, 3, 41, 42, 41, 52, 41, 59,226,229,238,231,225,236,
- 105,128, 9,190,228,229,246, 97,128, 9, 62,231,245,234,225,242,
- 225,244,105,128, 10,190, 98, 4, 41, 80, 41,121, 41,130, 41,140,
- 226,242,229,246,233,225,244,233,239,110, 2, 41, 95, 41,110,237,
- 225,242,235,225,242,237,229,238,233,225,110,128, 5, 95,243,233,
- 231,238,228,229,246, 97,128, 9,112,229,238,231,225,236,105,128,
- 9,133,239,240,239,237,239,230,111,128, 49, 26,242,229,246,101,
- 134, 1, 3, 41,159, 41,167, 41,178, 41,189, 41,197, 41,209,225,
- 227,245,244,101,128, 30,175,227,249,242,233,236,236,233, 99,128,
- 4,209,228,239,244,226,229,236,239,119,128, 30,183,231,242,225,
- 246,101,128, 30,177,232,239,239,235,225,226,239,246,101,128, 30,
- 179,244,233,236,228,101,128, 30,181, 99, 4, 41,227, 41,234, 42,
- 57, 42,127,225,242,239,110,128, 1,206,233,242, 99, 2, 41,242,
- 41,247,236,101,128, 36,208,245,237,230,236,229,120,133, 0,226,
- 42, 10, 42, 18, 42, 29, 42, 37, 42, 49,225,227,245,244,101,128,
- 30,165,228,239,244,226,229,236,239,119,128, 30,173,231,242,225,
- 246,101,128, 30,167,232,239,239,235,225,226,239,246,101,128, 30,
- 169,244,233,236,228,101,128, 30,171,245,244,101,133, 0,180, 42,
- 73, 42, 84, 42,101, 42,108, 42,117,226,229,236,239,247,227,237,
- 98,128, 3, 23, 99, 2, 42, 90, 42, 95,237, 98,128, 3, 1,239,
- 237, 98,128, 3, 1,228,229,246, 97,128, 9, 84,236,239,247,237,
- 239,100,128, 2,207,244,239,238,229,227,237, 98,128, 3, 65,249,
- 242,233,236,236,233, 99,128, 4, 48,100, 5, 42,149, 42,159, 42,
- 173, 42,179, 42,213,226,236,231,242,225,246,101,128, 2, 1,228,
- 225,235,231,245,242,237,245,235,232,105,128, 10,113,229,246, 97,
- 128, 9, 5,233,229,242,229,243,233,115,130, 0,228, 42,193, 42,
- 204,227,249,242,233,236,236,233, 99,128, 4,211,237,225,227,242,
- 239,110,128, 1,223,239,116, 2, 42,220, 42,228,226,229,236,239,
- 119,128, 30,161,237,225,227,242,239,110,128, 1,225,101,131, 0,
- 230, 42,247, 42,255, 43, 8,225,227,245,244,101,128, 1,253,235,
- 239,242,229,225,110,128, 49, 80,237,225,227,242,239,110,128, 1,
- 227,230,233,105, 6, 43, 33, 43, 53, 45,246, 45,252, 46, 11, 49,
- 111, 48, 2, 43, 39, 43, 46,176,178,176, 56,128, 32, 21,184,185,
- 180, 49,128, 32,164,177, 48, 3, 43, 62, 45, 86, 45,221, 48, 9,
- 43, 82, 43,102, 43,164, 43,226, 44, 32, 44, 94, 44,156, 44,218,
- 45, 24, 49, 3, 43, 90, 43, 94, 43, 98, 55,128, 4, 16, 56,128,
- 4, 17, 57,128, 4, 18, 50, 10, 43,124, 43,128, 43,132, 43,136,
- 43,140, 43,144, 43,148, 43,152, 43,156, 43,160, 48,128, 4, 19,
- 49,128, 4, 20, 50,128, 4, 21, 51,128, 4, 1, 52,128, 4, 22,
- 53,128, 4, 23, 54,128, 4, 24, 55,128, 4, 25, 56,128, 4, 26,
- 57,128, 4, 27, 51, 10, 43,186, 43,190, 43,194, 43,198, 43,202,
- 43,206, 43,210, 43,214, 43,218, 43,222, 48,128, 4, 28, 49,128,
- 4, 29, 50,128, 4, 30, 51,128, 4, 31, 52,128, 4, 32, 53,128,
- 4, 33, 54,128, 4, 34, 55,128, 4, 35, 56,128, 4, 36, 57,128,
- 4, 37, 52, 10, 43,248, 43,252, 44, 0, 44, 4, 44, 8, 44, 12,
- 44, 16, 44, 20, 44, 24, 44, 28, 48,128, 4, 38, 49,128, 4, 39,
- 50,128, 4, 40, 51,128, 4, 41, 52,128, 4, 42, 53,128, 4, 43,
- 54,128, 4, 44, 55,128, 4, 45, 56,128, 4, 46, 57,128, 4, 47,
- 53, 10, 44, 54, 44, 58, 44, 62, 44, 66, 44, 70, 44, 74, 44, 78,
- 44, 82, 44, 86, 44, 90, 48,128, 4,144, 49,128, 4, 2, 50,128,
- 4, 3, 51,128, 4, 4, 52,128, 4, 5, 53,128, 4, 6, 54,128,
- 4, 7, 55,128, 4, 8, 56,128, 4, 9, 57,128, 4, 10, 54, 10,
- 44,116, 44,120, 44,124, 44,128, 44,132, 44,136, 44,140, 44,144,
- 44,148, 44,152, 48,128, 4, 11, 49,128, 4, 12, 50,128, 4, 14,
- 51,128,246,196, 52,128,246,197, 53,128, 4, 48, 54,128, 4, 49,
- 55,128, 4, 50, 56,128, 4, 51, 57,128, 4, 52, 55, 10, 44,178,
- 44,182, 44,186, 44,190, 44,194, 44,198, 44,202, 44,206, 44,210,
- 44,214, 48,128, 4, 53, 49,128, 4, 81, 50,128, 4, 54, 51,128,
- 4, 55, 52,128, 4, 56, 53,128, 4, 57, 54,128, 4, 58, 55,128,
- 4, 59, 56,128, 4, 60, 57,128, 4, 61, 56, 10, 44,240, 44,244,
- 44,248, 44,252, 45, 0, 45, 4, 45, 8, 45, 12, 45, 16, 45, 20,
- 48,128, 4, 62, 49,128, 4, 63, 50,128, 4, 64, 51,128, 4, 65,
- 52,128, 4, 66, 53,128, 4, 67, 54,128, 4, 68, 55,128, 4, 69,
- 56,128, 4, 70, 57,128, 4, 71, 57, 10, 45, 46, 45, 50, 45, 54,
- 45, 58, 45, 62, 45, 66, 45, 70, 45, 74, 45, 78, 45, 82, 48,128,
- 4, 72, 49,128, 4, 73, 50,128, 4, 74, 51,128, 4, 75, 52,128,
- 4, 76, 53,128, 4, 77, 54,128, 4, 78, 55,128, 4, 79, 56,128,
- 4,145, 57,128, 4, 82, 49, 4, 45, 96, 45,158, 45,163, 45,189,
- 48, 10, 45,118, 45,122, 45,126, 45,130, 45,134, 45,138, 45,142,
- 45,146, 45,150, 45,154, 48,128, 4, 83, 49,128, 4, 84, 50,128,
- 4, 85, 51,128, 4, 86, 52,128, 4, 87, 53,128, 4, 88, 54,128,
- 4, 89, 55,128, 4, 90, 56,128, 4, 91, 57,128, 4, 92,177, 48,
- 128, 4, 94, 52, 4, 45,173, 45,177, 45,181, 45,185, 53,128, 4,
- 15, 54,128, 4, 98, 55,128, 4,114, 56,128, 4,116, 57, 5, 45,
- 201, 45,205, 45,209, 45,213, 45,217, 50,128,246,198, 51,128, 4,
- 95, 52,128, 4, 99, 53,128, 4,115, 54,128, 4,117, 56, 2, 45,
- 227, 45,241, 51, 2, 45,233, 45,237, 49,128,246,199, 50,128,246,
- 200,180, 54,128, 4,217,178,185, 57,128, 32, 14,179, 48, 2, 46,
- 3, 46, 7, 48,128, 32, 15, 49,128, 32, 13,181, 55, 7, 46, 28,
- 46, 98, 47,163, 47,240, 48,197, 49, 34, 49,105, 51, 2, 46, 34,
- 46, 48, 56, 2, 46, 40, 46, 44, 49,128, 6,106, 56,128, 6, 12,
- 57, 8, 46, 66, 46, 70, 46, 74, 46, 78, 46, 82, 46, 86, 46, 90,
- 46, 94, 50,128, 6, 96, 51,128, 6, 97, 52,128, 6, 98, 53,128,
- 6, 99, 54,128, 6,100, 55,128, 6,101, 56,128, 6,102, 57,128,
- 6,103, 52, 7, 46,114, 46,146, 46,208, 47, 14, 47, 46, 47,102,
- 47,158, 48, 5, 46,126, 46,130, 46,134, 46,138, 46,142, 48,128,
- 6,104, 49,128, 6,105, 51,128, 6, 27, 55,128, 6, 31, 57,128,
- 6, 33, 49, 10, 46,168, 46,172, 46,176, 46,180, 46,184, 46,188,
- 46,192, 46,196, 46,200, 46,204, 48,128, 6, 34, 49,128, 6, 35,
- 50,128, 6, 36, 51,128, 6, 37, 52,128, 6, 38, 53,128, 6, 39,
- 54,128, 6, 40, 55,128, 6, 41, 56,128, 6, 42, 57,128, 6, 43,
- 50, 10, 46,230, 46,234, 46,238, 46,242, 46,246, 46,250, 46,254,
- 47, 2, 47, 6, 47, 10, 48,128, 6, 44, 49,128, 6, 45, 50,128,
- 6, 46, 51,128, 6, 47, 52,128, 6, 48, 53,128, 6, 49, 54,128,
- 6, 50, 55,128, 6, 51, 56,128, 6, 52, 57,128, 6, 53, 51, 5,
- 47, 26, 47, 30, 47, 34, 47, 38, 47, 42, 48,128, 6, 54, 49,128,
- 6, 55, 50,128, 6, 56, 51,128, 6, 57, 52,128, 6, 58, 52, 9,
- 47, 66, 47, 70, 47, 74, 47, 78, 47, 82, 47, 86, 47, 90, 47, 94,
- 47, 98, 48,128, 6, 64, 49,128, 6, 65, 50,128, 6, 66, 51,128,
- 6, 67, 52,128, 6, 68, 53,128, 6, 69, 54,128, 6, 70, 56,128,
- 6, 72, 57,128, 6, 73, 53, 9, 47,122, 47,126, 47,130, 47,134,
- 47,138, 47,142, 47,146, 47,150, 47,154, 48,128, 6, 74, 49,128,
- 6, 75, 50,128, 6, 76, 51,128, 6, 77, 52,128, 6, 78, 53,128,
- 6, 79, 54,128, 6, 80, 55,128, 6, 81, 56,128, 6, 82,183, 48,
- 128, 6, 71, 53, 3, 47,171, 47,203, 47,235, 48, 5, 47,183, 47,
- 187, 47,191, 47,195, 47,199, 53,128, 6,164, 54,128, 6,126, 55,
- 128, 6,134, 56,128, 6,152, 57,128, 6,175, 49, 5, 47,215, 47,
- 219, 47,223, 47,227, 47,231, 49,128, 6,121, 50,128, 6,136, 51,
- 128, 6,145, 52,128, 6,186, 57,128, 6,210,179, 52,128, 6,213,
- 54, 7, 48, 0, 48, 5, 48, 10, 48, 15, 48, 53, 48,115, 48,177,
- 179, 54,128, 32,170,180, 53,128, 5,190,181, 56,128, 5,195, 54,
- 6, 48, 29, 48, 33, 48, 37, 48, 41, 48, 45, 48, 49, 52,128, 5,
- 208, 53,128, 5,209, 54,128, 5,210, 55,128, 5,211, 56,128, 5,
- 212, 57,128, 5,213, 55, 10, 48, 75, 48, 79, 48, 83, 48, 87, 48,
- 91, 48, 95, 48, 99, 48,103, 48,107, 48,111, 48,128, 5,214, 49,
- 128, 5,215, 50,128, 5,216, 51,128, 5,217, 52,128, 5,218, 53,
- 128, 5,219, 54,128, 5,220, 55,128, 5,221, 56,128, 5,222, 57,
- 128, 5,223, 56, 10, 48,137, 48,141, 48,145, 48,149, 48,153, 48,
- 157, 48,161, 48,165, 48,169, 48,173, 48,128, 5,224, 49,128, 5,
- 225, 50,128, 5,226, 51,128, 5,227, 52,128, 5,228, 53,128, 5,
- 229, 54,128, 5,230, 55,128, 5,231, 56,128, 5,232, 57,128, 5,
- 233, 57, 3, 48,185, 48,189, 48,193, 48,128, 5,234, 52,128,251,
- 42, 53,128,251, 43, 55, 4, 48,207, 48,221, 48,241, 48,246, 48,
- 2, 48,213, 48,217, 48,128,251, 75, 53,128,251, 31, 49, 3, 48,
- 229, 48,233, 48,237, 54,128, 5,240, 55,128, 5,241, 56,128, 5,
- 242,178, 51,128,251, 53, 57, 7, 49, 6, 49, 10, 49, 14, 49, 18,
- 49, 22, 49, 26, 49, 30, 51,128, 5,180, 52,128, 5,181, 53,128,
- 5,182, 54,128, 5,187, 55,128, 5,184, 56,128, 5,183, 57,128,
- 5,176, 56, 3, 49, 42, 49, 86, 49, 91, 48, 7, 49, 58, 49, 62,
- 49, 66, 49, 70, 49, 74, 49, 78, 49, 82, 48,128, 5,178, 49,128,
- 5,177, 50,128, 5,179, 51,128, 5,194, 52,128, 5,193, 54,128,
- 5,185, 55,128, 5,188,179, 57,128, 5,189, 52, 2, 49, 97, 49,
- 101, 49,128, 5,191, 50,128, 5,192,185,178, 57,128, 2,188, 54,
- 3, 49,119, 49,178, 49,185, 49, 4, 49,129, 49,145, 49,151, 49,
- 172, 50, 2, 49,135, 49,140,180, 56,128, 33, 5,184, 57,128, 33,
- 19,179,181, 50,128, 33, 22,181, 55, 3, 49,160, 49,164, 49,168,
- 51,128, 32, 44, 52,128, 32, 45, 53,128, 32, 46,182,182, 52,128,
- 32, 12,179,177,182, 55,128, 6,109,180,185,179, 55,128, 2,189,
- 103, 2, 49,198, 49,205,242,225,246,101,128, 0,224,117, 2, 49,
- 211, 49,220,234,225,242,225,244,105,128, 10,133,242,237,245,235,
- 232,105,128, 10, 5,104, 2, 49,235, 49,245,233,242,225,231,225,
- 238, 97,128, 48, 66,239,239,235,225,226,239,246,101,128, 30,163,
- 105, 7, 50, 16, 50, 41, 50, 48, 50, 60, 50, 85, 50,101, 50,181,
- 98, 2, 50, 22, 50, 31,229,238,231,225,236,105,128, 9,144,239,
- 240,239,237,239,230,111,128, 49, 30,228,229,246, 97,128, 9, 16,
- 229,227,249,242,233,236,236,233, 99,128, 4,213,231,117, 2, 50,
- 67, 50, 76,234,225,242,225,244,105,128, 10,144,242,237,245,235,
- 232,105,128, 10, 16,237,225,244,242,225,231,245,242,237,245,235,
- 232,105,128, 10, 72,110, 5, 50,113, 50,122, 50,136, 50,152, 50,
- 167,225,242,225,226,233, 99,128, 6, 57,230,233,238,225,236,225,
- 242,225,226,233, 99,128,254,202,233,238,233,244,233,225,236,225,
- 242,225,226,233, 99,128,254,203,237,229,228,233,225,236,225,242,
- 225,226,233, 99,128,254,204,246,229,242,244,229,228,226,242,229,
- 246,101,128, 2, 3,246,239,247,229,236,243,233,231,110, 3, 50,
- 197, 50,207, 50,214,226,229,238,231,225,236,105,128, 9,200,228,
- 229,246, 97,128, 9, 72,231,245,234,225,242,225,244,105,128, 10,
- 200,107, 2, 50,231, 50,255,225,244,225,235,225,238, 97,129, 48,
- 162, 50,243,232,225,236,230,247,233,228,244,104,128,255,113,239,
- 242,229,225,110,128, 49, 79,108, 3, 51, 15, 52, 71, 52, 80,101,
- 2, 51, 21, 52, 66,102,136, 5,208, 51, 41, 51, 50, 51, 65, 51,
- 79, 51,168, 51,182, 52, 37, 52, 51,225,242,225,226,233, 99,128,
- 6, 39,228,225,231,229,243,232,232,229,226,242,229,119,128,251,
- 48,230,233,238,225,236,225,242,225,226,233, 99,128,254,142,104,
- 2, 51, 85, 51,160,225,237,250, 97, 2, 51, 94, 51,127,225,226,
- 239,246,101, 2, 51,104, 51,113,225,242,225,226,233, 99,128, 6,
- 35,230,233,238,225,236,225,242,225,226,233, 99,128,254,132,226,
- 229,236,239,119, 2, 51,137, 51,146,225,242,225,226,233, 99,128,
- 6, 37,230,233,238,225,236,225,242,225,226,233, 99,128,254,136,
- 229,226,242,229,119,128, 5,208,236,225,237,229,228,232,229,226,
- 242,229,119,128,251, 79,237, 97, 2, 51,189, 51,225,228,228,225,
- 225,226,239,246,101, 2, 51,202, 51,211,225,242,225,226,233, 99,
- 128, 6, 34,230,233,238,225,236,225,242,225,226,233, 99,128,254,
- 130,235,243,245,242, 97, 4, 51,239, 51,248, 52, 6, 52, 22,225,
- 242,225,226,233, 99,128, 6, 73,230,233,238,225,236,225,242,225,
- 226,233, 99,128,254,240,233,238,233,244,233,225,236,225,242,225,
- 226,233, 99,128,254,243,237,229,228,233,225,236,225,242,225,226,
- 233, 99,128,254,244,240,225,244,225,232,232,229,226,242,229,119,
- 128,251, 46,241,225,237,225,244,243,232,229,226,242,229,119,128,
- 251, 47,240,104,128, 33, 53,236,229,241,245,225,108,128, 34, 76,
- 240,232, 97,129, 3,177, 52, 88,244,239,238,239,115,128, 3,172,
- 109, 4, 52,106, 52,114, 52,125, 52,159,225,227,242,239,110,128,
- 1, 1,239,238,239,243,240,225,227,101,128,255, 65,240,229,242,
- 243,225,238,100,130, 0, 38, 52,139, 52,151,237,239,238,239,243,
- 240,225,227,101,128,255, 6,243,237,225,236,108,128,247, 38,243,
- 241,245,225,242,101,128, 51,194,110, 4, 52,178, 52,189, 53, 55,
- 53, 65,226,239,240,239,237,239,230,111,128, 49, 34,103, 4, 52,
- 199, 52,210, 52,224, 53, 47,226,239,240,239,237,239,230,111,128,
- 49, 36,235,232,225,238,235,232,245,244,232,225,105,128, 14, 90,
- 236,101,131, 34, 32, 52,235, 53, 32, 53, 39,226,242,225,227,235,
- 229,116, 2, 52,247, 53, 11,236,229,230,116,129, 48, 8, 53, 0,
- 246,229,242,244,233,227,225,108,128,254, 63,242,233,231,232,116,
- 129, 48, 9, 53, 21,246,229,242,244,233,227,225,108,128,254, 64,
- 236,229,230,116,128, 35, 41,242,233,231,232,116,128, 35, 42,243,
- 244,242,239,109,128, 33, 43,239,244,229,236,229,233, 97,128, 3,
- 135,117, 2, 53, 71, 53, 83,228,225,244,244,225,228,229,246, 97,
- 128, 9, 82,243,246,225,242, 97, 3, 53, 95, 53,105, 53,112,226,
- 229,238,231,225,236,105,128, 9,130,228,229,246, 97,128, 9, 2,
- 231,245,234,225,242,225,244,105,128, 10,130,239,231,239,238,229,
- 107,128, 1, 5,112, 3, 53,140, 53,164, 53,194, 97, 2, 53,146,
- 53,158,225,244,239,243,241,245,225,242,101,128, 51, 0,242,229,
- 110,128, 36,156,239,243,244,242,239,240,232,101, 2, 53,177, 53,
- 188,225,242,237,229,238,233,225,110,128, 5, 90,237,239,100,128,
- 2,188,112, 2, 53,200, 53,205,236,101,128,248,255,242,111, 2,
- 53,212, 53,220,225,227,232,229,115,128, 34, 80,120, 2, 53,226,
- 53,246,229,241,245,225,108,129, 34, 72, 53,236,239,242,233,237,
- 225,231,101,128, 34, 82,233,237,225,244,229,236,249,229,241,245,
- 225,108,128, 34, 69,114, 4, 54, 15, 54, 42, 54, 46, 54, 91,225,
- 229, 97, 2, 54, 23, 54, 33,229,235,239,242,229,225,110,128, 49,
- 142,235,239,242,229,225,110,128, 49,141, 99,128, 35, 18,105, 2,
- 54, 52, 54, 66,231,232,244,232,225,236,230,242,233,238,103,128,
- 30,154,238,103,130, 0,229, 54, 75, 54, 83,225,227,245,244,101,
- 128, 1,251,226,229,236,239,119,128, 30, 1,242,239,119, 8, 54,
- 111, 54,118, 54,247, 55, 57, 55,107, 55,162, 55,185, 56, 4,226,
- 239,244,104,128, 33,148,100, 3, 54,126, 54,165, 54,212,225,243,
- 104, 4, 54,138, 54,145, 54,152, 54,160,228,239,247,110,128, 33,
- 227,236,229,230,116,128, 33,224,242,233,231,232,116,128, 33,226,
- 245,112,128, 33,225,226,108, 5, 54,178, 54,185, 54,192, 54,199,
- 54,207,226,239,244,104,128, 33,212,228,239,247,110,128, 33,211,
- 236,229,230,116,128, 33,208,242,233,231,232,116,128, 33,210,245,
- 112,128, 33,209,239,247,110,131, 33,147, 54,224, 54,231, 54,239,
- 236,229,230,116,128, 33,153,242,233,231,232,116,128, 33,152,247,
- 232,233,244,101,128, 33,233,104, 2, 54,253, 55, 48,229,225,100,
- 4, 55, 9, 55, 19, 55, 29, 55, 40,228,239,247,238,237,239,100,
- 128, 2,197,236,229,230,244,237,239,100,128, 2,194,242,233,231,
- 232,244,237,239,100,128, 2,195,245,240,237,239,100,128, 2,196,
- 239,242,233,250,229,120,128,248,231,236,229,230,116,131, 33,144,
- 55, 70, 55, 87, 55, 99,228,226,108,129, 33,208, 55, 78,243,244,
- 242,239,235,101,128, 33,205,239,246,229,242,242,233,231,232,116,
- 128, 33,198,247,232,233,244,101,128, 33,230,242,233,231,232,116,
- 132, 33,146, 55,123, 55,135, 55,143, 55,154,228,226,236,243,244,
- 242,239,235,101,128, 33,207,232,229,225,246,121,128, 39,158,239,
- 246,229,242,236,229,230,116,128, 33,196,247,232,233,244,101,128,
- 33,232,244,225, 98, 2, 55,170, 55,177,236,229,230,116,128, 33,
- 228,242,233,231,232,116,128, 33,229,245,112,132, 33,145, 55,198,
- 55,226, 55,244, 55,252,100, 2, 55,204, 55,216,110,129, 33,149,
- 55,210,226,243,101,128, 33,168,239,247,238,226,225,243,101,128,
- 33,168,236,229,230,116,129, 33,150, 55,235,239,230,228,239,247,
- 110,128, 33,197,242,233,231,232,116,128, 33,151,247,232,233,244,
- 101,128, 33,231,246,229,242,244,229,120,128,248,230,115, 5, 56,
- 25, 56,101, 56,146, 56,229, 56,239, 99, 2, 56, 31, 56, 83,233,
- 105, 2, 56, 38, 56, 61,227,233,242,227,245,109,129, 0, 94, 56,
- 49,237,239,238,239,243,240,225,227,101,128,255, 62,244,233,236,
- 228,101,129, 0,126, 56, 71,237,239,238,239,243,240,225,227,101,
- 128,255, 94,242,233,240,116,129, 2, 81, 56, 92,244,245,242,238,
- 229,100,128, 2, 82,237,225,236,108, 2, 56,110, 56,121,232,233,
- 242,225,231,225,238, 97,128, 48, 65,235,225,244,225,235,225,238,
- 97,129, 48,161, 56,134,232,225,236,230,247,233,228,244,104,128,
- 255,103,244,229,242,233,115, 2, 56,156, 56,225,107,131, 0, 42,
- 56,166, 56,194, 56,217, 97, 2, 56,172, 56,186,236,244,239,238,
- 229,225,242,225,226,233, 99,128, 6,109,242,225,226,233, 99,128,
- 6,109,109, 2, 56,200, 56,206,225,244,104,128, 34, 23,239,238,
- 239,243,240,225,227,101,128,255, 10,243,237,225,236,108,128,254,
- 97,109,128, 32, 66,245,240,229,242,233,239,114,128,246,233,249,
- 237,240,244,239,244,233,227,225,236,236,249,229,241,245,225,108,
- 128, 34, 67,116,132, 0, 64, 57, 15, 57, 22, 57, 34, 57, 42,233,
- 236,228,101,128, 0,227,237,239,238,239,243,240,225,227,101,128,
- 255, 32,243,237,225,236,108,128,254,107,245,242,238,229,100,128,
- 2, 80,117, 6, 57, 64, 57, 89, 57, 96, 57,121, 57,141, 57,157,
- 98, 2, 57, 70, 57, 79,229,238,231,225,236,105,128, 9,148,239,
- 240,239,237,239,230,111,128, 49, 32,228,229,246, 97,128, 9, 20,
- 231,117, 2, 57,103, 57,112,234,225,242,225,244,105,128, 10,148,
- 242,237,245,235,232,105,128, 10, 20,236,229,238,231,244,232,237,
- 225,242,235,226,229,238,231,225,236,105,128, 9,215,237,225,244,
- 242,225,231,245,242,237,245,235,232,105,128, 10, 76,246,239,247,
- 229,236,243,233,231,110, 3, 57,173, 57,183, 57,190,226,229,238,
- 231,225,236,105,128, 9,204,228,229,246, 97,128, 9, 76,231,245,
- 234,225,242,225,244,105,128, 10,204,246,225,231,242,225,232,225,
- 228,229,246, 97,128, 9, 61,121, 2, 57,221, 57,233,226,225,242,
- 237,229,238,233,225,110,128, 5, 97,233,110,130, 5,226, 57,242,
- 58, 1,225,236,244,239,238,229,232,229,226,242,229,119,128,251,
- 32,232,229,226,242,229,119,128, 5,226, 98,144, 0, 98, 58, 46,
- 58,181, 58,192, 58,201, 58,226, 60, 11, 60, 73, 60,146, 62, 72,
- 62, 84, 62,127, 62,135, 62,145, 64, 15, 64, 39, 64, 48, 97, 7,
- 58, 62, 58, 72, 58, 96, 58,103, 58,128, 58,152, 58,163,226,229,
- 238,231,225,236,105,128, 9,172,227,235,243,236,225,243,104,129,
- 0, 92, 58, 84,237,239,238,239,243,240,225,227,101,128,255, 60,
- 228,229,246, 97,128, 9, 44,231,117, 2, 58,110, 58,119,234,225,
- 242,225,244,105,128, 10,172,242,237,245,235,232,105,128, 10, 44,
- 104, 2, 58,134, 58,144,233,242,225,231,225,238, 97,128, 48,112,
- 244,244,232,225,105,128, 14, 63,235,225,244,225,235,225,238, 97,
- 128, 48,208,114,129, 0,124, 58,169,237,239,238,239,243,240,225,
- 227,101,128,255, 92,226,239,240,239,237,239,230,111,128, 49, 5,
- 227,233,242,227,236,101,128, 36,209,228,239,116, 2, 58,209, 58,
- 218,225,227,227,229,238,116,128, 30, 3,226,229,236,239,119,128,
- 30, 5,101, 6, 58,240, 59, 5, 59, 28, 59,170, 59,181, 59,193,
- 225,237,229,228,243,233,248,244,229,229,238,244,232,238,239,244,
- 229,115,128, 38,108, 99, 2, 59, 11, 59, 18,225,245,243,101,128,
- 34, 53,249,242,233,236,236,233, 99,128, 4, 49,104, 5, 59, 40,
- 59, 49, 59, 63, 59, 93, 59,152,225,242,225,226,233, 99,128, 6,
- 40,230,233,238,225,236,225,242,225,226,233, 99,128,254,144,105,
- 2, 59, 69, 59, 84,238,233,244,233,225,236,225,242,225,226,233,
- 99,128,254,145,242,225,231,225,238, 97,128, 48,121,237,101, 2,
- 59,100, 59,113,228,233,225,236,225,242,225,226,233, 99,128,254,
- 146,229,237,105, 2, 59,121, 59,136,238,233,244,233,225,236,225,
- 242,225,226,233, 99,128,252,159,243,239,236,225,244,229,228,225,
- 242,225,226,233, 99,128,252, 8,238,239,239,238,230,233,238,225,
- 236,225,242,225,226,233, 99,128,252,109,235,225,244,225,235,225,
- 238, 97,128, 48,217,238,225,242,237,229,238,233,225,110,128, 5,
- 98,116,132, 5,209, 59,205, 59,225, 59,245, 59,254, 97,129, 3,
- 178, 59,211,243,249,237,226,239,236,231,242,229,229,107,128, 3,
- 208,228,225,231,229,243,104,129,251, 49, 59,236,232,229,226,242,
- 229,119,128,251, 49,232,229,226,242,229,119,128, 5,209,242,225,
- 230,229,232,229,226,242,229,119,128,251, 76,104, 2, 60, 17, 60,
- 67, 97, 3, 60, 25, 60, 35, 60, 42,226,229,238,231,225,236,105,
- 128, 9,173,228,229,246, 97,128, 9, 45,231,117, 2, 60, 49, 60,
- 58,234,225,242,225,244,105,128, 10,173,242,237,245,235,232,105,
- 128, 10, 45,239,239,107,128, 2, 83,105, 5, 60, 85, 60, 96, 60,
- 107, 60,121, 60,135,232,233,242,225,231,225,238, 97,128, 48,115,
- 235,225,244,225,235,225,238, 97,128, 48,211,236,225,226,233,225,
- 236,227,236,233,227,107,128, 2,152,238,228,233,231,245,242,237,
- 245,235,232,105,128, 10, 2,242,245,243,241,245,225,242,101,128,
- 51, 49,108, 3, 60,154, 62, 55, 62, 66, 97, 2, 60,160, 62, 50,
- 227,107, 6, 60,175, 60,184, 60,221, 61,114, 61,169, 61,221,227,
- 233,242,227,236,101,128, 37,207,100, 2, 60,190, 60,199,233,225,
- 237,239,238,100,128, 37,198,239,247,238,240,239,233,238,244,233,
- 238,231,244,242,233,225,238,231,236,101,128, 37,188,108, 2, 60,
- 227, 61, 74,101, 2, 60,233, 61, 13,230,244,240,239,233,238,244,
- 233,238,103, 2, 60,248, 61, 2,240,239,233,238,244,229,114,128,
- 37,196,244,242,233,225,238,231,236,101,128, 37,192,238,244,233,
- 227,245,236,225,242,226,242,225,227,235,229,116, 2, 61, 33, 61,
- 53,236,229,230,116,129, 48, 16, 61, 42,246,229,242,244,233,227,
- 225,108,128,254, 59,242,233,231,232,116,129, 48, 17, 61, 63,246,
- 229,242,244,233,227,225,108,128,254, 60,239,247,229,114, 2, 61,
- 83, 61, 98,236,229,230,244,244,242,233,225,238,231,236,101,128,
- 37,227,242,233,231,232,244,244,242,233,225,238,231,236,101,128,
- 37,226,114, 2, 61,120, 61,131,229,227,244,225,238,231,236,101,
- 128, 37,172,233,231,232,244,240,239,233,238,244,233,238,103, 2,
- 61,148, 61,158,240,239,233,238,244,229,114,128, 37,186,244,242,
- 233,225,238,231,236,101,128, 37,182,115, 3, 61,177, 61,207, 61,
- 215,109, 2, 61,183, 61,195,225,236,236,243,241,245,225,242,101,
- 128, 37,170,233,236,233,238,231,230,225,227,101,128, 38, 59,241,
- 245,225,242,101,128, 37,160,244,225,114,128, 38, 5,245,240,112,
- 2, 61,229, 62, 11,229,114, 2, 61,236, 61,251,236,229,230,244,
- 244,242,233,225,238,231,236,101,128, 37,228,242,233,231,232,244,
- 244,242,233,225,238,231,236,101,128, 37,229,239,233,238,244,233,
- 238,103, 2, 62, 23, 62, 39,243,237,225,236,236,244,242,233,225,
- 238,231,236,101,128, 37,180,244,242,233,225,238,231,236,101,128,
- 37,178,238,107,128, 36, 35,233,238,229,226,229,236,239,119,128,
- 30, 7,239,227,107,128, 37,136,237,239,238,239,243,240,225,227,
- 101,128,255, 66,111, 3, 62, 92, 62,105, 62,116,226,225,233,237,
- 225,233,244,232,225,105,128, 14, 26,232,233,242,225,231,225,238,
- 97,128, 48,124,235,225,244,225,235,225,238, 97,128, 48,220,240,
- 225,242,229,110,128, 36,157,241,243,241,245,225,242,101,128, 51,
- 195,114, 4, 62,155, 63,149, 63,222, 64, 5,225, 99, 2, 62,162,
- 63, 56,101, 3, 62,170, 62,175, 62,243,229,120,128,248,244,236,
- 229,230,116,133, 0,123, 62,192, 62,197, 62,219, 62,227, 62,232,
- 226,116,128,248,243,109, 2, 62,203, 62,208,233,100,128,248,242,
- 239,238,239,243,240,225,227,101,128,255, 91,243,237,225,236,108,
- 128,254, 91,244,112,128,248,241,246,229,242,244,233,227,225,108,
- 128,254, 55,242,233,231,232,116,133, 0,125, 63, 5, 63, 10, 63,
- 32, 63, 40, 63, 45,226,116,128,248,254,109, 2, 63, 16, 63, 21,
- 233,100,128,248,253,239,238,239,243,240,225,227,101,128,255, 93,
- 243,237,225,236,108,128,254, 92,244,112,128,248,252,246,229,242,
- 244,233,227,225,108,128,254, 56,235,229,116, 2, 63, 64, 63,106,
- 236,229,230,116,132, 0, 91, 63, 79, 63, 84, 63, 89, 63,101,226,
- 116,128,248,240,229,120,128,248,239,237,239,238,239,243,240,225,
- 227,101,128,255, 59,244,112,128,248,238,242,233,231,232,116,132,
- 0, 93, 63,122, 63,127, 63,132, 63,144,226,116,128,248,251,229,
- 120,128,248,250,237,239,238,239,243,240,225,227,101,128,255, 61,
- 244,112,128,248,249,229,246,101,131, 2,216, 63,161, 63,172, 63,
- 178,226,229,236,239,247,227,237, 98,128, 3, 46,227,237, 98,128,
- 3, 6,233,238,246,229,242,244,229,100, 3, 63,193, 63,204, 63,
- 210,226,229,236,239,247,227,237, 98,128, 3, 47,227,237, 98,128,
- 3, 17,228,239,245,226,236,229,227,237, 98,128, 3, 97,233,228,
- 231,101, 2, 63,231, 63,242,226,229,236,239,247,227,237, 98,128,
- 3, 42,233,238,246,229,242,244,229,228,226,229,236,239,247,227,
- 237, 98,128, 3, 58,239,235,229,238,226,225,114,128, 0,166,115,
- 2, 64, 21, 64, 29,244,242,239,235,101,128, 1,128,245,240,229,
- 242,233,239,114,128,246,234,244,239,240,226,225,114,128, 1,131,
- 117, 3, 64, 56, 64, 67, 64, 78,232,233,242,225,231,225,238, 97,
- 128, 48,118,235,225,244,225,235,225,238, 97,128, 48,214,236,108,
- 2, 64, 85, 64,115,229,116,130, 32, 34, 64, 94, 64,104,233,238,
- 246,229,242,243,101,128, 37,216,239,240,229,242,225,244,239,114,
- 128, 34, 25,243,229,249,101,128, 37,206, 99,143, 0, 99, 64,156,
- 65,105, 65,116, 65,180, 65,211, 66, 48, 67,215, 68,199, 69, 43,
- 69, 92, 72, 84, 72, 92, 72,102, 72,114, 72,147, 97, 9, 64,176,
- 64,187, 64,197, 64,204, 64,211, 64,236, 64,246, 65, 42, 65, 51,
- 225,242,237,229,238,233,225,110,128, 5,110,226,229,238,231,225,
- 236,105,128, 9,154,227,245,244,101,128, 1, 7,228,229,246, 97,
- 128, 9, 26,231,117, 2, 64,218, 64,227,234,225,242,225,244,105,
- 128, 10,154,242,237,245,235,232,105,128, 10, 26,236,243,241,245,
- 225,242,101,128, 51,136,238,228,242,225,226,233,238,228,117, 4,
- 65, 8, 65, 18, 65, 24, 65, 31,226,229,238,231,225,236,105,128,
- 9,129,227,237, 98,128, 3, 16,228,229,246, 97,128, 9, 1,231,
- 245,234,225,242,225,244,105,128, 10,129,240,243,236,239,227,107,
- 128, 33,234,114, 3, 65, 59, 65, 65, 65, 91,229,239,102,128, 33,
- 5,239,110,130, 2,199, 65, 74, 65, 85,226,229,236,239,247,227,
- 237, 98,128, 3, 44,227,237, 98,128, 3, 12,242,233,225,231,229,
- 242,229,244,245,242,110,128, 33,181,226,239,240,239,237,239,230,
- 111,128, 49, 24, 99, 4, 65,126, 65,133, 65,152, 65,174,225,242,
- 239,110,128, 1, 13,229,228,233,236,236, 97,129, 0,231, 65,144,
- 225,227,245,244,101,128, 30, 9,233,242, 99, 2, 65,160, 65,165,
- 236,101,128, 36,210,245,237,230,236,229,120,128, 1, 9,245,242,
- 108,128, 2, 85,100, 2, 65,186, 65,202,239,116,129, 1, 11, 65,
- 193,225,227,227,229,238,116,128, 1, 11,243,241,245,225,242,101,
- 128, 51,197,101, 2, 65,217, 65,233,228,233,236,236, 97,129, 0,
- 184, 65,227,227,237, 98,128, 3, 39,238,116,132, 0,162, 65,246,
- 66, 14, 66, 26, 66, 37,105, 2, 65,252, 66, 4,231,242,225,228,
- 101,128, 33, 3,238,230,229,242,233,239,114,128,246,223,237,239,
- 238,239,243,240,225,227,101,128,255,224,239,236,228,243,244,249,
- 236,101,128,247,162,243,245,240,229,242,233,239,114,128,246,224,
- 104, 5, 66, 60, 66,123, 66,134, 67, 62, 67,154, 97, 4, 66, 70,
- 66, 81, 66, 91, 66, 98,225,242,237,229,238,233,225,110,128, 5,
- 121,226,229,238,231,225,236,105,128, 9,155,228,229,246, 97,128,
- 9, 27,231,117, 2, 66,105, 66,114,234,225,242,225,244,105,128,
- 10,155,242,237,245,235,232,105,128, 10, 27,226,239,240,239,237,
- 239,230,111,128, 49, 20,101, 6, 66,148, 66,168, 66,192, 67, 4,
- 67, 16, 67, 37,225,226,235,232,225,243,233,225,238,227,249,242,
- 233,236,236,233, 99,128, 4,189, 99, 2, 66,174, 66,182,235,237,
- 225,242,107,128, 39, 19,249,242,233,236,236,233, 99,128, 4, 71,
- 100, 2, 66,198, 66,242,229,243,227,229,238,228,229,114, 2, 66,
- 211, 66,231,225,226,235,232,225,243,233,225,238,227,249,242,233,
- 236,236,233, 99,128, 4,191,227,249,242,233,236,236,233, 99,128,
- 4,183,233,229,242,229,243,233,243,227,249,242,233,236,236,233,
- 99,128, 4,245,232,225,242,237,229,238,233,225,110,128, 5,115,
- 235,232,225,235,225,243,243,233,225,238,227,249,242,233,236,236,
- 233, 99,128, 4,204,246,229,242,244,233,227,225,236,243,244,242,
- 239,235,229,227,249,242,233,236,236,233, 99,128, 4,185,105,129,
- 3,199, 67, 68,229,245,227,104, 4, 67, 81, 67,116, 67,131, 67,
- 140, 97, 2, 67, 87, 67,102,227,233,242,227,236,229,235,239,242,
- 229,225,110,128, 50,119,240,225,242,229,238,235,239,242,229,225,
- 110,128, 50, 23,227,233,242,227,236,229,235,239,242,229,225,110,
- 128, 50,105,235,239,242,229,225,110,128, 49, 74,240,225,242,229,
- 238,235,239,242,229,225,110,128, 50, 9,111, 2, 67,160, 67,210,
- 227,104, 3, 67,169, 67,191, 67,201,225,110, 2, 67,176, 67,184,
- 231,244,232,225,105,128, 14, 10,244,232,225,105,128, 14, 8,233,
- 238,231,244,232,225,105,128, 14, 9,239,229,244,232,225,105,128,
- 14, 12,239,107,128, 1,136,105, 2, 67,221, 68, 67,229,245, 99,
- 5, 67,235, 68, 14, 68, 29, 68, 38, 68, 52, 97, 2, 67,241, 68,
- 0,227,233,242,227,236,229,235,239,242,229,225,110,128, 50,118,
- 240,225,242,229,238,235,239,242,229,225,110,128, 50, 22,227,233,
- 242,227,236,229,235,239,242,229,225,110,128, 50,104,235,239,242,
- 229,225,110,128, 49, 72,240,225,242,229,238,235,239,242,229,225,
- 110,128, 50, 8,245,240,225,242,229,238,235,239,242,229,225,110,
- 128, 50, 28,242, 99, 2, 68, 74, 68,169,236,101,132, 37,203, 68,
- 87, 68, 98, 68,103, 68,127,237,245,236,244,233,240,236,121,128,
- 34,151,239,116,128, 34,153,112, 2, 68,109, 68,115,236,245,115,
- 128, 34,149,239,243,244,225,236,237,225,242,107,128, 48, 54,247,
- 233,244,104, 2, 68,136, 68,152,236,229,230,244,232,225,236,230,
- 226,236,225,227,107,128, 37,208,242,233,231,232,244,232,225,236,
- 230,226,236,225,227,107,128, 37,209,245,237,230,236,229,120,130,
- 2,198, 68,182, 68,193,226,229,236,239,247,227,237, 98,128, 3,
- 45,227,237, 98,128, 3, 2,108, 3, 68,207, 68,213, 69, 11,229,
- 225,114,128, 35, 39,233,227,107, 4, 68,225, 68,236, 68,245, 68,
- 255,225,236,246,229,239,236,225,114,128, 1,194,228,229,238,244,
- 225,108,128, 1,192,236,225,244,229,242,225,108,128, 1,193,242,
- 229,244,242,239,230,236,229,120,128, 1,195,245, 98,129, 38, 99,
- 69, 18,243,245,233,116, 2, 69, 27, 69, 35,226,236,225,227,107,
- 128, 38, 99,247,232,233,244,101,128, 38,103,109, 3, 69, 51, 69,
- 65, 69, 76,227,245,226,229,228,243,241,245,225,242,101,128, 51,
- 164,239,238,239,243,240,225,227,101,128,255, 67,243,241,245,225,
- 242,229,228,243,241,245,225,242,101,128, 51,160,111, 8, 69,110,
- 69,121, 69,208, 70,150, 71,179, 71,210, 72, 61, 72, 70,225,242,
- 237,229,238,233,225,110,128, 5,129,236,239,110,131, 0, 58, 69,
- 133, 69,158, 69,177,237,239,110, 2, 69,141, 69,149,229,244,225,
- 242,121,128, 32,161,239,243,240,225,227,101,128,255, 26,115, 2,
- 69,164, 69,170,233,231,110,128, 32,161,237,225,236,108,128,254,
- 85,244,242,233,225,238,231,245,236,225,114, 2, 69,192, 69,202,
- 232,225,236,230,237,239,100,128, 2,209,237,239,100,128, 2,208,
- 109, 2, 69,214, 70,143,237, 97,134, 0, 44, 69,231, 70, 39, 70,
- 50, 70, 62, 70, 92, 70,115, 97, 3, 69,239, 70, 9, 70, 17,226,
- 239,246,101, 2, 69,248, 69,254,227,237, 98,128, 3, 19,242,233,
- 231,232,244,227,237, 98,128, 3, 21,227,227,229,238,116,128,246,
- 195,114, 2, 70, 23, 70, 30,225,226,233, 99,128, 6, 12,237,229,
- 238,233,225,110,128, 5, 93,233,238,230,229,242,233,239,114,128,
- 246,225,237,239,238,239,243,240,225,227,101,128,255, 12,242,229,
- 246,229,242,243,229,100, 2, 70, 75, 70, 86,225,226,239,246,229,
- 227,237, 98,128, 3, 20,237,239,100,128, 2,189,115, 2, 70, 98,
- 70,105,237,225,236,108,128,254, 80,245,240,229,242,233,239,114,
- 128,246,226,244,245,242,238,229,100, 2, 70,126, 70,137,225,226,
- 239,246,229,227,237, 98,128, 3, 18,237,239,100,128, 2,187,240,
- 225,243,115,128, 38, 60,110, 2, 70,156, 70,165,231,242,245,229,
- 238,116,128, 34, 69,116, 2, 70,171, 70,185,239,245,242,233,238,
- 244,229,231,242,225,108,128, 34, 46,242,239,108,142, 35, 3, 70,
- 219, 70,225, 70,240, 70,255, 71, 43, 71, 88, 71,102, 71,107, 71,
- 112, 71,117, 71,123, 71,128, 71,169, 71,174,193,195, 75,128, 0,
- 6, 66, 2, 70,231, 70,236,197, 76,128, 0, 7, 83,128, 0, 8,
- 67, 2, 70,246, 70,251,193, 78,128, 0, 24, 82,128, 0, 13, 68,
- 3, 71, 7, 71, 33, 71, 38, 67, 4, 71, 17, 71, 21, 71, 25, 71,
- 29, 49,128, 0, 17, 50,128, 0, 18, 51,128, 0, 19, 52,128, 0,
- 20,197, 76,128, 0,127,204, 69,128, 0, 16, 69, 5, 71, 55, 71,
- 59, 71, 64, 71, 69, 71, 74, 77,128, 0, 25,206, 81,128, 0, 5,
- 207, 84,128, 0, 4,211, 67,128, 0, 27, 84, 2, 71, 80, 71, 84,
- 66,128, 0, 23, 88,128, 0, 3, 70, 2, 71, 94, 71, 98, 70,128,
- 0, 12, 83,128, 0, 28,199, 83,128, 0, 29,200, 84,128, 0, 9,
- 204, 70,128, 0, 10,206,193, 75,128, 0, 21,210, 83,128, 0, 30,
- 83, 5, 71,140, 71,144, 71,154, 71,159, 71,164, 73,128, 0, 15,
- 79,129, 0, 14, 71,150, 84,128, 0, 2,212, 88,128, 0, 1,213,
- 66,128, 0, 26,217, 78,128, 0, 22,213, 83,128, 0, 31,214, 84,
- 128, 0, 11,240,249,242,233,231,232,116,129, 0,169, 71,191,115,
- 2, 71,197, 71,203,225,238,115,128,248,233,229,242,233,102,128,
- 246,217,114, 2, 71,216, 72, 44,238,229,242,226,242,225,227,235,
- 229,116, 2, 71,231, 72, 9,236,229,230,116,130, 48, 12, 71,242,
- 71,254,232,225,236,230,247,233,228,244,104,128,255, 98,246,229,
- 242,244,233,227,225,108,128,254, 65,242,233,231,232,116,130, 48,
- 13, 72, 21, 72, 33,232,225,236,230,247,233,228,244,104,128,255,
- 99,246,229,242,244,233,227,225,108,128,254, 66,240,239,242,225,
- 244,233,239,238,243,241,245,225,242,101,128, 51,127,243,241,245,
- 225,242,101,128, 51,199,246,229,242,235,231,243,241,245,225,242,
- 101,128, 51,198,240,225,242,229,110,128, 36,158,242,245,250,229,
- 233,242,111,128, 32,162,243,244,242,229,244,227,232,229,100,128,
- 2,151,245,114, 2, 72,121, 72,139,236,121, 2, 72,128, 72,134,
- 225,238,100,128, 34,207,239,114,128, 34,206,242,229,238,227,121,
- 128, 0,164,249,114, 4, 72,158, 72,166, 72,173, 72,181,194,242,
- 229,246,101,128,246,209,198,236,229,120,128,246,210,226,242,229,
- 246,101,128,246,212,230,236,229,120,128,246,213,100,146, 0,100,
- 72,228, 74,110, 75,134, 75,194, 76,114, 77, 68, 77,130, 78, 59,
- 78, 72, 78, 81, 78,107, 78,132, 78,141, 79,208, 79,216, 79,227,
- 79,247, 80, 19, 97, 11, 72,252, 73, 7, 73, 17, 73, 89, 73,152,
- 73,163, 73,174, 73,243, 74, 49, 74, 55, 74, 85,225,242,237,229,
- 238,233,225,110,128, 5,100,226,229,238,231,225,236,105,128, 9,
- 166,100, 5, 73, 29, 73, 38, 73, 44, 73, 58, 73, 74,225,242,225,
- 226,233, 99,128, 6, 54,229,246, 97,128, 9, 38,230,233,238,225,
- 236,225,242,225,226,233, 99,128,254,190,233,238,233,244,233,225,
- 236,225,242,225,226,233, 99,128,254,191,237,229,228,233,225,236,
- 225,242,225,226,233, 99,128,254,192,103, 3, 73, 97, 73,114, 73,
- 128,229,243,104,129, 5,188, 73,105,232,229,226,242,229,119,128,
- 5,188,231,229,114,129, 32, 32, 73,122,228,226,108,128, 32, 33,
- 117, 2, 73,134, 73,143,234,225,242,225,244,105,128, 10,166,242,
- 237,245,235,232,105,128, 10, 38,232,233,242,225,231,225,238, 97,
- 128, 48, 96,235,225,244,225,235,225,238, 97,128, 48,192,108, 3,
- 73,182, 73,191, 73,229,225,242,225,226,233, 99,128, 6, 47,229,
- 116,130, 5,211, 73,200, 73,220,228,225,231,229,243,104,129,251,
- 51, 73,211,232,229,226,242,229,119,128,251, 51,232,229,226,242,
- 229,119,128, 5,211,230,233,238,225,236,225,242,225,226,233, 99,
- 128,254,170,237,237, 97, 3, 73,253, 74, 6, 74, 18,225,242,225,
- 226,233, 99,128, 6, 79,236,239,247,225,242,225,226,233, 99,128,
- 6, 79,244,225,238, 97, 2, 74, 27, 74, 41,236,244,239,238,229,
- 225,242,225,226,233, 99,128, 6, 76,242,225,226,233, 99,128, 6,
- 76,238,228, 97,128, 9,100,242,231, 97, 2, 74, 63, 74, 72,232,
- 229,226,242,229,119,128, 5,167,236,229,230,244,232,229,226,242,
- 229,119,128, 5,167,243,233,225,240,238,229,245,237,225,244,225,
- 227,249,242,233,236,236,233,227,227,237, 98,128, 4,133, 98, 3,
- 74,118, 75,115, 75,125,108, 9, 74,138, 74,146, 75, 3, 75, 11,
- 75, 27, 75, 38, 75, 56, 75, 70, 75, 81,199,242,225,246,101,128,
- 246,211, 97, 2, 74,152, 74,209,238,231,236,229,226,242,225,227,
- 235,229,116, 2, 74,168, 74,188,236,229,230,116,129, 48, 10, 74,
- 177,246,229,242,244,233,227,225,108,128,254, 61,242,233,231,232,
- 116,129, 48, 11, 74,198,246,229,242,244,233,227,225,108,128,254,
- 62,114, 2, 74,215, 74,236,227,232,233,238,246,229,242,244,229,
- 228,226,229,236,239,247,227,237, 98,128, 3, 43,242,239,119, 2,
- 74,244, 74,251,236,229,230,116,128, 33,212,242,233,231,232,116,
- 128, 33,210,228,225,238,228, 97,128, 9,101,231,242,225,246,101,
- 129,246,214, 75, 21,227,237, 98,128, 3, 15,233,238,244,229,231,
- 242,225,108,128, 34, 44,236,239,247,236,233,238,101,129, 32, 23,
- 75, 50,227,237, 98,128, 3, 51,239,246,229,242,236,233,238,229,
- 227,237, 98,128, 3, 63,240,242,233,237,229,237,239,100,128, 2,
- 186,246,229,242,244,233,227,225,108, 2, 75, 94, 75,100,226,225,
- 114,128, 32, 22,236,233,238,229,225,226,239,246,229,227,237, 98,
- 128, 3, 14,239,240,239,237,239,230,111,128, 49, 9,243,241,245,
- 225,242,101,128, 51,200, 99, 4, 75,144, 75,151, 75,160, 75,187,
- 225,242,239,110,128, 1, 15,229,228,233,236,236, 97,128, 30, 17,
- 233,242, 99, 2, 75,168, 75,173,236,101,128, 36,211,245,237,230,
- 236,229,248,226,229,236,239,119,128, 30, 19,242,239,225,116,128,
- 1, 17,100, 4, 75,204, 76, 29, 76, 39, 76, 90, 97, 4, 75,214,
- 75,224, 75,231, 76, 0,226,229,238,231,225,236,105,128, 9,161,
- 228,229,246, 97,128, 9, 33,231,117, 2, 75,238, 75,247,234,225,
- 242,225,244,105,128, 10,161,242,237,245,235,232,105,128, 10, 33,
- 108, 2, 76, 6, 76, 15,225,242,225,226,233, 99,128, 6,136,230,
- 233,238,225,236,225,242,225,226,233, 99,128,251,137,228,232,225,
- 228,229,246, 97,128, 9, 92,232, 97, 3, 76, 48, 76, 58, 76, 65,
- 226,229,238,231,225,236,105,128, 9,162,228,229,246, 97,128, 9,
- 34,231,117, 2, 76, 72, 76, 81,234,225,242,225,244,105,128, 10,
- 162,242,237,245,235,232,105,128, 10, 34,239,116, 2, 76, 97, 76,
- 106,225,227,227,229,238,116,128, 30, 11,226,229,236,239,119,128,
- 30, 13,101, 8, 76,132, 76,185, 76,192, 76,217, 76,227, 76,238,
- 77, 27, 77, 63, 99, 2, 76,138, 76,175,233,237,225,236,243,229,
- 240,225,242,225,244,239,114, 2, 76,156, 76,165,225,242,225,226,
- 233, 99,128, 6,107,240,229,242,243,233,225,110,128, 6,107,249,
- 242,233,236,236,233, 99,128, 4, 52,231,242,229,101,128, 0,176,
- 232,105, 2, 76,199, 76,208,232,229,226,242,229,119,128, 5,173,
- 242,225,231,225,238, 97,128, 48,103,233,227,239,240,244,233, 99,
- 128, 3,239,235,225,244,225,235,225,238, 97,128, 48,199,108, 2,
- 76,244, 77, 11,229,244,101, 2, 76,252, 77, 3,236,229,230,116,
- 128, 35, 43,242,233,231,232,116,128, 35, 38,244, 97,129, 3,180,
- 77, 18,244,245,242,238,229,100,128, 1,141,238,239,237,233,238,
- 225,244,239,242,237,233,238,245,243,239,238,229,238,245,237,229,
- 242,225,244,239,242,226,229,238,231,225,236,105,128, 9,248,250,
- 104,128, 2,164,104, 2, 77, 74, 77,124, 97, 3, 77, 82, 77, 92,
- 77, 99,226,229,238,231,225,236,105,128, 9,167,228,229,246, 97,
- 128, 9, 39,231,117, 2, 77,106, 77,115,234,225,242,225,244,105,
- 128, 10,167,242,237,245,235,232,105,128, 10, 39,239,239,107,128,
- 2, 87,105, 6, 77,144, 77,193, 77,253, 78, 8, 78, 19, 78, 29,
- 97, 2, 77,150, 77,172,236,249,244,233,235,225,244,239,238,239,
- 115,129, 3,133, 77,166,227,237, 98,128, 3, 68,237,239,238,100,
- 129, 38,102, 77,181,243,245,233,244,247,232,233,244,101,128, 38,
- 98,229,242,229,243,233,115,133, 0,168, 77,212, 77,220, 77,231,
- 77,237, 77,245,225,227,245,244,101,128,246,215,226,229,236,239,
- 247,227,237, 98,128, 3, 36,227,237, 98,128, 3, 8,231,242,225,
- 246,101,128,246,216,244,239,238,239,115,128, 3,133,232,233,242,
- 225,231,225,238, 97,128, 48, 98,235,225,244,225,235,225,238, 97,
- 128, 48,194,244,244,239,237,225,242,107,128, 48, 3,246,105, 2,
- 78, 36, 78, 47,228,101,129, 0,247, 78, 43,115,128, 34, 35,243,
- 233,239,238,243,236,225,243,104,128, 34, 21,234,229,227,249,242,
- 233,236,236,233, 99,128, 4, 82,235,243,232,225,228,101,128, 37,
- 147,108, 2, 78, 87, 78, 98,233,238,229,226,229,236,239,119,128,
- 30, 15,243,241,245,225,242,101,128, 51,151,109, 2, 78,113, 78,
- 121,225,227,242,239,110,128, 1, 17,239,238,239,243,240,225,227,
- 101,128,255, 68,238,226,236,239,227,107,128, 37,132,111, 10, 78,
- 163, 78,175, 78,185, 78,196, 78,207, 79, 23, 79, 28, 79, 39, 79,
- 154, 79,180,227,232,225,228,225,244,232,225,105,128, 14, 14,228,
- 229,235,244,232,225,105,128, 14, 20,232,233,242,225,231,225,238,
- 97,128, 48,105,235,225,244,225,235,225,238, 97,128, 48,201,236,
- 236,225,114,132, 0, 36, 78,222, 78,233, 78,245, 79, 0,233,238,
- 230,229,242,233,239,114,128,246,227,237,239,238,239,243,240,225,
- 227,101,128,255, 4,239,236,228,243,244,249,236,101,128,247, 36,
- 115, 2, 79, 6, 79, 13,237,225,236,108,128,254,105,245,240,229,
- 242,233,239,114,128,246,228,238,103,128, 32,171,242,245,243,241,
- 245,225,242,101,128, 51, 38,116, 6, 79, 53, 79, 70, 79, 92, 79,
- 103, 79,135, 79,142,225,227,227,229,238,116,129, 2,217, 79, 64,
- 227,237, 98,128, 3, 7,226,229,236,239,247, 99, 2, 79, 81, 79,
- 86,237, 98,128, 3, 35,239,237, 98,128, 3, 35,235,225,244,225,
- 235,225,238, 97,128, 48,251,236,229,243,115, 2, 79,112, 79,116,
- 105,128, 1, 49,106,129,246,190, 79,122,243,244,242,239,235,229,
- 232,239,239,107,128, 2,132,237,225,244,104,128, 34,197,244,229,
- 228,227,233,242,227,236,101,128, 37,204,245,226,236,229,249,239,
- 228,240,225,244,225,104,129,251, 31, 79,171,232,229,226,242,229,
- 119,128,251, 31,247,238,244,225,227,107, 2, 79,191, 79,202,226,
- 229,236,239,247,227,237, 98,128, 3, 30,237,239,100,128, 2,213,
- 240,225,242,229,110,128, 36,159,243,245,240,229,242,233,239,114,
- 128,246,235,116, 2, 79,233, 79,239,225,233,108,128, 2, 86,239,
- 240,226,225,114,128, 1,140,117, 2, 79,253, 80, 8,232,233,242,
- 225,231,225,238, 97,128, 48,101,235,225,244,225,235,225,238, 97,
- 128, 48,197,122,132, 1,243, 80, 31, 80, 40, 80, 59, 80, 96,225,
- 236,244,239,238,101,128, 2,163, 99, 2, 80, 46, 80, 53,225,242,
- 239,110,128, 1,198,245,242,108,128, 2,165,101, 2, 80, 65, 80,
- 85,225,226,235,232,225,243,233,225,238,227,249,242,233,236,236,
- 233, 99,128, 4,225,227,249,242,233,236,236,233, 99,128, 4, 85,
- 232,229,227,249,242,233,236,236,233, 99,128, 4, 95,101,151, 0,
- 101, 80,159, 80,178, 80,212, 81,186, 81,248, 82, 25, 82, 37, 82,
- 60, 82,113, 83,225, 84, 27, 84,129, 84,245, 85,124, 85,199, 85,
- 230, 86, 36, 86, 89, 87, 24, 87,157, 87,177, 87,221, 88, 56, 97,
- 2, 80,165, 80,172,227,245,244,101,128, 0,233,242,244,104,128,
- 38, 65, 98, 3, 80,186, 80,195, 80,205,229,238,231,225,236,105,
- 128, 9,143,239,240,239,237,239,230,111,128, 49, 28,242,229,246,
- 101,128, 1, 21, 99, 5, 80,224, 81, 41, 81, 55, 81, 87, 81,176,
- 97, 2, 80,230, 81, 35,238,228,242, 97, 3, 80,241, 80,248, 81,
- 3,228,229,246, 97,128, 9, 13,231,245,234,225,242,225,244,105,
- 128, 10,141,246,239,247,229,236,243,233,231,110, 2, 81, 17, 81,
- 24,228,229,246, 97,128, 9, 69,231,245,234,225,242,225,244,105,
- 128, 10,197,242,239,110,128, 1, 27,229,228,233,236,236,225,226,
- 242,229,246,101,128, 30, 29,104, 2, 81, 61, 81, 72,225,242,237,
- 229,238,233,225,110,128, 5,101,249,233,247,238,225,242,237,229,
- 238,233,225,110,128, 5,135,233,242, 99, 2, 81, 95, 81,100,236,
- 101,128, 36,212,245,237,230,236,229,120,134, 0,234, 81,121, 81,
- 129, 81,137, 81,148, 81,156, 81,168,225,227,245,244,101,128, 30,
- 191,226,229,236,239,119,128, 30, 25,228,239,244,226,229,236,239,
- 119,128, 30,199,231,242,225,246,101,128, 30,193,232,239,239,235,
- 225,226,239,246,101,128, 30,195,244,233,236,228,101,128, 30,197,
- 249,242,233,236,236,233, 99,128, 4, 84,100, 4, 81,196, 81,206,
- 81,212, 81,222,226,236,231,242,225,246,101,128, 2, 5,229,246,
- 97,128, 9, 15,233,229,242,229,243,233,115,128, 0,235,239,116,
- 130, 1, 23, 81,231, 81,240,225,227,227,229,238,116,128, 1, 23,
- 226,229,236,239,119,128, 30,185,101, 2, 81,254, 82, 9,231,245,
- 242,237,245,235,232,105,128, 10, 15,237,225,244,242,225,231,245,
- 242,237,245,235,232,105,128, 10, 71,230,227,249,242,233,236,236,
- 233, 99,128, 4, 68,103, 2, 82, 43, 82, 50,242,225,246,101,128,
- 0,232,245,234,225,242,225,244,105,128, 10,143,104, 4, 82, 70,
- 82, 81, 82, 92, 82,102,225,242,237,229,238,233,225,110,128, 5,
- 103,226,239,240,239,237,239,230,111,128, 49, 29,233,242,225,231,
- 225,238, 97,128, 48, 72,239,239,235,225,226,239,246,101,128, 30,
- 187,105, 4, 82,123, 82,134, 83,192, 83,207,226,239,240,239,237,
- 239,230,111,128, 49, 31,231,232,116,142, 0, 56, 82,168, 82,177,
- 82,187, 82,217, 82,224, 83, 6, 83, 31, 83, 76, 83,110, 83,122,
- 83,133, 83,166, 83,174, 83,185,225,242,225,226,233, 99,128, 6,
- 104,226,229,238,231,225,236,105,128, 9,238,227,233,242,227,236,
- 101,129, 36,103, 82,198,233,238,246,229,242,243,229,243,225,238,
- 243,243,229,242,233,102,128, 39,145,228,229,246, 97,128, 9,110,
- 229,229,110, 2, 82,232, 82,241,227,233,242,227,236,101,128, 36,
- 113,112, 2, 82,247, 82,254,225,242,229,110,128, 36,133,229,242,
- 233,239,100,128, 36,153,231,117, 2, 83, 13, 83, 22,234,225,242,
- 225,244,105,128, 10,238,242,237,245,235,232,105,128, 10,110,104,
- 2, 83, 37, 83, 63, 97, 2, 83, 43, 83, 54,227,235,225,242,225,
- 226,233, 99,128, 6,104,238,231,250,232,239,117,128, 48, 40,238,
- 239,244,229,226,229,225,237,229,100,128, 38,107,105, 2, 83, 82,
- 83,100,228,229,239,231,242,225,240,232,233,227,240,225,242,229,
- 110,128, 50, 39,238,230,229,242,233,239,114,128, 32,136,237,239,
- 238,239,243,240,225,227,101,128,255, 24,239,236,228,243,244,249,
- 236,101,128,247, 56,112, 2, 83,139, 83,146,225,242,229,110,128,
- 36,123,229,114, 2, 83,153, 83,159,233,239,100,128, 36,143,243,
- 233,225,110,128, 6,248,242,239,237,225,110,128, 33,119,243,245,
- 240,229,242,233,239,114,128, 32,120,244,232,225,105,128, 14, 88,
- 238,246,229,242,244,229,228,226,242,229,246,101,128, 2, 7,239,
- 244,233,230,233,229,228,227,249,242,233,236,236,233, 99,128, 4,
- 101,107, 2, 83,231, 83,255,225,244,225,235,225,238, 97,129, 48,
- 168, 83,243,232,225,236,230,247,233,228,244,104,128,255,116,111,
- 2, 84, 5, 84, 20,238,235,225,242,231,245,242,237,245,235,232,
- 105,128, 10,116,242,229,225,110,128, 49, 84,108, 3, 84, 35, 84,
- 46, 84,107,227,249,242,233,236,236,233, 99,128, 4, 59,101, 2,
- 84, 52, 84, 59,237,229,238,116,128, 34, 8,246,229,110, 3, 84,
- 69, 84, 78, 84, 99,227,233,242,227,236,101,128, 36,106,112, 2,
- 84, 84, 84, 91,225,242,229,110,128, 36,126,229,242,233,239,100,
- 128, 36,146,242,239,237,225,110,128, 33,122,236,233,240,243,233,
- 115,129, 32, 38, 84,118,246,229,242,244,233,227,225,108,128, 34,
- 238,109, 5, 84,141, 84,169, 84,180, 84,200, 84,211,225,227,242,
- 239,110,130, 1, 19, 84,153, 84,161,225,227,245,244,101,128, 30,
- 23,231,242,225,246,101,128, 30, 21,227,249,242,233,236,236,233,
- 99,128, 4, 60,228,225,243,104,129, 32, 20, 84,189,246,229,242,
- 244,233,227,225,108,128,254, 49,239,238,239,243,240,225,227,101,
- 128,255, 69,112, 2, 84,217, 84,237,232,225,243,233,243,237,225,
- 242,235,225,242,237,229,238,233,225,110,128, 5, 91,244,249,243,
- 229,116,128, 34, 5,110, 6, 85, 3, 85, 14, 85, 25, 85, 69, 85,
- 101, 85,116,226,239,240,239,237,239,230,111,128, 49, 35,227,249,
- 242,233,236,236,233, 99,128, 4, 61,100, 2, 85, 31, 85, 50,225,
- 243,104,129, 32, 19, 85, 39,246,229,242,244,233,227,225,108,128,
- 254, 50,229,243,227,229,238,228,229,242,227,249,242,233,236,236,
- 233, 99,128, 4,163,103,130, 1, 75, 85, 77, 85, 88,226,239,240,
- 239,237,239,230,111,128, 49, 37,232,229,227,249,242,233,236,236,
- 233, 99,128, 4,165,232,239,239,235,227,249,242,233,236,236,233,
- 99,128, 4,200,243,240,225,227,101,128, 32, 2,111, 3, 85,132,
- 85,140, 85,149,231,239,238,229,107,128, 1, 25,235,239,242,229,
- 225,110,128, 49, 83,240,229,110,130, 2, 91, 85,159, 85,168,227,
- 236,239,243,229,100,128, 2,154,242,229,246,229,242,243,229,100,
- 130, 2, 92, 85,183, 85,192,227,236,239,243,229,100,128, 2, 94,
- 232,239,239,107,128, 2, 93,112, 2, 85,205, 85,212,225,242,229,
- 110,128, 36,160,243,233,236,239,110,129, 3,181, 85,222,244,239,
- 238,239,115,128, 3,173,241,117, 2, 85,237, 86, 25,225,108,130,
- 0, 61, 85,246, 86, 2,237,239,238,239,243,240,225,227,101,128,
- 255, 29,115, 2, 86, 8, 86, 15,237,225,236,108,128,254,102,245,
- 240,229,242,233,239,114,128, 32,124,233,246,225,236,229,238,227,
- 101,128, 34, 97,114, 3, 86, 44, 86, 55, 86, 66,226,239,240,239,
- 237,239,230,111,128, 49, 38,227,249,242,233,236,236,233, 99,128,
- 4, 64,229,246,229,242,243,229,100,129, 2, 88, 86, 78,227,249,
- 242,233,236,236,233, 99,128, 4, 77,115, 6, 86,103, 86,114, 86,
- 134, 86,215, 87, 4, 87, 14,227,249,242,233,236,236,233, 99,128,
- 4, 65,228,229,243,227,229,238,228,229,242,227,249,242,233,236,
- 236,233, 99,128, 4,171,104,132, 2,131, 86,146, 86,153, 86,184,
- 86,199,227,245,242,108,128, 2,134,239,242,116, 2, 86,161, 86,
- 168,228,229,246, 97,128, 9, 14,246,239,247,229,236,243,233,231,
- 238,228,229,246, 97,128, 9, 70,242,229,246,229,242,243,229,228,
- 236,239,239,112,128, 1,170,243,241,245,225,244,242,229,246,229,
- 242,243,229,100,128, 2,133,237,225,236,108, 2, 86,224, 86,235,
- 232,233,242,225,231,225,238, 97,128, 48, 71,235,225,244,225,235,
- 225,238, 97,129, 48,167, 86,248,232,225,236,230,247,233,228,244,
- 104,128,255,106,244,233,237,225,244,229,100,128, 33, 46,245,240,
- 229,242,233,239,114,128,246,236,116, 5, 87, 36, 87, 62, 87, 66,
- 87, 83, 87,149, 97,130, 3,183, 87, 44, 87, 54,242,237,229,238,
- 233,225,110,128, 5,104,244,239,238,239,115,128, 3,174,104,128,
- 0,240,233,236,228,101,129, 30,189, 87, 75,226,229,236,239,119,
- 128, 30, 27,238,225,232,244, 97, 3, 87, 95, 87,127, 87,136,230,
- 239,245,235,104, 2, 87,105, 87,114,232,229,226,242,229,119,128,
- 5,145,236,229,230,244,232,229,226,242,229,119,128, 5,145,232,
- 229,226,242,229,119,128, 5,145,236,229,230,244,232,229,226,242,
- 229,119,128, 5,145,245,242,238,229,100,128, 1,221,117, 2, 87,
- 163, 87,172,235,239,242,229,225,110,128, 49, 97,242,111,128, 32,
- 172,246,239,247,229,236,243,233,231,110, 3, 87,193, 87,203, 87,
- 210,226,229,238,231,225,236,105,128, 9,199,228,229,246, 97,128,
- 9, 71,231,245,234,225,242,225,244,105,128, 10,199,120, 2, 87,
- 227, 88, 44,227,236,225,109,132, 0, 33, 87,242, 87,253, 88, 24,
- 88, 36,225,242,237,229,238,233,225,110,128, 5, 92,100, 2, 88,
- 3, 88, 8,226,108,128, 32, 60,239,247,110,129, 0,161, 88, 16,
- 243,237,225,236,108,128,247,161,237,239,238,239,243,240,225,227,
- 101,128,255, 1,243,237,225,236,108,128,247, 33,233,243,244,229,
- 238,244,233,225,108,128, 34, 3,250,104,131, 2,146, 88, 67, 88,
- 86, 88, 97, 99, 2, 88, 73, 88, 80,225,242,239,110,128, 1,239,
- 245,242,108,128, 2,147,242,229,246,229,242,243,229,100,128, 1,
- 185,244,225,233,108,128, 1,186,102,140, 0,102, 88,132, 88,214,
- 88,225, 88,234, 88,246, 89, 93, 89,109, 91,117, 91,130, 91,156,
- 93, 33, 93, 41, 97, 4, 88,142, 88,149, 88,160, 88,171,228,229,
- 246, 97,128, 9, 94,231,245,242,237,245,235,232,105,128, 10, 94,
- 232,242,229,238,232,229,233,116,128, 33, 9,244,232, 97, 3, 88,
- 181, 88,190, 88,202,225,242,225,226,233, 99,128, 6, 78,236,239,
- 247,225,242,225,226,233, 99,128, 6, 78,244,225,238,225,242,225,
- 226,233, 99,128, 6, 75,226,239,240,239,237,239,230,111,128, 49,
- 8,227,233,242,227,236,101,128, 36,213,228,239,244,225,227,227,
- 229,238,116,128, 30, 31,101, 3, 88,254, 89, 76, 89, 86,104, 4,
- 89, 8, 89, 31, 89, 45, 89, 61,225,114, 2, 89, 15, 89, 22,225,
- 226,233, 99,128, 6, 65,237,229,238,233,225,110,128, 5,134,230,
- 233,238,225,236,225,242,225,226,233, 99,128,254,210,233,238,233,
- 244,233,225,236,225,242,225,226,233, 99,128,254,211,237,229,228,
- 233,225,236,225,242,225,226,233, 99,128,254,212,233,227,239,240,
- 244,233, 99,128, 3,229,237,225,236,101,128, 38, 64,102,130,251,
- 0, 89,101, 89,105,105,128,251, 3,108,128,251, 4,105,136,251,
- 1, 89,129, 89,169, 89,180, 89,202, 90, 68, 90, 85, 90, 93, 90,
- 106,230,244,229,229,110, 2, 89,139, 89,148,227,233,242,227,236,
- 101,128, 36,110,112, 2, 89,154, 89,161,225,242,229,110,128, 36,
- 130,229,242,233,239,100,128, 36,150,231,245,242,229,228,225,243,
- 104,128, 32, 18,236,236,229,100, 2, 89,189, 89,195,226,239,120,
- 128, 37,160,242,229,227,116,128, 37,172,238,225,108, 5, 89,216,
- 89,255, 90, 16, 90, 33, 90, 49,235,225,102,130, 5,218, 89,226,
- 89,246,228,225,231,229,243,104,129,251, 58, 89,237,232,229,226,
- 242,229,119,128,251, 58,232,229,226,242,229,119,128, 5,218,237,
- 229,109,129, 5,221, 90, 7,232,229,226,242,229,119,128, 5,221,
- 238,245,110,129, 5,223, 90, 24,232,229,226,242,229,119,128, 5,
- 223,240,101,129, 5,227, 90, 40,232,229,226,242,229,119,128, 5,
- 227,244,243,225,228,105,129, 5,229, 90, 59,232,229,226,242,229,
- 119,128, 5,229,242,243,244,244,239,238,229,227,232,233,238,229,
- 243,101,128, 2,201,243,232,229,249,101,128, 37,201,244,225,227,
- 249,242,233,236,236,233, 99,128, 4,115,246,101,142, 0, 53, 90,
- 139, 90,148, 90,158, 90,188, 90,195, 90,205, 90,230, 91, 1, 91,
- 35, 91, 47, 91, 58, 91, 91, 91, 99, 91,110,225,242,225,226,233,
- 99,128, 6,101,226,229,238,231,225,236,105,128, 9,235,227,233,
- 242,227,236,101,129, 36,100, 90,169,233,238,246,229,242,243,229,
- 243,225,238,243,243,229,242,233,102,128, 39,142,228,229,246, 97,
- 128, 9,107,229,233,231,232,244,232,115,128, 33, 93,231,117, 2,
- 90,212, 90,221,234,225,242,225,244,105,128, 10,235,242,237,245,
- 235,232,105,128, 10,107,232, 97, 2, 90,237, 90,248,227,235,225,
- 242,225,226,233, 99,128, 6,101,238,231,250,232,239,117,128, 48,
- 37,105, 2, 91, 7, 91, 25,228,229,239,231,242,225,240,232,233,
- 227,240,225,242,229,110,128, 50, 36,238,230,229,242,233,239,114,
- 128, 32,133,237,239,238,239,243,240,225,227,101,128,255, 21,239,
- 236,228,243,244,249,236,101,128,247, 53,112, 2, 91, 64, 91, 71,
- 225,242,229,110,128, 36,120,229,114, 2, 91, 78, 91, 84,233,239,
- 100,128, 36,140,243,233,225,110,128, 6,245,242,239,237,225,110,
- 128, 33,116,243,245,240,229,242,233,239,114,128, 32,117,244,232,
- 225,105,128, 14, 85,108,129,251, 2, 91,123,239,242,233,110,128,
- 1,146,109, 2, 91,136, 91,147,239,238,239,243,240,225,227,101,
- 128,255, 70,243,241,245,225,242,101,128, 51,153,111, 4, 91,166,
- 91,188, 91,200, 91,207,230, 97, 2, 91,173, 91,181,238,244,232,
- 225,105,128, 14, 31,244,232,225,105,128, 14, 29,238,231,237,225,
- 238,244,232,225,105,128, 14, 79,242,225,236,108,128, 34, 0,245,
- 114,142, 0, 52, 91,240, 91,249, 92, 3, 92, 33, 92, 40, 92, 65,
- 92, 92, 92,126, 92,138, 92,157, 92,168, 92,201, 92,209, 92,220,
- 225,242,225,226,233, 99,128, 6,100,226,229,238,231,225,236,105,
- 128, 9,234,227,233,242,227,236,101,129, 36, 99, 92, 14,233,238,
- 246,229,242,243,229,243,225,238,243,243,229,242,233,102,128, 39,
- 141,228,229,246, 97,128, 9,106,231,117, 2, 92, 47, 92, 56,234,
- 225,242,225,244,105,128, 10,234,242,237,245,235,232,105,128, 10,
- 106,232, 97, 2, 92, 72, 92, 83,227,235,225,242,225,226,233, 99,
- 128, 6,100,238,231,250,232,239,117,128, 48, 36,105, 2, 92, 98,
- 92,116,228,229,239,231,242,225,240,232,233,227,240,225,242,229,
- 110,128, 50, 35,238,230,229,242,233,239,114,128, 32,132,237,239,
- 238,239,243,240,225,227,101,128,255, 20,238,245,237,229,242,225,
- 244,239,242,226,229,238,231,225,236,105,128, 9,247,239,236,228,
- 243,244,249,236,101,128,247, 52,112, 2, 92,174, 92,181,225,242,
- 229,110,128, 36,119,229,114, 2, 92,188, 92,194,233,239,100,128,
- 36,139,243,233,225,110,128, 6,244,242,239,237,225,110,128, 33,
- 115,243,245,240,229,242,233,239,114,128, 32,116,116, 2, 92,226,
- 93, 8,229,229,110, 2, 92,234, 92,243,227,233,242,227,236,101,
- 128, 36,109,112, 2, 92,249, 93, 0,225,242,229,110,128, 36,129,
- 229,242,233,239,100,128, 36,149,104, 2, 93, 14, 93, 19,225,105,
- 128, 14, 84,244,239,238,229,227,232,233,238,229,243,101,128, 2,
- 203,240,225,242,229,110,128, 36,161,242, 97, 2, 93, 48, 93, 56,
- 227,244,233,239,110,128, 32, 68,238, 99,128, 32,163,103,144, 0,
- 103, 93, 97, 94, 43, 94, 66, 94,127, 94,144, 95, 65, 96, 58, 96,
- 143, 96,156, 97, 14, 97, 39, 97, 67, 97, 89, 98, 34, 98, 56, 98,
- 158, 97, 9, 93,117, 93,127, 93,134, 93,141, 93,205, 93,230, 93,
- 241, 93,252, 94, 30,226,229,238,231,225,236,105,128, 9,151,227,
- 245,244,101,128, 1,245,228,229,246, 97,128, 9, 23,102, 4, 93,
- 151, 93,160, 93,174, 93,190,225,242,225,226,233, 99,128, 6,175,
- 230,233,238,225,236,225,242,225,226,233, 99,128,251,147,233,238,
- 233,244,233,225,236,225,242,225,226,233, 99,128,251,148,237,229,
- 228,233,225,236,225,242,225,226,233, 99,128,251,149,231,117, 2,
- 93,212, 93,221,234,225,242,225,244,105,128, 10,151,242,237,245,
- 235,232,105,128, 10, 23,232,233,242,225,231,225,238, 97,128, 48,
- 76,235,225,244,225,235,225,238, 97,128, 48,172,237,237, 97,130,
- 3,179, 94, 6, 94, 19,236,225,244,233,238,243,237,225,236,108,
- 128, 2, 99,243,245,240,229,242,233,239,114,128, 2,224,238,231,
- 233,225,227,239,240,244,233, 99,128, 3,235, 98, 2, 94, 49, 94,
- 59,239,240,239,237,239,230,111,128, 49, 13,242,229,246,101,128,
- 1, 31, 99, 4, 94, 76, 94, 83, 94, 92, 94,114,225,242,239,110,
- 128, 1,231,229,228,233,236,236, 97,128, 1, 35,233,242, 99, 2,
- 94,100, 94,105,236,101,128, 36,214,245,237,230,236,229,120,128,
- 1, 29,239,237,237,225,225,227,227,229,238,116,128, 1, 35,228,
- 239,116,129, 1, 33, 94,135,225,227,227,229,238,116,128, 1, 33,
- 101, 6, 94,158, 94,169, 94,180, 94,191, 94,210, 95, 56,227,249,
- 242,233,236,236,233, 99,128, 4, 51,232,233,242,225,231,225,238,
- 97,128, 48, 82,235,225,244,225,235,225,238, 97,128, 48,178,239,
- 237,229,244,242,233,227,225,236,236,249,229,241,245,225,108,128,
- 34, 81,114, 3, 94,218, 95, 11, 95, 21,229,243,104, 3, 94,228,
- 94,243, 94,252,225,227,227,229,238,244,232,229,226,242,229,119,
- 128, 5,156,232,229,226,242,229,119,128, 5,243,237,245,241,228,
- 225,237,232,229,226,242,229,119,128, 5,157,237,225,238,228,226,
- 236,115,128, 0,223,243,232,225,249,233,109, 2, 95, 32, 95, 47,
- 225,227,227,229,238,244,232,229,226,242,229,119,128, 5,158,232,
- 229,226,242,229,119,128, 5,244,244,225,237,225,242,107,128, 48,
- 19,104, 5, 95, 77, 95,210, 96, 17, 96, 42, 96, 48, 97, 4, 95,
- 87, 95, 97, 95,120, 95,145,226,229,238,231,225,236,105,128, 9,
- 152,100, 2, 95,103, 95,114,225,242,237,229,238,233,225,110,128,
- 5,114,229,246, 97,128, 9, 24,231,117, 2, 95,127, 95,136,234,
- 225,242,225,244,105,128, 10,152,242,237,245,235,232,105,128, 10,
- 24,233,110, 4, 95,156, 95,165, 95,179, 95,195,225,242,225,226,
- 233, 99,128, 6, 58,230,233,238,225,236,225,242,225,226,233, 99,
- 128,254,206,233,238,233,244,233,225,236,225,242,225,226,233, 99,
- 128,254,207,237,229,228,233,225,236,225,242,225,226,233, 99,128,
- 254,208,101, 3, 95,218, 95,239, 96, 0,237,233,228,228,236,229,
- 232,239,239,235,227,249,242,233,236,236,233, 99,128, 4,149,243,
- 244,242,239,235,229,227,249,242,233,236,236,233, 99,128, 4,147,
- 245,240,244,245,242,238,227,249,242,233,236,236,233, 99,128, 4,
- 145,232, 97, 2, 96, 24, 96, 31,228,229,246, 97,128, 9, 90,231,
- 245,242,237,245,235,232,105,128, 10, 90,239,239,107,128, 2, 96,
- 250,243,241,245,225,242,101,128, 51,147,105, 3, 96, 66, 96, 77,
- 96, 88,232,233,242,225,231,225,238, 97,128, 48, 78,235,225,244,
- 225,235,225,238, 97,128, 48,174,109, 2, 96, 94, 96,105,225,242,
- 237,229,238,233,225,110,128, 5, 99,229,108,130, 5,210, 96,114,
- 96,134,228,225,231,229,243,104,129,251, 50, 96,125,232,229,226,
- 242,229,119,128,251, 50,232,229,226,242,229,119,128, 5,210,234,
- 229,227,249,242,233,236,236,233, 99,128, 4, 83,236,239,244,244,
- 225,108, 2, 96,167, 96,184,233,238,246,229,242,244,229,228,243,
- 244,242,239,235,101,128, 1,190,243,244,239,112,132, 2,148, 96,
- 199, 96,210, 96,216, 96,248,233,238,246,229,242,244,229,100,128,
- 2,150,237,239,100,128, 2,192,242,229,246,229,242,243,229,100,
- 130, 2,149, 96,231, 96,237,237,239,100,128, 2,193,243,245,240,
- 229,242,233,239,114,128, 2,228,243,244,242,239,235,101,129, 2,
- 161, 97, 3,242,229,246,229,242,243,229,100,128, 2,162,109, 2,
- 97, 20, 97, 28,225,227,242,239,110,128, 30, 33,239,238,239,243,
- 240,225,227,101,128,255, 71,111, 2, 97, 45, 97, 56,232,233,242,
- 225,231,225,238, 97,128, 48, 84,235,225,244,225,235,225,238, 97,
- 128, 48,180,240, 97, 2, 97, 74, 97, 80,242,229,110,128, 36,162,
- 243,241,245,225,242,101,128, 51,172,114, 2, 97, 95, 97,192, 97,
- 2, 97,101, 97,109,228,233,229,238,116,128, 34, 7,246,101,134,
- 0, 96, 97,126, 97,137, 97,154, 97,161, 97,170, 97,182,226,229,
- 236,239,247,227,237, 98,128, 3, 22, 99, 2, 97,143, 97,148,237,
- 98,128, 3, 0,239,237, 98,128, 3, 0,228,229,246, 97,128, 9,
- 83,236,239,247,237,239,100,128, 2,206,237,239,238,239,243,240,
- 225,227,101,128,255, 64,244,239,238,229,227,237, 98,128, 3, 64,
- 229,225,244,229,114,132, 0, 62, 97,208, 97,227, 97,239, 98, 26,
- 229,241,245,225,108,129, 34,101, 97,218,239,242,236,229,243,115,
- 128, 34,219,237,239,238,239,243,240,225,227,101,128,255, 30,111,
- 2, 97,245, 98, 15,114, 2, 97,251, 98, 8,229,241,245,233,246,
- 225,236,229,238,116,128, 34,115,236,229,243,115,128, 34,119,246,
- 229,242,229,241,245,225,108,128, 34,103,243,237,225,236,108,128,
- 254,101,115, 2, 98, 40, 98, 48,227,242,233,240,116,128, 2, 97,
- 244,242,239,235,101,128, 1,229,117, 4, 98, 66, 98, 77, 98,134,
- 98,145,232,233,242,225,231,225,238, 97,128, 48, 80,233,108, 2,
- 98, 84, 98,109,236,229,237,239,116, 2, 98, 94, 98,101,236,229,
- 230,116,128, 0,171,242,233,231,232,116,128, 0,187,243,233,238,
- 231,108, 2, 98,119, 98,126,236,229,230,116,128, 32, 57,242,233,
- 231,232,116,128, 32, 58,235,225,244,225,235,225,238, 97,128, 48,
- 176,242,225,237,245,243,241,245,225,242,101,128, 51, 24,249,243,
- 241,245,225,242,101,128, 51,201,104,144, 0,104, 98,204,101, 90,
- 101,125,101,162,101,202,103, 90,103,110,104, 75,104, 87,104, 99,
- 105,167,105,175,105,186,105,195,106, 19,106, 23, 97, 13, 98,232,
- 99, 15, 99, 25, 99, 55, 99, 80, 99,158, 99,170, 99,195, 99,210,
- 99,239, 99,252,100, 54,100, 63, 97, 2, 98,238, 99, 1,226,235,
- 232,225,243,233,225,238,227,249,242,233,236,236,233, 99,128, 4,
- 169,236,244,239,238,229,225,242,225,226,233, 99,128, 6,193,226,
- 229,238,231,225,236,105,128, 9,185,228,101, 2, 99, 32, 99, 50,
- 243,227,229,238,228,229,242,227,249,242,233,236,236,233, 99,128,
- 4,179,246, 97,128, 9, 57,231,117, 2, 99, 62, 99, 71,234,225,
- 242,225,244,105,128, 10,185,242,237,245,235,232,105,128, 10, 57,
- 104, 4, 99, 90, 99, 99, 99,113, 99,143,225,242,225,226,233, 99,
- 128, 6, 45,230,233,238,225,236,225,242,225,226,233, 99,128,254,
- 162,105, 2, 99,119, 99,134,238,233,244,233,225,236,225,242,225,
- 226,233, 99,128,254,163,242,225,231,225,238, 97,128, 48,111,237,
- 229,228,233,225,236,225,242,225,226,233, 99,128,254,164,233,244,
- 245,243,241,245,225,242,101,128, 51, 42,235,225,244,225,235,225,
- 238, 97,129, 48,207, 99,183,232,225,236,230,247,233,228,244,104,
- 128,255,138,236,225,238,244,231,245,242,237,245,235,232,105,128,
- 10, 77,237,250, 97, 2, 99,218, 99,227,225,242,225,226,233, 99,
- 128, 6, 33,236,239,247,225,242,225,226,233, 99,128, 6, 33,238,
- 231,245,236,230,233,236,236,229,114,128, 49,100,114, 2,100, 2,
- 100, 18,228,243,233,231,238,227,249,242,233,236,236,233, 99,128,
- 4, 74,240,239,239,110, 2,100, 27,100, 40,236,229,230,244,226,
- 225,242,226,245,112,128, 33,188,242,233,231,232,244,226,225,242,
- 226,245,112,128, 33,192,243,241,245,225,242,101,128, 51,202,244,
- 225,102, 3,100, 73,100,165,101, 0,240,225,244,225,104,134, 5,
- 178,100, 93,100, 98,100,112,100,121,100,136,100,152,177, 54,128,
- 5,178, 50, 2,100,104,100,108, 51,128, 5,178,102,128, 5,178,
- 232,229,226,242,229,119,128, 5,178,238,225,242,242,239,247,232,
- 229,226,242,229,119,128, 5,178,241,245,225,242,244,229,242,232,
- 229,226,242,229,119,128, 5,178,247,233,228,229,232,229,226,242,
- 229,119,128, 5,178,241,225,237,225,244,115,135, 5,179,100,188,
- 100,193,100,198,100,203,100,212,100,227,100,243,177, 98,128, 5,
- 179,178, 56,128, 5,179,179, 52,128, 5,179,232,229,226,242,229,
- 119,128, 5,179,238,225,242,242,239,247,232,229,226,242,229,119,
- 128, 5,179,241,245,225,242,244,229,242,232,229,226,242,229,119,
- 128, 5,179,247,233,228,229,232,229,226,242,229,119,128, 5,179,
- 243,229,231,239,108,135, 5,177,101, 22,101, 27,101, 32,101, 37,
- 101, 46,101, 61,101, 77,177, 55,128, 5,177,178, 52,128, 5,177,
- 179, 48,128, 5,177,232,229,226,242,229,119,128, 5,177,238,225,
- 242,242,239,247,232,229,226,242,229,119,128, 5,177,241,245,225,
- 242,244,229,242,232,229,226,242,229,119,128, 5,177,247,233,228,
- 229,232,229,226,242,229,119,128, 5,177, 98, 3,101, 98,101,103,
- 101,113,225,114,128, 1, 39,239,240,239,237,239,230,111,128, 49,
- 15,242,229,246,229,226,229,236,239,119,128, 30, 43, 99, 2,101,
- 131,101,140,229,228,233,236,236, 97,128, 30, 41,233,242, 99, 2,
- 101,148,101,153,236,101,128, 36,215,245,237,230,236,229,120,128,
- 1, 37,100, 2,101,168,101,178,233,229,242,229,243,233,115,128,
- 30, 39,239,116, 2,101,185,101,194,225,227,227,229,238,116,128,
- 30, 35,226,229,236,239,119,128, 30, 37,101,136, 5,212,101,222,
- 101,255,102, 19,102,248,103, 8,103, 53,103, 62,103, 75,225,242,
- 116,129, 38,101,101,230,243,245,233,116, 2,101,239,101,247,226,
- 236,225,227,107,128, 38,101,247,232,233,244,101,128, 38, 97,228,
- 225,231,229,243,104,129,251, 52,102, 10,232,229,226,242,229,119,
- 128,251, 52,104, 6,102, 33,102, 61,102, 69,102,119,102,165,102,
- 214, 97, 2,102, 39,102, 53,236,244,239,238,229,225,242,225,226,
- 233, 99,128, 6,193,242,225,226,233, 99,128, 6, 71,229,226,242,
- 229,119,128, 5,212,230,233,238,225,236, 97, 2,102, 80,102,111,
- 236,116, 2,102, 87,102, 99,239,238,229,225,242,225,226,233, 99,
- 128,251,167,244,247,239,225,242,225,226,233, 99,128,254,234,242,
- 225,226,233, 99,128,254,234,232,225,237,250,225,225,226,239,246,
- 101, 2,102,134,102,148,230,233,238,225,236,225,242,225,226,233,
- 99,128,251,165,233,243,239,236,225,244,229,228,225,242,225,226,
- 233, 99,128,251,164,105, 2,102,171,102,205,238,233,244,233,225,
- 236, 97, 2,102,183,102,197,236,244,239,238,229,225,242,225,226,
- 233, 99,128,251,168,242,225,226,233, 99,128,254,235,242,225,231,
- 225,238, 97,128, 48,120,237,229,228,233,225,236, 97, 2,102,226,
- 102,240,236,244,239,238,229,225,242,225,226,233, 99,128,251,169,
- 242,225,226,233, 99,128,254,236,233,243,229,233,229,242,225,243,
- 241,245,225,242,101,128, 51,123,107, 2,103, 14,103, 38,225,244,
- 225,235,225,238, 97,129, 48,216,103, 26,232,225,236,230,247,233,
- 228,244,104,128,255,141,245,244,225,225,242,245,243,241,245,225,
- 242,101,128, 51, 54,238,231,232,239,239,107,128, 2,103,242,245,
- 244,245,243,241,245,225,242,101,128, 51, 57,116,129, 5,215,103,
- 81,232,229,226,242,229,119,128, 5,215,232,239,239,107,129, 2,
- 102,103, 99,243,245,240,229,242,233,239,114,128, 2,177,105, 4,
- 103,120,103,205,103,216,103,241,229,245,104, 4,103,132,103,167,
- 103,182,103,191, 97, 2,103,138,103,153,227,233,242,227,236,229,
- 235,239,242,229,225,110,128, 50,123,240,225,242,229,238,235,239,
- 242,229,225,110,128, 50, 27,227,233,242,227,236,229,235,239,242,
- 229,225,110,128, 50,109,235,239,242,229,225,110,128, 49, 78,240,
- 225,242,229,238,235,239,242,229,225,110,128, 50, 13,232,233,242,
- 225,231,225,238, 97,128, 48,114,235,225,244,225,235,225,238, 97,
- 129, 48,210,103,229,232,225,236,230,247,233,228,244,104,128,255,
- 139,242,233,113,134, 5,180,104, 3,104, 8,104, 22,104, 31,104,
- 46,104, 62,177, 52,128, 5,180, 50, 2,104, 14,104, 18, 49,128,
- 5,180,100,128, 5,180,232,229,226,242,229,119,128, 5,180,238,
- 225,242,242,239,247,232,229,226,242,229,119,128, 5,180,241,245,
- 225,242,244,229,242,232,229,226,242,229,119,128, 5,180,247,233,
- 228,229,232,229,226,242,229,119,128, 5,180,236,233,238,229,226,
- 229,236,239,119,128, 30,150,237,239,238,239,243,240,225,227,101,
- 128,255, 72,111, 9,104,119,104,130,104,154,104,179,105, 11,105,
- 24,105,110,105,150,105,161,225,242,237,229,238,233,225,110,128,
- 5,112,232,105, 2,104,137,104,145,240,244,232,225,105,128, 14,
- 43,242,225,231,225,238, 97,128, 48,123,235,225,244,225,235,225,
- 238, 97,129, 48,219,104,167,232,225,236,230,247,233,228,244,104,
- 128,255,142,236,225,109,135, 5,185,104,199,104,204,104,209,104,
- 214,104,223,104,238,104,254,177, 57,128, 5,185,178, 54,128, 5,
- 185,179, 50,128, 5,185,232,229,226,242,229,119,128, 5,185,238,
- 225,242,242,239,247,232,229,226,242,229,119,128, 5,185,241,245,
- 225,242,244,229,242,232,229,226,242,229,119,128, 5,185,247,233,
- 228,229,232,229,226,242,229,119,128, 5,185,238,239,235,232,245,
- 235,244,232,225,105,128, 14, 46,111, 2,105, 30,105,100,107, 4,
- 105, 40,105, 52,105, 58,105, 80,225,226,239,246,229,227,239,237,
- 98,128, 3, 9,227,237, 98,128, 3, 9,240,225,236,225,244,225,
- 236,233,250,229,228,226,229,236,239,247,227,237, 98,128, 3, 33,
- 242,229,244,242,239,230,236,229,248,226,229,236,239,247,227,237,
- 98,128, 3, 34,238,243,241,245,225,242,101,128, 51, 66,114, 2,
- 105,116,105,143,105, 2,105,122,105,131,227,239,240,244,233, 99,
- 128, 3,233,250,239,238,244,225,236,226,225,114,128, 32, 21,238,
- 227,237, 98,128, 3, 27,244,243,240,242,233,238,231,115,128, 38,
- 104,245,243,101,128, 35, 2,240,225,242,229,110,128, 36,163,243,
- 245,240,229,242,233,239,114,128, 2,176,244,245,242,238,229,100,
- 128, 2,101,117, 4,105,205,105,216,105,229,105,254,232,233,242,
- 225,231,225,238, 97,128, 48,117,233,233,244,239,243,241,245,225,
- 242,101,128, 51, 51,235,225,244,225,235,225,238, 97,129, 48,213,
- 105,242,232,225,236,230,247,233,228,244,104,128,255,140,238,231,
- 225,242,245,237,236,225,245,116,129, 2,221,106, 13,227,237, 98,
- 128, 3, 11,118,128, 1,149,249,240,232,229,110,132, 0, 45,106,
- 39,106, 50,106, 62,106, 85,233,238,230,229,242,233,239,114,128,
- 246,229,237,239,238,239,243,240,225,227,101,128,255, 13,115, 2,
- 106, 68,106, 75,237,225,236,108,128,254, 99,245,240,229,242,233,
- 239,114,128,246,230,244,247,111,128, 32, 16,105,149, 0,105,106,
- 137,106,160,106,194,106,241,110,123,110,243,111, 24,111, 51,111,
- 213,111,217,111,255,112, 21,112,105,113, 14,113, 89,113, 97,113,
- 110,113,197,113,254,114, 26,114, 70,225, 99, 2,106,144,106,150,
- 245,244,101,128, 0,237,249,242,233,236,236,233, 99,128, 4, 79,
- 98, 3,106,168,106,177,106,187,229,238,231,225,236,105,128, 9,
- 135,239,240,239,237,239,230,111,128, 49, 39,242,229,246,101,128,
- 1, 45, 99, 3,106,202,106,209,106,231,225,242,239,110,128, 1,
- 208,233,242, 99, 2,106,217,106,222,236,101,128, 36,216,245,237,
- 230,236,229,120,128, 0,238,249,242,233,236,236,233, 99,128, 4,
- 86,100, 4,106,251,107, 5,110, 80,110,113,226,236,231,242,225,
- 246,101,128, 2, 9,101, 2,107, 11,110, 75,239,231,242,225,240,
- 104, 7,107, 32,107, 46,107, 59,109,244,110, 19,110, 32,110, 44,
- 229,225,242,244,232,227,233,242,227,236,101,128, 50,143,230,233,
- 242,229,227,233,242,227,236,101,128, 50,139,233, 99, 14,107, 90,
- 107,106,107,205,108, 3,108, 69,108, 98,108,114,108,171,108,220,
- 108,232,109, 3,109, 70,109,208,109,237,225,236,236,233,225,238,
- 227,229,240,225,242,229,110,128, 50, 63, 99, 4,107,116,107,127,
- 107,141,107,148,225,236,236,240,225,242,229,110,128, 50, 58,229,
- 238,244,242,229,227,233,242,227,236,101,128, 50,165,236,239,243,
- 101,128, 48, 6,111, 3,107,156,107,171,107,191,237,237, 97,129,
- 48, 1,107,164,236,229,230,116,128,255,100,238,231,242,225,244,
- 245,236,225,244,233,239,238,240,225,242,229,110,128, 50, 55,242,
- 242,229,227,244,227,233,242,227,236,101,128, 50,163,101, 3,107,
- 213,107,225,107,242,225,242,244,232,240,225,242,229,110,128, 50,
- 47,238,244,229,242,240,242,233,243,229,240,225,242,229,110,128,
- 50, 61,248,227,229,236,236,229,238,244,227,233,242,227,236,101,
- 128, 50,157,102, 2,108, 9,108, 24,229,243,244,233,246,225,236,
- 240,225,242,229,110,128, 50, 64,105, 2,108, 30,108, 59,238,225,
- 238,227,233,225,108, 2,108, 42,108, 51,227,233,242,227,236,101,
- 128, 50,150,240,225,242,229,110,128, 50, 54,242,229,240,225,242,
- 229,110,128, 50, 43,104, 2,108, 75,108, 86,225,246,229,240,225,
- 242,229,110,128, 50, 50,233,231,232,227,233,242,227,236,101,128,
- 50,164,233,244,229,242,225,244,233,239,238,237,225,242,107,128,
- 48, 5,108, 3,108,122,108,148,108,160,225,226,239,114, 2,108,
- 131,108,140,227,233,242,227,236,101,128, 50,152,240,225,242,229,
- 110,128, 50, 56,229,230,244,227,233,242,227,236,101,128, 50,167,
- 239,247,227,233,242,227,236,101,128, 50,166,109, 2,108,177,108,
- 209,101, 2,108,183,108,198,228,233,227,233,238,229,227,233,242,
- 227,236,101,128, 50,169,244,225,236,240,225,242,229,110,128, 50,
- 46,239,239,238,240,225,242,229,110,128, 50, 42,238,225,237,229,
- 240,225,242,229,110,128, 50, 52,112, 2,108,238,108,246,229,242,
- 233,239,100,128, 48, 2,242,233,238,244,227,233,242,227,236,101,
- 128, 50,158,114, 2,109, 9,109, 57,101, 3,109, 17,109, 28,109,
- 43,225,227,232,240,225,242,229,110,128, 50, 67,240,242,229,243,
- 229,238,244,240,225,242,229,110,128, 50, 57,243,239,245,242,227,
- 229,240,225,242,229,110,128, 50, 62,233,231,232,244,227,233,242,
- 227,236,101,128, 50,168,115, 5,109, 82,109,111,109,125,109,150,
- 109,178,101, 2,109, 88,109,101,227,242,229,244,227,233,242,227,
- 236,101,128, 50,153,236,230,240,225,242,229,110,128, 50, 66,239,
- 227,233,229,244,249,240,225,242,229,110,128, 50, 51,112, 2,109,
- 131,109,137,225,227,101,128, 48, 0,229,227,233,225,236,240,225,
- 242,229,110,128, 50, 53,116, 2,109,156,109,167,239,227,235,240,
- 225,242,229,110,128, 50, 49,245,228,249,240,225,242,229,110,128,
- 50, 59,117, 2,109,184,109,193,238,240,225,242,229,110,128, 50,
- 48,240,229,242,246,233,243,229,240,225,242,229,110,128, 50, 60,
- 119, 2,109,214,109,226,225,244,229,242,240,225,242,229,110,128,
- 50, 44,239,239,228,240,225,242,229,110,128, 50, 45,250,229,242,
- 111,128, 48, 7,109, 2,109,250,110, 7,229,244,225,236,227,233,
- 242,227,236,101,128, 50,142,239,239,238,227,233,242,227,236,101,
- 128, 50,138,238,225,237,229,227,233,242,227,236,101,128, 50,148,
- 243,245,238,227,233,242,227,236,101,128, 50,144,119, 2,110, 50,
- 110, 63,225,244,229,242,227,233,242,227,236,101,128, 50,140,239,
- 239,228,227,233,242,227,236,101,128, 50,141,246, 97,128, 9, 7,
- 233,229,242,229,243,233,115,130, 0,239,110, 94,110,102,225,227,
- 245,244,101,128, 30, 47,227,249,242,233,236,236,233, 99,128, 4,
- 229,239,244,226,229,236,239,119,128, 30,203,101, 3,110,131,110,
- 147,110,158,226,242,229,246,229,227,249,242,233,236,236,233, 99,
- 128, 4,215,227,249,242,233,236,236,233, 99,128, 4, 53,245,238,
- 103, 4,110,170,110,205,110,220,110,229, 97, 2,110,176,110,191,
- 227,233,242,227,236,229,235,239,242,229,225,110,128, 50,117,240,
- 225,242,229,238,235,239,242,229,225,110,128, 50, 21,227,233,242,
- 227,236,229,235,239,242,229,225,110,128, 50,103,235,239,242,229,
- 225,110,128, 49, 71,240,225,242,229,238,235,239,242,229,225,110,
- 128, 50, 7,103, 2,110,249,111, 0,242,225,246,101,128, 0,236,
- 117, 2,111, 6,111, 15,234,225,242,225,244,105,128, 10,135,242,
- 237,245,235,232,105,128, 10, 7,104, 2,111, 30,111, 40,233,242,
- 225,231,225,238, 97,128, 48, 68,239,239,235,225,226,239,246,101,
- 128, 30,201,105, 8,111, 69,111, 79,111, 90,111, 97,111,122,111,
- 138,111,153,111,169,226,229,238,231,225,236,105,128, 9,136,227,
- 249,242,233,236,236,233, 99,128, 4, 56,228,229,246, 97,128, 9,
- 8,231,117, 2,111,104,111,113,234,225,242,225,244,105,128, 10,
- 136,242,237,245,235,232,105,128, 10, 8,237,225,244,242,225,231,
- 245,242,237,245,235,232,105,128, 10, 64,238,246,229,242,244,229,
- 228,226,242,229,246,101,128, 2, 11,243,232,239,242,244,227,249,
- 242,233,236,236,233, 99,128, 4, 57,246,239,247,229,236,243,233,
- 231,110, 3,111,185,111,195,111,202,226,229,238,231,225,236,105,
- 128, 9,192,228,229,246, 97,128, 9, 64,231,245,234,225,242,225,
- 244,105,128, 10,192,106,128, 1, 51,107, 2,111,223,111,247,225,
- 244,225,235,225,238, 97,129, 48,164,111,235,232,225,236,230,247,
- 233,228,244,104,128,255,114,239,242,229,225,110,128, 49, 99,108,
- 2,112, 5,112, 10,228,101,128, 2,220,245,249,232,229,226,242,
- 229,119,128, 5,172,109, 2,112, 27,112, 94, 97, 3,112, 35,112,
- 55,112, 80,227,242,239,110,129, 1, 43,112, 44,227,249,242,233,
- 236,236,233, 99,128, 4,227,231,229,239,242,225,240,240,242,239,
- 248,233,237,225,244,229,236,249,229,241,245,225,108,128, 34, 83,
- 244,242,225,231,245,242,237,245,235,232,105,128, 10, 63,239,238,
- 239,243,240,225,227,101,128,255, 73,110, 5,112,117,112,127,112,
- 136,112,148,112,232,227,242,229,237,229,238,116,128, 34, 6,230,
- 233,238,233,244,121,128, 34, 30,233,225,242,237,229,238,233,225,
- 110,128, 5,107,116, 2,112,154,112,222,101, 2,112,160,112,211,
- 231,242,225,108,131, 34, 43,112,173,112,191,112,196, 98, 2,112,
- 179,112,187,239,244,244,239,109,128, 35, 33,116,128, 35, 33,229,
- 120,128,248,245,116, 2,112,202,112,207,239,112,128, 35, 32,112,
- 128, 35, 32,242,243,229,227,244,233,239,110,128, 34, 41,233,243,
- 241,245,225,242,101,128, 51, 5,118, 3,112,240,112,249,113, 2,
- 226,245,236,236,229,116,128, 37,216,227,233,242,227,236,101,128,
- 37,217,243,237,233,236,229,230,225,227,101,128, 38, 59,111, 3,
- 113, 22,113, 33,113, 41,227,249,242,233,236,236,233, 99,128, 4,
- 81,231,239,238,229,107,128, 1, 47,244, 97,131, 3,185,113, 52,
- 113, 73,113, 81,228,233,229,242,229,243,233,115,129, 3,202,113,
- 65,244,239,238,239,115,128, 3,144,236,225,244,233,110,128, 2,
- 105,244,239,238,239,115,128, 3,175,240,225,242,229,110,128, 36,
- 164,242,233,231,245,242,237,245,235,232,105,128, 10,114,115, 4,
- 113,120,113,165,113,179,113,187,237,225,236,108, 2,113,129,113,
- 140,232,233,242,225,231,225,238, 97,128, 48, 67,235,225,244,225,
- 235,225,238, 97,129, 48,163,113,153,232,225,236,230,247,233,228,
- 244,104,128,255,104,243,232,225,242,226,229,238,231,225,236,105,
- 128, 9,250,244,242,239,235,101,128, 2,104,245,240,229,242,233,
- 239,114,128,246,237,116, 2,113,203,113,237,229,242,225,244,233,
- 239,110, 2,113,215,113,226,232,233,242,225,231,225,238, 97,128,
- 48,157,235,225,244,225,235,225,238, 97,128, 48,253,233,236,228,
- 101,129, 1, 41,113,246,226,229,236,239,119,128, 30, 45,117, 2,
- 114, 4,114, 15,226,239,240,239,237,239,230,111,128, 49, 41,227,
- 249,242,233,236,236,233, 99,128, 4, 78,246,239,247,229,236,243,
- 233,231,110, 3,114, 42,114, 52,114, 59,226,229,238,231,225,236,
- 105,128, 9,191,228,229,246, 97,128, 9, 63,231,245,234,225,242,
- 225,244,105,128, 10,191,250,232,233,244,243, 97, 2,114, 81,114,
- 92,227,249,242,233,236,236,233, 99,128, 4,117,228,226,236,231,
- 242,225,246,229,227,249,242,233,236,236,233, 99,128, 4,119,106,
- 138, 0,106,114,135,114,198,114,209,115, 3,115, 19,115,132,115,
- 201,115,206,115,218,115,226, 97, 4,114,145,114,156,114,166,114,
- 173,225,242,237,229,238,233,225,110,128, 5,113,226,229,238,231,
- 225,236,105,128, 9,156,228,229,246, 97,128, 9, 28,231,117, 2,
- 114,180,114,189,234,225,242,225,244,105,128, 10,156,242,237,245,
- 235,232,105,128, 10, 28,226,239,240,239,237,239,230,111,128, 49,
- 16, 99, 3,114,217,114,224,114,246,225,242,239,110,128, 1,240,
- 233,242, 99, 2,114,232,114,237,236,101,128, 36,217,245,237,230,
- 236,229,120,128, 1, 53,242,239,243,243,229,228,244,225,233,108,
- 128, 2,157,228,239,244,236,229,243,243,243,244,242,239,235,101,
- 128, 2, 95,101, 3,115, 27,115, 38,115,103,227,249,242,233,236,
- 236,233, 99,128, 4, 88,229,109, 4,115, 49,115, 58,115, 72,115,
- 88,225,242,225,226,233, 99,128, 6, 44,230,233,238,225,236,225,
- 242,225,226,233, 99,128,254,158,233,238,233,244,233,225,236,225,
- 242,225,226,233, 99,128,254,159,237,229,228,233,225,236,225,242,
- 225,226,233, 99,128,254,160,104, 2,115,109,115,118,225,242,225,
- 226,233, 99,128, 6,152,230,233,238,225,236,225,242,225,226,233,
- 99,128,251,139,104, 2,115,138,115,188, 97, 3,115,146,115,156,
- 115,163,226,229,238,231,225,236,105,128, 9,157,228,229,246, 97,
- 128, 9, 29,231,117, 2,115,170,115,179,234,225,242,225,244,105,
- 128, 10,157,242,237,245,235,232,105,128, 10, 29,229,232,225,242,
- 237,229,238,233,225,110,128, 5,123,233,115,128, 48, 4,237,239,
- 238,239,243,240,225,227,101,128,255, 74,240,225,242,229,110,128,
- 36,165,243,245,240,229,242,233,239,114,128, 2,178,107,146, 0,
- 107,116, 21,118,110,118,121,118,183,118,194,119, 28,119, 42,120,
- 150,121, 90,121,103,121,129,121,178,122, 60,122, 82,122, 95,122,
- 118,122,160,122,170, 97, 12,116, 47,116, 79,116,101,116,131,116,
- 245,117, 14,117, 44,117, 69,117,175,117,189,118, 56,118, 85, 98,
- 2,116, 53,116, 70,225,243,232,235,233,242,227,249,242,233,236,
- 236,233, 99,128, 4,161,229,238,231,225,236,105,128, 9,149, 99,
- 2,116, 85,116, 91,245,244,101,128, 30, 49,249,242,233,236,236,
- 233, 99,128, 4, 58,228,101, 2,116,108,116,126,243,227,229,238,
- 228,229,242,227,249,242,233,236,236,233, 99,128, 4,155,246, 97,
- 128, 9, 21,102,135, 5,219,116,149,116,158,116,178,116,192,116,
- 201,116,217,116,232,225,242,225,226,233, 99,128, 6, 67,228,225,
- 231,229,243,104,129,251, 59,116,169,232,229,226,242,229,119,128,
- 251, 59,230,233,238,225,236,225,242,225,226,233, 99,128,254,218,
- 232,229,226,242,229,119,128, 5,219,233,238,233,244,233,225,236,
- 225,242,225,226,233, 99,128,254,219,237,229,228,233,225,236,225,
- 242,225,226,233, 99,128,254,220,242,225,230,229,232,229,226,242,
- 229,119,128,251, 77,231,117, 2,116,252,117, 5,234,225,242,225,
- 244,105,128, 10,149,242,237,245,235,232,105,128, 10, 21,104, 2,
- 117, 20,117, 30,233,242,225,231,225,238, 97,128, 48, 75,239,239,
- 235,227,249,242,233,236,236,233, 99,128, 4,196,235,225,244,225,
- 235,225,238, 97,129, 48,171,117, 57,232,225,236,230,247,233,228,
- 244,104,128,255,118,112, 2,117, 75,117, 96,240, 97,129, 3,186,
- 117, 82,243,249,237,226,239,236,231,242,229,229,107,128, 3,240,
- 249,229,239,245,110, 3,117,108,117,122,117,156,237,233,229,245,
- 237,235,239,242,229,225,110,128, 49,113,112, 2,117,128,117,143,
- 232,233,229,245,240,232,235,239,242,229,225,110,128, 49,132,233,
- 229,245,240,235,239,242,229,225,110,128, 49,120,243,243,225,238,
- 231,240,233,229,245,240,235,239,242,229,225,110,128, 49,121,242,
- 239,242,233,233,243,241,245,225,242,101,128, 51, 13,115, 5,117,
- 201,117,245,118, 4,118, 12,118, 40,232,233,228,225,225,245,244,
- 111, 2,117,214,117,223,225,242,225,226,233, 99,128, 6, 64,238,
- 239,243,233,228,229,226,229,225,242,233,238,231,225,242,225,226,
- 233, 99,128, 6, 64,237,225,236,236,235,225,244,225,235,225,238,
- 97,128, 48,245,241,245,225,242,101,128, 51,132,242, 97, 2,118,
- 19,118, 28,225,242,225,226,233, 99,128, 6, 80,244,225,238,225,
- 242,225,226,233, 99,128, 6, 77,244,242,239,235,229,227,249,242,
- 233,236,236,233, 99,128, 4,159,244,225,232,233,242,225,240,242,
- 239,236,239,238,231,237,225,242,235,232,225,236,230,247,233,228,
- 244,104,128,255,112,246,229,242,244,233,227,225,236,243,244,242,
- 239,235,229,227,249,242,233,236,236,233, 99,128, 4,157,226,239,
- 240,239,237,239,230,111,128, 49, 14, 99, 4,118,131,118,153,118,
- 162,118,170, 97, 2,118,137,118,147,236,243,241,245,225,242,101,
- 128, 51,137,242,239,110,128, 1,233,229,228,233,236,236, 97,128,
- 1, 55,233,242,227,236,101,128, 36,218,239,237,237,225,225,227,
- 227,229,238,116,128, 1, 55,228,239,244,226,229,236,239,119,128,
- 30, 51,101, 4,118,204,118,231,119, 0,119, 12,104, 2,118,210,
- 118,221,225,242,237,229,238,233,225,110,128, 5,132,233,242,225,
- 231,225,238, 97,128, 48, 81,235,225,244,225,235,225,238, 97,129,
- 48,177,118,244,232,225,236,230,247,233,228,244,104,128,255,121,
- 238,225,242,237,229,238,233,225,110,128, 5,111,243,237,225,236,
- 236,235,225,244,225,235,225,238, 97,128, 48,246,231,242,229,229,
- 238,236,225,238,228,233, 99,128, 1, 56,104, 6,119, 56,119,185,
- 119,196,119,221,120, 52,120,140, 97, 5,119, 68,119, 78,119, 89,
- 119, 96,119,121,226,229,238,231,225,236,105,128, 9,150,227,249,
- 242,233,236,236,233, 99,128, 4, 69,228,229,246, 97,128, 9, 22,
- 231,117, 2,119,103,119,112,234,225,242,225,244,105,128, 10,150,
- 242,237,245,235,232,105,128, 10, 22,104, 4,119,131,119,140,119,
- 154,119,170,225,242,225,226,233, 99,128, 6, 46,230,233,238,225,
- 236,225,242,225,226,233, 99,128,254,166,233,238,233,244,233,225,
- 236,225,242,225,226,233, 99,128,254,167,237,229,228,233,225,236,
- 225,242,225,226,233, 99,128,254,168,229,233,227,239,240,244,233,
- 99,128, 3,231,232, 97, 2,119,203,119,210,228,229,246, 97,128,
- 9, 89,231,245,242,237,245,235,232,105,128, 10, 89,233,229,245,
- 235,104, 4,119,235,120, 14,120, 29,120, 38, 97, 2,119,241,120,
- 0,227,233,242,227,236,229,235,239,242,229,225,110,128, 50,120,
- 240,225,242,229,238,235,239,242,229,225,110,128, 50, 24,227,233,
- 242,227,236,229,235,239,242,229,225,110,128, 50,106,235,239,242,
- 229,225,110,128, 49, 75,240,225,242,229,238,235,239,242,229,225,
- 110,128, 50, 10,111, 4,120, 62,120,111,120,121,120,126,235,104,
- 4,120, 73,120, 82,120, 91,120,101,225,233,244,232,225,105,128,
- 14, 2,239,238,244,232,225,105,128, 14, 5,245,225,244,244,232,
- 225,105,128, 14, 3,247,225,233,244,232,225,105,128, 14, 4,237,
- 245,244,244,232,225,105,128, 14, 91,239,107,128, 1,153,242,225,
- 235,232,225,238,231,244,232,225,105,128, 14, 6,250,243,241,245,
- 225,242,101,128, 51,145,105, 4,120,160,120,171,120,196,120,245,
- 232,233,242,225,231,225,238, 97,128, 48, 77,235,225,244,225,235,
- 225,238, 97,129, 48,173,120,184,232,225,236,230,247,233,228,244,
- 104,128,255,119,242,111, 3,120,205,120,220,120,236,231,245,242,
- 225,237,245,243,241,245,225,242,101,128, 51, 21,237,229,229,244,
- 239,242,245,243,241,245,225,242,101,128, 51, 22,243,241,245,225,
- 242,101,128, 51, 20,249,229,239,107, 5,121, 4,121, 39,121, 54,
- 121, 63,121, 77, 97, 2,121, 10,121, 25,227,233,242,227,236,229,
- 235,239,242,229,225,110,128, 50,110,240,225,242,229,238,235,239,
- 242,229,225,110,128, 50, 14,227,233,242,227,236,229,235,239,242,
- 229,225,110,128, 50, 96,235,239,242,229,225,110,128, 49, 49,240,
- 225,242,229,238,235,239,242,229,225,110,128, 50, 0,243,233,239,
- 243,235,239,242,229,225,110,128, 49, 51,234,229,227,249,242,233,
- 236,236,233, 99,128, 4, 92,108, 2,121,109,121,120,233,238,229,
- 226,229,236,239,119,128, 30, 53,243,241,245,225,242,101,128, 51,
- 152,109, 3,121,137,121,151,121,162,227,245,226,229,228,243,241,
- 245,225,242,101,128, 51,166,239,238,239,243,240,225,227,101,128,
- 255, 75,243,241,245,225,242,229,228,243,241,245,225,242,101,128,
- 51,162,111, 5,121,190,121,216,121,254,122, 10,122, 24,104, 2,
- 121,196,121,206,233,242,225,231,225,238, 97,128, 48, 83,237,243,
- 241,245,225,242,101,128, 51,192,235, 97, 2,121,223,121,231,233,
- 244,232,225,105,128, 14, 1,244,225,235,225,238, 97,129, 48,179,
- 121,242,232,225,236,230,247,233,228,244,104,128,255,122,239,240,
- 239,243,241,245,225,242,101,128, 51, 30,240,240,225,227,249,242,
- 233,236,236,233, 99,128, 4,129,114, 2,122, 30,122, 50,229,225,
- 238,243,244,225,238,228,225,242,228,243,249,237,226,239,108,128,
- 50,127,239,238,233,243,227,237, 98,128, 3, 67,240, 97, 2,122,
- 67,122, 73,242,229,110,128, 36,166,243,241,245,225,242,101,128,
- 51,170,243,233,227,249,242,233,236,236,233, 99,128, 4,111,116,
- 2,122,101,122,110,243,241,245,225,242,101,128, 51,207,245,242,
- 238,229,100,128, 2,158,117, 2,122,124,122,135,232,233,242,225,
- 231,225,238, 97,128, 48, 79,235,225,244,225,235,225,238, 97,129,
- 48,175,122,148,232,225,236,230,247,233,228,244,104,128,255,120,
- 246,243,241,245,225,242,101,128, 51,184,247,243,241,245,225,242,
- 101,128, 51,190,108,146, 0,108,122,220,124,247,125, 20,125, 86,
- 125,124,126, 20,126, 29,126, 45,126, 69,126, 87,126,205,126,246,
- 127,125,127,133,127,166,127,175,127,183,127,245, 97, 7,122,236,
- 122,246,122,253,123, 4,123, 29,123, 45,124,235,226,229,238,231,
- 225,236,105,128, 9,178,227,245,244,101,128, 1, 58,228,229,246,
- 97,128, 9, 50,231,117, 2,123, 11,123, 20,234,225,242,225,244,
- 105,128, 10,178,242,237,245,235,232,105,128, 10, 50,235,235,232,
- 225,238,231,249,225,239,244,232,225,105,128, 14, 69,109, 10,123,
- 67,124, 6,124, 23,124, 61,124, 75,124, 94,124,110,124,130,124,
- 150,124,173, 97, 2,123, 73,123,254,236,229,102, 4,123, 85,123,
- 99,123,191,123,208,230,233,238,225,236,225,242,225,226,233, 99,
- 128,254,252,232,225,237,250, 97, 2,123,109,123,150,225,226,239,
- 246,101, 2,123,119,123,133,230,233,238,225,236,225,242,225,226,
- 233, 99,128,254,248,233,243,239,236,225,244,229,228,225,242,225,
- 226,233, 99,128,254,247,226,229,236,239,119, 2,123,160,123,174,
- 230,233,238,225,236,225,242,225,226,233, 99,128,254,250,233,243,
- 239,236,225,244,229,228,225,242,225,226,233, 99,128,254,249,233,
- 243,239,236,225,244,229,228,225,242,225,226,233, 99,128,254,251,
- 237,225,228,228,225,225,226,239,246,101, 2,123,223,123,237,230,
- 233,238,225,236,225,242,225,226,233, 99,128,254,246,233,243,239,
- 236,225,244,229,228,225,242,225,226,233, 99,128,254,245,242,225,
- 226,233, 99,128, 6, 68,226,228, 97,129, 3,187,124, 14,243,244,
- 242,239,235,101,128, 1,155,229,100,130, 5,220,124, 32,124, 52,
- 228,225,231,229,243,104,129,251, 60,124, 43,232,229,226,242,229,
- 119,128,251, 60,232,229,226,242,229,119,128, 5,220,230,233,238,
- 225,236,225,242,225,226,233, 99,128,254,222,232,225,232,233,238,
- 233,244,233,225,236,225,242,225,226,233, 99,128,252,202,233,238,
- 233,244,233,225,236,225,242,225,226,233, 99,128,254,223,234,229,
- 229,237,233,238,233,244,233,225,236,225,242,225,226,233, 99,128,
- 252,201,235,232,225,232,233,238,233,244,233,225,236,225,242,225,
- 226,233, 99,128,252,203,236,225,237,232,229,232,233,243,239,236,
- 225,244,229,228,225,242,225,226,233, 99,128,253,242,237,101, 2,
- 124,180,124,193,228,233,225,236,225,242,225,226,233, 99,128,254,
- 224,229,109, 2,124,200,124,219,232,225,232,233,238,233,244,233,
- 225,236,225,242,225,226,233, 99,128,253,136,233,238,233,244,233,
- 225,236,225,242,225,226,233, 99,128,252,204,242,231,229,227,233,
- 242,227,236,101,128, 37,239, 98, 3,124,255,125, 4,125, 10,225,
- 114,128, 1,154,229,236,116,128, 2,108,239,240,239,237,239,230,
- 111,128, 49, 12, 99, 4,125, 30,125, 37,125, 46,125, 73,225,242,
- 239,110,128, 1, 62,229,228,233,236,236, 97,128, 1, 60,233,242,
- 99, 2,125, 54,125, 59,236,101,128, 36,219,245,237,230,236,229,
- 248,226,229,236,239,119,128, 30, 61,239,237,237,225,225,227,227,
- 229,238,116,128, 1, 60,228,239,116,130, 1, 64,125, 96,125,105,
- 225,227,227,229,238,116,128, 1, 64,226,229,236,239,119,129, 30,
- 55,125,115,237,225,227,242,239,110,128, 30, 57,101, 3,125,132,
- 125,170,126, 15,230,116, 2,125,139,125,155,225,238,231,236,229,
- 225,226,239,246,229,227,237, 98,128, 3, 26,244,225,227,235,226,
- 229,236,239,247,227,237, 98,128, 3, 24,243,115,132, 0, 60,125,
- 183,125,205,125,217,126, 7,229,241,245,225,108,129, 34,100,125,
- 193,239,242,231,242,229,225,244,229,114,128, 34,218,237,239,238,
- 239,243,240,225,227,101,128,255, 28,111, 2,125,223,125,252,114,
- 2,125,229,125,242,229,241,245,233,246,225,236,229,238,116,128,
- 34,114,231,242,229,225,244,229,114,128, 34,118,246,229,242,229,
- 241,245,225,108,128, 34,102,243,237,225,236,108,128,254,100,250,
- 104,128, 2,110,230,226,236,239,227,107,128, 37,140,232,239,239,
- 235,242,229,244,242,239,230,236,229,120,128, 2,109,105, 2,126,
- 51,126, 56,242, 97,128, 32,164,247,238,225,242,237,229,238,233,
- 225,110,128, 5,108,106,129, 1,201,126, 75,229,227,249,242,233,
- 236,236,233, 99,128, 4, 89,108,132,246,192,126, 99,126,123,126,
- 134,126,143, 97, 2,126,105,126,112,228,229,246, 97,128, 9, 51,
- 231,245,234,225,242,225,244,105,128, 10,179,233,238,229,226,229,
- 236,239,119,128, 30, 59,236,225,228,229,246, 97,128, 9, 52,246,
- 239,227,225,236,233, 99, 3,126,157,126,167,126,174,226,229,238,
- 231,225,236,105,128, 9,225,228,229,246, 97,128, 9, 97,246,239,
- 247,229,236,243,233,231,110, 2,126,188,126,198,226,229,238,231,
- 225,236,105,128, 9,227,228,229,246, 97,128, 9, 99,109, 3,126,
- 213,126,226,126,237,233,228,228,236,229,244,233,236,228,101,128,
- 2,107,239,238,239,243,240,225,227,101,128,255, 76,243,241,245,
- 225,242,101,128, 51,208,111, 6,127, 4,127, 16,127, 58,127, 69,
- 127, 75,127,117,227,232,245,236,225,244,232,225,105,128, 14, 44,
- 231,233,227,225,108, 3,127, 28,127, 34,127, 53,225,238,100,128,
- 34, 39,238,239,116,129, 0,172,127, 42,242,229,246,229,242,243,
- 229,100,128, 35, 16,239,114,128, 34, 40,236,233,238,231,244,232,
- 225,105,128, 14, 37,238,231,115,128, 1,127,247,236,233,238,101,
- 2,127, 85,127,108, 99, 2,127, 91,127,103,229,238,244,229,242,
- 236,233,238,101,128,254, 78,237, 98,128, 3, 50,228,225,243,232,
- 229,100,128,254, 77,250,229,238,231,101,128, 37,202,240,225,242,
- 229,110,128, 36,167,115, 3,127,141,127,148,127,156,236,225,243,
- 104,128, 1, 66,241,245,225,242,101,128, 33, 19,245,240,229,242,
- 233,239,114,128,246,238,244,243,232,225,228,101,128, 37,145,245,
- 244,232,225,105,128, 14, 38,246,239,227,225,236,233, 99, 3,127,
- 197,127,207,127,214,226,229,238,231,225,236,105,128, 9,140,228,
- 229,246, 97,128, 9, 12,246,239,247,229,236,243,233,231,110, 2,
- 127,228,127,238,226,229,238,231,225,236,105,128, 9,226,228,229,
- 246, 97,128, 9, 98,248,243,241,245,225,242,101,128, 51,211,109,
- 144, 0,109,128, 35,130,144,130,169,130,196,130,221,132, 18,132,
- 40,133, 95,133,125,133,174,134, 25,134, 47,134, 72,134, 81,135,
- 108,135,136, 97, 12,128, 61,128, 71,128,135,128,142,128,167,128,
- 215,130, 51,130, 76,130, 81,130, 95,130,107,130,112,226,229,238,
- 231,225,236,105,128, 9,174, 99, 2,128, 77,128,129,242,239,110,
- 132, 0,175,128, 91,128,102,128,108,128,117,226,229,236,239,247,
- 227,237, 98,128, 3, 49,227,237, 98,128, 3, 4,236,239,247,237,
- 239,100,128, 2,205,237,239,238,239,243,240,225,227,101,128,255,
- 227,245,244,101,128, 30, 63,228,229,246, 97,128, 9, 46,231,117,
- 2,128,149,128,158,234,225,242,225,244,105,128, 10,174,242,237,
- 245,235,232,105,128, 10, 46,104, 2,128,173,128,205,225,240,225,
- 235,104, 2,128,183,128,192,232,229,226,242,229,119,128, 5,164,
- 236,229,230,244,232,229,226,242,229,119,128, 5,164,233,242,225,
- 231,225,238, 97,128, 48,126,105, 5,128,227,129, 40,129,103,129,
- 133,130, 39,227,232,225,244,244,225,247, 97, 3,128,242,129, 17,
- 129, 24,236,239,119, 2,128,250,129, 5,236,229,230,244,244,232,
- 225,105,128,248,149,242,233,231,232,244,244,232,225,105,128,248,
- 148,244,232,225,105,128, 14, 75,245,240,240,229,242,236,229,230,
- 244,244,232,225,105,128,248,147,229,107, 3,129, 49,129, 80,129,
- 87,236,239,119, 2,129, 57,129, 68,236,229,230,244,244,232,225,
- 105,128,248,140,242,233,231,232,244,244,232,225,105,128,248,139,
- 244,232,225,105,128, 14, 72,245,240,240,229,242,236,229,230,244,
- 244,232,225,105,128,248,138,232,225,238,225,235,225,116, 2,129,
- 115,129,126,236,229,230,244,244,232,225,105,128,248,132,244,232,
- 225,105,128, 14, 49,116, 3,129,141,129,169,129,232,225,233,235,
- 232,117, 2,129,151,129,162,236,229,230,244,244,232,225,105,128,
- 248,137,244,232,225,105,128, 14, 71,232,111, 3,129,178,129,209,
- 129,216,236,239,119, 2,129,186,129,197,236,229,230,244,244,232,
- 225,105,128,248,143,242,233,231,232,244,244,232,225,105,128,248,
- 142,244,232,225,105,128, 14, 73,245,240,240,229,242,236,229,230,
- 244,244,232,225,105,128,248,141,242,105, 3,129,241,130, 16,130,
- 23,236,239,119, 2,129,249,130, 4,236,229,230,244,244,232,225,
- 105,128,248,146,242,233,231,232,244,244,232,225,105,128,248,145,
- 244,232,225,105,128, 14, 74,245,240,240,229,242,236,229,230,244,
- 244,232,225,105,128,248,144,249,225,237,239,235,244,232,225,105,
- 128, 14, 70,235,225,244,225,235,225,238, 97,129, 48,222,130, 64,
- 232,225,236,230,247,233,228,244,104,128,255,143,236,101,128, 38,
- 66,238,243,249,239,238,243,241,245,225,242,101,128, 51, 71,241,
- 225,230,232,229,226,242,229,119,128, 5,190,242,115,128, 38, 66,
- 115, 2,130,118,130,136,239,242,225,227,233,242,227,236,229,232,
- 229,226,242,229,119,128, 5,175,241,245,225,242,101,128, 51,131,
- 98, 2,130,150,130,160,239,240,239,237,239,230,111,128, 49, 7,
- 243,241,245,225,242,101,128, 51,212, 99, 2,130,175,130,183,233,
- 242,227,236,101,128, 36,220,245,226,229,228,243,241,245,225,242,
- 101,128, 51,165,228,239,116, 2,130,204,130,213,225,227,227,229,
- 238,116,128, 30, 65,226,229,236,239,119,128, 30, 67,101, 7,130,
- 237,131,108,131,119,131,134,131,159,131,196,131,208,101, 2,130,
- 243,131, 95,109, 4,130,253,131, 6,131, 20,131, 36,225,242,225,
- 226,233, 99,128, 6, 69,230,233,238,225,236,225,242,225,226,233,
- 99,128,254,226,233,238,233,244,233,225,236,225,242,225,226,233,
- 99,128,254,227,237,101, 2,131, 43,131, 56,228,233,225,236,225,
- 242,225,226,233, 99,128,254,228,229,237,105, 2,131, 64,131, 79,
- 238,233,244,233,225,236,225,242,225,226,233, 99,128,252,209,243,
- 239,236,225,244,229,228,225,242,225,226,233, 99,128,252, 72,244,
- 239,242,245,243,241,245,225,242,101,128, 51, 77,232,233,242,225,
- 231,225,238, 97,128, 48,129,233,250,233,229,242,225,243,241,245,
- 225,242,101,128, 51,126,235,225,244,225,235,225,238, 97,129, 48,
- 225,131,147,232,225,236,230,247,233,228,244,104,128,255,146,109,
- 130, 5,222,131,167,131,187,228,225,231,229,243,104,129,251, 62,
- 131,178,232,229,226,242,229,119,128,251, 62,232,229,226,242,229,
- 119,128, 5,222,238,225,242,237,229,238,233,225,110,128, 5,116,
- 242,235,232, 97, 3,131,219,131,228,132, 5,232,229,226,242,229,
- 119,128, 5,165,235,229,230,245,236, 97, 2,131,239,131,248,232,
- 229,226,242,229,119,128, 5,166,236,229,230,244,232,229,226,242,
- 229,119,128, 5,166,236,229,230,244,232,229,226,242,229,119,128,
- 5,165,104, 2,132, 24,132, 30,239,239,107,128, 2,113,250,243,
- 241,245,225,242,101,128, 51,146,105, 6,132, 54,132, 91,132,228,
- 132,239,133, 8,133, 65,228,100, 2,132, 61,132, 86,236,229,228,
- 239,244,235,225,244,225,235,225,238,225,232,225,236,230,247,233,
- 228,244,104,128,255,101,239,116,128, 0,183,229,245,109, 5,132,
- 105,132,140,132,155,132,164,132,215, 97, 2,132,111,132,126,227,
- 233,242,227,236,229,235,239,242,229,225,110,128, 50,114,240,225,
- 242,229,238,235,239,242,229,225,110,128, 50, 18,227,233,242,227,
- 236,229,235,239,242,229,225,110,128, 50,100,235,239,242,229,225,
- 110,128, 49, 65,112, 2,132,170,132,202, 97, 2,132,176,132,190,
- 238,243,233,239,243,235,239,242,229,225,110,128, 49,112,242,229,
- 238,235,239,242,229,225,110,128, 50, 4,233,229,245,240,235,239,
- 242,229,225,110,128, 49,110,243,233,239,243,235,239,242,229,225,
- 110,128, 49,111,232,233,242,225,231,225,238, 97,128, 48,127,235,
- 225,244,225,235,225,238, 97,129, 48,223,132,252,232,225,236,230,
- 247,233,228,244,104,128,255,144,238,117, 2,133, 15,133, 60,115,
- 132, 34, 18,133, 27,133, 38,133, 47,133, 53,226,229,236,239,247,
- 227,237, 98,128, 3, 32,227,233,242,227,236,101,128, 34,150,237,
- 239,100,128, 2,215,240,236,245,115,128, 34, 19,244,101,128, 32,
- 50,242,105, 2,133, 72,133, 86,226,225,225,242,245,243,241,245,
- 225,242,101,128, 51, 74,243,241,245,225,242,101,128, 51, 73,108,
- 2,133,101,133,116,239,238,231,236,229,231,244,245,242,238,229,
- 100,128, 2,112,243,241,245,225,242,101,128, 51,150,109, 3,133,
- 133,133,147,133,158,227,245,226,229,228,243,241,245,225,242,101,
- 128, 51,163,239,238,239,243,240,225,227,101,128,255, 77,243,241,
- 245,225,242,229,228,243,241,245,225,242,101,128, 51,159,111, 5,
- 133,186,133,212,133,237,133,247,134, 0,104, 2,133,192,133,202,
- 233,242,225,231,225,238, 97,128, 48,130,237,243,241,245,225,242,
- 101,128, 51,193,235,225,244,225,235,225,238, 97,129, 48,226,133,
- 225,232,225,236,230,247,233,228,244,104,128,255,147,236,243,241,
- 245,225,242,101,128, 51,214,237,225,244,232,225,105,128, 14, 33,
- 246,229,242,243,243,241,245,225,242,101,129, 51,167,134, 15,228,
- 243,241,245,225,242,101,128, 51,168,240, 97, 2,134, 32,134, 38,
- 242,229,110,128, 36,168,243,241,245,225,242,101,128, 51,171,115,
- 2,134, 53,134, 62,243,241,245,225,242,101,128, 51,179,245,240,
- 229,242,233,239,114,128,246,239,244,245,242,238,229,100,128, 2,
- 111,117,141, 0,181,134,111,134,115,134,125,134,149,134,159,134,
- 181,134,192,134,217,134,240,134,250,135, 24,135, 88,135, 98, 49,
- 128, 0,181,225,243,241,245,225,242,101,128, 51,130,227,104, 2,
- 134,132,134,142,231,242,229,225,244,229,114,128, 34,107,236,229,
- 243,115,128, 34,106,230,243,241,245,225,242,101,128, 51,140,103,
- 2,134,165,134,172,242,229,229,107,128, 3,188,243,241,245,225,
- 242,101,128, 51,141,232,233,242,225,231,225,238, 97,128, 48,128,
- 235,225,244,225,235,225,238, 97,129, 48,224,134,205,232,225,236,
- 230,247,233,228,244,104,128,255,145,108, 2,134,223,134,232,243,
- 241,245,225,242,101,128, 51,149,244,233,240,236,121,128, 0,215,
- 237,243,241,245,225,242,101,128, 51,155,238,225,104, 2,135, 2,
- 135, 11,232,229,226,242,229,119,128, 5,163,236,229,230,244,232,
- 229,226,242,229,119,128, 5,163,115, 2,135, 30,135, 79,233, 99,
- 3,135, 39,135, 56,135, 67,225,236,238,239,244,101,129, 38,106,
- 135, 50,228,226,108,128, 38,107,230,236,225,244,243,233,231,110,
- 128, 38,109,243,232,225,242,240,243,233,231,110,128, 38,111,243,
- 241,245,225,242,101,128, 51,178,246,243,241,245,225,242,101,128,
- 51,182,247,243,241,245,225,242,101,128, 51,188,118, 2,135,114,
- 135,127,237,229,231,225,243,241,245,225,242,101,128, 51,185,243,
- 241,245,225,242,101,128, 51,183,119, 2,135,142,135,155,237,229,
- 231,225,243,241,245,225,242,101,128, 51,191,243,241,245,225,242,
- 101,128, 51,189,110,150, 0,110,135,212,136, 90,136,114,136,180,
- 136,205,137, 7,137, 17,137, 84,137,127,139,161,139,179,139,204,
- 139,235,140, 5,140, 70,142, 52,142, 60,142, 85,142, 93,143, 61,
- 143, 71,143, 81, 97, 8,135,230,135,250,136, 1,136, 8,136, 33,
- 136, 44,136, 69,136, 81, 98, 2,135,236,135,245,229,238,231,225,
- 236,105,128, 9,168,236, 97,128, 34, 7,227,245,244,101,128, 1,
- 68,228,229,246, 97,128, 9, 40,231,117, 2,136, 15,136, 24,234,
- 225,242,225,244,105,128, 10,168,242,237,245,235,232,105,128, 10,
- 40,232,233,242,225,231,225,238, 97,128, 48,106,235,225,244,225,
- 235,225,238, 97,129, 48,202,136, 57,232,225,236,230,247,233,228,
- 244,104,128,255,133,240,239,243,244,242,239,240,232,101,128, 1,
- 73,243,241,245,225,242,101,128, 51,129, 98, 2,136, 96,136,106,
- 239,240,239,237,239,230,111,128, 49, 11,243,240,225,227,101,128,
- 0,160, 99, 4,136,124,136,131,136,140,136,167,225,242,239,110,
- 128, 1, 72,229,228,233,236,236, 97,128, 1, 70,233,242, 99, 2,
- 136,148,136,153,236,101,128, 36,221,245,237,230,236,229,248,226,
- 229,236,239,119,128, 30, 75,239,237,237,225,225,227,227,229,238,
- 116,128, 1, 70,228,239,116, 2,136,188,136,197,225,227,227,229,
- 238,116,128, 30, 69,226,229,236,239,119,128, 30, 71,101, 3,136,
- 213,136,224,136,249,232,233,242,225,231,225,238, 97,128, 48,109,
- 235,225,244,225,235,225,238, 97,129, 48,205,136,237,232,225,236,
- 230,247,233,228,244,104,128,255,136,247,243,232,229,241,229,236,
- 243,233,231,110,128, 32,170,230,243,241,245,225,242,101,128, 51,
- 139,103, 2,137, 23,137, 73, 97, 3,137, 31,137, 41,137, 48,226,
- 229,238,231,225,236,105,128, 9,153,228,229,246, 97,128, 9, 25,
- 231,117, 2,137, 55,137, 64,234,225,242,225,244,105,128, 10,153,
- 242,237,245,235,232,105,128, 10, 25,239,238,231,245,244,232,225,
- 105,128, 14, 7,104, 2,137, 90,137,100,233,242,225,231,225,238,
- 97,128, 48,147,239,239,107, 2,137,108,137,115,236,229,230,116,
- 128, 2,114,242,229,244,242,239,230,236,229,120,128, 2,115,105,
- 4,137,137,138, 50,138, 61,138,119,229,245,110, 7,137,155,137,
- 190,137,222,137,236,137,245,138, 22,138, 35, 97, 2,137,161,137,
- 176,227,233,242,227,236,229,235,239,242,229,225,110,128, 50,111,
- 240,225,242,229,238,235,239,242,229,225,110,128, 50, 15,227,105,
- 2,137,197,137,209,229,245,227,235,239,242,229,225,110,128, 49,
- 53,242,227,236,229,235,239,242,229,225,110,128, 50, 97,232,233,
- 229,245,232,235,239,242,229,225,110,128, 49, 54,235,239,242,229,
- 225,110,128, 49, 52,240, 97, 2,137,252,138, 10,238,243,233,239,
- 243,235,239,242,229,225,110,128, 49,104,242,229,238,235,239,242,
- 229,225,110,128, 50, 1,243,233,239,243,235,239,242,229,225,110,
- 128, 49,103,244,233,235,229,245,244,235,239,242,229,225,110,128,
- 49,102,232,233,242,225,231,225,238, 97,128, 48,107,107, 2,138,
- 67,138, 91,225,244,225,235,225,238, 97,129, 48,203,138, 79,232,
- 225,236,230,247,233,228,244,104,128,255,134,232,225,232,233,116,
- 2,138,101,138,112,236,229,230,244,244,232,225,105,128,248,153,
- 244,232,225,105,128, 14, 77,238,101,141, 0, 57,138,150,138,159,
- 138,169,138,199,138,206,138,231,139, 2,139, 36,139, 48,139, 59,
- 139, 92,139,100,139,111,225,242,225,226,233, 99,128, 6,105,226,
- 229,238,231,225,236,105,128, 9,239,227,233,242,227,236,101,129,
- 36,104,138,180,233,238,246,229,242,243,229,243,225,238,243,243,
- 229,242,233,102,128, 39,146,228,229,246, 97,128, 9,111,231,117,
- 2,138,213,138,222,234,225,242,225,244,105,128, 10,239,242,237,
- 245,235,232,105,128, 10,111,232, 97, 2,138,238,138,249,227,235,
- 225,242,225,226,233, 99,128, 6,105,238,231,250,232,239,117,128,
- 48, 41,105, 2,139, 8,139, 26,228,229,239,231,242,225,240,232,
- 233,227,240,225,242,229,110,128, 50, 40,238,230,229,242,233,239,
- 114,128, 32,137,237,239,238,239,243,240,225,227,101,128,255, 25,
- 239,236,228,243,244,249,236,101,128,247, 57,112, 2,139, 65,139,
- 72,225,242,229,110,128, 36,124,229,114, 2,139, 79,139, 85,233,
- 239,100,128, 36,144,243,233,225,110,128, 6,249,242,239,237,225,
- 110,128, 33,120,243,245,240,229,242,233,239,114,128, 32,121,116,
- 2,139,117,139,155,229,229,110, 2,139,125,139,134,227,233,242,
- 227,236,101,128, 36,114,112, 2,139,140,139,147,225,242,229,110,
- 128, 36,134,229,242,233,239,100,128, 36,154,232,225,105,128, 14,
- 89,106,129, 1,204,139,167,229,227,249,242,233,236,236,233, 99,
- 128, 4, 90,235,225,244,225,235,225,238, 97,129, 48,243,139,192,
- 232,225,236,230,247,233,228,244,104,128,255,157,108, 2,139,210,
- 139,224,229,231,242,233,231,232,244,236,239,238,103,128, 1,158,
- 233,238,229,226,229,236,239,119,128, 30, 73,109, 2,139,241,139,
- 252,239,238,239,243,240,225,227,101,128,255, 78,243,241,245,225,
- 242,101,128, 51,154,110, 2,140, 11,140, 61, 97, 3,140, 19,140,
- 29,140, 36,226,229,238,231,225,236,105,128, 9,163,228,229,246,
- 97,128, 9, 35,231,117, 2,140, 43,140, 52,234,225,242,225,244,
- 105,128, 10,163,242,237,245,235,232,105,128, 10, 35,238,225,228,
- 229,246, 97,128, 9, 41,111, 6,140, 84,140, 95,140,120,140,161,
- 141,113,142, 40,232,233,242,225,231,225,238, 97,128, 48,110,235,
- 225,244,225,235,225,238, 97,129, 48,206,140,108,232,225,236,230,
- 247,233,228,244,104,128,255,137,110, 3,140,128,140,144,140,153,
- 226,242,229,225,235,233,238,231,243,240,225,227,101,128, 0,160,
- 229,238,244,232,225,105,128, 14, 19,245,244,232,225,105,128, 14,
- 25,239,110, 7,140,178,140,187,140,201,140,235,140,251,141, 36,
- 141, 95,225,242,225,226,233, 99,128, 6, 70,230,233,238,225,236,
- 225,242,225,226,233, 99,128,254,230,231,232,245,238,238, 97, 2,
- 140,212,140,221,225,242,225,226,233, 99,128, 6,186,230,233,238,
- 225,236,225,242,225,226,233, 99,128,251,159,233,238,233,244,233,
- 225,236,225,242,225,226,233, 99,128,254,231,234,229,229,237,105,
- 2,141, 5,141, 20,238,233,244,233,225,236,225,242,225,226,233,
- 99,128,252,210,243,239,236,225,244,229,228,225,242,225,226,233,
- 99,128,252, 75,237,101, 2,141, 43,141, 56,228,233,225,236,225,
- 242,225,226,233, 99,128,254,232,229,237,105, 2,141, 64,141, 79,
- 238,233,244,233,225,236,225,242,225,226,233, 99,128,252,213,243,
- 239,236,225,244,229,228,225,242,225,226,233, 99,128,252, 78,238,
- 239,239,238,230,233,238,225,236,225,242,225,226,233, 99,128,252,
- 141,116, 7,141,129,141,140,141,169,141,204,141,216,141,236,142,
- 6,227,239,238,244,225,233,238,115,128, 34, 12,101, 2,141,146,
- 141,162,236,229,237,229,238,116,129, 34, 9,141,157,239,102,128,
- 34, 9,241,245,225,108,128, 34, 96,231,242,229,225,244,229,114,
- 129, 34,111,141,181,238,239,114, 2,141,189,141,197,229,241,245,
- 225,108,128, 34,113,236,229,243,115,128, 34,121,233,228,229,238,
- 244,233,227,225,108,128, 34, 98,236,229,243,115,129, 34,110,141,
- 225,238,239,242,229,241,245,225,108,128, 34,112,112, 2,141,242,
- 141,252,225,242,225,236,236,229,108,128, 34, 38,242,229,227,229,
- 228,229,115,128, 34,128,243,117, 3,142, 15,142, 22,142, 31,226,
- 243,229,116,128, 34,132,227,227,229,229,228,115,128, 34,129,240,
- 229,242,243,229,116,128, 34,133,247,225,242,237,229,238,233,225,
- 110,128, 5,118,240,225,242,229,110,128, 36,169,115, 2,142, 66,
- 142, 75,243,241,245,225,242,101,128, 51,177,245,240,229,242,233,
- 239,114,128, 32,127,244,233,236,228,101,128, 0,241,117,132, 3,
- 189,142,105,142,116,142,197,143, 24,232,233,242,225,231,225,238,
- 97,128, 48,108,107, 2,142,122,142,146,225,244,225,235,225,238,
- 97,129, 48,204,142,134,232,225,236,230,247,233,228,244,104,128,
- 255,135,244, 97, 3,142,155,142,165,142,172,226,229,238,231,225,
- 236,105,128, 9,188,228,229,246, 97,128, 9, 60,231,117, 2,142,
- 179,142,188,234,225,242,225,244,105,128, 10,188,242,237,245,235,
- 232,105,128, 10, 60,109, 2,142,203,142,237,226,229,242,243,233,
- 231,110,130, 0, 35,142,217,142,229,237,239,238,239,243,240,225,
- 227,101,128,255, 3,243,237,225,236,108,128,254, 95,229,114, 2,
- 142,244,143, 20,225,236,243,233,231,110, 2,142,255,143, 7,231,
- 242,229,229,107,128, 3,116,236,239,247,229,242,231,242,229,229,
- 107,128, 3,117,111,128, 33, 22,110,130, 5,224,143, 32,143, 52,
- 228,225,231,229,243,104,129,251, 64,143, 43,232,229,226,242,229,
- 119,128,251, 64,232,229,226,242,229,119,128, 5,224,246,243,241,
- 245,225,242,101,128, 51,181,247,243,241,245,225,242,101,128, 51,
- 187,249, 97, 3,143, 90,143,100,143,107,226,229,238,231,225,236,
- 105,128, 9,158,228,229,246, 97,128, 9, 30,231,117, 2,143,114,
- 143,123,234,225,242,225,244,105,128, 10,158,242,237,245,235,232,
- 105,128, 10, 30,111,147, 0,111,143,174,143,196,144, 18,144,188,
- 145, 4,145, 19,145, 59,145,182,145,203,145,241,145,252,146,174,
- 148, 8,148, 72,148,105,148,151,149, 24,149, 71,149, 83, 97, 2,
- 143,180,143,187,227,245,244,101,128, 0,243,238,231,244,232,225,
- 105,128, 14, 45, 98, 4,143,206,143,248,144, 1,144, 11,225,242,
- 242,229,100,130, 2,117,143,218,143,229,227,249,242,233,236,236,
- 233, 99,128, 4,233,228,233,229,242,229,243,233,243,227,249,242,
- 233,236,236,233, 99,128, 4,235,229,238,231,225,236,105,128, 9,
- 147,239,240,239,237,239,230,111,128, 49, 27,242,229,246,101,128,
- 1, 79, 99, 3,144, 26,144, 99,144,178, 97, 2,144, 32,144, 93,
- 238,228,242, 97, 3,144, 43,144, 50,144, 61,228,229,246, 97,128,
- 9, 17,231,245,234,225,242,225,244,105,128, 10,145,246,239,247,
- 229,236,243,233,231,110, 2,144, 75,144, 82,228,229,246, 97,128,
- 9, 73,231,245,234,225,242,225,244,105,128, 10,201,242,239,110,
- 128, 1,210,233,242, 99, 2,144,107,144,112,236,101,128, 36,222,
- 245,237,230,236,229,120,133, 0,244,144,131,144,139,144,150,144,
- 158,144,170,225,227,245,244,101,128, 30,209,228,239,244,226,229,
- 236,239,119,128, 30,217,231,242,225,246,101,128, 30,211,232,239,
- 239,235,225,226,239,246,101,128, 30,213,244,233,236,228,101,128,
- 30,215,249,242,233,236,236,233, 99,128, 4, 62,100, 4,144,198,
- 144,221,144,227,144,250,226,108, 2,144,205,144,213,225,227,245,
- 244,101,128, 1, 81,231,242,225,246,101,128, 2, 13,229,246, 97,
- 128, 9, 19,233,229,242,229,243,233,115,129, 0,246,144,239,227,
- 249,242,233,236,236,233, 99,128, 4,231,239,244,226,229,236,239,
- 119,128, 30,205,101,129, 1, 83,145, 10,235,239,242,229,225,110,
- 128, 49, 90,103, 3,145, 27,145, 42,145, 49,239,238,229,107,129,
- 2,219,145, 36,227,237, 98,128, 3, 40,242,225,246,101,128, 0,
- 242,245,234,225,242,225,244,105,128, 10,147,104, 4,145, 69,145,
- 80,145, 90,145,168,225,242,237,229,238,233,225,110,128, 5,133,
- 233,242,225,231,225,238, 97,128, 48, 74,111, 2,145, 96,145,106,
- 239,235,225,226,239,246,101,128, 30,207,242,110,133, 1,161,145,
- 121,145,129,145,140,145,148,145,160,225,227,245,244,101,128, 30,
- 219,228,239,244,226,229,236,239,119,128, 30,227,231,242,225,246,
- 101,128, 30,221,232,239,239,235,225,226,239,246,101,128, 30,223,
- 244,233,236,228,101,128, 30,225,245,238,231,225,242,245,237,236,
- 225,245,116,128, 1, 81,105,129, 1,163,145,188,238,246,229,242,
- 244,229,228,226,242,229,246,101,128, 2, 15,107, 2,145,209,145,
- 233,225,244,225,235,225,238, 97,129, 48,170,145,221,232,225,236,
- 230,247,233,228,244,104,128,255,117,239,242,229,225,110,128, 49,
- 87,236,229,232,229,226,242,229,119,128, 5,171,109, 6,146, 10,
- 146, 38,146, 45,146,134,146,145,146,163,225,227,242,239,110,130,
- 1, 77,146, 22,146, 30,225,227,245,244,101,128, 30, 83,231,242,
- 225,246,101,128, 30, 81,228,229,246, 97,128, 9, 80,229,231, 97,
- 133, 3,201,146, 61,146, 65,146, 76,146, 90,146,106, 49,128, 3,
- 214,227,249,242,233,236,236,233, 99,128, 4, 97,236,225,244,233,
- 238,227,236,239,243,229,100,128, 2,119,242,239,245,238,228,227,
- 249,242,233,236,236,233, 99,128, 4,123,116, 2,146,112,146,127,
- 233,244,236,239,227,249,242,233,236,236,233, 99,128, 4,125,239,
- 238,239,115,128, 3,206,231,245,234,225,242,225,244,105,128, 10,
- 208,233,227,242,239,110,129, 3,191,146,155,244,239,238,239,115,
- 128, 3,204,239,238,239,243,240,225,227,101,128,255, 79,238,101,
- 145, 0, 49,146,213,146,222,146,232,147, 6,147, 31,147, 40,147,
- 49,147, 74,147,108,147,142,147,154,147,173,147,184,147,217,147,
- 227,147,235,147,246,225,242,225,226,233, 99,128, 6, 97,226,229,
- 238,231,225,236,105,128, 9,231,227,233,242,227,236,101,129, 36,
- 96,146,243,233,238,246,229,242,243,229,243,225,238,243,243,229,
- 242,233,102,128, 39,138,100, 2,147, 12,147, 18,229,246, 97,128,
- 9,103,239,244,229,238,236,229,225,228,229,114,128, 32, 36,229,
- 233,231,232,244,104,128, 33, 91,230,233,244,244,229,100,128,246,
- 220,231,117, 2,147, 56,147, 65,234,225,242,225,244,105,128, 10,
- 231,242,237,245,235,232,105,128, 10,103,232, 97, 3,147, 83,147,
- 94,147, 99,227,235,225,242,225,226,233, 99,128, 6, 97,236,102,
- 128, 0,189,238,231,250,232,239,117,128, 48, 33,105, 2,147,114,
- 147,132,228,229,239,231,242,225,240,232,233,227,240,225,242,229,
- 110,128, 50, 32,238,230,229,242,233,239,114,128, 32,129,237,239,
- 238,239,243,240,225,227,101,128,255, 17,238,245,237,229,242,225,
- 244,239,242,226,229,238,231,225,236,105,128, 9,244,239,236,228,
- 243,244,249,236,101,128,247, 49,112, 2,147,190,147,197,225,242,
- 229,110,128, 36,116,229,114, 2,147,204,147,210,233,239,100,128,
- 36,136,243,233,225,110,128, 6,241,241,245,225,242,244,229,114,
- 128, 0,188,242,239,237,225,110,128, 33,112,243,245,240,229,242,
- 233,239,114,128, 0,185,244,104, 2,147,253,148, 2,225,105,128,
- 14, 81,233,242,100,128, 33, 83,111, 3,148, 16,148, 50,148, 66,
- 103, 2,148, 22,148, 40,239,238,229,107,129, 1,235,148, 31,237,
- 225,227,242,239,110,128, 1,237,245,242,237,245,235,232,105,128,
- 10, 19,237,225,244,242,225,231,245,242,237,245,235,232,105,128,
- 10, 75,240,229,110,128, 2, 84,112, 3,148, 80,148, 87,148, 98,
- 225,242,229,110,128, 36,170,229,238,226,245,236,236,229,116,128,
- 37,230,244,233,239,110,128, 35, 37,114, 2,148,111,148,140,100,
- 2,148,117,148,128,230,229,237,233,238,233,238,101,128, 0,170,
- 237,225,243,227,245,236,233,238,101,128, 0,186,244,232,239,231,
- 239,238,225,108,128, 34, 31,115, 5,148,163,148,195,148,212,149,
- 1,149, 14,232,239,242,116, 2,148,172,148,179,228,229,246, 97,
- 128, 9, 18,246,239,247,229,236,243,233,231,238,228,229,246, 97,
- 128, 9, 74,236,225,243,104,129, 0,248,148,204,225,227,245,244,
- 101,128, 1,255,237,225,236,108, 2,148,221,148,232,232,233,242,
- 225,231,225,238, 97,128, 48, 73,235,225,244,225,235,225,238, 97,
- 129, 48,169,148,245,232,225,236,230,247,233,228,244,104,128,255,
- 107,244,242,239,235,229,225,227,245,244,101,128, 1,255,245,240,
- 229,242,233,239,114,128,246,240,116, 2,149, 30,149, 41,227,249,
- 242,233,236,236,233, 99,128, 4,127,233,236,228,101,130, 0,245,
- 149, 52,149, 60,225,227,245,244,101,128, 30, 77,228,233,229,242,
- 229,243,233,115,128, 30, 79,245,226,239,240,239,237,239,230,111,
- 128, 49, 33,118, 2,149, 89,149,170,229,114, 2,149, 96,149,162,
- 236,233,238,101,131, 32, 62,149,109,149,132,149,155, 99, 2,149,
- 115,149,127,229,238,244,229,242,236,233,238,101,128,254, 74,237,
- 98,128, 3, 5,100, 2,149,138,149,146,225,243,232,229,100,128,
- 254, 73,226,236,247,225,246,121,128,254, 76,247,225,246,121,128,
- 254, 75,243,227,239,242,101,128, 0,175,239,247,229,236,243,233,
- 231,110, 3,149,185,149,195,149,202,226,229,238,231,225,236,105,
- 128, 9,203,228,229,246, 97,128, 9, 75,231,245,234,225,242,225,
- 244,105,128, 10,203,112,145, 0,112,149,251,152,123,152,134,152,
- 143,152,155,154, 80,154, 90,155, 82,156,101,156,191,156,217,157,
- 92,157,100,158, 2,158, 60,158, 88,158, 98, 97, 14,150, 25,150,
- 57,150, 67,150, 74,150, 81,150,129,150,140,150,154,150,165,150,
- 212,150,226,151,238,152, 21,152,111, 97, 2,150, 31,150, 43,237,
- 240,243,243,241,245,225,242,101,128, 51,128,243,229,238,244,239,
- 243,241,245,225,242,101,128, 51, 43,226,229,238,231,225,236,105,
- 128, 9,170,227,245,244,101,128, 30, 85,228,229,246, 97,128, 9,
- 42,103, 2,150, 87,150,105,101, 2,150, 93,150,100,228,239,247,
- 110,128, 33,223,245,112,128, 33,222,117, 2,150,111,150,120,234,
- 225,242,225,244,105,128, 10,170,242,237,245,235,232,105,128, 10,
- 42,232,233,242,225,231,225,238, 97,128, 48,113,233,249,225,238,
- 238,239,233,244,232,225,105,128, 14, 47,235,225,244,225,235,225,
- 238, 97,128, 48,209,108, 2,150,171,150,196,225,244,225,236,233,
- 250,225,244,233,239,238,227,249,242,233,236,236,233,227,227,237,
- 98,128, 4,132,239,227,232,235,225,227,249,242,233,236,236,233,
- 99,128, 4,192,238,243,233,239,243,235,239,242,229,225,110,128,
- 49,127,114, 3,150,234,150,255,151,227, 97, 2,150,240,150,248,
- 231,242,225,240,104,128, 0,182,236,236,229,108,128, 34, 37,229,
- 110, 2,151, 6,151,116,236,229,230,116,136, 0, 40,151, 29,151,
- 44,151, 49,151, 54,151, 65,151, 77,151,100,151,105,225,236,244,
- 239,238,229,225,242,225,226,233, 99,128,253, 62,226,116,128,248,
- 237,229,120,128,248,236,233,238,230,229,242,233,239,114,128, 32,
- 141,237,239,238,239,243,240,225,227,101,128,255, 8,115, 2,151,
- 83,151, 90,237,225,236,108,128,254, 89,245,240,229,242,233,239,
- 114,128, 32,125,244,112,128,248,235,246,229,242,244,233,227,225,
- 108,128,254, 53,242,233,231,232,116,136, 0, 41,151,140,151,155,
- 151,160,151,165,151,176,151,188,151,211,151,216,225,236,244,239,
- 238,229,225,242,225,226,233, 99,128,253, 63,226,116,128,248,248,
- 229,120,128,248,247,233,238,230,229,242,233,239,114,128, 32,142,
- 237,239,238,239,243,240,225,227,101,128,255, 9,115, 2,151,194,
- 151,201,237,225,236,108,128,254, 90,245,240,229,242,233,239,114,
- 128, 32,126,244,112,128,248,246,246,229,242,244,233,227,225,108,
- 128,254, 54,244,233,225,236,228,233,230,102,128, 34, 2,115, 3,
- 151,246,152, 1,152, 13,229,241,232,229,226,242,229,119,128, 5,
- 192,232,244,225,232,229,226,242,229,119,128, 5,153,241,245,225,
- 242,101,128, 51,169,244,225,104,134, 5,183,152, 39,152, 53,152,
- 58,152, 67,152, 82,152, 98, 49, 2,152, 45,152, 49, 49,128, 5,
- 183,100,128, 5,183,178, 97,128, 5,183,232,229,226,242,229,119,
- 128, 5,183,238,225,242,242,239,247,232,229,226,242,229,119,128,
- 5,183,241,245,225,242,244,229,242,232,229,226,242,229,119,128,
- 5,183,247,233,228,229,232,229,226,242,229,119,128, 5,183,250,
- 229,242,232,229,226,242,229,119,128, 5,161,226,239,240,239,237,
- 239,230,111,128, 49, 6,227,233,242,227,236,101,128, 36,223,228,
- 239,244,225,227,227,229,238,116,128, 30, 87,101,137, 5,228,152,
- 177,152,188,152,208,152,220,152,240,153, 86,153, 97,153,118,154,
- 73,227,249,242,233,236,236,233, 99,128, 4, 63,228,225,231,229,
- 243,104,129,251, 68,152,199,232,229,226,242,229,119,128,251, 68,
- 229,250,233,243,241,245,225,242,101,128, 51, 59,230,233,238,225,
- 236,228,225,231,229,243,232,232,229,226,242,229,119,128,251, 67,
- 104, 5,152,252,153, 19,153, 27,153, 41,153, 71,225,114, 2,153,
- 3,153, 10,225,226,233, 99,128, 6,126,237,229,238,233,225,110,
- 128, 5,122,229,226,242,229,119,128, 5,228,230,233,238,225,236,
- 225,242,225,226,233, 99,128,251, 87,105, 2,153, 47,153, 62,238,
- 233,244,233,225,236,225,242,225,226,233, 99,128,251, 88,242,225,
- 231,225,238, 97,128, 48,122,237,229,228,233,225,236,225,242,225,
- 226,233, 99,128,251, 89,235,225,244,225,235,225,238, 97,128, 48,
- 218,237,233,228,228,236,229,232,239,239,235,227,249,242,233,236,
- 236,233, 99,128, 4,167,114, 5,153,130,153,142,153,184,154, 49,
- 154, 62,225,230,229,232,229,226,242,229,119,128,251, 78,227,229,
- 238,116,131, 0, 37,153,155,153,164,153,176,225,242,225,226,233,
- 99,128, 6,106,237,239,238,239,243,240,225,227,101,128,255, 5,
- 243,237,225,236,108,128,254,106,105, 2,153,190,154, 31,239,100,
- 134, 0, 46,153,207,153,218,153,229,153,241,153,252,154, 8,225,
- 242,237,229,238,233,225,110,128, 5,137,227,229,238,244,229,242,
- 229,100,128, 0,183,232,225,236,230,247,233,228,244,104,128,255,
- 97,233,238,230,229,242,233,239,114,128,246,231,237,239,238,239,
- 243,240,225,227,101,128,255, 14,115, 2,154, 14,154, 21,237,225,
- 236,108,128,254, 82,245,240,229,242,233,239,114,128,246,232,243,
- 240,239,237,229,238,233,231,242,229,229,235,227,237, 98,128, 3,
- 66,240,229,238,228,233,227,245,236,225,114,128, 34,165,244,232,
- 239,245,243,225,238,100,128, 32, 48,243,229,244, 97,128, 32,167,
- 230,243,241,245,225,242,101,128, 51,138,104, 3,154, 98,154,148,
- 155, 29, 97, 3,154,106,154,116,154,123,226,229,238,231,225,236,
- 105,128, 9,171,228,229,246, 97,128, 9, 43,231,117, 2,154,130,
- 154,139,234,225,242,225,244,105,128, 10,171,242,237,245,235,232,
- 105,128, 10, 43,105,133, 3,198,154,162,154,166,154,252,155, 4,
- 155, 15, 49,128, 3,213,229,245,240,104, 4,154,179,154,214,154,
- 229,154,238, 97, 2,154,185,154,200,227,233,242,227,236,229,235,
- 239,242,229,225,110,128, 50,122,240,225,242,229,238,235,239,242,
- 229,225,110,128, 50, 26,227,233,242,227,236,229,235,239,242,229,
- 225,110,128, 50,108,235,239,242,229,225,110,128, 49, 77,240,225,
- 242,229,238,235,239,242,229,225,110,128, 50, 12,236,225,244,233,
- 110,128, 2,120,238,244,232,245,244,232,225,105,128, 14, 58,243,
- 249,237,226,239,236,231,242,229,229,107,128, 3,213,111, 3,155,
- 37,155, 42,155, 68,239,107,128, 1,165,240,104, 2,155, 49,155,
- 58,225,238,244,232,225,105,128, 14, 30,245,238,231,244,232,225,
- 105,128, 14, 28,243,225,237,240,232,225,239,244,232,225,105,128,
- 14, 32,105,133, 3,192,155, 96,156, 52,156, 63,156, 74,156, 88,
- 229,245,112, 6,155,112,155,147,155,179,155,207,155,221,156, 17,
- 97, 2,155,118,155,133,227,233,242,227,236,229,235,239,242,229,
- 225,110,128, 50,115,240,225,242,229,238,235,239,242,229,225,110,
- 128, 50, 19,227,105, 2,155,154,155,166,229,245,227,235,239,242,
- 229,225,110,128, 49,118,242,227,236,229,235,239,242,229,225,110,
- 128, 50,101,107, 2,155,185,155,199,233,249,229,239,235,235,239,
- 242,229,225,110,128, 49,114,239,242,229,225,110,128, 49, 66,240,
- 225,242,229,238,235,239,242,229,225,110,128, 50, 5,243,233,239,
- 115, 2,155,230,156, 2,107, 2,155,236,155,250,233,249,229,239,
- 235,235,239,242,229,225,110,128, 49,116,239,242,229,225,110,128,
- 49, 68,244,233,235,229,245,244,235,239,242,229,225,110,128, 49,
- 117,116, 2,156, 23,156, 38,232,233,229,245,244,232,235,239,242,
- 229,225,110,128, 49,119,233,235,229,245,244,235,239,242,229,225,
- 110,128, 49,115,232,233,242,225,231,225,238, 97,128, 48,116,235,
- 225,244,225,235,225,238, 97,128, 48,212,243,249,237,226,239,236,
- 231,242,229,229,107,128, 3,214,247,242,225,242,237,229,238,233,
- 225,110,128, 5,131,236,245,115,132, 0, 43,156,115,156,126,156,
- 135,156,168,226,229,236,239,247,227,237, 98,128, 3, 31,227,233,
- 242,227,236,101,128, 34,149,109, 2,156,141,156,148,233,238,245,
- 115,128, 0,177,111, 2,156,154,156,158,100,128, 2,214,238,239,
- 243,240,225,227,101,128,255, 11,115, 2,156,174,156,181,237,225,
- 236,108,128,254, 98,245,240,229,242,233,239,114,128, 32,122,109,
- 2,156,197,156,208,239,238,239,243,240,225,227,101,128,255, 80,
- 243,241,245,225,242,101,128, 51,216,111, 5,156,229,156,240,157,
- 51,157, 62,157, 72,232,233,242,225,231,225,238, 97,128, 48,125,
- 233,238,244,233,238,231,233,238,228,229,120, 4,157, 4,157, 16,
- 157, 28,157, 41,228,239,247,238,247,232,233,244,101,128, 38, 31,
- 236,229,230,244,247,232,233,244,101,128, 38, 28,242,233,231,232,
- 244,247,232,233,244,101,128, 38, 30,245,240,247,232,233,244,101,
- 128, 38, 29,235,225,244,225,235,225,238, 97,128, 48,221,240,236,
- 225,244,232,225,105,128, 14, 27,243,244,225,236,237,225,242,107,
- 129, 48, 18,157, 85,230,225,227,101,128, 48, 32,240,225,242,229,
- 110,128, 36,171,114, 3,157,108,157,134,157,159,101, 2,157,114,
- 157,122,227,229,228,229,115,128, 34,122,243,227,242,233,240,244,
- 233,239,110,128, 33, 30,233,237,101, 2,157,142,157,148,237,239,
- 100,128, 2,185,242,229,246,229,242,243,229,100,128, 32, 53,111,
- 4,157,169,157,176,157,186,157,199,228,245,227,116,128, 34, 15,
- 234,229,227,244,233,246,101,128, 35, 5,236,239,238,231,229,228,
- 235,225,238, 97,128, 48,252,112, 2,157,205,157,242,101, 2,157,
- 211,157,218,236,236,239,114,128, 35, 24,242,243,117, 2,157,226,
- 157,233,226,243,229,116,128, 34,130,240,229,242,243,229,116,128,
- 34,131,239,242,244,233,239,110,129, 34, 55,157,253,225,108,128,
- 34, 29,115, 2,158, 8,158, 51,105,130, 3,200,158, 16,158, 27,
- 227,249,242,233,236,236,233, 99,128, 4,113,236,233,240,238,229,
- 245,237,225,244,225,227,249,242,233,236,236,233,227,227,237, 98,
- 128, 4,134,243,241,245,225,242,101,128, 51,176,117, 2,158, 66,
- 158, 77,232,233,242,225,231,225,238, 97,128, 48,119,235,225,244,
- 225,235,225,238, 97,128, 48,215,246,243,241,245,225,242,101,128,
- 51,180,247,243,241,245,225,242,101,128, 51,186,113,136, 0,113,
- 158,128,159,177,159,188,159,197,159,204,159,216,159,254,160, 6,
- 97, 4,158,138,158,161,158,225,159,160,100, 2,158,144,158,150,
- 229,246, 97,128, 9, 88,237,225,232,229,226,242,229,119,128, 5,
- 168,102, 4,158,171,158,180,158,194,158,210,225,242,225,226,233,
- 99,128, 6, 66,230,233,238,225,236,225,242,225,226,233, 99,128,
- 254,214,233,238,233,244,233,225,236,225,242,225,226,233, 99,128,
- 254,215,237,229,228,233,225,236,225,242,225,226,233, 99,128,254,
- 216,237,225,244,115,136, 5,184,158,248,159, 12,159, 26,159, 31,
- 159, 36,159, 45,159, 60,159,147, 49, 3,159, 0,159, 4,159, 8,
- 48,128, 5,184, 97,128, 5,184, 99,128, 5,184, 50, 2,159, 18,
- 159, 22, 55,128, 5,184, 57,128, 5,184,179, 51,128, 5,184,228,
- 101,128, 5,184,232,229,226,242,229,119,128, 5,184,238,225,242,
- 242,239,247,232,229,226,242,229,119,128, 5,184,113, 2,159, 66,
- 159,132,225,244,225,110, 4,159, 79,159, 88,159,103,159,119,232,
- 229,226,242,229,119,128, 5,184,238,225,242,242,239,247,232,229,
- 226,242,229,119,128, 5,184,241,245,225,242,244,229,242,232,229,
- 226,242,229,119,128, 5,184,247,233,228,229,232,229,226,242,229,
- 119,128, 5,184,245,225,242,244,229,242,232,229,226,242,229,119,
- 128, 5,184,247,233,228,229,232,229,226,242,229,119,128, 5,184,
- 242,238,229,249,240,225,242,225,232,229,226,242,229,119,128, 5,
- 159,226,239,240,239,237,239,230,111,128, 49, 17,227,233,242,227,
- 236,101,128, 36,224,232,239,239,107,128, 2,160,237,239,238,239,
- 243,240,225,227,101,128,255, 81,239,102,130, 5,231,159,225,159,
- 245,228,225,231,229,243,104,129,251, 71,159,236,232,229,226,242,
- 229,119,128,251, 71,232,229,226,242,229,119,128, 5,231,240,225,
- 242,229,110,128, 36,172,117, 4,160, 16,160, 28,160,117,160,204,
- 225,242,244,229,242,238,239,244,101,128, 38,105,226,245,244,115,
- 135, 5,187,160, 49,160, 54,160, 59,160, 64,160, 73,160, 88,160,
- 104,177, 56,128, 5,187,178, 53,128, 5,187,179, 49,128, 5,187,
- 232,229,226,242,229,119,128, 5,187,238,225,242,242,239,247,232,
- 229,226,242,229,119,128, 5,187,241,245,225,242,244,229,242,232,
- 229,226,242,229,119,128, 5,187,247,233,228,229,232,229,226,242,
- 229,119,128, 5,187,229,243,244,233,239,110,133, 0, 63,160,136,
- 160,159,160,176,160,184,160,196,225,114, 2,160,143,160,150,225,
- 226,233, 99,128, 6, 31,237,229,238,233,225,110,128, 5, 94,228,
- 239,247,110,129, 0,191,160,168,243,237,225,236,108,128,247,191,
- 231,242,229,229,107,128, 3,126,237,239,238,239,243,240,225,227,
- 101,128,255, 31,243,237,225,236,108,128,247, 63,239,244,101, 4,
- 160,216,161, 31,161, 51,161, 80,228,226,108,133, 0, 34,160,232,
- 160,239,160,246,161, 2,161, 23,226,225,243,101,128, 32, 30,236,
- 229,230,116,128, 32, 28,237,239,238,239,243,240,225,227,101,128,
- 255, 2,240,242,233,237,101,129, 48, 30,161, 12,242,229,246,229,
- 242,243,229,100,128, 48, 29,242,233,231,232,116,128, 32, 29,236,
- 229,230,116,129, 32, 24,161, 40,242,229,246,229,242,243,229,100,
- 128, 32, 27,114, 2,161, 57,161, 67,229,246,229,242,243,229,100,
- 128, 32, 27,233,231,232,116,129, 32, 25,161, 76,110,128, 1, 73,
- 243,233,238,231,108, 2,161, 90,161, 97,226,225,243,101,128, 32,
- 26,101,129, 0, 39,161,103,237,239,238,239,243,240,225,227,101,
- 128,255, 7,114,145, 0,114,161,153,162,157,162,168,162,215,163,
- 10,164, 27,164, 51,164,146,166,180,166,217,166,229,167, 27,167,
- 35,167,197,167,208,167,243,168, 87, 97, 11,161,177,161,188,161,
- 198,161,205,162, 14,162, 30,162, 55,162, 66,162, 91,162,114,162,
- 151,225,242,237,229,238,233,225,110,128, 5,124,226,229,238,231,
- 225,236,105,128, 9,176,227,245,244,101,128, 1, 85,100, 4,161,
- 215,161,221,161,235,162, 5,229,246, 97,128, 9, 48,233,227,225,
- 108,129, 34, 26,161,230,229,120,128,248,229,239,246,229,242,243,
- 243,241,245,225,242,101,129, 51,174,161,251,228,243,241,245,225,
- 242,101,128, 51,175,243,241,245,225,242,101,128, 51,173,230,101,
- 129, 5,191,162, 21,232,229,226,242,229,119,128, 5,191,231,117,
- 2,162, 37,162, 46,234,225,242,225,244,105,128, 10,176,242,237,
- 245,235,232,105,128, 10, 48,232,233,242,225,231,225,238, 97,128,
- 48,137,235,225,244,225,235,225,238, 97,129, 48,233,162, 79,232,
- 225,236,230,247,233,228,244,104,128,255,151,236,239,247,229,242,
- 228,233,225,231,239,238,225,236,226,229,238,231,225,236,105,128,
- 9,241,109, 2,162,120,162,143,233,228,228,236,229,228,233,225,
- 231,239,238,225,236,226,229,238,231,225,236,105,128, 9,240,243,
- 232,239,242,110,128, 2,100,244,233,111,128, 34, 54,226,239,240,
- 239,237,239,230,111,128, 49, 22, 99, 4,162,178,162,185,162,194,
- 162,202,225,242,239,110,128, 1, 89,229,228,233,236,236, 97,128,
- 1, 87,233,242,227,236,101,128, 36,225,239,237,237,225,225,227,
- 227,229,238,116,128, 1, 87,100, 2,162,221,162,231,226,236,231,
- 242,225,246,101,128, 2, 17,239,116, 2,162,238,162,247,225,227,
- 227,229,238,116,128, 30, 89,226,229,236,239,119,129, 30, 91,163,
- 1,237,225,227,242,239,110,128, 30, 93,101, 6,163, 24,163, 69,
- 163,104,163,159,163,184,163,217,102, 2,163, 30,163, 43,229,242,
- 229,238,227,229,237,225,242,107,128, 32, 59,236,229,248,243,117,
- 2,163, 53,163, 60,226,243,229,116,128, 34,134,240,229,242,243,
- 229,116,128, 34,135,231,233,243,244,229,114, 2,163, 80,163, 85,
- 229,100,128, 0,174,115, 2,163, 91,163, 97,225,238,115,128,248,
- 232,229,242,233,102,128,246,218,104, 3,163,112,163,135,163,149,
- 225,114, 2,163,119,163,126,225,226,233, 99,128, 6, 49,237,229,
- 238,233,225,110,128, 5,128,230,233,238,225,236,225,242,225,226,
- 233, 99,128,254,174,233,242,225,231,225,238, 97,128, 48,140,235,
- 225,244,225,235,225,238, 97,129, 48,236,163,172,232,225,236,230,
- 247,233,228,244,104,128,255,154,243,104,130, 5,232,163,193,163,
- 208,228,225,231,229,243,232,232,229,226,242,229,119,128,251, 72,
- 232,229,226,242,229,119,128, 5,232,118, 3,163,225,163,238,164,
- 14,229,242,243,229,228,244,233,236,228,101,128, 34, 61,233, 97,
- 2,163,245,163,254,232,229,226,242,229,119,128, 5,151,237,245,
- 231,242,225,243,232,232,229,226,242,229,119,128, 5,151,236,239,
- 231,233,227,225,236,238,239,116,128, 35, 16,230,233,243,232,232,
- 239,239,107,129, 2,126,164, 40,242,229,246,229,242,243,229,100,
- 128, 2,127,104, 2,164, 57,164, 80, 97, 2,164, 63,164, 73,226,
- 229,238,231,225,236,105,128, 9,221,228,229,246, 97,128, 9, 93,
- 111,131, 3,193,164, 90,164,119,164,133,239,107,129, 2,125,164,
- 97,244,245,242,238,229,100,129, 2,123,164,108,243,245,240,229,
- 242,233,239,114,128, 2,181,243,249,237,226,239,236,231,242,229,
- 229,107,128, 3,241,244,233,227,232,239,239,235,237,239,100,128,
- 2,222,105, 6,164,160,165,204,165,250,166, 5,166, 30,166,166,
- 229,245,108, 9,164,182,164,217,164,232,164,246,165, 36,165, 50,
- 165,136,165,149,165,184, 97, 2,164,188,164,203,227,233,242,227,
- 236,229,235,239,242,229,225,110,128, 50,113,240,225,242,229,238,
- 235,239,242,229,225,110,128, 50, 17,227,233,242,227,236,229,235,
- 239,242,229,225,110,128, 50, 99,232,233,229,245,232,235,239,242,
- 229,225,110,128, 49, 64,107, 2,164,252,165, 28,233,249,229,239,
- 107, 2,165, 6,165, 15,235,239,242,229,225,110,128, 49, 58,243,
- 233,239,243,235,239,242,229,225,110,128, 49,105,239,242,229,225,
- 110,128, 49, 57,237,233,229,245,237,235,239,242,229,225,110,128,
- 49, 59,112, 3,165, 58,165, 90,165,105, 97, 2,165, 64,165, 78,
- 238,243,233,239,243,235,239,242,229,225,110,128, 49,108,242,229,
- 238,235,239,242,229,225,110,128, 50, 3,232,233,229,245,240,232,
- 235,239,242,229,225,110,128, 49, 63,233,229,245,112, 2,165,114,
- 165,123,235,239,242,229,225,110,128, 49, 60,243,233,239,243,235,
- 239,242,229,225,110,128, 49,107,243,233,239,243,235,239,242,229,
- 225,110,128, 49, 61,116, 2,165,155,165,170,232,233,229,245,244,
- 232,235,239,242,229,225,110,128, 49, 62,233,235,229,245,244,235,
- 239,242,229,225,110,128, 49,106,249,229,239,242,233,238,232,233,
- 229,245,232,235,239,242,229,225,110,128, 49,109,231,232,116, 2,
- 165,212,165,220,225,238,231,236,101,128, 34, 31,116, 2,165,226,
- 165,240,225,227,235,226,229,236,239,247,227,237, 98,128, 3, 25,
- 242,233,225,238,231,236,101,128, 34,191,232,233,242,225,231,225,
- 238, 97,128, 48,138,235,225,244,225,235,225,238, 97,129, 48,234,
- 166, 18,232,225,236,230,247,233,228,244,104,128,255,152,110, 2,
- 166, 36,166,152,103,131, 2,218,166, 46,166, 57,166, 63,226,229,
- 236,239,247,227,237, 98,128, 3, 37,227,237, 98,128, 3, 10,232,
- 225,236,102, 2,166, 72,166,118,236,229,230,116,131, 2,191,166,
- 85,166, 96,166,107,225,242,237,229,238,233,225,110,128, 5, 89,
- 226,229,236,239,247,227,237, 98,128, 3, 28,227,229,238,244,229,
- 242,229,100,128, 2,211,242,233,231,232,116,130, 2,190,166,130,
- 166,141,226,229,236,239,247,227,237, 98,128, 3, 57,227,229,238,
- 244,229,242,229,100,128, 2,210,246,229,242,244,229,228,226,242,
- 229,246,101,128, 2, 19,244,244,239,242,245,243,241,245,225,242,
- 101,128, 51, 81,108, 2,166,186,166,197,233,238,229,226,229,236,
- 239,119,128, 30, 95,239,238,231,236,229,103,129, 2,124,166,208,
- 244,245,242,238,229,100,128, 2,122,237,239,238,239,243,240,225,
- 227,101,128,255, 82,111, 3,166,237,166,248,167, 17,232,233,242,
- 225,231,225,238, 97,128, 48,141,235,225,244,225,235,225,238, 97,
- 129, 48,237,167, 5,232,225,236,230,247,233,228,244,104,128,255,
- 155,242,245,225,244,232,225,105,128, 14, 35,240,225,242,229,110,
- 128, 36,173,114, 3,167, 43,167, 79,167,109, 97, 3,167, 51,167,
- 61,167, 68,226,229,238,231,225,236,105,128, 9,220,228,229,246,
- 97,128, 9, 49,231,245,242,237,245,235,232,105,128, 10, 92,229,
- 104, 2,167, 86,167, 95,225,242,225,226,233, 99,128, 6,145,230,
- 233,238,225,236,225,242,225,226,233, 99,128,251,141,246,239,227,
- 225,236,233, 99, 4,167,125,167,135,167,142,167,153,226,229,238,
- 231,225,236,105,128, 9,224,228,229,246, 97,128, 9, 96,231,245,
- 234,225,242,225,244,105,128, 10,224,246,239,247,229,236,243,233,
- 231,110, 3,167,169,167,179,167,186,226,229,238,231,225,236,105,
- 128, 9,196,228,229,246, 97,128, 9, 68,231,245,234,225,242,225,
- 244,105,128, 10,196,243,245,240,229,242,233,239,114,128,246,241,
- 116, 2,167,214,167,222,226,236,239,227,107,128, 37,144,245,242,
- 238,229,100,129, 2,121,167,232,243,245,240,229,242,233,239,114,
- 128, 2,180,117, 4,167,253,168, 8,168, 33,168, 80,232,233,242,
- 225,231,225,238, 97,128, 48,139,235,225,244,225,235,225,238, 97,
- 129, 48,235,168, 21,232,225,236,230,247,233,228,244,104,128,255,
- 153,112, 2,168, 39,168, 74,229,101, 2,168, 46,168, 60,237,225,
- 242,235,226,229,238,231,225,236,105,128, 9,242,243,233,231,238,
- 226,229,238,231,225,236,105,128, 9,243,233,225,104,128,246,221,
- 244,232,225,105,128, 14, 36,246,239,227,225,236,233, 99, 4,168,
- 103,168,113,168,120,168,131,226,229,238,231,225,236,105,128, 9,
- 139,228,229,246, 97,128, 9, 11,231,245,234,225,242,225,244,105,
- 128, 10,139,246,239,247,229,236,243,233,231,110, 3,168,147,168,
- 157,168,164,226,229,238,231,225,236,105,128, 9,195,228,229,246,
- 97,128, 9, 67,231,245,234,225,242,225,244,105,128, 10,195,115,
- 147, 0,115,168,217,170,187,170,198,171, 68,171,107,174, 49,174,
- 60,176,203,179, 85,179,131,179,158,180, 93,180,160,181,193,181,
- 203,182,133,182,206,183,120,183,130, 97, 9,168,237,168,247,169,
- 12,169, 84,169,109,169,120,169,145,169,177,169,217,226,229,238,
- 231,225,236,105,128, 9,184,227,245,244,101,129, 1, 91,169, 0,
- 228,239,244,225,227,227,229,238,116,128, 30,101,100, 5,169, 24,
- 169, 33,169, 39,169, 53,169, 69,225,242,225,226,233, 99,128, 6,
- 53,229,246, 97,128, 9, 56,230,233,238,225,236,225,242,225,226,
- 233, 99,128,254,186,233,238,233,244,233,225,236,225,242,225,226,
- 233, 99,128,254,187,237,229,228,233,225,236,225,242,225,226,233,
- 99,128,254,188,231,117, 2,169, 91,169,100,234,225,242,225,244,
- 105,128, 10,184,242,237,245,235,232,105,128, 10, 56,232,233,242,
- 225,231,225,238, 97,128, 48, 85,235,225,244,225,235,225,238, 97,
- 129, 48,181,169,133,232,225,236,230,247,233,228,244,104,128,255,
- 123,236,236,225,236,236,225,232,239,245,225,236,225,249,232,229,
- 247,225,243,225,236,236,225,237,225,242,225,226,233, 99,128,253,
- 250,237,229,235,104,130, 5,225,169,188,169,208,228,225,231,229,
- 243,104,129,251, 65,169,199,232,229,226,242,229,119,128,251, 65,
- 232,229,226,242,229,119,128, 5,225,242, 97, 5,169,230,170, 48,
- 170, 56,170,106,170,114, 97, 5,169,242,169,250,170, 2,170, 33,
- 170, 41,225,244,232,225,105,128, 14, 50,229,244,232,225,105,128,
- 14, 65,233,237,225,233,109, 2,170, 12,170, 23,225,236,225,233,
- 244,232,225,105,128, 14, 68,245,225,238,244,232,225,105,128, 14,
- 67,237,244,232,225,105,128, 14, 51,244,232,225,105,128, 14, 48,
- 229,244,232,225,105,128, 14, 64,105, 3,170, 64,170, 88,170, 99,
- 105, 2,170, 70,170, 81,236,229,230,244,244,232,225,105,128,248,
- 134,244,232,225,105,128, 14, 53,236,229,230,244,244,232,225,105,
- 128,248,133,244,232,225,105,128, 14, 52,239,244,232,225,105,128,
- 14, 66,117, 3,170,122,170,172,170,179,101, 3,170,130,170,154,
- 170,165,101, 2,170,136,170,147,236,229,230,244,244,232,225,105,
- 128,248,136,244,232,225,105,128, 14, 55,236,229,230,244,244,232,
- 225,105,128,248,135,244,232,225,105,128, 14, 54,244,232,225,105,
- 128, 14, 56,245,244,232,225,105,128, 14, 57,226,239,240,239,237,
- 239,230,111,128, 49, 25, 99, 5,170,210,170,231,170,240,171, 33,
- 171, 55,225,242,239,110,129, 1, 97,170,219,228,239,244,225,227,
- 227,229,238,116,128, 30,103,229,228,233,236,236, 97,128, 1, 95,
- 232,247, 97,131, 2, 89,170,252,171, 7,171, 26,227,249,242,233,
- 236,236,233, 99,128, 4,217,228,233,229,242,229,243,233,243,227,
- 249,242,233,236,236,233, 99,128, 4,219,232,239,239,107,128, 2,
- 90,233,242, 99, 2,171, 41,171, 46,236,101,128, 36,226,245,237,
- 230,236,229,120,128, 1, 93,239,237,237,225,225,227,227,229,238,
- 116,128, 2, 25,228,239,116, 2,171, 76,171, 85,225,227,227,229,
- 238,116,128, 30, 97,226,229,236,239,119,129, 30, 99,171, 95,228,
- 239,244,225,227,227,229,238,116,128, 30,105,101, 9,171,127,171,
- 143,171,178,171,243,172, 90,172,117,172,142,172,223,172,250,225,
- 231,245,236,236,226,229,236,239,247,227,237, 98,128, 3, 60, 99,
- 2,171,149,171,171,239,238,100,129, 32, 51,171,157,244,239,238,
- 229,227,232,233,238,229,243,101,128, 2,202,244,233,239,110,128,
- 0,167,229,110, 4,171,189,171,198,171,212,171,228,225,242,225,
- 226,233, 99,128, 6, 51,230,233,238,225,236,225,242,225,226,233,
- 99,128,254,178,233,238,233,244,233,225,236,225,242,225,226,233,
- 99,128,254,179,237,229,228,233,225,236,225,242,225,226,233, 99,
- 128,254,180,231,239,108,135, 5,182,172, 7,172, 21,172, 26,172,
- 35,172, 50,172, 66,172, 77, 49, 2,172, 13,172, 17, 51,128, 5,
- 182,102,128, 5,182,178, 99,128, 5,182,232,229,226,242,229,119,
- 128, 5,182,238,225,242,242,239,247,232,229,226,242,229,119,128,
- 5,182,241,245,225,242,244,229,242,232,229,226,242,229,119,128,
- 5,182,244,225,232,229,226,242,229,119,128, 5,146,247,233,228,
- 229,232,229,226,242,229,119,128, 5,182,104, 2,172, 96,172,107,
- 225,242,237,229,238,233,225,110,128, 5,125,233,242,225,231,225,
- 238, 97,128, 48, 91,235,225,244,225,235,225,238, 97,129, 48,187,
- 172,130,232,225,236,230,247,233,228,244,104,128,255,126,237,105,
- 2,172,149,172,192,227,239,236,239,110,131, 0, 59,172,163,172,
- 172,172,184,225,242,225,226,233, 99,128, 6, 27,237,239,238,239,
- 243,240,225,227,101,128,255, 27,243,237,225,236,108,128,254, 84,
- 246,239,233,227,229,228,237,225,242,235,235,225,238, 97,129, 48,
- 156,172,211,232,225,236,230,247,233,228,244,104,128,255,159,238,
- 116, 2,172,230,172,240,233,243,241,245,225,242,101,128, 51, 34,
- 239,243,241,245,225,242,101,128, 51, 35,246,229,110,142, 0, 55,
- 173, 28,173, 37,173, 47,173, 77,173, 84,173, 94,173,119,173,146,
- 173,180,173,192,173,203,173,236,173,244,173,255,225,242,225,226,
- 233, 99,128, 6,103,226,229,238,231,225,236,105,128, 9,237,227,
- 233,242,227,236,101,129, 36,102,173, 58,233,238,246,229,242,243,
- 229,243,225,238,243,243,229,242,233,102,128, 39,144,228,229,246,
- 97,128, 9,109,229,233,231,232,244,232,115,128, 33, 94,231,117,
- 2,173,101,173,110,234,225,242,225,244,105,128, 10,237,242,237,
- 245,235,232,105,128, 10,109,232, 97, 2,173,126,173,137,227,235,
- 225,242,225,226,233, 99,128, 6,103,238,231,250,232,239,117,128,
- 48, 39,105, 2,173,152,173,170,228,229,239,231,242,225,240,232,
- 233,227,240,225,242,229,110,128, 50, 38,238,230,229,242,233,239,
- 114,128, 32,135,237,239,238,239,243,240,225,227,101,128,255, 23,
- 239,236,228,243,244,249,236,101,128,247, 55,112, 2,173,209,173,
- 216,225,242,229,110,128, 36,122,229,114, 2,173,223,173,229,233,
- 239,100,128, 36,142,243,233,225,110,128, 6,247,242,239,237,225,
- 110,128, 33,118,243,245,240,229,242,233,239,114,128, 32,119,116,
- 2,174, 5,174, 43,229,229,110, 2,174, 13,174, 22,227,233,242,
- 227,236,101,128, 36,112,112, 2,174, 28,174, 35,225,242,229,110,
- 128, 36,132,229,242,233,239,100,128, 36,152,232,225,105,128, 14,
- 87,230,244,232,249,240,232,229,110,128, 0,173,104, 7,174, 76,
- 175, 50,175, 61,175, 75,176, 20,176, 33,176,197, 97, 6,174, 90,
- 174,101,174,111,174,122,175, 9,175, 34,225,242,237,229,238,233,
- 225,110,128, 5,119,226,229,238,231,225,236,105,128, 9,182,227,
- 249,242,233,236,236,233, 99,128, 4, 72,100, 2,174,128,174,224,
- 228, 97, 4,174,139,174,148,174,179,174,193,225,242,225,226,233,
- 99,128, 6, 81,228,225,237,237, 97, 2,174,158,174,167,225,242,
- 225,226,233, 99,128,252, 97,244,225,238,225,242,225,226,233, 99,
- 128,252, 94,230,225,244,232,225,225,242,225,226,233, 99,128,252,
- 96,235,225,243,242, 97, 2,174,203,174,212,225,242,225,226,233,
- 99,128,252, 98,244,225,238,225,242,225,226,233, 99,128,252, 95,
- 101,132, 37,146,174,236,174,243,174,251,175, 4,228,225,242,107,
- 128, 37,147,236,233,231,232,116,128, 37,145,237,229,228,233,245,
- 109,128, 37,146,246, 97,128, 9, 54,231,117, 2,175, 16,175, 25,
- 234,225,242,225,244,105,128, 10,182,242,237,245,235,232,105,128,
- 10, 54,236,243,232,229,236,229,244,232,229,226,242,229,119,128,
- 5,147,226,239,240,239,237,239,230,111,128, 49, 21,227,232,225,
- 227,249,242,233,236,236,233, 99,128, 4, 73,101, 4,175, 85,175,
- 150,175,160,175,177,229,110, 4,175, 96,175,105,175,119,175,135,
- 225,242,225,226,233, 99,128, 6, 52,230,233,238,225,236,225,242,
- 225,226,233, 99,128,254,182,233,238,233,244,233,225,236,225,242,
- 225,226,233, 99,128,254,183,237,229,228,233,225,236,225,242,225,
- 226,233, 99,128,254,184,233,227,239,240,244,233, 99,128, 3,227,
- 241,229,108,129, 32,170,175,168,232,229,226,242,229,119,128, 32,
- 170,246, 97,134, 5,176,175,194,175,209,175,223,175,232,175,247,
- 176, 7, 49, 2,175,200,175,205,177, 53,128, 5,176, 53,128, 5,
- 176, 50, 2,175,215,175,219, 50,128, 5,176,101,128, 5,176,232,
- 229,226,242,229,119,128, 5,176,238,225,242,242,239,247,232,229,
- 226,242,229,119,128, 5,176,241,245,225,242,244,229,242,232,229,
- 226,242,229,119,128, 5,176,247,233,228,229,232,229,226,242,229,
- 119,128, 5,176,232,225,227,249,242,233,236,236,233, 99,128, 4,
- 187,105, 2,176, 39,176, 50,237,225,227,239,240,244,233, 99,128,
- 3,237,110,131, 5,233,176, 60,176,143,176,152,100, 2,176, 66,
- 176,132,225,231,229,243,104,130,251, 73,176, 78,176, 87,232,229,
- 226,242,229,119,128,251, 73,115, 2,176, 93,176,113,232,233,238,
- 228,239,116,129,251, 44,176,104,232,229,226,242,229,119,128,251,
- 44,233,238,228,239,116,129,251, 45,176,123,232,229,226,242,229,
- 119,128,251, 45,239,244,232,229,226,242,229,119,128, 5,193,232,
- 229,226,242,229,119,128, 5,233,115, 2,176,158,176,178,232,233,
- 238,228,239,116,129,251, 42,176,169,232,229,226,242,229,119,128,
- 251, 42,233,238,228,239,116,129,251, 43,176,188,232,229,226,242,
- 229,119,128,251, 43,239,239,107,128, 2,130,105, 8,176,221,177,
- 9,177, 20,177, 45,177, 75,177, 83,177, 96,178, 11,231,237, 97,
- 131, 3,195,176,233,176,237,176,245, 49,128, 3,194,230,233,238,
- 225,108,128, 3,194,236,245,238,225,244,229,243,249,237,226,239,
- 236,231,242,229,229,107,128, 3,242,232,233,242,225,231,225,238,
- 97,128, 48, 87,235,225,244,225,235,225,238, 97,129, 48,183,177,
- 33,232,225,236,230,247,233,228,244,104,128,255,124,236,245,113,
- 2,177, 53,177, 62,232,229,226,242,229,119,128, 5,189,236,229,
- 230,244,232,229,226,242,229,119,128, 5,189,237,233,236,225,114,
- 128, 34, 60,238,228,239,244,232,229,226,242,229,119,128, 5,194,
- 239,115, 6,177,111,177,146,177,178,177,206,177,220,177,252, 97,
- 2,177,117,177,132,227,233,242,227,236,229,235,239,242,229,225,
- 110,128, 50,116,240,225,242,229,238,235,239,242,229,225,110,128,
- 50, 20,227,105, 2,177,153,177,165,229,245,227,235,239,242,229,
- 225,110,128, 49,126,242,227,236,229,235,239,242,229,225,110,128,
- 50,102,107, 2,177,184,177,198,233,249,229,239,235,235,239,242,
- 229,225,110,128, 49,122,239,242,229,225,110,128, 49, 69,238,233,
- 229,245,238,235,239,242,229,225,110,128, 49,123,112, 2,177,226,
- 177,239,225,242,229,238,235,239,242,229,225,110,128, 50, 6,233,
- 229,245,240,235,239,242,229,225,110,128, 49,125,244,233,235,229,
- 245,244,235,239,242,229,225,110,128, 49,124,120,141, 0, 54,178,
- 41,178, 50,178, 60,178, 90,178, 97,178,122,178,149,178,183,178,
- 195,178,206,178,239,178,247,179, 2,225,242,225,226,233, 99,128,
- 6,102,226,229,238,231,225,236,105,128, 9,236,227,233,242,227,
- 236,101,129, 36,101,178, 71,233,238,246,229,242,243,229,243,225,
- 238,243,243,229,242,233,102,128, 39,143,228,229,246, 97,128, 9,
- 108,231,117, 2,178,104,178,113,234,225,242,225,244,105,128, 10,
- 236,242,237,245,235,232,105,128, 10,108,232, 97, 2,178,129,178,
- 140,227,235,225,242,225,226,233, 99,128, 6,102,238,231,250,232,
- 239,117,128, 48, 38,105, 2,178,155,178,173,228,229,239,231,242,
- 225,240,232,233,227,240,225,242,229,110,128, 50, 37,238,230,229,
- 242,233,239,114,128, 32,134,237,239,238,239,243,240,225,227,101,
- 128,255, 22,239,236,228,243,244,249,236,101,128,247, 54,112, 2,
- 178,212,178,219,225,242,229,110,128, 36,121,229,114, 2,178,226,
- 178,232,233,239,100,128, 36,141,243,233,225,110,128, 6,246,242,
- 239,237,225,110,128, 33,117,243,245,240,229,242,233,239,114,128,
- 32,118,116, 2,179, 8,179, 79,229,229,110, 2,179, 16,179, 58,
- 99, 2,179, 22,179, 30,233,242,227,236,101,128, 36,111,245,242,
- 242,229,238,227,249,228,229,238,239,237,233,238,225,244,239,242,
- 226,229,238,231,225,236,105,128, 9,249,112, 2,179, 64,179, 71,
- 225,242,229,110,128, 36,131,229,242,233,239,100,128, 36,151,232,
- 225,105,128, 14, 86,108, 2,179, 91,179,111,225,243,104,129, 0,
- 47,179, 99,237,239,238,239,243,240,225,227,101,128,255, 15,239,
- 238,103,129, 1,127,179,119,228,239,244,225,227,227,229,238,116,
- 128, 30,155,109, 2,179,137,179,147,233,236,229,230,225,227,101,
- 128, 38, 58,239,238,239,243,240,225,227,101,128,255, 83,111, 6,
- 179,172,179,222,179,233,180, 2,180, 47,180, 58,102, 2,179,178,
- 179,192,240,225,243,245,241,232,229,226,242,229,119,128, 5,195,
- 116, 2,179,198,179,207,232,249,240,232,229,110,128, 0,173,243,
- 233,231,238,227,249,242,233,236,236,233, 99,128, 4, 76,232,233,
- 242,225,231,225,238, 97,128, 48, 93,235,225,244,225,235,225,238,
- 97,129, 48,189,179,246,232,225,236,230,247,233,228,244,104,128,
- 255,127,236,233,228,245,115, 2,180, 12,180, 29,236,239,238,231,
- 239,246,229,242,236,225,249,227,237, 98,128, 3, 56,243,232,239,
- 242,244,239,246,229,242,236,225,249,227,237, 98,128, 3, 55,242,
- 245,243,233,244,232,225,105,128, 14, 41,115, 3,180, 66,180, 76,
- 180, 84,225,236,225,244,232,225,105,128, 14, 40,239,244,232,225,
- 105,128, 14, 11,245,225,244,232,225,105,128, 14, 42,240, 97, 3,
- 180,102,180,122,180,154,227,101,129, 0, 32,180,109,232,225,227,
- 235,225,242,225,226,233, 99,128, 0, 32,228,101,129, 38, 96,180,
- 129,243,245,233,116, 2,180,138,180,146,226,236,225,227,107,128,
- 38, 96,247,232,233,244,101,128, 38,100,242,229,110,128, 36,174,
- 241,245,225,242,101, 11,180,188,180,199,180,213,180,238,180,255,
- 181, 25,181, 40,181, 73,181,100,181,156,181,171,226,229,236,239,
- 247,227,237, 98,128, 3, 59, 99, 2,180,205,180,209, 99,128, 51,
- 196,109,128, 51,157,228,233,225,231,239,238,225,236,227,242,239,
- 243,243,232,225,244,227,232,230,233,236,108,128, 37,169,232,239,
- 242,233,250,239,238,244,225,236,230,233,236,108,128, 37,164,107,
- 2,181, 5,181, 9,103,128, 51,143,109,129, 51,158,181, 15,227,
- 225,240,233,244,225,108,128, 51,206,108, 2,181, 31,181, 35,110,
- 128, 51,209,239,103,128, 51,210,109, 4,181, 50,181, 54,181, 59,
- 181, 63,103,128, 51,142,233,108,128, 51,213,109,128, 51,156,243,
- 241,245,225,242,229,100,128, 51,161,239,242,244,232,239,231,239,
- 238,225,236,227,242,239,243,243,232,225,244,227,232,230,233,236,
- 108,128, 37,166,245,240,240,229,114, 2,181,110,181,133,236,229,
- 230,244,244,239,236,239,247,229,242,242,233,231,232,244,230,233,
- 236,108,128, 37,167,242,233,231,232,244,244,239,236,239,247,229,
- 242,236,229,230,244,230,233,236,108,128, 37,168,246,229,242,244,
- 233,227,225,236,230,233,236,108,128, 37,165,247,232,233,244,229,
- 247,233,244,232,243,237,225,236,236,226,236,225,227,107,128, 37,
- 163,242,243,241,245,225,242,101,128, 51,219,115, 2,181,209,182,
- 123, 97, 4,181,219,181,229,181,236,181,247,226,229,238,231,225,
- 236,105,128, 9,183,228,229,246, 97,128, 9, 55,231,245,234,225,
- 242,225,244,105,128, 10,183,238,103, 8,182, 10,182, 24,182, 38,
- 182, 52,182, 67,182, 81,182, 95,182,108,227,233,229,245,227,235,
- 239,242,229,225,110,128, 49, 73,232,233,229,245,232,235,239,242,
- 229,225,110,128, 49,133,233,229,245,238,231,235,239,242,229,225,
- 110,128, 49,128,235,233,249,229,239,235,235,239,242,229,225,110,
- 128, 49, 50,238,233,229,245,238,235,239,242,229,225,110,128, 49,
- 101,240,233,229,245,240,235,239,242,229,225,110,128, 49, 67,243,
- 233,239,243,235,239,242,229,225,110,128, 49, 70,244,233,235,229,
- 245,244,235,239,242,229,225,110,128, 49, 56,245,240,229,242,233,
- 239,114,128,246,242,116, 2,182,139,182,162,229,242,236,233,238,
- 103,129, 0,163,182,150,237,239,238,239,243,240,225,227,101,128,
- 255,225,242,239,235,101, 2,182,171,182,188,236,239,238,231,239,
- 246,229,242,236,225,249,227,237, 98,128, 3, 54,243,232,239,242,
- 244,239,246,229,242,236,225,249,227,237, 98,128, 3, 53,117, 7,
- 182,222,182,254,183, 20,183, 31,183, 72,183, 82,183, 86,226,243,
- 229,116,130, 34,130,182,233,182,244,238,239,244,229,241,245,225,
- 108,128, 34,138,239,242,229,241,245,225,108,128, 34,134, 99, 2,
- 183, 4,183, 12,227,229,229,228,115,128, 34,123,232,244,232,225,
- 116,128, 34, 11,232,233,242,225,231,225,238, 97,128, 48, 89,107,
- 2,183, 37,183, 61,225,244,225,235,225,238, 97,129, 48,185,183,
- 49,232,225,236,230,247,233,228,244,104,128,255,125,245,238,225,
- 242,225,226,233, 99,128, 6, 82,237,237,225,244,233,239,110,128,
- 34, 17,110,128, 38, 60,240,229,242,243,229,116,130, 34,131,183,
- 99,183,110,238,239,244,229,241,245,225,108,128, 34,139,239,242,
- 229,241,245,225,108,128, 34,135,246,243,241,245,225,242,101,128,
- 51,220,249,239,245,247,225,229,242,225,243,241,245,225,242,101,
- 128, 51,124,116,144, 0,116,183,183,184,192,184,213,185,100,185,
- 140,187,188,191, 70,192,145,192,157,192,169,193,202,193,227,194,
- 57,194,237,195,165,195,255, 97, 10,183,205,183,215,183,236,183,
- 243,184, 12,184, 90,184,107,184,132,184,146,184,150,226,229,238,
- 231,225,236,105,128, 9,164,227,107, 2,183,222,183,229,228,239,
- 247,110,128, 34,164,236,229,230,116,128, 34,163,228,229,246, 97,
- 128, 9, 36,231,117, 2,183,250,184, 3,234,225,242,225,244,105,
- 128, 10,164,242,237,245,235,232,105,128, 10, 36,104, 4,184, 22,
- 184, 31,184, 45,184, 75,225,242,225,226,233, 99,128, 6, 55,230,
- 233,238,225,236,225,242,225,226,233, 99,128,254,194,105, 2,184,
- 51,184, 66,238,233,244,233,225,236,225,242,225,226,233, 99,128,
- 254,195,242,225,231,225,238, 97,128, 48, 95,237,229,228,233,225,
- 236,225,242,225,226,233, 99,128,254,196,233,243,249,239,245,229,
- 242,225,243,241,245,225,242,101,128, 51,125,235,225,244,225,235,
- 225,238, 97,129, 48,191,184,120,232,225,236,230,247,233,228,244,
- 104,128,255,128,244,247,229,229,236,225,242,225,226,233, 99,128,
- 6, 64,117,128, 3,196,118,130, 5,234,184,158,184,183,228,225,
- 231,229,115,129,251, 74,184,168,104,129,251, 74,184,174,232,229,
- 226,242,229,119,128,251, 74,232,229,226,242,229,119,128, 5,234,
- 98, 2,184,198,184,203,225,114,128, 1,103,239,240,239,237,239,
- 230,111,128, 49, 10, 99, 6,184,227,184,234,184,241,184,250,185,
- 60,185, 87,225,242,239,110,128, 1,101,227,245,242,108,128, 2,
- 168,229,228,233,236,236, 97,128, 1, 99,232,229,104, 4,185, 6,
- 185, 15,185, 29,185, 45,225,242,225,226,233, 99,128, 6,134,230,
- 233,238,225,236,225,242,225,226,233, 99,128,251,123,233,238,233,
- 244,233,225,236,225,242,225,226,233, 99,128,251,124,237,229,228,
- 233,225,236,225,242,225,226,233, 99,128,251,125,233,242, 99, 2,
- 185, 68,185, 73,236,101,128, 36,227,245,237,230,236,229,248,226,
- 229,236,239,119,128, 30,113,239,237,237,225,225,227,227,229,238,
- 116,128, 1, 99,100, 2,185,106,185,116,233,229,242,229,243,233,
- 115,128, 30,151,239,116, 2,185,123,185,132,225,227,227,229,238,
- 116,128, 30,107,226,229,236,239,119,128, 30,109,101, 9,185,160,
- 185,171,185,191,186,201,186,226,187, 34,187,101,187,106,187,158,
- 227,249,242,233,236,236,233, 99,128, 4, 66,228,229,243,227,229,
- 238,228,229,242,227,249,242,233,236,236,233, 99,128, 4,173,104,
- 7,185,207,185,216,185,230,186, 14,186, 44,186, 85,186,183,225,
- 242,225,226,233, 99,128, 6, 42,230,233,238,225,236,225,242,225,
- 226,233, 99,128,254,150,232,225,232,105, 2,185,239,185,254,238,
- 233,244,233,225,236,225,242,225,226,233, 99,128,252,162,243,239,
- 236,225,244,229,228,225,242,225,226,233, 99,128,252, 12,105, 2,
- 186, 20,186, 35,238,233,244,233,225,236,225,242,225,226,233, 99,
- 128,254,151,242,225,231,225,238, 97,128, 48,102,234,229,229,237,
- 105, 2,186, 54,186, 69,238,233,244,233,225,236,225,242,225,226,
- 233, 99,128,252,161,243,239,236,225,244,229,228,225,242,225,226,
- 233, 99,128,252, 11,109, 2,186, 91,186,125,225,242,226,245,244,
- 97, 2,186,102,186,111,225,242,225,226,233, 99,128, 6, 41,230,
- 233,238,225,236,225,242,225,226,233, 99,128,254,148,101, 2,186,
- 131,186,144,228,233,225,236,225,242,225,226,233, 99,128,254,152,
- 229,237,105, 2,186,152,186,167,238,233,244,233,225,236,225,242,
- 225,226,233, 99,128,252,164,243,239,236,225,244,229,228,225,242,
- 225,226,233, 99,128,252, 14,238,239,239,238,230,233,238,225,236,
- 225,242,225,226,233, 99,128,252,115,235,225,244,225,235,225,238,
- 97,129, 48,198,186,214,232,225,236,230,247,233,228,244,104,128,
- 255,131,108, 2,186,232,186,251,229,240,232,239,238,101,129, 33,
- 33,186,243,226,236,225,227,107,128, 38, 14,233,243,232, 97, 2,
- 187, 4,187, 19,231,229,228,239,236,225,232,229,226,242,229,119,
- 128, 5,160,241,229,244,225,238,225,232,229,226,242,229,119,128,
- 5,169,110, 4,187, 44,187, 53,187, 72,187, 93,227,233,242,227,
- 236,101,128, 36,105,233,228,229,239,231,242,225,240,232,233,227,
- 240,225,242,229,110,128, 50, 41,112, 2,187, 78,187, 85,225,242,
- 229,110,128, 36,125,229,242,233,239,100,128, 36,145,242,239,237,
- 225,110,128, 33,121,243,104,128, 2,167,116,131, 5,216,187,116,
- 187,136,187,145,228,225,231,229,243,104,129,251, 56,187,127,232,
- 229,226,242,229,119,128,251, 56,232,229,226,242,229,119,128, 5,
- 216,243,229,227,249,242,233,236,236,233, 99,128, 4,181,246,233,
- 114, 2,187,166,187,175,232,229,226,242,229,119,128, 5,155,236,
- 229,230,244,232,229,226,242,229,119,128, 5,155,104, 6,187,202,
- 188, 98,188,220,189, 96,190, 3,191, 60, 97, 5,187,214,187,224,
- 187,231,188, 0,188, 29,226,229,238,231,225,236,105,128, 9,165,
- 228,229,246, 97,128, 9, 37,231,117, 2,187,238,187,247,234,225,
- 242,225,244,105,128, 10,165,242,237,245,235,232,105,128, 10, 37,
- 108, 2,188, 6,188, 15,225,242,225,226,233, 99,128, 6, 48,230,
- 233,238,225,236,225,242,225,226,233, 99,128,254,172,238,244,232,
- 225,235,232,225,116, 3,188, 44,188, 75,188, 82,236,239,119, 2,
- 188, 52,188, 63,236,229,230,244,244,232,225,105,128,248,152,242,
- 233,231,232,244,244,232,225,105,128,248,151,244,232,225,105,128,
- 14, 76,245,240,240,229,242,236,229,230,244,244,232,225,105,128,
- 248,150,101, 3,188,106,188,170,188,193,104, 4,188,116,188,125,
- 188,139,188,155,225,242,225,226,233, 99,128, 6, 43,230,233,238,
- 225,236,225,242,225,226,233, 99,128,254,154,233,238,233,244,233,
- 225,236,225,242,225,226,233, 99,128,254,155,237,229,228,233,225,
- 236,225,242,225,226,233, 99,128,254,156,242,101, 2,188,177,188,
- 186,229,248,233,243,244,115,128, 34, 3,230,239,242,101,128, 34,
- 52,244, 97,130, 3,184,188,202,188,206, 49,128, 3,209,243,249,
- 237,226,239,236,231,242,229,229,107,128, 3,209,105, 2,188,226,
- 189, 56,229,245,244,104, 4,188,239,189, 18,189, 33,189, 42, 97,
- 2,188,245,189, 4,227,233,242,227,236,229,235,239,242,229,225,
- 110,128, 50,121,240,225,242,229,238,235,239,242,229,225,110,128,
- 50, 25,227,233,242,227,236,229,235,239,242,229,225,110,128, 50,
- 107,235,239,242,229,225,110,128, 49, 76,240,225,242,229,238,235,
- 239,242,229,225,110,128, 50, 11,242,244,229,229,110, 2,189, 66,
- 189, 75,227,233,242,227,236,101,128, 36,108,112, 2,189, 81,189,
- 88,225,242,229,110,128, 36,128,229,242,233,239,100,128, 36,148,
- 111, 6,189,110,189,127,189,132,189,146,189,151,189,204,238,225,
- 238,231,237,239,238,244,232,239,244,232,225,105,128, 14, 17,239,
- 107,128, 1,173,240,232,245,244,232,225,239,244,232,225,105,128,
- 14, 18,242,110,128, 0,254,244,104, 3,189,160,189,184,189,194,
- 97, 2,189,166,189,176,232,225,238,244,232,225,105,128, 14, 23,
- 238,244,232,225,105,128, 14, 16,239,238,231,244,232,225,105,128,
- 14, 24,245,238,231,244,232,225,105,128, 14, 22,245,243,225,238,
- 100, 2,189,214,189,225,227,249,242,233,236,236,233, 99,128, 4,
- 130,243,243,229,240,225,242,225,244,239,114, 2,189,240,189,249,
- 225,242,225,226,233, 99,128, 6,108,240,229,242,243,233,225,110,
- 128, 6,108,242,229,101,144, 0, 51,190, 41,190, 50,190, 60,190,
- 90,190, 97,190,107,190,132,190,159,190,193,190,205,190,224,190,
- 235,191, 12,191, 34,191, 42,191, 53,225,242,225,226,233, 99,128,
- 6, 99,226,229,238,231,225,236,105,128, 9,233,227,233,242,227,
- 236,101,129, 36, 98,190, 71,233,238,246,229,242,243,229,243,225,
- 238,243,243,229,242,233,102,128, 39,140,228,229,246, 97,128, 9,
- 105,229,233,231,232,244,232,115,128, 33, 92,231,117, 2,190,114,
- 190,123,234,225,242,225,244,105,128, 10,233,242,237,245,235,232,
- 105,128, 10,105,232, 97, 2,190,139,190,150,227,235,225,242,225,
- 226,233, 99,128, 6, 99,238,231,250,232,239,117,128, 48, 35,105,
- 2,190,165,190,183,228,229,239,231,242,225,240,232,233,227,240,
- 225,242,229,110,128, 50, 34,238,230,229,242,233,239,114,128, 32,
- 131,237,239,238,239,243,240,225,227,101,128,255, 19,238,245,237,
- 229,242,225,244,239,242,226,229,238,231,225,236,105,128, 9,246,
- 239,236,228,243,244,249,236,101,128,247, 51,112, 2,190,241,190,
- 248,225,242,229,110,128, 36,118,229,114, 2,190,255,191, 5,233,
- 239,100,128, 36,138,243,233,225,110,128, 6,243,241,245,225,242,
- 244,229,242,115,129, 0,190,191, 25,229,237,228,225,243,104,128,
- 246,222,242,239,237,225,110,128, 33,114,243,245,240,229,242,233,
- 239,114,128, 0,179,244,232,225,105,128, 14, 83,250,243,241,245,
- 225,242,101,128, 51,148,105, 7,191, 86,191, 97,191,212,192, 54,
- 192, 66,192,115,192,132,232,233,242,225,231,225,238, 97,128, 48,
- 97,107, 2,191,103,191,127,225,244,225,235,225,238, 97,129, 48,
- 193,191,115,232,225,236,230,247,233,228,244,104,128,255,129,229,
- 245,116, 4,191,139,191,174,191,189,191,198, 97, 2,191,145,191,
- 160,227,233,242,227,236,229,235,239,242,229,225,110,128, 50,112,
- 240,225,242,229,238,235,239,242,229,225,110,128, 50, 16,227,233,
- 242,227,236,229,235,239,242,229,225,110,128, 50, 98,235,239,242,
- 229,225,110,128, 49, 55,240,225,242,229,238,235,239,242,229,225,
- 110,128, 50, 2,236,228,101,133, 2,220,191,228,191,239,192, 0,
- 192, 12,192, 40,226,229,236,239,247,227,237, 98,128, 3, 48, 99,
- 2,191,245,191,250,237, 98,128, 3, 3,239,237, 98,128, 3, 3,
- 228,239,245,226,236,229,227,237, 98,128, 3, 96,111, 2,192, 18,
- 192, 28,240,229,242,225,244,239,114,128, 34, 60,246,229,242,236,
- 225,249,227,237, 98,128, 3, 52,246,229,242,244,233,227,225,236,
- 227,237, 98,128, 3, 62,237,229,243,227,233,242,227,236,101,128,
- 34,151,112, 2,192, 72,192,102,229,232, 97, 2,192, 80,192, 89,
- 232,229,226,242,229,119,128, 5,150,236,229,230,244,232,229,226,
- 242,229,119,128, 5,150,240,233,231,245,242,237,245,235,232,105,
- 128, 10,112,244,236,239,227,249,242,233,236,236,233,227,227,237,
- 98,128, 4,131,247,238,225,242,237,229,238,233,225,110,128, 5,
- 127,236,233,238,229,226,229,236,239,119,128, 30,111,237,239,238,
- 239,243,240,225,227,101,128,255, 84,111, 7,192,185,192,196,192,
- 207,192,232,193, 96,193,108,193,192,225,242,237,229,238,233,225,
- 110,128, 5,105,232,233,242,225,231,225,238, 97,128, 48,104,235,
- 225,244,225,235,225,238, 97,129, 48,200,192,220,232,225,236,230,
- 247,233,228,244,104,128,255,132,110, 3,192,240,193, 82,193, 87,
- 101, 4,192,250,193, 63,193, 70,193, 76,226,225,114, 4,193, 6,
- 193, 35,193, 45,193, 54,229,248,244,242, 97, 2,193, 16,193, 26,
- 232,233,231,232,237,239,100,128, 2,229,236,239,247,237,239,100,
- 128, 2,233,232,233,231,232,237,239,100,128, 2,230,236,239,247,
- 237,239,100,128, 2,232,237,233,228,237,239,100,128, 2,231,230,
- 233,246,101,128, 1,189,243,233,120,128, 1,133,244,247,111,128,
- 1,168,239,115,128, 3,132,243,241,245,225,242,101,128, 51, 39,
- 240,225,244,225,235,244,232,225,105,128, 14, 15,242,244,239,233,
- 243,229,243,232,229,236,236,226,242,225,227,235,229,116, 2,193,
- 131,193,161,236,229,230,116,130, 48, 20,193,142,193,150,243,237,
- 225,236,108,128,254, 93,246,229,242,244,233,227,225,108,128,254,
- 57,242,233,231,232,116,130, 48, 21,193,173,193,181,243,237,225,
- 236,108,128,254, 94,246,229,242,244,233,227,225,108,128,254, 58,
- 244,225,239,244,232,225,105,128, 14, 21,240, 97, 2,193,209,193,
- 221,236,225,244,225,236,232,239,239,107,128, 1,171,242,229,110,
- 128, 36,175,114, 3,193,235,194, 10,194, 25,225,228,229,237,225,
- 242,107,129, 33, 34,193,247,115, 2,193,253,194, 3,225,238,115,
- 128,248,234,229,242,233,102,128,246,219,229,244,242,239,230,236,
- 229,248,232,239,239,107,128, 2,136,233,225,103, 4,194, 37,194,
- 42,194, 47,194, 52,228,110,128, 37,188,236,102,128, 37,196,242,
- 116,128, 37,186,245,112,128, 37,178,115,132, 2,166,194, 69,194,
- 108,194,214,194,227,225,228,105,130, 5,230,194, 79,194, 99,228,
- 225,231,229,243,104,129,251, 70,194, 90,232,229,226,242,229,119,
- 128,251, 70,232,229,226,242,229,119,128, 5,230,101, 2,194,114,
- 194,125,227,249,242,233,236,236,233, 99,128, 4, 70,242,101,134,
- 5,181,194,142,194,156,194,161,194,170,194,185,194,201, 49, 2,
- 194,148,194,152, 50,128, 5,181,101,128, 5,181,178, 98,128, 5,
- 181,232,229,226,242,229,119,128, 5,181,238,225,242,242,239,247,
- 232,229,226,242,229,119,128, 5,181,241,245,225,242,244,229,242,
- 232,229,226,242,229,119,128, 5,181,247,233,228,229,232,229,226,
- 242,229,119,128, 5,181,232,229,227,249,242,233,236,236,233, 99,
- 128, 4, 91,245,240,229,242,233,239,114,128,246,243,116, 4,194,
- 247,195, 41,195,106,195,157, 97, 3,194,255,195, 9,195, 16,226,
- 229,238,231,225,236,105,128, 9,159,228,229,246, 97,128, 9, 31,
- 231,117, 2,195, 23,195, 32,234,225,242,225,244,105,128, 10,159,
- 242,237,245,235,232,105,128, 10, 31,229,104, 4,195, 52,195, 61,
- 195, 75,195, 91,225,242,225,226,233, 99,128, 6,121,230,233,238,
- 225,236,225,242,225,226,233, 99,128,251,103,233,238,233,244,233,
- 225,236,225,242,225,226,233, 99,128,251,104,237,229,228,233,225,
- 236,225,242,225,226,233, 99,128,251,105,232, 97, 3,195,115,195,
- 125,195,132,226,229,238,231,225,236,105,128, 9,160,228,229,246,
- 97,128, 9, 32,231,117, 2,195,139,195,148,234,225,242,225,244,
- 105,128, 10,160,242,237,245,235,232,105,128, 10, 32,245,242,238,
- 229,100,128, 2,135,117, 3,195,173,195,184,195,209,232,233,242,
- 225,231,225,238, 97,128, 48,100,235,225,244,225,235,225,238, 97,
- 129, 48,196,195,197,232,225,236,230,247,233,228,244,104,128,255,
- 130,243,237,225,236,108, 2,195,219,195,230,232,233,242,225,231,
- 225,238, 97,128, 48, 99,235,225,244,225,235,225,238, 97,129, 48,
- 195,195,243,232,225,236,230,247,233,228,244,104,128,255,111,119,
- 2,196, 5,196,110,101, 2,196, 11,196, 59,236,246,101, 3,196,
- 21,196, 30,196, 51,227,233,242,227,236,101,128, 36,107,112, 2,
- 196, 36,196, 43,225,242,229,110,128, 36,127,229,242,233,239,100,
- 128, 36,147,242,239,237,225,110,128, 33,123,238,244,121, 3,196,
- 69,196, 78,196, 89,227,233,242,227,236,101,128, 36,115,232,225,
- 238,231,250,232,239,117,128, 83, 68,112, 2,196, 95,196,102,225,
- 242,229,110,128, 36,135,229,242,233,239,100,128, 36,155,111,142,
- 0, 50,196,142,196,151,196,161,196,191,196,243,197, 12,197, 39,
- 197, 73,197, 85,197,104,197,115,197,148,197,156,197,180,225,242,
- 225,226,233, 99,128, 6, 98,226,229,238,231,225,236,105,128, 9,
- 232,227,233,242,227,236,101,129, 36, 97,196,172,233,238,246,229,
- 242,243,229,243,225,238,243,243,229,242,233,102,128, 39,139,100,
- 2,196,197,196,203,229,246, 97,128, 9,104,239,116, 2,196,210,
- 196,221,229,238,236,229,225,228,229,114,128, 32, 37,236,229,225,
- 228,229,114,129, 32, 37,196,232,246,229,242,244,233,227,225,108,
- 128,254, 48,231,117, 2,196,250,197, 3,234,225,242,225,244,105,
- 128, 10,232,242,237,245,235,232,105,128, 10,104,232, 97, 2,197,
- 19,197, 30,227,235,225,242,225,226,233, 99,128, 6, 98,238,231,
- 250,232,239,117,128, 48, 34,105, 2,197, 45,197, 63,228,229,239,
- 231,242,225,240,232,233,227,240,225,242,229,110,128, 50, 33,238,
- 230,229,242,233,239,114,128, 32,130,237,239,238,239,243,240,225,
- 227,101,128,255, 18,238,245,237,229,242,225,244,239,242,226,229,
- 238,231,225,236,105,128, 9,245,239,236,228,243,244,249,236,101,
- 128,247, 50,112, 2,197,121,197,128,225,242,229,110,128, 36,117,
- 229,114, 2,197,135,197,141,233,239,100,128, 36,137,243,233,225,
- 110,128, 6,242,242,239,237,225,110,128, 33,113,115, 2,197,162,
- 197,170,244,242,239,235,101,128, 1,187,245,240,229,242,233,239,
- 114,128, 0,178,244,104, 2,197,187,197,192,225,105,128, 14, 82,
- 233,242,228,115,128, 33, 84,117,145, 0,117,197,237,197,245,198,
- 30,198, 87,198,225,199, 6,199,129,199,145,199,196,200, 10,200,
- 91,200,100,200,219,200,243,201, 95,201,123,201,237,225,227,245,
- 244,101,128, 0,250, 98, 4,197,255,198, 4,198, 13,198, 23,225,
- 114,128, 2,137,229,238,231,225,236,105,128, 9,137,239,240,239,
- 237,239,230,111,128, 49, 40,242,229,246,101,128, 1,109, 99, 3,
- 198, 38,198, 45,198, 77,225,242,239,110,128, 1,212,233,242, 99,
- 2,198, 53,198, 58,236,101,128, 36,228,245,237,230,236,229,120,
- 129, 0,251,198, 69,226,229,236,239,119,128, 30,119,249,242,233,
- 236,236,233, 99,128, 4, 67,100, 5,198, 99,198,110,198,133,198,
- 139,198,215,225,244,244,225,228,229,246, 97,128, 9, 81,226,108,
- 2,198,117,198,125,225,227,245,244,101,128, 1,113,231,242,225,
- 246,101,128, 2, 21,229,246, 97,128, 9, 9,233,229,242,229,243,
- 233,115,133, 0,252,198,159,198,167,198,175,198,198,198,206,225,
- 227,245,244,101,128, 1,216,226,229,236,239,119,128, 30,115, 99,
- 2,198,181,198,188,225,242,239,110,128, 1,218,249,242,233,236,
- 236,233, 99,128, 4,241,231,242,225,246,101,128, 1,220,237,225,
- 227,242,239,110,128, 1,214,239,244,226,229,236,239,119,128, 30,
- 229,103, 2,198,231,198,238,242,225,246,101,128, 0,249,117, 2,
- 198,244,198,253,234,225,242,225,244,105,128, 10,137,242,237,245,
- 235,232,105,128, 10, 9,104, 3,199, 14,199, 24,199,102,233,242,
- 225,231,225,238, 97,128, 48, 70,111, 2,199, 30,199, 40,239,235,
- 225,226,239,246,101,128, 30,231,242,110,133, 1,176,199, 55,199,
- 63,199, 74,199, 82,199, 94,225,227,245,244,101,128, 30,233,228,
- 239,244,226,229,236,239,119,128, 30,241,231,242,225,246,101,128,
- 30,235,232,239,239,235,225,226,239,246,101,128, 30,237,244,233,
- 236,228,101,128, 30,239,245,238,231,225,242,245,237,236,225,245,
- 116,129, 1,113,199,118,227,249,242,233,236,236,233, 99,128, 4,
- 243,233,238,246,229,242,244,229,228,226,242,229,246,101,128, 2,
- 23,107, 3,199,153,199,177,199,188,225,244,225,235,225,238, 97,
- 129, 48,166,199,165,232,225,236,230,247,233,228,244,104,128,255,
- 115,227,249,242,233,236,236,233, 99,128, 4,121,239,242,229,225,
- 110,128, 49, 92,109, 2,199,202,199,255, 97, 2,199,208,199,241,
- 227,242,239,110,130, 1,107,199,219,199,230,227,249,242,233,236,
- 236,233, 99,128, 4,239,228,233,229,242,229,243,233,115,128, 30,
- 123,244,242,225,231,245,242,237,245,235,232,105,128, 10, 65,239,
- 238,239,243,240,225,227,101,128,255, 85,110, 2,200, 16,200, 71,
- 228,229,242,243,227,239,242,101,132, 0, 95,200, 35,200, 41,200,
- 53,200, 64,228,226,108,128, 32, 23,237,239,238,239,243,240,225,
- 227,101,128,255, 63,246,229,242,244,233,227,225,108,128,254, 51,
- 247,225,246,121,128,254, 79,105, 2,200, 77,200, 82,239,110,128,
- 34, 42,246,229,242,243,225,108,128, 34, 0,239,231,239,238,229,
- 107,128, 1,115,112, 5,200,112,200,119,200,127,200,142,200,193,
- 225,242,229,110,128, 36,176,226,236,239,227,107,128, 37,128,240,
- 229,242,228,239,244,232,229,226,242,229,119,128, 5,196,243,233,
- 236,239,110,131, 3,197,200,156,200,177,200,185,228,233,229,242,
- 229,243,233,115,129, 3,203,200,169,244,239,238,239,115,128, 3,
- 176,236,225,244,233,110,128, 2,138,244,239,238,239,115,128, 3,
- 205,244,225,227,107, 2,200,202,200,213,226,229,236,239,247,227,
- 237, 98,128, 3, 29,237,239,100,128, 2,212,114, 2,200,225,200,
- 237,225,231,245,242,237,245,235,232,105,128, 10,115,233,238,103,
- 128, 1,111,115, 3,200,251,201, 10,201, 55,232,239,242,244,227,
- 249,242,233,236,236,233, 99,128, 4, 94,237,225,236,108, 2,201,
- 19,201, 30,232,233,242,225,231,225,238, 97,128, 48, 69,235,225,
- 244,225,235,225,238, 97,129, 48,165,201, 43,232,225,236,230,247,
- 233,228,244,104,128,255,105,244,242,225,233,231,232,116, 2,201,
- 67,201, 78,227,249,242,233,236,236,233, 99,128, 4,175,243,244,
- 242,239,235,229,227,249,242,233,236,236,233, 99,128, 4,177,244,
- 233,236,228,101,130, 1,105,201,107,201,115,225,227,245,244,101,
- 128, 30,121,226,229,236,239,119,128, 30,117,117, 5,201,135,201,
- 145,201,152,201,177,201,193,226,229,238,231,225,236,105,128, 9,
- 138,228,229,246, 97,128, 9, 10,231,117, 2,201,159,201,168,234,
- 225,242,225,244,105,128, 10,138,242,237,245,235,232,105,128, 10,
- 10,237,225,244,242,225,231,245,242,237,245,235,232,105,128, 10,
- 66,246,239,247,229,236,243,233,231,110, 3,201,209,201,219,201,
- 226,226,229,238,231,225,236,105,128, 9,194,228,229,246, 97,128,
- 9, 66,231,245,234,225,242,225,244,105,128, 10,194,246,239,247,
- 229,236,243,233,231,110, 3,201,253,202, 7,202, 14,226,229,238,
- 231,225,236,105,128, 9,193,228,229,246, 97,128, 9, 65,231,245,
- 234,225,242,225,244,105,128, 10,193,118,139, 0,118,202, 51,202,
- 199,202,208,202,219,203,148,203,155,203,253,204, 9,204,109,204,
- 117,204,138, 97, 4,202, 61,202, 68,202, 93,202,104,228,229,246,
- 97,128, 9, 53,231,117, 2,202, 75,202, 84,234,225,242,225,244,
- 105,128, 10,181,242,237,245,235,232,105,128, 10, 53,235,225,244,
- 225,235,225,238, 97,128, 48,247,118,132, 5,213,202,116,202,143,
- 202,175,202,187,228,225,231,229,243,104,130,251, 53,202,129,202,
- 134,182, 53,128,251, 53,232,229,226,242,229,119,128,251, 53,104,
- 2,202,149,202,157,229,226,242,229,119,128, 5,213,239,236,225,
- 109,129,251, 75,202,166,232,229,226,242,229,119,128,251, 75,246,
- 225,246,232,229,226,242,229,119,128, 5,240,249,239,228,232,229,
- 226,242,229,119,128, 5,241,227,233,242,227,236,101,128, 36,229,
- 228,239,244,226,229,236,239,119,128, 30,127,101, 6,202,233,202,
- 244,203, 52,203, 63,203, 69,203,136,227,249,242,233,236,236,233,
- 99,128, 4, 50,104, 4,202,254,203, 7,203, 21,203, 37,225,242,
- 225,226,233, 99,128, 6,164,230,233,238,225,236,225,242,225,226,
- 233, 99,128,251,107,233,238,233,244,233,225,236,225,242,225,226,
- 233, 99,128,251,108,237,229,228,233,225,236,225,242,225,226,233,
- 99,128,251,109,235,225,244,225,235,225,238, 97,128, 48,249,238,
- 245,115,128, 38, 64,242,244,233,227,225,108, 2,203, 80,203, 86,
- 226,225,114,128, 0,124,236,233,238,101, 4,203, 99,203,110,203,
- 121,203,130,225,226,239,246,229,227,237, 98,128, 3, 13,226,229,
- 236,239,247,227,237, 98,128, 3, 41,236,239,247,237,239,100,128,
- 2,204,237,239,100,128, 2,200,247,225,242,237,229,238,233,225,
- 110,128, 5,126,232,239,239,107,128, 2,139,105, 3,203,163,203,
- 174,203,213,235,225,244,225,235,225,238, 97,128, 48,248,242,225,
- 237, 97, 3,203,185,203,195,203,202,226,229,238,231,225,236,105,
- 128, 9,205,228,229,246, 97,128, 9, 77,231,245,234,225,242,225,
- 244,105,128, 10,205,243,225,242,231, 97, 3,203,225,203,235,203,
- 242,226,229,238,231,225,236,105,128, 9,131,228,229,246, 97,128,
- 9, 3,231,245,234,225,242,225,244,105,128, 10,131,237,239,238,
- 239,243,240,225,227,101,128,255, 86,111, 3,204, 17,204, 28,204,
- 98,225,242,237,229,238,233,225,110,128, 5,120,233,227,229,100,
- 2,204, 37,204, 73,233,244,229,242,225,244,233,239,110, 2,204,
- 51,204, 62,232,233,242,225,231,225,238, 97,128, 48,158,235,225,
- 244,225,235,225,238, 97,128, 48,254,237,225,242,235,235,225,238,
- 97,129, 48,155,204, 86,232,225,236,230,247,233,228,244,104,128,
- 255,158,235,225,244,225,235,225,238, 97,128, 48,250,240,225,242,
- 229,110,128, 36,177,116, 2,204,123,204,130,233,236,228,101,128,
- 30,125,245,242,238,229,100,128, 2,140,117, 2,204,144,204,155,
- 232,233,242,225,231,225,238, 97,128, 48,148,235,225,244,225,235,
- 225,238, 97,128, 48,244,119,143, 0,119,204,200,205,177,205,187,
- 205,210,205,250,206, 61,206, 69,208, 40,208, 81,208, 93,208,168,
- 208,176,208,183,208,194,208,203, 97, 8,204,218,204,225,204,235,
- 204,246,205, 28,205, 60,205, 72,205,108,227,245,244,101,128, 30,
- 131,229,235,239,242,229,225,110,128, 49, 89,232,233,242,225,231,
- 225,238, 97,128, 48,143,107, 2,204,252,205, 20,225,244,225,235,
- 225,238, 97,129, 48,239,205, 8,232,225,236,230,247,233,228,244,
- 104,128,255,156,239,242,229,225,110,128, 49, 88,243,237,225,236,
- 108, 2,205, 38,205, 49,232,233,242,225,231,225,238, 97,128, 48,
- 142,235,225,244,225,235,225,238, 97,128, 48,238,244,244,239,243,
- 241,245,225,242,101,128, 51, 87,118, 2,205, 78,205, 86,229,228,
- 225,243,104,128, 48, 28,249,245,238,228,229,242,243,227,239,242,
- 229,246,229,242,244,233,227,225,108,128,254, 52,119, 3,205,116,
- 205,125,205,139,225,242,225,226,233, 99,128, 6, 72,230,233,238,
- 225,236,225,242,225,226,233, 99,128,254,238,232,225,237,250,225,
- 225,226,239,246,101, 2,205,154,205,163,225,242,225,226,233, 99,
- 128, 6, 36,230,233,238,225,236,225,242,225,226,233, 99,128,254,
- 134,226,243,241,245,225,242,101,128, 51,221,227,233,242, 99, 2,
- 205,196,205,201,236,101,128, 36,230,245,237,230,236,229,120,128,
- 1,117,100, 2,205,216,205,226,233,229,242,229,243,233,115,128,
- 30,133,239,116, 2,205,233,205,242,225,227,227,229,238,116,128,
- 30,135,226,229,236,239,119,128, 30,137,101, 4,206, 4,206, 15,
- 206, 27,206, 51,232,233,242,225,231,225,238, 97,128, 48,145,233,
- 229,242,243,244,242,225,243,115,128, 33, 24,107, 2,206, 33,206,
- 43,225,244,225,235,225,238, 97,128, 48,241,239,242,229,225,110,
- 128, 49, 94,239,235,239,242,229,225,110,128, 49, 93,231,242,225,
- 246,101,128, 30,129,232,233,244,101, 8,206, 90,206, 99,206,183,
- 207, 17,207,101,207,146,207,198,207,254,226,245,236,236,229,116,
- 128, 37,230, 99, 2,206,105,206,125,233,242,227,236,101,129, 37,
- 203,206,115,233,238,246,229,242,243,101,128, 37,217,239,242,238,
- 229,242,226,242,225,227,235,229,116, 2,206,142,206,162,236,229,
- 230,116,129, 48, 14,206,151,246,229,242,244,233,227,225,108,128,
- 254, 67,242,233,231,232,116,129, 48, 15,206,172,246,229,242,244,
- 233,227,225,108,128,254, 68,100, 2,206,189,206,230,233,225,237,
- 239,238,100,129, 37,199,206,200,227,239,238,244,225,233,238,233,
- 238,231,226,236,225,227,235,243,237,225,236,236,228,233,225,237,
- 239,238,100,128, 37,200,239,247,238,240,239,233,238,244,233,238,
- 103, 2,206,246,207, 6,243,237,225,236,236,244,242,233,225,238,
- 231,236,101,128, 37,191,244,242,233,225,238,231,236,101,128, 37,
- 189,236,101, 2,207, 24,207, 66,230,244,240,239,233,238,244,233,
- 238,103, 2,207, 39,207, 55,243,237,225,236,236,244,242,233,225,
- 238,231,236,101,128, 37,195,244,242,233,225,238,231,236,101,128,
- 37,193,238,244,233,227,245,236,225,242,226,242,225,227,235,229,
- 116, 2,207, 86,207, 93,236,229,230,116,128, 48, 22,242,233,231,
- 232,116,128, 48, 23,242,233,231,232,244,240,239,233,238,244,233,
- 238,103, 2,207,119,207,135,243,237,225,236,236,244,242,233,225,
- 238,231,236,101,128, 37,185,244,242,233,225,238,231,236,101,128,
- 37,183,115, 3,207,154,207,184,207,192,109, 2,207,160,207,172,
- 225,236,236,243,241,245,225,242,101,128, 37,171,233,236,233,238,
- 231,230,225,227,101,128, 38, 58,241,245,225,242,101,128, 37,161,
- 244,225,114,128, 38, 6,116, 2,207,204,207,215,229,236,229,240,
- 232,239,238,101,128, 38, 15,239,242,244,239,233,243,229,243,232,
- 229,236,236,226,242,225,227,235,229,116, 2,207,239,207,246,236,
- 229,230,116,128, 48, 24,242,233,231,232,116,128, 48, 25,245,240,
- 240,239,233,238,244,233,238,103, 2,208, 13,208, 29,243,237,225,
- 236,236,244,242,233,225,238,231,236,101,128, 37,181,244,242,233,
- 225,238,231,236,101,128, 37,179,105, 2,208, 46,208, 57,232,233,
- 242,225,231,225,238, 97,128, 48,144,107, 2,208, 63,208, 73,225,
- 244,225,235,225,238, 97,128, 48,240,239,242,229,225,110,128, 49,
- 95,237,239,238,239,243,240,225,227,101,128,255, 87,111, 4,208,
- 103,208,114,208,139,208,157,232,233,242,225,231,225,238, 97,128,
- 48,146,235,225,244,225,235,225,238, 97,129, 48,242,208,127,232,
- 225,236,230,247,233,228,244,104,128,255,102,110,129, 32,169,208,
- 145,237,239,238,239,243,240,225,227,101,128,255,230,247,225,229,
- 238,244,232,225,105,128, 14, 39,240,225,242,229,110,128, 36,178,
- 242,233,238,103,128, 30,152,243,245,240,229,242,233,239,114,128,
- 2,183,244,245,242,238,229,100,128, 2,141,249,238,110,128, 1,
- 191,120,137, 0,120,208,231,208,242,208,253,209, 6,209, 33,209,
- 46,209, 50,209, 62,209, 70,225,226,239,246,229,227,237, 98,128,
- 3, 61,226,239,240,239,237,239,230,111,128, 49, 18,227,233,242,
- 227,236,101,128, 36,231,100, 2,209, 12,209, 22,233,229,242,229,
- 243,233,115,128, 30,141,239,244,225,227,227,229,238,116,128, 30,
- 139,229,232,225,242,237,229,238,233,225,110,128, 5,109,105,128,
- 3,190,237,239,238,239,243,240,225,227,101,128,255, 88,240,225,
- 242,229,110,128, 36,179,243,245,240,229,242,233,239,114,128, 2,
- 227,121,143, 0,121,209,115,210, 74,210, 97,210,137,212,103,212,
- 111,212,128,212,192,212,204,213,201,213,241,213,253,214, 8,214,
- 29,215, 2, 97, 11,209,139,209,151,209,161,209,168,209,175,209,
- 185,209,210,209,221,210, 3,210, 16,210, 62,225,228,239,243,241,
- 245,225,242,101,128, 51, 78,226,229,238,231,225,236,105,128, 9,
- 175,227,245,244,101,128, 0,253,228,229,246, 97,128, 9, 47,229,
- 235,239,242,229,225,110,128, 49, 82,231,117, 2,209,192,209,201,
- 234,225,242,225,244,105,128, 10,175,242,237,245,235,232,105,128,
- 10, 47,232,233,242,225,231,225,238, 97,128, 48,132,107, 2,209,
- 227,209,251,225,244,225,235,225,238, 97,129, 48,228,209,239,232,
- 225,236,230,247,233,228,244,104,128,255,148,239,242,229,225,110,
- 128, 49, 81,237,225,235,235,225,238,244,232,225,105,128, 14, 78,
- 243,237,225,236,108, 2,210, 26,210, 37,232,233,242,225,231,225,
- 238, 97,128, 48,131,235,225,244,225,235,225,238, 97,129, 48,227,
- 210, 50,232,225,236,230,247,233,228,244,104,128,255,108,244,227,
- 249,242,233,236,236,233, 99,128, 4, 99,227,233,242, 99, 2,210,
- 83,210, 88,236,101,128, 36,232,245,237,230,236,229,120,128, 1,
- 119,100, 2,210,103,210,113,233,229,242,229,243,233,115,128, 0,
- 255,239,116, 2,210,120,210,129,225,227,227,229,238,116,128, 30,
- 143,226,229,236,239,119,128, 30,245,101, 7,210,153,211,161,211,
- 170,211,188,211,220,212, 40,212, 91,104, 8,210,171,210,180,210,
- 214,210,228,211, 45,211, 61,211,120,211,138,225,242,225,226,233,
- 99,128, 6, 74,226,225,242,242,229,101, 2,210,191,210,200,225,
- 242,225,226,233, 99,128, 6,210,230,233,238,225,236,225,242,225,
- 226,233, 99,128,251,175,230,233,238,225,236,225,242,225,226,233,
- 99,128,254,242,232,225,237,250,225,225,226,239,246,101, 4,210,
- 247,211, 0,211, 14,211, 30,225,242,225,226,233, 99,128, 6, 38,
- 230,233,238,225,236,225,242,225,226,233, 99,128,254,138,233,238,
- 233,244,233,225,236,225,242,225,226,233, 99,128,254,139,237,229,
- 228,233,225,236,225,242,225,226,233, 99,128,254,140,233,238,233,
- 244,233,225,236,225,242,225,226,233, 99,128,254,243,237,101, 2,
- 211, 68,211, 81,228,233,225,236,225,242,225,226,233, 99,128,254,
- 244,229,237,105, 2,211, 89,211,104,238,233,244,233,225,236,225,
- 242,225,226,233, 99,128,252,221,243,239,236,225,244,229,228,225,
- 242,225,226,233, 99,128,252, 88,238,239,239,238,230,233,238,225,
- 236,225,242,225,226,233, 99,128,252,148,244,232,242,229,229,228,
- 239,244,243,226,229,236,239,247,225,242,225,226,233, 99,128, 6,
- 209,235,239,242,229,225,110,128, 49, 86,110,129, 0,165,211,176,
- 237,239,238,239,243,240,225,227,101,128,255,229,111, 2,211,194,
- 211,203,235,239,242,229,225,110,128, 49, 85,242,233,238,232,233,
- 229,245,232,235,239,242,229,225,110,128, 49,134,114, 3,211,228,
- 212, 8,212, 20,225,232,226,229,238,249,239,237,111, 2,211,242,
- 211,251,232,229,226,242,229,119,128, 5,170,236,229,230,244,232,
- 229,226,242,229,119,128, 5,170,233,227,249,242,233,236,236,233,
- 99,128, 4, 75,245,228,233,229,242,229,243,233,243,227,249,242,
- 233,236,236,233, 99,128, 4,249,243,233,229,245,238,103, 3,212,
- 53,212, 62,212, 78,235,239,242,229,225,110,128, 49,129,240,225,
- 238,243,233,239,243,235,239,242,229,225,110,128, 49,131,243,233,
- 239,243,235,239,242,229,225,110,128, 49,130,244,233,246,232,229,
- 226,242,229,119,128, 5,154,231,242,225,246,101,128, 30,243,232,
- 239,239,107,129, 1,180,212,120,225,226,239,246,101,128, 30,247,
- 105, 5,212,140,212,151,212,162,212,171,212,179,225,242,237,229,
- 238,233,225,110,128, 5,117,227,249,242,233,236,236,233, 99,128,
- 4, 87,235,239,242,229,225,110,128, 49, 98,238,249,225,238,103,
- 128, 38, 47,247,238,225,242,237,229,238,233,225,110,128, 5,130,
- 237,239,238,239,243,240,225,227,101,128,255, 89,111, 7,212,220,
- 213, 34,213, 45,213, 55,213, 93,213,139,213,148,100,131, 5,217,
- 212,230,212,250,213, 3,228,225,231,229,243,104,129,251, 57,212,
- 241,232,229,226,242,229,119,128,251, 57,232,229,226,242,229,119,
- 128, 5,217,249,239,100, 2,213, 11,213, 20,232,229,226,242,229,
- 119,128, 5,242,240,225,244,225,232,232,229,226,242,229,119,128,
- 251, 31,232,233,242,225,231,225,238, 97,128, 48,136,233,235,239,
- 242,229,225,110,128, 49,137,107, 2,213, 61,213, 85,225,244,225,
- 235,225,238, 97,129, 48,232,213, 73,232,225,236,230,247,233,228,
- 244,104,128,255,150,239,242,229,225,110,128, 49, 91,243,237,225,
- 236,108, 2,213,103,213,114,232,233,242,225,231,225,238, 97,128,
- 48,135,235,225,244,225,235,225,238, 97,129, 48,231,213,127,232,
- 225,236,230,247,233,228,244,104,128,255,110,244,231,242,229,229,
- 107,128, 3,243,121, 2,213,154,213,191, 97, 2,213,160,213,170,
- 229,235,239,242,229,225,110,128, 49,136,107, 2,213,176,213,184,
- 239,242,229,225,110,128, 49,135,244,232,225,105,128, 14, 34,233,
- 238,231,244,232,225,105,128, 14, 13,112, 2,213,207,213,214,225,
- 242,229,110,128, 36,180,239,231,229,231,242,225,237,237,229,238,
- 105,129, 3,122,213,230,231,242,229,229,235,227,237, 98,128, 3,
- 69,114,129, 1,166,213,247,233,238,103,128, 30,153,243,245,240,
- 229,242,233,239,114,128, 2,184,116, 2,214, 14,214, 21,233,236,
- 228,101,128, 30,249,245,242,238,229,100,128, 2,142,117, 5,214,
- 41,214, 52,214, 62,214,100,214,232,232,233,242,225,231,225,238,
- 97,128, 48,134,233,235,239,242,229,225,110,128, 49,140,107, 2,
- 214, 68,214, 92,225,244,225,235,225,238, 97,129, 48,230,214, 80,
- 232,225,236,230,247,233,228,244,104,128,255,149,239,242,229,225,
- 110,128, 49, 96,115, 3,214,108,214,146,214,187,226,233,103, 2,
- 214,116,214,127,227,249,242,233,236,236,233, 99,128, 4,107,233,
- 239,244,233,230,233,229,228,227,249,242,233,236,236,233, 99,128,
- 4,109,236,233,244,244,236,101, 2,214,157,214,168,227,249,242,
- 233,236,236,233, 99,128, 4,103,233,239,244,233,230,233,229,228,
- 227,249,242,233,236,236,233, 99,128, 4,105,237,225,236,108, 2,
- 214,196,214,207,232,233,242,225,231,225,238, 97,128, 48,133,235,
- 225,244,225,235,225,238, 97,129, 48,229,214,220,232,225,236,230,
- 247,233,228,244,104,128,255,109,249,101, 2,214,239,214,248,235,
- 239,242,229,225,110,128, 49,139,239,235,239,242,229,225,110,128,
- 49,138,249, 97, 2,215, 9,215, 19,226,229,238,231,225,236,105,
- 128, 9,223,228,229,246, 97,128, 9, 95,122,142, 0,122,215, 58,
- 216, 66,216, 77,216,120,216,147,217,182,218, 34,218, 76,218, 88,
- 218,100,218,128,218,136,218,152,218,161, 97, 10,215, 80,215, 91,
- 215, 98,215,105,215,116,215,194,215,224,215,235,216, 15,216, 27,
- 225,242,237,229,238,233,225,110,128, 5,102,227,245,244,101,128,
- 1,122,228,229,246, 97,128, 9, 91,231,245,242,237,245,235,232,
- 105,128, 10, 91,104, 4,215,126,215,135,215,149,215,179,225,242,
- 225,226,233, 99,128, 6, 56,230,233,238,225,236,225,242,225,226,
- 233, 99,128,254,198,105, 2,215,155,215,170,238,233,244,233,225,
- 236,225,242,225,226,233, 99,128,254,199,242,225,231,225,238, 97,
- 128, 48, 86,237,229,228,233,225,236,225,242,225,226,233, 99,128,
- 254,200,233,110, 2,215,201,215,210,225,242,225,226,233, 99,128,
- 6, 50,230,233,238,225,236,225,242,225,226,233, 99,128,254,176,
- 235,225,244,225,235,225,238, 97,128, 48,182,241,229,102, 2,215,
- 243,216, 1,231,225,228,239,236,232,229,226,242,229,119,128, 5,
- 149,241,225,244,225,238,232,229,226,242,229,119,128, 5,148,242,
- 241,225,232,229,226,242,229,119,128, 5,152,249,233,110,130, 5,
- 214,216, 37,216, 57,228,225,231,229,243,104,129,251, 54,216, 48,
- 232,229,226,242,229,119,128,251, 54,232,229,226,242,229,119,128,
- 5,214,226,239,240,239,237,239,230,111,128, 49, 23, 99, 3,216,
- 85,216, 92,216,114,225,242,239,110,128, 1,126,233,242, 99, 2,
- 216,100,216,105,236,101,128, 36,233,245,237,230,236,229,120,128,
- 30,145,245,242,108,128, 2,145,228,239,116,130, 1,124,216,130,
- 216,139,225,227,227,229,238,116,128, 1,124,226,229,236,239,119,
- 128, 30,147,101, 6,216,161,216,172,216,215,216,226,216,237,217,
- 177,227,249,242,233,236,236,233, 99,128, 4, 55,100, 2,216,178,
- 216,197,229,243,227,229,238,228,229,242,227,249,242,233,236,236,
- 233, 99,128, 4,153,233,229,242,229,243,233,243,227,249,242,233,
- 236,236,233, 99,128, 4,223,232,233,242,225,231,225,238, 97,128,
- 48, 92,235,225,244,225,235,225,238, 97,128, 48,188,242,111,140,
- 0, 48,217, 10,217, 19,217, 29,217, 36,217, 61,217, 74,217, 85,
- 217, 97,217,108,217,118,217,129,217,136,225,242,225,226,233, 99,
- 128, 6, 96,226,229,238,231,225,236,105,128, 9,230,228,229,246,
- 97,128, 9,102,231,117, 2,217, 43,217, 52,234,225,242,225,244,
- 105,128, 10,230,242,237,245,235,232,105,128, 10,102,232,225,227,
- 235,225,242,225,226,233, 99,128, 6, 96,233,238,230,229,242,233,
- 239,114,128, 32,128,237,239,238,239,243,240,225,227,101,128,255,
- 16,239,236,228,243,244,249,236,101,128,247, 48,240,229,242,243,
- 233,225,110,128, 6,240,243,245,240,229,242,233,239,114,128, 32,
- 112,244,232,225,105,128, 14, 80,247,233,228,244,104, 3,217,148,
- 217,157,217,169,234,239,233,238,229,114,128,254,255,238,239,238,
- 234,239,233,238,229,114,128, 32, 12,243,240,225,227,101,128, 32,
- 11,244, 97,128, 3,182,104, 2,217,188,217,199,226,239,240,239,
- 237,239,230,111,128, 49, 19,101, 4,217,209,217,220,217,236,217,
- 247,225,242,237,229,238,233,225,110,128, 5,106,226,242,229,246,
- 229,227,249,242,233,236,236,233, 99,128, 4,194,227,249,242,233,
- 236,236,233, 99,128, 4, 54,100, 2,217,253,218, 16,229,243,227,
- 229,238,228,229,242,227,249,242,233,236,236,233, 99,128, 4,151,
- 233,229,242,229,243,233,243,227,249,242,233,236,236,233, 99,128,
- 4,221,105, 3,218, 42,218, 53,218, 64,232,233,242,225,231,225,
- 238, 97,128, 48, 88,235,225,244,225,235,225,238, 97,128, 48,184,
- 238,239,242,232,229,226,242,229,119,128, 5,174,236,233,238,229,
- 226,229,236,239,119,128, 30,149,237,239,238,239,243,240,225,227,
- 101,128,255, 90,111, 2,218,106,218,117,232,233,242,225,231,225,
- 238, 97,128, 48, 94,235,225,244,225,235,225,238, 97,128, 48,190,
- 240,225,242,229,110,128, 36,181,242,229,244,242,239,230,236,229,
- 248,232,239,239,107,128, 2,144,243,244,242,239,235,101,128, 1,
- 182,117, 2,218,167,218,178,232,233,242,225,231,225,238, 97,128,
- 48, 90,235,225,244,225,235,225,238, 97,128, 48,186
- }
-#endif /* DEFINE_PS_TABLES_DATA */
- ;
-
-
-#ifdef DEFINE_PS_TABLES
- /*
- * This function searches the compressed table efficiently.
- */
- static unsigned long
- ft_get_adobe_glyph_index( const char* name,
- const char* limit )
- {
- int c = 0;
- int count, min, max;
- const unsigned char* p = ft_adobe_glyph_list;
-
-
- if ( name == 0 || name >= limit )
- goto NotFound;
-
- c = *name++;
- count = p[1];
- p += 2;
-
- min = 0;
- max = count;
-
- while ( min < max )
- {
- int mid = ( min + max ) >> 1;
- const unsigned char* q = p + mid * 2;
- int c2;
-
-
- q = ft_adobe_glyph_list + ( ( (int)q[0] << 8 ) | q[1] );
-
- c2 = q[0] & 127;
- if ( c2 == c )
- {
- p = q;
- goto Found;
- }
- if ( c2 < c )
- min = mid + 1;
- else
- max = mid;
- }
- goto NotFound;
-
- Found:
- for (;;)
- {
- /* assert (*p & 127) == c */
-
- if ( name >= limit )
- {
- if ( (p[0] & 128) == 0 &&
- (p[1] & 128) != 0 )
- return (unsigned long)( ( (int)p[2] << 8 ) | p[3] );
-
- goto NotFound;
- }
- c = *name++;
- if ( p[0] & 128 )
- {
- p++;
- if ( c != (p[0] & 127) )
- goto NotFound;
-
- continue;
- }
-
- p++;
- count = p[0] & 127;
- if ( p[0] & 128 )
- p += 2;
-
- p++;
-
- for ( ; count > 0; count--, p += 2 )
- {
- int offset = ( (int)p[0] << 8 ) | p[1];
- const unsigned char* q = ft_adobe_glyph_list + offset;
-
- if ( c == ( q[0] & 127 ) )
- {
- p = q;
- goto NextIter;
- }
- }
- goto NotFound;
-
- NextIter:
- ;
- }
-
- NotFound:
- return 0;
- }
-#endif /* DEFINE_PS_TABLES */
-
-#endif /* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/raster/ftraster.c b/contrib/libs/freetype/src/raster/ftraster.c
deleted file mode 100644
index c8460ac3a3..0000000000
--- a/contrib/libs/freetype/src/raster/ftraster.c
+++ /dev/null
@@ -1,2738 +0,0 @@
-/****************************************************************************
- *
- * ftraster.c
- *
- * The FreeType glyph rasterizer (body).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
- /**************************************************************************
- *
- * This file can be compiled without the rest of the FreeType engine, by
- * defining the STANDALONE_ macro when compiling it. You also need to
- * put the files `ftimage.h' and `ftmisc.h' into the $(incdir)
- * directory. Typically, you should do something like
- *
- * - copy `src/raster/ftraster.c' (this file) to your current directory
- *
- * - copy `include/freetype/ftimage.h' and `src/raster/ftmisc.h' to your
- * current directory
- *
- * - compile `ftraster' with the STANDALONE_ macro defined, as in
- *
- * cc -c -DSTANDALONE_ ftraster.c
- *
- * The renderer can be initialized with a call to
- * `ft_standard_raster.raster_new'; a bitmap can be generated
- * with a call to `ft_standard_raster.raster_render'.
- *
- * See the comments and documentation in the file `ftimage.h' for more
- * details on how the raster works.
- *
- */
-
-
- /**************************************************************************
- *
- * This is a rewrite of the FreeType 1.x scan-line converter
- *
- */
-
-#ifdef STANDALONE_
-
- /* The size in bytes of the render pool used by the scan-line converter */
- /* to do all of its work. */
-#define FT_RENDER_POOL_SIZE 16384L
-
-#define FT_CONFIG_STANDARD_LIBRARY_H <stdlib.h>
-
-#include <string.h> /* for memset */
-
-#error #include "ftmisc.h"
-#error #include "ftimage.h"
-
-#else /* !STANDALONE_ */
-
-#include "ftraster.h"
-#include <freetype/internal/ftcalc.h> /* for FT_MulDiv_No_Round */
-
-#endif /* !STANDALONE_ */
-
-
- /**************************************************************************
- *
- * A simple technical note on how the raster works
- * -----------------------------------------------
- *
- * Converting an outline into a bitmap is achieved in several steps:
- *
- * 1 - Decomposing the outline into successive `profiles'. Each
- * profile is simply an array of scanline intersections on a given
- * dimension. A profile's main attributes are
- *
- * o its scanline position boundaries, i.e. `Ymin' and `Ymax'
- *
- * o an array of intersection coordinates for each scanline
- * between `Ymin' and `Ymax'
- *
- * o a direction, indicating whether it was built going `up' or
- * `down', as this is very important for filling rules
- *
- * o its drop-out mode
- *
- * 2 - Sweeping the target map's scanlines in order to compute segment
- * `spans' which are then filled. Additionally, this pass
- * performs drop-out control.
- *
- * The outline data is parsed during step 1 only. The profiles are
- * built from the bottom of the render pool, used as a stack. The
- * following graphics shows the profile list under construction:
- *
- * __________________________________________________________ _ _
- * | | | | |
- * | profile | coordinates for | profile | coordinates for |-->
- * | 1 | profile 1 | 2 | profile 2 |-->
- * |_________|_________________|_________|_________________|__ _ _
- *
- * ^ ^
- * | |
- * start of render pool top
- *
- * The top of the profile stack is kept in the `top' variable.
- *
- * As you can see, a profile record is pushed on top of the render
- * pool, which is then followed by its coordinates/intersections. If
- * a change of direction is detected in the outline, a new profile is
- * generated until the end of the outline.
- *
- * Note that, for all generated profiles, the function End_Profile()
- * is used to record all their bottom-most scanlines as well as the
- * scanline above their upmost boundary. These positions are called
- * `y-turns' because they (sort of) correspond to local extrema.
- * They are stored in a sorted list built from the top of the render
- * pool as a downwards stack:
- *
- * _ _ _______________________________________
- * | |
- * <--| sorted list of |
- * <--| extrema scanlines |
- * _ _ __________________|____________________|
- *
- * ^ ^
- * | |
- * maxBuff sizeBuff = end of pool
- *
- * This list is later used during the sweep phase in order to
- * optimize performance (see technical note on the sweep below).
- *
- * Of course, the raster detects whether the two stacks collide and
- * handles the situation by bisecting the job and restarting.
- *
- */
-
-
- /*************************************************************************/
- /*************************************************************************/
- /** **/
- /** CONFIGURATION MACROS **/
- /** **/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /*************************************************************************/
- /*************************************************************************/
- /** **/
- /** OTHER MACROS (do not change) **/
- /** **/
- /*************************************************************************/
- /*************************************************************************/
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT raster
-
-
-#ifdef STANDALONE_
-
- /* Auxiliary macros for token concatenation. */
-#define FT_ERR_XCAT( x, y ) x ## y
-#define FT_ERR_CAT( x, y ) FT_ERR_XCAT( x, y )
-
- /* This macro is used to indicate that a function parameter is unused. */
- /* Its purpose is simply to reduce compiler warnings. Note also that */
- /* simply defining it as `(void)x' doesn't avoid warnings with certain */
- /* ANSI compilers (e.g. LCC). */
-#define FT_UNUSED( x ) (x) = (x)
-
- /* Disable the tracing mechanism for simplicity -- developers can */
- /* activate it easily by redefining these macros. */
-#ifndef FT_ERROR
-#define FT_ERROR( x ) do { } while ( 0 ) /* nothing */
-#endif
-
-#ifndef FT_TRACE
-#define FT_TRACE( x ) do { } while ( 0 ) /* nothing */
-#define FT_TRACE1( x ) do { } while ( 0 ) /* nothing */
-#define FT_TRACE6( x ) do { } while ( 0 ) /* nothing */
-#define FT_TRACE7( x ) do { } while ( 0 ) /* nothing */
-#endif
-
-#ifndef FT_THROW
-#define FT_THROW( e ) FT_ERR_CAT( Raster_Err_, e )
-#endif
-
-#define Raster_Err_Ok 0
-#define Raster_Err_Invalid_Outline -1
-#define Raster_Err_Cannot_Render_Glyph -2
-#define Raster_Err_Invalid_Argument -3
-#define Raster_Err_Raster_Overflow -4
-#define Raster_Err_Raster_Uninitialized -5
-#define Raster_Err_Raster_Negative_Height -6
-
-#define ft_memset memset
-
-#define FT_DEFINE_RASTER_FUNCS( class_, glyph_format_, raster_new_, \
- raster_reset_, raster_set_mode_, \
- raster_render_, raster_done_ ) \
- const FT_Raster_Funcs class_ = \
- { \
- glyph_format_, \
- raster_new_, \
- raster_reset_, \
- raster_set_mode_, \
- raster_render_, \
- raster_done_ \
- };
-
-#else /* !STANDALONE_ */
-
-
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/ftdebug.h> /* for FT_TRACE, FT_ERROR, and FT_THROW */
-
-#include "rasterrs.h"
-
-
-#endif /* !STANDALONE_ */
-
-
-#ifndef FT_MEM_SET
-#define FT_MEM_SET( d, s, c ) ft_memset( d, s, c )
-#endif
-
-#ifndef FT_MEM_ZERO
-#define FT_MEM_ZERO( dest, count ) FT_MEM_SET( dest, 0, count )
-#endif
-
-#ifndef FT_ZERO
-#define FT_ZERO( p ) FT_MEM_ZERO( p, sizeof ( *(p) ) )
-#endif
-
- /* FMulDiv means `Fast MulDiv'; it is used in case where `b' is */
- /* typically a small value and the result of a*b is known to fit into */
- /* 32 bits. */
-#define FMulDiv( a, b, c ) ( (a) * (b) / (c) )
-
- /* On the other hand, SMulDiv means `Slow MulDiv', and is used typically */
- /* for clipping computations. It simply uses the FT_MulDiv() function */
- /* defined in `ftcalc.h'. */
-#define SMulDiv_No_Round FT_MulDiv_No_Round
-
- /* The rasterizer is a very general purpose component; please leave */
- /* the following redefinitions there (you never know your target */
- /* environment). */
-
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-
-#ifndef NULL
-#define NULL (void*)0
-#endif
-
-#ifndef SUCCESS
-#define SUCCESS 0
-#endif
-
-#ifndef FAILURE
-#define FAILURE 1
-#endif
-
-
-#define MaxBezier 32 /* The maximum number of stacked Bezier curves. */
- /* Setting this constant to more than 32 is a */
- /* pure waste of space. */
-
-#define Pixel_Bits 6 /* fractional bits of *input* coordinates */
-
-
- /*************************************************************************/
- /*************************************************************************/
- /** **/
- /** SIMPLE TYPE DECLARATIONS **/
- /** **/
- /*************************************************************************/
- /*************************************************************************/
-
- typedef int Int;
- typedef unsigned int UInt;
- typedef short Short;
- typedef unsigned short UShort, *PUShort;
- typedef long Long, *PLong;
- typedef unsigned long ULong;
-
- typedef unsigned char Byte, *PByte;
- typedef char Bool;
-
- typedef struct TPoint_
- {
- Long x;
- Long y;
-
- } TPoint;
-
-
- /* values for the `flags' bit field */
-#define Flow_Up 0x08U
-#define Overshoot_Top 0x10U
-#define Overshoot_Bottom 0x20U
-#define Dropout 0x40U
-
-
- /* States of each line, arc, and profile */
- typedef enum TStates_
- {
- Unknown_State,
- Ascending_State,
- Descending_State,
- Flat_State
-
- } TStates;
-
-
- typedef struct TProfile_ TProfile;
- typedef TProfile* PProfile;
-
- struct TProfile_
- {
- PProfile link; /* link to next profile (various purposes) */
- PProfile next; /* next profile in same contour, used */
- /* during drop-out control */
- Int offset; /* bottom or currently scanned array index */
- Int height; /* profile's height in scanlines */
- Int start; /* profile's starting scanline, also use */
- /* as activation counter */
- UShort flags; /* Bit 0-2: drop-out mode */
- /* Bit 3: profile orientation (up/down) */
- /* Bit 4: is top profile? */
- /* Bit 5: is bottom profile? */
- /* Bit 6: dropout detected */
-
- FT_F26Dot6 X; /* current coordinate during sweep */
- Long x[1]; /* actually variable array of scanline */
- /* intersections with `height` elements */
- };
-
- typedef PProfile TProfileList;
- typedef PProfile* PProfileList;
-
-
-#undef RAS_ARG
-#undef RAS_ARGS
-#undef RAS_VAR
-#undef RAS_VARS
-
-#ifdef FT_STATIC_RASTER
-
-
-#define RAS_ARGS /* void */
-#define RAS_ARG void
-
-#define RAS_VARS /* void */
-#define RAS_VAR /* void */
-
-#define FT_UNUSED_RASTER do { } while ( 0 )
-
-
-#else /* !FT_STATIC_RASTER */
-
-
-#define RAS_ARGS black_PWorker worker,
-#define RAS_ARG black_PWorker worker
-
-#define RAS_VARS worker,
-#define RAS_VAR worker
-
-#define FT_UNUSED_RASTER FT_UNUSED( worker )
-
-
-#endif /* !FT_STATIC_RASTER */
-
-
- typedef struct black_TWorker_ black_TWorker, *black_PWorker;
-
-
- /* prototypes used for sweep function dispatch */
- typedef void
- Function_Sweep_Init( RAS_ARGS Int min,
- Int max );
-
- typedef void
- Function_Sweep_Span( RAS_ARGS Int y,
- FT_F26Dot6 x1,
- FT_F26Dot6 x2 );
-
- typedef void
- Function_Sweep_Step( RAS_ARG );
-
-
- /* NOTE: These operations are only valid on 2's complement processors */
-#undef FLOOR
-#undef CEILING
-#undef TRUNC
-#undef SCALED
-
-#define FLOOR( x ) ( (x) & -ras.precision )
-#define CEILING( x ) ( ( (x) + ras.precision - 1 ) & -ras.precision )
-#define TRUNC( x ) ( (Long)(x) >> ras.precision_bits )
-#define FRAC( x ) ( (x) & ( ras.precision - 1 ) )
-
- /* scale and shift grid to pixel centers */
-#define SCALED( x ) ( (x) * ras.precision_scale - ras.precision_half )
-
-#define IS_BOTTOM_OVERSHOOT( x ) \
- (Bool)( CEILING( x ) - x >= ras.precision_half )
-#define IS_TOP_OVERSHOOT( x ) \
- (Bool)( x - FLOOR( x ) >= ras.precision_half )
-
- /* Smart dropout rounding to find which pixel is closer to span ends. */
- /* To mimic Windows, symmetric cases do not depend on the precision. */
-#define SMART( p, q ) FLOOR( ( (p) + (q) + ras.precision * 63 / 64 ) >> 1 )
-
-#if FT_RENDER_POOL_SIZE > 2048
-#define FT_MAX_BLACK_POOL ( FT_RENDER_POOL_SIZE / sizeof ( Long ) )
-#else
-#define FT_MAX_BLACK_POOL ( 2048 / sizeof ( Long ) )
-#endif
-
- /* The most used variables are positioned at the top of the structure. */
- /* Thus, their offset can be coded with less opcodes, resulting in a */
- /* smaller executable. */
-
- struct black_TWorker_
- {
- Int precision_bits; /* precision related variables */
- Int precision;
- Int precision_half;
- Int precision_scale;
- Int precision_step;
-
- PLong buff; /* The profiles buffer */
- PLong sizeBuff; /* Render pool size */
- PLong maxBuff; /* Profiles buffer size */
- PLong top; /* Current cursor in buffer */
-
- FT_Error error;
-
- Byte dropOutControl; /* current drop_out control method */
-
- Long lastX, lastY;
- Long minY, maxY;
-
- UShort num_Profs; /* current number of profiles */
- Int numTurns; /* number of Y-turns in outline */
-
- PProfile cProfile; /* current profile */
- PProfile fProfile; /* head of linked list of profiles */
- PProfile gProfile; /* contour's first profile in case */
- /* of impact */
-
- TStates state; /* rendering state */
-
- FT_Outline outline;
-
- Int bTop; /* target bitmap max line index */
- Int bRight; /* target bitmap rightmost index */
- Int bPitch; /* target bitmap pitch */
- PByte bOrigin; /* target bitmap bottom-left origin */
- PByte bLine; /* target bitmap current line */
-
- /* dispatch variables */
-
- Function_Sweep_Init* Proc_Sweep_Init;
- Function_Sweep_Span* Proc_Sweep_Span;
- Function_Sweep_Span* Proc_Sweep_Drop;
- Function_Sweep_Step* Proc_Sweep_Step;
-
- };
-
-
- typedef struct black_TRaster_
- {
- void* memory;
-
- } black_TRaster, *black_PRaster;
-
-#ifdef FT_STATIC_RASTER
-
- static black_TWorker ras;
-
-#else /* !FT_STATIC_RASTER */
-
-#define ras (*worker)
-
-#endif /* !FT_STATIC_RASTER */
-
-
- /*************************************************************************/
- /*************************************************************************/
- /** **/
- /** PROFILES COMPUTATION **/
- /** **/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /**************************************************************************
- *
- * @Function:
- * Set_High_Precision
- *
- * @Description:
- * Set precision variables according to param flag.
- *
- * @Input:
- * High ::
- * Set to True for high precision (typically for ppem < 24),
- * false otherwise.
- */
- static void
- Set_High_Precision( RAS_ARGS Int High )
- {
- /*
- * `precision_step' is used in `Bezier_Up' to decide when to split a
- * given y-monotonous Bezier arc that crosses a scanline before
- * approximating it as a straight segment. The default value of 32 (for
- * low accuracy) corresponds to
- *
- * 32 / 64 == 0.5 pixels,
- *
- * while for the high accuracy case we have
- *
- * 256 / (1 << 12) = 0.0625 pixels.
- *
- */
-
- if ( High )
- {
- ras.precision_bits = 12;
- ras.precision_step = 256;
- }
- else
- {
- ras.precision_bits = 6;
- ras.precision_step = 32;
- }
-
- ras.precision = 1 << ras.precision_bits;
- ras.precision_half = ras.precision >> 1;
- ras.precision_scale = ras.precision >> Pixel_Bits;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * Insert_Y_Turn
- *
- * @Description:
- * Insert a salient into the sorted list placed on top of the render
- * pool.
- *
- * @Input:
- * New y scanline position.
- *
- * @Return:
- * SUCCESS on success. FAILURE in case of overflow.
- */
- static Bool
- Insert_Y_Turns( RAS_ARGS Int y,
- Int top )
- {
- Int n = ras.numTurns;
- PLong y_turns = ras.maxBuff;
-
-
- /* update top value */
- if ( n == 0 || top > y_turns[n] )
- y_turns[n] = top;
-
- /* look for first y value that is <= */
- while ( n-- && y < y_turns[n] )
- ;
-
- /* if it is <, simply insert it, ignore if == */
- if ( n < 0 || y > y_turns[n] )
- {
- ras.maxBuff--;
- if ( ras.maxBuff <= ras.top )
- {
- ras.error = FT_THROW( Raster_Overflow );
- return FAILURE;
- }
-
- do
- {
- Int y2 = (Int)y_turns[n];
-
-
- y_turns[n] = y;
- y = y2;
- } while ( n-- >= 0 );
-
- ras.numTurns++;
- }
-
- return SUCCESS;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * New_Profile
- *
- * @Description:
- * Create a new profile in the render pool.
- *
- * @Input:
- * aState ::
- * The state/orientation of the new profile.
- *
- * @Return:
- * SUCCESS on success. FAILURE in case of overflow or of incoherent
- * profile.
- */
- static Bool
- New_Profile( RAS_ARGS TStates aState )
- {
- Long e;
-
-
- if ( !ras.cProfile || ras.cProfile->height )
- {
- ras.cProfile = (PProfile)ras.top;
- ras.top = ras.cProfile->x;
-
- if ( ras.top >= ras.maxBuff )
- {
- FT_TRACE1(( "overflow in New_Profile\n" ));
- ras.error = FT_THROW( Raster_Overflow );
- return FAILURE;
- }
-
- ras.cProfile->height = 0;
- }
-
- ras.cProfile->flags = ras.dropOutControl;
-
- switch ( aState )
- {
- case Ascending_State:
- ras.cProfile->flags |= Flow_Up;
- if ( IS_BOTTOM_OVERSHOOT( ras.lastY ) )
- ras.cProfile->flags |= Overshoot_Bottom;
-
- e = CEILING( ras.lastY );
- break;
-
- case Descending_State:
- if ( IS_TOP_OVERSHOOT( ras.lastY ) )
- ras.cProfile->flags |= Overshoot_Top;
-
- e = FLOOR( ras.lastY );
- break;
-
- default:
- FT_ERROR(( "New_Profile: invalid profile direction\n" ));
- ras.error = FT_THROW( Invalid_Outline );
- return FAILURE;
- }
-
- if ( e > ras.maxY )
- e = ras.maxY;
- if ( e < ras.minY )
- e = ras.minY;
- ras.cProfile->start = (Int)TRUNC( e );
-
- FT_TRACE7(( " new %s profile = %p, start = %d\n",
- aState == Ascending_State ? "ascending" : "descending",
- (void *)ras.cProfile, ras.cProfile->start ));
-
- if ( ras.lastY == e )
- *ras.top++ = ras.lastX;
-
- ras.state = aState;
-
- return SUCCESS;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * End_Profile
- *
- * @Description:
- * Finalize the current profile and record y-turns.
- *
- * @Return:
- * SUCCESS on success. FAILURE in case of overflow or incoherency.
- */
- static Bool
- End_Profile( RAS_ARG )
- {
- PProfile p = ras.cProfile;
- Int h = (Int)( ras.top - p->x );
- Int bottom, top;
-
-
- if ( h < 0 )
- {
- FT_ERROR(( "End_Profile: negative height encountered\n" ));
- ras.error = FT_THROW( Raster_Negative_Height );
- return FAILURE;
- }
-
- if ( h > 0 )
- {
- FT_TRACE7(( " ending profile %p, start = %2d, height = %+3d\n",
- (void *)p, p->start, p->flags & Flow_Up ? h : -h ));
-
- p->height = h;
-
- if ( p->flags & Flow_Up )
- {
- if ( IS_TOP_OVERSHOOT( ras.lastY ) )
- p->flags |= Overshoot_Top;
-
- bottom = p->start;
- top = bottom + h;
- p->offset = 0;
- p->X = p->x[0];
- }
- else
- {
- if ( IS_BOTTOM_OVERSHOOT( ras.lastY ) )
- p->flags |= Overshoot_Bottom;
-
- top = p->start + 1;
- bottom = top - h;
- p->start = bottom;
- p->offset = h - 1;
- p->X = p->x[h - 1];
- }
-
- if ( Insert_Y_Turns( RAS_VARS bottom, top ) )
- return FAILURE;
-
- if ( !ras.gProfile )
- ras.gProfile = p;
-
- /* preliminary values to be finalized */
- p->next = ras.gProfile;
- p->link = (PProfile)ras.top;
-
- ras.num_Profs++;
- }
-
- return SUCCESS;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * Finalize_Profile_Table
- *
- * @Description:
- * Adjust all links in the profiles list.
- */
- static void
- Finalize_Profile_Table( RAS_ARG )
- {
- UShort n = ras.num_Profs;
- PProfile p = ras.fProfile;
- PProfile q;
-
-
- /* there should be at least two profiles, up and down */
- while ( --n )
- {
- q = p->link;
-
- /* fix the contour loop */
- if ( q->next == p->next )
- p->next = q;
-
- p = q;
- }
-
- /* null-terminate */
- p->link = NULL;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * Split_Conic
- *
- * @Description:
- * Subdivide one conic Bezier into two joint sub-arcs in the Bezier
- * stack.
- *
- * @Input:
- * None (subdivided Bezier is taken from the top of the stack).
- *
- * @Note:
- * This routine is the `beef' of this component. It is _the_ inner
- * loop that should be optimized to hell to get the best performance.
- */
- static void
- Split_Conic( TPoint* base )
- {
- Long a, b;
-
-
- base[4].x = base[2].x;
- a = base[0].x + base[1].x;
- b = base[1].x + base[2].x;
- base[3].x = b >> 1;
- base[2].x = ( a + b ) >> 2;
- base[1].x = a >> 1;
-
- base[4].y = base[2].y;
- a = base[0].y + base[1].y;
- b = base[1].y + base[2].y;
- base[3].y = b >> 1;
- base[2].y = ( a + b ) >> 2;
- base[1].y = a >> 1;
-
- /* hand optimized. gcc doesn't seem to be too good at common */
- /* expression substitution and instruction scheduling ;-) */
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * Split_Cubic
- *
- * @Description:
- * Subdivide a third-order Bezier arc into two joint sub-arcs in the
- * Bezier stack.
- *
- * @Note:
- * This routine is the `beef' of the component. It is one of _the_
- * inner loops that should be optimized like hell to get the best
- * performance.
- */
- static void
- Split_Cubic( TPoint* base )
- {
- Long a, b, c;
-
-
- base[6].x = base[3].x;
- a = base[0].x + base[1].x;
- b = base[1].x + base[2].x;
- c = base[2].x + base[3].x;
- base[5].x = c >> 1;
- c += b;
- base[4].x = c >> 2;
- base[1].x = a >> 1;
- a += b;
- base[2].x = a >> 2;
- base[3].x = ( a + c ) >> 3;
-
- base[6].y = base[3].y;
- a = base[0].y + base[1].y;
- b = base[1].y + base[2].y;
- c = base[2].y + base[3].y;
- base[5].y = c >> 1;
- c += b;
- base[4].y = c >> 2;
- base[1].y = a >> 1;
- a += b;
- base[2].y = a >> 2;
- base[3].y = ( a + c ) >> 3;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * Line_Up
- *
- * @Description:
- * Compute the x-coordinates of an ascending line segment and store
- * them in the render pool.
- *
- * @Input:
- * x1 ::
- * The x-coordinate of the segment's start point.
- *
- * y1 ::
- * The y-coordinate of the segment's start point.
- *
- * x2 ::
- * The x-coordinate of the segment's end point.
- *
- * y2 ::
- * The y-coordinate of the segment's end point.
- *
- * miny ::
- * A lower vertical clipping bound value.
- *
- * maxy ::
- * An upper vertical clipping bound value.
- *
- * @Return:
- * SUCCESS on success, FAILURE on render pool overflow.
- */
- static Bool
- Line_Up( RAS_ARGS Long x1,
- Long y1,
- Long x2,
- Long y2,
- Long miny,
- Long maxy )
- {
- Long e, e2, Dx, Dy;
- Long Ix, Rx, Ax;
- Int size;
-
- PLong top;
-
-
- if ( y2 < miny || y1 > maxy )
- return SUCCESS;
-
- e2 = y2 > maxy ? maxy : FLOOR( y2 );
- e = y1 < miny ? miny : CEILING( y1 );
-
- if ( y1 == e )
- e += ras.precision;
-
- if ( e2 < e ) /* nothing to do */
- return SUCCESS;
-
- size = (Int)TRUNC( e2 - e ) + 1;
- top = ras.top;
-
- if ( top + size >= ras.maxBuff )
- {
- ras.error = FT_THROW( Raster_Overflow );
- return FAILURE;
- }
-
- Dx = x2 - x1;
- Dy = y2 - y1;
-
- if ( Dx == 0 ) /* very easy */
- {
- do
- *top++ = x1;
- while ( --size );
- goto Fin;
- }
-
- Ix = SMulDiv_No_Round( e - y1, Dx, Dy );
- x1 += Ix;
- *top++ = x1;
-
- if ( --size )
- {
- Ax = Dx * ( e - y1 ) - Dy * Ix; /* remainder */
- Ix = FMulDiv( ras.precision, Dx, Dy );
- Rx = Dx * ras.precision - Dy * Ix; /* remainder */
- Dx = 1;
-
- if ( x2 < x1 )
- {
- Ax = -Ax;
- Rx = -Rx;
- Dx = -Dx;
- }
-
- do
- {
- x1 += Ix;
- Ax += Rx;
- if ( Ax >= Dy )
- {
- Ax -= Dy;
- x1 += Dx;
- }
- *top++ = x1;
- }
- while ( --size );
- }
-
- Fin:
- ras.top = top;
- return SUCCESS;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * Line_Down
- *
- * @Description:
- * Compute the x-coordinates of an descending line segment and store
- * them in the render pool.
- *
- * @Input:
- * x1 ::
- * The x-coordinate of the segment's start point.
- *
- * y1 ::
- * The y-coordinate of the segment's start point.
- *
- * x2 ::
- * The x-coordinate of the segment's end point.
- *
- * y2 ::
- * The y-coordinate of the segment's end point.
- *
- * miny ::
- * A lower vertical clipping bound value.
- *
- * maxy ::
- * An upper vertical clipping bound value.
- *
- * @Return:
- * SUCCESS on success, FAILURE on render pool overflow.
- */
- static Bool
- Line_Down( RAS_ARGS Long x1,
- Long y1,
- Long x2,
- Long y2,
- Long miny,
- Long maxy )
- {
- return Line_Up( RAS_VARS x1, -y1, x2, -y2, -maxy, -miny );
- }
-
-
- /* A function type describing the functions used to split Bezier arcs */
- typedef void (*TSplitter)( TPoint* base );
-
-
- /**************************************************************************
- *
- * @Function:
- * Bezier_Up
- *
- * @Description:
- * Compute the x-coordinates of an ascending Bezier arc and store
- * them in the render pool.
- *
- * @Input:
- * degree ::
- * The degree of the Bezier arc (either 2 or 3).
- *
- * splitter ::
- * The function to split Bezier arcs.
- *
- * miny ::
- * A lower vertical clipping bound value.
- *
- * maxy ::
- * An upper vertical clipping bound value.
- *
- * @Return:
- * SUCCESS on success, FAILURE on render pool overflow.
- */
- static Bool
- Bezier_Up( RAS_ARGS Int degree,
- TPoint* arc,
- TSplitter splitter,
- Long miny,
- Long maxy )
- {
- Long y1, y2, e, e2, dy;
- Long dx, x2;
-
- PLong top;
-
-
- y1 = arc[degree].y;
- y2 = arc[0].y;
-
- if ( y2 < miny || y1 > maxy )
- return SUCCESS;
-
- e2 = y2 > maxy ? maxy : FLOOR( y2 );
- e = y1 < miny ? miny : CEILING( y1 );
-
- if ( y1 == e )
- e += ras.precision;
-
- if ( e2 < e ) /* nothing to do */
- return SUCCESS;
-
- top = ras.top;
-
- if ( ( top + TRUNC( e2 - e ) + 1 ) >= ras.maxBuff )
- {
- ras.error = FT_THROW( Raster_Overflow );
- return FAILURE;
- }
-
- do
- {
- y2 = arc[0].y;
- x2 = arc[0].x;
-
- if ( y2 > e )
- {
- dy = y2 - arc[degree].y;
- dx = x2 - arc[degree].x;
-
- /* split condition should be invariant of direction */
- if ( dy > ras.precision_step ||
- dx > ras.precision_step ||
- -dx > ras.precision_step )
- {
- splitter( arc );
- arc += degree;
- }
- else
- {
- *top++ = x2 - FMulDiv( y2 - e, dx, dy );
- e += ras.precision;
- arc -= degree;
- }
- }
- else
- {
- if ( y2 == e )
- {
- *top++ = x2;
- e += ras.precision;
- }
- arc -= degree;
- }
- }
- while ( e <= e2 );
-
- ras.top = top;
- return SUCCESS;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * Bezier_Down
- *
- * @Description:
- * Compute the x-coordinates of an descending Bezier arc and store
- * them in the render pool.
- *
- * @Input:
- * degree ::
- * The degree of the Bezier arc (either 2 or 3).
- *
- * splitter ::
- * The function to split Bezier arcs.
- *
- * miny ::
- * A lower vertical clipping bound value.
- *
- * maxy ::
- * An upper vertical clipping bound value.
- *
- * @Return:
- * SUCCESS on success, FAILURE on render pool overflow.
- */
- static Bool
- Bezier_Down( RAS_ARGS Int degree,
- TPoint* arc,
- TSplitter splitter,
- Long miny,
- Long maxy )
- {
- Bool result;
-
-
- arc[0].y = -arc[0].y;
- arc[1].y = -arc[1].y;
- arc[2].y = -arc[2].y;
- if ( degree > 2 )
- arc[3].y = -arc[3].y;
-
- result = Bezier_Up( RAS_VARS degree, arc, splitter, -maxy, -miny );
-
- arc[0].y = -arc[0].y;
- return result;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * Line_To
- *
- * @Description:
- * Inject a new line segment and adjust the Profiles list.
- *
- * @Input:
- * x ::
- * The x-coordinate of the segment's end point (its start point
- * is stored in `lastX').
- *
- * y ::
- * The y-coordinate of the segment's end point (its start point
- * is stored in `lastY').
- *
- * @Return:
- * SUCCESS on success, FAILURE on render pool overflow or incorrect
- * profile.
- */
- static Bool
- Line_To( RAS_ARGS Long x,
- Long y )
- {
- TStates state;
-
-
- if ( y == ras.lastY )
- goto Fin;
-
- /* First, detect a change of direction */
-
- state = ras.lastY < y ? Ascending_State : Descending_State;
-
- if ( ras.state != state )
- {
- /* finalize current profile if any */
- if ( ras.state != Unknown_State &&
- End_Profile( RAS_VAR ) )
- goto Fail;
-
- /* create a new profile */
- if ( New_Profile( RAS_VARS state ) )
- goto Fail;
- }
-
- /* Then compute the lines */
-
- if ( state == Ascending_State )
- {
- if ( Line_Up( RAS_VARS ras.lastX, ras.lastY,
- x, y, ras.minY, ras.maxY ) )
- goto Fail;
- }
- else
- {
- if ( Line_Down( RAS_VARS ras.lastX, ras.lastY,
- x, y, ras.minY, ras.maxY ) )
- goto Fail;
- }
-
- Fin:
- ras.lastX = x;
- ras.lastY = y;
- return SUCCESS;
-
- Fail:
- return FAILURE;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * Conic_To
- *
- * @Description:
- * Inject a new conic arc and adjust the profile list.
- *
- * @Input:
- * cx ::
- * The x-coordinate of the arc's new control point.
- *
- * cy ::
- * The y-coordinate of the arc's new control point.
- *
- * x ::
- * The x-coordinate of the arc's end point (its start point is
- * stored in `lastX').
- *
- * y ::
- * The y-coordinate of the arc's end point (its start point is
- * stored in `lastY').
- *
- * @Return:
- * SUCCESS on success, FAILURE on render pool overflow or incorrect
- * profile.
- */
- static Bool
- Conic_To( RAS_ARGS Long cx,
- Long cy,
- Long x,
- Long y )
- {
- Long y1, y2, y3, x3, ymin, ymax;
- TStates state_bez;
- TPoint arcs[2 * MaxBezier + 1]; /* The Bezier stack */
- TPoint* arc; /* current Bezier arc pointer */
-
-
- arc = arcs;
- arc[2].x = ras.lastX;
- arc[2].y = ras.lastY;
- arc[1].x = cx;
- arc[1].y = cy;
- arc[0].x = x;
- arc[0].y = y;
-
- do
- {
- y1 = arc[2].y;
- y2 = arc[1].y;
- y3 = arc[0].y;
- x3 = arc[0].x;
-
- /* first, categorize the Bezier arc */
-
- if ( y1 <= y3 )
- {
- ymin = y1;
- ymax = y3;
- }
- else
- {
- ymin = y3;
- ymax = y1;
- }
-
- if ( y2 < FLOOR( ymin ) || y2 > CEILING( ymax ) )
- {
- /* this arc has no given direction, split it! */
- Split_Conic( arc );
- arc += 2;
- }
- else if ( y1 == y3 )
- {
- /* this arc is flat, advance position */
- /* and pop it from the Bezier stack */
- arc -= 2;
-
- ras.lastX = x3;
- ras.lastY = y3;
- }
- else
- {
- /* the arc is y-monotonous, either ascending or descending */
- /* detect a change of direction */
- state_bez = y1 < y3 ? Ascending_State : Descending_State;
- if ( ras.state != state_bez )
- {
- /* finalize current profile if any */
- if ( ras.state != Unknown_State &&
- End_Profile( RAS_VAR ) )
- goto Fail;
-
- /* create a new profile */
- if ( New_Profile( RAS_VARS state_bez ) )
- goto Fail;
- }
-
- /* now call the appropriate routine */
- if ( state_bez == Ascending_State )
- {
- if ( Bezier_Up( RAS_VARS 2, arc, Split_Conic,
- ras.minY, ras.maxY ) )
- goto Fail;
- }
- else
- if ( Bezier_Down( RAS_VARS 2, arc, Split_Conic,
- ras.minY, ras.maxY ) )
- goto Fail;
- arc -= 2;
-
- ras.lastX = x3;
- ras.lastY = y3;
- }
-
- } while ( arc >= arcs );
-
- return SUCCESS;
-
- Fail:
- return FAILURE;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * Cubic_To
- *
- * @Description:
- * Inject a new cubic arc and adjust the profile list.
- *
- * @Input:
- * cx1 ::
- * The x-coordinate of the arc's first new control point.
- *
- * cy1 ::
- * The y-coordinate of the arc's first new control point.
- *
- * cx2 ::
- * The x-coordinate of the arc's second new control point.
- *
- * cy2 ::
- * The y-coordinate of the arc's second new control point.
- *
- * x ::
- * The x-coordinate of the arc's end point (its start point is
- * stored in `lastX').
- *
- * y ::
- * The y-coordinate of the arc's end point (its start point is
- * stored in `lastY').
- *
- * @Return:
- * SUCCESS on success, FAILURE on render pool overflow or incorrect
- * profile.
- */
- static Bool
- Cubic_To( RAS_ARGS Long cx1,
- Long cy1,
- Long cx2,
- Long cy2,
- Long x,
- Long y )
- {
- Long y1, y2, y3, y4, x4, ymin1, ymax1, ymin2, ymax2;
- TStates state_bez;
- TPoint arcs[3 * MaxBezier + 1]; /* The Bezier stack */
- TPoint* arc; /* current Bezier arc pointer */
-
-
- arc = arcs;
- arc[3].x = ras.lastX;
- arc[3].y = ras.lastY;
- arc[2].x = cx1;
- arc[2].y = cy1;
- arc[1].x = cx2;
- arc[1].y = cy2;
- arc[0].x = x;
- arc[0].y = y;
-
- do
- {
- y1 = arc[3].y;
- y2 = arc[2].y;
- y3 = arc[1].y;
- y4 = arc[0].y;
- x4 = arc[0].x;
-
- /* first, categorize the Bezier arc */
-
- if ( y1 <= y4 )
- {
- ymin1 = y1;
- ymax1 = y4;
- }
- else
- {
- ymin1 = y4;
- ymax1 = y1;
- }
-
- if ( y2 <= y3 )
- {
- ymin2 = y2;
- ymax2 = y3;
- }
- else
- {
- ymin2 = y3;
- ymax2 = y2;
- }
-
- if ( ymin2 < FLOOR( ymin1 ) || ymax2 > CEILING( ymax1 ) )
- {
- /* this arc has no given direction, split it! */
- Split_Cubic( arc );
- arc += 3;
- }
- else if ( y1 == y4 )
- {
- /* this arc is flat, advance position */
- /* and pop it from the Bezier stack */
- arc -= 3;
-
- ras.lastX = x4;
- ras.lastY = y4;
- }
- else
- {
- state_bez = y1 < y4 ? Ascending_State : Descending_State;
-
- /* detect a change of direction */
- if ( ras.state != state_bez )
- {
- /* finalize current profile if any */
- if ( ras.state != Unknown_State &&
- End_Profile( RAS_VAR ) )
- goto Fail;
-
- if ( New_Profile( RAS_VARS state_bez ) )
- goto Fail;
- }
-
- /* compute intersections */
- if ( state_bez == Ascending_State )
- {
- if ( Bezier_Up( RAS_VARS 3, arc, Split_Cubic,
- ras.minY, ras.maxY ) )
- goto Fail;
- }
- else
- if ( Bezier_Down( RAS_VARS 3, arc, Split_Cubic,
- ras.minY, ras.maxY ) )
- goto Fail;
- arc -= 3;
-
- ras.lastX = x4;
- ras.lastY = y4;
- }
-
- } while ( arc >= arcs );
-
- return SUCCESS;
-
- Fail:
- return FAILURE;
- }
-
-
-#undef SWAP_
-#define SWAP_( x, y ) do \
- { \
- Long swap = x; \
- \
- \
- x = y; \
- y = swap; \
- } while ( 0 )
-
-
- /**************************************************************************
- *
- * @Function:
- * Decompose_Curve
- *
- * @Description:
- * Scan the outline arrays in order to emit individual segments and
- * Beziers by calling Line_To() and Bezier_To(). It handles all
- * weird cases, like when the first point is off the curve, or when
- * there are simply no `on' points in the contour!
- *
- * @Input:
- * first ::
- * The index of the first point in the contour.
- *
- * last ::
- * The index of the last point in the contour.
- *
- * flipped ::
- * If set, flip the direction of the curve.
- *
- * @Return:
- * SUCCESS on success, FAILURE on error.
- *
- * @Note:
- * Unlike FT_Outline_Decompose(), this function handles the scanmode
- * dropout tags in the individual contours. Therefore, it cannot be
- * replaced.
- */
- static Bool
- Decompose_Curve( RAS_ARGS Int first,
- Int last,
- Int flipped )
- {
- FT_Vector v_last;
- FT_Vector v_control;
- FT_Vector v_start;
-
- FT_Vector* points;
- FT_Vector* point;
- FT_Vector* limit;
- FT_Byte* tags;
-
- UInt tag; /* current point's state */
-
-
- points = ras.outline.points;
- limit = points + last;
-
- v_start.x = SCALED( points[first].x );
- v_start.y = SCALED( points[first].y );
- v_last.x = SCALED( points[last].x );
- v_last.y = SCALED( points[last].y );
-
- if ( flipped )
- {
- SWAP_( v_start.x, v_start.y );
- SWAP_( v_last.x, v_last.y );
- }
-
- v_control = v_start;
-
- point = points + first;
- tags = ras.outline.tags + first;
-
- /* set scan mode if necessary */
- if ( tags[0] & FT_CURVE_TAG_HAS_SCANMODE )
- ras.dropOutControl = (Byte)tags[0] >> 5;
-
- tag = FT_CURVE_TAG( tags[0] );
-
- /* A contour cannot start with a cubic control point! */
- if ( tag == FT_CURVE_TAG_CUBIC )
- goto Invalid_Outline;
-
- /* check first point to determine origin */
- if ( tag == FT_CURVE_TAG_CONIC )
- {
- /* first point is conic control. Yes, this happens. */
- if ( FT_CURVE_TAG( ras.outline.tags[last] ) == FT_CURVE_TAG_ON )
- {
- /* start at last point if it is on the curve */
- v_start = v_last;
- limit--;
- }
- else
- {
- /* if both first and last points are conic, */
- /* start at their middle and record its position */
- /* for closure */
- v_start.x = ( v_start.x + v_last.x ) / 2;
- v_start.y = ( v_start.y + v_last.y ) / 2;
-
- /* v_last = v_start; */
- }
- point--;
- tags--;
- }
-
- ras.lastX = v_start.x;
- ras.lastY = v_start.y;
-
- while ( point < limit )
- {
- point++;
- tags++;
-
- tag = FT_CURVE_TAG( tags[0] );
-
- switch ( tag )
- {
- case FT_CURVE_TAG_ON: /* emit a single line_to */
- {
- Long x, y;
-
-
- x = SCALED( point->x );
- y = SCALED( point->y );
- if ( flipped )
- SWAP_( x, y );
-
- if ( Line_To( RAS_VARS x, y ) )
- goto Fail;
- continue;
- }
-
- case FT_CURVE_TAG_CONIC: /* consume conic arcs */
- v_control.x = SCALED( point[0].x );
- v_control.y = SCALED( point[0].y );
-
- if ( flipped )
- SWAP_( v_control.x, v_control.y );
-
- Do_Conic:
- if ( point < limit )
- {
- FT_Vector v_middle;
- Long x, y;
-
-
- point++;
- tags++;
- tag = FT_CURVE_TAG( tags[0] );
-
- x = SCALED( point[0].x );
- y = SCALED( point[0].y );
-
- if ( flipped )
- SWAP_( x, y );
-
- if ( tag == FT_CURVE_TAG_ON )
- {
- if ( Conic_To( RAS_VARS v_control.x, v_control.y, x, y ) )
- goto Fail;
- continue;
- }
-
- if ( tag != FT_CURVE_TAG_CONIC )
- goto Invalid_Outline;
-
- v_middle.x = ( v_control.x + x ) / 2;
- v_middle.y = ( v_control.y + y ) / 2;
-
- if ( Conic_To( RAS_VARS v_control.x, v_control.y,
- v_middle.x, v_middle.y ) )
- goto Fail;
-
- v_control.x = x;
- v_control.y = y;
-
- goto Do_Conic;
- }
-
- if ( Conic_To( RAS_VARS v_control.x, v_control.y,
- v_start.x, v_start.y ) )
- goto Fail;
-
- goto Close;
-
- default: /* FT_CURVE_TAG_CUBIC */
- {
- Long x1, y1, x2, y2, x3, y3;
-
-
- if ( point + 1 > limit ||
- FT_CURVE_TAG( tags[1] ) != FT_CURVE_TAG_CUBIC )
- goto Invalid_Outline;
-
- point += 2;
- tags += 2;
-
- x1 = SCALED( point[-2].x );
- y1 = SCALED( point[-2].y );
- x2 = SCALED( point[-1].x );
- y2 = SCALED( point[-1].y );
-
- if ( flipped )
- {
- SWAP_( x1, y1 );
- SWAP_( x2, y2 );
- }
-
- if ( point <= limit )
- {
- x3 = SCALED( point[0].x );
- y3 = SCALED( point[0].y );
-
- if ( flipped )
- SWAP_( x3, y3 );
-
- if ( Cubic_To( RAS_VARS x1, y1, x2, y2, x3, y3 ) )
- goto Fail;
- continue;
- }
-
- if ( Cubic_To( RAS_VARS x1, y1, x2, y2, v_start.x, v_start.y ) )
- goto Fail;
- goto Close;
- }
- }
- }
-
- /* close the contour with a line segment */
- if ( Line_To( RAS_VARS v_start.x, v_start.y ) )
- goto Fail;
-
- Close:
- return SUCCESS;
-
- Invalid_Outline:
- ras.error = FT_THROW( Invalid_Outline );
-
- Fail:
- return FAILURE;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * Convert_Glyph
- *
- * @Description:
- * Convert a glyph into a series of segments and arcs and make a
- * profiles list with them.
- *
- * @Input:
- * flipped ::
- * If set, flip the direction of curve.
- *
- * @Return:
- * SUCCESS on success, FAILURE if any error was encountered during
- * rendering.
- */
- static Bool
- Convert_Glyph( RAS_ARGS Int flipped )
- {
- Int i;
- Int first, last;
-
-
- ras.fProfile = NULL;
- ras.cProfile = NULL;
-
- ras.top = ras.buff;
- ras.maxBuff = ras.sizeBuff - 1; /* top reserve */
-
- ras.numTurns = 0;
- ras.num_Profs = 0;
-
- last = -1;
- for ( i = 0; i < ras.outline.n_contours; i++ )
- {
- ras.state = Unknown_State;
- ras.gProfile = NULL;
-
- first = last + 1;
- last = ras.outline.contours[i];
-
- if ( Decompose_Curve( RAS_VARS first, last, flipped ) )
- return FAILURE;
-
- /* Note that ras.gProfile can stay nil if the contour was */
- /* too small to be drawn or degenerate. */
- if ( !ras.gProfile )
- continue;
-
- /* we must now check whether the extreme arcs join or not */
- if ( FRAC( ras.lastY ) == 0 &&
- ras.lastY >= ras.minY &&
- ras.lastY <= ras.maxY )
- if ( ( ras.gProfile->flags & Flow_Up ) ==
- ( ras.cProfile->flags & Flow_Up ) )
- ras.top--;
-
- if ( End_Profile( RAS_VAR ) )
- return FAILURE;
-
- if ( !ras.fProfile )
- ras.fProfile = ras.gProfile;
- }
-
- if ( ras.fProfile )
- Finalize_Profile_Table( RAS_VAR );
-
- return SUCCESS;
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /** **/
- /** SCAN-LINE SWEEPS AND DRAWING **/
- /** **/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /**************************************************************************
- *
- * InsNew
- *
- * Inserts a new profile in a linked list, sorted by coordinate.
- */
- static void
- InsNew( PProfileList list,
- PProfile profile )
- {
- PProfile *old, current;
- Long x;
-
-
- old = list;
- current = *old;
- x = profile->X;
-
- while ( current && current->X < x )
- {
- old = &current->link;
- current = *old;
- }
-
- profile->link = current;
- *old = profile;
- }
-
-
- /**************************************************************************
- *
- * Increment
- *
- * Advances all profile in the list to the next scanline. It also
- * sorts the trace list in the unlikely case of profile crossing.
- * The profiles are inserted in sorted order. We might need a single
- * swap to fix it when profiles (contours) cross.
- * Bubble sort with immediate restart is good enough and simple.
- */
- static void
- Increment( PProfileList list,
- Int flow )
- {
- PProfile *old, current, next;
-
-
- /* First, set the new X coordinates and remove exhausted profiles */
- old = list;
- while ( *old )
- {
- current = *old;
- if ( --current->height )
- {
- current->offset += flow;
- current->X = current->x[current->offset];
- old = &current->link;
- }
- else
- *old = current->link; /* remove */
- }
-
- /* Then make sure the list remains sorted */
- old = list;
- current = *old;
-
- if ( !current )
- return;
-
- while ( current->link )
- {
- next = current->link;
-
- if ( current->X <= next->X )
- {
- old = &current->link;
- current = next;
- }
- else
- {
- *old = next;
- current->link = next->link;
- next->link = current;
-
- /* this is likely the only necessary swap -- restart */
- old = list;
- current = *old;
- }
- }
- }
-
-
- /**************************************************************************
- *
- * Vertical Sweep Procedure Set
- *
- * These four routines are used during the vertical black/white sweep
- * phase by the generic Draw_Sweep() function.
- *
- */
-
- static void
- Vertical_Sweep_Init( RAS_ARGS Int min,
- Int max )
- {
- FT_UNUSED( max );
-
-
- ras.bLine = ras.bOrigin - min * ras.bPitch;
- }
-
-
- static void
- Vertical_Sweep_Span( RAS_ARGS Int y,
- FT_F26Dot6 x1,
- FT_F26Dot6 x2 )
- {
- Int e1 = (Int)TRUNC( CEILING( x1 ) );
- Int e2 = (Int)TRUNC( FLOOR( x2 ) );
-
- FT_UNUSED( y );
-
-
- FT_TRACE7(( " y=%d x=[% .*f;% .*f]",
- y,
- ras.precision_bits, (double)x1 / (double)ras.precision,
- ras.precision_bits, (double)x2 / (double)ras.precision ));
-
- if ( e2 >= 0 && e1 <= ras.bRight )
- {
- PByte target;
-
- Int c1, f1, c2, f2;
-
-
- if ( e1 < 0 )
- e1 = 0;
- if ( e2 > ras.bRight )
- e2 = ras.bRight;
-
- FT_TRACE7(( " -> x=[%d;%d]", e1, e2 ));
-
- c1 = e1 >> 3;
- c2 = e2 >> 3;
-
- f1 = 0xFF >> ( e1 & 7 );
- f2 = ~0x7F >> ( e2 & 7 );
-
- target = ras.bLine + c1;
- c2 -= c1;
-
- if ( c2 > 0 )
- {
- target[0] |= f1;
-
- /* memset() is slower than the following code on many platforms. */
- /* This is due to the fact that, in the vast majority of cases, */
- /* the span length in bytes is relatively small. */
- while ( --c2 > 0 )
- *( ++target ) = 0xFF;
-
- target[1] |= f2;
- }
- else
- *target |= ( f1 & f2 );
- }
-
- FT_TRACE7(( "\n" ));
- }
-
-
- static void
- Vertical_Sweep_Drop( RAS_ARGS Int y,
- FT_F26Dot6 x1,
- FT_F26Dot6 x2 )
- {
- Int e1 = (Int)TRUNC( x1 );
- Int e2 = (Int)TRUNC( x2 );
- Int c1, f1;
-
- FT_UNUSED( y );
-
-
- /* undocumented but confirmed: If the drop-out would result in a */
- /* pixel outside of the bounding box, use the pixel inside of the */
- /* bounding box instead */
- if ( e1 < 0 || e1 > ras.bRight )
- e1 = e2;
-
- /* otherwise check that the other pixel isn't set */
- else if ( e2 >=0 && e2 <= ras.bRight )
- {
- c1 = e2 >> 3;
- f1 = 0x80 >> ( e2 & 7 );
-
- if ( ras.bLine[c1] & f1 )
- return;
- }
-
- if ( e1 >= 0 && e1 <= ras.bRight )
- {
- c1 = e1 >> 3;
- f1 = 0x80 >> ( e1 & 7 );
-
- FT_TRACE7(( " y=%d x=%d%s\n", y, e1,
- ras.bLine[c1] & f1 ? " redundant" : "" ));
-
- ras.bLine[c1] |= f1;
- }
- }
-
-
- static void
- Vertical_Sweep_Step( RAS_ARG )
- {
- ras.bLine -= ras.bPitch;
- }
-
-
- /************************************************************************
- *
- * Horizontal Sweep Procedure Set
- *
- * These four routines are used during the horizontal black/white
- * sweep phase by the generic Draw_Sweep() function.
- *
- */
-
- static void
- Horizontal_Sweep_Init( RAS_ARGS Int min,
- Int max )
- {
- /* nothing, really */
- FT_UNUSED_RASTER;
- FT_UNUSED( min );
- FT_UNUSED( max );
- }
-
-
- static void
- Horizontal_Sweep_Span( RAS_ARGS Int y,
- FT_F26Dot6 x1,
- FT_F26Dot6 x2 )
- {
- Long e1 = CEILING( x1 );
- Long e2 = FLOOR( x2 );
-
-
- FT_TRACE7(( " x=%d y=[% .*f;% .*f]",
- y,
- ras.precision_bits, (double)x1 / (double)ras.precision,
- ras.precision_bits, (double)x2 / (double)ras.precision ));
-
- /* We should not need this procedure but the vertical sweep */
- /* mishandles horizontal lines through pixel centers. So we */
- /* have to check perfectly aligned span edges here. */
- /* */
- /* XXX: Can we handle horizontal lines better and drop this? */
-
- if ( x1 == e1 )
- {
- e1 = TRUNC( e1 );
-
- if ( e1 >= 0 && e1 <= ras.bTop )
- {
- Int f1;
- PByte bits;
-
-
- bits = ras.bOrigin + ( y >> 3 ) - e1 * ras.bPitch;
- f1 = 0x80 >> ( y & 7 );
-
- FT_TRACE7(( bits[0] & f1 ? " redundant"
- : " -> y=%ld edge", e1 ));
-
- bits[0] |= f1;
- }
- }
-
- if ( x2 == e2 )
- {
- e2 = TRUNC( e2 );
-
- if ( e2 >= 0 && e2 <= ras.bTop )
- {
- Int f1;
- PByte bits;
-
-
- bits = ras.bOrigin + ( y >> 3 ) - e2 * ras.bPitch;
- f1 = 0x80 >> ( y & 7 );
-
- FT_TRACE7(( bits[0] & f1 ? " redundant"
- : " -> y=%ld edge", e2 ));
-
- bits[0] |= f1;
- }
- }
-
- FT_TRACE7(( "\n" ));
- }
-
-
- static void
- Horizontal_Sweep_Drop( RAS_ARGS Int y,
- FT_F26Dot6 x1,
- FT_F26Dot6 x2 )
- {
- Int e1 = (Int)TRUNC( x1 );
- Int e2 = (Int)TRUNC( x2 );
- PByte bits;
- Int f1;
-
-
- /* undocumented but confirmed: If the drop-out would result in a */
- /* pixel outside of the bounding box, use the pixel inside of the */
- /* bounding box instead */
- if ( e1 < 0 || e1 > ras.bTop )
- e1 = e2;
-
- /* otherwise check that the other pixel isn't set */
- else if ( e2 >=0 && e2 <= ras.bTop )
- {
- bits = ras.bOrigin + ( y >> 3 ) - e2 * ras.bPitch;
- f1 = 0x80 >> ( y & 7 );
-
- if ( *bits & f1 )
- return;
- }
-
- if ( e1 >= 0 && e1 <= ras.bTop )
- {
- bits = ras.bOrigin + ( y >> 3 ) - e1 * ras.bPitch;
- f1 = 0x80 >> ( y & 7 );
-
- FT_TRACE7(( " x=%d y=%d%s\n", y, e1,
- *bits & f1 ? " redundant" : "" ));
-
- *bits |= f1;
- }
- }
-
-
- static void
- Horizontal_Sweep_Step( RAS_ARG )
- {
- /* Nothing, really */
- FT_UNUSED_RASTER;
- }
-
-
- /**************************************************************************
- *
- * Generic Sweep Drawing routine
- *
- * Note that this routine is executed with the pool containing at least
- * two valid profiles (up and down) and two y-turns (top and bottom).
- *
- */
-
- static void
- Draw_Sweep( RAS_ARG )
- {
- Int min_Y, max_Y, dropouts;
- Int y, y_turn;
-
- PProfile *Q, P, P_Left, P_Right;
-
- TProfileList waiting = ras.fProfile;
- TProfileList draw_left = NULL;
- TProfileList draw_right = NULL;
-
-
- /* use y_turns to set the drawing range */
-
- min_Y = (Int)ras.maxBuff[0];
- max_Y = (Int)ras.maxBuff[ras.numTurns] - 1;
-
- /* now initialize the sweep */
-
- ras.Proc_Sweep_Init( RAS_VARS min_Y, max_Y );
-
- /* let's go */
-
- for ( y = min_Y; y <= max_Y; )
- {
- /* check waiting list for new profile activations */
-
- Q = &waiting;
- while ( *Q )
- {
- P = *Q;
- if ( P->start == y )
- {
- *Q = P->link; /* remove */
-
- /* each active list contains profiles with the same flow */
- /* left and right are arbitrary, correspond to TrueType */
- if ( P->flags & Flow_Up )
- InsNew( &draw_left, P );
- else
- InsNew( &draw_right, P );
- }
- else
- Q = &P->link;
- }
-
- y_turn = (Int)*++ras.maxBuff;
-
- do
- {
- /* let's trace */
-
- dropouts = 0;
-
- P_Left = draw_left;
- P_Right = draw_right;
-
- while ( P_Left && P_Right )
- {
- Long x1 = P_Left ->X;
- Long x2 = P_Right->X;
- Long xs;
-
-
- /* TrueType should have x2 > x1, but can be opposite */
- /* by mistake or in CFF/Type1, fix it then */
- if ( x1 > x2 )
- {
- xs = x1;
- x1 = x2;
- x2 = xs;
- }
-
- if ( CEILING( x1 ) <= FLOOR( x2 ) )
- ras.Proc_Sweep_Span( RAS_VARS y, x1, x2 );
-
- /* otherwise, bottom ceiling > top floor, it is a drop-out */
- else
- {
- Int dropOutControl = P_Left->flags & 7;
-
-
- /* Drop-out control */
-
- /* e2 x2 x1 e1 */
- /* */
- /* ^ | */
- /* | | */
- /* +-------------+---------------------+------------+ */
- /* | | */
- /* | v */
- /* */
- /* pixel contour contour pixel */
- /* center center */
-
- /* drop-out mode scan conversion rules (OpenType specs) */
- /* ------------------------------------------------------- */
- /* bit 0 exclude stubs if set */
- /* bit 1 ignore drop-outs if set */
- /* bit 2 smart rounding if set */
-
- if ( dropOutControl & 2 )
- goto Next_Pair;
-
- /* The specification neither provides an exact definition */
- /* of a `stub' nor gives exact rules to exclude them. */
- /* */
- /* Here the constraints we use to recognize a stub. */
- /* */
- /* upper stub: */
- /* */
- /* - P_Left and P_Right are in the same contour */
- /* - P_Right is the successor of P_Left in that contour */
- /* - y is the top of P_Left and P_Right */
- /* */
- /* lower stub: */
- /* */
- /* - P_Left and P_Right are in the same contour */
- /* - P_Left is the successor of P_Right in that contour */
- /* - y is the bottom of P_Left */
- /* */
- /* We draw a stub if the following constraints are met. */
- /* */
- /* - for an upper or lower stub, there is top or bottom */
- /* overshoot, respectively */
- /* - the covered interval is greater or equal to a half */
- /* pixel */
-
- if ( dropOutControl & 1 )
- {
- /* upper stub test */
- if ( P_Left->height == 1 &&
- P_Left->next == P_Right &&
- !( P_Left->flags & Overshoot_Top &&
- x2 - x1 >= ras.precision_half ) )
- goto Next_Pair;
-
- /* lower stub test */
- if ( P_Left->offset == 0 &&
- P_Right->next == P_Left &&
- !( P_Left->flags & Overshoot_Bottom &&
- x2 - x1 >= ras.precision_half ) )
- goto Next_Pair;
- }
-
- /* select the pixel to set and the other pixel */
- if ( dropOutControl & 4 )
- {
- x2 = SMART( x1, x2 );
- x1 = x1 > x2 ? x2 + ras.precision : x2 - ras.precision;
- }
- else
- {
- x2 = FLOOR ( x2 );
- x1 = CEILING( x1 );
- }
-
- P_Left ->X = x2;
- P_Right->X = x1;
-
- /* mark profile for drop-out processing */
- P_Left->flags |= Dropout;
- dropouts++;
- }
-
- Next_Pair:
- P_Left = P_Left->link;
- P_Right = P_Right->link;
- }
-
- /* handle drop-outs _after_ the span drawing */
- P_Left = draw_left;
- P_Right = draw_right;
-
- while ( dropouts )
- {
- if ( P_Left->flags & Dropout )
- {
- ras.Proc_Sweep_Drop( RAS_VARS y, P_Left->X, P_Right->X );
-
- P_Left->flags &= ~Dropout;
- dropouts--;
- }
-
- P_Left = P_Left->link;
- P_Right = P_Right->link;
- }
-
- ras.Proc_Sweep_Step( RAS_VAR );
-
- Increment( &draw_left, 1 );
- Increment( &draw_right, -1 );
- }
- while ( ++y < y_turn );
- }
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * Render_Single_Pass
- *
- * @Description:
- * Perform one sweep with sub-banding.
- *
- * @Input:
- * flipped ::
- * If set, flip the direction of the outline.
- *
- * @Return:
- * Renderer error code.
- */
- static int
- Render_Single_Pass( RAS_ARGS Bool flipped,
- Int y_min,
- Int y_max )
- {
- Int y_mid;
- Int band_top = 0;
- Int band_stack[32]; /* enough to bisect 32-bit int bands */
-
-
- FT_TRACE6(( "%s pass [%d..%d]\n",
- flipped ? "Horizontal" : "Vertical",
- y_min, y_max ));
-
- while ( 1 )
- {
- ras.minY = (Long)y_min * ras.precision;
- ras.maxY = (Long)y_max * ras.precision;
-
- ras.error = Raster_Err_Ok;
-
- if ( Convert_Glyph( RAS_VARS flipped ) )
- {
- if ( ras.error != Raster_Err_Raster_Overflow )
- return ras.error;
-
- /* sub-banding */
-
- if ( y_min == y_max )
- return ras.error; /* still Raster_Overflow */
-
- FT_TRACE6(( "band [%d..%d]: to be bisected\n",
- y_min, y_max ));
-
- y_mid = ( y_min + y_max ) >> 1;
-
- band_stack[band_top++] = y_min;
- y_min = y_mid + 1;
- }
- else
- {
- FT_TRACE6(( "band [%d..%d]: %hd profiles; %td bytes remaining\n",
- y_min, y_max, ras.num_Profs,
- (char*)ras.maxBuff - (char*)ras.top ));
-
- if ( ras.fProfile )
- Draw_Sweep( RAS_VAR );
-
- if ( --band_top < 0 )
- break;
-
- y_max = y_min - 1;
- y_min = band_stack[band_top];
- }
- }
-
- return Raster_Err_Ok;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * Render_Glyph
- *
- * @Description:
- * Render a glyph in a bitmap. Sub-banding if needed.
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
- static FT_Error
- Render_Glyph( RAS_ARG )
- {
- FT_Error error;
- Long buffer[FT_MAX_BLACK_POOL];
-
-
- ras.buff = buffer;
- ras.sizeBuff = (&buffer)[1]; /* Points to right after buffer. */
-
- Set_High_Precision( RAS_VARS ras.outline.flags &
- FT_OUTLINE_HIGH_PRECISION );
-
- ras.dropOutControl = 0;
-
- if ( ras.outline.flags & FT_OUTLINE_IGNORE_DROPOUTS )
- ras.dropOutControl |= 2;
-
- if ( ras.outline.flags & FT_OUTLINE_SMART_DROPOUTS )
- ras.dropOutControl |= 4;
-
- if ( !( ras.outline.flags & FT_OUTLINE_INCLUDE_STUBS ) )
- ras.dropOutControl |= 1;
-
- FT_TRACE6(( "BW Raster: precision 1/%d, dropout mode %d\n",
- ras.precision, ras.dropOutControl ));
-
- /* Vertical Sweep */
- ras.Proc_Sweep_Init = Vertical_Sweep_Init;
- ras.Proc_Sweep_Span = Vertical_Sweep_Span;
- ras.Proc_Sweep_Drop = Vertical_Sweep_Drop;
- ras.Proc_Sweep_Step = Vertical_Sweep_Step;
-
- error = Render_Single_Pass( RAS_VARS 0, 0, ras.bTop );
- if ( error )
- return error;
-
- /* Horizontal Sweep */
- if ( !( ras.outline.flags & FT_OUTLINE_SINGLE_PASS ) )
- {
- ras.Proc_Sweep_Init = Horizontal_Sweep_Init;
- ras.Proc_Sweep_Span = Horizontal_Sweep_Span;
- ras.Proc_Sweep_Drop = Horizontal_Sweep_Drop;
- ras.Proc_Sweep_Step = Horizontal_Sweep_Step;
-
- error = Render_Single_Pass( RAS_VARS 1, 0, ras.bRight );
- if ( error )
- return error;
- }
-
- return Raster_Err_Ok;
- }
-
-
- /**** RASTER OBJECT CREATION: In standalone mode, we simply use *****/
- /**** a static object. *****/
-
-
-#ifdef STANDALONE_
-
-
- static int
- ft_black_new( void* memory,
- FT_Raster *araster )
- {
- static black_TRaster the_raster;
- FT_UNUSED( memory );
-
-
- *araster = (FT_Raster)&the_raster;
- FT_ZERO( &the_raster );
-
- return 0;
- }
-
-
- static void
- ft_black_done( FT_Raster raster )
- {
- /* nothing */
- FT_UNUSED( raster );
- }
-
-
-#else /* !STANDALONE_ */
-
-
- static int
- ft_black_new( void* memory_, /* FT_Memory */
- FT_Raster *araster_ ) /* black_PRaster */
- {
- FT_Memory memory = (FT_Memory)memory_;
- black_PRaster *araster = (black_PRaster*)araster_;
-
- FT_Error error;
- black_PRaster raster = NULL;
-
-
- if ( !FT_NEW( raster ) )
- raster->memory = memory;
-
- *araster = raster;
-
- return error;
- }
-
-
- static void
- ft_black_done( FT_Raster raster_ ) /* black_PRaster */
- {
- black_PRaster raster = (black_PRaster)raster_;
- FT_Memory memory = (FT_Memory)raster->memory;
-
-
- FT_FREE( raster );
- }
-
-
-#endif /* !STANDALONE_ */
-
-
- static void
- ft_black_reset( FT_Raster raster,
- PByte pool_base,
- ULong pool_size )
- {
- FT_UNUSED( raster );
- FT_UNUSED( pool_base );
- FT_UNUSED( pool_size );
- }
-
-
- static int
- ft_black_set_mode( FT_Raster raster,
- ULong mode,
- void* args )
- {
- FT_UNUSED( raster );
- FT_UNUSED( mode );
- FT_UNUSED( args );
-
- return 0;
- }
-
-
- static int
- ft_black_render( FT_Raster raster,
- const FT_Raster_Params* params )
- {
- const FT_Outline* outline = (const FT_Outline*)params->source;
- const FT_Bitmap* target_map = params->target;
-
-#ifndef FT_STATIC_RASTER
- black_TWorker worker[1];
-#endif
-
-
- if ( !raster )
- return FT_THROW( Raster_Uninitialized );
-
- if ( !outline )
- return FT_THROW( Invalid_Outline );
-
- /* return immediately if the outline is empty */
- if ( outline->n_points == 0 || outline->n_contours == 0 )
- return Raster_Err_Ok;
-
- if ( !outline->contours || !outline->points )
- return FT_THROW( Invalid_Outline );
-
- if ( outline->n_points !=
- outline->contours[outline->n_contours - 1] + 1 )
- return FT_THROW( Invalid_Outline );
-
- /* this version of the raster does not support direct rendering, sorry */
- if ( params->flags & FT_RASTER_FLAG_DIRECT ||
- params->flags & FT_RASTER_FLAG_AA )
- return FT_THROW( Cannot_Render_Glyph );
-
- if ( !target_map )
- return FT_THROW( Invalid_Argument );
-
- /* nothing to do */
- if ( !target_map->width || !target_map->rows )
- return Raster_Err_Ok;
-
- if ( !target_map->buffer )
- return FT_THROW( Invalid_Argument );
-
- ras.outline = *outline;
-
- ras.bTop = (Int)target_map->rows - 1;
- ras.bRight = (Int)target_map->width - 1;
- ras.bPitch = (Int)target_map->pitch;
- ras.bOrigin = (PByte)target_map->buffer;
-
- if ( ras.bPitch > 0 )
- ras.bOrigin += ras.bTop * ras.bPitch;
-
- return Render_Glyph( RAS_VAR );
- }
-
-
- FT_DEFINE_RASTER_FUNCS(
- ft_standard_raster,
-
- FT_GLYPH_FORMAT_OUTLINE,
-
- ft_black_new, /* FT_Raster_New_Func raster_new */
- ft_black_reset, /* FT_Raster_Reset_Func raster_reset */
- ft_black_set_mode, /* FT_Raster_Set_Mode_Func raster_set_mode */
- ft_black_render, /* FT_Raster_Render_Func raster_render */
- ft_black_done /* FT_Raster_Done_Func raster_done */
- )
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/raster/ftraster.h b/contrib/libs/freetype/src/raster/ftraster.h
deleted file mode 100644
index ad9cb1b9fe..0000000000
--- a/contrib/libs/freetype/src/raster/ftraster.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/****************************************************************************
- *
- * ftraster.h
- *
- * The FreeType glyph rasterizer (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used
- * modified and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTRASTER_H_
-#define FTRASTER_H_
-
-
-#include <ft2build.h>
-#include FT_CONFIG_CONFIG_H
-#include <freetype/ftimage.h>
-
-#include <freetype/internal/compiler-macros.h>
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * Uncomment the following line if you are using ftraster.c as a
- * standalone module, fully independent of FreeType.
- */
-/* #define STANDALONE_ */
-
- FT_EXPORT_VAR( const FT_Raster_Funcs ) ft_standard_raster;
-
-
-FT_END_HEADER
-
-#endif /* FTRASTER_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/raster/ftrend1.c b/contrib/libs/freetype/src/raster/ftrend1.c
deleted file mode 100644
index fd9f174f2e..0000000000
--- a/contrib/libs/freetype/src/raster/ftrend1.c
+++ /dev/null
@@ -1,209 +0,0 @@
-/****************************************************************************
- *
- * ftrend1.c
- *
- * The FreeType glyph rasterizer interface (body).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftobjs.h>
-#include <freetype/ftoutln.h>
-#include "ftrend1.h"
-#include "ftraster.h"
-
-#include "rasterrs.h"
-
-
- /* initialize renderer -- init its raster */
- static FT_Error
- ft_raster1_init( FT_Module module ) /* FT_Renderer */
- {
- FT_Renderer render = (FT_Renderer)module;
-
-
- render->clazz->raster_class->raster_reset( render->raster, NULL, 0 );
-
- return FT_Err_Ok;
- }
-
-
- /* set render-specific mode */
- static FT_Error
- ft_raster1_set_mode( FT_Renderer render,
- FT_ULong mode_tag,
- FT_Pointer data )
- {
- /* we simply pass it to the raster */
- return render->clazz->raster_class->raster_set_mode( render->raster,
- mode_tag,
- data );
- }
-
-
- /* transform a given glyph image */
- static FT_Error
- ft_raster1_transform( FT_Renderer render,
- FT_GlyphSlot slot,
- const FT_Matrix* matrix,
- const FT_Vector* delta )
- {
- FT_Error error = FT_Err_Ok;
-
-
- if ( slot->format != render->glyph_format )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- if ( matrix )
- FT_Outline_Transform( &slot->outline, matrix );
-
- if ( delta )
- FT_Outline_Translate( &slot->outline, delta->x, delta->y );
-
- Exit:
- return error;
- }
-
-
- /* return the glyph's control box */
- static void
- ft_raster1_get_cbox( FT_Renderer render,
- FT_GlyphSlot slot,
- FT_BBox* cbox )
- {
- FT_ZERO( cbox );
-
- if ( slot->format == render->glyph_format )
- FT_Outline_Get_CBox( &slot->outline, cbox );
- }
-
-
- /* convert a slot's glyph image into a bitmap */
- static FT_Error
- ft_raster1_render( FT_Renderer render,
- FT_GlyphSlot slot,
- FT_Render_Mode mode,
- const FT_Vector* origin )
- {
- FT_Error error = FT_Err_Ok;
- FT_Outline* outline = &slot->outline;
- FT_Bitmap* bitmap = &slot->bitmap;
- FT_Memory memory = render->root.memory;
- FT_Pos x_shift = 0;
- FT_Pos y_shift = 0;
-
- FT_Raster_Params params;
-
-
- /* check glyph image format */
- if ( slot->format != render->glyph_format )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- /* check rendering mode */
- if ( mode != FT_RENDER_MODE_MONO )
- {
- /* raster1 is only capable of producing monochrome bitmaps */
- return FT_THROW( Cannot_Render_Glyph );
- }
-
- /* release old bitmap buffer */
- if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
- {
- FT_FREE( bitmap->buffer );
- slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
- }
-
- if ( ft_glyphslot_preset_bitmap( slot, mode, origin ) )
- {
- error = FT_THROW( Raster_Overflow );
- goto Exit;
- }
-
- /* allocate new one */
- if ( FT_ALLOC_MULT( bitmap->buffer, bitmap->rows, bitmap->pitch ) )
- goto Exit;
-
- slot->internal->flags |= FT_GLYPH_OWN_BITMAP;
-
- x_shift = -slot->bitmap_left * 64;
- y_shift = ( (FT_Int)bitmap->rows - slot->bitmap_top ) * 64;
-
- if ( origin )
- {
- x_shift += origin->x;
- y_shift += origin->y;
- }
-
- /* translate outline to render it into the bitmap */
- if ( x_shift || y_shift )
- FT_Outline_Translate( outline, x_shift, y_shift );
-
- /* set up parameters */
- params.target = bitmap;
- params.source = outline;
- params.flags = FT_RASTER_FLAG_DEFAULT;
-
- /* render outline into the bitmap */
- error = render->raster_render( render->raster, &params );
-
- Exit:
- if ( !error )
- /* everything is fine; the glyph is now officially a bitmap */
- slot->format = FT_GLYPH_FORMAT_BITMAP;
- else if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
- {
- FT_FREE( bitmap->buffer );
- slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
- }
-
- if ( x_shift || y_shift )
- FT_Outline_Translate( outline, -x_shift, -y_shift );
-
- return error;
- }
-
-
- FT_DEFINE_RENDERER(
- ft_raster1_renderer_class,
-
- FT_MODULE_RENDERER,
- sizeof ( FT_RendererRec ),
-
- "raster1",
- 0x10000L,
- 0x20000L,
-
- NULL, /* module specific interface */
-
- ft_raster1_init, /* FT_Module_Constructor module_init */
- NULL, /* FT_Module_Destructor module_done */
- NULL, /* FT_Module_Requester get_interface */
-
- FT_GLYPH_FORMAT_OUTLINE,
-
- ft_raster1_render, /* FT_Renderer_RenderFunc render_glyph */
- ft_raster1_transform, /* FT_Renderer_TransformFunc transform_glyph */
- ft_raster1_get_cbox, /* FT_Renderer_GetCBoxFunc get_glyph_cbox */
- ft_raster1_set_mode, /* FT_Renderer_SetModeFunc set_mode */
-
- &ft_standard_raster /* FT_Raster_Funcs* raster_class */
- )
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/raster/ftrend1.h b/contrib/libs/freetype/src/raster/ftrend1.h
deleted file mode 100644
index cf3e73c0a2..0000000000
--- a/contrib/libs/freetype/src/raster/ftrend1.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/****************************************************************************
- *
- * ftrend1.h
- *
- * The FreeType glyph rasterizer interface (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTREND1_H_
-#define FTREND1_H_
-
-
-#include <freetype/ftrender.h>
-
-
-FT_BEGIN_HEADER
-
-
- FT_DECLARE_RENDERER( ft_raster1_renderer_class )
-
-
-FT_END_HEADER
-
-#endif /* FTREND1_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/raster/raster.c b/contrib/libs/freetype/src/raster/raster.c
deleted file mode 100644
index fe33af2423..0000000000
--- a/contrib/libs/freetype/src/raster/raster.c
+++ /dev/null
@@ -1,25 +0,0 @@
-/****************************************************************************
- *
- * raster.c
- *
- * FreeType monochrome rasterer module component (body only).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#define FT_MAKE_OPTION_SINGLE_OBJECT
-
-#include "ftraster.c"
-#include "ftrend1.c"
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/raster/rasterrs.h b/contrib/libs/freetype/src/raster/rasterrs.h
deleted file mode 100644
index 326d42e043..0000000000
--- a/contrib/libs/freetype/src/raster/rasterrs.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
- *
- * rasterrs.h
- *
- * monochrome renderer error codes (specification only).
- *
- * Copyright (C) 2001-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /**************************************************************************
- *
- * This file is used to define the monochrome renderer error enumeration
- * constants.
- *
- */
-
-#ifndef RASTERRS_H_
-#define RASTERRS_H_
-
-#include <freetype/ftmoderr.h>
-
-#undef FTERRORS_H_
-
-#undef FT_ERR_PREFIX
-#define FT_ERR_PREFIX Raster_Err_
-#define FT_ERR_BASE FT_Mod_Err_Raster
-
-#include <freetype/fterrors.h>
-
-#endif /* RASTERRS_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/sdf/ftbsdf.c b/contrib/libs/freetype/src/sdf/ftbsdf.c
deleted file mode 100644
index adde05ba19..0000000000
--- a/contrib/libs/freetype/src/sdf/ftbsdf.c
+++ /dev/null
@@ -1,1350 +0,0 @@
-/****************************************************************************
- *
- * ftbsdf.c
- *
- * Signed Distance Field support for bitmap fonts (body only).
- *
- * Copyright (C) 2020-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * Written by Anuj Verma.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftmemory.h>
-#include <freetype/fttrigon.h>
-
-#include "ftsdf.h"
-#include "ftsdferrs.h"
-#include "ftsdfcommon.h"
-
-
- /**************************************************************************
- *
- * A brief technical overview of how the BSDF rasterizer works
- * -----------------------------------------------------------
- *
- * [Notes]:
- * * SDF stands for Signed Distance Field everywhere.
- *
- * * BSDF stands for Bitmap to Signed Distance Field rasterizer.
- *
- * * This renderer converts rasterized bitmaps to SDF. There is another
- * renderer called 'sdf', which generates SDF directly from outlines;
- * see file `ftsdf.c` for more.
- *
- * * The idea of generating SDF from bitmaps is taken from two research
- * papers, where one is dependent on the other:
- *
- * - Per-Erik Danielsson: Euclidean Distance Mapping
- * http://webstaff.itn.liu.se/~stegu/JFA/Danielsson.pdf
- *
- * From this paper we use the eight-point sequential Euclidean
- * distance mapping (8SED). This is the heart of the process used
- * in this rasterizer.
- *
- * - Stefan Gustavson, Robin Strand: Anti-aliased Euclidean distance transform.
- * http://weber.itn.liu.se/~stegu/aadist/edtaa_preprint.pdf
- *
- * The original 8SED algorithm discards the pixels' alpha values,
- * which can contain information about the actual outline of the
- * glyph. This paper takes advantage of those alpha values and
- * approximates outline pretty accurately.
- *
- * * This rasterizer also works for monochrome bitmaps. However, the
- * result is not as accurate since we don't have any way to
- * approximate outlines from binary bitmaps.
- *
- * ========================================================================
- *
- * Generating SDF from bitmap is done in several steps.
- *
- * (1) The only information we have is the bitmap itself. It can
- * be monochrome or anti-aliased. If it is anti-aliased, pixel values
- * are nothing but coverage values. These coverage values can be used
- * to extract information about the outline of the image. For
- * example, if the pixel's alpha value is 0.5, then we can safely
- * assume that the outline passes through the center of the pixel.
- *
- * (2) Find edge pixels in the bitmap (see `bsdf_is_edge` for more). For
- * all edge pixels we use the Anti-aliased Euclidean distance
- * transform algorithm and compute approximate edge distances (see
- * `compute_edge_distance` and/or the second paper for more).
- *
- * (3) Now that we have computed approximate distances for edge pixels we
- * use the 8SED algorithm to basically sweep the entire bitmap and
- * compute distances for the rest of the pixels. (Since the algorithm
- * is pretty convoluted it is only explained briefly in a comment to
- * function `edt8`. To see the actual algorithm refer to the first
- * paper.)
- *
- * (4) Finally, compute the sign for each pixel. This is done in function
- * `finalize_sdf`. The basic idea is that if a pixel's original
- * alpha/coverage value is greater than 0.5 then it is 'inside' (and
- * 'outside' otherwise).
- *
- * Pseudo Code:
- *
- * ```
- * b = source bitmap;
- * t = target bitmap;
- * dm = list of distances; // dimension equal to b
- *
- * foreach grid_point (x, y) in b:
- * {
- * if (is_edge(x, y)):
- * dm = approximate_edge_distance(b, x, y);
- *
- * // do the 8SED on the distances
- * edt8(dm);
- *
- * // determine the signs
- * determine_signs(dm):
- *
- * // copy SDF data to the target bitmap
- * copy(dm to t);
- * }
- *
- */
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT bsdf
-
-
- /**************************************************************************
- *
- * useful macros
- *
- */
-
-#define ONE 65536 /* 1 in 16.16 */
-
-
- /**************************************************************************
- *
- * structs
- *
- */
-
-
- /**************************************************************************
- *
- * @Struct:
- * BSDF_TRaster
- *
- * @Description:
- * This struct is used in place of @FT_Raster and is stored within the
- * internal FreeType renderer struct. While rasterizing this is passed
- * to the @FT_Raster_RenderFunc function, which then can be used however
- * we want.
- *
- * @Fields:
- * memory ::
- * Used internally to allocate intermediate memory while raterizing.
- *
- */
- typedef struct BSDF_TRaster_
- {
- FT_Memory memory;
-
- } BSDF_TRaster, *BSDF_PRaster;
-
-
- /**************************************************************************
- *
- * @Struct:
- * ED
- *
- * @Description:
- * Euclidean distance. It gets used for Euclidean distance transforms;
- * it can also be interpreted as an edge distance.
- *
- * @Fields:
- * dist ::
- * Vector length of the `prox` parameter. Can be squared or absolute
- * depending on the `USE_SQUARED_DISTANCES` macro defined in file
- * `ftsdfcommon.h`.
- *
- * prox ::
- * Vector to the nearest edge. Can also be interpreted as shortest
- * distance of a point.
- *
- * alpha ::
- * Alpha value of the original bitmap from which we generate SDF.
- * Needed for computing the gradient and determining the proper sign
- * of a pixel.
- *
- */
- typedef struct ED_
- {
- FT_16D16 dist;
- FT_16D16_Vec prox;
- FT_Byte alpha;
-
- } ED;
-
-
- /**************************************************************************
- *
- * @Struct:
- * BSDF_Worker
- *
- * @Description:
- * A convenience struct that is passed to functions while generating
- * SDF; most of those functions require the same parameters.
- *
- * @Fields:
- * distance_map ::
- * A one-dimensional array that gets interpreted as two-dimensional
- * one. It contains the Euclidean distances of all points of the
- * bitmap.
- *
- * width ::
- * Width of the above `distance_map`.
- *
- * rows ::
- * Number of rows in the above `distance_map`.
- *
- * params ::
- * Internal parameters and properties required by the rasterizer. See
- * file `ftsdf.h` for more.
- *
- */
- typedef struct BSDF_Worker_
- {
- ED* distance_map;
-
- FT_Int width;
- FT_Int rows;
-
- SDF_Raster_Params params;
-
- } BSDF_Worker;
-
-
- /**************************************************************************
- *
- * initializer
- *
- */
-
- static const ED zero_ed = { 0, { 0, 0 }, 0 };
-
-
- /**************************************************************************
- *
- * rasterizer functions
- *
- */
-
- /**************************************************************************
- *
- * @Function:
- * bsdf_is_edge
- *
- * @Description:
- * Check whether a pixel is an edge pixel, i.e., whether it is
- * surrounded by a completely black pixel (zero alpha), and the current
- * pixel is not a completely black pixel.
- *
- * @Input:
- * dm ::
- * Array of distances. The parameter must point to the current
- * pixel, i.e., the pixel that is to be checked for being an edge.
- *
- * x ::
- * The x position of the current pixel.
- *
- * y ::
- * The y position of the current pixel.
- *
- * w ::
- * Width of the bitmap.
- *
- * r ::
- * Number of rows in the bitmap.
- *
- * @Return:
- * 1~if the current pixel is an edge pixel, 0~otherwise.
- *
- */
-
-#ifdef CHECK_NEIGHBOR
-#undef CHECK_NEIGHBOR
-#endif
-
-#define CHECK_NEIGHBOR( x_offset, y_offset ) \
- do \
- { \
- if ( x + x_offset >= 0 && x + x_offset < w && \
- y + y_offset >= 0 && y + y_offset < r ) \
- { \
- num_neighbors++; \
- \
- to_check = dm + y_offset * w + x_offset; \
- if ( to_check->alpha == 0 ) \
- { \
- is_edge = 1; \
- goto Done; \
- } \
- } \
- } while ( 0 )
-
- static FT_Bool
- bsdf_is_edge( ED* dm, /* distance map */
- FT_Int x, /* x index of point to check */
- FT_Int y, /* y index of point to check */
- FT_Int w, /* width */
- FT_Int r ) /* rows */
- {
- FT_Bool is_edge = 0;
- ED* to_check = NULL;
- FT_Int num_neighbors = 0;
-
-
- if ( dm->alpha == 0 )
- goto Done;
-
- if ( dm->alpha > 0 && dm->alpha < 255 )
- {
- is_edge = 1;
- goto Done;
- }
-
- /* up */
- CHECK_NEIGHBOR( 0, -1 );
-
- /* down */
- CHECK_NEIGHBOR( 0, 1 );
-
- /* left */
- CHECK_NEIGHBOR( -1, 0 );
-
- /* right */
- CHECK_NEIGHBOR( 1, 0 );
-
- /* up left */
- CHECK_NEIGHBOR( -1, -1 );
-
- /* up right */
- CHECK_NEIGHBOR( 1, -1 );
-
- /* down left */
- CHECK_NEIGHBOR( -1, 1 );
-
- /* down right */
- CHECK_NEIGHBOR( 1, 1 );
-
- if ( num_neighbors != 8 )
- is_edge = 1;
-
- Done:
- return is_edge;
- }
-
-#undef CHECK_NEIGHBOR
-
-
- /**************************************************************************
- *
- * @Function:
- * compute_edge_distance
- *
- * @Description:
- * Approximate the outline and compute the distance from `current`
- * to the approximated outline.
- *
- * @Input:
- * current ::
- * Array of Euclidean distances. `current` must point to the position
- * for which the distance is to be caculated. We treat this array as
- * a two-dimensional array mapped to a one-dimensional array.
- *
- * x ::
- * The x coordinate of the `current` parameter in the array.
- *
- * y ::
- * The y coordinate of the `current` parameter in the array.
- *
- * w ::
- * The width of the distances array.
- *
- * r ::
- * Number of rows in the distances array.
- *
- * @Return:
- * A vector pointing to the approximate edge distance.
- *
- * @Note:
- * This is a computationally expensive function. Try to reduce the
- * number of calls to this function. Moreover, this must only be used
- * for edge pixel positions.
- *
- */
- static FT_16D16_Vec
- compute_edge_distance( ED* current,
- FT_Int x,
- FT_Int y,
- FT_Int w,
- FT_Int r )
- {
- /*
- * This function, based on the paper presented by Stefan Gustavson and
- * Robin Strand, gets used to approximate edge distances from
- * anti-aliased bitmaps.
- *
- * The algorithm is as follows.
- *
- * (1) In anti-aliased images, the pixel's alpha value is the coverage
- * of the pixel by the outline. For example, if the alpha value is
- * 0.5f we can assume that the outline passes through the center of
- * the pixel.
- *
- * (2) For this reason we can use that alpha value to approximate the real
- * distance of the pixel to edge pretty accurately. A simple
- * approximation is `(0.5f - alpha)`, assuming that the outline is
- * parallel to the x or y~axis. However, in this algorithm we use a
- * different approximation which is quite accurate even for
- * non-axis-aligned edges.
- *
- * (3) The only remaining piece of information that we cannot
- * approximate directly from the alpha is the direction of the edge.
- * This is where we use Sobel's operator to compute the gradient of
- * the pixel. The gradient give us a pretty good approximation of
- * the edge direction. We use a 3x3 kernel filter to compute the
- * gradient.
- *
- * (4) After the above two steps we have both the direction and the
- * distance to the edge which is used to generate the Signed
- * Distance Field.
- *
- * References:
- *
- * - Anti-Aliased Euclidean Distance Transform:
- * http://weber.itn.liu.se/~stegu/aadist/edtaa_preprint.pdf
- * - Sobel Operator:
- * https://en.wikipedia.org/wiki/Sobel_operator
- */
-
- FT_16D16_Vec g = { 0, 0 };
- FT_16D16 dist, current_alpha;
- FT_16D16 a1, temp;
- FT_16D16 gx, gy;
- FT_16D16 alphas[9];
-
-
- /* Since our spread cannot be 0, this condition */
- /* can never be true. */
- if ( x <= 0 || x >= w - 1 ||
- y <= 0 || y >= r - 1 )
- return g;
-
- /* initialize the alphas */
- alphas[0] = 256 * (FT_16D16)current[-w - 1].alpha;
- alphas[1] = 256 * (FT_16D16)current[-w ].alpha;
- alphas[2] = 256 * (FT_16D16)current[-w + 1].alpha;
- alphas[3] = 256 * (FT_16D16)current[ -1].alpha;
- alphas[4] = 256 * (FT_16D16)current[ 0].alpha;
- alphas[5] = 256 * (FT_16D16)current[ 1].alpha;
- alphas[6] = 256 * (FT_16D16)current[ w - 1].alpha;
- alphas[7] = 256 * (FT_16D16)current[ w ].alpha;
- alphas[8] = 256 * (FT_16D16)current[ w + 1].alpha;
-
- current_alpha = alphas[4];
-
- /* Compute the gradient using the Sobel operator. */
- /* In this case we use the following 3x3 filters: */
- /* */
- /* For x: | -1 0 -1 | */
- /* | -root(2) 0 root(2) | */
- /* | -1 0 1 | */
- /* */
- /* For y: | -1 -root(2) -1 | */
- /* | 0 0 0 | */
- /* | 1 root(2) 1 | */
- /* */
- /* [Note]: 92681 is root(2) in 16.16 format. */
- g.x = -alphas[0] -
- FT_MulFix( alphas[3], 92681 ) -
- alphas[6] +
- alphas[2] +
- FT_MulFix( alphas[5], 92681 ) +
- alphas[8];
-
- g.y = -alphas[0] -
- FT_MulFix( alphas[1], 92681 ) -
- alphas[2] +
- alphas[6] +
- FT_MulFix( alphas[7], 92681 ) +
- alphas[8];
-
- FT_Vector_NormLen( &g );
-
- /* The gradient gives us the direction of the */
- /* edge for the current pixel. Once we have the */
- /* approximate direction of the edge, we can */
- /* approximate the edge distance much better. */
-
- if ( g.x == 0 || g.y == 0 )
- dist = ONE / 2 - alphas[4];
- else
- {
- gx = g.x;
- gy = g.y;
-
- gx = FT_ABS( gx );
- gy = FT_ABS( gy );
-
- if ( gx < gy )
- {
- temp = gx;
- gx = gy;
- gy = temp;
- }
-
- a1 = FT_DivFix( gy, gx ) / 2;
-
- if ( current_alpha < a1 )
- dist = ( gx + gy ) / 2 -
- square_root( 2 * FT_MulFix( gx,
- FT_MulFix( gy,
- current_alpha ) ) );
-
- else if ( current_alpha < ( ONE - a1 ) )
- dist = FT_MulFix( ONE / 2 - current_alpha, gx );
-
- else
- dist = -( gx + gy ) / 2 +
- square_root( 2 * FT_MulFix( gx,
- FT_MulFix( gy,
- ONE - current_alpha ) ) );
- }
-
- g.x = FT_MulFix( g.x, dist );
- g.y = FT_MulFix( g.y, dist );
-
- return g;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * bsdf_approximate_edge
- *
- * @Description:
- * Loops over all the pixels and call `compute_edge_distance` only for
- * edge pixels. This maked the process a lot faster since
- * `compute_edge_distance` uses functions such as `FT_Vector_NormLen',
- * which are quite slow.
- *
- * @InOut:
- * worker ::
- * Contains the distance map as well as all the relevant parameters
- * required by the function.
- *
- * @Return:
- * FreeType error, 0 means success.
- *
- * @Note:
- * The function directly manipulates `worker->distance_map`.
- *
- */
- static FT_Error
- bsdf_approximate_edge( BSDF_Worker* worker )
- {
- FT_Error error = FT_Err_Ok;
- FT_Int i, j;
- FT_Int index;
- ED* ed;
-
-
- if ( !worker || !worker->distance_map )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- ed = worker->distance_map;
-
- for ( j = 0; j < worker->rows; j++ )
- {
- for ( i = 0; i < worker->width; i++ )
- {
- index = j * worker->width + i;
-
- if ( bsdf_is_edge( worker->distance_map + index,
- i, j,
- worker->width,
- worker->rows ) )
- {
- /* approximate the edge distance for edge pixels */
- ed[index].prox = compute_edge_distance( ed + index,
- i, j,
- worker->width,
- worker->rows );
- ed[index].dist = VECTOR_LENGTH_16D16( ed[index].prox );
- }
- else
- {
- /* for non-edge pixels assign far away distances */
- ed[index].dist = 400 * ONE;
- ed[index].prox.x = 200 * ONE;
- ed[index].prox.y = 200 * ONE;
- }
- }
- }
-
- Exit:
- return error;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * bsdf_init_distance_map
- *
- * @Description:
- * Initialize the distance map according to the '8-point sequential
- * Euclidean distance mapping' (8SED) algorithm. Basically it copies
- * the `source` bitmap alpha values to the `distance_map->alpha`
- * parameter of `worker`.
- *
- * @Input:
- * source ::
- * Source bitmap to copy the data from.
- *
- * @Output:
- * worker ::
- * Target distance map to copy the data to.
- *
- * @Return:
- * FreeType error, 0 means success.
- *
- */
- static FT_Error
- bsdf_init_distance_map( const FT_Bitmap* source,
- BSDF_Worker* worker )
- {
- FT_Error error = FT_Err_Ok;
-
- FT_Int x_diff, y_diff;
- FT_Int t_i, t_j, s_i, s_j;
- FT_Byte* s;
- ED* t;
-
-
- /* again check the parameters (probably unnecessary) */
- if ( !source || !worker )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- /* Because of the way we convert a bitmap to SDF, */
- /* i.e., aligning the source to the center of the */
- /* target, the target's width and rows must be */
- /* checked before copying. */
- if ( worker->width < (FT_Int)source->width ||
- worker->rows < (FT_Int)source->rows )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- /* check pixel mode */
- if ( source->pixel_mode == FT_PIXEL_MODE_NONE )
- {
- FT_ERROR(( "bsdf_copy_source_to_target:"
- " Invalid pixel mode of source bitmap" ));
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( source->pixel_mode == FT_PIXEL_MODE_MONO )
- {
- FT_TRACE0(( "bsdf_copy_source_to_target:"
- " The `bsdf' renderer can convert monochrome\n" ));
- FT_TRACE0(( " "
- " bitmaps to SDF but the results are not perfect\n" ));
- FT_TRACE0(( " "
- " because there is no way to approximate actual\n" ));
- FT_TRACE0(( " "
- " outlines from monochrome bitmaps. Consider\n" ));
- FT_TRACE0(( " "
- " using an anti-aliased bitmap instead.\n" ));
- }
-#endif
-
- /* Calculate the width and row differences */
- /* between target and source. */
- x_diff = worker->width - (int)source->width;
- y_diff = worker->rows - (int)source->rows;
-
- x_diff /= 2;
- y_diff /= 2;
-
- t = (ED*)worker->distance_map;
- s = source->buffer;
-
- /* For now we only support pixel mode `FT_PIXEL_MODE_MONO` */
- /* and `FT_PIXEL_MODE_GRAY`. More will be added later. */
- /* */
- /* [NOTE]: We can also use @FT_Bitmap_Convert to convert */
- /* bitmap to 8bpp. To avoid extra allocation and */
- /* since the target bitmap can be 16bpp we manually */
- /* convert the source bitmap to the desired bpp. */
-
- switch ( source->pixel_mode )
- {
- case FT_PIXEL_MODE_MONO:
- {
- FT_Int t_width = worker->width;
- FT_Int t_rows = worker->rows;
- FT_Int s_width = (int)source->width;
- FT_Int s_rows = (int)source->rows;
-
-
- for ( t_j = 0; t_j < t_rows; t_j++ )
- {
- for ( t_i = 0; t_i < t_width; t_i++ )
- {
- FT_Int t_index = t_j * t_width + t_i;
- FT_Int s_index;
- FT_Int div, mod;
- FT_Byte pixel, byte;
-
-
- t[t_index] = zero_ed;
-
- s_i = t_i - x_diff;
- s_j = t_j - y_diff;
-
- /* Assign 0 to padding similar to */
- /* the source bitmap. */
- if ( s_i < 0 || s_i >= s_width ||
- s_j < 0 || s_j >= s_rows )
- continue;
-
- if ( worker->params.flip_y )
- s_index = ( s_rows - s_j - 1 ) * source->pitch;
- else
- s_index = s_j * source->pitch;
-
- div = s_index + s_i / 8;
- mod = 7 - s_i % 8;
-
- pixel = s[div];
- byte = (FT_Byte)( 1 << mod );
-
- t[t_index].alpha = pixel & byte ? 255 : 0;
- }
- }
- }
- break;
-
- case FT_PIXEL_MODE_GRAY:
- {
- FT_Int t_width = worker->width;
- FT_Int t_rows = worker->rows;
- FT_Int s_width = (int)source->width;
- FT_Int s_rows = (int)source->rows;
-
-
- /* loop over all pixels and assign pixel values from source */
- for ( t_j = 0; t_j < t_rows; t_j++ )
- {
- for ( t_i = 0; t_i < t_width; t_i++ )
- {
- FT_Int t_index = t_j * t_width + t_i;
- FT_Int s_index;
-
-
- t[t_index] = zero_ed;
-
- s_i = t_i - x_diff;
- s_j = t_j - y_diff;
-
- /* Assign 0 to padding similar to */
- /* the source bitmap. */
- if ( s_i < 0 || s_i >= s_width ||
- s_j < 0 || s_j >= s_rows )
- continue;
-
- if ( worker->params.flip_y )
- s_index = ( s_rows - s_j - 1 ) * s_width + s_i;
- else
- s_index = s_j * s_width + s_i;
-
- /* simply copy the alpha values */
- t[t_index].alpha = s[s_index];
- }
- }
- }
- break;
-
- default:
- FT_ERROR(( "bsdf_copy_source_to_target:"
- " unsopported pixel mode of source bitmap\n" ));
-
- error = FT_THROW( Unimplemented_Feature );
- break;
- }
-
- Exit:
- return error;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * compare_neighbor
- *
- * @Description:
- * Compare neighbor pixel (which is defined by the offset) and update
- * `current` distance if the new distance is shorter than the original.
- *
- * @Input:
- * x_offset ::
- * X offset of the neighbor to be checked. The offset is relative to
- * the `current`.
- *
- * y_offset ::
- * Y offset of the neighbor to be checked. The offset is relative to
- * the `current`.
- *
- * width ::
- * Width of the `current` array.
- *
- * @InOut:
- * current ::
- * Pointer into array of distances. This parameter must point to the
- * position whose neighbor is to be checked. The array is treated as
- * a two-dimensional array.
- *
- */
- static void
- compare_neighbor( ED* current,
- FT_Int x_offset,
- FT_Int y_offset,
- FT_Int width )
- {
- ED* to_check;
- FT_16D16 dist;
- FT_16D16_Vec dist_vec;
-
-
- to_check = current + ( y_offset * width ) + x_offset;
-
- /*
- * While checking for the nearest point we first approximate the
- * distance of `current` by adding the deviation (which is sqrt(2) at
- * most). Only if the new value is less than the current value we
- * calculate the actual distances using `FT_Vector_Length`. This last
- * step can be omitted by using squared distances.
- */
-
- /*
- * Approximate the distance. We subtract 1 to avoid precision errors,
- * which could happen because the two directions can be opposite.
- */
- dist = to_check->dist - ONE;
-
- if ( dist < current->dist )
- {
- dist_vec = to_check->prox;
-
- dist_vec.x += x_offset * ONE;
- dist_vec.y += y_offset * ONE;
- dist = VECTOR_LENGTH_16D16( dist_vec );
-
- if ( dist < current->dist )
- {
- current->dist = dist;
- current->prox = dist_vec;
- }
- }
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * first_pass
- *
- * @Description:
- * First pass of the 8SED algorithm. Loop over the bitmap from top to
- * bottom and scan each row left to right, updating the distances in
- * `worker->distance_map`.
- *
- * @InOut:
- * worker::
- * Contains all the relevant parameters.
- *
- */
- static void
- first_pass( BSDF_Worker* worker )
- {
- FT_Int i, j; /* iterators */
- FT_Int w, r; /* width, rows */
- ED* dm; /* distance map */
-
-
- dm = worker->distance_map;
- w = worker->width;
- r = worker->rows;
-
- /* Start scanning from top to bottom and sweep each */
- /* row back and forth comparing the distances of the */
- /* neighborhood. Leave the first row as it has no top */
- /* neighbor; it will be covered in the second scan of */
- /* the image (from bottom to top). */
- for ( j = 1; j < r; j++ )
- {
- FT_Int index;
- ED* current;
-
-
- /* Forward pass of rows (left -> right). Leave the first */
- /* column, which gets covered in the backward pass. */
- for ( i = 1; i < w - 1; i++ )
- {
- index = j * w + i;
- current = dm + index;
-
- /* left-up */
- compare_neighbor( current, -1, -1, w );
- /* up */
- compare_neighbor( current, 0, -1, w );
- /* up-right */
- compare_neighbor( current, 1, -1, w );
- /* left */
- compare_neighbor( current, -1, 0, w );
- }
-
- /* Backward pass of rows (right -> left). Leave the last */
- /* column, which was already covered in the forward pass. */
- for ( i = w - 2; i >= 0; i-- )
- {
- index = j * w + i;
- current = dm + index;
-
- /* right */
- compare_neighbor( current, 1, 0, w );
- }
- }
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * second_pass
- *
- * @Description:
- * Second pass of the 8SED algorithm. Loop over the bitmap from bottom
- * to top and scan each row left to right, updating the distances in
- * `worker->distance_map`.
- *
- * @InOut:
- * worker::
- * Contains all the relevant parameters.
- *
- */
- static void
- second_pass( BSDF_Worker* worker )
- {
- FT_Int i, j; /* iterators */
- FT_Int w, r; /* width, rows */
- ED* dm; /* distance map */
-
-
- dm = worker->distance_map;
- w = worker->width;
- r = worker->rows;
-
- /* Start scanning from bottom to top and sweep each */
- /* row back and forth comparing the distances of the */
- /* neighborhood. Leave the last row as it has no down */
- /* neighbor; it is already covered in the first scan */
- /* of the image (from top to bottom). */
- for ( j = r - 2; j >= 0; j-- )
- {
- FT_Int index;
- ED* current;
-
-
- /* Forward pass of rows (left -> right). Leave the first */
- /* column, which gets covered in the backward pass. */
- for ( i = 1; i < w - 1; i++ )
- {
- index = j * w + i;
- current = dm + index;
-
- /* left-up */
- compare_neighbor( current, -1, 1, w );
- /* up */
- compare_neighbor( current, 0, 1, w );
- /* up-right */
- compare_neighbor( current, 1, 1, w );
- /* left */
- compare_neighbor( current, -1, 0, w );
- }
-
- /* Backward pass of rows (right -> left). Leave the last */
- /* column, which was already covered in the forward pass. */
- for ( i = w - 2; i >= 0; i-- )
- {
- index = j * w + i;
- current = dm + index;
-
- /* right */
- compare_neighbor( current, 1, 0, w );
- }
- }
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * edt8
- *
- * @Description:
- * Compute the distance map of the a bitmap. Execute both first and
- * second pass of the 8SED algorithm.
- *
- * @InOut:
- * worker::
- * Contains all the relevant parameters.
- *
- * @Return:
- * FreeType error, 0 means success.
- *
- */
- static FT_Error
- edt8( BSDF_Worker* worker )
- {
- FT_Error error = FT_Err_Ok;
-
-
- if ( !worker || !worker->distance_map )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- /* first scan of the image */
- first_pass( worker );
-
- /* second scan of the image */
- second_pass( worker );
-
- Exit:
- return error;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * finalize_sdf
- *
- * @Description:
- * Copy the SDF data from `worker->distance_map` to the `target` bitmap.
- * Also transform the data to output format, (which is 6.10 fixed-point
- * format at the moment).
- *
- * @Input:
- * worker ::
- * Contains source distance map and other SDF data.
- *
- * @Output:
- * target ::
- * Target bitmap to which the SDF data is copied to.
- *
- * @Return:
- * FreeType error, 0 means success.
- *
- */
- static FT_Error
- finalize_sdf( BSDF_Worker* worker,
- const FT_Bitmap* target )
- {
- FT_Error error = FT_Err_Ok;
-
- FT_Int w, r;
- FT_Int i, j;
-
- FT_SDFFormat* t_buffer;
- FT_16D16 sp_sq, spread;
-
-
- if ( !worker || !target )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- w = (int)target->width;
- r = (int)target->rows;
- t_buffer = (FT_SDFFormat*)target->buffer;
-
- if ( w != worker->width ||
- r != worker->rows )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- spread = (FT_16D16)FT_INT_16D16( worker->params.spread );
-
-#if USE_SQUARED_DISTANCES
- sp_sq = (FT_16D16)FT_INT_16D16( worker->params.spread *
- worker->params.spread );
-#else
- sp_sq = (FT_16D16)FT_INT_16D16( worker->params.spread );
-#endif
-
- for ( j = 0; j < r; j++ )
- {
- for ( i = 0; i < w; i++ )
- {
- FT_Int index;
- FT_16D16 dist;
- FT_SDFFormat final_dist;
- FT_Char sign;
-
-
- index = j * w + i;
- dist = worker->distance_map[index].dist;
-
- if ( dist < 0 || dist > sp_sq )
- dist = sp_sq;
-
-#if USE_SQUARED_DISTANCES
- dist = square_root( dist );
-#endif
-
- /* We assume that if the pixel is inside a contour */
- /* its coverage value must be > 127. */
- sign = worker->distance_map[index].alpha < 127 ? -1 : 1;
-
- /* flip the sign according to the property */
- if ( worker->params.flip_sign )
- sign = -sign;
-
- /* concatenate from 16.16 to appropriate format */
- final_dist = map_fixed_to_sdf( dist * sign, spread );
-
- t_buffer[index] = final_dist;
- }
- }
-
- Exit:
- return error;
- }
-
-
- /**************************************************************************
- *
- * interface functions
- *
- */
-
- /* called when adding a new module through @FT_Add_Module */
- static FT_Error
- bsdf_raster_new( void* memory_, /* FT_Memory */
- FT_Raster* araster_ ) /* BSDF_PRaster* */
- {
- FT_Memory memory = (FT_Memory)memory_;
- BSDF_PRaster* araster = (BSDF_PRaster*)araster_;
-
- FT_Error error;
- BSDF_PRaster raster = NULL;
-
-
- if ( !FT_NEW( raster ) )
- raster->memory = memory;
-
- *araster = raster;
-
- return error;
- }
-
-
- /* unused */
- static void
- bsdf_raster_reset( FT_Raster raster,
- unsigned char* pool_base,
- unsigned long pool_size )
- {
- FT_UNUSED( raster );
- FT_UNUSED( pool_base );
- FT_UNUSED( pool_size );
- }
-
-
- /* unused */
- static FT_Error
- bsdf_raster_set_mode( FT_Raster raster,
- unsigned long mode,
- void* args )
- {
- FT_UNUSED( raster );
- FT_UNUSED( mode );
- FT_UNUSED( args );
-
- return FT_Err_Ok;
- }
-
-
- /* called while rendering through @FT_Render_Glyph */
- static FT_Error
- bsdf_raster_render( FT_Raster raster,
- const FT_Raster_Params* params )
- {
- FT_Error error = FT_Err_Ok;
- FT_Memory memory = NULL;
-
- const FT_Bitmap* source = NULL;
- const FT_Bitmap* target = NULL;
-
- BSDF_TRaster* bsdf_raster = (BSDF_TRaster*)raster;
- BSDF_Worker worker;
-
- const SDF_Raster_Params* sdf_params = (const SDF_Raster_Params*)params;
-
-
- worker.distance_map = NULL;
-
- /* check for valid parameters */
- if ( !raster || !params )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- /* check whether the flag is set */
- if ( sdf_params->root.flags != FT_RASTER_FLAG_SDF )
- {
- error = FT_THROW( Raster_Corrupted );
- goto Exit;
- }
-
- source = (const FT_Bitmap*)sdf_params->root.source;
- target = (const FT_Bitmap*)sdf_params->root.target;
-
- /* check source and target bitmap */
- if ( !source || !target )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- memory = bsdf_raster->memory;
- if ( !memory )
- {
- FT_TRACE0(( "bsdf_raster_render: Raster not set up properly,\n" ));
- FT_TRACE0(( " unable to find memory handle.\n" ));
-
- error = FT_THROW( Invalid_Handle );
- goto Exit;
- }
-
- /* check whether spread is set properly */
- if ( sdf_params->spread > MAX_SPREAD ||
- sdf_params->spread < MIN_SPREAD )
- {
- FT_TRACE0(( "bsdf_raster_render:"
- " The `spread' field of `SDF_Raster_Params'\n" ));
- FT_TRACE0(( " "
- " is invalid; the value of this field must be\n" ));
- FT_TRACE0(( " "
- " within [%d, %d].\n",
- MIN_SPREAD, MAX_SPREAD ));
- FT_TRACE0(( " "
- " Also, you must pass `SDF_Raster_Params'\n" ));
- FT_TRACE0(( " "
- " instead of the default `FT_Raster_Params'\n" ));
- FT_TRACE0(( " "
- " while calling this function and set the fields\n" ));
- FT_TRACE0(( " "
- " accordingly.\n" ));
-
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- /* set up the worker */
-
- /* allocate the distance map */
- if ( FT_QALLOC_MULT( worker.distance_map, target->rows,
- target->width * sizeof ( *worker.distance_map ) ) )
- goto Exit;
-
- worker.width = (int)target->width;
- worker.rows = (int)target->rows;
- worker.params = *sdf_params;
-
- FT_CALL( bsdf_init_distance_map( source, &worker ) );
- FT_CALL( bsdf_approximate_edge( &worker ) );
- FT_CALL( edt8( &worker ) );
- FT_CALL( finalize_sdf( &worker, target ) );
-
- FT_TRACE0(( "bsdf_raster_render: Total memory used = %ld\n",
- worker.width * worker.rows *
- (long)sizeof ( *worker.distance_map ) ));
-
- Exit:
- if ( worker.distance_map )
- FT_FREE( worker.distance_map );
-
- return error;
- }
-
-
- /* called while deleting `FT_Library` only if the module is added */
- static void
- bsdf_raster_done( FT_Raster raster )
- {
- FT_Memory memory = (FT_Memory)((BSDF_TRaster*)raster)->memory;
-
-
- FT_FREE( raster );
- }
-
-
- FT_DEFINE_RASTER_FUNCS(
- ft_bitmap_sdf_raster,
-
- FT_GLYPH_FORMAT_BITMAP,
-
- (FT_Raster_New_Func) bsdf_raster_new, /* raster_new */
- (FT_Raster_Reset_Func) bsdf_raster_reset, /* raster_reset */
- (FT_Raster_Set_Mode_Func)bsdf_raster_set_mode, /* raster_set_mode */
- (FT_Raster_Render_Func) bsdf_raster_render, /* raster_render */
- (FT_Raster_Done_Func) bsdf_raster_done /* raster_done */
- )
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/sdf/ftsdf.c b/contrib/libs/freetype/src/sdf/ftsdf.c
deleted file mode 100644
index dc55d42630..0000000000
--- a/contrib/libs/freetype/src/sdf/ftsdf.c
+++ /dev/null
@@ -1,3932 +0,0 @@
-/****************************************************************************
- *
- * ftsdf.c
- *
- * Signed Distance Field support for outline fonts (body).
- *
- * Copyright (C) 2020-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * Written by Anuj Verma.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/ftdebug.h>
-#include <freetype/ftoutln.h>
-#include <freetype/fttrigon.h>
-#include <freetype/ftbitmap.h>
-#include "ftsdf.h"
-
-#include "ftsdferrs.h"
-
-
- /**************************************************************************
- *
- * A brief technical overview of how the SDF rasterizer works
- * ----------------------------------------------------------
- *
- * [Notes]:
- * * SDF stands for Signed Distance Field everywhere.
- *
- * * This renderer generates SDF directly from outlines. There is
- * another renderer called 'bsdf', which converts bitmaps to SDF; see
- * file `ftbsdf.c` for more.
- *
- * * The basic idea of generating the SDF is taken from Viktor Chlumsky's
- * research paper. The paper explains both single and multi-channel
- * SDF, however, this implementation only generates single-channel SDF.
- *
- * Chlumsky, Viktor: Shape Decomposition for Multi-channel Distance
- * Fields. Master's thesis. Czech Technical University in Prague,
- * Faculty of InformationTechnology, 2015.
- *
- * For more information: https://github.com/Chlumsky/msdfgen
- *
- * ========================================================================
- *
- * Generating SDF from outlines is pretty straightforward.
- *
- * (1) We have a set of contours that make the outline of a shape/glyph.
- * Each contour comprises of several edges, with three types of edges.
- *
- * * line segments
- * * conic Bezier curves
- * * cubic Bezier curves
- *
- * (2) Apart from the outlines we also have a two-dimensional grid, namely
- * the bitmap that is used to represent the final SDF data.
- *
- * (3) In order to generate SDF, our task is to find shortest signed
- * distance from each grid point to the outline. The 'signed
- * distance' means that if the grid point is filled by any contour
- * then its sign is positive, otherwise it is negative. The pseudo
- * code is as follows.
- *
- * ```
- * foreach grid_point (x, y):
- * {
- * int min_dist = INT_MAX;
- *
- * foreach contour in outline:
- * {
- * foreach edge in contour:
- * {
- * // get shortest distance from point (x, y) to the edge
- * d = get_min_dist(x, y, edge);
- *
- * if (d < min_dist)
- * min_dist = d;
- * }
- *
- * bitmap[x, y] = min_dist;
- * }
- * }
- * ```
- *
- * (4) After running this algorithm the bitmap contains information about
- * the shortest distance from each point to the outline of the shape.
- * Of course, while this is the most straightforward way of generating
- * SDF, we use various optimizations in our implementation. See the
- * `sdf_generate_*' functions in this file for all details.
- *
- * The optimization currently used by default is subdivision; see
- * function `sdf_generate_subdivision` for more.
- *
- * Also, to see how we compute the shortest distance from a point to
- * each type of edge, check out the `get_min_distance_*' functions.
- *
- */
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT sdf
-
-
- /**************************************************************************
- *
- * definitions
- *
- */
-
- /*
- * If set to 1, the rasterizer uses Newton-Raphson's method for finding
- * the shortest distance from a point to a conic curve.
- *
- * If set to 0, an analytical method gets used instead, which computes the
- * roots of a cubic polynomial to find the shortest distance. However,
- * the analytical method can currently underflow; we thus use Newton's
- * method by default.
- */
-#ifndef USE_NEWTON_FOR_CONIC
-#define USE_NEWTON_FOR_CONIC 1
-#endif
-
- /*
- * The number of intervals a Bezier curve gets sampled and checked to find
- * the shortest distance.
- */
-#define MAX_NEWTON_DIVISIONS 4
-
- /*
- * The number of steps of Newton's iterations in each interval of the
- * Bezier curve. Basically, we run Newton's approximation
- *
- * x -= Q(t) / Q'(t)
- *
- * for each division to get the shortest distance.
- */
-#define MAX_NEWTON_STEPS 4
-
- /*
- * The epsilon distance (in 16.16 fractional units) used for corner
- * resolving. If the difference of two distances is less than this value
- * they will be checked for a corner if they are ambiguous.
- */
-#define CORNER_CHECK_EPSILON 32
-
-#if 0
- /*
- * Coarse grid dimension. Will probably be removed in the future because
- * coarse grid optimization is the slowest algorithm.
- */
-#define CG_DIMEN 8
-#endif
-
-
- /**************************************************************************
- *
- * macros
- *
- */
-
-#define MUL_26D6( a, b ) ( ( ( a ) * ( b ) ) / 64 )
-#define VEC_26D6_DOT( p, q ) ( MUL_26D6( p.x, q.x ) + \
- MUL_26D6( p.y, q.y ) )
-
-
- /**************************************************************************
- *
- * structures and enums
- *
- */
-
- /**************************************************************************
- *
- * @Struct:
- * SDF_TRaster
- *
- * @Description:
- * This struct is used in place of @FT_Raster and is stored within the
- * internal FreeType renderer struct. While rasterizing it is passed to
- * the @FT_Raster_RenderFunc function, which then can be used however we
- * want.
- *
- * @Fields:
- * memory ::
- * Used internally to allocate intermediate memory while raterizing.
- *
- */
- typedef struct SDF_TRaster_
- {
- FT_Memory memory;
-
- } SDF_TRaster, *SDF_PRaster;
-
-
- /**************************************************************************
- *
- * @Enum:
- * SDF_Edge_Type
- *
- * @Description:
- * Enumeration of all curve types present in fonts.
- *
- * @Fields:
- * SDF_EDGE_UNDEFINED ::
- * Undefined edge, simply used to initialize and detect errors.
- *
- * SDF_EDGE_LINE ::
- * Line segment with start and end point.
- *
- * SDF_EDGE_CONIC ::
- * A conic/quadratic Bezier curve with start, end, and one control
- * point.
- *
- * SDF_EDGE_CUBIC ::
- * A cubic Bezier curve with start, end, and two control points.
- *
- */
- typedef enum SDF_Edge_Type_
- {
- SDF_EDGE_UNDEFINED = 0,
- SDF_EDGE_LINE = 1,
- SDF_EDGE_CONIC = 2,
- SDF_EDGE_CUBIC = 3
-
- } SDF_Edge_Type;
-
-
- /**************************************************************************
- *
- * @Enum:
- * SDF_Contour_Orientation
- *
- * @Description:
- * Enumeration of all orientation values of a contour. We determine the
- * orientation by calculating the area covered by a contour. Contrary
- * to values returned by @FT_Outline_Get_Orientation,
- * `SDF_Contour_Orientation` is independent of the fill rule, which can
- * be different for different font formats.
- *
- * @Fields:
- * SDF_ORIENTATION_NONE ::
- * Undefined orientation, used for initialization and error detection.
- *
- * SDF_ORIENTATION_CW ::
- * Clockwise orientation (positive area covered).
- *
- * SDF_ORIENTATION_CCW ::
- * Counter-clockwise orientation (negative area covered).
- *
- * @Note:
- * See @FT_Outline_Get_Orientation for more details.
- *
- */
- typedef enum SDF_Contour_Orientation_
- {
- SDF_ORIENTATION_NONE = 0,
- SDF_ORIENTATION_CW = 1,
- SDF_ORIENTATION_CCW = 2
-
- } SDF_Contour_Orientation;
-
-
- /**************************************************************************
- *
- * @Struct:
- * SDF_Edge
- *
- * @Description:
- * Represent an edge of a contour.
- *
- * @Fields:
- * start_pos ::
- * Start position of an edge. Valid for all types of edges.
- *
- * end_pos ::
- * Etart position of an edge. Valid for all types of edges.
- *
- * control_a ::
- * A control point of the edge. Valid only for `SDF_EDGE_CONIC`
- * and `SDF_EDGE_CUBIC`.
- *
- * control_b ::
- * Another control point of the edge. Valid only for
- * `SDF_EDGE_CONIC`.
- *
- * edge_type ::
- * Type of the edge, see @SDF_Edge_Type for all possible edge types.
- *
- * next ::
- * Used to create a singly linked list, which can be interpreted
- * as a contour.
- *
- */
- typedef struct SDF_Edge_
- {
- FT_26D6_Vec start_pos;
- FT_26D6_Vec end_pos;
- FT_26D6_Vec control_a;
- FT_26D6_Vec control_b;
-
- SDF_Edge_Type edge_type;
-
- struct SDF_Edge_* next;
-
- } SDF_Edge;
-
-
- /**************************************************************************
- *
- * @Struct:
- * SDF_Contour
- *
- * @Description:
- * Represent a complete contour, which contains a list of edges.
- *
- * @Fields:
- * last_pos ::
- * Contains the value of `end_pos' of the last edge in the list of
- * edges. Useful while decomposing the outline with
- * @FT_Outline_Decompose.
- *
- * edges ::
- * Linked list of all the edges that make the contour.
- *
- * next ::
- * Used to create a singly linked list, which can be interpreted as a
- * complete shape or @FT_Outline.
- *
- */
- typedef struct SDF_Contour_
- {
- FT_26D6_Vec last_pos;
- SDF_Edge* edges;
-
- struct SDF_Contour_* next;
-
- } SDF_Contour;
-
-
- /**************************************************************************
- *
- * @Struct:
- * SDF_Shape
- *
- * @Description:
- * Represent a complete shape, which is the decomposition of
- * @FT_Outline.
- *
- * @Fields:
- * memory ::
- * Used internally to allocate memory.
- *
- * contours ::
- * Linked list of all the contours that make the shape.
- *
- */
- typedef struct SDF_Shape_
- {
- FT_Memory memory;
- SDF_Contour* contours;
-
- } SDF_Shape;
-
-
- /**************************************************************************
- *
- * @Struct:
- * SDF_Signed_Distance
- *
- * @Description:
- * Represent signed distance of a point, i.e., the distance of the edge
- * nearest to the point.
- *
- * @Fields:
- * distance ::
- * Distance of the point from the nearest edge. Can be squared or
- * absolute depending on the `USE_SQUARED_DISTANCES` macro defined in
- * file `ftsdfcommon.h`.
- *
- * cross ::
- * Cross product of the shortest distance vector (i.e., the vector
- * from the point to the nearest edge) and the direction of the edge
- * at the nearest point. This is used to resolve ambiguities of
- * `sign`.
- *
- * sign ::
- * A value used to indicate whether the distance vector is outside or
- * inside the contour corresponding to the edge.
- *
- * @Note:
- * `sign` may or may not be correct, therefore it must be checked
- * properly in case there is an ambiguity.
- *
- */
- typedef struct SDF_Signed_Distance_
- {
- FT_16D16 distance;
- FT_16D16 cross;
- FT_Char sign;
-
- } SDF_Signed_Distance;
-
-
- /**************************************************************************
- *
- * @Struct:
- * SDF_Params
- *
- * @Description:
- * Yet another internal parameters required by the rasterizer.
- *
- * @Fields:
- * orientation ::
- * This is not the @SDF_Contour_Orientation value but @FT_Orientation,
- * which determines whether clockwise-oriented outlines are to be
- * filled or counter-clockwise-oriented ones.
- *
- * flip_sign ::
- * If set to true, flip the sign. By default the points filled by the
- * outline are positive.
- *
- * flip_y ::
- * If set to true the output bitmap is upside-down. Can be useful
- * because OpenGL and DirectX use different coordinate systems for
- * textures.
- *
- * overload_sign ::
- * In the subdivision and bounding box optimization, the default
- * outside sign is taken as -1. This parameter can be used to modify
- * that behaviour. For example, while generating SDF for a single
- * counter-clockwise contour, the outside sign should be 1.
- *
- */
- typedef struct SDF_Params_
- {
- FT_Orientation orientation;
- FT_Bool flip_sign;
- FT_Bool flip_y;
-
- FT_Int overload_sign;
-
- } SDF_Params;
-
-
- /**************************************************************************
- *
- * constants, initializer, and destructor
- *
- */
-
- static
- const FT_Vector zero_vector = { 0, 0 };
-
- static
- const SDF_Edge null_edge = { { 0, 0 }, { 0, 0 },
- { 0, 0 }, { 0, 0 },
- SDF_EDGE_UNDEFINED, NULL };
-
- static
- const SDF_Contour null_contour = { { 0, 0 }, NULL, NULL };
-
- static
- const SDF_Shape null_shape = { NULL, NULL };
-
- static
- const SDF_Signed_Distance max_sdf = { INT_MAX, 0, 0 };
-
-
- /* Create a new @SDF_Edge on the heap and assigns the `edge` */
- /* pointer to the newly allocated memory. */
- static FT_Error
- sdf_edge_new( FT_Memory memory,
- SDF_Edge** edge )
- {
- FT_Error error = FT_Err_Ok;
- SDF_Edge* ptr = NULL;
-
-
- if ( !memory || !edge )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- if ( !FT_QNEW( ptr ) )
- {
- *ptr = null_edge;
- *edge = ptr;
- }
-
- Exit:
- return error;
- }
-
-
- /* Free the allocated `edge` variable. */
- static void
- sdf_edge_done( FT_Memory memory,
- SDF_Edge** edge )
- {
- if ( !memory || !edge || !*edge )
- return;
-
- FT_FREE( *edge );
- }
-
-
- /* Create a new @SDF_Contour on the heap and assign */
- /* the `contour` pointer to the newly allocated memory. */
- static FT_Error
- sdf_contour_new( FT_Memory memory,
- SDF_Contour** contour )
- {
- FT_Error error = FT_Err_Ok;
- SDF_Contour* ptr = NULL;
-
-
- if ( !memory || !contour )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- if ( !FT_QNEW( ptr ) )
- {
- *ptr = null_contour;
- *contour = ptr;
- }
-
- Exit:
- return error;
- }
-
-
- /* Free the allocated `contour` variable. */
- /* Also free the list of edges. */
- static void
- sdf_contour_done( FT_Memory memory,
- SDF_Contour** contour )
- {
- SDF_Edge* edges;
- SDF_Edge* temp;
-
-
- if ( !memory || !contour || !*contour )
- return;
-
- edges = (*contour)->edges;
-
- /* release all edges */
- while ( edges )
- {
- temp = edges;
- edges = edges->next;
-
- sdf_edge_done( memory, &temp );
- }
-
- FT_FREE( *contour );
- }
-
-
- /* Create a new @SDF_Shape on the heap and assign */
- /* the `shape` pointer to the newly allocated memory. */
- static FT_Error
- sdf_shape_new( FT_Memory memory,
- SDF_Shape** shape )
- {
- FT_Error error = FT_Err_Ok;
- SDF_Shape* ptr = NULL;
-
-
- if ( !memory || !shape )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- if ( !FT_QNEW( ptr ) )
- {
- *ptr = null_shape;
- ptr->memory = memory;
- *shape = ptr;
- }
-
- Exit:
- return error;
- }
-
-
- /* Free the allocated `shape` variable. */
- /* Also free the list of contours. */
- static void
- sdf_shape_done( SDF_Shape** shape )
- {
- FT_Memory memory;
- SDF_Contour* contours;
- SDF_Contour* temp;
-
-
- if ( !shape || !*shape )
- return;
-
- memory = (*shape)->memory;
- contours = (*shape)->contours;
-
- if ( !memory )
- return;
-
- /* release all contours */
- while ( contours )
- {
- temp = contours;
- contours = contours->next;
-
- sdf_contour_done( memory, &temp );
- }
-
- /* release the allocated shape struct */
- FT_FREE( *shape );
- }
-
-
- /**************************************************************************
- *
- * shape decomposition functions
- *
- */
-
- /* This function is called when starting a new contour at `to`, */
- /* which gets added to the shape's list. */
- static FT_Error
- sdf_move_to( const FT_26D6_Vec* to,
- void* user )
- {
- SDF_Shape* shape = ( SDF_Shape* )user;
- SDF_Contour* contour = NULL;
-
- FT_Error error = FT_Err_Ok;
- FT_Memory memory = shape->memory;
-
-
- if ( !to || !user )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- FT_CALL( sdf_contour_new( memory, &contour ) );
-
- contour->last_pos = *to;
- contour->next = shape->contours;
- shape->contours = contour;
-
- Exit:
- return error;
- }
-
-
- /* This function is called when there is a line in the */
- /* contour. The line starts at the previous edge point and */
- /* stops at `to`. */
- static FT_Error
- sdf_line_to( const FT_26D6_Vec* to,
- void* user )
- {
- SDF_Shape* shape = ( SDF_Shape* )user;
- SDF_Edge* edge = NULL;
- SDF_Contour* contour = NULL;
-
- FT_Error error = FT_Err_Ok;
- FT_Memory memory = shape->memory;
-
-
- if ( !to || !user )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- contour = shape->contours;
-
- if ( contour->last_pos.x == to->x &&
- contour->last_pos.y == to->y )
- goto Exit;
-
- FT_CALL( sdf_edge_new( memory, &edge ) );
-
- edge->edge_type = SDF_EDGE_LINE;
- edge->start_pos = contour->last_pos;
- edge->end_pos = *to;
-
- edge->next = contour->edges;
- contour->edges = edge;
- contour->last_pos = *to;
-
- Exit:
- return error;
- }
-
-
- /* This function is called when there is a conic Bezier curve */
- /* in the contour. The curve starts at the previous edge point */
- /* and stops at `to`, with control point `control_1`. */
- static FT_Error
- sdf_conic_to( const FT_26D6_Vec* control_1,
- const FT_26D6_Vec* to,
- void* user )
- {
- SDF_Shape* shape = ( SDF_Shape* )user;
- SDF_Edge* edge = NULL;
- SDF_Contour* contour = NULL;
-
- FT_Error error = FT_Err_Ok;
- FT_Memory memory = shape->memory;
-
-
- if ( !control_1 || !to || !user )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- contour = shape->contours;
-
- /* If the control point coincides with any of the end points */
- /* then it is a line and should be treated as one to avoid */
- /* unnecessary complexity later in the algorithm. */
- if ( ( contour->last_pos.x == control_1->x &&
- contour->last_pos.y == control_1->y ) ||
- ( control_1->x == to->x &&
- control_1->y == to->y ) )
- {
- sdf_line_to( to, user );
- goto Exit;
- }
-
- FT_CALL( sdf_edge_new( memory, &edge ) );
-
- edge->edge_type = SDF_EDGE_CONIC;
- edge->start_pos = contour->last_pos;
- edge->control_a = *control_1;
- edge->end_pos = *to;
-
- edge->next = contour->edges;
- contour->edges = edge;
- contour->last_pos = *to;
-
- Exit:
- return error;
- }
-
-
- /* This function is called when there is a cubic Bezier curve */
- /* in the contour. The curve starts at the previous edge point */
- /* and stops at `to`, with two control points `control_1` and */
- /* `control_2`. */
- static FT_Error
- sdf_cubic_to( const FT_26D6_Vec* control_1,
- const FT_26D6_Vec* control_2,
- const FT_26D6_Vec* to,
- void* user )
- {
- SDF_Shape* shape = ( SDF_Shape* )user;
- SDF_Edge* edge = NULL;
- SDF_Contour* contour = NULL;
-
- FT_Error error = FT_Err_Ok;
- FT_Memory memory = shape->memory;
-
-
- if ( !control_2 || !control_1 || !to || !user )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- contour = shape->contours;
-
- FT_CALL( sdf_edge_new( memory, &edge ) );
-
- edge->edge_type = SDF_EDGE_CUBIC;
- edge->start_pos = contour->last_pos;
- edge->control_a = *control_1;
- edge->control_b = *control_2;
- edge->end_pos = *to;
-
- edge->next = contour->edges;
- contour->edges = edge;
- contour->last_pos = *to;
-
- Exit:
- return error;
- }
-
-
- /* Construct the structure to hold all four outline */
- /* decomposition functions. */
- FT_DEFINE_OUTLINE_FUNCS(
- sdf_decompose_funcs,
-
- (FT_Outline_MoveTo_Func) sdf_move_to, /* move_to */
- (FT_Outline_LineTo_Func) sdf_line_to, /* line_to */
- (FT_Outline_ConicTo_Func)sdf_conic_to, /* conic_to */
- (FT_Outline_CubicTo_Func)sdf_cubic_to, /* cubic_to */
-
- 0, /* shift */
- 0 /* delta */
- )
-
-
- /* Decompose `outline` and put it into the `shape` structure. */
- static FT_Error
- sdf_outline_decompose( FT_Outline* outline,
- SDF_Shape* shape )
- {
- FT_Error error = FT_Err_Ok;
-
-
- if ( !outline || !shape )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- error = FT_Outline_Decompose( outline,
- &sdf_decompose_funcs,
- (void*)shape );
-
- Exit:
- return error;
- }
-
-
- /**************************************************************************
- *
- * utility functions
- *
- */
-
- /* Return the control box of an edge. The control box is a rectangle */
- /* in which all the control points can fit tightly. */
- static FT_CBox
- get_control_box( SDF_Edge edge )
- {
- FT_CBox cbox = { 0, 0, 0, 0 };
- FT_Bool is_set = 0;
-
-
- switch ( edge.edge_type )
- {
- case SDF_EDGE_CUBIC:
- cbox.xMin = edge.control_b.x;
- cbox.xMax = edge.control_b.x;
- cbox.yMin = edge.control_b.y;
- cbox.yMax = edge.control_b.y;
-
- is_set = 1;
- FALL_THROUGH;
-
- case SDF_EDGE_CONIC:
- if ( is_set )
- {
- cbox.xMin = edge.control_a.x < cbox.xMin
- ? edge.control_a.x
- : cbox.xMin;
- cbox.xMax = edge.control_a.x > cbox.xMax
- ? edge.control_a.x
- : cbox.xMax;
-
- cbox.yMin = edge.control_a.y < cbox.yMin
- ? edge.control_a.y
- : cbox.yMin;
- cbox.yMax = edge.control_a.y > cbox.yMax
- ? edge.control_a.y
- : cbox.yMax;
- }
- else
- {
- cbox.xMin = edge.control_a.x;
- cbox.xMax = edge.control_a.x;
- cbox.yMin = edge.control_a.y;
- cbox.yMax = edge.control_a.y;
-
- is_set = 1;
- }
- FALL_THROUGH;
-
- case SDF_EDGE_LINE:
- if ( is_set )
- {
- cbox.xMin = edge.start_pos.x < cbox.xMin
- ? edge.start_pos.x
- : cbox.xMin;
- cbox.xMax = edge.start_pos.x > cbox.xMax
- ? edge.start_pos.x
- : cbox.xMax;
-
- cbox.yMin = edge.start_pos.y < cbox.yMin
- ? edge.start_pos.y
- : cbox.yMin;
- cbox.yMax = edge.start_pos.y > cbox.yMax
- ? edge.start_pos.y
- : cbox.yMax;
- }
- else
- {
- cbox.xMin = edge.start_pos.x;
- cbox.xMax = edge.start_pos.x;
- cbox.yMin = edge.start_pos.y;
- cbox.yMax = edge.start_pos.y;
- }
-
- cbox.xMin = edge.end_pos.x < cbox.xMin
- ? edge.end_pos.x
- : cbox.xMin;
- cbox.xMax = edge.end_pos.x > cbox.xMax
- ? edge.end_pos.x
- : cbox.xMax;
-
- cbox.yMin = edge.end_pos.y < cbox.yMin
- ? edge.end_pos.y
- : cbox.yMin;
- cbox.yMax = edge.end_pos.y > cbox.yMax
- ? edge.end_pos.y
- : cbox.yMax;
-
- break;
-
- default:
- break;
- }
-
- return cbox;
- }
-
-
- /* Return orientation of a single contour. */
- /* Note that the orientation is independent of the fill rule! */
- /* So, for TTF a clockwise-oriented contour has to be filled */
- /* and the opposite for OTF fonts. */
- static SDF_Contour_Orientation
- get_contour_orientation ( SDF_Contour* contour )
- {
- SDF_Edge* head = NULL;
- FT_26D6 area = 0;
-
-
- /* return none if invalid parameters */
- if ( !contour || !contour->edges )
- return SDF_ORIENTATION_NONE;
-
- head = contour->edges;
-
- /* Calculate the area of the control box for all edges. */
- while ( head )
- {
- switch ( head->edge_type )
- {
- case SDF_EDGE_LINE:
- area += MUL_26D6( ( head->end_pos.x - head->start_pos.x ),
- ( head->end_pos.y + head->start_pos.y ) );
- break;
-
- case SDF_EDGE_CONIC:
- area += MUL_26D6( head->control_a.x - head->start_pos.x,
- head->control_a.y + head->start_pos.y );
- area += MUL_26D6( head->end_pos.x - head->control_a.x,
- head->end_pos.y + head->control_a.y );
- break;
-
- case SDF_EDGE_CUBIC:
- area += MUL_26D6( head->control_a.x - head->start_pos.x,
- head->control_a.y + head->start_pos.y );
- area += MUL_26D6( head->control_b.x - head->control_a.x,
- head->control_b.y + head->control_a.y );
- area += MUL_26D6( head->end_pos.x - head->control_b.x,
- head->end_pos.y + head->control_b.y );
- break;
-
- default:
- return SDF_ORIENTATION_NONE;
- }
-
- head = head->next;
- }
-
- /* Clockwise contours cover a positive area, and counter-clockwise */
- /* contours cover a negative area. */
- if ( area > 0 )
- return SDF_ORIENTATION_CW;
- else
- return SDF_ORIENTATION_CCW;
- }
-
-
- /* This function is exactly the same as the one */
- /* in the smooth renderer. It splits a conic */
- /* into two conics exactly half way at t = 0.5. */
- static void
- split_conic( FT_26D6_Vec* base )
- {
- FT_26D6 a, b;
-
-
- base[4].x = base[2].x;
- a = base[0].x + base[1].x;
- b = base[1].x + base[2].x;
- base[3].x = b / 2;
- base[2].x = ( a + b ) / 4;
- base[1].x = a / 2;
-
- base[4].y = base[2].y;
- a = base[0].y + base[1].y;
- b = base[1].y + base[2].y;
- base[3].y = b / 2;
- base[2].y = ( a + b ) / 4;
- base[1].y = a / 2;
- }
-
-
- /* This function is exactly the same as the one */
- /* in the smooth renderer. It splits a cubic */
- /* into two cubics exactly half way at t = 0.5. */
- static void
- split_cubic( FT_26D6_Vec* base )
- {
- FT_26D6 a, b, c;
-
-
- base[6].x = base[3].x;
- a = base[0].x + base[1].x;
- b = base[1].x + base[2].x;
- c = base[2].x + base[3].x;
- base[5].x = c / 2;
- c += b;
- base[4].x = c / 4;
- base[1].x = a / 2;
- a += b;
- base[2].x = a / 4;
- base[3].x = ( a + c ) / 8;
-
- base[6].y = base[3].y;
- a = base[0].y + base[1].y;
- b = base[1].y + base[2].y;
- c = base[2].y + base[3].y;
- base[5].y = c / 2;
- c += b;
- base[4].y = c / 4;
- base[1].y = a / 2;
- a += b;
- base[2].y = a / 4;
- base[3].y = ( a + c ) / 8;
- }
-
-
- /* Split a conic Bezier curve into a number of lines */
- /* and add them to `out'. */
- /* */
- /* This function uses recursion; we thus need */
- /* parameter `max_splits' for stopping. */
- static FT_Error
- split_sdf_conic( FT_Memory memory,
- FT_26D6_Vec* control_points,
- FT_UInt max_splits,
- SDF_Edge** out )
- {
- FT_Error error = FT_Err_Ok;
- FT_26D6_Vec cpos[5];
- SDF_Edge* left,* right;
-
-
- if ( !memory || !out )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- /* split conic outline */
- cpos[0] = control_points[0];
- cpos[1] = control_points[1];
- cpos[2] = control_points[2];
-
- split_conic( cpos );
-
- /* If max number of splits is done */
- /* then stop and add the lines to */
- /* the list. */
- if ( max_splits <= 2 )
- goto Append;
-
- /* Otherwise keep splitting. */
- FT_CALL( split_sdf_conic( memory, &cpos[0], max_splits / 2, out ) );
- FT_CALL( split_sdf_conic( memory, &cpos[2], max_splits / 2, out ) );
-
- /* [NOTE]: This is not an efficient way of */
- /* splitting the curve. Check the deviation */
- /* instead and stop if the deviation is less */
- /* than a pixel. */
-
- goto Exit;
-
- Append:
- /* Do allocation and add the lines to the list. */
-
- FT_CALL( sdf_edge_new( memory, &left ) );
- FT_CALL( sdf_edge_new( memory, &right ) );
-
- left->start_pos = cpos[0];
- left->end_pos = cpos[2];
- left->edge_type = SDF_EDGE_LINE;
-
- right->start_pos = cpos[2];
- right->end_pos = cpos[4];
- right->edge_type = SDF_EDGE_LINE;
-
- left->next = right;
- right->next = (*out);
- *out = left;
-
- Exit:
- return error;
- }
-
-
- /* Split a cubic Bezier curve into a number of lines */
- /* and add them to `out`. */
- /* */
- /* This function uses recursion; we thus need */
- /* parameter `max_splits' for stopping. */
- static FT_Error
- split_sdf_cubic( FT_Memory memory,
- FT_26D6_Vec* control_points,
- FT_UInt max_splits,
- SDF_Edge** out )
- {
- FT_Error error = FT_Err_Ok;
- FT_26D6_Vec cpos[7];
- SDF_Edge* left, *right;
- const FT_26D6 threshold = ONE_PIXEL / 4;
-
-
- if ( !memory || !out )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- /* split the cubic */
- cpos[0] = control_points[0];
- cpos[1] = control_points[1];
- cpos[2] = control_points[2];
- cpos[3] = control_points[3];
-
- /* If the segment is flat enough we won't get any benefit by */
- /* splitting it further, so we can just stop splitting. */
- /* */
- /* Check the deviation of the Bezier curve and stop if it is */
- /* smaller than the pre-defined `threshold` value. */
- if ( FT_ABS( 2 * cpos[0].x - 3 * cpos[1].x + cpos[3].x ) < threshold &&
- FT_ABS( 2 * cpos[0].y - 3 * cpos[1].y + cpos[3].y ) < threshold &&
- FT_ABS( cpos[0].x - 3 * cpos[2].x + 2 * cpos[3].x ) < threshold &&
- FT_ABS( cpos[0].y - 3 * cpos[2].y + 2 * cpos[3].y ) < threshold )
- {
- split_cubic( cpos );
- goto Append;
- }
-
- split_cubic( cpos );
-
- /* If max number of splits is done */
- /* then stop and add the lines to */
- /* the list. */
- if ( max_splits <= 2 )
- goto Append;
-
- /* Otherwise keep splitting. */
- FT_CALL( split_sdf_cubic( memory, &cpos[0], max_splits / 2, out ) );
- FT_CALL( split_sdf_cubic( memory, &cpos[3], max_splits / 2, out ) );
-
- /* [NOTE]: This is not an efficient way of */
- /* splitting the curve. Check the deviation */
- /* instead and stop if the deviation is less */
- /* than a pixel. */
-
- goto Exit;
-
- Append:
- /* Do allocation and add the lines to the list. */
-
- FT_CALL( sdf_edge_new( memory, &left) );
- FT_CALL( sdf_edge_new( memory, &right) );
-
- left->start_pos = cpos[0];
- left->end_pos = cpos[3];
- left->edge_type = SDF_EDGE_LINE;
-
- right->start_pos = cpos[3];
- right->end_pos = cpos[6];
- right->edge_type = SDF_EDGE_LINE;
-
- left->next = right;
- right->next = (*out);
- *out = left;
-
- Exit:
- return error;
- }
-
-
- /* Subdivide an entire shape into line segments */
- /* such that it doesn't look visually different */
- /* from the original curve. */
- static FT_Error
- split_sdf_shape( SDF_Shape* shape )
- {
- FT_Error error = FT_Err_Ok;
- FT_Memory memory;
-
- SDF_Contour* contours;
- SDF_Contour* new_contours = NULL;
-
-
- if ( !shape || !shape->memory )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- contours = shape->contours;
- memory = shape->memory;
-
- /* for each contour */
- while ( contours )
- {
- SDF_Edge* edges = contours->edges;
- SDF_Edge* new_edges = NULL;
-
- SDF_Contour* tempc;
-
-
- /* for each edge */
- while ( edges )
- {
- SDF_Edge* edge = edges;
- SDF_Edge* temp;
-
- switch ( edge->edge_type )
- {
- case SDF_EDGE_LINE:
- /* Just create a duplicate edge in case */
- /* it is a line. We can use the same edge. */
- FT_CALL( sdf_edge_new( memory, &temp ) );
-
- ft_memcpy( temp, edge, sizeof ( *edge ) );
-
- temp->next = new_edges;
- new_edges = temp;
- break;
-
- case SDF_EDGE_CONIC:
- /* Subdivide the curve and add it to the list. */
- {
- FT_26D6_Vec ctrls[3];
- FT_26D6 dx, dy;
- FT_UInt num_splits;
-
-
- ctrls[0] = edge->start_pos;
- ctrls[1] = edge->control_a;
- ctrls[2] = edge->end_pos;
-
- dx = FT_ABS( ctrls[2].x + ctrls[0].x - 2 * ctrls[1].x );
- dy = FT_ABS( ctrls[2].y + ctrls[0].y - 2 * ctrls[1].y );
- if ( dx < dy )
- dx = dy;
-
- /* Calculate the number of necessary bisections. Each */
- /* bisection causes a four-fold reduction of the deviation, */
- /* hence we bisect the Bezier curve until the deviation */
- /* becomes less than 1/8 of a pixel. For more details */
- /* check file `ftgrays.c`. */
- num_splits = 1;
- while ( dx > ONE_PIXEL / 8 )
- {
- dx >>= 2;
- num_splits <<= 1;
- }
-
- error = split_sdf_conic( memory, ctrls, num_splits, &new_edges );
- }
- break;
-
- case SDF_EDGE_CUBIC:
- /* Subdivide the curve and add it to the list. */
- {
- FT_26D6_Vec ctrls[4];
-
-
- ctrls[0] = edge->start_pos;
- ctrls[1] = edge->control_a;
- ctrls[2] = edge->control_b;
- ctrls[3] = edge->end_pos;
-
- error = split_sdf_cubic( memory, ctrls, 32, &new_edges );
- }
- break;
-
- default:
- error = FT_THROW( Invalid_Argument );
- }
-
- if ( error != FT_Err_Ok )
- goto Exit;
-
- edges = edges->next;
- }
-
- /* add to the contours list */
- FT_CALL( sdf_contour_new( memory, &tempc ) );
-
- tempc->next = new_contours;
- tempc->edges = new_edges;
- new_contours = tempc;
- new_edges = NULL;
-
- /* deallocate the contour */
- tempc = contours;
- contours = contours->next;
-
- sdf_contour_done( memory, &tempc );
- }
-
- shape->contours = new_contours;
-
- Exit:
- return error;
- }
-
-
- /**************************************************************************
- *
- * for debugging
- *
- */
-
-#ifdef FT_DEBUG_LEVEL_TRACE
-
- static void
- sdf_shape_dump( SDF_Shape* shape )
- {
- FT_UInt num_contours = 0;
-
- FT_UInt total_edges = 0;
- FT_UInt total_lines = 0;
- FT_UInt total_conic = 0;
- FT_UInt total_cubic = 0;
-
- SDF_Contour* contour_list;
-
-
- if ( !shape )
- {
- FT_TRACE5(( "sdf_shape_dump: null shape\n" ));
- return;
- }
-
- contour_list = shape->contours;
-
- FT_TRACE5(( "sdf_shape_dump (values are in 26.6 format):\n" ));
-
- while ( contour_list )
- {
- FT_UInt num_edges = 0;
- SDF_Edge* edge_list;
- SDF_Contour* contour = contour_list;
-
-
- FT_TRACE5(( " Contour %d\n", num_contours ));
-
- edge_list = contour->edges;
-
- while ( edge_list )
- {
- SDF_Edge* edge = edge_list;
-
-
- FT_TRACE5(( " %3d: ", num_edges ));
-
- switch ( edge->edge_type )
- {
- case SDF_EDGE_LINE:
- FT_TRACE5(( "Line: (%ld, %ld) -- (%ld, %ld)\n",
- edge->start_pos.x, edge->start_pos.y,
- edge->end_pos.x, edge->end_pos.y ));
- total_lines++;
- break;
-
- case SDF_EDGE_CONIC:
- FT_TRACE5(( "Conic: (%ld, %ld) .. (%ld, %ld) .. (%ld, %ld)\n",
- edge->start_pos.x, edge->start_pos.y,
- edge->control_a.x, edge->control_a.y,
- edge->end_pos.x, edge->end_pos.y ));
- total_conic++;
- break;
-
- case SDF_EDGE_CUBIC:
- FT_TRACE5(( "Cubic: (%ld, %ld) .. (%ld, %ld)"
- " .. (%ld, %ld) .. (%ld %ld)\n",
- edge->start_pos.x, edge->start_pos.y,
- edge->control_a.x, edge->control_a.y,
- edge->control_b.x, edge->control_b.y,
- edge->end_pos.x, edge->end_pos.y ));
- total_cubic++;
- break;
-
- default:
- break;
- }
-
- num_edges++;
- total_edges++;
- edge_list = edge_list->next;
- }
-
- num_contours++;
- contour_list = contour_list->next;
- }
-
- FT_TRACE5(( "\n" ));
- FT_TRACE5(( " total number of contours = %d\n", num_contours ));
- FT_TRACE5(( " total number of edges = %d\n", total_edges ));
- FT_TRACE5(( " |__lines = %d\n", total_lines ));
- FT_TRACE5(( " |__conic = %d\n", total_conic ));
- FT_TRACE5(( " |__cubic = %d\n", total_cubic ));
- }
-
-#endif /* FT_DEBUG_LEVEL_TRACE */
-
-
- /**************************************************************************
- *
- * math functions
- *
- */
-
-#if !USE_NEWTON_FOR_CONIC
-
- /* [NOTE]: All the functions below down until rasterizer */
- /* can be avoided if we decide to subdivide the */
- /* curve into lines. */
-
- /* This function uses Newton's iteration to find */
- /* the cube root of a fixed-point integer. */
- static FT_16D16
- cube_root( FT_16D16 val )
- {
- /* [IMPORTANT]: This function is not good as it may */
- /* not break, so use a lookup table instead. Or we */
- /* can use an algorithm similar to `square_root`. */
-
- FT_Int v, g, c;
-
-
- if ( val == 0 ||
- val == -FT_INT_16D16( 1 ) ||
- val == FT_INT_16D16( 1 ) )
- return val;
-
- v = val < 0 ? -val : val;
- g = square_root( v );
- c = 0;
-
- while ( 1 )
- {
- c = FT_MulFix( FT_MulFix( g, g ), g ) - v;
- c = FT_DivFix( c, 3 * FT_MulFix( g, g ) );
-
- g -= c;
-
- if ( ( c < 0 ? -c : c ) < 30 )
- break;
- }
-
- return val < 0 ? -g : g;
- }
-
-
- /* Calculate the perpendicular by using '1 - base^2'. */
- /* Then use arctan to compute the angle. */
- static FT_16D16
- arc_cos( FT_16D16 val )
- {
- FT_16D16 p;
- FT_16D16 b = val;
- FT_16D16 one = FT_INT_16D16( 1 );
-
-
- if ( b > one )
- b = one;
- if ( b < -one )
- b = -one;
-
- p = one - FT_MulFix( b, b );
- p = square_root( p );
-
- return FT_Atan2( b, p );
- }
-
-
- /* Compute roots of a quadratic polynomial, assign them to `out`, */
- /* and return number of real roots. */
- /* */
- /* The procedure can be found at */
- /* */
- /* https://mathworld.wolfram.com/QuadraticFormula.html */
- static FT_UShort
- solve_quadratic_equation( FT_26D6 a,
- FT_26D6 b,
- FT_26D6 c,
- FT_16D16 out[2] )
- {
- FT_16D16 discriminant = 0;
-
-
- a = FT_26D6_16D16( a );
- b = FT_26D6_16D16( b );
- c = FT_26D6_16D16( c );
-
- if ( a == 0 )
- {
- if ( b == 0 )
- return 0;
- else
- {
- out[0] = FT_DivFix( -c, b );
-
- return 1;
- }
- }
-
- discriminant = FT_MulFix( b, b ) - 4 * FT_MulFix( a, c );
-
- if ( discriminant < 0 )
- return 0;
- else if ( discriminant == 0 )
- {
- out[0] = FT_DivFix( -b, 2 * a );
-
- return 1;
- }
- else
- {
- discriminant = square_root( discriminant );
-
- out[0] = FT_DivFix( -b + discriminant, 2 * a );
- out[1] = FT_DivFix( -b - discriminant, 2 * a );
-
- return 2;
- }
- }
-
-
- /* Compute roots of a cubic polynomial, assign them to `out`, */
- /* and return number of real roots. */
- /* */
- /* The procedure can be found at */
- /* */
- /* https://mathworld.wolfram.com/CubicFormula.html */
- static FT_UShort
- solve_cubic_equation( FT_26D6 a,
- FT_26D6 b,
- FT_26D6 c,
- FT_26D6 d,
- FT_16D16 out[3] )
- {
- FT_16D16 q = 0; /* intermediate */
- FT_16D16 r = 0; /* intermediate */
-
- FT_16D16 a2 = b; /* x^2 coefficients */
- FT_16D16 a1 = c; /* x coefficients */
- FT_16D16 a0 = d; /* constant */
-
- FT_16D16 q3 = 0;
- FT_16D16 r2 = 0;
- FT_16D16 a23 = 0;
- FT_16D16 a22 = 0;
- FT_16D16 a1x2 = 0;
-
-
- /* cutoff value for `a` to be a cubic, otherwise solve quadratic */
- if ( a == 0 || FT_ABS( a ) < 16 )
- return solve_quadratic_equation( b, c, d, out );
-
- if ( d == 0 )
- {
- out[0] = 0;
-
- return solve_quadratic_equation( a, b, c, out + 1 ) + 1;
- }
-
- /* normalize the coefficients; this also makes them 16.16 */
- a2 = FT_DivFix( a2, a );
- a1 = FT_DivFix( a1, a );
- a0 = FT_DivFix( a0, a );
-
- /* compute intermediates */
- a1x2 = FT_MulFix( a1, a2 );
- a22 = FT_MulFix( a2, a2 );
- a23 = FT_MulFix( a22, a2 );
-
- q = ( 3 * a1 - a22 ) / 9;
- r = ( 9 * a1x2 - 27 * a0 - 2 * a23 ) / 54;
-
- /* [BUG]: `q3` and `r2` still cause underflow. */
-
- q3 = FT_MulFix( q, q );
- q3 = FT_MulFix( q3, q );
-
- r2 = FT_MulFix( r, r );
-
- if ( q3 < 0 && r2 < -q3 )
- {
- FT_16D16 t = 0;
-
-
- q3 = square_root( -q3 );
- t = FT_DivFix( r, q3 );
-
- if ( t > ( 1 << 16 ) )
- t = ( 1 << 16 );
- if ( t < -( 1 << 16 ) )
- t = -( 1 << 16 );
-
- t = arc_cos( t );
- a2 /= 3;
- q = 2 * square_root( -q );
-
- out[0] = FT_MulFix( q, FT_Cos( t / 3 ) ) - a2;
- out[1] = FT_MulFix( q, FT_Cos( ( t + FT_ANGLE_PI * 2 ) / 3 ) ) - a2;
- out[2] = FT_MulFix( q, FT_Cos( ( t + FT_ANGLE_PI * 4 ) / 3 ) ) - a2;
-
- return 3;
- }
-
- else if ( r2 == -q3 )
- {
- FT_16D16 s = 0;
-
-
- s = cube_root( r );
- a2 /= -3;
-
- out[0] = a2 + ( 2 * s );
- out[1] = a2 - s;
-
- return 2;
- }
-
- else
- {
- FT_16D16 s = 0;
- FT_16D16 t = 0;
- FT_16D16 dis = 0;
-
-
- if ( q3 == 0 )
- dis = FT_ABS( r );
- else
- dis = square_root( q3 + r2 );
-
- s = cube_root( r + dis );
- t = cube_root( r - dis );
- a2 /= -3;
- out[0] = ( a2 + ( s + t ) );
-
- return 1;
- }
- }
-
-#endif /* !USE_NEWTON_FOR_CONIC */
-
-
- /*************************************************************************/
- /*************************************************************************/
- /** **/
- /** RASTERIZER **/
- /** **/
- /*************************************************************************/
- /*************************************************************************/
-
- /**************************************************************************
- *
- * @Function:
- * resolve_corner
- *
- * @Description:
- * At some places on the grid two edges can give opposite directions;
- * this happens when the closest point is on one of the endpoint. In
- * that case we need to check the proper sign.
- *
- * This can be visualized by an example:
- *
- * ```
- * x
- *
- * o
- * ^ \
- * / \
- * / \
- * (a) / \ (b)
- * / \
- * / \
- * / v
- * ```
- *
- * Suppose `x` is the point whose shortest distance from an arbitrary
- * contour we want to find out. It is clear that `o` is the nearest
- * point on the contour. Now to determine the sign we do a cross
- * product of the shortest distance vector and the edge direction, i.e.,
- *
- * ```
- * => sign = cross(x - o, direction(a))
- * ```
- *
- * Using the right hand thumb rule we can see that the sign will be
- * positive.
- *
- * If we use `b', however, we have
- *
- * ```
- * => sign = cross(x - o, direction(b))
- * ```
- *
- * In this case the sign will be negative. To determine the correct
- * sign we thus divide the plane in two halves and check which plane the
- * point lies in.
- *
- * ```
- * |
- * x |
- * |
- * o
- * ^|\
- * / | \
- * / | \
- * (a) / | \ (b)
- * / | \
- * / \
- * / v
- * ```
- *
- * We can see that `x` lies in the plane of `a`, so we take the sign
- * determined by `a`. This test can be easily done by calculating the
- * orthogonality and taking the greater one.
- *
- * The orthogonality is simply the sinus of the two vectors (i.e.,
- * x - o) and the corresponding direction. We efficiently pre-compute
- * the orthogonality with the corresponding `get_min_distance_*`
- * functions.
- *
- * @Input:
- * sdf1 ::
- * First signed distance (can be any of `a` or `b`).
- *
- * sdf1 ::
- * Second signed distance (can be any of `a` or `b`).
- *
- * @Return:
- * The correct signed distance, which is computed by using the above
- * algorithm.
- *
- * @Note:
- * The function does not care about the actual distance, it simply
- * returns the signed distance which has a larger cross product. As a
- * consequence, this function should not be used if the two distances
- * are fairly apart. In that case simply use the signed distance with
- * a shorter absolute distance.
- *
- */
- static SDF_Signed_Distance
- resolve_corner( SDF_Signed_Distance sdf1,
- SDF_Signed_Distance sdf2 )
- {
- return FT_ABS( sdf1.cross ) > FT_ABS( sdf2.cross ) ? sdf1 : sdf2;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * get_min_distance_line
- *
- * @Description:
- * Find the shortest distance from the `line` segment to a given `point`
- * and assign it to `out`. Use it for line segments only.
- *
- * @Input:
- * line ::
- * The line segment to which the shortest distance is to be computed.
- *
- * point ::
- * Point from which the shortest distance is to be computed.
- *
- * @Output:
- * out ::
- * Signed distance from `point` to `line`.
- *
- * @Return:
- * FreeType error, 0 means success.
- *
- * @Note:
- * The `line' parameter must have an edge type of `SDF_EDGE_LINE`.
- *
- */
- static FT_Error
- get_min_distance_line( SDF_Edge* line,
- FT_26D6_Vec point,
- SDF_Signed_Distance* out )
- {
- /*
- * In order to calculate the shortest distance from a point to
- * a line segment, we do the following. Let's assume that
- *
- * ```
- * a = start point of the line segment
- * b = end point of the line segment
- * p = point from which shortest distance is to be calculated
- * ```
- *
- * (1) Write the parametric equation of the line.
- *
- * ```
- * point_on_line = a + (b - a) * t (t is the factor)
- * ```
- *
- * (2) Find the projection of point `p` on the line. The projection
- * will be perpendicular to the line, which allows us to get the
- * solution by making the dot product zero.
- *
- * ```
- * (point_on_line - a) . (p - point_on_line) = 0
- *
- * (point_on_line)
- * (a) x-------o----------------x (b)
- * |_|
- * |
- * |
- * (p)
- * ```
- *
- * (3) Simplification of the above equation yields the factor of
- * `point_on_line`:
- *
- * ```
- * t = ((p - a) . (b - a)) / |b - a|^2
- * ```
- *
- * (4) We clamp factor `t` between [0.0f, 1.0f] because `point_on_line`
- * can be outside of the line segment:
- *
- * ```
- * (point_on_line)
- * (a) x------------------------x (b) -----o---
- * |_|
- * |
- * |
- * (p)
- * ```
- *
- * (5) Finally, the distance we are interested in is
- *
- * ```
- * |point_on_line - p|
- * ```
- */
-
- FT_Error error = FT_Err_Ok;
-
- FT_Vector a; /* start position */
- FT_Vector b; /* end position */
- FT_Vector p; /* current point */
-
- FT_26D6_Vec line_segment; /* `b` - `a` */
- FT_26D6_Vec p_sub_a; /* `p` - `a` */
-
- FT_26D6 sq_line_length; /* squared length of `line_segment` */
- FT_16D16 factor; /* factor of the nearest point */
- FT_26D6 cross; /* used to determine sign */
-
- FT_16D16_Vec nearest_point; /* `point_on_line` */
- FT_16D16_Vec nearest_vector; /* `p` - `nearest_point` */
-
-
- if ( !line || !out )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- if ( line->edge_type != SDF_EDGE_LINE )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- a = line->start_pos;
- b = line->end_pos;
- p = point;
-
- line_segment.x = b.x - a.x;
- line_segment.y = b.y - a.y;
-
- p_sub_a.x = p.x - a.x;
- p_sub_a.y = p.y - a.y;
-
- sq_line_length = ( line_segment.x * line_segment.x ) / 64 +
- ( line_segment.y * line_segment.y ) / 64;
-
- /* currently factor is 26.6 */
- factor = ( p_sub_a.x * line_segment.x ) / 64 +
- ( p_sub_a.y * line_segment.y ) / 64;
-
- /* now factor is 16.16 */
- factor = FT_DivFix( factor, sq_line_length );
-
- /* clamp the factor between 0.0 and 1.0 in fixed-point */
- if ( factor > FT_INT_16D16( 1 ) )
- factor = FT_INT_16D16( 1 );
- if ( factor < 0 )
- factor = 0;
-
- nearest_point.x = FT_MulFix( FT_26D6_16D16( line_segment.x ),
- factor );
- nearest_point.y = FT_MulFix( FT_26D6_16D16( line_segment.y ),
- factor );
-
- nearest_point.x = FT_26D6_16D16( a.x ) + nearest_point.x;
- nearest_point.y = FT_26D6_16D16( a.y ) + nearest_point.y;
-
- nearest_vector.x = nearest_point.x - FT_26D6_16D16( p.x );
- nearest_vector.y = nearest_point.y - FT_26D6_16D16( p.y );
-
- cross = FT_MulFix( nearest_vector.x, line_segment.y ) -
- FT_MulFix( nearest_vector.y, line_segment.x );
-
- /* assign the output */
- out->sign = cross < 0 ? 1 : -1;
- out->distance = VECTOR_LENGTH_16D16( nearest_vector );
-
- /* Instead of finding `cross` for checking corner we */
- /* directly set it here. This is more efficient */
- /* because if the distance is perpendicular we can */
- /* directly set it to 1. */
- if ( factor != 0 && factor != FT_INT_16D16( 1 ) )
- out->cross = FT_INT_16D16( 1 );
- else
- {
- /* [OPTIMIZATION]: Pre-compute this direction. */
- /* If not perpendicular then compute `cross`. */
- FT_Vector_NormLen( &line_segment );
- FT_Vector_NormLen( &nearest_vector );
-
- out->cross = FT_MulFix( line_segment.x, nearest_vector.y ) -
- FT_MulFix( line_segment.y, nearest_vector.x );
- }
-
- Exit:
- return error;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * get_min_distance_conic
- *
- * @Description:
- * Find the shortest distance from the `conic` Bezier curve to a given
- * `point` and assign it to `out`. Use it for conic/quadratic curves
- * only.
- *
- * @Input:
- * conic ::
- * The conic Bezier curve to which the shortest distance is to be
- * computed.
- *
- * point ::
- * Point from which the shortest distance is to be computed.
- *
- * @Output:
- * out ::
- * Signed distance from `point` to `conic`.
- *
- * @Return:
- * FreeType error, 0 means success.
- *
- * @Note:
- * The `conic` parameter must have an edge type of `SDF_EDGE_CONIC`.
- *
- */
-
-#if !USE_NEWTON_FOR_CONIC
-
- /*
- * The function uses an analytical method to find the shortest distance
- * which is faster than the Newton-Raphson method, but has underflows at
- * the moment. Use Newton's method if you can see artifacts in the SDF.
- */
- static FT_Error
- get_min_distance_conic( SDF_Edge* conic,
- FT_26D6_Vec point,
- SDF_Signed_Distance* out )
- {
- /*
- * The procedure to find the shortest distance from a point to a
- * quadratic Bezier curve is similar to the line segment algorithm. The
- * shortest distance is perpendicular to the Bezier curve; the only
- * difference from line is that there can be more than one
- * perpendicular, and we also have to check the endpoints, because the
- * perpendicular may not be the shortest.
- *
- * Let's assume that
- * ```
- * p0 = first endpoint
- * p1 = control point
- * p2 = second endpoint
- * p = point from which shortest distance is to be calculated
- * ```
- *
- * (1) The equation of a quadratic Bezier curve can be written as
- *
- * ```
- * B(t) = (1 - t)^2 * p0 + 2(1 - t)t * p1 + t^2 * p2
- * ```
- *
- * with `t` a factor in the range [0.0f, 1.0f]. This equation can
- * be rewritten as
- *
- * ```
- * B(t) = t^2 * (p0 - 2p1 + p2) + 2t * (p1 - p0) + p0
- * ```
- *
- * With
- *
- * ```
- * A = p0 - 2p1 + p2
- * B = p1 - p0
- * ```
- *
- * we have
- *
- * ```
- * B(t) = t^2 * A + 2t * B + p0
- * ```
- *
- * (2) The derivative of the last equation above is
- *
- * ```
- * B'(t) = 2 *(tA + B)
- * ```
- *
- * (3) To find the shortest distance from `p` to `B(t)` we find the
- * point on the curve at which the shortest distance vector (i.e.,
- * `B(t) - p`) and the direction (i.e., `B'(t)`) make 90 degrees.
- * In other words, we make the dot product zero.
- *
- * ```
- * (B(t) - p) . (B'(t)) = 0
- * (t^2 * A + 2t * B + p0 - p) . (2 * (tA + B)) = 0
- * ```
- *
- * After simplifying we get a cubic equation
- *
- * ```
- * at^3 + bt^2 + ct + d = 0
- * ```
- *
- * with
- *
- * ```
- * a = A.A
- * b = 3A.B
- * c = 2B.B + A.p0 - A.p
- * d = p0.B - p.B
- * ```
- *
- * (4) Now the roots of the equation can be computed using 'Cardano's
- * Cubic formula'; we clamp the roots in the range [0.0f, 1.0f].
- *
- * [note]: `B` and `B(t)` are different in the above equations.
- */
-
- FT_Error error = FT_Err_Ok;
-
- FT_26D6_Vec aA, bB; /* A, B in the above comment */
- FT_26D6_Vec nearest_point = { 0, 0 };
- /* point on curve nearest to `point` */
- FT_26D6_Vec direction; /* direction of curve at `nearest_point` */
-
- FT_26D6_Vec p0, p1, p2; /* control points of a conic curve */
- FT_26D6_Vec p; /* `point` to which shortest distance */
-
- FT_26D6 a, b, c, d; /* cubic coefficients */
-
- FT_16D16 roots[3] = { 0, 0, 0 }; /* real roots of the cubic eq. */
- FT_16D16 min_factor; /* factor at `nearest_point` */
- FT_16D16 cross; /* to determine the sign */
- FT_16D16 min = FT_INT_MAX; /* shortest squared distance */
-
- FT_UShort num_roots; /* number of real roots of cubic */
- FT_UShort i;
-
-
- if ( !conic || !out )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- if ( conic->edge_type != SDF_EDGE_CONIC )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- p0 = conic->start_pos;
- p1 = conic->control_a;
- p2 = conic->end_pos;
- p = point;
-
- /* compute substitution coefficients */
- aA.x = p0.x - 2 * p1.x + p2.x;
- aA.y = p0.y - 2 * p1.y + p2.y;
-
- bB.x = p1.x - p0.x;
- bB.y = p1.y - p0.y;
-
- /* compute cubic coefficients */
- a = VEC_26D6_DOT( aA, aA );
-
- b = 3 * VEC_26D6_DOT( aA, bB );
-
- c = 2 * VEC_26D6_DOT( bB, bB ) +
- VEC_26D6_DOT( aA, p0 ) -
- VEC_26D6_DOT( aA, p );
-
- d = VEC_26D6_DOT( p0, bB ) -
- VEC_26D6_DOT( p, bB );
-
- /* find the roots */
- num_roots = solve_cubic_equation( a, b, c, d, roots );
-
- if ( num_roots == 0 )
- {
- roots[0] = 0;
- roots[1] = FT_INT_16D16( 1 );
- num_roots = 2;
- }
-
- /* [OPTIMIZATION]: Check the roots, clamp them and discard */
- /* duplicate roots. */
-
- /* convert these values to 16.16 for further computation */
- aA.x = FT_26D6_16D16( aA.x );
- aA.y = FT_26D6_16D16( aA.y );
-
- bB.x = FT_26D6_16D16( bB.x );
- bB.y = FT_26D6_16D16( bB.y );
-
- p0.x = FT_26D6_16D16( p0.x );
- p0.y = FT_26D6_16D16( p0.y );
-
- p.x = FT_26D6_16D16( p.x );
- p.y = FT_26D6_16D16( p.y );
-
- for ( i = 0; i < num_roots; i++ )
- {
- FT_16D16 t = roots[i];
- FT_16D16 t2 = 0;
- FT_16D16 dist = 0;
-
- FT_16D16_Vec curve_point;
- FT_16D16_Vec dist_vector;
-
- /*
- * Ideally we should discard the roots which are outside the range
- * [0.0, 1.0] and check the endpoints of the Bezier curve, but Behdad
- * Esfahbod proved the following lemma.
- *
- * Lemma:
- *
- * (1) If the closest point on the curve [0, 1] is to the endpoint at
- * `t` = 1 and the cubic has no real roots at `t` = 1 then the
- * cubic must have a real root at some `t` > 1.
- *
- * (2) Similarly, if the closest point on the curve [0, 1] is to the
- * endpoint at `t` = 0 and the cubic has no real roots at `t` = 0
- * then the cubic must have a real root at some `t` < 0.
- *
- * Now because of this lemma we only need to clamp the roots and that
- * will take care of the endpoints.
- *
- * For more details see
- *
- * https://lists.nongnu.org/archive/html/freetype-devel/2020-06/msg00147.html
- */
-
- if ( t < 0 )
- t = 0;
- if ( t > FT_INT_16D16( 1 ) )
- t = FT_INT_16D16( 1 );
-
- t2 = FT_MulFix( t, t );
-
- /* B(t) = t^2 * A + 2t * B + p0 - p */
- curve_point.x = FT_MulFix( aA.x, t2 ) +
- 2 * FT_MulFix( bB.x, t ) + p0.x;
- curve_point.y = FT_MulFix( aA.y, t2 ) +
- 2 * FT_MulFix( bB.y, t ) + p0.y;
-
- /* `curve_point` - `p` */
- dist_vector.x = curve_point.x - p.x;
- dist_vector.y = curve_point.y - p.y;
-
- dist = VECTOR_LENGTH_16D16( dist_vector );
-
- if ( dist < min )
- {
- min = dist;
- nearest_point = curve_point;
- min_factor = t;
- }
- }
-
- /* B'(t) = 2 * (tA + B) */
- direction.x = 2 * FT_MulFix( aA.x, min_factor ) + 2 * bB.x;
- direction.y = 2 * FT_MulFix( aA.y, min_factor ) + 2 * bB.y;
-
- /* determine the sign */
- cross = FT_MulFix( nearest_point.x - p.x, direction.y ) -
- FT_MulFix( nearest_point.y - p.y, direction.x );
-
- /* assign the values */
- out->distance = min;
- out->sign = cross < 0 ? 1 : -1;
-
- if ( min_factor != 0 && min_factor != FT_INT_16D16( 1 ) )
- out->cross = FT_INT_16D16( 1 ); /* the two are perpendicular */
- else
- {
- /* convert to nearest vector */
- nearest_point.x -= FT_26D6_16D16( p.x );
- nearest_point.y -= FT_26D6_16D16( p.y );
-
- /* compute `cross` if not perpendicular */
- FT_Vector_NormLen( &direction );
- FT_Vector_NormLen( &nearest_point );
-
- out->cross = FT_MulFix( direction.x, nearest_point.y ) -
- FT_MulFix( direction.y, nearest_point.x );
- }
-
- Exit:
- return error;
- }
-
-#else /* USE_NEWTON_FOR_CONIC */
-
- /*
- * The function uses Newton's approximation to find the shortest distance,
- * which is a bit slower than the analytical method but doesn't cause
- * underflow.
- */
- static FT_Error
- get_min_distance_conic( SDF_Edge* conic,
- FT_26D6_Vec point,
- SDF_Signed_Distance* out )
- {
- /*
- * This method uses Newton-Raphson's approximation to find the shortest
- * distance from a point to a conic curve. It does not involve solving
- * any cubic equation, that is why there is no risk of underflow.
- *
- * Let's assume that
- *
- * ```
- * p0 = first endpoint
- * p1 = control point
- * p3 = second endpoint
- * p = point from which shortest distance is to be calculated
- * ```
- *
- * (1) The equation of a quadratic Bezier curve can be written as
- *
- * ```
- * B(t) = (1 - t)^2 * p0 + 2(1 - t)t * p1 + t^2 * p2
- * ```
- *
- * with `t` the factor in the range [0.0f, 1.0f]. The above
- * equation can be rewritten as
- *
- * ```
- * B(t) = t^2 * (p0 - 2p1 + p2) + 2t * (p1 - p0) + p0
- * ```
- *
- * With
- *
- * ```
- * A = p0 - 2p1 + p2
- * B = 2 * (p1 - p0)
- * ```
- *
- * we have
- *
- * ```
- * B(t) = t^2 * A + t * B + p0
- * ```
- *
- * (2) The derivative of the above equation is
- *
- * ```
- * B'(t) = 2t * A + B
- * ```
- *
- * (3) The second derivative of the above equation is
- *
- * ```
- * B''(t) = 2A
- * ```
- *
- * (4) The equation `P(t)` of the distance from point `p` to the curve
- * can be written as
- *
- * ```
- * P(t) = t^2 * A + t^2 * B + p0 - p
- * ```
- *
- * With
- *
- * ```
- * C = p0 - p
- * ```
- *
- * we have
- *
- * ```
- * P(t) = t^2 * A + t * B + C
- * ```
- *
- * (5) Finally, the equation of the angle between `B(t)` and `P(t)` can
- * be written as
- *
- * ```
- * Q(t) = P(t) . B'(t)
- * ```
- *
- * (6) Our task is to find a value of `t` such that the above equation
- * `Q(t)` becomes zero, that is, the point-to-curve vector makes
- * 90~degrees with the curve. We solve this with the Newton-Raphson
- * method.
- *
- * (7) We first assume an arbitrary value of factor `t`, which we then
- * improve.
- *
- * ```
- * t := Q(t) / Q'(t)
- * ```
- *
- * Putting the value of `Q(t)` from the above equation gives
- *
- * ```
- * t := P(t) . B'(t) / derivative(P(t) . B'(t))
- * t := P(t) . B'(t) /
- * (P'(t) . B'(t) + P(t) . B''(t))
- * ```
- *
- * Note that `P'(t)` is the same as `B'(t)` because the constant is
- * gone due to the derivative.
- *
- * (8) Finally we get the equation to improve the factor as
- *
- * ```
- * t := P(t) . B'(t) /
- * (B'(t) . B'(t) + P(t) . B''(t))
- * ```
- *
- * [note]: `B` and `B(t)` are different in the above equations.
- */
-
- FT_Error error = FT_Err_Ok;
-
- FT_26D6_Vec aA, bB, cC; /* A, B, C in the above comment */
- FT_26D6_Vec nearest_point = { 0, 0 };
- /* point on curve nearest to `point` */
- FT_26D6_Vec direction; /* direction of curve at `nearest_point` */
-
- FT_26D6_Vec p0, p1, p2; /* control points of a conic curve */
- FT_26D6_Vec p; /* `point` to which shortest distance */
-
- FT_16D16 min_factor = 0; /* factor at `nearest_point' */
- FT_16D16 cross; /* to determine the sign */
- FT_16D16 min = FT_INT_MAX; /* shortest squared distance */
-
- FT_UShort iterations;
- FT_UShort steps;
-
-
- if ( !conic || !out )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- if ( conic->edge_type != SDF_EDGE_CONIC )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- p0 = conic->start_pos;
- p1 = conic->control_a;
- p2 = conic->end_pos;
- p = point;
-
- /* compute substitution coefficients */
- aA.x = p0.x - 2 * p1.x + p2.x;
- aA.y = p0.y - 2 * p1.y + p2.y;
-
- bB.x = 2 * ( p1.x - p0.x );
- bB.y = 2 * ( p1.y - p0.y );
-
- cC.x = p0.x;
- cC.y = p0.y;
-
- /* do Newton's iterations */
- for ( iterations = 0; iterations <= MAX_NEWTON_DIVISIONS; iterations++ )
- {
- FT_16D16 factor = FT_INT_16D16( iterations ) / MAX_NEWTON_DIVISIONS;
- FT_16D16 factor2;
- FT_16D16 length;
-
- FT_16D16_Vec curve_point; /* point on the curve */
- FT_16D16_Vec dist_vector; /* `curve_point` - `p` */
-
- FT_26D6_Vec d1; /* first derivative */
- FT_26D6_Vec d2; /* second derivative */
-
- FT_16D16 temp1;
- FT_16D16 temp2;
-
-
- for ( steps = 0; steps < MAX_NEWTON_STEPS; steps++ )
- {
- factor2 = FT_MulFix( factor, factor );
-
- /* B(t) = t^2 * A + t * B + p0 */
- curve_point.x = FT_MulFix( aA.x, factor2 ) +
- FT_MulFix( bB.x, factor ) + cC.x;
- curve_point.y = FT_MulFix( aA.y, factor2 ) +
- FT_MulFix( bB.y, factor ) + cC.y;
-
- /* convert to 16.16 */
- curve_point.x = FT_26D6_16D16( curve_point.x );
- curve_point.y = FT_26D6_16D16( curve_point.y );
-
- /* P(t) in the comment */
- dist_vector.x = curve_point.x - FT_26D6_16D16( p.x );
- dist_vector.y = curve_point.y - FT_26D6_16D16( p.y );
-
- length = VECTOR_LENGTH_16D16( dist_vector );
-
- if ( length < min )
- {
- min = length;
- min_factor = factor;
- nearest_point = curve_point;
- }
-
- /* This is Newton's approximation. */
- /* */
- /* t := P(t) . B'(t) / */
- /* (B'(t) . B'(t) + P(t) . B''(t)) */
-
- /* B'(t) = 2tA + B */
- d1.x = FT_MulFix( aA.x, 2 * factor ) + bB.x;
- d1.y = FT_MulFix( aA.y, 2 * factor ) + bB.y;
-
- /* B''(t) = 2A */
- d2.x = 2 * aA.x;
- d2.y = 2 * aA.y;
-
- dist_vector.x /= 1024;
- dist_vector.y /= 1024;
-
- /* temp1 = P(t) . B'(t) */
- temp1 = VEC_26D6_DOT( dist_vector, d1 );
-
- /* temp2 = B'(t) . B'(t) + P(t) . B''(t) */
- temp2 = VEC_26D6_DOT( d1, d1 ) +
- VEC_26D6_DOT( dist_vector, d2 );
-
- factor -= FT_DivFix( temp1, temp2 );
-
- if ( factor < 0 || factor > FT_INT_16D16( 1 ) )
- break;
- }
- }
-
- /* B'(t) = 2t * A + B */
- direction.x = 2 * FT_MulFix( aA.x, min_factor ) + bB.x;
- direction.y = 2 * FT_MulFix( aA.y, min_factor ) + bB.y;
-
- /* determine the sign */
- cross = FT_MulFix( nearest_point.x - FT_26D6_16D16( p.x ),
- direction.y ) -
- FT_MulFix( nearest_point.y - FT_26D6_16D16( p.y ),
- direction.x );
-
- /* assign the values */
- out->distance = min;
- out->sign = cross < 0 ? 1 : -1;
-
- if ( min_factor != 0 && min_factor != FT_INT_16D16( 1 ) )
- out->cross = FT_INT_16D16( 1 ); /* the two are perpendicular */
- else
- {
- /* convert to nearest vector */
- nearest_point.x -= FT_26D6_16D16( p.x );
- nearest_point.y -= FT_26D6_16D16( p.y );
-
- /* compute `cross` if not perpendicular */
- FT_Vector_NormLen( &direction );
- FT_Vector_NormLen( &nearest_point );
-
- out->cross = FT_MulFix( direction.x, nearest_point.y ) -
- FT_MulFix( direction.y, nearest_point.x );
- }
-
- Exit:
- return error;
- }
-
-
-#endif /* USE_NEWTON_FOR_CONIC */
-
-
- /**************************************************************************
- *
- * @Function:
- * get_min_distance_cubic
- *
- * @Description:
- * Find the shortest distance from the `cubic` Bezier curve to a given
- * `point` and assigns it to `out`. Use it for cubic curves only.
- *
- * @Input:
- * cubic ::
- * The cubic Bezier curve to which the shortest distance is to be
- * computed.
- *
- * point ::
- * Point from which the shortest distance is to be computed.
- *
- * @Output:
- * out ::
- * Signed distance from `point` to `cubic`.
- *
- * @Return:
- * FreeType error, 0 means success.
- *
- * @Note:
- * The function uses Newton's approximation to find the shortest
- * distance. Another way would be to divide the cubic into conic or
- * subdivide the curve into lines, but that is not implemented.
- *
- * The `cubic` parameter must have an edge type of `SDF_EDGE_CUBIC`.
- *
- */
- static FT_Error
- get_min_distance_cubic( SDF_Edge* cubic,
- FT_26D6_Vec point,
- SDF_Signed_Distance* out )
- {
- /*
- * The procedure to find the shortest distance from a point to a cubic
- * Bezier curve is similar to quadratic curve algorithm. The only
- * difference is that while calculating factor `t`, instead of a cubic
- * polynomial equation we have to find the roots of a 5th degree
- * polynomial equation. Solving this would require a significant amount
- * of time, and still the results may not be accurate. We are thus
- * going to directly approximate the value of `t` using the Newton-Raphson
- * method.
- *
- * Let's assume that
- *
- * ```
- * p0 = first endpoint
- * p1 = first control point
- * p2 = second control point
- * p3 = second endpoint
- * p = point from which shortest distance is to be calculated
- * ```
- *
- * (1) The equation of a cubic Bezier curve can be written as
- *
- * ```
- * B(t) = (1 - t)^3 * p0 + 3(1 - t)^2 t * p1 +
- * 3(1 - t)t^2 * p2 + t^3 * p3
- * ```
- *
- * The equation can be expanded and written as
- *
- * ```
- * B(t) = t^3 * (-p0 + 3p1 - 3p2 + p3) +
- * 3t^2 * (p0 - 2p1 + p2) + 3t * (-p0 + p1) + p0
- * ```
- *
- * With
- *
- * ```
- * A = -p0 + 3p1 - 3p2 + p3
- * B = 3(p0 - 2p1 + p2)
- * C = 3(-p0 + p1)
- * ```
- *
- * we have
- *
- * ```
- * B(t) = t^3 * A + t^2 * B + t * C + p0
- * ```
- *
- * (2) The derivative of the above equation is
- *
- * ```
- * B'(t) = 3t^2 * A + 2t * B + C
- * ```
- *
- * (3) The second derivative of the above equation is
- *
- * ```
- * B''(t) = 6t * A + 2B
- * ```
- *
- * (4) The equation `P(t)` of the distance from point `p` to the curve
- * can be written as
- *
- * ```
- * P(t) = t^3 * A + t^2 * B + t * C + p0 - p
- * ```
- *
- * With
- *
- * ```
- * D = p0 - p
- * ```
- *
- * we have
- *
- * ```
- * P(t) = t^3 * A + t^2 * B + t * C + D
- * ```
- *
- * (5) Finally the equation of the angle between `B(t)` and `P(t)` can
- * be written as
- *
- * ```
- * Q(t) = P(t) . B'(t)
- * ```
- *
- * (6) Our task is to find a value of `t` such that the above equation
- * `Q(t)` becomes zero, that is, the point-to-curve vector makes
- * 90~degree with curve. We solve this with the Newton-Raphson
- * method.
- *
- * (7) We first assume an arbitrary value of factor `t`, which we then
- * improve.
- *
- * ```
- * t := Q(t) / Q'(t)
- * ```
- *
- * Putting the value of `Q(t)` from the above equation gives
- *
- * ```
- * t := P(t) . B'(t) / derivative(P(t) . B'(t))
- * t := P(t) . B'(t) /
- * (P'(t) . B'(t) + P(t) . B''(t))
- * ```
- *
- * Note that `P'(t)` is the same as `B'(t)` because the constant is
- * gone due to the derivative.
- *
- * (8) Finally we get the equation to improve the factor as
- *
- * ```
- * t := P(t) . B'(t) /
- * (B'(t) . B'( t ) + P(t) . B''(t))
- * ```
- *
- * [note]: `B` and `B(t)` are different in the above equations.
- */
-
- FT_Error error = FT_Err_Ok;
-
- FT_26D6_Vec aA, bB, cC, dD; /* A, B, C, D in the above comment */
- FT_16D16_Vec nearest_point = { 0, 0 };
- /* point on curve nearest to `point` */
- FT_16D16_Vec direction; /* direction of curve at `nearest_point` */
-
- FT_26D6_Vec p0, p1, p2, p3; /* control points of a cubic curve */
- FT_26D6_Vec p; /* `point` to which shortest distance */
-
- FT_16D16 min_factor = 0; /* factor at shortest distance */
- FT_16D16 min_factor_sq = 0; /* factor at shortest distance */
- FT_16D16 cross; /* to determine the sign */
- FT_16D16 min = FT_INT_MAX; /* shortest distance */
-
- FT_UShort iterations;
- FT_UShort steps;
-
-
- if ( !cubic || !out )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- if ( cubic->edge_type != SDF_EDGE_CUBIC )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- p0 = cubic->start_pos;
- p1 = cubic->control_a;
- p2 = cubic->control_b;
- p3 = cubic->end_pos;
- p = point;
-
- /* compute substitution coefficients */
- aA.x = -p0.x + 3 * ( p1.x - p2.x ) + p3.x;
- aA.y = -p0.y + 3 * ( p1.y - p2.y ) + p3.y;
-
- bB.x = 3 * ( p0.x - 2 * p1.x + p2.x );
- bB.y = 3 * ( p0.y - 2 * p1.y + p2.y );
-
- cC.x = 3 * ( p1.x - p0.x );
- cC.y = 3 * ( p1.y - p0.y );
-
- dD.x = p0.x;
- dD.y = p0.y;
-
- for ( iterations = 0; iterations <= MAX_NEWTON_DIVISIONS; iterations++ )
- {
- FT_16D16 factor = FT_INT_16D16( iterations ) / MAX_NEWTON_DIVISIONS;
-
- FT_16D16 factor2; /* factor^2 */
- FT_16D16 factor3; /* factor^3 */
- FT_16D16 length;
-
- FT_16D16_Vec curve_point; /* point on the curve */
- FT_16D16_Vec dist_vector; /* `curve_point' - `p' */
-
- FT_26D6_Vec d1; /* first derivative */
- FT_26D6_Vec d2; /* second derivative */
-
- FT_16D16 temp1;
- FT_16D16 temp2;
-
-
- for ( steps = 0; steps < MAX_NEWTON_STEPS; steps++ )
- {
- factor2 = FT_MulFix( factor, factor );
- factor3 = FT_MulFix( factor2, factor );
-
- /* B(t) = t^3 * A + t^2 * B + t * C + D */
- curve_point.x = FT_MulFix( aA.x, factor3 ) +
- FT_MulFix( bB.x, factor2 ) +
- FT_MulFix( cC.x, factor ) + dD.x;
- curve_point.y = FT_MulFix( aA.y, factor3 ) +
- FT_MulFix( bB.y, factor2 ) +
- FT_MulFix( cC.y, factor ) + dD.y;
-
- /* convert to 16.16 */
- curve_point.x = FT_26D6_16D16( curve_point.x );
- curve_point.y = FT_26D6_16D16( curve_point.y );
-
- /* P(t) in the comment */
- dist_vector.x = curve_point.x - FT_26D6_16D16( p.x );
- dist_vector.y = curve_point.y - FT_26D6_16D16( p.y );
-
- length = VECTOR_LENGTH_16D16( dist_vector );
-
- if ( length < min )
- {
- min = length;
- min_factor = factor;
- min_factor_sq = factor2;
- nearest_point = curve_point;
- }
-
- /* This the Newton's approximation. */
- /* */
- /* t := P(t) . B'(t) / */
- /* (B'(t) . B'(t) + P(t) . B''(t)) */
-
- /* B'(t) = 3t^2 * A + 2t * B + C */
- d1.x = FT_MulFix( aA.x, 3 * factor2 ) +
- FT_MulFix( bB.x, 2 * factor ) + cC.x;
- d1.y = FT_MulFix( aA.y, 3 * factor2 ) +
- FT_MulFix( bB.y, 2 * factor ) + cC.y;
-
- /* B''(t) = 6t * A + 2B */
- d2.x = FT_MulFix( aA.x, 6 * factor ) + 2 * bB.x;
- d2.y = FT_MulFix( aA.y, 6 * factor ) + 2 * bB.y;
-
- dist_vector.x /= 1024;
- dist_vector.y /= 1024;
-
- /* temp1 = P(t) . B'(t) */
- temp1 = VEC_26D6_DOT( dist_vector, d1 );
-
- /* temp2 = B'(t) . B'(t) + P(t) . B''(t) */
- temp2 = VEC_26D6_DOT( d1, d1 ) +
- VEC_26D6_DOT( dist_vector, d2 );
-
- factor -= FT_DivFix( temp1, temp2 );
-
- if ( factor < 0 || factor > FT_INT_16D16( 1 ) )
- break;
- }
- }
-
- /* B'(t) = 3t^2 * A + 2t * B + C */
- direction.x = FT_MulFix( aA.x, 3 * min_factor_sq ) +
- FT_MulFix( bB.x, 2 * min_factor ) + cC.x;
- direction.y = FT_MulFix( aA.y, 3 * min_factor_sq ) +
- FT_MulFix( bB.y, 2 * min_factor ) + cC.y;
-
- /* determine the sign */
- cross = FT_MulFix( nearest_point.x - FT_26D6_16D16( p.x ),
- direction.y ) -
- FT_MulFix( nearest_point.y - FT_26D6_16D16( p.y ),
- direction.x );
-
- /* assign the values */
- out->distance = min;
- out->sign = cross < 0 ? 1 : -1;
-
- if ( min_factor != 0 && min_factor != FT_INT_16D16( 1 ) )
- out->cross = FT_INT_16D16( 1 ); /* the two are perpendicular */
- else
- {
- /* convert to nearest vector */
- nearest_point.x -= FT_26D6_16D16( p.x );
- nearest_point.y -= FT_26D6_16D16( p.y );
-
- /* compute `cross` if not perpendicular */
- FT_Vector_NormLen( &direction );
- FT_Vector_NormLen( &nearest_point );
-
- out->cross = FT_MulFix( direction.x, nearest_point.y ) -
- FT_MulFix( direction.y, nearest_point.x );
- }
-
- Exit:
- return error;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * sdf_edge_get_min_distance
- *
- * @Description:
- * Find shortest distance from `point` to any type of `edge`. It checks
- * the edge type and then calls the relevant `get_min_distance_*`
- * function.
- *
- * @Input:
- * edge ::
- * An edge to which the shortest distance is to be computed.
- *
- * point ::
- * Point from which the shortest distance is to be computed.
- *
- * @Output:
- * out ::
- * Signed distance from `point` to `edge`.
- *
- * @Return:
- * FreeType error, 0 means success.
- *
- */
- static FT_Error
- sdf_edge_get_min_distance( SDF_Edge* edge,
- FT_26D6_Vec point,
- SDF_Signed_Distance* out )
- {
- FT_Error error = FT_Err_Ok;
-
-
- if ( !edge || !out )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- /* edge-specific distance calculation */
- switch ( edge->edge_type )
- {
- case SDF_EDGE_LINE:
- get_min_distance_line( edge, point, out );
- break;
-
- case SDF_EDGE_CONIC:
- get_min_distance_conic( edge, point, out );
- break;
-
- case SDF_EDGE_CUBIC:
- get_min_distance_cubic( edge, point, out );
- break;
-
- default:
- error = FT_THROW( Invalid_Argument );
- }
-
- Exit:
- return error;
- }
-
-
- /* `sdf_generate' is not used at the moment */
-#if 0
-
- #error "DO NOT USE THIS!"
- #error "The function still outputs 16-bit data, which might cause memory"
- #error "corruption. If required I will add this later."
-
- /**************************************************************************
- *
- * @Function:
- * sdf_contour_get_min_distance
- *
- * @Description:
- * Iterate over all edges that make up the contour, find the shortest
- * distance from a point to this contour, and assigns result to `out`.
- *
- * @Input:
- * contour ::
- * A contour to which the shortest distance is to be computed.
- *
- * point ::
- * Point from which the shortest distance is to be computed.
- *
- * @Output:
- * out ::
- * Signed distance from the `point' to the `contour'.
- *
- * @Return:
- * FreeType error, 0 means success.
- *
- * @Note:
- * The function does not return a signed distance for each edge which
- * makes up the contour, it simply returns the shortest of all the
- * edges.
- *
- */
- static FT_Error
- sdf_contour_get_min_distance( SDF_Contour* contour,
- FT_26D6_Vec point,
- SDF_Signed_Distance* out )
- {
- FT_Error error = FT_Err_Ok;
- SDF_Signed_Distance min_dist = max_sdf;
- SDF_Edge* edge_list;
-
-
- if ( !contour || !out )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- edge_list = contour->edges;
-
- /* iterate over all the edges manually */
- while ( edge_list )
- {
- SDF_Signed_Distance current_dist = max_sdf;
- FT_16D16 diff;
-
-
- FT_CALL( sdf_edge_get_min_distance( edge_list,
- point,
- &current_dist ) );
-
- if ( current_dist.distance >= 0 )
- {
- diff = current_dist.distance - min_dist.distance;
-
-
- if ( FT_ABS( diff ) < CORNER_CHECK_EPSILON )
- min_dist = resolve_corner( min_dist, current_dist );
- else if ( diff < 0 )
- min_dist = current_dist;
- }
- else
- FT_TRACE0(( "sdf_contour_get_min_distance: Overflow.\n" ));
-
- edge_list = edge_list->next;
- }
-
- *out = min_dist;
-
- Exit:
- return error;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * sdf_generate
- *
- * @Description:
- * This is the main function that is responsible for generating signed
- * distance fields. The function does not align or compute the size of
- * `bitmap`; therefore the calling application must set up `bitmap`
- * properly and transform the `shape' appropriately in advance.
- *
- * Currently we check all pixels against all contours and all edges.
- *
- * @Input:
- * internal_params ::
- * Internal parameters and properties required by the rasterizer. See
- * @SDF_Params for more.
- *
- * shape ::
- * A complete shape which is used to generate SDF.
- *
- * spread ::
- * Maximum distances to be allowed in the output bitmap.
- *
- * @Output:
- * bitmap ::
- * The output bitmap which will contain the SDF information.
- *
- * @Return:
- * FreeType error, 0 means success.
- *
- */
- static FT_Error
- sdf_generate( const SDF_Params internal_params,
- const SDF_Shape* shape,
- FT_UInt spread,
- const FT_Bitmap* bitmap )
- {
- FT_Error error = FT_Err_Ok;
-
- FT_UInt width = 0;
- FT_UInt rows = 0;
- FT_UInt x = 0; /* used to loop in x direction, i.e., width */
- FT_UInt y = 0; /* used to loop in y direction, i.e., rows */
- FT_UInt sp_sq = 0; /* `spread` [* `spread`] as a 16.16 fixed value */
-
- FT_Short* buffer;
-
-
- if ( !shape || !bitmap )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- if ( spread < MIN_SPREAD || spread > MAX_SPREAD )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- width = bitmap->width;
- rows = bitmap->rows;
- buffer = (FT_Short*)bitmap->buffer;
-
- if ( USE_SQUARED_DISTANCES )
- sp_sq = FT_INT_16D16( spread * spread );
- else
- sp_sq = FT_INT_16D16( spread );
-
- if ( width == 0 || rows == 0 )
- {
- FT_TRACE0(( "sdf_generate:"
- " Cannot render glyph with width/height == 0\n" ));
- FT_TRACE0(( " "
- " (width, height provided [%d, %d])\n",
- width, rows ));
-
- error = FT_THROW( Cannot_Render_Glyph );
- goto Exit;
- }
-
- /* loop over all rows */
- for ( y = 0; y < rows; y++ )
- {
- /* loop over all pixels of a row */
- for ( x = 0; x < width; x++ )
- {
- /* `grid_point` is the current pixel position; */
- /* our task is to find the shortest distance */
- /* from this point to the entire shape. */
- FT_26D6_Vec grid_point = zero_vector;
- SDF_Signed_Distance min_dist = max_sdf;
- SDF_Contour* contour_list;
-
- FT_UInt index;
- FT_Short value;
-
-
- grid_point.x = FT_INT_26D6( x );
- grid_point.y = FT_INT_26D6( y );
-
- /* This `grid_point' is at the corner, but we */
- /* use the center of the pixel. */
- grid_point.x += FT_INT_26D6( 1 ) / 2;
- grid_point.y += FT_INT_26D6( 1 ) / 2;
-
- contour_list = shape->contours;
-
- /* iterate over all contours manually */
- while ( contour_list )
- {
- SDF_Signed_Distance current_dist = max_sdf;
-
-
- FT_CALL( sdf_contour_get_min_distance( contour_list,
- grid_point,
- &current_dist ) );
-
- if ( current_dist.distance < min_dist.distance )
- min_dist = current_dist;
-
- contour_list = contour_list->next;
- }
-
- /* [OPTIMIZATION]: if (min_dist > sp_sq) then simply clamp */
- /* the value to spread to avoid square_root */
-
- /* clamp the values to spread */
- if ( min_dist.distance > sp_sq )
- min_dist.distance = sp_sq;
-
- /* square_root the values and fit in a 6.10 fixed-point */
- if ( USE_SQUARED_DISTANCES )
- min_dist.distance = square_root( min_dist.distance );
-
- if ( internal_params.orientation == FT_ORIENTATION_FILL_LEFT )
- min_dist.sign = -min_dist.sign;
- if ( internal_params.flip_sign )
- min_dist.sign = -min_dist.sign;
-
- min_dist.distance /= 64; /* convert from 16.16 to 22.10 */
-
- value = min_dist.distance & 0x0000FFFF; /* truncate to 6.10 */
- value *= min_dist.sign;
-
- if ( internal_params.flip_y )
- index = y * width + x;
- else
- index = ( rows - y - 1 ) * width + x;
-
- buffer[index] = value;
- }
- }
-
- Exit:
- return error;
- }
-
-#endif /* 0 */
-
-
- /**************************************************************************
- *
- * @Function:
- * sdf_generate_bounding_box
- *
- * @Description:
- * This function does basically the same thing as `sdf_generate` above
- * but more efficiently.
- *
- * Instead of checking all pixels against all edges, we loop over all
- * edges and only check pixels around the control box of the edge; the
- * control box is increased by the spread in all directions. Anything
- * outside of the control box that exceeds `spread` doesn't need to be
- * computed.
- *
- * Lastly, to determine the sign of unchecked pixels, we do a single
- * pass of all rows starting with a '+' sign and flipping when we come
- * across a '-' sign and continue. This also eliminates the possibility
- * of overflow because we only check the proximity of the curve.
- * Therefore we can use squared distanced safely.
- *
- * @Input:
- * internal_params ::
- * Internal parameters and properties required by the rasterizer.
- * See @SDF_Params for more.
- *
- * shape ::
- * A complete shape which is used to generate SDF.
- *
- * spread ::
- * Maximum distances to be allowed in the output bitmap.
- *
- * @Output:
- * bitmap ::
- * The output bitmap which will contain the SDF information.
- *
- * @Return:
- * FreeType error, 0 means success.
- *
- */
- static FT_Error
- sdf_generate_bounding_box( const SDF_Params internal_params,
- const SDF_Shape* shape,
- FT_UInt spread,
- const FT_Bitmap* bitmap )
- {
- FT_Error error = FT_Err_Ok;
- FT_Memory memory = NULL;
-
- FT_Int width, rows, i, j;
- FT_Int sp_sq; /* max value to check */
-
- SDF_Contour* contours; /* list of all contours */
- FT_SDFFormat* buffer; /* the bitmap buffer */
-
- /* This buffer has the same size in indices as the */
- /* bitmap buffer. When we check a pixel position for */
- /* a shortest distance we keep it in this buffer. */
- /* This way we can find out which pixel is set, */
- /* and also determine the signs properly. */
- SDF_Signed_Distance* dists = NULL;
-
- const FT_16D16 fixed_spread = (FT_16D16)FT_INT_16D16( spread );
-
-
- if ( !shape || !bitmap )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- if ( spread < MIN_SPREAD || spread > MAX_SPREAD )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- memory = shape->memory;
- if ( !memory )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- if ( FT_ALLOC( dists,
- bitmap->width * bitmap->rows * sizeof ( *dists ) ) )
- goto Exit;
-
- contours = shape->contours;
- width = (FT_Int)bitmap->width;
- rows = (FT_Int)bitmap->rows;
- buffer = (FT_SDFFormat*)bitmap->buffer;
-
- if ( USE_SQUARED_DISTANCES )
- sp_sq = FT_INT_16D16( (FT_Int)( spread * spread ) );
- else
- sp_sq = fixed_spread;
-
- if ( width == 0 || rows == 0 )
- {
- FT_TRACE0(( "sdf_generate:"
- " Cannot render glyph with width/height == 0\n" ));
- FT_TRACE0(( " "
- " (width, height provided [%d, %d])", width, rows ));
-
- error = FT_THROW( Cannot_Render_Glyph );
- goto Exit;
- }
-
- /* loop over all contours */
- while ( contours )
- {
- SDF_Edge* edges = contours->edges;
-
-
- /* loop over all edges */
- while ( edges )
- {
- FT_CBox cbox;
- FT_Int x, y;
-
-
- /* get the control box and increase it by `spread' */
- cbox = get_control_box( *edges );
-
- cbox.xMin = ( cbox.xMin - 63 ) / 64 - ( FT_Pos )spread;
- cbox.xMax = ( cbox.xMax + 63 ) / 64 + ( FT_Pos )spread;
- cbox.yMin = ( cbox.yMin - 63 ) / 64 - ( FT_Pos )spread;
- cbox.yMax = ( cbox.yMax + 63 ) / 64 + ( FT_Pos )spread;
-
- /* now loop over the pixels in the control box. */
- for ( y = cbox.yMin; y < cbox.yMax; y++ )
- {
- for ( x = cbox.xMin; x < cbox.xMax; x++ )
- {
- FT_26D6_Vec grid_point = zero_vector;
- SDF_Signed_Distance dist = max_sdf;
- FT_UInt index = 0;
- FT_16D16 diff = 0;
-
-
- if ( x < 0 || x >= width )
- continue;
- if ( y < 0 || y >= rows )
- continue;
-
- grid_point.x = FT_INT_26D6( x );
- grid_point.y = FT_INT_26D6( y );
-
- /* This `grid_point` is at the corner, but we */
- /* use the center of the pixel. */
- grid_point.x += FT_INT_26D6( 1 ) / 2;
- grid_point.y += FT_INT_26D6( 1 ) / 2;
-
- FT_CALL( sdf_edge_get_min_distance( edges,
- grid_point,
- &dist ) );
-
- if ( internal_params.orientation == FT_ORIENTATION_FILL_LEFT )
- dist.sign = -dist.sign;
-
- /* ignore if the distance is greater than spread; */
- /* otherwise it creates artifacts due to the wrong sign */
- if ( dist.distance > sp_sq )
- continue;
-
- /* take the square root of the distance if required */
- if ( USE_SQUARED_DISTANCES )
- dist.distance = square_root( dist.distance );
-
- if ( internal_params.flip_y )
- index = (FT_UInt)( y * width + x );
- else
- index = (FT_UInt)( ( rows - y - 1 ) * width + x );
-
- /* check whether the pixel is set or not */
- if ( dists[index].sign == 0 )
- dists[index] = dist;
- else
- {
- diff = FT_ABS( dists[index].distance - dist.distance );
-
- if ( diff <= CORNER_CHECK_EPSILON )
- dists[index] = resolve_corner( dists[index], dist );
- else if ( dists[index].distance > dist.distance )
- dists[index] = dist;
- }
- }
- }
-
- edges = edges->next;
- }
-
- contours = contours->next;
- }
-
- /* final pass */
- for ( j = 0; j < rows; j++ )
- {
- /* We assume the starting pixel of each row is outside. */
- FT_Char current_sign = -1;
- FT_UInt index;
-
-
- if ( internal_params.overload_sign != 0 )
- current_sign = internal_params.overload_sign < 0 ? -1 : 1;
-
- for ( i = 0; i < width; i++ )
- {
- index = (FT_UInt)( j * width + i );
-
- /* if the pixel is not set */
- /* its shortest distance is more than `spread` */
- if ( dists[index].sign == 0 )
- dists[index].distance = fixed_spread;
- else
- current_sign = dists[index].sign;
-
- /* clamp the values */
- if ( dists[index].distance > fixed_spread )
- dists[index].distance = fixed_spread;
-
- /* flip sign if required */
- dists[index].distance *= internal_params.flip_sign ? -current_sign
- : current_sign;
-
- /* concatenate to appropriate format */
- buffer[index] = map_fixed_to_sdf( dists[index].distance,
- fixed_spread );
- }
- }
-
- Exit:
- FT_FREE( dists );
- return error;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * sdf_generate_subdivision
- *
- * @Description:
- * Subdivide the shape into a number of straight lines, then use the
- * above `sdf_generate_bounding_box` function to generate the SDF.
- *
- * Note: After calling this function `shape` no longer has the original
- * edges, it only contains lines.
- *
- * @Input:
- * internal_params ::
- * Internal parameters and properties required by the rasterizer.
- * See @SDF_Params for more.
- *
- * shape ::
- * A complete shape which is used to generate SDF.
- *
- * spread ::
- * Maximum distances to be allowed inthe output bitmap.
- *
- * @Output:
- * bitmap ::
- * The output bitmap which will contain the SDF information.
- *
- * @Return:
- * FreeType error, 0 means success.
- *
- */
- static FT_Error
- sdf_generate_subdivision( const SDF_Params internal_params,
- SDF_Shape* shape,
- FT_UInt spread,
- const FT_Bitmap* bitmap )
- {
- /*
- * Thanks to Alexei for providing the idea of this optimization.
- *
- * We take advantage of two facts.
- *
- * (1) Computing the shortest distance from a point to a line segment is
- * very fast.
- * (2) We don't have to compute the shortest distance for the entire
- * two-dimensional grid.
- *
- * Both ideas lead to the following optimization.
- *
- * (1) Split the outlines into a number of line segments.
- *
- * (2) For each line segment, only process its neighborhood.
- *
- * (3) Compute the closest distance to the line only for neighborhood
- * grid points.
- *
- * This greatly reduces the number of grid points to check.
- */
-
- FT_Error error = FT_Err_Ok;
-
-
- FT_CALL( split_sdf_shape( shape ) );
- FT_CALL( sdf_generate_bounding_box( internal_params,
- shape, spread, bitmap ) );
-
- Exit:
- return error;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * sdf_generate_with_overlaps
- *
- * @Description:
- * This function can be used to generate SDF for glyphs with overlapping
- * contours. The function generates SDF for contours separately on
- * separate bitmaps (to generate SDF it uses
- * `sdf_generate_subdivision`). At the end it simply combines all the
- * SDF into the output bitmap; this fixes all the signs and removes
- * overlaps.
- *
- * @Input:
- * internal_params ::
- * Internal parameters and properties required by the rasterizer. See
- * @SDF_Params for more.
- *
- * shape ::
- * A complete shape which is used to generate SDF.
- *
- * spread ::
- * Maximum distances to be allowed in the output bitmap.
- *
- * @Output:
- * bitmap ::
- * The output bitmap which will contain the SDF information.
- *
- * @Return:
- * FreeType error, 0 means success.
- *
- * @Note:
- * The function cannot generate a proper SDF for glyphs with
- * self-intersecting contours because we cannot separate them into two
- * separate bitmaps. In case of self-intersecting contours it is
- * necessary to remove the overlaps before generating the SDF.
- *
- */
- static FT_Error
- sdf_generate_with_overlaps( SDF_Params internal_params,
- SDF_Shape* shape,
- FT_UInt spread,
- const FT_Bitmap* bitmap )
- {
- FT_Error error = FT_Err_Ok;
-
- FT_Int num_contours; /* total number of contours */
- FT_Int i, j; /* iterators */
- FT_Int width, rows; /* width and rows of the bitmap */
- FT_Bitmap* bitmaps; /* separate bitmaps for contours */
-
- SDF_Contour* contour; /* temporary variable to iterate */
- SDF_Contour* temp_contour; /* temporary contour */
- SDF_Contour* head; /* head of the contour list */
- SDF_Shape temp_shape; /* temporary shape */
-
- FT_Memory memory; /* to allocate memory */
- FT_SDFFormat* t; /* target bitmap buffer */
- FT_Bool flip_sign; /* flip sign? */
-
- /* orientation of all the separate contours */
- SDF_Contour_Orientation* orientations;
-
-
- bitmaps = NULL;
- orientations = NULL;
- head = NULL;
-
- if ( !shape || !bitmap || !shape->memory )
- return FT_THROW( Invalid_Argument );
-
- /* Disable `flip_sign` to avoid extra complication */
- /* during the combination phase. */
- flip_sign = internal_params.flip_sign;
- internal_params.flip_sign = 0;
-
- contour = shape->contours;
- memory = shape->memory;
- temp_shape.memory = memory;
- width = (FT_Int)bitmap->width;
- rows = (FT_Int)bitmap->rows;
- num_contours = 0;
-
- /* find the number of contours in the shape */
- while ( contour )
- {
- num_contours++;
- contour = contour->next;
- }
-
- /* allocate the bitmaps to generate SDF for separate contours */
- if ( FT_ALLOC( bitmaps,
- (FT_UInt)num_contours * sizeof ( *bitmaps ) ) )
- goto Exit;
-
- /* allocate array to hold orientation for all contours */
- if ( FT_ALLOC( orientations,
- (FT_UInt)num_contours * sizeof ( *orientations ) ) )
- goto Exit;
-
- contour = shape->contours;
-
- /* Iterate over all contours and generate SDF separately. */
- for ( i = 0; i < num_contours; i++ )
- {
- /* initialize the corresponding bitmap */
- FT_Bitmap_Init( &bitmaps[i] );
-
- bitmaps[i].width = bitmap->width;
- bitmaps[i].rows = bitmap->rows;
- bitmaps[i].pitch = bitmap->pitch;
- bitmaps[i].num_grays = bitmap->num_grays;
- bitmaps[i].pixel_mode = bitmap->pixel_mode;
-
- /* allocate memory for the buffer */
- if ( FT_ALLOC( bitmaps[i].buffer,
- bitmap->rows * (FT_UInt)bitmap->pitch ) )
- goto Exit;
-
- /* determine the orientation */
- orientations[i] = get_contour_orientation( contour );
-
- /* The `overload_sign` property is specific to */
- /* `sdf_generate_bounding_box`. This basically */
- /* overloads the default sign of the outside */
- /* pixels, which is necessary for */
- /* counter-clockwise contours. */
- if ( orientations[i] == SDF_ORIENTATION_CCW &&
- internal_params.orientation == FT_ORIENTATION_FILL_RIGHT )
- internal_params.overload_sign = 1;
- else if ( orientations[i] == SDF_ORIENTATION_CW &&
- internal_params.orientation == FT_ORIENTATION_FILL_LEFT )
- internal_params.overload_sign = 1;
- else
- internal_params.overload_sign = 0;
-
- /* Make `contour->next` NULL so that there is */
- /* one contour in the list. Also hold the next */
- /* contour in a temporary variable so as to */
- /* restore the original value. */
- temp_contour = contour->next;
- contour->next = NULL;
-
- /* Use `temp_shape` to hold the new contour. */
- /* Now, `temp_shape` has only one contour. */
- temp_shape.contours = contour;
-
- /* finally generate the SDF */
- FT_CALL( sdf_generate_subdivision( internal_params,
- &temp_shape,
- spread,
- &bitmaps[i] ) );
-
- /* Restore the original `next` variable. */
- contour->next = temp_contour;
-
- /* Since `split_sdf_shape` deallocated the original */
- /* contours list we need to assign the new value to */
- /* the shape's contour. */
- temp_shape.contours->next = head;
- head = temp_shape.contours;
-
- /* Simply flip the orientation in case of post-script fonts */
- /* so as to avoid modificatons in the combining phase. */
- if ( internal_params.orientation == FT_ORIENTATION_FILL_LEFT )
- {
- if ( orientations[i] == SDF_ORIENTATION_CW )
- orientations[i] = SDF_ORIENTATION_CCW;
- else if ( orientations[i] == SDF_ORIENTATION_CCW )
- orientations[i] = SDF_ORIENTATION_CW;
- }
-
- contour = contour->next;
- }
-
- /* assign the new contour list to `shape->contours` */
- shape->contours = head;
-
- /* cast the output bitmap buffer */
- t = (FT_SDFFormat*)bitmap->buffer;
-
- /* Iterate over all pixels and combine all separate */
- /* contours. These are the rules for combining: */
- /* */
- /* (1) For all clockwise contours, compute the largest */
- /* value. Name this as `val_c`. */
- /* (2) For all counter-clockwise contours, compute the */
- /* smallest value. Name this as `val_ac`. */
- /* (3) Now, finally use the smaller value of `val_c' */
- /* and `val_ac'. */
- for ( j = 0; j < rows; j++ )
- {
- for ( i = 0; i < width; i++ )
- {
- FT_Int id = j * width + i; /* index of current pixel */
- FT_Int c; /* contour iterator */
-
- FT_SDFFormat val_c = 0; /* max clockwise value */
- FT_SDFFormat val_ac = UCHAR_MAX; /* min counter-clockwise val */
-
-
- /* iterate through all the contours */
- for ( c = 0; c < num_contours; c++ )
- {
- /* current contour value */
- FT_SDFFormat temp = ( (FT_SDFFormat*)bitmaps[c].buffer )[id];
-
-
- if ( orientations[c] == SDF_ORIENTATION_CW )
- val_c = FT_MAX( val_c, temp ); /* clockwise */
- else
- val_ac = FT_MIN( val_ac, temp ); /* counter-clockwise */
- }
-
- /* Finally find the smaller of the two and assign to output. */
- /* Also apply `flip_sign` if set. */
- t[id] = FT_MIN( val_c, val_ac );
-
- if ( flip_sign )
- t[id] = invert_sign( t[id] );
- }
- }
-
- Exit:
- /* deallocate orientations array */
- if ( orientations )
- FT_FREE( orientations );
-
- /* deallocate temporary bitmaps */
- if ( bitmaps )
- {
- if ( num_contours == 0 )
- error = FT_THROW( Raster_Corrupted );
- else
- {
- for ( i = 0; i < num_contours; i++ )
- FT_FREE( bitmaps[i].buffer );
-
- FT_FREE( bitmaps );
- }
- }
-
- /* restore the `flip_sign` property */
- internal_params.flip_sign = flip_sign;
-
- return error;
- }
-
-
- /**************************************************************************
- *
- * interface functions
- *
- */
-
- static FT_Error
- sdf_raster_new( void* memory_, /* FT_Memory */
- FT_Raster* araster_ ) /* SDF_PRaster* */
- {
- FT_Memory memory = (FT_Memory)memory_;
- SDF_PRaster* araster = (SDF_PRaster*)araster_;
-
-
- FT_Error error;
- SDF_PRaster raster = NULL;
-
-
- if ( !FT_NEW( raster ) )
- raster->memory = memory;
-
- *araster = raster;
-
- return error;
- }
-
-
- static void
- sdf_raster_reset( FT_Raster raster,
- unsigned char* pool_base,
- unsigned long pool_size )
- {
- FT_UNUSED( raster );
- FT_UNUSED( pool_base );
- FT_UNUSED( pool_size );
- }
-
-
- static FT_Error
- sdf_raster_set_mode( FT_Raster raster,
- unsigned long mode,
- void* args )
- {
- FT_UNUSED( raster );
- FT_UNUSED( mode );
- FT_UNUSED( args );
-
- return FT_Err_Ok;
- }
-
-
- static FT_Error
- sdf_raster_render( FT_Raster raster,
- const FT_Raster_Params* params )
- {
- FT_Error error = FT_Err_Ok;
- SDF_TRaster* sdf_raster = (SDF_TRaster*)raster;
- FT_Outline* outline = NULL;
- const SDF_Raster_Params* sdf_params = (const SDF_Raster_Params*)params;
-
- FT_Memory memory = NULL;
- SDF_Shape* shape = NULL;
- SDF_Params internal_params;
-
-
- /* check for valid arguments */
- if ( !sdf_raster || !sdf_params )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- outline = (FT_Outline*)sdf_params->root.source;
-
- /* check whether outline is valid */
- if ( !outline )
- {
- error = FT_THROW( Invalid_Outline );
- goto Exit;
- }
-
- /* if the outline is empty, return */
- if ( outline->n_points == 0 || outline->n_contours == 0 )
- goto Exit;
-
- /* check whether the outline has valid fields */
- if ( !outline->contours || !outline->points )
- {
- error = FT_THROW( Invalid_Outline );
- goto Exit;
- }
-
- /* check whether spread is set properly */
- if ( sdf_params->spread > MAX_SPREAD ||
- sdf_params->spread < MIN_SPREAD )
- {
- FT_TRACE0(( "sdf_raster_render:"
- " The `spread' field of `SDF_Raster_Params' is invalid,\n" ));
- FT_TRACE0(( " "
- " the value of this field must be within [%d, %d].\n",
- MIN_SPREAD, MAX_SPREAD ));
- FT_TRACE0(( " "
- " Also, you must pass `SDF_Raster_Params' instead of\n" ));
- FT_TRACE0(( " "
- " the default `FT_Raster_Params' while calling\n" ));
- FT_TRACE0(( " "
- " this function and set the fields properly.\n" ));
-
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- memory = sdf_raster->memory;
- if ( !memory )
- {
- FT_TRACE0(( "sdf_raster_render:"
- " Raster not setup properly,\n" ));
- FT_TRACE0(( " "
- " unable to find memory handle.\n" ));
-
- error = FT_THROW( Invalid_Handle );
- goto Exit;
- }
-
- /* set up the parameters */
- internal_params.orientation = FT_Outline_Get_Orientation( outline );
- internal_params.flip_sign = sdf_params->flip_sign;
- internal_params.flip_y = sdf_params->flip_y;
- internal_params.overload_sign = 0;
-
- FT_CALL( sdf_shape_new( memory, &shape ) );
-
- FT_CALL( sdf_outline_decompose( outline, shape ) );
-
- if ( sdf_params->overlaps )
- FT_CALL( sdf_generate_with_overlaps( internal_params,
- shape, sdf_params->spread,
- sdf_params->root.target ) );
- else
- FT_CALL( sdf_generate_subdivision( internal_params,
- shape, sdf_params->spread,
- sdf_params->root.target ) );
-
- if ( shape )
- sdf_shape_done( &shape );
-
- Exit:
- return error;
- }
-
-
- static void
- sdf_raster_done( FT_Raster raster )
- {
- FT_Memory memory = (FT_Memory)((SDF_TRaster*)raster)->memory;
-
-
- FT_FREE( raster );
- }
-
-
- FT_DEFINE_RASTER_FUNCS(
- ft_sdf_raster,
-
- FT_GLYPH_FORMAT_OUTLINE,
-
- (FT_Raster_New_Func) sdf_raster_new, /* raster_new */
- (FT_Raster_Reset_Func) sdf_raster_reset, /* raster_reset */
- (FT_Raster_Set_Mode_Func)sdf_raster_set_mode, /* raster_set_mode */
- (FT_Raster_Render_Func) sdf_raster_render, /* raster_render */
- (FT_Raster_Done_Func) sdf_raster_done /* raster_done */
- )
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/sdf/ftsdf.h b/contrib/libs/freetype/src/sdf/ftsdf.h
deleted file mode 100644
index 25a0a13bb8..0000000000
--- a/contrib/libs/freetype/src/sdf/ftsdf.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/****************************************************************************
- *
- * ftsdf.h
- *
- * Signed Distance Field support (specification).
- *
- * Copyright (C) 2020-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * Written by Anuj Verma.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTSDF_H_
-#define FTSDF_H_
-
-#include <ft2build.h>
-#include FT_CONFIG_CONFIG_H
-#include <freetype/ftimage.h>
-
-/* common properties and function */
-#include "ftsdfcommon.h"
-
-FT_BEGIN_HEADER
-
- /**************************************************************************
- *
- * @struct:
- * SDF_Raster_Params
- *
- * @description:
- * This struct must be passed to the raster render function
- * @FT_Raster_RenderFunc instead of @FT_Raster_Params because the
- * rasterizer requires some additional information to render properly.
- *
- * @fields:
- * root ::
- * The native raster parameters structure.
- *
- * spread ::
- * This is an essential parameter/property required by the renderer.
- * `spread` defines the maximum unsigned value that is present in the
- * final SDF output. For the default value check file
- * `ftsdfcommon.h`.
- *
- * flip_sign ::
- * By default positive values indicate positions inside of contours,
- * i.e., filled by a contour. If this property is true then that
- * output will be the opposite of the default, i.e., negative values
- * indicate positions inside of contours.
- *
- * flip_y ::
- * Setting this parameter to true maked the output image flipped
- * along the y-axis.
- *
- * overlaps ::
- * Set this to true to generate SDF for glyphs having overlapping
- * contours. The overlapping support is limited to glyphs that do not
- * have self-intersecting contours. Also, removing overlaps require a
- * considerable amount of extra memory; additionally, it will not work
- * if generating SDF from bitmap.
- *
- * @note:
- * All properties are valid for both the 'sdf' and 'bsdf' renderers; the
- * exception is `overlaps`, which gets ignored by the 'bsdf' renderer.
- *
- */
- typedef struct SDF_Raster_Params_
- {
- FT_Raster_Params root;
- FT_UInt spread;
- FT_Bool flip_sign;
- FT_Bool flip_y;
- FT_Bool overlaps;
-
- } SDF_Raster_Params;
-
-
- /* rasterizer to convert outline to SDF */
- FT_EXPORT_VAR( const FT_Raster_Funcs ) ft_sdf_raster;
-
- /* rasterizer to convert bitmap to SDF */
- FT_EXPORT_VAR( const FT_Raster_Funcs ) ft_bitmap_sdf_raster;
-
-FT_END_HEADER
-
-#endif /* FTSDF_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/sdf/ftsdfcommon.c b/contrib/libs/freetype/src/sdf/ftsdfcommon.c
deleted file mode 100644
index 6b2cf7dfec..0000000000
--- a/contrib/libs/freetype/src/sdf/ftsdfcommon.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/****************************************************************************
- *
- * ftsdfcommon.c
- *
- * Auxiliary data for Signed Distance Field support (body).
- *
- * Copyright (C) 2020-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * Written by Anuj Verma.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include "ftsdf.h"
-#include "ftsdfcommon.h"
-
-
- /**************************************************************************
- *
- * format and sign manipulating functions
- *
- */
-
- /*
- * Convert 16.16 fixed-point values to the desired output format.
- * In this case we reduce 16.16 fixed-point values to normalized
- * 8-bit values.
- *
- * The `max_value` in the parameter is the maximum value in the
- * distance field map and is equal to the spread. We normalize
- * the distances using this value instead of computing the maximum
- * value for the entire bitmap.
- *
- * You can use this function to map the 16.16 signed values to any
- * format required. Do note that the output buffer is 8-bit, so only
- * use an 8-bit format for `FT_SDFFormat`, or increase the buffer size in
- * `ftsdfrend.c`.
- */
- FT_LOCAL_DEF( FT_SDFFormat )
- map_fixed_to_sdf( FT_16D16 dist,
- FT_16D16 max_value )
- {
- FT_SDFFormat out;
- FT_16D16 udist;
-
-
- /* normalize the distance values */
- dist = FT_DivFix( dist, max_value );
-
- udist = dist < 0 ? -dist : dist;
-
- /* Reduce the distance values to 8 bits. */
- /* */
- /* Since +1/-1 in 16.16 takes the 16th bit, we right-shift */
- /* the number by 9 to make it fit into the 7-bit range. */
- /* */
- /* One bit is reserved for the sign. */
- udist >>= 9;
-
- /* Since `char` can only store a maximum positive value */
- /* of 127 we need to make sure it does not wrap around and */
- /* give a negative value. */
- if ( dist > 0 && udist > 127 )
- udist = 127;
- if ( dist < 0 && udist > 128 )
- udist = 128;
-
- /* Output the data; negative values are from [0, 127] and positive */
- /* from [128, 255]. One important thing is that negative values */
- /* are inverted here, that means [0, 128] maps to [-128, 0] linearly. */
- /* More on that in `freetype.h` near the documentation of */
- /* `FT_RENDER_MODE_SDF`. */
- out = dist < 0 ? 128 - (FT_SDFFormat)udist
- : (FT_SDFFormat)udist + 128;
-
- return out;
- }
-
-
- /*
- * Invert the signed distance packed into the corresponding format.
- * So if the values are negative they will become positive in the
- * chosen format.
- *
- * [Note]: This function should only be used after converting the
- * 16.16 signed distance values to `FT_SDFFormat`. If that
- * conversion has not been done, then simply invert the sign
- * and use the above function to pack the values.
- */
- FT_LOCAL_DEF( FT_SDFFormat )
- invert_sign( FT_SDFFormat dist )
- {
- return 255 - dist;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/sdf/ftsdfcommon.h b/contrib/libs/freetype/src/sdf/ftsdfcommon.h
deleted file mode 100644
index d0f623f9f3..0000000000
--- a/contrib/libs/freetype/src/sdf/ftsdfcommon.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/****************************************************************************
- *
- * ftsdfcommon.h
- *
- * Auxiliary data for Signed Distance Field support (specification).
- *
- * Copyright (C) 2020-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * Written by Anuj Verma.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /****************************************************
- *
- * This file contains common functions and properties
- * for both the 'sdf' and 'bsdf' renderers.
- *
- */
-
-#ifndef FTSDFCOMMON_H_
-#define FTSDFCOMMON_H_
-
-#include <ft2build.h>
-#include FT_CONFIG_CONFIG_H
-#include <freetype/internal/ftobjs.h>
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * default values (cannot be set individually for each renderer)
- *
- */
-
- /* default spread value */
-#define DEFAULT_SPREAD 8
- /* minimum spread supported by the renderer */
-#define MIN_SPREAD 2
- /* maximum spread supported by the renderer */
-#define MAX_SPREAD 32
- /* pixel size in 26.6 */
-#define ONE_PIXEL ( 1 << 6 )
-
-
- /**************************************************************************
- *
- * common definitions (cannot be set individually for each renderer)
- *
- */
-
- /* If this macro is set to 1 the rasterizer uses squared distances for */
- /* computation. It can greatly improve the performance but there is a */
- /* chance of overflow and artifacts. You can safely use it up to a */
- /* pixel size of 128. */
-#ifndef USE_SQUARED_DISTANCES
-#define USE_SQUARED_DISTANCES 0
-#endif
-
-
- /**************************************************************************
- *
- * common macros
- *
- */
-
- /* convert int to 26.6 fixed-point */
-#define FT_INT_26D6( x ) ( x * 64 )
- /* convert int to 16.16 fixed-point */
-#define FT_INT_16D16( x ) ( x * 65536 )
- /* convert 26.6 to 16.16 fixed-point */
-#define FT_26D6_16D16( x ) ( x * 1024 )
-
-
- /* Convenience macro to call a function; it */
- /* jumps to label `Exit` if an error occurs. */
-#define FT_CALL( x ) do \
- { \
- error = ( x ); \
- if ( error != FT_Err_Ok ) \
- goto Exit; \
- } while ( 0 )
-
-
- /*
- * The macro `VECTOR_LENGTH_16D16` computes either squared distances or
- * actual distances, depending on the value of `USE_SQUARED_DISTANCES`.
- *
- * By using squared distances the performance can be greatly improved but
- * there is a risk of overflow.
- */
-#if USE_SQUARED_DISTANCES
-#define VECTOR_LENGTH_16D16( v ) ( FT_MulFix( v.x, v.x ) + \
- FT_MulFix( v.y, v.y ) )
-#else
-#define VECTOR_LENGTH_16D16( v ) FT_Vector_Length( &v )
-#endif
-
-
- /**************************************************************************
- *
- * common typedefs
- *
- */
-
- typedef FT_Vector FT_26D6_Vec; /* with 26.6 fixed-point components */
- typedef FT_Vector FT_16D16_Vec; /* with 16.16 fixed-point components */
-
- typedef FT_Int32 FT_16D16; /* 16.16 fixed-point representation */
- typedef FT_Int32 FT_26D6; /* 26.6 fixed-point representation */
- typedef FT_Byte FT_SDFFormat; /* format to represent SDF data */
-
- typedef FT_BBox FT_CBox; /* control box of a curve */
-
-
-#define square_root( x ) (FT_16D16)FT_SqrtFixed( (FT_UInt32)( x ) )
-
- FT_LOCAL( FT_SDFFormat )
- map_fixed_to_sdf( FT_16D16 dist,
- FT_16D16 max_value );
-
- FT_LOCAL( FT_SDFFormat )
- invert_sign( FT_SDFFormat dist );
-
-
-FT_END_HEADER
-
-#endif /* FTSDFCOMMON_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/sdf/ftsdferrs.h b/contrib/libs/freetype/src/sdf/ftsdferrs.h
deleted file mode 100644
index 5af873fafb..0000000000
--- a/contrib/libs/freetype/src/sdf/ftsdferrs.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/****************************************************************************
- *
- * ftsdferrs.h
- *
- * Signed Distance Field error codes (specification only).
- *
- * Copyright (C) 2020-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * Written by Anuj Verma.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTSDFERRS_H_
-#define FTSDFERRS_H_
-
-#include <freetype/ftmoderr.h>
-
-#undef FTERRORS_H_
-
-#undef FT_ERR_PREFIX
-#define FT_ERR_PREFIX Sdf_Err_
-#define FT_ERR_BASE FT_Mod_Err_Sdf
-
-#include <freetype/fterrors.h>
-
-#endif /* FTSDFERRS_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/sdf/ftsdfrend.c b/contrib/libs/freetype/src/sdf/ftsdfrend.c
deleted file mode 100644
index d3324678d6..0000000000
--- a/contrib/libs/freetype/src/sdf/ftsdfrend.c
+++ /dev/null
@@ -1,603 +0,0 @@
-/****************************************************************************
- *
- * ftsdfrend.c
- *
- * Signed Distance Field renderer interface (body).
- *
- * Copyright (C) 2020-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * Written by Anuj Verma.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/services/svprop.h>
-#include <freetype/ftoutln.h>
-#include <freetype/ftbitmap.h>
-#include "ftsdfrend.h"
-#include "ftsdf.h"
-
-#include "ftsdferrs.h"
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT sdf
-
-
- /**************************************************************************
- *
- * macros and default property values
- *
- */
-#define SDF_RENDERER( rend ) ( (SDF_Renderer)rend )
-
-
- /**************************************************************************
- *
- * for setting properties
- *
- */
-
- /* property setter function */
- static FT_Error
- sdf_property_set( FT_Module module,
- const char* property_name,
- const void* value,
- FT_Bool value_is_string )
- {
- FT_Error error = FT_Err_Ok;
- SDF_Renderer render = SDF_RENDERER( FT_RENDERER( module ) );
-
- FT_UNUSED( value_is_string );
-
-
- if ( ft_strcmp( property_name, "spread" ) == 0 )
- {
- FT_Int val = *(const FT_Int*)value;
-
-
- if ( val > MAX_SPREAD || val < MIN_SPREAD )
- {
- FT_TRACE0(( "[sdf] sdf_property_set:"
- " the `spread' property can have a value\n" ));
- FT_TRACE0(( " "
- " within range [%d, %d] (value provided: %d)\n",
- MIN_SPREAD, MAX_SPREAD, val ));
-
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- render->spread = (FT_UInt)val;
- FT_TRACE7(( "[sdf] sdf_property_set:"
- " updated property `spread' to %d\n", val ));
- }
-
- else if ( ft_strcmp( property_name, "flip_sign" ) == 0 )
- {
- FT_Int val = *(const FT_Int*)value;
-
-
- render->flip_sign = val ? 1 : 0;
- FT_TRACE7(( "[sdf] sdf_property_set:"
- " updated property `flip_sign' to %d\n", val ));
- }
-
- else if ( ft_strcmp( property_name, "flip_y" ) == 0 )
- {
- FT_Int val = *(const FT_Int*)value;
-
-
- render->flip_y = val ? 1 : 0;
- FT_TRACE7(( "[sdf] sdf_property_set:"
- " updated property `flip_y' to %d\n", val ));
- }
-
- else if ( ft_strcmp( property_name, "overlaps" ) == 0 )
- {
- FT_Bool val = *(const FT_Bool*)value;
-
-
- render->overlaps = val;
- FT_TRACE7(( "[sdf] sdf_property_set:"
- " updated property `overlaps' to %d\n", val ));
- }
-
- else
- {
- FT_TRACE0(( "[sdf] sdf_property_set:"
- " missing property `%s'\n", property_name ));
- error = FT_THROW( Missing_Property );
- }
-
- Exit:
- return error;
- }
-
-
- /* property getter function */
- static FT_Error
- sdf_property_get( FT_Module module,
- const char* property_name,
- void* value )
- {
- FT_Error error = FT_Err_Ok;
- SDF_Renderer render = SDF_RENDERER( FT_RENDERER( module ) );
-
-
- if ( ft_strcmp( property_name, "spread" ) == 0 )
- {
- FT_UInt* val = (FT_UInt*)value;
-
-
- *val = render->spread;
- }
-
- else if ( ft_strcmp( property_name, "flip_sign" ) == 0 )
- {
- FT_Int* val = (FT_Int*)value;
-
-
- *val = render->flip_sign;
- }
-
- else if ( ft_strcmp( property_name, "flip_y" ) == 0 )
- {
- FT_Int* val = (FT_Int*)value;
-
-
- *val = render->flip_y;
- }
-
- else if ( ft_strcmp( property_name, "overlaps" ) == 0 )
- {
- FT_Int* val = (FT_Int*)value;
-
-
- *val = render->overlaps;
- }
-
- else
- {
- FT_TRACE0(( "[sdf] sdf_property_get:"
- " missing property `%s'\n", property_name ));
- error = FT_THROW( Missing_Property );
- }
-
- return error;
- }
-
-
- FT_DEFINE_SERVICE_PROPERTIESREC(
- sdf_service_properties,
-
- (FT_Properties_SetFunc)sdf_property_set, /* set_property */
- (FT_Properties_GetFunc)sdf_property_get ) /* get_property */
-
-
- FT_DEFINE_SERVICEDESCREC1(
- sdf_services,
-
- FT_SERVICE_ID_PROPERTIES, &sdf_service_properties )
-
-
- static FT_Module_Interface
- ft_sdf_requester( FT_Module module,
- const char* module_interface )
- {
- FT_UNUSED( module );
-
- return ft_service_list_lookup( sdf_services, module_interface );
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /** **/
- /** OUTLINE TO SDF CONVERTER **/
- /** **/
- /*************************************************************************/
- /*************************************************************************/
-
- /**************************************************************************
- *
- * interface functions
- *
- */
-
- static FT_Error
- ft_sdf_init( FT_Module module ) /* SDF_Renderer */
- {
- SDF_Renderer sdf_render = SDF_RENDERER( module );
-
-
- sdf_render->spread = DEFAULT_SPREAD;
- sdf_render->flip_sign = 0;
- sdf_render->flip_y = 0;
- sdf_render->overlaps = 0;
-
- return FT_Err_Ok;
- }
-
-
- static void
- ft_sdf_done( FT_Module module )
- {
- FT_UNUSED( module );
- }
-
-
- /* generate signed distance field from a glyph's slot image */
- static FT_Error
- ft_sdf_render( FT_Renderer module,
- FT_GlyphSlot slot,
- FT_Render_Mode mode,
- const FT_Vector* origin )
- {
- FT_Error error = FT_Err_Ok;
- FT_Outline* outline = &slot->outline;
- FT_Bitmap* bitmap = &slot->bitmap;
- FT_Memory memory = NULL;
- FT_Renderer render = NULL;
-
- FT_Pos x_shift = 0;
- FT_Pos y_shift = 0;
-
- FT_Pos x_pad = 0;
- FT_Pos y_pad = 0;
-
- SDF_Raster_Params params;
- SDF_Renderer sdf_module = SDF_RENDERER( module );
-
-
- render = &sdf_module->root;
- memory = render->root.memory;
-
- /* check whether slot format is correct before rendering */
- if ( slot->format != render->glyph_format )
- {
- error = FT_THROW( Invalid_Glyph_Format );
- goto Exit;
- }
-
- /* check whether render mode is correct */
- if ( mode != FT_RENDER_MODE_SDF )
- {
- error = FT_THROW( Cannot_Render_Glyph );
- goto Exit;
- }
-
- /* deallocate the previously allocated bitmap */
- if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
- {
- FT_FREE( bitmap->buffer );
- slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
- }
-
- /* preset the bitmap using the glyph's outline; */
- /* the sdf bitmap is similar to an anti-aliased bitmap */
- /* with a slightly bigger size and different pixel mode */
- if ( ft_glyphslot_preset_bitmap( slot, FT_RENDER_MODE_NORMAL, origin ) )
- {
- error = FT_THROW( Raster_Overflow );
- goto Exit;
- }
-
- /* nothing to render */
- if ( !bitmap->rows || !bitmap->pitch )
- goto Exit;
-
- /* the padding will simply be equal to the `spread' */
- x_pad = sdf_module->spread;
- y_pad = sdf_module->spread;
-
- /* apply the padding; will be in all the directions */
- bitmap->rows += y_pad * 2;
- bitmap->width += x_pad * 2;
-
- /* ignore the pitch, pixel mode and set custom */
- bitmap->pixel_mode = FT_PIXEL_MODE_GRAY;
- bitmap->pitch = (int)( bitmap->width );
- bitmap->num_grays = 255;
-
- /* allocate new buffer */
- if ( FT_ALLOC_MULT( bitmap->buffer, bitmap->rows, bitmap->pitch ) )
- goto Exit;
-
- slot->internal->flags |= FT_GLYPH_OWN_BITMAP;
-
- slot->bitmap_top += y_pad;
- slot->bitmap_left -= x_pad;
-
- x_shift = 64 * -slot->bitmap_left;
- y_shift = 64 * -slot->bitmap_top;
- y_shift += 64 * (FT_Int)bitmap->rows;
-
- if ( origin )
- {
- x_shift += origin->x;
- y_shift += origin->y;
- }
-
- /* translate outline to render it into the bitmap */
- if ( x_shift || y_shift )
- FT_Outline_Translate( outline, x_shift, y_shift );
-
- /* set up parameters */
- params.root.target = bitmap;
- params.root.source = outline;
- params.root.flags = FT_RASTER_FLAG_SDF;
- params.spread = sdf_module->spread;
- params.flip_sign = sdf_module->flip_sign;
- params.flip_y = sdf_module->flip_y;
- params.overlaps = sdf_module->overlaps;
-
- /* render the outline */
- error = render->raster_render( render->raster,
- (const FT_Raster_Params*)&params );
-
- /* transform the outline back to the original state */
- if ( x_shift || y_shift )
- FT_Outline_Translate( outline, -x_shift, -y_shift );
-
- Exit:
- if ( !error )
- {
- /* the glyph is successfully rendered to a bitmap */
- slot->format = FT_GLYPH_FORMAT_BITMAP;
- }
- else if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
- {
- FT_FREE( bitmap->buffer );
- slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
- }
-
- return error;
- }
-
-
- /* transform the glyph using matrix and/or delta */
- static FT_Error
- ft_sdf_transform( FT_Renderer render,
- FT_GlyphSlot slot,
- const FT_Matrix* matrix,
- const FT_Vector* delta )
- {
- FT_Error error = FT_Err_Ok;
-
-
- if ( slot->format != render->glyph_format )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- if ( matrix )
- FT_Outline_Transform( &slot->outline, matrix );
-
- if ( delta )
- FT_Outline_Translate( &slot->outline, delta->x, delta->y );
-
- Exit:
- return error;
- }
-
-
- /* return the control box of a glyph's outline */
- static void
- ft_sdf_get_cbox( FT_Renderer render,
- FT_GlyphSlot slot,
- FT_BBox* cbox )
- {
- FT_ZERO( cbox );
-
- if ( slot->format == render->glyph_format )
- FT_Outline_Get_CBox( &slot->outline, cbox );
- }
-
-
- /* set render specific modes or attributes */
- static FT_Error
- ft_sdf_set_mode( FT_Renderer render,
- FT_ULong mode_tag,
- FT_Pointer data )
- {
- /* pass it to the rasterizer */
- return render->clazz->raster_class->raster_set_mode( render->raster,
- mode_tag,
- data );
- }
-
-
- FT_DEFINE_RENDERER(
- ft_sdf_renderer_class,
-
- FT_MODULE_RENDERER,
- sizeof ( SDF_Renderer_Module ),
-
- "sdf",
- 0x10000L,
- 0x20000L,
-
- NULL,
-
- (FT_Module_Constructor)ft_sdf_init,
- (FT_Module_Destructor) ft_sdf_done,
- (FT_Module_Requester) ft_sdf_requester,
-
- FT_GLYPH_FORMAT_OUTLINE,
-
- (FT_Renderer_RenderFunc) ft_sdf_render, /* render_glyph */
- (FT_Renderer_TransformFunc)ft_sdf_transform, /* transform_glyph */
- (FT_Renderer_GetCBoxFunc) ft_sdf_get_cbox, /* get_glyph_cbox */
- (FT_Renderer_SetModeFunc) ft_sdf_set_mode, /* set_mode */
-
- (FT_Raster_Funcs*)&ft_sdf_raster /* raster_class */
- )
-
-
- /*************************************************************************/
- /*************************************************************************/
- /** **/
- /** BITMAP TO SDF CONVERTER **/
- /** **/
- /*************************************************************************/
- /*************************************************************************/
-
- /* generate signed distance field from glyph's bitmap */
- static FT_Error
- ft_bsdf_render( FT_Renderer module,
- FT_GlyphSlot slot,
- FT_Render_Mode mode,
- const FT_Vector* origin )
- {
- FT_Error error = FT_Err_Ok;
- FT_Memory memory = NULL;
-
- FT_Bitmap* bitmap = &slot->bitmap;
- FT_Renderer render = NULL;
- FT_Bitmap target;
-
- FT_Pos x_pad = 0;
- FT_Pos y_pad = 0;
-
- SDF_Raster_Params params;
- SDF_Renderer sdf_module = SDF_RENDERER( module );
-
-
- /* initialize the bitmap in case any error occurs */
- FT_Bitmap_Init( &target );
-
- render = &sdf_module->root;
- memory = render->root.memory;
-
- /* check whether slot format is correct before rendering */
- if ( slot->format != render->glyph_format )
- {
- error = FT_THROW( Invalid_Glyph_Format );
- goto Exit;
- }
-
- /* check whether render mode is correct */
- if ( mode != FT_RENDER_MODE_SDF )
- {
- error = FT_THROW( Cannot_Render_Glyph );
- goto Exit;
- }
-
- if ( origin )
- {
- FT_ERROR(( "ft_bsdf_render: can't translate the bitmap\n" ));
-
- error = FT_THROW( Unimplemented_Feature );
- goto Exit;
- }
-
- /* nothing to render */
- if ( !bitmap->rows || !bitmap->pitch )
- goto Exit;
-
- /* Do not generate SDF if the bitmap is not owned by the */
- /* glyph: it might be that the source buffer is already freed. */
- if ( !( slot->internal->flags & FT_GLYPH_OWN_BITMAP ) )
- {
- FT_ERROR(( "ft_bsdf_render: can't generate SDF from"
- " unowned source bitmap\n" ));
-
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- FT_Bitmap_New( &target );
-
- /* padding will simply be equal to `spread` */
- x_pad = sdf_module->spread;
- y_pad = sdf_module->spread;
-
- /* apply padding, which extends to all directions */
- target.rows = bitmap->rows + y_pad * 2;
- target.width = bitmap->width + x_pad * 2;
-
- /* set up the target bitmap */
- target.pixel_mode = FT_PIXEL_MODE_GRAY;
- target.pitch = (int)( target.width );
- target.num_grays = 255;
-
- if ( FT_ALLOC_MULT( target.buffer, target.rows, target.pitch ) )
- goto Exit;
-
- /* set up parameters */
- params.root.target = &target;
- params.root.source = bitmap;
- params.root.flags = FT_RASTER_FLAG_SDF;
- params.spread = sdf_module->spread;
- params.flip_sign = sdf_module->flip_sign;
- params.flip_y = sdf_module->flip_y;
-
- error = render->raster_render( render->raster,
- (const FT_Raster_Params*)&params );
-
- Exit:
- if ( !error )
- {
- /* the glyph is successfully converted to a SDF */
- if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
- FT_FREE( bitmap->buffer );
-
- slot->bitmap = target;
- slot->bitmap_top += y_pad;
- slot->bitmap_left -= x_pad;
-
- if ( target.buffer )
- slot->internal->flags |= FT_GLYPH_OWN_BITMAP;
- }
- else if ( target.buffer )
- FT_FREE( target.buffer );
-
- return error;
- }
-
-
- FT_DEFINE_RENDERER(
- ft_bitmap_sdf_renderer_class,
-
- FT_MODULE_RENDERER,
- sizeof ( SDF_Renderer_Module ),
-
- "bsdf",
- 0x10000L,
- 0x20000L,
-
- NULL,
-
- (FT_Module_Constructor)ft_sdf_init,
- (FT_Module_Destructor) ft_sdf_done,
- (FT_Module_Requester) ft_sdf_requester,
-
- FT_GLYPH_FORMAT_BITMAP,
-
- (FT_Renderer_RenderFunc) ft_bsdf_render, /* render_glyph */
- (FT_Renderer_TransformFunc)ft_sdf_transform, /* transform_glyph */
- (FT_Renderer_GetCBoxFunc) ft_sdf_get_cbox, /* get_glyph_cbox */
- (FT_Renderer_SetModeFunc) ft_sdf_set_mode, /* set_mode */
-
- (FT_Raster_Funcs*)&ft_bitmap_sdf_raster /* raster_class */
- )
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/sdf/ftsdfrend.h b/contrib/libs/freetype/src/sdf/ftsdfrend.h
deleted file mode 100644
index 2ea6f86819..0000000000
--- a/contrib/libs/freetype/src/sdf/ftsdfrend.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/****************************************************************************
- *
- * ftsdfrend.h
- *
- * Signed Distance Field renderer interface (specification).
- *
- * Copyright (C) 2020-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * Written by Anuj Verma.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTSDFREND_H_
-#define FTSDFREND_H_
-
-#include <freetype/ftrender.h>
-#include <freetype/ftmodapi.h>
-#include <freetype/internal/ftobjs.h>
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @struct:
- * SDF_Renderer_Module
- *
- * @description:
- * This struct extends the native renderer struct `FT_RendererRec`. It
- * is basically used to store various parameters required by the
- * renderer and some additional parameters that can be used to tweak the
- * output of the renderer.
- *
- * @fields:
- * root ::
- * The native rendere struct.
- *
- * spread ::
- * This is an essential parameter/property required by the renderer.
- * `spread` defines the maximum unsigned value that is present in the
- * final SDF output. For the default value check file
- * `ftsdfcommon.h`.
- *
- * flip_sign ::
- * By default positive values indicate positions inside of contours,
- * i.e., filled by a contour. If this property is true then that
- * output will be the opposite of the default, i.e., negative values
- * indicate positions inside of contours.
- *
- * flip_y ::
- * Setting this parameter to true makes the output image flipped
- * along the y-axis.
- *
- * overlaps ::
- * Set this to true to generate SDF for glyphs having overlapping
- * contours. The overlapping support is limited to glyphs that do not
- * have self-intersecting contours. Also, removing overlaps require a
- * considerable amount of extra memory; additionally, it will not work
- * if generating SDF from bitmap.
- *
- * @note:
- * All properties except `overlaps` are valid for both the 'sdf' and
- * 'bsdf' renderers.
- *
- */
- typedef struct SDF_Renderer_Module_
- {
- FT_RendererRec root;
- FT_UInt spread;
- FT_Bool flip_sign;
- FT_Bool flip_y;
- FT_Bool overlaps;
-
- } SDF_Renderer_Module, *SDF_Renderer;
-
-
- /**************************************************************************
- *
- * @renderer:
- * ft_sdf_renderer_class
- *
- * @description:
- * Renderer to convert @FT_Outline to signed distance fields.
- *
- */
- FT_DECLARE_RENDERER( ft_sdf_renderer_class )
-
-
- /**************************************************************************
- *
- * @renderer:
- * ft_bitmap_sdf_renderer_class
- *
- * @description:
- * This is not exactly a renderer; it is just a converter that
- * transforms bitmaps to signed distance fields.
- *
- * @note:
- * This is not a separate module, it is part of the 'sdf' module.
- *
- */
- FT_DECLARE_RENDERER( ft_bitmap_sdf_renderer_class )
-
-
-FT_END_HEADER
-
-#endif /* FTSDFREND_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/sdf/sdf.c b/contrib/libs/freetype/src/sdf/sdf.c
deleted file mode 100644
index 6045b8330b..0000000000
--- a/contrib/libs/freetype/src/sdf/sdf.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/****************************************************************************
- *
- * sdf.c
- *
- * FreeType Signed Distance Field renderer module component (body only).
- *
- * Copyright (C) 2020-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * Written by Anuj Verma.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#define FT_MAKE_OPTION_SINGLE_OBJECT
-
-#include "ftsdfrend.c"
-#include "ftsdfcommon.c"
-#include "ftbsdf.c"
-#include "ftsdf.c"
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/sfnt/pngshim.c b/contrib/libs/freetype/src/sfnt/pngshim.c
deleted file mode 100644
index a93b273a09..0000000000
--- a/contrib/libs/freetype/src/sfnt/pngshim.c
+++ /dev/null
@@ -1,462 +0,0 @@
-/****************************************************************************
- *
- * pngshim.c
- *
- * PNG Bitmap glyph support.
- *
- * Copyright (C) 2013-2024 by
- * Google, Inc.
- * Written by Stuart Gill and Behdad Esfahbod.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/tttags.h>
-#include FT_CONFIG_STANDARD_LIBRARY_H
-
-
-#if defined( TT_CONFIG_OPTION_EMBEDDED_BITMAPS ) && \
- defined( FT_CONFIG_OPTION_USE_PNG )
-
- /* We always include <setjmp.h>, so make libpng shut up! */
-#define PNG_SKIP_SETJMP_CHECK 1
-#error #include <png.h>
-#include "pngshim.h"
-
-#include "sferrors.h"
-
-
- /* This code is freely based on cairo-png.c. There's so many ways */
- /* to call libpng, and the way cairo does it is defacto standard. */
-
- static unsigned int
- multiply_alpha( unsigned int alpha,
- unsigned int color )
- {
- unsigned int temp = alpha * color + 0x80;
-
-
- return ( temp + ( temp >> 8 ) ) >> 8;
- }
-
-
- /* Premultiplies data and converts RGBA bytes => BGRA. */
- static void
- premultiply_data( png_structp png,
- png_row_infop row_info,
- png_bytep data )
- {
- unsigned int i = 0, limit;
-
- /* The `vector_size' attribute was introduced in gcc 3.1, which */
- /* predates clang; the `__BYTE_ORDER__' preprocessor symbol was */
- /* introduced in gcc 4.6 and clang 3.2, respectively. */
- /* `__builtin_shuffle' for gcc was introduced in gcc 4.7.0. */
- /* */
- /* Intel compilers do not currently support __builtin_shuffle; */
-
- /* The Intel check must be first. */
-#if !defined( __INTEL_COMPILER ) && \
- ( ( defined( __GNUC__ ) && \
- ( ( __GNUC__ >= 5 ) || \
- ( ( __GNUC__ == 4 ) && ( __GNUC_MINOR__ >= 7 ) ) ) ) || \
- ( defined( __clang__ ) && \
- ( ( __clang_major__ >= 4 ) || \
- ( ( __clang_major__ == 3 ) && ( __clang_minor__ >= 2 ) ) ) ) ) && \
- defined( __OPTIMIZE__ ) && \
- defined( __SSE__ ) && \
- __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
-
-#ifdef __clang__
- /* the clang documentation doesn't cover the two-argument case of */
- /* `__builtin_shufflevector'; however, it is is implemented since */
- /* version 2.8 */
-#define vector_shuffle __builtin_shufflevector
-#else
-#define vector_shuffle __builtin_shuffle
-#endif
-
- typedef unsigned short v82 __attribute__(( vector_size( 16 ) ));
-
-
- if ( row_info->rowbytes > 15 )
- {
- /* process blocks of 16 bytes in one rush, which gives a nice speed-up */
- limit = row_info->rowbytes - 16 + 1;
- for ( ; i < limit; i += 16 )
- {
- unsigned char* base = &data[i];
-
- v82 s, s0, s1, a;
-
- /* clang <= 3.9 can't apply scalar values to vectors */
- /* (or rather, it needs a different syntax) */
- v82 n0x80 = { 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 };
- v82 n0xFF = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
- v82 n8 = { 8, 8, 8, 8, 8, 8, 8, 8 };
-
- v82 ma = { 1, 1, 3, 3, 5, 5, 7, 7 };
- v82 o1 = { 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF };
- v82 m0 = { 1, 0, 3, 2, 5, 4, 7, 6 };
-
-
- ft_memcpy( &s, base, 16 ); /* RGBA RGBA RGBA RGBA */
- s0 = s & n0xFF; /* R B R B R B R B */
- s1 = s >> n8; /* G A G A G A G A */
-
- a = vector_shuffle( s1, ma ); /* A A A A A A A A */
- s1 |= o1; /* G 1 G 1 G 1 G 1 */
- s0 = vector_shuffle( s0, m0 ); /* B R B R B R B R */
-
- s0 *= a;
- s1 *= a;
- s0 += n0x80;
- s1 += n0x80;
- s0 = ( s0 + ( s0 >> n8 ) ) >> n8;
- s1 = ( s1 + ( s1 >> n8 ) ) >> n8;
-
- s = s0 | ( s1 << n8 );
- ft_memcpy( base, &s, 16 );
- }
- }
-#endif /* use `vector_size' */
-
- FT_UNUSED( png );
-
- limit = row_info->rowbytes;
- for ( ; i < limit; i += 4 )
- {
- unsigned char* base = &data[i];
- unsigned int alpha = base[3];
-
-
- if ( alpha == 0 )
- base[0] = base[1] = base[2] = base[3] = 0;
-
- else
- {
- unsigned int red = base[0];
- unsigned int green = base[1];
- unsigned int blue = base[2];
-
-
- if ( alpha != 0xFF )
- {
- red = multiply_alpha( alpha, red );
- green = multiply_alpha( alpha, green );
- blue = multiply_alpha( alpha, blue );
- }
-
- base[0] = (unsigned char)blue;
- base[1] = (unsigned char)green;
- base[2] = (unsigned char)red;
- base[3] = (unsigned char)alpha;
- }
- }
- }
-
-
- /* Converts RGBx bytes to BGRA. */
- static void
- convert_bytes_to_data( png_structp png,
- png_row_infop row_info,
- png_bytep data )
- {
- unsigned int i;
-
- FT_UNUSED( png );
-
-
- for ( i = 0; i < row_info->rowbytes; i += 4 )
- {
- unsigned char* base = &data[i];
- unsigned int red = base[0];
- unsigned int green = base[1];
- unsigned int blue = base[2];
-
-
- base[0] = (unsigned char)blue;
- base[1] = (unsigned char)green;
- base[2] = (unsigned char)red;
- base[3] = 0xFF;
- }
- }
-
-
- /* Use error callback to avoid png writing to stderr. */
- static void
- error_callback( png_structp png,
- png_const_charp error_msg )
- {
- FT_Error* error = (FT_Error*)png_get_error_ptr( png );
-
- FT_UNUSED( error_msg );
-
-
- *error = FT_THROW( Out_Of_Memory );
-#ifdef PNG_SETJMP_SUPPORTED
- ft_longjmp( png_jmpbuf( png ), 1 );
-#endif
- /* if we get here, then we have no choice but to abort ... */
- }
-
-
- /* Use warning callback to avoid png writing to stderr. */
- static void
- warning_callback( png_structp png,
- png_const_charp error_msg )
- {
- FT_UNUSED( png );
- FT_UNUSED( error_msg );
-
- /* Just ignore warnings. */
- }
-
-
- static void
- read_data_from_FT_Stream( png_structp png,
- png_bytep data,
- png_size_t length )
- {
- FT_Error error;
- png_voidp p = png_get_io_ptr( png );
- FT_Stream stream = (FT_Stream)p;
-
-
- if ( FT_FRAME_ENTER( length ) )
- {
- FT_Error* e = (FT_Error*)png_get_error_ptr( png );
-
-
- *e = FT_THROW( Invalid_Stream_Read );
- png_error( png, NULL );
-
- /* return; (never reached) */
- }
-
- ft_memcpy( data, stream->cursor, length );
-
- FT_FRAME_EXIT();
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- Load_SBit_Png( FT_GlyphSlot slot,
- FT_Int x_offset,
- FT_Int y_offset,
- FT_Int pix_bits,
- TT_SBit_Metrics metrics,
- FT_Memory memory,
- FT_Byte* data,
- FT_UInt png_len,
- FT_Bool populate_map_and_metrics,
- FT_Bool metrics_only )
- {
- FT_Bitmap *map = &slot->bitmap;
- FT_Error error = FT_Err_Ok;
- FT_StreamRec stream;
-
- png_structp png;
- png_infop info;
- png_uint_32 imgWidth, imgHeight;
-
- int bitdepth, color_type, interlace;
- FT_Int i;
-
- /* `rows` gets modified within a 'setjmp' scope; */
- /* we thus need the `volatile` keyword. */
- png_byte* *volatile rows = NULL;
-
-
- if ( x_offset < 0 ||
- y_offset < 0 )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- if ( !populate_map_and_metrics &&
- ( (FT_UInt)x_offset + metrics->width > map->width ||
- (FT_UInt)y_offset + metrics->height > map->rows ||
- pix_bits != 32 ||
- map->pixel_mode != FT_PIXEL_MODE_BGRA ) )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- FT_Stream_OpenMemory( &stream, data, png_len );
-
- png = png_create_read_struct( PNG_LIBPNG_VER_STRING,
- &error,
- error_callback,
- warning_callback );
- if ( !png )
- {
- error = FT_THROW( Out_Of_Memory );
- goto Exit;
- }
-
- info = png_create_info_struct( png );
- if ( !info )
- {
- error = FT_THROW( Out_Of_Memory );
- png_destroy_read_struct( &png, NULL, NULL );
- goto Exit;
- }
-
- if ( ft_setjmp( png_jmpbuf( png ) ) )
- {
- error = FT_THROW( Invalid_File_Format );
- goto DestroyExit;
- }
-
- png_set_read_fn( png, &stream, read_data_from_FT_Stream );
-
- png_read_info( png, info );
- png_get_IHDR( png, info,
- &imgWidth, &imgHeight,
- &bitdepth, &color_type, &interlace,
- NULL, NULL );
-
- if ( error ||
- ( !populate_map_and_metrics &&
- ( (FT_Int)imgWidth != metrics->width ||
- (FT_Int)imgHeight != metrics->height ) ) )
- goto DestroyExit;
-
- if ( populate_map_and_metrics )
- {
- /* reject too large bitmaps similarly to the rasterizer */
- if ( imgHeight > 0x7FFF || imgWidth > 0x7FFF )
- {
- error = FT_THROW( Array_Too_Large );
- goto DestroyExit;
- }
-
- metrics->width = (FT_UShort)imgWidth;
- metrics->height = (FT_UShort)imgHeight;
-
- map->width = metrics->width;
- map->rows = metrics->height;
- map->pixel_mode = FT_PIXEL_MODE_BGRA;
- map->pitch = (int)( map->width * 4 );
- map->num_grays = 256;
- }
-
- /* convert palette/gray image to rgb */
- if ( color_type == PNG_COLOR_TYPE_PALETTE )
- png_set_palette_to_rgb( png );
-
- /* expand gray bit depth if needed */
- if ( color_type == PNG_COLOR_TYPE_GRAY )
- {
-#if PNG_LIBPNG_VER >= 10209
- png_set_expand_gray_1_2_4_to_8( png );
-#else
- png_set_gray_1_2_4_to_8( png );
-#endif
- }
-
- /* transform transparency to alpha */
- if ( png_get_valid( png, info, PNG_INFO_tRNS ) )
- png_set_tRNS_to_alpha( png );
-
- if ( bitdepth == 16 )
- png_set_strip_16( png );
-
- if ( bitdepth < 8 )
- png_set_packing( png );
-
- /* convert grayscale to RGB */
- if ( color_type == PNG_COLOR_TYPE_GRAY ||
- color_type == PNG_COLOR_TYPE_GRAY_ALPHA )
- png_set_gray_to_rgb( png );
-
- if ( interlace != PNG_INTERLACE_NONE )
- png_set_interlace_handling( png );
-
- png_set_filler( png, 0xFF, PNG_FILLER_AFTER );
-
- /* recheck header after setting EXPAND options */
- png_read_update_info( png, info );
- png_get_IHDR( png, info,
- &imgWidth, &imgHeight,
- &bitdepth, &color_type, &interlace,
- NULL, NULL );
-
- if ( bitdepth != 8 ||
- !( color_type == PNG_COLOR_TYPE_RGB ||
- color_type == PNG_COLOR_TYPE_RGB_ALPHA ) )
- {
- error = FT_THROW( Invalid_File_Format );
- goto DestroyExit;
- }
-
- if ( metrics_only )
- goto DestroyExit;
-
- switch ( color_type )
- {
- default: /* Shouldn't happen, but ... */
- case PNG_COLOR_TYPE_RGB_ALPHA:
- png_set_read_user_transform_fn( png, premultiply_data );
- break;
-
- case PNG_COLOR_TYPE_RGB:
- /* Humm, this smells. Carry on though. */
- png_set_read_user_transform_fn( png, convert_bytes_to_data );
- break;
- }
-
- if ( populate_map_and_metrics )
- {
- /* this doesn't overflow: 0x7FFF * 0x7FFF * 4 < 2^32 */
- FT_ULong size = map->rows * (FT_ULong)map->pitch;
-
-
- error = ft_glyphslot_alloc_bitmap( slot, size );
- if ( error )
- goto DestroyExit;
- }
-
- if ( FT_QNEW_ARRAY( rows, imgHeight ) )
- {
- error = FT_THROW( Out_Of_Memory );
- goto DestroyExit;
- }
-
- for ( i = 0; i < (FT_Int)imgHeight; i++ )
- rows[i] = map->buffer + ( y_offset + i ) * map->pitch + x_offset * 4;
-
- png_read_image( png, rows );
-
- png_read_end( png, info );
-
- DestroyExit:
- /* even if reading fails with longjmp, rows must be freed */
- FT_FREE( rows );
- png_destroy_read_struct( &png, &info, NULL );
- FT_Stream_Close( &stream );
-
- Exit:
- return error;
- }
-
-#else /* !(TT_CONFIG_OPTION_EMBEDDED_BITMAPS && FT_CONFIG_OPTION_USE_PNG) */
-
- /* ANSI C doesn't like empty source files */
- typedef int pngshim_dummy_;
-
-#endif /* !(TT_CONFIG_OPTION_EMBEDDED_BITMAPS && FT_CONFIG_OPTION_USE_PNG) */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/sfnt/pngshim.h b/contrib/libs/freetype/src/sfnt/pngshim.h
deleted file mode 100644
index 6e7a5c08e7..0000000000
--- a/contrib/libs/freetype/src/sfnt/pngshim.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/****************************************************************************
- *
- * pngshim.h
- *
- * PNG Bitmap glyph support.
- *
- * Copyright (C) 2013-2024 by
- * Google, Inc.
- * Written by Stuart Gill and Behdad Esfahbod.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef PNGSHIM_H_
-#define PNGSHIM_H_
-
-
-#include "ttload.h"
-
-
-FT_BEGIN_HEADER
-
-#ifdef FT_CONFIG_OPTION_USE_PNG
-
- FT_LOCAL( FT_Error )
- Load_SBit_Png( FT_GlyphSlot slot,
- FT_Int x_offset,
- FT_Int y_offset,
- FT_Int pix_bits,
- TT_SBit_Metrics metrics,
- FT_Memory memory,
- FT_Byte* data,
- FT_UInt png_len,
- FT_Bool populate_map_and_metrics,
- FT_Bool metrics_only );
-
-#endif
-
-FT_END_HEADER
-
-#endif /* PNGSHIM_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/sfnt/sfdriver.c b/contrib/libs/freetype/src/sfnt/sfdriver.c
deleted file mode 100644
index 81072207b4..0000000000
--- a/contrib/libs/freetype/src/sfnt/sfdriver.c
+++ /dev/null
@@ -1,1384 +0,0 @@
-/****************************************************************************
- *
- * sfdriver.c
- *
- * High-level SFNT driver interface (body).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/sfnt.h>
-#include <freetype/internal/ftobjs.h>
-#include <freetype/ttnameid.h>
-
-#include "sfdriver.h"
-#include "ttload.h"
-#include "sfobjs.h"
-
-#include "sferrors.h"
-
-#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
-#include "ttsbit.h"
-#endif
-
-#ifdef TT_CONFIG_OPTION_COLOR_LAYERS
-#include "ttcolr.h"
-#include "ttcpal.h"
-#endif
-
-#ifdef FT_CONFIG_OPTION_SVG
-#include "ttsvg.h"
-#endif
-
-#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
-#include "ttpost.h"
-#endif
-
-#ifdef TT_CONFIG_OPTION_BDF
-#include "ttbdf.h"
-#include <freetype/internal/services/svbdf.h>
-#endif
-
-#ifdef TT_CONFIG_OPTION_GPOS_KERNING
-#include "ttgpos.h"
-#endif
-
-#include "ttcmap.h"
-#include "ttkern.h"
-#include "ttmtx.h"
-
-#include <freetype/internal/services/svgldict.h>
-#include <freetype/internal/services/svpostnm.h>
-#include <freetype/internal/services/svsfnt.h>
-#include <freetype/internal/services/svttcmap.h>
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
-#include <freetype/ftmm.h>
-#include <freetype/internal/services/svmm.h>
-#endif
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT sfdriver
-
-
- /*
- * SFNT TABLE SERVICE
- *
- */
-
- FT_CALLBACK_DEF( FT_Error )
- sfnt_load_table( FT_Face face, /* TT_Face */
- FT_ULong tag,
- FT_Long offset,
- FT_Byte* buffer,
- FT_ULong* length )
- {
- TT_Face ttface = (TT_Face)face;
-
-
- return tt_face_load_any( ttface, tag, offset, buffer, length );
- }
-
-
- FT_CALLBACK_DEF( void* )
- get_sfnt_table( FT_Face face, /* TT_Face */
- FT_Sfnt_Tag tag )
- {
- TT_Face ttface = (TT_Face)face;
-
- void* table;
-
-
- switch ( tag )
- {
- case FT_SFNT_HEAD:
- table = &ttface->header;
- break;
-
- case FT_SFNT_HHEA:
- table = &ttface->horizontal;
- break;
-
- case FT_SFNT_VHEA:
- table = ttface->vertical_info ? &ttface->vertical : NULL;
- break;
-
- case FT_SFNT_OS2:
- table = ( ttface->os2.version == 0xFFFFU ) ? NULL : &ttface->os2;
- break;
-
- case FT_SFNT_POST:
- table = &ttface->postscript;
- break;
-
- case FT_SFNT_MAXP:
- table = &ttface->max_profile;
- break;
-
- case FT_SFNT_PCLT:
- table = ttface->pclt.Version ? &ttface->pclt : NULL;
- break;
-
- default:
- table = NULL;
- }
-
- return table;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- sfnt_table_info( FT_Face face, /* TT_Face */
- FT_UInt idx,
- FT_ULong *tag,
- FT_ULong *offset,
- FT_ULong *length )
- {
- TT_Face ttface = (TT_Face)face;
-
-
- if ( !offset || !length )
- return FT_THROW( Invalid_Argument );
-
- if ( !tag )
- *length = ttface->num_tables;
- else
- {
- if ( idx >= ttface->num_tables )
- return FT_THROW( Table_Missing );
-
- *tag = ttface->dir_tables[idx].Tag;
- *offset = ttface->dir_tables[idx].Offset;
- *length = ttface->dir_tables[idx].Length;
- }
-
- return FT_Err_Ok;
- }
-
-
- FT_DEFINE_SERVICE_SFNT_TABLEREC(
- sfnt_service_sfnt_table,
-
- sfnt_load_table, /* FT_SFNT_TableLoadFunc load_table */
- get_sfnt_table, /* FT_SFNT_TableGetFunc get_table */
- sfnt_table_info /* FT_SFNT_TableInfoFunc table_info */
- )
-
-
-#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
-
- /*
- * GLYPH DICT SERVICE
- *
- */
-
- FT_CALLBACK_DEF( FT_Error )
- sfnt_get_glyph_name( FT_Face face,
- FT_UInt glyph_index,
- FT_Pointer buffer,
- FT_UInt buffer_max )
- {
- FT_String* gname;
- FT_Error error;
-
-
- error = tt_face_get_ps_name( (TT_Face)face, glyph_index, &gname );
- if ( !error )
- FT_STRCPYN( buffer, gname, buffer_max );
-
- return error;
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- sfnt_get_name_index( FT_Face face,
- const FT_String* glyph_name )
- {
- TT_Face ttface = (TT_Face)face;
-
- FT_UInt i, max_gid = FT_UINT_MAX;
-
-
- if ( face->num_glyphs < 0 )
- return 0;
- else if ( (FT_ULong)face->num_glyphs < FT_UINT_MAX )
- max_gid = (FT_UInt)face->num_glyphs;
- else
- FT_TRACE0(( "Ignore glyph names for invalid GID 0x%08x - 0x%08lx\n",
- FT_UINT_MAX, face->num_glyphs ));
-
- for ( i = 0; i < max_gid; i++ )
- {
- FT_String* gname;
- FT_Error error = tt_face_get_ps_name( ttface, i, &gname );
-
-
- if ( error )
- continue;
-
- if ( !ft_strcmp( glyph_name, gname ) )
- return i;
- }
-
- return 0;
- }
-
-
- FT_DEFINE_SERVICE_GLYPHDICTREC(
- sfnt_service_glyph_dict,
-
- sfnt_get_glyph_name, /* FT_GlyphDict_GetNameFunc get_name */
- sfnt_get_name_index /* FT_GlyphDict_NameIndexFunc name_index */
- )
-
-#endif /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES */
-
-
- /*
- * POSTSCRIPT NAME SERVICE
- *
- */
-
- /* an array representing allowed ASCII characters in a PS string */
- static const unsigned char sfnt_ps_map[16] =
- {
- /* 4 0 C 8 */
- 0x00, 0x00, /* 0x00: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 */
- 0x00, 0x00, /* 0x10: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 */
- 0xDE, 0x7C, /* 0x20: 1 1 0 1 1 1 1 0 0 1 1 1 1 1 0 0 */
- 0xFF, 0xAF, /* 0x30: 1 1 1 1 1 1 1 1 1 0 1 0 1 1 1 1 */
- 0xFF, 0xFF, /* 0x40: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 */
- 0xFF, 0xD7, /* 0x50: 1 1 1 1 1 1 1 1 1 1 0 1 0 1 1 1 */
- 0xFF, 0xFF, /* 0x60: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 */
- 0xFF, 0x57 /* 0x70: 1 1 1 1 1 1 1 1 0 1 0 1 0 1 1 1 */
- };
-
-
- static int
- sfnt_is_postscript( int c )
- {
- unsigned int cc;
-
-
- if ( c < 0 || c >= 0x80 )
- return 0;
-
- cc = (unsigned int)c;
-
- return sfnt_ps_map[cc >> 3] & ( 1 << ( cc & 0x07 ) );
- }
-
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
-
- /* Only ASCII letters and digits are taken for a variation font */
- /* instance's PostScript name. */
- /* */
- /* `ft_isalnum' is a macro, but we need a function here, thus */
- /* this definition. */
- static int
- sfnt_is_alphanumeric( int c )
- {
- return ft_isalnum( c );
- }
-
-
- /* the implementation of MurmurHash3 is taken and adapted from */
- /* https://github.com/aappleby/smhasher/blob/master/src/MurmurHash3.cpp */
-
-#define ROTL32( x, r ) ( x << r ) | ( x >> ( 32 - r ) )
-
-
- static FT_UInt32
- fmix32( FT_UInt32 h )
- {
- h ^= h >> 16;
- h *= 0x85ebca6b;
- h ^= h >> 13;
- h *= 0xc2b2ae35;
- h ^= h >> 16;
-
- return h;
- }
-
-
- static void
- murmur_hash_3_128( const void* key,
- const unsigned int len,
- FT_UInt32 seed,
- void* out )
- {
- const FT_Byte* data = (const FT_Byte*)key;
- const int nblocks = (int)len / 16;
-
- FT_UInt32 h1 = seed;
- FT_UInt32 h2 = seed;
- FT_UInt32 h3 = seed;
- FT_UInt32 h4 = seed;
-
- const FT_UInt32 c1 = 0x239b961b;
- const FT_UInt32 c2 = 0xab0e9789;
- const FT_UInt32 c3 = 0x38b34ae5;
- const FT_UInt32 c4 = 0xa1e38b93;
-
- const FT_UInt32* blocks = (const FT_UInt32*)( data + nblocks * 16 );
-
- int i;
-
-
- for( i = -nblocks; i; i++ )
- {
- FT_UInt32 k1 = blocks[i * 4 + 0];
- FT_UInt32 k2 = blocks[i * 4 + 1];
- FT_UInt32 k3 = blocks[i * 4 + 2];
- FT_UInt32 k4 = blocks[i * 4 + 3];
-
-
- k1 *= c1;
- k1 = ROTL32( k1, 15 );
- k1 *= c2;
- h1 ^= k1;
-
- h1 = ROTL32( h1, 19 );
- h1 += h2;
- h1 = h1 * 5 + 0x561ccd1b;
-
- k2 *= c2;
- k2 = ROTL32( k2, 16 );
- k2 *= c3;
- h2 ^= k2;
-
- h2 = ROTL32( h2, 17 );
- h2 += h3;
- h2 = h2 * 5 + 0x0bcaa747;
-
- k3 *= c3;
- k3 = ROTL32( k3, 17 );
- k3 *= c4;
- h3 ^= k3;
-
- h3 = ROTL32( h3, 15 );
- h3 += h4;
- h3 = h3 * 5 + 0x96cd1c35;
-
- k4 *= c4;
- k4 = ROTL32( k4, 18 );
- k4 *= c1;
- h4 ^= k4;
-
- h4 = ROTL32( h4, 13 );
- h4 += h1;
- h4 = h4 * 5 + 0x32ac3b17;
- }
-
- {
- const FT_Byte* tail = (const FT_Byte*)( data + nblocks * 16 );
-
- FT_UInt32 k1 = 0;
- FT_UInt32 k2 = 0;
- FT_UInt32 k3 = 0;
- FT_UInt32 k4 = 0;
-
-
- switch ( len & 15 )
- {
- case 15:
- k4 ^= (FT_UInt32)tail[14] << 16;
- FALL_THROUGH;
- case 14:
- k4 ^= (FT_UInt32)tail[13] << 8;
- FALL_THROUGH;
- case 13:
- k4 ^= (FT_UInt32)tail[12];
- k4 *= c4;
- k4 = ROTL32( k4, 18 );
- k4 *= c1;
- h4 ^= k4;
- FALL_THROUGH;
-
- case 12:
- k3 ^= (FT_UInt32)tail[11] << 24;
- FALL_THROUGH;
- case 11:
- k3 ^= (FT_UInt32)tail[10] << 16;
- FALL_THROUGH;
- case 10:
- k3 ^= (FT_UInt32)tail[9] << 8;
- FALL_THROUGH;
- case 9:
- k3 ^= (FT_UInt32)tail[8];
- k3 *= c3;
- k3 = ROTL32( k3, 17 );
- k3 *= c4;
- h3 ^= k3;
- FALL_THROUGH;
-
- case 8:
- k2 ^= (FT_UInt32)tail[7] << 24;
- FALL_THROUGH;
- case 7:
- k2 ^= (FT_UInt32)tail[6] << 16;
- FALL_THROUGH;
- case 6:
- k2 ^= (FT_UInt32)tail[5] << 8;
- FALL_THROUGH;
- case 5:
- k2 ^= (FT_UInt32)tail[4];
- k2 *= c2;
- k2 = ROTL32( k2, 16 );
- k2 *= c3;
- h2 ^= k2;
- FALL_THROUGH;
-
- case 4:
- k1 ^= (FT_UInt32)tail[3] << 24;
- FALL_THROUGH;
- case 3:
- k1 ^= (FT_UInt32)tail[2] << 16;
- FALL_THROUGH;
- case 2:
- k1 ^= (FT_UInt32)tail[1] << 8;
- FALL_THROUGH;
- case 1:
- k1 ^= (FT_UInt32)tail[0];
- k1 *= c1;
- k1 = ROTL32( k1, 15 );
- k1 *= c2;
- h1 ^= k1;
- }
- }
-
- h1 ^= len;
- h2 ^= len;
- h3 ^= len;
- h4 ^= len;
-
- h1 += h2;
- h1 += h3;
- h1 += h4;
-
- h2 += h1;
- h3 += h1;
- h4 += h1;
-
- h1 = fmix32( h1 );
- h2 = fmix32( h2 );
- h3 = fmix32( h3 );
- h4 = fmix32( h4 );
-
- h1 += h2;
- h1 += h3;
- h1 += h4;
-
- h2 += h1;
- h3 += h1;
- h4 += h1;
-
- ((FT_UInt32*)out)[0] = h1;
- ((FT_UInt32*)out)[1] = h2;
- ((FT_UInt32*)out)[2] = h3;
- ((FT_UInt32*)out)[3] = h4;
- }
-
-
-#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
-
-
- typedef int (*char_type_func)( int c );
-
-
- /* Handling of PID/EID 3/0 and 3/1 is the same. */
-#define IS_WIN( n ) ( (n)->platformID == 3 && \
- ( (n)->encodingID == 1 || (n)->encodingID == 0 ) )
-
-#define IS_APPLE( n ) ( (n)->platformID == 1 && \
- (n)->encodingID == 0 )
-
- static char*
- get_win_string( FT_Memory memory,
- FT_Stream stream,
- TT_Name entry,
- char_type_func char_type,
- FT_Bool report_invalid_characters )
- {
- FT_Error error;
-
- char* result = NULL;
- FT_String* r;
- FT_Char* p;
- FT_UInt len;
-
-
- if ( FT_QALLOC( result, entry->stringLength / 2 + 1 ) )
- return NULL;
-
- if ( FT_STREAM_SEEK( entry->stringOffset ) ||
- FT_FRAME_ENTER( entry->stringLength ) )
- goto get_win_string_error;
-
- r = (FT_String*)result;
- p = (FT_Char*)stream->cursor;
-
- for ( len = entry->stringLength / 2; len > 0; len--, p += 2 )
- {
- if ( p[0] == 0 && char_type( p[1] ) )
- *r++ = p[1];
- else
- {
- if ( report_invalid_characters )
- FT_TRACE0(( "get_win_string:"
- " Character 0x%X invalid in PS name string\n",
- ((unsigned)p[0])*256 + (unsigned)p[1] ));
- continue;
- }
- }
- *r = '\0';
-
- FT_FRAME_EXIT();
-
- if ( r != result )
- return result;
-
- get_win_string_error:
- FT_FREE( result );
-
- entry->stringLength = 0;
- entry->stringOffset = 0;
- FT_FREE( entry->string );
-
- return NULL;
- }
-
-
- static char*
- get_apple_string( FT_Memory memory,
- FT_Stream stream,
- TT_Name entry,
- char_type_func char_type,
- FT_Bool report_invalid_characters )
- {
- FT_Error error;
-
- char* result = NULL;
- FT_String* r;
- FT_Char* p;
- FT_UInt len;
-
-
- if ( FT_QALLOC( result, entry->stringLength + 1 ) )
- return NULL;
-
- if ( FT_STREAM_SEEK( entry->stringOffset ) ||
- FT_FRAME_ENTER( entry->stringLength ) )
- goto get_apple_string_error;
-
- r = (FT_String*)result;
- p = (FT_Char*)stream->cursor;
-
- for ( len = entry->stringLength; len > 0; len--, p++ )
- {
- if ( char_type( *p ) )
- *r++ = *p;
- else
- {
- if ( report_invalid_characters )
- FT_TRACE0(( "get_apple_string:"
- " Character `%c' (0x%X) invalid in PS name string\n",
- *p, *p ));
- continue;
- }
- }
- *r = '\0';
-
- FT_FRAME_EXIT();
-
- if ( r != result )
- return result;
-
- get_apple_string_error:
- FT_FREE( result );
-
- entry->stringOffset = 0;
- entry->stringLength = 0;
- FT_FREE( entry->string );
-
- return NULL;
- }
-
-
- FT_CALLBACK_DEF( FT_Bool )
- sfnt_get_name_id( TT_Face face,
- FT_UShort id,
- FT_Int *win,
- FT_Int *apple )
- {
- FT_Int n;
-
-
- *win = -1;
- *apple = -1;
-
- for ( n = 0; n < face->num_names; n++ )
- {
- TT_Name name = face->name_table.names + n;
-
-
- if ( name->nameID == id && name->stringLength > 0 )
- {
- if ( IS_WIN( name ) && ( name->languageID == 0x409 || *win == -1 ) )
- *win = n;
-
- if ( IS_APPLE( name ) && ( name->languageID == 0 || *apple == -1 ) )
- *apple = n;
- }
- }
-
- return ( *win >= 0 ) || ( *apple >= 0 );
- }
-
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
-
- /*
- The maximum length of an axis value descriptor.
-
- We need 65536 different values for the decimal fraction; this fits
- nicely into five decimal places. Consequently, it consists of
-
- . the minus sign if the number is negative,
- . up to five characters for the digits before the decimal point,
- . the decimal point if there is a fractional part, and
- . up to five characters for the digits after the decimal point.
-
- We also need one byte for the leading `_' character and up to four
- bytes for the axis tag.
- */
-#define MAX_VALUE_DESCRIPTOR_LEN ( 1 + 5 + 1 + 5 + 1 + 4 )
-
-
- /* the maximum length of PostScript font names */
-#define MAX_PS_NAME_LEN 127
-
-
- /*
- * Find the shortest decimal representation of a 16.16 fixed-point
- * number. The function fills `buf' with the result, returning a pointer
- * to the position after the representation's last byte.
- */
-
- static char*
- fixed2float( FT_Int fixed,
- char* buf )
- {
- char* p;
- char* q;
- char tmp[5];
-
- FT_Int int_part;
- FT_Int frac_part;
-
- FT_Int i;
-
-
- p = buf;
-
- if ( fixed == 0 )
- {
- *p++ = '0';
- return p;
- }
-
- if ( fixed < 0 )
- {
- *p++ = '-';
- fixed = NEG_INT( fixed );
- }
-
- int_part = ( fixed >> 16 ) & 0xFFFF;
- frac_part = fixed & 0xFFFF;
-
- /* get digits of integer part (in reverse order) */
- q = tmp;
- while ( int_part > 0 )
- {
- *q++ = '0' + int_part % 10;
- int_part /= 10;
- }
-
- /* copy digits in correct order to buffer */
- while ( q > tmp )
- *p++ = *--q;
-
- if ( !frac_part )
- return p;
-
- /* save position of point */
- q = p;
- *p++ = '.';
-
- /* apply rounding */
- frac_part = frac_part * 10 + 5;
-
- /* get digits of fractional part */
- for ( i = 0; i < 5; i++ )
- {
- *p++ = '0' + (char)( frac_part / 0x10000L );
-
- frac_part %= 0x10000L;
- if ( !frac_part )
- break;
-
- frac_part *= 10;
- }
-
- /*
- If the remainder stored in `frac_part' (after the last FOR loop) is
- smaller than 34480*10, the resulting decimal value minus 0.00001 is
- an equivalent representation of `fixed'.
-
- The above FOR loop always finds the larger of the two values; I
- verified this by iterating over all possible fixed-point numbers.
-
- If the remainder is 17232*10, both values are equally good, and we
- take the next even number (following IEEE 754's `round to nearest,
- ties to even' rounding rule).
-
- If the remainder is smaller than 17232*10, the lower of the two
- numbers is nearer to the exact result (values 17232 and 34480 were
- also found by testing all possible fixed-point values).
-
- We use this to find a shorter decimal representation. If not ending
- with digit zero, we take the representation with less error.
- */
- p--;
- if ( p - q == 5 ) /* five digits? */
- {
- /* take the representation that has zero as the last digit */
- if ( frac_part < 34480 * 10 &&
- *p == '1' )
- *p = '0';
-
- /* otherwise use the one with less error */
- else if ( frac_part == 17232 * 10 &&
- *p & 1 )
- *p -= 1;
-
- else if ( frac_part < 17232 * 10 &&
- *p != '0' )
- *p -= 1;
- }
-
- /* remove trailing zeros */
- while ( *p == '0' )
- *p-- = '\0';
-
- return p + 1;
- }
-
-
- static const char hexdigits[16] =
- {
- '0', '1', '2', '3', '4', '5', '6', '7',
- '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
- };
-
-
- static const char*
- sfnt_get_var_ps_name( TT_Face face )
- {
- FT_Error error;
- FT_Memory memory = face->root.memory;
-
- FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm;
-
- FT_UInt num_coords;
- FT_Fixed* coords;
- FT_MM_Var* mm_var;
-
- FT_Int found, win, apple;
- FT_UInt i, j;
-
- char* result = NULL;
- char* p;
-
-
- if ( !face->var_postscript_prefix )
- {
- FT_UInt len;
-
-
- /* check whether we have a Variations PostScript Name Prefix */
- found = sfnt_get_name_id( face,
- TT_NAME_ID_VARIATIONS_PREFIX,
- &win,
- &apple );
- if ( !found )
- {
- /* otherwise use the typographic family name */
- found = sfnt_get_name_id( face,
- TT_NAME_ID_TYPOGRAPHIC_FAMILY,
- &win,
- &apple );
- }
-
- if ( !found )
- {
- /* according to the 'name' documentation in the OpenType */
- /* specification the font family name is to be used if the */
- /* typographic family name is missing, so let's do that */
- found = sfnt_get_name_id( face,
- TT_NAME_ID_FONT_FAMILY,
- &win,
- &apple );
- }
-
- if ( !found )
- {
- FT_TRACE0(( "sfnt_get_var_ps_name:"
- " Can't construct PS name prefix for font instances\n" ));
- return NULL;
- }
-
- /* prefer Windows entries over Apple */
- if ( win != -1 )
- result = get_win_string( face->root.memory,
- face->name_table.stream,
- face->name_table.names + win,
- sfnt_is_alphanumeric,
- 0 );
- if ( !result && apple != -1 )
- result = get_apple_string( face->root.memory,
- face->name_table.stream,
- face->name_table.names + apple,
- sfnt_is_alphanumeric,
- 0 );
-
- if ( !result )
- {
- FT_TRACE0(( "sfnt_get_var_ps_name:"
- " No valid PS name prefix for font instances found\n" ));
- /* XXX It probably makes sense to never let this fail */
- /* since an arbitrary prefix should work, too. */
- /* On the other hand, it is very unlikely that */
- /* we ever reach this code at all. */
- return NULL;
- }
-
- len = ft_strlen( result );
-
- /* sanitize if necessary; we reserve space for 36 bytes (a 128bit */
- /* checksum as a hex number, preceded by `-' and followed by three */
- /* ASCII dots, to be used if the constructed PS name would be too */
- /* long); this is also sufficient for a single instance */
- if ( len > MAX_PS_NAME_LEN - ( 1 + 32 + 3 ) )
- {
- len = MAX_PS_NAME_LEN - ( 1 + 32 + 3 );
- result[len] = '\0';
-
- FT_TRACE0(( "sfnt_get_var_ps_name:"
- " Shortening variation PS name prefix\n" ));
- FT_TRACE0(( " "
- " to %d characters\n", len ));
- }
-
- face->var_postscript_prefix = result;
- face->var_postscript_prefix_len = len;
- }
-
- mm->get_var_blend( FT_FACE( face ),
- &num_coords,
- &coords,
- NULL,
- &mm_var );
-
- if ( FT_IS_NAMED_INSTANCE( FT_FACE( face ) ) &&
- !FT_IS_VARIATION( FT_FACE( face ) ) )
- {
- SFNT_Service sfnt = (SFNT_Service)face->sfnt;
-
- FT_Long instance = ( ( face->root.face_index & 0x7FFF0000L ) >> 16 ) - 1;
- FT_UInt psid = mm_var->namedstyle[instance].psid;
-
- char* ps_name = NULL;
-
-
- /* try first to load the name string with index `postScriptNameID' */
- if ( psid == 6 ||
- ( psid > 255 && psid < 32768 ) )
- (void)sfnt->get_name( face, (FT_UShort)psid, &ps_name );
-
- if ( ps_name )
- {
- result = ps_name;
- p = result + ft_strlen( result ) + 1;
-
- goto check_length;
- }
- else
- {
- /* otherwise construct a name using `subfamilyNameID' */
- FT_UInt strid = mm_var->namedstyle[instance].strid;
-
- char* subfamily_name;
- char* s;
-
-
- (void)sfnt->get_name( face, (FT_UShort)strid, &subfamily_name );
-
- if ( !subfamily_name )
- {
- FT_TRACE1(( "sfnt_get_var_ps_name:"
- " can't construct named instance PS name;\n" ));
- FT_TRACE1(( " "
- " trying to construct normal instance PS name\n" ));
- goto construct_instance_name;
- }
-
- /* after the prefix we have character `-' followed by the */
- /* subfamily name (using only characters a-z, A-Z, and 0-9) */
- if ( FT_QALLOC( result, face->var_postscript_prefix_len +
- 1 + ft_strlen( subfamily_name ) + 1 ) )
- return NULL;
-
- ft_strcpy( result, face->var_postscript_prefix );
-
- p = result + face->var_postscript_prefix_len;
- *p++ = '-';
-
- s = subfamily_name;
- while ( *s )
- {
- if ( ft_isalnum( *s ) )
- *p++ = *s;
- s++;
- }
- *p++ = '\0';
-
- FT_FREE( subfamily_name );
- }
- }
- else
- {
- FT_Var_Axis* axis;
-
-
- construct_instance_name:
- axis = mm_var->axis;
-
- if ( FT_QALLOC( result,
- face->var_postscript_prefix_len +
- num_coords * MAX_VALUE_DESCRIPTOR_LEN + 1 ) )
- return NULL;
-
- p = result;
-
- ft_strcpy( p, face->var_postscript_prefix );
- p += face->var_postscript_prefix_len;
-
- for ( i = 0; i < num_coords; i++, coords++, axis++ )
- {
- char t;
-
-
- /* omit axis value descriptor if it is identical */
- /* to the default axis value */
- if ( *coords == axis->def )
- continue;
-
- *p++ = '_';
- p = fixed2float( *coords, p );
-
- t = (char)( axis->tag >> 24 );
- if ( t != ' ' && ft_isalnum( t ) )
- *p++ = t;
- t = (char)( axis->tag >> 16 );
- if ( t != ' ' && ft_isalnum( t ) )
- *p++ = t;
- t = (char)( axis->tag >> 8 );
- if ( t != ' ' && ft_isalnum( t ) )
- *p++ = t;
- t = (char)axis->tag;
- if ( t != ' ' && ft_isalnum( t ) )
- *p++ = t;
- }
- *p++ = '\0';
- }
-
- check_length:
- if ( p - result > MAX_PS_NAME_LEN )
- {
- /* the PS name is too long; replace the part after the prefix with */
- /* a checksum; we use MurmurHash 3 with a hash length of 128 bit */
-
- FT_UInt32 seed = 123456789;
-
- FT_UInt32 hash[4];
- FT_UInt32* h;
-
-
- murmur_hash_3_128( result, p - result, seed, hash );
-
- p = result + face->var_postscript_prefix_len;
- *p++ = '-';
-
- /* we convert the hash value to hex digits from back to front */
- p += 32 + 3;
- h = hash + 3;
-
- *p-- = '\0';
- *p-- = '.';
- *p-- = '.';
- *p-- = '.';
-
- for ( i = 0; i < 4; i++, h-- )
- {
- FT_UInt32 v = *h;
-
-
- for ( j = 0; j < 8; j++ )
- {
- *p-- = hexdigits[v & 0xF];
- v >>= 4;
- }
- }
- }
-
- return result;
- }
-
-#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
-
-
- FT_CALLBACK_DEF( const char* )
- sfnt_get_ps_name( FT_Face face ) /* TT_Face */
- {
- TT_Face ttface = (TT_Face)face;
-
- FT_Int found, win, apple;
- const char* result = NULL;
-
-
- if ( ttface->postscript_name )
- return ttface->postscript_name;
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- if ( ttface->blend &&
- ( FT_IS_NAMED_INSTANCE( face ) ||
- FT_IS_VARIATION( face ) ) )
- {
- ttface->postscript_name = sfnt_get_var_ps_name( ttface );
- return ttface->postscript_name;
- }
-#endif
-
- /* scan the name table to see whether we have a Postscript name here, */
- /* either in Macintosh or Windows platform encodings */
- found = sfnt_get_name_id( ttface, TT_NAME_ID_PS_NAME, &win, &apple );
- if ( !found )
- return NULL;
-
- /* prefer Windows entries over Apple */
- if ( win != -1 )
- result = get_win_string( FT_FACE_MEMORY( face ),
- ttface->name_table.stream,
- ttface->name_table.names + win,
- sfnt_is_postscript,
- 1 );
- if ( !result && apple != -1 )
- result = get_apple_string( FT_FACE_MEMORY( face ),
- ttface->name_table.stream,
- ttface->name_table.names + apple,
- sfnt_is_postscript,
- 1 );
-
- ttface->postscript_name = result;
-
- return result;
- }
-
-
- FT_DEFINE_SERVICE_PSFONTNAMEREC(
- sfnt_service_ps_name,
-
- sfnt_get_ps_name /* FT_PsName_GetFunc get_ps_font_name */
- )
-
-
- /*
- * TT CMAP INFO
- */
- FT_DEFINE_SERVICE_TTCMAPSREC(
- tt_service_get_cmap_info,
-
- tt_get_cmap_info /* TT_CMap_Info_GetFunc get_cmap_info */
- )
-
-
-#ifdef TT_CONFIG_OPTION_BDF
-
- static FT_Error
- sfnt_get_charset_id( FT_Face face,
- const char* *acharset_encoding,
- const char* *acharset_registry )
- {
- BDF_PropertyRec encoding, registry;
- FT_Error error;
-
-
- /* XXX: I don't know whether this is correct, since
- * tt_face_find_bdf_prop only returns something correct if we have
- * previously selected a size that is listed in the BDF table.
- * Should we change the BDF table format to include single offsets
- * for `CHARSET_REGISTRY' and `CHARSET_ENCODING'?
- */
- error = tt_face_find_bdf_prop( face, "CHARSET_REGISTRY", &registry );
- if ( !error )
- {
- error = tt_face_find_bdf_prop( face, "CHARSET_ENCODING", &encoding );
- if ( !error )
- {
- if ( registry.type == BDF_PROPERTY_TYPE_ATOM &&
- encoding.type == BDF_PROPERTY_TYPE_ATOM )
- {
- *acharset_encoding = encoding.u.atom;
- *acharset_registry = registry.u.atom;
- }
- else
- error = FT_THROW( Invalid_Argument );
- }
- }
-
- return error;
- }
-
-
- FT_DEFINE_SERVICE_BDFRec(
- sfnt_service_bdf,
-
- sfnt_get_charset_id, /* FT_BDF_GetCharsetIdFunc get_charset_id */
- tt_face_find_bdf_prop /* FT_BDF_GetPropertyFunc get_property */
- )
-
-
-#endif /* TT_CONFIG_OPTION_BDF */
-
-
- /*
- * SERVICE LIST
- */
-
-#if defined TT_CONFIG_OPTION_POSTSCRIPT_NAMES && defined TT_CONFIG_OPTION_BDF
- FT_DEFINE_SERVICEDESCREC5(
- sfnt_services,
-
- FT_SERVICE_ID_SFNT_TABLE, &sfnt_service_sfnt_table,
- FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &sfnt_service_ps_name,
- FT_SERVICE_ID_GLYPH_DICT, &sfnt_service_glyph_dict,
- FT_SERVICE_ID_BDF, &sfnt_service_bdf,
- FT_SERVICE_ID_TT_CMAP, &tt_service_get_cmap_info )
-#elif defined TT_CONFIG_OPTION_POSTSCRIPT_NAMES
- FT_DEFINE_SERVICEDESCREC4(
- sfnt_services,
-
- FT_SERVICE_ID_SFNT_TABLE, &sfnt_service_sfnt_table,
- FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &sfnt_service_ps_name,
- FT_SERVICE_ID_GLYPH_DICT, &sfnt_service_glyph_dict,
- FT_SERVICE_ID_TT_CMAP, &tt_service_get_cmap_info )
-#elif defined TT_CONFIG_OPTION_BDF
- FT_DEFINE_SERVICEDESCREC4(
- sfnt_services,
-
- FT_SERVICE_ID_SFNT_TABLE, &sfnt_service_sfnt_table,
- FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &sfnt_service_ps_name,
- FT_SERVICE_ID_BDF, &sfnt_service_bdf,
- FT_SERVICE_ID_TT_CMAP, &tt_service_get_cmap_info )
-#else
- FT_DEFINE_SERVICEDESCREC3(
- sfnt_services,
-
- FT_SERVICE_ID_SFNT_TABLE, &sfnt_service_sfnt_table,
- FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &sfnt_service_ps_name,
- FT_SERVICE_ID_TT_CMAP, &tt_service_get_cmap_info )
-#endif
-
-
- FT_CALLBACK_DEF( FT_Module_Interface )
- sfnt_get_interface( FT_Module module,
- const char* module_interface )
- {
- FT_UNUSED( module );
-
- return ft_service_list_lookup( sfnt_services, module_interface );
- }
-
-
-#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
-#define PUT_EMBEDDED_BITMAPS( a ) a
-#else
-#define PUT_EMBEDDED_BITMAPS( a ) NULL
-#endif
-
-#ifdef TT_CONFIG_OPTION_COLOR_LAYERS
-#define PUT_COLOR_LAYERS( a ) a
-#else
-#define PUT_COLOR_LAYERS( a ) NULL
-#endif
-
-#ifdef FT_CONFIG_OPTION_SVG
-#define PUT_SVG_SUPPORT( a ) a
-#else
-#define PUT_SVG_SUPPORT( a ) NULL
-#endif
-
-#define PUT_COLOR_LAYERS_V1( a ) PUT_COLOR_LAYERS( a )
-
-#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
-#define PUT_PS_NAMES( a ) a
-#else
-#define PUT_PS_NAMES( a ) NULL
-#endif
-
-#ifdef TT_CONFIG_OPTION_GPOS_KERNING
-#define PUT_GPOS_KERNING( a ) a
-#else
-#define PUT_GPOS_KERNING( a ) NULL
-#endif
-
- FT_DEFINE_SFNT_INTERFACE(
- sfnt_interface,
-
- tt_face_goto_table, /* TT_Loader_GotoTableFunc goto_table */
-
- sfnt_init_face, /* TT_Init_Face_Func init_face */
- sfnt_load_face, /* TT_Load_Face_Func load_face */
- sfnt_done_face, /* TT_Done_Face_Func done_face */
- sfnt_get_interface, /* FT_Module_Requester get_interface */
-
- tt_face_load_any, /* TT_Load_Any_Func load_any */
-
- tt_face_load_head, /* TT_Load_Table_Func load_head */
- tt_face_load_hhea, /* TT_Load_Metrics_Func load_hhea */
- tt_face_load_cmap, /* TT_Load_Table_Func load_cmap */
- tt_face_load_maxp, /* TT_Load_Table_Func load_maxp */
- tt_face_load_os2, /* TT_Load_Table_Func load_os2 */
- tt_face_load_post, /* TT_Load_Table_Func load_post */
-
- tt_face_load_name, /* TT_Load_Table_Func load_name */
- tt_face_free_name, /* TT_Free_Table_Func free_name */
-
- tt_face_load_kern, /* TT_Load_Table_Func load_kern */
- PUT_GPOS_KERNING( tt_face_load_gpos ),
- /* TT_Load_Table_Func load_gpos */
- tt_face_load_gasp, /* TT_Load_Table_Func load_gasp */
- tt_face_load_pclt, /* TT_Load_Table_Func load_init */
-
- /* see `ttload.h' */
- PUT_EMBEDDED_BITMAPS( tt_face_load_bhed ),
- /* TT_Load_Table_Func load_bhed */
- PUT_EMBEDDED_BITMAPS( tt_face_load_sbit_image ),
- /* TT_Load_SBit_Image_Func load_sbit_image */
-
- /* see `ttpost.h' */
- PUT_PS_NAMES( tt_face_get_ps_name ),
- /* TT_Get_PS_Name_Func get_psname */
- PUT_PS_NAMES( tt_face_free_ps_names ),
- /* TT_Free_Table_Func free_psnames */
-
- /* since version 2.1.8 */
- tt_face_get_kerning, /* TT_Face_GetKerningFunc get_kerning */
-
- PUT_GPOS_KERNING( tt_face_get_gpos_kerning ),
- /* TT_Face_GetKerningFunc get_gpos_kerning */
-
- /* since version 2.2 */
- tt_face_load_font_dir, /* TT_Load_Table_Func load_font_dir */
- tt_face_load_hmtx, /* TT_Load_Metrics_Func load_hmtx */
-
- /* see `ttsbit.h' and `sfnt.h' */
- PUT_EMBEDDED_BITMAPS( tt_face_load_sbit ),
- /* TT_Load_Table_Func load_eblc */
- PUT_EMBEDDED_BITMAPS( tt_face_free_sbit ),
- /* TT_Free_Table_Func free_eblc */
-
- PUT_EMBEDDED_BITMAPS( tt_face_set_sbit_strike ),
- /* TT_Set_SBit_Strike_Func set_sbit_strike */
- PUT_EMBEDDED_BITMAPS( tt_face_load_strike_metrics ),
- /* TT_Load_Strike_Metrics_Func load_strike_metrics */
-
- PUT_COLOR_LAYERS( tt_face_load_cpal ),
- /* TT_Load_Table_Func load_cpal */
- PUT_COLOR_LAYERS( tt_face_load_colr ),
- /* TT_Load_Table_Func load_colr */
- PUT_COLOR_LAYERS( tt_face_free_cpal ),
- /* TT_Free_Table_Func free_cpal */
- PUT_COLOR_LAYERS( tt_face_free_colr ),
- /* TT_Free_Table_Func free_colr */
- PUT_COLOR_LAYERS( tt_face_palette_set ),
- /* TT_Set_Palette_Func set_palette */
- PUT_COLOR_LAYERS( tt_face_get_colr_layer ),
- /* TT_Get_Colr_Layer_Func get_colr_layer */
-
- PUT_COLOR_LAYERS_V1( tt_face_get_colr_glyph_paint ),
- /* TT_Get_Color_Glyph_Paint_Func get_colr_glyph_paint */
- PUT_COLOR_LAYERS_V1( tt_face_get_color_glyph_clipbox ),
- /* TT_Get_Color_Glyph_ClipBox_Func get_clipbox */
- PUT_COLOR_LAYERS_V1( tt_face_get_paint_layers ),
- /* TT_Get_Paint_Layers_Func get_paint_layers */
- PUT_COLOR_LAYERS_V1( tt_face_get_colorline_stops ),
- /* TT_Get_Paint get_paint */
- PUT_COLOR_LAYERS_V1( tt_face_get_paint ),
- /* TT_Get_Colorline_Stops_Func get_colorline_stops */
-
- PUT_COLOR_LAYERS( tt_face_colr_blend_layer ),
- /* TT_Blend_Colr_Func colr_blend */
-
- tt_face_get_metrics, /* TT_Get_Metrics_Func get_metrics */
-
- tt_face_get_name, /* TT_Get_Name_Func get_name */
- sfnt_get_name_id, /* TT_Get_Name_ID_Func get_name_id */
-
- PUT_SVG_SUPPORT( tt_face_load_svg ),
- /* TT_Load_Table_Func load_svg */
- PUT_SVG_SUPPORT( tt_face_free_svg ),
- /* TT_Free_Table_Func free_svg */
- PUT_SVG_SUPPORT( tt_face_load_svg_doc )
- /* TT_Load_Svg_Doc_Func load_svg_doc */
- )
-
-
- FT_DEFINE_MODULE(
- sfnt_module_class,
-
- 0, /* not a font driver or renderer */
- sizeof ( FT_ModuleRec ),
-
- "sfnt", /* driver name */
- 0x10000L, /* driver version 1.0 */
- 0x20000L, /* driver requires FreeType 2.0 or higher */
-
- (const void*)&sfnt_interface, /* module specific interface */
-
- NULL, /* FT_Module_Constructor module_init */
- NULL, /* FT_Module_Destructor module_done */
- sfnt_get_interface /* FT_Module_Requester get_interface */
- )
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/sfnt/sfdriver.h b/contrib/libs/freetype/src/sfnt/sfdriver.h
deleted file mode 100644
index 6f71489fdc..0000000000
--- a/contrib/libs/freetype/src/sfnt/sfdriver.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/****************************************************************************
- *
- * sfdriver.h
- *
- * High-level SFNT driver interface (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef SFDRIVER_H_
-#define SFDRIVER_H_
-
-
-#include <freetype/ftmodapi.h>
-
-
-FT_BEGIN_HEADER
-
- FT_DECLARE_MODULE( sfnt_module_class )
-
-FT_END_HEADER
-
-#endif /* SFDRIVER_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/sfnt/sferrors.h b/contrib/libs/freetype/src/sfnt/sferrors.h
deleted file mode 100644
index d3ca1d9aa8..0000000000
--- a/contrib/libs/freetype/src/sfnt/sferrors.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/****************************************************************************
- *
- * sferrors.h
- *
- * SFNT error codes (specification only).
- *
- * Copyright (C) 2001-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /**************************************************************************
- *
- * This file is used to define the SFNT error enumeration constants.
- *
- */
-
-#ifndef SFERRORS_H_
-#define SFERRORS_H_
-
-#include <freetype/ftmoderr.h>
-
-#undef FTERRORS_H_
-
-#undef FT_ERR_PREFIX
-#define FT_ERR_PREFIX SFNT_Err_
-#define FT_ERR_BASE FT_Mod_Err_SFNT
-
-#include <freetype/fterrors.h>
-
-#endif /* SFERRORS_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/sfnt/sfnt.c b/contrib/libs/freetype/src/sfnt/sfnt.c
deleted file mode 100644
index 52411febc4..0000000000
--- a/contrib/libs/freetype/src/sfnt/sfnt.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/****************************************************************************
- *
- * sfnt.c
- *
- * Single object library component.
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#define FT_MAKE_OPTION_SINGLE_OBJECT
-
-#include "pngshim.c"
-#include "sfdriver.c"
-#include "sfobjs.c"
-#include "sfwoff.c"
-#include "sfwoff2.c"
-#include "ttbdf.c"
-#include "ttcmap.c"
-#include "ttcolr.c"
-#include "ttcpal.c"
-#include "ttsvg.c"
-
-#include "ttgpos.c"
-#include "ttkern.c"
-#include "ttload.c"
-#include "ttmtx.c"
-#include "ttpost.c"
-#include "ttsbit.c"
-#include "woff2tags.c"
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/sfnt/sfobjs.c b/contrib/libs/freetype/src/sfnt/sfobjs.c
deleted file mode 100644
index 6ee4e5e939..0000000000
--- a/contrib/libs/freetype/src/sfnt/sfobjs.c
+++ /dev/null
@@ -1,1552 +0,0 @@
-/****************************************************************************
- *
- * sfobjs.c
- *
- * SFNT object management (base).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include "sfobjs.h"
-#include "ttload.h"
-#include "ttcmap.h"
-#include "ttkern.h"
-#include "sfwoff.h"
-#include "sfwoff2.h"
-#include <freetype/internal/sfnt.h>
-#include <freetype/internal/ftdebug.h>
-#include <freetype/ttnameid.h>
-#include <freetype/tttags.h>
-#include <freetype/internal/services/svpscmap.h>
-#include <freetype/ftsnames.h>
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
-#include <freetype/internal/services/svmm.h>
-#include <freetype/internal/services/svmetric.h>
-#endif
-
-#include "sferrors.h"
-
-#ifdef TT_CONFIG_OPTION_BDF
-#include "ttbdf.h"
-#endif
-
-#ifdef TT_CONFIG_OPTION_GPOS_KERNING
-#include "ttgpos.h"
-#endif
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT sfobjs
-
-
-
- /* convert a UTF-16 name entry to ASCII */
- static FT_String*
- tt_name_ascii_from_utf16( TT_Name entry,
- FT_Memory memory )
- {
- FT_String* string = NULL;
- FT_UInt len, code, n;
- FT_Byte* read = (FT_Byte*)entry->string;
- FT_Error error;
-
-
- len = (FT_UInt)entry->stringLength / 2;
-
- if ( FT_QNEW_ARRAY( string, len + 1 ) )
- return NULL;
-
- for ( n = 0; n < len; n++ )
- {
- code = FT_NEXT_USHORT( read );
-
- if ( code == 0 )
- break;
-
- if ( code < 32 || code > 127 )
- code = '?';
-
- string[n] = (char)code;
- }
-
- string[n] = 0;
-
- return string;
- }
-
-
- /* convert an Apple Roman or symbol name entry to ASCII */
- static FT_String*
- tt_name_ascii_from_other( TT_Name entry,
- FT_Memory memory )
- {
- FT_String* string = NULL;
- FT_UInt len, code, n;
- FT_Byte* read = (FT_Byte*)entry->string;
- FT_Error error;
-
-
- len = (FT_UInt)entry->stringLength;
-
- if ( FT_QNEW_ARRAY( string, len + 1 ) )
- return NULL;
-
- for ( n = 0; n < len; n++ )
- {
- code = *read++;
-
- if ( code == 0 )
- break;
-
- if ( code < 32 || code > 127 )
- code = '?';
-
- string[n] = (char)code;
- }
-
- string[n] = 0;
-
- return string;
- }
-
-
- typedef FT_String* (*TT_Name_ConvertFunc)( TT_Name entry,
- FT_Memory memory );
-
-
- /* documentation is in sfnt.h */
-
- FT_LOCAL_DEF( FT_Error )
- tt_face_get_name( TT_Face face,
- FT_UShort nameid,
- FT_String** name )
- {
- FT_Memory memory = face->root.memory;
- FT_Error error = FT_Err_Ok;
- FT_String* result = NULL;
- FT_UShort n;
- TT_Name rec;
-
- FT_Int found_apple = -1;
- FT_Int found_apple_roman = -1;
- FT_Int found_apple_english = -1;
- FT_Int found_win = -1;
- FT_Int found_unicode = -1;
-
- FT_Bool is_english = 0;
-
- TT_Name_ConvertFunc convert;
-
-
- FT_ASSERT( name );
-
- rec = face->name_table.names;
- for ( n = 0; n < face->num_names; n++, rec++ )
- {
- /* According to the OpenType 1.3 specification, only Microsoft or */
- /* Apple platform IDs might be used in the `name' table. The */
- /* `Unicode' platform is reserved for the `cmap' table, and the */
- /* `ISO' one is deprecated. */
- /* */
- /* However, the Apple TrueType specification doesn't say the same */
- /* thing and goes to suggest that all Unicode `name' table entries */
- /* should be coded in UTF-16 (in big-endian format I suppose). */
- /* */
- if ( rec->nameID == nameid && rec->stringLength > 0 )
- {
- switch ( rec->platformID )
- {
- case TT_PLATFORM_APPLE_UNICODE:
- case TT_PLATFORM_ISO:
- /* there is `languageID' to check there. We should use this */
- /* field only as a last solution when nothing else is */
- /* available. */
- /* */
- found_unicode = n;
- break;
-
- case TT_PLATFORM_MACINTOSH:
- /* This is a bit special because some fonts will use either */
- /* an English language id, or a Roman encoding id, to indicate */
- /* the English version of its font name. */
- /* */
- if ( rec->languageID == TT_MAC_LANGID_ENGLISH )
- found_apple_english = n;
- else if ( rec->encodingID == TT_MAC_ID_ROMAN )
- found_apple_roman = n;
- break;
-
- case TT_PLATFORM_MICROSOFT:
- /* we only take a non-English name when there is nothing */
- /* else available in the font */
- /* */
- if ( found_win == -1 || ( rec->languageID & 0x3FF ) == 0x009 )
- {
- switch ( rec->encodingID )
- {
- case TT_MS_ID_SYMBOL_CS:
- case TT_MS_ID_UNICODE_CS:
- case TT_MS_ID_UCS_4:
- is_english = FT_BOOL( ( rec->languageID & 0x3FF ) == 0x009 );
- found_win = n;
- break;
-
- default:
- ;
- }
- }
- break;
-
- default:
- ;
- }
- }
- }
-
- found_apple = found_apple_roman;
- if ( found_apple_english >= 0 )
- found_apple = found_apple_english;
-
- /* some fonts contain invalid Unicode or Macintosh formatted entries; */
- /* we will thus favor names encoded in Windows formats if available */
- /* (provided it is an English name) */
- /* */
- convert = NULL;
- if ( found_win >= 0 && !( found_apple >= 0 && !is_english ) )
- {
- rec = face->name_table.names + found_win;
- switch ( rec->encodingID )
- {
- /* all Unicode strings are encoded using UTF-16BE */
- case TT_MS_ID_UNICODE_CS:
- case TT_MS_ID_SYMBOL_CS:
- convert = tt_name_ascii_from_utf16;
- break;
-
- case TT_MS_ID_UCS_4:
- /* Apparently, if this value is found in a name table entry, it is */
- /* documented as `full Unicode repertoire'. Experience with the */
- /* MsGothic font shipped with Windows Vista shows that this really */
- /* means UTF-16 encoded names (UCS-4 values are only used within */
- /* charmaps). */
- convert = tt_name_ascii_from_utf16;
- break;
-
- default:
- ;
- }
- }
- else if ( found_apple >= 0 )
- {
- rec = face->name_table.names + found_apple;
- convert = tt_name_ascii_from_other;
- }
- else if ( found_unicode >= 0 )
- {
- rec = face->name_table.names + found_unicode;
- convert = tt_name_ascii_from_utf16;
- }
-
- if ( rec && convert )
- {
- if ( !rec->string )
- {
- FT_Stream stream = face->name_table.stream;
-
-
- if ( FT_QNEW_ARRAY ( rec->string, rec->stringLength ) ||
- FT_STREAM_SEEK( rec->stringOffset ) ||
- FT_STREAM_READ( rec->string, rec->stringLength ) )
- {
- FT_FREE( rec->string );
- rec->stringLength = 0;
- result = NULL;
- goto Exit;
- }
- }
-
- result = convert( rec, memory );
- }
-
- Exit:
- *name = result;
- return error;
- }
-
-
- static FT_Encoding
- sfnt_find_encoding( int platform_id,
- int encoding_id )
- {
- typedef struct TEncoding_
- {
- int platform_id;
- int encoding_id;
- FT_Encoding encoding;
-
- } TEncoding;
-
- static
- const TEncoding tt_encodings[] =
- {
- { TT_PLATFORM_ISO, -1, FT_ENCODING_UNICODE },
-
- { TT_PLATFORM_APPLE_UNICODE, -1, FT_ENCODING_UNICODE },
-
- { TT_PLATFORM_MACINTOSH, TT_MAC_ID_ROMAN, FT_ENCODING_APPLE_ROMAN },
-
- { TT_PLATFORM_MICROSOFT, TT_MS_ID_SYMBOL_CS, FT_ENCODING_MS_SYMBOL },
- { TT_PLATFORM_MICROSOFT, TT_MS_ID_UCS_4, FT_ENCODING_UNICODE },
- { TT_PLATFORM_MICROSOFT, TT_MS_ID_UNICODE_CS, FT_ENCODING_UNICODE },
- { TT_PLATFORM_MICROSOFT, TT_MS_ID_SJIS, FT_ENCODING_SJIS },
- { TT_PLATFORM_MICROSOFT, TT_MS_ID_PRC, FT_ENCODING_PRC },
- { TT_PLATFORM_MICROSOFT, TT_MS_ID_BIG_5, FT_ENCODING_BIG5 },
- { TT_PLATFORM_MICROSOFT, TT_MS_ID_WANSUNG, FT_ENCODING_WANSUNG },
- { TT_PLATFORM_MICROSOFT, TT_MS_ID_JOHAB, FT_ENCODING_JOHAB }
- };
-
- const TEncoding *cur, *limit;
-
-
- cur = tt_encodings;
- limit = cur + sizeof ( tt_encodings ) / sizeof ( tt_encodings[0] );
-
- for ( ; cur < limit; cur++ )
- {
- if ( cur->platform_id == platform_id )
- {
- if ( cur->encoding_id == encoding_id ||
- cur->encoding_id == -1 )
- return cur->encoding;
- }
- }
-
- return FT_ENCODING_NONE;
- }
-
-
- /* Fill in face->ttc_header. If the font is not a TTC, it is */
- /* synthesized into a TTC with one offset table. */
- static FT_Error
- sfnt_open_font( FT_Stream stream,
- TT_Face face,
- FT_Int* face_instance_index,
- FT_Long* woff2_num_faces )
- {
- FT_Memory memory = stream->memory;
- FT_Error error;
- FT_ULong tag, offset;
-
- static const FT_Frame_Field ttc_header_fields[] =
- {
-#undef FT_STRUCTURE
-#define FT_STRUCTURE TTC_HeaderRec
-
- FT_FRAME_START( 8 ),
- FT_FRAME_LONG( version ),
- FT_FRAME_LONG( count ), /* this is ULong in the specs */
- FT_FRAME_END
- };
-
-#ifndef FT_CONFIG_OPTION_USE_BROTLI
- FT_UNUSED( face_instance_index );
- FT_UNUSED( woff2_num_faces );
-#endif
-
-
- face->ttc_header.tag = 0;
- face->ttc_header.version = 0;
- face->ttc_header.count = 0;
-
-#if defined( FT_CONFIG_OPTION_USE_ZLIB ) || \
- defined( FT_CONFIG_OPTION_USE_BROTLI )
- retry:
-#endif
-
- offset = FT_STREAM_POS();
-
- if ( FT_READ_ULONG( tag ) )
- return error;
-
-#ifdef FT_CONFIG_OPTION_USE_ZLIB
- if ( tag == TTAG_wOFF )
- {
- FT_TRACE2(( "sfnt_open_font: file is a WOFF; synthesizing SFNT\n" ));
-
- if ( FT_STREAM_SEEK( offset ) )
- return error;
-
- error = woff_open_font( stream, face );
- if ( error )
- return error;
-
- /* Swap out stream and retry! */
- stream = face->root.stream;
- goto retry;
- }
-#endif
-
-#ifdef FT_CONFIG_OPTION_USE_BROTLI
- if ( tag == TTAG_wOF2 )
- {
- FT_TRACE2(( "sfnt_open_font: file is a WOFF2; synthesizing SFNT\n" ));
-
- if ( FT_STREAM_SEEK( offset ) )
- return error;
-
- error = woff2_open_font( stream,
- face,
- face_instance_index,
- woff2_num_faces );
- if ( error )
- return error;
-
- /* Swap out stream and retry! */
- stream = face->root.stream;
- goto retry;
- }
-#endif
-
- if ( tag != 0x00010000UL &&
- tag != TTAG_ttcf &&
- tag != TTAG_OTTO &&
- tag != TTAG_true &&
- tag != TTAG_typ1 &&
- tag != TTAG_0xA5kbd &&
- tag != TTAG_0xA5lst &&
- tag != 0x00020000UL )
- {
- FT_TRACE2(( " not a font using the SFNT container format\n" ));
- return FT_THROW( Unknown_File_Format );
- }
-
- face->ttc_header.tag = TTAG_ttcf;
-
- if ( tag == TTAG_ttcf )
- {
- FT_Int n;
-
-
- FT_TRACE3(( "sfnt_open_font: file is a collection\n" ));
-
- if ( FT_STREAM_READ_FIELDS( ttc_header_fields, &face->ttc_header ) )
- return error;
-
- FT_TRACE3(( " with %ld subfonts\n",
- face->ttc_header.count ));
-
- if ( face->ttc_header.count == 0 )
- return FT_THROW( Invalid_Table );
-
- /* a rough size estimate: let's conservatively assume that there */
- /* is just a single table info in each subfont header (12 + 16*1 = */
- /* 28 bytes), thus we have (at least) `12 + 4*count' bytes for the */
- /* size of the TTC header plus `28*count' bytes for all subfont */
- /* headers */
- if ( (FT_ULong)face->ttc_header.count > stream->size / ( 28 + 4 ) )
- return FT_THROW( Array_Too_Large );
-
- /* now read the offsets of each font in the file */
- if ( FT_QNEW_ARRAY( face->ttc_header.offsets, face->ttc_header.count ) )
- return error;
-
- if ( FT_FRAME_ENTER( face->ttc_header.count * 4L ) )
- return error;
-
- for ( n = 0; n < face->ttc_header.count; n++ )
- face->ttc_header.offsets[n] = FT_GET_ULONG();
-
- FT_FRAME_EXIT();
- }
- else
- {
- FT_TRACE3(( "sfnt_open_font: synthesize TTC\n" ));
-
- face->ttc_header.version = 1 << 16;
- face->ttc_header.count = 1;
-
- if ( FT_QNEW( face->ttc_header.offsets ) )
- return error;
-
- face->ttc_header.offsets[0] = offset;
- }
-
- return error;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- sfnt_init_face( FT_Stream stream,
- TT_Face face,
- FT_Int face_instance_index,
- FT_Int num_params,
- FT_Parameter* params )
- {
- FT_Error error;
- FT_Library library = face->root.driver->root.library;
- SFNT_Service sfnt;
- FT_Int face_index;
- FT_Long woff2_num_faces = 0;
-
-
- /* for now, parameters are unused */
- FT_UNUSED( num_params );
- FT_UNUSED( params );
-
-
- sfnt = (SFNT_Service)face->sfnt;
- if ( !sfnt )
- {
- sfnt = (SFNT_Service)FT_Get_Module_Interface( library, "sfnt" );
- if ( !sfnt )
- {
- FT_ERROR(( "sfnt_init_face: cannot access `sfnt' module\n" ));
- return FT_THROW( Missing_Module );
- }
-
- face->sfnt = sfnt;
- face->goto_table = sfnt->goto_table;
- }
-
- FT_FACE_FIND_GLOBAL_SERVICE( face, face->psnames, POSTSCRIPT_CMAPS );
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- if ( !face->mm )
- {
- /* we want the MM interface from the `truetype' module only */
- FT_Module tt_module = FT_Get_Module( library, "truetype" );
-
-
- face->mm = ft_module_get_service( tt_module,
- FT_SERVICE_ID_MULTI_MASTERS,
- 0 );
- }
-
- if ( !face->tt_var )
- {
- /* we want the metrics variations interface */
- /* from the `truetype' module only */
- FT_Module tt_module = FT_Get_Module( library, "truetype" );
-
-
- face->tt_var = ft_module_get_service( tt_module,
- FT_SERVICE_ID_METRICS_VARIATIONS,
- 0 );
- }
-
- if ( !face->face_var )
- face->face_var = ft_module_get_service(
- &face->root.driver->root,
- FT_SERVICE_ID_METRICS_VARIATIONS,
- 0 );
-#endif
-
- FT_TRACE2(( "SFNT driver\n" ));
-
- error = sfnt_open_font( stream,
- face,
- &face_instance_index,
- &woff2_num_faces );
- if ( error )
- return error;
-
- /* Stream may have changed in sfnt_open_font. */
- stream = face->root.stream;
-
- FT_TRACE2(( "sfnt_init_face: %p (index %d)\n",
- (void *)face,
- face_instance_index ));
-
- face_index = FT_ABS( face_instance_index ) & 0xFFFF;
-
- /* value -(N+1) requests information on index N */
- if ( face_instance_index < 0 && face_index > 0 )
- face_index--;
-
- if ( face_index >= face->ttc_header.count )
- {
- if ( face_instance_index >= 0 )
- return FT_THROW( Invalid_Argument );
- else
- face_index = 0;
- }
-
- if ( FT_STREAM_SEEK( face->ttc_header.offsets[face_index] ) )
- return error;
-
- /* check whether we have a valid TrueType file */
- error = sfnt->load_font_dir( face, stream );
- if ( error )
- return error;
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- {
- FT_Memory memory = face->root.memory;
-
- FT_ULong fvar_len;
-
- FT_ULong version;
- FT_ULong offset;
-
- FT_UShort num_axes;
- FT_UShort axis_size;
- FT_UShort num_instances;
- FT_UShort instance_size;
-
- FT_Int instance_index;
-
- FT_Byte* default_values = NULL;
- FT_Byte* instance_values = NULL;
-
-
- instance_index = FT_ABS( face_instance_index ) >> 16;
-
- /* test whether current face is a GX font with named instances */
- if ( face->goto_table( face, TTAG_fvar, stream, &fvar_len ) ||
- fvar_len < 20 ||
- FT_READ_ULONG( version ) ||
- FT_READ_USHORT( offset ) ||
- FT_STREAM_SKIP( 2 ) /* reserved */ ||
- FT_READ_USHORT( num_axes ) ||
- FT_READ_USHORT( axis_size ) ||
- FT_READ_USHORT( num_instances ) ||
- FT_READ_USHORT( instance_size ) )
- {
- version = 0;
- offset = 0;
- num_axes = 0;
- axis_size = 0;
- num_instances = 0;
- instance_size = 0;
- }
-
- /* check that the data is bound by the table length */
- if ( version != 0x00010000UL ||
- axis_size != 20 ||
- num_axes == 0 ||
- /* `num_axes' limit implied by 16-bit `instance_size' */
- num_axes > 0x3FFE ||
- !( instance_size == 4 + 4 * num_axes ||
- instance_size == 6 + 4 * num_axes ) ||
- /* `num_instances' limit implied by limited range of name IDs */
- num_instances > 0x7EFF ||
- offset +
- axis_size * num_axes +
- instance_size * num_instances > fvar_len )
- num_instances = 0;
- else
- face->variation_support |= TT_FACE_FLAG_VAR_FVAR;
-
- /*
- * As documented in the OpenType specification, an entry for the
- * default instance may be omitted in the named instance table. In
- * particular this means that even if there is no named instance
- * table in the font we actually do have a named instance, namely the
- * default instance.
- *
- * For consistency, we always want the default instance in our list
- * of named instances. If it is missing, we try to synthesize it
- * later on. Here, we have to adjust `num_instances' accordingly.
- */
-
- if ( ( face->variation_support & TT_FACE_FLAG_VAR_FVAR ) &&
- !( FT_QALLOC( default_values, num_axes * 4 ) ||
- FT_QALLOC( instance_values, num_axes * 4 ) ) )
- {
- /* the current stream position is 16 bytes after the table start */
- FT_ULong array_start = FT_STREAM_POS() - 16 + offset;
- FT_ULong default_value_offset, instance_offset;
-
- FT_Byte* p;
- FT_UInt i;
-
-
- default_value_offset = array_start + 8;
- p = default_values;
-
- for ( i = 0; i < num_axes; i++ )
- {
- (void)FT_STREAM_READ_AT( default_value_offset, p, 4 );
-
- default_value_offset += axis_size;
- p += 4;
- }
-
- instance_offset = array_start + axis_size * num_axes + 4;
-
- for ( i = 0; i < num_instances; i++ )
- {
- (void)FT_STREAM_READ_AT( instance_offset,
- instance_values,
- num_axes * 4 );
-
- if ( !ft_memcmp( default_values, instance_values, num_axes * 4 ) )
- break;
-
- instance_offset += instance_size;
- }
-
- /* named instance indices start with value 1 */
- face->var_default_named_instance = i + 1;
-
- if ( i == num_instances )
- {
- /* no default instance in named instance table; */
- /* we thus have to synthesize it */
- num_instances++;
- }
- }
-
- FT_FREE( default_values );
- FT_FREE( instance_values );
-
- /* we don't support Multiple Master CFFs yet; */
- /* note that `glyf' or `CFF2' have precedence */
- if ( face->goto_table( face, TTAG_glyf, stream, 0 ) &&
- face->goto_table( face, TTAG_CFF2, stream, 0 ) &&
- !face->goto_table( face, TTAG_CFF, stream, 0 ) )
- num_instances = 0;
-
- /* instance indices in `face_instance_index' start with index 1, */
- /* thus `>' and not `>=' */
- if ( instance_index > num_instances )
- {
- if ( face_instance_index >= 0 )
- return FT_THROW( Invalid_Argument );
- else
- num_instances = 0;
- }
-
- face->root.style_flags = (FT_Long)num_instances << 16;
- }
-#endif
-
- face->root.num_faces = face->ttc_header.count;
- face->root.face_index = face_instance_index;
-
- /* `num_faces' for a WOFF2 needs to be handled separately. */
- if ( woff2_num_faces )
- face->root.num_faces = woff2_num_faces;
-
- return error;
- }
-
-
-#define LOAD_( x ) \
- do \
- { \
- FT_TRACE2(( "`" #x "' " )); \
- FT_TRACE3(( "-->\n" )); \
- \
- error = sfnt->load_ ## x( face, stream ); \
- \
- FT_TRACE2(( "%s\n", ( !error ) \
- ? "loaded" \
- : FT_ERR_EQ( error, Table_Missing ) \
- ? "missing" \
- : "failed to load" )); \
- FT_TRACE3(( "\n" )); \
- } while ( 0 )
-
-#define LOADM_( x, vertical ) \
- do \
- { \
- FT_TRACE2(( "`%s" #x "' ", \
- vertical ? "vertical " : "" )); \
- FT_TRACE3(( "-->\n" )); \
- \
- error = sfnt->load_ ## x( face, stream, vertical ); \
- \
- FT_TRACE2(( "%s\n", ( !error ) \
- ? "loaded" \
- : FT_ERR_EQ( error, Table_Missing ) \
- ? "missing" \
- : "failed to load" )); \
- FT_TRACE3(( "\n" )); \
- } while ( 0 )
-
-#define GET_NAME( id, field ) \
- do \
- { \
- error = tt_face_get_name( face, TT_NAME_ID_ ## id, field ); \
- if ( error ) \
- goto Exit; \
- } while ( 0 )
-
-
- FT_LOCAL_DEF( FT_Error )
- sfnt_load_face( FT_Stream stream,
- TT_Face face,
- FT_Int face_instance_index,
- FT_Int num_params,
- FT_Parameter* params )
- {
- FT_Error error;
-#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
- FT_Error psnames_error;
-#endif
-
- FT_Bool has_outline;
- FT_Bool is_apple_sbit;
-
- FT_Bool has_CBLC;
- FT_Bool has_CBDT;
- FT_Bool has_EBLC;
- FT_Bool has_bloc;
- FT_Bool has_sbix;
-
- FT_Bool ignore_typographic_family = FALSE;
- FT_Bool ignore_typographic_subfamily = FALSE;
- FT_Bool ignore_sbix = FALSE;
-
- SFNT_Service sfnt = (SFNT_Service)face->sfnt;
-
- FT_UNUSED( face_instance_index );
-
-
- /* Check parameters */
-
- {
- FT_Int i;
-
-
- for ( i = 0; i < num_params; i++ )
- {
- if ( params[i].tag == FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_FAMILY )
- ignore_typographic_family = TRUE;
- else if ( params[i].tag == FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_SUBFAMILY )
- ignore_typographic_subfamily = TRUE;
- else if ( params[i].tag == FT_PARAM_TAG_IGNORE_SBIX )
- ignore_sbix = TRUE;
- }
- }
-
- /* Load tables */
-
- /* We now support two SFNT-based bitmapped font formats. They */
- /* are recognized easily as they do not include a `glyf' */
- /* table. */
- /* */
- /* The first format comes from Apple, and uses a table named */
- /* `bhed' instead of `head' to store the font header (using */
- /* the same format). It also doesn't include horizontal and */
- /* vertical metrics tables (i.e. `hhea' and `vhea' tables are */
- /* missing). */
- /* */
- /* The other format comes from Microsoft, and is used with */
- /* WinCE/PocketPC. It looks like a standard TTF, except that */
- /* it doesn't contain outlines. */
- /* */
-
- FT_TRACE2(( "sfnt_load_face: %p\n", (void *)face ));
- FT_TRACE2(( "\n" ));
-
- /* do we have outlines in there? */
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- has_outline = FT_BOOL( face->root.internal->incremental_interface ||
- tt_face_lookup_table( face, TTAG_glyf ) ||
- tt_face_lookup_table( face, TTAG_CFF ) ||
- tt_face_lookup_table( face, TTAG_CFF2 ) );
-#else
- has_outline = FT_BOOL( tt_face_lookup_table( face, TTAG_glyf ) ||
- tt_face_lookup_table( face, TTAG_CFF ) ||
- tt_face_lookup_table( face, TTAG_CFF2 ) );
-#endif
-
- /* check which sbit formats are present */
- has_CBLC = !face->goto_table( face, TTAG_CBLC, stream, 0 );
- has_CBDT = !face->goto_table( face, TTAG_CBDT, stream, 0 );
- has_EBLC = !face->goto_table( face, TTAG_EBLC, stream, 0 );
- has_bloc = !face->goto_table( face, TTAG_bloc, stream, 0 );
- has_sbix = !face->goto_table( face, TTAG_sbix, stream, 0 );
-
- is_apple_sbit = FALSE;
-
- if ( ignore_sbix )
- has_sbix = FALSE;
-
- /* if this font doesn't contain outlines, we try to load */
- /* a `bhed' table */
- if ( !has_outline && sfnt->load_bhed )
- {
- LOAD_( bhed );
- is_apple_sbit = FT_BOOL( !error );
- }
-
- /* load the font header (`head' table) if this isn't an Apple */
- /* sbit font file */
- if ( !is_apple_sbit || has_sbix )
- {
- LOAD_( head );
- if ( error )
- goto Exit;
- }
-
- /* Ignore outlines for CBLC/CBDT fonts. */
- if ( has_CBLC || has_CBDT )
- has_outline = FALSE;
-
- /* OpenType 1.8.2 introduced limits to this value; */
- /* however, they make sense for older SFNT fonts also */
- if ( face->header.Units_Per_EM < 16 ||
- face->header.Units_Per_EM > 16384 )
- {
- error = FT_THROW( Invalid_Table );
-
- goto Exit;
- }
-
- /* the following tables are often not present in embedded TrueType */
- /* fonts within PDF documents, so don't check for them. */
- LOAD_( maxp );
- LOAD_( cmap );
-
- /* the following tables are optional in PCL fonts -- */
- /* don't check for errors */
- LOAD_( name );
- LOAD_( post );
-
-#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
- psnames_error = error;
-#endif
-
- /* do not load the metrics headers and tables if this is an Apple */
- /* sbit font file */
- if ( !is_apple_sbit )
- {
- /* load the `hhea' and `hmtx' tables */
- LOADM_( hhea, 0 );
- if ( !error )
- {
- LOADM_( hmtx, 0 );
- if ( FT_ERR_EQ( error, Table_Missing ) )
- {
- error = FT_THROW( Hmtx_Table_Missing );
-
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- /* If this is an incrementally loaded font and there are */
- /* overriding metrics, tolerate a missing `hmtx' table. */
- if ( face->root.internal->incremental_interface &&
- face->root.internal->incremental_interface->funcs->
- get_glyph_metrics )
- {
- face->horizontal.number_Of_HMetrics = 0;
- error = FT_Err_Ok;
- }
-#endif
- }
- }
- else if ( FT_ERR_EQ( error, Table_Missing ) )
- {
- /* No `hhea' table necessary for SFNT Mac fonts. */
- if ( face->format_tag == TTAG_true )
- {
- FT_TRACE2(( "This is an SFNT Mac font.\n" ));
-
- has_outline = 0;
- error = FT_Err_Ok;
- }
- else
- {
- error = FT_THROW( Horiz_Header_Missing );
-
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- /* If this is an incrementally loaded font and there are */
- /* overriding metrics, tolerate a missing `hhea' table. */
- if ( face->root.internal->incremental_interface &&
- face->root.internal->incremental_interface->funcs->
- get_glyph_metrics )
- {
- face->horizontal.number_Of_HMetrics = 0;
- error = FT_Err_Ok;
- }
-#endif
-
- }
- }
-
- if ( error )
- goto Exit;
-
- /* try to load the `vhea' and `vmtx' tables */
- LOADM_( hhea, 1 );
- if ( !error )
- {
- LOADM_( hmtx, 1 );
- if ( !error )
- face->vertical_info = 1;
- }
-
- if ( error && FT_ERR_NEQ( error, Table_Missing ) )
- goto Exit;
-
- LOAD_( os2 );
- if ( error )
- {
- /* we treat the table as missing if there are any errors */
- face->os2.version = 0xFFFFU;
- }
- }
-
- /* the optional tables */
-
- /* embedded bitmap support */
- /* TODO: Replace this clumsy check for all possible sbit tables */
- /* with something better (for example, by passing a parameter */
- /* to suppress 'sbix' loading). */
- if ( sfnt->load_eblc &&
- ( has_CBLC || has_EBLC || has_bloc || has_sbix ) )
- LOAD_( eblc );
-
- /* colored glyph support */
- if ( sfnt->load_cpal )
- {
- LOAD_( cpal );
- LOAD_( colr );
- }
-
- /* OpenType-SVG glyph support */
- if ( sfnt->load_svg )
- LOAD_( svg );
-
- /* consider the pclt, kerning, and gasp tables as optional */
- LOAD_( pclt );
- LOAD_( gasp );
- LOAD_( kern );
-
-#ifdef TT_CONFIG_OPTION_GPOS_KERNING
- LOAD_( gpos );
-#endif
-
- face->root.num_glyphs = face->max_profile.numGlyphs;
-
- /* Bit 8 of the `fsSelection' field in the `OS/2' table denotes */
- /* a WWS-only font face. `WWS' stands for `weight', width', and */
- /* `slope', a term used by Microsoft's Windows Presentation */
- /* Foundation (WPF). This flag has been introduced in version */
- /* 1.5 of the OpenType specification (May 2008). */
-
- face->root.family_name = NULL;
- face->root.style_name = NULL;
- if ( face->os2.version != 0xFFFFU && face->os2.fsSelection & 256 )
- {
- if ( !ignore_typographic_family )
- GET_NAME( TYPOGRAPHIC_FAMILY, &face->root.family_name );
- if ( !face->root.family_name )
- GET_NAME( FONT_FAMILY, &face->root.family_name );
-
- if ( !ignore_typographic_subfamily )
- GET_NAME( TYPOGRAPHIC_SUBFAMILY, &face->root.style_name );
- if ( !face->root.style_name )
- GET_NAME( FONT_SUBFAMILY, &face->root.style_name );
- }
- else
- {
- GET_NAME( WWS_FAMILY, &face->root.family_name );
- if ( !face->root.family_name && !ignore_typographic_family )
- GET_NAME( TYPOGRAPHIC_FAMILY, &face->root.family_name );
- if ( !face->root.family_name )
- GET_NAME( FONT_FAMILY, &face->root.family_name );
-
- GET_NAME( WWS_SUBFAMILY, &face->root.style_name );
- if ( !face->root.style_name && !ignore_typographic_subfamily )
- GET_NAME( TYPOGRAPHIC_SUBFAMILY, &face->root.style_name );
- if ( !face->root.style_name )
- GET_NAME( FONT_SUBFAMILY, &face->root.style_name );
- }
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- {
- FT_Memory memory = face->root.memory;
-
-
- if ( FT_STRDUP( face->non_var_style_name, face->root.style_name ) )
- goto Exit;
- }
-#endif
-
- /* now set up root fields */
- {
- FT_Face root = &face->root;
- FT_Long flags = root->face_flags;
-
-
- /**********************************************************************
- *
- * Compute face flags.
- */
- if ( face->sbit_table_type == TT_SBIT_TABLE_TYPE_CBLC ||
- face->sbit_table_type == TT_SBIT_TABLE_TYPE_SBIX ||
- face->colr ||
- face->svg )
- flags |= FT_FACE_FLAG_COLOR; /* color glyphs */
-
- if ( has_outline == TRUE )
- {
- /* by default (and for backward compatibility) we handle */
- /* fonts with an 'sbix' table as bitmap-only */
- if ( has_sbix )
- flags |= FT_FACE_FLAG_SBIX; /* with 'sbix' bitmaps */
- else
- flags |= FT_FACE_FLAG_SCALABLE; /* scalable outlines */
- }
-
- /* The sfnt driver only supports bitmap fonts natively, thus we */
- /* don't set FT_FACE_FLAG_HINTER. */
- flags |= FT_FACE_FLAG_SFNT | /* SFNT file format */
- FT_FACE_FLAG_HORIZONTAL; /* horizontal data */
-
-#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
- if ( !psnames_error &&
- face->postscript.FormatType != 0x00030000L )
- flags |= FT_FACE_FLAG_GLYPH_NAMES;
-#endif
-
- /* fixed width font? */
- if ( face->postscript.isFixedPitch )
- flags |= FT_FACE_FLAG_FIXED_WIDTH;
-
- /* vertical information? */
- if ( face->vertical_info )
- flags |= FT_FACE_FLAG_VERTICAL;
-
- /* kerning available ? */
- if ( TT_FACE_HAS_KERNING( face )
-#ifdef TT_CONFIG_OPTION_GPOS_KERNING
- || face->gpos_kerning_available
-#endif
- )
- flags |= FT_FACE_FLAG_KERNING;
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- /* Don't bother to load the tables unless somebody asks for them. */
- /* No need to do work which will (probably) not be used. */
- if ( face->variation_support & TT_FACE_FLAG_VAR_FVAR )
- flags |= FT_FACE_FLAG_MULTIPLE_MASTERS;
-#endif
-
- root->face_flags = flags;
-
- /**********************************************************************
- *
- * Compute style flags.
- */
-
- flags = 0;
- if ( has_outline == TRUE && face->os2.version != 0xFFFFU )
- {
- /* We have an OS/2 table; use the `fsSelection' field. Bit 9 */
- /* indicates an oblique font face. This flag has been */
- /* introduced in version 1.5 of the OpenType specification. */
-
- if ( face->os2.fsSelection & 512 ) /* bit 9 */
- flags |= FT_STYLE_FLAG_ITALIC;
- else if ( face->os2.fsSelection & 1 ) /* bit 0 */
- flags |= FT_STYLE_FLAG_ITALIC;
-
- if ( face->os2.fsSelection & 32 ) /* bit 5 */
- flags |= FT_STYLE_FLAG_BOLD;
- }
- else
- {
- /* this is an old Mac font, use the header field */
-
- if ( face->header.Mac_Style & 1 )
- flags |= FT_STYLE_FLAG_BOLD;
-
- if ( face->header.Mac_Style & 2 )
- flags |= FT_STYLE_FLAG_ITALIC;
- }
-
- root->style_flags |= flags;
-
- /**********************************************************************
- *
- * Polish the charmaps.
- *
- * Try to set the charmap encoding according to the platform &
- * encoding ID of each charmap. Emulate Unicode charmap if one
- * is missing.
- */
-
- tt_face_build_cmaps( face ); /* ignore errors */
-
-
- /* set the encoding fields */
- {
- FT_Int m;
-#ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
- FT_Bool has_unicode = FALSE;
-#endif
-
-
- for ( m = 0; m < root->num_charmaps; m++ )
- {
- FT_CharMap charmap = root->charmaps[m];
-
-
- charmap->encoding = sfnt_find_encoding( charmap->platform_id,
- charmap->encoding_id );
-
-#ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
-
- if ( charmap->encoding == FT_ENCODING_UNICODE ||
- charmap->encoding == FT_ENCODING_MS_SYMBOL ) /* PUA */
- has_unicode = TRUE;
- }
-
- /* synthesize Unicode charmap if one is missing */
- if ( !has_unicode &&
- root->face_flags & FT_FACE_FLAG_GLYPH_NAMES )
- {
- FT_CharMapRec cmaprec;
-
-
- cmaprec.face = root;
- cmaprec.platform_id = TT_PLATFORM_MICROSOFT;
- cmaprec.encoding_id = TT_MS_ID_UNICODE_CS;
- cmaprec.encoding = FT_ENCODING_UNICODE;
-
-
- error = FT_CMap_New( (FT_CMap_Class)&tt_cmap_unicode_class_rec,
- NULL, &cmaprec, NULL );
- if ( error &&
- FT_ERR_NEQ( error, No_Unicode_Glyph_Name ) &&
- FT_ERR_NEQ( error, Unimplemented_Feature ) )
- goto Exit;
- error = FT_Err_Ok;
-
-#endif /* FT_CONFIG_OPTION_POSTSCRIPT_NAMES */
-
- }
- }
-
-#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
-
- /*
- * Now allocate the root array of FT_Bitmap_Size records and
- * populate them. Unfortunately, it isn't possible to indicate bit
- * depths in the FT_Bitmap_Size record. This is a design error.
- */
- {
- FT_UInt count;
-
-
- count = face->sbit_num_strikes;
-
- if ( count > 0 )
- {
- FT_Memory memory = face->root.memory;
- FT_UShort em_size = face->header.Units_Per_EM;
- FT_Short avgwidth = face->os2.xAvgCharWidth;
- FT_Size_Metrics metrics;
-
- FT_UInt* sbit_strike_map = NULL;
- FT_UInt strike_idx, bsize_idx;
-
-
- if ( em_size == 0 || face->os2.version == 0xFFFFU )
- {
- avgwidth = 1;
- em_size = 1;
- }
-
- /* to avoid invalid strike data in the `available_sizes' field */
- /* of `FT_Face', we map `available_sizes' indices to strike */
- /* indices */
- if ( FT_NEW_ARRAY( root->available_sizes, count ) ||
- FT_QNEW_ARRAY( sbit_strike_map, count ) )
- goto Exit;
-
- bsize_idx = 0;
- for ( strike_idx = 0; strike_idx < count; strike_idx++ )
- {
- FT_Bitmap_Size* bsize = root->available_sizes + bsize_idx;
-
-
- error = sfnt->load_strike_metrics( face, strike_idx, &metrics );
- if ( error )
- continue;
-
- bsize->height = (FT_Short)( metrics.height >> 6 );
- bsize->width = (FT_Short)(
- ( avgwidth * metrics.x_ppem + em_size / 2 ) / em_size );
-
- bsize->x_ppem = metrics.x_ppem << 6;
- bsize->y_ppem = metrics.y_ppem << 6;
-
- /* assume 72dpi */
- bsize->size = metrics.y_ppem << 6;
-
- /* only use strikes with valid PPEM values */
- if ( bsize->x_ppem && bsize->y_ppem )
- sbit_strike_map[bsize_idx++] = strike_idx;
- }
-
- /* reduce array size to the actually used elements */
- FT_MEM_QRENEW_ARRAY( sbit_strike_map, count, bsize_idx );
-
- /* from now on, all strike indices are mapped */
- /* using `sbit_strike_map' */
- if ( bsize_idx )
- {
- face->sbit_strike_map = sbit_strike_map;
-
- root->face_flags |= FT_FACE_FLAG_FIXED_SIZES;
- root->num_fixed_sizes = (FT_Int)bsize_idx;
- }
- }
- }
-
-#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
-
- /* a font with no bitmaps and no outlines is scalable; */
- /* it has only empty glyphs then */
- if ( !FT_HAS_FIXED_SIZES( root ) && !FT_IS_SCALABLE( root ) )
- root->face_flags |= FT_FACE_FLAG_SCALABLE;
-
-
- /**********************************************************************
- *
- * Set up metrics.
- */
- if ( FT_IS_SCALABLE( root ) ||
- FT_HAS_SBIX( root ) )
- {
- /* XXX What about if outline header is missing */
- /* (e.g. sfnt wrapped bitmap)? */
- root->bbox.xMin = face->header.xMin;
- root->bbox.yMin = face->header.yMin;
- root->bbox.xMax = face->header.xMax;
- root->bbox.yMax = face->header.yMax;
- root->units_per_EM = face->header.Units_Per_EM;
-
-
- /*
- * Computing the ascender/descender/height is tricky.
- *
- * The OpenType specification v1.8.3 says:
- *
- * [OS/2's] sTypoAscender, sTypoDescender and sTypoLineGap fields
- * are intended to allow applications to lay out documents in a
- * typographically-correct and portable fashion.
- *
- * This is somewhat at odds with the decades of backwards
- * compatibility, operating systems and applications doing whatever
- * they want, not to mention broken fonts.
- *
- * Not all fonts have an OS/2 table; in this case, we take the values
- * in the horizontal header, although there is nothing stopping the
- * values from being unreliable. Even with a OS/2 table, certain fonts
- * set the sTypoAscender, sTypoDescender and sTypoLineGap fields to 0
- * and instead correctly set usWinAscent and usWinDescent.
- *
- * As an example, Arial Narrow is shipped as four files ARIALN.TTF,
- * ARIALNI.TTF, ARIALNB.TTF and ARIALNBI.TTF. Strangely, all fonts have
- * the same values in their sTypo* fields, except ARIALNB.ttf which
- * sets them to 0. All of them have different usWinAscent/Descent
- * values. The OS/2 table therefore cannot be trusted for computing the
- * text height reliably.
- *
- * As a compromise, do the following:
- *
- * 1. If the OS/2 table exists and the fsSelection bit 7 is set
- * (USE_TYPO_METRICS), trust the font and use the sTypo* metrics.
- * 2. Otherwise, use the `hhea' table's metrics.
- * 3. If they are zero and the OS/2 table exists,
- * 1. use the OS/2 table's sTypo* metrics if they are non-zero.
- * 2. Otherwise, use the OS/2 table's usWin* metrics.
- */
-
- if ( face->os2.version != 0xFFFFU && face->os2.fsSelection & 128 )
- {
- root->ascender = face->os2.sTypoAscender;
- root->descender = face->os2.sTypoDescender;
- root->height = root->ascender - root->descender +
- face->os2.sTypoLineGap;
- }
- else
- {
- root->ascender = face->horizontal.Ascender;
- root->descender = face->horizontal.Descender;
- root->height = root->ascender - root->descender +
- face->horizontal.Line_Gap;
-
- if ( !( root->ascender || root->descender ) )
- {
- if ( face->os2.version != 0xFFFFU )
- {
- if ( face->os2.sTypoAscender || face->os2.sTypoDescender )
- {
- root->ascender = face->os2.sTypoAscender;
- root->descender = face->os2.sTypoDescender;
- root->height = root->ascender - root->descender +
- face->os2.sTypoLineGap;
- }
- else
- {
- root->ascender = (FT_Short)face->os2.usWinAscent;
- root->descender = -(FT_Short)face->os2.usWinDescent;
- root->height = root->ascender - root->descender;
- }
- }
- }
- }
-
- root->max_advance_width =
- (FT_Short)face->horizontal.advance_Width_Max;
- root->max_advance_height =
- (FT_Short)( face->vertical_info ? face->vertical.advance_Height_Max
- : root->height );
-
- /* See https://www.microsoft.com/typography/otspec/post.htm -- */
- /* Adjust underline position from top edge to centre of */
- /* stroke to convert TrueType meaning to FreeType meaning. */
- root->underline_position = face->postscript.underlinePosition -
- face->postscript.underlineThickness / 2;
- root->underline_thickness = face->postscript.underlineThickness;
- }
-
- }
-
- Exit:
- FT_TRACE2(( "sfnt_load_face: done\n" ));
-
- return error;
- }
-
-
-#undef LOAD_
-#undef LOADM_
-#undef GET_NAME
-
-
- FT_LOCAL_DEF( void )
- sfnt_done_face( TT_Face face )
- {
- FT_Memory memory;
- SFNT_Service sfnt;
-
-
- if ( !face )
- return;
-
- memory = face->root.memory;
- sfnt = (SFNT_Service)face->sfnt;
-
- if ( sfnt )
- {
- /* destroy the postscript names table if it is loaded */
- if ( sfnt->free_psnames )
- sfnt->free_psnames( face );
-
- /* destroy the embedded bitmaps table if it is loaded */
- if ( sfnt->free_eblc )
- sfnt->free_eblc( face );
-
- /* destroy color table data if it is loaded */
- if ( sfnt->free_cpal )
- {
- sfnt->free_cpal( face );
- sfnt->free_colr( face );
- }
-
-#ifdef FT_CONFIG_OPTION_SVG
- /* free SVG data */
- if ( sfnt->free_svg )
- sfnt->free_svg( face );
-#endif
- }
-
-#ifdef TT_CONFIG_OPTION_BDF
- /* freeing the embedded BDF properties */
- tt_face_free_bdf_props( face );
-#endif
-
- /* freeing the kerning table */
- tt_face_done_kern( face );
-
-#ifdef TT_CONFIG_OPTION_GPOS_KERNING
- /* freeing the GPOS table */
- tt_face_done_gpos( face );
-#endif
-
- /* freeing the collection table */
- FT_FREE( face->ttc_header.offsets );
- face->ttc_header.count = 0;
-
- /* freeing table directory */
- FT_FREE( face->dir_tables );
- face->num_tables = 0;
-
- {
- FT_Stream stream = FT_FACE_STREAM( face );
-
-
- /* simply release the 'cmap' table frame */
- FT_FRAME_RELEASE( face->cmap_table );
- face->cmap_size = 0;
- }
-
- face->horz_metrics_size = 0;
- face->vert_metrics_size = 0;
-
- /* freeing vertical metrics, if any */
- if ( face->vertical_info )
- {
- FT_FREE( face->vertical.long_metrics );
- FT_FREE( face->vertical.short_metrics );
- face->vertical_info = 0;
- }
-
- /* freeing the gasp table */
- FT_FREE( face->gasp.gaspRanges );
- face->gasp.numRanges = 0;
-
- /* freeing the name table */
- if ( sfnt )
- sfnt->free_name( face );
-
- /* freeing family and style name */
- FT_FREE( face->root.family_name );
- FT_FREE( face->root.style_name );
-
- /* freeing sbit size table */
- FT_FREE( face->root.available_sizes );
- FT_FREE( face->sbit_strike_map );
- face->root.num_fixed_sizes = 0;
-
- FT_FREE( face->postscript_name );
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- FT_FREE( face->var_postscript_prefix );
- FT_FREE( face->non_var_style_name );
-#endif
-
- /* freeing glyph color palette data */
- FT_FREE( face->palette_data.palette_name_ids );
- FT_FREE( face->palette_data.palette_flags );
- FT_FREE( face->palette_data.palette_entry_name_ids );
- FT_FREE( face->palette );
-
- face->sfnt = NULL;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/sfnt/sfobjs.h b/contrib/libs/freetype/src/sfnt/sfobjs.h
deleted file mode 100644
index 90847d9573..0000000000
--- a/contrib/libs/freetype/src/sfnt/sfobjs.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/****************************************************************************
- *
- * sfobjs.h
- *
- * SFNT object management (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef SFOBJS_H_
-#define SFOBJS_H_
-
-
-#include <freetype/internal/sfnt.h>
-#include <freetype/internal/ftobjs.h>
-
-
-FT_BEGIN_HEADER
-
-
- FT_LOCAL( FT_Error )
- sfnt_init_face( FT_Stream stream,
- TT_Face face,
- FT_Int face_instance_index,
- FT_Int num_params,
- FT_Parameter* params );
-
- FT_LOCAL( FT_Error )
- sfnt_load_face( FT_Stream stream,
- TT_Face face,
- FT_Int face_instance_index,
- FT_Int num_params,
- FT_Parameter* params );
-
- FT_LOCAL( void )
- sfnt_done_face( TT_Face face );
-
- FT_LOCAL( FT_Error )
- tt_face_get_name( TT_Face face,
- FT_UShort nameid,
- FT_String** name );
-
-
-FT_END_HEADER
-
-#endif /* SFOBJS_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/sfnt/sfwoff.c b/contrib/libs/freetype/src/sfnt/sfwoff.c
deleted file mode 100644
index 14514bf957..0000000000
--- a/contrib/libs/freetype/src/sfnt/sfwoff.c
+++ /dev/null
@@ -1,426 +0,0 @@
-/****************************************************************************
- *
- * sfwoff.c
- *
- * WOFF format management (base).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include "sfwoff.h"
-#include <freetype/tttags.h>
-#include <freetype/internal/ftcalc.h>
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/ftgzip.h>
-
-
-#ifdef FT_CONFIG_OPTION_USE_ZLIB
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT sfwoff
-
-
-#define WRITE_USHORT( p, v ) \
- do \
- { \
- *(p)++ = (FT_Byte)( (v) >> 8 ); \
- *(p)++ = (FT_Byte)( (v) >> 0 ); \
- \
- } while ( 0 )
-
-#define WRITE_ULONG( p, v ) \
- do \
- { \
- *(p)++ = (FT_Byte)( (v) >> 24 ); \
- *(p)++ = (FT_Byte)( (v) >> 16 ); \
- *(p)++ = (FT_Byte)( (v) >> 8 ); \
- *(p)++ = (FT_Byte)( (v) >> 0 ); \
- \
- } while ( 0 )
-
-
- static void
- sfnt_stream_close( FT_Stream stream )
- {
- FT_Memory memory = stream->memory;
-
-
- FT_FREE( stream->base );
-
- stream->size = 0;
- stream->close = NULL;
- }
-
-
- FT_COMPARE_DEF( int )
- compare_offsets( const void* a,
- const void* b )
- {
- WOFF_Table table1 = *(WOFF_Table*)a;
- WOFF_Table table2 = *(WOFF_Table*)b;
-
- FT_ULong offset1 = table1->Offset;
- FT_ULong offset2 = table2->Offset;
-
-
- if ( offset1 > offset2 )
- return 1;
- else if ( offset1 < offset2 )
- return -1;
- else
- return 0;
- }
-
-
- /* Replace `face->root.stream' with a stream containing the extracted */
- /* SFNT of a WOFF font. */
-
- FT_LOCAL_DEF( FT_Error )
- woff_open_font( FT_Stream stream,
- TT_Face face )
- {
- FT_Memory memory = stream->memory;
- FT_Error error = FT_Err_Ok;
-
- WOFF_HeaderRec woff;
- WOFF_Table tables = NULL;
- WOFF_Table* indices = NULL;
-
- FT_ULong woff_offset;
-
- FT_Byte* sfnt = NULL;
- FT_Stream sfnt_stream = NULL;
-
- FT_Byte* sfnt_header;
- FT_ULong sfnt_offset;
-
- FT_Int nn;
- FT_Tag old_tag = 0;
-
- static const FT_Frame_Field woff_header_fields[] =
- {
-#undef FT_STRUCTURE
-#define FT_STRUCTURE WOFF_HeaderRec
-
- FT_FRAME_START( 44 ),
- FT_FRAME_ULONG ( signature ),
- FT_FRAME_ULONG ( flavor ),
- FT_FRAME_ULONG ( length ),
- FT_FRAME_USHORT( num_tables ),
- FT_FRAME_USHORT( reserved ),
- FT_FRAME_ULONG ( totalSfntSize ),
- FT_FRAME_USHORT( majorVersion ),
- FT_FRAME_USHORT( minorVersion ),
- FT_FRAME_ULONG ( metaOffset ),
- FT_FRAME_ULONG ( metaLength ),
- FT_FRAME_ULONG ( metaOrigLength ),
- FT_FRAME_ULONG ( privOffset ),
- FT_FRAME_ULONG ( privLength ),
- FT_FRAME_END
- };
-
-
- FT_ASSERT( stream == face->root.stream );
- FT_ASSERT( FT_STREAM_POS() == 0 );
-
- if ( FT_STREAM_READ_FIELDS( woff_header_fields, &woff ) )
- return error;
-
- /* Make sure we don't recurse back here or hit TTC code. */
- if ( woff.flavor == TTAG_wOFF || woff.flavor == TTAG_ttcf )
- return FT_THROW( Invalid_Table );
-
- /* Miscellaneous checks. */
- if ( woff.length != stream->size ||
- woff.num_tables == 0 ||
- woff.num_tables > 0xFFFU ||
- 44 + woff.num_tables * 20UL >= woff.length ||
- 12 + woff.num_tables * 16UL >= woff.totalSfntSize ||
- ( woff.totalSfntSize & 3 ) != 0 ||
- ( woff.metaOffset == 0 && ( woff.metaLength != 0 ||
- woff.metaOrigLength != 0 ) ) ||
- ( woff.metaLength != 0 && woff.metaOrigLength == 0 ) ||
- ( woff.privOffset == 0 && woff.privLength != 0 ) )
- {
- FT_ERROR(( "woff_font_open: invalid WOFF header\n" ));
- return FT_THROW( Invalid_Table );
- }
-
- /* Don't trust `totalSfntSize' before thorough checks. */
- if ( FT_QALLOC( sfnt, 12 ) || FT_NEW( sfnt_stream ) )
- goto Exit;
-
- sfnt_header = sfnt;
-
- /* Write sfnt header. */
- {
- FT_Int entrySelector = FT_MSB( woff.num_tables );
- FT_Int searchRange = ( 1 << entrySelector ) * 16;
- FT_Int rangeShift = woff.num_tables * 16 - searchRange;
-
-
- WRITE_ULONG ( sfnt_header, woff.flavor );
- WRITE_USHORT( sfnt_header, woff.num_tables );
- WRITE_USHORT( sfnt_header, searchRange );
- WRITE_USHORT( sfnt_header, entrySelector );
- WRITE_USHORT( sfnt_header, rangeShift );
- }
-
- /* While the entries in the sfnt header must be sorted by the */
- /* tag value, the tables themselves are not. We thus have to */
- /* sort them by offset and check that they don't overlap. */
-
- if ( FT_QNEW_ARRAY( tables, woff.num_tables ) ||
- FT_QNEW_ARRAY( indices, woff.num_tables ) )
- goto Exit;
-
- FT_TRACE2(( "\n" ));
- FT_TRACE2(( " tag offset compLen origLen checksum\n" ));
- FT_TRACE2(( " -------------------------------------------\n" ));
-
- if ( FT_FRAME_ENTER( 20L * woff.num_tables ) )
- goto Exit;
-
- for ( nn = 0; nn < woff.num_tables; nn++ )
- {
- WOFF_Table table = tables + nn;
-
- table->Tag = FT_GET_TAG4();
- table->Offset = FT_GET_ULONG();
- table->CompLength = FT_GET_ULONG();
- table->OrigLength = FT_GET_ULONG();
- table->CheckSum = FT_GET_ULONG();
-
- FT_TRACE2(( " %c%c%c%c %08lx %08lx %08lx %08lx\n",
- (FT_Char)( table->Tag >> 24 ),
- (FT_Char)( table->Tag >> 16 ),
- (FT_Char)( table->Tag >> 8 ),
- (FT_Char)( table->Tag ),
- table->Offset,
- table->CompLength,
- table->OrigLength,
- table->CheckSum ));
-
- if ( table->Tag <= old_tag )
- {
- FT_FRAME_EXIT();
-
- FT_ERROR(( "woff_font_open: table tags are not sorted\n" ));
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- old_tag = table->Tag;
- indices[nn] = table;
- }
-
- FT_FRAME_EXIT();
-
- /* Sort by offset. */
-
- ft_qsort( indices,
- woff.num_tables,
- sizeof ( WOFF_Table ),
- compare_offsets );
-
- /* Check offsets and lengths. */
-
- woff_offset = 44 + woff.num_tables * 20L;
- sfnt_offset = 12 + woff.num_tables * 16L;
-
- for ( nn = 0; nn < woff.num_tables; nn++ )
- {
- WOFF_Table table = indices[nn];
-
-
- if ( table->Offset != woff_offset ||
- table->CompLength > woff.length ||
- table->Offset > woff.length - table->CompLength ||
- table->OrigLength > woff.totalSfntSize ||
- sfnt_offset > woff.totalSfntSize - table->OrigLength ||
- table->CompLength > table->OrigLength )
- {
- FT_ERROR(( "woff_font_open: invalid table offsets\n" ));
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- table->OrigOffset = sfnt_offset;
-
- /* The offsets must be multiples of 4. */
- woff_offset += ( table->CompLength + 3 ) & ~3U;
- sfnt_offset += ( table->OrigLength + 3 ) & ~3U;
- }
-
- /*
- * Final checks!
- *
- * We don't decode and check the metadata block.
- * We don't check table checksums either.
- * But other than those, I think we implement all
- * `MUST' checks from the spec.
- */
-
- if ( woff.metaOffset )
- {
- if ( woff.metaOffset != woff_offset ||
- woff.metaOffset + woff.metaLength > woff.length )
- {
- FT_ERROR(( "woff_font_open:"
- " invalid `metadata' offset or length\n" ));
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- /* We have padding only ... */
- woff_offset += woff.metaLength;
- }
-
- if ( woff.privOffset )
- {
- /* ... if it isn't the last block. */
- woff_offset = ( woff_offset + 3 ) & ~3U;
-
- if ( woff.privOffset != woff_offset ||
- woff.privOffset + woff.privLength > woff.length )
- {
- FT_ERROR(( "woff_font_open: invalid `private' offset or length\n" ));
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- /* No padding for the last block. */
- woff_offset += woff.privLength;
- }
-
- if ( sfnt_offset != woff.totalSfntSize ||
- woff_offset != woff.length )
- {
- FT_ERROR(( "woff_font_open: invalid `sfnt' table structure\n" ));
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- /* Now use `totalSfntSize'. */
- if ( FT_QREALLOC( sfnt, 12, woff.totalSfntSize ) )
- goto Exit;
-
- sfnt_header = sfnt + 12;
-
- /* Write the tables. */
-
- for ( nn = 0; nn < woff.num_tables; nn++ )
- {
- WOFF_Table table = tables + nn;
-
-
- /* Write SFNT table entry. */
- WRITE_ULONG( sfnt_header, table->Tag );
- WRITE_ULONG( sfnt_header, table->CheckSum );
- WRITE_ULONG( sfnt_header, table->OrigOffset );
- WRITE_ULONG( sfnt_header, table->OrigLength );
-
- /* Write table data. */
- if ( FT_STREAM_SEEK( table->Offset ) ||
- FT_FRAME_ENTER( table->CompLength ) )
- goto Exit;
-
- if ( table->CompLength == table->OrigLength )
- {
- /* Uncompressed data; just copy. */
- ft_memcpy( sfnt + table->OrigOffset,
- stream->cursor,
- table->OrigLength );
- }
- else
- {
- /* Uncompress with zlib. */
- FT_ULong output_len = table->OrigLength;
-
-
- error = FT_Gzip_Uncompress( memory,
- sfnt + table->OrigOffset, &output_len,
- stream->cursor, table->CompLength );
- if ( error )
- goto Exit1;
- if ( output_len != table->OrigLength )
- {
- FT_ERROR(( "woff_font_open: compressed table length mismatch\n" ));
- error = FT_THROW( Invalid_Table );
- goto Exit1;
- }
- }
-
- FT_FRAME_EXIT();
-
- /* We don't check whether the padding bytes in the WOFF file are */
- /* actually '\0'. For the output, however, we do set them properly. */
- sfnt_offset = table->OrigOffset + table->OrigLength;
- while ( sfnt_offset & 3 )
- {
- sfnt[sfnt_offset] = '\0';
- sfnt_offset++;
- }
- }
-
- /* Ok! Finally ready. Swap out stream and return. */
- FT_Stream_OpenMemory( sfnt_stream, sfnt, woff.totalSfntSize );
- sfnt_stream->memory = stream->memory;
- sfnt_stream->close = sfnt_stream_close;
-
- FT_Stream_Free(
- face->root.stream,
- ( face->root.face_flags & FT_FACE_FLAG_EXTERNAL_STREAM ) != 0 );
-
- face->root.stream = sfnt_stream;
-
- face->root.face_flags &= ~FT_FACE_FLAG_EXTERNAL_STREAM;
-
- Exit:
- FT_FREE( tables );
- FT_FREE( indices );
-
- if ( error )
- {
- FT_FREE( sfnt );
- FT_Stream_Close( sfnt_stream );
- FT_FREE( sfnt_stream );
- }
-
- return error;
-
- Exit1:
- FT_FRAME_EXIT();
- goto Exit;
- }
-
-
-#undef WRITE_USHORT
-#undef WRITE_ULONG
-
-#else /* !FT_CONFIG_OPTION_USE_ZLIB */
-
- /* ANSI C doesn't like empty source files */
- typedef int sfwoff_dummy_;
-
-#endif /* !FT_CONFIG_OPTION_USE_ZLIB */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/sfnt/sfwoff.h b/contrib/libs/freetype/src/sfnt/sfwoff.h
deleted file mode 100644
index a04735ffe2..0000000000
--- a/contrib/libs/freetype/src/sfnt/sfwoff.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/****************************************************************************
- *
- * sfwoff.h
- *
- * WOFFF format management (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef SFWOFF_H_
-#define SFWOFF_H_
-
-
-#include <freetype/internal/sfnt.h>
-#include <freetype/internal/ftobjs.h>
-
-
-FT_BEGIN_HEADER
-
-#ifdef FT_CONFIG_OPTION_USE_ZLIB
-
- FT_LOCAL( FT_Error )
- woff_open_font( FT_Stream stream,
- TT_Face face );
-
-
-#endif
-
-FT_END_HEADER
-
-#endif /* SFWOFF_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/sfnt/sfwoff2.c b/contrib/libs/freetype/src/sfnt/sfwoff2.c
deleted file mode 100644
index 5ab40f8a6a..0000000000
--- a/contrib/libs/freetype/src/sfnt/sfwoff2.c
+++ /dev/null
@@ -1,2380 +0,0 @@
-/****************************************************************************
- *
- * sfwoff2.c
- *
- * WOFF2 format management (base).
- *
- * Copyright (C) 2019-2024 by
- * Nikhil Ramakrishnan, David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-#include "sfwoff2.h"
-#include "woff2tags.h"
-#include <freetype/tttags.h>
-#include <freetype/internal/ftcalc.h>
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftstream.h>
-
-
-#ifdef FT_CONFIG_OPTION_USE_BROTLI
-
-#error #include <brotli/decode.h>
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT sfwoff2
-
- /* An arbitrary, heuristic size limit (67MByte) for expanded WOFF2 data. */
-#define MAX_SFNT_SIZE ( 1 << 26 )
-
-#define READ_255USHORT( var ) FT_SET_ERROR( Read255UShort( stream, &var ) )
-
-#define READ_BASE128( var ) FT_SET_ERROR( ReadBase128( stream, &var ) )
-
- /* `var' should be FT_ULong */
-#define ROUND4( var ) ( ( var + 3 ) & ~3UL )
-
-#define WRITE_USHORT( p, v ) \
- do \
- { \
- *(p)++ = (FT_Byte)( (v) >> 8 ); \
- *(p)++ = (FT_Byte)( (v) >> 0 ); \
- \
- } while ( 0 )
-
-#define WRITE_ULONG( p, v ) \
- do \
- { \
- *(p)++ = (FT_Byte)( (v) >> 24 ); \
- *(p)++ = (FT_Byte)( (v) >> 16 ); \
- *(p)++ = (FT_Byte)( (v) >> 8 ); \
- *(p)++ = (FT_Byte)( (v) >> 0 ); \
- \
- } while ( 0 )
-
-#define WRITE_SHORT( p, v ) \
- do \
- { \
- *(p)++ = (FT_Byte)( (v) >> 8 ); \
- *(p)++ = (FT_Byte)( (v) >> 0 ); \
- \
- } while ( 0 )
-
-#define WRITE_SFNT_BUF( buf, s ) \
- write_buf( &sfnt, sfnt_size, &dest_offset, buf, s, memory )
-
-#define WRITE_SFNT_BUF_AT( offset, buf, s ) \
- write_buf( &sfnt, sfnt_size, &offset, buf, s, memory )
-
-#define N_CONTOUR_STREAM 0
-#define N_POINTS_STREAM 1
-#define FLAG_STREAM 2
-#define GLYPH_STREAM 3
-#define COMPOSITE_STREAM 4
-#define BBOX_STREAM 5
-#define INSTRUCTION_STREAM 6
-
-#define HAVE_OVERLAP_SIMPLE_BITMAP 0x1
-
-
- static void
- stream_close( FT_Stream stream )
- {
- FT_Memory memory = stream->memory;
-
-
- FT_FREE( stream->base );
-
- stream->size = 0;
- stream->close = NULL;
- }
-
-
- FT_COMPARE_DEF( int )
- compare_tags( const void* a,
- const void* b )
- {
- WOFF2_Table table1 = *(WOFF2_Table*)a;
- WOFF2_Table table2 = *(WOFF2_Table*)b;
-
- FT_Tag tag1 = table1->Tag;
- FT_Tag tag2 = table2->Tag;
-
-
- if ( tag1 > tag2 )
- return 1;
- else if ( tag1 < tag2 )
- return -1;
- else
- return 0;
- }
-
-
- static FT_Error
- Read255UShort( FT_Stream stream,
- FT_UShort* value )
- {
- const FT_Byte oneMoreByteCode1 = 255;
- const FT_Byte oneMoreByteCode2 = 254;
- const FT_Byte wordCode = 253;
- const FT_UShort lowestUCode = 253;
-
- FT_Error error = FT_Err_Ok;
- FT_Byte code;
- FT_Byte result_byte = 0;
- FT_UShort result_short = 0;
-
-
- if ( FT_READ_BYTE( code ) )
- return error;
- if ( code == wordCode )
- {
- /* Read next two bytes and store `FT_UShort' value. */
- if ( FT_READ_USHORT( result_short ) )
- return error;
- *value = result_short;
- return FT_Err_Ok;
- }
- else if ( code == oneMoreByteCode1 )
- {
- if ( FT_READ_BYTE( result_byte ) )
- return error;
- *value = result_byte + lowestUCode;
- return FT_Err_Ok;
- }
- else if ( code == oneMoreByteCode2 )
- {
- if ( FT_READ_BYTE( result_byte ) )
- return error;
- *value = result_byte + lowestUCode * 2;
- return FT_Err_Ok;
- }
- else
- {
- *value = code;
- return FT_Err_Ok;
- }
- }
-
-
- static FT_Error
- ReadBase128( FT_Stream stream,
- FT_ULong* value )
- {
- FT_ULong result = 0;
- FT_Int i;
- FT_Byte code;
- FT_Error error = FT_Err_Ok;
-
-
- for ( i = 0; i < 5; ++i )
- {
- code = 0;
- if ( FT_READ_BYTE( code ) )
- return error;
-
- /* Leading zeros are invalid. */
- if ( i == 0 && code == 0x80 )
- return FT_THROW( Invalid_Table );
-
- /* If any of top seven bits are set then we're about to overflow. */
- if ( result & 0xfe000000 )
- return FT_THROW( Invalid_Table );
-
- result = ( result << 7 ) | ( code & 0x7f );
-
- /* Spin until most significant bit of data byte is false. */
- if ( ( code & 0x80 ) == 0 )
- {
- *value = result;
- return FT_Err_Ok;
- }
- }
-
- /* Make sure not to exceed the size bound. */
- return FT_THROW( Invalid_Table );
- }
-
-
- /* Extend memory of `dst_bytes' buffer and copy data from `src'. */
- static FT_Error
- write_buf( FT_Byte** dst_bytes,
- FT_ULong* dst_size,
- FT_ULong* offset,
- FT_Byte* src,
- FT_ULong size,
- FT_Memory memory )
- {
- FT_Error error = FT_Err_Ok;
- /* We are reallocating memory for `dst', so its pointer may change. */
- FT_Byte* dst = *dst_bytes;
-
-
- /* Check whether we are within limits. */
- if ( ( *offset + size ) > WOFF2_DEFAULT_MAX_SIZE )
- return FT_THROW( Array_Too_Large );
-
- /* Reallocate `dst'. */
- if ( ( *offset + size ) > *dst_size )
- {
- FT_TRACE6(( "Reallocating %lu to %lu.\n",
- *dst_size, (*offset + size) ));
- if ( FT_QREALLOC( dst,
- (FT_ULong)( *dst_size ),
- (FT_ULong)( *offset + size ) ) )
- goto Exit;
-
- *dst_size = *offset + size;
- }
-
- /* Copy data. */
- ft_memcpy( dst + *offset, src, size );
-
- *offset += size;
- /* Set pointer of `dst' to its correct value. */
- *dst_bytes = dst;
-
- Exit:
- return error;
- }
-
-
- /* Pad buffer to closest multiple of 4. */
- static FT_Error
- pad4( FT_Byte** sfnt_bytes,
- FT_ULong* sfnt_size,
- FT_ULong* out_offset,
- FT_Memory memory )
- {
- FT_Byte* sfnt = *sfnt_bytes;
- FT_ULong dest_offset = *out_offset;
-
- FT_Byte zeroes[] = { 0, 0, 0 };
- FT_ULong pad_bytes;
-
-
- if ( dest_offset + 3 < dest_offset )
- return FT_THROW( Invalid_Table );
-
- pad_bytes = ROUND4( dest_offset ) - dest_offset;
- if ( pad_bytes > 0 )
- {
- if ( WRITE_SFNT_BUF( &zeroes[0], pad_bytes ) )
- return FT_THROW( Invalid_Table );
- }
-
- *sfnt_bytes = sfnt;
- *out_offset = dest_offset;
- return FT_Err_Ok;
- }
-
-
- /* Calculate table checksum of `buf'. */
- static FT_ULong
- compute_ULong_sum( FT_Byte* buf,
- FT_ULong size )
- {
- FT_ULong checksum = 0;
- FT_ULong aligned_size = size & ~3UL;
- FT_ULong i;
- FT_Int shift;
-
-
- for ( i = 0; i < aligned_size; i += 4 )
- checksum += FT_NEXT_ULONG( buf );
-
- /* remaining bytes can be shifted and added one at a time */
- for ( shift = 24; i < size; i++, shift -= 8 )
- checksum += (FT_UInt32)FT_NEXT_BYTE( buf ) << shift;
-
- return checksum;
- }
-
-
- static FT_Error
- woff2_decompress( FT_Byte* dst,
- FT_ULong dst_size,
- const FT_Byte* src,
- FT_ULong src_size )
- {
- /* this cast is only of importance on 32bit systems; */
- /* we don't validate it */
- FT_Offset uncompressed_size = (FT_Offset)dst_size;
- BrotliDecoderResult result;
-
-
- result = BrotliDecoderDecompress( src_size,
- src,
- &uncompressed_size,
- dst );
-
- if ( result != BROTLI_DECODER_RESULT_SUCCESS ||
- uncompressed_size != dst_size )
- {
- FT_ERROR(( "woff2_decompress: Stream length mismatch.\n" ));
- return FT_THROW( Invalid_Table );
- }
-
- FT_TRACE2(( "woff2_decompress: Brotli stream decompressed.\n" ));
- return FT_Err_Ok;
- }
-
-
- static WOFF2_Table
- find_table( WOFF2_Table* tables,
- FT_UShort num_tables,
- FT_Tag tag )
- {
- FT_Int i;
-
-
- for ( i = 0; i < num_tables; i++ )
- {
- if ( tables[i]->Tag == tag )
- return tables[i];
- }
- return NULL;
- }
-
-
- /* Read `numberOfHMetrics' field from `hhea' table. */
- static FT_Error
- read_num_hmetrics( FT_Stream stream,
- FT_UShort* num_hmetrics )
- {
- FT_Error error = FT_Err_Ok;
- FT_UShort num_metrics;
-
-
- if ( FT_STREAM_SKIP( 34 ) )
- return FT_THROW( Invalid_Table );
-
- if ( FT_READ_USHORT( num_metrics ) )
- return FT_THROW( Invalid_Table );
-
- *num_hmetrics = num_metrics;
-
- return error;
- }
-
-
- /* An auxiliary function for overflow-safe addition. */
- static FT_Int
- with_sign( FT_Byte flag,
- FT_Int base_val )
- {
- /* Precondition: 0 <= base_val < 65536 (to avoid overflow). */
- return ( flag & 1 ) ? base_val : -base_val;
- }
-
-
- /* An auxiliary function for overflow-safe addition. */
- static FT_Int
- safe_int_addition( FT_Int a,
- FT_Int b,
- FT_Int* result )
- {
- if ( ( ( a > 0 ) && ( b > FT_INT_MAX - a ) ) ||
- ( ( a < 0 ) && ( b < FT_INT_MIN - a ) ) )
- return FT_THROW( Invalid_Table );
-
- *result = a + b;
- return FT_Err_Ok;
- }
-
-
- /*
- * Decode variable-length (flag, xCoordinate, yCoordinate) triplet for a
- * simple glyph. See
- *
- * https://www.w3.org/TR/WOFF2/#triplet_decoding
- */
- static FT_Error
- triplet_decode( const FT_Byte* flags_in,
- const FT_Byte* in,
- FT_ULong in_size,
- FT_ULong n_points,
- WOFF2_Point result,
- FT_ULong* in_bytes_used )
- {
- FT_Int x = 0;
- FT_Int y = 0;
- FT_Int dx;
- FT_Int dy;
- FT_Int b0, b1, b2;
-
- FT_ULong triplet_index = 0;
- FT_ULong data_bytes;
-
- FT_UInt i;
-
-
- if ( n_points > in_size )
- return FT_THROW( Invalid_Table );
-
- for ( i = 0; i < n_points; ++i )
- {
- FT_Byte flag = flags_in[i];
- FT_Bool on_curve = !( flag >> 7 );
-
-
- flag &= 0x7f;
- if ( flag < 84 )
- data_bytes = 1;
- else if ( flag < 120 )
- data_bytes = 2;
- else if ( flag < 124 )
- data_bytes = 3;
- else
- data_bytes = 4;
-
- /* Overflow checks */
- if ( triplet_index + data_bytes > in_size ||
- triplet_index + data_bytes < triplet_index )
- return FT_THROW( Invalid_Table );
-
- if ( flag < 10 )
- {
- dx = 0;
- dy = with_sign( flag,
- ( ( flag & 14 ) << 7 ) + in[triplet_index] );
- }
- else if ( flag < 20 )
- {
- dx = with_sign( flag,
- ( ( ( flag - 10 ) & 14 ) << 7 ) +
- in[triplet_index] );
- dy = 0;
- }
- else if ( flag < 84 )
- {
- b0 = flag - 20;
- b1 = in[triplet_index];
- dx = with_sign( flag,
- 1 + ( b0 & 0x30 ) + ( b1 >> 4 ) );
- dy = with_sign( flag >> 1,
- 1 + ( ( b0 & 0x0c ) << 2 ) + ( b1 & 0x0f ) );
- }
- else if ( flag < 120 )
- {
- b0 = flag - 84;
- dx = with_sign( flag,
- 1 + ( ( b0 / 12 ) << 8 ) + in[triplet_index] );
- dy = with_sign( flag >> 1,
- 1 + ( ( ( b0 % 12 ) >> 2 ) << 8 ) +
- in[triplet_index + 1] );
- }
- else if ( flag < 124 )
- {
- b2 = in[triplet_index + 1];
- dx = with_sign( flag,
- ( in[triplet_index] << 4 ) + ( b2 >> 4 ) );
- dy = with_sign( flag >> 1,
- ( ( b2 & 0x0f ) << 8 ) + in[triplet_index + 2] );
- }
- else
- {
- dx = with_sign( flag,
- ( in[triplet_index] << 8 ) +
- in[triplet_index + 1] );
- dy = with_sign( flag >> 1,
- ( in[triplet_index + 2] << 8 ) +
- in[triplet_index + 3] );
- }
-
- triplet_index += data_bytes;
-
- if ( safe_int_addition( x, dx, &x ) )
- return FT_THROW( Invalid_Table );
-
- if ( safe_int_addition( y, dy, &y ) )
- return FT_THROW( Invalid_Table );
-
- result[i].x = x;
- result[i].y = y;
- result[i].on_curve = on_curve;
- }
-
- *in_bytes_used = triplet_index;
- return FT_Err_Ok;
- }
-
-
- /* Store decoded points in glyph buffer. */
- static FT_Error
- store_points( FT_ULong n_points,
- const WOFF2_Point points,
- FT_UShort n_contours,
- FT_UShort instruction_len,
- FT_Bool have_overlap,
- FT_Byte* dst,
- FT_ULong dst_size,
- FT_ULong* glyph_size )
- {
- FT_UInt flag_offset = 10 + ( 2 * n_contours ) + 2 + instruction_len;
- FT_Byte last_flag = 0xFFU;
- FT_Byte repeat_count = 0;
- FT_Int last_x = 0;
- FT_Int last_y = 0;
- FT_UInt x_bytes = 0;
- FT_UInt y_bytes = 0;
- FT_UInt xy_bytes;
- FT_UInt i;
- FT_UInt x_offset;
- FT_UInt y_offset;
- FT_Byte* pointer;
-
-
- for ( i = 0; i < n_points; ++i )
- {
- const WOFF2_PointRec point = points[i];
-
- FT_Byte flag = point.on_curve ? GLYF_ON_CURVE : 0;
- FT_Int dx = point.x - last_x;
- FT_Int dy = point.y - last_y;
-
-
- if ( i == 0 && have_overlap )
- flag |= GLYF_OVERLAP_SIMPLE;
-
- if ( dx == 0 )
- flag |= GLYF_THIS_X_IS_SAME;
- else if ( dx > -256 && dx < 256 )
- {
- flag |= GLYF_X_SHORT | ( dx > 0 ? GLYF_THIS_X_IS_SAME : 0 );
- x_bytes += 1;
- }
- else
- x_bytes += 2;
-
- if ( dy == 0 )
- flag |= GLYF_THIS_Y_IS_SAME;
- else if ( dy > -256 && dy < 256 )
- {
- flag |= GLYF_Y_SHORT | ( dy > 0 ? GLYF_THIS_Y_IS_SAME : 0 );
- y_bytes += 1;
- }
- else
- y_bytes += 2;
-
- if ( flag == last_flag && repeat_count != 255 )
- {
- dst[flag_offset - 1] |= GLYF_REPEAT;
- repeat_count++;
- }
- else
- {
- if ( repeat_count != 0 )
- {
- if ( flag_offset >= dst_size )
- return FT_THROW( Invalid_Table );
-
- dst[flag_offset++] = repeat_count;
- }
- if ( flag_offset >= dst_size )
- return FT_THROW( Invalid_Table );
-
- dst[flag_offset++] = flag;
- repeat_count = 0;
- }
-
- last_x = point.x;
- last_y = point.y;
- last_flag = flag;
- }
-
- if ( repeat_count != 0 )
- {
- if ( flag_offset >= dst_size )
- return FT_THROW( Invalid_Table );
-
- dst[flag_offset++] = repeat_count;
- }
-
- xy_bytes = x_bytes + y_bytes;
- if ( xy_bytes < x_bytes ||
- flag_offset + xy_bytes < flag_offset ||
- flag_offset + xy_bytes > dst_size )
- return FT_THROW( Invalid_Table );
-
- x_offset = flag_offset;
- y_offset = flag_offset + x_bytes;
- last_x = 0;
- last_y = 0;
-
- for ( i = 0; i < n_points; ++i )
- {
- FT_Int dx = points[i].x - last_x;
- FT_Int dy = points[i].y - last_y;
-
-
- if ( dx == 0 )
- ;
- else if ( dx > -256 && dx < 256 )
- dst[x_offset++] = (FT_Byte)FT_ABS( dx );
- else
- {
- pointer = dst + x_offset;
- WRITE_SHORT( pointer, dx );
- x_offset += 2;
- }
-
- last_x += dx;
-
- if ( dy == 0 )
- ;
- else if ( dy > -256 && dy < 256 )
- dst[y_offset++] = (FT_Byte)FT_ABS( dy );
- else
- {
- pointer = dst + y_offset;
- WRITE_SHORT( pointer, dy );
- y_offset += 2;
- }
-
- last_y += dy;
- }
-
- *glyph_size = y_offset;
- return FT_Err_Ok;
- }
-
-
- static void
- compute_bbox( FT_ULong n_points,
- const WOFF2_Point points,
- FT_Byte* dst,
- FT_UShort* src_x_min )
- {
- FT_Int x_min = 0;
- FT_Int y_min = 0;
- FT_Int x_max = 0;
- FT_Int y_max = 0;
-
- FT_UInt i;
-
- FT_ULong offset;
- FT_Byte* pointer;
-
-
- if ( n_points > 0 )
- {
- x_min = points[0].x;
- y_min = points[0].y;
- x_max = points[0].x;
- y_max = points[0].y;
- }
-
- for ( i = 1; i < n_points; ++i )
- {
- FT_Int x = points[i].x;
- FT_Int y = points[i].y;
-
-
- x_min = FT_MIN( x, x_min );
- y_min = FT_MIN( y, y_min );
- x_max = FT_MAX( x, x_max );
- y_max = FT_MAX( y, y_max );
- }
-
- /* Write values to `glyf' record. */
- offset = 2;
- pointer = dst + offset;
-
- WRITE_SHORT( pointer, x_min );
- WRITE_SHORT( pointer, y_min );
- WRITE_SHORT( pointer, x_max );
- WRITE_SHORT( pointer, y_max );
-
- *src_x_min = (FT_UShort)x_min;
- }
-
-
- static FT_Error
- compositeGlyph_size( FT_Stream stream,
- FT_ULong offset,
- FT_ULong* size,
- FT_Bool* have_instructions )
- {
- FT_Error error = FT_Err_Ok;
- FT_ULong start_offset = offset;
- FT_Bool we_have_inst = FALSE;
- FT_UShort flags = FLAG_MORE_COMPONENTS;
-
-
- if ( FT_STREAM_SEEK( start_offset ) )
- goto Exit;
- while ( flags & FLAG_MORE_COMPONENTS )
- {
- FT_ULong arg_size;
-
-
- if ( FT_READ_USHORT( flags ) )
- goto Exit;
- we_have_inst |= ( flags & FLAG_WE_HAVE_INSTRUCTIONS ) != 0;
- /* glyph index */
- arg_size = 2;
- if ( flags & FLAG_ARG_1_AND_2_ARE_WORDS )
- arg_size += 4;
- else
- arg_size += 2;
-
- if ( flags & FLAG_WE_HAVE_A_SCALE )
- arg_size += 2;
- else if ( flags & FLAG_WE_HAVE_AN_X_AND_Y_SCALE )
- arg_size += 4;
- else if ( flags & FLAG_WE_HAVE_A_TWO_BY_TWO )
- arg_size += 8;
-
- if ( FT_STREAM_SKIP( arg_size ) )
- goto Exit;
- }
-
- *size = FT_STREAM_POS() - start_offset;
- *have_instructions = we_have_inst;
-
- Exit:
- return error;
- }
-
-
- /* Store loca values (provided by `reconstruct_glyf') to output stream. */
- static FT_Error
- store_loca( FT_ULong* loca_values,
- FT_ULong loca_values_size,
- FT_UShort index_format,
- FT_ULong* checksum,
- FT_Byte** sfnt_bytes,
- FT_ULong* sfnt_size,
- FT_ULong* out_offset,
- FT_Memory memory )
- {
- FT_Error error = FT_Err_Ok;
- FT_Byte* sfnt = *sfnt_bytes;
- FT_ULong dest_offset = *out_offset;
-
- FT_Byte* loca_buf = NULL;
- FT_Byte* dst = NULL;
-
- FT_UInt i = 0;
- FT_ULong loca_buf_size;
-
- const FT_ULong offset_size = index_format ? 4 : 2;
-
-
- if ( ( loca_values_size << 2 ) >> 2 != loca_values_size )
- goto Fail;
-
- loca_buf_size = loca_values_size * offset_size;
- if ( FT_QALLOC( loca_buf, loca_buf_size ) )
- goto Fail;
-
- dst = loca_buf;
- for ( i = 0; i < loca_values_size; i++ )
- {
- FT_ULong value = loca_values[i];
-
-
- if ( index_format )
- WRITE_ULONG( dst, value );
- else
- WRITE_USHORT( dst, ( value >> 1 ) );
- }
-
- *checksum = compute_ULong_sum( loca_buf, loca_buf_size );
- /* Write `loca' table to sfnt buffer. */
- if ( WRITE_SFNT_BUF( loca_buf, loca_buf_size ) )
- goto Fail;
-
- /* Set pointer `sfnt_bytes' to its correct value. */
- *sfnt_bytes = sfnt;
- *out_offset = dest_offset;
-
- FT_FREE( loca_buf );
- return error;
-
- Fail:
- if ( !error )
- error = FT_THROW( Invalid_Table );
-
- FT_FREE( loca_buf );
-
- return error;
- }
-
-
- static FT_Error
- reconstruct_glyf( FT_Stream stream,
- FT_ULong* glyf_checksum,
- FT_ULong* loca_checksum,
- FT_Byte** sfnt_bytes,
- FT_ULong* sfnt_size,
- FT_ULong* out_offset,
- WOFF2_Info info,
- FT_Memory memory )
- {
- FT_Error error = FT_Err_Ok;
- FT_Byte* sfnt = *sfnt_bytes;
-
- /* current position in stream */
- const FT_ULong pos = FT_STREAM_POS();
-
- FT_UInt num_substreams = 7;
-
- FT_UShort option_flags;
- FT_UShort num_glyphs;
- FT_UShort index_format;
- FT_ULong expected_loca_length;
- FT_UInt offset;
- FT_UInt i;
- FT_ULong points_size;
- FT_ULong glyph_buf_size;
- FT_ULong bbox_bitmap_offset;
- FT_ULong bbox_bitmap_length;
- FT_ULong overlap_bitmap_offset = 0;
- FT_ULong overlap_bitmap_length = 0;
-
- const FT_ULong glyf_start = *out_offset;
- FT_ULong dest_offset = *out_offset;
-
- WOFF2_Substream substreams = NULL;
-
- FT_ULong* loca_values = NULL;
- FT_UShort* n_points_arr = NULL;
- FT_Byte* glyph_buf = NULL;
- WOFF2_Point points = NULL;
-
-
- if ( FT_QNEW_ARRAY( substreams, num_substreams ) )
- goto Fail;
-
- if ( FT_STREAM_SKIP( 2 ) )
- goto Fail;
- if ( FT_READ_USHORT( option_flags ) )
- goto Fail;
- if ( FT_READ_USHORT( num_glyphs ) )
- goto Fail;
- if ( FT_READ_USHORT( index_format ) )
- goto Fail;
-
- FT_TRACE4(( "option_flags = %u; num_glyphs = %u; index_format = %u\n",
- option_flags, num_glyphs, index_format ));
-
- info->num_glyphs = num_glyphs;
-
- /* Calculate expected length of loca and compare. */
- /* See https://www.w3.org/TR/WOFF2/#conform-mustRejectLoca */
- /* index_format = 0 => Short version `loca'. */
- /* index_format = 1 => Long version `loca'. */
- expected_loca_length = ( index_format ? 4 : 2 ) *
- ( (FT_ULong)num_glyphs + 1 );
- if ( info->loca_table->dst_length != expected_loca_length )
- goto Fail;
-
- offset = 2 + 2 + 2 + 2 + ( num_substreams * 4 );
- if ( offset > info->glyf_table->TransformLength )
- goto Fail;
-
- for ( i = 0; i < num_substreams; ++i )
- {
- FT_ULong substream_size;
-
-
- if ( FT_READ_ULONG( substream_size ) )
- goto Fail;
- if ( substream_size > info->glyf_table->TransformLength - offset )
- goto Fail;
-
- substreams[i].start = pos + offset;
- substreams[i].offset = pos + offset;
- substreams[i].size = substream_size;
-
- FT_TRACE5(( " Substream %d: offset = %lu; size = %lu;\n",
- i, substreams[i].offset, substreams[i].size ));
- offset += substream_size;
- }
-
- if ( option_flags & HAVE_OVERLAP_SIMPLE_BITMAP )
- {
- /* Size of overlapBitmap = floor((numGlyphs + 7) / 8) */
- overlap_bitmap_length = ( num_glyphs + 7U ) >> 3;
- if ( overlap_bitmap_length > info->glyf_table->TransformLength - offset )
- goto Fail;
-
- overlap_bitmap_offset = pos + offset;
-
- FT_TRACE5(( " Overlap bitmap: offset = %lu; size = %lu;\n",
- overlap_bitmap_offset, overlap_bitmap_length ));
- offset += overlap_bitmap_length;
- }
-
- if ( FT_QNEW_ARRAY( loca_values, num_glyphs + 1 ) )
- goto Fail;
-
- points_size = 0;
- bbox_bitmap_offset = substreams[BBOX_STREAM].offset;
-
- /* Size of bboxBitmap = 4 * floor((numGlyphs + 31) / 32) */
- bbox_bitmap_length = ( ( num_glyphs + 31U ) >> 5 ) << 2;
- /* bboxStreamSize is the combined size of bboxBitmap and bboxStream. */
- substreams[BBOX_STREAM].offset += bbox_bitmap_length;
-
- glyph_buf_size = WOFF2_DEFAULT_GLYPH_BUF;
- if ( FT_QALLOC( glyph_buf, glyph_buf_size ) )
- goto Fail;
-
- if ( FT_QNEW_ARRAY( info->x_mins, num_glyphs ) )
- goto Fail;
-
- for ( i = 0; i < num_glyphs; ++i )
- {
- FT_ULong glyph_size = 0;
- FT_UShort n_contours = 0;
- FT_Bool have_bbox = FALSE;
- FT_Byte bbox_bitmap;
- FT_ULong bbox_offset;
- FT_UShort x_min = 0;
-
-
- /* Set `have_bbox'. */
- bbox_offset = bbox_bitmap_offset + ( i >> 3 );
- if ( FT_STREAM_SEEK( bbox_offset ) ||
- FT_READ_BYTE( bbox_bitmap ) )
- goto Fail;
- if ( bbox_bitmap & ( 0x80 >> ( i & 7 ) ) )
- have_bbox = TRUE;
-
- /* Read value from `nContourStream'. */
- if ( FT_STREAM_SEEK( substreams[N_CONTOUR_STREAM].offset ) ||
- FT_READ_USHORT( n_contours ) )
- goto Fail;
- substreams[N_CONTOUR_STREAM].offset += 2;
-
- if ( n_contours == 0xffff )
- {
- /* composite glyph */
- FT_Bool have_instructions = FALSE;
- FT_UShort instruction_size = 0;
- FT_ULong composite_size = 0;
- FT_ULong size_needed;
- FT_Byte* pointer = NULL;
-
-
- /* Composite glyphs must have explicit bbox. */
- if ( !have_bbox )
- goto Fail;
-
- if ( compositeGlyph_size( stream,
- substreams[COMPOSITE_STREAM].offset,
- &composite_size,
- &have_instructions) )
- goto Fail;
-
- if ( have_instructions )
- {
- if ( FT_STREAM_SEEK( substreams[GLYPH_STREAM].offset ) ||
- READ_255USHORT( instruction_size ) )
- goto Fail;
- substreams[GLYPH_STREAM].offset = FT_STREAM_POS();
- }
-
- size_needed = 12 + composite_size + instruction_size;
- if ( glyph_buf_size < size_needed )
- {
- if ( FT_QREALLOC( glyph_buf, glyph_buf_size, size_needed ) )
- goto Fail;
- glyph_buf_size = size_needed;
- }
-
- pointer = glyph_buf + glyph_size;
- WRITE_USHORT( pointer, n_contours );
- glyph_size += 2;
-
- /* Read x_min for current glyph. */
- if ( FT_STREAM_SEEK( substreams[BBOX_STREAM].offset ) ||
- FT_READ_USHORT( x_min ) )
- goto Fail;
- /* No increment here because we read again. */
-
- if ( FT_STREAM_SEEK( substreams[BBOX_STREAM].offset ) ||
- FT_STREAM_READ( glyph_buf + glyph_size, 8 ) )
- goto Fail;
-
- substreams[BBOX_STREAM].offset += 8;
- glyph_size += 8;
-
- if ( FT_STREAM_SEEK( substreams[COMPOSITE_STREAM].offset ) ||
- FT_STREAM_READ( glyph_buf + glyph_size, composite_size ) )
- goto Fail;
-
- substreams[COMPOSITE_STREAM].offset += composite_size;
- glyph_size += composite_size;
-
- if ( have_instructions )
- {
- pointer = glyph_buf + glyph_size;
- WRITE_USHORT( pointer, instruction_size );
- glyph_size += 2;
-
- if ( FT_STREAM_SEEK( substreams[INSTRUCTION_STREAM].offset ) ||
- FT_STREAM_READ( glyph_buf + glyph_size, instruction_size ) )
- goto Fail;
-
- substreams[INSTRUCTION_STREAM].offset += instruction_size;
- glyph_size += instruction_size;
- }
- }
- else if ( n_contours > 0 )
- {
- /* simple glyph */
- FT_ULong total_n_points = 0;
- FT_UShort n_points_contour;
- FT_UInt j;
- FT_ULong flag_size;
- FT_ULong triplet_size;
- FT_ULong triplet_bytes_used;
- FT_Bool have_overlap = FALSE;
- FT_Byte overlap_bitmap;
- FT_ULong overlap_offset;
- FT_Byte* flags_buf = NULL;
- FT_Byte* triplet_buf = NULL;
- FT_UShort instruction_size;
- FT_ULong size_needed;
- FT_Int end_point;
- FT_UInt contour_ix;
-
- FT_Byte* pointer = NULL;
-
-
- /* Set `have_overlap`. */
- if ( overlap_bitmap_offset )
- {
- overlap_offset = overlap_bitmap_offset + ( i >> 3 );
- if ( FT_STREAM_SEEK( overlap_offset ) ||
- FT_READ_BYTE( overlap_bitmap ) )
- goto Fail;
- if ( overlap_bitmap & ( 0x80 >> ( i & 7 ) ) )
- have_overlap = TRUE;
- }
-
- if ( FT_QNEW_ARRAY( n_points_arr, n_contours ) )
- goto Fail;
-
- if ( FT_STREAM_SEEK( substreams[N_POINTS_STREAM].offset ) )
- goto Fail;
-
- for ( j = 0; j < n_contours; ++j )
- {
- if ( READ_255USHORT( n_points_contour ) )
- goto Fail;
- n_points_arr[j] = n_points_contour;
- /* Prevent negative/overflow. */
- if ( total_n_points + n_points_contour < total_n_points )
- goto Fail;
- total_n_points += n_points_contour;
- }
- substreams[N_POINTS_STREAM].offset = FT_STREAM_POS();
-
- flag_size = total_n_points;
- if ( flag_size > substreams[FLAG_STREAM].size )
- goto Fail;
-
- flags_buf = stream->base + substreams[FLAG_STREAM].offset;
- triplet_buf = stream->base + substreams[GLYPH_STREAM].offset;
-
- if ( substreams[GLYPH_STREAM].size <
- ( substreams[GLYPH_STREAM].offset -
- substreams[GLYPH_STREAM].start ) )
- goto Fail;
-
- triplet_size = substreams[GLYPH_STREAM].size -
- ( substreams[GLYPH_STREAM].offset -
- substreams[GLYPH_STREAM].start );
- triplet_bytes_used = 0;
-
- /* Create array to store point information. */
- points_size = total_n_points;
- if ( FT_QNEW_ARRAY( points, points_size ) )
- goto Fail;
-
- if ( triplet_decode( flags_buf,
- triplet_buf,
- triplet_size,
- total_n_points,
- points,
- &triplet_bytes_used ) )
- goto Fail;
-
- substreams[FLAG_STREAM].offset += flag_size;
- substreams[GLYPH_STREAM].offset += triplet_bytes_used;
-
- if ( FT_STREAM_SEEK( substreams[GLYPH_STREAM].offset ) ||
- READ_255USHORT( instruction_size ) )
- goto Fail;
-
- substreams[GLYPH_STREAM].offset = FT_STREAM_POS();
-
- if ( total_n_points >= ( 1 << 27 ) )
- goto Fail;
-
- size_needed = 12 +
- ( 2 * n_contours ) +
- ( 5 * total_n_points ) +
- instruction_size;
- if ( glyph_buf_size < size_needed )
- {
- if ( FT_QREALLOC( glyph_buf, glyph_buf_size, size_needed ) )
- goto Fail;
- glyph_buf_size = size_needed;
- }
-
- pointer = glyph_buf + glyph_size;
- WRITE_USHORT( pointer, n_contours );
- glyph_size += 2;
-
- if ( have_bbox )
- {
- /* Read x_min for current glyph. */
- if ( FT_STREAM_SEEK( substreams[BBOX_STREAM].offset ) ||
- FT_READ_USHORT( x_min ) )
- goto Fail;
- /* No increment here because we read again. */
-
- if ( FT_STREAM_SEEK( substreams[BBOX_STREAM].offset ) ||
- FT_STREAM_READ( glyph_buf + glyph_size, 8 ) )
- goto Fail;
- substreams[BBOX_STREAM].offset += 8;
- }
- else
- compute_bbox( total_n_points, points, glyph_buf, &x_min );
-
- glyph_size = CONTOUR_OFFSET_END_POINT;
-
- pointer = glyph_buf + glyph_size;
- end_point = -1;
-
- for ( contour_ix = 0; contour_ix < n_contours; ++contour_ix )
- {
- end_point += n_points_arr[contour_ix];
- if ( end_point >= 65536 )
- goto Fail;
-
- WRITE_SHORT( pointer, end_point );
- glyph_size += 2;
- }
-
- WRITE_USHORT( pointer, instruction_size );
- glyph_size += 2;
-
- if ( FT_STREAM_SEEK( substreams[INSTRUCTION_STREAM].offset ) ||
- FT_STREAM_READ( glyph_buf + glyph_size, instruction_size ) )
- goto Fail;
-
- substreams[INSTRUCTION_STREAM].offset += instruction_size;
- glyph_size += instruction_size;
-
- if ( store_points( total_n_points,
- points,
- n_contours,
- instruction_size,
- have_overlap,
- glyph_buf,
- glyph_buf_size,
- &glyph_size ) )
- goto Fail;
-
- FT_FREE( points );
- FT_FREE( n_points_arr );
- }
- else
- {
- /* Empty glyph. */
- /* Must not have a bbox. */
- if ( have_bbox )
- {
- FT_ERROR(( "Empty glyph has a bbox.\n" ));
- goto Fail;
- }
- }
-
- loca_values[i] = dest_offset - glyf_start;
-
- if ( WRITE_SFNT_BUF( glyph_buf, glyph_size ) )
- goto Fail;
-
- if ( pad4( &sfnt, sfnt_size, &dest_offset, memory ) )
- goto Fail;
-
- *glyf_checksum += compute_ULong_sum( glyph_buf, glyph_size );
-
- /* Store x_mins, may be required to reconstruct `hmtx'. */
- info->x_mins[i] = (FT_Short)x_min;
- }
-
- info->glyf_table->dst_length = dest_offset - info->glyf_table->dst_offset;
- info->loca_table->dst_offset = dest_offset;
-
- /* `loca[n]' will be equal to the length of the `glyf' table. */
- loca_values[num_glyphs] = info->glyf_table->dst_length;
-
- if ( store_loca( loca_values,
- num_glyphs + 1,
- index_format,
- loca_checksum,
- &sfnt,
- sfnt_size,
- &dest_offset,
- memory ) )
- goto Fail;
-
- info->loca_table->dst_length = dest_offset - info->loca_table->dst_offset;
-
- FT_TRACE4(( " loca table info:\n" ));
- FT_TRACE4(( " dst_offset = %lu\n", info->loca_table->dst_offset ));
- FT_TRACE4(( " dst_length = %lu\n", info->loca_table->dst_length ));
- FT_TRACE4(( " checksum = %09lx\n", *loca_checksum ));
-
- /* Set pointer `sfnt_bytes' to its correct value. */
- *sfnt_bytes = sfnt;
- *out_offset = dest_offset;
-
- FT_FREE( substreams );
- FT_FREE( loca_values );
- FT_FREE( n_points_arr );
- FT_FREE( glyph_buf );
- FT_FREE( points );
-
- return error;
-
- Fail:
- if ( !error )
- error = FT_THROW( Invalid_Table );
-
- /* Set pointer `sfnt_bytes' to its correct value. */
- *sfnt_bytes = sfnt;
-
- FT_FREE( substreams );
- FT_FREE( loca_values );
- FT_FREE( n_points_arr );
- FT_FREE( glyph_buf );
- FT_FREE( points );
-
- return error;
- }
-
-
- /* Get `x_mins' for untransformed `glyf' table. */
- static FT_Error
- get_x_mins( FT_Stream stream,
- WOFF2_Table* tables,
- FT_UShort num_tables,
- WOFF2_Info info,
- FT_Memory memory )
- {
- FT_UShort num_glyphs;
- FT_UShort index_format;
- FT_ULong glyf_offset;
- FT_UShort glyf_offset_short;
- FT_ULong loca_offset;
- FT_Int i;
- FT_Error error = FT_Err_Ok;
- FT_ULong offset_size;
-
- /* At this point of time those tables might not have been read yet. */
- const WOFF2_Table maxp_table = find_table( tables, num_tables,
- TTAG_maxp );
- const WOFF2_Table head_table = find_table( tables, num_tables,
- TTAG_head );
-
-
- if ( !maxp_table )
- {
- FT_ERROR(( "`maxp' table is missing.\n" ));
- return FT_THROW( Invalid_Table );
- }
-
- if ( !head_table )
- {
- FT_ERROR(( "`head' table is missing.\n" ));
- return FT_THROW( Invalid_Table );
- }
-
- if ( !info->loca_table )
- {
- FT_ERROR(( "`loca' table is missing.\n" ));
- return FT_THROW( Invalid_Table );
- }
-
- /* Read `numGlyphs' field from `maxp' table. */
- if ( FT_STREAM_SEEK( maxp_table->src_offset ) || FT_STREAM_SKIP( 8 ) )
- return error;
-
- if ( FT_READ_USHORT( num_glyphs ) )
- return error;
-
- info->num_glyphs = num_glyphs;
-
- /* Read `indexToLocFormat' field from `head' table. */
- if ( FT_STREAM_SEEK( head_table->src_offset ) ||
- FT_STREAM_SKIP( 50 ) )
- return error;
-
- if ( FT_READ_USHORT( index_format ) )
- return error;
-
- offset_size = index_format ? 4 : 2;
-
- /* Create `x_mins' array. */
- if ( FT_QNEW_ARRAY( info->x_mins, num_glyphs ) )
- return error;
-
- loca_offset = info->loca_table->src_offset;
-
- for ( i = 0; i < num_glyphs; ++i )
- {
- if ( FT_STREAM_SEEK( loca_offset ) )
- return error;
-
- loca_offset += offset_size;
-
- if ( index_format )
- {
- if ( FT_READ_ULONG( glyf_offset ) )
- return error;
- }
- else
- {
- if ( FT_READ_USHORT( glyf_offset_short ) )
- return error;
-
- glyf_offset = (FT_ULong)( glyf_offset_short );
- glyf_offset = glyf_offset << 1;
- }
-
- glyf_offset += info->glyf_table->src_offset;
-
- if ( FT_STREAM_SEEK( glyf_offset ) || FT_STREAM_SKIP( 2 ) )
- return error;
-
- if ( FT_READ_SHORT( info->x_mins[i] ) )
- return error;
- }
-
- return error;
- }
-
-
- static FT_Error
- reconstruct_hmtx( FT_Stream stream,
- FT_UShort num_glyphs,
- FT_UShort num_hmetrics,
- FT_Short* x_mins,
- FT_ULong* checksum,
- FT_Byte** sfnt_bytes,
- FT_ULong* sfnt_size,
- FT_ULong* out_offset,
- FT_Memory memory )
- {
- FT_Error error = FT_Err_Ok;
- FT_Byte* sfnt = *sfnt_bytes;
- FT_ULong dest_offset = *out_offset;
-
- FT_Byte hmtx_flags;
- FT_Bool has_proportional_lsbs, has_monospace_lsbs;
- FT_ULong hmtx_table_size;
- FT_Int i;
-
- FT_UShort* advance_widths = NULL;
- FT_Short* lsbs = NULL;
- FT_Byte* hmtx_table = NULL;
- FT_Byte* dst = NULL;
-
-
- if ( FT_READ_BYTE( hmtx_flags ) )
- goto Fail;
-
- has_proportional_lsbs = ( hmtx_flags & 1 ) == 0;
- has_monospace_lsbs = ( hmtx_flags & 2 ) == 0;
-
- /* Bits 2-7 are reserved and MUST be zero. */
- if ( ( hmtx_flags & 0xFC ) != 0 )
- goto Fail;
-
- /* Are you REALLY transformed? */
- if ( has_proportional_lsbs && has_monospace_lsbs )
- goto Fail;
-
- /* Cannot have a transformed `hmtx' without `glyf'. */
- if ( ( num_hmetrics > num_glyphs ) ||
- ( num_hmetrics < 1 ) )
- goto Fail;
-
- /* Must have at least one entry. */
- if ( num_hmetrics < 1 )
- goto Fail;
-
- if ( FT_QNEW_ARRAY( advance_widths, num_hmetrics ) ||
- FT_QNEW_ARRAY( lsbs, num_glyphs ) )
- goto Fail;
-
- /* Read `advanceWidth' stream. Always present. */
- for ( i = 0; i < num_hmetrics; i++ )
- {
- FT_UShort advance_width;
-
-
- if ( FT_READ_USHORT( advance_width ) )
- goto Fail;
-
- advance_widths[i] = advance_width;
- }
-
- /* lsb values for proportional glyphs. */
- for ( i = 0; i < num_hmetrics; i++ )
- {
- FT_Short lsb;
-
-
- if ( has_proportional_lsbs )
- {
- if ( FT_READ_SHORT( lsb ) )
- goto Fail;
- }
- else
- lsb = x_mins[i];
-
- lsbs[i] = lsb;
- }
-
- /* lsb values for monospaced glyphs. */
- for ( i = num_hmetrics; i < num_glyphs; i++ )
- {
- FT_Short lsb;
-
-
- if ( has_monospace_lsbs )
- {
- if ( FT_READ_SHORT( lsb ) )
- goto Fail;
- }
- else
- lsb = x_mins[i];
-
- lsbs[i] = lsb;
- }
-
- /* Build the hmtx table. */
- hmtx_table_size = 2 * num_hmetrics + 2 * num_glyphs;
- if ( FT_QALLOC( hmtx_table, hmtx_table_size ) )
- goto Fail;
-
- dst = hmtx_table;
- FT_TRACE6(( "hmtx values: \n" ));
- for ( i = 0; i < num_glyphs; i++ )
- {
- if ( i < num_hmetrics )
- {
- WRITE_SHORT( dst, advance_widths[i] );
- FT_TRACE6(( "%d ", advance_widths[i] ));
- }
-
- WRITE_SHORT( dst, lsbs[i] );
- FT_TRACE6(( "%d ", lsbs[i] ));
- }
- FT_TRACE6(( "\n" ));
-
- *checksum = compute_ULong_sum( hmtx_table, hmtx_table_size );
- /* Write `hmtx' table to sfnt buffer. */
- if ( WRITE_SFNT_BUF( hmtx_table, hmtx_table_size ) )
- goto Fail;
-
- /* Set pointer `sfnt_bytes' to its correct value. */
- *sfnt_bytes = sfnt;
- *out_offset = dest_offset;
-
- FT_FREE( advance_widths );
- FT_FREE( lsbs );
- FT_FREE( hmtx_table );
-
- return error;
-
- Fail:
- FT_FREE( advance_widths );
- FT_FREE( lsbs );
- FT_FREE( hmtx_table );
-
- if ( !error )
- error = FT_THROW( Invalid_Table );
-
- return error;
- }
-
-
- static FT_Error
- reconstruct_font( FT_Byte* transformed_buf,
- FT_ULong transformed_buf_size,
- WOFF2_Table* indices,
- WOFF2_Header woff2,
- WOFF2_Info info,
- FT_Byte** sfnt_bytes,
- FT_ULong* sfnt_size,
- FT_Memory memory )
- {
- /* Memory management of `transformed_buf' is handled by the caller. */
-
- FT_Error error = FT_Err_Ok;
- FT_Stream stream = NULL;
- FT_Byte* buf_cursor = NULL;
- FT_Byte table_entry[16];
-
- /* We are reallocating memory for `sfnt', so its pointer may change. */
- FT_Byte* sfnt = *sfnt_bytes;
-
- FT_UShort num_tables = woff2->num_tables;
- FT_ULong dest_offset = 12 + num_tables * 16UL;
-
- FT_ULong checksum = 0;
- FT_ULong loca_checksum = 0;
- FT_Int nn = 0;
- FT_UShort num_hmetrics = 0;
- FT_ULong font_checksum = info->header_checksum;
- FT_Bool is_glyf_xform = FALSE;
-
- FT_ULong table_entry_offset = 12;
-
-
- /* A few table checks before reconstruction. */
- /* `glyf' must be present with `loca'. */
- info->glyf_table = find_table( indices, num_tables, TTAG_glyf );
- info->loca_table = find_table( indices, num_tables, TTAG_loca );
-
- if ( ( info->glyf_table == NULL ) ^ ( info->loca_table == NULL ) )
- {
- FT_ERROR(( "One of `glyf'/`loca' tables missing.\n" ));
- return FT_THROW( Invalid_Table );
- }
-
- /* Both `glyf' and `loca' must have same transformation. */
- if ( info->glyf_table != NULL )
- {
- if ( ( info->glyf_table->flags & WOFF2_FLAGS_TRANSFORM ) !=
- ( info->loca_table->flags & WOFF2_FLAGS_TRANSFORM ) )
- {
- FT_ERROR(( "Transformation mismatch"
- " between `glyf' and `loca' table." ));
- return FT_THROW( Invalid_Table );
- }
- }
-
- /* Create a stream for the uncompressed buffer. */
- if ( FT_NEW( stream ) )
- goto Fail;
- FT_Stream_OpenMemory( stream, transformed_buf, transformed_buf_size );
-
- FT_ASSERT( FT_STREAM_POS() == 0 );
-
- /* Reconstruct/copy tables to output stream. */
- for ( nn = 0; nn < num_tables; nn++ )
- {
- WOFF2_TableRec table = *( indices[nn] );
-
-
- FT_TRACE3(( "Seeking to %ld with table size %ld.\n",
- table.src_offset, table.src_length ));
- FT_TRACE3(( "Table tag: %c%c%c%c.\n",
- (FT_Char)( table.Tag >> 24 ),
- (FT_Char)( table.Tag >> 16 ),
- (FT_Char)( table.Tag >> 8 ),
- (FT_Char)( table.Tag ) ));
-
- if ( FT_STREAM_SEEK( table.src_offset ) )
- goto Fail;
-
- if ( table.src_offset + table.src_length > transformed_buf_size )
- goto Fail;
-
- /* Get stream size for fields of `hmtx' table. */
- if ( table.Tag == TTAG_hhea )
- {
- if ( read_num_hmetrics( stream, &num_hmetrics ) )
- goto Fail;
- }
-
- info->num_hmetrics = num_hmetrics;
-
- checksum = 0;
- if ( ( table.flags & WOFF2_FLAGS_TRANSFORM ) != WOFF2_FLAGS_TRANSFORM )
- {
- /* Check whether `head' is at least 12 bytes. */
- if ( table.Tag == TTAG_head )
- {
- if ( table.src_length < 12 )
- goto Fail;
-
- buf_cursor = transformed_buf + table.src_offset + 8;
- /* Set checkSumAdjustment = 0 */
- WRITE_ULONG( buf_cursor, 0 );
- }
-
- table.dst_offset = dest_offset;
-
- checksum = compute_ULong_sum( transformed_buf + table.src_offset,
- table.src_length );
- FT_TRACE4(( "Checksum = %09lx.\n", checksum ));
-
- if ( WRITE_SFNT_BUF( transformed_buf + table.src_offset,
- table.src_length ) )
- goto Fail;
- }
- else
- {
- FT_TRACE3(( "This table is transformed.\n" ));
-
- if ( table.Tag == TTAG_glyf )
- {
- is_glyf_xform = TRUE;
- table.dst_offset = dest_offset;
-
- if ( reconstruct_glyf( stream,
- &checksum,
- &loca_checksum,
- &sfnt,
- sfnt_size,
- &dest_offset,
- info,
- memory ) )
- goto Fail;
-
- FT_TRACE4(( "Checksum = %09lx.\n", checksum ));
- }
-
- else if ( table.Tag == TTAG_loca )
- checksum = loca_checksum;
-
- else if ( table.Tag == TTAG_hmtx )
- {
- /* If glyf is not transformed and hmtx is, handle separately. */
- if ( !is_glyf_xform )
- {
- if ( get_x_mins( stream, indices, num_tables, info, memory ) )
- goto Fail;
- }
-
- table.dst_offset = dest_offset;
-
- if ( reconstruct_hmtx( stream,
- info->num_glyphs,
- info->num_hmetrics,
- info->x_mins,
- &checksum,
- &sfnt,
- sfnt_size,
- &dest_offset,
- memory ) )
- goto Fail;
- }
- else
- {
- /* Unknown transform. */
- FT_ERROR(( "Unknown table transform.\n" ));
- goto Fail;
- }
- }
-
- font_checksum += checksum;
-
- buf_cursor = &table_entry[0];
- WRITE_ULONG( buf_cursor, table.Tag );
- WRITE_ULONG( buf_cursor, checksum );
- WRITE_ULONG( buf_cursor, table.dst_offset );
- WRITE_ULONG( buf_cursor, table.dst_length );
-
- WRITE_SFNT_BUF_AT( table_entry_offset, table_entry, 16 );
-
- /* Update checksum. */
- font_checksum += compute_ULong_sum( table_entry, 16 );
-
- if ( pad4( &sfnt, sfnt_size, &dest_offset, memory ) )
- goto Fail;
-
- /* Sanity check. */
- if ( (FT_ULong)( table.dst_offset + table.dst_length ) > dest_offset )
- {
- FT_ERROR(( "Table was partially written.\n" ));
- goto Fail;
- }
- }
-
- /* Update `head' checkSumAdjustment. */
- info->head_table = find_table( indices, num_tables, TTAG_head );
- if ( !info->head_table )
- {
- FT_ERROR(( "`head' table is missing.\n" ));
- goto Fail;
- }
-
- if ( info->head_table->dst_length < 12 )
- goto Fail;
-
- buf_cursor = sfnt + info->head_table->dst_offset + 8;
- font_checksum = 0xB1B0AFBA - font_checksum;
-
- WRITE_ULONG( buf_cursor, font_checksum );
-
- FT_TRACE2(( "Final checksum = %09lx.\n", font_checksum ));
-
- woff2->actual_sfnt_size = dest_offset;
-
- /* Set pointer of sfnt stream to its correct value. */
- *sfnt_bytes = sfnt;
-
- FT_Stream_Close( stream );
- FT_FREE( stream );
-
- return error;
-
- Fail:
- if ( !error )
- error = FT_THROW( Invalid_Table );
-
- /* Set pointer of sfnt stream to its correct value. */
- *sfnt_bytes = sfnt;
-
- FT_Stream_Close( stream );
- FT_FREE( stream );
-
- return error;
- }
-
-
- /* Replace `face->root.stream' with a stream containing the extracted */
- /* SFNT of a WOFF2 font. */
-
- FT_LOCAL_DEF( FT_Error )
- woff2_open_font( FT_Stream stream,
- TT_Face face,
- FT_Int* face_instance_index,
- FT_Long* num_faces )
- {
- FT_Memory memory = stream->memory;
- FT_Error error = FT_Err_Ok;
- FT_Int face_index;
-
- WOFF2_HeaderRec woff2;
- WOFF2_InfoRec info = { 0, 0, 0, NULL, NULL, NULL, NULL };
- WOFF2_Table tables = NULL;
- WOFF2_Table* indices = NULL;
- WOFF2_Table* temp_indices = NULL;
- WOFF2_Table last_table;
-
- FT_Int nn;
- FT_ULong j;
- FT_ULong flags;
- FT_UShort xform_version;
- FT_ULong src_offset = 0;
-
- FT_UInt glyf_index;
- FT_UInt loca_index;
- FT_UInt32 file_offset;
-
- FT_Byte* sfnt = NULL;
- FT_Stream sfnt_stream = NULL;
- FT_ULong sfnt_size;
-
- FT_Byte* uncompressed_buf = NULL;
-
- static const FT_Frame_Field woff2_header_fields[] =
- {
-#undef FT_STRUCTURE
-#define FT_STRUCTURE WOFF2_HeaderRec
-
- FT_FRAME_START( 48 ),
- FT_FRAME_ULONG ( signature ),
- FT_FRAME_ULONG ( flavor ),
- FT_FRAME_ULONG ( length ),
- FT_FRAME_USHORT ( num_tables ),
- FT_FRAME_SKIP_BYTES( 2 ),
- FT_FRAME_ULONG ( totalSfntSize ),
- FT_FRAME_ULONG ( totalCompressedSize ),
- FT_FRAME_SKIP_BYTES( 2 * 2 ),
- FT_FRAME_ULONG ( metaOffset ),
- FT_FRAME_ULONG ( metaLength ),
- FT_FRAME_ULONG ( metaOrigLength ),
- FT_FRAME_ULONG ( privOffset ),
- FT_FRAME_ULONG ( privLength ),
- FT_FRAME_END
- };
-
-
- FT_ASSERT( stream == face->root.stream );
- FT_ASSERT( FT_STREAM_POS() == 0 );
-
- face_index = FT_ABS( *face_instance_index ) & 0xFFFF;
-
- /* Read WOFF2 Header. */
- if ( FT_STREAM_READ_FIELDS( woff2_header_fields, &woff2 ) )
- return error;
-
- FT_TRACE4(( "signature -> 0x%lX\n", woff2.signature ));
- FT_TRACE2(( "flavor -> 0x%08lx\n", woff2.flavor ));
- FT_TRACE4(( "length -> %lu\n", woff2.length ));
- FT_TRACE2(( "num_tables -> %hu\n", woff2.num_tables ));
- FT_TRACE4(( "totalSfntSize -> %lu\n", woff2.totalSfntSize ));
- FT_TRACE4(( "metaOffset -> %lu\n", woff2.metaOffset ));
- FT_TRACE4(( "metaLength -> %lu\n", woff2.metaLength ));
- FT_TRACE4(( "privOffset -> %lu\n", woff2.privOffset ));
- FT_TRACE4(( "privLength -> %lu\n", woff2.privLength ));
-
- /* Make sure we don't recurse back here. */
- if ( woff2.flavor == TTAG_wOF2 )
- return FT_THROW( Invalid_Table );
-
- /* Miscellaneous checks. */
- if ( woff2.length != stream->size ||
- woff2.num_tables == 0 ||
- woff2.num_tables > 0xFFFU ||
- 48 + woff2.num_tables * 20UL >= woff2.length ||
- ( woff2.metaOffset == 0 && ( woff2.metaLength != 0 ||
- woff2.metaOrigLength != 0 ) ) ||
- ( woff2.metaLength != 0 && woff2.metaOrigLength == 0 ) ||
- ( woff2.metaOffset >= woff2.length ) ||
- ( woff2.length - woff2.metaOffset < woff2.metaLength ) ||
- ( woff2.privOffset == 0 && woff2.privLength != 0 ) ||
- ( woff2.privOffset >= woff2.length ) ||
- ( woff2.length - woff2.privOffset < woff2.privLength ) )
- {
- FT_ERROR(( "woff2_open_font: invalid WOFF2 header\n" ));
- return FT_THROW( Invalid_Table );
- }
-
- FT_TRACE2(( "woff2_open_font: WOFF2 Header is valid.\n" ));
-
- woff2.ttc_fonts = NULL;
-
- /* Read table directory. */
- if ( FT_QNEW_ARRAY( tables, woff2.num_tables ) ||
- FT_QNEW_ARRAY( indices, woff2.num_tables ) )
- goto Exit;
-
- FT_TRACE2(( "\n" ));
- FT_TRACE2(( " tag flags transform origLen transformLen offset\n" ));
- FT_TRACE2(( " -----------------------------------------------------------\n" ));
- /* " XXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX" */
-
- for ( nn = 0; nn < woff2.num_tables; nn++ )
- {
- WOFF2_Table table = tables + nn;
-
-
- if ( FT_READ_BYTE( table->FlagByte ) )
- goto Exit;
-
- if ( ( table->FlagByte & 0x3f ) == 0x3f )
- {
- if ( FT_READ_ULONG( table->Tag ) )
- goto Exit;
- }
- else
- {
- table->Tag = woff2_known_tags( table->FlagByte & 0x3f );
- if ( !table->Tag )
- {
- FT_ERROR(( "woff2_open_font: Unknown table tag." ));
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
- }
-
- flags = 0;
- xform_version = ( table->FlagByte >> 6 ) & 0x03;
-
- /* 0 means xform for glyph/loca, non-0 for others. */
- if ( table->Tag == TTAG_glyf || table->Tag == TTAG_loca )
- {
- if ( xform_version == 0 )
- flags |= WOFF2_FLAGS_TRANSFORM;
- }
- else if ( xform_version != 0 )
- flags |= WOFF2_FLAGS_TRANSFORM;
-
- flags |= xform_version;
-
- if ( READ_BASE128( table->dst_length ) )
- goto Exit;
-
- table->TransformLength = table->dst_length;
-
- if ( ( flags & WOFF2_FLAGS_TRANSFORM ) != 0 )
- {
- if ( READ_BASE128( table->TransformLength ) )
- goto Exit;
-
- if ( table->Tag == TTAG_loca && table->TransformLength )
- {
- FT_ERROR(( "woff2_open_font: Invalid loca `transformLength'.\n" ));
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
- }
-
- if ( src_offset + table->TransformLength < src_offset )
- {
- FT_ERROR(( "woff2_open_font: invalid WOFF2 table directory.\n" ));
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- table->flags = flags;
- table->src_offset = src_offset;
- table->src_length = table->TransformLength;
- src_offset += table->TransformLength;
- table->dst_offset = 0;
-
- FT_TRACE2(( " %c%c%c%c %08d %08d %08ld %08ld %08ld\n",
- (FT_Char)( table->Tag >> 24 ),
- (FT_Char)( table->Tag >> 16 ),
- (FT_Char)( table->Tag >> 8 ),
- (FT_Char)( table->Tag ),
- table->FlagByte & 0x3f,
- ( table->FlagByte >> 6 ) & 0x03,
- table->dst_length,
- table->TransformLength,
- table->src_offset ));
-
- indices[nn] = table;
- }
-
- /* End of last table is uncompressed size. */
- last_table = indices[woff2.num_tables - 1];
-
- woff2.uncompressed_size = last_table->src_offset +
- last_table->src_length;
- if ( woff2.uncompressed_size < last_table->src_offset )
- {
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- FT_TRACE2(( "Table directory parsed.\n" ));
-
- /* Check for and read collection directory. */
- woff2.num_fonts = 1;
- woff2.header_version = 0;
-
- if ( woff2.flavor == TTAG_ttcf )
- {
- FT_TRACE2(( "Font is a TTC, reading collection directory.\n" ));
-
- if ( FT_READ_ULONG( woff2.header_version ) )
- goto Exit;
-
- if ( woff2.header_version != 0x00010000 &&
- woff2.header_version != 0x00020000 )
- {
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- if ( READ_255USHORT( woff2.num_fonts ) )
- goto Exit;
-
- if ( !woff2.num_fonts )
- {
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- FT_TRACE4(( "Number of fonts in TTC: %d\n", woff2.num_fonts ));
-
- /* pre-zero pointers within in case of failure */
- if ( FT_NEW_ARRAY( woff2.ttc_fonts, woff2.num_fonts ) )
- goto Exit;
-
- for ( nn = 0; nn < woff2.num_fonts; nn++ )
- {
- WOFF2_TtcFont ttc_font = woff2.ttc_fonts + nn;
-
-
- if ( READ_255USHORT( ttc_font->num_tables ) )
- goto Exit;
- if ( FT_READ_ULONG( ttc_font->flavor ) )
- goto Exit;
-
- if ( FT_QNEW_ARRAY( ttc_font->table_indices, ttc_font->num_tables ) )
- goto Exit;
-
- FT_TRACE5(( "Number of tables in font %d: %d\n",
- nn, ttc_font->num_tables ));
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( ttc_font->num_tables )
- FT_TRACE6(( " Indices: " ));
-#endif
-
- glyf_index = 0;
- loca_index = 0;
-
- for ( j = 0; j < ttc_font->num_tables; j++ )
- {
- FT_UShort table_index;
- WOFF2_Table table;
-
-
- if ( READ_255USHORT( table_index ) )
- goto Exit;
-
- FT_TRACE6(( "%hu ", table_index ));
- if ( table_index >= woff2.num_tables )
- {
- FT_ERROR(( "woff2_open_font: invalid table index\n" ));
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- ttc_font->table_indices[j] = table_index;
-
- table = indices[table_index];
- if ( table->Tag == TTAG_loca )
- loca_index = table_index;
- if ( table->Tag == TTAG_glyf )
- glyf_index = table_index;
- }
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( ttc_font->num_tables )
- FT_TRACE6(( "\n" ));
-#endif
-
- /* glyf and loca must be consecutive */
- if ( glyf_index > 0 || loca_index > 0 )
- {
- if ( glyf_index > loca_index ||
- loca_index - glyf_index != 1 )
- {
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
- }
- }
-
- /* Collection directory reading complete. */
- FT_TRACE2(( "WOFF2 collection directory is valid.\n" ));
- }
- else
- woff2.ttc_fonts = NULL;
-
- woff2.compressed_offset = FT_STREAM_POS();
- file_offset = ROUND4( woff2.compressed_offset +
- woff2.totalCompressedSize );
-
- /* Some more checks before we start reading the tables. */
- if ( file_offset > woff2.length )
- {
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- if ( woff2.metaOffset )
- {
- if ( file_offset != woff2.metaOffset )
- {
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
- file_offset = ROUND4( woff2.metaOffset + woff2.metaLength );
- }
-
- if ( woff2.privOffset )
- {
- if ( file_offset != woff2.privOffset )
- {
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
- file_offset = ROUND4( woff2.privOffset + woff2.privLength );
- }
-
- if ( file_offset != ( ROUND4( woff2.length ) ) )
- {
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- /* Validate requested face index. */
- *num_faces = woff2.num_fonts;
- /* value -(N+1) requests information on index N */
- if ( *face_instance_index < 0 && face_index > 0 )
- face_index--;
-
- if ( face_index >= woff2.num_fonts )
- {
- if ( *face_instance_index >= 0 )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
- else
- face_index = 0;
- }
-
- /* Only retain tables of the requested face in a TTC. */
- if ( woff2.header_version )
- {
- WOFF2_TtcFont ttc_font = woff2.ttc_fonts + face_index;
-
-
- if ( ttc_font->num_tables == 0 || ttc_font->num_tables > 0xFFFU )
- {
- FT_ERROR(( "woff2_open_font: invalid WOFF2 CollectionFontEntry\n" ));
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- /* Create a temporary array. */
- if ( FT_QNEW_ARRAY( temp_indices,
- ttc_font->num_tables ) )
- goto Exit;
-
- FT_TRACE4(( "Storing tables for TTC face index %d.\n", face_index ));
- for ( nn = 0; nn < ttc_font->num_tables; nn++ )
- temp_indices[nn] = indices[ttc_font->table_indices[nn]];
-
- /* Resize array to required size. */
- if ( FT_QRENEW_ARRAY( indices,
- woff2.num_tables,
- ttc_font->num_tables ) )
- goto Exit;
-
- for ( nn = 0; nn < ttc_font->num_tables; nn++ )
- indices[nn] = temp_indices[nn];
-
- FT_FREE( temp_indices );
-
- /* Change header values. */
- woff2.flavor = ttc_font->flavor;
- woff2.num_tables = ttc_font->num_tables;
- }
-
- /* We need to allocate this much at the minimum. */
- sfnt_size = 12 + woff2.num_tables * 16UL;
- /* This is what we normally expect. */
- /* Initially trust `totalSfntSize' and change later as required. */
- if ( woff2.totalSfntSize > sfnt_size )
- {
- /* However, adjust the value to something reasonable. */
-
- /* Factor 64 is heuristic. */
- if ( ( woff2.totalSfntSize >> 6 ) > woff2.length )
- sfnt_size = woff2.length << 6;
- else
- sfnt_size = woff2.totalSfntSize;
-
- if ( sfnt_size >= MAX_SFNT_SIZE )
- sfnt_size = MAX_SFNT_SIZE;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( sfnt_size != woff2.totalSfntSize )
- FT_TRACE4(( "adjusting estimate of uncompressed font size"
- " to %lu bytes\n",
- sfnt_size ));
-#endif
- }
-
- /* Write sfnt header. */
- if ( FT_QALLOC( sfnt, sfnt_size ) ||
- FT_NEW( sfnt_stream ) )
- goto Exit;
-
- {
- FT_Byte* sfnt_header = sfnt;
-
- FT_Int entrySelector = FT_MSB( woff2.num_tables );
- FT_Int searchRange = ( 1 << entrySelector ) * 16;
- FT_Int rangeShift = woff2.num_tables * 16 - searchRange;
-
-
- WRITE_ULONG ( sfnt_header, woff2.flavor );
- WRITE_USHORT( sfnt_header, woff2.num_tables );
- WRITE_USHORT( sfnt_header, searchRange );
- WRITE_USHORT( sfnt_header, entrySelector );
- WRITE_USHORT( sfnt_header, rangeShift );
- }
-
- info.header_checksum = compute_ULong_sum( sfnt, 12 );
-
- /* Sort tables by tag. */
- ft_qsort( indices,
- woff2.num_tables,
- sizeof ( WOFF2_Table ),
- compare_tags );
-
- /* reject fonts that have multiple tables with the same tag */
- for ( nn = 1; nn < woff2.num_tables; nn++ )
- {
- FT_Tag tag = indices[nn]->Tag;
-
-
- if ( tag == indices[nn - 1]->Tag )
- {
- FT_ERROR(( "woff2_open_font:"
- " multiple tables with tag `%c%c%c%c'.\n",
- (FT_Char)( tag >> 24 ),
- (FT_Char)( tag >> 16 ),
- (FT_Char)( tag >> 8 ),
- (FT_Char)( tag ) ));
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
- }
-
- if ( woff2.uncompressed_size < 1 )
- {
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- /* We must not blindly trust `uncompressed_size` since its */
- /* value might be corrupted. If it is too large, reject the */
- /* font. In other words, we don't accept a WOFF2 font that */
- /* expands to something larger than MAX_SFNT_SIZE. If ever */
- /* necessary, this limit can be easily adjusted. */
- if ( woff2.uncompressed_size > MAX_SFNT_SIZE )
- {
- FT_ERROR(( "Uncompressed font too large.\n" ));
- error = FT_THROW( Array_Too_Large );
- goto Exit;
- }
-
- /* Allocate memory for uncompressed table data. */
- if ( FT_QALLOC( uncompressed_buf, woff2.uncompressed_size ) ||
- FT_FRAME_ENTER( woff2.totalCompressedSize ) )
- goto Exit;
-
- /* Uncompress the stream. */
- error = woff2_decompress( uncompressed_buf,
- woff2.uncompressed_size,
- stream->cursor,
- woff2.totalCompressedSize );
-
- FT_FRAME_EXIT();
-
- if ( error )
- goto Exit;
-
- error = reconstruct_font( uncompressed_buf,
- woff2.uncompressed_size,
- indices,
- &woff2,
- &info,
- &sfnt,
- &sfnt_size,
- memory );
-
- if ( error )
- goto Exit;
-
- /* Resize `sfnt' to actual size of sfnt stream. */
- if ( woff2.actual_sfnt_size < sfnt_size )
- {
- FT_TRACE5(( "Trimming sfnt stream from %lu to %lu.\n",
- sfnt_size, woff2.actual_sfnt_size ));
- if ( FT_QREALLOC( sfnt,
- (FT_ULong)( sfnt_size ),
- (FT_ULong)( woff2.actual_sfnt_size ) ) )
- goto Exit;
- }
-
- /* `reconstruct_font' has done all the work. */
- /* Swap out stream and return. */
- FT_Stream_OpenMemory( sfnt_stream, sfnt, woff2.actual_sfnt_size );
- sfnt_stream->memory = stream->memory;
- sfnt_stream->close = stream_close;
-
- FT_Stream_Free(
- face->root.stream,
- ( face->root.face_flags & FT_FACE_FLAG_EXTERNAL_STREAM ) != 0 );
-
- face->root.stream = sfnt_stream;
- face->root.face_flags &= ~FT_FACE_FLAG_EXTERNAL_STREAM;
-
- /* Set face_index to 0 or -1. */
- if ( *face_instance_index >= 0 )
- *face_instance_index = 0;
- else
- *face_instance_index = -1;
-
- FT_TRACE2(( "woff2_open_font: SFNT synthesized.\n" ));
-
- Exit:
- FT_FREE( tables );
- FT_FREE( indices );
- FT_FREE( uncompressed_buf );
- FT_FREE( info.x_mins );
-
- if ( woff2.ttc_fonts )
- {
- WOFF2_TtcFont ttc_font = woff2.ttc_fonts;
-
-
- for ( nn = 0; nn < woff2.num_fonts; nn++ )
- {
- FT_FREE( ttc_font->table_indices );
- ttc_font++;
- }
-
- FT_FREE( woff2.ttc_fonts );
- }
-
- if ( error )
- {
- FT_FREE( sfnt );
- if ( sfnt_stream )
- {
- FT_Stream_Close( sfnt_stream );
- FT_FREE( sfnt_stream );
- }
- }
-
- return error;
- }
-
-
-#undef READ_255USHORT
-#undef READ_BASE128
-#undef ROUND4
-#undef WRITE_USHORT
-#undef WRITE_ULONG
-#undef WRITE_SHORT
-#undef WRITE_SFNT_BUF
-#undef WRITE_SFNT_BUF_AT
-
-#undef N_CONTOUR_STREAM
-#undef N_POINTS_STREAM
-#undef FLAG_STREAM
-#undef GLYPH_STREAM
-#undef COMPOSITE_STREAM
-#undef BBOX_STREAM
-#undef INSTRUCTION_STREAM
-
-#else /* !FT_CONFIG_OPTION_USE_BROTLI */
-
- /* ANSI C doesn't like empty source files */
- typedef int sfwoff2_dummy_;
-
-#endif /* !FT_CONFIG_OPTION_USE_BROTLI */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/sfnt/sfwoff2.h b/contrib/libs/freetype/src/sfnt/sfwoff2.h
deleted file mode 100644
index f41140648d..0000000000
--- a/contrib/libs/freetype/src/sfnt/sfwoff2.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
- *
- * sfwoff2.h
- *
- * WOFFF2 format management (specification).
- *
- * Copyright (C) 2019-2024 by
- * Nikhil Ramakrishnan, David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef SFWOFF2_H_
-#define SFWOFF2_H_
-
-
-#include <freetype/internal/sfnt.h>
-#include <freetype/internal/ftobjs.h>
-
-
-FT_BEGIN_HEADER
-
-#ifdef FT_CONFIG_OPTION_USE_BROTLI
-
- /* Leave the first byte open to store `flag_byte'. */
-#define WOFF2_FLAGS_TRANSFORM 1 << 8
-
-#define WOFF2_SFNT_HEADER_SIZE 12
-#define WOFF2_SFNT_ENTRY_SIZE 16
-
- /* Suggested maximum size for output. */
-#define WOFF2_DEFAULT_MAX_SIZE 30 * 1024 * 1024
-
- /* 98% of Google Fonts have no glyph above 5k bytes. */
-#define WOFF2_DEFAULT_GLYPH_BUF 5120
-
- /* Composite glyph flags. */
- /* See `CompositeGlyph.java' in `sfntly' for full definitions. */
-#define FLAG_ARG_1_AND_2_ARE_WORDS 1 << 0
-#define FLAG_WE_HAVE_A_SCALE 1 << 3
-#define FLAG_MORE_COMPONENTS 1 << 5
-#define FLAG_WE_HAVE_AN_X_AND_Y_SCALE 1 << 6
-#define FLAG_WE_HAVE_A_TWO_BY_TWO 1 << 7
-#define FLAG_WE_HAVE_INSTRUCTIONS 1 << 8
-
- /* Simple glyph flags */
-#define GLYF_ON_CURVE 1 << 0
-#define GLYF_X_SHORT 1 << 1
-#define GLYF_Y_SHORT 1 << 2
-#define GLYF_REPEAT 1 << 3
-#define GLYF_THIS_X_IS_SAME 1 << 4
-#define GLYF_THIS_Y_IS_SAME 1 << 5
-#define GLYF_OVERLAP_SIMPLE 1 << 6
-
- /* Other constants */
-#define CONTOUR_OFFSET_END_POINT 10
-
-
- FT_LOCAL( FT_Error )
- woff2_open_font( FT_Stream stream,
- TT_Face face,
- FT_Int* face_index,
- FT_Long* num_faces );
-
-#endif /* FT_CONFIG_OPTION_USE_BROTLI */
-
-FT_END_HEADER
-
-#endif /* SFWOFF2_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/sfnt/ttbdf.c b/contrib/libs/freetype/src/sfnt/ttbdf.c
deleted file mode 100644
index d9765f486f..0000000000
--- a/contrib/libs/freetype/src/sfnt/ttbdf.c
+++ /dev/null
@@ -1,257 +0,0 @@
-/****************************************************************************
- *
- * ttbdf.c
- *
- * TrueType and OpenType embedded BDF properties (body).
- *
- * Copyright (C) 2005-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/tttags.h>
-#include "ttbdf.h"
-
-#include "sferrors.h"
-
-
-#ifdef TT_CONFIG_OPTION_BDF
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT ttbdf
-
-
- FT_LOCAL_DEF( void )
- tt_face_free_bdf_props( TT_Face face )
- {
- TT_BDF bdf = &face->bdf;
-
-
- if ( bdf->loaded )
- {
- FT_Stream stream = FT_FACE( face )->stream;
-
-
- if ( bdf->table )
- FT_FRAME_RELEASE( bdf->table );
-
- bdf->table_end = NULL;
- bdf->strings = NULL;
- bdf->strings_size = 0;
- }
- }
-
-
- static FT_Error
- tt_face_load_bdf_props( TT_Face face,
- FT_Stream stream )
- {
- TT_BDF bdf = &face->bdf;
- FT_ULong length;
- FT_Error error;
-
-
- FT_ZERO( bdf );
-
- error = tt_face_goto_table( face, TTAG_BDF, stream, &length );
- if ( error ||
- length < 8 ||
- FT_FRAME_EXTRACT( length, bdf->table ) )
- {
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- bdf->table_end = bdf->table + length;
-
- {
- FT_Byte* p = bdf->table;
- FT_UInt version = FT_NEXT_USHORT( p );
- FT_UInt num_strikes = FT_NEXT_USHORT( p );
- FT_ULong strings = FT_NEXT_ULONG ( p );
- FT_UInt count;
- FT_Byte* strike;
-
-
- if ( version != 0x0001 ||
- strings < 8 ||
- ( strings - 8 ) / 4 < num_strikes ||
- strings + 1 > length )
- {
- goto BadTable;
- }
-
- bdf->num_strikes = num_strikes;
- bdf->strings = bdf->table + strings;
- bdf->strings_size = length - strings;
-
- count = bdf->num_strikes;
- p = bdf->table + 8;
- strike = p + count * 4;
-
-
- for ( ; count > 0; count-- )
- {
- FT_UInt num_items = FT_PEEK_USHORT( p + 2 );
-
- /*
- * We don't need to check the value sets themselves, since this
- * is done later.
- */
- strike += 10 * num_items;
-
- p += 4;
- }
-
- if ( strike > bdf->strings )
- goto BadTable;
- }
-
- bdf->loaded = 1;
-
- Exit:
- return error;
-
- BadTable:
- FT_FRAME_RELEASE( bdf->table );
- FT_ZERO( bdf );
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- tt_face_find_bdf_prop( FT_Face face, /* TT_Face */
- const char* property_name,
- BDF_PropertyRec *aprop )
- {
- TT_Face ttface = (TT_Face)face;
- TT_BDF bdf = &ttface->bdf;
- FT_Size size = face->size;
- FT_Error error = FT_Err_Ok;
- FT_Byte* p;
- FT_UInt count;
- FT_Byte* strike;
- FT_Offset property_len;
-
-
- aprop->type = BDF_PROPERTY_TYPE_NONE;
-
- if ( bdf->loaded == 0 )
- {
- error = tt_face_load_bdf_props( ttface, FT_FACE_STREAM( face ) );
- if ( error )
- goto Exit;
- }
-
- count = bdf->num_strikes;
- p = bdf->table + 8;
- strike = p + 4 * count;
-
- error = FT_ERR( Invalid_Argument );
-
- if ( !size || !property_name )
- goto Exit;
-
- property_len = ft_strlen( property_name );
- if ( property_len == 0 )
- goto Exit;
-
- for ( ; count > 0; count-- )
- {
- FT_UInt _ppem = FT_NEXT_USHORT( p );
- FT_UInt _count = FT_NEXT_USHORT( p );
-
-
- if ( _ppem == size->metrics.y_ppem )
- {
- count = _count;
- goto FoundStrike;
- }
-
- strike += 10 * _count;
- }
- goto Exit;
-
- FoundStrike:
- p = strike;
- for ( ; count > 0; count-- )
- {
- FT_UInt type = FT_PEEK_USHORT( p + 4 );
-
-
- if ( ( type & 0x10 ) != 0 )
- {
- FT_UInt32 name_offset = FT_PEEK_ULONG( p );
- FT_UInt32 value = FT_PEEK_ULONG( p + 6 );
-
- /* be a bit paranoid for invalid entries here */
- if ( name_offset < bdf->strings_size &&
- property_len < bdf->strings_size - name_offset &&
- ft_strncmp( property_name,
- (const char*)bdf->strings + name_offset,
- bdf->strings_size - name_offset ) == 0 )
- {
- switch ( type & 0x0F )
- {
- case 0x00: /* string */
- case 0x01: /* atoms */
- /* check that the content is really 0-terminated */
- if ( value < bdf->strings_size &&
- ft_memchr( bdf->strings + value, 0, bdf->strings_size ) )
- {
- aprop->type = BDF_PROPERTY_TYPE_ATOM;
- aprop->u.atom = (const char*)bdf->strings + value;
- error = FT_Err_Ok;
- goto Exit;
- }
- break;
-
- case 0x02:
- aprop->type = BDF_PROPERTY_TYPE_INTEGER;
- aprop->u.integer = (FT_Int32)value;
- error = FT_Err_Ok;
- goto Exit;
-
- case 0x03:
- aprop->type = BDF_PROPERTY_TYPE_CARDINAL;
- aprop->u.cardinal = value;
- error = FT_Err_Ok;
- goto Exit;
-
- default:
- ;
- }
- }
- }
- p += 10;
- }
-
- Exit:
- return error;
- }
-
-#else /* !TT_CONFIG_OPTION_BDF */
-
- /* ANSI C doesn't like empty source files */
- typedef int tt_bdf_dummy_;
-
-#endif /* !TT_CONFIG_OPTION_BDF */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/sfnt/ttbdf.h b/contrib/libs/freetype/src/sfnt/ttbdf.h
deleted file mode 100644
index d8d722b928..0000000000
--- a/contrib/libs/freetype/src/sfnt/ttbdf.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/****************************************************************************
- *
- * ttbdf.h
- *
- * TrueType and OpenType embedded BDF properties (specification).
- *
- * Copyright (C) 2005-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef TTBDF_H_
-#define TTBDF_H_
-
-
-#include "ttload.h"
-#include <freetype/ftbdf.h>
-
-
-FT_BEGIN_HEADER
-
-
-#ifdef TT_CONFIG_OPTION_BDF
-
- FT_LOCAL( void )
- tt_face_free_bdf_props( TT_Face face );
-
-
- FT_LOCAL( FT_Error )
- tt_face_find_bdf_prop( FT_Face face,
- const char* property_name,
- BDF_PropertyRec *aprop );
-
-#endif /* TT_CONFIG_OPTION_BDF */
-
-
-FT_END_HEADER
-
-#endif /* TTBDF_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/sfnt/ttcmap.c b/contrib/libs/freetype/src/sfnt/ttcmap.c
deleted file mode 100644
index 28f4d1173c..0000000000
--- a/contrib/libs/freetype/src/sfnt/ttcmap.c
+++ /dev/null
@@ -1,3902 +0,0 @@
-/****************************************************************************
- *
- * ttcmap.c
- *
- * TrueType character mapping table (cmap) support (body).
- *
- * Copyright (C) 2002-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftdebug.h>
-
-#include "sferrors.h" /* must come before `ftvalid.h' */
-
-#include <freetype/internal/ftvalid.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/internal/services/svpscmap.h>
-#include "ttload.h"
-#include "ttcmap.h"
-#include "ttpost.h"
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT ttcmap
-
-
-#define TT_PEEK_SHORT FT_PEEK_SHORT
-#define TT_PEEK_USHORT FT_PEEK_USHORT
-#define TT_PEEK_UINT24 FT_PEEK_UOFF3
-#define TT_PEEK_LONG FT_PEEK_LONG
-#define TT_PEEK_ULONG FT_PEEK_ULONG
-
-#define TT_NEXT_SHORT FT_NEXT_SHORT
-#define TT_NEXT_USHORT FT_NEXT_USHORT
-#define TT_NEXT_UINT24 FT_NEXT_UOFF3
-#define TT_NEXT_LONG FT_NEXT_LONG
-#define TT_NEXT_ULONG FT_NEXT_ULONG
-
-
- /* Too large glyph index return values are caught in `FT_Get_Char_Index' */
- /* and `FT_Get_Next_Char' (the latter calls the internal `next' function */
- /* again in this case). To mark character code return values as invalid */
- /* it is sufficient to set the corresponding glyph index return value to */
- /* zero. */
-
-
- FT_CALLBACK_DEF( FT_Error )
- tt_cmap_init( FT_CMap cmap, /* TT_CMap */
- void* table_ )
- {
- TT_CMap ttcmap = (TT_CMap)cmap;
- FT_Byte* table = (FT_Byte*)table_;
-
-
- ttcmap->data = table;
- return FT_Err_Ok;
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** FORMAT 0 *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- /**************************************************************************
- *
- * TABLE OVERVIEW
- * --------------
- *
- * NAME OFFSET TYPE DESCRIPTION
- *
- * format 0 USHORT must be 0
- * length 2 USHORT table length in bytes
- * language 4 USHORT Mac language code
- * glyph_ids 6 BYTE[256] array of glyph indices
- * 262
- */
-
-#ifdef TT_CONFIG_CMAP_FORMAT_0
-
- FT_CALLBACK_DEF( FT_Error )
- tt_cmap0_validate( FT_Byte* table,
- FT_Validator valid )
- {
- FT_Byte* p;
- FT_UInt length;
-
-
- if ( table + 2 + 2 > valid->limit )
- FT_INVALID_TOO_SHORT;
-
- p = table + 2; /* skip format */
- length = TT_NEXT_USHORT( p );
-
- if ( table + length > valid->limit || length < 262 )
- FT_INVALID_TOO_SHORT;
-
- /* check glyph indices whenever necessary */
- if ( valid->level >= FT_VALIDATE_TIGHT )
- {
- FT_UInt n, idx;
-
-
- p = table + 6;
- for ( n = 0; n < 256; n++ )
- {
- idx = *p++;
- if ( idx >= TT_VALID_GLYPH_COUNT( valid ) )
- FT_INVALID_GLYPH_ID;
- }
- }
-
- return FT_Err_Ok;
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- tt_cmap0_char_index( FT_CMap cmap, /* TT_CMap */
- FT_UInt32 char_code )
- {
- TT_CMap ttcmap = (TT_CMap)cmap;
- FT_Byte* table = ttcmap->data;
-
-
- return char_code < 256 ? table[6 + char_code] : 0;
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- tt_cmap0_char_next( FT_CMap cmap, /* TT_CMap */
- FT_UInt32 *pchar_code )
- {
- TT_CMap ttcmap = (TT_CMap)cmap;
- FT_Byte* table = ttcmap->data;
- FT_UInt32 charcode = *pchar_code;
- FT_UInt32 result = 0;
- FT_UInt gindex = 0;
-
-
- table += 6; /* go to glyph IDs */
- while ( ++charcode < 256 )
- {
- gindex = table[charcode];
- if ( gindex != 0 )
- {
- result = charcode;
- break;
- }
- }
-
- *pchar_code = result;
- return gindex;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- tt_cmap0_get_info( FT_CharMap cmap, /* TT_CMap */
- TT_CMapInfo *cmap_info )
- {
- TT_CMap ttcmap = (TT_CMap)cmap;
- FT_Byte* p = ttcmap->data + 4;
-
-
- cmap_info->format = 0;
- cmap_info->language = (FT_ULong)TT_PEEK_USHORT( p );
-
- return FT_Err_Ok;
- }
-
-
- FT_DEFINE_TT_CMAP(
- tt_cmap0_class_rec,
-
- sizeof ( TT_CMapRec ),
-
- (FT_CMap_InitFunc) tt_cmap_init, /* init */
- (FT_CMap_DoneFunc) NULL, /* done */
- (FT_CMap_CharIndexFunc)tt_cmap0_char_index, /* char_index */
- (FT_CMap_CharNextFunc) tt_cmap0_char_next, /* char_next */
-
- (FT_CMap_CharVarIndexFunc) NULL, /* char_var_index */
- (FT_CMap_CharVarIsDefaultFunc)NULL, /* char_var_default */
- (FT_CMap_VariantListFunc) NULL, /* variant_list */
- (FT_CMap_CharVariantListFunc) NULL, /* charvariant_list */
- (FT_CMap_VariantCharListFunc) NULL, /* variantchar_list */
-
- 0,
- (TT_CMap_ValidateFunc)tt_cmap0_validate, /* validate */
- (TT_CMap_Info_GetFunc)tt_cmap0_get_info /* get_cmap_info */
- )
-
-#endif /* TT_CONFIG_CMAP_FORMAT_0 */
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** FORMAT 2 *****/
- /***** *****/
- /***** This is used for certain CJK encodings that encode text in a *****/
- /***** mixed 8/16 bits encoding along the following lines. *****/
- /***** *****/
- /***** * Certain byte values correspond to an 8-bit character code *****/
- /***** (typically in the range 0..127 for ASCII compatibility). *****/
- /***** *****/
- /***** * Certain byte values signal the first byte of a 2-byte *****/
- /***** character code (but these values are also valid as the *****/
- /***** second byte of a 2-byte character). *****/
- /***** *****/
- /***** The following charmap lookup and iteration functions all *****/
- /***** assume that the value `charcode' fulfills the following. *****/
- /***** *****/
- /***** - For one-byte characters, `charcode' is simply the *****/
- /***** character code. *****/
- /***** *****/
- /***** - For two-byte characters, `charcode' is the 2-byte *****/
- /***** character code in big endian format. More precisely: *****/
- /***** *****/
- /***** (charcode >> 8) is the first byte value *****/
- /***** (charcode & 0xFF) is the second byte value *****/
- /***** *****/
- /***** Note that not all values of `charcode' are valid according *****/
- /***** to these rules, and the function moderately checks the *****/
- /***** arguments. *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- /**************************************************************************
- *
- * TABLE OVERVIEW
- * --------------
- *
- * NAME OFFSET TYPE DESCRIPTION
- *
- * format 0 USHORT must be 2
- * length 2 USHORT table length in bytes
- * language 4 USHORT Mac language code
- * keys 6 USHORT[256] sub-header keys
- * subs 518 SUBHEAD[NSUBS] sub-headers array
- * glyph_ids 518+NSUB*8 USHORT[] glyph ID array
- *
- * The `keys' table is used to map charcode high bytes to sub-headers.
- * The value of `NSUBS' is the number of sub-headers defined in the
- * table and is computed by finding the maximum of the `keys' table.
- *
- * Note that for any `n', `keys[n]' is a byte offset within the `subs'
- * table, i.e., it is the corresponding sub-header index multiplied
- * by 8.
- *
- * Each sub-header has the following format.
- *
- * NAME OFFSET TYPE DESCRIPTION
- *
- * first 0 USHORT first valid low-byte
- * count 2 USHORT number of valid low-bytes
- * delta 4 SHORT see below
- * offset 6 USHORT see below
- *
- * A sub-header defines, for each high byte, the range of valid
- * low bytes within the charmap. Note that the range defined by `first'
- * and `count' must be completely included in the interval [0..255]
- * according to the specification.
- *
- * If a character code is contained within a given sub-header, then
- * mapping it to a glyph index is done as follows.
- *
- * - The value of `offset' is read. This is a _byte_ distance from the
- * location of the `offset' field itself into a slice of the
- * `glyph_ids' table. Let's call it `slice' (it is a USHORT[], too).
- *
- * - The value `slice[char.lo - first]' is read. If it is 0, there is
- * no glyph for the charcode. Otherwise, the value of `delta' is
- * added to it (modulo 65536) to form a new glyph index.
- *
- * It is up to the validation routine to check that all offsets fall
- * within the glyph IDs table (and not within the `subs' table itself or
- * outside of the CMap).
- */
-
-#ifdef TT_CONFIG_CMAP_FORMAT_2
-
- FT_CALLBACK_DEF( FT_Error )
- tt_cmap2_validate( FT_Byte* table,
- FT_Validator valid )
- {
- FT_Byte* p;
- FT_UInt length;
-
- FT_UInt n, max_subs;
- FT_Byte* keys; /* keys table */
- FT_Byte* subs; /* sub-headers */
- FT_Byte* glyph_ids; /* glyph ID array */
-
-
- if ( table + 2 + 2 > valid->limit )
- FT_INVALID_TOO_SHORT;
-
- p = table + 2; /* skip format */
- length = TT_NEXT_USHORT( p );
-
- if ( table + length > valid->limit || length < 6 + 512 )
- FT_INVALID_TOO_SHORT;
-
- keys = table + 6;
-
- /* parse keys to compute sub-headers count */
- p = keys;
- max_subs = 0;
- for ( n = 0; n < 256; n++ )
- {
- FT_UInt idx = TT_NEXT_USHORT( p );
-
-
- /* value must be multiple of 8 */
- if ( valid->level >= FT_VALIDATE_PARANOID && ( idx & 7 ) != 0 )
- FT_INVALID_DATA;
-
- idx >>= 3;
-
- if ( idx > max_subs )
- max_subs = idx;
- }
-
- FT_ASSERT( p == table + 518 );
-
- subs = p;
- glyph_ids = subs + ( max_subs + 1 ) * 8;
- if ( glyph_ids > valid->limit )
- FT_INVALID_TOO_SHORT;
-
- /* parse sub-headers */
- for ( n = 0; n <= max_subs; n++ )
- {
- FT_UInt first_code, code_count, offset;
- FT_Int delta;
-
-
- first_code = TT_NEXT_USHORT( p );
- code_count = TT_NEXT_USHORT( p );
- delta = TT_NEXT_SHORT( p );
- offset = TT_NEXT_USHORT( p );
-
- /* many Dynalab fonts have empty sub-headers */
- if ( code_count == 0 )
- continue;
-
- /* check range within 0..255 */
- if ( valid->level >= FT_VALIDATE_PARANOID )
- {
- if ( first_code >= 256 || code_count > 256 - first_code )
- FT_INVALID_DATA;
- }
-
- /* check offset */
- if ( offset != 0 )
- {
- FT_Byte* ids;
-
-
- ids = p - 2 + offset;
- if ( ids < glyph_ids || ids + code_count * 2 > table + length )
- FT_INVALID_OFFSET;
-
- /* check glyph IDs */
- if ( valid->level >= FT_VALIDATE_TIGHT )
- {
- FT_Byte* limit = p + code_count * 2;
- FT_UInt idx;
-
-
- for ( ; p < limit; )
- {
- idx = TT_NEXT_USHORT( p );
- if ( idx != 0 )
- {
- idx = (FT_UInt)( (FT_Int)idx + delta ) & 0xFFFFU;
- if ( idx >= TT_VALID_GLYPH_COUNT( valid ) )
- FT_INVALID_GLYPH_ID;
- }
- }
- }
- }
- }
-
- return FT_Err_Ok;
- }
-
-
- /* return sub header corresponding to a given character code */
- /* NULL on invalid charcode */
- static FT_Byte*
- tt_cmap2_get_subheader( FT_Byte* table,
- FT_UInt32 char_code )
- {
- FT_Byte* result = NULL;
-
-
- if ( char_code < 0x10000UL )
- {
- FT_UInt char_lo = (FT_UInt)( char_code & 0xFF );
- FT_UInt char_hi = (FT_UInt)( char_code >> 8 );
- FT_Byte* p = table + 6; /* keys table */
- FT_Byte* subs = table + 518; /* subheaders table */
- FT_Byte* sub;
-
-
- if ( char_hi == 0 )
- {
- /* an 8-bit character code -- we use subHeader 0 in this case */
- /* to test whether the character code is in the charmap */
- /* */
- sub = subs; /* jump to first sub-header */
-
- /* check that the sub-header for this byte is 0, which */
- /* indicates that it is really a valid one-byte value; */
- /* otherwise, return 0 */
- /* */
- p += char_lo * 2;
- if ( TT_PEEK_USHORT( p ) != 0 )
- goto Exit;
- }
- else
- {
- /* a 16-bit character code */
-
- /* jump to key entry */
- p += char_hi * 2;
- /* jump to sub-header */
- sub = subs + ( FT_PAD_FLOOR( TT_PEEK_USHORT( p ), 8 ) );
-
- /* check that the high byte isn't a valid one-byte value */
- if ( sub == subs )
- goto Exit;
- }
-
- result = sub;
- }
-
- Exit:
- return result;
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- tt_cmap2_char_index( FT_CMap cmap, /* TT_CMap */
- FT_UInt32 char_code )
- {
- TT_CMap ttcmap = (TT_CMap)cmap;
- FT_Byte* table = ttcmap->data;
- FT_UInt result = 0;
- FT_Byte* subheader;
-
-
- subheader = tt_cmap2_get_subheader( table, char_code );
- if ( subheader )
- {
- FT_Byte* p = subheader;
- FT_UInt idx = (FT_UInt)( char_code & 0xFF );
- FT_UInt start, count;
- FT_Int delta;
- FT_UInt offset;
-
-
- start = TT_NEXT_USHORT( p );
- count = TT_NEXT_USHORT( p );
- delta = TT_NEXT_SHORT ( p );
- offset = TT_PEEK_USHORT( p );
-
- idx -= start;
- if ( idx < count && offset != 0 )
- {
- p += offset + 2 * idx;
- idx = TT_PEEK_USHORT( p );
-
- if ( idx != 0 )
- result = (FT_UInt)( (FT_Int)idx + delta ) & 0xFFFFU;
- }
- }
-
- return result;
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- tt_cmap2_char_next( FT_CMap cmap, /* TT_CMap */
- FT_UInt32 *pcharcode )
- {
- TT_CMap ttcmap = (TT_CMap)cmap;
- FT_Byte* table = ttcmap->data;
- FT_UInt gindex = 0;
- FT_UInt32 result = 0;
- FT_UInt32 charcode = *pcharcode + 1;
- FT_Byte* subheader;
-
-
- while ( charcode < 0x10000UL )
- {
- subheader = tt_cmap2_get_subheader( table, charcode );
- if ( subheader )
- {
- FT_Byte* p = subheader;
- FT_UInt start = TT_NEXT_USHORT( p );
- FT_UInt count = TT_NEXT_USHORT( p );
- FT_Int delta = TT_NEXT_SHORT ( p );
- FT_UInt offset = TT_PEEK_USHORT( p );
- FT_UInt char_lo = (FT_UInt)( charcode & 0xFF );
- FT_UInt pos, idx;
-
-
- if ( char_lo >= start + count && charcode <= 0xFF )
- {
- /* this happens only for a malformed cmap */
- charcode = 0x100;
- continue;
- }
-
- if ( offset == 0 )
- {
- if ( charcode == 0x100 )
- goto Exit; /* this happens only for a malformed cmap */
- goto Next_SubHeader;
- }
-
- if ( char_lo < start )
- {
- char_lo = start;
- pos = 0;
- }
- else
- pos = (FT_UInt)( char_lo - start );
-
- p += offset + pos * 2;
- charcode = FT_PAD_FLOOR( charcode, 256 ) + char_lo;
-
- for ( ; pos < count; pos++, charcode++ )
- {
- idx = TT_NEXT_USHORT( p );
-
- if ( idx != 0 )
- {
- gindex = (FT_UInt)( (FT_Int)idx + delta ) & 0xFFFFU;
- if ( gindex != 0 )
- {
- result = charcode;
- goto Exit;
- }
- }
- }
-
- /* if unsuccessful, avoid `charcode' leaving */
- /* the current 256-character block */
- if ( count )
- charcode--;
- }
-
- /* If `charcode' is <= 0xFF, retry with `charcode + 1'. */
- /* Otherwise jump to the next 256-character block and retry. */
- Next_SubHeader:
- if ( charcode <= 0xFF )
- charcode++;
- else
- charcode = FT_PAD_FLOOR( charcode, 0x100 ) + 0x100;
- }
-
- Exit:
- *pcharcode = result;
-
- return gindex;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- tt_cmap2_get_info( FT_CharMap cmap, /* TT_CMap */
- TT_CMapInfo *cmap_info )
- {
- TT_CMap ttcmap = (TT_CMap)cmap;
- FT_Byte* p = ttcmap->data + 4;
-
-
- cmap_info->format = 2;
- cmap_info->language = (FT_ULong)TT_PEEK_USHORT( p );
-
- return FT_Err_Ok;
- }
-
-
- FT_DEFINE_TT_CMAP(
- tt_cmap2_class_rec,
-
- sizeof ( TT_CMapRec ),
-
- (FT_CMap_InitFunc) tt_cmap_init, /* init */
- (FT_CMap_DoneFunc) NULL, /* done */
- (FT_CMap_CharIndexFunc)tt_cmap2_char_index, /* char_index */
- (FT_CMap_CharNextFunc) tt_cmap2_char_next, /* char_next */
-
- (FT_CMap_CharVarIndexFunc) NULL, /* char_var_index */
- (FT_CMap_CharVarIsDefaultFunc)NULL, /* char_var_default */
- (FT_CMap_VariantListFunc) NULL, /* variant_list */
- (FT_CMap_CharVariantListFunc) NULL, /* charvariant_list */
- (FT_CMap_VariantCharListFunc) NULL, /* variantchar_list */
-
- 2,
- (TT_CMap_ValidateFunc)tt_cmap2_validate, /* validate */
- (TT_CMap_Info_GetFunc)tt_cmap2_get_info /* get_cmap_info */
- )
-
-#endif /* TT_CONFIG_CMAP_FORMAT_2 */
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** FORMAT 4 *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- /**************************************************************************
- *
- * TABLE OVERVIEW
- * --------------
- *
- * NAME OFFSET TYPE DESCRIPTION
- *
- * format 0 USHORT must be 4
- * length 2 USHORT table length
- * in bytes
- * language 4 USHORT Mac language code
- *
- * segCountX2 6 USHORT 2*NUM_SEGS
- * searchRange 8 USHORT 2*(1 << LOG_SEGS)
- * entrySelector 10 USHORT LOG_SEGS
- * rangeShift 12 USHORT segCountX2 -
- * searchRange
- *
- * endCount 14 USHORT[NUM_SEGS] end charcode for
- * each segment; last
- * is 0xFFFF
- *
- * pad 14+NUM_SEGS*2 USHORT padding
- *
- * startCount 16+NUM_SEGS*2 USHORT[NUM_SEGS] first charcode for
- * each segment
- *
- * idDelta 16+NUM_SEGS*4 SHORT[NUM_SEGS] delta for each
- * segment
- * idOffset 16+NUM_SEGS*6 SHORT[NUM_SEGS] range offset for
- * each segment; can be
- * zero
- *
- * glyphIds 16+NUM_SEGS*8 USHORT[] array of glyph ID
- * ranges
- *
- * Character codes are modelled by a series of ordered (increasing)
- * intervals called segments. Each segment has start and end codes,
- * provided by the `startCount' and `endCount' arrays. Segments must
- * not overlap, and the last segment should always contain the value
- * 0xFFFF for `endCount'.
- *
- * The fields `searchRange', `entrySelector' and `rangeShift' are better
- * ignored (they are traces of over-engineering in the TrueType
- * specification).
- *
- * Each segment also has a signed `delta', as well as an optional offset
- * within the `glyphIds' table.
- *
- * If a segment's idOffset is 0, the glyph index corresponding to any
- * charcode within the segment is obtained by adding the value of
- * `idDelta' directly to the charcode, modulo 65536.
- *
- * Otherwise, a glyph index is taken from the glyph IDs sub-array for
- * the segment, and the value of `idDelta' is added to it.
- *
- *
- * Finally, note that a lot of fonts contain an invalid last segment,
- * where `start' and `end' are correctly set to 0xFFFF but both `delta'
- * and `offset' are incorrect (e.g., `opens___.ttf' which comes with
- * OpenOffice.org). We need special code to deal with them correctly.
- */
-
-#ifdef TT_CONFIG_CMAP_FORMAT_4
-
- typedef struct TT_CMap4Rec_
- {
- TT_CMapRec cmap;
- FT_UInt32 cur_charcode; /* current charcode */
- FT_UInt cur_gindex; /* current glyph index */
-
- FT_UInt num_ranges;
- FT_UInt cur_range;
- FT_UInt cur_start;
- FT_UInt cur_end;
- FT_Int cur_delta;
- FT_Byte* cur_values;
-
- } TT_CMap4Rec, *TT_CMap4;
-
-
- FT_CALLBACK_DEF( FT_Error )
- tt_cmap4_init( FT_CMap cmap, /* TT_CMap4 */
- void* table_ )
- {
- TT_CMap4 ttcmap = (TT_CMap4)cmap;
- FT_Byte* table = (FT_Byte*)table_;
- FT_Byte* p;
-
-
- ttcmap->cmap.data = table;
-
- p = table + 6;
- ttcmap->num_ranges = FT_PEEK_USHORT( p ) >> 1;
- ttcmap->cur_charcode = (FT_UInt32)0xFFFFFFFFUL;
- ttcmap->cur_gindex = 0;
-
- return FT_Err_Ok;
- }
-
-
- static FT_Int
- tt_cmap4_set_range( TT_CMap4 cmap,
- FT_UInt range_index )
- {
- FT_Byte* table = cmap->cmap.data;
- FT_Byte* p;
- FT_UInt num_ranges = cmap->num_ranges;
-
-
- while ( range_index < num_ranges )
- {
- FT_UInt offset;
-
-
- p = table + 14 + range_index * 2;
- cmap->cur_end = FT_PEEK_USHORT( p );
-
- p += 2 + num_ranges * 2;
- cmap->cur_start = FT_PEEK_USHORT( p );
-
- p += num_ranges * 2;
- cmap->cur_delta = FT_PEEK_SHORT( p );
-
- p += num_ranges * 2;
- offset = FT_PEEK_USHORT( p );
-
- /* some fonts have an incorrect last segment; */
- /* we have to catch it */
- if ( range_index >= num_ranges - 1 &&
- cmap->cur_start == 0xFFFFU &&
- cmap->cur_end == 0xFFFFU )
- {
- TT_Face face = (TT_Face)FT_CMAP_FACE( cmap );
- FT_Byte* limit = face->cmap_table + face->cmap_size;
-
-
- if ( offset && p + offset + 2 > limit )
- {
- cmap->cur_delta = 1;
- offset = 0;
- }
- }
-
- if ( offset != 0xFFFFU )
- {
- cmap->cur_values = offset ? p + offset : NULL;
- cmap->cur_range = range_index;
- return 0;
- }
-
- /* we skip empty segments */
- range_index++;
- }
-
- return -1;
- }
-
-
- /* search the index of the charcode next to cmap->cur_charcode; */
- /* caller should call tt_cmap4_set_range with proper range */
- /* before calling this function */
- /* */
- static void
- tt_cmap4_next( TT_CMap4 cmap )
- {
- TT_Face face = (TT_Face)FT_CMAP_FACE( cmap );
- FT_Byte* limit = face->cmap_table + face->cmap_size;
-
- FT_UInt charcode;
-
-
- charcode = (FT_UInt)cmap->cur_charcode + 1;
-
- if ( charcode < cmap->cur_start )
- charcode = cmap->cur_start;
-
- for (;;)
- {
- FT_Byte* values = cmap->cur_values;
- FT_UInt end = cmap->cur_end;
- FT_Int delta = cmap->cur_delta;
-
-
- if ( charcode <= end )
- {
- if ( values )
- {
- FT_Byte* p = values + 2 * ( charcode - cmap->cur_start );
-
-
- /* if p > limit, the whole segment is invalid */
- if ( p > limit )
- goto Next_Segment;
-
- do
- {
- FT_UInt gindex = FT_NEXT_USHORT( p );
-
-
- if ( gindex )
- {
- gindex = (FT_UInt)( (FT_Int)gindex + delta ) & 0xFFFFU;
- if ( gindex )
- {
- cmap->cur_charcode = charcode;
- cmap->cur_gindex = gindex;
- return;
- }
- }
- } while ( ++charcode <= end );
- }
- else
- {
- do
- {
- FT_UInt gindex = (FT_UInt)( (FT_Int)charcode + delta ) & 0xFFFFU;
-
-
- if ( gindex >= (FT_UInt)face->root.num_glyphs )
- {
- /* we have an invalid glyph index; if there is an overflow, */
- /* we can adjust `charcode', otherwise the whole segment is */
- /* invalid */
- gindex = 0;
-
- if ( (FT_Int)charcode + delta < 0 &&
- (FT_Int)end + delta >= 0 )
- charcode = (FT_UInt)( -delta );
-
- else if ( (FT_Int)charcode + delta < 0x10000L &&
- (FT_Int)end + delta >= 0x10000L )
- charcode = (FT_UInt)( 0x10000L - delta );
-
- else
- goto Next_Segment;
- }
-
- if ( gindex )
- {
- cmap->cur_charcode = charcode;
- cmap->cur_gindex = gindex;
- return;
- }
- } while ( ++charcode <= end );
- }
- }
-
- Next_Segment:
- /* we need to find another range */
- if ( tt_cmap4_set_range( cmap, cmap->cur_range + 1 ) < 0 )
- break;
-
- if ( charcode < cmap->cur_start )
- charcode = cmap->cur_start;
- }
-
- cmap->cur_charcode = (FT_UInt32)0xFFFFFFFFUL;
- cmap->cur_gindex = 0;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- tt_cmap4_validate( FT_Byte* table,
- FT_Validator valid )
- {
- FT_Byte* p;
- FT_UInt length;
-
- FT_Byte *ends, *starts, *offsets, *deltas, *glyph_ids;
- FT_UInt num_segs;
- FT_Error error = FT_Err_Ok;
-
-
- if ( table + 2 + 2 > valid->limit )
- FT_INVALID_TOO_SHORT;
-
- p = table + 2; /* skip format */
- length = TT_NEXT_USHORT( p );
-
- /* in certain fonts, the `length' field is invalid and goes */
- /* out of bound. We try to correct this here... */
- if ( table + length > valid->limit )
- {
- if ( valid->level >= FT_VALIDATE_TIGHT )
- FT_INVALID_TOO_SHORT;
-
- length = (FT_UInt)( valid->limit - table );
- }
-
- /* it also happens that the `length' field is too small; */
- /* this is easy to correct */
- if ( length < (FT_UInt)( valid->limit - table ) )
- {
- if ( valid->level >= FT_VALIDATE_PARANOID )
- FT_INVALID_DATA;
-
- length = (FT_UInt)( valid->limit - table );
- }
-
- if ( length < 16 )
- FT_INVALID_TOO_SHORT;
-
- p = table + 6;
- num_segs = TT_NEXT_USHORT( p ); /* read segCountX2 */
-
- if ( valid->level >= FT_VALIDATE_PARANOID )
- {
- /* check that we have an even value here */
- if ( num_segs & 1 )
- FT_INVALID_DATA;
- }
-
- num_segs /= 2;
-
- if ( length < 16 + num_segs * 2 * 4 )
- FT_INVALID_TOO_SHORT;
-
- /* check the search parameters - even though we never use them */
- /* */
- if ( valid->level >= FT_VALIDATE_PARANOID )
- {
- /* check the values of `searchRange', `entrySelector', `rangeShift' */
- FT_UInt search_range = TT_NEXT_USHORT( p );
- FT_UInt entry_selector = TT_NEXT_USHORT( p );
- FT_UInt range_shift = TT_NEXT_USHORT( p );
-
-
- if ( ( search_range | range_shift ) & 1 ) /* must be even values */
- FT_INVALID_DATA;
-
- search_range /= 2;
- range_shift /= 2;
-
- /* `search range' is the greatest power of 2 that is <= num_segs */
-
- if ( search_range > num_segs ||
- search_range * 2 < num_segs ||
- search_range + range_shift != num_segs ||
- search_range != ( 1U << entry_selector ) )
- FT_INVALID_DATA;
- }
-
- ends = table + 14;
- starts = table + 16 + num_segs * 2;
- deltas = starts + num_segs * 2;
- offsets = deltas + num_segs * 2;
- glyph_ids = offsets + num_segs * 2;
-
- /* check last segment; its end count value must be 0xFFFF */
- if ( valid->level >= FT_VALIDATE_PARANOID )
- {
- p = ends + ( num_segs - 1 ) * 2;
- if ( TT_PEEK_USHORT( p ) != 0xFFFFU )
- FT_INVALID_DATA;
- }
-
- {
- FT_UInt start, end, offset, n;
- FT_UInt last_start = 0, last_end = 0;
- FT_Int delta;
- FT_Byte* p_start = starts;
- FT_Byte* p_end = ends;
- FT_Byte* p_delta = deltas;
- FT_Byte* p_offset = offsets;
-
-
- for ( n = 0; n < num_segs; n++ )
- {
- p = p_offset;
- start = TT_NEXT_USHORT( p_start );
- end = TT_NEXT_USHORT( p_end );
- delta = TT_NEXT_SHORT( p_delta );
- offset = TT_NEXT_USHORT( p_offset );
-
- if ( start > end )
- FT_INVALID_DATA;
-
- /* this test should be performed at default validation level; */
- /* unfortunately, some popular Asian fonts have overlapping */
- /* ranges in their charmaps */
- /* */
- if ( start <= last_end && n > 0 )
- {
- if ( valid->level >= FT_VALIDATE_TIGHT )
- FT_INVALID_DATA;
- else
- {
- /* allow overlapping segments, provided their start points */
- /* and end points, respectively, are in ascending order */
- /* */
- if ( last_start > start || last_end > end )
- error |= TT_CMAP_FLAG_UNSORTED;
- else
- error |= TT_CMAP_FLAG_OVERLAPPING;
- }
- }
-
- if ( offset && offset != 0xFFFFU )
- {
- p += offset; /* start of glyph ID array */
-
- /* check that we point within the glyph IDs table only */
- if ( valid->level >= FT_VALIDATE_TIGHT )
- {
- if ( p < glyph_ids ||
- p + ( end - start + 1 ) * 2 > table + length )
- FT_INVALID_DATA;
- }
- /* Some fonts handle the last segment incorrectly. In */
- /* theory, 0xFFFF might point to an ordinary glyph -- */
- /* a cmap 4 is versatile and could be used for any */
- /* encoding, not only Unicode. However, reality shows */
- /* that far too many fonts are sloppy and incorrectly */
- /* set all fields but `start' and `end' for the last */
- /* segment if it contains only a single character. */
- /* */
- /* We thus omit the test here, delaying it to the */
- /* routines that actually access the cmap. */
- else if ( n != num_segs - 1 ||
- !( start == 0xFFFFU && end == 0xFFFFU ) )
- {
- if ( p < glyph_ids ||
- p + ( end - start + 1 ) * 2 > valid->limit )
- FT_INVALID_DATA;
- }
-
- /* check glyph indices within the segment range */
- if ( valid->level >= FT_VALIDATE_TIGHT )
- {
- FT_UInt i, idx;
-
-
- for ( i = start; i < end; i++ )
- {
- idx = FT_NEXT_USHORT( p );
- if ( idx != 0 )
- {
- idx = (FT_UInt)( (FT_Int)idx + delta ) & 0xFFFFU;
-
- if ( idx >= TT_VALID_GLYPH_COUNT( valid ) )
- FT_INVALID_GLYPH_ID;
- }
- }
- }
- }
- else if ( offset == 0xFFFFU )
- {
- /* some fonts (erroneously?) use a range offset of 0xFFFF */
- /* to mean missing glyph in cmap table */
- /* */
- if ( valid->level >= FT_VALIDATE_PARANOID ||
- n != num_segs - 1 ||
- !( start == 0xFFFFU && end == 0xFFFFU ) )
- FT_INVALID_DATA;
- }
-
- last_start = start;
- last_end = end;
- }
- }
-
- return error;
- }
-
-
- static FT_UInt
- tt_cmap4_char_map_linear( TT_CMap cmap,
- FT_UInt32* pcharcode,
- FT_Bool next )
- {
- TT_Face face = (TT_Face)FT_CMAP_FACE( cmap );
- FT_Byte* limit = face->cmap_table + face->cmap_size;
-
-
- FT_UInt num_segs2, start, end, offset;
- FT_Int delta;
- FT_UInt i, num_segs;
- FT_UInt32 charcode = *pcharcode + next;
- FT_UInt gindex = 0;
- FT_Byte* p;
- FT_Byte* q;
-
-
- p = cmap->data + 6;
- num_segs = TT_PEEK_USHORT( p ) >> 1;
-
- if ( !num_segs )
- return 0;
-
- num_segs2 = num_segs << 1;
-
- /* linear search */
- p = cmap->data + 14; /* ends table */
- q = cmap->data + 16 + num_segs2; /* starts table */
-
- for ( i = 0; i < num_segs; i++ )
- {
- end = TT_NEXT_USHORT( p );
- start = TT_NEXT_USHORT( q );
-
- if ( charcode < start )
- {
- if ( next )
- charcode = start;
- else
- break;
- }
-
- Again:
- if ( charcode <= end )
- {
- FT_Byte* r;
-
-
- r = q - 2 + num_segs2;
- delta = TT_PEEK_SHORT( r );
- r += num_segs2;
- offset = TT_PEEK_USHORT( r );
-
- /* some fonts have an incorrect last segment; */
- /* we have to catch it */
- if ( i >= num_segs - 1 &&
- start == 0xFFFFU && end == 0xFFFFU )
- {
- if ( offset && r + offset + 2 > limit )
- {
- delta = 1;
- offset = 0;
- }
- }
-
- if ( offset == 0xFFFFU )
- continue;
-
- if ( offset )
- {
- r += offset + ( charcode - start ) * 2;
-
- /* if r > limit, the whole segment is invalid */
- if ( next && r > limit )
- continue;
-
- gindex = TT_PEEK_USHORT( r );
- if ( gindex )
- {
- gindex = (FT_UInt)( (FT_Int)gindex + delta ) & 0xFFFFU;
- if ( gindex >= (FT_UInt)face->root.num_glyphs )
- gindex = 0;
- }
- }
- else
- {
- gindex = (FT_UInt)( (FT_Int)charcode + delta ) & 0xFFFFU;
-
- if ( next && gindex >= (FT_UInt)face->root.num_glyphs )
- {
- /* we have an invalid glyph index; if there is an overflow, */
- /* we can adjust `charcode', otherwise the whole segment is */
- /* invalid */
- gindex = 0;
-
- if ( (FT_Int)charcode + delta < 0 &&
- (FT_Int)end + delta >= 0 )
- charcode = (FT_UInt)( -delta );
-
- else if ( (FT_Int)charcode + delta < 0x10000L &&
- (FT_Int)end + delta >= 0x10000L )
- charcode = (FT_UInt)( 0x10000L - delta );
-
- else
- continue;
- }
- }
-
- if ( next && !gindex )
- {
- if ( charcode >= 0xFFFFU )
- break;
-
- charcode++;
- goto Again;
- }
-
- break;
- }
- }
-
- if ( next )
- *pcharcode = charcode;
-
- return gindex;
- }
-
-
- static FT_UInt
- tt_cmap4_char_map_binary( TT_CMap cmap,
- FT_UInt32* pcharcode,
- FT_Bool next )
- {
- TT_Face face = (TT_Face)FT_CMAP_FACE( cmap );
- FT_Byte* limit = face->cmap_table + face->cmap_size;
-
- FT_UInt num_segs2, start, end, offset;
- FT_Int delta;
- FT_UInt max, min, mid, num_segs;
- FT_UInt charcode = (FT_UInt)*pcharcode + next;
- FT_UInt gindex = 0;
- FT_Byte* p;
-
-
- p = cmap->data + 6;
- num_segs = TT_PEEK_USHORT( p ) >> 1;
-
- if ( !num_segs )
- return 0;
-
- num_segs2 = num_segs << 1;
-
- min = 0;
- max = num_segs;
-
- /* binary search */
- do
- {
- mid = ( min + max ) >> 1;
- p = cmap->data + 14 + mid * 2;
- end = TT_PEEK_USHORT( p );
- p += 2 + num_segs2;
- start = TT_PEEK_USHORT( p );
-
- if ( charcode < start )
- max = mid;
- else if ( charcode > end )
- min = mid + 1;
- else
- {
- p += num_segs2;
- delta = TT_PEEK_SHORT( p );
- p += num_segs2;
- offset = TT_PEEK_USHORT( p );
-
- /* some fonts have an incorrect last segment; */
- /* we have to catch it */
- if ( mid >= num_segs - 1 &&
- start == 0xFFFFU && end == 0xFFFFU )
- {
- if ( offset && p + offset + 2 > limit )
- {
- delta = 1;
- offset = 0;
- }
- }
-
- /* search the first segment containing `charcode' */
- if ( cmap->flags & TT_CMAP_FLAG_OVERLAPPING )
- {
- FT_UInt i;
-
-
- /* call the current segment `max' */
- max = mid;
-
- if ( offset == 0xFFFFU )
- mid = max + 1;
-
- /* search in segments before the current segment */
- for ( i = max; i > 0; i-- )
- {
- FT_UInt prev_end;
- FT_Byte* old_p;
-
-
- old_p = p;
- p = cmap->data + 14 + ( i - 1 ) * 2;
- prev_end = TT_PEEK_USHORT( p );
-
- if ( charcode > prev_end )
- {
- p = old_p;
- break;
- }
-
- end = prev_end;
- p += 2 + num_segs2;
- start = TT_PEEK_USHORT( p );
- p += num_segs2;
- delta = TT_PEEK_SHORT( p );
- p += num_segs2;
- offset = TT_PEEK_USHORT( p );
-
- if ( offset != 0xFFFFU )
- mid = i - 1;
- }
-
- /* no luck */
- if ( mid == max + 1 )
- {
- if ( i != max )
- {
- p = cmap->data + 14 + max * 2;
- end = TT_PEEK_USHORT( p );
- p += 2 + num_segs2;
- start = TT_PEEK_USHORT( p );
- p += num_segs2;
- delta = TT_PEEK_SHORT( p );
- p += num_segs2;
- offset = TT_PEEK_USHORT( p );
- }
-
- mid = max;
-
- /* search in segments after the current segment */
- for ( i = max + 1; i < num_segs; i++ )
- {
- FT_UInt next_end, next_start;
-
-
- p = cmap->data + 14 + i * 2;
- next_end = TT_PEEK_USHORT( p );
- p += 2 + num_segs2;
- next_start = TT_PEEK_USHORT( p );
-
- if ( charcode < next_start )
- break;
-
- end = next_end;
- start = next_start;
- p += num_segs2;
- delta = TT_PEEK_SHORT( p );
- p += num_segs2;
- offset = TT_PEEK_USHORT( p );
-
- if ( offset != 0xFFFFU )
- mid = i;
- }
- i--;
-
- /* still no luck */
- if ( mid == max )
- {
- mid = i;
-
- break;
- }
- }
-
- /* end, start, delta, and offset are for the i'th segment */
- if ( mid != i )
- {
- p = cmap->data + 14 + mid * 2;
- end = TT_PEEK_USHORT( p );
- p += 2 + num_segs2;
- start = TT_PEEK_USHORT( p );
- p += num_segs2;
- delta = TT_PEEK_SHORT( p );
- p += num_segs2;
- offset = TT_PEEK_USHORT( p );
- }
- }
- else
- {
- if ( offset == 0xFFFFU )
- break;
- }
-
- if ( offset )
- {
- p += offset + ( charcode - start ) * 2;
-
- /* if p > limit, the whole segment is invalid */
- if ( next && p > limit )
- break;
-
- gindex = TT_PEEK_USHORT( p );
- if ( gindex )
- {
- gindex = (FT_UInt)( (FT_Int)gindex + delta ) & 0xFFFFU;
- if ( gindex >= (FT_UInt)face->root.num_glyphs )
- gindex = 0;
- }
- }
- else
- {
- gindex = (FT_UInt)( (FT_Int)charcode + delta ) & 0xFFFFU;
-
- if ( next && gindex >= (FT_UInt)face->root.num_glyphs )
- {
- /* we have an invalid glyph index; if there is an overflow, */
- /* we can adjust `charcode', otherwise the whole segment is */
- /* invalid */
- gindex = 0;
-
- if ( (FT_Int)charcode + delta < 0 &&
- (FT_Int)end + delta >= 0 )
- charcode = (FT_UInt)( -delta );
-
- else if ( (FT_Int)charcode + delta < 0x10000L &&
- (FT_Int)end + delta >= 0x10000L )
- charcode = (FT_UInt)( 0x10000L - delta );
- }
- }
-
- break;
- }
- }
- while ( min < max );
-
- if ( next )
- {
- TT_CMap4 cmap4 = (TT_CMap4)cmap;
-
-
- /* if `charcode' is not in any segment, then `mid' is */
- /* the segment nearest to `charcode' */
-
- if ( charcode > end && ++mid == num_segs )
- return 0;
-
- if ( tt_cmap4_set_range( cmap4, mid ) )
- {
- if ( gindex )
- *pcharcode = charcode;
- }
- else
- {
- cmap4->cur_charcode = charcode;
-
- if ( gindex )
- cmap4->cur_gindex = gindex;
- else
- {
- tt_cmap4_next( cmap4 );
- gindex = cmap4->cur_gindex;
- }
-
- if ( gindex )
- *pcharcode = cmap4->cur_charcode;
- }
- }
-
- return gindex;
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- tt_cmap4_char_index( FT_CMap cmap, /* TT_CMap */
- FT_UInt32 char_code )
- {
- TT_CMap ttcmap = (TT_CMap)cmap;
-
-
- if ( char_code >= 0x10000UL )
- return 0;
-
- if ( ttcmap->flags & TT_CMAP_FLAG_UNSORTED )
- return tt_cmap4_char_map_linear( ttcmap, &char_code, 0 );
- else
- return tt_cmap4_char_map_binary( ttcmap, &char_code, 0 );
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- tt_cmap4_char_next( FT_CMap cmap, /* TT_CMap */
- FT_UInt32 *pchar_code )
- {
- TT_CMap ttcmap = (TT_CMap)cmap;
- FT_UInt gindex;
-
-
- if ( *pchar_code >= 0xFFFFU )
- return 0;
-
- if ( ttcmap->flags & TT_CMAP_FLAG_UNSORTED )
- gindex = tt_cmap4_char_map_linear( ttcmap, pchar_code, 1 );
- else
- {
- TT_CMap4 cmap4 = (TT_CMap4)cmap;
-
-
- /* no need to search */
- if ( *pchar_code == cmap4->cur_charcode )
- {
- tt_cmap4_next( cmap4 );
- gindex = cmap4->cur_gindex;
- if ( gindex )
- *pchar_code = cmap4->cur_charcode;
- }
- else
- gindex = tt_cmap4_char_map_binary( ttcmap, pchar_code, 1 );
- }
-
- return gindex;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- tt_cmap4_get_info( FT_CharMap cmap, /* TT_CMap */
- TT_CMapInfo *cmap_info )
- {
- TT_CMap ttcmap = (TT_CMap)cmap;
- FT_Byte* p = ttcmap->data + 4;
-
-
- cmap_info->format = 4;
- cmap_info->language = (FT_ULong)TT_PEEK_USHORT( p );
-
- return FT_Err_Ok;
- }
-
-
- FT_DEFINE_TT_CMAP(
- tt_cmap4_class_rec,
-
- sizeof ( TT_CMap4Rec ),
-
- (FT_CMap_InitFunc) tt_cmap4_init, /* init */
- (FT_CMap_DoneFunc) NULL, /* done */
- (FT_CMap_CharIndexFunc)tt_cmap4_char_index, /* char_index */
- (FT_CMap_CharNextFunc) tt_cmap4_char_next, /* char_next */
-
- (FT_CMap_CharVarIndexFunc) NULL, /* char_var_index */
- (FT_CMap_CharVarIsDefaultFunc)NULL, /* char_var_default */
- (FT_CMap_VariantListFunc) NULL, /* variant_list */
- (FT_CMap_CharVariantListFunc) NULL, /* charvariant_list */
- (FT_CMap_VariantCharListFunc) NULL, /* variantchar_list */
-
- 4,
- (TT_CMap_ValidateFunc)tt_cmap4_validate, /* validate */
- (TT_CMap_Info_GetFunc)tt_cmap4_get_info /* get_cmap_info */
- )
-
-#endif /* TT_CONFIG_CMAP_FORMAT_4 */
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** FORMAT 6 *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- /**************************************************************************
- *
- * TABLE OVERVIEW
- * --------------
- *
- * NAME OFFSET TYPE DESCRIPTION
- *
- * format 0 USHORT must be 6
- * length 2 USHORT table length in bytes
- * language 4 USHORT Mac language code
- *
- * first 6 USHORT first segment code
- * count 8 USHORT segment size in chars
- * glyphIds 10 USHORT[count] glyph IDs
- *
- * A very simplified segment mapping.
- */
-
-#ifdef TT_CONFIG_CMAP_FORMAT_6
-
- FT_CALLBACK_DEF( FT_Error )
- tt_cmap6_validate( FT_Byte* table,
- FT_Validator valid )
- {
- FT_Byte* p;
- FT_UInt length, count;
-
-
- if ( table + 10 > valid->limit )
- FT_INVALID_TOO_SHORT;
-
- p = table + 2;
- length = TT_NEXT_USHORT( p );
-
- p = table + 8; /* skip language and start index */
- count = TT_NEXT_USHORT( p );
-
- if ( table + length > valid->limit || length < 10 + count * 2 )
- FT_INVALID_TOO_SHORT;
-
- /* check glyph indices */
- if ( valid->level >= FT_VALIDATE_TIGHT )
- {
- FT_UInt gindex;
-
-
- for ( ; count > 0; count-- )
- {
- gindex = TT_NEXT_USHORT( p );
- if ( gindex >= TT_VALID_GLYPH_COUNT( valid ) )
- FT_INVALID_GLYPH_ID;
- }
- }
-
- return FT_Err_Ok;
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- tt_cmap6_char_index( FT_CMap cmap, /* TT_CMap */
- FT_UInt32 char_code )
- {
- TT_CMap ttcmap = (TT_CMap)cmap;
- FT_Byte* table = ttcmap->data;
- FT_UInt result = 0;
- FT_Byte* p = table + 6;
- FT_UInt start = TT_NEXT_USHORT( p );
- FT_UInt count = TT_NEXT_USHORT( p );
- FT_UInt idx = (FT_UInt)( char_code - start );
-
-
- if ( idx < count )
- {
- p += 2 * idx;
- result = TT_PEEK_USHORT( p );
- }
-
- return result;
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- tt_cmap6_char_next( FT_CMap cmap, /* TT_CMap */
- FT_UInt32 *pchar_code )
- {
- TT_CMap ttcmap = (TT_CMap)cmap;
- FT_Byte* table = ttcmap->data;
- FT_UInt32 result = 0;
- FT_UInt32 char_code = *pchar_code + 1;
- FT_UInt gindex = 0;
-
- FT_Byte* p = table + 6;
- FT_UInt start = TT_NEXT_USHORT( p );
- FT_UInt count = TT_NEXT_USHORT( p );
- FT_UInt idx;
-
-
- if ( char_code >= 0x10000UL )
- return 0;
-
- if ( char_code < start )
- char_code = start;
-
- idx = (FT_UInt)( char_code - start );
- p += 2 * idx;
-
- for ( ; idx < count; idx++ )
- {
- gindex = TT_NEXT_USHORT( p );
- if ( gindex != 0 )
- {
- result = char_code;
- break;
- }
-
- if ( char_code >= 0xFFFFU )
- return 0;
-
- char_code++;
- }
-
- *pchar_code = result;
- return gindex;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- tt_cmap6_get_info( FT_CharMap cmap, /* TT_CMap */
- TT_CMapInfo *cmap_info )
- {
- TT_CMap ttcmap = (TT_CMap)cmap;
- FT_Byte* p = ttcmap->data + 4;
-
-
- cmap_info->format = 6;
- cmap_info->language = (FT_ULong)TT_PEEK_USHORT( p );
-
- return FT_Err_Ok;
- }
-
-
- FT_DEFINE_TT_CMAP(
- tt_cmap6_class_rec,
-
- sizeof ( TT_CMapRec ),
-
- (FT_CMap_InitFunc) tt_cmap_init, /* init */
- (FT_CMap_DoneFunc) NULL, /* done */
- (FT_CMap_CharIndexFunc)tt_cmap6_char_index, /* char_index */
- (FT_CMap_CharNextFunc) tt_cmap6_char_next, /* char_next */
-
- (FT_CMap_CharVarIndexFunc) NULL, /* char_var_index */
- (FT_CMap_CharVarIsDefaultFunc)NULL, /* char_var_default */
- (FT_CMap_VariantListFunc) NULL, /* variant_list */
- (FT_CMap_CharVariantListFunc) NULL, /* charvariant_list */
- (FT_CMap_VariantCharListFunc) NULL, /* variantchar_list */
-
- 6,
- (TT_CMap_ValidateFunc)tt_cmap6_validate, /* validate */
- (TT_CMap_Info_GetFunc)tt_cmap6_get_info /* get_cmap_info */
- )
-
-#endif /* TT_CONFIG_CMAP_FORMAT_6 */
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** FORMAT 8 *****/
- /***** *****/
- /***** It is hard to completely understand what the OpenType spec *****/
- /***** says about this format, but here is my conclusion. *****/
- /***** *****/
- /***** The purpose of this format is to easily map UTF-16 text to *****/
- /***** glyph indices. Basically, the `char_code' must be in one of *****/
- /***** the following formats. *****/
- /***** *****/
- /***** - A 16-bit value that isn't part of the Unicode Surrogates *****/
- /***** Area (i.e. U+D800-U+DFFF). *****/
- /***** *****/
- /***** - A 32-bit value, made of two surrogate values, i.e.. if *****/
- /***** `char_code = (char_hi << 16) | char_lo', then both *****/
- /***** `char_hi' and `char_lo' must be in the Surrogates Area. *****/
- /***** Area. *****/
- /***** *****/
- /***** The `is32' table embedded in the charmap indicates whether a *****/
- /***** given 16-bit value is in the surrogates area or not. *****/
- /***** *****/
- /***** So, for any given `char_code', we can assert the following. *****/
- /***** *****/
- /***** If `char_hi == 0' then we must have `is32[char_lo] == 0'. *****/
- /***** *****/
- /***** If `char_hi != 0' then we must have both *****/
- /***** `is32[char_hi] != 0' and `is32[char_lo] != 0'. *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- /**************************************************************************
- *
- * TABLE OVERVIEW
- * --------------
- *
- * NAME OFFSET TYPE DESCRIPTION
- *
- * format 0 USHORT must be 8
- * reserved 2 USHORT reserved
- * length 4 ULONG length in bytes
- * language 8 ULONG Mac language code
- * is32 12 BYTE[8192] 32-bitness bitmap
- * count 8204 ULONG number of groups
- *
- * This header is followed by `count' groups of the following format:
- *
- * start 0 ULONG first charcode
- * end 4 ULONG last charcode
- * startId 8 ULONG start glyph ID for the group
- */
-
-#ifdef TT_CONFIG_CMAP_FORMAT_8
-
- FT_CALLBACK_DEF( FT_Error )
- tt_cmap8_validate( FT_Byte* table,
- FT_Validator valid )
- {
- FT_Byte* p = table + 4;
- FT_Byte* is32;
- FT_UInt32 length;
- FT_UInt32 num_groups;
-
-
- if ( table + 16 + 8192 > valid->limit )
- FT_INVALID_TOO_SHORT;
-
- length = TT_NEXT_ULONG( p );
- if ( length > (FT_UInt32)( valid->limit - table ) || length < 8192 + 16 )
- FT_INVALID_TOO_SHORT;
-
- is32 = table + 12;
- p = is32 + 8192; /* skip `is32' array */
- num_groups = TT_NEXT_ULONG( p );
-
- /* p + num_groups * 12 > valid->limit ? */
- if ( num_groups > (FT_UInt32)( valid->limit - p ) / 12 )
- FT_INVALID_TOO_SHORT;
-
- /* check groups, they must be in increasing order */
- {
- FT_UInt32 n, start, end, start_id, count, last = 0;
-
-
- for ( n = 0; n < num_groups; n++ )
- {
- FT_UInt hi, lo;
-
-
- start = TT_NEXT_ULONG( p );
- end = TT_NEXT_ULONG( p );
- start_id = TT_NEXT_ULONG( p );
-
- if ( start > end )
- FT_INVALID_DATA;
-
- if ( n > 0 && start <= last )
- FT_INVALID_DATA;
-
- if ( valid->level >= FT_VALIDATE_TIGHT )
- {
- FT_UInt32 d = end - start;
-
-
- /* start_id + end - start >= TT_VALID_GLYPH_COUNT( valid ) ? */
- if ( d > TT_VALID_GLYPH_COUNT( valid ) ||
- start_id >= TT_VALID_GLYPH_COUNT( valid ) - d )
- FT_INVALID_GLYPH_ID;
-
- count = (FT_UInt32)( end - start + 1 );
-
- if ( start & ~0xFFFFU )
- {
- /* start_hi != 0; check that is32[i] is 1 for each i in */
- /* the `hi' and `lo' of the range [start..end] */
- for ( ; count > 0; count--, start++ )
- {
- hi = (FT_UInt)( start >> 16 );
- lo = (FT_UInt)( start & 0xFFFFU );
-
- if ( (is32[hi >> 3] & ( 0x80 >> ( hi & 7 ) ) ) == 0 )
- FT_INVALID_DATA;
-
- if ( (is32[lo >> 3] & ( 0x80 >> ( lo & 7 ) ) ) == 0 )
- FT_INVALID_DATA;
- }
- }
- else
- {
- /* start_hi == 0; check that is32[i] is 0 for each i in */
- /* the range [start..end] */
-
- /* end_hi cannot be != 0! */
- if ( end & ~0xFFFFU )
- FT_INVALID_DATA;
-
- for ( ; count > 0; count--, start++ )
- {
- lo = (FT_UInt)( start & 0xFFFFU );
-
- if ( (is32[lo >> 3] & ( 0x80 >> ( lo & 7 ) ) ) != 0 )
- FT_INVALID_DATA;
- }
- }
- }
-
- last = end;
- }
- }
-
- return FT_Err_Ok;
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- tt_cmap8_char_index( FT_CMap cmap, /* TT_CMap */
- FT_UInt32 char_code )
- {
- TT_CMap ttcmap = (TT_CMap)cmap;
- FT_Byte* table = ttcmap->data;
- FT_UInt result = 0;
- FT_Byte* p = table + 8204;
- FT_UInt32 num_groups = TT_NEXT_ULONG( p );
- FT_UInt32 start, end, start_id;
-
-
- for ( ; num_groups > 0; num_groups-- )
- {
- start = TT_NEXT_ULONG( p );
- end = TT_NEXT_ULONG( p );
- start_id = TT_NEXT_ULONG( p );
-
- if ( char_code < start )
- break;
-
- if ( char_code <= end )
- {
- if ( start_id > 0xFFFFFFFFUL - ( char_code - start ) )
- return 0;
-
- result = (FT_UInt)( start_id + ( char_code - start ) );
- break;
- }
- }
- return result;
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- tt_cmap8_char_next( FT_CMap cmap, /* TT_CMap */
- FT_UInt32 *pchar_code )
- {
- TT_CMap ttcmap = (TT_CMap)cmap;
- FT_Face face = FT_CMAP_FACE( cmap );
- FT_UInt32 result = 0;
- FT_UInt32 char_code;
- FT_UInt gindex = 0;
- FT_Byte* table = ttcmap->data;
- FT_Byte* p = table + 8204;
- FT_UInt32 num_groups = TT_NEXT_ULONG( p );
- FT_UInt32 start, end, start_id;
-
-
- if ( *pchar_code >= 0xFFFFFFFFUL )
- return 0;
-
- char_code = *pchar_code + 1;
-
- p = table + 8208;
-
- for ( ; num_groups > 0; num_groups-- )
- {
- start = TT_NEXT_ULONG( p );
- end = TT_NEXT_ULONG( p );
- start_id = TT_NEXT_ULONG( p );
-
- if ( char_code < start )
- char_code = start;
-
- Again:
- if ( char_code <= end )
- {
- /* ignore invalid group */
- if ( start_id > 0xFFFFFFFFUL - ( char_code - start ) )
- continue;
-
- gindex = (FT_UInt)( start_id + ( char_code - start ) );
-
- /* does first element of group point to `.notdef' glyph? */
- if ( gindex == 0 )
- {
- if ( char_code >= 0xFFFFFFFFUL )
- break;
-
- char_code++;
- goto Again;
- }
-
- /* if `gindex' is invalid, the remaining values */
- /* in this group are invalid, too */
- if ( gindex >= (FT_UInt)face->num_glyphs )
- {
- gindex = 0;
- continue;
- }
-
- result = char_code;
- break;
- }
- }
-
- *pchar_code = result;
- return gindex;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- tt_cmap8_get_info( FT_CharMap cmap, /* TT_CMap */
- TT_CMapInfo *cmap_info )
- {
- TT_CMap ttcmap = (TT_CMap)cmap;
- FT_Byte* p = ttcmap->data + 8;
-
-
- cmap_info->format = 8;
- cmap_info->language = (FT_ULong)TT_PEEK_ULONG( p );
-
- return FT_Err_Ok;
- }
-
-
- FT_DEFINE_TT_CMAP(
- tt_cmap8_class_rec,
-
- sizeof ( TT_CMapRec ),
-
- (FT_CMap_InitFunc) tt_cmap_init, /* init */
- (FT_CMap_DoneFunc) NULL, /* done */
- (FT_CMap_CharIndexFunc)tt_cmap8_char_index, /* char_index */
- (FT_CMap_CharNextFunc) tt_cmap8_char_next, /* char_next */
-
- (FT_CMap_CharVarIndexFunc) NULL, /* char_var_index */
- (FT_CMap_CharVarIsDefaultFunc)NULL, /* char_var_default */
- (FT_CMap_VariantListFunc) NULL, /* variant_list */
- (FT_CMap_CharVariantListFunc) NULL, /* charvariant_list */
- (FT_CMap_VariantCharListFunc) NULL, /* variantchar_list */
-
- 8,
- (TT_CMap_ValidateFunc)tt_cmap8_validate, /* validate */
- (TT_CMap_Info_GetFunc)tt_cmap8_get_info /* get_cmap_info */
- )
-
-#endif /* TT_CONFIG_CMAP_FORMAT_8 */
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** FORMAT 10 *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- /**************************************************************************
- *
- * TABLE OVERVIEW
- * --------------
- *
- * NAME OFFSET TYPE DESCRIPTION
- *
- * format 0 USHORT must be 10
- * reserved 2 USHORT reserved
- * length 4 ULONG length in bytes
- * language 8 ULONG Mac language code
- *
- * start 12 ULONG first char in range
- * count 16 ULONG number of chars in range
- * glyphIds 20 USHORT[count] glyph indices covered
- */
-
-#ifdef TT_CONFIG_CMAP_FORMAT_10
-
- FT_CALLBACK_DEF( FT_Error )
- tt_cmap10_validate( FT_Byte* table,
- FT_Validator valid )
- {
- FT_Byte* p = table + 4;
- FT_ULong length, count;
-
-
- if ( table + 20 > valid->limit )
- FT_INVALID_TOO_SHORT;
-
- length = TT_NEXT_ULONG( p );
- p = table + 16;
- count = TT_NEXT_ULONG( p );
-
- if ( length > (FT_ULong)( valid->limit - table ) ||
- /* length < 20 + count * 2 ? */
- length < 20 ||
- ( length - 20 ) / 2 < count )
- FT_INVALID_TOO_SHORT;
-
- /* check glyph indices */
- if ( valid->level >= FT_VALIDATE_TIGHT )
- {
- FT_UInt gindex;
-
-
- for ( ; count > 0; count-- )
- {
- gindex = TT_NEXT_USHORT( p );
- if ( gindex >= TT_VALID_GLYPH_COUNT( valid ) )
- FT_INVALID_GLYPH_ID;
- }
- }
-
- return FT_Err_Ok;
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- tt_cmap10_char_index( FT_CMap cmap, /* TT_CMap */
- FT_UInt32 char_code )
- {
- TT_CMap ttcmap = (TT_CMap)cmap;
- FT_Byte* table = ttcmap->data;
- FT_UInt result = 0;
- FT_Byte* p = table + 12;
- FT_UInt32 start = TT_NEXT_ULONG( p );
- FT_UInt32 count = TT_NEXT_ULONG( p );
- FT_UInt32 idx;
-
-
- if ( char_code < start )
- return 0;
-
- idx = char_code - start;
-
- if ( idx < count )
- {
- p += 2 * idx;
- result = TT_PEEK_USHORT( p );
- }
-
- return result;
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- tt_cmap10_char_next( FT_CMap cmap, /* TT_CMap */
- FT_UInt32 *pchar_code )
- {
- TT_CMap ttcmap = (TT_CMap)cmap;
- FT_Byte* table = ttcmap->data;
- FT_UInt32 char_code;
- FT_UInt gindex = 0;
- FT_Byte* p = table + 12;
- FT_UInt32 start = TT_NEXT_ULONG( p );
- FT_UInt32 count = TT_NEXT_ULONG( p );
- FT_UInt32 idx;
-
-
- if ( *pchar_code >= 0xFFFFFFFFUL )
- return 0;
-
- char_code = *pchar_code + 1;
-
- if ( char_code < start )
- char_code = start;
-
- idx = char_code - start;
- p += 2 * idx;
-
- for ( ; idx < count; idx++ )
- {
- gindex = TT_NEXT_USHORT( p );
- if ( gindex != 0 )
- break;
-
- if ( char_code >= 0xFFFFFFFFUL )
- return 0;
-
- char_code++;
- }
-
- *pchar_code = char_code;
- return gindex;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- tt_cmap10_get_info( FT_CharMap cmap, /* TT_CMap */
- TT_CMapInfo *cmap_info )
- {
- TT_CMap ttcmap = (TT_CMap)cmap;
- FT_Byte* p = ttcmap->data + 8;
-
-
- cmap_info->format = 10;
- cmap_info->language = (FT_ULong)TT_PEEK_ULONG( p );
-
- return FT_Err_Ok;
- }
-
-
- FT_DEFINE_TT_CMAP(
- tt_cmap10_class_rec,
-
- sizeof ( TT_CMapRec ),
-
- (FT_CMap_InitFunc) tt_cmap_init, /* init */
- (FT_CMap_DoneFunc) NULL, /* done */
- (FT_CMap_CharIndexFunc)tt_cmap10_char_index, /* char_index */
- (FT_CMap_CharNextFunc) tt_cmap10_char_next, /* char_next */
-
- (FT_CMap_CharVarIndexFunc) NULL, /* char_var_index */
- (FT_CMap_CharVarIsDefaultFunc)NULL, /* char_var_default */
- (FT_CMap_VariantListFunc) NULL, /* variant_list */
- (FT_CMap_CharVariantListFunc) NULL, /* charvariant_list */
- (FT_CMap_VariantCharListFunc) NULL, /* variantchar_list */
-
- 10,
- (TT_CMap_ValidateFunc)tt_cmap10_validate, /* validate */
- (TT_CMap_Info_GetFunc)tt_cmap10_get_info /* get_cmap_info */
- )
-
-#endif /* TT_CONFIG_CMAP_FORMAT_10 */
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** FORMAT 12 *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- /**************************************************************************
- *
- * TABLE OVERVIEW
- * --------------
- *
- * NAME OFFSET TYPE DESCRIPTION
- *
- * format 0 USHORT must be 12
- * reserved 2 USHORT reserved
- * length 4 ULONG length in bytes
- * language 8 ULONG Mac language code
- * count 12 ULONG number of groups
- * 16
- *
- * This header is followed by `count' groups of the following format:
- *
- * start 0 ULONG first charcode
- * end 4 ULONG last charcode
- * startId 8 ULONG start glyph ID for the group
- */
-
-#ifdef TT_CONFIG_CMAP_FORMAT_12
-
- typedef struct TT_CMap12Rec_
- {
- TT_CMapRec cmap;
- FT_Bool valid;
- FT_ULong cur_charcode;
- FT_UInt cur_gindex;
- FT_ULong cur_group;
- FT_ULong num_groups;
-
- } TT_CMap12Rec, *TT_CMap12;
-
-
- FT_CALLBACK_DEF( FT_Error )
- tt_cmap12_init( FT_CMap cmap, /* TT_CMap12 */
- void* table_ )
- {
- TT_CMap12 ttcmap = (TT_CMap12)cmap;
- FT_Byte* table = (FT_Byte*)table_;
-
-
- ttcmap->cmap.data = table;
-
- table += 12;
- ttcmap->num_groups = FT_PEEK_ULONG( table );
-
- ttcmap->valid = 0;
-
- return FT_Err_Ok;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- tt_cmap12_validate( FT_Byte* table,
- FT_Validator valid )
- {
- FT_Byte* p;
- FT_ULong length;
- FT_ULong num_groups;
-
-
- if ( table + 16 > valid->limit )
- FT_INVALID_TOO_SHORT;
-
- p = table + 4;
- length = TT_NEXT_ULONG( p );
-
- p = table + 12;
- num_groups = TT_NEXT_ULONG( p );
-
- if ( length > (FT_ULong)( valid->limit - table ) ||
- /* length < 16 + 12 * num_groups ? */
- length < 16 ||
- ( length - 16 ) / 12 < num_groups )
- FT_INVALID_TOO_SHORT;
-
- /* check groups, they must be in increasing order */
- {
- FT_ULong n, start, end, start_id, last = 0;
-
-
- for ( n = 0; n < num_groups; n++ )
- {
- start = TT_NEXT_ULONG( p );
- end = TT_NEXT_ULONG( p );
- start_id = TT_NEXT_ULONG( p );
-
- if ( start > end )
- FT_INVALID_DATA;
-
- if ( n > 0 && start <= last )
- FT_INVALID_DATA;
-
- if ( valid->level >= FT_VALIDATE_TIGHT )
- {
- FT_UInt32 d = end - start;
-
-
- /* start_id + end - start >= TT_VALID_GLYPH_COUNT( valid ) ? */
- if ( d > TT_VALID_GLYPH_COUNT( valid ) ||
- start_id >= TT_VALID_GLYPH_COUNT( valid ) - d )
- FT_INVALID_GLYPH_ID;
- }
-
- last = end;
- }
- }
-
- return FT_Err_Ok;
- }
-
-
- /* search the index of the charcode next to cmap->cur_charcode */
- /* cmap->cur_group should be set up properly by caller */
- /* */
- static void
- tt_cmap12_next( FT_CMap cmap ) /* TT_CMap12 */
- {
- TT_CMap12 ttcmap = (TT_CMap12)cmap;
- FT_Face face = FT_CMAP_FACE( cmap );
- FT_Byte* p;
- FT_ULong start, end, start_id, char_code;
- FT_ULong n;
- FT_UInt gindex;
-
-
- char_code = ttcmap->cur_charcode + 1;
-
- for ( n = ttcmap->cur_group; n < ttcmap->num_groups; n++ )
- {
- p = ttcmap->cmap.data + 16 + 12 * n;
- start = TT_NEXT_ULONG( p );
- end = TT_NEXT_ULONG( p );
- start_id = TT_PEEK_ULONG( p );
-
- if ( char_code < start )
- char_code = start;
-
- Again:
- if ( char_code <= end )
- {
- /* ignore invalid group */
- if ( start_id > 0xFFFFFFFFUL - ( char_code - start ) )
- continue;
-
- gindex = (FT_UInt)( start_id + ( char_code - start ) );
-
- /* does first element of group point to `.notdef' glyph? */
- if ( gindex == 0 )
- {
- if ( char_code >= 0xFFFFFFFFUL )
- goto Fail;
-
- char_code++;
- goto Again;
- }
-
- /* if `gindex' is invalid, the remaining values */
- /* in this group are invalid, too */
- if ( gindex >= (FT_UInt)face->num_glyphs )
- continue;
-
- ttcmap->cur_charcode = char_code;
- ttcmap->cur_gindex = gindex;
- ttcmap->cur_group = n;
-
- return;
- }
- }
-
- Fail:
- ttcmap->valid = 0;
- }
-
-
- static FT_UInt
- tt_cmap12_char_map_binary( TT_CMap cmap,
- FT_UInt32* pchar_code,
- FT_Bool next )
- {
- FT_UInt gindex = 0;
- FT_Byte* p = cmap->data + 12;
- FT_UInt32 num_groups = TT_PEEK_ULONG( p );
- FT_UInt32 char_code = *pchar_code + next;
- FT_UInt32 start, end, start_id;
- FT_UInt32 max, min, mid;
-
-
- if ( !num_groups )
- return 0;
-
- min = 0;
- max = num_groups;
-
- /* binary search */
- do
- {
- mid = ( min + max ) >> 1;
- p = cmap->data + 16 + 12 * mid;
-
- start = TT_NEXT_ULONG( p );
- end = TT_NEXT_ULONG( p );
-
- if ( char_code < start )
- max = mid;
- else if ( char_code > end )
- min = mid + 1;
- else
- {
- start_id = TT_PEEK_ULONG( p );
-
- /* reject invalid glyph index */
- if ( start_id > 0xFFFFFFFFUL - ( char_code - start ) )
- gindex = 0;
- else
- gindex = (FT_UInt)( start_id + ( char_code - start ) );
- break;
- }
- }
- while ( min < max );
-
- if ( next )
- {
- FT_Face face = FT_CMAP_FACE( cmap );
- TT_CMap12 cmap12 = (TT_CMap12)cmap;
-
-
- /* if `char_code' is not in any group, then `mid' is */
- /* the group nearest to `char_code' */
-
- if ( char_code > end && ++mid == num_groups )
- return 0;
-
- cmap12->valid = 1;
- cmap12->cur_charcode = char_code;
- cmap12->cur_group = mid;
-
- if ( gindex >= (FT_UInt)face->num_glyphs )
- gindex = 0;
-
- if ( !gindex )
- {
- tt_cmap12_next( FT_CMAP( cmap12 ) );
-
- if ( cmap12->valid )
- gindex = cmap12->cur_gindex;
- }
- else
- cmap12->cur_gindex = gindex;
-
- *pchar_code = cmap12->cur_charcode;
- }
-
- return gindex;
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- tt_cmap12_char_index( FT_CMap cmap, /* TT_CMap */
- FT_UInt32 char_code )
- {
- return tt_cmap12_char_map_binary( (TT_CMap)cmap, &char_code, 0 );
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- tt_cmap12_char_next( FT_CMap cmap, /* TT_CMap12 */
- FT_UInt32 *pchar_code )
- {
- TT_CMap12 cmap12 = (TT_CMap12)cmap;
- FT_UInt gindex;
-
-
- if ( *pchar_code >= 0xFFFFFFFFUL )
- return 0;
-
- /* no need to search */
- if ( cmap12->valid && cmap12->cur_charcode == *pchar_code )
- {
- tt_cmap12_next( FT_CMAP( cmap12 ) );
- if ( cmap12->valid )
- {
- gindex = cmap12->cur_gindex;
- *pchar_code = (FT_UInt32)cmap12->cur_charcode;
- }
- else
- gindex = 0;
- }
- else
- gindex = tt_cmap12_char_map_binary( (TT_CMap)cmap, pchar_code, 1 );
-
- return gindex;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- tt_cmap12_get_info( FT_CharMap cmap, /* TT_CMap */
- TT_CMapInfo *cmap_info )
- {
- TT_CMap ttcmap = (TT_CMap)cmap;
- FT_Byte* p = ttcmap->data + 8;
-
-
- cmap_info->format = 12;
- cmap_info->language = (FT_ULong)TT_PEEK_ULONG( p );
-
- return FT_Err_Ok;
- }
-
-
- FT_DEFINE_TT_CMAP(
- tt_cmap12_class_rec,
-
- sizeof ( TT_CMap12Rec ),
-
- (FT_CMap_InitFunc) tt_cmap12_init, /* init */
- (FT_CMap_DoneFunc) NULL, /* done */
- (FT_CMap_CharIndexFunc)tt_cmap12_char_index, /* char_index */
- (FT_CMap_CharNextFunc) tt_cmap12_char_next, /* char_next */
-
- (FT_CMap_CharVarIndexFunc) NULL, /* char_var_index */
- (FT_CMap_CharVarIsDefaultFunc)NULL, /* char_var_default */
- (FT_CMap_VariantListFunc) NULL, /* variant_list */
- (FT_CMap_CharVariantListFunc) NULL, /* charvariant_list */
- (FT_CMap_VariantCharListFunc) NULL, /* variantchar_list */
-
- 12,
- (TT_CMap_ValidateFunc)tt_cmap12_validate, /* validate */
- (TT_CMap_Info_GetFunc)tt_cmap12_get_info /* get_cmap_info */
- )
-
-#endif /* TT_CONFIG_CMAP_FORMAT_12 */
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** FORMAT 13 *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- /**************************************************************************
- *
- * TABLE OVERVIEW
- * --------------
- *
- * NAME OFFSET TYPE DESCRIPTION
- *
- * format 0 USHORT must be 13
- * reserved 2 USHORT reserved
- * length 4 ULONG length in bytes
- * language 8 ULONG Mac language code
- * count 12 ULONG number of groups
- * 16
- *
- * This header is followed by `count' groups of the following format:
- *
- * start 0 ULONG first charcode
- * end 4 ULONG last charcode
- * glyphId 8 ULONG glyph ID for the whole group
- */
-
-#ifdef TT_CONFIG_CMAP_FORMAT_13
-
- typedef struct TT_CMap13Rec_
- {
- TT_CMapRec cmap;
- FT_Bool valid;
- FT_ULong cur_charcode;
- FT_UInt cur_gindex;
- FT_ULong cur_group;
- FT_ULong num_groups;
-
- } TT_CMap13Rec, *TT_CMap13;
-
-
- FT_CALLBACK_DEF( FT_Error )
- tt_cmap13_init( FT_CMap cmap, /* TT_CMap13 */
- void* table_ )
- {
- TT_CMap13 ttcmap = (TT_CMap13)cmap;
- FT_Byte* table = (FT_Byte*)table_;
-
-
- ttcmap->cmap.data = table;
-
- table += 12;
- ttcmap->num_groups = FT_PEEK_ULONG( table );
-
- ttcmap->valid = 0;
-
- return FT_Err_Ok;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- tt_cmap13_validate( FT_Byte* table,
- FT_Validator valid )
- {
- FT_Byte* p;
- FT_ULong length;
- FT_ULong num_groups;
-
-
- if ( table + 16 > valid->limit )
- FT_INVALID_TOO_SHORT;
-
- p = table + 4;
- length = TT_NEXT_ULONG( p );
-
- p = table + 12;
- num_groups = TT_NEXT_ULONG( p );
-
- if ( length > (FT_ULong)( valid->limit - table ) ||
- /* length < 16 + 12 * num_groups ? */
- length < 16 ||
- ( length - 16 ) / 12 < num_groups )
- FT_INVALID_TOO_SHORT;
-
- /* check groups, they must be in increasing order */
- {
- FT_ULong n, start, end, glyph_id, last = 0;
-
-
- for ( n = 0; n < num_groups; n++ )
- {
- start = TT_NEXT_ULONG( p );
- end = TT_NEXT_ULONG( p );
- glyph_id = TT_NEXT_ULONG( p );
-
- if ( start > end )
- FT_INVALID_DATA;
-
- if ( n > 0 && start <= last )
- FT_INVALID_DATA;
-
- if ( valid->level >= FT_VALIDATE_TIGHT )
- {
- if ( glyph_id >= TT_VALID_GLYPH_COUNT( valid ) )
- FT_INVALID_GLYPH_ID;
- }
-
- last = end;
- }
- }
-
- return FT_Err_Ok;
- }
-
-
- /* search the index of the charcode next to cmap->cur_charcode */
- /* cmap->cur_group should be set up properly by caller */
- /* */
- static void
- tt_cmap13_next( FT_CMap cmap ) /* TT_CMap13 */
- {
- TT_CMap13 ttcmap = (TT_CMap13)cmap;
- FT_Face face = FT_CMAP_FACE( cmap );
- FT_Byte* p;
- FT_ULong start, end, glyph_id, char_code;
- FT_ULong n;
- FT_UInt gindex;
-
-
- char_code = ttcmap->cur_charcode + 1;
-
- for ( n = ttcmap->cur_group; n < ttcmap->num_groups; n++ )
- {
- p = ttcmap->cmap.data + 16 + 12 * n;
- start = TT_NEXT_ULONG( p );
- end = TT_NEXT_ULONG( p );
- glyph_id = TT_PEEK_ULONG( p );
-
- if ( char_code < start )
- char_code = start;
-
- if ( char_code <= end )
- {
- gindex = (FT_UInt)glyph_id;
-
- if ( gindex && gindex < (FT_UInt)face->num_glyphs )
- {
- ttcmap->cur_charcode = char_code;
- ttcmap->cur_gindex = gindex;
- ttcmap->cur_group = n;
-
- return;
- }
- }
- }
-
- ttcmap->valid = 0;
- }
-
-
- static FT_UInt
- tt_cmap13_char_map_binary( TT_CMap cmap,
- FT_UInt32* pchar_code,
- FT_Bool next )
- {
- FT_UInt gindex = 0;
- FT_Byte* p = cmap->data + 12;
- FT_UInt32 num_groups = TT_PEEK_ULONG( p );
- FT_UInt32 char_code = *pchar_code + next;
- FT_UInt32 start, end;
- FT_UInt32 max, min, mid;
-
-
- if ( !num_groups )
- return 0;
-
- min = 0;
- max = num_groups;
-
- /* binary search */
- do
- {
- mid = ( min + max ) >> 1;
- p = cmap->data + 16 + 12 * mid;
-
- start = TT_NEXT_ULONG( p );
- end = TT_NEXT_ULONG( p );
-
- if ( char_code < start )
- max = mid;
- else if ( char_code > end )
- min = mid + 1;
- else
- {
- gindex = (FT_UInt)TT_PEEK_ULONG( p );
-
- break;
- }
- }
- while ( min < max );
-
- if ( next )
- {
- FT_Face face = cmap->cmap.charmap.face;
- TT_CMap13 cmap13 = (TT_CMap13)cmap;
-
-
- /* if `char_code' is not in any group, then `mid' is */
- /* the group nearest to `char_code' */
-
- if ( char_code > end && ++mid == num_groups )
- return 0;
-
- cmap13->valid = 1;
- cmap13->cur_charcode = char_code;
- cmap13->cur_group = mid;
-
- if ( gindex >= (FT_UInt)face->num_glyphs )
- gindex = 0;
-
- if ( !gindex )
- {
- tt_cmap13_next( FT_CMAP( cmap13 ) );
-
- if ( cmap13->valid )
- gindex = cmap13->cur_gindex;
- }
- else
- cmap13->cur_gindex = gindex;
-
- *pchar_code = cmap13->cur_charcode;
- }
-
- return gindex;
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- tt_cmap13_char_index( FT_CMap cmap, /* TT_CMap */
- FT_UInt32 char_code )
- {
- return tt_cmap13_char_map_binary( (TT_CMap)cmap, &char_code, 0 );
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- tt_cmap13_char_next( FT_CMap cmap, /* TT_CMap13 */
- FT_UInt32 *pchar_code )
- {
- TT_CMap13 cmap13 = (TT_CMap13)cmap;
- FT_UInt gindex;
-
-
- if ( *pchar_code >= 0xFFFFFFFFUL )
- return 0;
-
- /* no need to search */
- if ( cmap13->valid && cmap13->cur_charcode == *pchar_code )
- {
- tt_cmap13_next( FT_CMAP( cmap13 ) );
- if ( cmap13->valid )
- {
- gindex = cmap13->cur_gindex;
- *pchar_code = cmap13->cur_charcode;
- }
- else
- gindex = 0;
- }
- else
- gindex = tt_cmap13_char_map_binary( (TT_CMap)cmap, pchar_code, 1 );
-
- return gindex;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- tt_cmap13_get_info( FT_CharMap cmap, /* TT_CMap */
- TT_CMapInfo *cmap_info )
- {
- TT_CMap ttcmap = (TT_CMap)cmap;
- FT_Byte* p = ttcmap->data + 8;
-
-
- cmap_info->format = 13;
- cmap_info->language = (FT_ULong)TT_PEEK_ULONG( p );
-
- return FT_Err_Ok;
- }
-
-
- FT_DEFINE_TT_CMAP(
- tt_cmap13_class_rec,
-
- sizeof ( TT_CMap13Rec ),
-
- (FT_CMap_InitFunc) tt_cmap13_init, /* init */
- (FT_CMap_DoneFunc) NULL, /* done */
- (FT_CMap_CharIndexFunc)tt_cmap13_char_index, /* char_index */
- (FT_CMap_CharNextFunc) tt_cmap13_char_next, /* char_next */
-
- (FT_CMap_CharVarIndexFunc) NULL, /* char_var_index */
- (FT_CMap_CharVarIsDefaultFunc)NULL, /* char_var_default */
- (FT_CMap_VariantListFunc) NULL, /* variant_list */
- (FT_CMap_CharVariantListFunc) NULL, /* charvariant_list */
- (FT_CMap_VariantCharListFunc) NULL, /* variantchar_list */
-
- 13,
- (TT_CMap_ValidateFunc)tt_cmap13_validate, /* validate */
- (TT_CMap_Info_GetFunc)tt_cmap13_get_info /* get_cmap_info */
- )
-
-#endif /* TT_CONFIG_CMAP_FORMAT_13 */
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** FORMAT 14 *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- /**************************************************************************
- *
- * TABLE OVERVIEW
- * --------------
- *
- * NAME OFFSET TYPE DESCRIPTION
- *
- * format 0 USHORT must be 14
- * length 2 ULONG table length in bytes
- * numSelector 6 ULONG number of variation sel. records
- *
- * Followed by numSelector records, each of which looks like
- *
- * varSelector 0 UINT24 Unicode codepoint of sel.
- * defaultOff 3 ULONG offset to a default UVS table
- * describing any variants to be found in
- * the normal Unicode subtable.
- * nonDefOff 7 ULONG offset to a non-default UVS table
- * describing any variants not in the
- * standard cmap, with GIDs here
- * (either offset may be 0 NULL)
- *
- * Selectors are sorted by code point.
- *
- * A default Unicode Variation Selector (UVS) subtable is just a list of
- * ranges of code points which are to be found in the standard cmap. No
- * glyph IDs (GIDs) here.
- *
- * numRanges 0 ULONG number of ranges following
- *
- * A range looks like
- *
- * uniStart 0 UINT24 code point of the first character in
- * this range
- * additionalCnt 3 UBYTE count of additional characters in this
- * range (zero means a range of a single
- * character)
- *
- * Ranges are sorted by `uniStart'.
- *
- * A non-default Unicode Variation Selector (UVS) subtable is a list of
- * mappings from codepoint to GID.
- *
- * numMappings 0 ULONG number of mappings
- *
- * A range looks like
- *
- * uniStart 0 UINT24 code point of the first character in
- * this range
- * GID 3 USHORT and its GID
- *
- * Ranges are sorted by `uniStart'.
- */
-
-#ifdef TT_CONFIG_CMAP_FORMAT_14
-
- typedef struct TT_CMap14Rec_
- {
- TT_CMapRec cmap;
- FT_ULong num_selectors;
-
- /* This array is used to store the results of various
- * cmap 14 query functions. The data is overwritten
- * on each call to these functions.
- */
- FT_UInt32 max_results;
- FT_UInt32* results;
- FT_Memory memory;
-
- } TT_CMap14Rec, *TT_CMap14;
-
-
- FT_CALLBACK_DEF( void )
- tt_cmap14_done( FT_CMap cmap ) /* TT_CMap14 */
- {
- TT_CMap14 ttcmap = (TT_CMap14)cmap;
- FT_Memory memory = ttcmap->memory;
-
-
- ttcmap->max_results = 0;
- if ( memory && ttcmap->results )
- FT_FREE( ttcmap->results );
- }
-
-
- static FT_Error
- tt_cmap14_ensure( TT_CMap14 cmap,
- FT_UInt32 num_results,
- FT_Memory memory )
- {
- FT_UInt32 old_max = cmap->max_results;
- FT_Error error = FT_Err_Ok;
-
-
- if ( num_results > cmap->max_results )
- {
- cmap->memory = memory;
-
- if ( FT_QRENEW_ARRAY( cmap->results, old_max, num_results ) )
- return error;
-
- cmap->max_results = num_results;
- }
-
- return error;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- tt_cmap14_init( FT_CMap cmap, /* TT_CMap14 */
- void* table_ )
- {
- TT_CMap14 ttcmap = (TT_CMap14)cmap;
- FT_Byte* table = (FT_Byte*)table_;
-
-
- ttcmap->cmap.data = table;
-
- table += 6;
- ttcmap->num_selectors = FT_PEEK_ULONG( table );
- ttcmap->max_results = 0;
- ttcmap->results = NULL;
-
- return FT_Err_Ok;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- tt_cmap14_validate( FT_Byte* table,
- FT_Validator valid )
- {
- FT_Byte* p;
- FT_ULong length;
- FT_ULong num_selectors;
-
-
- if ( table + 2 + 4 + 4 > valid->limit )
- FT_INVALID_TOO_SHORT;
-
- p = table + 2;
- length = TT_NEXT_ULONG( p );
- num_selectors = TT_NEXT_ULONG( p );
-
- if ( length > (FT_ULong)( valid->limit - table ) ||
- /* length < 10 + 11 * num_selectors ? */
- length < 10 ||
- ( length - 10 ) / 11 < num_selectors )
- FT_INVALID_TOO_SHORT;
-
- /* check selectors, they must be in increasing order */
- {
- /* we start lastVarSel at 1 because a variant selector value of 0
- * isn't valid.
- */
- FT_ULong n, lastVarSel = 1;
-
-
- for ( n = 0; n < num_selectors; n++ )
- {
- FT_ULong varSel = TT_NEXT_UINT24( p );
- FT_ULong defOff = TT_NEXT_ULONG( p );
- FT_ULong nondefOff = TT_NEXT_ULONG( p );
-
-
- if ( defOff >= length || nondefOff >= length )
- FT_INVALID_TOO_SHORT;
-
- if ( varSel < lastVarSel )
- FT_INVALID_DATA;
-
- lastVarSel = varSel + 1;
-
- /* check the default table (these glyphs should be reached */
- /* through the normal Unicode cmap, no GIDs, just check order) */
- if ( defOff != 0 )
- {
- FT_Byte* defp = table + defOff;
- FT_ULong numRanges;
- FT_ULong i;
- FT_ULong lastBase = 0;
-
-
- if ( defp + 4 > valid->limit )
- FT_INVALID_TOO_SHORT;
-
- numRanges = TT_NEXT_ULONG( defp );
-
- /* defp + numRanges * 4 > valid->limit ? */
- if ( numRanges > (FT_ULong)( valid->limit - defp ) / 4 )
- FT_INVALID_TOO_SHORT;
-
- for ( i = 0; i < numRanges; i++ )
- {
- FT_ULong base = TT_NEXT_UINT24( defp );
- FT_ULong cnt = FT_NEXT_BYTE( defp );
-
-
- if ( base + cnt >= 0x110000UL ) /* end of Unicode */
- FT_INVALID_DATA;
-
- if ( base < lastBase )
- FT_INVALID_DATA;
-
- lastBase = base + cnt + 1U;
- }
- }
-
- /* and the non-default table (these glyphs are specified here) */
- if ( nondefOff != 0 )
- {
- FT_Byte* ndp = table + nondefOff;
- FT_ULong numMappings;
- FT_ULong i, lastUni = 0;
-
-
- if ( ndp + 4 > valid->limit )
- FT_INVALID_TOO_SHORT;
-
- numMappings = TT_NEXT_ULONG( ndp );
-
- /* numMappings * 5 > (FT_ULong)( valid->limit - ndp ) ? */
- if ( numMappings > ( (FT_ULong)( valid->limit - ndp ) ) / 5 )
- FT_INVALID_TOO_SHORT;
-
- for ( i = 0; i < numMappings; i++ )
- {
- FT_ULong uni = TT_NEXT_UINT24( ndp );
- FT_ULong gid = TT_NEXT_USHORT( ndp );
-
-
- if ( uni >= 0x110000UL ) /* end of Unicode */
- FT_INVALID_DATA;
-
- if ( uni < lastUni )
- FT_INVALID_DATA;
-
- lastUni = uni + 1U;
-
- if ( valid->level >= FT_VALIDATE_TIGHT &&
- gid >= TT_VALID_GLYPH_COUNT( valid ) )
- FT_INVALID_GLYPH_ID;
- }
- }
- }
- }
-
- return FT_Err_Ok;
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- tt_cmap14_char_index( FT_CMap cmap,
- FT_UInt32 char_code )
- {
- FT_UNUSED( cmap );
- FT_UNUSED( char_code );
-
- /* This can't happen */
- return 0;
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- tt_cmap14_char_next( FT_CMap cmap,
- FT_UInt32 *pchar_code )
- {
- FT_UNUSED( cmap );
-
- /* This can't happen */
- *pchar_code = 0;
- return 0;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- tt_cmap14_get_info( FT_CharMap cmap,
- TT_CMapInfo *cmap_info )
- {
- FT_UNUSED( cmap );
-
- cmap_info->format = 14;
- /* subtable 14 does not define a language field */
- cmap_info->language = 0xFFFFFFFFUL;
-
- return FT_Err_Ok;
- }
-
-
- static FT_UInt
- tt_cmap14_char_map_def_binary( FT_Byte *base,
- FT_UInt32 char_code )
- {
- FT_UInt32 numRanges = TT_PEEK_ULONG( base );
- FT_UInt32 max, min;
-
-
- min = 0;
- max = numRanges;
-
- base += 4;
-
- /* binary search */
- while ( min < max )
- {
- FT_UInt32 mid = ( min + max ) >> 1;
- FT_Byte* p = base + 4 * mid;
- FT_ULong start = TT_NEXT_UINT24( p );
- FT_UInt cnt = FT_NEXT_BYTE( p );
-
-
- if ( char_code < start )
- max = mid;
- else if ( char_code > start + cnt )
- min = mid + 1;
- else
- return TRUE;
- }
-
- return FALSE;
- }
-
-
- static FT_UInt
- tt_cmap14_char_map_nondef_binary( FT_Byte *base,
- FT_UInt32 char_code )
- {
- FT_UInt32 numMappings = TT_PEEK_ULONG( base );
- FT_UInt32 max, min;
-
-
- min = 0;
- max = numMappings;
-
- base += 4;
-
- /* binary search */
- while ( min < max )
- {
- FT_UInt32 mid = ( min + max ) >> 1;
- FT_Byte* p = base + 5 * mid;
- FT_UInt32 uni = (FT_UInt32)TT_NEXT_UINT24( p );
-
-
- if ( char_code < uni )
- max = mid;
- else if ( char_code > uni )
- min = mid + 1;
- else
- return TT_PEEK_USHORT( p );
- }
-
- return 0;
- }
-
-
- static FT_Byte*
- tt_cmap14_find_variant( FT_Byte *base,
- FT_UInt32 variantCode )
- {
- FT_UInt32 numVar = TT_PEEK_ULONG( base );
- FT_UInt32 max, min;
-
-
- min = 0;
- max = numVar;
-
- base += 4;
-
- /* binary search */
- while ( min < max )
- {
- FT_UInt32 mid = ( min + max ) >> 1;
- FT_Byte* p = base + 11 * mid;
- FT_ULong varSel = TT_NEXT_UINT24( p );
-
-
- if ( variantCode < varSel )
- max = mid;
- else if ( variantCode > varSel )
- min = mid + 1;
- else
- return p;
- }
-
- return NULL;
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- tt_cmap14_char_var_index( FT_CMap cmap, /* TT_CMap */
- FT_CMap ucmap, /* TT_CMap */
- FT_UInt32 charcode,
- FT_UInt32 variantSelector )
- {
- TT_CMap ttcmap = (TT_CMap)cmap;
- TT_CMap ttucmap = (TT_CMap)ucmap;
-
- FT_Byte* p = tt_cmap14_find_variant( ttcmap->data + 6,
- variantSelector );
- FT_ULong defOff;
- FT_ULong nondefOff;
-
-
- if ( !p )
- return 0;
-
- defOff = TT_NEXT_ULONG( p );
- nondefOff = TT_PEEK_ULONG( p );
-
- if ( defOff != 0 &&
- tt_cmap14_char_map_def_binary( ttcmap->data + defOff, charcode ) )
- {
- /* This is the default variant of this charcode. GID not stored */
- /* here; stored in the normal Unicode charmap instead. */
- return ttucmap->cmap.clazz->char_index( &ttucmap->cmap, charcode );
- }
-
- if ( nondefOff != 0 )
- return tt_cmap14_char_map_nondef_binary( ttcmap->data + nondefOff,
- charcode );
-
- return 0;
- }
-
-
- FT_CALLBACK_DEF( FT_Int )
- tt_cmap14_char_var_isdefault( FT_CMap cmap, /* TT_CMap */
- FT_UInt32 charcode,
- FT_UInt32 variantSelector )
- {
- TT_CMap ttcmap = (TT_CMap)cmap;
- FT_Byte* p = tt_cmap14_find_variant( ttcmap->data + 6,
- variantSelector );
- FT_ULong defOff;
- FT_ULong nondefOff;
-
-
- if ( !p )
- return -1;
-
- defOff = TT_NEXT_ULONG( p );
- nondefOff = TT_NEXT_ULONG( p );
-
- if ( defOff != 0 &&
- tt_cmap14_char_map_def_binary( ttcmap->data + defOff, charcode ) )
- return 1;
-
- if ( nondefOff != 0 &&
- tt_cmap14_char_map_nondef_binary( ttcmap->data + nondefOff,
- charcode ) != 0 )
- return 0;
-
- return -1;
- }
-
-
- FT_CALLBACK_DEF( FT_UInt32* )
- tt_cmap14_variants( FT_CMap cmap, /* TT_CMap14 */
- FT_Memory memory )
- {
- TT_CMap ttcmap = (TT_CMap)cmap;
- TT_CMap14 cmap14 = (TT_CMap14)cmap;
- FT_UInt32 count = cmap14->num_selectors;
- FT_Byte* p = ttcmap->data + 10;
- FT_UInt32* result;
- FT_UInt32 i;
-
-
- if ( tt_cmap14_ensure( cmap14, ( count + 1 ), memory ) )
- return NULL;
-
- result = cmap14->results;
- for ( i = 0; i < count; i++ )
- {
- result[i] = (FT_UInt32)TT_NEXT_UINT24( p );
- p += 8;
- }
- result[i] = 0;
-
- return result;
- }
-
-
- FT_CALLBACK_DEF( FT_UInt32 * )
- tt_cmap14_char_variants( FT_CMap cmap, /* TT_CMap14 */
- FT_Memory memory,
- FT_UInt32 charCode )
- {
- TT_CMap ttcmap = (TT_CMap)cmap;
- TT_CMap14 cmap14 = (TT_CMap14)cmap;
- FT_UInt32 count = cmap14->num_selectors;
- FT_Byte* p = ttcmap->data + 10;
- FT_UInt32* q;
-
-
- if ( tt_cmap14_ensure( cmap14, ( count + 1 ), memory ) )
- return NULL;
-
- for ( q = cmap14->results; count > 0; count-- )
- {
- FT_UInt32 varSel = TT_NEXT_UINT24( p );
- FT_ULong defOff = TT_NEXT_ULONG( p );
- FT_ULong nondefOff = TT_NEXT_ULONG( p );
-
-
- if ( ( defOff != 0 &&
- tt_cmap14_char_map_def_binary( ttcmap->data + defOff,
- charCode ) ) ||
- ( nondefOff != 0 &&
- tt_cmap14_char_map_nondef_binary( ttcmap->data + nondefOff,
- charCode ) != 0 ) )
- {
- q[0] = varSel;
- q++;
- }
- }
- q[0] = 0;
-
- return cmap14->results;
- }
-
-
- static FT_UInt
- tt_cmap14_def_char_count( FT_Byte *p )
- {
- FT_UInt32 numRanges = (FT_UInt32)TT_NEXT_ULONG( p );
- FT_UInt tot = 0;
-
-
- p += 3; /* point to the first `cnt' field */
- for ( ; numRanges > 0; numRanges-- )
- {
- tot += 1 + p[0];
- p += 4;
- }
-
- return tot;
- }
-
-
- static FT_UInt32*
- tt_cmap14_get_def_chars( TT_CMap cmap,
- FT_Byte* p,
- FT_Memory memory )
- {
- TT_CMap14 cmap14 = (TT_CMap14) cmap;
- FT_UInt32 numRanges;
- FT_UInt cnt;
- FT_UInt32* q;
-
-
- cnt = tt_cmap14_def_char_count( p );
- numRanges = (FT_UInt32)TT_NEXT_ULONG( p );
-
- if ( tt_cmap14_ensure( cmap14, ( cnt + 1 ), memory ) )
- return NULL;
-
- for ( q = cmap14->results; numRanges > 0; numRanges-- )
- {
- FT_UInt32 uni = (FT_UInt32)TT_NEXT_UINT24( p );
-
-
- cnt = FT_NEXT_BYTE( p ) + 1;
- do
- {
- q[0] = uni;
- uni += 1;
- q += 1;
-
- } while ( --cnt != 0 );
- }
- q[0] = 0;
-
- return cmap14->results;
- }
-
-
- static FT_UInt32*
- tt_cmap14_get_nondef_chars( TT_CMap cmap,
- FT_Byte *p,
- FT_Memory memory )
- {
- TT_CMap14 cmap14 = (TT_CMap14) cmap;
- FT_UInt32 numMappings;
- FT_UInt i;
- FT_UInt32 *ret;
-
-
- numMappings = (FT_UInt32)TT_NEXT_ULONG( p );
-
- if ( tt_cmap14_ensure( cmap14, ( numMappings + 1 ), memory ) )
- return NULL;
-
- ret = cmap14->results;
- for ( i = 0; i < numMappings; i++ )
- {
- ret[i] = (FT_UInt32)TT_NEXT_UINT24( p );
- p += 2;
- }
- ret[i] = 0;
-
- return ret;
- }
-
-
- FT_CALLBACK_DEF( FT_UInt32 * )
- tt_cmap14_variant_chars( FT_CMap cmap, /* TT_CMap */
- FT_Memory memory,
- FT_UInt32 variantSelector )
- {
- TT_CMap ttcmap = (TT_CMap)cmap;
- FT_Byte *p = tt_cmap14_find_variant( ttcmap->data + 6,
- variantSelector );
- FT_Int i;
- FT_ULong defOff;
- FT_ULong nondefOff;
-
-
- if ( !p )
- return NULL;
-
- defOff = TT_NEXT_ULONG( p );
- nondefOff = TT_NEXT_ULONG( p );
-
- if ( defOff == 0 && nondefOff == 0 )
- return NULL;
-
- if ( defOff == 0 )
- return tt_cmap14_get_nondef_chars( ttcmap, ttcmap->data + nondefOff,
- memory );
- else if ( nondefOff == 0 )
- return tt_cmap14_get_def_chars( ttcmap, ttcmap->data + defOff,
- memory );
- else
- {
- /* Both a default and a non-default glyph set? That's probably not */
- /* good font design, but the spec allows for it... */
- TT_CMap14 cmap14 = (TT_CMap14)cmap;
- FT_UInt32 numRanges;
- FT_UInt32 numMappings;
- FT_UInt32 duni;
- FT_UInt32 dcnt;
- FT_UInt32 nuni;
- FT_Byte* dp;
- FT_UInt di, ni, k;
-
- FT_UInt32 *ret;
-
-
- p = ttcmap->data + nondefOff;
- dp = ttcmap->data + defOff;
-
- numMappings = (FT_UInt32)TT_NEXT_ULONG( p );
- dcnt = tt_cmap14_def_char_count( dp );
- numRanges = (FT_UInt32)TT_NEXT_ULONG( dp );
-
- if ( numMappings == 0 )
- return tt_cmap14_get_def_chars( ttcmap, ttcmap->data + defOff,
- memory );
- if ( dcnt == 0 )
- return tt_cmap14_get_nondef_chars( ttcmap, ttcmap->data + nondefOff,
- memory );
-
- if ( tt_cmap14_ensure( cmap14, ( dcnt + numMappings + 1 ), memory ) )
- return NULL;
-
- ret = cmap14->results;
- duni = (FT_UInt32)TT_NEXT_UINT24( dp );
- dcnt = FT_NEXT_BYTE( dp );
- di = 1;
- nuni = (FT_UInt32)TT_NEXT_UINT24( p );
- p += 2;
- ni = 1;
- i = 0;
-
- for (;;)
- {
- if ( nuni > duni + dcnt )
- {
- for ( k = 0; k <= dcnt; k++ )
- ret[i++] = duni + k;
-
- di++;
-
- if ( di > numRanges )
- break;
-
- duni = (FT_UInt32)TT_NEXT_UINT24( dp );
- dcnt = FT_NEXT_BYTE( dp );
- }
- else
- {
- if ( nuni < duni )
- ret[i++] = nuni;
- /* If it is within the default range then ignore it -- */
- /* that should not have happened */
- ni++;
- if ( ni > numMappings )
- break;
-
- nuni = (FT_UInt32)TT_NEXT_UINT24( p );
- p += 2;
- }
- }
-
- if ( ni <= numMappings )
- {
- /* If we get here then we have run out of all default ranges. */
- /* We have read one non-default mapping which we haven't stored */
- /* and there may be others that need to be read. */
- ret[i++] = nuni;
- while ( ni < numMappings )
- {
- ret[i++] = (FT_UInt32)TT_NEXT_UINT24( p );
- p += 2;
- ni++;
- }
- }
- else if ( di <= numRanges )
- {
- /* If we get here then we have run out of all non-default */
- /* mappings. We have read one default range which we haven't */
- /* stored and there may be others that need to be read. */
- for ( k = 0; k <= dcnt; k++ )
- ret[i++] = duni + k;
-
- while ( di < numRanges )
- {
- duni = (FT_UInt32)TT_NEXT_UINT24( dp );
- dcnt = FT_NEXT_BYTE( dp );
-
- for ( k = 0; k <= dcnt; k++ )
- ret[i++] = duni + k;
- di++;
- }
- }
-
- ret[i] = 0;
-
- return ret;
- }
- }
-
-
- FT_DEFINE_TT_CMAP(
- tt_cmap14_class_rec,
-
- sizeof ( TT_CMap14Rec ),
-
- (FT_CMap_InitFunc) tt_cmap14_init, /* init */
- (FT_CMap_DoneFunc) tt_cmap14_done, /* done */
- (FT_CMap_CharIndexFunc)tt_cmap14_char_index, /* char_index */
- (FT_CMap_CharNextFunc) tt_cmap14_char_next, /* char_next */
-
- /* Format 14 extension functions */
- (FT_CMap_CharVarIndexFunc) tt_cmap14_char_var_index,
- (FT_CMap_CharVarIsDefaultFunc)tt_cmap14_char_var_isdefault,
- (FT_CMap_VariantListFunc) tt_cmap14_variants,
- (FT_CMap_CharVariantListFunc) tt_cmap14_char_variants,
- (FT_CMap_VariantCharListFunc) tt_cmap14_variant_chars,
-
- 14,
- (TT_CMap_ValidateFunc)tt_cmap14_validate, /* validate */
- (TT_CMap_Info_GetFunc)tt_cmap14_get_info /* get_cmap_info */
- )
-
-#endif /* TT_CONFIG_CMAP_FORMAT_14 */
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** SYNTHETIC UNICODE *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- /* This charmap is generated using postscript glyph names. */
-
-#ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
-
- FT_CALLBACK_DEF( const char * )
- tt_get_glyph_name( void* face_, /* TT_Face */
- FT_UInt idx )
- {
- TT_Face face = (TT_Face)face_;
- FT_String* PSname = NULL;
-
-
- tt_face_get_ps_name( face, idx, &PSname );
-
- return PSname;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- tt_cmap_unicode_init( FT_CMap cmap, /* PS_Unicodes */
- FT_Pointer pointer )
- {
- PS_Unicodes unicodes = (PS_Unicodes)cmap;
- TT_Face face = (TT_Face)FT_CMAP_FACE( cmap );
- FT_Memory memory = FT_FACE_MEMORY( face );
- FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)face->psnames;
-
- FT_UNUSED( pointer );
-
-
- if ( !psnames->unicodes_init )
- return FT_THROW( Unimplemented_Feature );
-
- return psnames->unicodes_init( memory,
- unicodes,
- face->root.num_glyphs,
- &tt_get_glyph_name,
- (PS_FreeGlyphNameFunc)NULL,
- (FT_Pointer)face );
- }
-
-
- FT_CALLBACK_DEF( void )
- tt_cmap_unicode_done( FT_CMap cmap ) /* PS_Unicodes */
- {
- PS_Unicodes unicodes = (PS_Unicodes)cmap;
- FT_Face face = FT_CMAP_FACE( cmap );
- FT_Memory memory = FT_FACE_MEMORY( face );
-
-
- FT_FREE( unicodes->maps );
- unicodes->num_maps = 0;
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- tt_cmap_unicode_char_index( FT_CMap cmap, /* PS_Unicodes */
- FT_UInt32 char_code )
- {
- PS_Unicodes unicodes = (PS_Unicodes)cmap;
- TT_Face face = (TT_Face)FT_CMAP_FACE( cmap );
- FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)face->psnames;
-
-
- return psnames->unicodes_char_index( unicodes, char_code );
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- tt_cmap_unicode_char_next( FT_CMap cmap, /* PS_Unicodes */
- FT_UInt32 *pchar_code )
- {
- PS_Unicodes unicodes = (PS_Unicodes)cmap;
- TT_Face face = (TT_Face)FT_CMAP_FACE( cmap );
- FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)face->psnames;
-
-
- return psnames->unicodes_char_next( unicodes, pchar_code );
- }
-
-
- FT_DEFINE_TT_CMAP(
- tt_cmap_unicode_class_rec,
-
- sizeof ( PS_UnicodesRec ),
-
- (FT_CMap_InitFunc) tt_cmap_unicode_init, /* init */
- (FT_CMap_DoneFunc) tt_cmap_unicode_done, /* done */
- (FT_CMap_CharIndexFunc)tt_cmap_unicode_char_index, /* char_index */
- (FT_CMap_CharNextFunc) tt_cmap_unicode_char_next, /* char_next */
-
- (FT_CMap_CharVarIndexFunc) NULL, /* char_var_index */
- (FT_CMap_CharVarIsDefaultFunc)NULL, /* char_var_default */
- (FT_CMap_VariantListFunc) NULL, /* variant_list */
- (FT_CMap_CharVariantListFunc) NULL, /* charvariant_list */
- (FT_CMap_VariantCharListFunc) NULL, /* variantchar_list */
-
- ~0U,
- (TT_CMap_ValidateFunc)NULL, /* validate */
- (TT_CMap_Info_GetFunc)NULL /* get_cmap_info */
- )
-
-#endif /* FT_CONFIG_OPTION_POSTSCRIPT_NAMES */
-
-
- static const TT_CMap_Class tt_cmap_classes[] =
- {
-#undef TTCMAPCITEM
-#define TTCMAPCITEM( a ) &a,
-#include "ttcmapc.h"
- NULL,
- };
-
-
- /* parse the `cmap' table and build the corresponding TT_CMap objects */
- /* in the current face */
- /* */
- FT_LOCAL_DEF( FT_Error )
- tt_face_build_cmaps( TT_Face face )
- {
- FT_Byte* const table = face->cmap_table;
- FT_Byte* limit;
- FT_UInt volatile num_cmaps;
- FT_Byte* volatile p = table;
- FT_Library library = FT_FACE_LIBRARY( face );
-
- FT_UNUSED( library );
-
-
- if ( !p || face->cmap_size < 4 )
- return FT_THROW( Invalid_Table );
-
- /* Version 1.8.3 of the OpenType specification contains the following */
- /* (https://docs.microsoft.com/en-us/typography/opentype/spec/cmap): */
- /* */
- /* The 'cmap' table version number remains at 0x0000 for fonts that */
- /* make use of the newer subtable formats. */
- /* */
- /* This essentially means that a version format test is useless. */
-
- /* ignore format */
- p += 2;
-
- num_cmaps = TT_NEXT_USHORT( p );
- FT_TRACE4(( "tt_face_build_cmaps: %d cmaps\n", num_cmaps ));
-
- limit = table + face->cmap_size;
- for ( ; num_cmaps > 0 && p + 8 <= limit; num_cmaps-- )
- {
- FT_CharMapRec charmap;
- FT_UInt32 offset;
-
-
- charmap.platform_id = TT_NEXT_USHORT( p );
- charmap.encoding_id = TT_NEXT_USHORT( p );
- charmap.face = FT_FACE( face );
- charmap.encoding = FT_ENCODING_NONE; /* will be filled later */
- offset = TT_NEXT_ULONG( p );
-
- if ( offset && offset <= face->cmap_size - 2 )
- {
- FT_Byte* volatile cmap = table + offset;
- volatile FT_UInt format = TT_PEEK_USHORT( cmap );
- const TT_CMap_Class* volatile pclazz = tt_cmap_classes;
- TT_CMap_Class volatile clazz;
-
-
- for ( ; *pclazz; pclazz++ )
- {
- clazz = *pclazz;
- if ( clazz->format == format )
- {
- volatile TT_ValidatorRec valid;
- volatile FT_Error error = FT_Err_Ok;
-
-
- ft_validator_init( FT_VALIDATOR( &valid ), cmap, limit,
- FT_VALIDATE_DEFAULT );
-
- valid.num_glyphs = (FT_UInt)face->max_profile.numGlyphs;
-
- if ( ft_setjmp( FT_VALIDATOR( &valid )->jump_buffer) == 0 )
- {
- /* validate this cmap sub-table */
- error = clazz->validate( cmap, FT_VALIDATOR( &valid ) );
- }
-
- if ( !valid.validator.error )
- {
- FT_CMap ttcmap;
-
-
- /* It might make sense to store the single variation */
- /* selector cmap somewhere special. But it would have to be */
- /* in the public FT_FaceRec, and we can't change that. */
-
- if ( !FT_CMap_New( (FT_CMap_Class)clazz,
- cmap, &charmap, &ttcmap ) )
- {
- /* it is simpler to directly set `flags' than adding */
- /* a parameter to FT_CMap_New */
- ((TT_CMap)ttcmap)->flags = (FT_Int)error;
- }
- }
- else
- {
- FT_TRACE0(( "tt_face_build_cmaps:"
- " broken cmap sub-table ignored\n" ));
- }
- break;
- }
- }
-
- if ( !*pclazz )
- {
- FT_TRACE0(( "tt_face_build_cmaps:"
- " unsupported cmap sub-table ignored\n" ));
- }
- }
- }
-
- return FT_Err_Ok;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- tt_get_cmap_info( FT_CharMap charmap,
- TT_CMapInfo *cmap_info )
- {
- FT_CMap cmap = FT_CMAP( charmap );
- TT_CMap_Class clazz = (TT_CMap_Class)cmap->clazz;
-
-
- if ( clazz->get_cmap_info )
- return clazz->get_cmap_info( charmap, cmap_info );
- else
- return FT_THROW( Invalid_CharMap_Format );
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/sfnt/ttcmap.h b/contrib/libs/freetype/src/sfnt/ttcmap.h
deleted file mode 100644
index e2c5e72bf0..0000000000
--- a/contrib/libs/freetype/src/sfnt/ttcmap.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/****************************************************************************
- *
- * ttcmap.h
- *
- * TrueType character mapping table (cmap) support (specification).
- *
- * Copyright (C) 2002-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef TTCMAP_H_
-#define TTCMAP_H_
-
-
-#include <freetype/internal/tttypes.h>
-#include <freetype/internal/ftvalid.h>
-#include <freetype/internal/services/svttcmap.h>
-
-FT_BEGIN_HEADER
-
-
-#define TT_CMAP_FLAG_UNSORTED 1
-#define TT_CMAP_FLAG_OVERLAPPING 2
-
- typedef struct TT_CMapRec_
- {
- FT_CMapRec cmap;
- FT_Byte* data; /* pointer to in-memory cmap table */
- FT_Int flags; /* for format 4 only */
-
- } TT_CMapRec, *TT_CMap;
-
- typedef const struct TT_CMap_ClassRec_* TT_CMap_Class;
-
-
- typedef FT_Error
- (*TT_CMap_ValidateFunc)( FT_Byte* data,
- FT_Validator valid );
-
- typedef struct TT_CMap_ClassRec_
- {
- FT_CMap_ClassRec clazz;
- FT_UInt format;
- TT_CMap_ValidateFunc validate;
- TT_CMap_Info_GetFunc get_cmap_info;
-
- } TT_CMap_ClassRec;
-
-
-#define FT_DEFINE_TT_CMAP( class_, \
- size_, \
- init_, \
- done_, \
- char_index_, \
- char_next_, \
- char_var_index_, \
- char_var_default_, \
- variant_list_, \
- charvariant_list_, \
- variantchar_list_, \
- format_, \
- validate_, \
- get_cmap_info_ ) \
- FT_CALLBACK_TABLE_DEF \
- const TT_CMap_ClassRec class_ = \
- { \
- { size_, \
- init_, \
- done_, \
- char_index_, \
- char_next_, \
- char_var_index_, \
- char_var_default_, \
- variant_list_, \
- charvariant_list_, \
- variantchar_list_ \
- }, \
- \
- format_, \
- validate_, \
- get_cmap_info_ \
- };
-
-
-#undef TTCMAPCITEM
-#define TTCMAPCITEM( a ) FT_CALLBACK_TABLE const TT_CMap_ClassRec a;
-#include "ttcmapc.h"
-
-
- typedef struct TT_ValidatorRec_
- {
- FT_ValidatorRec validator;
- FT_UInt num_glyphs;
-
- } TT_ValidatorRec, *TT_Validator;
-
-
-#define TT_VALIDATOR( x ) ( (TT_Validator)( x ) )
-#define TT_VALID_GLYPH_COUNT( x ) TT_VALIDATOR( x )->num_glyphs
-
-
- FT_CALLBACK_TABLE const TT_CMap_ClassRec tt_cmap_unicode_class_rec;
-
- FT_LOCAL( FT_Error )
- tt_face_build_cmaps( TT_Face face );
-
- /* used in tt-cmaps service */
- FT_LOCAL( FT_Error )
- tt_get_cmap_info( FT_CharMap charmap,
- TT_CMapInfo *cmap_info );
-
-
-FT_END_HEADER
-
-#endif /* TTCMAP_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/sfnt/ttcmapc.h b/contrib/libs/freetype/src/sfnt/ttcmapc.h
deleted file mode 100644
index 370898363f..0000000000
--- a/contrib/libs/freetype/src/sfnt/ttcmapc.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/****************************************************************************
- *
- * ttcmapc.h
- *
- * TT CMAP classes definitions (specification only).
- *
- * Copyright (C) 2009-2024 by
- * Oran Agra and Mickey Gabel.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifdef TT_CONFIG_CMAP_FORMAT_0
- TTCMAPCITEM( tt_cmap0_class_rec )
-#endif
-
-#ifdef TT_CONFIG_CMAP_FORMAT_2
- TTCMAPCITEM( tt_cmap2_class_rec )
-#endif
-
-#ifdef TT_CONFIG_CMAP_FORMAT_4
- TTCMAPCITEM( tt_cmap4_class_rec )
-#endif
-
-#ifdef TT_CONFIG_CMAP_FORMAT_6
- TTCMAPCITEM( tt_cmap6_class_rec )
-#endif
-
-#ifdef TT_CONFIG_CMAP_FORMAT_8
- TTCMAPCITEM( tt_cmap8_class_rec )
-#endif
-
-#ifdef TT_CONFIG_CMAP_FORMAT_10
- TTCMAPCITEM( tt_cmap10_class_rec )
-#endif
-
-#ifdef TT_CONFIG_CMAP_FORMAT_12
- TTCMAPCITEM( tt_cmap12_class_rec )
-#endif
-
-#ifdef TT_CONFIG_CMAP_FORMAT_13
- TTCMAPCITEM( tt_cmap13_class_rec )
-#endif
-
-#ifdef TT_CONFIG_CMAP_FORMAT_14
- TTCMAPCITEM( tt_cmap14_class_rec )
-#endif
-
-
- /* END */
diff --git a/contrib/libs/freetype/src/sfnt/ttcolr.c b/contrib/libs/freetype/src/sfnt/ttcolr.c
deleted file mode 100644
index b37658dde9..0000000000
--- a/contrib/libs/freetype/src/sfnt/ttcolr.c
+++ /dev/null
@@ -1,1923 +0,0 @@
-/****************************************************************************
- *
- * ttcolr.c
- *
- * TrueType and OpenType colored glyph layer support (body).
- *
- * Copyright (C) 2018-2024 by
- * David Turner, Robert Wilhelm, Dominik Röttsches, and Werner Lemberg.
- *
- * Originally written by Shao Yu Zhang <shaozhang@fb.com>.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /**************************************************************************
- *
- * `COLR' table specification:
- *
- * https://www.microsoft.com/typography/otspec/colr.htm
- *
- */
-
-
-#include <freetype/internal/ftcalc.h>
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/tttags.h>
-#include <freetype/ftcolor.h>
-#include <freetype/config/integer-types.h>
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
-#include <freetype/internal/services/svmm.h>
-#endif
-
-#ifdef TT_CONFIG_OPTION_COLOR_LAYERS
-
-#include "ttcolr.h"
-
-
- /* NOTE: These are the table sizes calculated through the specs. */
-#define BASE_GLYPH_SIZE 6U
-#define BASE_GLYPH_PAINT_RECORD_SIZE 6U
-#define LAYER_V1_LIST_PAINT_OFFSET_SIZE 4U
-#define LAYER_V1_LIST_NUM_LAYERS_SIZE 4U
-#define COLOR_STOP_SIZE 6U
-#define VAR_IDX_BASE_SIZE 4U
-#define LAYER_SIZE 4U
-/* https://docs.microsoft.com/en-us/typography/opentype/spec/colr#colr-header */
-/* 3 * uint16 + 2 * Offset32 */
-#define COLRV0_HEADER_SIZE 14U
-/* COLRV0_HEADER_SIZE + 5 * Offset32 */
-#define COLRV1_HEADER_SIZE 34U
-
-
-#define ENSURE_READ_BYTES( byte_size ) \
- if ( p < colr->paints_start_v1 || \
- p > (FT_Byte*)colr->table + colr->table_size - byte_size ) \
- return 0
-
-
- typedef enum FT_PaintFormat_Internal_
- {
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_SOLID = 3,
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_LINEAR_GRADIENT = 5,
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_RADIAL_GRADIENT = 7,
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_SWEEP_GRADIENT = 9,
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_TRANSFORM = 13,
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_TRANSLATE = 15,
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_SCALE = 17,
- FT_COLR_PAINTFORMAT_INTERNAL_SCALE_CENTER = 18,
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_SCALE_CENTER = 19,
- FT_COLR_PAINTFORMAT_INTERNAL_SCALE_UNIFORM = 20,
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_SCALE_UNIFORM = 21,
- FT_COLR_PAINTFORMAT_INTERNAL_SCALE_UNIFORM_CENTER = 22,
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_SCALE_UNIFORM_CENTER = 23,
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_ROTATE = 25,
- FT_COLR_PAINTFORMAT_INTERNAL_ROTATE_CENTER = 26,
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_ROTATE_CENTER = 27,
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_SKEW = 29,
- FT_COLR_PAINTFORMAT_INTERNAL_SKEW_CENTER = 30,
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_SKEW_CENTER = 31,
-
- } FT_PaintFormat_Internal;
-
-
- typedef struct BaseGlyphRecord_
- {
- FT_UShort gid;
- FT_UShort first_layer_index;
- FT_UShort num_layers;
-
- } BaseGlyphRecord;
-
-
- typedef struct BaseGlyphV1Record_
- {
- FT_UShort gid;
- /* Offset from start of BaseGlyphV1List, i.e., from base_glyphs_v1. */
- FT_ULong paint_offset;
-
- } BaseGlyphV1Record;
-
-
- typedef struct Colr_
- {
- FT_UShort version;
- FT_UShort num_base_glyphs;
- FT_UShort num_layers;
-
- FT_Byte* base_glyphs;
- FT_Byte* layers;
-
- FT_ULong num_base_glyphs_v1;
- /* Points at beginning of BaseGlyphV1List. */
- FT_Byte* base_glyphs_v1;
-
- FT_ULong num_layers_v1;
- FT_Byte* layers_v1;
-
- FT_Byte* clip_list;
-
- /*
- * Paint tables start at the minimum of the end of the LayerList and the
- * end of the BaseGlyphList. Record this location in a field here for
- * safety checks when accessing paint tables.
- */
- FT_Byte* paints_start_v1;
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- /* Item Variation Store for variable 'COLR' v1. */
- GX_ItemVarStoreRec var_store;
- GX_DeltaSetIdxMapRec delta_set_idx_map;
-#endif
-
- /* The memory that backs up the `COLR' table. */
- void* table;
- FT_ULong table_size;
-
- } Colr;
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT ttcolr
-
-
- FT_LOCAL_DEF( FT_Error )
- tt_face_load_colr( TT_Face face,
- FT_Stream stream )
- {
- FT_Error error;
- FT_Memory memory = face->root.memory;
-
- FT_Byte* table = NULL;
- FT_Byte* p = NULL;
- /* Needed for reading array lengths in referenced tables. */
- FT_Byte* p1 = NULL;
-
- Colr* colr = NULL;
-
- FT_ULong base_glyph_offset, layer_offset;
- FT_ULong base_glyphs_offset_v1, num_base_glyphs_v1;
- FT_ULong layer_offset_v1, num_layers_v1, clip_list_offset;
- FT_ULong table_size;
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- FT_ULong colr_offset_in_stream;
-#endif
-
-
- /* `COLR' always needs `CPAL' */
- if ( !face->cpal )
- return FT_THROW( Invalid_File_Format );
-
- error = face->goto_table( face, TTAG_COLR, stream, &table_size );
- if ( error )
- goto NoColr;
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- colr_offset_in_stream = FT_STREAM_POS();
-#endif
-
- if ( table_size < COLRV0_HEADER_SIZE )
- goto NoColr;
-
- if ( FT_FRAME_EXTRACT( table_size, table ) )
- goto NoColr;
-
- p = table;
-
- if ( FT_NEW( colr ) )
- goto NoColr;
-
- colr->version = FT_NEXT_USHORT( p );
- if ( colr->version != 0 && colr->version != 1 )
- goto InvalidTable;
-
- colr->num_base_glyphs = FT_NEXT_USHORT( p );
- base_glyph_offset = FT_NEXT_ULONG( p );
-
- if ( table_size <= base_glyph_offset )
- goto InvalidTable;
- if ( ( table_size - base_glyph_offset ) / BASE_GLYPH_SIZE
- < colr->num_base_glyphs )
- goto InvalidTable;
-
- layer_offset = FT_NEXT_ULONG( p );
- colr->num_layers = FT_NEXT_USHORT( p );
-
- if ( table_size <= layer_offset )
- goto InvalidTable;
- if ( ( table_size - layer_offset ) / LAYER_SIZE
- < colr->num_layers )
- goto InvalidTable;
-
- if ( colr->version == 1 )
- {
- if ( table_size < COLRV1_HEADER_SIZE )
- goto InvalidTable;
-
- base_glyphs_offset_v1 = FT_NEXT_ULONG( p );
-
- if ( table_size - 4 <= base_glyphs_offset_v1 )
- goto InvalidTable;
-
- p1 = (FT_Byte*)( table + base_glyphs_offset_v1 );
- num_base_glyphs_v1 = FT_PEEK_ULONG( p1 );
-
- if ( ( table_size - base_glyphs_offset_v1 ) / BASE_GLYPH_PAINT_RECORD_SIZE
- < num_base_glyphs_v1 )
- goto InvalidTable;
-
- colr->num_base_glyphs_v1 = num_base_glyphs_v1;
- colr->base_glyphs_v1 = p1;
-
- layer_offset_v1 = FT_NEXT_ULONG( p );
-
- if ( table_size <= layer_offset_v1 )
- goto InvalidTable;
-
- if ( layer_offset_v1 )
- {
- if ( table_size - 4 <= layer_offset_v1 )
- goto InvalidTable;
-
- p1 = (FT_Byte*)( table + layer_offset_v1 );
- num_layers_v1 = FT_PEEK_ULONG( p1 );
-
- if ( ( table_size - layer_offset_v1 ) / LAYER_V1_LIST_PAINT_OFFSET_SIZE
- < num_layers_v1 )
- goto InvalidTable;
-
- colr->num_layers_v1 = num_layers_v1;
- colr->layers_v1 = p1;
-
- colr->paints_start_v1 =
- FT_MIN( colr->base_glyphs_v1 +
- colr->num_base_glyphs_v1 * BASE_GLYPH_PAINT_RECORD_SIZE,
- colr->layers_v1 +
- colr->num_layers_v1 * LAYER_V1_LIST_PAINT_OFFSET_SIZE );
- }
- else
- {
- colr->num_layers_v1 = 0;
- colr->layers_v1 = 0;
- colr->paints_start_v1 =
- colr->base_glyphs_v1 +
- colr->num_base_glyphs_v1 * BASE_GLYPH_PAINT_RECORD_SIZE;
- }
-
- clip_list_offset = FT_NEXT_ULONG( p );
-
- if ( table_size <= clip_list_offset )
- goto InvalidTable;
-
- if ( clip_list_offset )
- colr->clip_list = (FT_Byte*)( table + clip_list_offset );
- else
- colr->clip_list = 0;
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- colr->var_store.dataCount = 0;
- colr->var_store.varData = NULL;
- colr->var_store.axisCount = 0;
- colr->var_store.regionCount = 0;
- colr->var_store.varRegionList = 0;
-
- colr->delta_set_idx_map.mapCount = 0;
- colr->delta_set_idx_map.outerIndex = NULL;
- colr->delta_set_idx_map.innerIndex = NULL;
-
- if ( face->variation_support & TT_FACE_FLAG_VAR_FVAR )
- {
- FT_ULong var_idx_map_offset, var_store_offset;
-
- FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm;
-
-
- var_idx_map_offset = FT_NEXT_ULONG( p );
-
- if ( var_idx_map_offset >= table_size )
- goto InvalidTable;
-
- var_store_offset = FT_NEXT_ULONG( p );
- if ( table_size <= var_store_offset )
- goto InvalidTable;
-
- if ( var_store_offset )
- {
- /* If variation info has not been initialized yet, try doing so, */
- /* otherwise loading the variation store will fail as it */
- /* requires access to `blend` for checking the number of axes. */
- if ( !face->blend )
- if ( mm->get_mm_var( FT_FACE( face ), NULL ) )
- goto InvalidTable;
-
- /* Try loading `VarIdxMap` and `VarStore`. */
- error = mm->load_item_var_store(
- FT_FACE( face ),
- colr_offset_in_stream + var_store_offset,
- &colr->var_store );
- if ( error != FT_Err_Ok )
- goto InvalidTable;
- }
-
- if ( colr->var_store.axisCount && var_idx_map_offset )
- {
- error = mm->load_delta_set_idx_map(
- FT_FACE( face ),
- colr_offset_in_stream + var_idx_map_offset,
- &colr->delta_set_idx_map,
- &colr->var_store,
- table_size );
- if ( error != FT_Err_Ok )
- goto InvalidTable;
- }
- }
-#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
- }
-
- colr->base_glyphs = (FT_Byte*)( table + base_glyph_offset );
- colr->layers = (FT_Byte*)( table + layer_offset );
- colr->table = table;
- colr->table_size = table_size;
-
- face->colr = colr;
-
- return FT_Err_Ok;
-
- InvalidTable:
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- {
- FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm;
-
-
- mm->done_delta_set_idx_map( FT_FACE( face ),
- &colr->delta_set_idx_map );
- mm->done_item_var_store( FT_FACE( face ),
- &colr->var_store );
- }
-#endif
-
- error = FT_THROW( Invalid_Table );
-
- NoColr:
- FT_FRAME_RELEASE( table );
- FT_FREE( colr );
-
- return error;
- }
-
-
- FT_LOCAL_DEF( void )
- tt_face_free_colr( TT_Face face )
- {
- FT_Stream stream = face->root.stream;
- FT_Memory memory = face->root.memory;
-
- Colr* colr = (Colr*)face->colr;
-
-
- if ( colr )
- {
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- {
- FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm;
-
-
- mm->done_delta_set_idx_map( FT_FACE( face ),
- &colr->delta_set_idx_map );
- mm->done_item_var_store( FT_FACE( face ),
- &colr->var_store );
- }
-#endif
- FT_FRAME_RELEASE( colr->table );
- FT_FREE( colr );
- }
- }
-
-
- static FT_Bool
- find_base_glyph_record( FT_Byte* base_glyph_begin,
- FT_UInt num_base_glyph,
- FT_UInt glyph_id,
- BaseGlyphRecord* record )
- {
- FT_UInt min = 0;
- FT_UInt max = num_base_glyph;
-
-
- while ( min < max )
- {
- FT_UInt mid = min + ( max - min ) / 2;
- FT_Byte* p = base_glyph_begin + mid * BASE_GLYPH_SIZE;
-
- FT_UShort gid = FT_NEXT_USHORT( p );
-
-
- if ( gid < glyph_id )
- min = mid + 1;
- else if (gid > glyph_id )
- max = mid;
- else
- {
- record->gid = gid;
- record->first_layer_index = FT_NEXT_USHORT( p );
- record->num_layers = FT_NEXT_USHORT( p );
-
- return 1;
- }
- }
-
- return 0;
- }
-
-
- FT_LOCAL_DEF( FT_Bool )
- tt_face_get_colr_layer( TT_Face face,
- FT_UInt base_glyph,
- FT_UInt *aglyph_index,
- FT_UInt *acolor_index,
- FT_LayerIterator* iterator )
- {
- Colr* colr = (Colr*)face->colr;
- BaseGlyphRecord glyph_record;
-
-
- if ( !colr )
- return 0;
-
- if ( !iterator->p )
- {
- FT_ULong offset;
-
-
- /* first call to function */
- iterator->layer = 0;
-
- if ( !find_base_glyph_record( colr->base_glyphs,
- colr->num_base_glyphs,
- base_glyph,
- &glyph_record ) )
- return 0;
-
- if ( glyph_record.num_layers )
- iterator->num_layers = glyph_record.num_layers;
- else
- return 0;
-
- offset = LAYER_SIZE * glyph_record.first_layer_index;
- if ( offset + LAYER_SIZE * glyph_record.num_layers > colr->table_size )
- return 0;
-
- iterator->p = colr->layers + offset;
- }
-
- if ( iterator->layer >= iterator->num_layers ||
- iterator->p < colr->layers ||
- iterator->p >= ( (FT_Byte*)colr->table + colr->table_size ) )
- return 0;
-
- *aglyph_index = FT_NEXT_USHORT( iterator->p );
- *acolor_index = FT_NEXT_USHORT( iterator->p );
-
- if ( *aglyph_index >= (FT_UInt)( FT_FACE( face )->num_glyphs ) ||
- ( *acolor_index != 0xFFFF &&
- *acolor_index >= face->palette_data.num_palette_entries ) )
- return 0;
-
- iterator->layer++;
-
- return 1;
- }
-
-
- static FT_Bool
- read_color_line( Colr* colr,
- FT_Byte* color_line_p,
- FT_ColorLine* colorline,
- FT_Bool read_variable )
- {
- FT_Byte* p = color_line_p;
- FT_PaintExtend paint_extend;
-
-
- ENSURE_READ_BYTES( 3 );
-
- paint_extend = (FT_PaintExtend)FT_NEXT_BYTE( p );
- if ( paint_extend > FT_COLR_PAINT_EXTEND_REFLECT )
- return 0;
-
- colorline->extend = paint_extend;
-
- colorline->color_stop_iterator.num_color_stops = FT_NEXT_USHORT( p );
- colorline->color_stop_iterator.p = p;
- colorline->color_stop_iterator.current_color_stop = 0;
- colorline->color_stop_iterator.read_variable = read_variable;
-
- return 1;
- }
-
-
- /*
- * Read a paint offset for `FT_Paint*` objects that have them and check
- * whether it is within reasonable limits within the font and the COLR
- * table.
- *
- * Return 1 on success, 0 on failure.
- */
- static FT_Bool
- get_child_table_pointer ( Colr* colr,
- FT_Byte* paint_base,
- FT_Byte** p,
- FT_Byte** child_table_pointer )
- {
- FT_UInt32 paint_offset;
- FT_Byte* child_table_p;
-
-
- if ( !child_table_pointer )
- return 0;
-
- if ( *p < colr->paints_start_v1 ||
- *p > (FT_Byte*)colr->table + colr->table_size - 1 - 3 )
- return 0;
-
- paint_offset = FT_NEXT_UOFF3( *p );
- if ( !paint_offset )
- return 0;
-
- child_table_p = (FT_Byte*)( paint_base + paint_offset );
-
- if ( child_table_p < colr->paints_start_v1 ||
- child_table_p >= ( (FT_Byte*)colr->table + colr->table_size ) )
- return 0;
-
- *child_table_pointer = child_table_p;
- return 1;
- }
-
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
-
- static FT_Bool
- get_deltas_for_var_index_base ( TT_Face face,
- Colr* colr,
- FT_ULong var_index_base,
- FT_UInt num_deltas,
- FT_ItemVarDelta* deltas )
- {
- FT_UInt outer_index = 0;
- FT_UInt inner_index = 0;
- FT_ULong loop_var_index = var_index_base;
-
- FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm;
-
- FT_UInt i = 0;
-
-
- if ( var_index_base == 0xFFFFFFFF )
- {
- for ( i = 0; i < num_deltas; ++i )
- deltas[i] = 0;
- return 1;
- }
-
- for ( i = 0; i < num_deltas; ++i )
- {
- loop_var_index = var_index_base + i;
-
- if ( colr->delta_set_idx_map.innerIndex )
- {
- if ( loop_var_index >= colr->delta_set_idx_map.mapCount )
- loop_var_index = colr->delta_set_idx_map.mapCount - 1;
-
- outer_index = colr->delta_set_idx_map.outerIndex[loop_var_index];
- inner_index = colr->delta_set_idx_map.innerIndex[loop_var_index];
- }
- else
- {
- outer_index = 0;
- inner_index = loop_var_index;
- }
-
- deltas[i] = mm->get_item_delta( FT_FACE( face ), &colr->var_store,
- outer_index, inner_index );
- }
-
- return 1;
- }
-
-#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
-
-
- static FT_Bool
- read_paint( TT_Face face,
- Colr* colr,
- FT_Byte* p,
- FT_COLR_Paint* apaint )
- {
- FT_Byte* paint_base = p;
- FT_Byte* child_table_p = NULL;
- FT_Bool do_read_var = FALSE;
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- FT_ULong var_index_base = 0;
- /* Longest varIndexBase offset is 5 in the spec. */
- FT_ItemVarDelta item_deltas[6] = { 0, 0, 0, 0, 0, 0 };
-#else
- FT_UNUSED( face );
-#endif
-
-
- if ( !p || !colr || !colr->table )
- return 0;
-
- /* The last byte of the 'COLR' table is at 'size-1'; subtract 1 of */
- /* that to account for the expected format byte we are going to read. */
- if ( p < colr->paints_start_v1 ||
- p > (FT_Byte*)colr->table + colr->table_size - 2 )
- return 0;
-
- apaint->format = (FT_PaintFormat)FT_NEXT_BYTE( p );
-
- if ( apaint->format >= FT_COLR_PAINT_FORMAT_MAX )
- return 0;
-
- if ( apaint->format == FT_COLR_PAINTFORMAT_COLR_LAYERS )
- {
- /* Initialize layer iterator/ */
- FT_Byte num_layers;
- FT_UInt32 first_layer_index;
-
-
- ENSURE_READ_BYTES( 5 );
- num_layers = FT_NEXT_BYTE( p );
- if ( num_layers > colr->num_layers_v1 )
- return 0;
-
- first_layer_index = FT_NEXT_ULONG( p );
- if ( first_layer_index + num_layers > colr->num_layers_v1 )
- return 0;
-
- apaint->u.colr_layers.layer_iterator.num_layers = num_layers;
- apaint->u.colr_layers.layer_iterator.layer = 0;
- /* TODO: Check whether pointer is outside colr? */
- apaint->u.colr_layers.layer_iterator.p =
- colr->layers_v1 +
- LAYER_V1_LIST_NUM_LAYERS_SIZE +
- LAYER_V1_LIST_PAINT_OFFSET_SIZE * first_layer_index;
-
- return 1;
- }
-
- else if ( apaint->format == FT_COLR_PAINTFORMAT_SOLID ||
- (FT_PaintFormat_Internal)apaint->format ==
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_SOLID )
- {
- ENSURE_READ_BYTES( 4 );
- apaint->u.solid.color.palette_index = FT_NEXT_USHORT( p );
- apaint->u.solid.color.alpha = FT_NEXT_SHORT( p );
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- if ( (FT_PaintFormat_Internal)apaint->format ==
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_SOLID )
- {
- ENSURE_READ_BYTES( 4 );
- var_index_base = FT_NEXT_ULONG( p );
-
- if ( !get_deltas_for_var_index_base( face, colr, var_index_base, 1,
- item_deltas ) )
- return 0;
-
- apaint->u.solid.color.alpha += (FT_F2Dot14)item_deltas[0];
- }
-#endif
-
- apaint->format = FT_COLR_PAINTFORMAT_SOLID;
-
- return 1;
- }
-
- else if ( apaint->format == FT_COLR_PAINTFORMAT_COLR_GLYPH )
- {
- ENSURE_READ_BYTES(2);
- apaint->u.colr_glyph.glyphID = FT_NEXT_USHORT( p );
-
- return 1;
- }
-
- /*
- * Grouped below here are all paint formats that have an offset to a
- * child paint table as the first entry (for example, a color line or a
- * child paint table). Retrieve that and determine whether that paint
- * offset is valid first.
- */
-
- if ( !get_child_table_pointer( colr, paint_base, &p, &child_table_p ) )
- return 0;
-
- if ( apaint->format == FT_COLR_PAINTFORMAT_LINEAR_GRADIENT ||
- ( do_read_var =
- ( (FT_PaintFormat_Internal)apaint->format ==
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_LINEAR_GRADIENT ) ) )
- {
- if ( !read_color_line( colr,
- child_table_p,
- &apaint->u.linear_gradient.colorline,
- do_read_var ) )
- return 0;
-
- /*
- * In order to support variations expose these as FT_Fixed 16.16
- * values so that we can support fractional values after
- * interpolation.
- */
- ENSURE_READ_BYTES( 12 );
- apaint->u.linear_gradient.p0.x = INT_TO_FIXED( FT_NEXT_SHORT( p ) );
- apaint->u.linear_gradient.p0.y = INT_TO_FIXED( FT_NEXT_SHORT( p ) );
- apaint->u.linear_gradient.p1.x = INT_TO_FIXED( FT_NEXT_SHORT( p ) );
- apaint->u.linear_gradient.p1.y = INT_TO_FIXED( FT_NEXT_SHORT( p ) );
- apaint->u.linear_gradient.p2.x = INT_TO_FIXED( FT_NEXT_SHORT( p ) );
- apaint->u.linear_gradient.p2.y = INT_TO_FIXED( FT_NEXT_SHORT( p ) );
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- if ( do_read_var )
- {
- ENSURE_READ_BYTES( 4 );
- var_index_base = FT_NEXT_ULONG ( p );
-
- if ( !get_deltas_for_var_index_base( face, colr, var_index_base, 6,
- item_deltas ) )
- return 0;
-
- apaint->u.linear_gradient.p0.x += INT_TO_FIXED( item_deltas[0] );
- apaint->u.linear_gradient.p0.y += INT_TO_FIXED( item_deltas[1] );
- apaint->u.linear_gradient.p1.x += INT_TO_FIXED( item_deltas[2] );
- apaint->u.linear_gradient.p1.y += INT_TO_FIXED( item_deltas[3] );
- apaint->u.linear_gradient.p2.x += INT_TO_FIXED( item_deltas[4] );
- apaint->u.linear_gradient.p2.y += INT_TO_FIXED( item_deltas[5] );
- }
-#endif
-
- apaint->format = FT_COLR_PAINTFORMAT_LINEAR_GRADIENT;
-
- return 1;
- }
-
- else if ( apaint->format == FT_COLR_PAINTFORMAT_RADIAL_GRADIENT ||
- ( do_read_var =
- ( (FT_PaintFormat_Internal)apaint->format ==
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_RADIAL_GRADIENT ) ) )
- {
- FT_Pos tmp;
-
-
- if ( !read_color_line( colr,
- child_table_p,
- &apaint->u.radial_gradient.colorline,
- do_read_var ) )
- return 0;
-
-
- /* In the OpenType specification, `r0` and `r1` are defined as */
- /* `UFWORD`. Since FreeType doesn't have a corresponding 16.16 */
- /* format we convert to `FWORD` and replace negative values with */
- /* (32bit) `FT_INT_MAX`. */
-
- ENSURE_READ_BYTES( 12 );
-
- apaint->u.radial_gradient.c0.x = INT_TO_FIXED( FT_NEXT_SHORT( p ) );
- apaint->u.radial_gradient.c0.y = INT_TO_FIXED( FT_NEXT_SHORT( p ) );
-
- tmp = INT_TO_FIXED( FT_NEXT_SHORT( p ) );
- apaint->u.radial_gradient.r0 = tmp < 0 ? FT_INT_MAX : tmp;
-
- apaint->u.radial_gradient.c1.x = INT_TO_FIXED( FT_NEXT_SHORT( p ) );
- apaint->u.radial_gradient.c1.y = INT_TO_FIXED( FT_NEXT_SHORT( p ) );
-
- tmp = INT_TO_FIXED( FT_NEXT_SHORT( p ) );
- apaint->u.radial_gradient.r1 = tmp < 0 ? FT_INT_MAX : tmp;
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- if ( do_read_var )
- {
- ENSURE_READ_BYTES( 4 );
- var_index_base = FT_NEXT_ULONG ( p );
-
- if ( !get_deltas_for_var_index_base( face, colr, var_index_base, 6,
- item_deltas ) )
- return 0;
-
- apaint->u.radial_gradient.c0.x += INT_TO_FIXED( item_deltas[0] );
- apaint->u.radial_gradient.c0.y += INT_TO_FIXED( item_deltas[1] );
-
- // TODO: Anything to be done about UFWORD deltas here?
- apaint->u.radial_gradient.r0 += INT_TO_FIXED( item_deltas[2] );
-
- apaint->u.radial_gradient.c1.x += INT_TO_FIXED( item_deltas[3] );
- apaint->u.radial_gradient.c1.y += INT_TO_FIXED( item_deltas[4] );
-
- apaint->u.radial_gradient.r1 += INT_TO_FIXED( item_deltas[5] );
- }
-#endif
-
- apaint->format = FT_COLR_PAINTFORMAT_RADIAL_GRADIENT;
-
- return 1;
- }
-
- else if ( apaint->format == FT_COLR_PAINTFORMAT_SWEEP_GRADIENT ||
- ( do_read_var =
- ( (FT_PaintFormat_Internal)apaint->format ==
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_SWEEP_GRADIENT ) ) )
- {
- if ( !read_color_line( colr,
- child_table_p,
- &apaint->u.sweep_gradient.colorline,
- do_read_var) )
- return 0;
-
- ENSURE_READ_BYTES( 8 );
-
- apaint->u.sweep_gradient.center.x =
- INT_TO_FIXED( FT_NEXT_SHORT( p ) );
- apaint->u.sweep_gradient.center.y =
- INT_TO_FIXED( FT_NEXT_SHORT( p ) );
-
- apaint->u.sweep_gradient.start_angle =
- F2DOT14_TO_FIXED( FT_NEXT_SHORT( p ) );
- apaint->u.sweep_gradient.end_angle =
- F2DOT14_TO_FIXED( FT_NEXT_SHORT( p ) );
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- if ( do_read_var )
- {
- ENSURE_READ_BYTES( 4 );
- var_index_base = FT_NEXT_ULONG ( p );
-
- if ( !get_deltas_for_var_index_base( face, colr, var_index_base, 4,
- item_deltas ) )
- return 0;
-
- // TODO: Handle overflow?
- apaint->u.sweep_gradient.center.x += INT_TO_FIXED( item_deltas[0] );
- apaint->u.sweep_gradient.center.y += INT_TO_FIXED( item_deltas[1] );
-
- apaint->u.sweep_gradient.start_angle +=
- F2DOT14_TO_FIXED( item_deltas[2] );
- apaint->u.sweep_gradient.end_angle +=
- F2DOT14_TO_FIXED( item_deltas[3] );
- }
-#endif
- apaint->format = FT_COLR_PAINTFORMAT_SWEEP_GRADIENT;
-
- return 1;
- }
-
- if ( apaint->format == FT_COLR_PAINTFORMAT_GLYPH )
- {
- ENSURE_READ_BYTES( 2 );
- apaint->u.glyph.paint.p = child_table_p;
- apaint->u.glyph.paint.insert_root_transform = 0;
- apaint->u.glyph.glyphID = FT_NEXT_USHORT( p );
-
- return 1;
- }
-
- else if ( apaint->format == FT_COLR_PAINTFORMAT_TRANSFORM ||
- (FT_PaintFormat_Internal)apaint->format ==
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_TRANSFORM )
- {
- apaint->u.transform.paint.p = child_table_p;
- apaint->u.transform.paint.insert_root_transform = 0;
-
- if ( !get_child_table_pointer( colr, paint_base, &p, &child_table_p ) )
- return 0;
-
- p = child_table_p;
-
- /*
- * The following matrix coefficients are encoded as
- * OpenType 16.16 fixed-point values.
- */
- ENSURE_READ_BYTES( 24 );
- apaint->u.transform.affine.xx = FT_NEXT_LONG( p );
- apaint->u.transform.affine.yx = FT_NEXT_LONG( p );
- apaint->u.transform.affine.xy = FT_NEXT_LONG( p );
- apaint->u.transform.affine.yy = FT_NEXT_LONG( p );
- apaint->u.transform.affine.dx = FT_NEXT_LONG( p );
- apaint->u.transform.affine.dy = FT_NEXT_LONG( p );
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- if ( (FT_PaintFormat_Internal)apaint->format ==
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_TRANSFORM )
- {
- ENSURE_READ_BYTES( 4 );
- var_index_base = FT_NEXT_ULONG( p );
-
- if ( !get_deltas_for_var_index_base( face, colr, var_index_base, 6,
- item_deltas ) )
- return 0;
-
- apaint->u.transform.affine.xx += (FT_Fixed)item_deltas[0];
- apaint->u.transform.affine.yx += (FT_Fixed)item_deltas[1];
- apaint->u.transform.affine.xy += (FT_Fixed)item_deltas[2];
- apaint->u.transform.affine.yy += (FT_Fixed)item_deltas[3];
- apaint->u.transform.affine.dx += (FT_Fixed)item_deltas[4];
- apaint->u.transform.affine.dy += (FT_Fixed)item_deltas[5];
- }
-#endif
-
- apaint->format = FT_COLR_PAINTFORMAT_TRANSFORM;
-
- return 1;
- }
-
- else if ( apaint->format == FT_COLR_PAINTFORMAT_TRANSLATE ||
- (FT_PaintFormat_Internal)apaint->format ==
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_TRANSLATE )
- {
- apaint->u.translate.paint.p = child_table_p;
- apaint->u.translate.paint.insert_root_transform = 0;
-
- ENSURE_READ_BYTES( 4 );
- apaint->u.translate.dx = INT_TO_FIXED( FT_NEXT_SHORT( p ) );
- apaint->u.translate.dy = INT_TO_FIXED( FT_NEXT_SHORT( p ) );
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- if ( (FT_PaintFormat_Internal)apaint->format ==
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_TRANSLATE )
- {
- ENSURE_READ_BYTES( 4 );
- var_index_base = FT_NEXT_ULONG( p );
-
- if ( !get_deltas_for_var_index_base( face, colr, var_index_base, 2,
- item_deltas ) )
- return 0;
-
- apaint->u.translate.dx += INT_TO_FIXED( item_deltas[0] );
- apaint->u.translate.dy += INT_TO_FIXED( item_deltas[1] );
- }
-#endif
-
- apaint->format = FT_COLR_PAINTFORMAT_TRANSLATE;
-
- return 1;
- }
-
- else if ( apaint->format >= FT_COLR_PAINTFORMAT_SCALE &&
- (FT_PaintFormat_Internal)apaint->format <=
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_SCALE_UNIFORM_CENTER )
- {
- apaint->u.scale.paint.p = child_table_p;
- apaint->u.scale.paint.insert_root_transform = 0;
-
- /* All scale paints get at least one scale value. */
- ENSURE_READ_BYTES( 2 );
- apaint->u.scale.scale_x = F2DOT14_TO_FIXED( FT_NEXT_SHORT( p ) );
-
- /* Non-uniform ones read an extra y value. */
- if ( apaint->format == FT_COLR_PAINTFORMAT_SCALE ||
- (FT_PaintFormat_Internal)apaint->format ==
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_SCALE ||
- (FT_PaintFormat_Internal)apaint->format ==
- FT_COLR_PAINTFORMAT_INTERNAL_SCALE_CENTER ||
- (FT_PaintFormat_Internal)apaint->format ==
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_SCALE_CENTER )
- {
- ENSURE_READ_BYTES( 2 );
- apaint->u.scale.scale_y = F2DOT14_TO_FIXED( FT_NEXT_SHORT( p ) );
- }
- else
- apaint->u.scale.scale_y = apaint->u.scale.scale_x;
-
- /* Scale paints that have a center read center coordinates, */
- /* otherwise the center is (0,0). */
- if ( (FT_PaintFormat_Internal)apaint->format ==
- FT_COLR_PAINTFORMAT_INTERNAL_SCALE_CENTER ||
- (FT_PaintFormat_Internal)apaint->format ==
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_SCALE_CENTER ||
- (FT_PaintFormat_Internal)apaint->format ==
- FT_COLR_PAINTFORMAT_INTERNAL_SCALE_UNIFORM_CENTER ||
- (FT_PaintFormat_Internal)apaint->format ==
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_SCALE_UNIFORM_CENTER )
- {
- ENSURE_READ_BYTES( 4 );
- apaint->u.scale.center_x = INT_TO_FIXED( FT_NEXT_SHORT ( p ) );
- apaint->u.scale.center_y = INT_TO_FIXED( FT_NEXT_SHORT ( p ) );
- }
- else
- {
- apaint->u.scale.center_x = 0;
- apaint->u.scale.center_y = 0;
- }
-
- /* Base values set, now handle variations. */
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- if ( (FT_PaintFormat_Internal)apaint->format ==
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_SCALE ||
- (FT_PaintFormat_Internal)apaint->format ==
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_SCALE_CENTER ||
- (FT_PaintFormat_Internal)apaint->format ==
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_SCALE_UNIFORM ||
- (FT_PaintFormat_Internal)apaint->format ==
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_SCALE_UNIFORM_CENTER )
- {
- ENSURE_READ_BYTES( 4 );
- var_index_base = FT_NEXT_ULONG( p );
-
- if ( (FT_PaintFormat_Internal)apaint->format ==
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_SCALE )
- {
- if ( !get_deltas_for_var_index_base( face, colr, var_index_base, 2,
- item_deltas ) )
- return 0;
-
- apaint->u.scale.scale_x += F2DOT14_TO_FIXED( item_deltas[0] );
- apaint->u.scale.scale_y += F2DOT14_TO_FIXED( item_deltas[1] );
- }
-
- if ( (FT_PaintFormat_Internal)apaint->format ==
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_SCALE_CENTER )
- {
- if ( !get_deltas_for_var_index_base( face, colr, var_index_base, 4,
- item_deltas ) )
- return 0;
-
- apaint->u.scale.scale_x += F2DOT14_TO_FIXED( item_deltas[0] );
- apaint->u.scale.scale_y += F2DOT14_TO_FIXED( item_deltas[1] );
- apaint->u.scale.center_x += INT_TO_FIXED( item_deltas[2] );
- apaint->u.scale.center_y += INT_TO_FIXED( item_deltas[3] );
- }
-
- if ( (FT_PaintFormat_Internal)apaint->format ==
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_SCALE_UNIFORM )
- {
- if ( !get_deltas_for_var_index_base( face, colr, var_index_base, 1,
- item_deltas ) )
- return 0;
-
- apaint->u.scale.scale_x += F2DOT14_TO_FIXED( item_deltas[0] );
- apaint->u.scale.scale_y += F2DOT14_TO_FIXED( item_deltas[0] );
- }
-
- if ( (FT_PaintFormat_Internal)apaint->format ==
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_SCALE_UNIFORM_CENTER )
- {
- if ( !get_deltas_for_var_index_base( face, colr, var_index_base, 3,
- item_deltas ) )
- return 0;
-
- apaint->u.scale.scale_x += F2DOT14_TO_FIXED( item_deltas[0] );
- apaint->u.scale.scale_y += F2DOT14_TO_FIXED( item_deltas[0] );
- apaint->u.scale.center_x += INT_TO_FIXED( item_deltas[1] );
- apaint->u.scale.center_y += INT_TO_FIXED( item_deltas[2] );
- }
- }
-#endif
-
- /* FT 'COLR' v1 API output format always returns fully defined */
- /* structs; we thus set the format to the public API value. */
- apaint->format = FT_COLR_PAINTFORMAT_SCALE;
-
- return 1;
- }
-
- else if ( apaint->format == FT_COLR_PAINTFORMAT_ROTATE ||
- (FT_PaintFormat_Internal)apaint->format ==
- FT_COLR_PAINTFORMAT_INTERNAL_ROTATE_CENTER ||
- (FT_PaintFormat_Internal)apaint->format ==
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_ROTATE ||
- (FT_PaintFormat_Internal)apaint->format ==
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_ROTATE_CENTER )
- {
- apaint->u.rotate.paint.p = child_table_p;
- apaint->u.rotate.paint.insert_root_transform = 0;
-
- ENSURE_READ_BYTES( 2 );
- apaint->u.rotate.angle = F2DOT14_TO_FIXED( FT_NEXT_SHORT( p ) );
-
- if ( (FT_PaintFormat_Internal)apaint->format ==
- FT_COLR_PAINTFORMAT_INTERNAL_ROTATE_CENTER ||
- (FT_PaintFormat_Internal)apaint->format ==
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_ROTATE_CENTER )
- {
- ENSURE_READ_BYTES( 4 );
- apaint->u.rotate.center_x = INT_TO_FIXED( FT_NEXT_SHORT( p ) );
- apaint->u.rotate.center_y = INT_TO_FIXED( FT_NEXT_SHORT( p ) );
- }
- else
- {
- apaint->u.rotate.center_x = 0;
- apaint->u.rotate.center_y = 0;
- }
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- if ( (FT_PaintFormat_Internal)apaint->format ==
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_ROTATE ||
- (FT_PaintFormat_Internal)apaint->format ==
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_ROTATE_CENTER )
- {
- FT_UInt num_deltas = 0;
-
-
- ENSURE_READ_BYTES( 4 );
- var_index_base = FT_NEXT_ULONG( p );
-
- if ( (FT_PaintFormat_Internal)apaint->format ==
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_ROTATE_CENTER )
- num_deltas = 3;
- if ( (FT_PaintFormat_Internal)apaint->format ==
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_ROTATE )
- num_deltas = 1;
-
- if ( num_deltas > 0 )
- {
- if ( !get_deltas_for_var_index_base( face, colr, var_index_base,
- num_deltas, item_deltas ) )
- return 0;
-
- apaint->u.rotate.angle += F2DOT14_TO_FIXED( item_deltas[0] );
-
- if ( num_deltas == 3 )
- {
- apaint->u.rotate.center_x += INT_TO_FIXED( item_deltas[1] );
- apaint->u.rotate.center_y += INT_TO_FIXED( item_deltas[2] );
- }
- }
- }
-#endif
-
- apaint->format = FT_COLR_PAINTFORMAT_ROTATE;
-
-
- return 1;
- }
-
- else if ( apaint->format == FT_COLR_PAINTFORMAT_SKEW ||
- (FT_PaintFormat_Internal)apaint->format ==
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_SKEW ||
- (FT_PaintFormat_Internal)apaint->format ==
- FT_COLR_PAINTFORMAT_INTERNAL_SKEW_CENTER ||
- (FT_PaintFormat_Internal)apaint->format ==
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_SKEW_CENTER )
- {
- apaint->u.skew.paint.p = child_table_p;
- apaint->u.skew.paint.insert_root_transform = 0;
-
- ENSURE_READ_BYTES( 4 );
- apaint->u.skew.x_skew_angle = F2DOT14_TO_FIXED( FT_NEXT_SHORT( p ) );
- apaint->u.skew.y_skew_angle = F2DOT14_TO_FIXED( FT_NEXT_SHORT( p ) );
-
- if ( (FT_PaintFormat_Internal)apaint->format ==
- FT_COLR_PAINTFORMAT_INTERNAL_SKEW_CENTER ||
- (FT_PaintFormat_Internal)apaint->format ==
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_SKEW_CENTER )
- {
- ENSURE_READ_BYTES( 4 );
- apaint->u.skew.center_x = INT_TO_FIXED( FT_NEXT_SHORT( p ) );
- apaint->u.skew.center_y = INT_TO_FIXED( FT_NEXT_SHORT( p ) );
- }
- else
- {
- apaint->u.skew.center_x = 0;
- apaint->u.skew.center_y = 0;
- }
-
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- if ( (FT_PaintFormat_Internal)apaint->format ==
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_SKEW ||
- (FT_PaintFormat_Internal)apaint->format ==
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_SKEW_CENTER )
- {
- ENSURE_READ_BYTES( 4 );
- var_index_base = FT_NEXT_ULONG( p );
-
- if ( (FT_PaintFormat_Internal)apaint->format ==
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_SKEW )
- {
- if ( !get_deltas_for_var_index_base( face, colr, var_index_base, 2,
- item_deltas ) )
- return 0;
-
- apaint->u.skew.x_skew_angle += F2DOT14_TO_FIXED( item_deltas[0] );
- apaint->u.skew.y_skew_angle += F2DOT14_TO_FIXED( item_deltas[1] );
- }
-
- if ( (FT_PaintFormat_Internal)apaint->format ==
- FT_COLR_PAINTFORMAT_INTERNAL_VAR_SKEW_CENTER )
- {
- if ( !get_deltas_for_var_index_base( face, colr, var_index_base, 4,
- item_deltas ) )
- return 0;
-
- apaint->u.skew.x_skew_angle += F2DOT14_TO_FIXED( item_deltas[0] );
- apaint->u.skew.y_skew_angle += F2DOT14_TO_FIXED( item_deltas[1] );
- apaint->u.skew.center_x += INT_TO_FIXED( item_deltas[2] );
- apaint->u.skew.center_y += INT_TO_FIXED( item_deltas[3] );
- }
- }
-#endif
-
- apaint->format = FT_COLR_PAINTFORMAT_SKEW;
-
- return 1;
- }
-
- else if ( apaint->format == FT_COLR_PAINTFORMAT_COMPOSITE )
- {
- FT_UInt composite_mode;
-
-
- apaint->u.composite.source_paint.p = child_table_p;
- apaint->u.composite.source_paint.insert_root_transform = 0;
-
- ENSURE_READ_BYTES( 1 );
- composite_mode = FT_NEXT_BYTE( p );
- if ( composite_mode >= FT_COLR_COMPOSITE_MAX )
- return 0;
-
- apaint->u.composite.composite_mode = (FT_Composite_Mode)composite_mode;
-
- if ( !get_child_table_pointer( colr, paint_base, &p, &child_table_p ) )
- return 0;
-
- apaint->u.composite.backdrop_paint.p =
- child_table_p;
- apaint->u.composite.backdrop_paint.insert_root_transform =
- 0;
-
- return 1;
- }
-
- return 0;
- }
-
-
- static FT_Bool
- find_base_glyph_v1_record( FT_Byte * base_glyph_begin,
- FT_UInt num_base_glyph,
- FT_UInt glyph_id,
- BaseGlyphV1Record *record )
- {
- FT_UInt min = 0;
- FT_UInt max = num_base_glyph;
-
-
- while ( min < max )
- {
- FT_UInt mid = min + ( max - min ) / 2;
- FT_UShort gid;
-
- /*
- * `base_glyph_begin` is the beginning of `BaseGlyphV1List`;
- * skip `numBaseGlyphV1Records` by adding 4 to start binary search
- * in the array of `BaseGlyphV1Record`.
- */
- FT_Byte *p = base_glyph_begin + 4 + mid * BASE_GLYPH_PAINT_RECORD_SIZE;
-
- gid = FT_NEXT_USHORT( p );
-
- if ( gid < glyph_id )
- min = mid + 1;
- else if (gid > glyph_id )
- max = mid;
- else
- {
- record->gid = gid;
- record->paint_offset = FT_NEXT_ULONG ( p );
- return 1;
- }
- }
-
- return 0;
- }
-
-
- FT_LOCAL_DEF( FT_Bool )
- tt_face_get_colr_glyph_paint( TT_Face face,
- FT_UInt base_glyph,
- FT_Color_Root_Transform root_transform,
- FT_OpaquePaint* opaque_paint )
- {
- Colr* colr = (Colr*)face->colr;
- BaseGlyphV1Record base_glyph_v1_record;
- FT_Byte* p;
-
- if ( !colr || !colr->table )
- return 0;
-
- if ( colr->version < 1 || !colr->num_base_glyphs_v1 ||
- !colr->base_glyphs_v1 )
- return 0;
-
- if ( opaque_paint->p )
- return 0;
-
- if ( !find_base_glyph_v1_record( colr->base_glyphs_v1,
- colr->num_base_glyphs_v1,
- base_glyph,
- &base_glyph_v1_record ) )
- return 0;
-
- if ( !base_glyph_v1_record.paint_offset ||
- base_glyph_v1_record.paint_offset > colr->table_size )
- return 0;
-
- p = (FT_Byte*)( colr->base_glyphs_v1 +
- base_glyph_v1_record.paint_offset );
- if ( p >= ( (FT_Byte*)colr->table + colr->table_size ) )
- return 0;
-
- opaque_paint->p = p;
-
- if ( root_transform == FT_COLOR_INCLUDE_ROOT_TRANSFORM )
- opaque_paint->insert_root_transform = 1;
- else
- opaque_paint->insert_root_transform = 0;
-
- return 1;
- }
-
-
- FT_LOCAL_DEF( FT_Bool )
- tt_face_get_color_glyph_clipbox( TT_Face face,
- FT_UInt base_glyph,
- FT_ClipBox* clip_box )
- {
- Colr* colr;
-
- FT_Byte *p, *p1, *clip_base, *limit;
-
- FT_Byte clip_list_format;
- FT_ULong num_clip_boxes, i;
- FT_UShort gid_start, gid_end;
- FT_UInt32 clip_box_offset;
- FT_Byte format;
-
- const FT_Byte num_corners = 4;
- FT_Vector corners[4];
- FT_Byte j;
- FT_BBox font_clip_box;
-
-
- colr = (Colr*)face->colr;
- if ( !colr )
- return 0;
-
- if ( !colr->clip_list )
- return 0;
-
- p = colr->clip_list;
-
- /* Limit points to the first byte after the end of the color table. */
- /* Thus, in subsequent limit checks below we need to check whether the */
- /* read pointer is strictly greater than a position offset by certain */
- /* field sizes to the left of that position. */
- limit = (FT_Byte*)colr->table + colr->table_size;
-
- /* Check whether we can extract one `uint8` and one `uint32`. */
- if ( p > limit - ( 1 + 4 ) )
- return 0;
-
- clip_base = p;
- clip_list_format = FT_NEXT_BYTE ( p );
-
- /* Format byte used here to be able to upgrade ClipList for >16bit */
- /* glyph ids; for now we can expect it to be 1. */
- if ( !( clip_list_format == 1 ) )
- return 0;
-
- num_clip_boxes = FT_NEXT_ULONG( p );
-
- /* Check whether we can extract two `uint16` and one `Offset24`, */
- /* `num_clip_boxes` times. */
- if ( colr->table_size / ( 2 + 2 + 3 ) < num_clip_boxes ||
- p > limit - ( 2 + 2 + 3 ) * num_clip_boxes )
- return 0;
-
- for ( i = 0; i < num_clip_boxes; ++i )
- {
- gid_start = FT_NEXT_USHORT( p );
- gid_end = FT_NEXT_USHORT( p );
- clip_box_offset = FT_NEXT_UOFF3( p );
-
- if ( base_glyph >= gid_start && base_glyph <= gid_end )
- {
- p1 = (FT_Byte*)( clip_base + clip_box_offset );
-
- /* Check whether we can extract one `uint8`. */
- if ( p1 > limit - 1 )
- return 0;
-
- format = FT_NEXT_BYTE( p1 );
-
- if ( format > 2 )
- return 0;
-
- /* Check whether we can extract four `FWORD`. */
- if ( p1 > limit - ( 2 + 2 + 2 + 2 ) )
- return 0;
-
- /* `face->root.size->metrics.x_scale` and `y_scale` are factors */
- /* that scale a font unit value in integers to a 26.6 fixed value */
- /* according to the requested size, see for example */
- /* `ft_recompute_scaled_metrics`. */
- font_clip_box.xMin = FT_MulFix( FT_NEXT_SHORT( p1 ),
- face->root.size->metrics.x_scale );
- font_clip_box.yMin = FT_MulFix( FT_NEXT_SHORT( p1 ),
- face->root.size->metrics.y_scale );
- font_clip_box.xMax = FT_MulFix( FT_NEXT_SHORT( p1 ),
- face->root.size->metrics.x_scale );
- font_clip_box.yMax = FT_MulFix( FT_NEXT_SHORT( p1 ),
- face->root.size->metrics.y_scale );
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- if ( format == 2 )
- {
- FT_ULong var_index_base = 0;
- /* varIndexBase offset for clipbox is 3 at most. */
- FT_ItemVarDelta item_deltas[4] = { 0, 0, 0, 0 };
-
-
- /* Check whether we can extract a 32-bit varIndexBase now. */
- if ( p1 > limit - 4 )
- return 0;
-
- var_index_base = FT_NEXT_ULONG( p1 );
-
- if ( !get_deltas_for_var_index_base( face, colr, var_index_base, 4,
- item_deltas ) )
- return 0;
-
- font_clip_box.xMin +=
- FT_MulFix( item_deltas[0], face->root.size->metrics.x_scale );
- font_clip_box.yMin +=
- FT_MulFix( item_deltas[1], face->root.size->metrics.y_scale );
- font_clip_box.xMax +=
- FT_MulFix( item_deltas[2], face->root.size->metrics.x_scale );
- font_clip_box.yMax +=
- FT_MulFix( item_deltas[3], face->root.size->metrics.y_scale );
- }
-#endif
-
- /* Make 4 corner points (xMin, yMin), (xMax, yMax) and transform */
- /* them. If we we would only transform two corner points and */
- /* span a rectangle based on those, the rectangle may become too */
- /* small to cover the glyph. */
- corners[0].x = font_clip_box.xMin;
- corners[1].x = font_clip_box.xMin;
- corners[2].x = font_clip_box.xMax;
- corners[3].x = font_clip_box.xMax;
-
- corners[0].y = font_clip_box.yMin;
- corners[1].y = font_clip_box.yMax;
- corners[2].y = font_clip_box.yMax;
- corners[3].y = font_clip_box.yMin;
-
- for ( j = 0; j < num_corners; ++j )
- {
- if ( face->root.internal->transform_flags & 1 )
- FT_Vector_Transform( &corners[j],
- &face->root.internal->transform_matrix );
-
- if ( face->root.internal->transform_flags & 2 )
- {
- corners[j].x += face->root.internal->transform_delta.x;
- corners[j].y += face->root.internal->transform_delta.y;
- }
- }
-
- clip_box->bottom_left = corners[0];
- clip_box->top_left = corners[1];
- clip_box->top_right = corners[2];
- clip_box->bottom_right = corners[3];
-
- return 1;
- }
- }
-
- return 0;
- }
-
-
- FT_LOCAL_DEF( FT_Bool )
- tt_face_get_paint_layers( TT_Face face,
- FT_LayerIterator* iterator,
- FT_OpaquePaint* opaque_paint )
- {
- FT_Byte* p = NULL;
- FT_Byte* p_first_layer = NULL;
- FT_Byte* p_paint = NULL;
- FT_UInt32 paint_offset;
-
- Colr* colr;
-
-
- if ( iterator->layer == iterator->num_layers )
- return 0;
-
- colr = (Colr*)face->colr;
- if ( !colr )
- return 0;
-
- /*
- * We have an iterator pointing at a paint offset as part of the
- * `paintOffset` array in `LayerV1List`.
- */
- p = iterator->p;
-
- /*
- * Do a cursor sanity check of the iterator. Counting backwards from
- * where it stands, we need to end up at a position after the beginning
- * of the `LayerV1List` table and not after the end of the
- * `LayerV1List`.
- */
- p_first_layer = p -
- iterator->layer * LAYER_V1_LIST_PAINT_OFFSET_SIZE -
- LAYER_V1_LIST_NUM_LAYERS_SIZE;
- if ( p_first_layer < (FT_Byte*)colr->layers_v1 )
- return 0;
- if ( p_first_layer >= (FT_Byte*)(
- colr->layers_v1 + LAYER_V1_LIST_NUM_LAYERS_SIZE +
- colr->num_layers_v1 * LAYER_V1_LIST_PAINT_OFFSET_SIZE ) )
- return 0;
-
- /*
- * Before reading, ensure that `p` is within 'COLR' v1 and we can read a
- * 4-byte ULONG.
- */
- if ( p < colr->layers_v1 ||
- p > (FT_Byte*)colr->table + colr->table_size - 4 )
- return 0;
-
- paint_offset =
- FT_NEXT_ULONG( p );
- opaque_paint->insert_root_transform =
- 0;
-
- p_paint = (FT_Byte*)( colr->layers_v1 + paint_offset );
-
- if ( p_paint < colr->paints_start_v1 ||
- p_paint >= ( (FT_Byte*)colr->table + colr->table_size ) )
- return 0;
-
- opaque_paint->p = p_paint;
-
- iterator->p = p;
-
- iterator->layer++;
-
- return 1;
- }
-
-
- FT_LOCAL_DEF( FT_Bool )
- tt_face_get_colorline_stops( TT_Face face,
- FT_ColorStop* color_stop,
- FT_ColorStopIterator *iterator )
- {
- Colr* colr = (Colr*)face->colr;
-
- FT_Byte* p;
- FT_ULong var_index_base;
- FT_Byte* last_entry_p = NULL;
- FT_UInt entry_size = COLOR_STOP_SIZE;
-
-
- if ( !colr || !colr->table || !iterator )
- return 0;
-
- if ( iterator->current_color_stop >= iterator->num_color_stops )
- return 0;
-
- if ( iterator->read_variable )
- entry_size += VAR_IDX_BASE_SIZE;
-
- /* Calculate the start pointer for the last to-be-read (Var)ColorStop */
- /* and check whether we can read a full (Var)ColorStop at that */
- /* position by comparing it to the position that is the size of one */
- /* (Var)ColorStop before the end of the 'COLR' table. */
- last_entry_p =
- iterator->p + ( iterator->num_color_stops - 1 -
- iterator->current_color_stop ) * entry_size;
- if ( iterator->p < colr->paints_start_v1 ||
- last_entry_p > (FT_Byte*)colr->table +
- colr->table_size - entry_size )
- return 0;
-
- /* Iterator points at first `ColorStop` of `ColorLine`. */
- p = iterator->p;
-
- color_stop->stop_offset = F2DOT14_TO_FIXED( FT_NEXT_SHORT( p ) );
-
- color_stop->color.palette_index = FT_NEXT_USHORT( p );
-
- color_stop->color.alpha = FT_NEXT_SHORT( p );
-
- if ( iterator->read_variable )
- {
- /* Pointer p needs to be advanced independently of whether we intend */
- /* to take variable deltas into account or not. Otherwise iteration */
- /* would fail due to wrong offsets. */
- var_index_base = FT_NEXT_ULONG( p );
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- {
- FT_Int item_deltas[2];
-
-
- if ( !get_deltas_for_var_index_base( face, colr,
- var_index_base,
- 2,
- item_deltas ) )
- return 0;
-
- color_stop->stop_offset += F2DOT14_TO_FIXED( item_deltas[0] );
- color_stop->color.alpha += (FT_F2Dot14)item_deltas[1];
- }
-#else
- FT_UNUSED( var_index_base );
-#endif
- }
-
- iterator->p = p;
- iterator->current_color_stop++;
-
- return 1;
- }
-
-
- FT_LOCAL_DEF( FT_Bool )
- tt_face_get_paint( TT_Face face,
- FT_OpaquePaint opaque_paint,
- FT_COLR_Paint* paint )
- {
- Colr* colr = (Colr*)face->colr;
- FT_OpaquePaint next_paint;
- FT_Matrix ft_root_scale;
-
- if ( !colr || !colr->base_glyphs_v1 || !colr->table )
- return 0;
-
- if ( opaque_paint.insert_root_transform )
- {
- /* 'COLR' v1 glyph information is returned in unscaled coordinates,
- * i.e., `FT_Size` is not applied or multiplied into the values. When
- * client applications draw color glyphs, they can request to include
- * a top-level transform, which includes the active `x_scale` and
- * `y_scale` information for scaling the glyph, as well the additional
- * transform and translate configured through `FT_Set_Transform`.
- * This allows client applications to apply this top-level transform
- * to the graphics context first and only once, then have gradient and
- * contour scaling applied correctly when performing the additional
- * drawing operations for subsequenct paints. Prepare this initial
- * transform here.
- */
- paint->format = FT_COLR_PAINTFORMAT_TRANSFORM;
-
- next_paint.p = opaque_paint.p;
- next_paint.insert_root_transform = 0;
- paint->u.transform.paint = next_paint;
-
- /* `x_scale` and `y_scale` are in 26.6 format, representing the scale
- * factor to get from font units to requested size. However, expected
- * return values are in 16.16, so we shift accordingly with rounding.
- */
- ft_root_scale.xx = ( face->root.size->metrics.x_scale + 32 ) >> 6;
- ft_root_scale.xy = 0;
- ft_root_scale.yx = 0;
- ft_root_scale.yy = ( face->root.size->metrics.y_scale + 32 ) >> 6;
-
- if ( face->root.internal->transform_flags & 1 )
- FT_Matrix_Multiply( &face->root.internal->transform_matrix,
- &ft_root_scale );
-
- paint->u.transform.affine.xx = ft_root_scale.xx;
- paint->u.transform.affine.xy = ft_root_scale.xy;
- paint->u.transform.affine.yx = ft_root_scale.yx;
- paint->u.transform.affine.yy = ft_root_scale.yy;
-
- /* The translation is specified in 26.6 format and, according to the
- * documentation of `FT_Set_Translate`, is performed on the character
- * size given in the last call to `FT_Set_Char_Size`. The
- * 'PaintTransform' paint table's `FT_Affine23` format expects
- * values in 16.16 format, thus we need to shift by 10 bits.
- */
- if ( face->root.internal->transform_flags & 2 )
- {
- paint->u.transform.affine.dx =
- face->root.internal->transform_delta.x * ( 1 << 10 );
- paint->u.transform.affine.dy =
- face->root.internal->transform_delta.y * ( 1 << 10 );
- }
- else
- {
- paint->u.transform.affine.dx = 0;
- paint->u.transform.affine.dy = 0;
- }
-
- return 1;
- }
-
- return read_paint( face, colr, opaque_paint.p, paint );
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- tt_face_colr_blend_layer( TT_Face face,
- FT_UInt color_index,
- FT_GlyphSlot dstSlot,
- FT_GlyphSlot srcSlot )
- {
- FT_Error error;
-
- FT_UInt x, y;
- FT_Byte b, g, r, alpha;
-
- FT_ULong size;
- FT_Byte* src;
- FT_Byte* dst;
-
-
- if ( !dstSlot->bitmap.buffer )
- {
- /* Initialize destination of color bitmap */
- /* with the size of first component. */
- dstSlot->bitmap_left = srcSlot->bitmap_left;
- dstSlot->bitmap_top = srcSlot->bitmap_top;
-
- dstSlot->bitmap.width = srcSlot->bitmap.width;
- dstSlot->bitmap.rows = srcSlot->bitmap.rows;
- dstSlot->bitmap.pixel_mode = FT_PIXEL_MODE_BGRA;
- dstSlot->bitmap.pitch = (int)dstSlot->bitmap.width * 4;
- dstSlot->bitmap.num_grays = 256;
-
- size = dstSlot->bitmap.rows * (unsigned int)dstSlot->bitmap.pitch;
-
- error = ft_glyphslot_alloc_bitmap( dstSlot, size );
- if ( error )
- return error;
-
- FT_MEM_ZERO( dstSlot->bitmap.buffer, size );
- }
- else
- {
- /* Resize destination if needed such that new component fits. */
- FT_Int x_min, x_max, y_min, y_max;
-
-
- x_min = FT_MIN( dstSlot->bitmap_left, srcSlot->bitmap_left );
- x_max = FT_MAX( dstSlot->bitmap_left + (FT_Int)dstSlot->bitmap.width,
- srcSlot->bitmap_left + (FT_Int)srcSlot->bitmap.width );
-
- y_min = FT_MIN( dstSlot->bitmap_top - (FT_Int)dstSlot->bitmap.rows,
- srcSlot->bitmap_top - (FT_Int)srcSlot->bitmap.rows );
- y_max = FT_MAX( dstSlot->bitmap_top, srcSlot->bitmap_top );
-
- if ( x_min != dstSlot->bitmap_left ||
- x_max != dstSlot->bitmap_left + (FT_Int)dstSlot->bitmap.width ||
- y_min != dstSlot->bitmap_top - (FT_Int)dstSlot->bitmap.rows ||
- y_max != dstSlot->bitmap_top )
- {
- FT_Memory memory = face->root.memory;
-
- FT_UInt width = (FT_UInt)( x_max - x_min );
- FT_UInt rows = (FT_UInt)( y_max - y_min );
- FT_UInt pitch = width * 4;
-
- FT_Byte* buf = NULL;
- FT_Byte* p;
- FT_Byte* q;
-
-
- size = rows * pitch;
- if ( FT_ALLOC( buf, size ) )
- return error;
-
- p = dstSlot->bitmap.buffer;
- q = buf +
- (int)pitch * ( y_max - dstSlot->bitmap_top ) +
- 4 * ( dstSlot->bitmap_left - x_min );
-
- for ( y = 0; y < dstSlot->bitmap.rows; y++ )
- {
- FT_MEM_COPY( q, p, dstSlot->bitmap.width * 4 );
-
- p += dstSlot->bitmap.pitch;
- q += pitch;
- }
-
- ft_glyphslot_set_bitmap( dstSlot, buf );
-
- dstSlot->bitmap_top = y_max;
- dstSlot->bitmap_left = x_min;
-
- dstSlot->bitmap.width = width;
- dstSlot->bitmap.rows = rows;
- dstSlot->bitmap.pitch = (int)pitch;
-
- dstSlot->internal->flags |= FT_GLYPH_OWN_BITMAP;
- dstSlot->format = FT_GLYPH_FORMAT_BITMAP;
- }
- }
-
- if ( color_index == 0xFFFF )
- {
- if ( face->have_foreground_color )
- {
- b = face->foreground_color.blue;
- g = face->foreground_color.green;
- r = face->foreground_color.red;
- alpha = face->foreground_color.alpha;
- }
- else
- {
- if ( face->palette_data.palette_flags &&
- ( face->palette_data.palette_flags[face->palette_index] &
- FT_PALETTE_FOR_DARK_BACKGROUND ) )
- {
- /* white opaque */
- b = 0xFF;
- g = 0xFF;
- r = 0xFF;
- alpha = 0xFF;
- }
- else
- {
- /* black opaque */
- b = 0x00;
- g = 0x00;
- r = 0x00;
- alpha = 0xFF;
- }
- }
- }
- else
- {
- b = face->palette[color_index].blue;
- g = face->palette[color_index].green;
- r = face->palette[color_index].red;
- alpha = face->palette[color_index].alpha;
- }
-
- /* XXX Convert if srcSlot.bitmap is not grey? */
- src = srcSlot->bitmap.buffer;
- dst = dstSlot->bitmap.buffer +
- dstSlot->bitmap.pitch * ( dstSlot->bitmap_top - srcSlot->bitmap_top ) +
- 4 * ( srcSlot->bitmap_left - dstSlot->bitmap_left );
-
- for ( y = 0; y < srcSlot->bitmap.rows; y++ )
- {
- for ( x = 0; x < srcSlot->bitmap.width; x++ )
- {
- int aa = src[x];
- int fa = alpha * aa / 255;
-
- int fb = b * fa / 255;
- int fg = g * fa / 255;
- int fr = r * fa / 255;
-
- int ba2 = 255 - fa;
-
- int bb = dst[4 * x + 0];
- int bg = dst[4 * x + 1];
- int br = dst[4 * x + 2];
- int ba = dst[4 * x + 3];
-
-
- dst[4 * x + 0] = (FT_Byte)( bb * ba2 / 255 + fb );
- dst[4 * x + 1] = (FT_Byte)( bg * ba2 / 255 + fg );
- dst[4 * x + 2] = (FT_Byte)( br * ba2 / 255 + fr );
- dst[4 * x + 3] = (FT_Byte)( ba * ba2 / 255 + fa );
- }
-
- src += srcSlot->bitmap.pitch;
- dst += dstSlot->bitmap.pitch;
- }
-
- return FT_Err_Ok;
- }
-
-#else /* !TT_CONFIG_OPTION_COLOR_LAYERS */
-
- /* ANSI C doesn't like empty source files */
- typedef int tt_colr_dummy_;
-
-#endif /* !TT_CONFIG_OPTION_COLOR_LAYERS */
-
-/* EOF */
diff --git a/contrib/libs/freetype/src/sfnt/ttcolr.h b/contrib/libs/freetype/src/sfnt/ttcolr.h
deleted file mode 100644
index 30031464c7..0000000000
--- a/contrib/libs/freetype/src/sfnt/ttcolr.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************************
- *
- * ttcolr.h
- *
- * TrueType and OpenType colored glyph layer support (specification).
- *
- * Copyright (C) 2018-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * Originally written by Shao Yu Zhang <shaozhang@fb.com>.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef __TTCOLR_H__
-#define __TTCOLR_H__
-
-
-#include "ttload.h"
-
-
-FT_BEGIN_HEADER
-
-
- FT_LOCAL( FT_Error )
- tt_face_load_colr( TT_Face face,
- FT_Stream stream );
-
- FT_LOCAL( void )
- tt_face_free_colr( TT_Face face );
-
- FT_LOCAL( FT_Bool )
- tt_face_get_colr_layer( TT_Face face,
- FT_UInt base_glyph,
- FT_UInt *aglyph_index,
- FT_UInt *acolor_index,
- FT_LayerIterator* iterator );
-
- FT_LOCAL( FT_Bool )
- tt_face_get_colr_glyph_paint( TT_Face face,
- FT_UInt base_glyph,
- FT_Color_Root_Transform root_transform,
- FT_OpaquePaint* paint );
-
- FT_LOCAL( FT_Bool )
- tt_face_get_color_glyph_clipbox( TT_Face face,
- FT_UInt base_glyph,
- FT_ClipBox* clip_box );
-
- FT_LOCAL( FT_Bool )
- tt_face_get_paint_layers( TT_Face face,
- FT_LayerIterator* iterator,
- FT_OpaquePaint* paint );
-
- FT_LOCAL( FT_Bool )
- tt_face_get_colorline_stops( TT_Face face,
- FT_ColorStop* color_stop,
- FT_ColorStopIterator* iterator );
-
- FT_LOCAL( FT_Bool )
- tt_face_get_paint( TT_Face face,
- FT_OpaquePaint opaque_paint,
- FT_COLR_Paint* paint );
-
- FT_LOCAL( FT_Error )
- tt_face_colr_blend_layer( TT_Face face,
- FT_UInt color_index,
- FT_GlyphSlot dstSlot,
- FT_GlyphSlot srcSlot );
-
-
-FT_END_HEADER
-
-
-#endif /* __TTCOLR_H__ */
-
-/* END */
diff --git a/contrib/libs/freetype/src/sfnt/ttcpal.c b/contrib/libs/freetype/src/sfnt/ttcpal.c
deleted file mode 100644
index 997eb869ff..0000000000
--- a/contrib/libs/freetype/src/sfnt/ttcpal.c
+++ /dev/null
@@ -1,310 +0,0 @@
-/****************************************************************************
- *
- * ttcpal.c
- *
- * TrueType and OpenType color palette support (body).
- *
- * Copyright (C) 2018-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * Originally written by Shao Yu Zhang <shaozhang@fb.com>.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /**************************************************************************
- *
- * `CPAL' table specification:
- *
- * https://www.microsoft.com/typography/otspec/cpal.htm
- *
- */
-
-
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/tttags.h>
-#include <freetype/ftcolor.h>
-
-
-#ifdef TT_CONFIG_OPTION_COLOR_LAYERS
-
-#include "ttcpal.h"
-
-
- /* NOTE: These are the table sizes calculated through the specs. */
-#define CPAL_V0_HEADER_BASE_SIZE 12U
-#define COLOR_SIZE 4U
-
-
- /* all data from `CPAL' not covered in FT_Palette_Data */
- typedef struct Cpal_
- {
- FT_UShort version; /* Table version number (0 or 1 supported). */
- FT_UShort num_colors; /* Total number of color records, */
- /* combined for all palettes. */
- FT_Byte* colors; /* RGBA array of colors */
- FT_Byte* color_indices; /* Index of each palette's first color record */
- /* in the combined color record array. */
-
- /* The memory which backs up the `CPAL' table. */
- void* table;
- FT_ULong table_size;
-
- } Cpal;
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT ttcpal
-
-
- FT_LOCAL_DEF( FT_Error )
- tt_face_load_cpal( TT_Face face,
- FT_Stream stream )
- {
- FT_Error error;
- FT_Memory memory = face->root.memory;
-
- FT_Byte* table = NULL;
- FT_Byte* p = NULL;
-
- Cpal* cpal = NULL;
-
- FT_ULong colors_offset;
- FT_ULong table_size;
-
-
- error = face->goto_table( face, TTAG_CPAL, stream, &table_size );
- if ( error )
- goto NoCpal;
-
- if ( table_size < CPAL_V0_HEADER_BASE_SIZE )
- goto InvalidTable;
-
- if ( FT_FRAME_EXTRACT( table_size, table ) )
- goto NoCpal;
-
- p = table;
-
- if ( FT_NEW( cpal ) )
- goto NoCpal;
-
- cpal->version = FT_NEXT_USHORT( p );
- if ( cpal->version > 1 )
- goto InvalidTable;
-
- face->palette_data.num_palette_entries = FT_NEXT_USHORT( p );
- face->palette_data.num_palettes = FT_NEXT_USHORT( p );
-
- cpal->num_colors = FT_NEXT_USHORT( p );
- colors_offset = FT_NEXT_ULONG( p );
-
- if ( CPAL_V0_HEADER_BASE_SIZE +
- face->palette_data.num_palettes * 2U > table_size )
- goto InvalidTable;
-
- if ( colors_offset >= table_size )
- goto InvalidTable;
- if ( cpal->num_colors * COLOR_SIZE > table_size - colors_offset )
- goto InvalidTable;
-
- if ( face->palette_data.num_palette_entries > cpal->num_colors )
- goto InvalidTable;
-
- cpal->color_indices = p;
- cpal->colors = (FT_Byte*)( table + colors_offset );
-
- if ( cpal->version == 1 )
- {
- FT_ULong type_offset, label_offset, entry_label_offset;
- FT_UShort* array = NULL;
- FT_UShort* limit;
- FT_UShort* q;
-
-
- if ( CPAL_V0_HEADER_BASE_SIZE +
- face->palette_data.num_palettes * 2U +
- 3U * 4 > table_size )
- goto InvalidTable;
-
- p += face->palette_data.num_palettes * 2U;
-
- type_offset = FT_NEXT_ULONG( p );
- label_offset = FT_NEXT_ULONG( p );
- entry_label_offset = FT_NEXT_ULONG( p );
-
- if ( type_offset )
- {
- if ( type_offset >= table_size )
- goto InvalidTable;
- if ( face->palette_data.num_palettes * 2U >
- table_size - type_offset )
- goto InvalidTable;
-
- if ( FT_QNEW_ARRAY( array, face->palette_data.num_palettes ) )
- goto NoCpal;
-
- p = table + type_offset;
- q = array;
- limit = q + face->palette_data.num_palettes;
-
- while ( q < limit )
- *q++ = FT_NEXT_USHORT( p );
-
- face->palette_data.palette_flags = array;
- }
-
- if ( label_offset )
- {
- if ( label_offset >= table_size )
- goto InvalidTable;
- if ( face->palette_data.num_palettes * 2U >
- table_size - label_offset )
- goto InvalidTable;
-
- if ( FT_QNEW_ARRAY( array, face->palette_data.num_palettes ) )
- goto NoCpal;
-
- p = table + label_offset;
- q = array;
- limit = q + face->palette_data.num_palettes;
-
- while ( q < limit )
- *q++ = FT_NEXT_USHORT( p );
-
- face->palette_data.palette_name_ids = array;
- }
-
- if ( entry_label_offset )
- {
- if ( entry_label_offset >= table_size )
- goto InvalidTable;
- if ( face->palette_data.num_palette_entries * 2U >
- table_size - entry_label_offset )
- goto InvalidTable;
-
- if ( FT_QNEW_ARRAY( array, face->palette_data.num_palette_entries ) )
- goto NoCpal;
-
- p = table + entry_label_offset;
- q = array;
- limit = q + face->palette_data.num_palette_entries;
-
- while ( q < limit )
- *q++ = FT_NEXT_USHORT( p );
-
- face->palette_data.palette_entry_name_ids = array;
- }
- }
-
- cpal->table = table;
- cpal->table_size = table_size;
-
- face->cpal = cpal;
-
- /* set up default palette */
- if ( FT_NEW_ARRAY( face->palette,
- face->palette_data.num_palette_entries ) )
- goto NoCpal;
-
- if ( tt_face_palette_set( face, 0 ) )
- goto InvalidTable;
-
- return FT_Err_Ok;
-
- InvalidTable:
- error = FT_THROW( Invalid_Table );
-
- NoCpal:
- FT_FRAME_RELEASE( table );
- FT_FREE( cpal );
-
- face->cpal = NULL;
-
- /* arrays in `face->palette_data' and `face->palette' */
- /* are freed in `sfnt_done_face' */
-
- return error;
- }
-
-
- FT_LOCAL_DEF( void )
- tt_face_free_cpal( TT_Face face )
- {
- FT_Stream stream = face->root.stream;
- FT_Memory memory = face->root.memory;
-
- Cpal* cpal = (Cpal*)face->cpal;
-
-
- if ( cpal )
- {
- FT_FRAME_RELEASE( cpal->table );
- FT_FREE( cpal );
- }
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- tt_face_palette_set( TT_Face face,
- FT_UInt palette_index )
- {
- Cpal* cpal = (Cpal*)face->cpal;
-
- FT_Byte* offset;
- FT_Byte* p;
-
- FT_Color* q;
- FT_Color* limit;
-
- FT_UShort color_index;
-
-
- if ( !cpal || palette_index >= face->palette_data.num_palettes )
- return FT_THROW( Invalid_Argument );
-
- offset = cpal->color_indices + 2 * palette_index;
- color_index = FT_PEEK_USHORT( offset );
-
- if ( color_index + face->palette_data.num_palette_entries >
- cpal->num_colors )
- return FT_THROW( Invalid_Table );
-
- p = cpal->colors + COLOR_SIZE * color_index;
- q = face->palette;
- limit = q + face->palette_data.num_palette_entries;
-
- while ( q < limit )
- {
- q->blue = FT_NEXT_BYTE( p );
- q->green = FT_NEXT_BYTE( p );
- q->red = FT_NEXT_BYTE( p );
- q->alpha = FT_NEXT_BYTE( p );
-
- q++;
- }
-
- return FT_Err_Ok;
- }
-
-
-#else /* !TT_CONFIG_OPTION_COLOR_LAYERS */
-
- /* ANSI C doesn't like empty source files */
- typedef int tt_cpal_dummy_;
-
-#endif /* !TT_CONFIG_OPTION_COLOR_LAYERS */
-
-/* EOF */
diff --git a/contrib/libs/freetype/src/sfnt/ttcpal.h b/contrib/libs/freetype/src/sfnt/ttcpal.h
deleted file mode 100644
index bb301ae88b..0000000000
--- a/contrib/libs/freetype/src/sfnt/ttcpal.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/****************************************************************************
- *
- * ttcpal.h
- *
- * TrueType and OpenType color palette support (specification).
- *
- * Copyright (C) 2018-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * Originally written by Shao Yu Zhang <shaozhang@fb.com>.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef __TTCPAL_H__
-#define __TTCPAL_H__
-
-
-#include "ttload.h"
-
-
-FT_BEGIN_HEADER
-
-
- FT_LOCAL( FT_Error )
- tt_face_load_cpal( TT_Face face,
- FT_Stream stream );
-
- FT_LOCAL( void )
- tt_face_free_cpal( TT_Face face );
-
- FT_LOCAL( FT_Error )
- tt_face_palette_set( TT_Face face,
- FT_UInt palette_index );
-
-
-FT_END_HEADER
-
-
-#endif /* __TTCPAL_H__ */
-
-/* END */
diff --git a/contrib/libs/freetype/src/sfnt/ttgpos.c b/contrib/libs/freetype/src/sfnt/ttgpos.c
deleted file mode 100644
index b6cd8bf820..0000000000
--- a/contrib/libs/freetype/src/sfnt/ttgpos.c
+++ /dev/null
@@ -1,598 +0,0 @@
-/****************************************************************************
- *
- * ttgpos.c
- *
- * Load the TrueType GPOS table. The only GPOS layout feature this
- * currently supports is kerning, from x advances in the pair adjustment
- * layout feature.
- *
- * Parts of the implementation were adapted from:
- * https://github.com/nothings/stb/blob/master/stb_truetype.h
- *
- * GPOS spec reference available at:
- * https://learn.microsoft.com/en-us/typography/opentype/spec/gpos
- *
- * Copyright (C) 2024 by
- * David Saltzman
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- */
-
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/tttags.h>
-#include "freetype/fttypes.h"
-#include "freetype/internal/ftobjs.h"
-#include "ttgpos.h"
-
-
-#ifdef TT_CONFIG_OPTION_GPOS_KERNING
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT ttgpos
-
-
- typedef enum coverage_table_format_type_
- {
- COVERAGE_TABLE_FORMAT_LIST = 1,
- COVERAGE_TABLE_FORMAT_RANGE = 2
-
- } coverage_table_format_type;
-
- typedef enum class_def_table_format_type_
- {
- CLASS_DEF_TABLE_FORMAT_ARRAY = 1,
- CLASS_DEF_TABLE_FORMAT_RANGE_GROUPS = 2
-
- } class_def_table_format_type;
-
- typedef enum gpos_lookup_type_
- {
- GPOS_LOOKUP_TYPE_NONE = 0,
- GPOS_LOOKUP_TYPE_SINGLE_ADJUSTMENT = 1,
- GPOS_LOOKUP_TYPE_PAIR_ADJUSTMENT = 2,
- GPOS_LOOKUP_TYPE_CURSIVE_ATTACHMENT = 3,
- GPOS_LOOKUP_TYPE_MARK_TO_BASE_ATTACHMENT = 4,
- GPOS_LOOKUP_TYPE_MARK_TO_LIGATURE_ATTACHMENT = 5,
- GPOS_LOOKUP_TYPE_MARK_TO_MARK_ATTACHMENT = 6,
- GPOS_LOOKUP_TYPE_CONTEXT_POSITIONING = 7,
- GPOS_LOOKUP_TYPE_CHAINED_CONTEXT_POSITIONING = 8,
- GPOS_LOOKUP_TYPE_EXTENSION_POSITIONING = 9
-
- } gpos_lookup_type;
-
- typedef enum gpos_pair_adjustment_format_
- {
- GPOS_PAIR_ADJUSTMENT_FORMAT_GLYPH_PAIR = 1,
- GPOS_PAIR_ADJUSTMENT_FORMAT_CLASS_PAIR = 2
-
- } gpos_pair_adjustment_format;
-
- typedef enum gpos_value_format_bitmask_
- {
- GPOS_VALUE_FORMAT_NONE = 0x0000,
- GPOS_VALUE_FORMAT_X_PLACEMENT = 0x0001,
- GPOS_VALUE_FORMAT_Y_PLACEMENT = 0x0002,
- GPOS_VALUE_FORMAT_X_ADVANCE = 0x0004,
- GPOS_VALUE_FORMAT_Y_ADVANCE = 0x0008,
- GPOS_VALUE_FORMAT_X_PLACEMENT_DEVICE = 0x0010,
- GPOS_VALUE_FORMAT_Y_PLACEMENT_DEVICE = 0x0020,
- GPOS_VALUE_FORMAT_X_ADVANCE_DEVICE = 0x0040,
- GPOS_VALUE_FORMAT_Y_ADVANCE_DEVICE = 0x0080
-
- } gpos_value_format_bitmask;
-
-
- typedef struct TT_GPOS_Subtable_Iterator_Context_
- {
- /* Iteration state. */
- FT_Byte* current_lookup_table;
- gpos_lookup_type current_lookup_type;
- FT_UShort subtable_count;
- FT_Byte* subtable_offsets;
- FT_UInt subtable_idx;
-
- /* Element for the current iteration. */
- FT_Byte* subtable;
- gpos_lookup_type subtable_type;
-
- } TT_GPOS_Subtable_Iterator_Context;
-
-
- /* Initialize a subtable iterator for a given lookup list index. */
- static void
- tt_gpos_subtable_iterator_init(
- TT_GPOS_Subtable_Iterator_Context* context,
- FT_Byte* gpos_table,
- FT_ULong lookup_list_idx )
- {
- FT_Byte* lookup_list = gpos_table + FT_PEEK_USHORT( gpos_table + 8 );
- FT_UInt16 lookup_count = FT_PEEK_USHORT( lookup_list );
-
-
- if ( lookup_list_idx < lookup_count )
- {
- context->current_lookup_table =
- lookup_list + FT_PEEK_USHORT( lookup_list + 2 + 2 * lookup_list_idx );
- context->current_lookup_type =
- (gpos_lookup_type)FT_PEEK_USHORT( context->current_lookup_table );
- context->subtable_count =
- FT_PEEK_USHORT( context->current_lookup_table + 4 );
- context->subtable_offsets = context->current_lookup_table + 6;
- }
- else
- {
- context->current_lookup_table = NULL;
- context->current_lookup_type = GPOS_LOOKUP_TYPE_NONE;
- context->subtable_count = 0;
- context->subtable_offsets = NULL;
- }
-
- context->subtable_idx = 0;
- context->subtable = NULL;
- context->subtable_type = GPOS_LOOKUP_TYPE_NONE;
- }
-
-
- /* Get the next subtable. Return whether there was a next one. */
- static FT_Bool
- tt_gpos_subtable_iterator_next(
- TT_GPOS_Subtable_Iterator_Context* context )
- {
- if ( context->subtable_idx < context->subtable_count )
- {
- FT_UShort subtable_offset =
- FT_PEEK_USHORT( context->subtable_offsets +
- 2 * context->subtable_idx );
-
-
- context->subtable = context->current_lookup_table + subtable_offset;
-
- if ( context->current_lookup_type ==
- GPOS_LOOKUP_TYPE_EXTENSION_POSITIONING )
- {
- /* Update type and subtable based on extension positioning header. */
- context->subtable_type =
- (gpos_lookup_type)FT_PEEK_USHORT( context->subtable + 2 );
- context->subtable += FT_PEEK_ULONG( context->subtable + 4 );
- }
- else
- context->subtable_type = context->current_lookup_type;
-
- context->subtable_idx++;
- return TRUE;
- }
-
- return FALSE;
- }
-
-
- static FT_Int
- tt_gpos_get_coverage_index( FT_Byte *coverage_table,
- FT_UInt glyph )
- {
- coverage_table_format_type coverage_format =
- (coverage_table_format_type)FT_PEEK_USHORT( coverage_table );
-
-
- switch ( coverage_format )
- {
- case COVERAGE_TABLE_FORMAT_LIST:
- {
- FT_UShort glyph_count = FT_PEEK_USHORT( coverage_table + 2 );
-
- FT_Int l = 0;
- FT_Int r = glyph_count - 1;
- FT_Int m;
-
- FT_Int straw;
- FT_Int needle = (FT_Int)glyph;
-
-
- /* Binary search. */
- while ( l <= r )
- {
- FT_Byte *glyph_array = coverage_table + 4;
- FT_UShort glyph_id;
-
-
- m = ( l + r ) >> 1;
- glyph_id = FT_PEEK_USHORT( glyph_array + 2 * m );
- straw = glyph_id;
-
- if ( needle < straw )
- r = m - 1;
- else if ( needle > straw )
- l = m + 1;
- else
- return m;
- }
- break;
- }
-
- case COVERAGE_TABLE_FORMAT_RANGE:
- {
- FT_UShort range_count = FT_PEEK_USHORT( coverage_table + 2 );
- FT_Byte *range_array = coverage_table + 4;
-
- FT_Int l = 0;
- FT_Int r = range_count - 1;
- FT_Int m;
-
- FT_Int straw_start;
- FT_Int straw_end;
- FT_Int needle = (FT_Int)glyph;
-
-
- /* Binary search. */
- while ( l <= r )
- {
- FT_Byte *range_record;
-
-
- m = ( l + r ) >> 1;
- range_record = range_array + 6 * m;
- straw_start = FT_PEEK_USHORT( range_record );
- straw_end = FT_PEEK_USHORT( range_record + 2 );
-
- if ( needle < straw_start )
- r = m - 1;
- else if ( needle > straw_end )
- l = m + 1;
- else
- {
- FT_UShort start_coverage_index =
- FT_PEEK_USHORT( range_record + 4 );
-
-
- return (FT_Int)start_coverage_index + (FT_Int)glyph - straw_start;
- }
- }
- break;
- }
- }
-
- return -1;
- }
-
-
- static FT_Int
- tt_gpos_get_glyph_class( FT_Byte *class_def_table,
- FT_UInt glyph )
- {
- class_def_table_format_type class_def_format =
- (class_def_table_format_type)FT_PEEK_USHORT( class_def_table );
-
-
- switch ( class_def_format )
- {
- case CLASS_DEF_TABLE_FORMAT_ARRAY:
- {
- FT_UInt start_glyph_id = FT_PEEK_USHORT( class_def_table + 2 );
- FT_UInt glyph_count = FT_PEEK_USHORT( class_def_table + 4 );
- FT_Byte *class_value_array = class_def_table + 6;
-
-
- if ( glyph >= start_glyph_id &&
- glyph < start_glyph_id + glyph_count )
- return (FT_Int)FT_PEEK_USHORT( class_value_array +
- 2 * ( glyph - start_glyph_id ) );
- break;
- }
-
- case CLASS_DEF_TABLE_FORMAT_RANGE_GROUPS:
- {
- FT_UShort class_range_count = FT_PEEK_USHORT( class_def_table + 2 );
- FT_Byte *class_range_records = class_def_table + 4;
-
- FT_Int l = 0;
- FT_Int r = class_range_count - 1;
- FT_Int m;
-
- FT_Int straw_start;
- FT_Int straw_end;
- FT_Int needle = (FT_Int)glyph;
-
-
- while ( l <= r )
- {
- FT_Byte *class_range_record;
-
-
- m = ( l + r ) >> 1;
- class_range_record = class_range_records + 6 * m;
- straw_start = FT_PEEK_USHORT( class_range_record );
- straw_end = FT_PEEK_USHORT( class_range_record + 2 );
-
- if ( needle < straw_start )
- r = m - 1;
- else if ( needle > straw_end )
- l = m + 1;
- else
- return (FT_Int)FT_PEEK_USHORT( class_range_record + 4 );
- }
- break;
- }
- }
-
- /* "All glyphs not assigned to a class fall into class 0." */
- /* (OpenType spec) */
- return 0;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- tt_face_load_gpos( TT_Face face,
- FT_Stream stream )
- {
- FT_Error error;
- FT_ULong table_size;
-
-
- /* The GPOS table is optional; exit silently if it is missing. */
- error = face->goto_table( face, TTAG_GPOS, stream, &table_size );
- if ( error )
- goto Exit;
-
- if ( table_size < 4 ) /* the case of a malformed table */
- {
- FT_ERROR(( "tt_face_load_gpos:"
- " GPOS table is too small - ignored\n" ));
- error = FT_THROW( Table_Missing );
- goto Exit;
- }
-
- if ( FT_FRAME_EXTRACT( table_size, face->gpos_table ) )
- {
- FT_ERROR(( "tt_face_load_gpos:"
- " could not extract GPOS table\n" ));
- goto Exit;
- }
-
- face->gpos_kerning_available = FALSE;
-
- if ( face->gpos_table )
- {
- FT_Byte* feature_list = face->gpos_table +
- FT_PEEK_USHORT( face->gpos_table + 6 );
- FT_UInt16 feature_count = FT_PEEK_USHORT( feature_list );
- FT_Byte* feature_records = feature_list + 2;
-
- FT_UInt idx;
-
-
- for ( idx = 0; idx < feature_count; idx++, feature_records += 6 )
- {
- FT_ULong feature_tag = FT_PEEK_ULONG( feature_records );
-
-
- if ( feature_tag == TTAG_kern )
- {
- face->gpos_kerning_available = TRUE;
- break;
- }
- }
- }
-
- Exit:
- return error;
- }
-
-
- FT_LOCAL_DEF( void )
- tt_face_done_gpos( TT_Face face )
- {
- FT_Stream stream = face->root.stream;
-
-
- FT_FRAME_RELEASE( face->gpos_table );
- }
-
-
- FT_LOCAL_DEF( FT_Int )
- tt_face_get_gpos_kerning( TT_Face face,
- FT_UInt left_glyph,
- FT_UInt right_glyph )
- {
- FT_Byte* feature_list;
- FT_UInt16 feature_count;
- FT_Byte* feature_records;
- FT_UInt feature_idx;
-
-
- if ( !face->gpos_kerning_available )
- return 0;
-
- feature_list = face->gpos_table +
- FT_PEEK_USHORT( face->gpos_table + 6 );
- feature_count = FT_PEEK_USHORT( feature_list );
- feature_records = feature_list + 2;
-
- for ( feature_idx = 0;
- feature_idx < feature_count;
- feature_idx++, feature_records += 6 )
- {
- FT_ULong feature_tag = FT_PEEK_ULONG( feature_records );
- FT_Byte* feature_table;
- FT_UInt16 lookup_idx_count;
- FT_UInt16 lookup_idx;
-
-
- if ( feature_tag != TTAG_kern )
- continue;
-
- feature_table = feature_list + FT_PEEK_USHORT( feature_records + 4 );
- lookup_idx_count = FT_PEEK_USHORT( feature_table + 2 );
-
- for ( lookup_idx = 0; lookup_idx < lookup_idx_count; lookup_idx++ )
- {
- FT_UInt16 lookup_list_idx =
- FT_PEEK_USHORT( feature_table + 4 + 2 * lookup_idx );
- TT_GPOS_Subtable_Iterator_Context subtable_iter;
-
-
- tt_gpos_subtable_iterator_init( &subtable_iter,
- face->gpos_table,
- lookup_list_idx );
-
- while ( tt_gpos_subtable_iterator_next( &subtable_iter ) )
- {
- FT_Byte* subtable;
-
- gpos_value_format_bitmask value_format_1;
- gpos_value_format_bitmask value_format_2;
- gpos_pair_adjustment_format format;
-
- FT_UShort coverage_offset;
- FT_Int coverage_index;
-
-
- if ( subtable_iter.subtable_type !=
- GPOS_LOOKUP_TYPE_PAIR_ADJUSTMENT )
- continue;
-
- subtable = subtable_iter.subtable;
-
- value_format_1 =
- (gpos_value_format_bitmask)FT_PEEK_USHORT( subtable + 4 );
- value_format_2 =
- (gpos_value_format_bitmask)FT_PEEK_USHORT( subtable + 6 );
-
- if ( !( value_format_1 == GPOS_VALUE_FORMAT_X_ADVANCE &&
- value_format_2 == GPOS_VALUE_FORMAT_NONE ) )
- continue;
-
- format = (gpos_pair_adjustment_format)FT_PEEK_USHORT( subtable );
-
- coverage_offset = FT_PEEK_USHORT( subtable + 2 );
- coverage_index =
- tt_gpos_get_coverage_index( subtable + coverage_offset,
- left_glyph );
-
- if ( coverage_index == -1 )
- continue;
-
- switch ( format )
- {
- case GPOS_PAIR_ADJUSTMENT_FORMAT_GLYPH_PAIR:
- {
- FT_Int l, r, m;
- FT_Int straw, needle;
-
- FT_Int value_record_pair_size_in_bytes = 2;
-
- FT_UShort pair_set_count = FT_PEEK_USHORT( subtable + 8 );
- FT_UShort pair_pos_offset;
-
- FT_Byte* pair_value_table;
- FT_UShort pair_value_count;
- FT_Byte* pair_value_array;
-
-
- if ( coverage_index >= pair_set_count )
- return 0;
-
- pair_pos_offset =
- FT_PEEK_USHORT( subtable + 10 + 2 * coverage_index );
-
- pair_value_table = subtable + pair_pos_offset;
- pair_value_count = FT_PEEK_USHORT( pair_value_table );
- pair_value_array = pair_value_table + 2;
-
- needle = (FT_Int)right_glyph;
- r = pair_value_count - 1;
- l = 0;
-
- /* Binary search. */
- while ( l <= r )
- {
- FT_UShort second_glyph;
- FT_Byte* pair_value;
-
-
- m = ( l + r ) >> 1;
- pair_value = pair_value_array +
- ( 2 + value_record_pair_size_in_bytes ) * m;
- second_glyph = FT_PEEK_USHORT( pair_value );
- straw = second_glyph;
-
- if ( needle < straw )
- r = m - 1;
- else if ( needle > straw )
- l = m + 1;
- else
- {
- FT_Short x_advance = FT_PEEK_SHORT( pair_value + 2 );
-
-
- return x_advance;
- }
- }
- break;
- }
-
- case GPOS_PAIR_ADJUSTMENT_FORMAT_CLASS_PAIR:
- {
- FT_UShort class_def1_offset = FT_PEEK_USHORT( subtable + 8 );
- FT_UShort class_def2_offset = FT_PEEK_USHORT( subtable + 10 );
-
- FT_Int left_glyph_class =
- tt_gpos_get_glyph_class( subtable + class_def1_offset,
- left_glyph );
- FT_Int right_glyph_class =
- tt_gpos_get_glyph_class( subtable + class_def2_offset,
- right_glyph );
-
- FT_UShort class1_count = FT_PEEK_USHORT( subtable + 12 );
- FT_UShort class2_count = FT_PEEK_USHORT( subtable + 14 );
-
- FT_Byte *class1_records, *class2_records;
- FT_Short x_advance;
-
-
- if ( left_glyph_class < 0 ||
- left_glyph_class >= class1_count )
- return 0; /* malformed */
- if ( right_glyph_class < 0 ||
- right_glyph_class >= class2_count )
- return 0; /* malformed */
-
- if ( right_glyph_class == 0 )
- continue; /* right glyph not found in this table */
-
- class1_records = subtable + 16;
- class2_records =
- class1_records + 2 * ( left_glyph_class * class2_count );
-
- x_advance =
- FT_PEEK_SHORT( class2_records + 2 * right_glyph_class );
-
- return x_advance;
- }
- }
- }
- }
- }
-
- return 0;
- }
-
-#else /* !TT_CONFIG_OPTION_GPOS_KERNING */
-
- /* ANSI C doesn't like empty source files */
- typedef int tt_gpos_dummy_;
-
-#endif /* !TT_CONFIG_OPTION_GPOS_KERNING */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/sfnt/ttgpos.h b/contrib/libs/freetype/src/sfnt/ttgpos.h
deleted file mode 100644
index 570e9e3d75..0000000000
--- a/contrib/libs/freetype/src/sfnt/ttgpos.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/****************************************************************************
- *
- * ttgpos.c
- *
- * Load the TrueType GPOS table. The only GPOS layout feature this
- * currently supports is kerning, from x advances in the pair adjustment
- * layout feature.
- *
- * Copyright (C) 2024 by
- * David Saltzman
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- */
-
-
-#ifndef TTGPOS_H_
-#define TTGPOS_H_
-
-
-#include <freetype/internal/ftstream.h>
-#include <freetype/internal/tttypes.h>
-
-
-FT_BEGIN_HEADER
-
-
-#ifdef TT_CONFIG_OPTION_GPOS_KERNING
-
- FT_LOCAL( FT_Error )
- tt_face_load_gpos( TT_Face face,
- FT_Stream stream );
-
- FT_LOCAL( void )
- tt_face_done_gpos( TT_Face face );
-
- FT_LOCAL( FT_Int )
- tt_face_get_gpos_kerning( TT_Face face,
- FT_UInt left_glyph,
- FT_UInt right_glyph );
-
-#endif /* TT_CONFIG_OPTION_GPOS_KERNING */
-
-
-FT_END_HEADER
-
-#endif /* TTGPOS_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/sfnt/ttkern.c b/contrib/libs/freetype/src/sfnt/ttkern.c
deleted file mode 100644
index f0411366af..0000000000
--- a/contrib/libs/freetype/src/sfnt/ttkern.c
+++ /dev/null
@@ -1,317 +0,0 @@
-/****************************************************************************
- *
- * ttkern.c
- *
- * Load the basic TrueType kerning table. This doesn't handle
- * kerning data within the GPOS table at the moment.
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/tttags.h>
-#include "ttkern.h"
-
-#include "sferrors.h"
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT ttkern
-
-
-#undef TT_KERN_INDEX
-#define TT_KERN_INDEX( g1, g2 ) ( ( (FT_ULong)(g1) << 16 ) | (g2) )
-
-
- FT_LOCAL_DEF( FT_Error )
- tt_face_load_kern( TT_Face face,
- FT_Stream stream )
- {
- FT_Error error;
- FT_ULong table_size;
- FT_Byte* p;
- FT_Byte* p_limit;
- FT_UInt nn, num_tables;
- FT_UInt32 avail = 0, ordered = 0;
-
-
- /* the kern table is optional; exit silently if it is missing */
- error = face->goto_table( face, TTAG_kern, stream, &table_size );
- if ( error )
- goto Exit;
-
- if ( table_size < 4 ) /* the case of a malformed table */
- {
- FT_ERROR(( "tt_face_load_kern:"
- " kerning table is too small - ignored\n" ));
- error = FT_THROW( Table_Missing );
- goto Exit;
- }
-
- if ( FT_FRAME_EXTRACT( table_size, face->kern_table ) )
- {
- FT_ERROR(( "tt_face_load_kern:"
- " could not extract kerning table\n" ));
- goto Exit;
- }
-
- face->kern_table_size = table_size;
-
- p = face->kern_table;
- p_limit = p + table_size;
-
- p += 2; /* skip version */
- num_tables = FT_NEXT_USHORT( p );
-
- if ( num_tables > 32 ) /* we only support up to 32 sub-tables */
- num_tables = 32;
-
- for ( nn = 0; nn < num_tables; nn++ )
- {
- FT_UInt num_pairs, length, coverage, format;
- FT_Byte* p_next;
- FT_UInt32 mask = (FT_UInt32)1UL << nn;
-
-
- if ( p + 6 > p_limit )
- break;
-
- p_next = p;
-
- p += 2; /* skip version */
- length = FT_NEXT_USHORT( p );
- coverage = FT_NEXT_USHORT( p );
-
- if ( length <= 6 + 8 )
- break;
-
- p_next += length;
-
- if ( p_next > p_limit ) /* handle broken table */
- p_next = p_limit;
-
- format = coverage >> 8;
-
- /* we currently only support format 0 kerning tables */
- if ( format != 0 )
- goto NextTable;
-
- /* only use horizontal kerning tables */
- if ( ( coverage & 3U ) != 0x0001 ||
- p + 8 > p_next )
- goto NextTable;
-
- num_pairs = FT_NEXT_USHORT( p );
- p += 6;
-
- if ( ( p_next - p ) < 6 * (int)num_pairs ) /* handle broken count */
- num_pairs = (FT_UInt)( ( p_next - p ) / 6 );
-
- avail |= mask;
-
- /*
- * Now check whether the pairs in this table are ordered.
- * We then can use binary search.
- */
- if ( num_pairs > 0 )
- {
- FT_ULong count;
- FT_ULong old_pair;
-
-
- old_pair = FT_NEXT_ULONG( p );
- p += 2;
-
- for ( count = num_pairs - 1; count > 0; count-- )
- {
- FT_UInt32 cur_pair;
-
-
- cur_pair = FT_NEXT_ULONG( p );
- if ( cur_pair < old_pair )
- break;
-
- p += 2;
- old_pair = cur_pair;
- }
-
- if ( count == 0 )
- ordered |= mask;
- }
-
- NextTable:
- p = p_next;
- }
-
- face->num_kern_tables = nn;
- face->kern_avail_bits = avail;
- face->kern_order_bits = ordered;
-
- Exit:
- return error;
- }
-
-
- FT_LOCAL_DEF( void )
- tt_face_done_kern( TT_Face face )
- {
- FT_Stream stream = face->root.stream;
-
-
- FT_FRAME_RELEASE( face->kern_table );
- face->kern_table_size = 0;
- face->num_kern_tables = 0;
- face->kern_avail_bits = 0;
- face->kern_order_bits = 0;
- }
-
-
- FT_LOCAL_DEF( FT_Int )
- tt_face_get_kerning( TT_Face face,
- FT_UInt left_glyph,
- FT_UInt right_glyph )
- {
- FT_Int result = 0;
- FT_UInt count, mask;
-
- FT_Byte* p;
- FT_Byte* p_limit;
-
-
- if ( !face->kern_table )
- return result;
-
- p = face->kern_table;
- p_limit = p + face->kern_table_size;
-
- p += 4;
- mask = 0x0001;
-
- for ( count = face->num_kern_tables;
- count > 0 && p + 6 <= p_limit;
- count--, mask <<= 1 )
- {
- FT_Byte* base = p;
- FT_Byte* next;
- FT_UInt version = FT_NEXT_USHORT( p );
- FT_UInt length = FT_NEXT_USHORT( p );
- FT_UInt coverage = FT_NEXT_USHORT( p );
- FT_UInt num_pairs;
- FT_Int value = 0;
-
- FT_UNUSED( version );
-
-
- next = base + length;
-
- if ( next > p_limit ) /* handle broken table */
- next = p_limit;
-
- if ( ( face->kern_avail_bits & mask ) == 0 )
- goto NextTable;
-
- FT_ASSERT( p + 8 <= next ); /* tested in tt_face_load_kern */
-
- num_pairs = FT_NEXT_USHORT( p );
- p += 6;
-
- if ( ( next - p ) < 6 * (int)num_pairs ) /* handle broken count */
- num_pairs = (FT_UInt)( ( next - p ) / 6 );
-
- switch ( coverage >> 8 )
- {
- case 0:
- {
- FT_ULong key0 = TT_KERN_INDEX( left_glyph, right_glyph );
-
-
- if ( face->kern_order_bits & mask ) /* binary search */
- {
- FT_UInt min = 0;
- FT_UInt max = num_pairs;
-
-
- while ( min < max )
- {
- FT_UInt mid = ( min + max ) >> 1;
- FT_Byte* q = p + 6 * mid;
- FT_ULong key;
-
-
- key = FT_NEXT_ULONG( q );
-
- if ( key == key0 )
- {
- value = FT_PEEK_SHORT( q );
- goto Found;
- }
- if ( key < key0 )
- min = mid + 1;
- else
- max = mid;
- }
- }
- else /* linear search */
- {
- FT_UInt count2;
-
-
- for ( count2 = num_pairs; count2 > 0; count2-- )
- {
- FT_ULong key = FT_NEXT_ULONG( p );
-
-
- if ( key == key0 )
- {
- value = FT_PEEK_SHORT( p );
- goto Found;
- }
- p += 2;
- }
- }
- }
- break;
-
- /*
- * We don't support format 2 because we haven't seen a single font
- * using it in real life...
- */
-
- default:
- ;
- }
-
- goto NextTable;
-
- Found:
- if ( coverage & 8 ) /* override or add */
- result = value;
- else
- result += value;
-
- NextTable:
- p = next;
- }
-
- return result;
- }
-
-#undef TT_KERN_INDEX
-
-/* END */
diff --git a/contrib/libs/freetype/src/sfnt/ttkern.h b/contrib/libs/freetype/src/sfnt/ttkern.h
deleted file mode 100644
index a54e51df12..0000000000
--- a/contrib/libs/freetype/src/sfnt/ttkern.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/****************************************************************************
- *
- * ttkern.h
- *
- * Load the basic TrueType kerning table. This doesn't handle
- * kerning data within the GPOS table at the moment.
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef TTKERN_H_
-#define TTKERN_H_
-
-
-#include <freetype/internal/ftstream.h>
-#include <freetype/internal/tttypes.h>
-
-
-FT_BEGIN_HEADER
-
-
- FT_LOCAL( FT_Error )
- tt_face_load_kern( TT_Face face,
- FT_Stream stream );
-
- FT_LOCAL( void )
- tt_face_done_kern( TT_Face face );
-
- FT_LOCAL( FT_Int )
- tt_face_get_kerning( TT_Face face,
- FT_UInt left_glyph,
- FT_UInt right_glyph );
-
-#define TT_FACE_HAS_KERNING( face ) ( (face)->kern_avail_bits != 0 )
-
-
-FT_END_HEADER
-
-#endif /* TTKERN_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/sfnt/ttload.c b/contrib/libs/freetype/src/sfnt/ttload.c
deleted file mode 100644
index c3a5fae2cb..0000000000
--- a/contrib/libs/freetype/src/sfnt/ttload.c
+++ /dev/null
@@ -1,1496 +0,0 @@
-/****************************************************************************
- *
- * ttload.c
- *
- * Load the basic TrueType tables, i.e., tables that can be either in
- * TTF or OTF fonts (body).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/tttags.h>
-#include "ttload.h"
-
-#include "sferrors.h"
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT ttload
-
-
- /**************************************************************************
- *
- * @Function:
- * tt_face_lookup_table
- *
- * @Description:
- * Looks for a TrueType table by name.
- *
- * @Input:
- * face ::
- * A face object handle.
- *
- * tag ::
- * The searched tag.
- *
- * @Return:
- * A pointer to the table directory entry. 0 if not found.
- */
- FT_LOCAL_DEF( TT_Table )
- tt_face_lookup_table( TT_Face face,
- FT_ULong tag )
- {
- TT_Table entry;
- TT_Table limit;
-#ifdef FT_DEBUG_LEVEL_TRACE
- FT_Bool zero_length = FALSE;
-#endif
-
-
- FT_TRACE4(( "tt_face_lookup_table: %p, `%c%c%c%c' -- ",
- (void *)face,
- (FT_Char)( tag >> 24 ),
- (FT_Char)( tag >> 16 ),
- (FT_Char)( tag >> 8 ),
- (FT_Char)( tag ) ));
-
- entry = face->dir_tables;
- limit = entry + face->num_tables;
-
- for ( ; entry < limit; entry++ )
- {
- /* For compatibility with Windows, we consider */
- /* zero-length tables the same as missing tables. */
- if ( entry->Tag == tag )
- {
- if ( entry->Length != 0 )
- {
- FT_TRACE4(( "found table.\n" ));
- return entry;
- }
-#ifdef FT_DEBUG_LEVEL_TRACE
- zero_length = TRUE;
-#endif
- }
- }
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( zero_length )
- FT_TRACE4(( "ignoring empty table\n" ));
- else
- FT_TRACE4(( "could not find table\n" ));
-#endif
-
- return NULL;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * tt_face_goto_table
- *
- * @Description:
- * Looks for a TrueType table by name, then seek a stream to it.
- *
- * @Input:
- * face ::
- * A face object handle.
- *
- * tag ::
- * The searched tag.
- *
- * stream ::
- * The stream to seek when the table is found.
- *
- * @Output:
- * length ::
- * The length of the table if found, undefined otherwise.
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
- FT_LOCAL_DEF( FT_Error )
- tt_face_goto_table( TT_Face face,
- FT_ULong tag,
- FT_Stream stream,
- FT_ULong* length )
- {
- TT_Table table;
- FT_Error error;
-
-
- table = tt_face_lookup_table( face, tag );
- if ( table )
- {
- if ( length )
- *length = table->Length;
-
- if ( FT_STREAM_SEEK( table->Offset ) )
- goto Exit;
- }
- else
- error = FT_THROW( Table_Missing );
-
- Exit:
- return error;
- }
-
-
- /* Here, we */
- /* */
- /* - check that `num_tables' is valid (and adjust it if necessary); */
- /* also return the number of valid table entries */
- /* */
- /* - look for a `head' table, check its size, and parse it to check */
- /* whether its `magic' field is correctly set */
- /* */
- /* - errors (except errors returned by stream handling) */
- /* */
- /* SFNT_Err_Unknown_File_Format: */
- /* no table is defined in directory, it is not sfnt-wrapped */
- /* data */
- /* SFNT_Err_Table_Missing: */
- /* table directory is valid, but essential tables */
- /* (head/bhed/SING) are missing */
- /* */
- static FT_Error
- check_table_dir( SFNT_Header sfnt,
- FT_Stream stream,
- FT_UShort* valid )
- {
- FT_Error error;
- FT_UShort nn, valid_entries = 0;
- FT_UInt has_head = 0, has_sing = 0, has_meta = 0;
- FT_ULong offset = sfnt->offset + 12;
-
- static const FT_Frame_Field table_dir_entry_fields[] =
- {
-#undef FT_STRUCTURE
-#define FT_STRUCTURE TT_TableRec
-
- FT_FRAME_START( 16 ),
- FT_FRAME_ULONG( Tag ),
- FT_FRAME_ULONG( CheckSum ),
- FT_FRAME_ULONG( Offset ),
- FT_FRAME_ULONG( Length ),
- FT_FRAME_END
- };
-
-
- if ( FT_STREAM_SEEK( offset ) )
- goto Exit;
-
- for ( nn = 0; nn < sfnt->num_tables; nn++ )
- {
- TT_TableRec table;
-
-
- if ( FT_STREAM_READ_FIELDS( table_dir_entry_fields, &table ) )
- {
- FT_TRACE2(( "check_table_dir:"
- " can read only %hu table%s in font (instead of %hu)\n",
- nn, nn == 1 ? "" : "s", sfnt->num_tables ));
- sfnt->num_tables = nn;
- break;
- }
-
- /* we ignore invalid tables */
-
- if ( table.Offset > stream->size )
- {
- FT_TRACE2(( "check_table_dir: table entry %hu invalid\n", nn ));
- continue;
- }
- else if ( table.Length > stream->size - table.Offset )
- {
- /* Some tables have such a simple structure that clipping its */
- /* contents is harmless. This also makes FreeType less sensitive */
- /* to invalid table lengths (which programs like Acroread seem to */
- /* ignore in general). */
-
- if ( table.Tag == TTAG_hmtx ||
- table.Tag == TTAG_vmtx )
- valid_entries++;
- else
- {
- FT_TRACE2(( "check_table_dir: table entry %hu invalid\n", nn ));
- continue;
- }
- }
- else
- valid_entries++;
-
- if ( table.Tag == TTAG_head || table.Tag == TTAG_bhed )
- {
- FT_UInt32 magic;
-
-
-#ifndef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
- if ( table.Tag == TTAG_head )
-#endif
- has_head = 1;
-
- /*
- * The table length should be 0x36, but certain font tools make it
- * 0x38, so we will just check that it is greater.
- *
- * Note that according to the specification, the table must be
- * padded to 32-bit lengths, but this doesn't apply to the value of
- * its `Length' field!
- *
- */
- if ( table.Length < 0x36 )
- {
- FT_TRACE2(( "check_table_dir:"
- " `head' or `bhed' table too small\n" ));
- error = FT_THROW( Table_Missing );
- goto Exit;
- }
-
- if ( FT_STREAM_SEEK( table.Offset + 12 ) ||
- FT_READ_ULONG( magic ) )
- goto Exit;
-
- if ( magic != 0x5F0F3CF5UL )
- FT_TRACE2(( "check_table_dir:"
- " invalid magic number in `head' or `bhed' table\n"));
-
- if ( FT_STREAM_SEEK( offset + ( nn + 1 ) * 16 ) )
- goto Exit;
- }
- else if ( table.Tag == TTAG_SING )
- has_sing = 1;
- else if ( table.Tag == TTAG_META )
- has_meta = 1;
- }
-
- *valid = valid_entries;
-
- if ( !valid_entries )
- {
- FT_TRACE2(( "check_table_dir: no valid tables found\n" ));
- error = FT_THROW( Unknown_File_Format );
- goto Exit;
- }
-
- /* if `sing' and `meta' tables are present, there is no `head' table */
- if ( has_head || ( has_sing && has_meta ) )
- {
- error = FT_Err_Ok;
- goto Exit;
- }
- else
- {
- FT_TRACE2(( "check_table_dir:" ));
-#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
- FT_TRACE2(( " neither `head', `bhed', nor `sing' table found\n" ));
-#else
- FT_TRACE2(( " neither `head' nor `sing' table found\n" ));
-#endif
- error = FT_THROW( Table_Missing );
- }
-
- Exit:
- return error;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * tt_face_load_font_dir
- *
- * @Description:
- * Loads the header of a SFNT font file.
- *
- * @Input:
- * face ::
- * A handle to the target face object.
- *
- * stream ::
- * The input stream.
- *
- * @Output:
- * sfnt ::
- * The SFNT header.
- *
- * @Return:
- * FreeType error code. 0 means success.
- *
- * @Note:
- * The stream cursor must be at the beginning of the font directory.
- */
- FT_LOCAL_DEF( FT_Error )
- tt_face_load_font_dir( TT_Face face,
- FT_Stream stream )
- {
- SFNT_HeaderRec sfnt;
- FT_Error error;
- FT_Memory memory = stream->memory;
- FT_UShort nn, valid_entries = 0;
-
- static const FT_Frame_Field offset_table_fields[] =
- {
-#undef FT_STRUCTURE
-#define FT_STRUCTURE SFNT_HeaderRec
-
- FT_FRAME_START( 8 ),
- FT_FRAME_USHORT( num_tables ),
- FT_FRAME_USHORT( search_range ),
- FT_FRAME_USHORT( entry_selector ),
- FT_FRAME_USHORT( range_shift ),
- FT_FRAME_END
- };
-
-
- FT_TRACE2(( "tt_face_load_font_dir: %p\n", (void *)face ));
-
- /* read the offset table */
-
- sfnt.offset = FT_STREAM_POS();
-
- if ( FT_READ_ULONG( sfnt.format_tag ) ||
- FT_STREAM_READ_FIELDS( offset_table_fields, &sfnt ) )
- goto Exit;
-
- /* many fonts don't have these fields set correctly */
-#if 0
- if ( sfnt.search_range != 1 << ( sfnt.entry_selector + 4 ) ||
- sfnt.search_range + sfnt.range_shift != sfnt.num_tables << 4 )
- return FT_THROW( Unknown_File_Format );
-#endif
-
- /* load the table directory */
-
- FT_TRACE2(( "-- Number of tables: %10hu\n", sfnt.num_tables ));
- FT_TRACE2(( "-- Format version: 0x%08lx\n", sfnt.format_tag ));
-
- if ( sfnt.format_tag != TTAG_OTTO )
- {
- /* check first */
- error = check_table_dir( &sfnt, stream, &valid_entries );
- if ( error )
- {
- FT_TRACE2(( "tt_face_load_font_dir:"
- " invalid table directory for TrueType\n" ));
- goto Exit;
- }
- }
- else
- {
- valid_entries = sfnt.num_tables;
- if ( !valid_entries )
- {
- FT_TRACE2(( "tt_face_load_font_dir: no valid tables found\n" ));
- error = FT_THROW( Unknown_File_Format );
- goto Exit;
- }
- }
-
- face->num_tables = valid_entries;
- face->format_tag = sfnt.format_tag;
-
- if ( FT_QNEW_ARRAY( face->dir_tables, face->num_tables ) )
- goto Exit;
-
- if ( FT_STREAM_SEEK( sfnt.offset + 12 ) ||
- FT_FRAME_ENTER( sfnt.num_tables * 16L ) )
- goto Exit;
-
- FT_TRACE2(( "\n" ));
- FT_TRACE2(( " tag offset length checksum\n" ));
- FT_TRACE2(( " ----------------------------------\n" ));
-
- valid_entries = 0;
- for ( nn = 0; nn < sfnt.num_tables; nn++ )
- {
- TT_TableRec entry;
- FT_UShort i;
- FT_Bool duplicate;
-
-
- entry.Tag = FT_GET_TAG4();
- entry.CheckSum = FT_GET_ULONG();
- entry.Offset = FT_GET_ULONG();
- entry.Length = FT_GET_ULONG();
-
- /* ignore invalid tables that can't be sanitized */
-
- if ( entry.Offset > stream->size )
- continue;
- else if ( entry.Length > stream->size - entry.Offset )
- {
- if ( entry.Tag == TTAG_hmtx ||
- entry.Tag == TTAG_vmtx )
- {
-#ifdef FT_DEBUG_LEVEL_TRACE
- FT_ULong old_length = entry.Length;
-#endif
-
-
- /* make metrics table length a multiple of 4 */
- entry.Length = ( stream->size - entry.Offset ) & ~3U;
-
- FT_TRACE2(( " %c%c%c%c %08lx %08lx %08lx"
- " (sanitized; original length %08lx)",
- (FT_Char)( entry.Tag >> 24 ),
- (FT_Char)( entry.Tag >> 16 ),
- (FT_Char)( entry.Tag >> 8 ),
- (FT_Char)( entry.Tag ),
- entry.Offset,
- entry.Length,
- entry.CheckSum,
- old_length ));
- }
- else
- continue;
- }
-#ifdef FT_DEBUG_LEVEL_TRACE
- else
- FT_TRACE2(( " %c%c%c%c %08lx %08lx %08lx",
- (FT_Char)( entry.Tag >> 24 ),
- (FT_Char)( entry.Tag >> 16 ),
- (FT_Char)( entry.Tag >> 8 ),
- (FT_Char)( entry.Tag ),
- entry.Offset,
- entry.Length,
- entry.CheckSum ));
-#endif
-
- /* ignore duplicate tables – the first one wins */
- duplicate = 0;
- for ( i = 0; i < valid_entries; i++ )
- {
- if ( face->dir_tables[i].Tag == entry.Tag )
- {
- duplicate = 1;
- break;
- }
- }
- if ( duplicate )
- {
- FT_TRACE2(( " (duplicate, ignored)\n" ));
- continue;
- }
- else
- {
- FT_TRACE2(( "\n" ));
-
- /* we finally have a valid entry */
- face->dir_tables[valid_entries++] = entry;
- }
- }
-
- /* final adjustment to number of tables */
- face->num_tables = valid_entries;
-
- FT_FRAME_EXIT();
-
- if ( !valid_entries )
- {
- FT_TRACE2(( "tt_face_load_font_dir: no valid tables found\n" ));
- error = FT_THROW( Unknown_File_Format );
- goto Exit;
- }
-
- FT_TRACE2(( "table directory loaded\n" ));
- FT_TRACE2(( "\n" ));
-
- Exit:
- return error;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * tt_face_load_any
- *
- * @Description:
- * Loads any font table into client memory.
- *
- * @Input:
- * face ::
- * The face object to look for.
- *
- * tag ::
- * The tag of table to load. Use the value 0 if you want
- * to access the whole font file, else set this parameter
- * to a valid TrueType table tag that you can forge with
- * the MAKE_TT_TAG macro.
- *
- * offset ::
- * The starting offset in the table (or the file if
- * tag == 0).
- *
- * length ::
- * The address of the decision variable:
- *
- * If length == NULL:
- * Loads the whole table. Returns an error if
- * `offset' == 0!
- *
- * If *length == 0:
- * Exits immediately; returning the length of the given
- * table or of the font file, depending on the value of
- * `tag'.
- *
- * If *length != 0:
- * Loads the next `length' bytes of table or font,
- * starting at offset `offset' (in table or font too).
- *
- * @Output:
- * buffer ::
- * The address of target buffer.
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
- FT_LOCAL_DEF( FT_Error )
- tt_face_load_any( TT_Face face,
- FT_ULong tag,
- FT_Long offset,
- FT_Byte* buffer,
- FT_ULong* length )
- {
- FT_Error error;
- FT_Stream stream;
- TT_Table table;
- FT_ULong size;
-
-
- if ( tag != 0 )
- {
- /* look for tag in font directory */
- table = tt_face_lookup_table( face, tag );
- if ( !table )
- {
- error = FT_THROW( Table_Missing );
- goto Exit;
- }
-
- offset += table->Offset;
- size = table->Length;
- }
- else
- /* tag == 0 -- the user wants to access the font file directly */
- size = face->root.stream->size;
-
- if ( length && *length == 0 )
- {
- *length = size;
-
- return FT_Err_Ok;
- }
-
- if ( length )
- size = *length;
-
- stream = face->root.stream;
- /* the `if' is syntactic sugar for picky compilers */
- if ( FT_STREAM_READ_AT( offset, buffer, size ) )
- goto Exit;
-
- Exit:
- return error;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * tt_face_load_generic_header
- *
- * @Description:
- * Loads the TrueType table `head' or `bhed'.
- *
- * @Input:
- * face ::
- * A handle to the target face object.
- *
- * stream ::
- * The input stream.
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
- static FT_Error
- tt_face_load_generic_header( TT_Face face,
- FT_Stream stream,
- FT_ULong tag )
- {
- FT_Error error;
- TT_Header* header;
-
- static const FT_Frame_Field header_fields[] =
- {
-#undef FT_STRUCTURE
-#define FT_STRUCTURE TT_Header
-
- FT_FRAME_START( 54 ),
- FT_FRAME_ULONG ( Table_Version ),
- FT_FRAME_ULONG ( Font_Revision ),
- FT_FRAME_LONG ( CheckSum_Adjust ),
- FT_FRAME_LONG ( Magic_Number ),
- FT_FRAME_USHORT( Flags ),
- FT_FRAME_USHORT( Units_Per_EM ),
- FT_FRAME_ULONG ( Created[0] ),
- FT_FRAME_ULONG ( Created[1] ),
- FT_FRAME_ULONG ( Modified[0] ),
- FT_FRAME_ULONG ( Modified[1] ),
- FT_FRAME_SHORT ( xMin ),
- FT_FRAME_SHORT ( yMin ),
- FT_FRAME_SHORT ( xMax ),
- FT_FRAME_SHORT ( yMax ),
- FT_FRAME_USHORT( Mac_Style ),
- FT_FRAME_USHORT( Lowest_Rec_PPEM ),
- FT_FRAME_SHORT ( Font_Direction ),
- FT_FRAME_SHORT ( Index_To_Loc_Format ),
- FT_FRAME_SHORT ( Glyph_Data_Format ),
- FT_FRAME_END
- };
-
-
- error = face->goto_table( face, tag, stream, 0 );
- if ( error )
- goto Exit;
-
- header = &face->header;
-
- if ( FT_STREAM_READ_FIELDS( header_fields, header ) )
- goto Exit;
-
- FT_TRACE3(( "Units per EM: %4hu\n", header->Units_Per_EM ));
- FT_TRACE3(( "IndexToLoc: %4hd\n", header->Index_To_Loc_Format ));
-
- Exit:
- return error;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- tt_face_load_head( TT_Face face,
- FT_Stream stream )
- {
- return tt_face_load_generic_header( face, stream, TTAG_head );
- }
-
-
-#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
-
- FT_LOCAL_DEF( FT_Error )
- tt_face_load_bhed( TT_Face face,
- FT_Stream stream )
- {
- return tt_face_load_generic_header( face, stream, TTAG_bhed );
- }
-
-#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
-
-
- /**************************************************************************
- *
- * @Function:
- * tt_face_load_maxp
- *
- * @Description:
- * Loads the maximum profile into a face object.
- *
- * @Input:
- * face ::
- * A handle to the target face object.
- *
- * stream ::
- * The input stream.
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
- FT_LOCAL_DEF( FT_Error )
- tt_face_load_maxp( TT_Face face,
- FT_Stream stream )
- {
- FT_Error error;
- TT_MaxProfile* maxProfile = &face->max_profile;
-
- static const FT_Frame_Field maxp_fields[] =
- {
-#undef FT_STRUCTURE
-#define FT_STRUCTURE TT_MaxProfile
-
- FT_FRAME_START( 6 ),
- FT_FRAME_LONG ( version ),
- FT_FRAME_USHORT( numGlyphs ),
- FT_FRAME_END
- };
-
- static const FT_Frame_Field maxp_fields_extra[] =
- {
- FT_FRAME_START( 26 ),
- FT_FRAME_USHORT( maxPoints ),
- FT_FRAME_USHORT( maxContours ),
- FT_FRAME_USHORT( maxCompositePoints ),
- FT_FRAME_USHORT( maxCompositeContours ),
- FT_FRAME_USHORT( maxZones ),
- FT_FRAME_USHORT( maxTwilightPoints ),
- FT_FRAME_USHORT( maxStorage ),
- FT_FRAME_USHORT( maxFunctionDefs ),
- FT_FRAME_USHORT( maxInstructionDefs ),
- FT_FRAME_USHORT( maxStackElements ),
- FT_FRAME_USHORT( maxSizeOfInstructions ),
- FT_FRAME_USHORT( maxComponentElements ),
- FT_FRAME_USHORT( maxComponentDepth ),
- FT_FRAME_END
- };
-
-
- error = face->goto_table( face, TTAG_maxp, stream, 0 );
- if ( error )
- goto Exit;
-
- if ( FT_STREAM_READ_FIELDS( maxp_fields, maxProfile ) )
- goto Exit;
-
- maxProfile->maxPoints = 0;
- maxProfile->maxContours = 0;
- maxProfile->maxCompositePoints = 0;
- maxProfile->maxCompositeContours = 0;
- maxProfile->maxZones = 0;
- maxProfile->maxTwilightPoints = 0;
- maxProfile->maxStorage = 0;
- maxProfile->maxFunctionDefs = 0;
- maxProfile->maxInstructionDefs = 0;
- maxProfile->maxStackElements = 0;
- maxProfile->maxSizeOfInstructions = 0;
- maxProfile->maxComponentElements = 0;
- maxProfile->maxComponentDepth = 0;
-
- if ( maxProfile->version >= 0x10000L )
- {
- if ( FT_STREAM_READ_FIELDS( maxp_fields_extra, maxProfile ) )
- goto Exit;
-
- /* XXX: an adjustment that is necessary to load certain */
- /* broken fonts like `Keystrokes MT' :-( */
- /* */
- /* We allocate 64 function entries by default when */
- /* the maxFunctionDefs value is smaller. */
-
- if ( maxProfile->maxFunctionDefs < 64 )
- maxProfile->maxFunctionDefs = 64;
-
- /* we add 4 phantom points later */
- if ( maxProfile->maxTwilightPoints > ( 0xFFFFU - 4 ) )
- {
- FT_TRACE0(( "tt_face_load_maxp:"
- " too much twilight points in `maxp' table;\n" ));
- FT_TRACE0(( " "
- " some glyphs might be rendered incorrectly\n" ));
-
- maxProfile->maxTwilightPoints = 0xFFFFU - 4;
- }
- }
-
- FT_TRACE3(( "numGlyphs: %hu\n", maxProfile->numGlyphs ));
-
- Exit:
- return error;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * tt_face_load_name
- *
- * @Description:
- * Loads the name records.
- *
- * @Input:
- * face ::
- * A handle to the target face object.
- *
- * stream ::
- * The input stream.
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
- FT_LOCAL_DEF( FT_Error )
- tt_face_load_name( TT_Face face,
- FT_Stream stream )
- {
- FT_Error error;
- FT_Memory memory = stream->memory;
- FT_ULong table_pos, table_len;
- FT_ULong storage_start, storage_limit;
- TT_NameTable table;
- TT_Name names = NULL;
- TT_LangTag langTags = NULL;
-
- static const FT_Frame_Field name_table_fields[] =
- {
-#undef FT_STRUCTURE
-#define FT_STRUCTURE TT_NameTableRec
-
- FT_FRAME_START( 6 ),
- FT_FRAME_USHORT( format ),
- FT_FRAME_USHORT( numNameRecords ),
- FT_FRAME_USHORT( storageOffset ),
- FT_FRAME_END
- };
-
- static const FT_Frame_Field name_record_fields[] =
- {
-#undef FT_STRUCTURE
-#define FT_STRUCTURE TT_NameRec
-
- /* no FT_FRAME_START */
- FT_FRAME_USHORT( platformID ),
- FT_FRAME_USHORT( encodingID ),
- FT_FRAME_USHORT( languageID ),
- FT_FRAME_USHORT( nameID ),
- FT_FRAME_USHORT( stringLength ),
- FT_FRAME_USHORT( stringOffset ),
- FT_FRAME_END
- };
-
- static const FT_Frame_Field langTag_record_fields[] =
- {
-#undef FT_STRUCTURE
-#define FT_STRUCTURE TT_LangTagRec
-
- /* no FT_FRAME_START */
- FT_FRAME_USHORT( stringLength ),
- FT_FRAME_USHORT( stringOffset ),
- FT_FRAME_END
- };
-
-
- table = &face->name_table;
- table->stream = stream;
-
- error = face->goto_table( face, TTAG_name, stream, &table_len );
- if ( error )
- goto Exit;
-
- table_pos = FT_STREAM_POS();
-
- if ( FT_STREAM_READ_FIELDS( name_table_fields, table ) )
- goto Exit;
-
- /* Some popular Asian fonts have an invalid `storageOffset' value (it */
- /* should be at least `6 + 12*numNameRecords'). However, the string */
- /* offsets, computed as `storageOffset + entry->stringOffset', are */
- /* valid pointers within the name table... */
- /* */
- /* We thus can't check `storageOffset' right now. */
- /* */
- storage_start = table_pos + 6 + 12 * table->numNameRecords;
- storage_limit = table_pos + table_len;
-
- if ( storage_start > storage_limit )
- {
- FT_ERROR(( "tt_face_load_name: invalid `name' table\n" ));
- error = FT_THROW( Name_Table_Missing );
- goto Exit;
- }
-
- /* `name' format 1 contains additional language tag records, */
- /* which we load first */
- if ( table->format == 1 )
- {
- if ( FT_STREAM_SEEK( storage_start ) ||
- FT_READ_USHORT( table->numLangTagRecords ) )
- goto Exit;
-
- storage_start += 2 + 4 * table->numLangTagRecords;
-
- /* allocate language tag records array */
- if ( FT_QNEW_ARRAY( langTags, table->numLangTagRecords ) ||
- FT_FRAME_ENTER( table->numLangTagRecords * 4 ) )
- goto Exit;
-
- /* load language tags */
- {
- TT_LangTag entry = langTags;
- TT_LangTag limit = FT_OFFSET( entry, table->numLangTagRecords );
-
-
- for ( ; entry < limit; entry++ )
- {
- (void)FT_STREAM_READ_FIELDS( langTag_record_fields, entry );
-
- /* check that the langTag string is within the table */
- entry->stringOffset += table_pos + table->storageOffset;
- if ( entry->stringOffset < storage_start ||
- entry->stringOffset + entry->stringLength > storage_limit )
- {
- /* invalid entry; ignore it */
- entry->stringLength = 0;
- }
-
- /* mark the string as not yet loaded */
- entry->string = NULL;
- }
-
- table->langTags = langTags;
- langTags = NULL;
- }
-
- FT_FRAME_EXIT();
-
- (void)FT_STREAM_SEEK( table_pos + 6 );
- }
-
- /* allocate name records array */
- if ( FT_QNEW_ARRAY( names, table->numNameRecords ) ||
- FT_FRAME_ENTER( table->numNameRecords * 12 ) )
- goto Exit;
-
- /* load name records */
- {
- TT_Name entry = names;
- FT_UInt count = table->numNameRecords;
- FT_UInt valid = 0;
-
-
- for ( ; count > 0; count-- )
- {
- if ( FT_STREAM_READ_FIELDS( name_record_fields, entry ) )
- continue;
-
- /* check that the name is not empty */
- if ( entry->stringLength == 0 )
- continue;
-
- /* check that the name string is within the table */
- entry->stringOffset += table_pos + table->storageOffset;
- if ( entry->stringOffset < storage_start ||
- entry->stringOffset + entry->stringLength > storage_limit )
- {
- /* invalid entry; ignore it */
- continue;
- }
-
- /* assure that we have a valid language tag ID, and */
- /* that the corresponding langTag entry is valid, too */
- if ( table->format == 1 && entry->languageID >= 0x8000U )
- {
- if ( entry->languageID - 0x8000U >= table->numLangTagRecords ||
- !table->langTags[entry->languageID - 0x8000U].stringLength )
- {
- /* invalid entry; ignore it */
- continue;
- }
- }
-
- /* mark the string as not yet converted */
- entry->string = NULL;
-
- valid++;
- entry++;
- }
-
- /* reduce array size to the actually used elements */
- FT_MEM_QRENEW_ARRAY( names,
- table->numNameRecords,
- valid );
- table->names = names;
- names = NULL;
- table->numNameRecords = valid;
- }
-
- FT_FRAME_EXIT();
-
- /* everything went well, update face->num_names */
- face->num_names = (FT_UShort)table->numNameRecords;
-
- Exit:
- FT_FREE( names );
- FT_FREE( langTags );
- return error;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * tt_face_free_name
- *
- * @Description:
- * Frees the name records.
- *
- * @Input:
- * face ::
- * A handle to the target face object.
- */
- FT_LOCAL_DEF( void )
- tt_face_free_name( TT_Face face )
- {
- FT_Memory memory = face->root.memory;
- TT_NameTable table = &face->name_table;
-
-
- if ( table->names )
- {
- TT_Name entry = table->names;
- TT_Name limit = entry + table->numNameRecords;
-
-
- for ( ; entry < limit; entry++ )
- FT_FREE( entry->string );
-
- FT_FREE( table->names );
- }
-
- if ( table->langTags )
- {
- TT_LangTag entry = table->langTags;
- TT_LangTag limit = entry + table->numLangTagRecords;
-
-
- for ( ; entry < limit; entry++ )
- FT_FREE( entry->string );
-
- FT_FREE( table->langTags );
- }
-
- table->numNameRecords = 0;
- table->numLangTagRecords = 0;
- table->format = 0;
- table->storageOffset = 0;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * tt_face_load_cmap
- *
- * @Description:
- * Loads the cmap directory in a face object. The cmaps themselves
- * are loaded on demand in the `ttcmap.c' module.
- *
- * @Input:
- * face ::
- * A handle to the target face object.
- *
- * stream ::
- * A handle to the input stream.
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
-
- FT_LOCAL_DEF( FT_Error )
- tt_face_load_cmap( TT_Face face,
- FT_Stream stream )
- {
- FT_Error error;
-
-
- error = face->goto_table( face, TTAG_cmap, stream, &face->cmap_size );
- if ( error )
- goto Exit;
-
- if ( FT_FRAME_EXTRACT( face->cmap_size, face->cmap_table ) )
- face->cmap_size = 0;
-
- Exit:
- return error;
- }
-
-
-
- /**************************************************************************
- *
- * @Function:
- * tt_face_load_os2
- *
- * @Description:
- * Loads the OS2 table.
- *
- * @Input:
- * face ::
- * A handle to the target face object.
- *
- * stream ::
- * A handle to the input stream.
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
- FT_LOCAL_DEF( FT_Error )
- tt_face_load_os2( TT_Face face,
- FT_Stream stream )
- {
- FT_Error error;
- TT_OS2* os2;
-
- static const FT_Frame_Field os2_fields[] =
- {
-#undef FT_STRUCTURE
-#define FT_STRUCTURE TT_OS2
-
- FT_FRAME_START( 78 ),
- FT_FRAME_USHORT( version ),
- FT_FRAME_SHORT ( xAvgCharWidth ),
- FT_FRAME_USHORT( usWeightClass ),
- FT_FRAME_USHORT( usWidthClass ),
- FT_FRAME_SHORT ( fsType ),
- FT_FRAME_SHORT ( ySubscriptXSize ),
- FT_FRAME_SHORT ( ySubscriptYSize ),
- FT_FRAME_SHORT ( ySubscriptXOffset ),
- FT_FRAME_SHORT ( ySubscriptYOffset ),
- FT_FRAME_SHORT ( ySuperscriptXSize ),
- FT_FRAME_SHORT ( ySuperscriptYSize ),
- FT_FRAME_SHORT ( ySuperscriptXOffset ),
- FT_FRAME_SHORT ( ySuperscriptYOffset ),
- FT_FRAME_SHORT ( yStrikeoutSize ),
- FT_FRAME_SHORT ( yStrikeoutPosition ),
- FT_FRAME_SHORT ( sFamilyClass ),
- FT_FRAME_BYTE ( panose[0] ),
- FT_FRAME_BYTE ( panose[1] ),
- FT_FRAME_BYTE ( panose[2] ),
- FT_FRAME_BYTE ( panose[3] ),
- FT_FRAME_BYTE ( panose[4] ),
- FT_FRAME_BYTE ( panose[5] ),
- FT_FRAME_BYTE ( panose[6] ),
- FT_FRAME_BYTE ( panose[7] ),
- FT_FRAME_BYTE ( panose[8] ),
- FT_FRAME_BYTE ( panose[9] ),
- FT_FRAME_ULONG ( ulUnicodeRange1 ),
- FT_FRAME_ULONG ( ulUnicodeRange2 ),
- FT_FRAME_ULONG ( ulUnicodeRange3 ),
- FT_FRAME_ULONG ( ulUnicodeRange4 ),
- FT_FRAME_BYTE ( achVendID[0] ),
- FT_FRAME_BYTE ( achVendID[1] ),
- FT_FRAME_BYTE ( achVendID[2] ),
- FT_FRAME_BYTE ( achVendID[3] ),
-
- FT_FRAME_USHORT( fsSelection ),
- FT_FRAME_USHORT( usFirstCharIndex ),
- FT_FRAME_USHORT( usLastCharIndex ),
- FT_FRAME_SHORT ( sTypoAscender ),
- FT_FRAME_SHORT ( sTypoDescender ),
- FT_FRAME_SHORT ( sTypoLineGap ),
- FT_FRAME_USHORT( usWinAscent ),
- FT_FRAME_USHORT( usWinDescent ),
- FT_FRAME_END
- };
-
- /* `OS/2' version 1 and newer */
- static const FT_Frame_Field os2_fields_extra1[] =
- {
- FT_FRAME_START( 8 ),
- FT_FRAME_ULONG( ulCodePageRange1 ),
- FT_FRAME_ULONG( ulCodePageRange2 ),
- FT_FRAME_END
- };
-
- /* `OS/2' version 2 and newer */
- static const FT_Frame_Field os2_fields_extra2[] =
- {
- FT_FRAME_START( 10 ),
- FT_FRAME_SHORT ( sxHeight ),
- FT_FRAME_SHORT ( sCapHeight ),
- FT_FRAME_USHORT( usDefaultChar ),
- FT_FRAME_USHORT( usBreakChar ),
- FT_FRAME_USHORT( usMaxContext ),
- FT_FRAME_END
- };
-
- /* `OS/2' version 5 and newer */
- static const FT_Frame_Field os2_fields_extra5[] =
- {
- FT_FRAME_START( 4 ),
- FT_FRAME_USHORT( usLowerOpticalPointSize ),
- FT_FRAME_USHORT( usUpperOpticalPointSize ),
- FT_FRAME_END
- };
-
-
- /* We now support old Mac fonts where the OS/2 table doesn't */
- /* exist. Simply put, we set the `version' field to 0xFFFF */
- /* and test this value each time we need to access the table. */
- error = face->goto_table( face, TTAG_OS2, stream, 0 );
- if ( error )
- goto Exit;
-
- os2 = &face->os2;
-
- if ( FT_STREAM_READ_FIELDS( os2_fields, os2 ) )
- goto Exit;
-
- os2->ulCodePageRange1 = 0;
- os2->ulCodePageRange2 = 0;
- os2->sxHeight = 0;
- os2->sCapHeight = 0;
- os2->usDefaultChar = 0;
- os2->usBreakChar = 0;
- os2->usMaxContext = 0;
- os2->usLowerOpticalPointSize = 0;
- os2->usUpperOpticalPointSize = 0xFFFF;
-
- if ( os2->version >= 0x0001 )
- {
- /* only version 1 tables */
- if ( FT_STREAM_READ_FIELDS( os2_fields_extra1, os2 ) )
- goto Exit;
-
- if ( os2->version >= 0x0002 )
- {
- /* only version 2 tables */
- if ( FT_STREAM_READ_FIELDS( os2_fields_extra2, os2 ) )
- goto Exit;
-
- if ( os2->version >= 0x0005 )
- {
- /* only version 5 tables */
- if ( FT_STREAM_READ_FIELDS( os2_fields_extra5, os2 ) )
- goto Exit;
- }
- }
- }
-
- FT_TRACE3(( "sTypoAscender: %4hd\n", os2->sTypoAscender ));
- FT_TRACE3(( "sTypoDescender: %4hd\n", os2->sTypoDescender ));
- FT_TRACE3(( "usWinAscent: %4hu\n", os2->usWinAscent ));
- FT_TRACE3(( "usWinDescent: %4hu\n", os2->usWinDescent ));
- FT_TRACE3(( "fsSelection: 0x%2hx\n", os2->fsSelection ));
-
- Exit:
- return error;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * tt_face_load_postscript
- *
- * @Description:
- * Loads the Postscript table.
- *
- * @Input:
- * face ::
- * A handle to the target face object.
- *
- * stream ::
- * A handle to the input stream.
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
- FT_LOCAL_DEF( FT_Error )
- tt_face_load_post( TT_Face face,
- FT_Stream stream )
- {
- FT_Error error;
- TT_Postscript* post = &face->postscript;
-
- static const FT_Frame_Field post_fields[] =
- {
-#undef FT_STRUCTURE
-#define FT_STRUCTURE TT_Postscript
-
- FT_FRAME_START( 32 ),
- FT_FRAME_LONG ( FormatType ),
- FT_FRAME_LONG ( italicAngle ),
- FT_FRAME_SHORT( underlinePosition ),
- FT_FRAME_SHORT( underlineThickness ),
- FT_FRAME_ULONG( isFixedPitch ),
- FT_FRAME_ULONG( minMemType42 ),
- FT_FRAME_ULONG( maxMemType42 ),
- FT_FRAME_ULONG( minMemType1 ),
- FT_FRAME_ULONG( maxMemType1 ),
- FT_FRAME_END
- };
-
-
- error = face->goto_table( face, TTAG_post, stream, 0 );
- if ( error )
- return error;
-
- if ( FT_STREAM_READ_FIELDS( post_fields, post ) )
- return error;
-
- if ( post->FormatType != 0x00030000L &&
- post->FormatType != 0x00025000L &&
- post->FormatType != 0x00020000L &&
- post->FormatType != 0x00010000L )
- return FT_THROW( Invalid_Post_Table_Format );
-
- /* we don't load the glyph names, we do that in another */
- /* module (ttpost). */
-
- FT_TRACE3(( "FormatType: 0x%lx\n", post->FormatType ));
- FT_TRACE3(( "isFixedPitch: %s\n", post->isFixedPitch
- ? " yes" : " no" ));
-
- return FT_Err_Ok;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * tt_face_load_pclt
- *
- * @Description:
- * Loads the PCL 5 Table.
- *
- * @Input:
- * face ::
- * A handle to the target face object.
- *
- * stream ::
- * A handle to the input stream.
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
- FT_LOCAL_DEF( FT_Error )
- tt_face_load_pclt( TT_Face face,
- FT_Stream stream )
- {
- static const FT_Frame_Field pclt_fields[] =
- {
-#undef FT_STRUCTURE
-#define FT_STRUCTURE TT_PCLT
-
- FT_FRAME_START( 54 ),
- FT_FRAME_ULONG ( Version ),
- FT_FRAME_ULONG ( FontNumber ),
- FT_FRAME_USHORT( Pitch ),
- FT_FRAME_USHORT( xHeight ),
- FT_FRAME_USHORT( Style ),
- FT_FRAME_USHORT( TypeFamily ),
- FT_FRAME_USHORT( CapHeight ),
- FT_FRAME_USHORT( SymbolSet ),
- FT_FRAME_BYTES ( TypeFace, 16 ),
- FT_FRAME_BYTES ( CharacterComplement, 8 ),
- FT_FRAME_BYTES ( FileName, 6 ),
- FT_FRAME_CHAR ( StrokeWeight ),
- FT_FRAME_CHAR ( WidthType ),
- FT_FRAME_BYTE ( SerifStyle ),
- FT_FRAME_BYTE ( Reserved ),
- FT_FRAME_END
- };
-
- FT_Error error;
- TT_PCLT* pclt = &face->pclt;
-
-
- /* optional table */
- error = face->goto_table( face, TTAG_PCLT, stream, 0 );
- if ( error )
- goto Exit;
-
- if ( FT_STREAM_READ_FIELDS( pclt_fields, pclt ) )
- goto Exit;
-
- Exit:
- return error;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * tt_face_load_gasp
- *
- * @Description:
- * Loads the `gasp' table into a face object.
- *
- * @Input:
- * face ::
- * A handle to the target face object.
- *
- * stream ::
- * The input stream.
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
- FT_LOCAL_DEF( FT_Error )
- tt_face_load_gasp( TT_Face face,
- FT_Stream stream )
- {
- FT_Error error;
- FT_Memory memory = stream->memory;
-
- FT_UShort j, num_ranges;
- TT_GaspRange gasp_ranges = NULL;
-
-
- /* the gasp table is optional */
- error = face->goto_table( face, TTAG_gasp, stream, 0 );
- if ( error )
- goto Exit;
-
- if ( FT_FRAME_ENTER( 4L ) )
- goto Exit;
-
- face->gasp.version = FT_GET_USHORT();
- num_ranges = FT_GET_USHORT();
-
- FT_FRAME_EXIT();
-
- /* only support versions 0 and 1 of the table */
- if ( face->gasp.version >= 2 )
- {
- face->gasp.numRanges = 0;
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- FT_TRACE3(( "numRanges: %hu\n", num_ranges ));
-
- if ( FT_QNEW_ARRAY( gasp_ranges, num_ranges ) ||
- FT_FRAME_ENTER( num_ranges * 4L ) )
- goto Exit;
-
- for ( j = 0; j < num_ranges; j++ )
- {
- gasp_ranges[j].maxPPEM = FT_GET_USHORT();
- gasp_ranges[j].gaspFlag = FT_GET_USHORT();
-
- FT_TRACE3(( "gaspRange %hu: rangeMaxPPEM %5hu, rangeGaspBehavior 0x%hx\n",
- j,
- gasp_ranges[j].maxPPEM,
- gasp_ranges[j].gaspFlag ));
- }
-
- face->gasp.gaspRanges = gasp_ranges;
- gasp_ranges = NULL;
- face->gasp.numRanges = num_ranges;
-
- FT_FRAME_EXIT();
-
- Exit:
- FT_FREE( gasp_ranges );
- return error;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/sfnt/ttload.h b/contrib/libs/freetype/src/sfnt/ttload.h
deleted file mode 100644
index 2b1d62d9bd..0000000000
--- a/contrib/libs/freetype/src/sfnt/ttload.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/****************************************************************************
- *
- * ttload.h
- *
- * Load the basic TrueType tables, i.e., tables that can be either in
- * TTF or OTF fonts (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef TTLOAD_H_
-#define TTLOAD_H_
-
-
-#include <freetype/internal/ftstream.h>
-#include <freetype/internal/tttypes.h>
-
-
-FT_BEGIN_HEADER
-
-
- FT_LOCAL( TT_Table )
- tt_face_lookup_table( TT_Face face,
- FT_ULong tag );
-
- FT_LOCAL( FT_Error )
- tt_face_goto_table( TT_Face face,
- FT_ULong tag,
- FT_Stream stream,
- FT_ULong* length );
-
-
- FT_LOCAL( FT_Error )
- tt_face_load_font_dir( TT_Face face,
- FT_Stream stream );
-
-
- FT_LOCAL( FT_Error )
- tt_face_load_any( TT_Face face,
- FT_ULong tag,
- FT_Long offset,
- FT_Byte* buffer,
- FT_ULong* length );
-
-
- FT_LOCAL( FT_Error )
- tt_face_load_head( TT_Face face,
- FT_Stream stream );
-
-
- FT_LOCAL( FT_Error )
- tt_face_load_cmap( TT_Face face,
- FT_Stream stream );
-
-
- FT_LOCAL( FT_Error )
- tt_face_load_maxp( TT_Face face,
- FT_Stream stream );
-
-
- FT_LOCAL( FT_Error )
- tt_face_load_name( TT_Face face,
- FT_Stream stream );
-
-
- FT_LOCAL( FT_Error )
- tt_face_load_os2( TT_Face face,
- FT_Stream stream );
-
-
- FT_LOCAL( FT_Error )
- tt_face_load_post( TT_Face face,
- FT_Stream stream );
-
-
- FT_LOCAL( FT_Error )
- tt_face_load_pclt( TT_Face face,
- FT_Stream stream );
-
- FT_LOCAL( void )
- tt_face_free_name( TT_Face face );
-
-
- FT_LOCAL( FT_Error )
- tt_face_load_gasp( TT_Face face,
- FT_Stream stream );
-
-#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
-
- FT_LOCAL( FT_Error )
- tt_face_load_bhed( TT_Face face,
- FT_Stream stream );
-
-#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
-
-
-FT_END_HEADER
-
-#endif /* TTLOAD_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/sfnt/ttmtx.c b/contrib/libs/freetype/src/sfnt/ttmtx.c
deleted file mode 100644
index 2788411856..0000000000
--- a/contrib/libs/freetype/src/sfnt/ttmtx.c
+++ /dev/null
@@ -1,338 +0,0 @@
-/****************************************************************************
- *
- * ttmtx.c
- *
- * Load the metrics tables common to TTF and OTF fonts (body).
- *
- * Copyright (C) 2006-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/tttags.h>
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
-#include <freetype/internal/services/svmetric.h>
-#endif
-
-#include "ttmtx.h"
-
-#include "sferrors.h"
-
-
- /* IMPORTANT: The TT_HoriHeader and TT_VertHeader structures should */
- /* be identical except for the names of their fields, */
- /* which are different. */
- /* */
- /* This ensures that `tt_face_load_hmtx' is able to read */
- /* both the horizontal and vertical headers. */
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT ttmtx
-
-
- /**************************************************************************
- *
- * @Function:
- * tt_face_load_hmtx
- *
- * @Description:
- * Load the `hmtx' or `vmtx' table into a face object.
- *
- * @Input:
- * face ::
- * A handle to the target face object.
- *
- * stream ::
- * The input stream.
- *
- * vertical ::
- * A boolean flag. If set, load `vmtx'.
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
- FT_LOCAL_DEF( FT_Error )
- tt_face_load_hmtx( TT_Face face,
- FT_Stream stream,
- FT_Bool vertical )
- {
- FT_Error error;
- FT_ULong tag, table_size;
- FT_ULong* ptable_offset;
- FT_ULong* ptable_size;
-
-
- if ( vertical )
- {
- tag = TTAG_vmtx;
- ptable_offset = &face->vert_metrics_offset;
- ptable_size = &face->vert_metrics_size;
- }
- else
- {
- tag = TTAG_hmtx;
- ptable_offset = &face->horz_metrics_offset;
- ptable_size = &face->horz_metrics_size;
- }
-
- error = face->goto_table( face, tag, stream, &table_size );
- if ( error )
- goto Fail;
-
- *ptable_size = table_size;
- *ptable_offset = FT_STREAM_POS();
-
- Fail:
- return error;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * tt_face_load_hhea
- *
- * @Description:
- * Load the `hhea' or 'vhea' table into a face object.
- *
- * @Input:
- * face ::
- * A handle to the target face object.
- *
- * stream ::
- * The input stream.
- *
- * vertical ::
- * A boolean flag. If set, load `vhea'.
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
- FT_LOCAL_DEF( FT_Error )
- tt_face_load_hhea( TT_Face face,
- FT_Stream stream,
- FT_Bool vertical )
- {
- FT_Error error;
- TT_HoriHeader* header;
-
- static const FT_Frame_Field metrics_header_fields[] =
- {
-#undef FT_STRUCTURE
-#define FT_STRUCTURE TT_HoriHeader
-
- FT_FRAME_START( 36 ),
- FT_FRAME_ULONG ( Version ),
- FT_FRAME_SHORT ( Ascender ),
- FT_FRAME_SHORT ( Descender ),
- FT_FRAME_SHORT ( Line_Gap ),
- FT_FRAME_USHORT( advance_Width_Max ),
- FT_FRAME_SHORT ( min_Left_Side_Bearing ),
- FT_FRAME_SHORT ( min_Right_Side_Bearing ),
- FT_FRAME_SHORT ( xMax_Extent ),
- FT_FRAME_SHORT ( caret_Slope_Rise ),
- FT_FRAME_SHORT ( caret_Slope_Run ),
- FT_FRAME_SHORT ( caret_Offset ),
- FT_FRAME_SHORT ( Reserved[0] ),
- FT_FRAME_SHORT ( Reserved[1] ),
- FT_FRAME_SHORT ( Reserved[2] ),
- FT_FRAME_SHORT ( Reserved[3] ),
- FT_FRAME_SHORT ( metric_Data_Format ),
- FT_FRAME_USHORT( number_Of_HMetrics ),
- FT_FRAME_END
- };
-
-
- if ( vertical )
- {
- void *v = &face->vertical;
-
-
- error = face->goto_table( face, TTAG_vhea, stream, 0 );
- if ( error )
- goto Fail;
-
- header = (TT_HoriHeader*)v;
- }
- else
- {
- error = face->goto_table( face, TTAG_hhea, stream, 0 );
- if ( error )
- goto Fail;
-
- header = &face->horizontal;
- }
-
- if ( FT_STREAM_READ_FIELDS( metrics_header_fields, header ) )
- goto Fail;
-
- FT_TRACE3(( "Ascender: %5d\n", header->Ascender ));
- FT_TRACE3(( "Descender: %5d\n", header->Descender ));
- FT_TRACE3(( "number_Of_Metrics: %5u\n", header->number_Of_HMetrics ));
-
- header->long_metrics = NULL;
- header->short_metrics = NULL;
-
- Fail:
- return error;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * tt_face_get_metrics
- *
- * @Description:
- * Return the horizontal or vertical metrics in font units for a
- * given glyph. The values are the left side bearing (top side
- * bearing for vertical metrics) and advance width (advance height
- * for vertical metrics).
- *
- * @Input:
- * face ::
- * A pointer to the TrueType face structure.
- *
- * vertical ::
- * If set to TRUE, get vertical metrics.
- *
- * gindex ::
- * The glyph index.
- *
- * @Output:
- * abearing ::
- * The bearing, either left side or top side.
- *
- * aadvance ::
- * The advance width or advance height, depending on
- * the `vertical' flag.
- */
- FT_LOCAL_DEF( void )
- tt_face_get_metrics( TT_Face face,
- FT_Bool vertical,
- FT_UInt gindex,
- FT_Short *abearing,
- FT_UShort *aadvance )
- {
- FT_Error error;
- FT_Stream stream = face->root.stream;
- TT_HoriHeader* header;
- FT_ULong table_pos, table_size, table_end;
- FT_UShort k;
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- FT_Service_MetricsVariations var =
- (FT_Service_MetricsVariations)face->tt_var;
-#endif
-
-
- if ( vertical )
- {
- void* v = &face->vertical;
-
-
- header = (TT_HoriHeader*)v;
- table_pos = face->vert_metrics_offset;
- table_size = face->vert_metrics_size;
- }
- else
- {
- header = &face->horizontal;
- table_pos = face->horz_metrics_offset;
- table_size = face->horz_metrics_size;
- }
-
- table_end = table_pos + table_size;
-
- k = header->number_Of_HMetrics;
-
- if ( k > 0 )
- {
- if ( gindex < (FT_UInt)k )
- {
- table_pos += 4 * gindex;
- if ( table_pos + 4 > table_end )
- goto NoData;
-
- if ( FT_STREAM_SEEK( table_pos ) ||
- FT_READ_USHORT( *aadvance ) ||
- FT_READ_SHORT( *abearing ) )
- goto NoData;
- }
- else
- {
- table_pos += 4 * ( k - 1 );
- if ( table_pos + 2 > table_end )
- goto NoData;
-
- if ( FT_STREAM_SEEK( table_pos ) ||
- FT_READ_USHORT( *aadvance ) )
- goto NoData;
-
- table_pos += 4 + 2 * ( gindex - k );
- if ( table_pos + 2 > table_end )
- *abearing = 0;
- else
- {
- if ( FT_STREAM_SEEK( table_pos ) )
- *abearing = 0;
- else
- (void)FT_READ_SHORT( *abearing );
- }
- }
- }
- else
- {
- NoData:
- *abearing = 0;
- *aadvance = 0;
- }
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- if ( var && face->blend )
- {
- FT_Face f = FT_FACE( face );
- FT_Int a = (FT_Int)*aadvance;
- FT_Int b = (FT_Int)*abearing;
-
-
- if ( vertical )
- {
- if ( var->vadvance_adjust )
- var->vadvance_adjust( f, gindex, &a );
- if ( var->tsb_adjust )
- var->tsb_adjust( f, gindex, &b );
- }
- else
- {
- if ( var->hadvance_adjust )
- var->hadvance_adjust( f, gindex, &a );
- if ( var->lsb_adjust )
- var->lsb_adjust( f, gindex, &b );
- }
-
- *aadvance = (FT_UShort)a;
- *abearing = (FT_Short)b;
- }
-#endif
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/sfnt/ttmtx.h b/contrib/libs/freetype/src/sfnt/ttmtx.h
deleted file mode 100644
index 34b3c0e18f..0000000000
--- a/contrib/libs/freetype/src/sfnt/ttmtx.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/****************************************************************************
- *
- * ttmtx.h
- *
- * Load the metrics tables common to TTF and OTF fonts (specification).
- *
- * Copyright (C) 2006-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef TTMTX_H_
-#define TTMTX_H_
-
-
-#include <freetype/internal/ftstream.h>
-#include <freetype/internal/tttypes.h>
-
-
-FT_BEGIN_HEADER
-
-
- FT_LOCAL( FT_Error )
- tt_face_load_hhea( TT_Face face,
- FT_Stream stream,
- FT_Bool vertical );
-
-
- FT_LOCAL( FT_Error )
- tt_face_load_hmtx( TT_Face face,
- FT_Stream stream,
- FT_Bool vertical );
-
-
- FT_LOCAL( void )
- tt_face_get_metrics( TT_Face face,
- FT_Bool vertical,
- FT_UInt gindex,
- FT_Short* abearing,
- FT_UShort* aadvance );
-
-FT_END_HEADER
-
-#endif /* TTMTX_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/sfnt/ttpost.c b/contrib/libs/freetype/src/sfnt/ttpost.c
deleted file mode 100644
index 5698a62c8d..0000000000
--- a/contrib/libs/freetype/src/sfnt/ttpost.c
+++ /dev/null
@@ -1,484 +0,0 @@
-/****************************************************************************
- *
- * ttpost.c
- *
- * PostScript name table processing for TrueType and OpenType fonts
- * (body).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
- /**************************************************************************
- *
- * The post table is not completely loaded by the core engine. This
- * file loads the missing PS glyph names and implements an API to access
- * them.
- *
- */
-
-
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/tttags.h>
-
-
-#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
-
-#include "ttpost.h"
-
-#include "sferrors.h"
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT ttpost
-
-
- /* If this configuration macro is defined, we rely on the `psnames' */
- /* module to grab the glyph names. */
-
-#ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
-
-
-#include <freetype/internal/services/svpscmap.h>
-
-#define MAC_NAME( x ) (FT_String*)psnames->macintosh_name( (FT_UInt)(x) )
-
-
-#else /* !FT_CONFIG_OPTION_POSTSCRIPT_NAMES */
-
-
- /* Otherwise, we ignore the `psnames' module, and provide our own */
- /* table of Mac names. Thus, it is possible to build a version of */
- /* FreeType without the Type 1 driver & psnames module. */
-
-#define MAC_NAME( x ) (FT_String*)tt_post_default_names[x]
-
- /* the 258 default Mac PS glyph names; see file `tools/glnames.py' */
-
- static const FT_String* const tt_post_default_names[258] =
- {
- /* 0 */
- ".notdef", ".null", "nonmarkingreturn", "space", "exclam",
- "quotedbl", "numbersign", "dollar", "percent", "ampersand",
- /* 10 */
- "quotesingle", "parenleft", "parenright", "asterisk", "plus",
- "comma", "hyphen", "period", "slash", "zero",
- /* 20 */
- "one", "two", "three", "four", "five",
- "six", "seven", "eight", "nine", "colon",
- /* 30 */
- "semicolon", "less", "equal", "greater", "question",
- "at", "A", "B", "C", "D",
- /* 40 */
- "E", "F", "G", "H", "I",
- "J", "K", "L", "M", "N",
- /* 50 */
- "O", "P", "Q", "R", "S",
- "T", "U", "V", "W", "X",
- /* 60 */
- "Y", "Z", "bracketleft", "backslash", "bracketright",
- "asciicircum", "underscore", "grave", "a", "b",
- /* 70 */
- "c", "d", "e", "f", "g",
- "h", "i", "j", "k", "l",
- /* 80 */
- "m", "n", "o", "p", "q",
- "r", "s", "t", "u", "v",
- /* 90 */
- "w", "x", "y", "z", "braceleft",
- "bar", "braceright", "asciitilde", "Adieresis", "Aring",
- /* 100 */
- "Ccedilla", "Eacute", "Ntilde", "Odieresis", "Udieresis",
- "aacute", "agrave", "acircumflex", "adieresis", "atilde",
- /* 110 */
- "aring", "ccedilla", "eacute", "egrave", "ecircumflex",
- "edieresis", "iacute", "igrave", "icircumflex", "idieresis",
- /* 120 */
- "ntilde", "oacute", "ograve", "ocircumflex", "odieresis",
- "otilde", "uacute", "ugrave", "ucircumflex", "udieresis",
- /* 130 */
- "dagger", "degree", "cent", "sterling", "section",
- "bullet", "paragraph", "germandbls", "registered", "copyright",
- /* 140 */
- "trademark", "acute", "dieresis", "notequal", "AE",
- "Oslash", "infinity", "plusminus", "lessequal", "greaterequal",
- /* 150 */
- "yen", "mu", "partialdiff", "summation", "product",
- "pi", "integral", "ordfeminine", "ordmasculine", "Omega",
- /* 160 */
- "ae", "oslash", "questiondown", "exclamdown", "logicalnot",
- "radical", "florin", "approxequal", "Delta", "guillemotleft",
- /* 170 */
- "guillemotright", "ellipsis", "nonbreakingspace", "Agrave", "Atilde",
- "Otilde", "OE", "oe", "endash", "emdash",
- /* 180 */
- "quotedblleft", "quotedblright", "quoteleft", "quoteright", "divide",
- "lozenge", "ydieresis", "Ydieresis", "fraction", "currency",
- /* 190 */
- "guilsinglleft", "guilsinglright", "fi", "fl", "daggerdbl",
- "periodcentered", "quotesinglbase", "quotedblbase", "perthousand", "Acircumflex",
- /* 200 */
- "Ecircumflex", "Aacute", "Edieresis", "Egrave", "Iacute",
- "Icircumflex", "Idieresis", "Igrave", "Oacute", "Ocircumflex",
- /* 210 */
- "apple", "Ograve", "Uacute", "Ucircumflex", "Ugrave",
- "dotlessi", "circumflex", "tilde", "macron", "breve",
- /* 220 */
- "dotaccent", "ring", "cedilla", "hungarumlaut", "ogonek",
- "caron", "Lslash", "lslash", "Scaron", "scaron",
- /* 230 */
- "Zcaron", "zcaron", "brokenbar", "Eth", "eth",
- "Yacute", "yacute", "Thorn", "thorn", "minus",
- /* 240 */
- "multiply", "onesuperior", "twosuperior", "threesuperior", "onehalf",
- "onequarter", "threequarters", "franc", "Gbreve", "gbreve",
- /* 250 */
- "Idotaccent", "Scedilla", "scedilla", "Cacute", "cacute",
- "Ccaron", "ccaron", "dcroat",
- };
-
-
-#endif /* !FT_CONFIG_OPTION_POSTSCRIPT_NAMES */
-
-
- static FT_Error
- load_format_20( TT_Post_Names names,
- FT_Stream stream,
- FT_UShort num_glyphs,
- FT_ULong post_len )
- {
- FT_Memory memory = stream->memory;
- FT_Error error;
-
- FT_UShort n;
- FT_UShort num_names = 0;
-
- FT_UShort* glyph_indices = NULL;
- FT_Byte** name_strings = NULL;
- FT_Byte* q;
-
-
- if ( (FT_ULong)num_glyphs * 2 > post_len )
- {
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- /* load the indices and note their maximum */
- if ( FT_QNEW_ARRAY( glyph_indices, num_glyphs ) ||
- FT_FRAME_ENTER( num_glyphs * 2 ) )
- goto Fail;
-
- q = (FT_Byte*)stream->cursor;
-
- for ( n = 0; n < num_glyphs; n++ )
- {
- FT_UShort idx = FT_NEXT_USHORT( q );
-
-
- if ( idx > num_names )
- num_names = idx;
-
- glyph_indices[n] = idx;
- }
-
- FT_FRAME_EXIT();
-
- /* compute number of names stored in the table */
- num_names = num_names > 257 ? num_names - 257 : 0;
-
- /* now load the name strings */
- if ( num_names )
- {
- FT_Byte* p;
- FT_Byte* p_end;
-
-
- post_len -= (FT_ULong)num_glyphs * 2;
-
- if ( FT_QALLOC( name_strings, num_names * sizeof ( FT_Byte* ) +
- post_len + 1 ) )
- goto Fail;
-
- p = (FT_Byte*)( name_strings + num_names );
- if ( FT_STREAM_READ( p, post_len ) )
- goto Fail;
-
- p_end = p + post_len;
-
- /* convert from Pascal- to C-strings and set pointers */
- for ( n = 0; p < p_end && n < num_names; n++ )
- {
- FT_UInt len = *p;
-
-
- /* names in the Adobe Glyph List are shorter than 40 characters */
- if ( len >= 40U )
- FT_TRACE4(( "load_format_20: unusual %u-char name found\n", len ));
-
- *p++ = 0;
- name_strings[n] = p;
- p += len;
- }
- *p_end = 0;
-
- /* deal with missing or insufficient string data */
- if ( n < num_names )
- {
- FT_TRACE4(( "load_format_20: %hu PostScript names are truncated\n",
- (FT_UShort)( num_names - n ) ));
-
- for ( ; n < num_names; n++ )
- name_strings[n] = p_end;
- }
- }
-
- /* all right, set table fields and exit successfully */
- names->num_glyphs = num_glyphs;
- names->num_names = num_names;
- names->glyph_indices = glyph_indices;
- names->glyph_names = name_strings;
-
- return FT_Err_Ok;
-
- Fail:
- FT_FREE( name_strings );
- FT_FREE( glyph_indices );
-
- Exit:
- return error;
- }
-
-
- static FT_Error
- load_format_25( TT_Post_Names names,
- FT_Stream stream,
- FT_UShort num_glyphs,
- FT_ULong post_len )
- {
- FT_Memory memory = stream->memory;
- FT_Error error;
-
- FT_UShort n;
- FT_UShort* glyph_indices = NULL;
- FT_Byte* q;
-
-
- /* check the number of glyphs, including the theoretical limit */
- if ( num_glyphs > post_len ||
- num_glyphs > 258 + 128 )
- {
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- /* load the indices and check their Mac range */
- if ( FT_QNEW_ARRAY( glyph_indices, num_glyphs ) ||
- FT_FRAME_ENTER( num_glyphs ) )
- goto Fail;
-
- q = (FT_Byte*)stream->cursor;
-
- for ( n = 0; n < num_glyphs; n++ )
- {
- FT_Int idx = n + FT_NEXT_CHAR( q );
-
-
- if ( idx < 0 || idx > 257 )
- idx = 0;
-
- glyph_indices[n] = (FT_UShort)idx;
- }
-
- FT_FRAME_EXIT();
-
- /* OK, set table fields and exit successfully */
- names->num_glyphs = num_glyphs;
- names->glyph_indices = glyph_indices;
-
- return FT_Err_Ok;
-
- Fail:
- FT_FREE( glyph_indices );
-
- Exit:
- return error;
- }
-
-
- static FT_Error
- load_post_names( TT_Face face )
- {
- FT_Error error = FT_Err_Ok;
- FT_Stream stream = face->root.stream;
- FT_Fixed format = face->postscript.FormatType;
- FT_ULong post_len;
- FT_UShort num_glyphs;
-
-
- /* seek to the beginning of the PS names table */
- error = face->goto_table( face, TTAG_post, stream, &post_len );
- if ( error )
- goto Exit;
-
- /* UNDOCUMENTED! The number of glyphs in this table can be smaller */
- /* than the value in the maxp table (cf. cyberbit.ttf). */
- if ( post_len < 34 ||
- FT_STREAM_SKIP( 32 ) ||
- FT_READ_USHORT( num_glyphs ) ||
- num_glyphs > face->max_profile.numGlyphs ||
- num_glyphs == 0 )
- goto Exit;
-
- /* now read postscript names data */
- if ( format == 0x00020000L )
- error = load_format_20( &face->postscript_names, stream,
- num_glyphs, post_len - 34 );
- else if ( format == 0x00025000L )
- error = load_format_25( &face->postscript_names, stream,
- num_glyphs, post_len - 34 );
-
- Exit:
- face->postscript_names.loaded = 1; /* even if failed */
- return error;
- }
-
-
- FT_LOCAL_DEF( void )
- tt_face_free_ps_names( TT_Face face )
- {
- FT_Memory memory = face->root.memory;
- TT_Post_Names names = &face->postscript_names;
-
-
- if ( names->num_glyphs )
- {
- FT_FREE( names->glyph_indices );
- names->num_glyphs = 0;
- }
-
- if ( names->num_names )
- {
- FT_FREE( names->glyph_names );
- names->num_names = 0;
- }
-
- names->loaded = 0;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * tt_face_get_ps_name
- *
- * @Description:
- * Get the PostScript glyph name of a glyph.
- *
- * @Input:
- * face ::
- * A handle to the parent face.
- *
- * idx ::
- * The glyph index.
- *
- * @InOut:
- * PSname ::
- * The address of a string pointer. Undefined in case of
- * error, otherwise it is a pointer to the glyph name.
- *
- * You must not modify the returned string!
- *
- * @Output:
- * FreeType error code. 0 means success.
- */
- FT_LOCAL_DEF( FT_Error )
- tt_face_get_ps_name( TT_Face face,
- FT_UInt idx,
- FT_String** PSname )
- {
- FT_Error error;
- FT_Fixed format;
-
-#ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
- FT_Service_PsCMaps psnames;
-#endif
-
-
- if ( !face )
- return FT_THROW( Invalid_Face_Handle );
-
- if ( idx >= (FT_UInt)face->max_profile.numGlyphs )
- return FT_THROW( Invalid_Glyph_Index );
-
-#ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
- psnames = (FT_Service_PsCMaps)face->psnames;
- if ( !psnames )
- return FT_THROW( Unimplemented_Feature );
-#endif
-
- /* `.notdef' by default */
- *PSname = MAC_NAME( 0 );
-
- format = face->postscript.FormatType;
-
- if ( format == 0x00020000L ||
- format == 0x00025000L )
- {
- TT_Post_Names names = &face->postscript_names;
-
-
- if ( !names->loaded )
- {
- error = load_post_names( face );
- if ( error )
- goto End;
- }
-
- if ( idx < (FT_UInt)names->num_glyphs )
- {
- FT_UShort name_index = names->glyph_indices[idx];
-
-
- if ( name_index < 258 )
- *PSname = MAC_NAME( name_index );
- else /* only for version 2.0 */
- *PSname = (FT_String*)names->glyph_names[name_index - 258];
- }
- }
-
- /* version 1.0 is only valid with 258 glyphs */
- else if ( format == 0x00010000L &&
- face->max_profile.numGlyphs == 258 )
- *PSname = MAC_NAME( idx );
-
- /* nothing to do for format == 0x00030000L */
-
- End:
- /* post format errors ignored */
- return FT_Err_Ok;
- }
-
-#else /* !TT_CONFIG_OPTION_POSTSCRIPT_NAMES */
-
- /* ANSI C doesn't like empty source files */
- typedef int tt_post_dummy_;
-
-#endif /* !TT_CONFIG_OPTION_POSTSCRIPT_NAMES */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/sfnt/ttpost.h b/contrib/libs/freetype/src/sfnt/ttpost.h
deleted file mode 100644
index 150db6c398..0000000000
--- a/contrib/libs/freetype/src/sfnt/ttpost.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/****************************************************************************
- *
- * ttpost.h
- *
- * PostScript name table processing for TrueType and OpenType fonts
- * (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef TTPOST_H_
-#define TTPOST_H_
-
-
-#include <ft2build.h>
-#include FT_CONFIG_CONFIG_H
-#include <freetype/internal/tttypes.h>
-
-
-FT_BEGIN_HEADER
-
-
- FT_LOCAL( FT_Error )
- tt_face_get_ps_name( TT_Face face,
- FT_UInt idx,
- FT_String** PSname );
-
- FT_LOCAL( void )
- tt_face_free_ps_names( TT_Face face );
-
-
-FT_END_HEADER
-
-#endif /* TTPOST_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/sfnt/ttsbit.c b/contrib/libs/freetype/src/sfnt/ttsbit.c
deleted file mode 100644
index cb3a8abf18..0000000000
--- a/contrib/libs/freetype/src/sfnt/ttsbit.c
+++ /dev/null
@@ -1,1685 +0,0 @@
-/****************************************************************************
- *
- * ttsbit.c
- *
- * TrueType and OpenType embedded bitmap support (body).
- *
- * Copyright (C) 2005-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * Copyright 2013 by Google, Inc.
- * Google Author(s): Behdad Esfahbod.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/tttags.h>
-#include <freetype/ftbitmap.h>
-
-
-#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
-
-#include "ttsbit.h"
-
-#include "sferrors.h"
-
-#include "ttmtx.h"
-#include "pngshim.h"
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT ttsbit
-
-
- FT_LOCAL_DEF( FT_Error )
- tt_face_load_sbit( TT_Face face,
- FT_Stream stream )
- {
- FT_Error error;
- FT_ULong table_size;
- FT_ULong table_start;
-
-
- face->sbit_table = NULL;
- face->sbit_table_size = 0;
- face->sbit_table_type = TT_SBIT_TABLE_TYPE_NONE;
- face->sbit_num_strikes = 0;
-
- error = face->goto_table( face, TTAG_CBLC, stream, &table_size );
- if ( !error )
- face->sbit_table_type = TT_SBIT_TABLE_TYPE_CBLC;
- else
- {
- error = face->goto_table( face, TTAG_EBLC, stream, &table_size );
- if ( error )
- error = face->goto_table( face, TTAG_bloc, stream, &table_size );
- if ( !error )
- face->sbit_table_type = TT_SBIT_TABLE_TYPE_EBLC;
- }
-
- if ( error )
- {
- error = face->goto_table( face, TTAG_sbix, stream, &table_size );
- if ( !error )
- face->sbit_table_type = TT_SBIT_TABLE_TYPE_SBIX;
- }
- if ( error )
- goto Exit;
-
- if ( table_size < 8 )
- {
- FT_ERROR(( "tt_face_load_sbit_strikes: table too short\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- table_start = FT_STREAM_POS();
-
- switch ( (FT_UInt)face->sbit_table_type )
- {
- case TT_SBIT_TABLE_TYPE_EBLC:
- case TT_SBIT_TABLE_TYPE_CBLC:
- {
- FT_Byte* p;
- FT_Fixed version;
- FT_ULong num_strikes;
- FT_UInt count;
-
-
- if ( FT_FRAME_EXTRACT( table_size, face->sbit_table ) )
- goto Exit;
-
- face->sbit_table_size = table_size;
-
- p = face->sbit_table;
-
- version = FT_NEXT_LONG( p );
- num_strikes = FT_NEXT_ULONG( p );
-
- /* there's at least one font (FZShuSong-Z01, version 3) */
- /* that uses the wrong byte order for the `version' field */
- if ( ( (FT_ULong)version & 0xFFFF0000UL ) != 0x00020000UL &&
- ( (FT_ULong)version & 0x0000FFFFUL ) != 0x00000200UL &&
- ( (FT_ULong)version & 0xFFFF0000UL ) != 0x00030000UL &&
- ( (FT_ULong)version & 0x0000FFFFUL ) != 0x00000300UL )
- {
- error = FT_THROW( Unknown_File_Format );
- goto Exit;
- }
-
- if ( num_strikes >= 0x10000UL )
- {
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- /*
- * Count the number of strikes available in the table. We are a bit
- * paranoid there and don't trust the data.
- */
- count = (FT_UInt)num_strikes;
- if ( 8 + 48UL * count > table_size )
- count = (FT_UInt)( ( table_size - 8 ) / 48 );
-
- face->sbit_num_strikes = count;
- }
- break;
-
- case TT_SBIT_TABLE_TYPE_SBIX:
- {
- FT_UShort version;
- FT_UShort flags;
- FT_ULong num_strikes;
- FT_UInt count;
-
-
- if ( FT_FRAME_ENTER( 8 ) )
- goto Exit;
-
- version = FT_GET_USHORT();
- flags = FT_GET_USHORT();
- num_strikes = FT_GET_ULONG();
-
- FT_FRAME_EXIT();
-
- if ( version < 1 )
- {
- error = FT_THROW( Unknown_File_Format );
- goto Exit;
- }
-
- /* Bit 0 must always be `1'. */
- /* Bit 1 controls the overlay of bitmaps with outlines. */
- /* All other bits should be zero. */
- if ( !( flags == 1 || flags == 3 ) ||
- num_strikes >= 0x10000UL )
- {
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- if ( flags == 3 )
- face->root.face_flags |= FT_FACE_FLAG_SBIX_OVERLAY;
-
- /*
- * Count the number of strikes available in the table. We are a bit
- * paranoid there and don't trust the data.
- */
- count = (FT_UInt)num_strikes;
- if ( 8 + 4UL * count > table_size )
- count = (FT_UInt)( ( table_size - 8 ) / 4 );
-
- if ( FT_STREAM_SEEK( FT_STREAM_POS() - 8 ) )
- goto Exit;
-
- face->sbit_table_size = 8 + count * 4;
- if ( FT_FRAME_EXTRACT( face->sbit_table_size, face->sbit_table ) )
- goto Exit;
-
- face->sbit_num_strikes = count;
- }
- break;
-
- default:
- /* we ignore unknown table formats */
- error = FT_THROW( Unknown_File_Format );
- break;
- }
-
- if ( !error )
- FT_TRACE3(( "tt_face_load_sbit_strikes: found %u strikes\n",
- face->sbit_num_strikes ));
-
- face->ebdt_start = 0;
- face->ebdt_size = 0;
-
- if ( face->sbit_table_type == TT_SBIT_TABLE_TYPE_SBIX )
- {
- /* the `sbix' table is self-contained; */
- /* it has no associated data table */
- face->ebdt_start = table_start;
- face->ebdt_size = table_size;
- }
- else if ( face->sbit_table_type != TT_SBIT_TABLE_TYPE_NONE )
- {
- FT_ULong ebdt_size;
-
-
- error = face->goto_table( face, TTAG_CBDT, stream, &ebdt_size );
- if ( error )
- error = face->goto_table( face, TTAG_EBDT, stream, &ebdt_size );
- if ( error )
- error = face->goto_table( face, TTAG_bdat, stream, &ebdt_size );
-
- if ( !error )
- {
- face->ebdt_start = FT_STREAM_POS();
- face->ebdt_size = ebdt_size;
- }
- }
-
- if ( !face->ebdt_size )
- {
- FT_TRACE2(( "tt_face_load_sbit_strikes:"
- " no embedded bitmap data table found;\n" ));
- FT_TRACE2(( " "
- " resetting number of strikes to zero\n" ));
- face->sbit_num_strikes = 0;
- }
-
- return FT_Err_Ok;
-
- Exit:
- if ( error )
- {
- if ( face->sbit_table )
- FT_FRAME_RELEASE( face->sbit_table );
- face->sbit_table_size = 0;
- face->sbit_table_type = TT_SBIT_TABLE_TYPE_NONE;
- }
-
- return error;
- }
-
-
- FT_LOCAL_DEF( void )
- tt_face_free_sbit( TT_Face face )
- {
- FT_Stream stream = face->root.stream;
-
-
- FT_FRAME_RELEASE( face->sbit_table );
- face->sbit_table_size = 0;
- face->sbit_table_type = TT_SBIT_TABLE_TYPE_NONE;
- face->sbit_num_strikes = 0;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- tt_face_set_sbit_strike( TT_Face face,
- FT_Size_Request req,
- FT_ULong* astrike_index )
- {
- return FT_Match_Size( (FT_Face)face, req, 0, astrike_index );
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- tt_face_load_strike_metrics( TT_Face face,
- FT_ULong strike_index,
- FT_Size_Metrics* metrics )
- {
- /* we have to test for the existence of `sbit_strike_map' */
- /* because the function gets also used at the very beginning */
- /* to construct `sbit_strike_map' itself */
- if ( face->sbit_strike_map )
- {
- if ( strike_index >= (FT_ULong)face->root.num_fixed_sizes )
- return FT_THROW( Invalid_Argument );
-
- /* map to real index */
- strike_index = face->sbit_strike_map[strike_index];
- }
- else
- {
- if ( strike_index >= (FT_ULong)face->sbit_num_strikes )
- return FT_THROW( Invalid_Argument );
- }
-
- switch ( (FT_UInt)face->sbit_table_type )
- {
- case TT_SBIT_TABLE_TYPE_EBLC:
- case TT_SBIT_TABLE_TYPE_CBLC:
- {
- FT_Byte* strike;
- FT_Char max_before_bl;
- FT_Char min_after_bl;
-
-
- strike = face->sbit_table + 8 + strike_index * 48;
-
- metrics->x_ppem = (FT_UShort)strike[44];
- metrics->y_ppem = (FT_UShort)strike[45];
-
- metrics->ascender = (FT_Char)strike[16] * 64; /* hori.ascender */
- metrics->descender = (FT_Char)strike[17] * 64; /* hori.descender */
-
- /* Due to fuzzy wording in the EBLC documentation, we find both */
- /* positive and negative values for `descender'. Additionally, */
- /* many fonts have both `ascender' and `descender' set to zero */
- /* (which is definitely wrong). MS Windows simply ignores all */
- /* those values... For these reasons we apply some heuristics */
- /* to get a reasonable, non-zero value for the height. */
-
- max_before_bl = (FT_Char)strike[24];
- min_after_bl = (FT_Char)strike[25];
-
- if ( metrics->descender > 0 )
- {
- /* compare sign of descender with `min_after_bl' */
- if ( min_after_bl < 0 )
- metrics->descender = -metrics->descender;
- }
-
- else if ( metrics->descender == 0 )
- {
- if ( metrics->ascender == 0 )
- {
- FT_TRACE2(( "tt_face_load_strike_metrics:"
- " sanitizing invalid ascender and descender\n" ));
- FT_TRACE2(( " "
- " values for strike %ld (%dppem, %dppem)\n",
- strike_index,
- metrics->x_ppem, metrics->y_ppem ));
-
- /* sanitize buggy ascender and descender values */
- if ( max_before_bl || min_after_bl )
- {
- metrics->ascender = max_before_bl * 64;
- metrics->descender = min_after_bl * 64;
- }
- else
- {
- metrics->ascender = metrics->y_ppem * 64;
- metrics->descender = 0;
- }
- }
- }
-
-#if 0
- else
- ; /* if we have a negative descender, simply use it */
-#endif
-
- metrics->height = metrics->ascender - metrics->descender;
- if ( metrics->height == 0 )
- {
- FT_TRACE2(( "tt_face_load_strike_metrics:"
- " sanitizing invalid height value\n" ));
- FT_TRACE2(( " "
- " for strike (%d, %d)\n",
- metrics->x_ppem, metrics->y_ppem ));
- metrics->height = metrics->y_ppem * 64;
- metrics->descender = metrics->ascender - metrics->height;
- }
-
- /* Is this correct? */
- metrics->max_advance = ( (FT_Char)strike[22] + /* min_origin_SB */
- strike[18] + /* max_width */
- (FT_Char)strike[23] /* min_advance_SB */
- ) * 64;
-
- /* set the scale values (in 16.16 units) so advances */
- /* from the hmtx and vmtx table are scaled correctly */
- metrics->x_scale = FT_DivFix( metrics->x_ppem * 64,
- face->header.Units_Per_EM );
- metrics->y_scale = FT_DivFix( metrics->y_ppem * 64,
- face->header.Units_Per_EM );
-
- return FT_Err_Ok;
- }
-
- case TT_SBIT_TABLE_TYPE_SBIX:
- {
- FT_Stream stream = face->root.stream;
- FT_UInt offset;
- FT_UShort ppem, resolution;
- TT_HoriHeader *hori;
- FT_Fixed scale;
-
- FT_Error error;
- FT_Byte* p;
-
-
- p = face->sbit_table + 8 + 4 * strike_index;
- offset = FT_NEXT_ULONG( p );
-
- if ( offset + 4 > face->ebdt_size )
- return FT_THROW( Invalid_File_Format );
-
- if ( FT_STREAM_SEEK( face->ebdt_start + offset ) ||
- FT_FRAME_ENTER( 4 ) )
- return error;
-
- ppem = FT_GET_USHORT();
- resolution = FT_GET_USHORT();
-
- FT_UNUSED( resolution ); /* What to do with this? */
-
- FT_FRAME_EXIT();
-
- metrics->x_ppem = ppem;
- metrics->y_ppem = ppem;
-
- scale = FT_DivFix( ppem * 64, face->header.Units_Per_EM );
- hori = &face->horizontal;
-
- metrics->ascender = FT_MulFix( hori->Ascender, scale );
- metrics->descender = FT_MulFix( hori->Descender, scale );
- metrics->height =
- FT_MulFix( hori->Ascender - hori->Descender + hori->Line_Gap,
- scale );
- metrics->max_advance = FT_MulFix( hori->advance_Width_Max, scale );
-
- /* set the scale values (in 16.16 units) so advances */
- /* from the hmtx and vmtx table are scaled correctly */
- metrics->x_scale = scale;
- metrics->y_scale = scale;
-
- return error;
- }
-
- default:
- return FT_THROW( Unknown_File_Format );
- }
- }
-
-
- typedef struct TT_SBitDecoderRec_
- {
- TT_Face face;
- FT_Stream stream;
- FT_Bitmap* bitmap;
- TT_SBit_Metrics metrics;
- FT_Bool metrics_loaded;
- FT_Bool bitmap_allocated;
- FT_Byte bit_depth;
-
- FT_ULong ebdt_start;
- FT_ULong ebdt_size;
-
- FT_ULong strike_index_array;
- FT_ULong strike_index_count;
- FT_Byte* eblc_base;
- FT_Byte* eblc_limit;
-
- } TT_SBitDecoderRec, *TT_SBitDecoder;
-
-
- static FT_Error
- tt_sbit_decoder_init( TT_SBitDecoder decoder,
- TT_Face face,
- FT_ULong strike_index,
- TT_SBit_MetricsRec* metrics )
- {
- FT_Error error = FT_ERR( Table_Missing );
- FT_Stream stream = face->root.stream;
-
-
- strike_index = face->sbit_strike_map[strike_index];
-
- if ( !face->ebdt_size )
- goto Exit;
- if ( FT_STREAM_SEEK( face->ebdt_start ) )
- goto Exit;
-
- decoder->face = face;
- decoder->stream = stream;
- decoder->bitmap = &face->root.glyph->bitmap;
- decoder->metrics = metrics;
-
- decoder->metrics_loaded = 0;
- decoder->bitmap_allocated = 0;
-
- decoder->ebdt_start = face->ebdt_start;
- decoder->ebdt_size = face->ebdt_size;
-
- decoder->eblc_base = face->sbit_table;
- decoder->eblc_limit = face->sbit_table + face->sbit_table_size;
-
- /* now find the strike corresponding to the index */
- {
- FT_Byte* p;
-
-
- if ( 8 + 48 * strike_index + 3 * 4 + 34 + 1 > face->sbit_table_size )
- {
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- p = decoder->eblc_base + 8 + 48 * strike_index;
-
- decoder->strike_index_array = FT_NEXT_ULONG( p );
- p += 4;
- decoder->strike_index_count = FT_NEXT_ULONG( p );
- p += 34;
- decoder->bit_depth = *p;
-
- /* decoder->strike_index_array + */
- /* 8 * decoder->strike_index_count > face->sbit_table_size ? */
- if ( decoder->strike_index_array > face->sbit_table_size ||
- decoder->strike_index_count >
- ( face->sbit_table_size - decoder->strike_index_array ) / 8 )
- error = FT_THROW( Invalid_File_Format );
- }
-
- Exit:
- return error;
- }
-
-
- static void
- tt_sbit_decoder_done( TT_SBitDecoder decoder )
- {
- FT_UNUSED( decoder );
- }
-
-
- static FT_Error
- tt_sbit_decoder_alloc_bitmap( TT_SBitDecoder decoder,
- FT_Bool metrics_only )
- {
- FT_Error error = FT_Err_Ok;
- FT_UInt width, height;
- FT_Bitmap* map = decoder->bitmap;
- FT_ULong size;
-
-
- if ( !decoder->metrics_loaded )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- width = decoder->metrics->width;
- height = decoder->metrics->height;
-
- map->width = width;
- map->rows = height;
-
- switch ( decoder->bit_depth )
- {
- case 1:
- map->pixel_mode = FT_PIXEL_MODE_MONO;
- map->pitch = (int)( ( map->width + 7 ) >> 3 );
- map->num_grays = 2;
- break;
-
- case 2:
- map->pixel_mode = FT_PIXEL_MODE_GRAY2;
- map->pitch = (int)( ( map->width + 3 ) >> 2 );
- map->num_grays = 4;
- break;
-
- case 4:
- map->pixel_mode = FT_PIXEL_MODE_GRAY4;
- map->pitch = (int)( ( map->width + 1 ) >> 1 );
- map->num_grays = 16;
- break;
-
- case 8:
- map->pixel_mode = FT_PIXEL_MODE_GRAY;
- map->pitch = (int)( map->width );
- map->num_grays = 256;
- break;
-
- case 32:
- map->pixel_mode = FT_PIXEL_MODE_BGRA;
- map->pitch = (int)( map->width * 4 );
- map->num_grays = 256;
- break;
-
- default:
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- size = map->rows * (FT_ULong)map->pitch;
-
- /* check that there is no empty image */
- if ( size == 0 )
- goto Exit; /* exit successfully! */
-
- if ( metrics_only )
- goto Exit; /* only metrics are requested */
-
- error = ft_glyphslot_alloc_bitmap( decoder->face->root.glyph, size );
- if ( error )
- goto Exit;
-
- decoder->bitmap_allocated = 1;
-
- Exit:
- return error;
- }
-
-
- static FT_Error
- tt_sbit_decoder_load_metrics( TT_SBitDecoder decoder,
- FT_Byte* *pp,
- FT_Byte* limit,
- FT_Bool big )
- {
- FT_Byte* p = *pp;
- TT_SBit_Metrics metrics = decoder->metrics;
-
-
- if ( p + 5 > limit )
- goto Fail;
-
- metrics->height = p[0];
- metrics->width = p[1];
- metrics->horiBearingX = (FT_Char)p[2];
- metrics->horiBearingY = (FT_Char)p[3];
- metrics->horiAdvance = p[4];
-
- p += 5;
- if ( big )
- {
- if ( p + 3 > limit )
- goto Fail;
-
- metrics->vertBearingX = (FT_Char)p[0];
- metrics->vertBearingY = (FT_Char)p[1];
- metrics->vertAdvance = p[2];
-
- p += 3;
- }
- else
- {
- /* avoid uninitialized data in case there is no vertical info -- */
- metrics->vertBearingX = 0;
- metrics->vertBearingY = 0;
- metrics->vertAdvance = 0;
- }
-
- decoder->metrics_loaded = 1;
- *pp = p;
- return FT_Err_Ok;
-
- Fail:
- FT_TRACE1(( "tt_sbit_decoder_load_metrics: broken table\n" ));
- return FT_THROW( Invalid_Argument );
- }
-
-
- /* forward declaration */
- static FT_Error
- tt_sbit_decoder_load_image( TT_SBitDecoder decoder,
- FT_UInt glyph_index,
- FT_Int x_pos,
- FT_Int y_pos,
- FT_UInt recurse_count,
- FT_Bool metrics_only );
-
- typedef FT_Error (*TT_SBitDecoder_LoadFunc)(
- TT_SBitDecoder decoder,
- FT_Byte* p,
- FT_Byte* plimit,
- FT_Int x_pos,
- FT_Int y_pos,
- FT_UInt recurse_count );
-
-
- static FT_Error
- tt_sbit_decoder_load_byte_aligned( TT_SBitDecoder decoder,
- FT_Byte* p,
- FT_Byte* limit,
- FT_Int x_pos,
- FT_Int y_pos,
- FT_UInt recurse_count )
- {
- FT_Error error = FT_Err_Ok;
- FT_Byte* line;
- FT_Int pitch, width, height, line_bits, h;
- FT_UInt bit_height, bit_width;
- FT_Bitmap* bitmap;
-
- FT_UNUSED( recurse_count );
-
-
- /* check that we can write the glyph into the bitmap */
- bitmap = decoder->bitmap;
- bit_width = bitmap->width;
- bit_height = bitmap->rows;
- pitch = bitmap->pitch;
- line = bitmap->buffer;
-
- if ( !line )
- goto Exit;
-
- width = decoder->metrics->width;
- height = decoder->metrics->height;
-
- line_bits = width * decoder->bit_depth;
-
- if ( x_pos < 0 || (FT_UInt)( x_pos + width ) > bit_width ||
- y_pos < 0 || (FT_UInt)( y_pos + height ) > bit_height )
- {
- FT_TRACE1(( "tt_sbit_decoder_load_byte_aligned:"
- " invalid bitmap dimensions\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- if ( p + ( ( line_bits + 7 ) >> 3 ) * height > limit )
- {
- FT_TRACE1(( "tt_sbit_decoder_load_byte_aligned: broken bitmap\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- /* now do the blit */
- line += y_pos * pitch + ( x_pos >> 3 );
- x_pos &= 7;
-
- if ( x_pos == 0 ) /* the easy one */
- {
- for ( h = height; h > 0; h--, line += pitch )
- {
- FT_Byte* pwrite = line;
- FT_Int w;
-
-
- for ( w = line_bits; w >= 8; w -= 8 )
- {
- pwrite[0] = (FT_Byte)( pwrite[0] | *p++ );
- pwrite += 1;
- }
-
- if ( w > 0 )
- pwrite[0] = (FT_Byte)( pwrite[0] | ( *p++ & ( 0xFF00U >> w ) ) );
- }
- }
- else /* x_pos > 0 */
- {
- for ( h = height; h > 0; h--, line += pitch )
- {
- FT_Byte* pwrite = line;
- FT_Int w;
- FT_UInt wval = 0;
-
-
- for ( w = line_bits; w >= 8; w -= 8 )
- {
- wval = (FT_UInt)( wval | *p++ );
- pwrite[0] = (FT_Byte)( pwrite[0] | ( wval >> x_pos ) );
- pwrite += 1;
- wval <<= 8;
- }
-
- if ( w > 0 )
- wval = (FT_UInt)( wval | ( *p++ & ( 0xFF00U >> w ) ) );
-
- /* all bits read and there are `x_pos + w' bits to be written */
-
- pwrite[0] = (FT_Byte)( pwrite[0] | ( wval >> x_pos ) );
-
- if ( x_pos + w > 8 )
- {
- pwrite++;
- wval <<= 8;
- pwrite[0] = (FT_Byte)( pwrite[0] | ( wval >> x_pos ) );
- }
- }
- }
-
- Exit:
- if ( !error )
- FT_TRACE3(( "tt_sbit_decoder_load_byte_aligned: loaded\n" ));
- return error;
- }
-
-
- /*
- * Load a bit-aligned bitmap (with pointer `p') into a line-aligned bitmap
- * (with pointer `pwrite'). In the example below, the width is 3 pixel,
- * and `x_pos' is 1 pixel.
- *
- * p p+1
- * | | |
- * | 7 6 5 4 3 2 1 0 | 7 6 5 4 3 2 1 0 |...
- * | | |
- * +-------+ +-------+ +-------+ ...
- * . . .
- * . . .
- * v . .
- * +-------+ . .
- * | | .
- * | 7 6 5 4 3 2 1 0 | .
- * | | .
- * pwrite . .
- * . .
- * v .
- * +-------+ .
- * | |
- * | 7 6 5 4 3 2 1 0 |
- * | |
- * pwrite+1 .
- * .
- * v
- * +-------+
- * | |
- * | 7 6 5 4 3 2 1 0 |
- * | |
- * pwrite+2
- *
- */
-
- static FT_Error
- tt_sbit_decoder_load_bit_aligned( TT_SBitDecoder decoder,
- FT_Byte* p,
- FT_Byte* limit,
- FT_Int x_pos,
- FT_Int y_pos,
- FT_UInt recurse_count )
- {
- FT_Error error = FT_Err_Ok;
- FT_Byte* line;
- FT_Int pitch, width, height, line_bits, h, nbits;
- FT_UInt bit_height, bit_width;
- FT_Bitmap* bitmap;
- FT_UShort rval;
-
- FT_UNUSED( recurse_count );
-
-
- /* check that we can write the glyph into the bitmap */
- bitmap = decoder->bitmap;
- bit_width = bitmap->width;
- bit_height = bitmap->rows;
- pitch = bitmap->pitch;
- line = bitmap->buffer;
-
- width = decoder->metrics->width;
- height = decoder->metrics->height;
-
- line_bits = width * decoder->bit_depth;
-
- if ( x_pos < 0 || (FT_UInt)( x_pos + width ) > bit_width ||
- y_pos < 0 || (FT_UInt)( y_pos + height ) > bit_height )
- {
- FT_TRACE1(( "tt_sbit_decoder_load_bit_aligned:"
- " invalid bitmap dimensions\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- if ( p + ( ( line_bits * height + 7 ) >> 3 ) > limit )
- {
- FT_TRACE1(( "tt_sbit_decoder_load_bit_aligned: broken bitmap\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- if ( !line_bits || !height )
- {
- /* nothing to do */
- goto Exit;
- }
-
- /* now do the blit */
-
- /* adjust `line' to point to the first byte of the bitmap */
- line += y_pos * pitch + ( x_pos >> 3 );
- x_pos &= 7;
-
- /* the higher byte of `rval' is used as a buffer */
- rval = 0;
- nbits = 0;
-
- for ( h = height; h > 0; h--, line += pitch )
- {
- FT_Byte* pwrite = line;
- FT_Int w = line_bits;
-
-
- /* handle initial byte (in target bitmap) specially if necessary */
- if ( x_pos )
- {
- w = ( line_bits < 8 - x_pos ) ? line_bits : 8 - x_pos;
-
- if ( h == height )
- {
- rval = *p++;
- nbits = x_pos;
- }
- else if ( nbits < w )
- {
- if ( p < limit )
- rval |= *p++;
- nbits += 8 - w;
- }
- else
- {
- rval >>= 8;
- nbits -= w;
- }
-
- *pwrite++ |= ( ( rval >> nbits ) & 0xFF ) &
- ( ~( 0xFFU << w ) << ( 8 - w - x_pos ) );
- rval <<= 8;
-
- w = line_bits - w;
- }
-
- /* handle medial bytes */
- for ( ; w >= 8; w -= 8 )
- {
- rval |= *p++;
- *pwrite++ |= ( rval >> nbits ) & 0xFF;
-
- rval <<= 8;
- }
-
- /* handle final byte if necessary */
- if ( w > 0 )
- {
- if ( nbits < w )
- {
- if ( p < limit )
- rval |= *p++;
- *pwrite |= ( ( rval >> nbits ) & 0xFF ) & ( 0xFF00U >> w );
- nbits += 8 - w;
-
- rval <<= 8;
- }
- else
- {
- *pwrite |= ( ( rval >> nbits ) & 0xFF ) & ( 0xFF00U >> w );
- nbits -= w;
- }
- }
- }
-
- Exit:
- if ( !error )
- FT_TRACE3(( "tt_sbit_decoder_load_bit_aligned: loaded\n" ));
- return error;
- }
-
-
- static FT_Error
- tt_sbit_decoder_load_compound( TT_SBitDecoder decoder,
- FT_Byte* p,
- FT_Byte* limit,
- FT_Int x_pos,
- FT_Int y_pos,
- FT_UInt recurse_count )
- {
- FT_Error error = FT_Err_Ok;
- FT_UInt num_components, nn;
-
- FT_Char horiBearingX = (FT_Char)decoder->metrics->horiBearingX;
- FT_Char horiBearingY = (FT_Char)decoder->metrics->horiBearingY;
- FT_Byte horiAdvance = (FT_Byte)decoder->metrics->horiAdvance;
- FT_Char vertBearingX = (FT_Char)decoder->metrics->vertBearingX;
- FT_Char vertBearingY = (FT_Char)decoder->metrics->vertBearingY;
- FT_Byte vertAdvance = (FT_Byte)decoder->metrics->vertAdvance;
-
-
- if ( p + 2 > limit )
- goto Fail;
-
- num_components = FT_NEXT_USHORT( p );
- if ( p + 4 * num_components > limit )
- {
- FT_TRACE1(( "tt_sbit_decoder_load_compound: broken table\n" ));
- goto Fail;
- }
-
- FT_TRACE3(( "tt_sbit_decoder_load_compound: loading %d component%s\n",
- num_components,
- num_components == 1 ? "" : "s" ));
-
- for ( nn = 0; nn < num_components; nn++ )
- {
- FT_UInt gindex = FT_NEXT_USHORT( p );
- FT_Char dx = FT_NEXT_CHAR( p );
- FT_Char dy = FT_NEXT_CHAR( p );
-
-
- /* NB: a recursive call */
- error = tt_sbit_decoder_load_image( decoder,
- gindex,
- x_pos + dx,
- y_pos + dy,
- recurse_count + 1,
- /* request full bitmap image */
- FALSE );
- if ( error )
- break;
- }
-
- FT_TRACE3(( "tt_sbit_decoder_load_compound: done\n" ));
-
- decoder->metrics->horiBearingX = horiBearingX;
- decoder->metrics->horiBearingY = horiBearingY;
- decoder->metrics->horiAdvance = horiAdvance;
- decoder->metrics->vertBearingX = vertBearingX;
- decoder->metrics->vertBearingY = vertBearingY;
- decoder->metrics->vertAdvance = vertAdvance;
- decoder->metrics->width = (FT_Byte)decoder->bitmap->width;
- decoder->metrics->height = (FT_Byte)decoder->bitmap->rows;
-
- Exit:
- return error;
-
- Fail:
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
-
-#ifdef FT_CONFIG_OPTION_USE_PNG
-
- static FT_Error
- tt_sbit_decoder_load_png( TT_SBitDecoder decoder,
- FT_Byte* p,
- FT_Byte* limit,
- FT_Int x_pos,
- FT_Int y_pos,
- FT_UInt recurse_count )
- {
- FT_Error error = FT_Err_Ok;
- FT_ULong png_len;
-
- FT_UNUSED( recurse_count );
-
-
- if ( limit - p < 4 )
- {
- FT_TRACE1(( "tt_sbit_decoder_load_png: broken bitmap\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- png_len = FT_NEXT_ULONG( p );
- if ( (FT_ULong)( limit - p ) < png_len )
- {
- FT_TRACE1(( "tt_sbit_decoder_load_png: broken bitmap\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- error = Load_SBit_Png( decoder->face->root.glyph,
- x_pos,
- y_pos,
- decoder->bit_depth,
- decoder->metrics,
- decoder->stream->memory,
- p,
- png_len,
- FALSE,
- FALSE );
-
- Exit:
- if ( !error )
- FT_TRACE3(( "tt_sbit_decoder_load_png: loaded\n" ));
- return error;
- }
-
-#endif /* FT_CONFIG_OPTION_USE_PNG */
-
-
- static FT_Error
- tt_sbit_decoder_load_bitmap( TT_SBitDecoder decoder,
- FT_UInt glyph_format,
- FT_ULong glyph_start,
- FT_ULong glyph_size,
- FT_Int x_pos,
- FT_Int y_pos,
- FT_UInt recurse_count,
- FT_Bool metrics_only )
- {
- FT_Error error;
- FT_Stream stream = decoder->stream;
- FT_Byte* p;
- FT_Byte* p_limit;
- FT_Byte* data;
-
-
- /* seek into the EBDT table now */
- if ( !glyph_size ||
- glyph_start + glyph_size > decoder->ebdt_size )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- if ( FT_STREAM_SEEK( decoder->ebdt_start + glyph_start ) ||
- FT_FRAME_EXTRACT( glyph_size, data ) )
- goto Exit;
-
- p = data;
- p_limit = p + glyph_size;
-
- /* read the data, depending on the glyph format */
- switch ( glyph_format )
- {
- case 1:
- case 2:
- case 8:
- case 17:
- error = tt_sbit_decoder_load_metrics( decoder, &p, p_limit, 0 );
- break;
-
- case 6:
- case 7:
- case 9:
- case 18:
- error = tt_sbit_decoder_load_metrics( decoder, &p, p_limit, 1 );
- break;
-
- default:
- error = FT_Err_Ok;
- }
-
- if ( error )
- goto Fail;
-
- {
- TT_SBitDecoder_LoadFunc loader;
-
-
- switch ( glyph_format )
- {
- case 1:
- case 6:
- loader = tt_sbit_decoder_load_byte_aligned;
- break;
-
- case 2:
- case 7:
- {
- /* Don't trust `glyph_format'. For example, Apple's main Korean */
- /* system font, `AppleMyungJo.ttf' (version 7.0d2e6), uses glyph */
- /* format 7, but the data is format 6. We check whether we have */
- /* an excessive number of bytes in the image: If it is equal to */
- /* the value for a byte-aligned glyph, use the other loading */
- /* routine. */
- /* */
- /* Note that for some (width,height) combinations, where the */
- /* width is not a multiple of 8, the sizes for bit- and */
- /* byte-aligned data are equal, for example (7,7) or (15,6). We */
- /* then prefer what `glyph_format' specifies. */
-
- FT_UInt width = decoder->metrics->width;
- FT_UInt height = decoder->metrics->height;
-
- FT_UInt bit_size = ( width * height + 7 ) >> 3;
- FT_UInt byte_size = height * ( ( width + 7 ) >> 3 );
-
-
- if ( bit_size < byte_size &&
- byte_size == (FT_UInt)( p_limit - p ) )
- loader = tt_sbit_decoder_load_byte_aligned;
- else
- loader = tt_sbit_decoder_load_bit_aligned;
- }
- break;
-
- case 5:
- loader = tt_sbit_decoder_load_bit_aligned;
- break;
-
- case 8:
- if ( p + 1 > p_limit )
- goto Fail;
-
- p += 1; /* skip padding */
- FALL_THROUGH;
-
- case 9:
- loader = tt_sbit_decoder_load_compound;
- break;
-
- case 17: /* small metrics, PNG image data */
- case 18: /* big metrics, PNG image data */
- case 19: /* metrics in EBLC, PNG image data */
-#ifdef FT_CONFIG_OPTION_USE_PNG
- loader = tt_sbit_decoder_load_png;
- break;
-#else
- error = FT_THROW( Unimplemented_Feature );
- goto Fail;
-#endif /* FT_CONFIG_OPTION_USE_PNG */
-
- default:
- error = FT_THROW( Invalid_Table );
- goto Fail;
- }
-
- if ( !decoder->bitmap_allocated )
- {
- error = tt_sbit_decoder_alloc_bitmap( decoder, metrics_only );
-
- if ( error )
- goto Fail;
- }
-
- if ( metrics_only )
- goto Fail; /* this is not an error */
-
- error = loader( decoder, p, p_limit, x_pos, y_pos, recurse_count );
- }
-
- Fail:
- FT_FRAME_RELEASE( data );
-
- Exit:
- return error;
- }
-
-
- static FT_Error
- tt_sbit_decoder_load_image( TT_SBitDecoder decoder,
- FT_UInt glyph_index,
- FT_Int x_pos,
- FT_Int y_pos,
- FT_UInt recurse_count,
- FT_Bool metrics_only )
- {
- FT_Byte* p = decoder->eblc_base + decoder->strike_index_array;
- FT_Byte* p_limit = decoder->eblc_limit;
- FT_ULong num_ranges = decoder->strike_index_count;
- FT_UInt start, end, index_format, image_format;
- FT_ULong image_start = 0, image_end = 0, image_offset;
-
-
- /* arbitrary recursion limit */
- if ( recurse_count > 100 )
- {
- FT_TRACE4(( "tt_sbit_decoder_load_image:"
- " recursion depth exceeded\n" ));
- goto Failure;
- }
-
-
- /* First, we find the correct strike range that applies to this */
- /* glyph index. */
- for ( ; num_ranges > 0; num_ranges-- )
- {
- start = FT_NEXT_USHORT( p );
- end = FT_NEXT_USHORT( p );
-
- if ( glyph_index >= start && glyph_index <= end )
- goto FoundRange;
-
- p += 4; /* ignore index offset */
- }
- goto NoBitmap;
-
- FoundRange:
- image_offset = FT_NEXT_ULONG( p );
-
- /* overflow check */
- p = decoder->eblc_base + decoder->strike_index_array;
- if ( image_offset > (FT_ULong)( p_limit - p ) )
- goto Failure;
-
- p += image_offset;
- if ( p + 8 > p_limit )
- goto NoBitmap;
-
- /* now find the glyph's location and extend within the ebdt table */
- index_format = FT_NEXT_USHORT( p );
- image_format = FT_NEXT_USHORT( p );
- image_offset = FT_NEXT_ULONG ( p );
-
- switch ( index_format )
- {
- case 1: /* 4-byte offsets relative to `image_offset' */
- p += 4 * ( glyph_index - start );
- if ( p + 8 > p_limit )
- goto NoBitmap;
-
- image_start = FT_NEXT_ULONG( p );
- image_end = FT_NEXT_ULONG( p );
-
- if ( image_start == image_end ) /* missing glyph */
- goto NoBitmap;
- break;
-
- case 2: /* big metrics, constant image size */
- {
- FT_ULong image_size;
-
-
- if ( p + 12 > p_limit )
- goto NoBitmap;
-
- image_size = FT_NEXT_ULONG( p );
-
- if ( tt_sbit_decoder_load_metrics( decoder, &p, p_limit, 1 ) )
- goto NoBitmap;
-
- image_start = image_size * ( glyph_index - start );
- image_end = image_start + image_size;
- }
- break;
-
- case 3: /* 2-byte offsets relative to 'image_offset' */
- p += 2 * ( glyph_index - start );
- if ( p + 4 > p_limit )
- goto NoBitmap;
-
- image_start = FT_NEXT_USHORT( p );
- image_end = FT_NEXT_USHORT( p );
-
- if ( image_start == image_end ) /* missing glyph */
- goto NoBitmap;
- break;
-
- case 4: /* sparse glyph array with (glyph,offset) pairs */
- {
- FT_ULong mm, num_glyphs;
-
-
- if ( p + 4 > p_limit )
- goto NoBitmap;
-
- num_glyphs = FT_NEXT_ULONG( p );
-
- /* overflow check for p + ( num_glyphs + 1 ) * 4 */
- if ( p + 4 > p_limit ||
- num_glyphs > (FT_ULong)( ( ( p_limit - p ) >> 2 ) - 1 ) )
- goto NoBitmap;
-
- for ( mm = 0; mm < num_glyphs; mm++ )
- {
- FT_UInt gindex = FT_NEXT_USHORT( p );
-
-
- if ( gindex == glyph_index )
- {
- image_start = FT_NEXT_USHORT( p );
- p += 2;
- image_end = FT_PEEK_USHORT( p );
- break;
- }
- p += 2;
- }
-
- if ( mm >= num_glyphs )
- goto NoBitmap;
- }
- break;
-
- case 5: /* constant metrics with sparse glyph codes */
- case 19:
- {
- FT_ULong image_size, mm, num_glyphs;
-
-
- if ( p + 16 > p_limit )
- goto NoBitmap;
-
- image_size = FT_NEXT_ULONG( p );
-
- if ( tt_sbit_decoder_load_metrics( decoder, &p, p_limit, 1 ) )
- goto NoBitmap;
-
- num_glyphs = FT_NEXT_ULONG( p );
-
- /* overflow check for p + 2 * num_glyphs */
- if ( num_glyphs > (FT_ULong)( ( p_limit - p ) >> 1 ) )
- goto NoBitmap;
-
- for ( mm = 0; mm < num_glyphs; mm++ )
- {
- FT_UInt gindex = FT_NEXT_USHORT( p );
-
-
- if ( gindex == glyph_index )
- break;
- }
-
- if ( mm >= num_glyphs )
- goto NoBitmap;
-
- image_start = image_size * mm;
- image_end = image_start + image_size;
- }
- break;
-
- default:
- goto NoBitmap;
- }
-
- if ( image_start > image_end )
- goto NoBitmap;
-
- image_end -= image_start;
- image_start = image_offset + image_start;
-
- FT_TRACE3(( "tt_sbit_decoder_load_image:"
- " found sbit (format %d) for glyph index %d\n",
- image_format, glyph_index ));
-
- return tt_sbit_decoder_load_bitmap( decoder,
- image_format,
- image_start,
- image_end,
- x_pos,
- y_pos,
- recurse_count,
- metrics_only );
-
- Failure:
- return FT_THROW( Invalid_Table );
-
- NoBitmap:
- if ( recurse_count )
- {
- FT_TRACE4(( "tt_sbit_decoder_load_image:"
- " missing subglyph sbit with glyph index %d\n",
- glyph_index ));
- return FT_THROW( Invalid_Composite );
- }
-
- FT_TRACE4(( "tt_sbit_decoder_load_image:"
- " no sbit found for glyph index %d\n", glyph_index ));
- return FT_THROW( Missing_Bitmap );
- }
-
-
- static FT_Error
- tt_face_load_sbix_image( TT_Face face,
- FT_ULong strike_index,
- FT_UInt glyph_index,
- FT_Stream stream,
- FT_Bitmap *map,
- TT_SBit_MetricsRec *metrics,
- FT_Bool metrics_only )
- {
- FT_UInt strike_offset, glyph_start, glyph_end;
- FT_Int originOffsetX, originOffsetY;
- FT_Tag graphicType;
- FT_Int recurse_depth = 0;
-
- FT_Error error;
- FT_Byte* p;
-
- FT_UNUSED( map );
-#ifndef FT_CONFIG_OPTION_USE_PNG
- FT_UNUSED( metrics_only );
-#endif
-
-
- strike_index = face->sbit_strike_map[strike_index];
-
- metrics->width = 0;
- metrics->height = 0;
-
- p = face->sbit_table + 8 + 4 * strike_index;
- strike_offset = FT_NEXT_ULONG( p );
-
- retry:
- if ( glyph_index > (FT_UInt)face->root.num_glyphs )
- return FT_THROW( Invalid_Argument );
-
- if ( strike_offset >= face->ebdt_size ||
- face->ebdt_size - strike_offset < 4 + glyph_index * 4 + 8 )
- return FT_THROW( Invalid_File_Format );
-
- if ( FT_STREAM_SEEK( face->ebdt_start +
- strike_offset + 4 +
- glyph_index * 4 ) ||
- FT_FRAME_ENTER( 8 ) )
- return error;
-
- glyph_start = FT_GET_ULONG();
- glyph_end = FT_GET_ULONG();
-
- FT_FRAME_EXIT();
-
- if ( glyph_start == glyph_end )
- return FT_THROW( Missing_Bitmap );
- if ( glyph_start > glyph_end ||
- glyph_end - glyph_start < 8 ||
- face->ebdt_size - strike_offset < glyph_end )
- return FT_THROW( Invalid_File_Format );
-
- if ( FT_STREAM_SEEK( face->ebdt_start + strike_offset + glyph_start ) ||
- FT_FRAME_ENTER( glyph_end - glyph_start ) )
- return error;
-
- originOffsetX = FT_GET_SHORT();
- originOffsetY = FT_GET_SHORT();
-
- graphicType = FT_GET_TAG4();
-
- switch ( graphicType )
- {
- case FT_MAKE_TAG( 'd', 'u', 'p', 'e' ):
- if ( recurse_depth < 4 )
- {
- glyph_index = FT_GET_USHORT();
- FT_FRAME_EXIT();
- recurse_depth++;
- goto retry;
- }
- error = FT_THROW( Invalid_File_Format );
- break;
-
- case FT_MAKE_TAG( 'p', 'n', 'g', ' ' ):
-#ifdef FT_CONFIG_OPTION_USE_PNG
- error = Load_SBit_Png( face->root.glyph,
- 0,
- 0,
- 32,
- metrics,
- stream->memory,
- stream->cursor,
- glyph_end - glyph_start - 8,
- TRUE,
- metrics_only );
-#else
- error = FT_THROW( Unimplemented_Feature );
-#endif
- break;
-
- case FT_MAKE_TAG( 'j', 'p', 'g', ' ' ):
- case FT_MAKE_TAG( 't', 'i', 'f', 'f' ):
- case FT_MAKE_TAG( 'r', 'g', 'b', 'l' ): /* used on iOS 7.1 */
- error = FT_THROW( Unknown_File_Format );
- break;
-
- default:
- error = FT_THROW( Unimplemented_Feature );
- break;
- }
-
- FT_FRAME_EXIT();
-
- if ( !error )
- {
- FT_Short abearing; /* not used here */
- FT_UShort aadvance;
-
-
- tt_face_get_metrics( face, FALSE, glyph_index, &abearing, &aadvance );
-
- metrics->horiBearingX = (FT_Short)originOffsetX;
- metrics->vertBearingX = (FT_Short)originOffsetX;
-
- metrics->horiBearingY = (FT_Short)( originOffsetY + metrics->height );
- metrics->vertBearingY = (FT_Short)originOffsetY;
-
- metrics->horiAdvance = (FT_UShort)( aadvance *
- face->root.size->metrics.x_ppem /
- face->header.Units_Per_EM );
-
- if ( face->vertical_info )
- tt_face_get_metrics( face, TRUE, glyph_index, &abearing, &aadvance );
- else if ( face->os2.version != 0xFFFFU )
- aadvance = (FT_UShort)FT_ABS( face->os2.sTypoAscender -
- face->os2.sTypoDescender );
- else
- aadvance = (FT_UShort)FT_ABS( face->horizontal.Ascender -
- face->horizontal.Descender );
-
- metrics->vertAdvance = (FT_UShort)( aadvance *
- face->root.size->metrics.x_ppem /
- face->header.Units_Per_EM );
- }
-
- return error;
- }
-
- FT_LOCAL_DEF( FT_Error )
- tt_face_load_sbit_image( TT_Face face,
- FT_ULong strike_index,
- FT_UInt glyph_index,
- FT_UInt load_flags,
- FT_Stream stream,
- FT_Bitmap *map,
- TT_SBit_MetricsRec *metrics )
- {
- FT_Error error = FT_Err_Ok;
-
-
- switch ( (FT_UInt)face->sbit_table_type )
- {
- case TT_SBIT_TABLE_TYPE_EBLC:
- case TT_SBIT_TABLE_TYPE_CBLC:
- {
- TT_SBitDecoderRec decoder[1];
-
-
- error = tt_sbit_decoder_init( decoder, face, strike_index, metrics );
- if ( !error )
- {
- error = tt_sbit_decoder_load_image(
- decoder,
- glyph_index,
- 0,
- 0,
- 0,
- ( load_flags & FT_LOAD_BITMAP_METRICS_ONLY ) != 0 );
- tt_sbit_decoder_done( decoder );
- }
- }
- break;
-
- case TT_SBIT_TABLE_TYPE_SBIX:
- error = tt_face_load_sbix_image(
- face,
- strike_index,
- glyph_index,
- stream,
- map,
- metrics,
- ( load_flags & FT_LOAD_BITMAP_METRICS_ONLY ) != 0 );
- break;
-
- default:
- error = FT_THROW( Unknown_File_Format );
- break;
- }
-
- /* Flatten color bitmaps if color was not requested. */
- if ( !error &&
- !( load_flags & FT_LOAD_COLOR ) &&
- !( load_flags & FT_LOAD_BITMAP_METRICS_ONLY ) &&
- map->pixel_mode == FT_PIXEL_MODE_BGRA )
- {
- FT_Bitmap new_map;
- FT_Library library = face->root.glyph->library;
-
-
- FT_Bitmap_Init( &new_map );
-
- /* Convert to 8bit grayscale. */
- error = FT_Bitmap_Convert( library, map, &new_map, 1 );
- if ( error )
- FT_Bitmap_Done( library, &new_map );
- else
- {
- map->pixel_mode = new_map.pixel_mode;
- map->pitch = new_map.pitch;
- map->num_grays = new_map.num_grays;
-
- ft_glyphslot_set_bitmap( face->root.glyph, new_map.buffer );
- face->root.glyph->internal->flags |= FT_GLYPH_OWN_BITMAP;
- }
- }
-
- return error;
- }
-
-#else /* !TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
-
- /* ANSI C doesn't like empty source files */
- typedef int tt_sbit_dummy_;
-
-#endif /* !TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/sfnt/ttsbit.h b/contrib/libs/freetype/src/sfnt/ttsbit.h
deleted file mode 100644
index 96f80a5842..0000000000
--- a/contrib/libs/freetype/src/sfnt/ttsbit.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/****************************************************************************
- *
- * ttsbit.h
- *
- * TrueType and OpenType embedded bitmap support (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef TTSBIT_H_
-#define TTSBIT_H_
-
-
-#include "ttload.h"
-
-
-FT_BEGIN_HEADER
-
-
- FT_LOCAL( FT_Error )
- tt_face_load_sbit( TT_Face face,
- FT_Stream stream );
-
- FT_LOCAL( void )
- tt_face_free_sbit( TT_Face face );
-
-
- FT_LOCAL( FT_Error )
- tt_face_set_sbit_strike( TT_Face face,
- FT_Size_Request req,
- FT_ULong* astrike_index );
-
- FT_LOCAL( FT_Error )
- tt_face_load_strike_metrics( TT_Face face,
- FT_ULong strike_index,
- FT_Size_Metrics* metrics );
-
- FT_LOCAL( FT_Error )
- tt_face_load_sbit_image( TT_Face face,
- FT_ULong strike_index,
- FT_UInt glyph_index,
- FT_UInt load_flags,
- FT_Stream stream,
- FT_Bitmap *map,
- TT_SBit_MetricsRec *metrics );
-
-
-FT_END_HEADER
-
-#endif /* TTSBIT_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/sfnt/ttsvg.c b/contrib/libs/freetype/src/sfnt/ttsvg.c
deleted file mode 100644
index 298afd8b55..0000000000
--- a/contrib/libs/freetype/src/sfnt/ttsvg.c
+++ /dev/null
@@ -1,413 +0,0 @@
-/****************************************************************************
- *
- * ttsvg.c
- *
- * OpenType SVG Color (specification).
- *
- * Copyright (C) 2022-2024 by
- * David Turner, Robert Wilhelm, Werner Lemberg, and Moazin Khatti.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /**************************************************************************
- *
- * 'SVG' table specification:
- *
- * https://docs.microsoft.com/en-us/typography/opentype/spec/svg
- *
- */
-
-#include <ft2build.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/ftdebug.h>
-#include <freetype/tttags.h>
-#include <freetype/ftgzip.h>
-#include <freetype/otsvg.h>
-
-
-#ifdef FT_CONFIG_OPTION_SVG
-
-#include "ttsvg.h"
-
-
- /* NOTE: These table sizes are given by the specification. */
-#define SVG_TABLE_HEADER_SIZE (10U)
-#define SVG_DOCUMENT_RECORD_SIZE (12U)
-#define SVG_DOCUMENT_LIST_MINIMUM_SIZE (2U + SVG_DOCUMENT_RECORD_SIZE)
-#define SVG_MINIMUM_SIZE (SVG_TABLE_HEADER_SIZE + \
- SVG_DOCUMENT_LIST_MINIMUM_SIZE)
-
-
- typedef struct Svg_
- {
- FT_UShort version; /* table version (starting at 0) */
- FT_UShort num_entries; /* number of SVG document records */
-
- FT_Byte* svg_doc_list; /* pointer to the start of SVG Document List */
-
- void* table; /* memory that backs up SVG */
- FT_ULong table_size;
-
- } Svg;
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, usued to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT ttsvg
-
-
- FT_LOCAL_DEF( FT_Error )
- tt_face_load_svg( TT_Face face,
- FT_Stream stream )
- {
- FT_Error error;
- FT_Memory memory = face->root.memory;
-
- FT_ULong table_size;
- FT_Byte* table = NULL;
- FT_Byte* p = NULL;
- Svg* svg = NULL;
- FT_ULong offsetToSVGDocumentList;
-
-
- error = face->goto_table( face, TTAG_SVG, stream, &table_size );
- if ( error )
- goto NoSVG;
-
- if ( table_size < SVG_MINIMUM_SIZE )
- goto InvalidTable;
-
- if ( FT_FRAME_EXTRACT( table_size, table ) )
- goto NoSVG;
-
- /* Allocate memory for the SVG object */
- if ( FT_NEW( svg ) )
- goto NoSVG;
-
- p = table;
- svg->version = FT_NEXT_USHORT( p );
- offsetToSVGDocumentList = FT_NEXT_ULONG( p );
-
- if ( offsetToSVGDocumentList < SVG_TABLE_HEADER_SIZE ||
- offsetToSVGDocumentList > table_size -
- SVG_DOCUMENT_LIST_MINIMUM_SIZE )
- goto InvalidTable;
-
- svg->svg_doc_list = (FT_Byte*)( table + offsetToSVGDocumentList );
-
- p = svg->svg_doc_list;
- svg->num_entries = FT_NEXT_USHORT( p );
-
- FT_TRACE3(( "version: %d\n", svg->version ));
- FT_TRACE3(( "number of entries: %d\n", svg->num_entries ));
-
- if ( offsetToSVGDocumentList + 2U +
- svg->num_entries * SVG_DOCUMENT_RECORD_SIZE > table_size )
- goto InvalidTable;
-
- svg->table = table;
- svg->table_size = table_size;
-
- face->svg = svg;
- face->root.face_flags |= FT_FACE_FLAG_SVG;
-
- return FT_Err_Ok;
-
- InvalidTable:
- error = FT_THROW( Invalid_Table );
-
- NoSVG:
- FT_FRAME_RELEASE( table );
- FT_FREE( svg );
- face->svg = NULL;
-
- return error;
- }
-
-
- FT_LOCAL_DEF( void )
- tt_face_free_svg( TT_Face face )
- {
- FT_Memory memory = face->root.memory;
- FT_Stream stream = face->root.stream;
-
- Svg* svg = (Svg*)face->svg;
-
-
- if ( svg )
- {
- FT_FRAME_RELEASE( svg->table );
- FT_FREE( svg );
- }
- }
-
-
- typedef struct Svg_doc_
- {
- FT_UShort start_glyph_id;
- FT_UShort end_glyph_id;
-
- FT_ULong offset;
- FT_ULong length;
-
- } Svg_doc;
-
-
- static Svg_doc
- extract_svg_doc( FT_Byte* stream )
- {
- Svg_doc doc;
-
-
- doc.start_glyph_id = FT_NEXT_USHORT( stream );
- doc.end_glyph_id = FT_NEXT_USHORT( stream );
-
- doc.offset = FT_NEXT_ULONG( stream );
- doc.length = FT_NEXT_ULONG( stream );
-
- return doc;
- }
-
-
- static FT_Int
- compare_svg_doc( Svg_doc doc,
- FT_UInt glyph_index )
- {
- if ( glyph_index < doc.start_glyph_id )
- return -1;
- else if ( glyph_index > doc.end_glyph_id )
- return 1;
- else
- return 0;
- }
-
-
- static FT_Error
- find_doc( FT_Byte* document_records,
- FT_UShort num_entries,
- FT_UInt glyph_index,
- FT_ULong *doc_offset,
- FT_ULong *doc_length,
- FT_UShort *start_glyph,
- FT_UShort *end_glyph )
- {
- FT_Error error;
-
- Svg_doc start_doc;
- Svg_doc mid_doc = { 0, 0, 0, 0 }; /* pacify compiler */
- Svg_doc end_doc;
-
- FT_Bool found = FALSE;
- FT_UInt i = 0;
-
- FT_UInt start_index = 0;
- FT_UInt end_index = num_entries - 1;
- FT_Int comp_res;
-
-
- /* search algorithm */
- if ( num_entries == 0 )
- {
- error = FT_THROW( Invalid_Table );
- return error;
- }
-
- start_doc = extract_svg_doc( document_records + start_index * 12 );
- end_doc = extract_svg_doc( document_records + end_index * 12 );
-
- if ( ( compare_svg_doc( start_doc, glyph_index ) == -1 ) ||
- ( compare_svg_doc( end_doc, glyph_index ) == 1 ) )
- {
- error = FT_THROW( Invalid_Glyph_Index );
- return error;
- }
-
- while ( start_index <= end_index )
- {
- i = ( start_index + end_index ) / 2;
- mid_doc = extract_svg_doc( document_records + i * 12 );
- comp_res = compare_svg_doc( mid_doc, glyph_index );
-
- if ( comp_res == 1 )
- {
- start_index = i + 1;
- start_doc = extract_svg_doc( document_records + start_index * 4 );
- }
- else if ( comp_res == -1 )
- {
- end_index = i - 1;
- end_doc = extract_svg_doc( document_records + end_index * 4 );
- }
- else
- {
- found = TRUE;
- break;
- }
- }
- /* search algorithm end */
-
- if ( found != TRUE )
- {
- FT_TRACE5(( "SVG glyph not found\n" ));
- error = FT_THROW( Invalid_Glyph_Index );
- }
- else
- {
- *doc_offset = mid_doc.offset;
- *doc_length = mid_doc.length;
-
- *start_glyph = mid_doc.start_glyph_id;
- *end_glyph = mid_doc.end_glyph_id;
-
- error = FT_Err_Ok;
- }
-
- return error;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- tt_face_load_svg_doc( FT_GlyphSlot glyph,
- FT_UInt glyph_index )
- {
- FT_Error error = FT_Err_Ok;
- TT_Face face = (TT_Face)glyph->face;
- FT_Memory memory = face->root.memory;
- Svg* svg = (Svg*)face->svg;
-
- FT_Byte* doc_list;
- FT_ULong doc_limit;
-
- FT_Byte* doc;
- FT_ULong doc_offset;
- FT_ULong doc_length;
- FT_UShort doc_start_glyph_id;
- FT_UShort doc_end_glyph_id;
-
- FT_SVG_Document svg_document = (FT_SVG_Document)glyph->other;
-
-
- FT_ASSERT( !( svg == NULL ) );
-
- doc_list = svg->svg_doc_list;
-
- error = find_doc( doc_list + 2, svg->num_entries, glyph_index,
- &doc_offset, &doc_length,
- &doc_start_glyph_id, &doc_end_glyph_id );
- if ( error != FT_Err_Ok )
- goto Exit;
-
- doc_limit = svg->table_size -
- (FT_ULong)( doc_list - (FT_Byte*)svg->table );
- if ( doc_offset > doc_limit ||
- doc_length > doc_limit - doc_offset )
- {
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- doc = doc_list + doc_offset;
-
- if ( doc_length > 6 &&
- doc[0] == 0x1F &&
- doc[1] == 0x8B &&
- doc[2] == 0x08 )
- {
-#ifdef FT_CONFIG_OPTION_USE_ZLIB
-
- FT_ULong uncomp_size;
- FT_Byte* uncomp_buffer = NULL;
-
-
- /*
- * Get the size of the original document. This helps in allotting the
- * buffer to accommodate the uncompressed version. The last 4 bytes
- * of the compressed document are equal to the original size modulo
- * 2^32. Since the size of SVG documents is less than 2^32 bytes we
- * can use this accurately. The four bytes are stored in
- * little-endian format.
- */
- FT_TRACE4(( "SVG document is GZIP compressed\n" ));
- uncomp_size = (FT_ULong)doc[doc_length - 1] << 24 |
- (FT_ULong)doc[doc_length - 2] << 16 |
- (FT_ULong)doc[doc_length - 3] << 8 |
- (FT_ULong)doc[doc_length - 4];
-
- if ( FT_QALLOC( uncomp_buffer, uncomp_size ) )
- goto Exit;
-
- error = FT_Gzip_Uncompress( memory,
- uncomp_buffer,
- &uncomp_size,
- doc,
- doc_length );
- if ( error )
- {
- FT_FREE( uncomp_buffer );
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- glyph->internal->flags |= FT_GLYPH_OWN_GZIP_SVG;
-
- doc = uncomp_buffer;
- doc_length = uncomp_size;
-
-#else /* !FT_CONFIG_OPTION_USE_ZLIB */
-
- error = FT_THROW( Unimplemented_Feature );
- goto Exit;
-
-#endif /* !FT_CONFIG_OPTION_USE_ZLIB */
- }
-
- svg_document->svg_document = doc;
- svg_document->svg_document_length = doc_length;
-
- svg_document->metrics = glyph->face->size->metrics;
- svg_document->units_per_EM = glyph->face->units_per_EM;
-
- svg_document->start_glyph_id = doc_start_glyph_id;
- svg_document->end_glyph_id = doc_end_glyph_id;
-
- svg_document->transform.xx = 0x10000;
- svg_document->transform.xy = 0;
- svg_document->transform.yx = 0;
- svg_document->transform.yy = 0x10000;
-
- svg_document->delta.x = 0;
- svg_document->delta.y = 0;
-
- FT_TRACE5(( "start_glyph_id: %d\n", doc_start_glyph_id ));
- FT_TRACE5(( "end_glyph_id: %d\n", doc_end_glyph_id ));
- FT_TRACE5(( "svg_document:\n" ));
- FT_TRACE5(( " %.*s\n", (FT_UInt)doc_length, doc ));
-
- glyph->other = svg_document;
-
- Exit:
- return error;
- }
-
-#else /* !FT_CONFIG_OPTION_SVG */
-
- /* ANSI C doesn't like empty source files */
- typedef int tt_svg_dummy_;
-
-#endif /* !FT_CONFIG_OPTION_SVG */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/sfnt/ttsvg.h b/contrib/libs/freetype/src/sfnt/ttsvg.h
deleted file mode 100644
index 20f9e47c99..0000000000
--- a/contrib/libs/freetype/src/sfnt/ttsvg.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/****************************************************************************
- *
- * ttsvg.h
- *
- * OpenType SVG Color (specification).
- *
- * Copyright (C) 2022-2024 by
- * David Turner, Robert Wilhelm, Werner Lemberg, and Moazin Khatti.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-#ifndef TTSVG_H_
-#define TTSVG_H_
-
-#include <freetype/internal/ftstream.h>
-#include <freetype/internal/tttypes.h>
-
-
-FT_BEGIN_HEADER
-
- FT_LOCAL( FT_Error )
- tt_face_load_svg( TT_Face face,
- FT_Stream stream );
-
- FT_LOCAL( void )
- tt_face_free_svg( TT_Face face );
-
- FT_LOCAL( FT_Error )
- tt_face_load_svg_doc( FT_GlyphSlot glyph,
- FT_UInt glyph_index );
-
-FT_END_HEADER
-
-#endif /* TTSVG_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/sfnt/woff2tags.c b/contrib/libs/freetype/src/sfnt/woff2tags.c
deleted file mode 100644
index 532ccfa173..0000000000
--- a/contrib/libs/freetype/src/sfnt/woff2tags.c
+++ /dev/null
@@ -1,119 +0,0 @@
-/****************************************************************************
- *
- * woff2tags.c
- *
- * WOFF2 Font table tags (base).
- *
- * Copyright (C) 2019-2024 by
- * Nikhil Ramakrishnan, David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/tttags.h>
-
-#ifdef FT_CONFIG_OPTION_USE_BROTLI
-
-#include "woff2tags.h"
-
- /*
- * Return tag from index in the order given in WOFF2 specification.
- *
- * See
- *
- * https://www.w3.org/TR/WOFF2/#table_dir_format
- *
- * for details.
- */
- FT_LOCAL_DEF( FT_Tag )
- woff2_known_tags( FT_Byte index )
- {
- static const FT_Tag known_tags[63] =
- {
- FT_MAKE_TAG('c', 'm', 'a', 'p'), /* 0 */
- FT_MAKE_TAG('h', 'e', 'a', 'd'), /* 1 */
- FT_MAKE_TAG('h', 'h', 'e', 'a'), /* 2 */
- FT_MAKE_TAG('h', 'm', 't', 'x'), /* 3 */
- FT_MAKE_TAG('m', 'a', 'x', 'p'), /* 4 */
- FT_MAKE_TAG('n', 'a', 'm', 'e'), /* 5 */
- FT_MAKE_TAG('O', 'S', '/', '2'), /* 6 */
- FT_MAKE_TAG('p', 'o', 's', 't'), /* 7 */
- FT_MAKE_TAG('c', 'v', 't', ' '), /* 8 */
- FT_MAKE_TAG('f', 'p', 'g', 'm'), /* 9 */
- FT_MAKE_TAG('g', 'l', 'y', 'f'), /* 10 */
- FT_MAKE_TAG('l', 'o', 'c', 'a'), /* 11 */
- FT_MAKE_TAG('p', 'r', 'e', 'p'), /* 12 */
- FT_MAKE_TAG('C', 'F', 'F', ' '), /* 13 */
- FT_MAKE_TAG('V', 'O', 'R', 'G'), /* 14 */
- FT_MAKE_TAG('E', 'B', 'D', 'T'), /* 15 */
- FT_MAKE_TAG('E', 'B', 'L', 'C'), /* 16 */
- FT_MAKE_TAG('g', 'a', 's', 'p'), /* 17 */
- FT_MAKE_TAG('h', 'd', 'm', 'x'), /* 18 */
- FT_MAKE_TAG('k', 'e', 'r', 'n'), /* 19 */
- FT_MAKE_TAG('L', 'T', 'S', 'H'), /* 20 */
- FT_MAKE_TAG('P', 'C', 'L', 'T'), /* 21 */
- FT_MAKE_TAG('V', 'D', 'M', 'X'), /* 22 */
- FT_MAKE_TAG('v', 'h', 'e', 'a'), /* 23 */
- FT_MAKE_TAG('v', 'm', 't', 'x'), /* 24 */
- FT_MAKE_TAG('B', 'A', 'S', 'E'), /* 25 */
- FT_MAKE_TAG('G', 'D', 'E', 'F'), /* 26 */
- FT_MAKE_TAG('G', 'P', 'O', 'S'), /* 27 */
- FT_MAKE_TAG('G', 'S', 'U', 'B'), /* 28 */
- FT_MAKE_TAG('E', 'B', 'S', 'C'), /* 29 */
- FT_MAKE_TAG('J', 'S', 'T', 'F'), /* 30 */
- FT_MAKE_TAG('M', 'A', 'T', 'H'), /* 31 */
- FT_MAKE_TAG('C', 'B', 'D', 'T'), /* 32 */
- FT_MAKE_TAG('C', 'B', 'L', 'C'), /* 33 */
- FT_MAKE_TAG('C', 'O', 'L', 'R'), /* 34 */
- FT_MAKE_TAG('C', 'P', 'A', 'L'), /* 35 */
- FT_MAKE_TAG('S', 'V', 'G', ' '), /* 36 */
- FT_MAKE_TAG('s', 'b', 'i', 'x'), /* 37 */
- FT_MAKE_TAG('a', 'c', 'n', 't'), /* 38 */
- FT_MAKE_TAG('a', 'v', 'a', 'r'), /* 39 */
- FT_MAKE_TAG('b', 'd', 'a', 't'), /* 40 */
- FT_MAKE_TAG('b', 'l', 'o', 'c'), /* 41 */
- FT_MAKE_TAG('b', 's', 'l', 'n'), /* 42 */
- FT_MAKE_TAG('c', 'v', 'a', 'r'), /* 43 */
- FT_MAKE_TAG('f', 'd', 's', 'c'), /* 44 */
- FT_MAKE_TAG('f', 'e', 'a', 't'), /* 45 */
- FT_MAKE_TAG('f', 'm', 't', 'x'), /* 46 */
- FT_MAKE_TAG('f', 'v', 'a', 'r'), /* 47 */
- FT_MAKE_TAG('g', 'v', 'a', 'r'), /* 48 */
- FT_MAKE_TAG('h', 's', 't', 'y'), /* 49 */
- FT_MAKE_TAG('j', 'u', 's', 't'), /* 50 */
- FT_MAKE_TAG('l', 'c', 'a', 'r'), /* 51 */
- FT_MAKE_TAG('m', 'o', 'r', 't'), /* 52 */
- FT_MAKE_TAG('m', 'o', 'r', 'x'), /* 53 */
- FT_MAKE_TAG('o', 'p', 'b', 'd'), /* 54 */
- FT_MAKE_TAG('p', 'r', 'o', 'p'), /* 55 */
- FT_MAKE_TAG('t', 'r', 'a', 'k'), /* 56 */
- FT_MAKE_TAG('Z', 'a', 'p', 'f'), /* 57 */
- FT_MAKE_TAG('S', 'i', 'l', 'f'), /* 58 */
- FT_MAKE_TAG('G', 'l', 'a', 't'), /* 59 */
- FT_MAKE_TAG('G', 'l', 'o', 'c'), /* 60 */
- FT_MAKE_TAG('F', 'e', 'a', 't'), /* 61 */
- FT_MAKE_TAG('S', 'i', 'l', 'l'), /* 62 */
- };
-
-
- if ( index > 62 )
- return 0;
-
- return known_tags[index];
- }
-
-#else /* !FT_CONFIG_OPTION_USE_BROTLI */
-
- /* ANSI C doesn't like empty source files */
- typedef int woff2tags_dummy_;
-
-#endif /* !FT_CONFIG_OPTION_USE_BROTLI */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/sfnt/woff2tags.h b/contrib/libs/freetype/src/sfnt/woff2tags.h
deleted file mode 100644
index d03b4b41bc..0000000000
--- a/contrib/libs/freetype/src/sfnt/woff2tags.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/****************************************************************************
- *
- * woff2tags.h
- *
- * WOFF2 Font table tags (specification).
- *
- * Copyright (C) 2019-2024 by
- * Nikhil Ramakrishnan, David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef WOFF2TAGS_H
-#define WOFF2TAGS_H
-
-
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/compiler-macros.h>
-
-
-FT_BEGIN_HEADER
-
-#ifdef FT_CONFIG_OPTION_USE_BROTLI
-
- FT_LOCAL( FT_Tag )
- woff2_known_tags( FT_Byte index );
-
-#endif
-
-FT_END_HEADER
-
-#endif /* WOFF2TAGS_H */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/smooth/ftgrays.c b/contrib/libs/freetype/src/smooth/ftgrays.c
deleted file mode 100644
index ec06235db6..0000000000
--- a/contrib/libs/freetype/src/smooth/ftgrays.c
+++ /dev/null
@@ -1,2149 +0,0 @@
-/****************************************************************************
- *
- * ftgrays.c
- *
- * A new `perfect' anti-aliasing renderer (body).
- *
- * Copyright (C) 2000-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
- /**************************************************************************
- *
- * This file can be compiled without the rest of the FreeType engine, by
- * defining the STANDALONE_ macro when compiling it. You also need to
- * put the files `ftgrays.h' and `ftimage.h' into the current
- * compilation directory. Typically, you could do something like
- *
- * - copy `src/smooth/ftgrays.c' (this file) to your current directory
- *
- * - copy `include/freetype/ftimage.h' and `src/smooth/ftgrays.h' to the
- * same directory
- *
- * - compile `ftgrays' with the STANDALONE_ macro defined, as in
- *
- * cc -c -DSTANDALONE_ ftgrays.c
- *
- * The renderer can be initialized with a call to
- * `ft_gray_raster.raster_new'; an anti-aliased bitmap can be generated
- * with a call to `ft_gray_raster.raster_render'.
- *
- * See the comments and documentation in the file `ftimage.h' for more
- * details on how the raster works.
- *
- */
-
- /**************************************************************************
- *
- * This is a new anti-aliasing scan-converter for FreeType 2. The
- * algorithm used here is _very_ different from the one in the standard
- * `ftraster' module. Actually, `ftgrays' computes the _exact_
- * coverage of the outline on each pixel cell by straight segments.
- *
- * It is based on ideas that I initially found in Raph Levien's
- * excellent LibArt graphics library (see https://www.levien.com/libart
- * for more information, though the web pages do not tell anything
- * about the renderer; you'll have to dive into the source code to
- * understand how it works).
- *
- * Note, however, that this is a _very_ different implementation
- * compared to Raph's. Coverage information is stored in a very
- * different way, and I don't use sorted vector paths. Also, it doesn't
- * use floating point values.
- *
- * Bézier segments are flattened by splitting them until their deviation
- * from straight line becomes much smaller than a pixel. Therefore, the
- * pixel coverage by a Bézier curve is calculated approximately. To
- * estimate the deviation, we use the distance from the control point
- * to the conic chord centre or the cubic chord trisection. These
- * distances vanish fast after each split. In the conic case, they vanish
- * predictably and the number of necessary splits can be calculated.
- *
- * This renderer has the following advantages:
- *
- * - It doesn't need an intermediate bitmap. Instead, one can supply a
- * callback function that will be called by the renderer to draw gray
- * spans on any target surface. You can thus do direct composition on
- * any kind of bitmap, provided that you give the renderer the right
- * callback.
- *
- * - A perfect anti-aliaser, i.e., it computes the _exact_ coverage on
- * each pixel cell by straight segments.
- *
- * - It performs a single pass on the outline (the `standard' FT2
- * renderer makes two passes).
- *
- * - It can easily be modified to render to _any_ number of gray levels
- * cheaply.
- *
- * - For small (< 80) pixel sizes, it is faster than the standard
- * renderer.
- *
- */
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT smooth
-
-
-#ifdef STANDALONE_
-
-
- /* The size in bytes of the render pool used by the scan-line converter */
- /* to do all of its work. */
-#define FT_RENDER_POOL_SIZE 16384L
-
-
- /* Auxiliary macros for token concatenation. */
-#define FT_ERR_XCAT( x, y ) x ## y
-#define FT_ERR_CAT( x, y ) FT_ERR_XCAT( x, y )
-
-#define FT_BEGIN_STMNT do {
-#define FT_END_STMNT } while ( 0 )
-
-#define FT_MIN( a, b ) ( (a) < (b) ? (a) : (b) )
-#define FT_MAX( a, b ) ( (a) > (b) ? (a) : (b) )
-#define FT_ABS( a ) ( (a) < 0 ? -(a) : (a) )
-
-
- /*
- * Approximate sqrt(x*x+y*y) using the `alpha max plus beta min'
- * algorithm. We use alpha = 1, beta = 3/8, giving us results with a
- * largest error less than 7% compared to the exact value.
- */
-#define FT_HYPOT( x, y ) \
- ( x = FT_ABS( x ), \
- y = FT_ABS( y ), \
- x > y ? x + ( 3 * y >> 3 ) \
- : y + ( 3 * x >> 3 ) )
-
-
- /* define this to dump debugging information */
-/* #define FT_DEBUG_LEVEL_TRACE */
-
-
-#ifdef FT_DEBUG_LEVEL_TRACE
-#include <stdio.h>
-#include <stdarg.h>
-#endif
-
-#include <stddef.h>
-#include <string.h>
-#include <setjmp.h>
-#include <limits.h>
-#define FT_CHAR_BIT CHAR_BIT
-#define FT_UINT_MAX UINT_MAX
-#define FT_INT_MAX INT_MAX
-#define FT_ULONG_MAX ULONG_MAX
-
-#define ADD_INT( a, b ) \
- (int)( (unsigned int)(a) + (unsigned int)(b) )
-
-#define FT_STATIC_BYTE_CAST( type, var ) (type)(unsigned char)(var)
-
-
-#define ft_memset memset
-
-#define ft_setjmp setjmp
-#define ft_longjmp longjmp
-#define ft_jmp_buf jmp_buf
-
-typedef ptrdiff_t FT_PtrDist;
-
-
-#define Smooth_Err_Ok 0
-#define Smooth_Err_Invalid_Outline -1
-#define Smooth_Err_Cannot_Render_Glyph -2
-#define Smooth_Err_Invalid_Argument -3
-#define Smooth_Err_Raster_Overflow -4
-
-#define FT_BEGIN_HEADER
-#define FT_END_HEADER
-
-#error #include "ftimage.h"
-#include "ftgrays.h"
-
-
- /* This macro is used to indicate that a function parameter is unused. */
- /* Its purpose is simply to reduce compiler warnings. Note also that */
- /* simply defining it as `(void)x' doesn't avoid warnings with certain */
- /* ANSI compilers (e.g. LCC). */
-#define FT_UNUSED( x ) (x) = (x)
-
-
- /* we only use level 5 & 7 tracing messages; cf. ftdebug.h */
-
-#ifdef FT_DEBUG_LEVEL_TRACE
-
- void
- FT_Message( const char* fmt,
- ... )
- {
- va_list ap;
-
-
- va_start( ap, fmt );
- vfprintf( stderr, fmt, ap );
- va_end( ap );
- }
-
-
- /* empty function useful for setting a breakpoint to catch errors */
- int
- FT_Throw( int error,
- int line,
- const char* file )
- {
- FT_UNUSED( error );
- FT_UNUSED( line );
- FT_UNUSED( file );
-
- return 0;
- }
-
-
- /* we don't handle tracing levels in stand-alone mode; */
-#ifndef FT_TRACE5
-#define FT_TRACE5( varformat ) FT_Message varformat
-#endif
-#ifndef FT_TRACE7
-#define FT_TRACE7( varformat ) FT_Message varformat
-#endif
-#ifndef FT_ERROR
-#define FT_ERROR( varformat ) FT_Message varformat
-#endif
-
-#define FT_THROW( e ) \
- ( FT_Throw( FT_ERR_CAT( Smooth_Err_, e ), \
- __LINE__, \
- __FILE__ ) | \
- FT_ERR_CAT( Smooth_Err_, e ) )
-
-#else /* !FT_DEBUG_LEVEL_TRACE */
-
-#define FT_TRACE5( x ) do { } while ( 0 ) /* nothing */
-#define FT_TRACE7( x ) do { } while ( 0 ) /* nothing */
-#define FT_ERROR( x ) do { } while ( 0 ) /* nothing */
-#define FT_THROW( e ) FT_ERR_CAT( Smooth_Err_, e )
-
-#endif /* !FT_DEBUG_LEVEL_TRACE */
-
-
-#define FT_Trace_Enable() do { } while ( 0 ) /* nothing */
-#define FT_Trace_Disable() do { } while ( 0 ) /* nothing */
-
-
-#define FT_DEFINE_OUTLINE_FUNCS( class_, \
- move_to_, line_to_, \
- conic_to_, cubic_to_, \
- shift_, delta_ ) \
- static const FT_Outline_Funcs class_ = \
- { \
- move_to_, \
- line_to_, \
- conic_to_, \
- cubic_to_, \
- shift_, \
- delta_ \
- };
-
-#define FT_DEFINE_RASTER_FUNCS( class_, glyph_format_, \
- raster_new_, raster_reset_, \
- raster_set_mode_, raster_render_, \
- raster_done_ ) \
- const FT_Raster_Funcs class_ = \
- { \
- glyph_format_, \
- raster_new_, \
- raster_reset_, \
- raster_set_mode_, \
- raster_render_, \
- raster_done_ \
- };
-
-
-#else /* !STANDALONE_ */
-
-
-#include <ft2build.h>
-#include FT_CONFIG_CONFIG_H
-#include "ftgrays.h"
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftcalc.h>
-#include <freetype/ftoutln.h>
-
-#include "ftsmerrs.h"
-
-
-#endif /* !STANDALONE_ */
-
-
-#ifndef FT_MEM_SET
-#define FT_MEM_SET( d, s, c ) ft_memset( d, s, c )
-#endif
-
-#ifndef FT_MEM_ZERO
-#define FT_MEM_ZERO( dest, count ) FT_MEM_SET( dest, 0, count )
-#endif
-
-#ifndef FT_ZERO
-#define FT_ZERO( p ) FT_MEM_ZERO( p, sizeof ( *(p) ) )
-#endif
-
- /* as usual, for the speed hungry :-) */
-
-#undef RAS_ARG
-#undef RAS_ARG_
-#undef RAS_VAR
-#undef RAS_VAR_
-
-#ifndef FT_STATIC_RASTER
-
-#define RAS_ARG gray_PWorker worker
-#define RAS_ARG_ gray_PWorker worker,
-
-#define RAS_VAR worker
-#define RAS_VAR_ worker,
-
-#else /* FT_STATIC_RASTER */
-
-#define RAS_ARG void
-#define RAS_ARG_ /* empty */
-#define RAS_VAR /* empty */
-#define RAS_VAR_ /* empty */
-
-#endif /* FT_STATIC_RASTER */
-
-
- /* must be at least 6 bits! */
-#define PIXEL_BITS 8
-
-#define ONE_PIXEL ( 1 << PIXEL_BITS )
-#undef TRUNC
-#define TRUNC( x ) (TCoord)( (x) >> PIXEL_BITS )
-#undef FRACT
-#define FRACT( x ) (TCoord)( (x) & ( ONE_PIXEL - 1 ) )
-
-#if PIXEL_BITS >= 6
-#define UPSCALE( x ) ( (x) * ( ONE_PIXEL >> 6 ) )
-#define DOWNSCALE( x ) ( (x) >> ( PIXEL_BITS - 6 ) )
-#else
-#define UPSCALE( x ) ( (x) >> ( 6 - PIXEL_BITS ) )
-#define DOWNSCALE( x ) ( (x) * ( 64 >> PIXEL_BITS ) )
-#endif
-
-
- /* Compute `dividend / divisor' and return both its quotient and */
- /* remainder, cast to a specific type. This macro also ensures that */
- /* the remainder is always positive. We use the remainder to keep */
- /* track of accumulating errors and compensate for them. */
-#define FT_DIV_MOD( type, dividend, divisor, quotient, remainder ) \
- FT_BEGIN_STMNT \
- (quotient) = (type)( (dividend) / (divisor) ); \
- (remainder) = (type)( (dividend) % (divisor) ); \
- if ( (remainder) < 0 ) \
- { \
- (quotient)--; \
- (remainder) += (type)(divisor); \
- } \
- FT_END_STMNT
-
-#if defined( __GNUC__ ) && __GNUC__ < 7 && defined( __arm__ )
- /* Work around a bug specific to GCC which make the compiler fail to */
- /* optimize a division and modulo operation on the same parameters */
- /* into a single call to `__aeabi_idivmod'. See */
- /* */
- /* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43721 */
-#undef FT_DIV_MOD
-#define FT_DIV_MOD( type, dividend, divisor, quotient, remainder ) \
- FT_BEGIN_STMNT \
- (quotient) = (type)( (dividend) / (divisor) ); \
- (remainder) = (type)( (dividend) - (quotient) * (divisor) ); \
- if ( (remainder) < 0 ) \
- { \
- (quotient)--; \
- (remainder) += (type)(divisor); \
- } \
- FT_END_STMNT
-#endif /* __arm__ */
-
-
- /* Calculating coverages for a slanted line requires a division each */
- /* time the line crosses from cell to cell. These macros speed up */
- /* the repetitive divisions by replacing them with multiplications */
- /* and right shifts so that at most two divisions are performed for */
- /* each slanted line. Nevertheless, these divisions are noticeable */
- /* in the overall performance because flattened curves produce a */
- /* very large number of slanted lines. */
- /* */
- /* The division results here are always within ONE_PIXEL. Therefore */
- /* the shift magnitude should be at least PIXEL_BITS wider than the */
- /* divisors to provide sufficient accuracy of the multiply-shift. */
- /* It should not exceed (64 - PIXEL_BITS) to prevent overflowing and */
- /* leave enough room for 64-bit unsigned multiplication however. */
-#define FT_UDIVPREP( c, b ) \
- FT_Int64 b ## _r = c ? (FT_Int64)0xFFFFFFFF / ( b ) : 0
-#define FT_UDIV( a, b ) \
- (TCoord)( ( (FT_UInt64)( a ) * (FT_UInt64)( b ## _r ) ) >> 32 )
-
-
- /* Scale area and apply fill rule to calculate the coverage byte. */
- /* The top fill bit is used for the non-zero rule. The eighth */
- /* fill bit is used for the even-odd rule. The higher coverage */
- /* bytes are either clamped for the non-zero-rule or discarded */
- /* later for the even-odd rule. */
-#define FT_FILL_RULE( coverage, area, fill ) \
- FT_BEGIN_STMNT \
- coverage = (int)( area >> ( PIXEL_BITS * 2 + 1 - 8 ) ); \
- if ( coverage & fill ) \
- coverage = ~coverage; \
- if ( coverage > 255 && fill & INT_MIN ) \
- coverage = 255; \
- FT_END_STMNT
-
-
- /* It is faster to write small spans byte-by-byte than calling */
- /* `memset'. This is mainly due to the cost of the function call. */
-#define FT_GRAY_SET( d, s, count ) \
- FT_BEGIN_STMNT \
- unsigned char* q = d; \
- switch ( count ) \
- { \
- case 7: *q++ = (unsigned char)s; FALL_THROUGH; \
- case 6: *q++ = (unsigned char)s; FALL_THROUGH; \
- case 5: *q++ = (unsigned char)s; FALL_THROUGH; \
- case 4: *q++ = (unsigned char)s; FALL_THROUGH; \
- case 3: *q++ = (unsigned char)s; FALL_THROUGH; \
- case 2: *q++ = (unsigned char)s; FALL_THROUGH; \
- case 1: *q = (unsigned char)s; FALL_THROUGH; \
- case 0: break; \
- default: FT_MEM_SET( d, s, count ); \
- } \
- FT_END_STMNT
-
-
- /**************************************************************************
- *
- * TYPE DEFINITIONS
- */
-
- /* don't change the following types to FT_Int or FT_Pos, since we might */
- /* need to define them to "float" or "double" when experimenting with */
- /* new algorithms */
-
- typedef long TPos; /* subpixel coordinate */
- typedef int TCoord; /* integer scanline/pixel coordinate */
- typedef int TArea; /* cell areas, coordinate products */
-
-
- typedef struct TCell_* PCell;
-
- typedef struct TCell_
- {
- TCoord x; /* same with gray_TWorker.ex */
- TCoord cover; /* same with gray_TWorker.cover */
- TArea area;
- PCell next;
-
- } TCell;
-
- typedef struct TPixmap_
- {
- unsigned char* origin; /* pixmap origin at the bottom-left */
- int pitch; /* pitch to go down one row */
-
- } TPixmap;
-
- /* maximum number of gray cells in the buffer */
-#if FT_RENDER_POOL_SIZE > 2048
-#define FT_MAX_GRAY_POOL ( FT_RENDER_POOL_SIZE / sizeof ( TCell ) )
-#else
-#define FT_MAX_GRAY_POOL ( 2048 / sizeof ( TCell ) )
-#endif
-
- /* FT_Span buffer size for direct rendering only */
-#define FT_MAX_GRAY_SPANS 16
-
-
-#if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */
- /* We disable the warning `structure was padded due to */
- /* __declspec(align())' in order to compile cleanly with */
- /* the maximum level of warnings. */
-#pragma warning( push )
-#pragma warning( disable : 4324 )
-#endif /* _MSC_VER */
-
- typedef struct gray_TWorker_
- {
- FT_BBox cbox;
-
- TCoord min_ex, max_ex; /* min and max integer pixel coordinates */
- TCoord min_ey, max_ey;
- TCoord count_ey; /* same as (max_ey - min_ey) */
-
- PCell cell; /* current cell */
- PCell cell_free; /* call allocation next free slot */
- PCell cell_null; /* last cell, used as dumpster and limit */
-
- PCell* ycells; /* array of cell linked-lists; one per */
- /* vertical coordinate in the current band */
-
- TPos x, y; /* last point position */
-
- FT_Outline outline; /* input outline */
- TPixmap target; /* target pixmap */
-
- FT_Raster_Span_Func render_span;
- void* render_span_data;
-
- ft_jmp_buf jump_buffer;
-
- } gray_TWorker, *gray_PWorker;
-
-#if defined( _MSC_VER )
-#pragma warning( pop )
-#endif
-
-#ifndef FT_STATIC_RASTER
-#define ras (*worker)
-#else
- static gray_TWorker ras;
-#endif
-
- /* The |x| value of the null cell. Must be the largest possible */
- /* integer value stored in a `TCell.x` field. */
-#define CELL_MAX_X_VALUE INT_MAX
-
-
-#define FT_INTEGRATE( ras, a, b ) \
- ras.cell->cover = ADD_INT( ras.cell->cover, a ), \
- ras.cell->area = ADD_INT( ras.cell->area, (a) * (TArea)(b) )
-
-
- typedef struct gray_TRaster_
- {
- void* memory;
-
- } gray_TRaster, *gray_PRaster;
-
-
-#ifdef FT_DEBUG_LEVEL_TRACE
-
- /* to be called while in the debugger -- */
- /* this function causes a compiler warning since it is unused otherwise */
- static void
- gray_dump_cells( RAS_ARG )
- {
- int y;
-
-
- for ( y = ras.min_ey; y < ras.max_ey; y++ )
- {
- PCell cell = ras.ycells[y - ras.min_ey];
-
-
- printf( "%3d:", y );
-
- for ( ; cell != ras.cell_null; cell = cell->next )
- printf( " (%3d, c:%4d, a:%6d)",
- cell->x, cell->cover, cell->area );
- printf( "\n" );
- }
- }
-
-#endif /* FT_DEBUG_LEVEL_TRACE */
-
-
- /**************************************************************************
- *
- * Set the current cell to a new position.
- */
- static void
- gray_set_cell( RAS_ARG_ TCoord ex,
- TCoord ey )
- {
- /* Move the cell pointer to a new position in the linked list. We use */
- /* a dumpster null cell for everything outside of the clipping region */
- /* during the render phase. This means that: */
- /* */
- /* . the new vertical position must be within min_ey..max_ey-1. */
- /* . the new horizontal position must be strictly less than max_ex */
- /* */
- /* Note that if a cell is to the left of the clipping region, it is */
- /* actually set to the (min_ex-1) horizontal position. */
-
- TCoord ey_index = ey - ras.min_ey;
-
-
- if ( ey_index < 0 || ey_index >= ras.count_ey || ex >= ras.max_ex )
- ras.cell = ras.cell_null;
- else
- {
- PCell* pcell = ras.ycells + ey_index;
- PCell cell;
-
-
- ex = FT_MAX( ex, ras.min_ex - 1 );
-
- while ( 1 )
- {
- cell = *pcell;
-
- if ( cell->x > ex )
- break;
-
- if ( cell->x == ex )
- goto Found;
-
- pcell = &cell->next;
- }
-
- /* insert new cell */
- cell = ras.cell_free++;
- if ( cell >= ras.cell_null )
- ft_longjmp( ras.jump_buffer, 1 );
-
- cell->x = ex;
- cell->area = 0;
- cell->cover = 0;
-
- cell->next = *pcell;
- *pcell = cell;
-
- Found:
- ras.cell = cell;
- }
- }
-
-
-#ifndef FT_INT64
-
- /**************************************************************************
- *
- * Render a scanline as one or more cells.
- */
- static void
- gray_render_scanline( RAS_ARG_ TCoord ey,
- TPos x1,
- TCoord y1,
- TPos x2,
- TCoord y2 )
- {
- TCoord ex1, ex2, fx1, fx2, first, dy, delta, mod;
- TPos p, dx;
- int incr;
-
-
- ex1 = TRUNC( x1 );
- ex2 = TRUNC( x2 );
-
- /* trivial case. Happens often */
- if ( y1 == y2 )
- {
- gray_set_cell( RAS_VAR_ ex2, ey );
- return;
- }
-
- fx1 = FRACT( x1 );
- fx2 = FRACT( x2 );
-
- /* everything is located in a single cell. That is easy! */
- /* */
- if ( ex1 == ex2 )
- goto End;
-
- /* ok, we'll have to render a run of adjacent cells on the same */
- /* scanline... */
- /* */
- dx = x2 - x1;
- dy = y2 - y1;
-
- if ( dx > 0 )
- {
- p = ( ONE_PIXEL - fx1 ) * dy;
- first = ONE_PIXEL;
- incr = 1;
- }
- else
- {
- p = fx1 * dy;
- first = 0;
- incr = -1;
- dx = -dx;
- }
-
- /* the fractional part of y-delta is mod/dx. It is essential to */
- /* keep track of its accumulation for accurate rendering. */
- /* XXX: y-delta and x-delta below should be related. */
- FT_DIV_MOD( TCoord, p, dx, delta, mod );
-
- FT_INTEGRATE( ras, delta, fx1 + first );
- y1 += delta;
- ex1 += incr;
- gray_set_cell( RAS_VAR_ ex1, ey );
-
- if ( ex1 != ex2 )
- {
- TCoord lift, rem;
-
-
- p = ONE_PIXEL * dy;
- FT_DIV_MOD( TCoord, p, dx, lift, rem );
-
- do
- {
- delta = lift;
- mod += rem;
- if ( mod >= (TCoord)dx )
- {
- mod -= (TCoord)dx;
- delta++;
- }
-
- FT_INTEGRATE( ras, delta, ONE_PIXEL );
- y1 += delta;
- ex1 += incr;
- gray_set_cell( RAS_VAR_ ex1, ey );
- } while ( ex1 != ex2 );
- }
-
- fx1 = ONE_PIXEL - first;
-
- End:
- FT_INTEGRATE( ras, y2 - y1, fx1 + fx2 );
- }
-
-
- /**************************************************************************
- *
- * Render a given line as a series of scanlines.
- */
- static void
- gray_render_line( RAS_ARG_ TPos to_x,
- TPos to_y )
- {
- TCoord ey1, ey2, fy1, fy2, first, delta, mod;
- TPos p, dx, dy, x, x2;
- int incr;
-
-
- ey1 = TRUNC( ras.y );
- ey2 = TRUNC( to_y ); /* if (ey2 >= ras.max_ey) ey2 = ras.max_ey-1; */
-
- /* perform vertical clipping */
- if ( ( ey1 >= ras.max_ey && ey2 >= ras.max_ey ) ||
- ( ey1 < ras.min_ey && ey2 < ras.min_ey ) )
- goto End;
-
- fy1 = FRACT( ras.y );
- fy2 = FRACT( to_y );
-
- /* everything is on a single scanline */
- if ( ey1 == ey2 )
- {
- gray_render_scanline( RAS_VAR_ ey1, ras.x, fy1, to_x, fy2 );
- goto End;
- }
-
- dx = to_x - ras.x;
- dy = to_y - ras.y;
-
- /* vertical line - avoid calling gray_render_scanline */
- if ( dx == 0 )
- {
- TCoord ex = TRUNC( ras.x );
- TCoord two_fx = FRACT( ras.x ) << 1;
-
-
- if ( dy > 0)
- {
- first = ONE_PIXEL;
- incr = 1;
- }
- else
- {
- first = 0;
- incr = -1;
- }
-
- delta = first - fy1;
- FT_INTEGRATE( ras, delta, two_fx);
- ey1 += incr;
-
- gray_set_cell( RAS_VAR_ ex, ey1 );
-
- delta = first + first - ONE_PIXEL;
- while ( ey1 != ey2 )
- {
- FT_INTEGRATE( ras, delta, two_fx);
- ey1 += incr;
-
- gray_set_cell( RAS_VAR_ ex, ey1 );
- }
-
- delta = fy2 - ONE_PIXEL + first;
- FT_INTEGRATE( ras, delta, two_fx);
-
- goto End;
- }
-
- /* ok, we have to render several scanlines */
- if ( dy > 0)
- {
- p = ( ONE_PIXEL - fy1 ) * dx;
- first = ONE_PIXEL;
- incr = 1;
- }
- else
- {
- p = fy1 * dx;
- first = 0;
- incr = -1;
- dy = -dy;
- }
-
- /* the fractional part of x-delta is mod/dy. It is essential to */
- /* keep track of its accumulation for accurate rendering. */
- FT_DIV_MOD( TCoord, p, dy, delta, mod );
-
- x = ras.x + delta;
- gray_render_scanline( RAS_VAR_ ey1, ras.x, fy1, x, first );
-
- ey1 += incr;
- gray_set_cell( RAS_VAR_ TRUNC( x ), ey1 );
-
- if ( ey1 != ey2 )
- {
- TCoord lift, rem;
-
-
- p = ONE_PIXEL * dx;
- FT_DIV_MOD( TCoord, p, dy, lift, rem );
-
- do
- {
- delta = lift;
- mod += rem;
- if ( mod >= (TCoord)dy )
- {
- mod -= (TCoord)dy;
- delta++;
- }
-
- x2 = x + delta;
- gray_render_scanline( RAS_VAR_ ey1,
- x, ONE_PIXEL - first,
- x2, first );
- x = x2;
-
- ey1 += incr;
- gray_set_cell( RAS_VAR_ TRUNC( x ), ey1 );
- } while ( ey1 != ey2 );
- }
-
- gray_render_scanline( RAS_VAR_ ey1,
- x, ONE_PIXEL - first,
- to_x, fy2 );
-
- End:
- ras.x = to_x;
- ras.y = to_y;
- }
-
-#else
-
- /**************************************************************************
- *
- * Render a straight line across multiple cells in any direction.
- */
- static void
- gray_render_line( RAS_ARG_ TPos to_x,
- TPos to_y )
- {
- TPos dx, dy;
- TCoord fx1, fy1, fx2, fy2;
- TCoord ex1, ey1, ex2, ey2;
-
-
- ey1 = TRUNC( ras.y );
- ey2 = TRUNC( to_y );
-
- /* perform vertical clipping */
- if ( ( ey1 >= ras.max_ey && ey2 >= ras.max_ey ) ||
- ( ey1 < ras.min_ey && ey2 < ras.min_ey ) )
- goto End;
-
- ex1 = TRUNC( ras.x );
- ex2 = TRUNC( to_x );
-
- fx1 = FRACT( ras.x );
- fy1 = FRACT( ras.y );
-
- dx = to_x - ras.x;
- dy = to_y - ras.y;
-
- if ( ex1 == ex2 && ey1 == ey2 ) /* inside one cell */
- ;
- else if ( dy == 0 ) /* ex1 != ex2 */ /* any horizontal line */
- {
- gray_set_cell( RAS_VAR_ ex2, ey2 );
- goto End;
- }
- else if ( dx == 0 )
- {
- if ( dy > 0 ) /* vertical line up */
- do
- {
- fy2 = ONE_PIXEL;
- FT_INTEGRATE( ras, fy2 - fy1, fx1 * 2 );
- fy1 = 0;
- ey1++;
- gray_set_cell( RAS_VAR_ ex1, ey1 );
- } while ( ey1 != ey2 );
- else /* vertical line down */
- do
- {
- fy2 = 0;
- FT_INTEGRATE( ras, fy2 - fy1, fx1 * 2 );
- fy1 = ONE_PIXEL;
- ey1--;
- gray_set_cell( RAS_VAR_ ex1, ey1 );
- } while ( ey1 != ey2 );
- }
- else /* any other line */
- {
- FT_Int64 prod = dx * (FT_Int64)fy1 - dy * (FT_Int64)fx1;
- FT_UDIVPREP( ex1 != ex2, dx );
- FT_UDIVPREP( ey1 != ey2, dy );
-
-
- /* The fundamental value `prod' determines which side and the */
- /* exact coordinate where the line exits current cell. It is */
- /* also easily updated when moving from one cell to the next. */
- do
- {
- if ( prod - dx * ONE_PIXEL > 0 &&
- prod <= 0 ) /* left */
- {
- fx2 = 0;
- fy2 = FT_UDIV( -prod, -dx );
- prod -= dy * ONE_PIXEL;
- FT_INTEGRATE( ras, fy2 - fy1, fx1 + fx2 );
- fx1 = ONE_PIXEL;
- fy1 = fy2;
- ex1--;
- }
- else if ( prod - dx * ONE_PIXEL + dy * ONE_PIXEL > 0 &&
- prod - dx * ONE_PIXEL <= 0 ) /* up */
- {
- prod -= dx * ONE_PIXEL;
- fx2 = FT_UDIV( -prod, dy );
- fy2 = ONE_PIXEL;
- FT_INTEGRATE( ras, fy2 - fy1, fx1 + fx2 );
- fx1 = fx2;
- fy1 = 0;
- ey1++;
- }
- else if ( prod + dy * ONE_PIXEL >= 0 &&
- prod - dx * ONE_PIXEL + dy * ONE_PIXEL <= 0 ) /* right */
- {
- prod += dy * ONE_PIXEL;
- fx2 = ONE_PIXEL;
- fy2 = FT_UDIV( prod, dx );
- FT_INTEGRATE( ras, fy2 - fy1, fx1 + fx2 );
- fx1 = 0;
- fy1 = fy2;
- ex1++;
- }
- else /* ( prod > 0 &&
- prod + dy * ONE_PIXEL < 0 ) down */
- {
- fx2 = FT_UDIV( prod, -dy );
- fy2 = 0;
- prod += dx * ONE_PIXEL;
- FT_INTEGRATE( ras, fy2 - fy1, fx1 + fx2 );
- fx1 = fx2;
- fy1 = ONE_PIXEL;
- ey1--;
- }
-
- gray_set_cell( RAS_VAR_ ex1, ey1 );
-
- } while ( ex1 != ex2 || ey1 != ey2 );
- }
-
- fx2 = FRACT( to_x );
- fy2 = FRACT( to_y );
-
- FT_INTEGRATE( ras, fy2 - fy1, fx1 + fx2 );
-
- End:
- ras.x = to_x;
- ras.y = to_y;
- }
-
-#endif
-
- /*
- * For now, the code that uses DDA to render conic curves requires
- * `FT_Int64` to be defined. See for example
- * https://gitlab.freedesktop.org/freetype/freetype/-/issues/1071.
- */
-
-#ifdef FT_INT64
-
-#define LEFT_SHIFT( a, b ) (FT_Int64)( (FT_UInt64)(a) << (b) )
-
-
- static void
- gray_render_conic( RAS_ARG_ const FT_Vector* control,
- const FT_Vector* to )
- {
- FT_Vector p0, p1, p2;
- TPos ax, ay, bx, by, dx, dy;
- int shift;
-
- FT_Int64 rx, ry;
- FT_Int64 qx, qy;
- FT_Int64 px, py;
-
- FT_UInt count;
-
-
- p0.x = ras.x;
- p0.y = ras.y;
- p1.x = UPSCALE( control->x );
- p1.y = UPSCALE( control->y );
- p2.x = UPSCALE( to->x );
- p2.y = UPSCALE( to->y );
-
- /* short-cut the arc that crosses the current band */
- if ( ( TRUNC( p0.y ) >= ras.max_ey &&
- TRUNC( p1.y ) >= ras.max_ey &&
- TRUNC( p2.y ) >= ras.max_ey ) ||
- ( TRUNC( p0.y ) < ras.min_ey &&
- TRUNC( p1.y ) < ras.min_ey &&
- TRUNC( p2.y ) < ras.min_ey ) )
- {
- ras.x = p2.x;
- ras.y = p2.y;
- return;
- }
-
- bx = p1.x - p0.x;
- by = p1.y - p0.y;
- ax = p2.x - p1.x - bx; /* p0.x + p2.x - 2 * p1.x */
- ay = p2.y - p1.y - by; /* p0.y + p2.y - 2 * p1.y */
-
- dx = FT_ABS( ax );
- dy = FT_ABS( ay );
- if ( dx < dy )
- dx = dy;
-
- if ( dx <= ONE_PIXEL / 4 )
- {
- gray_render_line( RAS_VAR_ p2.x, p2.y );
- return;
- }
-
- /* We can calculate the number of necessary segments because */
- /* each bisection predictably reduces deviation exactly 4-fold. */
- /* Even 32-bit deviation would vanish after 16 bisections. */
- shift = 16;
- do
- {
- dx >>= 2;
- shift--;
-
- } while ( dx > ONE_PIXEL / 4 );
- count = 0x10000U >> shift;
-
- /*
- * The (P0,P1,P2) arc equation, for t in [0,1] range:
- *
- * P(t) = P0*(1-t)^2 + P1*2*t*(1-t) + P2*t^2
- *
- * P(t) = P0 + 2*(P1-P0)*t + (P0+P2-2*P1)*t^2
- * = P0 + 2*B*t + A*t^2
- *
- * for A = P0 + P2 - 2*P1
- * and B = P1 - P0
- *
- * Let's consider the difference when advancing by a small
- * parameter h:
- *
- * Q(h,t) = P(t+h) - P(t) = 2*B*h + A*h^2 + 2*A*h*t
- *
- * And then its own difference:
- *
- * R(h,t) = Q(h,t+h) - Q(h,t) = 2*A*h*h = R (constant)
- *
- * Since R is always a constant, it is possible to compute
- * successive positions with:
- *
- * P = P0
- * Q = Q(h,0) = 2*B*h + A*h*h
- * R = 2*A*h*h
- *
- * loop:
- * P += Q
- * Q += R
- * EMIT(P)
- *
- * To ensure accurate results, perform computations on 64-bit
- * values, after scaling them by 2^32.
- *
- * h = 1 / 2^N
- *
- * R << 32 = 2 * A << (32 - N - N)
- * = A << (33 - 2*N)
- *
- * Q << 32 = (2 * B << (32 - N)) + (A << (32 - N - N))
- * = (B << (33 - N)) + (A << (32 - 2*N))
- */
-
- rx = LEFT_SHIFT( ax, shift + shift );
- ry = LEFT_SHIFT( ay, shift + shift );
-
- qx = LEFT_SHIFT( bx, shift + 17 ) + rx;
- qy = LEFT_SHIFT( by, shift + 17 ) + ry;
-
- rx *= 2;
- ry *= 2;
-
- px = LEFT_SHIFT( p0.x, 32 );
- py = LEFT_SHIFT( p0.y, 32 );
-
- do
- {
- px += qx;
- py += qy;
- qx += rx;
- qy += ry;
-
- gray_render_line( RAS_VAR_ (FT_Pos)( px >> 32 ),
- (FT_Pos)( py >> 32 ) );
- } while ( --count );
- }
-
-#else /* !FT_INT64 */
-
- /*
- * Note that multiple attempts to speed up the function below
- * with SSE2 intrinsics, using various data layouts, have turned
- * out to be slower than the non-SIMD code below.
- */
- static void
- gray_split_conic( FT_Vector* base )
- {
- TPos a, b;
-
-
- base[4].x = base[2].x;
- a = base[0].x + base[1].x;
- b = base[1].x + base[2].x;
- base[3].x = b >> 1;
- base[2].x = ( a + b ) >> 2;
- base[1].x = a >> 1;
-
- base[4].y = base[2].y;
- a = base[0].y + base[1].y;
- b = base[1].y + base[2].y;
- base[3].y = b >> 1;
- base[2].y = ( a + b ) >> 2;
- base[1].y = a >> 1;
- }
-
-
- static void
- gray_render_conic( RAS_ARG_ const FT_Vector* control,
- const FT_Vector* to )
- {
- FT_Vector bez_stack[16 * 2 + 1]; /* enough to accommodate bisections */
- FT_Vector* arc = bez_stack;
- TPos dx, dy;
- int draw;
-
-
- arc[0].x = UPSCALE( to->x );
- arc[0].y = UPSCALE( to->y );
- arc[1].x = UPSCALE( control->x );
- arc[1].y = UPSCALE( control->y );
- arc[2].x = ras.x;
- arc[2].y = ras.y;
-
- /* short-cut the arc that crosses the current band */
- if ( ( TRUNC( arc[0].y ) >= ras.max_ey &&
- TRUNC( arc[1].y ) >= ras.max_ey &&
- TRUNC( arc[2].y ) >= ras.max_ey ) ||
- ( TRUNC( arc[0].y ) < ras.min_ey &&
- TRUNC( arc[1].y ) < ras.min_ey &&
- TRUNC( arc[2].y ) < ras.min_ey ) )
- {
- ras.x = arc[0].x;
- ras.y = arc[0].y;
- return;
- }
-
- dx = FT_ABS( arc[2].x + arc[0].x - 2 * arc[1].x );
- dy = FT_ABS( arc[2].y + arc[0].y - 2 * arc[1].y );
- if ( dx < dy )
- dx = dy;
-
- /* We can calculate the number of necessary bisections because */
- /* each bisection predictably reduces deviation exactly 4-fold. */
- /* Even 32-bit deviation would vanish after 16 bisections. */
- draw = 1;
- while ( dx > ONE_PIXEL / 4 )
- {
- dx >>= 2;
- draw <<= 1;
- }
-
- /* We use decrement counter to count the total number of segments */
- /* to draw starting from 2^level. Before each draw we split as */
- /* many times as there are trailing zeros in the counter. */
- do
- {
- int split = draw & ( -draw ); /* isolate the rightmost 1-bit */
-
-
- while ( ( split >>= 1 ) )
- {
- gray_split_conic( arc );
- arc += 2;
- }
-
- gray_render_line( RAS_VAR_ arc[0].x, arc[0].y );
- arc -= 2;
-
- } while ( --draw );
- }
-
-#endif /* !FT_INT64 */
-
-
- /*
- * For cubic Bézier, binary splits are still faster than DDA
- * because the splits are adaptive to how quickly each sub-arc
- * approaches their chord trisection points.
- *
- * It might be useful to experiment with SSE2 to speed up
- * `gray_split_cubic`, though.
- */
- static void
- gray_split_cubic( FT_Vector* base )
- {
- TPos a, b, c;
-
-
- base[6].x = base[3].x;
- a = base[0].x + base[1].x;
- b = base[1].x + base[2].x;
- c = base[2].x + base[3].x;
- base[5].x = c >> 1;
- c += b;
- base[4].x = c >> 2;
- base[1].x = a >> 1;
- a += b;
- base[2].x = a >> 2;
- base[3].x = ( a + c ) >> 3;
-
- base[6].y = base[3].y;
- a = base[0].y + base[1].y;
- b = base[1].y + base[2].y;
- c = base[2].y + base[3].y;
- base[5].y = c >> 1;
- c += b;
- base[4].y = c >> 2;
- base[1].y = a >> 1;
- a += b;
- base[2].y = a >> 2;
- base[3].y = ( a + c ) >> 3;
- }
-
-
- static void
- gray_render_cubic( RAS_ARG_ const FT_Vector* control1,
- const FT_Vector* control2,
- const FT_Vector* to )
- {
- FT_Vector bez_stack[16 * 3 + 1]; /* enough to accommodate bisections */
- FT_Vector* arc = bez_stack;
-
-
- arc[0].x = UPSCALE( to->x );
- arc[0].y = UPSCALE( to->y );
- arc[1].x = UPSCALE( control2->x );
- arc[1].y = UPSCALE( control2->y );
- arc[2].x = UPSCALE( control1->x );
- arc[2].y = UPSCALE( control1->y );
- arc[3].x = ras.x;
- arc[3].y = ras.y;
-
- /* short-cut the arc that crosses the current band */
- if ( ( TRUNC( arc[0].y ) >= ras.max_ey &&
- TRUNC( arc[1].y ) >= ras.max_ey &&
- TRUNC( arc[2].y ) >= ras.max_ey &&
- TRUNC( arc[3].y ) >= ras.max_ey ) ||
- ( TRUNC( arc[0].y ) < ras.min_ey &&
- TRUNC( arc[1].y ) < ras.min_ey &&
- TRUNC( arc[2].y ) < ras.min_ey &&
- TRUNC( arc[3].y ) < ras.min_ey ) )
- {
- ras.x = arc[0].x;
- ras.y = arc[0].y;
- return;
- }
-
- for (;;)
- {
- /* with each split, control points quickly converge towards */
- /* chord trisection points and the vanishing distances below */
- /* indicate when the segment is flat enough to draw */
- if ( FT_ABS( 2 * arc[0].x - 3 * arc[1].x + arc[3].x ) > ONE_PIXEL / 2 ||
- FT_ABS( 2 * arc[0].y - 3 * arc[1].y + arc[3].y ) > ONE_PIXEL / 2 ||
- FT_ABS( arc[0].x - 3 * arc[2].x + 2 * arc[3].x ) > ONE_PIXEL / 2 ||
- FT_ABS( arc[0].y - 3 * arc[2].y + 2 * arc[3].y ) > ONE_PIXEL / 2 )
- goto Split;
-
- gray_render_line( RAS_VAR_ arc[0].x, arc[0].y );
-
- if ( arc == bez_stack )
- return;
-
- arc -= 3;
- continue;
-
- Split:
- gray_split_cubic( arc );
- arc += 3;
- }
- }
-
-
- static int
- gray_move_to( const FT_Vector* to,
- void* worker_ ) /* gray_PWorker */
- {
- gray_PWorker worker = (gray_PWorker)worker_;
-
- TPos x, y;
-
-
- /* start to a new position */
- x = UPSCALE( to->x );
- y = UPSCALE( to->y );
-
- gray_set_cell( RAS_VAR_ TRUNC( x ), TRUNC( y ) );
-
- ras.x = x;
- ras.y = y;
- return 0;
- }
-
-
- static int
- gray_line_to( const FT_Vector* to,
- void* worker_ ) /* gray_PWorker */
- {
- gray_PWorker worker = (gray_PWorker)worker_;
-
-
- gray_render_line( RAS_VAR_ UPSCALE( to->x ), UPSCALE( to->y ) );
- return 0;
- }
-
-
- static int
- gray_conic_to( const FT_Vector* control,
- const FT_Vector* to,
- void* worker_ ) /* gray_PWorker */
- {
- gray_PWorker worker = (gray_PWorker)worker_;
-
-
- gray_render_conic( RAS_VAR_ control, to );
- return 0;
- }
-
-
- static int
- gray_cubic_to( const FT_Vector* control1,
- const FT_Vector* control2,
- const FT_Vector* to,
- void* worker_ ) /* gray_PWorker */
- {
- gray_PWorker worker = (gray_PWorker)worker_;
-
-
- gray_render_cubic( RAS_VAR_ control1, control2, to );
- return 0;
- }
-
-
-#ifdef STANDALONE_
-
- /**************************************************************************
- *
- * The following functions should only compile in stand-alone mode,
- * i.e., when building this component without the rest of FreeType.
- *
- */
-
- /**************************************************************************
- *
- * @Function:
- * FT_Outline_Decompose
- *
- * @Description:
- * Walk over an outline's structure to decompose it into individual
- * segments and Bézier arcs. This function is also able to emit
- * `move to' and `close to' operations to indicate the start and end
- * of new contours in the outline.
- *
- * @Input:
- * outline ::
- * A pointer to the source target.
- *
- * func_interface ::
- * A table of `emitters', i.e., function pointers
- * called during decomposition to indicate path
- * operations.
- *
- * @InOut:
- * user ::
- * A typeless pointer which is passed to each
- * emitter during the decomposition. It can be
- * used to store the state during the
- * decomposition.
- *
- * @Return:
- * Error code. 0 means success.
- */
- static int
- FT_Outline_Decompose( const FT_Outline* outline,
- const FT_Outline_Funcs* func_interface,
- void* user )
- {
-#undef SCALED
-#define SCALED( x ) ( (x) * ( 1L << shift ) - delta )
-
- FT_Vector v_last;
- FT_Vector v_control;
- FT_Vector v_start;
-
- FT_Vector* point;
- FT_Vector* limit;
- char* tags;
-
- int error;
-
- int n; /* index of contour in outline */
- int first; /* index of first point in contour */
- int last; /* index of last point in contour */
-
- char tag; /* current point's state */
-
- int shift;
- TPos delta;
-
-
- if ( !outline )
- return FT_THROW( Invalid_Outline );
-
- if ( !func_interface )
- return FT_THROW( Invalid_Argument );
-
- shift = func_interface->shift;
- delta = func_interface->delta;
-
- last = -1;
- for ( n = 0; n < outline->n_contours; n++ )
- {
- FT_TRACE5(( "FT_Outline_Decompose: Contour %d\n", n ));
-
- first = last + 1;
- last = outline->contours[n];
- if ( last < first )
- goto Invalid_Outline;
-
- limit = outline->points + last;
-
- v_start = outline->points[first];
- v_start.x = SCALED( v_start.x );
- v_start.y = SCALED( v_start.y );
-
- v_last = outline->points[last];
- v_last.x = SCALED( v_last.x );
- v_last.y = SCALED( v_last.y );
-
- v_control = v_start;
-
- point = outline->points + first;
- tags = outline->tags + first;
- tag = FT_CURVE_TAG( tags[0] );
-
- /* A contour cannot start with a cubic control point! */
- if ( tag == FT_CURVE_TAG_CUBIC )
- goto Invalid_Outline;
-
- /* check first point to determine origin */
- if ( tag == FT_CURVE_TAG_CONIC )
- {
- /* first point is conic control. Yes, this happens. */
- if ( FT_CURVE_TAG( outline->tags[last] ) == FT_CURVE_TAG_ON )
- {
- /* start at last point if it is on the curve */
- v_start = v_last;
- limit--;
- }
- else
- {
- /* if both first and last points are conic, */
- /* start at their middle and record its position */
- /* for closure */
- v_start.x = ( v_start.x + v_last.x ) / 2;
- v_start.y = ( v_start.y + v_last.y ) / 2;
-
- v_last = v_start;
- }
- point--;
- tags--;
- }
-
- FT_TRACE5(( " move to (%.2f, %.2f)\n",
- v_start.x / 64.0, v_start.y / 64.0 ));
- error = func_interface->move_to( &v_start, user );
- if ( error )
- goto Exit;
-
- while ( point < limit )
- {
- point++;
- tags++;
-
- tag = FT_CURVE_TAG( tags[0] );
- switch ( tag )
- {
- case FT_CURVE_TAG_ON: /* emit a single line_to */
- {
- FT_Vector vec;
-
-
- vec.x = SCALED( point->x );
- vec.y = SCALED( point->y );
-
- FT_TRACE5(( " line to (%.2f, %.2f)\n",
- vec.x / 64.0, vec.y / 64.0 ));
- error = func_interface->line_to( &vec, user );
- if ( error )
- goto Exit;
- continue;
- }
-
- case FT_CURVE_TAG_CONIC: /* consume conic arcs */
- v_control.x = SCALED( point->x );
- v_control.y = SCALED( point->y );
-
- Do_Conic:
- if ( point < limit )
- {
- FT_Vector vec;
- FT_Vector v_middle;
-
-
- point++;
- tags++;
- tag = FT_CURVE_TAG( tags[0] );
-
- vec.x = SCALED( point->x );
- vec.y = SCALED( point->y );
-
- if ( tag == FT_CURVE_TAG_ON )
- {
- FT_TRACE5(( " conic to (%.2f, %.2f)"
- " with control (%.2f, %.2f)\n",
- vec.x / 64.0, vec.y / 64.0,
- v_control.x / 64.0, v_control.y / 64.0 ));
- error = func_interface->conic_to( &v_control, &vec, user );
- if ( error )
- goto Exit;
- continue;
- }
-
- if ( tag != FT_CURVE_TAG_CONIC )
- goto Invalid_Outline;
-
- v_middle.x = ( v_control.x + vec.x ) / 2;
- v_middle.y = ( v_control.y + vec.y ) / 2;
-
- FT_TRACE5(( " conic to (%.2f, %.2f)"
- " with control (%.2f, %.2f)\n",
- v_middle.x / 64.0, v_middle.y / 64.0,
- v_control.x / 64.0, v_control.y / 64.0 ));
- error = func_interface->conic_to( &v_control, &v_middle, user );
- if ( error )
- goto Exit;
-
- v_control = vec;
- goto Do_Conic;
- }
-
- FT_TRACE5(( " conic to (%.2f, %.2f)"
- " with control (%.2f, %.2f)\n",
- v_start.x / 64.0, v_start.y / 64.0,
- v_control.x / 64.0, v_control.y / 64.0 ));
- error = func_interface->conic_to( &v_control, &v_start, user );
- goto Close;
-
- default: /* FT_CURVE_TAG_CUBIC */
- {
- FT_Vector vec1, vec2;
-
-
- if ( point + 1 > limit ||
- FT_CURVE_TAG( tags[1] ) != FT_CURVE_TAG_CUBIC )
- goto Invalid_Outline;
-
- point += 2;
- tags += 2;
-
- vec1.x = SCALED( point[-2].x );
- vec1.y = SCALED( point[-2].y );
-
- vec2.x = SCALED( point[-1].x );
- vec2.y = SCALED( point[-1].y );
-
- if ( point <= limit )
- {
- FT_Vector vec;
-
-
- vec.x = SCALED( point->x );
- vec.y = SCALED( point->y );
-
- FT_TRACE5(( " cubic to (%.2f, %.2f)"
- " with controls (%.2f, %.2f) and (%.2f, %.2f)\n",
- vec.x / 64.0, vec.y / 64.0,
- vec1.x / 64.0, vec1.y / 64.0,
- vec2.x / 64.0, vec2.y / 64.0 ));
- error = func_interface->cubic_to( &vec1, &vec2, &vec, user );
- if ( error )
- goto Exit;
- continue;
- }
-
- FT_TRACE5(( " cubic to (%.2f, %.2f)"
- " with controls (%.2f, %.2f) and (%.2f, %.2f)\n",
- v_start.x / 64.0, v_start.y / 64.0,
- vec1.x / 64.0, vec1.y / 64.0,
- vec2.x / 64.0, vec2.y / 64.0 ));
- error = func_interface->cubic_to( &vec1, &vec2, &v_start, user );
- goto Close;
- }
- }
- }
-
- /* close the contour with a line segment */
- FT_TRACE5(( " line to (%.2f, %.2f)\n",
- v_start.x / 64.0, v_start.y / 64.0 ));
- error = func_interface->line_to( &v_start, user );
-
- Close:
- if ( error )
- goto Exit;
- }
-
- FT_TRACE5(( "FT_Outline_Decompose: Done\n", n ));
- return Smooth_Err_Ok;
-
- Exit:
- FT_TRACE5(( "FT_Outline_Decompose: Error 0x%x\n", error ));
- return error;
-
- Invalid_Outline:
- return FT_THROW( Invalid_Outline );
- }
-
-#endif /* STANDALONE_ */
-
-
- FT_DEFINE_OUTLINE_FUNCS(
- func_interface,
-
- (FT_Outline_MoveTo_Func) gray_move_to, /* move_to */
- (FT_Outline_LineTo_Func) gray_line_to, /* line_to */
- (FT_Outline_ConicTo_Func)gray_conic_to, /* conic_to */
- (FT_Outline_CubicTo_Func)gray_cubic_to, /* cubic_to */
-
- 0, /* shift */
- 0 /* delta */
- )
-
-
- static int
- gray_convert_glyph_inner( RAS_ARG_
- int continued )
- {
- volatile int error;
-
-
- if ( ft_setjmp( ras.jump_buffer ) == 0 )
- {
- if ( continued )
- FT_Trace_Disable();
- error = FT_Outline_Decompose( &ras.outline, &func_interface, &ras );
- if ( continued )
- FT_Trace_Enable();
-
- FT_TRACE7(( "band [%d..%d]: %td cell%s remaining\n",
- ras.min_ey,
- ras.max_ey,
- ras.cell_null - ras.cell_free,
- ras.cell_null - ras.cell_free == 1 ? "" : "s" ));
- }
- else
- {
- error = FT_THROW( Raster_Overflow );
-
- FT_TRACE7(( "band [%d..%d]: to be bisected\n",
- ras.min_ey, ras.max_ey ));
- }
-
- return error;
- }
-
-
- static void
- gray_sweep( RAS_ARG )
- {
- int fill = ( ras.outline.flags & FT_OUTLINE_EVEN_ODD_FILL ) ? 0x100
- : INT_MIN;
- int coverage;
- int y;
-
-
- for ( y = ras.min_ey; y < ras.max_ey; y++ )
- {
- PCell cell = ras.ycells[y - ras.min_ey];
- TCoord x = ras.min_ex;
- TArea cover = 0;
-
- unsigned char* line = ras.target.origin - ras.target.pitch * y;
-
-
- for ( ; cell != ras.cell_null; cell = cell->next )
- {
- TArea area;
-
-
- if ( cover != 0 && cell->x > x )
- {
- FT_FILL_RULE( coverage, cover, fill );
- FT_GRAY_SET( line + x, coverage, cell->x - x );
- }
-
- cover += (TArea)cell->cover * ( ONE_PIXEL * 2 );
- area = cover - cell->area;
-
- if ( area != 0 && cell->x >= ras.min_ex )
- {
- FT_FILL_RULE( coverage, area, fill );
- line[cell->x] = (unsigned char)coverage;
- }
-
- x = cell->x + 1;
- }
-
- if ( cover != 0 ) /* only if cropped */
- {
- FT_FILL_RULE( coverage, cover, fill );
- FT_GRAY_SET( line + x, coverage, ras.max_ex - x );
- }
- }
- }
-
-
- static void
- gray_sweep_direct( RAS_ARG )
- {
- int fill = ( ras.outline.flags & FT_OUTLINE_EVEN_ODD_FILL ) ? 0x100
- : INT_MIN;
- int coverage;
- int y;
-
- FT_Span span[FT_MAX_GRAY_SPANS];
- int n = 0;
-
-
- for ( y = ras.min_ey; y < ras.max_ey; y++ )
- {
- PCell cell = ras.ycells[y - ras.min_ey];
- TCoord x = ras.min_ex;
- TArea cover = 0;
-
-
- for ( ; cell != ras.cell_null; cell = cell->next )
- {
- TArea area;
-
-
- if ( cover != 0 && cell->x > x )
- {
- FT_FILL_RULE( coverage, cover, fill );
-
- span[n].coverage = (unsigned char)coverage;
- span[n].x = (short)x;
- span[n].len = (unsigned short)( cell->x - x );
-
- if ( ++n == FT_MAX_GRAY_SPANS )
- {
- /* flush the span buffer and reset the count */
- ras.render_span( y, n, span, ras.render_span_data );
- n = 0;
- }
- }
-
- cover += (TArea)cell->cover * ( ONE_PIXEL * 2 );
- area = cover - cell->area;
-
- if ( area != 0 && cell->x >= ras.min_ex )
- {
- FT_FILL_RULE( coverage, area, fill );
-
- span[n].coverage = (unsigned char)coverage;
- span[n].x = (short)cell->x;
- span[n].len = 1;
-
- if ( ++n == FT_MAX_GRAY_SPANS )
- {
- /* flush the span buffer and reset the count */
- ras.render_span( y, n, span, ras.render_span_data );
- n = 0;
- }
- }
-
- x = cell->x + 1;
- }
-
- if ( cover != 0 ) /* only if cropped */
- {
- FT_FILL_RULE( coverage, cover, fill );
-
- span[n].coverage = (unsigned char)coverage;
- span[n].x = (short)x;
- span[n].len = (unsigned short)( ras.max_ex - x );
-
- ++n;
- }
-
- if ( n )
- {
- /* flush the span buffer and reset the count */
- ras.render_span( y, n, span, ras.render_span_data );
- n = 0;
- }
- }
- }
-
-
- static int
- gray_convert_glyph( RAS_ARG )
- {
- TCell buffer[FT_MAX_GRAY_POOL];
- size_t height = (size_t)( ras.cbox.yMax - ras.cbox.yMin );
- size_t n = FT_MAX_GRAY_POOL / 8;
- TCoord y;
- TCoord bands[32]; /* enough to accommodate bisections */
- TCoord* band;
-
- int continued = 0;
-
-
- /* Initialize the null cell at the end of the poll. */
- ras.cell_null = buffer + FT_MAX_GRAY_POOL - 1;
- ras.cell_null->x = CELL_MAX_X_VALUE;
- ras.cell_null->area = 0;
- ras.cell_null->cover = 0;
- ras.cell_null->next = NULL;
-
- /* set up vertical bands */
- ras.ycells = (PCell*)buffer;
-
- if ( height > n )
- {
- /* two divisions rounded up */
- n = ( height + n - 1 ) / n;
- height = ( height + n - 1 ) / n;
- }
-
- for ( y = ras.cbox.yMin; y < ras.cbox.yMax; )
- {
- ras.min_ey = y;
- y += height;
- ras.max_ey = FT_MIN( y, ras.cbox.yMax );
-
- ras.count_ey = ras.max_ey - ras.min_ey;
-
- band = bands;
- band[1] = ras.cbox.xMin;
- band[0] = ras.cbox.xMax;
-
- do
- {
- TCoord i;
- int error;
-
-
- ras.min_ex = band[1];
- ras.max_ex = band[0];
-
- /* memory management: zero out and skip ycells */
- for ( i = 0; i < ras.count_ey; ++i )
- ras.ycells[i] = ras.cell_null;
-
- n = ( (size_t)ras.count_ey * sizeof ( PCell ) + sizeof ( TCell ) - 1 )
- / sizeof ( TCell );
-
- ras.cell_free = buffer + n;
- ras.cell = ras.cell_null;
-
- error = gray_convert_glyph_inner( RAS_VAR_ continued );
- continued = 1;
-
- if ( !error )
- {
- if ( ras.render_span ) /* for FT_RASTER_FLAG_DIRECT only */
- gray_sweep_direct( RAS_VAR );
- else
- gray_sweep( RAS_VAR );
- band--;
- continue;
- }
- else if ( error != Smooth_Err_Raster_Overflow )
- return error;
-
- /* render pool overflow; we will reduce the render band by half */
- i = ( band[0] - band[1] ) >> 1;
-
- /* this should never happen even with tiny rendering pool */
- if ( i == 0 )
- {
- FT_TRACE7(( "gray_convert_glyph: rotten glyph\n" ));
- return FT_THROW( Raster_Overflow );
- }
-
- band++;
- band[1] = band[0];
- band[0] += i;
- } while ( band >= bands );
- }
-
- return Smooth_Err_Ok;
- }
-
-
- static int
- gray_raster_render( FT_Raster raster,
- const FT_Raster_Params* params )
- {
- const FT_Outline* outline = (const FT_Outline*)params->source;
- const FT_Bitmap* target_map = params->target;
-
-#ifndef FT_STATIC_RASTER
- gray_TWorker worker[1];
-#endif
-
-
- if ( !raster )
- return FT_THROW( Invalid_Argument );
-
- /* this version does not support monochrome rendering */
- if ( !( params->flags & FT_RASTER_FLAG_AA ) )
- return FT_THROW( Cannot_Render_Glyph );
-
- if ( !outline )
- return FT_THROW( Invalid_Outline );
-
- /* return immediately if the outline is empty */
- if ( outline->n_points == 0 || outline->n_contours == 0 )
- return Smooth_Err_Ok;
-
- if ( !outline->contours || !outline->points )
- return FT_THROW( Invalid_Outline );
-
- if ( outline->n_points !=
- outline->contours[outline->n_contours - 1] + 1 )
- return FT_THROW( Invalid_Outline );
-
- ras.outline = *outline;
-
- if ( params->flags & FT_RASTER_FLAG_DIRECT )
- {
- if ( !params->gray_spans )
- return Smooth_Err_Ok;
-
- ras.render_span = (FT_Raster_Span_Func)params->gray_spans;
- ras.render_span_data = params->user;
-
- ras.cbox = params->clip_box;
- }
- else
- {
- /* if direct mode is not set, we must have a target bitmap */
- if ( !target_map )
- return FT_THROW( Invalid_Argument );
-
- /* nothing to do */
- if ( !target_map->width || !target_map->rows )
- return Smooth_Err_Ok;
-
- if ( !target_map->buffer )
- return FT_THROW( Invalid_Argument );
-
- if ( target_map->pitch < 0 )
- ras.target.origin = target_map->buffer;
- else
- ras.target.origin = target_map->buffer
- + ( target_map->rows - 1 ) * (unsigned int)target_map->pitch;
-
- ras.target.pitch = target_map->pitch;
-
- ras.render_span = (FT_Raster_Span_Func)NULL;
- ras.render_span_data = NULL;
-
- ras.cbox.xMin = 0;
- ras.cbox.yMin = 0;
- ras.cbox.xMax = (FT_Pos)target_map->width;
- ras.cbox.yMax = (FT_Pos)target_map->rows;
- }
-
- /* exit if nothing to do */
- if ( ras.cbox.xMin >= ras.cbox.xMax || ras.cbox.yMin >= ras.cbox.yMax )
- return Smooth_Err_Ok;
-
- return gray_convert_glyph( RAS_VAR );
- }
-
-
- /**** RASTER OBJECT CREATION: In stand-alone mode, we simply use *****/
- /**** a static object. *****/
-
-#ifdef STANDALONE_
-
- static int
- gray_raster_new( void* memory,
- FT_Raster* araster )
- {
- static gray_TRaster the_raster;
-
- FT_UNUSED( memory );
-
-
- *araster = (FT_Raster)&the_raster;
- FT_ZERO( &the_raster );
-
- return 0;
- }
-
-
- static void
- gray_raster_done( FT_Raster raster )
- {
- /* nothing */
- FT_UNUSED( raster );
- }
-
-#else /* !STANDALONE_ */
-
- static int
- gray_raster_new( void* memory_,
- FT_Raster* araster_ )
- {
- FT_Memory memory = (FT_Memory)memory_;
- gray_PRaster* araster = (gray_PRaster*)araster_;
-
- FT_Error error;
- gray_PRaster raster = NULL;
-
-
- if ( !FT_NEW( raster ) )
- raster->memory = memory;
-
- *araster = raster;
-
- return error;
- }
-
-
- static void
- gray_raster_done( FT_Raster raster )
- {
- FT_Memory memory = (FT_Memory)((gray_PRaster)raster)->memory;
-
-
- FT_FREE( raster );
- }
-
-#endif /* !STANDALONE_ */
-
-
- static void
- gray_raster_reset( FT_Raster raster,
- unsigned char* pool_base,
- unsigned long pool_size )
- {
- FT_UNUSED( raster );
- FT_UNUSED( pool_base );
- FT_UNUSED( pool_size );
- }
-
-
- static int
- gray_raster_set_mode( FT_Raster raster,
- unsigned long mode,
- void* args )
- {
- FT_UNUSED( raster );
- FT_UNUSED( mode );
- FT_UNUSED( args );
-
-
- return 0; /* nothing to do */
- }
-
-
- FT_DEFINE_RASTER_FUNCS(
- ft_grays_raster,
-
- FT_GLYPH_FORMAT_OUTLINE,
-
- (FT_Raster_New_Func) gray_raster_new, /* raster_new */
- (FT_Raster_Reset_Func) gray_raster_reset, /* raster_reset */
- (FT_Raster_Set_Mode_Func)gray_raster_set_mode, /* raster_set_mode */
- (FT_Raster_Render_Func) gray_raster_render, /* raster_render */
- (FT_Raster_Done_Func) gray_raster_done /* raster_done */
- )
-
-
-/* END */
-
-
-/* Local Variables: */
-/* coding: utf-8 */
-/* End: */
diff --git a/contrib/libs/freetype/src/smooth/ftgrays.h b/contrib/libs/freetype/src/smooth/ftgrays.h
deleted file mode 100644
index 1f4123bafd..0000000000
--- a/contrib/libs/freetype/src/smooth/ftgrays.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/****************************************************************************
- *
- * ftgrays.h
- *
- * FreeType smooth renderer declaration
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTGRAYS_H_
-#define FTGRAYS_H_
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-
-#ifdef STANDALONE_
-#error #include "ftimage.h"
-#else
-#include <ft2build.h>
-#include <freetype/ftimage.h>
-#endif
-
-
- /**************************************************************************
- *
- * To make ftgrays.h independent from configuration files we check
- * whether FT_EXPORT_VAR has been defined already.
- *
- * On some systems and compilers (Win32 mostly), an extra keyword is
- * necessary to compile the library as a DLL.
- */
-#ifndef FT_EXPORT_VAR
-#define FT_EXPORT_VAR( x ) extern x
-#endif
-
- FT_EXPORT_VAR( const FT_Raster_Funcs ) ft_grays_raster;
-
-
-#ifdef __cplusplus
- }
-#endif
-
-#endif /* FTGRAYS_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/smooth/ftsmerrs.h b/contrib/libs/freetype/src/smooth/ftsmerrs.h
deleted file mode 100644
index 6d41fb8e0f..0000000000
--- a/contrib/libs/freetype/src/smooth/ftsmerrs.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
- *
- * ftsmerrs.h
- *
- * smooth renderer error codes (specification only).
- *
- * Copyright (C) 2001-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /**************************************************************************
- *
- * This file is used to define the smooth renderer error enumeration
- * constants.
- *
- */
-
-#ifndef FTSMERRS_H_
-#define FTSMERRS_H_
-
-#include <freetype/ftmoderr.h>
-
-#undef FTERRORS_H_
-
-#undef FT_ERR_PREFIX
-#define FT_ERR_PREFIX Smooth_Err_
-#define FT_ERR_BASE FT_Mod_Err_Smooth
-
-#include <freetype/fterrors.h>
-
-#endif /* FTSMERRS_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/smooth/ftsmooth.c b/contrib/libs/freetype/src/smooth/ftsmooth.c
deleted file mode 100644
index f0acc1ea4a..0000000000
--- a/contrib/libs/freetype/src/smooth/ftsmooth.c
+++ /dev/null
@@ -1,605 +0,0 @@
-/****************************************************************************
- *
- * ftsmooth.c
- *
- * Anti-aliasing renderer interface (body).
- *
- * Copyright (C) 2000-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftobjs.h>
-#include <freetype/ftoutln.h>
-#include "ftsmooth.h"
-#include "ftgrays.h"
-
-#include "ftsmerrs.h"
-
-
- /* sets render-specific mode */
- static FT_Error
- ft_smooth_set_mode( FT_Renderer render,
- FT_ULong mode_tag,
- FT_Pointer data )
- {
- /* we simply pass it to the raster */
- return render->clazz->raster_class->raster_set_mode( render->raster,
- mode_tag,
- data );
- }
-
- /* transform a given glyph image */
- static FT_Error
- ft_smooth_transform( FT_Renderer render,
- FT_GlyphSlot slot,
- const FT_Matrix* matrix,
- const FT_Vector* delta )
- {
- FT_Error error = FT_Err_Ok;
-
-
- if ( slot->format != render->glyph_format )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- if ( matrix )
- FT_Outline_Transform( &slot->outline, matrix );
-
- if ( delta )
- FT_Outline_Translate( &slot->outline, delta->x, delta->y );
-
- Exit:
- return error;
- }
-
-
- /* return the glyph's control box */
- static void
- ft_smooth_get_cbox( FT_Renderer render,
- FT_GlyphSlot slot,
- FT_BBox* cbox )
- {
- FT_ZERO( cbox );
-
- if ( slot->format == render->glyph_format )
- FT_Outline_Get_CBox( &slot->outline, cbox );
- }
-
- typedef struct TOrigin_
- {
- unsigned char* origin; /* pixmap origin at the bottom-left */
- int pitch; /* pitch to go down one row */
-
- } TOrigin;
-
-#ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
-
- /* initialize renderer -- init its raster */
- static FT_Error
- ft_smooth_init( FT_Module module ) /* FT_Renderer */
- {
- FT_Renderer render = (FT_Renderer)module;
-
- FT_Vector* sub = render->root.library->lcd_geometry;
-
-
- /* set up default subpixel geometry for striped RGB panels. */
- sub[0].x = -21;
- sub[0].y = 0;
- sub[1].x = 0;
- sub[1].y = 0;
- sub[2].x = 21;
- sub[2].y = 0;
-
- render->clazz->raster_class->raster_reset( render->raster, NULL, 0 );
-
- return 0;
- }
-
-
- /* This function writes every third byte in direct rendering mode */
- static void
- ft_smooth_lcd_spans( int y,
- int count,
- const FT_Span* spans,
- void* target_ ) /* TOrigin* */
- {
- TOrigin* target = (TOrigin*)target_;
-
- unsigned char* dst_line = target->origin - y * target->pitch;
- unsigned char* dst;
- unsigned short w;
-
-
- for ( ; count--; spans++ )
- for ( dst = dst_line + spans->x * 3, w = spans->len; w--; dst += 3 )
- *dst = spans->coverage;
- }
-
-
- static FT_Error
- ft_smooth_raster_lcd( FT_Renderer render,
- FT_Outline* outline,
- FT_Bitmap* bitmap )
- {
- FT_Error error = FT_Err_Ok;
- FT_Vector* sub = render->root.library->lcd_geometry;
- FT_Pos x, y;
-
- FT_Raster_Params params;
- TOrigin target;
-
-
- /* Render 3 separate coverage bitmaps, shifting the outline. */
- /* Set up direct rendering to record them on each third byte. */
- params.source = outline;
- params.flags = FT_RASTER_FLAG_AA | FT_RASTER_FLAG_DIRECT;
- params.gray_spans = ft_smooth_lcd_spans;
- params.user = &target;
-
- params.clip_box.xMin = 0;
- params.clip_box.yMin = 0;
- params.clip_box.xMax = bitmap->width;
- params.clip_box.yMax = bitmap->rows;
-
- if ( bitmap->pitch < 0 )
- target.origin = bitmap->buffer;
- else
- target.origin = bitmap->buffer
- + ( bitmap->rows - 1 ) * (unsigned int)bitmap->pitch;
-
- target.pitch = bitmap->pitch;
-
- FT_Outline_Translate( outline,
- -sub[0].x,
- -sub[0].y );
- error = render->raster_render( render->raster, &params );
- x = sub[0].x;
- y = sub[0].y;
- if ( error )
- goto Exit;
-
- target.origin++;
- FT_Outline_Translate( outline,
- sub[0].x - sub[1].x,
- sub[0].y - sub[1].y );
- error = render->raster_render( render->raster, &params );
- x = sub[1].x;
- y = sub[1].y;
- if ( error )
- goto Exit;
-
- target.origin++;
- FT_Outline_Translate( outline,
- sub[1].x - sub[2].x,
- sub[1].y - sub[2].y );
- error = render->raster_render( render->raster, &params );
- x = sub[2].x;
- y = sub[2].y;
-
- Exit:
- FT_Outline_Translate( outline, x, y );
-
- return error;
- }
-
-
- static FT_Error
- ft_smooth_raster_lcdv( FT_Renderer render,
- FT_Outline* outline,
- FT_Bitmap* bitmap )
- {
- FT_Error error = FT_Err_Ok;
- int pitch = bitmap->pitch;
- FT_Vector* sub = render->root.library->lcd_geometry;
- FT_Pos x, y;
-
- FT_Raster_Params params;
-
-
- params.target = bitmap;
- params.source = outline;
- params.flags = FT_RASTER_FLAG_AA;
-
- /* Render 3 separate coverage bitmaps, shifting the outline. */
- /* Notice that the subpixel geometry vectors are rotated. */
- /* Triple the pitch to render on each third row. */
- bitmap->pitch *= 3;
- bitmap->rows /= 3;
-
- FT_Outline_Translate( outline,
- -sub[0].y,
- sub[0].x );
- error = render->raster_render( render->raster, &params );
- x = sub[0].y;
- y = -sub[0].x;
- if ( error )
- goto Exit;
-
- bitmap->buffer += pitch;
- FT_Outline_Translate( outline,
- sub[0].y - sub[1].y,
- sub[1].x - sub[0].x );
- error = render->raster_render( render->raster, &params );
- x = sub[1].y;
- y = -sub[1].x;
- bitmap->buffer -= pitch;
- if ( error )
- goto Exit;
-
- bitmap->buffer += 2 * pitch;
- FT_Outline_Translate( outline,
- sub[1].y - sub[2].y,
- sub[2].x - sub[1].x );
- error = render->raster_render( render->raster, &params );
- x = sub[2].y;
- y = -sub[2].x;
- bitmap->buffer -= 2 * pitch;
-
- Exit:
- FT_Outline_Translate( outline, x, y );
-
- bitmap->pitch /= 3;
- bitmap->rows *= 3;
-
- return error;
- }
-
-#else /* FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
-
- /* initialize renderer -- init its raster */
- static FT_Error
- ft_smooth_init( FT_Module module ) /* FT_Renderer */
- {
- FT_Renderer render = (FT_Renderer)module;
-
-
- /* set up default LCD filtering */
- FT_Library_SetLcdFilter( render->root.library, FT_LCD_FILTER_DEFAULT );
-
- render->clazz->raster_class->raster_reset( render->raster, NULL, 0 );
-
- return 0;
- }
-
-
- static FT_Error
- ft_smooth_raster_lcd( FT_Renderer render,
- FT_Outline* outline,
- FT_Bitmap* bitmap )
- {
- FT_Error error = FT_Err_Ok;
- FT_Vector* points = outline->points;
- FT_Vector* points_end = FT_OFFSET( points, outline->n_points );
- FT_Vector* vec;
-
- FT_Raster_Params params;
-
-
- params.target = bitmap;
- params.source = outline;
- params.flags = FT_RASTER_FLAG_AA;
-
- /* implode outline */
- for ( vec = points; vec < points_end; vec++ )
- vec->x *= 3;
-
- /* render outline into the bitmap */
- error = render->raster_render( render->raster, &params );
-
- /* deflate outline */
- for ( vec = points; vec < points_end; vec++ )
- vec->x /= 3;
-
- return error;
- }
-
-
- static FT_Error
- ft_smooth_raster_lcdv( FT_Renderer render,
- FT_Outline* outline,
- FT_Bitmap* bitmap )
- {
- FT_Error error = FT_Err_Ok;
- FT_Vector* points = outline->points;
- FT_Vector* points_end = FT_OFFSET( points, outline->n_points );
- FT_Vector* vec;
-
- FT_Raster_Params params;
-
-
- params.target = bitmap;
- params.source = outline;
- params.flags = FT_RASTER_FLAG_AA;
-
- /* implode outline */
- for ( vec = points; vec < points_end; vec++ )
- vec->y *= 3;
-
- /* render outline into the bitmap */
- error = render->raster_render( render->raster, &params );
-
- /* deflate outline */
- for ( vec = points; vec < points_end; vec++ )
- vec->y /= 3;
-
- return error;
- }
-
-#endif /* FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
-
-/* Oversampling scale to be used in rendering overlaps */
-#define SCALE ( 1 << 2 )
-
- /* This function averages inflated spans in direct rendering mode */
- static void
- ft_smooth_overlap_spans( int y,
- int count,
- const FT_Span* spans,
- void* target_ )
- {
- TOrigin* target = (TOrigin*)target_;
-
-
- unsigned char* dst = target->origin - ( y / SCALE ) * target->pitch;
- unsigned short x;
- unsigned int cover, sum;
-
-
- /* When accumulating the oversampled spans we need to assure that */
- /* fully covered pixels are equal to 255 and do not overflow. */
- /* It is important that the SCALE is a power of 2, each subpixel */
- /* cover can also reach a power of 2 after rounding, and the total */
- /* is clamped to 255 when it adds up to 256. */
- for ( ; count--; spans++ )
- {
- cover = ( spans->coverage + SCALE * SCALE / 2 ) / ( SCALE * SCALE );
- for ( x = 0; x < spans->len; x++ )
- {
- sum = dst[( spans->x + x ) / SCALE] + cover;
- dst[( spans->x + x ) / SCALE] = (unsigned char)( sum - ( sum >> 8 ) );
- }
- }
- }
-
-
- static FT_Error
- ft_smooth_raster_overlap( FT_Renderer render,
- FT_Outline* outline,
- FT_Bitmap* bitmap )
- {
- FT_Error error = FT_Err_Ok;
- FT_Vector* points = outline->points;
- FT_Vector* points_end = FT_OFFSET( points, outline->n_points );
- FT_Vector* vec;
-
- FT_Raster_Params params;
- TOrigin target;
-
-
- /* Reject outlines that are too wide for 16-bit FT_Span. */
- /* Other limits are applied upstream with the same error code. */
- if ( bitmap->width * SCALE > 0x7FFF )
- return FT_THROW( Raster_Overflow );
-
- /* Set up direct rendering to average oversampled spans. */
- params.source = outline;
- params.flags = FT_RASTER_FLAG_AA | FT_RASTER_FLAG_DIRECT;
- params.gray_spans = ft_smooth_overlap_spans;
- params.user = &target;
-
- params.clip_box.xMin = 0;
- params.clip_box.yMin = 0;
- params.clip_box.xMax = bitmap->width * SCALE;
- params.clip_box.yMax = bitmap->rows * SCALE;
-
- if ( bitmap->pitch < 0 )
- target.origin = bitmap->buffer;
- else
- target.origin = bitmap->buffer
- + ( bitmap->rows - 1 ) * (unsigned int)bitmap->pitch;
-
- target.pitch = bitmap->pitch;
-
- /* inflate outline */
- for ( vec = points; vec < points_end; vec++ )
- {
- vec->x *= SCALE;
- vec->y *= SCALE;
- }
-
- /* render outline into the bitmap */
- error = render->raster_render( render->raster, &params );
-
- /* deflate outline */
- for ( vec = points; vec < points_end; vec++ )
- {
- vec->x /= SCALE;
- vec->y /= SCALE;
- }
-
- return error;
- }
-
-#undef SCALE
-
- static FT_Error
- ft_smooth_render( FT_Renderer render,
- FT_GlyphSlot slot,
- FT_Render_Mode mode,
- const FT_Vector* origin )
- {
- FT_Error error = FT_Err_Ok;
- FT_Outline* outline = &slot->outline;
- FT_Bitmap* bitmap = &slot->bitmap;
- FT_Memory memory = render->root.memory;
- FT_Pos x_shift = 0;
- FT_Pos y_shift = 0;
-
-
- /* check glyph image format */
- if ( slot->format != render->glyph_format )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- /* check mode */
- if ( mode != FT_RENDER_MODE_NORMAL &&
- mode != FT_RENDER_MODE_LIGHT &&
- mode != FT_RENDER_MODE_LCD &&
- mode != FT_RENDER_MODE_LCD_V )
- {
- error = FT_THROW( Cannot_Render_Glyph );
- goto Exit;
- }
-
- /* release old bitmap buffer */
- if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
- {
- FT_FREE( bitmap->buffer );
- slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
- }
-
- if ( ft_glyphslot_preset_bitmap( slot, mode, origin ) )
- {
- error = FT_THROW( Raster_Overflow );
- goto Exit;
- }
-
- if ( !bitmap->rows || !bitmap->pitch )
- goto Exit;
-
- /* allocate new one */
- if ( FT_ALLOC_MULT( bitmap->buffer, bitmap->rows, bitmap->pitch ) )
- goto Exit;
-
- slot->internal->flags |= FT_GLYPH_OWN_BITMAP;
-
- x_shift = 64 * -slot->bitmap_left;
- y_shift = 64 * -slot->bitmap_top;
- if ( bitmap->pixel_mode == FT_PIXEL_MODE_LCD_V )
- y_shift += 64 * (FT_Int)bitmap->rows / 3;
- else
- y_shift += 64 * (FT_Int)bitmap->rows;
-
- if ( origin )
- {
- x_shift += origin->x;
- y_shift += origin->y;
- }
-
- /* translate outline to render it into the bitmap */
- if ( x_shift || y_shift )
- FT_Outline_Translate( outline, x_shift, y_shift );
-
- if ( mode == FT_RENDER_MODE_NORMAL ||
- mode == FT_RENDER_MODE_LIGHT )
- {
- if ( outline->flags & FT_OUTLINE_OVERLAP )
- error = ft_smooth_raster_overlap( render, outline, bitmap );
- else
- {
- FT_Raster_Params params;
-
-
- params.target = bitmap;
- params.source = outline;
- params.flags = FT_RASTER_FLAG_AA;
-
- error = render->raster_render( render->raster, &params );
- }
- }
- else
- {
- if ( mode == FT_RENDER_MODE_LCD )
- error = ft_smooth_raster_lcd ( render, outline, bitmap );
- else if ( mode == FT_RENDER_MODE_LCD_V )
- error = ft_smooth_raster_lcdv( render, outline, bitmap );
-
-#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
-
- /* finally apply filtering */
- {
- FT_Byte* lcd_weights;
- FT_Bitmap_LcdFilterFunc lcd_filter_func;
-
-
- /* Per-face LCD filtering takes priority if set up. */
- if ( slot->face && slot->face->internal->lcd_filter_func )
- {
- lcd_weights = slot->face->internal->lcd_weights;
- lcd_filter_func = slot->face->internal->lcd_filter_func;
- }
- else
- {
- lcd_weights = slot->library->lcd_weights;
- lcd_filter_func = slot->library->lcd_filter_func;
- }
-
- if ( lcd_filter_func )
- lcd_filter_func( bitmap, lcd_weights );
- }
-
-#endif /* FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
-
- }
-
- Exit:
- if ( !error )
- {
- /* everything is fine; the glyph is now officially a bitmap */
- slot->format = FT_GLYPH_FORMAT_BITMAP;
- }
- else if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
- {
- FT_FREE( bitmap->buffer );
- slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
- }
-
- if ( x_shift || y_shift )
- FT_Outline_Translate( outline, -x_shift, -y_shift );
-
- return error;
- }
-
-
- FT_DEFINE_RENDERER(
- ft_smooth_renderer_class,
-
- FT_MODULE_RENDERER,
- sizeof ( FT_RendererRec ),
-
- "smooth",
- 0x10000L,
- 0x20000L,
-
- NULL, /* module specific interface */
-
- (FT_Module_Constructor)ft_smooth_init, /* module_init */
- (FT_Module_Destructor) NULL, /* module_done */
- (FT_Module_Requester) NULL, /* get_interface */
-
- FT_GLYPH_FORMAT_OUTLINE,
-
- (FT_Renderer_RenderFunc) ft_smooth_render, /* render_glyph */
- (FT_Renderer_TransformFunc)ft_smooth_transform, /* transform_glyph */
- (FT_Renderer_GetCBoxFunc) ft_smooth_get_cbox, /* get_glyph_cbox */
- (FT_Renderer_SetModeFunc) ft_smooth_set_mode, /* set_mode */
-
- (FT_Raster_Funcs*)&ft_grays_raster /* raster_class */
- )
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/smooth/ftsmooth.h b/contrib/libs/freetype/src/smooth/ftsmooth.h
deleted file mode 100644
index d7b61a9e60..0000000000
--- a/contrib/libs/freetype/src/smooth/ftsmooth.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/****************************************************************************
- *
- * ftsmooth.h
- *
- * Anti-aliasing renderer interface (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef FTSMOOTH_H_
-#define FTSMOOTH_H_
-
-
-#include <freetype/ftrender.h>
-
-
-FT_BEGIN_HEADER
-
-
- FT_DECLARE_RENDERER( ft_smooth_renderer_class )
-
-
-FT_END_HEADER
-
-#endif /* FTSMOOTH_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/smooth/smooth.c b/contrib/libs/freetype/src/smooth/smooth.c
deleted file mode 100644
index 8c5068180e..0000000000
--- a/contrib/libs/freetype/src/smooth/smooth.c
+++ /dev/null
@@ -1,25 +0,0 @@
-/****************************************************************************
- *
- * smooth.c
- *
- * FreeType anti-aliasing rasterer module component (body only).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#define FT_MAKE_OPTION_SINGLE_OBJECT
-
-#include "ftgrays.c"
-#include "ftsmooth.c"
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/svg/ftsvg.c b/contrib/libs/freetype/src/svg/ftsvg.c
deleted file mode 100644
index 35788a2d8d..0000000000
--- a/contrib/libs/freetype/src/svg/ftsvg.c
+++ /dev/null
@@ -1,355 +0,0 @@
-/****************************************************************************
- *
- * ftsvg.c
- *
- * The FreeType SVG renderer interface (body).
- *
- * Copyright (C) 2022-2024 by
- * David Turner, Robert Wilhelm, Werner Lemberg, and Moazin Khatti.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftserv.h>
-#include <freetype/internal/services/svprop.h>
-#include <freetype/otsvg.h>
-#include <freetype/internal/svginterface.h>
-#include <freetype/ftbbox.h>
-
-#include "ftsvg.h"
-#include "svgtypes.h"
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, usued to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT otsvg
-
-
-#ifdef FT_CONFIG_OPTION_SVG
-
- /* ft_svg_init */
- static FT_Error
- ft_svg_init( FT_Module module )
- {
- SVG_Renderer render = (SVG_Renderer)module;
-
- FT_Error error = FT_Err_Ok;
-
-
- render->loaded = FALSE;
- render->hooks_set = FALSE;
-
- return error;
- }
-
-
- static void
- ft_svg_done( FT_Module module )
- {
- SVG_Renderer render = (SVG_Renderer)module;
-
-
- if ( render->loaded == TRUE &&
- render->hooks_set == TRUE )
- render->hooks.free_svg( &render->state );
-
- render->loaded = FALSE;
- }
-
-
- static FT_Error
- ft_svg_preset_slot( FT_Module module,
- FT_GlyphSlot slot,
- FT_Bool cache )
- {
- SVG_Renderer svg_renderer = (SVG_Renderer)module;
- SVG_RendererHooks hooks = svg_renderer->hooks;
-
-
- if ( svg_renderer->hooks_set == FALSE )
- {
- FT_TRACE1(( "Hooks are NOT set. Can't render OT-SVG glyphs\n" ));
- return FT_THROW( Missing_SVG_Hooks );
- }
-
- if ( svg_renderer->loaded == FALSE )
- {
- FT_TRACE3(( "ft_svg_preset_slot: first presetting call,"
- " calling init hook\n" ));
- hooks.init_svg( &svg_renderer->state );
-
- svg_renderer->loaded = TRUE;
- }
-
- return hooks.preset_slot( slot, cache, &svg_renderer->state );
- }
-
-
- static FT_Error
- ft_svg_render( FT_Renderer renderer,
- FT_GlyphSlot slot,
- FT_Render_Mode mode,
- const FT_Vector* origin )
- {
- SVG_Renderer svg_renderer = (SVG_Renderer)renderer;
-
- FT_Library library = renderer->root.library;
- FT_Memory memory = library->memory;
- FT_Error error;
-
- FT_ULong size_image_buffer;
-
- SVG_RendererHooks hooks = svg_renderer->hooks;
-
-
- FT_UNUSED( mode );
- FT_UNUSED( origin );
-
- if ( mode != FT_RENDER_MODE_NORMAL )
- return FT_THROW( Bad_Argument );
-
- if ( svg_renderer->hooks_set == FALSE )
- {
- FT_TRACE1(( "Hooks are NOT set. Can't render OT-SVG glyphs\n" ));
- return FT_THROW( Missing_SVG_Hooks );
- }
-
- if ( svg_renderer->loaded == FALSE )
- {
- FT_TRACE3(( "ft_svg_render: first rendering, calling init hook\n" ));
- error = hooks.init_svg( &svg_renderer->state );
-
- svg_renderer->loaded = TRUE;
- }
-
- ft_svg_preset_slot( (FT_Module)renderer, slot, TRUE );
-
- size_image_buffer = (FT_ULong)slot->bitmap.pitch * slot->bitmap.rows;
- /* No `FT_QALLOC` here since we need a clean, empty canvas */
- /* to start with. */
- if ( FT_ALLOC( slot->bitmap.buffer, size_image_buffer ) )
- return error;
-
- error = hooks.render_svg( slot, &svg_renderer->state );
- if ( error )
- FT_FREE( slot->bitmap.buffer );
- else
- slot->internal->flags |= FT_GLYPH_OWN_BITMAP;
-
- return error;
- }
-
-
- static const SVG_Interface svg_interface =
- {
- ft_svg_preset_slot /* Preset_Bitmap_Func preset_slot */
- };
-
-
- static FT_Error
- ft_svg_property_set( FT_Module module,
- const char* property_name,
- const void* value,
- FT_Bool value_is_string )
- {
- FT_Error error = FT_Err_Ok;
- SVG_Renderer renderer = (SVG_Renderer)module;
-
-
- if ( !ft_strcmp( property_name, "svg-hooks" ) )
- {
- SVG_RendererHooks* hooks;
-
-
- if ( value_is_string == TRUE )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- hooks = (SVG_RendererHooks*)value;
-
- if ( !hooks->init_svg ||
- !hooks->free_svg ||
- !hooks->render_svg ||
- !hooks->preset_slot )
- {
- FT_TRACE0(( "ft_svg_property_set:"
- " SVG rendering hooks not set because\n" ));
- FT_TRACE0(( " "
- " at least one function pointer is NULL\n" ));
-
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- renderer->hooks = *hooks;
- renderer->hooks_set = TRUE;
- }
- else
- error = FT_THROW( Missing_Property );
-
- Exit:
- return error;
- }
-
-
- static FT_Error
- ft_svg_property_get( FT_Module module,
- const char* property_name,
- void* value )
- {
- FT_Error error = FT_Err_Ok;
- SVG_Renderer renderer = (SVG_Renderer)module;
-
-
- if ( !ft_strcmp( property_name, "svg-hooks" ) )
- {
- SVG_RendererHooks* hooks = (SVG_RendererHooks*)value;
-
-
- *hooks = renderer->hooks;
- }
- else
- error = FT_THROW( Missing_Property );
-
- return error;
- }
-
-
- FT_DEFINE_SERVICE_PROPERTIESREC(
- ft_svg_service_properties,
-
- ft_svg_property_set, /* FT_Properties_SetFunc set_property */
- ft_svg_property_get /* FT_Properties_GetFunc get_property */
- )
-
-
- FT_DEFINE_SERVICEDESCREC1(
- ft_svg_services,
- FT_SERVICE_ID_PROPERTIES, &ft_svg_service_properties )
-
-
- FT_CALLBACK_DEF( FT_Module_Interface )
- ft_svg_get_interface( FT_Module module,
- const char* ft_svg_interface )
- {
- FT_Module_Interface result;
-
-
- FT_UNUSED( module );
-
- result = ft_service_list_lookup( ft_svg_services, ft_svg_interface );
- if ( result )
- return result;
-
- return 0;
- }
-
-
- static FT_Error
- ft_svg_transform( FT_Renderer renderer,
- FT_GlyphSlot slot,
- const FT_Matrix* _matrix,
- const FT_Vector* _delta )
- {
- FT_SVG_Document doc = (FT_SVG_Document)slot->other;
- FT_Matrix* matrix = (FT_Matrix*)_matrix;
- FT_Vector* delta = (FT_Vector*)_delta;
-
- FT_Matrix tmp_matrix;
- FT_Vector tmp_delta;
-
- FT_Matrix a, b;
- FT_Pos x, y;
-
-
- FT_UNUSED( renderer );
-
- if ( !matrix )
- {
- tmp_matrix.xx = 0x10000;
- tmp_matrix.xy = 0;
- tmp_matrix.yx = 0;
- tmp_matrix.yy = 0x10000;
-
- matrix = &tmp_matrix;
- }
-
- if ( !delta )
- {
- tmp_delta.x = 0;
- tmp_delta.y = 0;
-
- delta = &tmp_delta;
- }
-
- a = doc->transform;
- b = *matrix;
- FT_Matrix_Multiply( &b, &a );
-
-
- x = ADD_LONG( ADD_LONG( FT_MulFix( matrix->xx, doc->delta.x ),
- FT_MulFix( matrix->xy, doc->delta.y ) ),
- delta->x );
- y = ADD_LONG( ADD_LONG( FT_MulFix( matrix->yx, doc->delta.x ),
- FT_MulFix( matrix->yy, doc->delta.y ) ),
- delta->y );
-
- doc->delta.x = x;
- doc->delta.y = y;
- doc->transform = a;
-
- return FT_Err_Ok;
- }
-
-#endif /* FT_CONFIG_OPTION_SVG */
-
-
-#ifdef FT_CONFIG_OPTION_SVG
-#define PUT_SVG_MODULE( a ) a
-#define SVG_GLYPH_FORMAT FT_GLYPH_FORMAT_SVG
-#else
-#define PUT_SVG_MODULE( a ) NULL
-#define SVG_GLYPH_FORMAT FT_GLYPH_FORMAT_NONE
-#endif
-
-
- FT_DEFINE_RENDERER(
- ft_svg_renderer_class,
-
- FT_MODULE_RENDERER,
- sizeof ( SVG_RendererRec ),
-
- "ot-svg",
- 0x10000L,
- 0x20000L,
-
- (const void*)PUT_SVG_MODULE( &svg_interface ), /* module specific interface */
-
- PUT_SVG_MODULE( ft_svg_init ), /* FT_Module_Constructor module_init */
- PUT_SVG_MODULE( ft_svg_done ), /* FT_Module_Destructor module_done */
- PUT_SVG_MODULE( ft_svg_get_interface ), /* FT_Module_Requester get_interface */
-
- SVG_GLYPH_FORMAT,
-
- PUT_SVG_MODULE( ft_svg_render ), /* FT_Renderer_RenderFunc render_glyph */
- PUT_SVG_MODULE( ft_svg_transform ), /* FT_Renderer_TransformFunc transform_glyph */
- NULL, /* FT_Renderer_GetCBoxFunc get_glyph_cbox */
- NULL, /* FT_Renderer_SetModeFunc set_mode */
- NULL /* FT_Raster_Funcs* raster_class */
- )
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/svg/ftsvg.h b/contrib/libs/freetype/src/svg/ftsvg.h
deleted file mode 100644
index 623c091dc6..0000000000
--- a/contrib/libs/freetype/src/svg/ftsvg.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/****************************************************************************
- *
- * ftsvg.h
- *
- * The FreeType SVG renderer interface (specification).
- *
- * Copyright (C) 2022-2024 by
- * David Turner, Robert Wilhelm, Werner Lemberg, and Moazin Khatti.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-#ifndef FTSVG_H_
-#define FTSVG_H_
-
-#include <ft2build.h>
-#include <freetype/ftrender.h>
-#include <freetype/internal/ftobjs.h>
-
-
-FT_BEGIN_HEADER
-
- FT_DECLARE_RENDERER( ft_svg_renderer_class )
-
-FT_END_HEADER
-
-#endif /* FTSVG_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/svg/svg.c b/contrib/libs/freetype/src/svg/svg.c
deleted file mode 100644
index 1f1c04b2f2..0000000000
--- a/contrib/libs/freetype/src/svg/svg.c
+++ /dev/null
@@ -1,24 +0,0 @@
-/****************************************************************************
- *
- * svg.c
- *
- * FreeType SVG renderer module component (body only).
- *
- * Copyright (C) 2022-2024 by
- * David Turner, Robert Wilhelm, Werner Lemberg, and Moazin Khatti.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-#define FT_MAKE_OPTION_SINGLE_OBJECT
-
-#include "svgtypes.h"
-#include "ftsvg.c"
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/svg/svgtypes.h b/contrib/libs/freetype/src/svg/svgtypes.h
deleted file mode 100644
index f1d6d73c54..0000000000
--- a/contrib/libs/freetype/src/svg/svgtypes.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
- *
- * svgtypes.h
- *
- * The FreeType SVG renderer internal types (specification).
- *
- * Copyright (C) 2022-2024 by
- * David Turner, Robert Wilhelm, Werner Lemberg, and Moazin Khatti.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-#ifndef SVGTYPES_H_
-#define SVGTYPES_H_
-
-#include <ft2build.h>
-#include <freetype/internal/ftobjs.h>
-#include <freetype/ftrender.h>
-#include <freetype/otsvg.h>
-
-
- typedef struct SVG_RendererRec_
- {
- FT_RendererRec root; /* this inherits FT_RendererRec */
- FT_Bool loaded;
- FT_Bool hooks_set;
- SVG_RendererHooks hooks; /* this holds hooks for SVG rendering */
- FT_Pointer state; /* a place for hooks to store state, if needed */
-
- } SVG_RendererRec;
-
- typedef struct SVG_RendererRec_* SVG_Renderer;
-
-#endif /* SVGTYPES_H_ */
-
-
-/* EOF */
diff --git a/contrib/libs/freetype/src/truetype/truetype.c b/contrib/libs/freetype/src/truetype/truetype.c
deleted file mode 100644
index fe9cb9247a..0000000000
--- a/contrib/libs/freetype/src/truetype/truetype.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/****************************************************************************
- *
- * truetype.c
- *
- * FreeType TrueType driver component (body only).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#define FT_MAKE_OPTION_SINGLE_OBJECT
-
-#include "ttdriver.c" /* driver interface */
-#include "ttgload.c" /* glyph loader */
-#include "ttgxvar.c" /* gx distortable font */
-#include "ttinterp.c"
-#include "ttobjs.c" /* object manager */
-#include "ttpload.c" /* tables loader */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/truetype/ttdriver.c b/contrib/libs/freetype/src/truetype/ttdriver.c
deleted file mode 100644
index 4ab68eb9a1..0000000000
--- a/contrib/libs/freetype/src/truetype/ttdriver.c
+++ /dev/null
@@ -1,704 +0,0 @@
-/****************************************************************************
- *
- * ttdriver.c
- *
- * TrueType font driver implementation (body).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/internal/sfnt.h>
-#include <freetype/internal/services/svfntfmt.h>
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
-#include <freetype/ftmm.h>
-#include <freetype/internal/services/svmm.h>
-#include <freetype/internal/services/svmetric.h>
-#endif
-
-#include <freetype/internal/services/svtteng.h>
-#include <freetype/internal/services/svttglyf.h>
-#include <freetype/internal/services/svprop.h>
-#include <freetype/ftdriver.h>
-
-#include "ttdriver.h"
-#include "ttgload.h"
-#include "ttpload.h"
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
-#include "ttgxvar.h"
-#endif
-
-#include "tterrors.h"
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT ttdriver
-
-
- /*
- * PROPERTY SERVICE
- *
- */
- FT_CALLBACK_DEF( FT_Error )
- tt_property_set( FT_Module module, /* TT_Driver */
- const char* property_name,
- const void* value,
- FT_Bool value_is_string )
- {
- FT_Error error = FT_Err_Ok;
- TT_Driver driver = (TT_Driver)module;
-
-#ifndef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
- FT_UNUSED( value_is_string );
-#endif
-
-
- if ( !ft_strcmp( property_name, "interpreter-version" ) )
- {
- FT_UInt interpreter_version;
-
-
-#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
- if ( value_is_string )
- {
- const char* s = (const char*)value;
-
-
- interpreter_version = (FT_UInt)ft_strtol( s, NULL, 10 );
- }
- else
-#endif
- {
- FT_UInt* iv = (FT_UInt*)value;
-
-
- interpreter_version = *iv;
- }
-
- switch ( interpreter_version )
- {
- case TT_INTERPRETER_VERSION_35:
- driver->interpreter_version = TT_INTERPRETER_VERSION_35;
- break;
-
- case TT_INTERPRETER_VERSION_38:
- case TT_INTERPRETER_VERSION_40:
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- driver->interpreter_version = TT_INTERPRETER_VERSION_40;
- break;
-#endif
-
- default:
- error = FT_ERR( Unimplemented_Feature );
- }
-
- return error;
- }
-
- FT_TRACE2(( "tt_property_set: missing property `%s'\n",
- property_name ));
- return FT_THROW( Missing_Property );
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- tt_property_get( FT_Module module, /* TT_Driver */
- const char* property_name,
- void* value )
- {
- FT_Error error = FT_Err_Ok;
- TT_Driver driver = (TT_Driver)module;
-
- FT_UInt interpreter_version = driver->interpreter_version;
-
-
- if ( !ft_strcmp( property_name, "interpreter-version" ) )
- {
- FT_UInt* val = (FT_UInt*)value;
-
-
- *val = interpreter_version;
-
- return error;
- }
-
- FT_TRACE2(( "tt_property_get: missing property `%s'\n",
- property_name ));
- return FT_THROW( Missing_Property );
- }
-
-
- FT_DEFINE_SERVICE_PROPERTIESREC(
- tt_service_properties,
-
- tt_property_set, /* FT_Properties_SetFunc set_property */
- tt_property_get /* FT_Properties_GetFunc get_property */
- )
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /**** ****/
- /**** ****/
- /**** F A C E S ****/
- /**** ****/
- /**** ****/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /**************************************************************************
- *
- * @Function:
- * tt_get_kerning
- *
- * @Description:
- * A driver method used to return the kerning vector between two
- * glyphs of the same face.
- *
- * @Input:
- * face ::
- * A handle to the source face object.
- *
- * left_glyph ::
- * The index of the left glyph in the kern pair.
- *
- * right_glyph ::
- * The index of the right glyph in the kern pair.
- *
- * @Output:
- * kerning ::
- * The kerning vector. This is in font units for
- * scalable formats, and in pixels for fixed-sizes
- * formats.
- *
- * @Return:
- * FreeType error code. 0 means success.
- *
- * @Note:
- * Only horizontal layouts (left-to-right & right-to-left) are
- * supported by this function. Other layouts, or more sophisticated
- * kernings, are out of scope of this method (the basic driver
- * interface is meant to be simple).
- *
- * They can be implemented by format-specific interfaces.
- */
- FT_CALLBACK_DEF( FT_Error )
- tt_get_kerning( FT_Face face, /* TT_Face */
- FT_UInt left_glyph,
- FT_UInt right_glyph,
- FT_Vector* kerning )
- {
- TT_Face ttface = (TT_Face)face;
- SFNT_Service sfnt = (SFNT_Service)ttface->sfnt;
-
-
- kerning->x = 0;
- kerning->y = 0;
-
- if ( sfnt )
- {
- /* Use 'kern' table if available since that can be faster; otherwise */
- /* use GPOS kerning pairs if available. */
- if ( ttface->kern_avail_bits != 0 )
- kerning->x = sfnt->get_kerning( ttface,
- left_glyph,
- right_glyph );
-#ifdef TT_CONFIG_OPTION_GPOS_KERNING
- else if ( ttface->gpos_kerning_available )
- kerning->x = sfnt->get_gpos_kerning( ttface,
- left_glyph,
- right_glyph );
-#endif
- }
-
- return 0;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- tt_get_advances( FT_Face face, /* TT_Face */
- FT_UInt start,
- FT_UInt count,
- FT_Int32 flags,
- FT_Fixed *advances )
- {
- FT_UInt nn;
- TT_Face ttface = (TT_Face)face;
-
-
- /* XXX: TODO: check for sbits */
-
- if ( flags & FT_LOAD_VERTICAL_LAYOUT )
- {
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- /* no fast retrieval for blended MM fonts without VVAR table */
- if ( ( FT_IS_NAMED_INSTANCE( face ) || FT_IS_VARIATION( face ) ) &&
- !( ttface->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) )
- return FT_THROW( Unimplemented_Feature );
-#endif
-
- for ( nn = 0; nn < count; nn++ )
- {
- FT_Short tsb;
- FT_UShort ah;
-
-
- /* since we don't need `tsb', we use zero for `yMax' parameter */
- TT_Get_VMetrics( ttface, start + nn, 0, &tsb, &ah );
- advances[nn] = ah;
- }
- }
- else
- {
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- /* no fast retrieval for blended MM fonts without HVAR table */
- if ( ( FT_IS_NAMED_INSTANCE( face ) || FT_IS_VARIATION( face ) ) &&
- !( ttface->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) )
- return FT_THROW( Unimplemented_Feature );
-#endif
-
- for ( nn = 0; nn < count; nn++ )
- {
- FT_Short lsb;
- FT_UShort aw;
-
-
- TT_Get_HMetrics( ttface, start + nn, &lsb, &aw );
- advances[nn] = aw;
- }
- }
-
- return FT_Err_Ok;
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /**** ****/
- /**** ****/
- /**** S I Z E S ****/
- /**** ****/
- /**** ****/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
-#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
-
- FT_CALLBACK_DEF( FT_Error )
- tt_size_select( FT_Size size,
- FT_ULong strike_index )
- {
- TT_Face ttface = (TT_Face)size->face;
- TT_Size ttsize = (TT_Size)size;
- FT_Error error = FT_Err_Ok;
-
-
- ttsize->strike_index = strike_index;
-
- if ( FT_IS_SCALABLE( size->face ) )
- {
- /* use the scaled metrics, even when tt_size_reset fails */
- FT_Select_Metrics( size->face, strike_index );
-
- tt_size_reset( ttsize ); /* ignore return value */
- }
- else
- {
- SFNT_Service sfnt = (SFNT_Service)ttface->sfnt;
- FT_Size_Metrics* size_metrics = &size->metrics;
-
-
- error = sfnt->load_strike_metrics( ttface,
- strike_index,
- size_metrics );
- if ( error )
- ttsize->strike_index = 0xFFFFFFFFUL;
- }
-
- return error;
- }
-
-#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
-
-
- FT_CALLBACK_DEF( FT_Error )
- tt_size_request( FT_Size size,
- FT_Size_Request req )
- {
- TT_Size ttsize = (TT_Size)size;
- FT_Error error = FT_Err_Ok;
-
-
-#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
-
- if ( FT_HAS_FIXED_SIZES( size->face ) )
- {
- TT_Face ttface = (TT_Face)size->face;
- SFNT_Service sfnt = (SFNT_Service)ttface->sfnt;
- FT_ULong strike_index;
-
-
- error = sfnt->set_sbit_strike( ttface, req, &strike_index );
-
- if ( error )
- ttsize->strike_index = 0xFFFFFFFFUL;
- else
- return tt_size_select( size, strike_index );
- }
-
-#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
-
- {
- FT_Error err = FT_Request_Metrics( size->face, req );
-
-
- if ( err )
- {
- error = err;
- goto Exit;
- }
- }
-
- if ( FT_IS_SCALABLE( size->face ) )
- {
- error = tt_size_reset( ttsize );
-
-#ifdef TT_USE_BYTECODE_INTERPRETER
- /* for the `MPS' bytecode instruction we need the point size */
- if ( !error )
- {
- FT_UInt resolution =
- ttsize->metrics->x_ppem > ttsize->metrics->y_ppem
- ? req->horiResolution
- : req->vertResolution;
-
-
- /* if we don't have a resolution value, assume 72dpi */
- if ( req->type == FT_SIZE_REQUEST_TYPE_SCALES ||
- !resolution )
- resolution = 72;
-
- ttsize->point_size = FT_MulDiv( ttsize->ttmetrics.ppem,
- 64 * 72,
- resolution );
- }
-#endif
- }
-
- Exit:
- return error;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * tt_glyph_load
- *
- * @Description:
- * A driver method used to load a glyph within a given glyph slot.
- *
- * @Input:
- * slot ::
- * A handle to the target slot object where the glyph
- * will be loaded.
- *
- * size ::
- * A handle to the source face size at which the glyph
- * must be scaled, loaded, etc.
- *
- * glyph_index ::
- * The index of the glyph in the font file.
- *
- * load_flags ::
- * A flag indicating what to load for this glyph. The
- * FT_LOAD_XXX constants can be used to control the
- * glyph loading process (e.g., whether the outline
- * should be scaled, whether to load bitmaps or not,
- * whether to hint the outline, etc).
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
- FT_CALLBACK_DEF( FT_Error )
- tt_glyph_load( FT_GlyphSlot slot, /* TT_GlyphSlot */
- FT_Size size, /* TT_Size */
- FT_UInt glyph_index,
- FT_Int32 load_flags )
- {
- TT_GlyphSlot ttslot = (TT_GlyphSlot)slot;
- TT_Size ttsize = (TT_Size)size;
- FT_Face face = ttslot->face;
- FT_Error error;
-
-
- if ( !slot )
- return FT_THROW( Invalid_Slot_Handle );
-
- if ( !size )
- return FT_THROW( Invalid_Size_Handle );
-
- if ( !face )
- return FT_THROW( Invalid_Face_Handle );
-
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- if ( glyph_index >= (FT_UInt)face->num_glyphs &&
- !face->internal->incremental_interface )
-#else
- if ( glyph_index >= (FT_UInt)face->num_glyphs )
-#endif
- return FT_THROW( Invalid_Argument );
-
- if ( load_flags & FT_LOAD_NO_HINTING )
- {
- /* both FT_LOAD_NO_HINTING and FT_LOAD_NO_AUTOHINT */
- /* are necessary to disable hinting for tricky fonts */
-
- if ( FT_IS_TRICKY( face ) )
- load_flags &= ~FT_LOAD_NO_HINTING;
-
- if ( load_flags & FT_LOAD_NO_AUTOHINT )
- load_flags |= FT_LOAD_NO_HINTING;
- }
-
- if ( load_flags & ( FT_LOAD_NO_RECURSE | FT_LOAD_NO_SCALE ) )
- {
- load_flags |= FT_LOAD_NO_BITMAP | FT_LOAD_NO_SCALE;
-
- if ( !FT_IS_TRICKY( face ) )
- load_flags |= FT_LOAD_NO_HINTING;
- }
-
- /* use hinted metrics only if we load a glyph with hinting */
- ttsize->metrics = ( load_flags & FT_LOAD_NO_HINTING )
- ? &size->metrics
- : &ttsize->hinted_metrics;
-
- /* now fill in the glyph slot with outline/bitmap/layered */
- error = TT_Load_Glyph( ttsize, ttslot, glyph_index, load_flags );
-
- /* force drop-out mode to 2 - irrelevant now */
- /* slot->outline.dropout_mode = 2; */
-
- return error;
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /**** ****/
- /**** ****/
- /**** D R I V E R I N T E R F A C E ****/
- /**** ****/
- /**** ****/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
-
- FT_DEFINE_SERVICE_MULTIMASTERSREC(
- tt_service_gx_multi_masters,
-
- NULL, /* FT_Get_MM_Func get_mm */
- NULL, /* FT_Set_MM_Design_Func set_mm_design */
- TT_Set_MM_Blend, /* FT_Set_MM_Blend_Func set_mm_blend */
- TT_Get_MM_Blend, /* FT_Get_MM_Blend_Func get_mm_blend */
- TT_Get_MM_Var, /* FT_Get_MM_Var_Func get_mm_var */
- TT_Set_Var_Design, /* FT_Set_Var_Design_Func set_var_design */
- TT_Get_Var_Design, /* FT_Get_Var_Design_Func get_var_design */
- TT_Set_Named_Instance, /* FT_Set_Named_Instance_Func set_named_instance */
- TT_Get_Default_Named_Instance,
- /* FT_Get_Default_Named_Instance_Func get_default_named_instance */
- NULL, /* FT_Set_MM_WeightVector_Func set_mm_weightvector */
- NULL, /* FT_Get_MM_WeightVector_Func get_mm_weightvector */
-
- tt_construct_ps_name, /* FT_Construct_PS_Name_Func construct_ps_name */
- tt_var_load_delta_set_index_mapping,
- /* FT_Var_Load_Delta_Set_Idx_Map_Func load_delta_set_idx_map */
- tt_var_load_item_variation_store,
- /* FT_Var_Load_Item_Var_Store_Func load_item_variation_store */
- tt_var_get_item_delta, /* FT_Var_Get_Item_Delta_Func get_item_delta */
- tt_var_done_item_variation_store,
- /* FT_Var_Done_Item_Var_Store_Func done_item_variation_store */
- tt_var_done_delta_set_index_map,
- /* FT_Var_Done_Delta_Set_Idx_Map_Func done_delta_set_index_map */
- tt_get_var_blend, /* FT_Get_Var_Blend_Func get_var_blend */
- tt_done_blend /* FT_Done_Blend_Func done_blend */
- )
-
- FT_DEFINE_SERVICE_METRICSVARIATIONSREC(
- tt_service_metrics_variations,
-
- tt_hadvance_adjust, /* FT_HAdvance_Adjust_Func hadvance_adjust */
- NULL, /* FT_LSB_Adjust_Func lsb_adjust */
- NULL, /* FT_RSB_Adjust_Func rsb_adjust */
-
- tt_vadvance_adjust, /* FT_VAdvance_Adjust_Func vadvance_adjust */
- NULL, /* FT_TSB_Adjust_Func tsb_adjust */
- NULL, /* FT_BSB_Adjust_Func bsb_adjust */
- NULL, /* FT_VOrg_Adjust_Func vorg_adjust */
-
- tt_apply_mvar, /* FT_Metrics_Adjust_Func metrics_adjust */
- tt_size_reset_height /* FT_Size_Reset_Func size_reset */
- )
-
-#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
-
-
- static const FT_Service_TrueTypeEngineRec tt_service_truetype_engine =
- {
-#ifdef TT_USE_BYTECODE_INTERPRETER
-
- FT_TRUETYPE_ENGINE_TYPE_PATENTED
-
-#else /* !TT_USE_BYTECODE_INTERPRETER */
-
- FT_TRUETYPE_ENGINE_TYPE_NONE
-
-#endif /* TT_USE_BYTECODE_INTERPRETER */
- };
-
-
- FT_DEFINE_SERVICE_TTGLYFREC(
- tt_service_truetype_glyf,
-
- (TT_Glyf_GetLocationFunc)tt_face_get_location /* get_location */
- )
-
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- FT_DEFINE_SERVICEDESCREC6(
- tt_services,
-
- FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_TRUETYPE,
- FT_SERVICE_ID_MULTI_MASTERS, &tt_service_gx_multi_masters,
- FT_SERVICE_ID_METRICS_VARIATIONS, &tt_service_metrics_variations,
- FT_SERVICE_ID_TRUETYPE_ENGINE, &tt_service_truetype_engine,
- FT_SERVICE_ID_TT_GLYF, &tt_service_truetype_glyf,
- FT_SERVICE_ID_PROPERTIES, &tt_service_properties )
-#else
- FT_DEFINE_SERVICEDESCREC4(
- tt_services,
-
- FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_TRUETYPE,
- FT_SERVICE_ID_TRUETYPE_ENGINE, &tt_service_truetype_engine,
- FT_SERVICE_ID_TT_GLYF, &tt_service_truetype_glyf,
- FT_SERVICE_ID_PROPERTIES, &tt_service_properties )
-#endif
-
-
- FT_CALLBACK_DEF( FT_Module_Interface )
- tt_get_interface( FT_Module driver, /* TT_Driver */
- const char* tt_interface )
- {
- FT_Library library;
- FT_Module_Interface result;
- FT_Module sfntd;
- SFNT_Service sfnt;
-
-
- result = ft_service_list_lookup( tt_services, tt_interface );
- if ( result )
- return result;
-
- if ( !driver )
- return NULL;
- library = driver->library;
- if ( !library )
- return NULL;
-
- /* only return the default interface from the SFNT module */
- sfntd = FT_Get_Module( library, "sfnt" );
- if ( sfntd )
- {
- sfnt = (SFNT_Service)( sfntd->clazz->module_interface );
- if ( sfnt )
- return sfnt->get_interface( driver, tt_interface );
- }
-
- return 0;
- }
-
-
- /* The FT_DriverInterface structure is defined in ftdriver.h. */
-
-#ifdef TT_USE_BYTECODE_INTERPRETER
-#define TT_HINTER_FLAG FT_MODULE_DRIVER_HAS_HINTER
-#else
-#define TT_HINTER_FLAG 0
-#endif
-
-#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
-#define TT_SIZE_SELECT tt_size_select
-#else
-#define TT_SIZE_SELECT 0
-#endif
-
- FT_DEFINE_DRIVER(
- tt_driver_class,
-
- FT_MODULE_FONT_DRIVER |
- FT_MODULE_DRIVER_SCALABLE |
- TT_HINTER_FLAG,
-
- sizeof ( TT_DriverRec ),
-
- "truetype", /* driver name */
- 0x10000L, /* driver version == 1.0 */
- 0x20000L, /* driver requires FreeType 2.0 or above */
-
- NULL, /* module-specific interface */
-
- tt_driver_init, /* FT_Module_Constructor module_init */
- tt_driver_done, /* FT_Module_Destructor module_done */
- tt_get_interface, /* FT_Module_Requester get_interface */
-
- sizeof ( TT_FaceRec ),
- sizeof ( TT_SizeRec ),
- sizeof ( FT_GlyphSlotRec ),
-
- tt_face_init, /* FT_Face_InitFunc init_face */
- tt_face_done, /* FT_Face_DoneFunc done_face */
- tt_size_init, /* FT_Size_InitFunc init_size */
- tt_size_done, /* FT_Size_DoneFunc done_size */
- tt_slot_init, /* FT_Slot_InitFunc init_slot */
- NULL, /* FT_Slot_DoneFunc done_slot */
-
- tt_glyph_load, /* FT_Slot_LoadFunc load_glyph */
-
- tt_get_kerning, /* FT_Face_GetKerningFunc get_kerning */
- NULL, /* FT_Face_AttachFunc attach_file */
- tt_get_advances, /* FT_Face_GetAdvancesFunc get_advances */
-
- tt_size_request, /* FT_Size_RequestFunc request_size */
- TT_SIZE_SELECT /* FT_Size_SelectFunc select_size */
- )
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/truetype/ttdriver.h b/contrib/libs/freetype/src/truetype/ttdriver.h
deleted file mode 100644
index 3e1cf234fc..0000000000
--- a/contrib/libs/freetype/src/truetype/ttdriver.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/****************************************************************************
- *
- * ttdriver.h
- *
- * High-level TrueType driver interface (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef TTDRIVER_H_
-#define TTDRIVER_H_
-
-
-#include <freetype/internal/ftdrv.h>
-
-
-FT_BEGIN_HEADER
-
- FT_DECLARE_DRIVER( tt_driver_class )
-
-FT_END_HEADER
-
-#endif /* TTDRIVER_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/truetype/tterrors.h b/contrib/libs/freetype/src/truetype/tterrors.h
deleted file mode 100644
index 7ad937bd04..0000000000
--- a/contrib/libs/freetype/src/truetype/tterrors.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
- *
- * tterrors.h
- *
- * TrueType error codes (specification only).
- *
- * Copyright (C) 2001-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /**************************************************************************
- *
- * This file is used to define the TrueType error enumeration
- * constants.
- *
- */
-
-#ifndef TTERRORS_H_
-#define TTERRORS_H_
-
-#include <freetype/ftmoderr.h>
-
-#undef FTERRORS_H_
-
-#undef FT_ERR_PREFIX
-#define FT_ERR_PREFIX TT_Err_
-#define FT_ERR_BASE FT_Mod_Err_TrueType
-
-#include <freetype/fterrors.h>
-
-#endif /* TTERRORS_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/truetype/ttgload.c b/contrib/libs/freetype/src/truetype/ttgload.c
deleted file mode 100644
index b656ccf04e..0000000000
--- a/contrib/libs/freetype/src/truetype/ttgload.c
+++ /dev/null
@@ -1,2740 +0,0 @@
-/****************************************************************************
- *
- * ttgload.c
- *
- * TrueType Glyph Loader (body).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <ft2build.h>
-#include <freetype/internal/ftdebug.h>
-#include FT_CONFIG_CONFIG_H
-#include <freetype/internal/ftcalc.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/internal/sfnt.h>
-#include <freetype/tttags.h>
-#include <freetype/ftoutln.h>
-#include <freetype/ftdriver.h>
-#include <freetype/ftlist.h>
-
-#include "ttgload.h"
-#include "ttpload.h"
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
-#include "ttgxvar.h"
-#endif
-
-#include "tterrors.h"
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT ttgload
-
-
- /**************************************************************************
- *
- * Simple glyph flags.
- */
-#define ON_CURVE_POINT 0x01 /* same value as FT_CURVE_TAG_ON */
-#define X_SHORT_VECTOR 0x02
-#define Y_SHORT_VECTOR 0x04
-#define REPEAT_FLAG 0x08
-#define X_POSITIVE 0x10 /* two meanings depending on X_SHORT_VECTOR */
-#define SAME_X 0x10
-#define Y_POSITIVE 0x20 /* two meanings depending on Y_SHORT_VECTOR */
-#define SAME_Y 0x20
-#define OVERLAP_SIMPLE 0x40 /* retained as FT_OUTLINE_OVERLAP */
-
-
- /**************************************************************************
- *
- * Composite glyph flags.
- */
-#define ARGS_ARE_WORDS 0x0001
-#define ARGS_ARE_XY_VALUES 0x0002
-#define ROUND_XY_TO_GRID 0x0004
-#define WE_HAVE_A_SCALE 0x0008
-/* reserved 0x0010 */
-#define MORE_COMPONENTS 0x0020
-#define WE_HAVE_AN_XY_SCALE 0x0040
-#define WE_HAVE_A_2X2 0x0080
-#define WE_HAVE_INSTR 0x0100
-#define USE_MY_METRICS 0x0200
-#define OVERLAP_COMPOUND 0x0400 /* retained as FT_OUTLINE_OVERLAP */
-#define SCALED_COMPONENT_OFFSET 0x0800
-#define UNSCALED_COMPONENT_OFFSET 0x1000
-
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
-#define IS_DEFAULT_INSTANCE( _face ) \
- ( !( FT_IS_NAMED_INSTANCE( _face ) || \
- FT_IS_VARIATION( _face ) ) )
-#else
-#define IS_DEFAULT_INSTANCE( _face ) 1
-#endif
-
-
- /**************************************************************************
- *
- * Return the horizontal metrics in font units for a given glyph.
- */
- FT_LOCAL_DEF( void )
- TT_Get_HMetrics( TT_Face face,
- FT_UInt idx,
- FT_Short* lsb,
- FT_UShort* aw )
- {
- ( (SFNT_Service)face->sfnt )->get_metrics( face, 0, idx, lsb, aw );
-
- FT_TRACE5(( " advance width (font units): %d\n", *aw ));
- FT_TRACE5(( " left side bearing (font units): %d\n", *lsb ));
- }
-
-
- /**************************************************************************
- *
- * Return the vertical metrics in font units for a given glyph.
- * See function `tt_loader_set_pp' below for explanations.
- */
- FT_LOCAL_DEF( void )
- TT_Get_VMetrics( TT_Face face,
- FT_UInt idx,
- FT_Pos yMax,
- FT_Short* tsb,
- FT_UShort* ah )
- {
- if ( face->vertical_info )
- ( (SFNT_Service)face->sfnt )->get_metrics( face, 1, idx, tsb, ah );
-
- else if ( face->os2.version != 0xFFFFU )
- {
- *tsb = (FT_Short)( face->os2.sTypoAscender - yMax );
- *ah = (FT_UShort)FT_ABS( face->os2.sTypoAscender -
- face->os2.sTypoDescender );
- }
-
- else
- {
- *tsb = (FT_Short)( face->horizontal.Ascender - yMax );
- *ah = (FT_UShort)FT_ABS( face->horizontal.Ascender -
- face->horizontal.Descender );
- }
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( !face->vertical_info )
- FT_TRACE5(( " [vertical metrics missing, computing values]\n" ));
-#endif
-
- FT_TRACE5(( " advance height (font units): %d\n", *ah ));
- FT_TRACE5(( " top side bearing (font units): %d\n", *tsb ));
- }
-
-
- static FT_Error
- tt_get_metrics( TT_Loader loader,
- FT_UInt glyph_index )
- {
- TT_Face face = loader->face;
-
- FT_Error error;
- FT_Stream stream = loader->stream;
-
- FT_Short left_bearing = 0, top_bearing = 0;
- FT_UShort advance_width = 0, advance_height = 0;
-
- /* we must preserve the stream position */
- /* (which gets altered by the metrics functions) */
- FT_ULong pos = FT_STREAM_POS();
-
-
- TT_Get_HMetrics( face, glyph_index,
- &left_bearing,
- &advance_width );
- TT_Get_VMetrics( face, glyph_index,
- loader->bbox.yMax,
- &top_bearing,
- &advance_height );
-
- if ( FT_STREAM_SEEK( pos ) )
- return error;
-
- loader->left_bearing = left_bearing;
- loader->advance = advance_width;
- loader->top_bearing = top_bearing;
- loader->vadvance = advance_height;
-
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- /* With the incremental interface, these values are set by */
- /* a call to `tt_get_metrics_incremental'. */
- if ( face->root.internal->incremental_interface == NULL )
-#endif
- {
- if ( !loader->linear_def )
- {
- loader->linear_def = 1;
- loader->linear = advance_width;
- }
- }
-
- return FT_Err_Ok;
- }
-
-
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
-
- static void
- tt_get_metrics_incremental( TT_Loader loader,
- FT_UInt glyph_index )
- {
- TT_Face face = loader->face;
-
- FT_Short left_bearing = 0, top_bearing = 0;
- FT_UShort advance_width = 0, advance_height = 0;
-
-
- /* If this is an incrementally loaded font check whether there are */
- /* overriding metrics for this glyph. */
- if ( face->root.internal->incremental_interface &&
- face->root.internal->incremental_interface->funcs->get_glyph_metrics )
- {
- FT_Incremental_MetricsRec incr_metrics;
- FT_Error error;
-
-
- incr_metrics.bearing_x = loader->left_bearing;
- incr_metrics.bearing_y = 0;
- incr_metrics.advance = loader->advance;
- incr_metrics.advance_v = 0;
-
- error = face->root.internal->incremental_interface->funcs->get_glyph_metrics(
- face->root.internal->incremental_interface->object,
- glyph_index, FALSE, &incr_metrics );
- if ( error )
- goto Exit;
-
- left_bearing = (FT_Short)incr_metrics.bearing_x;
- advance_width = (FT_UShort)incr_metrics.advance;
-
-#if 0
-
- /* GWW: Do I do the same for vertical metrics? */
- incr_metrics.bearing_x = 0;
- incr_metrics.bearing_y = loader->top_bearing;
- incr_metrics.advance = loader->vadvance;
-
- error = face->root.internal->incremental_interface->funcs->get_glyph_metrics(
- face->root.internal->incremental_interface->object,
- glyph_index, TRUE, &incr_metrics );
- if ( error )
- goto Exit;
-
- top_bearing = (FT_Short)incr_metrics.bearing_y;
- advance_height = (FT_UShort)incr_metrics.advance;
-
-#endif /* 0 */
-
- loader->left_bearing = left_bearing;
- loader->advance = advance_width;
- loader->top_bearing = top_bearing;
- loader->vadvance = advance_height;
-
- if ( !loader->linear_def )
- {
- loader->linear_def = 1;
- loader->linear = advance_width;
- }
- }
-
- Exit:
- return;
- }
-
-#endif /* FT_CONFIG_OPTION_INCREMENTAL */
-
-
- /**************************************************************************
- *
- * The following functions are used by default with TrueType fonts.
- * However, they can be replaced by alternatives if we need to support
- * TrueType-compressed formats (like MicroType) in the future.
- *
- */
-
- FT_CALLBACK_DEF( FT_Error )
- TT_Access_Glyph_Frame( TT_Loader loader,
- FT_UInt glyph_index,
- FT_ULong offset,
- FT_UInt byte_count )
- {
- FT_Error error;
- FT_Stream stream = loader->stream;
-
- FT_UNUSED( glyph_index );
-
-
- /* the following line sets the `error' variable through macros! */
- if ( FT_STREAM_SEEK( offset ) || FT_FRAME_ENTER( byte_count ) )
- return error;
-
- loader->cursor = stream->cursor;
- loader->limit = stream->limit;
-
- return FT_Err_Ok;
- }
-
-
- FT_CALLBACK_DEF( void )
- TT_Forget_Glyph_Frame( TT_Loader loader )
- {
- FT_Stream stream = loader->stream;
-
-
- FT_FRAME_EXIT();
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- TT_Load_Glyph_Header( TT_Loader loader )
- {
- FT_Byte* p = loader->cursor;
- FT_Byte* limit = loader->limit;
-
-
- if ( p + 10 > limit )
- return FT_THROW( Invalid_Outline );
-
- loader->n_contours = FT_NEXT_SHORT( p );
-
- loader->bbox.xMin = FT_NEXT_SHORT( p );
- loader->bbox.yMin = FT_NEXT_SHORT( p );
- loader->bbox.xMax = FT_NEXT_SHORT( p );
- loader->bbox.yMax = FT_NEXT_SHORT( p );
-
- FT_TRACE5(( " # of contours: %d\n", loader->n_contours ));
- FT_TRACE5(( " xMin: %4ld xMax: %4ld\n", loader->bbox.xMin,
- loader->bbox.xMax ));
- FT_TRACE5(( " yMin: %4ld yMax: %4ld\n", loader->bbox.yMin,
- loader->bbox.yMax ));
- loader->cursor = p;
-
- return FT_Err_Ok;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- TT_Load_Simple_Glyph( TT_Loader load )
- {
- FT_Error error;
- FT_Byte* p = load->cursor;
- FT_Byte* limit = load->limit;
- FT_GlyphLoader gloader = load->gloader;
- FT_Outline* outline = &gloader->current.outline;
- FT_Int n_contours = load->n_contours;
- FT_Int n_points;
- FT_UShort n_ins;
-
- FT_Byte *flag, *flag_limit;
- FT_Byte c, count;
- FT_Vector *vec, *vec_limit;
- FT_Pos x, y;
- FT_UShort *cont, *cont_limit;
- FT_Int last;
-
-
- /* check that we can add the contours to the glyph */
- error = FT_GLYPHLOADER_CHECK_POINTS( gloader, 0, n_contours );
- if ( error )
- goto Fail;
-
- /* check space for contours array + instructions count */
- if ( n_contours >= 0xFFF || p + 2 * n_contours + 2 > limit )
- goto Invalid_Outline;
-
- /* reading the contours' endpoints & number of points */
- cont = outline->contours;
- cont_limit = cont + n_contours;
-
- last = -1;
- for ( ; cont < cont_limit; cont++ )
- {
- *cont = FT_NEXT_USHORT( p );
-
- if ( *cont <= last )
- goto Invalid_Outline;
-
- last = *cont;
- }
-
- n_points = last + 1;
-
- FT_TRACE5(( " # of points: %d\n", n_points ));
-
- /* note that we will add four phantom points later */
- error = FT_GLYPHLOADER_CHECK_POINTS( gloader, n_points + 4, 0 );
- if ( error )
- goto Fail;
-
- /* space checked above */
- n_ins = FT_NEXT_USHORT( p );
-
- FT_TRACE5(( " Instructions size: %u\n", n_ins ));
-
- /* check instructions size */
- if ( p + n_ins > limit )
- {
- FT_TRACE1(( "TT_Load_Simple_Glyph: excessive instruction count\n" ));
- error = FT_THROW( Too_Many_Hints );
- goto Fail;
- }
-
-#ifdef TT_USE_BYTECODE_INTERPRETER
-
- if ( IS_HINTED( load->load_flags ) )
- {
- TT_ExecContext exec = load->exec;
- FT_Memory memory = exec->memory;
-
-
- if ( exec->glyphSize )
- FT_FREE( exec->glyphIns );
- exec->glyphSize = 0;
-
- /* we don't trust `maxSizeOfInstructions' in the `maxp' table */
- /* and thus allocate the bytecode array size by ourselves */
- if ( n_ins )
- {
- if ( FT_DUP( exec->glyphIns, p, n_ins ) )
- return error;
-
- exec->glyphSize = n_ins;
- }
- }
-
-#endif /* TT_USE_BYTECODE_INTERPRETER */
-
- p += n_ins;
-
- /* reading the point tags */
- flag = outline->tags;
- flag_limit = flag + n_points;
-
- FT_ASSERT( flag );
-
- while ( flag < flag_limit )
- {
- if ( p + 1 > limit )
- goto Invalid_Outline;
-
- *flag++ = c = FT_NEXT_BYTE( p );
- if ( c & REPEAT_FLAG )
- {
- if ( p + 1 > limit )
- goto Invalid_Outline;
-
- count = FT_NEXT_BYTE( p );
- if ( flag + (FT_Int)count > flag_limit )
- goto Invalid_Outline;
-
- for ( ; count > 0; count-- )
- *flag++ = c;
- }
- }
-
- /* retain the overlap flag */
- if ( n_points && outline->tags[0] & OVERLAP_SIMPLE )
- gloader->base.outline.flags |= FT_OUTLINE_OVERLAP;
-
- /* reading the X coordinates */
-
- vec = outline->points;
- vec_limit = vec + n_points;
- flag = outline->tags;
- x = 0;
-
- for ( ; vec < vec_limit; vec++, flag++ )
- {
- FT_Pos delta = 0;
- FT_Byte f = *flag;
-
-
- if ( f & X_SHORT_VECTOR )
- {
- if ( p + 1 > limit )
- goto Invalid_Outline;
-
- delta = (FT_Pos)FT_NEXT_BYTE( p );
- if ( !( f & X_POSITIVE ) )
- delta = -delta;
- }
- else if ( !( f & SAME_X ) )
- {
- if ( p + 2 > limit )
- goto Invalid_Outline;
-
- delta = (FT_Pos)FT_NEXT_SHORT( p );
- }
-
- x += delta;
- vec->x = x;
- }
-
- /* reading the Y coordinates */
-
- vec = outline->points;
- vec_limit = vec + n_points;
- flag = outline->tags;
- y = 0;
-
- for ( ; vec < vec_limit; vec++, flag++ )
- {
- FT_Pos delta = 0;
- FT_Byte f = *flag;
-
-
- if ( f & Y_SHORT_VECTOR )
- {
- if ( p + 1 > limit )
- goto Invalid_Outline;
-
- delta = (FT_Pos)FT_NEXT_BYTE( p );
- if ( !( f & Y_POSITIVE ) )
- delta = -delta;
- }
- else if ( !( f & SAME_Y ) )
- {
- if ( p + 2 > limit )
- goto Invalid_Outline;
-
- delta = (FT_Pos)FT_NEXT_SHORT( p );
- }
-
- y += delta;
- vec->y = y;
-
- /* the cast is for stupid compilers */
- *flag = (FT_Byte)( f & ON_CURVE_POINT );
- }
-
- outline->n_points = (FT_UShort)n_points;
- outline->n_contours = (FT_UShort)n_contours;
-
- load->cursor = p;
-
- Fail:
- return error;
-
- Invalid_Outline:
- error = FT_THROW( Invalid_Outline );
- goto Fail;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- TT_Load_Composite_Glyph( TT_Loader loader )
- {
- FT_Error error;
- FT_Byte* p = loader->cursor;
- FT_Byte* limit = loader->limit;
- FT_GlyphLoader gloader = loader->gloader;
- FT_Long num_glyphs = loader->face->root.num_glyphs;
- FT_SubGlyph subglyph;
- FT_UInt num_subglyphs;
-
-
- num_subglyphs = 0;
-
- do
- {
- FT_Fixed xx, xy, yy, yx;
- FT_UInt count;
-
-
- /* check that we can load a new subglyph */
- error = FT_GlyphLoader_CheckSubGlyphs( gloader, num_subglyphs + 1 );
- if ( error )
- goto Fail;
-
- /* check space */
- if ( p + 4 > limit )
- goto Invalid_Composite;
-
- subglyph = gloader->current.subglyphs + num_subglyphs;
-
- subglyph->arg1 = subglyph->arg2 = 0;
-
- subglyph->flags = FT_NEXT_USHORT( p );
- subglyph->index = FT_NEXT_USHORT( p );
-
- /* we reject composites that have components */
- /* with invalid glyph indices */
- if ( subglyph->index >= num_glyphs )
- goto Invalid_Composite;
-
- /* check space */
- count = 2;
- if ( subglyph->flags & ARGS_ARE_WORDS )
- count += 2;
- if ( subglyph->flags & WE_HAVE_A_SCALE )
- count += 2;
- else if ( subglyph->flags & WE_HAVE_AN_XY_SCALE )
- count += 4;
- else if ( subglyph->flags & WE_HAVE_A_2X2 )
- count += 8;
-
- if ( p + count > limit )
- goto Invalid_Composite;
-
- /* read arguments */
- if ( subglyph->flags & ARGS_ARE_XY_VALUES )
- {
- if ( subglyph->flags & ARGS_ARE_WORDS )
- {
- subglyph->arg1 = FT_NEXT_SHORT( p );
- subglyph->arg2 = FT_NEXT_SHORT( p );
- }
- else
- {
- subglyph->arg1 = FT_NEXT_CHAR( p );
- subglyph->arg2 = FT_NEXT_CHAR( p );
- }
- }
- else
- {
- if ( subglyph->flags & ARGS_ARE_WORDS )
- {
- subglyph->arg1 = (FT_Int)FT_NEXT_USHORT( p );
- subglyph->arg2 = (FT_Int)FT_NEXT_USHORT( p );
- }
- else
- {
- subglyph->arg1 = (FT_Int)FT_NEXT_BYTE( p );
- subglyph->arg2 = (FT_Int)FT_NEXT_BYTE( p );
- }
- }
-
- /* read transform */
- xx = yy = 0x10000L;
- xy = yx = 0;
-
- if ( subglyph->flags & WE_HAVE_A_SCALE )
- {
- xx = (FT_Fixed)FT_NEXT_SHORT( p ) * 4;
- yy = xx;
- }
- else if ( subglyph->flags & WE_HAVE_AN_XY_SCALE )
- {
- xx = (FT_Fixed)FT_NEXT_SHORT( p ) * 4;
- yy = (FT_Fixed)FT_NEXT_SHORT( p ) * 4;
- }
- else if ( subglyph->flags & WE_HAVE_A_2X2 )
- {
- xx = (FT_Fixed)FT_NEXT_SHORT( p ) * 4;
- yx = (FT_Fixed)FT_NEXT_SHORT( p ) * 4;
- xy = (FT_Fixed)FT_NEXT_SHORT( p ) * 4;
- yy = (FT_Fixed)FT_NEXT_SHORT( p ) * 4;
- }
-
- subglyph->transform.xx = xx;
- subglyph->transform.xy = xy;
- subglyph->transform.yx = yx;
- subglyph->transform.yy = yy;
-
- num_subglyphs++;
-
- } while ( subglyph->flags & MORE_COMPONENTS );
-
- gloader->current.num_subglyphs = num_subglyphs;
- FT_TRACE5(( " %d component%s\n",
- num_subglyphs,
- num_subglyphs > 1 ? "s" : "" ));
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- {
- FT_UInt i;
-
-
- subglyph = gloader->current.subglyphs;
-
- for ( i = 0; i < num_subglyphs; i++ )
- {
- if ( num_subglyphs > 1 )
- FT_TRACE7(( " subglyph %d:\n", i ));
-
- FT_TRACE7(( " glyph index: %d\n", subglyph->index ));
-
- if ( subglyph->flags & ARGS_ARE_XY_VALUES )
- FT_TRACE7(( " offset: x=%d, y=%d\n",
- subglyph->arg1,
- subglyph->arg2 ));
- else
- FT_TRACE7(( " matching points: base=%d, component=%d\n",
- subglyph->arg1,
- subglyph->arg2 ));
-
- if ( subglyph->flags & WE_HAVE_A_SCALE )
- FT_TRACE7(( " scaling: %f\n",
- (double)subglyph->transform.xx / 65536 ));
- else if ( subglyph->flags & WE_HAVE_AN_XY_SCALE )
- FT_TRACE7(( " scaling: x=%f, y=%f\n",
- (double)subglyph->transform.xx / 65536,
- (double)subglyph->transform.yy / 65536 ));
- else if ( subglyph->flags & WE_HAVE_A_2X2 )
- {
- FT_TRACE7(( " scaling: xx=%f, yx=%f\n",
- (double)subglyph->transform.xx / 65536,
- (double)subglyph->transform.yx / 65536 ));
- FT_TRACE7(( " xy=%f, yy=%f\n",
- (double)subglyph->transform.xy / 65536,
- (double)subglyph->transform.yy / 65536 ));
- }
-
- subglyph++;
- }
- }
-#endif /* FT_DEBUG_LEVEL_TRACE */
-
-#ifdef TT_USE_BYTECODE_INTERPRETER
-
- {
- FT_Stream stream = loader->stream;
-
-
- /* we must undo the FT_FRAME_ENTER in order to point */
- /* to the composite instructions, if we find some. */
- /* We will process them later. */
- /* */
- loader->ins_pos = (FT_ULong)( FT_STREAM_POS() +
- p - limit );
- }
-
-#endif
-
- loader->cursor = p;
-
- Fail:
- return error;
-
- Invalid_Composite:
- error = FT_THROW( Invalid_Composite );
- goto Fail;
- }
-
-
- FT_LOCAL_DEF( void )
- TT_Init_Glyph_Loading( TT_Face face )
- {
- face->access_glyph_frame = TT_Access_Glyph_Frame;
- face->read_glyph_header = TT_Load_Glyph_Header;
- face->read_simple_glyph = TT_Load_Simple_Glyph;
- face->read_composite_glyph = TT_Load_Composite_Glyph;
- face->forget_glyph_frame = TT_Forget_Glyph_Frame;
- }
-
-
- static void
- tt_prepare_zone( TT_GlyphZone zone,
- FT_GlyphLoad load,
- FT_UInt start_point,
- FT_UInt start_contour )
- {
- zone->n_points = load->outline.n_points + 4 - (FT_UShort)start_point;
- zone->n_contours = load->outline.n_contours - (FT_UShort)start_contour;
- zone->org = load->extra_points + start_point;
- zone->cur = load->outline.points + start_point;
- zone->orus = load->extra_points2 + start_point;
- zone->tags = load->outline.tags + start_point;
- zone->contours = load->outline.contours + start_contour;
- zone->first_point = (FT_UShort)start_point;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * TT_Hint_Glyph
- *
- * @Description:
- * Hint the glyph using the zone prepared by the caller. Note that
- * the zone is supposed to include four phantom points.
- */
- static FT_Error
- TT_Hint_Glyph( TT_Loader loader,
- FT_Bool is_composite )
- {
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- TT_Face face = loader->face;
- TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face );
-#endif
-
- TT_GlyphZone zone = &loader->zone;
-
-#ifdef TT_USE_BYTECODE_INTERPRETER
- TT_ExecContext exec = loader->exec;
- FT_Long n_ins = exec->glyphSize;
-#else
- FT_UNUSED( is_composite );
-#endif
-
-
-#ifdef TT_USE_BYTECODE_INTERPRETER
- /* save original point positions in `org' array */
- if ( n_ins > 0 )
- FT_ARRAY_COPY( zone->org, zone->cur, zone->n_points );
-
- /* Reset graphics state. */
- exec->GS = loader->size->GS;
-
- /* XXX: UNDOCUMENTED! Hinting instructions of a composite glyph */
- /* completely refer to the (already) hinted subglyphs. */
- if ( is_composite )
- {
- exec->metrics.x_scale = 1 << 16;
- exec->metrics.y_scale = 1 << 16;
-
- FT_ARRAY_COPY( zone->orus, zone->cur, zone->n_points );
- }
- else
- {
- exec->metrics.x_scale = loader->size->metrics->x_scale;
- exec->metrics.y_scale = loader->size->metrics->y_scale;
- }
-#endif
-
- /* round phantom points */
- zone->cur[zone->n_points - 4].x =
- FT_PIX_ROUND( zone->cur[zone->n_points - 4].x );
- zone->cur[zone->n_points - 3].x =
- FT_PIX_ROUND( zone->cur[zone->n_points - 3].x );
- zone->cur[zone->n_points - 2].y =
- FT_PIX_ROUND( zone->cur[zone->n_points - 2].y );
- zone->cur[zone->n_points - 1].y =
- FT_PIX_ROUND( zone->cur[zone->n_points - 1].y );
-
-#ifdef TT_USE_BYTECODE_INTERPRETER
-
- if ( n_ins > 0 )
- {
- FT_Error error;
-
-
- TT_Set_CodeRange( exec, tt_coderange_glyph, exec->glyphIns, n_ins );
-
- exec->is_composite = is_composite;
- exec->pts = *zone;
-
- error = TT_Run_Context( exec );
- if ( error && exec->pedantic_hinting )
- return error;
-
- /* store drop-out mode in bits 5-7; set bit 2 also as a marker */
- loader->gloader->current.outline.tags[0] |=
- ( exec->GS.scan_type << 5 ) | FT_CURVE_TAG_HAS_SCANMODE;
- }
-
-#endif
-
- /* Save possibly modified glyph phantom points unless in v40 backward */
- /* compatibility mode, where no movement on the x axis means no reason */
- /* to change bearings or advance widths. */
-
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- if ( driver->interpreter_version == TT_INTERPRETER_VERSION_40 &&
- exec->backward_compatibility )
- return FT_Err_Ok;
-#endif
-
- loader->pp1 = zone->cur[zone->n_points - 4];
- loader->pp2 = zone->cur[zone->n_points - 3];
- loader->pp3 = zone->cur[zone->n_points - 2];
- loader->pp4 = zone->cur[zone->n_points - 1];
-
- return FT_Err_Ok;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * TT_Process_Simple_Glyph
- *
- * @Description:
- * Once a simple glyph has been loaded, it needs to be processed.
- * Usually, this means scaling and hinting through bytecode
- * interpretation.
- */
- static FT_Error
- TT_Process_Simple_Glyph( TT_Loader loader )
- {
- FT_Error error = FT_Err_Ok;
- FT_GlyphLoader gloader = loader->gloader;
- FT_Outline* outline = &gloader->current.outline;
- FT_Int n_points = outline->n_points;
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- FT_Memory memory = loader->face->root.memory;
- FT_Vector* unrounded = NULL;
-#endif
-
-
- /* set phantom points */
- outline->points[n_points ] = loader->pp1;
- outline->points[n_points + 1] = loader->pp2;
- outline->points[n_points + 2] = loader->pp3;
- outline->points[n_points + 3] = loader->pp4;
-
- n_points += 4;
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
-
- if ( !IS_DEFAULT_INSTANCE( FT_FACE( loader->face ) ) )
- {
- if ( FT_QNEW_ARRAY( unrounded, n_points ) )
- goto Exit;
-
- /* Deltas apply to the unscaled data. */
- error = TT_Vary_Apply_Glyph_Deltas( loader,
- outline,
- unrounded );
- if ( error )
- goto Exit;
- }
-
-#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
-
- if ( IS_HINTED( loader->load_flags ) )
- {
- tt_prepare_zone( &loader->zone, &gloader->current, 0, 0 );
-
- FT_ARRAY_COPY( loader->zone.orus, loader->zone.cur,
- loader->zone.n_points );
- }
-
- {
- FT_Vector* vec = outline->points;
- FT_Vector* limit = outline->points + n_points;
-
- FT_Fixed x_scale = 0; /* pacify compiler */
- FT_Fixed y_scale = 0;
-
- FT_Bool do_scale = FALSE;
-
-
- {
- /* scale the glyph */
- if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 )
- {
- x_scale = loader->size->metrics->x_scale;
- y_scale = loader->size->metrics->y_scale;
-
- do_scale = TRUE;
- }
- }
-
- if ( do_scale )
- {
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- if ( !IS_DEFAULT_INSTANCE( FT_FACE( loader->face ) ) )
- {
- FT_Vector* u = unrounded;
-
-
- for ( ; vec < limit; vec++, u++ )
- {
- vec->x = ADD_LONG( FT_MulFix( u->x, x_scale ), 32 ) >> 6;
- vec->y = ADD_LONG( FT_MulFix( u->y, y_scale ), 32 ) >> 6;
- }
- }
- else
-#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
- {
- for ( ; vec < limit; vec++ )
- {
- vec->x = FT_MulFix( vec->x, x_scale );
- vec->y = FT_MulFix( vec->y, y_scale );
- }
- }
- }
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- /* if we have a HVAR table, `pp1' and/or `pp2' */
- /* are already adjusted but unscaled */
- if ( ( loader->face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) &&
- IS_HINTED( loader->load_flags ) )
- {
- loader->pp1.x = FT_MulFix( loader->pp1.x, x_scale );
- loader->pp2.x = FT_MulFix( loader->pp2.x, x_scale );
- /* pp1.y and pp2.y are always zero */
- }
- else
-#endif
- {
- loader->pp1 = outline->points[n_points - 4];
- loader->pp2 = outline->points[n_points - 3];
- }
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- /* if we have a VVAR table, `pp3' and/or `pp4' */
- /* are already adjusted but unscaled */
- if ( ( loader->face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) &&
- IS_HINTED( loader->load_flags ) )
- {
- loader->pp3.x = FT_MulFix( loader->pp3.x, x_scale );
- loader->pp3.y = FT_MulFix( loader->pp3.y, y_scale );
- loader->pp4.x = FT_MulFix( loader->pp4.x, x_scale );
- loader->pp4.y = FT_MulFix( loader->pp4.y, y_scale );
- }
- else
-#endif
- {
- loader->pp3 = outline->points[n_points - 2];
- loader->pp4 = outline->points[n_points - 1];
- }
- }
-
- if ( IS_HINTED( loader->load_flags ) )
- error = TT_Hint_Glyph( loader, 0 );
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- Exit:
- FT_FREE( unrounded );
-#endif
-
- return error;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * TT_Process_Composite_Component
- *
- * @Description:
- * Once a composite component has been loaded, it needs to be
- * processed. Usually, this means transforming and translating.
- */
- static FT_Error
- TT_Process_Composite_Component( TT_Loader loader,
- FT_SubGlyph subglyph,
- FT_UInt start_point,
- FT_UInt num_base_points )
- {
- FT_GlyphLoader gloader = loader->gloader;
- FT_Outline current;
- FT_Bool have_scale;
- FT_Pos x, y;
-
-
- current.points = gloader->base.outline.points +
- num_base_points;
- current.n_points = gloader->base.outline.n_points -
- (FT_UShort)num_base_points;
-
- have_scale = FT_BOOL( subglyph->flags & ( WE_HAVE_A_SCALE |
- WE_HAVE_AN_XY_SCALE |
- WE_HAVE_A_2X2 ) );
-
- /* perform the transform required for this subglyph */
- if ( have_scale )
- FT_Outline_Transform( &current, &subglyph->transform );
-
- /* get offset */
- if ( !( subglyph->flags & ARGS_ARE_XY_VALUES ) )
- {
- FT_UInt num_points = gloader->base.outline.n_points;
- FT_UInt k = (FT_UInt)subglyph->arg1;
- FT_UInt l = (FT_UInt)subglyph->arg2;
- FT_Vector* p1;
- FT_Vector* p2;
-
-
- /* match l-th point of the newly loaded component to the k-th point */
- /* of the previously loaded components. */
-
- /* change to the point numbers used by our outline */
- k += start_point;
- l += num_base_points;
- if ( k >= num_base_points ||
- l >= num_points )
- return FT_THROW( Invalid_Composite );
-
- p1 = gloader->base.outline.points + k;
- p2 = gloader->base.outline.points + l;
-
- x = SUB_LONG( p1->x, p2->x );
- y = SUB_LONG( p1->y, p2->y );
- }
- else
- {
- x = subglyph->arg1;
- y = subglyph->arg2;
-
- if ( !x && !y )
- return FT_Err_Ok;
-
- /* Use a default value dependent on */
- /* TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED. This is useful for old */
- /* TT fonts which don't set the xxx_COMPONENT_OFFSET bit. */
-
- if ( have_scale &&
-#ifdef TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED
- !( subglyph->flags & UNSCALED_COMPONENT_OFFSET ) )
-#else
- ( subglyph->flags & SCALED_COMPONENT_OFFSET ) )
-#endif
- {
-
-#if 0
-
- /********************************************************************
- *
- * This algorithm is what Apple documents. But it doesn't work.
- */
- int a = subglyph->transform.xx > 0 ? subglyph->transform.xx
- : -subglyph->transform.xx;
- int b = subglyph->transform.yx > 0 ? subglyph->transform.yx
- : -subglyph->transform.yx;
- int c = subglyph->transform.xy > 0 ? subglyph->transform.xy
- : -subglyph->transform.xy;
- int d = subglyph->transform.yy > 0 ? subglyph->transform.yy
- : -subglyph->transform.yy;
- int m = a > b ? a : b;
- int n = c > d ? c : d;
-
-
- if ( a - b <= 33 && a - b >= -33 )
- m *= 2;
- if ( c - d <= 33 && c - d >= -33 )
- n *= 2;
- x = FT_MulFix( x, m );
- y = FT_MulFix( y, n );
-
-#else /* 1 */
-
- /********************************************************************
- *
- * This algorithm is a guess and works much better than the above.
- */
- FT_Fixed mac_xscale = FT_Hypot( subglyph->transform.xx,
- subglyph->transform.xy );
- FT_Fixed mac_yscale = FT_Hypot( subglyph->transform.yy,
- subglyph->transform.yx );
-
-
- x = FT_MulFix( x, mac_xscale );
- y = FT_MulFix( y, mac_yscale );
-
-#endif /* 1 */
-
- }
-
- if ( !( loader->load_flags & FT_LOAD_NO_SCALE ) )
- {
- FT_Fixed x_scale = loader->size->metrics->x_scale;
- FT_Fixed y_scale = loader->size->metrics->y_scale;
-
-
- x = FT_MulFix( x, x_scale );
- y = FT_MulFix( y, y_scale );
-
- if ( subglyph->flags & ROUND_XY_TO_GRID )
- {
- TT_Face face = loader->face;
- TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face );
-
-
- if ( IS_HINTED( loader->load_flags ) )
- {
- /*
- * We round the horizontal offset only if there is hinting along
- * the x axis; this corresponds to integer advance width values.
- *
- * Theoretically, a glyph's bytecode can toggle ClearType's
- * `backward compatibility' mode, which would allow modification
- * of the advance width. In reality, however, applications
- * neither allow nor expect modified advance widths if subpixel
- * rendering is active.
- *
- */
- if ( driver->interpreter_version == TT_INTERPRETER_VERSION_35 )
- x = FT_PIX_ROUND( x );
-
- y = FT_PIX_ROUND( y );
- }
- }
- }
- }
-
- if ( x || y )
- FT_Outline_Translate( &current, x, y );
-
- return FT_Err_Ok;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * TT_Process_Composite_Glyph
- *
- * @Description:
- * This is slightly different from TT_Process_Simple_Glyph, in that
- * its sole purpose is to hint the glyph. Thus this function is
- * only available when bytecode interpreter is enabled.
- */
- static FT_Error
- TT_Process_Composite_Glyph( TT_Loader loader,
- FT_UInt start_point,
- FT_UInt start_contour )
- {
- FT_Error error;
- FT_Outline* outline = &loader->gloader->base.outline;
- FT_Stream stream = loader->stream;
- FT_UShort n_ins;
- FT_UInt i;
-
-
- /* make room for phantom points */
- error = FT_GLYPHLOADER_CHECK_POINTS( loader->gloader,
- outline->n_points + 4,
- 0 );
- if ( error )
- return error;
-
- outline->points[outline->n_points ] = loader->pp1;
- outline->points[outline->n_points + 1] = loader->pp2;
- outline->points[outline->n_points + 2] = loader->pp3;
- outline->points[outline->n_points + 3] = loader->pp4;
-
-#ifdef TT_USE_BYTECODE_INTERPRETER
-
- {
- TT_ExecContext exec = loader->exec;
- FT_Memory memory = exec->memory;
-
-
- if ( exec->glyphSize )
- FT_FREE( exec->glyphIns );
- exec->glyphSize = 0;
-
- /* TT_Load_Composite_Glyph only gives us the offset of instructions */
- /* so we read them here */
- if ( FT_STREAM_SEEK( loader->ins_pos ) ||
- FT_READ_USHORT( n_ins ) )
- return error;
-
- FT_TRACE5(( " Instructions size = %hu\n", n_ins ));
-
- if ( !n_ins )
- return FT_Err_Ok;
-
- /* don't trust `maxSizeOfInstructions'; */
- /* only do a rough safety check */
- if ( n_ins > loader->byte_len )
- {
- FT_TRACE1(( "TT_Process_Composite_Glyph:"
- " too many instructions (%hu) for glyph with length %u\n",
- n_ins, loader->byte_len ));
- return FT_THROW( Too_Many_Hints );
- }
-
- if ( FT_QNEW_ARRAY( exec->glyphIns, n_ins ) ||
- FT_STREAM_READ( exec->glyphIns, n_ins ) )
- return error;
-
- exec->glyphSize = n_ins;
- }
-
-#endif
-
- tt_prepare_zone( &loader->zone, &loader->gloader->base,
- start_point, start_contour );
-
- /* Some points are likely touched during execution of */
- /* instructions on components. So let's untouch them. */
- for ( i = 0; i < loader->zone.n_points - 4U; i++ )
- loader->zone.tags[i] &= ~FT_CURVE_TAG_TOUCH_BOTH;
-
- return TT_Hint_Glyph( loader, 1 );
- }
-
-
- /*
- * Calculate the phantom points
- *
- * Defining the right side bearing (rsb) as
- *
- * rsb = aw - (lsb + xmax - xmin)
- *
- * (with `aw' the advance width, `lsb' the left side bearing, and `xmin'
- * and `xmax' the glyph's minimum and maximum x value), the OpenType
- * specification defines the initial position of horizontal phantom points
- * as
- *
- * pp1 = (round(xmin - lsb), 0) ,
- * pp2 = (round(pp1 + aw), 0) .
- *
- * Note that the rounding to the grid (in the device space) is not
- * documented currently in the specification.
- *
- * However, the specification lacks the precise definition of vertical
- * phantom points. Greg Hitchcock provided the following explanation.
- *
- * - a `vmtx' table is present
- *
- * For any glyph, the minimum and maximum y values (`ymin' and `ymax')
- * are given in the `glyf' table, the top side bearing (tsb) and advance
- * height (ah) are given in the `vmtx' table. The bottom side bearing
- * (bsb) is then calculated as
- *
- * bsb = ah - (tsb + ymax - ymin) ,
- *
- * and the initial position of vertical phantom points is
- *
- * pp3 = (x, round(ymax + tsb)) ,
- * pp4 = (x, round(pp3 - ah)) .
- *
- * See below for value `x'.
- *
- * - no `vmtx' table in the font
- *
- * If there is an `OS/2' table, we set
- *
- * DefaultAscender = sTypoAscender ,
- * DefaultDescender = sTypoDescender ,
- *
- * otherwise we use data from the `hhea' table:
- *
- * DefaultAscender = Ascender ,
- * DefaultDescender = Descender .
- *
- * With these two variables we can now set
- *
- * ah = DefaultAscender - sDefaultDescender ,
- * tsb = DefaultAscender - yMax ,
- *
- * and proceed as if a `vmtx' table was present.
- *
- * Usually we have
- *
- * x = aw / 2 , (1)
- *
- * but there is one compatibility case where it can be set to
- *
- * x = -DefaultDescender -
- * ((DefaultAscender - DefaultDescender - aw) / 2) . (2)
- *
- * and another one with
- *
- * x = 0 . (3)
- *
- * In Windows, the history of those values is quite complicated,
- * depending on the hinting engine (that is, the graphics framework).
- *
- * framework from to formula
- * ----------------------------------------------------------
- * GDI Windows 98 current (1)
- * (Windows 2000 for NT)
- * GDI+ Windows XP Windows 7 (2)
- * GDI+ Windows 8 current (3)
- * DWrite Windows 7 current (3)
- *
- * For simplicity, FreeType uses (1) for grayscale subpixel hinting and
- * (3) for everything else.
- *
- */
- static void
- tt_loader_set_pp( TT_Loader loader )
- {
- loader->pp1.x = loader->bbox.xMin - loader->left_bearing;
- loader->pp1.y = 0;
- loader->pp2.x = loader->pp1.x + loader->advance;
- loader->pp2.y = 0;
-
- loader->pp3.x = 0;
- loader->pp3.y = loader->bbox.yMax + loader->top_bearing;
- loader->pp4.x = 0;
- loader->pp4.y = loader->pp3.y - loader->vadvance;
-
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- {
- TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( loader->face );
-
-
- if ( driver->interpreter_version == TT_INTERPRETER_VERSION_40 &&
- loader->exec &&
- loader->exec->subpixel_hinting_lean &&
- loader->exec->grayscale_cleartype )
- {
- loader->pp3.x = loader->advance / 2;
- loader->pp4.x = loader->advance / 2;
- }
- }
-#endif
- }
-
-
- /* a utility function to retrieve i-th node from given FT_List */
- static FT_ListNode
- ft_list_get_node_at( FT_List list,
- FT_UInt idx )
- {
- FT_ListNode cur;
-
-
- if ( !list )
- return NULL;
-
- for ( cur = list->head; cur; cur = cur->next )
- {
- if ( !idx )
- return cur;
-
- idx--;
- }
-
- return NULL;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * load_truetype_glyph
- *
- * @Description:
- * Loads a given truetype glyph. Handles composites and uses a
- * TT_Loader object.
- */
- static FT_Error
- load_truetype_glyph( TT_Loader loader,
- FT_UInt glyph_index,
- FT_UInt recurse_count,
- FT_Bool header_only )
- {
- FT_Error error = FT_Err_Ok;
- FT_Fixed x_scale, y_scale;
- FT_ULong offset;
- TT_Face face = loader->face;
- FT_GlyphLoader gloader = loader->gloader;
-
- FT_Bool opened_frame = 0;
-
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- FT_StreamRec inc_stream;
- FT_Data glyph_data;
- FT_Bool glyph_data_loaded = 0;
-#endif
-
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( recurse_count )
- FT_TRACE5(( " nesting level: %d\n", recurse_count ));
-#endif
-
- /* some fonts have an incorrect value of `maxComponentDepth' */
- if ( recurse_count > face->max_profile.maxComponentDepth )
- {
- FT_TRACE1(( "load_truetype_glyph: maxComponentDepth set to %d\n",
- recurse_count ));
- face->max_profile.maxComponentDepth = (FT_UShort)recurse_count;
- }
-
-#ifndef FT_CONFIG_OPTION_INCREMENTAL
- /* check glyph index */
- if ( glyph_index >= (FT_UInt)face->root.num_glyphs )
- {
- error = FT_THROW( Invalid_Glyph_Index );
- goto Exit;
- }
-#endif
-
- loader->glyph_index = glyph_index;
-
- if ( loader->load_flags & FT_LOAD_NO_SCALE )
- {
- x_scale = 0x10000L;
- y_scale = 0x10000L;
- }
- else
- {
- x_scale = loader->size->metrics->x_scale;
- y_scale = loader->size->metrics->y_scale;
- }
-
- /* Set `offset' to the start of the glyph relative to the start of */
- /* the `glyf' table, and `byte_len' to the length of the glyph in */
- /* bytes. */
-
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
-
- /* If we are loading glyph data via the incremental interface, set */
- /* the loader stream to a memory stream reading the data returned */
- /* by the interface. */
- if ( face->root.internal->incremental_interface )
- {
- error = face->root.internal->incremental_interface->funcs->get_glyph_data(
- face->root.internal->incremental_interface->object,
- glyph_index, &glyph_data );
- if ( error )
- goto Exit;
-
- glyph_data_loaded = 1;
- offset = 0;
- loader->byte_len = glyph_data.length;
-
- FT_ZERO( &inc_stream );
- FT_Stream_OpenMemory( &inc_stream,
- glyph_data.pointer,
- glyph_data.length );
-
- loader->stream = &inc_stream;
- }
- else
-
-#endif /* FT_CONFIG_OPTION_INCREMENTAL */
- {
- FT_ULong len;
-
-
- offset = tt_face_get_location( FT_FACE( face ), glyph_index, &len );
-
- loader->byte_len = (FT_UInt)len;
- }
-
- if ( loader->byte_len > 0 )
- {
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- /* for the incremental interface, `glyf_offset' is always zero */
- if ( !face->glyf_offset &&
- !face->root.internal->incremental_interface )
-#else
- if ( !face->glyf_offset )
-#endif /* FT_CONFIG_OPTION_INCREMENTAL */
- {
- FT_TRACE2(( "no `glyf' table but non-zero `loca' entry\n" ));
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- error = face->access_glyph_frame( loader, glyph_index,
- face->glyf_offset + offset,
- loader->byte_len );
- if ( error )
- goto Exit;
-
- /* read glyph header first */
- error = face->read_glyph_header( loader );
-
- face->forget_glyph_frame( loader );
-
- if ( error )
- goto Exit;
- }
-
- /* a space glyph */
- if ( loader->byte_len == 0 || loader->n_contours == 0 )
- {
- loader->bbox.xMin = 0;
- loader->bbox.xMax = 0;
- loader->bbox.yMin = 0;
- loader->bbox.yMax = 0;
- }
-
- /* the metrics must be computed after loading the glyph header */
- /* since we need the glyph's `yMax' value in case the vertical */
- /* metrics must be emulated */
- error = tt_get_metrics( loader, glyph_index );
- if ( error )
- goto Exit;
-
- if ( header_only )
- goto Exit;
-
- if ( loader->byte_len == 0 || loader->n_contours == 0 )
- {
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- tt_get_metrics_incremental( loader, glyph_index );
-#endif
- tt_loader_set_pp( loader );
-
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
-
- if ( FT_IS_NAMED_INSTANCE( FT_FACE( face ) ) ||
- FT_IS_VARIATION( FT_FACE( face ) ) )
- {
- /* a small outline structure with four elements for */
- /* communication with `TT_Vary_Apply_Glyph_Deltas' */
- FT_Vector points[4];
- FT_Outline outline;
-
- /* unrounded values */
- FT_Vector unrounded[4] = { {0, 0}, {0, 0}, {0, 0}, {0, 0} };
-
-
- points[0] = loader->pp1;
- points[1] = loader->pp2;
- points[2] = loader->pp3;
- points[3] = loader->pp4;
-
- outline.n_points = 0;
- outline.n_contours = 0;
- outline.points = points;
- outline.tags = NULL;
- outline.contours = NULL;
-
- /* this must be done before scaling */
- error = TT_Vary_Apply_Glyph_Deltas( loader,
- &outline,
- unrounded );
- if ( error )
- goto Exit;
- }
-
-#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
-
- /* scale phantom points, if necessary; */
- /* they get rounded in `TT_Hint_Glyph' */
- if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 )
- {
- loader->pp1.x = FT_MulFix( loader->pp1.x, x_scale );
- loader->pp2.x = FT_MulFix( loader->pp2.x, x_scale );
- /* pp1.y and pp2.y are always zero */
-
- loader->pp3.x = FT_MulFix( loader->pp3.x, x_scale );
- loader->pp3.y = FT_MulFix( loader->pp3.y, y_scale );
- loader->pp4.x = FT_MulFix( loader->pp4.x, x_scale );
- loader->pp4.y = FT_MulFix( loader->pp4.y, y_scale );
- }
-
- error = FT_Err_Ok;
- goto Exit;
- }
-
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- tt_get_metrics_incremental( loader, glyph_index );
-#endif
- tt_loader_set_pp( loader );
-
-
- /***********************************************************************/
- /***********************************************************************/
- /***********************************************************************/
-
- /* we now open a frame again, right after the glyph header */
- /* (which consists of 10 bytes) */
- error = face->access_glyph_frame( loader, glyph_index,
- face->glyf_offset + offset + 10,
- loader->byte_len - 10 );
- if ( error )
- goto Exit;
-
- opened_frame = 1;
-
- /* if it is a simple glyph, load it */
-
- if ( loader->n_contours > 0 )
- {
- error = face->read_simple_glyph( loader );
- if ( error )
- goto Exit;
-
- /* all data have been read */
- face->forget_glyph_frame( loader );
- opened_frame = 0;
-
- error = TT_Process_Simple_Glyph( loader );
- if ( error )
- goto Exit;
-
- FT_GlyphLoader_Add( gloader );
- }
-
- /***********************************************************************/
- /***********************************************************************/
- /***********************************************************************/
-
- /* otherwise, load a composite! */
- else if ( loader->n_contours < 0 )
- {
- FT_Memory memory = face->root.memory;
-
- FT_UInt start_point;
- FT_UInt start_contour;
- FT_ULong ins_pos; /* position of composite instructions, if any */
-
- FT_ListNode node, node2;
-
-
- /* normalize the `n_contours' value */
- loader->n_contours = -1;
-
- /*
- * We store the glyph index directly in the `node->data' pointer,
- * following the glib solution (cf. macro `GUINT_TO_POINTER') with a
- * double cast to make this portable. Note, however, that this needs
- * pointers with a width of at least 32 bits.
- */
-
- /* clear the nodes filled by sibling chains */
- node = ft_list_get_node_at( &loader->composites, recurse_count );
- for ( node2 = node; node2; node2 = node2->next )
- node2->data = (void*)-1;
-
- /* check whether we already have a composite glyph with this index */
- if ( FT_List_Find( &loader->composites,
- FT_UINT_TO_POINTER( glyph_index ) ) )
- {
- FT_TRACE1(( "TT_Load_Composite_Glyph:"
- " infinite recursion detected\n" ));
- error = FT_THROW( Invalid_Composite );
- goto Exit;
- }
-
- else if ( node )
- node->data = FT_UINT_TO_POINTER( glyph_index );
-
- else
- {
- if ( FT_QNEW( node ) )
- goto Exit;
- node->data = FT_UINT_TO_POINTER( glyph_index );
- FT_List_Add( &loader->composites, node );
- }
-
- start_point = gloader->base.outline.n_points;
- start_contour = gloader->base.outline.n_contours;
-
- /* for each subglyph, read composite header */
- error = face->read_composite_glyph( loader );
- if ( error )
- goto Exit;
-
- /* store the offset of instructions */
- ins_pos = loader->ins_pos;
-
- /* all data we need are read */
- face->forget_glyph_frame( loader );
- opened_frame = 0;
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
-
- if ( FT_IS_NAMED_INSTANCE( FT_FACE( face ) ) ||
- FT_IS_VARIATION( FT_FACE( face ) ) )
- {
- FT_UShort i, limit;
- FT_SubGlyph subglyph;
-
- FT_Outline outline = { 0, 0, NULL, NULL, NULL, 0 };
- FT_Vector* unrounded = NULL;
-
-
- limit = (FT_UShort)gloader->current.num_subglyphs;
-
- /* construct an outline structure for */
- /* communication with `TT_Vary_Apply_Glyph_Deltas' */
- if ( FT_QNEW_ARRAY( outline.points, limit + 4 ) ||
- FT_QNEW_ARRAY( outline.tags, limit ) ||
- FT_QNEW_ARRAY( outline.contours, limit ) ||
- FT_QNEW_ARRAY( unrounded, limit + 4 ) )
- goto Exit1;
-
- outline.n_contours = outline.n_points = limit;
-
- subglyph = gloader->current.subglyphs;
-
- for ( i = 0; i < limit; i++, subglyph++ )
- {
- /* applying deltas for anchor points doesn't make sense, */
- /* but we don't have to specially check this since */
- /* unused delta values are zero anyways */
- outline.points[i].x = subglyph->arg1;
- outline.points[i].y = subglyph->arg2;
- outline.tags[i] = ON_CURVE_POINT;
- outline.contours[i] = i;
- }
-
- outline.points[i++] = loader->pp1;
- outline.points[i++] = loader->pp2;
- outline.points[i++] = loader->pp3;
- outline.points[i ] = loader->pp4;
-
- /* this call provides additional offsets */
- /* for each component's translation */
- if ( FT_SET_ERROR( TT_Vary_Apply_Glyph_Deltas( loader,
- &outline,
- unrounded ) ) )
- goto Exit1;
-
- subglyph = gloader->current.subglyphs;
-
- for ( i = 0; i < limit; i++, subglyph++ )
- {
- if ( subglyph->flags & ARGS_ARE_XY_VALUES )
- {
- subglyph->arg1 = (FT_Int16)outline.points[i].x;
- subglyph->arg2 = (FT_Int16)outline.points[i].y;
- }
- }
-
- Exit1:
- FT_FREE( outline.points );
- FT_FREE( outline.tags );
- FT_FREE( outline.contours );
- FT_FREE( unrounded );
-
- if ( error )
- goto Exit;
- }
-
-#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
-
- /* scale phantom points, if necessary; */
- /* they get rounded in `TT_Hint_Glyph' */
- if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 )
- {
- loader->pp1.x = FT_MulFix( loader->pp1.x, x_scale );
- loader->pp2.x = FT_MulFix( loader->pp2.x, x_scale );
- /* pp1.y and pp2.y are always zero */
-
- loader->pp3.x = FT_MulFix( loader->pp3.x, x_scale );
- loader->pp3.y = FT_MulFix( loader->pp3.y, y_scale );
- loader->pp4.x = FT_MulFix( loader->pp4.x, x_scale );
- loader->pp4.y = FT_MulFix( loader->pp4.y, y_scale );
- }
-
- /* if the flag FT_LOAD_NO_RECURSE is set, we return the subglyph */
- /* `as is' in the glyph slot (the client application will be */
- /* responsible for interpreting these data)... */
- if ( loader->load_flags & FT_LOAD_NO_RECURSE )
- {
- FT_GlyphLoader_Add( gloader );
- loader->glyph->format = FT_GLYPH_FORMAT_COMPOSITE;
-
- goto Exit;
- }
-
- /*********************************************************************/
- /*********************************************************************/
- /*********************************************************************/
-
- {
- FT_UInt n, num_base_points;
- FT_SubGlyph subglyph = NULL;
-
- FT_UInt num_points = start_point;
- FT_UInt num_subglyphs = gloader->current.num_subglyphs;
- FT_UInt num_base_subgs = gloader->base.num_subglyphs;
-
- FT_Stream old_stream = loader->stream;
- FT_UInt old_byte_len = loader->byte_len;
-
-
- FT_GlyphLoader_Add( gloader );
-
- /* read each subglyph independently */
- for ( n = 0; n < num_subglyphs; n++ )
- {
- FT_Vector pp[4];
-
- FT_Int linear_hadvance;
- FT_Int linear_vadvance;
-
-
- /* Each time we call `load_truetype_glyph' in this loop, the */
- /* value of `gloader.base.subglyphs' can change due to table */
- /* reallocations. We thus need to recompute the subglyph */
- /* pointer on each iteration. */
- subglyph = gloader->base.subglyphs + num_base_subgs + n;
-
- pp[0] = loader->pp1;
- pp[1] = loader->pp2;
- pp[2] = loader->pp3;
- pp[3] = loader->pp4;
-
- linear_hadvance = loader->linear;
- linear_vadvance = loader->vadvance;
-
- num_base_points = gloader->base.outline.n_points;
-
- error = load_truetype_glyph( loader,
- (FT_UInt)subglyph->index,
- recurse_count + 1,
- FALSE );
- if ( error )
- goto Exit;
-
- /* restore subglyph pointer */
- subglyph = gloader->base.subglyphs + num_base_subgs + n;
-
- /* restore phantom points if necessary */
- if ( !( subglyph->flags & USE_MY_METRICS ) )
- {
- loader->pp1 = pp[0];
- loader->pp2 = pp[1];
- loader->pp3 = pp[2];
- loader->pp4 = pp[3];
-
- loader->linear = linear_hadvance;
- loader->vadvance = linear_vadvance;
- }
-
- num_points = gloader->base.outline.n_points;
-
- if ( num_points == num_base_points )
- continue;
-
- /* gloader->base.outline consists of three parts: */
- /* */
- /* 0 ----> start_point ----> num_base_points ----> n_points */
- /* (1) (2) (3) */
- /* */
- /* (1) points that exist from the beginning */
- /* (2) component points that have been loaded so far */
- /* (3) points of the newly loaded component */
- error = TT_Process_Composite_Component( loader,
- subglyph,
- start_point,
- num_base_points );
- if ( error )
- goto Exit;
- }
-
- loader->stream = old_stream;
- loader->byte_len = old_byte_len;
-
- /* process the glyph */
- loader->ins_pos = ins_pos;
- if ( IS_HINTED( loader->load_flags ) &&
-#ifdef TT_USE_BYTECODE_INTERPRETER
- subglyph &&
- subglyph->flags & WE_HAVE_INSTR &&
-#endif
- num_points > start_point )
- {
- error = TT_Process_Composite_Glyph( loader,
- start_point,
- start_contour );
- if ( error )
- goto Exit;
- }
- }
-
- /* retain the overlap flag */
- if ( gloader->base.num_subglyphs &&
- gloader->base.subglyphs[0].flags & OVERLAP_COMPOUND )
- gloader->base.outline.flags |= FT_OUTLINE_OVERLAP;
- }
-
- /***********************************************************************/
- /***********************************************************************/
- /***********************************************************************/
-
- Exit:
-
- if ( opened_frame )
- face->forget_glyph_frame( loader );
-
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
-
- if ( glyph_data_loaded )
- face->root.internal->incremental_interface->funcs->free_glyph_data(
- face->root.internal->incremental_interface->object,
- &glyph_data );
-
-#endif
-
- return error;
- }
-
-
- static FT_Error
- compute_glyph_metrics( TT_Loader loader,
- FT_UInt glyph_index )
- {
- TT_Face face = loader->face;
- TT_Size size = loader->size;
- TT_GlyphSlot glyph = loader->glyph;
- FT_BBox bbox;
- FT_Fixed y_scale;
-
-
- y_scale = 0x10000L;
- if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 )
- y_scale = size->metrics->y_scale;
-
- if ( glyph->format != FT_GLYPH_FORMAT_COMPOSITE )
- FT_Outline_Get_CBox( &glyph->outline, &bbox );
- else
- bbox = loader->bbox;
-
- /* get the device-independent horizontal advance; it is scaled later */
- /* by the base layer. */
- glyph->linearHoriAdvance = loader->linear;
-
- glyph->metrics.horiBearingX = bbox.xMin;
- glyph->metrics.horiBearingY = bbox.yMax;
- if ( loader->widthp )
- glyph->metrics.horiAdvance = loader->widthp[glyph_index] * 64;
- else
- glyph->metrics.horiAdvance = SUB_LONG( loader->pp2.x, loader->pp1.x );
-
- /* set glyph dimensions */
- glyph->metrics.width = SUB_LONG( bbox.xMax, bbox.xMin );
- glyph->metrics.height = SUB_LONG( bbox.yMax, bbox.yMin );
-
- /* Now take care of vertical metrics. In the case where there is */
- /* no vertical information within the font (relatively common), */
- /* create some metrics manually */
- {
- FT_Pos top; /* scaled vertical top side bearing */
- FT_Pos advance; /* scaled vertical advance height */
-
-
- /* Get the unscaled top bearing and advance height. */
- if ( face->vertical_info &&
- face->vertical.number_Of_VMetrics > 0 )
- {
- top = (FT_Short)FT_DivFix( SUB_LONG( loader->pp3.y, bbox.yMax ),
- y_scale );
-
- if ( loader->pp3.y <= loader->pp4.y )
- advance = 0;
- else
- advance = (FT_UShort)FT_DivFix( SUB_LONG( loader->pp3.y,
- loader->pp4.y ),
- y_scale );
- }
- else
- {
- FT_Pos height;
-
-
- /* XXX Compute top side bearing and advance height in */
- /* Get_VMetrics instead of here. */
-
- /* NOTE: The OS/2 values are the only `portable' ones, */
- /* which is why we use them, if there is an OS/2 */
- /* table in the font. Otherwise, we use the */
- /* values defined in the horizontal header. */
-
- height = (FT_Short)FT_DivFix( SUB_LONG( bbox.yMax,
- bbox.yMin ),
- y_scale );
- if ( face->os2.version != 0xFFFFU )
- advance = (FT_Pos)( face->os2.sTypoAscender -
- face->os2.sTypoDescender );
- else
- advance = (FT_Pos)( face->horizontal.Ascender -
- face->horizontal.Descender );
-
- top = ( advance - height ) / 2;
- }
-
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- {
- FT_Incremental_InterfaceRec* incr;
- FT_Incremental_MetricsRec incr_metrics;
- FT_Error error;
-
-
- incr = face->root.internal->incremental_interface;
-
- /* If this is an incrementally loaded font see if there are */
- /* overriding metrics for this glyph. */
- if ( incr && incr->funcs->get_glyph_metrics )
- {
- incr_metrics.bearing_x = 0;
- incr_metrics.bearing_y = top;
- incr_metrics.advance = advance;
-
- error = incr->funcs->get_glyph_metrics( incr->object,
- glyph_index,
- TRUE,
- &incr_metrics );
- if ( error )
- return error;
-
- top = incr_metrics.bearing_y;
- advance = incr_metrics.advance;
- }
- }
-
- /* GWW: Do vertical metrics get loaded incrementally too? */
-
-#endif /* FT_CONFIG_OPTION_INCREMENTAL */
-
- glyph->linearVertAdvance = advance;
-
- /* scale the metrics */
- if ( !( loader->load_flags & FT_LOAD_NO_SCALE ) )
- {
- top = FT_MulFix( top, y_scale );
- advance = FT_MulFix( advance, y_scale );
- }
-
- /* XXX: for now, we have no better algorithm for the lsb, but it */
- /* should work fine. */
- /* */
- glyph->metrics.vertBearingX = SUB_LONG( glyph->metrics.horiBearingX,
- glyph->metrics.horiAdvance / 2 );
- glyph->metrics.vertBearingY = top;
- glyph->metrics.vertAdvance = advance;
- }
-
- return FT_Err_Ok;
- }
-
-
-#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
-
- static FT_Error
- load_sbit_image( TT_Size size,
- TT_GlyphSlot glyph,
- FT_UInt glyph_index,
- FT_Int32 load_flags )
- {
- TT_Face face = (TT_Face)glyph->face;
- SFNT_Service sfnt = (SFNT_Service)face->sfnt;
- FT_Stream stream = face->root.stream;
- FT_Error error;
- TT_SBit_MetricsRec sbit_metrics;
-
-
- error = sfnt->load_sbit_image( face,
- size->strike_index,
- glyph_index,
- (FT_UInt)load_flags,
- stream,
- &glyph->bitmap,
- &sbit_metrics );
- if ( !error )
- {
- glyph->outline.n_points = 0;
- glyph->outline.n_contours = 0;
-
- glyph->metrics.width = (FT_Pos)sbit_metrics.width * 64;
- glyph->metrics.height = (FT_Pos)sbit_metrics.height * 64;
-
- glyph->metrics.horiBearingX = (FT_Pos)sbit_metrics.horiBearingX * 64;
- glyph->metrics.horiBearingY = (FT_Pos)sbit_metrics.horiBearingY * 64;
- glyph->metrics.horiAdvance = (FT_Pos)sbit_metrics.horiAdvance * 64;
-
- glyph->metrics.vertBearingX = (FT_Pos)sbit_metrics.vertBearingX * 64;
- glyph->metrics.vertBearingY = (FT_Pos)sbit_metrics.vertBearingY * 64;
- glyph->metrics.vertAdvance = (FT_Pos)sbit_metrics.vertAdvance * 64;
-
- glyph->format = FT_GLYPH_FORMAT_BITMAP;
-
- if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
- {
- glyph->bitmap_left = sbit_metrics.vertBearingX;
- glyph->bitmap_top = sbit_metrics.vertBearingY;
- }
- else
- {
- glyph->bitmap_left = sbit_metrics.horiBearingX;
- glyph->bitmap_top = sbit_metrics.horiBearingY;
- }
- }
-
- return error;
- }
-
-#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
-
-
- static FT_Error
- tt_loader_init( TT_Loader loader,
- TT_Size size,
- TT_GlyphSlot glyph,
- FT_Int32 load_flags,
- FT_Bool glyf_table_only )
- {
- TT_Face face = (TT_Face)glyph->face;
- FT_Stream stream = face->root.stream;
-
-#ifdef TT_USE_BYTECODE_INTERPRETER
- FT_Error error;
- FT_Bool pedantic = FT_BOOL( load_flags & FT_LOAD_PEDANTIC );
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( glyph->face );
-#endif
-#endif
-
-
- FT_ZERO( loader );
-
-#ifdef TT_USE_BYTECODE_INTERPRETER
-
- /* load execution context */
- if ( IS_HINTED( load_flags ) && !glyf_table_only )
- {
- TT_ExecContext exec;
- FT_Bool grayscale = TRUE;
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- FT_Bool subpixel_hinting_lean;
- FT_Bool grayscale_cleartype;
-#endif
-
- FT_Bool reexecute = FALSE;
-
-
- if ( size->bytecode_ready < 0 || size->cvt_ready < 0 )
- {
- error = tt_size_ready_bytecode( size, pedantic );
- if ( error )
- return error;
- }
- else if ( size->bytecode_ready )
- return size->bytecode_ready;
- else if ( size->cvt_ready )
- return size->cvt_ready;
-
- /* query new execution context */
- exec = size->context;
- if ( !exec )
- return FT_THROW( Could_Not_Find_Context );
-
- grayscale = FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
- FT_RENDER_MODE_MONO );
-
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- if ( driver->interpreter_version == TT_INTERPRETER_VERSION_40 )
- {
- subpixel_hinting_lean =
- FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
- FT_RENDER_MODE_MONO );
- grayscale_cleartype =
- FT_BOOL( subpixel_hinting_lean &&
- !( ( load_flags &
- FT_LOAD_TARGET_LCD ) ||
- ( load_flags &
- FT_LOAD_TARGET_LCD_V ) ) );
- exec->vertical_lcd_lean =
- FT_BOOL( subpixel_hinting_lean &&
- ( load_flags &
- FT_LOAD_TARGET_LCD_V ) );
- grayscale = FT_BOOL( grayscale && !subpixel_hinting_lean );
- }
- else
- {
- subpixel_hinting_lean = FALSE;
- grayscale_cleartype = FALSE;
- exec->vertical_lcd_lean = FALSE;
- }
-#endif
-
- error = TT_Load_Context( exec, face, size );
- if ( error )
- return error;
-
- {
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- if ( driver->interpreter_version == TT_INTERPRETER_VERSION_40 )
- {
- /* a change from mono to subpixel rendering (and vice versa) */
- /* requires a re-execution of the CVT program */
- if ( subpixel_hinting_lean != exec->subpixel_hinting_lean )
- {
- FT_TRACE4(( "tt_loader_init: subpixel hinting change,"
- " re-executing `prep' table\n" ));
-
- exec->subpixel_hinting_lean = subpixel_hinting_lean;
- reexecute = TRUE;
- }
-
- /* a change from colored to grayscale subpixel rendering (and */
- /* vice versa) requires a re-execution of the CVT program */
- if ( grayscale_cleartype != exec->grayscale_cleartype )
- {
- FT_TRACE4(( "tt_loader_init: grayscale subpixel hinting change,"
- " re-executing `prep' table\n" ));
-
- exec->grayscale_cleartype = grayscale_cleartype;
- reexecute = TRUE;
- }
- }
-#endif
-
- /* a change from mono to grayscale rendering (and vice versa) */
- /* requires a re-execution of the CVT program */
- if ( grayscale != exec->grayscale )
- {
- FT_TRACE4(( "tt_loader_init: grayscale hinting change,"
- " re-executing `prep' table\n" ));
-
- exec->grayscale = grayscale;
- reexecute = TRUE;
- }
- }
-
- if ( reexecute )
- {
- error = tt_size_run_prep( size, pedantic );
- if ( error )
- return error;
- error = TT_Load_Context( exec, face, size );
- if ( error )
- return error;
- }
-
- /* check whether the cvt program has disabled hinting */
- if ( exec->GS.instruct_control & 1 )
- load_flags |= FT_LOAD_NO_HINTING;
-
- /* load default graphics state -- if needed */
- if ( exec->GS.instruct_control & 2 )
- exec->GS = tt_default_graphics_state;
-
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- /*
- * Toggle backward compatibility according to what font wants, except
- * when
- *
- * 1) we have a `tricky' font that heavily relies on the interpreter to
- * render glyphs correctly, for example DFKai-SB, or
- * 2) FT_RENDER_MODE_MONO (i.e, monochrome rendering) is requested.
- *
- * In those cases, backward compatibility needs to be turned off to get
- * correct rendering. The rendering is then completely up to the
- * font's programming.
- *
- */
- if ( driver->interpreter_version == TT_INTERPRETER_VERSION_40 &&
- subpixel_hinting_lean &&
- !FT_IS_TRICKY( glyph->face ) )
- exec->backward_compatibility = !( exec->GS.instruct_control & 4 );
- else
- exec->backward_compatibility = FALSE;
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL */
-
- exec->pedantic_hinting = FT_BOOL( load_flags & FT_LOAD_PEDANTIC );
- loader->exec = exec;
- loader->instructions = exec->glyphIns;
-
- /* Use the hdmx table if any unless FT_LOAD_COMPUTE_METRICS */
- /* is set or backward compatibility mode of the v38 or v40 */
- /* interpreters is active. See `ttinterp.h' for details on */
- /* backward compatibility mode. */
- if ( IS_HINTED( loader->load_flags ) &&
- !( loader->load_flags & FT_LOAD_COMPUTE_METRICS ) &&
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- !( driver->interpreter_version == TT_INTERPRETER_VERSION_40 &&
- exec->backward_compatibility ) &&
-#endif
- !face->postscript.isFixedPitch )
- {
- loader->widthp = size->widthp;
- }
- else
- loader->widthp = NULL;
- }
-
-#endif /* TT_USE_BYTECODE_INTERPRETER */
-
- /* get face's glyph loader */
- if ( !glyf_table_only )
- {
- FT_GlyphLoader gloader = glyph->internal->loader;
-
-
- FT_GlyphLoader_Rewind( gloader );
- loader->gloader = gloader;
- }
-
- loader->load_flags = (FT_ULong)load_flags;
-
- loader->face = face;
- loader->size = size;
- loader->glyph = (FT_GlyphSlot)glyph;
- loader->stream = stream;
-
- loader->composites.head = NULL;
- loader->composites.tail = NULL;
-
- return FT_Err_Ok;
- }
-
-
- static void
- tt_loader_done( TT_Loader loader )
- {
- FT_List_Finalize( &loader->composites,
- NULL,
- loader->face->root.memory,
- NULL );
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * TT_Load_Glyph
- *
- * @Description:
- * A function used to load a single glyph within a given glyph slot,
- * for a given size.
- *
- * @InOut:
- * glyph ::
- * A handle to a target slot object where the glyph
- * will be loaded.
- *
- * @Input:
- * size ::
- * A handle to the source face size at which the glyph
- * must be scaled/loaded.
- *
- * glyph_index ::
- * The index of the glyph in the font file.
- *
- * load_flags ::
- * A flag indicating what to load for this glyph. The
- * FT_LOAD_XXX constants can be used to control the
- * glyph loading process (e.g., whether the outline
- * should be scaled, whether to load bitmaps or not,
- * whether to hint the outline, etc).
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
- FT_LOCAL_DEF( FT_Error )
- TT_Load_Glyph( TT_Size size,
- TT_GlyphSlot glyph,
- FT_UInt glyph_index,
- FT_Int32 load_flags )
- {
- TT_Face face = (TT_Face)glyph->face;
- FT_Error error;
- TT_LoaderRec loader;
-
-
- FT_TRACE1(( "TT_Load_Glyph: glyph index %d\n", glyph_index ));
-
-#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
-
- /* try to load embedded bitmap (if any) */
- if ( size->strike_index != 0xFFFFFFFFUL &&
- ( load_flags & FT_LOAD_NO_BITMAP ) == 0 &&
- IS_DEFAULT_INSTANCE( glyph->face ) )
- {
- FT_Fixed x_scale = size->root.metrics.x_scale;
- FT_Fixed y_scale = size->root.metrics.y_scale;
-
-
- error = load_sbit_image( size, glyph, glyph_index, load_flags );
- if ( FT_ERR_EQ( error, Missing_Bitmap ) )
- {
- /* the bitmap strike is incomplete and misses the requested glyph; */
- /* if we have a bitmap-only font, return an empty glyph */
- if ( !FT_IS_SCALABLE( glyph->face ) )
- {
- FT_Short left_bearing = 0;
- FT_Short top_bearing = 0;
-
- FT_UShort advance_width = 0;
- FT_UShort advance_height = 0;
-
-
- /* to return an empty glyph, however, we need metrics data */
- /* from the `hmtx' (or `vmtx') table; the assumption is that */
- /* empty glyphs are missing intentionally, representing */
- /* whitespace - not having at least horizontal metrics is */
- /* thus considered an error */
- if ( !face->horz_metrics_size )
- return error;
-
- /* we now construct an empty bitmap glyph */
- TT_Get_HMetrics( face, glyph_index,
- &left_bearing,
- &advance_width );
- TT_Get_VMetrics( face, glyph_index,
- 0,
- &top_bearing,
- &advance_height );
-
- glyph->outline.n_points = 0;
- glyph->outline.n_contours = 0;
-
- glyph->metrics.width = 0;
- glyph->metrics.height = 0;
-
- glyph->metrics.horiBearingX = FT_MulFix( left_bearing, x_scale );
- glyph->metrics.horiBearingY = 0;
- glyph->metrics.horiAdvance = FT_MulFix( advance_width, x_scale );
-
- glyph->metrics.vertBearingX = 0;
- glyph->metrics.vertBearingY = FT_MulFix( top_bearing, y_scale );
- glyph->metrics.vertAdvance = FT_MulFix( advance_height, y_scale );
-
- glyph->format = FT_GLYPH_FORMAT_BITMAP;
- glyph->bitmap.pixel_mode = FT_PIXEL_MODE_MONO;
-
- glyph->bitmap_left = 0;
- glyph->bitmap_top = 0;
-
- return FT_Err_Ok;
- }
- }
- else if ( error )
- {
- /* return error if font is not scalable */
- if ( !FT_IS_SCALABLE( glyph->face ) )
- return error;
- }
- else
- {
- if ( FT_IS_SCALABLE( glyph->face ) ||
- FT_HAS_SBIX( glyph->face ) )
- {
- /* for the bbox we need the header only */
- (void)tt_loader_init( &loader, size, glyph, load_flags, TRUE );
- (void)load_truetype_glyph( &loader, glyph_index, 0, TRUE );
- tt_loader_done( &loader );
- glyph->linearHoriAdvance = loader.linear;
- glyph->linearVertAdvance = loader.vadvance;
-
- /* Bitmaps from the 'sbix' table need special treatment: */
- /* if there is a glyph contour, the bitmap origin must be */
- /* shifted to be relative to the lower left corner of the */
- /* glyph bounding box, also taking the left-side bearing */
- /* (or top bearing) into account. */
- if ( face->sbit_table_type == TT_SBIT_TABLE_TYPE_SBIX &&
- loader.n_contours > 0 )
- {
- FT_Int bitmap_left;
- FT_Int bitmap_top;
-
-
- if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
- {
- /* This is a guess, since Apple's CoreText engine doesn't */
- /* really do vertical typesetting. */
- bitmap_left = loader.bbox.xMin;
- bitmap_top = loader.top_bearing;
- }
- else
- {
- bitmap_left = loader.left_bearing;
- bitmap_top = loader.bbox.yMin;
- }
-
- glyph->bitmap_left += FT_MulFix( bitmap_left, x_scale ) >> 6;
- glyph->bitmap_top += FT_MulFix( bitmap_top, y_scale ) >> 6;
- }
-
- /* sanity checks: if `xxxAdvance' in the sbit metric */
- /* structure isn't set, use `linearXXXAdvance' */
- if ( !glyph->metrics.horiAdvance && glyph->linearHoriAdvance )
- glyph->metrics.horiAdvance = FT_MulFix( glyph->linearHoriAdvance,
- x_scale );
- if ( !glyph->metrics.vertAdvance && glyph->linearVertAdvance )
- glyph->metrics.vertAdvance = FT_MulFix( glyph->linearVertAdvance,
- y_scale );
- }
-
- return FT_Err_Ok;
- }
- }
-
- if ( load_flags & FT_LOAD_SBITS_ONLY )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
-#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
-
- /* if FT_LOAD_NO_SCALE is not set, `ttmetrics' must be valid */
- if ( !( load_flags & FT_LOAD_NO_SCALE ) && !size->ttmetrics.valid )
- {
- error = FT_THROW( Invalid_Size_Handle );
- goto Exit;
- }
-
-#ifdef FT_CONFIG_OPTION_SVG
-
- /* check for OT-SVG */
- if ( ( load_flags & FT_LOAD_NO_SVG ) == 0 &&
- ( load_flags & FT_LOAD_COLOR ) &&
- face->svg )
- {
- SFNT_Service sfnt = (SFNT_Service)face->sfnt;
-
-
- FT_TRACE3(( "Trying to load SVG glyph\n" ));
-
- error = sfnt->load_svg_doc( glyph, glyph_index );
- if ( !error )
- {
- FT_Fixed x_scale = size->root.metrics.x_scale;
- FT_Fixed y_scale = size->root.metrics.y_scale;
-
- FT_Short leftBearing;
- FT_Short topBearing;
- FT_UShort advanceX;
- FT_UShort advanceY;
-
-
- FT_TRACE3(( "Successfully loaded SVG glyph\n" ));
-
- glyph->format = FT_GLYPH_FORMAT_SVG;
-
- sfnt->get_metrics( face,
- FALSE,
- glyph_index,
- &leftBearing,
- &advanceX );
- sfnt->get_metrics( face,
- TRUE,
- glyph_index,
- &topBearing,
- &advanceY );
-
- glyph->linearHoriAdvance = advanceX;
- glyph->linearVertAdvance = advanceY;
-
- glyph->metrics.horiAdvance = FT_MulFix( advanceX, x_scale );
- glyph->metrics.vertAdvance = FT_MulFix( advanceY, y_scale );
-
- return error;
- }
-
- FT_TRACE3(( "Failed to load SVG glyph\n" ));
- }
-
- /* return immediately if we only want SVG glyphs */
- if ( load_flags & FT_LOAD_SVG_ONLY )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
-#endif /* FT_CONFIG_OPTION_SVG */
-
- error = tt_loader_init( &loader, size, glyph, load_flags, FALSE );
- if ( error )
- goto Exit;
-
- /* done if we are only interested in the `hdmx` advance */
- if ( load_flags & FT_LOAD_ADVANCE_ONLY &&
- !( load_flags & FT_LOAD_VERTICAL_LAYOUT ) &&
- loader.widthp )
- {
- glyph->metrics.horiAdvance = loader.widthp[glyph_index] * 64;
- goto Done;
- }
-
- glyph->format = FT_GLYPH_FORMAT_OUTLINE;
- glyph->num_subglyphs = 0;
- glyph->outline.flags = 0;
-
- /* main loading loop */
- error = load_truetype_glyph( &loader, glyph_index, 0, FALSE );
- if ( !error )
- {
- if ( glyph->format == FT_GLYPH_FORMAT_COMPOSITE )
- {
- glyph->num_subglyphs = loader.gloader->base.num_subglyphs;
- glyph->subglyphs = loader.gloader->base.subglyphs;
- }
- else
- {
- glyph->outline = loader.gloader->base.outline;
- glyph->outline.flags &= ~FT_OUTLINE_SINGLE_PASS;
-
- /* Translate array so that (0,0) is the glyph's origin. Note */
- /* that this behaviour is independent on the value of bit 1 of */
- /* the `flags' field in the `head' table -- at least major */
- /* applications like Acroread indicate that. */
- if ( loader.pp1.x )
- FT_Outline_Translate( &glyph->outline, -loader.pp1.x, 0 );
- }
-
-#ifdef TT_USE_BYTECODE_INTERPRETER
-
- if ( IS_HINTED( load_flags ) )
- {
- glyph->control_data = loader.exec->glyphIns;
- glyph->control_len = loader.exec->glyphSize;
-
- if ( loader.exec->GS.scan_control )
- {
- /* convert scan conversion mode to FT_OUTLINE_XXX flags */
- switch ( loader.exec->GS.scan_type )
- {
- case 0: /* simple drop-outs including stubs */
- glyph->outline.flags |= FT_OUTLINE_INCLUDE_STUBS;
- break;
- case 1: /* simple drop-outs excluding stubs */
- /* nothing; it's the default rendering mode */
- break;
- case 4: /* smart drop-outs including stubs */
- glyph->outline.flags |= FT_OUTLINE_SMART_DROPOUTS |
- FT_OUTLINE_INCLUDE_STUBS;
- break;
- case 5: /* smart drop-outs excluding stubs */
- glyph->outline.flags |= FT_OUTLINE_SMART_DROPOUTS;
- break;
-
- default: /* no drop-out control */
- glyph->outline.flags |= FT_OUTLINE_IGNORE_DROPOUTS;
- break;
- }
- }
- else
- glyph->outline.flags |= FT_OUTLINE_IGNORE_DROPOUTS;
- }
-
-#endif /* TT_USE_BYTECODE_INTERPRETER */
-
- error = compute_glyph_metrics( &loader, glyph_index );
- }
-
- /* Set the `high precision' bit flag. */
- /* This is _critical_ to get correct output for monochrome */
- /* TrueType glyphs at all sizes using the bytecode interpreter. */
- /* */
- if ( !( load_flags & FT_LOAD_NO_SCALE ) &&
- size->metrics->y_ppem < 24 )
- glyph->outline.flags |= FT_OUTLINE_HIGH_PRECISION;
-
- FT_TRACE1(( " subglyphs = %u, contours = %hu, points = %hu,"
- " flags = 0x%.3x\n",
- loader.gloader->base.num_subglyphs,
- glyph->outline.n_contours,
- glyph->outline.n_points,
- glyph->outline.flags ));
-
- Done:
- tt_loader_done( &loader );
-
- Exit:
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( error )
- FT_TRACE1(( " failed (error code 0x%x)\n",
- error ));
-#endif
-
- return error;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/truetype/ttgload.h b/contrib/libs/freetype/src/truetype/ttgload.h
deleted file mode 100644
index 22ea967f30..0000000000
--- a/contrib/libs/freetype/src/truetype/ttgload.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/****************************************************************************
- *
- * ttgload.h
- *
- * TrueType Glyph Loader (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef TTGLOAD_H_
-#define TTGLOAD_H_
-
-
-#include "ttobjs.h"
-
-#ifdef TT_USE_BYTECODE_INTERPRETER
-#include "ttinterp.h"
-#endif
-
-
-FT_BEGIN_HEADER
-
-
- FT_LOCAL( void )
- TT_Init_Glyph_Loading( TT_Face face );
-
- FT_LOCAL( void )
- TT_Get_HMetrics( TT_Face face,
- FT_UInt idx,
- FT_Short* lsb,
- FT_UShort* aw );
-
- FT_LOCAL( void )
- TT_Get_VMetrics( TT_Face face,
- FT_UInt idx,
- FT_Pos yMax,
- FT_Short* tsb,
- FT_UShort* ah );
-
- FT_LOCAL( FT_Error )
- TT_Load_Glyph( TT_Size size,
- TT_GlyphSlot glyph,
- FT_UInt glyph_index,
- FT_Int32 load_flags );
-
-
-FT_END_HEADER
-
-#endif /* TTGLOAD_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/truetype/ttgxvar.c b/contrib/libs/freetype/src/truetype/ttgxvar.c
deleted file mode 100644
index 4f0083c96b..0000000000
--- a/contrib/libs/freetype/src/truetype/ttgxvar.c
+++ /dev/null
@@ -1,4594 +0,0 @@
-/****************************************************************************
- *
- * ttgxvar.c
- *
- * TrueType GX Font Variation loader
- *
- * Copyright (C) 2004-2024 by
- * David Turner, Robert Wilhelm, Werner Lemberg, and George Williams.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /**************************************************************************
- *
- * Apple documents the `fvar', `gvar', `cvar', and `avar' tables at
- *
- * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6[fgca]var.html
- *
- * The documentation for `gvar' is not intelligible; `cvar' refers you
- * to `gvar' and is thus also incomprehensible.
- *
- * The documentation for `avar' appears correct, but Apple has no fonts
- * with an `avar' table, so it is hard to test.
- *
- * Many thanks to John Jenkins (at Apple) in figuring this out.
- *
- *
- * Apple's `kern' table has some references to tuple indices, but as
- * there is no indication where these indices are defined, nor how to
- * interpolate the kerning values (different tuples have different
- * classes) this issue is ignored.
- *
- */
-
-
-#include <ft2build.h>
-#include <freetype/internal/ftdebug.h>
-#include FT_CONFIG_CONFIG_H
-#include <freetype/internal/ftcalc.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/internal/sfnt.h>
-#include <freetype/internal/services/svmetric.h>
-#include <freetype/tttags.h>
-#include <freetype/ttnameid.h>
-#include <freetype/ftmm.h>
-#include <freetype/ftlist.h>
-
-#include "ttpload.h"
-#include "ttgxvar.h"
-
-#include "tterrors.h"
-
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
-
-
-#define FT_Stream_FTell( stream ) \
- (FT_ULong)( (stream)->cursor - (stream)->base )
-#define FT_Stream_SeekSet( stream, off ) \
- (stream)->cursor = \
- ( (off) < (FT_ULong)( (stream)->limit - (stream)->base ) ) \
- ? (stream)->base + (off) \
- : (stream)->limit
-
-
- /* some macros we need */
-#define FT_fdot14ToFixed( x ) \
- ( (FT_Fixed)( (FT_ULong)(x) << 2 ) )
-#define FT_intToFixed( i ) \
- ( (FT_Fixed)( (FT_ULong)(i) << 16 ) )
-#define FT_fdot6ToFixed( i ) \
- ( (FT_Fixed)( (FT_ULong)(i) << 10 ) )
-#define FT_fixedToInt( x ) \
- ( (FT_Short)( ( (x) + 0x8000U ) >> 16 ) )
-#define FT_fixedToFdot6( x ) \
- ( (FT_Pos)( ( (x) + 0x200 ) >> 10 ) )
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT ttgxvar
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** Internal Routines *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /**************************************************************************
- *
- * The macro ALL_POINTS is used in `ft_var_readpackedpoints'. It
- * indicates that there is a delta for every point without needing to
- * enumerate all of them.
- */
-
- /* ensure that value `0' has the same width as a pointer */
-#define ALL_POINTS (FT_UShort*)~(FT_PtrDist)0
-
-
-#define GX_PT_POINTS_ARE_WORDS 0x80U
-#define GX_PT_POINT_RUN_COUNT_MASK 0x7FU
-
-
- /**************************************************************************
- *
- * @Function:
- * ft_var_readpackedpoints
- *
- * @Description:
- * Read a set of points to which the following deltas will apply.
- * Points are packed with a run length encoding.
- *
- * @Input:
- * stream ::
- * The data stream.
- *
- * @Output:
- * point_cnt ::
- * The number of points read. A zero value means that
- * all points in the glyph will be affected, without
- * enumerating them individually.
- *
- * @Return:
- * An array of FT_UShort containing the affected points or the
- * special value ALL_POINTS.
- */
- static FT_UShort*
- ft_var_readpackedpoints( FT_Stream stream,
- FT_UInt *point_cnt )
- {
- FT_UShort *points = NULL;
- FT_UInt n;
- FT_UInt runcnt, cnt;
- FT_UInt i, j;
- FT_UShort first;
- FT_Byte* p;
- FT_Memory memory = stream->memory;
- FT_Error error;
-
-
- *point_cnt = 0;
-
- n = FT_GET_BYTE();
- if ( n == 0 )
- return ALL_POINTS;
-
- if ( n & GX_PT_POINTS_ARE_WORDS )
- {
- n &= GX_PT_POINT_RUN_COUNT_MASK;
- n <<= 8;
- n |= FT_GET_BYTE();
- }
-
- if ( FT_QNEW_ARRAY( points, n ) )
- return NULL;
-
- p = stream->cursor;
- first = 0;
- i = 0;
- while ( i < n )
- {
- if ( p >= stream->limit )
- goto Fail;
-
- runcnt = FT_NEXT_BYTE( p );
- cnt = runcnt & GX_PT_POINT_RUN_COUNT_MASK;
-
- /* first point not included in run count */
- cnt++;
- if ( cnt > n - i )
- cnt = n - i;
-
- if ( runcnt & GX_PT_POINTS_ARE_WORDS )
- {
- if ( 2 * cnt > (FT_UInt)( stream->limit - p ) )
- goto Fail;
-
- for ( j = 0; j < cnt; j++ )
- {
- first += FT_NEXT_USHORT( p );
- points[i++] = first;
- }
- }
- else
- {
- if ( cnt > (FT_UInt)( stream->limit - p ) )
- goto Fail;
-
- for ( j = 0; j < cnt; j++ )
- {
- first += FT_NEXT_BYTE( p );
- points[i++] = first;
- }
- }
- }
-
- stream->cursor = p;
-
- *point_cnt = n;
-
- return points;
-
- Fail:
- FT_TRACE1(( "ft_var_readpackedpoints: invalid table\n" ));
-
- FT_FREE( points );
- return NULL;
- }
-
-
-#define GX_DT_DELTAS_ARE_ZERO 0x80U
-#define GX_DT_DELTAS_ARE_WORDS 0x40U
-#define GX_DT_DELTA_RUN_COUNT_MASK 0x3FU
-
-
- /**************************************************************************
- *
- * @Function:
- * ft_var_readpackeddeltas
- *
- * @Description:
- * Read a set of deltas. These are packed slightly differently than
- * points. In particular there is no overall count.
- *
- * @Input:
- * stream ::
- * The data stream.
- *
- * delta_cnt ::
- * The number of deltas to be read.
- *
- * @Return:
- * An array of FT_Fixed containing the deltas for the affected
- * points. (This only gets the deltas for one dimension. It will
- * generally be called twice, once for x, once for y. When used in
- * cvt table, it will only be called once.)
- *
- * We use FT_Fixed to avoid accumulation errors while summing up all
- * deltas (the rounding to integer values happens as the very last
- * step).
- */
- static FT_Fixed*
- ft_var_readpackeddeltas( FT_Stream stream,
- FT_UInt delta_cnt )
- {
- FT_Fixed *deltas = NULL;
- FT_UInt runcnt, cnt;
- FT_UInt i, j;
- FT_Byte* p;
- FT_Memory memory = stream->memory;
- FT_Error error;
-
-
- if ( FT_QNEW_ARRAY( deltas, delta_cnt ) )
- return NULL;
-
- p = stream->cursor;
- i = 0;
- while ( i < delta_cnt )
- {
- if ( p >= stream->limit )
- goto Fail;
-
- runcnt = FT_NEXT_BYTE( p );
- cnt = runcnt & GX_DT_DELTA_RUN_COUNT_MASK;
-
- /* first point not included in run count */
- cnt++;
- if ( cnt > delta_cnt - i )
- cnt = delta_cnt - i;
-
- if ( runcnt & GX_DT_DELTAS_ARE_ZERO )
- {
- for ( j = 0; j < cnt; j++ )
- deltas[i++] = 0;
- }
- else if ( runcnt & GX_DT_DELTAS_ARE_WORDS )
- {
- if ( 2 * cnt > (FT_UInt)( stream->limit - p ) )
- goto Fail;
-
- for ( j = 0; j < cnt; j++ )
- deltas[i++] = FT_intToFixed( FT_NEXT_SHORT( p ) );
- }
- else
- {
- if ( cnt > (FT_UInt)( stream->limit - p ) )
- goto Fail;
-
- for ( j = 0; j < cnt; j++ )
- deltas[i++] = FT_intToFixed( FT_NEXT_CHAR( p ) );
- }
- }
-
- stream->cursor = p;
-
- return deltas;
-
- Fail:
- FT_TRACE1(( "ft_var_readpackeddeltas: invalid table\n" ));
-
- FT_FREE( deltas );
- return NULL;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * ft_var_load_avar
- *
- * @Description:
- * Parse the `avar' table if present. It need not be, so we return
- * nothing.
- *
- * @InOut:
- * face ::
- * The font face.
- */
- static void
- ft_var_load_avar( TT_Face face )
- {
- FT_Error error;
- FT_Stream stream = FT_FACE_STREAM( face );
- FT_Memory memory = stream->memory;
- FT_Int i, j;
-
- GX_Blend blend = face->blend;
- GX_AVarSegment segment;
- GX_AVarTable table;
-
- FT_Long version;
- FT_Long axisCount;
- FT_ULong table_len;
-
-#ifndef TT_CONFIG_OPTION_NO_BORING_EXPANSION
- FT_ULong table_offset;
- FT_ULong store_offset;
- FT_ULong axisMap_offset;
-#endif
-
-
- FT_TRACE2(( "AVAR " ));
-
- blend->avar_loaded = TRUE;
- error = face->goto_table( face, TTAG_avar, stream, &table_len );
- if ( error )
- {
- FT_TRACE2(( "is missing\n" ));
- return;
- }
-
-#ifndef TT_CONFIG_OPTION_NO_BORING_EXPANSION
- table_offset = FT_STREAM_POS();
-#endif
-
- if ( FT_FRAME_ENTER( table_len ) )
- return;
-
- version = FT_GET_LONG();
- axisCount = FT_GET_LONG();
-
- if ( version != 0x00010000L
-#ifndef TT_CONFIG_OPTION_NO_BORING_EXPANSION
- && version != 0x00020000L
-#endif
- )
- {
- FT_TRACE2(( "bad table version\n" ));
- goto Exit;
- }
-
- FT_TRACE2(( "loaded\n" ));
-
- if ( axisCount != (FT_Long)blend->mmvar->num_axis )
- {
- FT_TRACE2(( "ft_var_load_avar:"
- " number of axes in `avar' and `fvar'\n" ));
- FT_TRACE2(( " table are different\n" ));
- goto Exit;
- }
-
- if ( FT_NEW( blend->avar_table ) )
- goto Exit;
- table = blend->avar_table;
-
- if ( FT_QNEW_ARRAY( table->avar_segment, axisCount ) )
- goto Exit;
-
- segment = &table->avar_segment[0];
- for ( i = 0; i < axisCount; i++, segment++ )
- {
- FT_TRACE5(( " axis %d:\n", i ));
-
- segment->pairCount = FT_GET_USHORT();
- if ( (FT_ULong)segment->pairCount * 4 > table_len ||
- FT_QNEW_ARRAY( segment->correspondence, segment->pairCount ) )
- {
- /* Failure. Free everything we have done so far. We must do */
- /* it right now since loading the `avar' table is optional. */
-
- for ( j = i - 1; j >= 0; j-- )
- FT_FREE( table->avar_segment[j].correspondence );
-
- FT_FREE( table->avar_segment );
- goto Exit;
- }
-
- for ( j = 0; j < segment->pairCount; j++ )
- {
- segment->correspondence[j].fromCoord =
- FT_fdot14ToFixed( FT_GET_SHORT() );
- segment->correspondence[j].toCoord =
- FT_fdot14ToFixed( FT_GET_SHORT() );
-
- FT_TRACE5(( " mapping %.5f to %.5f\n",
- (double)segment->correspondence[j].fromCoord / 65536,
- (double)segment->correspondence[j].toCoord / 65536 ));
- }
-
- FT_TRACE5(( "\n" ));
- }
-
-#ifndef TT_CONFIG_OPTION_NO_BORING_EXPANSION
- if ( version < 0x00020000L )
- goto Exit;
-
- axisMap_offset = FT_GET_ULONG();
- store_offset = FT_GET_ULONG();
-
- if ( store_offset )
- {
- error = tt_var_load_item_variation_store(
- FT_FACE( face ),
- table_offset + store_offset,
- &table->itemStore );
- if ( error )
- goto Exit;
- }
-
- if ( axisMap_offset )
- {
- error = tt_var_load_delta_set_index_mapping(
- FT_FACE( face ),
- table_offset + axisMap_offset,
- &table->axisMap,
- &table->itemStore,
- table_len );
- if ( error )
- goto Exit;
- }
-#endif
-
-
- Exit:
- FT_FRAME_EXIT();
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- tt_var_load_item_variation_store( FT_Face face, /* TT_Face */
- FT_ULong offset,
- GX_ItemVarStore itemStore )
- {
- TT_Face ttface = (TT_Face)face;
- FT_Stream stream = FT_FACE_STREAM( face );
- FT_Memory memory = stream->memory;
-
- FT_Error error;
- FT_UShort format;
- FT_ULong region_offset;
-
- FT_UInt data_count;
- FT_UShort axis_count;
- FT_UInt region_count;
-
- FT_UInt i, j;
- FT_Bool long_words;
-
- GX_Blend blend = ttface->blend;
- FT_ULong* dataOffsetArray = NULL;
-
-
- if ( FT_STREAM_SEEK( offset ) ||
- FT_READ_USHORT( format ) )
- goto Exit;
-
- if ( format != 1 )
- {
- FT_TRACE2(( "tt_var_load_item_variation_store: bad store format %d\n",
- format ));
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- /* read top level fields */
- if ( FT_READ_ULONG( region_offset ) ||
- FT_READ_USHORT( data_count ) )
- goto Exit;
-
- /* we need at least one entry in `itemStore->varData' */
- if ( !data_count )
- {
- FT_TRACE2(( "tt_var_load_item_variation_store: missing varData\n" ));
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- /* make temporary copy of item variation data offsets; */
- /* we will parse region list first, then come back */
- if ( FT_QNEW_ARRAY( dataOffsetArray, data_count ) )
- goto Exit;
-
- for ( i = 0; i < data_count; i++ )
- {
- if ( FT_READ_ULONG( dataOffsetArray[i] ) )
- goto Exit;
- }
-
- /* parse array of region records (region list) */
- if ( FT_STREAM_SEEK( offset + region_offset ) )
- goto Exit;
-
- if ( FT_READ_USHORT( axis_count ) ||
- FT_READ_USHORT( region_count ) )
- goto Exit;
-
- if ( axis_count != (FT_Long)blend->mmvar->num_axis )
- {
- FT_TRACE2(( "tt_var_load_item_variation_store:"
- " number of axes in item variation store\n" ));
- FT_TRACE2(( " "
- " and `fvar' table are different\n" ));
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
- itemStore->axisCount = axis_count;
-
- /* new constraint in OpenType 1.8.4 */
- if ( region_count >= 32768U )
- {
- FT_TRACE2(( "tt_var_load_item_variation_store:"
- " too many variation region tables\n" ));
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- if ( FT_NEW_ARRAY( itemStore->varRegionList, region_count ) )
- goto Exit;
- itemStore->regionCount = region_count;
-
- for ( i = 0; i < itemStore->regionCount; i++ )
- {
- GX_AxisCoords axisCoords;
-
-
- if ( FT_NEW_ARRAY( itemStore->varRegionList[i].axisList, axis_count ) )
- goto Exit;
-
- axisCoords = itemStore->varRegionList[i].axisList;
-
- for ( j = 0; j < itemStore->axisCount; j++ )
- {
- FT_Int start, peak, end;
-
-
- if ( FT_READ_SHORT( start ) ||
- FT_READ_SHORT( peak ) ||
- FT_READ_SHORT( end ) )
- goto Exit;
-
- /* immediately tag invalid ranges with special peak = 0 */
- if ( ( start < 0 && end > 0 ) || start > peak || peak > end )
- peak = 0;
-
- axisCoords[j].startCoord = FT_fdot14ToFixed( start );
- axisCoords[j].peakCoord = FT_fdot14ToFixed( peak );
- axisCoords[j].endCoord = FT_fdot14ToFixed( end );
- }
- }
-
- /* end of region list parse */
-
- /* use dataOffsetArray now to parse varData items */
- if ( FT_NEW_ARRAY( itemStore->varData, data_count ) )
- goto Exit;
- itemStore->dataCount = data_count;
-
- for ( i = 0; i < data_count; i++ )
- {
- GX_ItemVarData varData = &itemStore->varData[i];
-
- FT_UInt item_count;
- FT_UShort word_delta_count;
- FT_UInt region_idx_count;
- FT_UInt per_region_size;
-
-
- if ( FT_STREAM_SEEK( offset + dataOffsetArray[i] ) )
- goto Exit;
-
- if ( FT_READ_USHORT( item_count ) ||
- FT_READ_USHORT( word_delta_count ) ||
- FT_READ_USHORT( region_idx_count ) )
- goto Exit;
-
- long_words = !!( word_delta_count & 0x8000 );
- word_delta_count &= 0x7FFF;
-
- /* check some data consistency */
- if ( word_delta_count > region_idx_count )
- {
- FT_TRACE2(( "bad short count %d or region count %d\n",
- word_delta_count,
- region_idx_count ));
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- if ( region_idx_count > itemStore->regionCount )
- {
- FT_TRACE2(( "inconsistent regionCount %d in varData[%d]\n",
- region_idx_count,
- i ));
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- /* parse region indices */
- if ( FT_NEW_ARRAY( varData->regionIndices, region_idx_count ) )
- goto Exit;
- varData->regionIdxCount = region_idx_count;
- varData->wordDeltaCount = word_delta_count;
- varData->longWords = long_words;
-
- for ( j = 0; j < varData->regionIdxCount; j++ )
- {
- if ( FT_READ_USHORT( varData->regionIndices[j] ) )
- goto Exit;
-
- if ( varData->regionIndices[j] >= itemStore->regionCount )
- {
- FT_TRACE2(( "bad region index %d\n",
- varData->regionIndices[j] ));
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
- }
-
- per_region_size = word_delta_count + region_idx_count;
- if ( long_words )
- per_region_size *= 2;
-
- if ( FT_NEW_ARRAY( varData->deltaSet, per_region_size * item_count ) )
- goto Exit;
- if ( FT_Stream_Read( stream,
- varData->deltaSet,
- per_region_size * item_count ) )
- {
- FT_TRACE2(( "deltaSet read failed." ));
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- varData->itemCount = item_count;
- }
-
- Exit:
- FT_FREE( dataOffsetArray );
-
- return error;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- tt_var_load_delta_set_index_mapping( FT_Face face, /* TT_Face */
- FT_ULong offset,
- GX_DeltaSetIdxMap map,
- GX_ItemVarStore itemStore,
- FT_ULong table_len )
- {
- FT_Stream stream = FT_FACE_STREAM( face );
- FT_Memory memory = stream->memory;
-
- FT_Error error;
-
- FT_Byte format;
- FT_Byte entryFormat;
- FT_UInt entrySize;
- FT_UInt innerBitCount;
- FT_UInt innerIndexMask;
- FT_ULong i;
- FT_UInt j;
-
-
- if ( FT_STREAM_SEEK( offset ) ||
- FT_READ_BYTE( format ) ||
- FT_READ_BYTE( entryFormat ) )
- goto Exit;
-
- if ( format == 0 )
- {
- if ( FT_READ_USHORT( map->mapCount ) )
- goto Exit;
- }
- else if ( format == 1 ) /* new in OpenType 1.9 */
- {
- if ( FT_READ_ULONG( map->mapCount ) )
- goto Exit;
- }
- else
- {
- FT_TRACE2(( "bad map format %d\n", format ));
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- if ( entryFormat & 0xC0 )
- {
- FT_TRACE2(( "bad entry format %d\n", format ));
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- /* bytes per entry: 1, 2, 3, or 4 */
- entrySize = ( ( entryFormat & 0x30 ) >> 4 ) + 1;
- innerBitCount = ( entryFormat & 0x0F ) + 1;
- innerIndexMask = ( 1 << innerBitCount ) - 1;
-
- /* rough sanity check */
- if ( map->mapCount * entrySize > table_len )
- {
- FT_TRACE1(( "tt_var_load_delta_set_index_mapping:"
- " invalid number of delta-set index mappings\n" ));
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- if ( FT_NEW_ARRAY( map->innerIndex, map->mapCount ) )
- goto Exit;
-
- if ( FT_NEW_ARRAY( map->outerIndex, map->mapCount ) )
- goto Exit;
-
- for ( i = 0; i < map->mapCount; i++ )
- {
- FT_UInt mapData = 0;
- FT_UInt outerIndex, innerIndex;
-
-
- /* read map data one unsigned byte at a time, big endian */
- for ( j = 0; j < entrySize; j++ )
- {
- FT_Byte data;
-
-
- if ( FT_READ_BYTE( data ) )
- goto Exit;
-
- mapData = ( mapData << 8 ) | data;
- }
-
- /* new in OpenType 1.8.4 */
- if ( mapData == 0xFFFFFFFFUL )
- {
- /* no variation data for this item */
- map->outerIndex[i] = 0xFFFFU;
- map->innerIndex[i] = 0xFFFFU;
-
- continue;
- }
-
- outerIndex = mapData >> innerBitCount;
-
- if ( outerIndex >= itemStore->dataCount )
- {
- FT_TRACE2(( "outerIndex[%ld] == %d out of range\n",
- i,
- outerIndex ));
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- map->outerIndex[i] = outerIndex;
-
- innerIndex = mapData & innerIndexMask;
-
- if ( innerIndex >= itemStore->varData[outerIndex].itemCount )
- {
- FT_TRACE2(( "innerIndex[%ld] == %d out of range\n",
- i,
- innerIndex ));
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- map->innerIndex[i] = innerIndex;
- }
-
- Exit:
- return error;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * ft_var_load_hvvar
- *
- * @Description:
- * If `vertical' is zero, parse the `HVAR' table and set
- * `blend->hvar_loaded' to TRUE. On success, `blend->hvar_checked'
- * is set to TRUE.
- *
- * If `vertical' is not zero, parse the `VVAR' table and set
- * `blend->vvar_loaded' to TRUE. On success, `blend->vvar_checked'
- * is set to TRUE.
- *
- * Some memory may remain allocated on error; it is always freed in
- * `tt_done_blend', however.
- *
- * @InOut:
- * face ::
- * The font face.
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
- static FT_Error
- ft_var_load_hvvar( TT_Face face,
- FT_Bool vertical )
- {
- FT_Stream stream = FT_FACE_STREAM( face );
- FT_Memory memory = stream->memory;
-
- GX_Blend blend = face->blend;
-
- GX_HVVarTable table;
-
- FT_Error error;
- FT_UShort majorVersion;
- FT_ULong table_len;
- FT_ULong table_offset;
- FT_ULong store_offset;
- FT_ULong widthMap_offset;
-
-
- if ( vertical )
- {
- blend->vvar_loaded = TRUE;
-
- FT_TRACE2(( "VVAR " ));
-
- error = face->goto_table( face, TTAG_VVAR, stream, &table_len );
- }
- else
- {
- blend->hvar_loaded = TRUE;
-
- FT_TRACE2(( "HVAR " ));
-
- error = face->goto_table( face, TTAG_HVAR, stream, &table_len );
- }
-
- if ( error )
- {
- FT_TRACE2(( "is missing\n" ));
- goto Exit;
- }
-
- table_offset = FT_STREAM_POS();
-
- /* skip minor version */
- if ( FT_READ_USHORT( majorVersion ) ||
- FT_STREAM_SKIP( 2 ) )
- goto Exit;
-
- if ( majorVersion != 1 )
- {
- FT_TRACE2(( "bad table version %d\n", majorVersion ));
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- if ( FT_READ_ULONG( store_offset ) ||
- FT_READ_ULONG( widthMap_offset ) )
- goto Exit;
-
- if ( vertical )
- {
- if ( FT_NEW( blend->vvar_table ) )
- goto Exit;
- table = blend->vvar_table;
- }
- else
- {
- if ( FT_NEW( blend->hvar_table ) )
- goto Exit;
- table = blend->hvar_table;
- }
-
- error = tt_var_load_item_variation_store(
- FT_FACE( face ),
- table_offset + store_offset,
- &table->itemStore );
- if ( error )
- goto Exit;
-
- if ( widthMap_offset )
- {
- error = tt_var_load_delta_set_index_mapping(
- FT_FACE( face ),
- table_offset + widthMap_offset,
- &table->widthMap,
- &table->itemStore,
- table_len );
- if ( error )
- goto Exit;
- }
-
- FT_TRACE2(( "loaded\n" ));
- error = FT_Err_Ok;
-
- Exit:
- if ( !error )
- {
- if ( vertical )
- {
- blend->vvar_checked = TRUE;
-
- /* FreeType doesn't provide functions to quickly retrieve */
- /* TSB, BSB, or VORG values; we thus don't have to implement */
- /* support for those three item variation stores. */
-
- face->variation_support |= TT_FACE_FLAG_VAR_VADVANCE;
- }
- else
- {
- blend->hvar_checked = TRUE;
-
- /* FreeType doesn't provide functions to quickly retrieve */
- /* LSB or RSB values; we thus don't have to implement */
- /* support for those two item variation stores. */
-
- face->variation_support |= TT_FACE_FLAG_VAR_HADVANCE;
- }
- }
-
- return error;
- }
-
-
- FT_LOCAL_DEF( FT_ItemVarDelta )
- tt_var_get_item_delta( FT_Face face, /* TT_Face */
- GX_ItemVarStore itemStore,
- FT_UInt outerIndex,
- FT_UInt innerIndex )
- {
- TT_Face ttface = (TT_Face)face;
- FT_Stream stream = FT_FACE_STREAM( face );
- FT_Memory memory = stream->memory;
- FT_Error error = FT_Err_Ok;
-
- GX_ItemVarData varData;
- FT_ItemVarDelta* deltaSet = NULL;
- FT_ItemVarDelta deltaSetStack[16];
-
- FT_Fixed* scalars = NULL;
- FT_Fixed scalarsStack[16];
-
- FT_UInt master, j;
- FT_ItemVarDelta returnValue = 0;
- FT_UInt per_region_size;
- FT_Byte* bytes;
-
-
- if ( !ttface->blend || !ttface->blend->normalizedcoords )
- return 0;
-
- /* OpenType 1.8.4+: No variation data for this item */
- /* as indices have special value 0xFFFF. */
- if ( outerIndex == 0xFFFF && innerIndex == 0xFFFF )
- return 0;
-
- /* See pseudo code from `Font Variations Overview' */
- /* in the OpenType specification. */
-
- if ( outerIndex >= itemStore->dataCount )
- return 0; /* Out of range. */
-
- varData = &itemStore->varData[outerIndex];
-
- if ( innerIndex >= varData->itemCount )
- return 0; /* Out of range. */
-
- if ( varData->regionIdxCount == 0 )
- return 0; /* Avoid "applying zero offset to null pointer". */
-
- if ( varData->regionIdxCount < 16 )
- {
- deltaSet = deltaSetStack;
- scalars = scalarsStack;
- }
- else
- {
- if ( FT_QNEW_ARRAY( deltaSet, varData->regionIdxCount ) )
- goto Exit;
- if ( FT_QNEW_ARRAY( scalars, varData->regionIdxCount ) )
- goto Exit;
- }
-
- /* Parse delta set. */
- /* */
- /* Deltas are (word_delta_count + region_idx_count) bytes each */
- /* if `longWords` isn't set, and twice as much otherwise. */
- per_region_size = varData->wordDeltaCount + varData->regionIdxCount;
- if ( varData->longWords )
- per_region_size *= 2;
-
- bytes = varData->deltaSet + per_region_size * innerIndex;
-
- if ( varData->longWords )
- {
- for ( master = 0; master < varData->wordDeltaCount; master++ )
- deltaSet[master] = FT_NEXT_LONG( bytes );
- for ( ; master < varData->regionIdxCount; master++ )
- deltaSet[master] = FT_NEXT_SHORT( bytes );
- }
- else
- {
- for ( master = 0; master < varData->wordDeltaCount; master++ )
- deltaSet[master] = FT_NEXT_SHORT( bytes );
- for ( ; master < varData->regionIdxCount; master++ )
- deltaSet[master] = FT_NEXT_CHAR( bytes );
- }
-
- /* outer loop steps through master designs to be blended */
- for ( master = 0; master < varData->regionIdxCount; master++ )
- {
- FT_Fixed scalar = 0x10000L;
- FT_UInt regionIndex = varData->regionIndices[master];
-
- GX_AxisCoords axis = itemStore->varRegionList[regionIndex].axisList;
-
-
- /* inner loop steps through axes in this region */
- for ( j = 0; j < itemStore->axisCount; j++, axis++ )
- {
- FT_Fixed ncv = ttface->blend->normalizedcoords[j];
-
-
- /* compute the scalar contribution of this axis */
- /* with peak of 0 used for invalid axes */
- if ( axis->peakCoord == ncv ||
- axis->peakCoord == 0 )
- continue;
-
- /* ignore this region if coords are out of range */
- else if ( ncv <= axis->startCoord ||
- ncv >= axis->endCoord )
- {
- scalar = 0;
- break;
- }
-
- /* cumulative product of all the axis scalars */
- else if ( ncv < axis->peakCoord )
- scalar = FT_MulDiv( scalar,
- ncv - axis->startCoord,
- axis->peakCoord - axis->startCoord );
- else /* ncv > axis->peakCoord */
- scalar = FT_MulDiv( scalar,
- axis->endCoord - ncv,
- axis->endCoord - axis->peakCoord );
-
- } /* per-axis loop */
-
- scalars[master] = scalar;
-
- } /* per-region loop */
-
-
- /* Compute the scaled delta for this region.
- *
- * From: https://docs.microsoft.com/en-us/typography/opentype/spec/otvarcommonformats#item-variation-store-header-and-item-variation-data-subtables:
- *
- * `Fixed` is a 32-bit (16.16) type and, in the general case, requires
- * 32-bit deltas. As described above, the `DeltaSet` record can
- * accommodate deltas that are, logically, either 16-bit or 32-bit.
- * When scaled deltas are applied to `Fixed` values, the `Fixed` value
- * is treated like a 32-bit integer.
- *
- * `FT_MulAddFix` internally uses 64-bit precision; it thus can handle
- * deltas ranging from small 8-bit to large 32-bit values that are
- * applied to 16.16 `FT_Fixed` / OpenType `Fixed` values.
- */
- returnValue = FT_MulAddFix( scalars, deltaSet, varData->regionIdxCount );
-
- Exit:
- if ( scalars != scalarsStack )
- FT_FREE( scalars );
- if ( deltaSet != deltaSetStack )
- FT_FREE( deltaSet );
-
- return returnValue;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * tt_hvadvance_adjust
- *
- * @Description:
- * Apply `HVAR' advance width or `VVAR' advance height adjustment of
- * a given glyph.
- *
- * @Input:
- * gindex ::
- * The glyph index.
- *
- * vertical ::
- * If set, handle `VVAR' table.
- *
- * @InOut:
- * face ::
- * The font face.
- *
- * adelta ::
- * Points to width or height value that gets modified.
- */
- static FT_Error
- tt_hvadvance_adjust( TT_Face face,
- FT_UInt gindex,
- FT_Int *avalue,
- FT_Bool vertical )
- {
- FT_Error error = FT_Err_Ok;
- FT_UInt innerIndex, outerIndex;
- FT_Int delta;
-
- GX_HVVarTable table;
-
-
- if ( !face->doblend || !face->blend )
- goto Exit;
-
- if ( vertical )
- {
- if ( !face->blend->vvar_loaded )
- {
- /* initialize vvar table */
- face->blend->vvar_error = ft_var_load_hvvar( face, 1 );
- }
-
- if ( !face->blend->vvar_checked )
- {
- error = face->blend->vvar_error;
- goto Exit;
- }
-
- table = face->blend->vvar_table;
- }
- else
- {
- if ( !face->blend->hvar_loaded )
- {
- /* initialize hvar table */
- face->blend->hvar_error = ft_var_load_hvvar( face, 0 );
- }
-
- if ( !face->blend->hvar_checked )
- {
- error = face->blend->hvar_error;
- goto Exit;
- }
-
- table = face->blend->hvar_table;
- }
-
- /* advance width or height adjustments are always present in an */
- /* `HVAR' or `VVAR' table; no need to test for this capability */
-
- if ( table->widthMap.innerIndex )
- {
- FT_UInt idx = gindex;
-
-
- if ( idx >= table->widthMap.mapCount )
- idx = table->widthMap.mapCount - 1;
-
- /* trust that HVAR parser has checked indices */
- outerIndex = table->widthMap.outerIndex[idx];
- innerIndex = table->widthMap.innerIndex[idx];
- }
- else
- {
- /* no widthMap data */
- outerIndex = 0;
- innerIndex = gindex;
- }
-
- delta = tt_var_get_item_delta( FT_FACE( face ),
- &table->itemStore,
- outerIndex,
- innerIndex );
-
- if ( delta )
- {
- FT_TRACE5(( "%s value %d adjusted by %d unit%s (%s)\n",
- vertical ? "vertical height" : "horizontal width",
- *avalue,
- delta,
- delta == 1 ? "" : "s",
- vertical ? "VVAR" : "HVAR" ));
-
- *avalue = ADD_INT( *avalue, delta );
- }
-
- Exit:
- return error;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- tt_hadvance_adjust( FT_Face face, /* TT_Face */
- FT_UInt gindex,
- FT_Int *avalue )
- {
- return tt_hvadvance_adjust( (TT_Face)face, gindex, avalue, 0 );
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- tt_vadvance_adjust( FT_Face face, /* TT_Face */
- FT_UInt gindex,
- FT_Int *avalue )
- {
- return tt_hvadvance_adjust( (TT_Face)face, gindex, avalue, 1 );
- }
-
-
-#define GX_VALUE_SIZE 8
-
- /* all values are FT_Short or FT_UShort entities; */
- /* we treat them consistently as FT_Short */
-#define GX_VALUE_CASE( tag, dflt ) \
- case MVAR_TAG_ ## tag : \
- p = (FT_Short*)&face->dflt; \
- break
-
-#define GX_GASP_CASE( idx ) \
- case MVAR_TAG_GASP_ ## idx : \
- if ( idx < face->gasp.numRanges - 1 ) \
- p = (FT_Short*)&face->gasp.gaspRanges[idx].maxPPEM; \
- else \
- p = NULL; \
- break
-
-
- static FT_Short*
- ft_var_get_value_pointer( TT_Face face,
- FT_ULong mvar_tag )
- {
- FT_Short* p;
-
-
- switch ( mvar_tag )
- {
- GX_GASP_CASE( 0 );
- GX_GASP_CASE( 1 );
- GX_GASP_CASE( 2 );
- GX_GASP_CASE( 3 );
- GX_GASP_CASE( 4 );
- GX_GASP_CASE( 5 );
- GX_GASP_CASE( 6 );
- GX_GASP_CASE( 7 );
- GX_GASP_CASE( 8 );
- GX_GASP_CASE( 9 );
-
- GX_VALUE_CASE( CPHT, os2.sCapHeight );
- GX_VALUE_CASE( HASC, os2.sTypoAscender );
- GX_VALUE_CASE( HCLA, os2.usWinAscent );
- GX_VALUE_CASE( HCLD, os2.usWinDescent );
- GX_VALUE_CASE( HCOF, horizontal.caret_Offset );
- GX_VALUE_CASE( HCRN, horizontal.caret_Slope_Run );
- GX_VALUE_CASE( HCRS, horizontal.caret_Slope_Rise );
- GX_VALUE_CASE( HDSC, os2.sTypoDescender );
- GX_VALUE_CASE( HLGP, os2.sTypoLineGap );
- GX_VALUE_CASE( SBXO, os2.ySubscriptXOffset);
- GX_VALUE_CASE( SBXS, os2.ySubscriptXSize );
- GX_VALUE_CASE( SBYO, os2.ySubscriptYOffset );
- GX_VALUE_CASE( SBYS, os2.ySubscriptYSize );
- GX_VALUE_CASE( SPXO, os2.ySuperscriptXOffset );
- GX_VALUE_CASE( SPXS, os2.ySuperscriptXSize );
- GX_VALUE_CASE( SPYO, os2.ySuperscriptYOffset );
- GX_VALUE_CASE( SPYS, os2.ySuperscriptYSize );
- GX_VALUE_CASE( STRO, os2.yStrikeoutPosition );
- GX_VALUE_CASE( STRS, os2.yStrikeoutSize );
- GX_VALUE_CASE( UNDO, postscript.underlinePosition );
- GX_VALUE_CASE( UNDS, postscript.underlineThickness );
- GX_VALUE_CASE( VASC, vertical.Ascender );
- GX_VALUE_CASE( VCOF, vertical.caret_Offset );
- GX_VALUE_CASE( VCRN, vertical.caret_Slope_Run );
- GX_VALUE_CASE( VCRS, vertical.caret_Slope_Rise );
- GX_VALUE_CASE( VDSC, vertical.Descender );
- GX_VALUE_CASE( VLGP, vertical.Line_Gap );
- GX_VALUE_CASE( XHGT, os2.sxHeight );
-
- default:
- /* ignore unknown tag */
- p = NULL;
- }
-
- return p;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * ft_var_load_mvar
- *
- * @Description:
- * Parse the `MVAR' table.
- *
- * Some memory may remain allocated on error; it is always freed in
- * `tt_done_blend', however.
- *
- * @InOut:
- * face ::
- * The font face.
- */
- static void
- ft_var_load_mvar( TT_Face face )
- {
- FT_Stream stream = FT_FACE_STREAM( face );
- FT_Memory memory = stream->memory;
-
- GX_Blend blend = face->blend;
- GX_ItemVarStore itemStore;
- GX_Value value, limit;
-
- FT_Error error;
- FT_UShort majorVersion;
- FT_ULong table_len;
- FT_ULong table_offset;
- FT_UShort store_offset;
- FT_ULong records_offset;
-
-
- FT_TRACE2(( "MVAR " ));
-
- error = face->goto_table( face, TTAG_MVAR, stream, &table_len );
- if ( error )
- {
- FT_TRACE2(( "is missing\n" ));
- return;
- }
-
- table_offset = FT_STREAM_POS();
-
- /* skip minor version */
- if ( FT_READ_USHORT( majorVersion ) ||
- FT_STREAM_SKIP( 2 ) )
- return;
-
- if ( majorVersion != 1 )
- {
- FT_TRACE2(( "bad table version %d\n", majorVersion ));
- return;
- }
-
- if ( FT_NEW( blend->mvar_table ) )
- return;
-
- /* skip reserved entry and value record size */
- if ( FT_STREAM_SKIP( 4 ) ||
- FT_READ_USHORT( blend->mvar_table->valueCount ) ||
- FT_READ_USHORT( store_offset ) )
- return;
-
- records_offset = FT_STREAM_POS();
-
- error = tt_var_load_item_variation_store(
- FT_FACE( face ),
- table_offset + store_offset,
- &blend->mvar_table->itemStore );
- if ( error )
- return;
-
- if ( FT_NEW_ARRAY( blend->mvar_table->values,
- blend->mvar_table->valueCount ) )
- return;
-
- if ( FT_STREAM_SEEK( records_offset ) ||
- FT_FRAME_ENTER( blend->mvar_table->valueCount * GX_VALUE_SIZE ) )
- return;
-
- value = blend->mvar_table->values;
- limit = FT_OFFSET( value, blend->mvar_table->valueCount );
- itemStore = &blend->mvar_table->itemStore;
-
- for ( ; value < limit; value++ )
- {
- value->tag = FT_GET_ULONG();
- value->outerIndex = FT_GET_USHORT();
- value->innerIndex = FT_GET_USHORT();
-
- /* new in OpenType 1.8.4 */
- if ( value->outerIndex == 0xFFFFU && value->innerIndex == 0xFFFFU )
- {
- /* no variation data for this item */
- continue;
- }
-
- if ( value->outerIndex >= itemStore->dataCount ||
- value->innerIndex >= itemStore->varData[value->outerIndex]
- .itemCount )
- {
- error = FT_THROW( Invalid_Table );
- break;
- }
- }
-
- FT_FRAME_EXIT();
-
- if ( error )
- return;
-
- FT_TRACE2(( "loaded\n" ));
-
- value = blend->mvar_table->values;
- limit = FT_OFFSET( value, blend->mvar_table->valueCount );
-
- /* save original values of the data MVAR is going to modify */
- for ( ; value < limit; value++ )
- {
- FT_Short* p = ft_var_get_value_pointer( face, value->tag );
-
-
- if ( p )
- value->unmodified = *p;
-#ifdef FT_DEBUG_LEVEL_TRACE
- else
- FT_TRACE1(( "ft_var_load_mvar: Ignoring unknown tag `%c%c%c%c'\n",
- (FT_Char)( value->tag >> 24 ),
- (FT_Char)( value->tag >> 16 ),
- (FT_Char)( value->tag >> 8 ),
- (FT_Char)( value->tag ) ));
-#endif
- }
-
- face->variation_support |= TT_FACE_FLAG_VAR_MVAR;
- }
-
-
- static FT_Error
- ft_size_reset_iterator( FT_ListNode node,
- void* user )
- {
- FT_Size size = (FT_Size)node->data;
- FT_Service_MetricsVariations var = (FT_Service_MetricsVariations)user;
-
-
- var->size_reset( size );
-
- return FT_Err_Ok;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * tt_apply_mvar
- *
- * @Description:
- * Apply `MVAR' table adjustments.
- *
- * @InOut:
- * face ::
- * The font face.
- */
- FT_LOCAL_DEF( void )
- tt_apply_mvar( FT_Face face ) /* TT_Face */
- {
- TT_Face ttface = (TT_Face)face;
-
- GX_Blend blend = ttface->blend;
- GX_Value value, limit;
-
- FT_Short mvar_hasc_delta = 0;
- FT_Short mvar_hdsc_delta = 0;
- FT_Short mvar_hlgp_delta = 0;
-
-
- if ( !( ttface->variation_support & TT_FACE_FLAG_VAR_MVAR ) )
- return;
-
- value = blend->mvar_table->values;
- limit = FT_OFFSET( value, blend->mvar_table->valueCount );
-
- for ( ; value < limit; value++ )
- {
- FT_Short* p = ft_var_get_value_pointer( ttface, value->tag );
- FT_Int delta;
-
-
- delta = tt_var_get_item_delta( face,
- &blend->mvar_table->itemStore,
- value->outerIndex,
- value->innerIndex );
-
- if ( p && delta )
- {
- FT_TRACE5(( "value %c%c%c%c (%d unit%s) adjusted by %d unit%s (MVAR)\n",
- (FT_Char)( value->tag >> 24 ),
- (FT_Char)( value->tag >> 16 ),
- (FT_Char)( value->tag >> 8 ),
- (FT_Char)( value->tag ),
- value->unmodified,
- value->unmodified == 1 ? "" : "s",
- delta,
- delta == 1 ? "" : "s" ));
-
- /* since we handle both signed and unsigned values as FT_Short, */
- /* ensure proper overflow arithmetic */
- *p = (FT_Short)( value->unmodified + (FT_Short)delta );
-
- /* Treat hasc, hdsc and hlgp specially, see below. */
- if ( value->tag == MVAR_TAG_HASC )
- mvar_hasc_delta = (FT_Short)delta;
- else if ( value->tag == MVAR_TAG_HDSC )
- mvar_hdsc_delta = (FT_Short)delta;
- else if ( value->tag == MVAR_TAG_HLGP )
- mvar_hlgp_delta = (FT_Short)delta;
- }
- }
-
- /* adjust all derived values */
- {
- FT_Service_MetricsVariations var =
- (FT_Service_MetricsVariations)ttface->face_var;
-
- /*
- * Apply the deltas of hasc, hdsc and hlgp to the FT_Face's ascender,
- * descender and height attributes, no matter how they were originally
- * computed.
- *
- * (Code that ignores those and accesses the font's metrics values
- * directly is already served by the delta application code above.)
- *
- * The MVAR table supports variations for both typo and win metrics.
- * According to Behdad Esfahbod, the thinking of the working group was
- * that no one uses win metrics anymore for setting line metrics (the
- * specification even calls these metrics "horizontal clipping
- * ascent/descent", probably for their role on the Windows platform in
- * computing clipping boxes), and new fonts should use typo metrics, so
- * typo deltas should be applied to whatever sfnt_load_face decided the
- * line metrics should be.
- *
- * Before, the following led to different line metrics between default
- * outline and instances, visible when e.g. the default outlines were
- * used as the regular face and instances for everything else:
- *
- * 1. sfnt_load_face applied the hhea metrics by default.
- * 2. This code later applied the typo metrics by default, regardless of
- * whether they were actually changed or the font had the OS/2 table's
- * fsSelection's bit 7 (USE_TYPO_METRICS) set.
- */
- FT_Short current_line_gap = face->height - face->ascender +
- face->descender;
-
-
- face->ascender = face->ascender + mvar_hasc_delta;
- face->descender = face->descender + mvar_hdsc_delta;
- face->height = face->ascender - face->descender +
- current_line_gap + mvar_hlgp_delta;
-
- face->underline_position = ttface->postscript.underlinePosition -
- ttface->postscript.underlineThickness / 2;
- face->underline_thickness = ttface->postscript.underlineThickness;
-
- /* iterate over all FT_Size objects and call `var->size_reset' */
- /* to propagate the metrics changes */
- if ( var && var->size_reset )
- FT_List_Iterate( &face->sizes_list,
- ft_size_reset_iterator,
- (void*)var );
- }
- }
-
-
- typedef struct GX_GVar_Head_
- {
- FT_Long version;
- FT_UShort axisCount;
- FT_UShort globalCoordCount;
- FT_ULong offsetToCoord;
- FT_UShort glyphCount;
- FT_UShort flags;
- FT_ULong offsetToData;
-
- } GX_GVar_Head;
-
-
- /**************************************************************************
- *
- * @Function:
- * ft_var_load_gvar
- *
- * @Description:
- * Parse the `gvar' table if present. If `fvar' is there, `gvar' had
- * better be there too.
- *
- * @InOut:
- * face ::
- * The font face.
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
- static FT_Error
- ft_var_load_gvar( TT_Face face )
- {
- FT_Stream stream = FT_FACE_STREAM( face );
- FT_Memory memory = stream->memory;
- GX_Blend blend = face->blend;
- FT_Error error;
- FT_UInt i, j;
- FT_ULong table_len;
- FT_ULong gvar_start;
- FT_ULong offsetToData;
- FT_ULong offsets_len;
- GX_GVar_Head gvar_head;
-
- static const FT_Frame_Field gvar_fields[] =
- {
-
-#undef FT_STRUCTURE
-#define FT_STRUCTURE GX_GVar_Head
-
- FT_FRAME_START( 20 ),
- FT_FRAME_LONG ( version ),
- FT_FRAME_USHORT( axisCount ),
- FT_FRAME_USHORT( globalCoordCount ),
- FT_FRAME_ULONG ( offsetToCoord ),
- FT_FRAME_USHORT( glyphCount ),
- FT_FRAME_USHORT( flags ),
- FT_FRAME_ULONG ( offsetToData ),
- FT_FRAME_END
- };
-
-
- FT_TRACE2(( "GVAR " ));
-
- if ( FT_SET_ERROR( face->goto_table( face,
- TTAG_gvar,
- stream,
- &table_len ) ) )
- {
- FT_TRACE2(( "is missing\n" ));
- goto Exit;
- }
-
- gvar_start = FT_STREAM_POS( );
- if ( FT_STREAM_READ_FIELDS( gvar_fields, &gvar_head ) )
- goto Exit;
-
- if ( gvar_head.version != 0x00010000L )
- {
- FT_TRACE1(( "bad table version\n" ));
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- if ( gvar_head.axisCount != (FT_UShort)blend->mmvar->num_axis )
- {
- FT_TRACE1(( "ft_var_load_gvar:"
- " number of axes in `gvar' and `cvar'\n" ));
- FT_TRACE1(( " table are different\n" ));
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- /* rough sanity check, ignoring offsets */
- if ( (FT_ULong)gvar_head.globalCoordCount * gvar_head.axisCount >
- table_len / 2 )
- {
- FT_TRACE1(( "ft_var_load_gvar:"
- " invalid number of global coordinates\n" ));
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- /* offsets can be either 2 or 4 bytes */
- /* (one more offset than glyphs, to mark size of last) */
- offsets_len = ( gvar_head.glyphCount + 1 ) *
- ( ( gvar_head.flags & 1 ) ? 4L : 2L );
-
- /* rough sanity check */
- if (offsets_len > table_len )
- {
- FT_TRACE1(( "ft_var_load_gvar: invalid number of glyphs\n" ));
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- FT_TRACE2(( "loaded\n" ));
-
- blend->gvar_size = table_len;
- offsetToData = gvar_start + gvar_head.offsetToData;
-
- FT_TRACE5(( "gvar: there %s %d shared coordinate%s:\n",
- gvar_head.globalCoordCount == 1 ? "is" : "are",
- gvar_head.globalCoordCount,
- gvar_head.globalCoordCount == 1 ? "" : "s" ));
-
- if ( FT_FRAME_ENTER( offsets_len ) )
- goto Exit;
-
- /* offsets (one more offset than glyphs, to mark size of last) */
- if ( FT_QNEW_ARRAY( blend->glyphoffsets, gvar_head.glyphCount + 1 ) )
- goto Fail2;
-
- if ( gvar_head.flags & 1 )
- {
- FT_ULong limit = gvar_start + table_len;
- FT_ULong max_offset = 0;
-
-
- for ( i = 0; i <= gvar_head.glyphCount; i++ )
- {
- blend->glyphoffsets[i] = offsetToData + FT_GET_ULONG();
-
- if ( max_offset <= blend->glyphoffsets[i] )
- max_offset = blend->glyphoffsets[i];
- else
- {
- FT_TRACE2(( "ft_var_load_gvar:"
- " glyph variation data offset %d not monotonic\n",
- i ));
- blend->glyphoffsets[i] = max_offset;
- }
-
- /* use `<', not `<=' */
- if ( limit < blend->glyphoffsets[i] )
- {
- FT_TRACE2(( "ft_var_load_gvar:"
- " glyph variation data offset %d out of range\n",
- i ));
- blend->glyphoffsets[i] = limit;
- }
- }
- }
- else
- {
- FT_ULong limit = gvar_start + table_len;
- FT_ULong max_offset = 0;
-
-
- for ( i = 0; i <= gvar_head.glyphCount; i++ )
- {
- blend->glyphoffsets[i] = offsetToData + FT_GET_USHORT() * 2;
-
- if ( max_offset <= blend->glyphoffsets[i] )
- max_offset = blend->glyphoffsets[i];
- else
- {
- FT_TRACE2(( "ft_var_load_gvar:"
- " glyph variation data offset %d not monotonic\n",
- i ));
- blend->glyphoffsets[i] = max_offset;
- }
-
- /* use `<', not `<=' */
- if ( limit < blend->glyphoffsets[i] )
- {
- FT_TRACE2(( "ft_var_load_gvar:"
- " glyph variation data offset %d out of range\n",
- i ));
- blend->glyphoffsets[i] = limit;
- }
- }
- }
-
- blend->gv_glyphcnt = gvar_head.glyphCount;
-
- FT_FRAME_EXIT();
-
- if ( gvar_head.globalCoordCount != 0 )
- {
- if ( FT_STREAM_SEEK( gvar_start + gvar_head.offsetToCoord ) ||
- FT_FRAME_ENTER( gvar_head.globalCoordCount *
- gvar_head.axisCount * 2L ) )
- {
- FT_TRACE2(( "ft_var_load_gvar:"
- " glyph variation shared tuples missing\n" ));
- goto Fail;
- }
-
- if ( FT_QNEW_ARRAY( blend->tuplecoords,
- gvar_head.axisCount * gvar_head.globalCoordCount ) )
- goto Fail2;
-
- for ( i = 0; i < gvar_head.globalCoordCount; i++ )
- {
- FT_TRACE5(( " [ " ));
- for ( j = 0; j < (FT_UInt)gvar_head.axisCount; j++ )
- {
- blend->tuplecoords[i * gvar_head.axisCount + j] =
- FT_fdot14ToFixed( FT_GET_SHORT() );
- FT_TRACE5(( "%.5f ",
- (double)blend->tuplecoords[i * gvar_head.axisCount + j] / 65536 ));
- }
- FT_TRACE5(( "]\n" ));
- }
-
- blend->tuplecount = gvar_head.globalCoordCount;
-
- FT_TRACE5(( "\n" ));
-
- FT_FRAME_EXIT();
- }
-
- Exit:
- return error;
-
- Fail2:
- FT_FRAME_EXIT();
-
- Fail:
- FT_FREE( blend->glyphoffsets );
- blend->gv_glyphcnt = 0;
- goto Exit;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * ft_var_apply_tuple
- *
- * @Description:
- * Figure out whether a given tuple (design) applies to the current
- * blend, and if so, what is the scaling factor.
- *
- * @Input:
- * blend ::
- * The current blend of the font.
- *
- * tupleIndex ::
- * A flag saying whether this is an intermediate
- * tuple or not.
- *
- * tuple_coords ::
- * The coordinates of the tuple in normalized axis
- * units.
- *
- * im_start_coords ::
- * The initial coordinates where this tuple starts
- * to apply (for intermediate coordinates).
- *
- * im_end_coords ::
- * The final coordinates after which this tuple no
- * longer applies (for intermediate coordinates).
- *
- * @Return:
- * An FT_Fixed value containing the scaling factor.
- */
- static FT_Fixed
- ft_var_apply_tuple( GX_Blend blend,
- FT_UShort tupleIndex,
- FT_Fixed* tuple_coords,
- FT_Fixed* im_start_coords,
- FT_Fixed* im_end_coords )
- {
- FT_UInt i;
- FT_Fixed apply = 0x10000L;
-
-
- for ( i = 0; i < blend->num_axis; i++ )
- {
- FT_Fixed ncv = blend->normalizedcoords[i];
-
-
- FT_TRACE6(( " axis %d coordinate %.5f:\n", i, (double)ncv / 65536 ));
-
- /* It's not clear why (for intermediate tuples) we don't need */
- /* to check against start/end -- the documentation says we don't. */
- /* Similarly, it's unclear why we don't need to scale along the */
- /* axis. */
-
- if ( tuple_coords[i] == ncv )
- {
- FT_TRACE6(( " tuple coordinate %.5f fits perfectly\n",
- (double)tuple_coords[i] / 65536 ));
- /* `apply' does not change */
- continue;
- }
-
- if ( tuple_coords[i] == 0 )
- {
- FT_TRACE6(( " tuple coordinate is zero, ignore\n" ));
- continue;
- }
-
- if ( !( tupleIndex & GX_TI_INTERMEDIATE_TUPLE ) )
- {
- /* not an intermediate tuple */
-
- if ( ( tuple_coords[i] > ncv && ncv > 0 ) ||
- ( tuple_coords[i] < ncv && ncv < 0 ) )
- {
- FT_TRACE6(( " tuple coordinate %.5f fits\n",
- (double)tuple_coords[i] / 65536 ));
- apply = FT_MulDiv( apply, ncv, tuple_coords[i] );
- }
- else
- {
- FT_TRACE6(( " tuple coordinate %.5f is exceeded, stop\n",
- (double)tuple_coords[i] / 65536 ));
- apply = 0;
- break;
- }
- }
- else
- {
- /* intermediate tuple */
-
- if ( ncv <= im_start_coords[i] ||
- ncv >= im_end_coords[i] )
- {
- FT_TRACE6(( " intermediate tuple range ]%.5f;%.5f[ is exceeded,"
- " stop\n",
- (double)im_start_coords[i] / 65536,
- (double)im_end_coords[i] / 65536 ));
- apply = 0;
- break;
- }
-
- FT_TRACE6(( " intermediate tuple range ]%.5f;%.5f[ fits\n",
- (double)im_start_coords[i] / 65536,
- (double)im_end_coords[i] / 65536 ));
- if ( ncv < tuple_coords[i] )
- apply = FT_MulDiv( apply,
- ncv - im_start_coords[i],
- tuple_coords[i] - im_start_coords[i] );
- else /* ncv > tuple_coords[i] */
- apply = FT_MulDiv( apply,
- im_end_coords[i] - ncv,
- im_end_coords[i] - tuple_coords[i] );
- }
- }
-
- FT_TRACE6(( " apply factor is %.5f\n", (double)apply / 65536 ));
-
- return apply;
- }
-
-
- /* convert from design coordinates to normalized coordinates */
-
- static void
- ft_var_to_normalized( TT_Face face,
- FT_UInt num_coords,
- FT_Fixed* coords,
- FT_Fixed* normalized )
- {
- FT_Error error = FT_Err_Ok;
- FT_Memory memory = face->root.memory;
- FT_UInt i, j;
-
- GX_Blend blend;
- FT_MM_Var* mmvar;
- FT_Var_Axis* a;
- GX_AVarSegment av;
-
- FT_Fixed* new_normalized = NULL;
- FT_Fixed* old_normalized;
-
-
- blend = face->blend;
- mmvar = blend->mmvar;
-
- if ( num_coords > mmvar->num_axis )
- {
- FT_TRACE2(( "ft_var_to_normalized:"
- " only using first %d of %d coordinates\n",
- mmvar->num_axis, num_coords ));
- num_coords = mmvar->num_axis;
- }
-
- /* Axis normalization is a two-stage process. First we normalize */
- /* based on the [min,def,max] values for the axis to be [-1,0,1]. */
- /* Then, if there's an `avar' table, we renormalize this range. */
-
- a = mmvar->axis;
- for ( i = 0; i < num_coords; i++, a++ )
- {
- FT_Fixed coord = coords[i];
-
-
- FT_TRACE5(( " %d: %.5f\n", i, (double)coord / 65536 ));
- if ( coord > a->maximum || coord < a->minimum )
- {
- FT_TRACE1(( "ft_var_to_normalized: design coordinate %.5f\n",
- (double)coord / 65536 ));
- FT_TRACE1(( " is out of range [%.5f;%.5f];"
- " clamping\n",
- (double)a->minimum / 65536,
- (double)a->maximum / 65536 ));
- }
-
- if ( coord > a->def )
- normalized[i] = coord >= a->maximum ? 0x10000L :
- FT_DivFix( SUB_LONG( coord, a->def ),
- SUB_LONG( a->maximum, a->def ) );
- else if ( coord < a->def )
- normalized[i] = coord <= a->minimum ? -0x10000L :
- FT_DivFix( SUB_LONG( coord, a->def ),
- SUB_LONG( a->def, a->minimum ) );
- else
- normalized[i] = 0;
- }
-
- FT_TRACE5(( "\n" ));
-
- for ( ; i < mmvar->num_axis; i++ )
- normalized[i] = 0;
-
- if ( blend->avar_table )
- {
- GX_AVarTable table = blend->avar_table;
-
-
- FT_TRACE5(( "normalized design coordinates"
- " before applying `avar' data:\n" ));
-
- if ( table->avar_segment )
- {
- av = table->avar_segment;
-
- for ( i = 0; i < mmvar->num_axis; i++, av++ )
- {
- for ( j = 1; j < (FT_UInt)av->pairCount; j++ )
- {
- if ( normalized[i] < av->correspondence[j].fromCoord )
- {
- FT_TRACE5(( " %.5f\n", (double)normalized[i] / 65536 ));
-
- normalized[i] =
- FT_MulDiv( normalized[i] - av->correspondence[j - 1].fromCoord,
- av->correspondence[j].toCoord -
- av->correspondence[j - 1].toCoord,
- av->correspondence[j].fromCoord -
- av->correspondence[j - 1].fromCoord ) +
- av->correspondence[j - 1].toCoord;
- break;
- }
- }
- }
- }
-
- if ( table->itemStore.varData )
- {
- if ( FT_QNEW_ARRAY( new_normalized, mmvar->num_axis ) )
- return;
-
- /* Install our half-normalized coordinates for the next */
- /* Item Variation Store to work with. */
- old_normalized = face->blend->normalizedcoords;
- face->blend->normalizedcoords = normalized;
-
- for ( i = 0; i < mmvar->num_axis; i++ )
- {
- FT_Fixed v = normalized[i];
- FT_UInt innerIndex = i;
- FT_UInt outerIndex = 0;
- FT_Int delta;
-
-
- if ( table->axisMap.innerIndex )
- {
- FT_UInt idx = i;
-
-
- if ( idx >= table->axisMap.mapCount )
- idx = table->axisMap.mapCount - 1;
-
- outerIndex = table->axisMap.outerIndex[idx];
- innerIndex = table->axisMap.innerIndex[idx];
- }
-
- delta = tt_var_get_item_delta( FT_FACE( face ),
- &table->itemStore,
- outerIndex,
- innerIndex );
-
- /* Convert delta in F2DOT14 to 16.16 before adding. */
- v += MUL_INT( delta, 4 );
-
- /* Clamp value to range [-1, 1]. */
- v = v >= 0x10000L ? 0x10000 : v;
- v = v <= -0x10000L ? -0x10000 : v;
-
- new_normalized[i] = v;
- }
-
- for ( i = 0; i < mmvar->num_axis; i++ )
- {
- normalized[i] = new_normalized[i];
- }
-
- face->blend->normalizedcoords = old_normalized;
-
- FT_FREE( new_normalized );
- }
- }
- }
-
-
- /* convert from normalized coordinates to design coordinates */
-
- static void
- ft_var_to_design( TT_Face face,
- FT_UInt num_coords,
- FT_Fixed* coords,
- FT_Fixed* design )
- {
- GX_Blend blend;
- FT_MM_Var* mmvar;
- FT_Var_Axis* a;
-
- FT_UInt i, j, nc;
-
-
- blend = face->blend;
-
- nc = num_coords;
- if ( num_coords > blend->num_axis )
- {
- FT_TRACE2(( "ft_var_to_design:"
- " only using first %d of %d coordinates\n",
- blend->num_axis, num_coords ));
- nc = blend->num_axis;
- }
-
- for ( i = 0; i < nc; i++ )
- design[i] = coords[i];
-
- for ( ; i < num_coords; i++ )
- design[i] = 0;
-
- if ( blend->avar_table && blend->avar_table->avar_segment )
- {
- GX_AVarSegment av = blend->avar_table->avar_segment;
-
-
- FT_TRACE5(( "design coordinates"
- " after removing `avar' distortion:\n" ));
-
- for ( i = 0; i < nc; i++, av++ )
- {
- for ( j = 1; j < (FT_UInt)av->pairCount; j++ )
- {
- if ( design[i] < av->correspondence[j].toCoord )
- {
- design[i] =
- FT_MulDiv( design[i] - av->correspondence[j - 1].toCoord,
- av->correspondence[j].fromCoord -
- av->correspondence[j - 1].fromCoord,
- av->correspondence[j].toCoord -
- av->correspondence[j - 1].toCoord ) +
- av->correspondence[j - 1].fromCoord;
-
- FT_TRACE5(( " %.5f\n", (double)design[i] / 65536 ));
- break;
- }
- }
- }
- }
-
- mmvar = blend->mmvar;
- a = mmvar->axis;
-
- for ( i = 0; i < nc; i++, a++ )
- {
- if ( design[i] < 0 )
- design[i] = a->def + FT_MulFix( design[i],
- a->def - a->minimum );
- else if ( design[i] > 0 )
- design[i] = a->def + FT_MulFix( design[i],
- a->maximum - a->def );
- else
- design[i] = a->def;
- }
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** MULTIPLE MASTERS SERVICE FUNCTIONS *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-
- typedef struct GX_FVar_Head_
- {
- FT_Long version;
- FT_UShort offsetToData;
- FT_UShort axisCount;
- FT_UShort axisSize;
- FT_UShort instanceCount;
- FT_UShort instanceSize;
-
- } GX_FVar_Head;
-
-
- typedef struct fvar_axis_
- {
- FT_ULong axisTag;
- FT_Fixed minValue;
- FT_Fixed defaultValue;
- FT_Fixed maxValue;
- FT_UShort flags;
- FT_UShort nameID;
-
- } GX_FVar_Axis;
-
-
- /**************************************************************************
- *
- * @Function:
- * TT_Get_MM_Var
- *
- * @Description:
- * Check that the font's `fvar' table is valid, parse it, and return
- * those data. It also loads (and parses) the `MVAR' table, if
- * possible.
- *
- * @InOut:
- * face ::
- * The font face.
- * TT_Get_MM_Var initializes the blend structure.
- *
- * @Output:
- * master ::
- * The `fvar' data (must be freed by caller). Can be NULL,
- * which makes this function simply load MM support.
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
- FT_LOCAL_DEF( FT_Error )
- TT_Get_MM_Var( FT_Face face, /* TT_Face */
- FT_MM_Var* *master )
- {
- TT_Face ttface = (TT_Face)face;
- FT_Stream stream = FT_FACE_STREAM( face );
- FT_Memory memory = FT_FACE_MEMORY( face );
- FT_ULong table_len;
- FT_Error error = FT_Err_Ok;
- FT_ULong fvar_start = 0;
- FT_UInt i, j;
- FT_MM_Var* mmvar = NULL;
- FT_Fixed* next_coords;
- FT_Fixed* nsc;
- FT_String* next_name;
- FT_Var_Axis* a;
- FT_Fixed* c;
- FT_Var_Named_Style* ns;
- GX_FVar_Head fvar_head = { 0, 0, 0, 0, 0, 0 };
- FT_Bool usePsName = 0;
- FT_UInt num_instances;
- FT_UInt num_axes;
- FT_UShort* axis_flags;
-
- FT_Offset mmvar_size;
- FT_Offset axis_flags_size;
- FT_Offset axis_size;
- FT_Offset namedstyle_size;
- FT_Offset next_coords_size;
- FT_Offset next_name_size;
-
- FT_Bool need_init;
-
- static const FT_Frame_Field fvar_fields[] =
- {
-
-#undef FT_STRUCTURE
-#define FT_STRUCTURE GX_FVar_Head
-
- FT_FRAME_START( 16 ),
- FT_FRAME_LONG ( version ),
- FT_FRAME_USHORT ( offsetToData ),
- FT_FRAME_SKIP_SHORT,
- FT_FRAME_USHORT ( axisCount ),
- FT_FRAME_USHORT ( axisSize ),
- FT_FRAME_USHORT ( instanceCount ),
- FT_FRAME_USHORT ( instanceSize ),
- FT_FRAME_END
- };
-
- static const FT_Frame_Field fvaraxis_fields[] =
- {
-
-#undef FT_STRUCTURE
-#define FT_STRUCTURE GX_FVar_Axis
-
- FT_FRAME_START( 20 ),
- FT_FRAME_ULONG ( axisTag ),
- FT_FRAME_LONG ( minValue ),
- FT_FRAME_LONG ( defaultValue ),
- FT_FRAME_LONG ( maxValue ),
- FT_FRAME_USHORT( flags ),
- FT_FRAME_USHORT( nameID ),
- FT_FRAME_END
- };
-
- /* `num_instances` holds the number of all named instances including */
- /* the default instance, which might be missing in the table of named */
- /* instances (in 'fvar'). This value is validated in `sfobjs.c` and */
- /* may be reset to 0 if consistency checks fail. */
- num_instances = (FT_UInt)face->style_flags >> 16;
-
- /* read the font data and set up the internal representation */
- /* if not already done */
-
- need_init = !ttface->blend;
-
- if ( need_init )
- {
- FT_TRACE2(( "FVAR " ));
-
- if ( FT_SET_ERROR( ttface->goto_table( ttface, TTAG_fvar,
- stream, &table_len ) ) )
- {
- FT_TRACE1(( "is missing\n" ));
- goto Exit;
- }
-
- fvar_start = FT_STREAM_POS( );
-
- /* the validity of the `fvar' header data was already checked */
- /* in function `sfnt_init_face' */
- if ( FT_STREAM_READ_FIELDS( fvar_fields, &fvar_head ) )
- goto Exit;
-
- /* If `num_instances` is larger, synthetization of the default */
- /* instance is required. If `num_instances` is smaller, */
- /* however, the value has been reset to 0 in `sfnt_init_face` */
- /* (in `sfobjs.c`); in this case we have underallocated `mmvar` */
- /* structs. */
- if ( num_instances < fvar_head.instanceCount )
- {
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- usePsName = FT_BOOL( fvar_head.instanceSize ==
- 6 + 4 * fvar_head.axisCount );
-
- FT_TRACE2(( "loaded\n" ));
-
- FT_TRACE5(( "%d variation ax%s\n",
- fvar_head.axisCount,
- fvar_head.axisCount == 1 ? "is" : "es" ));
-
- if ( FT_NEW( ttface->blend ) )
- goto Exit;
-
- num_axes = fvar_head.axisCount;
- ttface->blend->num_axis = num_axes;
- }
- else
- num_axes = ttface->blend->num_axis;
-
- /* prepare storage area for MM data; this cannot overflow */
- /* 32-bit arithmetic because of the size limits used in the */
- /* `fvar' table validity check in `sfnt_init_face' */
-
- /* the various `*_size' variables, which we also use as */
- /* offsets into the `mmvar' array, must be multiples of the */
- /* pointer size (except the last one); without such an */
- /* alignment there might be runtime errors due to */
- /* misaligned addresses */
-#undef ALIGN_SIZE
-#define ALIGN_SIZE( n ) \
- ( ( (n) + sizeof (void*) - 1 ) & ~( sizeof (void*) - 1 ) )
-
- mmvar_size = ALIGN_SIZE( sizeof ( FT_MM_Var ) );
- axis_flags_size = ALIGN_SIZE( num_axes *
- sizeof ( FT_UShort ) );
- axis_size = ALIGN_SIZE( num_axes *
- sizeof ( FT_Var_Axis ) );
- namedstyle_size = ALIGN_SIZE( num_instances *
- sizeof ( FT_Var_Named_Style ) );
- next_coords_size = ALIGN_SIZE( num_instances *
- num_axes *
- sizeof ( FT_Fixed ) );
- next_name_size = num_axes * 5;
-
- if ( need_init )
- {
- ttface->blend->mmvar_len = mmvar_size +
- axis_flags_size +
- axis_size +
- namedstyle_size +
- next_coords_size +
- next_name_size;
-
- if ( FT_ALLOC( mmvar, ttface->blend->mmvar_len ) )
- goto Exit;
- ttface->blend->mmvar = mmvar;
-
- /* set up pointers and offsets into the `mmvar' array; */
- /* the data gets filled in later on */
-
- mmvar->num_axis =
- num_axes;
- mmvar->num_designs =
- ~0U; /* meaningless in this context; each glyph */
- /* may have a different number of designs */
- /* (or tuples, as called by Apple) */
- mmvar->num_namedstyles =
- num_instances;
-
- /* alas, no public field in `FT_Var_Axis' for axis flags */
- axis_flags =
- (FT_UShort*)( (char*)mmvar + mmvar_size );
- mmvar->axis =
- (FT_Var_Axis*)( (char*)axis_flags + axis_flags_size );
- mmvar->namedstyle =
- (FT_Var_Named_Style*)( (char*)mmvar->axis + axis_size );
-
- next_coords = (FT_Fixed*)( (char*)mmvar->namedstyle +
- namedstyle_size );
- for ( i = 0; i < num_instances; i++ )
- {
- mmvar->namedstyle[i].coords = next_coords;
- next_coords += num_axes;
- }
-
- next_name = (FT_String*)( (char*)mmvar->namedstyle +
- namedstyle_size + next_coords_size );
- for ( i = 0; i < num_axes; i++ )
- {
- mmvar->axis[i].name = next_name;
- next_name += 5;
- }
-
- /* now fill in the data */
-
- if ( FT_STREAM_SEEK( fvar_start + fvar_head.offsetToData ) )
- goto Exit;
-
- a = mmvar->axis;
- for ( i = 0; i < num_axes; i++ )
- {
- GX_FVar_Axis axis_rec;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- int invalid = 0;
-#endif
-
-
- if ( FT_STREAM_READ_FIELDS( fvaraxis_fields, &axis_rec ) )
- goto Exit;
- a->tag = axis_rec.axisTag;
- a->minimum = axis_rec.minValue;
- a->def = axis_rec.defaultValue;
- a->maximum = axis_rec.maxValue;
- a->strid = axis_rec.nameID;
-
- a->name[0] = (FT_String)( a->tag >> 24 );
- a->name[1] = (FT_String)( ( a->tag >> 16 ) & 0xFF );
- a->name[2] = (FT_String)( ( a->tag >> 8 ) & 0xFF );
- a->name[3] = (FT_String)( ( a->tag ) & 0xFF );
- a->name[4] = '\0';
-
- *axis_flags = axis_rec.flags;
-
- if ( a->minimum > a->def ||
- a->def > a->maximum )
- {
- a->minimum = a->def;
- a->maximum = a->def;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- invalid = 1;
-#endif
- }
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( i == 0 )
- FT_TRACE5(( " idx tag "
- /* " XXX `XXXX'" */
- " minimum default maximum flags\n" ));
- /* " XXXX.XXXXX XXXX.XXXXX XXXX.XXXXX 0xXXXX" */
-
- FT_TRACE5(( " %3d `%s'"
- " %10.5f %10.5f %10.5f 0x%04X%s\n",
- i,
- a->name,
- (double)a->minimum / 65536,
- (double)a->def / 65536,
- (double)a->maximum / 65536,
- *axis_flags,
- invalid ? " (invalid, disabled)" : "" ));
-#endif
-
- a++;
- axis_flags++;
- }
-
- FT_TRACE5(( "\n" ));
-
- /* named instance coordinates are stored as design coordinates; */
- /* we have to convert them to normalized coordinates also */
- if ( FT_NEW_ARRAY( ttface->blend->normalized_stylecoords,
- num_axes * num_instances ) )
- goto Exit;
-
- if ( fvar_head.instanceCount && !ttface->blend->avar_loaded )
- {
- FT_ULong offset = FT_STREAM_POS();
-
-
- ft_var_load_avar( ttface );
-
- if ( FT_STREAM_SEEK( offset ) )
- goto Exit;
- }
-
- FT_TRACE5(( "%d named instance%s\n",
- fvar_head.instanceCount,
- fvar_head.instanceCount == 1 ? "" : "s" ));
-
- ns = mmvar->namedstyle;
- nsc = ttface->blend->normalized_stylecoords;
- for ( i = 0; i < fvar_head.instanceCount; i++, ns++ )
- {
- /* PostScript names add 2 bytes to the instance record size */
- if ( FT_FRAME_ENTER( ( usePsName ? 6L : 4L ) +
- 4L * num_axes ) )
- goto Exit;
-
- ns->strid = FT_GET_USHORT();
- (void) /* flags = */ FT_GET_USHORT();
-
- c = ns->coords;
- for ( j = 0; j < num_axes; j++, c++ )
- *c = FT_GET_LONG();
-
- /* valid psid values are 6, [256;32767], and 0xFFFF */
- if ( usePsName )
- ns->psid = FT_GET_USHORT();
- else
- ns->psid = 0xFFFF;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- {
- SFNT_Service sfnt = (SFNT_Service)ttface->sfnt;
-
- FT_String* strname = NULL;
- FT_String* psname = NULL;
-
- FT_ULong pos;
-
-
- pos = FT_STREAM_POS();
-
- if ( ns->strid != 0xFFFF )
- {
- (void)sfnt->get_name( ttface,
- (FT_UShort)ns->strid,
- &strname );
- if ( strname && !ft_strcmp( strname, ".notdef" ) )
- strname = NULL;
- }
-
- if ( ns->psid != 0xFFFF )
- {
- (void)sfnt->get_name( ttface,
- (FT_UShort)ns->psid,
- &psname );
- if ( psname && !ft_strcmp( psname, ".notdef" ) )
- psname = NULL;
- }
-
- (void)FT_STREAM_SEEK( pos );
-
- FT_TRACE5(( " named instance %d (%s%s%s, %s%s%s)\n",
- i,
- strname ? "name: `" : "",
- strname ? strname : "unnamed",
- strname ? "'" : "",
- psname ? "PS name: `" : "",
- psname ? psname : "no PS name",
- psname ? "'" : "" ));
-
- FT_FREE( strname );
- FT_FREE( psname );
- }
-#endif /* FT_DEBUG_LEVEL_TRACE */
-
- ft_var_to_normalized( ttface, num_axes, ns->coords, nsc );
- nsc += num_axes;
-
- FT_FRAME_EXIT();
- }
-
- if ( num_instances != fvar_head.instanceCount )
- {
- SFNT_Service sfnt = (SFNT_Service)ttface->sfnt;
-
- FT_Int found, dummy1, dummy2;
- FT_UInt strid = ~0U;
-
-
- /* The default instance is missing in array the */
- /* of named instances; try to synthesize an entry. */
- /* If this fails, `default_named_instance` remains */
- /* at value zero, which doesn't do any harm. */
- found = sfnt->get_name_id( ttface,
- TT_NAME_ID_TYPOGRAPHIC_SUBFAMILY,
- &dummy1,
- &dummy2 );
- if ( found )
- strid = TT_NAME_ID_TYPOGRAPHIC_SUBFAMILY;
- else
- {
- found = sfnt->get_name_id( ttface,
- TT_NAME_ID_FONT_SUBFAMILY,
- &dummy1,
- &dummy2 );
- if ( found )
- strid = TT_NAME_ID_FONT_SUBFAMILY;
- }
-
- if ( found )
- {
- found = sfnt->get_name_id( ttface,
- TT_NAME_ID_PS_NAME,
- &dummy1,
- &dummy2 );
- if ( found )
- {
- FT_TRACE5(( "TT_Get_MM_Var:"
- " Adding default instance to named instances\n" ));
-
- /* named instance indices start with value 1 */
- ttface->var_default_named_instance = num_instances;
-
- ns = &mmvar->namedstyle[fvar_head.instanceCount];
-
- ns->strid = strid;
- ns->psid = TT_NAME_ID_PS_NAME;
-
- a = mmvar->axis;
- c = ns->coords;
- for ( j = 0; j < num_axes; j++, a++, c++ )
- *c = a->def;
- }
- }
- }
-
- ft_var_load_mvar( ttface );
- }
-
- /* fill the output array if requested */
-
- if ( master )
- {
- FT_UInt n;
-
-
- if ( FT_DUP( mmvar, ttface->blend->mmvar, ttface->blend->mmvar_len ) )
- goto Exit;
-
- axis_flags =
- (FT_UShort*)( (char*)mmvar + mmvar_size );
- mmvar->axis =
- (FT_Var_Axis*)( (char*)axis_flags + axis_flags_size );
- mmvar->namedstyle =
- (FT_Var_Named_Style*)( (char*)mmvar->axis+ axis_size );
-
- next_coords = (FT_Fixed*)( (char*)mmvar->namedstyle +
- namedstyle_size );
- for ( n = 0; n < mmvar->num_namedstyles; n++ )
- {
- mmvar->namedstyle[n].coords = next_coords;
- next_coords += num_axes;
- }
-
- a = mmvar->axis;
- next_name = (FT_String*)( (char*)mmvar->namedstyle +
- namedstyle_size + next_coords_size );
- for ( n = 0; n < num_axes; n++ )
- {
- a->name = next_name;
-
- /* standard PostScript names for some standard apple tags */
- if ( a->tag == TTAG_wght )
- a->name = (char*)"Weight";
- else if ( a->tag == TTAG_wdth )
- a->name = (char*)"Width";
- else if ( a->tag == TTAG_opsz )
- a->name = (char*)"OpticalSize";
- else if ( a->tag == TTAG_slnt )
- a->name = (char*)"Slant";
- else if ( a->tag == TTAG_ital )
- a->name = (char*)"Italic";
-
- next_name += 5;
- a++;
- }
-
- *master = mmvar;
- }
-
- Exit:
- return error;
- }
-
-
- static FT_Error
- tt_set_mm_blend( TT_Face face,
- FT_UInt num_coords,
- FT_Fixed* coords,
- FT_Bool set_design_coords )
- {
- FT_Error error = FT_Err_Ok;
- GX_Blend blend;
- FT_MM_Var* mmvar;
- FT_UInt i;
-
- FT_Bool all_design_coords = FALSE;
-
- FT_Memory memory = face->root.memory;
-
- enum
- {
- mcvt_retain,
- mcvt_modify,
- mcvt_load
-
- } manageCvt;
-
-
- face->doblend = FALSE;
-
- if ( !face->blend )
- {
- if ( FT_SET_ERROR( TT_Get_MM_Var( FT_FACE( face ), NULL ) ) )
- goto Exit;
- }
-
- blend = face->blend;
- mmvar = blend->mmvar;
-
- if ( num_coords > mmvar->num_axis )
- {
- FT_TRACE2(( "TT_Set_MM_Blend:"
- " only using first %d of %d coordinates\n",
- mmvar->num_axis, num_coords ));
- num_coords = mmvar->num_axis;
- }
-
- FT_TRACE5(( "TT_Set_MM_Blend:\n" ));
- FT_TRACE5(( " normalized design coordinates:\n" ));
-
- for ( i = 0; i < num_coords; i++ )
- {
- FT_TRACE5(( " %.5f\n", (double)coords[i] / 65536 ));
- if ( coords[i] < -0x00010000L || coords[i] > 0x00010000L )
- {
- FT_TRACE1(( "TT_Set_MM_Blend: normalized design coordinate %.5f\n",
- (double)coords[i] / 65536 ));
- FT_TRACE1(( " is out of range [-1;1]\n" ));
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
- }
-
- FT_TRACE5(( "\n" ));
-
- if ( !face->is_cff2 && !blend->glyphoffsets )
- {
- /* While a missing 'gvar' table is acceptable, for example for */
- /* fonts that only vary metrics information or 'COLR' v1 */
- /* `PaintVar*` tables, an incorrect SFNT table offset or size */
- /* for 'gvar', or an inconsistent 'gvar' table is not. */
- error = ft_var_load_gvar( face );
- if ( error != FT_Err_Table_Missing && error != FT_Err_Ok )
- goto Exit;
- error = FT_Err_Ok;
- }
-
- if ( !blend->coords )
- {
- if ( FT_NEW_ARRAY( blend->coords, mmvar->num_axis ) )
- goto Exit;
-
- /* the first time we have to compute all design coordinates */
- all_design_coords = TRUE;
- }
-
- if ( !blend->normalizedcoords )
- {
- if ( FT_NEW_ARRAY( blend->normalizedcoords, mmvar->num_axis ) )
- goto Exit;
-
- manageCvt = mcvt_modify;
-
- /* If we have not set the blend coordinates before this, then the */
- /* cvt table will still be what we read from the `cvt ' table and */
- /* we don't need to reload it. We may need to change it though... */
- }
- else
- {
- FT_Bool have_diff = 0;
- FT_UInt j;
- FT_Fixed* c;
- FT_Fixed* n;
-
-
- manageCvt = mcvt_retain;
-
- for ( i = 0; i < num_coords; i++ )
- {
- if ( blend->normalizedcoords[i] != coords[i] )
- {
- manageCvt = mcvt_load;
- have_diff = 1;
- break;
- }
- }
-
- if ( !have_diff )
- {
- if ( FT_IS_NAMED_INSTANCE( FT_FACE( face ) ) )
- {
- FT_UInt instance_index = (FT_UInt)face->root.face_index >> 16;
-
-
- c = blend->normalizedcoords + i;
- n = blend->normalized_stylecoords +
- ( instance_index - 1 ) * mmvar->num_axis +
- i;
-
- for ( j = i; j < mmvar->num_axis; j++, n++, c++ )
- if ( *c != *n )
- have_diff = 1;
- }
- else
- {
- c = blend->normalizedcoords + i;
- for ( j = i; j < mmvar->num_axis; j++, c++ )
- if ( *c != 0 )
- have_diff = 1;
- }
- }
-
- /* return value -1 indicates `no change' */
- if ( !have_diff )
- {
- face->doblend = TRUE;
-
- return -1;
- }
-
- for ( ; i < mmvar->num_axis; i++ )
- {
- if ( blend->normalizedcoords[i] != 0 )
- {
- manageCvt = mcvt_load;
- break;
- }
- }
-
- /* If we don't change the blend coords then we don't need to do */
- /* anything to the cvt table. It will be correct. Otherwise we */
- /* no longer have the original cvt (it was modified when we set */
- /* the blend last time), so we must reload and then modify it. */
- }
-
- blend->num_axis = mmvar->num_axis;
- if ( coords )
- FT_MEM_COPY( blend->normalizedcoords,
- coords,
- num_coords * sizeof ( FT_Fixed ) );
-
- if ( set_design_coords )
- ft_var_to_design( face,
- all_design_coords ? blend->num_axis : num_coords,
- blend->normalizedcoords,
- blend->coords );
-
- face->doblend = TRUE;
-
- if ( face->cvt )
- {
- switch ( manageCvt )
- {
- case mcvt_load:
- /* The cvt table has been loaded already; every time we change the */
- /* blend we may need to reload and remodify the cvt table. */
- FT_FREE( face->cvt );
-
- error = tt_face_load_cvt( face, face->root.stream );
- break;
-
- case mcvt_modify:
- /* The original cvt table is in memory. All we need to do is */
- /* apply the `cvar' table (if any). */
- error = tt_face_vary_cvt( face, face->root.stream );
- break;
-
- case mcvt_retain:
- /* The cvt table is correct for this set of coordinates. */
- break;
- }
- }
-
- Exit:
- return error;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * TT_Set_MM_Blend
- *
- * @Description:
- * Set the blend (normalized) coordinates for this instance of the
- * font. Check that the `gvar' table is reasonable and does some
- * initial preparation.
- *
- * @InOut:
- * face ::
- * The font.
- * Initialize the blend structure with `gvar' data.
- *
- * @Input:
- * num_coords ::
- * The number of available coordinates. If it is
- * larger than the number of axes, ignore the excess
- * values. If it is smaller than the number of axes,
- * use the default value (0) for the remaining axes.
- *
- * coords ::
- * An array of `num_coords', each between [-1,1].
- *
- * @Return:
- * FreeType error code. 0 means success, -1 means success and unchanged
- * axis values.
- */
- FT_LOCAL_DEF( FT_Error )
- TT_Set_MM_Blend( FT_Face face, /* TT_Face */
- FT_UInt num_coords,
- FT_Fixed* coords )
- {
- return tt_set_mm_blend( (TT_Face)face, num_coords, coords, 1 );
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * TT_Get_MM_Blend
- *
- * @Description:
- * Get the blend (normalized) coordinates for this instance of the
- * font.
- *
- * @InOut:
- * face ::
- * The font.
- * Initialize the blend structure with `gvar' data.
- *
- * @Input:
- * num_coords ::
- * The number of available coordinates. If it is
- * larger than the number of axes, set the excess
- * values to 0.
- *
- * coords ::
- * An array of `num_coords', each between [-1,1].
- *
- * @Return:
- * FreeType error code. 0 means success, -1 means success and unchanged
- * axis values.
- */
- FT_LOCAL_DEF( FT_Error )
- TT_Get_MM_Blend( FT_Face face, /* TT_Face */
- FT_UInt num_coords,
- FT_Fixed* coords )
- {
- TT_Face ttface = (TT_Face)face;
-
- FT_Error error = FT_Err_Ok;
- GX_Blend blend;
- FT_UInt i, nc;
-
-
- if ( !ttface->blend )
- {
- if ( FT_SET_ERROR( TT_Get_MM_Var( face, NULL ) ) )
- return error;
- }
-
- blend = ttface->blend;
-
- if ( !blend->coords )
- {
- /* select default instance coordinates */
- /* if no instance is selected yet */
- if ( FT_SET_ERROR( tt_set_mm_blend( ttface, 0, NULL, 1 ) ) )
- return error;
- }
-
- nc = num_coords;
- if ( num_coords > blend->num_axis )
- {
- FT_TRACE2(( "TT_Get_MM_Blend:"
- " only using first %d of %d coordinates\n",
- blend->num_axis, num_coords ));
- nc = blend->num_axis;
- }
-
- if ( ttface->doblend )
- {
- for ( i = 0; i < nc; i++ )
- coords[i] = blend->normalizedcoords[i];
- }
- else
- {
- for ( i = 0; i < nc; i++ )
- coords[i] = 0;
- }
-
- for ( ; i < num_coords; i++ )
- coords[i] = 0;
-
- return FT_Err_Ok;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * TT_Set_Var_Design
- *
- * @Description:
- * Set the coordinates for the instance, measured in the user
- * coordinate system. Parse the `avar' table (if present) to convert
- * from user to normalized coordinates.
- *
- * @InOut:
- * face ::
- * The font face.
- * Initialize the blend struct with `gvar' data.
- *
- * @Input:
- * num_coords ::
- * The number of available coordinates. If it is
- * larger than the number of axes, ignore the excess
- * values. If it is smaller than the number of axes,
- * use the default values for the remaining axes.
- *
- * coords ::
- * A coordinate array with `num_coords' elements.
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
- FT_LOCAL_DEF( FT_Error )
- TT_Set_Var_Design( FT_Face face, /* TT_Face */
- FT_UInt num_coords,
- FT_Fixed* coords )
- {
- TT_Face ttface = (TT_Face)face;
- FT_Error error = FT_Err_Ok;
- GX_Blend blend;
- FT_MM_Var* mmvar;
- FT_UInt i;
- FT_Memory memory = FT_FACE_MEMORY( face );
-
- FT_Fixed* c;
- FT_Fixed* n;
- FT_Fixed* normalized = NULL;
-
- FT_Bool have_diff = 0;
-
-
- if ( !ttface->blend )
- {
- if ( FT_SET_ERROR( TT_Get_MM_Var( face, NULL ) ) )
- goto Exit;
- }
-
- blend = ttface->blend;
- mmvar = blend->mmvar;
-
- if ( num_coords > mmvar->num_axis )
- {
- FT_TRACE2(( "TT_Set_Var_Design:"
- " only using first %d of %d coordinates\n",
- mmvar->num_axis, num_coords ));
- num_coords = mmvar->num_axis;
- }
-
- if ( !blend->coords )
- {
- if ( FT_NEW_ARRAY( blend->coords, mmvar->num_axis ) )
- goto Exit;
- }
-
- c = blend->coords;
- n = coords;
- for ( i = 0; i < num_coords; i++, n++, c++ )
- {
- if ( *c != *n )
- {
- *c = *n;
- have_diff = 1;
- }
- }
-
- if ( FT_IS_NAMED_INSTANCE( face ) )
- {
- FT_UInt instance_index;
- FT_Var_Named_Style* named_style;
-
-
- instance_index = (FT_UInt)face->face_index >> 16;
- named_style = mmvar->namedstyle + instance_index - 1;
-
- n = named_style->coords + num_coords;
- for ( ; i < mmvar->num_axis; i++, n++, c++ )
- {
- if ( *c != *n )
- {
- *c = *n;
- have_diff = 1;
- }
- }
- }
- else
- {
- FT_Var_Axis* a;
-
-
- a = mmvar->axis + num_coords;
- for ( ; i < mmvar->num_axis; i++, a++, c++ )
- {
- if ( *c != a->def )
- {
- *c = a->def;
- have_diff = 1;
- }
- }
- }
-
- /* return value -1 indicates `no change'; */
- /* we can exit early if `normalizedcoords' is already computed */
- if ( blend->normalizedcoords && !have_diff )
- return -1;
-
- if ( FT_NEW_ARRAY( normalized, mmvar->num_axis ) )
- goto Exit;
-
- if ( !ttface->blend->avar_loaded )
- ft_var_load_avar( ttface );
-
- FT_TRACE5(( "TT_Set_Var_Design:\n" ));
- FT_TRACE5(( " normalized design coordinates:\n" ));
- ft_var_to_normalized( ttface, num_coords, blend->coords, normalized );
-
- error = tt_set_mm_blend( ttface, mmvar->num_axis, normalized, 0 );
- if ( error )
- goto Exit;
-
- Exit:
- FT_FREE( normalized );
- return error;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * TT_Get_Var_Design
- *
- * @Description:
- * Get the design coordinates of the currently selected interpolated
- * font.
- *
- * @Input:
- * face ::
- * A handle to the source face.
- *
- * num_coords ::
- * The number of design coordinates to retrieve. If it
- * is larger than the number of axes, set the excess
- * values to~0.
- *
- * @Output:
- * coords ::
- * The design coordinates array.
- *
- * @Return:
- * FreeType error code. 0~means success.
- */
- FT_LOCAL_DEF( FT_Error )
- TT_Get_Var_Design( FT_Face face, /* TT_Face */
- FT_UInt num_coords,
- FT_Fixed* coords )
- {
- TT_Face ttface = (TT_Face)face;
- FT_Error error = FT_Err_Ok;
- GX_Blend blend;
- FT_UInt i, nc;
-
-
- if ( !ttface->blend )
- {
- if ( FT_SET_ERROR( TT_Get_MM_Var( face, NULL ) ) )
- return error;
- }
-
- blend = ttface->blend;
-
- if ( !blend->coords )
- {
- /* select default instance coordinates */
- /* if no instance is selected yet */
- if ( FT_SET_ERROR( tt_set_mm_blend( ttface, 0, NULL, 1 ) ) )
- return error;
- }
-
- nc = num_coords;
- if ( num_coords > blend->num_axis )
- {
- FT_TRACE2(( "TT_Get_Var_Design:"
- " only using first %d of %d coordinates\n",
- blend->num_axis, num_coords ));
- nc = blend->num_axis;
- }
-
- if ( ttface->doblend )
- {
- for ( i = 0; i < nc; i++ )
- coords[i] = blend->coords[i];
- }
- else
- {
- for ( i = 0; i < nc; i++ )
- coords[i] = 0;
- }
-
- for ( ; i < num_coords; i++ )
- coords[i] = 0;
-
- return FT_Err_Ok;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * TT_Set_Named_Instance
- *
- * @Description:
- * Set the given named instance, also resetting any further
- * variation.
- *
- * @Input:
- * face ::
- * A handle to the source face.
- *
- * instance_index ::
- * The instance index, starting with value 1.
- * Value 0 indicates to not use an instance.
- *
- * @Return:
- * FreeType error code. 0~means success, -1 means success and unchanged
- * axis values.
- */
- FT_LOCAL_DEF( FT_Error )
- TT_Set_Named_Instance( FT_Face face, /* TT_Face */
- FT_UInt instance_index )
- {
- TT_Face ttface = (TT_Face)face;
- FT_Error error;
- GX_Blend blend;
- FT_MM_Var* mmvar;
-
- FT_Memory memory = FT_FACE_MEMORY( face );
-
- FT_UInt num_instances;
-
-
- if ( !ttface->blend )
- {
- if ( FT_SET_ERROR( TT_Get_MM_Var( face, NULL ) ) )
- goto Exit;
- }
-
- blend = ttface->blend;
- mmvar = blend->mmvar;
-
- num_instances = (FT_UInt)face->style_flags >> 16;
-
- /* `instance_index' starts with value 1, thus `>' */
- if ( instance_index > num_instances )
- {
- error = FT_ERR( Invalid_Argument );
- goto Exit;
- }
-
- if ( instance_index > 0 )
- {
- SFNT_Service sfnt = (SFNT_Service)ttface->sfnt;
-
- FT_Var_Named_Style* named_style;
- FT_String* style_name;
-
-
- named_style = mmvar->namedstyle + instance_index - 1;
-
- error = sfnt->get_name( ttface,
- (FT_UShort)named_style->strid,
- &style_name );
- if ( error )
- goto Exit;
-
- /* set (or replace) style name */
- FT_FREE( face->style_name );
- face->style_name = style_name;
-
- /* finally, select the named instance */
- error = TT_Set_Var_Design( face,
- mmvar->num_axis,
- named_style->coords );
- }
- else
- {
- /* restore non-VF style name */
- FT_FREE( face->style_name );
- if ( FT_STRDUP( face->style_name, ttface->non_var_style_name ) )
- goto Exit;
- error = TT_Set_Var_Design( face, 0, NULL );
- }
-
- Exit:
- return error;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * TT_Get_Default_Named_Instance
- *
- * @Description:
- * Get the default named instance.
- *
- * @Input:
- * face ::
- * A handle to the source face.
- *
- * @Output:
- * instance_index ::
- * The default named instance index.
- *
- * @Return:
- * FreeType error code. 0~means success.
- */
- FT_LOCAL_DEF( FT_Error )
- TT_Get_Default_Named_Instance( FT_Face face,
- FT_UInt *instance_index )
- {
- TT_Face ttface = (TT_Face)face;
- FT_Error error = FT_Err_Ok;
-
-
- if ( !ttface->blend )
- {
- if ( FT_SET_ERROR( TT_Get_MM_Var( face, NULL ) ) )
- goto Exit;
- }
-
- *instance_index = ttface->var_default_named_instance;
-
- Exit:
- return error;
- }
-
-
- /* This function triggers (lazy) recomputation of the `postscript_name` */
- /* field in `TT_Face`. */
-
- FT_LOCAL_DEF( void )
- tt_construct_ps_name( FT_Face face )
- {
- TT_Face ttface = (TT_Face)face;
- FT_Memory memory = FT_FACE_MEMORY( face );
-
-
- FT_FREE( ttface->postscript_name );
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** GX VAR PARSING ROUTINES *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-
-#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
-
- static FT_Error
- tt_cvt_ready_iterator( FT_ListNode node,
- void* user )
- {
- TT_Size size = (TT_Size)node->data;
-
- FT_UNUSED( user );
-
-
- size->cvt_ready = -1;
-
- return FT_Err_Ok;
- }
-
-#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
-
-
-
- /**************************************************************************
- *
- * @Function:
- * tt_face_vary_cvt
- *
- * @Description:
- * Modify the loaded cvt table according to the `cvar' table and the
- * font's blend.
- *
- * @InOut:
- * face ::
- * A handle to the target face object.
- *
- * @Input:
- * stream ::
- * A handle to the input stream.
- *
- * @Return:
- * FreeType error code. 0 means success.
- *
- * Most errors are ignored. It is perfectly valid not to have a
- * `cvar' table even if there is a `gvar' and `fvar' table.
- */
- FT_LOCAL_DEF( FT_Error )
- tt_face_vary_cvt( TT_Face face,
- FT_Stream stream )
- {
-#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
-
- FT_Error error;
- FT_Memory memory = stream->memory;
-
- FT_Face root = &face->root;
-
- FT_ULong table_start;
- FT_ULong table_len;
-
- FT_UInt tupleCount;
- FT_ULong offsetToData;
-
- FT_ULong here;
- FT_UInt i, j;
-
- FT_Fixed* peak_coords = NULL;
- FT_Fixed* tuple_coords;
- FT_Fixed* im_start_coords;
- FT_Fixed* im_end_coords;
-
- GX_Blend blend = face->blend;
-
- FT_UInt point_count;
- FT_UInt spoint_count = 0;
-
- FT_UShort* sharedpoints = NULL;
- FT_UShort* localpoints = NULL;
- FT_UShort* points;
-
- FT_Fixed* deltas = NULL;
- FT_Fixed* cvt_deltas = NULL;
-
-
- FT_TRACE2(( "CVAR " ));
-
- if ( !blend )
- {
- FT_TRACE2(( "\n" ));
- FT_TRACE2(( "tt_face_vary_cvt: no blend specified\n" ));
-
- return FT_Err_Ok;
- }
-
- if ( !face->cvt )
- {
- FT_TRACE2(( "\n" ));
- FT_TRACE2(( "tt_face_vary_cvt: no `cvt ' table\n" ));
-
- return FT_Err_Ok;
- }
-
- error = face->goto_table( face, TTAG_cvar, stream, &table_len );
- if ( error )
- {
- FT_TRACE2(( "is missing\n" ));
-
- return FT_Err_Ok;
- }
-
- if ( FT_FRAME_ENTER( table_len ) )
- return FT_Err_Ok;
-
- table_start = FT_Stream_FTell( stream );
- if ( FT_GET_LONG() != 0x00010000L )
- {
- FT_TRACE2(( "bad table version\n" ));
-
- error = FT_Err_Ok;
- goto FExit;
- }
-
- FT_TRACE2(( "loaded\n" ));
-
- tupleCount = FT_GET_USHORT();
- offsetToData = FT_GET_USHORT();
-
- /* rough sanity test */
- if ( offsetToData + ( tupleCount & GX_TC_TUPLE_COUNT_MASK ) * 4 >
- table_len )
- {
- FT_TRACE2(( "tt_face_vary_cvt:"
- " invalid CVT variation array header\n" ));
-
- error = FT_THROW( Invalid_Table );
- goto FExit;
- }
-
- offsetToData += table_start;
-
- if ( tupleCount & GX_TC_TUPLES_SHARE_POINT_NUMBERS )
- {
- here = FT_Stream_FTell( stream );
-
- FT_Stream_SeekSet( stream, offsetToData );
-
- sharedpoints = ft_var_readpackedpoints( stream, &spoint_count );
-
- offsetToData = FT_Stream_FTell( stream );
-
- FT_Stream_SeekSet( stream, here );
- }
-
- FT_TRACE5(( "cvar: there %s %d tuple%s:\n",
- ( tupleCount & GX_TC_TUPLE_COUNT_MASK ) == 1 ? "is" : "are",
- tupleCount & GX_TC_TUPLE_COUNT_MASK,
- ( tupleCount & GX_TC_TUPLE_COUNT_MASK ) == 1 ? "" : "s" ));
-
- if ( FT_QNEW_ARRAY( peak_coords, 3 * blend->num_axis ) ||
- FT_NEW_ARRAY( cvt_deltas, face->cvt_size ) )
- goto Exit;
-
- im_start_coords = peak_coords + blend->num_axis;
- im_end_coords = im_start_coords + blend->num_axis;
-
- for ( i = 0; i < ( tupleCount & GX_TC_TUPLE_COUNT_MASK ); i++ )
- {
- FT_UInt tupleDataSize;
- FT_UInt tupleIndex;
- FT_Fixed apply;
-
-
- FT_TRACE6(( " tuple %d:\n", i ));
-
- tupleDataSize = FT_GET_USHORT();
- tupleIndex = FT_GET_USHORT();
-
- if ( tupleIndex & GX_TI_EMBEDDED_TUPLE_COORD )
- {
- for ( j = 0; j < blend->num_axis; j++ )
- peak_coords[j] = FT_fdot14ToFixed( FT_GET_SHORT() );
- tuple_coords = peak_coords;
- }
- else if ( ( tupleIndex & GX_TI_TUPLE_INDEX_MASK ) < blend->tuplecount )
- tuple_coords = blend->tuplecoords +
- ( tupleIndex & GX_TI_TUPLE_INDEX_MASK ) * blend->num_axis;
- else
- {
- FT_TRACE2(( "tt_face_vary_cvt:"
- " invalid tuple index\n" ));
-
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- if ( tupleIndex & GX_TI_INTERMEDIATE_TUPLE )
- {
- for ( j = 0; j < blend->num_axis; j++ )
- im_start_coords[j] = FT_fdot14ToFixed( FT_GET_SHORT() );
- for ( j = 0; j < blend->num_axis; j++ )
- im_end_coords[j] = FT_fdot14ToFixed( FT_GET_SHORT() );
- }
-
- apply = ft_var_apply_tuple( blend,
- (FT_UShort)tupleIndex,
- tuple_coords,
- im_start_coords,
- im_end_coords );
-
- if ( apply == 0 ) /* tuple isn't active for our blend */
- {
- offsetToData += tupleDataSize;
- continue;
- }
-
- here = FT_Stream_FTell( stream );
-
- FT_Stream_SeekSet( stream, offsetToData );
-
- if ( tupleIndex & GX_TI_PRIVATE_POINT_NUMBERS )
- {
- localpoints = ft_var_readpackedpoints( stream, &point_count );
- points = localpoints;
- }
- else
- {
- localpoints = NULL;
- points = sharedpoints;
- point_count = spoint_count;
- }
-
- deltas = ft_var_readpackeddeltas( stream,
- point_count == 0 ? face->cvt_size
- : point_count );
-
- if ( !points || !deltas )
- ; /* failure, ignore it */
-
- else if ( localpoints == ALL_POINTS )
- {
-#ifdef FT_DEBUG_LEVEL_TRACE
- int count = 0;
-#endif
-
-
- FT_TRACE7(( " CVT deltas:\n" ));
-
- /* this means that there are deltas for every entry in cvt */
- for ( j = 0; j < face->cvt_size; j++ )
- {
- FT_Fixed old_cvt_delta;
-
-
- old_cvt_delta = cvt_deltas[j];
- cvt_deltas[j] = old_cvt_delta + FT_MulFix( deltas[j], apply );
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( old_cvt_delta != cvt_deltas[j] )
- {
- FT_TRACE7(( " %d: %f -> %f\n",
- j,
- (double)( FT_fdot6ToFixed( face->cvt[j] ) +
- old_cvt_delta ) / 65536,
- (double)( FT_fdot6ToFixed( face->cvt[j] ) +
- cvt_deltas[j] ) / 65536 ));
- count++;
- }
-#endif
- }
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( !count )
- FT_TRACE7(( " none\n" ));
-#endif
- }
-
- else
- {
-#ifdef FT_DEBUG_LEVEL_TRACE
- int count = 0;
-#endif
-
-
- FT_TRACE7(( " CVT deltas:\n" ));
-
- for ( j = 0; j < point_count; j++ )
- {
- int pindex;
- FT_Fixed old_cvt_delta;
-
-
- pindex = points[j];
- if ( (FT_ULong)pindex >= face->cvt_size )
- continue;
-
- old_cvt_delta = cvt_deltas[pindex];
- cvt_deltas[pindex] = old_cvt_delta + FT_MulFix( deltas[j], apply );
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( old_cvt_delta != cvt_deltas[pindex] )
- {
- FT_TRACE7(( " %d: %f -> %f\n",
- pindex,
- (double)( FT_fdot6ToFixed( face->cvt[pindex] ) +
- old_cvt_delta ) / 65536,
- (double)( FT_fdot6ToFixed( face->cvt[pindex] ) +
- cvt_deltas[pindex] ) / 65536 ));
- count++;
- }
-#endif
- }
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( !count )
- FT_TRACE7(( " none\n" ));
-#endif
- }
-
- if ( localpoints != ALL_POINTS )
- FT_FREE( localpoints );
- FT_FREE( deltas );
-
- offsetToData += tupleDataSize;
-
- FT_Stream_SeekSet( stream, here );
- }
-
- FT_TRACE5(( "\n" ));
-
- for ( i = 0; i < face->cvt_size; i++ )
- face->cvt[i] += FT_fixedToFdot6( cvt_deltas[i] );
-
- /* Iterate over all `FT_Size` objects and set `cvt_ready` to -1 */
- /* to trigger rescaling of all CVT values. */
- FT_List_Iterate( &root->sizes_list,
- tt_cvt_ready_iterator,
- NULL );
-
- Exit:
- if ( sharedpoints != ALL_POINTS )
- FT_FREE( sharedpoints );
- FT_FREE( cvt_deltas );
- FT_FREE( peak_coords );
-
- FExit:
- FT_FRAME_EXIT();
-
- return error;
-
-#else /* !TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
-
- FT_UNUSED( face );
- FT_UNUSED( stream );
-
- return FT_Err_Ok;
-
-#endif /* !TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
-
- }
-
-
- /* Shift the original coordinates of all points between indices `p1' */
- /* and `p2', using the same difference as given by index `ref'. */
-
- /* modeled after `af_iup_shift' */
-
- static void
- tt_delta_shift( int p1,
- int p2,
- int ref,
- FT_Vector* in_points,
- FT_Vector* out_points )
- {
- int p;
- FT_Vector delta;
-
-
- delta.x = out_points[ref].x - in_points[ref].x;
- delta.y = out_points[ref].y - in_points[ref].y;
-
- if ( delta.x == 0 && delta.y == 0 )
- return;
-
- for ( p = p1; p < ref; p++ )
- {
- out_points[p].x += delta.x;
- out_points[p].y += delta.y;
- }
-
- for ( p = ref + 1; p <= p2; p++ )
- {
- out_points[p].x += delta.x;
- out_points[p].y += delta.y;
- }
- }
-
-
- /* Interpolate the original coordinates of all points with indices */
- /* between `p1' and `p2', using `ref1' and `ref2' as the reference */
- /* point indices. */
-
- /* modeled after `af_iup_interp', `_iup_worker_interpolate', and */
- /* `Ins_IUP' with spec differences in handling ill-defined cases. */
- static void
- tt_delta_interpolate( int p1,
- int p2,
- int ref1,
- int ref2,
- FT_Vector* in_points,
- FT_Vector* out_points )
- {
- int p, i;
-
- FT_Pos out, in1, in2, out1, out2, d1, d2;
-
-
- if ( p1 > p2 )
- return;
-
- /* handle both horizontal and vertical coordinates */
- for ( i = 0; i <= 1; i++ )
- {
- /* shift array pointers so that we can access `foo.y' as `foo.x' */
- in_points = (FT_Vector*)( (FT_Pos*)in_points + i );
- out_points = (FT_Vector*)( (FT_Pos*)out_points + i );
-
- if ( in_points[ref1].x > in_points[ref2].x )
- {
- p = ref1;
- ref1 = ref2;
- ref2 = p;
- }
-
- in1 = in_points[ref1].x;
- in2 = in_points[ref2].x;
- out1 = out_points[ref1].x;
- out2 = out_points[ref2].x;
- d1 = out1 - in1;
- d2 = out2 - in2;
-
- /* If the reference points have the same coordinate but different */
- /* delta, inferred delta is zero. Otherwise interpolate. */
- if ( in1 != in2 || out1 == out2 )
- {
- FT_Fixed scale = in1 != in2 ? FT_DivFix( out2 - out1, in2 - in1 )
- : 0;
-
-
- for ( p = p1; p <= p2; p++ )
- {
- out = in_points[p].x;
-
- if ( out <= in1 )
- out += d1;
- else if ( out >= in2 )
- out += d2;
- else
- out = out1 + FT_MulFix( out - in1, scale );
-
- out_points[p].x = out;
- }
- }
- }
- }
-
-
- /* Interpolate points without delta values, similar to */
- /* the `IUP' hinting instruction. */
-
- /* modeled after `Ins_IUP */
-
- static void
- tt_interpolate_deltas( FT_Outline* outline,
- FT_Vector* out_points,
- FT_Vector* in_points,
- FT_Bool* has_delta )
- {
- FT_Int first_point;
- FT_Int end_point;
-
- FT_Int first_delta;
- FT_Int cur_delta;
-
- FT_Int point;
- FT_Short contour;
-
-
- /* ignore empty outlines */
- if ( !outline->n_contours )
- return;
-
- contour = 0;
- point = 0;
-
- do
- {
- end_point = outline->contours[contour];
- first_point = point;
-
- /* search first point that has a delta */
- while ( point <= end_point && !has_delta[point] )
- point++;
-
- if ( point <= end_point )
- {
- first_delta = point;
- cur_delta = point;
-
- point++;
-
- while ( point <= end_point )
- {
- /* search next point that has a delta */
- /* and interpolate intermediate points */
- if ( has_delta[point] )
- {
- tt_delta_interpolate( cur_delta + 1,
- point - 1,
- cur_delta,
- point,
- in_points,
- out_points );
- cur_delta = point;
- }
-
- point++;
- }
-
- /* shift contour if we only have a single delta */
- if ( cur_delta == first_delta )
- tt_delta_shift( first_point,
- end_point,
- cur_delta,
- in_points,
- out_points );
- else
- {
- /* otherwise handle remaining points */
- /* at the end and beginning of the contour */
- tt_delta_interpolate( cur_delta + 1,
- end_point,
- cur_delta,
- first_delta,
- in_points,
- out_points );
-
- if ( first_delta > 0 )
- tt_delta_interpolate( first_point,
- first_delta - 1,
- cur_delta,
- first_delta,
- in_points,
- out_points );
- }
- }
- contour++;
-
- } while ( contour < outline->n_contours );
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * TT_Vary_Apply_Glyph_Deltas
- *
- * @Description:
- * Apply the appropriate deltas to the current glyph.
- *
- * @InOut:
- * loader ::
- * A handle to the loader object.
- *
- * outline ::
- * The outline to change, with appended phantom points.
- *
- * @Output:
- * unrounded ::
- * An array with `n_points' elements that is filled with unrounded
- * point coordinates (in 26.6 format).
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
- FT_LOCAL_DEF( FT_Error )
- TT_Vary_Apply_Glyph_Deltas( TT_Loader loader,
- FT_Outline* outline,
- FT_Vector* unrounded )
- {
- FT_Error error;
- TT_Face face = loader->face;
- FT_Stream stream = face->root.stream;
- FT_Memory memory = stream->memory;
- FT_UInt glyph_index = loader->glyph_index;
- FT_UInt n_points = (FT_UInt)outline->n_points + 4;
-
- FT_Vector* points_org = NULL; /* coordinates in 16.16 format */
- FT_Vector* points_out = NULL; /* coordinates in 16.16 format */
- FT_Bool* has_delta = NULL;
-
- FT_ULong glyph_start;
-
- FT_UInt tupleCount;
- FT_ULong offsetToData;
- FT_ULong dataSize;
-
- FT_ULong here;
- FT_UInt i, j;
-
- FT_Fixed* peak_coords = NULL;
- FT_Fixed* tuple_coords;
- FT_Fixed* im_start_coords;
- FT_Fixed* im_end_coords;
-
- GX_Blend blend = face->blend;
-
- FT_UInt point_count;
- FT_UInt spoint_count = 0;
-
- FT_UShort* sharedpoints = NULL;
- FT_UShort* localpoints = NULL;
- FT_UShort* points;
-
- FT_Fixed* deltas_x = NULL;
- FT_Fixed* deltas_y = NULL;
- FT_Fixed* point_deltas_x = NULL;
- FT_Fixed* point_deltas_y = NULL;
-
-
- if ( !face->doblend || !blend )
- return FT_THROW( Invalid_Argument );
-
- for ( i = 0; i < n_points; i++ )
- {
- unrounded[i].x = INT_TO_F26DOT6( outline->points[i].x );
- unrounded[i].y = INT_TO_F26DOT6( outline->points[i].y );
- }
-
- if ( glyph_index >= blend->gv_glyphcnt ||
- blend->glyphoffsets[glyph_index] ==
- blend->glyphoffsets[glyph_index + 1] )
- {
- FT_TRACE2(( "TT_Vary_Apply_Glyph_Deltas:"
- " no variation data for glyph %d\n", glyph_index ));
- return FT_Err_Ok;
- }
-
- dataSize = blend->glyphoffsets[glyph_index + 1] -
- blend->glyphoffsets[glyph_index];
-
- if ( FT_STREAM_SEEK( blend->glyphoffsets[glyph_index] ) ||
- FT_FRAME_ENTER( dataSize ) )
- return error;
-
- glyph_start = FT_Stream_FTell( stream );
-
- /* each set of glyph variation data is formatted similarly to `cvar' */
-
- tupleCount = FT_GET_USHORT();
- offsetToData = FT_GET_USHORT();
-
- /* rough sanity test */
- if ( offsetToData > dataSize ||
- ( tupleCount & GX_TC_TUPLE_COUNT_MASK ) * 4 > dataSize )
- {
- FT_TRACE2(( "TT_Vary_Apply_Glyph_Deltas:"
- " invalid glyph variation array header\n" ));
-
- error = FT_THROW( Invalid_Table );
- goto FExit;
- }
-
- offsetToData += glyph_start;
-
- if ( tupleCount & GX_TC_TUPLES_SHARE_POINT_NUMBERS )
- {
- here = FT_Stream_FTell( stream );
-
- FT_Stream_SeekSet( stream, offsetToData );
-
- sharedpoints = ft_var_readpackedpoints( stream, &spoint_count );
-
- offsetToData = FT_Stream_FTell( stream );
-
- FT_Stream_SeekSet( stream, here );
- }
-
- FT_TRACE5(( "gvar: there %s %d tuple%s:\n",
- ( tupleCount & GX_TC_TUPLE_COUNT_MASK ) == 1 ? "is" : "are",
- tupleCount & GX_TC_TUPLE_COUNT_MASK,
- ( tupleCount & GX_TC_TUPLE_COUNT_MASK ) == 1 ? "" : "s" ));
-
- if ( FT_QNEW_ARRAY( peak_coords, 3 * blend->num_axis ) ||
- FT_NEW_ARRAY( point_deltas_x, 2 * n_points ) ||
- FT_QNEW_ARRAY( points_org, n_points ) ||
- FT_QNEW_ARRAY( points_out, n_points ) ||
- FT_QNEW_ARRAY( has_delta, n_points ) )
- goto Exit;
-
- im_start_coords = peak_coords + blend->num_axis;
- im_end_coords = im_start_coords + blend->num_axis;
- point_deltas_y = point_deltas_x + n_points;
-
- for ( j = 0; j < n_points; j++ )
- {
- points_org[j].x = FT_intToFixed( outline->points[j].x );
- points_org[j].y = FT_intToFixed( outline->points[j].y );
- }
-
- for ( i = 0; i < ( tupleCount & GX_TC_TUPLE_COUNT_MASK ); i++ )
- {
- FT_UInt tupleDataSize;
- FT_UInt tupleIndex;
- FT_Fixed apply;
-
-
- FT_TRACE6(( " tuple %d:\n", i ));
-
- tupleDataSize = FT_GET_USHORT();
- tupleIndex = FT_GET_USHORT();
-
- if ( tupleIndex & GX_TI_EMBEDDED_TUPLE_COORD )
- {
- for ( j = 0; j < blend->num_axis; j++ )
- peak_coords[j] = FT_fdot14ToFixed( FT_GET_SHORT() );
- tuple_coords = peak_coords;
- }
- else if ( ( tupleIndex & GX_TI_TUPLE_INDEX_MASK ) < blend->tuplecount )
- tuple_coords = blend->tuplecoords +
- ( tupleIndex & GX_TI_TUPLE_INDEX_MASK ) * blend->num_axis;
- else
- {
- FT_TRACE2(( "TT_Vary_Apply_Glyph_Deltas:"
- " invalid tuple index\n" ));
-
- error = FT_THROW( Invalid_Table );
- goto Exit;
- }
-
- if ( tupleIndex & GX_TI_INTERMEDIATE_TUPLE )
- {
- for ( j = 0; j < blend->num_axis; j++ )
- im_start_coords[j] = FT_fdot14ToFixed( FT_GET_SHORT() );
- for ( j = 0; j < blend->num_axis; j++ )
- im_end_coords[j] = FT_fdot14ToFixed( FT_GET_SHORT() );
- }
-
- apply = ft_var_apply_tuple( blend,
- (FT_UShort)tupleIndex,
- tuple_coords,
- im_start_coords,
- im_end_coords );
-
- if ( apply == 0 ) /* tuple isn't active for our blend */
- {
- offsetToData += tupleDataSize;
- continue;
- }
-
- here = FT_Stream_FTell( stream );
-
- FT_Stream_SeekSet( stream, offsetToData );
-
- if ( tupleIndex & GX_TI_PRIVATE_POINT_NUMBERS )
- {
- localpoints = ft_var_readpackedpoints( stream, &point_count );
- points = localpoints;
- }
- else
- {
- points = sharedpoints;
- point_count = spoint_count;
- }
-
- deltas_x = ft_var_readpackeddeltas( stream,
- point_count == 0 ? n_points
- : point_count );
- deltas_y = ft_var_readpackeddeltas( stream,
- point_count == 0 ? n_points
- : point_count );
-
- if ( !points || !deltas_y || !deltas_x )
- ; /* failure, ignore it */
-
- else if ( points == ALL_POINTS )
- {
-#ifdef FT_DEBUG_LEVEL_TRACE
- int count = 0;
-#endif
-
-
- FT_TRACE7(( " point deltas:\n" ));
-
- /* this means that there are deltas for every point in the glyph */
- for ( j = 0; j < n_points; j++ )
- {
- FT_Fixed old_point_delta_x = point_deltas_x[j];
- FT_Fixed old_point_delta_y = point_deltas_y[j];
-
- FT_Fixed point_delta_x = FT_MulFix( deltas_x[j], apply );
- FT_Fixed point_delta_y = FT_MulFix( deltas_y[j], apply );
-
-
- point_deltas_x[j] = old_point_delta_x + point_delta_x;
- point_deltas_y[j] = old_point_delta_y + point_delta_y;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( point_delta_x || point_delta_y )
- {
- FT_TRACE7(( " %d: (%f, %f) -> (%f, %f)\n",
- j,
- (double)( FT_intToFixed( outline->points[j].x ) +
- old_point_delta_x ) / 65536,
- (double)( FT_intToFixed( outline->points[j].y ) +
- old_point_delta_y ) / 65536,
- (double)( FT_intToFixed( outline->points[j].x ) +
- point_deltas_x[j] ) / 65536,
- (double)( FT_intToFixed( outline->points[j].y ) +
- point_deltas_y[j] ) / 65536 ));
- count++;
- }
-#endif
- }
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( !count )
- FT_TRACE7(( " none\n" ));
-#endif
- }
-
- else
- {
-#ifdef FT_DEBUG_LEVEL_TRACE
- int count = 0;
-#endif
-
-
- /* we have to interpolate the missing deltas similar to the */
- /* IUP bytecode instruction */
- for ( j = 0; j < n_points; j++ )
- {
- has_delta[j] = FALSE;
- points_out[j] = points_org[j];
- }
-
- for ( j = 0; j < point_count; j++ )
- {
- FT_UShort idx = points[j];
-
-
- if ( idx >= n_points )
- continue;
-
- has_delta[idx] = TRUE;
-
- points_out[idx].x += FT_MulFix( deltas_x[j], apply );
- points_out[idx].y += FT_MulFix( deltas_y[j], apply );
- }
-
- /* no need to handle phantom points here, */
- /* since solitary points can't be interpolated */
- tt_interpolate_deltas( outline,
- points_out,
- points_org,
- has_delta );
-
- FT_TRACE7(( " point deltas:\n" ));
-
- for ( j = 0; j < n_points; j++ )
- {
- FT_Fixed old_point_delta_x = point_deltas_x[j];
- FT_Fixed old_point_delta_y = point_deltas_y[j];
-
- FT_Pos point_delta_x = points_out[j].x - points_org[j].x;
- FT_Pos point_delta_y = points_out[j].y - points_org[j].y;
-
-
- point_deltas_x[j] = old_point_delta_x + point_delta_x;
- point_deltas_y[j] = old_point_delta_y + point_delta_y;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( point_delta_x || point_delta_y )
- {
- FT_TRACE7(( " %d: (%f, %f) -> (%f, %f)\n",
- j,
- (double)( FT_intToFixed( outline->points[j].x ) +
- old_point_delta_x ) / 65536,
- (double)( FT_intToFixed( outline->points[j].y ) +
- old_point_delta_y ) / 65536,
- (double)( FT_intToFixed( outline->points[j].x ) +
- point_deltas_x[j] ) / 65536,
- (double)( FT_intToFixed( outline->points[j].y ) +
- point_deltas_y[j] ) / 65536 ));
- count++;
- }
-#endif
- }
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( !count )
- FT_TRACE7(( " none\n" ));
-#endif
- }
-
- if ( localpoints != ALL_POINTS )
- FT_FREE( localpoints );
- FT_FREE( deltas_x );
- FT_FREE( deltas_y );
-
- offsetToData += tupleDataSize;
-
- FT_Stream_SeekSet( stream, here );
- }
-
- FT_TRACE5(( "\n" ));
-
- /* To avoid double adjustment of advance width or height, */
- /* do not move phantom points if there is HVAR or VVAR */
- /* support, respectively. */
- if ( face->variation_support & TT_FACE_FLAG_VAR_HADVANCE )
- {
- point_deltas_x[n_points - 4] = 0;
- point_deltas_y[n_points - 4] = 0;
- point_deltas_x[n_points - 3] = 0;
- point_deltas_y[n_points - 3] = 0;
- }
- if ( face->variation_support & TT_FACE_FLAG_VAR_VADVANCE )
- {
- point_deltas_x[n_points - 2] = 0;
- point_deltas_y[n_points - 2] = 0;
- point_deltas_x[n_points - 1] = 0;
- point_deltas_y[n_points - 1] = 0;
- }
-
- for ( i = 0; i < n_points; i++ )
- {
- unrounded[i].x += FT_fixedToFdot6( point_deltas_x[i] );
- unrounded[i].y += FT_fixedToFdot6( point_deltas_y[i] );
-
- outline->points[i].x += FT_fixedToInt( point_deltas_x[i] );
- outline->points[i].y += FT_fixedToInt( point_deltas_y[i] );
- }
-
- /* To avoid double adjustment of advance width or height, */
- /* adjust phantom points only if there is no HVAR or VVAR */
- /* support, respectively. */
- if ( !( face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) )
- {
- loader->pp1 = outline->points[n_points - 4];
- loader->pp2 = outline->points[n_points - 3];
- loader->linear = FT_PIX_ROUND( unrounded[n_points - 3].x -
- unrounded[n_points - 4].x ) / 64;
- }
- if ( !( face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) )
- {
- loader->pp3 = outline->points[n_points - 2];
- loader->pp4 = outline->points[n_points - 1];
- loader->vadvance = FT_PIX_ROUND( unrounded[n_points - 1].y -
- unrounded[n_points - 2].y ) / 64;
- }
-
- Exit:
- if ( sharedpoints != ALL_POINTS )
- FT_FREE( sharedpoints );
- FT_FREE( points_org );
- FT_FREE( points_out );
- FT_FREE( has_delta );
- FT_FREE( peak_coords );
- FT_FREE( point_deltas_x );
-
- FExit:
- FT_FRAME_EXIT();
-
- return error;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * tt_get_var_blend
- *
- * @Description:
- * An extended internal version of `TT_Get_MM_Blend' that returns
- * pointers instead of copying data, without any initialization of
- * the MM machinery in case it isn't loaded yet.
- */
- FT_LOCAL_DEF( FT_Error )
- tt_get_var_blend( FT_Face face, /* TT_Face */
- FT_UInt *num_coords,
- FT_Fixed* *coords,
- FT_Fixed* *normalizedcoords,
- FT_MM_Var* *mm_var )
- {
- TT_Face ttface = (TT_Face)face;
-
-
- if ( ttface->blend )
- {
- if ( num_coords )
- *num_coords = ttface->blend->num_axis;
- if ( coords )
- *coords = ttface->blend->coords;
- if ( normalizedcoords )
- *normalizedcoords = ttface->blend->normalizedcoords;
- if ( mm_var )
- *mm_var = ttface->blend->mmvar;
- }
- else
- {
- if ( num_coords )
- *num_coords = 0;
- if ( coords )
- *coords = NULL;
- if ( mm_var )
- *mm_var = NULL;
- }
-
- return FT_Err_Ok;
- }
-
-
- FT_LOCAL_DEF( void )
- tt_var_done_item_variation_store( FT_Face face,
- GX_ItemVarStore itemStore )
- {
- FT_Memory memory = FT_FACE_MEMORY( face );
- FT_UInt i;
-
-
- if ( itemStore->varData )
- {
- for ( i = 0; i < itemStore->dataCount; i++ )
- {
- FT_FREE( itemStore->varData[i].regionIndices );
- FT_FREE( itemStore->varData[i].deltaSet );
- }
-
- FT_FREE( itemStore->varData );
- }
-
- if ( itemStore->varRegionList )
- {
- for ( i = 0; i < itemStore->regionCount; i++ )
- FT_FREE( itemStore->varRegionList[i].axisList );
-
- FT_FREE( itemStore->varRegionList );
- }
- }
-
-
- FT_LOCAL_DEF( void )
- tt_var_done_delta_set_index_map( FT_Face face,
- GX_DeltaSetIdxMap deltaSetIdxMap )
- {
- FT_Memory memory = FT_FACE_MEMORY( face );
-
-
- FT_FREE( deltaSetIdxMap->innerIndex );
- FT_FREE( deltaSetIdxMap->outerIndex );
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * tt_done_blend
- *
- * @Description:
- * Free the blend internal data structure.
- */
- FT_LOCAL_DEF( void )
- tt_done_blend( FT_Face face )
- {
- TT_Face ttface = (TT_Face)face;
- FT_Memory memory = FT_FACE_MEMORY( face );
- GX_Blend blend = ttface->blend;
-
-
- if ( blend )
- {
- FT_UInt i, num_axes;
-
-
- /* blend->num_axis might not be set up yet */
- num_axes = blend->mmvar->num_axis;
-
- FT_FREE( blend->coords );
- FT_FREE( blend->normalizedcoords );
- FT_FREE( blend->normalized_stylecoords );
- FT_FREE( blend->mmvar );
-
- if ( blend->avar_table )
- {
- if ( blend->avar_table->avar_segment )
- {
- for ( i = 0; i < num_axes; i++ )
- FT_FREE( blend->avar_table->avar_segment[i].correspondence );
- FT_FREE( blend->avar_table->avar_segment );
- }
-
- tt_var_done_item_variation_store( face,
- &blend->avar_table->itemStore );
-
- tt_var_done_delta_set_index_map( face,
- &blend->avar_table->axisMap );
-
- FT_FREE( blend->avar_table );
- }
-
- if ( blend->hvar_table )
- {
- tt_var_done_item_variation_store( face,
- &blend->hvar_table->itemStore );
-
- tt_var_done_delta_set_index_map( face,
- &blend->hvar_table->widthMap );
- FT_FREE( blend->hvar_table );
- }
-
- if ( blend->vvar_table )
- {
- tt_var_done_item_variation_store( face,
- &blend->vvar_table->itemStore );
-
- tt_var_done_delta_set_index_map( face,
- &blend->vvar_table->widthMap );
- FT_FREE( blend->vvar_table );
- }
-
- if ( blend->mvar_table )
- {
- tt_var_done_item_variation_store( face,
- &blend->mvar_table->itemStore );
-
- FT_FREE( blend->mvar_table->values );
- FT_FREE( blend->mvar_table );
- }
-
- FT_FREE( blend->tuplecoords );
- FT_FREE( blend->glyphoffsets );
- FT_FREE( blend );
- }
- }
-
-#else /* !TT_CONFIG_OPTION_GX_VAR_SUPPORT */
-
- /* ANSI C doesn't like empty source files */
- typedef int tt_gxvar_dummy_;
-
-#endif /* !TT_CONFIG_OPTION_GX_VAR_SUPPORT */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/truetype/ttgxvar.h b/contrib/libs/freetype/src/truetype/ttgxvar.h
deleted file mode 100644
index 9326011e3a..0000000000
--- a/contrib/libs/freetype/src/truetype/ttgxvar.h
+++ /dev/null
@@ -1,453 +0,0 @@
-/****************************************************************************
- *
- * ttgxvar.h
- *
- * TrueType GX Font Variation loader (specification)
- *
- * Copyright (C) 2004-2024 by
- * David Turner, Robert Wilhelm, Werner Lemberg and George Williams.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef TTGXVAR_H_
-#define TTGXVAR_H_
-
-
-#include <freetype/internal/ftmmtypes.h>
-#include "ttobjs.h"
-
-
-FT_BEGIN_HEADER
-
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
-
- /**************************************************************************
- *
- * @Struct:
- * GX_AVarCorrespondenceRec
- *
- * @Description:
- * A data structure representing `shortFracCorrespondence' in `avar'
- * table according to the specifications from Apple.
- */
- typedef struct GX_AVarCorrespondenceRec_
- {
- FT_Fixed fromCoord;
- FT_Fixed toCoord;
-
- } GX_AVarCorrespondenceRec_, *GX_AVarCorrespondence;
-
-
- /**************************************************************************
- *
- * @Struct:
- * GX_AVarRec
- *
- * @Description:
- * Data from the segment field of `avar' table.
- * There is one of these for each axis.
- */
- typedef struct GX_AVarSegmentRec_
- {
- FT_UShort pairCount;
- GX_AVarCorrespondence correspondence; /* array with pairCount entries */
-
- } GX_AVarSegmentRec, *GX_AVarSegment;
-
-
- /**************************************************************************
- *
- * @Struct:
- * GX_AVarTableRec
- *
- * @Description:
- * Data from the `avar' table.
- */
- typedef struct GX_AVarTableRec_
- {
- GX_AVarSegment avar_segment; /* avar_segment[num_axis] */
- GX_ItemVarStoreRec itemStore; /* Item Variation Store */
- GX_DeltaSetIdxMapRec axisMap; /* Axis Mapping */
-
- } GX_AVarTableRec, *GX_AVarTable;
-
-
- /**************************************************************************
- *
- * @Struct:
- * GX_HVVarTableRec
- *
- * @Description:
- * Data from either the `HVAR' or `VVAR' table.
- */
- typedef struct GX_HVVarTableRec_
- {
- GX_ItemVarStoreRec itemStore; /* Item Variation Store */
- GX_DeltaSetIdxMapRec widthMap; /* Advance Width Mapping */
-
-#if 0
- GX_DeltaSetIdxMapRec lsbMap; /* not implemented */
- GX_DeltaSetIdxMapRec rsbMap; /* not implemented */
-
- GX_DeltaSetIdxMapRec tsbMap; /* not implemented */
- GX_DeltaSetIdxMapRec bsbMap; /* not implemented */
- GX_DeltaSetIdxMapRec vorgMap; /* not implemented */
-#endif
-
- } GX_HVVarTableRec, *GX_HVVarTable;
-
-
-#define MVAR_TAG_GASP_0 FT_MAKE_TAG( 'g', 's', 'p', '0' )
-#define MVAR_TAG_GASP_1 FT_MAKE_TAG( 'g', 's', 'p', '1' )
-#define MVAR_TAG_GASP_2 FT_MAKE_TAG( 'g', 's', 'p', '2' )
-#define MVAR_TAG_GASP_3 FT_MAKE_TAG( 'g', 's', 'p', '3' )
-#define MVAR_TAG_GASP_4 FT_MAKE_TAG( 'g', 's', 'p', '4' )
-#define MVAR_TAG_GASP_5 FT_MAKE_TAG( 'g', 's', 'p', '5' )
-#define MVAR_TAG_GASP_6 FT_MAKE_TAG( 'g', 's', 'p', '6' )
-#define MVAR_TAG_GASP_7 FT_MAKE_TAG( 'g', 's', 'p', '7' )
-#define MVAR_TAG_GASP_8 FT_MAKE_TAG( 'g', 's', 'p', '8' )
-#define MVAR_TAG_GASP_9 FT_MAKE_TAG( 'g', 's', 'p', '9' )
-
-#define MVAR_TAG_CPHT FT_MAKE_TAG( 'c', 'p', 'h', 't' )
-#define MVAR_TAG_HASC FT_MAKE_TAG( 'h', 'a', 's', 'c' )
-#define MVAR_TAG_HCLA FT_MAKE_TAG( 'h', 'c', 'l', 'a' )
-#define MVAR_TAG_HCLD FT_MAKE_TAG( 'h', 'c', 'l', 'd' )
-#define MVAR_TAG_HCOF FT_MAKE_TAG( 'h', 'c', 'o', 'f' )
-#define MVAR_TAG_HCRN FT_MAKE_TAG( 'h', 'c', 'r', 'n' )
-#define MVAR_TAG_HCRS FT_MAKE_TAG( 'h', 'c', 'r', 's' )
-#define MVAR_TAG_HDSC FT_MAKE_TAG( 'h', 'd', 's', 'c' )
-#define MVAR_TAG_HLGP FT_MAKE_TAG( 'h', 'l', 'g', 'p' )
-#define MVAR_TAG_SBXO FT_MAKE_TAG( 's', 'b', 'x', 'o' )
-#define MVAR_TAG_SBXS FT_MAKE_TAG( 's', 'b', 'x', 's' )
-#define MVAR_TAG_SBYO FT_MAKE_TAG( 's', 'b', 'y', 'o' )
-#define MVAR_TAG_SBYS FT_MAKE_TAG( 's', 'b', 'y', 's' )
-#define MVAR_TAG_SPXO FT_MAKE_TAG( 's', 'p', 'x', 'o' )
-#define MVAR_TAG_SPXS FT_MAKE_TAG( 's', 'p', 'x', 's' )
-#define MVAR_TAG_SPYO FT_MAKE_TAG( 's', 'p', 'y', 'o' )
-#define MVAR_TAG_SPYS FT_MAKE_TAG( 's', 'p', 'y', 's' )
-#define MVAR_TAG_STRO FT_MAKE_TAG( 's', 't', 'r', 'o' )
-#define MVAR_TAG_STRS FT_MAKE_TAG( 's', 't', 'r', 's' )
-#define MVAR_TAG_UNDO FT_MAKE_TAG( 'u', 'n', 'd', 'o' )
-#define MVAR_TAG_UNDS FT_MAKE_TAG( 'u', 'n', 'd', 's' )
-#define MVAR_TAG_VASC FT_MAKE_TAG( 'v', 'a', 's', 'c' )
-#define MVAR_TAG_VCOF FT_MAKE_TAG( 'v', 'c', 'o', 'f' )
-#define MVAR_TAG_VCRN FT_MAKE_TAG( 'v', 'c', 'r', 'n' )
-#define MVAR_TAG_VCRS FT_MAKE_TAG( 'v', 'c', 'r', 's' )
-#define MVAR_TAG_VDSC FT_MAKE_TAG( 'v', 'd', 's', 'c' )
-#define MVAR_TAG_VLGP FT_MAKE_TAG( 'v', 'l', 'g', 'p' )
-#define MVAR_TAG_XHGT FT_MAKE_TAG( 'x', 'h', 'g', 't' )
-
-
- typedef struct GX_ValueRec_
- {
- FT_ULong tag;
- FT_UShort outerIndex;
- FT_UShort innerIndex;
-
- FT_Short unmodified; /* values are either FT_Short or FT_UShort */
-
- } GX_ValueRec, *GX_Value;
-
-
- /**************************************************************************
- *
- * @Struct:
- * GX_MVarTableRec
- *
- * @Description:
- * Data from the `MVAR' table.
- */
- typedef struct GX_MVarTableRec_
- {
- FT_UShort valueCount;
-
- GX_ItemVarStoreRec itemStore; /* Item Variation Store */
- GX_Value values; /* Value Records */
-
- } GX_MVarTableRec, *GX_MVarTable;
-
-
- /**************************************************************************
- *
- * @Struct:
- * GX_BlendRec
- *
- * @Description:
- * Data for interpolating a font from a distortable font specified
- * by the GX *var tables ([fgcahvm]var).
- *
- * @Fields:
- * num_axis ::
- * The number of axes along which interpolation may happen.
- *
- * coords ::
- * An array of design coordinates (in user space) indicating the
- * contribution along each axis to the final interpolated font.
- * `normalizedcoords' holds the same values.
- *
- * normalizedcoords ::
- * An array of normalized values (between [-1,1]) indicating the
- * contribution along each axis to the final interpolated font.
- * `coords' holds the same values.
- *
- * mmvar ::
- * Data from the `fvar' table.
- *
- * mmvar_len ::
- * The length of the `mmvar' structure.
- *
- * normalized_stylecoords ::
- * A two-dimensional array that holds the named instance data from
- * `mmvar' as normalized values.
- *
- * avar_loaded ::
- * A Boolean; if set, FreeType tried to load (and parse) the `avar'
- * table.
- *
- * avar_table ::
- * Data from the `avar' table.
- *
- * hvar_loaded ::
- * A Boolean; if set, FreeType tried to load (and parse) the `hvar'
- * table.
- *
- * hvar_checked ::
- * A Boolean; if set, FreeType successfully loaded and parsed the
- * `hvar' table.
- *
- * hvar_error ::
- * If loading and parsing of the `hvar' table failed, this field
- * holds the corresponding error code.
- *
- * hvar_table ::
- * Data from the `hvar' table.
- *
- * vvar_loaded ::
- * A Boolean; if set, FreeType tried to load (and parse) the `vvar'
- * table.
- *
- * vvar_checked ::
- * A Boolean; if set, FreeType successfully loaded and parsed the
- * `vvar' table.
- *
- * vvar_error ::
- * If loading and parsing of the `vvar' table failed, this field
- * holds the corresponding error code.
- *
- * vvar_table ::
- * Data from the `vvar' table.
- *
- * mvar_table ::
- * Data from the `mvar' table.
- *
- * tuplecount ::
- * The number of shared tuples in the `gvar' table.
- *
- * tuplecoords ::
- * A two-dimensional array that holds the shared tuple coordinates
- * in the `gvar' table.
- *
- * gv_glyphcnt ::
- * The number of glyphs handled in the `gvar' table.
- *
- * glyphoffsets ::
- * Offsets into the glyph variation data array.
- *
- * gvar_size ::
- * The size of the `gvar' table.
- */
- typedef struct GX_BlendRec_
- {
- FT_UInt num_axis;
- FT_Fixed* coords;
- FT_Fixed* normalizedcoords;
-
- FT_MM_Var* mmvar;
- FT_Offset mmvar_len;
-
- FT_Fixed* normalized_stylecoords;
- /* normalized_stylecoords[num_namedstyles][num_axis] */
-
- FT_Bool avar_loaded;
- GX_AVarTable avar_table;
-
- FT_Bool hvar_loaded;
- FT_Bool hvar_checked;
- FT_Error hvar_error;
- GX_HVVarTable hvar_table;
-
- FT_Bool vvar_loaded;
- FT_Bool vvar_checked;
- FT_Error vvar_error;
- GX_HVVarTable vvar_table;
-
- GX_MVarTable mvar_table;
-
- FT_UInt tuplecount;
- FT_Fixed* tuplecoords; /* tuplecoords[tuplecount][num_axis] */
-
- FT_UInt gv_glyphcnt;
- FT_ULong* glyphoffsets; /* glyphoffsets[gv_glyphcnt + 1] */
-
- FT_ULong gvar_size;
-
- } GX_BlendRec;
-
-
- /**************************************************************************
- *
- * @enum:
- * GX_TupleCountFlags
- *
- * @Description:
- * Flags used within the `TupleCount' field of the `gvar' table.
- */
- typedef enum GX_TupleCountFlags_
- {
- GX_TC_TUPLES_SHARE_POINT_NUMBERS = 0x8000,
- GX_TC_RESERVED_TUPLE_FLAGS = 0x7000,
- GX_TC_TUPLE_COUNT_MASK = 0x0FFF
-
- } GX_TupleCountFlags;
-
-
- /**************************************************************************
- *
- * @enum:
- * GX_TupleIndexFlags
- *
- * @Description:
- * Flags used within the `TupleIndex' field of the `gvar' and `cvar'
- * tables.
- */
- typedef enum GX_TupleIndexFlags_
- {
- GX_TI_EMBEDDED_TUPLE_COORD = 0x8000,
- GX_TI_INTERMEDIATE_TUPLE = 0x4000,
- GX_TI_PRIVATE_POINT_NUMBERS = 0x2000,
- GX_TI_RESERVED_TUPLE_FLAG = 0x1000,
- GX_TI_TUPLE_INDEX_MASK = 0x0FFF
-
- } GX_TupleIndexFlags;
-
-
-#define TTAG_wght FT_MAKE_TAG( 'w', 'g', 'h', 't' )
-#define TTAG_wdth FT_MAKE_TAG( 'w', 'd', 't', 'h' )
-#define TTAG_opsz FT_MAKE_TAG( 'o', 'p', 's', 'z' )
-#define TTAG_slnt FT_MAKE_TAG( 's', 'l', 'n', 't' )
-#define TTAG_ital FT_MAKE_TAG( 'i', 't', 'a', 'l' )
-
-
- FT_LOCAL( FT_Error )
- TT_Set_MM_Blend( FT_Face face,
- FT_UInt num_coords,
- FT_Fixed* coords );
-
- FT_LOCAL( FT_Error )
- TT_Get_MM_Blend( FT_Face face,
- FT_UInt num_coords,
- FT_Fixed* coords );
-
- FT_LOCAL( FT_Error )
- TT_Set_Var_Design( FT_Face face,
- FT_UInt num_coords,
- FT_Fixed* coords );
-
- FT_LOCAL( FT_Error )
- TT_Get_MM_Var( FT_Face face,
- FT_MM_Var* *master );
-
- FT_LOCAL( FT_Error )
- TT_Get_Var_Design( FT_Face face,
- FT_UInt num_coords,
- FT_Fixed* coords );
-
- FT_LOCAL( FT_Error )
- TT_Set_Named_Instance( FT_Face face,
- FT_UInt instance_index );
-
- FT_LOCAL( FT_Error )
- TT_Get_Default_Named_Instance( FT_Face face,
- FT_UInt *instance_index );
-
- FT_LOCAL( void )
- tt_construct_ps_name( FT_Face face );
-
- FT_LOCAL( FT_Error )
- tt_face_vary_cvt( TT_Face face,
- FT_Stream stream );
-
-
- FT_LOCAL( FT_Error )
- TT_Vary_Apply_Glyph_Deltas( TT_Loader loader,
- FT_Outline* outline,
- FT_Vector* unrounded );
-
- FT_LOCAL( FT_Error )
- tt_hadvance_adjust( FT_Face face,
- FT_UInt gindex,
- FT_Int *adelta );
-
- FT_LOCAL( FT_Error )
- tt_vadvance_adjust( FT_Face face,
- FT_UInt gindex,
- FT_Int *adelta );
-
- FT_LOCAL( void )
- tt_apply_mvar( FT_Face face );
-
- FT_LOCAL( FT_Error )
- tt_var_load_item_variation_store( FT_Face face,
- FT_ULong offset,
- GX_ItemVarStore itemStore );
-
- FT_LOCAL( FT_Error )
- tt_var_load_delta_set_index_mapping( FT_Face face,
- FT_ULong offset,
- GX_DeltaSetIdxMap map,
- GX_ItemVarStore itemStore,
- FT_ULong table_len );
-
- FT_LOCAL( FT_ItemVarDelta )
- tt_var_get_item_delta( FT_Face face,
- GX_ItemVarStore itemStore,
- FT_UInt outerIndex,
- FT_UInt innerIndex );
-
- FT_LOCAL( void )
- tt_var_done_item_variation_store( FT_Face face,
- GX_ItemVarStore itemStore );
-
- FT_LOCAL( void )
- tt_var_done_delta_set_index_map( FT_Face face,
- GX_DeltaSetIdxMap deltaSetIdxMap );
-
-
- FT_LOCAL( FT_Error )
- tt_get_var_blend( FT_Face face,
- FT_UInt *num_coords,
- FT_Fixed* *coords,
- FT_Fixed* *normalizedcoords,
- FT_MM_Var* *mm_var );
-
- FT_LOCAL( void )
- tt_done_blend( FT_Face face );
-
-#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
-
-
-FT_END_HEADER
-
-
-#endif /* TTGXVAR_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/truetype/ttinterp.c b/contrib/libs/freetype/src/truetype/ttinterp.c
deleted file mode 100644
index 951891dbf5..0000000000
--- a/contrib/libs/freetype/src/truetype/ttinterp.c
+++ /dev/null
@@ -1,7751 +0,0 @@
-/****************************************************************************
- *
- * ttinterp.c
- *
- * TrueType bytecode interpreter (body).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-/* Greg Hitchcock from Microsoft has helped a lot in resolving unclear */
-/* issues; many thanks! */
-
-
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftcalc.h>
-#include <freetype/fttrigon.h>
-#include <freetype/ftsystem.h>
-#include <freetype/ftdriver.h>
-#include <freetype/ftmm.h>
-
-#include "ttinterp.h"
-#include "tterrors.h"
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
-#include "ttgxvar.h"
-#endif
-
-
-#ifdef TT_USE_BYTECODE_INTERPRETER
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT ttinterp
-
-
-#define NO_SUBPIXEL_HINTING \
- ( ((TT_Driver)FT_FACE_DRIVER( exc->face ))->interpreter_version == \
- TT_INTERPRETER_VERSION_35 )
-
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
-#define SUBPIXEL_HINTING_MINIMAL \
- ( ((TT_Driver)FT_FACE_DRIVER( exc->face ))->interpreter_version == \
- TT_INTERPRETER_VERSION_40 )
-#endif
-
-#define PROJECT( v1, v2 ) \
- exc->func_project( exc, \
- SUB_LONG( (v1)->x, (v2)->x ), \
- SUB_LONG( (v1)->y, (v2)->y ) )
-
-#define DUALPROJ( v1, v2 ) \
- exc->func_dualproj( exc, \
- SUB_LONG( (v1)->x, (v2)->x ), \
- SUB_LONG( (v1)->y, (v2)->y ) )
-
-#define FAST_PROJECT( v ) \
- exc->func_project( exc, (v)->x, (v)->y )
-
-#define FAST_DUALPROJ( v ) \
- exc->func_dualproj( exc, (v)->x, (v)->y )
-
-
- /**************************************************************************
- *
- * Two simple bounds-checking macros.
- */
-#define BOUNDS( x, n ) ( (FT_UInt)(x) >= (FT_UInt)(n) )
-#define BOUNDSL( x, n ) ( (FT_ULong)(x) >= (FT_ULong)(n) )
-
-
-#undef SUCCESS
-#define SUCCESS 0
-
-#undef FAILURE
-#define FAILURE 1
-
-
- /**************************************************************************
- *
- * CODERANGE FUNCTIONS
- *
- */
-
-
- /**************************************************************************
- *
- * @Function:
- * TT_Goto_CodeRange
- *
- * @Description:
- * Switches to a new code range (updates the code related elements in
- * `exec', and `IP').
- *
- * @Input:
- * range ::
- * The new execution code range.
- *
- * IP ::
- * The new IP in the new code range.
- *
- * @InOut:
- * exec ::
- * The target execution context.
- */
- FT_LOCAL_DEF( void )
- TT_Goto_CodeRange( TT_ExecContext exec,
- FT_Int range,
- FT_Long IP )
- {
- TT_CodeRange* coderange;
-
-
- FT_ASSERT( range >= 1 && range <= 3 );
-
- coderange = &exec->codeRangeTable[range - 1];
-
- FT_ASSERT( coderange->base );
-
- /* NOTE: Because the last instruction of a program may be a CALL */
- /* which will return to the first byte *after* the code */
- /* range, we test for IP <= Size instead of IP < Size. */
- /* */
- FT_ASSERT( IP <= coderange->size );
-
- exec->code = coderange->base;
- exec->codeSize = coderange->size;
- exec->IP = IP;
- exec->curRange = range;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * TT_Set_CodeRange
- *
- * @Description:
- * Sets a code range.
- *
- * @Input:
- * range ::
- * The code range index.
- *
- * base ::
- * The new code base.
- *
- * length ::
- * The range size in bytes.
- *
- * @InOut:
- * exec ::
- * The target execution context.
- */
- FT_LOCAL_DEF( void )
- TT_Set_CodeRange( TT_ExecContext exec,
- FT_Int range,
- void* base,
- FT_Long length )
- {
- FT_ASSERT( range >= 1 && range <= 3 );
-
- exec->codeRangeTable[range - 1].base = (FT_Byte*)base;
- exec->codeRangeTable[range - 1].size = length;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * TT_Clear_CodeRange
- *
- * @Description:
- * Clears a code range.
- *
- * @Input:
- * range ::
- * The code range index.
- *
- * @InOut:
- * exec ::
- * The target execution context.
- */
- FT_LOCAL_DEF( void )
- TT_Clear_CodeRange( TT_ExecContext exec,
- FT_Int range )
- {
- FT_ASSERT( range >= 1 && range <= 3 );
-
- exec->codeRangeTable[range - 1].base = NULL;
- exec->codeRangeTable[range - 1].size = 0;
- }
-
-
- /**************************************************************************
- *
- * EXECUTION CONTEXT ROUTINES
- *
- */
-
-
- /**************************************************************************
- *
- * @Function:
- * TT_Done_Context
- *
- * @Description:
- * Destroys a given context.
- *
- * @Input:
- * exec ::
- * A handle to the target execution context.
- *
- * memory ::
- * A handle to the parent memory object.
- *
- * @Note:
- * Only the glyph loader and debugger should call this function.
- */
- FT_LOCAL_DEF( void )
- TT_Done_Context( TT_ExecContext exec )
- {
- FT_Memory memory = exec->memory;
-
-
- /* points zone */
- exec->maxPoints = 0;
- exec->maxContours = 0;
-
- /* free stack */
- FT_FREE( exec->stack );
- exec->stackSize = 0;
-
- /* free glyf cvt working area */
- FT_FREE( exec->glyfCvt );
- exec->glyfCvtSize = 0;
-
- /* free glyf storage working area */
- FT_FREE( exec->glyfStorage );
- exec->glyfStoreSize = 0;
-
- /* free call stack */
- FT_FREE( exec->callStack );
- exec->callSize = 0;
- exec->callTop = 0;
-
- /* free glyph code range */
- FT_FREE( exec->glyphIns );
- exec->glyphSize = 0;
-
- exec->size = NULL;
- exec->face = NULL;
-
- FT_FREE( exec );
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * TT_Load_Context
- *
- * @Description:
- * Prepare an execution context for glyph hinting.
- *
- * @Input:
- * face ::
- * A handle to the source face object.
- *
- * size ::
- * A handle to the source size object.
- *
- * @InOut:
- * exec ::
- * A handle to the target execution context.
- *
- * @Return:
- * FreeType error code. 0 means success.
- *
- * @Note:
- * Only the glyph loader and debugger should call this function.
- *
- * Note that not all members of `TT_ExecContext` get initialized.
- */
- FT_LOCAL_DEF( FT_Error )
- TT_Load_Context( TT_ExecContext exec,
- TT_Face face,
- TT_Size size )
- {
- FT_Int i;
- TT_MaxProfile* maxp;
- FT_Error error;
- FT_Memory memory = exec->memory;
-
-
- exec->face = face;
- maxp = &face->max_profile;
- exec->size = size;
-
- if ( size )
- {
- exec->numFDefs = size->num_function_defs;
- exec->maxFDefs = size->max_function_defs;
- exec->numIDefs = size->num_instruction_defs;
- exec->maxIDefs = size->max_instruction_defs;
- exec->FDefs = size->function_defs;
- exec->IDefs = size->instruction_defs;
- exec->pointSize = size->point_size;
- exec->tt_metrics = size->ttmetrics;
- exec->metrics = *size->metrics;
-
- exec->maxFunc = size->max_func;
- exec->maxIns = size->max_ins;
-
- for ( i = 0; i < TT_MAX_CODE_RANGES; i++ )
- exec->codeRangeTable[i] = size->codeRangeTable[i];
-
- /* set graphics state */
- exec->GS = size->GS;
-
- exec->cvtSize = size->cvt_size;
- exec->cvt = size->cvt;
-
- exec->storeSize = size->storage_size;
- exec->storage = size->storage;
-
- exec->twilight = size->twilight;
-
- /* In case of multi-threading it can happen that the old size object */
- /* no longer exists, thus we must clear all glyph zone references. */
- FT_ZERO( &exec->zp0 );
- exec->zp1 = exec->zp0;
- exec->zp2 = exec->zp0;
- }
-
- /* XXX: We reserve a little more elements on the stack to deal safely */
- /* with broken fonts like arialbs, courbs, timesbs, etc. */
- if ( FT_QRENEW_ARRAY( exec->stack,
- exec->stackSize,
- maxp->maxStackElements + 32 ) )
- return error;
- exec->stackSize = maxp->maxStackElements + 32;
-
- /* free previous glyph code range */
- FT_FREE( exec->glyphIns );
- exec->glyphSize = 0;
-
- exec->pts.n_points = 0;
- exec->pts.n_contours = 0;
-
- exec->zp1 = exec->pts;
- exec->zp2 = exec->pts;
- exec->zp0 = exec->pts;
-
- exec->instruction_trap = FALSE;
-
- return FT_Err_Ok;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * TT_Save_Context
- *
- * @Description:
- * Saves the code ranges in a `size' object.
- *
- * @Input:
- * exec ::
- * A handle to the source execution context.
- *
- * @InOut:
- * size ::
- * A handle to the target size object.
- *
- * @Note:
- * Only the glyph loader and debugger should call this function.
- */
- FT_LOCAL_DEF( void )
- TT_Save_Context( TT_ExecContext exec,
- TT_Size size )
- {
- FT_Int i;
-
-
- /* XXX: Will probably disappear soon with all the code range */
- /* management, which is now rather obsolete. */
- /* */
- size->num_function_defs = exec->numFDefs;
- size->num_instruction_defs = exec->numIDefs;
-
- size->max_func = exec->maxFunc;
- size->max_ins = exec->maxIns;
-
- for ( i = 0; i < TT_MAX_CODE_RANGES; i++ )
- size->codeRangeTable[i] = exec->codeRangeTable[i];
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * TT_Run_Context
- *
- * @Description:
- * Executes one or more instructions in the execution context.
- *
- * @Input:
- * exec ::
- * A handle to the target execution context.
- *
- * @Return:
- * TrueType error code. 0 means success.
- */
- FT_LOCAL_DEF( FT_Error )
- TT_Run_Context( TT_ExecContext exec )
- {
- TT_Goto_CodeRange( exec, tt_coderange_glyph, 0 );
-
- exec->zp0 = exec->pts;
- exec->zp1 = exec->pts;
- exec->zp2 = exec->pts;
-
- exec->GS.gep0 = 1;
- exec->GS.gep1 = 1;
- exec->GS.gep2 = 1;
-
- exec->GS.projVector.x = 0x4000;
- exec->GS.projVector.y = 0x0000;
-
- exec->GS.freeVector = exec->GS.projVector;
- exec->GS.dualVector = exec->GS.projVector;
-
- exec->GS.round_state = 1;
- exec->GS.loop = 1;
-
- /* some glyphs leave something on the stack. so we clean it */
- /* before a new execution. */
- exec->top = 0;
- exec->callTop = 0;
-
- return exec->face->interpreter( exec );
- }
-
-
- /* The default value for `scan_control' is documented as FALSE in the */
- /* TrueType specification. This is confusing since it implies a */
- /* Boolean value. However, this is not the case, thus both the */
- /* default values of our `scan_type' and `scan_control' fields (which */
- /* the documentation's `scan_control' variable is split into) are */
- /* zero. */
-
- const TT_GraphicsState tt_default_graphics_state =
- {
- 0, 0, 0,
- { 0x4000, 0 },
- { 0x4000, 0 },
- { 0x4000, 0 },
-
- 1, 64, 1,
- TRUE, 68, 0, 0, 9, 3,
- 0, FALSE, 0, 1, 1, 1
- };
-
-
- /* documentation is in ttinterp.h */
-
- FT_EXPORT_DEF( TT_ExecContext )
- TT_New_Context( TT_Driver driver )
- {
- FT_Memory memory;
- FT_Error error;
-
- TT_ExecContext exec = NULL;
-
-
- if ( !driver )
- goto Fail;
-
- memory = driver->root.root.memory;
-
- /* allocate object and zero everything inside */
- if ( FT_NEW( exec ) )
- goto Fail;
-
- /* create callStack here, other allocations delayed */
- exec->memory = memory;
- exec->callSize = 32;
-
- if ( FT_QNEW_ARRAY( exec->callStack, exec->callSize ) )
- FT_FREE( exec );
-
- Fail:
- return exec;
- }
-
-
- /**************************************************************************
- *
- * Before an opcode is executed, the interpreter verifies that there are
- * enough arguments on the stack, with the help of the `Pop_Push_Count'
- * table.
- *
- * For each opcode, the first column gives the number of arguments that
- * are popped from the stack; the second one gives the number of those
- * that are pushed in result.
- *
- * Opcodes which have a varying number of parameters in the data stream
- * (NPUSHB, NPUSHW) are handled specially; they have a negative value in
- * the `opcode_length' table, and the value in `Pop_Push_Count' is set
- * to zero.
- *
- */
-
-
-#undef PACK
-#define PACK( x, y ) ( ( x << 4 ) | y )
-
-
- static
- const FT_Byte Pop_Push_Count[256] =
- {
- /* opcodes are gathered in groups of 16 */
- /* please keep the spaces as they are */
-
- /* 0x00 */
- /* SVTCA[0] */ PACK( 0, 0 ),
- /* SVTCA[1] */ PACK( 0, 0 ),
- /* SPVTCA[0] */ PACK( 0, 0 ),
- /* SPVTCA[1] */ PACK( 0, 0 ),
- /* SFVTCA[0] */ PACK( 0, 0 ),
- /* SFVTCA[1] */ PACK( 0, 0 ),
- /* SPVTL[0] */ PACK( 2, 0 ),
- /* SPVTL[1] */ PACK( 2, 0 ),
- /* SFVTL[0] */ PACK( 2, 0 ),
- /* SFVTL[1] */ PACK( 2, 0 ),
- /* SPVFS */ PACK( 2, 0 ),
- /* SFVFS */ PACK( 2, 0 ),
- /* GPV */ PACK( 0, 2 ),
- /* GFV */ PACK( 0, 2 ),
- /* SFVTPV */ PACK( 0, 0 ),
- /* ISECT */ PACK( 5, 0 ),
-
- /* 0x10 */
- /* SRP0 */ PACK( 1, 0 ),
- /* SRP1 */ PACK( 1, 0 ),
- /* SRP2 */ PACK( 1, 0 ),
- /* SZP0 */ PACK( 1, 0 ),
- /* SZP1 */ PACK( 1, 0 ),
- /* SZP2 */ PACK( 1, 0 ),
- /* SZPS */ PACK( 1, 0 ),
- /* SLOOP */ PACK( 1, 0 ),
- /* RTG */ PACK( 0, 0 ),
- /* RTHG */ PACK( 0, 0 ),
- /* SMD */ PACK( 1, 0 ),
- /* ELSE */ PACK( 0, 0 ),
- /* JMPR */ PACK( 1, 0 ),
- /* SCVTCI */ PACK( 1, 0 ),
- /* SSWCI */ PACK( 1, 0 ),
- /* SSW */ PACK( 1, 0 ),
-
- /* 0x20 */
- /* DUP */ PACK( 1, 2 ),
- /* POP */ PACK( 1, 0 ),
- /* CLEAR */ PACK( 0, 0 ),
- /* SWAP */ PACK( 2, 2 ),
- /* DEPTH */ PACK( 0, 1 ),
- /* CINDEX */ PACK( 1, 1 ),
- /* MINDEX */ PACK( 1, 0 ),
- /* ALIGNPTS */ PACK( 2, 0 ),
- /* INS_$28 */ PACK( 0, 0 ),
- /* UTP */ PACK( 1, 0 ),
- /* LOOPCALL */ PACK( 2, 0 ),
- /* CALL */ PACK( 1, 0 ),
- /* FDEF */ PACK( 1, 0 ),
- /* ENDF */ PACK( 0, 0 ),
- /* MDAP[0] */ PACK( 1, 0 ),
- /* MDAP[1] */ PACK( 1, 0 ),
-
- /* 0x30 */
- /* IUP[0] */ PACK( 0, 0 ),
- /* IUP[1] */ PACK( 0, 0 ),
- /* SHP[0] */ PACK( 0, 0 ), /* loops */
- /* SHP[1] */ PACK( 0, 0 ), /* loops */
- /* SHC[0] */ PACK( 1, 0 ),
- /* SHC[1] */ PACK( 1, 0 ),
- /* SHZ[0] */ PACK( 1, 0 ),
- /* SHZ[1] */ PACK( 1, 0 ),
- /* SHPIX */ PACK( 1, 0 ), /* loops */
- /* IP */ PACK( 0, 0 ), /* loops */
- /* MSIRP[0] */ PACK( 2, 0 ),
- /* MSIRP[1] */ PACK( 2, 0 ),
- /* ALIGNRP */ PACK( 0, 0 ), /* loops */
- /* RTDG */ PACK( 0, 0 ),
- /* MIAP[0] */ PACK( 2, 0 ),
- /* MIAP[1] */ PACK( 2, 0 ),
-
- /* 0x40 */
- /* NPUSHB */ PACK( 0, 0 ),
- /* NPUSHW */ PACK( 0, 0 ),
- /* WS */ PACK( 2, 0 ),
- /* RS */ PACK( 1, 1 ),
- /* WCVTP */ PACK( 2, 0 ),
- /* RCVT */ PACK( 1, 1 ),
- /* GC[0] */ PACK( 1, 1 ),
- /* GC[1] */ PACK( 1, 1 ),
- /* SCFS */ PACK( 2, 0 ),
- /* MD[0] */ PACK( 2, 1 ),
- /* MD[1] */ PACK( 2, 1 ),
- /* MPPEM */ PACK( 0, 1 ),
- /* MPS */ PACK( 0, 1 ),
- /* FLIPON */ PACK( 0, 0 ),
- /* FLIPOFF */ PACK( 0, 0 ),
- /* DEBUG */ PACK( 1, 0 ),
-
- /* 0x50 */
- /* LT */ PACK( 2, 1 ),
- /* LTEQ */ PACK( 2, 1 ),
- /* GT */ PACK( 2, 1 ),
- /* GTEQ */ PACK( 2, 1 ),
- /* EQ */ PACK( 2, 1 ),
- /* NEQ */ PACK( 2, 1 ),
- /* ODD */ PACK( 1, 1 ),
- /* EVEN */ PACK( 1, 1 ),
- /* IF */ PACK( 1, 0 ),
- /* EIF */ PACK( 0, 0 ),
- /* AND */ PACK( 2, 1 ),
- /* OR */ PACK( 2, 1 ),
- /* NOT */ PACK( 1, 1 ),
- /* DELTAP1 */ PACK( 1, 0 ),
- /* SDB */ PACK( 1, 0 ),
- /* SDS */ PACK( 1, 0 ),
-
- /* 0x60 */
- /* ADD */ PACK( 2, 1 ),
- /* SUB */ PACK( 2, 1 ),
- /* DIV */ PACK( 2, 1 ),
- /* MUL */ PACK( 2, 1 ),
- /* ABS */ PACK( 1, 1 ),
- /* NEG */ PACK( 1, 1 ),
- /* FLOOR */ PACK( 1, 1 ),
- /* CEILING */ PACK( 1, 1 ),
- /* ROUND[0] */ PACK( 1, 1 ),
- /* ROUND[1] */ PACK( 1, 1 ),
- /* ROUND[2] */ PACK( 1, 1 ),
- /* ROUND[3] */ PACK( 1, 1 ),
- /* NROUND[0] */ PACK( 1, 1 ),
- /* NROUND[1] */ PACK( 1, 1 ),
- /* NROUND[2] */ PACK( 1, 1 ),
- /* NROUND[3] */ PACK( 1, 1 ),
-
- /* 0x70 */
- /* WCVTF */ PACK( 2, 0 ),
- /* DELTAP2 */ PACK( 1, 0 ),
- /* DELTAP3 */ PACK( 1, 0 ),
- /* DELTAC1 */ PACK( 1, 0 ),
- /* DELTAC2 */ PACK( 1, 0 ),
- /* DELTAC3 */ PACK( 1, 0 ),
- /* SROUND */ PACK( 1, 0 ),
- /* S45ROUND */ PACK( 1, 0 ),
- /* JROT */ PACK( 2, 0 ),
- /* JROF */ PACK( 2, 0 ),
- /* ROFF */ PACK( 0, 0 ),
- /* INS_$7B */ PACK( 0, 0 ),
- /* RUTG */ PACK( 0, 0 ),
- /* RDTG */ PACK( 0, 0 ),
- /* SANGW */ PACK( 1, 0 ),
- /* AA */ PACK( 1, 0 ),
-
- /* 0x80 */
- /* FLIPPT */ PACK( 0, 0 ), /* loops */
- /* FLIPRGON */ PACK( 2, 0 ),
- /* FLIPRGOFF */ PACK( 2, 0 ),
- /* INS_$83 */ PACK( 0, 0 ),
- /* INS_$84 */ PACK( 0, 0 ),
- /* SCANCTRL */ PACK( 1, 0 ),
- /* SDPVTL[0] */ PACK( 2, 0 ),
- /* SDPVTL[1] */ PACK( 2, 0 ),
- /* GETINFO */ PACK( 1, 1 ),
- /* IDEF */ PACK( 1, 0 ),
- /* ROLL */ PACK( 3, 3 ),
- /* MAX */ PACK( 2, 1 ),
- /* MIN */ PACK( 2, 1 ),
- /* SCANTYPE */ PACK( 1, 0 ),
- /* INSTCTRL */ PACK( 2, 0 ),
- /* INS_$8F */ PACK( 0, 0 ),
-
- /* 0x90 */
- /* INS_$90 */ PACK( 0, 0 ),
- /* GETVAR */ PACK( 0, 0 ), /* will be handled specially */
- /* GETDATA */ PACK( 0, 1 ),
- /* INS_$93 */ PACK( 0, 0 ),
- /* INS_$94 */ PACK( 0, 0 ),
- /* INS_$95 */ PACK( 0, 0 ),
- /* INS_$96 */ PACK( 0, 0 ),
- /* INS_$97 */ PACK( 0, 0 ),
- /* INS_$98 */ PACK( 0, 0 ),
- /* INS_$99 */ PACK( 0, 0 ),
- /* INS_$9A */ PACK( 0, 0 ),
- /* INS_$9B */ PACK( 0, 0 ),
- /* INS_$9C */ PACK( 0, 0 ),
- /* INS_$9D */ PACK( 0, 0 ),
- /* INS_$9E */ PACK( 0, 0 ),
- /* INS_$9F */ PACK( 0, 0 ),
-
- /* 0xA0 */
- /* INS_$A0 */ PACK( 0, 0 ),
- /* INS_$A1 */ PACK( 0, 0 ),
- /* INS_$A2 */ PACK( 0, 0 ),
- /* INS_$A3 */ PACK( 0, 0 ),
- /* INS_$A4 */ PACK( 0, 0 ),
- /* INS_$A5 */ PACK( 0, 0 ),
- /* INS_$A6 */ PACK( 0, 0 ),
- /* INS_$A7 */ PACK( 0, 0 ),
- /* INS_$A8 */ PACK( 0, 0 ),
- /* INS_$A9 */ PACK( 0, 0 ),
- /* INS_$AA */ PACK( 0, 0 ),
- /* INS_$AB */ PACK( 0, 0 ),
- /* INS_$AC */ PACK( 0, 0 ),
- /* INS_$AD */ PACK( 0, 0 ),
- /* INS_$AE */ PACK( 0, 0 ),
- /* INS_$AF */ PACK( 0, 0 ),
-
- /* 0xB0 */
- /* PUSHB[0] */ PACK( 0, 1 ),
- /* PUSHB[1] */ PACK( 0, 2 ),
- /* PUSHB[2] */ PACK( 0, 3 ),
- /* PUSHB[3] */ PACK( 0, 4 ),
- /* PUSHB[4] */ PACK( 0, 5 ),
- /* PUSHB[5] */ PACK( 0, 6 ),
- /* PUSHB[6] */ PACK( 0, 7 ),
- /* PUSHB[7] */ PACK( 0, 8 ),
- /* PUSHW[0] */ PACK( 0, 1 ),
- /* PUSHW[1] */ PACK( 0, 2 ),
- /* PUSHW[2] */ PACK( 0, 3 ),
- /* PUSHW[3] */ PACK( 0, 4 ),
- /* PUSHW[4] */ PACK( 0, 5 ),
- /* PUSHW[5] */ PACK( 0, 6 ),
- /* PUSHW[6] */ PACK( 0, 7 ),
- /* PUSHW[7] */ PACK( 0, 8 ),
-
- /* 0xC0 */
- /* MDRP[00] */ PACK( 1, 0 ),
- /* MDRP[01] */ PACK( 1, 0 ),
- /* MDRP[02] */ PACK( 1, 0 ),
- /* MDRP[03] */ PACK( 1, 0 ),
- /* MDRP[04] */ PACK( 1, 0 ),
- /* MDRP[05] */ PACK( 1, 0 ),
- /* MDRP[06] */ PACK( 1, 0 ),
- /* MDRP[07] */ PACK( 1, 0 ),
- /* MDRP[08] */ PACK( 1, 0 ),
- /* MDRP[09] */ PACK( 1, 0 ),
- /* MDRP[10] */ PACK( 1, 0 ),
- /* MDRP[11] */ PACK( 1, 0 ),
- /* MDRP[12] */ PACK( 1, 0 ),
- /* MDRP[13] */ PACK( 1, 0 ),
- /* MDRP[14] */ PACK( 1, 0 ),
- /* MDRP[15] */ PACK( 1, 0 ),
-
- /* 0xD0 */
- /* MDRP[16] */ PACK( 1, 0 ),
- /* MDRP[17] */ PACK( 1, 0 ),
- /* MDRP[18] */ PACK( 1, 0 ),
- /* MDRP[19] */ PACK( 1, 0 ),
- /* MDRP[20] */ PACK( 1, 0 ),
- /* MDRP[21] */ PACK( 1, 0 ),
- /* MDRP[22] */ PACK( 1, 0 ),
- /* MDRP[23] */ PACK( 1, 0 ),
- /* MDRP[24] */ PACK( 1, 0 ),
- /* MDRP[25] */ PACK( 1, 0 ),
- /* MDRP[26] */ PACK( 1, 0 ),
- /* MDRP[27] */ PACK( 1, 0 ),
- /* MDRP[28] */ PACK( 1, 0 ),
- /* MDRP[29] */ PACK( 1, 0 ),
- /* MDRP[30] */ PACK( 1, 0 ),
- /* MDRP[31] */ PACK( 1, 0 ),
-
- /* 0xE0 */
- /* MIRP[00] */ PACK( 2, 0 ),
- /* MIRP[01] */ PACK( 2, 0 ),
- /* MIRP[02] */ PACK( 2, 0 ),
- /* MIRP[03] */ PACK( 2, 0 ),
- /* MIRP[04] */ PACK( 2, 0 ),
- /* MIRP[05] */ PACK( 2, 0 ),
- /* MIRP[06] */ PACK( 2, 0 ),
- /* MIRP[07] */ PACK( 2, 0 ),
- /* MIRP[08] */ PACK( 2, 0 ),
- /* MIRP[09] */ PACK( 2, 0 ),
- /* MIRP[10] */ PACK( 2, 0 ),
- /* MIRP[11] */ PACK( 2, 0 ),
- /* MIRP[12] */ PACK( 2, 0 ),
- /* MIRP[13] */ PACK( 2, 0 ),
- /* MIRP[14] */ PACK( 2, 0 ),
- /* MIRP[15] */ PACK( 2, 0 ),
-
- /* 0xF0 */
- /* MIRP[16] */ PACK( 2, 0 ),
- /* MIRP[17] */ PACK( 2, 0 ),
- /* MIRP[18] */ PACK( 2, 0 ),
- /* MIRP[19] */ PACK( 2, 0 ),
- /* MIRP[20] */ PACK( 2, 0 ),
- /* MIRP[21] */ PACK( 2, 0 ),
- /* MIRP[22] */ PACK( 2, 0 ),
- /* MIRP[23] */ PACK( 2, 0 ),
- /* MIRP[24] */ PACK( 2, 0 ),
- /* MIRP[25] */ PACK( 2, 0 ),
- /* MIRP[26] */ PACK( 2, 0 ),
- /* MIRP[27] */ PACK( 2, 0 ),
- /* MIRP[28] */ PACK( 2, 0 ),
- /* MIRP[29] */ PACK( 2, 0 ),
- /* MIRP[30] */ PACK( 2, 0 ),
- /* MIRP[31] */ PACK( 2, 0 )
- };
-
-
-#ifdef FT_DEBUG_LEVEL_TRACE
-
- /* the first hex digit gives the length of the opcode name; the space */
- /* after the digit is here just to increase readability of the source */
- /* code */
-
- static
- const char* const opcode_name[256] =
- {
- /* 0x00 */
- "8 SVTCA[y]",
- "8 SVTCA[x]",
- "9 SPVTCA[y]",
- "9 SPVTCA[x]",
- "9 SFVTCA[y]",
- "9 SFVTCA[x]",
- "9 SPVTL[||]",
- "8 SPVTL[+]",
- "9 SFVTL[||]",
- "8 SFVTL[+]",
- "5 SPVFS",
- "5 SFVFS",
- "3 GPV",
- "3 GFV",
- "6 SFVTPV",
- "5 ISECT",
-
- /* 0x10 */
- "4 SRP0",
- "4 SRP1",
- "4 SRP2",
- "4 SZP0",
- "4 SZP1",
- "4 SZP2",
- "4 SZPS",
- "5 SLOOP",
- "3 RTG",
- "4 RTHG",
- "3 SMD",
- "4 ELSE",
- "4 JMPR",
- "6 SCVTCI",
- "5 SSWCI",
- "3 SSW",
-
- /* 0x20 */
- "3 DUP",
- "3 POP",
- "5 CLEAR",
- "4 SWAP",
- "5 DEPTH",
- "6 CINDEX",
- "6 MINDEX",
- "8 ALIGNPTS",
- "7 INS_$28",
- "3 UTP",
- "8 LOOPCALL",
- "4 CALL",
- "4 FDEF",
- "4 ENDF",
- "6 MDAP[]",
- "9 MDAP[rnd]",
-
- /* 0x30 */
- "6 IUP[y]",
- "6 IUP[x]",
- "8 SHP[rp2]",
- "8 SHP[rp1]",
- "8 SHC[rp2]",
- "8 SHC[rp1]",
- "8 SHZ[rp2]",
- "8 SHZ[rp1]",
- "5 SHPIX",
- "2 IP",
- "7 MSIRP[]",
- "A MSIRP[rp0]",
- "7 ALIGNRP",
- "4 RTDG",
- "6 MIAP[]",
- "9 MIAP[rnd]",
-
- /* 0x40 */
- "6 NPUSHB",
- "6 NPUSHW",
- "2 WS",
- "2 RS",
- "5 WCVTP",
- "4 RCVT",
- "8 GC[curr]",
- "8 GC[orig]",
- "4 SCFS",
- "8 MD[curr]",
- "8 MD[orig]",
- "5 MPPEM",
- "3 MPS",
- "6 FLIPON",
- "7 FLIPOFF",
- "5 DEBUG",
-
- /* 0x50 */
- "2 LT",
- "4 LTEQ",
- "2 GT",
- "4 GTEQ",
- "2 EQ",
- "3 NEQ",
- "3 ODD",
- "4 EVEN",
- "2 IF",
- "3 EIF",
- "3 AND",
- "2 OR",
- "3 NOT",
- "7 DELTAP1",
- "3 SDB",
- "3 SDS",
-
- /* 0x60 */
- "3 ADD",
- "3 SUB",
- "3 DIV",
- "3 MUL",
- "3 ABS",
- "3 NEG",
- "5 FLOOR",
- "7 CEILING",
- "8 ROUND[G]",
- "8 ROUND[B]",
- "8 ROUND[W]",
- "7 ROUND[]",
- "9 NROUND[G]",
- "9 NROUND[B]",
- "9 NROUND[W]",
- "8 NROUND[]",
-
- /* 0x70 */
- "5 WCVTF",
- "7 DELTAP2",
- "7 DELTAP3",
- "7 DELTAC1",
- "7 DELTAC2",
- "7 DELTAC3",
- "6 SROUND",
- "8 S45ROUND",
- "4 JROT",
- "4 JROF",
- "4 ROFF",
- "7 INS_$7B",
- "4 RUTG",
- "4 RDTG",
- "5 SANGW",
- "2 AA",
-
- /* 0x80 */
- "6 FLIPPT",
- "8 FLIPRGON",
- "9 FLIPRGOFF",
- "7 INS_$83",
- "7 INS_$84",
- "8 SCANCTRL",
- "A SDPVTL[||]",
- "9 SDPVTL[+]",
- "7 GETINFO",
- "4 IDEF",
- "4 ROLL",
- "3 MAX",
- "3 MIN",
- "8 SCANTYPE",
- "8 INSTCTRL",
- "7 INS_$8F",
-
- /* 0x90 */
- "7 INS_$90",
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- "C GETVARIATION",
- "7 GETDATA",
-#else
- "7 INS_$91",
- "7 INS_$92",
-#endif
- "7 INS_$93",
- "7 INS_$94",
- "7 INS_$95",
- "7 INS_$96",
- "7 INS_$97",
- "7 INS_$98",
- "7 INS_$99",
- "7 INS_$9A",
- "7 INS_$9B",
- "7 INS_$9C",
- "7 INS_$9D",
- "7 INS_$9E",
- "7 INS_$9F",
-
- /* 0xA0 */
- "7 INS_$A0",
- "7 INS_$A1",
- "7 INS_$A2",
- "7 INS_$A3",
- "7 INS_$A4",
- "7 INS_$A5",
- "7 INS_$A6",
- "7 INS_$A7",
- "7 INS_$A8",
- "7 INS_$A9",
- "7 INS_$AA",
- "7 INS_$AB",
- "7 INS_$AC",
- "7 INS_$AD",
- "7 INS_$AE",
- "7 INS_$AF",
-
- /* 0xB0 */
- "8 PUSHB[0]",
- "8 PUSHB[1]",
- "8 PUSHB[2]",
- "8 PUSHB[3]",
- "8 PUSHB[4]",
- "8 PUSHB[5]",
- "8 PUSHB[6]",
- "8 PUSHB[7]",
- "8 PUSHW[0]",
- "8 PUSHW[1]",
- "8 PUSHW[2]",
- "8 PUSHW[3]",
- "8 PUSHW[4]",
- "8 PUSHW[5]",
- "8 PUSHW[6]",
- "8 PUSHW[7]",
-
- /* 0xC0 */
- "7 MDRP[G]",
- "7 MDRP[B]",
- "7 MDRP[W]",
- "6 MDRP[]",
- "8 MDRP[rG]",
- "8 MDRP[rB]",
- "8 MDRP[rW]",
- "7 MDRP[r]",
- "8 MDRP[mG]",
- "8 MDRP[mB]",
- "8 MDRP[mW]",
- "7 MDRP[m]",
- "9 MDRP[mrG]",
- "9 MDRP[mrB]",
- "9 MDRP[mrW]",
- "8 MDRP[mr]",
-
- /* 0xD0 */
- "8 MDRP[pG]",
- "8 MDRP[pB]",
- "8 MDRP[pW]",
- "7 MDRP[p]",
- "9 MDRP[prG]",
- "9 MDRP[prB]",
- "9 MDRP[prW]",
- "8 MDRP[pr]",
- "9 MDRP[pmG]",
- "9 MDRP[pmB]",
- "9 MDRP[pmW]",
- "8 MDRP[pm]",
- "A MDRP[pmrG]",
- "A MDRP[pmrB]",
- "A MDRP[pmrW]",
- "9 MDRP[pmr]",
-
- /* 0xE0 */
- "7 MIRP[G]",
- "7 MIRP[B]",
- "7 MIRP[W]",
- "6 MIRP[]",
- "8 MIRP[rG]",
- "8 MIRP[rB]",
- "8 MIRP[rW]",
- "7 MIRP[r]",
- "8 MIRP[mG]",
- "8 MIRP[mB]",
- "8 MIRP[mW]",
- "7 MIRP[m]",
- "9 MIRP[mrG]",
- "9 MIRP[mrB]",
- "9 MIRP[mrW]",
- "8 MIRP[mr]",
-
- /* 0xF0 */
- "8 MIRP[pG]",
- "8 MIRP[pB]",
- "8 MIRP[pW]",
- "7 MIRP[p]",
- "9 MIRP[prG]",
- "9 MIRP[prB]",
- "9 MIRP[prW]",
- "8 MIRP[pr]",
- "9 MIRP[pmG]",
- "9 MIRP[pmB]",
- "9 MIRP[pmW]",
- "8 MIRP[pm]",
- "A MIRP[pmrG]",
- "A MIRP[pmrB]",
- "A MIRP[pmrW]",
- "9 MIRP[pmr]"
- };
-
-#endif /* FT_DEBUG_LEVEL_TRACE */
-
-
- static
- const FT_Char opcode_length[256] =
- {
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-
- -1,-2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 2, 3, 4, 5, 6, 7, 8, 9, 3, 5, 7, 9, 11,13,15,17,
-
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
- };
-
-#undef PACK
-
-
-#ifndef FT_CONFIG_OPTION_NO_ASSEMBLER
-
-#if defined( __arm__ ) && \
- ( defined( __thumb2__ ) || !defined( __thumb__ ) )
-
-#define TT_MulFix14 TT_MulFix14_arm
-
- static FT_Int32
- TT_MulFix14_arm( FT_Int32 a,
- FT_Int b )
- {
- FT_Int32 t, t2;
-
-
-#if defined( __CC_ARM ) || defined( __ARMCC__ )
-
- __asm
- {
- smull t2, t, b, a /* (lo=t2,hi=t) = a*b */
- mov a, t, asr #31 /* a = (hi >> 31) */
- add a, a, #0x2000 /* a += 0x2000 */
- adds t2, t2, a /* t2 += a */
- adc t, t, #0 /* t += carry */
- mov a, t2, lsr #14 /* a = t2 >> 14 */
- orr a, a, t, lsl #18 /* a |= t << 18 */
- }
-
-#elif defined( __GNUC__ )
-
- __asm__ __volatile__ (
- "smull %1, %2, %4, %3\n\t" /* (lo=%1,hi=%2) = a*b */
- "mov %0, %2, asr #31\n\t" /* %0 = (hi >> 31) */
-#if defined( __clang__ ) && defined( __thumb2__ )
- "add.w %0, %0, #0x2000\n\t" /* %0 += 0x2000 */
-#else
- "add %0, %0, #0x2000\n\t" /* %0 += 0x2000 */
-#endif
- "adds %1, %1, %0\n\t" /* %1 += %0 */
- "adc %2, %2, #0\n\t" /* %2 += carry */
- "mov %0, %1, lsr #14\n\t" /* %0 = %1 >> 16 */
- "orr %0, %0, %2, lsl #18\n\t" /* %0 |= %2 << 16 */
- : "=r"(a), "=&r"(t2), "=&r"(t)
- : "r"(a), "r"(b)
- : "cc" );
-
-#endif
-
- return a;
- }
-
-#endif /* __arm__ && ( __thumb2__ || !__thumb__ ) */
-
-#endif /* !FT_CONFIG_OPTION_NO_ASSEMBLER */
-
-
-#if defined( __GNUC__ ) && \
- ( defined( __i386__ ) || defined( __x86_64__ ) )
-
-#define TT_MulFix14 TT_MulFix14_long_long
-
- /* Temporarily disable the warning that C90 doesn't support `long long'. */
-#if ( __GNUC__ * 100 + __GNUC_MINOR__ ) >= 406
-#pragma GCC diagnostic push
-#endif
-#pragma GCC diagnostic ignored "-Wlong-long"
-
- /* This is declared `noinline' because inlining the function results */
- /* in slower code. The `pure' attribute indicates that the result */
- /* only depends on the parameters. */
- static __attribute__(( noinline ))
- __attribute__(( pure )) FT_Int32
- TT_MulFix14_long_long( FT_Int32 a,
- FT_Int b )
- {
-
- long long ret = (long long)a * b;
-
- /* The following line assumes that right shifting of signed values */
- /* will actually preserve the sign bit. The exact behaviour is */
- /* undefined, but this is true on x86 and x86_64. */
- long long tmp = ret >> 63;
-
-
- ret += 0x2000 + tmp;
-
- return (FT_Int32)( ret >> 14 );
- }
-
-#if ( __GNUC__ * 100 + __GNUC_MINOR__ ) >= 406
-#pragma GCC diagnostic pop
-#endif
-
-#endif /* __GNUC__ && ( __i386__ || __x86_64__ ) */
-
-
-#ifndef TT_MulFix14
-
- /* Compute (a*b)/2^14 with maximum accuracy and rounding. */
- /* This is optimized to be faster than calling FT_MulFix() */
- /* for platforms where sizeof(int) == 2. */
- static FT_Int32
- TT_MulFix14( FT_Int32 a,
- FT_Int b )
- {
- FT_Int32 sign;
- FT_UInt32 ah, al, mid, lo, hi;
-
-
- sign = a ^ b;
-
- if ( a < 0 )
- a = -a;
- if ( b < 0 )
- b = -b;
-
- ah = (FT_UInt32)( ( a >> 16 ) & 0xFFFFU );
- al = (FT_UInt32)( a & 0xFFFFU );
-
- lo = al * b;
- mid = ah * b;
- hi = mid >> 16;
- mid = ( mid << 16 ) + ( 1 << 13 ); /* rounding */
- lo += mid;
- if ( lo < mid )
- hi += 1;
-
- mid = ( lo >> 14 ) | ( hi << 18 );
-
- return sign >= 0 ? (FT_Int32)mid : -(FT_Int32)mid;
- }
-
-#endif /* !TT_MulFix14 */
-
-
-#if defined( __GNUC__ ) && \
- ( defined( __i386__ ) || \
- defined( __x86_64__ ) || \
- defined( __arm__ ) )
-
-#define TT_DotFix14 TT_DotFix14_long_long
-
-#if ( __GNUC__ * 100 + __GNUC_MINOR__ ) >= 406
-#pragma GCC diagnostic push
-#endif
-#pragma GCC diagnostic ignored "-Wlong-long"
-
- static __attribute__(( pure )) FT_Int32
- TT_DotFix14_long_long( FT_Int32 ax,
- FT_Int32 ay,
- FT_Int bx,
- FT_Int by )
- {
- /* Temporarily disable the warning that C90 doesn't support */
- /* `long long'. */
-
- long long temp1 = (long long)ax * bx;
- long long temp2 = (long long)ay * by;
-
-
- temp1 += temp2;
- temp2 = temp1 >> 63;
- temp1 += 0x2000 + temp2;
-
- return (FT_Int32)( temp1 >> 14 );
-
- }
-
-#if ( __GNUC__ * 100 + __GNUC_MINOR__ ) >= 406
-#pragma GCC diagnostic pop
-#endif
-
-#endif /* __GNUC__ && (__arm__ || __i386__ || __x86_64__) */
-
-
-#ifndef TT_DotFix14
-
- /* compute (ax*bx+ay*by)/2^14 with maximum accuracy and rounding */
- static FT_Int32
- TT_DotFix14( FT_Int32 ax,
- FT_Int32 ay,
- FT_Int bx,
- FT_Int by )
- {
- FT_Int32 m, s, hi1, hi2, hi;
- FT_UInt32 l, lo1, lo2, lo;
-
-
- /* compute ax*bx as 64-bit value */
- l = (FT_UInt32)( ( ax & 0xFFFFU ) * bx );
- m = ( ax >> 16 ) * bx;
-
- lo1 = l + ( (FT_UInt32)m << 16 );
- hi1 = ( m >> 16 ) + ( (FT_Int32)l >> 31 ) + ( lo1 < l );
-
- /* compute ay*by as 64-bit value */
- l = (FT_UInt32)( ( ay & 0xFFFFU ) * by );
- m = ( ay >> 16 ) * by;
-
- lo2 = l + ( (FT_UInt32)m << 16 );
- hi2 = ( m >> 16 ) + ( (FT_Int32)l >> 31 ) + ( lo2 < l );
-
- /* add them */
- lo = lo1 + lo2;
- hi = hi1 + hi2 + ( lo < lo1 );
-
- /* divide the result by 2^14 with rounding */
- s = hi >> 31;
- l = lo + (FT_UInt32)s;
- hi += s + ( l < lo );
- lo = l;
-
- l = lo + 0x2000U;
- hi += ( l < lo );
-
- return (FT_Int32)( ( (FT_UInt32)hi << 18 ) | ( l >> 14 ) );
- }
-
-#endif /* TT_DotFix14 */
-
-
- /**************************************************************************
- *
- * @Function:
- * Current_Ratio
- *
- * @Description:
- * Returns the current aspect ratio scaling factor depending on the
- * projection vector's state and device resolutions.
- *
- * @Return:
- * The aspect ratio in 16.16 format, always <= 1.0 .
- */
- static FT_Long
- Current_Ratio( TT_ExecContext exc )
- {
- if ( !exc->tt_metrics.ratio )
- {
- if ( exc->GS.projVector.y == 0 )
- exc->tt_metrics.ratio = exc->tt_metrics.x_ratio;
-
- else if ( exc->GS.projVector.x == 0 )
- exc->tt_metrics.ratio = exc->tt_metrics.y_ratio;
-
- else
- {
- FT_F26Dot6 x, y;
-
-
- x = TT_MulFix14( exc->tt_metrics.x_ratio,
- exc->GS.projVector.x );
- y = TT_MulFix14( exc->tt_metrics.y_ratio,
- exc->GS.projVector.y );
- exc->tt_metrics.ratio = FT_Hypot( x, y );
- }
- }
- return exc->tt_metrics.ratio;
- }
-
-
- FT_CALLBACK_DEF( FT_Long )
- Current_Ppem( TT_ExecContext exc )
- {
- return exc->tt_metrics.ppem;
- }
-
-
- FT_CALLBACK_DEF( FT_Long )
- Current_Ppem_Stretched( TT_ExecContext exc )
- {
- return FT_MulFix( exc->tt_metrics.ppem, Current_Ratio( exc ) );
- }
-
-
- /**************************************************************************
- *
- * Functions related to the control value table (CVT).
- *
- */
-
-
- FT_CALLBACK_DEF( FT_F26Dot6 )
- Read_CVT( TT_ExecContext exc,
- FT_ULong idx )
- {
- return exc->cvt[idx];
- }
-
-
- FT_CALLBACK_DEF( FT_F26Dot6 )
- Read_CVT_Stretched( TT_ExecContext exc,
- FT_ULong idx )
- {
- return FT_MulFix( exc->cvt[idx], Current_Ratio( exc ) );
- }
-
-
- static void
- Modify_CVT_Check( TT_ExecContext exc )
- {
- if ( exc->iniRange == tt_coderange_glyph &&
- exc->cvt != exc->glyfCvt )
- {
- FT_Memory memory = exc->memory;
- FT_Error error;
-
-
- FT_MEM_QRENEW_ARRAY( exc->glyfCvt, exc->glyfCvtSize, exc->cvtSize );
- exc->error = error;
- if ( error )
- return;
-
- exc->glyfCvtSize = exc->cvtSize;
- FT_ARRAY_COPY( exc->glyfCvt, exc->cvt, exc->glyfCvtSize );
- exc->cvt = exc->glyfCvt;
- }
- }
-
-
- FT_CALLBACK_DEF( void )
- Write_CVT( TT_ExecContext exc,
- FT_ULong idx,
- FT_F26Dot6 value )
- {
- Modify_CVT_Check( exc );
- if ( exc->error )
- return;
-
- exc->cvt[idx] = value;
- }
-
-
- FT_CALLBACK_DEF( void )
- Write_CVT_Stretched( TT_ExecContext exc,
- FT_ULong idx,
- FT_F26Dot6 value )
- {
- Modify_CVT_Check( exc );
- if ( exc->error )
- return;
-
- exc->cvt[idx] = FT_DivFix( value, Current_Ratio( exc ) );
- }
-
-
- FT_CALLBACK_DEF( void )
- Move_CVT( TT_ExecContext exc,
- FT_ULong idx,
- FT_F26Dot6 value )
- {
- Modify_CVT_Check( exc );
- if ( exc->error )
- return;
-
- exc->cvt[idx] = ADD_LONG( exc->cvt[idx], value );
- }
-
-
- FT_CALLBACK_DEF( void )
- Move_CVT_Stretched( TT_ExecContext exc,
- FT_ULong idx,
- FT_F26Dot6 value )
- {
- Modify_CVT_Check( exc );
- if ( exc->error )
- return;
-
- exc->cvt[idx] = ADD_LONG( exc->cvt[idx],
- FT_DivFix( value, Current_Ratio( exc ) ) );
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * GetShortIns
- *
- * @Description:
- * Returns a short integer taken from the instruction stream at
- * address IP.
- *
- * @Return:
- * Short read at code[IP].
- *
- * @Note:
- * This one could become a macro.
- */
- static FT_Short
- GetShortIns( TT_ExecContext exc )
- {
- /* Reading a byte stream so there is no endianness (DaveP) */
- exc->IP += 2;
- return (FT_Short)( ( exc->code[exc->IP - 2] << 8 ) +
- exc->code[exc->IP - 1] );
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * Ins_Goto_CodeRange
- *
- * @Description:
- * Goes to a certain code range in the instruction stream.
- *
- * @Input:
- * aRange ::
- * The index of the code range.
- *
- * aIP ::
- * The new IP address in the code range.
- *
- * @Return:
- * SUCCESS or FAILURE.
- */
- static FT_Bool
- Ins_Goto_CodeRange( TT_ExecContext exc,
- FT_Int aRange,
- FT_Long aIP )
- {
- TT_CodeRange* range;
-
-
- if ( aRange < 1 || aRange > 3 )
- {
- exc->error = FT_THROW( Bad_Argument );
- return FAILURE;
- }
-
- range = &exc->codeRangeTable[aRange - 1];
-
- if ( !range->base ) /* invalid coderange */
- {
- exc->error = FT_THROW( Invalid_CodeRange );
- return FAILURE;
- }
-
- /* NOTE: Because the last instruction of a program may be a CALL */
- /* which will return to the first byte *after* the code */
- /* range, we test for aIP <= Size, instead of aIP < Size. */
-
- if ( aIP > range->size )
- {
- exc->error = FT_THROW( Code_Overflow );
- return FAILURE;
- }
-
- exc->code = range->base;
- exc->codeSize = range->size;
- exc->IP = aIP;
- exc->curRange = aRange;
-
- return SUCCESS;
- }
-
-
- /*
- *
- * Apple's TrueType specification at
- *
- * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM02/Chap2.html#order
- *
- * gives the following order of operations in instructions that move
- * points.
- *
- * - check single width cut-in (MIRP, MDRP)
- *
- * - check control value cut-in (MIRP, MIAP)
- *
- * - apply engine compensation (MIRP, MDRP)
- *
- * - round distance (MIRP, MDRP) or value (MIAP, MDAP)
- *
- * - check minimum distance (MIRP,MDRP)
- *
- * - move point (MIRP, MDRP, MIAP, MSIRP, MDAP)
- *
- * For rounding instructions, engine compensation happens before rounding.
- *
- */
-
-
- /**************************************************************************
- *
- * @Function:
- * Direct_Move
- *
- * @Description:
- * Moves a point by a given distance along the freedom vector. The
- * point will be `touched'.
- *
- * @Input:
- * point ::
- * The index of the point to move.
- *
- * distance ::
- * The distance to apply.
- *
- * @InOut:
- * zone ::
- * The affected glyph zone.
- *
- * @Note:
- * See `ttinterp.h' for details on backward compatibility mode.
- * `Touches' the point.
- */
- static void
- Direct_Move( TT_ExecContext exc,
- TT_GlyphZone zone,
- FT_UShort point,
- FT_F26Dot6 distance )
- {
- FT_F26Dot6 v;
-
-
- v = exc->GS.freeVector.x;
-
- if ( v != 0 )
- {
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- /* Exception to the post-IUP curfew: Allow the x component of */
- /* diagonal moves, but only post-IUP. DejaVu tries to adjust */
- /* diagonal stems like on `Z' and `z' post-IUP. */
- if ( SUBPIXEL_HINTING_MINIMAL && !exc->backward_compatibility )
- zone->cur[point].x = ADD_LONG( zone->cur[point].x,
- FT_MulDiv( distance,
- v,
- exc->F_dot_P ) );
- else
-#endif
-
- if ( NO_SUBPIXEL_HINTING )
- zone->cur[point].x = ADD_LONG( zone->cur[point].x,
- FT_MulDiv( distance,
- v,
- exc->F_dot_P ) );
-
- zone->tags[point] |= FT_CURVE_TAG_TOUCH_X;
- }
-
- v = exc->GS.freeVector.y;
-
- if ( v != 0 )
- {
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- if ( !( SUBPIXEL_HINTING_MINIMAL &&
- exc->backward_compatibility &&
- exc->iupx_called &&
- exc->iupy_called ) )
-#endif
- zone->cur[point].y = ADD_LONG( zone->cur[point].y,
- FT_MulDiv( distance,
- v,
- exc->F_dot_P ) );
-
- zone->tags[point] |= FT_CURVE_TAG_TOUCH_Y;
- }
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * Direct_Move_Orig
- *
- * @Description:
- * Moves the *original* position of a point by a given distance along
- * the freedom vector. Obviously, the point will not be `touched'.
- *
- * @Input:
- * point ::
- * The index of the point to move.
- *
- * distance ::
- * The distance to apply.
- *
- * @InOut:
- * zone ::
- * The affected glyph zone.
- */
- static void
- Direct_Move_Orig( TT_ExecContext exc,
- TT_GlyphZone zone,
- FT_UShort point,
- FT_F26Dot6 distance )
- {
- FT_F26Dot6 v;
-
-
- v = exc->GS.freeVector.x;
-
- if ( v != 0 )
- zone->org[point].x = ADD_LONG( zone->org[point].x,
- FT_MulDiv( distance,
- v,
- exc->F_dot_P ) );
-
- v = exc->GS.freeVector.y;
-
- if ( v != 0 )
- zone->org[point].y = ADD_LONG( zone->org[point].y,
- FT_MulDiv( distance,
- v,
- exc->F_dot_P ) );
- }
-
-
- /**************************************************************************
- *
- * Special versions of Direct_Move()
- *
- * The following versions are used whenever both vectors are both
- * along one of the coordinate unit vectors, i.e. in 90% of the cases.
- * See `ttinterp.h' for details on backward compatibility mode.
- *
- */
-
-
- static void
- Direct_Move_X( TT_ExecContext exc,
- TT_GlyphZone zone,
- FT_UShort point,
- FT_F26Dot6 distance )
- {
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- if ( SUBPIXEL_HINTING_MINIMAL && !exc->backward_compatibility )
- zone->cur[point].x = ADD_LONG( zone->cur[point].x, distance );
- else
-#endif
-
- if ( NO_SUBPIXEL_HINTING )
- zone->cur[point].x = ADD_LONG( zone->cur[point].x, distance );
-
- zone->tags[point] |= FT_CURVE_TAG_TOUCH_X;
- }
-
-
- static void
- Direct_Move_Y( TT_ExecContext exc,
- TT_GlyphZone zone,
- FT_UShort point,
- FT_F26Dot6 distance )
- {
- FT_UNUSED( exc );
-
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- if ( !( SUBPIXEL_HINTING_MINIMAL &&
- exc->backward_compatibility &&
- exc->iupx_called && exc->iupy_called ) )
-#endif
- zone->cur[point].y = ADD_LONG( zone->cur[point].y, distance );
-
- zone->tags[point] |= FT_CURVE_TAG_TOUCH_Y;
- }
-
-
- /**************************************************************************
- *
- * Special versions of Direct_Move_Orig()
- *
- * The following versions are used whenever both vectors are both
- * along one of the coordinate unit vectors, i.e. in 90% of the cases.
- *
- */
-
-
- static void
- Direct_Move_Orig_X( TT_ExecContext exc,
- TT_GlyphZone zone,
- FT_UShort point,
- FT_F26Dot6 distance )
- {
- FT_UNUSED( exc );
-
- zone->org[point].x = ADD_LONG( zone->org[point].x, distance );
- }
-
-
- static void
- Direct_Move_Orig_Y( TT_ExecContext exc,
- TT_GlyphZone zone,
- FT_UShort point,
- FT_F26Dot6 distance )
- {
- FT_UNUSED( exc );
-
- zone->org[point].y = ADD_LONG( zone->org[point].y, distance );
- }
-
- /**************************************************************************
- *
- * @Function:
- * Round_None
- *
- * @Description:
- * Does not round, but adds engine compensation.
- *
- * @Input:
- * distance ::
- * The distance (not) to round.
- *
- * color ::
- * The engine compensation color.
- *
- * @Return:
- * The compensated distance.
- */
- static FT_F26Dot6
- Round_None( TT_ExecContext exc,
- FT_F26Dot6 distance,
- FT_Int color )
- {
- FT_F26Dot6 compensation = exc->tt_metrics.compensations[color];
- FT_F26Dot6 val;
-
-
- if ( distance >= 0 )
- {
- val = ADD_LONG( distance, compensation );
- if ( val < 0 )
- val = 0;
- }
- else
- {
- val = SUB_LONG( distance, compensation );
- if ( val > 0 )
- val = 0;
- }
- return val;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * Round_To_Grid
- *
- * @Description:
- * Rounds value to grid after adding engine compensation.
- *
- * @Input:
- * distance ::
- * The distance to round.
- *
- * color ::
- * The engine compensation color.
- *
- * @Return:
- * Rounded distance.
- */
- static FT_F26Dot6
- Round_To_Grid( TT_ExecContext exc,
- FT_F26Dot6 distance,
- FT_Int color )
- {
- FT_F26Dot6 compensation = exc->tt_metrics.compensations[color];
- FT_F26Dot6 val;
-
-
- if ( distance >= 0 )
- {
- val = FT_PIX_ROUND_LONG( ADD_LONG( distance, compensation ) );
- if ( val < 0 )
- val = 0;
- }
- else
- {
- val = NEG_LONG( FT_PIX_ROUND_LONG( SUB_LONG( compensation,
- distance ) ) );
- if ( val > 0 )
- val = 0;
- }
-
- return val;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * Round_To_Half_Grid
- *
- * @Description:
- * Rounds value to half grid after adding engine compensation.
- *
- * @Input:
- * distance ::
- * The distance to round.
- *
- * color ::
- * The engine compensation color.
- *
- * @Return:
- * Rounded distance.
- */
- static FT_F26Dot6
- Round_To_Half_Grid( TT_ExecContext exc,
- FT_F26Dot6 distance,
- FT_Int color )
- {
- FT_F26Dot6 compensation = exc->tt_metrics.compensations[color];
- FT_F26Dot6 val;
-
-
- if ( distance >= 0 )
- {
- val = ADD_LONG( FT_PIX_FLOOR( ADD_LONG( distance, compensation ) ),
- 32 );
- if ( val < 0 )
- val = 32;
- }
- else
- {
- val = NEG_LONG( ADD_LONG( FT_PIX_FLOOR( SUB_LONG( compensation,
- distance ) ),
- 32 ) );
- if ( val > 0 )
- val = -32;
- }
-
- return val;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * Round_Down_To_Grid
- *
- * @Description:
- * Rounds value down to grid after adding engine compensation.
- *
- * @Input:
- * distance ::
- * The distance to round.
- *
- * color ::
- * The engine compensation color.
- *
- * @Return:
- * Rounded distance.
- */
- static FT_F26Dot6
- Round_Down_To_Grid( TT_ExecContext exc,
- FT_F26Dot6 distance,
- FT_Int color )
- {
- FT_F26Dot6 compensation = exc->tt_metrics.compensations[color];
- FT_F26Dot6 val;
-
-
- if ( distance >= 0 )
- {
- val = FT_PIX_FLOOR( ADD_LONG( distance, compensation ) );
- if ( val < 0 )
- val = 0;
- }
- else
- {
- val = NEG_LONG( FT_PIX_FLOOR( SUB_LONG( compensation, distance ) ) );
- if ( val > 0 )
- val = 0;
- }
-
- return val;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * Round_Up_To_Grid
- *
- * @Description:
- * Rounds value up to grid after adding engine compensation.
- *
- * @Input:
- * distance ::
- * The distance to round.
- *
- * color ::
- * The engine compensation color.
- *
- * @Return:
- * Rounded distance.
- */
- static FT_F26Dot6
- Round_Up_To_Grid( TT_ExecContext exc,
- FT_F26Dot6 distance,
- FT_Int color )
- {
- FT_F26Dot6 compensation = exc->tt_metrics.compensations[color];
- FT_F26Dot6 val;
-
-
- if ( distance >= 0 )
- {
- val = FT_PIX_CEIL_LONG( ADD_LONG( distance, compensation ) );
- if ( val < 0 )
- val = 0;
- }
- else
- {
- val = NEG_LONG( FT_PIX_CEIL_LONG( SUB_LONG( compensation,
- distance ) ) );
- if ( val > 0 )
- val = 0;
- }
-
- return val;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * Round_To_Double_Grid
- *
- * @Description:
- * Rounds value to double grid after adding engine compensation.
- *
- * @Input:
- * distance ::
- * The distance to round.
- *
- * color ::
- * The engine compensation color.
- *
- * @Return:
- * Rounded distance.
- */
- static FT_F26Dot6
- Round_To_Double_Grid( TT_ExecContext exc,
- FT_F26Dot6 distance,
- FT_Int color )
- {
- FT_F26Dot6 compensation = exc->tt_metrics.compensations[color];
- FT_F26Dot6 val;
-
-
- if ( distance >= 0 )
- {
- val = FT_PAD_ROUND_LONG( ADD_LONG( distance, compensation ), 32 );
- if ( val < 0 )
- val = 0;
- }
- else
- {
- val = NEG_LONG( FT_PAD_ROUND_LONG( SUB_LONG( compensation, distance ),
- 32 ) );
- if ( val > 0 )
- val = 0;
- }
-
- return val;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * Round_Super
- *
- * @Description:
- * Super-rounds value to grid after adding engine compensation.
- *
- * @Input:
- * distance ::
- * The distance to round.
- *
- * color ::
- * The engine compensation color.
- *
- * @Return:
- * Rounded distance.
- *
- * @Note:
- * The TrueType specification says very little about the relationship
- * between rounding and engine compensation. However, it seems from
- * the description of super round that we should add the compensation
- * before rounding.
- */
- static FT_F26Dot6
- Round_Super( TT_ExecContext exc,
- FT_F26Dot6 distance,
- FT_Int color )
- {
- FT_F26Dot6 compensation = exc->tt_metrics.compensations[color];
- FT_F26Dot6 val;
-
-
- if ( distance >= 0 )
- {
- val = ADD_LONG( distance,
- exc->threshold - exc->phase + compensation ) &
- -exc->period;
- val = ADD_LONG( val, exc->phase );
- if ( val < 0 )
- val = exc->phase;
- }
- else
- {
- val = NEG_LONG( SUB_LONG( exc->threshold - exc->phase + compensation,
- distance ) &
- -exc->period );
- val = SUB_LONG( val, exc->phase );
- if ( val > 0 )
- val = -exc->phase;
- }
-
- return val;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * Round_Super_45
- *
- * @Description:
- * Super-rounds value to grid after adding engine compensation.
- *
- * @Input:
- * distance ::
- * The distance to round.
- *
- * color ::
- * The engine compensation color.
- *
- * @Return:
- * Rounded distance.
- *
- * @Note:
- * There is a separate function for Round_Super_45() as we may need
- * greater precision.
- */
- static FT_F26Dot6
- Round_Super_45( TT_ExecContext exc,
- FT_F26Dot6 distance,
- FT_Int color )
- {
- FT_F26Dot6 compensation = exc->tt_metrics.compensations[color];
- FT_F26Dot6 val;
-
-
- if ( distance >= 0 )
- {
- val = ( ADD_LONG( distance,
- exc->threshold - exc->phase + compensation ) /
- exc->period ) * exc->period;
- val = ADD_LONG( val, exc->phase );
- if ( val < 0 )
- val = exc->phase;
- }
- else
- {
- val = NEG_LONG( ( SUB_LONG( exc->threshold - exc->phase + compensation,
- distance ) /
- exc->period ) * exc->period );
- val = SUB_LONG( val, exc->phase );
- if ( val > 0 )
- val = -exc->phase;
- }
-
- return val;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * Compute_Round
- *
- * @Description:
- * Sets the rounding mode.
- *
- * @Input:
- * round_mode ::
- * The rounding mode to be used.
- */
- static void
- Compute_Round( TT_ExecContext exc,
- FT_Byte round_mode )
- {
- switch ( round_mode )
- {
- case TT_Round_Off:
- exc->func_round = (TT_Round_Func)Round_None;
- break;
-
- case TT_Round_To_Grid:
- exc->func_round = (TT_Round_Func)Round_To_Grid;
- break;
-
- case TT_Round_Up_To_Grid:
- exc->func_round = (TT_Round_Func)Round_Up_To_Grid;
- break;
-
- case TT_Round_Down_To_Grid:
- exc->func_round = (TT_Round_Func)Round_Down_To_Grid;
- break;
-
- case TT_Round_To_Half_Grid:
- exc->func_round = (TT_Round_Func)Round_To_Half_Grid;
- break;
-
- case TT_Round_To_Double_Grid:
- exc->func_round = (TT_Round_Func)Round_To_Double_Grid;
- break;
-
- case TT_Round_Super:
- exc->func_round = (TT_Round_Func)Round_Super;
- break;
-
- case TT_Round_Super_45:
- exc->func_round = (TT_Round_Func)Round_Super_45;
- break;
- }
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * SetSuperRound
- *
- * @Description:
- * Sets Super Round parameters.
- *
- * @Input:
- * GridPeriod ::
- * The grid period.
- *
- * selector ::
- * The SROUND opcode.
- */
- static void
- SetSuperRound( TT_ExecContext exc,
- FT_F2Dot14 GridPeriod,
- FT_Long selector )
- {
- switch ( (FT_Int)( selector & 0xC0 ) )
- {
- case 0:
- exc->period = GridPeriod / 2;
- break;
-
- case 0x40:
- exc->period = GridPeriod;
- break;
-
- case 0x80:
- exc->period = GridPeriod * 2;
- break;
-
- /* This opcode is reserved, but... */
- case 0xC0:
- exc->period = GridPeriod;
- break;
- }
-
- switch ( (FT_Int)( selector & 0x30 ) )
- {
- case 0:
- exc->phase = 0;
- break;
-
- case 0x10:
- exc->phase = exc->period / 4;
- break;
-
- case 0x20:
- exc->phase = exc->period / 2;
- break;
-
- case 0x30:
- exc->phase = exc->period * 3 / 4;
- break;
- }
-
- if ( ( selector & 0x0F ) == 0 )
- exc->threshold = exc->period - 1;
- else
- exc->threshold = ( (FT_Int)( selector & 0x0F ) - 4 ) * exc->period / 8;
-
- /* convert to F26Dot6 format */
- exc->period >>= 8;
- exc->phase >>= 8;
- exc->threshold >>= 8;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * Project
- *
- * @Description:
- * Computes the projection of vector given by (v2-v1) along the
- * current projection vector.
- *
- * @Input:
- * v1 ::
- * First input vector.
- * v2 ::
- * Second input vector.
- *
- * @Return:
- * The distance in F26dot6 format.
- */
- static FT_F26Dot6
- Project( TT_ExecContext exc,
- FT_Pos dx,
- FT_Pos dy )
- {
- return TT_DotFix14( dx, dy,
- exc->GS.projVector.x,
- exc->GS.projVector.y );
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * Dual_Project
- *
- * @Description:
- * Computes the projection of the vector given by (v2-v1) along the
- * current dual vector.
- *
- * @Input:
- * v1 ::
- * First input vector.
- * v2 ::
- * Second input vector.
- *
- * @Return:
- * The distance in F26dot6 format.
- */
- static FT_F26Dot6
- Dual_Project( TT_ExecContext exc,
- FT_Pos dx,
- FT_Pos dy )
- {
- return TT_DotFix14( dx, dy,
- exc->GS.dualVector.x,
- exc->GS.dualVector.y );
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * Project_x
- *
- * @Description:
- * Computes the projection of the vector given by (v2-v1) along the
- * horizontal axis.
- *
- * @Input:
- * v1 ::
- * First input vector.
- * v2 ::
- * Second input vector.
- *
- * @Return:
- * The distance in F26dot6 format.
- */
- static FT_F26Dot6
- Project_x( TT_ExecContext exc,
- FT_Pos dx,
- FT_Pos dy )
- {
- FT_UNUSED( exc );
- FT_UNUSED( dy );
-
- return dx;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * Project_y
- *
- * @Description:
- * Computes the projection of the vector given by (v2-v1) along the
- * vertical axis.
- *
- * @Input:
- * v1 ::
- * First input vector.
- * v2 ::
- * Second input vector.
- *
- * @Return:
- * The distance in F26dot6 format.
- */
- static FT_F26Dot6
- Project_y( TT_ExecContext exc,
- FT_Pos dx,
- FT_Pos dy )
- {
- FT_UNUSED( exc );
- FT_UNUSED( dx );
-
- return dy;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * Compute_Funcs
- *
- * @Description:
- * Computes the projection and movement function pointers according
- * to the current graphics state.
- */
- static void
- Compute_Funcs( TT_ExecContext exc )
- {
- if ( exc->GS.freeVector.x == 0x4000 )
- exc->F_dot_P = exc->GS.projVector.x;
- else if ( exc->GS.freeVector.y == 0x4000 )
- exc->F_dot_P = exc->GS.projVector.y;
- else
- exc->F_dot_P =
- ( (FT_Long)exc->GS.projVector.x * exc->GS.freeVector.x +
- (FT_Long)exc->GS.projVector.y * exc->GS.freeVector.y ) >> 14;
-
- if ( exc->GS.projVector.x == 0x4000 )
- exc->func_project = (TT_Project_Func)Project_x;
- else if ( exc->GS.projVector.y == 0x4000 )
- exc->func_project = (TT_Project_Func)Project_y;
- else
- exc->func_project = (TT_Project_Func)Project;
-
- if ( exc->GS.dualVector.x == 0x4000 )
- exc->func_dualproj = (TT_Project_Func)Project_x;
- else if ( exc->GS.dualVector.y == 0x4000 )
- exc->func_dualproj = (TT_Project_Func)Project_y;
- else
- exc->func_dualproj = (TT_Project_Func)Dual_Project;
-
- exc->func_move = (TT_Move_Func)Direct_Move;
- exc->func_move_orig = (TT_Move_Func)Direct_Move_Orig;
-
- if ( exc->F_dot_P == 0x4000L )
- {
- if ( exc->GS.freeVector.x == 0x4000 )
- {
- exc->func_move = (TT_Move_Func)Direct_Move_X;
- exc->func_move_orig = (TT_Move_Func)Direct_Move_Orig_X;
- }
- else if ( exc->GS.freeVector.y == 0x4000 )
- {
- exc->func_move = (TT_Move_Func)Direct_Move_Y;
- exc->func_move_orig = (TT_Move_Func)Direct_Move_Orig_Y;
- }
- }
-
- /* at small sizes, F_dot_P can become too small, resulting */
- /* in overflows and `spikes' in a number of glyphs like `w'. */
-
- if ( FT_ABS( exc->F_dot_P ) < 0x400L )
- exc->F_dot_P = 0x4000L;
-
- /* Disable cached aspect ratio */
- exc->tt_metrics.ratio = 0;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * Normalize
- *
- * @Description:
- * Norms a vector.
- *
- * @Input:
- * Vx ::
- * The horizontal input vector coordinate.
- * Vy ::
- * The vertical input vector coordinate.
- *
- * @Output:
- * R ::
- * The normed unit vector.
- *
- * @Return:
- * Returns FAILURE if a vector parameter is zero.
- *
- * @Note:
- * In case Vx and Vy are both zero, `Normalize' returns SUCCESS, and
- * R is undefined.
- */
- static FT_Bool
- Normalize( FT_F26Dot6 Vx,
- FT_F26Dot6 Vy,
- FT_UnitVector* R )
- {
- FT_Vector V;
-
-
- if ( Vx == 0 && Vy == 0 )
- {
- /* XXX: UNDOCUMENTED! It seems that it is possible to try */
- /* to normalize the vector (0,0). Return immediately. */
- return SUCCESS;
- }
-
- V.x = Vx;
- V.y = Vy;
-
- FT_Vector_NormLen( &V );
-
- R->x = (FT_F2Dot14)( V.x / 4 );
- R->y = (FT_F2Dot14)( V.y / 4 );
-
- return SUCCESS;
- }
-
-
- /**************************************************************************
- *
- * Here we start with the implementation of the various opcodes.
- *
- */
-
-
-#define ARRAY_BOUND_ERROR \
- do \
- { \
- exc->error = FT_THROW( Invalid_Reference ); \
- return; \
- } while (0)
-
-
- /**************************************************************************
- *
- * MPPEM[]: Measure Pixel Per EM
- * Opcode range: 0x4B
- * Stack: --> Euint16
- */
- static void
- Ins_MPPEM( TT_ExecContext exc,
- FT_Long* args )
- {
- args[0] = exc->func_cur_ppem( exc );
- }
-
-
- /**************************************************************************
- *
- * MPS[]: Measure Point Size
- * Opcode range: 0x4C
- * Stack: --> Euint16
- */
- static void
- Ins_MPS( TT_ExecContext exc,
- FT_Long* args )
- {
- if ( NO_SUBPIXEL_HINTING )
- {
- /* Microsoft's GDI bytecode interpreter always returns value 12; */
- /* we return the current PPEM value instead. */
- args[0] = exc->func_cur_ppem( exc );
- }
- else
- {
- /* A possible practical application of the MPS instruction is to */
- /* implement optical scaling and similar features, which should be */
- /* based on perceptual attributes, thus independent of the */
- /* resolution. */
- args[0] = exc->pointSize;
- }
- }
-
-
- /**************************************************************************
- *
- * DUP[]: DUPlicate the stack's top element
- * Opcode range: 0x20
- * Stack: StkElt --> StkElt StkElt
- */
- static void
- Ins_DUP( FT_Long* args )
- {
- args[1] = args[0];
- }
-
-
- /**************************************************************************
- *
- * POP[]: POP the stack's top element
- * Opcode range: 0x21
- * Stack: StkElt -->
- */
- static void
- Ins_POP( void )
- {
- /* nothing to do */
- }
-
-
- /**************************************************************************
- *
- * CLEAR[]: CLEAR the entire stack
- * Opcode range: 0x22
- * Stack: StkElt... -->
- */
- static void
- Ins_CLEAR( TT_ExecContext exc )
- {
- exc->new_top = 0;
- }
-
-
- /**************************************************************************
- *
- * SWAP[]: SWAP the stack's top two elements
- * Opcode range: 0x23
- * Stack: 2 * StkElt --> 2 * StkElt
- */
- static void
- Ins_SWAP( FT_Long* args )
- {
- FT_Long L;
-
-
- L = args[0];
- args[0] = args[1];
- args[1] = L;
- }
-
-
- /**************************************************************************
- *
- * DEPTH[]: return the stack DEPTH
- * Opcode range: 0x24
- * Stack: --> uint32
- */
- static void
- Ins_DEPTH( TT_ExecContext exc,
- FT_Long* args )
- {
- args[0] = exc->top;
- }
-
-
- /**************************************************************************
- *
- * LT[]: Less Than
- * Opcode range: 0x50
- * Stack: int32? int32? --> bool
- */
- static void
- Ins_LT( FT_Long* args )
- {
- args[0] = ( args[0] < args[1] );
- }
-
-
- /**************************************************************************
- *
- * LTEQ[]: Less Than or EQual
- * Opcode range: 0x51
- * Stack: int32? int32? --> bool
- */
- static void
- Ins_LTEQ( FT_Long* args )
- {
- args[0] = ( args[0] <= args[1] );
- }
-
-
- /**************************************************************************
- *
- * GT[]: Greater Than
- * Opcode range: 0x52
- * Stack: int32? int32? --> bool
- */
- static void
- Ins_GT( FT_Long* args )
- {
- args[0] = ( args[0] > args[1] );
- }
-
-
- /**************************************************************************
- *
- * GTEQ[]: Greater Than or EQual
- * Opcode range: 0x53
- * Stack: int32? int32? --> bool
- */
- static void
- Ins_GTEQ( FT_Long* args )
- {
- args[0] = ( args[0] >= args[1] );
- }
-
-
- /**************************************************************************
- *
- * EQ[]: EQual
- * Opcode range: 0x54
- * Stack: StkElt StkElt --> bool
- */
- static void
- Ins_EQ( FT_Long* args )
- {
- args[0] = ( args[0] == args[1] );
- }
-
-
- /**************************************************************************
- *
- * NEQ[]: Not EQual
- * Opcode range: 0x55
- * Stack: StkElt StkElt --> bool
- */
- static void
- Ins_NEQ( FT_Long* args )
- {
- args[0] = ( args[0] != args[1] );
- }
-
-
- /**************************************************************************
- *
- * ODD[]: Is ODD
- * Opcode range: 0x56
- * Stack: f26.6 --> bool
- */
- static void
- Ins_ODD( TT_ExecContext exc,
- FT_Long* args )
- {
- args[0] = ( ( exc->func_round( exc, args[0], 3 ) & 127 ) == 64 );
- }
-
-
- /**************************************************************************
- *
- * EVEN[]: Is EVEN
- * Opcode range: 0x57
- * Stack: f26.6 --> bool
- */
- static void
- Ins_EVEN( TT_ExecContext exc,
- FT_Long* args )
- {
- args[0] = ( ( exc->func_round( exc, args[0], 3 ) & 127 ) == 0 );
- }
-
-
- /**************************************************************************
- *
- * AND[]: logical AND
- * Opcode range: 0x5A
- * Stack: uint32 uint32 --> uint32
- */
- static void
- Ins_AND( FT_Long* args )
- {
- args[0] = ( args[0] && args[1] );
- }
-
-
- /**************************************************************************
- *
- * OR[]: logical OR
- * Opcode range: 0x5B
- * Stack: uint32 uint32 --> uint32
- */
- static void
- Ins_OR( FT_Long* args )
- {
- args[0] = ( args[0] || args[1] );
- }
-
-
- /**************************************************************************
- *
- * NOT[]: logical NOT
- * Opcode range: 0x5C
- * Stack: StkElt --> uint32
- */
- static void
- Ins_NOT( FT_Long* args )
- {
- args[0] = !args[0];
- }
-
-
- /**************************************************************************
- *
- * ADD[]: ADD
- * Opcode range: 0x60
- * Stack: f26.6 f26.6 --> f26.6
- */
- static void
- Ins_ADD( FT_Long* args )
- {
- args[0] = ADD_LONG( args[0], args[1] );
- }
-
-
- /**************************************************************************
- *
- * SUB[]: SUBtract
- * Opcode range: 0x61
- * Stack: f26.6 f26.6 --> f26.6
- */
- static void
- Ins_SUB( FT_Long* args )
- {
- args[0] = SUB_LONG( args[0], args[1] );
- }
-
-
- /**************************************************************************
- *
- * DIV[]: DIVide
- * Opcode range: 0x62
- * Stack: f26.6 f26.6 --> f26.6
- */
- static void
- Ins_DIV( TT_ExecContext exc,
- FT_Long* args )
- {
- if ( args[1] == 0 )
- exc->error = FT_THROW( Divide_By_Zero );
- else
- args[0] = FT_MulDiv_No_Round( args[0], 64L, args[1] );
- }
-
-
- /**************************************************************************
- *
- * MUL[]: MULtiply
- * Opcode range: 0x63
- * Stack: f26.6 f26.6 --> f26.6
- */
- static void
- Ins_MUL( FT_Long* args )
- {
- args[0] = FT_MulDiv( args[0], args[1], 64L );
- }
-
-
- /**************************************************************************
- *
- * ABS[]: ABSolute value
- * Opcode range: 0x64
- * Stack: f26.6 --> f26.6
- */
- static void
- Ins_ABS( FT_Long* args )
- {
- if ( args[0] < 0 )
- args[0] = NEG_LONG( args[0] );
- }
-
-
- /**************************************************************************
- *
- * NEG[]: NEGate
- * Opcode range: 0x65
- * Stack: f26.6 --> f26.6
- */
- static void
- Ins_NEG( FT_Long* args )
- {
- args[0] = NEG_LONG( args[0] );
- }
-
-
- /**************************************************************************
- *
- * FLOOR[]: FLOOR
- * Opcode range: 0x66
- * Stack: f26.6 --> f26.6
- */
- static void
- Ins_FLOOR( FT_Long* args )
- {
- args[0] = FT_PIX_FLOOR( args[0] );
- }
-
-
- /**************************************************************************
- *
- * CEILING[]: CEILING
- * Opcode range: 0x67
- * Stack: f26.6 --> f26.6
- */
- static void
- Ins_CEILING( FT_Long* args )
- {
- args[0] = FT_PIX_CEIL_LONG( args[0] );
- }
-
-
- /**************************************************************************
- *
- * RS[]: Read Store
- * Opcode range: 0x43
- * Stack: uint32 --> uint32
- */
- static void
- Ins_RS( TT_ExecContext exc,
- FT_Long* args )
- {
- FT_ULong I = (FT_ULong)args[0];
-
-
- if ( BOUNDSL( I, exc->storeSize ) )
- {
- if ( exc->pedantic_hinting )
- ARRAY_BOUND_ERROR;
- else
- args[0] = 0;
- }
- else
- args[0] = exc->storage[I];
- }
-
-
- /**************************************************************************
- *
- * WS[]: Write Store
- * Opcode range: 0x42
- * Stack: uint32 uint32 -->
- */
- static void
- Ins_WS( TT_ExecContext exc,
- FT_Long* args )
- {
- FT_ULong I = (FT_ULong)args[0];
-
-
- if ( BOUNDSL( I, exc->storeSize ) )
- {
- if ( exc->pedantic_hinting )
- ARRAY_BOUND_ERROR;
- }
- else
- {
- if ( exc->iniRange == tt_coderange_glyph &&
- exc->storage != exc->glyfStorage )
- {
- FT_Memory memory = exc->memory;
- FT_Error error;
-
-
- FT_MEM_QRENEW_ARRAY( exc->glyfStorage,
- exc->glyfStoreSize,
- exc->storeSize );
- exc->error = error;
- if ( error )
- return;
-
- exc->glyfStoreSize = exc->storeSize;
- FT_ARRAY_COPY( exc->glyfStorage, exc->storage, exc->glyfStoreSize );
- exc->storage = exc->glyfStorage;
- }
-
- exc->storage[I] = args[1];
- }
- }
-
-
- /**************************************************************************
- *
- * WCVTP[]: Write CVT in Pixel units
- * Opcode range: 0x44
- * Stack: f26.6 uint32 -->
- */
- static void
- Ins_WCVTP( TT_ExecContext exc,
- FT_Long* args )
- {
- FT_ULong I = (FT_ULong)args[0];
-
-
- if ( BOUNDSL( I, exc->cvtSize ) )
- {
- if ( exc->pedantic_hinting )
- ARRAY_BOUND_ERROR;
- }
- else
- exc->func_write_cvt( exc, I, args[1] );
- }
-
-
- /**************************************************************************
- *
- * WCVTF[]: Write CVT in Funits
- * Opcode range: 0x70
- * Stack: uint32 uint32 -->
- */
- static void
- Ins_WCVTF( TT_ExecContext exc,
- FT_Long* args )
- {
- FT_ULong I = (FT_ULong)args[0];
-
-
- if ( BOUNDSL( I, exc->cvtSize ) )
- {
- if ( exc->pedantic_hinting )
- ARRAY_BOUND_ERROR;
- }
- else
- exc->cvt[I] = FT_MulFix( args[1], exc->tt_metrics.scale );
- }
-
-
- /**************************************************************************
- *
- * RCVT[]: Read CVT
- * Opcode range: 0x45
- * Stack: uint32 --> f26.6
- */
- static void
- Ins_RCVT( TT_ExecContext exc,
- FT_Long* args )
- {
- FT_ULong I = (FT_ULong)args[0];
-
-
- if ( BOUNDSL( I, exc->cvtSize ) )
- {
- if ( exc->pedantic_hinting )
- ARRAY_BOUND_ERROR;
- else
- args[0] = 0;
- }
- else
- args[0] = exc->func_read_cvt( exc, I );
- }
-
-
- /**************************************************************************
- *
- * AA[]: Adjust Angle
- * Opcode range: 0x7F
- * Stack: uint32 -->
- */
- static void
- Ins_AA( void )
- {
- /* intentionally no longer supported */
- }
-
-
- /**************************************************************************
- *
- * DEBUG[]: DEBUG. Unsupported.
- * Opcode range: 0x4F
- * Stack: uint32 -->
- *
- * Note: The original instruction pops a value from the stack.
- */
- static void
- Ins_DEBUG( TT_ExecContext exc )
- {
- exc->error = FT_THROW( Debug_OpCode );
- }
-
-
- /**************************************************************************
- *
- * ROUND[ab]: ROUND value
- * Opcode range: 0x68-0x6B
- * Stack: f26.6 --> f26.6
- */
- static void
- Ins_ROUND( TT_ExecContext exc,
- FT_Long* args )
- {
- args[0] = exc->func_round( exc, args[0], exc->opcode & 3 );
- }
-
-
- /**************************************************************************
- *
- * NROUND[ab]: No ROUNDing of value
- * Opcode range: 0x6C-0x6F
- * Stack: f26.6 --> f26.6
- */
- static void
- Ins_NROUND( TT_ExecContext exc,
- FT_Long* args )
- {
- args[0] = Round_None( exc, args[0], exc->opcode & 3 );
- }
-
-
- /**************************************************************************
- *
- * MAX[]: MAXimum
- * Opcode range: 0x8B
- * Stack: int32? int32? --> int32
- */
- static void
- Ins_MAX( FT_Long* args )
- {
- if ( args[1] > args[0] )
- args[0] = args[1];
- }
-
-
- /**************************************************************************
- *
- * MIN[]: MINimum
- * Opcode range: 0x8C
- * Stack: int32? int32? --> int32
- */
- static void
- Ins_MIN( FT_Long* args )
- {
- if ( args[1] < args[0] )
- args[0] = args[1];
- }
-
-
- /**************************************************************************
- *
- * MINDEX[]: Move INDEXed element
- * Opcode range: 0x26
- * Stack: int32? --> StkElt
- */
- static void
- Ins_MINDEX( TT_ExecContext exc,
- FT_Long* args )
- {
- FT_Long L, K;
-
-
- L = args[0];
-
- if ( L <= 0 || L > exc->args )
- {
- if ( exc->pedantic_hinting )
- exc->error = FT_THROW( Invalid_Reference );
- }
- else
- {
- K = exc->stack[exc->args - L];
-
- FT_ARRAY_MOVE( &exc->stack[exc->args - L ],
- &exc->stack[exc->args - L + 1],
- ( L - 1 ) );
-
- exc->stack[exc->args - 1] = K;
- }
- }
-
-
- /**************************************************************************
- *
- * CINDEX[]: Copy INDEXed element
- * Opcode range: 0x25
- * Stack: int32 --> StkElt
- */
- static void
- Ins_CINDEX( TT_ExecContext exc,
- FT_Long* args )
- {
- FT_Long L;
-
-
- L = args[0];
-
- if ( L <= 0 || L > exc->args )
- {
- if ( exc->pedantic_hinting )
- exc->error = FT_THROW( Invalid_Reference );
- args[0] = 0;
- }
- else
- args[0] = exc->stack[exc->args - L];
- }
-
-
- /**************************************************************************
- *
- * ROLL[]: ROLL top three elements
- * Opcode range: 0x8A
- * Stack: 3 * StkElt --> 3 * StkElt
- */
- static void
- Ins_ROLL( FT_Long* args )
- {
- FT_Long A, B, C;
-
-
- A = args[2];
- B = args[1];
- C = args[0];
-
- args[2] = C;
- args[1] = A;
- args[0] = B;
- }
-
-
- /**************************************************************************
- *
- * MANAGING THE FLOW OF CONTROL
- *
- */
-
-
- /**************************************************************************
- *
- * SLOOP[]: Set LOOP variable
- * Opcode range: 0x17
- * Stack: int32? -->
- */
- static void
- Ins_SLOOP( TT_ExecContext exc,
- FT_Long* args )
- {
- if ( args[0] < 0 )
- exc->error = FT_THROW( Bad_Argument );
- else
- {
- /* we heuristically limit the number of loops to 16 bits */
- exc->GS.loop = args[0] > 0xFFFFL ? 0xFFFFL : args[0];
- }
- }
-
-
- static FT_Bool
- SkipCode( TT_ExecContext exc )
- {
- exc->IP += exc->length;
-
- if ( exc->IP < exc->codeSize )
- {
- exc->opcode = exc->code[exc->IP];
-
- exc->length = opcode_length[exc->opcode];
- if ( exc->length < 0 )
- {
- if ( exc->IP + 1 >= exc->codeSize )
- goto Fail_Overflow;
- exc->length = 2 - exc->length * exc->code[exc->IP + 1];
- }
-
- if ( exc->IP + exc->length <= exc->codeSize )
- return SUCCESS;
- }
-
- Fail_Overflow:
- exc->error = FT_THROW( Code_Overflow );
- return FAILURE;
- }
-
-
- /**************************************************************************
- *
- * IF[]: IF test
- * Opcode range: 0x58
- * Stack: StkElt -->
- */
- static void
- Ins_IF( TT_ExecContext exc,
- FT_Long* args )
- {
- FT_Int nIfs;
- FT_Bool Out;
-
-
- if ( args[0] != 0 )
- return;
-
- nIfs = 1;
- Out = 0;
-
- do
- {
- if ( SkipCode( exc ) == FAILURE )
- return;
-
- switch ( exc->opcode )
- {
- case 0x58: /* IF */
- nIfs++;
- break;
-
- case 0x1B: /* ELSE */
- Out = FT_BOOL( nIfs == 1 );
- break;
-
- case 0x59: /* EIF */
- nIfs--;
- Out = FT_BOOL( nIfs == 0 );
- break;
- }
- } while ( Out == 0 );
- }
-
-
- /**************************************************************************
- *
- * ELSE[]: ELSE
- * Opcode range: 0x1B
- * Stack: -->
- */
- static void
- Ins_ELSE( TT_ExecContext exc )
- {
- FT_Int nIfs;
-
-
- nIfs = 1;
-
- do
- {
- if ( SkipCode( exc ) == FAILURE )
- return;
-
- switch ( exc->opcode )
- {
- case 0x58: /* IF */
- nIfs++;
- break;
-
- case 0x59: /* EIF */
- nIfs--;
- break;
- }
- } while ( nIfs != 0 );
- }
-
-
- /**************************************************************************
- *
- * EIF[]: End IF
- * Opcode range: 0x59
- * Stack: -->
- */
- static void
- Ins_EIF( void )
- {
- /* nothing to do */
- }
-
-
- /**************************************************************************
- *
- * JMPR[]: JuMP Relative
- * Opcode range: 0x1C
- * Stack: int32 -->
- */
- static void
- Ins_JMPR( TT_ExecContext exc,
- FT_Long* args )
- {
- if ( args[0] == 0 && exc->args == 0 )
- {
- exc->error = FT_THROW( Bad_Argument );
- return;
- }
-
- exc->IP = ADD_LONG( exc->IP, args[0] );
- if ( exc->IP < 0 ||
- ( exc->callTop > 0 &&
- exc->IP > exc->callStack[exc->callTop - 1].Def->end ) )
- {
- exc->error = FT_THROW( Bad_Argument );
- return;
- }
-
- exc->step_ins = FALSE;
-
- if ( args[0] < 0 )
- {
- if ( ++exc->neg_jump_counter > exc->neg_jump_counter_max )
- exc->error = FT_THROW( Execution_Too_Long );
- }
- }
-
-
- /**************************************************************************
- *
- * JROT[]: Jump Relative On True
- * Opcode range: 0x78
- * Stack: StkElt int32 -->
- */
- static void
- Ins_JROT( TT_ExecContext exc,
- FT_Long* args )
- {
- if ( args[1] != 0 )
- Ins_JMPR( exc, args );
- }
-
-
- /**************************************************************************
- *
- * JROF[]: Jump Relative On False
- * Opcode range: 0x79
- * Stack: StkElt int32 -->
- */
- static void
- Ins_JROF( TT_ExecContext exc,
- FT_Long* args )
- {
- if ( args[1] == 0 )
- Ins_JMPR( exc, args );
- }
-
-
- /**************************************************************************
- *
- * DEFINING AND USING FUNCTIONS AND INSTRUCTIONS
- *
- */
-
-
- /**************************************************************************
- *
- * FDEF[]: Function DEFinition
- * Opcode range: 0x2C
- * Stack: uint32 -->
- */
- static void
- Ins_FDEF( TT_ExecContext exc,
- FT_Long* args )
- {
- FT_ULong n;
- TT_DefRecord* rec;
- TT_DefRecord* limit;
-
-
- /* FDEF is only allowed in `prep' or `fpgm' */
- if ( exc->iniRange == tt_coderange_glyph )
- {
- exc->error = FT_THROW( DEF_In_Glyf_Bytecode );
- return;
- }
-
- /* some font programs are broken enough to redefine functions! */
- /* We will then parse the current table. */
-
- rec = exc->FDefs;
- limit = FT_OFFSET( rec, exc->numFDefs );
- n = (FT_ULong)args[0];
-
- for ( ; rec < limit; rec++ )
- {
- if ( rec->opc == n )
- break;
- }
-
- if ( rec == limit )
- {
- /* check that there is enough room for new functions */
- if ( exc->numFDefs >= exc->maxFDefs )
- {
- exc->error = FT_THROW( Too_Many_Function_Defs );
- return;
- }
- exc->numFDefs++;
- }
-
- /* Although FDEF takes unsigned 32-bit integer, */
- /* func # must be within unsigned 16-bit integer */
- if ( n > 0xFFFFU )
- {
- exc->error = FT_THROW( Too_Many_Function_Defs );
- return;
- }
-
- rec->range = exc->curRange;
- rec->opc = (FT_UInt16)n;
- rec->start = exc->IP + 1;
- rec->active = TRUE;
-
- if ( n > exc->maxFunc )
- exc->maxFunc = (FT_UInt16)n;
-
- /* Now skip the whole function definition. */
- /* We don't allow nested IDEFS & FDEFs. */
-
- while ( SkipCode( exc ) == SUCCESS )
- {
- switch ( exc->opcode )
- {
- case 0x89: /* IDEF */
- case 0x2C: /* FDEF */
- exc->error = FT_THROW( Nested_DEFS );
- return;
-
- case 0x2D: /* ENDF */
- rec->end = exc->IP;
- return;
- }
- }
- }
-
-
- /**************************************************************************
- *
- * ENDF[]: END Function definition
- * Opcode range: 0x2D
- * Stack: -->
- */
- static void
- Ins_ENDF( TT_ExecContext exc )
- {
- TT_CallRec* pRec;
-
-
- if ( exc->callTop <= 0 ) /* We encountered an ENDF without a call */
- {
- exc->error = FT_THROW( ENDF_In_Exec_Stream );
- return;
- }
-
- exc->callTop--;
-
- pRec = &exc->callStack[exc->callTop];
-
- pRec->Cur_Count--;
-
- exc->step_ins = FALSE;
-
- if ( pRec->Cur_Count > 0 )
- {
- exc->callTop++;
- exc->IP = pRec->Def->start;
- }
- else
- /* Loop through the current function */
- Ins_Goto_CodeRange( exc, pRec->Caller_Range, pRec->Caller_IP );
-
- /* Exit the current call frame. */
-
- /* NOTE: If the last instruction of a program is a */
- /* CALL or LOOPCALL, the return address is */
- /* always out of the code range. This is a */
- /* valid address, and it is why we do not test */
- /* the result of Ins_Goto_CodeRange() here! */
- }
-
-
- /**************************************************************************
- *
- * CALL[]: CALL function
- * Opcode range: 0x2B
- * Stack: uint32? -->
- */
- static void
- Ins_CALL( TT_ExecContext exc,
- FT_Long* args )
- {
- FT_ULong F;
- TT_CallRec* pCrec;
- TT_DefRecord* def;
-
-
- /* first of all, check the index */
-
- F = (FT_ULong)args[0];
- if ( BOUNDSL( F, exc->maxFunc + 1 ) )
- goto Fail;
-
- if ( !exc->FDefs )
- goto Fail;
-
- /* Except for some old Apple fonts, all functions in a TrueType */
- /* font are defined in increasing order, starting from 0. This */
- /* means that we normally have */
- /* */
- /* exc->maxFunc+1 == exc->numFDefs */
- /* exc->FDefs[n].opc == n for n in 0..exc->maxFunc */
- /* */
- /* If this isn't true, we need to look up the function table. */
-
- def = exc->FDefs + F;
- if ( exc->maxFunc + 1 != exc->numFDefs || def->opc != F )
- {
- /* look up the FDefs table */
- TT_DefRecord* limit;
-
-
- def = exc->FDefs;
- limit = def + exc->numFDefs;
-
- while ( def < limit && def->opc != F )
- def++;
-
- if ( def == limit )
- goto Fail;
- }
-
- /* check that the function is active */
- if ( !def->active )
- goto Fail;
-
- /* check the call stack */
- if ( exc->callTop >= exc->callSize )
- {
- exc->error = FT_THROW( Stack_Overflow );
- return;
- }
-
- pCrec = exc->callStack + exc->callTop;
-
- pCrec->Caller_Range = exc->curRange;
- pCrec->Caller_IP = exc->IP + 1;
- pCrec->Cur_Count = 1;
- pCrec->Def = def;
-
- exc->callTop++;
-
- Ins_Goto_CodeRange( exc, def->range, def->start );
-
- exc->step_ins = FALSE;
-
- return;
-
- Fail:
- exc->error = FT_THROW( Invalid_Reference );
- }
-
-
- /**************************************************************************
- *
- * LOOPCALL[]: LOOP and CALL function
- * Opcode range: 0x2A
- * Stack: uint32? Eint16? -->
- */
- static void
- Ins_LOOPCALL( TT_ExecContext exc,
- FT_Long* args )
- {
- FT_ULong F;
- TT_CallRec* pCrec;
- TT_DefRecord* def;
-
-
- /* first of all, check the index */
- F = (FT_ULong)args[1];
- if ( BOUNDSL( F, exc->maxFunc + 1 ) )
- goto Fail;
-
- /* Except for some old Apple fonts, all functions in a TrueType */
- /* font are defined in increasing order, starting from 0. This */
- /* means that we normally have */
- /* */
- /* exc->maxFunc+1 == exc->numFDefs */
- /* exc->FDefs[n].opc == n for n in 0..exc->maxFunc */
- /* */
- /* If this isn't true, we need to look up the function table. */
-
- def = FT_OFFSET( exc->FDefs, F );
- if ( exc->maxFunc + 1 != exc->numFDefs || def->opc != F )
- {
- /* look up the FDefs table */
- TT_DefRecord* limit;
-
-
- def = exc->FDefs;
- limit = FT_OFFSET( def, exc->numFDefs );
-
- while ( def < limit && def->opc != F )
- def++;
-
- if ( def == limit )
- goto Fail;
- }
-
- /* check that the function is active */
- if ( !def->active )
- goto Fail;
-
- /* check stack */
- if ( exc->callTop >= exc->callSize )
- {
- exc->error = FT_THROW( Stack_Overflow );
- return;
- }
-
- if ( args[0] > 0 )
- {
- pCrec = exc->callStack + exc->callTop;
-
- pCrec->Caller_Range = exc->curRange;
- pCrec->Caller_IP = exc->IP + 1;
- pCrec->Cur_Count = (FT_Int)args[0];
- pCrec->Def = def;
-
- exc->callTop++;
-
- Ins_Goto_CodeRange( exc, def->range, def->start );
-
- exc->step_ins = FALSE;
-
- exc->loopcall_counter += (FT_ULong)args[0];
- if ( exc->loopcall_counter > exc->loopcall_counter_max )
- exc->error = FT_THROW( Execution_Too_Long );
- }
-
- return;
-
- Fail:
- exc->error = FT_THROW( Invalid_Reference );
- }
-
-
- /**************************************************************************
- *
- * IDEF[]: Instruction DEFinition
- * Opcode range: 0x89
- * Stack: Eint8 -->
- */
- static void
- Ins_IDEF( TT_ExecContext exc,
- FT_Long* args )
- {
- TT_DefRecord* def;
- TT_DefRecord* limit;
-
-
- /* we enable IDEF only in `prep' or `fpgm' */
- if ( exc->iniRange == tt_coderange_glyph )
- {
- exc->error = FT_THROW( DEF_In_Glyf_Bytecode );
- return;
- }
-
- /* First of all, look for the same function in our table */
-
- def = exc->IDefs;
- limit = FT_OFFSET( def, exc->numIDefs );
-
- for ( ; def < limit; def++ )
- if ( def->opc == (FT_ULong)args[0] )
- break;
-
- if ( def == limit )
- {
- /* check that there is enough room for a new instruction */
- if ( exc->numIDefs >= exc->maxIDefs )
- {
- exc->error = FT_THROW( Too_Many_Instruction_Defs );
- return;
- }
- exc->numIDefs++;
- }
-
- /* opcode must be unsigned 8-bit integer */
- if ( 0 > args[0] || args[0] > 0x00FF )
- {
- exc->error = FT_THROW( Too_Many_Instruction_Defs );
- return;
- }
-
- def->opc = (FT_Byte)args[0];
- def->start = exc->IP + 1;
- def->range = exc->curRange;
- def->active = TRUE;
-
- if ( (FT_ULong)args[0] > exc->maxIns )
- exc->maxIns = (FT_Byte)args[0];
-
- /* Now skip the whole function definition. */
- /* We don't allow nested IDEFs & FDEFs. */
-
- while ( SkipCode( exc ) == SUCCESS )
- {
- switch ( exc->opcode )
- {
- case 0x89: /* IDEF */
- case 0x2C: /* FDEF */
- exc->error = FT_THROW( Nested_DEFS );
- return;
- case 0x2D: /* ENDF */
- def->end = exc->IP;
- return;
- }
- }
- }
-
-
- /**************************************************************************
- *
- * PUSHING DATA ONTO THE INTERPRETER STACK
- *
- */
-
-
- /**************************************************************************
- *
- * NPUSHB[]: PUSH N Bytes
- * Opcode range: 0x40
- * Stack: --> uint32...
- */
- static void
- Ins_NPUSHB( TT_ExecContext exc,
- FT_Long* args )
- {
- FT_UShort L, K;
-
-
- L = (FT_UShort)exc->code[exc->IP + 1];
-
- if ( BOUNDS( L, exc->stackSize + 1 - exc->top ) )
- {
- exc->error = FT_THROW( Stack_Overflow );
- return;
- }
-
- for ( K = 1; K <= L; K++ )
- args[K - 1] = exc->code[exc->IP + K + 1];
-
- exc->new_top += L;
- }
-
-
- /**************************************************************************
- *
- * NPUSHW[]: PUSH N Words
- * Opcode range: 0x41
- * Stack: --> int32...
- */
- static void
- Ins_NPUSHW( TT_ExecContext exc,
- FT_Long* args )
- {
- FT_UShort L, K;
-
-
- L = (FT_UShort)exc->code[exc->IP + 1];
-
- if ( BOUNDS( L, exc->stackSize + 1 - exc->top ) )
- {
- exc->error = FT_THROW( Stack_Overflow );
- return;
- }
-
- exc->IP += 2;
-
- for ( K = 0; K < L; K++ )
- args[K] = GetShortIns( exc );
-
- exc->step_ins = FALSE;
- exc->new_top += L;
- }
-
-
- /**************************************************************************
- *
- * PUSHB[abc]: PUSH Bytes
- * Opcode range: 0xB0-0xB7
- * Stack: --> uint32...
- */
- static void
- Ins_PUSHB( TT_ExecContext exc,
- FT_Long* args )
- {
- FT_UShort L, K;
-
-
- L = (FT_UShort)( exc->opcode - 0xB0 + 1 );
-
- if ( BOUNDS( L, exc->stackSize + 1 - exc->top ) )
- {
- exc->error = FT_THROW( Stack_Overflow );
- return;
- }
-
- for ( K = 1; K <= L; K++ )
- args[K - 1] = exc->code[exc->IP + K];
- }
-
-
- /**************************************************************************
- *
- * PUSHW[abc]: PUSH Words
- * Opcode range: 0xB8-0xBF
- * Stack: --> int32...
- */
- static void
- Ins_PUSHW( TT_ExecContext exc,
- FT_Long* args )
- {
- FT_UShort L, K;
-
-
- L = (FT_UShort)( exc->opcode - 0xB8 + 1 );
-
- if ( BOUNDS( L, exc->stackSize + 1 - exc->top ) )
- {
- exc->error = FT_THROW( Stack_Overflow );
- return;
- }
-
- exc->IP++;
-
- for ( K = 0; K < L; K++ )
- args[K] = GetShortIns( exc );
-
- exc->step_ins = FALSE;
- }
-
-
- /**************************************************************************
- *
- * MANAGING THE GRAPHICS STATE
- *
- */
-
-
- static FT_Bool
- Ins_SxVTL( TT_ExecContext exc,
- FT_UShort aIdx1,
- FT_UShort aIdx2,
- FT_UnitVector* Vec )
- {
- FT_Long A, B, C;
- FT_Vector* p1;
- FT_Vector* p2;
-
- FT_Byte opcode = exc->opcode;
-
-
- if ( BOUNDS( aIdx1, exc->zp2.n_points ) ||
- BOUNDS( aIdx2, exc->zp1.n_points ) )
- {
- if ( exc->pedantic_hinting )
- exc->error = FT_THROW( Invalid_Reference );
- return FAILURE;
- }
-
- p1 = exc->zp1.cur + aIdx2;
- p2 = exc->zp2.cur + aIdx1;
-
- A = SUB_LONG( p1->x, p2->x );
- B = SUB_LONG( p1->y, p2->y );
-
- /* If p1 == p2, SPvTL and SFvTL behave the same as */
- /* SPvTCA[X] and SFvTCA[X], respectively. */
- /* */
- /* Confirmed by Greg Hitchcock. */
-
- if ( A == 0 && B == 0 )
- {
- A = 0x4000;
- opcode = 0;
- }
-
- if ( ( opcode & 1 ) != 0 )
- {
- C = B; /* counter-clockwise rotation */
- B = A;
- A = NEG_LONG( C );
- }
-
- Normalize( A, B, Vec );
-
- return SUCCESS;
- }
-
-
- /**************************************************************************
- *
- * SVTCA[a]: Set (F and P) Vectors to Coordinate Axis
- * Opcode range: 0x00-0x01
- * Stack: -->
- *
- * SPvTCA[a]: Set PVector to Coordinate Axis
- * Opcode range: 0x02-0x03
- * Stack: -->
- *
- * SFvTCA[a]: Set FVector to Coordinate Axis
- * Opcode range: 0x04-0x05
- * Stack: -->
- */
- static void
- Ins_SxyTCA( TT_ExecContext exc )
- {
- FT_Short AA, BB;
-
- FT_Byte opcode = exc->opcode;
-
-
- AA = (FT_Short)( ( opcode & 1 ) << 14 );
- BB = (FT_Short)( AA ^ 0x4000 );
-
- if ( opcode < 4 )
- {
- exc->GS.projVector.x = AA;
- exc->GS.projVector.y = BB;
-
- exc->GS.dualVector.x = AA;
- exc->GS.dualVector.y = BB;
- }
-
- if ( ( opcode & 2 ) == 0 )
- {
- exc->GS.freeVector.x = AA;
- exc->GS.freeVector.y = BB;
- }
-
- Compute_Funcs( exc );
- }
-
-
- /**************************************************************************
- *
- * SPvTL[a]: Set PVector To Line
- * Opcode range: 0x06-0x07
- * Stack: uint32 uint32 -->
- */
- static void
- Ins_SPVTL( TT_ExecContext exc,
- FT_Long* args )
- {
- if ( Ins_SxVTL( exc,
- (FT_UShort)args[1],
- (FT_UShort)args[0],
- &exc->GS.projVector ) == SUCCESS )
- {
- exc->GS.dualVector = exc->GS.projVector;
- Compute_Funcs( exc );
- }
- }
-
-
- /**************************************************************************
- *
- * SFvTL[a]: Set FVector To Line
- * Opcode range: 0x08-0x09
- * Stack: uint32 uint32 -->
- */
- static void
- Ins_SFVTL( TT_ExecContext exc,
- FT_Long* args )
- {
- if ( Ins_SxVTL( exc,
- (FT_UShort)args[1],
- (FT_UShort)args[0],
- &exc->GS.freeVector ) == SUCCESS )
- {
- Compute_Funcs( exc );
- }
- }
-
-
- /**************************************************************************
- *
- * SFvTPv[]: Set FVector To PVector
- * Opcode range: 0x0E
- * Stack: -->
- */
- static void
- Ins_SFVTPV( TT_ExecContext exc )
- {
- exc->GS.freeVector = exc->GS.projVector;
- Compute_Funcs( exc );
- }
-
-
- /**************************************************************************
- *
- * SPvFS[]: Set PVector From Stack
- * Opcode range: 0x0A
- * Stack: f2.14 f2.14 -->
- */
- static void
- Ins_SPVFS( TT_ExecContext exc,
- FT_Long* args )
- {
- FT_Short S;
- FT_Long X, Y;
-
-
- /* Only use low 16bits, then sign extend */
- S = (FT_Short)args[1];
- Y = (FT_Long)S;
- S = (FT_Short)args[0];
- X = (FT_Long)S;
-
- Normalize( X, Y, &exc->GS.projVector );
-
- exc->GS.dualVector = exc->GS.projVector;
- Compute_Funcs( exc );
- }
-
-
- /**************************************************************************
- *
- * SFvFS[]: Set FVector From Stack
- * Opcode range: 0x0B
- * Stack: f2.14 f2.14 -->
- */
- static void
- Ins_SFVFS( TT_ExecContext exc,
- FT_Long* args )
- {
- FT_Short S;
- FT_Long X, Y;
-
-
- /* Only use low 16bits, then sign extend */
- S = (FT_Short)args[1];
- Y = (FT_Long)S;
- S = (FT_Short)args[0];
- X = S;
-
- Normalize( X, Y, &exc->GS.freeVector );
- Compute_Funcs( exc );
- }
-
-
- /**************************************************************************
- *
- * GPv[]: Get Projection Vector
- * Opcode range: 0x0C
- * Stack: ef2.14 --> ef2.14
- */
- static void
- Ins_GPV( TT_ExecContext exc,
- FT_Long* args )
- {
- args[0] = exc->GS.projVector.x;
- args[1] = exc->GS.projVector.y;
- }
-
-
- /**************************************************************************
- *
- * GFv[]: Get Freedom Vector
- * Opcode range: 0x0D
- * Stack: ef2.14 --> ef2.14
- */
- static void
- Ins_GFV( TT_ExecContext exc,
- FT_Long* args )
- {
- args[0] = exc->GS.freeVector.x;
- args[1] = exc->GS.freeVector.y;
- }
-
-
- /**************************************************************************
- *
- * SRP0[]: Set Reference Point 0
- * Opcode range: 0x10
- * Stack: uint32 -->
- */
- static void
- Ins_SRP0( TT_ExecContext exc,
- FT_Long* args )
- {
- exc->GS.rp0 = (FT_UShort)args[0];
- }
-
-
- /**************************************************************************
- *
- * SRP1[]: Set Reference Point 1
- * Opcode range: 0x11
- * Stack: uint32 -->
- */
- static void
- Ins_SRP1( TT_ExecContext exc,
- FT_Long* args )
- {
- exc->GS.rp1 = (FT_UShort)args[0];
- }
-
-
- /**************************************************************************
- *
- * SRP2[]: Set Reference Point 2
- * Opcode range: 0x12
- * Stack: uint32 -->
- */
- static void
- Ins_SRP2( TT_ExecContext exc,
- FT_Long* args )
- {
- exc->GS.rp2 = (FT_UShort)args[0];
- }
-
-
- /**************************************************************************
- *
- * SMD[]: Set Minimum Distance
- * Opcode range: 0x1A
- * Stack: f26.6 -->
- */
- static void
- Ins_SMD( TT_ExecContext exc,
- FT_Long* args )
- {
- exc->GS.minimum_distance = args[0];
- }
-
-
- /**************************************************************************
- *
- * SCVTCI[]: Set Control Value Table Cut In
- * Opcode range: 0x1D
- * Stack: f26.6 -->
- */
- static void
- Ins_SCVTCI( TT_ExecContext exc,
- FT_Long* args )
- {
- exc->GS.control_value_cutin = (FT_F26Dot6)args[0];
- }
-
-
- /**************************************************************************
- *
- * SSWCI[]: Set Single Width Cut In
- * Opcode range: 0x1E
- * Stack: f26.6 -->
- */
- static void
- Ins_SSWCI( TT_ExecContext exc,
- FT_Long* args )
- {
- exc->GS.single_width_cutin = (FT_F26Dot6)args[0];
- }
-
-
- /**************************************************************************
- *
- * SSW[]: Set Single Width
- * Opcode range: 0x1F
- * Stack: int32? -->
- */
- static void
- Ins_SSW( TT_ExecContext exc,
- FT_Long* args )
- {
- exc->GS.single_width_value = FT_MulFix( args[0],
- exc->tt_metrics.scale );
- }
-
-
- /**************************************************************************
- *
- * FLIPON[]: Set auto-FLIP to ON
- * Opcode range: 0x4D
- * Stack: -->
- */
- static void
- Ins_FLIPON( TT_ExecContext exc )
- {
- exc->GS.auto_flip = TRUE;
- }
-
-
- /**************************************************************************
- *
- * FLIPOFF[]: Set auto-FLIP to OFF
- * Opcode range: 0x4E
- * Stack: -->
- */
- static void
- Ins_FLIPOFF( TT_ExecContext exc )
- {
- exc->GS.auto_flip = FALSE;
- }
-
-
- /**************************************************************************
- *
- * SANGW[]: Set ANGle Weight
- * Opcode range: 0x7E
- * Stack: uint32 -->
- */
- static void
- Ins_SANGW( void )
- {
- /* instruction not supported anymore */
- }
-
-
- /**************************************************************************
- *
- * SDB[]: Set Delta Base
- * Opcode range: 0x5E
- * Stack: uint32 -->
- */
- static void
- Ins_SDB( TT_ExecContext exc,
- FT_Long* args )
- {
- exc->GS.delta_base = (FT_UShort)args[0];
- }
-
-
- /**************************************************************************
- *
- * SDS[]: Set Delta Shift
- * Opcode range: 0x5F
- * Stack: uint32 -->
- */
- static void
- Ins_SDS( TT_ExecContext exc,
- FT_Long* args )
- {
- if ( (FT_ULong)args[0] > 6UL )
- exc->error = FT_THROW( Bad_Argument );
- else
- exc->GS.delta_shift = (FT_UShort)args[0];
- }
-
-
- /**************************************************************************
- *
- * RTHG[]: Round To Half Grid
- * Opcode range: 0x19
- * Stack: -->
- */
- static void
- Ins_RTHG( TT_ExecContext exc )
- {
- exc->GS.round_state = TT_Round_To_Half_Grid;
- exc->func_round = (TT_Round_Func)Round_To_Half_Grid;
- }
-
-
- /**************************************************************************
- *
- * RTG[]: Round To Grid
- * Opcode range: 0x18
- * Stack: -->
- */
- static void
- Ins_RTG( TT_ExecContext exc )
- {
- exc->GS.round_state = TT_Round_To_Grid;
- exc->func_round = (TT_Round_Func)Round_To_Grid;
- }
-
-
- /**************************************************************************
- * RTDG[]: Round To Double Grid
- * Opcode range: 0x3D
- * Stack: -->
- */
- static void
- Ins_RTDG( TT_ExecContext exc )
- {
- exc->GS.round_state = TT_Round_To_Double_Grid;
- exc->func_round = (TT_Round_Func)Round_To_Double_Grid;
- }
-
-
- /**************************************************************************
- * RUTG[]: Round Up To Grid
- * Opcode range: 0x7C
- * Stack: -->
- */
- static void
- Ins_RUTG( TT_ExecContext exc )
- {
- exc->GS.round_state = TT_Round_Up_To_Grid;
- exc->func_round = (TT_Round_Func)Round_Up_To_Grid;
- }
-
-
- /**************************************************************************
- *
- * RDTG[]: Round Down To Grid
- * Opcode range: 0x7D
- * Stack: -->
- */
- static void
- Ins_RDTG( TT_ExecContext exc )
- {
- exc->GS.round_state = TT_Round_Down_To_Grid;
- exc->func_round = (TT_Round_Func)Round_Down_To_Grid;
- }
-
-
- /**************************************************************************
- *
- * ROFF[]: Round OFF
- * Opcode range: 0x7A
- * Stack: -->
- */
- static void
- Ins_ROFF( TT_ExecContext exc )
- {
- exc->GS.round_state = TT_Round_Off;
- exc->func_round = (TT_Round_Func)Round_None;
- }
-
-
- /**************************************************************************
- *
- * SROUND[]: Super ROUND
- * Opcode range: 0x76
- * Stack: Eint8 -->
- */
- static void
- Ins_SROUND( TT_ExecContext exc,
- FT_Long* args )
- {
- SetSuperRound( exc, 0x4000, args[0] );
-
- exc->GS.round_state = TT_Round_Super;
- exc->func_round = (TT_Round_Func)Round_Super;
- }
-
-
- /**************************************************************************
- *
- * S45ROUND[]: Super ROUND 45 degrees
- * Opcode range: 0x77
- * Stack: uint32 -->
- */
- static void
- Ins_S45ROUND( TT_ExecContext exc,
- FT_Long* args )
- {
- SetSuperRound( exc, 0x2D41, args[0] );
-
- exc->GS.round_state = TT_Round_Super_45;
- exc->func_round = (TT_Round_Func)Round_Super_45;
- }
-
-
- /**************************************************************************
- *
- * GC[a]: Get Coordinate projected onto
- * Opcode range: 0x46-0x47
- * Stack: uint32 --> f26.6
- *
- * XXX: UNDOCUMENTED: Measures from the original glyph must be taken
- * along the dual projection vector!
- */
- static void
- Ins_GC( TT_ExecContext exc,
- FT_Long* args )
- {
- FT_ULong L;
- FT_F26Dot6 R;
-
-
- L = (FT_ULong)args[0];
-
- if ( BOUNDSL( L, exc->zp2.n_points ) )
- {
- if ( exc->pedantic_hinting )
- exc->error = FT_THROW( Invalid_Reference );
- R = 0;
- }
- else
- {
- if ( exc->opcode & 1 )
- R = FAST_DUALPROJ( &exc->zp2.org[L] );
- else
- R = FAST_PROJECT( &exc->zp2.cur[L] );
- }
-
- args[0] = R;
- }
-
-
- /**************************************************************************
- *
- * SCFS[]: Set Coordinate From Stack
- * Opcode range: 0x48
- * Stack: f26.6 uint32 -->
- *
- * Formula:
- *
- * OA := OA + ( value - OA.p )/( f.p ) * f
- */
- static void
- Ins_SCFS( TT_ExecContext exc,
- FT_Long* args )
- {
- FT_Long K;
- FT_UShort L;
-
-
- L = (FT_UShort)args[0];
-
- if ( BOUNDS( L, exc->zp2.n_points ) )
- {
- if ( exc->pedantic_hinting )
- exc->error = FT_THROW( Invalid_Reference );
- return;
- }
-
- K = FAST_PROJECT( &exc->zp2.cur[L] );
-
- exc->func_move( exc, &exc->zp2, L, SUB_LONG( args[1], K ) );
-
- /* UNDOCUMENTED! The MS rasterizer does that with */
- /* twilight points (confirmed by Greg Hitchcock) */
- if ( exc->GS.gep2 == 0 )
- exc->zp2.org[L] = exc->zp2.cur[L];
- }
-
-
- /**************************************************************************
- *
- * MD[a]: Measure Distance
- * Opcode range: 0x49-0x4A
- * Stack: uint32 uint32 --> f26.6
- *
- * XXX: UNDOCUMENTED: Measure taken in the original glyph must be along
- * the dual projection vector.
- *
- * XXX: UNDOCUMENTED: Flag attributes are inverted!
- * 0 => measure distance in original outline
- * 1 => measure distance in grid-fitted outline
- *
- * XXX: UNDOCUMENTED: `zp0 - zp1', and not `zp2 - zp1!
- */
- static void
- Ins_MD( TT_ExecContext exc,
- FT_Long* args )
- {
- FT_UShort K, L;
- FT_F26Dot6 D;
-
-
- K = (FT_UShort)args[1];
- L = (FT_UShort)args[0];
-
- if ( BOUNDS( L, exc->zp0.n_points ) ||
- BOUNDS( K, exc->zp1.n_points ) )
- {
- if ( exc->pedantic_hinting )
- exc->error = FT_THROW( Invalid_Reference );
- D = 0;
- }
- else
- {
- if ( exc->opcode & 1 )
- D = PROJECT( exc->zp0.cur + L, exc->zp1.cur + K );
- else
- {
- /* XXX: UNDOCUMENTED: twilight zone special case */
-
- if ( exc->GS.gep0 == 0 || exc->GS.gep1 == 0 )
- {
- FT_Vector* vec1 = exc->zp0.org + L;
- FT_Vector* vec2 = exc->zp1.org + K;
-
-
- D = DUALPROJ( vec1, vec2 );
- }
- else
- {
- FT_Vector* vec1 = exc->zp0.orus + L;
- FT_Vector* vec2 = exc->zp1.orus + K;
-
-
- if ( exc->metrics.x_scale == exc->metrics.y_scale )
- {
- /* this should be faster */
- D = DUALPROJ( vec1, vec2 );
- D = FT_MulFix( D, exc->metrics.x_scale );
- }
- else
- {
- FT_Vector vec;
-
-
- vec.x = FT_MulFix( vec1->x - vec2->x, exc->metrics.x_scale );
- vec.y = FT_MulFix( vec1->y - vec2->y, exc->metrics.y_scale );
-
- D = FAST_DUALPROJ( &vec );
- }
- }
- }
- }
-
- args[0] = D;
- }
-
-
- /**************************************************************************
- *
- * SDPvTL[a]: Set Dual PVector to Line
- * Opcode range: 0x86-0x87
- * Stack: uint32 uint32 -->
- */
- static void
- Ins_SDPVTL( TT_ExecContext exc,
- FT_Long* args )
- {
- FT_Long A, B, C;
- FT_UShort p1, p2; /* was FT_Int in pas type ERROR */
-
- FT_Byte opcode = exc->opcode;
-
-
- p1 = (FT_UShort)args[1];
- p2 = (FT_UShort)args[0];
-
- if ( BOUNDS( p2, exc->zp1.n_points ) ||
- BOUNDS( p1, exc->zp2.n_points ) )
- {
- if ( exc->pedantic_hinting )
- exc->error = FT_THROW( Invalid_Reference );
- return;
- }
-
- {
- FT_Vector* v1 = exc->zp1.org + p2;
- FT_Vector* v2 = exc->zp2.org + p1;
-
-
- A = SUB_LONG( v1->x, v2->x );
- B = SUB_LONG( v1->y, v2->y );
-
- /* If v1 == v2, SDPvTL behaves the same as */
- /* SVTCA[X], respectively. */
- /* */
- /* Confirmed by Greg Hitchcock. */
-
- if ( A == 0 && B == 0 )
- {
- A = 0x4000;
- opcode = 0;
- }
- }
-
- if ( ( opcode & 1 ) != 0 )
- {
- C = B; /* counter-clockwise rotation */
- B = A;
- A = NEG_LONG( C );
- }
-
- Normalize( A, B, &exc->GS.dualVector );
-
- {
- FT_Vector* v1 = exc->zp1.cur + p2;
- FT_Vector* v2 = exc->zp2.cur + p1;
-
-
- A = SUB_LONG( v1->x, v2->x );
- B = SUB_LONG( v1->y, v2->y );
-
- if ( A == 0 && B == 0 )
- {
- A = 0x4000;
- opcode = 0;
- }
- }
-
- if ( ( opcode & 1 ) != 0 )
- {
- C = B; /* counter-clockwise rotation */
- B = A;
- A = NEG_LONG( C );
- }
-
- Normalize( A, B, &exc->GS.projVector );
- Compute_Funcs( exc );
- }
-
-
- /**************************************************************************
- *
- * SZP0[]: Set Zone Pointer 0
- * Opcode range: 0x13
- * Stack: uint32 -->
- */
- static void
- Ins_SZP0( TT_ExecContext exc,
- FT_Long* args )
- {
- switch ( (FT_Int)args[0] )
- {
- case 0:
- exc->zp0 = exc->twilight;
- break;
-
- case 1:
- exc->zp0 = exc->pts;
- break;
-
- default:
- if ( exc->pedantic_hinting )
- exc->error = FT_THROW( Invalid_Reference );
- return;
- }
-
- exc->GS.gep0 = (FT_UShort)args[0];
- }
-
-
- /**************************************************************************
- *
- * SZP1[]: Set Zone Pointer 1
- * Opcode range: 0x14
- * Stack: uint32 -->
- */
- static void
- Ins_SZP1( TT_ExecContext exc,
- FT_Long* args )
- {
- switch ( (FT_Int)args[0] )
- {
- case 0:
- exc->zp1 = exc->twilight;
- break;
-
- case 1:
- exc->zp1 = exc->pts;
- break;
-
- default:
- if ( exc->pedantic_hinting )
- exc->error = FT_THROW( Invalid_Reference );
- return;
- }
-
- exc->GS.gep1 = (FT_UShort)args[0];
- }
-
-
- /**************************************************************************
- *
- * SZP2[]: Set Zone Pointer 2
- * Opcode range: 0x15
- * Stack: uint32 -->
- */
- static void
- Ins_SZP2( TT_ExecContext exc,
- FT_Long* args )
- {
- switch ( (FT_Int)args[0] )
- {
- case 0:
- exc->zp2 = exc->twilight;
- break;
-
- case 1:
- exc->zp2 = exc->pts;
- break;
-
- default:
- if ( exc->pedantic_hinting )
- exc->error = FT_THROW( Invalid_Reference );
- return;
- }
-
- exc->GS.gep2 = (FT_UShort)args[0];
- }
-
-
- /**************************************************************************
- *
- * SZPS[]: Set Zone PointerS
- * Opcode range: 0x16
- * Stack: uint32 -->
- */
- static void
- Ins_SZPS( TT_ExecContext exc,
- FT_Long* args )
- {
- switch ( (FT_Int)args[0] )
- {
- case 0:
- exc->zp0 = exc->twilight;
- break;
-
- case 1:
- exc->zp0 = exc->pts;
- break;
-
- default:
- if ( exc->pedantic_hinting )
- exc->error = FT_THROW( Invalid_Reference );
- return;
- }
-
- exc->zp1 = exc->zp0;
- exc->zp2 = exc->zp0;
-
- exc->GS.gep0 = (FT_UShort)args[0];
- exc->GS.gep1 = (FT_UShort)args[0];
- exc->GS.gep2 = (FT_UShort)args[0];
- }
-
-
- /**************************************************************************
- *
- * INSTCTRL[]: INSTruction ConTRoL
- * Opcode range: 0x8E
- * Stack: int32 int32 -->
- */
- static void
- Ins_INSTCTRL( TT_ExecContext exc,
- FT_Long* args )
- {
- FT_ULong K, L, Kf;
-
-
- K = (FT_ULong)args[1];
- L = (FT_ULong)args[0];
-
- /* selector values cannot be `OR'ed; */
- /* they are indices starting with index 1, not flags */
- if ( K < 1 || K > 3 )
- {
- if ( exc->pedantic_hinting )
- exc->error = FT_THROW( Invalid_Reference );
- return;
- }
-
- /* convert index to flag value */
- Kf = 1 << ( K - 1 );
-
- if ( L != 0 )
- {
- /* arguments to selectors look like flag values */
- if ( L != Kf )
- {
- if ( exc->pedantic_hinting )
- exc->error = FT_THROW( Invalid_Reference );
- return;
- }
- }
-
- /* INSTCTRL should only be used in the CVT program */
- if ( exc->iniRange == tt_coderange_cvt )
- {
- exc->GS.instruct_control &= ~(FT_Byte)Kf;
- exc->GS.instruct_control |= (FT_Byte)L;
- }
-
- /* except to change the subpixel flags temporarily */
- else if ( exc->iniRange == tt_coderange_glyph && K == 3 )
- {
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- /* Native ClearType fonts sign a waiver that turns off all backward */
- /* compatibility hacks and lets them program points to the grid like */
- /* it's 1996. They might sign a waiver for just one glyph, though. */
- if ( SUBPIXEL_HINTING_MINIMAL )
- exc->backward_compatibility = !FT_BOOL( L == 4 );
-#endif
- }
- else if ( exc->pedantic_hinting )
- exc->error = FT_THROW( Invalid_Reference );
- }
-
-
- /**************************************************************************
- *
- * SCANCTRL[]: SCAN ConTRoL
- * Opcode range: 0x85
- * Stack: uint32? -->
- */
- static void
- Ins_SCANCTRL( TT_ExecContext exc,
- FT_Long* args )
- {
- FT_Int A;
-
-
- /* Get Threshold */
- A = (FT_Int)( args[0] & 0xFF );
-
- if ( A == 0xFF )
- {
- exc->GS.scan_control = TRUE;
- return;
- }
- else if ( A == 0 )
- {
- exc->GS.scan_control = FALSE;
- return;
- }
-
- if ( ( args[0] & 0x100 ) != 0 && exc->tt_metrics.ppem <= A )
- exc->GS.scan_control = TRUE;
-
- if ( ( args[0] & 0x200 ) != 0 && exc->tt_metrics.rotated )
- exc->GS.scan_control = TRUE;
-
- if ( ( args[0] & 0x400 ) != 0 && exc->tt_metrics.stretched )
- exc->GS.scan_control = TRUE;
-
- if ( ( args[0] & 0x800 ) != 0 && exc->tt_metrics.ppem > A )
- exc->GS.scan_control = FALSE;
-
- if ( ( args[0] & 0x1000 ) != 0 && exc->tt_metrics.rotated )
- exc->GS.scan_control = FALSE;
-
- if ( ( args[0] & 0x2000 ) != 0 && exc->tt_metrics.stretched )
- exc->GS.scan_control = FALSE;
- }
-
-
- /**************************************************************************
- *
- * SCANTYPE[]: SCAN TYPE
- * Opcode range: 0x8D
- * Stack: uint16 -->
- */
- static void
- Ins_SCANTYPE( TT_ExecContext exc,
- FT_Long* args )
- {
- if ( args[0] >= 0 )
- exc->GS.scan_type = (FT_Int)args[0] & 0xFFFF;
- }
-
-
- /**************************************************************************
- *
- * MANAGING OUTLINES
- *
- */
-
-
- /**************************************************************************
- *
- * FLIPPT[]: FLIP PoinT
- * Opcode range: 0x80
- * Stack: uint32... -->
- */
- static void
- Ins_FLIPPT( TT_ExecContext exc )
- {
- FT_UShort point;
-
-
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- /* See `ttinterp.h' for details on backward compatibility mode. */
- if ( SUBPIXEL_HINTING_MINIMAL &&
- exc->backward_compatibility &&
- exc->iupx_called &&
- exc->iupy_called )
- goto Fail;
-#endif
-
- if ( exc->top < exc->GS.loop )
- {
- if ( exc->pedantic_hinting )
- exc->error = FT_THROW( Too_Few_Arguments );
- goto Fail;
- }
-
- while ( exc->GS.loop > 0 )
- {
- exc->args--;
-
- point = (FT_UShort)exc->stack[exc->args];
-
- if ( BOUNDS( point, exc->pts.n_points ) )
- {
- if ( exc->pedantic_hinting )
- {
- exc->error = FT_THROW( Invalid_Reference );
- return;
- }
- }
- else
- exc->pts.tags[point] ^= FT_CURVE_TAG_ON;
-
- exc->GS.loop--;
- }
-
- Fail:
- exc->GS.loop = 1;
- exc->new_top = exc->args;
- }
-
-
- /**************************************************************************
- *
- * FLIPRGON[]: FLIP RanGe ON
- * Opcode range: 0x81
- * Stack: uint32 uint32 -->
- */
- static void
- Ins_FLIPRGON( TT_ExecContext exc,
- FT_Long* args )
- {
- FT_UShort I, K, L;
-
-
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- /* See `ttinterp.h' for details on backward compatibility mode. */
- if ( SUBPIXEL_HINTING_MINIMAL &&
- exc->backward_compatibility &&
- exc->iupx_called &&
- exc->iupy_called )
- return;
-#endif
-
- K = (FT_UShort)args[1];
- L = (FT_UShort)args[0];
-
- if ( BOUNDS( K, exc->pts.n_points ) ||
- BOUNDS( L, exc->pts.n_points ) )
- {
- if ( exc->pedantic_hinting )
- exc->error = FT_THROW( Invalid_Reference );
- return;
- }
-
- for ( I = L; I <= K; I++ )
- exc->pts.tags[I] |= FT_CURVE_TAG_ON;
- }
-
-
- /**************************************************************************
- *
- * FLIPRGOFF: FLIP RanGe OFF
- * Opcode range: 0x82
- * Stack: uint32 uint32 -->
- */
- static void
- Ins_FLIPRGOFF( TT_ExecContext exc,
- FT_Long* args )
- {
- FT_UShort I, K, L;
-
-
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- /* See `ttinterp.h' for details on backward compatibility mode. */
- if ( SUBPIXEL_HINTING_MINIMAL &&
- exc->backward_compatibility &&
- exc->iupx_called &&
- exc->iupy_called )
- return;
-#endif
-
- K = (FT_UShort)args[1];
- L = (FT_UShort)args[0];
-
- if ( BOUNDS( K, exc->pts.n_points ) ||
- BOUNDS( L, exc->pts.n_points ) )
- {
- if ( exc->pedantic_hinting )
- exc->error = FT_THROW( Invalid_Reference );
- return;
- }
-
- for ( I = L; I <= K; I++ )
- exc->pts.tags[I] &= ~FT_CURVE_TAG_ON;
- }
-
-
- static FT_Bool
- Compute_Point_Displacement( TT_ExecContext exc,
- FT_F26Dot6* x,
- FT_F26Dot6* y,
- TT_GlyphZone zone,
- FT_UShort* refp )
- {
- TT_GlyphZoneRec zp;
- FT_UShort p;
- FT_F26Dot6 d;
-
-
- if ( exc->opcode & 1 )
- {
- zp = exc->zp0;
- p = exc->GS.rp1;
- }
- else
- {
- zp = exc->zp1;
- p = exc->GS.rp2;
- }
-
- if ( BOUNDS( p, zp.n_points ) )
- {
- if ( exc->pedantic_hinting )
- exc->error = FT_THROW( Invalid_Reference );
- *refp = 0;
- return FAILURE;
- }
-
- *zone = zp;
- *refp = p;
-
- d = PROJECT( zp.cur + p, zp.org + p );
-
- *x = FT_MulDiv( d, (FT_Long)exc->GS.freeVector.x, exc->F_dot_P );
- *y = FT_MulDiv( d, (FT_Long)exc->GS.freeVector.y, exc->F_dot_P );
-
- return SUCCESS;
- }
-
-
- /* See `ttinterp.h' for details on backward compatibility mode. */
- static void
- Move_Zp2_Point( TT_ExecContext exc,
- FT_UShort point,
- FT_F26Dot6 dx,
- FT_F26Dot6 dy,
- FT_Bool touch )
- {
- if ( exc->GS.freeVector.x != 0 )
- {
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- if ( !( SUBPIXEL_HINTING_MINIMAL &&
- exc->backward_compatibility ) )
-#endif
- exc->zp2.cur[point].x = ADD_LONG( exc->zp2.cur[point].x, dx );
-
- if ( touch )
- exc->zp2.tags[point] |= FT_CURVE_TAG_TOUCH_X;
- }
-
- if ( exc->GS.freeVector.y != 0 )
- {
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- if ( !( SUBPIXEL_HINTING_MINIMAL &&
- exc->backward_compatibility &&
- exc->iupx_called &&
- exc->iupy_called ) )
-#endif
- exc->zp2.cur[point].y = ADD_LONG( exc->zp2.cur[point].y, dy );
-
- if ( touch )
- exc->zp2.tags[point] |= FT_CURVE_TAG_TOUCH_Y;
- }
- }
-
-
- /**************************************************************************
- *
- * SHP[a]: SHift Point by the last point
- * Opcode range: 0x32-0x33
- * Stack: uint32... -->
- */
- static void
- Ins_SHP( TT_ExecContext exc )
- {
- TT_GlyphZoneRec zp;
- FT_UShort refp;
-
- FT_F26Dot6 dx, dy;
- FT_UShort point;
-
-
- if ( exc->top < exc->GS.loop )
- {
- if ( exc->pedantic_hinting )
- exc->error = FT_THROW( Invalid_Reference );
- goto Fail;
- }
-
- if ( Compute_Point_Displacement( exc, &dx, &dy, &zp, &refp ) )
- return;
-
- while ( exc->GS.loop > 0 )
- {
- exc->args--;
- point = (FT_UShort)exc->stack[exc->args];
-
- if ( BOUNDS( point, exc->zp2.n_points ) )
- {
- if ( exc->pedantic_hinting )
- {
- exc->error = FT_THROW( Invalid_Reference );
- return;
- }
- }
- else
- Move_Zp2_Point( exc, point, dx, dy, TRUE );
-
- exc->GS.loop--;
- }
-
- Fail:
- exc->GS.loop = 1;
- exc->new_top = exc->args;
- }
-
-
- /**************************************************************************
- *
- * SHC[a]: SHift Contour
- * Opcode range: 0x34-35
- * Stack: uint32 -->
- *
- * UNDOCUMENTED: According to Greg Hitchcock, there is one (virtual)
- * contour in the twilight zone, namely contour number
- * zero which includes all points of it.
- */
- static void
- Ins_SHC( TT_ExecContext exc,
- FT_Long* args )
- {
- TT_GlyphZoneRec zp;
- FT_UShort refp;
- FT_F26Dot6 dx, dy;
-
- FT_UShort contour, bounds;
- FT_UShort start, limit, i;
-
-
- contour = (FT_UShort)args[0];
- bounds = ( exc->GS.gep2 == 0 ) ? 1 : exc->zp2.n_contours;
-
- if ( BOUNDS( contour, bounds ) )
- {
- if ( exc->pedantic_hinting )
- exc->error = FT_THROW( Invalid_Reference );
- return;
- }
-
- if ( Compute_Point_Displacement( exc, &dx, &dy, &zp, &refp ) )
- return;
-
- if ( contour == 0 )
- start = 0;
- else
- start = exc->zp2.contours[contour - 1] + 1 - exc->zp2.first_point;
-
- /* we use the number of points if in the twilight zone */
- if ( exc->GS.gep2 == 0 )
- limit = exc->zp2.n_points;
- else
- limit = exc->zp2.contours[contour] + 1 - exc->zp2.first_point;
-
- for ( i = start; i < limit; i++ )
- {
- if ( zp.cur != exc->zp2.cur || refp != i )
- Move_Zp2_Point( exc, i, dx, dy, TRUE );
- }
- }
-
-
- /**************************************************************************
- *
- * SHZ[a]: SHift Zone
- * Opcode range: 0x36-37
- * Stack: uint32 -->
- */
- static void
- Ins_SHZ( TT_ExecContext exc,
- FT_Long* args )
- {
- TT_GlyphZoneRec zp;
- FT_UShort refp;
- FT_F26Dot6 dx,
- dy;
-
- FT_UShort limit, i;
-
-
- if ( BOUNDS( args[0], 2 ) )
- {
- if ( exc->pedantic_hinting )
- exc->error = FT_THROW( Invalid_Reference );
- return;
- }
-
- if ( Compute_Point_Displacement( exc, &dx, &dy, &zp, &refp ) )
- return;
-
- /* XXX: UNDOCUMENTED! SHZ doesn't move the phantom points. */
- /* Twilight zone has no real contours, so use `n_points'. */
- /* Normal zone's `n_points' includes phantoms, so must */
- /* use end of last contour. */
- if ( exc->GS.gep2 == 0 )
- limit = exc->zp2.n_points;
- else if ( exc->GS.gep2 == 1 && exc->zp2.n_contours > 0 )
- limit = exc->zp2.contours[exc->zp2.n_contours - 1] + 1;
- else
- limit = 0;
-
- /* XXX: UNDOCUMENTED! SHZ doesn't touch the points */
- for ( i = 0; i < limit; i++ )
- {
- if ( zp.cur != exc->zp2.cur || refp != i )
- Move_Zp2_Point( exc, i, dx, dy, FALSE );
- }
- }
-
-
- /**************************************************************************
- *
- * SHPIX[]: SHift points by a PIXel amount
- * Opcode range: 0x38
- * Stack: f26.6 uint32... -->
- */
- static void
- Ins_SHPIX( TT_ExecContext exc,
- FT_Long* args )
- {
- FT_F26Dot6 dx, dy;
- FT_UShort point;
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- FT_Bool in_twilight = FT_BOOL( exc->GS.gep0 == 0 ||
- exc->GS.gep1 == 0 ||
- exc->GS.gep2 == 0 );
-#endif
-
-
-
- if ( exc->top < exc->GS.loop + 1 )
- {
- if ( exc->pedantic_hinting )
- exc->error = FT_THROW( Invalid_Reference );
- goto Fail;
- }
-
- dx = TT_MulFix14( args[0], exc->GS.freeVector.x );
- dy = TT_MulFix14( args[0], exc->GS.freeVector.y );
-
- while ( exc->GS.loop > 0 )
- {
- exc->args--;
-
- point = (FT_UShort)exc->stack[exc->args];
-
- if ( BOUNDS( point, exc->zp2.n_points ) )
- {
- if ( exc->pedantic_hinting )
- {
- exc->error = FT_THROW( Invalid_Reference );
- return;
- }
- }
- else
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- if ( SUBPIXEL_HINTING_MINIMAL &&
- exc->backward_compatibility )
- {
- /* Special case: allow SHPIX to move points in the twilight zone. */
- /* Otherwise, treat SHPIX the same as DELTAP. Unbreaks various */
- /* fonts such as older versions of Rokkitt and DTL Argo T Light */
- /* that would glitch severely after calling ALIGNRP after a */
- /* blocked SHPIX. */
- if ( in_twilight ||
- ( !( exc->iupx_called && exc->iupy_called ) &&
- ( ( exc->is_composite && exc->GS.freeVector.y != 0 ) ||
- ( exc->zp2.tags[point] & FT_CURVE_TAG_TOUCH_Y ) ) ) )
- Move_Zp2_Point( exc, point, 0, dy, TRUE );
- }
- else
-#endif
- Move_Zp2_Point( exc, point, dx, dy, TRUE );
-
- exc->GS.loop--;
- }
-
- Fail:
- exc->GS.loop = 1;
- exc->new_top = exc->args;
- }
-
-
- /**************************************************************************
- *
- * MSIRP[a]: Move Stack Indirect Relative Position
- * Opcode range: 0x3A-0x3B
- * Stack: f26.6 uint32 -->
- */
- static void
- Ins_MSIRP( TT_ExecContext exc,
- FT_Long* args )
- {
- FT_UShort point = 0;
- FT_F26Dot6 distance;
-
-
- point = (FT_UShort)args[0];
-
- if ( BOUNDS( point, exc->zp1.n_points ) ||
- BOUNDS( exc->GS.rp0, exc->zp0.n_points ) )
- {
- if ( exc->pedantic_hinting )
- exc->error = FT_THROW( Invalid_Reference );
- return;
- }
-
- /* UNDOCUMENTED! The MS rasterizer does that with */
- /* twilight points (confirmed by Greg Hitchcock) */
- if ( exc->GS.gep1 == 0 )
- {
- exc->zp1.org[point] = exc->zp0.org[exc->GS.rp0];
- exc->func_move_orig( exc, &exc->zp1, point, args[1] );
- exc->zp1.cur[point] = exc->zp1.org[point];
- }
-
- distance = PROJECT( exc->zp1.cur + point, exc->zp0.cur + exc->GS.rp0 );
-
- exc->func_move( exc,
- &exc->zp1,
- point,
- SUB_LONG( args[1], distance ) );
-
- exc->GS.rp1 = exc->GS.rp0;
- exc->GS.rp2 = point;
-
- if ( ( exc->opcode & 1 ) != 0 )
- exc->GS.rp0 = point;
- }
-
-
- /**************************************************************************
- *
- * MDAP[a]: Move Direct Absolute Point
- * Opcode range: 0x2E-0x2F
- * Stack: uint32 -->
- */
- static void
- Ins_MDAP( TT_ExecContext exc,
- FT_Long* args )
- {
- FT_UShort point;
- FT_F26Dot6 cur_dist;
- FT_F26Dot6 distance;
-
-
- point = (FT_UShort)args[0];
-
- if ( BOUNDS( point, exc->zp0.n_points ) )
- {
- if ( exc->pedantic_hinting )
- exc->error = FT_THROW( Invalid_Reference );
- return;
- }
-
- if ( ( exc->opcode & 1 ) != 0 )
- {
- cur_dist = FAST_PROJECT( &exc->zp0.cur[point] );
- distance = SUB_LONG( exc->func_round( exc, cur_dist, 3 ), cur_dist );
- }
- else
- distance = 0;
-
- exc->func_move( exc, &exc->zp0, point, distance );
-
- exc->GS.rp0 = point;
- exc->GS.rp1 = point;
- }
-
-
- /**************************************************************************
- *
- * MIAP[a]: Move Indirect Absolute Point
- * Opcode range: 0x3E-0x3F
- * Stack: uint32 uint32 -->
- */
- static void
- Ins_MIAP( TT_ExecContext exc,
- FT_Long* args )
- {
- FT_ULong cvtEntry;
- FT_UShort point;
- FT_F26Dot6 distance;
- FT_F26Dot6 org_dist;
-
-
- cvtEntry = (FT_ULong)args[1];
- point = (FT_UShort)args[0];
-
- if ( BOUNDS( point, exc->zp0.n_points ) ||
- BOUNDSL( cvtEntry, exc->cvtSize ) )
- {
- if ( exc->pedantic_hinting )
- exc->error = FT_THROW( Invalid_Reference );
- goto Fail;
- }
-
- /* UNDOCUMENTED! */
- /* */
- /* The behaviour of an MIAP instruction is quite different when used */
- /* in the twilight zone. */
- /* */
- /* First, no control value cut-in test is performed as it would fail */
- /* anyway. Second, the original point, i.e. (org_x,org_y) of */
- /* zp0.point, is set to the absolute, unrounded distance found in the */
- /* CVT. */
- /* */
- /* This is used in the CVT programs of the Microsoft fonts Arial, */
- /* Times, etc., in order to re-adjust some key font heights. It */
- /* allows the use of the IP instruction in the twilight zone, which */
- /* otherwise would be invalid according to the specification. */
- /* */
- /* We implement it with a special sequence for the twilight zone. */
- /* This is a bad hack, but it seems to work. */
- /* */
- /* Confirmed by Greg Hitchcock. */
-
- distance = exc->func_read_cvt( exc, cvtEntry );
-
- if ( exc->GS.gep0 == 0 ) /* If in twilight zone */
- {
- exc->zp0.org[point].x = TT_MulFix14( distance,
- exc->GS.freeVector.x );
- exc->zp0.org[point].y = TT_MulFix14( distance,
- exc->GS.freeVector.y );
- exc->zp0.cur[point] = exc->zp0.org[point];
- }
-
- org_dist = FAST_PROJECT( &exc->zp0.cur[point] );
-
- if ( ( exc->opcode & 1 ) != 0 ) /* rounding and control cut-in flag */
- {
- FT_F26Dot6 control_value_cutin = exc->GS.control_value_cutin;
- FT_F26Dot6 delta;
-
-
- delta = SUB_LONG( distance, org_dist );
- if ( delta < 0 )
- delta = NEG_LONG( delta );
-
- if ( delta > control_value_cutin )
- distance = org_dist;
-
- distance = exc->func_round( exc, distance, 3 );
- }
-
- exc->func_move( exc, &exc->zp0, point, SUB_LONG( distance, org_dist ) );
-
- Fail:
- exc->GS.rp0 = point;
- exc->GS.rp1 = point;
- }
-
-
- /**************************************************************************
- *
- * MDRP[abcde]: Move Direct Relative Point
- * Opcode range: 0xC0-0xDF
- * Stack: uint32 -->
- */
- static void
- Ins_MDRP( TT_ExecContext exc,
- FT_Long* args )
- {
- FT_UShort point = 0;
- FT_F26Dot6 org_dist, distance;
-
-
- point = (FT_UShort)args[0];
-
- if ( BOUNDS( point, exc->zp1.n_points ) ||
- BOUNDS( exc->GS.rp0, exc->zp0.n_points ) )
- {
- if ( exc->pedantic_hinting )
- exc->error = FT_THROW( Invalid_Reference );
- goto Fail;
- }
-
- /* XXX: Is there some undocumented feature while in the */
- /* twilight zone? */
-
- /* XXX: UNDOCUMENTED: twilight zone special case */
-
- if ( exc->GS.gep0 == 0 || exc->GS.gep1 == 0 )
- {
- FT_Vector* vec1 = &exc->zp1.org[point];
- FT_Vector* vec2 = &exc->zp0.org[exc->GS.rp0];
-
-
- org_dist = DUALPROJ( vec1, vec2 );
- }
- else
- {
- FT_Vector* vec1 = &exc->zp1.orus[point];
- FT_Vector* vec2 = &exc->zp0.orus[exc->GS.rp0];
-
-
- if ( exc->metrics.x_scale == exc->metrics.y_scale )
- {
- /* this should be faster */
- org_dist = DUALPROJ( vec1, vec2 );
- org_dist = FT_MulFix( org_dist, exc->metrics.x_scale );
- }
- else
- {
- FT_Vector vec;
-
-
- vec.x = FT_MulFix( SUB_LONG( vec1->x, vec2->x ),
- exc->metrics.x_scale );
- vec.y = FT_MulFix( SUB_LONG( vec1->y, vec2->y ),
- exc->metrics.y_scale );
-
- org_dist = FAST_DUALPROJ( &vec );
- }
- }
-
- /* single width cut-in test */
-
- /* |org_dist - single_width_value| < single_width_cutin */
- if ( exc->GS.single_width_cutin > 0 &&
- org_dist < exc->GS.single_width_value +
- exc->GS.single_width_cutin &&
- org_dist > exc->GS.single_width_value -
- exc->GS.single_width_cutin )
- {
- if ( org_dist >= 0 )
- org_dist = exc->GS.single_width_value;
- else
- org_dist = -exc->GS.single_width_value;
- }
-
- /* round flag */
-
- if ( ( exc->opcode & 4 ) != 0 )
- {
- distance = exc->func_round( exc, org_dist, exc->opcode & 3 );
- }
- else
- distance = Round_None( exc, org_dist, exc->opcode & 3 );
-
- /* minimum distance flag */
-
- if ( ( exc->opcode & 8 ) != 0 )
- {
- FT_F26Dot6 minimum_distance = exc->GS.minimum_distance;
-
-
- if ( org_dist >= 0 )
- {
- if ( distance < minimum_distance )
- distance = minimum_distance;
- }
- else
- {
- if ( distance > NEG_LONG( minimum_distance ) )
- distance = NEG_LONG( minimum_distance );
- }
- }
-
- /* now move the point */
-
- org_dist = PROJECT( exc->zp1.cur + point, exc->zp0.cur + exc->GS.rp0 );
-
- exc->func_move( exc, &exc->zp1, point, SUB_LONG( distance, org_dist ) );
-
- Fail:
- exc->GS.rp1 = exc->GS.rp0;
- exc->GS.rp2 = point;
-
- if ( ( exc->opcode & 16 ) != 0 )
- exc->GS.rp0 = point;
- }
-
-
- /**************************************************************************
- *
- * MIRP[abcde]: Move Indirect Relative Point
- * Opcode range: 0xE0-0xFF
- * Stack: int32? uint32 -->
- */
- static void
- Ins_MIRP( TT_ExecContext exc,
- FT_Long* args )
- {
- FT_UShort point;
- FT_ULong cvtEntry;
-
- FT_F26Dot6 cvt_dist,
- distance,
- cur_dist,
- org_dist;
-
- FT_F26Dot6 delta;
-
-
- point = (FT_UShort)args[0];
- cvtEntry = (FT_ULong)( ADD_LONG( args[1], 1 ) );
-
- /* XXX: UNDOCUMENTED! cvt[-1] = 0 always */
-
- if ( BOUNDS( point, exc->zp1.n_points ) ||
- BOUNDSL( cvtEntry, exc->cvtSize + 1 ) ||
- BOUNDS( exc->GS.rp0, exc->zp0.n_points ) )
- {
- if ( exc->pedantic_hinting )
- exc->error = FT_THROW( Invalid_Reference );
- goto Fail;
- }
-
- if ( !cvtEntry )
- cvt_dist = 0;
- else
- cvt_dist = exc->func_read_cvt( exc, cvtEntry - 1 );
-
- /* single width test */
-
- delta = SUB_LONG( cvt_dist, exc->GS.single_width_value );
- if ( delta < 0 )
- delta = NEG_LONG( delta );
-
- if ( delta < exc->GS.single_width_cutin )
- {
- if ( cvt_dist >= 0 )
- cvt_dist = exc->GS.single_width_value;
- else
- cvt_dist = -exc->GS.single_width_value;
- }
-
- /* UNDOCUMENTED! The MS rasterizer does that with */
- /* twilight points (confirmed by Greg Hitchcock) */
- if ( exc->GS.gep1 == 0 )
- {
- exc->zp1.org[point].x = ADD_LONG(
- exc->zp0.org[exc->GS.rp0].x,
- TT_MulFix14( cvt_dist,
- exc->GS.freeVector.x ) );
- exc->zp1.org[point].y = ADD_LONG(
- exc->zp0.org[exc->GS.rp0].y,
- TT_MulFix14( cvt_dist,
- exc->GS.freeVector.y ) );
- exc->zp1.cur[point] = exc->zp1.org[point];
- }
-
- org_dist = DUALPROJ( &exc->zp1.org[point], &exc->zp0.org[exc->GS.rp0] );
- cur_dist = PROJECT ( &exc->zp1.cur[point], &exc->zp0.cur[exc->GS.rp0] );
-
- /* auto-flip test */
-
- if ( exc->GS.auto_flip )
- {
- if ( ( org_dist ^ cvt_dist ) < 0 )
- cvt_dist = NEG_LONG( cvt_dist );
- }
-
- /* control value cut-in and round */
-
- if ( ( exc->opcode & 4 ) != 0 )
- {
- /* XXX: UNDOCUMENTED! Only perform cut-in test when both points */
- /* refer to the same zone. */
-
- if ( exc->GS.gep0 == exc->GS.gep1 )
- {
- FT_F26Dot6 control_value_cutin = exc->GS.control_value_cutin;
-
-
- /* XXX: According to Greg Hitchcock, the following wording is */
- /* the right one: */
- /* */
- /* When the absolute difference between the value in */
- /* the table [CVT] and the measurement directly from */
- /* the outline is _greater_ than the cut_in value, the */
- /* outline measurement is used. */
- /* */
- /* This is from `instgly.doc'. The description in */
- /* `ttinst2.doc', version 1.66, is thus incorrect since */
- /* it implies `>=' instead of `>'. */
-
- delta = SUB_LONG( cvt_dist, org_dist );
- if ( delta < 0 )
- delta = NEG_LONG( delta );
-
- if ( delta > control_value_cutin )
- cvt_dist = org_dist;
- }
-
- distance = exc->func_round( exc, cvt_dist, exc->opcode & 3 );
- }
- else
- distance = Round_None( exc, cvt_dist, exc->opcode & 3 );
-
- /* minimum distance test */
-
- if ( ( exc->opcode & 8 ) != 0 )
- {
- FT_F26Dot6 minimum_distance = exc->GS.minimum_distance;
-
-
- if ( org_dist >= 0 )
- {
- if ( distance < minimum_distance )
- distance = minimum_distance;
- }
- else
- {
- if ( distance > NEG_LONG( minimum_distance ) )
- distance = NEG_LONG( minimum_distance );
- }
- }
-
- exc->func_move( exc,
- &exc->zp1,
- point,
- SUB_LONG( distance, cur_dist ) );
-
- Fail:
- exc->GS.rp1 = exc->GS.rp0;
-
- if ( ( exc->opcode & 16 ) != 0 )
- exc->GS.rp0 = point;
-
- exc->GS.rp2 = point;
- }
-
-
- /**************************************************************************
- *
- * ALIGNRP[]: ALIGN Relative Point
- * Opcode range: 0x3C
- * Stack: uint32 uint32... -->
- */
- static void
- Ins_ALIGNRP( TT_ExecContext exc )
- {
- FT_UShort point;
- FT_F26Dot6 distance;
-
-
- if ( exc->top < exc->GS.loop ||
- BOUNDS( exc->GS.rp0, exc->zp0.n_points ) )
- {
- if ( exc->pedantic_hinting )
- exc->error = FT_THROW( Invalid_Reference );
- goto Fail;
- }
-
- while ( exc->GS.loop > 0 )
- {
- exc->args--;
-
- point = (FT_UShort)exc->stack[exc->args];
-
- if ( BOUNDS( point, exc->zp1.n_points ) )
- {
- if ( exc->pedantic_hinting )
- {
- exc->error = FT_THROW( Invalid_Reference );
- return;
- }
- }
- else
- {
- distance = PROJECT( exc->zp1.cur + point,
- exc->zp0.cur + exc->GS.rp0 );
-
- exc->func_move( exc, &exc->zp1, point, NEG_LONG( distance ) );
- }
-
- exc->GS.loop--;
- }
-
- Fail:
- exc->GS.loop = 1;
- exc->new_top = exc->args;
- }
-
-
- /**************************************************************************
- *
- * ISECT[]: moves point to InterSECTion
- * Opcode range: 0x0F
- * Stack: 5 * uint32 -->
- */
- static void
- Ins_ISECT( TT_ExecContext exc,
- FT_Long* args )
- {
- FT_UShort point,
- a0, a1,
- b0, b1;
-
- FT_F26Dot6 discriminant, dotproduct;
-
- FT_F26Dot6 dx, dy,
- dax, day,
- dbx, dby;
-
- FT_F26Dot6 val;
-
- FT_Vector R;
-
-
- point = (FT_UShort)args[0];
-
- a0 = (FT_UShort)args[1];
- a1 = (FT_UShort)args[2];
- b0 = (FT_UShort)args[3];
- b1 = (FT_UShort)args[4];
-
- if ( BOUNDS( b0, exc->zp0.n_points ) ||
- BOUNDS( b1, exc->zp0.n_points ) ||
- BOUNDS( a0, exc->zp1.n_points ) ||
- BOUNDS( a1, exc->zp1.n_points ) ||
- BOUNDS( point, exc->zp2.n_points ) )
- {
- if ( exc->pedantic_hinting )
- exc->error = FT_THROW( Invalid_Reference );
- return;
- }
-
- /* Cramer's rule */
-
- dbx = SUB_LONG( exc->zp0.cur[b1].x, exc->zp0.cur[b0].x );
- dby = SUB_LONG( exc->zp0.cur[b1].y, exc->zp0.cur[b0].y );
-
- dax = SUB_LONG( exc->zp1.cur[a1].x, exc->zp1.cur[a0].x );
- day = SUB_LONG( exc->zp1.cur[a1].y, exc->zp1.cur[a0].y );
-
- dx = SUB_LONG( exc->zp0.cur[b0].x, exc->zp1.cur[a0].x );
- dy = SUB_LONG( exc->zp0.cur[b0].y, exc->zp1.cur[a0].y );
-
- discriminant = ADD_LONG( FT_MulDiv( dax, NEG_LONG( dby ), 0x40 ),
- FT_MulDiv( day, dbx, 0x40 ) );
- dotproduct = ADD_LONG( FT_MulDiv( dax, dbx, 0x40 ),
- FT_MulDiv( day, dby, 0x40 ) );
-
- /* The discriminant above is actually a cross product of vectors */
- /* da and db. Together with the dot product, they can be used as */
- /* surrogates for sine and cosine of the angle between the vectors. */
- /* Indeed, */
- /* dotproduct = |da||db|cos(angle) */
- /* discriminant = |da||db|sin(angle) . */
- /* We use these equations to reject grazing intersections by */
- /* thresholding abs(tan(angle)) at 1/19, corresponding to 3 degrees. */
- if ( MUL_LONG( 19, FT_ABS( discriminant ) ) > FT_ABS( dotproduct ) )
- {
- val = ADD_LONG( FT_MulDiv( dx, NEG_LONG( dby ), 0x40 ),
- FT_MulDiv( dy, dbx, 0x40 ) );
-
- R.x = FT_MulDiv( val, dax, discriminant );
- R.y = FT_MulDiv( val, day, discriminant );
-
- /* XXX: Block in backward_compatibility and/or post-IUP? */
- exc->zp2.cur[point].x = ADD_LONG( exc->zp1.cur[a0].x, R.x );
- exc->zp2.cur[point].y = ADD_LONG( exc->zp1.cur[a0].y, R.y );
- }
- else
- {
- /* else, take the middle of the middles of A and B */
-
- /* XXX: Block in backward_compatibility and/or post-IUP? */
- exc->zp2.cur[point].x =
- ADD_LONG( ADD_LONG( exc->zp1.cur[a0].x, exc->zp1.cur[a1].x ),
- ADD_LONG( exc->zp0.cur[b0].x, exc->zp0.cur[b1].x ) ) / 4;
- exc->zp2.cur[point].y =
- ADD_LONG( ADD_LONG( exc->zp1.cur[a0].y, exc->zp1.cur[a1].y ),
- ADD_LONG( exc->zp0.cur[b0].y, exc->zp0.cur[b1].y ) ) / 4;
- }
-
- exc->zp2.tags[point] |= FT_CURVE_TAG_TOUCH_BOTH;
- }
-
-
- /**************************************************************************
- *
- * ALIGNPTS[]: ALIGN PoinTS
- * Opcode range: 0x27
- * Stack: uint32 uint32 -->
- */
- static void
- Ins_ALIGNPTS( TT_ExecContext exc,
- FT_Long* args )
- {
- FT_UShort p1, p2;
- FT_F26Dot6 distance;
-
-
- p1 = (FT_UShort)args[0];
- p2 = (FT_UShort)args[1];
-
- if ( BOUNDS( p1, exc->zp1.n_points ) ||
- BOUNDS( p2, exc->zp0.n_points ) )
- {
- if ( exc->pedantic_hinting )
- exc->error = FT_THROW( Invalid_Reference );
- return;
- }
-
- distance = PROJECT( exc->zp0.cur + p2, exc->zp1.cur + p1 ) / 2;
-
- exc->func_move( exc, &exc->zp1, p1, distance );
- exc->func_move( exc, &exc->zp0, p2, NEG_LONG( distance ) );
- }
-
-
- /**************************************************************************
- *
- * IP[]: Interpolate Point
- * Opcode range: 0x39
- * Stack: uint32... -->
- */
-
- /* SOMETIMES, DUMBER CODE IS BETTER CODE */
-
- static void
- Ins_IP( TT_ExecContext exc )
- {
- FT_F26Dot6 old_range, cur_range;
- FT_Vector* orus_base;
- FT_Vector* cur_base;
- FT_Int twilight;
-
-
- if ( exc->top < exc->GS.loop )
- {
- if ( exc->pedantic_hinting )
- exc->error = FT_THROW( Invalid_Reference );
- goto Fail;
- }
-
- /*
- * We need to deal in a special way with the twilight zone.
- * Otherwise, by definition, the value of exc->twilight.orus[n] is (0,0),
- * for every n.
- */
- twilight = ( exc->GS.gep0 == 0 ||
- exc->GS.gep1 == 0 ||
- exc->GS.gep2 == 0 );
-
- if ( BOUNDS( exc->GS.rp1, exc->zp0.n_points ) )
- {
- if ( exc->pedantic_hinting )
- exc->error = FT_THROW( Invalid_Reference );
- goto Fail;
- }
-
- if ( twilight )
- orus_base = &exc->zp0.org[exc->GS.rp1];
- else
- orus_base = &exc->zp0.orus[exc->GS.rp1];
-
- cur_base = &exc->zp0.cur[exc->GS.rp1];
-
- /* XXX: There are some glyphs in some braindead but popular */
- /* fonts out there (e.g. [aeu]grave in monotype.ttf) */
- /* calling IP[] with bad values of rp[12]. */
- /* Do something sane when this odd thing happens. */
- if ( BOUNDS( exc->GS.rp1, exc->zp0.n_points ) ||
- BOUNDS( exc->GS.rp2, exc->zp1.n_points ) )
- {
- old_range = 0;
- cur_range = 0;
- }
- else
- {
- if ( twilight )
- old_range = DUALPROJ( &exc->zp1.org[exc->GS.rp2], orus_base );
- else if ( exc->metrics.x_scale == exc->metrics.y_scale )
- old_range = DUALPROJ( &exc->zp1.orus[exc->GS.rp2], orus_base );
- else
- {
- FT_Vector vec;
-
-
- vec.x = FT_MulFix( SUB_LONG( exc->zp1.orus[exc->GS.rp2].x,
- orus_base->x ),
- exc->metrics.x_scale );
- vec.y = FT_MulFix( SUB_LONG( exc->zp1.orus[exc->GS.rp2].y,
- orus_base->y ),
- exc->metrics.y_scale );
-
- old_range = FAST_DUALPROJ( &vec );
- }
-
- cur_range = PROJECT( &exc->zp1.cur[exc->GS.rp2], cur_base );
- }
-
- for ( ; exc->GS.loop > 0; exc->GS.loop-- )
- {
- FT_UInt point = (FT_UInt)exc->stack[--exc->args];
- FT_F26Dot6 org_dist, cur_dist, new_dist;
-
-
- /* check point bounds */
- if ( BOUNDS( point, exc->zp2.n_points ) )
- {
- if ( exc->pedantic_hinting )
- {
- exc->error = FT_THROW( Invalid_Reference );
- return;
- }
- continue;
- }
-
- if ( twilight )
- org_dist = DUALPROJ( &exc->zp2.org[point], orus_base );
- else if ( exc->metrics.x_scale == exc->metrics.y_scale )
- org_dist = DUALPROJ( &exc->zp2.orus[point], orus_base );
- else
- {
- FT_Vector vec;
-
-
- vec.x = FT_MulFix( SUB_LONG( exc->zp2.orus[point].x,
- orus_base->x ),
- exc->metrics.x_scale );
- vec.y = FT_MulFix( SUB_LONG( exc->zp2.orus[point].y,
- orus_base->y ),
- exc->metrics.y_scale );
-
- org_dist = FAST_DUALPROJ( &vec );
- }
-
- cur_dist = PROJECT( &exc->zp2.cur[point], cur_base );
-
- if ( org_dist )
- {
- if ( old_range )
- new_dist = FT_MulDiv( org_dist, cur_range, old_range );
- else
- {
- /* This is the same as what MS does for the invalid case: */
- /* */
- /* delta = (Original_Pt - Original_RP1) - */
- /* (Current_Pt - Current_RP1) ; */
- /* */
- /* In FreeType speak: */
- /* */
- /* delta = org_dist - cur_dist . */
- /* */
- /* We move `point' by `new_dist - cur_dist' after leaving */
- /* this block, thus we have */
- /* */
- /* new_dist - cur_dist = delta , */
- /* new_dist - cur_dist = org_dist - cur_dist , */
- /* new_dist = org_dist . */
-
- new_dist = org_dist;
- }
- }
- else
- new_dist = 0;
-
- exc->func_move( exc,
- &exc->zp2,
- (FT_UShort)point,
- SUB_LONG( new_dist, cur_dist ) );
- }
-
- Fail:
- exc->GS.loop = 1;
- exc->new_top = exc->args;
- }
-
-
- /**************************************************************************
- *
- * UTP[a]: UnTouch Point
- * Opcode range: 0x29
- * Stack: uint32 -->
- */
- static void
- Ins_UTP( TT_ExecContext exc,
- FT_Long* args )
- {
- FT_UShort point;
- FT_Byte mask;
-
-
- point = (FT_UShort)args[0];
-
- if ( BOUNDS( point, exc->zp0.n_points ) )
- {
- if ( exc->pedantic_hinting )
- exc->error = FT_THROW( Invalid_Reference );
- return;
- }
-
- mask = 0xFF;
-
- if ( exc->GS.freeVector.x != 0 )
- mask &= ~FT_CURVE_TAG_TOUCH_X;
-
- if ( exc->GS.freeVector.y != 0 )
- mask &= ~FT_CURVE_TAG_TOUCH_Y;
-
- exc->zp0.tags[point] &= mask;
- }
-
-
- /* Local variables for Ins_IUP: */
- typedef struct IUP_WorkerRec_
- {
- FT_Vector* orgs; /* original and current coordinate */
- FT_Vector* curs; /* arrays */
- FT_Vector* orus;
- FT_UInt max_points;
-
- } IUP_WorkerRec, *IUP_Worker;
-
-
- static void
- iup_worker_shift_( IUP_Worker worker,
- FT_UInt p1,
- FT_UInt p2,
- FT_UInt p )
- {
- FT_UInt i;
- FT_F26Dot6 dx;
-
-
- dx = SUB_LONG( worker->curs[p].x, worker->orgs[p].x );
- if ( dx != 0 )
- {
- for ( i = p1; i < p; i++ )
- worker->curs[i].x = ADD_LONG( worker->curs[i].x, dx );
-
- for ( i = p + 1; i <= p2; i++ )
- worker->curs[i].x = ADD_LONG( worker->curs[i].x, dx );
- }
- }
-
-
- static void
- iup_worker_interpolate_( IUP_Worker worker,
- FT_UInt p1,
- FT_UInt p2,
- FT_UInt ref1,
- FT_UInt ref2 )
- {
- FT_UInt i;
- FT_F26Dot6 orus1, orus2, org1, org2, cur1, cur2, delta1, delta2;
-
-
- if ( p1 > p2 )
- return;
-
- if ( BOUNDS( ref1, worker->max_points ) ||
- BOUNDS( ref2, worker->max_points ) )
- return;
-
- orus1 = worker->orus[ref1].x;
- orus2 = worker->orus[ref2].x;
-
- if ( orus1 > orus2 )
- {
- FT_F26Dot6 tmp_o;
- FT_UInt tmp_r;
-
-
- tmp_o = orus1;
- orus1 = orus2;
- orus2 = tmp_o;
-
- tmp_r = ref1;
- ref1 = ref2;
- ref2 = tmp_r;
- }
-
- org1 = worker->orgs[ref1].x;
- org2 = worker->orgs[ref2].x;
- cur1 = worker->curs[ref1].x;
- cur2 = worker->curs[ref2].x;
- delta1 = SUB_LONG( cur1, org1 );
- delta2 = SUB_LONG( cur2, org2 );
-
- if ( cur1 == cur2 || orus1 == orus2 )
- {
-
- /* trivial snap or shift of untouched points */
- for ( i = p1; i <= p2; i++ )
- {
- FT_F26Dot6 x = worker->orgs[i].x;
-
-
- if ( x <= org1 )
- x = ADD_LONG( x, delta1 );
-
- else if ( x >= org2 )
- x = ADD_LONG( x, delta2 );
-
- else
- x = cur1;
-
- worker->curs[i].x = x;
- }
- }
- else
- {
- FT_Fixed scale = 0;
- FT_Bool scale_valid = 0;
-
-
- /* interpolation */
- for ( i = p1; i <= p2; i++ )
- {
- FT_F26Dot6 x = worker->orgs[i].x;
-
-
- if ( x <= org1 )
- x = ADD_LONG( x, delta1 );
-
- else if ( x >= org2 )
- x = ADD_LONG( x, delta2 );
-
- else
- {
- if ( !scale_valid )
- {
- scale_valid = 1;
- scale = FT_DivFix( SUB_LONG( cur2, cur1 ),
- SUB_LONG( orus2, orus1 ) );
- }
-
- x = ADD_LONG( cur1,
- FT_MulFix( SUB_LONG( worker->orus[i].x, orus1 ),
- scale ) );
- }
- worker->curs[i].x = x;
- }
- }
- }
-
-
- /**************************************************************************
- *
- * IUP[a]: Interpolate Untouched Points
- * Opcode range: 0x30-0x31
- * Stack: -->
- */
- static void
- Ins_IUP( TT_ExecContext exc )
- {
- IUP_WorkerRec V;
- FT_Byte mask;
-
- FT_UInt first_point; /* first point of contour */
- FT_UInt end_point; /* end point (last+1) of contour */
-
- FT_UInt first_touched; /* first touched point in contour */
- FT_UInt cur_touched; /* current touched point in contour */
-
- FT_UInt point; /* current point */
- FT_Short contour; /* current contour */
-
-
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- /* See `ttinterp.h' for details on backward compatibility mode. */
- /* Allow IUP until it has been called on both axes. Immediately */
- /* return on subsequent ones. */
- if ( SUBPIXEL_HINTING_MINIMAL &&
- exc->backward_compatibility )
- {
- if ( exc->iupx_called && exc->iupy_called )
- return;
-
- if ( exc->opcode & 1 )
- exc->iupx_called = TRUE;
- else
- exc->iupy_called = TRUE;
- }
-#endif
-
- /* ignore empty outlines */
- if ( exc->pts.n_contours == 0 )
- return;
-
- if ( exc->opcode & 1 )
- {
- mask = FT_CURVE_TAG_TOUCH_X;
- V.orgs = exc->pts.org;
- V.curs = exc->pts.cur;
- V.orus = exc->pts.orus;
- }
- else
- {
- mask = FT_CURVE_TAG_TOUCH_Y;
- V.orgs = (FT_Vector*)( (FT_Pos*)exc->pts.org + 1 );
- V.curs = (FT_Vector*)( (FT_Pos*)exc->pts.cur + 1 );
- V.orus = (FT_Vector*)( (FT_Pos*)exc->pts.orus + 1 );
- }
- V.max_points = exc->pts.n_points;
-
- contour = 0;
- point = 0;
-
- do
- {
- end_point = exc->pts.contours[contour] - exc->pts.first_point;
- first_point = point;
-
- if ( BOUNDS( end_point, exc->pts.n_points ) )
- end_point = exc->pts.n_points - 1;
-
- while ( point <= end_point && ( exc->pts.tags[point] & mask ) == 0 )
- point++;
-
- if ( point <= end_point )
- {
- first_touched = point;
- cur_touched = point;
-
- point++;
-
- while ( point <= end_point )
- {
- if ( ( exc->pts.tags[point] & mask ) != 0 )
- {
- iup_worker_interpolate_( &V,
- cur_touched + 1,
- point - 1,
- cur_touched,
- point );
- cur_touched = point;
- }
-
- point++;
- }
-
- if ( cur_touched == first_touched )
- iup_worker_shift_( &V, first_point, end_point, cur_touched );
- else
- {
- iup_worker_interpolate_( &V,
- (FT_UShort)( cur_touched + 1 ),
- end_point,
- cur_touched,
- first_touched );
-
- if ( first_touched > 0 )
- iup_worker_interpolate_( &V,
- first_point,
- first_touched - 1,
- cur_touched,
- first_touched );
- }
- }
- contour++;
- } while ( contour < exc->pts.n_contours );
- }
-
-
- /**************************************************************************
- *
- * DELTAPn[]: DELTA exceptions P1, P2, P3
- * Opcode range: 0x5D,0x71,0x72
- * Stack: uint32 (2 * uint32)... -->
- */
- static void
- Ins_DELTAP( TT_ExecContext exc,
- FT_Long* args )
- {
- FT_ULong nump, k;
- FT_UShort A;
- FT_ULong C, P;
- FT_Long B;
-
-
- P = (FT_ULong)exc->func_cur_ppem( exc );
- nump = (FT_ULong)args[0]; /* some points theoretically may occur more
- than once, thus UShort isn't enough */
-
- for ( k = 1; k <= nump; k++ )
- {
- if ( exc->args < 2 )
- {
- if ( exc->pedantic_hinting )
- exc->error = FT_THROW( Too_Few_Arguments );
- exc->args = 0;
- goto Fail;
- }
-
- exc->args -= 2;
-
- A = (FT_UShort)exc->stack[exc->args + 1];
- B = exc->stack[exc->args];
-
- /* XXX: Because some popular fonts contain some invalid DeltaP */
- /* instructions, we simply ignore them when the stacked */
- /* point reference is off limit, rather than returning an */
- /* error. As a delta instruction doesn't change a glyph */
- /* in great ways, this shouldn't be a problem. */
-
- if ( !BOUNDS( A, exc->zp0.n_points ) )
- {
- C = ( (FT_ULong)B & 0xF0 ) >> 4;
-
- switch ( exc->opcode )
- {
- case 0x5D:
- break;
-
- case 0x71:
- C += 16;
- break;
-
- case 0x72:
- C += 32;
- break;
- }
-
- C += exc->GS.delta_base;
-
- if ( P == C )
- {
- B = ( (FT_ULong)B & 0xF ) - 8;
- if ( B >= 0 )
- B++;
- B *= 1L << ( 6 - exc->GS.delta_shift );
-
-
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- /* See `ttinterp.h' for details on backward compatibility */
- /* mode. */
- if ( SUBPIXEL_HINTING_MINIMAL &&
- exc->backward_compatibility )
- {
- if ( !( exc->iupx_called && exc->iupy_called ) &&
- ( ( exc->is_composite && exc->GS.freeVector.y != 0 ) ||
- ( exc->zp0.tags[A] & FT_CURVE_TAG_TOUCH_Y ) ) )
- exc->func_move( exc, &exc->zp0, A, B );
- }
- else
-#endif
- exc->func_move( exc, &exc->zp0, A, B );
- }
- }
- else
- if ( exc->pedantic_hinting )
- exc->error = FT_THROW( Invalid_Reference );
- }
-
- Fail:
- exc->new_top = exc->args;
- }
-
-
- /**************************************************************************
- *
- * DELTACn[]: DELTA exceptions C1, C2, C3
- * Opcode range: 0x73,0x74,0x75
- * Stack: uint32 (2 * uint32)... -->
- */
- static void
- Ins_DELTAC( TT_ExecContext exc,
- FT_Long* args )
- {
- FT_ULong nump, k;
- FT_ULong A, C, P;
- FT_Long B;
-
-
- P = (FT_ULong)exc->func_cur_ppem( exc );
- nump = (FT_ULong)args[0];
-
- for ( k = 1; k <= nump; k++ )
- {
- if ( exc->args < 2 )
- {
- if ( exc->pedantic_hinting )
- exc->error = FT_THROW( Too_Few_Arguments );
- exc->args = 0;
- goto Fail;
- }
-
- exc->args -= 2;
-
- A = (FT_ULong)exc->stack[exc->args + 1];
- B = exc->stack[exc->args];
-
- if ( BOUNDSL( A, exc->cvtSize ) )
- {
- if ( exc->pedantic_hinting )
- {
- exc->error = FT_THROW( Invalid_Reference );
- return;
- }
- }
- else
- {
- C = ( (FT_ULong)B & 0xF0 ) >> 4;
-
- switch ( exc->opcode )
- {
- case 0x73:
- break;
-
- case 0x74:
- C += 16;
- break;
-
- case 0x75:
- C += 32;
- break;
- }
-
- C += exc->GS.delta_base;
-
- if ( P == C )
- {
- B = ( (FT_ULong)B & 0xF ) - 8;
- if ( B >= 0 )
- B++;
- B *= 1L << ( 6 - exc->GS.delta_shift );
-
- exc->func_move_cvt( exc, A, B );
- }
- }
- }
-
- Fail:
- exc->new_top = exc->args;
- }
-
-
- /**************************************************************************
- *
- * MISC. INSTRUCTIONS
- *
- */
-
-
- /**************************************************************************
- *
- * GETINFO[]: GET INFOrmation
- * Opcode range: 0x88
- * Stack: uint32 --> uint32
- */
- static void
- Ins_GETINFO( TT_ExecContext exc,
- FT_Long* args )
- {
- FT_Long K;
- TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( exc->face );
-
-
- K = 0;
-
- if ( ( args[0] & 1 ) != 0 )
- K = driver->interpreter_version;
-
- /*********************************
- * GLYPH ROTATED
- * Selector Bit: 1
- * Return Bit(s): 8
- */
- if ( ( args[0] & 2 ) != 0 && exc->tt_metrics.rotated )
- K |= 1 << 8;
-
- /*********************************
- * GLYPH STRETCHED
- * Selector Bit: 2
- * Return Bit(s): 9
- */
- if ( ( args[0] & 4 ) != 0 && exc->tt_metrics.stretched )
- K |= 1 << 9;
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- /*********************************
- * VARIATION GLYPH
- * Selector Bit: 3
- * Return Bit(s): 10
- */
- if ( (args[0] & 8 ) != 0 && exc->face->blend )
- K |= 1 << 10;
-#endif
-
- /*********************************
- * BI-LEVEL HINTING AND
- * GRAYSCALE RENDERING
- * Selector Bit: 5
- * Return Bit(s): 12
- */
- if ( ( args[0] & 32 ) != 0 && exc->grayscale )
- K |= 1 << 12;
-
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- /* Toggle the following flags only outside of monochrome mode. */
- /* Otherwise, instructions may behave weirdly and rendering results */
- /* may differ between v35 and v40 mode, e.g., in `Times New Roman */
- /* Bold Italic'. */
- if ( SUBPIXEL_HINTING_MINIMAL && exc->subpixel_hinting_lean )
- {
- /*********************************
- * HINTING FOR SUBPIXEL
- * Selector Bit: 6
- * Return Bit(s): 13
- *
- * v40 does subpixel hinting by default.
- */
- if ( ( args[0] & 64 ) != 0 )
- K |= 1 << 13;
-
- /*********************************
- * VERTICAL LCD SUBPIXELS?
- * Selector Bit: 8
- * Return Bit(s): 15
- */
- if ( ( args[0] & 256 ) != 0 && exc->vertical_lcd_lean )
- K |= 1 << 15;
-
- /*********************************
- * SUBPIXEL POSITIONED?
- * Selector Bit: 10
- * Return Bit(s): 17
- *
- * XXX: FreeType supports it, dependent on what client does?
- */
- if ( ( args[0] & 1024 ) != 0 )
- K |= 1 << 17;
-
- /*********************************
- * SYMMETRICAL SMOOTHING
- * Selector Bit: 11
- * Return Bit(s): 18
- *
- * The only smoothing method FreeType supports unless someone sets
- * FT_LOAD_TARGET_MONO.
- */
- if ( ( args[0] & 2048 ) != 0 && exc->subpixel_hinting_lean )
- K |= 1 << 18;
-
- /*********************************
- * CLEARTYPE HINTING AND
- * GRAYSCALE RENDERING
- * Selector Bit: 12
- * Return Bit(s): 19
- *
- * Grayscale rendering is what FreeType does anyway unless someone
- * sets FT_LOAD_TARGET_MONO or FT_LOAD_TARGET_LCD(_V)
- */
- if ( ( args[0] & 4096 ) != 0 && exc->grayscale_cleartype )
- K |= 1 << 19;
- }
-#endif
-
- args[0] = K;
- }
-
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
-
- /**************************************************************************
- *
- * GETVARIATION[]: get normalized variation (blend) coordinates
- * Opcode range: 0x91
- * Stack: --> f2.14...
- *
- * XXX: UNDOCUMENTED! There is no official documentation from Apple for
- * this bytecode instruction. Active only if a font has GX
- * variation axes.
- */
- static void
- Ins_GETVARIATION( TT_ExecContext exc,
- FT_Long* args )
- {
- FT_UInt num_axes = exc->face->blend->num_axis;
- FT_Fixed* coords = exc->face->blend->normalizedcoords;
-
- FT_UInt i;
-
-
- if ( BOUNDS( num_axes, exc->stackSize + 1 - exc->top ) )
- {
- exc->error = FT_THROW( Stack_Overflow );
- return;
- }
-
- if ( coords )
- {
- for ( i = 0; i < num_axes; i++ )
- args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */
- }
- else
- {
- for ( i = 0; i < num_axes; i++ )
- args[i] = 0;
- }
- }
-
-
- /**************************************************************************
- *
- * GETDATA[]: no idea what this is good for
- * Opcode range: 0x92
- * Stack: --> 17
- *
- * XXX: UNDOCUMENTED! There is no documentation from Apple for this
- * very weird bytecode instruction.
- */
- static void
- Ins_GETDATA( FT_Long* args )
- {
- args[0] = 17;
- }
-
-#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
-
-
- static void
- Ins_UNKNOWN( TT_ExecContext exc )
- {
- TT_DefRecord* def = exc->IDefs;
- TT_DefRecord* limit = FT_OFFSET( def, exc->numIDefs );
-
-
- for ( ; def < limit; def++ )
- {
- if ( (FT_Byte)def->opc == exc->opcode && def->active )
- {
- TT_CallRec* call;
-
-
- if ( exc->callTop >= exc->callSize )
- {
- exc->error = FT_THROW( Stack_Overflow );
- return;
- }
-
- call = exc->callStack + exc->callTop++;
-
- call->Caller_Range = exc->curRange;
- call->Caller_IP = exc->IP + 1;
- call->Cur_Count = 1;
- call->Def = def;
-
- Ins_Goto_CodeRange( exc, def->range, def->start );
-
- exc->step_ins = FALSE;
- return;
- }
- }
-
- exc->error = FT_THROW( Invalid_Opcode );
- }
-
-
- /**************************************************************************
- *
- * RUN
- *
- * This function executes a run of opcodes. It will exit in the
- * following cases:
- *
- * - Errors (in which case it returns FALSE).
- *
- * - Reaching the end of the main code range (returns TRUE).
- * Reaching the end of a code range within a function call is an
- * error.
- *
- * - After executing one single opcode, if the flag `Instruction_Trap'
- * is set to TRUE (returns TRUE).
- *
- * On exit with TRUE, test IP < CodeSize to know whether it comes from
- * an instruction trap or a normal termination.
- *
- *
- * Note: The documented DEBUG opcode pops a value from the stack. This
- * behaviour is unsupported; here a DEBUG opcode is always an
- * error.
- *
- *
- * THIS IS THE INTERPRETER'S MAIN LOOP.
- *
- */
-
-
- /* documentation is in ttinterp.h */
-
- FT_EXPORT_DEF( FT_Error )
- TT_RunIns( void* exec )
- {
- TT_ExecContext exc = (TT_ExecContext)exec;
-
- FT_ULong ins_counter = 0; /* executed instructions counter */
- FT_ULong num_twilight_points;
- FT_UShort i;
-
-
- /* We restrict the number of twilight points to a reasonable, */
- /* heuristic value to avoid slow execution of malformed bytecode. */
- num_twilight_points = FT_MAX( 30,
- 2 * ( exc->pts.n_points + exc->cvtSize ) );
- if ( exc->twilight.n_points > num_twilight_points )
- {
- if ( num_twilight_points > 0xFFFFU )
- num_twilight_points = 0xFFFFU;
-
- FT_TRACE5(( "TT_RunIns: Resetting number of twilight points\n" ));
- FT_TRACE5(( " from %d to the more reasonable value %ld\n",
- exc->twilight.n_points,
- num_twilight_points ));
- exc->twilight.n_points = (FT_UShort)num_twilight_points;
- }
-
- /* Set up loop detectors. We restrict the number of LOOPCALL loops */
- /* and the number of JMPR, JROT, and JROF calls with a negative */
- /* argument to values that depend on various parameters like the */
- /* size of the CVT table or the number of points in the current */
- /* glyph (if applicable). */
- /* */
- /* The idea is that in real-world bytecode you either iterate over */
- /* all CVT entries (in the `prep' table), or over all points (or */
- /* contours, in the `glyf' table) of a glyph, and such iterations */
- /* don't happen very often. */
- exc->loopcall_counter = 0;
- exc->neg_jump_counter = 0;
-
- /* The maximum values are heuristic. */
- if ( exc->pts.n_points )
- exc->loopcall_counter_max = FT_MAX( 50,
- 10 * exc->pts.n_points ) +
- FT_MAX( 50,
- exc->cvtSize / 10 );
- else
- exc->loopcall_counter_max = 300 + 22 * exc->cvtSize;
-
- /* as a protection against an unreasonable number of CVT entries */
- /* we assume at most 100 control values per glyph for the counter */
- if ( exc->loopcall_counter_max >
- 100 * (FT_ULong)exc->face->root.num_glyphs )
- exc->loopcall_counter_max = 100 * (FT_ULong)exc->face->root.num_glyphs;
-
- FT_TRACE5(( "TT_RunIns: Limiting total number of loops in LOOPCALL"
- " to %ld\n", exc->loopcall_counter_max ));
-
- exc->neg_jump_counter_max = exc->loopcall_counter_max;
- FT_TRACE5(( "TT_RunIns: Limiting total number of backward jumps"
- " to %ld\n", exc->neg_jump_counter_max ));
-
- /* set PPEM and CVT functions */
- exc->tt_metrics.ratio = 0;
- if ( exc->metrics.x_ppem != exc->metrics.y_ppem )
- {
- /* non-square pixels, use the stretched routines */
- exc->func_cur_ppem = Current_Ppem_Stretched;
- exc->func_read_cvt = Read_CVT_Stretched;
- exc->func_write_cvt = Write_CVT_Stretched;
- exc->func_move_cvt = Move_CVT_Stretched;
- }
- else
- {
- /* square pixels, use normal routines */
- exc->func_cur_ppem = Current_Ppem;
- exc->func_read_cvt = Read_CVT;
- exc->func_write_cvt = Write_CVT;
- exc->func_move_cvt = Move_CVT;
- }
-
- exc->iniRange = exc->curRange;
-
- Compute_Funcs( exc );
- Compute_Round( exc, (FT_Byte)exc->GS.round_state );
-
- /* These flags cancel execution of some opcodes after IUP is called */
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- exc->iupx_called = FALSE;
- exc->iupy_called = FALSE;
-#endif
-
- do
- {
- exc->opcode = exc->code[exc->IP];
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( ft_trace_levels[trace_ttinterp] >= 6 )
- {
- FT_Long cnt = FT_MIN( 8, exc->top );
- FT_Long n;
-
-
- /* if tracing level is 7, show current code position */
- /* and the first few stack elements also */
- FT_TRACE6(( " " ));
- FT_TRACE7(( "%06ld ", exc->IP ));
- FT_TRACE6(( "%s", opcode_name[exc->opcode] + 2 ));
- FT_TRACE7(( "%*s", *opcode_name[exc->opcode] == 'A'
- ? 2
- : 12 - ( *opcode_name[exc->opcode] - '0' ),
- "#" ));
- for ( n = 1; n <= cnt; n++ )
- FT_TRACE7(( " %ld", exc->stack[exc->top - n] ));
- FT_TRACE6(( "\n" ));
- }
-#endif /* FT_DEBUG_LEVEL_TRACE */
-
- if ( ( exc->length = opcode_length[exc->opcode] ) < 0 )
- {
- if ( exc->IP + 1 >= exc->codeSize )
- goto LErrorCodeOverflow_;
-
- exc->length = 2 - exc->length * exc->code[exc->IP + 1];
- }
-
- if ( exc->IP + exc->length > exc->codeSize )
- goto LErrorCodeOverflow_;
-
- /* First, let's check for empty stack and overflow */
- exc->args = exc->top - ( Pop_Push_Count[exc->opcode] >> 4 );
-
- /* `args' is the top of the stack once arguments have been popped. */
- /* One can also interpret it as the index of the last argument. */
- if ( exc->args < 0 )
- {
- if ( exc->pedantic_hinting )
- {
- exc->error = FT_THROW( Too_Few_Arguments );
- goto LErrorLabel_;
- }
-
- /* push zeroes onto the stack */
- for ( i = 0; i < Pop_Push_Count[exc->opcode] >> 4; i++ )
- exc->stack[i] = 0;
- exc->args = 0;
- }
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- if ( exc->opcode == 0x91 )
- {
- /* this is very special: GETVARIATION returns */
- /* a variable number of arguments */
-
- /* it is the job of the application to `activate' GX handling, */
- /* that is, calling any of the GX API functions on the current */
- /* font to select a variation instance */
- if ( exc->face->blend )
- exc->new_top = exc->args + exc->face->blend->num_axis;
- }
- else
-#endif
- exc->new_top = exc->args + ( Pop_Push_Count[exc->opcode] & 15 );
-
- /* `new_top' is the new top of the stack, after the instruction's */
- /* execution. `top' will be set to `new_top' after the `switch' */
- /* statement. */
- if ( exc->new_top > exc->stackSize )
- {
- exc->error = FT_THROW( Stack_Overflow );
- goto LErrorLabel_;
- }
-
- exc->step_ins = TRUE;
- exc->error = FT_Err_Ok;
-
- {
- FT_Long* args = exc->stack + exc->args;
- FT_Byte opcode = exc->opcode;
-
-
- switch ( opcode )
- {
- case 0x00: /* SVTCA y */
- case 0x01: /* SVTCA x */
- case 0x02: /* SPvTCA y */
- case 0x03: /* SPvTCA x */
- case 0x04: /* SFvTCA y */
- case 0x05: /* SFvTCA x */
- Ins_SxyTCA( exc );
- break;
-
- case 0x06: /* SPvTL // */
- case 0x07: /* SPvTL + */
- Ins_SPVTL( exc, args );
- break;
-
- case 0x08: /* SFvTL // */
- case 0x09: /* SFvTL + */
- Ins_SFVTL( exc, args );
- break;
-
- case 0x0A: /* SPvFS */
- Ins_SPVFS( exc, args );
- break;
-
- case 0x0B: /* SFvFS */
- Ins_SFVFS( exc, args );
- break;
-
- case 0x0C: /* GPv */
- Ins_GPV( exc, args );
- break;
-
- case 0x0D: /* GFv */
- Ins_GFV( exc, args );
- break;
-
- case 0x0E: /* SFvTPv */
- Ins_SFVTPV( exc );
- break;
-
- case 0x0F: /* ISECT */
- Ins_ISECT( exc, args );
- break;
-
- case 0x10: /* SRP0 */
- Ins_SRP0( exc, args );
- break;
-
- case 0x11: /* SRP1 */
- Ins_SRP1( exc, args );
- break;
-
- case 0x12: /* SRP2 */
- Ins_SRP2( exc, args );
- break;
-
- case 0x13: /* SZP0 */
- Ins_SZP0( exc, args );
- break;
-
- case 0x14: /* SZP1 */
- Ins_SZP1( exc, args );
- break;
-
- case 0x15: /* SZP2 */
- Ins_SZP2( exc, args );
- break;
-
- case 0x16: /* SZPS */
- Ins_SZPS( exc, args );
- break;
-
- case 0x17: /* SLOOP */
- Ins_SLOOP( exc, args );
- break;
-
- case 0x18: /* RTG */
- Ins_RTG( exc );
- break;
-
- case 0x19: /* RTHG */
- Ins_RTHG( exc );
- break;
-
- case 0x1A: /* SMD */
- Ins_SMD( exc, args );
- break;
-
- case 0x1B: /* ELSE */
- Ins_ELSE( exc );
- break;
-
- case 0x1C: /* JMPR */
- Ins_JMPR( exc, args );
- break;
-
- case 0x1D: /* SCVTCI */
- Ins_SCVTCI( exc, args );
- break;
-
- case 0x1E: /* SSWCI */
- Ins_SSWCI( exc, args );
- break;
-
- case 0x1F: /* SSW */
- Ins_SSW( exc, args );
- break;
-
- case 0x20: /* DUP */
- Ins_DUP( args );
- break;
-
- case 0x21: /* POP */
- Ins_POP();
- break;
-
- case 0x22: /* CLEAR */
- Ins_CLEAR( exc );
- break;
-
- case 0x23: /* SWAP */
- Ins_SWAP( args );
- break;
-
- case 0x24: /* DEPTH */
- Ins_DEPTH( exc, args );
- break;
-
- case 0x25: /* CINDEX */
- Ins_CINDEX( exc, args );
- break;
-
- case 0x26: /* MINDEX */
- Ins_MINDEX( exc, args );
- break;
-
- case 0x27: /* ALIGNPTS */
- Ins_ALIGNPTS( exc, args );
- break;
-
- case 0x28: /* RAW */
- Ins_UNKNOWN( exc );
- break;
-
- case 0x29: /* UTP */
- Ins_UTP( exc, args );
- break;
-
- case 0x2A: /* LOOPCALL */
- Ins_LOOPCALL( exc, args );
- break;
-
- case 0x2B: /* CALL */
- Ins_CALL( exc, args );
- break;
-
- case 0x2C: /* FDEF */
- Ins_FDEF( exc, args );
- break;
-
- case 0x2D: /* ENDF */
- Ins_ENDF( exc );
- break;
-
- case 0x2E: /* MDAP */
- case 0x2F: /* MDAP */
- Ins_MDAP( exc, args );
- break;
-
- case 0x30: /* IUP */
- case 0x31: /* IUP */
- Ins_IUP( exc );
- break;
-
- case 0x32: /* SHP */
- case 0x33: /* SHP */
- Ins_SHP( exc );
- break;
-
- case 0x34: /* SHC */
- case 0x35: /* SHC */
- Ins_SHC( exc, args );
- break;
-
- case 0x36: /* SHZ */
- case 0x37: /* SHZ */
- Ins_SHZ( exc, args );
- break;
-
- case 0x38: /* SHPIX */
- Ins_SHPIX( exc, args );
- break;
-
- case 0x39: /* IP */
- Ins_IP( exc );
- break;
-
- case 0x3A: /* MSIRP */
- case 0x3B: /* MSIRP */
- Ins_MSIRP( exc, args );
- break;
-
- case 0x3C: /* AlignRP */
- Ins_ALIGNRP( exc );
- break;
-
- case 0x3D: /* RTDG */
- Ins_RTDG( exc );
- break;
-
- case 0x3E: /* MIAP */
- case 0x3F: /* MIAP */
- Ins_MIAP( exc, args );
- break;
-
- case 0x40: /* NPUSHB */
- Ins_NPUSHB( exc, args );
- break;
-
- case 0x41: /* NPUSHW */
- Ins_NPUSHW( exc, args );
- break;
-
- case 0x42: /* WS */
- Ins_WS( exc, args );
- break;
-
- case 0x43: /* RS */
- Ins_RS( exc, args );
- break;
-
- case 0x44: /* WCVTP */
- Ins_WCVTP( exc, args );
- break;
-
- case 0x45: /* RCVT */
- Ins_RCVT( exc, args );
- break;
-
- case 0x46: /* GC */
- case 0x47: /* GC */
- Ins_GC( exc, args );
- break;
-
- case 0x48: /* SCFS */
- Ins_SCFS( exc, args );
- break;
-
- case 0x49: /* MD */
- case 0x4A: /* MD */
- Ins_MD( exc, args );
- break;
-
- case 0x4B: /* MPPEM */
- Ins_MPPEM( exc, args );
- break;
-
- case 0x4C: /* MPS */
- Ins_MPS( exc, args );
- break;
-
- case 0x4D: /* FLIPON */
- Ins_FLIPON( exc );
- break;
-
- case 0x4E: /* FLIPOFF */
- Ins_FLIPOFF( exc );
- break;
-
- case 0x4F: /* DEBUG */
- Ins_DEBUG( exc );
- break;
-
- case 0x50: /* LT */
- Ins_LT( args );
- break;
-
- case 0x51: /* LTEQ */
- Ins_LTEQ( args );
- break;
-
- case 0x52: /* GT */
- Ins_GT( args );
- break;
-
- case 0x53: /* GTEQ */
- Ins_GTEQ( args );
- break;
-
- case 0x54: /* EQ */
- Ins_EQ( args );
- break;
-
- case 0x55: /* NEQ */
- Ins_NEQ( args );
- break;
-
- case 0x56: /* ODD */
- Ins_ODD( exc, args );
- break;
-
- case 0x57: /* EVEN */
- Ins_EVEN( exc, args );
- break;
-
- case 0x58: /* IF */
- Ins_IF( exc, args );
- break;
-
- case 0x59: /* EIF */
- Ins_EIF();
- break;
-
- case 0x5A: /* AND */
- Ins_AND( args );
- break;
-
- case 0x5B: /* OR */
- Ins_OR( args );
- break;
-
- case 0x5C: /* NOT */
- Ins_NOT( args );
- break;
-
- case 0x5D: /* DELTAP1 */
- Ins_DELTAP( exc, args );
- break;
-
- case 0x5E: /* SDB */
- Ins_SDB( exc, args );
- break;
-
- case 0x5F: /* SDS */
- Ins_SDS( exc, args );
- break;
-
- case 0x60: /* ADD */
- Ins_ADD( args );
- break;
-
- case 0x61: /* SUB */
- Ins_SUB( args );
- break;
-
- case 0x62: /* DIV */
- Ins_DIV( exc, args );
- break;
-
- case 0x63: /* MUL */
- Ins_MUL( args );
- break;
-
- case 0x64: /* ABS */
- Ins_ABS( args );
- break;
-
- case 0x65: /* NEG */
- Ins_NEG( args );
- break;
-
- case 0x66: /* FLOOR */
- Ins_FLOOR( args );
- break;
-
- case 0x67: /* CEILING */
- Ins_CEILING( args );
- break;
-
- case 0x68: /* ROUND */
- case 0x69: /* ROUND */
- case 0x6A: /* ROUND */
- case 0x6B: /* ROUND */
- Ins_ROUND( exc, args );
- break;
-
- case 0x6C: /* NROUND */
- case 0x6D: /* NROUND */
- case 0x6E: /* NRRUND */
- case 0x6F: /* NROUND */
- Ins_NROUND( exc, args );
- break;
-
- case 0x70: /* WCVTF */
- Ins_WCVTF( exc, args );
- break;
-
- case 0x71: /* DELTAP2 */
- case 0x72: /* DELTAP3 */
- Ins_DELTAP( exc, args );
- break;
-
- case 0x73: /* DELTAC0 */
- case 0x74: /* DELTAC1 */
- case 0x75: /* DELTAC2 */
- Ins_DELTAC( exc, args );
- break;
-
- case 0x76: /* SROUND */
- Ins_SROUND( exc, args );
- break;
-
- case 0x77: /* S45Round */
- Ins_S45ROUND( exc, args );
- break;
-
- case 0x78: /* JROT */
- Ins_JROT( exc, args );
- break;
-
- case 0x79: /* JROF */
- Ins_JROF( exc, args );
- break;
-
- case 0x7A: /* ROFF */
- Ins_ROFF( exc );
- break;
-
- case 0x7B: /* ???? */
- Ins_UNKNOWN( exc );
- break;
-
- case 0x7C: /* RUTG */
- Ins_RUTG( exc );
- break;
-
- case 0x7D: /* RDTG */
- Ins_RDTG( exc );
- break;
-
- case 0x7E: /* SANGW */
- Ins_SANGW();
- break;
-
- case 0x7F: /* AA */
- Ins_AA();
- break;
-
- case 0x80: /* FLIPPT */
- Ins_FLIPPT( exc );
- break;
-
- case 0x81: /* FLIPRGON */
- Ins_FLIPRGON( exc, args );
- break;
-
- case 0x82: /* FLIPRGOFF */
- Ins_FLIPRGOFF( exc, args );
- break;
-
- case 0x83: /* UNKNOWN */
- case 0x84: /* UNKNOWN */
- Ins_UNKNOWN( exc );
- break;
-
- case 0x85: /* SCANCTRL */
- Ins_SCANCTRL( exc, args );
- break;
-
- case 0x86: /* SDPvTL */
- case 0x87: /* SDPvTL */
- Ins_SDPVTL( exc, args );
- break;
-
- case 0x88: /* GETINFO */
- Ins_GETINFO( exc, args );
- break;
-
- case 0x89: /* IDEF */
- Ins_IDEF( exc, args );
- break;
-
- case 0x8A: /* ROLL */
- Ins_ROLL( args );
- break;
-
- case 0x8B: /* MAX */
- Ins_MAX( args );
- break;
-
- case 0x8C: /* MIN */
- Ins_MIN( args );
- break;
-
- case 0x8D: /* SCANTYPE */
- Ins_SCANTYPE( exc, args );
- break;
-
- case 0x8E: /* INSTCTRL */
- Ins_INSTCTRL( exc, args );
- break;
-
- case 0x8F: /* ADJUST */
- case 0x90: /* ADJUST */
- Ins_UNKNOWN( exc );
- break;
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- case 0x91:
- /* it is the job of the application to `activate' GX handling, */
- /* that is, calling any of the GX API functions on the current */
- /* font to select a variation instance */
- if ( exc->face->blend )
- Ins_GETVARIATION( exc, args );
- else
- Ins_UNKNOWN( exc );
- break;
-
- case 0x92:
- /* there is at least one MS font (LaoUI.ttf version 5.01) that */
- /* uses IDEFs for 0x91 and 0x92; for this reason we activate */
- /* GETDATA for GX fonts only, similar to GETVARIATION */
- if ( exc->face->blend )
- Ins_GETDATA( args );
- else
- Ins_UNKNOWN( exc );
- break;
-#endif
-
- default:
- if ( opcode >= 0xE0 )
- Ins_MIRP( exc, args );
- else if ( opcode >= 0xC0 )
- Ins_MDRP( exc, args );
- else if ( opcode >= 0xB8 )
- Ins_PUSHW( exc, args );
- else if ( opcode >= 0xB0 )
- Ins_PUSHB( exc, args );
- else
- Ins_UNKNOWN( exc );
- }
- }
-
- if ( exc->error )
- {
- switch ( exc->error )
- {
- /* looking for redefined instructions */
- case FT_ERR( Invalid_Opcode ):
- {
- TT_DefRecord* def = exc->IDefs;
- TT_DefRecord* limit = FT_OFFSET( def, exc->numIDefs );
-
-
- for ( ; def < limit; def++ )
- {
- if ( def->active && exc->opcode == (FT_Byte)def->opc )
- {
- TT_CallRec* callrec;
-
-
- if ( exc->callTop >= exc->callSize )
- {
- exc->error = FT_THROW( Invalid_Reference );
- goto LErrorLabel_;
- }
-
- callrec = &exc->callStack[exc->callTop];
-
- callrec->Caller_Range = exc->curRange;
- callrec->Caller_IP = exc->IP + 1;
- callrec->Cur_Count = 1;
- callrec->Def = def;
-
- if ( Ins_Goto_CodeRange( exc,
- def->range,
- def->start ) == FAILURE )
- goto LErrorLabel_;
-
- goto LSuiteLabel_;
- }
- }
- }
-
- exc->error = FT_THROW( Invalid_Opcode );
- goto LErrorLabel_;
-
-#if 0
- break; /* Unreachable code warning suppression. */
- /* Leave to remind in case a later change the editor */
- /* to consider break; */
-#endif
-
- default:
- goto LErrorLabel_;
-
-#if 0
- break;
-#endif
- }
- }
-
- exc->top = exc->new_top;
-
- if ( exc->step_ins )
- exc->IP += exc->length;
-
- /* increment instruction counter and check if we didn't */
- /* run this program for too long (e.g. infinite loops). */
- if ( ++ins_counter > TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES )
- {
- exc->error = FT_THROW( Execution_Too_Long );
- goto LErrorLabel_;
- }
-
- LSuiteLabel_:
- if ( exc->IP >= exc->codeSize )
- {
- if ( exc->callTop > 0 )
- {
- exc->error = FT_THROW( Code_Overflow );
- goto LErrorLabel_;
- }
- else
- goto LNo_Error_;
- }
- } while ( !exc->instruction_trap );
-
- LNo_Error_:
- FT_TRACE4(( " %ld instruction%s executed\n",
- ins_counter,
- ins_counter == 1 ? "" : "s" ));
-
- return FT_Err_Ok;
-
- LErrorCodeOverflow_:
- exc->error = FT_THROW( Code_Overflow );
-
- LErrorLabel_:
- if ( exc->error && !exc->instruction_trap )
- FT_TRACE1(( " The interpreter returned error 0x%x\n", exc->error ));
-
- return exc->error;
- }
-
-#else /* !TT_USE_BYTECODE_INTERPRETER */
-
- /* ANSI C doesn't like empty source files */
- typedef int tt_interp_dummy_;
-
-#endif /* !TT_USE_BYTECODE_INTERPRETER */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/truetype/ttinterp.h b/contrib/libs/freetype/src/truetype/ttinterp.h
deleted file mode 100644
index 4f1a9bbc67..0000000000
--- a/contrib/libs/freetype/src/truetype/ttinterp.h
+++ /dev/null
@@ -1,465 +0,0 @@
-/****************************************************************************
- *
- * ttinterp.h
- *
- * TrueType bytecode interpreter (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef TTINTERP_H_
-#define TTINTERP_H_
-
-#include "ttobjs.h"
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * Rounding mode constants.
- */
-#define TT_Round_Off 5
-#define TT_Round_To_Half_Grid 0
-#define TT_Round_To_Grid 1
-#define TT_Round_To_Double_Grid 2
-#define TT_Round_Up_To_Grid 4
-#define TT_Round_Down_To_Grid 3
-#define TT_Round_Super 6
-#define TT_Round_Super_45 7
-
-
- /**************************************************************************
- *
- * Function types used by the interpreter, depending on various modes
- * (e.g. the rounding mode, whether to render a vertical or horizontal
- * line etc).
- *
- */
-
- /* Rounding function */
- typedef FT_F26Dot6
- (*TT_Round_Func)( TT_ExecContext exc,
- FT_F26Dot6 distance,
- FT_Int color );
-
- /* Point displacement along the freedom vector routine */
- typedef void
- (*TT_Move_Func)( TT_ExecContext exc,
- TT_GlyphZone zone,
- FT_UShort point,
- FT_F26Dot6 distance );
-
- /* Distance projection along one of the projection vectors */
- typedef FT_F26Dot6
- (*TT_Project_Func)( TT_ExecContext exc,
- FT_Pos dx,
- FT_Pos dy );
-
- /* getting current ppem. Take care of non-square pixels if necessary */
- typedef FT_Long
- (*TT_Cur_Ppem_Func)( TT_ExecContext exc );
-
- /* reading a cvt value. Take care of non-square pixels if necessary */
- typedef FT_F26Dot6
- (*TT_Get_CVT_Func)( TT_ExecContext exc,
- FT_ULong idx );
-
- /* setting or moving a cvt value. Take care of non-square pixels */
- /* if necessary */
- typedef void
- (*TT_Set_CVT_Func)( TT_ExecContext exc,
- FT_ULong idx,
- FT_F26Dot6 value );
-
-
- /**************************************************************************
- *
- * This structure defines a call record, used to manage function calls.
- */
- typedef struct TT_CallRec_
- {
- FT_Int Caller_Range;
- FT_Long Caller_IP;
- FT_Long Cur_Count;
-
- TT_DefRecord *Def; /* either FDEF or IDEF */
-
- } TT_CallRec, *TT_CallStack;
-
-
- /**************************************************************************
- *
- * The main structure for the interpreter which collects all necessary
- * variables and states.
- *
- * Members that are initialized by `TT_Load_Context` are marked with '!'.
- * Members that are initialized by `TT_Run_Context` are marked with '@'.
- */
- typedef struct TT_ExecContextRec_
- {
- TT_Face face; /* ! */
- TT_Size size; /* ! */
- FT_Memory memory;
-
- /* instructions state */
-
- FT_Error error; /* last execution error */
-
- FT_Long top; /* @ top of exec. stack */
-
- FT_Long stackSize; /* ! size of exec. stack */
- FT_Long* stack; /* ! current exec. stack */
-
- FT_Long args;
- FT_Long new_top; /* new top after exec. */
-
- TT_GlyphZoneRec zp0, /* @! zone records */
- zp1, /* @! */
- zp2, /* @! */
- pts, /* ! */
- twilight; /* ! */
-
- FT_Long pointSize; /* ! in 26.6 format */
- FT_Size_Metrics metrics; /* ! */
- TT_Size_Metrics tt_metrics; /* ! size metrics */
-
- TT_GraphicsState GS; /* !@ current graphics state */
-
- FT_Int iniRange; /* initial code range number */
- FT_Int curRange; /* current code range number */
- FT_Byte* code; /* current code range */
- FT_Long IP; /* current instruction pointer */
- FT_Long codeSize; /* size of current range */
-
- FT_Byte opcode; /* current opcode */
- FT_Int length; /* length of current opcode */
-
- FT_Bool step_ins; /* true if the interpreter must */
- /* increment IP after ins. exec */
- FT_ULong cvtSize; /* ! */
- FT_Long* cvt; /* ! */
- FT_ULong glyfCvtSize;
- FT_Long* glyfCvt; /* cvt working copy for glyph */
-
- FT_UInt glyphSize; /* ! glyph instructions buffer size */
- FT_Byte* glyphIns; /* ! glyph instructions buffer */
-
- FT_UInt numFDefs; /* ! number of function defs */
- FT_UInt maxFDefs; /* ! maximum number of function defs */
- TT_DefArray FDefs; /* table of FDefs entries */
-
- FT_UInt numIDefs; /* ! number of instruction defs */
- FT_UInt maxIDefs; /* ! maximum number of ins defs */
- TT_DefArray IDefs; /* table of IDefs entries */
-
- FT_UInt maxFunc; /* ! maximum function index */
- FT_UInt maxIns; /* ! maximum instruction index */
-
- FT_Int callTop, /* @ top of call stack during execution */
- callSize; /* size of call stack */
- TT_CallStack callStack; /* call stack */
-
- FT_UShort maxPoints; /* capacity of this context's `pts' */
- FT_Short maxContours; /* record, expressed in points and */
- /* contours. */
-
- TT_CodeRangeTable codeRangeTable; /* ! table of valid code ranges */
- /* useful for the debugger */
-
- FT_UShort storeSize; /* ! size of current storage */
- FT_Long* storage; /* ! storage area */
- FT_UShort glyfStoreSize;
- FT_Long* glyfStorage; /* storage working copy for glyph */
-
- FT_F26Dot6 period; /* values used for the */
- FT_F26Dot6 phase; /* `SuperRounding' */
- FT_F26Dot6 threshold;
-
- FT_Bool instruction_trap; /* ! If `True', the interpreter */
- /* exits after each instruction */
-
- TT_GraphicsState default_GS; /* graphics state resulting from */
- /* the prep program */
- FT_Bool is_composite; /* true if the glyph is composite */
- FT_Bool pedantic_hinting; /* true if pedantic interpretation */
-
- /* latest interpreter additions */
-
- FT_Long F_dot_P; /* dot product of freedom and projection */
- /* vectors */
- TT_Round_Func func_round; /* current rounding function */
-
- TT_Project_Func func_project, /* current projection function */
- func_dualproj, /* current dual proj. function */
- func_freeProj; /* current freedom proj. func */
-
- TT_Move_Func func_move; /* current point move function */
- TT_Move_Func func_move_orig; /* move original position function */
-
- TT_Cur_Ppem_Func func_cur_ppem; /* get current proj. ppem value */
-
- TT_Get_CVT_Func func_read_cvt; /* read a cvt entry */
- TT_Set_CVT_Func func_write_cvt; /* write a cvt entry (in pixels) */
- TT_Set_CVT_Func func_move_cvt; /* incr a cvt entry (in pixels) */
-
- FT_Bool grayscale; /* bi-level hinting and */
- /* grayscale rendering */
-
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- /*
- * FreeType supports ClearType-like hinting of TrueType fonts through
- * the version 40 interpreter. This is achieved through several hacks
- * in the base (v35) interpreter, as detailed below.
- *
- * ClearType is an umbrella term for several rendering techniques
- * employed by Microsoft's various GUI and rendering toolkit
- * implementations, most importantly: subpixel rendering for using the
- * RGB subpixels of LCDs to approximately triple the perceived
- * resolution on the x-axis and subpixel hinting for positioning stems
- * on subpixel borders. TrueType programming is explicit, i.e., fonts
- * must be programmed to take advantage of ClearType's possibilities.
- *
- * When ClearType was introduced, it seemed unlikely that all fonts
- * would be reprogrammed, so Microsoft decided to implement a backward
- * compatibility mode. It employs several simple to complicated
- * assumptions and tricks, many of them font-dependent, that modify the
- * interpretation of the bytecode contained in these fonts to retrofit
- * them into a ClearType-y look. The quality of the results varies.
- * Most (web)fonts that were released since then have come to rely on
- * these hacks to render correctly, even some of Microsoft's flagship
- * fonts (e.g., Calibri, Cambria, Segoe UI).
- *
- * FreeType's minimal subpixel hinting code (interpreter version 40)
- * employs a small list of font-agnostic hacks loosely based on the
- * public information available on Microsoft's compatibility mode[2].
- * The focus is on modern (web)fonts rather than legacy fonts that were
- * made for monochrome rendering. It will not match ClearType rendering
- * exactly. Unlike the `Infinality' code (interpreter version 38) that
- * came before, it will not try to toggle hacks for specific fonts for
- * performance and complexity reasons. It will fall back to version 35
- * behavior for tricky fonts[1] or when monochrome rendering is
- * requested.
- *
- * Major hacks
- *
- * - Any point movement on the x axis is ignored (cf. `Direct_Move' and
- * `Direct_Move_X'). This has the smallest code footprint and single
- * biggest effect. The ClearType way to increase resolution is
- * supersampling the x axis, the FreeType way is ignoring instructions
- * on the x axis, which gives the same result in the majority of
- * cases.
- *
- * - Points are not moved post-IUP (neither on the x nor on the y axis),
- * except the x component of diagonal moves post-IUP (cf.
- * `Direct_Move', `Direct_Move_Y', `Move_Zp2_Point'). Post-IUP
- * changes are commonly used to `fix' pixel patterns which has little
- * use outside monochrome rendering.
- *
- * - SHPIX and DELTAP don't execute unless moving a composite on the
- * y axis or moving a previously y touched point. SHPIX additionally
- * denies movement on the x axis (cf. `Ins_SHPIX' and `Ins_DELTAP').
- * Both instructions are commonly used to `fix' pixel patterns for
- * monochrome or Windows's GDI rendering but make little sense for
- * FreeType rendering. Both can distort the outline. See [2] for
- * details.
- *
- * - The hdmx table and modifications to phantom points are ignored.
- * Bearings and advance widths remain unchanged (except rounding them
- * outside the interpreter!), cf. `compute_glyph_metrics' and
- * `TT_Hint_Glyph'. Letting non-native-ClearType fonts modify spacing
- * might mess up spacing.
- *
- * Minor hacks
- *
- * - FLIPRGON, FLIPRGOFF, and FLIPPT don't execute post-IUP. This
- * prevents dents in e.g. Arial-Regular's `D' and `G' glyphs at
- * various sizes.
- *
- * (Post-IUP is the state after both IUP[x] and IUP[y] have been
- * executed.)
- *
- * The best results are achieved for fonts that were from the outset
- * designed with ClearType in mind, meaning they leave the x axis mostly
- * alone and don't mess with the `final' outline to produce more
- * pleasing pixel patterns. The harder the designer tried to produce
- * very specific patterns (`superhinting') for pre-ClearType-displays,
- * the worse the results.
- *
- * Microsoft defines a way to turn off backward compatibility and
- * interpret instructions as before (called `native ClearType')[2][3].
- * The font designer then regains full control and is responsible for
- * making the font work correctly with ClearType without any
- * hand-holding by the interpreter or rasterizer[4]. The v40
- * interpreter assumes backward compatibility by default, which can be
- * turned off the same way by executing the following in the control
- * program (cf. `Ins_INSTCTRL').
- *
- * #PUSH 4,3
- * INSTCTRL[]
- *
- * [1] Tricky fonts as FreeType defines them rely on the bytecode
- * interpreter to display correctly. Hacks can interfere with them,
- * so they get treated like native ClearType fonts (v40 with
- * backward compatibility turned off). Cf. `TT_RunIns'.
- *
- * [2] Proposed by Microsoft's Greg Hitchcock in
- * https://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
- *
- * [3] Beat Stamm describes it in more detail:
- * http://rastertragedy.com/RTRCh4.htm#Sec12.
- *
- * [4] The list of `native ClearType' fonts is small at the time of this
- * writing; I found the following on a Windows 10 Update 1511
- * installation: Constantia, Corbel, Sitka, Malgun Gothic, Microsoft
- * JhengHei (Bold and UI Bold), Microsoft YaHei (Bold and UI Bold),
- * SimSun, NSimSun, and Yu Gothic.
- *
- */
-
- /* Using v40 implies subpixel hinting, unless FT_RENDER_MODE_MONO has been
- * requested. Used to detect interpreter */
- /* version switches. `_lean' to differentiate from the Infinality */
- /* `subpixel_hinting', which is managed differently. */
- FT_Bool subpixel_hinting_lean;
-
- /* Long side of a LCD subpixel is vertical (e.g., screen is rotated). */
- /* `_lean' to differentiate from the Infinality `vertical_lcd', which */
- /* is managed differently. */
- FT_Bool vertical_lcd_lean;
-
- /* Default to backward compatibility mode in v40 interpreter. If */
- /* this is false, it implies the interpreter is in v35 or in native */
- /* ClearType mode. */
- FT_Bool backward_compatibility;
-
- /* Useful for detecting and denying post-IUP trickery that is usually */
- /* used to fix pixel patterns (`superhinting'). */
- FT_Bool iupx_called;
- FT_Bool iupy_called;
-
- /* ClearType hinting and grayscale rendering, as used by Universal */
- /* Windows Platform apps (Windows 8 and above). Like the standard */
- /* colorful ClearType mode, it utilizes a vastly increased virtual */
- /* resolution on the x axis. Different from bi-level hinting and */
- /* grayscale rendering, the old mode from Win9x days that roughly */
- /* adheres to the physical pixel grid on both axes. */
- FT_Bool grayscale_cleartype;
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL */
-
- /* We maintain two counters (in addition to the instruction counter) */
- /* that act as loop detectors for LOOPCALL and jump opcodes with */
- /* negative arguments. */
- FT_ULong loopcall_counter;
- FT_ULong loopcall_counter_max;
- FT_ULong neg_jump_counter;
- FT_ULong neg_jump_counter_max;
-
- } TT_ExecContextRec;
-
-
- extern const TT_GraphicsState tt_default_graphics_state;
-
-
-#ifdef TT_USE_BYTECODE_INTERPRETER
- FT_LOCAL( void )
- TT_Goto_CodeRange( TT_ExecContext exec,
- FT_Int range,
- FT_Long IP );
-
- FT_LOCAL( void )
- TT_Set_CodeRange( TT_ExecContext exec,
- FT_Int range,
- void* base,
- FT_Long length );
-
- FT_LOCAL( void )
- TT_Clear_CodeRange( TT_ExecContext exec,
- FT_Int range );
-#endif /* TT_USE_BYTECODE_INTERPRETER */
-
-
- /**************************************************************************
- *
- * @Function:
- * TT_New_Context
- *
- * @Description:
- * Create a `TT_ExecContext`. Note that there is now an execution
- * context per `TT_Size` that is not shared among faces.
- *
- * @Input:
- * driver ::
- * A handle to the driver, used for memory allocation.
- *
- * @Return:
- * A handle to a new empty execution context.
- *
- * @Note:
- * Only the glyph loader and debugger should call this function.
- * (And right now only the glyph loader uses it.)
- */
- FT_EXPORT( TT_ExecContext )
- TT_New_Context( TT_Driver driver );
-
-
-#ifdef TT_USE_BYTECODE_INTERPRETER
- FT_LOCAL( void )
- TT_Done_Context( TT_ExecContext exec );
-
- FT_LOCAL( FT_Error )
- TT_Load_Context( TT_ExecContext exec,
- TT_Face face,
- TT_Size size );
-
- FT_LOCAL( void )
- TT_Save_Context( TT_ExecContext exec,
- TT_Size ins );
-
- FT_LOCAL( FT_Error )
- TT_Run_Context( TT_ExecContext exec );
-#endif /* TT_USE_BYTECODE_INTERPRETER */
-
-
- /**************************************************************************
- *
- * @Function:
- * TT_RunIns
- *
- * @Description:
- * Executes one or more instruction in the execution context. This
- * is the main function of the TrueType opcode interpreter.
- *
- * @Input:
- * exec ::
- * A handle to the target execution context.
- *
- * @Return:
- * FreeType error code. 0 means success.
- *
- * @Note:
- * Only the object manager and debugger should call this function.
- *
- * This function is publicly exported because it is directly
- * invoked by the TrueType debugger.
- */
- FT_EXPORT( FT_Error )
- TT_RunIns( void* exec );
-
-
-FT_END_HEADER
-
-#endif /* TTINTERP_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/truetype/ttobjs.c b/contrib/libs/freetype/src/truetype/ttobjs.c
deleted file mode 100644
index d0ac318120..0000000000
--- a/contrib/libs/freetype/src/truetype/ttobjs.c
+++ /dev/null
@@ -1,1543 +0,0 @@
-/****************************************************************************
- *
- * ttobjs.c
- *
- * Objects manager (body).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/tttags.h>
-#include <freetype/internal/sfnt.h>
-#include <freetype/ftdriver.h>
-
-#include "ttgload.h"
-#include "ttpload.h"
-
-#include "tterrors.h"
-
-#ifdef TT_USE_BYTECODE_INTERPRETER
-#include "ttinterp.h"
-#endif
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
-#include "ttgxvar.h"
-#endif
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT ttobjs
-
-
-#ifdef TT_USE_BYTECODE_INTERPRETER
-
- /**************************************************************************
- *
- * GLYPH ZONE FUNCTIONS
- *
- */
-
-
- /**************************************************************************
- *
- * @Function:
- * tt_glyphzone_done
- *
- * @Description:
- * Deallocate a glyph zone.
- *
- * @Input:
- * zone ::
- * A pointer to the target glyph zone.
- */
- FT_LOCAL_DEF( void )
- tt_glyphzone_done( TT_GlyphZone zone )
- {
- FT_Memory memory = zone->memory;
-
-
- if ( memory )
- {
- FT_FREE( zone->contours );
- FT_FREE( zone->tags );
- FT_FREE( zone->cur );
- FT_FREE( zone->org );
- FT_FREE( zone->orus );
-
- zone->max_points = zone->n_points = 0;
- zone->max_contours = zone->n_contours = 0;
- zone->memory = NULL;
- }
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * tt_glyphzone_new
- *
- * @Description:
- * Allocate a new glyph zone.
- *
- * @Input:
- * memory ::
- * A handle to the current memory object.
- *
- * maxPoints ::
- * The capacity of glyph zone in points.
- *
- * maxContours ::
- * The capacity of glyph zone in contours.
- *
- * @Output:
- * zone ::
- * A pointer to the target glyph zone record.
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
- FT_LOCAL_DEF( FT_Error )
- tt_glyphzone_new( FT_Memory memory,
- FT_UShort maxPoints,
- FT_UShort maxContours,
- TT_GlyphZone zone )
- {
- FT_Error error;
-
-
- FT_ZERO( zone );
- zone->memory = memory;
-
- if ( FT_NEW_ARRAY( zone->org, maxPoints ) ||
- FT_NEW_ARRAY( zone->cur, maxPoints ) ||
- FT_NEW_ARRAY( zone->orus, maxPoints ) ||
- FT_NEW_ARRAY( zone->tags, maxPoints ) ||
- FT_NEW_ARRAY( zone->contours, maxContours ) )
- {
- tt_glyphzone_done( zone );
- }
- else
- {
- zone->max_points = maxPoints;
- zone->max_contours = maxContours;
- }
-
- return error;
- }
-
-
- /*
- * Fonts embedded in PDFs are made unique by prepending randomization
- * prefixes to their names: as defined in Section 5.5.3, 'Font Subsets',
- * of the PDF Reference, they consist of 6 uppercase letters followed by
- * the `+` sign. For safety, we do not skip prefixes violating this rule.
- */
-
- static const FT_String*
- tt_skip_pdffont_random_tag( const FT_String* name )
- {
- if ( ft_isupper( name[0] ) &&
- ft_isupper( name[1] ) &&
- ft_isupper( name[2] ) &&
- ft_isupper( name[3] ) &&
- ft_isupper( name[4] ) &&
- ft_isupper( name[5] ) &&
- '+' == name[6] &&
- name[7] )
- {
- FT_TRACE7(( "name without randomization tag: %s\n", name + 7 ));
- return name + 7;
- }
-
- return name;
- }
-
-
- /* Compare the face with a list of well-known `tricky' fonts. */
- /* This list shall be expanded as we find more of them. */
-
- static FT_Bool
- tt_check_trickyness_family( const FT_String* name )
- {
-
-#define TRICK_NAMES_MAX_CHARACTERS 19
-#define TRICK_NAMES_COUNT 20
-
- static const char trick_names[TRICK_NAMES_COUNT]
- [TRICK_NAMES_MAX_CHARACTERS + 1] =
- {
- /*
- PostScript names are given in brackets if they differ from the
- family name. The version numbers, together with the copyright or
- release year data, are taken from fonts available to the
- developers.
-
- Note that later versions of the fonts might be no longer tricky;
- for example, `MingLiU' version 7.00 (file `mingliu.ttc' from
- Windows 7) is an ordinary TTC with non-tricky subfonts.
- */
-
- "cpop", /* dftt-p7.ttf; version 1.00, 1992 [DLJGyShoMedium] */
- "DFGirl-W6-WIN-BF", /* dftt-h6.ttf; version 1.00, 1993 */
- "DFGothic-EB", /* DynaLab Inc. 1992-1995 */
- "DFGyoSho-Lt", /* DynaLab Inc. 1992-1995 */
- "DFHei", /* DynaLab Inc. 1992-1995 [DFHei-Bd-WIN-HK-BF] */
- /* covers "DFHei-Md-HK-BF", maybe DynaLab Inc. */
-
- "DFHSGothic-W5", /* DynaLab Inc. 1992-1995 */
- "DFHSMincho-W3", /* DynaLab Inc. 1992-1995 */
- "DFHSMincho-W7", /* DynaLab Inc. 1992-1995 */
- "DFKaiSho-SB", /* dfkaisb.ttf */
- "DFKaiShu", /* covers "DFKaiShu-Md-HK-BF", maybe DynaLab Inc. */
- "DFKai-SB", /* kaiu.ttf; version 3.00, 1998 [DFKaiShu-SB-Estd-BF] */
-
- "DFMing", /* DynaLab Inc. 1992-1995 [DFMing-Md-WIN-HK-BF] */
- /* covers "DFMing-Bd-HK-BF", maybe DynaLab Inc. */
-
- "DLC", /* dftt-m7.ttf; version 1.00, 1993 [DLCMingBold] */
- /* dftt-f5.ttf; version 1.00, 1993 [DLCFongSung] */
- /* covers following */
- /* "DLCHayMedium", dftt-b5.ttf; version 1.00, 1993 */
- /* "DLCHayBold", dftt-b7.ttf; version 1.00, 1993 */
- /* "DLCKaiMedium", dftt-k5.ttf; version 1.00, 1992 */
- /* "DLCLiShu", dftt-l5.ttf; version 1.00, 1992 */
- /* "DLCRoundBold", dftt-r7.ttf; version 1.00, 1993 */
-
- "HuaTianKaiTi?", /* htkt2.ttf */
- "HuaTianSongTi?", /* htst3.ttf */
- "Ming(for ISO10646)", /* hkscsiic.ttf; version 0.12, 2007 [Ming] */
- /* iicore.ttf; version 0.07, 2007 [Ming] */
- "MingLiU", /* mingliu.ttf */
- /* mingliu.ttc; version 3.21, 2001 */
- "MingMedium", /* dftt-m5.ttf; version 1.00, 1993 [DLCMingMedium] */
- "PMingLiU", /* mingliu.ttc; version 3.21, 2001 */
- "MingLi43", /* mingli.ttf; version 1.00, 1992 */
- };
-
- int nn;
- const FT_String* name_without_tag;
-
-
- name_without_tag = tt_skip_pdffont_random_tag( name );
- for ( nn = 0; nn < TRICK_NAMES_COUNT; nn++ )
- if ( ft_strstr( name_without_tag, trick_names[nn] ) )
- return TRUE;
-
- return FALSE;
- }
-
-
- /* XXX: This function should be in the `sfnt' module. */
-
- /* Some PDF generators clear the checksums in the TrueType header table. */
- /* For example, Quartz ContextPDF clears all entries, or Bullzip PDF */
- /* Printer clears the entries for subsetted subtables. We thus have to */
- /* recalculate the checksums where necessary. */
-
- static FT_UInt32
- tt_synth_sfnt_checksum( FT_Stream stream,
- FT_ULong length )
- {
- FT_Error error;
- FT_UInt32 checksum = 0;
- FT_Byte* p;
- FT_Int shift;
-
-
- if ( FT_FRAME_ENTER( length ) )
- return 0;
-
- p = (FT_Byte*)stream->cursor;
-
- for ( ; length > 3; length -= 4 )
- checksum += FT_NEXT_ULONG( p );
-
- for ( shift = 24; length > 0; length--, shift -=8 )
- checksum += (FT_UInt32)FT_NEXT_BYTE( p ) << shift;
-
- FT_FRAME_EXIT();
-
- return checksum;
- }
-
-
- /* XXX: This function should be in the `sfnt' module. */
-
- static FT_ULong
- tt_get_sfnt_checksum( TT_Face face,
- FT_UShort i )
- {
-#if 0 /* if we believe the written value, use following part. */
- if ( face->dir_tables[i].CheckSum )
- return face->dir_tables[i].CheckSum;
-#endif
-
- if ( !face->goto_table )
- return 0;
-
- if ( face->goto_table( face,
- face->dir_tables[i].Tag,
- face->root.stream,
- NULL ) )
- return 0;
-
- return (FT_ULong)tt_synth_sfnt_checksum( face->root.stream,
- face->dir_tables[i].Length );
- }
-
-
- typedef struct tt_sfnt_id_rec_
- {
- FT_ULong CheckSum;
- FT_ULong Length;
-
- } tt_sfnt_id_rec;
-
-
- static FT_Bool
- tt_check_trickyness_sfnt_ids( TT_Face face )
- {
-#define TRICK_SFNT_IDS_PER_FACE 3
-#define TRICK_SFNT_IDS_NUM_FACES 31
-
- static const tt_sfnt_id_rec sfnt_id[TRICK_SFNT_IDS_NUM_FACES]
- [TRICK_SFNT_IDS_PER_FACE] =
- {
-
-#define TRICK_SFNT_ID_cvt 0
-#define TRICK_SFNT_ID_fpgm 1
-#define TRICK_SFNT_ID_prep 2
-
- { /* MingLiU 1995 */
- { 0x05BCF058UL, 0x000002E4UL }, /* cvt */
- { 0x28233BF1UL, 0x000087C4UL }, /* fpgm */
- { 0xA344A1EAUL, 0x000001E1UL } /* prep */
- },
- { /* MingLiU 1996- */
- { 0x05BCF058UL, 0x000002E4UL }, /* cvt */
- { 0x28233BF1UL, 0x000087C4UL }, /* fpgm */
- { 0xA344A1EBUL, 0x000001E1UL } /* prep */
- },
- { /* DFGothic-EB */
- { 0x12C3EBB2UL, 0x00000350UL }, /* cvt */
- { 0xB680EE64UL, 0x000087A7UL }, /* fpgm */
- { 0xCE939563UL, 0x00000758UL } /* prep */
- },
- { /* DFGyoSho-Lt */
- { 0x11E5EAD4UL, 0x00000350UL }, /* cvt */
- { 0xCE5956E9UL, 0x0000BC85UL }, /* fpgm */
- { 0x8272F416UL, 0x00000045UL } /* prep */
- },
- { /* DFHei-Md-HK-BF */
- { 0x1257EB46UL, 0x00000350UL }, /* cvt */
- { 0xF699D160UL, 0x0000715FUL }, /* fpgm */
- { 0xD222F568UL, 0x000003BCUL } /* prep */
- },
- { /* DFHSGothic-W5 */
- { 0x1262EB4EUL, 0x00000350UL }, /* cvt */
- { 0xE86A5D64UL, 0x00007940UL }, /* fpgm */
- { 0x7850F729UL, 0x000005FFUL } /* prep */
- },
- { /* DFHSMincho-W3 */
- { 0x122DEB0AUL, 0x00000350UL }, /* cvt */
- { 0x3D16328AUL, 0x0000859BUL }, /* fpgm */
- { 0xA93FC33BUL, 0x000002CBUL } /* prep */
- },
- { /* DFHSMincho-W7 */
- { 0x125FEB26UL, 0x00000350UL }, /* cvt */
- { 0xA5ACC982UL, 0x00007EE1UL }, /* fpgm */
- { 0x90999196UL, 0x0000041FUL } /* prep */
- },
- { /* DFKaiShu */
- { 0x11E5EAD4UL, 0x00000350UL }, /* cvt */
- { 0x5A30CA3BUL, 0x00009063UL }, /* fpgm */
- { 0x13A42602UL, 0x0000007EUL } /* prep */
- },
- { /* DFKaiShu, variant */
- { 0x11E5EAD4UL, 0x00000350UL }, /* cvt */
- { 0xA6E78C01UL, 0x00008998UL }, /* fpgm */
- { 0x13A42602UL, 0x0000007EUL } /* prep */
- },
- { /* DFKaiShu-Md-HK-BF */
- { 0x11E5EAD4UL, 0x00000360UL }, /* cvt */
- { 0x9DB282B2UL, 0x0000C06EUL }, /* fpgm */
- { 0x53E6D7CAUL, 0x00000082UL } /* prep */
- },
- { /* DFMing-Bd-HK-BF */
- { 0x1243EB18UL, 0x00000350UL }, /* cvt */
- { 0xBA0A8C30UL, 0x000074ADUL }, /* fpgm */
- { 0xF3D83409UL, 0x0000037BUL } /* prep */
- },
- { /* DLCLiShu */
- { 0x07DCF546UL, 0x00000308UL }, /* cvt */
- { 0x40FE7C90UL, 0x00008E2AUL }, /* fpgm */
- { 0x608174B5UL, 0x0000007AUL } /* prep */
- },
- { /* DLCHayBold */
- { 0xEB891238UL, 0x00000308UL }, /* cvt */
- { 0xD2E4DCD4UL, 0x0000676FUL }, /* fpgm */
- { 0x8EA5F293UL, 0x000003B8UL } /* prep */
- },
- { /* HuaTianKaiTi */
- { 0xFFFBFFFCUL, 0x00000008UL }, /* cvt */
- { 0x9C9E48B8UL, 0x0000BEA2UL }, /* fpgm */
- { 0x70020112UL, 0x00000008UL } /* prep */
- },
- { /* HuaTianSongTi */
- { 0xFFFBFFFCUL, 0x00000008UL }, /* cvt */
- { 0x0A5A0483UL, 0x00017C39UL }, /* fpgm */
- { 0x70020112UL, 0x00000008UL } /* prep */
- },
- { /* NEC fadpop7.ttf */
- { 0x00000000UL, 0x00000000UL }, /* cvt */
- { 0x40C92555UL, 0x000000E5UL }, /* fpgm */
- { 0xA39B58E3UL, 0x0000117CUL } /* prep */
- },
- { /* NEC fadrei5.ttf */
- { 0x00000000UL, 0x00000000UL }, /* cvt */
- { 0x33C41652UL, 0x000000E5UL }, /* fpgm */
- { 0x26D6C52AUL, 0x00000F6AUL } /* prep */
- },
- { /* NEC fangot7.ttf */
- { 0x00000000UL, 0x00000000UL }, /* cvt */
- { 0x6DB1651DUL, 0x0000019DUL }, /* fpgm */
- { 0x6C6E4B03UL, 0x00002492UL } /* prep */
- },
- { /* NEC fangyo5.ttf */
- { 0x00000000UL, 0x00000000UL }, /* cvt */
- { 0x40C92555UL, 0x000000E5UL }, /* fpgm */
- { 0xDE51FAD0UL, 0x0000117CUL } /* prep */
- },
- { /* NEC fankyo5.ttf */
- { 0x00000000UL, 0x00000000UL }, /* cvt */
- { 0x85E47664UL, 0x000000E5UL }, /* fpgm */
- { 0xA6C62831UL, 0x00001CAAUL } /* prep */
- },
- { /* NEC fanrgo5.ttf */
- { 0x00000000UL, 0x00000000UL }, /* cvt */
- { 0x2D891CFDUL, 0x0000019DUL }, /* fpgm */
- { 0xA0604633UL, 0x00001DE8UL } /* prep */
- },
- { /* NEC fangot5.ttc */
- { 0x00000000UL, 0x00000000UL }, /* cvt */
- { 0x40AA774CUL, 0x000001CBUL }, /* fpgm */
- { 0x9B5CAA96UL, 0x00001F9AUL } /* prep */
- },
- { /* NEC fanmin3.ttc */
- { 0x00000000UL, 0x00000000UL }, /* cvt */
- { 0x0D3DE9CBUL, 0x00000141UL }, /* fpgm */
- { 0xD4127766UL, 0x00002280UL } /* prep */
- },
- { /* NEC FA-Gothic, 1996 */
- { 0x00000000UL, 0x00000000UL }, /* cvt */
- { 0x4A692698UL, 0x000001F0UL }, /* fpgm */
- { 0x340D4346UL, 0x00001FCAUL } /* prep */
- },
- { /* NEC FA-Minchou, 1996 */
- { 0x00000000UL, 0x00000000UL }, /* cvt */
- { 0xCD34C604UL, 0x00000166UL }, /* fpgm */
- { 0x6CF31046UL, 0x000022B0UL } /* prep */
- },
- { /* NEC FA-RoundGothicB, 1996 */
- { 0x00000000UL, 0x00000000UL }, /* cvt */
- { 0x5DA75315UL, 0x0000019DUL }, /* fpgm */
- { 0x40745A5FUL, 0x000022E0UL } /* prep */
- },
- { /* NEC FA-RoundGothicM, 1996 */
- { 0x00000000UL, 0x00000000UL }, /* cvt */
- { 0xF055FC48UL, 0x000001C2UL }, /* fpgm */
- { 0x3900DED3UL, 0x00001E18UL } /* prep */
- },
- { /* MINGLI.TTF, 1992 */
- { 0x00170003UL, 0x00000060UL }, /* cvt */
- { 0xDBB4306EUL, 0x000058AAUL }, /* fpgm */
- { 0xD643482AUL, 0x00000035UL } /* prep */
- },
- { /* DFHei-Bd-WIN-HK-BF, issue #1087 */
- { 0x1269EB58UL, 0x00000350UL }, /* cvt */
- { 0x5CD5957AUL, 0x00006A4EUL }, /* fpgm */
- { 0xF758323AUL, 0x00000380UL } /* prep */
- },
- { /* DFMing-Md-WIN-HK-BF, issue #1087 */
- { 0x122FEB0BUL, 0x00000350UL }, /* cvt */
- { 0x7F10919AUL, 0x000070A9UL }, /* fpgm */
- { 0x7CD7E7B7UL, 0x0000025CUL } /* prep */
- }
- };
-
- FT_ULong checksum;
- int num_matched_ids[TRICK_SFNT_IDS_NUM_FACES];
- FT_Bool has_cvt, has_fpgm, has_prep;
- FT_UShort i;
- int j, k;
-
-
- FT_MEM_SET( num_matched_ids, 0,
- sizeof ( int ) * TRICK_SFNT_IDS_NUM_FACES );
- has_cvt = FALSE;
- has_fpgm = FALSE;
- has_prep = FALSE;
-
- for ( i = 0; i < face->num_tables; i++ )
- {
- checksum = 0;
-
- switch( face->dir_tables[i].Tag )
- {
- case TTAG_cvt:
- k = TRICK_SFNT_ID_cvt;
- has_cvt = TRUE;
- break;
-
- case TTAG_fpgm:
- k = TRICK_SFNT_ID_fpgm;
- has_fpgm = TRUE;
- break;
-
- case TTAG_prep:
- k = TRICK_SFNT_ID_prep;
- has_prep = TRUE;
- break;
-
- default:
- continue;
- }
-
- for ( j = 0; j < TRICK_SFNT_IDS_NUM_FACES; j++ )
- if ( face->dir_tables[i].Length == sfnt_id[j][k].Length )
- {
- if ( !checksum )
- checksum = tt_get_sfnt_checksum( face, i );
-
- if ( sfnt_id[j][k].CheckSum == checksum )
- num_matched_ids[j]++;
-
- if ( num_matched_ids[j] == TRICK_SFNT_IDS_PER_FACE )
- return TRUE;
- }
- }
-
- for ( j = 0; j < TRICK_SFNT_IDS_NUM_FACES; j++ )
- {
- if ( !has_cvt && !sfnt_id[j][TRICK_SFNT_ID_cvt].Length )
- num_matched_ids[j]++;
- if ( !has_fpgm && !sfnt_id[j][TRICK_SFNT_ID_fpgm].Length )
- num_matched_ids[j]++;
- if ( !has_prep && !sfnt_id[j][TRICK_SFNT_ID_prep].Length )
- num_matched_ids[j]++;
- if ( num_matched_ids[j] == TRICK_SFNT_IDS_PER_FACE )
- return TRUE;
- }
-
- return FALSE;
- }
-
-
- static FT_Bool
- tt_check_trickyness( FT_Face face )
- {
- if ( !face )
- return FALSE;
-
- /* For first, check the face name for quick check. */
- if ( face->family_name &&
- tt_check_trickyness_family( face->family_name ) )
- {
- FT_TRACE3(( "found as a tricky font"
- " by its family name: %s\n", face->family_name ));
- return TRUE;
- }
-
- /* Type42 fonts may lack `name' tables, we thus try to identify */
- /* tricky fonts by checking the checksums of Type42-persistent */
- /* sfnt tables (`cvt', `fpgm', and `prep'). */
- if ( tt_check_trickyness_sfnt_ids( (TT_Face)face ) )
- {
- FT_TRACE3(( "found as a tricky font"
- " by its cvt/fpgm/prep table checksum\n" ));
- return TRUE;
- }
-
- return FALSE;
- }
-
-#endif /* TT_USE_BYTECODE_INTERPRETER */
-
-
- /* Check whether `.notdef' is the only glyph in the `loca' table. */
- static FT_Bool
- tt_check_single_notdef( FT_Face ttface )
- {
- FT_Bool result = FALSE;
-
- TT_Face face = (TT_Face)ttface;
- FT_ULong asize;
- FT_ULong i;
- FT_ULong glyph_index = 0;
- FT_UInt count = 0;
-
-
- for( i = 0; i < face->num_locations; i++ )
- {
- tt_face_get_location( ttface, i, &asize );
- if ( asize > 0 )
- {
- count += 1;
- if ( count > 1 )
- break;
- glyph_index = i;
- }
- }
-
- /* Only have a single outline. */
- if ( count == 1 )
- {
- if ( glyph_index == 0 )
- result = TRUE;
- else
- {
- /* FIXME: Need to test glyphname == .notdef ? */
- FT_Error error;
- char buf[8];
-
-
- error = FT_Get_Glyph_Name( ttface, glyph_index, buf, 8 );
- if ( !error &&
- buf[0] == '.' && !ft_strncmp( buf, ".notdef", 8 ) )
- result = TRUE;
- }
- }
-
- return result;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * tt_face_init
- *
- * @Description:
- * Initialize a given TrueType face object.
- *
- * @Input:
- * stream ::
- * The source font stream.
- *
- * face_index ::
- * The index of the TrueType font, if we are opening a
- * collection, in bits 0-15. The numbered instance
- * index~+~1 of a GX (sub)font, if applicable, in bits
- * 16-30.
- *
- * num_params ::
- * Number of additional generic parameters. Ignored.
- *
- * params ::
- * Additional generic parameters. Ignored.
- *
- * @InOut:
- * face ::
- * The newly built face object.
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
- FT_LOCAL_DEF( FT_Error )
- tt_face_init( FT_Stream stream,
- FT_Face ttface, /* TT_Face */
- FT_Int face_index,
- FT_Int num_params,
- FT_Parameter* params )
- {
- FT_Error error;
- FT_Library library;
- SFNT_Service sfnt;
- TT_Face face = (TT_Face)ttface;
-
-
- FT_TRACE2(( "TTF driver\n" ));
-
- library = ttface->driver->root.library;
-
- sfnt = (SFNT_Service)FT_Get_Module_Interface( library, "sfnt" );
- if ( !sfnt )
- {
- FT_ERROR(( "tt_face_init: cannot access `sfnt' module\n" ));
- error = FT_THROW( Missing_Module );
- goto Exit;
- }
-
- /* create input stream from resource */
- if ( FT_STREAM_SEEK( 0 ) )
- goto Exit;
-
- /* check that we have a valid TrueType file */
- FT_TRACE2(( " " ));
- error = sfnt->init_face( stream, face, face_index, num_params, params );
-
- /* Stream may have changed. */
- stream = face->root.stream;
-
- if ( error )
- goto Exit;
-
- /* We must also be able to accept Mac/GX fonts, as well as OT ones. */
- /* The 0x00020000 tag is completely undocumented; some fonts from */
- /* Arphic made for Chinese Windows 3.1 have this. */
- if ( face->format_tag != 0x00010000L && /* MS fonts */
- face->format_tag != 0x00020000L && /* CJK fonts for Win 3.1 */
- face->format_tag != TTAG_true && /* Mac fonts */
- face->format_tag != TTAG_0xA5kbd && /* `Keyboard.dfont' (legacy Mac OS X) */
- face->format_tag != TTAG_0xA5lst ) /* `LastResort.dfont' (legacy Mac OS X) */
- {
- FT_TRACE2(( " not a TTF font\n" ));
- goto Bad_Format;
- }
-
-#ifdef TT_USE_BYTECODE_INTERPRETER
- ttface->face_flags |= FT_FACE_FLAG_HINTER;
-#endif
-
- /* If we are performing a simple font format check, exit immediately. */
- if ( face_index < 0 )
- return FT_Err_Ok;
-
- /* Load font directory */
- error = sfnt->load_face( stream, face, face_index, num_params, params );
- if ( error )
- goto Exit;
-
-#ifdef TT_USE_BYTECODE_INTERPRETER
- if ( tt_check_trickyness( ttface ) )
- ttface->face_flags |= FT_FACE_FLAG_TRICKY;
-#endif
-
- error = tt_face_load_hdmx( face, stream );
- if ( error )
- goto Exit;
-
- if ( FT_IS_SCALABLE( ttface ) ||
- FT_HAS_SBIX( ttface ) )
- {
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- if ( !ttface->internal->incremental_interface )
-#endif
- {
- error = tt_face_load_loca( face, stream );
-
- /* having a (non-zero) `glyf' table without */
- /* a `loca' table is not valid */
- if ( face->glyf_len && FT_ERR_EQ( error, Table_Missing ) )
- goto Exit;
- if ( error )
- goto Exit;
- }
-
- /* `fpgm', `cvt', and `prep' are optional */
- error = tt_face_load_cvt( face, stream );
- if ( error && FT_ERR_NEQ( error, Table_Missing ) )
- goto Exit;
-
- error = tt_face_load_fpgm( face, stream );
- if ( error && FT_ERR_NEQ( error, Table_Missing ) )
- goto Exit;
-
- error = tt_face_load_prep( face, stream );
- if ( error && FT_ERR_NEQ( error, Table_Missing ) )
- goto Exit;
-
- /* Check the scalable flag based on `loca'. */
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- if ( !ttface->internal->incremental_interface )
-#endif
- {
- if ( ttface->num_fixed_sizes &&
- face->glyph_locations &&
- tt_check_single_notdef( ttface ) )
- {
- FT_TRACE5(( "tt_face_init:"
- " Only the `.notdef' glyph has an outline.\n" ));
- FT_TRACE5(( " "
- " Resetting scalable flag to FALSE.\n" ));
-
- ttface->face_flags &= ~FT_FACE_FLAG_SCALABLE;
- }
- }
- }
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- {
- FT_UInt instance_index = (FT_UInt)face_index >> 16;
-
-
- if ( FT_HAS_MULTIPLE_MASTERS( ttface ) )
- {
- error = FT_Set_Named_Instance( ttface, instance_index );
- if ( error )
- goto Exit;
- }
- }
-#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
-
- /* initialize standard glyph loading routines */
- TT_Init_Glyph_Loading( face );
-
- Exit:
- return error;
-
- Bad_Format:
- error = FT_THROW( Unknown_File_Format );
- goto Exit;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * tt_face_done
- *
- * @Description:
- * Finalize a given face object.
- *
- * @Input:
- * face ::
- * A pointer to the face object to destroy.
- */
- FT_LOCAL_DEF( void )
- tt_face_done( FT_Face ttface ) /* TT_Face */
- {
- TT_Face face = (TT_Face)ttface;
- FT_Memory memory;
- FT_Stream stream;
- SFNT_Service sfnt;
-
-
- if ( !face )
- return;
-
- memory = ttface->memory;
- stream = ttface->stream;
- sfnt = (SFNT_Service)face->sfnt;
-
- /* for `extended TrueType formats' (i.e. compressed versions) */
- if ( face->extra.finalizer )
- face->extra.finalizer( face->extra.data );
-
- if ( sfnt )
- sfnt->done_face( face );
-
- /* freeing the locations table */
- tt_face_done_loca( face );
-
- tt_face_free_hdmx( face );
-
- /* freeing the CVT */
- FT_FREE( face->cvt );
- face->cvt_size = 0;
-
- /* freeing the programs */
- FT_FRAME_RELEASE( face->font_program );
- FT_FRAME_RELEASE( face->cvt_program );
- face->font_program_size = 0;
- face->cvt_program_size = 0;
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- tt_done_blend( ttface );
- face->blend = NULL;
-#endif
- }
-
-
- /**************************************************************************
- *
- * SIZE FUNCTIONS
- *
- */
-
-#ifdef TT_USE_BYTECODE_INTERPRETER
-
- /**************************************************************************
- *
- * @Function:
- * tt_size_run_fpgm
- *
- * @Description:
- * Run the font program.
- *
- * @Input:
- * size ::
- * A handle to the size object.
- *
- * pedantic ::
- * Set if bytecode execution should be pedantic.
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
- FT_LOCAL_DEF( FT_Error )
- tt_size_run_fpgm( TT_Size size,
- FT_Bool pedantic )
- {
- TT_Face face = (TT_Face)size->root.face;
- TT_ExecContext exec;
- FT_Error error;
-
-
- exec = size->context;
-
- error = TT_Load_Context( exec, face, size );
- if ( error )
- return error;
-
- exec->callTop = 0;
- exec->top = 0;
-
- exec->period = 64;
- exec->phase = 0;
- exec->threshold = 0;
-
- exec->instruction_trap = FALSE;
- exec->F_dot_P = 0x4000L;
-
- exec->pedantic_hinting = pedantic;
-
- {
- FT_Size_Metrics* size_metrics = &exec->metrics;
- TT_Size_Metrics* tt_metrics = &exec->tt_metrics;
-
-
- size_metrics->x_ppem = 0;
- size_metrics->y_ppem = 0;
- size_metrics->x_scale = 0;
- size_metrics->y_scale = 0;
-
- tt_metrics->ppem = 0;
- tt_metrics->scale = 0;
- tt_metrics->ratio = 0x10000L;
- }
-
- /* allow font program execution */
- TT_Set_CodeRange( exec,
- tt_coderange_font,
- face->font_program,
- (FT_Long)face->font_program_size );
-
- /* disable CVT and glyph programs coderange */
- TT_Clear_CodeRange( exec, tt_coderange_cvt );
- TT_Clear_CodeRange( exec, tt_coderange_glyph );
-
- if ( face->font_program_size > 0 )
- {
- TT_Goto_CodeRange( exec, tt_coderange_font, 0 );
-
- FT_TRACE4(( "Executing `fpgm' table.\n" ));
- error = face->interpreter( exec );
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( error )
- FT_TRACE4(( " interpretation failed with error code 0x%x\n",
- error ));
-#endif
- }
- else
- error = FT_Err_Ok;
-
- size->bytecode_ready = error;
-
- if ( !error )
- TT_Save_Context( exec, size );
-
- return error;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * tt_size_run_prep
- *
- * @Description:
- * Run the control value program.
- *
- * @Input:
- * size ::
- * A handle to the size object.
- *
- * pedantic ::
- * Set if bytecode execution should be pedantic.
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
- FT_LOCAL_DEF( FT_Error )
- tt_size_run_prep( TT_Size size,
- FT_Bool pedantic )
- {
- TT_Face face = (TT_Face)size->root.face;
- TT_ExecContext exec;
- FT_Error error;
- FT_UInt i;
-
-
- /* Scale the cvt values to the new ppem. */
- /* By default, we use the y ppem value for scaling. */
- FT_TRACE6(( "CVT values:\n" ));
- for ( i = 0; i < size->cvt_size; i++ )
- {
- /* Unscaled CVT values are already stored in 26.6 format. */
- /* Note that this scaling operation is very sensitive to rounding; */
- /* the integer division by 64 must be applied to the first argument. */
- size->cvt[i] = FT_MulFix( face->cvt[i] / 64, size->ttmetrics.scale );
- FT_TRACE6(( " %3d: %f (%f)\n",
- i, (double)face->cvt[i] / 64, (double)size->cvt[i] / 64 ));
- }
- FT_TRACE6(( "\n" ));
-
- exec = size->context;
-
- error = TT_Load_Context( exec, face, size );
- if ( error )
- return error;
-
- exec->callTop = 0;
- exec->top = 0;
-
- exec->instruction_trap = FALSE;
-
- exec->pedantic_hinting = pedantic;
-
- TT_Set_CodeRange( exec,
- tt_coderange_cvt,
- face->cvt_program,
- (FT_Long)face->cvt_program_size );
-
- TT_Clear_CodeRange( exec, tt_coderange_glyph );
-
- if ( face->cvt_program_size > 0 )
- {
- TT_Goto_CodeRange( exec, tt_coderange_cvt, 0 );
-
- FT_TRACE4(( "Executing `prep' table.\n" ));
- error = face->interpreter( exec );
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( error )
- FT_TRACE4(( " interpretation failed with error code 0x%x\n",
- error ));
-#endif
- }
- else
- error = FT_Err_Ok;
-
- size->cvt_ready = error;
-
- /* UNDOCUMENTED! The MS rasterizer doesn't allow the following */
- /* graphics state variables to be modified by the CVT program. */
-
- exec->GS.dualVector.x = 0x4000;
- exec->GS.dualVector.y = 0;
- exec->GS.projVector.x = 0x4000;
- exec->GS.projVector.y = 0x0;
- exec->GS.freeVector.x = 0x4000;
- exec->GS.freeVector.y = 0x0;
-
- exec->GS.rp0 = 0;
- exec->GS.rp1 = 0;
- exec->GS.rp2 = 0;
-
- exec->GS.gep0 = 1;
- exec->GS.gep1 = 1;
- exec->GS.gep2 = 1;
-
- exec->GS.loop = 1;
-
- /* save as default graphics state */
- size->GS = exec->GS;
-
- TT_Save_Context( exec, size );
-
- return error;
- }
-
-
- static void
- tt_size_done_bytecode( FT_Size ftsize )
- {
- TT_Size size = (TT_Size)ftsize;
- TT_Face face = (TT_Face)ftsize->face;
- FT_Memory memory = face->root.memory;
-
- if ( size->context )
- {
- TT_Done_Context( size->context );
- size->context = NULL;
- }
-
- FT_FREE( size->cvt );
- size->cvt_size = 0;
-
- /* free storage area */
- FT_FREE( size->storage );
- size->storage_size = 0;
-
- /* twilight zone */
- tt_glyphzone_done( &size->twilight );
-
- FT_FREE( size->function_defs );
- FT_FREE( size->instruction_defs );
-
- size->num_function_defs = 0;
- size->max_function_defs = 0;
- size->num_instruction_defs = 0;
- size->max_instruction_defs = 0;
-
- size->max_func = 0;
- size->max_ins = 0;
-
- size->bytecode_ready = -1;
- size->cvt_ready = -1;
- }
-
-
- /* Initialize bytecode-related fields in the size object. */
- /* We do this only if bytecode interpretation is really needed. */
- static FT_Error
- tt_size_init_bytecode( FT_Size ftsize,
- FT_Bool pedantic )
- {
- FT_Error error;
- TT_Size size = (TT_Size)ftsize;
- TT_Face face = (TT_Face)ftsize->face;
- FT_Memory memory = face->root.memory;
-
- FT_UShort n_twilight;
- TT_MaxProfile* maxp = &face->max_profile;
-
-
- /* clean up bytecode related data */
- FT_FREE( size->function_defs );
- FT_FREE( size->instruction_defs );
- FT_FREE( size->cvt );
- FT_FREE( size->storage );
-
- if ( size->context )
- TT_Done_Context( size->context );
- tt_glyphzone_done( &size->twilight );
-
- size->bytecode_ready = -1;
- size->cvt_ready = -1;
-
- size->context = TT_New_Context( (TT_Driver)face->root.driver );
-
- size->max_function_defs = maxp->maxFunctionDefs;
- size->max_instruction_defs = maxp->maxInstructionDefs;
-
- size->num_function_defs = 0;
- size->num_instruction_defs = 0;
-
- size->max_func = 0;
- size->max_ins = 0;
-
- size->cvt_size = face->cvt_size;
- size->storage_size = maxp->maxStorage;
-
- /* Set default metrics */
- {
- TT_Size_Metrics* tt_metrics = &size->ttmetrics;
-
-
- tt_metrics->rotated = FALSE;
- tt_metrics->stretched = FALSE;
-
- /* Set default engine compensation. Value 3 is not described */
- /* in the OpenType specification (as of Mai 2019), but Greg */
- /* says that MS handles it the same as `gray'. */
- /* */
- /* The Apple specification says that the compensation for */
- /* `gray' is always zero. FreeType doesn't do any */
- /* compensation at all. */
- tt_metrics->compensations[0] = 0; /* gray */
- tt_metrics->compensations[1] = 0; /* black */
- tt_metrics->compensations[2] = 0; /* white */
- tt_metrics->compensations[3] = 0; /* zero */
- }
-
- /* allocate function defs, instruction defs, cvt, and storage area */
- if ( FT_NEW_ARRAY( size->function_defs, size->max_function_defs ) ||
- FT_NEW_ARRAY( size->instruction_defs, size->max_instruction_defs ) ||
- FT_NEW_ARRAY( size->cvt, size->cvt_size ) ||
- FT_NEW_ARRAY( size->storage, size->storage_size ) )
- goto Exit;
-
- /* reserve twilight zone */
- n_twilight = maxp->maxTwilightPoints;
-
- /* there are 4 phantom points (do we need this?) */
- n_twilight += 4;
-
- error = tt_glyphzone_new( memory, n_twilight, 0, &size->twilight );
- if ( error )
- goto Exit;
-
- size->twilight.n_points = n_twilight;
-
- size->GS = tt_default_graphics_state;
-
- /* set `face->interpreter' according to the debug hook present */
- {
- FT_Library library = face->root.driver->root.library;
-
-
- face->interpreter = (TT_Interpreter)
- library->debug_hooks[FT_DEBUG_HOOK_TRUETYPE];
- if ( !face->interpreter )
- face->interpreter = (TT_Interpreter)TT_RunIns;
- }
-
- /* Fine, now run the font program! */
-
- /* In case of an error while executing `fpgm', we intentionally don't */
- /* clean up immediately – bugs in the `fpgm' are so fundamental that */
- /* all following hinting calls should fail. Additionally, `fpgm' is */
- /* to be executed just once; calling it again is completely useless */
- /* and might even lead to extremely slow behaviour if it is malformed */
- /* (containing an infinite loop, for example). */
- error = tt_size_run_fpgm( size, pedantic );
- return error;
-
- Exit:
- if ( error )
- tt_size_done_bytecode( ftsize );
-
- return error;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- tt_size_ready_bytecode( TT_Size size,
- FT_Bool pedantic )
- {
- FT_Error error = FT_Err_Ok;
-
-
- if ( size->bytecode_ready < 0 )
- error = tt_size_init_bytecode( (FT_Size)size, pedantic );
- else
- error = size->bytecode_ready;
-
- if ( error )
- goto Exit;
-
- /* rescale CVT when needed */
- if ( size->cvt_ready < 0 )
- {
- FT_UShort i;
-
-
- /* all twilight points are originally zero */
- for ( i = 0; i < size->twilight.n_points; i++ )
- {
- size->twilight.org[i].x = 0;
- size->twilight.org[i].y = 0;
- size->twilight.cur[i].x = 0;
- size->twilight.cur[i].y = 0;
- }
-
- /* clear storage area */
- for ( i = 0; i < size->storage_size; i++ )
- size->storage[i] = 0;
-
- size->GS = tt_default_graphics_state;
-
- error = tt_size_run_prep( size, pedantic );
- }
- else
- error = size->cvt_ready;
-
- Exit:
- return error;
- }
-
-#endif /* TT_USE_BYTECODE_INTERPRETER */
-
-
- /**************************************************************************
- *
- * @Function:
- * tt_size_init
- *
- * @Description:
- * Initialize a new TrueType size object.
- *
- * @InOut:
- * size ::
- * A handle to the size object.
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
- FT_LOCAL_DEF( FT_Error )
- tt_size_init( FT_Size ttsize ) /* TT_Size */
- {
- TT_Size size = (TT_Size)ttsize;
- FT_Error error = FT_Err_Ok;
-
-
-#ifdef TT_USE_BYTECODE_INTERPRETER
- size->bytecode_ready = -1;
- size->cvt_ready = -1;
-#endif
-
- size->ttmetrics.valid = FALSE;
- size->strike_index = 0xFFFFFFFFUL;
-
- return error;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * tt_size_done
- *
- * @Description:
- * The TrueType size object finalizer.
- *
- * @Input:
- * size ::
- * A handle to the target size object.
- */
- FT_LOCAL_DEF( void )
- tt_size_done( FT_Size ttsize ) /* TT_Size */
- {
- TT_Size size = (TT_Size)ttsize;
-
-
-#ifdef TT_USE_BYTECODE_INTERPRETER
- tt_size_done_bytecode( ttsize );
-#endif
-
- size->ttmetrics.valid = FALSE;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * tt_size_reset_height
- *
- * @Description:
- * Recompute a TrueType size's ascender, descender, and height
- * when resolutions and character dimensions have been changed.
- * Used for variation fonts as an iterator function.
- *
- * @Input:
- * ft_size ::
- * A handle to the target TT_Size object. This function will be called
- * through a `FT_Size_Reset_Func` pointer which takes `FT_Size`. This
- * function must take `FT_Size` as a result. The passed `FT_Size` is
- * expected to point to a `TT_Size`.
- */
- FT_LOCAL_DEF( FT_Error )
- tt_size_reset_height( FT_Size ft_size )
- {
- TT_Size size = (TT_Size)ft_size;
- TT_Face face = (TT_Face)size->root.face;
- FT_Size_Metrics* size_metrics = &size->hinted_metrics;
-
- size->ttmetrics.valid = FALSE;
-
- /* copy the result from base layer */
- *size_metrics = size->root.metrics;
-
- if ( size_metrics->x_ppem < 1 || size_metrics->y_ppem < 1 )
- return FT_THROW( Invalid_PPem );
-
- /* This bit flag, if set, indicates that the ppems must be */
- /* rounded to integers. Nearly all TrueType fonts have this bit */
- /* set, as hinting won't work really well otherwise. */
- /* */
- if ( face->header.Flags & 8 )
- {
- /* the TT spec always asks for ROUND, not FLOOR or CEIL */
- size_metrics->ascender = FT_PIX_ROUND(
- FT_MulFix( face->root.ascender,
- size_metrics->y_scale ) );
- size_metrics->descender = FT_PIX_ROUND(
- FT_MulFix( face->root.descender,
- size_metrics->y_scale ) );
- size_metrics->height = FT_PIX_ROUND(
- FT_MulFix( face->root.height,
- size_metrics->y_scale ) );
- }
-
- size->ttmetrics.valid = TRUE;
-
- return FT_Err_Ok;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * tt_size_reset
- *
- * @Description:
- * Reset a TrueType size when resolutions and character dimensions
- * have been changed.
- *
- * @Input:
- * size ::
- * A handle to the target size object.
- */
- FT_LOCAL_DEF( FT_Error )
- tt_size_reset( TT_Size size )
- {
- FT_Error error;
- TT_Face face = (TT_Face)size->root.face;
- FT_Size_Metrics* size_metrics = &size->hinted_metrics;
-
-
- error = tt_size_reset_height( (FT_Size)size );
- if ( error )
- return error;
-
- if ( face->header.Flags & 8 )
- {
- /* base scaling values on integer ppem values, */
- /* as mandated by the TrueType specification */
- size_metrics->x_scale = FT_DivFix( size_metrics->x_ppem << 6,
- face->root.units_per_EM );
- size_metrics->y_scale = FT_DivFix( size_metrics->y_ppem << 6,
- face->root.units_per_EM );
-
- size_metrics->max_advance = FT_PIX_ROUND(
- FT_MulFix( face->root.max_advance_width,
- size_metrics->x_scale ) );
- }
-
- /* compute new transformation */
- if ( size_metrics->x_ppem >= size_metrics->y_ppem )
- {
- size->ttmetrics.scale = size_metrics->x_scale;
- size->ttmetrics.ppem = size_metrics->x_ppem;
- size->ttmetrics.x_ratio = 0x10000L;
- size->ttmetrics.y_ratio = FT_DivFix( size_metrics->y_ppem,
- size_metrics->x_ppem );
- }
- else
- {
- size->ttmetrics.scale = size_metrics->y_scale;
- size->ttmetrics.ppem = size_metrics->y_ppem;
- size->ttmetrics.x_ratio = FT_DivFix( size_metrics->x_ppem,
- size_metrics->y_ppem );
- size->ttmetrics.y_ratio = 0x10000L;
- }
-
- size->widthp = tt_face_get_device_metrics( face, size_metrics->x_ppem, 0 );
-
- size->metrics = size_metrics;
-
-#ifdef TT_USE_BYTECODE_INTERPRETER
- size->cvt_ready = -1;
-#endif /* TT_USE_BYTECODE_INTERPRETER */
-
- return FT_Err_Ok;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * tt_driver_init
- *
- * @Description:
- * Initialize a given TrueType driver object.
- *
- * @Input:
- * driver ::
- * A handle to the target driver object.
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
- FT_LOCAL_DEF( FT_Error )
- tt_driver_init( FT_Module ttdriver ) /* TT_Driver */
- {
-
-#ifdef TT_USE_BYTECODE_INTERPRETER
-
- TT_Driver driver = (TT_Driver)ttdriver;
-
- driver->interpreter_version = TT_INTERPRETER_VERSION_35;
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- driver->interpreter_version = TT_INTERPRETER_VERSION_40;
-#endif
-
-#else /* !TT_USE_BYTECODE_INTERPRETER */
-
- FT_UNUSED( ttdriver );
-
-#endif /* !TT_USE_BYTECODE_INTERPRETER */
-
- return FT_Err_Ok;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * tt_driver_done
- *
- * @Description:
- * Finalize a given TrueType driver.
- *
- * @Input:
- * driver ::
- * A handle to the target TrueType driver.
- */
- FT_LOCAL_DEF( void )
- tt_driver_done( FT_Module ttdriver ) /* TT_Driver */
- {
- FT_UNUSED( ttdriver );
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * tt_slot_init
- *
- * @Description:
- * Initialize a new slot object.
- *
- * @InOut:
- * slot ::
- * A handle to the slot object.
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
- FT_LOCAL_DEF( FT_Error )
- tt_slot_init( FT_GlyphSlot slot )
- {
- return FT_GlyphLoader_CreateExtra( slot->internal->loader );
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/truetype/ttobjs.h b/contrib/libs/freetype/src/truetype/ttobjs.h
deleted file mode 100644
index 9c36ca7836..0000000000
--- a/contrib/libs/freetype/src/truetype/ttobjs.h
+++ /dev/null
@@ -1,426 +0,0 @@
-/****************************************************************************
- *
- * ttobjs.h
- *
- * Objects manager (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef TTOBJS_H_
-#define TTOBJS_H_
-
-
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/tttypes.h>
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @Type:
- * TT_Driver
- *
- * @Description:
- * A handle to a TrueType driver object.
- */
- typedef struct TT_DriverRec_* TT_Driver;
-
-
- /**************************************************************************
- *
- * @Type:
- * TT_GlyphSlot
- *
- * @Description:
- * A handle to a TrueType glyph slot object.
- *
- * @Note:
- * This is a direct typedef of FT_GlyphSlot, as there is nothing
- * specific about the TrueType glyph slot.
- */
- typedef FT_GlyphSlot TT_GlyphSlot;
-
-
- /**************************************************************************
- *
- * @Struct:
- * TT_GraphicsState
- *
- * @Description:
- * The TrueType graphics state used during bytecode interpretation.
- */
- typedef struct TT_GraphicsState_
- {
- FT_UShort rp0;
- FT_UShort rp1;
- FT_UShort rp2;
-
- FT_UnitVector dualVector;
- FT_UnitVector projVector;
- FT_UnitVector freeVector;
-
- FT_Long loop;
- FT_F26Dot6 minimum_distance;
- FT_Int round_state;
-
- FT_Bool auto_flip;
- FT_F26Dot6 control_value_cutin;
- FT_F26Dot6 single_width_cutin;
- FT_F26Dot6 single_width_value;
- FT_UShort delta_base;
- FT_UShort delta_shift;
-
- FT_Byte instruct_control;
- /* According to Greg Hitchcock from Microsoft, the `scan_control' */
- /* variable as documented in the TrueType specification is a 32-bit */
- /* integer; the high-word part holds the SCANTYPE value, the low-word */
- /* part the SCANCTRL value. We separate it into two fields. */
- FT_Bool scan_control;
- FT_Int scan_type;
-
- FT_UShort gep0;
- FT_UShort gep1;
- FT_UShort gep2;
-
- } TT_GraphicsState;
-
-
-#ifdef TT_USE_BYTECODE_INTERPRETER
-
- FT_LOCAL( void )
- tt_glyphzone_done( TT_GlyphZone zone );
-
- FT_LOCAL( FT_Error )
- tt_glyphzone_new( FT_Memory memory,
- FT_UShort maxPoints,
- FT_UShort maxContours,
- TT_GlyphZone zone );
-
-#endif /* TT_USE_BYTECODE_INTERPRETER */
-
-
-
- /**************************************************************************
- *
- * EXECUTION SUBTABLES
- *
- * These sub-tables relate to instruction execution.
- *
- */
-
-
-#define TT_MAX_CODE_RANGES 3
-
-
- /**************************************************************************
- *
- * There can only be 3 active code ranges at once:
- * - the Font Program
- * - the CVT Program
- * - a glyph's instructions set
- */
- typedef enum TT_CodeRange_Tag_
- {
- tt_coderange_none = 0,
- tt_coderange_font,
- tt_coderange_cvt,
- tt_coderange_glyph
-
- } TT_CodeRange_Tag;
-
-
- typedef struct TT_CodeRange_
- {
- FT_Byte* base;
- FT_Long size;
-
- } TT_CodeRange;
-
- typedef TT_CodeRange TT_CodeRangeTable[TT_MAX_CODE_RANGES];
-
-
- /**************************************************************************
- *
- * Defines a function/instruction definition record.
- */
- typedef struct TT_DefRecord_
- {
- FT_Int range; /* in which code range is it located? */
- FT_Long start; /* where does it start? */
- FT_Long end; /* where does it end? */
- FT_UInt opc; /* function #, or instruction code */
- FT_Bool active; /* is it active? */
-
- } TT_DefRecord, *TT_DefArray;
-
-
- /**************************************************************************
- *
- * Subglyph transformation record.
- */
- typedef struct TT_Transform_
- {
- FT_Fixed xx, xy; /* transformation matrix coefficients */
- FT_Fixed yx, yy;
- FT_F26Dot6 ox, oy; /* offsets */
-
- } TT_Transform;
-
-
- /**************************************************************************
- *
- * A note regarding non-squared pixels:
- *
- * (This text will probably go into some docs at some time; for now, it
- * is kept here to explain some definitions in the TT_Size_Metrics
- * record).
- *
- * The CVT is a one-dimensional array containing values that control
- * certain important characteristics in a font, like the height of all
- * capitals, all lowercase letter, default spacing or stem width/height.
- *
- * These values are found in FUnits in the font file, and must be scaled
- * to pixel coordinates before being used by the CVT and glyph programs.
- * Unfortunately, when using distinct x and y resolutions (or distinct x
- * and y pointsizes), there are two possible scalings.
- *
- * A first try was to implement a `lazy' scheme where all values were
- * scaled when first used. However, while some values are always used
- * in the same direction, some others are used under many different
- * circumstances and orientations.
- *
- * I have found a simpler way to do the same, and it even seems to work
- * in most of the cases:
- *
- * - All CVT values are scaled to the maximum ppem size.
- *
- * - When performing a read or write in the CVT, a ratio factor is used
- * to perform adequate scaling. Example:
- *
- * x_ppem = 14
- * y_ppem = 10
- *
- * We choose ppem = x_ppem = 14 as the CVT scaling size. All cvt
- * entries are scaled to it.
- *
- * x_ratio = 1.0
- * y_ratio = y_ppem/ppem (< 1.0)
- *
- * We compute the current ratio like:
- *
- * - If projVector is horizontal,
- * ratio = x_ratio = 1.0
- *
- * - if projVector is vertical,
- * ratio = y_ratio
- *
- * - else,
- * ratio = sqrt( (proj.x * x_ratio) ^ 2 + (proj.y * y_ratio) ^ 2 )
- *
- * Reading a cvt value returns
- * ratio * cvt[index]
- *
- * Writing a cvt value in pixels:
- * cvt[index] / ratio
- *
- * The current ppem is simply
- * ratio * ppem
- *
- */
-
-
- /**************************************************************************
- *
- * Metrics used by the TrueType size and context objects.
- */
- typedef struct TT_Size_Metrics_
- {
- /* for non-square pixels */
- FT_Long x_ratio;
- FT_Long y_ratio;
-
- FT_UShort ppem; /* maximum ppem size */
- FT_Long ratio; /* current ratio */
- FT_Fixed scale;
-
- FT_F26Dot6 compensations[4]; /* device-specific compensations */
-
- FT_Bool valid;
-
- FT_Bool rotated; /* `is the glyph rotated?'-flag */
- FT_Bool stretched; /* `is the glyph stretched?'-flag */
-
- } TT_Size_Metrics;
-
-
- /**************************************************************************
- *
- * TrueType size class.
- */
- typedef struct TT_SizeRec_
- {
- FT_SizeRec root;
-
- /* we have our own copy of metrics so that we can modify */
- /* it without affecting auto-hinting (when used) */
- FT_Size_Metrics* metrics; /* for the current rendering mode */
- FT_Size_Metrics hinted_metrics; /* for the hinted rendering mode */
-
- TT_Size_Metrics ttmetrics;
-
- FT_Byte* widthp; /* glyph widths from the hdmx table */
-
- FT_ULong strike_index; /* 0xFFFFFFFF to indicate invalid */
-
-#ifdef TT_USE_BYTECODE_INTERPRETER
-
- FT_Long point_size; /* for the `MPS' bytecode instruction */
-
- FT_UInt num_function_defs; /* number of function definitions */
- FT_UInt max_function_defs;
- TT_DefArray function_defs; /* table of function definitions */
-
- FT_UInt num_instruction_defs; /* number of ins. definitions */
- FT_UInt max_instruction_defs;
- TT_DefArray instruction_defs; /* table of ins. definitions */
-
- FT_UInt max_func;
- FT_UInt max_ins;
-
- TT_CodeRangeTable codeRangeTable;
-
- TT_GraphicsState GS;
-
- FT_ULong cvt_size; /* the scaled control value table */
- FT_Long* cvt;
-
- FT_UShort storage_size; /* The storage area is now part of */
- FT_Long* storage; /* the instance */
-
- TT_GlyphZoneRec twilight; /* The instance's twilight zone */
-
- TT_ExecContext context;
-
- /* if negative, `fpgm' (resp. `prep'), wasn't executed yet; */
- /* otherwise it is the returned error code */
- FT_Error bytecode_ready;
- FT_Error cvt_ready;
-
-#endif /* TT_USE_BYTECODE_INTERPRETER */
-
- } TT_SizeRec;
-
-
- /**************************************************************************
- *
- * TrueType driver class.
- */
- typedef struct TT_DriverRec_
- {
- FT_DriverRec root;
-
- TT_GlyphZoneRec zone; /* glyph loader points zone */
-
- FT_UInt interpreter_version;
-
- } TT_DriverRec;
-
-
- /* Note: All of the functions below (except tt_size_reset()) are used */
- /* as function pointers in a FT_Driver_ClassRec. Therefore their */
- /* parameters are of types FT_Face, FT_Size, etc., rather than TT_Face, */
- /* TT_Size, etc., so that the compiler can confirm that the types and */
- /* number of parameters are correct. In all cases the FT_xxx types are */
- /* cast to their TT_xxx counterparts inside the functions since FreeType */
- /* will always use the TT driver to create them. */
-
-
- /**************************************************************************
- *
- * Face functions
- */
- FT_LOCAL( FT_Error )
- tt_face_init( FT_Stream stream,
- FT_Face ttface, /* TT_Face */
- FT_Int face_index,
- FT_Int num_params,
- FT_Parameter* params );
-
- FT_LOCAL( void )
- tt_face_done( FT_Face ttface ); /* TT_Face */
-
-
- /**************************************************************************
- *
- * Size functions
- */
- FT_LOCAL( FT_Error )
- tt_size_init( FT_Size ttsize ); /* TT_Size */
-
- FT_LOCAL( void )
- tt_size_done( FT_Size ttsize ); /* TT_Size */
-
-#ifdef TT_USE_BYTECODE_INTERPRETER
-
- FT_LOCAL( FT_Error )
- tt_size_run_fpgm( TT_Size size,
- FT_Bool pedantic );
-
- FT_LOCAL( FT_Error )
- tt_size_run_prep( TT_Size size,
- FT_Bool pedantic );
-
- FT_LOCAL( FT_Error )
- tt_size_ready_bytecode( TT_Size size,
- FT_Bool pedantic );
-
-#endif /* TT_USE_BYTECODE_INTERPRETER */
-
- FT_LOCAL( FT_Error )
- tt_size_reset_height( FT_Size size );
-
- FT_LOCAL( FT_Error )
- tt_size_reset( TT_Size size );
-
-
- /**************************************************************************
- *
- * Driver functions
- */
- FT_LOCAL( FT_Error )
- tt_driver_init( FT_Module ttdriver ); /* TT_Driver */
-
- FT_LOCAL( void )
- tt_driver_done( FT_Module ttdriver ); /* TT_Driver */
-
-
- /**************************************************************************
- *
- * Slot functions
- */
- FT_LOCAL( FT_Error )
- tt_slot_init( FT_GlyphSlot slot );
-
-
- /* auxiliary */
-#define IS_HINTED( flags ) ( ( flags & FT_LOAD_NO_HINTING ) == 0 )
-
-
-FT_END_HEADER
-
-#endif /* TTOBJS_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/truetype/ttpload.c b/contrib/libs/freetype/src/truetype/ttpload.c
deleted file mode 100644
index 9505b5f179..0000000000
--- a/contrib/libs/freetype/src/truetype/ttpload.c
+++ /dev/null
@@ -1,665 +0,0 @@
-/****************************************************************************
- *
- * ttpload.c
- *
- * TrueType-specific tables loader (body).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/tttags.h>
-
-#include "ttpload.h"
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
-#include "ttgxvar.h"
-#endif
-
-#include "tterrors.h"
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT ttpload
-
-
- /**************************************************************************
- *
- * @Function:
- * tt_face_load_loca
- *
- * @Description:
- * Load the locations table.
- *
- * @InOut:
- * face ::
- * A handle to the target face object.
- *
- * @Input:
- * stream ::
- * The input stream.
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
- FT_LOCAL_DEF( FT_Error )
- tt_face_load_loca( TT_Face face,
- FT_Stream stream )
- {
- FT_Error error;
- FT_ULong table_len;
- FT_Int shift;
-
-
- /* we need the size of the `glyf' table for malformed `loca' tables */
- error = face->goto_table( face, TTAG_glyf, stream, &face->glyf_len );
-
- /* it is possible that a font doesn't have a glyf table at all */
- /* or its size is zero */
- if ( FT_ERR_EQ( error, Table_Missing ) )
- {
- face->glyf_len = 0;
- face->glyf_offset = 0;
- }
- else if ( error )
- goto Exit;
- else
- {
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- if ( face->root.internal->incremental_interface )
- face->glyf_offset = 0;
- else
-#endif
- face->glyf_offset = FT_STREAM_POS();
- }
-
- FT_TRACE2(( "Locations " ));
- error = face->goto_table( face, TTAG_loca, stream, &table_len );
- if ( error )
- {
- error = FT_THROW( Locations_Missing );
- goto Exit;
- }
-
- shift = face->header.Index_To_Loc_Format != 0 ? 2 : 1;
-
- if ( table_len > 0x10000UL << shift )
- {
- FT_TRACE2(( "table too large\n" ));
- table_len = 0x10000UL << shift;
- }
-
- face->num_locations = table_len >> shift;
-
- if ( face->num_locations != (FT_ULong)face->root.num_glyphs + 1 )
- {
- FT_TRACE2(( "glyph count mismatch! loca: %ld, maxp: %ld\n",
- face->num_locations - 1, face->root.num_glyphs ));
-
- /* we only handle the case where `maxp' gives a larger value */
- if ( face->num_locations < (FT_ULong)face->root.num_glyphs + 1 )
- {
- FT_ULong new_loca_len =
- ( (FT_ULong)face->root.num_glyphs + 1 ) << shift;
-
- TT_Table entry = face->dir_tables;
- TT_Table limit = entry + face->num_tables;
-
- FT_Long pos = (FT_Long)FT_STREAM_POS();
- FT_Long dist = 0x7FFFFFFFL;
- FT_Bool found = 0;
-
-
- /* compute the distance to next table in font file */
- for ( ; entry < limit; entry++ )
- {
- FT_Long diff = (FT_Long)entry->Offset - pos;
-
-
- if ( diff > 0 && diff < dist )
- {
- dist = diff;
- found = 1;
- }
- }
-
- if ( !found )
- {
- /* `loca' is the last table */
- dist = (FT_Long)stream->size - pos;
- }
-
- if ( new_loca_len <= (FT_ULong)dist )
- {
- face->num_locations = (FT_ULong)face->root.num_glyphs + 1;
- table_len = new_loca_len;
-
- FT_TRACE2(( "adjusting num_locations to %ld\n",
- face->num_locations ));
- }
- else
- {
- face->root.num_glyphs = face->num_locations
- ? (FT_Long)face->num_locations - 1 : 0;
-
- FT_TRACE2(( "adjusting num_glyphs to %ld\n",
- face->root.num_glyphs ));
- }
- }
- }
-
- /*
- * Extract the frame. We don't need to decompress it since
- * we are able to parse it directly.
- */
- if ( FT_FRAME_EXTRACT( table_len, face->glyph_locations ) )
- goto Exit;
-
- FT_TRACE2(( "loaded\n" ));
-
- Exit:
- return error;
- }
-
-
- FT_LOCAL_DEF( FT_ULong )
- tt_face_get_location( FT_Face face, /* TT_Face */
- FT_UInt gindex,
- FT_ULong *asize )
- {
- TT_Face ttface = (TT_Face)face;
- FT_ULong pos1, pos2;
- FT_Byte* p;
- FT_Byte* p_limit;
-
-
- pos1 = pos2 = 0;
-
- if ( gindex < ttface->num_locations )
- {
- if ( ttface->header.Index_To_Loc_Format != 0 )
- {
- p = ttface->glyph_locations + gindex * 4;
- p_limit = ttface->glyph_locations + ttface->num_locations * 4;
-
- pos1 = FT_NEXT_ULONG( p );
- pos2 = pos1;
-
- if ( p + 4 <= p_limit )
- pos2 = FT_NEXT_ULONG( p );
- }
- else
- {
- p = ttface->glyph_locations + gindex * 2;
- p_limit = ttface->glyph_locations + ttface->num_locations * 2;
-
- pos1 = FT_NEXT_USHORT( p );
- pos2 = pos1;
-
- if ( p + 2 <= p_limit )
- pos2 = FT_NEXT_USHORT( p );
-
- pos1 <<= 1;
- pos2 <<= 1;
- }
- }
-
- /* Check broken location data. */
- if ( pos1 > ttface->glyf_len )
- {
- FT_TRACE1(( "tt_face_get_location:"
- " too large offset (0x%08lx) found for glyph index %d,\n",
- pos1, gindex ));
- FT_TRACE1(( " "
- " exceeding the end of `glyf' table (0x%08lx)\n",
- ttface->glyf_len ));
- *asize = 0;
- return 0;
- }
-
- if ( pos2 > ttface->glyf_len )
- {
- /* We try to sanitize the last `loca' entry. */
- if ( gindex == ttface->num_locations - 2 )
- {
- FT_TRACE1(( "tt_face_get_location:"
- " too large size (%ld bytes) found for glyph index %d,\n",
- pos2 - pos1, gindex ));
- FT_TRACE1(( " "
- " truncating at the end of `glyf' table to %ld bytes\n",
- ttface->glyf_len - pos1 ));
- pos2 = ttface->glyf_len;
- }
- else
- {
- FT_TRACE1(( "tt_face_get_location:"
- " too large offset (0x%08lx) found for glyph index %d,\n",
- pos2, gindex + 1 ));
- FT_TRACE1(( " "
- " exceeding the end of `glyf' table (0x%08lx)\n",
- ttface->glyf_len ));
- *asize = 0;
- return 0;
- }
- }
-
- /* The `loca' table must be ordered; it refers to the length of */
- /* an entry as the difference between the current and the next */
- /* position. However, there do exist (malformed) fonts which */
- /* don't obey this rule, so we are only able to provide an */
- /* upper bound for the size. */
- /* */
- /* We get (intentionally) a wrong, non-zero result in case the */
- /* `glyf' table is missing. */
- if ( pos2 >= pos1 )
- *asize = (FT_ULong)( pos2 - pos1 );
- else
- *asize = (FT_ULong)( ttface->glyf_len - pos1 );
-
- return pos1;
- }
-
-
- FT_LOCAL_DEF( void )
- tt_face_done_loca( TT_Face face )
- {
- FT_Stream stream = face->root.stream;
-
-
- FT_FRAME_RELEASE( face->glyph_locations );
- face->num_locations = 0;
- }
-
-
-
- /**************************************************************************
- *
- * @Function:
- * tt_face_load_cvt
- *
- * @Description:
- * Load the control value table into a face object.
- *
- * @InOut:
- * face ::
- * A handle to the target face object.
- *
- * @Input:
- * stream ::
- * A handle to the input stream.
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
- FT_LOCAL_DEF( FT_Error )
- tt_face_load_cvt( TT_Face face,
- FT_Stream stream )
- {
-#ifdef TT_USE_BYTECODE_INTERPRETER
-
- FT_Error error;
- FT_Memory memory = stream->memory;
- FT_ULong table_len;
-
-
- FT_TRACE2(( "CVT " ));
-
- error = face->goto_table( face, TTAG_cvt, stream, &table_len );
- if ( error )
- {
- FT_TRACE2(( "is missing\n" ));
-
- face->cvt_size = 0;
- face->cvt = NULL;
- error = FT_Err_Ok;
-
- goto Exit;
- }
-
- face->cvt_size = table_len / 2;
-
- if ( FT_QNEW_ARRAY( face->cvt, face->cvt_size ) )
- goto Exit;
-
- if ( FT_FRAME_ENTER( face->cvt_size * 2L ) )
- goto Exit;
-
- {
- FT_Int32* cur = face->cvt;
- FT_Int32* limit = cur + face->cvt_size;
-
-
- for ( ; cur < limit; cur++ )
- *cur = FT_GET_SHORT() * 64;
- }
-
- FT_FRAME_EXIT();
- FT_TRACE2(( "loaded\n" ));
-
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- if ( face->doblend )
- error = tt_face_vary_cvt( face, stream );
-#endif
-
- Exit:
- return error;
-
-#else /* !TT_USE_BYTECODE_INTERPRETER */
-
- FT_UNUSED( face );
- FT_UNUSED( stream );
-
- return FT_Err_Ok;
-
-#endif
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * tt_face_load_fpgm
- *
- * @Description:
- * Load the font program.
- *
- * @InOut:
- * face ::
- * A handle to the target face object.
- *
- * @Input:
- * stream ::
- * A handle to the input stream.
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
- FT_LOCAL_DEF( FT_Error )
- tt_face_load_fpgm( TT_Face face,
- FT_Stream stream )
- {
-#ifdef TT_USE_BYTECODE_INTERPRETER
-
- FT_Error error;
- FT_ULong table_len;
-
-
- FT_TRACE2(( "Font program " ));
-
- /* The font program is optional */
- error = face->goto_table( face, TTAG_fpgm, stream, &table_len );
- if ( error )
- {
- face->font_program = NULL;
- face->font_program_size = 0;
- error = FT_Err_Ok;
-
- FT_TRACE2(( "is missing\n" ));
- }
- else
- {
- face->font_program_size = table_len;
- if ( FT_FRAME_EXTRACT( table_len, face->font_program ) )
- goto Exit;
-
- FT_TRACE2(( "loaded, %12ld bytes\n", face->font_program_size ));
- }
-
- Exit:
- return error;
-
-#else /* !TT_USE_BYTECODE_INTERPRETER */
-
- FT_UNUSED( face );
- FT_UNUSED( stream );
-
- return FT_Err_Ok;
-
-#endif
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * tt_face_load_prep
- *
- * @Description:
- * Load the cvt program.
- *
- * @InOut:
- * face ::
- * A handle to the target face object.
- *
- * @Input:
- * stream ::
- * A handle to the input stream.
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
- FT_LOCAL_DEF( FT_Error )
- tt_face_load_prep( TT_Face face,
- FT_Stream stream )
- {
-#ifdef TT_USE_BYTECODE_INTERPRETER
-
- FT_Error error;
- FT_ULong table_len;
-
-
- FT_TRACE2(( "Prep program " ));
-
- error = face->goto_table( face, TTAG_prep, stream, &table_len );
- if ( error )
- {
- face->cvt_program = NULL;
- face->cvt_program_size = 0;
- error = FT_Err_Ok;
-
- FT_TRACE2(( "is missing\n" ));
- }
- else
- {
- face->cvt_program_size = table_len;
- if ( FT_FRAME_EXTRACT( table_len, face->cvt_program ) )
- goto Exit;
-
- FT_TRACE2(( "loaded, %12ld bytes\n", face->cvt_program_size ));
- }
-
- Exit:
- return error;
-
-#else /* !TT_USE_BYTECODE_INTERPRETER */
-
- FT_UNUSED( face );
- FT_UNUSED( stream );
-
- return FT_Err_Ok;
-
-#endif
- }
-
-
- FT_COMPARE_DEF( int )
- compare_ppem( const void* a,
- const void* b )
- {
- return **(FT_Byte**)a - **(FT_Byte**)b;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * tt_face_load_hdmx
- *
- * @Description:
- * Load the `hdmx' table into the face object.
- *
- * @Input:
- * face ::
- * A handle to the target face object.
- *
- * stream ::
- * A handle to the input stream.
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
-
- FT_LOCAL_DEF( FT_Error )
- tt_face_load_hdmx( TT_Face face,
- FT_Stream stream )
- {
- FT_Error error;
- FT_Memory memory = stream->memory;
- FT_UInt nn, num_records;
- FT_ULong table_size, record_size;
- FT_Byte* p;
- FT_Byte* limit;
-
-
- /* this table is optional */
- error = face->goto_table( face, TTAG_hdmx, stream, &table_size );
- if ( error || table_size < 8 )
- return FT_Err_Ok;
-
- if ( FT_FRAME_EXTRACT( table_size, face->hdmx_table ) )
- goto Exit;
-
- p = face->hdmx_table;
- limit = p + table_size;
-
- /* Given that `hdmx' tables are losing its importance (for example, */
- /* variation fonts introduced in OpenType 1.8 must not have this */
- /* table) we no longer test for a correct `version' field. */
- p += 2;
- num_records = FT_NEXT_USHORT( p );
- record_size = FT_NEXT_ULONG( p );
-
- /* There are at least two fonts, HANNOM-A and HANNOM-B version */
- /* 2.0 (2005), which get this wrong: The upper two bytes of */
- /* the size value are set to 0xFF instead of 0x00. We catch */
- /* and fix this. */
-
- if ( record_size >= 0xFFFF0000UL )
- record_size &= 0xFFFFU;
-
- FT_TRACE2(( "Hdmx " ));
-
- /* The limit for `num_records' is a heuristic value. */
- if ( num_records > 255 || num_records == 0 )
- {
- FT_TRACE2(( "with unreasonable %u records rejected\n", num_records ));
- goto Fail;
- }
-
- /* Out-of-spec tables are rejected. The record size must be */
- /* equal to the number of glyphs + 2 + 32-bit padding. */
- if ( (FT_Long)record_size != ( ( face->root.num_glyphs + 2 + 3 ) & ~3 ) )
- {
- FT_TRACE2(( "with record size off by %ld bytes rejected\n",
- (FT_Long)record_size -
- ( ( face->root.num_glyphs + 2 + 3 ) & ~3 ) ));
- goto Fail;
- }
-
- if ( FT_QNEW_ARRAY( face->hdmx_records, num_records ) )
- goto Fail;
-
- for ( nn = 0; nn < num_records; nn++ )
- {
- if ( p + record_size > limit )
- break;
- face->hdmx_records[nn] = p;
- p += record_size;
- }
-
- /* The records must be already sorted by ppem but it does not */
- /* hurt to make sure so that the binary search works later. */
- ft_qsort( face->hdmx_records, nn, sizeof ( FT_Byte* ), compare_ppem );
-
- face->hdmx_record_count = nn;
- face->hdmx_table_size = table_size;
- face->hdmx_record_size = record_size;
-
- FT_TRACE2(( "%ux%lu loaded\n", num_records, record_size ));
-
- Exit:
- return error;
-
- Fail:
- FT_FRAME_RELEASE( face->hdmx_table );
- face->hdmx_table_size = 0;
- goto Exit;
- }
-
-
- FT_LOCAL_DEF( void )
- tt_face_free_hdmx( TT_Face face )
- {
- FT_Stream stream = face->root.stream;
- FT_Memory memory = stream->memory;
-
-
- FT_FREE( face->hdmx_records );
- FT_FRAME_RELEASE( face->hdmx_table );
- }
-
-
- /**************************************************************************
- *
- * Return the advance width table for a given pixel size if it is found
- * in the font's `hdmx' table (if any). The records must be sorted for
- * the binary search to work properly.
- */
- FT_LOCAL_DEF( FT_Byte* )
- tt_face_get_device_metrics( TT_Face face,
- FT_UInt ppem,
- FT_UInt gindex )
- {
- FT_UInt min = 0;
- FT_UInt max = face->hdmx_record_count;
- FT_UInt mid;
- FT_Byte* result = NULL;
-
-
- while ( min < max )
- {
- mid = ( min + max ) >> 1;
-
- if ( face->hdmx_records[mid][0] > ppem )
- max = mid;
- else if ( face->hdmx_records[mid][0] < ppem )
- min = mid + 1;
- else
- {
- result = face->hdmx_records[mid] + 2 + gindex;
- break;
- }
- }
-
- return result;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/truetype/ttpload.h b/contrib/libs/freetype/src/truetype/ttpload.h
deleted file mode 100644
index bc32b58020..0000000000
--- a/contrib/libs/freetype/src/truetype/ttpload.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/****************************************************************************
- *
- * ttpload.h
- *
- * TrueType-specific tables loader (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef TTPLOAD_H_
-#define TTPLOAD_H_
-
-
-#include <freetype/internal/tttypes.h>
-
-
-FT_BEGIN_HEADER
-
-
- FT_LOCAL( FT_Error )
- tt_face_load_loca( TT_Face face,
- FT_Stream stream );
-
- FT_LOCAL( FT_ULong )
- tt_face_get_location( FT_Face face,
- FT_UInt gindex,
- FT_ULong *asize );
-
- FT_LOCAL( void )
- tt_face_done_loca( TT_Face face );
-
- FT_LOCAL( FT_Error )
- tt_face_load_cvt( TT_Face face,
- FT_Stream stream );
-
- FT_LOCAL( FT_Error )
- tt_face_load_fpgm( TT_Face face,
- FT_Stream stream );
-
-
- FT_LOCAL( FT_Error )
- tt_face_load_prep( TT_Face face,
- FT_Stream stream );
-
-
- FT_LOCAL( FT_Error )
- tt_face_load_hdmx( TT_Face face,
- FT_Stream stream );
-
-
- FT_LOCAL( void )
- tt_face_free_hdmx( TT_Face face );
-
-
- FT_LOCAL( FT_Byte* )
- tt_face_get_device_metrics( TT_Face face,
- FT_UInt ppem,
- FT_UInt gindex );
-
-FT_END_HEADER
-
-#endif /* TTPLOAD_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/type1/t1afm.c b/contrib/libs/freetype/src/type1/t1afm.c
deleted file mode 100644
index a63cd4dc48..0000000000
--- a/contrib/libs/freetype/src/type1/t1afm.c
+++ /dev/null
@@ -1,413 +0,0 @@
-/****************************************************************************
- *
- * t1afm.c
- *
- * AFM support for Type 1 fonts (body).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include "t1afm.h"
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/internal/psaux.h>
-#include "t1errors.h"
-
-
-#ifndef T1_CONFIG_OPTION_NO_AFM
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT t1afm
-
-
- FT_LOCAL_DEF( void )
- T1_Done_Metrics( FT_Memory memory,
- AFM_FontInfo fi )
- {
- FT_FREE( fi->KernPairs );
- fi->NumKernPair = 0;
-
- FT_FREE( fi->TrackKerns );
- fi->NumTrackKern = 0;
-
- FT_FREE( fi );
- }
-
-
- /* read a glyph name and return the equivalent glyph index */
- static FT_Int
- t1_get_index( const char* name,
- FT_Offset len,
- void* user_data )
- {
- T1_Font type1 = (T1_Font)user_data;
- FT_Int n;
-
-
- /* PS string/name length must be < 16-bit */
- if ( len > 0xFFFFU )
- return 0;
-
- for ( n = 0; n < type1->num_glyphs; n++ )
- {
- char* gname = (char*)type1->glyph_names[n];
-
-
- if ( gname && gname[0] == name[0] &&
- ft_strlen( gname ) == len &&
- ft_strncmp( gname, name, len ) == 0 )
- return n;
- }
-
- return 0;
- }
-
-
-#undef KERN_INDEX
-#define KERN_INDEX( g1, g2 ) ( ( (FT_ULong)(g1) << 16 ) | (g2) )
-
-
- /* compare two kerning pairs */
- FT_COMPARE_DEF( int )
- compare_kern_pairs( const void* a,
- const void* b )
- {
- AFM_KernPair pair1 = (AFM_KernPair)a;
- AFM_KernPair pair2 = (AFM_KernPair)b;
-
- FT_ULong index1 = KERN_INDEX( pair1->index1, pair1->index2 );
- FT_ULong index2 = KERN_INDEX( pair2->index1, pair2->index2 );
-
-
- if ( index1 > index2 )
- return 1;
- else if ( index1 < index2 )
- return -1;
- else
- return 0;
- }
-
-
- /* parse a PFM file -- for now, only read the kerning pairs */
- static FT_Error
- T1_Read_PFM( FT_Face t1_face,
- FT_Stream stream,
- AFM_FontInfo fi )
- {
- FT_Error error = FT_Err_Ok;
- FT_Memory memory = stream->memory;
- FT_Byte* start;
- FT_Byte* limit;
- FT_Byte* p;
- AFM_KernPair kp;
- FT_Int width_table_length;
- FT_CharMap oldcharmap;
- FT_CharMap charmap;
- FT_Int n;
-
-
- start = (FT_Byte*)stream->cursor;
- limit = (FT_Byte*)stream->limit;
-
- /* Figure out how long the width table is. */
- /* This info is a little-endian short at offset 99. */
- p = start + 99;
- if ( p + 2 > limit )
- {
- error = FT_THROW( Unknown_File_Format );
- goto Exit;
- }
- width_table_length = FT_PEEK_USHORT_LE( p );
-
- p += 18 + width_table_length;
- if ( p + 0x12 > limit || FT_PEEK_USHORT_LE( p ) < 0x12 )
- /* extension table is probably optional */
- goto Exit;
-
- /* Kerning offset is 14 bytes from start of extensions table. */
- p += 14;
- p = start + FT_PEEK_ULONG_LE( p );
-
- if ( p == start )
- /* zero offset means no table */
- goto Exit;
-
- if ( p + 2 > limit )
- {
- error = FT_THROW( Unknown_File_Format );
- goto Exit;
- }
-
- fi->NumKernPair = FT_PEEK_USHORT_LE( p );
- p += 2;
- if ( p + 4 * fi->NumKernPair > limit )
- {
- error = FT_THROW( Unknown_File_Format );
- goto Exit;
- }
-
- /* Actually, kerning pairs are simply optional! */
- if ( fi->NumKernPair == 0 )
- goto Exit;
-
- /* allocate the pairs */
- if ( FT_QNEW_ARRAY( fi->KernPairs, fi->NumKernPair ) )
- goto Exit;
-
- /* now, read each kern pair */
- kp = fi->KernPairs;
- limit = p + 4 * fi->NumKernPair;
-
- /* PFM kerning data are stored by encoding rather than glyph index, */
- /* so find the PostScript charmap of this font and install it */
- /* temporarily. If we find no PostScript charmap, then just use */
- /* the default and hope it is the right one. */
- oldcharmap = t1_face->charmap;
-
- for ( n = 0; n < t1_face->num_charmaps; n++ )
- {
- charmap = t1_face->charmaps[n];
- /* check against PostScript pseudo platform */
- if ( charmap->platform_id == 7 )
- {
- t1_face->charmap = charmap;
- break;
- }
- }
-
- /* Kerning info is stored as: */
- /* */
- /* encoding of first glyph (1 byte) */
- /* encoding of second glyph (1 byte) */
- /* offset (little-endian short) */
- for ( ; p < limit; p += 4 )
- {
- kp->index1 = FT_Get_Char_Index( t1_face, p[0] );
- kp->index2 = FT_Get_Char_Index( t1_face, p[1] );
-
- kp->x = (FT_Int)FT_PEEK_SHORT_LE( p + 2 );
- kp->y = 0;
-
- kp++;
- }
-
- t1_face->charmap = oldcharmap;
-
- /* now, sort the kern pairs according to their glyph indices */
- ft_qsort( fi->KernPairs, fi->NumKernPair, sizeof ( AFM_KernPairRec ),
- compare_kern_pairs );
-
- Exit:
- if ( error )
- {
- FT_FREE( fi->KernPairs );
- fi->NumKernPair = 0;
- }
-
- return error;
- }
-
-
- /* parse a metrics file -- either AFM or PFM depending on what */
- /* it turns out to be */
- FT_LOCAL_DEF( FT_Error )
- T1_Read_Metrics( FT_Face t1_face,
- FT_Stream stream )
- {
- PSAux_Service psaux;
- FT_Memory memory = stream->memory;
- AFM_ParserRec parser;
- AFM_FontInfo fi = NULL;
- FT_Error error = FT_ERR( Unknown_File_Format );
- T1_Face face = (T1_Face)t1_face;
- T1_Font t1_font = &face->type1;
-
-
- if ( face->afm_data )
- {
- FT_TRACE1(( "T1_Read_Metrics:"
- " Freeing previously attached metrics data.\n" ));
- T1_Done_Metrics( memory, (AFM_FontInfo)face->afm_data );
-
- face->afm_data = NULL;
- }
-
- if ( FT_NEW( fi ) ||
- FT_FRAME_ENTER( stream->size ) )
- goto Exit;
-
- fi->FontBBox = t1_font->font_bbox;
- fi->Ascender = t1_font->font_bbox.yMax;
- fi->Descender = t1_font->font_bbox.yMin;
-
- psaux = (PSAux_Service)face->psaux;
- if ( psaux->afm_parser_funcs )
- {
- error = psaux->afm_parser_funcs->init( &parser,
- stream->memory,
- stream->cursor,
- stream->limit );
-
- if ( !error )
- {
- parser.FontInfo = fi;
- parser.get_index = t1_get_index;
- parser.user_data = t1_font;
-
- error = psaux->afm_parser_funcs->parse( &parser );
- psaux->afm_parser_funcs->done( &parser );
- }
- }
-
- if ( FT_ERR_EQ( error, Unknown_File_Format ) )
- {
- FT_Byte* start = stream->cursor;
-
-
- /* MS Windows allows versions up to 0x3FF without complaining */
- if ( stream->size > 6 &&
- start[1] < 4 &&
- FT_PEEK_ULONG_LE( start + 2 ) == stream->size )
- error = T1_Read_PFM( t1_face, stream, fi );
- }
-
- if ( !error )
- {
- t1_font->font_bbox = fi->FontBBox;
-
- t1_face->bbox.xMin = fi->FontBBox.xMin >> 16;
- t1_face->bbox.yMin = fi->FontBBox.yMin >> 16;
- /* no `U' suffix here to 0xFFFF! */
- t1_face->bbox.xMax = ( fi->FontBBox.xMax + 0xFFFF ) >> 16;
- t1_face->bbox.yMax = ( fi->FontBBox.yMax + 0xFFFF ) >> 16;
-
- /* ascender and descender are optional and could both be zero */
- /* check if values are meaningful before overriding defaults */
- if ( fi->Ascender > fi->Descender )
- {
- /* no `U' suffix here to 0x8000! */
- t1_face->ascender = (FT_Short)( ( fi->Ascender + 0x8000 ) >> 16 );
- t1_face->descender = (FT_Short)( ( fi->Descender + 0x8000 ) >> 16 );
- }
-
- if ( fi->NumKernPair )
- {
- t1_face->face_flags |= FT_FACE_FLAG_KERNING;
- face->afm_data = fi;
- fi = NULL;
- }
- }
-
- FT_FRAME_EXIT();
-
- Exit:
- if ( fi )
- T1_Done_Metrics( memory, fi );
-
- return error;
- }
-
-
- /* find the kerning for a given glyph pair */
- FT_LOCAL_DEF( void )
- T1_Get_Kerning( AFM_FontInfo fi,
- FT_UInt glyph1,
- FT_UInt glyph2,
- FT_Vector* kerning )
- {
- AFM_KernPair min, mid, max;
- FT_ULong idx = KERN_INDEX( glyph1, glyph2 );
-
-
- /* simple binary search */
- min = fi->KernPairs;
- max = min + fi->NumKernPair - 1;
-
- while ( min <= max )
- {
- FT_ULong midi;
-
-
- mid = min + ( max - min ) / 2;
- midi = KERN_INDEX( mid->index1, mid->index2 );
-
- if ( midi == idx )
- {
- kerning->x = mid->x;
- kerning->y = mid->y;
-
- return;
- }
-
- if ( midi < idx )
- min = mid + 1;
- else
- max = mid - 1;
- }
-
- kerning->x = 0;
- kerning->y = 0;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- T1_Get_Track_Kerning( FT_Face face,
- FT_Fixed ptsize,
- FT_Int degree,
- FT_Fixed* kerning )
- {
- AFM_FontInfo fi = (AFM_FontInfo)( (T1_Face)face )->afm_data;
- FT_UInt i;
-
-
- if ( !fi )
- return FT_THROW( Invalid_Argument );
-
- for ( i = 0; i < fi->NumTrackKern; i++ )
- {
- AFM_TrackKern tk = fi->TrackKerns + i;
-
-
- if ( tk->degree != degree )
- continue;
-
- if ( ptsize < tk->min_ptsize )
- *kerning = tk->min_kern;
- else if ( ptsize > tk->max_ptsize )
- *kerning = tk->max_kern;
- else
- {
- *kerning = FT_MulDiv( ptsize - tk->min_ptsize,
- tk->max_kern - tk->min_kern,
- tk->max_ptsize - tk->min_ptsize ) +
- tk->min_kern;
- }
- }
-
- return FT_Err_Ok;
- }
-
-#else /* T1_CONFIG_OPTION_NO_AFM */
-
- /* ANSI C doesn't like empty source files */
- typedef int t1_afm_dummy_;
-
-#endif /* T1_CONFIG_OPTION_NO_AFM */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/type1/t1afm.h b/contrib/libs/freetype/src/type1/t1afm.h
deleted file mode 100644
index 7f5cdda191..0000000000
--- a/contrib/libs/freetype/src/type1/t1afm.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/****************************************************************************
- *
- * t1afm.h
- *
- * AFM support for Type 1 fonts (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef T1AFM_H_
-#define T1AFM_H_
-
-#include "t1objs.h"
-#include <freetype/internal/t1types.h>
-
-FT_BEGIN_HEADER
-
-
- FT_LOCAL( FT_Error )
- T1_Read_Metrics( FT_Face face,
- FT_Stream stream );
-
- FT_LOCAL( void )
- T1_Done_Metrics( FT_Memory memory,
- AFM_FontInfo fi );
-
- FT_LOCAL( void )
- T1_Get_Kerning( AFM_FontInfo fi,
- FT_UInt glyph1,
- FT_UInt glyph2,
- FT_Vector* kerning );
-
- FT_LOCAL( FT_Error )
- T1_Get_Track_Kerning( FT_Face face,
- FT_Fixed ptsize,
- FT_Int degree,
- FT_Fixed* kerning );
-
-FT_END_HEADER
-
-#endif /* T1AFM_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/type1/t1driver.c b/contrib/libs/freetype/src/type1/t1driver.c
deleted file mode 100644
index 8ed01914a5..0000000000
--- a/contrib/libs/freetype/src/type1/t1driver.c
+++ /dev/null
@@ -1,807 +0,0 @@
-/****************************************************************************
- *
- * t1driver.c
- *
- * Type 1 driver interface (body).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include "t1driver.h"
-#include "t1gload.h"
-#include "t1load.h"
-
-#include "t1errors.h"
-
-#ifndef T1_CONFIG_OPTION_NO_AFM
-#include "t1afm.h"
-#endif
-
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/internal/fthash.h>
-#include <freetype/internal/ftpsprop.h>
-#include <freetype/ftdriver.h>
-
-#include <freetype/internal/services/svmm.h>
-#include <freetype/internal/services/svgldict.h>
-#include <freetype/internal/services/svfntfmt.h>
-#include <freetype/internal/services/svpostnm.h>
-#include <freetype/internal/services/svpscmap.h>
-#include <freetype/internal/services/svpsinfo.h>
-#include <freetype/internal/services/svprop.h>
-#include <freetype/internal/services/svkern.h>
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT t1driver
-
- /*
- * GLYPH DICT SERVICE
- *
- */
-
- FT_CALLBACK_DEF( FT_Error )
- t1_get_glyph_name( FT_Face face, /* T1_Face */
- FT_UInt glyph_index,
- FT_Pointer buffer,
- FT_UInt buffer_max )
- {
- T1_Face t1face = (T1_Face)face;
-
-
- FT_STRCPYN( buffer, t1face->type1.glyph_names[glyph_index], buffer_max );
-
- return FT_Err_Ok;
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- t1_get_name_index( FT_Face face, /* T1_Face */
- const FT_String* glyph_name )
- {
- T1_Face t1face = (T1_Face)face;
- FT_Int i;
-
-
- for ( i = 0; i < t1face->type1.num_glyphs; i++ )
- {
- FT_String* gname = t1face->type1.glyph_names[i];
-
-
- if ( !ft_strcmp( glyph_name, gname ) )
- return (FT_UInt)i;
- }
-
- return 0;
- }
-
-
- static const FT_Service_GlyphDictRec t1_service_glyph_dict =
- {
- t1_get_glyph_name, /* FT_GlyphDict_GetNameFunc get_name */
- t1_get_name_index /* FT_GlyphDict_NameIndexFunc name_index */
- };
-
-
- /*
- * POSTSCRIPT NAME SERVICE
- *
- */
-
- static const char*
- t1_get_ps_name( FT_Face face ) /* T1_Face */
- {
- T1_Face t1face = (T1_Face)face;
-
-
- return (const char*) t1face->type1.font_name;
- }
-
-
- static const FT_Service_PsFontNameRec t1_service_ps_name =
- {
- (FT_PsName_GetFunc)t1_get_ps_name /* get_ps_font_name */
- };
-
-
- /*
- * MULTIPLE MASTERS SERVICE
- *
- */
-
-#ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT
- static const FT_Service_MultiMastersRec t1_service_multi_masters =
- {
- T1_Get_Multi_Master, /* FT_Get_MM_Func get_mm */
- T1_Set_MM_Design, /* FT_Set_MM_Design_Func set_mm_design */
- T1_Set_MM_Blend, /* FT_Set_MM_Blend_Func set_mm_blend */
- T1_Get_MM_Blend, /* FT_Get_MM_Blend_Func get_mm_blend */
- T1_Get_MM_Var, /* FT_Get_MM_Var_Func get_mm_var */
- T1_Set_Var_Design, /* FT_Set_Var_Design_Func set_var_design */
- T1_Get_Var_Design, /* FT_Get_Var_Design_Func get_var_design */
- T1_Reset_MM_Blend, /* FT_Set_Named_Instance_Func set_named_instance */
- NULL, /* FT_Get_Default_Named_Instance_Func get_default_named_instance */
- T1_Set_MM_WeightVector,
- /* FT_Set_MM_WeightVector_Func set_mm_weightvector */
- T1_Get_MM_WeightVector,
- /* FT_Get_MM_WeightVector_Func get_mm_weightvector */
-
- NULL, /* FT_Construct_PS_Name_Func construct_ps_name */
- NULL, /* FT_Var_Load_Delta_Set_Idx_Map_Func load_delta_set_idx_map */
- NULL, /* FT_Var_Load_Item_Var_Store_Func load_item_variation_store */
- NULL, /* FT_Var_Get_Item_Delta_Func get_item_delta */
- NULL, /* FT_Var_Done_Item_Var_Store_Func done_item_variation_store */
- NULL, /* FT_Var_Done_Delta_Set_Idx_Map_Func done_delta_set_index_map */
- NULL, /* FT_Get_Var_Blend_Func get_var_blend */
- T1_Done_Blend /* FT_Done_Blend_Func done_blend */
- };
-#endif
-
-
- /*
- * POSTSCRIPT INFO SERVICE
- *
- */
-
- static FT_Error
- t1_ps_get_font_info( FT_Face face,
- PS_FontInfoRec* afont_info )
- {
- *afont_info = ((T1_Face)face)->type1.font_info;
-
- return FT_Err_Ok;
- }
-
-
- static FT_Error
- t1_ps_get_font_extra( FT_Face face,
- PS_FontExtraRec* afont_extra )
- {
- *afont_extra = ((T1_Face)face)->type1.font_extra;
-
- return FT_Err_Ok;
- }
-
-
- static FT_Int
- t1_ps_has_glyph_names( FT_Face face )
- {
- FT_UNUSED( face );
-
- return 1;
- }
-
-
- static FT_Error
- t1_ps_get_font_private( FT_Face face,
- PS_PrivateRec* afont_private )
- {
- *afont_private = ((T1_Face)face)->type1.private_dict;
-
- return FT_Err_Ok;
- }
-
-
- static FT_Long
- t1_ps_get_font_value( FT_Face face,
- PS_Dict_Keys key,
- FT_UInt idx,
- void *value,
- FT_Long value_len_ )
- {
- FT_ULong retval = 0; /* always >= 1 if valid */
- FT_ULong value_len = value_len_ < 0 ? 0 : (FT_ULong)value_len_;
-
- T1_Face t1face = (T1_Face)face;
- T1_Font type1 = &t1face->type1;
-
-
- switch ( key )
- {
- case PS_DICT_FONT_TYPE:
- retval = sizeof ( type1->font_type );
- if ( value && value_len >= retval )
- *((FT_Byte *)value) = type1->font_type;
- break;
-
- case PS_DICT_FONT_MATRIX:
- if ( idx < sizeof ( type1->font_matrix ) /
- sizeof ( type1->font_matrix.xx ) )
- {
- FT_Fixed val = 0;
-
-
- retval = sizeof ( val );
- if ( value && value_len >= retval )
- {
- switch ( idx )
- {
- case 0:
- val = type1->font_matrix.xx;
- break;
- case 1:
- val = type1->font_matrix.xy;
- break;
- case 2:
- val = type1->font_matrix.yx;
- break;
- case 3:
- val = type1->font_matrix.yy;
- break;
- }
- *((FT_Fixed *)value) = val;
- }
- }
- break;
-
- case PS_DICT_FONT_BBOX:
- if ( idx < sizeof ( type1->font_bbox ) /
- sizeof ( type1->font_bbox.xMin ) )
- {
- FT_Fixed val = 0;
-
-
- retval = sizeof ( val );
- if ( value && value_len >= retval )
- {
- switch ( idx )
- {
- case 0:
- val = type1->font_bbox.xMin;
- break;
- case 1:
- val = type1->font_bbox.yMin;
- break;
- case 2:
- val = type1->font_bbox.xMax;
- break;
- case 3:
- val = type1->font_bbox.yMax;
- break;
- }
- *((FT_Fixed *)value) = val;
- }
- }
- break;
-
- case PS_DICT_PAINT_TYPE:
- retval = sizeof ( type1->paint_type );
- if ( value && value_len >= retval )
- *((FT_Byte *)value) = type1->paint_type;
- break;
-
- case PS_DICT_FONT_NAME:
- if ( type1->font_name )
- {
- retval = ft_strlen( type1->font_name ) + 1;
- if ( value && value_len >= retval )
- ft_memcpy( value, (void *)( type1->font_name ), retval );
- }
- break;
-
- case PS_DICT_UNIQUE_ID:
- retval = sizeof ( type1->private_dict.unique_id );
- if ( value && value_len >= retval )
- *((FT_Int *)value) = type1->private_dict.unique_id;
- break;
-
- case PS_DICT_NUM_CHAR_STRINGS:
- retval = sizeof ( type1->num_glyphs );
- if ( value && value_len >= retval )
- *((FT_Int *)value) = type1->num_glyphs;
- break;
-
- case PS_DICT_CHAR_STRING_KEY:
- if ( idx < (FT_UInt)type1->num_glyphs )
- {
- retval = ft_strlen( type1->glyph_names[idx] ) + 1;
- if ( value && value_len >= retval )
- ft_memcpy( value, (void *)( type1->glyph_names[idx] ), retval );
- }
- break;
-
- case PS_DICT_CHAR_STRING:
- if ( idx < (FT_UInt)type1->num_glyphs )
- {
- retval = type1->charstrings_len[idx] + 1;
- if ( value && value_len >= retval )
- {
- ft_memcpy( value, (void *)( type1->charstrings[idx] ),
- retval - 1 );
- ((FT_Char *)value)[retval - 1] = (FT_Char)'\0';
- }
- }
- break;
-
- case PS_DICT_ENCODING_TYPE:
- retval = sizeof ( type1->encoding_type );
- if ( value && value_len >= retval )
- *((T1_EncodingType *)value) = type1->encoding_type;
- break;
-
- case PS_DICT_ENCODING_ENTRY:
- if ( type1->encoding_type == T1_ENCODING_TYPE_ARRAY &&
- idx < (FT_UInt)type1->encoding.num_chars )
- {
- retval = ft_strlen( type1->encoding.char_name[idx] ) + 1;
- if ( value && value_len >= retval )
- ft_memcpy( value, (void *)( type1->encoding.char_name[idx] ),
- retval );
- }
- break;
-
- case PS_DICT_NUM_SUBRS:
- retval = sizeof ( type1->num_subrs );
- if ( value && value_len >= retval )
- *((FT_Int *)value) = type1->num_subrs;
- break;
-
- case PS_DICT_SUBR:
- {
- FT_Bool ok = 0;
-
-
- if ( type1->subrs_hash )
- {
- /* convert subr index to array index */
- size_t* val = ft_hash_num_lookup( (FT_Int)idx,
- type1->subrs_hash );
-
-
- if ( val )
- {
- idx = *val;
- ok = 1;
- }
- }
- else
- {
- if ( idx < (FT_UInt)type1->num_subrs )
- ok = 1;
- }
-
- if ( ok && type1->subrs )
- {
- retval = type1->subrs_len[idx] + 1;
- if ( value && value_len >= retval )
- {
- ft_memcpy( value, (void *)( type1->subrs[idx] ), retval - 1 );
- ((FT_Char *)value)[retval - 1] = (FT_Char)'\0';
- }
- }
- }
- break;
-
- case PS_DICT_STD_HW:
- retval = sizeof ( type1->private_dict.standard_width[0] );
- if ( value && value_len >= retval )
- *((FT_UShort *)value) = type1->private_dict.standard_width[0];
- break;
-
- case PS_DICT_STD_VW:
- retval = sizeof ( type1->private_dict.standard_height[0] );
- if ( value && value_len >= retval )
- *((FT_UShort *)value) = type1->private_dict.standard_height[0];
- break;
-
- case PS_DICT_NUM_BLUE_VALUES:
- retval = sizeof ( type1->private_dict.num_blue_values );
- if ( value && value_len >= retval )
- *((FT_Byte *)value) = type1->private_dict.num_blue_values;
- break;
-
- case PS_DICT_BLUE_VALUE:
- if ( idx < type1->private_dict.num_blue_values )
- {
- retval = sizeof ( type1->private_dict.blue_values[idx] );
- if ( value && value_len >= retval )
- *((FT_Short *)value) = type1->private_dict.blue_values[idx];
- }
- break;
-
- case PS_DICT_BLUE_SCALE:
- retval = sizeof ( type1->private_dict.blue_scale );
- if ( value && value_len >= retval )
- *((FT_Fixed *)value) = type1->private_dict.blue_scale;
- break;
-
- case PS_DICT_BLUE_FUZZ:
- retval = sizeof ( type1->private_dict.blue_fuzz );
- if ( value && value_len >= retval )
- *((FT_Int *)value) = type1->private_dict.blue_fuzz;
- break;
-
- case PS_DICT_BLUE_SHIFT:
- retval = sizeof ( type1->private_dict.blue_shift );
- if ( value && value_len >= retval )
- *((FT_Int *)value) = type1->private_dict.blue_shift;
- break;
-
- case PS_DICT_NUM_OTHER_BLUES:
- retval = sizeof ( type1->private_dict.num_other_blues );
- if ( value && value_len >= retval )
- *((FT_Byte *)value) = type1->private_dict.num_other_blues;
- break;
-
- case PS_DICT_OTHER_BLUE:
- if ( idx < type1->private_dict.num_other_blues )
- {
- retval = sizeof ( type1->private_dict.other_blues[idx] );
- if ( value && value_len >= retval )
- *((FT_Short *)value) = type1->private_dict.other_blues[idx];
- }
- break;
-
- case PS_DICT_NUM_FAMILY_BLUES:
- retval = sizeof ( type1->private_dict.num_family_blues );
- if ( value && value_len >= retval )
- *((FT_Byte *)value) = type1->private_dict.num_family_blues;
- break;
-
- case PS_DICT_FAMILY_BLUE:
- if ( idx < type1->private_dict.num_family_blues )
- {
- retval = sizeof ( type1->private_dict.family_blues[idx] );
- if ( value && value_len >= retval )
- *((FT_Short *)value) = type1->private_dict.family_blues[idx];
- }
- break;
-
- case PS_DICT_NUM_FAMILY_OTHER_BLUES:
- retval = sizeof ( type1->private_dict.num_family_other_blues );
- if ( value && value_len >= retval )
- *((FT_Byte *)value) = type1->private_dict.num_family_other_blues;
- break;
-
- case PS_DICT_FAMILY_OTHER_BLUE:
- if ( idx < type1->private_dict.num_family_other_blues )
- {
- retval = sizeof ( type1->private_dict.family_other_blues[idx] );
- if ( value && value_len >= retval )
- *((FT_Short *)value) = type1->private_dict.family_other_blues[idx];
- }
- break;
-
- case PS_DICT_NUM_STEM_SNAP_H:
- retval = sizeof ( type1->private_dict.num_snap_widths );
- if ( value && value_len >= retval )
- *((FT_Byte *)value) = type1->private_dict.num_snap_widths;
- break;
-
- case PS_DICT_STEM_SNAP_H:
- if ( idx < type1->private_dict.num_snap_widths )
- {
- retval = sizeof ( type1->private_dict.snap_widths[idx] );
- if ( value && value_len >= retval )
- *((FT_Short *)value) = type1->private_dict.snap_widths[idx];
- }
- break;
-
- case PS_DICT_NUM_STEM_SNAP_V:
- retval = sizeof ( type1->private_dict.num_snap_heights );
- if ( value && value_len >= retval )
- *((FT_Byte *)value) = type1->private_dict.num_snap_heights;
- break;
-
- case PS_DICT_STEM_SNAP_V:
- if ( idx < type1->private_dict.num_snap_heights )
- {
- retval = sizeof ( type1->private_dict.snap_heights[idx] );
- if ( value && value_len >= retval )
- *((FT_Short *)value) = type1->private_dict.snap_heights[idx];
- }
- break;
-
- case PS_DICT_RND_STEM_UP:
- retval = sizeof ( type1->private_dict.round_stem_up );
- if ( value && value_len >= retval )
- *((FT_Bool *)value) = type1->private_dict.round_stem_up;
- break;
-
- case PS_DICT_FORCE_BOLD:
- retval = sizeof ( type1->private_dict.force_bold );
- if ( value && value_len >= retval )
- *((FT_Bool *)value) = type1->private_dict.force_bold;
- break;
-
- case PS_DICT_MIN_FEATURE:
- if ( idx < sizeof ( type1->private_dict.min_feature ) /
- sizeof ( type1->private_dict.min_feature[0] ) )
- {
- retval = sizeof ( type1->private_dict.min_feature[idx] );
- if ( value && value_len >= retval )
- *((FT_Short *)value) = type1->private_dict.min_feature[idx];
- }
- break;
-
- case PS_DICT_LEN_IV:
- retval = sizeof ( type1->private_dict.lenIV );
- if ( value && value_len >= retval )
- *((FT_Int *)value) = type1->private_dict.lenIV;
- break;
-
- case PS_DICT_PASSWORD:
- retval = sizeof ( type1->private_dict.password );
- if ( value && value_len >= retval )
- *((FT_Long *)value) = type1->private_dict.password;
- break;
-
- case PS_DICT_LANGUAGE_GROUP:
- retval = sizeof ( type1->private_dict.language_group );
- if ( value && value_len >= retval )
- *((FT_Long *)value) = type1->private_dict.language_group;
- break;
-
- case PS_DICT_IS_FIXED_PITCH:
- retval = sizeof ( type1->font_info.is_fixed_pitch );
- if ( value && value_len >= retval )
- *((FT_Bool *)value) = type1->font_info.is_fixed_pitch;
- break;
-
- case PS_DICT_UNDERLINE_POSITION:
- retval = sizeof ( type1->font_info.underline_position );
- if ( value && value_len >= retval )
- *((FT_Short *)value) = type1->font_info.underline_position;
- break;
-
- case PS_DICT_UNDERLINE_THICKNESS:
- retval = sizeof ( type1->font_info.underline_thickness );
- if ( value && value_len >= retval )
- *((FT_UShort *)value) = type1->font_info.underline_thickness;
- break;
-
- case PS_DICT_FS_TYPE:
- retval = sizeof ( type1->font_extra.fs_type );
- if ( value && value_len >= retval )
- *((FT_UShort *)value) = type1->font_extra.fs_type;
- break;
-
- case PS_DICT_VERSION:
- if ( type1->font_info.version )
- {
- retval = ft_strlen( type1->font_info.version ) + 1;
- if ( value && value_len >= retval )
- ft_memcpy( value, (void *)( type1->font_info.version ), retval );
- }
- break;
-
- case PS_DICT_NOTICE:
- if ( type1->font_info.notice )
- {
- retval = ft_strlen( type1->font_info.notice ) + 1;
- if ( value && value_len >= retval )
- ft_memcpy( value, (void *)( type1->font_info.notice ), retval );
- }
- break;
-
- case PS_DICT_FULL_NAME:
- if ( type1->font_info.full_name )
- {
- retval = ft_strlen( type1->font_info.full_name ) + 1;
- if ( value && value_len >= retval )
- ft_memcpy( value, (void *)( type1->font_info.full_name ), retval );
- }
- break;
-
- case PS_DICT_FAMILY_NAME:
- if ( type1->font_info.family_name )
- {
- retval = ft_strlen( type1->font_info.family_name ) + 1;
- if ( value && value_len >= retval )
- ft_memcpy( value, (void *)( type1->font_info.family_name ),
- retval );
- }
- break;
-
- case PS_DICT_WEIGHT:
- if ( type1->font_info.weight )
- {
- retval = ft_strlen( type1->font_info.weight ) + 1;
- if ( value && value_len >= retval )
- ft_memcpy( value, (void *)( type1->font_info.weight ), retval );
- }
- break;
-
- case PS_DICT_ITALIC_ANGLE:
- retval = sizeof ( type1->font_info.italic_angle );
- if ( value && value_len >= retval )
- *((FT_Long *)value) = type1->font_info.italic_angle;
- break;
- }
-
- return retval == 0 ? -1 : (FT_Long)retval;
- }
-
-
- static const FT_Service_PsInfoRec t1_service_ps_info =
- {
- t1_ps_get_font_info, /* PS_GetFontInfoFunc ps_get_font_info */
- t1_ps_get_font_extra, /* PS_GetFontExtraFunc ps_get_font_extra */
- t1_ps_has_glyph_names, /* PS_HasGlyphNamesFunc ps_has_glyph_names */
- t1_ps_get_font_private, /* PS_GetFontPrivateFunc ps_get_font_private */
- t1_ps_get_font_value, /* PS_GetFontValueFunc ps_get_font_value */
- };
-
-
-#ifndef T1_CONFIG_OPTION_NO_AFM
- static const FT_Service_KerningRec t1_service_kerning =
- {
- T1_Get_Track_Kerning, /* get_track */
- };
-#endif
-
-
- /*
- * PROPERTY SERVICE
- *
- */
-
- FT_DEFINE_SERVICE_PROPERTIESREC(
- t1_service_properties,
-
- ps_property_set, /* FT_Properties_SetFunc set_property */
- ps_property_get /* FT_Properties_GetFunc get_property */
- )
-
- /*
- * SERVICE LIST
- *
- */
-
- static const FT_ServiceDescRec t1_services[] =
- {
- { FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &t1_service_ps_name },
- { FT_SERVICE_ID_GLYPH_DICT, &t1_service_glyph_dict },
- { FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_TYPE_1 },
- { FT_SERVICE_ID_POSTSCRIPT_INFO, &t1_service_ps_info },
- { FT_SERVICE_ID_PROPERTIES, &t1_service_properties },
-
-#ifndef T1_CONFIG_OPTION_NO_AFM
- { FT_SERVICE_ID_KERNING, &t1_service_kerning },
-#endif
-
-#ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT
- { FT_SERVICE_ID_MULTI_MASTERS, &t1_service_multi_masters },
-#endif
- { NULL, NULL }
- };
-
-
- FT_CALLBACK_DEF( FT_Module_Interface )
- Get_Interface( FT_Module module,
- const FT_String* t1_interface )
- {
- FT_UNUSED( module );
-
- return ft_service_list_lookup( t1_services, t1_interface );
- }
-
-
-#ifndef T1_CONFIG_OPTION_NO_AFM
-
- /**************************************************************************
- *
- * @Function:
- * Get_Kerning
- *
- * @Description:
- * A driver method used to return the kerning vector between two
- * glyphs of the same face.
- *
- * @Input:
- * face ::
- * A handle to the source face object.
- *
- * left_glyph ::
- * The index of the left glyph in the kern pair.
- *
- * right_glyph ::
- * The index of the right glyph in the kern pair.
- *
- * @Output:
- * kerning ::
- * The kerning vector. This is in font units for
- * scalable formats, and in pixels for fixed-sizes
- * formats.
- *
- * @Return:
- * FreeType error code. 0 means success.
- *
- * @Note:
- * Only horizontal layouts (left-to-right & right-to-left) are
- * supported by this function. Other layouts, or more sophisticated
- * kernings are out of scope of this method (the basic driver
- * interface is meant to be simple).
- *
- * They can be implemented by format-specific interfaces.
- */
- static FT_Error
- Get_Kerning( FT_Face t1face, /* T1_Face */
- FT_UInt left_glyph,
- FT_UInt right_glyph,
- FT_Vector* kerning )
- {
- T1_Face face = (T1_Face)t1face;
-
-
- kerning->x = 0;
- kerning->y = 0;
-
- if ( face->afm_data )
- T1_Get_Kerning( (AFM_FontInfo)face->afm_data,
- left_glyph,
- right_glyph,
- kerning );
-
- return FT_Err_Ok;
- }
-
-
-#endif /* T1_CONFIG_OPTION_NO_AFM */
-
-
- FT_CALLBACK_TABLE_DEF
- const FT_Driver_ClassRec t1_driver_class =
- {
- {
- FT_MODULE_FONT_DRIVER |
- FT_MODULE_DRIVER_SCALABLE |
- FT_MODULE_DRIVER_HAS_HINTER,
-
- sizeof ( PS_DriverRec ),
-
- "type1",
- 0x10000L,
- 0x20000L,
-
- NULL, /* module-specific interface */
-
- T1_Driver_Init, /* FT_Module_Constructor module_init */
- T1_Driver_Done, /* FT_Module_Destructor module_done */
- Get_Interface, /* FT_Module_Requester get_interface */
- },
-
- sizeof ( T1_FaceRec ),
- sizeof ( T1_SizeRec ),
- sizeof ( T1_GlyphSlotRec ),
-
- T1_Face_Init, /* FT_Face_InitFunc init_face */
- T1_Face_Done, /* FT_Face_DoneFunc done_face */
- T1_Size_Init, /* FT_Size_InitFunc init_size */
- T1_Size_Done, /* FT_Size_DoneFunc done_size */
- T1_GlyphSlot_Init, /* FT_Slot_InitFunc init_slot */
- T1_GlyphSlot_Done, /* FT_Slot_DoneFunc done_slot */
-
- T1_Load_Glyph, /* FT_Slot_LoadFunc load_glyph */
-
-#ifdef T1_CONFIG_OPTION_NO_AFM
- NULL, /* FT_Face_GetKerningFunc get_kerning */
- NULL, /* FT_Face_AttachFunc attach_file */
-#else
- Get_Kerning, /* FT_Face_GetKerningFunc get_kerning */
- T1_Read_Metrics, /* FT_Face_AttachFunc attach_file */
-#endif
- T1_Get_Advances, /* FT_Face_GetAdvancesFunc get_advances */
-
- T1_Size_Request, /* FT_Size_RequestFunc request_size */
- NULL /* FT_Size_SelectFunc select_size */
- };
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/type1/t1driver.h b/contrib/libs/freetype/src/type1/t1driver.h
deleted file mode 100644
index 5ff52b55b1..0000000000
--- a/contrib/libs/freetype/src/type1/t1driver.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/****************************************************************************
- *
- * t1driver.h
- *
- * High-level Type 1 driver interface (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef T1DRIVER_H_
-#define T1DRIVER_H_
-
-
-#include <freetype/internal/ftdrv.h>
-
-
-FT_BEGIN_HEADER
-
- FT_EXPORT_VAR( const FT_Driver_ClassRec ) t1_driver_class;
-
-FT_END_HEADER
-
-#endif /* T1DRIVER_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/type1/t1errors.h b/contrib/libs/freetype/src/type1/t1errors.h
deleted file mode 100644
index 8aeb24ae18..0000000000
--- a/contrib/libs/freetype/src/type1/t1errors.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/****************************************************************************
- *
- * t1errors.h
- *
- * Type 1 error codes (specification only).
- *
- * Copyright (C) 2001-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /**************************************************************************
- *
- * This file is used to define the Type 1 error enumeration constants.
- *
- */
-
-#ifndef T1ERRORS_H_
-#define T1ERRORS_H_
-
-#include <freetype/ftmoderr.h>
-
-#undef FTERRORS_H_
-
-#undef FT_ERR_PREFIX
-#define FT_ERR_PREFIX T1_Err_
-#define FT_ERR_BASE FT_Mod_Err_Type1
-
-#include <freetype/fterrors.h>
-
-#endif /* T1ERRORS_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/type1/t1gload.c b/contrib/libs/freetype/src/type1/t1gload.c
deleted file mode 100644
index c29e682510..0000000000
--- a/contrib/libs/freetype/src/type1/t1gload.c
+++ /dev/null
@@ -1,606 +0,0 @@
-/****************************************************************************
- *
- * t1gload.c
- *
- * Type 1 Glyph Loader (body).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include "t1gload.h"
-#include <freetype/internal/ftcalc.h>
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/ftoutln.h>
-#include <freetype/internal/psaux.h>
-#include <freetype/internal/cfftypes.h>
-#include <freetype/ftdriver.h>
-
-#include "t1errors.h"
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT t1gload
-
-
- static FT_Error
- T1_Parse_Glyph_And_Get_Char_String( T1_Decoder decoder,
- FT_UInt glyph_index,
- FT_Data* char_string,
- FT_Bool* force_scaling )
- {
- T1_Face face = (T1_Face)decoder->builder.face;
- T1_Font type1 = &face->type1;
- FT_Error error = FT_Err_Ok;
-
- PSAux_Service psaux = (PSAux_Service)face->psaux;
- const T1_Decoder_Funcs decoder_funcs = psaux->t1_decoder_funcs;
- PS_Decoder psdecoder;
-
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- FT_Incremental_InterfaceRec *inc =
- face->root.internal->incremental_interface;
-#endif
-
-#ifdef T1_CONFIG_OPTION_OLD_ENGINE
- PS_Driver driver = (PS_Driver)FT_FACE_DRIVER( face );
-#endif
-
-
- decoder->font_matrix = type1->font_matrix;
- decoder->font_offset = type1->font_offset;
-
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
-
- /* For incremental fonts get the character data using the */
- /* callback function. */
- if ( inc )
- error = inc->funcs->get_glyph_data( inc->object,
- glyph_index, char_string );
- else
-
-#endif /* FT_CONFIG_OPTION_INCREMENTAL */
-
- /* For ordinary fonts get the character data stored in the face record. */
- {
- char_string->pointer = type1->charstrings[glyph_index];
- char_string->length = type1->charstrings_len[glyph_index];
- }
-
- if ( !error )
- {
- /* choose which renderer to use */
-#ifdef T1_CONFIG_OPTION_OLD_ENGINE
- if ( driver->hinting_engine == FT_HINTING_FREETYPE ||
- decoder->builder.metrics_only )
- error = decoder_funcs->parse_charstrings_old(
- decoder,
- (FT_Byte*)char_string->pointer,
- (FT_UInt)char_string->length );
-#else
- if ( decoder->builder.metrics_only )
- error = decoder_funcs->parse_metrics(
- decoder,
- (FT_Byte*)char_string->pointer,
- (FT_UInt)char_string->length );
-#endif
- else
- {
- CFF_SubFontRec subfont;
-
-
- psaux->ps_decoder_init( &psdecoder, decoder, TRUE );
-
- psaux->t1_make_subfont( FT_FACE( face ),
- &face->type1.private_dict, &subfont );
- psdecoder.current_subfont = &subfont;
-
- error = decoder_funcs->parse_charstrings(
- &psdecoder,
- (FT_Byte*)char_string->pointer,
- (FT_ULong)char_string->length );
-
- /* Adobe's engine uses 16.16 numbers everywhere; */
- /* as a consequence, glyphs larger than 2000ppem get rejected */
- if ( FT_ERR_EQ( error, Glyph_Too_Big ) )
- {
- /* this time, we retry unhinted and scale up the glyph later on */
- /* (the engine uses and sets the hardcoded value 0x10000 / 64 = */
- /* 0x400 for both `x_scale' and `y_scale' in this case) */
- ((T1_GlyphSlot)decoder->builder.glyph)->hint = FALSE;
-
- *force_scaling = TRUE;
-
- error = decoder_funcs->parse_charstrings(
- &psdecoder,
- (FT_Byte*)char_string->pointer,
- (FT_ULong)char_string->length );
- }
- }
- }
-
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
-
- /* Incremental fonts can optionally override the metrics. */
- if ( !error && inc && inc->funcs->get_glyph_metrics )
- {
- FT_Incremental_MetricsRec metrics;
-
-
- metrics.bearing_x = FIXED_TO_INT( decoder->builder.left_bearing.x );
- metrics.bearing_y = 0;
- metrics.advance = FIXED_TO_INT( decoder->builder.advance.x );
- metrics.advance_v = FIXED_TO_INT( decoder->builder.advance.y );
-
- error = inc->funcs->get_glyph_metrics( inc->object,
- glyph_index, FALSE, &metrics );
-
- decoder->builder.left_bearing.x = INT_TO_FIXED( metrics.bearing_x );
- decoder->builder.advance.x = INT_TO_FIXED( metrics.advance );
- decoder->builder.advance.y = INT_TO_FIXED( metrics.advance_v );
- }
-
-#endif /* FT_CONFIG_OPTION_INCREMENTAL */
-
- return error;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- T1_Parse_Glyph( T1_Decoder decoder,
- FT_UInt glyph_index )
- {
- FT_Data glyph_data;
- FT_Bool force_scaling = FALSE;
- FT_Error error = T1_Parse_Glyph_And_Get_Char_String(
- decoder, glyph_index, &glyph_data,
- &force_scaling );
-
-
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
-
- if ( !error )
- {
- T1_Face face = (T1_Face)decoder->builder.face;
-
-
- if ( face->root.internal->incremental_interface )
- face->root.internal->incremental_interface->funcs->free_glyph_data(
- face->root.internal->incremental_interface->object,
- &glyph_data );
- }
-
-#endif /* FT_CONFIG_OPTION_INCREMENTAL */
-
- return error;
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /********** *********/
- /********** COMPUTE THE MAXIMUM ADVANCE WIDTH *********/
- /********** *********/
- /********** The following code is in charge of computing *********/
- /********** the maximum advance width of the font. It *********/
- /********** quickly processes each glyph charstring to *********/
- /********** extract the value from either a `sbw' or `seac' *********/
- /********** operator. *********/
- /********** *********/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
- FT_LOCAL_DEF( FT_Error )
- T1_Compute_Max_Advance( T1_Face face,
- FT_Pos* max_advance )
- {
- FT_Error error;
- T1_DecoderRec decoder;
- FT_Int glyph_index;
- T1_Font type1 = &face->type1;
- PSAux_Service psaux = (PSAux_Service)face->psaux;
-
-
- FT_ASSERT( ( face->len_buildchar == 0 ) == ( face->buildchar == NULL ) );
-
- *max_advance = 0;
-
- /* initialize load decoder */
- error = psaux->t1_decoder_funcs->init( &decoder,
- (FT_Face)face,
- 0, /* size */
- 0, /* glyph slot */
- (FT_Byte**)type1->glyph_names,
- face->blend,
- 0,
- FT_RENDER_MODE_NORMAL,
- T1_Parse_Glyph );
- if ( error )
- return error;
-
- decoder.builder.metrics_only = 1;
- decoder.builder.load_points = 0;
-
- decoder.num_subrs = type1->num_subrs;
- decoder.subrs = type1->subrs;
- decoder.subrs_len = type1->subrs_len;
- decoder.subrs_hash = type1->subrs_hash;
-
- decoder.buildchar = face->buildchar;
- decoder.len_buildchar = face->len_buildchar;
-
- *max_advance = 0;
-
- FT_TRACE6(( "T1_Compute_Max_Advance:\n" ));
-
- /* for each glyph, parse the glyph charstring and extract */
- /* the advance width */
- for ( glyph_index = 0; glyph_index < type1->num_glyphs; glyph_index++ )
- {
- /* now get load the unscaled outline */
- (void)T1_Parse_Glyph( &decoder, (FT_UInt)glyph_index );
- if ( glyph_index == 0 || decoder.builder.advance.x > *max_advance )
- *max_advance = decoder.builder.advance.x;
-
- /* ignore the error if one occurred - skip to next glyph */
- }
-
- FT_TRACE6(( "T1_Compute_Max_Advance: max advance: %f\n",
- (double)*max_advance / 65536 ));
-
- psaux->t1_decoder_funcs->done( &decoder );
-
- return FT_Err_Ok;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- T1_Get_Advances( FT_Face t1face, /* T1_Face */
- FT_UInt first,
- FT_UInt count,
- FT_Int32 load_flags,
- FT_Fixed* advances )
- {
- T1_Face face = (T1_Face)t1face;
- T1_DecoderRec decoder;
- T1_Font type1 = &face->type1;
- PSAux_Service psaux = (PSAux_Service)face->psaux;
- FT_UInt nn;
- FT_Error error;
-
-
- FT_TRACE5(( "T1_Get_Advances:\n" ));
-
- if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
- {
- for ( nn = 0; nn < count; nn++ )
- {
- advances[nn] = 0;
-
- FT_TRACE5(( " idx %d: advance height 0 font units\n",
- first + nn ));
- }
-
- return FT_Err_Ok;
- }
-
- error = psaux->t1_decoder_funcs->init( &decoder,
- (FT_Face)face,
- 0, /* size */
- 0, /* glyph slot */
- (FT_Byte**)type1->glyph_names,
- face->blend,
- 0,
- FT_RENDER_MODE_NORMAL,
- T1_Parse_Glyph );
- if ( error )
- return error;
-
- decoder.builder.metrics_only = 1;
- decoder.builder.load_points = 0;
-
- decoder.num_subrs = type1->num_subrs;
- decoder.subrs = type1->subrs;
- decoder.subrs_len = type1->subrs_len;
- decoder.subrs_hash = type1->subrs_hash;
-
- decoder.buildchar = face->buildchar;
- decoder.len_buildchar = face->len_buildchar;
-
- for ( nn = 0; nn < count; nn++ )
- {
- error = T1_Parse_Glyph( &decoder, first + nn );
- if ( !error )
- advances[nn] = FIXED_TO_INT( decoder.builder.advance.x );
- else
- advances[nn] = 0;
-
- FT_TRACE5(( " idx %d: advance width %ld font unit%s\n",
- first + nn,
- advances[nn],
- advances[nn] == 1 ? "" : "s" ));
- }
-
- return FT_Err_Ok;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- T1_Load_Glyph( FT_GlyphSlot t1glyph, /* T1_GlyphSlot */
- FT_Size t1size, /* T1_Size */
- FT_UInt glyph_index,
- FT_Int32 load_flags )
- {
- T1_GlyphSlot glyph = (T1_GlyphSlot)t1glyph;
- FT_Error error;
- T1_DecoderRec decoder;
- T1_Face face = (T1_Face)t1glyph->face;
- FT_Bool hinting;
- FT_Bool scaled;
- FT_Bool force_scaling = FALSE;
- T1_Font type1 = &face->type1;
- PSAux_Service psaux = (PSAux_Service)face->psaux;
- const T1_Decoder_Funcs decoder_funcs = psaux->t1_decoder_funcs;
-
- FT_Matrix font_matrix;
- FT_Vector font_offset;
- FT_Data glyph_data;
- FT_Bool must_finish_decoder = FALSE;
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- FT_Bool glyph_data_loaded = 0;
-#endif
-
-
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- if ( glyph_index >= (FT_UInt)face->root.num_glyphs &&
- !face->root.internal->incremental_interface )
-#else
- if ( glyph_index >= (FT_UInt)face->root.num_glyphs )
-#endif /* FT_CONFIG_OPTION_INCREMENTAL */
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- FT_TRACE1(( "T1_Load_Glyph: glyph index %d\n", glyph_index ));
-
- FT_ASSERT( ( face->len_buildchar == 0 ) == ( face->buildchar == NULL ) );
-
- if ( load_flags & FT_LOAD_NO_RECURSE )
- load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
-
- if ( t1size )
- {
- glyph->x_scale = t1size->metrics.x_scale;
- glyph->y_scale = t1size->metrics.y_scale;
- }
- else
- {
- glyph->x_scale = 0x10000L;
- glyph->y_scale = 0x10000L;
- }
-
- t1glyph->outline.n_points = 0;
- t1glyph->outline.n_contours = 0;
-
- hinting = FT_BOOL( !( load_flags & FT_LOAD_NO_SCALE ) &&
- !( load_flags & FT_LOAD_NO_HINTING ) );
- scaled = FT_BOOL( !( load_flags & FT_LOAD_NO_SCALE ) );
-
- glyph->hint = hinting;
- glyph->scaled = scaled;
- t1glyph->format = FT_GLYPH_FORMAT_OUTLINE;
-
- error = decoder_funcs->init( &decoder,
- t1glyph->face,
- t1size,
- t1glyph,
- (FT_Byte**)type1->glyph_names,
- face->blend,
- hinting,
- FT_LOAD_TARGET_MODE( load_flags ),
- T1_Parse_Glyph );
- if ( error )
- goto Exit;
-
- must_finish_decoder = TRUE;
-
- decoder.builder.no_recurse = FT_BOOL( load_flags & FT_LOAD_NO_RECURSE );
-
- decoder.num_subrs = type1->num_subrs;
- decoder.subrs = type1->subrs;
- decoder.subrs_len = type1->subrs_len;
- decoder.subrs_hash = type1->subrs_hash;
-
- decoder.buildchar = face->buildchar;
- decoder.len_buildchar = face->len_buildchar;
-
- /* now load the unscaled outline */
- error = T1_Parse_Glyph_And_Get_Char_String( &decoder, glyph_index,
- &glyph_data,
- &force_scaling );
- if ( error )
- goto Exit;
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- glyph_data_loaded = 1;
-#endif
-
- hinting = glyph->hint;
- font_matrix = decoder.font_matrix;
- font_offset = decoder.font_offset;
-
- /* save new glyph tables */
- decoder_funcs->done( &decoder );
-
- must_finish_decoder = FALSE;
-
- /* now, set the metrics -- this is rather simple, as */
- /* the left side bearing is the xMin, and the top side */
- /* bearing the yMax */
- if ( !error )
- {
- t1glyph->outline.flags &= FT_OUTLINE_OWNER;
- t1glyph->outline.flags |= FT_OUTLINE_REVERSE_FILL;
-
- /* for composite glyphs, return only left side bearing and */
- /* advance width */
- if ( load_flags & FT_LOAD_NO_RECURSE )
- {
- FT_Slot_Internal internal = t1glyph->internal;
-
-
- t1glyph->metrics.horiBearingX =
- FIXED_TO_INT( decoder.builder.left_bearing.x );
- t1glyph->metrics.horiAdvance =
- FIXED_TO_INT( decoder.builder.advance.x );
-
- internal->glyph_matrix = font_matrix;
- internal->glyph_delta = font_offset;
- internal->glyph_transformed = 1;
- }
- else
- {
- FT_BBox cbox;
- FT_Glyph_Metrics* metrics = &t1glyph->metrics;
-
-
- /* copy the _unscaled_ advance width */
- metrics->horiAdvance =
- FIXED_TO_INT( decoder.builder.advance.x );
- t1glyph->linearHoriAdvance =
- FIXED_TO_INT( decoder.builder.advance.x );
- t1glyph->internal->glyph_transformed = 0;
-
- if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
- {
- /* make up vertical ones */
- metrics->vertAdvance = ( face->type1.font_bbox.yMax -
- face->type1.font_bbox.yMin ) >> 16;
- t1glyph->linearVertAdvance = metrics->vertAdvance;
- }
- else
- {
- metrics->vertAdvance =
- FIXED_TO_INT( decoder.builder.advance.y );
- t1glyph->linearVertAdvance =
- FIXED_TO_INT( decoder.builder.advance.y );
- }
-
- t1glyph->format = FT_GLYPH_FORMAT_OUTLINE;
-
- if ( t1size && t1size->metrics.y_ppem < 24 )
- t1glyph->outline.flags |= FT_OUTLINE_HIGH_PRECISION;
-
-#if 1
- /* apply the font matrix, if any */
- if ( font_matrix.xx != 0x10000L || font_matrix.yy != 0x10000L ||
- font_matrix.xy != 0 || font_matrix.yx != 0 )
- {
- FT_Outline_Transform( &t1glyph->outline, &font_matrix );
-
- metrics->horiAdvance = FT_MulFix( metrics->horiAdvance,
- font_matrix.xx );
- metrics->vertAdvance = FT_MulFix( metrics->vertAdvance,
- font_matrix.yy );
- }
-
- if ( font_offset.x || font_offset.y )
- {
- FT_Outline_Translate( &t1glyph->outline,
- font_offset.x,
- font_offset.y );
-
- metrics->horiAdvance += font_offset.x;
- metrics->vertAdvance += font_offset.y;
- }
-#endif
-
- if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 || force_scaling )
- {
- /* scale the outline and the metrics */
- FT_Int n;
- FT_Outline* cur = decoder.builder.base;
- FT_Vector* vec = cur->points;
- FT_Fixed x_scale = glyph->x_scale;
- FT_Fixed y_scale = glyph->y_scale;
-
-
- /* First of all, scale the points, if we are not hinting */
- if ( !hinting || !decoder.builder.hints_funcs )
- for ( n = cur->n_points; n > 0; n--, vec++ )
- {
- vec->x = FT_MulFix( vec->x, x_scale );
- vec->y = FT_MulFix( vec->y, y_scale );
- }
-
- /* Then scale the metrics */
- metrics->horiAdvance = FT_MulFix( metrics->horiAdvance, x_scale );
- metrics->vertAdvance = FT_MulFix( metrics->vertAdvance, y_scale );
- }
-
- /* compute the other metrics */
- FT_Outline_Get_CBox( &t1glyph->outline, &cbox );
-
- metrics->width = cbox.xMax - cbox.xMin;
- metrics->height = cbox.yMax - cbox.yMin;
-
- metrics->horiBearingX = cbox.xMin;
- metrics->horiBearingY = cbox.yMax;
-
- if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
- {
- /* make up vertical ones */
- ft_synthesize_vertical_metrics( metrics,
- metrics->vertAdvance );
- }
- }
-
- /* Set control data to the glyph charstrings. Note that this is */
- /* _not_ zero-terminated. */
- t1glyph->control_data = (FT_Byte*)glyph_data.pointer;
- t1glyph->control_len = glyph_data.length;
- }
-
-
- Exit:
-
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- if ( glyph_data_loaded && face->root.internal->incremental_interface )
- {
- face->root.internal->incremental_interface->funcs->free_glyph_data(
- face->root.internal->incremental_interface->object,
- &glyph_data );
-
- /* Set the control data to null - it is no longer available if */
- /* loaded incrementally. */
- t1glyph->control_data = NULL;
- t1glyph->control_len = 0;
- }
-#endif
-
- if ( must_finish_decoder )
- decoder_funcs->done( &decoder );
-
- return error;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/type1/t1gload.h b/contrib/libs/freetype/src/type1/t1gload.h
deleted file mode 100644
index 17a6a5941e..0000000000
--- a/contrib/libs/freetype/src/type1/t1gload.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/****************************************************************************
- *
- * t1gload.h
- *
- * Type 1 Glyph Loader (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef T1GLOAD_H_
-#define T1GLOAD_H_
-
-
-#include "t1objs.h"
-
-
-FT_BEGIN_HEADER
-
-
- FT_LOCAL( FT_Error )
- T1_Compute_Max_Advance( T1_Face face,
- FT_Pos* max_advance );
-
- FT_LOCAL( FT_Error )
- T1_Get_Advances( FT_Face face,
- FT_UInt first,
- FT_UInt count,
- FT_Int32 load_flags,
- FT_Fixed* advances );
-
- FT_LOCAL( FT_Error )
- T1_Load_Glyph( FT_GlyphSlot glyph,
- FT_Size size,
- FT_UInt glyph_index,
- FT_Int32 load_flags );
-
-
-FT_END_HEADER
-
-#endif /* T1GLOAD_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/type1/t1load.c b/contrib/libs/freetype/src/type1/t1load.c
deleted file mode 100644
index ee7fb42a51..0000000000
--- a/contrib/libs/freetype/src/type1/t1load.c
+++ /dev/null
@@ -1,2755 +0,0 @@
-/****************************************************************************
- *
- * t1load.c
- *
- * Type 1 font loader (body).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /**************************************************************************
- *
- * This is the new and improved Type 1 data loader for FreeType 2. The
- * old loader has several problems: it is slow, complex, difficult to
- * maintain, and contains incredible hacks to make it accept some
- * ill-formed Type 1 fonts without hiccup-ing. Moreover, about 5% of
- * the Type 1 fonts on my machine still aren't loaded correctly by it.
- *
- * This version is much simpler, much faster and also easier to read and
- * maintain by a great order of magnitude. The idea behind it is to
- * _not_ try to read the Type 1 token stream with a state machine (i.e.
- * a Postscript-like interpreter) but rather to perform simple pattern
- * matching.
- *
- * Indeed, nearly all data definitions follow a simple pattern like
- *
- * ... /Field <data> ...
- *
- * where <data> can be a number, a boolean, a string, or an array of
- * numbers. There are a few exceptions, namely the encoding, font name,
- * charstrings, and subrs; they are handled with a special pattern
- * matching routine.
- *
- * All other common cases are handled very simply. The matching rules
- * are defined in the file `t1tokens.h' through the use of several
- * macros calls PARSE_XXX. This file is included twice here; the first
- * time to generate parsing callback functions, the second time to
- * generate a table of keywords (with pointers to the associated
- * callback functions).
- *
- * The function `parse_dict' simply scans *linearly* a given dictionary
- * (either the top-level or private one) and calls the appropriate
- * callback when it encounters an immediate keyword.
- *
- * This is by far the fastest way one can find to parse and read all
- * data.
- *
- * This led to tremendous code size reduction. Note that later, the
- * glyph loader will also be _greatly_ simplified, and the automatic
- * hinter will replace the clumsy `t1hinter'.
- *
- */
-
-
-#include <ft2build.h>
-#include <freetype/internal/ftdebug.h>
-#include FT_CONFIG_CONFIG_H
-#include <freetype/ftmm.h>
-#include <freetype/internal/t1types.h>
-#include <freetype/internal/ftcalc.h>
-#include <freetype/internal/fthash.h>
-
-#include "t1load.h"
-#include "t1errors.h"
-
-
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
-#define IS_INCREMENTAL \
- FT_BOOL( FT_FACE( face )->internal->incremental_interface )
-#else
-#define IS_INCREMENTAL 0
-#endif
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT t1load
-
-
-#ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** MULTIPLE MASTERS SUPPORT *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- static FT_Error
- t1_allocate_blend( T1_Face face,
- FT_UInt num_designs,
- FT_UInt num_axis )
- {
- PS_Blend blend;
- FT_Memory memory = face->root.memory;
- FT_Error error = FT_Err_Ok;
-
-
- blend = face->blend;
- if ( !blend )
- {
- if ( FT_NEW( blend ) )
- goto Exit;
-
- blend->num_default_design_vector = 0;
- blend->weight_vector = NULL;
- blend->default_weight_vector = NULL;
- blend->design_pos[0] = NULL;
-
- face->blend = blend;
- }
-
- /* allocate design data if needed */
- if ( num_designs > 0 )
- {
- if ( blend->num_designs == 0 )
- {
- FT_UInt nn;
-
-
- /* allocate the blend `private' and `font_info' dictionaries */
- if ( FT_NEW_ARRAY( blend->font_infos[1], num_designs ) ||
- FT_NEW_ARRAY( blend->privates [1], num_designs ) ||
- FT_NEW_ARRAY( blend->bboxes [1], num_designs ) )
- goto Exit;
-
- blend->font_infos[0] = &face->type1.font_info;
- blend->privates [0] = &face->type1.private_dict;
- blend->bboxes [0] = &face->type1.font_bbox;
-
- for ( nn = 2; nn <= num_designs; nn++ )
- {
- blend->font_infos[nn] = blend->font_infos[nn - 1] + 1;
- blend->privates [nn] = blend->privates [nn - 1] + 1;
- blend->bboxes [nn] = blend->bboxes [nn - 1] + 1;
- }
-
- blend->num_designs = num_designs;
- }
- else if ( blend->num_designs != num_designs )
- goto Fail;
- }
-
- /* allocate axis data if needed */
- if ( num_axis > 0 )
- {
- if ( blend->num_axis != 0 && blend->num_axis != num_axis )
- goto Fail;
-
- blend->num_axis = num_axis;
- }
-
- Exit:
- return error;
-
- Fail:
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- T1_Get_Multi_Master( FT_Face face, /* T1_Face */
- FT_Multi_Master* master )
- {
- T1_Face t1face = (T1_Face)face;
- PS_Blend blend = t1face->blend;
- FT_UInt n;
- FT_Error error;
-
-
- error = FT_THROW( Invalid_Argument );
-
- if ( blend )
- {
- master->num_axis = blend->num_axis;
- master->num_designs = blend->num_designs;
-
- for ( n = 0; n < blend->num_axis; n++ )
- {
- FT_MM_Axis* axis = master->axis + n;
- PS_DesignMap map = blend->design_map + n;
-
-
- axis->name = blend->axis_names[n];
- axis->minimum = map->design_points[0];
- axis->maximum = map->design_points[map->num_points - 1];
- }
-
- error = FT_Err_Ok;
- }
-
- return error;
- }
-
-
- /**************************************************************************
- *
- * Given a normalized (blend) coordinate, figure out the design
- * coordinate appropriate for that value.
- */
- static FT_Fixed
- mm_axis_unmap( PS_DesignMap axismap,
- FT_Fixed ncv )
- {
- int j;
-
-
- if ( ncv <= axismap->blend_points[0] )
- return INT_TO_FIXED( axismap->design_points[0] );
-
- for ( j = 1; j < axismap->num_points; j++ )
- {
- if ( ncv <= axismap->blend_points[j] )
- return INT_TO_FIXED( axismap->design_points[j - 1] +
- FT_MulDiv( ncv - axismap->blend_points[j - 1],
- axismap->design_points[j] -
- axismap->design_points[j - 1],
- axismap->blend_points[j] -
- axismap->blend_points[j - 1] ) );
- }
-
- return INT_TO_FIXED( axismap->design_points[axismap->num_points - 1] );
- }
-
-
- /**************************************************************************
- *
- * Given a vector of weights, one for each design, figure out the
- * normalized axis coordinates which gave rise to those weights.
- */
- static void
- mm_weights_unmap( FT_Fixed* weights,
- FT_Fixed* axiscoords,
- FT_UInt axis_count )
- {
- FT_ASSERT( axis_count <= T1_MAX_MM_AXIS );
-
- if ( axis_count == 1 )
- axiscoords[0] = weights[1];
-
- else if ( axis_count == 2 )
- {
- axiscoords[0] = weights[3] + weights[1];
- axiscoords[1] = weights[3] + weights[2];
- }
-
- else if ( axis_count == 3 )
- {
- axiscoords[0] = weights[7] + weights[5] + weights[3] + weights[1];
- axiscoords[1] = weights[7] + weights[6] + weights[3] + weights[2];
- axiscoords[2] = weights[7] + weights[6] + weights[5] + weights[4];
- }
-
- else
- {
- axiscoords[0] = weights[15] + weights[13] + weights[11] + weights[9] +
- weights[7] + weights[5] + weights[3] + weights[1];
- axiscoords[1] = weights[15] + weights[14] + weights[11] + weights[10] +
- weights[7] + weights[6] + weights[3] + weights[2];
- axiscoords[2] = weights[15] + weights[14] + weights[13] + weights[12] +
- weights[7] + weights[6] + weights[5] + weights[4];
- axiscoords[3] = weights[15] + weights[14] + weights[13] + weights[12] +
- weights[11] + weights[10] + weights[9] + weights[8];
- }
- }
-
-
- /**************************************************************************
- *
- * Just a wrapper around T1_Get_Multi_Master to support the different
- * arguments needed by the GX var distortable fonts.
- */
- FT_LOCAL_DEF( FT_Error )
- T1_Get_MM_Var( FT_Face face, /* T1_Face */
- FT_MM_Var* *master )
- {
- T1_Face t1face = (T1_Face)face;
- FT_Memory memory = FT_FACE_MEMORY( face );
- FT_MM_Var *mmvar = NULL;
- FT_Multi_Master mmaster;
- FT_Error error;
- FT_UInt i;
- FT_Fixed axiscoords[T1_MAX_MM_AXIS];
- PS_Blend blend = t1face->blend;
- FT_UShort* axis_flags;
-
- FT_Offset mmvar_size;
- FT_Offset axis_flags_size;
- FT_Offset axis_size;
-
-
- error = T1_Get_Multi_Master( face, &mmaster );
- if ( error )
- goto Exit;
-
- /* the various `*_size' variables, which we also use as */
- /* offsets into the `mmvar' array, must be multiples of the */
- /* pointer size (except the last one); without such an */
- /* alignment there might be runtime errors due to */
- /* misaligned addresses */
-#undef ALIGN_SIZE
-#define ALIGN_SIZE( n ) \
- ( ( (n) + sizeof (void*) - 1 ) & ~( sizeof (void*) - 1 ) )
-
- mmvar_size = ALIGN_SIZE( sizeof ( FT_MM_Var ) );
- axis_flags_size = ALIGN_SIZE( mmaster.num_axis *
- sizeof ( FT_UShort ) );
- axis_size = mmaster.num_axis * sizeof ( FT_Var_Axis );
-
- if ( FT_QALLOC( mmvar, mmvar_size +
- axis_flags_size +
- axis_size ) )
- goto Exit;
-
- mmvar->num_axis = mmaster.num_axis;
- mmvar->num_designs = mmaster.num_designs;
- mmvar->num_namedstyles = 0; /* Not supported */
-
- /* while axis flags are meaningless here, we have to provide the array */
- /* to make `FT_Get_Var_Axis_Flags' work: the function expects that the */
- /* values directly follow the data of `FT_MM_Var' */
- axis_flags = (FT_UShort*)( (char*)mmvar + mmvar_size );
- FT_ARRAY_ZERO( axis_flags, mmaster.num_axis );
-
- mmvar->axis = (FT_Var_Axis*)( (char*)axis_flags + axis_flags_size );
- mmvar->namedstyle = NULL;
-
- for ( i = 0; i < mmaster.num_axis; i++ )
- {
- mmvar->axis[i].name = mmaster.axis[i].name;
- mmvar->axis[i].minimum = INT_TO_FIXED( mmaster.axis[i].minimum );
- mmvar->axis[i].maximum = INT_TO_FIXED( mmaster.axis[i].maximum );
- mmvar->axis[i].strid = ~0U; /* Does not apply */
- mmvar->axis[i].tag = ~0U; /* Does not apply */
-
- if ( !mmvar->axis[i].name )
- continue;
-
- if ( ft_strcmp( mmvar->axis[i].name, "Weight" ) == 0 )
- mmvar->axis[i].tag = FT_MAKE_TAG( 'w', 'g', 'h', 't' );
- else if ( ft_strcmp( mmvar->axis[i].name, "Width" ) == 0 )
- mmvar->axis[i].tag = FT_MAKE_TAG( 'w', 'd', 't', 'h' );
- else if ( ft_strcmp( mmvar->axis[i].name, "OpticalSize" ) == 0 )
- mmvar->axis[i].tag = FT_MAKE_TAG( 'o', 'p', 's', 'z' );
- else if ( ft_strcmp( mmvar->axis[i].name, "Slant" ) == 0 )
- mmvar->axis[i].tag = FT_MAKE_TAG( 's', 'l', 'n', 't' );
- else if ( ft_strcmp( mmvar->axis[i].name, "Italic" ) == 0 )
- mmvar->axis[i].tag = FT_MAKE_TAG( 'i', 't', 'a', 'l' );
- }
-
- mm_weights_unmap( blend->default_weight_vector,
- axiscoords,
- blend->num_axis );
-
- for ( i = 0; i < mmaster.num_axis; i++ )
- mmvar->axis[i].def = mm_axis_unmap( &blend->design_map[i],
- axiscoords[i] );
-
- *master = mmvar;
-
- Exit:
- return error;
- }
-
-
- static FT_Error
- t1_set_mm_blend( T1_Face face,
- FT_UInt num_coords,
- FT_Fixed* coords )
- {
- PS_Blend blend = face->blend;
- FT_UInt n, m;
-
- FT_Bool have_diff = 0;
-
-
- if ( !blend )
- return FT_THROW( Invalid_Argument );
-
- if ( num_coords > blend->num_axis )
- num_coords = blend->num_axis;
-
- /* recompute the weight vector from the blend coordinates */
- for ( n = 0; n < blend->num_designs; n++ )
- {
- FT_Fixed result = 0x10000L; /* 1.0 fixed */
- FT_Fixed factor;
-
-
- for ( m = 0; m < blend->num_axis; m++ )
- {
- /* use a default value if we don't have a coordinate */
- if ( m >= num_coords )
- {
- result >>= 1;
- continue;
- }
-
- /* get current blend axis position */
- factor = coords[m];
- if ( ( n & ( 1 << m ) ) == 0 )
- factor = 0x10000L - factor;
-
- if ( factor <= 0 )
- {
- result = 0;
- break;
- }
- else if ( factor >= 0x10000L )
- continue;
-
- result = FT_MulFix( result, factor );
- }
-
- if ( blend->weight_vector[n] != result )
- {
- blend->weight_vector[n] = result;
- have_diff = 1;
- }
- }
-
- /* return value -1 indicates `no change' */
- return have_diff ? FT_Err_Ok : -1;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- T1_Set_MM_Blend( FT_Face face, /* T1_Face */
- FT_UInt num_coords,
- FT_Fixed* coords )
- {
- return t1_set_mm_blend( (T1_Face)face, num_coords, coords );
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- T1_Get_MM_Blend( FT_Face face, /* T1_Face */
- FT_UInt num_coords,
- FT_Fixed* coords )
- {
- T1_Face t1face = (T1_Face)face;
- PS_Blend blend = t1face->blend;
-
- FT_Fixed axiscoords[4];
- FT_UInt i, nc;
-
-
- if ( !blend )
- return FT_THROW( Invalid_Argument );
-
- mm_weights_unmap( blend->weight_vector,
- axiscoords,
- blend->num_axis );
-
- nc = num_coords;
- if ( num_coords > blend->num_axis )
- {
- FT_TRACE2(( "T1_Get_MM_Blend: only using first %d of %d coordinates\n",
- blend->num_axis, num_coords ));
- nc = blend->num_axis;
- }
-
- for ( i = 0; i < nc; i++ )
- coords[i] = axiscoords[i];
- for ( ; i < num_coords; i++ )
- coords[i] = 0x8000;
-
- return FT_Err_Ok;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- T1_Set_MM_WeightVector( FT_Face face, /* T1_Face */
- FT_UInt len,
- FT_Fixed* weightvector )
- {
- T1_Face t1face = (T1_Face)face;
- PS_Blend blend = t1face->blend;
- FT_UInt i, n;
-
-
- if ( !blend )
- return FT_THROW( Invalid_Argument );
-
- if ( !len && !weightvector )
- {
- for ( i = 0; i < blend->num_designs; i++ )
- blend->weight_vector[i] = blend->default_weight_vector[i];
- }
- else
- {
- if ( !weightvector )
- return FT_THROW( Invalid_Argument );
-
- n = len < blend->num_designs ? len : blend->num_designs;
-
- for ( i = 0; i < n; i++ )
- blend->weight_vector[i] = weightvector[i];
-
- for ( ; i < blend->num_designs; i++ )
- blend->weight_vector[i] = (FT_Fixed)0;
- }
-
- return FT_Err_Ok;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- T1_Get_MM_WeightVector( FT_Face face, /* T1_Face */
- FT_UInt* len,
- FT_Fixed* weightvector )
- {
- T1_Face t1face = (T1_Face)face;
- PS_Blend blend = t1face->blend;
- FT_UInt i;
-
-
- if ( !blend )
- return FT_THROW( Invalid_Argument );
-
- if ( *len < blend->num_designs )
- {
- *len = blend->num_designs;
- return FT_THROW( Invalid_Argument );
- }
-
- for ( i = 0; i < blend->num_designs; i++ )
- weightvector[i] = blend->weight_vector[i];
- for ( ; i < *len; i++ )
- weightvector[i] = (FT_Fixed)0;
-
- *len = blend->num_designs;
-
- return FT_Err_Ok;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- T1_Set_MM_Design( FT_Face face, /* T1_Face */
- FT_UInt num_coords,
- FT_Long* coords )
- {
- T1_Face t1face = (T1_Face)face;
- FT_Error error;
- PS_Blend blend = t1face->blend;
- FT_UInt n;
- FT_Fixed final_blends[T1_MAX_MM_DESIGNS];
-
-
- if ( !blend )
- return FT_THROW( Invalid_Argument );
-
- if ( num_coords > blend->num_axis )
- num_coords = blend->num_axis;
-
- /* compute the blend coordinates through the blend design map */
-
- for ( n = 0; n < blend->num_axis; n++ )
- {
- FT_Long design;
- FT_Fixed the_blend;
- PS_DesignMap map = blend->design_map + n;
- FT_Long* designs = map->design_points;
- FT_Fixed* blends = map->blend_points;
- FT_Int p, before = -1, after = -1;
-
-
- /* use a default value if we don't have a coordinate */
- if ( n < num_coords )
- design = coords[n];
- else
- design = ( designs[map->num_points - 1] - designs[0] ) / 2;
-
- for ( p = 0; p < (FT_Int)map->num_points; p++ )
- {
- FT_Long p_design = designs[p];
-
-
- /* exact match? */
- if ( design == p_design )
- {
- the_blend = blends[p];
- goto Found;
- }
-
- if ( design < p_design )
- {
- after = p;
- break;
- }
-
- before = p;
- }
-
- /* now interpolate if necessary */
- if ( before < 0 )
- the_blend = blends[0];
-
- else if ( after < 0 )
- the_blend = blends[map->num_points - 1];
-
- else
- the_blend = FT_MulDiv( design - designs[before],
- blends [after] - blends [before],
- designs[after] - designs[before] );
-
- Found:
- final_blends[n] = the_blend;
- }
-
- error = t1_set_mm_blend( t1face, blend->num_axis, final_blends );
- if ( error )
- return error;
-
- return FT_Err_Ok;
- }
-
-
- /* MM fonts don't have named instances, so only the design is reset */
-
- FT_LOCAL_DEF( FT_Error )
- T1_Reset_MM_Blend( FT_Face face,
- FT_UInt instance_index )
- {
- FT_UNUSED( instance_index );
-
- return T1_Set_MM_Blend( face, 0, NULL );
- }
-
-
- /**************************************************************************
- *
- * Just a wrapper around T1_Set_MM_Design to support the different
- * arguments needed by the GX var distortable fonts.
- */
- FT_LOCAL_DEF( FT_Error )
- T1_Set_Var_Design( FT_Face face, /* T1_Face */
- FT_UInt num_coords,
- FT_Fixed* coords )
- {
- FT_Long lcoords[T1_MAX_MM_AXIS];
- FT_UInt i;
-
-
- if ( num_coords > T1_MAX_MM_AXIS )
- num_coords = T1_MAX_MM_AXIS;
-
- for ( i = 0; i < num_coords; i++ )
- lcoords[i] = FIXED_TO_INT( coords[i] );
-
- return T1_Set_MM_Design( face, num_coords, lcoords );
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- T1_Get_Var_Design( FT_Face face, /* T1_Face */
- FT_UInt num_coords,
- FT_Fixed* coords )
- {
- T1_Face t1face = (T1_Face)face;
- PS_Blend blend = t1face->blend;
-
- FT_Fixed axiscoords[4];
- FT_UInt i, nc;
-
-
- if ( !blend )
- return FT_THROW( Invalid_Argument );
-
- mm_weights_unmap( blend->weight_vector,
- axiscoords,
- blend->num_axis );
-
- nc = num_coords;
- if ( num_coords > blend->num_axis )
- {
- FT_TRACE2(( "T1_Get_Var_Design:"
- " only using first %d of %d coordinates\n",
- blend->num_axis, num_coords ));
- nc = blend->num_axis;
- }
-
- for ( i = 0; i < nc; i++ )
- coords[i] = mm_axis_unmap( &blend->design_map[i], axiscoords[i] );
- for ( ; i < num_coords; i++ )
- coords[i] = 0;
-
- return FT_Err_Ok;
- }
-
-
- FT_LOCAL_DEF( void )
- T1_Done_Blend( FT_Face face ) /* T1_Face */
- {
- T1_Face t1face = (T1_Face)face;
- FT_Memory memory = FT_FACE_MEMORY( face );
- PS_Blend blend = t1face->blend;
-
-
- if ( blend )
- {
- FT_UInt num_designs = blend->num_designs;
- FT_UInt num_axis = blend->num_axis;
- FT_UInt n;
-
-
- /* release design pos table */
- FT_FREE( blend->design_pos[0] );
- for ( n = 1; n < num_designs; n++ )
- blend->design_pos[n] = NULL;
-
- /* release blend `private' and `font info' dictionaries */
- FT_FREE( blend->privates[1] );
- FT_FREE( blend->font_infos[1] );
- FT_FREE( blend->bboxes[1] );
-
- for ( n = 0; n < num_designs; n++ )
- {
- blend->privates [n] = NULL;
- blend->font_infos[n] = NULL;
- blend->bboxes [n] = NULL;
- }
-
- /* release weight vectors */
- FT_FREE( blend->weight_vector );
- blend->default_weight_vector = NULL;
-
- /* release axis names */
- for ( n = 0; n < num_axis; n++ )
- FT_FREE( blend->axis_names[n] );
-
- /* release design map */
- for ( n = 0; n < num_axis; n++ )
- {
- PS_DesignMap dmap = blend->design_map + n;
-
-
- FT_FREE( dmap->blend_points );
- FT_FREE( dmap->design_points );
- dmap->num_points = 0;
- }
-
- FT_FREE( t1face->blend );
- }
- }
-
-
- static void
- parse_blend_axis_types( FT_Face face, /* T1_Face */
- void* loader_ )
- {
- T1_Face t1face = (T1_Face)face;
- T1_Loader loader = (T1_Loader)loader_;
- T1_TokenRec axis_tokens[T1_MAX_MM_AXIS];
- FT_Int n, num_axis;
- FT_Error error = FT_Err_Ok;
- PS_Blend blend;
- FT_Memory memory = FT_FACE_MEMORY( face );
-
-
- /* take an array of objects */
- T1_ToTokenArray( &loader->parser, axis_tokens,
- T1_MAX_MM_AXIS, &num_axis );
- if ( num_axis < 0 )
- {
- error = FT_ERR( Ignore );
- goto Exit;
- }
- if ( num_axis == 0 || num_axis > T1_MAX_MM_AXIS )
- {
- FT_ERROR(( "parse_blend_axis_types: incorrect number of axes: %d\n",
- num_axis ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- /* allocate blend if necessary */
- error = t1_allocate_blend( t1face, 0, (FT_UInt)num_axis );
- if ( error )
- goto Exit;
-
- FT_TRACE4(( " [" ));
-
- blend = t1face->blend;
-
- /* each token is an immediate containing the name of the axis */
- for ( n = 0; n < num_axis; n++ )
- {
- T1_Token token = axis_tokens + n;
- FT_Byte* name;
- FT_UInt len;
-
-
- /* skip first slash, if any */
- if ( token->start[0] == '/' )
- token->start++;
-
- len = (FT_UInt)( token->limit - token->start );
- if ( len == 0 )
- {
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- FT_TRACE4(( " /%.*s", len, token->start ));
-
- name = (FT_Byte*)blend->axis_names[n];
- if ( name )
- {
- FT_TRACE0(( "parse_blend_axis_types:"
- " overwriting axis name `%s' with `%.*s'\n",
- name, len, token->start ));
- FT_FREE( name );
- }
-
- if ( FT_QALLOC( blend->axis_names[n], len + 1 ) )
- goto Exit;
-
- name = (FT_Byte*)blend->axis_names[n];
- FT_MEM_COPY( name, token->start, len );
- name[len] = '\0';
- }
-
- FT_TRACE4(( "]\n" ));
-
- Exit:
- loader->parser.root.error = error;
- }
-
-
- static void
- parse_blend_design_positions( FT_Face face, /* T1_Face */
- void* loader_ )
- {
- T1_Face t1face = (T1_Face)face;
- T1_Loader loader = (T1_Loader)loader_;
- T1_TokenRec design_tokens[T1_MAX_MM_DESIGNS];
- FT_Int num_designs;
- FT_Int num_axis = 0; /* make compiler happy */
- T1_Parser parser = &loader->parser;
- FT_Memory memory = FT_FACE_MEMORY( face );
- FT_Error error = FT_Err_Ok;
- FT_Fixed* design_pos[T1_MAX_MM_DESIGNS];
-
-
- design_pos[0] = NULL;
-
- /* get the array of design tokens -- compute number of designs */
- T1_ToTokenArray( parser, design_tokens,
- T1_MAX_MM_DESIGNS, &num_designs );
- if ( num_designs < 0 )
- {
- error = FT_ERR( Ignore );
- goto Exit;
- }
- if ( num_designs == 0 || num_designs > T1_MAX_MM_DESIGNS )
- {
- FT_ERROR(( "parse_blend_design_positions:"
- " incorrect number of designs: %d\n",
- num_designs ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- {
- FT_Byte* old_cursor = parser->root.cursor;
- FT_Byte* old_limit = parser->root.limit;
- FT_Int n, nn;
- PS_Blend blend;
-
-
- FT_TRACE4(( " [" ));
-
- for ( n = 0; n < num_designs; n++ )
- {
- T1_TokenRec axis_tokens[T1_MAX_MM_AXIS];
- T1_Token token;
- FT_Int axis, n_axis;
-
-
- /* read axis/coordinates tokens */
- token = design_tokens + n;
- parser->root.cursor = token->start;
- parser->root.limit = token->limit;
- T1_ToTokenArray( parser, axis_tokens, T1_MAX_MM_AXIS, &n_axis );
-
- if ( n == 0 )
- {
- if ( n_axis <= 0 || n_axis > T1_MAX_MM_AXIS )
- {
- FT_ERROR(( "parse_blend_design_positions:"
- " invalid number of axes: %d\n",
- n_axis ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- num_axis = n_axis;
- error = t1_allocate_blend( t1face,
- (FT_UInt)num_designs,
- (FT_UInt)num_axis );
- if ( error )
- goto Exit;
-
- /* allocate a blend design pos table */
- if ( FT_QNEW_ARRAY( design_pos[0], num_designs * num_axis ) )
- goto Exit;
-
- for ( nn = 1; nn < num_designs; nn++ )
- design_pos[nn] = design_pos[0] + num_axis * nn;
- }
- else if ( n_axis != num_axis )
- {
- FT_ERROR(( "parse_blend_design_positions: incorrect table\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- /* now read each axis token into the design position */
- FT_TRACE4(( " [" )) ;
- for ( axis = 0; axis < n_axis; axis++ )
- {
- T1_Token token2 = axis_tokens + axis;
-
-
- parser->root.cursor = token2->start;
- parser->root.limit = token2->limit;
- design_pos[n][axis] = T1_ToFixed( parser, 0 );
- FT_TRACE4(( " %f", (double)design_pos[n][axis] / 65536 ));
- }
- FT_TRACE4(( "]" )) ;
- }
-
- FT_TRACE4(( "]\n" ));
-
- loader->parser.root.cursor = old_cursor;
- loader->parser.root.limit = old_limit;
-
- /* a valid BlendDesignPosition has been parsed */
- blend = t1face->blend;
- if ( blend->design_pos[0] )
- FT_FREE( blend->design_pos[0] );
-
- for ( n = 0; n < num_designs; n++ )
- {
- blend->design_pos[n] = design_pos[n];
- design_pos[n] = NULL;
- }
- }
-
- Exit:
- FT_FREE( design_pos[0] );
- loader->parser.root.error = error;
- }
-
-
- static void
- parse_blend_design_map( FT_Face face, /* T1_Face */
- void* loader_ )
- {
- T1_Face t1face = (T1_Face)face;
- T1_Loader loader = (T1_Loader)loader_;
- FT_Error error = FT_Err_Ok;
- T1_Parser parser = &loader->parser;
- PS_Blend blend;
- T1_TokenRec axis_tokens[T1_MAX_MM_AXIS];
- FT_Int n, num_axis;
- FT_Byte* old_cursor;
- FT_Byte* old_limit;
- FT_Memory memory = FT_FACE_MEMORY( face );
-
-
- T1_ToTokenArray( parser, axis_tokens,
- T1_MAX_MM_AXIS, &num_axis );
- if ( num_axis < 0 )
- {
- error = FT_ERR( Ignore );
- goto Exit;
- }
- if ( num_axis == 0 || num_axis > T1_MAX_MM_AXIS )
- {
- FT_ERROR(( "parse_blend_design_map: incorrect number of axes: %d\n",
- num_axis ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- old_cursor = parser->root.cursor;
- old_limit = parser->root.limit;
-
- error = t1_allocate_blend( t1face, 0, (FT_UInt)num_axis );
- if ( error )
- goto Exit;
- blend = t1face->blend;
-
- FT_TRACE4(( " [" ));
-
- /* now read each axis design map */
- for ( n = 0; n < num_axis; n++ )
- {
- PS_DesignMap map = blend->design_map + n;
- T1_Token axis_token;
- T1_TokenRec point_tokens[T1_MAX_MM_MAP_POINTS];
- FT_Int p, num_points;
-
-
- axis_token = axis_tokens + n;
-
- parser->root.cursor = axis_token->start;
- parser->root.limit = axis_token->limit;
- T1_ToTokenArray( parser, point_tokens,
- T1_MAX_MM_MAP_POINTS, &num_points );
-
- FT_TRACE4(( " [" ));
-
- if ( num_points <= 0 || num_points > T1_MAX_MM_MAP_POINTS )
- {
- FT_ERROR(( "parse_blend_design_map: incorrect table\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- if ( map->design_points )
- {
- FT_ERROR(( "parse_blend_design_map: duplicate table\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- /* allocate design map data */
- if ( FT_QNEW_ARRAY( map->design_points, num_points ) ||
- FT_QNEW_ARRAY( map->blend_points, num_points ) )
- goto Exit;
- map->num_points = (FT_Byte)num_points;
-
- for ( p = 0; p < num_points; p++ )
- {
- T1_Token point_token;
-
-
- point_token = point_tokens + p;
-
- /* don't include delimiting brackets */
- parser->root.cursor = point_token->start + 1;
- parser->root.limit = point_token->limit - 1;
-
- map->design_points[p] = T1_ToInt( parser );
- map->blend_points [p] = T1_ToFixed( parser, 0 );
-
- FT_TRACE4(( " [%ld %f]",
- map->design_points[p],
- (double)map->blend_points[p] / 65536 ));
- }
-
- FT_TRACE4(( "]" ));
- }
-
- FT_TRACE4(( "]\n" ));
-
- parser->root.cursor = old_cursor;
- parser->root.limit = old_limit;
-
- Exit:
- parser->root.error = error;
- }
-
-
- static void
- parse_weight_vector( FT_Face face, /* T1_Face */
- void* loader_ )
- {
- T1_Face t1face = (T1_Face)face;
- T1_Loader loader = (T1_Loader)loader_;
- T1_TokenRec design_tokens[T1_MAX_MM_DESIGNS];
- FT_Int num_designs;
- FT_Error error = FT_Err_Ok;
- FT_Memory memory = FT_FACE_MEMORY( face );
- T1_Parser parser = &loader->parser;
- PS_Blend blend = t1face->blend;
- T1_Token token;
- FT_Int n;
- FT_Byte* old_cursor;
- FT_Byte* old_limit;
-
-
- T1_ToTokenArray( parser, design_tokens,
- T1_MAX_MM_DESIGNS, &num_designs );
- if ( num_designs < 0 )
- {
- error = FT_ERR( Ignore );
- goto Exit;
- }
- if ( num_designs == 0 || num_designs > T1_MAX_MM_DESIGNS )
- {
- FT_ERROR(( "parse_weight_vector:"
- " incorrect number of designs: %d\n",
- num_designs ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- if ( !blend || !blend->num_designs )
- {
- error = t1_allocate_blend( t1face, (FT_UInt)num_designs, 0 );
- if ( error )
- goto Exit;
- blend = t1face->blend;
- }
- else if ( blend->num_designs != (FT_UInt)num_designs )
- {
- FT_ERROR(( "parse_weight_vector:"
- " /BlendDesignPosition and /WeightVector have\n" ));
- FT_ERROR(( " "
- " different number of elements\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- if ( !blend->weight_vector )
- if ( FT_QNEW_ARRAY( blend->weight_vector, num_designs * 2 ) )
- goto Exit;
-
- blend->default_weight_vector = blend->weight_vector + num_designs;
-
- old_cursor = parser->root.cursor;
- old_limit = parser->root.limit;
-
- FT_TRACE4(( "[" ));
-
- for ( n = 0; n < num_designs; n++ )
- {
- token = design_tokens + n;
- parser->root.cursor = token->start;
- parser->root.limit = token->limit;
-
- blend->default_weight_vector[n] =
- blend->weight_vector[n] = T1_ToFixed( parser, 0 );
-
- FT_TRACE4(( " %f", (double)blend->weight_vector[n] / 65536 ));
- }
-
- FT_TRACE4(( "]\n" ));
-
- parser->root.cursor = old_cursor;
- parser->root.limit = old_limit;
-
- Exit:
- parser->root.error = error;
- }
-
-
- /* e.g., /BuildCharArray [0 0 0 0 0 0 0 0] def */
- /* we're only interested in the number of array elements */
- static void
- parse_buildchar( FT_Face face, /* T1_Face */
- void* loader_ )
- {
- T1_Face t1face = (T1_Face)face;
- T1_Loader loader = (T1_Loader)loader_;
-
-
- t1face->len_buildchar = (FT_UInt)T1_ToFixedArray( &loader->parser,
- 0, NULL, 0 );
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- {
- FT_UInt i;
-
-
- FT_TRACE4(( " [" ));
- for ( i = 0; i < t1face->len_buildchar; i++ )
- FT_TRACE4(( " 0" ));
-
- FT_TRACE4(( "]\n" ));
- }
-#endif
-
- return;
- }
-
-
-#endif /* !T1_CONFIG_OPTION_NO_MM_SUPPORT */
-
-
-
-
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** TYPE 1 SYMBOL PARSING *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- static FT_Error
- t1_load_keyword( T1_Face face,
- T1_Loader loader,
- const T1_Field field )
- {
- FT_Error error;
- void* dummy_object;
- void** objects;
- FT_UInt max_objects;
- PS_Blend blend = face->blend;
-
-
- if ( blend && blend->num_designs == 0 )
- blend = NULL;
-
- /* if the keyword has a dedicated callback, call it */
- if ( field->type == T1_FIELD_TYPE_CALLBACK )
- {
- FT_TRACE4(( " %s", field->ident ));
-
- field->reader( (FT_Face)face, loader );
- error = loader->parser.root.error;
- goto Exit;
- }
-
- /* now, the keyword is either a simple field, or a table of fields; */
- /* we are now going to take care of it */
- switch ( field->location )
- {
- case T1_FIELD_LOCATION_FONT_INFO:
- dummy_object = &face->type1.font_info;
- objects = &dummy_object;
- max_objects = 0;
-
- if ( blend )
- {
- objects = (void**)blend->font_infos;
- max_objects = blend->num_designs;
- }
- break;
-
- case T1_FIELD_LOCATION_FONT_EXTRA:
- dummy_object = &face->type1.font_extra;
- objects = &dummy_object;
- max_objects = 0;
- break;
-
- case T1_FIELD_LOCATION_PRIVATE:
- dummy_object = &face->type1.private_dict;
- objects = &dummy_object;
- max_objects = 0;
-
- if ( blend )
- {
- objects = (void**)blend->privates;
- max_objects = blend->num_designs;
- }
- break;
-
- case T1_FIELD_LOCATION_BBOX:
- dummy_object = &face->type1.font_bbox;
- objects = &dummy_object;
- max_objects = 0;
-
- if ( blend )
- {
- objects = (void**)blend->bboxes;
- max_objects = blend->num_designs;
- }
- break;
-
- case T1_FIELD_LOCATION_LOADER:
- dummy_object = loader;
- objects = &dummy_object;
- max_objects = 0;
- break;
-
- case T1_FIELD_LOCATION_FACE:
- dummy_object = face;
- objects = &dummy_object;
- max_objects = 0;
- break;
-
-#ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT
- case T1_FIELD_LOCATION_BLEND:
- dummy_object = face->blend;
- objects = &dummy_object;
- max_objects = 0;
- break;
-#endif
-
- default:
- dummy_object = &face->type1;
- objects = &dummy_object;
- max_objects = 0;
- }
-
- FT_TRACE4(( " %s", field->ident ));
-
- if ( *objects )
- {
- if ( field->type == T1_FIELD_TYPE_INTEGER_ARRAY ||
- field->type == T1_FIELD_TYPE_FIXED_ARRAY )
- error = T1_Load_Field_Table( &loader->parser, field,
- objects, max_objects, 0 );
- else
- error = T1_Load_Field( &loader->parser, field,
- objects, max_objects, 0 );
- }
- else
- {
- FT_TRACE1(( "t1_load_keyword: ignoring keyword `%s'"
- " which is not valid at this point\n",
- field->ident ));
- FT_TRACE1(( " (probably due to missing keywords)\n" ));
- error = FT_Err_Ok;
- }
-
- FT_TRACE4(( "\n" ));
-
- Exit:
- return error;
- }
-
-
- static void
- parse_private( FT_Face face,
- void* loader_ )
- {
- T1_Loader loader = (T1_Loader)loader_;
- FT_UNUSED( face );
-
- loader->keywords_encountered |= T1_PRIVATE;
-
- FT_TRACE4(( "\n" ));
- }
-
-
- /* return 1 in case of success */
-
- static int
- read_binary_data( T1_Parser parser,
- FT_ULong* size,
- FT_Byte** base,
- FT_Bool incremental )
- {
- FT_Byte* cur;
- FT_Byte* limit = parser->root.limit;
-
-
- /* the binary data has one of the following formats */
- /* */
- /* `size' [white*] RD white ....... ND */
- /* `size' [white*] -| white ....... |- */
- /* */
-
- T1_Skip_Spaces( parser );
-
- cur = parser->root.cursor;
-
- if ( cur < limit && ft_isdigit( *cur ) )
- {
- FT_Long s = T1_ToInt( parser );
-
-
- T1_Skip_PS_Token( parser ); /* `RD' or `-|' or something else */
-
- /* there is only one whitespace char after the */
- /* `RD' or `-|' token */
- *base = parser->root.cursor + 1;
-
- if ( s >= 0 && s < limit - *base )
- {
- parser->root.cursor += s + 1;
- *size = (FT_ULong)s;
- return !parser->root.error;
- }
- }
-
- if( !incremental )
- {
- FT_ERROR(( "read_binary_data: invalid size field\n" ));
- parser->root.error = FT_THROW( Invalid_File_Format );
- }
-
- return 0;
- }
-
-
- /* We now define the routines to handle the `/Encoding', `/Subrs', */
- /* and `/CharStrings' dictionaries. */
-
- static void
- t1_parse_font_matrix( FT_Face face, /* T1_Face */
- void* loader_ )
- {
- T1_Face t1face = (T1_Face)face;
- T1_Loader loader = (T1_Loader)loader_;
- T1_Parser parser = &loader->parser;
- FT_Matrix* matrix = &t1face->type1.font_matrix;
- FT_Vector* offset = &t1face->type1.font_offset;
- FT_Fixed temp[6];
- FT_Fixed temp_scale;
- FT_Int result;
-
-
- /* input is scaled by 1000 to accommodate default FontMatrix */
- result = T1_ToFixedArray( parser, 6, temp, 3 );
-
- if ( result < 6 )
- {
- parser->root.error = FT_THROW( Invalid_File_Format );
- return;
- }
-
- FT_TRACE4(( " [%f %f %f %f %f %f]\n",
- (double)temp[0] / 65536 / 1000,
- (double)temp[1] / 65536 / 1000,
- (double)temp[2] / 65536 / 1000,
- (double)temp[3] / 65536 / 1000,
- (double)temp[4] / 65536 / 1000,
- (double)temp[5] / 65536 / 1000 ));
-
- temp_scale = FT_ABS( temp[3] );
-
- if ( temp_scale == 0 )
- {
- FT_ERROR(( "t1_parse_font_matrix: invalid font matrix\n" ));
- parser->root.error = FT_THROW( Invalid_File_Format );
- return;
- }
-
- /* atypical case */
- if ( temp_scale != 0x10000L )
- {
- /* set units per EM based on FontMatrix values */
- face->units_per_EM = (FT_UShort)FT_DivFix( 1000, temp_scale );
-
- temp[0] = FT_DivFix( temp[0], temp_scale );
- temp[1] = FT_DivFix( temp[1], temp_scale );
- temp[2] = FT_DivFix( temp[2], temp_scale );
- temp[4] = FT_DivFix( temp[4], temp_scale );
- temp[5] = FT_DivFix( temp[5], temp_scale );
- temp[3] = temp[3] < 0 ? -0x10000L : 0x10000L;
- }
- matrix->xx = temp[0];
- matrix->yx = temp[1];
- matrix->xy = temp[2];
- matrix->yy = temp[3];
-
- if ( !FT_Matrix_Check( matrix ) )
- {
- FT_ERROR(( "t1_parse_font_matrix: invalid font matrix\n" ));
- parser->root.error = FT_THROW( Invalid_File_Format );
- return;
- }
-
- /* note that the offsets must be expressed in integer font units */
- offset->x = temp[4] >> 16;
- offset->y = temp[5] >> 16;
- }
-
-
- static void
- parse_encoding( FT_Face face, /* T1_Face */
- void* loader_ )
- {
- T1_Face t1face = (T1_Face)face;
- T1_Loader loader = (T1_Loader)loader_;
- T1_Parser parser = &loader->parser;
- FT_Byte* cur;
- FT_Byte* limit = parser->root.limit;
-
- PSAux_Service psaux = (PSAux_Service)t1face->psaux;
-
-
- T1_Skip_Spaces( parser );
- cur = parser->root.cursor;
- if ( cur >= limit )
- {
- FT_ERROR(( "parse_encoding: out of bounds\n" ));
- parser->root.error = FT_THROW( Invalid_File_Format );
- return;
- }
-
- /* if we have a number or `[', the encoding is an array, */
- /* and we must load it now */
- if ( ft_isdigit( *cur ) || *cur == '[' )
- {
- T1_Encoding encode = &t1face->type1.encoding;
- FT_Int count, array_size, n;
- PS_Table char_table = &loader->encoding_table;
- FT_Memory memory = parser->root.memory;
- FT_Error error;
- FT_Bool only_immediates = 0;
-
-
- /* read the number of entries in the encoding; should be 256 */
- if ( *cur == '[' )
- {
- count = 256;
- only_immediates = 1;
- parser->root.cursor++;
- }
- else
- count = (FT_Int)T1_ToInt( parser );
-
- array_size = count;
- if ( count > 256 )
- {
- FT_TRACE2(( "parse_encoding:"
- " only using first 256 encoding array entries\n" ));
- array_size = 256;
- }
-
- T1_Skip_Spaces( parser );
- if ( parser->root.cursor >= limit )
- return;
-
- /* PostScript happily allows overwriting of encoding arrays */
- if ( encode->char_index )
- {
- FT_FREE( encode->char_index );
- FT_FREE( encode->char_name );
- T1_Release_Table( char_table );
- }
-
- /* we use a T1_Table to store our charnames */
- loader->num_chars = encode->num_chars = array_size;
- if ( FT_QNEW_ARRAY( encode->char_index, array_size ) ||
- FT_QNEW_ARRAY( encode->char_name, array_size ) ||
- FT_SET_ERROR( psaux->ps_table_funcs->init(
- char_table, array_size, memory ) ) )
- {
- parser->root.error = error;
- return;
- }
-
- /* We need to `zero' out encoding_table.elements */
- for ( n = 0; n < array_size; n++ )
- (void)T1_Add_Table( char_table, n, ".notdef", 8 );
-
- /* Now we need to read records of the form */
- /* */
- /* ... charcode /charname ... */
- /* */
- /* for each entry in our table. */
- /* */
- /* We simply look for a number followed by an immediate */
- /* name. Note that this ignores correctly the sequence */
- /* that is often seen in type1 fonts: */
- /* */
- /* 0 1 255 { 1 index exch /.notdef put } for dup */
- /* */
- /* used to clean the encoding array before anything else. */
- /* */
- /* Alternatively, if the array is directly given as */
- /* */
- /* /Encoding [ ... ] */
- /* */
- /* we only read immediates. */
-
- n = 0;
- T1_Skip_Spaces( parser );
-
- while ( parser->root.cursor < limit )
- {
- cur = parser->root.cursor;
-
- /* we stop when we encounter a `def' or `]' */
- if ( *cur == 'd' && cur + 3 < limit )
- {
- if ( cur[1] == 'e' &&
- cur[2] == 'f' &&
- IS_PS_DELIM( cur[3] ) )
- {
- FT_TRACE6(( "encoding end\n" ));
- cur += 3;
- break;
- }
- }
- if ( *cur == ']' )
- {
- FT_TRACE6(( "encoding end\n" ));
- cur++;
- break;
- }
-
- /* check whether we've found an entry */
- if ( ft_isdigit( *cur ) || only_immediates )
- {
- FT_Int charcode;
-
-
- if ( only_immediates )
- charcode = n;
- else
- {
- charcode = (FT_Int)T1_ToInt( parser );
- T1_Skip_Spaces( parser );
-
- /* protect against invalid charcode */
- if ( cur == parser->root.cursor )
- {
- parser->root.error = FT_THROW( Unknown_File_Format );
- return;
- }
- }
-
- cur = parser->root.cursor;
-
- if ( cur + 2 < limit && *cur == '/' && n < count )
- {
- FT_UInt len;
-
-
- cur++;
-
- parser->root.cursor = cur;
- T1_Skip_PS_Token( parser );
- if ( parser->root.cursor >= limit )
- return;
- if ( parser->root.error )
- return;
-
- len = (FT_UInt)( parser->root.cursor - cur );
-
- if ( n < array_size )
- {
- parser->root.error = T1_Add_Table( char_table, charcode,
- cur, len + 1 );
- if ( parser->root.error )
- return;
- char_table->elements[charcode][len] = '\0';
- }
-
- n++;
- }
- else if ( only_immediates )
- {
- /* Since the current position is not updated for */
- /* immediates-only mode we would get an infinite loop if */
- /* we don't do anything here. */
- /* */
- /* This encoding array is not valid according to the type1 */
- /* specification (it might be an encoding for a CID type1 */
- /* font, however), so we conclude that this font is NOT a */
- /* type1 font. */
- parser->root.error = FT_THROW( Unknown_File_Format );
- return;
- }
- }
- else
- {
- T1_Skip_PS_Token( parser );
- if ( parser->root.error )
- return;
- }
-
- T1_Skip_Spaces( parser );
- }
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- FT_TRACE4(( " [" ));
-
- /* XXX show encoding vector */
- FT_TRACE4(( "..." ));
-
- FT_TRACE4(( "]\n" ));
-#endif
-
- t1face->type1.encoding_type = T1_ENCODING_TYPE_ARRAY;
- parser->root.cursor = cur;
- }
-
- /* Otherwise, we should have either `StandardEncoding', */
- /* `ExpertEncoding', or `ISOLatin1Encoding' */
- else
- {
- if ( cur + 17 < limit &&
- ft_strncmp( (const char*)cur, "StandardEncoding", 16 ) == 0 )
- {
- t1face->type1.encoding_type = T1_ENCODING_TYPE_STANDARD;
- FT_TRACE4(( " StandardEncoding\n" ));
- }
-
- else if ( cur + 15 < limit &&
- ft_strncmp( (const char*)cur, "ExpertEncoding", 14 ) == 0 )
- {
- t1face->type1.encoding_type = T1_ENCODING_TYPE_EXPERT;
- FT_TRACE4(( " ExpertEncoding\n" ));
- }
-
- else if ( cur + 18 < limit &&
- ft_strncmp( (const char*)cur, "ISOLatin1Encoding", 17 ) == 0 )
- {
- t1face->type1.encoding_type = T1_ENCODING_TYPE_ISOLATIN1;
- FT_TRACE4(( " ISOLatin1Encoding\n" ));
- }
-
- else
- {
- parser->root.error = FT_ERR( Ignore );
- FT_TRACE4(( "<unknown>\n" ));
- }
- }
- }
-
-
- static void
- parse_subrs( FT_Face face, /* T1_Face */
- void* loader_ )
- {
- T1_Face t1face = (T1_Face)face;
- T1_Loader loader = (T1_Loader)loader_;
- T1_Parser parser = &loader->parser;
- PS_Table table = &loader->subrs;
- FT_Memory memory = parser->root.memory;
- FT_Error error;
- FT_Int num_subrs;
- FT_UInt count;
-
- PSAux_Service psaux = (PSAux_Service)t1face->psaux;
-
-
- T1_Skip_Spaces( parser );
-
- /* test for empty array */
- if ( parser->root.cursor < parser->root.limit &&
- *parser->root.cursor == '[' )
- {
- T1_Skip_PS_Token( parser );
- T1_Skip_Spaces ( parser );
- if ( parser->root.cursor >= parser->root.limit ||
- *parser->root.cursor != ']' )
- parser->root.error = FT_THROW( Invalid_File_Format );
- return;
- }
-
- num_subrs = (FT_Int)T1_ToInt( parser );
- if ( num_subrs < 0 )
- {
- parser->root.error = FT_THROW( Invalid_File_Format );
- return;
- }
-
- /* we certainly need more than 8 bytes per subroutine */
- if ( parser->root.limit >= parser->root.cursor &&
- num_subrs > ( parser->root.limit - parser->root.cursor ) >> 3 )
- {
- /*
- * There are two possibilities. Either the font contains an invalid
- * value for `num_subrs', or we have a subsetted font where the
- * subroutine indices are not adjusted, e.g.
- *
- * /Subrs 812 array
- * dup 0 { ... } NP
- * dup 51 { ... } NP
- * dup 681 { ... } NP
- * ND
- *
- * In both cases, we use a number hash that maps from subr indices to
- * actual array elements.
- */
-
- FT_TRACE0(( "parse_subrs: adjusting number of subroutines"
- " (from %d to %zu)\n",
- num_subrs,
- ( parser->root.limit - parser->root.cursor ) >> 3 ));
- num_subrs = ( parser->root.limit - parser->root.cursor ) >> 3;
-
- if ( !loader->subrs_hash )
- {
- if ( FT_QNEW( loader->subrs_hash ) )
- goto Fail;
-
- error = ft_hash_num_init( loader->subrs_hash, memory );
- if ( error )
- goto Fail;
- }
- }
-
- /* position the parser right before the `dup' of the first subr */
- T1_Skip_PS_Token( parser ); /* `array' */
- if ( parser->root.error )
- return;
- T1_Skip_Spaces( parser );
-
- /* initialize subrs array -- with synthetic fonts it is possible */
- /* we get here twice */
- if ( !loader->num_subrs )
- {
- error = psaux->ps_table_funcs->init( table, num_subrs, memory );
- if ( error )
- goto Fail;
- }
-
- /* the format is simple: */
- /* */
- /* `index' + binary data */
- /* */
- for ( count = 0; ; count++ )
- {
- FT_Long idx;
- FT_ULong size;
- FT_Byte* base;
-
-
- /* If we are out of data, or if the next token isn't `dup', */
- /* we are done. */
- if ( parser->root.cursor + 4 >= parser->root.limit ||
- ft_strncmp( (char*)parser->root.cursor, "dup", 3 ) != 0 )
- break;
-
- T1_Skip_PS_Token( parser ); /* `dup' */
-
- idx = T1_ToInt( parser );
-
- if ( !read_binary_data( parser, &size, &base, IS_INCREMENTAL ) )
- return;
-
- /* The binary string is followed by one token, e.g. `NP' */
- /* (bound to `noaccess put') or by two separate tokens: */
- /* `noaccess' & `put'. We position the parser right */
- /* before the next `dup', if any. */
- T1_Skip_PS_Token( parser ); /* `NP' or `|' or `noaccess' */
- if ( parser->root.error )
- return;
- T1_Skip_Spaces ( parser );
-
- if ( parser->root.cursor + 4 < parser->root.limit &&
- ft_strncmp( (char*)parser->root.cursor, "put", 3 ) == 0 )
- {
- T1_Skip_PS_Token( parser ); /* skip `put' */
- T1_Skip_Spaces ( parser );
- }
-
- /* if we use a hash, the subrs index is the key, and a running */
- /* counter specified for `T1_Add_Table' acts as the value */
- if ( loader->subrs_hash )
- {
- ft_hash_num_insert( idx, count, loader->subrs_hash, memory );
- idx = count;
- }
-
- /* with synthetic fonts it is possible we get here twice */
- if ( loader->num_subrs )
- continue;
-
- /* some fonts use a value of -1 for lenIV to indicate that */
- /* the charstrings are unencoded */
- /* */
- /* thanks to Tom Kacvinsky for pointing this out */
- /* */
- if ( t1face->type1.private_dict.lenIV >= 0 )
- {
- FT_Byte* temp = NULL;
-
-
- /* some fonts define empty subr records -- this is not totally */
- /* compliant to the specification (which says they should at */
- /* least contain a `return'), but we support them anyway */
- if ( size < (FT_ULong)t1face->type1.private_dict.lenIV )
- {
- error = FT_THROW( Invalid_File_Format );
- goto Fail;
- }
-
- /* t1_decrypt() shouldn't write to base -- make temporary copy */
- if ( FT_DUP( temp, base, size ) )
- goto Fail;
- psaux->t1_decrypt( temp, size, 4330 );
- size -= (FT_ULong)t1face->type1.private_dict.lenIV;
- error = T1_Add_Table( table,
- (FT_Int)idx,
- temp + t1face->type1.private_dict.lenIV,
- size );
- FT_FREE( temp );
- }
- else
- error = T1_Add_Table( table, (FT_Int)idx, base, size );
- if ( error )
- goto Fail;
- }
-
- if ( !loader->num_subrs )
- loader->num_subrs = num_subrs;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- FT_TRACE4(( " <" ));
-
- /* XXX show subrs? */
- FT_TRACE4(( "%d elements", num_subrs ));
-
- FT_TRACE4(( ">\n" ));
-#endif
-
- return;
-
- Fail:
- parser->root.error = error;
- }
-
-
-#define TABLE_EXTEND 5
-
-
- static void
- parse_charstrings( FT_Face face, /* T1_Face */
- void* loader_ )
- {
- T1_Face t1face = (T1_Face)face;
- T1_Loader loader = (T1_Loader)loader_;
- T1_Parser parser = &loader->parser;
- PS_Table code_table = &loader->charstrings;
- PS_Table name_table = &loader->glyph_names;
- PS_Table swap_table = &loader->swap_table;
- FT_Memory memory = parser->root.memory;
- FT_Error error;
-
- PSAux_Service psaux = (PSAux_Service)t1face->psaux;
-
- FT_Byte* cur = parser->root.cursor;
- FT_Byte* limit = parser->root.limit;
- FT_Int n, num_glyphs;
- FT_Int notdef_index = 0;
- FT_Byte notdef_found = 0;
-
-
- num_glyphs = (FT_Int)T1_ToInt( parser );
- if ( num_glyphs < 0 )
- {
- error = FT_THROW( Invalid_File_Format );
- goto Fail;
- }
-
- /* we certainly need more than 8 bytes per glyph */
- if ( num_glyphs > ( limit - cur ) >> 3 )
- {
- FT_TRACE0(( "parse_charstrings: adjusting number of glyphs"
- " (from %d to %zu)\n",
- num_glyphs, ( limit - cur ) >> 3 ));
- num_glyphs = ( limit - cur ) >> 3;
- }
-
- /* some fonts like Optima-Oblique not only define the /CharStrings */
- /* array but access it also */
- if ( num_glyphs == 0 || parser->root.error )
- return;
-
- /* initialize tables, leaving space for addition of .notdef, */
- /* if necessary, and a few other glyphs to handle buggy */
- /* fonts which have more glyphs than specified. */
-
- /* for some non-standard fonts like `Optima' which provides */
- /* different outlines depending on the resolution it is */
- /* possible to get here twice */
- if ( !loader->num_glyphs )
- {
- error = psaux->ps_table_funcs->init(
- code_table, num_glyphs + 1 + TABLE_EXTEND, memory );
- if ( error )
- goto Fail;
-
- error = psaux->ps_table_funcs->init(
- name_table, num_glyphs + 1 + TABLE_EXTEND, memory );
- if ( error )
- goto Fail;
-
- /* Initialize table for swapping index notdef_index and */
- /* index 0 names and codes (if necessary). */
-
- error = psaux->ps_table_funcs->init( swap_table, 4, memory );
- if ( error )
- goto Fail;
- }
-
- n = 0;
-
- for (;;)
- {
- FT_ULong size;
- FT_Byte* base;
-
-
- /* the format is simple: */
- /* `/glyphname' + binary data */
-
- T1_Skip_Spaces( parser );
-
- cur = parser->root.cursor;
- if ( cur >= limit )
- break;
-
- /* we stop when we find a `def' or `end' keyword */
- if ( cur + 3 < limit && IS_PS_DELIM( cur[3] ) )
- {
- if ( cur[0] == 'd' &&
- cur[1] == 'e' &&
- cur[2] == 'f' )
- {
- /* There are fonts which have this: */
- /* */
- /* /CharStrings 118 dict def */
- /* Private begin */
- /* CharStrings begin */
- /* ... */
- /* */
- /* To catch this we ignore `def' if */
- /* no charstring has actually been */
- /* seen. */
- if ( n )
- break;
- }
-
- if ( cur[0] == 'e' &&
- cur[1] == 'n' &&
- cur[2] == 'd' )
- break;
- }
-
- T1_Skip_PS_Token( parser );
- if ( parser->root.cursor >= limit )
- {
- error = FT_THROW( Invalid_File_Format );
- goto Fail;
- }
- if ( parser->root.error )
- return;
-
- if ( *cur == '/' )
- {
- FT_UInt len;
-
-
- if ( cur + 2 >= limit )
- {
- error = FT_THROW( Invalid_File_Format );
- goto Fail;
- }
-
- cur++; /* skip `/' */
- len = (FT_UInt)( parser->root.cursor - cur );
-
- if ( !read_binary_data( parser, &size, &base, IS_INCREMENTAL ) )
- return;
-
- /* for some non-standard fonts like `Optima' which provides */
- /* different outlines depending on the resolution it is */
- /* possible to get here twice */
- if ( loader->num_glyphs )
- continue;
-
- error = T1_Add_Table( name_table, n, cur, len + 1 );
- if ( error )
- goto Fail;
-
- /* add a trailing zero to the name table */
- name_table->elements[n][len] = '\0';
-
- /* record index of /.notdef */
- if ( *cur == '.' &&
- ft_strcmp( ".notdef",
- (const char*)( name_table->elements[n] ) ) == 0 )
- {
- notdef_index = n;
- notdef_found = 1;
- }
-
- if ( t1face->type1.private_dict.lenIV >= 0 &&
- n < num_glyphs + TABLE_EXTEND )
- {
- FT_Byte* temp = NULL;
-
-
- if ( size <= (FT_ULong)t1face->type1.private_dict.lenIV )
- {
- error = FT_THROW( Invalid_File_Format );
- goto Fail;
- }
-
- /* t1_decrypt() shouldn't write to base -- make temporary copy */
- if ( FT_DUP( temp, base, size ) )
- goto Fail;
- psaux->t1_decrypt( temp, size, 4330 );
- size -= (FT_ULong)t1face->type1.private_dict.lenIV;
- error = T1_Add_Table( code_table,
- n,
- temp + t1face->type1.private_dict.lenIV,
- size );
- FT_FREE( temp );
- }
- else
- error = T1_Add_Table( code_table, n, base, size );
- if ( error )
- goto Fail;
-
- n++;
- }
- }
-
- if ( !n )
- {
- error = FT_THROW( Invalid_File_Format );
- goto Fail;
- }
-
- loader->num_glyphs = n;
-
- /* if /.notdef is found but does not occupy index 0, do our magic. */
- if ( notdef_found &&
- ft_strcmp( ".notdef", (const char*)name_table->elements[0] ) )
- {
- /* Swap glyph in index 0 with /.notdef glyph. First, add index 0 */
- /* name and code entries to swap_table. Then place notdef_index */
- /* name and code entries into swap_table. Then swap name and code */
- /* entries at indices notdef_index and 0 using values stored in */
- /* swap_table. */
-
- /* Index 0 name */
- error = T1_Add_Table( swap_table, 0,
- name_table->elements[0],
- name_table->lengths [0] );
- if ( error )
- goto Fail;
-
- /* Index 0 code */
- error = T1_Add_Table( swap_table, 1,
- code_table->elements[0],
- code_table->lengths [0] );
- if ( error )
- goto Fail;
-
- /* Index notdef_index name */
- error = T1_Add_Table( swap_table, 2,
- name_table->elements[notdef_index],
- name_table->lengths [notdef_index] );
- if ( error )
- goto Fail;
-
- /* Index notdef_index code */
- error = T1_Add_Table( swap_table, 3,
- code_table->elements[notdef_index],
- code_table->lengths [notdef_index] );
- if ( error )
- goto Fail;
-
- error = T1_Add_Table( name_table, notdef_index,
- swap_table->elements[0],
- swap_table->lengths [0] );
- if ( error )
- goto Fail;
-
- error = T1_Add_Table( code_table, notdef_index,
- swap_table->elements[1],
- swap_table->lengths [1] );
- if ( error )
- goto Fail;
-
- error = T1_Add_Table( name_table, 0,
- swap_table->elements[2],
- swap_table->lengths [2] );
- if ( error )
- goto Fail;
-
- error = T1_Add_Table( code_table, 0,
- swap_table->elements[3],
- swap_table->lengths [3] );
- if ( error )
- goto Fail;
-
- }
- else if ( !notdef_found )
- {
- /* notdef_index is already 0, or /.notdef is undefined in */
- /* charstrings dictionary. Worry about /.notdef undefined. */
- /* We take index 0 and add it to the end of the table(s) */
- /* and add our own /.notdef glyph to index 0. */
-
- /* 0 333 hsbw endchar */
- FT_Byte notdef_glyph[] = { 0x8B, 0xF7, 0xE1, 0x0D, 0x0E };
-
-
- error = T1_Add_Table( swap_table, 0,
- name_table->elements[0],
- name_table->lengths [0] );
- if ( error )
- goto Fail;
-
- error = T1_Add_Table( swap_table, 1,
- code_table->elements[0],
- code_table->lengths [0] );
- if ( error )
- goto Fail;
-
- error = T1_Add_Table( name_table, 0, ".notdef", 8 );
- if ( error )
- goto Fail;
-
- error = T1_Add_Table( code_table, 0, notdef_glyph, 5 );
-
- if ( error )
- goto Fail;
-
- error = T1_Add_Table( name_table, n,
- swap_table->elements[0],
- swap_table->lengths [0] );
- if ( error )
- goto Fail;
-
- error = T1_Add_Table( code_table, n,
- swap_table->elements[1],
- swap_table->lengths [1] );
- if ( error )
- goto Fail;
-
- /* we added a glyph. */
- loader->num_glyphs += 1;
- }
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- FT_TRACE4(( " <" ));
-
- /* XXX show charstrings? */
- FT_TRACE4(( "%d elements", loader->num_glyphs ));
-
- FT_TRACE4(( ">\n" ));
-#endif
-
- return;
-
- Fail:
- parser->root.error = error;
- }
-
-
- /**************************************************************************
- *
- * Define the token field static variables. This is a set of
- * T1_FieldRec variables.
- *
- */
-
-
- static
- const T1_FieldRec t1_keywords[] =
- {
-
-#include "t1tokens.h"
-
- /* now add the special functions... */
- T1_FIELD_CALLBACK( "FontMatrix", t1_parse_font_matrix,
- T1_FIELD_DICT_FONTDICT )
- T1_FIELD_CALLBACK( "Encoding", parse_encoding,
- T1_FIELD_DICT_FONTDICT )
- T1_FIELD_CALLBACK( "Subrs", parse_subrs,
- T1_FIELD_DICT_PRIVATE )
- T1_FIELD_CALLBACK( "CharStrings", parse_charstrings,
- T1_FIELD_DICT_PRIVATE )
- T1_FIELD_CALLBACK( "Private", parse_private,
- T1_FIELD_DICT_FONTDICT )
-
-#ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT
- T1_FIELD_CALLBACK( "BlendDesignPositions", parse_blend_design_positions,
- T1_FIELD_DICT_FONTDICT )
- T1_FIELD_CALLBACK( "BlendDesignMap", parse_blend_design_map,
- T1_FIELD_DICT_FONTDICT )
- T1_FIELD_CALLBACK( "BlendAxisTypes", parse_blend_axis_types,
- T1_FIELD_DICT_FONTDICT )
- T1_FIELD_CALLBACK( "WeightVector", parse_weight_vector,
- T1_FIELD_DICT_FONTDICT )
- T1_FIELD_CALLBACK( "BuildCharArray", parse_buildchar,
- T1_FIELD_DICT_PRIVATE )
-#endif
-
- T1_FIELD_ZERO
- };
-
-
- static FT_Error
- parse_dict( T1_Face face,
- T1_Loader loader,
- FT_Byte* base,
- FT_ULong size )
- {
- T1_Parser parser = &loader->parser;
- FT_Byte *limit, *start_binary = NULL;
- FT_Bool have_integer = 0;
-
-
- parser->root.cursor = base;
- parser->root.limit = base + size;
- parser->root.error = FT_Err_Ok;
-
- limit = parser->root.limit;
-
- T1_Skip_Spaces( parser );
-
- while ( parser->root.cursor < limit )
- {
- FT_Byte* cur;
-
-
- cur = parser->root.cursor;
-
- /* look for `eexec' */
- if ( IS_PS_TOKEN( cur, limit, "eexec" ) )
- break;
-
- /* look for `closefile' which ends the eexec section */
- else if ( IS_PS_TOKEN( cur, limit, "closefile" ) )
- break;
-
- /* in a synthetic font the base font starts after a */
- /* `FontDictionary' token that is placed after a Private dict */
- else if ( IS_PS_TOKEN( cur, limit, "FontDirectory" ) )
- {
- if ( loader->keywords_encountered & T1_PRIVATE )
- loader->keywords_encountered |=
- T1_FONTDIR_AFTER_PRIVATE;
- parser->root.cursor += 13;
- }
-
- /* check whether we have an integer */
- else if ( ft_isdigit( *cur ) )
- {
- start_binary = cur;
- T1_Skip_PS_Token( parser );
- if ( parser->root.error )
- goto Exit;
- have_integer = 1;
- }
-
- /* in valid Type 1 fonts we don't see `RD' or `-|' directly */
- /* since those tokens are handled by parse_subrs and */
- /* parse_charstrings */
- else if ( *cur == 'R' && cur + 6 < limit && *( cur + 1 ) == 'D' &&
- have_integer )
- {
- FT_ULong s;
- FT_Byte* b;
-
-
- parser->root.cursor = start_binary;
- if ( !read_binary_data( parser, &s, &b, IS_INCREMENTAL ) )
- return FT_THROW( Invalid_File_Format );
- have_integer = 0;
- }
-
- else if ( *cur == '-' && cur + 6 < limit && *( cur + 1 ) == '|' &&
- have_integer )
- {
- FT_ULong s;
- FT_Byte* b;
-
-
- parser->root.cursor = start_binary;
- if ( !read_binary_data( parser, &s, &b, IS_INCREMENTAL ) )
- return FT_THROW( Invalid_File_Format );
- have_integer = 0;
- }
-
- /* look for immediates */
- else if ( *cur == '/' && cur + 2 < limit )
- {
- FT_UInt len;
-
-
- cur++;
-
- parser->root.cursor = cur;
- T1_Skip_PS_Token( parser );
- if ( parser->root.error )
- goto Exit;
-
- len = (FT_UInt)( parser->root.cursor - cur );
-
- if ( len > 0 && len < 22 && parser->root.cursor < limit )
- {
- /* now compare the immediate name to the keyword table */
- T1_Field keyword = (T1_Field)t1_keywords;
-
-
- while ( keyword->len )
- {
- FT_Byte* name = (FT_Byte*)keyword->ident;
-
-
- if ( keyword->len == len &&
- ft_memcmp( cur, name, len ) == 0 )
- {
- /* We found it -- run the parsing callback! */
- /* We record every instance of every field */
- /* (until we reach the base font of a */
- /* synthetic font) to deal adequately with */
- /* multiple master fonts; this is also */
- /* necessary because later PostScript */
- /* definitions override earlier ones. */
-
- /* Once we encounter `FontDirectory' after */
- /* `/Private', we know that this is a synthetic */
- /* font; except for `/CharStrings' we are not */
- /* interested in anything that follows this */
- /* `FontDirectory'. */
-
- /* MM fonts have more than one /Private token at */
- /* the top level; let's hope that all the junk */
- /* that follows the first /Private token is not */
- /* interesting to us. */
-
- /* According to Adobe Tech Note #5175 (CID-Keyed */
- /* Font Installation for ATM Software) a `begin' */
- /* must be followed by exactly one `end', and */
- /* `begin' -- `end' pairs must be accurately */
- /* paired. We could use this to distinguish */
- /* between the global Private and the Private */
- /* dict that is a member of the Blend dict. */
-
- const FT_UInt dict =
- ( loader->keywords_encountered & T1_PRIVATE )
- ? T1_FIELD_DICT_PRIVATE
- : T1_FIELD_DICT_FONTDICT;
-
-
- if ( !( dict & keyword->dict ) )
- {
- FT_TRACE1(( "parse_dict: found `%s' but ignoring it"
- " since it is in the wrong dictionary\n",
- keyword->ident ));
- break;
- }
-
- if ( !( loader->keywords_encountered &
- T1_FONTDIR_AFTER_PRIVATE ) ||
- ft_strcmp( (const char*)name, "CharStrings" ) == 0 )
- {
- parser->root.error = t1_load_keyword( face,
- loader,
- keyword );
- if ( parser->root.error )
- {
- if ( FT_ERR_EQ( parser->root.error, Ignore ) )
- parser->root.error = FT_Err_Ok;
- else
- return parser->root.error;
- }
- }
- break;
- }
-
- keyword++;
- }
- }
-
- have_integer = 0;
- }
- else
- {
- T1_Skip_PS_Token( parser );
- if ( parser->root.error )
- goto Exit;
- have_integer = 0;
- }
-
- T1_Skip_Spaces( parser );
- }
-
- Exit:
- return parser->root.error;
- }
-
-
- static void
- t1_init_loader( T1_Loader loader,
- T1_Face face )
- {
- FT_UNUSED( face );
-
- FT_ZERO( loader );
- }
-
-
- static void
- t1_done_loader( T1_Loader loader )
- {
- T1_Parser parser = &loader->parser;
- FT_Memory memory = parser->root.memory;
-
-
- /* finalize tables */
- T1_Release_Table( &loader->encoding_table );
- T1_Release_Table( &loader->charstrings );
- T1_Release_Table( &loader->glyph_names );
- T1_Release_Table( &loader->swap_table );
- T1_Release_Table( &loader->subrs );
-
- /* finalize hash */
- ft_hash_num_free( loader->subrs_hash, memory );
- FT_FREE( loader->subrs_hash );
-
- /* finalize parser */
- T1_Finalize_Parser( parser );
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- T1_Open_Face( T1_Face face )
- {
- T1_LoaderRec loader;
- T1_Parser parser;
- T1_Font type1 = &face->type1;
- PS_Private priv = &type1->private_dict;
- FT_Error error;
-
- PSAux_Service psaux = (PSAux_Service)face->psaux;
-
-
- t1_init_loader( &loader, face );
-
- /* default values */
- face->ndv_idx = -1;
- face->cdv_idx = -1;
- face->len_buildchar = 0;
-
- priv->blue_shift = 7;
- priv->blue_fuzz = 1;
- priv->lenIV = 4;
- priv->expansion_factor = (FT_Fixed)( 0.06 * 0x10000L );
- priv->blue_scale = (FT_Fixed)( 0.039625 * 0x10000L * 1000 );
-
- parser = &loader.parser;
- error = T1_New_Parser( parser,
- face->root.stream,
- face->root.memory,
- psaux );
- if ( error )
- goto Exit;
-
- FT_TRACE4(( " top dictionary:\n" ));
- error = parse_dict( face, &loader,
- parser->base_dict, parser->base_len );
- if ( error )
- goto Exit;
-
- error = T1_Get_Private_Dict( parser, psaux );
- if ( error )
- goto Exit;
-
- FT_TRACE4(( " private dictionary:\n" ));
- error = parse_dict( face, &loader,
- parser->private_dict, parser->private_len );
- if ( error )
- goto Exit;
-
- /* ensure even-ness of `num_blue_values' */
- priv->num_blue_values &= ~1;
-
-#ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT
-
- /* we don't support Multiple Master fonts with intermediate designs; */
- /* this implies that `num_designs' must be equal to `2^^num_axis' */
- if ( face->blend &&
- face->blend->num_designs != ( 1U << face->blend->num_axis ) )
- {
- FT_ERROR(( "T1_Open_Face:"
- " number-of-designs != 2 ^^ number-of-axes\n" ));
- T1_Done_Blend( FT_FACE( face ) );
- }
-
- if ( face->blend &&
- face->blend->num_default_design_vector != 0 &&
- face->blend->num_default_design_vector != face->blend->num_axis )
- {
- /* we don't use it currently so just warn, reset, and ignore */
- FT_ERROR(( "T1_Open_Face(): /DesignVector contains %u entries "
- "while there are %u axes.\n",
- face->blend->num_default_design_vector,
- face->blend->num_axis ));
-
- face->blend->num_default_design_vector = 0;
- }
-
- /* the following can happen for MM instances; we then treat the */
- /* font as a normal PS font */
- if ( face->blend &&
- ( !face->blend->num_designs || !face->blend->num_axis ) )
- T1_Done_Blend( FT_FACE( face ) );
-
- /* the font may have no valid WeightVector */
- if ( face->blend && !face->blend->weight_vector )
- T1_Done_Blend( FT_FACE( face ) );
-
- /* the font may have no valid BlendDesignPositions */
- if ( face->blend && !face->blend->design_pos[0] )
- T1_Done_Blend( FT_FACE( face ) );
-
- /* the font may have no valid BlendDesignMap */
- if ( face->blend )
- {
- FT_UInt i;
-
-
- for ( i = 0; i < face->blend->num_axis; i++ )
- if ( !face->blend->design_map[i].num_points )
- {
- T1_Done_Blend( FT_FACE( face ) );
- break;
- }
- }
-
- if ( face->blend )
- {
- if ( face->len_buildchar > 0 )
- {
- FT_Memory memory = face->root.memory;
-
-
- if ( FT_NEW_ARRAY( face->buildchar, face->len_buildchar ) )
- {
- FT_ERROR(( "T1_Open_Face: cannot allocate BuildCharArray\n" ));
- face->len_buildchar = 0;
- goto Exit;
- }
- }
- }
- else
- face->len_buildchar = 0;
-
-#endif /* !T1_CONFIG_OPTION_NO_MM_SUPPORT */
-
- /* now, propagate the subrs, charstrings, and glyphnames tables */
- /* to the Type1 data */
- type1->num_glyphs = loader.num_glyphs;
-
- if ( loader.subrs.init )
- {
- type1->num_subrs = loader.num_subrs;
- type1->subrs_block = loader.subrs.block;
- type1->subrs = loader.subrs.elements;
- type1->subrs_len = loader.subrs.lengths;
- type1->subrs_hash = loader.subrs_hash;
-
- /* prevent `t1_done_loader' from freeing the propagated data */
- loader.subrs.init = 0;
- loader.subrs_hash = NULL;
- }
-
- if ( !IS_INCREMENTAL )
- if ( !loader.charstrings.init )
- {
- FT_ERROR(( "T1_Open_Face: no `/CharStrings' array in face\n" ));
- error = FT_THROW( Invalid_File_Format );
- }
-
- loader.charstrings.init = 0;
- type1->charstrings_block = loader.charstrings.block;
- type1->charstrings = loader.charstrings.elements;
- type1->charstrings_len = loader.charstrings.lengths;
-
- /* we copy the glyph names `block' and `elements' fields; */
- /* the `lengths' field must be released later */
- type1->glyph_names_block = loader.glyph_names.block;
- type1->glyph_names = (FT_String**)loader.glyph_names.elements;
- loader.glyph_names.block = NULL;
- loader.glyph_names.elements = NULL;
-
- /* we must now build type1.encoding when we have a custom array */
- if ( type1->encoding_type == T1_ENCODING_TYPE_ARRAY )
- {
- FT_Int charcode, idx, min_char, max_char;
-
-
- /* OK, we do the following: for each element in the encoding */
- /* table, look up the index of the glyph having the same name */
- /* the index is then stored in type1.encoding.char_index, and */
- /* the name to type1.encoding.char_name */
-
- min_char = 0;
- max_char = 0;
-
- charcode = 0;
- for ( ; charcode < loader.encoding_table.max_elems; charcode++ )
- {
- const FT_String* char_name =
- (const FT_String*)loader.encoding_table.elements[charcode];
-
-
- type1->encoding.char_index[charcode] = 0;
- type1->encoding.char_name [charcode] = ".notdef";
-
- if ( char_name )
- for ( idx = 0; idx < type1->num_glyphs; idx++ )
- {
- const FT_String* glyph_name = type1->glyph_names[idx];
-
-
- if ( ft_strcmp( char_name, glyph_name ) == 0 )
- {
- type1->encoding.char_index[charcode] = (FT_UShort)idx;
- type1->encoding.char_name [charcode] = glyph_name;
-
- /* Change min/max encoded char only if glyph name is */
- /* not /.notdef */
- if ( ft_strcmp( ".notdef", glyph_name ) != 0 )
- {
- if ( charcode < min_char )
- min_char = charcode;
- if ( charcode >= max_char )
- max_char = charcode + 1;
- }
- break;
- }
- }
- }
-
- type1->encoding.code_first = min_char;
- type1->encoding.code_last = max_char;
- type1->encoding.num_chars = loader.num_chars;
- }
-
- /* some sanitizing to avoid overflows later on; */
- /* the upper limits are ad-hoc values */
- if ( priv->blue_shift > 1000 || priv->blue_shift < 0 )
- {
- FT_TRACE2(( "T1_Open_Face:"
- " setting unlikely BlueShift value %d to default (7)\n",
- priv->blue_shift ));
- priv->blue_shift = 7;
- }
-
- if ( priv->blue_fuzz > 1000 || priv->blue_fuzz < 0 )
- {
- FT_TRACE2(( "T1_Open_Face:"
- " setting unlikely BlueFuzz value %d to default (1)\n",
- priv->blue_fuzz ));
- priv->blue_fuzz = 1;
- }
-
- Exit:
- t1_done_loader( &loader );
- return error;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/type1/t1load.h b/contrib/libs/freetype/src/type1/t1load.h
deleted file mode 100644
index a45efa7cb7..0000000000
--- a/contrib/libs/freetype/src/type1/t1load.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/****************************************************************************
- *
- * t1load.h
- *
- * Type 1 font loader (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef T1LOAD_H_
-#define T1LOAD_H_
-
-
-#include <freetype/internal/ftstream.h>
-#include <freetype/internal/psaux.h>
-#include <freetype/ftmm.h>
-
-#include "t1parse.h"
-
-
-FT_BEGIN_HEADER
-
-
- typedef struct T1_Loader_
- {
- T1_ParserRec parser; /* parser used to read the stream */
-
- FT_Int num_chars; /* number of characters in encoding */
- PS_TableRec encoding_table; /* PS_Table used to store the */
- /* encoding character names */
-
- FT_Int num_glyphs;
- PS_TableRec glyph_names;
- PS_TableRec charstrings;
- PS_TableRec swap_table; /* For moving .notdef glyph to index 0. */
-
- FT_Int num_subrs;
- PS_TableRec subrs;
- FT_Hash subrs_hash;
- FT_Bool fontdata;
-
- FT_UInt keywords_encountered; /* T1_LOADER_ENCOUNTERED_XXX */
-
- } T1_LoaderRec, *T1_Loader;
-
-
- /* treatment of some keywords differs depending on whether */
- /* they precede or follow certain other keywords */
-
-#define T1_PRIVATE ( 1 << 0 )
-#define T1_FONTDIR_AFTER_PRIVATE ( 1 << 1 )
-
-
- FT_LOCAL( FT_Error )
- T1_Open_Face( T1_Face face );
-
-#ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT
-
- FT_LOCAL( FT_Error )
- T1_Get_Multi_Master( FT_Face face,
- FT_Multi_Master* master );
-
- FT_LOCAL( FT_Error )
- T1_Get_MM_Var( FT_Face face,
- FT_MM_Var* *master );
-
- FT_LOCAL( FT_Error )
- T1_Set_MM_Blend( FT_Face face,
- FT_UInt num_coords,
- FT_Fixed* coords );
-
- FT_LOCAL( FT_Error )
- T1_Get_MM_Blend( FT_Face face,
- FT_UInt num_coords,
- FT_Fixed* coords );
-
- FT_LOCAL( FT_Error )
- T1_Set_MM_Design( FT_Face face,
- FT_UInt num_coords,
- FT_Long* coords );
-
- FT_LOCAL( FT_Error )
- T1_Reset_MM_Blend( FT_Face face,
- FT_UInt instance_index );
-
- FT_LOCAL( FT_Error )
- T1_Get_Var_Design( FT_Face face,
- FT_UInt num_coords,
- FT_Fixed* coords );
-
- FT_LOCAL( FT_Error )
- T1_Set_Var_Design( FT_Face face,
- FT_UInt num_coords,
- FT_Fixed* coords );
-
- FT_LOCAL( void )
- T1_Done_Blend( FT_Face face );
-
- FT_LOCAL( FT_Error )
- T1_Set_MM_WeightVector( FT_Face face,
- FT_UInt len,
- FT_Fixed* weightvector );
-
- FT_LOCAL( FT_Error )
- T1_Get_MM_WeightVector( FT_Face face,
- FT_UInt* len,
- FT_Fixed* weightvector );
-
-#endif /* !T1_CONFIG_OPTION_NO_MM_SUPPORT */
-
-
-FT_END_HEADER
-
-#endif /* T1LOAD_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/type1/t1objs.c b/contrib/libs/freetype/src/type1/t1objs.c
deleted file mode 100644
index b1b27c31fe..0000000000
--- a/contrib/libs/freetype/src/type1/t1objs.c
+++ /dev/null
@@ -1,655 +0,0 @@
-/****************************************************************************
- *
- * t1objs.c
- *
- * Type 1 objects manager (body).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/internal/ftcalc.h>
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/ttnameid.h>
-#include <freetype/ftdriver.h>
-
-#include "t1gload.h"
-#include "t1load.h"
-
-#include "t1errors.h"
-
-#ifndef T1_CONFIG_OPTION_NO_AFM
-#include "t1afm.h"
-#endif
-
-#include <freetype/internal/services/svpscmap.h>
-#include <freetype/internal/psaux.h>
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT t1objs
-
-
- /**************************************************************************
- *
- * SIZE FUNCTIONS
- *
- */
-
-
- static PSH_Globals_Funcs
- T1_Size_Get_Globals_Funcs( T1_Size size )
- {
- T1_Face face = (T1_Face)size->root.face;
- PSHinter_Service pshinter = (PSHinter_Service)face->pshinter;
- FT_Module module;
-
-
- module = FT_Get_Module( size->root.face->driver->root.library,
- "pshinter" );
- return ( module && pshinter && pshinter->get_globals_funcs )
- ? pshinter->get_globals_funcs( module )
- : 0;
- }
-
-
- FT_LOCAL_DEF( void )
- T1_Size_Done( FT_Size t1size ) /* T1_Size */
- {
- T1_Size size = (T1_Size)t1size;
-
-
- if ( t1size->internal->module_data )
- {
- PSH_Globals_Funcs funcs;
-
-
- funcs = T1_Size_Get_Globals_Funcs( size );
- if ( funcs )
- funcs->destroy( (PSH_Globals)t1size->internal->module_data );
-
- t1size->internal->module_data = NULL;
- }
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- T1_Size_Init( FT_Size t1size ) /* T1_Size */
- {
- T1_Size size = (T1_Size)t1size;
- FT_Error error = FT_Err_Ok;
- PSH_Globals_Funcs funcs = T1_Size_Get_Globals_Funcs( size );
-
-
- if ( funcs )
- {
- PSH_Globals globals;
- T1_Face face = (T1_Face)size->root.face;
-
-
- error = funcs->create( size->root.face->memory,
- &face->type1.private_dict, &globals );
- if ( !error )
- t1size->internal->module_data = globals;
- }
-
- return error;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- T1_Size_Request( FT_Size t1size, /* T1_Size */
- FT_Size_Request req )
- {
- FT_Error error;
-
- T1_Size size = (T1_Size)t1size;
- PSH_Globals_Funcs funcs = T1_Size_Get_Globals_Funcs( size );
-
-
- error = FT_Request_Metrics( size->root.face, req );
- if ( error )
- goto Exit;
-
- if ( funcs )
- funcs->set_scale( (PSH_Globals)t1size->internal->module_data,
- size->root.metrics.x_scale,
- size->root.metrics.y_scale,
- 0, 0 );
-
- Exit:
- return error;
- }
-
-
- /**************************************************************************
- *
- * SLOT FUNCTIONS
- *
- */
-
- FT_LOCAL_DEF( void )
- T1_GlyphSlot_Done( FT_GlyphSlot slot )
- {
- /* `slot->internal` might be NULL in out-of-memory situations. */
- if ( slot->internal )
- slot->internal->glyph_hints = NULL;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- T1_GlyphSlot_Init( FT_GlyphSlot slot )
- {
- T1_Face face;
- PSHinter_Service pshinter;
-
-
- face = (T1_Face)slot->face;
- pshinter = (PSHinter_Service)face->pshinter;
-
- if ( pshinter )
- {
- FT_Module module;
-
-
- module = FT_Get_Module( slot->library, "pshinter" );
- if ( module )
- {
- T1_Hints_Funcs funcs;
-
-
- funcs = pshinter->get_t1_funcs( module );
- slot->internal->glyph_hints = (void*)funcs;
- }
- }
-
- return 0;
- }
-
-
- /**************************************************************************
- *
- * FACE FUNCTIONS
- *
- */
-
-
- /**************************************************************************
- *
- * @Function:
- * T1_Face_Done
- *
- * @Description:
- * The face object destructor.
- *
- * @Input:
- * face ::
- * A typeless pointer to the face object to destroy.
- */
- FT_LOCAL_DEF( void )
- T1_Face_Done( FT_Face t1face ) /* T1_Face */
- {
- T1_Face face = (T1_Face)t1face;
- FT_Memory memory;
- T1_Font type1;
-
-
- if ( !face )
- return;
-
- memory = face->root.memory;
- type1 = &face->type1;
-
-#ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT
- /* release multiple masters information */
- FT_ASSERT( ( face->len_buildchar == 0 ) == ( face->buildchar == NULL ) );
-
- if ( face->buildchar )
- {
- FT_FREE( face->buildchar );
-
- face->len_buildchar = 0;
- }
-
- T1_Done_Blend( t1face );
- face->blend = NULL;
-#endif
-
- /* release font info strings */
- {
- PS_FontInfo info = &type1->font_info;
-
-
- FT_FREE( info->version );
- FT_FREE( info->notice );
- FT_FREE( info->full_name );
- FT_FREE( info->family_name );
- FT_FREE( info->weight );
- }
-
- /* release top dictionary */
- FT_FREE( type1->charstrings_len );
- FT_FREE( type1->charstrings );
- FT_FREE( type1->glyph_names );
-
- FT_FREE( type1->subrs );
- FT_FREE( type1->subrs_len );
-
- ft_hash_num_free( type1->subrs_hash, memory );
- FT_FREE( type1->subrs_hash );
-
- FT_FREE( type1->subrs_block );
- FT_FREE( type1->charstrings_block );
- FT_FREE( type1->glyph_names_block );
-
- FT_FREE( type1->encoding.char_index );
- FT_FREE( type1->encoding.char_name );
- FT_FREE( type1->font_name );
-
-#ifndef T1_CONFIG_OPTION_NO_AFM
- /* release afm data if present */
- if ( face->afm_data )
- T1_Done_Metrics( memory, (AFM_FontInfo)face->afm_data );
-#endif
-
- /* release unicode map, if any */
-#if 0
- FT_FREE( face->unicode_map_rec.maps );
- face->unicode_map_rec.num_maps = 0;
- face->unicode_map = NULL;
-#endif
-
- face->root.family_name = NULL;
- face->root.style_name = NULL;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * T1_Face_Init
- *
- * @Description:
- * The face object constructor.
- *
- * @Input:
- * stream ::
- * Dummy argument for compatibility with the `FT_Face_InitFunc` API.
- * Ignored. The stream should be passed through `face->root.stream`.
- *
- * face_index ::
- * The index of the font face in the resource.
- *
- * num_params ::
- * Number of additional generic parameters. Ignored.
- *
- * params ::
- * Additional generic parameters. Ignored.
- *
- * @InOut:
- * face ::
- * The face record to build.
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
- FT_LOCAL_DEF( FT_Error )
- T1_Face_Init( FT_Stream stream,
- FT_Face t1face, /* T1_Face */
- FT_Int face_index,
- FT_Int num_params,
- FT_Parameter* params )
- {
- T1_Face face = (T1_Face)t1face;
- FT_Error error;
- FT_Service_PsCMaps psnames;
- PSAux_Service psaux;
- T1_Font type1 = &face->type1;
- PS_FontInfo info = &type1->font_info;
-
- FT_UNUSED( num_params );
- FT_UNUSED( params );
- FT_UNUSED( stream );
-
-
- face->root.num_faces = 1;
-
- FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS );
- face->psnames = psnames;
-
- face->psaux = FT_Get_Module_Interface( FT_FACE_LIBRARY( face ),
- "psaux" );
- psaux = (PSAux_Service)face->psaux;
- if ( !psaux )
- {
- FT_ERROR(( "T1_Face_Init: cannot access `psaux' module\n" ));
- error = FT_THROW( Missing_Module );
- goto Exit;
- }
-
- face->pshinter = FT_Get_Module_Interface( FT_FACE_LIBRARY( face ),
- "pshinter" );
-
- FT_TRACE2(( "Type 1 driver\n" ));
-
- /* open the tokenizer; this will also check the font format */
- error = T1_Open_Face( face );
- if ( error )
- goto Exit;
-
- FT_TRACE2(( "T1_Face_Init: %p (index %d)\n",
- (void *)face,
- face_index ));
-
- /* if we just wanted to check the format, leave successfully now */
- if ( face_index < 0 )
- goto Exit;
-
- /* check the face index */
- if ( ( face_index & 0xFFFF ) > 0 )
- {
- FT_ERROR(( "T1_Face_Init: invalid face index\n" ));
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- /* now load the font program into the face object */
-
- /* initialize the face object fields */
-
- /* set up root face fields */
- {
- FT_Face root = (FT_Face)&face->root;
-
-
- root->num_glyphs = type1->num_glyphs;
- root->face_index = 0;
-
- root->face_flags |= FT_FACE_FLAG_SCALABLE |
- FT_FACE_FLAG_HORIZONTAL |
- FT_FACE_FLAG_GLYPH_NAMES |
- FT_FACE_FLAG_HINTER;
-
- if ( info->is_fixed_pitch )
- root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
-
- if ( face->blend )
- root->face_flags |= FT_FACE_FLAG_MULTIPLE_MASTERS;
-
- /* The following code to extract the family and the style is very */
- /* simplistic and might get some things wrong. For a full-featured */
- /* algorithm you might have a look at the whitepaper given at */
- /* */
- /* https://blogs.msdn.com/text/archive/2007/04/23/wpf-font-selection-model.aspx */
-
- /* get style name -- be careful, some broken fonts only */
- /* have a `/FontName' dictionary entry! */
- root->family_name = info->family_name;
- root->style_name = NULL;
-
- if ( root->family_name )
- {
- char* full = info->full_name;
- char* family = root->family_name;
-
-
- if ( full )
- {
- FT_Bool the_same = TRUE;
-
-
- while ( *full )
- {
- if ( *full == *family )
- {
- family++;
- full++;
- }
- else
- {
- if ( *full == ' ' || *full == '-' )
- full++;
- else if ( *family == ' ' || *family == '-' )
- family++;
- else
- {
- the_same = FALSE;
-
- if ( !*family )
- root->style_name = full;
- break;
- }
- }
- }
-
- if ( the_same )
- root->style_name = (char *)"Regular";
- }
- }
- else
- {
- /* do we have a `/FontName'? */
- if ( type1->font_name )
- root->family_name = type1->font_name;
- }
-
- if ( !root->style_name )
- {
- if ( info->weight )
- root->style_name = info->weight;
- else
- /* assume `Regular' style because we don't know better */
- root->style_name = (char *)"Regular";
- }
-
- /* compute style flags */
- root->style_flags = 0;
- if ( info->italic_angle )
- root->style_flags |= FT_STYLE_FLAG_ITALIC;
- if ( info->weight )
- {
- if ( !ft_strcmp( info->weight, "Bold" ) ||
- !ft_strcmp( info->weight, "Black" ) )
- root->style_flags |= FT_STYLE_FLAG_BOLD;
- }
-
- /* no embedded bitmap support */
- root->num_fixed_sizes = 0;
- root->available_sizes = NULL;
-
- root->bbox.xMin = type1->font_bbox.xMin >> 16;
- root->bbox.yMin = type1->font_bbox.yMin >> 16;
- /* no `U' suffix here to 0xFFFF! */
- root->bbox.xMax = ( type1->font_bbox.xMax + 0xFFFF ) >> 16;
- root->bbox.yMax = ( type1->font_bbox.yMax + 0xFFFF ) >> 16;
-
- /* Set units_per_EM if we didn't set it in t1_parse_font_matrix. */
- if ( !root->units_per_EM )
- root->units_per_EM = 1000;
-
- root->ascender = (FT_Short)( root->bbox.yMax );
- root->descender = (FT_Short)( root->bbox.yMin );
-
- root->height = (FT_Short)( ( root->units_per_EM * 12 ) / 10 );
- if ( root->height < root->ascender - root->descender )
- root->height = (FT_Short)( root->ascender - root->descender );
-
- /* now compute the maximum advance width */
- root->max_advance_width =
- (FT_Short)( root->bbox.xMax );
- {
- FT_Pos max_advance;
-
-
- error = T1_Compute_Max_Advance( face, &max_advance );
-
- /* in case of error, keep the standard width */
- if ( !error )
- root->max_advance_width = (FT_Short)FIXED_TO_INT( max_advance );
- else
- error = FT_Err_Ok; /* clear error */
- }
-
- root->max_advance_height = root->height;
-
- root->underline_position = (FT_Short)info->underline_position;
- root->underline_thickness = (FT_Short)info->underline_thickness;
- }
-
- {
- FT_Face root = &face->root;
-
-
- if ( psnames )
- {
- FT_CharMapRec charmap;
- T1_CMap_Classes cmap_classes = psaux->t1_cmap_classes;
- FT_CMap_Class clazz;
-
-
- charmap.face = root;
-
- /* first of all, try to synthesize a Unicode charmap */
- charmap.platform_id = TT_PLATFORM_MICROSOFT;
- charmap.encoding_id = TT_MS_ID_UNICODE_CS;
- charmap.encoding = FT_ENCODING_UNICODE;
-
- error = FT_CMap_New( cmap_classes->unicode, NULL, &charmap, NULL );
- if ( error &&
- FT_ERR_NEQ( error, No_Unicode_Glyph_Name ) &&
- FT_ERR_NEQ( error, Unimplemented_Feature ) )
- goto Exit;
- error = FT_Err_Ok;
-
- /* now, generate an Adobe Standard encoding when appropriate */
- charmap.platform_id = TT_PLATFORM_ADOBE;
- clazz = NULL;
-
- switch ( type1->encoding_type )
- {
- case T1_ENCODING_TYPE_STANDARD:
- charmap.encoding = FT_ENCODING_ADOBE_STANDARD;
- charmap.encoding_id = TT_ADOBE_ID_STANDARD;
- clazz = cmap_classes->standard;
- break;
-
- case T1_ENCODING_TYPE_EXPERT:
- charmap.encoding = FT_ENCODING_ADOBE_EXPERT;
- charmap.encoding_id = TT_ADOBE_ID_EXPERT;
- clazz = cmap_classes->expert;
- break;
-
- case T1_ENCODING_TYPE_ARRAY:
- charmap.encoding = FT_ENCODING_ADOBE_CUSTOM;
- charmap.encoding_id = TT_ADOBE_ID_CUSTOM;
- clazz = cmap_classes->custom;
- break;
-
- case T1_ENCODING_TYPE_ISOLATIN1:
- charmap.encoding = FT_ENCODING_ADOBE_LATIN_1;
- charmap.encoding_id = TT_ADOBE_ID_LATIN_1;
- clazz = cmap_classes->unicode;
- break;
-
- default:
- ;
- }
-
- if ( clazz )
- error = FT_CMap_New( clazz, NULL, &charmap, NULL );
- }
- }
-
- Exit:
- return error;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * T1_Driver_Init
- *
- * @Description:
- * Initializes a given Type 1 driver object.
- *
- * @Input:
- * driver ::
- * A handle to the target driver object.
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
- FT_LOCAL_DEF( FT_Error )
- T1_Driver_Init( FT_Module module )
- {
- PS_Driver driver = (PS_Driver)module;
-
- FT_UInt32 seed;
-
-
- /* set default property values, cf. `ftt1drv.h' */
- driver->hinting_engine = FT_HINTING_ADOBE;
-
- driver->no_stem_darkening = TRUE;
-
- driver->darken_params[0] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1;
- driver->darken_params[1] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1;
- driver->darken_params[2] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2;
- driver->darken_params[3] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2;
- driver->darken_params[4] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3;
- driver->darken_params[5] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3;
- driver->darken_params[6] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4;
- driver->darken_params[7] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4;
-
- /* compute random seed from some memory addresses */
- seed = (FT_UInt32)( (FT_Offset)(char*)&seed ^
- (FT_Offset)(char*)&module ^
- (FT_Offset)(char*)module->memory );
- seed = seed ^ ( seed >> 10 ) ^ ( seed >> 20 );
-
- driver->random_seed = (FT_Int32)seed;
- if ( driver->random_seed < 0 )
- driver->random_seed = -driver->random_seed;
- else if ( driver->random_seed == 0 )
- driver->random_seed = 123456789;
-
- return FT_Err_Ok;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * T1_Driver_Done
- *
- * @Description:
- * Finalizes a given Type 1 driver.
- *
- * @Input:
- * driver ::
- * A handle to the target Type 1 driver.
- */
- FT_LOCAL_DEF( void )
- T1_Driver_Done( FT_Module driver )
- {
- FT_UNUSED( driver );
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/type1/t1objs.h b/contrib/libs/freetype/src/type1/t1objs.h
deleted file mode 100644
index 3809370c1e..0000000000
--- a/contrib/libs/freetype/src/type1/t1objs.h
+++ /dev/null
@@ -1,160 +0,0 @@
-/****************************************************************************
- *
- * t1objs.h
- *
- * Type 1 objects manager (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef T1OBJS_H_
-#define T1OBJS_H_
-
-
-#include <ft2build.h>
-#include <freetype/internal/ftobjs.h>
-#include FT_CONFIG_CONFIG_H
-#include <freetype/internal/t1types.h>
-
-
-FT_BEGIN_HEADER
-
-
- /* The following structures must be defined by the hinter */
- typedef struct T1_Size_Hints_ T1_Size_Hints;
- typedef struct T1_Glyph_Hints_ T1_Glyph_Hints;
-
-
- /**************************************************************************
- *
- * @Type:
- * T1_Size
- *
- * @Description:
- * A handle to a Type 1 size object.
- */
- typedef struct T1_SizeRec_* T1_Size;
-
-
- /**************************************************************************
- *
- * @Type:
- * T1_GlyphSlot
- *
- * @Description:
- * A handle to a Type 1 glyph slot object.
- */
- typedef struct T1_GlyphSlotRec_* T1_GlyphSlot;
-
-
- /**************************************************************************
- *
- * @Type:
- * T1_CharMap
- *
- * @Description:
- * A handle to a Type 1 character mapping object.
- *
- * @Note:
- * The Type 1 format doesn't use a charmap but an encoding table.
- * The driver is responsible for making up charmap objects
- * corresponding to these tables.
- */
- typedef struct T1_CharMapRec_* T1_CharMap;
-
-
- /**************************************************************************
- *
- * HERE BEGINS THE TYPE1 SPECIFIC STUFF
- *
- */
-
-
- /**************************************************************************
- *
- * @Type:
- * T1_SizeRec
- *
- * @Description:
- * Type 1 size record.
- */
- typedef struct T1_SizeRec_
- {
- FT_SizeRec root;
-
- } T1_SizeRec;
-
-
- FT_LOCAL( void )
- T1_Size_Done( FT_Size size );
-
- FT_LOCAL( FT_Error )
- T1_Size_Request( FT_Size size,
- FT_Size_Request req );
-
- FT_LOCAL( FT_Error )
- T1_Size_Init( FT_Size size );
-
-
- /**************************************************************************
- *
- * @Type:
- * T1_GlyphSlotRec
- *
- * @Description:
- * Type 1 glyph slot record.
- */
- typedef struct T1_GlyphSlotRec_
- {
- FT_GlyphSlotRec root;
-
- FT_Bool hint;
- FT_Bool scaled;
-
- FT_Fixed x_scale;
- FT_Fixed y_scale;
-
- FT_Int max_points;
- FT_Int max_contours;
-
- } T1_GlyphSlotRec;
-
-
- FT_LOCAL( FT_Error )
- T1_Face_Init( FT_Stream stream,
- FT_Face face,
- FT_Int face_index,
- FT_Int num_params,
- FT_Parameter* params );
-
- FT_LOCAL( void )
- T1_Face_Done( FT_Face face );
-
- FT_LOCAL( FT_Error )
- T1_GlyphSlot_Init( FT_GlyphSlot slot );
-
- FT_LOCAL( void )
- T1_GlyphSlot_Done( FT_GlyphSlot slot );
-
- FT_LOCAL( FT_Error )
- T1_Driver_Init( FT_Module driver );
-
- FT_LOCAL( void )
- T1_Driver_Done( FT_Module driver );
-
-
-FT_END_HEADER
-
-#endif /* T1OBJS_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/type1/t1parse.c b/contrib/libs/freetype/src/type1/t1parse.c
deleted file mode 100644
index 3717ea7c57..0000000000
--- a/contrib/libs/freetype/src/type1/t1parse.c
+++ /dev/null
@@ -1,487 +0,0 @@
-/****************************************************************************
- *
- * t1parse.c
- *
- * Type 1 parser (body).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /**************************************************************************
- *
- * The Type 1 parser is in charge of the following:
- *
- * - provide an implementation of a growing sequence of objects called
- * a `T1_Table' (used to build various tables needed by the loader).
- *
- * - opening .pfb and .pfa files to extract their top-level and private
- * dictionaries.
- *
- * - read numbers, arrays & strings from any dictionary.
- *
- * See `t1load.c' to see how data is loaded from the font file.
- *
- */
-
-
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/internal/psaux.h>
-
-#include "t1parse.h"
-
-#include "t1errors.h"
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT t1parse
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** INPUT STREAM PARSER *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /* see Adobe Technical Note 5040.Download_Fonts.pdf */
-
- static FT_Error
- read_pfb_tag( FT_Stream stream,
- FT_UShort *atag,
- FT_ULong *asize )
- {
- FT_Error error;
- FT_UShort tag;
- FT_ULong size;
-
-
- *atag = 0;
- *asize = 0;
-
- if ( !FT_READ_USHORT( tag ) )
- {
- if ( tag == 0x8001U || tag == 0x8002U )
- {
- if ( !FT_READ_ULONG_LE( size ) )
- *asize = size;
- }
-
- *atag = tag;
- }
-
- return error;
- }
-
-
- static FT_Error
- check_type1_format( FT_Stream stream,
- const char* header_string,
- size_t header_length )
- {
- FT_Error error;
- FT_UShort tag;
- FT_ULong dummy;
-
-
- if ( FT_STREAM_SEEK( 0 ) )
- goto Exit;
-
- error = read_pfb_tag( stream, &tag, &dummy );
- if ( error )
- goto Exit;
-
- /* We assume that the first segment in a PFB is always encoded as */
- /* text. This might be wrong (and the specification doesn't insist */
- /* on that), but we have never seen a counterexample. */
- if ( tag != 0x8001U && FT_STREAM_SEEK( 0 ) )
- goto Exit;
-
- if ( !FT_FRAME_ENTER( header_length ) )
- {
- error = FT_Err_Ok;
-
- if ( ft_memcmp( stream->cursor, header_string, header_length ) != 0 )
- error = FT_THROW( Unknown_File_Format );
-
- FT_FRAME_EXIT();
- }
-
- Exit:
- return error;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- T1_New_Parser( T1_Parser parser,
- FT_Stream stream,
- FT_Memory memory,
- PSAux_Service psaux )
- {
- FT_Error error;
- FT_UShort tag;
- FT_ULong size;
-
-
- psaux->ps_parser_funcs->init( &parser->root, NULL, NULL, memory );
-
- parser->stream = stream;
- parser->base_len = 0;
- parser->base_dict = NULL;
- parser->private_len = 0;
- parser->private_dict = NULL;
- parser->in_pfb = 0;
- parser->in_memory = 0;
- parser->single_block = 0;
-
- /* check the header format */
- error = check_type1_format( stream, "%!PS-AdobeFont", 14 );
- if ( error )
- {
- if ( FT_ERR_NEQ( error, Unknown_File_Format ) )
- goto Exit;
-
- error = check_type1_format( stream, "%!FontType", 10 );
- if ( error )
- {
- FT_TRACE2(( " not a Type 1 font\n" ));
- goto Exit;
- }
- }
-
- /*******************************************************************
- *
- * Here a short summary of what is going on:
- *
- * When creating a new Type 1 parser, we try to locate and load
- * the base dictionary if this is possible (i.e., for PFB
- * files). Otherwise, we load the whole font into memory.
- *
- * When `loading' the base dictionary, we only setup pointers
- * in the case of a memory-based stream. Otherwise, we
- * allocate and load the base dictionary in it.
- *
- * parser->in_pfb is set if we are in a binary (`.pfb') font.
- * parser->in_memory is set if we have a memory stream.
- */
-
- /* try to compute the size of the base dictionary; */
- /* look for a Postscript binary file tag, i.e., 0x8001 */
- if ( FT_STREAM_SEEK( 0L ) )
- goto Exit;
-
- error = read_pfb_tag( stream, &tag, &size );
- if ( error )
- goto Exit;
-
- if ( tag != 0x8001U )
- {
- /* assume that this is a PFA file for now; an error will */
- /* be produced later when more things are checked */
- if ( FT_STREAM_SEEK( 0L ) )
- goto Exit;
- size = stream->size;
- }
- else
- parser->in_pfb = 1;
-
- /* now, try to load `size' bytes of the `base' dictionary we */
- /* found previously */
-
- /* if it is a memory-based resource, set up pointers */
- if ( !stream->read )
- {
- parser->base_dict = (FT_Byte*)stream->base + stream->pos;
- parser->base_len = size;
- parser->in_memory = 1;
-
- /* check that the `size' field is valid */
- if ( FT_STREAM_SKIP( size ) )
- goto Exit;
- }
- else
- {
- /* read segment in memory -- this is clumsy, but so does the format */
- if ( FT_QALLOC( parser->base_dict, size ) ||
- FT_STREAM_READ( parser->base_dict, size ) )
- goto Exit;
- parser->base_len = size;
- }
-
- parser->root.base = parser->base_dict;
- parser->root.cursor = parser->base_dict;
- parser->root.limit = parser->root.cursor + parser->base_len;
-
- Exit:
- if ( error && !parser->in_memory )
- FT_FREE( parser->base_dict );
-
- return error;
- }
-
-
- FT_LOCAL_DEF( void )
- T1_Finalize_Parser( T1_Parser parser )
- {
- FT_Memory memory = parser->root.memory;
-
-
- /* always free the private dictionary */
- FT_FREE( parser->private_dict );
-
- /* free the base dictionary only when we have a disk stream */
- if ( !parser->in_memory )
- FT_FREE( parser->base_dict );
-
- parser->root.funcs.done( &parser->root );
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- T1_Get_Private_Dict( T1_Parser parser,
- PSAux_Service psaux )
- {
- FT_Stream stream = parser->stream;
- FT_Memory memory = parser->root.memory;
- FT_Error error = FT_Err_Ok;
- FT_ULong size;
-
-
- if ( parser->in_pfb )
- {
- /* in the case of the PFB format, the private dictionary can be */
- /* made of several segments. We thus first read the number of */
- /* segments to compute the total size of the private dictionary */
- /* then re-read them into memory. */
- FT_ULong start_pos = FT_STREAM_POS();
- FT_UShort tag;
-
-
- parser->private_len = 0;
- for (;;)
- {
- error = read_pfb_tag( stream, &tag, &size );
- if ( error )
- goto Fail;
-
- if ( tag != 0x8002U )
- break;
-
- parser->private_len += size;
-
- if ( FT_STREAM_SKIP( size ) )
- goto Fail;
- }
-
- /* Check that we have a private dictionary there */
- /* and allocate private dictionary buffer */
- if ( parser->private_len == 0 )
- {
- FT_ERROR(( "T1_Get_Private_Dict:"
- " invalid private dictionary section\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Fail;
- }
-
- if ( FT_STREAM_SEEK( start_pos ) ||
- FT_QALLOC( parser->private_dict, parser->private_len ) )
- goto Fail;
-
- parser->private_len = 0;
- for (;;)
- {
- error = read_pfb_tag( stream, &tag, &size );
- if ( error || tag != 0x8002U )
- {
- error = FT_Err_Ok;
- break;
- }
-
- if ( FT_STREAM_READ( parser->private_dict + parser->private_len,
- size ) )
- goto Fail;
-
- parser->private_len += size;
- }
- }
- else
- {
- /* We have already `loaded' the whole PFA font file into memory; */
- /* if this is a memory resource, allocate a new block to hold */
- /* the private dict. Otherwise, simply overwrite into the base */
- /* dictionary block in the heap. */
-
- /* First look for the `eexec' keyword. Ensure `eexec' is real -- */
- /* it could be in a comment or string (as e.g. in u003043t.gsf */
- /* from ghostscript). */
- FT_Byte* cur = parser->base_dict;
- FT_Byte* limit = cur + parser->base_len;
- FT_Pointer pos_lf;
- FT_Bool test_cr;
-
-
- parser->root.cursor = parser->base_dict;
- parser->root.limit = parser->base_dict + parser->base_len;
-
- cur = parser->root.cursor;
- limit = parser->root.limit;
-
- while ( cur < limit )
- {
- /* 9 = 5 letters for `eexec' + whitespace + 4 chars */
- if ( cur[0] == 'e' && cur + 9 < limit )
- {
- if ( cur[1] == 'e' &&
- cur[2] == 'x' &&
- cur[3] == 'e' &&
- cur[4] == 'c' )
- goto Found;
- }
-
- T1_Skip_PS_Token( parser );
- if ( parser->root.error )
- break;
- T1_Skip_Spaces ( parser );
- cur = parser->root.cursor;
- }
-
- FT_ERROR(( "T1_Get_Private_Dict: could not find `eexec' keyword\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
-
- /* now determine where to write the _encrypted_ binary private */
- /* dictionary. We overwrite the base dictionary for disk-based */
- /* resources and allocate a new block otherwise */
-
- Found:
- parser->root.limit = parser->base_dict + parser->base_len;
-
- T1_Skip_PS_Token( parser );
- cur = parser->root.cursor;
- limit = parser->root.limit;
-
- /* According to the Type 1 spec, the first cipher byte must not be */
- /* an ASCII whitespace character code (blank, tab, carriage return */
- /* or line feed). We have seen Type 1 fonts with two line feed */
- /* characters... So skip now all whitespace character codes. */
- /* */
- /* On the other hand, Adobe's Type 1 parser handles fonts just */
- /* fine that are violating this limitation, so we add a heuristic */
- /* test to stop at \r only if it is not used for EOL. */
-
- pos_lf = ft_memchr( cur, '\n', (size_t)( limit - cur ) );
- test_cr = FT_BOOL( !pos_lf ||
- pos_lf > ft_memchr( cur,
- '\r',
- (size_t)( limit - cur ) ) );
-
- while ( cur < limit &&
- ( *cur == ' ' ||
- *cur == '\t' ||
- (test_cr && *cur == '\r' ) ||
- *cur == '\n' ) )
- cur++;
- if ( cur >= limit )
- {
- FT_ERROR(( "T1_Get_Private_Dict:"
- " `eexec' not properly terminated\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- size = parser->base_len - (FT_ULong)( cur - parser->base_dict );
-
- if ( parser->in_memory )
- {
- /* note that we allocate one more byte to put a terminating `0' */
- if ( FT_QALLOC( parser->private_dict, size + 1 ) )
- goto Fail;
- parser->private_len = size;
- }
- else
- {
- parser->single_block = 1;
- parser->private_dict = parser->base_dict;
- parser->private_len = size;
- parser->base_dict = NULL;
- parser->base_len = 0;
- }
-
- /* now determine whether the private dictionary is encoded in binary */
- /* or hexadecimal ASCII format -- decode it accordingly */
-
- /* we need to access the next 4 bytes (after the final whitespace */
- /* following the `eexec' keyword); if they all are hexadecimal */
- /* digits, then we have a case of ASCII storage */
-
- if ( cur + 3 < limit &&
- ft_isxdigit( cur[0] ) && ft_isxdigit( cur[1] ) &&
- ft_isxdigit( cur[2] ) && ft_isxdigit( cur[3] ) )
- {
- /* ASCII hexadecimal encoding */
- FT_ULong len;
-
-
- parser->root.cursor = cur;
- (void)psaux->ps_parser_funcs->to_bytes( &parser->root,
- parser->private_dict,
- parser->private_len,
- &len,
- 0 );
- parser->private_len = len;
-
- /* put a safeguard */
- parser->private_dict[len] = '\0';
- }
- else
- /* binary encoding -- copy the private dict */
- FT_MEM_MOVE( parser->private_dict, cur, size );
- }
-
- /* we now decrypt the encoded binary private dictionary */
- psaux->t1_decrypt( parser->private_dict, parser->private_len, 55665U );
-
- if ( parser->private_len < 4 )
- {
- FT_ERROR(( "T1_Get_Private_Dict:"
- " invalid private dictionary section\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Fail;
- }
-
- /* replace the four random bytes at the beginning with whitespace */
- parser->private_dict[0] = ' ';
- parser->private_dict[1] = ' ';
- parser->private_dict[2] = ' ';
- parser->private_dict[3] = ' ';
-
- parser->root.base = parser->private_dict;
- parser->root.cursor = parser->private_dict;
- parser->root.limit = parser->root.cursor + parser->private_len;
-
- Fail:
- Exit:
- return error;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/type1/t1parse.h b/contrib/libs/freetype/src/type1/t1parse.h
deleted file mode 100644
index a0a2134d45..0000000000
--- a/contrib/libs/freetype/src/type1/t1parse.h
+++ /dev/null
@@ -1,137 +0,0 @@
-/****************************************************************************
- *
- * t1parse.h
- *
- * Type 1 parser (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef T1PARSE_H_
-#define T1PARSE_H_
-
-
-#include <freetype/internal/t1types.h>
-#include <freetype/internal/ftstream.h>
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @Struct:
- * T1_ParserRec
- *
- * @Description:
- * A PS_ParserRec is an object used to parse a Type 1 fonts very
- * quickly.
- *
- * @Fields:
- * root ::
- * The root parser.
- *
- * stream ::
- * The current input stream.
- *
- * base_dict ::
- * A pointer to the top-level dictionary.
- *
- * base_len ::
- * The length in bytes of the top dictionary.
- *
- * private_dict ::
- * A pointer to the private dictionary.
- *
- * private_len ::
- * The length in bytes of the private dictionary.
- *
- * in_pfb ::
- * A boolean. Indicates that we are handling a PFB
- * file.
- *
- * in_memory ::
- * A boolean. Indicates a memory-based stream.
- *
- * single_block ::
- * A boolean. Indicates that the private dictionary
- * is stored in lieu of the base dictionary.
- */
- typedef struct T1_ParserRec_
- {
- PS_ParserRec root;
- FT_Stream stream;
-
- FT_Byte* base_dict;
- FT_ULong base_len;
-
- FT_Byte* private_dict;
- FT_ULong private_len;
-
- FT_Bool in_pfb;
- FT_Bool in_memory;
- FT_Bool single_block;
-
- } T1_ParserRec, *T1_Parser;
-
-
-#define T1_Add_Table( p, i, o, l ) (p)->funcs.add( (p), i, o, l )
-#define T1_Release_Table( p ) \
- do \
- { \
- if ( (p)->funcs.release ) \
- (p)->funcs.release( p ); \
- } while ( 0 )
-
-
-#define T1_Skip_Spaces( p ) (p)->root.funcs.skip_spaces( &(p)->root )
-#define T1_Skip_PS_Token( p ) (p)->root.funcs.skip_PS_token( &(p)->root )
-
-#define T1_ToInt( p ) (p)->root.funcs.to_int( &(p)->root )
-#define T1_ToFixed( p, t ) (p)->root.funcs.to_fixed( &(p)->root, t )
-
-#define T1_ToCoordArray( p, m, c ) \
- (p)->root.funcs.to_coord_array( &(p)->root, m, c )
-#define T1_ToFixedArray( p, m, f, t ) \
- (p)->root.funcs.to_fixed_array( &(p)->root, m, f, t )
-#define T1_ToToken( p, t ) \
- (p)->root.funcs.to_token( &(p)->root, t )
-#define T1_ToTokenArray( p, t, m, c ) \
- (p)->root.funcs.to_token_array( &(p)->root, t, m, c )
-
-#define T1_Load_Field( p, f, o, m, pf ) \
- (p)->root.funcs.load_field( &(p)->root, f, o, m, pf )
-
-#define T1_Load_Field_Table( p, f, o, m, pf ) \
- (p)->root.funcs.load_field_table( &(p)->root, f, o, m, pf )
-
-
- FT_LOCAL( FT_Error )
- T1_New_Parser( T1_Parser parser,
- FT_Stream stream,
- FT_Memory memory,
- PSAux_Service psaux );
-
- FT_LOCAL( FT_Error )
- T1_Get_Private_Dict( T1_Parser parser,
- PSAux_Service psaux );
-
- FT_LOCAL( void )
- T1_Finalize_Parser( T1_Parser parser );
-
-
-FT_END_HEADER
-
-#endif /* T1PARSE_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/type1/t1tokens.h b/contrib/libs/freetype/src/type1/t1tokens.h
deleted file mode 100644
index 5a3d2f1ef0..0000000000
--- a/contrib/libs/freetype/src/type1/t1tokens.h
+++ /dev/null
@@ -1,143 +0,0 @@
-/****************************************************************************
- *
- * t1tokens.h
- *
- * Type 1 tokenizer (specification).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#undef FT_STRUCTURE
-#define FT_STRUCTURE PS_FontInfoRec
-#undef T1CODE
-#define T1CODE T1_FIELD_LOCATION_FONT_INFO
-
- T1_FIELD_STRING( "version", version,
- T1_FIELD_DICT_FONTDICT )
- T1_FIELD_STRING( "Notice", notice,
- T1_FIELD_DICT_FONTDICT )
- T1_FIELD_STRING( "FullName", full_name,
- T1_FIELD_DICT_FONTDICT )
- T1_FIELD_STRING( "FamilyName", family_name,
- T1_FIELD_DICT_FONTDICT )
- T1_FIELD_STRING( "Weight", weight,
- T1_FIELD_DICT_FONTDICT )
-
- /* we use pointers to detect modifications made by synthetic fonts */
- T1_FIELD_NUM ( "ItalicAngle", italic_angle,
- T1_FIELD_DICT_FONTDICT )
- T1_FIELD_BOOL ( "isFixedPitch", is_fixed_pitch,
- T1_FIELD_DICT_FONTDICT )
- T1_FIELD_NUM ( "UnderlinePosition", underline_position,
- T1_FIELD_DICT_FONTDICT )
- T1_FIELD_NUM ( "UnderlineThickness", underline_thickness,
- T1_FIELD_DICT_FONTDICT )
-
-#undef FT_STRUCTURE
-#define FT_STRUCTURE PS_FontExtraRec
-#undef T1CODE
-#define T1CODE T1_FIELD_LOCATION_FONT_EXTRA
-
- T1_FIELD_NUM ( "FSType", fs_type,
- T1_FIELD_DICT_FONTDICT )
-
-#undef FT_STRUCTURE
-#define FT_STRUCTURE PS_PrivateRec
-#undef T1CODE
-#define T1CODE T1_FIELD_LOCATION_PRIVATE
-
- T1_FIELD_NUM ( "UniqueID", unique_id,
- T1_FIELD_DICT_FONTDICT | T1_FIELD_DICT_PRIVATE )
- T1_FIELD_NUM ( "lenIV", lenIV,
- T1_FIELD_DICT_PRIVATE )
- T1_FIELD_NUM ( "LanguageGroup", language_group,
- T1_FIELD_DICT_PRIVATE )
- T1_FIELD_NUM ( "password", password,
- T1_FIELD_DICT_PRIVATE )
-
- T1_FIELD_FIXED_1000( "BlueScale", blue_scale,
- T1_FIELD_DICT_PRIVATE )
- T1_FIELD_NUM ( "BlueShift", blue_shift,
- T1_FIELD_DICT_PRIVATE )
- T1_FIELD_NUM ( "BlueFuzz", blue_fuzz,
- T1_FIELD_DICT_PRIVATE )
-
- T1_FIELD_NUM_TABLE ( "BlueValues", blue_values, 14,
- T1_FIELD_DICT_PRIVATE )
- T1_FIELD_NUM_TABLE ( "OtherBlues", other_blues, 10,
- T1_FIELD_DICT_PRIVATE )
- T1_FIELD_NUM_TABLE ( "FamilyBlues", family_blues, 14,
- T1_FIELD_DICT_PRIVATE )
- T1_FIELD_NUM_TABLE ( "FamilyOtherBlues", family_other_blues, 10,
- T1_FIELD_DICT_PRIVATE )
-
- T1_FIELD_NUM_TABLE2( "StdHW", standard_width, 1,
- T1_FIELD_DICT_PRIVATE )
- T1_FIELD_NUM_TABLE2( "StdVW", standard_height, 1,
- T1_FIELD_DICT_PRIVATE )
- T1_FIELD_NUM_TABLE2( "MinFeature", min_feature, 2,
- T1_FIELD_DICT_PRIVATE )
-
- T1_FIELD_NUM_TABLE ( "StemSnapH", snap_widths, 12,
- T1_FIELD_DICT_PRIVATE )
- T1_FIELD_NUM_TABLE ( "StemSnapV", snap_heights, 12,
- T1_FIELD_DICT_PRIVATE )
-
- T1_FIELD_FIXED ( "ExpansionFactor", expansion_factor,
- T1_FIELD_DICT_PRIVATE )
- T1_FIELD_BOOL ( "ForceBold", force_bold,
- T1_FIELD_DICT_PRIVATE )
-
-
-#undef FT_STRUCTURE
-#define FT_STRUCTURE T1_FontRec
-#undef T1CODE
-#define T1CODE T1_FIELD_LOCATION_FONT_DICT
-
- T1_FIELD_KEY ( "FontName", font_name, T1_FIELD_DICT_FONTDICT )
- T1_FIELD_NUM ( "PaintType", paint_type, T1_FIELD_DICT_FONTDICT )
- T1_FIELD_NUM ( "FontType", font_type, T1_FIELD_DICT_FONTDICT )
- T1_FIELD_FIXED( "StrokeWidth", stroke_width, T1_FIELD_DICT_FONTDICT )
-
-
-#undef FT_STRUCTURE
-#define FT_STRUCTURE FT_BBox
-#undef T1CODE
-#define T1CODE T1_FIELD_LOCATION_BBOX
-
- T1_FIELD_BBOX( "FontBBox", xMin, T1_FIELD_DICT_FONTDICT )
-
-
-#ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT
-
-#undef FT_STRUCTURE
-#define FT_STRUCTURE T1_FaceRec
-#undef T1CODE
-#define T1CODE T1_FIELD_LOCATION_FACE
-
- T1_FIELD_NUM( "NDV", ndv_idx, T1_FIELD_DICT_PRIVATE )
- T1_FIELD_NUM( "CDV", cdv_idx, T1_FIELD_DICT_PRIVATE )
-
-
-#undef FT_STRUCTURE
-#define FT_STRUCTURE PS_BlendRec
-#undef T1CODE
-#define T1CODE T1_FIELD_LOCATION_BLEND
-
- T1_FIELD_NUM_TABLE( "DesignVector", default_design_vector,
- T1_MAX_MM_DESIGNS, T1_FIELD_DICT_FONTDICT )
-
-
-#endif /* T1_CONFIG_OPTION_NO_MM_SUPPORT */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/type1/type1.c b/contrib/libs/freetype/src/type1/type1.c
deleted file mode 100644
index d7ff53c799..0000000000
--- a/contrib/libs/freetype/src/type1/type1.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/****************************************************************************
- *
- * type1.c
- *
- * FreeType Type 1 driver component (body only).
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#define FT_MAKE_OPTION_SINGLE_OBJECT
-
-#include "t1afm.c"
-#include "t1driver.c"
-#include "t1gload.c"
-#include "t1load.c"
-#include "t1objs.c"
-#include "t1parse.c"
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/type42/t42drivr.c b/contrib/libs/freetype/src/type42/t42drivr.c
deleted file mode 100644
index 25f507f150..0000000000
--- a/contrib/libs/freetype/src/type42/t42drivr.c
+++ /dev/null
@@ -1,248 +0,0 @@
-/****************************************************************************
- *
- * t42drivr.c
- *
- * High-level Type 42 driver interface (body).
- *
- * Copyright (C) 2002-2024 by
- * Roberto Alameda.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /**************************************************************************
- *
- * This driver implements Type42 fonts as described in the
- * Technical Note #5012 from Adobe, with these limitations:
- *
- * 1) CID Fonts are not currently supported.
- * 2) Incremental fonts making use of the GlyphDirectory keyword
- * will be loaded, but the rendering will be using the TrueType
- * tables.
- * 3) As for Type1 fonts, CDevProc is not supported.
- * 4) The Metrics dictionary is not supported.
- * 5) AFM metrics are not supported.
- *
- * In other words, this driver supports Type42 fonts derived from
- * TrueType fonts in a non-CID manner, as done by usual conversion
- * programs.
- *
- */
-
-
-#include "t42drivr.h"
-#include "t42objs.h"
-#include "t42error.h"
-#include <freetype/internal/ftdebug.h>
-
-#include <freetype/internal/services/svfntfmt.h>
-#include <freetype/internal/services/svgldict.h>
-#include <freetype/internal/services/svpostnm.h>
-#include <freetype/internal/services/svpsinfo.h>
-
-#undef FT_COMPONENT
-#define FT_COMPONENT t42
-
-
- /*
- *
- * GLYPH DICT SERVICE
- *
- */
-
- FT_CALLBACK_DEF( FT_Error )
- t42_get_glyph_name( FT_Face face, /* T42_Face */
- FT_UInt glyph_index,
- FT_Pointer buffer,
- FT_UInt buffer_max )
- {
- T42_Face t42face = (T42_Face)face;
-
-
- FT_STRCPYN( buffer,
- t42face->type1.glyph_names[glyph_index],
- buffer_max );
-
- return FT_Err_Ok;
- }
-
-
- FT_CALLBACK_DEF( FT_UInt )
- t42_get_name_index( FT_Face face, /* T42_Face */
- const FT_String* glyph_name )
- {
- T42_Face t42face = (T42_Face)face;
- FT_Int i;
-
-
- for ( i = 0; i < t42face->type1.num_glyphs; i++ )
- {
- FT_String* gname = t42face->type1.glyph_names[i];
-
-
- if ( glyph_name[0] == gname[0] && !ft_strcmp( glyph_name, gname ) )
- return (FT_UInt)ft_strtol(
- (const char *)t42face->type1.charstrings[i],
- NULL,
- 10 );
- }
-
- return 0;
- }
-
-
- static const FT_Service_GlyphDictRec t42_service_glyph_dict =
- {
- (FT_GlyphDict_GetNameFunc) t42_get_glyph_name, /* get_name */
- (FT_GlyphDict_NameIndexFunc)t42_get_name_index /* name_index */
- };
-
-
- /*
- *
- * POSTSCRIPT NAME SERVICE
- *
- */
-
- FT_CALLBACK_DEF( const char* )
- t42_get_ps_font_name( FT_Face face ) /* T42_Face */
- {
- T42_Face t42face = (T42_Face)face;
-
-
- return (const char*)t42face->type1.font_name;
- }
-
-
- static const FT_Service_PsFontNameRec t42_service_ps_font_name =
- {
- (FT_PsName_GetFunc)t42_get_ps_font_name /* get_ps_font_name */
- };
-
-
- /*
- *
- * POSTSCRIPT INFO SERVICE
- *
- */
-
- FT_CALLBACK_DEF( FT_Error )
- t42_ps_get_font_info( FT_Face face,
- PS_FontInfoRec* afont_info )
- {
- *afont_info = ((T42_Face)face)->type1.font_info;
-
- return FT_Err_Ok;
- }
-
-
- FT_CALLBACK_DEF( FT_Error )
- t42_ps_get_font_extra( FT_Face face,
- PS_FontExtraRec* afont_extra )
- {
- *afont_extra = ((T42_Face)face)->type1.font_extra;
-
- return FT_Err_Ok;
- }
-
-
- FT_CALLBACK_DEF( FT_Int )
- t42_ps_has_glyph_names( FT_Face face )
- {
- FT_UNUSED( face );
-
- return 1;
- }
-
-
- static const FT_Service_PsInfoRec t42_service_ps_info =
- {
- (PS_GetFontInfoFunc) t42_ps_get_font_info, /* ps_get_font_info */
- (PS_GetFontExtraFunc) t42_ps_get_font_extra, /* ps_get_font_extra */
- (PS_HasGlyphNamesFunc) t42_ps_has_glyph_names, /* ps_has_glyph_names */
- /* Type42 fonts don't have a Private dict */
- (PS_GetFontPrivateFunc)NULL, /* ps_get_font_private */
- /* not implemented */
- (PS_GetFontValueFunc) NULL /* ps_get_font_value */
- };
-
-
- /*
- *
- * SERVICE LIST
- *
- */
-
- static const FT_ServiceDescRec t42_services[] =
- {
- { FT_SERVICE_ID_GLYPH_DICT, &t42_service_glyph_dict },
- { FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &t42_service_ps_font_name },
- { FT_SERVICE_ID_POSTSCRIPT_INFO, &t42_service_ps_info },
- { FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_TYPE_42 },
- { NULL, NULL }
- };
-
-
- FT_CALLBACK_DEF( FT_Module_Interface )
- T42_Get_Interface( FT_Module module,
- const FT_String* t42_interface )
- {
- FT_UNUSED( module );
-
- return ft_service_list_lookup( t42_services, t42_interface );
- }
-
-
- const FT_Driver_ClassRec t42_driver_class =
- {
- {
- FT_MODULE_FONT_DRIVER |
- FT_MODULE_DRIVER_SCALABLE |
-#ifdef TT_USE_BYTECODE_INTERPRETER
- FT_MODULE_DRIVER_HAS_HINTER,
-#else
- 0,
-#endif
-
- sizeof ( T42_DriverRec ),
-
- "type42",
- 0x10000L,
- 0x20000L,
-
- NULL, /* module-specific interface */
-
- T42_Driver_Init, /* FT_Module_Constructor module_init */
- T42_Driver_Done, /* FT_Module_Destructor module_done */
- T42_Get_Interface, /* FT_Module_Requester get_interface */
- },
-
- sizeof ( T42_FaceRec ),
- sizeof ( T42_SizeRec ),
- sizeof ( T42_GlyphSlotRec ),
-
- T42_Face_Init, /* FT_Face_InitFunc init_face */
- T42_Face_Done, /* FT_Face_DoneFunc done_face */
- T42_Size_Init, /* FT_Size_InitFunc init_size */
- T42_Size_Done, /* FT_Size_DoneFunc done_size */
- T42_GlyphSlot_Init, /* FT_Slot_InitFunc init_slot */
- T42_GlyphSlot_Done, /* FT_Slot_DoneFunc done_slot */
-
- T42_GlyphSlot_Load, /* FT_Slot_LoadFunc load_glyph */
-
- NULL, /* FT_Face_GetKerningFunc get_kerning */
- NULL, /* FT_Face_AttachFunc attach_file */
- NULL, /* FT_Face_GetAdvancesFunc get_advances */
-
- T42_Size_Request, /* FT_Size_RequestFunc request_size */
- T42_Size_Select /* FT_Size_SelectFunc select_size */
- };
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/type42/t42drivr.h b/contrib/libs/freetype/src/type42/t42drivr.h
deleted file mode 100644
index 5b3852b864..0000000000
--- a/contrib/libs/freetype/src/type42/t42drivr.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/****************************************************************************
- *
- * t42drivr.h
- *
- * High-level Type 42 driver interface (specification).
- *
- * Copyright (C) 2002-2024 by
- * Roberto Alameda.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef T42DRIVR_H_
-#define T42DRIVR_H_
-
-
-#include <freetype/internal/ftdrv.h>
-
-
-FT_BEGIN_HEADER
-
- FT_EXPORT_VAR( const FT_Driver_ClassRec ) t42_driver_class;
-
-FT_END_HEADER
-
-
-#endif /* T42DRIVR_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/type42/t42error.h b/contrib/libs/freetype/src/type42/t42error.h
deleted file mode 100644
index f52205e2f0..0000000000
--- a/contrib/libs/freetype/src/type42/t42error.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/****************************************************************************
- *
- * t42error.h
- *
- * Type 42 error codes (specification only).
- *
- * Copyright (C) 2002-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /**************************************************************************
- *
- * This file is used to define the Type 42 error enumeration constants.
- *
- */
-
-#ifndef T42ERROR_H_
-#define T42ERROR_H_
-
-#include <freetype/ftmoderr.h>
-
-#undef FTERRORS_H_
-
-#undef FT_ERR_PREFIX
-#define FT_ERR_PREFIX T42_Err_
-#define FT_ERR_BASE FT_Mod_Err_Type42
-
-#include <freetype/fterrors.h>
-
-#endif /* T42ERROR_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/type42/t42objs.c b/contrib/libs/freetype/src/type42/t42objs.c
deleted file mode 100644
index 7010ba86ed..0000000000
--- a/contrib/libs/freetype/src/type42/t42objs.c
+++ /dev/null
@@ -1,698 +0,0 @@
-/****************************************************************************
- *
- * t42objs.c
- *
- * Type 42 objects manager (body).
- *
- * Copyright (C) 2002-2024 by
- * Roberto Alameda.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include "t42objs.h"
-#include "t42parse.h"
-#include "t42error.h"
-#include <freetype/internal/ftdebug.h>
-#include <freetype/ftlist.h>
-#include <freetype/ttnameid.h>
-
-
-#undef FT_COMPONENT
-#define FT_COMPONENT t42
-
-
- static FT_Error
- T42_Open_Face( T42_Face face )
- {
- T42_LoaderRec loader;
- T42_Parser parser;
- T1_Font type1 = &face->type1;
- FT_Memory memory = face->root.memory;
- FT_Error error;
-
- PSAux_Service psaux = (PSAux_Service)face->psaux;
-
-
- t42_loader_init( &loader, face );
-
- parser = &loader.parser;
-
- face->ttf_data = NULL;
- face->ttf_size = 0;
-
- error = t42_parser_init( parser,
- face->root.stream,
- memory,
- psaux);
- if ( error )
- goto Exit;
-
- error = t42_parse_dict( face, &loader,
- parser->base_dict, parser->base_len );
- if ( error )
- goto Exit;
-
- if ( type1->font_type != 42 )
- {
- FT_ERROR(( "T42_Open_Face: cannot handle FontType %d\n",
- type1->font_type ));
- error = FT_THROW( Unknown_File_Format );
- goto Exit;
- }
-
- /* now, propagate the charstrings and glyphnames tables */
- /* to the Type1 data */
- type1->num_glyphs = loader.num_glyphs;
-
- if ( !loader.charstrings.init )
- {
- FT_ERROR(( "T42_Open_Face: no charstrings array in face\n" ));
- error = FT_THROW( Invalid_File_Format );
- }
-
- loader.charstrings.init = 0;
- type1->charstrings_block = loader.charstrings.block;
- type1->charstrings = loader.charstrings.elements;
- type1->charstrings_len = loader.charstrings.lengths;
-
- /* we copy the glyph names `block' and `elements' fields; */
- /* the `lengths' field must be released later */
- type1->glyph_names_block = loader.glyph_names.block;
- type1->glyph_names = (FT_String**)loader.glyph_names.elements;
- loader.glyph_names.block = NULL;
- loader.glyph_names.elements = NULL;
-
- /* we must now build type1.encoding when we have a custom array */
- if ( type1->encoding_type == T1_ENCODING_TYPE_ARRAY )
- {
- FT_Int charcode, idx, min_char, max_char;
-
-
- /* OK, we do the following: for each element in the encoding */
- /* table, look up the index of the glyph having the same name */
- /* as defined in the CharStrings array. */
- /* The index is then stored in type1.encoding.char_index, and */
- /* the name in type1.encoding.char_name */
-
- min_char = 0;
- max_char = 0;
-
- charcode = 0;
- for ( ; charcode < loader.encoding_table.max_elems; charcode++ )
- {
- const FT_String* char_name =
- (const FT_String*)loader.encoding_table.elements[charcode];
-
-
- type1->encoding.char_index[charcode] = 0;
- type1->encoding.char_name [charcode] = ".notdef";
-
- if ( char_name )
- for ( idx = 0; idx < type1->num_glyphs; idx++ )
- {
- const FT_String* glyph_name = type1->glyph_names[idx];
-
-
- if ( ft_strcmp( char_name, glyph_name ) == 0 )
- {
- type1->encoding.char_index[charcode] = (FT_UShort)idx;
- type1->encoding.char_name [charcode] = glyph_name;
-
- /* Change min/max encoded char only if glyph name is */
- /* not /.notdef */
- if ( ft_strcmp( ".notdef", glyph_name ) != 0 )
- {
- if ( charcode < min_char )
- min_char = charcode;
- if ( charcode >= max_char )
- max_char = charcode + 1;
- }
- break;
- }
- }
- }
-
- type1->encoding.code_first = min_char;
- type1->encoding.code_last = max_char;
- type1->encoding.num_chars = loader.num_chars;
- }
-
- Exit:
- t42_loader_done( &loader );
- if ( error )
- {
- FT_FREE( face->ttf_data );
- face->ttf_size = 0;
- }
- return error;
- }
-
-
- /***************** Driver Functions *************/
-
-
- FT_LOCAL_DEF( FT_Error )
- T42_Face_Init( FT_Stream stream,
- FT_Face t42face, /* T42_Face */
- FT_Int face_index,
- FT_Int num_params,
- FT_Parameter* params )
- {
- T42_Face face = (T42_Face)t42face;
- FT_Error error;
- FT_Service_PsCMaps psnames;
- PSAux_Service psaux;
- FT_Face root = (FT_Face)&face->root;
- T1_Font type1 = &face->type1;
- PS_FontInfo info = &type1->font_info;
-
- FT_UNUSED( num_params );
- FT_UNUSED( params );
- FT_UNUSED( stream );
-
-
- face->ttf_face = NULL;
- face->root.num_faces = 1;
-
- FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS );
- face->psnames = psnames;
-
- face->psaux = FT_Get_Module_Interface( FT_FACE_LIBRARY( face ),
- "psaux" );
- psaux = (PSAux_Service)face->psaux;
- if ( !psaux )
- {
- FT_ERROR(( "T42_Face_Init: cannot access `psaux' module\n" ));
- error = FT_THROW( Missing_Module );
- goto Exit;
- }
-
- FT_TRACE2(( "Type 42 driver\n" ));
-
- /* open the tokenizer, this will also check the font format */
- error = T42_Open_Face( face );
- if ( error )
- goto Exit;
-
- /* if we just wanted to check the format, leave successfully now */
- if ( face_index < 0 )
- goto Exit;
-
- /* check the face index */
- if ( ( face_index & 0xFFFF ) > 0 )
- {
- FT_ERROR(( "T42_Face_Init: invalid face index\n" ));
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- /* Now load the font program into the face object */
-
- /* Init the face object fields */
- /* Now set up root face fields */
-
- root->num_glyphs = type1->num_glyphs;
- root->num_charmaps = 0;
- root->face_index = 0;
-
- root->face_flags |= FT_FACE_FLAG_SCALABLE |
- FT_FACE_FLAG_HORIZONTAL |
- FT_FACE_FLAG_GLYPH_NAMES;
-
- if ( info->is_fixed_pitch )
- root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
-
-#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
- root->face_flags |= FT_FACE_FLAG_HINTER;
-#endif
-
- /* XXX: TODO -- add kerning with .afm support */
-
- /* get style name -- be careful, some broken fonts only */
- /* have a `/FontName' dictionary entry! */
- root->family_name = info->family_name;
- /* assume "Regular" style if we don't know better */
- root->style_name = (char *)"Regular";
- if ( root->family_name )
- {
- char* full = info->full_name;
- char* family = root->family_name;
-
-
- if ( full )
- {
- while ( *full )
- {
- if ( *full == *family )
- {
- family++;
- full++;
- }
- else
- {
- if ( *full == ' ' || *full == '-' )
- full++;
- else if ( *family == ' ' || *family == '-' )
- family++;
- else
- {
- if ( !*family )
- root->style_name = full;
- break;
- }
- }
- }
- }
- }
- else
- {
- /* do we have a `/FontName'? */
- if ( type1->font_name )
- root->family_name = type1->font_name;
- }
-
- /* no embedded bitmap support */
- root->num_fixed_sizes = 0;
- root->available_sizes = NULL;
-
- /* Load the TTF font embedded in the T42 font */
- {
- FT_Open_Args args;
-
-
- args.flags = FT_OPEN_MEMORY | FT_OPEN_DRIVER;
- args.driver = FT_Get_Module( FT_FACE_LIBRARY( face ),
- "truetype" );
- args.memory_base = face->ttf_data;
- args.memory_size = face->ttf_size;
-
- if ( num_params )
- {
- args.flags |= FT_OPEN_PARAMS;
- args.num_params = num_params;
- args.params = params;
- }
-
- error = FT_Open_Face( FT_FACE_LIBRARY( face ),
- &args, 0, &face->ttf_face );
- }
-
- if ( error )
- goto Exit;
-
- FT_Done_Size( face->ttf_face->size );
-
- /* Ignore info in FontInfo dictionary and use the info from the */
- /* loaded TTF font. The PostScript interpreter also ignores it. */
- root->bbox = face->ttf_face->bbox;
- root->units_per_EM = face->ttf_face->units_per_EM;
-
- root->ascender = face->ttf_face->ascender;
- root->descender = face->ttf_face->descender;
- root->height = face->ttf_face->height;
-
- root->max_advance_width = face->ttf_face->max_advance_width;
- root->max_advance_height = face->ttf_face->max_advance_height;
-
- root->underline_position = (FT_Short)info->underline_position;
- root->underline_thickness = (FT_Short)info->underline_thickness;
-
- /* compute style flags */
- root->style_flags = 0;
- if ( info->italic_angle )
- root->style_flags |= FT_STYLE_FLAG_ITALIC;
-
- if ( face->ttf_face->style_flags & FT_STYLE_FLAG_BOLD )
- root->style_flags |= FT_STYLE_FLAG_BOLD;
-
- if ( face->ttf_face->face_flags & FT_FACE_FLAG_VERTICAL )
- root->face_flags |= FT_FACE_FLAG_VERTICAL;
-
- {
- if ( psnames )
- {
- FT_CharMapRec charmap;
- T1_CMap_Classes cmap_classes = psaux->t1_cmap_classes;
- FT_CMap_Class clazz;
-
-
- charmap.face = root;
-
- /* first of all, try to synthesize a Unicode charmap */
- charmap.platform_id = TT_PLATFORM_MICROSOFT;
- charmap.encoding_id = TT_MS_ID_UNICODE_CS;
- charmap.encoding = FT_ENCODING_UNICODE;
-
- error = FT_CMap_New( cmap_classes->unicode, NULL, &charmap, NULL );
- if ( error &&
- FT_ERR_NEQ( error, No_Unicode_Glyph_Name ) &&
- FT_ERR_NEQ( error, Unimplemented_Feature ) )
- goto Exit;
- error = FT_Err_Ok;
-
- /* now, generate an Adobe Standard encoding when appropriate */
- charmap.platform_id = TT_PLATFORM_ADOBE;
- clazz = NULL;
-
- switch ( type1->encoding_type )
- {
- case T1_ENCODING_TYPE_STANDARD:
- charmap.encoding = FT_ENCODING_ADOBE_STANDARD;
- charmap.encoding_id = TT_ADOBE_ID_STANDARD;
- clazz = cmap_classes->standard;
- break;
-
- case T1_ENCODING_TYPE_EXPERT:
- charmap.encoding = FT_ENCODING_ADOBE_EXPERT;
- charmap.encoding_id = TT_ADOBE_ID_EXPERT;
- clazz = cmap_classes->expert;
- break;
-
- case T1_ENCODING_TYPE_ARRAY:
- charmap.encoding = FT_ENCODING_ADOBE_CUSTOM;
- charmap.encoding_id = TT_ADOBE_ID_CUSTOM;
- clazz = cmap_classes->custom;
- break;
-
- case T1_ENCODING_TYPE_ISOLATIN1:
- charmap.encoding = FT_ENCODING_ADOBE_LATIN_1;
- charmap.encoding_id = TT_ADOBE_ID_LATIN_1;
- clazz = cmap_classes->unicode;
- break;
-
- default:
- ;
- }
-
- if ( clazz )
- error = FT_CMap_New( clazz, NULL, &charmap, NULL );
- }
- }
- Exit:
- return error;
- }
-
-
- FT_LOCAL_DEF( void )
- T42_Face_Done( FT_Face t42face )
- {
- T42_Face face = (T42_Face)t42face;
- T1_Font type1;
- PS_FontInfo info;
- FT_Memory memory;
-
-
- if ( !face )
- return;
-
- type1 = &face->type1;
- info = &type1->font_info;
- memory = face->root.memory;
-
- /* delete internal ttf face prior to freeing face->ttf_data */
- if ( face->ttf_face )
- FT_Done_Face( face->ttf_face );
-
- /* release font info strings */
- FT_FREE( info->version );
- FT_FREE( info->notice );
- FT_FREE( info->full_name );
- FT_FREE( info->family_name );
- FT_FREE( info->weight );
-
- /* release top dictionary */
- FT_FREE( type1->charstrings_len );
- FT_FREE( type1->charstrings );
- FT_FREE( type1->glyph_names );
-
- FT_FREE( type1->charstrings_block );
- FT_FREE( type1->glyph_names_block );
-
- FT_FREE( type1->encoding.char_index );
- FT_FREE( type1->encoding.char_name );
- FT_FREE( type1->font_name );
-
- FT_FREE( face->ttf_data );
-
-#if 0
- /* release afm data if present */
- if ( face->afm_data )
- T1_Done_AFM( memory, (T1_AFM*)face->afm_data );
-#endif
-
- /* release unicode map, if any */
- FT_FREE( face->unicode_map.maps );
- face->unicode_map.num_maps = 0;
-
- face->root.family_name = NULL;
- face->root.style_name = NULL;
- }
-
-
- /**************************************************************************
- *
- * @Function:
- * T42_Driver_Init
- *
- * @Description:
- * Initializes a given Type 42 driver object.
- *
- * @Input:
- * driver ::
- * A handle to the target driver object.
- *
- * @Return:
- * FreeType error code. 0 means success.
- */
- FT_LOCAL_DEF( FT_Error )
- T42_Driver_Init( FT_Module module ) /* T42_Driver */
- {
- T42_Driver driver = (T42_Driver)module;
- FT_Module ttmodule;
-
-
- ttmodule = FT_Get_Module( module->library, "truetype" );
- if ( !ttmodule )
- {
- FT_ERROR(( "T42_Driver_Init: cannot access `truetype' module\n" ));
- return FT_THROW( Missing_Module );
- }
-
- driver->ttclazz = (FT_Driver_Class)ttmodule->clazz;
-
- return FT_Err_Ok;
- }
-
-
- FT_LOCAL_DEF( void )
- T42_Driver_Done( FT_Module module )
- {
- FT_UNUSED( module );
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- T42_Size_Init( FT_Size size ) /* T42_Size */
- {
- T42_Size t42size = (T42_Size)size;
- FT_Face face = size->face;
- T42_Face t42face = (T42_Face)face;
- FT_Size ttsize;
- FT_Error error;
-
-
- error = FT_New_Size( t42face->ttf_face, &ttsize );
- if ( !error )
- t42size->ttsize = ttsize;
-
- FT_Activate_Size( ttsize );
-
- return error;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- T42_Size_Request( FT_Size t42size, /* T42_Size */
- FT_Size_Request req )
- {
- T42_Size size = (T42_Size)t42size;
- T42_Face face = (T42_Face)t42size->face;
- FT_Error error;
-
-
- FT_Activate_Size( size->ttsize );
-
- error = FT_Request_Size( face->ttf_face, req );
- if ( !error )
- t42size->metrics = face->ttf_face->size->metrics;
-
- return error;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- T42_Size_Select( FT_Size t42size, /* T42_Size */
- FT_ULong strike_index )
- {
- T42_Size size = (T42_Size)t42size;
- T42_Face face = (T42_Face)t42size->face;
- FT_Error error;
-
-
- FT_Activate_Size( size->ttsize );
-
- error = FT_Select_Size( face->ttf_face, (FT_Int)strike_index );
- if ( !error )
- t42size->metrics = face->ttf_face->size->metrics;
-
- return error;
-
- }
-
-
- FT_LOCAL_DEF( void )
- T42_Size_Done( FT_Size t42size ) /* T42_Size */
- {
- T42_Size size = (T42_Size)t42size;
- FT_Face face = t42size->face;
- T42_Face t42face = (T42_Face)face;
- FT_ListNode node;
-
-
- node = FT_List_Find( &t42face->ttf_face->sizes_list, size->ttsize );
- if ( node )
- {
- FT_Done_Size( size->ttsize );
- size->ttsize = NULL;
- }
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- T42_GlyphSlot_Init( FT_GlyphSlot t42slot ) /* T42_GlyphSlot */
- {
- T42_GlyphSlot slot = (T42_GlyphSlot)t42slot;
- FT_Face face = t42slot->face;
- T42_Face t42face = (T42_Face)face;
- FT_GlyphSlot ttslot;
- FT_Memory memory = face->memory;
- FT_Error error = FT_Err_Ok;
-
-
- if ( !face->glyph )
- {
- /* First glyph slot for this face */
- slot->ttslot = t42face->ttf_face->glyph;
- }
- else
- {
- error = FT_New_GlyphSlot( t42face->ttf_face, &ttslot );
- if ( !error )
- slot->ttslot = ttslot;
- }
-
- /* share the loader so that the autohinter can see it */
- FT_GlyphLoader_Done( slot->ttslot->internal->loader );
- FT_FREE( slot->ttslot->internal );
- slot->ttslot->internal = t42slot->internal;
-
- return error;
- }
-
-
- FT_LOCAL_DEF( void )
- T42_GlyphSlot_Done( FT_GlyphSlot t42slot ) /* T42_GlyphSlot */
- {
- T42_GlyphSlot slot = (T42_GlyphSlot)t42slot;
-
-
- /* do not destroy the inherited internal structure just yet */
- slot->ttslot->internal = NULL;
- FT_Done_GlyphSlot( slot->ttslot );
- }
-
-
- static void
- t42_glyphslot_clear( FT_GlyphSlot slot )
- {
- /* free bitmap if needed */
- ft_glyphslot_free_bitmap( slot );
-
- /* clear all public fields in the glyph slot */
- FT_ZERO( &slot->metrics );
- FT_ZERO( &slot->outline );
- FT_ZERO( &slot->bitmap );
-
- slot->bitmap_left = 0;
- slot->bitmap_top = 0;
- slot->num_subglyphs = 0;
- slot->subglyphs = NULL;
- slot->control_data = NULL;
- slot->control_len = 0;
- slot->other = NULL;
- slot->format = FT_GLYPH_FORMAT_NONE;
-
- slot->linearHoriAdvance = 0;
- slot->linearVertAdvance = 0;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- T42_GlyphSlot_Load( FT_GlyphSlot glyph,
- FT_Size size,
- FT_UInt glyph_index,
- FT_Int32 load_flags )
- {
- FT_Error error;
- T42_GlyphSlot t42slot = (T42_GlyphSlot)glyph;
- T42_Size t42size = (T42_Size)size;
- T42_Face t42face = (T42_Face)size->face;
- FT_Driver_Class ttclazz = ((T42_Driver)glyph->face->driver)->ttclazz;
-
-
- FT_TRACE1(( "T42_GlyphSlot_Load: glyph index %d\n", glyph_index ));
-
- /* map T42 glyph index to embedded TTF's glyph index */
- glyph_index = (FT_UInt)ft_strtol(
- (const char *)t42face->type1.charstrings[glyph_index],
- NULL, 10 );
-
- t42_glyphslot_clear( t42slot->ttslot );
- error = ttclazz->load_glyph( t42slot->ttslot,
- t42size->ttsize,
- glyph_index,
- load_flags | FT_LOAD_NO_BITMAP );
-
- if ( !error )
- {
- glyph->metrics = t42slot->ttslot->metrics;
-
- glyph->linearHoriAdvance = t42slot->ttslot->linearHoriAdvance;
- glyph->linearVertAdvance = t42slot->ttslot->linearVertAdvance;
-
- glyph->format = t42slot->ttslot->format;
- glyph->outline = t42slot->ttslot->outline;
-
- glyph->bitmap = t42slot->ttslot->bitmap;
- glyph->bitmap_left = t42slot->ttslot->bitmap_left;
- glyph->bitmap_top = t42slot->ttslot->bitmap_top;
-
- glyph->num_subglyphs = t42slot->ttslot->num_subglyphs;
- glyph->subglyphs = t42slot->ttslot->subglyphs;
-
- glyph->control_data = t42slot->ttslot->control_data;
- glyph->control_len = t42slot->ttslot->control_len;
- }
-
- return error;
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/type42/t42objs.h b/contrib/libs/freetype/src/type42/t42objs.h
deleted file mode 100644
index 3ca83bc54e..0000000000
--- a/contrib/libs/freetype/src/type42/t42objs.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/****************************************************************************
- *
- * t42objs.h
- *
- * Type 42 objects manager (specification).
- *
- * Copyright (C) 2002-2024 by
- * Roberto Alameda.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef T42OBJS_H_
-#define T42OBJS_H_
-
-#include <freetype/freetype.h>
-#include <freetype/t1tables.h>
-#include <freetype/internal/t1types.h>
-#include "t42types.h"
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/ftdrv.h>
-#include <freetype/internal/services/svpscmap.h>
-#include <freetype/internal/pshints.h>
-
-
-FT_BEGIN_HEADER
-
-
- /* Type42 size */
- typedef struct T42_SizeRec_
- {
- FT_SizeRec root;
- FT_Size ttsize;
-
- } T42_SizeRec, *T42_Size;
-
-
- /* Type42 slot */
- typedef struct T42_GlyphSlotRec_
- {
- FT_GlyphSlotRec root;
- FT_GlyphSlot ttslot;
-
- } T42_GlyphSlotRec, *T42_GlyphSlot;
-
-
- /* Type 42 driver */
- typedef struct T42_DriverRec_
- {
- FT_DriverRec root;
- FT_Driver_Class ttclazz;
-
- } T42_DriverRec, *T42_Driver;
-
-
- /* */
-
-
- FT_LOCAL( FT_Error )
- T42_Face_Init( FT_Stream stream,
- FT_Face face,
- FT_Int face_index,
- FT_Int num_params,
- FT_Parameter* params );
-
-
- FT_LOCAL( void )
- T42_Face_Done( FT_Face face );
-
-
- FT_LOCAL( FT_Error )
- T42_Size_Init( FT_Size size );
-
-
- FT_LOCAL( FT_Error )
- T42_Size_Request( FT_Size size,
- FT_Size_Request req );
-
-
- FT_LOCAL( FT_Error )
- T42_Size_Select( FT_Size size,
- FT_ULong strike_index );
-
-
- FT_LOCAL( void )
- T42_Size_Done( FT_Size size );
-
-
- FT_LOCAL( FT_Error )
- T42_GlyphSlot_Init( FT_GlyphSlot slot );
-
-
- FT_LOCAL( FT_Error )
- T42_GlyphSlot_Load( FT_GlyphSlot glyph,
- FT_Size size,
- FT_UInt glyph_index,
- FT_Int32 load_flags );
-
- FT_LOCAL( void )
- T42_GlyphSlot_Done( FT_GlyphSlot slot );
-
-
- FT_LOCAL( FT_Error )
- T42_Driver_Init( FT_Module module );
-
- FT_LOCAL( void )
- T42_Driver_Done( FT_Module module );
-
- /* */
-
-FT_END_HEADER
-
-
-#endif /* T42OBJS_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/type42/t42parse.c b/contrib/libs/freetype/src/type42/t42parse.c
deleted file mode 100644
index e53d352873..0000000000
--- a/contrib/libs/freetype/src/type42/t42parse.c
+++ /dev/null
@@ -1,1351 +0,0 @@
-/****************************************************************************
- *
- * t42parse.c
- *
- * Type 42 font parser (body).
- *
- * Copyright (C) 2002-2024 by
- * Roberto Alameda.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include "t42parse.h"
-#include "t42error.h"
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/internal/psaux.h>
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT t42
-
-
- static void
- t42_parse_font_matrix( FT_Face face,
- void* loader_ );
- static void
- t42_parse_encoding( FT_Face face,
- void* loader_ );
-
- static void
- t42_parse_charstrings( FT_Face face,
- void* loader_ );
-
- static void
- t42_parse_sfnts( FT_Face face,
- void* loader_ );
-
-
- /* as Type42 fonts have no Private dict, */
- /* we set the last argument of T1_FIELD_XXX to 0 */
- static const
- T1_FieldRec t42_keywords[] =
- {
-
-#undef FT_STRUCTURE
-#define FT_STRUCTURE T1_FontInfo
-#undef T1CODE
-#define T1CODE T1_FIELD_LOCATION_FONT_INFO
-
- T1_FIELD_STRING( "version", version, 0 )
- T1_FIELD_STRING( "Notice", notice, 0 )
- T1_FIELD_STRING( "FullName", full_name, 0 )
- T1_FIELD_STRING( "FamilyName", family_name, 0 )
- T1_FIELD_STRING( "Weight", weight, 0 )
- T1_FIELD_NUM ( "ItalicAngle", italic_angle, 0 )
- T1_FIELD_BOOL ( "isFixedPitch", is_fixed_pitch, 0 )
- T1_FIELD_NUM ( "UnderlinePosition", underline_position, 0 )
- T1_FIELD_NUM ( "UnderlineThickness", underline_thickness, 0 )
-
-#undef FT_STRUCTURE
-#define FT_STRUCTURE PS_FontExtraRec
-#undef T1CODE
-#define T1CODE T1_FIELD_LOCATION_FONT_EXTRA
-
- T1_FIELD_NUM ( "FSType", fs_type, 0 )
-
-#undef FT_STRUCTURE
-#define FT_STRUCTURE T1_FontRec
-#undef T1CODE
-#define T1CODE T1_FIELD_LOCATION_FONT_DICT
-
- T1_FIELD_KEY ( "FontName", font_name, 0 )
- T1_FIELD_NUM ( "PaintType", paint_type, 0 )
- T1_FIELD_NUM ( "FontType", font_type, 0 )
- T1_FIELD_FIXED( "StrokeWidth", stroke_width, 0 )
-
-#undef FT_STRUCTURE
-#define FT_STRUCTURE FT_BBox
-#undef T1CODE
-#define T1CODE T1_FIELD_LOCATION_BBOX
-
- T1_FIELD_BBOX( "FontBBox", xMin, 0 )
-
- T1_FIELD_CALLBACK( "FontMatrix", t42_parse_font_matrix, 0 )
- T1_FIELD_CALLBACK( "Encoding", t42_parse_encoding, 0 )
- T1_FIELD_CALLBACK( "CharStrings", t42_parse_charstrings, 0 )
- T1_FIELD_CALLBACK( "sfnts", t42_parse_sfnts, 0 )
-
- T1_FIELD_ZERO
- };
-
-
-#define T1_Add_Table( p, i, o, l ) (p)->funcs.add( (p), i, o, l )
-#define T1_Release_Table( p ) \
- do \
- { \
- if ( (p)->funcs.release ) \
- (p)->funcs.release( p ); \
- } while ( 0 )
-
-#define T1_Skip_Spaces( p ) (p)->root.funcs.skip_spaces( &(p)->root )
-#define T1_Skip_PS_Token( p ) (p)->root.funcs.skip_PS_token( &(p)->root )
-
-#define T1_ToInt( p ) \
- (p)->root.funcs.to_int( &(p)->root )
-#define T1_ToBytes( p, b, m, n, d ) \
- (p)->root.funcs.to_bytes( &(p)->root, b, m, n, d )
-
-#define T1_ToFixedArray( p, m, f, t ) \
- (p)->root.funcs.to_fixed_array( &(p)->root, m, f, t )
-#define T1_ToToken( p, t ) \
- (p)->root.funcs.to_token( &(p)->root, t )
-
-#define T1_Load_Field( p, f, o, m, pf ) \
- (p)->root.funcs.load_field( &(p)->root, f, o, m, pf )
-#define T1_Load_Field_Table( p, f, o, m, pf ) \
- (p)->root.funcs.load_field_table( &(p)->root, f, o, m, pf )
-
-
- /********************* Parsing Functions ******************/
-
- FT_LOCAL_DEF( FT_Error )
- t42_parser_init( T42_Parser parser,
- FT_Stream stream,
- FT_Memory memory,
- PSAux_Service psaux )
- {
- FT_Error error = FT_Err_Ok;
- FT_Long size;
-
-
- psaux->ps_parser_funcs->init( &parser->root, NULL, NULL, memory );
-
- parser->stream = stream;
- parser->base_len = 0;
- parser->base_dict = NULL;
- parser->in_memory = 0;
-
- /********************************************************************
- *
- * Here a short summary of what is going on:
- *
- * When creating a new Type 42 parser, we try to locate and load
- * the base dictionary, loading the whole font into memory.
- *
- * When `loading' the base dictionary, we only set up pointers
- * in the case of a memory-based stream. Otherwise, we allocate
- * and load the base dictionary in it.
- *
- * parser->in_memory is set if we have a memory stream.
- */
-
- if ( FT_STREAM_SEEK( 0L ) ||
- FT_FRAME_ENTER( 17 ) )
- goto Exit;
-
- if ( ft_memcmp( stream->cursor, "%!PS-TrueTypeFont", 17 ) != 0 )
- {
- FT_TRACE2(( " not a Type42 font\n" ));
- error = FT_THROW( Unknown_File_Format );
- }
-
- FT_FRAME_EXIT();
-
- if ( error || FT_STREAM_SEEK( 0 ) )
- goto Exit;
-
- size = (FT_Long)stream->size;
-
- /* now, try to load `size' bytes of the `base' dictionary we */
- /* found previously */
-
- /* if it is a memory-based resource, set up pointers */
- if ( !stream->read )
- {
- parser->base_dict = (FT_Byte*)stream->base + stream->pos;
- parser->base_len = size;
- parser->in_memory = 1;
-
- /* check that the `size' field is valid */
- if ( FT_STREAM_SKIP( size ) )
- goto Exit;
- }
- else
- {
- /* read segment in memory */
- if ( FT_QALLOC( parser->base_dict, size ) ||
- FT_STREAM_READ( parser->base_dict, size ) )
- goto Exit;
-
- parser->base_len = size;
- }
-
- parser->root.base = parser->base_dict;
- parser->root.cursor = parser->base_dict;
- parser->root.limit = parser->root.cursor + parser->base_len;
-
- Exit:
- if ( error && !parser->in_memory )
- FT_FREE( parser->base_dict );
-
- return error;
- }
-
-
- FT_LOCAL_DEF( void )
- t42_parser_done( T42_Parser parser )
- {
- FT_Memory memory = parser->root.memory;
-
-
- /* free the base dictionary only when we have a disk stream */
- if ( !parser->in_memory )
- FT_FREE( parser->base_dict );
-
- if ( parser->root.funcs.done )
- parser->root.funcs.done( &parser->root );
- }
-
-
- static int
- t42_is_space( FT_Byte c )
- {
- return ( c == ' ' || c == '\t' ||
- c == '\r' || c == '\n' || c == '\f' ||
- c == '\0' );
- }
-
-
- static void
- t42_parse_font_matrix( FT_Face face, /* T42_Face */
- void* loader_ )
- {
- T42_Face t42face = (T42_Face)face;
- T42_Loader loader = (T42_Loader)loader_;
- T42_Parser parser = &loader->parser;
- FT_Matrix* matrix = &t42face->type1.font_matrix;
- FT_Vector* offset = &t42face->type1.font_offset;
- FT_Fixed temp[6];
- FT_Fixed temp_scale;
- FT_Int result;
-
-
- result = T1_ToFixedArray( parser, 6, temp, 0 );
-
- if ( result < 6 )
- {
- parser->root.error = FT_THROW( Invalid_File_Format );
- return;
- }
-
- temp_scale = FT_ABS( temp[3] );
-
- if ( temp_scale == 0 )
- {
- FT_ERROR(( "t42_parse_font_matrix: invalid font matrix\n" ));
- parser->root.error = FT_THROW( Invalid_File_Format );
- return;
- }
-
- /* atypical case */
- if ( temp_scale != 0x10000L )
- {
- temp[0] = FT_DivFix( temp[0], temp_scale );
- temp[1] = FT_DivFix( temp[1], temp_scale );
- temp[2] = FT_DivFix( temp[2], temp_scale );
- temp[4] = FT_DivFix( temp[4], temp_scale );
- temp[5] = FT_DivFix( temp[5], temp_scale );
- temp[3] = temp[3] < 0 ? -0x10000L : 0x10000L;
- }
-
- matrix->xx = temp[0];
- matrix->yx = temp[1];
- matrix->xy = temp[2];
- matrix->yy = temp[3];
-
- if ( !FT_Matrix_Check( matrix ) )
- {
- FT_ERROR(( "t42_parse_font_matrix: invalid font matrix\n" ));
- parser->root.error = FT_THROW( Invalid_File_Format );
- return;
- }
-
- /* note that the offsets must be expressed in integer font units */
- offset->x = temp[4] >> 16;
- offset->y = temp[5] >> 16;
- }
-
-
- static void
- t42_parse_encoding( FT_Face face,
- void* loader_ )
- {
- T42_Face t42face = (T42_Face)face;
- T42_Loader loader = (T42_Loader)loader_;
- T42_Parser parser = &loader->parser;
- FT_Byte* cur;
- FT_Byte* limit = parser->root.limit;
-
- PSAux_Service psaux = (PSAux_Service)t42face->psaux;
-
-
- T1_Skip_Spaces( parser );
- cur = parser->root.cursor;
- if ( cur >= limit )
- {
- FT_ERROR(( "t42_parse_encoding: out of bounds\n" ));
- parser->root.error = FT_THROW( Invalid_File_Format );
- return;
- }
-
- /* if we have a number or `[', the encoding is an array, */
- /* and we must load it now */
- if ( ft_isdigit( *cur ) || *cur == '[' )
- {
- T1_Encoding encode = &t42face->type1.encoding;
- FT_Int count, n;
- PS_Table char_table = &loader->encoding_table;
- FT_Memory memory = parser->root.memory;
- FT_Error error;
- FT_Bool only_immediates = 0;
-
-
- /* read the number of entries in the encoding; should be 256 */
- if ( *cur == '[' )
- {
- count = 256;
- only_immediates = 1;
- parser->root.cursor++;
- }
- else
- count = (FT_Int)T1_ToInt( parser );
-
- /* only composite fonts (which we don't support) */
- /* can have larger values */
- if ( count > 256 )
- {
- FT_ERROR(( "t42_parse_encoding: invalid encoding array size\n" ));
- parser->root.error = FT_THROW( Invalid_File_Format );
- return;
- }
-
- T1_Skip_Spaces( parser );
- if ( parser->root.cursor >= limit )
- return;
-
- /* PostScript happily allows overwriting of encoding arrays */
- if ( encode->char_index )
- {
- FT_FREE( encode->char_index );
- FT_FREE( encode->char_name );
- T1_Release_Table( char_table );
- }
-
- /* we use a T1_Table to store our charnames */
- loader->num_chars = encode->num_chars = count;
- if ( FT_QNEW_ARRAY( encode->char_index, count ) ||
- FT_QNEW_ARRAY( encode->char_name, count ) ||
- FT_SET_ERROR( psaux->ps_table_funcs->init(
- char_table, count, memory ) ) )
- {
- parser->root.error = error;
- return;
- }
-
- /* We need to `zero' out encoding_table.elements */
- for ( n = 0; n < count; n++ )
- (void)T1_Add_Table( char_table, n, ".notdef", 8 );
-
- /* Now we need to read records of the form */
- /* */
- /* ... charcode /charname ... */
- /* */
- /* for each entry in our table. */
- /* */
- /* We simply look for a number followed by an immediate */
- /* name. Note that this ignores correctly the sequence */
- /* that is often seen in type42 fonts: */
- /* */
- /* 0 1 255 { 1 index exch /.notdef put } for dup */
- /* */
- /* used to clean the encoding array before anything else. */
- /* */
- /* Alternatively, if the array is directly given as */
- /* */
- /* /Encoding [ ... ] */
- /* */
- /* we only read immediates. */
-
- n = 0;
- T1_Skip_Spaces( parser );
-
- while ( parser->root.cursor < limit )
- {
- cur = parser->root.cursor;
-
- /* we stop when we encounter `def' or `]' */
- if ( *cur == 'd' && cur + 3 < limit )
- {
- if ( cur[1] == 'e' &&
- cur[2] == 'f' &&
- t42_is_space( cur[3] ) )
- {
- FT_TRACE6(( "encoding end\n" ));
- cur += 3;
- break;
- }
- }
- if ( *cur == ']' )
- {
- FT_TRACE6(( "encoding end\n" ));
- cur++;
- break;
- }
-
- /* check whether we have found an entry */
- if ( ft_isdigit( *cur ) || only_immediates )
- {
- FT_Int charcode;
-
-
- if ( only_immediates )
- charcode = n;
- else
- {
- charcode = (FT_Int)T1_ToInt( parser );
- T1_Skip_Spaces( parser );
-
- /* protect against invalid charcode */
- if ( cur == parser->root.cursor )
- {
- parser->root.error = FT_THROW( Unknown_File_Format );
- return;
- }
- }
-
- cur = parser->root.cursor;
-
- if ( cur + 2 < limit && *cur == '/' && n < count )
- {
- FT_UInt len;
-
-
- cur++;
-
- parser->root.cursor = cur;
- T1_Skip_PS_Token( parser );
- if ( parser->root.cursor >= limit )
- return;
- if ( parser->root.error )
- return;
-
- len = (FT_UInt)( parser->root.cursor - cur );
-
- parser->root.error = T1_Add_Table( char_table, charcode,
- cur, len + 1 );
- if ( parser->root.error )
- return;
- char_table->elements[charcode][len] = '\0';
-
- n++;
- }
- else if ( only_immediates )
- {
- /* Since the current position is not updated for */
- /* immediates-only mode we would get an infinite loop if */
- /* we don't do anything here. */
- /* */
- /* This encoding array is not valid according to the */
- /* type42 specification (it might be an encoding for a CID */
- /* type42 font, however), so we conclude that this font is */
- /* NOT a type42 font. */
- parser->root.error = FT_THROW( Unknown_File_Format );
- return;
- }
- }
- else
- {
- T1_Skip_PS_Token( parser );
- if ( parser->root.error )
- return;
- }
-
- T1_Skip_Spaces( parser );
- }
-
- t42face->type1.encoding_type = T1_ENCODING_TYPE_ARRAY;
- parser->root.cursor = cur;
- }
-
- /* Otherwise, we should have either `StandardEncoding', */
- /* `ExpertEncoding', or `ISOLatin1Encoding' */
- else
- {
- if ( cur + 17 < limit &&
- ft_strncmp( (const char*)cur, "StandardEncoding", 16 ) == 0 )
- t42face->type1.encoding_type = T1_ENCODING_TYPE_STANDARD;
-
- else if ( cur + 15 < limit &&
- ft_strncmp( (const char*)cur, "ExpertEncoding", 14 ) == 0 )
- t42face->type1.encoding_type = T1_ENCODING_TYPE_EXPERT;
-
- else if ( cur + 18 < limit &&
- ft_strncmp( (const char*)cur, "ISOLatin1Encoding", 17 ) == 0 )
- t42face->type1.encoding_type = T1_ENCODING_TYPE_ISOLATIN1;
-
- else
- parser->root.error = FT_ERR( Ignore );
- }
- }
-
-
- typedef enum T42_Load_Status_
- {
- BEFORE_START,
- BEFORE_TABLE_DIR,
- OTHER_TABLES
-
- } T42_Load_Status;
-
-
- static void
- t42_parse_sfnts( FT_Face face,
- void* loader_ )
- {
- T42_Face t42face = (T42_Face)face;
- T42_Loader loader = (T42_Loader)loader_;
- T42_Parser parser = &loader->parser;
- FT_Memory memory = parser->root.memory;
- FT_Byte* cur;
- FT_Byte* limit = parser->root.limit;
- FT_Error error;
- FT_Int num_tables = 0;
- FT_Long ttf_count;
- FT_Long ttf_reserved;
-
- FT_ULong n, string_size, old_string_size, real_size;
- FT_Byte* string_buf = NULL;
- FT_Bool allocated = 0;
-
- T42_Load_Status status;
-
- /** There should only be one sfnts array, but free any previous. */
- FT_FREE( t42face->ttf_data );
- t42face->ttf_size = 0;
-
- /* The format is */
- /* */
- /* /sfnts [ <hexstring> <hexstring> ... ] def */
- /* */
- /* or */
- /* */
- /* /sfnts [ */
- /* <num_bin_bytes> RD <binary data> */
- /* <num_bin_bytes> RD <binary data> */
- /* ... */
- /* ] def */
- /* */
- /* with exactly one space after the `RD' token. */
-
- T1_Skip_Spaces( parser );
-
- if ( parser->root.cursor >= limit || *parser->root.cursor++ != '[' )
- {
- FT_ERROR(( "t42_parse_sfnts: can't find begin of sfnts vector\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Fail;
- }
-
- T1_Skip_Spaces( parser );
- status = BEFORE_START;
- string_size = 0;
- old_string_size = 0;
- ttf_count = 0;
- ttf_reserved = 12;
- if ( FT_QALLOC( t42face->ttf_data, ttf_reserved ) )
- goto Fail;
-
- FT_TRACE2(( "\n" ));
- FT_TRACE2(( "t42_parse_sfnts:\n" ));
-
- while ( parser->root.cursor < limit )
- {
- FT_ULong size;
-
-
- cur = parser->root.cursor;
-
- if ( *cur == ']' )
- {
- parser->root.cursor++;
- t42face->ttf_size = ttf_count;
- goto Exit;
- }
-
- else if ( *cur == '<' )
- {
- if ( string_buf && !allocated )
- {
- FT_ERROR(( "t42_parse_sfnts: "
- "can't handle mixed binary and hex strings\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Fail;
- }
-
- T1_Skip_PS_Token( parser );
- if ( parser->root.error )
- goto Exit;
-
- /* don't include delimiters */
- string_size = (FT_ULong)( ( parser->root.cursor - cur - 2 + 1 ) / 2 );
- if ( !string_size )
- {
- FT_ERROR(( "t42_parse_sfnts: invalid data in sfnts array\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Fail;
- }
- if ( FT_QREALLOC( string_buf, old_string_size, string_size ) )
- goto Fail;
-
- allocated = 1;
-
- parser->root.cursor = cur;
- (void)T1_ToBytes( parser, string_buf, string_size, &real_size, 1 );
- old_string_size = string_size;
- string_size = real_size;
- }
-
- else if ( ft_isdigit( *cur ) )
- {
- FT_Long tmp;
-
-
- if ( allocated )
- {
- FT_ERROR(( "t42_parse_sfnts: "
- "can't handle mixed binary and hex strings\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Fail;
- }
-
- tmp = T1_ToInt( parser );
- if ( tmp < 0 )
- {
- FT_ERROR(( "t42_parse_sfnts: invalid string size\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Fail;
- }
- else
- string_size = (FT_ULong)tmp;
-
- T1_Skip_PS_Token( parser ); /* `RD' */
- if ( parser->root.error )
- return;
-
- string_buf = parser->root.cursor + 1; /* one space after `RD' */
-
- if ( (FT_ULong)( limit - parser->root.cursor ) <= string_size )
- {
- FT_ERROR(( "t42_parse_sfnts: too much binary data\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Fail;
- }
- else
- parser->root.cursor += string_size + 1;
- }
-
- if ( !string_buf )
- {
- FT_ERROR(( "t42_parse_sfnts: invalid data in sfnts array\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Fail;
- }
-
- /* A string can have a trailing zero (odd) byte for padding. */
- /* Ignore it. */
- if ( ( string_size & 1 ) && string_buf[string_size - 1] == 0 )
- string_size--;
-
- if ( !string_size )
- {
- FT_ERROR(( "t42_parse_sfnts: invalid string\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Fail;
- }
-
- FT_TRACE2(( " PS string size %5lu bytes, offset 0x%08lx (%lu)\n",
- string_size, ttf_count, ttf_count ));
-
- /* The whole TTF is now loaded into `string_buf'. We are */
- /* checking its contents while copying it to `ttf_data'. */
-
- size = (FT_ULong)( limit - parser->root.cursor );
-
- for ( n = 0; n < string_size; n++ )
- {
- switch ( status )
- {
- case BEFORE_START:
- /* load offset table, 12 bytes */
- if ( ttf_count < 12 )
- {
- t42face->ttf_data[ttf_count++] = string_buf[n];
- continue;
- }
- else
- {
- FT_Long ttf_reserved_prev = ttf_reserved;
-
-
- num_tables = 16 * t42face->ttf_data[4] + t42face->ttf_data[5];
- status = BEFORE_TABLE_DIR;
- ttf_reserved = 12 + 16 * num_tables;
-
- FT_TRACE2(( " SFNT directory contains %d tables\n",
- num_tables ));
-
- if ( (FT_Long)size < ttf_reserved )
- {
- FT_ERROR(( "t42_parse_sfnts: invalid data in sfnts array\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Fail;
- }
-
- if ( FT_QREALLOC( t42face->ttf_data, ttf_reserved_prev,
- ttf_reserved ) )
- goto Fail;
- }
- FALL_THROUGH;
-
- case BEFORE_TABLE_DIR:
- /* the offset table is read; read the table directory */
- if ( ttf_count < ttf_reserved )
- {
- t42face->ttf_data[ttf_count++] = string_buf[n];
- continue;
- }
- else
- {
- int i;
- FT_ULong len;
- FT_Long ttf_reserved_prev = ttf_reserved;
-
-
- FT_TRACE2(( "\n" ));
- FT_TRACE2(( " table length\n" ));
- FT_TRACE2(( " ------------------------------\n" ));
-
- for ( i = 0; i < num_tables; i++ )
- {
- FT_Byte* p = t42face->ttf_data + 12 + 16 * i + 12;
-
-
- len = FT_PEEK_ULONG( p );
- FT_TRACE2(( " %4i 0x%08lx (%lu)\n", i, len, len ));
-
- if ( len > size ||
- ttf_reserved > (FT_Long)( size - len ) )
- {
- FT_ERROR(( "t42_parse_sfnts:"
- " invalid data in sfnts array\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Fail;
- }
-
- /* Pad to a 4-byte boundary length */
- ttf_reserved += (FT_Long)( ( len + 3 ) & ~3U );
- }
- ttf_reserved += 1;
-
- status = OTHER_TABLES;
-
- FT_TRACE2(( "\n" ));
- FT_TRACE2(( " allocating %ld bytes\n", ttf_reserved ));
- FT_TRACE2(( "\n" ));
-
- if ( FT_QREALLOC( t42face->ttf_data, ttf_reserved_prev,
- ttf_reserved ) )
- goto Fail;
- }
- FALL_THROUGH;
-
- case OTHER_TABLES:
- /* all other tables are just copied */
- if ( ttf_count >= ttf_reserved )
- {
- FT_ERROR(( "t42_parse_sfnts: too much binary data\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Fail;
- }
- t42face->ttf_data[ttf_count++] = string_buf[n];
- }
- }
-
- T1_Skip_Spaces( parser );
- }
-
- /* if control reaches this point, the format was not valid */
- error = FT_THROW( Invalid_File_Format );
-
- Fail:
- parser->root.error = error;
-
- Exit:
- if ( parser->root.error )
- {
- FT_FREE( t42face->ttf_data );
- t42face->ttf_size = 0;
- }
- if ( allocated )
- FT_FREE( string_buf );
- }
-
-
- static void
- t42_parse_charstrings( FT_Face face, /* T42_Face */
- void* loader_ )
- {
- T42_Face t42face = (T42_Face)face;
- T42_Loader loader = (T42_Loader)loader_;
- T42_Parser parser = &loader->parser;
- PS_Table code_table = &loader->charstrings;
- PS_Table name_table = &loader->glyph_names;
- PS_Table swap_table = &loader->swap_table;
- FT_Memory memory = parser->root.memory;
- FT_Error error;
-
- PSAux_Service psaux = (PSAux_Service)t42face->psaux;
-
- FT_Byte* cur;
- FT_Byte* limit = parser->root.limit;
- FT_Int n;
- FT_Int notdef_index = 0;
- FT_Byte notdef_found = 0;
-
-
- T1_Skip_Spaces( parser );
-
- if ( parser->root.cursor >= limit )
- {
- FT_ERROR(( "t42_parse_charstrings: out of bounds\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Fail;
- }
-
- if ( ft_isdigit( *parser->root.cursor ) )
- {
- loader->num_glyphs = T1_ToInt( parser );
- if ( parser->root.error )
- return;
- if ( loader->num_glyphs < 0 )
- {
- FT_ERROR(( "t42_parse_encoding: invalid number of glyphs\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Fail;
- }
-
- /* we certainly need more than 4 bytes per glyph */
- if ( loader->num_glyphs > ( limit - parser->root.cursor ) >> 2 )
- {
- FT_TRACE0(( "t42_parse_charstrings: adjusting number of glyphs"
- " (from %d to %zu)\n",
- loader->num_glyphs,
- ( limit - parser->root.cursor ) >> 2 ));
- loader->num_glyphs = ( limit - parser->root.cursor ) >> 2;
- }
-
- }
- else if ( *parser->root.cursor == '<' )
- {
- /* We have `<< ... >>'. Count the number of `/' in the dictionary */
- /* to get its size. */
- FT_Int count = 0;
-
-
- T1_Skip_PS_Token( parser );
- if ( parser->root.error )
- return;
- T1_Skip_Spaces( parser );
- cur = parser->root.cursor;
-
- while ( parser->root.cursor < limit )
- {
- if ( *parser->root.cursor == '/' )
- count++;
- else if ( *parser->root.cursor == '>' )
- {
- loader->num_glyphs = count;
- parser->root.cursor = cur; /* rewind */
- break;
- }
- T1_Skip_PS_Token( parser );
- if ( parser->root.error )
- return;
- T1_Skip_Spaces( parser );
- }
- }
- else
- {
- FT_ERROR(( "t42_parse_charstrings: invalid token\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Fail;
- }
-
- if ( parser->root.cursor >= limit )
- {
- FT_ERROR(( "t42_parse_charstrings: out of bounds\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Fail;
- }
-
- /* initialize tables */
-
- /* contrary to Type1, we disallow multiple CharStrings arrays */
- if ( swap_table->init )
- {
- FT_ERROR(( "t42_parse_charstrings:"
- " only one CharStrings array allowed\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Fail;
- }
-
- error = psaux->ps_table_funcs->init( code_table,
- loader->num_glyphs,
- memory );
- if ( error )
- goto Fail;
-
- error = psaux->ps_table_funcs->init( name_table,
- loader->num_glyphs,
- memory );
- if ( error )
- goto Fail;
-
- /* Initialize table for swapping index notdef_index and */
- /* index 0 names and codes (if necessary). */
-
- error = psaux->ps_table_funcs->init( swap_table, 4, memory );
- if ( error )
- goto Fail;
-
- n = 0;
-
- for (;;)
- {
- /* We support two formats. */
- /* */
- /* `/glyphname' + index [+ `def'] */
- /* `(glyphname)' [+ `cvn'] + index [+ `def'] */
- /* */
- /* The latter format gets created by the */
- /* LilyPond typesetting program. */
-
- T1_Skip_Spaces( parser );
-
- cur = parser->root.cursor;
- if ( cur >= limit )
- break;
-
- /* We stop when we find an `end' keyword or '>' */
- if ( *cur == 'e' &&
- cur + 3 < limit &&
- cur[1] == 'n' &&
- cur[2] == 'd' &&
- t42_is_space( cur[3] ) )
- break;
- if ( *cur == '>' )
- break;
-
- T1_Skip_PS_Token( parser );
- if ( parser->root.cursor >= limit )
- {
- FT_ERROR(( "t42_parse_charstrings: out of bounds\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Fail;
- }
- if ( parser->root.error )
- return;
-
- if ( *cur == '/' || *cur == '(' )
- {
- FT_UInt len;
- FT_Bool have_literal = FT_BOOL( *cur == '(' );
-
-
- if ( cur + ( have_literal ? 3 : 2 ) >= limit )
- {
- FT_ERROR(( "t42_parse_charstrings: out of bounds\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Fail;
- }
-
- cur++; /* skip `/' */
- len = (FT_UInt)( parser->root.cursor - cur );
- if ( have_literal )
- len--;
-
- error = T1_Add_Table( name_table, n, cur, len + 1 );
- if ( error )
- goto Fail;
-
- /* add a trailing zero to the name table */
- name_table->elements[n][len] = '\0';
-
- /* record index of /.notdef */
- if ( *cur == '.' &&
- ft_strcmp( ".notdef",
- (const char*)( name_table->elements[n] ) ) == 0 )
- {
- notdef_index = n;
- notdef_found = 1;
- }
-
- T1_Skip_Spaces( parser );
-
- if ( have_literal )
- T1_Skip_PS_Token( parser );
-
- cur = parser->root.cursor;
-
- (void)T1_ToInt( parser );
- if ( parser->root.cursor >= limit )
- {
- FT_ERROR(( "t42_parse_charstrings: out of bounds\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Fail;
- }
-
- len = (FT_UInt)( parser->root.cursor - cur );
-
- error = T1_Add_Table( code_table, n, cur, len + 1 );
- if ( error )
- goto Fail;
-
- code_table->elements[n][len] = '\0';
-
- n++;
- if ( n >= loader->num_glyphs )
- break;
- }
- }
-
- loader->num_glyphs = n;
-
- if ( !notdef_found )
- {
- FT_ERROR(( "t42_parse_charstrings: no /.notdef glyph\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Fail;
- }
-
- /* if /.notdef does not occupy index 0, do our magic. */
- if ( ft_strcmp( ".notdef", (const char*)name_table->elements[0] ) )
- {
- /* Swap glyph in index 0 with /.notdef glyph. First, add index 0 */
- /* name and code entries to swap_table. Then place notdef_index */
- /* name and code entries into swap_table. Then swap name and code */
- /* entries at indices notdef_index and 0 using values stored in */
- /* swap_table. */
-
- /* Index 0 name */
- error = T1_Add_Table( swap_table, 0,
- name_table->elements[0],
- name_table->lengths [0] );
- if ( error )
- goto Fail;
-
- /* Index 0 code */
- error = T1_Add_Table( swap_table, 1,
- code_table->elements[0],
- code_table->lengths [0] );
- if ( error )
- goto Fail;
-
- /* Index notdef_index name */
- error = T1_Add_Table( swap_table, 2,
- name_table->elements[notdef_index],
- name_table->lengths [notdef_index] );
- if ( error )
- goto Fail;
-
- /* Index notdef_index code */
- error = T1_Add_Table( swap_table, 3,
- code_table->elements[notdef_index],
- code_table->lengths [notdef_index] );
- if ( error )
- goto Fail;
-
- error = T1_Add_Table( name_table, notdef_index,
- swap_table->elements[0],
- swap_table->lengths [0] );
- if ( error )
- goto Fail;
-
- error = T1_Add_Table( code_table, notdef_index,
- swap_table->elements[1],
- swap_table->lengths [1] );
- if ( error )
- goto Fail;
-
- error = T1_Add_Table( name_table, 0,
- swap_table->elements[2],
- swap_table->lengths [2] );
- if ( error )
- goto Fail;
-
- error = T1_Add_Table( code_table, 0,
- swap_table->elements[3],
- swap_table->lengths [3] );
- if ( error )
- goto Fail;
-
- }
-
- return;
-
- Fail:
- parser->root.error = error;
- }
-
-
- static FT_Error
- t42_load_keyword( T42_Face face,
- T42_Loader loader,
- T1_Field field )
- {
- FT_Error error;
- void* dummy_object;
- void** objects;
- FT_UInt max_objects = 0;
-
-
- /* if the keyword has a dedicated callback, call it */
- if ( field->type == T1_FIELD_TYPE_CALLBACK )
- {
- field->reader( (FT_Face)face, loader );
- error = loader->parser.root.error;
- goto Exit;
- }
-
- /* now the keyword is either a simple field or a table of fields; */
- /* we are now going to take care of it */
-
- switch ( field->location )
- {
- case T1_FIELD_LOCATION_FONT_INFO:
- dummy_object = &face->type1.font_info;
- break;
-
- case T1_FIELD_LOCATION_FONT_EXTRA:
- dummy_object = &face->type1.font_extra;
- break;
-
- case T1_FIELD_LOCATION_BBOX:
- dummy_object = &face->type1.font_bbox;
- break;
-
- default:
- dummy_object = &face->type1;
- }
-
- objects = &dummy_object;
-
- if ( field->type == T1_FIELD_TYPE_INTEGER_ARRAY ||
- field->type == T1_FIELD_TYPE_FIXED_ARRAY )
- error = T1_Load_Field_Table( &loader->parser, field,
- objects, max_objects, 0 );
- else
- error = T1_Load_Field( &loader->parser, field,
- objects, max_objects, 0 );
-
- Exit:
- return error;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- t42_parse_dict( T42_Face face,
- T42_Loader loader,
- FT_Byte* base,
- FT_Long size )
- {
- T42_Parser parser = &loader->parser;
- FT_Byte* limit;
-
-
- parser->root.cursor = base;
- parser->root.limit = base + size;
- parser->root.error = FT_Err_Ok;
-
- limit = parser->root.limit;
-
- T1_Skip_Spaces( parser );
-
- while ( parser->root.cursor < limit )
- {
- FT_Byte* cur;
-
-
- cur = parser->root.cursor;
-
- /* look for `FontDirectory' which causes problems for some fonts */
- if ( *cur == 'F' && cur + 25 < limit &&
- ft_strncmp( (char*)cur, "FontDirectory", 13 ) == 0 )
- {
- FT_Byte* cur2;
-
-
- /* skip the `FontDirectory' keyword */
- T1_Skip_PS_Token( parser );
- T1_Skip_Spaces ( parser );
- cur = cur2 = parser->root.cursor;
-
- /* look up the `known' keyword */
- while ( cur < limit )
- {
- if ( *cur == 'k' && cur + 5 < limit &&
- ft_strncmp( (char*)cur, "known", 5 ) == 0 )
- break;
-
- T1_Skip_PS_Token( parser );
- if ( parser->root.error )
- goto Exit;
- T1_Skip_Spaces ( parser );
- cur = parser->root.cursor;
- }
-
- if ( cur < limit )
- {
- T1_TokenRec token;
-
-
- /* skip the `known' keyword and the token following it */
- T1_Skip_PS_Token( parser );
- T1_ToToken( parser, &token );
-
- /* if the last token was an array, skip it! */
- if ( token.type == T1_TOKEN_TYPE_ARRAY )
- cur2 = parser->root.cursor;
- }
- parser->root.cursor = cur2;
- }
-
- /* look for immediates */
- else if ( *cur == '/' && cur + 2 < limit )
- {
- FT_UInt len;
-
-
- cur++;
-
- parser->root.cursor = cur;
- T1_Skip_PS_Token( parser );
- if ( parser->root.error )
- goto Exit;
-
- len = (FT_UInt)( parser->root.cursor - cur );
-
- if ( len > 0 && len < 22 && parser->root.cursor < limit )
- {
- T1_Field keyword = (T1_Field)t42_keywords;
-
-
- /* now compare the immediate name to the keyword table */
- while ( keyword->len )
- {
- FT_Byte* name = (FT_Byte*)keyword->ident;
-
-
- if ( !name )
- continue;
-
- if ( keyword->len == len &&
- ft_memcmp( cur, name, len ) == 0 )
- {
- /* we found it -- run the parsing callback! */
- parser->root.error = t42_load_keyword( face,
- loader,
- keyword );
- if ( parser->root.error )
- return parser->root.error;
- break;
- }
-
- keyword++;
- }
- }
- }
- else
- {
- T1_Skip_PS_Token( parser );
- if ( parser->root.error )
- goto Exit;
- }
-
- T1_Skip_Spaces( parser );
- }
-
- Exit:
- return parser->root.error;
- }
-
-
- FT_LOCAL_DEF( void )
- t42_loader_init( T42_Loader loader,
- T42_Face face )
- {
- FT_UNUSED( face );
-
- FT_ZERO( loader );
- loader->num_glyphs = 0;
- loader->num_chars = 0;
-
- /* initialize the tables -- simply set their `init' field to 0 */
- loader->encoding_table.init = 0;
- loader->charstrings.init = 0;
- loader->glyph_names.init = 0;
- }
-
-
- FT_LOCAL_DEF( void )
- t42_loader_done( T42_Loader loader )
- {
- T42_Parser parser = &loader->parser;
-
-
- /* finalize tables */
- T1_Release_Table( &loader->encoding_table );
- T1_Release_Table( &loader->charstrings );
- T1_Release_Table( &loader->glyph_names );
- T1_Release_Table( &loader->swap_table );
-
- /* finalize parser */
- t42_parser_done( parser );
- }
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/type42/t42parse.h b/contrib/libs/freetype/src/type42/t42parse.h
deleted file mode 100644
index e977861624..0000000000
--- a/contrib/libs/freetype/src/type42/t42parse.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/****************************************************************************
- *
- * t42parse.h
- *
- * Type 42 font parser (specification).
- *
- * Copyright (C) 2002-2024 by
- * Roberto Alameda.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef T42PARSE_H_
-#define T42PARSE_H_
-
-
-#include "t42objs.h"
-#include <freetype/internal/psaux.h>
-
-
-FT_BEGIN_HEADER
-
- typedef struct T42_ParserRec_
- {
- PS_ParserRec root;
- FT_Stream stream;
-
- FT_Byte* base_dict;
- FT_Long base_len;
-
- FT_Bool in_memory;
-
- } T42_ParserRec, *T42_Parser;
-
-
- typedef struct T42_Loader_
- {
- T42_ParserRec parser; /* parser used to read the stream */
-
- FT_Int num_chars; /* number of characters in encoding */
- PS_TableRec encoding_table; /* PS_Table used to store the */
- /* encoding character names */
-
- FT_Int num_glyphs;
- PS_TableRec glyph_names;
- PS_TableRec charstrings;
- PS_TableRec swap_table; /* For moving .notdef glyph to index 0. */
-
- } T42_LoaderRec, *T42_Loader;
-
-
- FT_LOCAL( FT_Error )
- t42_parser_init( T42_Parser parser,
- FT_Stream stream,
- FT_Memory memory,
- PSAux_Service psaux );
-
- FT_LOCAL( void )
- t42_parser_done( T42_Parser parser );
-
-
- FT_LOCAL( FT_Error )
- t42_parse_dict( T42_Face face,
- T42_Loader loader,
- FT_Byte* base,
- FT_Long size );
-
-
- FT_LOCAL( void )
- t42_loader_init( T42_Loader loader,
- T42_Face face );
-
- FT_LOCAL( void )
- t42_loader_done( T42_Loader loader );
-
-
- /* */
-
-FT_END_HEADER
-
-
-#endif /* T42PARSE_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/type42/t42types.h b/contrib/libs/freetype/src/type42/t42types.h
deleted file mode 100644
index 550cc07ca1..0000000000
--- a/contrib/libs/freetype/src/type42/t42types.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/****************************************************************************
- *
- * t42types.h
- *
- * Type 42 font data types (specification only).
- *
- * Copyright (C) 2002-2024 by
- * Roberto Alameda.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef T42TYPES_H_
-#define T42TYPES_H_
-
-
-#include <freetype/freetype.h>
-#include <freetype/t1tables.h>
-#include <freetype/internal/t1types.h>
-#include <freetype/internal/pshints.h>
-
-
-FT_BEGIN_HEADER
-
-
- typedef struct T42_FaceRec_
- {
- FT_FaceRec root;
- T1_FontRec type1;
- const void* psnames;
- const void* psaux;
-#if 0
- const void* afm_data;
-#endif
- FT_Byte* ttf_data;
- FT_Long ttf_size;
- FT_Face ttf_face;
- FT_CharMapRec charmaprecs[2];
- FT_CharMap charmaps[2];
- PS_UnicodesRec unicode_map;
-
- } T42_FaceRec, *T42_Face;
-
-
-FT_END_HEADER
-
-#endif /* T42TYPES_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/type42/type42.c b/contrib/libs/freetype/src/type42/type42.c
deleted file mode 100644
index a9444f0f50..0000000000
--- a/contrib/libs/freetype/src/type42/type42.c
+++ /dev/null
@@ -1,26 +0,0 @@
-/****************************************************************************
- *
- * type42.c
- *
- * FreeType Type 42 driver component.
- *
- * Copyright (C) 2002-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#define FT_MAKE_OPTION_SINGLE_OBJECT
-
-#include "t42drivr.c"
-#include "t42objs.c"
-#include "t42parse.c"
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/winfonts/fnterrs.h b/contrib/libs/freetype/src/winfonts/fnterrs.h
deleted file mode 100644
index 7ca6592397..0000000000
--- a/contrib/libs/freetype/src/winfonts/fnterrs.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
- *
- * fnterrs.h
- *
- * Win FNT/FON error codes (specification only).
- *
- * Copyright (C) 2001-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /**************************************************************************
- *
- * This file is used to define the Windows FNT/FON error enumeration
- * constants.
- *
- */
-
-#ifndef FNTERRS_H_
-#define FNTERRS_H_
-
-#include <freetype/ftmoderr.h>
-
-#undef FTERRORS_H_
-
-#undef FT_ERR_PREFIX
-#define FT_ERR_PREFIX FNT_Err_
-#define FT_ERR_BASE FT_Mod_Err_Winfonts
-
-#include <freetype/fterrors.h>
-
-#endif /* FNTERRS_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/winfonts/winfnt.c b/contrib/libs/freetype/src/winfonts/winfnt.c
deleted file mode 100644
index 74a06416cd..0000000000
--- a/contrib/libs/freetype/src/winfonts/winfnt.c
+++ /dev/null
@@ -1,1219 +0,0 @@
-/****************************************************************************
- *
- * winfnt.c
- *
- * FreeType font driver for Windows FNT/FON files
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- * Copyright 2003 Huw D M Davies for Codeweavers
- * Copyright 2007 Dmitry Timoshkov for Codeweavers
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#include <freetype/ftwinfnt.h>
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/internal/ftobjs.h>
-#include <freetype/ttnameid.h>
-
-#include "winfnt.h"
-#include "fnterrs.h"
-#include <freetype/internal/services/svwinfnt.h>
-#include <freetype/internal/services/svfntfmt.h>
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT winfnt
-
-
- static const FT_Frame_Field winmz_header_fields[] =
- {
-#undef FT_STRUCTURE
-#define FT_STRUCTURE WinMZ_HeaderRec
-
- FT_FRAME_START( 64 ),
- FT_FRAME_USHORT_LE ( magic ),
- FT_FRAME_SKIP_BYTES( 29 * 2 ),
- FT_FRAME_ULONG_LE ( lfanew ),
- FT_FRAME_END
- };
-
- static const FT_Frame_Field winne_header_fields[] =
- {
-#undef FT_STRUCTURE
-#define FT_STRUCTURE WinNE_HeaderRec
-
- FT_FRAME_START( 40 ),
- FT_FRAME_USHORT_LE ( magic ),
- FT_FRAME_SKIP_BYTES( 34 ),
- FT_FRAME_USHORT_LE ( resource_tab_offset ),
- FT_FRAME_USHORT_LE ( rname_tab_offset ),
- FT_FRAME_END
- };
-
- static const FT_Frame_Field winpe32_header_fields[] =
- {
-#undef FT_STRUCTURE
-#define FT_STRUCTURE WinPE32_HeaderRec
-
- FT_FRAME_START( 248 ),
- FT_FRAME_ULONG_LE ( magic ), /* PE00 */
- FT_FRAME_USHORT_LE ( machine ), /* 0x014C - i386 */
- FT_FRAME_USHORT_LE ( number_of_sections ),
- FT_FRAME_SKIP_BYTES( 12 ),
- FT_FRAME_USHORT_LE ( size_of_optional_header ),
- FT_FRAME_SKIP_BYTES( 2 ),
- FT_FRAME_USHORT_LE ( magic32 ), /* 0x10B */
- FT_FRAME_SKIP_BYTES( 110 ),
- FT_FRAME_ULONG_LE ( rsrc_virtual_address ),
- FT_FRAME_ULONG_LE ( rsrc_size ),
- FT_FRAME_SKIP_BYTES( 104 ),
- FT_FRAME_END
- };
-
- static const FT_Frame_Field winpe32_section_fields[] =
- {
-#undef FT_STRUCTURE
-#define FT_STRUCTURE WinPE32_SectionRec
-
- FT_FRAME_START( 40 ),
- FT_FRAME_BYTES ( name, 8 ),
- FT_FRAME_SKIP_BYTES( 4 ),
- FT_FRAME_ULONG_LE ( virtual_address ),
- FT_FRAME_ULONG_LE ( size_of_raw_data ),
- FT_FRAME_ULONG_LE ( pointer_to_raw_data ),
- FT_FRAME_SKIP_BYTES( 16 ),
- FT_FRAME_END
- };
-
- static const FT_Frame_Field winpe_rsrc_dir_fields[] =
- {
-#undef FT_STRUCTURE
-#define FT_STRUCTURE WinPE_RsrcDirRec
-
- FT_FRAME_START( 16 ),
- FT_FRAME_ULONG_LE ( characteristics ),
- FT_FRAME_ULONG_LE ( time_date_stamp ),
- FT_FRAME_USHORT_LE( major_version ),
- FT_FRAME_USHORT_LE( minor_version ),
- FT_FRAME_USHORT_LE( number_of_named_entries ),
- FT_FRAME_USHORT_LE( number_of_id_entries ),
- FT_FRAME_END
- };
-
- static const FT_Frame_Field winpe_rsrc_dir_entry_fields[] =
- {
-#undef FT_STRUCTURE
-#define FT_STRUCTURE WinPE_RsrcDirEntryRec
-
- FT_FRAME_START( 8 ),
- FT_FRAME_ULONG_LE( name ),
- FT_FRAME_ULONG_LE( offset ),
- FT_FRAME_END
- };
-
- static const FT_Frame_Field winpe_rsrc_data_entry_fields[] =
- {
-#undef FT_STRUCTURE
-#define FT_STRUCTURE WinPE_RsrcDataEntryRec
-
- FT_FRAME_START( 16 ),
- FT_FRAME_ULONG_LE( offset_to_data ),
- FT_FRAME_ULONG_LE( size ),
- FT_FRAME_ULONG_LE( code_page ),
- FT_FRAME_ULONG_LE( reserved ),
- FT_FRAME_END
- };
-
- static const FT_Frame_Field winfnt_header_fields[] =
- {
-#undef FT_STRUCTURE
-#define FT_STRUCTURE FT_WinFNT_HeaderRec
-
- FT_FRAME_START( 148 ),
- FT_FRAME_USHORT_LE( version ),
- FT_FRAME_ULONG_LE ( file_size ),
- FT_FRAME_BYTES ( copyright, 60 ),
- FT_FRAME_USHORT_LE( file_type ),
- FT_FRAME_USHORT_LE( nominal_point_size ),
- FT_FRAME_USHORT_LE( vertical_resolution ),
- FT_FRAME_USHORT_LE( horizontal_resolution ),
- FT_FRAME_USHORT_LE( ascent ),
- FT_FRAME_USHORT_LE( internal_leading ),
- FT_FRAME_USHORT_LE( external_leading ),
- FT_FRAME_BYTE ( italic ),
- FT_FRAME_BYTE ( underline ),
- FT_FRAME_BYTE ( strike_out ),
- FT_FRAME_USHORT_LE( weight ),
- FT_FRAME_BYTE ( charset ),
- FT_FRAME_USHORT_LE( pixel_width ),
- FT_FRAME_USHORT_LE( pixel_height ),
- FT_FRAME_BYTE ( pitch_and_family ),
- FT_FRAME_USHORT_LE( avg_width ),
- FT_FRAME_USHORT_LE( max_width ),
- FT_FRAME_BYTE ( first_char ),
- FT_FRAME_BYTE ( last_char ),
- FT_FRAME_BYTE ( default_char ),
- FT_FRAME_BYTE ( break_char ),
- FT_FRAME_USHORT_LE( bytes_per_row ),
- FT_FRAME_ULONG_LE ( device_offset ),
- FT_FRAME_ULONG_LE ( face_name_offset ),
- FT_FRAME_ULONG_LE ( bits_pointer ),
- FT_FRAME_ULONG_LE ( bits_offset ),
- FT_FRAME_BYTE ( reserved ),
- FT_FRAME_ULONG_LE ( flags ),
- FT_FRAME_USHORT_LE( A_space ),
- FT_FRAME_USHORT_LE( B_space ),
- FT_FRAME_USHORT_LE( C_space ),
- FT_FRAME_ULONG_LE ( color_table_offset ),
- FT_FRAME_BYTES ( reserved1, 16 ),
- FT_FRAME_END
- };
-
-
- static void
- fnt_font_done( FNT_Face face )
- {
- FT_Memory memory = FT_FACE( face )->memory;
- FT_Stream stream = FT_FACE( face )->stream;
- FNT_Font font = face->font;
-
-
- if ( !font )
- return;
-
- if ( font->fnt_frame )
- FT_FRAME_RELEASE( font->fnt_frame );
- FT_FREE( font->family_name );
-
- FT_FREE( font );
- face->font = NULL;
- }
-
-
- static FT_Error
- fnt_font_load( FNT_Font font,
- FT_Stream stream )
- {
- FT_Error error;
- FT_WinFNT_Header header = &font->header;
- FT_Bool new_format;
- FT_UInt size;
-
-
- /* first of all, read the FNT header */
- if ( FT_STREAM_SEEK( font->offset ) ||
- FT_STREAM_READ_FIELDS( winfnt_header_fields, header ) )
- {
- FT_TRACE2(( " not a Windows FNT file\n" ));
- error = FT_THROW( Unknown_File_Format );
- goto Exit;
- }
-
- /* check header */
- if ( header->version != 0x200 &&
- header->version != 0x300 )
- {
- FT_TRACE2(( " not a Windows FNT file\n" ));
- error = FT_THROW( Unknown_File_Format );
- goto Exit;
- }
-
- new_format = FT_BOOL( font->header.version == 0x300 );
- size = new_format ? 148 : 118;
-
- if ( header->file_size < size )
- {
- FT_TRACE2(( " not a Windows FNT file\n" ));
- error = FT_THROW( Unknown_File_Format );
- goto Exit;
- }
-
- /* Version 2 doesn't have these fields */
- if ( header->version == 0x200 )
- {
- header->flags = 0;
- header->A_space = 0;
- header->B_space = 0;
- header->C_space = 0;
-
- header->color_table_offset = 0;
- }
-
- if ( header->file_type & 1 )
- {
- FT_TRACE2(( "[can't handle vector FNT fonts]\n" ));
- error = FT_THROW( Unknown_File_Format );
- goto Exit;
- }
-
- /* this is a FNT file/table; extract its frame */
- if ( FT_STREAM_SEEK( font->offset ) ||
- FT_FRAME_EXTRACT( header->file_size, font->fnt_frame ) )
- goto Exit;
-
- Exit:
- return error;
- }
-
-
- static FT_Error
- fnt_face_get_dll_font( FNT_Face face,
- FT_Int face_instance_index )
- {
- FT_Error error;
- FT_Stream stream = FT_FACE( face )->stream;
- FT_Memory memory = FT_FACE( face )->memory;
- WinMZ_HeaderRec mz_header;
- FT_Long face_index;
-
-
- face->font = NULL;
-
- face_index = FT_ABS( face_instance_index ) & 0xFFFF;
-
- /* does it begin with an MZ header? */
- if ( FT_STREAM_SEEK( 0 ) ||
- FT_STREAM_READ_FIELDS( winmz_header_fields, &mz_header ) )
- {
- error = FT_ERR( Unknown_File_Format );
- goto Exit;
- }
-
- error = FT_ERR( Unknown_File_Format );
- if ( mz_header.magic == WINFNT_MZ_MAGIC )
- {
- /* yes, now look for an NE header in the file */
- WinNE_HeaderRec ne_header;
-
-
- FT_TRACE2(( "MZ signature found\n" ));
-
- if ( FT_STREAM_SEEK( mz_header.lfanew ) ||
- FT_STREAM_READ_FIELDS( winne_header_fields, &ne_header ) )
- goto Exit;
-
- error = FT_ERR( Unknown_File_Format );
- if ( ne_header.magic == WINFNT_NE_MAGIC )
- {
- /* good, now look into the resource table for each FNT resource */
- FT_ULong res_offset = mz_header.lfanew +
- ne_header.resource_tab_offset;
- FT_UShort size_shift;
- FT_UShort font_count = 0;
- FT_ULong font_offset = 0;
-
-
- FT_TRACE2(( "NE signature found\n" ));
-
- if ( FT_STREAM_SEEK( res_offset ) ||
- FT_FRAME_ENTER( ne_header.rname_tab_offset -
- ne_header.resource_tab_offset ) )
- goto Exit;
-
- size_shift = FT_GET_USHORT_LE();
-
- /* Microsoft's specification of the executable-file header format */
- /* for `New Executable' (NE) doesn't give a limit for the */
- /* alignment shift count; however, in 1985, the year of the */
- /* specification release, only 32bit values were supported, thus */
- /* anything larger than 16 doesn't make sense in general, given */
- /* that file offsets are 16bit values, shifted by the alignment */
- /* shift count */
- if ( size_shift > 16 )
- {
- FT_TRACE2(( "invalid alignment shift count for resource data\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit1;
- }
-
-
- for (;;)
- {
- FT_UShort type_id, count;
-
-
- type_id = FT_GET_USHORT_LE();
- if ( !type_id )
- break;
-
- count = FT_GET_USHORT_LE();
-
- FT_TRACE2(( type_id == 0x8007U ? "RT_FONTDIR count %hu\n" :
- type_id == 0x8008U ? "RT_FONT count %hu\n" : "",
- count ));
-
- if ( type_id == 0x8008U )
- {
- font_count = count;
- font_offset = FT_STREAM_POS() + 4 -
- (FT_ULong)( stream->limit - stream->cursor );
- break;
- }
-
- stream->cursor += 4 + count * 12;
- }
-
- FT_FRAME_EXIT();
-
- if ( !font_count || !font_offset )
- {
- FT_TRACE2(( "this file doesn't contain any FNT resources\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- /* loading `winfnt_header_fields' needs at least 118 bytes; */
- /* use this as a rough measure to check the expected font size */
- if ( font_count * 118UL > stream->size )
- {
- FT_TRACE2(( "invalid number of faces\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- face->root.num_faces = font_count;
-
- if ( face_instance_index < 0 )
- goto Exit;
-
- if ( face_index >= font_count )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- if ( FT_NEW( face->font ) )
- goto Exit;
-
- if ( FT_STREAM_SEEK( font_offset + (FT_ULong)face_index * 12 ) ||
- FT_FRAME_ENTER( 12 ) )
- goto Fail;
-
- face->font->offset = (FT_ULong)FT_GET_USHORT_LE() << size_shift;
- face->font->fnt_size = (FT_ULong)FT_GET_USHORT_LE() << size_shift;
-
- stream->cursor += 8;
-
- FT_FRAME_EXIT();
-
- error = fnt_font_load( face->font, stream );
- }
- else if ( ne_header.magic == WINFNT_PE_MAGIC )
- {
- WinPE32_HeaderRec pe32_header;
- WinPE32_SectionRec pe32_section;
- WinPE_RsrcDirRec root_dir, name_dir, lang_dir;
- WinPE_RsrcDirEntryRec dir_entry1, dir_entry2, dir_entry3;
- WinPE_RsrcDataEntryRec data_entry;
-
- FT_ULong root_dir_offset, name_dir_offset, lang_dir_offset;
- FT_UShort i, j, k;
-
-
- FT_TRACE2(( "PE signature found\n" ));
-
- if ( FT_STREAM_SEEK( mz_header.lfanew ) ||
- FT_STREAM_READ_FIELDS( winpe32_header_fields, &pe32_header ) )
- goto Exit;
-
- FT_TRACE2(( "magic %04lx, machine %02x, number_of_sections %u, "
- "size_of_optional_header %02x\n",
- pe32_header.magic, pe32_header.machine,
- pe32_header.number_of_sections,
- pe32_header.size_of_optional_header ));
- FT_TRACE2(( "magic32 %02x, rsrc_virtual_address %04lx, "
- "rsrc_size %04lx\n",
- pe32_header.magic32, pe32_header.rsrc_virtual_address,
- pe32_header.rsrc_size ));
-
- if ( pe32_header.magic != WINFNT_PE_MAGIC /* check full signature */ ||
- pe32_header.machine != 0x014C /* i386 */ ||
- pe32_header.size_of_optional_header != 0xE0 /* FIXME */ ||
- pe32_header.magic32 != 0x10B )
- {
- FT_TRACE2(( "this file has an invalid PE header\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- face->root.num_faces = 0;
-
- for ( i = 0; i < pe32_header.number_of_sections; i++ )
- {
- if ( FT_STREAM_READ_FIELDS( winpe32_section_fields,
- &pe32_section ) )
- goto Exit;
-
- FT_TRACE2(( "name %.8s, va %04lx, size %04lx, offset %04lx\n",
- pe32_section.name, pe32_section.virtual_address,
- pe32_section.size_of_raw_data,
- pe32_section.pointer_to_raw_data ));
-
- if ( pe32_header.rsrc_virtual_address ==
- pe32_section.virtual_address )
- goto Found_rsrc_section;
- }
-
- FT_TRACE2(( "this file doesn't contain any resources\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
-
- Found_rsrc_section:
- FT_TRACE2(( "found resources section %.8s\n", pe32_section.name ));
-
- if ( FT_STREAM_SEEK( pe32_section.pointer_to_raw_data ) ||
- FT_STREAM_READ_FIELDS( winpe_rsrc_dir_fields, &root_dir ) )
- goto Exit;
-
- root_dir_offset = pe32_section.pointer_to_raw_data;
-
- for ( i = 0; i < root_dir.number_of_named_entries +
- root_dir.number_of_id_entries; i++ )
- {
- if ( FT_STREAM_SEEK( root_dir_offset + 16 + i * 8 ) ||
- FT_STREAM_READ_FIELDS( winpe_rsrc_dir_entry_fields,
- &dir_entry1 ) )
- goto Exit;
-
- if ( !( dir_entry1.offset & 0x80000000UL ) /* DataIsDirectory */ )
- {
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- dir_entry1.offset &= ~0x80000000UL;
-
- name_dir_offset = pe32_section.pointer_to_raw_data +
- dir_entry1.offset;
-
- if ( FT_STREAM_SEEK( pe32_section.pointer_to_raw_data +
- dir_entry1.offset ) ||
- FT_STREAM_READ_FIELDS( winpe_rsrc_dir_fields, &name_dir ) )
- goto Exit;
-
- for ( j = 0; j < name_dir.number_of_named_entries +
- name_dir.number_of_id_entries; j++ )
- {
- if ( FT_STREAM_SEEK( name_dir_offset + 16 + j * 8 ) ||
- FT_STREAM_READ_FIELDS( winpe_rsrc_dir_entry_fields,
- &dir_entry2 ) )
- goto Exit;
-
- if ( !( dir_entry2.offset & 0x80000000UL ) /* DataIsDirectory */ )
- {
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- dir_entry2.offset &= ~0x80000000UL;
-
- lang_dir_offset = pe32_section.pointer_to_raw_data +
- dir_entry2.offset;
-
- if ( FT_STREAM_SEEK( pe32_section.pointer_to_raw_data +
- dir_entry2.offset ) ||
- FT_STREAM_READ_FIELDS( winpe_rsrc_dir_fields, &lang_dir ) )
- goto Exit;
-
- for ( k = 0; k < lang_dir.number_of_named_entries +
- lang_dir.number_of_id_entries; k++ )
- {
- if ( FT_STREAM_SEEK( lang_dir_offset + 16 + k * 8 ) ||
- FT_STREAM_READ_FIELDS( winpe_rsrc_dir_entry_fields,
- &dir_entry3 ) )
- goto Exit;
-
- if ( dir_entry2.offset & 0x80000000UL /* DataIsDirectory */ )
- {
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- if ( dir_entry1.name == 8 /* RT_FONT */ )
- {
- if ( FT_STREAM_SEEK( root_dir_offset + dir_entry3.offset ) ||
- FT_STREAM_READ_FIELDS( winpe_rsrc_data_entry_fields,
- &data_entry ) )
- goto Exit;
-
- FT_TRACE2(( "found font #%lu, offset %04lx, "
- "size %04lx, cp %lu\n",
- dir_entry2.name,
- pe32_section.pointer_to_raw_data +
- data_entry.offset_to_data -
- pe32_section.virtual_address,
- data_entry.size, data_entry.code_page ));
-
- if ( face_index == face->root.num_faces )
- {
- if ( FT_NEW( face->font ) )
- goto Exit;
-
- face->font->offset = pe32_section.pointer_to_raw_data +
- data_entry.offset_to_data -
- pe32_section.virtual_address;
- face->font->fnt_size = data_entry.size;
-
- error = fnt_font_load( face->font, stream );
- if ( error )
- {
- FT_TRACE2(( "font #%lu load error 0x%x\n",
- dir_entry2.name, error ));
- goto Fail;
- }
- else
- FT_TRACE2(( "font #%lu successfully loaded\n",
- dir_entry2.name ));
- }
-
- face->root.num_faces++;
- }
- }
- }
- }
- }
-
- if ( !face->root.num_faces )
- {
- FT_TRACE2(( "this file doesn't contain any RT_FONT resources\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- if ( face_index >= face->root.num_faces )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
- }
-
- Fail:
- if ( error )
- fnt_font_done( face );
-
- Exit:
- return error;
-
- Exit1:
- FT_FRAME_EXIT();
- goto Exit;
- }
-
-
- typedef struct FNT_CMapRec_
- {
- FT_CMapRec cmap;
- FT_UInt32 first;
- FT_UInt32 count;
-
- } FNT_CMapRec, *FNT_CMap;
-
-
- static FT_Error
- fnt_cmap_init( FT_CMap cmap, /* FNT_CMap */
- FT_Pointer pointer )
- {
- FNT_CMap fntcmap = (FNT_CMap)cmap;
- FNT_Face face = (FNT_Face)FT_CMAP_FACE( cmap );
- FNT_Font font = face->font;
-
- FT_UNUSED( pointer );
-
-
- fntcmap->first = (FT_UInt32)font->header.first_char;
- fntcmap->count = (FT_UInt32)( font->header.last_char -
- fntcmap->first + 1 );
-
- return 0;
- }
-
-
- static FT_UInt
- fnt_cmap_char_index( FT_CMap cmap, /* FNT_CMap */
- FT_UInt32 char_code )
- {
- FNT_CMap fntcmap = (FNT_CMap)cmap;
- FT_UInt gindex = 0;
-
-
- char_code -= fntcmap->first;
- if ( char_code < fntcmap->count )
- /* we artificially increase the glyph index; */
- /* FNT_Load_Glyph reverts to the right one */
- gindex = (FT_UInt)( char_code + 1 );
- return gindex;
- }
-
-
- static FT_UInt
- fnt_cmap_char_next( FT_CMap cmap, /* FNT_CMap */
- FT_UInt32 *pchar_code )
- {
- FNT_CMap fntcmap = (FNT_CMap)cmap;
- FT_UInt gindex = 0;
- FT_UInt32 result = 0;
- FT_UInt32 char_code = *pchar_code + 1;
-
-
- if ( char_code <= fntcmap->first )
- {
- result = fntcmap->first;
- gindex = 1;
- }
- else
- {
- char_code -= fntcmap->first;
- if ( char_code < fntcmap->count )
- {
- result = fntcmap->first + char_code;
- gindex = (FT_UInt)( char_code + 1 );
- }
- }
-
- *pchar_code = result;
- return gindex;
- }
-
-
- static const FT_CMap_ClassRec fnt_cmap_class_rec =
- {
- sizeof ( FNT_CMapRec ),
-
- (FT_CMap_InitFunc) fnt_cmap_init,
- (FT_CMap_DoneFunc) NULL,
- (FT_CMap_CharIndexFunc)fnt_cmap_char_index,
- (FT_CMap_CharNextFunc) fnt_cmap_char_next,
-
- NULL, NULL, NULL, NULL, NULL
- };
-
- static FT_CMap_Class const fnt_cmap_class = &fnt_cmap_class_rec;
-
-
- static void
- FNT_Face_Done( FT_Face fntface ) /* FNT_Face */
- {
- FNT_Face face = (FNT_Face)fntface;
- FT_Memory memory;
-
-
- if ( !face )
- return;
-
- memory = FT_FACE_MEMORY( face );
-
- fnt_font_done( face );
-
- FT_FREE( fntface->available_sizes );
- fntface->num_fixed_sizes = 0;
- }
-
-
- static FT_Error
- FNT_Face_Init( FT_Stream stream,
- FT_Face fntface, /* FNT_Face */
- FT_Int face_instance_index,
- FT_Int num_params,
- FT_Parameter* params )
- {
- FNT_Face face = (FNT_Face)fntface;
- FT_Error error;
- FT_Memory memory = FT_FACE_MEMORY( face );
- FT_Int face_index;
-
- FT_UNUSED( num_params );
- FT_UNUSED( params );
-
-
- FT_TRACE2(( "Windows FNT driver\n" ));
-
- face_index = FT_ABS( face_instance_index ) & 0xFFFF;
-
- /* try to load font from a DLL */
- error = fnt_face_get_dll_font( face, face_instance_index );
- if ( !error && face_instance_index < 0 )
- goto Exit;
-
- if ( FT_ERR_EQ( error, Unknown_File_Format ) )
- {
- /* this didn't work; try to load a single FNT font */
- FNT_Font font;
-
- if ( FT_NEW( face->font ) )
- goto Exit;
-
- fntface->num_faces = 1;
-
- font = face->font;
- font->offset = 0;
- font->fnt_size = stream->size;
-
- error = fnt_font_load( font, stream );
-
- if ( !error )
- {
- if ( face_instance_index < 0 )
- goto Exit;
-
- if ( face_index > 0 )
- error = FT_THROW( Invalid_Argument );
- }
- }
-
- if ( error )
- goto Fail;
-
- /* sanity check */
- if ( !face->font->header.pixel_height )
- {
- FT_TRACE2(( "invalid pixel height\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Fail;
- }
-
- /* we now need to fill the root FT_Face fields */
- /* with relevant information */
- {
- FT_Face root = FT_FACE( face );
- FNT_Font font = face->font;
- FT_ULong family_size;
-
-
- root->face_index = face_index;
-
- root->face_flags |= FT_FACE_FLAG_FIXED_SIZES |
- FT_FACE_FLAG_HORIZONTAL;
-
- if ( font->header.avg_width == font->header.max_width )
- root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
-
- if ( font->header.italic )
- root->style_flags |= FT_STYLE_FLAG_ITALIC;
-
- if ( font->header.weight >= 800 )
- root->style_flags |= FT_STYLE_FLAG_BOLD;
-
- /* set up the `fixed_sizes' array */
- if ( FT_QNEW( root->available_sizes ) )
- goto Fail;
-
- root->num_fixed_sizes = 1;
-
- {
- FT_Bitmap_Size* bsize = root->available_sizes;
- FT_UShort x_res, y_res;
-
-
- bsize->width = (FT_Short)font->header.avg_width;
- bsize->height = (FT_Short)( font->header.pixel_height +
- font->header.external_leading );
- bsize->size = font->header.nominal_point_size << 6;
-
- x_res = font->header.horizontal_resolution;
- if ( !x_res )
- x_res = 72;
-
- y_res = font->header.vertical_resolution;
- if ( !y_res )
- y_res = 72;
-
- bsize->y_ppem = FT_MulDiv( bsize->size, y_res, 72 );
- bsize->y_ppem = FT_PIX_ROUND( bsize->y_ppem );
-
- /*
- * this reads:
- *
- * the nominal height is larger than the bbox's height
- *
- * => nominal_point_size contains incorrect value;
- * use pixel_height as the nominal height
- */
- if ( bsize->y_ppem > ( font->header.pixel_height << 6 ) )
- {
- FT_TRACE2(( "use pixel_height as the nominal height\n" ));
-
- bsize->y_ppem = font->header.pixel_height << 6;
- bsize->size = FT_MulDiv( bsize->y_ppem, 72, y_res );
- }
-
- bsize->x_ppem = FT_MulDiv( bsize->size, x_res, 72 );
- bsize->x_ppem = FT_PIX_ROUND( bsize->x_ppem );
- }
-
- {
- FT_CharMapRec charmap;
-
-
- charmap.encoding = FT_ENCODING_NONE;
- /* initial platform/encoding should indicate unset status? */
- charmap.platform_id = TT_PLATFORM_APPLE_UNICODE;
- charmap.encoding_id = TT_APPLE_ID_DEFAULT;
- charmap.face = root;
-
- if ( font->header.charset == FT_WinFNT_ID_MAC )
- {
- charmap.encoding = FT_ENCODING_APPLE_ROMAN;
- charmap.platform_id = TT_PLATFORM_MACINTOSH;
-/* charmap.encoding_id = TT_MAC_ID_ROMAN; */
- }
-
- error = FT_CMap_New( fnt_cmap_class,
- NULL,
- &charmap,
- NULL );
- if ( error )
- goto Fail;
- }
-
- /* set up remaining flags */
-
- if ( font->header.last_char < font->header.first_char )
- {
- FT_TRACE2(( "invalid number of glyphs\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Fail;
- }
-
- /* reserve one slot for the .notdef glyph at index 0 */
- root->num_glyphs = font->header.last_char -
- font->header.first_char + 1 + 1;
-
- if ( font->header.face_name_offset >= font->header.file_size )
- {
- FT_TRACE2(( "invalid family name offset\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Fail;
- }
- family_size = font->header.file_size - font->header.face_name_offset;
- /* Some broken fonts don't delimit the face name with a final */
- /* null byte -- the frame is erroneously one byte too small. */
- /* We thus allocate one more byte, setting it explicitly to */
- /* zero. */
- if ( FT_QALLOC( font->family_name, family_size + 1 ) )
- goto Fail;
-
- FT_MEM_COPY( font->family_name,
- font->fnt_frame + font->header.face_name_offset,
- family_size );
-
- font->family_name[family_size] = '\0';
-
- /* shrink it to the actual length */
- if ( FT_QREALLOC( font->family_name,
- family_size + 1,
- ft_strlen( font->family_name ) + 1 ) )
- goto Fail;
-
- root->family_name = font->family_name;
- root->style_name = (char *)"Regular";
-
- if ( root->style_flags & FT_STYLE_FLAG_BOLD )
- {
- if ( root->style_flags & FT_STYLE_FLAG_ITALIC )
- root->style_name = (char *)"Bold Italic";
- else
- root->style_name = (char *)"Bold";
- }
- else if ( root->style_flags & FT_STYLE_FLAG_ITALIC )
- root->style_name = (char *)"Italic";
- }
- goto Exit;
-
- Fail:
- FNT_Face_Done( fntface );
-
- Exit:
- return error;
- }
-
-
- static FT_Error
- FNT_Size_Select( FT_Size size,
- FT_ULong strike_index )
- {
- FNT_Face face = (FNT_Face)size->face;
- FT_WinFNT_Header header = &face->font->header;
-
- FT_UNUSED( strike_index );
-
-
- FT_Select_Metrics( size->face, 0 );
-
- size->metrics.ascender = header->ascent * 64;
- size->metrics.descender = -( header->pixel_height -
- header->ascent ) * 64;
- size->metrics.max_advance = header->max_width * 64;
-
- return FT_Err_Ok;
- }
-
-
- static FT_Error
- FNT_Size_Request( FT_Size size,
- FT_Size_Request req )
- {
- FNT_Face face = (FNT_Face)size->face;
- FT_WinFNT_Header header = &face->font->header;
- FT_Bitmap_Size* bsize = size->face->available_sizes;
- FT_Error error = FT_ERR( Invalid_Pixel_Size );
- FT_Long height;
-
-
- height = FT_REQUEST_HEIGHT( req );
- height = ( height + 32 ) >> 6;
-
- switch ( req->type )
- {
- case FT_SIZE_REQUEST_TYPE_NOMINAL:
- if ( height == ( ( bsize->y_ppem + 32 ) >> 6 ) )
- error = FT_Err_Ok;
- break;
-
- case FT_SIZE_REQUEST_TYPE_REAL_DIM:
- if ( height == header->pixel_height )
- error = FT_Err_Ok;
- break;
-
- default:
- error = FT_THROW( Unimplemented_Feature );
- break;
- }
-
- if ( error )
- return error;
- else
- return FNT_Size_Select( size, 0 );
- }
-
-
- static FT_Error
- FNT_Load_Glyph( FT_GlyphSlot slot,
- FT_Size size,
- FT_UInt glyph_index,
- FT_Int32 load_flags )
- {
- FNT_Face face = (FNT_Face)size->face;
- FNT_Font font;
- FT_Error error = FT_Err_Ok;
- FT_Byte* p;
- FT_UInt len;
- FT_Bitmap* bitmap = &slot->bitmap;
- FT_ULong offset;
- FT_Bool new_format;
-
-
- if ( !face )
- {
- error = FT_THROW( Invalid_Face_Handle );
- goto Exit;
- }
-
- font = face->font;
-
- if ( !font ||
- glyph_index >= (FT_UInt)( FT_FACE( face )->num_glyphs ) )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- FT_TRACE1(( "FNT_Load_Glyph: glyph index %d\n", glyph_index ));
-
- if ( glyph_index > 0 )
- glyph_index--; /* revert to real index */
- else
- glyph_index = font->header.default_char; /* the `.notdef' glyph */
-
- new_format = FT_BOOL( font->header.version == 0x300 );
- len = new_format ? 6 : 4;
-
- /* get glyph width and offset */
- offset = ( new_format ? 148 : 118 ) + len * glyph_index;
-
- if ( offset >= font->header.file_size - 2 - ( new_format ? 4 : 2 ) )
- {
- FT_TRACE2(( "invalid FNT offset\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- p = font->fnt_frame + offset;
-
- bitmap->width = FT_NEXT_USHORT_LE( p );
-
- /* jump to glyph entry */
- if ( new_format )
- offset = FT_NEXT_ULONG_LE( p );
- else
- offset = FT_NEXT_USHORT_LE( p );
-
- if ( offset >= font->header.file_size )
- {
- FT_TRACE2(( "invalid FNT offset\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- bitmap->rows = font->header.pixel_height;
- bitmap->pixel_mode = FT_PIXEL_MODE_MONO;
-
- slot->bitmap_left = 0;
- slot->bitmap_top = font->header.ascent;
- slot->format = FT_GLYPH_FORMAT_BITMAP;
-
- /* now set up metrics */
- slot->metrics.width = (FT_Pos)( bitmap->width << 6 );
- slot->metrics.height = (FT_Pos)( bitmap->rows << 6 );
- slot->metrics.horiAdvance = (FT_Pos)( bitmap->width << 6 );
- slot->metrics.horiBearingX = 0;
- slot->metrics.horiBearingY = slot->bitmap_top << 6;
-
- ft_synthesize_vertical_metrics( &slot->metrics,
- (FT_Pos)( bitmap->rows << 6 ) );
-
- if ( load_flags & FT_LOAD_BITMAP_METRICS_ONLY )
- goto Exit;
-
- /* jump to glyph data */
- p = font->fnt_frame + /* font->header.bits_offset */ + offset;
-
- /* allocate and build bitmap */
- {
- FT_Memory memory = FT_FACE_MEMORY( slot->face );
- FT_UInt pitch = ( bitmap->width + 7 ) >> 3;
- FT_Byte* column;
- FT_Byte* write;
-
-
- bitmap->pitch = (int)pitch;
- if ( !pitch ||
- offset + pitch * bitmap->rows > font->header.file_size )
- {
- FT_TRACE2(( "invalid bitmap width\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- /* note: since glyphs are stored in columns and not in rows we */
- /* can't use ft_glyphslot_set_bitmap */
- if ( FT_QALLOC_MULT( bitmap->buffer, bitmap->rows, pitch ) )
- goto Exit;
-
- column = (FT_Byte*)bitmap->buffer;
-
- for ( ; pitch > 0; pitch--, column++ )
- {
- FT_Byte* limit = p + bitmap->rows;
-
-
- for ( write = column; p < limit; p++, write += bitmap->pitch )
- *write = *p;
- }
-
- slot->internal->flags = FT_GLYPH_OWN_BITMAP;
- }
-
- Exit:
- return error;
- }
-
-
- static FT_Error
- winfnt_get_header( FT_Face face,
- FT_WinFNT_HeaderRec *aheader )
- {
- FNT_Font font = ((FNT_Face)face)->font;
-
-
- *aheader = font->header;
-
- return 0;
- }
-
-
- static const FT_Service_WinFntRec winfnt_service_rec =
- {
- winfnt_get_header /* get_header */
- };
-
- /*
- * SERVICE LIST
- *
- */
-
- static const FT_ServiceDescRec winfnt_services[] =
- {
- { FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_WINFNT },
- { FT_SERVICE_ID_WINFNT, &winfnt_service_rec },
- { NULL, NULL }
- };
-
-
- static FT_Module_Interface
- winfnt_get_service( FT_Module module,
- const FT_String* service_id )
- {
- FT_UNUSED( module );
-
- return ft_service_list_lookup( winfnt_services, service_id );
- }
-
-
-
-
- FT_CALLBACK_TABLE_DEF
- const FT_Driver_ClassRec winfnt_driver_class =
- {
- {
- FT_MODULE_FONT_DRIVER |
- FT_MODULE_DRIVER_NO_OUTLINES,
- sizeof ( FT_DriverRec ),
-
- "winfonts",
- 0x10000L,
- 0x20000L,
-
- NULL, /* module-specific interface */
-
- NULL, /* FT_Module_Constructor module_init */
- NULL, /* FT_Module_Destructor module_done */
- winfnt_get_service /* FT_Module_Requester get_interface */
- },
-
- sizeof ( FNT_FaceRec ),
- sizeof ( FT_SizeRec ),
- sizeof ( FT_GlyphSlotRec ),
-
- FNT_Face_Init, /* FT_Face_InitFunc init_face */
- FNT_Face_Done, /* FT_Face_DoneFunc done_face */
- NULL, /* FT_Size_InitFunc init_size */
- NULL, /* FT_Size_DoneFunc done_size */
- NULL, /* FT_Slot_InitFunc init_slot */
- NULL, /* FT_Slot_DoneFunc done_slot */
-
- FNT_Load_Glyph, /* FT_Slot_LoadFunc load_glyph */
-
- NULL, /* FT_Face_GetKerningFunc get_kerning */
- NULL, /* FT_Face_AttachFunc attach_file */
- NULL, /* FT_Face_GetAdvancesFunc get_advances */
-
- FNT_Size_Request, /* FT_Size_RequestFunc request_size */
- FNT_Size_Select /* FT_Size_SelectFunc select_size */
- };
-
-
-/* END */
diff --git a/contrib/libs/freetype/src/winfonts/winfnt.h b/contrib/libs/freetype/src/winfonts/winfnt.h
deleted file mode 100644
index 78137496f9..0000000000
--- a/contrib/libs/freetype/src/winfonts/winfnt.h
+++ /dev/null
@@ -1,164 +0,0 @@
-/****************************************************************************
- *
- * winfnt.h
- *
- * FreeType font driver for Windows FNT/FON files
- *
- * Copyright (C) 1996-2024 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- * Copyright 2007 Dmitry Timoshkov for Codeweavers
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
-#ifndef WINFNT_H_
-#define WINFNT_H_
-
-
-#include <freetype/ftwinfnt.h>
-#include <freetype/internal/ftdrv.h>
-
-
-FT_BEGIN_HEADER
-
-
- typedef struct WinMZ_HeaderRec_
- {
- FT_UShort magic;
- /* skipped content */
- FT_UShort lfanew;
-
- } WinMZ_HeaderRec;
-
-
- typedef struct WinNE_HeaderRec_
- {
- FT_UShort magic;
- /* skipped content */
- FT_UShort resource_tab_offset;
- FT_UShort rname_tab_offset;
-
- } WinNE_HeaderRec;
-
-
- typedef struct WinPE32_HeaderRec_
- {
- FT_ULong magic;
- FT_UShort machine;
- FT_UShort number_of_sections;
- /* skipped content */
- FT_UShort size_of_optional_header;
- /* skipped content */
- FT_UShort magic32;
- /* skipped content */
- FT_ULong rsrc_virtual_address;
- FT_ULong rsrc_size;
- /* skipped content */
-
- } WinPE32_HeaderRec;
-
-
- typedef struct WinPE32_SectionRec_
- {
- FT_Byte name[8];
- /* skipped content */
- FT_ULong virtual_address;
- FT_ULong size_of_raw_data;
- FT_ULong pointer_to_raw_data;
- /* skipped content */
-
- } WinPE32_SectionRec;
-
-
- typedef struct WinPE_RsrcDirRec_
- {
- FT_ULong characteristics;
- FT_ULong time_date_stamp;
- FT_UShort major_version;
- FT_UShort minor_version;
- FT_UShort number_of_named_entries;
- FT_UShort number_of_id_entries;
-
- } WinPE_RsrcDirRec;
-
-
- typedef struct WinPE_RsrcDirEntryRec_
- {
- FT_ULong name;
- FT_ULong offset;
-
- } WinPE_RsrcDirEntryRec;
-
-
- typedef struct WinPE_RsrcDataEntryRec_
- {
- FT_ULong offset_to_data;
- FT_ULong size;
- FT_ULong code_page;
- FT_ULong reserved;
-
- } WinPE_RsrcDataEntryRec;
-
-
- typedef struct WinNameInfoRec_
- {
- FT_UShort offset;
- FT_UShort length;
- FT_UShort flags;
- FT_UShort id;
- FT_UShort handle;
- FT_UShort usage;
-
- } WinNameInfoRec;
-
-
- typedef struct WinResourceInfoRec_
- {
- FT_UShort type_id;
- FT_UShort count;
-
- } WinResourceInfoRec;
-
-
-#define WINFNT_MZ_MAGIC 0x5A4D
-#define WINFNT_NE_MAGIC 0x454E
-#define WINFNT_PE_MAGIC 0x4550
-
-
- typedef struct FNT_FontRec_
- {
- FT_ULong offset;
-
- FT_WinFNT_HeaderRec header;
-
- FT_Byte* fnt_frame;
- FT_ULong fnt_size;
- FT_String* family_name;
-
- } FNT_FontRec, *FNT_Font;
-
-
- typedef struct FNT_FaceRec_
- {
- FT_FaceRec root;
- FNT_Font font;
-
- } FNT_FaceRec, *FNT_Face;
-
-
- FT_EXPORT_VAR( const FT_Driver_ClassRec ) winfnt_driver_class;
-
-
-FT_END_HEADER
-
-
-#endif /* WINFNT_H_ */
-
-
-/* END */
diff --git a/contrib/libs/freetype/ya.make b/contrib/libs/freetype/ya.make
deleted file mode 100644
index d013e29bbb..0000000000
--- a/contrib/libs/freetype/ya.make
+++ /dev/null
@@ -1,115 +0,0 @@
-# Generated by devtools/yamaker from nixpkgs 22.11.
-
-LIBRARY()
-
-LICENSE(
- "(FTL OR GPL-2.0-or-later)" AND
- "(FTL OR GPL-2.0-or-later)" AND
- BSL-1.0 AND
- FTL AND
- MIT AND
- MIT-Modern-Variant AND
- MIT-open-group AND
- Public-Domain AND
- Zlib
-)
-
-LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
-
-VERSION(2.13.3)
-
-ORIGINAL_SOURCE(https://gitlab.freedesktop.org/freetype/freetype/)
-
-PEERDIR(
- contrib/libs/zlib
-)
-
-ADDINCL(
- GLOBAL contrib/libs/freetype/include
- contrib/libs/freetype/include/freetype/config
- contrib/libs/freetype/src/autofit
- contrib/libs/freetype/src/base
- contrib/libs/freetype/src/bdf
- contrib/libs/freetype/src/cache
- contrib/libs/freetype/src/cff
- contrib/libs/freetype/src/cid
- contrib/libs/freetype/src/dlg
- contrib/libs/freetype/src/lzw
- contrib/libs/freetype/src/pcf
- contrib/libs/freetype/src/pfr
- contrib/libs/freetype/src/psaux
- contrib/libs/freetype/src/pshinter
- contrib/libs/freetype/src/psnames
- contrib/libs/freetype/src/raster
- contrib/libs/freetype/src/sdf
- contrib/libs/freetype/src/sfnt
- contrib/libs/freetype/src/smooth
- contrib/libs/freetype/src/svg
- contrib/libs/freetype/src/truetype
- contrib/libs/freetype/src/type1
- contrib/libs/freetype/src/type42
- contrib/libs/freetype/src/winfonts
-)
-
-NO_COMPILER_WARNINGS()
-
-NO_RUNTIME()
-
-CFLAGS(
- -DFT2_BUILD_LIBRARY
- -DFT_CONFIG_OPTION_SYSTEM_ZLIB
-)
-
-SRCS(
- src/autofit/autofit.c
- src/base/ftbase.c
- src/base/ftbbox.c
- src/base/ftbdf.c
- src/base/ftbitmap.c
- src/base/ftcid.c
- src/base/ftdebug.c
- src/base/ftfstype.c
- src/base/ftgasp.c
- src/base/ftglyph.c
- src/base/ftgxval.c
- src/base/ftinit.c
- src/base/ftmm.c
- src/base/ftotval.c
- src/base/ftpatent.c
- src/base/ftpfr.c
- src/base/ftstroke.c
- src/base/ftsynth.c
- src/base/ftsystem.c
- src/base/fttype1.c
- src/base/ftwinfnt.c
- src/bdf/bdf.c
- src/bzip2/ftbzip2.c
- src/cache/ftcache.c
- src/cff/cff.c
- src/cid/type1cid.c
- src/dlg/dlgwrap.c
- src/gzip/ftgzip.c
- src/lzw/ftlzw.c
- src/pcf/pcf.c
- src/pfr/pfr.c
- src/psaux/psaux.c
- src/pshinter/pshinter.c
- src/psnames/psnames.c
- src/raster/raster.c
- src/sdf/sdf.c
- src/sfnt/sfnt.c
- src/smooth/smooth.c
- src/svg/svg.c
- src/truetype/truetype.c
- src/type1/type1.c
- src/type42/type42.c
- src/winfonts/winfnt.c
-)
-
-IF (OS_DARWIN)
- SRCS(
- src/base/ftmac.c
- )
-ENDIF()
-
-END()
diff --git a/contrib/libs/lcms2/.yandex_meta/__init__.py b/contrib/libs/lcms2/.yandex_meta/__init__.py
deleted file mode 100644
index 1d48cb38a6..0000000000
--- a/contrib/libs/lcms2/.yandex_meta/__init__.py
+++ /dev/null
@@ -1,30 +0,0 @@
-from devtools.yamaker import fileutil
-
-from devtools.yamaker.modules import Linkable, Switch
-from devtools.yamaker.project import NixProject
-
-
-def post_build(self):
- fileutil.convert_to_utf8(f"{self.dstdir}/AUTHORS", from_="latin1")
-
-
-def post_install(self):
- with self.yamakes["."] as lcms:
- # reentrable variant of gmtime is gmtime_r on Unix, gmtime_s on Windows
- lcms.CFLAGS.remove("-DHAVE_GMTIME_R=1")
- lcms.after(
- "CFLAGS",
- Switch(
- OS_WINDOWS=Linkable(CFLAGS=["-DHAVE_GMTIME_S=1"]),
- default=Linkable(CFLAGS=["-DHAVE_GMTIME_R=1"]),
- ),
- )
-
-
-lcms2 = NixProject(
- owners=["shindo", "g:mds", "g:cpp-contrib"],
- arcdir="contrib/libs/lcms2",
- nixattr="lcms2",
- post_build=post_build,
- post_install=post_install,
-)
diff --git a/contrib/libs/lcms2/.yandex_meta/devtools.copyrights.report b/contrib/libs/lcms2/.yandex_meta/devtools.copyrights.report
deleted file mode 100644
index 438acd40c3..0000000000
--- a/contrib/libs/lcms2/.yandex_meta/devtools.copyrights.report
+++ /dev/null
@@ -1,156 +0,0 @@
-# File format ($ symbol means the beginning of a line):
-#
-# $ # this message
-# $ # =======================
-# $ # comments (all commentaries should starts with some number of spaces and # symbol)
-# ${action} {license id} {license text hash}
-# $BELONGS ./ya/make/file/relative/path/1/ya.make ./ya/make/2/ya.make
-# ${all_file_action} filename
-# $ # user commentaries (many lines)
-# $ generated description - files with this license, license text... (some number of lines that starts with some number of spaces, do not modify)
-# ${action} {license spdx} {license text hash}
-# $BELONGS ./ya/make/file/relative/path/3/ya.make
-# ${all_file_action} filename
-# $ # user commentaries
-# $ generated description
-# $ ...
-#
-# You can modify action, all_file_action and add commentaries
-# Available actions:
-# keep - keep license in contrib and use in credits
-# skip - skip license
-# remove - remove all files with this license
-# rename - save license text/links into licenses texts file, but not store SPDX into LINCENSE macro. You should store correct license id into devtools.license.spdx.txt file
-#
-# {all file action} records will be generated when license text contains filename that exists on filesystem (in contrib directory)
-# We suppose that that files can contain some license info
-# Available all file actions:
-# FILE_IGNORE - ignore file (do nothing)
-# FILE_INCLUDE - include all file data into licenses text file
-# =======================
-
-KEEP COPYRIGHT_SERVICE_LABEL 07c8fa7554d50e315318be35b61d4793
-BELONGS utils/jpgicc/ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- utils/jpgicc/LICENSE_iccjpeg [52:55]
-
-KEEP COPYRIGHT_SERVICE_LABEL 153b1c67d98d8dd69d7dcaaa31389bec
-BELONGS utils/jpgicc/ya.make
- License text:
- This software is copyright (C) 1991-2013, Thomas G. Lane, Guido Vollbeding.
- All Rights Reserved except as specified below.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- utils/jpgicc/LICENSE_iccjpeg [20:21]
-
-KEEP COPYRIGHT_SERVICE_LABEL 9855ff798e83714c245975bd9091c84b
-BELONGS utils/jpgicc/ya.make
- License text:
- Copyright property of CompuServe Incorporated
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- utils/jpgicc/LICENSE_iccjpeg [65:67]
-
-KEEP COPYRIGHT_SERVICE_LABEL aa60f9f901d8a70162904fc48f222c49
-BELONGS utils/jpgicc/ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- utils/jpgicc/LICENSE_iccjpeg [52:55]
-
-KEEP COPYRIGHT_SERVICE_LABEL c98e8a421395169a5bc32c4c4ecdafc8
-BELONGS ya.make
- License text:
- // Copyright (c) 1998-2021 Marti Maria Saguer
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/cmsgmt.c [4:4]
-
-KEEP COPYRIGHT_SERVICE_LABEL dc1c978ad126171c001998b8a02b43a8
-BELONGS ya.make
- License text:
- Copyright (c) 2023 Marti Maria Saguer
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- LICENSE [3:3]
-
-KEEP COPYRIGHT_SERVICE_LABEL ddeddc5b6b20149a38ac62a44099a2c0
-BELONGS utils/jpgicc/ya.make utils/linkicc/ya.make utils/psicc/ya.make utils/tificc/ya.make utils/transicc/ya.make ya.make
- License text:
- // Copyright (c) 1998-2023 Marti Maria Saguer
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- include/lcms2.h [4:4]
- include/lcms2_plugin.h [4:4]
- src/cmsalpha.c [4:4]
- src/cmscam02.c [4:4]
- src/cmscgats.c [4:4]
- src/cmscnvrt.c [4:4]
- src/cmserr.c [4:4]
- src/cmsgamma.c [4:4]
- src/cmshalf.c [4:4]
- src/cmsintrp.c [4:4]
- src/cmsio0.c [4:4]
- src/cmsio1.c [4:4]
- src/cmslut.c [4:4]
- src/cmsmd5.c [4:4]
- src/cmsmtrx.c [4:4]
- src/cmsnamed.c [4:4]
- src/cmsopt.c [4:4]
- src/cmspack.c [4:4]
- src/cmspcs.c [4:4]
- src/cmsplugin.c [4:4]
- src/cmsps2.c [4:4]
- src/cmssamp.c [4:4]
- src/cmssm.c [4:4]
- src/cmstypes.c [4:4]
- src/cmsvirt.c [4:4]
- src/cmswtpnt.c [4:4]
- src/cmsxform.c [4:4]
- src/lcms2_internal.h [4:4]
- utils/common/utils.h [5:5]
- utils/common/vprf.c [4:4]
- utils/common/xgetopt.c [5:5]
- utils/jpgicc/jpgicc.c [4:4]
- utils/jpgicc/jpgicc.c [1254:1255]
- utils/linkicc/linkicc.c [4:4]
- utils/linkicc/linkicc.c [274:275]
- utils/psicc/psicc.c [4:4]
- utils/psicc/psicc.c [216:217]
- utils/tificc/tificc.c [4:4]
- utils/tificc/tificc.c [1041:1042]
- utils/transicc/transicc.c [4:4]
- utils/transicc/transicc.c [1257:1258]
-
-KEEP COPYRIGHT_SERVICE_LABEL e40f0af5a3901b7c40a36232bb6f92a9
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- src/cmssm.c [207:211]
diff --git a/contrib/libs/lcms2/.yandex_meta/devtools.licenses.report b/contrib/libs/lcms2/.yandex_meta/devtools.licenses.report
deleted file mode 100644
index 97618f5baa..0000000000
--- a/contrib/libs/lcms2/.yandex_meta/devtools.licenses.report
+++ /dev/null
@@ -1,208 +0,0 @@
-# File format ($ symbol means the beginning of a line):
-#
-# $ # this message
-# $ # =======================
-# $ # comments (all commentaries should starts with some number of spaces and # symbol)
-# ${action} {license spdx} {license text hash}
-# $BELONGS ./ya/make/file/relative/path/1/ya.make ./ya/make/2/ya.make
-# ${all_file_action} filename
-# $ # user commentaries (many lines)
-# $ generated description - files with this license, license text... (some number of lines that starts with some number of spaces, do not modify)
-# ${action} {license spdx} {license text hash}
-# $BELONGS ./ya/make/file/relative/path/3/ya.make
-# ${all_file_action} filename
-# $ # user commentaries
-# $ generated description
-# $ ...
-#
-# You can modify action, all_file_action and add commentaries
-# Available actions:
-# keep - keep license in contrib and use in credits
-# skip - skip license
-# remove - remove all files with this license
-# rename - save license text/links into licenses texts file, but not store SPDX into LINCENSE macro. You should store correct license id into devtools.license.spdx.txt file
-#
-# {all file action} records will be generated when license text contains filename that exists on filesystem (in contrib directory)
-# We suppose that that files can contain some license info
-# Available all file actions:
-# FILE_IGNORE - ignore file (do nothing)
-# FILE_INCLUDE - include all file data into licenses text file
-# =======================
-# ChangeLog is changelog, it does not describe current status at all
-IGNORE_FILES ChangeLog
-
-KEEP MIT 24e6fb6f6ed9a5425a9e54ac886c7a38
-BELONGS utils/linkicc/ya.make utils/psicc/ya.make utils/tificc/ya.make utils/transicc/ya.make
-FILE_INCLUDE AUTHORS found in files: utils/linkicc/linkicc.c at line 19, utils/psicc/psicc.c at line 19, utils/tificc/tificc.c at line 19, utils/transicc/transicc.c at line 19
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: MIT
- Score : 100.00
- Match type : TEXT
- Links : http://opensource.org/licenses/mit-license.php, https://spdx.org/licenses/MIT
- Files with this license:
- utils/linkicc/linkicc.c [6:22]
- utils/psicc/psicc.c [6:22]
- utils/tificc/tificc.c [6:22]
- utils/transicc/transicc.c [6:22]
-
-KEEP Softsurfer 311038bc2326a11981bde73df7ba7705
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: LicenseRef-scancode-softsurfer
- Score : 98.08
- Match type : TEXT
- Links : http://geomalgorithms.com/a05-_intersect-1.html#Intersection%20of%202%20Planes, https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/softsurfer.LICENSE
- Files with this license:
- src/cmssm.c [208:212]
-
-KEEP MIT 399584035c417b91040964779555dfac
-BELONGS ya.make
- License text:
- MIT License
- Scancode info:
- Original SPDX id: MIT
- Score : 100.00
- Match type : REFERENCE
- Links : http://opensource.org/licenses/mit-license.php, https://spdx.org/licenses/MIT
- Files with this license:
- LICENSE [1:1]
-
-SKIP LicenseRef-scancode-free-unknown 52a6530fbc8416fff7e08fa2845d5a76
-BELONGS ya.make
-# not a license
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: LicenseRef-scancode-free-unknown
- Score : 50.00
- Match type : REFERENCE
- Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/free-unknown.LICENSE
- Files with this license:
- README.md [16:16]
-
-KEEP IJG 5540d4850b32f05c6de82e87239d100b
-BELONGS utils/jpgicc/ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: IJG
- Score : 97.18
- Match type : REFERENCE
- Links : http://fedoraproject.org/wiki/Licensing/IJG, https://spdx.org/licenses/IJG
- Files with this license:
- utils/jpgicc/LICENSE_iccjpeg [4:11]
-
-KEEP IJG 5817aede26ed47ea3d800cd135dfe5e5
-BELONGS utils/jpgicc/ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: IJG
- Score : 97.95
- Match type : TEXT
- Links : http://fedoraproject.org/wiki/Licensing/IJG, https://spdx.org/licenses/IJG
- Files with this license:
- utils/jpgicc/LICENSE_iccjpeg [13:48]
-
-KEEP MIT 7c49e6e986839189d7592cb9b4db0b4c
-BELONGS utils/jpgicc/ya.make ya.make
-FILE_INCLUDE AUTHORS found in files: include/lcms2.h at line 19, include/lcms2_plugin.h at line 19, src/cmsalpha.c at line 19, src/cmscam02.c at line 19, src/cmscgats.c at line 19, src/cmscnvrt.c at line 19, src/cmserr.c at line 19, src/cmsgamma.c at line 19, src/cmsgmt.c at line 19, src/cmshalf.c at line 19, src/cmsintrp.c at line 19, src/cmsio0.c at line 19, src/cmsio1.c at line 19, src/cmslut.c at line 19, src/cmsmd5.c at line 19, src/cmsmtrx.c at line 19, src/cmsnamed.c at line 19, src/cmsopt.c at line 19, src/cmspack.c at line 19, src/cmspcs.c at line 19, src/cmsplugin.c at line 19, src/cmsps2.c at line 19, src/cmssamp.c at line 19, src/cmssm.c at line 19, src/cmstypes.c at line 19, src/cmsvirt.c at line 19, src/cmswtpnt.c at line 19, src/cmsxform.c at line 19, src/lcms2_internal.h at line 19, utils/common/utils.h at line 20, utils/common/vprf.c at line 19, utils/common/xgetopt.c at line 20, utils/jpgicc/jpgicc.c at line 19
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: MIT
- Score : 100.00
- Match type : TEXT
- Links : http://opensource.org/licenses/mit-license.php, https://spdx.org/licenses/MIT
- Files with this license:
- include/lcms2.h [6:22]
- include/lcms2_plugin.h [6:22]
- src/cmsalpha.c [6:22]
- src/cmscam02.c [6:22]
- src/cmscgats.c [6:22]
- src/cmscnvrt.c [6:22]
- src/cmserr.c [6:22]
- src/cmsgamma.c [6:22]
- src/cmsgmt.c [6:22]
- src/cmshalf.c [6:22]
- src/cmsintrp.c [6:22]
- src/cmsio0.c [6:22]
- src/cmsio1.c [6:22]
- src/cmslut.c [6:22]
- src/cmsmd5.c [6:22]
- src/cmsmtrx.c [6:22]
- src/cmsnamed.c [6:22]
- src/cmsopt.c [6:22]
- src/cmspack.c [6:22]
- src/cmspcs.c [6:22]
- src/cmsplugin.c [6:22]
- src/cmsps2.c [6:22]
- src/cmssamp.c [6:22]
- src/cmssm.c [6:22]
- src/cmstypes.c [6:22]
- src/cmsvirt.c [6:22]
- src/cmswtpnt.c [6:22]
- src/cmsxform.c [6:22]
- src/lcms2_internal.h [6:22]
- utils/common/utils.h [7:23]
- utils/common/vprf.c [6:22]
- utils/common/xgetopt.c [7:23]
- utils/jpgicc/jpgicc.c [6:22]
-
-KEEP MIT 94890220f883df92236a2e64421f8224
-BELONGS ya.make
- License text:
- redistribute such patches, please make sure to include the mail, or at least the MIT license. By including the MIT license you prevent to get in legal trouble.
- Scancode info:
- Original SPDX id: MIT
- Score : 100.00
- Match type : REFERENCE
- Links : http://opensource.org/licenses/mit-license.php, https://spdx.org/licenses/MIT
- Files with this license:
- SECURITY.md [22:22]
-
-SKIP LicenseRef-scancode-unknown-license-reference af7985bc98b322384bcb4e1d99c5d0e4
-BELONGS utils/psicc/ya.make
- License text:
- "engine. Both lcms and this program are freeware. You can\n"
- Scancode info:
- Original SPDX id: LicenseRef-scancode-unknown-license-reference
- Score : 100.00
- Match type : REFERENCE
- Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/unknown-license-reference.LICENSE
- Files with this license:
- utils/psicc/psicc.c [61:61]
-
-KEEP MIT b1101be903428cec3d118f4496ad8c15
-BELONGS ya.make
- License text:
- Please understand that this is a lot of work, and obviously it can fail as well, so the “no guarantee†clause of MIT license applies. If you choose to
- Scancode info:
- Original SPDX id: MIT
- Score : 100.00
- Match type : REFERENCE
- Links : http://opensource.org/licenses/mit-license.php, https://spdx.org/licenses/MIT
- Files with this license:
- SECURITY.md [21:21]
-
-KEEP MIT fe08b97a5e3117443682cd1138cb81cd
-BELONGS ya.make
- License text:
- redistribute such patches, please make sure to include the mail, or at least the MIT license. By including the MIT license you prevent to get in legal trouble.
- Scancode info:
- Original SPDX id: MIT
- Score : 100.00
- Match type : REFERENCE
- Links : http://opensource.org/licenses/mit-license.php, https://spdx.org/licenses/MIT
- Files with this license:
- SECURITY.md [22:22]
-
-KEEP MIT feae1bf7eb9fd714ebbdf0b08a0a3afd
-BELONGS ya.make
-FILE_INCLUDE AUTHORS found in files: LICENSE at line 19
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: MIT
- Score : 100.00
- Match type : TEXT
- Links : http://opensource.org/licenses/mit-license.php, https://spdx.org/licenses/MIT
- Files with this license:
- LICENSE [5:22]
diff --git a/contrib/libs/lcms2/.yandex_meta/licenses.list.txt b/contrib/libs/lcms2/.yandex_meta/licenses.list.txt
deleted file mode 100644
index 3886eac675..0000000000
--- a/contrib/libs/lcms2/.yandex_meta/licenses.list.txt
+++ /dev/null
@@ -1,139 +0,0 @@
-====================COPYRIGHT====================
- Copyright 2001, softSurfer (www.softsurfer.com)
- This code may be freely used and modified for any purpose
- providing that this copyright notice is included with it.
- SoftSurfer makes no warranty for this code, and cannot be held
- liable for any real or imagined damage resulting from its use.
-
-
-====================COPYRIGHT====================
-// Copyright (c) 1998-2021 Marti Maria Saguer
-
-
-====================COPYRIGHT====================
-// Copyright (c) 1998-2023 Marti Maria Saguer
-
-
-====================COPYRIGHT====================
-Copyright (c) 2023 Marti Maria Saguer
-
-
-====================File: AUTHORS====================
-
-Main Author
-------------
-Marti Maria
-
-
-Contributors
-------------
-Bob Friesenhahn
-Kai-Uwe Behrmann
-Stuart Nixon
-Jordi Vilar
-Richard Hughes
-Auke Nauta
-Chris Evans (Google)
-Lorenzo Ridolfi
-Robin Watts (Artifex)
-Shawn Pedersen
-Andrew Brygin
-Samuli Suominen
-Florian Höch
-Aurelien Jarno
-Claudiu Cebuc
-Michael Vhrel (Artifex)
-Michal Cihar
-Daniel Kaneider
-Mateusz Jurczyk (Google)
-Paul Miller
-Sébastien Léon
-Christian Schmitz
-XhmikosR
-Stanislav Brabec (SuSe)
-Leonhard Gruenschloss (Google)
-Patrick Noffke
-Christopher James Halse Rogers
-John Hein
-Thomas Weber (Debian)
-Mark Allen
-Noel Carboni
-Sergei Trofimovic
-Philipp Knechtges
-Amyspark
-Lovell Fuller
-Eli Schwartz
-Diogo Teles Sant'Anna
-
-Special Thanks
---------------
-Artifex software
-AlienSkin software
-libVIPS
-Jan Morovic
-Jos Vernon (WebSupergoo)
-Harald Schneider (Maxon)
-Christian Albrecht
-Dimitrios Anastassakis
-Lemke Software
-Tim Zaman
-
-
-====================MIT====================
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-
-====================MIT====================
-MIT License
-
-
-====================MIT====================
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject
-to the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-====================MIT====================
-Please understand that this is a lot of work, and obviously it can fail as well, so the “no guarantee†clause of MIT license applies. If you choose to
-
-
-====================MIT====================
-redistribute such patches, please make sure to include the mail, or at least the MIT license. By including the MIT license you prevent to get in legal trouble.
-
-
-====================Softsurfer====================
- This code may be freely used and modified for any purpose
- providing that this copyright notice is included with it.
- SoftSurfer makes no warranty for this code, and cannot be held
- liable for any real or imagined damage resulting from its use.
- Users of this code must verify correctness for their application.
diff --git a/contrib/libs/lcms2/.yandex_meta/override.nix b/contrib/libs/lcms2/.yandex_meta/override.nix
deleted file mode 100644
index 222cc50414..0000000000
--- a/contrib/libs/lcms2/.yandex_meta/override.nix
+++ /dev/null
@@ -1,12 +0,0 @@
-pkgs: attrs: with pkgs; with attrs; rec {
- version = "2.16";
-
- src = fetchFromGitHub {
- owner = "mm2";
- repo = "Little-CMS";
- rev = "lcms${version}";
- hash = "sha256-pI+ZyM9UfiW0/GLk+gsoJuRQ1Nz3WRfSCHnwkFPBtzc=";
- };
-
- patches = [];
-}
diff --git a/contrib/libs/lcms2/AUTHORS b/contrib/libs/lcms2/AUTHORS
deleted file mode 100644
index 9b10080e32..0000000000
--- a/contrib/libs/lcms2/AUTHORS
+++ /dev/null
@@ -1,58 +0,0 @@
-
-Main Author
-------------
-Marti Maria
-
-
-Contributors
-------------
-Bob Friesenhahn
-Kai-Uwe Behrmann
-Stuart Nixon
-Jordi Vilar
-Richard Hughes
-Auke Nauta
-Chris Evans (Google)
-Lorenzo Ridolfi
-Robin Watts (Artifex)
-Shawn Pedersen
-Andrew Brygin
-Samuli Suominen
-Florian Höch
-Aurelien Jarno
-Claudiu Cebuc
-Michael Vhrel (Artifex)
-Michal Cihar
-Daniel Kaneider
-Mateusz Jurczyk (Google)
-Paul Miller
-Sébastien Léon
-Christian Schmitz
-XhmikosR
-Stanislav Brabec (SuSe)
-Leonhard Gruenschloss (Google)
-Patrick Noffke
-Christopher James Halse Rogers
-John Hein
-Thomas Weber (Debian)
-Mark Allen
-Noel Carboni
-Sergei Trofimovic
-Philipp Knechtges
-Amyspark
-Lovell Fuller
-Eli Schwartz
-Diogo Teles Sant'Anna
-
-Special Thanks
---------------
-Artifex software
-AlienSkin software
-libVIPS
-Jan Morovic
-Jos Vernon (WebSupergoo)
-Harald Schneider (Maxon)
-Christian Albrecht
-Dimitrios Anastassakis
-Lemke Software
-Tim Zaman
diff --git a/contrib/libs/lcms2/ChangeLog b/contrib/libs/lcms2/ChangeLog
deleted file mode 100644
index e5f7242b18..0000000000
--- a/contrib/libs/lcms2/ChangeLog
+++ /dev/null
@@ -1,288 +0,0 @@
------------------------
-2.16 Featured release
------------------------
-New import .CUBE files as RGB devicelinks
-New Read/Write MHC2 tags for Windows GPU access
-New Support for UTF8 on multilocalized unicode functions
-New Suppot for OkLab color space, built-in and formatter.
-Improved floating point transforms float -> integer are now honored as float
-Improved MSYS2, mingw is now supported
-Improved proferred CMM, platform and creator now survives profile edition.
-Fixed tificc now can deal with Lab TIFF
-Fixed code can now be compiled by a C++17 compiler, "register" keywork use detected at compile time.
-Fixed Reverted postcript creation that corrupted some interpreters.
-
------------------------
-2.15 Maintenance release
------------------------
-New MESON build system, many thanks to amispark and Lovell Fuller for bringing this.
-Fixed a bug that caused memory corruption on colord
-cmsReadRawTag can read portions of tags again. Removing this caused colord to segfault when dumping profiles
-Added more checks based of fuzzer discoveries.
-MSYS2 can now compile lcms2
-Checked on Apple Silicon M1 and M2
-Fixed a bug of fastfloat plug-in that affected Krita CMYK color selector
-
------------------------
-2.14 Featured release
------------------------
-lcms2 now implements ICC specification 4.4
-New multi-threaded plug-in
-several fixes to keep fuzzers happy
-Remove check on DLL when CMS_NO_REGISTER_KEYWORD is used
-Added more validation against broken profiles
-Add more help to several tools
-
------------------------
-2.13.1 Hot fix
------------------------
-Fix for pure white going gray in grayscale transforms.
-
------------------------
-2.13 Featured release
------------------------
-Added support for premultiplied alpha
-tifficc can now handle alpha channels, both unassociated and premultiplied
-Better documentation
-CGATS parser can now deal with very long strings
-Added Projects for Visual Studio 2020
-Travis CI discontinued, GitHub actions used instead
-Added a very preliminar meson build script (thanks to xclaesse)
-Added ARM64 target to visual studio 2019 (thanks to gaborkertesz-linaro)
-Added thread safe code to get time
-Added automatic linear space detection
-Added cmsGetStageContextID function
-Added cmsDetectRGBProfileGamma function
-configure now accepts --without-fastfloat to turn plugin off
-autogen.sh has now a --distclean toggle to get rid of all autotools generated files
-Checked to work on STM32 Cortex-A, Cortex-M families
-Bug & typos fixing (thanks to many reporters and contributors)
-
------------------------
-2.12 Maintenance release
------------------------
-Added new build-in sigmoidal tone curve
-Added XCode 12 project
-Added support for multichannel input up to 15 channels
-Fix LUT8 write matrix
-Fix version mess on 10/11
-Fix tools & samples xgetopt
-Fix warnings on different function pointers
-Fix matlab MEX compilation
-plugin: cleanup and better SSE detection
-plugin: add lab to any on float
-plugin: it can now be compiled as C++
-recover PDF documentation, but try to keep it under a reasonable size.
-Prevent a rare but possible out-of-bounds read in postscript generator
-Remove unused variables
-
------------------------
-2.11 Maintenance release
------------------------
-Fixed __cpuid() on fast float plugin to allow gnu gcc
-Fixed copy alpha bounds check
-Fixed data race condition on contexts pool
-Fixed LUT16 write matrix on multichannel V2 profiles
-
------------------------
-2.10 Featured release
------------------------
-Added a compilation toggle to remove "register" keyword in API.
-Previously commercial, fast_float plug-in is now released as open source under GPL3 license.
-MD5 functions are now accessible through plug-in API.
-Added support for Visual Studio 2019
-Bug fixing.
-
-
------------------------
-2.9 Maintenance release
------------------------
-Several fixes related with security, and therefore not detailed here.
-C++ compiles now without warnings
-Added OSX and clang in travis
-Added a travis-ci test matrix for many compilers and OS. Thanks to Thomas Weber (debian) for this great improvement.
-testbed can now work with dynamic versions of library
-Fixed wrong planar formatters regarding linestride interpretation
-
------------------------
-2.8 Featured release
------------------------
-
-Changed ChangeLog direction
-Fixed many typos in comments, thanks to Stefan Weil for doing that.
-Fixed localization bug, added a new test case crayons.icc thanks to Richard Hughes for providing the profile.
-Fixed a bug in optimizer that made some formats (i.e, bits planar) unavailable
-Fixed misalignment problems on Alpha. The compiler does not align strings, and accessing begin of string as a uint16 makes code to fail.
-Added some extra checks to the tools and examples.
-Fixed a bug that prevented to read luminance tag
-BIG amount of functionality contributed/Sponsored by Alien Skin Software: TransformStride, copyAlpha, performance plug-ins. Fixes some warnings as well.
-Added an extra _ to _stdcall to make it more portable
-Fixed a bug in transicc for named color profiles
-Fixed several compiler warnings
-Added support for Visual Studio 2015
-Fixed for XCODE project
-
------------------------
-2.7 Maintenance release
------------------------
-
-Added a version retrieval function
-Added an option in transicc for working in bounded mode
-Fixed wrong handling of extra channels in some formatters.
-Added a project for VS2013
-Added license for iccjpeg.c
-New project for mac
-Added a global optimization that merges consecutive matrices in pipelines. Fixes loss of precision in some transforms
-Added a flag to clip negative values in unbounded transforms (only gray, rgb, cmyk)
-Move unused var suppresor before the `return` statements.
-Remove dead code.
-Add missing comma in CGATS parser
-utils/jpgicc/iccjpeg.c: Fix check if unsigned variable 'total_length'… …
-Some maintenance fixes
-Remove unused vcproj files
-Added a function to retrieve the iohandler of a given profile object
-Added a safety check on named color lists
-Fixed a macro clash on SNONE.
-Fixed a possible segmentation fault in a non-happy path
-
------------------------
-2.6 Featured release
------------------------
-
-Added pthread dependency. From now lcms supports multithreading
-Fix for delete tag memory corruption
-Added directories for tiff, jpeg in configure script
-New locking plug-in, from Artifex
-Big revamp on Contexts, from Artifex
-Fixed memory leaks on error handling
-Changed endianness detection for PowerPC
-Added a way to retrieve matrix shaper always, no matter LUT is present
-Fixed a bug in PCS/Colorspace order when reading V2 Lab devicelinks
-Fixed some indexing out of bounds in floating point interpolation
-Fixed a double free in recovering from a previous error in default intent handler.
-
------------------------
-2.5 Maintenance release
------------------------
-
-Added some checks for non-happy path, mostly failing mallocs
-Transform2Devicelink now keeps white point when guessing deviceclass is enabled
-Rendering intent used when creating the transform is now propagated to profile header in cmsTransform2Devicelink. This is because 7.2.15 in spec 4.3
-Added a simple project for cppcheck
-Added support for VS2012
-Remove spurious tabs added by git merge of pull request
-Fixed a bug in parametric curves
-Added some fixes from XhmikosR
-Added TIFF Lab16 handling on tifficc
-More changes from Artifex
-Added identity curves support for write V2 LUT
-Added a way to read the profile creator from header
-Added a reference for Mac MLU tag
-Fixed devicelink generation for 8 bits
-Several minor issues found by cppcheck
-Several improvements in cgats parser.
-Fixed some bugs on floating point curves.
-Fixed a bug on big endian platforms not supporting uint64 or long long.
-Added error descriptions on cmsSmoothToneCurve
-Added new cmsPlugInTHR() and fixed some race conditions (thanks to Artifex)
-update black point detection algorithm to reflect ICC changes
-Fixed some 64 bit warnings on size_t to uint32 conversions
-Fixed a multithead bug on optimization (StageDEF)
-RGB profiles using same tone curves for several channels are storing now only one copy of the curve (saves space)
-User defined parametric curves can now be saved in ICC profiles.
-
---------------------
-2.4 Featured release
---------------------
-
-Added a check for maximum input channels
-Fixed an uninitialized read on PatchLUT
-Fixed a bug in XYZ floating point PCS
-added half float variants (ABGR and so)
-Added formatter resolution after xform optimization plugin
-Fixed a bug in transicc when clot tables are present
-Added a conditional compilatio flag for "half" support
-Fixed a bug on named color profiles.
-Fixed a typo on tificc and jpgicc names, thanks to Elle Stone for reporting.
-Added half float support
-Increased security checks, thanks to Mateusz Jurczyk, from Google.
-Fixed a bug on IT8 reading of negative numbers.
-Fixed a bug on ending zero when saving a IT8 to memory
-Internal stage structs are now accessible through plug-in API
-Added a new plug-in type
-Added getPipelineContextID
-Fixed a bug in pipeline duplication
-gamma 1.0 can now operate in unbounded mode
-Exposed internal overview table for tone curves
-Added a new plug in entry for full transform
-Added support for transforms on planar data with different stride
-Added black point detection algorithm from Adobe paper
-Fixed a bug in black preservation checking
-Added performance improvements from several contributors, mostly Artifex
-Fixed uint64 to work in systems without long long native type
-Fixed a bug in the named color devicelink generation
-
------------------------
-2.3 Maintenance release
------------------------
-
-Added compatibility with Argyll's CGATS parser
-Updated to ICC spec 4.3
-Adding a memory alignment macro for CGATS parser
-Fixed a bug on the range of data in transicc, when colorant tag is specified
-Fixed Absolute colorimetric intent issues
-Fixed encoding for floating point tags in Lab/XYZ
-Fixed a 0 byte allocation issue in _cmsCreateSubAllocChunk
-
------------------------
-2.2 Maintenance release
------------------------
-
-Pascal unit now is supported by Free Pascal Compiler
-Fixed a bug on ReadRAWtag
-Added dictionary metatag support
-Fixed a bug in black preservation and slightly non-monotonic curves
-Added named color functionality
-Fixed a bug that made crash black preservation on CMYK2CMYK devicelinks
-Added functions to retrieve formatters from transforms
-Profiles with weird curves are not prone to p`relinearization optimization.
-changed memmove to memcpy in cache for xput improvement
-Fixed GBD bug (out of bounds memory overwrite)
-Fixed some potential issues as NULL dereferencing
-Updated linkicc to 2.1, cleanup
-Removed pthreads need
-Fixed severa bugs in absolute colorimetric intent
-
------------------------
-2.1 Maintenance release
------------------------
-
-Added bound check in floating point interpolation
-Fixed a bug on curve reversing when source curves have few points
-Added Duotone support (Bilinear interpolation)
-Fixed delphi interface
-linkicc now stores the rendering intent in the profile header
-Fixed several integer overflow and other integrity checks, thanks to Chris Evans
-Fixed an issue on curve inversion
-Fixed memory leaks on when recovering from errors
-Fixed a bug in psid and profile sequence tags
-Fixed a bug in device link creation on v4 profiles
-Fixed a bug in tificc in floating point formats
-Peliminary Delphi wrapper
-Fixed some typos in error messages
-Added cmsTagLinkedTo
-Fixed VC2010, VC2008 projects
-Added a check on jpgicc for NULL transforms
-Added UTILS_UNUSED_PARAMETER for samples
-Added cmsChangeBufferFormat for backwards compatibility
-Fixed a bug on Lab + Alpha float formatters, added such predefined formatters as well
-Fixed a bug on transicc that made profiles with output colorants info to malfunction
-Fixed a bug that prevented linkicc to work
-Fixed a bug on V2 CHAD construction, affects absolute colorimetric intent
-
------------------------
-2.0 Major version bump
------------------------
-
-
-
diff --git a/contrib/libs/lcms2/INSTALL b/contrib/libs/lcms2/INSTALL
deleted file mode 100644
index 2e5ee4adf9..0000000000
--- a/contrib/libs/lcms2/INSTALL
+++ /dev/null
@@ -1,2 +0,0 @@
-
- Please see the documentation in doc folder
diff --git a/contrib/libs/lcms2/README.md b/contrib/libs/lcms2/README.md
deleted file mode 100644
index 8655d0dfa2..0000000000
--- a/contrib/libs/lcms2/README.md
+++ /dev/null
@@ -1,18 +0,0 @@
-
-![Little CMS](doc/logo-small.png)
-
-# About Little CMS
-[www.littlecms.com](https://www.littlecms.com)
-
-Little CMS intends to be an **OPEN SOURCE** small-footprint color management engine, with special focus on accuracy and performance. It uses the International Color Consortium standard (ICC), which is the modern standard when regarding to color management. The ICC specification is widely used and is referred to in many International and other de-facto standards. It was approved as an International Standard, ISO 15076-1, in 2005.
-
-
-
-# Conformance
-Little CMS is a **FULL IMPLEMENTATION** of ICC specification 4.4, it fully supports all kind of V2 and V4 profiles, including abstract, devicelink and named color profiles. Check the tutorial for a exhaustive list of features.
-
-
-# A bit of story
-Since the initial release, back in 1998, Little CMS has grown to become one of the most popular open-source color management libraries, and has been used in a large number of production projects, in areas as printer firmware, monitors, digital cameras, RIPs, publishing, scientific, and many others. You can find Little CMS in most Linux distributions, and it's released under an open source license.
-
-### Please see the complete documentation in doc folder
diff --git a/contrib/libs/lcms2/SECURITY.md b/contrib/libs/lcms2/SECURITY.md
deleted file mode 100644
index a5c0f965db..0000000000
--- a/contrib/libs/lcms2/SECURITY.md
+++ /dev/null
@@ -1,27 +0,0 @@
-# Security Policy
-
-## Supported Versions
-
-Security updates are applied only to the latest release.
-
-## Reporting a Vulnerability
-
-LittleCMS is located deep in the Linux dependency tree. So, security issues are real and should be addressed. The proposed process is quite simple, if you detect a potential security issue and you are able to create a patch, please send us the patch to analyse. We have an extensive test bed of apps and utilities using lcms, so we can check if all those goes fine. If you don’t want to create a patch and only want to report the vulnerability, thats ok too. and we will be very gratefull. Just contact us.
-
-**Please avoid public advisories if possible, as doing that, hints how to use the flaw for malicious use**.
-
-Please don’t make noise to gain popularity, this can result in bad karma to you. Any CVE without reliable proof will be promptly disputed.
-
-Please don’t use untrusted patches from 3rd parties. We had an incident years ago with so called “security experts†trying to add a back door by using a crafted patch.
-
-Credits to vulnerability busters will be given on each release
-
-After the patch proves to be harmless, I will send to the mailing list a signed mail with the patch attached.
-That is, you got a patch from upstream that upstream claims to be reasonably tested. I will apply the same checks that I do before a normal release.
-Please understand that this is a lot of work, and obviously it can fail as well, so the “no guarantee†clause of MIT license applies. If you choose to
-redistribute such patches, please make sure to include the mail, or at least the MIT license. By including the MIT license you prevent to get in legal trouble.
-
-## Using GitHub security advisory
-
-Please disclose it at our [security advisory](https://github.com/mm2/Little-CMS/security/advisories/new).
-
diff --git a/contrib/libs/lcms2/include/lcms2.h b/contrib/libs/lcms2/include/lcms2.h
deleted file mode 100644
index f75a7042be..0000000000
--- a/contrib/libs/lcms2/include/lcms2.h
+++ /dev/null
@@ -1,1997 +0,0 @@
-//---------------------------------------------------------------------------------
-//
-// Little Color Management System
-// Copyright (c) 1998-2023 Marti Maria Saguer
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//---------------------------------------------------------------------------------
-//
-// Version 2.16
-//
-
-#ifndef _lcms2_H
-
-// ********** Configuration toggles ****************************************
-
-// Uncomment this one if you are using big endian machines
-// #define CMS_USE_BIG_ENDIAN 1
-
-// Uncomment this one if your compiler/machine does NOT support the
-// "long long" type.
-// #define CMS_DONT_USE_INT64 1
-
-// Uncomment this if your compiler doesn't work with fast floor function
-// #define CMS_DONT_USE_FAST_FLOOR 1
-
-// Uncomment this line if you want lcms to use the black point tag in profile,
-// if commented, lcms will compute the black point by its own.
-// It is safer to leave it commented out
-// #define CMS_USE_PROFILE_BLACK_POINT_TAG 1
-
-// Uncomment this line if you are compiling as C++ and want a C++ API
-// #define CMS_USE_CPP_API
-
-// Uncomment this line if you need strict CGATS syntax. Makes CGATS files to
-// require "KEYWORD" on undefined identifiers, keep it commented out unless needed
-// #define CMS_STRICT_CGATS 1
-
-// Uncomment to get rid of the tables for "half" float support
-// #define CMS_NO_HALF_SUPPORT 1
-
-// Uncomment to get rid of pthreads/windows dependency
-// #define CMS_NO_PTHREADS 1
-
-// Uncomment this for special windows mutex initialization (see lcms2_internal.h)
-// #define CMS_RELY_ON_WINDOWS_STATIC_MUTEX_INIT
-
-// Uncomment this to remove the "register" storage class
-#define CMS_NO_REGISTER_KEYWORD 1
-
-// ********** End of configuration toggles ******************************
-
-// Needed for streams
-#include <stdio.h>
-
-// Needed for portability (C99 per 7.1.2)
-#include <limits.h>
-#include <time.h>
-#include <stddef.h>
-
-#ifndef CMS_USE_CPP_API
-# ifdef __cplusplus
-# if __cplusplus >= 201703L
-# define CMS_NO_REGISTER_KEYWORD 1
-# endif
-extern "C" {
-# endif
-#endif
-
-// Version/release
-#define LCMS_VERSION 2160
-
-// I will give the chance of redefining basic types for compilers that are not fully C99 compliant
-#ifndef CMS_BASIC_TYPES_ALREADY_DEFINED
-
-// Base types
-typedef unsigned char cmsUInt8Number; // That is guaranteed by the C99 spec
-typedef signed char cmsInt8Number; // That is guaranteed by the C99 spec
-
-#if CHAR_BIT != 8
-# error "Unable to find 8 bit type, unsupported compiler"
-#endif
-
-// IEEE float storage numbers
-typedef float cmsFloat32Number;
-typedef double cmsFloat64Number;
-
-// 16-bit base types
-#if (USHRT_MAX == 65535U)
- typedef unsigned short cmsUInt16Number;
-#elif (UINT_MAX == 65535U)
- typedef unsigned int cmsUInt16Number;
-#else
-# error "Unable to find 16 bits unsigned type, unsupported compiler"
-#endif
-
-#if (SHRT_MAX == 32767)
- typedef short cmsInt16Number;
-#elif (INT_MAX == 32767)
- typedef int cmsInt16Number;
-#else
-# error "Unable to find 16 bits signed type, unsupported compiler"
-#endif
-
-// 32-bit base type
-#if (UINT_MAX == 4294967295U)
- typedef unsigned int cmsUInt32Number;
-#elif (ULONG_MAX == 4294967295U)
- typedef unsigned long cmsUInt32Number;
-#else
-# error "Unable to find 32 bit unsigned type, unsupported compiler"
-#endif
-
-#if (INT_MAX == +2147483647)
- typedef int cmsInt32Number;
-#elif (LONG_MAX == +2147483647)
- typedef long cmsInt32Number;
-#else
-# error "Unable to find 32 bit signed type, unsupported compiler"
-#endif
-
-// 64-bit base types
-#ifndef CMS_DONT_USE_INT64
-# if (ULONG_MAX == 18446744073709551615U)
- typedef unsigned long cmsUInt64Number;
-# elif (ULLONG_MAX == 18446744073709551615U)
- typedef unsigned long long cmsUInt64Number;
-# else
-# define CMS_DONT_USE_INT64 1
-# endif
-# if (LONG_MAX == +9223372036854775807)
- typedef long cmsInt64Number;
-# elif (LLONG_MAX == +9223372036854775807)
- typedef long long cmsInt64Number;
-# else
-# define CMS_DONT_USE_INT64 1
-# endif
-#endif
-#endif
-
-// Handle "register" keyword
-#if defined(CMS_NO_REGISTER_KEYWORD)
-# define CMSREGISTER
-#else
-# define CMSREGISTER register
-#endif
-
-// In the case 64 bit numbers are not supported by the compiler
-#ifdef CMS_DONT_USE_INT64
- typedef cmsUInt32Number cmsUInt64Number[2];
- typedef cmsInt32Number cmsInt64Number[2];
-#endif
-
-// Derivative types
-typedef cmsUInt32Number cmsSignature;
-typedef cmsUInt16Number cmsU8Fixed8Number;
-typedef cmsInt32Number cmsS15Fixed16Number;
-typedef cmsUInt32Number cmsU16Fixed16Number;
-
-// Boolean type, which will be using the native integer
-typedef int cmsBool;
-
-// Try to detect windows
-#if defined (_WIN32) || defined(_WIN64) || defined(WIN32) || defined(_WIN32_)
-# define CMS_IS_WINDOWS_ 1
-#endif
-
-#ifdef _MSC_VER
-# define CMS_IS_WINDOWS_ 1
-#endif
-
-#ifdef __BORLANDC__
-# define CMS_IS_WINDOWS_ 1
-#endif
-
-// Try to detect big endian platforms. This list can be endless, so primarily rely on the configure script
-// on Unix-like systems, and allow it to be set on the compiler command line using
-// -DCMS_USE_BIG_ENDIAN or something similar
-#ifdef CMS_USE_BIG_ENDIAN // set at compiler command line takes overall precedence
-
-# if CMS_USE_BIG_ENDIAN == 0
-# undef CMS_USE_BIG_ENDIAN
-# endif
-
-#else // CMS_USE_BIG_ENDIAN
-
-# ifdef WORDS_BIGENDIAN // set by configure (or explicitly on compiler command line)
-# define CMS_USE_BIG_ENDIAN 1
-# else // WORDS_BIGENDIAN
-// Fall back to platform/compiler specific tests
-# if defined(__sgi__) || defined(__sgi) || defined(sparc)
-# define CMS_USE_BIG_ENDIAN 1
-# endif
-
-# if defined(__s390__) || defined(__s390x__)
-# define CMS_USE_BIG_ENDIAN 1
-# endif
-
-# ifdef macintosh
-# ifdef __BIG_ENDIAN__
-# define CMS_USE_BIG_ENDIAN 1
-# endif
-# ifdef __LITTLE_ENDIAN__
-# undef CMS_USE_BIG_ENDIAN
-# endif
-# endif
-# endif // WORDS_BIGENDIAN
-
-# if defined(_HOST_BIG_ENDIAN) || defined(__BIG_ENDIAN__)
-# define CMS_USE_BIG_ENDIAN 1
-# endif
-
-#endif // CMS_USE_BIG_ENDIAN
-
-
-// Calling convention -- this is hardly platform and compiler dependent
-#if defined(CMS_IS_WINDOWS_) && !defined(__GNUC__)
-# if defined(CMS_DLL) || defined(CMS_DLL_BUILD)
-# ifdef __BORLANDC__
-# define CMSEXPORT __stdcall _export
-# define CMSAPI
-# else
-# define CMSEXPORT __stdcall
-# ifdef CMS_DLL_BUILD
-# define CMSAPI __declspec(dllexport)
-# else
-# define CMSAPI __declspec(dllimport)
-# endif
-# endif
-# else
-# define CMSEXPORT
-# define CMSAPI
-# endif
-#else // not Windows
-# ifdef HAVE_FUNC_ATTRIBUTE_VISIBILITY
-# define CMSEXPORT
-# define CMSAPI __attribute__((visibility("default")))
-# else
-# define CMSEXPORT
-# define CMSAPI
-# endif
-#endif // CMS_IS_WINDOWS_
-
-#ifdef HasTHREADS
-# if HasTHREADS == 1
-# undef CMS_NO_PTHREADS
-# else
-# define CMS_NO_PTHREADS 1
-# endif
-#endif
-
-// Some common definitions
-#define cmsMAX_PATH 256
-
-#ifndef FALSE
-# define FALSE 0
-#endif
-#ifndef TRUE
-# define TRUE 1
-#endif
-
-// D50 XYZ normalized to Y=1.0
-#define cmsD50X 0.9642
-#define cmsD50Y 1.0
-#define cmsD50Z 0.8249
-
-// V4 perceptual black
-#define cmsPERCEPTUAL_BLACK_X 0.00336
-#define cmsPERCEPTUAL_BLACK_Y 0.0034731
-#define cmsPERCEPTUAL_BLACK_Z 0.00287
-
-// Definitions in ICC spec
-#define cmsMagicNumber 0x61637370 // 'acsp'
-#define lcmsSignature 0x6c636d73 // 'lcms'
-
-
-// Base ICC type definitions
-typedef enum {
- cmsSigChromaticityType = 0x6368726D, // 'chrm'
- cmsSigcicpType = 0x63696370, // 'cicp'
- cmsSigColorantOrderType = 0x636C726F, // 'clro'
- cmsSigColorantTableType = 0x636C7274, // 'clrt'
- cmsSigCrdInfoType = 0x63726469, // 'crdi'
- cmsSigCurveType = 0x63757276, // 'curv'
- cmsSigDataType = 0x64617461, // 'data'
- cmsSigDictType = 0x64696374, // 'dict'
- cmsSigDateTimeType = 0x6474696D, // 'dtim'
- cmsSigDeviceSettingsType = 0x64657673, // 'devs'
- cmsSigLut16Type = 0x6d667432, // 'mft2'
- cmsSigLut8Type = 0x6d667431, // 'mft1'
- cmsSigLutAtoBType = 0x6d414220, // 'mAB '
- cmsSigLutBtoAType = 0x6d424120, // 'mBA '
- cmsSigMeasurementType = 0x6D656173, // 'meas'
- cmsSigMultiLocalizedUnicodeType = 0x6D6C7563, // 'mluc'
- cmsSigMultiProcessElementType = 0x6D706574, // 'mpet'
- cmsSigNamedColorType = 0x6E636f6C, // 'ncol' -- DEPRECATED!
- cmsSigNamedColor2Type = 0x6E636C32, // 'ncl2'
- cmsSigParametricCurveType = 0x70617261, // 'para'
- cmsSigProfileSequenceDescType = 0x70736571, // 'pseq'
- cmsSigProfileSequenceIdType = 0x70736964, // 'psid'
- cmsSigResponseCurveSet16Type = 0x72637332, // 'rcs2'
- cmsSigS15Fixed16ArrayType = 0x73663332, // 'sf32'
- cmsSigScreeningType = 0x7363726E, // 'scrn'
- cmsSigSignatureType = 0x73696720, // 'sig '
- cmsSigTextType = 0x74657874, // 'text'
- cmsSigTextDescriptionType = 0x64657363, // 'desc'
- cmsSigU16Fixed16ArrayType = 0x75663332, // 'uf32'
- cmsSigUcrBgType = 0x62666420, // 'bfd '
- cmsSigUInt16ArrayType = 0x75693136, // 'ui16'
- cmsSigUInt32ArrayType = 0x75693332, // 'ui32'
- cmsSigUInt64ArrayType = 0x75693634, // 'ui64'
- cmsSigUInt8ArrayType = 0x75693038, // 'ui08'
- cmsSigVcgtType = 0x76636774, // 'vcgt'
- cmsSigViewingConditionsType = 0x76696577, // 'view'
- cmsSigXYZType = 0x58595A20, // 'XYZ '
- cmsSigMHC2Type = 0x4D484332 // 'MHC2'
-
-
-} cmsTagTypeSignature;
-
-// Base ICC tag definitions
-typedef enum {
- cmsSigAToB0Tag = 0x41324230, // 'A2B0'
- cmsSigAToB1Tag = 0x41324231, // 'A2B1'
- cmsSigAToB2Tag = 0x41324232, // 'A2B2'
- cmsSigBlueColorantTag = 0x6258595A, // 'bXYZ'
- cmsSigBlueMatrixColumnTag = 0x6258595A, // 'bXYZ'
- cmsSigBlueTRCTag = 0x62545243, // 'bTRC'
- cmsSigBToA0Tag = 0x42324130, // 'B2A0'
- cmsSigBToA1Tag = 0x42324131, // 'B2A1'
- cmsSigBToA2Tag = 0x42324132, // 'B2A2'
- cmsSigCalibrationDateTimeTag = 0x63616C74, // 'calt'
- cmsSigCharTargetTag = 0x74617267, // 'targ'
- cmsSigChromaticAdaptationTag = 0x63686164, // 'chad'
- cmsSigChromaticityTag = 0x6368726D, // 'chrm'
- cmsSigColorantOrderTag = 0x636C726F, // 'clro'
- cmsSigColorantTableTag = 0x636C7274, // 'clrt'
- cmsSigColorantTableOutTag = 0x636C6F74, // 'clot'
- cmsSigColorimetricIntentImageStateTag = 0x63696973, // 'ciis'
- cmsSigCopyrightTag = 0x63707274, // 'cprt'
- cmsSigCrdInfoTag = 0x63726469, // 'crdi'
- cmsSigDataTag = 0x64617461, // 'data'
- cmsSigDateTimeTag = 0x6474696D, // 'dtim'
- cmsSigDeviceMfgDescTag = 0x646D6E64, // 'dmnd'
- cmsSigDeviceModelDescTag = 0x646D6464, // 'dmdd'
- cmsSigDeviceSettingsTag = 0x64657673, // 'devs'
- cmsSigDToB0Tag = 0x44324230, // 'D2B0'
- cmsSigDToB1Tag = 0x44324231, // 'D2B1'
- cmsSigDToB2Tag = 0x44324232, // 'D2B2'
- cmsSigDToB3Tag = 0x44324233, // 'D2B3'
- cmsSigBToD0Tag = 0x42324430, // 'B2D0'
- cmsSigBToD1Tag = 0x42324431, // 'B2D1'
- cmsSigBToD2Tag = 0x42324432, // 'B2D2'
- cmsSigBToD3Tag = 0x42324433, // 'B2D3'
- cmsSigGamutTag = 0x67616D74, // 'gamt'
- cmsSigGrayTRCTag = 0x6b545243, // 'kTRC'
- cmsSigGreenColorantTag = 0x6758595A, // 'gXYZ'
- cmsSigGreenMatrixColumnTag = 0x6758595A, // 'gXYZ'
- cmsSigGreenTRCTag = 0x67545243, // 'gTRC'
- cmsSigLuminanceTag = 0x6C756d69, // 'lumi'
- cmsSigMeasurementTag = 0x6D656173, // 'meas'
- cmsSigMediaBlackPointTag = 0x626B7074, // 'bkpt'
- cmsSigMediaWhitePointTag = 0x77747074, // 'wtpt'
- cmsSigNamedColorTag = 0x6E636f6C, // 'ncol' // Deprecated by the ICC
- cmsSigNamedColor2Tag = 0x6E636C32, // 'ncl2'
- cmsSigOutputResponseTag = 0x72657370, // 'resp'
- cmsSigPerceptualRenderingIntentGamutTag = 0x72696730, // 'rig0'
- cmsSigPreview0Tag = 0x70726530, // 'pre0'
- cmsSigPreview1Tag = 0x70726531, // 'pre1'
- cmsSigPreview2Tag = 0x70726532, // 'pre2'
- cmsSigProfileDescriptionTag = 0x64657363, // 'desc'
- cmsSigProfileDescriptionMLTag = 0x6473636d, // 'dscm'
- cmsSigProfileSequenceDescTag = 0x70736571, // 'pseq'
- cmsSigProfileSequenceIdTag = 0x70736964, // 'psid'
- cmsSigPs2CRD0Tag = 0x70736430, // 'psd0'
- cmsSigPs2CRD1Tag = 0x70736431, // 'psd1'
- cmsSigPs2CRD2Tag = 0x70736432, // 'psd2'
- cmsSigPs2CRD3Tag = 0x70736433, // 'psd3'
- cmsSigPs2CSATag = 0x70733273, // 'ps2s'
- cmsSigPs2RenderingIntentTag = 0x70733269, // 'ps2i'
- cmsSigRedColorantTag = 0x7258595A, // 'rXYZ'
- cmsSigRedMatrixColumnTag = 0x7258595A, // 'rXYZ'
- cmsSigRedTRCTag = 0x72545243, // 'rTRC'
- cmsSigSaturationRenderingIntentGamutTag = 0x72696732, // 'rig2'
- cmsSigScreeningDescTag = 0x73637264, // 'scrd'
- cmsSigScreeningTag = 0x7363726E, // 'scrn'
- cmsSigTechnologyTag = 0x74656368, // 'tech'
- cmsSigUcrBgTag = 0x62666420, // 'bfd '
- cmsSigViewingCondDescTag = 0x76756564, // 'vued'
- cmsSigViewingConditionsTag = 0x76696577, // 'view'
- cmsSigVcgtTag = 0x76636774, // 'vcgt'
- cmsSigMetaTag = 0x6D657461, // 'meta'
- cmsSigcicpTag = 0x63696370, // 'cicp'
- cmsSigArgyllArtsTag = 0x61727473, // 'arts'
- cmsSigMHC2Tag = 0x4D484332 // 'MHC2'
-
-} cmsTagSignature;
-
-
-// ICC Technology tag
-typedef enum {
- cmsSigDigitalCamera = 0x6463616D, // 'dcam'
- cmsSigFilmScanner = 0x6673636E, // 'fscn'
- cmsSigReflectiveScanner = 0x7273636E, // 'rscn'
- cmsSigInkJetPrinter = 0x696A6574, // 'ijet'
- cmsSigThermalWaxPrinter = 0x74776178, // 'twax'
- cmsSigElectrophotographicPrinter = 0x6570686F, // 'epho'
- cmsSigElectrostaticPrinter = 0x65737461, // 'esta'
- cmsSigDyeSublimationPrinter = 0x64737562, // 'dsub'
- cmsSigPhotographicPaperPrinter = 0x7270686F, // 'rpho'
- cmsSigFilmWriter = 0x6670726E, // 'fprn'
- cmsSigVideoMonitor = 0x7669646D, // 'vidm'
- cmsSigVideoCamera = 0x76696463, // 'vidc'
- cmsSigProjectionTelevision = 0x706A7476, // 'pjtv'
- cmsSigCRTDisplay = 0x43525420, // 'CRT '
- cmsSigPMDisplay = 0x504D4420, // 'PMD '
- cmsSigAMDisplay = 0x414D4420, // 'AMD '
- cmsSigPhotoCD = 0x4B504344, // 'KPCD'
- cmsSigPhotoImageSetter = 0x696D6773, // 'imgs'
- cmsSigGravure = 0x67726176, // 'grav'
- cmsSigOffsetLithography = 0x6F666673, // 'offs'
- cmsSigSilkscreen = 0x73696C6B, // 'silk'
- cmsSigFlexography = 0x666C6578, // 'flex'
- cmsSigMotionPictureFilmScanner = 0x6D706673, // 'mpfs'
- cmsSigMotionPictureFilmRecorder = 0x6D706672, // 'mpfr'
- cmsSigDigitalMotionPictureCamera = 0x646D7063, // 'dmpc'
- cmsSigDigitalCinemaProjector = 0x64636A70 // 'dcpj'
-
-} cmsTechnologySignature;
-
-
-// ICC Color spaces
-typedef enum {
- cmsSigXYZData = 0x58595A20, // 'XYZ '
- cmsSigLabData = 0x4C616220, // 'Lab '
- cmsSigLuvData = 0x4C757620, // 'Luv '
- cmsSigYCbCrData = 0x59436272, // 'YCbr'
- cmsSigYxyData = 0x59787920, // 'Yxy '
- cmsSigRgbData = 0x52474220, // 'RGB '
- cmsSigGrayData = 0x47524159, // 'GRAY'
- cmsSigHsvData = 0x48535620, // 'HSV '
- cmsSigHlsData = 0x484C5320, // 'HLS '
- cmsSigCmykData = 0x434D594B, // 'CMYK'
- cmsSigCmyData = 0x434D5920, // 'CMY '
- cmsSigMCH1Data = 0x4D434831, // 'MCH1'
- cmsSigMCH2Data = 0x4D434832, // 'MCH2'
- cmsSigMCH3Data = 0x4D434833, // 'MCH3'
- cmsSigMCH4Data = 0x4D434834, // 'MCH4'
- cmsSigMCH5Data = 0x4D434835, // 'MCH5'
- cmsSigMCH6Data = 0x4D434836, // 'MCH6'
- cmsSigMCH7Data = 0x4D434837, // 'MCH7'
- cmsSigMCH8Data = 0x4D434838, // 'MCH8'
- cmsSigMCH9Data = 0x4D434839, // 'MCH9'
- cmsSigMCHAData = 0x4D434841, // 'MCHA'
- cmsSigMCHBData = 0x4D434842, // 'MCHB'
- cmsSigMCHCData = 0x4D434843, // 'MCHC'
- cmsSigMCHDData = 0x4D434844, // 'MCHD'
- cmsSigMCHEData = 0x4D434845, // 'MCHE'
- cmsSigMCHFData = 0x4D434846, // 'MCHF'
- cmsSigNamedData = 0x6e6d636c, // 'nmcl'
- cmsSig1colorData = 0x31434C52, // '1CLR'
- cmsSig2colorData = 0x32434C52, // '2CLR'
- cmsSig3colorData = 0x33434C52, // '3CLR'
- cmsSig4colorData = 0x34434C52, // '4CLR'
- cmsSig5colorData = 0x35434C52, // '5CLR'
- cmsSig6colorData = 0x36434C52, // '6CLR'
- cmsSig7colorData = 0x37434C52, // '7CLR'
- cmsSig8colorData = 0x38434C52, // '8CLR'
- cmsSig9colorData = 0x39434C52, // '9CLR'
- cmsSig10colorData = 0x41434C52, // 'ACLR'
- cmsSig11colorData = 0x42434C52, // 'BCLR'
- cmsSig12colorData = 0x43434C52, // 'CCLR'
- cmsSig13colorData = 0x44434C52, // 'DCLR'
- cmsSig14colorData = 0x45434C52, // 'ECLR'
- cmsSig15colorData = 0x46434C52, // 'FCLR'
- cmsSigLuvKData = 0x4C75764B // 'LuvK'
-
-} cmsColorSpaceSignature;
-
-// ICC Profile Class
-typedef enum {
- cmsSigInputClass = 0x73636E72, // 'scnr'
- cmsSigDisplayClass = 0x6D6E7472, // 'mntr'
- cmsSigOutputClass = 0x70727472, // 'prtr'
- cmsSigLinkClass = 0x6C696E6B, // 'link'
- cmsSigAbstractClass = 0x61627374, // 'abst'
- cmsSigColorSpaceClass = 0x73706163, // 'spac'
- cmsSigNamedColorClass = 0x6e6d636c // 'nmcl'
-
-} cmsProfileClassSignature;
-
-// ICC Platforms
-typedef enum {
- cmsSigMacintosh = 0x4150504C, // 'APPL'
- cmsSigMicrosoft = 0x4D534654, // 'MSFT'
- cmsSigSolaris = 0x53554E57, // 'SUNW'
- cmsSigSGI = 0x53474920, // 'SGI '
- cmsSigTaligent = 0x54474E54, // 'TGNT'
- cmsSigUnices = 0x2A6E6978 // '*nix' // From argyll -- Not official
-
-} cmsPlatformSignature;
-
-// Reference gamut
-#define cmsSigPerceptualReferenceMediumGamut 0x70726d67 //'prmg'
-
-// For cmsSigColorimetricIntentImageStateTag
-#define cmsSigSceneColorimetryEstimates 0x73636F65 //'scoe'
-#define cmsSigSceneAppearanceEstimates 0x73617065 //'sape'
-#define cmsSigFocalPlaneColorimetryEstimates 0x66706365 //'fpce'
-#define cmsSigReflectionHardcopyOriginalColorimetry 0x72686F63 //'rhoc'
-#define cmsSigReflectionPrintOutputColorimetry 0x72706F63 //'rpoc'
-
-// Multi process elements types
-typedef enum {
- cmsSigCurveSetElemType = 0x63767374, //'cvst'
- cmsSigMatrixElemType = 0x6D617466, //'matf'
- cmsSigCLutElemType = 0x636C7574, //'clut'
-
- cmsSigBAcsElemType = 0x62414353, // 'bACS'
- cmsSigEAcsElemType = 0x65414353, // 'eACS'
-
- // Custom from here, not in the ICC Spec
- cmsSigXYZ2LabElemType = 0x6C327820, // 'l2x '
- cmsSigLab2XYZElemType = 0x78326C20, // 'x2l '
- cmsSigNamedColorElemType = 0x6E636C20, // 'ncl '
- cmsSigLabV2toV4 = 0x32203420, // '2 4 '
- cmsSigLabV4toV2 = 0x34203220, // '4 2 '
-
- // Identities
- cmsSigIdentityElemType = 0x69646E20, // 'idn '
-
- // Float to floatPCS
- cmsSigLab2FloatPCS = 0x64326C20, // 'd2l '
- cmsSigFloatPCS2Lab = 0x6C326420, // 'l2d '
- cmsSigXYZ2FloatPCS = 0x64327820, // 'd2x '
- cmsSigFloatPCS2XYZ = 0x78326420, // 'x2d '
- cmsSigClipNegativesElemType = 0x636c7020 // 'clp '
-
-} cmsStageSignature;
-
-// Types of CurveElements
-typedef enum {
-
- cmsSigFormulaCurveSeg = 0x70617266, // 'parf'
- cmsSigSampledCurveSeg = 0x73616D66, // 'samf'
- cmsSigSegmentedCurve = 0x63757266 // 'curf'
-
-} cmsCurveSegSignature;
-
-// Used in ResponseCurveType
-#define cmsSigStatusA 0x53746141 //'StaA'
-#define cmsSigStatusE 0x53746145 //'StaE'
-#define cmsSigStatusI 0x53746149 //'StaI'
-#define cmsSigStatusT 0x53746154 //'StaT'
-#define cmsSigStatusM 0x5374614D //'StaM'
-#define cmsSigDN 0x444E2020 //'DN '
-#define cmsSigDNP 0x444E2050 //'DN P'
-#define cmsSigDNN 0x444E4E20 //'DNN '
-#define cmsSigDNNP 0x444E4E50 //'DNNP'
-
-// Device attributes, currently defined values correspond to the low 4 bytes
-// of the 8 byte attribute quantity
-#define cmsReflective 0
-#define cmsTransparency 1
-#define cmsGlossy 0
-#define cmsMatte 2
-
-// Common structures in ICC tags
-typedef struct {
- cmsUInt32Number len;
- cmsUInt32Number flag;
- cmsUInt8Number data[1];
-
-} cmsICCData;
-
-// ICC date time
-typedef struct {
- cmsUInt16Number year;
- cmsUInt16Number month;
- cmsUInt16Number day;
- cmsUInt16Number hours;
- cmsUInt16Number minutes;
- cmsUInt16Number seconds;
-
-} cmsDateTimeNumber;
-
-// ICC XYZ
-typedef struct {
- cmsS15Fixed16Number X;
- cmsS15Fixed16Number Y;
- cmsS15Fixed16Number Z;
-
-} cmsEncodedXYZNumber;
-
-
-// Profile ID as computed by MD5 algorithm
-typedef union {
- cmsUInt8Number ID8[16];
- cmsUInt16Number ID16[8];
- cmsUInt32Number ID32[4];
-
-} cmsProfileID;
-
-
-// ----------------------------------------------------------------------------------------------
-// ICC profile internal base types. Strictly, shouldn't be declared in this header, but maybe
-// somebody want to use this info for accessing profile header directly, so here it is.
-
-// Profile header -- it is 32-bit aligned, so no issues are expected on alignment
-typedef struct {
- cmsUInt32Number size; // Profile size in bytes
- cmsSignature cmmId; // CMM for this profile
- cmsUInt32Number version; // Format version number
- cmsProfileClassSignature deviceClass; // Type of profile
- cmsColorSpaceSignature colorSpace; // Color space of data
- cmsColorSpaceSignature pcs; // PCS, XYZ or Lab only
- cmsDateTimeNumber date; // Date profile was created
- cmsSignature magic; // Magic Number to identify an ICC profile
- cmsPlatformSignature platform; // Primary Platform
- cmsUInt32Number flags; // Various bit settings
- cmsSignature manufacturer; // Device manufacturer
- cmsUInt32Number model; // Device model number
- cmsUInt64Number attributes; // Device attributes
- cmsUInt32Number renderingIntent;// Rendering intent
- cmsEncodedXYZNumber illuminant; // Profile illuminant
- cmsSignature creator; // Profile creator
- cmsProfileID profileID; // Profile ID using MD5
- cmsInt8Number reserved[28]; // Reserved for future use
-
-} cmsICCHeader;
-
-// ICC base tag
-typedef struct {
- cmsTagTypeSignature sig;
- cmsInt8Number reserved[4];
-
-} cmsTagBase;
-
-// A tag entry in directory
-typedef struct {
- cmsTagSignature sig; // The tag signature
- cmsUInt32Number offset; // Start of tag
- cmsUInt32Number size; // Size in bytes
-
-} cmsTagEntry;
-
-// ----------------------------------------------------------------------------------------------
-
-// Little CMS specific typedefs
-
-typedef void* cmsHANDLE ; // Generic handle
-typedef void* cmsHPROFILE; // Opaque typedefs to hide internals
-typedef void* cmsHTRANSFORM;
-
-#define cmsMAXCHANNELS 16 // Maximum number of channels in ICC profiles
-
-// Format of pixel is defined by one cmsUInt32Number, using bit fields as follows
-//
-// 2 1 0
-// 4 3 2 10987 6 5 4 3 2 1 098 7654 321
-// M A O TTTTT U Y F P X S EEE CCCC BBB
-//
-// M: Premultiplied alpha (only works when extra samples is 1)
-// A: Floating point -- With this flag we can differentiate 16 bits as float and as int
-// O: Optimized -- previous optimization already returns the final 8-bit value
-// T: Pixeltype
-// F: Flavor 0=MinIsBlack(Chocolate) 1=MinIsWhite(Vanilla)
-// P: Planar? 0=Chunky, 1=Planar
-// X: swap 16 bps endianness?
-// S: Do swap? ie, BGR, KYMC
-// E: Extra samples
-// C: Channels (Samples per pixel)
-// B: bytes per sample
-// Y: Swap first - changes ABGR to BGRA and KCMY to CMYK
-
-#define PREMUL_SH(m) ((m) << 23)
-#define FLOAT_SH(a) ((a) << 22)
-#define OPTIMIZED_SH(s) ((s) << 21)
-#define COLORSPACE_SH(s) ((s) << 16)
-#define SWAPFIRST_SH(s) ((s) << 14)
-#define FLAVOR_SH(s) ((s) << 13)
-#define PLANAR_SH(p) ((p) << 12)
-#define ENDIAN16_SH(e) ((e) << 11)
-#define DOSWAP_SH(e) ((e) << 10)
-#define EXTRA_SH(e) ((e) << 7)
-#define CHANNELS_SH(c) ((c) << 3)
-#define BYTES_SH(b) (b)
-
-// These macros unpack format specifiers into integers
-#define T_PREMUL(m) (((m)>>23)&1)
-#define T_FLOAT(a) (((a)>>22)&1)
-#define T_OPTIMIZED(o) (((o)>>21)&1)
-#define T_COLORSPACE(s) (((s)>>16)&31)
-#define T_SWAPFIRST(s) (((s)>>14)&1)
-#define T_FLAVOR(s) (((s)>>13)&1)
-#define T_PLANAR(p) (((p)>>12)&1)
-#define T_ENDIAN16(e) (((e)>>11)&1)
-#define T_DOSWAP(e) (((e)>>10)&1)
-#define T_EXTRA(e) (((e)>>7)&7)
-#define T_CHANNELS(c) (((c)>>3)&15)
-#define T_BYTES(b) ((b)&7)
-
-
-// Pixel types
-#define PT_ANY 0 // Don't check colorspace
- // 1 & 2 are reserved
-#define PT_GRAY 3
-#define PT_RGB 4
-#define PT_CMY 5
-#define PT_CMYK 6
-#define PT_YCbCr 7
-#define PT_YUV 8 // Lu'v'
-#define PT_XYZ 9
-#define PT_Lab 10
-#define PT_YUVK 11 // Lu'v'K
-#define PT_HSV 12
-#define PT_HLS 13
-#define PT_Yxy 14
-#define PT_MCH1 15
-#define PT_MCH2 16
-#define PT_MCH3 17
-#define PT_MCH4 18
-#define PT_MCH5 19
-#define PT_MCH6 20
-#define PT_MCH7 21
-#define PT_MCH8 22
-#define PT_MCH9 23
-#define PT_MCH10 24
-#define PT_MCH11 25
-#define PT_MCH12 26
-#define PT_MCH13 27
-#define PT_MCH14 28
-#define PT_MCH15 29
-#define PT_LabV2 30 // Identical to PT_Lab, but using the V2 old encoding
-
-// Some (not all!) representations
-
-#ifndef TYPE_RGB_8 // TYPE_RGB_8 is a very common identifier, so don't include ours
- // if user has it already defined.
-
-#define TYPE_GRAY_8 (COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(1))
-#define TYPE_GRAY_8_REV (COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(1)|FLAVOR_SH(1))
-#define TYPE_GRAY_16 (COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(2))
-#define TYPE_GRAY_16_REV (COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(2)|FLAVOR_SH(1))
-#define TYPE_GRAY_16_SE (COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(2)|ENDIAN16_SH(1))
-#define TYPE_GRAYA_8 (COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(1)|BYTES_SH(1))
-#define TYPE_GRAYA_8_PREMUL (COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(1)|BYTES_SH(1)|PREMUL_SH(1))
-#define TYPE_GRAYA_16 (COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(1)|BYTES_SH(2))
-#define TYPE_GRAYA_16_PREMUL (COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(1)|BYTES_SH(2)|PREMUL_SH(1))
-#define TYPE_GRAYA_16_SE (COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(1)|BYTES_SH(2)|ENDIAN16_SH(1))
-#define TYPE_GRAYA_8_PLANAR (COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(1)|BYTES_SH(1)|PLANAR_SH(1))
-#define TYPE_GRAYA_16_PLANAR (COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(1)|BYTES_SH(2)|PLANAR_SH(1))
-
-#define TYPE_RGB_8 (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(1))
-#define TYPE_RGB_8_PLANAR (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(1)|PLANAR_SH(1))
-#define TYPE_BGR_8 (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(1)|DOSWAP_SH(1))
-#define TYPE_BGR_8_PLANAR (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(1)|DOSWAP_SH(1)|PLANAR_SH(1))
-#define TYPE_RGB_16 (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(2))
-#define TYPE_RGB_16_PLANAR (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(2)|PLANAR_SH(1))
-#define TYPE_RGB_16_SE (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(2)|ENDIAN16_SH(1))
-#define TYPE_BGR_16 (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1))
-#define TYPE_BGR_16_PLANAR (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1)|PLANAR_SH(1))
-#define TYPE_BGR_16_SE (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1)|ENDIAN16_SH(1))
-
-#define TYPE_RGBA_8 (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1))
-#define TYPE_RGBA_8_PREMUL (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1)|PREMUL_SH(1))
-#define TYPE_RGBA_8_PLANAR (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1)|PLANAR_SH(1))
-#define TYPE_RGBA_16 (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2))
-#define TYPE_RGBA_16_PREMUL (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|PREMUL_SH(1))
-#define TYPE_RGBA_16_PLANAR (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|PLANAR_SH(1))
-#define TYPE_RGBA_16_SE (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|ENDIAN16_SH(1))
-
-#define TYPE_ARGB_8 (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1)|SWAPFIRST_SH(1))
-#define TYPE_ARGB_8_PREMUL (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1)|SWAPFIRST_SH(1)|PREMUL_SH(1))
-#define TYPE_ARGB_8_PLANAR (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1)|SWAPFIRST_SH(1)|PLANAR_SH(1))
-#define TYPE_ARGB_16 (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|SWAPFIRST_SH(1))
-#define TYPE_ARGB_16_PREMUL (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|SWAPFIRST_SH(1)|PREMUL_SH(1))
-
-#define TYPE_ABGR_8 (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1)|DOSWAP_SH(1))
-#define TYPE_ABGR_8_PREMUL (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1)|DOSWAP_SH(1)|PREMUL_SH(1))
-#define TYPE_ABGR_8_PLANAR (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1)|DOSWAP_SH(1)|PLANAR_SH(1))
-#define TYPE_ABGR_16 (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1))
-#define TYPE_ABGR_16_PREMUL (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1)|PREMUL_SH(1))
-#define TYPE_ABGR_16_PLANAR (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1)|PLANAR_SH(1))
-#define TYPE_ABGR_16_SE (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1)|ENDIAN16_SH(1))
-
-#define TYPE_BGRA_8 (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1)|DOSWAP_SH(1)|SWAPFIRST_SH(1))
-#define TYPE_BGRA_8_PREMUL (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1)|DOSWAP_SH(1)|SWAPFIRST_SH(1)|PREMUL_SH(1))
-#define TYPE_BGRA_8_PLANAR (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1)|DOSWAP_SH(1)|SWAPFIRST_SH(1)|PLANAR_SH(1))
-#define TYPE_BGRA_16 (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1)|SWAPFIRST_SH(1))
-#define TYPE_BGRA_16_PREMUL (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1)|SWAPFIRST_SH(1)|PREMUL_SH(1))
-#define TYPE_BGRA_16_SE (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|ENDIAN16_SH(1)|DOSWAP_SH(1)|SWAPFIRST_SH(1))
-
-#define TYPE_CMY_8 (COLORSPACE_SH(PT_CMY)|CHANNELS_SH(3)|BYTES_SH(1))
-#define TYPE_CMY_8_PLANAR (COLORSPACE_SH(PT_CMY)|CHANNELS_SH(3)|BYTES_SH(1)|PLANAR_SH(1))
-#define TYPE_CMY_16 (COLORSPACE_SH(PT_CMY)|CHANNELS_SH(3)|BYTES_SH(2))
-#define TYPE_CMY_16_PLANAR (COLORSPACE_SH(PT_CMY)|CHANNELS_SH(3)|BYTES_SH(2)|PLANAR_SH(1))
-#define TYPE_CMY_16_SE (COLORSPACE_SH(PT_CMY)|CHANNELS_SH(3)|BYTES_SH(2)|ENDIAN16_SH(1))
-
-#define TYPE_CMYK_8 (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(1))
-#define TYPE_CMYKA_8 (COLORSPACE_SH(PT_CMYK)|EXTRA_SH(1)|CHANNELS_SH(4)|BYTES_SH(1))
-#define TYPE_CMYK_8_REV (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(1)|FLAVOR_SH(1))
-#define TYPE_YUVK_8 TYPE_CMYK_8_REV
-#define TYPE_CMYK_8_PLANAR (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(1)|PLANAR_SH(1))
-#define TYPE_CMYK_16 (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(2))
-#define TYPE_CMYK_16_REV (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(2)|FLAVOR_SH(1))
-#define TYPE_YUVK_16 TYPE_CMYK_16_REV
-#define TYPE_CMYK_16_PLANAR (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(2)|PLANAR_SH(1))
-#define TYPE_CMYK_16_SE (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(2)|ENDIAN16_SH(1))
-
-#define TYPE_KYMC_8 (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(1)|DOSWAP_SH(1))
-#define TYPE_KYMC_16 (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(2)|DOSWAP_SH(1))
-#define TYPE_KYMC_16_SE (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(2)|DOSWAP_SH(1)|ENDIAN16_SH(1))
-
-#define TYPE_KCMY_8 (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(1)|SWAPFIRST_SH(1))
-#define TYPE_KCMY_8_REV (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(1)|FLAVOR_SH(1)|SWAPFIRST_SH(1))
-#define TYPE_KCMY_16 (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(2)|SWAPFIRST_SH(1))
-#define TYPE_KCMY_16_REV (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(2)|FLAVOR_SH(1)|SWAPFIRST_SH(1))
-#define TYPE_KCMY_16_SE (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(2)|ENDIAN16_SH(1)|SWAPFIRST_SH(1))
-
-#define TYPE_CMYK5_8 (COLORSPACE_SH(PT_MCH5)|CHANNELS_SH(5)|BYTES_SH(1))
-#define TYPE_CMYK5_16 (COLORSPACE_SH(PT_MCH5)|CHANNELS_SH(5)|BYTES_SH(2))
-#define TYPE_CMYK5_16_SE (COLORSPACE_SH(PT_MCH5)|CHANNELS_SH(5)|BYTES_SH(2)|ENDIAN16_SH(1))
-#define TYPE_KYMC5_8 (COLORSPACE_SH(PT_MCH5)|CHANNELS_SH(5)|BYTES_SH(1)|DOSWAP_SH(1))
-#define TYPE_KYMC5_16 (COLORSPACE_SH(PT_MCH5)|CHANNELS_SH(5)|BYTES_SH(2)|DOSWAP_SH(1))
-#define TYPE_KYMC5_16_SE (COLORSPACE_SH(PT_MCH5)|CHANNELS_SH(5)|BYTES_SH(2)|DOSWAP_SH(1)|ENDIAN16_SH(1))
-#define TYPE_CMYK6_8 (COLORSPACE_SH(PT_MCH6)|CHANNELS_SH(6)|BYTES_SH(1))
-#define TYPE_CMYK6_8_PLANAR (COLORSPACE_SH(PT_MCH6)|CHANNELS_SH(6)|BYTES_SH(1)|PLANAR_SH(1))
-#define TYPE_CMYK6_16 (COLORSPACE_SH(PT_MCH6)|CHANNELS_SH(6)|BYTES_SH(2))
-#define TYPE_CMYK6_16_PLANAR (COLORSPACE_SH(PT_MCH6)|CHANNELS_SH(6)|BYTES_SH(2)|PLANAR_SH(1))
-#define TYPE_CMYK6_16_SE (COLORSPACE_SH(PT_MCH6)|CHANNELS_SH(6)|BYTES_SH(2)|ENDIAN16_SH(1))
-#define TYPE_CMYK7_8 (COLORSPACE_SH(PT_MCH7)|CHANNELS_SH(7)|BYTES_SH(1))
-#define TYPE_CMYK7_16 (COLORSPACE_SH(PT_MCH7)|CHANNELS_SH(7)|BYTES_SH(2))
-#define TYPE_CMYK7_16_SE (COLORSPACE_SH(PT_MCH7)|CHANNELS_SH(7)|BYTES_SH(2)|ENDIAN16_SH(1))
-#define TYPE_KYMC7_8 (COLORSPACE_SH(PT_MCH7)|CHANNELS_SH(7)|BYTES_SH(1)|DOSWAP_SH(1))
-#define TYPE_KYMC7_16 (COLORSPACE_SH(PT_MCH7)|CHANNELS_SH(7)|BYTES_SH(2)|DOSWAP_SH(1))
-#define TYPE_KYMC7_16_SE (COLORSPACE_SH(PT_MCH7)|CHANNELS_SH(7)|BYTES_SH(2)|DOSWAP_SH(1)|ENDIAN16_SH(1))
-#define TYPE_CMYK8_8 (COLORSPACE_SH(PT_MCH8)|CHANNELS_SH(8)|BYTES_SH(1))
-#define TYPE_CMYK8_16 (COLORSPACE_SH(PT_MCH8)|CHANNELS_SH(8)|BYTES_SH(2))
-#define TYPE_CMYK8_16_SE (COLORSPACE_SH(PT_MCH8)|CHANNELS_SH(8)|BYTES_SH(2)|ENDIAN16_SH(1))
-#define TYPE_KYMC8_8 (COLORSPACE_SH(PT_MCH8)|CHANNELS_SH(8)|BYTES_SH(1)|DOSWAP_SH(1))
-#define TYPE_KYMC8_16 (COLORSPACE_SH(PT_MCH8)|CHANNELS_SH(8)|BYTES_SH(2)|DOSWAP_SH(1))
-#define TYPE_KYMC8_16_SE (COLORSPACE_SH(PT_MCH8)|CHANNELS_SH(8)|BYTES_SH(2)|DOSWAP_SH(1)|ENDIAN16_SH(1))
-#define TYPE_CMYK9_8 (COLORSPACE_SH(PT_MCH9)|CHANNELS_SH(9)|BYTES_SH(1))
-#define TYPE_CMYK9_16 (COLORSPACE_SH(PT_MCH9)|CHANNELS_SH(9)|BYTES_SH(2))
-#define TYPE_CMYK9_16_SE (COLORSPACE_SH(PT_MCH9)|CHANNELS_SH(9)|BYTES_SH(2)|ENDIAN16_SH(1))
-#define TYPE_KYMC9_8 (COLORSPACE_SH(PT_MCH9)|CHANNELS_SH(9)|BYTES_SH(1)|DOSWAP_SH(1))
-#define TYPE_KYMC9_16 (COLORSPACE_SH(PT_MCH9)|CHANNELS_SH(9)|BYTES_SH(2)|DOSWAP_SH(1))
-#define TYPE_KYMC9_16_SE (COLORSPACE_SH(PT_MCH9)|CHANNELS_SH(9)|BYTES_SH(2)|DOSWAP_SH(1)|ENDIAN16_SH(1))
-#define TYPE_CMYK10_8 (COLORSPACE_SH(PT_MCH10)|CHANNELS_SH(10)|BYTES_SH(1))
-#define TYPE_CMYK10_16 (COLORSPACE_SH(PT_MCH10)|CHANNELS_SH(10)|BYTES_SH(2))
-#define TYPE_CMYK10_16_SE (COLORSPACE_SH(PT_MCH10)|CHANNELS_SH(10)|BYTES_SH(2)|ENDIAN16_SH(1))
-#define TYPE_KYMC10_8 (COLORSPACE_SH(PT_MCH10)|CHANNELS_SH(10)|BYTES_SH(1)|DOSWAP_SH(1))
-#define TYPE_KYMC10_16 (COLORSPACE_SH(PT_MCH10)|CHANNELS_SH(10)|BYTES_SH(2)|DOSWAP_SH(1))
-#define TYPE_KYMC10_16_SE (COLORSPACE_SH(PT_MCH10)|CHANNELS_SH(10)|BYTES_SH(2)|DOSWAP_SH(1)|ENDIAN16_SH(1))
-#define TYPE_CMYK11_8 (COLORSPACE_SH(PT_MCH11)|CHANNELS_SH(11)|BYTES_SH(1))
-#define TYPE_CMYK11_16 (COLORSPACE_SH(PT_MCH11)|CHANNELS_SH(11)|BYTES_SH(2))
-#define TYPE_CMYK11_16_SE (COLORSPACE_SH(PT_MCH11)|CHANNELS_SH(11)|BYTES_SH(2)|ENDIAN16_SH(1))
-#define TYPE_KYMC11_8 (COLORSPACE_SH(PT_MCH11)|CHANNELS_SH(11)|BYTES_SH(1)|DOSWAP_SH(1))
-#define TYPE_KYMC11_16 (COLORSPACE_SH(PT_MCH11)|CHANNELS_SH(11)|BYTES_SH(2)|DOSWAP_SH(1))
-#define TYPE_KYMC11_16_SE (COLORSPACE_SH(PT_MCH11)|CHANNELS_SH(11)|BYTES_SH(2)|DOSWAP_SH(1)|ENDIAN16_SH(1))
-#define TYPE_CMYK12_8 (COLORSPACE_SH(PT_MCH12)|CHANNELS_SH(12)|BYTES_SH(1))
-#define TYPE_CMYK12_16 (COLORSPACE_SH(PT_MCH12)|CHANNELS_SH(12)|BYTES_SH(2))
-#define TYPE_CMYK12_16_SE (COLORSPACE_SH(PT_MCH12)|CHANNELS_SH(12)|BYTES_SH(2)|ENDIAN16_SH(1))
-#define TYPE_KYMC12_8 (COLORSPACE_SH(PT_MCH12)|CHANNELS_SH(12)|BYTES_SH(1)|DOSWAP_SH(1))
-#define TYPE_KYMC12_16 (COLORSPACE_SH(PT_MCH12)|CHANNELS_SH(12)|BYTES_SH(2)|DOSWAP_SH(1))
-#define TYPE_KYMC12_16_SE (COLORSPACE_SH(PT_MCH12)|CHANNELS_SH(12)|BYTES_SH(2)|DOSWAP_SH(1)|ENDIAN16_SH(1))
-
-// Colorimetric
-#define TYPE_XYZ_16 (COLORSPACE_SH(PT_XYZ)|CHANNELS_SH(3)|BYTES_SH(2))
-#define TYPE_Lab_8 (COLORSPACE_SH(PT_Lab)|CHANNELS_SH(3)|BYTES_SH(1))
-#define TYPE_LabV2_8 (COLORSPACE_SH(PT_LabV2)|CHANNELS_SH(3)|BYTES_SH(1))
-
-#define TYPE_ALab_8 (COLORSPACE_SH(PT_Lab)|CHANNELS_SH(3)|BYTES_SH(1)|EXTRA_SH(1)|SWAPFIRST_SH(1))
-#define TYPE_ALabV2_8 (COLORSPACE_SH(PT_LabV2)|CHANNELS_SH(3)|BYTES_SH(1)|EXTRA_SH(1)|SWAPFIRST_SH(1))
-#define TYPE_Lab_16 (COLORSPACE_SH(PT_Lab)|CHANNELS_SH(3)|BYTES_SH(2))
-#define TYPE_LabV2_16 (COLORSPACE_SH(PT_LabV2)|CHANNELS_SH(3)|BYTES_SH(2))
-#define TYPE_Yxy_16 (COLORSPACE_SH(PT_Yxy)|CHANNELS_SH(3)|BYTES_SH(2))
-
-// YCbCr
-#define TYPE_YCbCr_8 (COLORSPACE_SH(PT_YCbCr)|CHANNELS_SH(3)|BYTES_SH(1))
-#define TYPE_YCbCr_8_PLANAR (COLORSPACE_SH(PT_YCbCr)|CHANNELS_SH(3)|BYTES_SH(1)|PLANAR_SH(1))
-#define TYPE_YCbCr_16 (COLORSPACE_SH(PT_YCbCr)|CHANNELS_SH(3)|BYTES_SH(2))
-#define TYPE_YCbCr_16_PLANAR (COLORSPACE_SH(PT_YCbCr)|CHANNELS_SH(3)|BYTES_SH(2)|PLANAR_SH(1))
-#define TYPE_YCbCr_16_SE (COLORSPACE_SH(PT_YCbCr)|CHANNELS_SH(3)|BYTES_SH(2)|ENDIAN16_SH(1))
-
-// YUV
-#define TYPE_YUV_8 (COLORSPACE_SH(PT_YUV)|CHANNELS_SH(3)|BYTES_SH(1))
-#define TYPE_YUV_8_PLANAR (COLORSPACE_SH(PT_YUV)|CHANNELS_SH(3)|BYTES_SH(1)|PLANAR_SH(1))
-#define TYPE_YUV_16 (COLORSPACE_SH(PT_YUV)|CHANNELS_SH(3)|BYTES_SH(2))
-#define TYPE_YUV_16_PLANAR (COLORSPACE_SH(PT_YUV)|CHANNELS_SH(3)|BYTES_SH(2)|PLANAR_SH(1))
-#define TYPE_YUV_16_SE (COLORSPACE_SH(PT_YUV)|CHANNELS_SH(3)|BYTES_SH(2)|ENDIAN16_SH(1))
-
-// HLS
-#define TYPE_HLS_8 (COLORSPACE_SH(PT_HLS)|CHANNELS_SH(3)|BYTES_SH(1))
-#define TYPE_HLS_8_PLANAR (COLORSPACE_SH(PT_HLS)|CHANNELS_SH(3)|BYTES_SH(1)|PLANAR_SH(1))
-#define TYPE_HLS_16 (COLORSPACE_SH(PT_HLS)|CHANNELS_SH(3)|BYTES_SH(2))
-#define TYPE_HLS_16_PLANAR (COLORSPACE_SH(PT_HLS)|CHANNELS_SH(3)|BYTES_SH(2)|PLANAR_SH(1))
-#define TYPE_HLS_16_SE (COLORSPACE_SH(PT_HLS)|CHANNELS_SH(3)|BYTES_SH(2)|ENDIAN16_SH(1))
-
-// HSV
-#define TYPE_HSV_8 (COLORSPACE_SH(PT_HSV)|CHANNELS_SH(3)|BYTES_SH(1))
-#define TYPE_HSV_8_PLANAR (COLORSPACE_SH(PT_HSV)|CHANNELS_SH(3)|BYTES_SH(1)|PLANAR_SH(1))
-#define TYPE_HSV_16 (COLORSPACE_SH(PT_HSV)|CHANNELS_SH(3)|BYTES_SH(2))
-#define TYPE_HSV_16_PLANAR (COLORSPACE_SH(PT_HSV)|CHANNELS_SH(3)|BYTES_SH(2)|PLANAR_SH(1))
-#define TYPE_HSV_16_SE (COLORSPACE_SH(PT_HSV)|CHANNELS_SH(3)|BYTES_SH(2)|ENDIAN16_SH(1))
-
-// Named color index. Only 16 bits is allowed (don't check colorspace)
-#define TYPE_NAMED_COLOR_INDEX (CHANNELS_SH(1)|BYTES_SH(2))
-
-// Float formatters.
-#define TYPE_XYZ_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_XYZ)|CHANNELS_SH(3)|BYTES_SH(4))
-#define TYPE_Lab_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_Lab)|CHANNELS_SH(3)|BYTES_SH(4))
-#define TYPE_LabA_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_Lab)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(4))
-#define TYPE_GRAY_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(4))
-#define TYPE_GRAYA_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(4)|EXTRA_SH(1))
-#define TYPE_GRAYA_FLT_PREMUL (FLOAT_SH(1)|COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(4)|EXTRA_SH(1)|PREMUL_SH(1))
-#define TYPE_RGB_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(4))
-
-#define TYPE_RGBA_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(4))
-#define TYPE_RGBA_FLT_PREMUL (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(4)|PREMUL_SH(1))
-#define TYPE_ARGB_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(4)|SWAPFIRST_SH(1))
-#define TYPE_ARGB_FLT_PREMUL (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(4)|SWAPFIRST_SH(1)|PREMUL_SH(1))
-#define TYPE_BGR_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(4)|DOSWAP_SH(1))
-#define TYPE_BGRA_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(4)|DOSWAP_SH(1)|SWAPFIRST_SH(1))
-#define TYPE_BGRA_FLT_PREMUL (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(4)|DOSWAP_SH(1)|SWAPFIRST_SH(1)|PREMUL_SH(1))
-#define TYPE_ABGR_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(4)|DOSWAP_SH(1))
-#define TYPE_ABGR_FLT_PREMUL (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(4)|DOSWAP_SH(1)|PREMUL_SH(1))
-
-#define TYPE_CMYK_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(4))
-
-// Floating point formatters.
-// NOTE THAT 'BYTES' FIELD IS SET TO ZERO ON DLB because 8 bytes overflows the bitfield
-#define TYPE_XYZ_DBL (FLOAT_SH(1)|COLORSPACE_SH(PT_XYZ)|CHANNELS_SH(3)|BYTES_SH(0))
-#define TYPE_Lab_DBL (FLOAT_SH(1)|COLORSPACE_SH(PT_Lab)|CHANNELS_SH(3)|BYTES_SH(0))
-#define TYPE_GRAY_DBL (FLOAT_SH(1)|COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(0))
-#define TYPE_RGB_DBL (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(0))
-#define TYPE_BGR_DBL (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(0)|DOSWAP_SH(1))
-#define TYPE_CMYK_DBL (FLOAT_SH(1)|COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(0))
-#define TYPE_OKLAB_DBL (FLOAT_SH(1)|COLORSPACE_SH(PT_MCH3)|CHANNELS_SH(3)|BYTES_SH(0))
-
-// IEEE 754-2008 "half"
-#define TYPE_GRAY_HALF_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(2))
-#define TYPE_RGB_HALF_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(2))
-#define TYPE_RGBA_HALF_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2))
-#define TYPE_CMYK_HALF_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(2))
-
-#define TYPE_RGBA_HALF_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2))
-#define TYPE_ARGB_HALF_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|SWAPFIRST_SH(1))
-#define TYPE_BGR_HALF_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1))
-#define TYPE_BGRA_HALF_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1)|SWAPFIRST_SH(1))
-#define TYPE_ABGR_HALF_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1))
-
-#endif
-
-// Colorspaces
-typedef struct {
- cmsFloat64Number X;
- cmsFloat64Number Y;
- cmsFloat64Number Z;
-
- } cmsCIEXYZ;
-
-typedef struct {
- cmsFloat64Number x;
- cmsFloat64Number y;
- cmsFloat64Number Y;
-
- } cmsCIExyY;
-
-typedef struct {
- cmsFloat64Number L;
- cmsFloat64Number a;
- cmsFloat64Number b;
-
- } cmsCIELab;
-
-typedef struct {
- cmsFloat64Number L;
- cmsFloat64Number C;
- cmsFloat64Number h;
-
- } cmsCIELCh;
-
-typedef struct {
- cmsFloat64Number J;
- cmsFloat64Number C;
- cmsFloat64Number h;
-
- } cmsJCh;
-
-typedef struct {
- cmsCIEXYZ Red;
- cmsCIEXYZ Green;
- cmsCIEXYZ Blue;
-
- } cmsCIEXYZTRIPLE;
-
-typedef struct {
- cmsCIExyY Red;
- cmsCIExyY Green;
- cmsCIExyY Blue;
-
- } cmsCIExyYTRIPLE;
-
-// Illuminant types for structs below
-#define cmsILLUMINANT_TYPE_UNKNOWN 0x0000000
-#define cmsILLUMINANT_TYPE_D50 0x0000001
-#define cmsILLUMINANT_TYPE_D65 0x0000002
-#define cmsILLUMINANT_TYPE_D93 0x0000003
-#define cmsILLUMINANT_TYPE_F2 0x0000004
-#define cmsILLUMINANT_TYPE_D55 0x0000005
-#define cmsILLUMINANT_TYPE_A 0x0000006
-#define cmsILLUMINANT_TYPE_E 0x0000007
-#define cmsILLUMINANT_TYPE_F8 0x0000008
-
-typedef struct {
- cmsUInt32Number Observer; // 0 = unknown, 1=CIE 1931, 2=CIE 1964
- cmsCIEXYZ Backing; // Value of backing
- cmsUInt32Number Geometry; // 0=unknown, 1=45/0, 0/45 2=0d, d/0
- cmsFloat64Number Flare; // 0..1.0
- cmsUInt32Number IlluminantType;
-
- } cmsICCMeasurementConditions;
-
-typedef struct {
- cmsCIEXYZ IlluminantXYZ; // Not the same struct as CAM02,
- cmsCIEXYZ SurroundXYZ; // This is for storing the tag
- cmsUInt32Number IlluminantType; // viewing condition
-
- } cmsICCViewingConditions;
-
-typedef struct {
- cmsUInt8Number ColourPrimaries; // Recommendation ITU-T H.273
- cmsUInt8Number TransferCharacteristics; // (ISO/IEC 23091-2)
- cmsUInt8Number MatrixCoefficients;
- cmsUInt8Number VideoFullRangeFlag;
-
-} cmsVideoSignalType;
-
-typedef struct {
- cmsUInt32Number CurveEntries;
- cmsFloat64Number* RedCurve;
- cmsFloat64Number* GreenCurve;
- cmsFloat64Number* BlueCurve;
-
- cmsFloat64Number MinLuminance; // ST.2086 min luminance in nits
- cmsFloat64Number PeakLuminance; // ST.2086 peak luminance in nits
-
- cmsFloat64Number XYZ2XYZmatrix[3][4];
-
-} cmsMHC2Type;
-
-
-
-// Get LittleCMS version (for shared objects) -----------------------------------------------------------------------------
-
-CMSAPI int CMSEXPORT cmsGetEncodedCMMversion(void);
-
-// Support of non-standard functions --------------------------------------------------------------------------------------
-
-CMSAPI int CMSEXPORT cmsstrcasecmp(const char* s1, const char* s2);
-CMSAPI long int CMSEXPORT cmsfilelength(FILE* f);
-
-
-// Context handling --------------------------------------------------------------------------------------------------------
-
-// Each context holds its owns globals and its own plug-ins. There is a global context with the id = 0 for lecacy compatibility
-// though using the global context is not recommended. Proper context handling makes lcms more thread-safe.
-
-typedef struct _cmsContext_struct* cmsContext;
-
-CMSAPI cmsContext CMSEXPORT cmsCreateContext(void* Plugin, void* UserData);
-CMSAPI void CMSEXPORT cmsDeleteContext(cmsContext ContextID);
-CMSAPI cmsContext CMSEXPORT cmsDupContext(cmsContext ContextID, void* NewUserData);
-CMSAPI void* CMSEXPORT cmsGetContextUserData(cmsContext ContextID);
-
-// Plug-In registering --------------------------------------------------------------------------------------------------
-
-CMSAPI cmsBool CMSEXPORT cmsPlugin(void* Plugin);
-CMSAPI cmsBool CMSEXPORT cmsPluginTHR(cmsContext ContextID, void* Plugin);
-CMSAPI void CMSEXPORT cmsUnregisterPlugins(void);
-CMSAPI void CMSEXPORT cmsUnregisterPluginsTHR(cmsContext ContextID);
-
-// Error logging ----------------------------------------------------------------------------------------------------------
-
-// There is no error handling at all. When a function fails, it returns proper value.
-// For example, all create functions does return NULL on failure. Other may return FALSE.
-// It may be interesting, for the developer, to know why the function is failing.
-// for that reason, lcms2 does offer a logging function. This function will get
-// an ENGLISH string with some clues on what is going wrong. You can show this
-// info to the end user if you wish, or just create some sort of log on disk.
-// The logging function should NOT terminate the program, as this obviously can leave
-// unfreed resources. It is the programmer's responsibility to check each function
-// return code to make sure it didn't fail.
-
-#define cmsERROR_UNDEFINED 0
-#define cmsERROR_FILE 1
-#define cmsERROR_RANGE 2
-#define cmsERROR_INTERNAL 3
-#define cmsERROR_NULL 4
-#define cmsERROR_READ 5
-#define cmsERROR_SEEK 6
-#define cmsERROR_WRITE 7
-#define cmsERROR_UNKNOWN_EXTENSION 8
-#define cmsERROR_COLORSPACE_CHECK 9
-#define cmsERROR_ALREADY_DEFINED 10
-#define cmsERROR_BAD_SIGNATURE 11
-#define cmsERROR_CORRUPTION_DETECTED 12
-#define cmsERROR_NOT_SUITABLE 13
-
-// Error logger is called with the ContextID when a message is raised. This gives the
-// chance to know which thread is responsible of the warning and any environment associated
-// with it. Non-multithreading applications may safely ignore this parameter.
-// Note that under certain special circumstances, ContextID may be NULL.
-typedef void (* cmsLogErrorHandlerFunction)(cmsContext ContextID, cmsUInt32Number ErrorCode, const char *Text);
-
-// Allows user to set any specific logger
-CMSAPI void CMSEXPORT cmsSetLogErrorHandler(cmsLogErrorHandlerFunction Fn);
-CMSAPI void CMSEXPORT cmsSetLogErrorHandlerTHR(cmsContext ContextID, cmsLogErrorHandlerFunction Fn);
-
-// Conversions --------------------------------------------------------------------------------------------------------------
-
-// Returns pointers to constant structs
-CMSAPI const cmsCIEXYZ* CMSEXPORT cmsD50_XYZ(void);
-CMSAPI const cmsCIExyY* CMSEXPORT cmsD50_xyY(void);
-
-// Colorimetric space conversions
-CMSAPI void CMSEXPORT cmsXYZ2xyY(cmsCIExyY* Dest, const cmsCIEXYZ* Source);
-CMSAPI void CMSEXPORT cmsxyY2XYZ(cmsCIEXYZ* Dest, const cmsCIExyY* Source);
-CMSAPI void CMSEXPORT cmsXYZ2Lab(const cmsCIEXYZ* WhitePoint, cmsCIELab* Lab, const cmsCIEXYZ* xyz);
-CMSAPI void CMSEXPORT cmsLab2XYZ(const cmsCIEXYZ* WhitePoint, cmsCIEXYZ* xyz, const cmsCIELab* Lab);
-CMSAPI void CMSEXPORT cmsLab2LCh(cmsCIELCh*LCh, const cmsCIELab* Lab);
-CMSAPI void CMSEXPORT cmsLCh2Lab(cmsCIELab* Lab, const cmsCIELCh* LCh);
-
-// Encoding /Decoding on PCS
-CMSAPI void CMSEXPORT cmsLabEncoded2Float(cmsCIELab* Lab, const cmsUInt16Number wLab[3]);
-CMSAPI void CMSEXPORT cmsLabEncoded2FloatV2(cmsCIELab* Lab, const cmsUInt16Number wLab[3]);
-CMSAPI void CMSEXPORT cmsFloat2LabEncoded(cmsUInt16Number wLab[3], const cmsCIELab* Lab);
-CMSAPI void CMSEXPORT cmsFloat2LabEncodedV2(cmsUInt16Number wLab[3], const cmsCIELab* Lab);
-CMSAPI void CMSEXPORT cmsXYZEncoded2Float(cmsCIEXYZ* fxyz, const cmsUInt16Number XYZ[3]);
-CMSAPI void CMSEXPORT cmsFloat2XYZEncoded(cmsUInt16Number XYZ[3], const cmsCIEXYZ* fXYZ);
-
-// DeltaE metrics
-CMSAPI cmsFloat64Number CMSEXPORT cmsDeltaE(const cmsCIELab* Lab1, const cmsCIELab* Lab2);
-CMSAPI cmsFloat64Number CMSEXPORT cmsCIE94DeltaE(const cmsCIELab* Lab1, const cmsCIELab* Lab2);
-CMSAPI cmsFloat64Number CMSEXPORT cmsBFDdeltaE(const cmsCIELab* Lab1, const cmsCIELab* Lab2);
-CMSAPI cmsFloat64Number CMSEXPORT cmsCMCdeltaE(const cmsCIELab* Lab1, const cmsCIELab* Lab2, cmsFloat64Number l, cmsFloat64Number c);
-CMSAPI cmsFloat64Number CMSEXPORT cmsCIE2000DeltaE(const cmsCIELab* Lab1, const cmsCIELab* Lab2, cmsFloat64Number Kl, cmsFloat64Number Kc, cmsFloat64Number Kh);
-
-// Temperature <-> Chromaticity (Black body)
-CMSAPI cmsBool CMSEXPORT cmsWhitePointFromTemp(cmsCIExyY* WhitePoint, cmsFloat64Number TempK);
-CMSAPI cmsBool CMSEXPORT cmsTempFromWhitePoint(cmsFloat64Number* TempK, const cmsCIExyY* WhitePoint);
-
-// Chromatic adaptation
-CMSAPI cmsBool CMSEXPORT cmsAdaptToIlluminant(cmsCIEXYZ* Result, const cmsCIEXYZ* SourceWhitePt,
- const cmsCIEXYZ* Illuminant,
- const cmsCIEXYZ* Value);
-
-// CIECAM02 ---------------------------------------------------------------------------------------------------
-
-// Viewing conditions. Please note those are CAM model viewing conditions, and not the ICC tag viewing
-// conditions, which I'm naming cmsICCViewingConditions to make differences evident. Unfortunately, the tag
-// cannot deal with surround La, Yb and D value so is basically useless to store CAM02 viewing conditions.
-
-
-#define AVG_SURROUND 1
-#define DIM_SURROUND 2
-#define DARK_SURROUND 3
-#define CUTSHEET_SURROUND 4
-
-#define D_CALCULATE (-1)
-
-typedef struct {
- cmsCIEXYZ whitePoint;
- cmsFloat64Number Yb;
- cmsFloat64Number La;
- cmsUInt32Number surround;
- cmsFloat64Number D_value;
-
- } cmsViewingConditions;
-
-CMSAPI cmsHANDLE CMSEXPORT cmsCIECAM02Init(cmsContext ContextID, const cmsViewingConditions* pVC);
-CMSAPI void CMSEXPORT cmsCIECAM02Done(cmsHANDLE hModel);
-CMSAPI void CMSEXPORT cmsCIECAM02Forward(cmsHANDLE hModel, const cmsCIEXYZ* pIn, cmsJCh* pOut);
-CMSAPI void CMSEXPORT cmsCIECAM02Reverse(cmsHANDLE hModel, const cmsJCh* pIn, cmsCIEXYZ* pOut);
-
-
-// Tone curves -----------------------------------------------------------------------------------------
-
-// This describes a curve segment. For a table of supported types, see the manual. User can increase the number of
-// available types by using a proper plug-in. Parametric segments allow 10 parameters at most
-
-typedef struct {
- cmsFloat32Number x0, x1; // Domain; for x0 < x <= x1
- cmsInt32Number Type; // Parametric type, Type == 0 means sampled segment. Negative values are reserved
- cmsFloat64Number Params[10]; // Parameters if Type != 0
- cmsUInt32Number nGridPoints; // Number of grid points if Type == 0
- cmsFloat32Number* SampledPoints; // Points to an array of floats if Type == 0
-
-} cmsCurveSegment;
-
-// The internal representation is none of your business.
-typedef struct _cms_curve_struct cmsToneCurve;
-
-CMSAPI cmsToneCurve* CMSEXPORT cmsBuildSegmentedToneCurve(cmsContext ContextID, cmsUInt32Number nSegments, const cmsCurveSegment Segments[]);
-CMSAPI cmsToneCurve* CMSEXPORT cmsBuildParametricToneCurve(cmsContext ContextID, cmsInt32Number Type, const cmsFloat64Number Params[]);
-CMSAPI cmsToneCurve* CMSEXPORT cmsBuildGamma(cmsContext ContextID, cmsFloat64Number Gamma);
-CMSAPI cmsToneCurve* CMSEXPORT cmsBuildTabulatedToneCurve16(cmsContext ContextID, cmsUInt32Number nEntries, const cmsUInt16Number values[]);
-CMSAPI cmsToneCurve* CMSEXPORT cmsBuildTabulatedToneCurveFloat(cmsContext ContextID, cmsUInt32Number nEntries, const cmsFloat32Number values[]);
-CMSAPI void CMSEXPORT cmsFreeToneCurve(cmsToneCurve* Curve);
-CMSAPI void CMSEXPORT cmsFreeToneCurveTriple(cmsToneCurve* Curve[3]);
-CMSAPI cmsToneCurve* CMSEXPORT cmsDupToneCurve(const cmsToneCurve* Src);
-CMSAPI cmsToneCurve* CMSEXPORT cmsReverseToneCurve(const cmsToneCurve* InGamma);
-CMSAPI cmsToneCurve* CMSEXPORT cmsReverseToneCurveEx(cmsUInt32Number nResultSamples, const cmsToneCurve* InGamma);
-CMSAPI cmsToneCurve* CMSEXPORT cmsJoinToneCurve(cmsContext ContextID, const cmsToneCurve* X, const cmsToneCurve* Y, cmsUInt32Number nPoints);
-CMSAPI cmsBool CMSEXPORT cmsSmoothToneCurve(cmsToneCurve* Tab, cmsFloat64Number lambda);
-CMSAPI cmsFloat32Number CMSEXPORT cmsEvalToneCurveFloat(const cmsToneCurve* Curve, cmsFloat32Number v);
-CMSAPI cmsUInt16Number CMSEXPORT cmsEvalToneCurve16(const cmsToneCurve* Curve, cmsUInt16Number v);
-CMSAPI cmsBool CMSEXPORT cmsIsToneCurveMultisegment(const cmsToneCurve* InGamma);
-CMSAPI cmsBool CMSEXPORT cmsIsToneCurveLinear(const cmsToneCurve* Curve);
-CMSAPI cmsBool CMSEXPORT cmsIsToneCurveMonotonic(const cmsToneCurve* t);
-CMSAPI cmsBool CMSEXPORT cmsIsToneCurveDescending(const cmsToneCurve* t);
-CMSAPI cmsInt32Number CMSEXPORT cmsGetToneCurveParametricType(const cmsToneCurve* t);
-CMSAPI cmsFloat64Number CMSEXPORT cmsEstimateGamma(const cmsToneCurve* t, cmsFloat64Number Precision);
-
-CMSAPI const cmsCurveSegment* CMSEXPORT cmsGetToneCurveSegment(cmsInt32Number n, const cmsToneCurve* t);
-
-// Tone curve tabular estimation
-CMSAPI cmsUInt32Number CMSEXPORT cmsGetToneCurveEstimatedTableEntries(const cmsToneCurve* t);
-CMSAPI const cmsUInt16Number* CMSEXPORT cmsGetToneCurveEstimatedTable(const cmsToneCurve* t);
-
-
-// Implements pipelines of multi-processing elements -------------------------------------------------------------
-
-// Nothing to see here, move along
-typedef struct _cmsPipeline_struct cmsPipeline;
-typedef struct _cmsStage_struct cmsStage;
-
-// Those are hi-level pipelines
-CMSAPI cmsPipeline* CMSEXPORT cmsPipelineAlloc(cmsContext ContextID, cmsUInt32Number InputChannels, cmsUInt32Number OutputChannels);
-CMSAPI void CMSEXPORT cmsPipelineFree(cmsPipeline* lut);
-CMSAPI cmsPipeline* CMSEXPORT cmsPipelineDup(const cmsPipeline* Orig);
-
-CMSAPI cmsContext CMSEXPORT cmsGetPipelineContextID(const cmsPipeline* lut);
-CMSAPI cmsUInt32Number CMSEXPORT cmsPipelineInputChannels(const cmsPipeline* lut);
-CMSAPI cmsUInt32Number CMSEXPORT cmsPipelineOutputChannels(const cmsPipeline* lut);
-
-CMSAPI cmsUInt32Number CMSEXPORT cmsPipelineStageCount(const cmsPipeline* lut);
-CMSAPI cmsStage* CMSEXPORT cmsPipelineGetPtrToFirstStage(const cmsPipeline* lut);
-CMSAPI cmsStage* CMSEXPORT cmsPipelineGetPtrToLastStage(const cmsPipeline* lut);
-
-CMSAPI void CMSEXPORT cmsPipelineEval16(const cmsUInt16Number In[], cmsUInt16Number Out[], const cmsPipeline* lut);
-CMSAPI void CMSEXPORT cmsPipelineEvalFloat(const cmsFloat32Number In[], cmsFloat32Number Out[], const cmsPipeline* lut);
-CMSAPI cmsBool CMSEXPORT cmsPipelineEvalReverseFloat(cmsFloat32Number Target[], cmsFloat32Number Result[], cmsFloat32Number Hint[], const cmsPipeline* lut);
-CMSAPI cmsBool CMSEXPORT cmsPipelineCat(cmsPipeline* l1, const cmsPipeline* l2);
-CMSAPI cmsBool CMSEXPORT cmsPipelineSetSaveAs8bitsFlag(cmsPipeline* lut, cmsBool On);
-
-// Where to place/locate the stages in the pipeline chain
-typedef enum { cmsAT_BEGIN, cmsAT_END } cmsStageLoc;
-
-CMSAPI cmsBool CMSEXPORT cmsPipelineInsertStage(cmsPipeline* lut, cmsStageLoc loc, cmsStage* mpe);
-CMSAPI void CMSEXPORT cmsPipelineUnlinkStage(cmsPipeline* lut, cmsStageLoc loc, cmsStage** mpe);
-
-// This function is quite useful to analyze the structure of a Pipeline and retrieve the Stage elements
-// that conform the Pipeline. It should be called with the Pipeline, the number of expected elements and
-// then a list of expected types followed with a list of double pointers to Stage elements. If
-// the function founds a match with current pipeline, it fills the pointers and returns TRUE
-// if not, returns FALSE without touching anything.
-CMSAPI cmsBool CMSEXPORT cmsPipelineCheckAndRetreiveStages(const cmsPipeline* Lut, cmsUInt32Number n, ...);
-
-// Matrix has double precision and CLUT has only float precision. That is because an ICC profile can encode
-// matrices with far more precision that CLUTS
-CMSAPI cmsStage* CMSEXPORT cmsStageAllocIdentity(cmsContext ContextID, cmsUInt32Number nChannels);
-CMSAPI cmsStage* CMSEXPORT cmsStageAllocToneCurves(cmsContext ContextID, cmsUInt32Number nChannels, cmsToneCurve* const Curves[]);
-CMSAPI cmsStage* CMSEXPORT cmsStageAllocMatrix(cmsContext ContextID, cmsUInt32Number Rows, cmsUInt32Number Cols, const cmsFloat64Number* Matrix, const cmsFloat64Number* Offset);
-
-CMSAPI cmsStage* CMSEXPORT cmsStageAllocCLut16bit(cmsContext ContextID, cmsUInt32Number nGridPoints, cmsUInt32Number inputChan, cmsUInt32Number outputChan, const cmsUInt16Number* Table);
-CMSAPI cmsStage* CMSEXPORT cmsStageAllocCLutFloat(cmsContext ContextID, cmsUInt32Number nGridPoints, cmsUInt32Number inputChan, cmsUInt32Number outputChan, const cmsFloat32Number* Table);
-
-CMSAPI cmsStage* CMSEXPORT cmsStageAllocCLut16bitGranular(cmsContext ContextID, const cmsUInt32Number clutPoints[], cmsUInt32Number inputChan, cmsUInt32Number outputChan, const cmsUInt16Number* Table);
-CMSAPI cmsStage* CMSEXPORT cmsStageAllocCLutFloatGranular(cmsContext ContextID, const cmsUInt32Number clutPoints[], cmsUInt32Number inputChan, cmsUInt32Number outputChan, const cmsFloat32Number* Table);
-
-CMSAPI cmsStage* CMSEXPORT cmsStageDup(cmsStage* mpe);
-CMSAPI void CMSEXPORT cmsStageFree(cmsStage* mpe);
-CMSAPI cmsStage* CMSEXPORT cmsStageNext(const cmsStage* mpe);
-
-CMSAPI cmsUInt32Number CMSEXPORT cmsStageInputChannels(const cmsStage* mpe);
-CMSAPI cmsUInt32Number CMSEXPORT cmsStageOutputChannels(const cmsStage* mpe);
-CMSAPI cmsStageSignature CMSEXPORT cmsStageType(const cmsStage* mpe);
-CMSAPI void* CMSEXPORT cmsStageData(const cmsStage* mpe);
-CMSAPI cmsContext CMSEXPORT cmsGetStageContextID(const cmsStage* mpe);
-
-// Sampling
-typedef cmsInt32Number (* cmsSAMPLER16) (CMSREGISTER const cmsUInt16Number In[],
- CMSREGISTER cmsUInt16Number Out[],
- CMSREGISTER void * Cargo);
-
-typedef cmsInt32Number (* cmsSAMPLERFLOAT)(CMSREGISTER const cmsFloat32Number In[],
- CMSREGISTER cmsFloat32Number Out[],
- CMSREGISTER void * Cargo);
-
-// Use this flag to prevent changes being written to destination
-#define SAMPLER_INSPECT 0x01000000
-
-// For CLUT only
-CMSAPI cmsBool CMSEXPORT cmsStageSampleCLut16bit(cmsStage* mpe, cmsSAMPLER16 Sampler, void* Cargo, cmsUInt32Number dwFlags);
-CMSAPI cmsBool CMSEXPORT cmsStageSampleCLutFloat(cmsStage* mpe, cmsSAMPLERFLOAT Sampler, void* Cargo, cmsUInt32Number dwFlags);
-
-// Slicers
-CMSAPI cmsBool CMSEXPORT cmsSliceSpace16(cmsUInt32Number nInputs, const cmsUInt32Number clutPoints[],
- cmsSAMPLER16 Sampler, void * Cargo);
-
-CMSAPI cmsBool CMSEXPORT cmsSliceSpaceFloat(cmsUInt32Number nInputs, const cmsUInt32Number clutPoints[],
- cmsSAMPLERFLOAT Sampler, void * Cargo);
-
-// Multilocalized Unicode management ---------------------------------------------------------------------------------------
-
-typedef struct _cms_MLU_struct cmsMLU;
-
-#define cmsNoLanguage "\0\0"
-#define cmsNoCountry "\0\0"
-
-// Special language/country to retrieve unicode field for description in V2 profiles. Use with care.
-#define cmsV2Unicode "\xff\xff"
-
-CMSAPI cmsMLU* CMSEXPORT cmsMLUalloc(cmsContext ContextID, cmsUInt32Number nItems);
-CMSAPI void CMSEXPORT cmsMLUfree(cmsMLU* mlu);
-CMSAPI cmsMLU* CMSEXPORT cmsMLUdup(const cmsMLU* mlu);
-
-CMSAPI cmsBool CMSEXPORT cmsMLUsetASCII(cmsMLU* mlu,
- const char LanguageCode[3], const char CountryCode[3],
- const char* ASCIIString);
-CMSAPI cmsBool CMSEXPORT cmsMLUsetWide(cmsMLU* mlu,
- const char LanguageCode[3], const char CountryCode[3],
- const wchar_t* WideString);
-CMSAPI cmsBool CMSEXPORT cmsMLUsetUTF8(cmsMLU* mlu,
- const char LanguageCode[3], const char CountryCode[3],
- const char* UTF8String);
-
-CMSAPI cmsUInt32Number CMSEXPORT cmsMLUgetASCII(const cmsMLU* mlu,
- const char LanguageCode[3], const char CountryCode[3],
- char* Buffer, cmsUInt32Number BufferSize);
-
-CMSAPI cmsUInt32Number CMSEXPORT cmsMLUgetWide(const cmsMLU* mlu,
- const char LanguageCode[3], const char CountryCode[3],
- wchar_t* Buffer, cmsUInt32Number BufferSize);
-CMSAPI cmsUInt32Number CMSEXPORT cmsMLUgetUTF8(const cmsMLU* mlu,
- const char LanguageCode[3], const char CountryCode[3],
- char* Buffer, cmsUInt32Number BufferSize);
-
-
-CMSAPI cmsBool CMSEXPORT cmsMLUgetTranslation(const cmsMLU* mlu,
- const char LanguageCode[3], const char CountryCode[3],
- char ObtainedLanguage[3], char ObtainedCountry[3]);
-
-CMSAPI cmsUInt32Number CMSEXPORT cmsMLUtranslationsCount(const cmsMLU* mlu);
-
-CMSAPI cmsBool CMSEXPORT cmsMLUtranslationsCodes(const cmsMLU* mlu,
- cmsUInt32Number idx,
- char LanguageCode[3],
- char CountryCode[3]);
-
-// Undercolorremoval & black generation -------------------------------------------------------------------------------------
-
-typedef struct {
- cmsToneCurve* Ucr;
- cmsToneCurve* Bg;
- cmsMLU* Desc;
-
-} cmsUcrBg;
-
-// Screening ----------------------------------------------------------------------------------------------------------------
-
-#define cmsPRINTER_DEFAULT_SCREENS 0x0001
-#define cmsFREQUENCE_UNITS_LINES_CM 0x0000
-#define cmsFREQUENCE_UNITS_LINES_INCH 0x0002
-
-#define cmsSPOT_UNKNOWN 0
-#define cmsSPOT_PRINTER_DEFAULT 1
-#define cmsSPOT_ROUND 2
-#define cmsSPOT_DIAMOND 3
-#define cmsSPOT_ELLIPSE 4
-#define cmsSPOT_LINE 5
-#define cmsSPOT_SQUARE 6
-#define cmsSPOT_CROSS 7
-
-typedef struct {
- cmsFloat64Number Frequency;
- cmsFloat64Number ScreenAngle;
- cmsUInt32Number SpotShape;
-
-} cmsScreeningChannel;
-
-typedef struct {
- cmsUInt32Number Flag;
- cmsUInt32Number nChannels;
- cmsScreeningChannel Channels[cmsMAXCHANNELS];
-
-} cmsScreening;
-
-
-// Named color -----------------------------------------------------------------------------------------------------------------
-
-typedef struct _cms_NAMEDCOLORLIST_struct cmsNAMEDCOLORLIST;
-
-CMSAPI cmsNAMEDCOLORLIST* CMSEXPORT cmsAllocNamedColorList(cmsContext ContextID,
- cmsUInt32Number n,
- cmsUInt32Number ColorantCount,
- const char* Prefix, const char* Suffix);
-
-CMSAPI void CMSEXPORT cmsFreeNamedColorList(cmsNAMEDCOLORLIST* v);
-CMSAPI cmsNAMEDCOLORLIST* CMSEXPORT cmsDupNamedColorList(const cmsNAMEDCOLORLIST* v);
-CMSAPI cmsBool CMSEXPORT cmsAppendNamedColor(cmsNAMEDCOLORLIST* v, const char* Name,
- cmsUInt16Number PCS[3],
- cmsUInt16Number Colorant[cmsMAXCHANNELS]);
-
-CMSAPI cmsUInt32Number CMSEXPORT cmsNamedColorCount(const cmsNAMEDCOLORLIST* v);
-CMSAPI cmsInt32Number CMSEXPORT cmsNamedColorIndex(const cmsNAMEDCOLORLIST* v, const char* Name);
-
-CMSAPI cmsBool CMSEXPORT cmsNamedColorInfo(const cmsNAMEDCOLORLIST* NamedColorList, cmsUInt32Number nColor,
- char* Name,
- char* Prefix,
- char* Suffix,
- cmsUInt16Number* PCS,
- cmsUInt16Number* Colorant);
-
-// Retrieve named color list from transform
-CMSAPI cmsNAMEDCOLORLIST* CMSEXPORT cmsGetNamedColorList(cmsHTRANSFORM xform);
-
-// Profile sequence -----------------------------------------------------------------------------------------------------
-
-// Profile sequence descriptor. Some fields come from profile sequence descriptor tag, others
-// come from Profile Sequence Identifier Tag
-typedef struct {
-
- cmsSignature deviceMfg;
- cmsSignature deviceModel;
- cmsUInt64Number attributes;
- cmsTechnologySignature technology;
- cmsProfileID ProfileID;
- cmsMLU* Manufacturer;
- cmsMLU* Model;
- cmsMLU* Description;
-
-} cmsPSEQDESC;
-
-typedef struct {
-
- cmsUInt32Number n;
- cmsContext ContextID;
- cmsPSEQDESC* seq;
-
-} cmsSEQ;
-
-CMSAPI cmsSEQ* CMSEXPORT cmsAllocProfileSequenceDescription(cmsContext ContextID, cmsUInt32Number n);
-CMSAPI cmsSEQ* CMSEXPORT cmsDupProfileSequenceDescription(const cmsSEQ* pseq);
-CMSAPI void CMSEXPORT cmsFreeProfileSequenceDescription(cmsSEQ* pseq);
-
-// Dictionaries --------------------------------------------------------------------------------------------------------
-
-typedef struct _cmsDICTentry_struct {
-
- struct _cmsDICTentry_struct* Next;
-
- cmsMLU *DisplayName;
- cmsMLU *DisplayValue;
- wchar_t* Name;
- wchar_t* Value;
-
-} cmsDICTentry;
-
-CMSAPI cmsHANDLE CMSEXPORT cmsDictAlloc(cmsContext ContextID);
-CMSAPI void CMSEXPORT cmsDictFree(cmsHANDLE hDict);
-CMSAPI cmsHANDLE CMSEXPORT cmsDictDup(cmsHANDLE hDict);
-
-CMSAPI cmsBool CMSEXPORT cmsDictAddEntry(cmsHANDLE hDict, const wchar_t* Name, const wchar_t* Value, const cmsMLU *DisplayName, const cmsMLU *DisplayValue);
-CMSAPI const cmsDICTentry* CMSEXPORT cmsDictGetEntryList(cmsHANDLE hDict);
-CMSAPI const cmsDICTentry* CMSEXPORT cmsDictNextEntry(const cmsDICTentry* e);
-
-// Access to Profile data ----------------------------------------------------------------------------------------------
-CMSAPI cmsHPROFILE CMSEXPORT cmsCreateProfilePlaceholder(cmsContext ContextID);
-
-CMSAPI cmsContext CMSEXPORT cmsGetProfileContextID(cmsHPROFILE hProfile);
-CMSAPI cmsInt32Number CMSEXPORT cmsGetTagCount(cmsHPROFILE hProfile);
-CMSAPI cmsTagSignature CMSEXPORT cmsGetTagSignature(cmsHPROFILE hProfile, cmsUInt32Number n);
-CMSAPI cmsBool CMSEXPORT cmsIsTag(cmsHPROFILE hProfile, cmsTagSignature sig);
-
-// Read and write pre-formatted data
-CMSAPI void* CMSEXPORT cmsReadTag(cmsHPROFILE hProfile, cmsTagSignature sig);
-CMSAPI cmsBool CMSEXPORT cmsWriteTag(cmsHPROFILE hProfile, cmsTagSignature sig, const void* data);
-CMSAPI cmsBool CMSEXPORT cmsLinkTag(cmsHPROFILE hProfile, cmsTagSignature sig, cmsTagSignature dest);
-CMSAPI cmsTagSignature CMSEXPORT cmsTagLinkedTo(cmsHPROFILE hProfile, cmsTagSignature sig);
-
-// Read and write raw data
-CMSAPI cmsUInt32Number CMSEXPORT cmsReadRawTag(cmsHPROFILE hProfile, cmsTagSignature sig, void* Buffer, cmsUInt32Number BufferSize);
-CMSAPI cmsBool CMSEXPORT cmsWriteRawTag(cmsHPROFILE hProfile, cmsTagSignature sig, const void* data, cmsUInt32Number Size);
-
-// Access header data
-#define cmsEmbeddedProfileFalse 0x00000000
-#define cmsEmbeddedProfileTrue 0x00000001
-#define cmsUseAnywhere 0x00000000
-#define cmsUseWithEmbeddedDataOnly 0x00000002
-
-CMSAPI cmsUInt32Number CMSEXPORT cmsGetHeaderFlags(cmsHPROFILE hProfile);
-CMSAPI void CMSEXPORT cmsGetHeaderAttributes(cmsHPROFILE hProfile, cmsUInt64Number* Flags);
-CMSAPI void CMSEXPORT cmsGetHeaderProfileID(cmsHPROFILE hProfile, cmsUInt8Number* ProfileID);
-CMSAPI cmsBool CMSEXPORT cmsGetHeaderCreationDateTime(cmsHPROFILE hProfile, struct tm *Dest);
-CMSAPI cmsUInt32Number CMSEXPORT cmsGetHeaderRenderingIntent(cmsHPROFILE hProfile);
-
-CMSAPI void CMSEXPORT cmsSetHeaderFlags(cmsHPROFILE hProfile, cmsUInt32Number Flags);
-CMSAPI cmsUInt32Number CMSEXPORT cmsGetHeaderManufacturer(cmsHPROFILE hProfile);
-CMSAPI void CMSEXPORT cmsSetHeaderManufacturer(cmsHPROFILE hProfile, cmsUInt32Number manufacturer);
-CMSAPI cmsUInt32Number CMSEXPORT cmsGetHeaderCreator(cmsHPROFILE hProfile);
-CMSAPI cmsUInt32Number CMSEXPORT cmsGetHeaderModel(cmsHPROFILE hProfile);
-CMSAPI void CMSEXPORT cmsSetHeaderModel(cmsHPROFILE hProfile, cmsUInt32Number model);
-CMSAPI void CMSEXPORT cmsSetHeaderAttributes(cmsHPROFILE hProfile, cmsUInt64Number Flags);
-CMSAPI void CMSEXPORT cmsSetHeaderProfileID(cmsHPROFILE hProfile, cmsUInt8Number* ProfileID);
-CMSAPI void CMSEXPORT cmsSetHeaderRenderingIntent(cmsHPROFILE hProfile, cmsUInt32Number RenderingIntent);
-
-CMSAPI cmsColorSpaceSignature
- CMSEXPORT cmsGetPCS(cmsHPROFILE hProfile);
-CMSAPI void CMSEXPORT cmsSetPCS(cmsHPROFILE hProfile, cmsColorSpaceSignature pcs);
-CMSAPI cmsColorSpaceSignature
- CMSEXPORT cmsGetColorSpace(cmsHPROFILE hProfile);
-CMSAPI void CMSEXPORT cmsSetColorSpace(cmsHPROFILE hProfile, cmsColorSpaceSignature sig);
-CMSAPI cmsProfileClassSignature
- CMSEXPORT cmsGetDeviceClass(cmsHPROFILE hProfile);
-CMSAPI void CMSEXPORT cmsSetDeviceClass(cmsHPROFILE hProfile, cmsProfileClassSignature sig);
-CMSAPI void CMSEXPORT cmsSetProfileVersion(cmsHPROFILE hProfile, cmsFloat64Number Version);
-CMSAPI cmsFloat64Number CMSEXPORT cmsGetProfileVersion(cmsHPROFILE hProfile);
-
-CMSAPI cmsUInt32Number CMSEXPORT cmsGetEncodedICCversion(cmsHPROFILE hProfile);
-CMSAPI void CMSEXPORT cmsSetEncodedICCversion(cmsHPROFILE hProfile, cmsUInt32Number Version);
-
-// How profiles may be used
-#define LCMS_USED_AS_INPUT 0
-#define LCMS_USED_AS_OUTPUT 1
-#define LCMS_USED_AS_PROOF 2
-
-CMSAPI cmsBool CMSEXPORT cmsIsIntentSupported(cmsHPROFILE hProfile, cmsUInt32Number Intent, cmsUInt32Number UsedDirection);
-CMSAPI cmsBool CMSEXPORT cmsIsMatrixShaper(cmsHPROFILE hProfile);
-CMSAPI cmsBool CMSEXPORT cmsIsCLUT(cmsHPROFILE hProfile, cmsUInt32Number Intent, cmsUInt32Number UsedDirection);
-
-// Translate form/to our notation to ICC
-CMSAPI cmsColorSpaceSignature CMSEXPORT _cmsICCcolorSpace(int OurNotation);
-CMSAPI int CMSEXPORT _cmsLCMScolorSpace(cmsColorSpaceSignature ProfileSpace);
-
-// Deprecated, use cmsChannelsOfColorSpace instead
-CMSAPI cmsUInt32Number CMSEXPORT cmsChannelsOf(cmsColorSpaceSignature ColorSpace);
-
-// Get number of channels of color space or -1 if color space is not listed/supported
-CMSAPI cmsInt32Number CMSEXPORT cmsChannelsOfColorSpace(cmsColorSpaceSignature ColorSpace);
-
-// Build a suitable formatter for the colorspace of this profile. nBytes=1 means 8 bits, nBytes=2 means 16 bits.
-CMSAPI cmsUInt32Number CMSEXPORT cmsFormatterForColorspaceOfProfile(cmsHPROFILE hProfile, cmsUInt32Number nBytes, cmsBool lIsFloat);
-CMSAPI cmsUInt32Number CMSEXPORT cmsFormatterForPCSOfProfile(cmsHPROFILE hProfile, cmsUInt32Number nBytes, cmsBool lIsFloat);
-
-
-// Localized info
-typedef enum {
- cmsInfoDescription = 0,
- cmsInfoManufacturer = 1,
- cmsInfoModel = 2,
- cmsInfoCopyright = 3
-} cmsInfoType;
-
-CMSAPI cmsUInt32Number CMSEXPORT cmsGetProfileInfo(cmsHPROFILE hProfile, cmsInfoType Info,
- const char LanguageCode[3], const char CountryCode[3],
- wchar_t* Buffer, cmsUInt32Number BufferSize);
-
-CMSAPI cmsUInt32Number CMSEXPORT cmsGetProfileInfoASCII(cmsHPROFILE hProfile, cmsInfoType Info,
- const char LanguageCode[3], const char CountryCode[3],
- char* Buffer, cmsUInt32Number BufferSize);
-
-CMSAPI cmsUInt32Number CMSEXPORT cmsGetProfileInfoUTF8(cmsHPROFILE hProfile, cmsInfoType Info,
- const char LanguageCode[3], const char CountryCode[3],
- char* Buffer, cmsUInt32Number BufferSize);
-
-// IO handlers ----------------------------------------------------------------------------------------------------------
-
-typedef struct _cms_io_handler cmsIOHANDLER;
-
-CMSAPI cmsIOHANDLER* CMSEXPORT cmsOpenIOhandlerFromFile(cmsContext ContextID, const char* FileName, const char* AccessMode);
-CMSAPI cmsIOHANDLER* CMSEXPORT cmsOpenIOhandlerFromStream(cmsContext ContextID, FILE* Stream);
-CMSAPI cmsIOHANDLER* CMSEXPORT cmsOpenIOhandlerFromMem(cmsContext ContextID, void *Buffer, cmsUInt32Number size, const char* AccessMode);
-CMSAPI cmsIOHANDLER* CMSEXPORT cmsOpenIOhandlerFromNULL(cmsContext ContextID);
-CMSAPI cmsIOHANDLER* CMSEXPORT cmsGetProfileIOhandler(cmsHPROFILE hProfile);
-CMSAPI cmsBool CMSEXPORT cmsCloseIOhandler(cmsIOHANDLER* io);
-
-// MD5 message digest --------------------------------------------------------------------------------------------------
-
-CMSAPI cmsBool CMSEXPORT cmsMD5computeID(cmsHPROFILE hProfile);
-
-// Profile high level functions ------------------------------------------------------------------------------------------
-
-CMSAPI cmsHPROFILE CMSEXPORT cmsOpenProfileFromFile(const char *ICCProfile, const char *sAccess);
-CMSAPI cmsHPROFILE CMSEXPORT cmsOpenProfileFromFileTHR(cmsContext ContextID, const char *ICCProfile, const char *sAccess);
-CMSAPI cmsHPROFILE CMSEXPORT cmsOpenProfileFromStream(FILE* ICCProfile, const char* sAccess);
-CMSAPI cmsHPROFILE CMSEXPORT cmsOpenProfileFromStreamTHR(cmsContext ContextID, FILE* ICCProfile, const char* sAccess);
-CMSAPI cmsHPROFILE CMSEXPORT cmsOpenProfileFromMem(const void * MemPtr, cmsUInt32Number dwSize);
-CMSAPI cmsHPROFILE CMSEXPORT cmsOpenProfileFromMemTHR(cmsContext ContextID, const void * MemPtr, cmsUInt32Number dwSize);
-CMSAPI cmsHPROFILE CMSEXPORT cmsOpenProfileFromIOhandlerTHR(cmsContext ContextID, cmsIOHANDLER* io);
-CMSAPI cmsHPROFILE CMSEXPORT cmsOpenProfileFromIOhandler2THR(cmsContext ContextID, cmsIOHANDLER* io, cmsBool write);
-CMSAPI cmsBool CMSEXPORT cmsCloseProfile(cmsHPROFILE hProfile);
-
-CMSAPI cmsBool CMSEXPORT cmsSaveProfileToFile(cmsHPROFILE hProfile, const char* FileName);
-CMSAPI cmsBool CMSEXPORT cmsSaveProfileToStream(cmsHPROFILE hProfile, FILE* Stream);
-CMSAPI cmsBool CMSEXPORT cmsSaveProfileToMem(cmsHPROFILE hProfile, void *MemPtr, cmsUInt32Number* BytesNeeded);
-CMSAPI cmsUInt32Number CMSEXPORT cmsSaveProfileToIOhandler(cmsHPROFILE hProfile, cmsIOHANDLER* io);
-
-// Predefined virtual profiles ------------------------------------------------------------------------------------------
-
-CMSAPI cmsHPROFILE CMSEXPORT cmsCreateRGBProfileTHR(cmsContext ContextID,
- const cmsCIExyY* WhitePoint,
- const cmsCIExyYTRIPLE* Primaries,
- cmsToneCurve* const TransferFunction[3]);
-
-CMSAPI cmsHPROFILE CMSEXPORT cmsCreateRGBProfile(const cmsCIExyY* WhitePoint,
- const cmsCIExyYTRIPLE* Primaries,
- cmsToneCurve* const TransferFunction[3]);
-
-CMSAPI cmsHPROFILE CMSEXPORT cmsCreateGrayProfileTHR(cmsContext ContextID,
- const cmsCIExyY* WhitePoint,
- const cmsToneCurve* TransferFunction);
-
-CMSAPI cmsHPROFILE CMSEXPORT cmsCreateGrayProfile(const cmsCIExyY* WhitePoint,
- const cmsToneCurve* TransferFunction);
-
-CMSAPI cmsHPROFILE CMSEXPORT cmsCreateLinearizationDeviceLinkTHR(cmsContext ContextID,
- cmsColorSpaceSignature ColorSpace,
- cmsToneCurve* const TransferFunctions[]);
-
-CMSAPI cmsHPROFILE CMSEXPORT cmsCreateLinearizationDeviceLink(cmsColorSpaceSignature ColorSpace,
- cmsToneCurve* const TransferFunctions[]);
-
-CMSAPI cmsHPROFILE CMSEXPORT cmsCreateInkLimitingDeviceLinkTHR(cmsContext ContextID,
- cmsColorSpaceSignature ColorSpace, cmsFloat64Number Limit);
-
-CMSAPI cmsHPROFILE CMSEXPORT cmsCreateInkLimitingDeviceLink(cmsColorSpaceSignature ColorSpace, cmsFloat64Number Limit);
-
-CMSAPI cmsHPROFILE CMSEXPORT cmsCreateDeviceLinkFromCubeFile(const char* cFileName);
-
-CMSAPI cmsHPROFILE CMSEXPORT cmsCreateDeviceLinkFromCubeFileTHR(cmsContext ContextID, const char* cFileName);
-
-CMSAPI cmsHPROFILE CMSEXPORT cmsCreateLab2ProfileTHR(cmsContext ContextID, const cmsCIExyY* WhitePoint);
-CMSAPI cmsHPROFILE CMSEXPORT cmsCreateLab2Profile(const cmsCIExyY* WhitePoint);
-CMSAPI cmsHPROFILE CMSEXPORT cmsCreateLab4ProfileTHR(cmsContext ContextID, const cmsCIExyY* WhitePoint);
-CMSAPI cmsHPROFILE CMSEXPORT cmsCreateLab4Profile(const cmsCIExyY* WhitePoint);
-
-CMSAPI cmsHPROFILE CMSEXPORT cmsCreateXYZProfileTHR(cmsContext ContextID);
-CMSAPI cmsHPROFILE CMSEXPORT cmsCreateXYZProfile(void);
-
-CMSAPI cmsHPROFILE CMSEXPORT cmsCreate_sRGBProfileTHR(cmsContext ContextID);
-CMSAPI cmsHPROFILE CMSEXPORT cmsCreate_sRGBProfile(void);
-
-CMSAPI cmsHPROFILE CMSEXPORT cmsCreate_OkLabProfile(cmsContext ctx);
-
-CMSAPI cmsHPROFILE CMSEXPORT cmsCreateBCHSWabstractProfileTHR(cmsContext ContextID,
- cmsUInt32Number nLUTPoints,
- cmsFloat64Number Bright,
- cmsFloat64Number Contrast,
- cmsFloat64Number Hue,
- cmsFloat64Number Saturation,
- cmsUInt32Number TempSrc,
- cmsUInt32Number TempDest);
-
-CMSAPI cmsHPROFILE CMSEXPORT cmsCreateBCHSWabstractProfile(cmsUInt32Number nLUTPoints,
- cmsFloat64Number Bright,
- cmsFloat64Number Contrast,
- cmsFloat64Number Hue,
- cmsFloat64Number Saturation,
- cmsUInt32Number TempSrc,
- cmsUInt32Number TempDest);
-
-CMSAPI cmsHPROFILE CMSEXPORT cmsCreateNULLProfileTHR(cmsContext ContextID);
-CMSAPI cmsHPROFILE CMSEXPORT cmsCreateNULLProfile(void);
-
-// Converts a transform to a devicelink profile
-CMSAPI cmsHPROFILE CMSEXPORT cmsTransform2DeviceLink(cmsHTRANSFORM hTransform, cmsFloat64Number Version, cmsUInt32Number dwFlags);
-
-// Intents ----------------------------------------------------------------------------------------------
-
-// ICC Intents
-#define INTENT_PERCEPTUAL 0
-#define INTENT_RELATIVE_COLORIMETRIC 1
-#define INTENT_SATURATION 2
-#define INTENT_ABSOLUTE_COLORIMETRIC 3
-
-// Non-ICC intents
-#define INTENT_PRESERVE_K_ONLY_PERCEPTUAL 10
-#define INTENT_PRESERVE_K_ONLY_RELATIVE_COLORIMETRIC 11
-#define INTENT_PRESERVE_K_ONLY_SATURATION 12
-#define INTENT_PRESERVE_K_PLANE_PERCEPTUAL 13
-#define INTENT_PRESERVE_K_PLANE_RELATIVE_COLORIMETRIC 14
-#define INTENT_PRESERVE_K_PLANE_SATURATION 15
-
-// Call with NULL as parameters to get the intent count
-CMSAPI cmsUInt32Number CMSEXPORT cmsGetSupportedIntents(cmsUInt32Number nMax, cmsUInt32Number* Codes, char** Descriptions);
-CMSAPI cmsUInt32Number CMSEXPORT cmsGetSupportedIntentsTHR(cmsContext ContextID, cmsUInt32Number nMax, cmsUInt32Number* Codes, char** Descriptions);
-
-// Flags
-
-#define cmsFLAGS_NOCACHE 0x0040 // Inhibit 1-pixel cache
-#define cmsFLAGS_NOOPTIMIZE 0x0100 // Inhibit optimizations
-#define cmsFLAGS_NULLTRANSFORM 0x0200 // Don't transform anyway
-
-// Proofing flags
-#define cmsFLAGS_GAMUTCHECK 0x1000 // Out of Gamut alarm
-#define cmsFLAGS_SOFTPROOFING 0x4000 // Do softproofing
-
-// Misc
-#define cmsFLAGS_BLACKPOINTCOMPENSATION 0x2000
-#define cmsFLAGS_NOWHITEONWHITEFIXUP 0x0004 // Don't fix scum dot
-#define cmsFLAGS_HIGHRESPRECALC 0x0400 // Use more memory to give better accuracy
-#define cmsFLAGS_LOWRESPRECALC 0x0800 // Use less memory to minimize resources
-
-// For devicelink creation
-#define cmsFLAGS_8BITS_DEVICELINK 0x0008 // Create 8 bits devicelinks
-#define cmsFLAGS_GUESSDEVICECLASS 0x0020 // Guess device class (for transform2devicelink)
-#define cmsFLAGS_KEEP_SEQUENCE 0x0080 // Keep profile sequence for devicelink creation
-
-// Specific to a particular optimizations
-#define cmsFLAGS_FORCE_CLUT 0x0002 // Force CLUT optimization
-#define cmsFLAGS_CLUT_POST_LINEARIZATION 0x0001 // create postlinearization tables if possible
-#define cmsFLAGS_CLUT_PRE_LINEARIZATION 0x0010 // create prelinearization tables if possible
-
-// Specific to unbounded mode
-#define cmsFLAGS_NONEGATIVES 0x8000 // Prevent negative numbers in floating point transforms
-
-// Copy alpha channels when transforming
-#define cmsFLAGS_COPY_ALPHA 0x04000000 // Alpha channels are copied on cmsDoTransform()
-
-// Fine-tune control over number of gridpoints
-#define cmsFLAGS_GRIDPOINTS(n) (((n) & 0xFF) << 16)
-
-// CRD special
-#define cmsFLAGS_NODEFAULTRESOURCEDEF 0x01000000
-
-// Transforms ---------------------------------------------------------------------------------------------------
-
-CMSAPI cmsHTRANSFORM CMSEXPORT cmsCreateTransformTHR(cmsContext ContextID,
- cmsHPROFILE Input,
- cmsUInt32Number InputFormat,
- cmsHPROFILE Output,
- cmsUInt32Number OutputFormat,
- cmsUInt32Number Intent,
- cmsUInt32Number dwFlags);
-
-CMSAPI cmsHTRANSFORM CMSEXPORT cmsCreateTransform(cmsHPROFILE Input,
- cmsUInt32Number InputFormat,
- cmsHPROFILE Output,
- cmsUInt32Number OutputFormat,
- cmsUInt32Number Intent,
- cmsUInt32Number dwFlags);
-
-CMSAPI cmsHTRANSFORM CMSEXPORT cmsCreateProofingTransformTHR(cmsContext ContextID,
- cmsHPROFILE Input,
- cmsUInt32Number InputFormat,
- cmsHPROFILE Output,
- cmsUInt32Number OutputFormat,
- cmsHPROFILE Proofing,
- cmsUInt32Number Intent,
- cmsUInt32Number ProofingIntent,
- cmsUInt32Number dwFlags);
-
-CMSAPI cmsHTRANSFORM CMSEXPORT cmsCreateProofingTransform(cmsHPROFILE Input,
- cmsUInt32Number InputFormat,
- cmsHPROFILE Output,
- cmsUInt32Number OutputFormat,
- cmsHPROFILE Proofing,
- cmsUInt32Number Intent,
- cmsUInt32Number ProofingIntent,
- cmsUInt32Number dwFlags);
-
-CMSAPI cmsHTRANSFORM CMSEXPORT cmsCreateMultiprofileTransformTHR(cmsContext ContextID,
- cmsHPROFILE hProfiles[],
- cmsUInt32Number nProfiles,
- cmsUInt32Number InputFormat,
- cmsUInt32Number OutputFormat,
- cmsUInt32Number Intent,
- cmsUInt32Number dwFlags);
-
-
-CMSAPI cmsHTRANSFORM CMSEXPORT cmsCreateMultiprofileTransform(cmsHPROFILE hProfiles[],
- cmsUInt32Number nProfiles,
- cmsUInt32Number InputFormat,
- cmsUInt32Number OutputFormat,
- cmsUInt32Number Intent,
- cmsUInt32Number dwFlags);
-
-
-CMSAPI cmsHTRANSFORM CMSEXPORT cmsCreateExtendedTransform(cmsContext ContextID,
- cmsUInt32Number nProfiles, cmsHPROFILE hProfiles[],
- cmsBool BPC[],
- cmsUInt32Number Intents[],
- cmsFloat64Number AdaptationStates[],
- cmsHPROFILE hGamutProfile,
- cmsUInt32Number nGamutPCSposition,
- cmsUInt32Number InputFormat,
- cmsUInt32Number OutputFormat,
- cmsUInt32Number dwFlags);
-
-CMSAPI void CMSEXPORT cmsDeleteTransform(cmsHTRANSFORM hTransform);
-
-CMSAPI void CMSEXPORT cmsDoTransform(cmsHTRANSFORM Transform,
- const void * InputBuffer,
- void * OutputBuffer,
- cmsUInt32Number Size);
-
-CMSAPI void CMSEXPORT cmsDoTransformStride(cmsHTRANSFORM Transform, // Deprecated
- const void * InputBuffer,
- void * OutputBuffer,
- cmsUInt32Number Size,
- cmsUInt32Number Stride);
-
-CMSAPI void CMSEXPORT cmsDoTransformLineStride(cmsHTRANSFORM Transform,
- const void* InputBuffer,
- void* OutputBuffer,
- cmsUInt32Number PixelsPerLine,
- cmsUInt32Number LineCount,
- cmsUInt32Number BytesPerLineIn,
- cmsUInt32Number BytesPerLineOut,
- cmsUInt32Number BytesPerPlaneIn,
- cmsUInt32Number BytesPerPlaneOut);
-
-
-CMSAPI void CMSEXPORT cmsSetAlarmCodes(const cmsUInt16Number NewAlarm[cmsMAXCHANNELS]);
-CMSAPI void CMSEXPORT cmsGetAlarmCodes(cmsUInt16Number NewAlarm[cmsMAXCHANNELS]);
-
-
-CMSAPI void CMSEXPORT cmsSetAlarmCodesTHR(cmsContext ContextID,
- const cmsUInt16Number AlarmCodes[cmsMAXCHANNELS]);
-CMSAPI void CMSEXPORT cmsGetAlarmCodesTHR(cmsContext ContextID,
- cmsUInt16Number AlarmCodes[cmsMAXCHANNELS]);
-
-
-
-// Adaptation state for absolute colorimetric intent
-CMSAPI cmsFloat64Number CMSEXPORT cmsSetAdaptationState(cmsFloat64Number d);
-CMSAPI cmsFloat64Number CMSEXPORT cmsSetAdaptationStateTHR(cmsContext ContextID, cmsFloat64Number d);
-
-
-
-// Grab the ContextID from an open transform. Returns NULL if a NULL transform is passed
-CMSAPI cmsContext CMSEXPORT cmsGetTransformContextID(cmsHTRANSFORM hTransform);
-
-// Grab the input/output formats
-CMSAPI cmsUInt32Number CMSEXPORT cmsGetTransformInputFormat(cmsHTRANSFORM hTransform);
-CMSAPI cmsUInt32Number CMSEXPORT cmsGetTransformOutputFormat(cmsHTRANSFORM hTransform);
-
-// For backwards compatibility
-CMSAPI cmsBool CMSEXPORT cmsChangeBuffersFormat(cmsHTRANSFORM hTransform,
- cmsUInt32Number InputFormat,
- cmsUInt32Number OutputFormat);
-
-
-
-// PostScript ColorRenderingDictionary and ColorSpaceArray ----------------------------------------------------
-
-typedef enum { cmsPS_RESOURCE_CSA, cmsPS_RESOURCE_CRD } cmsPSResourceType;
-
-// lcms2 unified method to access postscript color resources
-CMSAPI cmsUInt32Number CMSEXPORT cmsGetPostScriptColorResource(cmsContext ContextID,
- cmsPSResourceType Type,
- cmsHPROFILE hProfile,
- cmsUInt32Number Intent,
- cmsUInt32Number dwFlags,
- cmsIOHANDLER* io);
-
-CMSAPI cmsUInt32Number CMSEXPORT cmsGetPostScriptCSA(cmsContext ContextID, cmsHPROFILE hProfile, cmsUInt32Number Intent, cmsUInt32Number dwFlags, void* Buffer, cmsUInt32Number dwBufferLen);
-CMSAPI cmsUInt32Number CMSEXPORT cmsGetPostScriptCRD(cmsContext ContextID, cmsHPROFILE hProfile, cmsUInt32Number Intent, cmsUInt32Number dwFlags, void* Buffer, cmsUInt32Number dwBufferLen);
-
-
-// IT8.7 / CGATS.17-200x handling -----------------------------------------------------------------------------
-
-CMSAPI cmsHANDLE CMSEXPORT cmsIT8Alloc(cmsContext ContextID);
-CMSAPI void CMSEXPORT cmsIT8Free(cmsHANDLE hIT8);
-
-// Tables
-CMSAPI cmsUInt32Number CMSEXPORT cmsIT8TableCount(cmsHANDLE hIT8);
-CMSAPI cmsInt32Number CMSEXPORT cmsIT8SetTable(cmsHANDLE hIT8, cmsUInt32Number nTable);
-
-// Persistence
-CMSAPI cmsHANDLE CMSEXPORT cmsIT8LoadFromFile(cmsContext ContextID, const char* cFileName);
-CMSAPI cmsHANDLE CMSEXPORT cmsIT8LoadFromMem(cmsContext ContextID, const void *Ptr, cmsUInt32Number len);
-// CMSAPI cmsHANDLE CMSEXPORT cmsIT8LoadFromIOhandler(cmsContext ContextID, cmsIOHANDLER* io);
-
-CMSAPI cmsBool CMSEXPORT cmsIT8SaveToFile(cmsHANDLE hIT8, const char* cFileName);
-CMSAPI cmsBool CMSEXPORT cmsIT8SaveToMem(cmsHANDLE hIT8, void *MemPtr, cmsUInt32Number* BytesNeeded);
-
-// Properties
-CMSAPI const char* CMSEXPORT cmsIT8GetSheetType(cmsHANDLE hIT8);
-CMSAPI cmsBool CMSEXPORT cmsIT8SetSheetType(cmsHANDLE hIT8, const char* Type);
-
-CMSAPI cmsBool CMSEXPORT cmsIT8SetComment(cmsHANDLE hIT8, const char* cComment);
-
-CMSAPI cmsBool CMSEXPORT cmsIT8SetPropertyStr(cmsHANDLE hIT8, const char* cProp, const char *Str);
-CMSAPI cmsBool CMSEXPORT cmsIT8SetPropertyDbl(cmsHANDLE hIT8, const char* cProp, cmsFloat64Number Val);
-CMSAPI cmsBool CMSEXPORT cmsIT8SetPropertyHex(cmsHANDLE hIT8, const char* cProp, cmsUInt32Number Val);
-CMSAPI cmsBool CMSEXPORT cmsIT8SetPropertyMulti(cmsHANDLE hIT8, const char* Key, const char* SubKey, const char *Buffer);
-CMSAPI cmsBool CMSEXPORT cmsIT8SetPropertyUncooked(cmsHANDLE hIT8, const char* Key, const char* Buffer);
-
-
-CMSAPI const char* CMSEXPORT cmsIT8GetProperty(cmsHANDLE hIT8, const char* cProp);
-CMSAPI cmsFloat64Number CMSEXPORT cmsIT8GetPropertyDbl(cmsHANDLE hIT8, const char* cProp);
-CMSAPI const char* CMSEXPORT cmsIT8GetPropertyMulti(cmsHANDLE hIT8, const char* Key, const char *SubKey);
-CMSAPI cmsUInt32Number CMSEXPORT cmsIT8EnumProperties(cmsHANDLE hIT8, char ***PropertyNames);
-CMSAPI cmsUInt32Number CMSEXPORT cmsIT8EnumPropertyMulti(cmsHANDLE hIT8, const char* cProp, const char ***SubpropertyNames);
-
-// Datasets
-CMSAPI const char* CMSEXPORT cmsIT8GetDataRowCol(cmsHANDLE hIT8, int row, int col);
-CMSAPI cmsFloat64Number CMSEXPORT cmsIT8GetDataRowColDbl(cmsHANDLE hIT8, int row, int col);
-
-CMSAPI cmsBool CMSEXPORT cmsIT8SetDataRowCol(cmsHANDLE hIT8, int row, int col,
- const char* Val);
-
-CMSAPI cmsBool CMSEXPORT cmsIT8SetDataRowColDbl(cmsHANDLE hIT8, int row, int col,
- cmsFloat64Number Val);
-
-CMSAPI const char* CMSEXPORT cmsIT8GetData(cmsHANDLE hIT8, const char* cPatch, const char* cSample);
-
-
-CMSAPI cmsFloat64Number CMSEXPORT cmsIT8GetDataDbl(cmsHANDLE hIT8, const char* cPatch, const char* cSample);
-
-CMSAPI cmsBool CMSEXPORT cmsIT8SetData(cmsHANDLE hIT8, const char* cPatch,
- const char* cSample,
- const char *Val);
-
-CMSAPI cmsBool CMSEXPORT cmsIT8SetDataDbl(cmsHANDLE hIT8, const char* cPatch,
- const char* cSample,
- cmsFloat64Number Val);
-
-CMSAPI int CMSEXPORT cmsIT8FindDataFormat(cmsHANDLE hIT8, const char* cSample);
-CMSAPI cmsBool CMSEXPORT cmsIT8SetDataFormat(cmsHANDLE hIT8, int n, const char *Sample);
-CMSAPI int CMSEXPORT cmsIT8EnumDataFormat(cmsHANDLE hIT8, char ***SampleNames);
-
-CMSAPI const char* CMSEXPORT cmsIT8GetPatchName(cmsHANDLE hIT8, int nPatch, char* buffer);
-CMSAPI int CMSEXPORT cmsIT8GetPatchByName(cmsHANDLE hIT8, const char *cPatch);
-
-// The LABEL extension
-CMSAPI int CMSEXPORT cmsIT8SetTableByLabel(cmsHANDLE hIT8, const char* cSet, const char* cField, const char* ExpectedType);
-
-CMSAPI cmsBool CMSEXPORT cmsIT8SetIndexColumn(cmsHANDLE hIT8, const char* cSample);
-
-// Formatter for double
-CMSAPI void CMSEXPORT cmsIT8DefineDblFormat(cmsHANDLE hIT8, const char* Formatter);
-
-// Gamut boundary description routines ------------------------------------------------------------------------------
-
-CMSAPI cmsHANDLE CMSEXPORT cmsGBDAlloc(cmsContext ContextID);
-CMSAPI void CMSEXPORT cmsGBDFree(cmsHANDLE hGBD);
-CMSAPI cmsBool CMSEXPORT cmsGDBAddPoint(cmsHANDLE hGBD, const cmsCIELab* Lab);
-CMSAPI cmsBool CMSEXPORT cmsGDBCompute(cmsHANDLE hGDB, cmsUInt32Number dwFlags);
-CMSAPI cmsBool CMSEXPORT cmsGDBCheckPoint(cmsHANDLE hGBD, const cmsCIELab* Lab);
-
-// Feature detection ----------------------------------------------------------------------------------------------
-
-// Estimate the black point
-CMSAPI cmsBool CMSEXPORT cmsDetectBlackPoint(cmsCIEXYZ* BlackPoint, cmsHPROFILE hProfile, cmsUInt32Number Intent, cmsUInt32Number dwFlags);
-CMSAPI cmsBool CMSEXPORT cmsDetectDestinationBlackPoint(cmsCIEXYZ* BlackPoint, cmsHPROFILE hProfile, cmsUInt32Number Intent, cmsUInt32Number dwFlags);
-
-// Estimate total area coverage
-CMSAPI cmsFloat64Number CMSEXPORT cmsDetectTAC(cmsHPROFILE hProfile);
-
-// Estimate gamma space, always positive. Returns -1 on error.
-CMSAPI cmsFloat64Number CMSEXPORT cmsDetectRGBProfileGamma(cmsHPROFILE hProfile, cmsFloat64Number threshold);
-
-// Poor man's gamut mapping
-CMSAPI cmsBool CMSEXPORT cmsDesaturateLab(cmsCIELab* Lab,
- double amax, double amin,
- double bmax, double bmin);
-
-#ifndef CMS_USE_CPP_API
-# ifdef __cplusplus
- }
-# endif
-#endif
-
-#define _lcms2_H
-#endif
diff --git a/contrib/libs/lcms2/include/lcms2_plugin.h b/contrib/libs/lcms2/include/lcms2_plugin.h
deleted file mode 100644
index d232af3df8..0000000000
--- a/contrib/libs/lcms2/include/lcms2_plugin.h
+++ /dev/null
@@ -1,700 +0,0 @@
-//---------------------------------------------------------------------------------
-//
-// Little Color Management System
-// Copyright (c) 1998-2023 Marti Maria Saguer
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//---------------------------------------------------------------------------------
-//
-// This is the plug-in header file. Normal LittleCMS clients should not use it.
-// It is provided for plug-in writers that may want to access the support
-// functions to do low level operations. All plug-in related structures
-// are defined here. Including this file forces to include the standard API too.
-
-#ifndef _lcms_plugin_H
-
-// Deal with Microsoft's attempt at deprecating C standard runtime functions
-#ifdef _MSC_VER
-# if (_MSC_VER >= 1400)
-# ifndef _CRT_SECURE_NO_DEPRECATE
-# define _CRT_SECURE_NO_DEPRECATE
-# endif
-# ifndef _CRT_SECURE_NO_WARNINGS
-# define _CRT_SECURE_NO_WARNINGS
-# endif
-# endif
-#endif
-
-#ifndef _lcms2_H
-#include "lcms2.h"
-#endif
-
-// We need some standard C functions.
-#include <stdlib.h>
-#include <math.h>
-#include <stdarg.h>
-#include <memory.h>
-#include <string.h>
-
-
-#ifndef CMS_USE_CPP_API
-# ifdef __cplusplus
-extern "C" {
-# endif
-#endif
-
-// Vector & Matrix operations -----------------------------------------------------------------------
-
-// Axis of the matrix/array. No specific meaning at all.
-#define VX 0
-#define VY 1
-#define VZ 2
-
-// Vectors
-typedef struct {
- cmsFloat64Number n[3];
-
- } cmsVEC3;
-
-// 3x3 Matrix
-typedef struct {
- cmsVEC3 v[3];
-
- } cmsMAT3;
-
-CMSAPI void CMSEXPORT _cmsVEC3init(cmsVEC3* r, cmsFloat64Number x, cmsFloat64Number y, cmsFloat64Number z);
-CMSAPI void CMSEXPORT _cmsVEC3minus(cmsVEC3* r, const cmsVEC3* a, const cmsVEC3* b);
-CMSAPI void CMSEXPORT _cmsVEC3cross(cmsVEC3* r, const cmsVEC3* u, const cmsVEC3* v);
-CMSAPI cmsFloat64Number CMSEXPORT _cmsVEC3dot(const cmsVEC3* u, const cmsVEC3* v);
-CMSAPI cmsFloat64Number CMSEXPORT _cmsVEC3length(const cmsVEC3* a);
-CMSAPI cmsFloat64Number CMSEXPORT _cmsVEC3distance(const cmsVEC3* a, const cmsVEC3* b);
-
-CMSAPI void CMSEXPORT _cmsMAT3identity(cmsMAT3* a);
-CMSAPI cmsBool CMSEXPORT _cmsMAT3isIdentity(const cmsMAT3* a);
-CMSAPI void CMSEXPORT _cmsMAT3per(cmsMAT3* r, const cmsMAT3* a, const cmsMAT3* b);
-CMSAPI cmsBool CMSEXPORT _cmsMAT3inverse(const cmsMAT3* a, cmsMAT3* b);
-CMSAPI cmsBool CMSEXPORT _cmsMAT3solve(cmsVEC3* x, cmsMAT3* a, cmsVEC3* b);
-CMSAPI void CMSEXPORT _cmsMAT3eval(cmsVEC3* r, const cmsMAT3* a, const cmsVEC3* v);
-
-
-// MD5 low level -------------------------------------------------------------------------------------
-
-CMSAPI cmsHANDLE CMSEXPORT cmsMD5alloc(cmsContext ContextID);
-CMSAPI void CMSEXPORT cmsMD5add(cmsHANDLE Handle, const cmsUInt8Number* buf, cmsUInt32Number len);
-CMSAPI void CMSEXPORT cmsMD5finish(cmsProfileID* ProfileID, cmsHANDLE Handle);
-
-// Error logging -------------------------------------------------------------------------------------
-
-CMSAPI void CMSEXPORT cmsSignalError(cmsContext ContextID, cmsUInt32Number ErrorCode, const char *ErrorText, ...);
-
-// Memory management ----------------------------------------------------------------------------------
-
-CMSAPI void* CMSEXPORT _cmsMalloc(cmsContext ContextID, cmsUInt32Number size);
-CMSAPI void* CMSEXPORT _cmsMallocZero(cmsContext ContextID, cmsUInt32Number size);
-CMSAPI void* CMSEXPORT _cmsCalloc(cmsContext ContextID, cmsUInt32Number num, cmsUInt32Number size);
-CMSAPI void* CMSEXPORT _cmsRealloc(cmsContext ContextID, void* Ptr, cmsUInt32Number NewSize);
-CMSAPI void CMSEXPORT _cmsFree(cmsContext ContextID, void* Ptr);
-CMSAPI void* CMSEXPORT _cmsDupMem(cmsContext ContextID, const void* Org, cmsUInt32Number size);
-
-// I/O handler ----------------------------------------------------------------------------------
-
-struct _cms_io_handler {
-
- void* stream; // Associated stream, which is implemented differently depending on media.
-
- cmsContext ContextID;
- cmsUInt32Number UsedSpace;
- cmsUInt32Number ReportedSize;
- char PhysicalFile[cmsMAX_PATH];
-
- cmsUInt32Number (* Read)(struct _cms_io_handler* iohandler, void *Buffer,
- cmsUInt32Number size,
- cmsUInt32Number count);
- cmsBool (* Seek)(struct _cms_io_handler* iohandler, cmsUInt32Number offset);
- cmsBool (* Close)(struct _cms_io_handler* iohandler);
- cmsUInt32Number (* Tell)(struct _cms_io_handler* iohandler);
- cmsBool (* Write)(struct _cms_io_handler* iohandler, cmsUInt32Number size,
- const void* Buffer);
-};
-
-// Endianness adjust functions
-CMSAPI cmsUInt16Number CMSEXPORT _cmsAdjustEndianess16(cmsUInt16Number Word);
-CMSAPI cmsUInt32Number CMSEXPORT _cmsAdjustEndianess32(cmsUInt32Number Value);
-CMSAPI void CMSEXPORT _cmsAdjustEndianess64(cmsUInt64Number* Result, cmsUInt64Number* QWord);
-
-// Helper IO functions
-CMSAPI cmsBool CMSEXPORT _cmsReadUInt8Number(cmsIOHANDLER* io, cmsUInt8Number* n);
-CMSAPI cmsBool CMSEXPORT _cmsReadUInt16Number(cmsIOHANDLER* io, cmsUInt16Number* n);
-CMSAPI cmsBool CMSEXPORT _cmsReadUInt32Number(cmsIOHANDLER* io, cmsUInt32Number* n);
-CMSAPI cmsBool CMSEXPORT _cmsReadFloat32Number(cmsIOHANDLER* io, cmsFloat32Number* n);
-CMSAPI cmsBool CMSEXPORT _cmsReadUInt64Number(cmsIOHANDLER* io, cmsUInt64Number* n);
-CMSAPI cmsBool CMSEXPORT _cmsRead15Fixed16Number(cmsIOHANDLER* io, cmsFloat64Number* n);
-CMSAPI cmsBool CMSEXPORT _cmsReadXYZNumber(cmsIOHANDLER* io, cmsCIEXYZ* XYZ);
-CMSAPI cmsBool CMSEXPORT _cmsReadUInt16Array(cmsIOHANDLER* io, cmsUInt32Number n, cmsUInt16Number* Array);
-
-CMSAPI cmsBool CMSEXPORT _cmsWriteUInt8Number(cmsIOHANDLER* io, cmsUInt8Number n);
-CMSAPI cmsBool CMSEXPORT _cmsWriteUInt16Number(cmsIOHANDLER* io, cmsUInt16Number n);
-CMSAPI cmsBool CMSEXPORT _cmsWriteUInt32Number(cmsIOHANDLER* io, cmsUInt32Number n);
-CMSAPI cmsBool CMSEXPORT _cmsWriteFloat32Number(cmsIOHANDLER* io, cmsFloat32Number n);
-CMSAPI cmsBool CMSEXPORT _cmsWriteUInt64Number(cmsIOHANDLER* io, cmsUInt64Number* n);
-CMSAPI cmsBool CMSEXPORT _cmsWrite15Fixed16Number(cmsIOHANDLER* io, cmsFloat64Number n);
-CMSAPI cmsBool CMSEXPORT _cmsWriteXYZNumber(cmsIOHANDLER* io, const cmsCIEXYZ* XYZ);
-CMSAPI cmsBool CMSEXPORT _cmsWriteUInt16Array(cmsIOHANDLER* io, cmsUInt32Number n, const cmsUInt16Number* Array);
-
-// ICC base tag
-typedef struct {
- cmsTagTypeSignature sig;
- cmsInt8Number reserved[4];
-
-} _cmsTagBase;
-
-// Type base helper functions
-CMSAPI cmsTagTypeSignature CMSEXPORT _cmsReadTypeBase(cmsIOHANDLER* io);
-CMSAPI cmsBool CMSEXPORT _cmsWriteTypeBase(cmsIOHANDLER* io, cmsTagTypeSignature sig);
-
-// Alignment functions
-CMSAPI cmsBool CMSEXPORT _cmsReadAlignment(cmsIOHANDLER* io);
-CMSAPI cmsBool CMSEXPORT _cmsWriteAlignment(cmsIOHANDLER* io);
-
-// To deal with text streams. 2K at most
-CMSAPI cmsBool CMSEXPORT _cmsIOPrintf(cmsIOHANDLER* io, const char* frm, ...);
-
-// Fixed point helper functions
-CMSAPI cmsFloat64Number CMSEXPORT _cms8Fixed8toDouble(cmsUInt16Number fixed8);
-CMSAPI cmsUInt16Number CMSEXPORT _cmsDoubleTo8Fixed8(cmsFloat64Number val);
-
-CMSAPI cmsFloat64Number CMSEXPORT _cms15Fixed16toDouble(cmsS15Fixed16Number fix32);
-CMSAPI cmsS15Fixed16Number CMSEXPORT _cmsDoubleTo15Fixed16(cmsFloat64Number v);
-
-// Date/time helper functions
-CMSAPI void CMSEXPORT _cmsEncodeDateTimeNumber(cmsDateTimeNumber *Dest, const struct tm *Source);
-CMSAPI void CMSEXPORT _cmsDecodeDateTimeNumber(const cmsDateTimeNumber *Source, struct tm *Dest);
-
-//----------------------------------------------------------------------------------------------------------
-
-// Shared callbacks for user data
-typedef void (* _cmsFreeUserDataFn)(cmsContext ContextID, void* Data);
-typedef void* (* _cmsDupUserDataFn)(cmsContext ContextID, const void* Data);
-
-//----------------------------------------------------------------------------------------------------------
-
-// Plug-in foundation
-#define cmsPluginMagicNumber 0x61637070 // 'acpp'
-
-#define cmsPluginMemHandlerSig 0x6D656D48 // 'memH'
-#define cmsPluginInterpolationSig 0x696E7048 // 'inpH'
-#define cmsPluginParametricCurveSig 0x70617248 // 'parH'
-#define cmsPluginFormattersSig 0x66726D48 // 'frmH
-#define cmsPluginTagTypeSig 0x74797048 // 'typH'
-#define cmsPluginTagSig 0x74616748 // 'tagH'
-#define cmsPluginRenderingIntentSig 0x696E7448 // 'intH'
-#define cmsPluginMultiProcessElementSig 0x6D706548 // 'mpeH'
-#define cmsPluginOptimizationSig 0x6F707448 // 'optH'
-#define cmsPluginTransformSig 0x7A666D48 // 'xfmH'
-#define cmsPluginMutexSig 0x6D747A48 // 'mtxH'
-#define cmsPluginParalellizationSig 0x70726C48 // 'prlH
-
-typedef struct _cmsPluginBaseStruct {
-
- cmsUInt32Number Magic; // 'acpp' signature
- cmsUInt32Number ExpectedVersion; // Expected version of LittleCMS
- cmsUInt32Number Type; // Type of plug-in
- struct _cmsPluginBaseStruct* Next; // For multiple plugin definition. NULL for end of list.
-
-} cmsPluginBase;
-
-// Maximum number of types in a plugin array
-#define MAX_TYPES_IN_LCMS_PLUGIN 20
-
-//----------------------------------------------------------------------------------------------------------
-
-// Memory handler. Each new plug-in type replaces current behaviour
-
-typedef void* (* _cmsMallocFnPtrType)(cmsContext ContextID, cmsUInt32Number size);
-typedef void (* _cmsFreeFnPtrType)(cmsContext ContextID, void *Ptr);
-typedef void* (* _cmsReallocFnPtrType)(cmsContext ContextID, void* Ptr, cmsUInt32Number NewSize);
-
-typedef void* (* _cmsMalloZerocFnPtrType)(cmsContext ContextID, cmsUInt32Number size);
-typedef void* (* _cmsCallocFnPtrType)(cmsContext ContextID, cmsUInt32Number num, cmsUInt32Number size);
-typedef void* (* _cmsDupFnPtrType)(cmsContext ContextID, const void* Org, cmsUInt32Number size);
-
-typedef struct {
-
- cmsPluginBase base;
-
- // Required
- _cmsMallocFnPtrType MallocPtr;
- _cmsFreeFnPtrType FreePtr;
- _cmsReallocFnPtrType ReallocPtr;
-
- // Optional
- _cmsMalloZerocFnPtrType MallocZeroPtr;
- _cmsCallocFnPtrType CallocPtr;
- _cmsDupFnPtrType DupPtr;
-
-} cmsPluginMemHandler;
-
-
-// ------------------------------------------------------------------------------------------------------------------
-
-// Interpolation. 16 bits and floating point versions.
-struct _cms_interp_struc;
-
-// Interpolation callbacks
-
-// 16 bits forward interpolation. This function performs precision-limited linear interpolation
-// and is supposed to be quite fast. Implementation may be tetrahedral or trilinear, and plug-ins may
-// choose to implement any other interpolation algorithm.
-typedef void (* _cmsInterpFn16)(CMSREGISTER const cmsUInt16Number Input[],
- CMSREGISTER cmsUInt16Number Output[],
- CMSREGISTER const struct _cms_interp_struc* p);
-
-// Floating point forward interpolation. Full precision interpolation using floats. This is not a
-// time critical function. Implementation may be tetrahedral or trilinear, and plug-ins may
-// choose to implement any other interpolation algorithm.
-typedef void (* _cmsInterpFnFloat)(cmsFloat32Number const Input[],
- cmsFloat32Number Output[],
- const struct _cms_interp_struc* p);
-
-
-
-// This type holds a pointer to an interpolator that can be either 16 bits or float
-typedef union {
- _cmsInterpFn16 Lerp16; // Forward interpolation in 16 bits
- _cmsInterpFnFloat LerpFloat; // Forward interpolation in floating point
-} cmsInterpFunction;
-
-// Flags for interpolator selection
-#define CMS_LERP_FLAGS_16BITS 0x0000 // The default
-#define CMS_LERP_FLAGS_FLOAT 0x0001 // Requires different implementation
-#define CMS_LERP_FLAGS_TRILINEAR 0x0100 // Hint only
-
-
-#define MAX_INPUT_DIMENSIONS 15
-
-typedef struct _cms_interp_struc { // Used on all interpolations. Supplied by lcms2 when calling the interpolation function
-
- cmsContext ContextID; // The calling thread
-
- cmsUInt32Number dwFlags; // Keep original flags
- cmsUInt32Number nInputs; // != 1 only in 3D interpolation
- cmsUInt32Number nOutputs; // != 1 only in 3D interpolation
-
- cmsUInt32Number nSamples[MAX_INPUT_DIMENSIONS]; // Valid on all kinds of tables
- cmsUInt32Number Domain[MAX_INPUT_DIMENSIONS]; // Domain = nSamples - 1
-
- cmsUInt32Number opta[MAX_INPUT_DIMENSIONS]; // Optimization for 3D CLUT. This is the number of nodes premultiplied for each
- // dimension. For example, in 7 nodes, 7, 7^2 , 7^3, 7^4, etc. On non-regular
- // Samplings may vary according of the number of nodes for each dimension.
-
- const void *Table; // Points to the actual interpolation table
- cmsInterpFunction Interpolation; // Points to the function to do the interpolation
-
- } cmsInterpParams;
-
-// Interpolators factory
-typedef cmsInterpFunction (* cmsInterpFnFactory)(cmsUInt32Number nInputChannels, cmsUInt32Number nOutputChannels, cmsUInt32Number dwFlags);
-
-// The plug-in
-typedef struct {
- cmsPluginBase base;
-
- // Points to a user-supplied function which implements the factory
- cmsInterpFnFactory InterpolatorsFactory;
-
-} cmsPluginInterpolation;
-
-//----------------------------------------------------------------------------------------------------------
-
-// Parametric curves. A negative type means same function but analytically inverted. Max. number of params is 10
-
-// Evaluator callback for user-supplied parametric curves. May implement more than one type
-typedef cmsFloat64Number (* cmsParametricCurveEvaluator)(cmsInt32Number Type, const cmsFloat64Number Params[10], cmsFloat64Number R);
-
-// Plug-in may implement an arbitrary number of parametric curves
-typedef struct {
- cmsPluginBase base;
-
- cmsUInt32Number nFunctions; // Number of supported functions
- cmsUInt32Number FunctionTypes[MAX_TYPES_IN_LCMS_PLUGIN]; // The identification types
- cmsUInt32Number ParameterCount[MAX_TYPES_IN_LCMS_PLUGIN]; // Number of parameters for each function
-
- cmsParametricCurveEvaluator Evaluator; // The evaluator
-
-} cmsPluginParametricCurves;
-//----------------------------------------------------------------------------------------------------------
-
-// Formatters. This plug-in adds new handlers, replacing them if they already exist. Formatters dealing with
-// cmsFloat32Number (bps = 4) or double (bps = 0) types are requested via FormatterFloat callback. Others come across
-// Formatter16 callback
-
-struct _cmstransform_struct;
-
-typedef cmsUInt8Number* (* cmsFormatter16)(CMSREGISTER struct _cmstransform_struct* CMMcargo,
- CMSREGISTER cmsUInt16Number Values[],
- CMSREGISTER cmsUInt8Number* Buffer,
- CMSREGISTER cmsUInt32Number Stride);
-
-typedef cmsUInt8Number* (* cmsFormatterFloat)(struct _cmstransform_struct* CMMcargo,
- cmsFloat32Number Values[],
- cmsUInt8Number* Buffer,
- cmsUInt32Number Stride);
-
-// This type holds a pointer to a formatter that can be either 16 bits or cmsFloat32Number
-typedef union {
- cmsFormatter16 Fmt16;
- cmsFormatterFloat FmtFloat;
-
-} cmsFormatter;
-
-#define CMS_PACK_FLAGS_16BITS 0x0000
-#define CMS_PACK_FLAGS_FLOAT 0x0001
-
-typedef enum { cmsFormatterInput=0, cmsFormatterOutput=1 } cmsFormatterDirection;
-
-typedef cmsFormatter (* cmsFormatterFactory)(cmsUInt32Number Type, // Specific type, i.e. TYPE_RGB_8
- cmsFormatterDirection Dir,
- cmsUInt32Number dwFlags); // precision
-
-// Plug-in may implement an arbitrary number of formatters
-typedef struct {
- cmsPluginBase base;
- cmsFormatterFactory FormattersFactory;
-
-} cmsPluginFormatters;
-
-//----------------------------------------------------------------------------------------------------------
-
-// Tag type handler. Each type is free to return anything it wants, and it is up to the caller to
-// know in advance what is the type contained in the tag.
-typedef struct _cms_typehandler_struct {
-
- cmsTagTypeSignature Signature; // The signature of the type
-
- // Allocates and reads items
- void * (* ReadPtr)(struct _cms_typehandler_struct* self,
- cmsIOHANDLER* io,
- cmsUInt32Number* nItems,
- cmsUInt32Number SizeOfTag);
-
- // Writes n Items
- cmsBool (* WritePtr)(struct _cms_typehandler_struct* self,
- cmsIOHANDLER* io,
- void* Ptr,
- cmsUInt32Number nItems);
-
- // Duplicate an item or array of items
- void* (* DupPtr)(struct _cms_typehandler_struct* self,
- const void *Ptr,
- cmsUInt32Number n);
-
- // Free all resources
- void (* FreePtr)(struct _cms_typehandler_struct* self,
- void *Ptr);
-
- // Additional parameters used by the calling thread
- cmsContext ContextID;
- cmsUInt32Number ICCVersion;
-
-} cmsTagTypeHandler;
-
-// Each plug-in implements a single type
-typedef struct {
- cmsPluginBase base;
- cmsTagTypeHandler Handler;
-
-} cmsPluginTagType;
-
-//----------------------------------------------------------------------------------------------------------
-
-// This is the tag plugin, which identifies tags. For writing, a pointer to function is provided.
-// This function should return the desired type for this tag, given the version of profile
-// and the data being serialized.
-typedef struct {
-
- cmsUInt32Number ElemCount; // If this tag needs an array, how many elements should keep
-
- // For reading.
- cmsUInt32Number nSupportedTypes; // In how many types this tag can come (MAX_TYPES_IN_LCMS_PLUGIN maximum)
- cmsTagTypeSignature SupportedTypes[MAX_TYPES_IN_LCMS_PLUGIN];
-
- // For writing
- cmsTagTypeSignature (* DecideType)(cmsFloat64Number ICCVersion, const void *Data);
-
-} cmsTagDescriptor;
-
-// Plug-in implements a single tag
-typedef struct {
- cmsPluginBase base;
-
- cmsTagSignature Signature;
- cmsTagDescriptor Descriptor;
-
-} cmsPluginTag;
-
-//----------------------------------------------------------------------------------------------------------
-
-// Custom intents. This function should join all profiles specified in the array in
-// a single LUT. Any custom intent in the chain redirects to custom function. If more than
-// one custom intent is found, the one located first is invoked. Usually users should use only one
-// custom intent, so mixing custom intents in same multiprofile transform is not supported.
-
-typedef cmsPipeline* (* cmsIntentFn)( cmsContext ContextID,
- cmsUInt32Number nProfiles,
- cmsUInt32Number Intents[],
- cmsHPROFILE hProfiles[],
- cmsBool BPC[],
- cmsFloat64Number AdaptationStates[],
- cmsUInt32Number dwFlags);
-
-
-// Each plug-in defines a single intent number.
-typedef struct {
- cmsPluginBase base;
- cmsUInt32Number Intent;
- cmsIntentFn Link;
- char Description[256];
-
-} cmsPluginRenderingIntent;
-
-
-// The default ICC intents (perceptual, saturation, rel.col and abs.col)
-CMSAPI cmsPipeline* CMSEXPORT _cmsDefaultICCintents(cmsContext ContextID,
- cmsUInt32Number nProfiles,
- cmsUInt32Number Intents[],
- cmsHPROFILE hProfiles[],
- cmsBool BPC[],
- cmsFloat64Number AdaptationStates[],
- cmsUInt32Number dwFlags);
-
-
-//----------------------------------------------------------------------------------------------------------
-
-// Pipelines, Multi Process Elements.
-
-typedef void (* _cmsStageEvalFn) (const cmsFloat32Number In[], cmsFloat32Number Out[], const cmsStage* mpe);
-typedef void*(* _cmsStageDupElemFn) (cmsStage* mpe);
-typedef void (* _cmsStageFreeElemFn) (cmsStage* mpe);
-
-
-// This function allocates a generic MPE
-CMSAPI cmsStage* CMSEXPORT _cmsStageAllocPlaceholder(cmsContext ContextID,
- cmsStageSignature Type,
- cmsUInt32Number InputChannels,
- cmsUInt32Number OutputChannels,
- _cmsStageEvalFn EvalPtr, // Points to fn that evaluates the element (always in floating point)
- _cmsStageDupElemFn DupElemPtr, // Points to a fn that duplicates the stage
- _cmsStageFreeElemFn FreePtr, // Points to a fn that sets the element free
- void* Data); // A generic pointer to whatever memory needed by the element
-typedef struct {
- cmsPluginBase base;
- cmsTagTypeHandler Handler;
-
-} cmsPluginMultiProcessElement;
-
-
-// Data kept in "Element" member of cmsStage
-
-// Curves
-typedef struct {
- cmsUInt32Number nCurves;
- cmsToneCurve** TheCurves;
-
-} _cmsStageToneCurvesData;
-
-// Matrix
-typedef struct {
- cmsFloat64Number* Double; // floating point for the matrix
- cmsFloat64Number* Offset; // The offset
-
-} _cmsStageMatrixData;
-
-// CLUT
-typedef struct {
-
- union { // Can have only one of both representations at same time
- cmsUInt16Number* T; // Points to the table 16 bits table
- cmsFloat32Number* TFloat; // Points to the cmsFloat32Number table
-
- } Tab;
-
- cmsInterpParams* Params;
- cmsUInt32Number nEntries;
- cmsBool HasFloatValues;
-
-} _cmsStageCLutData;
-
-
-//----------------------------------------------------------------------------------------------------------
-// Optimization. Using this plug-in, additional optimization strategies may be implemented.
-// The function should return TRUE if any optimization is done on the LUT, this terminates
-// the optimization search. Or FALSE if it is unable to optimize and want to give a chance
-// to the rest of optimizers.
-
-typedef cmsBool (* _cmsOPToptimizeFn)(cmsPipeline** Lut,
- cmsUInt32Number Intent,
- cmsUInt32Number* InputFormat,
- cmsUInt32Number* OutputFormat,
- cmsUInt32Number* dwFlags);
-
-// Pipeline Evaluator (in 16 bits)
-typedef void (* _cmsPipelineEval16Fn)(CMSREGISTER const cmsUInt16Number In[],
- CMSREGISTER cmsUInt16Number Out[],
- const void* Data);
-
-// Pipeline Evaluator (in floating point)
-typedef void (* _cmsPipelineEvalFloatFn)(const cmsFloat32Number In[],
- cmsFloat32Number Out[],
- const void* Data);
-
-
-// This function may be used to set the optional evaluator and a block of private data. If private data is being used, an optional
-// duplicator and free functions should also be specified in order to duplicate the LUT construct. Use NULL to inhibit such functionality.
-
-CMSAPI void CMSEXPORT _cmsPipelineSetOptimizationParameters(cmsPipeline* Lut,
- _cmsPipelineEval16Fn Eval16,
- void* PrivateData,
- _cmsFreeUserDataFn FreePrivateDataFn,
- _cmsDupUserDataFn DupPrivateDataFn);
-
-typedef struct {
- cmsPluginBase base;
-
- // Optimize entry point
- _cmsOPToptimizeFn OptimizePtr;
-
-} cmsPluginOptimization;
-
-//----------------------------------------------------------------------------------------------------------
-// Full xform
-
-typedef struct {
- cmsUInt32Number BytesPerLineIn;
- cmsUInt32Number BytesPerLineOut;
- cmsUInt32Number BytesPerPlaneIn;
- cmsUInt32Number BytesPerPlaneOut;
-
-} cmsStride;
-
-typedef void (* _cmsTransformFn)(struct _cmstransform_struct *CMMcargo, // Legacy function, handles just ONE scanline.
- const void* InputBuffer,
- void* OutputBuffer,
- cmsUInt32Number Size,
- cmsUInt32Number Stride); // Stride in bytes to the next plane in planar formats
-
-
-typedef void (*_cmsTransform2Fn)(struct _cmstransform_struct *CMMcargo,
- const void* InputBuffer,
- void* OutputBuffer,
- cmsUInt32Number PixelsPerLine,
- cmsUInt32Number LineCount,
- const cmsStride* Stride);
-
-typedef cmsBool (* _cmsTransformFactory)(_cmsTransformFn* xform,
- void** UserData,
- _cmsFreeUserDataFn* FreePrivateDataFn,
- cmsPipeline** Lut,
- cmsUInt32Number* InputFormat,
- cmsUInt32Number* OutputFormat,
- cmsUInt32Number* dwFlags);
-
-typedef cmsBool (* _cmsTransform2Factory)(_cmsTransform2Fn* xform,
- void** UserData,
- _cmsFreeUserDataFn* FreePrivateDataFn,
- cmsPipeline** Lut,
- cmsUInt32Number* InputFormat,
- cmsUInt32Number* OutputFormat,
- cmsUInt32Number* dwFlags);
-
-
-// Retrieve user data as specified by the factory
-CMSAPI void CMSEXPORT _cmsSetTransformUserData(struct _cmstransform_struct *CMMcargo, void* ptr, _cmsFreeUserDataFn FreePrivateDataFn);
-CMSAPI void * CMSEXPORT _cmsGetTransformUserData(struct _cmstransform_struct *CMMcargo);
-
-
-// Retrieve formatters
-CMSAPI void CMSEXPORT _cmsGetTransformFormatters16 (struct _cmstransform_struct *CMMcargo, cmsFormatter16* FromInput, cmsFormatter16* ToOutput);
-CMSAPI void CMSEXPORT _cmsGetTransformFormattersFloat(struct _cmstransform_struct *CMMcargo, cmsFormatterFloat* FromInput, cmsFormatterFloat* ToOutput);
-
-// Retrieve original flags
-CMSAPI cmsUInt32Number CMSEXPORT _cmsGetTransformFlags(struct _cmstransform_struct* CMMcargo);
-
-typedef struct {
- cmsPluginBase base;
-
- // Transform entry point
- union {
- _cmsTransformFactory legacy_xform;
- _cmsTransform2Factory xform;
- } factories;
-
-} cmsPluginTransform;
-
-//----------------------------------------------------------------------------------------------------------
-// Mutex
-
-typedef void* (* _cmsCreateMutexFnPtrType)(cmsContext ContextID);
-typedef void (* _cmsDestroyMutexFnPtrType)(cmsContext ContextID, void* mtx);
-typedef cmsBool (* _cmsLockMutexFnPtrType)(cmsContext ContextID, void* mtx);
-typedef void (* _cmsUnlockMutexFnPtrType)(cmsContext ContextID, void* mtx);
-
-typedef struct {
- cmsPluginBase base;
-
- _cmsCreateMutexFnPtrType CreateMutexPtr;
- _cmsDestroyMutexFnPtrType DestroyMutexPtr;
- _cmsLockMutexFnPtrType LockMutexPtr;
- _cmsUnlockMutexFnPtrType UnlockMutexPtr;
-
-} cmsPluginMutex;
-
-CMSAPI void* CMSEXPORT _cmsCreateMutex(cmsContext ContextID);
-CMSAPI void CMSEXPORT _cmsDestroyMutex(cmsContext ContextID, void* mtx);
-CMSAPI cmsBool CMSEXPORT _cmsLockMutex(cmsContext ContextID, void* mtx);
-CMSAPI void CMSEXPORT _cmsUnlockMutex(cmsContext ContextID, void* mtx);
-
-//----------------------------------------------------------------------------------------------------------
-// Parallelization
-
-CMSAPI _cmsTransform2Fn CMSEXPORT _cmsGetTransformWorker(struct _cmstransform_struct* CMMcargo);
-CMSAPI cmsInt32Number CMSEXPORT _cmsGetTransformMaxWorkers(struct _cmstransform_struct* CMMcargo);
-CMSAPI cmsUInt32Number CMSEXPORT _cmsGetTransformWorkerFlags(struct _cmstransform_struct* CMMcargo);
-
-// Let's plug-in to guess the best number of workers
-#define CMS_GUESS_MAX_WORKERS -1
-
-typedef struct {
- cmsPluginBase base;
-
- cmsInt32Number MaxWorkers; // Number of starts to do as maximum
- cmsUInt32Number WorkerFlags; // Reserved
- _cmsTransform2Fn SchedulerFn; // callback to setup functions
-
-} cmsPluginParalellization;
-
-
-#ifndef CMS_USE_CPP_API
-# ifdef __cplusplus
- }
-# endif
-#endif
-
-#define _lcms_plugin_H
-#endif
diff --git a/contrib/libs/lcms2/patches/register.patch b/contrib/libs/lcms2/patches/register.patch
deleted file mode 100644
index 007134c74c..0000000000
--- a/contrib/libs/lcms2/patches/register.patch
+++ /dev/null
@@ -1,5 +0,0 @@
---- a/include/lcms2.h (index)
-+++ b/include/lcms2.h (working tree)
-@@ -62,1 +62,1 @@
--// #define CMS_NO_REGISTER_KEYWORD 1
-+#define CMS_NO_REGISTER_KEYWORD 1
diff --git a/contrib/libs/lcms2/src/cmsalpha.c b/contrib/libs/lcms2/src/cmsalpha.c
deleted file mode 100644
index 7422256ca3..0000000000
--- a/contrib/libs/lcms2/src/cmsalpha.c
+++ /dev/null
@@ -1,650 +0,0 @@
-//---------------------------------------------------------------------------------
-//
-// Little Color Management System
-// Copyright (c) 1998-2023 Marti Maria Saguer
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//---------------------------------------------------------------------------------
-//
-
-#include "lcms2_internal.h"
-
-// Alpha copy ------------------------------------------------------------------------------------------------------------------
-
-// This macro return words stored as big endian
-#define CHANGE_ENDIAN(w) (cmsUInt16Number) ((cmsUInt16Number) ((w)<<8)|((w)>>8))
-
-
-// Floor to byte, taking care of saturation
-cmsINLINE cmsUInt8Number _cmsQuickSaturateByte(cmsFloat64Number d)
-{
- d += 0.5;
- if (d <= 0) return 0;
- if (d >= 255.0) return 255;
-
- return (cmsUInt8Number) _cmsQuickFloorWord(d);
-}
-
-
-// Return the size in bytes of a given formatter
-static
-cmsUInt32Number trueBytesSize(cmsUInt32Number Format)
-{
- cmsUInt32Number fmt_bytes = T_BYTES(Format);
-
- // For double, the T_BYTES field returns zero
- if (fmt_bytes == 0)
- return sizeof(double);
-
- // Otherwise, it is already correct for all formats
- return fmt_bytes;
-}
-
-
-// Several format converters
-
-typedef void(*cmsFormatterAlphaFn)(void* dst, const void* src);
-
-
-// From 8
-
-static
-void copy8(void* dst, const void* src)
-{
- memmove(dst, src, 1);
-}
-
-static
-void from8to16(void* dst, const void* src)
-{
- cmsUInt8Number n = *(cmsUInt8Number*)src;
- *(cmsUInt16Number*) dst = (cmsUInt16Number) FROM_8_TO_16(n);
-}
-
-static
-void from8to16SE(void* dst, const void* src)
-{
- cmsUInt8Number n = *(cmsUInt8Number*)src;
- *(cmsUInt16Number*)dst = CHANGE_ENDIAN(FROM_8_TO_16(n));
-}
-
-static
-void from8toFLT(void* dst, const void* src)
-{
- *(cmsFloat32Number*)dst = (cmsFloat32Number) (*(cmsUInt8Number*)src) / 255.0f;
-}
-
-static
-void from8toDBL(void* dst, const void* src)
-{
- *(cmsFloat64Number*)dst = (cmsFloat64Number) (*(cmsUInt8Number*)src) / 255.0;
-}
-
-static
-void from8toHLF(void* dst, const void* src)
-{
-#ifndef CMS_NO_HALF_SUPPORT
- cmsFloat32Number n = (*(cmsUInt8Number*)src) / 255.0f;
- *(cmsUInt16Number*)dst = _cmsFloat2Half(n);
-#else
- cmsUNUSED_PARAMETER(dst);
- cmsUNUSED_PARAMETER(src);
-#endif
-}
-
-// From 16
-
-static
-void from16to8(void* dst, const void* src)
-{
- cmsUInt16Number n = *(cmsUInt16Number*)src;
- *(cmsUInt8Number*) dst = FROM_16_TO_8(n);
-}
-
-static
-void from16SEto8(void* dst, const void* src)
-{
- cmsUInt16Number n = *(cmsUInt16Number*)src;
- *(cmsUInt8Number*)dst = FROM_16_TO_8(CHANGE_ENDIAN(n));
-}
-
-static
-void copy16(void* dst, const void* src)
-{
- memmove(dst, src, 2);
-}
-
-static
-void from16to16(void* dst, const void* src)
-{
- cmsUInt16Number n = *(cmsUInt16Number*)src;
- *(cmsUInt16Number*)dst = CHANGE_ENDIAN(n);
-}
-
-static
-void from16toFLT(void* dst, const void* src)
-{
- *(cmsFloat32Number*)dst = (*(cmsUInt16Number*)src) / 65535.0f;
-}
-
-static
-void from16SEtoFLT(void* dst, const void* src)
-{
- *(cmsFloat32Number*)dst = (CHANGE_ENDIAN(*(cmsUInt16Number*)src)) / 65535.0f;
-}
-
-static
-void from16toDBL(void* dst, const void* src)
-{
- *(cmsFloat64Number*)dst = (cmsFloat64Number) (*(cmsUInt16Number*)src) / 65535.0;
-}
-
-static
-void from16SEtoDBL(void* dst, const void* src)
-{
- *(cmsFloat64Number*)dst = (cmsFloat64Number) (CHANGE_ENDIAN(*(cmsUInt16Number*)src)) / 65535.0;
-}
-
-static
-void from16toHLF(void* dst, const void* src)
-{
-#ifndef CMS_NO_HALF_SUPPORT
- cmsFloat32Number n = (*(cmsUInt16Number*)src) / 65535.0f;
- *(cmsUInt16Number*)dst = _cmsFloat2Half(n);
-#else
- cmsUNUSED_PARAMETER(dst);
- cmsUNUSED_PARAMETER(src);
-#endif
-}
-
-static
-void from16SEtoHLF(void* dst, const void* src)
-{
-#ifndef CMS_NO_HALF_SUPPORT
- cmsFloat32Number n = (CHANGE_ENDIAN(*(cmsUInt16Number*)src)) / 65535.0f;
- *(cmsUInt16Number*)dst = _cmsFloat2Half(n);
-#else
- cmsUNUSED_PARAMETER(dst);
- cmsUNUSED_PARAMETER(src);
-#endif
-}
-// From Float
-
-static
-void fromFLTto8(void* dst, const void* src)
-{
- cmsFloat32Number n = *(cmsFloat32Number*)src;
- *(cmsUInt8Number*)dst = _cmsQuickSaturateByte(n * 255.0);
-}
-
-static
-void fromFLTto16(void* dst, const void* src)
-{
- cmsFloat32Number n = *(cmsFloat32Number*)src;
- *(cmsUInt16Number*)dst = _cmsQuickSaturateWord(n * 65535.0);
-}
-
-static
-void fromFLTto16SE(void* dst, const void* src)
-{
- cmsFloat32Number n = *(cmsFloat32Number*)src;
- cmsUInt16Number i = _cmsQuickSaturateWord(n * 65535.0);
-
- *(cmsUInt16Number*)dst = CHANGE_ENDIAN(i);
-}
-
-static
-void copy32(void* dst, const void* src)
-{
- memmove(dst, src, sizeof(cmsFloat32Number));
-}
-
-static
-void fromFLTtoDBL(void* dst, const void* src)
-{
- cmsFloat32Number n = *(cmsFloat32Number*)src;
- *(cmsFloat64Number*)dst = (cmsFloat64Number)n;
-}
-
-static
-void fromFLTtoHLF(void* dst, const void* src)
-{
-#ifndef CMS_NO_HALF_SUPPORT
- cmsFloat32Number n = *(cmsFloat32Number*)src;
- *(cmsUInt16Number*)dst = _cmsFloat2Half(n);
-#else
- cmsUNUSED_PARAMETER(dst);
- cmsUNUSED_PARAMETER(src);
-#endif
-}
-
-
-// From HALF
-
-static
-void fromHLFto8(void* dst, const void* src)
-{
-#ifndef CMS_NO_HALF_SUPPORT
- cmsFloat32Number n = _cmsHalf2Float(*(cmsUInt16Number*)src);
- *(cmsUInt8Number*)dst = _cmsQuickSaturateByte(n * 255.0);
-#else
- cmsUNUSED_PARAMETER(dst);
- cmsUNUSED_PARAMETER(src);
-#endif
-
-}
-
-static
-void fromHLFto16(void* dst, const void* src)
-{
-#ifndef CMS_NO_HALF_SUPPORT
- cmsFloat32Number n = _cmsHalf2Float(*(cmsUInt16Number*)src);
- *(cmsUInt16Number*)dst = _cmsQuickSaturateWord(n * 65535.0);
-#else
- cmsUNUSED_PARAMETER(dst);
- cmsUNUSED_PARAMETER(src);
-#endif
-}
-
-static
-void fromHLFto16SE(void* dst, const void* src)
-{
-#ifndef CMS_NO_HALF_SUPPORT
- cmsFloat32Number n = _cmsHalf2Float(*(cmsUInt16Number*)src);
- cmsUInt16Number i = _cmsQuickSaturateWord(n * 65535.0);
- *(cmsUInt16Number*)dst = CHANGE_ENDIAN(i);
-#else
- cmsUNUSED_PARAMETER(dst);
- cmsUNUSED_PARAMETER(src);
-#endif
-}
-
-static
-void fromHLFtoFLT(void* dst, const void* src)
-{
-#ifndef CMS_NO_HALF_SUPPORT
- *(cmsFloat32Number*)dst = _cmsHalf2Float(*(cmsUInt16Number*)src);
-#else
- cmsUNUSED_PARAMETER(dst);
- cmsUNUSED_PARAMETER(src);
-#endif
-}
-
-static
-void fromHLFtoDBL(void* dst, const void* src)
-{
-#ifndef CMS_NO_HALF_SUPPORT
- *(cmsFloat64Number*)dst = (cmsFloat64Number)_cmsHalf2Float(*(cmsUInt16Number*)src);
-#else
- cmsUNUSED_PARAMETER(dst);
- cmsUNUSED_PARAMETER(src);
-#endif
-}
-
-// From double
-static
-void fromDBLto8(void* dst, const void* src)
-{
- cmsFloat64Number n = *(cmsFloat64Number*)src;
- *(cmsUInt8Number*)dst = _cmsQuickSaturateByte(n * 255.0);
-}
-
-static
-void fromDBLto16(void* dst, const void* src)
-{
- cmsFloat64Number n = *(cmsFloat64Number*)src;
- *(cmsUInt16Number*)dst = _cmsQuickSaturateWord(n * 65535.0f);
-}
-
-static
-void fromDBLto16SE(void* dst, const void* src)
-{
- cmsFloat64Number n = *(cmsFloat64Number*)src;
- cmsUInt16Number i = _cmsQuickSaturateWord(n * 65535.0f);
- *(cmsUInt16Number*)dst = CHANGE_ENDIAN(i);
-}
-
-static
-void fromDBLtoFLT(void* dst, const void* src)
-{
- cmsFloat64Number n = *(cmsFloat64Number*)src;
- *(cmsFloat32Number*)dst = (cmsFloat32Number) n;
-}
-
-static
-void fromDBLtoHLF(void* dst, const void* src)
-{
-#ifndef CMS_NO_HALF_SUPPORT
- cmsFloat32Number n = (cmsFloat32Number) *(cmsFloat64Number*)src;
- *(cmsUInt16Number*)dst = _cmsFloat2Half(n);
-#else
- cmsUNUSED_PARAMETER(dst);
- cmsUNUSED_PARAMETER(src);
-#endif
-}
-
-static
-void copy64(void* dst, const void* src)
-{
- memmove(dst, src, sizeof(cmsFloat64Number));
-}
-
-
-// Returns the position (x or y) of the formatter in the table of functions
-static
-int FormatterPos(cmsUInt32Number frm)
-{
- cmsUInt32Number b = T_BYTES(frm);
-
- if (b == 0 && T_FLOAT(frm))
- return 5; // DBL
-#ifndef CMS_NO_HALF_SUPPORT
- if (b == 2 && T_FLOAT(frm))
- return 3; // HLF
-#endif
- if (b == 4 && T_FLOAT(frm))
- return 4; // FLT
- if (b == 2 && !T_FLOAT(frm))
- {
- if (T_ENDIAN16(frm))
- return 2; // 16SE
- else
- return 1; // 16
- }
- if (b == 1 && !T_FLOAT(frm))
- return 0; // 8
- return -1; // not recognized
-}
-
-// Obtains an alpha-to-alpha function formatter
-static
-cmsFormatterAlphaFn _cmsGetFormatterAlpha(cmsContext id, cmsUInt32Number in, cmsUInt32Number out)
-{
-static cmsFormatterAlphaFn FormattersAlpha[6][6] = {
-
- /* from 8 */ { copy8, from8to16, from8to16SE, from8toHLF, from8toFLT, from8toDBL },
- /* from 16*/ { from16to8, copy16, from16to16, from16toHLF, from16toFLT, from16toDBL },
- /* from 16SE*/{ from16SEto8, from16to16, copy16, from16SEtoHLF,from16SEtoFLT, from16SEtoDBL },
- /* from HLF*/ { fromHLFto8, fromHLFto16, fromHLFto16SE, copy16, fromHLFtoFLT, fromHLFtoDBL },
- /* from FLT*/ { fromFLTto8, fromFLTto16, fromFLTto16SE, fromFLTtoHLF, copy32, fromFLTtoDBL },
- /* from DBL*/ { fromDBLto8, fromDBLto16, fromDBLto16SE, fromDBLtoHLF, fromDBLtoFLT, copy64 }};
-
- int in_n = FormatterPos(in);
- int out_n = FormatterPos(out);
-
- if (in_n < 0 || out_n < 0 || in_n > 5 || out_n > 5) {
-
- cmsSignalError(id, cmsERROR_UNKNOWN_EXTENSION, "Unrecognized alpha channel width");
- return NULL;
- }
-
- return FormattersAlpha[in_n][out_n];
-}
-
-
-
-// This function computes the distance from each component to the next one in bytes.
-static
-cmsBool ComputeIncrementsForChunky(cmsUInt32Number Format,
- cmsUInt32Number ComponentStartingOrder[],
- cmsUInt32Number ComponentPointerIncrements[])
-{
- cmsUInt32Number channels[cmsMAXCHANNELS];
- cmsUInt32Number extra = T_EXTRA(Format);
- cmsUInt32Number nchannels = T_CHANNELS(Format);
- cmsUInt32Number total_chans = nchannels + extra;
- cmsUInt32Number i;
- cmsUInt32Number channelSize = trueBytesSize(Format);
- cmsUInt32Number pixelSize = channelSize * total_chans;
-
- // Sanity check
- if (total_chans <= 0 || total_chans >= cmsMAXCHANNELS)
- return FALSE;
-
- memset(channels, 0, sizeof(channels));
-
- // Separation is independent of starting point and only depends on channel size
- for (i = 0; i < extra; i++)
- ComponentPointerIncrements[i] = pixelSize;
-
- // Handle do swap
- for (i = 0; i < total_chans; i++)
- {
- if (T_DOSWAP(Format)) {
- channels[i] = total_chans - i - 1;
- }
- else {
- channels[i] = i;
- }
- }
-
- // Handle swap first (ROL of positions), example CMYK -> KCMY | 0123 -> 3012
- if (T_SWAPFIRST(Format) && total_chans > 1) {
-
- cmsUInt32Number tmp = channels[0];
- for (i = 0; i < total_chans-1; i++)
- channels[i] = channels[i + 1];
-
- channels[total_chans - 1] = tmp;
- }
-
- // Handle size
- if (channelSize > 1)
- for (i = 0; i < total_chans; i++) {
- channels[i] *= channelSize;
- }
-
- for (i = 0; i < extra; i++)
- ComponentStartingOrder[i] = channels[i + nchannels];
-
- return TRUE;
-}
-
-
-
-// On planar configurations, the distance is the stride added to any non-negative
-static
-cmsBool ComputeIncrementsForPlanar(cmsUInt32Number Format,
- cmsUInt32Number BytesPerPlane,
- cmsUInt32Number ComponentStartingOrder[],
- cmsUInt32Number ComponentPointerIncrements[])
-{
- cmsUInt32Number channels[cmsMAXCHANNELS];
- cmsUInt32Number extra = T_EXTRA(Format);
- cmsUInt32Number nchannels = T_CHANNELS(Format);
- cmsUInt32Number total_chans = nchannels + extra;
- cmsUInt32Number i;
- cmsUInt32Number channelSize = trueBytesSize(Format);
-
- // Sanity check
- if (total_chans <= 0 || total_chans >= cmsMAXCHANNELS)
- return FALSE;
-
- memset(channels, 0, sizeof(channels));
-
- // Separation is independent of starting point and only depends on channel size
- for (i = 0; i < extra; i++)
- ComponentPointerIncrements[i] = channelSize;
-
- // Handle do swap
- for (i = 0; i < total_chans; i++)
- {
- if (T_DOSWAP(Format)) {
- channels[i] = total_chans - i - 1;
- }
- else {
- channels[i] = i;
- }
- }
-
- // Handle swap first (ROL of positions), example CMYK -> KCMY | 0123 -> 3012
- if (T_SWAPFIRST(Format) && total_chans > 0) {
-
- cmsUInt32Number tmp = channels[0];
- for (i = 0; i < total_chans - 1; i++)
- channels[i] = channels[i + 1];
-
- channels[total_chans - 1] = tmp;
- }
-
- // Handle size
- for (i = 0; i < total_chans; i++) {
- channels[i] *= BytesPerPlane;
- }
-
- for (i = 0; i < extra; i++)
- ComponentStartingOrder[i] = channels[i + nchannels];
-
- return TRUE;
-}
-
-
-
-// Dispatcher por chunky and planar RGB
-static
-cmsBool ComputeComponentIncrements(cmsUInt32Number Format,
- cmsUInt32Number BytesPerPlane,
- cmsUInt32Number ComponentStartingOrder[],
- cmsUInt32Number ComponentPointerIncrements[])
-{
- if (T_PLANAR(Format)) {
-
- return ComputeIncrementsForPlanar(Format, BytesPerPlane, ComponentStartingOrder, ComponentPointerIncrements);
- }
- else {
- return ComputeIncrementsForChunky(Format, ComponentStartingOrder, ComponentPointerIncrements);
- }
-
-}
-
-// Handles extra channels copying alpha if requested by the flags
-void _cmsHandleExtraChannels(_cmsTRANSFORM* p, const void* in,
- void* out,
- cmsUInt32Number PixelsPerLine,
- cmsUInt32Number LineCount,
- const cmsStride* Stride)
-{
- cmsUInt32Number i, j, k;
- cmsUInt32Number nExtra;
- cmsUInt32Number SourceStartingOrder[cmsMAXCHANNELS];
- cmsUInt32Number SourceIncrements[cmsMAXCHANNELS];
- cmsUInt32Number DestStartingOrder[cmsMAXCHANNELS];
- cmsUInt32Number DestIncrements[cmsMAXCHANNELS];
-
- cmsFormatterAlphaFn copyValueFn;
-
- // Make sure we need some copy
- if (!(p->dwOriginalFlags & cmsFLAGS_COPY_ALPHA))
- return;
-
- // Exit early if in-place color-management is occurring - no need to copy extra channels to themselves.
- if (p->InputFormat == p->OutputFormat && in == out)
- return;
-
- // Make sure we have same number of alpha channels. If not, just return as this should be checked at transform creation time.
- nExtra = T_EXTRA(p->InputFormat);
- if (nExtra != T_EXTRA(p->OutputFormat))
- return;
-
- // Anything to do?
- if (nExtra == 0)
- return;
-
- // Compute the increments
- if (!ComputeComponentIncrements(p->InputFormat, Stride->BytesPerPlaneIn, SourceStartingOrder, SourceIncrements))
- return;
- if (!ComputeComponentIncrements(p->OutputFormat, Stride->BytesPerPlaneOut, DestStartingOrder, DestIncrements))
- return;
-
- // Check for conversions 8, 16, half, float, dbl
- copyValueFn = _cmsGetFormatterAlpha(p->ContextID, p->InputFormat, p->OutputFormat);
- if (copyValueFn == NULL)
- return;
-
- if (nExtra == 1) { // Optimized routine for copying a single extra channel quickly
-
- cmsUInt8Number* SourcePtr;
- cmsUInt8Number* DestPtr;
-
- cmsUInt32Number SourceStrideIncrement = 0;
- cmsUInt32Number DestStrideIncrement = 0;
-
- // The loop itself
- for (i = 0; i < LineCount; i++) {
-
- // Prepare pointers for the loop
- SourcePtr = (cmsUInt8Number*)in + SourceStartingOrder[0] + SourceStrideIncrement;
- DestPtr = (cmsUInt8Number*)out + DestStartingOrder[0] + DestStrideIncrement;
-
- for (j = 0; j < PixelsPerLine; j++) {
-
- copyValueFn(DestPtr, SourcePtr);
-
- SourcePtr += SourceIncrements[0];
- DestPtr += DestIncrements[0];
- }
-
- SourceStrideIncrement += Stride->BytesPerLineIn;
- DestStrideIncrement += Stride->BytesPerLineOut;
- }
-
- }
- else { // General case with more than one extra channel
-
- cmsUInt8Number* SourcePtr[cmsMAXCHANNELS];
- cmsUInt8Number* DestPtr[cmsMAXCHANNELS];
-
- cmsUInt32Number SourceStrideIncrements[cmsMAXCHANNELS];
- cmsUInt32Number DestStrideIncrements[cmsMAXCHANNELS];
-
- memset(SourceStrideIncrements, 0, sizeof(SourceStrideIncrements));
- memset(DestStrideIncrements, 0, sizeof(DestStrideIncrements));
-
- // The loop itself
- for (i = 0; i < LineCount; i++) {
-
- // Prepare pointers for the loop
- for (j = 0; j < nExtra; j++) {
-
- SourcePtr[j] = (cmsUInt8Number*)in + SourceStartingOrder[j] + SourceStrideIncrements[j];
- DestPtr[j] = (cmsUInt8Number*)out + DestStartingOrder[j] + DestStrideIncrements[j];
- }
-
- for (j = 0; j < PixelsPerLine; j++) {
-
- for (k = 0; k < nExtra; k++) {
-
- copyValueFn(DestPtr[k], SourcePtr[k]);
-
- SourcePtr[k] += SourceIncrements[k];
- DestPtr[k] += DestIncrements[k];
- }
- }
-
- for (j = 0; j < nExtra; j++) {
-
- SourceStrideIncrements[j] += Stride->BytesPerLineIn;
- DestStrideIncrements[j] += Stride->BytesPerLineOut;
- }
- }
- }
-}
-
-
diff --git a/contrib/libs/lcms2/src/cmscam02.c b/contrib/libs/lcms2/src/cmscam02.c
deleted file mode 100644
index 3f080a190c..0000000000
--- a/contrib/libs/lcms2/src/cmscam02.c
+++ /dev/null
@@ -1,486 +0,0 @@
-//---------------------------------------------------------------------------------
-//
-// Little Color Management System
-// Copyright (c) 1998-2023 Marti Maria Saguer
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//---------------------------------------------------------------------------------
-//
-
-#include "lcms2_internal.h"
-
-// CIECAM 02 appearance model. Many thanks to Jordi Vilar for the debugging.
-
-// ---------- Implementation --------------------------------------------
-
-typedef struct {
-
- cmsFloat64Number XYZ[3];
- cmsFloat64Number RGB[3];
- cmsFloat64Number RGBc[3];
- cmsFloat64Number RGBp[3];
- cmsFloat64Number RGBpa[3];
- cmsFloat64Number a, b, h, e, H, A, J, Q, s, t, C, M;
- cmsFloat64Number abC[2];
- cmsFloat64Number abs[2];
- cmsFloat64Number abM[2];
-
-} CAM02COLOR;
-
-typedef struct {
-
- CAM02COLOR adoptedWhite;
- cmsFloat64Number LA, Yb;
- cmsFloat64Number F, c, Nc;
- cmsUInt32Number surround;
- cmsFloat64Number n, Nbb, Ncb, z, FL, D;
-
- cmsContext ContextID;
-
-} cmsCIECAM02;
-
-
-static
-cmsFloat64Number compute_n(cmsCIECAM02* pMod)
-{
- return (pMod -> Yb / pMod -> adoptedWhite.XYZ[1]);
-}
-
-static
-cmsFloat64Number compute_z(cmsCIECAM02* pMod)
-{
- return (1.48 + pow(pMod -> n, 0.5));
-}
-
-static
-cmsFloat64Number computeNbb(cmsCIECAM02* pMod)
-{
- return (0.725 * pow((1.0 / pMod -> n), 0.2));
-}
-
-static
-cmsFloat64Number computeFL(cmsCIECAM02* pMod)
-{
- cmsFloat64Number k, FL;
-
- k = 1.0 / ((5.0 * pMod->LA) + 1.0);
- FL = 0.2 * pow(k, 4.0) * (5.0 * pMod->LA) + 0.1 *
- (pow((1.0 - pow(k, 4.0)), 2.0)) *
- (pow((5.0 * pMod->LA), (1.0 / 3.0)));
-
- return FL;
-}
-
-static
-cmsFloat64Number computeD(cmsCIECAM02* pMod)
-{
- cmsFloat64Number D;
-
- D = pMod->F - (1.0/3.6)*(exp(((-pMod ->LA-42) / 92.0)));
-
- return D;
-}
-
-
-static
-CAM02COLOR XYZtoCAT02(CAM02COLOR clr)
-{
- clr.RGB[0] = (clr.XYZ[0] * 0.7328) + (clr.XYZ[1] * 0.4296) + (clr.XYZ[2] * -0.1624);
- clr.RGB[1] = (clr.XYZ[0] * -0.7036) + (clr.XYZ[1] * 1.6975) + (clr.XYZ[2] * 0.0061);
- clr.RGB[2] = (clr.XYZ[0] * 0.0030) + (clr.XYZ[1] * 0.0136) + (clr.XYZ[2] * 0.9834);
-
- return clr;
-}
-
-static
-CAM02COLOR ChromaticAdaptation(CAM02COLOR clr, cmsCIECAM02* pMod)
-{
- cmsUInt32Number i;
-
- for (i = 0; i < 3; i++) {
- clr.RGBc[i] = ((pMod -> adoptedWhite.XYZ[1] *
- (pMod->D / pMod -> adoptedWhite.RGB[i])) +
- (1.0 - pMod->D)) * clr.RGB[i];
- }
-
- return clr;
-}
-
-
-static
-CAM02COLOR CAT02toHPE(CAM02COLOR clr)
-{
- cmsFloat64Number M[9];
-
- M[0] =(( 0.38971 * 1.096124) + (0.68898 * 0.454369) + (-0.07868 * -0.009628));
- M[1] =(( 0.38971 * -0.278869) + (0.68898 * 0.473533) + (-0.07868 * -0.005698));
- M[2] =(( 0.38971 * 0.182745) + (0.68898 * 0.072098) + (-0.07868 * 1.015326));
- M[3] =((-0.22981 * 1.096124) + (1.18340 * 0.454369) + ( 0.04641 * -0.009628));
- M[4] =((-0.22981 * -0.278869) + (1.18340 * 0.473533) + ( 0.04641 * -0.005698));
- M[5] =((-0.22981 * 0.182745) + (1.18340 * 0.072098) + ( 0.04641 * 1.015326));
- M[6] =(-0.009628);
- M[7] =(-0.005698);
- M[8] =( 1.015326);
-
- clr.RGBp[0] = (clr.RGBc[0] * M[0]) + (clr.RGBc[1] * M[1]) + (clr.RGBc[2] * M[2]);
- clr.RGBp[1] = (clr.RGBc[0] * M[3]) + (clr.RGBc[1] * M[4]) + (clr.RGBc[2] * M[5]);
- clr.RGBp[2] = (clr.RGBc[0] * M[6]) + (clr.RGBc[1] * M[7]) + (clr.RGBc[2] * M[8]);
-
- return clr;
-}
-
-static
-CAM02COLOR NonlinearCompression(CAM02COLOR clr, cmsCIECAM02* pMod)
-{
- cmsUInt32Number i;
- cmsFloat64Number temp;
-
- for (i = 0; i < 3; i++) {
- if (clr.RGBp[i] < 0) {
-
- temp = pow((-1.0 * pMod->FL * clr.RGBp[i] / 100.0), 0.42);
- clr.RGBpa[i] = (-1.0 * 400.0 * temp) / (temp + 27.13) + 0.1;
- }
- else {
- temp = pow((pMod->FL * clr.RGBp[i] / 100.0), 0.42);
- clr.RGBpa[i] = (400.0 * temp) / (temp + 27.13) + 0.1;
- }
- }
-
- clr.A = (((2.0 * clr.RGBpa[0]) + clr.RGBpa[1] +
- (clr.RGBpa[2] / 20.0)) - 0.305) * pMod->Nbb;
-
- return clr;
-}
-
-static
-CAM02COLOR ComputeCorrelates(CAM02COLOR clr, cmsCIECAM02* pMod)
-{
- cmsFloat64Number a, b, temp, e, t, r2d, d2r;
-
- a = clr.RGBpa[0] - (12.0 * clr.RGBpa[1] / 11.0) + (clr.RGBpa[2] / 11.0);
- b = (clr.RGBpa[0] + clr.RGBpa[1] - (2.0 * clr.RGBpa[2])) / 9.0;
-
- r2d = (180.0 / 3.141592654);
- if (a == 0) {
- if (b == 0) clr.h = 0;
- else if (b > 0) clr.h = 90;
- else clr.h = 270;
- }
- else if (a > 0) {
- temp = b / a;
- if (b > 0) clr.h = (r2d * atan(temp));
- else if (b == 0) clr.h = 0;
- else clr.h = (r2d * atan(temp)) + 360;
- }
- else {
- temp = b / a;
- clr.h = (r2d * atan(temp)) + 180;
- }
-
- d2r = (3.141592654 / 180.0);
- e = ((12500.0 / 13.0) * pMod->Nc * pMod->Ncb) *
- (cos((clr.h * d2r + 2.0)) + 3.8);
-
- if (clr.h < 20.14) {
- temp = ((clr.h + 122.47)/1.2) + ((20.14 - clr.h)/0.8);
- clr.H = 300 + (100*((clr.h + 122.47)/1.2)) / temp;
- }
- else if (clr.h < 90.0) {
- temp = ((clr.h - 20.14)/0.8) + ((90.00 - clr.h)/0.7);
- clr.H = (100*((clr.h - 20.14)/0.8)) / temp;
- }
- else if (clr.h < 164.25) {
- temp = ((clr.h - 90.00)/0.7) + ((164.25 - clr.h)/1.0);
- clr.H = 100 + ((100*((clr.h - 90.00)/0.7)) / temp);
- }
- else if (clr.h < 237.53) {
- temp = ((clr.h - 164.25)/1.0) + ((237.53 - clr.h)/1.2);
- clr.H = 200 + ((100*((clr.h - 164.25)/1.0)) / temp);
- }
- else {
- temp = ((clr.h - 237.53)/1.2) + ((360 - clr.h + 20.14)/0.8);
- clr.H = 300 + ((100*((clr.h - 237.53)/1.2)) / temp);
- }
-
- clr.J = 100.0 * pow((clr.A / pMod->adoptedWhite.A),
- (pMod->c * pMod->z));
-
- clr.Q = (4.0 / pMod->c) * pow((clr.J / 100.0), 0.5) *
- (pMod->adoptedWhite.A + 4.0) * pow(pMod->FL, 0.25);
-
- t = (e * pow(((a * a) + (b * b)), 0.5)) /
- (clr.RGBpa[0] + clr.RGBpa[1] +
- ((21.0 / 20.0) * clr.RGBpa[2]));
-
- clr.C = pow(t, 0.9) * pow((clr.J / 100.0), 0.5) *
- pow((1.64 - pow(0.29, pMod->n)), 0.73);
-
- clr.M = clr.C * pow(pMod->FL, 0.25);
- clr.s = 100.0 * pow((clr.M / clr.Q), 0.5);
-
- return clr;
-}
-
-
-static
-CAM02COLOR InverseCorrelates(CAM02COLOR clr, cmsCIECAM02* pMod)
-{
-
- cmsFloat64Number t, e, p1, p2, p3, p4, p5, hr, d2r;
- d2r = 3.141592654 / 180.0;
-
- t = pow( (clr.C / (pow((clr.J / 100.0), 0.5) *
- (pow((1.64 - pow(0.29, pMod->n)), 0.73)))),
- (1.0 / 0.9) );
- e = ((12500.0 / 13.0) * pMod->Nc * pMod->Ncb) *
- (cos((clr.h * d2r + 2.0)) + 3.8);
-
- clr.A = pMod->adoptedWhite.A * pow(
- (clr.J / 100.0),
- (1.0 / (pMod->c * pMod->z)));
-
- p1 = e / t;
- p2 = (clr.A / pMod->Nbb) + 0.305;
- p3 = 21.0 / 20.0;
-
- hr = clr.h * d2r;
-
- if (fabs(sin(hr)) >= fabs(cos(hr))) {
- p4 = p1 / sin(hr);
- clr.b = (p2 * (2.0 + p3) * (460.0 / 1403.0)) /
- (p4 + (2.0 + p3) * (220.0 / 1403.0) *
- (cos(hr) / sin(hr)) - (27.0 / 1403.0) +
- p3 * (6300.0 / 1403.0));
- clr.a = clr.b * (cos(hr) / sin(hr));
- }
- else {
- p5 = p1 / cos(hr);
- clr.a = (p2 * (2.0 + p3) * (460.0 / 1403.0)) /
- (p5 + (2.0 + p3) * (220.0 / 1403.0) -
- ((27.0 / 1403.0) - p3 * (6300.0 / 1403.0)) *
- (sin(hr) / cos(hr)));
- clr.b = clr.a * (sin(hr) / cos(hr));
- }
-
- clr.RGBpa[0] = ((460.0 / 1403.0) * p2) +
- ((451.0 / 1403.0) * clr.a) +
- ((288.0 / 1403.0) * clr.b);
- clr.RGBpa[1] = ((460.0 / 1403.0) * p2) -
- ((891.0 / 1403.0) * clr.a) -
- ((261.0 / 1403.0) * clr.b);
- clr.RGBpa[2] = ((460.0 / 1403.0) * p2) -
- ((220.0 / 1403.0) * clr.a) -
- ((6300.0 / 1403.0) * clr.b);
-
- return clr;
-}
-
-static
-CAM02COLOR InverseNonlinearity(CAM02COLOR clr, cmsCIECAM02* pMod)
-{
- cmsUInt32Number i;
- cmsFloat64Number c1;
-
- for (i = 0; i < 3; i++) {
- if ((clr.RGBpa[i] - 0.1) < 0) c1 = -1;
- else c1 = 1;
- clr.RGBp[i] = c1 * (100.0 / pMod->FL) *
- pow(((27.13 * fabs(clr.RGBpa[i] - 0.1)) /
- (400.0 - fabs(clr.RGBpa[i] - 0.1))),
- (1.0 / 0.42));
- }
-
- return clr;
-}
-
-static
-CAM02COLOR HPEtoCAT02(CAM02COLOR clr)
-{
- cmsFloat64Number M[9];
-
- M[0] = (( 0.7328 * 1.910197) + (0.4296 * 0.370950));
- M[1] = (( 0.7328 * -1.112124) + (0.4296 * 0.629054));
- M[2] = (( 0.7328 * 0.201908) + (0.4296 * 0.000008) - 0.1624);
- M[3] = ((-0.7036 * 1.910197) + (1.6975 * 0.370950));
- M[4] = ((-0.7036 * -1.112124) + (1.6975 * 0.629054));
- M[5] = ((-0.7036 * 0.201908) + (1.6975 * 0.000008) + 0.0061);
- M[6] = (( 0.0030 * 1.910197) + (0.0136 * 0.370950));
- M[7] = (( 0.0030 * -1.112124) + (0.0136 * 0.629054));
- M[8] = (( 0.0030 * 0.201908) + (0.0136 * 0.000008) + 0.9834);
-
- clr.RGBc[0] = (clr.RGBp[0] * M[0]) + (clr.RGBp[1] * M[1]) + (clr.RGBp[2] * M[2]);
- clr.RGBc[1] = (clr.RGBp[0] * M[3]) + (clr.RGBp[1] * M[4]) + (clr.RGBp[2] * M[5]);
- clr.RGBc[2] = (clr.RGBp[0] * M[6]) + (clr.RGBp[1] * M[7]) + (clr.RGBp[2] * M[8]);
- return clr;
-}
-
-
-static
-CAM02COLOR InverseChromaticAdaptation(CAM02COLOR clr, cmsCIECAM02* pMod)
-{
- cmsUInt32Number i;
- for (i = 0; i < 3; i++) {
- clr.RGB[i] = clr.RGBc[i] /
- ((pMod->adoptedWhite.XYZ[1] * pMod->D / pMod->adoptedWhite.RGB[i]) + 1.0 - pMod->D);
- }
- return clr;
-}
-
-
-static
-CAM02COLOR CAT02toXYZ(CAM02COLOR clr)
-{
- clr.XYZ[0] = (clr.RGB[0] * 1.096124) + (clr.RGB[1] * -0.278869) + (clr.RGB[2] * 0.182745);
- clr.XYZ[1] = (clr.RGB[0] * 0.454369) + (clr.RGB[1] * 0.473533) + (clr.RGB[2] * 0.072098);
- clr.XYZ[2] = (clr.RGB[0] * -0.009628) + (clr.RGB[1] * -0.005698) + (clr.RGB[2] * 1.015326);
-
- return clr;
-}
-
-
-cmsHANDLE CMSEXPORT cmsCIECAM02Init(cmsContext ContextID, const cmsViewingConditions* pVC)
-{
- cmsCIECAM02* lpMod;
-
- _cmsAssert(pVC != NULL);
-
- if((lpMod = (cmsCIECAM02*) _cmsMallocZero(ContextID, sizeof(cmsCIECAM02))) == NULL) {
- return NULL;
- }
-
- lpMod ->ContextID = ContextID;
-
- lpMod ->adoptedWhite.XYZ[0] = pVC ->whitePoint.X;
- lpMod ->adoptedWhite.XYZ[1] = pVC ->whitePoint.Y;
- lpMod ->adoptedWhite.XYZ[2] = pVC ->whitePoint.Z;
-
- lpMod -> LA = pVC ->La;
- lpMod -> Yb = pVC ->Yb;
- lpMod -> D = pVC ->D_value;
- lpMod -> surround = pVC ->surround;
-
- switch (lpMod -> surround) {
-
-
- case CUTSHEET_SURROUND:
- lpMod->F = 0.8;
- lpMod->c = 0.41;
- lpMod->Nc = 0.8;
- break;
-
- case DARK_SURROUND:
- lpMod -> F = 0.8;
- lpMod -> c = 0.525;
- lpMod -> Nc = 0.8;
- break;
-
- case DIM_SURROUND:
- lpMod -> F = 0.9;
- lpMod -> c = 0.59;
- lpMod -> Nc = 0.95;
- break;
-
- default:
- // Average surround
- lpMod -> F = 1.0;
- lpMod -> c = 0.69;
- lpMod -> Nc = 1.0;
- }
-
- lpMod -> n = compute_n(lpMod);
- lpMod -> z = compute_z(lpMod);
- lpMod -> Nbb = computeNbb(lpMod);
- lpMod -> FL = computeFL(lpMod);
-
- if (lpMod -> D == D_CALCULATE) {
- lpMod -> D = computeD(lpMod);
- }
-
- lpMod -> Ncb = lpMod -> Nbb;
-
- lpMod -> adoptedWhite = XYZtoCAT02(lpMod -> adoptedWhite);
- lpMod -> adoptedWhite = ChromaticAdaptation(lpMod -> adoptedWhite, lpMod);
- lpMod -> adoptedWhite = CAT02toHPE(lpMod -> adoptedWhite);
- lpMod -> adoptedWhite = NonlinearCompression(lpMod -> adoptedWhite, lpMod);
-
- return (cmsHANDLE) lpMod;
-
-}
-
-void CMSEXPORT cmsCIECAM02Done(cmsHANDLE hModel)
-{
- cmsCIECAM02* lpMod = (cmsCIECAM02*) hModel;
-
- if (lpMod) _cmsFree(lpMod ->ContextID, lpMod);
-}
-
-
-void CMSEXPORT cmsCIECAM02Forward(cmsHANDLE hModel, const cmsCIEXYZ* pIn, cmsJCh* pOut)
-{
- CAM02COLOR clr;
- cmsCIECAM02* lpMod = (cmsCIECAM02*) hModel;
-
- _cmsAssert(lpMod != NULL);
- _cmsAssert(pIn != NULL);
- _cmsAssert(pOut != NULL);
-
- memset(&clr, 0, sizeof(clr));
-
- clr.XYZ[0] = pIn ->X;
- clr.XYZ[1] = pIn ->Y;
- clr.XYZ[2] = pIn ->Z;
-
- clr = XYZtoCAT02(clr);
- clr = ChromaticAdaptation(clr, lpMod);
- clr = CAT02toHPE(clr);
- clr = NonlinearCompression(clr, lpMod);
- clr = ComputeCorrelates(clr, lpMod);
-
- pOut ->J = clr.J;
- pOut ->C = clr.C;
- pOut ->h = clr.h;
-}
-
-void CMSEXPORT cmsCIECAM02Reverse(cmsHANDLE hModel, const cmsJCh* pIn, cmsCIEXYZ* pOut)
-{
- CAM02COLOR clr;
- cmsCIECAM02* lpMod = (cmsCIECAM02*) hModel;
-
- _cmsAssert(lpMod != NULL);
- _cmsAssert(pIn != NULL);
- _cmsAssert(pOut != NULL);
-
- memset(&clr, 0, sizeof(clr));
-
- clr.J = pIn -> J;
- clr.C = pIn -> C;
- clr.h = pIn -> h;
-
- clr = InverseCorrelates(clr, lpMod);
- clr = InverseNonlinearity(clr, lpMod);
- clr = HPEtoCAT02(clr);
- clr = InverseChromaticAdaptation(clr, lpMod);
- clr = CAT02toXYZ(clr);
-
- pOut ->X = clr.XYZ[0];
- pOut ->Y = clr.XYZ[1];
- pOut ->Z = clr.XYZ[2];
-}
diff --git a/contrib/libs/lcms2/src/cmscgats.c b/contrib/libs/lcms2/src/cmscgats.c
deleted file mode 100644
index bccbf58c10..0000000000
--- a/contrib/libs/lcms2/src/cmscgats.c
+++ /dev/null
@@ -1,3236 +0,0 @@
-//---------------------------------------------------------------------------------
-//
-// Little Color Management System
-// Copyright (c) 1998-2023 Marti Maria Saguer
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//---------------------------------------------------------------------------------
-//
-
-#include "lcms2_internal.h"
-
-
-// IT8.7 / CGATS.17-200x handling -----------------------------------------------------------------------------
-
-
-#define MAXID 128 // Max length of identifier
-#define MAXSTR 1024 // Max length of string
-#define MAXTABLES 255 // Max Number of tables in a single stream
-#define MAXINCLUDE 20 // Max number of nested includes
-
-#define DEFAULT_DBL_FORMAT "%.10g" // Double formatting
-
-#ifdef CMS_IS_WINDOWS_
-# include <io.h>
-# define DIR_CHAR '\\'
-#else
-# define DIR_CHAR '/'
-#endif
-
-
-// Symbols
-typedef enum {
-
- SUNDEFINED,
- SINUM, // Integer
- SDNUM, // Real
- SIDENT, // Identifier
- SSTRING, // string
- SCOMMENT, // comment
- SEOLN, // End of line
- SEOF, // End of stream
- SSYNERROR, // Syntax error found on stream
-
- // IT8 symbols
-
- SBEGIN_DATA,
- SBEGIN_DATA_FORMAT,
- SEND_DATA,
- SEND_DATA_FORMAT,
- SKEYWORD,
- SDATA_FORMAT_ID,
- SINCLUDE,
-
- // Cube symbols
-
- SDOMAIN_MAX,
- SDOMAIN_MIN,
- S_LUT1D_SIZE,
- S_LUT1D_INPUT_RANGE,
- S_LUT3D_SIZE,
- S_LUT3D_INPUT_RANGE,
- S_LUT_IN_VIDEO_RANGE,
- S_LUT_OUT_VIDEO_RANGE,
- STITLE
-
- } SYMBOL;
-
-
-// How to write the value
-typedef enum {
-
- WRITE_UNCOOKED,
- WRITE_STRINGIFY,
- WRITE_HEXADECIMAL,
- WRITE_BINARY,
- WRITE_PAIR
-
- } WRITEMODE;
-
-// Linked list of variable names
-typedef struct _KeyVal {
-
- struct _KeyVal* Next;
- char* Keyword; // Name of variable
- struct _KeyVal* NextSubkey; // If key is a dictionary, points to the next item
- char* Subkey; // If key is a dictionary, points to the subkey name
- char* Value; // Points to value
- WRITEMODE WriteAs; // How to write the value
-
- } KEYVALUE;
-
-
-// Linked list of memory chunks (Memory sink)
-typedef struct _OwnedMem {
-
- struct _OwnedMem* Next;
- void * Ptr; // Point to value
-
- } OWNEDMEM;
-
-// Suballocator
-typedef struct _SubAllocator {
-
- cmsUInt8Number* Block;
- cmsUInt32Number BlockSize;
- cmsUInt32Number Used;
-
- } SUBALLOCATOR;
-
-// Table. Each individual table can hold properties and rows & cols
-typedef struct _Table {
-
- char SheetType[MAXSTR]; // The first row of the IT8 (the type)
-
- int nSamples, nPatches; // Cols, Rows
- int SampleID; // Pos of ID
-
- KEYVALUE* HeaderList; // The properties
-
- char** DataFormat; // The binary stream descriptor
- char** Data; // The binary stream
-
- } TABLE;
-
-// File stream being parsed
-typedef struct _FileContext {
- char FileName[cmsMAX_PATH]; // File name if being read from file
- FILE* Stream; // File stream or NULL if holded in memory
- } FILECTX;
-
-//Very simple string
-typedef struct {
-
- struct struct_it8* it8;
- cmsInt32Number max;
- cmsInt32Number len;
- char* begin;
- } string;
-
-
-// This struct hold all information about an open IT8 handler.
-typedef struct struct_it8 {
-
- cmsUInt32Number TablesCount; // How many tables in this stream
- cmsUInt32Number nTable; // The actual table
-
- // Partser type
- cmsBool IsCUBE;
-
- // Tables
- TABLE Tab[MAXTABLES];
-
- // Memory management
- OWNEDMEM* MemorySink; // The storage backend
- SUBALLOCATOR Allocator; // String suballocator -- just to keep it fast
-
- // Parser state machine
- SYMBOL sy; // Current symbol
- int ch; // Current character
-
- cmsInt32Number inum; // integer value
- cmsFloat64Number dnum; // real value
-
- string* id; // identifier
- string* str; // string
-
- // Allowed keywords & datasets. They have visibility on whole stream
- KEYVALUE* ValidKeywords;
- KEYVALUE* ValidSampleID;
-
- char* Source; // Points to loc. being parsed
- cmsInt32Number lineno; // line counter for error reporting
-
- FILECTX* FileStack[MAXINCLUDE]; // Stack of files being parsed
- cmsInt32Number IncludeSP; // Include Stack Pointer
-
- char* MemoryBlock; // The stream if holded in memory
-
- char DoubleFormatter[MAXID];// Printf-like 'cmsFloat64Number' formatter
-
- cmsContext ContextID; // The threading context
-
- } cmsIT8;
-
-
-// The stream for save operations
-typedef struct {
-
- FILE* stream; // For save-to-file behaviour
-
- cmsUInt8Number* Base;
- cmsUInt8Number* Ptr; // For save-to-mem behaviour
- cmsUInt32Number Used;
- cmsUInt32Number Max;
-
- } SAVESTREAM;
-
-
-// ------------------------------------------------------ cmsIT8 parsing routines
-
-
-// A keyword
-typedef struct {
-
- const char *id;
- SYMBOL sy;
-
- } KEYWORD;
-
-// The keyword->symbol translation tables. Sorting is required.
-static const KEYWORD TabKeysIT8[] = {
-
- {"$INCLUDE", SINCLUDE}, // This is an extension!
- {".INCLUDE", SINCLUDE}, // This is an extension!
-
- {"BEGIN_DATA", SBEGIN_DATA },
- {"BEGIN_DATA_FORMAT", SBEGIN_DATA_FORMAT },
- {"DATA_FORMAT_IDENTIFIER", SDATA_FORMAT_ID},
- {"END_DATA", SEND_DATA},
- {"END_DATA_FORMAT", SEND_DATA_FORMAT},
- {"KEYWORD", SKEYWORD}
- };
-
-#define NUMKEYS_IT8 (sizeof(TabKeysIT8)/sizeof(KEYWORD))
-
-static const KEYWORD TabKeysCUBE[] = {
-
- {"DOMAIN_MAX", SDOMAIN_MAX },
- {"DOMAIN_MIN", SDOMAIN_MIN },
- {"LUT_1D_SIZE", S_LUT1D_SIZE },
- {"LUT_1D_INPUT_RANGE", S_LUT1D_INPUT_RANGE },
- {"LUT_3D_SIZE", S_LUT3D_SIZE },
- {"LUT_3D_INPUT_RANGE", S_LUT3D_INPUT_RANGE },
- {"LUT_IN_VIDEO_RANGE", S_LUT_IN_VIDEO_RANGE },
- {"LUT_OUT_VIDEO_RANGE", S_LUT_OUT_VIDEO_RANGE },
- {"TITLE", STITLE }
-
-};
-
-#define NUMKEYS_CUBE (sizeof(TabKeysCUBE)/sizeof(KEYWORD))
-
-
-
-// Predefined properties
-
-// A property
-typedef struct {
- const char *id; // The identifier
- WRITEMODE as; // How is supposed to be written
- } PROPERTY;
-
-static PROPERTY PredefinedProperties[] = {
-
- {"NUMBER_OF_FIELDS", WRITE_UNCOOKED}, // Required - NUMBER OF FIELDS
- {"NUMBER_OF_SETS", WRITE_UNCOOKED}, // Required - NUMBER OF SETS
- {"ORIGINATOR", WRITE_STRINGIFY}, // Required - Identifies the specific system, organization or individual that created the data file.
- {"FILE_DESCRIPTOR", WRITE_STRINGIFY}, // Required - Describes the purpose or contents of the data file.
- {"CREATED", WRITE_STRINGIFY}, // Required - Indicates date of creation of the data file.
- {"DESCRIPTOR", WRITE_STRINGIFY}, // Required - Describes the purpose or contents of the data file.
- {"DIFFUSE_GEOMETRY", WRITE_STRINGIFY}, // The diffuse geometry used. Allowed values are "sphere" or "opal".
- {"MANUFACTURER", WRITE_STRINGIFY},
- {"MANUFACTURE", WRITE_STRINGIFY}, // Some broken Fuji targets does store this value
- {"PROD_DATE", WRITE_STRINGIFY}, // Identifies year and month of production of the target in the form yyyy:mm.
- {"SERIAL", WRITE_STRINGIFY}, // Uniquely identifies individual physical target.
-
- {"MATERIAL", WRITE_STRINGIFY}, // Identifies the material on which the target was produced using a code
- // uniquely identifying th e material. This is intend ed to be used for IT8.7
- // physical targets only (i.e . IT8.7/1 and IT8.7/2).
-
- {"INSTRUMENTATION", WRITE_STRINGIFY}, // Used to report the specific instrumentation used (manufacturer and
- // model number) to generate the data reported. This data will often
- // provide more information about the particular data collected than an
- // extensive list of specific details. This is particularly important for
- // spectral data or data derived from spectrophotometry.
-
- {"MEASUREMENT_SOURCE", WRITE_STRINGIFY}, // Illumination used for spectral measurements. This data helps provide
- // a guide to the potential for issues of paper fluorescence, etc.
-
- {"PRINT_CONDITIONS", WRITE_STRINGIFY}, // Used to define the characteristics of the printed sheet being reported.
- // Where standard conditions have been defined (e.g., SWOP at nominal)
- // named conditions may suffice. Otherwise, detailed information is
- // needed.
-
- {"SAMPLE_BACKING", WRITE_STRINGIFY}, // Identifies the backing material used behind the sample during
- // measurement. Allowed values are "black", "white", or {"na".
-
- {"CHISQ_DOF", WRITE_STRINGIFY}, // Degrees of freedom associated with the Chi squared statistic
- // below properties are new in recent specs:
-
- {"MEASUREMENT_GEOMETRY", WRITE_STRINGIFY}, // The type of measurement, either reflection or transmission, should be indicated
- // along with details of the geometry and the aperture size and shape. For example,
- // for transmission measurements it is important to identify 0/diffuse, diffuse/0,
- // opal or integrating sphere, etc. For reflection it is important to identify 0/45,
- // 45/0, sphere (specular included or excluded), etc.
-
- {"FILTER", WRITE_STRINGIFY}, // Identifies the use of physical filter(s) during measurement. Typically used to
- // denote the use of filters such as none, D65, Red, Green or Blue.
-
- {"POLARIZATION", WRITE_STRINGIFY}, // Identifies the use of a physical polarization filter during measurement. Allowed
- // values are {"yes", "white", "none" or "na".
-
- {"WEIGHTING_FUNCTION", WRITE_PAIR}, // Indicates such functions as: the CIE standard observer functions used in the
- // calculation of various data parameters (2 degree and 10 degree), CIE standard
- // illuminant functions used in the calculation of various data parameters (e.g., D50,
- // D65, etc.), density status response, etc. If used there shall be at least one
- // name-value pair following the WEIGHTING_FUNCTION tag/keyword. The first attribute
- // in the set shall be {"name" and shall identify the particular parameter used.
- // The second shall be {"value" and shall provide the value associated with that name.
- // For ASCII data, a string containing the Name and Value attribute pairs shall follow
- // the weighting function keyword. A semi-colon separates attribute pairs from each
- // other and within the attribute the name and value are separated by a comma.
-
- {"COMPUTATIONAL_PARAMETER", WRITE_PAIR}, // Parameter that is used in computing a value from measured data. Name is the name
- // of the calculation, parameter is the name of the parameter used in the calculation
- // and value is the value of the parameter.
-
- {"TARGET_TYPE", WRITE_STRINGIFY}, // The type of target being measured, e.g. IT8.7/1, IT8.7/3, user defined, etc.
-
- {"COLORANT", WRITE_STRINGIFY}, // Identifies the colorant(s) used in creating the target.
-
- {"TABLE_DESCRIPTOR", WRITE_STRINGIFY}, // Describes the purpose or contents of a data table.
-
- {"TABLE_NAME", WRITE_STRINGIFY} // Provides a short name for a data table.
-};
-
-#define NUMPREDEFINEDPROPS (sizeof(PredefinedProperties)/sizeof(PROPERTY))
-
-
-// Predefined sample types on dataset
-static const char* PredefinedSampleID[] = {
- "SAMPLE_ID", // Identifies sample that data represents
- "STRING", // Identifies label, or other non-machine readable value.
- // Value must begin and end with a " symbol
-
- "CMYK_C", // Cyan component of CMYK data expressed as a percentage
- "CMYK_M", // Magenta component of CMYK data expressed as a percentage
- "CMYK_Y", // Yellow component of CMYK data expressed as a percentage
- "CMYK_K", // Black component of CMYK data expressed as a percentage
- "D_RED", // Red filter density
- "D_GREEN", // Green filter density
- "D_BLUE", // Blue filter density
- "D_VIS", // Visual filter density
- "D_MAJOR_FILTER", // Major filter d ensity
- "RGB_R", // Red component of RGB data
- "RGB_G", // Green component of RGB data
- "RGB_B", // Blue com ponent of RGB data
- "SPECTRAL_NM", // Wavelength of measurement expressed in nanometers
- "SPECTRAL_PCT", // Percentage reflectance/transmittance
- "SPECTRAL_DEC", // Reflectance/transmittance
- "XYZ_X", // X component of tristimulus data
- "XYZ_Y", // Y component of tristimulus data
- "XYZ_Z", // Z component of tristimulus data
- "XYY_X", // x component of chromaticity data
- "XYY_Y", // y component of chromaticity data
- "XYY_CAPY", // Y component of tristimulus data
- "LAB_L", // L* component of Lab data
- "LAB_A", // a* component of Lab data
- "LAB_B", // b* component of Lab data
- "LAB_C", // C*ab component of Lab data
- "LAB_H", // hab component of Lab data
- "LAB_DE", // CIE dE
- "LAB_DE_94", // CIE dE using CIE 94
- "LAB_DE_CMC", // dE using CMC
- "LAB_DE_2000", // CIE dE using CIE DE 2000
- "MEAN_DE", // Mean Delta E (LAB_DE) of samples compared to batch average
- // (Used for data files for ANSI IT8.7/1 and IT8.7/2 targets)
- "STDEV_X", // Standard deviation of X (tristimulus data)
- "STDEV_Y", // Standard deviation of Y (tristimulus data)
- "STDEV_Z", // Standard deviation of Z (tristimulus data)
- "STDEV_L", // Standard deviation of L*
- "STDEV_A", // Standard deviation of a*
- "STDEV_B", // Standard deviation of b*
- "STDEV_DE", // Standard deviation of CIE dE
- "CHI_SQD_PAR"}; // The average of the standard deviations of L*, a* and b*. It is
- // used to derive an estimate of the chi-squared parameter which is
- // recommended as the predictor of the variability of dE
-
-#define NUMPREDEFINEDSAMPLEID (sizeof(PredefinedSampleID)/sizeof(char *))
-
-//Forward declaration of some internal functions
-static void* AllocChunk(cmsIT8* it8, cmsUInt32Number size);
-
-static
-string* StringAlloc(cmsIT8* it8, int max)
-{
- string* s = (string*) AllocChunk(it8, sizeof(string));
- if (s == NULL) return NULL;
-
- s->it8 = it8;
- s->max = max;
- s->len = 0;
- s->begin = (char*) AllocChunk(it8, s->max);
-
- return s;
-}
-
-static
-void StringClear(string* s)
-{
- s->len = 0;
-}
-
-static
-void StringAppend(string* s, char c)
-{
- if (s->len + 1 >= s->max)
- {
- char* new_ptr;
-
- s->max *= 10;
- new_ptr = (char*) AllocChunk(s->it8, s->max);
- if (new_ptr != NULL && s->begin != NULL)
- memcpy(new_ptr, s->begin, s->len);
-
- s->begin = new_ptr;
- }
-
- if (s->begin != NULL)
- {
- s->begin[s->len++] = c;
- s->begin[s->len] = 0;
- }
-}
-
-static
-char* StringPtr(string* s)
-{
- return s->begin;
-}
-
-static
-void StringCat(string* s, const char* c)
-{
- while (*c)
- {
- StringAppend(s, *c);
- c++;
- }
-}
-
-
-// Checks whatever c is a separator
-static
-cmsBool isseparator(int c)
-{
- return (c == ' ') || (c == '\t');
-}
-
-// Checks whatever c is a valid identifier char
-static
-cmsBool ismiddle(int c)
-{
- return (!isseparator(c) && (c != '#') && (c !='\"') && (c != '\'') && (c > 32) && (c < 127));
-}
-
-// Checks whatsever c is a valid identifier middle char.
-static
-cmsBool isidchar(int c)
-{
- return isalnum(c) || ismiddle(c);
-}
-
-// Checks whatsever c is a valid identifier first char.
-static
-cmsBool isfirstidchar(int c)
-{
- return c != '-' && !isdigit(c) && ismiddle(c);
-}
-
-// Guess whether the supplied path looks like an absolute path
-static
-cmsBool isabsolutepath(const char *path)
-{
- char ThreeChars[4];
-
- if(path == NULL)
- return FALSE;
- if (path[0] == 0)
- return FALSE;
-
- strncpy(ThreeChars, path, 3);
- ThreeChars[3] = 0;
-
- if(ThreeChars[0] == DIR_CHAR)
- return TRUE;
-
-#ifdef CMS_IS_WINDOWS_
- if (isalpha((int) ThreeChars[0]) && ThreeChars[1] == ':')
- return TRUE;
-#endif
- return FALSE;
-}
-
-
-// Makes a file path based on a given reference path
-// NOTE: this function doesn't check if the path exists or even if it's legal
-static
-cmsBool BuildAbsolutePath(const char *relPath, const char *basePath, char *buffer, cmsUInt32Number MaxLen)
-{
- char *tail;
- cmsUInt32Number len;
-
- // Already absolute?
- if (isabsolutepath(relPath)) {
-
- memcpy(buffer, relPath, MaxLen);
- buffer[MaxLen-1] = 0;
- return TRUE;
- }
-
- // No, search for last
- memcpy(buffer, basePath, MaxLen);
- buffer[MaxLen-1] = 0;
-
- tail = strrchr(buffer, DIR_CHAR);
- if (tail == NULL) return FALSE; // Is not absolute and has no separators??
-
- len = (cmsUInt32Number) (tail - buffer);
- if (len >= MaxLen) return FALSE;
-
- // No need to assure zero terminator over here
- strncpy(tail + 1, relPath, MaxLen - len);
-
- return TRUE;
-}
-
-
-// Make sure no exploit is being even tried
-static
-const char* NoMeta(const char* str)
-{
- if (strchr(str, '%') != NULL)
- return "**** CORRUPTED FORMAT STRING ***";
-
- return str;
-}
-
-// Syntax error
-static
-cmsBool SynError(cmsIT8* it8, const char *Txt, ...)
-{
- char Buffer[256], ErrMsg[1024];
- va_list args;
-
- va_start(args, Txt);
- vsnprintf(Buffer, 255, Txt, args);
- Buffer[255] = 0;
- va_end(args);
-
- snprintf(ErrMsg, 1023, "%s: Line %d, %s", it8->FileStack[it8 ->IncludeSP]->FileName, it8->lineno, Buffer);
- ErrMsg[1023] = 0;
- it8->sy = SSYNERROR;
- cmsSignalError(it8 ->ContextID, cmsERROR_CORRUPTION_DETECTED, "%s", ErrMsg);
- return FALSE;
-}
-
-// Check if current symbol is same as specified. issue an error else.
-static
-cmsBool Check(cmsIT8* it8, SYMBOL sy, const char* Err)
-{
- if (it8 -> sy != sy)
- return SynError(it8, NoMeta(Err));
- return TRUE;
-}
-
-// Read Next character from stream
-static
-void NextCh(cmsIT8* it8)
-{
- if (it8 -> FileStack[it8 ->IncludeSP]->Stream) {
-
- it8 ->ch = fgetc(it8 ->FileStack[it8 ->IncludeSP]->Stream);
-
- if (feof(it8 -> FileStack[it8 ->IncludeSP]->Stream)) {
-
- if (it8 ->IncludeSP > 0) {
-
- fclose(it8 ->FileStack[it8->IncludeSP--]->Stream);
- it8 -> ch = ' '; // Whitespace to be ignored
-
- } else
- it8 ->ch = 0; // EOF
- }
- }
- else {
- it8->ch = *it8->Source;
- if (it8->ch) it8->Source++;
- }
-}
-
-
-// Try to see if current identifier is a keyword, if so return the referred symbol
-static
-SYMBOL BinSrchKey(const char *id, int NumKeys, const KEYWORD* TabKeys)
-{
- int l = 1;
- int r = NumKeys;
- int x, res;
-
- while (r >= l)
- {
- x = (l+r)/2;
- res = cmsstrcasecmp(id, TabKeys[x-1].id);
- if (res == 0) return TabKeys[x-1].sy;
- if (res < 0) r = x - 1;
- else l = x + 1;
- }
-
- return SUNDEFINED;
-}
-
-
-// 10 ^n
-static
-cmsFloat64Number xpow10(int n)
-{
- return pow(10, (cmsFloat64Number) n);
-}
-
-
-// Reads a Real number, tries to follow from integer number
-static
-void ReadReal(cmsIT8* it8, cmsInt32Number inum)
-{
- it8->dnum = (cmsFloat64Number)inum;
-
- while (isdigit(it8->ch)) {
-
- it8->dnum = (cmsFloat64Number)it8->dnum * 10.0 + (cmsFloat64Number)(it8->ch - '0');
- NextCh(it8);
- }
-
- if (it8->ch == '.') { // Decimal point
-
- cmsFloat64Number frac = 0.0; // fraction
- int prec = 0; // precision
-
- NextCh(it8); // Eats dec. point
-
- while (isdigit(it8->ch)) {
-
- frac = frac * 10.0 + (cmsFloat64Number)(it8->ch - '0');
- prec++;
- NextCh(it8);
- }
-
- it8->dnum = it8->dnum + (frac / xpow10(prec));
- }
-
- // Exponent, example 34.00E+20
- if (toupper(it8->ch) == 'E') {
-
- cmsInt32Number e;
- cmsInt32Number sgn;
-
- NextCh(it8); sgn = 1;
-
- if (it8->ch == '-') {
-
- sgn = -1; NextCh(it8);
- }
- else
- if (it8->ch == '+') {
-
- sgn = +1;
- NextCh(it8);
- }
-
- e = 0;
- while (isdigit(it8->ch)) {
-
- cmsInt32Number digit = (it8->ch - '0');
-
- if ((cmsFloat64Number)e * 10.0 + (cmsFloat64Number)digit < (cmsFloat64Number)+2147483647.0)
- e = e * 10 + digit;
-
- NextCh(it8);
- }
-
- e = sgn*e;
- it8->dnum = it8->dnum * xpow10(e);
- }
-}
-
-// Parses a float number
-// This can not call directly atof because it uses locale dependent
-// parsing, while CCMX files always use . as decimal separator
-static
-cmsFloat64Number ParseFloatNumber(const char *Buffer)
-{
- cmsFloat64Number dnum = 0.0;
- int sign = 1;
-
- // keep safe
- if (Buffer == NULL) return 0.0;
-
- if (*Buffer == '-' || *Buffer == '+') {
-
- sign = (*Buffer == '-') ? -1 : 1;
- Buffer++;
- }
-
-
- while (*Buffer && isdigit((int)*Buffer)) {
-
- dnum = dnum * 10.0 + (*Buffer - '0');
- if (*Buffer) Buffer++;
- }
-
- if (*Buffer == '.') {
-
- cmsFloat64Number frac = 0.0; // fraction
- int prec = 0; // precision
-
- if (*Buffer) Buffer++;
-
- while (*Buffer && isdigit((int)*Buffer)) {
-
- frac = frac * 10.0 + (*Buffer - '0');
- prec++;
- if (*Buffer) Buffer++;
- }
-
- dnum = dnum + (frac / xpow10(prec));
- }
-
- // Exponent, example 34.00E+20
- if (*Buffer && toupper(*Buffer) == 'E') {
-
- int e;
- int sgn;
-
- if (*Buffer) Buffer++;
- sgn = 1;
-
- if (*Buffer == '-') {
-
- sgn = -1;
- if (*Buffer) Buffer++;
- }
- else
- if (*Buffer == '+') {
-
- sgn = +1;
- if (*Buffer) Buffer++;
- }
-
- e = 0;
- while (*Buffer && isdigit((int)*Buffer)) {
-
- cmsInt32Number digit = (*Buffer - '0');
-
- if ((cmsFloat64Number)e * 10.0 + digit < (cmsFloat64Number)+2147483647.0)
- e = e * 10 + digit;
-
- if (*Buffer) Buffer++;
- }
-
- e = sgn*e;
- dnum = dnum * xpow10(e);
- }
-
- return sign * dnum;
-}
-
-
-// Reads a string, special case to avoid infinite recursion on .include
-static
-void InStringSymbol(cmsIT8* it8)
-{
- while (isseparator(it8->ch))
- NextCh(it8);
-
- if (it8->ch == '\'' || it8->ch == '\"')
- {
- int sng;
-
- sng = it8->ch;
- StringClear(it8->str);
-
- NextCh(it8);
-
- while (it8->ch != sng) {
-
- if (it8->ch == '\n' || it8->ch == '\r' || it8->ch == 0) break;
- else {
- StringAppend(it8->str, (char)it8->ch);
- NextCh(it8);
- }
- }
-
- it8->sy = SSTRING;
- NextCh(it8);
- }
- else
- SynError(it8, "String expected");
-
-}
-
-// Reads next symbol
-static
-void InSymbol(cmsIT8* it8)
-{
- SYMBOL key;
-
- do {
-
- while (isseparator(it8->ch))
- NextCh(it8);
-
- if (isfirstidchar(it8->ch)) { // Identifier
-
- StringClear(it8->id);
-
- do {
-
- StringAppend(it8->id, (char) it8->ch);
-
- NextCh(it8);
-
- } while (isidchar(it8->ch));
-
-
- key = BinSrchKey(StringPtr(it8->id),
- it8->IsCUBE ? NUMKEYS_CUBE : NUMKEYS_IT8,
- it8->IsCUBE ? TabKeysCUBE : TabKeysIT8);
- if (key == SUNDEFINED) it8->sy = SIDENT;
- else it8->sy = key;
-
- }
- else // Is a number?
- if (isdigit(it8->ch) || it8->ch == '.' || it8->ch == '-' || it8->ch == '+')
- {
- int sign = 1;
-
- if (it8->ch == '-') {
- sign = -1;
- NextCh(it8);
- }
-
- it8->inum = 0;
- it8->sy = SINUM;
-
- if (it8->ch == '0') { // 0xnnnn (Hexa) or 0bnnnn (Binary)
-
- NextCh(it8);
- if (toupper(it8->ch) == 'X') {
-
- int j;
-
- NextCh(it8);
- while (isxdigit(it8->ch))
- {
- it8->ch = toupper(it8->ch);
- if (it8->ch >= 'A' && it8->ch <= 'F') j = it8->ch -'A'+10;
- else j = it8->ch - '0';
-
- if ((cmsFloat64Number) it8->inum * 16.0 + (cmsFloat64Number) j > (cmsFloat64Number)+2147483647.0)
- {
- SynError(it8, "Invalid hexadecimal number");
- it8->sy = SEOF;
- return;
- }
-
- it8->inum = it8->inum * 16 + j;
- NextCh(it8);
- }
- return;
- }
-
- if (toupper(it8->ch) == 'B') { // Binary
-
- int j;
-
- NextCh(it8);
- while (it8->ch == '0' || it8->ch == '1')
- {
- j = it8->ch - '0';
-
- if ((cmsFloat64Number) it8->inum * 2.0 + j > (cmsFloat64Number)+2147483647.0)
- {
- SynError(it8, "Invalid binary number");
- it8->sy = SEOF;
- return;
- }
-
- it8->inum = it8->inum * 2 + j;
- NextCh(it8);
- }
- return;
- }
- }
-
-
- while (isdigit(it8->ch)) {
-
- cmsInt32Number digit = (it8->ch - '0');
-
- if ((cmsFloat64Number) it8->inum * 10.0 + (cmsFloat64Number) digit > (cmsFloat64Number) +2147483647.0) {
- ReadReal(it8, it8->inum);
- it8->sy = SDNUM;
- it8->dnum *= sign;
- return;
- }
-
- it8->inum = it8->inum * 10 + digit;
- NextCh(it8);
- }
-
- if (it8->ch == '.') {
-
- ReadReal(it8, it8->inum);
- it8->sy = SDNUM;
- it8->dnum *= sign;
- return;
- }
-
- it8 -> inum *= sign;
-
- // Special case. Numbers followed by letters are taken as identifiers
-
- if (isidchar(it8 ->ch)) {
-
- char buffer[127];
-
- if (it8 ->sy == SINUM) {
-
- snprintf(buffer, sizeof(buffer), "%d", it8->inum);
- }
- else {
-
- snprintf(buffer, sizeof(buffer), it8 ->DoubleFormatter, it8->dnum);
- }
-
- StringClear(it8->id);
- StringCat(it8->id, buffer);
-
- do {
-
- StringAppend(it8->id, (char) it8->ch);
-
- NextCh(it8);
-
- } while (isidchar(it8->ch));
-
- it8->sy = SIDENT;
- }
- return;
-
- }
- else
- switch ((int) it8->ch) {
-
- // Eof stream markers
- case '\x1a':
- case 0:
- case -1:
- it8->sy = SEOF;
- break;
-
-
- // Next line
- case '\r':
- NextCh(it8);
- if (it8->ch == '\n')
- NextCh(it8);
- it8->sy = SEOLN;
- it8->lineno++;
- break;
-
- case '\n':
- NextCh(it8);
- it8->sy = SEOLN;
- it8->lineno++;
- break;
-
- // Comment
- case '#':
- NextCh(it8);
- while (it8->ch && it8->ch != '\n' && it8->ch != '\r')
- NextCh(it8);
-
- it8->sy = SCOMMENT;
- break;
-
- // String.
- case '\'':
- case '\"':
- InStringSymbol(it8);
- break;
-
-
- default:
- SynError(it8, "Unrecognized character: 0x%x", it8 ->ch);
- it8->sy = SEOF;
- return;
- }
-
- } while (it8->sy == SCOMMENT);
-
- // Handle the include special token
-
- if (it8 -> sy == SINCLUDE) {
-
- FILECTX* FileNest;
-
- if(it8 -> IncludeSP >= (MAXINCLUDE-1)) {
-
- SynError(it8, "Too many recursion levels");
- it8->sy = SEOF;
- return;
- }
-
- InStringSymbol(it8);
- if (!Check(it8, SSTRING, "Filename expected"))
- {
- it8->sy = SEOF;
- return;
- }
-
- FileNest = it8 -> FileStack[it8 -> IncludeSP + 1];
- if(FileNest == NULL) {
-
- FileNest = it8 ->FileStack[it8 -> IncludeSP + 1] = (FILECTX*)AllocChunk(it8, sizeof(FILECTX));
- if (FileNest == NULL) {
- SynError(it8, "Out of memory");
- it8->sy = SEOF;
- return;
- }
- }
-
- if (BuildAbsolutePath(StringPtr(it8->str),
- it8->FileStack[it8->IncludeSP]->FileName,
- FileNest->FileName, cmsMAX_PATH-1) == FALSE) {
- SynError(it8, "File path too long");
- it8->sy = SEOF;
- return;
- }
-
- FileNest->Stream = fopen(FileNest->FileName, "rt");
- if (FileNest->Stream == NULL) {
-
- SynError(it8, "File %s not found", FileNest->FileName);
- it8->sy = SEOF;
- return;
- }
- it8->IncludeSP++;
-
- it8 ->ch = ' ';
- InSymbol(it8);
- }
-
-}
-
-// Checks end of line separator
-static
-cmsBool CheckEOLN(cmsIT8* it8)
-{
- if (!Check(it8, SEOLN, "Expected separator")) return FALSE;
- while (it8 -> sy == SEOLN)
- InSymbol(it8);
- return TRUE;
-
-}
-
-// Skip a symbol
-
-static
-void Skip(cmsIT8* it8, SYMBOL sy)
-{
- if (it8->sy == sy && it8->sy != SEOF)
- InSymbol(it8);
-}
-
-
-// Skip multiple EOLN
-static
-void SkipEOLN(cmsIT8* it8)
-{
- while (it8->sy == SEOLN) {
- InSymbol(it8);
- }
-}
-
-
-// Returns a string holding current value
-static
-cmsBool GetVal(cmsIT8* it8, char* Buffer, cmsUInt32Number max, const char* ErrorTitle)
-{
- switch (it8->sy) {
-
- case SEOLN: // Empty value
- Buffer[0]=0;
- break;
- case SIDENT: strncpy(Buffer, StringPtr(it8->id), max);
- Buffer[max-1]=0;
- break;
- case SINUM: snprintf(Buffer, max, "%d", it8 -> inum); break;
- case SDNUM: snprintf(Buffer, max, it8->DoubleFormatter, it8 -> dnum); break;
- case SSTRING: strncpy(Buffer, StringPtr(it8->str), max);
- Buffer[max-1] = 0;
- break;
-
-
- default:
- return SynError(it8, "%s", ErrorTitle);
- }
-
- Buffer[max] = 0;
- return TRUE;
-}
-
-// ---------------------------------------------------------- Table
-
-static
-TABLE* GetTable(cmsIT8* it8)
-{
- if ((it8 -> nTable >= it8 ->TablesCount)) {
-
- SynError(it8, "Table %d out of sequence", it8 -> nTable);
- return it8 -> Tab;
- }
-
- return it8 ->Tab + it8 ->nTable;
-}
-
-// ---------------------------------------------------------- Memory management
-
-
-// Frees an allocator and owned memory
-void CMSEXPORT cmsIT8Free(cmsHANDLE hIT8)
-{
- cmsIT8* it8 = (cmsIT8*) hIT8;
-
- if (it8 == NULL)
- return;
-
- if (it8->MemorySink) {
-
- OWNEDMEM* p;
- OWNEDMEM* n;
-
- for (p = it8->MemorySink; p != NULL; p = n) {
-
- n = p->Next;
- if (p->Ptr) _cmsFree(it8 ->ContextID, p->Ptr);
- _cmsFree(it8 ->ContextID, p);
- }
- }
-
- if (it8->MemoryBlock)
- _cmsFree(it8 ->ContextID, it8->MemoryBlock);
-
- _cmsFree(it8 ->ContextID, it8);
-}
-
-
-// Allocates a chunk of data, keep linked list
-static
-void* AllocBigBlock(cmsIT8* it8, cmsUInt32Number size)
-{
- OWNEDMEM* ptr1;
- void* ptr = _cmsMallocZero(it8->ContextID, size);
-
- if (ptr != NULL) {
-
- ptr1 = (OWNEDMEM*) _cmsMallocZero(it8 ->ContextID, sizeof(OWNEDMEM));
-
- if (ptr1 == NULL) {
-
- _cmsFree(it8 ->ContextID, ptr);
- return NULL;
- }
-
- ptr1-> Ptr = ptr;
- ptr1-> Next = it8 -> MemorySink;
- it8 -> MemorySink = ptr1;
- }
-
- return ptr;
-}
-
-
-// Suballocator.
-static
-void* AllocChunk(cmsIT8* it8, cmsUInt32Number size)
-{
- cmsUInt32Number Free = it8 ->Allocator.BlockSize - it8 ->Allocator.Used;
- cmsUInt8Number* ptr;
-
- size = _cmsALIGNMEM(size);
-
- if (size > Free) {
-
- if (it8 -> Allocator.BlockSize == 0)
-
- it8 -> Allocator.BlockSize = 20*1024;
- else
- it8 ->Allocator.BlockSize *= 2;
-
- if (it8 ->Allocator.BlockSize < size)
- it8 ->Allocator.BlockSize = size;
-
- it8 ->Allocator.Used = 0;
- it8 ->Allocator.Block = (cmsUInt8Number*) AllocBigBlock(it8, it8 ->Allocator.BlockSize);
- }
-
- if (it8->Allocator.Block == NULL)
- return NULL;
-
- ptr = it8 ->Allocator.Block + it8 ->Allocator.Used;
- it8 ->Allocator.Used += size;
-
- return (void*) ptr;
-
-}
-
-
-// Allocates a string
-static
-char *AllocString(cmsIT8* it8, const char* str)
-{
- cmsUInt32Number Size = (cmsUInt32Number) strlen(str)+1;
- char *ptr;
-
-
- ptr = (char *) AllocChunk(it8, Size);
- if (ptr) memcpy(ptr, str, Size-1);
-
- return ptr;
-}
-
-// Searches through linked list
-
-static
-cmsBool IsAvailableOnList(KEYVALUE* p, const char* Key, const char* Subkey, KEYVALUE** LastPtr)
-{
- if (LastPtr) *LastPtr = p;
-
- for (; p != NULL; p = p->Next) {
-
- if (LastPtr) *LastPtr = p;
-
- if (*Key != '#') { // Comments are ignored
-
- if (cmsstrcasecmp(Key, p->Keyword) == 0)
- break;
- }
- }
-
- if (p == NULL)
- return FALSE;
-
- if (Subkey == 0)
- return TRUE;
-
- for (; p != NULL; p = p->NextSubkey) {
-
- if (p ->Subkey == NULL) continue;
-
- if (LastPtr) *LastPtr = p;
-
- if (cmsstrcasecmp(Subkey, p->Subkey) == 0)
- return TRUE;
- }
-
- return FALSE;
-}
-
-
-
-// Add a property into a linked list
-static
-KEYVALUE* AddToList(cmsIT8* it8, KEYVALUE** Head, const char *Key, const char *Subkey, const char* xValue, WRITEMODE WriteAs)
-{
- KEYVALUE* p;
- KEYVALUE* last;
-
-
- // Check if property is already in list
-
- if (IsAvailableOnList(*Head, Key, Subkey, &p)) {
-
- // This may work for editing properties
-
- if (cmsstrcasecmp(Key, "NUMBER_OF_FIELDS") == 0 ||
- cmsstrcasecmp(Key, "NUMBER_OF_SETS") == 0) {
-
- SynError(it8, "duplicate key <%s>", Key);
- return NULL;
- }
- }
- else {
-
- last = p;
-
- // Allocate the container
- p = (KEYVALUE*) AllocChunk(it8, sizeof(KEYVALUE));
- if (p == NULL)
- {
- SynError(it8, "AddToList: out of memory");
- return NULL;
- }
-
- // Store name and value
- p->Keyword = AllocString(it8, Key);
- p->Subkey = (Subkey == NULL) ? NULL : AllocString(it8, Subkey);
-
- // Keep the container in our list
- if (*Head == NULL) {
- *Head = p;
- }
- else
- {
- if (Subkey != NULL && last != NULL) {
-
- last->NextSubkey = p;
-
- // If Subkey is not null, then last is the last property with the same key,
- // but not necessarily is the last property in the list, so we need to move
- // to the actual list end
- while (last->Next != NULL)
- last = last->Next;
- }
-
- if (last != NULL) last->Next = p;
- }
-
- p->Next = NULL;
- p->NextSubkey = NULL;
- }
-
- p->WriteAs = WriteAs;
-
- if (xValue != NULL) {
-
- p->Value = AllocString(it8, xValue);
- }
- else {
- p->Value = NULL;
- }
-
- return p;
-}
-
-static
-KEYVALUE* AddAvailableProperty(cmsIT8* it8, const char* Key, WRITEMODE as)
-{
- return AddToList(it8, &it8->ValidKeywords, Key, NULL, NULL, as);
-}
-
-
-static
-KEYVALUE* AddAvailableSampleID(cmsIT8* it8, const char* Key)
-{
- return AddToList(it8, &it8->ValidSampleID, Key, NULL, NULL, WRITE_UNCOOKED);
-}
-
-
-static
-void AllocTable(cmsIT8* it8)
-{
- TABLE* t;
-
- t = it8 ->Tab + it8 ->TablesCount;
-
- t->HeaderList = NULL;
- t->DataFormat = NULL;
- t->Data = NULL;
-
- it8 ->TablesCount++;
-}
-
-
-cmsInt32Number CMSEXPORT cmsIT8SetTable(cmsHANDLE IT8, cmsUInt32Number nTable)
-{
- cmsIT8* it8 = (cmsIT8*) IT8;
-
- if (nTable >= it8 ->TablesCount) {
-
- if (nTable == it8 ->TablesCount) {
-
- AllocTable(it8);
- }
- else {
- SynError(it8, "Table %d is out of sequence", nTable);
- return -1;
- }
- }
-
- it8 ->nTable = nTable;
-
- return (cmsInt32Number) nTable;
-}
-
-
-
-// Init an empty container
-cmsHANDLE CMSEXPORT cmsIT8Alloc(cmsContext ContextID)
-{
- cmsIT8* it8;
- cmsUInt32Number i;
-
- it8 = (cmsIT8*) _cmsMallocZero(ContextID, sizeof(cmsIT8));
- if (it8 == NULL) return NULL;
-
- AllocTable(it8);
-
- it8->MemoryBlock = NULL;
- it8->MemorySink = NULL;
-
- it8->IsCUBE = FALSE;
-
- it8 ->nTable = 0;
-
- it8->ContextID = ContextID;
- it8->Allocator.Used = 0;
- it8->Allocator.Block = NULL;
- it8->Allocator.BlockSize = 0;
-
- it8->ValidKeywords = NULL;
- it8->ValidSampleID = NULL;
-
- it8 -> sy = SUNDEFINED;
- it8 -> ch = ' ';
- it8 -> Source = NULL;
- it8 -> inum = 0;
- it8 -> dnum = 0.0;
-
- it8->FileStack[0] = (FILECTX*)AllocChunk(it8, sizeof(FILECTX));
- it8->IncludeSP = 0;
- it8 -> lineno = 1;
-
- it8->id = StringAlloc(it8, MAXSTR);
- it8->str = StringAlloc(it8, MAXSTR);
-
- strcpy(it8->DoubleFormatter, DEFAULT_DBL_FORMAT);
- cmsIT8SetSheetType((cmsHANDLE) it8, "CGATS.17");
-
- // Initialize predefined properties & data
-
- for (i=0; i < NUMPREDEFINEDPROPS; i++)
- AddAvailableProperty(it8, PredefinedProperties[i].id, PredefinedProperties[i].as);
-
- for (i=0; i < NUMPREDEFINEDSAMPLEID; i++)
- AddAvailableSampleID(it8, PredefinedSampleID[i]);
-
-
- return (cmsHANDLE) it8;
-}
-
-
-const char* CMSEXPORT cmsIT8GetSheetType(cmsHANDLE hIT8)
-{
- return GetTable((cmsIT8*) hIT8)->SheetType;
-}
-
-cmsBool CMSEXPORT cmsIT8SetSheetType(cmsHANDLE hIT8, const char* Type)
-{
- TABLE* t = GetTable((cmsIT8*) hIT8);
-
- strncpy(t ->SheetType, Type, MAXSTR-1);
- t ->SheetType[MAXSTR-1] = 0;
- return TRUE;
-}
-
-cmsBool CMSEXPORT cmsIT8SetComment(cmsHANDLE hIT8, const char* Val)
-{
- cmsIT8* it8 = (cmsIT8*) hIT8;
-
- if (!Val) return FALSE;
- if (!*Val) return FALSE;
-
- return AddToList(it8, &GetTable(it8)->HeaderList, "# ", NULL, Val, WRITE_UNCOOKED) != NULL;
-}
-
-// Sets a property
-cmsBool CMSEXPORT cmsIT8SetPropertyStr(cmsHANDLE hIT8, const char* Key, const char *Val)
-{
- cmsIT8* it8 = (cmsIT8*) hIT8;
-
- if (!Val) return FALSE;
- if (!*Val) return FALSE;
-
- return AddToList(it8, &GetTable(it8)->HeaderList, Key, NULL, Val, WRITE_STRINGIFY) != NULL;
-}
-
-cmsBool CMSEXPORT cmsIT8SetPropertyDbl(cmsHANDLE hIT8, const char* cProp, cmsFloat64Number Val)
-{
- cmsIT8* it8 = (cmsIT8*) hIT8;
- char Buffer[1024];
-
- snprintf(Buffer, 1023, it8->DoubleFormatter, Val);
-
- return AddToList(it8, &GetTable(it8)->HeaderList, cProp, NULL, Buffer, WRITE_UNCOOKED) != NULL;
-}
-
-cmsBool CMSEXPORT cmsIT8SetPropertyHex(cmsHANDLE hIT8, const char* cProp, cmsUInt32Number Val)
-{
- cmsIT8* it8 = (cmsIT8*) hIT8;
- char Buffer[1024];
-
- snprintf(Buffer, 1023, "%u", Val);
-
- return AddToList(it8, &GetTable(it8)->HeaderList, cProp, NULL, Buffer, WRITE_HEXADECIMAL) != NULL;
-}
-
-cmsBool CMSEXPORT cmsIT8SetPropertyUncooked(cmsHANDLE hIT8, const char* Key, const char* Buffer)
-{
- cmsIT8* it8 = (cmsIT8*) hIT8;
-
- return AddToList(it8, &GetTable(it8)->HeaderList, Key, NULL, Buffer, WRITE_UNCOOKED) != NULL;
-}
-
-cmsBool CMSEXPORT cmsIT8SetPropertyMulti(cmsHANDLE hIT8, const char* Key, const char* SubKey, const char *Buffer)
-{
- cmsIT8* it8 = (cmsIT8*) hIT8;
-
- return AddToList(it8, &GetTable(it8)->HeaderList, Key, SubKey, Buffer, WRITE_PAIR) != NULL;
-}
-
-// Gets a property
-const char* CMSEXPORT cmsIT8GetProperty(cmsHANDLE hIT8, const char* Key)
-{
- cmsIT8* it8 = (cmsIT8*) hIT8;
- KEYVALUE* p;
-
- if (IsAvailableOnList(GetTable(it8) -> HeaderList, Key, NULL, &p))
- {
- return p -> Value;
- }
- return NULL;
-}
-
-
-cmsFloat64Number CMSEXPORT cmsIT8GetPropertyDbl(cmsHANDLE hIT8, const char* cProp)
-{
- const char *v = cmsIT8GetProperty(hIT8, cProp);
-
- if (v == NULL) return 0.0;
-
- return ParseFloatNumber(v);
-}
-
-const char* CMSEXPORT cmsIT8GetPropertyMulti(cmsHANDLE hIT8, const char* Key, const char *SubKey)
-{
- cmsIT8* it8 = (cmsIT8*) hIT8;
- KEYVALUE* p;
-
- if (IsAvailableOnList(GetTable(it8) -> HeaderList, Key, SubKey, &p)) {
- return p -> Value;
- }
- return NULL;
-}
-
-// ----------------------------------------------------------------- Datasets
-
-// A safe atoi that returns 0 when NULL input is given
-static
-cmsInt32Number satoi(const char* b)
-{
- int n;
-
- if (b == NULL) return 0;
-
- n = atoi(b);
- if (n > 0x7fffffffL) return 0x7fffffffL;
- if (n < -0x7ffffffeL) return -0x7ffffffeL;
-
- return (cmsInt32Number)n;
-}
-
-
-static
-cmsBool AllocateDataFormat(cmsIT8* it8)
-{
- TABLE* t = GetTable(it8);
-
- if (t -> DataFormat) return TRUE; // Already allocated
-
- t -> nSamples = satoi(cmsIT8GetProperty(it8, "NUMBER_OF_FIELDS"));
-
- if (t -> nSamples <= 0) {
-
- SynError(it8, "AllocateDataFormat: Unknown NUMBER_OF_FIELDS");
- return FALSE;
- }
-
- t -> DataFormat = (char**) AllocChunk (it8, ((cmsUInt32Number) t->nSamples + 1) * sizeof(char *));
- if (t->DataFormat == NULL) {
-
- SynError(it8, "AllocateDataFormat: Unable to allocate dataFormat array");
- return FALSE;
- }
-
- return TRUE;
-}
-
-static
-const char *GetDataFormat(cmsIT8* it8, int n)
-{
- TABLE* t = GetTable(it8);
-
- if (t->DataFormat)
- return t->DataFormat[n];
-
- return NULL;
-}
-
-static
-cmsBool SetDataFormat(cmsIT8* it8, int n, const char *label)
-{
- TABLE* t = GetTable(it8);
-
- if (!t->DataFormat) {
-
- if (!AllocateDataFormat(it8))
- return FALSE;
- }
-
- if (n > t -> nSamples) {
- SynError(it8, "More than NUMBER_OF_FIELDS fields.");
- return FALSE;
- }
-
- if (t->DataFormat) {
- t->DataFormat[n] = AllocString(it8, label);
- if (t->DataFormat[n] == NULL) return FALSE;
- }
-
- return TRUE;
-}
-
-
-cmsBool CMSEXPORT cmsIT8SetDataFormat(cmsHANDLE h, int n, const char *Sample)
-{
- cmsIT8* it8 = (cmsIT8*)h;
- return SetDataFormat(it8, n, Sample);
-}
-
-// Convert to binary
-static
-const char* satob(const char* v)
-{
- cmsUInt32Number x;
- static char buf[33];
- char *s = buf + 33;
-
- if (v == NULL) return "0";
-
- x = atoi(v);
- *--s = 0;
- if (!x) *--s = '0';
- for (; x; x /= 2) *--s = '0' + x%2;
-
- return s;
-}
-
-
-static
-cmsBool AllocateDataSet(cmsIT8* it8)
-{
- TABLE* t = GetTable(it8);
-
- if (t -> Data) return TRUE; // Already allocated
-
- t-> nSamples = satoi(cmsIT8GetProperty(it8, "NUMBER_OF_FIELDS"));
- t-> nPatches = satoi(cmsIT8GetProperty(it8, "NUMBER_OF_SETS"));
-
- if (t -> nSamples < 0 || t->nSamples > 0x7ffe || t->nPatches < 0 || t->nPatches > 0x7ffe)
- {
- SynError(it8, "AllocateDataSet: too much data");
- return FALSE;
- }
- else {
- // Some dumb analizers warns of possible overflow here, just take a look couple of lines above.
- t->Data = (char**)AllocChunk(it8, ((cmsUInt32Number)t->nSamples + 1) * ((cmsUInt32Number)t->nPatches + 1) * sizeof(char*));
- if (t->Data == NULL) {
-
- SynError(it8, "AllocateDataSet: Unable to allocate data array");
- return FALSE;
- }
- }
-
- return TRUE;
-}
-
-static
-char* GetData(cmsIT8* it8, int nSet, int nField)
-{
- TABLE* t = GetTable(it8);
- int nSamples = t -> nSamples;
- int nPatches = t -> nPatches;
-
- if (nSet < 0 || nSet >= nPatches || nField < 0 || nField >= nSamples)
- return NULL;
-
- if (!t->Data) return NULL;
- return t->Data [nSet * nSamples + nField];
-}
-
-static
-cmsBool SetData(cmsIT8* it8, int nSet, int nField, const char *Val)
-{
- TABLE* t = GetTable(it8);
-
- if (!t->Data) {
- if (!AllocateDataSet(it8)) return FALSE;
- }
-
- if (!t->Data) return FALSE;
-
- if (nSet > t -> nPatches || nSet < 0) {
-
- return SynError(it8, "Patch %d out of range, there are %d patches", nSet, t -> nPatches);
- }
-
- if (nField > t ->nSamples || nField < 0) {
- return SynError(it8, "Sample %d out of range, there are %d samples", nField, t ->nSamples);
-
- }
-
- t->Data [nSet * t -> nSamples + nField] = AllocString(it8, Val);
- return TRUE;
-}
-
-
-// --------------------------------------------------------------- File I/O
-
-
-// Writes a string to file
-static
-void WriteStr(SAVESTREAM* f, const char *str)
-{
- cmsUInt32Number len;
-
- if (str == NULL)
- str = " ";
-
- // Length to write
- len = (cmsUInt32Number) strlen(str);
- f ->Used += len;
-
-
- if (f ->stream) { // Should I write it to a file?
-
- if (fwrite(str, 1, len, f->stream) != len) {
- cmsSignalError(0, cmsERROR_WRITE, "Write to file error in CGATS parser");
- return;
- }
-
- }
- else { // Or to a memory block?
-
- if (f ->Base) { // Am I just counting the bytes?
-
- if (f ->Used > f ->Max) {
-
- cmsSignalError(0, cmsERROR_WRITE, "Write to memory overflows in CGATS parser");
- return;
- }
-
- memmove(f ->Ptr, str, len);
- f->Ptr += len;
- }
-
- }
-}
-
-
-// Write formatted
-
-static
-void Writef(SAVESTREAM* f, const char* frm, ...)
-{
- char Buffer[4096];
- va_list args;
-
- va_start(args, frm);
- vsnprintf(Buffer, 4095, frm, args);
- Buffer[4095] = 0;
- WriteStr(f, Buffer);
- va_end(args);
-
-}
-
-// Writes full header
-static
-void WriteHeader(cmsIT8* it8, SAVESTREAM* fp)
-{
- KEYVALUE* p;
- TABLE* t = GetTable(it8);
-
- // Writes the type
- WriteStr(fp, t->SheetType);
- WriteStr(fp, "\n");
-
- for (p = t->HeaderList; (p != NULL); p = p->Next)
- {
- if (*p ->Keyword == '#') {
-
- char* Pt;
-
- WriteStr(fp, "#\n# ");
- for (Pt = p ->Value; *Pt; Pt++) {
-
-
- Writef(fp, "%c", *Pt);
-
- if (*Pt == '\n') {
- WriteStr(fp, "# ");
- }
- }
-
- WriteStr(fp, "\n#\n");
- continue;
- }
-
-
- if (!IsAvailableOnList(it8-> ValidKeywords, p->Keyword, NULL, NULL)) {
-
-#ifdef CMS_STRICT_CGATS
- WriteStr(fp, "KEYWORD\t\"");
- WriteStr(fp, p->Keyword);
- WriteStr(fp, "\"\n");
-#endif
-
- AddAvailableProperty(it8, p->Keyword, WRITE_UNCOOKED);
- }
-
- WriteStr(fp, p->Keyword);
- if (p->Value) {
-
- switch (p ->WriteAs) {
-
- case WRITE_UNCOOKED:
- Writef(fp, "\t%s", p ->Value);
- break;
-
- case WRITE_STRINGIFY:
- Writef(fp, "\t\"%s\"", p->Value );
- break;
-
- case WRITE_HEXADECIMAL:
- Writef(fp, "\t0x%X", satoi(p ->Value));
- break;
-
- case WRITE_BINARY:
- Writef(fp, "\t0b%s", satob(p ->Value));
- break;
-
- case WRITE_PAIR:
- Writef(fp, "\t\"%s,%s\"", p->Subkey, p->Value);
- break;
-
- default: SynError(it8, "Unknown write mode %d", p ->WriteAs);
- return;
- }
- }
-
- WriteStr (fp, "\n");
- }
-
-}
-
-
-// Writes the data format
-static
-void WriteDataFormat(SAVESTREAM* fp, cmsIT8* it8)
-{
- int i, nSamples;
- TABLE* t = GetTable(it8);
-
- if (!t -> DataFormat) return;
-
- WriteStr(fp, "BEGIN_DATA_FORMAT\n");
- WriteStr(fp, " ");
- nSamples = satoi(cmsIT8GetProperty(it8, "NUMBER_OF_FIELDS"));
-
- if (nSamples <= t->nSamples) {
-
- for (i = 0; i < nSamples; i++) {
-
- WriteStr(fp, t->DataFormat[i]);
- WriteStr(fp, ((i == (nSamples - 1)) ? "\n" : "\t"));
- }
- }
-
- WriteStr (fp, "END_DATA_FORMAT\n");
-}
-
-
-// Writes data array
-static
-void WriteData(SAVESTREAM* fp, cmsIT8* it8)
-{
- int i, j, nPatches;
- TABLE* t = GetTable(it8);
-
- if (!t->Data) return;
-
- WriteStr (fp, "BEGIN_DATA\n");
-
- nPatches = satoi(cmsIT8GetProperty(it8, "NUMBER_OF_SETS"));
-
- if (nPatches <= t->nPatches) {
-
- for (i = 0; i < nPatches; i++) {
-
- WriteStr(fp, " ");
-
- for (j = 0; j < t->nSamples; j++) {
-
- char* ptr = t->Data[i * t->nSamples + j];
-
- if (ptr == NULL) WriteStr(fp, "\"\"");
- else {
- // If value contains whitespace, enclose within quote
-
- if (strchr(ptr, ' ') != NULL) {
-
- WriteStr(fp, "\"");
- WriteStr(fp, ptr);
- WriteStr(fp, "\"");
- }
- else
- WriteStr(fp, ptr);
- }
-
- WriteStr(fp, ((j == (t->nSamples - 1)) ? "\n" : "\t"));
- }
- }
- }
- WriteStr (fp, "END_DATA\n");
-}
-
-
-
-// Saves whole file
-cmsBool CMSEXPORT cmsIT8SaveToFile(cmsHANDLE hIT8, const char* cFileName)
-{
- SAVESTREAM sd;
- cmsUInt32Number i;
- cmsIT8* it8 = (cmsIT8*) hIT8;
-
- memset(&sd, 0, sizeof(sd));
-
- sd.stream = fopen(cFileName, "wt");
- if (!sd.stream) return FALSE;
-
- for (i=0; i < it8 ->TablesCount; i++) {
-
- TABLE* t;
-
- if (cmsIT8SetTable(hIT8, i) < 0) goto Error;
-
- /**
- * Check for wrong data
- */
- t = GetTable(it8);
- if (t->Data == NULL) goto Error;
- if (t->DataFormat == NULL) goto Error;
-
- WriteHeader(it8, &sd);
- WriteDataFormat(&sd, it8);
- WriteData(&sd, it8);
- }
-
- if (fclose(sd.stream) != 0) return FALSE;
- return TRUE;
-
-Error:
- fclose(sd.stream);
- return FALSE;
-
-}
-
-
-// Saves to memory
-cmsBool CMSEXPORT cmsIT8SaveToMem(cmsHANDLE hIT8, void *MemPtr, cmsUInt32Number* BytesNeeded)
-{
- SAVESTREAM sd;
- cmsUInt32Number i;
- cmsIT8* it8 = (cmsIT8*) hIT8;
-
- memset(&sd, 0, sizeof(sd));
-
- sd.stream = NULL;
- sd.Base = (cmsUInt8Number*) MemPtr;
- sd.Ptr = sd.Base;
-
- sd.Used = 0;
-
- if (sd.Base && (*BytesNeeded > 0)) {
-
- sd.Max = (*BytesNeeded) - 1; // Write to memory?
- }
- else
- sd.Max = 0; // Just counting the needed bytes
-
- for (i=0; i < it8 ->TablesCount; i++) {
-
- cmsIT8SetTable(hIT8, i);
- WriteHeader(it8, &sd);
- WriteDataFormat(&sd, it8);
- WriteData(&sd, it8);
- }
-
- sd.Used++; // The \0 at the very end
-
- if (sd.Base)
- *sd.Ptr = 0;
-
- *BytesNeeded = sd.Used;
-
- return TRUE;
-}
-
-
-// -------------------------------------------------------------- Higher level parsing
-
-static
-cmsBool DataFormatSection(cmsIT8* it8)
-{
- int iField = 0;
- TABLE* t = GetTable(it8);
-
- InSymbol(it8); // Eats "BEGIN_DATA_FORMAT"
- CheckEOLN(it8);
-
- while (it8->sy != SEND_DATA_FORMAT &&
- it8->sy != SEOLN &&
- it8->sy != SEOF &&
- it8->sy != SSYNERROR) {
-
- if (it8->sy != SIDENT) {
-
- return SynError(it8, "Sample type expected");
- }
-
- if (!SetDataFormat(it8, iField, StringPtr(it8->id))) return FALSE;
- iField++;
-
- InSymbol(it8);
- SkipEOLN(it8);
- }
-
- SkipEOLN(it8);
- Skip(it8, SEND_DATA_FORMAT);
- SkipEOLN(it8);
-
- if (iField != t ->nSamples) {
- SynError(it8, "Count mismatch. NUMBER_OF_FIELDS was %d, found %d\n", t ->nSamples, iField);
-
-
- }
-
- return TRUE;
-}
-
-
-
-static
-cmsBool DataSection (cmsIT8* it8)
-{
- int iField = 0;
- int iSet = 0;
- char Buffer[256];
- TABLE* t = GetTable(it8);
-
- InSymbol(it8); // Eats "BEGIN_DATA"
- CheckEOLN(it8);
-
- if (!t->Data) {
- if (!AllocateDataSet(it8)) return FALSE;
- }
-
- while (it8->sy != SEND_DATA && it8->sy != SEOF)
- {
- if (iField >= t -> nSamples) {
- iField = 0;
- iSet++;
-
- }
-
- if (it8->sy != SEND_DATA && it8->sy != SEOF) {
-
- switch (it8->sy)
- {
-
- // To keep very long data
- case SIDENT:
- if (!SetData(it8, iSet, iField, StringPtr(it8->id)))
- return FALSE;
- break;
-
- case SSTRING:
- if (!SetData(it8, iSet, iField, StringPtr(it8->str)))
- return FALSE;
- break;
-
- default:
-
- if (!GetVal(it8, Buffer, 255, "Sample data expected"))
- return FALSE;
-
- if (!SetData(it8, iSet, iField, Buffer))
- return FALSE;
- }
-
- iField++;
-
- InSymbol(it8);
- SkipEOLN(it8);
- }
- }
-
- SkipEOLN(it8);
- Skip(it8, SEND_DATA);
- SkipEOLN(it8);
-
- // Check for data completion.
-
- if ((iSet+1) != t -> nPatches)
- return SynError(it8, "Count mismatch. NUMBER_OF_SETS was %d, found %d\n", t ->nPatches, iSet+1);
-
- return TRUE;
-}
-
-
-
-
-static
-cmsBool HeaderSection(cmsIT8* it8)
-{
- char VarName[MAXID];
- char Buffer[MAXSTR];
- KEYVALUE* Key;
-
- while (it8->sy != SEOF &&
- it8->sy != SSYNERROR &&
- it8->sy != SBEGIN_DATA_FORMAT &&
- it8->sy != SBEGIN_DATA) {
-
-
- switch (it8 -> sy) {
-
- case SKEYWORD:
- InSymbol(it8);
- if (!GetVal(it8, Buffer, MAXSTR-1, "Keyword expected")) return FALSE;
- if (!AddAvailableProperty(it8, Buffer, WRITE_UNCOOKED)) return FALSE;
- InSymbol(it8);
- break;
-
-
- case SDATA_FORMAT_ID:
- InSymbol(it8);
- if (!GetVal(it8, Buffer, MAXSTR-1, "Keyword expected")) return FALSE;
- if (!AddAvailableSampleID(it8, Buffer)) return FALSE;
- InSymbol(it8);
- break;
-
-
- case SIDENT:
- strncpy(VarName, StringPtr(it8->id), MAXID - 1);
- VarName[MAXID - 1] = 0;
-
- if (!IsAvailableOnList(it8->ValidKeywords, VarName, NULL, &Key)) {
-
-#ifdef CMS_STRICT_CGATS
- return SynError(it8, "Undefined keyword '%s'", VarName);
-#else
- Key = AddAvailableProperty(it8, VarName, WRITE_UNCOOKED);
- if (Key == NULL) return FALSE;
-#endif
- }
-
- InSymbol(it8);
- if (!GetVal(it8, Buffer, MAXSTR - 1, "Property data expected")) return FALSE;
-
- if (Key->WriteAs != WRITE_PAIR) {
- AddToList(it8, &GetTable(it8)->HeaderList, VarName, NULL, Buffer,
- (it8->sy == SSTRING) ? WRITE_STRINGIFY : WRITE_UNCOOKED);
- }
- else {
- const char *Subkey;
- char *Nextkey;
- if (it8->sy != SSTRING)
- return SynError(it8, "Invalid value '%s' for property '%s'.", Buffer, VarName);
-
- // chop the string as a list of "subkey, value" pairs, using ';' as a separator
- for (Subkey = Buffer; Subkey != NULL; Subkey = Nextkey)
- {
- char *Value, *temp;
-
- // identify token pair boundary
- Nextkey = (char*)strchr(Subkey, ';');
- if (Nextkey)
- *Nextkey++ = '\0';
-
- // for each pair, split the subkey and the value
- Value = (char*)strrchr(Subkey, ',');
- if (Value == NULL)
- return SynError(it8, "Invalid value for property '%s'.", VarName);
-
- // gobble the spaces before the coma, and the coma itself
- temp = Value++;
- do *temp-- = '\0'; while (temp >= Subkey && *temp == ' ');
-
- // gobble any space at the right
- temp = Value + strlen(Value) - 1;
- while (*temp == ' ') *temp-- = '\0';
-
- // trim the strings from the left
- Subkey += strspn(Subkey, " ");
- Value += strspn(Value, " ");
-
- if (Subkey[0] == 0 || Value[0] == 0)
- return SynError(it8, "Invalid value for property '%s'.", VarName);
- AddToList(it8, &GetTable(it8)->HeaderList, VarName, Subkey, Value, WRITE_PAIR);
- }
- }
-
- InSymbol(it8);
- break;
-
-
- case SEOLN: break;
-
- default:
- return SynError(it8, "expected keyword or identifier");
- }
-
- SkipEOLN(it8);
- }
-
- return TRUE;
-
-}
-
-
-static
-void ReadType(cmsIT8* it8, char* SheetTypePtr)
-{
- cmsInt32Number cnt = 0;
-
- // First line is a very special case.
-
- while (isseparator(it8->ch))
- NextCh(it8);
-
- while (it8->ch != '\r' && it8 ->ch != '\n' && it8->ch != '\t' && it8 -> ch != 0) {
-
- if (cnt++ < MAXSTR)
- *SheetTypePtr++= (char) it8 ->ch;
- NextCh(it8);
- }
-
- *SheetTypePtr = 0;
-}
-
-
-static
-cmsBool ParseIT8(cmsIT8* it8, cmsBool nosheet)
-{
- char* SheetTypePtr = it8 ->Tab[0].SheetType;
-
- if (nosheet == 0) {
- ReadType(it8, SheetTypePtr);
- }
-
- InSymbol(it8);
-
- SkipEOLN(it8);
-
- while (it8-> sy != SEOF &&
- it8-> sy != SSYNERROR) {
-
- switch (it8 -> sy) {
-
- case SBEGIN_DATA_FORMAT:
- if (!DataFormatSection(it8)) return FALSE;
- break;
-
- case SBEGIN_DATA:
-
- if (!DataSection(it8)) return FALSE;
-
- if (it8 -> sy != SEOF) {
-
- AllocTable(it8);
- it8 ->nTable = it8 ->TablesCount - 1;
-
- // Read sheet type if present. We only support identifier and string.
- // <ident> <eoln> is a type string
- // anything else, is not a type string
- if (nosheet == 0) {
-
- if (it8 ->sy == SIDENT) {
-
- // May be a type sheet or may be a prop value statement. We cannot use insymbol in
- // this special case...
- while (isseparator(it8->ch))
- NextCh(it8);
-
- // If a newline is found, then this is a type string
- if (it8 ->ch == '\n' || it8->ch == '\r') {
-
- cmsIT8SetSheetType(it8, StringPtr(it8 ->id));
- InSymbol(it8);
- }
- else
- {
- // It is not. Just continue
- cmsIT8SetSheetType(it8, "");
- }
- }
- else
- // Validate quoted strings
- if (it8 ->sy == SSTRING) {
- cmsIT8SetSheetType(it8, StringPtr(it8 ->str));
- InSymbol(it8);
- }
- }
-
- }
- break;
-
- case SEOLN:
- SkipEOLN(it8);
- break;
-
- default:
- if (!HeaderSection(it8)) return FALSE;
- }
-
- }
-
- return (it8 -> sy != SSYNERROR);
-}
-
-
-
-// Init useful pointers
-
-static
-void CookPointers(cmsIT8* it8)
-{
- int idField, i;
- char* Fld;
- cmsUInt32Number j;
- cmsUInt32Number nOldTable = it8->nTable;
-
- for (j = 0; j < it8->TablesCount; j++) {
-
- TABLE* t = it8->Tab + j;
-
- t->SampleID = 0;
- it8->nTable = j;
-
- for (idField = 0; idField < t->nSamples; idField++)
- {
- if (t->DataFormat == NULL) {
- SynError(it8, "Undefined DATA_FORMAT");
- return;
- }
-
- Fld = t->DataFormat[idField];
- if (!Fld) continue;
-
-
- if (cmsstrcasecmp(Fld, "SAMPLE_ID") == 0) {
-
- t->SampleID = idField;
- }
-
- // "LABEL" is an extension. It keeps references to forward tables
-
- if ((cmsstrcasecmp(Fld, "LABEL") == 0) || Fld[0] == '$') {
-
- // Search for table references...
- for (i = 0; i < t->nPatches; i++) {
-
- char* Label = GetData(it8, i, idField);
-
- if (Label) {
-
- cmsUInt32Number k;
-
- // This is the label, search for a table containing
- // this property
-
- for (k = 0; k < it8->TablesCount; k++) {
-
- TABLE* Table = it8->Tab + k;
- KEYVALUE* p;
-
- if (IsAvailableOnList(Table->HeaderList, Label, NULL, &p)) {
-
- // Available, keep type and table
- char Buffer[256];
-
- char* Type = p->Value;
- int nTable = (int)k;
-
- snprintf(Buffer, 255, "%s %d %s", Label, nTable, Type);
-
- SetData(it8, i, idField, Buffer);
- }
- }
- }
- }
- }
- }
- }
-
- it8->nTable = nOldTable;
-}
-
-// Try to infere if the file is a CGATS/IT8 file at all. Read first line
-// that should be something like some printable characters plus a \n
-// returns 0 if this is not like a CGATS, or an integer otherwise. This integer is the number of words in first line?
-static
-int IsMyBlock(const cmsUInt8Number* Buffer, cmsUInt32Number n)
-{
- int words = 1, space = 0, quot = 0;
- cmsUInt32Number i;
-
- if (n < 10) return 0; // Too small
-
- if (n > 132)
- n = 132;
-
- for (i = 1; i < n; i++) {
-
- switch(Buffer[i])
- {
- case '\n':
- case '\r':
- return ((quot == 1) || (words > 2)) ? 0 : words;
- case '\t':
- case ' ':
- if(!quot && !space)
- space = 1;
- break;
- case '\"':
- quot = !quot;
- break;
- default:
- if (Buffer[i] < 32) return 0;
- if (Buffer[i] > 127) return 0;
- words += space;
- space = 0;
- break;
- }
- }
-
- return 0;
-}
-
-
-static
-cmsBool IsMyFile(const char* FileName)
-{
- FILE *fp;
- cmsUInt32Number Size;
- cmsUInt8Number Ptr[133];
-
- fp = fopen(FileName, "rt");
- if (!fp) {
- cmsSignalError(0, cmsERROR_FILE, "File '%s' not found", FileName);
- return FALSE;
- }
-
- Size = (cmsUInt32Number) fread(Ptr, 1, 132, fp);
-
- if (fclose(fp) != 0)
- return FALSE;
-
- Ptr[Size] = '\0';
-
- return IsMyBlock(Ptr, Size);
-}
-
-// ---------------------------------------------------------- Exported routines
-
-
-cmsHANDLE CMSEXPORT cmsIT8LoadFromMem(cmsContext ContextID, const void *Ptr, cmsUInt32Number len)
-{
- cmsHANDLE hIT8;
- cmsIT8* it8;
- int type;
-
- _cmsAssert(Ptr != NULL);
- _cmsAssert(len != 0);
-
- type = IsMyBlock((const cmsUInt8Number*)Ptr, len);
- if (type == 0) return NULL;
-
- hIT8 = cmsIT8Alloc(ContextID);
- if (!hIT8) return NULL;
-
- it8 = (cmsIT8*) hIT8;
- it8 ->MemoryBlock = (char*) _cmsMalloc(ContextID, len + 1);
- if (it8->MemoryBlock == NULL)
- {
- cmsIT8Free(hIT8);
- return NULL;
- }
-
- strncpy(it8 ->MemoryBlock, (const char*) Ptr, len);
- it8 ->MemoryBlock[len] = 0;
-
- strncpy(it8->FileStack[0]->FileName, "", cmsMAX_PATH-1);
- it8-> Source = it8 -> MemoryBlock;
-
- if (!ParseIT8(it8, type-1)) {
-
- cmsIT8Free(hIT8);
- return NULL;
- }
-
- CookPointers(it8);
- it8 ->nTable = 0;
-
- _cmsFree(ContextID, it8->MemoryBlock);
- it8 -> MemoryBlock = NULL;
-
- return hIT8;
-
-
-}
-
-
-cmsHANDLE CMSEXPORT cmsIT8LoadFromFile(cmsContext ContextID, const char* cFileName)
-{
-
- cmsHANDLE hIT8;
- cmsIT8* it8;
- int type;
-
- _cmsAssert(cFileName != NULL);
-
- type = IsMyFile(cFileName);
- if (type == 0) return NULL;
-
- hIT8 = cmsIT8Alloc(ContextID);
- it8 = (cmsIT8*) hIT8;
- if (!hIT8) return NULL;
-
-
- it8 ->FileStack[0]->Stream = fopen(cFileName, "rt");
-
- if (!it8 ->FileStack[0]->Stream) {
- cmsIT8Free(hIT8);
- return NULL;
- }
-
-
- strncpy(it8->FileStack[0]->FileName, cFileName, cmsMAX_PATH-1);
- it8->FileStack[0]->FileName[cmsMAX_PATH-1] = 0;
-
- if (!ParseIT8(it8, type-1)) {
-
- fclose(it8 ->FileStack[0]->Stream);
- cmsIT8Free(hIT8);
- return NULL;
- }
-
- CookPointers(it8);
- it8 ->nTable = 0;
-
- if (fclose(it8 ->FileStack[0]->Stream)!= 0) {
- cmsIT8Free(hIT8);
- return NULL;
- }
-
- return hIT8;
-
-}
-
-int CMSEXPORT cmsIT8EnumDataFormat(cmsHANDLE hIT8, char ***SampleNames)
-{
- cmsIT8* it8 = (cmsIT8*) hIT8;
- TABLE* t;
-
- _cmsAssert(hIT8 != NULL);
-
- t = GetTable(it8);
-
- if (SampleNames)
- *SampleNames = t -> DataFormat;
- return t -> nSamples;
-}
-
-
-cmsUInt32Number CMSEXPORT cmsIT8EnumProperties(cmsHANDLE hIT8, char ***PropertyNames)
-{
- cmsIT8* it8 = (cmsIT8*) hIT8;
- KEYVALUE* p;
- cmsUInt32Number n;
- char **Props;
- TABLE* t;
-
- _cmsAssert(hIT8 != NULL);
-
- t = GetTable(it8);
-
- // Pass#1 - count properties
-
- n = 0;
- for (p = t -> HeaderList; p != NULL; p = p->Next) {
- n++;
- }
-
-
- Props = (char**)AllocChunk(it8, sizeof(char*) * n);
- if (Props != NULL) {
-
- // Pass#2 - Fill pointers
- n = 0;
- for (p = t->HeaderList; p != NULL; p = p->Next) {
- Props[n++] = p->Keyword;
- }
-
- }
- *PropertyNames = Props;
-
- return n;
-}
-
-cmsUInt32Number CMSEXPORT cmsIT8EnumPropertyMulti(cmsHANDLE hIT8, const char* cProp, const char ***SubpropertyNames)
-{
- cmsIT8* it8 = (cmsIT8*) hIT8;
- KEYVALUE *p, *tmp;
- cmsUInt32Number n;
- const char **Props;
- TABLE* t;
-
- _cmsAssert(hIT8 != NULL);
-
-
- t = GetTable(it8);
-
- if(!IsAvailableOnList(t->HeaderList, cProp, NULL, &p)) {
- *SubpropertyNames = 0;
- return 0;
- }
-
- // Pass#1 - count properties
-
- n = 0;
- for (tmp = p; tmp != NULL; tmp = tmp->NextSubkey) {
- if(tmp->Subkey != NULL)
- n++;
- }
-
-
- Props = (const char **) AllocChunk(it8, sizeof(char *) * n);
- if (Props != NULL) {
-
- // Pass#2 - Fill pointers
- n = 0;
- for (tmp = p; tmp != NULL; tmp = tmp->NextSubkey) {
- if (tmp->Subkey != NULL)
- Props[n++] = p->Subkey;
- }
- }
-
- *SubpropertyNames = Props;
- return n;
-}
-
-static
-int LocatePatch(cmsIT8* it8, const char* cPatch)
-{
- int i;
- const char *data;
- TABLE* t = GetTable(it8);
-
- for (i=0; i < t-> nPatches; i++) {
-
- data = GetData(it8, i, t->SampleID);
-
- if (data != NULL) {
-
- if (cmsstrcasecmp(data, cPatch) == 0)
- return i;
- }
- }
-
- // SynError(it8, "Couldn't find patch '%s'\n", cPatch);
- return -1;
-}
-
-
-static
-int LocateEmptyPatch(cmsIT8* it8)
-{
- int i;
- const char *data;
- TABLE* t = GetTable(it8);
-
- for (i=0; i < t-> nPatches; i++) {
-
- data = GetData(it8, i, t->SampleID);
-
- if (data == NULL)
- return i;
-
- }
-
- return -1;
-}
-
-static
-int LocateSample(cmsIT8* it8, const char* cSample)
-{
- int i;
- const char *fld;
- TABLE* t = GetTable(it8);
-
- for (i=0; i < t->nSamples; i++) {
-
- fld = GetDataFormat(it8, i);
- if (fld != NULL) {
- if (cmsstrcasecmp(fld, cSample) == 0)
- return i;
- }
- }
-
- return -1;
-
-}
-
-
-int CMSEXPORT cmsIT8FindDataFormat(cmsHANDLE hIT8, const char* cSample)
-{
- cmsIT8* it8 = (cmsIT8*) hIT8;
-
- _cmsAssert(hIT8 != NULL);
-
- return LocateSample(it8, cSample);
-}
-
-
-
-const char* CMSEXPORT cmsIT8GetDataRowCol(cmsHANDLE hIT8, int row, int col)
-{
- cmsIT8* it8 = (cmsIT8*) hIT8;
-
- _cmsAssert(hIT8 != NULL);
-
- return GetData(it8, row, col);
-}
-
-
-cmsFloat64Number CMSEXPORT cmsIT8GetDataRowColDbl(cmsHANDLE hIT8, int row, int col)
-{
- const char* Buffer;
-
- Buffer = cmsIT8GetDataRowCol(hIT8, row, col);
-
- if (Buffer == NULL) return 0.0;
-
- return ParseFloatNumber(Buffer);
-}
-
-
-cmsBool CMSEXPORT cmsIT8SetDataRowCol(cmsHANDLE hIT8, int row, int col, const char* Val)
-{
- cmsIT8* it8 = (cmsIT8*) hIT8;
-
- _cmsAssert(hIT8 != NULL);
-
- return SetData(it8, row, col, Val);
-}
-
-
-cmsBool CMSEXPORT cmsIT8SetDataRowColDbl(cmsHANDLE hIT8, int row, int col, cmsFloat64Number Val)
-{
- cmsIT8* it8 = (cmsIT8*) hIT8;
- char Buff[256];
-
- _cmsAssert(hIT8 != NULL);
-
- snprintf(Buff, 255, it8->DoubleFormatter, Val);
-
- return SetData(it8, row, col, Buff);
-}
-
-
-
-const char* CMSEXPORT cmsIT8GetData(cmsHANDLE hIT8, const char* cPatch, const char* cSample)
-{
- cmsIT8* it8 = (cmsIT8*) hIT8;
- int iField, iSet;
-
- _cmsAssert(hIT8 != NULL);
-
- iField = LocateSample(it8, cSample);
- if (iField < 0) {
- return NULL;
- }
-
- iSet = LocatePatch(it8, cPatch);
- if (iSet < 0) {
- return NULL;
- }
-
- return GetData(it8, iSet, iField);
-}
-
-
-cmsFloat64Number CMSEXPORT cmsIT8GetDataDbl(cmsHANDLE it8, const char* cPatch, const char* cSample)
-{
- const char* Buffer;
-
- Buffer = cmsIT8GetData(it8, cPatch, cSample);
-
- return ParseFloatNumber(Buffer);
-}
-
-
-
-cmsBool CMSEXPORT cmsIT8SetData(cmsHANDLE hIT8, const char* cPatch, const char* cSample, const char *Val)
-{
- cmsIT8* it8 = (cmsIT8*) hIT8;
- int iField, iSet;
- TABLE* t;
-
- _cmsAssert(hIT8 != NULL);
-
- t = GetTable(it8);
-
- iField = LocateSample(it8, cSample);
-
- if (iField < 0)
- return FALSE;
-
- if (t-> nPatches == 0) {
-
- if (!AllocateDataFormat(it8))
- return FALSE;
-
- if (!AllocateDataSet(it8))
- return FALSE;
-
- CookPointers(it8);
- }
-
- if (cmsstrcasecmp(cSample, "SAMPLE_ID") == 0) {
-
- iSet = LocateEmptyPatch(it8);
- if (iSet < 0) {
- return SynError(it8, "Couldn't add more patches '%s'\n", cPatch);
- }
-
- iField = t -> SampleID;
- }
- else {
- iSet = LocatePatch(it8, cPatch);
- if (iSet < 0) {
- return FALSE;
- }
- }
-
- return SetData(it8, iSet, iField, Val);
-}
-
-
-cmsBool CMSEXPORT cmsIT8SetDataDbl(cmsHANDLE hIT8, const char* cPatch,
- const char* cSample,
- cmsFloat64Number Val)
-{
- cmsIT8* it8 = (cmsIT8*) hIT8;
- char Buff[256];
-
- _cmsAssert(hIT8 != NULL);
-
- snprintf(Buff, 255, it8->DoubleFormatter, Val);
- return cmsIT8SetData(hIT8, cPatch, cSample, Buff);
-}
-
-// Buffer should get MAXSTR at least
-
-const char* CMSEXPORT cmsIT8GetPatchName(cmsHANDLE hIT8, int nPatch, char* buffer)
-{
- cmsIT8* it8 = (cmsIT8*) hIT8;
- TABLE* t;
- char* Data;
-
- _cmsAssert(hIT8 != NULL);
-
- t = GetTable(it8);
- Data = GetData(it8, nPatch, t->SampleID);
-
- if (!Data) return NULL;
- if (!buffer) return Data;
-
- strncpy(buffer, Data, MAXSTR-1);
- buffer[MAXSTR-1] = 0;
- return buffer;
-}
-
-int CMSEXPORT cmsIT8GetPatchByName(cmsHANDLE hIT8, const char *cPatch)
-{
- _cmsAssert(hIT8 != NULL);
-
- return LocatePatch((cmsIT8*)hIT8, cPatch);
-}
-
-cmsUInt32Number CMSEXPORT cmsIT8TableCount(cmsHANDLE hIT8)
-{
- cmsIT8* it8 = (cmsIT8*) hIT8;
-
- _cmsAssert(hIT8 != NULL);
-
- return it8 ->TablesCount;
-}
-
-// This handles the "LABEL" extension.
-// Label, nTable, Type
-
-int CMSEXPORT cmsIT8SetTableByLabel(cmsHANDLE hIT8, const char* cSet, const char* cField, const char* ExpectedType)
-{
- const char* cLabelFld;
- char Type[256], Label[256];
- cmsUInt32Number nTable;
-
- _cmsAssert(hIT8 != NULL);
-
- if (cField != NULL && *cField == 0)
- cField = "LABEL";
-
- if (cField == NULL)
- cField = "LABEL";
-
- cLabelFld = cmsIT8GetData(hIT8, cSet, cField);
- if (!cLabelFld) return -1;
-
- if (sscanf(cLabelFld, "%255s %u %255s", Label, &nTable, Type) != 3)
- return -1;
-
- if (ExpectedType != NULL && *ExpectedType == 0)
- ExpectedType = NULL;
-
- if (ExpectedType) {
-
- if (cmsstrcasecmp(Type, ExpectedType) != 0) return -1;
- }
-
- return cmsIT8SetTable(hIT8, nTable);
-}
-
-
-cmsBool CMSEXPORT cmsIT8SetIndexColumn(cmsHANDLE hIT8, const char* cSample)
-{
- cmsIT8* it8 = (cmsIT8*) hIT8;
- int pos;
-
- _cmsAssert(hIT8 != NULL);
-
- pos = LocateSample(it8, cSample);
- if(pos == -1)
- return FALSE;
-
- it8->Tab[it8->nTable].SampleID = pos;
- return TRUE;
-}
-
-
-void CMSEXPORT cmsIT8DefineDblFormat(cmsHANDLE hIT8, const char* Formatter)
-{
- cmsIT8* it8 = (cmsIT8*) hIT8;
-
- _cmsAssert(hIT8 != NULL);
-
- if (Formatter == NULL)
- strcpy(it8->DoubleFormatter, DEFAULT_DBL_FORMAT);
- else
- strncpy(it8->DoubleFormatter, Formatter, sizeof(it8->DoubleFormatter));
-
- it8 ->DoubleFormatter[sizeof(it8 ->DoubleFormatter)-1] = 0;
-}
-
-
-static
-cmsBool ReadNumbers(cmsIT8* cube, int n, cmsFloat64Number* arr)
-{
- int i;
-
- for (i = 0; i < n; i++) {
-
- if (cube->sy == SINUM)
- arr[i] = cube->inum;
- else
- if (cube->sy == SDNUM)
- arr[i] = cube->dnum;
- else
- return SynError(cube, "Number expected");
-
- InSymbol(cube);
- }
-
- return CheckEOLN(cube);
-}
-
-static
-cmsBool ParseCube(cmsIT8* cube, cmsStage** Shaper, cmsStage** CLUT, char title[])
-{
- cmsFloat64Number domain_min[3] = { 0, 0, 0 };
- cmsFloat64Number domain_max[3] = { 1.0, 1.0, 1.0 };
- cmsFloat64Number check_0_1[2] = { 0, 1.0 };
- int shaper_size = 0;
- int lut_size = 0;
- int i;
-
- InSymbol(cube);
-
- while (cube->sy != SEOF) {
- switch (cube->sy)
- {
- // Set profile description
- case STITLE:
- InSymbol(cube);
- if (!Check(cube, SSTRING, "Title string expected")) return FALSE;
- memcpy(title, StringPtr(cube->str), MAXSTR);
- title[MAXSTR - 1] = 0;
- InSymbol(cube);
- break;
-
- // Define domain
- case SDOMAIN_MIN:
- InSymbol(cube);
- if (!ReadNumbers(cube, 3, domain_min)) return FALSE;
- break;
-
- case SDOMAIN_MAX:
- InSymbol(cube);
- if (!ReadNumbers(cube, 3, domain_max)) return FALSE;
- break;
-
- // Define shaper
- case S_LUT1D_SIZE:
- InSymbol(cube);
- if (!Check(cube, SINUM, "Shaper size expected")) return FALSE;
- shaper_size = cube->inum;
- InSymbol(cube);
- break;
-
- // Deefine CLUT
- case S_LUT3D_SIZE:
- InSymbol(cube);
- if (!Check(cube, SINUM, "LUT size expected")) return FALSE;
- lut_size = cube->inum;
- InSymbol(cube);
- break;
-
- // Range. If present, has to be 0..1.0
- case S_LUT1D_INPUT_RANGE:
- case S_LUT3D_INPUT_RANGE:
- InSymbol(cube);
- if (!ReadNumbers(cube, 2, check_0_1)) return FALSE;
- if (check_0_1[0] != 0 || check_0_1[1] != 1.0) {
- return SynError(cube, "Unsupported format");
- }
- break;
-
- case SEOLN:
- InSymbol(cube);
- break;
-
- default:
- case S_LUT_IN_VIDEO_RANGE:
- case S_LUT_OUT_VIDEO_RANGE:
- return SynError(cube, "Unsupported format");
-
- // Read and create tables
- case SINUM:
- case SDNUM:
-
- if (shaper_size > 0) {
-
- cmsToneCurve* curves[3];
- cmsFloat32Number* shapers = (cmsFloat32Number*)_cmsMalloc(cube->ContextID, 3 * shaper_size * sizeof(cmsFloat32Number));
- if (shapers == NULL) return FALSE;
-
- for (i = 0; i < shaper_size; i++) {
-
- cmsFloat64Number nums[3];
-
- if (!ReadNumbers(cube, 3, nums)) return FALSE;
-
- shapers[i + 0] = (cmsFloat32Number) ((nums[0] - domain_min[0]) / (domain_max[0] - domain_min[0]));
- shapers[i + 1 * shaper_size] = (cmsFloat32Number) ((nums[1] - domain_min[1]) / (domain_max[1] - domain_min[1]));
- shapers[i + 2 * shaper_size] = (cmsFloat32Number) ((nums[2] - domain_min[2]) / (domain_max[2] - domain_min[2]));
- }
-
- for (i = 0; i < 3; i++) {
-
- curves[i] = cmsBuildTabulatedToneCurveFloat(cube->ContextID, shaper_size,
- &shapers[i * shaper_size]);
- if (curves[i] == NULL) return FALSE;
- }
-
- *Shaper = cmsStageAllocToneCurves(cube->ContextID, 3, curves);
-
- cmsFreeToneCurveTriple(curves);
- }
-
- if (lut_size > 0) {
-
- int nodes = lut_size * lut_size * lut_size;
-
- cmsFloat32Number* lut_table = _cmsMalloc(cube->ContextID, nodes * 3 * sizeof(cmsFloat32Number));
- if (lut_table == NULL) return FALSE;
-
- for (i = 0; i < nodes; i++) {
-
- cmsFloat64Number nums[3];
-
- if (!ReadNumbers(cube, 3, nums)) return FALSE;
-
- lut_table[i * 3 + 2] = (cmsFloat32Number) ((nums[0] - domain_min[0]) / (domain_max[0] - domain_min[0]));
- lut_table[i * 3 + 1] = (cmsFloat32Number) ((nums[1] - domain_min[1]) / (domain_max[1] - domain_min[1]));
- lut_table[i * 3 + 0] = (cmsFloat32Number) ((nums[2] - domain_min[2]) / (domain_max[2] - domain_min[2]));
- }
-
- *CLUT = cmsStageAllocCLutFloat(cube->ContextID, lut_size, 3, 3, lut_table);
- _cmsFree(cube->ContextID, lut_table);
- }
-
- if (!Check(cube, SEOF, "Extra symbols found in file")) return FALSE;
- }
- }
-
- return TRUE;
-}
-
-// Share the parser to read .cube format and create RGB devicelink profiles
-cmsHPROFILE CMSEXPORT cmsCreateDeviceLinkFromCubeFileTHR(cmsContext ContextID, const char* cFileName)
-{
- cmsHPROFILE hProfile = NULL;
- cmsIT8* cube = NULL;
- cmsPipeline* Pipeline = NULL;
- cmsStage* CLUT = NULL;
- cmsStage* Shaper = NULL;
- cmsMLU* DescriptionMLU = NULL;
- char title[MAXSTR];
-
- _cmsAssert(cFileName != NULL);
-
- cube = (cmsIT8*) cmsIT8Alloc(ContextID);
- if (!cube) return NULL;
-
- cube->IsCUBE = TRUE;
- cube->FileStack[0]->Stream = fopen(cFileName, "rt");
-
- if (!cube->FileStack[0]->Stream) goto Done;
-
- strncpy(cube->FileStack[0]->FileName, cFileName, cmsMAX_PATH - 1);
- cube->FileStack[0]->FileName[cmsMAX_PATH - 1] = 0;
-
- if (!ParseCube(cube, &Shaper, &CLUT, title)) goto Done;
-
- // Success on parsing, let's create the profile
- hProfile = cmsCreateProfilePlaceholder(ContextID);
- if (!hProfile) goto Done;
-
- cmsSetProfileVersion(hProfile, 4.4);
-
- cmsSetDeviceClass(hProfile, cmsSigLinkClass);
- cmsSetColorSpace(hProfile, cmsSigRgbData);
- cmsSetPCS(hProfile, cmsSigRgbData);
-
- cmsSetHeaderRenderingIntent(hProfile, INTENT_PERCEPTUAL);
-
- // Creates a Pipeline to hold CLUT and shaper
- Pipeline = cmsPipelineAlloc(ContextID, 3, 3);
- if (Pipeline == NULL) goto Done;
-
- // Populates the pipeline
- if (Shaper != NULL) {
- if (!cmsPipelineInsertStage(Pipeline, cmsAT_BEGIN, Shaper))
- goto Done;
- }
-
- if (CLUT != NULL) {
- if (!cmsPipelineInsertStage(Pipeline, cmsAT_END, CLUT))
- goto Done;
- }
-
- // Propagate the description. We put no copyright because we know
- // nothing on the copyrighted state of the .cube
- DescriptionMLU = cmsMLUalloc(ContextID, 1);
- if (!cmsMLUsetUTF8(DescriptionMLU, cmsNoLanguage, cmsNoCountry, title)) goto Done;
-
- // Flush the tags
- if (!cmsWriteTag(hProfile, cmsSigProfileDescriptionTag, DescriptionMLU)) goto Done;
- if (!cmsWriteTag(hProfile, cmsSigAToB0Tag, (void*)Pipeline)) goto Done;
-
-Done:
-
- if (DescriptionMLU != NULL)
- cmsMLUfree(DescriptionMLU);
-
- if (Pipeline != NULL)
- cmsPipelineFree(Pipeline);
-
- cmsIT8Free((cmsHANDLE) cube);
-
- return hProfile;
-}
-
-cmsHPROFILE CMSEXPORT cmsCreateDeviceLinkFromCubeFile(const char* cFileName)
-{
- return cmsCreateDeviceLinkFromCubeFileTHR(NULL, cFileName);
-}
diff --git a/contrib/libs/lcms2/src/cmscnvrt.c b/contrib/libs/lcms2/src/cmscnvrt.c
deleted file mode 100644
index f00c117337..0000000000
--- a/contrib/libs/lcms2/src/cmscnvrt.c
+++ /dev/null
@@ -1,1227 +0,0 @@
-//---------------------------------------------------------------------------------
-//
-// Little Color Management System
-// Copyright (c) 1998-2023 Marti Maria Saguer
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//---------------------------------------------------------------------------------
-//
-
-#include "lcms2_internal.h"
-
-
-// This is the default routine for ICC-style intents. A user may decide to override it by using a plugin.
-// Supported intents are perceptual, relative colorimetric, saturation and ICC-absolute colorimetric
-static
-cmsPipeline* DefaultICCintents(cmsContext ContextID,
- cmsUInt32Number nProfiles,
- cmsUInt32Number Intents[],
- cmsHPROFILE hProfiles[],
- cmsBool BPC[],
- cmsFloat64Number AdaptationStates[],
- cmsUInt32Number dwFlags);
-
-//---------------------------------------------------------------------------------
-
-// This is the entry for black-preserving K-only intents, which are non-ICC. Last profile have to be a output profile
-// to do the trick (no devicelinks allowed at that position)
-static
-cmsPipeline* BlackPreservingKOnlyIntents(cmsContext ContextID,
- cmsUInt32Number nProfiles,
- cmsUInt32Number Intents[],
- cmsHPROFILE hProfiles[],
- cmsBool BPC[],
- cmsFloat64Number AdaptationStates[],
- cmsUInt32Number dwFlags);
-
-//---------------------------------------------------------------------------------
-
-// This is the entry for black-plane preserving, which are non-ICC. Again, Last profile have to be a output profile
-// to do the trick (no devicelinks allowed at that position)
-static
-cmsPipeline* BlackPreservingKPlaneIntents(cmsContext ContextID,
- cmsUInt32Number nProfiles,
- cmsUInt32Number Intents[],
- cmsHPROFILE hProfiles[],
- cmsBool BPC[],
- cmsFloat64Number AdaptationStates[],
- cmsUInt32Number dwFlags);
-
-//---------------------------------------------------------------------------------
-
-
-// This is a structure holding implementations for all supported intents.
-typedef struct _cms_intents_list {
-
- cmsUInt32Number Intent;
- char Description[256];
- cmsIntentFn Link;
- struct _cms_intents_list* Next;
-
-} cmsIntentsList;
-
-
-// Built-in intents
-static cmsIntentsList DefaultIntents[] = {
-
- { INTENT_PERCEPTUAL, "Perceptual", DefaultICCintents, &DefaultIntents[1] },
- { INTENT_RELATIVE_COLORIMETRIC, "Relative colorimetric", DefaultICCintents, &DefaultIntents[2] },
- { INTENT_SATURATION, "Saturation", DefaultICCintents, &DefaultIntents[3] },
- { INTENT_ABSOLUTE_COLORIMETRIC, "Absolute colorimetric", DefaultICCintents, &DefaultIntents[4] },
- { INTENT_PRESERVE_K_ONLY_PERCEPTUAL, "Perceptual preserving black ink", BlackPreservingKOnlyIntents, &DefaultIntents[5] },
- { INTENT_PRESERVE_K_ONLY_RELATIVE_COLORIMETRIC, "Relative colorimetric preserving black ink", BlackPreservingKOnlyIntents, &DefaultIntents[6] },
- { INTENT_PRESERVE_K_ONLY_SATURATION, "Saturation preserving black ink", BlackPreservingKOnlyIntents, &DefaultIntents[7] },
- { INTENT_PRESERVE_K_PLANE_PERCEPTUAL, "Perceptual preserving black plane", BlackPreservingKPlaneIntents, &DefaultIntents[8] },
- { INTENT_PRESERVE_K_PLANE_RELATIVE_COLORIMETRIC,"Relative colorimetric preserving black plane", BlackPreservingKPlaneIntents, &DefaultIntents[9] },
- { INTENT_PRESERVE_K_PLANE_SATURATION, "Saturation preserving black plane", BlackPreservingKPlaneIntents, NULL }
-};
-
-
-// A pointer to the beginning of the list
-_cmsIntentsPluginChunkType _cmsIntentsPluginChunk = { NULL };
-
-// Duplicates the zone of memory used by the plug-in in the new context
-static
-void DupPluginIntentsList(struct _cmsContext_struct* ctx,
- const struct _cmsContext_struct* src)
-{
- _cmsIntentsPluginChunkType newHead = { NULL };
- cmsIntentsList* entry;
- cmsIntentsList* Anterior = NULL;
- _cmsIntentsPluginChunkType* head = (_cmsIntentsPluginChunkType*) src->chunks[IntentPlugin];
-
- // Walk the list copying all nodes
- for (entry = head->Intents;
- entry != NULL;
- entry = entry ->Next) {
-
- cmsIntentsList *newEntry = ( cmsIntentsList *) _cmsSubAllocDup(ctx ->MemPool, entry, sizeof(cmsIntentsList));
-
- if (newEntry == NULL)
- return;
-
- // We want to keep the linked list order, so this is a little bit tricky
- newEntry -> Next = NULL;
- if (Anterior)
- Anterior -> Next = newEntry;
-
- Anterior = newEntry;
-
- if (newHead.Intents == NULL)
- newHead.Intents = newEntry;
- }
-
- ctx ->chunks[IntentPlugin] = _cmsSubAllocDup(ctx->MemPool, &newHead, sizeof(_cmsIntentsPluginChunkType));
-}
-
-void _cmsAllocIntentsPluginChunk(struct _cmsContext_struct* ctx,
- const struct _cmsContext_struct* src)
-{
- if (src != NULL) {
-
- // Copy all linked list
- DupPluginIntentsList(ctx, src);
- }
- else {
- static _cmsIntentsPluginChunkType IntentsPluginChunkType = { NULL };
- ctx ->chunks[IntentPlugin] = _cmsSubAllocDup(ctx ->MemPool, &IntentsPluginChunkType, sizeof(_cmsIntentsPluginChunkType));
- }
-}
-
-
-// Search the list for a suitable intent. Returns NULL if not found
-static
-cmsIntentsList* SearchIntent(cmsContext ContextID, cmsUInt32Number Intent)
-{
- _cmsIntentsPluginChunkType* ctx = ( _cmsIntentsPluginChunkType*) _cmsContextGetClientChunk(ContextID, IntentPlugin);
- cmsIntentsList* pt;
-
- for (pt = ctx -> Intents; pt != NULL; pt = pt -> Next)
- if (pt ->Intent == Intent) return pt;
-
- for (pt = DefaultIntents; pt != NULL; pt = pt -> Next)
- if (pt ->Intent == Intent) return pt;
-
- return NULL;
-}
-
-// Black point compensation. Implemented as a linear scaling in XYZ. Black points
-// should come relative to the white point. Fills an matrix/offset element m
-// which is organized as a 4x4 matrix.
-static
-void ComputeBlackPointCompensation(const cmsCIEXYZ* BlackPointIn,
- const cmsCIEXYZ* BlackPointOut,
- cmsMAT3* m, cmsVEC3* off)
-{
- cmsFloat64Number ax, ay, az, bx, by, bz, tx, ty, tz;
-
- // Now we need to compute a matrix plus an offset m and of such of
- // [m]*bpin + off = bpout
- // [m]*D50 + off = D50
- //
- // This is a linear scaling in the form ax+b, where
- // a = (bpout - D50) / (bpin - D50)
- // b = - D50* (bpout - bpin) / (bpin - D50)
-
- tx = BlackPointIn->X - cmsD50_XYZ()->X;
- ty = BlackPointIn->Y - cmsD50_XYZ()->Y;
- tz = BlackPointIn->Z - cmsD50_XYZ()->Z;
-
- ax = (BlackPointOut->X - cmsD50_XYZ()->X) / tx;
- ay = (BlackPointOut->Y - cmsD50_XYZ()->Y) / ty;
- az = (BlackPointOut->Z - cmsD50_XYZ()->Z) / tz;
-
- bx = - cmsD50_XYZ()-> X * (BlackPointOut->X - BlackPointIn->X) / tx;
- by = - cmsD50_XYZ()-> Y * (BlackPointOut->Y - BlackPointIn->Y) / ty;
- bz = - cmsD50_XYZ()-> Z * (BlackPointOut->Z - BlackPointIn->Z) / tz;
-
- _cmsVEC3init(&m ->v[0], ax, 0, 0);
- _cmsVEC3init(&m ->v[1], 0, ay, 0);
- _cmsVEC3init(&m ->v[2], 0, 0, az);
- _cmsVEC3init(off, bx, by, bz);
-
-}
-
-
-// Approximate a blackbody illuminant based on CHAD information
-static
-cmsFloat64Number CHAD2Temp(const cmsMAT3* Chad)
-{
- // Convert D50 across inverse CHAD to get the absolute white point
- cmsVEC3 d, s;
- cmsCIEXYZ Dest;
- cmsCIExyY DestChromaticity;
- cmsFloat64Number TempK;
- cmsMAT3 m1, m2;
-
- m1 = *Chad;
- if (!_cmsMAT3inverse(&m1, &m2)) return FALSE;
-
- s.n[VX] = cmsD50_XYZ() -> X;
- s.n[VY] = cmsD50_XYZ() -> Y;
- s.n[VZ] = cmsD50_XYZ() -> Z;
-
- _cmsMAT3eval(&d, &m2, &s);
-
- Dest.X = d.n[VX];
- Dest.Y = d.n[VY];
- Dest.Z = d.n[VZ];
-
- cmsXYZ2xyY(&DestChromaticity, &Dest);
-
- if (!cmsTempFromWhitePoint(&TempK, &DestChromaticity))
- return -1.0;
-
- return TempK;
-}
-
-// Compute a CHAD based on a given temperature
-static
-void Temp2CHAD(cmsMAT3* Chad, cmsFloat64Number Temp)
-{
- cmsCIEXYZ White;
- cmsCIExyY ChromaticityOfWhite;
-
- cmsWhitePointFromTemp(&ChromaticityOfWhite, Temp);
- cmsxyY2XYZ(&White, &ChromaticityOfWhite);
- _cmsAdaptationMatrix(Chad, NULL, &White, cmsD50_XYZ());
-}
-
-// Join scalings to obtain relative input to absolute and then to relative output.
-// Result is stored in a 3x3 matrix
-static
-cmsBool ComputeAbsoluteIntent(cmsFloat64Number AdaptationState,
- const cmsCIEXYZ* WhitePointIn,
- const cmsMAT3* ChromaticAdaptationMatrixIn,
- const cmsCIEXYZ* WhitePointOut,
- const cmsMAT3* ChromaticAdaptationMatrixOut,
- cmsMAT3* m)
-{
- cmsMAT3 Scale, m1, m2, m3, m4;
-
- // TODO: Follow Marc Mahy's recommendation to check if CHAD is same by using M1*M2 == M2*M1. If so, do nothing.
- // TODO: Add support for ArgyllArts tag
-
- // Adaptation state
- if (AdaptationState == 1.0) {
-
- // Observer is fully adapted. Keep chromatic adaptation.
- // That is the standard V4 behaviour
- _cmsVEC3init(&m->v[0], WhitePointIn->X / WhitePointOut->X, 0, 0);
- _cmsVEC3init(&m->v[1], 0, WhitePointIn->Y / WhitePointOut->Y, 0);
- _cmsVEC3init(&m->v[2], 0, 0, WhitePointIn->Z / WhitePointOut->Z);
-
- }
- else {
-
- // Incomplete adaptation. This is an advanced feature.
- _cmsVEC3init(&Scale.v[0], WhitePointIn->X / WhitePointOut->X, 0, 0);
- _cmsVEC3init(&Scale.v[1], 0, WhitePointIn->Y / WhitePointOut->Y, 0);
- _cmsVEC3init(&Scale.v[2], 0, 0, WhitePointIn->Z / WhitePointOut->Z);
-
-
- if (AdaptationState == 0.0) {
-
- m1 = *ChromaticAdaptationMatrixOut;
- _cmsMAT3per(&m2, &m1, &Scale);
- // m2 holds CHAD from output white to D50 times abs. col. scaling
-
- // Observer is not adapted, undo the chromatic adaptation
- _cmsMAT3per(m, &m2, ChromaticAdaptationMatrixOut);
-
- m3 = *ChromaticAdaptationMatrixIn;
- if (!_cmsMAT3inverse(&m3, &m4)) return FALSE;
- _cmsMAT3per(m, &m2, &m4);
-
- } else {
-
- cmsMAT3 MixedCHAD;
- cmsFloat64Number TempSrc, TempDest, Temp;
-
- m1 = *ChromaticAdaptationMatrixIn;
- if (!_cmsMAT3inverse(&m1, &m2)) return FALSE;
- _cmsMAT3per(&m3, &m2, &Scale);
- // m3 holds CHAD from input white to D50 times abs. col. scaling
-
- TempSrc = CHAD2Temp(ChromaticAdaptationMatrixIn);
- TempDest = CHAD2Temp(ChromaticAdaptationMatrixOut);
-
- if (TempSrc < 0.0 || TempDest < 0.0) return FALSE; // Something went wrong
-
- if (_cmsMAT3isIdentity(&Scale) && fabs(TempSrc - TempDest) < 0.01) {
-
- _cmsMAT3identity(m);
- return TRUE;
- }
-
- Temp = (1.0 - AdaptationState) * TempDest + AdaptationState * TempSrc;
-
- // Get a CHAD from whatever output temperature to D50. This replaces output CHAD
- Temp2CHAD(&MixedCHAD, Temp);
-
- _cmsMAT3per(m, &m3, &MixedCHAD);
- }
-
- }
- return TRUE;
-
-}
-
-// Just to see if m matrix should be applied
-static
-cmsBool IsEmptyLayer(cmsMAT3* m, cmsVEC3* off)
-{
- cmsFloat64Number diff = 0;
- cmsMAT3 Ident;
- int i;
-
- if (m == NULL && off == NULL) return TRUE; // NULL is allowed as an empty layer
- if (m == NULL && off != NULL) return FALSE; // This is an internal error
-
- _cmsMAT3identity(&Ident);
-
- for (i=0; i < 3*3; i++)
- diff += fabs(((cmsFloat64Number*)m)[i] - ((cmsFloat64Number*)&Ident)[i]);
-
- for (i=0; i < 3; i++)
- diff += fabs(((cmsFloat64Number*)off)[i]);
-
-
- return (diff < 0.002);
-}
-
-
-// Compute the conversion layer
-static
-cmsBool ComputeConversion(cmsUInt32Number i,
- cmsHPROFILE hProfiles[],
- cmsUInt32Number Intent,
- cmsBool BPC,
- cmsFloat64Number AdaptationState,
- cmsMAT3* m, cmsVEC3* off)
-{
-
- int k;
-
- // m and off are set to identity and this is detected latter on
- _cmsMAT3identity(m);
- _cmsVEC3init(off, 0, 0, 0);
-
- // If intent is abs. colorimetric,
- if (Intent == INTENT_ABSOLUTE_COLORIMETRIC) {
-
- cmsCIEXYZ WhitePointIn, WhitePointOut;
- cmsMAT3 ChromaticAdaptationMatrixIn, ChromaticAdaptationMatrixOut;
-
- if (!_cmsReadMediaWhitePoint(&WhitePointIn, hProfiles[i - 1])) return FALSE;
- if (!_cmsReadCHAD(&ChromaticAdaptationMatrixIn, hProfiles[i - 1])) return FALSE;
-
- if (!_cmsReadMediaWhitePoint(&WhitePointOut, hProfiles[i])) return FALSE;
- if (!_cmsReadCHAD(&ChromaticAdaptationMatrixOut, hProfiles[i])) return FALSE;
-
- if (!ComputeAbsoluteIntent(AdaptationState,
- &WhitePointIn, &ChromaticAdaptationMatrixIn,
- &WhitePointOut, &ChromaticAdaptationMatrixOut, m)) return FALSE;
-
- }
- else {
- // Rest of intents may apply BPC.
-
- if (BPC) {
-
- cmsCIEXYZ BlackPointIn = { 0, 0, 0}, BlackPointOut = { 0, 0, 0 };
-
- cmsDetectBlackPoint(&BlackPointIn, hProfiles[i-1], Intent, 0);
- cmsDetectDestinationBlackPoint(&BlackPointOut, hProfiles[i], Intent, 0);
-
- // If black points are equal, then do nothing
- if (BlackPointIn.X != BlackPointOut.X ||
- BlackPointIn.Y != BlackPointOut.Y ||
- BlackPointIn.Z != BlackPointOut.Z)
- ComputeBlackPointCompensation(&BlackPointIn, &BlackPointOut, m, off);
- }
- }
-
- // Offset should be adjusted because the encoding. We encode XYZ normalized to 0..1.0,
- // to do that, we divide by MAX_ENCODEABLE_XZY. The conversion stage goes XYZ -> XYZ so
- // we have first to convert from encoded to XYZ and then convert back to encoded.
- // y = Mx + Off
- // x = x'c
- // y = M x'c + Off
- // y = y'c; y' = y / c
- // y' = (Mx'c + Off) /c = Mx' + (Off / c)
-
- for (k=0; k < 3; k++) {
- off ->n[k] /= MAX_ENCODEABLE_XYZ;
- }
-
- return TRUE;
-}
-
-
-// Add a conversion stage if needed. If a matrix/offset m is given, it applies to XYZ space
-static
-cmsBool AddConversion(cmsPipeline* Result, cmsColorSpaceSignature InPCS, cmsColorSpaceSignature OutPCS, cmsMAT3* m, cmsVEC3* off)
-{
- cmsFloat64Number* m_as_dbl = (cmsFloat64Number*) m;
- cmsFloat64Number* off_as_dbl = (cmsFloat64Number*) off;
-
- // Handle PCS mismatches. A specialized stage is added to the LUT in such case
- switch (InPCS) {
-
- case cmsSigXYZData: // Input profile operates in XYZ
-
- switch (OutPCS) {
-
- case cmsSigXYZData: // XYZ -> XYZ
- if (!IsEmptyLayer(m, off) &&
- !cmsPipelineInsertStage(Result, cmsAT_END, cmsStageAllocMatrix(Result ->ContextID, 3, 3, m_as_dbl, off_as_dbl)))
- return FALSE;
- break;
-
- case cmsSigLabData: // XYZ -> Lab
- if (!IsEmptyLayer(m, off) &&
- !cmsPipelineInsertStage(Result, cmsAT_END, cmsStageAllocMatrix(Result ->ContextID, 3, 3, m_as_dbl, off_as_dbl)))
- return FALSE;
- if (!cmsPipelineInsertStage(Result, cmsAT_END, _cmsStageAllocXYZ2Lab(Result ->ContextID)))
- return FALSE;
- break;
-
- default:
- return FALSE; // Colorspace mismatch
- }
- break;
-
- case cmsSigLabData: // Input profile operates in Lab
-
- switch (OutPCS) {
-
- case cmsSigXYZData: // Lab -> XYZ
-
- if (!cmsPipelineInsertStage(Result, cmsAT_END, _cmsStageAllocLab2XYZ(Result ->ContextID)))
- return FALSE;
- if (!IsEmptyLayer(m, off) &&
- !cmsPipelineInsertStage(Result, cmsAT_END, cmsStageAllocMatrix(Result ->ContextID, 3, 3, m_as_dbl, off_as_dbl)))
- return FALSE;
- break;
-
- case cmsSigLabData: // Lab -> Lab
-
- if (!IsEmptyLayer(m, off)) {
- if (!cmsPipelineInsertStage(Result, cmsAT_END, _cmsStageAllocLab2XYZ(Result ->ContextID)) ||
- !cmsPipelineInsertStage(Result, cmsAT_END, cmsStageAllocMatrix(Result ->ContextID, 3, 3, m_as_dbl, off_as_dbl)) ||
- !cmsPipelineInsertStage(Result, cmsAT_END, _cmsStageAllocXYZ2Lab(Result ->ContextID)))
- return FALSE;
- }
- break;
-
- default:
- return FALSE; // Mismatch
- }
- break;
-
- // On colorspaces other than PCS, check for same space
- default:
- if (InPCS != OutPCS) return FALSE;
- break;
- }
-
- return TRUE;
-}
-
-
-// Is a given space compatible with another?
-static
-cmsBool ColorSpaceIsCompatible(cmsColorSpaceSignature a, cmsColorSpaceSignature b)
-{
- // If they are same, they are compatible.
- if (a == b) return TRUE;
-
- // Check for MCH4 substitution of CMYK
- if ((a == cmsSig4colorData) && (b == cmsSigCmykData)) return TRUE;
- if ((a == cmsSigCmykData) && (b == cmsSig4colorData)) return TRUE;
-
- // Check for XYZ/Lab. Those spaces are interchangeable as they can be computed one from other.
- if ((a == cmsSigXYZData) && (b == cmsSigLabData)) return TRUE;
- if ((a == cmsSigLabData) && (b == cmsSigXYZData)) return TRUE;
-
- return FALSE;
-}
-
-
-// Default handler for ICC-style intents
-static
-cmsPipeline* DefaultICCintents(cmsContext ContextID,
- cmsUInt32Number nProfiles,
- cmsUInt32Number TheIntents[],
- cmsHPROFILE hProfiles[],
- cmsBool BPC[],
- cmsFloat64Number AdaptationStates[],
- cmsUInt32Number dwFlags)
-{
- cmsPipeline* Lut = NULL;
- cmsPipeline* Result;
- cmsHPROFILE hProfile;
- cmsMAT3 m;
- cmsVEC3 off;
- cmsColorSpaceSignature ColorSpaceIn, ColorSpaceOut = cmsSigLabData, CurrentColorSpace;
- cmsProfileClassSignature ClassSig;
- cmsUInt32Number i, Intent;
-
- // For safety
- if (nProfiles == 0) return NULL;
-
- // Allocate an empty LUT for holding the result. 0 as channel count means 'undefined'
- Result = cmsPipelineAlloc(ContextID, 0, 0);
- if (Result == NULL) return NULL;
-
- CurrentColorSpace = cmsGetColorSpace(hProfiles[0]);
-
- for (i=0; i < nProfiles; i++) {
-
- cmsBool lIsDeviceLink, lIsInput;
-
- hProfile = hProfiles[i];
- ClassSig = cmsGetDeviceClass(hProfile);
- lIsDeviceLink = (ClassSig == cmsSigLinkClass || ClassSig == cmsSigAbstractClass );
-
- // First profile is used as input unless devicelink or abstract
- if ((i == 0) && !lIsDeviceLink) {
- lIsInput = TRUE;
- }
- else {
- // Else use profile in the input direction if current space is not PCS
- lIsInput = (CurrentColorSpace != cmsSigXYZData) &&
- (CurrentColorSpace != cmsSigLabData);
- }
-
- Intent = TheIntents[i];
-
- if (lIsInput || lIsDeviceLink) {
-
- ColorSpaceIn = cmsGetColorSpace(hProfile);
- ColorSpaceOut = cmsGetPCS(hProfile);
- }
- else {
-
- ColorSpaceIn = cmsGetPCS(hProfile);
- ColorSpaceOut = cmsGetColorSpace(hProfile);
- }
-
- if (!ColorSpaceIsCompatible(ColorSpaceIn, CurrentColorSpace)) {
-
- cmsSignalError(ContextID, cmsERROR_COLORSPACE_CHECK, "ColorSpace mismatch");
- goto Error;
- }
-
- // If devicelink is found, then no custom intent is allowed and we can
- // read the LUT to be applied. Settings don't apply here.
- if (lIsDeviceLink || ((ClassSig == cmsSigNamedColorClass) && (nProfiles == 1))) {
-
- // Get the involved LUT from the profile
- Lut = _cmsReadDevicelinkLUT(hProfile, Intent);
- if (Lut == NULL) goto Error;
-
- // What about abstract profiles?
- if (ClassSig == cmsSigAbstractClass && i > 0) {
- if (!ComputeConversion(i, hProfiles, Intent, BPC[i], AdaptationStates[i], &m, &off)) goto Error;
- }
- else {
- _cmsMAT3identity(&m);
- _cmsVEC3init(&off, 0, 0, 0);
- }
-
-
- if (!AddConversion(Result, CurrentColorSpace, ColorSpaceIn, &m, &off)) goto Error;
-
- }
- else {
-
- if (lIsInput) {
- // Input direction means non-pcs connection, so proceed like devicelinks
- Lut = _cmsReadInputLUT(hProfile, Intent);
- if (Lut == NULL) goto Error;
- }
- else {
-
- // Output direction means PCS connection. Intent may apply here
- Lut = _cmsReadOutputLUT(hProfile, Intent);
- if (Lut == NULL) goto Error;
-
-
- if (!ComputeConversion(i, hProfiles, Intent, BPC[i], AdaptationStates[i], &m, &off)) goto Error;
- if (!AddConversion(Result, CurrentColorSpace, ColorSpaceIn, &m, &off)) goto Error;
-
- }
- }
-
- // Concatenate to the output LUT
- if (!cmsPipelineCat(Result, Lut))
- goto Error;
-
- cmsPipelineFree(Lut);
- Lut = NULL;
-
- // Update current space
- CurrentColorSpace = ColorSpaceOut;
- }
-
- // Check for non-negatives clip
- if (dwFlags & cmsFLAGS_NONEGATIVES) {
-
- if (ColorSpaceOut == cmsSigGrayData ||
- ColorSpaceOut == cmsSigRgbData ||
- ColorSpaceOut == cmsSigCmykData) {
-
- cmsStage* clip = _cmsStageClipNegatives(Result->ContextID, cmsChannelsOfColorSpace(ColorSpaceOut));
- if (clip == NULL) goto Error;
-
- if (!cmsPipelineInsertStage(Result, cmsAT_END, clip))
- goto Error;
- }
-
- }
-
- return Result;
-
-Error:
-
- if (Lut != NULL) cmsPipelineFree(Lut);
- if (Result != NULL) cmsPipelineFree(Result);
- return NULL;
-
- cmsUNUSED_PARAMETER(dwFlags);
-}
-
-
-// Wrapper for DLL calling convention
-cmsPipeline* CMSEXPORT _cmsDefaultICCintents(cmsContext ContextID,
- cmsUInt32Number nProfiles,
- cmsUInt32Number TheIntents[],
- cmsHPROFILE hProfiles[],
- cmsBool BPC[],
- cmsFloat64Number AdaptationStates[],
- cmsUInt32Number dwFlags)
-{
- return DefaultICCintents(ContextID, nProfiles, TheIntents, hProfiles, BPC, AdaptationStates, dwFlags);
-}
-
-// Black preserving intents ---------------------------------------------------------------------------------------------
-
-// Translate black-preserving intents to ICC ones
-static
-cmsUInt32Number TranslateNonICCIntents(cmsUInt32Number Intent)
-{
- switch (Intent) {
- case INTENT_PRESERVE_K_ONLY_PERCEPTUAL:
- case INTENT_PRESERVE_K_PLANE_PERCEPTUAL:
- return INTENT_PERCEPTUAL;
-
- case INTENT_PRESERVE_K_ONLY_RELATIVE_COLORIMETRIC:
- case INTENT_PRESERVE_K_PLANE_RELATIVE_COLORIMETRIC:
- return INTENT_RELATIVE_COLORIMETRIC;
-
- case INTENT_PRESERVE_K_ONLY_SATURATION:
- case INTENT_PRESERVE_K_PLANE_SATURATION:
- return INTENT_SATURATION;
-
- default: return Intent;
- }
-}
-
-// Sampler for Black-only preserving CMYK->CMYK transforms
-
-typedef struct {
- cmsPipeline* cmyk2cmyk; // The original transform
- cmsToneCurve* KTone; // Black-to-black tone curve
-
-} GrayOnlyParams;
-
-
-// Preserve black only if that is the only ink used
-static
-int BlackPreservingGrayOnlySampler(CMSREGISTER const cmsUInt16Number In[], CMSREGISTER cmsUInt16Number Out[], CMSREGISTER void* Cargo)
-{
- GrayOnlyParams* bp = (GrayOnlyParams*) Cargo;
-
- // If going across black only, keep black only
- if (In[0] == 0 && In[1] == 0 && In[2] == 0) {
-
- // TAC does not apply because it is black ink!
- Out[0] = Out[1] = Out[2] = 0;
- Out[3] = cmsEvalToneCurve16(bp->KTone, In[3]);
- return TRUE;
- }
-
- // Keep normal transform for other colors
- bp ->cmyk2cmyk ->Eval16Fn(In, Out, bp ->cmyk2cmyk->Data);
- return TRUE;
-}
-
-
-// Check whatever the profile is a CMYK->CMYK devicelink
-static
-cmsBool is_cmyk_devicelink(cmsHPROFILE hProfile)
-{
- return cmsGetDeviceClass(hProfile) == cmsSigLinkClass &&
- cmsGetColorSpace(hProfile) == cmsSigCmykData &&
- cmsGetColorSpace(hProfile) == cmsSigCmykData;
-}
-
-// This is the entry for black-preserving K-only intents, which are non-ICC
-static
-cmsPipeline* BlackPreservingKOnlyIntents(cmsContext ContextID,
- cmsUInt32Number nProfiles,
- cmsUInt32Number TheIntents[],
- cmsHPROFILE hProfiles[],
- cmsBool BPC[],
- cmsFloat64Number AdaptationStates[],
- cmsUInt32Number dwFlags)
-{
- GrayOnlyParams bp;
- cmsPipeline* Result;
- cmsUInt32Number ICCIntents[256];
- cmsStage* CLUT;
- cmsUInt32Number i, nGridPoints;
- cmsUInt32Number lastProfilePos;
- cmsUInt32Number preservationProfilesCount;
- cmsHPROFILE hLastProfile;
-
-
- // Sanity check
- if (nProfiles < 1 || nProfiles > 255) return NULL;
-
- // Translate black-preserving intents to ICC ones
- for (i=0; i < nProfiles; i++)
- ICCIntents[i] = TranslateNonICCIntents(TheIntents[i]);
-
-
- // Trim all CMYK devicelinks at the end
- lastProfilePos = nProfiles - 1;
- hLastProfile = hProfiles[lastProfilePos];
-
- // Skip CMYK->CMYK devicelinks on ending
- while (is_cmyk_devicelink(hLastProfile))
- {
- if (lastProfilePos < 2)
- break;
-
- hLastProfile = hProfiles[--lastProfilePos];
- }
-
-
- preservationProfilesCount = lastProfilePos + 1;
-
- // Check for non-cmyk profiles
- if (cmsGetColorSpace(hProfiles[0]) != cmsSigCmykData ||
- !(cmsGetColorSpace(hLastProfile) == cmsSigCmykData ||
- cmsGetDeviceClass(hLastProfile) == cmsSigOutputClass))
- return DefaultICCintents(ContextID, nProfiles, ICCIntents, hProfiles, BPC, AdaptationStates, dwFlags);
-
- // Allocate an empty LUT for holding the result
- Result = cmsPipelineAlloc(ContextID, 4, 4);
- if (Result == NULL) return NULL;
-
- memset(&bp, 0, sizeof(bp));
-
- // Create a LUT holding normal ICC transform
- bp.cmyk2cmyk = DefaultICCintents(ContextID,
- preservationProfilesCount,
- ICCIntents,
- hProfiles,
- BPC,
- AdaptationStates,
- dwFlags);
-
- if (bp.cmyk2cmyk == NULL) goto Error;
-
- // Now, compute the tone curve
- bp.KTone = _cmsBuildKToneCurve(ContextID,
- 4096,
- preservationProfilesCount,
- ICCIntents,
- hProfiles,
- BPC,
- AdaptationStates,
- dwFlags);
-
- if (bp.KTone == NULL) goto Error;
-
-
- // How many gridpoints are we going to use?
- nGridPoints = _cmsReasonableGridpointsByColorspace(cmsSigCmykData, dwFlags);
-
- // Create the CLUT. 16 bits
- CLUT = cmsStageAllocCLut16bit(ContextID, nGridPoints, 4, 4, NULL);
- if (CLUT == NULL) goto Error;
-
- // This is the one and only MPE in this LUT
- if (!cmsPipelineInsertStage(Result, cmsAT_BEGIN, CLUT))
- goto Error;
-
- // Sample it. We cannot afford pre/post linearization this time.
- if (!cmsStageSampleCLut16bit(CLUT, BlackPreservingGrayOnlySampler, (void*) &bp, 0))
- goto Error;
-
-
- // Insert possible devicelinks at the end
- for (i = lastProfilePos + 1; i < nProfiles; i++)
- {
- cmsPipeline* devlink = _cmsReadDevicelinkLUT(hProfiles[i], ICCIntents[i]);
- if (devlink == NULL)
- goto Error;
-
- if (!cmsPipelineCat(Result, devlink))
- goto Error;
- }
-
-
- // Get rid of xform and tone curve
- cmsPipelineFree(bp.cmyk2cmyk);
- cmsFreeToneCurve(bp.KTone);
-
- return Result;
-
-Error:
-
- if (bp.cmyk2cmyk != NULL) cmsPipelineFree(bp.cmyk2cmyk);
- if (bp.KTone != NULL) cmsFreeToneCurve(bp.KTone);
- if (Result != NULL) cmsPipelineFree(Result);
- return NULL;
-
-}
-
-// K Plane-preserving CMYK to CMYK ------------------------------------------------------------------------------------
-
-typedef struct {
-
- cmsPipeline* cmyk2cmyk; // The original transform
- cmsHTRANSFORM hProofOutput; // Output CMYK to Lab (last profile)
- cmsHTRANSFORM cmyk2Lab; // The input chain
- cmsToneCurve* KTone; // Black-to-black tone curve
- cmsPipeline* LabK2cmyk; // The output profile
- cmsFloat64Number MaxError;
-
- cmsHTRANSFORM hRoundTrip;
- cmsFloat64Number MaxTAC;
-
-
-} PreserveKPlaneParams;
-
-
-// The CLUT will be stored at 16 bits, but calculations are performed at cmsFloat32Number precision
-static
-int BlackPreservingSampler(CMSREGISTER const cmsUInt16Number In[], CMSREGISTER cmsUInt16Number Out[], CMSREGISTER void* Cargo)
-{
- int i;
- cmsFloat32Number Inf[4], Outf[4];
- cmsFloat32Number LabK[4];
- cmsFloat64Number SumCMY, SumCMYK, Error, Ratio;
- cmsCIELab ColorimetricLab, BlackPreservingLab;
- PreserveKPlaneParams* bp = (PreserveKPlaneParams*) Cargo;
-
- // Convert from 16 bits to floating point
- for (i=0; i < 4; i++)
- Inf[i] = (cmsFloat32Number) (In[i] / 65535.0);
-
- // Get the K across Tone curve
- LabK[3] = cmsEvalToneCurveFloat(bp ->KTone, Inf[3]);
-
- // If going across black only, keep black only
- if (In[0] == 0 && In[1] == 0 && In[2] == 0) {
-
- Out[0] = Out[1] = Out[2] = 0;
- Out[3] = _cmsQuickSaturateWord(LabK[3] * 65535.0);
- return TRUE;
- }
-
- // Try the original transform,
- cmsPipelineEvalFloat(Inf, Outf, bp ->cmyk2cmyk);
-
- // Store a copy of the floating point result into 16-bit
- for (i=0; i < 4; i++)
- Out[i] = _cmsQuickSaturateWord(Outf[i] * 65535.0);
-
- // Maybe K is already ok (mostly on K=0)
- if (fabsf(Outf[3] - LabK[3]) < (3.0 / 65535.0)) {
- return TRUE;
- }
-
- // K differ, measure and keep Lab measurement for further usage
- // this is done in relative colorimetric intent
- cmsDoTransform(bp->hProofOutput, Out, &ColorimetricLab, 1);
-
- // Is not black only and the transform doesn't keep black.
- // Obtain the Lab of output CMYK. After that we have Lab + K
- cmsDoTransform(bp ->cmyk2Lab, Outf, LabK, 1);
-
- // Obtain the corresponding CMY using reverse interpolation
- // (K is fixed in LabK[3])
- if (!cmsPipelineEvalReverseFloat(LabK, Outf, Outf, bp ->LabK2cmyk)) {
-
- // Cannot find a suitable value, so use colorimetric xform
- // which is already stored in Out[]
- return TRUE;
- }
-
- // Make sure to pass through K (which now is fixed)
- Outf[3] = LabK[3];
-
- // Apply TAC if needed
- SumCMY = (cmsFloat64Number) Outf[0] + Outf[1] + Outf[2];
- SumCMYK = SumCMY + Outf[3];
-
- if (SumCMYK > bp ->MaxTAC) {
-
- Ratio = 1 - ((SumCMYK - bp->MaxTAC) / SumCMY);
- if (Ratio < 0)
- Ratio = 0;
- }
- else
- Ratio = 1.0;
-
- Out[0] = _cmsQuickSaturateWord(Outf[0] * Ratio * 65535.0); // C
- Out[1] = _cmsQuickSaturateWord(Outf[1] * Ratio * 65535.0); // M
- Out[2] = _cmsQuickSaturateWord(Outf[2] * Ratio * 65535.0); // Y
- Out[3] = _cmsQuickSaturateWord(Outf[3] * 65535.0);
-
- // Estimate the error (this goes 16 bits to Lab DBL)
- cmsDoTransform(bp->hProofOutput, Out, &BlackPreservingLab, 1);
- Error = cmsDeltaE(&ColorimetricLab, &BlackPreservingLab);
- if (Error > bp -> MaxError)
- bp->MaxError = Error;
-
- return TRUE;
-}
-
-
-
-// This is the entry for black-plane preserving, which are non-ICC
-static
-cmsPipeline* BlackPreservingKPlaneIntents(cmsContext ContextID,
- cmsUInt32Number nProfiles,
- cmsUInt32Number TheIntents[],
- cmsHPROFILE hProfiles[],
- cmsBool BPC[],
- cmsFloat64Number AdaptationStates[],
- cmsUInt32Number dwFlags)
-{
- PreserveKPlaneParams bp;
-
- cmsPipeline* Result = NULL;
- cmsUInt32Number ICCIntents[256];
- cmsStage* CLUT;
- cmsUInt32Number i, nGridPoints;
- cmsUInt32Number lastProfilePos;
- cmsUInt32Number preservationProfilesCount;
- cmsHPROFILE hLastProfile;
- cmsHPROFILE hLab;
-
- // Sanity check
- if (nProfiles < 1 || nProfiles > 255) return NULL;
-
- // Translate black-preserving intents to ICC ones
- for (i=0; i < nProfiles; i++)
- ICCIntents[i] = TranslateNonICCIntents(TheIntents[i]);
-
- // Trim all CMYK devicelinks at the end
- lastProfilePos = nProfiles - 1;
- hLastProfile = hProfiles[lastProfilePos];
-
- // Skip CMYK->CMYK devicelinks on ending
- while (is_cmyk_devicelink(hLastProfile))
- {
- if (lastProfilePos < 2)
- break;
-
- hLastProfile = hProfiles[--lastProfilePos];
- }
-
- preservationProfilesCount = lastProfilePos + 1;
-
- // Check for non-cmyk profiles
- if (cmsGetColorSpace(hProfiles[0]) != cmsSigCmykData ||
- !(cmsGetColorSpace(hLastProfile) == cmsSigCmykData ||
- cmsGetDeviceClass(hLastProfile) == cmsSigOutputClass))
- return DefaultICCintents(ContextID, nProfiles, ICCIntents, hProfiles, BPC, AdaptationStates, dwFlags);
-
- // Allocate an empty LUT for holding the result
- Result = cmsPipelineAlloc(ContextID, 4, 4);
- if (Result == NULL) return NULL;
-
- memset(&bp, 0, sizeof(bp));
-
- // We need the input LUT of the last profile, assuming this one is responsible of
- // black generation. This LUT will be searched in inverse order.
- bp.LabK2cmyk = _cmsReadInputLUT(hLastProfile, INTENT_RELATIVE_COLORIMETRIC);
- if (bp.LabK2cmyk == NULL) goto Cleanup;
-
- // Get total area coverage (in 0..1 domain)
- bp.MaxTAC = cmsDetectTAC(hLastProfile) / 100.0;
- if (bp.MaxTAC <= 0) goto Cleanup;
-
-
- // Create a LUT holding normal ICC transform
- bp.cmyk2cmyk = DefaultICCintents(ContextID,
- preservationProfilesCount,
- ICCIntents,
- hProfiles,
- BPC,
- AdaptationStates,
- dwFlags);
- if (bp.cmyk2cmyk == NULL) goto Cleanup;
-
- // Now the tone curve
- bp.KTone = _cmsBuildKToneCurve(ContextID, 4096, preservationProfilesCount,
- ICCIntents,
- hProfiles,
- BPC,
- AdaptationStates,
- dwFlags);
- if (bp.KTone == NULL) goto Cleanup;
-
- // To measure the output, Last profile to Lab
- hLab = cmsCreateLab4ProfileTHR(ContextID, NULL);
- bp.hProofOutput = cmsCreateTransformTHR(ContextID, hLastProfile,
- CHANNELS_SH(4)|BYTES_SH(2), hLab, TYPE_Lab_DBL,
- INTENT_RELATIVE_COLORIMETRIC,
- cmsFLAGS_NOCACHE|cmsFLAGS_NOOPTIMIZE);
- if ( bp.hProofOutput == NULL) goto Cleanup;
-
- // Same as anterior, but lab in the 0..1 range
- bp.cmyk2Lab = cmsCreateTransformTHR(ContextID, hLastProfile,
- FLOAT_SH(1)|CHANNELS_SH(4)|BYTES_SH(4), hLab,
- FLOAT_SH(1)|CHANNELS_SH(3)|BYTES_SH(4),
- INTENT_RELATIVE_COLORIMETRIC,
- cmsFLAGS_NOCACHE|cmsFLAGS_NOOPTIMIZE);
- if (bp.cmyk2Lab == NULL) goto Cleanup;
- cmsCloseProfile(hLab);
-
- // Error estimation (for debug only)
- bp.MaxError = 0;
-
- // How many gridpoints are we going to use?
- nGridPoints = _cmsReasonableGridpointsByColorspace(cmsSigCmykData, dwFlags);
-
-
- CLUT = cmsStageAllocCLut16bit(ContextID, nGridPoints, 4, 4, NULL);
- if (CLUT == NULL) goto Cleanup;
-
- if (!cmsPipelineInsertStage(Result, cmsAT_BEGIN, CLUT))
- goto Cleanup;
-
- cmsStageSampleCLut16bit(CLUT, BlackPreservingSampler, (void*) &bp, 0);
-
- // Insert possible devicelinks at the end
- for (i = lastProfilePos + 1; i < nProfiles; i++)
- {
- cmsPipeline* devlink = _cmsReadDevicelinkLUT(hProfiles[i], ICCIntents[i]);
- if (devlink == NULL)
- goto Cleanup;
-
- if (!cmsPipelineCat(Result, devlink))
- goto Cleanup;
- }
-
-
-Cleanup:
-
- if (bp.cmyk2cmyk) cmsPipelineFree(bp.cmyk2cmyk);
- if (bp.cmyk2Lab) cmsDeleteTransform(bp.cmyk2Lab);
- if (bp.hProofOutput) cmsDeleteTransform(bp.hProofOutput);
-
- if (bp.KTone) cmsFreeToneCurve(bp.KTone);
- if (bp.LabK2cmyk) cmsPipelineFree(bp.LabK2cmyk);
-
- return Result;
-}
-
-
-
-// Link routines ------------------------------------------------------------------------------------------------------
-
-// Chain several profiles into a single LUT. It just checks the parameters and then calls the handler
-// for the first intent in chain. The handler may be user-defined. Is up to the handler to deal with the
-// rest of intents in chain. A maximum of 255 profiles at time are supported, which is pretty reasonable.
-cmsPipeline* _cmsLinkProfiles(cmsContext ContextID,
- cmsUInt32Number nProfiles,
- cmsUInt32Number TheIntents[],
- cmsHPROFILE hProfiles[],
- cmsBool BPC[],
- cmsFloat64Number AdaptationStates[],
- cmsUInt32Number dwFlags)
-{
- cmsUInt32Number i;
- cmsIntentsList* Intent;
-
- // Make sure a reasonable number of profiles is provided
- if (nProfiles <= 0 || nProfiles > 255) {
- cmsSignalError(ContextID, cmsERROR_RANGE, "Couldn't link '%d' profiles", nProfiles);
- return NULL;
- }
-
- for (i=0; i < nProfiles; i++) {
-
- // Check if black point is really needed or allowed. Note that
- // following Adobe's document:
- // BPC does not apply to devicelink profiles, nor to abs colorimetric,
- // and applies always on V4 perceptual and saturation.
-
- if (TheIntents[i] == INTENT_ABSOLUTE_COLORIMETRIC)
- BPC[i] = FALSE;
-
- if (TheIntents[i] == INTENT_PERCEPTUAL || TheIntents[i] == INTENT_SATURATION) {
-
- // Force BPC for V4 profiles in perceptual and saturation
- if (cmsGetEncodedICCversion(hProfiles[i]) >= 0x4000000)
- BPC[i] = TRUE;
- }
- }
-
- // Search for a handler. The first intent in the chain defines the handler. That would
- // prevent using multiple custom intents in a multiintent chain, but the behaviour of
- // this case would present some issues if the custom intent tries to do things like
- // preserve primaries. This solution is not perfect, but works well on most cases.
-
- Intent = SearchIntent(ContextID, TheIntents[0]);
- if (Intent == NULL) {
- cmsSignalError(ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unsupported intent '%d'", TheIntents[0]);
- return NULL;
- }
-
- // Call the handler
- return Intent ->Link(ContextID, nProfiles, TheIntents, hProfiles, BPC, AdaptationStates, dwFlags);
-}
-
-// -------------------------------------------------------------------------------------------------
-
-// Get information about available intents. nMax is the maximum space for the supplied "Codes"
-// and "Descriptions" the function returns the total number of intents, which may be greater
-// than nMax, although the matrices are not populated beyond this level.
-cmsUInt32Number CMSEXPORT cmsGetSupportedIntentsTHR(cmsContext ContextID, cmsUInt32Number nMax, cmsUInt32Number* Codes, char** Descriptions)
-{
- _cmsIntentsPluginChunkType* ctx = ( _cmsIntentsPluginChunkType*) _cmsContextGetClientChunk(ContextID, IntentPlugin);
- cmsIntentsList* pt;
- cmsUInt32Number nIntents;
-
- for (nIntents=0, pt = DefaultIntents; pt != NULL; pt = pt -> Next)
- {
- if (nIntents < nMax) {
- if (Codes != NULL)
- Codes[nIntents] = pt ->Intent;
-
- if (Descriptions != NULL)
- Descriptions[nIntents] = pt ->Description;
- }
-
- nIntents++;
- }
-
- for (pt = ctx->Intents; pt != NULL; pt = pt -> Next)
- {
- if (nIntents < nMax) {
- if (Codes != NULL)
- Codes[nIntents] = pt ->Intent;
-
- if (Descriptions != NULL)
- Descriptions[nIntents] = pt ->Description;
- }
-
- nIntents++;
- }
-
- return nIntents;
-}
-
-cmsUInt32Number CMSEXPORT cmsGetSupportedIntents(cmsUInt32Number nMax, cmsUInt32Number* Codes, char** Descriptions)
-{
- return cmsGetSupportedIntentsTHR(NULL, nMax, Codes, Descriptions);
-}
-
-// The plug-in registration. User can add new intents or override default routines
-cmsBool _cmsRegisterRenderingIntentPlugin(cmsContext id, cmsPluginBase* Data)
-{
- _cmsIntentsPluginChunkType* ctx = ( _cmsIntentsPluginChunkType*) _cmsContextGetClientChunk(id, IntentPlugin);
- cmsPluginRenderingIntent* Plugin = (cmsPluginRenderingIntent*) Data;
- cmsIntentsList* fl;
-
- // Do we have to reset the custom intents?
- if (Data == NULL) {
-
- ctx->Intents = NULL;
- return TRUE;
- }
-
- fl = (cmsIntentsList*) _cmsPluginMalloc(id, sizeof(cmsIntentsList));
- if (fl == NULL) return FALSE;
-
-
- fl ->Intent = Plugin ->Intent;
- strncpy(fl ->Description, Plugin ->Description, sizeof(fl ->Description)-1);
- fl ->Description[sizeof(fl ->Description)-1] = 0;
-
- fl ->Link = Plugin ->Link;
-
- fl ->Next = ctx ->Intents;
- ctx ->Intents = fl;
-
- return TRUE;
-}
-
diff --git a/contrib/libs/lcms2/src/cmserr.c b/contrib/libs/lcms2/src/cmserr.c
deleted file mode 100644
index 811c63502d..0000000000
--- a/contrib/libs/lcms2/src/cmserr.c
+++ /dev/null
@@ -1,707 +0,0 @@
-//---------------------------------------------------------------------------------
-//
-// Little Color Management System
-// Copyright (c) 1998-2023 Marti Maria Saguer
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//---------------------------------------------------------------------------------
-
-#include "lcms2_internal.h"
-
-
-// This function is here to help applications to prevent mixing lcms versions on header and shared objects.
-int CMSEXPORT cmsGetEncodedCMMversion(void)
-{
- return LCMS_VERSION;
-}
-
-// I am so tired about incompatibilities on those functions that here are some replacements
-// that hopefully would be fully portable.
-
-// compare two strings ignoring case
-int CMSEXPORT cmsstrcasecmp(const char* s1, const char* s2)
-{
- CMSREGISTER const unsigned char *us1 = (const unsigned char *)s1,
- *us2 = (const unsigned char *)s2;
-
- while (toupper(*us1) == toupper(*us2++))
- if (*us1++ == '\0')
- return 0;
-
- return (toupper(*us1) - toupper(*--us2));
-}
-
-// long int because C99 specifies ftell in such way (7.19.9.2)
-long int CMSEXPORT cmsfilelength(FILE* f)
-{
- long int p , n;
-
- p = ftell(f); // register current file position
- if (p == -1L)
- return -1L;
-
- if (fseek(f, 0, SEEK_END) != 0) {
- return -1L;
- }
-
- n = ftell(f);
- fseek(f, p, SEEK_SET); // file position restored
-
- return n;
-}
-
-
-// Memory handling ------------------------------------------------------------------
-//
-// This is the interface to low-level memory management routines. By default a simple
-// wrapping to malloc/free/realloc is provided, although there is a limit on the max
-// amount of memory that can be reclaimed. This is mostly as a safety feature to prevent
-// bogus or evil code to allocate huge blocks that otherwise lcms would never need.
-
-#define MAX_MEMORY_FOR_ALLOC ((cmsUInt32Number)(1024U*1024U*512U))
-
-// User may override this behaviour by using a memory plug-in, which basically replaces
-// the default memory management functions. In this case, no check is performed and it
-// is up to the plug-in writer to keep in the safe side. There are only three functions
-// required to be implemented: malloc, realloc and free, although the user may want to
-// replace the optional mallocZero, calloc and dup as well.
-
-cmsBool _cmsRegisterMemHandlerPlugin(cmsContext ContextID, cmsPluginBase* Plugin);
-
-// *********************************************************************************
-
-// This is the default memory allocation function. It does a very coarse
-// check of amount of memory, just to prevent exploits
-static
-void* _cmsMallocDefaultFn(cmsContext ContextID, cmsUInt32Number size)
-{
- // Never allow 0 or over maximum
- if (size == 0 || size > MAX_MEMORY_FOR_ALLOC) return NULL;
-
- return (void*) malloc(size);
-
- cmsUNUSED_PARAMETER(ContextID);
-}
-
-// Generic allocate & zero
-static
-void* _cmsMallocZeroDefaultFn(cmsContext ContextID, cmsUInt32Number size)
-{
- void *pt = _cmsMalloc(ContextID, size);
- if (pt == NULL) return NULL;
-
- memset(pt, 0, size);
- return pt;
-}
-
-
-// The default free function. The only check proformed is against NULL pointers
-static
-void _cmsFreeDefaultFn(cmsContext ContextID, void *Ptr)
-{
- // free(NULL) is defined a no-op by C99, therefore it is safe to
- // avoid the check, but it is here just in case...
-
- if (Ptr) free(Ptr);
-
- cmsUNUSED_PARAMETER(ContextID);
-}
-
-// The default realloc function. Again it checks for exploits. If Ptr is NULL,
-// realloc behaves the same way as malloc and allocates a new block of size bytes.
-static
-void* _cmsReallocDefaultFn(cmsContext ContextID, void* Ptr, cmsUInt32Number size)
-{
-
- if (size > MAX_MEMORY_FOR_ALLOC) return NULL; // Never realloc over 512Mb
-
- return realloc(Ptr, size);
-
- cmsUNUSED_PARAMETER(ContextID);
-}
-
-
-// The default calloc function. Allocates an array of num elements, each one of size bytes
-// all memory is initialized to zero.
-static
-void* _cmsCallocDefaultFn(cmsContext ContextID, cmsUInt32Number num, cmsUInt32Number size)
-{
- cmsUInt32Number Total = num * size;
-
- // Preserve calloc behaviour
- if (Total == 0) return NULL;
-
- // Safe check for overflow.
- if (num >= UINT_MAX / size) return NULL;
-
- // Check for overflow
- if (Total < num || Total < size) {
- return NULL;
- }
-
- if (Total > MAX_MEMORY_FOR_ALLOC) return NULL; // Never alloc over 512Mb
-
- return _cmsMallocZero(ContextID, Total);
-}
-
-// Generic block duplication
-static
-void* _cmsDupDefaultFn(cmsContext ContextID, const void* Org, cmsUInt32Number size)
-{
- void* mem;
-
- if (size > MAX_MEMORY_FOR_ALLOC) return NULL; // Never dup over 512Mb
-
- mem = _cmsMalloc(ContextID, size);
-
- if (mem != NULL && Org != NULL)
- memmove(mem, Org, size);
-
- return mem;
-}
-
-
-// Pointers to memory manager functions in Context0
-_cmsMemPluginChunkType _cmsMemPluginChunk = { _cmsMallocDefaultFn, _cmsMallocZeroDefaultFn, _cmsFreeDefaultFn,
- _cmsReallocDefaultFn, _cmsCallocDefaultFn, _cmsDupDefaultFn
- };
-
-
-// Reset and duplicate memory manager
-void _cmsAllocMemPluginChunk(struct _cmsContext_struct* ctx, const struct _cmsContext_struct* src)
-{
- _cmsAssert(ctx != NULL);
-
- if (src != NULL) {
-
- // Duplicate
- ctx ->chunks[MemPlugin] = _cmsSubAllocDup(ctx ->MemPool, src ->chunks[MemPlugin], sizeof(_cmsMemPluginChunkType));
- }
- else {
-
- // To reset it, we use the default allocators, which cannot be overridden
- ctx ->chunks[MemPlugin] = &ctx ->DefaultMemoryManager;
- }
-}
-
-// Auxiliary to fill memory management functions from plugin (or context 0 defaults)
-void _cmsInstallAllocFunctions(cmsPluginMemHandler* Plugin, _cmsMemPluginChunkType* ptr)
-{
- if (Plugin == NULL) {
-
- memcpy(ptr, &_cmsMemPluginChunk, sizeof(_cmsMemPluginChunk));
- }
- else {
-
- ptr ->MallocPtr = Plugin -> MallocPtr;
- ptr ->FreePtr = Plugin -> FreePtr;
- ptr ->ReallocPtr = Plugin -> ReallocPtr;
-
- // Make sure we revert to defaults
- ptr ->MallocZeroPtr= _cmsMallocZeroDefaultFn;
- ptr ->CallocPtr = _cmsCallocDefaultFn;
- ptr ->DupPtr = _cmsDupDefaultFn;
-
- if (Plugin ->MallocZeroPtr != NULL) ptr ->MallocZeroPtr = Plugin -> MallocZeroPtr;
- if (Plugin ->CallocPtr != NULL) ptr ->CallocPtr = Plugin -> CallocPtr;
- if (Plugin ->DupPtr != NULL) ptr ->DupPtr = Plugin -> DupPtr;
-
- }
-}
-
-
-// Plug-in replacement entry
-cmsBool _cmsRegisterMemHandlerPlugin(cmsContext ContextID, cmsPluginBase *Data)
-{
- cmsPluginMemHandler* Plugin = (cmsPluginMemHandler*) Data;
- _cmsMemPluginChunkType* ptr;
-
- // NULL forces to reset to defaults. In this special case, the defaults are stored in the context structure.
- // Remaining plug-ins does NOT have any copy in the context structure, but this is somehow special as the
- // context internal data should be malloc'ed by using those functions.
- if (Data == NULL) {
-
- struct _cmsContext_struct* ctx = ( struct _cmsContext_struct*) ContextID;
-
- // Return to the default allocators
- if (ContextID != NULL) {
- ctx->chunks[MemPlugin] = (void*) &ctx->DefaultMemoryManager;
- }
- return TRUE;
- }
-
- // Check for required callbacks
- if (Plugin -> MallocPtr == NULL ||
- Plugin -> FreePtr == NULL ||
- Plugin -> ReallocPtr == NULL) return FALSE;
-
- // Set replacement functions
- ptr = (_cmsMemPluginChunkType*) _cmsContextGetClientChunk(ContextID, MemPlugin);
- if (ptr == NULL)
- return FALSE;
-
- _cmsInstallAllocFunctions(Plugin, ptr);
- return TRUE;
-}
-
-// Generic allocate
-void* CMSEXPORT _cmsMalloc(cmsContext ContextID, cmsUInt32Number size)
-{
- _cmsMemPluginChunkType* ptr = (_cmsMemPluginChunkType*) _cmsContextGetClientChunk(ContextID, MemPlugin);
- return ptr ->MallocPtr(ContextID, size);
-}
-
-// Generic allocate & zero
-void* CMSEXPORT _cmsMallocZero(cmsContext ContextID, cmsUInt32Number size)
-{
- _cmsMemPluginChunkType* ptr = (_cmsMemPluginChunkType*) _cmsContextGetClientChunk(ContextID, MemPlugin);
- return ptr->MallocZeroPtr(ContextID, size);
-}
-
-// Generic calloc
-void* CMSEXPORT _cmsCalloc(cmsContext ContextID, cmsUInt32Number num, cmsUInt32Number size)
-{
- _cmsMemPluginChunkType* ptr = (_cmsMemPluginChunkType*) _cmsContextGetClientChunk(ContextID, MemPlugin);
- return ptr->CallocPtr(ContextID, num, size);
-}
-
-// Generic reallocate
-void* CMSEXPORT _cmsRealloc(cmsContext ContextID, void* Ptr, cmsUInt32Number size)
-{
- _cmsMemPluginChunkType* ptr = (_cmsMemPluginChunkType*) _cmsContextGetClientChunk(ContextID, MemPlugin);
- return ptr->ReallocPtr(ContextID, Ptr, size);
-}
-
-// Generic free memory
-void CMSEXPORT _cmsFree(cmsContext ContextID, void* Ptr)
-{
- if (Ptr != NULL) {
- _cmsMemPluginChunkType* ptr = (_cmsMemPluginChunkType*) _cmsContextGetClientChunk(ContextID, MemPlugin);
- ptr ->FreePtr(ContextID, Ptr);
- }
-}
-
-// Generic block duplication
-void* CMSEXPORT _cmsDupMem(cmsContext ContextID, const void* Org, cmsUInt32Number size)
-{
- _cmsMemPluginChunkType* ptr = (_cmsMemPluginChunkType*) _cmsContextGetClientChunk(ContextID, MemPlugin);
- return ptr ->DupPtr(ContextID, Org, size);
-}
-
-// ********************************************************************************************
-
-// Sub allocation takes care of many pointers of small size. The memory allocated in
-// this way have be freed at once. Next function allocates a single chunk for linked list
-// I prefer this method over realloc due to the big impact on xput realloc may have if
-// memory is being swapped to disk. This approach is safer (although that may not be true on all platforms)
-static
-_cmsSubAllocator_chunk* _cmsCreateSubAllocChunk(cmsContext ContextID, cmsUInt32Number Initial)
-{
- _cmsSubAllocator_chunk* chunk;
-
- // 20K by default
- if (Initial == 0)
- Initial = 20*1024;
-
- // Create the container
- chunk = (_cmsSubAllocator_chunk*) _cmsMallocZero(ContextID, sizeof(_cmsSubAllocator_chunk));
- if (chunk == NULL) return NULL;
-
- // Initialize values
- chunk ->Block = (cmsUInt8Number*) _cmsMalloc(ContextID, Initial);
- if (chunk ->Block == NULL) {
-
- // Something went wrong
- _cmsFree(ContextID, chunk);
- return NULL;
- }
-
- chunk ->BlockSize = Initial;
- chunk ->Used = 0;
- chunk ->next = NULL;
-
- return chunk;
-}
-
-// The suballocated is nothing but a pointer to the first element in the list. We also keep
-// the thread ID in this structure.
-_cmsSubAllocator* _cmsCreateSubAlloc(cmsContext ContextID, cmsUInt32Number Initial)
-{
- _cmsSubAllocator* sub;
-
- // Create the container
- sub = (_cmsSubAllocator*) _cmsMallocZero(ContextID, sizeof(_cmsSubAllocator));
- if (sub == NULL) return NULL;
-
- sub ->ContextID = ContextID;
-
- sub ->h = _cmsCreateSubAllocChunk(ContextID, Initial);
- if (sub ->h == NULL) {
- _cmsFree(ContextID, sub);
- return NULL;
- }
-
- return sub;
-}
-
-
-// Get rid of whole linked list
-void _cmsSubAllocDestroy(_cmsSubAllocator* sub)
-{
- _cmsSubAllocator_chunk *chunk, *n;
-
- for (chunk = sub ->h; chunk != NULL; chunk = n) {
-
- n = chunk->next;
- if (chunk->Block != NULL) _cmsFree(sub ->ContextID, chunk->Block);
- _cmsFree(sub ->ContextID, chunk);
- }
-
- // Free the header
- _cmsFree(sub ->ContextID, sub);
-}
-
-
-// Get a pointer to small memory block.
-void* _cmsSubAlloc(_cmsSubAllocator* sub, cmsUInt32Number size)
-{
- cmsUInt32Number Free = sub -> h ->BlockSize - sub -> h -> Used;
- cmsUInt8Number* ptr;
-
- size = _cmsALIGNMEM(size);
-
- // Check for memory. If there is no room, allocate a new chunk of double memory size.
- if (size > Free) {
-
- _cmsSubAllocator_chunk* chunk;
- cmsUInt32Number newSize;
-
- newSize = sub -> h ->BlockSize * 2;
- if (newSize < size) newSize = size;
-
- chunk = _cmsCreateSubAllocChunk(sub -> ContextID, newSize);
- if (chunk == NULL) return NULL;
-
- // Link list
- chunk ->next = sub ->h;
- sub ->h = chunk;
-
- }
-
- ptr = sub -> h ->Block + sub -> h ->Used;
- sub -> h -> Used += size;
-
- return (void*) ptr;
-}
-
-// Duplicate in pool
-void* _cmsSubAllocDup(_cmsSubAllocator* s, const void *ptr, cmsUInt32Number size)
-{
- void *NewPtr;
-
- // Dup of null pointer is also NULL
- if (ptr == NULL)
- return NULL;
-
- NewPtr = _cmsSubAlloc(s, size);
-
- if (ptr != NULL && NewPtr != NULL) {
- memcpy(NewPtr, ptr, size);
- }
-
- return NewPtr;
-}
-
-
-
-// Error logging ******************************************************************
-
-// There is no error handling at all. When a function fails, it returns proper value.
-// For example, all create functions does return NULL on failure. Other return FALSE
-// It may be interesting, for the developer, to know why the function is failing.
-// for that reason, lcms2 does offer a logging function. This function does receive
-// a ENGLISH string with some clues on what is going wrong. You can show this
-// info to the end user, or just create some sort of log.
-// The logging function should NOT terminate the program, as this obviously can leave
-// resources. It is the programmer's responsibility to check each function return code
-// to make sure it didn't fail.
-
-// Error messages are limited to MAX_ERROR_MESSAGE_LEN
-
-#define MAX_ERROR_MESSAGE_LEN 1024
-
-// ---------------------------------------------------------------------------------------------------------
-
-// This is our default log error
-static void DefaultLogErrorHandlerFunction(cmsContext ContextID, cmsUInt32Number ErrorCode, const char *Text);
-
-// Context0 storage, which is global
-_cmsLogErrorChunkType _cmsLogErrorChunk = { DefaultLogErrorHandlerFunction };
-
-// Allocates and inits error logger container for a given context. If src is NULL, only initializes the value
-// to the default. Otherwise, it duplicates the value. The interface is standard across all context clients
-void _cmsAllocLogErrorChunk(struct _cmsContext_struct* ctx,
- const struct _cmsContext_struct* src)
-{
- static _cmsLogErrorChunkType LogErrorChunk = { DefaultLogErrorHandlerFunction };
- void* from;
-
- if (src != NULL) {
- from = src ->chunks[Logger];
- }
- else {
- from = &LogErrorChunk;
- }
-
- ctx ->chunks[Logger] = _cmsSubAllocDup(ctx ->MemPool, from, sizeof(_cmsLogErrorChunkType));
-}
-
-// The default error logger does nothing.
-static
-void DefaultLogErrorHandlerFunction(cmsContext ContextID, cmsUInt32Number ErrorCode, const char *Text)
-{
- // fprintf(stderr, "[lcms]: %s\n", Text);
- // fflush(stderr);
-
- cmsUNUSED_PARAMETER(ContextID);
- cmsUNUSED_PARAMETER(ErrorCode);
- cmsUNUSED_PARAMETER(Text);
-}
-
-// Change log error, context based
-void CMSEXPORT cmsSetLogErrorHandlerTHR(cmsContext ContextID, cmsLogErrorHandlerFunction Fn)
-{
- _cmsLogErrorChunkType* lhg = (_cmsLogErrorChunkType*) _cmsContextGetClientChunk(ContextID, Logger);
-
- if (lhg != NULL) {
-
- if (Fn == NULL)
- lhg -> LogErrorHandler = DefaultLogErrorHandlerFunction;
- else
- lhg -> LogErrorHandler = Fn;
- }
-}
-
-// Change log error, legacy
-void CMSEXPORT cmsSetLogErrorHandler(cmsLogErrorHandlerFunction Fn)
-{
- cmsSetLogErrorHandlerTHR(NULL, Fn);
-}
-
-// Log an error
-// ErrorText is a text holding an english description of error.
-void CMSEXPORT cmsSignalError(cmsContext ContextID, cmsUInt32Number ErrorCode, const char *ErrorText, ...)
-{
- va_list args;
- char Buffer[MAX_ERROR_MESSAGE_LEN];
- _cmsLogErrorChunkType* lhg;
-
-
- va_start(args, ErrorText);
- vsnprintf(Buffer, MAX_ERROR_MESSAGE_LEN-1, ErrorText, args);
- va_end(args);
-
- // Check for the context, if specified go there. If not, go for the global
- lhg = (_cmsLogErrorChunkType*) _cmsContextGetClientChunk(ContextID, Logger);
- if (lhg ->LogErrorHandler) {
- lhg ->LogErrorHandler(ContextID, ErrorCode, Buffer);
- }
-}
-
-// Utility function to print signatures
-void _cmsTagSignature2String(char String[5], cmsTagSignature sig)
-{
- cmsUInt32Number be;
-
- // Convert to big endian
- be = _cmsAdjustEndianess32((cmsUInt32Number) sig);
-
- // Move chars
- memmove(String, &be, 4);
-
- // Make sure of terminator
- String[4] = 0;
-}
-
-//--------------------------------------------------------------------------------------------------
-
-
-static
-void* defMtxCreate(cmsContext id)
-{
- _cmsMutex* ptr_mutex = (_cmsMutex*) _cmsMalloc(id, sizeof(_cmsMutex));
- _cmsInitMutexPrimitive(ptr_mutex);
- return (void*) ptr_mutex;
-}
-
-static
-void defMtxDestroy(cmsContext id, void* mtx)
-{
- _cmsDestroyMutexPrimitive((_cmsMutex *) mtx);
- _cmsFree(id, mtx);
-}
-
-static
-cmsBool defMtxLock(cmsContext id, void* mtx)
-{
- cmsUNUSED_PARAMETER(id);
- return _cmsLockPrimitive((_cmsMutex *) mtx) == 0;
-}
-
-static
-void defMtxUnlock(cmsContext id, void* mtx)
-{
- cmsUNUSED_PARAMETER(id);
- _cmsUnlockPrimitive((_cmsMutex *) mtx);
-}
-
-
-
-// Pointers to memory manager functions in Context0
-_cmsMutexPluginChunkType _cmsMutexPluginChunk = { defMtxCreate, defMtxDestroy, defMtxLock, defMtxUnlock };
-
-// Allocate and init mutex container.
-void _cmsAllocMutexPluginChunk(struct _cmsContext_struct* ctx,
- const struct _cmsContext_struct* src)
-{
- static _cmsMutexPluginChunkType MutexChunk = {defMtxCreate, defMtxDestroy, defMtxLock, defMtxUnlock };
- void* from;
-
- if (src != NULL) {
- from = src ->chunks[MutexPlugin];
- }
- else {
- from = &MutexChunk;
- }
-
- ctx ->chunks[MutexPlugin] = _cmsSubAllocDup(ctx ->MemPool, from, sizeof(_cmsMutexPluginChunkType));
-}
-
-// Register new ways to transform
-cmsBool _cmsRegisterMutexPlugin(cmsContext ContextID, cmsPluginBase* Data)
-{
- cmsPluginMutex* Plugin = (cmsPluginMutex*) Data;
- _cmsMutexPluginChunkType* ctx = ( _cmsMutexPluginChunkType*) _cmsContextGetClientChunk(ContextID, MutexPlugin);
-
- if (Data == NULL) {
-
- // No lock routines
- ctx->CreateMutexPtr = NULL;
- ctx->DestroyMutexPtr = NULL;
- ctx->LockMutexPtr = NULL;
- ctx ->UnlockMutexPtr = NULL;
- return TRUE;
- }
-
- // Factory callback is required
- if (Plugin ->CreateMutexPtr == NULL || Plugin ->DestroyMutexPtr == NULL ||
- Plugin ->LockMutexPtr == NULL || Plugin ->UnlockMutexPtr == NULL) return FALSE;
-
- ctx->CreateMutexPtr = Plugin->CreateMutexPtr;
- ctx->DestroyMutexPtr = Plugin ->DestroyMutexPtr;
- ctx ->LockMutexPtr = Plugin ->LockMutexPtr;
- ctx ->UnlockMutexPtr = Plugin ->UnlockMutexPtr;
-
- // All is ok
- return TRUE;
-}
-
-// Generic Mutex fns
-void* CMSEXPORT _cmsCreateMutex(cmsContext ContextID)
-{
- _cmsMutexPluginChunkType* ptr = (_cmsMutexPluginChunkType*) _cmsContextGetClientChunk(ContextID, MutexPlugin);
-
- if (ptr ->CreateMutexPtr == NULL) return NULL;
-
- return ptr ->CreateMutexPtr(ContextID);
-}
-
-void CMSEXPORT _cmsDestroyMutex(cmsContext ContextID, void* mtx)
-{
- _cmsMutexPluginChunkType* ptr = (_cmsMutexPluginChunkType*) _cmsContextGetClientChunk(ContextID, MutexPlugin);
-
- if (ptr ->DestroyMutexPtr != NULL) {
-
- ptr ->DestroyMutexPtr(ContextID, mtx);
- }
-}
-
-cmsBool CMSEXPORT _cmsLockMutex(cmsContext ContextID, void* mtx)
-{
- _cmsMutexPluginChunkType* ptr = (_cmsMutexPluginChunkType*) _cmsContextGetClientChunk(ContextID, MutexPlugin);
-
- if (ptr ->LockMutexPtr == NULL) return TRUE;
-
- return ptr ->LockMutexPtr(ContextID, mtx);
-}
-
-void CMSEXPORT _cmsUnlockMutex(cmsContext ContextID, void* mtx)
-{
- _cmsMutexPluginChunkType* ptr = (_cmsMutexPluginChunkType*) _cmsContextGetClientChunk(ContextID, MutexPlugin);
-
- if (ptr ->UnlockMutexPtr != NULL) {
-
- ptr ->UnlockMutexPtr(ContextID, mtx);
- }
-}
-
-// The global Context0 storage for parallelization plug-in
- _cmsParallelizationPluginChunkType _cmsParallelizationPluginChunk = { 0 };
-
-// Allocate parallelization container.
-void _cmsAllocParallelizationPluginChunk(struct _cmsContext_struct* ctx,
- const struct _cmsContext_struct* src)
-{
- if (src != NULL) {
- void* from = src->chunks[ParallelizationPlugin];
- ctx->chunks[ParallelizationPlugin] = _cmsSubAllocDup(ctx->MemPool, from, sizeof(_cmsParallelizationPluginChunkType));
- }
- else {
- _cmsParallelizationPluginChunkType ParallelizationPluginChunk = { 0 };
- ctx->chunks[ParallelizationPlugin] = _cmsSubAllocDup(ctx->MemPool, &ParallelizationPluginChunk, sizeof(_cmsParallelizationPluginChunkType));
- }
-}
-
-// Register parallel processing
-cmsBool _cmsRegisterParallelizationPlugin(cmsContext ContextID, cmsPluginBase* Data)
-{
- cmsPluginParalellization* Plugin = (cmsPluginParalellization*)Data;
- _cmsParallelizationPluginChunkType* ctx = (_cmsParallelizationPluginChunkType*)_cmsContextGetClientChunk(ContextID, ParallelizationPlugin);
-
- if (Data == NULL) {
-
- // No parallelization routines
- ctx->MaxWorkers = 0;
- ctx->WorkerFlags = 0;
- ctx->SchedulerFn = NULL;
- return TRUE;
- }
-
- // callback is required
- if (Plugin->SchedulerFn == NULL) return FALSE;
-
- ctx->MaxWorkers = Plugin->MaxWorkers;
- ctx->WorkerFlags = Plugin->WorkerFlags;
- ctx->SchedulerFn = Plugin->SchedulerFn;
-
- // All is ok
- return TRUE;
-}
-
diff --git a/contrib/libs/lcms2/src/cmsgamma.c b/contrib/libs/lcms2/src/cmsgamma.c
deleted file mode 100644
index a8a8946205..0000000000
--- a/contrib/libs/lcms2/src/cmsgamma.c
+++ /dev/null
@@ -1,1513 +0,0 @@
-//---------------------------------------------------------------------------------
-//
-// Little Color Management System
-// Copyright (c) 1998-2023 Marti Maria Saguer
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//---------------------------------------------------------------------------------
-//
-#include "lcms2_internal.h"
-
-// Tone curves are powerful constructs that can contain curves specified in diverse ways.
-// The curve is stored in segments, where each segment can be sampled or specified by parameters.
-// a 16.bit simplification of the *whole* curve is kept for optimization purposes. For float operation,
-// each segment is evaluated separately. Plug-ins may be used to define new parametric schemes,
-// each plug-in may define up to MAX_TYPES_IN_LCMS_PLUGIN functions types. For defining a function,
-// the plug-in should provide the type id, how many parameters each type has, and a pointer to
-// a procedure that evaluates the function. In the case of reverse evaluation, the evaluator will
-// be called with the type id as a negative value, and a sampled version of the reversed curve
-// will be built.
-
-// ----------------------------------------------------------------- Implementation
-// Maxim number of nodes
-#define MAX_NODES_IN_CURVE 4097
-#define MINUS_INF (-1E22F)
-#define PLUS_INF (+1E22F)
-
-// The list of supported parametric curves
-typedef struct _cmsParametricCurvesCollection_st {
-
- cmsUInt32Number nFunctions; // Number of supported functions in this chunk
- cmsInt32Number FunctionTypes[MAX_TYPES_IN_LCMS_PLUGIN]; // The identification types
- cmsUInt32Number ParameterCount[MAX_TYPES_IN_LCMS_PLUGIN]; // Number of parameters for each function
-
- cmsParametricCurveEvaluator Evaluator; // The evaluator
-
- struct _cmsParametricCurvesCollection_st* Next; // Next in list
-
-} _cmsParametricCurvesCollection;
-
-// This is the default (built-in) evaluator
-static cmsFloat64Number DefaultEvalParametricFn(cmsInt32Number Type, const cmsFloat64Number Params[], cmsFloat64Number R);
-
-// The built-in list
-static _cmsParametricCurvesCollection DefaultCurves = {
- 10, // # of curve types
- { 1, 2, 3, 4, 5, 6, 7, 8, 108, 109 }, // Parametric curve ID
- { 1, 3, 4, 5, 7, 4, 5, 5, 1, 1 }, // Parameters by type
- DefaultEvalParametricFn, // Evaluator
- NULL // Next in chain
-};
-
-// Duplicates the zone of memory used by the plug-in in the new context
-static
-void DupPluginCurvesList(struct _cmsContext_struct* ctx,
- const struct _cmsContext_struct* src)
-{
- _cmsCurvesPluginChunkType newHead = { NULL };
- _cmsParametricCurvesCollection* entry;
- _cmsParametricCurvesCollection* Anterior = NULL;
- _cmsCurvesPluginChunkType* head = (_cmsCurvesPluginChunkType*) src->chunks[CurvesPlugin];
-
- _cmsAssert(head != NULL);
-
- // Walk the list copying all nodes
- for (entry = head->ParametricCurves;
- entry != NULL;
- entry = entry ->Next) {
-
- _cmsParametricCurvesCollection *newEntry = ( _cmsParametricCurvesCollection *) _cmsSubAllocDup(ctx ->MemPool, entry, sizeof(_cmsParametricCurvesCollection));
-
- if (newEntry == NULL)
- return;
-
- // We want to keep the linked list order, so this is a little bit tricky
- newEntry -> Next = NULL;
- if (Anterior)
- Anterior -> Next = newEntry;
-
- Anterior = newEntry;
-
- if (newHead.ParametricCurves == NULL)
- newHead.ParametricCurves = newEntry;
- }
-
- ctx ->chunks[CurvesPlugin] = _cmsSubAllocDup(ctx->MemPool, &newHead, sizeof(_cmsCurvesPluginChunkType));
-}
-
-// The allocator have to follow the chain
-void _cmsAllocCurvesPluginChunk(struct _cmsContext_struct* ctx,
- const struct _cmsContext_struct* src)
-{
- _cmsAssert(ctx != NULL);
-
- if (src != NULL) {
-
- // Copy all linked list
- DupPluginCurvesList(ctx, src);
- }
- else {
- static _cmsCurvesPluginChunkType CurvesPluginChunk = { NULL };
- ctx ->chunks[CurvesPlugin] = _cmsSubAllocDup(ctx ->MemPool, &CurvesPluginChunk, sizeof(_cmsCurvesPluginChunkType));
- }
-}
-
-
-// The linked list head
-_cmsCurvesPluginChunkType _cmsCurvesPluginChunk = { NULL };
-
-// As a way to install new parametric curves
-cmsBool _cmsRegisterParametricCurvesPlugin(cmsContext ContextID, cmsPluginBase* Data)
-{
- _cmsCurvesPluginChunkType* ctx = ( _cmsCurvesPluginChunkType*) _cmsContextGetClientChunk(ContextID, CurvesPlugin);
- cmsPluginParametricCurves* Plugin = (cmsPluginParametricCurves*) Data;
- _cmsParametricCurvesCollection* fl;
-
- if (Data == NULL) {
-
- ctx -> ParametricCurves = NULL;
- return TRUE;
- }
-
- fl = (_cmsParametricCurvesCollection*) _cmsPluginMalloc(ContextID, sizeof(_cmsParametricCurvesCollection));
- if (fl == NULL) return FALSE;
-
- // Copy the parameters
- fl ->Evaluator = Plugin ->Evaluator;
- fl ->nFunctions = Plugin ->nFunctions;
-
- // Make sure no mem overwrites
- if (fl ->nFunctions > MAX_TYPES_IN_LCMS_PLUGIN)
- fl ->nFunctions = MAX_TYPES_IN_LCMS_PLUGIN;
-
- // Copy the data
- memmove(fl->FunctionTypes, Plugin ->FunctionTypes, fl->nFunctions * sizeof(cmsUInt32Number));
- memmove(fl->ParameterCount, Plugin ->ParameterCount, fl->nFunctions * sizeof(cmsUInt32Number));
-
- // Keep linked list
- fl ->Next = ctx->ParametricCurves;
- ctx->ParametricCurves = fl;
-
- // All is ok
- return TRUE;
-}
-
-
-// Search in type list, return position or -1 if not found
-static
-int IsInSet(int Type, _cmsParametricCurvesCollection* c)
-{
- int i;
-
- for (i=0; i < (int) c ->nFunctions; i++)
- if (abs(Type) == c ->FunctionTypes[i]) return i;
-
- return -1;
-}
-
-
-// Search for the collection which contains a specific type
-static
-_cmsParametricCurvesCollection *GetParametricCurveByType(cmsContext ContextID, int Type, int* index)
-{
- _cmsParametricCurvesCollection* c;
- int Position;
- _cmsCurvesPluginChunkType* ctx = ( _cmsCurvesPluginChunkType*) _cmsContextGetClientChunk(ContextID, CurvesPlugin);
-
- for (c = ctx->ParametricCurves; c != NULL; c = c ->Next) {
-
- Position = IsInSet(Type, c);
-
- if (Position != -1) {
- if (index != NULL)
- *index = Position;
- return c;
- }
- }
- // If none found, revert for defaults
- for (c = &DefaultCurves; c != NULL; c = c ->Next) {
-
- Position = IsInSet(Type, c);
-
- if (Position != -1) {
- if (index != NULL)
- *index = Position;
- return c;
- }
- }
-
- return NULL;
-}
-
-// Low level allocate, which takes care of memory details. nEntries may be zero, and in this case
-// no optimization curve is computed. nSegments may also be zero in the inverse case, where only the
-// optimization curve is given. Both features simultaneously is an error
-static
-cmsToneCurve* AllocateToneCurveStruct(cmsContext ContextID, cmsUInt32Number nEntries,
- cmsUInt32Number nSegments, const cmsCurveSegment* Segments,
- const cmsUInt16Number* Values)
-{
- cmsToneCurve* p;
- cmsUInt32Number i;
-
- // We allow huge tables, which are then restricted for smoothing operations
- if (nEntries > 65530) {
- cmsSignalError(ContextID, cmsERROR_RANGE, "Couldn't create tone curve of more than 65530 entries");
- return NULL;
- }
-
- if (nEntries == 0 && nSegments == 0) {
- cmsSignalError(ContextID, cmsERROR_RANGE, "Couldn't create tone curve with zero segments and no table");
- return NULL;
- }
-
- // Allocate all required pointers, etc.
- p = (cmsToneCurve*) _cmsMallocZero(ContextID, sizeof(cmsToneCurve));
- if (!p) return NULL;
-
- // In this case, there are no segments
- if (nSegments == 0) {
- p ->Segments = NULL;
- p ->Evals = NULL;
- }
- else {
- p ->Segments = (cmsCurveSegment*) _cmsCalloc(ContextID, nSegments, sizeof(cmsCurveSegment));
- if (p ->Segments == NULL) goto Error;
-
- p ->Evals = (cmsParametricCurveEvaluator*) _cmsCalloc(ContextID, nSegments, sizeof(cmsParametricCurveEvaluator));
- if (p ->Evals == NULL) goto Error;
- }
-
- p -> nSegments = nSegments;
-
- // This 16-bit table contains a limited precision representation of the whole curve and is kept for
- // increasing xput on certain operations.
- if (nEntries == 0) {
- p ->Table16 = NULL;
- }
- else {
- p ->Table16 = (cmsUInt16Number*) _cmsCalloc(ContextID, nEntries, sizeof(cmsUInt16Number));
- if (p ->Table16 == NULL) goto Error;
- }
-
- p -> nEntries = nEntries;
-
- // Initialize members if requested
- if (Values != NULL && (nEntries > 0)) {
-
- for (i=0; i < nEntries; i++)
- p ->Table16[i] = Values[i];
- }
-
- // Initialize the segments stuff. The evaluator for each segment is located and a pointer to it
- // is placed in advance to maximize performance.
- if (Segments != NULL && (nSegments > 0)) {
-
- _cmsParametricCurvesCollection *c;
-
- p ->SegInterp = (cmsInterpParams**) _cmsCalloc(ContextID, nSegments, sizeof(cmsInterpParams*));
- if (p ->SegInterp == NULL) goto Error;
-
- for (i=0; i < nSegments; i++) {
-
- // Type 0 is a special marker for table-based curves
- if (Segments[i].Type == 0)
- p ->SegInterp[i] = _cmsComputeInterpParams(ContextID, Segments[i].nGridPoints, 1, 1, NULL, CMS_LERP_FLAGS_FLOAT);
-
- memmove(&p ->Segments[i], &Segments[i], sizeof(cmsCurveSegment));
-
- if (Segments[i].Type == 0 && Segments[i].SampledPoints != NULL)
- p ->Segments[i].SampledPoints = (cmsFloat32Number*) _cmsDupMem(ContextID, Segments[i].SampledPoints, sizeof(cmsFloat32Number) * Segments[i].nGridPoints);
- else
- p ->Segments[i].SampledPoints = NULL;
-
-
- c = GetParametricCurveByType(ContextID, Segments[i].Type, NULL);
- if (c != NULL)
- p ->Evals[i] = c ->Evaluator;
- }
- }
-
- p ->InterpParams = _cmsComputeInterpParams(ContextID, p ->nEntries, 1, 1, p->Table16, CMS_LERP_FLAGS_16BITS);
- if (p->InterpParams != NULL)
- return p;
-
-Error:
- for (i=0; i < nSegments; i++) {
- if (p ->Segments && p ->Segments[i].SampledPoints) _cmsFree(ContextID, p ->Segments[i].SampledPoints);
- if (p ->SegInterp && p ->SegInterp[i]) _cmsFree(ContextID, p ->SegInterp[i]);
- }
- if (p -> SegInterp) _cmsFree(ContextID, p -> SegInterp);
- if (p -> Segments) _cmsFree(ContextID, p -> Segments);
- if (p -> Evals) _cmsFree(ContextID, p -> Evals);
- if (p ->Table16) _cmsFree(ContextID, p ->Table16);
- _cmsFree(ContextID, p);
- return NULL;
-}
-
-
-// Generates a sigmoidal function with desired steepness.
-cmsINLINE double sigmoid_base(double k, double t)
-{
- return (1.0 / (1.0 + exp(-k * t))) - 0.5;
-}
-
-cmsINLINE double inverted_sigmoid_base(double k, double t)
-{
- return -log((1.0 / (t + 0.5)) - 1.0) / k;
-}
-
-cmsINLINE double sigmoid_factory(double k, double t)
-{
- double correction = 0.5 / sigmoid_base(k, 1);
-
- return correction * sigmoid_base(k, 2.0 * t - 1.0) + 0.5;
-}
-
-cmsINLINE double inverse_sigmoid_factory(double k, double t)
-{
- double correction = 0.5 / sigmoid_base(k, 1);
-
- return (inverted_sigmoid_base(k, (t - 0.5) / correction) + 1.0) / 2.0;
-}
-
-
-// Parametric Fn using floating point
-static
-cmsFloat64Number DefaultEvalParametricFn(cmsInt32Number Type, const cmsFloat64Number Params[], cmsFloat64Number R)
-{
- cmsFloat64Number e, Val, disc;
-
- switch (Type) {
-
- // X = Y ^ Gamma
- case 1:
- if (R < 0) {
-
- if (fabs(Params[0] - 1.0) < MATRIX_DET_TOLERANCE)
- Val = R;
- else
- Val = 0;
- }
- else
- Val = pow(R, Params[0]);
- break;
-
- // Type 1 Reversed: X = Y ^1/gamma
- case -1:
- if (R < 0) {
-
- if (fabs(Params[0] - 1.0) < MATRIX_DET_TOLERANCE)
- Val = R;
- else
- Val = 0;
- }
- else
- {
- if (fabs(Params[0]) < MATRIX_DET_TOLERANCE)
- Val = PLUS_INF;
- else
- Val = pow(R, 1 / Params[0]);
- }
- break;
-
- // CIE 122-1966
- // Y = (aX + b)^Gamma | X >= -b/a
- // Y = 0 | else
- case 2:
- {
-
- if (fabs(Params[1]) < MATRIX_DET_TOLERANCE)
- {
- Val = 0;
- }
- else
- {
- disc = -Params[2] / Params[1];
-
- if (R >= disc) {
-
- e = Params[1] * R + Params[2];
-
- if (e > 0)
- Val = pow(e, Params[0]);
- else
- Val = 0;
- }
- else
- Val = 0;
- }
- }
- break;
-
- // Type 2 Reversed
- // X = (Y ^1/g - b) / a
- case -2:
- {
- if (fabs(Params[0]) < MATRIX_DET_TOLERANCE ||
- fabs(Params[1]) < MATRIX_DET_TOLERANCE)
- {
- Val = 0;
- }
- else
- {
- if (R < 0)
- Val = 0;
- else
- Val = (pow(R, 1.0 / Params[0]) - Params[2]) / Params[1];
-
- if (Val < 0)
- Val = 0;
- }
- }
- break;
-
-
- // IEC 61966-3
- // Y = (aX + b)^Gamma + c | X <= -b/a
- // Y = c | else
- case 3:
- {
- if (fabs(Params[1]) < MATRIX_DET_TOLERANCE)
- {
- Val = 0;
- }
- else
- {
- disc = -Params[2] / Params[1];
- if (disc < 0)
- disc = 0;
-
- if (R >= disc) {
-
- e = Params[1] * R + Params[2];
-
- if (e > 0)
- Val = pow(e, Params[0]) + Params[3];
- else
- Val = 0;
- }
- else
- Val = Params[3];
- }
- }
- break;
-
-
- // Type 3 reversed
- // X=((Y-c)^1/g - b)/a | (Y>=c)
- // X=-b/a | (Y<c)
- case -3:
- {
- if (fabs(Params[0]) < MATRIX_DET_TOLERANCE ||
- fabs(Params[1]) < MATRIX_DET_TOLERANCE)
- {
- Val = 0;
- }
- else
- {
- if (R >= Params[3]) {
-
- e = R - Params[3];
-
- if (e > 0)
- Val = (pow(e, 1 / Params[0]) - Params[2]) / Params[1];
- else
- Val = 0;
- }
- else {
- Val = -Params[2] / Params[1];
- }
- }
- }
- break;
-
-
- // IEC 61966-2.1 (sRGB)
- // Y = (aX + b)^Gamma | X >= d
- // Y = cX | X < d
- case 4:
- if (R >= Params[4]) {
-
- e = Params[1]*R + Params[2];
-
- if (e > 0)
- Val = pow(e, Params[0]);
- else
- Val = 0;
- }
- else
- Val = R * Params[3];
- break;
-
- // Type 4 reversed
- // X=((Y^1/g-b)/a) | Y >= (ad+b)^g
- // X=Y/c | Y< (ad+b)^g
- case -4:
- {
-
- e = Params[1] * Params[4] + Params[2];
- if (e < 0)
- disc = 0;
- else
- disc = pow(e, Params[0]);
-
- if (R >= disc) {
-
- if (fabs(Params[0]) < MATRIX_DET_TOLERANCE ||
- fabs(Params[1]) < MATRIX_DET_TOLERANCE)
-
- Val = 0;
-
- else
- Val = (pow(R, 1.0 / Params[0]) - Params[2]) / Params[1];
- }
- else {
-
- if (fabs(Params[3]) < MATRIX_DET_TOLERANCE)
- Val = 0;
- else
- Val = R / Params[3];
- }
-
- }
- break;
-
-
- // Y = (aX + b)^Gamma + e | X >= d
- // Y = cX + f | X < d
- case 5:
- if (R >= Params[4]) {
-
- e = Params[1]*R + Params[2];
-
- if (e > 0)
- Val = pow(e, Params[0]) + Params[5];
- else
- Val = Params[5];
- }
- else
- Val = R*Params[3] + Params[6];
- break;
-
-
- // Reversed type 5
- // X=((Y-e)1/g-b)/a | Y >=(ad+b)^g+e), cd+f
- // X=(Y-f)/c | else
- case -5:
- {
- disc = Params[3] * Params[4] + Params[6];
- if (R >= disc) {
-
- e = R - Params[5];
- if (e < 0)
- Val = 0;
- else
- {
- if (fabs(Params[0]) < MATRIX_DET_TOLERANCE ||
- fabs(Params[1]) < MATRIX_DET_TOLERANCE)
-
- Val = 0;
- else
- Val = (pow(e, 1.0 / Params[0]) - Params[2]) / Params[1];
- }
- }
- else {
- if (fabs(Params[3]) < MATRIX_DET_TOLERANCE)
- Val = 0;
- else
- Val = (R - Params[6]) / Params[3];
- }
-
- }
- break;
-
-
- // Types 6,7,8 comes from segmented curves as described in ICCSpecRevision_02_11_06_Float.pdf
- // Type 6 is basically identical to type 5 without d
-
- // Y = (a * X + b) ^ Gamma + c
- case 6:
- e = Params[1]*R + Params[2];
-
- // On gamma 1.0, don't clamp
- if (Params[0] == 1.0) {
- Val = e + Params[3];
- }
- else {
- if (e < 0)
- Val = Params[3];
- else
- Val = pow(e, Params[0]) + Params[3];
- }
- break;
-
- // ((Y - c) ^1/Gamma - b) / a
- case -6:
- {
- if (fabs(Params[0]) < MATRIX_DET_TOLERANCE ||
- fabs(Params[1]) < MATRIX_DET_TOLERANCE)
- {
- Val = 0;
- }
- else
- {
- e = R - Params[3];
- if (e < 0)
- Val = 0;
- else
- Val = (pow(e, 1.0 / Params[0]) - Params[2]) / Params[1];
- }
- }
- break;
-
-
- // Y = a * log (b * X^Gamma + c) + d
- case 7:
-
- e = Params[2] * pow(R, Params[0]) + Params[3];
- if (e <= 0)
- Val = Params[4];
- else
- Val = Params[1]*log10(e) + Params[4];
- break;
-
- // (Y - d) / a = log(b * X ^Gamma + c)
- // pow(10, (Y-d) / a) = b * X ^Gamma + c
- // pow((pow(10, (Y-d) / a) - c) / b, 1/g) = X
- case -7:
- {
- if (fabs(Params[0]) < MATRIX_DET_TOLERANCE ||
- fabs(Params[1]) < MATRIX_DET_TOLERANCE ||
- fabs(Params[2]) < MATRIX_DET_TOLERANCE)
- {
- Val = 0;
- }
- else
- {
- Val = pow((pow(10.0, (R - Params[4]) / Params[1]) - Params[3]) / Params[2], 1.0 / Params[0]);
- }
- }
- break;
-
-
- //Y = a * b^(c*X+d) + e
- case 8:
- Val = (Params[0] * pow(Params[1], Params[2] * R + Params[3]) + Params[4]);
- break;
-
-
- // Y = (log((y-e) / a) / log(b) - d ) / c
- // a=0, b=1, c=2, d=3, e=4,
- case -8:
-
- disc = R - Params[4];
- if (disc < 0) Val = 0;
- else
- {
- if (fabs(Params[0]) < MATRIX_DET_TOLERANCE ||
- fabs(Params[2]) < MATRIX_DET_TOLERANCE)
- {
- Val = 0;
- }
- else
- {
- Val = (log(disc / Params[0]) / log(Params[1]) - Params[3]) / Params[2];
- }
- }
- break;
-
-
- // S-Shaped: (1 - (1-x)^1/g)^1/g
- case 108:
- if (fabs(Params[0]) < MATRIX_DET_TOLERANCE)
- Val = 0;
- else
- Val = pow(1.0 - pow(1 - R, 1/Params[0]), 1/Params[0]);
- break;
-
- // y = (1 - (1-x)^1/g)^1/g
- // y^g = (1 - (1-x)^1/g)
- // 1 - y^g = (1-x)^1/g
- // (1 - y^g)^g = 1 - x
- // 1 - (1 - y^g)^g
- case -108:
- Val = 1 - pow(1 - pow(R, Params[0]), Params[0]);
- break;
-
- // Sigmoidals
- case 109:
- Val = sigmoid_factory(Params[0], R);
- break;
-
- case -109:
- Val = inverse_sigmoid_factory(Params[0], R);
- break;
-
- default:
- // Unsupported parametric curve. Should never reach here
- return 0;
- }
-
- return Val;
-}
-
-// Evaluate a segmented function for a single value. Return -Inf if no valid segment found .
-// If fn type is 0, perform an interpolation on the table
-static
-cmsFloat64Number EvalSegmentedFn(const cmsToneCurve *g, cmsFloat64Number R)
-{
- int i;
- cmsFloat32Number Out32;
- cmsFloat64Number Out;
-
- for (i = (int) g->nSegments - 1; i >= 0; --i) {
-
- // Check for domain
- if ((R > g->Segments[i].x0) && (R <= g->Segments[i].x1)) {
-
- // Type == 0 means segment is sampled
- if (g->Segments[i].Type == 0) {
-
- cmsFloat32Number R1 = (cmsFloat32Number)(R - g->Segments[i].x0) / (g->Segments[i].x1 - g->Segments[i].x0);
-
- // Setup the table (TODO: clean that)
- g->SegInterp[i]->Table = g->Segments[i].SampledPoints;
-
- g->SegInterp[i]->Interpolation.LerpFloat(&R1, &Out32, g->SegInterp[i]);
- Out = (cmsFloat64Number) Out32;
-
- }
- else {
- Out = g->Evals[i](g->Segments[i].Type, g->Segments[i].Params, R);
- }
-
- if (isinf(Out))
- return PLUS_INF;
- else
- {
- if (isinf(-Out))
- return MINUS_INF;
- }
-
- return Out;
- }
- }
-
- return MINUS_INF;
-}
-
-// Access to estimated low-res table
-cmsUInt32Number CMSEXPORT cmsGetToneCurveEstimatedTableEntries(const cmsToneCurve* t)
-{
- _cmsAssert(t != NULL);
- return t ->nEntries;
-}
-
-const cmsUInt16Number* CMSEXPORT cmsGetToneCurveEstimatedTable(const cmsToneCurve* t)
-{
- _cmsAssert(t != NULL);
- return t ->Table16;
-}
-
-
-// Create an empty gamma curve, by using tables. This specifies only the limited-precision part, and leaves the
-// floating point description empty.
-cmsToneCurve* CMSEXPORT cmsBuildTabulatedToneCurve16(cmsContext ContextID, cmsUInt32Number nEntries, const cmsUInt16Number Values[])
-{
- return AllocateToneCurveStruct(ContextID, nEntries, 0, NULL, Values);
-}
-
-static
-cmsUInt32Number EntriesByGamma(cmsFloat64Number Gamma)
-{
- if (fabs(Gamma - 1.0) < 0.001) return 2;
- return 4096;
-}
-
-
-// Create a segmented gamma, fill the table
-cmsToneCurve* CMSEXPORT cmsBuildSegmentedToneCurve(cmsContext ContextID,
- cmsUInt32Number nSegments, const cmsCurveSegment Segments[])
-{
- cmsUInt32Number i;
- cmsFloat64Number R, Val;
- cmsToneCurve* g;
- cmsUInt32Number nGridPoints = 4096;
-
- _cmsAssert(Segments != NULL);
-
- // Optimizatin for identity curves.
- if (nSegments == 1 && Segments[0].Type == 1) {
-
- nGridPoints = EntriesByGamma(Segments[0].Params[0]);
- }
-
- g = AllocateToneCurveStruct(ContextID, nGridPoints, nSegments, Segments, NULL);
- if (g == NULL) return NULL;
-
- // Once we have the floating point version, we can approximate a 16 bit table of 4096 entries
- // for performance reasons. This table would normally not be used except on 8/16 bits transforms.
- for (i = 0; i < nGridPoints; i++) {
-
- R = (cmsFloat64Number) i / (nGridPoints-1);
-
- Val = EvalSegmentedFn(g, R);
-
- // Round and saturate
- g ->Table16[i] = _cmsQuickSaturateWord(Val * 65535.0);
- }
-
- return g;
-}
-
-// Use a segmented curve to store the floating point table
-cmsToneCurve* CMSEXPORT cmsBuildTabulatedToneCurveFloat(cmsContext ContextID, cmsUInt32Number nEntries, const cmsFloat32Number values[])
-{
- cmsCurveSegment Seg[3];
-
- // Do some housekeeping
- if (nEntries == 0 || values == NULL)
- return NULL;
-
- // A segmented tone curve should have function segments in the first and last positions
- // Initialize segmented curve part up to 0 to constant value = samples[0]
- Seg[0].x0 = MINUS_INF;
- Seg[0].x1 = 0;
- Seg[0].Type = 6;
-
- Seg[0].Params[0] = 1;
- Seg[0].Params[1] = 0;
- Seg[0].Params[2] = 0;
- Seg[0].Params[3] = values[0];
- Seg[0].Params[4] = 0;
-
- // From zero to 1
- Seg[1].x0 = 0;
- Seg[1].x1 = 1.0;
- Seg[1].Type = 0;
-
- Seg[1].nGridPoints = nEntries;
- Seg[1].SampledPoints = (cmsFloat32Number*) values;
-
- // Final segment is constant = lastsample
- Seg[2].x0 = 1.0;
- Seg[2].x1 = PLUS_INF;
- Seg[2].Type = 6;
-
- Seg[2].Params[0] = 1;
- Seg[2].Params[1] = 0;
- Seg[2].Params[2] = 0;
- Seg[2].Params[3] = values[nEntries-1];
- Seg[2].Params[4] = 0;
-
-
- return cmsBuildSegmentedToneCurve(ContextID, 3, Seg);
-}
-
-// Parametric curves
-//
-// Parameters goes as: Curve, a, b, c, d, e, f
-// Type is the ICC type +1
-// if type is negative, then the curve is analytically inverted
-cmsToneCurve* CMSEXPORT cmsBuildParametricToneCurve(cmsContext ContextID, cmsInt32Number Type, const cmsFloat64Number Params[])
-{
- cmsCurveSegment Seg0;
- int Pos = 0;
- cmsUInt32Number size;
- _cmsParametricCurvesCollection* c = GetParametricCurveByType(ContextID, Type, &Pos);
-
- _cmsAssert(Params != NULL);
-
- if (c == NULL) {
- cmsSignalError(ContextID, cmsERROR_UNKNOWN_EXTENSION, "Invalid parametric curve type %d", Type);
- return NULL;
- }
-
- memset(&Seg0, 0, sizeof(Seg0));
-
- Seg0.x0 = MINUS_INF;
- Seg0.x1 = PLUS_INF;
- Seg0.Type = Type;
-
- size = c->ParameterCount[Pos] * sizeof(cmsFloat64Number);
- memmove(Seg0.Params, Params, size);
-
- return cmsBuildSegmentedToneCurve(ContextID, 1, &Seg0);
-}
-
-
-
-// Build a gamma table based on gamma constant
-cmsToneCurve* CMSEXPORT cmsBuildGamma(cmsContext ContextID, cmsFloat64Number Gamma)
-{
- return cmsBuildParametricToneCurve(ContextID, 1, &Gamma);
-}
-
-
-// Free all memory taken by the gamma curve
-void CMSEXPORT cmsFreeToneCurve(cmsToneCurve* Curve)
-{
- cmsContext ContextID;
-
- if (Curve == NULL) return;
-
- ContextID = Curve ->InterpParams->ContextID;
-
- _cmsFreeInterpParams(Curve ->InterpParams);
-
- if (Curve -> Table16)
- _cmsFree(ContextID, Curve ->Table16);
-
- if (Curve ->Segments) {
-
- cmsUInt32Number i;
-
- for (i=0; i < Curve ->nSegments; i++) {
-
- if (Curve ->Segments[i].SampledPoints) {
- _cmsFree(ContextID, Curve ->Segments[i].SampledPoints);
- }
-
- if (Curve ->SegInterp[i] != 0)
- _cmsFreeInterpParams(Curve->SegInterp[i]);
- }
-
- _cmsFree(ContextID, Curve ->Segments);
- _cmsFree(ContextID, Curve ->SegInterp);
- }
-
- if (Curve -> Evals)
- _cmsFree(ContextID, Curve -> Evals);
-
- _cmsFree(ContextID, Curve);
-}
-
-// Utility function, free 3 gamma tables
-void CMSEXPORT cmsFreeToneCurveTriple(cmsToneCurve* Curve[3])
-{
-
- _cmsAssert(Curve != NULL);
-
- if (Curve[0] != NULL) cmsFreeToneCurve(Curve[0]);
- if (Curve[1] != NULL) cmsFreeToneCurve(Curve[1]);
- if (Curve[2] != NULL) cmsFreeToneCurve(Curve[2]);
-
- Curve[0] = Curve[1] = Curve[2] = NULL;
-}
-
-
-// Duplicate a gamma table
-cmsToneCurve* CMSEXPORT cmsDupToneCurve(const cmsToneCurve* In)
-{
- if (In == NULL) return NULL;
-
- return AllocateToneCurveStruct(In ->InterpParams ->ContextID, In ->nEntries, In ->nSegments, In ->Segments, In ->Table16);
-}
-
-// Joins two curves for X and Y. Curves should be monotonic.
-// We want to get
-//
-// y = Y^-1(X(t))
-//
-cmsToneCurve* CMSEXPORT cmsJoinToneCurve(cmsContext ContextID,
- const cmsToneCurve* X,
- const cmsToneCurve* Y, cmsUInt32Number nResultingPoints)
-{
- cmsToneCurve* out = NULL;
- cmsToneCurve* Yreversed = NULL;
- cmsFloat32Number t, x;
- cmsFloat32Number* Res = NULL;
- cmsUInt32Number i;
-
-
- _cmsAssert(X != NULL);
- _cmsAssert(Y != NULL);
-
- Yreversed = cmsReverseToneCurveEx(nResultingPoints, Y);
- if (Yreversed == NULL) goto Error;
-
- Res = (cmsFloat32Number*) _cmsCalloc(ContextID, nResultingPoints, sizeof(cmsFloat32Number));
- if (Res == NULL) goto Error;
-
- //Iterate
- for (i=0; i < nResultingPoints; i++) {
-
- t = (cmsFloat32Number) i / (cmsFloat32Number)(nResultingPoints-1);
- x = cmsEvalToneCurveFloat(X, t);
- Res[i] = cmsEvalToneCurveFloat(Yreversed, x);
- }
-
- // Allocate space for output
- out = cmsBuildTabulatedToneCurveFloat(ContextID, nResultingPoints, Res);
-
-Error:
-
- if (Res != NULL) _cmsFree(ContextID, Res);
- if (Yreversed != NULL) cmsFreeToneCurve(Yreversed);
-
- return out;
-}
-
-
-
-// Get the surrounding nodes. This is tricky on non-monotonic tables
-static
-int GetInterval(cmsFloat64Number In, const cmsUInt16Number LutTable[], const struct _cms_interp_struc* p)
-{
- int i;
- int y0, y1;
-
- // A 1 point table is not allowed
- if (p -> Domain[0] < 1) return -1;
-
- // Let's see if ascending or descending.
- if (LutTable[0] < LutTable[p ->Domain[0]]) {
-
- // Table is overall ascending
- for (i = (int) p->Domain[0] - 1; i >= 0; --i) {
-
- y0 = LutTable[i];
- y1 = LutTable[i+1];
-
- if (y0 <= y1) { // Increasing
- if (In >= y0 && In <= y1) return i;
- }
- else
- if (y1 < y0) { // Decreasing
- if (In >= y1 && In <= y0) return i;
- }
- }
- }
- else {
- // Table is overall descending
- for (i=0; i < (int) p -> Domain[0]; i++) {
-
- y0 = LutTable[i];
- y1 = LutTable[i+1];
-
- if (y0 <= y1) { // Increasing
- if (In >= y0 && In <= y1) return i;
- }
- else
- if (y1 < y0) { // Decreasing
- if (In >= y1 && In <= y0) return i;
- }
- }
- }
-
- return -1;
-}
-
-// Reverse a gamma table
-cmsToneCurve* CMSEXPORT cmsReverseToneCurveEx(cmsUInt32Number nResultSamples, const cmsToneCurve* InCurve)
-{
- cmsToneCurve *out;
- cmsFloat64Number a = 0, b = 0, y, x1, y1, x2, y2;
- int i, j;
- int Ascending;
-
- _cmsAssert(InCurve != NULL);
-
- // Try to reverse it analytically whatever possible
-
- if (InCurve ->nSegments == 1 && InCurve ->Segments[0].Type > 0 &&
- /* InCurve -> Segments[0].Type <= 5 */
- GetParametricCurveByType(InCurve ->InterpParams->ContextID, InCurve ->Segments[0].Type, NULL) != NULL) {
-
- return cmsBuildParametricToneCurve(InCurve ->InterpParams->ContextID,
- -(InCurve -> Segments[0].Type),
- InCurve -> Segments[0].Params);
- }
-
- // Nope, reverse the table.
- out = cmsBuildTabulatedToneCurve16(InCurve ->InterpParams->ContextID, nResultSamples, NULL);
- if (out == NULL)
- return NULL;
-
- // We want to know if this is an ascending or descending table
- Ascending = !cmsIsToneCurveDescending(InCurve);
-
- // Iterate across Y axis
- for (i=0; i < (int) nResultSamples; i++) {
-
- y = (cmsFloat64Number) i * 65535.0 / (nResultSamples - 1);
-
- // Find interval in which y is within.
- j = GetInterval(y, InCurve->Table16, InCurve->InterpParams);
- if (j >= 0) {
-
-
- // Get limits of interval
- x1 = InCurve ->Table16[j];
- x2 = InCurve ->Table16[j+1];
-
- y1 = (cmsFloat64Number) (j * 65535.0) / (InCurve ->nEntries - 1);
- y2 = (cmsFloat64Number) ((j+1) * 65535.0 ) / (InCurve ->nEntries - 1);
-
- // If collapsed, then use any
- if (x1 == x2) {
-
- out ->Table16[i] = _cmsQuickSaturateWord(Ascending ? y2 : y1);
- continue;
-
- } else {
-
- // Interpolate
- a = (y2 - y1) / (x2 - x1);
- b = y2 - a * x2;
- }
- }
-
- out ->Table16[i] = _cmsQuickSaturateWord(a* y + b);
- }
-
-
- return out;
-}
-
-// Reverse a gamma table
-cmsToneCurve* CMSEXPORT cmsReverseToneCurve(const cmsToneCurve* InGamma)
-{
- _cmsAssert(InGamma != NULL);
-
- return cmsReverseToneCurveEx(4096, InGamma);
-}
-
-// From: Eilers, P.H.C. (1994) Smoothing and interpolation with finite
-// differences. in: Graphic Gems IV, Heckbert, P.S. (ed.), Academic press.
-//
-// Smoothing and interpolation with second differences.
-//
-// Input: weights (w), data (y): vector from 1 to m.
-// Input: smoothing parameter (lambda), length (m).
-// Output: smoothed vector (z): vector from 1 to m.
-
-static
-cmsBool smooth2(cmsContext ContextID, cmsFloat32Number w[], cmsFloat32Number y[],
- cmsFloat32Number z[], cmsFloat32Number lambda, int m)
-{
- int i, i1, i2;
- cmsFloat32Number *c, *d, *e;
- cmsBool st;
-
-
- c = (cmsFloat32Number*) _cmsCalloc(ContextID, MAX_NODES_IN_CURVE, sizeof(cmsFloat32Number));
- d = (cmsFloat32Number*) _cmsCalloc(ContextID, MAX_NODES_IN_CURVE, sizeof(cmsFloat32Number));
- e = (cmsFloat32Number*) _cmsCalloc(ContextID, MAX_NODES_IN_CURVE, sizeof(cmsFloat32Number));
-
- if (c != NULL && d != NULL && e != NULL) {
-
-
- d[1] = w[1] + lambda;
- c[1] = -2 * lambda / d[1];
- e[1] = lambda /d[1];
- z[1] = w[1] * y[1];
- d[2] = w[2] + 5 * lambda - d[1] * c[1] * c[1];
- c[2] = (-4 * lambda - d[1] * c[1] * e[1]) / d[2];
- e[2] = lambda / d[2];
- z[2] = w[2] * y[2] - c[1] * z[1];
-
- for (i = 3; i < m - 1; i++) {
- i1 = i - 1; i2 = i - 2;
- d[i]= w[i] + 6 * lambda - c[i1] * c[i1] * d[i1] - e[i2] * e[i2] * d[i2];
- c[i] = (-4 * lambda -d[i1] * c[i1] * e[i1])/ d[i];
- e[i] = lambda / d[i];
- z[i] = w[i] * y[i] - c[i1] * z[i1] - e[i2] * z[i2];
- }
-
- i1 = m - 2; i2 = m - 3;
-
- d[m - 1] = w[m - 1] + 5 * lambda -c[i1] * c[i1] * d[i1] - e[i2] * e[i2] * d[i2];
- c[m - 1] = (-2 * lambda - d[i1] * c[i1] * e[i1]) / d[m - 1];
- z[m - 1] = w[m - 1] * y[m - 1] - c[i1] * z[i1] - e[i2] * z[i2];
- i1 = m - 1; i2 = m - 2;
-
- d[m] = w[m] + lambda - c[i1] * c[i1] * d[i1] - e[i2] * e[i2] * d[i2];
- z[m] = (w[m] * y[m] - c[i1] * z[i1] - e[i2] * z[i2]) / d[m];
- z[m - 1] = z[m - 1] / d[m - 1] - c[m - 1] * z[m];
-
- for (i = m - 2; 1<= i; i--)
- z[i] = z[i] / d[i] - c[i] * z[i + 1] - e[i] * z[i + 2];
-
- st = TRUE;
- }
- else st = FALSE;
-
- if (c != NULL) _cmsFree(ContextID, c);
- if (d != NULL) _cmsFree(ContextID, d);
- if (e != NULL) _cmsFree(ContextID, e);
-
- return st;
-}
-
-// Smooths a curve sampled at regular intervals.
-cmsBool CMSEXPORT cmsSmoothToneCurve(cmsToneCurve* Tab, cmsFloat64Number lambda)
-{
- cmsBool SuccessStatus = TRUE;
- cmsFloat32Number *w, *y, *z;
- cmsUInt32Number i, nItems, Zeros, Poles;
- cmsBool notCheck = FALSE;
-
- if (Tab != NULL && Tab->InterpParams != NULL)
- {
- cmsContext ContextID = Tab->InterpParams->ContextID;
-
- if (!cmsIsToneCurveLinear(Tab)) // Only non-linear curves need smoothing
- {
- nItems = Tab->nEntries;
- if (nItems < MAX_NODES_IN_CURVE)
- {
- // Allocate one more item than needed
- w = (cmsFloat32Number *)_cmsCalloc(ContextID, nItems + 1, sizeof(cmsFloat32Number));
- y = (cmsFloat32Number *)_cmsCalloc(ContextID, nItems + 1, sizeof(cmsFloat32Number));
- z = (cmsFloat32Number *)_cmsCalloc(ContextID, nItems + 1, sizeof(cmsFloat32Number));
-
- if (w != NULL && y != NULL && z != NULL) // Ensure no memory allocation failure
- {
- memset(w, 0, (nItems + 1) * sizeof(cmsFloat32Number));
- memset(y, 0, (nItems + 1) * sizeof(cmsFloat32Number));
- memset(z, 0, (nItems + 1) * sizeof(cmsFloat32Number));
-
- for (i = 0; i < nItems; i++)
- {
- y[i + 1] = (cmsFloat32Number)Tab->Table16[i];
- w[i + 1] = 1.0;
- }
-
- if (lambda < 0)
- {
- notCheck = TRUE;
- lambda = -lambda;
- }
-
- if (smooth2(ContextID, w, y, z, (cmsFloat32Number)lambda, (int)nItems))
- {
- // Do some reality - checking...
-
- Zeros = Poles = 0;
- for (i = nItems; i > 1; --i)
- {
- if (z[i] == 0.) Zeros++;
- if (z[i] >= 65535.) Poles++;
- if (z[i] < z[i - 1])
- {
- cmsSignalError(ContextID, cmsERROR_RANGE, "cmsSmoothToneCurve: Non-Monotonic.");
- SuccessStatus = notCheck;
- break;
- }
- }
-
- if (SuccessStatus && Zeros > (nItems / 3))
- {
- cmsSignalError(ContextID, cmsERROR_RANGE, "cmsSmoothToneCurve: Degenerated, mostly zeros.");
- SuccessStatus = notCheck;
- }
-
- if (SuccessStatus && Poles > (nItems / 3))
- {
- cmsSignalError(ContextID, cmsERROR_RANGE, "cmsSmoothToneCurve: Degenerated, mostly poles.");
- SuccessStatus = notCheck;
- }
-
- if (SuccessStatus) // Seems ok
- {
- for (i = 0; i < nItems; i++)
- {
- // Clamp to cmsUInt16Number
- Tab->Table16[i] = _cmsQuickSaturateWord(z[i + 1]);
- }
- }
- }
- else // Could not smooth
- {
- cmsSignalError(ContextID, cmsERROR_RANGE, "cmsSmoothToneCurve: Function smooth2 failed.");
- SuccessStatus = FALSE;
- }
- }
- else // One or more buffers could not be allocated
- {
- cmsSignalError(ContextID, cmsERROR_RANGE, "cmsSmoothToneCurve: Could not allocate memory.");
- SuccessStatus = FALSE;
- }
-
- if (z != NULL)
- _cmsFree(ContextID, z);
-
- if (y != NULL)
- _cmsFree(ContextID, y);
-
- if (w != NULL)
- _cmsFree(ContextID, w);
- }
- else // too many items in the table
- {
- cmsSignalError(ContextID, cmsERROR_RANGE, "cmsSmoothToneCurve: Too many points.");
- SuccessStatus = FALSE;
- }
- }
- }
- else // Tab parameter or Tab->InterpParams is NULL
- {
- // Can't signal an error here since the ContextID is not known at this point
- SuccessStatus = FALSE;
- }
-
- return SuccessStatus;
-}
-
-// Is a table linear? Do not use parametric since we cannot guarantee some weird parameters resulting
-// in a linear table. This way assures it is linear in 12 bits, which should be enough in most cases.
-cmsBool CMSEXPORT cmsIsToneCurveLinear(const cmsToneCurve* Curve)
-{
- int i;
- int diff;
-
- _cmsAssert(Curve != NULL);
-
- for (i=0; i < (int) Curve ->nEntries; i++) {
-
- diff = abs((int) Curve->Table16[i] - (int) _cmsQuantizeVal(i, Curve ->nEntries));
- if (diff > 0x0f)
- return FALSE;
- }
-
- return TRUE;
-}
-
-// Same, but for monotonicity
-cmsBool CMSEXPORT cmsIsToneCurveMonotonic(const cmsToneCurve* t)
-{
- cmsUInt32Number n;
- int i, last;
- cmsBool lDescending;
-
- _cmsAssert(t != NULL);
-
- // Degenerated curves are monotonic? Ok, let's pass them
- n = t ->nEntries;
- if (n < 2) return TRUE;
-
- // Curve direction
- lDescending = cmsIsToneCurveDescending(t);
-
- if (lDescending) {
-
- last = t ->Table16[0];
-
- for (i = 1; i < (int) n; i++) {
-
- if (t ->Table16[i] - last > 2) // We allow some ripple
- return FALSE;
- else
- last = t ->Table16[i];
-
- }
- }
- else {
-
- last = t ->Table16[n-1];
-
- for (i = (int) n - 2; i >= 0; --i) {
-
- if (t ->Table16[i] - last > 2)
- return FALSE;
- else
- last = t ->Table16[i];
-
- }
- }
-
- return TRUE;
-}
-
-// Same, but for descending tables
-cmsBool CMSEXPORT cmsIsToneCurveDescending(const cmsToneCurve* t)
-{
- _cmsAssert(t != NULL);
-
- return t ->Table16[0] > t ->Table16[t ->nEntries-1];
-}
-
-
-// Another info fn: is out gamma table multisegment?
-cmsBool CMSEXPORT cmsIsToneCurveMultisegment(const cmsToneCurve* t)
-{
- _cmsAssert(t != NULL);
-
- return t -> nSegments > 1;
-}
-
-cmsInt32Number CMSEXPORT cmsGetToneCurveParametricType(const cmsToneCurve* t)
-{
- _cmsAssert(t != NULL);
-
- if (t -> nSegments != 1) return 0;
- return t ->Segments[0].Type;
-}
-
-// We need accuracy this time
-cmsFloat32Number CMSEXPORT cmsEvalToneCurveFloat(const cmsToneCurve* Curve, cmsFloat32Number v)
-{
- _cmsAssert(Curve != NULL);
-
- // Check for 16 bits table. If so, this is a limited-precision tone curve
- if (Curve ->nSegments == 0) {
-
- cmsUInt16Number In, Out;
-
- In = (cmsUInt16Number) _cmsQuickSaturateWord(v * 65535.0);
- Out = cmsEvalToneCurve16(Curve, In);
-
- return (cmsFloat32Number) (Out / 65535.0);
- }
-
- return (cmsFloat32Number) EvalSegmentedFn(Curve, v);
-}
-
-// We need xput over here
-cmsUInt16Number CMSEXPORT cmsEvalToneCurve16(const cmsToneCurve* Curve, cmsUInt16Number v)
-{
- cmsUInt16Number out;
-
- _cmsAssert(Curve != NULL);
-
- Curve ->InterpParams ->Interpolation.Lerp16(&v, &out, Curve ->InterpParams);
- return out;
-}
-
-
-// Least squares fitting.
-// A mathematical procedure for finding the best-fitting curve to a given set of points by
-// minimizing the sum of the squares of the offsets ("the residuals") of the points from the curve.
-// The sum of the squares of the offsets is used instead of the offset absolute values because
-// this allows the residuals to be treated as a continuous differentiable quantity.
-//
-// y = f(x) = x ^ g
-//
-// R = (yi - (xi^g))
-// R2 = (yi - (xi^g))2
-// SUM R2 = SUM (yi - (xi^g))2
-//
-// dR2/dg = -2 SUM x^g log(x)(y - x^g)
-// solving for dR2/dg = 0
-//
-// g = 1/n * SUM(log(y) / log(x))
-
-cmsFloat64Number CMSEXPORT cmsEstimateGamma(const cmsToneCurve* t, cmsFloat64Number Precision)
-{
- cmsFloat64Number gamma, sum, sum2;
- cmsFloat64Number n, x, y, Std;
- cmsUInt32Number i;
-
- _cmsAssert(t != NULL);
-
- sum = sum2 = n = 0;
-
- // Excluding endpoints
- for (i=1; i < (MAX_NODES_IN_CURVE-1); i++) {
-
- x = (cmsFloat64Number) i / (MAX_NODES_IN_CURVE-1);
- y = (cmsFloat64Number) cmsEvalToneCurveFloat(t, (cmsFloat32Number) x);
-
- // Avoid 7% on lower part to prevent
- // artifacts due to linear ramps
-
- if (y > 0. && y < 1. && x > 0.07) {
-
- gamma = log(y) / log(x);
- sum += gamma;
- sum2 += gamma * gamma;
- n++;
- }
- }
-
- // We need enough valid samples
- if (n <= 1) return -1.0;
-
- // Take a look on SD to see if gamma isn't exponential at all
- Std = sqrt((n * sum2 - sum * sum) / (n*(n-1)));
-
- if (Std > Precision)
- return -1.0;
-
- return (sum / n); // The mean
-}
-
-// Retrieve segments on tone curves
-
-const cmsCurveSegment* CMSEXPORT cmsGetToneCurveSegment(cmsInt32Number n, const cmsToneCurve* t)
-{
- _cmsAssert(t != NULL);
-
- if (n < 0 || n >= (cmsInt32Number) t->nSegments) return NULL;
- return t->Segments + n;
-}
-
diff --git a/contrib/libs/lcms2/src/cmsgmt.c b/contrib/libs/lcms2/src/cmsgmt.c
deleted file mode 100644
index 64573476c8..0000000000
--- a/contrib/libs/lcms2/src/cmsgmt.c
+++ /dev/null
@@ -1,659 +0,0 @@
-//---------------------------------------------------------------------------------
-//
-// Little Color Management System
-// Copyright (c) 1998-2021 Marti Maria Saguer
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//---------------------------------------------------------------------------------
-//
-
-#include "lcms2_internal.h"
-
-
-// Auxiliary: append a Lab identity after the given sequence of profiles
-// and return the transform. Lab profile is closed, rest of profiles are kept open.
-cmsHTRANSFORM _cmsChain2Lab(cmsContext ContextID,
- cmsUInt32Number nProfiles,
- cmsUInt32Number InputFormat,
- cmsUInt32Number OutputFormat,
- const cmsUInt32Number Intents[],
- const cmsHPROFILE hProfiles[],
- const cmsBool BPC[],
- const cmsFloat64Number AdaptationStates[],
- cmsUInt32Number dwFlags)
-{
- cmsHTRANSFORM xform;
- cmsHPROFILE hLab;
- cmsHPROFILE ProfileList[256];
- cmsBool BPCList[256];
- cmsFloat64Number AdaptationList[256];
- cmsUInt32Number IntentList[256];
- cmsUInt32Number i;
-
- // This is a rather big number and there is no need of dynamic memory
- // since we are adding a profile, 254 + 1 = 255 and this is the limit
- if (nProfiles > 254) return NULL;
-
- // The output space
- hLab = cmsCreateLab4ProfileTHR(ContextID, NULL);
- if (hLab == NULL) return NULL;
-
- // Create a copy of parameters
- for (i=0; i < nProfiles; i++) {
-
- ProfileList[i] = hProfiles[i];
- BPCList[i] = BPC[i];
- AdaptationList[i] = AdaptationStates[i];
- IntentList[i] = Intents[i];
- }
-
- // Place Lab identity at chain's end.
- ProfileList[nProfiles] = hLab;
- BPCList[nProfiles] = 0;
- AdaptationList[nProfiles] = 1.0;
- IntentList[nProfiles] = INTENT_RELATIVE_COLORIMETRIC;
-
- // Create the transform
- xform = cmsCreateExtendedTransform(ContextID, nProfiles + 1, ProfileList,
- BPCList,
- IntentList,
- AdaptationList,
- NULL, 0,
- InputFormat,
- OutputFormat,
- dwFlags);
-
- cmsCloseProfile(hLab);
-
- return xform;
-}
-
-
-// Compute K -> L* relationship. Flags may include black point compensation. In this case,
-// the relationship is assumed from the profile with BPC to a black point zero.
-static
-cmsToneCurve* ComputeKToLstar(cmsContext ContextID,
- cmsUInt32Number nPoints,
- cmsUInt32Number nProfiles,
- const cmsUInt32Number Intents[],
- const cmsHPROFILE hProfiles[],
- const cmsBool BPC[],
- const cmsFloat64Number AdaptationStates[],
- cmsUInt32Number dwFlags)
-{
- cmsToneCurve* out = NULL;
- cmsUInt32Number i;
- cmsHTRANSFORM xform;
- cmsCIELab Lab;
- cmsFloat32Number cmyk[4];
- cmsFloat32Number* SampledPoints;
-
- xform = _cmsChain2Lab(ContextID, nProfiles, TYPE_CMYK_FLT, TYPE_Lab_DBL, Intents, hProfiles, BPC, AdaptationStates, dwFlags);
- if (xform == NULL) return NULL;
-
- SampledPoints = (cmsFloat32Number*) _cmsCalloc(ContextID, nPoints, sizeof(cmsFloat32Number));
- if (SampledPoints == NULL) goto Error;
-
- for (i=0; i < nPoints; i++) {
-
- cmyk[0] = 0;
- cmyk[1] = 0;
- cmyk[2] = 0;
- cmyk[3] = (cmsFloat32Number) ((i * 100.0) / (nPoints-1));
-
- cmsDoTransform(xform, cmyk, &Lab, 1);
- SampledPoints[i]= (cmsFloat32Number) (1.0 - Lab.L / 100.0); // Negate K for easier operation
- }
-
- out = cmsBuildTabulatedToneCurveFloat(ContextID, nPoints, SampledPoints);
-
-Error:
-
- cmsDeleteTransform(xform);
- if (SampledPoints) _cmsFree(ContextID, SampledPoints);
-
- return out;
-}
-
-
-// Compute Black tone curve on a CMYK -> CMYK transform. This is done by
-// using the proof direction on both profiles to find K->L* relationship
-// then joining both curves. dwFlags may include black point compensation.
-cmsToneCurve* _cmsBuildKToneCurve(cmsContext ContextID,
- cmsUInt32Number nPoints,
- cmsUInt32Number nProfiles,
- const cmsUInt32Number Intents[],
- const cmsHPROFILE hProfiles[],
- const cmsBool BPC[],
- const cmsFloat64Number AdaptationStates[],
- cmsUInt32Number dwFlags)
-{
- cmsToneCurve *in, *out, *KTone;
-
- // Make sure CMYK -> CMYK
- if (cmsGetColorSpace(hProfiles[0]) != cmsSigCmykData ||
- cmsGetColorSpace(hProfiles[nProfiles-1])!= cmsSigCmykData) return NULL;
-
-
- // Make sure last is an output profile
- if (cmsGetDeviceClass(hProfiles[nProfiles - 1]) != cmsSigOutputClass) return NULL;
-
- // Create individual curves. BPC works also as each K to L* is
- // computed as a BPC to zero black point in case of L*
- in = ComputeKToLstar(ContextID, nPoints, nProfiles - 1, Intents, hProfiles, BPC, AdaptationStates, dwFlags);
- if (in == NULL) return NULL;
-
- out = ComputeKToLstar(ContextID, nPoints, 1,
- Intents + (nProfiles - 1),
- &hProfiles [nProfiles - 1],
- BPC + (nProfiles - 1),
- AdaptationStates + (nProfiles - 1),
- dwFlags);
- if (out == NULL) {
- cmsFreeToneCurve(in);
- return NULL;
- }
-
- // Build the relationship. This effectively limits the maximum accuracy to 16 bits, but
- // since this is used on black-preserving LUTs, we are not losing accuracy in any case
- KTone = cmsJoinToneCurve(ContextID, in, out, nPoints);
-
- // Get rid of components
- cmsFreeToneCurve(in); cmsFreeToneCurve(out);
-
- // Something went wrong...
- if (KTone == NULL) return NULL;
-
- // Make sure it is monotonic
- if (!cmsIsToneCurveMonotonic(KTone)) {
- cmsFreeToneCurve(KTone);
- return NULL;
- }
-
- return KTone;
-}
-
-
-// Gamut LUT Creation -----------------------------------------------------------------------------------------
-
-// Used by gamut & softproofing
-
-typedef struct {
-
- cmsHTRANSFORM hInput; // From whatever input color space. 16 bits to DBL
- cmsHTRANSFORM hForward, hReverse; // Transforms going from Lab to colorant and back
- cmsFloat64Number Threshold; // The threshold after which is considered out of gamut
-
- } GAMUTCHAIN;
-
-// This sampler does compute gamut boundaries by comparing original
-// values with a transform going back and forth. Values above ERR_THRESHOLD
-// of maximum are considered out of gamut.
-
-#define ERR_THRESHOLD 5
-
-
-static
-int GamutSampler(CMSREGISTER const cmsUInt16Number In[], CMSREGISTER cmsUInt16Number Out[], CMSREGISTER void* Cargo)
-{
- GAMUTCHAIN* t = (GAMUTCHAIN* ) Cargo;
- cmsCIELab LabIn1, LabOut1;
- cmsCIELab LabIn2, LabOut2;
- cmsUInt16Number Proof[cmsMAXCHANNELS], Proof2[cmsMAXCHANNELS];
- cmsFloat64Number dE1, dE2, ErrorRatio;
-
- // Assume in-gamut by default. NEVER READ, USED FOR DEBUG PURPOSES.
- ErrorRatio = 1.0;
-
- // Convert input to Lab
- cmsDoTransform(t -> hInput, In, &LabIn1, 1);
-
- // converts from PCS to colorant. This always
- // does return in-gamut values,
- cmsDoTransform(t -> hForward, &LabIn1, Proof, 1);
-
- // Now, do the inverse, from colorant to PCS.
- cmsDoTransform(t -> hReverse, Proof, &LabOut1, 1);
-
- memmove(&LabIn2, &LabOut1, sizeof(cmsCIELab));
-
- // Try again, but this time taking Check as input
- cmsDoTransform(t -> hForward, &LabOut1, Proof2, 1);
- cmsDoTransform(t -> hReverse, Proof2, &LabOut2, 1);
-
- // Take difference of direct value
- dE1 = cmsDeltaE(&LabIn1, &LabOut1);
-
- // Take difference of converted value
- dE2 = cmsDeltaE(&LabIn2, &LabOut2);
-
-
- // if dE1 is small and dE2 is small, value is likely to be in gamut
- if (dE1 < t->Threshold && dE2 < t->Threshold)
- Out[0] = 0;
- else {
-
- // if dE1 is small and dE2 is big, undefined. Assume in gamut
- if (dE1 < t->Threshold && dE2 > t->Threshold)
- Out[0] = 0;
- else
- // dE1 is big and dE2 is small, clearly out of gamut
- if (dE1 > t->Threshold && dE2 < t->Threshold)
- Out[0] = (cmsUInt16Number) _cmsQuickFloor((dE1 - t->Threshold) + .5);
- else {
-
- // dE1 is big and dE2 is also big, could be due to perceptual mapping
- // so take error ratio
- if (dE2 == 0.0)
- ErrorRatio = dE1;
- else
- ErrorRatio = dE1 / dE2;
-
- if (ErrorRatio > t->Threshold)
- Out[0] = (cmsUInt16Number) _cmsQuickFloor((ErrorRatio - t->Threshold) + .5);
- else
- Out[0] = 0;
- }
- }
-
-
- return TRUE;
-}
-
-// Does compute a gamut LUT going back and forth across pcs -> relativ. colorimetric intent -> pcs
-// the dE obtained is then annotated on the LUT. Values truly out of gamut are clipped to dE = 0xFFFE
-// and values changed are supposed to be handled by any gamut remapping, so, are out of gamut as well.
-//
-// **WARNING: This algorithm does assume that gamut remapping algorithms does NOT move in-gamut colors,
-// of course, many perceptual and saturation intents does not work in such way, but relativ. ones should.
-
-cmsPipeline* _cmsCreateGamutCheckPipeline(cmsContext ContextID,
- cmsHPROFILE hProfiles[],
- cmsBool BPC[],
- cmsUInt32Number Intents[],
- cmsFloat64Number AdaptationStates[],
- cmsUInt32Number nGamutPCSposition,
- cmsHPROFILE hGamut)
-{
- cmsHPROFILE hLab;
- cmsPipeline* Gamut;
- cmsStage* CLUT;
- cmsUInt32Number dwFormat;
- GAMUTCHAIN Chain;
- cmsUInt32Number nGridpoints;
- cmsInt32Number nChannels;
- cmsColorSpaceSignature ColorSpace;
- cmsUInt32Number i;
- cmsHPROFILE ProfileList[256];
- cmsBool BPCList[256];
- cmsFloat64Number AdaptationList[256];
- cmsUInt32Number IntentList[256];
-
- memset(&Chain, 0, sizeof(GAMUTCHAIN));
-
-
- if (nGamutPCSposition <= 0 || nGamutPCSposition > 255) {
- cmsSignalError(ContextID, cmsERROR_RANGE, "Wrong position of PCS. 1..255 expected, %d found.", nGamutPCSposition);
- return NULL;
- }
-
- hLab = cmsCreateLab4ProfileTHR(ContextID, NULL);
- if (hLab == NULL) return NULL;
-
-
- // The figure of merit. On matrix-shaper profiles, should be almost zero as
- // the conversion is pretty exact. On LUT based profiles, different resolutions
- // of input and output CLUT may result in differences.
-
- if (cmsIsMatrixShaper(hGamut)) {
-
- Chain.Threshold = 1.0;
- }
- else {
- Chain.Threshold = ERR_THRESHOLD;
- }
-
-
- // Create a copy of parameters
- for (i=0; i < nGamutPCSposition; i++) {
- ProfileList[i] = hProfiles[i];
- BPCList[i] = BPC[i];
- AdaptationList[i] = AdaptationStates[i];
- IntentList[i] = Intents[i];
- }
-
- // Fill Lab identity
- ProfileList[nGamutPCSposition] = hLab;
- BPCList[nGamutPCSposition] = 0;
- AdaptationList[nGamutPCSposition] = 1.0;
- IntentList[nGamutPCSposition] = INTENT_RELATIVE_COLORIMETRIC;
-
-
- ColorSpace = cmsGetColorSpace(hGamut);
- nChannels = cmsChannelsOfColorSpace(ColorSpace);
- nGridpoints = _cmsReasonableGridpointsByColorspace(ColorSpace, cmsFLAGS_HIGHRESPRECALC);
- dwFormat = (CHANNELS_SH(nChannels)|BYTES_SH(2));
-
- // 16 bits to Lab double
- Chain.hInput = cmsCreateExtendedTransform(ContextID,
- nGamutPCSposition + 1,
- ProfileList,
- BPCList,
- IntentList,
- AdaptationList,
- NULL, 0,
- dwFormat, TYPE_Lab_DBL,
- cmsFLAGS_NOCACHE);
-
-
- // Does create the forward step. Lab double to device
- dwFormat = (CHANNELS_SH(nChannels)|BYTES_SH(2));
- Chain.hForward = cmsCreateTransformTHR(ContextID,
- hLab, TYPE_Lab_DBL,
- hGamut, dwFormat,
- INTENT_RELATIVE_COLORIMETRIC,
- cmsFLAGS_NOCACHE);
-
- // Does create the backwards step
- Chain.hReverse = cmsCreateTransformTHR(ContextID, hGamut, dwFormat,
- hLab, TYPE_Lab_DBL,
- INTENT_RELATIVE_COLORIMETRIC,
- cmsFLAGS_NOCACHE);
-
-
- // All ok?
- if (Chain.hInput && Chain.hForward && Chain.hReverse) {
-
- // Go on, try to compute gamut LUT from PCS. This consist on a single channel containing
- // dE when doing a transform back and forth on the colorimetric intent.
-
- Gamut = cmsPipelineAlloc(ContextID, 3, 1);
- if (Gamut != NULL) {
-
- CLUT = cmsStageAllocCLut16bit(ContextID, nGridpoints, nChannels, 1, NULL);
- if (!cmsPipelineInsertStage(Gamut, cmsAT_BEGIN, CLUT)) {
- cmsPipelineFree(Gamut);
- Gamut = NULL;
- }
- else {
- cmsStageSampleCLut16bit(CLUT, GamutSampler, (void*) &Chain, 0);
- }
- }
- }
- else
- Gamut = NULL; // Didn't work...
-
- // Free all needed stuff.
- if (Chain.hInput) cmsDeleteTransform(Chain.hInput);
- if (Chain.hForward) cmsDeleteTransform(Chain.hForward);
- if (Chain.hReverse) cmsDeleteTransform(Chain.hReverse);
- if (hLab) cmsCloseProfile(hLab);
-
- // And return computed hull
- return Gamut;
-}
-
-// Total Area Coverage estimation ----------------------------------------------------------------
-
-typedef struct {
- cmsUInt32Number nOutputChans;
- cmsHTRANSFORM hRoundTrip;
- cmsFloat32Number MaxTAC;
- cmsFloat32Number MaxInput[cmsMAXCHANNELS];
-
-} cmsTACestimator;
-
-
-// This callback just accounts the maximum ink dropped in the given node. It does not populate any
-// memory, as the destination table is NULL. Its only purpose it to know the global maximum.
-static
-int EstimateTAC(CMSREGISTER const cmsUInt16Number In[], CMSREGISTER cmsUInt16Number Out[], CMSREGISTER void * Cargo)
-{
- cmsTACestimator* bp = (cmsTACestimator*) Cargo;
- cmsFloat32Number RoundTrip[cmsMAXCHANNELS];
- cmsUInt32Number i;
- cmsFloat32Number Sum;
-
-
- // Evaluate the xform
- cmsDoTransform(bp->hRoundTrip, In, RoundTrip, 1);
-
- // All all amounts of ink
- for (Sum=0, i=0; i < bp ->nOutputChans; i++)
- Sum += RoundTrip[i];
-
- // If above maximum, keep track of input values
- if (Sum > bp ->MaxTAC) {
-
- bp ->MaxTAC = Sum;
-
- for (i=0; i < bp ->nOutputChans; i++) {
- bp ->MaxInput[i] = In[i];
- }
- }
-
- return TRUE;
-
- cmsUNUSED_PARAMETER(Out);
-}
-
-
-// Detect Total area coverage of the profile
-cmsFloat64Number CMSEXPORT cmsDetectTAC(cmsHPROFILE hProfile)
-{
- cmsTACestimator bp;
- cmsUInt32Number dwFormatter;
- cmsUInt32Number GridPoints[MAX_INPUT_DIMENSIONS];
- cmsHPROFILE hLab;
- cmsContext ContextID = cmsGetProfileContextID(hProfile);
-
- // TAC only works on output profiles
- if (cmsGetDeviceClass(hProfile) != cmsSigOutputClass) {
- return 0;
- }
-
- // Create a fake formatter for result
- dwFormatter = cmsFormatterForColorspaceOfProfile(hProfile, 4, TRUE);
-
- // Unsupported color space?
- if (dwFormatter == 0) return 0;
-
- bp.nOutputChans = T_CHANNELS(dwFormatter);
- bp.MaxTAC = 0; // Initial TAC is 0
-
- // for safety
- if (bp.nOutputChans >= cmsMAXCHANNELS) return 0;
-
- hLab = cmsCreateLab4ProfileTHR(ContextID, NULL);
- if (hLab == NULL) return 0;
- // Setup a roundtrip on perceptual intent in output profile for TAC estimation
- bp.hRoundTrip = cmsCreateTransformTHR(ContextID, hLab, TYPE_Lab_16,
- hProfile, dwFormatter, INTENT_PERCEPTUAL, cmsFLAGS_NOOPTIMIZE|cmsFLAGS_NOCACHE);
-
- cmsCloseProfile(hLab);
- if (bp.hRoundTrip == NULL) return 0;
-
- // For L* we only need black and white. For C* we need many points
- GridPoints[0] = 6;
- GridPoints[1] = 74;
- GridPoints[2] = 74;
-
-
- if (!cmsSliceSpace16(3, GridPoints, EstimateTAC, &bp)) {
- bp.MaxTAC = 0;
- }
-
- cmsDeleteTransform(bp.hRoundTrip);
-
- // Results in %
- return bp.MaxTAC;
-}
-
-
-// Carefully, clamp on CIELab space.
-
-cmsBool CMSEXPORT cmsDesaturateLab(cmsCIELab* Lab,
- double amax, double amin,
- double bmax, double bmin)
-{
-
- // Whole Luma surface to zero
-
- if (Lab -> L < 0) {
-
- Lab-> L = Lab->a = Lab-> b = 0.0;
- return FALSE;
- }
-
- // Clamp white, DISCARD HIGHLIGHTS. This is done
- // in such way because icc spec doesn't allow the
- // use of L>100 as a highlight means.
-
- if (Lab->L > 100)
- Lab -> L = 100;
-
- // Check out gamut prism, on a, b faces
-
- if (Lab -> a < amin || Lab->a > amax||
- Lab -> b < bmin || Lab->b > bmax) {
-
- cmsCIELCh LCh;
- double h, slope;
-
- // Falls outside a, b limits. Transports to LCh space,
- // and then do the clipping
-
-
- if (Lab -> a == 0.0) { // Is hue exactly 90?
-
- // atan will not work, so clamp here
- Lab -> b = Lab->b < 0 ? bmin : bmax;
- return TRUE;
- }
-
- cmsLab2LCh(&LCh, Lab);
-
- slope = Lab -> b / Lab -> a;
- h = LCh.h;
-
- // There are 4 zones
-
- if ((h >= 0. && h < 45.) ||
- (h >= 315 && h <= 360.)) {
-
- // clip by amax
- Lab -> a = amax;
- Lab -> b = amax * slope;
- }
- else
- if (h >= 45. && h < 135.)
- {
- // clip by bmax
- Lab -> b = bmax;
- Lab -> a = bmax / slope;
- }
- else
- if (h >= 135. && h < 225.) {
- // clip by amin
- Lab -> a = amin;
- Lab -> b = amin * slope;
-
- }
- else
- if (h >= 225. && h < 315.) {
- // clip by bmin
- Lab -> b = bmin;
- Lab -> a = bmin / slope;
- }
- else {
- cmsSignalError(0, cmsERROR_RANGE, "Invalid angle");
- return FALSE;
- }
-
- }
-
- return TRUE;
-}
-
-// Detect whatever a given ICC profile works in linear (gamma 1.0) space
-// Actually, doing that "well" is quite hard, since every component may behave completely different.
-// Since the true point of this function is to detect suitable optimizations, I am imposing some requirements
-// that simplifies things: only RGB, and only profiles that can got in both directions.
-// The algorithm obtains Y from a synthetical gray R=G=B. Then least squares fitting is used to estimate gamma.
-// For gamma close to 1.0, RGB is linear. On profiles not supported, -1 is returned.
-
-cmsFloat64Number CMSEXPORT cmsDetectRGBProfileGamma(cmsHPROFILE hProfile, cmsFloat64Number threshold)
-{
- cmsContext ContextID;
- cmsHPROFILE hXYZ;
- cmsHTRANSFORM xform;
- cmsToneCurve* Y_curve;
- cmsUInt16Number rgb[256][3];
- cmsCIEXYZ XYZ[256];
- cmsFloat32Number Y_normalized[256];
- cmsFloat64Number gamma;
- cmsProfileClassSignature cl;
- int i;
-
- if (cmsGetColorSpace(hProfile) != cmsSigRgbData)
- return -1;
-
- cl = cmsGetDeviceClass(hProfile);
- if (cl != cmsSigInputClass && cl != cmsSigDisplayClass &&
- cl != cmsSigOutputClass && cl != cmsSigColorSpaceClass)
- return -1;
-
- ContextID = cmsGetProfileContextID(hProfile);
- hXYZ = cmsCreateXYZProfileTHR(ContextID);
- if (hXYZ == NULL)
- return -1;
- xform = cmsCreateTransformTHR(ContextID, hProfile, TYPE_RGB_16, hXYZ, TYPE_XYZ_DBL,
- INTENT_RELATIVE_COLORIMETRIC, cmsFLAGS_NOOPTIMIZE);
-
- if (xform == NULL) { // If not RGB or forward direction is not supported, regret with the previous error
-
- cmsCloseProfile(hXYZ);
- return -1;
- }
-
- for (i = 0; i < 256; i++) {
- rgb[i][0] = rgb[i][1] = rgb[i][2] = FROM_8_TO_16(i);
- }
-
- cmsDoTransform(xform, rgb, XYZ, 256);
-
- cmsDeleteTransform(xform);
- cmsCloseProfile(hXYZ);
-
- for (i = 0; i < 256; i++) {
- Y_normalized[i] = (cmsFloat32Number) XYZ[i].Y;
- }
-
- Y_curve = cmsBuildTabulatedToneCurveFloat(ContextID, 256, Y_normalized);
- if (Y_curve == NULL)
- return -1;
-
- gamma = cmsEstimateGamma(Y_curve, threshold);
-
- cmsFreeToneCurve(Y_curve);
-
- return gamma;
-}
-
diff --git a/contrib/libs/lcms2/src/cmshalf.c b/contrib/libs/lcms2/src/cmshalf.c
deleted file mode 100644
index 043ee530b4..0000000000
--- a/contrib/libs/lcms2/src/cmshalf.c
+++ /dev/null
@@ -1,535 +0,0 @@
-//---------------------------------------------------------------------------------
-//
-// Little Color Management System
-// Copyright (c) 1998-2023 Marti Maria Saguer
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//---------------------------------------------------------------------------------
-//
-//
-#include "lcms2_internal.h"
-
-#ifndef CMS_NO_HALF_SUPPORT
-
-// This code is inspired in the paper "Fast Half Float Conversions"
-// by Jeroen van der Zijp
-
-static const cmsUInt32Number Mantissa[2048] = {
-
-0x00000000, 0x33800000, 0x34000000, 0x34400000, 0x34800000, 0x34a00000,
-0x34c00000, 0x34e00000, 0x35000000, 0x35100000, 0x35200000, 0x35300000,
-0x35400000, 0x35500000, 0x35600000, 0x35700000, 0x35800000, 0x35880000,
-0x35900000, 0x35980000, 0x35a00000, 0x35a80000, 0x35b00000, 0x35b80000,
-0x35c00000, 0x35c80000, 0x35d00000, 0x35d80000, 0x35e00000, 0x35e80000,
-0x35f00000, 0x35f80000, 0x36000000, 0x36040000, 0x36080000, 0x360c0000,
-0x36100000, 0x36140000, 0x36180000, 0x361c0000, 0x36200000, 0x36240000,
-0x36280000, 0x362c0000, 0x36300000, 0x36340000, 0x36380000, 0x363c0000,
-0x36400000, 0x36440000, 0x36480000, 0x364c0000, 0x36500000, 0x36540000,
-0x36580000, 0x365c0000, 0x36600000, 0x36640000, 0x36680000, 0x366c0000,
-0x36700000, 0x36740000, 0x36780000, 0x367c0000, 0x36800000, 0x36820000,
-0x36840000, 0x36860000, 0x36880000, 0x368a0000, 0x368c0000, 0x368e0000,
-0x36900000, 0x36920000, 0x36940000, 0x36960000, 0x36980000, 0x369a0000,
-0x369c0000, 0x369e0000, 0x36a00000, 0x36a20000, 0x36a40000, 0x36a60000,
-0x36a80000, 0x36aa0000, 0x36ac0000, 0x36ae0000, 0x36b00000, 0x36b20000,
-0x36b40000, 0x36b60000, 0x36b80000, 0x36ba0000, 0x36bc0000, 0x36be0000,
-0x36c00000, 0x36c20000, 0x36c40000, 0x36c60000, 0x36c80000, 0x36ca0000,
-0x36cc0000, 0x36ce0000, 0x36d00000, 0x36d20000, 0x36d40000, 0x36d60000,
-0x36d80000, 0x36da0000, 0x36dc0000, 0x36de0000, 0x36e00000, 0x36e20000,
-0x36e40000, 0x36e60000, 0x36e80000, 0x36ea0000, 0x36ec0000, 0x36ee0000,
-0x36f00000, 0x36f20000, 0x36f40000, 0x36f60000, 0x36f80000, 0x36fa0000,
-0x36fc0000, 0x36fe0000, 0x37000000, 0x37010000, 0x37020000, 0x37030000,
-0x37040000, 0x37050000, 0x37060000, 0x37070000, 0x37080000, 0x37090000,
-0x370a0000, 0x370b0000, 0x370c0000, 0x370d0000, 0x370e0000, 0x370f0000,
-0x37100000, 0x37110000, 0x37120000, 0x37130000, 0x37140000, 0x37150000,
-0x37160000, 0x37170000, 0x37180000, 0x37190000, 0x371a0000, 0x371b0000,
-0x371c0000, 0x371d0000, 0x371e0000, 0x371f0000, 0x37200000, 0x37210000,
-0x37220000, 0x37230000, 0x37240000, 0x37250000, 0x37260000, 0x37270000,
-0x37280000, 0x37290000, 0x372a0000, 0x372b0000, 0x372c0000, 0x372d0000,
-0x372e0000, 0x372f0000, 0x37300000, 0x37310000, 0x37320000, 0x37330000,
-0x37340000, 0x37350000, 0x37360000, 0x37370000, 0x37380000, 0x37390000,
-0x373a0000, 0x373b0000, 0x373c0000, 0x373d0000, 0x373e0000, 0x373f0000,
-0x37400000, 0x37410000, 0x37420000, 0x37430000, 0x37440000, 0x37450000,
-0x37460000, 0x37470000, 0x37480000, 0x37490000, 0x374a0000, 0x374b0000,
-0x374c0000, 0x374d0000, 0x374e0000, 0x374f0000, 0x37500000, 0x37510000,
-0x37520000, 0x37530000, 0x37540000, 0x37550000, 0x37560000, 0x37570000,
-0x37580000, 0x37590000, 0x375a0000, 0x375b0000, 0x375c0000, 0x375d0000,
-0x375e0000, 0x375f0000, 0x37600000, 0x37610000, 0x37620000, 0x37630000,
-0x37640000, 0x37650000, 0x37660000, 0x37670000, 0x37680000, 0x37690000,
-0x376a0000, 0x376b0000, 0x376c0000, 0x376d0000, 0x376e0000, 0x376f0000,
-0x37700000, 0x37710000, 0x37720000, 0x37730000, 0x37740000, 0x37750000,
-0x37760000, 0x37770000, 0x37780000, 0x37790000, 0x377a0000, 0x377b0000,
-0x377c0000, 0x377d0000, 0x377e0000, 0x377f0000, 0x37800000, 0x37808000,
-0x37810000, 0x37818000, 0x37820000, 0x37828000, 0x37830000, 0x37838000,
-0x37840000, 0x37848000, 0x37850000, 0x37858000, 0x37860000, 0x37868000,
-0x37870000, 0x37878000, 0x37880000, 0x37888000, 0x37890000, 0x37898000,
-0x378a0000, 0x378a8000, 0x378b0000, 0x378b8000, 0x378c0000, 0x378c8000,
-0x378d0000, 0x378d8000, 0x378e0000, 0x378e8000, 0x378f0000, 0x378f8000,
-0x37900000, 0x37908000, 0x37910000, 0x37918000, 0x37920000, 0x37928000,
-0x37930000, 0x37938000, 0x37940000, 0x37948000, 0x37950000, 0x37958000,
-0x37960000, 0x37968000, 0x37970000, 0x37978000, 0x37980000, 0x37988000,
-0x37990000, 0x37998000, 0x379a0000, 0x379a8000, 0x379b0000, 0x379b8000,
-0x379c0000, 0x379c8000, 0x379d0000, 0x379d8000, 0x379e0000, 0x379e8000,
-0x379f0000, 0x379f8000, 0x37a00000, 0x37a08000, 0x37a10000, 0x37a18000,
-0x37a20000, 0x37a28000, 0x37a30000, 0x37a38000, 0x37a40000, 0x37a48000,
-0x37a50000, 0x37a58000, 0x37a60000, 0x37a68000, 0x37a70000, 0x37a78000,
-0x37a80000, 0x37a88000, 0x37a90000, 0x37a98000, 0x37aa0000, 0x37aa8000,
-0x37ab0000, 0x37ab8000, 0x37ac0000, 0x37ac8000, 0x37ad0000, 0x37ad8000,
-0x37ae0000, 0x37ae8000, 0x37af0000, 0x37af8000, 0x37b00000, 0x37b08000,
-0x37b10000, 0x37b18000, 0x37b20000, 0x37b28000, 0x37b30000, 0x37b38000,
-0x37b40000, 0x37b48000, 0x37b50000, 0x37b58000, 0x37b60000, 0x37b68000,
-0x37b70000, 0x37b78000, 0x37b80000, 0x37b88000, 0x37b90000, 0x37b98000,
-0x37ba0000, 0x37ba8000, 0x37bb0000, 0x37bb8000, 0x37bc0000, 0x37bc8000,
-0x37bd0000, 0x37bd8000, 0x37be0000, 0x37be8000, 0x37bf0000, 0x37bf8000,
-0x37c00000, 0x37c08000, 0x37c10000, 0x37c18000, 0x37c20000, 0x37c28000,
-0x37c30000, 0x37c38000, 0x37c40000, 0x37c48000, 0x37c50000, 0x37c58000,
-0x37c60000, 0x37c68000, 0x37c70000, 0x37c78000, 0x37c80000, 0x37c88000,
-0x37c90000, 0x37c98000, 0x37ca0000, 0x37ca8000, 0x37cb0000, 0x37cb8000,
-0x37cc0000, 0x37cc8000, 0x37cd0000, 0x37cd8000, 0x37ce0000, 0x37ce8000,
-0x37cf0000, 0x37cf8000, 0x37d00000, 0x37d08000, 0x37d10000, 0x37d18000,
-0x37d20000, 0x37d28000, 0x37d30000, 0x37d38000, 0x37d40000, 0x37d48000,
-0x37d50000, 0x37d58000, 0x37d60000, 0x37d68000, 0x37d70000, 0x37d78000,
-0x37d80000, 0x37d88000, 0x37d90000, 0x37d98000, 0x37da0000, 0x37da8000,
-0x37db0000, 0x37db8000, 0x37dc0000, 0x37dc8000, 0x37dd0000, 0x37dd8000,
-0x37de0000, 0x37de8000, 0x37df0000, 0x37df8000, 0x37e00000, 0x37e08000,
-0x37e10000, 0x37e18000, 0x37e20000, 0x37e28000, 0x37e30000, 0x37e38000,
-0x37e40000, 0x37e48000, 0x37e50000, 0x37e58000, 0x37e60000, 0x37e68000,
-0x37e70000, 0x37e78000, 0x37e80000, 0x37e88000, 0x37e90000, 0x37e98000,
-0x37ea0000, 0x37ea8000, 0x37eb0000, 0x37eb8000, 0x37ec0000, 0x37ec8000,
-0x37ed0000, 0x37ed8000, 0x37ee0000, 0x37ee8000, 0x37ef0000, 0x37ef8000,
-0x37f00000, 0x37f08000, 0x37f10000, 0x37f18000, 0x37f20000, 0x37f28000,
-0x37f30000, 0x37f38000, 0x37f40000, 0x37f48000, 0x37f50000, 0x37f58000,
-0x37f60000, 0x37f68000, 0x37f70000, 0x37f78000, 0x37f80000, 0x37f88000,
-0x37f90000, 0x37f98000, 0x37fa0000, 0x37fa8000, 0x37fb0000, 0x37fb8000,
-0x37fc0000, 0x37fc8000, 0x37fd0000, 0x37fd8000, 0x37fe0000, 0x37fe8000,
-0x37ff0000, 0x37ff8000, 0x38000000, 0x38004000, 0x38008000, 0x3800c000,
-0x38010000, 0x38014000, 0x38018000, 0x3801c000, 0x38020000, 0x38024000,
-0x38028000, 0x3802c000, 0x38030000, 0x38034000, 0x38038000, 0x3803c000,
-0x38040000, 0x38044000, 0x38048000, 0x3804c000, 0x38050000, 0x38054000,
-0x38058000, 0x3805c000, 0x38060000, 0x38064000, 0x38068000, 0x3806c000,
-0x38070000, 0x38074000, 0x38078000, 0x3807c000, 0x38080000, 0x38084000,
-0x38088000, 0x3808c000, 0x38090000, 0x38094000, 0x38098000, 0x3809c000,
-0x380a0000, 0x380a4000, 0x380a8000, 0x380ac000, 0x380b0000, 0x380b4000,
-0x380b8000, 0x380bc000, 0x380c0000, 0x380c4000, 0x380c8000, 0x380cc000,
-0x380d0000, 0x380d4000, 0x380d8000, 0x380dc000, 0x380e0000, 0x380e4000,
-0x380e8000, 0x380ec000, 0x380f0000, 0x380f4000, 0x380f8000, 0x380fc000,
-0x38100000, 0x38104000, 0x38108000, 0x3810c000, 0x38110000, 0x38114000,
-0x38118000, 0x3811c000, 0x38120000, 0x38124000, 0x38128000, 0x3812c000,
-0x38130000, 0x38134000, 0x38138000, 0x3813c000, 0x38140000, 0x38144000,
-0x38148000, 0x3814c000, 0x38150000, 0x38154000, 0x38158000, 0x3815c000,
-0x38160000, 0x38164000, 0x38168000, 0x3816c000, 0x38170000, 0x38174000,
-0x38178000, 0x3817c000, 0x38180000, 0x38184000, 0x38188000, 0x3818c000,
-0x38190000, 0x38194000, 0x38198000, 0x3819c000, 0x381a0000, 0x381a4000,
-0x381a8000, 0x381ac000, 0x381b0000, 0x381b4000, 0x381b8000, 0x381bc000,
-0x381c0000, 0x381c4000, 0x381c8000, 0x381cc000, 0x381d0000, 0x381d4000,
-0x381d8000, 0x381dc000, 0x381e0000, 0x381e4000, 0x381e8000, 0x381ec000,
-0x381f0000, 0x381f4000, 0x381f8000, 0x381fc000, 0x38200000, 0x38204000,
-0x38208000, 0x3820c000, 0x38210000, 0x38214000, 0x38218000, 0x3821c000,
-0x38220000, 0x38224000, 0x38228000, 0x3822c000, 0x38230000, 0x38234000,
-0x38238000, 0x3823c000, 0x38240000, 0x38244000, 0x38248000, 0x3824c000,
-0x38250000, 0x38254000, 0x38258000, 0x3825c000, 0x38260000, 0x38264000,
-0x38268000, 0x3826c000, 0x38270000, 0x38274000, 0x38278000, 0x3827c000,
-0x38280000, 0x38284000, 0x38288000, 0x3828c000, 0x38290000, 0x38294000,
-0x38298000, 0x3829c000, 0x382a0000, 0x382a4000, 0x382a8000, 0x382ac000,
-0x382b0000, 0x382b4000, 0x382b8000, 0x382bc000, 0x382c0000, 0x382c4000,
-0x382c8000, 0x382cc000, 0x382d0000, 0x382d4000, 0x382d8000, 0x382dc000,
-0x382e0000, 0x382e4000, 0x382e8000, 0x382ec000, 0x382f0000, 0x382f4000,
-0x382f8000, 0x382fc000, 0x38300000, 0x38304000, 0x38308000, 0x3830c000,
-0x38310000, 0x38314000, 0x38318000, 0x3831c000, 0x38320000, 0x38324000,
-0x38328000, 0x3832c000, 0x38330000, 0x38334000, 0x38338000, 0x3833c000,
-0x38340000, 0x38344000, 0x38348000, 0x3834c000, 0x38350000, 0x38354000,
-0x38358000, 0x3835c000, 0x38360000, 0x38364000, 0x38368000, 0x3836c000,
-0x38370000, 0x38374000, 0x38378000, 0x3837c000, 0x38380000, 0x38384000,
-0x38388000, 0x3838c000, 0x38390000, 0x38394000, 0x38398000, 0x3839c000,
-0x383a0000, 0x383a4000, 0x383a8000, 0x383ac000, 0x383b0000, 0x383b4000,
-0x383b8000, 0x383bc000, 0x383c0000, 0x383c4000, 0x383c8000, 0x383cc000,
-0x383d0000, 0x383d4000, 0x383d8000, 0x383dc000, 0x383e0000, 0x383e4000,
-0x383e8000, 0x383ec000, 0x383f0000, 0x383f4000, 0x383f8000, 0x383fc000,
-0x38400000, 0x38404000, 0x38408000, 0x3840c000, 0x38410000, 0x38414000,
-0x38418000, 0x3841c000, 0x38420000, 0x38424000, 0x38428000, 0x3842c000,
-0x38430000, 0x38434000, 0x38438000, 0x3843c000, 0x38440000, 0x38444000,
-0x38448000, 0x3844c000, 0x38450000, 0x38454000, 0x38458000, 0x3845c000,
-0x38460000, 0x38464000, 0x38468000, 0x3846c000, 0x38470000, 0x38474000,
-0x38478000, 0x3847c000, 0x38480000, 0x38484000, 0x38488000, 0x3848c000,
-0x38490000, 0x38494000, 0x38498000, 0x3849c000, 0x384a0000, 0x384a4000,
-0x384a8000, 0x384ac000, 0x384b0000, 0x384b4000, 0x384b8000, 0x384bc000,
-0x384c0000, 0x384c4000, 0x384c8000, 0x384cc000, 0x384d0000, 0x384d4000,
-0x384d8000, 0x384dc000, 0x384e0000, 0x384e4000, 0x384e8000, 0x384ec000,
-0x384f0000, 0x384f4000, 0x384f8000, 0x384fc000, 0x38500000, 0x38504000,
-0x38508000, 0x3850c000, 0x38510000, 0x38514000, 0x38518000, 0x3851c000,
-0x38520000, 0x38524000, 0x38528000, 0x3852c000, 0x38530000, 0x38534000,
-0x38538000, 0x3853c000, 0x38540000, 0x38544000, 0x38548000, 0x3854c000,
-0x38550000, 0x38554000, 0x38558000, 0x3855c000, 0x38560000, 0x38564000,
-0x38568000, 0x3856c000, 0x38570000, 0x38574000, 0x38578000, 0x3857c000,
-0x38580000, 0x38584000, 0x38588000, 0x3858c000, 0x38590000, 0x38594000,
-0x38598000, 0x3859c000, 0x385a0000, 0x385a4000, 0x385a8000, 0x385ac000,
-0x385b0000, 0x385b4000, 0x385b8000, 0x385bc000, 0x385c0000, 0x385c4000,
-0x385c8000, 0x385cc000, 0x385d0000, 0x385d4000, 0x385d8000, 0x385dc000,
-0x385e0000, 0x385e4000, 0x385e8000, 0x385ec000, 0x385f0000, 0x385f4000,
-0x385f8000, 0x385fc000, 0x38600000, 0x38604000, 0x38608000, 0x3860c000,
-0x38610000, 0x38614000, 0x38618000, 0x3861c000, 0x38620000, 0x38624000,
-0x38628000, 0x3862c000, 0x38630000, 0x38634000, 0x38638000, 0x3863c000,
-0x38640000, 0x38644000, 0x38648000, 0x3864c000, 0x38650000, 0x38654000,
-0x38658000, 0x3865c000, 0x38660000, 0x38664000, 0x38668000, 0x3866c000,
-0x38670000, 0x38674000, 0x38678000, 0x3867c000, 0x38680000, 0x38684000,
-0x38688000, 0x3868c000, 0x38690000, 0x38694000, 0x38698000, 0x3869c000,
-0x386a0000, 0x386a4000, 0x386a8000, 0x386ac000, 0x386b0000, 0x386b4000,
-0x386b8000, 0x386bc000, 0x386c0000, 0x386c4000, 0x386c8000, 0x386cc000,
-0x386d0000, 0x386d4000, 0x386d8000, 0x386dc000, 0x386e0000, 0x386e4000,
-0x386e8000, 0x386ec000, 0x386f0000, 0x386f4000, 0x386f8000, 0x386fc000,
-0x38700000, 0x38704000, 0x38708000, 0x3870c000, 0x38710000, 0x38714000,
-0x38718000, 0x3871c000, 0x38720000, 0x38724000, 0x38728000, 0x3872c000,
-0x38730000, 0x38734000, 0x38738000, 0x3873c000, 0x38740000, 0x38744000,
-0x38748000, 0x3874c000, 0x38750000, 0x38754000, 0x38758000, 0x3875c000,
-0x38760000, 0x38764000, 0x38768000, 0x3876c000, 0x38770000, 0x38774000,
-0x38778000, 0x3877c000, 0x38780000, 0x38784000, 0x38788000, 0x3878c000,
-0x38790000, 0x38794000, 0x38798000, 0x3879c000, 0x387a0000, 0x387a4000,
-0x387a8000, 0x387ac000, 0x387b0000, 0x387b4000, 0x387b8000, 0x387bc000,
-0x387c0000, 0x387c4000, 0x387c8000, 0x387cc000, 0x387d0000, 0x387d4000,
-0x387d8000, 0x387dc000, 0x387e0000, 0x387e4000, 0x387e8000, 0x387ec000,
-0x387f0000, 0x387f4000, 0x387f8000, 0x387fc000, 0x38000000, 0x38002000,
-0x38004000, 0x38006000, 0x38008000, 0x3800a000, 0x3800c000, 0x3800e000,
-0x38010000, 0x38012000, 0x38014000, 0x38016000, 0x38018000, 0x3801a000,
-0x3801c000, 0x3801e000, 0x38020000, 0x38022000, 0x38024000, 0x38026000,
-0x38028000, 0x3802a000, 0x3802c000, 0x3802e000, 0x38030000, 0x38032000,
-0x38034000, 0x38036000, 0x38038000, 0x3803a000, 0x3803c000, 0x3803e000,
-0x38040000, 0x38042000, 0x38044000, 0x38046000, 0x38048000, 0x3804a000,
-0x3804c000, 0x3804e000, 0x38050000, 0x38052000, 0x38054000, 0x38056000,
-0x38058000, 0x3805a000, 0x3805c000, 0x3805e000, 0x38060000, 0x38062000,
-0x38064000, 0x38066000, 0x38068000, 0x3806a000, 0x3806c000, 0x3806e000,
-0x38070000, 0x38072000, 0x38074000, 0x38076000, 0x38078000, 0x3807a000,
-0x3807c000, 0x3807e000, 0x38080000, 0x38082000, 0x38084000, 0x38086000,
-0x38088000, 0x3808a000, 0x3808c000, 0x3808e000, 0x38090000, 0x38092000,
-0x38094000, 0x38096000, 0x38098000, 0x3809a000, 0x3809c000, 0x3809e000,
-0x380a0000, 0x380a2000, 0x380a4000, 0x380a6000, 0x380a8000, 0x380aa000,
-0x380ac000, 0x380ae000, 0x380b0000, 0x380b2000, 0x380b4000, 0x380b6000,
-0x380b8000, 0x380ba000, 0x380bc000, 0x380be000, 0x380c0000, 0x380c2000,
-0x380c4000, 0x380c6000, 0x380c8000, 0x380ca000, 0x380cc000, 0x380ce000,
-0x380d0000, 0x380d2000, 0x380d4000, 0x380d6000, 0x380d8000, 0x380da000,
-0x380dc000, 0x380de000, 0x380e0000, 0x380e2000, 0x380e4000, 0x380e6000,
-0x380e8000, 0x380ea000, 0x380ec000, 0x380ee000, 0x380f0000, 0x380f2000,
-0x380f4000, 0x380f6000, 0x380f8000, 0x380fa000, 0x380fc000, 0x380fe000,
-0x38100000, 0x38102000, 0x38104000, 0x38106000, 0x38108000, 0x3810a000,
-0x3810c000, 0x3810e000, 0x38110000, 0x38112000, 0x38114000, 0x38116000,
-0x38118000, 0x3811a000, 0x3811c000, 0x3811e000, 0x38120000, 0x38122000,
-0x38124000, 0x38126000, 0x38128000, 0x3812a000, 0x3812c000, 0x3812e000,
-0x38130000, 0x38132000, 0x38134000, 0x38136000, 0x38138000, 0x3813a000,
-0x3813c000, 0x3813e000, 0x38140000, 0x38142000, 0x38144000, 0x38146000,
-0x38148000, 0x3814a000, 0x3814c000, 0x3814e000, 0x38150000, 0x38152000,
-0x38154000, 0x38156000, 0x38158000, 0x3815a000, 0x3815c000, 0x3815e000,
-0x38160000, 0x38162000, 0x38164000, 0x38166000, 0x38168000, 0x3816a000,
-0x3816c000, 0x3816e000, 0x38170000, 0x38172000, 0x38174000, 0x38176000,
-0x38178000, 0x3817a000, 0x3817c000, 0x3817e000, 0x38180000, 0x38182000,
-0x38184000, 0x38186000, 0x38188000, 0x3818a000, 0x3818c000, 0x3818e000,
-0x38190000, 0x38192000, 0x38194000, 0x38196000, 0x38198000, 0x3819a000,
-0x3819c000, 0x3819e000, 0x381a0000, 0x381a2000, 0x381a4000, 0x381a6000,
-0x381a8000, 0x381aa000, 0x381ac000, 0x381ae000, 0x381b0000, 0x381b2000,
-0x381b4000, 0x381b6000, 0x381b8000, 0x381ba000, 0x381bc000, 0x381be000,
-0x381c0000, 0x381c2000, 0x381c4000, 0x381c6000, 0x381c8000, 0x381ca000,
-0x381cc000, 0x381ce000, 0x381d0000, 0x381d2000, 0x381d4000, 0x381d6000,
-0x381d8000, 0x381da000, 0x381dc000, 0x381de000, 0x381e0000, 0x381e2000,
-0x381e4000, 0x381e6000, 0x381e8000, 0x381ea000, 0x381ec000, 0x381ee000,
-0x381f0000, 0x381f2000, 0x381f4000, 0x381f6000, 0x381f8000, 0x381fa000,
-0x381fc000, 0x381fe000, 0x38200000, 0x38202000, 0x38204000, 0x38206000,
-0x38208000, 0x3820a000, 0x3820c000, 0x3820e000, 0x38210000, 0x38212000,
-0x38214000, 0x38216000, 0x38218000, 0x3821a000, 0x3821c000, 0x3821e000,
-0x38220000, 0x38222000, 0x38224000, 0x38226000, 0x38228000, 0x3822a000,
-0x3822c000, 0x3822e000, 0x38230000, 0x38232000, 0x38234000, 0x38236000,
-0x38238000, 0x3823a000, 0x3823c000, 0x3823e000, 0x38240000, 0x38242000,
-0x38244000, 0x38246000, 0x38248000, 0x3824a000, 0x3824c000, 0x3824e000,
-0x38250000, 0x38252000, 0x38254000, 0x38256000, 0x38258000, 0x3825a000,
-0x3825c000, 0x3825e000, 0x38260000, 0x38262000, 0x38264000, 0x38266000,
-0x38268000, 0x3826a000, 0x3826c000, 0x3826e000, 0x38270000, 0x38272000,
-0x38274000, 0x38276000, 0x38278000, 0x3827a000, 0x3827c000, 0x3827e000,
-0x38280000, 0x38282000, 0x38284000, 0x38286000, 0x38288000, 0x3828a000,
-0x3828c000, 0x3828e000, 0x38290000, 0x38292000, 0x38294000, 0x38296000,
-0x38298000, 0x3829a000, 0x3829c000, 0x3829e000, 0x382a0000, 0x382a2000,
-0x382a4000, 0x382a6000, 0x382a8000, 0x382aa000, 0x382ac000, 0x382ae000,
-0x382b0000, 0x382b2000, 0x382b4000, 0x382b6000, 0x382b8000, 0x382ba000,
-0x382bc000, 0x382be000, 0x382c0000, 0x382c2000, 0x382c4000, 0x382c6000,
-0x382c8000, 0x382ca000, 0x382cc000, 0x382ce000, 0x382d0000, 0x382d2000,
-0x382d4000, 0x382d6000, 0x382d8000, 0x382da000, 0x382dc000, 0x382de000,
-0x382e0000, 0x382e2000, 0x382e4000, 0x382e6000, 0x382e8000, 0x382ea000,
-0x382ec000, 0x382ee000, 0x382f0000, 0x382f2000, 0x382f4000, 0x382f6000,
-0x382f8000, 0x382fa000, 0x382fc000, 0x382fe000, 0x38300000, 0x38302000,
-0x38304000, 0x38306000, 0x38308000, 0x3830a000, 0x3830c000, 0x3830e000,
-0x38310000, 0x38312000, 0x38314000, 0x38316000, 0x38318000, 0x3831a000,
-0x3831c000, 0x3831e000, 0x38320000, 0x38322000, 0x38324000, 0x38326000,
-0x38328000, 0x3832a000, 0x3832c000, 0x3832e000, 0x38330000, 0x38332000,
-0x38334000, 0x38336000, 0x38338000, 0x3833a000, 0x3833c000, 0x3833e000,
-0x38340000, 0x38342000, 0x38344000, 0x38346000, 0x38348000, 0x3834a000,
-0x3834c000, 0x3834e000, 0x38350000, 0x38352000, 0x38354000, 0x38356000,
-0x38358000, 0x3835a000, 0x3835c000, 0x3835e000, 0x38360000, 0x38362000,
-0x38364000, 0x38366000, 0x38368000, 0x3836a000, 0x3836c000, 0x3836e000,
-0x38370000, 0x38372000, 0x38374000, 0x38376000, 0x38378000, 0x3837a000,
-0x3837c000, 0x3837e000, 0x38380000, 0x38382000, 0x38384000, 0x38386000,
-0x38388000, 0x3838a000, 0x3838c000, 0x3838e000, 0x38390000, 0x38392000,
-0x38394000, 0x38396000, 0x38398000, 0x3839a000, 0x3839c000, 0x3839e000,
-0x383a0000, 0x383a2000, 0x383a4000, 0x383a6000, 0x383a8000, 0x383aa000,
-0x383ac000, 0x383ae000, 0x383b0000, 0x383b2000, 0x383b4000, 0x383b6000,
-0x383b8000, 0x383ba000, 0x383bc000, 0x383be000, 0x383c0000, 0x383c2000,
-0x383c4000, 0x383c6000, 0x383c8000, 0x383ca000, 0x383cc000, 0x383ce000,
-0x383d0000, 0x383d2000, 0x383d4000, 0x383d6000, 0x383d8000, 0x383da000,
-0x383dc000, 0x383de000, 0x383e0000, 0x383e2000, 0x383e4000, 0x383e6000,
-0x383e8000, 0x383ea000, 0x383ec000, 0x383ee000, 0x383f0000, 0x383f2000,
-0x383f4000, 0x383f6000, 0x383f8000, 0x383fa000, 0x383fc000, 0x383fe000,
-0x38400000, 0x38402000, 0x38404000, 0x38406000, 0x38408000, 0x3840a000,
-0x3840c000, 0x3840e000, 0x38410000, 0x38412000, 0x38414000, 0x38416000,
-0x38418000, 0x3841a000, 0x3841c000, 0x3841e000, 0x38420000, 0x38422000,
-0x38424000, 0x38426000, 0x38428000, 0x3842a000, 0x3842c000, 0x3842e000,
-0x38430000, 0x38432000, 0x38434000, 0x38436000, 0x38438000, 0x3843a000,
-0x3843c000, 0x3843e000, 0x38440000, 0x38442000, 0x38444000, 0x38446000,
-0x38448000, 0x3844a000, 0x3844c000, 0x3844e000, 0x38450000, 0x38452000,
-0x38454000, 0x38456000, 0x38458000, 0x3845a000, 0x3845c000, 0x3845e000,
-0x38460000, 0x38462000, 0x38464000, 0x38466000, 0x38468000, 0x3846a000,
-0x3846c000, 0x3846e000, 0x38470000, 0x38472000, 0x38474000, 0x38476000,
-0x38478000, 0x3847a000, 0x3847c000, 0x3847e000, 0x38480000, 0x38482000,
-0x38484000, 0x38486000, 0x38488000, 0x3848a000, 0x3848c000, 0x3848e000,
-0x38490000, 0x38492000, 0x38494000, 0x38496000, 0x38498000, 0x3849a000,
-0x3849c000, 0x3849e000, 0x384a0000, 0x384a2000, 0x384a4000, 0x384a6000,
-0x384a8000, 0x384aa000, 0x384ac000, 0x384ae000, 0x384b0000, 0x384b2000,
-0x384b4000, 0x384b6000, 0x384b8000, 0x384ba000, 0x384bc000, 0x384be000,
-0x384c0000, 0x384c2000, 0x384c4000, 0x384c6000, 0x384c8000, 0x384ca000,
-0x384cc000, 0x384ce000, 0x384d0000, 0x384d2000, 0x384d4000, 0x384d6000,
-0x384d8000, 0x384da000, 0x384dc000, 0x384de000, 0x384e0000, 0x384e2000,
-0x384e4000, 0x384e6000, 0x384e8000, 0x384ea000, 0x384ec000, 0x384ee000,
-0x384f0000, 0x384f2000, 0x384f4000, 0x384f6000, 0x384f8000, 0x384fa000,
-0x384fc000, 0x384fe000, 0x38500000, 0x38502000, 0x38504000, 0x38506000,
-0x38508000, 0x3850a000, 0x3850c000, 0x3850e000, 0x38510000, 0x38512000,
-0x38514000, 0x38516000, 0x38518000, 0x3851a000, 0x3851c000, 0x3851e000,
-0x38520000, 0x38522000, 0x38524000, 0x38526000, 0x38528000, 0x3852a000,
-0x3852c000, 0x3852e000, 0x38530000, 0x38532000, 0x38534000, 0x38536000,
-0x38538000, 0x3853a000, 0x3853c000, 0x3853e000, 0x38540000, 0x38542000,
-0x38544000, 0x38546000, 0x38548000, 0x3854a000, 0x3854c000, 0x3854e000,
-0x38550000, 0x38552000, 0x38554000, 0x38556000, 0x38558000, 0x3855a000,
-0x3855c000, 0x3855e000, 0x38560000, 0x38562000, 0x38564000, 0x38566000,
-0x38568000, 0x3856a000, 0x3856c000, 0x3856e000, 0x38570000, 0x38572000,
-0x38574000, 0x38576000, 0x38578000, 0x3857a000, 0x3857c000, 0x3857e000,
-0x38580000, 0x38582000, 0x38584000, 0x38586000, 0x38588000, 0x3858a000,
-0x3858c000, 0x3858e000, 0x38590000, 0x38592000, 0x38594000, 0x38596000,
-0x38598000, 0x3859a000, 0x3859c000, 0x3859e000, 0x385a0000, 0x385a2000,
-0x385a4000, 0x385a6000, 0x385a8000, 0x385aa000, 0x385ac000, 0x385ae000,
-0x385b0000, 0x385b2000, 0x385b4000, 0x385b6000, 0x385b8000, 0x385ba000,
-0x385bc000, 0x385be000, 0x385c0000, 0x385c2000, 0x385c4000, 0x385c6000,
-0x385c8000, 0x385ca000, 0x385cc000, 0x385ce000, 0x385d0000, 0x385d2000,
-0x385d4000, 0x385d6000, 0x385d8000, 0x385da000, 0x385dc000, 0x385de000,
-0x385e0000, 0x385e2000, 0x385e4000, 0x385e6000, 0x385e8000, 0x385ea000,
-0x385ec000, 0x385ee000, 0x385f0000, 0x385f2000, 0x385f4000, 0x385f6000,
-0x385f8000, 0x385fa000, 0x385fc000, 0x385fe000, 0x38600000, 0x38602000,
-0x38604000, 0x38606000, 0x38608000, 0x3860a000, 0x3860c000, 0x3860e000,
-0x38610000, 0x38612000, 0x38614000, 0x38616000, 0x38618000, 0x3861a000,
-0x3861c000, 0x3861e000, 0x38620000, 0x38622000, 0x38624000, 0x38626000,
-0x38628000, 0x3862a000, 0x3862c000, 0x3862e000, 0x38630000, 0x38632000,
-0x38634000, 0x38636000, 0x38638000, 0x3863a000, 0x3863c000, 0x3863e000,
-0x38640000, 0x38642000, 0x38644000, 0x38646000, 0x38648000, 0x3864a000,
-0x3864c000, 0x3864e000, 0x38650000, 0x38652000, 0x38654000, 0x38656000,
-0x38658000, 0x3865a000, 0x3865c000, 0x3865e000, 0x38660000, 0x38662000,
-0x38664000, 0x38666000, 0x38668000, 0x3866a000, 0x3866c000, 0x3866e000,
-0x38670000, 0x38672000, 0x38674000, 0x38676000, 0x38678000, 0x3867a000,
-0x3867c000, 0x3867e000, 0x38680000, 0x38682000, 0x38684000, 0x38686000,
-0x38688000, 0x3868a000, 0x3868c000, 0x3868e000, 0x38690000, 0x38692000,
-0x38694000, 0x38696000, 0x38698000, 0x3869a000, 0x3869c000, 0x3869e000,
-0x386a0000, 0x386a2000, 0x386a4000, 0x386a6000, 0x386a8000, 0x386aa000,
-0x386ac000, 0x386ae000, 0x386b0000, 0x386b2000, 0x386b4000, 0x386b6000,
-0x386b8000, 0x386ba000, 0x386bc000, 0x386be000, 0x386c0000, 0x386c2000,
-0x386c4000, 0x386c6000, 0x386c8000, 0x386ca000, 0x386cc000, 0x386ce000,
-0x386d0000, 0x386d2000, 0x386d4000, 0x386d6000, 0x386d8000, 0x386da000,
-0x386dc000, 0x386de000, 0x386e0000, 0x386e2000, 0x386e4000, 0x386e6000,
-0x386e8000, 0x386ea000, 0x386ec000, 0x386ee000, 0x386f0000, 0x386f2000,
-0x386f4000, 0x386f6000, 0x386f8000, 0x386fa000, 0x386fc000, 0x386fe000,
-0x38700000, 0x38702000, 0x38704000, 0x38706000, 0x38708000, 0x3870a000,
-0x3870c000, 0x3870e000, 0x38710000, 0x38712000, 0x38714000, 0x38716000,
-0x38718000, 0x3871a000, 0x3871c000, 0x3871e000, 0x38720000, 0x38722000,
-0x38724000, 0x38726000, 0x38728000, 0x3872a000, 0x3872c000, 0x3872e000,
-0x38730000, 0x38732000, 0x38734000, 0x38736000, 0x38738000, 0x3873a000,
-0x3873c000, 0x3873e000, 0x38740000, 0x38742000, 0x38744000, 0x38746000,
-0x38748000, 0x3874a000, 0x3874c000, 0x3874e000, 0x38750000, 0x38752000,
-0x38754000, 0x38756000, 0x38758000, 0x3875a000, 0x3875c000, 0x3875e000,
-0x38760000, 0x38762000, 0x38764000, 0x38766000, 0x38768000, 0x3876a000,
-0x3876c000, 0x3876e000, 0x38770000, 0x38772000, 0x38774000, 0x38776000,
-0x38778000, 0x3877a000, 0x3877c000, 0x3877e000, 0x38780000, 0x38782000,
-0x38784000, 0x38786000, 0x38788000, 0x3878a000, 0x3878c000, 0x3878e000,
-0x38790000, 0x38792000, 0x38794000, 0x38796000, 0x38798000, 0x3879a000,
-0x3879c000, 0x3879e000, 0x387a0000, 0x387a2000, 0x387a4000, 0x387a6000,
-0x387a8000, 0x387aa000, 0x387ac000, 0x387ae000, 0x387b0000, 0x387b2000,
-0x387b4000, 0x387b6000, 0x387b8000, 0x387ba000, 0x387bc000, 0x387be000,
-0x387c0000, 0x387c2000, 0x387c4000, 0x387c6000, 0x387c8000, 0x387ca000,
-0x387cc000, 0x387ce000, 0x387d0000, 0x387d2000, 0x387d4000, 0x387d6000,
-0x387d8000, 0x387da000, 0x387dc000, 0x387de000, 0x387e0000, 0x387e2000,
-0x387e4000, 0x387e6000, 0x387e8000, 0x387ea000, 0x387ec000, 0x387ee000,
-0x387f0000, 0x387f2000, 0x387f4000, 0x387f6000, 0x387f8000, 0x387fa000,
-0x387fc000, 0x387fe000
-};
-
-static const cmsUInt16Number Offset[64] = {
-0x0000, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400,
-0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400,
-0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400,
-0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400,
-0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400,
-0x0400, 0x0400, 0x0000, 0x0400, 0x0400, 0x0400,
-0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400,
-0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400,
-0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400,
-0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400,
-0x0400, 0x0400, 0x0400, 0x0400
-};
-
-static const cmsUInt32Number Exponent[64] = {
-0x00000000, 0x00800000, 0x01000000, 0x01800000, 0x02000000, 0x02800000,
-0x03000000, 0x03800000, 0x04000000, 0x04800000, 0x05000000, 0x05800000,
-0x06000000, 0x06800000, 0x07000000, 0x07800000, 0x08000000, 0x08800000,
-0x09000000, 0x09800000, 0x0a000000, 0x0a800000, 0x0b000000, 0x0b800000,
-0x0c000000, 0x0c800000, 0x0d000000, 0x0d800000, 0x0e000000, 0x0e800000,
-0x0f000000, 0x47800000, 0x80000000, 0x80800000, 0x81000000, 0x81800000,
-0x82000000, 0x82800000, 0x83000000, 0x83800000, 0x84000000, 0x84800000,
-0x85000000, 0x85800000, 0x86000000, 0x86800000, 0x87000000, 0x87800000,
-0x88000000, 0x88800000, 0x89000000, 0x89800000, 0x8a000000, 0x8a800000,
-0x8b000000, 0x8b800000, 0x8c000000, 0x8c800000, 0x8d000000, 0x8d800000,
-0x8e000000, 0x8e800000, 0x8f000000, 0xc7800000
-};
-
-static const cmsUInt16Number Base[512] = {
-0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-0x0000, 0x0000, 0x0000, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040,
-0x0080, 0x0100, 0x0200, 0x0400, 0x0800, 0x0c00, 0x1000, 0x1400, 0x1800, 0x1c00,
-0x2000, 0x2400, 0x2800, 0x2c00, 0x3000, 0x3400, 0x3800, 0x3c00, 0x4000, 0x4400,
-0x4800, 0x4c00, 0x5000, 0x5400, 0x5800, 0x5c00, 0x6000, 0x6400, 0x6800, 0x6c00,
-0x7000, 0x7400, 0x7800, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00,
-0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00,
-0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00,
-0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00,
-0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00,
-0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00,
-0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00,
-0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00,
-0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00,
-0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00,
-0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00,
-0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x8000, 0x8000, 0x8000, 0x8000,
-0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
-0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
-0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
-0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
-0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
-0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
-0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
-0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
-0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
-0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8001,
-0x8002, 0x8004, 0x8008, 0x8010, 0x8020, 0x8040, 0x8080, 0x8100, 0x8200, 0x8400,
-0x8800, 0x8c00, 0x9000, 0x9400, 0x9800, 0x9c00, 0xa000, 0xa400, 0xa800, 0xac00,
-0xb000, 0xb400, 0xb800, 0xbc00, 0xc000, 0xc400, 0xc800, 0xcc00, 0xd000, 0xd400,
-0xd800, 0xdc00, 0xe000, 0xe400, 0xe800, 0xec00, 0xf000, 0xf400, 0xf800, 0xfc00,
-0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00,
-0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00,
-0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00,
-0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00,
-0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00,
-0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00,
-0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00,
-0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00,
-0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00,
-0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00,
-0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00,
-0xfc00, 0xfc00
-};
-
-static const cmsUInt8Number Shift[512] = {
-0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
-0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
-0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
-0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
-0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
-0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
-0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
-0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x17,
-0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x10, 0x0f, 0x0e, 0x0d, 0x0d, 0x0d, 0x0d,
-0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d,
-0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d,
-0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
-0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
-0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
-0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
-0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
-0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
-0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
-0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
-0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x0d, 0x18, 0x18, 0x18, 0x18,
-0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
-0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
-0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
-0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
-0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
-0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
-0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
-0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x17, 0x16, 0x15, 0x14, 0x13,
-0x12, 0x11, 0x10, 0x0f, 0x0e, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d,
-0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d,
-0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x18, 0x18, 0x18, 0x18,
-0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
-0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
-0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
-0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
-0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
-0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
-0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
-0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
-0x18, 0x18, 0x18, 0x18, 0x0d
-};
-
-cmsFloat32Number CMSEXPORT _cmsHalf2Float(cmsUInt16Number h)
-{
- union {
- cmsFloat32Number flt;
- cmsUInt32Number num;
- } out;
-
- int n = h >> 10;
-
- out.num = Mantissa[ (h & 0x3ff) + Offset[ n ] ] + Exponent[ n ];
- return out.flt;
-}
-
-cmsUInt16Number CMSEXPORT _cmsFloat2Half(cmsFloat32Number flt)
-{
- union {
- cmsFloat32Number flt;
- cmsUInt32Number num;
- } in;
-
- cmsUInt32Number n, j;
-
- in.flt = flt;
- n = in.num;
- j = (n >> 23) & 0x1ff;
-
- return (cmsUInt16Number) ((cmsUInt32Number) Base[ j ] + (( n & 0x007fffff) >> Shift[ j ]));
-}
-
-#endif
diff --git a/contrib/libs/lcms2/src/cmsintrp.c b/contrib/libs/lcms2/src/cmsintrp.c
deleted file mode 100644
index 2b5c634f42..0000000000
--- a/contrib/libs/lcms2/src/cmsintrp.c
+++ /dev/null
@@ -1,1330 +0,0 @@
-//---------------------------------------------------------------------------------
-//
-// Little Color Management System
-// Copyright (c) 1998-2023 Marti Maria Saguer
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//---------------------------------------------------------------------------------
-//
-
-#include "lcms2_internal.h"
-
-// This module incorporates several interpolation routines, for 1 to 8 channels on input and
-// up to 65535 channels on output. The user may change those by using the interpolation plug-in
-
-// Some people may want to compile as C++ with all warnings on, in this case make compiler silent
-#ifdef _MSC_VER
-# if (_MSC_VER >= 1400)
-# pragma warning( disable : 4365 )
-# endif
-#endif
-
-// Interpolation routines by default
-static cmsInterpFunction DefaultInterpolatorsFactory(cmsUInt32Number nInputChannels, cmsUInt32Number nOutputChannels, cmsUInt32Number dwFlags);
-
-// This is the default factory
-_cmsInterpPluginChunkType _cmsInterpPluginChunk = { NULL };
-
-// The interpolation plug-in memory chunk allocator/dup
-void _cmsAllocInterpPluginChunk(struct _cmsContext_struct* ctx, const struct _cmsContext_struct* src)
-{
- void* from;
-
- _cmsAssert(ctx != NULL);
-
- if (src != NULL) {
- from = src ->chunks[InterpPlugin];
- }
- else {
- static _cmsInterpPluginChunkType InterpPluginChunk = { NULL };
-
- from = &InterpPluginChunk;
- }
-
- _cmsAssert(from != NULL);
- ctx ->chunks[InterpPlugin] = _cmsSubAllocDup(ctx ->MemPool, from, sizeof(_cmsInterpPluginChunkType));
-}
-
-
-// Main plug-in entry
-cmsBool _cmsRegisterInterpPlugin(cmsContext ContextID, cmsPluginBase* Data)
-{
- cmsPluginInterpolation* Plugin = (cmsPluginInterpolation*) Data;
- _cmsInterpPluginChunkType* ptr = (_cmsInterpPluginChunkType*) _cmsContextGetClientChunk(ContextID, InterpPlugin);
-
- if (Data == NULL) {
-
- ptr ->Interpolators = NULL;
- return TRUE;
- }
-
- // Set replacement functions
- ptr ->Interpolators = Plugin ->InterpolatorsFactory;
- return TRUE;
-}
-
-
-// Set the interpolation method
-cmsBool _cmsSetInterpolationRoutine(cmsContext ContextID, cmsInterpParams* p)
-{
- _cmsInterpPluginChunkType* ptr = (_cmsInterpPluginChunkType*) _cmsContextGetClientChunk(ContextID, InterpPlugin);
-
- p ->Interpolation.Lerp16 = NULL;
-
- // Invoke factory, possibly in the Plug-in
- if (ptr ->Interpolators != NULL)
- p ->Interpolation = ptr->Interpolators(p -> nInputs, p ->nOutputs, p ->dwFlags);
-
- // If unsupported by the plug-in, go for the LittleCMS default.
- // If happens only if an extern plug-in is being used
- if (p ->Interpolation.Lerp16 == NULL)
- p ->Interpolation = DefaultInterpolatorsFactory(p ->nInputs, p ->nOutputs, p ->dwFlags);
-
- // Check for valid interpolator (we just check one member of the union)
- if (p ->Interpolation.Lerp16 == NULL) {
- return FALSE;
- }
-
- return TRUE;
-}
-
-
-// This function precalculates as many parameters as possible to speed up the interpolation.
-cmsInterpParams* _cmsComputeInterpParamsEx(cmsContext ContextID,
- const cmsUInt32Number nSamples[],
- cmsUInt32Number InputChan, cmsUInt32Number OutputChan,
- const void *Table,
- cmsUInt32Number dwFlags)
-{
- cmsInterpParams* p;
- cmsUInt32Number i;
-
- // Check for maximum inputs
- if (InputChan > MAX_INPUT_DIMENSIONS) {
- cmsSignalError(ContextID, cmsERROR_RANGE, "Too many input channels (%d channels, max=%d)", InputChan, MAX_INPUT_DIMENSIONS);
- return NULL;
- }
-
- // Creates an empty object
- p = (cmsInterpParams*) _cmsMallocZero(ContextID, sizeof(cmsInterpParams));
- if (p == NULL) return NULL;
-
- // Keep original parameters
- p -> dwFlags = dwFlags;
- p -> nInputs = InputChan;
- p -> nOutputs = OutputChan;
- p ->Table = Table;
- p ->ContextID = ContextID;
-
- // Fill samples per input direction and domain (which is number of nodes minus one)
- for (i=0; i < InputChan; i++) {
-
- p -> nSamples[i] = nSamples[i];
- p -> Domain[i] = nSamples[i] - 1;
- }
-
- // Compute factors to apply to each component to index the grid array
- p -> opta[0] = p -> nOutputs;
- for (i=1; i < InputChan; i++)
- p ->opta[i] = p ->opta[i-1] * nSamples[InputChan-i];
-
-
- if (!_cmsSetInterpolationRoutine(ContextID, p)) {
- cmsSignalError(ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unsupported interpolation (%d->%d channels)", InputChan, OutputChan);
- _cmsFree(ContextID, p);
- return NULL;
- }
-
- // All seems ok
- return p;
-}
-
-
-// This one is a wrapper on the anterior, but assuming all directions have same number of nodes
-cmsInterpParams* CMSEXPORT _cmsComputeInterpParams(cmsContext ContextID, cmsUInt32Number nSamples,
- cmsUInt32Number InputChan, cmsUInt32Number OutputChan, const void* Table, cmsUInt32Number dwFlags)
-{
- int i;
- cmsUInt32Number Samples[MAX_INPUT_DIMENSIONS];
-
- // Fill the auxiliary array
- for (i=0; i < MAX_INPUT_DIMENSIONS; i++)
- Samples[i] = nSamples;
-
- // Call the extended function
- return _cmsComputeInterpParamsEx(ContextID, Samples, InputChan, OutputChan, Table, dwFlags);
-}
-
-
-// Free all associated memory
-void CMSEXPORT _cmsFreeInterpParams(cmsInterpParams* p)
-{
- if (p != NULL) _cmsFree(p ->ContextID, p);
-}
-
-
-// Inline fixed point interpolation
-cmsINLINE CMS_NO_SANITIZE cmsUInt16Number LinearInterp(cmsS15Fixed16Number a, cmsS15Fixed16Number l, cmsS15Fixed16Number h)
-{
- cmsUInt32Number dif = (cmsUInt32Number) (h - l) * a + 0x8000;
- dif = (dif >> 16) + l;
- return (cmsUInt16Number) (dif);
-}
-
-
-// Linear interpolation (Fixed-point optimized)
-static
-void LinLerp1D(CMSREGISTER const cmsUInt16Number Value[],
- CMSREGISTER cmsUInt16Number Output[],
- CMSREGISTER const cmsInterpParams* p)
-{
- cmsUInt16Number y1, y0;
- int cell0, rest;
- int val3;
- const cmsUInt16Number* LutTable = (cmsUInt16Number*) p ->Table;
-
- // if last value or just one point
- if (Value[0] == 0xffff || p->Domain[0] == 0) {
-
- Output[0] = LutTable[p -> Domain[0]];
- }
- else
- {
- val3 = p->Domain[0] * Value[0];
- val3 = _cmsToFixedDomain(val3); // To fixed 15.16
-
- cell0 = FIXED_TO_INT(val3); // Cell is 16 MSB bits
- rest = FIXED_REST_TO_INT(val3); // Rest is 16 LSB bits
-
- y0 = LutTable[cell0];
- y1 = LutTable[cell0 + 1];
-
- Output[0] = LinearInterp(rest, y0, y1);
- }
-}
-
-// To prevent out of bounds indexing
-cmsINLINE cmsFloat32Number fclamp(cmsFloat32Number v)
-{
- return ((v < 1.0e-9f) || isnan(v)) ? 0.0f : (v > 1.0f ? 1.0f : v);
-}
-
-// Floating-point version of 1D interpolation
-static
-void LinLerp1Dfloat(const cmsFloat32Number Value[],
- cmsFloat32Number Output[],
- const cmsInterpParams* p)
-{
- cmsFloat32Number y1, y0;
- cmsFloat32Number val2, rest;
- int cell0, cell1;
- const cmsFloat32Number* LutTable = (cmsFloat32Number*) p ->Table;
-
- val2 = fclamp(Value[0]);
-
- // if last value...
- if (val2 == 1.0 || p->Domain[0] == 0) {
- Output[0] = LutTable[p -> Domain[0]];
- }
- else
- {
- val2 *= p->Domain[0];
-
- cell0 = (int)floor(val2);
- cell1 = (int)ceil(val2);
-
- // Rest is 16 LSB bits
- rest = val2 - cell0;
-
- y0 = LutTable[cell0];
- y1 = LutTable[cell1];
-
- Output[0] = y0 + (y1 - y0) * rest;
- }
-}
-
-
-
-// Eval gray LUT having only one input channel
-static CMS_NO_SANITIZE
-void Eval1Input(CMSREGISTER const cmsUInt16Number Input[],
- CMSREGISTER cmsUInt16Number Output[],
- CMSREGISTER const cmsInterpParams* p16)
-{
- cmsS15Fixed16Number fk;
- cmsS15Fixed16Number k0, k1, rk, K0, K1;
- int v;
- cmsUInt32Number OutChan;
- const cmsUInt16Number* LutTable = (cmsUInt16Number*) p16 -> Table;
-
-
- // if last value...
- if (Input[0] == 0xffff || p16->Domain[0] == 0) {
-
- cmsUInt32Number y0 = p16->Domain[0] * p16->opta[0];
-
- for (OutChan = 0; OutChan < p16->nOutputs; OutChan++) {
- Output[OutChan] = LutTable[y0 + OutChan];
- }
- }
- else
- {
-
- v = Input[0] * p16->Domain[0];
- fk = _cmsToFixedDomain(v);
-
- k0 = FIXED_TO_INT(fk);
- rk = (cmsUInt16Number)FIXED_REST_TO_INT(fk);
-
- k1 = k0 + (Input[0] != 0xFFFFU ? 1 : 0);
-
- K0 = p16->opta[0] * k0;
- K1 = p16->opta[0] * k1;
-
- for (OutChan = 0; OutChan < p16->nOutputs; OutChan++) {
-
- Output[OutChan] = LinearInterp(rk, LutTable[K0 + OutChan], LutTable[K1 + OutChan]);
- }
- }
-}
-
-
-
-// Eval gray LUT having only one input channel
-static
-void Eval1InputFloat(const cmsFloat32Number Value[],
- cmsFloat32Number Output[],
- const cmsInterpParams* p)
-{
- cmsFloat32Number y1, y0;
- cmsFloat32Number val2, rest;
- int cell0, cell1;
- cmsUInt32Number OutChan;
- const cmsFloat32Number* LutTable = (cmsFloat32Number*) p ->Table;
-
- val2 = fclamp(Value[0]);
-
- // if last value...
- if (val2 == 1.0 || p->Domain[0] == 0) {
-
- cmsUInt32Number start = p->Domain[0] * p->opta[0];
-
- for (OutChan = 0; OutChan < p->nOutputs; OutChan++) {
- Output[OutChan] = LutTable[start + OutChan];
- }
- }
- else
- {
- val2 *= p->Domain[0];
-
- cell0 = (int)floor(val2);
- cell1 = (int)ceil(val2);
-
- // Rest is 16 LSB bits
- rest = val2 - cell0;
-
- cell0 *= p->opta[0];
- cell1 *= p->opta[0];
-
- for (OutChan = 0; OutChan < p->nOutputs; OutChan++) {
-
- y0 = LutTable[cell0 + OutChan];
- y1 = LutTable[cell1 + OutChan];
-
- Output[OutChan] = y0 + (y1 - y0) * rest;
- }
- }
-}
-
-// Bilinear interpolation (16 bits) - cmsFloat32Number version
-static
-void BilinearInterpFloat(const cmsFloat32Number Input[],
- cmsFloat32Number Output[],
- const cmsInterpParams* p)
-
-{
-# define LERP(a,l,h) (cmsFloat32Number) ((l)+(((h)-(l))*(a)))
-# define DENS(i,j) (LutTable[(i)+(j)+OutChan])
-
- const cmsFloat32Number* LutTable = (cmsFloat32Number*) p ->Table;
- cmsFloat32Number px, py;
- int x0, y0,
- X0, Y0, X1, Y1;
- int TotalOut, OutChan;
- cmsFloat32Number fx, fy,
- d00, d01, d10, d11,
- dx0, dx1,
- dxy;
-
- TotalOut = p -> nOutputs;
- px = fclamp(Input[0]) * p->Domain[0];
- py = fclamp(Input[1]) * p->Domain[1];
-
- x0 = (int) _cmsQuickFloor(px); fx = px - (cmsFloat32Number) x0;
- y0 = (int) _cmsQuickFloor(py); fy = py - (cmsFloat32Number) y0;
-
- X0 = p -> opta[1] * x0;
- X1 = X0 + (fclamp(Input[0]) >= 1.0 ? 0 : p->opta[1]);
-
- Y0 = p -> opta[0] * y0;
- Y1 = Y0 + (fclamp(Input[1]) >= 1.0 ? 0 : p->opta[0]);
-
- for (OutChan = 0; OutChan < TotalOut; OutChan++) {
-
- d00 = DENS(X0, Y0);
- d01 = DENS(X0, Y1);
- d10 = DENS(X1, Y0);
- d11 = DENS(X1, Y1);
-
- dx0 = LERP(fx, d00, d10);
- dx1 = LERP(fx, d01, d11);
-
- dxy = LERP(fy, dx0, dx1);
-
- Output[OutChan] = dxy;
- }
-
-
-# undef LERP
-# undef DENS
-}
-
-// Bilinear interpolation (16 bits) - optimized version
-static CMS_NO_SANITIZE
-void BilinearInterp16(CMSREGISTER const cmsUInt16Number Input[],
- CMSREGISTER cmsUInt16Number Output[],
- CMSREGISTER const cmsInterpParams* p)
-
-{
-#define DENS(i,j) (LutTable[(i)+(j)+OutChan])
-#define LERP(a,l,h) (cmsUInt16Number) (l + ROUND_FIXED_TO_INT(((h-l)*a)))
-
- const cmsUInt16Number* LutTable = (cmsUInt16Number*) p ->Table;
- int OutChan, TotalOut;
- cmsS15Fixed16Number fx, fy;
- CMSREGISTER int rx, ry;
- int x0, y0;
- CMSREGISTER int X0, X1, Y0, Y1;
-
- int d00, d01, d10, d11,
- dx0, dx1,
- dxy;
-
- TotalOut = p -> nOutputs;
-
- fx = _cmsToFixedDomain((int) Input[0] * p -> Domain[0]);
- x0 = FIXED_TO_INT(fx);
- rx = FIXED_REST_TO_INT(fx); // Rest in 0..1.0 domain
-
-
- fy = _cmsToFixedDomain((int) Input[1] * p -> Domain[1]);
- y0 = FIXED_TO_INT(fy);
- ry = FIXED_REST_TO_INT(fy);
-
-
- X0 = p -> opta[1] * x0;
- X1 = X0 + (Input[0] == 0xFFFFU ? 0 : p->opta[1]);
-
- Y0 = p -> opta[0] * y0;
- Y1 = Y0 + (Input[1] == 0xFFFFU ? 0 : p->opta[0]);
-
- for (OutChan = 0; OutChan < TotalOut; OutChan++) {
-
- d00 = DENS(X0, Y0);
- d01 = DENS(X0, Y1);
- d10 = DENS(X1, Y0);
- d11 = DENS(X1, Y1);
-
- dx0 = LERP(rx, d00, d10);
- dx1 = LERP(rx, d01, d11);
-
- dxy = LERP(ry, dx0, dx1);
-
- Output[OutChan] = (cmsUInt16Number) dxy;
- }
-
-
-# undef LERP
-# undef DENS
-}
-
-
-// Trilinear interpolation (16 bits) - cmsFloat32Number version
-static
-void TrilinearInterpFloat(const cmsFloat32Number Input[],
- cmsFloat32Number Output[],
- const cmsInterpParams* p)
-
-{
-# define LERP(a,l,h) (cmsFloat32Number) ((l)+(((h)-(l))*(a)))
-# define DENS(i,j,k) (LutTable[(i)+(j)+(k)+OutChan])
-
- const cmsFloat32Number* LutTable = (cmsFloat32Number*) p ->Table;
- cmsFloat32Number px, py, pz;
- int x0, y0, z0,
- X0, Y0, Z0, X1, Y1, Z1;
- int TotalOut, OutChan;
-
- cmsFloat32Number fx, fy, fz,
- d000, d001, d010, d011,
- d100, d101, d110, d111,
- dx00, dx01, dx10, dx11,
- dxy0, dxy1, dxyz;
-
- TotalOut = p -> nOutputs;
-
- // We need some clipping here
- px = fclamp(Input[0]) * p->Domain[0];
- py = fclamp(Input[1]) * p->Domain[1];
- pz = fclamp(Input[2]) * p->Domain[2];
-
- x0 = (int) floor(px); fx = px - (cmsFloat32Number) x0; // We need full floor funcionality here
- y0 = (int) floor(py); fy = py - (cmsFloat32Number) y0;
- z0 = (int) floor(pz); fz = pz - (cmsFloat32Number) z0;
-
- X0 = p -> opta[2] * x0;
- X1 = X0 + (fclamp(Input[0]) >= 1.0 ? 0 : p->opta[2]);
-
- Y0 = p -> opta[1] * y0;
- Y1 = Y0 + (fclamp(Input[1]) >= 1.0 ? 0 : p->opta[1]);
-
- Z0 = p -> opta[0] * z0;
- Z1 = Z0 + (fclamp(Input[2]) >= 1.0 ? 0 : p->opta[0]);
-
- for (OutChan = 0; OutChan < TotalOut; OutChan++) {
-
- d000 = DENS(X0, Y0, Z0);
- d001 = DENS(X0, Y0, Z1);
- d010 = DENS(X0, Y1, Z0);
- d011 = DENS(X0, Y1, Z1);
-
- d100 = DENS(X1, Y0, Z0);
- d101 = DENS(X1, Y0, Z1);
- d110 = DENS(X1, Y1, Z0);
- d111 = DENS(X1, Y1, Z1);
-
-
- dx00 = LERP(fx, d000, d100);
- dx01 = LERP(fx, d001, d101);
- dx10 = LERP(fx, d010, d110);
- dx11 = LERP(fx, d011, d111);
-
- dxy0 = LERP(fy, dx00, dx10);
- dxy1 = LERP(fy, dx01, dx11);
-
- dxyz = LERP(fz, dxy0, dxy1);
-
- Output[OutChan] = dxyz;
- }
-
-
-# undef LERP
-# undef DENS
-}
-
-// Trilinear interpolation (16 bits) - optimized version
-static CMS_NO_SANITIZE
-void TrilinearInterp16(CMSREGISTER const cmsUInt16Number Input[],
- CMSREGISTER cmsUInt16Number Output[],
- CMSREGISTER const cmsInterpParams* p)
-
-{
-#define DENS(i,j,k) (LutTable[(i)+(j)+(k)+OutChan])
-#define LERP(a,l,h) (cmsUInt16Number) (l + ROUND_FIXED_TO_INT(((h-l)*a)))
-
- const cmsUInt16Number* LutTable = (cmsUInt16Number*) p ->Table;
- int OutChan, TotalOut;
- cmsS15Fixed16Number fx, fy, fz;
- CMSREGISTER int rx, ry, rz;
- int x0, y0, z0;
- CMSREGISTER int X0, X1, Y0, Y1, Z0, Z1;
- int d000, d001, d010, d011,
- d100, d101, d110, d111,
- dx00, dx01, dx10, dx11,
- dxy0, dxy1, dxyz;
-
- TotalOut = p -> nOutputs;
-
- fx = _cmsToFixedDomain((int) Input[0] * p -> Domain[0]);
- x0 = FIXED_TO_INT(fx);
- rx = FIXED_REST_TO_INT(fx); // Rest in 0..1.0 domain
-
-
- fy = _cmsToFixedDomain((int) Input[1] * p -> Domain[1]);
- y0 = FIXED_TO_INT(fy);
- ry = FIXED_REST_TO_INT(fy);
-
- fz = _cmsToFixedDomain((int) Input[2] * p -> Domain[2]);
- z0 = FIXED_TO_INT(fz);
- rz = FIXED_REST_TO_INT(fz);
-
-
- X0 = p -> opta[2] * x0;
- X1 = X0 + (Input[0] == 0xFFFFU ? 0 : p->opta[2]);
-
- Y0 = p -> opta[1] * y0;
- Y1 = Y0 + (Input[1] == 0xFFFFU ? 0 : p->opta[1]);
-
- Z0 = p -> opta[0] * z0;
- Z1 = Z0 + (Input[2] == 0xFFFFU ? 0 : p->opta[0]);
-
- for (OutChan = 0; OutChan < TotalOut; OutChan++) {
-
- d000 = DENS(X0, Y0, Z0);
- d001 = DENS(X0, Y0, Z1);
- d010 = DENS(X0, Y1, Z0);
- d011 = DENS(X0, Y1, Z1);
-
- d100 = DENS(X1, Y0, Z0);
- d101 = DENS(X1, Y0, Z1);
- d110 = DENS(X1, Y1, Z0);
- d111 = DENS(X1, Y1, Z1);
-
-
- dx00 = LERP(rx, d000, d100);
- dx01 = LERP(rx, d001, d101);
- dx10 = LERP(rx, d010, d110);
- dx11 = LERP(rx, d011, d111);
-
- dxy0 = LERP(ry, dx00, dx10);
- dxy1 = LERP(ry, dx01, dx11);
-
- dxyz = LERP(rz, dxy0, dxy1);
-
- Output[OutChan] = (cmsUInt16Number) dxyz;
- }
-
-
-# undef LERP
-# undef DENS
-}
-
-
-// Tetrahedral interpolation, using Sakamoto algorithm.
-#define DENS(i,j,k) (LutTable[(i)+(j)+(k)+OutChan])
-static
-void TetrahedralInterpFloat(const cmsFloat32Number Input[],
- cmsFloat32Number Output[],
- const cmsInterpParams* p)
-{
- const cmsFloat32Number* LutTable = (cmsFloat32Number*) p -> Table;
- cmsFloat32Number px, py, pz;
- int x0, y0, z0,
- X0, Y0, Z0, X1, Y1, Z1;
- cmsFloat32Number rx, ry, rz;
- cmsFloat32Number c0, c1=0, c2=0, c3=0;
- int OutChan, TotalOut;
-
- TotalOut = p -> nOutputs;
-
- // We need some clipping here
- px = fclamp(Input[0]) * p->Domain[0];
- py = fclamp(Input[1]) * p->Domain[1];
- pz = fclamp(Input[2]) * p->Domain[2];
-
- x0 = (int) floor(px); rx = (px - (cmsFloat32Number) x0); // We need full floor functionality here
- y0 = (int) floor(py); ry = (py - (cmsFloat32Number) y0);
- z0 = (int) floor(pz); rz = (pz - (cmsFloat32Number) z0);
-
-
- X0 = p -> opta[2] * x0;
- X1 = X0 + (fclamp(Input[0]) >= 1.0 ? 0 : p->opta[2]);
-
- Y0 = p -> opta[1] * y0;
- Y1 = Y0 + (fclamp(Input[1]) >= 1.0 ? 0 : p->opta[1]);
-
- Z0 = p -> opta[0] * z0;
- Z1 = Z0 + (fclamp(Input[2]) >= 1.0 ? 0 : p->opta[0]);
-
- for (OutChan=0; OutChan < TotalOut; OutChan++) {
-
- // These are the 6 Tetrahedral
-
- c0 = DENS(X0, Y0, Z0);
-
- if (rx >= ry && ry >= rz) {
-
- c1 = DENS(X1, Y0, Z0) - c0;
- c2 = DENS(X1, Y1, Z0) - DENS(X1, Y0, Z0);
- c3 = DENS(X1, Y1, Z1) - DENS(X1, Y1, Z0);
-
- }
- else
- if (rx >= rz && rz >= ry) {
-
- c1 = DENS(X1, Y0, Z0) - c0;
- c2 = DENS(X1, Y1, Z1) - DENS(X1, Y0, Z1);
- c3 = DENS(X1, Y0, Z1) - DENS(X1, Y0, Z0);
-
- }
- else
- if (rz >= rx && rx >= ry) {
-
- c1 = DENS(X1, Y0, Z1) - DENS(X0, Y0, Z1);
- c2 = DENS(X1, Y1, Z1) - DENS(X1, Y0, Z1);
- c3 = DENS(X0, Y0, Z1) - c0;
-
- }
- else
- if (ry >= rx && rx >= rz) {
-
- c1 = DENS(X1, Y1, Z0) - DENS(X0, Y1, Z0);
- c2 = DENS(X0, Y1, Z0) - c0;
- c3 = DENS(X1, Y1, Z1) - DENS(X1, Y1, Z0);
-
- }
- else
- if (ry >= rz && rz >= rx) {
-
- c1 = DENS(X1, Y1, Z1) - DENS(X0, Y1, Z1);
- c2 = DENS(X0, Y1, Z0) - c0;
- c3 = DENS(X0, Y1, Z1) - DENS(X0, Y1, Z0);
-
- }
- else
- if (rz >= ry && ry >= rx) {
-
- c1 = DENS(X1, Y1, Z1) - DENS(X0, Y1, Z1);
- c2 = DENS(X0, Y1, Z1) - DENS(X0, Y0, Z1);
- c3 = DENS(X0, Y0, Z1) - c0;
-
- }
- else {
- c1 = c2 = c3 = 0;
- }
-
- Output[OutChan] = c0 + c1 * rx + c2 * ry + c3 * rz;
- }
-
-}
-
-#undef DENS
-
-static CMS_NO_SANITIZE
-void TetrahedralInterp16(CMSREGISTER const cmsUInt16Number Input[],
- CMSREGISTER cmsUInt16Number Output[],
- CMSREGISTER const cmsInterpParams* p)
-{
- const cmsUInt16Number* LutTable = (cmsUInt16Number*) p -> Table;
- cmsS15Fixed16Number fx, fy, fz;
- cmsS15Fixed16Number rx, ry, rz;
- int x0, y0, z0;
- cmsS15Fixed16Number c0, c1, c2, c3, Rest;
- cmsUInt32Number X0, X1, Y0, Y1, Z0, Z1;
- cmsUInt32Number TotalOut = p -> nOutputs;
-
- fx = _cmsToFixedDomain((int) Input[0] * p -> Domain[0]);
- fy = _cmsToFixedDomain((int) Input[1] * p -> Domain[1]);
- fz = _cmsToFixedDomain((int) Input[2] * p -> Domain[2]);
-
- x0 = FIXED_TO_INT(fx);
- y0 = FIXED_TO_INT(fy);
- z0 = FIXED_TO_INT(fz);
-
- rx = FIXED_REST_TO_INT(fx);
- ry = FIXED_REST_TO_INT(fy);
- rz = FIXED_REST_TO_INT(fz);
-
- X0 = p -> opta[2] * x0;
- X1 = (Input[0] == 0xFFFFU ? 0 : p->opta[2]);
-
- Y0 = p -> opta[1] * y0;
- Y1 = (Input[1] == 0xFFFFU ? 0 : p->opta[1]);
-
- Z0 = p -> opta[0] * z0;
- Z1 = (Input[2] == 0xFFFFU ? 0 : p->opta[0]);
-
- LutTable += X0+Y0+Z0;
-
- // Output should be computed as x = ROUND_FIXED_TO_INT(_cmsToFixedDomain(Rest))
- // which expands as: x = (Rest + ((Rest+0x7fff)/0xFFFF) + 0x8000)>>16
- // This can be replaced by: t = Rest+0x8001, x = (t + (t>>16))>>16
- // at the cost of being off by one at 7fff and 17ffe.
-
- if (rx >= ry) {
- if (ry >= rz) {
- Y1 += X1;
- Z1 += Y1;
- for (; TotalOut; TotalOut--) {
- c1 = LutTable[X1];
- c2 = LutTable[Y1];
- c3 = LutTable[Z1];
- c0 = *LutTable++;
- c3 -= c2;
- c2 -= c1;
- c1 -= c0;
- Rest = c1 * rx + c2 * ry + c3 * rz + 0x8001;
- *Output++ = (cmsUInt16Number) c0 + ((Rest + (Rest>>16))>>16);
- }
- } else if (rz >= rx) {
- X1 += Z1;
- Y1 += X1;
- for (; TotalOut; TotalOut--) {
- c1 = LutTable[X1];
- c2 = LutTable[Y1];
- c3 = LutTable[Z1];
- c0 = *LutTable++;
- c2 -= c1;
- c1 -= c3;
- c3 -= c0;
- Rest = c1 * rx + c2 * ry + c3 * rz + 0x8001;
- *Output++ = (cmsUInt16Number) c0 + ((Rest + (Rest>>16))>>16);
- }
- } else {
- Z1 += X1;
- Y1 += Z1;
- for (; TotalOut; TotalOut--) {
- c1 = LutTable[X1];
- c2 = LutTable[Y1];
- c3 = LutTable[Z1];
- c0 = *LutTable++;
- c2 -= c3;
- c3 -= c1;
- c1 -= c0;
- Rest = c1 * rx + c2 * ry + c3 * rz + 0x8001;
- *Output++ = (cmsUInt16Number) c0 + ((Rest + (Rest>>16))>>16);
- }
- }
- } else {
- if (rx >= rz) {
- X1 += Y1;
- Z1 += X1;
- for (; TotalOut; TotalOut--) {
- c1 = LutTable[X1];
- c2 = LutTable[Y1];
- c3 = LutTable[Z1];
- c0 = *LutTable++;
- c3 -= c1;
- c1 -= c2;
- c2 -= c0;
- Rest = c1 * rx + c2 * ry + c3 * rz + 0x8001;
- *Output++ = (cmsUInt16Number) c0 + ((Rest + (Rest>>16))>>16);
- }
- } else if (ry >= rz) {
- Z1 += Y1;
- X1 += Z1;
- for (; TotalOut; TotalOut--) {
- c1 = LutTable[X1];
- c2 = LutTable[Y1];
- c3 = LutTable[Z1];
- c0 = *LutTable++;
- c1 -= c3;
- c3 -= c2;
- c2 -= c0;
- Rest = c1 * rx + c2 * ry + c3 * rz + 0x8001;
- *Output++ = (cmsUInt16Number) c0 + ((Rest + (Rest>>16))>>16);
- }
- } else {
- Y1 += Z1;
- X1 += Y1;
- for (; TotalOut; TotalOut--) {
- c1 = LutTable[X1];
- c2 = LutTable[Y1];
- c3 = LutTable[Z1];
- c0 = *LutTable++;
- c1 -= c2;
- c2 -= c3;
- c3 -= c0;
- Rest = c1 * rx + c2 * ry + c3 * rz + 0x8001;
- *Output++ = (cmsUInt16Number) c0 + ((Rest + (Rest>>16))>>16);
- }
- }
- }
-}
-
-
-#define DENS(i,j,k) (LutTable[(i)+(j)+(k)+OutChan])
-static CMS_NO_SANITIZE
-void Eval4Inputs(CMSREGISTER const cmsUInt16Number Input[],
- CMSREGISTER cmsUInt16Number Output[],
- CMSREGISTER const cmsInterpParams* p16)
-{
- const cmsUInt16Number* LutTable;
- cmsS15Fixed16Number fk;
- cmsS15Fixed16Number k0, rk;
- int K0, K1;
- cmsS15Fixed16Number fx, fy, fz;
- cmsS15Fixed16Number rx, ry, rz;
- int x0, y0, z0;
- cmsS15Fixed16Number X0, X1, Y0, Y1, Z0, Z1;
- cmsUInt32Number i;
- cmsS15Fixed16Number c0, c1, c2, c3, Rest;
- cmsUInt32Number OutChan;
- cmsUInt16Number Tmp1[MAX_STAGE_CHANNELS], Tmp2[MAX_STAGE_CHANNELS];
-
-
- fk = _cmsToFixedDomain((int) Input[0] * p16 -> Domain[0]);
- fx = _cmsToFixedDomain((int) Input[1] * p16 -> Domain[1]);
- fy = _cmsToFixedDomain((int) Input[2] * p16 -> Domain[2]);
- fz = _cmsToFixedDomain((int) Input[3] * p16 -> Domain[3]);
-
- k0 = FIXED_TO_INT(fk);
- x0 = FIXED_TO_INT(fx);
- y0 = FIXED_TO_INT(fy);
- z0 = FIXED_TO_INT(fz);
-
- rk = FIXED_REST_TO_INT(fk);
- rx = FIXED_REST_TO_INT(fx);
- ry = FIXED_REST_TO_INT(fy);
- rz = FIXED_REST_TO_INT(fz);
-
- K0 = p16 -> opta[3] * k0;
- K1 = K0 + (Input[0] == 0xFFFFU ? 0 : p16->opta[3]);
-
- X0 = p16 -> opta[2] * x0;
- X1 = X0 + (Input[1] == 0xFFFFU ? 0 : p16->opta[2]);
-
- Y0 = p16 -> opta[1] * y0;
- Y1 = Y0 + (Input[2] == 0xFFFFU ? 0 : p16->opta[1]);
-
- Z0 = p16 -> opta[0] * z0;
- Z1 = Z0 + (Input[3] == 0xFFFFU ? 0 : p16->opta[0]);
-
- LutTable = (cmsUInt16Number*) p16 -> Table;
- LutTable += K0;
-
- for (OutChan=0; OutChan < p16 -> nOutputs; OutChan++) {
-
- c0 = DENS(X0, Y0, Z0);
-
- if (rx >= ry && ry >= rz) {
-
- c1 = DENS(X1, Y0, Z0) - c0;
- c2 = DENS(X1, Y1, Z0) - DENS(X1, Y0, Z0);
- c3 = DENS(X1, Y1, Z1) - DENS(X1, Y1, Z0);
-
- }
- else
- if (rx >= rz && rz >= ry) {
-
- c1 = DENS(X1, Y0, Z0) - c0;
- c2 = DENS(X1, Y1, Z1) - DENS(X1, Y0, Z1);
- c3 = DENS(X1, Y0, Z1) - DENS(X1, Y0, Z0);
-
- }
- else
- if (rz >= rx && rx >= ry) {
-
- c1 = DENS(X1, Y0, Z1) - DENS(X0, Y0, Z1);
- c2 = DENS(X1, Y1, Z1) - DENS(X1, Y0, Z1);
- c3 = DENS(X0, Y0, Z1) - c0;
-
- }
- else
- if (ry >= rx && rx >= rz) {
-
- c1 = DENS(X1, Y1, Z0) - DENS(X0, Y1, Z0);
- c2 = DENS(X0, Y1, Z0) - c0;
- c3 = DENS(X1, Y1, Z1) - DENS(X1, Y1, Z0);
-
- }
- else
- if (ry >= rz && rz >= rx) {
-
- c1 = DENS(X1, Y1, Z1) - DENS(X0, Y1, Z1);
- c2 = DENS(X0, Y1, Z0) - c0;
- c3 = DENS(X0, Y1, Z1) - DENS(X0, Y1, Z0);
-
- }
- else
- if (rz >= ry && ry >= rx) {
-
- c1 = DENS(X1, Y1, Z1) - DENS(X0, Y1, Z1);
- c2 = DENS(X0, Y1, Z1) - DENS(X0, Y0, Z1);
- c3 = DENS(X0, Y0, Z1) - c0;
-
- }
- else {
- c1 = c2 = c3 = 0;
- }
-
- Rest = c1 * rx + c2 * ry + c3 * rz;
-
- Tmp1[OutChan] = (cmsUInt16Number)(c0 + ROUND_FIXED_TO_INT(_cmsToFixedDomain(Rest)));
- }
-
-
- LutTable = (cmsUInt16Number*) p16 -> Table;
- LutTable += K1;
-
- for (OutChan=0; OutChan < p16 -> nOutputs; OutChan++) {
-
- c0 = DENS(X0, Y0, Z0);
-
- if (rx >= ry && ry >= rz) {
-
- c1 = DENS(X1, Y0, Z0) - c0;
- c2 = DENS(X1, Y1, Z0) - DENS(X1, Y0, Z0);
- c3 = DENS(X1, Y1, Z1) - DENS(X1, Y1, Z0);
-
- }
- else
- if (rx >= rz && rz >= ry) {
-
- c1 = DENS(X1, Y0, Z0) - c0;
- c2 = DENS(X1, Y1, Z1) - DENS(X1, Y0, Z1);
- c3 = DENS(X1, Y0, Z1) - DENS(X1, Y0, Z0);
-
- }
- else
- if (rz >= rx && rx >= ry) {
-
- c1 = DENS(X1, Y0, Z1) - DENS(X0, Y0, Z1);
- c2 = DENS(X1, Y1, Z1) - DENS(X1, Y0, Z1);
- c3 = DENS(X0, Y0, Z1) - c0;
-
- }
- else
- if (ry >= rx && rx >= rz) {
-
- c1 = DENS(X1, Y1, Z0) - DENS(X0, Y1, Z0);
- c2 = DENS(X0, Y1, Z0) - c0;
- c3 = DENS(X1, Y1, Z1) - DENS(X1, Y1, Z0);
-
- }
- else
- if (ry >= rz && rz >= rx) {
-
- c1 = DENS(X1, Y1, Z1) - DENS(X0, Y1, Z1);
- c2 = DENS(X0, Y1, Z0) - c0;
- c3 = DENS(X0, Y1, Z1) - DENS(X0, Y1, Z0);
-
- }
- else
- if (rz >= ry && ry >= rx) {
-
- c1 = DENS(X1, Y1, Z1) - DENS(X0, Y1, Z1);
- c2 = DENS(X0, Y1, Z1) - DENS(X0, Y0, Z1);
- c3 = DENS(X0, Y0, Z1) - c0;
-
- }
- else {
- c1 = c2 = c3 = 0;
- }
-
- Rest = c1 * rx + c2 * ry + c3 * rz;
-
- Tmp2[OutChan] = (cmsUInt16Number) (c0 + ROUND_FIXED_TO_INT(_cmsToFixedDomain(Rest)));
- }
-
-
-
- for (i=0; i < p16 -> nOutputs; i++) {
- Output[i] = LinearInterp(rk, Tmp1[i], Tmp2[i]);
- }
-}
-#undef DENS
-
-
-// For more that 3 inputs (i.e., CMYK)
-// evaluate two 3-dimensional interpolations and then linearly interpolate between them.
-static
-void Eval4InputsFloat(const cmsFloat32Number Input[],
- cmsFloat32Number Output[],
- const cmsInterpParams* p)
-{
- const cmsFloat32Number* LutTable = (cmsFloat32Number*) p -> Table;
- cmsFloat32Number rest;
- cmsFloat32Number pk;
- int k0, K0, K1;
- const cmsFloat32Number* T;
- cmsUInt32Number i;
- cmsFloat32Number Tmp1[MAX_STAGE_CHANNELS], Tmp2[MAX_STAGE_CHANNELS];
- cmsInterpParams p1;
-
- pk = fclamp(Input[0]) * p->Domain[0];
- k0 = _cmsQuickFloor(pk);
- rest = pk - (cmsFloat32Number) k0;
-
- K0 = p -> opta[3] * k0;
- K1 = K0 + (fclamp(Input[0]) >= 1.0 ? 0 : p->opta[3]);
-
- p1 = *p;
- memmove(&p1.Domain[0], &p ->Domain[1], 3*sizeof(cmsUInt32Number));
-
- T = LutTable + K0;
- p1.Table = T;
-
- TetrahedralInterpFloat(Input + 1, Tmp1, &p1);
-
- T = LutTable + K1;
- p1.Table = T;
- TetrahedralInterpFloat(Input + 1, Tmp2, &p1);
-
- for (i=0; i < p -> nOutputs; i++)
- {
- cmsFloat32Number y0 = Tmp1[i];
- cmsFloat32Number y1 = Tmp2[i];
-
- Output[i] = y0 + (y1 - y0) * rest;
- }
-}
-
-#define EVAL_FNS(N,NM) static CMS_NO_SANITIZE \
-void Eval##N##Inputs(CMSREGISTER const cmsUInt16Number Input[], CMSREGISTER cmsUInt16Number Output[], CMSREGISTER const cmsInterpParams* p16)\
-{\
- const cmsUInt16Number* LutTable = (cmsUInt16Number*) p16 -> Table;\
- cmsS15Fixed16Number fk;\
- cmsS15Fixed16Number k0, rk;\
- int K0, K1;\
- const cmsUInt16Number* T;\
- cmsUInt32Number i;\
- cmsUInt16Number Tmp1[MAX_STAGE_CHANNELS], Tmp2[MAX_STAGE_CHANNELS];\
- cmsInterpParams p1;\
-\
- fk = _cmsToFixedDomain((cmsS15Fixed16Number) Input[0] * p16 -> Domain[0]);\
- k0 = FIXED_TO_INT(fk);\
- rk = FIXED_REST_TO_INT(fk);\
-\
- K0 = p16 -> opta[NM] * k0;\
- K1 = p16 -> opta[NM] * (k0 + (Input[0] != 0xFFFFU ? 1 : 0));\
-\
- p1 = *p16;\
- memmove(&p1.Domain[0], &p16 ->Domain[1], NM*sizeof(cmsUInt32Number));\
-\
- T = LutTable + K0;\
- p1.Table = T;\
-\
- Eval##NM##Inputs(Input + 1, Tmp1, &p1);\
-\
- T = LutTable + K1;\
- p1.Table = T;\
-\
- Eval##NM##Inputs(Input + 1, Tmp2, &p1);\
-\
- for (i=0; i < p16 -> nOutputs; i++) {\
-\
- Output[i] = LinearInterp(rk, Tmp1[i], Tmp2[i]);\
- }\
-}\
-\
-static void Eval##N##InputsFloat(const cmsFloat32Number Input[], \
- cmsFloat32Number Output[],\
- const cmsInterpParams * p)\
-{\
- const cmsFloat32Number* LutTable = (cmsFloat32Number*) p -> Table;\
- cmsFloat32Number rest;\
- cmsFloat32Number pk;\
- int k0, K0, K1;\
- const cmsFloat32Number* T;\
- cmsUInt32Number i;\
- cmsFloat32Number Tmp1[MAX_STAGE_CHANNELS], Tmp2[MAX_STAGE_CHANNELS];\
- cmsInterpParams p1;\
-\
- pk = fclamp(Input[0]) * p->Domain[0];\
- k0 = _cmsQuickFloor(pk);\
- rest = pk - (cmsFloat32Number) k0;\
-\
- K0 = p -> opta[NM] * k0;\
- K1 = K0 + (fclamp(Input[0]) >= 1.0 ? 0 : p->opta[NM]);\
-\
- p1 = *p;\
- memmove(&p1.Domain[0], &p ->Domain[1], NM*sizeof(cmsUInt32Number));\
-\
- T = LutTable + K0;\
- p1.Table = T;\
-\
- Eval##NM##InputsFloat(Input + 1, Tmp1, &p1);\
-\
- T = LutTable + K1;\
- p1.Table = T;\
-\
- Eval##NM##InputsFloat(Input + 1, Tmp2, &p1);\
-\
- for (i=0; i < p -> nOutputs; i++) {\
-\
- cmsFloat32Number y0 = Tmp1[i];\
- cmsFloat32Number y1 = Tmp2[i];\
-\
- Output[i] = y0 + (y1 - y0) * rest;\
- }\
-}
-
-
-/**
-* Thanks to Carles Llopis for the templating idea
-*/
-EVAL_FNS(5, 4)
-EVAL_FNS(6, 5)
-EVAL_FNS(7, 6)
-EVAL_FNS(8, 7)
-EVAL_FNS(9, 8)
-EVAL_FNS(10, 9)
-EVAL_FNS(11, 10)
-EVAL_FNS(12, 11)
-EVAL_FNS(13, 12)
-EVAL_FNS(14, 13)
-EVAL_FNS(15, 14)
-
-
-// The default factory
-static
-cmsInterpFunction DefaultInterpolatorsFactory(cmsUInt32Number nInputChannels, cmsUInt32Number nOutputChannels, cmsUInt32Number dwFlags)
-{
-
- cmsInterpFunction Interpolation;
- cmsBool IsFloat = (dwFlags & CMS_LERP_FLAGS_FLOAT);
- cmsBool IsTrilinear = (dwFlags & CMS_LERP_FLAGS_TRILINEAR);
-
- memset(&Interpolation, 0, sizeof(Interpolation));
-
- // Safety check
- if (nInputChannels >= 4 && nOutputChannels >= MAX_STAGE_CHANNELS)
- return Interpolation;
-
- switch (nInputChannels) {
-
- case 1: // Gray LUT / linear
-
- if (nOutputChannels == 1) {
-
- if (IsFloat)
- Interpolation.LerpFloat = LinLerp1Dfloat;
- else
- Interpolation.Lerp16 = LinLerp1D;
-
- }
- else {
-
- if (IsFloat)
- Interpolation.LerpFloat = Eval1InputFloat;
- else
- Interpolation.Lerp16 = Eval1Input;
- }
- break;
-
- case 2: // Duotone
- if (IsFloat)
- Interpolation.LerpFloat = BilinearInterpFloat;
- else
- Interpolation.Lerp16 = BilinearInterp16;
- break;
-
- case 3: // RGB et al
-
- if (IsTrilinear) {
-
- if (IsFloat)
- Interpolation.LerpFloat = TrilinearInterpFloat;
- else
- Interpolation.Lerp16 = TrilinearInterp16;
- }
- else {
-
- if (IsFloat)
- Interpolation.LerpFloat = TetrahedralInterpFloat;
- else {
-
- Interpolation.Lerp16 = TetrahedralInterp16;
- }
- }
- break;
-
- case 4: // CMYK lut
-
- if (IsFloat)
- Interpolation.LerpFloat = Eval4InputsFloat;
- else
- Interpolation.Lerp16 = Eval4Inputs;
- break;
-
- case 5: // 5 Inks
- if (IsFloat)
- Interpolation.LerpFloat = Eval5InputsFloat;
- else
- Interpolation.Lerp16 = Eval5Inputs;
- break;
-
- case 6: // 6 Inks
- if (IsFloat)
- Interpolation.LerpFloat = Eval6InputsFloat;
- else
- Interpolation.Lerp16 = Eval6Inputs;
- break;
-
- case 7: // 7 inks
- if (IsFloat)
- Interpolation.LerpFloat = Eval7InputsFloat;
- else
- Interpolation.Lerp16 = Eval7Inputs;
- break;
-
- case 8: // 8 inks
- if (IsFloat)
- Interpolation.LerpFloat = Eval8InputsFloat;
- else
- Interpolation.Lerp16 = Eval8Inputs;
- break;
-
- case 9:
- if (IsFloat)
- Interpolation.LerpFloat = Eval9InputsFloat;
- else
- Interpolation.Lerp16 = Eval9Inputs;
- break;
-
- case 10:
- if (IsFloat)
- Interpolation.LerpFloat = Eval10InputsFloat;
- else
- Interpolation.Lerp16 = Eval10Inputs;
- break;
-
- case 11:
- if (IsFloat)
- Interpolation.LerpFloat = Eval11InputsFloat;
- else
- Interpolation.Lerp16 = Eval11Inputs;
- break;
-
- case 12:
- if (IsFloat)
- Interpolation.LerpFloat = Eval12InputsFloat;
- else
- Interpolation.Lerp16 = Eval12Inputs;
- break;
-
- case 13:
- if (IsFloat)
- Interpolation.LerpFloat = Eval13InputsFloat;
- else
- Interpolation.Lerp16 = Eval13Inputs;
- break;
-
- case 14:
- if (IsFloat)
- Interpolation.LerpFloat = Eval14InputsFloat;
- else
- Interpolation.Lerp16 = Eval14Inputs;
- break;
-
- case 15:
- if (IsFloat)
- Interpolation.LerpFloat = Eval15InputsFloat;
- else
- Interpolation.Lerp16 = Eval15Inputs;
- break;
-
- default:
- Interpolation.Lerp16 = NULL;
- }
-
- return Interpolation;
-}
diff --git a/contrib/libs/lcms2/src/cmsio0.c b/contrib/libs/lcms2/src/cmsio0.c
deleted file mode 100644
index 75442e664d..0000000000
--- a/contrib/libs/lcms2/src/cmsio0.c
+++ /dev/null
@@ -1,2097 +0,0 @@
-//---------------------------------------------------------------------------------
-//
-// Little Color Management System
-// Copyright (c) 1998-2023 Marti Maria Saguer
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//---------------------------------------------------------------------------------
-//
-
-#include "lcms2_internal.h"
-
-// Generic I/O, tag dictionary management, profile struct
-
-// IOhandlers are abstractions used by littleCMS to read from whatever file, stream,
-// memory block or any storage. Each IOhandler provides implementations for read,
-// write, seek and tell functions. LittleCMS code deals with IO across those objects.
-// In this way, is easier to add support for new storage media.
-
-// NULL stream, for taking care of used space -------------------------------------
-
-// NULL IOhandler basically does nothing but keep track on how many bytes have been
-// written. This is handy when creating profiles, where the file size is needed in the
-// header. Then, whole profile is serialized across NULL IOhandler and a second pass
-// writes the bytes to the pertinent IOhandler.
-
-typedef struct {
- cmsUInt32Number Pointer; // Points to current location
-} FILENULL;
-
-static
-cmsUInt32Number NULLRead(cmsIOHANDLER* iohandler, void *Buffer, cmsUInt32Number size, cmsUInt32Number count)
-{
- FILENULL* ResData = (FILENULL*) iohandler ->stream;
-
- cmsUInt32Number len = size * count;
- ResData -> Pointer += len;
- return count;
-
- cmsUNUSED_PARAMETER(Buffer);
-}
-
-static
-cmsBool NULLSeek(cmsIOHANDLER* iohandler, cmsUInt32Number offset)
-{
- FILENULL* ResData = (FILENULL*) iohandler ->stream;
-
- ResData ->Pointer = offset;
- return TRUE;
-}
-
-static
-cmsUInt32Number NULLTell(cmsIOHANDLER* iohandler)
-{
- FILENULL* ResData = (FILENULL*) iohandler ->stream;
- return ResData -> Pointer;
-}
-
-static
-cmsBool NULLWrite(cmsIOHANDLER* iohandler, cmsUInt32Number size, const void *Ptr)
-{
- FILENULL* ResData = (FILENULL*) iohandler ->stream;
-
- ResData ->Pointer += size;
- if (ResData ->Pointer > iohandler->UsedSpace)
- iohandler->UsedSpace = ResData ->Pointer;
-
- return TRUE;
-
- cmsUNUSED_PARAMETER(Ptr);
-}
-
-static
-cmsBool NULLClose(cmsIOHANDLER* iohandler)
-{
- FILENULL* ResData = (FILENULL*) iohandler ->stream;
-
- _cmsFree(iohandler ->ContextID, ResData);
- _cmsFree(iohandler ->ContextID, iohandler);
- return TRUE;
-}
-
-// The NULL IOhandler creator
-cmsIOHANDLER* CMSEXPORT cmsOpenIOhandlerFromNULL(cmsContext ContextID)
-{
- struct _cms_io_handler* iohandler = NULL;
- FILENULL* fm = NULL;
-
- iohandler = (struct _cms_io_handler*) _cmsMallocZero(ContextID, sizeof(struct _cms_io_handler));
- if (iohandler == NULL) return NULL;
-
- fm = (FILENULL*) _cmsMallocZero(ContextID, sizeof(FILENULL));
- if (fm == NULL) goto Error;
-
- fm ->Pointer = 0;
-
- iohandler ->ContextID = ContextID;
- iohandler ->stream = (void*) fm;
- iohandler ->UsedSpace = 0;
- iohandler ->ReportedSize = 0;
- iohandler ->PhysicalFile[0] = 0;
-
- iohandler ->Read = NULLRead;
- iohandler ->Seek = NULLSeek;
- iohandler ->Close = NULLClose;
- iohandler ->Tell = NULLTell;
- iohandler ->Write = NULLWrite;
-
- return iohandler;
-
-Error:
- if (iohandler) _cmsFree(ContextID, iohandler);
- return NULL;
-
-}
-
-
-// Memory-based stream --------------------------------------------------------------
-
-// Those functions implements an iohandler which takes a block of memory as storage medium.
-
-typedef struct {
- cmsUInt8Number* Block; // Points to allocated memory
- cmsUInt32Number Size; // Size of allocated memory
- cmsUInt32Number Pointer; // Points to current location
- int FreeBlockOnClose; // As title
-
-} FILEMEM;
-
-static
-cmsUInt32Number MemoryRead(struct _cms_io_handler* iohandler, void *Buffer, cmsUInt32Number size, cmsUInt32Number count)
-{
- FILEMEM* ResData = (FILEMEM*) iohandler ->stream;
- cmsUInt8Number* Ptr;
- cmsUInt32Number len = size * count;
-
- if (ResData -> Pointer + len > ResData -> Size){
-
- len = (ResData -> Size - ResData -> Pointer);
- cmsSignalError(iohandler ->ContextID, cmsERROR_READ, "Read from memory error. Got %d bytes, block should be of %d bytes", len, count * size);
- return 0;
- }
-
- Ptr = ResData -> Block;
- Ptr += ResData -> Pointer;
- memmove(Buffer, Ptr, len);
- ResData -> Pointer += len;
-
- return count;
-}
-
-// SEEK_CUR is assumed
-static
-cmsBool MemorySeek(struct _cms_io_handler* iohandler, cmsUInt32Number offset)
-{
- FILEMEM* ResData = (FILEMEM*) iohandler ->stream;
-
- if (offset > ResData ->Size) {
- cmsSignalError(iohandler ->ContextID, cmsERROR_SEEK, "Too few data; probably corrupted profile");
- return FALSE;
- }
-
- ResData ->Pointer = offset;
- return TRUE;
-}
-
-// Tell for memory
-static
-cmsUInt32Number MemoryTell(struct _cms_io_handler* iohandler)
-{
- FILEMEM* ResData = (FILEMEM*) iohandler ->stream;
-
- if (ResData == NULL) return 0;
- return ResData -> Pointer;
-}
-
-
-// Writes data to memory, also keeps used space for further reference.
-static
-cmsBool MemoryWrite(struct _cms_io_handler* iohandler, cmsUInt32Number size, const void *Ptr)
-{
- FILEMEM* ResData = (FILEMEM*) iohandler ->stream;
-
- if (ResData == NULL) return FALSE; // Housekeeping
-
- // Check for available space. Clip.
- if (ResData->Pointer + size > ResData->Size) {
- size = ResData ->Size - ResData->Pointer;
- }
-
- if (size == 0) return TRUE; // Write zero bytes is ok, but does nothing
-
- memmove(ResData ->Block + ResData ->Pointer, Ptr, size);
- ResData ->Pointer += size;
-
- if (ResData ->Pointer > iohandler->UsedSpace)
- iohandler->UsedSpace = ResData ->Pointer;
-
- return TRUE;
-}
-
-
-static
-cmsBool MemoryClose(struct _cms_io_handler* iohandler)
-{
- FILEMEM* ResData = (FILEMEM*) iohandler ->stream;
-
- if (ResData ->FreeBlockOnClose) {
-
- if (ResData ->Block) _cmsFree(iohandler ->ContextID, ResData ->Block);
- }
-
- _cmsFree(iohandler ->ContextID, ResData);
- _cmsFree(iohandler ->ContextID, iohandler);
-
- return TRUE;
-}
-
-// Create a iohandler for memory block. AccessMode=='r' assumes the iohandler is going to read, and makes
-// a copy of the memory block for letting user to free the memory after invoking open profile. In write
-// mode ("w"), Buffer points to the begin of memory block to be written.
-cmsIOHANDLER* CMSEXPORT cmsOpenIOhandlerFromMem(cmsContext ContextID, void *Buffer, cmsUInt32Number size, const char* AccessMode)
-{
- cmsIOHANDLER* iohandler = NULL;
- FILEMEM* fm = NULL;
-
- _cmsAssert(AccessMode != NULL);
-
- iohandler = (cmsIOHANDLER*) _cmsMallocZero(ContextID, sizeof(cmsIOHANDLER));
- if (iohandler == NULL) return NULL;
-
- switch (*AccessMode) {
-
- case 'r':
- fm = (FILEMEM*) _cmsMallocZero(ContextID, sizeof(FILEMEM));
- if (fm == NULL) goto Error;
-
- if (Buffer == NULL) {
- cmsSignalError(ContextID, cmsERROR_READ, "Couldn't read profile from NULL pointer");
- goto Error;
- }
-
- fm ->Block = (cmsUInt8Number*) _cmsMalloc(ContextID, size);
- if (fm ->Block == NULL) {
-
- _cmsFree(ContextID, fm);
- _cmsFree(ContextID, iohandler);
- cmsSignalError(ContextID, cmsERROR_READ, "Couldn't allocate %ld bytes for profile", (long) size);
- return NULL;
- }
-
-
- memmove(fm->Block, Buffer, size);
- fm ->FreeBlockOnClose = TRUE;
- fm ->Size = size;
- fm ->Pointer = 0;
- iohandler -> ReportedSize = size;
- break;
-
- case 'w':
- fm = (FILEMEM*) _cmsMallocZero(ContextID, sizeof(FILEMEM));
- if (fm == NULL) goto Error;
-
- fm ->Block = (cmsUInt8Number*) Buffer;
- fm ->FreeBlockOnClose = FALSE;
- fm ->Size = size;
- fm ->Pointer = 0;
- iohandler -> ReportedSize = 0;
- break;
-
- default:
- cmsSignalError(ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unknown access mode '%c'", *AccessMode);
- return NULL;
- }
-
- iohandler ->ContextID = ContextID;
- iohandler ->stream = (void*) fm;
- iohandler ->UsedSpace = 0;
- iohandler ->PhysicalFile[0] = 0;
-
- iohandler ->Read = MemoryRead;
- iohandler ->Seek = MemorySeek;
- iohandler ->Close = MemoryClose;
- iohandler ->Tell = MemoryTell;
- iohandler ->Write = MemoryWrite;
-
- return iohandler;
-
-Error:
- if (fm) _cmsFree(ContextID, fm);
- if (iohandler) _cmsFree(ContextID, iohandler);
- return NULL;
-}
-
-// File-based stream -------------------------------------------------------
-
-// Read count elements of size bytes each. Return number of elements read
-static
-cmsUInt32Number FileRead(cmsIOHANDLER* iohandler, void *Buffer, cmsUInt32Number size, cmsUInt32Number count)
-{
- cmsUInt32Number nReaded = (cmsUInt32Number) fread(Buffer, size, count, (FILE*) iohandler->stream);
-
- if (nReaded != count) {
- cmsSignalError(iohandler ->ContextID, cmsERROR_FILE, "Read error. Got %d bytes, block should be of %d bytes", nReaded * size, count * size);
- return 0;
- }
-
- return nReaded;
-}
-
-// Position file pointer in the file
-static
-cmsBool FileSeek(cmsIOHANDLER* iohandler, cmsUInt32Number offset)
-{
- if (fseek((FILE*) iohandler ->stream, (long) offset, SEEK_SET) != 0) {
-
- cmsSignalError(iohandler ->ContextID, cmsERROR_FILE, "Seek error; probably corrupted file");
- return FALSE;
- }
-
- return TRUE;
-}
-
-// Returns file pointer position or 0 on error, which is also a valid position.
-static
-cmsUInt32Number FileTell(cmsIOHANDLER* iohandler)
-{
- long t = ftell((FILE*)iohandler ->stream);
- if (t == -1L) {
- cmsSignalError(iohandler->ContextID, cmsERROR_FILE, "Tell error; probably corrupted file");
- return 0;
- }
-
- return (cmsUInt32Number)t;
-}
-
-// Writes data to stream, also keeps used space for further reference. Returns TRUE on success, FALSE on error
-static
-cmsBool FileWrite(cmsIOHANDLER* iohandler, cmsUInt32Number size, const void* Buffer)
-{
- if (size == 0) return TRUE; // We allow to write 0 bytes, but nothing is written
-
- iohandler->UsedSpace += size;
- return (fwrite(Buffer, size, 1, (FILE*)iohandler->stream) == 1);
-}
-
-// Closes the file
-static
-cmsBool FileClose(cmsIOHANDLER* iohandler)
-{
- if (fclose((FILE*) iohandler ->stream) != 0) return FALSE;
- _cmsFree(iohandler ->ContextID, iohandler);
- return TRUE;
-}
-
-// Create a iohandler for disk based files.
-cmsIOHANDLER* CMSEXPORT cmsOpenIOhandlerFromFile(cmsContext ContextID, const char* FileName, const char* AccessMode)
-{
- cmsIOHANDLER* iohandler = NULL;
- FILE* fm = NULL;
- cmsInt32Number fileLen;
- char mode[4] = { 0,0,0,0 };
-
- _cmsAssert(FileName != NULL);
- _cmsAssert(AccessMode != NULL);
-
- iohandler = (cmsIOHANDLER*) _cmsMallocZero(ContextID, sizeof(cmsIOHANDLER));
- if (iohandler == NULL) return NULL;
-
- // Validate access mode
- while (*AccessMode) {
-
- switch (*AccessMode)
- {
- case 'r':
- case 'w':
-
- if (mode[0] == 0) {
- mode[0] = *AccessMode;
- mode[1] = 'b';
- }
- else {
- _cmsFree(ContextID, iohandler);
- cmsSignalError(ContextID, cmsERROR_FILE, "Access mode already specified '%c'", *AccessMode);
- return NULL;
- }
- break;
-
- // Close on exec. Not all runtime supports that. Up to the caller to decide.
- case 'e':
- mode[2] = 'e';
- break;
-
- default:
- _cmsFree(ContextID, iohandler);
- cmsSignalError(ContextID, cmsERROR_FILE, "Wrong access mode '%c'", *AccessMode);
- return NULL;
- }
-
- AccessMode++;
- }
-
- switch (mode[0]) {
-
- case 'r':
- fm = fopen(FileName, mode);
- if (fm == NULL) {
- _cmsFree(ContextID, iohandler);
- cmsSignalError(ContextID, cmsERROR_FILE, "File '%s' not found", FileName);
- return NULL;
- }
- fileLen = (cmsInt32Number)cmsfilelength(fm);
- if (fileLen < 0)
- {
- fclose(fm);
- _cmsFree(ContextID, iohandler);
- cmsSignalError(ContextID, cmsERROR_FILE, "Cannot get size of file '%s'", FileName);
- return NULL;
- }
- iohandler -> ReportedSize = (cmsUInt32Number) fileLen;
- break;
-
- case 'w':
- fm = fopen(FileName, mode);
- if (fm == NULL) {
- _cmsFree(ContextID, iohandler);
- cmsSignalError(ContextID, cmsERROR_FILE, "Couldn't create '%s'", FileName);
- return NULL;
- }
- iohandler -> ReportedSize = 0;
- break;
-
- default:
- _cmsFree(ContextID, iohandler); // Would never reach
- return NULL;
- }
-
- iohandler ->ContextID = ContextID;
- iohandler ->stream = (void*) fm;
- iohandler ->UsedSpace = 0;
-
- // Keep track of the original file
- strncpy(iohandler -> PhysicalFile, FileName, sizeof(iohandler -> PhysicalFile)-1);
- iohandler -> PhysicalFile[sizeof(iohandler -> PhysicalFile)-1] = 0;
-
- iohandler ->Read = FileRead;
- iohandler ->Seek = FileSeek;
- iohandler ->Close = FileClose;
- iohandler ->Tell = FileTell;
- iohandler ->Write = FileWrite;
-
- return iohandler;
-}
-
-// Create a iohandler for stream based files
-cmsIOHANDLER* CMSEXPORT cmsOpenIOhandlerFromStream(cmsContext ContextID, FILE* Stream)
-{
- cmsIOHANDLER* iohandler = NULL;
- cmsInt32Number fileSize;
-
- fileSize = (cmsInt32Number)cmsfilelength(Stream);
- if (fileSize < 0)
- {
- cmsSignalError(ContextID, cmsERROR_FILE, "Cannot get size of stream");
- return NULL;
- }
-
- iohandler = (cmsIOHANDLER*) _cmsMallocZero(ContextID, sizeof(cmsIOHANDLER));
- if (iohandler == NULL) return NULL;
-
- iohandler -> ContextID = ContextID;
- iohandler -> stream = (void*) Stream;
- iohandler -> UsedSpace = 0;
- iohandler -> ReportedSize = (cmsUInt32Number) fileSize;
- iohandler -> PhysicalFile[0] = 0;
-
- iohandler ->Read = FileRead;
- iohandler ->Seek = FileSeek;
- iohandler ->Close = FileClose;
- iohandler ->Tell = FileTell;
- iohandler ->Write = FileWrite;
-
- return iohandler;
-}
-
-
-
-// Close an open IO handler
-cmsBool CMSEXPORT cmsCloseIOhandler(cmsIOHANDLER* io)
-{
- return io -> Close(io);
-}
-
-// -------------------------------------------------------------------------------------------------------
-
-cmsIOHANDLER* CMSEXPORT cmsGetProfileIOhandler(cmsHPROFILE hProfile)
-{
- _cmsICCPROFILE* Icc = (_cmsICCPROFILE*)hProfile;
-
- if (Icc == NULL) return NULL;
- return Icc->IOhandler;
-}
-
-// Creates an empty structure holding all required parameters
-cmsHPROFILE CMSEXPORT cmsCreateProfilePlaceholder(cmsContext ContextID)
-{
- _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) _cmsMallocZero(ContextID, sizeof(_cmsICCPROFILE));
- if (Icc == NULL) return NULL;
-
- Icc ->ContextID = ContextID;
-
- // Set it to empty
- Icc -> TagCount = 0;
-
- // Set default version
- Icc ->Version = 0x02100000;
-
- // Set default CMM (that's me!)
- Icc ->CMM = lcmsSignature;
-
- // Set default creator
- // Created by LittleCMS (that's me!)
- Icc ->creator = lcmsSignature;
-
- // Set default platform
-#ifdef CMS_IS_WINDOWS_
- Icc ->platform = cmsSigMicrosoft;
-#else
- Icc ->platform = cmsSigMacintosh;
-#endif
-
- // Set default device class
- Icc->DeviceClass = cmsSigDisplayClass;
-
- // Set creation date/time
- if (!_cmsGetTime(&Icc->Created))
- goto Error;
-
- // Create a mutex if the user provided proper plugin. NULL otherwise
- Icc ->UsrMutex = _cmsCreateMutex(ContextID);
-
- // Return the handle
- return (cmsHPROFILE) Icc;
-
-Error:
- _cmsFree(ContextID, Icc);
- return NULL;
-}
-
-cmsContext CMSEXPORT cmsGetProfileContextID(cmsHPROFILE hProfile)
-{
- _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
-
- if (Icc == NULL) return NULL;
- return Icc -> ContextID;
-}
-
-
-// Return the number of tags
-cmsInt32Number CMSEXPORT cmsGetTagCount(cmsHPROFILE hProfile)
-{
- _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
- if (Icc == NULL) return -1;
-
- return (cmsInt32Number) Icc->TagCount;
-}
-
-// Return the tag signature of a given tag number
-cmsTagSignature CMSEXPORT cmsGetTagSignature(cmsHPROFILE hProfile, cmsUInt32Number n)
-{
- _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
-
- if (n > Icc->TagCount) return (cmsTagSignature) 0; // Mark as not available
- if (n >= MAX_TABLE_TAG) return (cmsTagSignature) 0; // As double check
-
- return Icc ->TagNames[n];
-}
-
-
-static
-int SearchOneTag(_cmsICCPROFILE* Profile, cmsTagSignature sig)
-{
- int i;
-
- for (i=0; i < (int) Profile -> TagCount; i++) {
-
- if (sig == Profile -> TagNames[i])
- return i;
- }
-
- return -1;
-}
-
-// Search for a specific tag in tag dictionary. Returns position or -1 if tag not found.
-// If followlinks is turned on, then the position of the linked tag is returned
-int _cmsSearchTag(_cmsICCPROFILE* Icc, cmsTagSignature sig, cmsBool lFollowLinks)
-{
- int n;
- cmsTagSignature LinkedSig;
-
- do {
-
- // Search for given tag in ICC profile directory
- n = SearchOneTag(Icc, sig);
- if (n < 0)
- return -1; // Not found
-
- if (!lFollowLinks)
- return n; // Found, don't follow links
-
- // Is this a linked tag?
- LinkedSig = Icc ->TagLinked[n];
-
- // Yes, follow link
- if (LinkedSig != (cmsTagSignature) 0) {
- sig = LinkedSig;
- }
-
- } while (LinkedSig != (cmsTagSignature) 0);
-
- return n;
-}
-
-// Deletes a tag entry
-
-static
-void _cmsDeleteTagByPos(_cmsICCPROFILE* Icc, int i)
-{
- _cmsAssert(Icc != NULL);
- _cmsAssert(i >= 0);
-
-
- if (Icc -> TagPtrs[i] != NULL) {
-
- // Free previous version
- if (Icc ->TagSaveAsRaw[i]) {
- _cmsFree(Icc ->ContextID, Icc ->TagPtrs[i]);
- }
- else {
- cmsTagTypeHandler* TypeHandler = Icc ->TagTypeHandlers[i];
-
- if (TypeHandler != NULL) {
-
- cmsTagTypeHandler LocalTypeHandler = *TypeHandler;
- LocalTypeHandler.ContextID = Icc ->ContextID; // As an additional parameter
- LocalTypeHandler.ICCVersion = Icc ->Version;
- LocalTypeHandler.FreePtr(&LocalTypeHandler, Icc -> TagPtrs[i]);
- Icc ->TagPtrs[i] = NULL;
- }
- }
-
- }
-}
-
-
-// Creates a new tag entry
-static
-cmsBool _cmsNewTag(_cmsICCPROFILE* Icc, cmsTagSignature sig, int* NewPos)
-{
- int i;
-
- // Search for the tag
- i = _cmsSearchTag(Icc, sig, FALSE);
- if (i >= 0) {
-
- // Already exists? delete it
- _cmsDeleteTagByPos(Icc, i);
- *NewPos = i;
- }
- else {
-
- // No, make a new one
- if (Icc -> TagCount >= MAX_TABLE_TAG) {
- cmsSignalError(Icc ->ContextID, cmsERROR_RANGE, "Too many tags (%d)", MAX_TABLE_TAG);
- return FALSE;
- }
-
- *NewPos = (int) Icc ->TagCount;
- Icc -> TagCount++;
- }
-
- return TRUE;
-}
-
-
-// Check existence
-cmsBool CMSEXPORT cmsIsTag(cmsHPROFILE hProfile, cmsTagSignature sig)
-{
- _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) (void*) hProfile;
- return _cmsSearchTag(Icc, sig, FALSE) >= 0;
-}
-
-
-
-// Checks for link compatibility
-static
-cmsBool CompatibleTypes(const cmsTagDescriptor* desc1, const cmsTagDescriptor* desc2)
-{
- cmsUInt32Number i;
-
- if (desc1 == NULL || desc2 == NULL) return FALSE;
-
- if (desc1->nSupportedTypes != desc2->nSupportedTypes) return FALSE;
- if (desc1->ElemCount != desc2->ElemCount) return FALSE;
-
- for (i = 0; i < desc1->nSupportedTypes; i++)
- {
- if (desc1->SupportedTypes[i] != desc2->SupportedTypes[i]) return FALSE;
- }
-
- return TRUE;
-}
-
-// Enforces that the profile version is per. spec.
-// Operates on the big endian bytes from the profile.
-// Called before converting to platform endianness.
-// Byte 0 is BCD major version, so max 9.
-// Byte 1 is 2 BCD digits, one per nibble.
-// Reserved bytes 2 & 3 must be 0.
-static
-cmsUInt32Number _validatedVersion(cmsUInt32Number DWord)
-{
- cmsUInt8Number* pByte = (cmsUInt8Number*) &DWord;
- cmsUInt8Number temp1;
- cmsUInt8Number temp2;
-
- if (*pByte > 0x09) *pByte = (cmsUInt8Number) 0x09;
- temp1 = (cmsUInt8Number) (*(pByte+1) & 0xf0);
- temp2 = (cmsUInt8Number) (*(pByte+1) & 0x0f);
- if (temp1 > 0x90U) temp1 = 0x90U;
- if (temp2 > 0x09U) temp2 = 0x09U;
- *(pByte+1) = (cmsUInt8Number)(temp1 | temp2);
- *(pByte+2) = (cmsUInt8Number)0;
- *(pByte+3) = (cmsUInt8Number)0;
-
- return DWord;
-}
-
-// Check device class
-static
-cmsBool validDeviceClass(cmsProfileClassSignature cl)
-{
- if ((int)cl == 0) return TRUE; // We allow zero because older lcms versions defaulted to that.
-
- switch (cl)
- {
- case cmsSigInputClass:
- case cmsSigDisplayClass:
- case cmsSigOutputClass:
- case cmsSigLinkClass:
- case cmsSigAbstractClass:
- case cmsSigColorSpaceClass:
- case cmsSigNamedColorClass:
- return TRUE;
-
- default:
- return FALSE;
- }
-
-}
-
-// Read profile header and validate it
-cmsBool _cmsReadHeader(_cmsICCPROFILE* Icc)
-{
- cmsTagEntry Tag;
- cmsICCHeader Header;
- cmsUInt32Number i, j;
- cmsUInt32Number HeaderSize;
- cmsIOHANDLER* io = Icc ->IOhandler;
- cmsUInt32Number TagCount;
-
-
- // Read the header
- if (io -> Read(io, &Header, sizeof(cmsICCHeader), 1) != 1) {
- return FALSE;
- }
-
- // Validate file as an ICC profile
- if (_cmsAdjustEndianess32(Header.magic) != cmsMagicNumber) {
- cmsSignalError(Icc ->ContextID, cmsERROR_BAD_SIGNATURE, "not an ICC profile, invalid signature");
- return FALSE;
- }
-
- // Adjust endianness of the used parameters
- Icc -> CMM = _cmsAdjustEndianess32(Header.cmmId);
- Icc -> DeviceClass = (cmsProfileClassSignature) _cmsAdjustEndianess32(Header.deviceClass);
- Icc -> ColorSpace = (cmsColorSpaceSignature) _cmsAdjustEndianess32(Header.colorSpace);
- Icc -> PCS = (cmsColorSpaceSignature) _cmsAdjustEndianess32(Header.pcs);
-
- Icc -> RenderingIntent = _cmsAdjustEndianess32(Header.renderingIntent);
- Icc -> platform = (cmsPlatformSignature)_cmsAdjustEndianess32(Header.platform);
- Icc -> flags = _cmsAdjustEndianess32(Header.flags);
- Icc -> manufacturer = _cmsAdjustEndianess32(Header.manufacturer);
- Icc -> model = _cmsAdjustEndianess32(Header.model);
- Icc -> creator = _cmsAdjustEndianess32(Header.creator);
-
- _cmsAdjustEndianess64(&Icc -> attributes, &Header.attributes);
- Icc -> Version = _cmsAdjustEndianess32(_validatedVersion(Header.version));
-
- if (Icc->Version > 0x5000000) {
- cmsSignalError(Icc->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unsupported profile version '0x%x'", Icc->Version);
- return FALSE;
- }
-
- if (!validDeviceClass(Icc->DeviceClass)) {
- cmsSignalError(Icc->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unsupported device class '0x%x'", Icc->DeviceClass);
- return FALSE;
- }
-
- // Get size as reported in header
- HeaderSize = _cmsAdjustEndianess32(Header.size);
-
- // Make sure HeaderSize is lower than profile size
- if (HeaderSize >= Icc ->IOhandler ->ReportedSize)
- HeaderSize = Icc ->IOhandler ->ReportedSize;
-
-
- // Get creation date/time
- _cmsDecodeDateTimeNumber(&Header.date, &Icc ->Created);
-
- // The profile ID are 32 raw bytes
- memmove(Icc ->ProfileID.ID32, Header.profileID.ID32, 16);
-
-
- // Read tag directory
- if (!_cmsReadUInt32Number(io, &TagCount)) return FALSE;
- if (TagCount > MAX_TABLE_TAG) {
-
- cmsSignalError(Icc ->ContextID, cmsERROR_RANGE, "Too many tags (%d)", TagCount);
- return FALSE;
- }
-
-
- // Read tag directory
- Icc -> TagCount = 0;
- for (i=0; i < TagCount; i++) {
-
- if (!_cmsReadUInt32Number(io, (cmsUInt32Number *) &Tag.sig)) return FALSE;
- if (!_cmsReadUInt32Number(io, &Tag.offset)) return FALSE;
- if (!_cmsReadUInt32Number(io, &Tag.size)) return FALSE;
-
- // Perform some sanity check. Offset + size should fall inside file.
- if (Tag.size == 0 || Tag.offset == 0) continue;
- if (Tag.offset + Tag.size > HeaderSize ||
- Tag.offset + Tag.size < Tag.offset)
- continue;
-
- Icc -> TagNames[Icc ->TagCount] = Tag.sig;
- Icc -> TagOffsets[Icc ->TagCount] = Tag.offset;
- Icc -> TagSizes[Icc ->TagCount] = Tag.size;
-
- // Search for links
- for (j=0; j < Icc ->TagCount; j++) {
-
- if ((Icc ->TagOffsets[j] == Tag.offset) &&
- (Icc ->TagSizes[j] == Tag.size)) {
-
- // Check types.
- if (CompatibleTypes(_cmsGetTagDescriptor(Icc->ContextID, Icc->TagNames[j]),
- _cmsGetTagDescriptor(Icc->ContextID, Tag.sig))) {
-
- Icc->TagLinked[Icc->TagCount] = Icc->TagNames[j];
- }
- }
-
- }
-
- Icc ->TagCount++;
- }
-
-
- for (i = 0; i < Icc->TagCount; i++) {
- for (j = 0; j < Icc->TagCount; j++) {
-
- // Tags cannot be duplicate
- if ((i != j) && (Icc->TagNames[i] == Icc->TagNames[j])) {
- cmsSignalError(Icc->ContextID, cmsERROR_RANGE, "Duplicate tag found");
- return FALSE;
- }
-
- }
- }
-
- return TRUE;
-}
-
-// Saves profile header
-cmsBool _cmsWriteHeader(_cmsICCPROFILE* Icc, cmsUInt32Number UsedSpace)
-{
- cmsICCHeader Header;
- cmsUInt32Number i;
- cmsTagEntry Tag;
- cmsUInt32Number Count;
-
- Header.size = _cmsAdjustEndianess32(UsedSpace);
- Header.cmmId = _cmsAdjustEndianess32(Icc ->CMM);
- Header.version = _cmsAdjustEndianess32(Icc ->Version);
-
- Header.deviceClass = (cmsProfileClassSignature) _cmsAdjustEndianess32(Icc -> DeviceClass);
- Header.colorSpace = (cmsColorSpaceSignature) _cmsAdjustEndianess32(Icc -> ColorSpace);
- Header.pcs = (cmsColorSpaceSignature) _cmsAdjustEndianess32(Icc -> PCS);
-
- // NOTE: in v4 Timestamp must be in UTC rather than in local time
- _cmsEncodeDateTimeNumber(&Header.date, &Icc ->Created);
-
- Header.magic = _cmsAdjustEndianess32(cmsMagicNumber);
-
- Header.platform = (cmsPlatformSignature) _cmsAdjustEndianess32(Icc -> platform);
-
- Header.flags = _cmsAdjustEndianess32(Icc -> flags);
- Header.manufacturer = _cmsAdjustEndianess32(Icc -> manufacturer);
- Header.model = _cmsAdjustEndianess32(Icc -> model);
-
- _cmsAdjustEndianess64(&Header.attributes, &Icc -> attributes);
-
- // Rendering intent in the header (for embedded profiles)
- Header.renderingIntent = _cmsAdjustEndianess32(Icc -> RenderingIntent);
-
- // Illuminant is always D50
- Header.illuminant.X = (cmsS15Fixed16Number) _cmsAdjustEndianess32((cmsUInt32Number) _cmsDoubleTo15Fixed16(cmsD50_XYZ()->X));
- Header.illuminant.Y = (cmsS15Fixed16Number) _cmsAdjustEndianess32((cmsUInt32Number) _cmsDoubleTo15Fixed16(cmsD50_XYZ()->Y));
- Header.illuminant.Z = (cmsS15Fixed16Number) _cmsAdjustEndianess32((cmsUInt32Number) _cmsDoubleTo15Fixed16(cmsD50_XYZ()->Z));
-
- Header.creator = _cmsAdjustEndianess32(Icc ->creator);
-
- memset(&Header.reserved, 0, sizeof(Header.reserved));
-
- // Set profile ID. Endianness is always big endian
- memmove(&Header.profileID, &Icc ->ProfileID, 16);
-
- // Dump the header
- if (!Icc -> IOhandler->Write(Icc->IOhandler, sizeof(cmsICCHeader), &Header)) return FALSE;
-
- // Saves Tag directory
-
- // Get true count
- Count = 0;
- for (i=0; i < Icc -> TagCount; i++) {
- if (Icc ->TagNames[i] != (cmsTagSignature) 0)
- Count++;
- }
-
- // Store number of tags
- if (!_cmsWriteUInt32Number(Icc ->IOhandler, Count)) return FALSE;
-
- for (i=0; i < Icc -> TagCount; i++) {
-
- if (Icc ->TagNames[i] == (cmsTagSignature) 0) continue; // It is just a placeholder
-
- Tag.sig = (cmsTagSignature) _cmsAdjustEndianess32((cmsUInt32Number) Icc -> TagNames[i]);
- Tag.offset = _cmsAdjustEndianess32((cmsUInt32Number) Icc -> TagOffsets[i]);
- Tag.size = _cmsAdjustEndianess32((cmsUInt32Number) Icc -> TagSizes[i]);
-
- if (!Icc ->IOhandler -> Write(Icc-> IOhandler, sizeof(cmsTagEntry), &Tag)) return FALSE;
- }
-
- return TRUE;
-}
-
-// ----------------------------------------------------------------------- Set/Get several struct members
-
-
-cmsUInt32Number CMSEXPORT cmsGetHeaderRenderingIntent(cmsHPROFILE hProfile)
-{
- _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
- return Icc -> RenderingIntent;
-}
-
-void CMSEXPORT cmsSetHeaderRenderingIntent(cmsHPROFILE hProfile, cmsUInt32Number RenderingIntent)
-{
- _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
- Icc -> RenderingIntent = RenderingIntent;
-}
-
-cmsUInt32Number CMSEXPORT cmsGetHeaderFlags(cmsHPROFILE hProfile)
-{
- _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
- return (cmsUInt32Number) Icc -> flags;
-}
-
-void CMSEXPORT cmsSetHeaderFlags(cmsHPROFILE hProfile, cmsUInt32Number Flags)
-{
- _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
- Icc -> flags = (cmsUInt32Number) Flags;
-}
-
-cmsUInt32Number CMSEXPORT cmsGetHeaderManufacturer(cmsHPROFILE hProfile)
-{
- _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
- return Icc ->manufacturer;
-}
-
-void CMSEXPORT cmsSetHeaderManufacturer(cmsHPROFILE hProfile, cmsUInt32Number manufacturer)
-{
- _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
- Icc -> manufacturer = manufacturer;
-}
-
-cmsUInt32Number CMSEXPORT cmsGetHeaderCreator(cmsHPROFILE hProfile)
-{
- _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
- return Icc ->creator;
-}
-
-cmsUInt32Number CMSEXPORT cmsGetHeaderModel(cmsHPROFILE hProfile)
-{
- _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
- return Icc ->model;
-}
-
-void CMSEXPORT cmsSetHeaderModel(cmsHPROFILE hProfile, cmsUInt32Number model)
-{
- _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
- Icc -> model = model;
-}
-
-void CMSEXPORT cmsGetHeaderAttributes(cmsHPROFILE hProfile, cmsUInt64Number* Flags)
-{
- _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
- memmove(Flags, &Icc -> attributes, sizeof(cmsUInt64Number));
-}
-
-void CMSEXPORT cmsSetHeaderAttributes(cmsHPROFILE hProfile, cmsUInt64Number Flags)
-{
- _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
- memmove(&Icc -> attributes, &Flags, sizeof(cmsUInt64Number));
-}
-
-void CMSEXPORT cmsGetHeaderProfileID(cmsHPROFILE hProfile, cmsUInt8Number* ProfileID)
-{
- _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
- memmove(ProfileID, Icc ->ProfileID.ID8, 16);
-}
-
-void CMSEXPORT cmsSetHeaderProfileID(cmsHPROFILE hProfile, cmsUInt8Number* ProfileID)
-{
- _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
- memmove(&Icc -> ProfileID, ProfileID, 16);
-}
-
-cmsBool CMSEXPORT cmsGetHeaderCreationDateTime(cmsHPROFILE hProfile, struct tm *Dest)
-{
- _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
- memmove(Dest, &Icc ->Created, sizeof(struct tm));
- return TRUE;
-}
-
-cmsColorSpaceSignature CMSEXPORT cmsGetPCS(cmsHPROFILE hProfile)
-{
- _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
- return Icc -> PCS;
-}
-
-void CMSEXPORT cmsSetPCS(cmsHPROFILE hProfile, cmsColorSpaceSignature pcs)
-{
- _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
- Icc -> PCS = pcs;
-}
-
-cmsColorSpaceSignature CMSEXPORT cmsGetColorSpace(cmsHPROFILE hProfile)
-{
- _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
- return Icc -> ColorSpace;
-}
-
-void CMSEXPORT cmsSetColorSpace(cmsHPROFILE hProfile, cmsColorSpaceSignature sig)
-{
- _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
- Icc -> ColorSpace = sig;
-}
-
-cmsProfileClassSignature CMSEXPORT cmsGetDeviceClass(cmsHPROFILE hProfile)
-{
- _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
- return Icc -> DeviceClass;
-}
-
-void CMSEXPORT cmsSetDeviceClass(cmsHPROFILE hProfile, cmsProfileClassSignature sig)
-{
- _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
- Icc -> DeviceClass = sig;
-}
-
-cmsUInt32Number CMSEXPORT cmsGetEncodedICCversion(cmsHPROFILE hProfile)
-{
- _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
- return Icc -> Version;
-}
-
-void CMSEXPORT cmsSetEncodedICCversion(cmsHPROFILE hProfile, cmsUInt32Number Version)
-{
- _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
- Icc -> Version = Version;
-}
-
-// Get an hexadecimal number with same digits as v
-static
-cmsUInt32Number BaseToBase(cmsUInt32Number in, int BaseIn, int BaseOut)
-{
- char Buff[100];
- int i, len;
- cmsUInt32Number out;
-
- for (len=0; in > 0 && len < 100; len++) {
-
- Buff[len] = (char) (in % BaseIn);
- in /= BaseIn;
- }
-
- for (i=len-1, out=0; i >= 0; --i) {
- out = out * BaseOut + Buff[i];
- }
-
- return out;
-}
-
-void CMSEXPORT cmsSetProfileVersion(cmsHPROFILE hProfile, cmsFloat64Number Version)
-{
- _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
-
- // 4.2 -> 0x4200000
-
- Icc -> Version = BaseToBase((cmsUInt32Number) floor(Version * 100.0 + 0.5), 10, 16) << 16;
-}
-
-cmsFloat64Number CMSEXPORT cmsGetProfileVersion(cmsHPROFILE hProfile)
-{
- _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
- cmsUInt32Number n = Icc -> Version >> 16;
-
- return BaseToBase(n, 16, 10) / 100.0;
-}
-// --------------------------------------------------------------------------------------------------------------
-
-
-// Create profile from IOhandler
-cmsHPROFILE CMSEXPORT cmsOpenProfileFromIOhandlerTHR(cmsContext ContextID, cmsIOHANDLER* io)
-{
- _cmsICCPROFILE* NewIcc;
- cmsHPROFILE hEmpty = cmsCreateProfilePlaceholder(ContextID);
-
- if (hEmpty == NULL) return NULL;
-
- NewIcc = (_cmsICCPROFILE*) hEmpty;
-
- NewIcc ->IOhandler = io;
- if (!_cmsReadHeader(NewIcc)) goto Error;
- return hEmpty;
-
-Error:
- cmsCloseProfile(hEmpty);
- return NULL;
-}
-
-// Create profile from IOhandler
-cmsHPROFILE CMSEXPORT cmsOpenProfileFromIOhandler2THR(cmsContext ContextID, cmsIOHANDLER* io, cmsBool write)
-{
- _cmsICCPROFILE* NewIcc;
- cmsHPROFILE hEmpty = cmsCreateProfilePlaceholder(ContextID);
-
- if (hEmpty == NULL) return NULL;
-
- NewIcc = (_cmsICCPROFILE*) hEmpty;
-
- NewIcc ->IOhandler = io;
- if (write) {
-
- NewIcc -> IsWrite = TRUE;
- return hEmpty;
- }
-
- if (!_cmsReadHeader(NewIcc)) goto Error;
- return hEmpty;
-
-Error:
- cmsCloseProfile(hEmpty);
- return NULL;
-}
-
-
-// Create profile from disk file
-cmsHPROFILE CMSEXPORT cmsOpenProfileFromFileTHR(cmsContext ContextID, const char *lpFileName, const char *sAccess)
-{
- _cmsICCPROFILE* NewIcc;
- cmsHPROFILE hEmpty = cmsCreateProfilePlaceholder(ContextID);
-
- if (hEmpty == NULL) return NULL;
-
- NewIcc = (_cmsICCPROFILE*) hEmpty;
-
- NewIcc ->IOhandler = cmsOpenIOhandlerFromFile(ContextID, lpFileName, sAccess);
- if (NewIcc ->IOhandler == NULL) goto Error;
-
- if (*sAccess == 'W' || *sAccess == 'w') {
-
- NewIcc -> IsWrite = TRUE;
-
- return hEmpty;
- }
-
- if (!_cmsReadHeader(NewIcc)) goto Error;
- return hEmpty;
-
-Error:
- cmsCloseProfile(hEmpty);
- return NULL;
-}
-
-
-cmsHPROFILE CMSEXPORT cmsOpenProfileFromFile(const char *ICCProfile, const char *sAccess)
-{
- return cmsOpenProfileFromFileTHR(NULL, ICCProfile, sAccess);
-}
-
-
-cmsHPROFILE CMSEXPORT cmsOpenProfileFromStreamTHR(cmsContext ContextID, FILE* ICCProfile, const char *sAccess)
-{
- _cmsICCPROFILE* NewIcc;
- cmsHPROFILE hEmpty = cmsCreateProfilePlaceholder(ContextID);
-
- if (hEmpty == NULL) return NULL;
-
- NewIcc = (_cmsICCPROFILE*) hEmpty;
-
- NewIcc ->IOhandler = cmsOpenIOhandlerFromStream(ContextID, ICCProfile);
- if (NewIcc ->IOhandler == NULL) goto Error;
-
- if (*sAccess == 'w') {
-
- NewIcc -> IsWrite = TRUE;
- return hEmpty;
- }
-
- if (!_cmsReadHeader(NewIcc)) goto Error;
- return hEmpty;
-
-Error:
- cmsCloseProfile(hEmpty);
- return NULL;
-
-}
-
-cmsHPROFILE CMSEXPORT cmsOpenProfileFromStream(FILE* ICCProfile, const char *sAccess)
-{
- return cmsOpenProfileFromStreamTHR(NULL, ICCProfile, sAccess);
-}
-
-
-// Open from memory block
-cmsHPROFILE CMSEXPORT cmsOpenProfileFromMemTHR(cmsContext ContextID, const void* MemPtr, cmsUInt32Number dwSize)
-{
- _cmsICCPROFILE* NewIcc;
- cmsHPROFILE hEmpty;
-
- hEmpty = cmsCreateProfilePlaceholder(ContextID);
- if (hEmpty == NULL) return NULL;
-
- NewIcc = (_cmsICCPROFILE*) hEmpty;
-
- // Ok, in this case const void* is casted to void* just because open IO handler
- // shares read and writing modes. Don't abuse this feature!
- NewIcc ->IOhandler = cmsOpenIOhandlerFromMem(ContextID, (void*) MemPtr, dwSize, "r");
- if (NewIcc ->IOhandler == NULL) goto Error;
-
- if (!_cmsReadHeader(NewIcc)) goto Error;
-
- return hEmpty;
-
-Error:
- cmsCloseProfile(hEmpty);
- return NULL;
-}
-
-cmsHPROFILE CMSEXPORT cmsOpenProfileFromMem(const void* MemPtr, cmsUInt32Number dwSize)
-{
- return cmsOpenProfileFromMemTHR(NULL, MemPtr, dwSize);
-}
-
-
-
-// Dump tag contents. If the profile is being modified, untouched tags are copied from FileOrig
-static
-cmsBool SaveTags(_cmsICCPROFILE* Icc, _cmsICCPROFILE* FileOrig)
-{
- cmsUInt8Number* Data;
- cmsUInt32Number i;
- cmsUInt32Number Begin;
- cmsIOHANDLER* io = Icc ->IOhandler;
- cmsTagDescriptor* TagDescriptor;
- cmsTagTypeSignature TypeBase;
- cmsTagTypeSignature Type;
- cmsTagTypeHandler* TypeHandler;
- cmsFloat64Number Version = cmsGetProfileVersion((cmsHPROFILE) Icc);
- cmsTagTypeHandler LocalTypeHandler;
-
- for (i=0; i < Icc -> TagCount; i++) {
-
- if (Icc ->TagNames[i] == (cmsTagSignature) 0) continue;
-
- // Linked tags are not written
- if (Icc ->TagLinked[i] != (cmsTagSignature) 0) continue;
-
- Icc -> TagOffsets[i] = Begin = io ->UsedSpace;
-
- Data = (cmsUInt8Number*) Icc -> TagPtrs[i];
-
- if (!Data) {
-
- // Reach here if we are copying a tag from a disk-based ICC profile which has not been modified by user.
- // In this case a blind copy of the block data is performed
- if (FileOrig != NULL && Icc -> TagOffsets[i]) {
-
- if (FileOrig->IOhandler != NULL)
- {
- cmsUInt32Number TagSize = FileOrig->TagSizes[i];
- cmsUInt32Number TagOffset = FileOrig->TagOffsets[i];
- void* Mem;
-
- if (!FileOrig->IOhandler->Seek(FileOrig->IOhandler, TagOffset)) return FALSE;
-
- Mem = _cmsMalloc(Icc->ContextID, TagSize);
- if (Mem == NULL) return FALSE;
-
- if (FileOrig->IOhandler->Read(FileOrig->IOhandler, Mem, TagSize, 1) != 1) return FALSE;
- if (!io->Write(io, TagSize, Mem)) return FALSE;
- _cmsFree(Icc->ContextID, Mem);
-
- Icc->TagSizes[i] = (io->UsedSpace - Begin);
-
-
- // Align to 32 bit boundary.
- if (!_cmsWriteAlignment(io))
- return FALSE;
- }
- }
-
- continue;
- }
-
-
- // Should this tag be saved as RAW? If so, tagsizes should be specified in advance (no further cooking is done)
- if (Icc ->TagSaveAsRaw[i]) {
-
- if (io -> Write(io, Icc ->TagSizes[i], Data) != 1) return FALSE;
- }
- else {
-
- // Search for support on this tag
- TagDescriptor = _cmsGetTagDescriptor(Icc-> ContextID, Icc -> TagNames[i]);
- if (TagDescriptor == NULL) continue; // Unsupported, ignore it
-
- if (TagDescriptor ->DecideType != NULL) {
-
- Type = TagDescriptor ->DecideType(Version, Data);
- }
- else {
-
- Type = TagDescriptor ->SupportedTypes[0];
- }
-
- TypeHandler = _cmsGetTagTypeHandler(Icc->ContextID, Type);
-
- if (TypeHandler == NULL) {
- cmsSignalError(Icc ->ContextID, cmsERROR_INTERNAL, "(Internal) no handler for tag %x", Icc -> TagNames[i]);
- continue;
- }
-
- TypeBase = TypeHandler ->Signature;
- if (!_cmsWriteTypeBase(io, TypeBase))
- return FALSE;
-
- LocalTypeHandler = *TypeHandler;
- LocalTypeHandler.ContextID = Icc ->ContextID;
- LocalTypeHandler.ICCVersion = Icc ->Version;
- if (!LocalTypeHandler.WritePtr(&LocalTypeHandler, io, Data, TagDescriptor ->ElemCount)) {
-
- char String[5];
-
- _cmsTagSignature2String(String, (cmsTagSignature) TypeBase);
- cmsSignalError(Icc ->ContextID, cmsERROR_WRITE, "Couldn't write type '%s'", String);
- return FALSE;
- }
- }
-
-
- Icc -> TagSizes[i] = (io ->UsedSpace - Begin);
-
- // Align to 32 bit boundary.
- if (! _cmsWriteAlignment(io))
- return FALSE;
- }
-
-
- return TRUE;
-}
-
-
-// Fill the offset and size fields for all linked tags
-static
-cmsBool SetLinks( _cmsICCPROFILE* Icc)
-{
- cmsUInt32Number i;
-
- for (i=0; i < Icc -> TagCount; i++) {
-
- cmsTagSignature lnk = Icc ->TagLinked[i];
- if (lnk != (cmsTagSignature) 0) {
-
- int j = _cmsSearchTag(Icc, lnk, FALSE);
- if (j >= 0) {
-
- Icc ->TagOffsets[i] = Icc ->TagOffsets[j];
- Icc ->TagSizes[i] = Icc ->TagSizes[j];
- }
-
- }
- }
-
- return TRUE;
-}
-
-// Low-level save to IOHANDLER. It returns the number of bytes used to
-// store the profile, or zero on error. io may be NULL and in this case
-// no data is written--only sizes are calculated
-cmsUInt32Number CMSEXPORT cmsSaveProfileToIOhandler(cmsHPROFILE hProfile, cmsIOHANDLER* io)
-{
- _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
- _cmsICCPROFILE Keep;
- cmsIOHANDLER* PrevIO = NULL;
- cmsUInt32Number UsedSpace;
- cmsContext ContextID;
-
- _cmsAssert(hProfile != NULL);
-
- if (!_cmsLockMutex(Icc->ContextID, Icc->UsrMutex)) return 0;
- memmove(&Keep, Icc, sizeof(_cmsICCPROFILE));
-
- ContextID = cmsGetProfileContextID(hProfile);
- PrevIO = Icc ->IOhandler = cmsOpenIOhandlerFromNULL(ContextID);
- if (PrevIO == NULL) {
- _cmsUnlockMutex(Icc->ContextID, Icc->UsrMutex);
- return 0;
- }
-
- // Pass #1 does compute offsets
-
- if (!_cmsWriteHeader(Icc, 0)) goto Error;
- if (!SaveTags(Icc, &Keep)) goto Error;
-
- UsedSpace = PrevIO ->UsedSpace;
-
- // Pass #2 does save to iohandler
-
- if (io != NULL) {
-
- Icc ->IOhandler = io;
- if (!SetLinks(Icc)) goto Error;
- if (!_cmsWriteHeader(Icc, UsedSpace)) goto Error;
- if (!SaveTags(Icc, &Keep)) goto Error;
- }
-
- memmove(Icc, &Keep, sizeof(_cmsICCPROFILE));
- if (!cmsCloseIOhandler(PrevIO))
- UsedSpace = 0; // As a error marker
-
- _cmsUnlockMutex(Icc->ContextID, Icc->UsrMutex);
-
- return UsedSpace;
-
-
-Error:
- cmsCloseIOhandler(PrevIO);
- memmove(Icc, &Keep, sizeof(_cmsICCPROFILE));
- _cmsUnlockMutex(Icc->ContextID, Icc->UsrMutex);
-
- return 0;
-}
-
-
-// Low-level save to disk.
-cmsBool CMSEXPORT cmsSaveProfileToFile(cmsHPROFILE hProfile, const char* FileName)
-{
- cmsContext ContextID = cmsGetProfileContextID(hProfile);
- cmsIOHANDLER* io = cmsOpenIOhandlerFromFile(ContextID, FileName, "w");
- cmsBool rc;
-
- if (io == NULL) return FALSE;
-
- rc = (cmsSaveProfileToIOhandler(hProfile, io) != 0);
- rc &= cmsCloseIOhandler(io);
-
- if (rc == FALSE) { // remove() is C99 per 7.19.4.1
- remove(FileName); // We have to IGNORE return value in this case
- }
- return rc;
-}
-
-// Same as anterior, but for streams
-cmsBool CMSEXPORT cmsSaveProfileToStream(cmsHPROFILE hProfile, FILE* Stream)
-{
- cmsBool rc;
- cmsContext ContextID = cmsGetProfileContextID(hProfile);
- cmsIOHANDLER* io = cmsOpenIOhandlerFromStream(ContextID, Stream);
-
- if (io == NULL) return FALSE;
-
- rc = (cmsSaveProfileToIOhandler(hProfile, io) != 0);
- rc &= cmsCloseIOhandler(io);
-
- return rc;
-}
-
-
-// Same as anterior, but for memory blocks. In this case, a NULL as MemPtr means calculate needed space only
-cmsBool CMSEXPORT cmsSaveProfileToMem(cmsHPROFILE hProfile, void *MemPtr, cmsUInt32Number* BytesNeeded)
-{
- cmsBool rc;
- cmsIOHANDLER* io;
- cmsContext ContextID = cmsGetProfileContextID(hProfile);
-
- _cmsAssert(BytesNeeded != NULL);
-
- // Should we just calculate the needed space?
- if (MemPtr == NULL) {
-
- *BytesNeeded = cmsSaveProfileToIOhandler(hProfile, NULL);
- return (*BytesNeeded == 0) ? FALSE : TRUE;
- }
-
- // That is a real write operation
- io = cmsOpenIOhandlerFromMem(ContextID, MemPtr, *BytesNeeded, "w");
- if (io == NULL) return FALSE;
-
- rc = (cmsSaveProfileToIOhandler(hProfile, io) != 0);
- rc &= cmsCloseIOhandler(io);
-
- return rc;
-}
-
-// Free one tag contents
-static
-void freeOneTag(_cmsICCPROFILE* Icc, cmsUInt32Number i)
-{
- if (Icc->TagPtrs[i]) {
-
- cmsTagTypeHandler* TypeHandler = Icc->TagTypeHandlers[i];
-
- if (TypeHandler != NULL) {
- cmsTagTypeHandler LocalTypeHandler = *TypeHandler;
-
- LocalTypeHandler.ContextID = Icc->ContextID;
- LocalTypeHandler.ICCVersion = Icc->Version;
- LocalTypeHandler.FreePtr(&LocalTypeHandler, Icc->TagPtrs[i]);
- }
- else
- _cmsFree(Icc->ContextID, Icc->TagPtrs[i]);
- }
-}
-
-// Closes a profile freeing any involved resources
-cmsBool CMSEXPORT cmsCloseProfile(cmsHPROFILE hProfile)
-{
- _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
- cmsBool rc = TRUE;
- cmsUInt32Number i;
-
- if (!Icc) return FALSE;
-
- // Was open in write mode?
- if (Icc ->IsWrite) {
-
- Icc ->IsWrite = FALSE; // Assure no further writing
- rc &= cmsSaveProfileToFile(hProfile, Icc ->IOhandler->PhysicalFile);
- }
-
- for (i=0; i < Icc -> TagCount; i++) {
-
- freeOneTag(Icc, i);
- }
-
- if (Icc ->IOhandler != NULL) {
- rc &= cmsCloseIOhandler(Icc->IOhandler);
- }
-
- _cmsDestroyMutex(Icc->ContextID, Icc->UsrMutex);
-
- _cmsFree(Icc ->ContextID, Icc); // Free placeholder memory
-
- return rc;
-}
-
-
-// -------------------------------------------------------------------------------------------------------------------
-
-
-// Returns TRUE if a given tag is supported by a plug-in
-static
-cmsBool IsTypeSupported(cmsTagDescriptor* TagDescriptor, cmsTagTypeSignature Type)
-{
- cmsUInt32Number i, nMaxTypes;
-
- nMaxTypes = TagDescriptor->nSupportedTypes;
- if (nMaxTypes >= MAX_TYPES_IN_LCMS_PLUGIN)
- nMaxTypes = MAX_TYPES_IN_LCMS_PLUGIN;
-
- for (i=0; i < nMaxTypes; i++) {
- if (Type == TagDescriptor ->SupportedTypes[i]) return TRUE;
- }
-
- return FALSE;
-}
-
-
-// That's the main read function
-void* CMSEXPORT cmsReadTag(cmsHPROFILE hProfile, cmsTagSignature sig)
-{
- _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
- cmsIOHANDLER* io;
- cmsTagTypeHandler* TypeHandler;
- cmsTagTypeHandler LocalTypeHandler;
- cmsTagDescriptor* TagDescriptor;
- cmsTagTypeSignature BaseType;
- cmsUInt32Number Offset, TagSize;
- cmsUInt32Number ElemCount;
- int n;
-
- if (!_cmsLockMutex(Icc->ContextID, Icc ->UsrMutex)) return NULL;
-
- n = _cmsSearchTag(Icc, sig, TRUE);
- if (n < 0)
- {
- // Not found, return NULL
- _cmsUnlockMutex(Icc->ContextID, Icc->UsrMutex);
- return NULL;
- }
-
- // If the element is already in memory, return the pointer
- if (Icc -> TagPtrs[n]) {
-
- if (Icc->TagTypeHandlers[n] == NULL) goto Error;
-
- // Sanity check
- BaseType = Icc->TagTypeHandlers[n]->Signature;
- if (BaseType == 0) goto Error;
-
- TagDescriptor = _cmsGetTagDescriptor(Icc->ContextID, sig);
- if (TagDescriptor == NULL) goto Error;
-
- if (!IsTypeSupported(TagDescriptor, BaseType)) goto Error;
-
- if (Icc ->TagSaveAsRaw[n]) goto Error; // We don't support read raw tags as cooked
-
- _cmsUnlockMutex(Icc->ContextID, Icc ->UsrMutex);
- return Icc -> TagPtrs[n];
- }
-
- // We need to read it. Get the offset and size to the file
- Offset = Icc -> TagOffsets[n];
- TagSize = Icc -> TagSizes[n];
-
- if (TagSize < 8) goto Error;
-
- io = Icc ->IOhandler;
-
- if (io == NULL) { // This is a built-in profile that has been manipulated, abort early
-
- cmsSignalError(Icc->ContextID, cmsERROR_CORRUPTION_DETECTED, "Corrupted built-in profile.");
- goto Error;
- }
-
- // Seek to its location
- if (!io -> Seek(io, Offset))
- goto Error;
-
- // Search for support on this tag
- TagDescriptor = _cmsGetTagDescriptor(Icc-> ContextID, sig);
- if (TagDescriptor == NULL) {
-
- char String[5];
-
- _cmsTagSignature2String(String, sig);
-
- // An unknown element was found.
- cmsSignalError(Icc ->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unknown tag type '%s' found.", String);
- goto Error; // Unsupported.
- }
-
- // if supported, get type and check if in list
- BaseType = _cmsReadTypeBase(io);
- if (BaseType == 0) goto Error;
-
- if (!IsTypeSupported(TagDescriptor, BaseType)) goto Error;
-
- TagSize -= 8; // Already read by the type base logic
-
- // Get type handler
- TypeHandler = _cmsGetTagTypeHandler(Icc ->ContextID, BaseType);
- if (TypeHandler == NULL) goto Error;
- LocalTypeHandler = *TypeHandler;
-
-
- // Read the tag
- Icc -> TagTypeHandlers[n] = TypeHandler;
-
- LocalTypeHandler.ContextID = Icc ->ContextID;
- LocalTypeHandler.ICCVersion = Icc ->Version;
- Icc -> TagPtrs[n] = LocalTypeHandler.ReadPtr(&LocalTypeHandler, io, &ElemCount, TagSize);
-
- // The tag type is supported, but something wrong happened and we cannot read the tag.
- // let know the user about this (although it is just a warning)
- if (Icc -> TagPtrs[n] == NULL) {
-
- char String[5];
-
- _cmsTagSignature2String(String, sig);
- cmsSignalError(Icc ->ContextID, cmsERROR_CORRUPTION_DETECTED, "Corrupted tag '%s'", String);
- goto Error;
- }
-
- // This is a weird error that may be a symptom of something more serious, the number of
- // stored item is actually less than the number of required elements.
- if (ElemCount < TagDescriptor ->ElemCount) {
-
- char String[5];
-
- _cmsTagSignature2String(String, sig);
- cmsSignalError(Icc ->ContextID, cmsERROR_CORRUPTION_DETECTED, "'%s' Inconsistent number of items: expected %d, got %d",
- String, TagDescriptor ->ElemCount, ElemCount);
- goto Error;
- }
-
-
- // Return the data
- _cmsUnlockMutex(Icc->ContextID, Icc ->UsrMutex);
- return Icc -> TagPtrs[n];
-
-
- // Return error and unlock the data
-Error:
-
- freeOneTag(Icc, n);
- Icc->TagPtrs[n] = NULL;
-
- _cmsUnlockMutex(Icc->ContextID, Icc ->UsrMutex);
- return NULL;
-}
-
-
-// Get true type of data
-cmsTagTypeSignature _cmsGetTagTrueType(cmsHPROFILE hProfile, cmsTagSignature sig)
-{
- _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
- cmsTagTypeHandler* TypeHandler;
- int n;
-
- // Search for given tag in ICC profile directory
- n = _cmsSearchTag(Icc, sig, TRUE);
- if (n < 0) return (cmsTagTypeSignature) 0; // Not found, return NULL
-
- // Get the handler. The true type is there
- TypeHandler = Icc -> TagTypeHandlers[n];
- return TypeHandler ->Signature;
-}
-
-
-// Write a single tag. This just keeps track of the tak into a list of "to be written". If the tag is already
-// in that list, the previous version is deleted.
-cmsBool CMSEXPORT cmsWriteTag(cmsHPROFILE hProfile, cmsTagSignature sig, const void* data)
-{
- _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
- cmsTagTypeHandler* TypeHandler = NULL;
- cmsTagTypeHandler LocalTypeHandler;
- cmsTagDescriptor* TagDescriptor = NULL;
- cmsTagTypeSignature Type;
- int i;
- cmsFloat64Number Version;
- char TypeString[5], SigString[5];
-
- if (!_cmsLockMutex(Icc->ContextID, Icc ->UsrMutex)) return FALSE;
-
- // To delete tags.
- if (data == NULL) {
-
- // Delete the tag
- i = _cmsSearchTag(Icc, sig, FALSE);
- if (i >= 0) {
-
- // Use zero as a mark of deleted
- _cmsDeleteTagByPos(Icc, i);
- Icc ->TagNames[i] = (cmsTagSignature) 0;
- _cmsUnlockMutex(Icc->ContextID, Icc ->UsrMutex);
- return TRUE;
- }
- // Didn't find the tag
- goto Error;
- }
-
- if (!_cmsNewTag(Icc, sig, &i)) goto Error;
-
- // This is not raw
- Icc ->TagSaveAsRaw[i] = FALSE;
-
- // This is not a link
- Icc ->TagLinked[i] = (cmsTagSignature) 0;
-
- // Get information about the TAG.
- TagDescriptor = _cmsGetTagDescriptor(Icc-> ContextID, sig);
- if (TagDescriptor == NULL){
- cmsSignalError(Icc ->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unsupported tag '%x'", sig);
- goto Error;
- }
-
-
- // Now we need to know which type to use. It depends on the version.
- Version = cmsGetProfileVersion(hProfile);
-
- if (TagDescriptor ->DecideType != NULL) {
-
- // Let the tag descriptor to decide the type base on depending on
- // the data. This is useful for example on parametric curves, where
- // curves specified by a table cannot be saved as parametric and needs
- // to be casted to single v2-curves, even on v4 profiles.
-
- Type = TagDescriptor ->DecideType(Version, data);
- }
- else {
-
- Type = TagDescriptor ->SupportedTypes[0];
- }
-
- // Does the tag support this type?
- if (!IsTypeSupported(TagDescriptor, Type)) {
-
- _cmsTagSignature2String(TypeString, (cmsTagSignature) Type);
- _cmsTagSignature2String(SigString, sig);
-
- cmsSignalError(Icc ->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unsupported type '%s' for tag '%s'", TypeString, SigString);
- goto Error;
- }
-
- // Does we have a handler for this type?
- TypeHandler = _cmsGetTagTypeHandler(Icc->ContextID, Type);
- if (TypeHandler == NULL) {
-
- _cmsTagSignature2String(TypeString, (cmsTagSignature) Type);
- _cmsTagSignature2String(SigString, sig);
-
- cmsSignalError(Icc ->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unsupported type '%s' for tag '%s'", TypeString, SigString);
- goto Error; // Should never happen
- }
-
-
- // Fill fields on icc structure
- Icc ->TagTypeHandlers[i] = TypeHandler;
- Icc ->TagNames[i] = sig;
- Icc ->TagSizes[i] = 0;
- Icc ->TagOffsets[i] = 0;
-
- LocalTypeHandler = *TypeHandler;
- LocalTypeHandler.ContextID = Icc ->ContextID;
- LocalTypeHandler.ICCVersion = Icc ->Version;
- Icc ->TagPtrs[i] = LocalTypeHandler.DupPtr(&LocalTypeHandler, data, TagDescriptor ->ElemCount);
-
- if (Icc ->TagPtrs[i] == NULL) {
-
- _cmsTagSignature2String(TypeString, (cmsTagSignature) Type);
- _cmsTagSignature2String(SigString, sig);
- cmsSignalError(Icc ->ContextID, cmsERROR_CORRUPTION_DETECTED, "Malformed struct in type '%s' for tag '%s'", TypeString, SigString);
-
- goto Error;
- }
-
- _cmsUnlockMutex(Icc->ContextID, Icc ->UsrMutex);
- return TRUE;
-
-Error:
- _cmsUnlockMutex(Icc->ContextID, Icc ->UsrMutex);
- return FALSE;
-
-}
-
-// Read and write raw data. Read/Write Raw/cooked pairs try to maintain consistency within the pair. Some sequences
-// raw/cooked would work, but at a cost. Data "cooked" may be converted to "raw" by using the "write" serialization logic.
-// In general it is better to avoid mixing pairs.
-
-cmsUInt32Number CMSEXPORT cmsReadRawTag(cmsHPROFILE hProfile, cmsTagSignature sig, void* data, cmsUInt32Number BufferSize)
-{
- _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
- void *Object;
- int i;
- cmsIOHANDLER* MemIO;
- cmsTagTypeHandler* TypeHandler = NULL;
- cmsTagTypeHandler LocalTypeHandler;
- cmsTagDescriptor* TagDescriptor = NULL;
- cmsUInt32Number rc;
- cmsUInt32Number Offset, TagSize;
-
- // Sanity check
- if (data != NULL && BufferSize == 0) return 0;
-
- if (!_cmsLockMutex(Icc->ContextID, Icc ->UsrMutex)) return 0;
-
- // Search for given tag in ICC profile directory
-
- i = _cmsSearchTag(Icc, sig, TRUE);
- if (i < 0) goto Error; // Not found,
-
- // It is already read?
- if (Icc -> TagPtrs[i] == NULL) {
-
- // Not yet, get original position
- Offset = Icc ->TagOffsets[i];
- TagSize = Icc ->TagSizes[i];
-
- // read the data directly, don't keep copy
-
- if (data != NULL) {
-
- if (BufferSize < TagSize)
- TagSize = BufferSize;
-
- if (!Icc ->IOhandler ->Seek(Icc ->IOhandler, Offset)) goto Error;
- if (!Icc ->IOhandler ->Read(Icc ->IOhandler, data, 1, TagSize)) goto Error;
-
- _cmsUnlockMutex(Icc->ContextID, Icc ->UsrMutex);
- return TagSize;
- }
-
- _cmsUnlockMutex(Icc->ContextID, Icc ->UsrMutex);
- return Icc ->TagSizes[i];
- }
-
- // The data has been already read, or written. But wait!, maybe the user choose to save as
- // raw data. In this case, return the raw data directly
-
- if (Icc ->TagSaveAsRaw[i]) {
-
- if (data != NULL) {
-
- TagSize = Icc ->TagSizes[i];
- if (BufferSize < TagSize)
- TagSize = BufferSize;
-
- memmove(data, Icc ->TagPtrs[i], TagSize);
-
- _cmsUnlockMutex(Icc->ContextID, Icc ->UsrMutex);
- return TagSize;
- }
-
- _cmsUnlockMutex(Icc->ContextID, Icc ->UsrMutex);
- return Icc ->TagSizes[i];
- }
-
- // Already read, or previously set by cmsWriteTag(). We need to serialize that
- // data to raw to get something that makes sense
-
- _cmsUnlockMutex(Icc->ContextID, Icc ->UsrMutex);
- Object = cmsReadTag(hProfile, sig);
- if (!_cmsLockMutex(Icc->ContextID, Icc ->UsrMutex)) return 0;
-
- if (Object == NULL) goto Error;
-
- // Now we need to serialize to a memory block: just use a memory iohandler
-
- if (data == NULL) {
- MemIO = cmsOpenIOhandlerFromNULL(cmsGetProfileContextID(hProfile));
- } else{
- MemIO = cmsOpenIOhandlerFromMem(cmsGetProfileContextID(hProfile), data, BufferSize, "w");
- }
- if (MemIO == NULL) goto Error;
-
- // Obtain type handling for the tag
- TypeHandler = Icc ->TagTypeHandlers[i];
- TagDescriptor = _cmsGetTagDescriptor(Icc-> ContextID, sig);
- if (TagDescriptor == NULL) {
- cmsCloseIOhandler(MemIO);
- goto Error;
- }
-
- if (TypeHandler == NULL) goto Error;
-
- // Serialize
- LocalTypeHandler = *TypeHandler;
- LocalTypeHandler.ContextID = Icc ->ContextID;
- LocalTypeHandler.ICCVersion = Icc ->Version;
-
- if (!_cmsWriteTypeBase(MemIO, TypeHandler ->Signature)) {
- cmsCloseIOhandler(MemIO);
- goto Error;
- }
-
- if (!LocalTypeHandler.WritePtr(&LocalTypeHandler, MemIO, Object, TagDescriptor ->ElemCount)) {
- cmsCloseIOhandler(MemIO);
- goto Error;
- }
-
- // Get Size and close
- rc = MemIO ->Tell(MemIO);
- cmsCloseIOhandler(MemIO); // Ignore return code this time
-
- _cmsUnlockMutex(Icc->ContextID, Icc ->UsrMutex);
- return rc;
-
-Error:
- _cmsUnlockMutex(Icc->ContextID, Icc ->UsrMutex);
- return 0;
-}
-
-// Similar to the anterior. This function allows to write directly to the ICC profile any data, without
-// checking anything. As a rule, mixing Raw with cooked doesn't work, so writing a tag as raw and then reading
-// it as cooked without serializing does result into an error. If that is what you want, you will need to dump
-// the profile to memry or disk and then reopen it.
-cmsBool CMSEXPORT cmsWriteRawTag(cmsHPROFILE hProfile, cmsTagSignature sig, const void* data, cmsUInt32Number Size)
-{
- _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
- int i;
-
- if (!_cmsLockMutex(Icc->ContextID, Icc ->UsrMutex)) return 0;
-
- if (!_cmsNewTag(Icc, sig, &i)) {
- _cmsUnlockMutex(Icc->ContextID, Icc ->UsrMutex);
- return FALSE;
- }
-
- // Mark the tag as being written as RAW
- Icc ->TagSaveAsRaw[i] = TRUE;
- Icc ->TagNames[i] = sig;
- Icc ->TagLinked[i] = (cmsTagSignature) 0;
-
- // Keep a copy of the block
- Icc ->TagPtrs[i] = _cmsDupMem(Icc ->ContextID, data, Size);
- Icc ->TagSizes[i] = Size;
-
- _cmsUnlockMutex(Icc->ContextID, Icc ->UsrMutex);
-
- if (Icc->TagPtrs[i] == NULL) {
- Icc->TagNames[i] = (cmsTagSignature) 0;
- return FALSE;
- }
- return TRUE;
-}
-
-// Using this function you can collapse several tag entries to the same block in the profile
-cmsBool CMSEXPORT cmsLinkTag(cmsHPROFILE hProfile, cmsTagSignature sig, cmsTagSignature dest)
-{
- _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
- int i;
-
- if (!_cmsLockMutex(Icc->ContextID, Icc ->UsrMutex)) return FALSE;
-
- if (!_cmsNewTag(Icc, sig, &i)) {
- _cmsUnlockMutex(Icc->ContextID, Icc ->UsrMutex);
- return FALSE;
- }
-
- // Keep necessary information
- Icc ->TagSaveAsRaw[i] = FALSE;
- Icc ->TagNames[i] = sig;
- Icc ->TagLinked[i] = dest;
-
- Icc ->TagPtrs[i] = NULL;
- Icc ->TagSizes[i] = 0;
- Icc ->TagOffsets[i] = 0;
-
- _cmsUnlockMutex(Icc->ContextID, Icc ->UsrMutex);
- return TRUE;
-}
-
-
-// Returns the tag linked to sig, in the case two tags are sharing same resource
-cmsTagSignature CMSEXPORT cmsTagLinkedTo(cmsHPROFILE hProfile, cmsTagSignature sig)
-{
- _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
- int i;
-
- // Search for given tag in ICC profile directory
- i = _cmsSearchTag(Icc, sig, FALSE);
- if (i < 0) return (cmsTagSignature) 0; // Not found, return 0
-
- return Icc -> TagLinked[i];
-}
diff --git a/contrib/libs/lcms2/src/cmsio1.c b/contrib/libs/lcms2/src/cmsio1.c
deleted file mode 100644
index c75b454cd5..0000000000
--- a/contrib/libs/lcms2/src/cmsio1.c
+++ /dev/null
@@ -1,1039 +0,0 @@
-//---------------------------------------------------------------------------------
-//
-// Little Color Management System
-// Copyright (c) 1998-2023 Marti Maria Saguer
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//---------------------------------------------------------------------------------
-//
-
-#include "lcms2_internal.h"
-
-// Read tags using low-level functions, provides necessary glue code to adapt versions, etc.
-
-// LUT tags
-static const cmsTagSignature Device2PCS16[] = {cmsSigAToB0Tag, // Perceptual
- cmsSigAToB1Tag, // Relative colorimetric
- cmsSigAToB2Tag, // Saturation
- cmsSigAToB1Tag }; // Absolute colorimetric
-
-static const cmsTagSignature Device2PCSFloat[] = {cmsSigDToB0Tag, // Perceptual
- cmsSigDToB1Tag, // Relative colorimetric
- cmsSigDToB2Tag, // Saturation
- cmsSigDToB3Tag }; // Absolute colorimetric
-
-static const cmsTagSignature PCS2Device16[] = {cmsSigBToA0Tag, // Perceptual
- cmsSigBToA1Tag, // Relative colorimetric
- cmsSigBToA2Tag, // Saturation
- cmsSigBToA1Tag }; // Absolute colorimetric
-
-static const cmsTagSignature PCS2DeviceFloat[] = {cmsSigBToD0Tag, // Perceptual
- cmsSigBToD1Tag, // Relative colorimetric
- cmsSigBToD2Tag, // Saturation
- cmsSigBToD3Tag }; // Absolute colorimetric
-
-
-// Factors to convert from 1.15 fixed point to 0..1.0 range and vice-versa
-#define InpAdj (1.0/MAX_ENCODEABLE_XYZ) // (65536.0/(65535.0*2.0))
-#define OutpAdj (MAX_ENCODEABLE_XYZ) // ((2.0*65535.0)/65536.0)
-
-// Several resources for gray conversions.
-static const cmsFloat64Number GrayInputMatrix[] = { (InpAdj*cmsD50X), (InpAdj*cmsD50Y), (InpAdj*cmsD50Z) };
-static const cmsFloat64Number OneToThreeInputMatrix[] = { 1, 1, 1 };
-static const cmsFloat64Number PickYMatrix[] = { 0, (OutpAdj*cmsD50Y), 0 };
-static const cmsFloat64Number PickLstarMatrix[] = { 1, 0, 0 };
-
-// Get a media white point fixing some issues found in certain old profiles
-cmsBool _cmsReadMediaWhitePoint(cmsCIEXYZ* Dest, cmsHPROFILE hProfile)
-{
- cmsCIEXYZ* Tag;
-
- _cmsAssert(Dest != NULL);
-
- Tag = (cmsCIEXYZ*) cmsReadTag(hProfile, cmsSigMediaWhitePointTag);
-
- // If no wp, take D50
- if (Tag == NULL) {
- *Dest = *cmsD50_XYZ();
- return TRUE;
- }
-
- // V2 display profiles should give D50
- if (cmsGetEncodedICCversion(hProfile) < 0x4000000) {
-
- if (cmsGetDeviceClass(hProfile) == cmsSigDisplayClass) {
- *Dest = *cmsD50_XYZ();
- return TRUE;
- }
- }
-
- // All seems ok
- *Dest = *Tag;
- return TRUE;
-}
-
-
-// Chromatic adaptation matrix. Fix some issues as well
-cmsBool _cmsReadCHAD(cmsMAT3* Dest, cmsHPROFILE hProfile)
-{
- cmsMAT3* Tag;
-
- _cmsAssert(Dest != NULL);
-
- Tag = (cmsMAT3*) cmsReadTag(hProfile, cmsSigChromaticAdaptationTag);
-
- if (Tag != NULL) {
- *Dest = *Tag;
- return TRUE;
- }
-
- // No CHAD available, default it to identity
- _cmsMAT3identity(Dest);
-
- // V2 display profiles should give D50
- if (cmsGetEncodedICCversion(hProfile) < 0x4000000) {
-
- if (cmsGetDeviceClass(hProfile) == cmsSigDisplayClass) {
-
- cmsCIEXYZ* White = (cmsCIEXYZ*) cmsReadTag(hProfile, cmsSigMediaWhitePointTag);
-
- if (White == NULL) {
-
- _cmsMAT3identity(Dest);
- return TRUE;
- }
-
- return _cmsAdaptationMatrix(Dest, NULL, White, cmsD50_XYZ());
- }
- }
-
- return TRUE;
-}
-
-
-// Auxiliary, read colorants as a MAT3 structure. Used by any function that needs a matrix-shaper
-static
-cmsBool ReadICCMatrixRGB2XYZ(cmsMAT3* r, cmsHPROFILE hProfile)
-{
- cmsCIEXYZ *PtrRed, *PtrGreen, *PtrBlue;
-
- _cmsAssert(r != NULL);
-
- PtrRed = (cmsCIEXYZ *) cmsReadTag(hProfile, cmsSigRedColorantTag);
- PtrGreen = (cmsCIEXYZ *) cmsReadTag(hProfile, cmsSigGreenColorantTag);
- PtrBlue = (cmsCIEXYZ *) cmsReadTag(hProfile, cmsSigBlueColorantTag);
-
- if (PtrRed == NULL || PtrGreen == NULL || PtrBlue == NULL)
- return FALSE;
-
- _cmsVEC3init(&r -> v[0], PtrRed -> X, PtrGreen -> X, PtrBlue -> X);
- _cmsVEC3init(&r -> v[1], PtrRed -> Y, PtrGreen -> Y, PtrBlue -> Y);
- _cmsVEC3init(&r -> v[2], PtrRed -> Z, PtrGreen -> Z, PtrBlue -> Z);
-
- return TRUE;
-}
-
-
-// Gray input pipeline
-static
-cmsPipeline* BuildGrayInputMatrixPipeline(cmsHPROFILE hProfile)
-{
- cmsToneCurve *GrayTRC;
- cmsPipeline* Lut;
- cmsContext ContextID = cmsGetProfileContextID(hProfile);
-
- GrayTRC = (cmsToneCurve *) cmsReadTag(hProfile, cmsSigGrayTRCTag);
- if (GrayTRC == NULL) return NULL;
-
- Lut = cmsPipelineAlloc(ContextID, 1, 3);
- if (Lut == NULL)
- goto Error;
-
- if (cmsGetPCS(hProfile) == cmsSigLabData) {
-
- // In this case we implement the profile as an identity matrix plus 3 tone curves
- cmsUInt16Number Zero[2] = { 0x8080, 0x8080 };
- cmsToneCurve* EmptyTab;
- cmsToneCurve* LabCurves[3];
-
- EmptyTab = cmsBuildTabulatedToneCurve16(ContextID, 2, Zero);
-
- if (EmptyTab == NULL)
- goto Error;
-
- LabCurves[0] = GrayTRC;
- LabCurves[1] = EmptyTab;
- LabCurves[2] = EmptyTab;
-
- if (!cmsPipelineInsertStage(Lut, cmsAT_END, cmsStageAllocMatrix(ContextID, 3, 1, OneToThreeInputMatrix, NULL)) ||
- !cmsPipelineInsertStage(Lut, cmsAT_END, cmsStageAllocToneCurves(ContextID, 3, LabCurves))) {
- cmsFreeToneCurve(EmptyTab);
- goto Error;
- }
-
- cmsFreeToneCurve(EmptyTab);
-
- }
- else {
-
- if (!cmsPipelineInsertStage(Lut, cmsAT_END, cmsStageAllocToneCurves(ContextID, 1, &GrayTRC)) ||
- !cmsPipelineInsertStage(Lut, cmsAT_END, cmsStageAllocMatrix(ContextID, 3, 1, GrayInputMatrix, NULL)))
- goto Error;
- }
-
- return Lut;
-
-Error:
- cmsPipelineFree(Lut);
- return NULL;
-}
-
-// RGB Matrix shaper
-static
-cmsPipeline* BuildRGBInputMatrixShaper(cmsHPROFILE hProfile)
-{
- cmsPipeline* Lut;
- cmsMAT3 Mat;
- cmsToneCurve *Shapes[3];
- cmsContext ContextID = cmsGetProfileContextID(hProfile);
- int i, j;
-
- if (!ReadICCMatrixRGB2XYZ(&Mat, hProfile)) return NULL;
-
- // XYZ PCS in encoded in 1.15 format, and the matrix output comes in 0..0xffff range, so
- // we need to adjust the output by a factor of (0x10000/0xffff) to put data in
- // a 1.16 range, and then a >> 1 to obtain 1.15. The total factor is (65536.0)/(65535.0*2)
-
- for (i=0; i < 3; i++)
- for (j=0; j < 3; j++)
- Mat.v[i].n[j] *= InpAdj;
-
-
- Shapes[0] = (cmsToneCurve *) cmsReadTag(hProfile, cmsSigRedTRCTag);
- Shapes[1] = (cmsToneCurve *) cmsReadTag(hProfile, cmsSigGreenTRCTag);
- Shapes[2] = (cmsToneCurve *) cmsReadTag(hProfile, cmsSigBlueTRCTag);
-
- if (!Shapes[0] || !Shapes[1] || !Shapes[2])
- return NULL;
-
- Lut = cmsPipelineAlloc(ContextID, 3, 3);
- if (Lut != NULL) {
-
- if (!cmsPipelineInsertStage(Lut, cmsAT_END, cmsStageAllocToneCurves(ContextID, 3, Shapes)) ||
- !cmsPipelineInsertStage(Lut, cmsAT_END, cmsStageAllocMatrix(ContextID, 3, 3, (cmsFloat64Number*) &Mat, NULL)))
- goto Error;
-
- // Note that it is certainly possible a single profile would have a LUT based
- // tag for output working in lab and a matrix-shaper for the fallback cases.
- // This is not allowed by the spec, but this code is tolerant to those cases
- if (cmsGetPCS(hProfile) == cmsSigLabData) {
-
- if (!cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageAllocXYZ2Lab(ContextID)))
- goto Error;
- }
-
- }
-
- return Lut;
-
-Error:
- cmsPipelineFree(Lut);
- return NULL;
-}
-
-
-
-// Read the DToAX tag, adjusting the encoding of Lab or XYZ if needed
-static
-cmsPipeline* _cmsReadFloatInputTag(cmsHPROFILE hProfile, cmsTagSignature tagFloat)
-{
- cmsContext ContextID = cmsGetProfileContextID(hProfile);
- cmsPipeline* Lut = cmsPipelineDup((cmsPipeline*) cmsReadTag(hProfile, tagFloat));
- cmsColorSpaceSignature spc = cmsGetColorSpace(hProfile);
- cmsColorSpaceSignature PCS = cmsGetPCS(hProfile);
-
- if (Lut == NULL) return NULL;
-
- // input and output of transform are in lcms 0..1 encoding. If XYZ or Lab spaces are used,
- // these need to be normalized into the appropriate ranges (Lab = 100,0,0, XYZ=1.0,1.0,1.0)
- if ( spc == cmsSigLabData)
- {
- if (!cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageNormalizeToLabFloat(ContextID)))
- goto Error;
- }
- else if (spc == cmsSigXYZData)
- {
- if (!cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageNormalizeToXyzFloat(ContextID)))
- goto Error;
- }
-
- if ( PCS == cmsSigLabData)
- {
- if (!cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageNormalizeFromLabFloat(ContextID)))
- goto Error;
- }
- else if( PCS == cmsSigXYZData)
- {
- if (!cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageNormalizeFromXyzFloat(ContextID)))
- goto Error;
- }
-
- return Lut;
-
-Error:
- cmsPipelineFree(Lut);
- return NULL;
-}
-
-
-// Read and create a BRAND NEW MPE LUT from a given profile. All stuff dependent of version, etc
-// is adjusted here in order to create a LUT that takes care of all those details.
-// We add intent = 0xffffffff as a way to read matrix shaper always, no matter of other LUT
-cmsPipeline* CMSEXPORT _cmsReadInputLUT(cmsHPROFILE hProfile, cmsUInt32Number Intent)
-{
- cmsTagTypeSignature OriginalType;
- cmsTagSignature tag16;
- cmsTagSignature tagFloat;
- cmsContext ContextID = cmsGetProfileContextID(hProfile);
-
- // On named color, take the appropriate tag
- if (cmsGetDeviceClass(hProfile) == cmsSigNamedColorClass) {
-
- cmsPipeline* Lut;
- cmsNAMEDCOLORLIST* nc = (cmsNAMEDCOLORLIST*) cmsReadTag(hProfile, cmsSigNamedColor2Tag);
-
- if (nc == NULL) return NULL;
-
- Lut = cmsPipelineAlloc(ContextID, 0, 0);
- if (Lut == NULL)
- return NULL;
-
- if (!cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageAllocNamedColor(nc, TRUE)) ||
- !cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageAllocLabV2ToV4(ContextID))) {
- cmsPipelineFree(Lut);
- return NULL;
- }
- return Lut;
- }
-
- // This is an attempt to reuse this function to retrieve the matrix-shaper as pipeline no
- // matter other LUT are present and have precedence. Intent = 0xffffffff can be used for that.
- if (Intent <= INTENT_ABSOLUTE_COLORIMETRIC) {
-
- tag16 = Device2PCS16[Intent];
- tagFloat = Device2PCSFloat[Intent];
-
- if (cmsIsTag(hProfile, tagFloat)) { // Float tag takes precedence
-
- // Floating point LUT are always V4, but the encoding range is no
- // longer 0..1.0, so we need to add an stage depending on the color space
- return _cmsReadFloatInputTag(hProfile, tagFloat);
- }
-
- // Revert to perceptual if no tag is found
- if (!cmsIsTag(hProfile, tag16)) {
- tag16 = Device2PCS16[0];
- }
-
- if (cmsIsTag(hProfile, tag16)) { // Is there any LUT-Based table?
-
- // Check profile version and LUT type. Do the necessary adjustments if needed
-
- // First read the tag
- cmsPipeline* Lut = (cmsPipeline*) cmsReadTag(hProfile, tag16);
- if (Lut == NULL) return NULL;
-
- // After reading it, we have now info about the original type
- OriginalType = _cmsGetTagTrueType(hProfile, tag16);
-
- // The profile owns the Lut, so we need to copy it
- Lut = cmsPipelineDup(Lut);
-
- // We need to adjust data only for Lab16 on output
- if (OriginalType != cmsSigLut16Type || cmsGetPCS(hProfile) != cmsSigLabData)
- return Lut;
-
- // If the input is Lab, add also a conversion at the begin
- if (cmsGetColorSpace(hProfile) == cmsSigLabData &&
- !cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageAllocLabV4ToV2(ContextID)))
- goto Error;
-
- // Add a matrix for conversion V2 to V4 Lab PCS
- if (!cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageAllocLabV2ToV4(ContextID)))
- goto Error;
-
- return Lut;
-Error:
- cmsPipelineFree(Lut);
- return NULL;
- }
- }
-
- // Lut was not found, try to create a matrix-shaper
-
- // Check if this is a grayscale profile.
- if (cmsGetColorSpace(hProfile) == cmsSigGrayData) {
-
- // if so, build appropriate conversion tables.
- // The tables are the PCS iluminant, scaled across GrayTRC
- return BuildGrayInputMatrixPipeline(hProfile);
- }
-
- // Not gray, create a normal matrix-shaper
- return BuildRGBInputMatrixShaper(hProfile);
-}
-
-// ---------------------------------------------------------------------------------------------------------------
-
-// Gray output pipeline.
-// XYZ -> Gray or Lab -> Gray. Since we only know the GrayTRC, we need to do some assumptions. Gray component will be
-// given by Y on XYZ PCS and by L* on Lab PCS, Both across inverse TRC curve.
-// The complete pipeline on XYZ is Matrix[3:1] -> Tone curve and in Lab Matrix[3:1] -> Tone Curve as well.
-
-static
-cmsPipeline* BuildGrayOutputPipeline(cmsHPROFILE hProfile)
-{
- cmsToneCurve *GrayTRC, *RevGrayTRC;
- cmsPipeline* Lut;
- cmsContext ContextID = cmsGetProfileContextID(hProfile);
-
- GrayTRC = (cmsToneCurve *) cmsReadTag(hProfile, cmsSigGrayTRCTag);
- if (GrayTRC == NULL) return NULL;
-
- RevGrayTRC = cmsReverseToneCurve(GrayTRC);
- if (RevGrayTRC == NULL) return NULL;
-
- Lut = cmsPipelineAlloc(ContextID, 3, 1);
- if (Lut == NULL) {
- cmsFreeToneCurve(RevGrayTRC);
- return NULL;
- }
-
- if (cmsGetPCS(hProfile) == cmsSigLabData) {
-
- if (!cmsPipelineInsertStage(Lut, cmsAT_END, cmsStageAllocMatrix(ContextID, 1, 3, PickLstarMatrix, NULL)))
- goto Error;
- }
- else {
- if (!cmsPipelineInsertStage(Lut, cmsAT_END, cmsStageAllocMatrix(ContextID, 1, 3, PickYMatrix, NULL)))
- goto Error;
- }
-
- if (!cmsPipelineInsertStage(Lut, cmsAT_END, cmsStageAllocToneCurves(ContextID, 1, &RevGrayTRC)))
- goto Error;
-
- cmsFreeToneCurve(RevGrayTRC);
- return Lut;
-
-Error:
- cmsFreeToneCurve(RevGrayTRC);
- cmsPipelineFree(Lut);
- return NULL;
-}
-
-
-static
-cmsPipeline* BuildRGBOutputMatrixShaper(cmsHPROFILE hProfile)
-{
- cmsPipeline* Lut;
- cmsToneCurve *Shapes[3], *InvShapes[3];
- cmsMAT3 Mat, Inv;
- int i, j;
- cmsContext ContextID = cmsGetProfileContextID(hProfile);
-
- if (!ReadICCMatrixRGB2XYZ(&Mat, hProfile))
- return NULL;
-
- if (!_cmsMAT3inverse(&Mat, &Inv))
- return NULL;
-
- // XYZ PCS in encoded in 1.15 format, and the matrix input should come in 0..0xffff range, so
- // we need to adjust the input by a << 1 to obtain a 1.16 fixed and then by a factor of
- // (0xffff/0x10000) to put data in 0..0xffff range. Total factor is (2.0*65535.0)/65536.0;
-
- for (i=0; i < 3; i++)
- for (j=0; j < 3; j++)
- Inv.v[i].n[j] *= OutpAdj;
-
- Shapes[0] = (cmsToneCurve *) cmsReadTag(hProfile, cmsSigRedTRCTag);
- Shapes[1] = (cmsToneCurve *) cmsReadTag(hProfile, cmsSigGreenTRCTag);
- Shapes[2] = (cmsToneCurve *) cmsReadTag(hProfile, cmsSigBlueTRCTag);
-
- if (!Shapes[0] || !Shapes[1] || !Shapes[2])
- return NULL;
-
- InvShapes[0] = cmsReverseToneCurve(Shapes[0]);
- InvShapes[1] = cmsReverseToneCurve(Shapes[1]);
- InvShapes[2] = cmsReverseToneCurve(Shapes[2]);
-
- if (!InvShapes[0] || !InvShapes[1] || !InvShapes[2]) {
- return NULL;
- }
-
- Lut = cmsPipelineAlloc(ContextID, 3, 3);
- if (Lut != NULL) {
-
- // Note that it is certainly possible a single profile would have a LUT based
- // tag for output working in lab and a matrix-shaper for the fallback cases.
- // This is not allowed by the spec, but this code is tolerant to those cases
- if (cmsGetPCS(hProfile) == cmsSigLabData) {
-
- if (!cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageAllocLab2XYZ(ContextID)))
- goto Error;
- }
-
- if (!cmsPipelineInsertStage(Lut, cmsAT_END, cmsStageAllocMatrix(ContextID, 3, 3, (cmsFloat64Number*) &Inv, NULL)) ||
- !cmsPipelineInsertStage(Lut, cmsAT_END, cmsStageAllocToneCurves(ContextID, 3, InvShapes)))
- goto Error;
- }
-
- cmsFreeToneCurveTriple(InvShapes);
- return Lut;
-Error:
- cmsFreeToneCurveTriple(InvShapes);
- cmsPipelineFree(Lut);
- return NULL;
-}
-
-
-// Change CLUT interpolation to trilinear
-static
-void ChangeInterpolationToTrilinear(cmsPipeline* Lut)
-{
- cmsStage* Stage;
-
- for (Stage = cmsPipelineGetPtrToFirstStage(Lut);
- Stage != NULL;
- Stage = cmsStageNext(Stage)) {
-
- if (cmsStageType(Stage) == cmsSigCLutElemType) {
-
- _cmsStageCLutData* CLUT = (_cmsStageCLutData*) Stage ->Data;
-
- CLUT ->Params->dwFlags |= CMS_LERP_FLAGS_TRILINEAR;
- _cmsSetInterpolationRoutine(Lut->ContextID, CLUT ->Params);
- }
- }
-}
-
-
-// Read the DToAX tag, adjusting the encoding of Lab or XYZ if needed
-static
-cmsPipeline* _cmsReadFloatOutputTag(cmsHPROFILE hProfile, cmsTagSignature tagFloat)
-{
- cmsContext ContextID = cmsGetProfileContextID(hProfile);
- cmsPipeline* Lut = cmsPipelineDup((cmsPipeline*) cmsReadTag(hProfile, tagFloat));
- cmsColorSpaceSignature PCS = cmsGetPCS(hProfile);
- cmsColorSpaceSignature dataSpace = cmsGetColorSpace(hProfile);
-
- if (Lut == NULL) return NULL;
-
- // If PCS is Lab or XYZ, the floating point tag is accepting data in the space encoding,
- // and since the formatter has already accommodated to 0..1.0, we should undo this change
- if ( PCS == cmsSigLabData)
- {
- if (!cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageNormalizeToLabFloat(ContextID)))
- goto Error;
- }
- else
- if (PCS == cmsSigXYZData)
- {
- if (!cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageNormalizeToXyzFloat(ContextID)))
- goto Error;
- }
-
- // the output can be Lab or XYZ, in which case normalisation is needed on the end of the pipeline
- if ( dataSpace == cmsSigLabData)
- {
- if (!cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageNormalizeFromLabFloat(ContextID)))
- goto Error;
- }
- else if (dataSpace == cmsSigXYZData)
- {
- if (!cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageNormalizeFromXyzFloat(ContextID)))
- goto Error;
- }
-
- return Lut;
-
-Error:
- cmsPipelineFree(Lut);
- return NULL;
-}
-
-// Create an output MPE LUT from a given profile. Version mismatches are handled here
-cmsPipeline* CMSEXPORT _cmsReadOutputLUT(cmsHPROFILE hProfile, cmsUInt32Number Intent)
-{
- cmsTagTypeSignature OriginalType;
- cmsTagSignature tag16;
- cmsTagSignature tagFloat;
- cmsContext ContextID = cmsGetProfileContextID(hProfile);
-
-
- if (Intent <= INTENT_ABSOLUTE_COLORIMETRIC) {
-
- tag16 = PCS2Device16[Intent];
- tagFloat = PCS2DeviceFloat[Intent];
-
- if (cmsIsTag(hProfile, tagFloat)) { // Float tag takes precedence
-
- // Floating point LUT are always V4
- return _cmsReadFloatOutputTag(hProfile, tagFloat);
- }
-
- // Revert to perceptual if no tag is found
- if (!cmsIsTag(hProfile, tag16)) {
- tag16 = PCS2Device16[0];
- }
-
- if (cmsIsTag(hProfile, tag16)) { // Is there any LUT-Based table?
-
- // Check profile version and LUT type. Do the necessary adjustments if needed
-
- // First read the tag
- cmsPipeline* Lut = (cmsPipeline*) cmsReadTag(hProfile, tag16);
- if (Lut == NULL) return NULL;
-
- // After reading it, we have info about the original type
- OriginalType = _cmsGetTagTrueType(hProfile, tag16);
-
- // The profile owns the Lut, so we need to copy it
- Lut = cmsPipelineDup(Lut);
- if (Lut == NULL) return NULL;
-
- // Now it is time for a controversial stuff. I found that for 3D LUTS using
- // Lab used as indexer space, trilinear interpolation should be used
- if (cmsGetPCS(hProfile) == cmsSigLabData)
- ChangeInterpolationToTrilinear(Lut);
-
- // We need to adjust data only for Lab and Lut16 type
- if (OriginalType != cmsSigLut16Type || cmsGetPCS(hProfile) != cmsSigLabData)
- return Lut;
-
- // Add a matrix for conversion V4 to V2 Lab PCS
- if (!cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageAllocLabV4ToV2(ContextID)))
- goto Error;
-
- // If the output is Lab, add also a conversion at the end
- if (cmsGetColorSpace(hProfile) == cmsSigLabData)
- if (!cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageAllocLabV2ToV4(ContextID)))
- goto Error;
-
- return Lut;
-Error:
- cmsPipelineFree(Lut);
- return NULL;
- }
- }
-
- // Lut not found, try to create a matrix-shaper
-
- // Check if this is a grayscale profile.
- if (cmsGetColorSpace(hProfile) == cmsSigGrayData) {
-
- // if so, build appropriate conversion tables.
- // The tables are the PCS iluminant, scaled across GrayTRC
- return BuildGrayOutputPipeline(hProfile);
- }
-
- // Not gray, create a normal matrix-shaper, which only operates in XYZ space
- return BuildRGBOutputMatrixShaper(hProfile);
-}
-
-// ---------------------------------------------------------------------------------------------------------------
-
-// Read the AToD0 tag, adjusting the encoding of Lab or XYZ if needed
-static
-cmsPipeline* _cmsReadFloatDevicelinkTag(cmsHPROFILE hProfile, cmsTagSignature tagFloat)
-{
- cmsContext ContextID = cmsGetProfileContextID(hProfile);
- cmsPipeline* Lut = cmsPipelineDup((cmsPipeline*)cmsReadTag(hProfile, tagFloat));
- cmsColorSpaceSignature PCS = cmsGetPCS(hProfile);
- cmsColorSpaceSignature spc = cmsGetColorSpace(hProfile);
-
- if (Lut == NULL) return NULL;
-
- if (spc == cmsSigLabData)
- {
- if (!cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageNormalizeToLabFloat(ContextID)))
- goto Error;
- }
- else
- if (spc == cmsSigXYZData)
- {
- if (!cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageNormalizeToXyzFloat(ContextID)))
- goto Error;
- }
-
- if (PCS == cmsSigLabData)
- {
- if (!cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageNormalizeFromLabFloat(ContextID)))
- goto Error;
- }
- else
- if (PCS == cmsSigXYZData)
- {
- if (!cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageNormalizeFromXyzFloat(ContextID)))
- goto Error;
- }
-
- return Lut;
-Error:
- cmsPipelineFree(Lut);
- return NULL;
-}
-
-// This one includes abstract profiles as well. Matrix-shaper cannot be obtained on that device class. The
-// tag name here may default to AToB0
-cmsPipeline* CMSEXPORT _cmsReadDevicelinkLUT(cmsHPROFILE hProfile, cmsUInt32Number Intent)
-{
- cmsPipeline* Lut;
- cmsTagTypeSignature OriginalType;
- cmsTagSignature tag16;
- cmsTagSignature tagFloat;
- cmsContext ContextID = cmsGetProfileContextID(hProfile);
-
-
- if (Intent > INTENT_ABSOLUTE_COLORIMETRIC)
- return NULL;
-
- tag16 = Device2PCS16[Intent];
- tagFloat = Device2PCSFloat[Intent];
-
- // On named color, take the appropriate tag
- if (cmsGetDeviceClass(hProfile) == cmsSigNamedColorClass) {
-
- cmsNAMEDCOLORLIST* nc = (cmsNAMEDCOLORLIST*)cmsReadTag(hProfile, cmsSigNamedColor2Tag);
-
- if (nc == NULL) return NULL;
-
- Lut = cmsPipelineAlloc(ContextID, 0, 0);
- if (Lut == NULL)
- goto Error;
-
- if (!cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageAllocNamedColor(nc, FALSE)))
- goto Error;
-
- if (cmsGetColorSpace(hProfile) == cmsSigLabData)
- if (!cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageAllocLabV2ToV4(ContextID)))
- goto Error;
-
- return Lut;
- Error:
- cmsPipelineFree(Lut);
- return NULL;
- }
-
-
- if (cmsIsTag(hProfile, tagFloat)) { // Float tag takes precedence
-
- // Floating point LUT are always V
- return _cmsReadFloatDevicelinkTag(hProfile, tagFloat);
- }
-
- tagFloat = Device2PCSFloat[0];
- if (cmsIsTag(hProfile, tagFloat)) {
-
- return cmsPipelineDup((cmsPipeline*)cmsReadTag(hProfile, tagFloat));
- }
-
- if (!cmsIsTag(hProfile, tag16)) { // Is there any LUT-Based table?
-
- tag16 = Device2PCS16[0];
- if (!cmsIsTag(hProfile, tag16)) return NULL;
- }
-
- // Check profile version and LUT type. Do the necessary adjustments if needed
-
- // Read the tag
- Lut = (cmsPipeline*)cmsReadTag(hProfile, tag16);
- if (Lut == NULL) return NULL;
-
- // The profile owns the Lut, so we need to copy it
- Lut = cmsPipelineDup(Lut);
- if (Lut == NULL) return NULL;
-
- // Now it is time for a controversial stuff. I found that for 3D LUTS using
- // Lab used as indexer space, trilinear interpolation should be used
- if (cmsGetPCS(hProfile) == cmsSigLabData)
- ChangeInterpolationToTrilinear(Lut);
-
- // After reading it, we have info about the original type
- OriginalType = _cmsGetTagTrueType(hProfile, tag16);
-
- // We need to adjust data for Lab16 on output
- if (OriginalType != cmsSigLut16Type) return Lut;
-
- // Here it is possible to get Lab on both sides
-
- if (cmsGetColorSpace(hProfile) == cmsSigLabData) {
- if (!cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageAllocLabV4ToV2(ContextID)))
- goto Error2;
- }
-
- if (cmsGetPCS(hProfile) == cmsSigLabData) {
- if (!cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageAllocLabV2ToV4(ContextID)))
- goto Error2;
- }
-
- return Lut;
-
-Error2:
- cmsPipelineFree(Lut);
- return NULL;
-}
-
-// ---------------------------------------------------------------------------------------------------------------
-
-// Returns TRUE if the profile is implemented as matrix-shaper
-cmsBool CMSEXPORT cmsIsMatrixShaper(cmsHPROFILE hProfile)
-{
- switch (cmsGetColorSpace(hProfile)) {
-
- case cmsSigGrayData:
-
- return cmsIsTag(hProfile, cmsSigGrayTRCTag);
-
- case cmsSigRgbData:
-
- return (cmsIsTag(hProfile, cmsSigRedColorantTag) &&
- cmsIsTag(hProfile, cmsSigGreenColorantTag) &&
- cmsIsTag(hProfile, cmsSigBlueColorantTag) &&
- cmsIsTag(hProfile, cmsSigRedTRCTag) &&
- cmsIsTag(hProfile, cmsSigGreenTRCTag) &&
- cmsIsTag(hProfile, cmsSigBlueTRCTag));
-
- default:
-
- return FALSE;
- }
-}
-
-// Returns TRUE if the intent is implemented as CLUT
-cmsBool CMSEXPORT cmsIsCLUT(cmsHPROFILE hProfile, cmsUInt32Number Intent, cmsUInt32Number UsedDirection)
-{
- const cmsTagSignature* TagTable;
-
- // For devicelinks, the supported intent is that one stated in the header
- if (cmsGetDeviceClass(hProfile) == cmsSigLinkClass) {
- return (cmsGetHeaderRenderingIntent(hProfile) == Intent);
- }
-
- switch (UsedDirection) {
-
- case LCMS_USED_AS_INPUT: TagTable = Device2PCS16; break;
- case LCMS_USED_AS_OUTPUT:TagTable = PCS2Device16; break;
-
- // For proofing, we need rel. colorimetric in output. Let's do some recursion
- case LCMS_USED_AS_PROOF:
- return cmsIsIntentSupported(hProfile, Intent, LCMS_USED_AS_INPUT) &&
- cmsIsIntentSupported(hProfile, INTENT_RELATIVE_COLORIMETRIC, LCMS_USED_AS_OUTPUT);
-
- default:
- cmsSignalError(cmsGetProfileContextID(hProfile), cmsERROR_RANGE, "Unexpected direction (%d)", UsedDirection);
- return FALSE;
- }
-
- // Extended intents are not strictly CLUT-based
- if (Intent > INTENT_ABSOLUTE_COLORIMETRIC)
- return FALSE;
-
- return cmsIsTag(hProfile, TagTable[Intent]);
-
-}
-
-
-// Return info about supported intents
-cmsBool CMSEXPORT cmsIsIntentSupported(cmsHPROFILE hProfile,
- cmsUInt32Number Intent, cmsUInt32Number UsedDirection)
-{
-
- if (cmsIsCLUT(hProfile, Intent, UsedDirection)) return TRUE;
-
- // Is there any matrix-shaper? If so, the intent is supported. This is a bit odd, since V2 matrix shaper
- // does not fully support relative colorimetric because they cannot deal with non-zero black points, but
- // many profiles claims that, and this is certainly not true for V4 profiles. Lets answer "yes" no matter
- // the accuracy would be less than optimal in rel.col and v2 case.
-
- return cmsIsMatrixShaper(hProfile);
-}
-
-
-// ---------------------------------------------------------------------------------------------------------------
-
-// Read both, profile sequence description and profile sequence id if present. Then combine both to
-// create qa unique structure holding both. Shame on ICC to store things in such complicated way.
-cmsSEQ* _cmsReadProfileSequence(cmsHPROFILE hProfile)
-{
- cmsSEQ* ProfileSeq;
- cmsSEQ* ProfileId;
- cmsSEQ* NewSeq;
- cmsUInt32Number i;
-
- // Take profile sequence description first
- ProfileSeq = (cmsSEQ*) cmsReadTag(hProfile, cmsSigProfileSequenceDescTag);
-
- // Take profile sequence ID
- ProfileId = (cmsSEQ*) cmsReadTag(hProfile, cmsSigProfileSequenceIdTag);
-
- if (ProfileSeq == NULL && ProfileId == NULL) return NULL;
-
- if (ProfileSeq == NULL) return cmsDupProfileSequenceDescription(ProfileId);
- if (ProfileId == NULL) return cmsDupProfileSequenceDescription(ProfileSeq);
-
- // We have to mix both together. For that they must agree
- if (ProfileSeq ->n != ProfileId ->n) return cmsDupProfileSequenceDescription(ProfileSeq);
-
- NewSeq = cmsDupProfileSequenceDescription(ProfileSeq);
-
- // Ok, proceed to the mixing
- if (NewSeq != NULL) {
- for (i=0; i < ProfileSeq ->n; i++) {
-
- memmove(&NewSeq ->seq[i].ProfileID, &ProfileId ->seq[i].ProfileID, sizeof(cmsProfileID));
- NewSeq ->seq[i].Description = cmsMLUdup(ProfileId ->seq[i].Description);
- }
- }
- return NewSeq;
-}
-
-// Dump the contents of profile sequence in both tags (if v4 available)
-cmsBool _cmsWriteProfileSequence(cmsHPROFILE hProfile, const cmsSEQ* seq)
-{
- if (!cmsWriteTag(hProfile, cmsSigProfileSequenceDescTag, seq)) return FALSE;
-
- if (cmsGetEncodedICCversion(hProfile) >= 0x4000000) {
-
- if (!cmsWriteTag(hProfile, cmsSigProfileSequenceIdTag, seq)) return FALSE;
- }
-
- return TRUE;
-}
-
-
-// Auxiliary, read and duplicate a MLU if found.
-static
-cmsMLU* GetMLUFromProfile(cmsHPROFILE h, cmsTagSignature sig)
-{
- cmsMLU* mlu = (cmsMLU*) cmsReadTag(h, sig);
- if (mlu == NULL) return NULL;
-
- return cmsMLUdup(mlu);
-}
-
-// Create a sequence description out of an array of profiles
-cmsSEQ* _cmsCompileProfileSequence(cmsContext ContextID, cmsUInt32Number nProfiles, cmsHPROFILE hProfiles[])
-{
- cmsUInt32Number i;
- cmsSEQ* seq = cmsAllocProfileSequenceDescription(ContextID, nProfiles);
-
- if (seq == NULL) return NULL;
-
- for (i=0; i < nProfiles; i++) {
-
- cmsPSEQDESC* ps = &seq ->seq[i];
- cmsHPROFILE h = hProfiles[i];
- cmsTechnologySignature* techpt;
-
- cmsGetHeaderAttributes(h, &ps ->attributes);
- cmsGetHeaderProfileID(h, ps ->ProfileID.ID8);
- ps ->deviceMfg = cmsGetHeaderManufacturer(h);
- ps ->deviceModel = cmsGetHeaderModel(h);
-
- techpt = (cmsTechnologySignature*) cmsReadTag(h, cmsSigTechnologyTag);
- if (techpt == NULL)
- ps ->technology = (cmsTechnologySignature) 0;
- else
- ps ->technology = *techpt;
-
- ps ->Manufacturer = GetMLUFromProfile(h, cmsSigDeviceMfgDescTag);
- ps ->Model = GetMLUFromProfile(h, cmsSigDeviceModelDescTag);
- ps ->Description = GetMLUFromProfile(h, cmsSigProfileDescriptionTag);
-
- }
-
- return seq;
-}
-
-// -------------------------------------------------------------------------------------------------------------------
-
-
-static
-const cmsMLU* GetInfo(cmsHPROFILE hProfile, cmsInfoType Info)
-{
- cmsTagSignature sig;
-
- switch (Info) {
-
- case cmsInfoDescription:
- sig = cmsSigProfileDescriptionTag;
- break;
-
- case cmsInfoManufacturer:
- sig = cmsSigDeviceMfgDescTag;
- break;
-
- case cmsInfoModel:
- sig = cmsSigDeviceModelDescTag;
- break;
-
- case cmsInfoCopyright:
- sig = cmsSigCopyrightTag;
- break;
-
- default: return NULL;
- }
-
-
- return (cmsMLU*) cmsReadTag(hProfile, sig);
-}
-
-
-
-cmsUInt32Number CMSEXPORT cmsGetProfileInfo(cmsHPROFILE hProfile, cmsInfoType Info,
- const char LanguageCode[3], const char CountryCode[3],
- wchar_t* Buffer, cmsUInt32Number BufferSize)
-{
- const cmsMLU* mlu = GetInfo(hProfile, Info);
- if (mlu == NULL) return 0;
-
- return cmsMLUgetWide(mlu, LanguageCode, CountryCode, Buffer, BufferSize);
-}
-
-
-cmsUInt32Number CMSEXPORT cmsGetProfileInfoASCII(cmsHPROFILE hProfile, cmsInfoType Info,
- const char LanguageCode[3], const char CountryCode[3],
- char* Buffer, cmsUInt32Number BufferSize)
-{
- const cmsMLU* mlu = GetInfo(hProfile, Info);
- if (mlu == NULL) return 0;
-
- return cmsMLUgetASCII(mlu, LanguageCode, CountryCode, Buffer, BufferSize);
-}
-
-cmsUInt32Number CMSEXPORT cmsGetProfileInfoUTF8(cmsHPROFILE hProfile, cmsInfoType Info,
- const char LanguageCode[3], const char CountryCode[3],
- char* Buffer, cmsUInt32Number BufferSize)
-{
- const cmsMLU* mlu = GetInfo(hProfile, Info);
- if (mlu == NULL) return 0;
-
- return cmsMLUgetUTF8(mlu, LanguageCode, CountryCode, Buffer, BufferSize);
-}
diff --git a/contrib/libs/lcms2/src/cmslut.c b/contrib/libs/lcms2/src/cmslut.c
deleted file mode 100644
index 1ea61a806b..0000000000
--- a/contrib/libs/lcms2/src/cmslut.c
+++ /dev/null
@@ -1,1851 +0,0 @@
-//---------------------------------------------------------------------------------
-//
-// Little Color Management System
-// Copyright (c) 1998-2023 Marti Maria Saguer
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//---------------------------------------------------------------------------------
-//
-
-#include "lcms2_internal.h"
-
-
-// Allocates an empty multi profile element
-cmsStage* CMSEXPORT _cmsStageAllocPlaceholder(cmsContext ContextID,
- cmsStageSignature Type,
- cmsUInt32Number InputChannels,
- cmsUInt32Number OutputChannels,
- _cmsStageEvalFn EvalPtr,
- _cmsStageDupElemFn DupElemPtr,
- _cmsStageFreeElemFn FreePtr,
- void* Data)
-{
- cmsStage* ph = (cmsStage*) _cmsMallocZero(ContextID, sizeof(cmsStage));
-
- if (ph == NULL) return NULL;
-
-
- ph ->ContextID = ContextID;
-
- ph ->Type = Type;
- ph ->Implements = Type; // By default, no clue on what is implementing
-
- ph ->InputChannels = InputChannels;
- ph ->OutputChannels = OutputChannels;
- ph ->EvalPtr = EvalPtr;
- ph ->DupElemPtr = DupElemPtr;
- ph ->FreePtr = FreePtr;
- ph ->Data = Data;
-
- return ph;
-}
-
-
-static
-void EvaluateIdentity(const cmsFloat32Number In[],
- cmsFloat32Number Out[],
- const cmsStage *mpe)
-{
- memmove(Out, In, mpe ->InputChannels * sizeof(cmsFloat32Number));
-}
-
-
-cmsStage* CMSEXPORT cmsStageAllocIdentity(cmsContext ContextID, cmsUInt32Number nChannels)
-{
- return _cmsStageAllocPlaceholder(ContextID,
- cmsSigIdentityElemType,
- nChannels, nChannels,
- EvaluateIdentity,
- NULL,
- NULL,
- NULL);
- }
-
-// Conversion functions. From floating point to 16 bits
-static
-void FromFloatTo16(const cmsFloat32Number In[], cmsUInt16Number Out[], cmsUInt32Number n)
-{
- cmsUInt32Number i;
-
- for (i=0; i < n; i++) {
- Out[i] = _cmsQuickSaturateWord(In[i] * 65535.0);
- }
-}
-
-// From 16 bits to floating point
-static
-void From16ToFloat(const cmsUInt16Number In[], cmsFloat32Number Out[], cmsUInt32Number n)
-{
- cmsUInt32Number i;
-
- for (i=0; i < n; i++) {
- Out[i] = (cmsFloat32Number) In[i] / 65535.0F;
- }
-}
-
-
-// This function is quite useful to analyze the structure of a LUT and retrieve the MPE elements
-// that conform the LUT. It should be called with the LUT, the number of expected elements and
-// then a list of expected types followed with a list of cmsFloat64Number pointers to MPE elements. If
-// the function founds a match with current pipeline, it fills the pointers and returns TRUE
-// if not, returns FALSE without touching anything. Setting pointers to NULL does bypass
-// the storage process.
-cmsBool CMSEXPORT cmsPipelineCheckAndRetreiveStages(const cmsPipeline* Lut, cmsUInt32Number n, ...)
-{
- va_list args;
- cmsUInt32Number i;
- cmsStage* mpe;
- cmsStageSignature Type;
- void** ElemPtr;
-
- // Make sure same number of elements
- if (cmsPipelineStageCount(Lut) != n) return FALSE;
-
- va_start(args, n);
-
- // Iterate across asked types
- mpe = Lut ->Elements;
- for (i=0; i < n; i++) {
-
- // Get asked type. cmsStageSignature is promoted to int by compiler
- Type = (cmsStageSignature)va_arg(args, int);
- if (mpe ->Type != Type) {
-
- va_end(args); // Mismatch. We are done.
- return FALSE;
- }
- mpe = mpe ->Next;
- }
-
- // Found a combination, fill pointers if not NULL
- mpe = Lut ->Elements;
- for (i=0; i < n; i++) {
-
- ElemPtr = va_arg(args, void**);
- if (ElemPtr != NULL)
- *ElemPtr = mpe;
-
- mpe = mpe ->Next;
- }
-
- va_end(args);
- return TRUE;
-}
-
-// Below there are implementations for several types of elements. Each type may be implemented by a
-// evaluation function, a duplication function, a function to free resources and a constructor.
-
-// *************************************************************************************************
-// Type cmsSigCurveSetElemType (curves)
-// *************************************************************************************************
-
-cmsToneCurve** _cmsStageGetPtrToCurveSet(const cmsStage* mpe)
-{
- _cmsStageToneCurvesData* Data = (_cmsStageToneCurvesData*) mpe ->Data;
-
- return Data ->TheCurves;
-}
-
-static
-void EvaluateCurves(const cmsFloat32Number In[],
- cmsFloat32Number Out[],
- const cmsStage *mpe)
-{
- _cmsStageToneCurvesData* Data;
- cmsUInt32Number i;
-
- _cmsAssert(mpe != NULL);
-
- Data = (_cmsStageToneCurvesData*) mpe ->Data;
- if (Data == NULL) return;
-
- if (Data ->TheCurves == NULL) return;
-
- for (i=0; i < Data ->nCurves; i++) {
- Out[i] = cmsEvalToneCurveFloat(Data ->TheCurves[i], In[i]);
- }
-}
-
-static
-void CurveSetElemTypeFree(cmsStage* mpe)
-{
- _cmsStageToneCurvesData* Data;
- cmsUInt32Number i;
-
- _cmsAssert(mpe != NULL);
-
- Data = (_cmsStageToneCurvesData*) mpe ->Data;
- if (Data == NULL) return;
-
- if (Data ->TheCurves != NULL) {
- for (i=0; i < Data ->nCurves; i++) {
- if (Data ->TheCurves[i] != NULL)
- cmsFreeToneCurve(Data ->TheCurves[i]);
- }
- }
- _cmsFree(mpe ->ContextID, Data ->TheCurves);
- _cmsFree(mpe ->ContextID, Data);
-}
-
-
-static
-void* CurveSetDup(cmsStage* mpe)
-{
- _cmsStageToneCurvesData* Data = (_cmsStageToneCurvesData*) mpe ->Data;
- _cmsStageToneCurvesData* NewElem;
- cmsUInt32Number i;
-
- NewElem = (_cmsStageToneCurvesData*) _cmsMallocZero(mpe ->ContextID, sizeof(_cmsStageToneCurvesData));
- if (NewElem == NULL) return NULL;
-
- NewElem ->nCurves = Data ->nCurves;
- NewElem ->TheCurves = (cmsToneCurve**) _cmsCalloc(mpe ->ContextID, NewElem ->nCurves, sizeof(cmsToneCurve*));
-
- if (NewElem ->TheCurves == NULL) goto Error;
-
- for (i=0; i < NewElem ->nCurves; i++) {
-
- // Duplicate each curve. It may fail.
- NewElem ->TheCurves[i] = cmsDupToneCurve(Data ->TheCurves[i]);
- if (NewElem ->TheCurves[i] == NULL) goto Error;
-
-
- }
- return (void*) NewElem;
-
-Error:
-
- if (NewElem ->TheCurves != NULL) {
- for (i=0; i < NewElem ->nCurves; i++) {
- if (NewElem ->TheCurves[i])
- cmsFreeToneCurve(NewElem ->TheCurves[i]);
- }
- }
- _cmsFree(mpe ->ContextID, NewElem ->TheCurves);
- _cmsFree(mpe ->ContextID, NewElem);
- return NULL;
-}
-
-
-// Curves == NULL forces identity curves
-cmsStage* CMSEXPORT cmsStageAllocToneCurves(cmsContext ContextID, cmsUInt32Number nChannels, cmsToneCurve* const Curves[])
-{
- cmsUInt32Number i;
- _cmsStageToneCurvesData* NewElem;
- cmsStage* NewMPE;
-
-
- NewMPE = _cmsStageAllocPlaceholder(ContextID, cmsSigCurveSetElemType, nChannels, nChannels,
- EvaluateCurves, CurveSetDup, CurveSetElemTypeFree, NULL );
- if (NewMPE == NULL) return NULL;
-
- NewElem = (_cmsStageToneCurvesData*) _cmsMallocZero(ContextID, sizeof(_cmsStageToneCurvesData));
- if (NewElem == NULL) {
- cmsStageFree(NewMPE);
- return NULL;
- }
-
- NewMPE ->Data = (void*) NewElem;
-
- NewElem ->nCurves = nChannels;
- NewElem ->TheCurves = (cmsToneCurve**) _cmsCalloc(ContextID, nChannels, sizeof(cmsToneCurve*));
- if (NewElem ->TheCurves == NULL) {
- cmsStageFree(NewMPE);
- return NULL;
- }
-
- for (i=0; i < nChannels; i++) {
-
- if (Curves == NULL) {
- NewElem ->TheCurves[i] = cmsBuildGamma(ContextID, 1.0);
- }
- else {
- NewElem ->TheCurves[i] = cmsDupToneCurve(Curves[i]);
- }
-
- if (NewElem ->TheCurves[i] == NULL) {
- cmsStageFree(NewMPE);
- return NULL;
- }
-
- }
-
- return NewMPE;
-}
-
-
-// Create a bunch of identity curves
-cmsStage* CMSEXPORT _cmsStageAllocIdentityCurves(cmsContext ContextID, cmsUInt32Number nChannels)
-{
- cmsStage* mpe = cmsStageAllocToneCurves(ContextID, nChannels, NULL);
-
- if (mpe == NULL) return NULL;
- mpe ->Implements = cmsSigIdentityElemType;
- return mpe;
-}
-
-
-// *************************************************************************************************
-// Type cmsSigMatrixElemType (Matrices)
-// *************************************************************************************************
-
-
-// Special care should be taken here because precision loss. A temporary cmsFloat64Number buffer is being used
-static
-void EvaluateMatrix(const cmsFloat32Number In[],
- cmsFloat32Number Out[],
- const cmsStage *mpe)
-{
- cmsUInt32Number i, j;
- _cmsStageMatrixData* Data = (_cmsStageMatrixData*) mpe ->Data;
- cmsFloat64Number Tmp;
-
- // Input is already in 0..1.0 notation
- for (i=0; i < mpe ->OutputChannels; i++) {
-
- Tmp = 0;
- for (j=0; j < mpe->InputChannels; j++) {
- Tmp += In[j] * Data->Double[i*mpe->InputChannels + j];
- }
-
- if (Data ->Offset != NULL)
- Tmp += Data->Offset[i];
-
- Out[i] = (cmsFloat32Number) Tmp;
- }
-
-
- // Output in 0..1.0 domain
-}
-
-
-// Duplicate a yet-existing matrix element
-static
-void* MatrixElemDup(cmsStage* mpe)
-{
- _cmsStageMatrixData* Data = (_cmsStageMatrixData*) mpe ->Data;
- _cmsStageMatrixData* NewElem;
- cmsUInt32Number sz;
-
- NewElem = (_cmsStageMatrixData*) _cmsMallocZero(mpe ->ContextID, sizeof(_cmsStageMatrixData));
- if (NewElem == NULL) return NULL;
-
- sz = mpe ->InputChannels * mpe ->OutputChannels;
-
- NewElem ->Double = (cmsFloat64Number*) _cmsDupMem(mpe ->ContextID, Data ->Double, sz * sizeof(cmsFloat64Number)) ;
-
- if (Data ->Offset)
- NewElem ->Offset = (cmsFloat64Number*) _cmsDupMem(mpe ->ContextID,
- Data ->Offset, mpe -> OutputChannels * sizeof(cmsFloat64Number)) ;
-
- return (void*) NewElem;
-}
-
-
-static
-void MatrixElemTypeFree(cmsStage* mpe)
-{
- _cmsStageMatrixData* Data = (_cmsStageMatrixData*) mpe ->Data;
- if (Data == NULL)
- return;
- if (Data ->Double)
- _cmsFree(mpe ->ContextID, Data ->Double);
-
- if (Data ->Offset)
- _cmsFree(mpe ->ContextID, Data ->Offset);
-
- _cmsFree(mpe ->ContextID, mpe ->Data);
-}
-
-
-
-cmsStage* CMSEXPORT cmsStageAllocMatrix(cmsContext ContextID, cmsUInt32Number Rows, cmsUInt32Number Cols,
- const cmsFloat64Number* Matrix, const cmsFloat64Number* Offset)
-{
- cmsUInt32Number i, n;
- _cmsStageMatrixData* NewElem;
- cmsStage* NewMPE;
-
- n = Rows * Cols;
-
- // Check for overflow
- if (n == 0) return NULL;
- if (n >= UINT_MAX / Cols) return NULL;
- if (n >= UINT_MAX / Rows) return NULL;
- if (n < Rows || n < Cols) return NULL;
-
- NewMPE = _cmsStageAllocPlaceholder(ContextID, cmsSigMatrixElemType, Cols, Rows,
- EvaluateMatrix, MatrixElemDup, MatrixElemTypeFree, NULL );
- if (NewMPE == NULL) return NULL;
-
-
- NewElem = (_cmsStageMatrixData*) _cmsMallocZero(ContextID, sizeof(_cmsStageMatrixData));
- if (NewElem == NULL) goto Error;
- NewMPE->Data = (void*)NewElem;
-
- NewElem ->Double = (cmsFloat64Number*) _cmsCalloc(ContextID, n, sizeof(cmsFloat64Number));
- if (NewElem->Double == NULL) goto Error;
-
- for (i=0; i < n; i++) {
- NewElem ->Double[i] = Matrix[i];
- }
-
- if (Offset != NULL) {
-
- NewElem ->Offset = (cmsFloat64Number*) _cmsCalloc(ContextID, Rows, sizeof(cmsFloat64Number));
- if (NewElem->Offset == NULL) goto Error;
-
- for (i=0; i < Rows; i++) {
- NewElem ->Offset[i] = Offset[i];
- }
- }
-
- return NewMPE;
-
-Error:
- cmsStageFree(NewMPE);
- return NULL;
-}
-
-
-// *************************************************************************************************
-// Type cmsSigCLutElemType
-// *************************************************************************************************
-
-
-// Evaluate in true floating point
-static
-void EvaluateCLUTfloat(const cmsFloat32Number In[], cmsFloat32Number Out[], const cmsStage *mpe)
-{
- _cmsStageCLutData* Data = (_cmsStageCLutData*) mpe ->Data;
-
- Data -> Params ->Interpolation.LerpFloat(In, Out, Data->Params);
-}
-
-
-// Convert to 16 bits, evaluate, and back to floating point
-static
-void EvaluateCLUTfloatIn16(const cmsFloat32Number In[], cmsFloat32Number Out[], const cmsStage *mpe)
-{
- _cmsStageCLutData* Data = (_cmsStageCLutData*) mpe ->Data;
- cmsUInt16Number In16[MAX_STAGE_CHANNELS], Out16[MAX_STAGE_CHANNELS];
-
- _cmsAssert(mpe ->InputChannels <= MAX_STAGE_CHANNELS);
- _cmsAssert(mpe ->OutputChannels <= MAX_STAGE_CHANNELS);
-
- FromFloatTo16(In, In16, mpe ->InputChannels);
- Data -> Params ->Interpolation.Lerp16(In16, Out16, Data->Params);
- From16ToFloat(Out16, Out, mpe ->OutputChannels);
-}
-
-
-// Given an hypercube of b dimensions, with Dims[] number of nodes by dimension, calculate the total amount of nodes
-static
-cmsUInt32Number CubeSize(const cmsUInt32Number Dims[], cmsUInt32Number b)
-{
- cmsUInt32Number rv, dim;
-
- _cmsAssert(Dims != NULL);
-
- for (rv = 1; b > 0; b--) {
-
- dim = Dims[b-1];
- if (dim <= 1) return 0; // Error
-
- rv *= dim;
-
- // Check for overflow
- if (rv > UINT_MAX / dim) return 0;
- }
-
- // Again, prevent overflow
- if (rv > UINT_MAX / 15) return 0;
-
- return rv;
-}
-
-static
-void* CLUTElemDup(cmsStage* mpe)
-{
- _cmsStageCLutData* Data = (_cmsStageCLutData*) mpe ->Data;
- _cmsStageCLutData* NewElem;
-
-
- NewElem = (_cmsStageCLutData*) _cmsMallocZero(mpe ->ContextID, sizeof(_cmsStageCLutData));
- if (NewElem == NULL) return NULL;
-
- NewElem ->nEntries = Data ->nEntries;
- NewElem ->HasFloatValues = Data ->HasFloatValues;
-
- if (Data ->Tab.T) {
-
- if (Data ->HasFloatValues) {
- NewElem ->Tab.TFloat = (cmsFloat32Number*) _cmsDupMem(mpe ->ContextID, Data ->Tab.TFloat, Data ->nEntries * sizeof (cmsFloat32Number));
- if (NewElem ->Tab.TFloat == NULL)
- goto Error;
- } else {
- NewElem ->Tab.T = (cmsUInt16Number*) _cmsDupMem(mpe ->ContextID, Data ->Tab.T, Data ->nEntries * sizeof (cmsUInt16Number));
- if (NewElem ->Tab.T == NULL)
- goto Error;
- }
- }
-
- NewElem ->Params = _cmsComputeInterpParamsEx(mpe ->ContextID,
- Data ->Params ->nSamples,
- Data ->Params ->nInputs,
- Data ->Params ->nOutputs,
- NewElem ->Tab.T,
- Data ->Params ->dwFlags);
- if (NewElem->Params != NULL)
- return (void*) NewElem;
- Error:
- if (NewElem->Tab.T)
- // This works for both types
- _cmsFree(mpe ->ContextID, NewElem -> Tab.T);
- _cmsFree(mpe ->ContextID, NewElem);
- return NULL;
-}
-
-
-static
-void CLutElemTypeFree(cmsStage* mpe)
-{
-
- _cmsStageCLutData* Data = (_cmsStageCLutData*) mpe ->Data;
-
- // Already empty
- if (Data == NULL) return;
-
- // This works for both types
- if (Data -> Tab.T)
- _cmsFree(mpe ->ContextID, Data -> Tab.T);
-
- _cmsFreeInterpParams(Data ->Params);
- _cmsFree(mpe ->ContextID, mpe ->Data);
-}
-
-
-// Allocates a 16-bit multidimensional CLUT. This is evaluated at 16-bit precision. Table may have different
-// granularity on each dimension.
-cmsStage* CMSEXPORT cmsStageAllocCLut16bitGranular(cmsContext ContextID,
- const cmsUInt32Number clutPoints[],
- cmsUInt32Number inputChan,
- cmsUInt32Number outputChan,
- const cmsUInt16Number* Table)
-{
- cmsUInt32Number i, n;
- _cmsStageCLutData* NewElem;
- cmsStage* NewMPE;
-
- _cmsAssert(clutPoints != NULL);
-
- if (inputChan > MAX_INPUT_DIMENSIONS) {
- cmsSignalError(ContextID, cmsERROR_RANGE, "Too many input channels (%d channels, max=%d)", inputChan, MAX_INPUT_DIMENSIONS);
- return NULL;
- }
-
- NewMPE = _cmsStageAllocPlaceholder(ContextID, cmsSigCLutElemType, inputChan, outputChan,
- EvaluateCLUTfloatIn16, CLUTElemDup, CLutElemTypeFree, NULL );
-
- if (NewMPE == NULL) return NULL;
-
- NewElem = (_cmsStageCLutData*) _cmsMallocZero(ContextID, sizeof(_cmsStageCLutData));
- if (NewElem == NULL) {
- cmsStageFree(NewMPE);
- return NULL;
- }
-
- NewMPE ->Data = (void*) NewElem;
-
- NewElem -> nEntries = n = outputChan * CubeSize(clutPoints, inputChan);
- NewElem -> HasFloatValues = FALSE;
-
- if (n == 0) {
- cmsStageFree(NewMPE);
- return NULL;
- }
-
-
- NewElem ->Tab.T = (cmsUInt16Number*) _cmsCalloc(ContextID, n, sizeof(cmsUInt16Number));
- if (NewElem ->Tab.T == NULL) {
- cmsStageFree(NewMPE);
- return NULL;
- }
-
- if (Table != NULL) {
- for (i=0; i < n; i++) {
- NewElem ->Tab.T[i] = Table[i];
- }
- }
-
- NewElem ->Params = _cmsComputeInterpParamsEx(ContextID, clutPoints, inputChan, outputChan, NewElem ->Tab.T, CMS_LERP_FLAGS_16BITS);
- if (NewElem ->Params == NULL) {
- cmsStageFree(NewMPE);
- return NULL;
- }
-
- return NewMPE;
-}
-
-cmsStage* CMSEXPORT cmsStageAllocCLut16bit(cmsContext ContextID,
- cmsUInt32Number nGridPoints,
- cmsUInt32Number inputChan,
- cmsUInt32Number outputChan,
- const cmsUInt16Number* Table)
-{
- cmsUInt32Number Dimensions[MAX_INPUT_DIMENSIONS];
- int i;
-
- // Our resulting LUT would be same gridpoints on all dimensions
- for (i=0; i < MAX_INPUT_DIMENSIONS; i++)
- Dimensions[i] = nGridPoints;
-
- return cmsStageAllocCLut16bitGranular(ContextID, Dimensions, inputChan, outputChan, Table);
-}
-
-
-cmsStage* CMSEXPORT cmsStageAllocCLutFloat(cmsContext ContextID,
- cmsUInt32Number nGridPoints,
- cmsUInt32Number inputChan,
- cmsUInt32Number outputChan,
- const cmsFloat32Number* Table)
-{
- cmsUInt32Number Dimensions[MAX_INPUT_DIMENSIONS];
- int i;
-
- // Our resulting LUT would be same gridpoints on all dimensions
- for (i=0; i < MAX_INPUT_DIMENSIONS; i++)
- Dimensions[i] = nGridPoints;
-
- return cmsStageAllocCLutFloatGranular(ContextID, Dimensions, inputChan, outputChan, Table);
-}
-
-
-
-cmsStage* CMSEXPORT cmsStageAllocCLutFloatGranular(cmsContext ContextID, const cmsUInt32Number clutPoints[], cmsUInt32Number inputChan, cmsUInt32Number outputChan, const cmsFloat32Number* Table)
-{
- cmsUInt32Number i, n;
- _cmsStageCLutData* NewElem;
- cmsStage* NewMPE;
-
- _cmsAssert(clutPoints != NULL);
-
- if (inputChan > MAX_INPUT_DIMENSIONS) {
- cmsSignalError(ContextID, cmsERROR_RANGE, "Too many input channels (%d channels, max=%d)", inputChan, MAX_INPUT_DIMENSIONS);
- return NULL;
- }
-
- NewMPE = _cmsStageAllocPlaceholder(ContextID, cmsSigCLutElemType, inputChan, outputChan,
- EvaluateCLUTfloat, CLUTElemDup, CLutElemTypeFree, NULL);
- if (NewMPE == NULL) return NULL;
-
-
- NewElem = (_cmsStageCLutData*) _cmsMallocZero(ContextID, sizeof(_cmsStageCLutData));
- if (NewElem == NULL) {
- cmsStageFree(NewMPE);
- return NULL;
- }
-
- NewMPE ->Data = (void*) NewElem;
-
- // There is a potential integer overflow on conputing n and nEntries.
- NewElem -> nEntries = n = outputChan * CubeSize(clutPoints, inputChan);
- NewElem -> HasFloatValues = TRUE;
-
- if (n == 0) {
- cmsStageFree(NewMPE);
- return NULL;
- }
-
- NewElem ->Tab.TFloat = (cmsFloat32Number*) _cmsCalloc(ContextID, n, sizeof(cmsFloat32Number));
- if (NewElem ->Tab.TFloat == NULL) {
- cmsStageFree(NewMPE);
- return NULL;
- }
-
- if (Table != NULL) {
- for (i=0; i < n; i++) {
- NewElem ->Tab.TFloat[i] = Table[i];
- }
- }
-
- NewElem ->Params = _cmsComputeInterpParamsEx(ContextID, clutPoints, inputChan, outputChan, NewElem ->Tab.TFloat, CMS_LERP_FLAGS_FLOAT);
- if (NewElem ->Params == NULL) {
- cmsStageFree(NewMPE);
- return NULL;
- }
-
- return NewMPE;
-}
-
-
-static
-int IdentitySampler(CMSREGISTER const cmsUInt16Number In[], CMSREGISTER cmsUInt16Number Out[], CMSREGISTER void * Cargo)
-{
- int nChan = *(int*) Cargo;
- int i;
-
- for (i=0; i < nChan; i++)
- Out[i] = In[i];
-
- return 1;
-}
-
-// Creates an MPE that just copies input to output
-cmsStage* CMSEXPORT _cmsStageAllocIdentityCLut(cmsContext ContextID, cmsUInt32Number nChan)
-{
- cmsUInt32Number Dimensions[MAX_INPUT_DIMENSIONS];
- cmsStage* mpe ;
- int i;
-
- for (i=0; i < MAX_INPUT_DIMENSIONS; i++)
- Dimensions[i] = 2;
-
- mpe = cmsStageAllocCLut16bitGranular(ContextID, Dimensions, nChan, nChan, NULL);
- if (mpe == NULL) return NULL;
-
- if (!cmsStageSampleCLut16bit(mpe, IdentitySampler, &nChan, 0)) {
- cmsStageFree(mpe);
- return NULL;
- }
-
- mpe ->Implements = cmsSigIdentityElemType;
- return mpe;
-}
-
-
-
-// Quantize a value 0 <= i < MaxSamples to 0..0xffff
-cmsUInt16Number CMSEXPORT _cmsQuantizeVal(cmsFloat64Number i, cmsUInt32Number MaxSamples)
-{
- cmsFloat64Number x;
-
- x = ((cmsFloat64Number) i * 65535.) / (cmsFloat64Number) (MaxSamples - 1);
- return _cmsQuickSaturateWord(x);
-}
-
-
-// This routine does a sweep on whole input space, and calls its callback
-// function on knots. returns TRUE if all ok, FALSE otherwise.
-cmsBool CMSEXPORT cmsStageSampleCLut16bit(cmsStage* mpe, cmsSAMPLER16 Sampler, void * Cargo, cmsUInt32Number dwFlags)
-{
- int i, t, index, rest;
- cmsUInt32Number nTotalPoints;
- cmsUInt32Number nInputs, nOutputs;
- cmsUInt32Number* nSamples;
- cmsUInt16Number In[MAX_INPUT_DIMENSIONS+1], Out[MAX_STAGE_CHANNELS];
- _cmsStageCLutData* clut;
-
- if (mpe == NULL) return FALSE;
-
- clut = (_cmsStageCLutData*) mpe->Data;
-
- if (clut == NULL) return FALSE;
-
- nSamples = clut->Params ->nSamples;
- nInputs = clut->Params ->nInputs;
- nOutputs = clut->Params ->nOutputs;
-
- if (nInputs <= 0) return FALSE;
- if (nOutputs <= 0) return FALSE;
- if (nInputs > MAX_INPUT_DIMENSIONS) return FALSE;
- if (nOutputs >= MAX_STAGE_CHANNELS) return FALSE;
-
- memset(In, 0, sizeof(In));
- memset(Out, 0, sizeof(Out));
-
- nTotalPoints = CubeSize(nSamples, nInputs);
- if (nTotalPoints == 0) return FALSE;
-
- index = 0;
- for (i = 0; i < (int) nTotalPoints; i++) {
-
- rest = i;
- for (t = (int)nInputs - 1; t >= 0; --t) {
-
- cmsUInt32Number Colorant = rest % nSamples[t];
-
- rest /= nSamples[t];
-
- In[t] = _cmsQuantizeVal(Colorant, nSamples[t]);
- }
-
- if (clut ->Tab.T != NULL) {
- for (t = 0; t < (int)nOutputs; t++)
- Out[t] = clut->Tab.T[index + t];
- }
-
- if (!Sampler(In, Out, Cargo))
- return FALSE;
-
- if (!(dwFlags & SAMPLER_INSPECT)) {
-
- if (clut ->Tab.T != NULL) {
- for (t=0; t < (int) nOutputs; t++)
- clut->Tab.T[index + t] = Out[t];
- }
- }
-
- index += nOutputs;
- }
-
- return TRUE;
-}
-
-// Same as anterior, but for floating point
-cmsBool CMSEXPORT cmsStageSampleCLutFloat(cmsStage* mpe, cmsSAMPLERFLOAT Sampler, void * Cargo, cmsUInt32Number dwFlags)
-{
- int i, t, index, rest;
- cmsUInt32Number nTotalPoints;
- cmsUInt32Number nInputs, nOutputs;
- cmsUInt32Number* nSamples;
- cmsFloat32Number In[MAX_INPUT_DIMENSIONS+1], Out[MAX_STAGE_CHANNELS];
- _cmsStageCLutData* clut;
-
- if (mpe == NULL) return FALSE;
-
- clut = (_cmsStageCLutData*)mpe->Data;
-
- if (clut == NULL) return FALSE;
-
- nSamples = clut->Params ->nSamples;
- nInputs = clut->Params ->nInputs;
- nOutputs = clut->Params ->nOutputs;
-
- if (nInputs <= 0) return FALSE;
- if (nOutputs <= 0) return FALSE;
- if (nInputs > MAX_INPUT_DIMENSIONS) return FALSE;
- if (nOutputs >= MAX_STAGE_CHANNELS) return FALSE;
-
- nTotalPoints = CubeSize(nSamples, nInputs);
- if (nTotalPoints == 0) return FALSE;
-
- index = 0;
- for (i = 0; i < (int)nTotalPoints; i++) {
-
- rest = i;
- for (t = (int) nInputs-1; t >=0; --t) {
-
- cmsUInt32Number Colorant = rest % nSamples[t];
-
- rest /= nSamples[t];
-
- In[t] = (cmsFloat32Number) (_cmsQuantizeVal(Colorant, nSamples[t]) / 65535.0);
- }
-
- if (clut ->Tab.TFloat != NULL) {
- for (t=0; t < (int) nOutputs; t++)
- Out[t] = clut->Tab.TFloat[index + t];
- }
-
- if (!Sampler(In, Out, Cargo))
- return FALSE;
-
- if (!(dwFlags & SAMPLER_INSPECT)) {
-
- if (clut ->Tab.TFloat != NULL) {
- for (t=0; t < (int) nOutputs; t++)
- clut->Tab.TFloat[index + t] = Out[t];
- }
- }
-
- index += nOutputs;
- }
-
- return TRUE;
-}
-
-
-
-// This routine does a sweep on whole input space, and calls its callback
-// function on knots. returns TRUE if all ok, FALSE otherwise.
-cmsBool CMSEXPORT cmsSliceSpace16(cmsUInt32Number nInputs, const cmsUInt32Number clutPoints[],
- cmsSAMPLER16 Sampler, void * Cargo)
-{
- int i, t, rest;
- cmsUInt32Number nTotalPoints;
- cmsUInt16Number In[cmsMAXCHANNELS];
-
- if (nInputs >= cmsMAXCHANNELS) return FALSE;
-
- nTotalPoints = CubeSize(clutPoints, nInputs);
- if (nTotalPoints == 0) return FALSE;
-
- for (i = 0; i < (int) nTotalPoints; i++) {
-
- rest = i;
- for (t = (int) nInputs-1; t >=0; --t) {
-
- cmsUInt32Number Colorant = rest % clutPoints[t];
-
- rest /= clutPoints[t];
- In[t] = _cmsQuantizeVal(Colorant, clutPoints[t]);
-
- }
-
- if (!Sampler(In, NULL, Cargo))
- return FALSE;
- }
-
- return TRUE;
-}
-
-cmsInt32Number CMSEXPORT cmsSliceSpaceFloat(cmsUInt32Number nInputs, const cmsUInt32Number clutPoints[],
- cmsSAMPLERFLOAT Sampler, void * Cargo)
-{
- int i, t, rest;
- cmsUInt32Number nTotalPoints;
- cmsFloat32Number In[cmsMAXCHANNELS];
-
- if (nInputs >= cmsMAXCHANNELS) return FALSE;
-
- nTotalPoints = CubeSize(clutPoints, nInputs);
- if (nTotalPoints == 0) return FALSE;
-
- for (i = 0; i < (int) nTotalPoints; i++) {
-
- rest = i;
- for (t = (int) nInputs-1; t >=0; --t) {
-
- cmsUInt32Number Colorant = rest % clutPoints[t];
-
- rest /= clutPoints[t];
- In[t] = (cmsFloat32Number) (_cmsQuantizeVal(Colorant, clutPoints[t]) / 65535.0);
-
- }
-
- if (!Sampler(In, NULL, Cargo))
- return FALSE;
- }
-
- return TRUE;
-}
-
-// ********************************************************************************
-// Type cmsSigLab2XYZElemType
-// ********************************************************************************
-
-
-static
-void EvaluateLab2XYZ(const cmsFloat32Number In[],
- cmsFloat32Number Out[],
- const cmsStage *mpe)
-{
- cmsCIELab Lab;
- cmsCIEXYZ XYZ;
- const cmsFloat64Number XYZadj = MAX_ENCODEABLE_XYZ;
-
- // V4 rules
- Lab.L = In[0] * 100.0;
- Lab.a = In[1] * 255.0 - 128.0;
- Lab.b = In[2] * 255.0 - 128.0;
-
- cmsLab2XYZ(NULL, &XYZ, &Lab);
-
- // From XYZ, range 0..19997 to 0..1.0, note that 1.99997 comes from 0xffff
- // encoded as 1.15 fixed point, so 1 + (32767.0 / 32768.0)
-
- Out[0] = (cmsFloat32Number) ((cmsFloat64Number) XYZ.X / XYZadj);
- Out[1] = (cmsFloat32Number) ((cmsFloat64Number) XYZ.Y / XYZadj);
- Out[2] = (cmsFloat32Number) ((cmsFloat64Number) XYZ.Z / XYZadj);
- return;
-
- cmsUNUSED_PARAMETER(mpe);
-}
-
-
-// No dup or free routines needed, as the structure has no pointers in it.
-cmsStage* CMSEXPORT _cmsStageAllocLab2XYZ(cmsContext ContextID)
-{
- return _cmsStageAllocPlaceholder(ContextID, cmsSigLab2XYZElemType, 3, 3, EvaluateLab2XYZ, NULL, NULL, NULL);
-}
-
-// ********************************************************************************
-
-// v2 L=100 is supposed to be placed on 0xFF00. There is no reasonable
-// number of gridpoints that would make exact match. However, a prelinearization
-// of 258 entries, would map 0xFF00 exactly on entry 257, and this is good to avoid scum dot.
-// Almost all what we need but unfortunately, the rest of entries should be scaled by
-// (255*257/256) and this is not exact.
-
-cmsStage* _cmsStageAllocLabV2ToV4curves(cmsContext ContextID)
-{
- cmsStage* mpe;
- cmsToneCurve* LabTable[3];
- int i, j;
-
- LabTable[0] = cmsBuildTabulatedToneCurve16(ContextID, 258, NULL);
- LabTable[1] = cmsBuildTabulatedToneCurve16(ContextID, 258, NULL);
- LabTable[2] = cmsBuildTabulatedToneCurve16(ContextID, 258, NULL);
-
- for (j=0; j < 3; j++) {
-
- if (LabTable[j] == NULL) {
- cmsFreeToneCurveTriple(LabTable);
- return NULL;
- }
-
- // We need to map * (0xffff / 0xff00), that's same as (257 / 256)
- // So we can use 258-entry tables to do the trick (i / 257) * (255 * 257) * (257 / 256);
- for (i=0; i < 257; i++) {
-
- LabTable[j]->Table16[i] = (cmsUInt16Number) ((i * 0xffff + 0x80) >> 8);
- }
-
- LabTable[j] ->Table16[257] = 0xffff;
- }
-
- mpe = cmsStageAllocToneCurves(ContextID, 3, LabTable);
- cmsFreeToneCurveTriple(LabTable);
-
- if (mpe == NULL) return NULL;
- mpe ->Implements = cmsSigLabV2toV4;
- return mpe;
-}
-
-// ********************************************************************************
-
-// Matrix-based conversion, which is more accurate, but slower and cannot properly be saved in devicelink profiles
-cmsStage* CMSEXPORT _cmsStageAllocLabV2ToV4(cmsContext ContextID)
-{
- static const cmsFloat64Number V2ToV4[] = { 65535.0/65280.0, 0, 0,
- 0, 65535.0/65280.0, 0,
- 0, 0, 65535.0/65280.0
- };
-
- cmsStage *mpe = cmsStageAllocMatrix(ContextID, 3, 3, V2ToV4, NULL);
-
- if (mpe == NULL) return mpe;
- mpe ->Implements = cmsSigLabV2toV4;
- return mpe;
-}
-
-
-// Reverse direction
-cmsStage* CMSEXPORT _cmsStageAllocLabV4ToV2(cmsContext ContextID)
-{
- static const cmsFloat64Number V4ToV2[] = { 65280.0/65535.0, 0, 0,
- 0, 65280.0/65535.0, 0,
- 0, 0, 65280.0/65535.0
- };
-
- cmsStage *mpe = cmsStageAllocMatrix(ContextID, 3, 3, V4ToV2, NULL);
-
- if (mpe == NULL) return mpe;
- mpe ->Implements = cmsSigLabV4toV2;
- return mpe;
-}
-
-
-// To Lab to float. Note that the MPE gives numbers in normal Lab range
-// and we need 0..1.0 range for the formatters
-// L* : 0...100 => 0...1.0 (L* / 100)
-// ab* : -128..+127 to 0..1 ((ab* + 128) / 255)
-
-cmsStage* _cmsStageNormalizeFromLabFloat(cmsContext ContextID)
-{
- static const cmsFloat64Number a1[] = {
- 1.0/100.0, 0, 0,
- 0, 1.0/255.0, 0,
- 0, 0, 1.0/255.0
- };
-
- static const cmsFloat64Number o1[] = {
- 0,
- 128.0/255.0,
- 128.0/255.0
- };
-
- cmsStage *mpe = cmsStageAllocMatrix(ContextID, 3, 3, a1, o1);
-
- if (mpe == NULL) return mpe;
- mpe ->Implements = cmsSigLab2FloatPCS;
- return mpe;
-}
-
-// Fom XYZ to floating point PCS
-cmsStage* _cmsStageNormalizeFromXyzFloat(cmsContext ContextID)
-{
-#define n (32768.0/65535.0)
- static const cmsFloat64Number a1[] = {
- n, 0, 0,
- 0, n, 0,
- 0, 0, n
- };
-#undef n
-
- cmsStage *mpe = cmsStageAllocMatrix(ContextID, 3, 3, a1, NULL);
-
- if (mpe == NULL) return mpe;
- mpe ->Implements = cmsSigXYZ2FloatPCS;
- return mpe;
-}
-
-cmsStage* _cmsStageNormalizeToLabFloat(cmsContext ContextID)
-{
- static const cmsFloat64Number a1[] = {
- 100.0, 0, 0,
- 0, 255.0, 0,
- 0, 0, 255.0
- };
-
- static const cmsFloat64Number o1[] = {
- 0,
- -128.0,
- -128.0
- };
-
- cmsStage *mpe = cmsStageAllocMatrix(ContextID, 3, 3, a1, o1);
- if (mpe == NULL) return mpe;
- mpe ->Implements = cmsSigFloatPCS2Lab;
- return mpe;
-}
-
-cmsStage* _cmsStageNormalizeToXyzFloat(cmsContext ContextID)
-{
-#define n (65535.0/32768.0)
-
- static const cmsFloat64Number a1[] = {
- n, 0, 0,
- 0, n, 0,
- 0, 0, n
- };
-#undef n
-
- cmsStage *mpe = cmsStageAllocMatrix(ContextID, 3, 3, a1, NULL);
- if (mpe == NULL) return mpe;
- mpe ->Implements = cmsSigFloatPCS2XYZ;
- return mpe;
-}
-
-// Clips values smaller than zero
-static
-void Clipper(const cmsFloat32Number In[], cmsFloat32Number Out[], const cmsStage *mpe)
-{
- cmsUInt32Number i;
- for (i = 0; i < mpe->InputChannels; i++) {
-
- cmsFloat32Number n = In[i];
- Out[i] = n < 0 ? 0 : n;
- }
-}
-
-cmsStage* _cmsStageClipNegatives(cmsContext ContextID, cmsUInt32Number nChannels)
-{
- return _cmsStageAllocPlaceholder(ContextID, cmsSigClipNegativesElemType,
- nChannels, nChannels, Clipper, NULL, NULL, NULL);
-}
-
-// ********************************************************************************
-// Type cmsSigXYZ2LabElemType
-// ********************************************************************************
-
-static
-void EvaluateXYZ2Lab(const cmsFloat32Number In[], cmsFloat32Number Out[], const cmsStage *mpe)
-{
- cmsCIELab Lab;
- cmsCIEXYZ XYZ;
- const cmsFloat64Number XYZadj = MAX_ENCODEABLE_XYZ;
-
- // From 0..1.0 to XYZ
-
- XYZ.X = In[0] * XYZadj;
- XYZ.Y = In[1] * XYZadj;
- XYZ.Z = In[2] * XYZadj;
-
- cmsXYZ2Lab(NULL, &Lab, &XYZ);
-
- // From V4 Lab to 0..1.0
-
- Out[0] = (cmsFloat32Number) (Lab.L / 100.0);
- Out[1] = (cmsFloat32Number) ((Lab.a + 128.0) / 255.0);
- Out[2] = (cmsFloat32Number) ((Lab.b + 128.0) / 255.0);
- return;
-
- cmsUNUSED_PARAMETER(mpe);
-}
-
-cmsStage* CMSEXPORT _cmsStageAllocXYZ2Lab(cmsContext ContextID)
-{
- return _cmsStageAllocPlaceholder(ContextID, cmsSigXYZ2LabElemType, 3, 3, EvaluateXYZ2Lab, NULL, NULL, NULL);
-
-}
-
-// ********************************************************************************
-
-// For v4, S-Shaped curves are placed in a/b axis to increase resolution near gray
-
-cmsStage* _cmsStageAllocLabPrelin(cmsContext ContextID)
-{
- cmsToneCurve* LabTable[3];
- cmsFloat64Number Params[1] = {2.4} ;
-
- LabTable[0] = cmsBuildGamma(ContextID, 1.0);
- LabTable[1] = cmsBuildParametricToneCurve(ContextID, 108, Params);
- LabTable[2] = cmsBuildParametricToneCurve(ContextID, 108, Params);
-
- return cmsStageAllocToneCurves(ContextID, 3, LabTable);
-}
-
-
-// Free a single MPE
-void CMSEXPORT cmsStageFree(cmsStage* mpe)
-{
- if (mpe ->FreePtr)
- mpe ->FreePtr(mpe);
-
- _cmsFree(mpe ->ContextID, mpe);
-}
-
-
-cmsUInt32Number CMSEXPORT cmsStageInputChannels(const cmsStage* mpe)
-{
- return mpe ->InputChannels;
-}
-
-cmsUInt32Number CMSEXPORT cmsStageOutputChannels(const cmsStage* mpe)
-{
- return mpe ->OutputChannels;
-}
-
-cmsStageSignature CMSEXPORT cmsStageType(const cmsStage* mpe)
-{
- return mpe -> Type;
-}
-
-void* CMSEXPORT cmsStageData(const cmsStage* mpe)
-{
- return mpe -> Data;
-}
-
-cmsContext CMSEXPORT cmsGetStageContextID(const cmsStage* mpe)
-{
- return mpe -> ContextID;
-}
-
-cmsStage* CMSEXPORT cmsStageNext(const cmsStage* mpe)
-{
- return mpe -> Next;
-}
-
-
-// Duplicates an MPE
-cmsStage* CMSEXPORT cmsStageDup(cmsStage* mpe)
-{
- cmsStage* NewMPE;
-
- if (mpe == NULL) return NULL;
- NewMPE = _cmsStageAllocPlaceholder(mpe ->ContextID,
- mpe ->Type,
- mpe ->InputChannels,
- mpe ->OutputChannels,
- mpe ->EvalPtr,
- mpe ->DupElemPtr,
- mpe ->FreePtr,
- NULL);
- if (NewMPE == NULL) return NULL;
-
- NewMPE ->Implements = mpe ->Implements;
-
- if (mpe ->DupElemPtr) {
-
- NewMPE ->Data = mpe ->DupElemPtr(mpe);
-
- if (NewMPE->Data == NULL) {
-
- cmsStageFree(NewMPE);
- return NULL;
- }
-
- } else {
-
- NewMPE ->Data = NULL;
- }
-
- return NewMPE;
-}
-
-
-// ***********************************************************************************************************
-
-// This function sets up the channel count
-static
-cmsBool BlessLUT(cmsPipeline* lut)
-{
- // We can set the input/output channels only if we have elements.
- if (lut ->Elements != NULL) {
-
- cmsStage* prev;
- cmsStage* next;
- cmsStage* First;
- cmsStage* Last;
-
- First = cmsPipelineGetPtrToFirstStage(lut);
- Last = cmsPipelineGetPtrToLastStage(lut);
-
- if (First == NULL || Last == NULL) return FALSE;
-
- lut->InputChannels = First->InputChannels;
- lut->OutputChannels = Last->OutputChannels;
-
- // Check chain consistency
- prev = First;
- next = prev->Next;
-
- while (next != NULL)
- {
- if (next->InputChannels != prev->OutputChannels)
- return FALSE;
-
- next = next->Next;
- prev = prev->Next;
- }
-}
-
- return TRUE;
-}
-
-
-// Default to evaluate the LUT on 16 bit-basis. Precision is retained.
-static
-void _LUTeval16(CMSREGISTER const cmsUInt16Number In[], CMSREGISTER cmsUInt16Number Out[], CMSREGISTER const void* D)
-{
- cmsPipeline* lut = (cmsPipeline*) D;
- cmsStage *mpe;
- cmsFloat32Number Storage[2][MAX_STAGE_CHANNELS];
- int Phase = 0, NextPhase;
-
- From16ToFloat(In, &Storage[Phase][0], lut ->InputChannels);
-
- for (mpe = lut ->Elements;
- mpe != NULL;
- mpe = mpe ->Next) {
-
- NextPhase = Phase ^ 1;
- mpe ->EvalPtr(&Storage[Phase][0], &Storage[NextPhase][0], mpe);
- Phase = NextPhase;
- }
-
-
- FromFloatTo16(&Storage[Phase][0], Out, lut ->OutputChannels);
-}
-
-
-
-// Does evaluate the LUT on cmsFloat32Number-basis.
-static
-void _LUTevalFloat(const cmsFloat32Number In[], cmsFloat32Number Out[], const void* D)
-{
- cmsPipeline* lut = (cmsPipeline*) D;
- cmsStage *mpe;
- cmsFloat32Number Storage[2][MAX_STAGE_CHANNELS];
- int Phase = 0, NextPhase;
-
- memmove(&Storage[Phase][0], In, lut ->InputChannels * sizeof(cmsFloat32Number));
-
- for (mpe = lut ->Elements;
- mpe != NULL;
- mpe = mpe ->Next) {
-
- NextPhase = Phase ^ 1;
- mpe ->EvalPtr(&Storage[Phase][0], &Storage[NextPhase][0], mpe);
- Phase = NextPhase;
- }
-
- memmove(Out, &Storage[Phase][0], lut ->OutputChannels * sizeof(cmsFloat32Number));
-}
-
-
-// LUT Creation & Destruction
-cmsPipeline* CMSEXPORT cmsPipelineAlloc(cmsContext ContextID, cmsUInt32Number InputChannels, cmsUInt32Number OutputChannels)
-{
- cmsPipeline* NewLUT;
-
- // A value of zero in channels is allowed as placeholder
- if (InputChannels >= cmsMAXCHANNELS ||
- OutputChannels >= cmsMAXCHANNELS) return NULL;
-
- NewLUT = (cmsPipeline*) _cmsMallocZero(ContextID, sizeof(cmsPipeline));
- if (NewLUT == NULL) return NULL;
-
- NewLUT -> InputChannels = InputChannels;
- NewLUT -> OutputChannels = OutputChannels;
-
- NewLUT ->Eval16Fn = _LUTeval16;
- NewLUT ->EvalFloatFn = _LUTevalFloat;
- NewLUT ->DupDataFn = NULL;
- NewLUT ->FreeDataFn = NULL;
- NewLUT ->Data = NewLUT;
- NewLUT ->ContextID = ContextID;
-
- if (!BlessLUT(NewLUT))
- {
- _cmsFree(ContextID, NewLUT);
- return NULL;
- }
-
- return NewLUT;
-}
-
-cmsContext CMSEXPORT cmsGetPipelineContextID(const cmsPipeline* lut)
-{
- _cmsAssert(lut != NULL);
- return lut ->ContextID;
-}
-
-cmsUInt32Number CMSEXPORT cmsPipelineInputChannels(const cmsPipeline* lut)
-{
- _cmsAssert(lut != NULL);
- return lut ->InputChannels;
-}
-
-cmsUInt32Number CMSEXPORT cmsPipelineOutputChannels(const cmsPipeline* lut)
-{
- _cmsAssert(lut != NULL);
- return lut ->OutputChannels;
-}
-
-// Free a profile elements LUT
-void CMSEXPORT cmsPipelineFree(cmsPipeline* lut)
-{
- cmsStage *mpe, *Next;
-
- if (lut == NULL) return;
-
- for (mpe = lut ->Elements;
- mpe != NULL;
- mpe = Next) {
-
- Next = mpe ->Next;
- cmsStageFree(mpe);
- }
-
- if (lut ->FreeDataFn) lut ->FreeDataFn(lut ->ContextID, lut ->Data);
-
- _cmsFree(lut ->ContextID, lut);
-}
-
-
-// Default to evaluate the LUT on 16 bit-basis.
-void CMSEXPORT cmsPipelineEval16(const cmsUInt16Number In[], cmsUInt16Number Out[], const cmsPipeline* lut)
-{
- _cmsAssert(lut != NULL);
- lut ->Eval16Fn(In, Out, lut->Data);
-}
-
-
-// Does evaluate the LUT on cmsFloat32Number-basis.
-void CMSEXPORT cmsPipelineEvalFloat(const cmsFloat32Number In[], cmsFloat32Number Out[], const cmsPipeline* lut)
-{
- _cmsAssert(lut != NULL);
- lut ->EvalFloatFn(In, Out, lut);
-}
-
-
-
-// Duplicates a LUT
-cmsPipeline* CMSEXPORT cmsPipelineDup(const cmsPipeline* lut)
-{
- cmsPipeline* NewLUT;
- cmsStage *NewMPE, *Anterior = NULL, *mpe;
- cmsBool First = TRUE;
-
- if (lut == NULL) return NULL;
-
- NewLUT = cmsPipelineAlloc(lut ->ContextID, lut ->InputChannels, lut ->OutputChannels);
- if (NewLUT == NULL) return NULL;
-
- for (mpe = lut ->Elements;
- mpe != NULL;
- mpe = mpe ->Next) {
-
- NewMPE = cmsStageDup(mpe);
-
- if (NewMPE == NULL) {
- cmsPipelineFree(NewLUT);
- return NULL;
- }
-
- if (First) {
- NewLUT ->Elements = NewMPE;
- First = FALSE;
- }
- else {
- if (Anterior != NULL)
- Anterior ->Next = NewMPE;
- }
-
- Anterior = NewMPE;
- }
-
- NewLUT ->Eval16Fn = lut ->Eval16Fn;
- NewLUT ->EvalFloatFn = lut ->EvalFloatFn;
- NewLUT ->DupDataFn = lut ->DupDataFn;
- NewLUT ->FreeDataFn = lut ->FreeDataFn;
-
- if (NewLUT ->DupDataFn != NULL)
- NewLUT ->Data = NewLUT ->DupDataFn(lut ->ContextID, lut->Data);
-
-
- NewLUT ->SaveAs8Bits = lut ->SaveAs8Bits;
-
- if (!BlessLUT(NewLUT))
- {
- _cmsFree(lut->ContextID, NewLUT);
- return NULL;
- }
-
- return NewLUT;
-}
-
-
-int CMSEXPORT cmsPipelineInsertStage(cmsPipeline* lut, cmsStageLoc loc, cmsStage* mpe)
-{
- cmsStage* Anterior = NULL, *pt;
-
- if (lut == NULL || mpe == NULL)
- return FALSE;
-
- switch (loc) {
-
- case cmsAT_BEGIN:
- mpe ->Next = lut ->Elements;
- lut ->Elements = mpe;
- break;
-
- case cmsAT_END:
-
- if (lut ->Elements == NULL)
- lut ->Elements = mpe;
- else {
-
- for (pt = lut ->Elements;
- pt != NULL;
- pt = pt -> Next) Anterior = pt;
-
- Anterior ->Next = mpe;
- mpe ->Next = NULL;
- }
- break;
- default:;
- return FALSE;
- }
-
- return BlessLUT(lut);
-}
-
-// Unlink an element and return the pointer to it
-void CMSEXPORT cmsPipelineUnlinkStage(cmsPipeline* lut, cmsStageLoc loc, cmsStage** mpe)
-{
- cmsStage *Anterior, *pt, *Last;
- cmsStage *Unlinked = NULL;
-
-
- // If empty LUT, there is nothing to remove
- if (lut ->Elements == NULL) {
- if (mpe) *mpe = NULL;
- return;
- }
-
- // On depending on the strategy...
- switch (loc) {
-
- case cmsAT_BEGIN:
- {
- cmsStage* elem = lut ->Elements;
-
- lut ->Elements = elem -> Next;
- elem ->Next = NULL;
- Unlinked = elem;
-
- }
- break;
-
- case cmsAT_END:
- Anterior = Last = NULL;
- for (pt = lut ->Elements;
- pt != NULL;
- pt = pt -> Next) {
- Anterior = Last;
- Last = pt;
- }
-
- Unlinked = Last; // Next already points to NULL
-
- // Truncate the chain
- if (Anterior)
- Anterior ->Next = NULL;
- else
- lut ->Elements = NULL;
- break;
- default:;
- }
-
- if (mpe)
- *mpe = Unlinked;
- else
- cmsStageFree(Unlinked);
-
- // May fail, but we ignore it
- BlessLUT(lut);
-}
-
-
-// Concatenate two LUT into a new single one
-cmsBool CMSEXPORT cmsPipelineCat(cmsPipeline* l1, const cmsPipeline* l2)
-{
- cmsStage* mpe;
-
- // If both LUTS does not have elements, we need to inherit
- // the number of channels
- if (l1 ->Elements == NULL && l2 ->Elements == NULL) {
- l1 ->InputChannels = l2 ->InputChannels;
- l1 ->OutputChannels = l2 ->OutputChannels;
- }
-
- // Cat second
- for (mpe = l2 ->Elements;
- mpe != NULL;
- mpe = mpe ->Next) {
-
- // We have to dup each element
- if (!cmsPipelineInsertStage(l1, cmsAT_END, cmsStageDup(mpe)))
- return FALSE;
- }
-
- return BlessLUT(l1);
-}
-
-
-cmsBool CMSEXPORT cmsPipelineSetSaveAs8bitsFlag(cmsPipeline* lut, cmsBool On)
-{
- cmsBool Anterior = lut ->SaveAs8Bits;
-
- lut ->SaveAs8Bits = On;
- return Anterior;
-}
-
-
-cmsStage* CMSEXPORT cmsPipelineGetPtrToFirstStage(const cmsPipeline* lut)
-{
- return lut ->Elements;
-}
-
-cmsStage* CMSEXPORT cmsPipelineGetPtrToLastStage(const cmsPipeline* lut)
-{
- cmsStage *mpe, *Anterior = NULL;
-
- for (mpe = lut ->Elements; mpe != NULL; mpe = mpe ->Next)
- Anterior = mpe;
-
- return Anterior;
-}
-
-cmsUInt32Number CMSEXPORT cmsPipelineStageCount(const cmsPipeline* lut)
-{
- cmsStage *mpe;
- cmsUInt32Number n;
-
- for (n=0, mpe = lut ->Elements; mpe != NULL; mpe = mpe ->Next)
- n++;
-
- return n;
-}
-
-// This function may be used to set the optional evaluator and a block of private data. If private data is being used, an optional
-// duplicator and free functions should also be specified in order to duplicate the LUT construct. Use NULL to inhibit such functionality.
-void CMSEXPORT _cmsPipelineSetOptimizationParameters(cmsPipeline* Lut,
- _cmsPipelineEval16Fn Eval16,
- void* PrivateData,
- _cmsFreeUserDataFn FreePrivateDataFn,
- _cmsDupUserDataFn DupPrivateDataFn)
-{
-
- Lut ->Eval16Fn = Eval16;
- Lut ->DupDataFn = DupPrivateDataFn;
- Lut ->FreeDataFn = FreePrivateDataFn;
- Lut ->Data = PrivateData;
-}
-
-
-// ----------------------------------------------------------- Reverse interpolation
-// Here's how it goes. The derivative Df(x) of the function f is the linear
-// transformation that best approximates f near the point x. It can be represented
-// by a matrix A whose entries are the partial derivatives of the components of f
-// with respect to all the coordinates. This is know as the Jacobian
-//
-// The best linear approximation to f is given by the matrix equation:
-//
-// y-y0 = A (x-x0)
-//
-// So, if x0 is a good "guess" for the zero of f, then solving for the zero of this
-// linear approximation will give a "better guess" for the zero of f. Thus let y=0,
-// and since y0=f(x0) one can solve the above equation for x. This leads to the
-// Newton's method formula:
-//
-// xn+1 = xn - A-1 f(xn)
-//
-// where xn+1 denotes the (n+1)-st guess, obtained from the n-th guess xn in the
-// fashion described above. Iterating this will give better and better approximations
-// if you have a "good enough" initial guess.
-
-
-#define JACOBIAN_EPSILON 0.001f
-#define INVERSION_MAX_ITERATIONS 30
-
-// Increment with reflexion on boundary
-static
-void IncDelta(cmsFloat32Number *Val)
-{
- if (*Val < (1.0 - JACOBIAN_EPSILON))
-
- *Val += JACOBIAN_EPSILON;
-
- else
- *Val -= JACOBIAN_EPSILON;
-
-}
-
-
-
-// Euclidean distance between two vectors of n elements each one
-static
-cmsFloat32Number EuclideanDistance(cmsFloat32Number a[], cmsFloat32Number b[], int n)
-{
- cmsFloat32Number sum = 0;
- int i;
-
- for (i=0; i < n; i++) {
- cmsFloat32Number dif = b[i] - a[i];
- sum += dif * dif;
- }
-
- return sqrtf(sum);
-}
-
-
-// Evaluate a LUT in reverse direction. It only searches on 3->3 LUT. Uses Newton method
-//
-// x1 <- x - [J(x)]^-1 * f(x)
-//
-// lut: The LUT on where to do the search
-// Target: LabK, 3 values of Lab plus destination K which is fixed
-// Result: The obtained CMYK
-// Hint: Location where begin the search
-
-cmsBool CMSEXPORT cmsPipelineEvalReverseFloat(cmsFloat32Number Target[],
- cmsFloat32Number Result[],
- cmsFloat32Number Hint[],
- const cmsPipeline* lut)
-{
- cmsUInt32Number i, j;
- cmsFloat64Number error, LastError = 1E20;
- cmsFloat32Number fx[4], x[4], xd[4], fxd[4];
- cmsVEC3 tmp, tmp2;
- cmsMAT3 Jacobian;
-
- // Only 3->3 and 4->3 are supported
- if (lut ->InputChannels != 3 && lut ->InputChannels != 4) return FALSE;
- if (lut ->OutputChannels != 3) return FALSE;
-
- // Take the hint as starting point if specified
- if (Hint == NULL) {
-
- // Begin at any point, we choose 1/3 of CMY axis
- x[0] = x[1] = x[2] = 0.3f;
- }
- else {
-
- // Only copy 3 channels from hint...
- for (j=0; j < 3; j++)
- x[j] = Hint[j];
- }
-
- // If Lut is 4-dimensions, then grab target[3], which is fixed
- if (lut ->InputChannels == 4) {
- x[3] = Target[3];
- }
- else x[3] = 0; // To keep lint happy
-
-
- // Iterate
- for (i = 0; i < INVERSION_MAX_ITERATIONS; i++) {
-
- // Get beginning fx
- cmsPipelineEvalFloat(x, fx, lut);
-
- // Compute error
- error = EuclideanDistance(fx, Target, 3);
-
- // If not convergent, return last safe value
- if (error >= LastError)
- break;
-
- // Keep latest values
- LastError = error;
- for (j=0; j < lut ->InputChannels; j++)
- Result[j] = x[j];
-
- // Found an exact match?
- if (error <= 0)
- break;
-
- // Obtain slope (the Jacobian)
- for (j = 0; j < 3; j++) {
-
- xd[0] = x[0];
- xd[1] = x[1];
- xd[2] = x[2];
- xd[3] = x[3]; // Keep fixed channel
-
- IncDelta(&xd[j]);
-
- cmsPipelineEvalFloat(xd, fxd, lut);
-
- Jacobian.v[0].n[j] = ((fxd[0] - fx[0]) / JACOBIAN_EPSILON);
- Jacobian.v[1].n[j] = ((fxd[1] - fx[1]) / JACOBIAN_EPSILON);
- Jacobian.v[2].n[j] = ((fxd[2] - fx[2]) / JACOBIAN_EPSILON);
- }
-
- // Solve system
- tmp2.n[0] = fx[0] - Target[0];
- tmp2.n[1] = fx[1] - Target[1];
- tmp2.n[2] = fx[2] - Target[2];
-
- if (!_cmsMAT3solve(&tmp, &Jacobian, &tmp2))
- return FALSE;
-
- // Move our guess
- x[0] -= (cmsFloat32Number) tmp.n[0];
- x[1] -= (cmsFloat32Number) tmp.n[1];
- x[2] -= (cmsFloat32Number) tmp.n[2];
-
- // Some clipping....
- for (j=0; j < 3; j++) {
- if (x[j] < 0) x[j] = 0;
- else
- if (x[j] > 1.0) x[j] = 1.0;
- }
- }
-
- return TRUE;
-}
-
-
diff --git a/contrib/libs/lcms2/src/cmsmd5.c b/contrib/libs/lcms2/src/cmsmd5.c
deleted file mode 100644
index cd6ce97d2b..0000000000
--- a/contrib/libs/lcms2/src/cmsmd5.c
+++ /dev/null
@@ -1,313 +0,0 @@
-//---------------------------------------------------------------------------------
-//
-// Little Color Management System
-// Copyright (c) 1998-2023 Marti Maria Saguer
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//---------------------------------------------------------------------------------
-
-
-#include "lcms2_internal.h"
-
-#ifdef CMS_USE_BIG_ENDIAN
-
-static
-void byteReverse(cmsUInt8Number * buf, cmsUInt32Number longs)
-{
- do {
-
- cmsUInt32Number t = _cmsAdjustEndianess32(*(cmsUInt32Number *) buf);
- *(cmsUInt32Number *) buf = t;
- buf += sizeof(cmsUInt32Number);
-
- } while (--longs);
-
-}
-
-#else
-#define byteReverse(buf, len)
-#endif
-
-
-typedef struct {
-
- cmsUInt32Number buf[4];
- cmsUInt32Number bits[2];
- cmsUInt8Number in[64];
- cmsContext ContextID;
-
-} _cmsMD5;
-
-#define F1(x, y, z) (z ^ (x & (y ^ z)))
-#define F2(x, y, z) F1(z, x, y)
-#define F3(x, y, z) (x ^ y ^ z)
-#define F4(x, y, z) (y ^ (x | ~z))
-
-#define STEP(f, w, x, y, z, data, s) \
- ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
-
-
-static
-void cmsMD5_Transform(cmsUInt32Number buf[4], cmsUInt32Number in[16])
-{
- CMSREGISTER cmsUInt32Number a, b, c, d;
-
- a = buf[0];
- b = buf[1];
- c = buf[2];
- d = buf[3];
-
- STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
- STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
- STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
- STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
- STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
- STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
- STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
- STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
- STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
- STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
- STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
- STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
- STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
- STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
- STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
- STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
-
- STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
- STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
- STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
- STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
- STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
- STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
- STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
- STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
- STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
- STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
- STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
- STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
- STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
- STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
- STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
- STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
-
- STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
- STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
- STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
- STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
- STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
- STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
- STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
- STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
- STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
- STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
- STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
- STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
- STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
- STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
- STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
- STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
-
- STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
- STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
- STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
- STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
- STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
- STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
- STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
- STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
- STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
- STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
- STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
- STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
- STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
- STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
- STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
- STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
-
- buf[0] += a;
- buf[1] += b;
- buf[2] += c;
- buf[3] += d;
-}
-
-
-// Create a MD5 object
-
-cmsHANDLE CMSEXPORT cmsMD5alloc(cmsContext ContextID)
-{
- _cmsMD5* ctx = (_cmsMD5*) _cmsMallocZero(ContextID, sizeof(_cmsMD5));
- if (ctx == NULL) return NULL;
-
- ctx ->ContextID = ContextID;
-
- ctx->buf[0] = 0x67452301;
- ctx->buf[1] = 0xefcdab89;
- ctx->buf[2] = 0x98badcfe;
- ctx->buf[3] = 0x10325476;
-
- ctx->bits[0] = 0;
- ctx->bits[1] = 0;
-
- return (cmsHANDLE) ctx;
-}
-
-void CMSEXPORT cmsMD5add(cmsHANDLE Handle, const cmsUInt8Number* buf, cmsUInt32Number len)
-{
- _cmsMD5* ctx = (_cmsMD5*) Handle;
- cmsUInt32Number t;
-
- t = ctx->bits[0];
- if ((ctx->bits[0] = t + (len << 3)) < t)
- ctx->bits[1]++;
-
- ctx->bits[1] += len >> 29;
-
- t = (t >> 3) & 0x3f;
-
- if (t) {
-
- cmsUInt8Number *p = (cmsUInt8Number *) ctx->in + t;
-
- t = 64 - t;
- if (len < t) {
- memmove(p, buf, len);
- return;
- }
-
- memmove(p, buf, t);
- byteReverse(ctx->in, 16);
-
- cmsMD5_Transform(ctx->buf, (cmsUInt32Number *) ctx->in);
- buf += t;
- len -= t;
- }
-
- while (len >= 64) {
- memmove(ctx->in, buf, 64);
- byteReverse(ctx->in, 16);
- cmsMD5_Transform(ctx->buf, (cmsUInt32Number *) ctx->in);
- buf += 64;
- len -= 64;
- }
-
- memmove(ctx->in, buf, len);
-}
-
-// Destroy the object and return the checksum
-void CMSEXPORT cmsMD5finish(cmsProfileID* ProfileID, cmsHANDLE Handle)
-{
- _cmsMD5* ctx = (_cmsMD5*) Handle;
- cmsUInt32Number count;
- cmsUInt8Number *p;
-
- count = (ctx->bits[0] >> 3) & 0x3F;
-
- p = ctx->in + count;
- *p++ = 0x80;
-
- count = 64 - 1 - count;
-
- if (count < 8) {
-
- memset(p, 0, count);
- byteReverse(ctx->in, 16);
- cmsMD5_Transform(ctx->buf, (cmsUInt32Number *) ctx->in);
-
- memset(ctx->in, 0, 56);
- } else {
- memset(p, 0, count - 8);
- }
- byteReverse(ctx->in, 14);
-
- ((cmsUInt32Number *) ctx->in)[14] = ctx->bits[0];
- ((cmsUInt32Number *) ctx->in)[15] = ctx->bits[1];
-
- cmsMD5_Transform(ctx->buf, (cmsUInt32Number *) ctx->in);
-
- byteReverse((cmsUInt8Number *) ctx->buf, 4);
- memmove(ProfileID ->ID8, ctx->buf, 16);
-
- _cmsFree(ctx ->ContextID, ctx);
-}
-
-
-
-// Assuming io points to an ICC profile, compute and store MD5 checksum
-// In the header, rendering intentent, attributes and ID should be set to zero
-// before computing MD5 checksum (per 6.1.13 in ICC spec)
-
-cmsBool CMSEXPORT cmsMD5computeID(cmsHPROFILE hProfile)
-{
- cmsContext ContextID;
- cmsUInt32Number BytesNeeded;
- cmsUInt8Number* Mem = NULL;
- cmsHANDLE MD5 = NULL;
- _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
- _cmsICCPROFILE Keep;
-
- _cmsAssert(hProfile != NULL);
-
- ContextID = cmsGetProfileContextID(hProfile);
-
- // Save a copy of the profile header
- memmove(&Keep, Icc, sizeof(_cmsICCPROFILE));
-
- // Set RI, attributes and ID
- memset(&Icc ->attributes, 0, sizeof(Icc ->attributes));
- Icc ->RenderingIntent = 0;
- memset(&Icc ->ProfileID, 0, sizeof(Icc ->ProfileID));
-
- // Compute needed storage
- if (!cmsSaveProfileToMem(hProfile, NULL, &BytesNeeded)) goto Error;
-
- // Allocate memory
- Mem = (cmsUInt8Number*) _cmsMalloc(ContextID, BytesNeeded);
- if (Mem == NULL) goto Error;
-
- // Save to temporary storage
- if (!cmsSaveProfileToMem(hProfile, Mem, &BytesNeeded)) goto Error;
-
- // Create MD5 object
- MD5 = cmsMD5alloc(ContextID);
- if (MD5 == NULL) goto Error;
-
- // Add all bytes
- cmsMD5add(MD5, Mem, BytesNeeded);
-
- // Temp storage is no longer needed
- _cmsFree(ContextID, Mem);
-
- // Restore header
- memmove(Icc, &Keep, sizeof(_cmsICCPROFILE));
-
- // And store the ID
- cmsMD5finish(&Icc ->ProfileID, MD5);
- return TRUE;
-
-Error:
-
- // Free resources as something went wrong
- // "MD5" cannot be other than NULL here, so no need to free it
- if (Mem != NULL) _cmsFree(ContextID, Mem);
- memmove(Icc, &Keep, sizeof(_cmsICCPROFILE));
- return FALSE;
-}
-
diff --git a/contrib/libs/lcms2/src/cmsmtrx.c b/contrib/libs/lcms2/src/cmsmtrx.c
deleted file mode 100644
index 5f5a3c892d..0000000000
--- a/contrib/libs/lcms2/src/cmsmtrx.c
+++ /dev/null
@@ -1,176 +0,0 @@
-//---------------------------------------------------------------------------------
-//
-// Little Color Management System
-// Copyright (c) 1998-2023 Marti Maria Saguer
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//---------------------------------------------------------------------------------
-//
-
-#include "lcms2_internal.h"
-
-
-#define DSWAP(x, y) {cmsFloat64Number tmp = (x); (x)=(y); (y)=tmp;}
-
-
-// Initiate a vector
-void CMSEXPORT _cmsVEC3init(cmsVEC3* r, cmsFloat64Number x, cmsFloat64Number y, cmsFloat64Number z)
-{
- r -> n[VX] = x;
- r -> n[VY] = y;
- r -> n[VZ] = z;
-}
-
-// Vector subtraction
-void CMSEXPORT _cmsVEC3minus(cmsVEC3* r, const cmsVEC3* a, const cmsVEC3* b)
-{
- r -> n[VX] = a -> n[VX] - b -> n[VX];
- r -> n[VY] = a -> n[VY] - b -> n[VY];
- r -> n[VZ] = a -> n[VZ] - b -> n[VZ];
-}
-
-// Vector cross product
-void CMSEXPORT _cmsVEC3cross(cmsVEC3* r, const cmsVEC3* u, const cmsVEC3* v)
-{
- r ->n[VX] = u->n[VY] * v->n[VZ] - v->n[VY] * u->n[VZ];
- r ->n[VY] = u->n[VZ] * v->n[VX] - v->n[VZ] * u->n[VX];
- r ->n[VZ] = u->n[VX] * v->n[VY] - v->n[VX] * u->n[VY];
-}
-
-// Vector dot product
-cmsFloat64Number CMSEXPORT _cmsVEC3dot(const cmsVEC3* u, const cmsVEC3* v)
-{
- return u->n[VX] * v->n[VX] + u->n[VY] * v->n[VY] + u->n[VZ] * v->n[VZ];
-}
-
-// Euclidean length
-cmsFloat64Number CMSEXPORT _cmsVEC3length(const cmsVEC3* a)
-{
- return sqrt(a ->n[VX] * a ->n[VX] +
- a ->n[VY] * a ->n[VY] +
- a ->n[VZ] * a ->n[VZ]);
-}
-
-// Euclidean distance
-cmsFloat64Number CMSEXPORT _cmsVEC3distance(const cmsVEC3* a, const cmsVEC3* b)
-{
- cmsFloat64Number d1 = a ->n[VX] - b ->n[VX];
- cmsFloat64Number d2 = a ->n[VY] - b ->n[VY];
- cmsFloat64Number d3 = a ->n[VZ] - b ->n[VZ];
-
- return sqrt(d1*d1 + d2*d2 + d3*d3);
-}
-
-
-
-// 3x3 Identity
-void CMSEXPORT _cmsMAT3identity(cmsMAT3* a)
-{
- _cmsVEC3init(&a-> v[0], 1.0, 0.0, 0.0);
- _cmsVEC3init(&a-> v[1], 0.0, 1.0, 0.0);
- _cmsVEC3init(&a-> v[2], 0.0, 0.0, 1.0);
-}
-
-static
-cmsBool CloseEnough(cmsFloat64Number a, cmsFloat64Number b)
-{
- return fabs(b - a) < (1.0 / 65535.0);
-}
-
-
-cmsBool CMSEXPORT _cmsMAT3isIdentity(const cmsMAT3* a)
-{
- cmsMAT3 Identity;
- int i, j;
-
- _cmsMAT3identity(&Identity);
-
- for (i=0; i < 3; i++)
- for (j=0; j < 3; j++)
- if (!CloseEnough(a ->v[i].n[j], Identity.v[i].n[j])) return FALSE;
-
- return TRUE;
-}
-
-
-// Multiply two matrices
-void CMSEXPORT _cmsMAT3per(cmsMAT3* r, const cmsMAT3* a, const cmsMAT3* b)
-{
-#define ROWCOL(i, j) \
- a->v[i].n[0]*b->v[0].n[j] + a->v[i].n[1]*b->v[1].n[j] + a->v[i].n[2]*b->v[2].n[j]
-
- _cmsVEC3init(&r-> v[0], ROWCOL(0,0), ROWCOL(0,1), ROWCOL(0,2));
- _cmsVEC3init(&r-> v[1], ROWCOL(1,0), ROWCOL(1,1), ROWCOL(1,2));
- _cmsVEC3init(&r-> v[2], ROWCOL(2,0), ROWCOL(2,1), ROWCOL(2,2));
-
-#undef ROWCOL //(i, j)
-}
-
-
-
-// Inverse of a matrix b = a^(-1)
-cmsBool CMSEXPORT _cmsMAT3inverse(const cmsMAT3* a, cmsMAT3* b)
-{
- cmsFloat64Number det, c0, c1, c2;
-
- c0 = a -> v[1].n[1]*a -> v[2].n[2] - a -> v[1].n[2]*a -> v[2].n[1];
- c1 = -a -> v[1].n[0]*a -> v[2].n[2] + a -> v[1].n[2]*a -> v[2].n[0];
- c2 = a -> v[1].n[0]*a -> v[2].n[1] - a -> v[1].n[1]*a -> v[2].n[0];
-
- det = a -> v[0].n[0]*c0 + a -> v[0].n[1]*c1 + a -> v[0].n[2]*c2;
-
- if (fabs(det) < MATRIX_DET_TOLERANCE) return FALSE; // singular matrix; can't invert
-
- b -> v[0].n[0] = c0/det;
- b -> v[0].n[1] = (a -> v[0].n[2]*a -> v[2].n[1] - a -> v[0].n[1]*a -> v[2].n[2])/det;
- b -> v[0].n[2] = (a -> v[0].n[1]*a -> v[1].n[2] - a -> v[0].n[2]*a -> v[1].n[1])/det;
- b -> v[1].n[0] = c1/det;
- b -> v[1].n[1] = (a -> v[0].n[0]*a -> v[2].n[2] - a -> v[0].n[2]*a -> v[2].n[0])/det;
- b -> v[1].n[2] = (a -> v[0].n[2]*a -> v[1].n[0] - a -> v[0].n[0]*a -> v[1].n[2])/det;
- b -> v[2].n[0] = c2/det;
- b -> v[2].n[1] = (a -> v[0].n[1]*a -> v[2].n[0] - a -> v[0].n[0]*a -> v[2].n[1])/det;
- b -> v[2].n[2] = (a -> v[0].n[0]*a -> v[1].n[1] - a -> v[0].n[1]*a -> v[1].n[0])/det;
-
- return TRUE;
-}
-
-
-// Solve a system in the form Ax = b
-cmsBool CMSEXPORT _cmsMAT3solve(cmsVEC3* x, cmsMAT3* a, cmsVEC3* b)
-{
- cmsMAT3 m, a_1;
-
- memmove(&m, a, sizeof(cmsMAT3));
-
- if (!_cmsMAT3inverse(&m, &a_1)) return FALSE; // Singular matrix
-
- _cmsMAT3eval(x, &a_1, b);
- return TRUE;
-}
-
-// Evaluate a vector across a matrix
-void CMSEXPORT _cmsMAT3eval(cmsVEC3* r, const cmsMAT3* a, const cmsVEC3* v)
-{
- r->n[VX] = a->v[0].n[VX]*v->n[VX] + a->v[0].n[VY]*v->n[VY] + a->v[0].n[VZ]*v->n[VZ];
- r->n[VY] = a->v[1].n[VX]*v->n[VX] + a->v[1].n[VY]*v->n[VY] + a->v[1].n[VZ]*v->n[VZ];
- r->n[VZ] = a->v[2].n[VX]*v->n[VX] + a->v[2].n[VY]*v->n[VY] + a->v[2].n[VZ]*v->n[VZ];
-}
-
-
diff --git a/contrib/libs/lcms2/src/cmsnamed.c b/contrib/libs/lcms2/src/cmsnamed.c
deleted file mode 100644
index f368fe2483..0000000000
--- a/contrib/libs/lcms2/src/cmsnamed.c
+++ /dev/null
@@ -1,1202 +0,0 @@
-//---------------------------------------------------------------------------------
-//
-// Little Color Management System
-// Copyright (c) 1998-2023 Marti Maria Saguer
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//---------------------------------------------------------------------------------
-//
-
-#include "lcms2_internal.h"
-
-// Multilocalized unicode objects. That is an attempt to encapsulate i18n.
-
-
-// Allocates an empty multi localizad unicode object
-cmsMLU* CMSEXPORT cmsMLUalloc(cmsContext ContextID, cmsUInt32Number nItems)
-{
- cmsMLU* mlu;
-
- // nItems should be positive if given
- if (nItems <= 0) nItems = 2;
-
- // Create the container
- mlu = (cmsMLU*) _cmsMallocZero(ContextID, sizeof(cmsMLU));
- if (mlu == NULL) return NULL;
-
- mlu ->ContextID = ContextID;
-
- // Create entry array
- mlu ->Entries = (_cmsMLUentry*) _cmsCalloc(ContextID, nItems, sizeof(_cmsMLUentry));
- if (mlu ->Entries == NULL) {
- _cmsFree(ContextID, mlu);
- return NULL;
- }
-
- // Ok, keep indexes up to date
- mlu ->AllocatedEntries = nItems;
- mlu ->UsedEntries = 0;
-
- return mlu;
-}
-
-
-// Grows a mempool table for a MLU. Each time this function is called, mempool size is multiplied times two.
-static
-cmsBool GrowMLUpool(cmsMLU* mlu)
-{
- cmsUInt32Number size;
- void *NewPtr;
-
- // Sanity check
- if (mlu == NULL) return FALSE;
-
- if (mlu ->PoolSize == 0)
- size = 256;
- else
- size = mlu ->PoolSize * 2;
-
- // Check for overflow
- if (size < mlu ->PoolSize) return FALSE;
-
- // Reallocate the pool
- NewPtr = _cmsRealloc(mlu ->ContextID, mlu ->MemPool, size);
- if (NewPtr == NULL) return FALSE;
-
-
- mlu ->MemPool = NewPtr;
- mlu ->PoolSize = size;
-
- return TRUE;
-}
-
-
-// Grows a entry table for a MLU. Each time this function is called, table size is multiplied times two.
-static
-cmsBool GrowMLUtable(cmsMLU* mlu)
-{
- cmsUInt32Number AllocatedEntries;
- _cmsMLUentry *NewPtr;
-
- // Sanity check
- if (mlu == NULL) return FALSE;
-
- AllocatedEntries = mlu ->AllocatedEntries * 2;
-
- // Check for overflow
- if (AllocatedEntries / 2 != mlu ->AllocatedEntries) return FALSE;
-
- // Reallocate the memory
- NewPtr = (_cmsMLUentry*)_cmsRealloc(mlu ->ContextID, mlu ->Entries, AllocatedEntries*sizeof(_cmsMLUentry));
- if (NewPtr == NULL) return FALSE;
-
- mlu ->Entries = NewPtr;
- mlu ->AllocatedEntries = AllocatedEntries;
-
- return TRUE;
-}
-
-
-// Search for a specific entry in the structure. Language and Country are used.
-static
-int SearchMLUEntry(cmsMLU* mlu, cmsUInt16Number LanguageCode, cmsUInt16Number CountryCode)
-{
- cmsUInt32Number i;
-
- // Sanity check
- if (mlu == NULL) return -1;
-
- // Iterate whole table
- for (i=0; i < mlu ->UsedEntries; i++) {
-
- if (mlu ->Entries[i].Country == CountryCode &&
- mlu ->Entries[i].Language == LanguageCode) return (int) i;
- }
-
- // Not found
- return -1;
-}
-
-// Add a block of characters to the intended MLU. Language and country are specified.
-// Only one entry for Language/country pair is allowed.
-static
-cmsBool AddMLUBlock(cmsMLU* mlu, cmsUInt32Number size, const wchar_t *Block,
- cmsUInt16Number LanguageCode, cmsUInt16Number CountryCode)
-{
- cmsUInt32Number Offset;
- cmsUInt8Number* Ptr;
-
- // Sanity check
- if (mlu == NULL) return FALSE;
-
- // Is there any room available?
- if (mlu ->UsedEntries >= mlu ->AllocatedEntries) {
- if (!GrowMLUtable(mlu)) return FALSE;
- }
-
- // Only one ASCII string
- if (SearchMLUEntry(mlu, LanguageCode, CountryCode) >= 0) return FALSE; // Only one is allowed!
-
- // Check for size
- while ((mlu ->PoolSize - mlu ->PoolUsed) < size) {
-
- if (!GrowMLUpool(mlu)) return FALSE;
- }
-
- Offset = mlu ->PoolUsed;
-
- Ptr = (cmsUInt8Number*) mlu ->MemPool;
- if (Ptr == NULL) return FALSE;
-
- // Set the entry
- memmove(Ptr + Offset, Block, size);
- mlu ->PoolUsed += size;
-
- mlu ->Entries[mlu ->UsedEntries].StrW = Offset;
- mlu ->Entries[mlu ->UsedEntries].Len = size;
- mlu ->Entries[mlu ->UsedEntries].Country = CountryCode;
- mlu ->Entries[mlu ->UsedEntries].Language = LanguageCode;
- mlu ->UsedEntries++;
-
- return TRUE;
-}
-
-// Convert from a 3-char code to a cmsUInt16Number. It is done in this way because some
-// compilers don't properly align beginning of strings
-static
-cmsUInt16Number strTo16(const char str[3])
-{
- const cmsUInt8Number* ptr8;
- cmsUInt16Number n;
-
- // For non-existent strings
- if (str == NULL) return 0;
- ptr8 = (const cmsUInt8Number*)str;
- n = (cmsUInt16Number)(((cmsUInt16Number)ptr8[0] << 8) | ptr8[1]);
-
- return n;
-}
-
-static
-void strFrom16(char str[3], cmsUInt16Number n)
-{
- str[0] = (char)(n >> 8);
- str[1] = (char)n;
- str[2] = (char)0;
-}
-
-
-// Convert from UTF8 to wchar, returns len.
-static
-cmsUInt32Number decodeUTF8(wchar_t* out, const char* in)
-{
- cmsUInt32Number codepoint = 0;
- cmsUInt32Number size = 0;
-
- while (*in)
- {
- cmsUInt8Number ch = (cmsUInt8Number) *in;
-
- if (ch <= 0x7f)
- {
- codepoint = ch;
- }
- else if (ch <= 0xbf)
- {
- codepoint = (codepoint << 6) | (ch & 0x3f);
- }
- else if (ch <= 0xdf)
- {
- codepoint = ch & 0x1f;
- }
- else if (ch <= 0xef)
- {
- codepoint = ch & 0x0f;
- }
- else
- {
- codepoint = ch & 0x07;
- }
-
- in++;
-
- if (((*in & 0xc0) != 0x80) && (codepoint <= 0x10ffff))
- {
- if (sizeof(wchar_t) > 2)
- {
- if (out) *out++ = (wchar_t) codepoint;
- size++;
- }
- else
- if (codepoint > 0xffff)
- {
- if (out)
- {
- *out++ = (wchar_t)(0xd800 + (codepoint >> 10));
- *out++ = (wchar_t)(0xdc00 + (codepoint & 0x03ff));
- size += 2;
- }
- }
- else
- if (codepoint < 0xd800 || codepoint >= 0xe000)
- {
- if (out) *out++ = (wchar_t) codepoint;
- size++;
- }
- }
- }
-
- return size;
-}
-
-// Convert from wchar_t to UTF8
-static
-cmsUInt32Number encodeUTF8(char* out, const wchar_t* in, cmsUInt32Number max_wchars, cmsUInt32Number max_chars)
-{
- cmsUInt32Number codepoint = 0;
- cmsUInt32Number size = 0;
- cmsUInt32Number len_w = 0;
-
- while (*in && len_w < max_wchars)
- {
- if (*in >= 0xd800 && *in <= 0xdbff)
- codepoint = ((*in - 0xd800) << 10) + 0x10000;
- else
- {
- if (*in >= 0xdc00 && *in <= 0xdfff)
- codepoint |= *in - 0xdc00;
- else
- codepoint = *in;
-
- if (codepoint <= 0x7f)
- {
- if (out && (size + 1 < max_chars)) *out++ = (char)codepoint;
- size++;
- }
-
- else if (codepoint <= 0x7ff)
- {
- if (out && (max_chars > 0) && (size + 2 < max_chars))
- {
- *out++ = (char)(cmsUInt32Number)(0xc0 | ((codepoint >> 6) & 0x1f));
- *out++ = (char)(cmsUInt32Number)(0x80 | (codepoint & 0x3f));
- }
- size += 2;
- }
- else if (codepoint <= 0xffff)
- {
- if (out && (max_chars > 0) && (size + 3 < max_chars))
- {
- *out++ = (char)(cmsUInt32Number)(0xe0 | ((codepoint >> 12) & 0x0f));
- *out++ = (char)(cmsUInt32Number)(0x80 | ((codepoint >> 6) & 0x3f));
- *out++ = (char)(cmsUInt32Number)(0x80 | (codepoint & 0x3f));
- }
- size += 3;
- }
- else
- {
- if (out && (max_chars > 0) && (size + 4 < max_chars))
- {
- *out++ = (char)(cmsUInt32Number)(0xf0 | ((codepoint >> 18) & 0x07));
- *out++ = (char)(cmsUInt32Number)(0x80 | ((codepoint >> 12) & 0x3f));
- *out++ = (char)(cmsUInt32Number)(0x80 | ((codepoint >> 6) & 0x3f));
- *out++ = (char)(cmsUInt32Number)(0x80 | (codepoint & 0x3f));
- }
- size += 4;
- }
-
- codepoint = 0;
- }
-
- in++; len_w++;
- }
-
- return size;
-}
-
-// Add an ASCII entry. Do not add any \0 termination (ICC1v43_2010-12.pdf page 61)
-// In the case the user explicitly sets an empty string, we force a \0
-cmsBool CMSEXPORT cmsMLUsetASCII(cmsMLU* mlu, const char LanguageCode[3], const char CountryCode[3], const char* ASCIIString)
-{
- cmsUInt32Number i, len = (cmsUInt32Number)strlen(ASCIIString);
- wchar_t* WStr;
- cmsBool rc;
- cmsUInt16Number Lang = strTo16(LanguageCode);
- cmsUInt16Number Cntry = strTo16(CountryCode);
-
- if (mlu == NULL) return FALSE;
-
- // len == 0 would prevent operation, so we set a empty string pointing to zero
- if (len == 0)
- {
- wchar_t empty = 0;
- return AddMLUBlock(mlu, sizeof(wchar_t), &empty, Lang, Cntry);
- }
-
- WStr = (wchar_t*)_cmsCalloc(mlu->ContextID, len, sizeof(wchar_t));
- if (WStr == NULL) return FALSE;
-
- for (i = 0; i < len; i++)
- WStr[i] = (wchar_t)ASCIIString[i];
-
- rc = AddMLUBlock(mlu, len * sizeof(wchar_t), WStr, Lang, Cntry);
-
- _cmsFree(mlu->ContextID, WStr);
- return rc;
-
-}
-
-// Add an UTF8 entry. Do not add any \0 termination (ICC1v43_2010-12.pdf page 61)
-// In the case the user explicitly sets an empty string, we force a \0
-cmsBool CMSEXPORT cmsMLUsetUTF8(cmsMLU* mlu, const char LanguageCode[3], const char CountryCode[3], const char* UTF8String)
-{
- cmsUInt32Number UTF8len;
- wchar_t* WStr;
- cmsBool rc;
- cmsUInt16Number Lang = strTo16(LanguageCode);
- cmsUInt16Number Cntry = strTo16(CountryCode);
-
- if (mlu == NULL) return FALSE;
-
- if (*UTF8String == '\0')
- {
- wchar_t empty = 0;
- return AddMLUBlock(mlu, sizeof(wchar_t), &empty, Lang, Cntry);
- }
-
- // Len excluding terminator 0
- UTF8len = decodeUTF8(NULL, UTF8String);
-
- // Get space for dest
- WStr = (wchar_t*) _cmsCalloc(mlu ->ContextID, UTF8len, sizeof(wchar_t));
- if (WStr == NULL) return FALSE;
-
- decodeUTF8(WStr, UTF8String);
-
- rc = AddMLUBlock(mlu, UTF8len * sizeof(wchar_t), WStr, Lang, Cntry);
-
- _cmsFree(mlu ->ContextID, WStr);
- return rc;
-}
-
-// We don't need any wcs support library
-static
-cmsUInt32Number mywcslen(const wchar_t *s)
-{
- const wchar_t *p;
-
- p = s;
- while (*p)
- p++;
-
- return (cmsUInt32Number)(p - s);
-}
-
-// Add a wide entry. Do not add any \0 terminator (ICC1v43_2010-12.pdf page 61)
-cmsBool CMSEXPORT cmsMLUsetWide(cmsMLU* mlu, const char Language[3], const char Country[3], const wchar_t* WideString)
-{
- cmsUInt16Number Lang = strTo16(Language);
- cmsUInt16Number Cntry = strTo16(Country);
- cmsUInt32Number len;
-
- if (mlu == NULL) return FALSE;
- if (WideString == NULL) return FALSE;
-
- len = (cmsUInt32Number) (mywcslen(WideString)) * sizeof(wchar_t);
- if (len == 0)
- len = sizeof(wchar_t);
-
- return AddMLUBlock(mlu, len, WideString, Lang, Cntry);
-}
-
-// Duplicating a MLU is as easy as copying all members
-cmsMLU* CMSEXPORT cmsMLUdup(const cmsMLU* mlu)
-{
- cmsMLU* NewMlu = NULL;
-
- // Duplicating a NULL obtains a NULL
- if (mlu == NULL) return NULL;
-
- NewMlu = cmsMLUalloc(mlu ->ContextID, mlu ->UsedEntries);
- if (NewMlu == NULL) return NULL;
-
- // Should never happen
- if (NewMlu ->AllocatedEntries < mlu ->UsedEntries)
- goto Error;
-
- // Sanitize...
- if (NewMlu ->Entries == NULL || mlu ->Entries == NULL) goto Error;
-
- memmove(NewMlu ->Entries, mlu ->Entries, mlu ->UsedEntries * sizeof(_cmsMLUentry));
- NewMlu ->UsedEntries = mlu ->UsedEntries;
-
- // The MLU may be empty
- if (mlu ->PoolUsed == 0) {
- NewMlu ->MemPool = NULL;
- }
- else {
- // It is not empty
- NewMlu ->MemPool = _cmsMalloc(mlu ->ContextID, mlu ->PoolUsed);
- if (NewMlu ->MemPool == NULL) goto Error;
- }
-
- NewMlu ->PoolSize = mlu ->PoolUsed;
-
- if (NewMlu ->MemPool == NULL || mlu ->MemPool == NULL) goto Error;
-
- memmove(NewMlu ->MemPool, mlu->MemPool, mlu ->PoolUsed);
- NewMlu ->PoolUsed = mlu ->PoolUsed;
-
- return NewMlu;
-
-Error:
-
- if (NewMlu != NULL) cmsMLUfree(NewMlu);
- return NULL;
-}
-
-// Free any used memory
-void CMSEXPORT cmsMLUfree(cmsMLU* mlu)
-{
- if (mlu) {
-
- if (mlu -> Entries) _cmsFree(mlu ->ContextID, mlu->Entries);
- if (mlu -> MemPool) _cmsFree(mlu ->ContextID, mlu->MemPool);
-
- _cmsFree(mlu ->ContextID, mlu);
- }
-}
-
-
-// The algorithm first searches for an exact match of country and language, if not found it uses
-// the Language. If none is found, first entry is used instead.
-static
-const wchar_t* _cmsMLUgetWide(const cmsMLU* mlu,
- cmsUInt32Number *len,
- cmsUInt16Number LanguageCode, cmsUInt16Number CountryCode,
- cmsUInt16Number* UsedLanguageCode, cmsUInt16Number* UsedCountryCode)
-{
- cmsUInt32Number i;
- int Best = -1;
- _cmsMLUentry* v;
-
- if (mlu == NULL) return NULL;
-
- if (mlu -> AllocatedEntries <= 0) return NULL;
-
- for (i=0; i < mlu ->UsedEntries; i++) {
-
- v = mlu ->Entries + i;
-
- if (v -> Language == LanguageCode) {
-
- if (Best == -1) Best = (int) i;
-
- if (v -> Country == CountryCode) {
-
- if (UsedLanguageCode != NULL) *UsedLanguageCode = v ->Language;
- if (UsedCountryCode != NULL) *UsedCountryCode = v ->Country;
-
- if (len != NULL) *len = v ->Len;
-
- return (wchar_t*) ((cmsUInt8Number*) mlu ->MemPool + v -> StrW); // Found exact match
- }
- }
- }
-
- // No string found. Return First one
- if (Best == -1)
- Best = 0;
-
- v = mlu ->Entries + Best;
-
- if (UsedLanguageCode != NULL) *UsedLanguageCode = v ->Language;
- if (UsedCountryCode != NULL) *UsedCountryCode = v ->Country;
-
- if (len != NULL) *len = v ->Len;
-
- if (v->StrW + v->Len > mlu->PoolSize) return NULL;
-
- return (wchar_t*) ((cmsUInt8Number*) mlu ->MemPool + v ->StrW);
-}
-
-
-// Obtain an ASCII representation of the wide string. Setting buffer to NULL returns the len
-cmsUInt32Number CMSEXPORT cmsMLUgetASCII(const cmsMLU* mlu,
- const char LanguageCode[3], const char CountryCode[3],
- char* Buffer, cmsUInt32Number BufferSize)
-{
- const wchar_t *Wide;
- cmsUInt32Number StrLen = 0;
- cmsUInt32Number ASCIIlen, i;
-
- cmsUInt16Number Lang = strTo16(LanguageCode);
- cmsUInt16Number Cntry = strTo16(CountryCode);
-
- // Sanitize
- if (mlu == NULL) return 0;
-
- // Get WideChar
- Wide = _cmsMLUgetWide(mlu, &StrLen, Lang, Cntry, NULL, NULL);
- if (Wide == NULL) return 0;
-
- ASCIIlen = StrLen / sizeof(wchar_t);
-
- // Maybe we want only to know the len?
- if (Buffer == NULL) return ASCIIlen + 1; // Note the zero at the end
-
- // No buffer size means no data
- if (BufferSize <= 0) return 0;
-
- // Some clipping may be required
- if (BufferSize < ASCIIlen + 1)
- ASCIIlen = BufferSize - 1;
-
- // Precess each character
- for (i=0; i < ASCIIlen; i++) {
-
- wchar_t wc = Wide[i];
-
- if (wc < 0xff)
- Buffer[i] = (char)wc;
- else
- Buffer[i] = '?';
- }
-
- // We put a termination "\0"
- Buffer[ASCIIlen] = 0;
- return ASCIIlen + 1;
-}
-
-
-// Obtain a UTF8 representation of the wide string. Setting buffer to NULL returns the len
-cmsUInt32Number CMSEXPORT cmsMLUgetUTF8(const cmsMLU* mlu,
- const char LanguageCode[3], const char CountryCode[3],
- char* Buffer, cmsUInt32Number BufferSize)
-{
- const wchar_t *Wide;
- cmsUInt32Number StrLen = 0;
- cmsUInt32Number UTF8len;
-
- cmsUInt16Number Lang = strTo16(LanguageCode);
- cmsUInt16Number Cntry = strTo16(CountryCode);
-
- // Sanitize
- if (mlu == NULL) return 0;
-
- // Get WideChar
- Wide = _cmsMLUgetWide(mlu, &StrLen, Lang, Cntry, NULL, NULL);
- if (Wide == NULL) return 0;
-
- UTF8len = encodeUTF8(NULL, Wide, StrLen / sizeof(wchar_t), BufferSize);
-
- // Maybe we want only to know the len?
- if (Buffer == NULL) return UTF8len + 1; // Note the zero at the end
-
- // No buffer size means no data
- if (BufferSize <= 0) return 0;
-
- // Some clipping may be required
- if (BufferSize < UTF8len + 1)
- UTF8len = BufferSize - 1;
-
- // Process it
- encodeUTF8(Buffer, Wide, StrLen / sizeof(wchar_t), BufferSize);
-
- // We put a termination "\0"
- Buffer[UTF8len] = 0;
- return UTF8len + 1;
-}
-
-// Obtain a wide representation of the MLU, on depending on current locale settings
-cmsUInt32Number CMSEXPORT cmsMLUgetWide(const cmsMLU* mlu,
- const char LanguageCode[3], const char CountryCode[3],
- wchar_t* Buffer, cmsUInt32Number BufferSize)
-{
- const wchar_t *Wide;
- cmsUInt32Number StrLen = 0;
-
- cmsUInt16Number Lang = strTo16(LanguageCode);
- cmsUInt16Number Cntry = strTo16(CountryCode);
-
- // Sanitize
- if (mlu == NULL) return 0;
-
- Wide = _cmsMLUgetWide(mlu, &StrLen, Lang, Cntry, NULL, NULL);
- if (Wide == NULL) return 0;
-
- // Maybe we want only to know the len?
- if (Buffer == NULL) return StrLen + sizeof(wchar_t);
-
- // Invalid buffer size means no data
- if (BufferSize < sizeof(wchar_t)) return 0;
-
- // Some clipping may be required
- if (BufferSize < StrLen + sizeof(wchar_t))
- StrLen = BufferSize - sizeof(wchar_t);
-
- memmove(Buffer, Wide, StrLen);
- Buffer[StrLen / sizeof(wchar_t)] = 0;
-
- return StrLen + sizeof(wchar_t);
-}
-
-
-// Get also the language and country
-CMSAPI cmsBool CMSEXPORT cmsMLUgetTranslation(const cmsMLU* mlu,
- const char LanguageCode[3], const char CountryCode[3],
- char ObtainedLanguage[3], char ObtainedCountry[3])
-{
- const wchar_t *Wide;
-
- cmsUInt16Number Lang = strTo16(LanguageCode);
- cmsUInt16Number Cntry = strTo16(CountryCode);
- cmsUInt16Number ObtLang, ObtCode;
-
- // Sanitize
- if (mlu == NULL) return FALSE;
-
- Wide = _cmsMLUgetWide(mlu, NULL, Lang, Cntry, &ObtLang, &ObtCode);
- if (Wide == NULL) return FALSE;
-
- // Get used language and code
- strFrom16(ObtainedLanguage, ObtLang);
- strFrom16(ObtainedCountry, ObtCode);
-
- return TRUE;
-}
-
-
-
-// Get the number of translations in the MLU object
-cmsUInt32Number CMSEXPORT cmsMLUtranslationsCount(const cmsMLU* mlu)
-{
- if (mlu == NULL) return 0;
- return mlu->UsedEntries;
-}
-
-// Get the language and country codes for a specific MLU index
-cmsBool CMSEXPORT cmsMLUtranslationsCodes(const cmsMLU* mlu,
- cmsUInt32Number idx,
- char LanguageCode[3],
- char CountryCode[3])
-{
- _cmsMLUentry *entry;
-
- if (mlu == NULL) return FALSE;
-
- if (idx >= mlu->UsedEntries) return FALSE;
-
- entry = &mlu->Entries[idx];
-
- strFrom16(LanguageCode, entry->Language);
- strFrom16(CountryCode, entry->Country);
-
- return TRUE;
-}
-
-
-// Named color lists --------------------------------------------------------------------------------------------
-
-// Grow the list to keep at least NumElements
-static
-cmsBool GrowNamedColorList(cmsNAMEDCOLORLIST* v)
-{
- cmsUInt32Number size;
- _cmsNAMEDCOLOR * NewPtr;
-
- if (v == NULL) return FALSE;
-
- if (v ->Allocated == 0)
- size = 64; // Initial guess
- else
- size = v ->Allocated * 2;
-
- // Keep a maximum color lists can grow, 100K entries seems reasonable
- if (size > 1024 * 100) {
- _cmsFree(v->ContextID, (void*) v->List);
- v->List = NULL;
- return FALSE;
- }
-
- NewPtr = (_cmsNAMEDCOLOR*) _cmsRealloc(v ->ContextID, v ->List, size * sizeof(_cmsNAMEDCOLOR));
- if (NewPtr == NULL)
- return FALSE;
-
- v ->List = NewPtr;
- v ->Allocated = size;
- return TRUE;
-}
-
-// Allocate a list for n elements
-cmsNAMEDCOLORLIST* CMSEXPORT cmsAllocNamedColorList(cmsContext ContextID, cmsUInt32Number n, cmsUInt32Number ColorantCount, const char* Prefix, const char* Suffix)
-{
- cmsNAMEDCOLORLIST* v;
-
- if (ColorantCount > cmsMAXCHANNELS)
- return NULL;
-
- v = (cmsNAMEDCOLORLIST*)_cmsMallocZero(ContextID, sizeof(cmsNAMEDCOLORLIST));
- if (v == NULL) return NULL;
-
- v ->List = NULL;
- v ->nColors = 0;
- v ->ContextID = ContextID;
-
- while (v -> Allocated < n) {
- if (!GrowNamedColorList(v)) {
- cmsFreeNamedColorList(v);
- return NULL;
- }
- }
-
- strncpy(v ->Prefix, Prefix, sizeof(v ->Prefix)-1);
- strncpy(v ->Suffix, Suffix, sizeof(v ->Suffix)-1);
- v->Prefix[32] = v->Suffix[32] = 0;
-
- v -> ColorantCount = ColorantCount;
-
- return v;
-}
-
-// Free a list
-void CMSEXPORT cmsFreeNamedColorList(cmsNAMEDCOLORLIST* v)
-{
- if (v == NULL) return;
- if (v ->List) _cmsFree(v ->ContextID, v ->List);
- _cmsFree(v ->ContextID, v);
-}
-
-cmsNAMEDCOLORLIST* CMSEXPORT cmsDupNamedColorList(const cmsNAMEDCOLORLIST* v)
-{
- cmsNAMEDCOLORLIST* NewNC;
-
- if (v == NULL) return NULL;
-
- NewNC= cmsAllocNamedColorList(v ->ContextID, v -> nColors, v ->ColorantCount, v ->Prefix, v ->Suffix);
- if (NewNC == NULL) return NULL;
-
- // For really large tables we need this
- while (NewNC ->Allocated < v ->Allocated){
- if (!GrowNamedColorList(NewNC))
- {
- cmsFreeNamedColorList(NewNC);
- return NULL;
- }
- }
-
- memmove(NewNC ->Prefix, v ->Prefix, sizeof(v ->Prefix));
- memmove(NewNC ->Suffix, v ->Suffix, sizeof(v ->Suffix));
- NewNC ->ColorantCount = v ->ColorantCount;
- memmove(NewNC->List, v ->List, v->nColors * sizeof(_cmsNAMEDCOLOR));
- NewNC ->nColors = v ->nColors;
- return NewNC;
-}
-
-
-// Append a color to a list. List pointer may change if reallocated
-cmsBool CMSEXPORT cmsAppendNamedColor(cmsNAMEDCOLORLIST* NamedColorList,
- const char* Name,
- cmsUInt16Number PCS[3], cmsUInt16Number Colorant[cmsMAXCHANNELS])
-{
- cmsUInt32Number i;
-
- if (NamedColorList == NULL) return FALSE;
-
- if (NamedColorList ->nColors + 1 > NamedColorList ->Allocated) {
- if (!GrowNamedColorList(NamedColorList)) return FALSE;
- }
-
- for (i=0; i < NamedColorList ->ColorantCount; i++)
- NamedColorList ->List[NamedColorList ->nColors].DeviceColorant[i] = Colorant == NULL ? (cmsUInt16Number)0 : Colorant[i];
-
- for (i=0; i < 3; i++)
- NamedColorList ->List[NamedColorList ->nColors].PCS[i] = PCS == NULL ? (cmsUInt16Number) 0 : PCS[i];
-
- if (Name != NULL) {
-
- strncpy(NamedColorList ->List[NamedColorList ->nColors].Name, Name, cmsMAX_PATH-1);
- NamedColorList ->List[NamedColorList ->nColors].Name[cmsMAX_PATH-1] = 0;
-
- }
- else
- NamedColorList ->List[NamedColorList ->nColors].Name[0] = 0;
-
-
- NamedColorList ->nColors++;
- return TRUE;
-}
-
-// Returns number of elements
-cmsUInt32Number CMSEXPORT cmsNamedColorCount(const cmsNAMEDCOLORLIST* NamedColorList)
-{
- if (NamedColorList == NULL) return 0;
- return NamedColorList ->nColors;
-}
-
-// Info about a given color
-cmsBool CMSEXPORT cmsNamedColorInfo(const cmsNAMEDCOLORLIST* NamedColorList, cmsUInt32Number nColor,
- char* Name,
- char* Prefix,
- char* Suffix,
- cmsUInt16Number* PCS,
- cmsUInt16Number* Colorant)
-{
- if (NamedColorList == NULL) return FALSE;
-
- if (nColor >= cmsNamedColorCount(NamedColorList)) return FALSE;
-
- // strcpy instead of strncpy because many apps are using small buffers
- if (Name) strcpy(Name, NamedColorList->List[nColor].Name);
- if (Prefix) strcpy(Prefix, NamedColorList->Prefix);
- if (Suffix) strcpy(Suffix, NamedColorList->Suffix);
- if (PCS)
- memmove(PCS, NamedColorList ->List[nColor].PCS, 3*sizeof(cmsUInt16Number));
-
- if (Colorant)
- memmove(Colorant, NamedColorList ->List[nColor].DeviceColorant,
- sizeof(cmsUInt16Number) * NamedColorList ->ColorantCount);
-
-
- return TRUE;
-}
-
-// Search for a given color name (no prefix or suffix)
-cmsInt32Number CMSEXPORT cmsNamedColorIndex(const cmsNAMEDCOLORLIST* NamedColorList, const char* Name)
-{
- cmsUInt32Number i;
- cmsUInt32Number n;
-
- if (NamedColorList == NULL) return -1;
- n = cmsNamedColorCount(NamedColorList);
- for (i=0; i < n; i++) {
- if (cmsstrcasecmp(Name, NamedColorList->List[i].Name) == 0)
- return (cmsInt32Number) i;
- }
-
- return -1;
-}
-
-// MPE support -----------------------------------------------------------------------------------------------------------------
-
-static
-void FreeNamedColorList(cmsStage* mpe)
-{
- cmsNAMEDCOLORLIST* List = (cmsNAMEDCOLORLIST*) mpe ->Data;
- cmsFreeNamedColorList(List);
-}
-
-static
-void* DupNamedColorList(cmsStage* mpe)
-{
- cmsNAMEDCOLORLIST* List = (cmsNAMEDCOLORLIST*) mpe ->Data;
- return cmsDupNamedColorList(List);
-}
-
-static
-void EvalNamedColorPCS(const cmsFloat32Number In[], cmsFloat32Number Out[], const cmsStage *mpe)
-{
- cmsNAMEDCOLORLIST* NamedColorList = (cmsNAMEDCOLORLIST*) mpe ->Data;
- cmsUInt16Number index = (cmsUInt16Number) _cmsQuickSaturateWord(In[0] * 65535.0);
-
- if (index >= NamedColorList-> nColors) {
- cmsSignalError(NamedColorList ->ContextID, cmsERROR_RANGE, "Color %d out of range", index);
- Out[0] = Out[1] = Out[2] = 0.0f;
- }
- else {
-
- // Named color always uses Lab
- Out[0] = (cmsFloat32Number) (NamedColorList->List[index].PCS[0] / 65535.0);
- Out[1] = (cmsFloat32Number) (NamedColorList->List[index].PCS[1] / 65535.0);
- Out[2] = (cmsFloat32Number) (NamedColorList->List[index].PCS[2] / 65535.0);
- }
-}
-
-static
-void EvalNamedColor(const cmsFloat32Number In[], cmsFloat32Number Out[], const cmsStage *mpe)
-{
- cmsNAMEDCOLORLIST* NamedColorList = (cmsNAMEDCOLORLIST*) mpe ->Data;
- cmsUInt16Number index = (cmsUInt16Number) _cmsQuickSaturateWord(In[0] * 65535.0);
- cmsUInt32Number j;
-
- if (index >= NamedColorList-> nColors) {
- cmsSignalError(NamedColorList ->ContextID, cmsERROR_RANGE, "Color %d out of range", index);
- for (j = 0; j < NamedColorList->ColorantCount; j++)
- Out[j] = 0.0f;
-
- }
- else {
- for (j=0; j < NamedColorList ->ColorantCount; j++)
- Out[j] = (cmsFloat32Number) (NamedColorList->List[index].DeviceColorant[j] / 65535.0);
- }
-}
-
-
-// Named color lookup element
-cmsStage* CMSEXPORT _cmsStageAllocNamedColor(cmsNAMEDCOLORLIST* NamedColorList, cmsBool UsePCS)
-{
- return _cmsStageAllocPlaceholder(NamedColorList ->ContextID,
- cmsSigNamedColorElemType,
- 1, UsePCS ? 3 : NamedColorList ->ColorantCount,
- UsePCS ? EvalNamedColorPCS : EvalNamedColor,
- DupNamedColorList,
- FreeNamedColorList,
- cmsDupNamedColorList(NamedColorList));
-
-}
-
-
-// Retrieve the named color list from a transform. Should be first element in the LUT
-cmsNAMEDCOLORLIST* CMSEXPORT cmsGetNamedColorList(cmsHTRANSFORM xform)
-{
- _cmsTRANSFORM* v = (_cmsTRANSFORM*) xform;
- cmsStage* mpe;
-
- if (v == NULL) return NULL;
- if (v->Lut == NULL) return NULL;
-
- mpe = v->Lut->Elements;
- if (mpe == NULL) return NULL;
-
- if (mpe ->Type != cmsSigNamedColorElemType) return NULL;
- return (cmsNAMEDCOLORLIST*) mpe ->Data;
-}
-
-
-// Profile sequence description routines -------------------------------------------------------------------------------------
-
-cmsSEQ* CMSEXPORT cmsAllocProfileSequenceDescription(cmsContext ContextID, cmsUInt32Number n)
-{
- cmsSEQ* Seq;
- cmsUInt32Number i;
-
- if (n == 0) return NULL;
-
- // In a absolutely arbitrary way, I hereby decide to allow a maxim of 255 profiles linked
- // in a devicelink. It makes not sense anyway and may be used for exploits, so let's close the door!
- if (n > 255) return NULL;
-
- Seq = (cmsSEQ*) _cmsMallocZero(ContextID, sizeof(cmsSEQ));
- if (Seq == NULL) return NULL;
-
- Seq -> ContextID = ContextID;
- Seq -> seq = (cmsPSEQDESC*) _cmsCalloc(ContextID, n, sizeof(cmsPSEQDESC));
- Seq -> n = n;
-
- if (Seq -> seq == NULL) {
- _cmsFree(ContextID, Seq);
- return NULL;
- }
-
- for (i=0; i < n; i++) {
- Seq -> seq[i].Manufacturer = NULL;
- Seq -> seq[i].Model = NULL;
- Seq -> seq[i].Description = NULL;
- }
-
- return Seq;
-}
-
-void CMSEXPORT cmsFreeProfileSequenceDescription(cmsSEQ* pseq)
-{
- cmsUInt32Number i;
-
- if (pseq == NULL)
- return;
-
- if (pseq ->seq != NULL) {
- for (i=0; i < pseq ->n; i++) {
- if (pseq ->seq[i].Manufacturer != NULL) cmsMLUfree(pseq ->seq[i].Manufacturer);
- if (pseq ->seq[i].Model != NULL) cmsMLUfree(pseq ->seq[i].Model);
- if (pseq ->seq[i].Description != NULL) cmsMLUfree(pseq ->seq[i].Description);
- }
-
- _cmsFree(pseq ->ContextID, pseq ->seq);
- }
-
- _cmsFree(pseq -> ContextID, pseq);
-}
-
-cmsSEQ* CMSEXPORT cmsDupProfileSequenceDescription(const cmsSEQ* pseq)
-{
- cmsSEQ *NewSeq;
- cmsUInt32Number i;
-
- if (pseq == NULL)
- return NULL;
-
- NewSeq = (cmsSEQ*) _cmsMalloc(pseq -> ContextID, sizeof(cmsSEQ));
- if (NewSeq == NULL) return NULL;
-
-
- NewSeq -> seq = (cmsPSEQDESC*) _cmsCalloc(pseq ->ContextID, pseq ->n, sizeof(cmsPSEQDESC));
- if (NewSeq ->seq == NULL) goto Error;
-
- NewSeq -> ContextID = pseq ->ContextID;
- NewSeq -> n = pseq ->n;
-
- for (i=0; i < pseq->n; i++) {
-
- memmove(&NewSeq ->seq[i].attributes, &pseq ->seq[i].attributes, sizeof(cmsUInt64Number));
-
- NewSeq ->seq[i].deviceMfg = pseq ->seq[i].deviceMfg;
- NewSeq ->seq[i].deviceModel = pseq ->seq[i].deviceModel;
- memmove(&NewSeq ->seq[i].ProfileID, &pseq ->seq[i].ProfileID, sizeof(cmsProfileID));
- NewSeq ->seq[i].technology = pseq ->seq[i].technology;
-
- NewSeq ->seq[i].Manufacturer = cmsMLUdup(pseq ->seq[i].Manufacturer);
- NewSeq ->seq[i].Model = cmsMLUdup(pseq ->seq[i].Model);
- NewSeq ->seq[i].Description = cmsMLUdup(pseq ->seq[i].Description);
-
- }
-
- return NewSeq;
-
-Error:
-
- cmsFreeProfileSequenceDescription(NewSeq);
- return NULL;
-}
-
-// Dictionaries --------------------------------------------------------------------------------------------------------
-
-// Dictionaries are just very simple linked lists
-
-
-typedef struct _cmsDICT_struct {
- cmsDICTentry* head;
- cmsContext ContextID;
-} _cmsDICT;
-
-
-// Allocate an empty dictionary
-cmsHANDLE CMSEXPORT cmsDictAlloc(cmsContext ContextID)
-{
- _cmsDICT* dict = (_cmsDICT*) _cmsMallocZero(ContextID, sizeof(_cmsDICT));
- if (dict == NULL) return NULL;
-
- dict ->ContextID = ContextID;
- return (cmsHANDLE) dict;
-
-}
-
-// Dispose resources
-void CMSEXPORT cmsDictFree(cmsHANDLE hDict)
-{
- _cmsDICT* dict = (_cmsDICT*) hDict;
- cmsDICTentry *entry, *next;
-
- _cmsAssert(dict != NULL);
-
- // Walk the list freeing all nodes
- entry = dict ->head;
- while (entry != NULL) {
-
- if (entry ->DisplayName != NULL) cmsMLUfree(entry ->DisplayName);
- if (entry ->DisplayValue != NULL) cmsMLUfree(entry ->DisplayValue);
- if (entry ->Name != NULL) _cmsFree(dict ->ContextID, entry -> Name);
- if (entry ->Value != NULL) _cmsFree(dict ->ContextID, entry -> Value);
-
- // Don't fall in the habitual trap...
- next = entry ->Next;
- _cmsFree(dict ->ContextID, entry);
-
- entry = next;
- }
-
- _cmsFree(dict ->ContextID, dict);
-}
-
-
-// Duplicate a wide char string
-static
-wchar_t* DupWcs(cmsContext ContextID, const wchar_t* ptr)
-{
- if (ptr == NULL) return NULL;
- return (wchar_t*) _cmsDupMem(ContextID, ptr, (mywcslen(ptr) + 1) * sizeof(wchar_t));
-}
-
-// Add a new entry to the linked list
-cmsBool CMSEXPORT cmsDictAddEntry(cmsHANDLE hDict, const wchar_t* Name, const wchar_t* Value, const cmsMLU *DisplayName, const cmsMLU *DisplayValue)
-{
- _cmsDICT* dict = (_cmsDICT*) hDict;
- cmsDICTentry *entry;
-
- _cmsAssert(dict != NULL);
- _cmsAssert(Name != NULL);
-
- entry = (cmsDICTentry*) _cmsMallocZero(dict ->ContextID, sizeof(cmsDICTentry));
- if (entry == NULL) return FALSE;
-
- entry ->DisplayName = cmsMLUdup(DisplayName);
- entry ->DisplayValue = cmsMLUdup(DisplayValue);
- entry ->Name = DupWcs(dict ->ContextID, Name);
- entry ->Value = DupWcs(dict ->ContextID, Value);
-
- entry ->Next = dict ->head;
- dict ->head = entry;
-
- return TRUE;
-}
-
-
-// Duplicates an existing dictionary
-cmsHANDLE CMSEXPORT cmsDictDup(cmsHANDLE hDict)
-{
- _cmsDICT* old_dict = (_cmsDICT*) hDict;
- cmsHANDLE hNew;
- cmsDICTentry *entry;
-
- _cmsAssert(old_dict != NULL);
-
- hNew = cmsDictAlloc(old_dict ->ContextID);
- if (hNew == NULL) return NULL;
-
- // Walk the list freeing all nodes
- entry = old_dict ->head;
- while (entry != NULL) {
-
- if (!cmsDictAddEntry(hNew, entry ->Name, entry ->Value, entry ->DisplayName, entry ->DisplayValue)) {
-
- cmsDictFree(hNew);
- return NULL;
- }
-
- entry = entry -> Next;
- }
-
- return hNew;
-}
-
-// Get a pointer to the linked list
-const cmsDICTentry* CMSEXPORT cmsDictGetEntryList(cmsHANDLE hDict)
-{
- _cmsDICT* dict = (_cmsDICT*) hDict;
-
- if (dict == NULL) return NULL;
- return dict ->head;
-}
-
-// Helper For external languages
-const cmsDICTentry* CMSEXPORT cmsDictNextEntry(const cmsDICTentry* e)
-{
- if (e == NULL) return NULL;
- return e ->Next;
-}
diff --git a/contrib/libs/lcms2/src/cmsopt.c b/contrib/libs/lcms2/src/cmsopt.c
deleted file mode 100644
index 4038088b2b..0000000000
--- a/contrib/libs/lcms2/src/cmsopt.c
+++ /dev/null
@@ -1,1978 +0,0 @@
-//---------------------------------------------------------------------------------
-//
-// Little Color Management System
-// Copyright (c) 1998-2023 Marti Maria Saguer
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//---------------------------------------------------------------------------------
-//
-
-#include "lcms2_internal.h"
-
-
-//----------------------------------------------------------------------------------
-
-// Optimization for 8 bits, Shaper-CLUT (3 inputs only)
-typedef struct {
-
- cmsContext ContextID;
-
- const cmsInterpParams* p; // Tetrahedrical interpolation parameters. This is a not-owned pointer.
-
- cmsUInt16Number rx[256], ry[256], rz[256];
- cmsUInt32Number X0[256], Y0[256], Z0[256]; // Precomputed nodes and offsets for 8-bit input data
-
-
-} Prelin8Data;
-
-
-// Generic optimization for 16 bits Shaper-CLUT-Shaper (any inputs)
-typedef struct {
-
- cmsContext ContextID;
-
- // Number of channels
- cmsUInt32Number nInputs;
- cmsUInt32Number nOutputs;
-
- _cmsInterpFn16 EvalCurveIn16[MAX_INPUT_DIMENSIONS]; // The maximum number of input channels is known in advance
- cmsInterpParams* ParamsCurveIn16[MAX_INPUT_DIMENSIONS];
-
- _cmsInterpFn16 EvalCLUT; // The evaluator for 3D grid
- const cmsInterpParams* CLUTparams; // (not-owned pointer)
-
-
- _cmsInterpFn16* EvalCurveOut16; // Points to an array of curve evaluators in 16 bits (not-owned pointer)
- cmsInterpParams** ParamsCurveOut16; // Points to an array of references to interpolation params (not-owned pointer)
-
-
-} Prelin16Data;
-
-
-// Optimization for matrix-shaper in 8 bits. Numbers are operated in n.14 signed, tables are stored in 1.14 fixed
-
-typedef cmsInt32Number cmsS1Fixed14Number; // Note that this may hold more than 16 bits!
-
-#define DOUBLE_TO_1FIXED14(x) ((cmsS1Fixed14Number) floor((x) * 16384.0 + 0.5))
-
-typedef struct {
-
- cmsContext ContextID;
-
- cmsS1Fixed14Number Shaper1R[256]; // from 0..255 to 1.14 (0.0...1.0)
- cmsS1Fixed14Number Shaper1G[256];
- cmsS1Fixed14Number Shaper1B[256];
-
- cmsS1Fixed14Number Mat[3][3]; // n.14 to n.14 (needs a saturation after that)
- cmsS1Fixed14Number Off[3];
-
- cmsUInt16Number Shaper2R[16385]; // 1.14 to 0..255
- cmsUInt16Number Shaper2G[16385];
- cmsUInt16Number Shaper2B[16385];
-
-} MatShaper8Data;
-
-// Curves, optimization is shared between 8 and 16 bits
-typedef struct {
-
- cmsContext ContextID;
-
- cmsUInt32Number nCurves; // Number of curves
- cmsUInt32Number nElements; // Elements in curves
- cmsUInt16Number** Curves; // Points to a dynamically allocated array
-
-} Curves16Data;
-
-
-// Simple optimizations ----------------------------------------------------------------------------------------------------------
-
-
-// Remove an element in linked chain
-static
-void _RemoveElement(cmsStage** head)
-{
- cmsStage* mpe = *head;
- cmsStage* next = mpe ->Next;
- *head = next;
- cmsStageFree(mpe);
-}
-
-// Remove all identities in chain. Note that pt actually is a double pointer to the element that holds the pointer.
-static
-cmsBool _Remove1Op(cmsPipeline* Lut, cmsStageSignature UnaryOp)
-{
- cmsStage** pt = &Lut ->Elements;
- cmsBool AnyOpt = FALSE;
-
- while (*pt != NULL) {
-
- if ((*pt) ->Implements == UnaryOp) {
- _RemoveElement(pt);
- AnyOpt = TRUE;
- }
- else
- pt = &((*pt) -> Next);
- }
-
- return AnyOpt;
-}
-
-// Same, but only if two adjacent elements are found
-static
-cmsBool _Remove2Op(cmsPipeline* Lut, cmsStageSignature Op1, cmsStageSignature Op2)
-{
- cmsStage** pt1;
- cmsStage** pt2;
- cmsBool AnyOpt = FALSE;
-
- pt1 = &Lut ->Elements;
- if (*pt1 == NULL) return AnyOpt;
-
- while (*pt1 != NULL) {
-
- pt2 = &((*pt1) -> Next);
- if (*pt2 == NULL) return AnyOpt;
-
- if ((*pt1) ->Implements == Op1 && (*pt2) ->Implements == Op2) {
- _RemoveElement(pt2);
- _RemoveElement(pt1);
- AnyOpt = TRUE;
- }
- else
- pt1 = &((*pt1) -> Next);
- }
-
- return AnyOpt;
-}
-
-
-static
-cmsBool CloseEnoughFloat(cmsFloat64Number a, cmsFloat64Number b)
-{
- return fabs(b - a) < 0.00001f;
-}
-
-static
-cmsBool isFloatMatrixIdentity(const cmsMAT3* a)
-{
- cmsMAT3 Identity;
- int i, j;
-
- _cmsMAT3identity(&Identity);
-
- for (i = 0; i < 3; i++)
- for (j = 0; j < 3; j++)
- if (!CloseEnoughFloat(a->v[i].n[j], Identity.v[i].n[j])) return FALSE;
-
- return TRUE;
-}
-
-// if two adjacent matrices are found, multiply them.
-static
-cmsBool _MultiplyMatrix(cmsPipeline* Lut)
-{
- cmsStage** pt1;
- cmsStage** pt2;
- cmsStage* chain;
- cmsBool AnyOpt = FALSE;
-
- pt1 = &Lut->Elements;
- if (*pt1 == NULL) return AnyOpt;
-
- while (*pt1 != NULL) {
-
- pt2 = &((*pt1)->Next);
- if (*pt2 == NULL) return AnyOpt;
-
- if ((*pt1)->Implements == cmsSigMatrixElemType && (*pt2)->Implements == cmsSigMatrixElemType) {
-
- // Get both matrices
- _cmsStageMatrixData* m1 = (_cmsStageMatrixData*) cmsStageData(*pt1);
- _cmsStageMatrixData* m2 = (_cmsStageMatrixData*) cmsStageData(*pt2);
- cmsMAT3 res;
-
- // Input offset and output offset should be zero to use this optimization
- if (m1->Offset != NULL || m2 ->Offset != NULL ||
- cmsStageInputChannels(*pt1) != 3 || cmsStageOutputChannels(*pt1) != 3 ||
- cmsStageInputChannels(*pt2) != 3 || cmsStageOutputChannels(*pt2) != 3)
- return FALSE;
-
- // Multiply both matrices to get the result
- _cmsMAT3per(&res, (cmsMAT3*)m2->Double, (cmsMAT3*)m1->Double);
-
- // Get the next in chain after the matrices
- chain = (*pt2)->Next;
-
- // Remove both matrices
- _RemoveElement(pt2);
- _RemoveElement(pt1);
-
- // Now what if the result is a plain identity?
- if (!isFloatMatrixIdentity(&res)) {
-
- // We can not get rid of full matrix
- cmsStage* Multmat = cmsStageAllocMatrix(Lut->ContextID, 3, 3, (const cmsFloat64Number*) &res, NULL);
- if (Multmat == NULL) return FALSE; // Should never happen
-
- // Recover the chain
- Multmat->Next = chain;
- *pt1 = Multmat;
- }
-
- AnyOpt = TRUE;
- }
- else
- pt1 = &((*pt1)->Next);
- }
-
- return AnyOpt;
-}
-
-
-// Preoptimize just gets rif of no-ops coming paired. Conversion from v2 to v4 followed
-// by a v4 to v2 and vice-versa. The elements are then discarded.
-static
-cmsBool PreOptimize(cmsPipeline* Lut)
-{
- cmsBool AnyOpt = FALSE, Opt;
-
- do {
-
- Opt = FALSE;
-
- // Remove all identities
- Opt |= _Remove1Op(Lut, cmsSigIdentityElemType);
-
- // Remove XYZ2Lab followed by Lab2XYZ
- Opt |= _Remove2Op(Lut, cmsSigXYZ2LabElemType, cmsSigLab2XYZElemType);
-
- // Remove Lab2XYZ followed by XYZ2Lab
- Opt |= _Remove2Op(Lut, cmsSigLab2XYZElemType, cmsSigXYZ2LabElemType);
-
- // Remove V4 to V2 followed by V2 to V4
- Opt |= _Remove2Op(Lut, cmsSigLabV4toV2, cmsSigLabV2toV4);
-
- // Remove V2 to V4 followed by V4 to V2
- Opt |= _Remove2Op(Lut, cmsSigLabV2toV4, cmsSigLabV4toV2);
-
- // Remove float pcs Lab conversions
- Opt |= _Remove2Op(Lut, cmsSigLab2FloatPCS, cmsSigFloatPCS2Lab);
-
- // Remove float pcs Lab conversions
- Opt |= _Remove2Op(Lut, cmsSigXYZ2FloatPCS, cmsSigFloatPCS2XYZ);
-
- // Simplify matrix.
- Opt |= _MultiplyMatrix(Lut);
-
- if (Opt) AnyOpt = TRUE;
-
- } while (Opt);
-
- return AnyOpt;
-}
-
-static
-void Eval16nop1D(CMSREGISTER const cmsUInt16Number Input[],
- CMSREGISTER cmsUInt16Number Output[],
- CMSREGISTER const struct _cms_interp_struc* p)
-{
- Output[0] = Input[0];
-
- cmsUNUSED_PARAMETER(p);
-}
-
-static
-void PrelinEval16(CMSREGISTER const cmsUInt16Number Input[],
- CMSREGISTER cmsUInt16Number Output[],
- CMSREGISTER const void* D)
-{
- Prelin16Data* p16 = (Prelin16Data*) D;
- cmsUInt16Number StageABC[MAX_INPUT_DIMENSIONS];
- cmsUInt16Number StageDEF[cmsMAXCHANNELS];
- cmsUInt32Number i;
-
- for (i=0; i < p16 ->nInputs; i++) {
-
- p16 ->EvalCurveIn16[i](&Input[i], &StageABC[i], p16 ->ParamsCurveIn16[i]);
- }
-
- p16 ->EvalCLUT(StageABC, StageDEF, p16 ->CLUTparams);
-
- for (i=0; i < p16 ->nOutputs; i++) {
-
- p16 ->EvalCurveOut16[i](&StageDEF[i], &Output[i], p16 ->ParamsCurveOut16[i]);
- }
-}
-
-
-static
-void PrelinOpt16free(cmsContext ContextID, void* ptr)
-{
- Prelin16Data* p16 = (Prelin16Data*) ptr;
-
- _cmsFree(ContextID, p16 ->EvalCurveOut16);
- _cmsFree(ContextID, p16 ->ParamsCurveOut16);
-
- _cmsFree(ContextID, p16);
-}
-
-static
-void* Prelin16dup(cmsContext ContextID, const void* ptr)
-{
- Prelin16Data* p16 = (Prelin16Data*) ptr;
- Prelin16Data* Duped = (Prelin16Data*) _cmsDupMem(ContextID, p16, sizeof(Prelin16Data));
-
- if (Duped == NULL) return NULL;
-
- Duped->EvalCurveOut16 = (_cmsInterpFn16*) _cmsDupMem(ContextID, p16->EvalCurveOut16, p16->nOutputs * sizeof(_cmsInterpFn16));
- Duped->ParamsCurveOut16 = (cmsInterpParams**)_cmsDupMem(ContextID, p16->ParamsCurveOut16, p16->nOutputs * sizeof(cmsInterpParams*));
-
- return Duped;
-}
-
-
-static
-Prelin16Data* PrelinOpt16alloc(cmsContext ContextID,
- const cmsInterpParams* ColorMap,
- cmsUInt32Number nInputs, cmsToneCurve** In,
- cmsUInt32Number nOutputs, cmsToneCurve** Out )
-{
- cmsUInt32Number i;
- Prelin16Data* p16 = (Prelin16Data*)_cmsMallocZero(ContextID, sizeof(Prelin16Data));
- if (p16 == NULL) return NULL;
-
- p16 ->nInputs = nInputs;
- p16 ->nOutputs = nOutputs;
-
-
- for (i=0; i < nInputs; i++) {
-
- if (In == NULL) {
- p16 -> ParamsCurveIn16[i] = NULL;
- p16 -> EvalCurveIn16[i] = Eval16nop1D;
-
- }
- else {
- p16 -> ParamsCurveIn16[i] = In[i] ->InterpParams;
- p16 -> EvalCurveIn16[i] = p16 ->ParamsCurveIn16[i]->Interpolation.Lerp16;
- }
- }
-
- p16 ->CLUTparams = ColorMap;
- p16 ->EvalCLUT = ColorMap ->Interpolation.Lerp16;
-
-
- p16 -> EvalCurveOut16 = (_cmsInterpFn16*) _cmsCalloc(ContextID, nOutputs, sizeof(_cmsInterpFn16));
- if (p16->EvalCurveOut16 == NULL)
- {
- _cmsFree(ContextID, p16);
- return NULL;
- }
-
- p16 -> ParamsCurveOut16 = (cmsInterpParams**) _cmsCalloc(ContextID, nOutputs, sizeof(cmsInterpParams* ));
- if (p16->ParamsCurveOut16 == NULL)
- {
-
- _cmsFree(ContextID, p16->EvalCurveOut16);
- _cmsFree(ContextID, p16);
- return NULL;
- }
-
- for (i=0; i < nOutputs; i++) {
-
- if (Out == NULL) {
- p16 ->ParamsCurveOut16[i] = NULL;
- p16 -> EvalCurveOut16[i] = Eval16nop1D;
- }
- else {
-
- p16 ->ParamsCurveOut16[i] = Out[i] ->InterpParams;
- p16 -> EvalCurveOut16[i] = p16 ->ParamsCurveOut16[i]->Interpolation.Lerp16;
- }
- }
-
- return p16;
-}
-
-
-
-// Resampling ---------------------------------------------------------------------------------
-
-#define PRELINEARIZATION_POINTS 4096
-
-// Sampler implemented by another LUT. This is a clean way to precalculate the devicelink 3D CLUT for
-// almost any transform. We use floating point precision and then convert from floating point to 16 bits.
-static
-cmsInt32Number XFormSampler16(CMSREGISTER const cmsUInt16Number In[],
- CMSREGISTER cmsUInt16Number Out[],
- CMSREGISTER void* Cargo)
-{
- cmsPipeline* Lut = (cmsPipeline*) Cargo;
- cmsFloat32Number InFloat[cmsMAXCHANNELS], OutFloat[cmsMAXCHANNELS];
- cmsUInt32Number i;
-
- _cmsAssert(Lut -> InputChannels < cmsMAXCHANNELS);
- _cmsAssert(Lut -> OutputChannels < cmsMAXCHANNELS);
-
- // From 16 bit to floating point
- for (i=0; i < Lut ->InputChannels; i++)
- InFloat[i] = (cmsFloat32Number) (In[i] / 65535.0);
-
- // Evaluate in floating point
- cmsPipelineEvalFloat(InFloat, OutFloat, Lut);
-
- // Back to 16 bits representation
- for (i=0; i < Lut ->OutputChannels; i++)
- Out[i] = _cmsQuickSaturateWord(OutFloat[i] * 65535.0);
-
- // Always succeed
- return TRUE;
-}
-
-// Try to see if the curves of a given MPE are linear
-static
-cmsBool AllCurvesAreLinear(cmsStage* mpe)
-{
- cmsToneCurve** Curves;
- cmsUInt32Number i, n;
-
- Curves = _cmsStageGetPtrToCurveSet(mpe);
- if (Curves == NULL) return FALSE;
-
- n = cmsStageOutputChannels(mpe);
-
- for (i=0; i < n; i++) {
- if (!cmsIsToneCurveLinear(Curves[i])) return FALSE;
- }
-
- return TRUE;
-}
-
-// This function replaces a specific node placed in "At" by the "Value" numbers. Its purpose
-// is to fix scum dot on broken profiles/transforms. Works on 1, 3 and 4 channels
-static
-cmsBool PatchLUT(cmsStage* CLUT, cmsUInt16Number At[], cmsUInt16Number Value[],
- cmsUInt32Number nChannelsOut, cmsUInt32Number nChannelsIn)
-{
- _cmsStageCLutData* Grid = (_cmsStageCLutData*) CLUT ->Data;
- cmsInterpParams* p16 = Grid ->Params;
- cmsFloat64Number px, py, pz, pw;
- int x0, y0, z0, w0;
- int i, index;
-
- if (CLUT -> Type != cmsSigCLutElemType) {
- cmsSignalError(CLUT->ContextID, cmsERROR_INTERNAL, "(internal) Attempt to PatchLUT on non-lut stage");
- return FALSE;
- }
-
- if (nChannelsIn == 4) {
-
- px = ((cmsFloat64Number) At[0] * (p16->Domain[0])) / 65535.0;
- py = ((cmsFloat64Number) At[1] * (p16->Domain[1])) / 65535.0;
- pz = ((cmsFloat64Number) At[2] * (p16->Domain[2])) / 65535.0;
- pw = ((cmsFloat64Number) At[3] * (p16->Domain[3])) / 65535.0;
-
- x0 = (int) floor(px);
- y0 = (int) floor(py);
- z0 = (int) floor(pz);
- w0 = (int) floor(pw);
-
- if (((px - x0) != 0) ||
- ((py - y0) != 0) ||
- ((pz - z0) != 0) ||
- ((pw - w0) != 0)) return FALSE; // Not on exact node
-
- index = (int) p16 -> opta[3] * x0 +
- (int) p16 -> opta[2] * y0 +
- (int) p16 -> opta[1] * z0 +
- (int) p16 -> opta[0] * w0;
- }
- else
- if (nChannelsIn == 3) {
-
- px = ((cmsFloat64Number) At[0] * (p16->Domain[0])) / 65535.0;
- py = ((cmsFloat64Number) At[1] * (p16->Domain[1])) / 65535.0;
- pz = ((cmsFloat64Number) At[2] * (p16->Domain[2])) / 65535.0;
-
- x0 = (int) floor(px);
- y0 = (int) floor(py);
- z0 = (int) floor(pz);
-
- if (((px - x0) != 0) ||
- ((py - y0) != 0) ||
- ((pz - z0) != 0)) return FALSE; // Not on exact node
-
- index = (int) p16 -> opta[2] * x0 +
- (int) p16 -> opta[1] * y0 +
- (int) p16 -> opta[0] * z0;
- }
- else
- if (nChannelsIn == 1) {
-
- px = ((cmsFloat64Number) At[0] * (p16->Domain[0])) / 65535.0;
-
- x0 = (int) floor(px);
-
- if (((px - x0) != 0)) return FALSE; // Not on exact node
-
- index = (int) p16 -> opta[0] * x0;
- }
- else {
- cmsSignalError(CLUT->ContextID, cmsERROR_INTERNAL, "(internal) %d Channels are not supported on PatchLUT", nChannelsIn);
- return FALSE;
- }
-
- for (i = 0; i < (int) nChannelsOut; i++)
- Grid->Tab.T[index + i] = Value[i];
-
- return TRUE;
-}
-
-// Auxiliary, to see if two values are equal or very different
-static
-cmsBool WhitesAreEqual(cmsUInt32Number n, cmsUInt16Number White1[], cmsUInt16Number White2[] )
-{
- cmsUInt32Number i;
-
- for (i=0; i < n; i++) {
-
- if (abs(White1[i] - White2[i]) > 0xf000) return TRUE; // Values are so extremely different that the fixup should be avoided
- if (White1[i] != White2[i]) return FALSE;
- }
- return TRUE;
-}
-
-
-// Locate the node for the white point and fix it to pure white in order to avoid scum dot.
-static
-cmsBool FixWhiteMisalignment(cmsPipeline* Lut, cmsColorSpaceSignature EntryColorSpace, cmsColorSpaceSignature ExitColorSpace)
-{
- cmsUInt16Number *WhitePointIn, *WhitePointOut;
- cmsUInt16Number WhiteIn[cmsMAXCHANNELS], WhiteOut[cmsMAXCHANNELS], ObtainedOut[cmsMAXCHANNELS];
- cmsUInt32Number i, nOuts, nIns;
- cmsStage *PreLin = NULL, *CLUT = NULL, *PostLin = NULL;
-
- if (!_cmsEndPointsBySpace(EntryColorSpace,
- &WhitePointIn, NULL, &nIns)) return FALSE;
-
- if (!_cmsEndPointsBySpace(ExitColorSpace,
- &WhitePointOut, NULL, &nOuts)) return FALSE;
-
- // It needs to be fixed?
- if (Lut ->InputChannels != nIns) return FALSE;
- if (Lut ->OutputChannels != nOuts) return FALSE;
-
- cmsPipelineEval16(WhitePointIn, ObtainedOut, Lut);
-
- if (WhitesAreEqual(nOuts, WhitePointOut, ObtainedOut)) return TRUE; // whites already match
-
- // Check if the LUT comes as Prelin, CLUT or Postlin. We allow all combinations
- if (!cmsPipelineCheckAndRetreiveStages(Lut, 3, cmsSigCurveSetElemType, cmsSigCLutElemType, cmsSigCurveSetElemType, &PreLin, &CLUT, &PostLin))
- if (!cmsPipelineCheckAndRetreiveStages(Lut, 2, cmsSigCurveSetElemType, cmsSigCLutElemType, &PreLin, &CLUT))
- if (!cmsPipelineCheckAndRetreiveStages(Lut, 2, cmsSigCLutElemType, cmsSigCurveSetElemType, &CLUT, &PostLin))
- if (!cmsPipelineCheckAndRetreiveStages(Lut, 1, cmsSigCLutElemType, &CLUT))
- return FALSE;
-
- // We need to interpolate white points of both, pre and post curves
- if (PreLin) {
-
- cmsToneCurve** Curves = _cmsStageGetPtrToCurveSet(PreLin);
-
- for (i=0; i < nIns; i++) {
- WhiteIn[i] = cmsEvalToneCurve16(Curves[i], WhitePointIn[i]);
- }
- }
- else {
- for (i=0; i < nIns; i++)
- WhiteIn[i] = WhitePointIn[i];
- }
-
- // If any post-linearization, we need to find how is represented white before the curve, do
- // a reverse interpolation in this case.
- if (PostLin) {
-
- cmsToneCurve** Curves = _cmsStageGetPtrToCurveSet(PostLin);
-
- for (i=0; i < nOuts; i++) {
-
- cmsToneCurve* InversePostLin = cmsReverseToneCurve(Curves[i]);
- if (InversePostLin == NULL) {
- WhiteOut[i] = WhitePointOut[i];
-
- } else {
-
- WhiteOut[i] = cmsEvalToneCurve16(InversePostLin, WhitePointOut[i]);
- cmsFreeToneCurve(InversePostLin);
- }
- }
- }
- else {
- for (i=0; i < nOuts; i++)
- WhiteOut[i] = WhitePointOut[i];
- }
-
- // Ok, proceed with patching. May fail and we don't care if it fails
- PatchLUT(CLUT, WhiteIn, WhiteOut, nOuts, nIns);
-
- return TRUE;
-}
-
-// -----------------------------------------------------------------------------------------------------------------------------------------------
-// This function creates simple LUT from complex ones. The generated LUT has an optional set of
-// prelinearization curves, a CLUT of nGridPoints and optional postlinearization tables.
-// These curves have to exist in the original LUT in order to be used in the simplified output.
-// Caller may also use the flags to allow this feature.
-// LUTS with all curves will be simplified to a single curve. Parametric curves are lost.
-// This function should be used on 16-bits LUTS only, as floating point losses precision when simplified
-// -----------------------------------------------------------------------------------------------------------------------------------------------
-
-static
-cmsBool OptimizeByResampling(cmsPipeline** Lut, cmsUInt32Number Intent, cmsUInt32Number* InputFormat, cmsUInt32Number* OutputFormat, cmsUInt32Number* dwFlags)
-{
- cmsPipeline* Src = NULL;
- cmsPipeline* Dest = NULL;
- cmsStage* CLUT;
- cmsStage *KeepPreLin = NULL, *KeepPostLin = NULL;
- cmsUInt32Number nGridPoints;
- cmsColorSpaceSignature ColorSpace, OutputColorSpace;
- cmsStage *NewPreLin = NULL;
- cmsStage *NewPostLin = NULL;
- _cmsStageCLutData* DataCLUT;
- cmsToneCurve** DataSetIn;
- cmsToneCurve** DataSetOut;
- Prelin16Data* p16;
-
- // This is a lossy optimization! does not apply in floating-point cases
- if (_cmsFormatterIsFloat(*InputFormat) || _cmsFormatterIsFloat(*OutputFormat)) return FALSE;
-
- ColorSpace = _cmsICCcolorSpace((int) T_COLORSPACE(*InputFormat));
- OutputColorSpace = _cmsICCcolorSpace((int) T_COLORSPACE(*OutputFormat));
-
- // Color space must be specified
- if (ColorSpace == (cmsColorSpaceSignature)0 ||
- OutputColorSpace == (cmsColorSpaceSignature)0) return FALSE;
-
- nGridPoints = _cmsReasonableGridpointsByColorspace(ColorSpace, *dwFlags);
-
- // For empty LUTs, 2 points are enough
- if (cmsPipelineStageCount(*Lut) == 0)
- nGridPoints = 2;
-
- Src = *Lut;
-
- // Allocate an empty LUT
- Dest = cmsPipelineAlloc(Src ->ContextID, Src ->InputChannels, Src ->OutputChannels);
- if (!Dest) return FALSE;
-
- // Prelinearization tables are kept unless indicated by flags
- if (*dwFlags & cmsFLAGS_CLUT_PRE_LINEARIZATION) {
-
- // Get a pointer to the prelinearization element
- cmsStage* PreLin = cmsPipelineGetPtrToFirstStage(Src);
-
- // Check if suitable
- if (PreLin && PreLin ->Type == cmsSigCurveSetElemType) {
-
- // Maybe this is a linear tram, so we can avoid the whole stuff
- if (!AllCurvesAreLinear(PreLin)) {
-
- // All seems ok, proceed.
- NewPreLin = cmsStageDup(PreLin);
- if(!cmsPipelineInsertStage(Dest, cmsAT_BEGIN, NewPreLin))
- goto Error;
-
- // Remove prelinearization. Since we have duplicated the curve
- // in destination LUT, the sampling should be applied after this stage.
- cmsPipelineUnlinkStage(Src, cmsAT_BEGIN, &KeepPreLin);
- }
- }
- }
-
- // Allocate the CLUT
- CLUT = cmsStageAllocCLut16bit(Src ->ContextID, nGridPoints, Src ->InputChannels, Src->OutputChannels, NULL);
- if (CLUT == NULL) goto Error;
-
- // Add the CLUT to the destination LUT
- if (!cmsPipelineInsertStage(Dest, cmsAT_END, CLUT)) {
- goto Error;
- }
-
- // Postlinearization tables are kept unless indicated by flags
- if (*dwFlags & cmsFLAGS_CLUT_POST_LINEARIZATION) {
-
- // Get a pointer to the postlinearization if present
- cmsStage* PostLin = cmsPipelineGetPtrToLastStage(Src);
-
- // Check if suitable
- if (PostLin && cmsStageType(PostLin) == cmsSigCurveSetElemType) {
-
- // Maybe this is a linear tram, so we can avoid the whole stuff
- if (!AllCurvesAreLinear(PostLin)) {
-
- // All seems ok, proceed.
- NewPostLin = cmsStageDup(PostLin);
- if (!cmsPipelineInsertStage(Dest, cmsAT_END, NewPostLin))
- goto Error;
-
- // In destination LUT, the sampling should be applied after this stage.
- cmsPipelineUnlinkStage(Src, cmsAT_END, &KeepPostLin);
- }
- }
- }
-
- // Now its time to do the sampling. We have to ignore pre/post linearization
- // The source LUT without pre/post curves is passed as parameter.
- if (!cmsStageSampleCLut16bit(CLUT, XFormSampler16, (void*) Src, 0)) {
-Error:
- // Ops, something went wrong, Restore stages
- if (KeepPreLin != NULL) {
- if (!cmsPipelineInsertStage(Src, cmsAT_BEGIN, KeepPreLin)) {
- _cmsAssert(0); // This never happens
- }
- }
- if (KeepPostLin != NULL) {
- if (!cmsPipelineInsertStage(Src, cmsAT_END, KeepPostLin)) {
- _cmsAssert(0); // This never happens
- }
- }
- cmsPipelineFree(Dest);
- return FALSE;
- }
-
- // Done.
-
- if (KeepPreLin != NULL) cmsStageFree(KeepPreLin);
- if (KeepPostLin != NULL) cmsStageFree(KeepPostLin);
- cmsPipelineFree(Src);
-
- DataCLUT = (_cmsStageCLutData*) CLUT ->Data;
-
- if (NewPreLin == NULL) DataSetIn = NULL;
- else DataSetIn = ((_cmsStageToneCurvesData*) NewPreLin ->Data) ->TheCurves;
-
- if (NewPostLin == NULL) DataSetOut = NULL;
- else DataSetOut = ((_cmsStageToneCurvesData*) NewPostLin ->Data) ->TheCurves;
-
-
- if (DataSetIn == NULL && DataSetOut == NULL) {
-
- _cmsPipelineSetOptimizationParameters(Dest, (_cmsPipelineEval16Fn) DataCLUT->Params->Interpolation.Lerp16, DataCLUT->Params, NULL, NULL);
- }
- else {
-
- p16 = PrelinOpt16alloc(Dest ->ContextID,
- DataCLUT ->Params,
- Dest ->InputChannels,
- DataSetIn,
- Dest ->OutputChannels,
- DataSetOut);
-
- _cmsPipelineSetOptimizationParameters(Dest, PrelinEval16, (void*) p16, PrelinOpt16free, Prelin16dup);
- }
-
-
- // Don't fix white on absolute colorimetric
- if (Intent == INTENT_ABSOLUTE_COLORIMETRIC)
- *dwFlags |= cmsFLAGS_NOWHITEONWHITEFIXUP;
-
- if (!(*dwFlags & cmsFLAGS_NOWHITEONWHITEFIXUP)) {
-
- FixWhiteMisalignment(Dest, ColorSpace, OutputColorSpace);
- }
-
- *Lut = Dest;
- return TRUE;
-
- cmsUNUSED_PARAMETER(Intent);
-}
-
-
-// -----------------------------------------------------------------------------------------------------------------------------------------------
-// Fixes the gamma balancing of transform. This is described in my paper "Prelinearization Stages on
-// Color-Management Application-Specific Integrated Circuits (ASICs)" presented at NIP24. It only works
-// for RGB transforms. See the paper for more details
-// -----------------------------------------------------------------------------------------------------------------------------------------------
-
-
-// Normalize endpoints by slope limiting max and min. This assures endpoints as well.
-// Descending curves are handled as well.
-static
-void SlopeLimiting(cmsToneCurve* g)
-{
- int BeginVal, EndVal;
- int AtBegin = (int) floor((cmsFloat64Number) g ->nEntries * 0.02 + 0.5); // Cutoff at 2%
- int AtEnd = (int) g ->nEntries - AtBegin - 1; // And 98%
- cmsFloat64Number Val, Slope, beta;
- int i;
-
- if (cmsIsToneCurveDescending(g)) {
- BeginVal = 0xffff; EndVal = 0;
- }
- else {
- BeginVal = 0; EndVal = 0xffff;
- }
-
- // Compute slope and offset for begin of curve
- Val = g ->Table16[AtBegin];
- Slope = (Val - BeginVal) / AtBegin;
- beta = Val - Slope * AtBegin;
-
- for (i=0; i < AtBegin; i++)
- g ->Table16[i] = _cmsQuickSaturateWord(i * Slope + beta);
-
- // Compute slope and offset for the end
- Val = g ->Table16[AtEnd];
- Slope = (EndVal - Val) / AtBegin; // AtBegin holds the X interval, which is same in both cases
- beta = Val - Slope * AtEnd;
-
- for (i = AtEnd; i < (int) g ->nEntries; i++)
- g ->Table16[i] = _cmsQuickSaturateWord(i * Slope + beta);
-}
-
-
-// Precomputes tables for 8-bit on input devicelink.
-static
-Prelin8Data* PrelinOpt8alloc(cmsContext ContextID, const cmsInterpParams* p, cmsToneCurve* G[3])
-{
- int i;
- cmsUInt16Number Input[3];
- cmsS15Fixed16Number v1, v2, v3;
- Prelin8Data* p8;
-
- p8 = (Prelin8Data*)_cmsMallocZero(ContextID, sizeof(Prelin8Data));
- if (p8 == NULL) return NULL;
-
- // Since this only works for 8 bit input, values comes always as x * 257,
- // we can safely take msb byte (x << 8 + x)
-
- for (i=0; i < 256; i++) {
-
- if (G != NULL) {
-
- // Get 16-bit representation
- Input[0] = cmsEvalToneCurve16(G[0], FROM_8_TO_16(i));
- Input[1] = cmsEvalToneCurve16(G[1], FROM_8_TO_16(i));
- Input[2] = cmsEvalToneCurve16(G[2], FROM_8_TO_16(i));
- }
- else {
- Input[0] = FROM_8_TO_16(i);
- Input[1] = FROM_8_TO_16(i);
- Input[2] = FROM_8_TO_16(i);
- }
-
-
- // Move to 0..1.0 in fixed domain
- v1 = _cmsToFixedDomain((int) (Input[0] * p -> Domain[0]));
- v2 = _cmsToFixedDomain((int) (Input[1] * p -> Domain[1]));
- v3 = _cmsToFixedDomain((int) (Input[2] * p -> Domain[2]));
-
- // Store the precalculated table of nodes
- p8 ->X0[i] = (p->opta[2] * FIXED_TO_INT(v1));
- p8 ->Y0[i] = (p->opta[1] * FIXED_TO_INT(v2));
- p8 ->Z0[i] = (p->opta[0] * FIXED_TO_INT(v3));
-
- // Store the precalculated table of offsets
- p8 ->rx[i] = (cmsUInt16Number) FIXED_REST_TO_INT(v1);
- p8 ->ry[i] = (cmsUInt16Number) FIXED_REST_TO_INT(v2);
- p8 ->rz[i] = (cmsUInt16Number) FIXED_REST_TO_INT(v3);
- }
-
- p8 ->ContextID = ContextID;
- p8 ->p = p;
-
- return p8;
-}
-
-static
-void Prelin8free(cmsContext ContextID, void* ptr)
-{
- _cmsFree(ContextID, ptr);
-}
-
-static
-void* Prelin8dup(cmsContext ContextID, const void* ptr)
-{
- return _cmsDupMem(ContextID, ptr, sizeof(Prelin8Data));
-}
-
-
-
-// A optimized interpolation for 8-bit input.
-#define DENS(i,j,k) (LutTable[(i)+(j)+(k)+OutChan])
-static CMS_NO_SANITIZE
-void PrelinEval8(CMSREGISTER const cmsUInt16Number Input[],
- CMSREGISTER cmsUInt16Number Output[],
- CMSREGISTER const void* D)
-{
-
- cmsUInt8Number r, g, b;
- cmsS15Fixed16Number rx, ry, rz;
- cmsS15Fixed16Number c0, c1, c2, c3, Rest;
- int OutChan;
- CMSREGISTER cmsS15Fixed16Number X0, X1, Y0, Y1, Z0, Z1;
- Prelin8Data* p8 = (Prelin8Data*) D;
- CMSREGISTER const cmsInterpParams* p = p8 ->p;
- int TotalOut = (int) p -> nOutputs;
- const cmsUInt16Number* LutTable = (const cmsUInt16Number*) p->Table;
-
- r = (cmsUInt8Number) (Input[0] >> 8);
- g = (cmsUInt8Number) (Input[1] >> 8);
- b = (cmsUInt8Number) (Input[2] >> 8);
-
- X0 = (cmsS15Fixed16Number) p8->X0[r];
- Y0 = (cmsS15Fixed16Number) p8->Y0[g];
- Z0 = (cmsS15Fixed16Number) p8->Z0[b];
-
- rx = p8 ->rx[r];
- ry = p8 ->ry[g];
- rz = p8 ->rz[b];
-
- X1 = X0 + (cmsS15Fixed16Number)((rx == 0) ? 0 : p ->opta[2]);
- Y1 = Y0 + (cmsS15Fixed16Number)((ry == 0) ? 0 : p ->opta[1]);
- Z1 = Z0 + (cmsS15Fixed16Number)((rz == 0) ? 0 : p ->opta[0]);
-
-
- // These are the 6 Tetrahedral
- for (OutChan=0; OutChan < TotalOut; OutChan++) {
-
- c0 = DENS(X0, Y0, Z0);
-
- if (rx >= ry && ry >= rz)
- {
- c1 = DENS(X1, Y0, Z0) - c0;
- c2 = DENS(X1, Y1, Z0) - DENS(X1, Y0, Z0);
- c3 = DENS(X1, Y1, Z1) - DENS(X1, Y1, Z0);
- }
- else
- if (rx >= rz && rz >= ry)
- {
- c1 = DENS(X1, Y0, Z0) - c0;
- c2 = DENS(X1, Y1, Z1) - DENS(X1, Y0, Z1);
- c3 = DENS(X1, Y0, Z1) - DENS(X1, Y0, Z0);
- }
- else
- if (rz >= rx && rx >= ry)
- {
- c1 = DENS(X1, Y0, Z1) - DENS(X0, Y0, Z1);
- c2 = DENS(X1, Y1, Z1) - DENS(X1, Y0, Z1);
- c3 = DENS(X0, Y0, Z1) - c0;
- }
- else
- if (ry >= rx && rx >= rz)
- {
- c1 = DENS(X1, Y1, Z0) - DENS(X0, Y1, Z0);
- c2 = DENS(X0, Y1, Z0) - c0;
- c3 = DENS(X1, Y1, Z1) - DENS(X1, Y1, Z0);
- }
- else
- if (ry >= rz && rz >= rx)
- {
- c1 = DENS(X1, Y1, Z1) - DENS(X0, Y1, Z1);
- c2 = DENS(X0, Y1, Z0) - c0;
- c3 = DENS(X0, Y1, Z1) - DENS(X0, Y1, Z0);
- }
- else
- if (rz >= ry && ry >= rx)
- {
- c1 = DENS(X1, Y1, Z1) - DENS(X0, Y1, Z1);
- c2 = DENS(X0, Y1, Z1) - DENS(X0, Y0, Z1);
- c3 = DENS(X0, Y0, Z1) - c0;
- }
- else {
- c1 = c2 = c3 = 0;
- }
-
- Rest = c1 * rx + c2 * ry + c3 * rz + 0x8001;
- Output[OutChan] = (cmsUInt16Number) (c0 + ((Rest + (Rest >> 16)) >> 16));
-
- }
-}
-
-#undef DENS
-
-
-// Curves that contain wide empty areas are not optimizeable
-static
-cmsBool IsDegenerated(const cmsToneCurve* g)
-{
- cmsUInt32Number i, Zeros = 0, Poles = 0;
- cmsUInt32Number nEntries = g ->nEntries;
-
- for (i=0; i < nEntries; i++) {
-
- if (g ->Table16[i] == 0x0000) Zeros++;
- if (g ->Table16[i] == 0xffff) Poles++;
- }
-
- if (Zeros == 1 && Poles == 1) return FALSE; // For linear tables
- if (Zeros > (nEntries / 20)) return TRUE; // Degenerated, many zeros
- if (Poles > (nEntries / 20)) return TRUE; // Degenerated, many poles
-
- return FALSE;
-}
-
-// --------------------------------------------------------------------------------------------------------------
-// We need xput over here
-
-static
-cmsBool OptimizeByComputingLinearization(cmsPipeline** Lut, cmsUInt32Number Intent, cmsUInt32Number* InputFormat, cmsUInt32Number* OutputFormat, cmsUInt32Number* dwFlags)
-{
- cmsPipeline* OriginalLut;
- cmsUInt32Number nGridPoints;
- cmsToneCurve *Trans[cmsMAXCHANNELS], *TransReverse[cmsMAXCHANNELS];
- cmsUInt32Number t, i;
- cmsFloat32Number v, In[cmsMAXCHANNELS], Out[cmsMAXCHANNELS];
- cmsBool lIsSuitable, lIsLinear;
- cmsPipeline* OptimizedLUT = NULL, *LutPlusCurves = NULL;
- cmsStage* OptimizedCLUTmpe;
- cmsColorSpaceSignature ColorSpace, OutputColorSpace;
- cmsStage* OptimizedPrelinMpe;
- cmsToneCurve** OptimizedPrelinCurves;
- _cmsStageCLutData* OptimizedPrelinCLUT;
-
-
- // This is a lossy optimization! does not apply in floating-point cases
- if (_cmsFormatterIsFloat(*InputFormat) || _cmsFormatterIsFloat(*OutputFormat)) return FALSE;
-
- // Only on chunky RGB
- if (T_COLORSPACE(*InputFormat) != PT_RGB) return FALSE;
- if (T_PLANAR(*InputFormat)) return FALSE;
-
- if (T_COLORSPACE(*OutputFormat) != PT_RGB) return FALSE;
- if (T_PLANAR(*OutputFormat)) return FALSE;
-
- // On 16 bits, user has to specify the feature
- if (!_cmsFormatterIs8bit(*InputFormat)) {
- if (!(*dwFlags & cmsFLAGS_CLUT_PRE_LINEARIZATION)) return FALSE;
- }
-
- OriginalLut = *Lut;
-
- ColorSpace = _cmsICCcolorSpace((int) T_COLORSPACE(*InputFormat));
- OutputColorSpace = _cmsICCcolorSpace((int) T_COLORSPACE(*OutputFormat));
-
- // Color space must be specified
- if (ColorSpace == (cmsColorSpaceSignature)0 ||
- OutputColorSpace == (cmsColorSpaceSignature)0) return FALSE;
-
- nGridPoints = _cmsReasonableGridpointsByColorspace(ColorSpace, *dwFlags);
-
- // Empty gamma containers
- memset(Trans, 0, sizeof(Trans));
- memset(TransReverse, 0, sizeof(TransReverse));
-
- // If the last stage of the original lut are curves, and those curves are
- // degenerated, it is likely the transform is squeezing and clipping
- // the output from previous CLUT. We cannot optimize this case
- {
- cmsStage* last = cmsPipelineGetPtrToLastStage(OriginalLut);
-
- if (last == NULL) goto Error;
- if (cmsStageType(last) == cmsSigCurveSetElemType) {
-
- _cmsStageToneCurvesData* Data = (_cmsStageToneCurvesData*)cmsStageData(last);
- for (i = 0; i < Data->nCurves; i++) {
- if (IsDegenerated(Data->TheCurves[i]))
- goto Error;
- }
- }
- }
-
- for (t = 0; t < OriginalLut ->InputChannels; t++) {
- Trans[t] = cmsBuildTabulatedToneCurve16(OriginalLut ->ContextID, PRELINEARIZATION_POINTS, NULL);
- if (Trans[t] == NULL) goto Error;
- }
-
- // Populate the curves
- for (i=0; i < PRELINEARIZATION_POINTS; i++) {
-
- v = (cmsFloat32Number) ((cmsFloat64Number) i / (PRELINEARIZATION_POINTS - 1));
-
- // Feed input with a gray ramp
- for (t=0; t < OriginalLut ->InputChannels; t++)
- In[t] = v;
-
- // Evaluate the gray value
- cmsPipelineEvalFloat(In, Out, OriginalLut);
-
- // Store result in curve
- for (t=0; t < OriginalLut ->InputChannels; t++)
- {
- if (Trans[t]->Table16 != NULL)
- Trans[t] ->Table16[i] = _cmsQuickSaturateWord(Out[t] * 65535.0);
- }
- }
-
- // Slope-limit the obtained curves
- for (t = 0; t < OriginalLut ->InputChannels; t++)
- SlopeLimiting(Trans[t]);
-
- // Check for validity. lIsLinear is here for debug purposes
- lIsSuitable = TRUE;
- lIsLinear = TRUE;
- for (t=0; (lIsSuitable && (t < OriginalLut ->InputChannels)); t++) {
-
- // Exclude if already linear
- if (!cmsIsToneCurveLinear(Trans[t]))
- lIsLinear = FALSE;
-
- // Exclude if non-monotonic
- if (!cmsIsToneCurveMonotonic(Trans[t]))
- lIsSuitable = FALSE;
-
- if (IsDegenerated(Trans[t]))
- lIsSuitable = FALSE;
- }
-
- // If it is not suitable, just quit
- if (!lIsSuitable) goto Error;
-
- // Invert curves if possible
- for (t = 0; t < OriginalLut ->InputChannels; t++) {
- TransReverse[t] = cmsReverseToneCurveEx(PRELINEARIZATION_POINTS, Trans[t]);
- if (TransReverse[t] == NULL) goto Error;
- }
-
- // Now inset the reversed curves at the begin of transform
- LutPlusCurves = cmsPipelineDup(OriginalLut);
- if (LutPlusCurves == NULL) goto Error;
-
- if (!cmsPipelineInsertStage(LutPlusCurves, cmsAT_BEGIN, cmsStageAllocToneCurves(OriginalLut ->ContextID, OriginalLut ->InputChannels, TransReverse)))
- goto Error;
-
- // Create the result LUT
- OptimizedLUT = cmsPipelineAlloc(OriginalLut ->ContextID, OriginalLut ->InputChannels, OriginalLut ->OutputChannels);
- if (OptimizedLUT == NULL) goto Error;
-
- OptimizedPrelinMpe = cmsStageAllocToneCurves(OriginalLut ->ContextID, OriginalLut ->InputChannels, Trans);
-
- // Create and insert the curves at the beginning
- if (!cmsPipelineInsertStage(OptimizedLUT, cmsAT_BEGIN, OptimizedPrelinMpe))
- goto Error;
-
- // Allocate the CLUT for result
- OptimizedCLUTmpe = cmsStageAllocCLut16bit(OriginalLut ->ContextID, nGridPoints, OriginalLut ->InputChannels, OriginalLut ->OutputChannels, NULL);
-
- // Add the CLUT to the destination LUT
- if (!cmsPipelineInsertStage(OptimizedLUT, cmsAT_END, OptimizedCLUTmpe))
- goto Error;
-
- // Resample the LUT
- if (!cmsStageSampleCLut16bit(OptimizedCLUTmpe, XFormSampler16, (void*) LutPlusCurves, 0)) goto Error;
-
- // Free resources
- for (t = 0; t < OriginalLut ->InputChannels; t++) {
-
- if (Trans[t]) cmsFreeToneCurve(Trans[t]);
- if (TransReverse[t]) cmsFreeToneCurve(TransReverse[t]);
- }
-
- cmsPipelineFree(LutPlusCurves);
-
-
- OptimizedPrelinCurves = _cmsStageGetPtrToCurveSet(OptimizedPrelinMpe);
- OptimizedPrelinCLUT = (_cmsStageCLutData*) OptimizedCLUTmpe ->Data;
-
- // Set the evaluator if 8-bit
- if (_cmsFormatterIs8bit(*InputFormat)) {
-
- Prelin8Data* p8 = PrelinOpt8alloc(OptimizedLUT ->ContextID,
- OptimizedPrelinCLUT ->Params,
- OptimizedPrelinCurves);
- if (p8 == NULL) return FALSE;
-
- _cmsPipelineSetOptimizationParameters(OptimizedLUT, PrelinEval8, (void*) p8, Prelin8free, Prelin8dup);
-
- }
- else
- {
- Prelin16Data* p16 = PrelinOpt16alloc(OptimizedLUT ->ContextID,
- OptimizedPrelinCLUT ->Params,
- 3, OptimizedPrelinCurves, 3, NULL);
- if (p16 == NULL) return FALSE;
-
- _cmsPipelineSetOptimizationParameters(OptimizedLUT, PrelinEval16, (void*) p16, PrelinOpt16free, Prelin16dup);
-
- }
-
- // Don't fix white on absolute colorimetric
- if (Intent == INTENT_ABSOLUTE_COLORIMETRIC)
- *dwFlags |= cmsFLAGS_NOWHITEONWHITEFIXUP;
-
- if (!(*dwFlags & cmsFLAGS_NOWHITEONWHITEFIXUP)) {
-
- if (!FixWhiteMisalignment(OptimizedLUT, ColorSpace, OutputColorSpace)) {
-
- return FALSE;
- }
- }
-
- // And return the obtained LUT
-
- cmsPipelineFree(OriginalLut);
- *Lut = OptimizedLUT;
- return TRUE;
-
-Error:
-
- for (t = 0; t < OriginalLut ->InputChannels; t++) {
-
- if (Trans[t]) cmsFreeToneCurve(Trans[t]);
- if (TransReverse[t]) cmsFreeToneCurve(TransReverse[t]);
- }
-
- if (LutPlusCurves != NULL) cmsPipelineFree(LutPlusCurves);
- if (OptimizedLUT != NULL) cmsPipelineFree(OptimizedLUT);
-
- return FALSE;
-
- cmsUNUSED_PARAMETER(Intent);
- cmsUNUSED_PARAMETER(lIsLinear);
-}
-
-
-// Curves optimizer ------------------------------------------------------------------------------------------------------------------
-
-static
-void CurvesFree(cmsContext ContextID, void* ptr)
-{
- Curves16Data* Data = (Curves16Data*) ptr;
- cmsUInt32Number i;
-
- for (i=0; i < Data -> nCurves; i++) {
-
- _cmsFree(ContextID, Data ->Curves[i]);
- }
-
- _cmsFree(ContextID, Data ->Curves);
- _cmsFree(ContextID, ptr);
-}
-
-static
-void* CurvesDup(cmsContext ContextID, const void* ptr)
-{
- Curves16Data* Data = (Curves16Data*)_cmsDupMem(ContextID, ptr, sizeof(Curves16Data));
- cmsUInt32Number i;
-
- if (Data == NULL) return NULL;
-
- Data->Curves = (cmsUInt16Number**) _cmsDupMem(ContextID, Data->Curves, Data->nCurves * sizeof(cmsUInt16Number*));
-
- for (i=0; i < Data -> nCurves; i++) {
- Data->Curves[i] = (cmsUInt16Number*) _cmsDupMem(ContextID, Data->Curves[i], Data->nElements * sizeof(cmsUInt16Number));
- }
-
- return (void*) Data;
-}
-
-// Precomputes tables for 8-bit on input devicelink.
-static
-Curves16Data* CurvesAlloc(cmsContext ContextID, cmsUInt32Number nCurves, cmsUInt32Number nElements, cmsToneCurve** G)
-{
- cmsUInt32Number i, j;
- Curves16Data* c16;
-
- c16 = (Curves16Data*)_cmsMallocZero(ContextID, sizeof(Curves16Data));
- if (c16 == NULL) return NULL;
-
- c16 ->nCurves = nCurves;
- c16 ->nElements = nElements;
-
- c16->Curves = (cmsUInt16Number**) _cmsCalloc(ContextID, nCurves, sizeof(cmsUInt16Number*));
- if (c16->Curves == NULL) {
- _cmsFree(ContextID, c16);
- return NULL;
- }
-
- for (i=0; i < nCurves; i++) {
-
- c16->Curves[i] = (cmsUInt16Number*) _cmsCalloc(ContextID, nElements, sizeof(cmsUInt16Number));
-
- if (c16->Curves[i] == NULL) {
-
- for (j=0; j < i; j++) {
- _cmsFree(ContextID, c16->Curves[j]);
- }
- _cmsFree(ContextID, c16->Curves);
- _cmsFree(ContextID, c16);
- return NULL;
- }
-
- if (nElements == 256U) {
-
- for (j=0; j < nElements; j++) {
-
- c16 ->Curves[i][j] = cmsEvalToneCurve16(G[i], FROM_8_TO_16(j));
- }
- }
- else {
-
- for (j=0; j < nElements; j++) {
- c16 ->Curves[i][j] = cmsEvalToneCurve16(G[i], (cmsUInt16Number) j);
- }
- }
- }
-
- return c16;
-}
-
-static
-void FastEvaluateCurves8(CMSREGISTER const cmsUInt16Number In[],
- CMSREGISTER cmsUInt16Number Out[],
- CMSREGISTER const void* D)
-{
- Curves16Data* Data = (Curves16Data*) D;
- int x;
- cmsUInt32Number i;
-
- for (i=0; i < Data ->nCurves; i++) {
-
- x = (In[i] >> 8);
- Out[i] = Data -> Curves[i][x];
- }
-}
-
-
-static
-void FastEvaluateCurves16(CMSREGISTER const cmsUInt16Number In[],
- CMSREGISTER cmsUInt16Number Out[],
- CMSREGISTER const void* D)
-{
- Curves16Data* Data = (Curves16Data*) D;
- cmsUInt32Number i;
-
- for (i=0; i < Data ->nCurves; i++) {
- Out[i] = Data -> Curves[i][In[i]];
- }
-}
-
-
-static
-void FastIdentity16(CMSREGISTER const cmsUInt16Number In[],
- CMSREGISTER cmsUInt16Number Out[],
- CMSREGISTER const void* D)
-{
- cmsPipeline* Lut = (cmsPipeline*) D;
- cmsUInt32Number i;
-
- for (i=0; i < Lut ->InputChannels; i++) {
- Out[i] = In[i];
- }
-}
-
-
-// If the target LUT holds only curves, the optimization procedure is to join all those
-// curves together. That only works on curves and does not work on matrices.
-static
-cmsBool OptimizeByJoiningCurves(cmsPipeline** Lut, cmsUInt32Number Intent, cmsUInt32Number* InputFormat, cmsUInt32Number* OutputFormat, cmsUInt32Number* dwFlags)
-{
- cmsToneCurve** GammaTables = NULL;
- cmsFloat32Number InFloat[cmsMAXCHANNELS], OutFloat[cmsMAXCHANNELS];
- cmsUInt32Number i, j;
- cmsPipeline* Src = *Lut;
- cmsPipeline* Dest = NULL;
- cmsStage* mpe;
- cmsStage* ObtainedCurves = NULL;
-
-
- // This is a lossy optimization! does not apply in floating-point cases
- if (_cmsFormatterIsFloat(*InputFormat) || _cmsFormatterIsFloat(*OutputFormat)) return FALSE;
-
- // Only curves in this LUT?
- for (mpe = cmsPipelineGetPtrToFirstStage(Src);
- mpe != NULL;
- mpe = cmsStageNext(mpe)) {
- if (cmsStageType(mpe) != cmsSigCurveSetElemType) return FALSE;
- }
-
- // Allocate an empty LUT
- Dest = cmsPipelineAlloc(Src ->ContextID, Src ->InputChannels, Src ->OutputChannels);
- if (Dest == NULL) return FALSE;
-
- // Create target curves
- GammaTables = (cmsToneCurve**) _cmsCalloc(Src ->ContextID, Src ->InputChannels, sizeof(cmsToneCurve*));
- if (GammaTables == NULL) goto Error;
-
- for (i=0; i < Src ->InputChannels; i++) {
- GammaTables[i] = cmsBuildTabulatedToneCurve16(Src ->ContextID, PRELINEARIZATION_POINTS, NULL);
- if (GammaTables[i] == NULL) goto Error;
- }
-
- // Compute 16 bit result by using floating point
- for (i=0; i < PRELINEARIZATION_POINTS; i++) {
-
- for (j=0; j < Src ->InputChannels; j++)
- InFloat[j] = (cmsFloat32Number) ((cmsFloat64Number) i / (PRELINEARIZATION_POINTS - 1));
-
- cmsPipelineEvalFloat(InFloat, OutFloat, Src);
-
- for (j=0; j < Src ->InputChannels; j++)
- GammaTables[j] -> Table16[i] = _cmsQuickSaturateWord(OutFloat[j] * 65535.0);
- }
-
- ObtainedCurves = cmsStageAllocToneCurves(Src ->ContextID, Src ->InputChannels, GammaTables);
- if (ObtainedCurves == NULL) goto Error;
-
- for (i=0; i < Src ->InputChannels; i++) {
- cmsFreeToneCurve(GammaTables[i]);
- GammaTables[i] = NULL;
- }
-
- if (GammaTables != NULL) {
- _cmsFree(Src->ContextID, GammaTables);
- GammaTables = NULL;
- }
-
- // Maybe the curves are linear at the end
- if (!AllCurvesAreLinear(ObtainedCurves)) {
- _cmsStageToneCurvesData* Data;
-
- if (!cmsPipelineInsertStage(Dest, cmsAT_BEGIN, ObtainedCurves))
- goto Error;
- Data = (_cmsStageToneCurvesData*) cmsStageData(ObtainedCurves);
- ObtainedCurves = NULL;
-
- // If the curves are to be applied in 8 bits, we can save memory
- if (_cmsFormatterIs8bit(*InputFormat)) {
- Curves16Data* c16 = CurvesAlloc(Dest ->ContextID, Data ->nCurves, 256, Data ->TheCurves);
-
- if (c16 == NULL) goto Error;
- *dwFlags |= cmsFLAGS_NOCACHE;
- _cmsPipelineSetOptimizationParameters(Dest, FastEvaluateCurves8, c16, CurvesFree, CurvesDup);
-
- }
- else {
- Curves16Data* c16 = CurvesAlloc(Dest ->ContextID, Data ->nCurves, 65536, Data ->TheCurves);
-
- if (c16 == NULL) goto Error;
- *dwFlags |= cmsFLAGS_NOCACHE;
- _cmsPipelineSetOptimizationParameters(Dest, FastEvaluateCurves16, c16, CurvesFree, CurvesDup);
- }
- }
- else {
-
- // LUT optimizes to nothing. Set the identity LUT
- cmsStageFree(ObtainedCurves);
- ObtainedCurves = NULL;
-
- if (!cmsPipelineInsertStage(Dest, cmsAT_BEGIN, cmsStageAllocIdentity(Dest ->ContextID, Src ->InputChannels)))
- goto Error;
-
- *dwFlags |= cmsFLAGS_NOCACHE;
- _cmsPipelineSetOptimizationParameters(Dest, FastIdentity16, (void*) Dest, NULL, NULL);
- }
-
- // We are done.
- cmsPipelineFree(Src);
- *Lut = Dest;
- return TRUE;
-
-Error:
-
- if (ObtainedCurves != NULL) cmsStageFree(ObtainedCurves);
- if (GammaTables != NULL) {
- for (i=0; i < Src ->InputChannels; i++) {
- if (GammaTables[i] != NULL) cmsFreeToneCurve(GammaTables[i]);
- }
-
- _cmsFree(Src ->ContextID, GammaTables);
- }
-
- if (Dest != NULL) cmsPipelineFree(Dest);
- return FALSE;
-
- cmsUNUSED_PARAMETER(Intent);
- cmsUNUSED_PARAMETER(InputFormat);
- cmsUNUSED_PARAMETER(OutputFormat);
- cmsUNUSED_PARAMETER(dwFlags);
-}
-
-// -------------------------------------------------------------------------------------------------------------------------------------
-// LUT is Shaper - Matrix - Matrix - Shaper, which is very frequent when combining two matrix-shaper profiles
-
-
-static
-void FreeMatShaper(cmsContext ContextID, void* Data)
-{
- if (Data != NULL) _cmsFree(ContextID, Data);
-}
-
-static
-void* DupMatShaper(cmsContext ContextID, const void* Data)
-{
- return _cmsDupMem(ContextID, Data, sizeof(MatShaper8Data));
-}
-
-
-// A fast matrix-shaper evaluator for 8 bits. This is a bit tricky since I'm using 1.14 signed fixed point
-// to accomplish some performance. Actually it takes 256x3 16 bits tables and 16385 x 3 tables of 8 bits,
-// in total about 50K, and the performance boost is huge!
-static CMS_NO_SANITIZE
-void MatShaperEval16(CMSREGISTER const cmsUInt16Number In[],
- CMSREGISTER cmsUInt16Number Out[],
- CMSREGISTER const void* D)
-{
- MatShaper8Data* p = (MatShaper8Data*) D;
- cmsS1Fixed14Number l1, l2, l3, r, g, b;
- cmsUInt32Number ri, gi, bi;
-
- // In this case (and only in this case!) we can use this simplification since
- // In[] is assured to come from a 8 bit number. (a << 8 | a)
- ri = In[0] & 0xFFU;
- gi = In[1] & 0xFFU;
- bi = In[2] & 0xFFU;
-
- // Across first shaper, which also converts to 1.14 fixed point
- r = p->Shaper1R[ri];
- g = p->Shaper1G[gi];
- b = p->Shaper1B[bi];
-
- // Evaluate the matrix in 1.14 fixed point
- l1 = (p->Mat[0][0] * r + p->Mat[0][1] * g + p->Mat[0][2] * b + p->Off[0] + 0x2000) >> 14;
- l2 = (p->Mat[1][0] * r + p->Mat[1][1] * g + p->Mat[1][2] * b + p->Off[1] + 0x2000) >> 14;
- l3 = (p->Mat[2][0] * r + p->Mat[2][1] * g + p->Mat[2][2] * b + p->Off[2] + 0x2000) >> 14;
-
- // Now we have to clip to 0..1.0 range
- ri = (l1 < 0) ? 0 : ((l1 > 16384) ? 16384U : (cmsUInt32Number) l1);
- gi = (l2 < 0) ? 0 : ((l2 > 16384) ? 16384U : (cmsUInt32Number) l2);
- bi = (l3 < 0) ? 0 : ((l3 > 16384) ? 16384U : (cmsUInt32Number) l3);
-
- // And across second shaper,
- Out[0] = p->Shaper2R[ri];
- Out[1] = p->Shaper2G[gi];
- Out[2] = p->Shaper2B[bi];
-
-}
-
-// This table converts from 8 bits to 1.14 after applying the curve
-static
-void FillFirstShaper(cmsS1Fixed14Number* Table, cmsToneCurve* Curve)
-{
- int i;
- cmsFloat32Number R, y;
-
- for (i=0; i < 256; i++) {
-
- R = (cmsFloat32Number) (i / 255.0);
- y = cmsEvalToneCurveFloat(Curve, R);
-
- if (y < 131072.0)
- Table[i] = DOUBLE_TO_1FIXED14(y);
- else
- Table[i] = 0x7fffffff;
- }
-}
-
-// This table converts form 1.14 (being 0x4000 the last entry) to 8 bits after applying the curve
-static
-void FillSecondShaper(cmsUInt16Number* Table, cmsToneCurve* Curve, cmsBool Is8BitsOutput)
-{
- int i;
- cmsFloat32Number R, Val;
-
- for (i=0; i < 16385; i++) {
-
- R = (cmsFloat32Number) (i / 16384.0);
- Val = cmsEvalToneCurveFloat(Curve, R); // Val comes 0..1.0
-
- if (Val < 0)
- Val = 0;
-
- if (Val > 1.0)
- Val = 1.0;
-
- if (Is8BitsOutput) {
-
- // If 8 bits output, we can optimize further by computing the / 257 part.
- // first we compute the resulting byte and then we store the byte times
- // 257. This quantization allows to round very quick by doing a >> 8, but
- // since the low byte is always equal to msb, we can do a & 0xff and this works!
- cmsUInt16Number w = _cmsQuickSaturateWord(Val * 65535.0);
- cmsUInt8Number b = FROM_16_TO_8(w);
-
- Table[i] = FROM_8_TO_16(b);
- }
- else Table[i] = _cmsQuickSaturateWord(Val * 65535.0);
- }
-}
-
-// Compute the matrix-shaper structure
-static
-cmsBool SetMatShaper(cmsPipeline* Dest, cmsToneCurve* Curve1[3], cmsMAT3* Mat, cmsVEC3* Off, cmsToneCurve* Curve2[3], cmsUInt32Number* OutputFormat)
-{
- MatShaper8Data* p;
- int i, j;
- cmsBool Is8Bits = _cmsFormatterIs8bit(*OutputFormat);
-
- // Allocate a big chuck of memory to store precomputed tables
- p = (MatShaper8Data*) _cmsMalloc(Dest ->ContextID, sizeof(MatShaper8Data));
- if (p == NULL) return FALSE;
-
- p -> ContextID = Dest -> ContextID;
-
- // Precompute tables
- FillFirstShaper(p ->Shaper1R, Curve1[0]);
- FillFirstShaper(p ->Shaper1G, Curve1[1]);
- FillFirstShaper(p ->Shaper1B, Curve1[2]);
-
- FillSecondShaper(p ->Shaper2R, Curve2[0], Is8Bits);
- FillSecondShaper(p ->Shaper2G, Curve2[1], Is8Bits);
- FillSecondShaper(p ->Shaper2B, Curve2[2], Is8Bits);
-
- // Convert matrix to nFixed14. Note that those values may take more than 16 bits
- for (i=0; i < 3; i++) {
- for (j=0; j < 3; j++) {
- p ->Mat[i][j] = DOUBLE_TO_1FIXED14(Mat->v[i].n[j]);
- }
- }
-
- for (i=0; i < 3; i++) {
-
- if (Off == NULL) {
- p ->Off[i] = 0;
- }
- else {
- p ->Off[i] = DOUBLE_TO_1FIXED14(Off->n[i]);
- }
- }
-
- // Mark as optimized for faster formatter
- if (Is8Bits)
- *OutputFormat |= OPTIMIZED_SH(1);
-
- // Fill function pointers
- _cmsPipelineSetOptimizationParameters(Dest, MatShaperEval16, (void*) p, FreeMatShaper, DupMatShaper);
- return TRUE;
-}
-
-// 8 bits on input allows matrix-shaper boot up to 25 Mpixels per second on RGB. That's fast!
-static
-cmsBool OptimizeMatrixShaper(cmsPipeline** Lut, cmsUInt32Number Intent, cmsUInt32Number* InputFormat, cmsUInt32Number* OutputFormat, cmsUInt32Number* dwFlags)
-{
- cmsStage* Curve1, *Curve2;
- cmsStage* Matrix1, *Matrix2;
- cmsMAT3 res;
- cmsBool IdentityMat;
- cmsPipeline* Dest, *Src;
- cmsFloat64Number* Offset;
-
- // Only works on RGB to RGB
- if (T_CHANNELS(*InputFormat) != 3 || T_CHANNELS(*OutputFormat) != 3) return FALSE;
-
- // Only works on 8 bit input
- if (!_cmsFormatterIs8bit(*InputFormat)) return FALSE;
-
- // Seems suitable, proceed
- Src = *Lut;
-
- // Check for:
- //
- // shaper-matrix-matrix-shaper
- // shaper-matrix-shaper
- //
- // Both of those constructs are possible (first because abs. colorimetric).
- // additionally, In the first case, the input matrix offset should be zero.
-
- IdentityMat = FALSE;
- if (cmsPipelineCheckAndRetreiveStages(Src, 4,
- cmsSigCurveSetElemType, cmsSigMatrixElemType, cmsSigMatrixElemType, cmsSigCurveSetElemType,
- &Curve1, &Matrix1, &Matrix2, &Curve2)) {
-
- // Get both matrices
- _cmsStageMatrixData* Data1 = (_cmsStageMatrixData*)cmsStageData(Matrix1);
- _cmsStageMatrixData* Data2 = (_cmsStageMatrixData*)cmsStageData(Matrix2);
-
- // Only RGB to RGB
- if (Matrix1->InputChannels != 3 || Matrix1->OutputChannels != 3 ||
- Matrix2->InputChannels != 3 || Matrix2->OutputChannels != 3) return FALSE;
-
- // Input offset should be zero
- if (Data1->Offset != NULL) return FALSE;
-
- // Multiply both matrices to get the result
- _cmsMAT3per(&res, (cmsMAT3*)Data2->Double, (cmsMAT3*)Data1->Double);
-
- // Only 2nd matrix has offset, or it is zero
- Offset = Data2->Offset;
-
- // Now the result is in res + Data2 -> Offset. Maybe is a plain identity?
- if (_cmsMAT3isIdentity(&res) && Offset == NULL) {
-
- // We can get rid of full matrix
- IdentityMat = TRUE;
- }
-
- }
- else {
-
- if (cmsPipelineCheckAndRetreiveStages(Src, 3,
- cmsSigCurveSetElemType, cmsSigMatrixElemType, cmsSigCurveSetElemType,
- &Curve1, &Matrix1, &Curve2)) {
-
- _cmsStageMatrixData* Data = (_cmsStageMatrixData*)cmsStageData(Matrix1);
-
- if (Matrix1->InputChannels != 3 || Matrix1->OutputChannels != 3) return FALSE;
-
- // Copy the matrix to our result
- memcpy(&res, Data->Double, sizeof(res));
-
- // Preserve the Odffset (may be NULL as a zero offset)
- Offset = Data->Offset;
-
- if (_cmsMAT3isIdentity(&res) && Offset == NULL) {
-
- // We can get rid of full matrix
- IdentityMat = TRUE;
- }
- }
- else
- return FALSE; // Not optimizeable this time
-
- }
-
- // Allocate an empty LUT
- Dest = cmsPipelineAlloc(Src ->ContextID, Src ->InputChannels, Src ->OutputChannels);
- if (!Dest) return FALSE;
-
- // Assamble the new LUT
- if (!cmsPipelineInsertStage(Dest, cmsAT_BEGIN, cmsStageDup(Curve1)))
- goto Error;
-
- if (!IdentityMat) {
-
- if (!cmsPipelineInsertStage(Dest, cmsAT_END, cmsStageAllocMatrix(Dest->ContextID, 3, 3, (const cmsFloat64Number*)&res, Offset)))
- goto Error;
- }
-
- if (!cmsPipelineInsertStage(Dest, cmsAT_END, cmsStageDup(Curve2)))
- goto Error;
-
- // If identity on matrix, we can further optimize the curves, so call the join curves routine
- if (IdentityMat) {
-
- OptimizeByJoiningCurves(&Dest, Intent, InputFormat, OutputFormat, dwFlags);
- }
- else {
- _cmsStageToneCurvesData* mpeC1 = (_cmsStageToneCurvesData*) cmsStageData(Curve1);
- _cmsStageToneCurvesData* mpeC2 = (_cmsStageToneCurvesData*) cmsStageData(Curve2);
-
- // In this particular optimization, cache does not help as it takes more time to deal with
- // the cache than with the pixel handling
- *dwFlags |= cmsFLAGS_NOCACHE;
-
- // Setup the optimizarion routines
- SetMatShaper(Dest, mpeC1 ->TheCurves, &res, (cmsVEC3*) Offset, mpeC2->TheCurves, OutputFormat);
- }
-
- cmsPipelineFree(Src);
- *Lut = Dest;
- return TRUE;
-Error:
- // Leave Src unchanged
- cmsPipelineFree(Dest);
- return FALSE;
-}
-
-
-// -------------------------------------------------------------------------------------------------------------------------------------
-// Optimization plug-ins
-
-// List of optimizations
-typedef struct _cmsOptimizationCollection_st {
-
- _cmsOPToptimizeFn OptimizePtr;
-
- struct _cmsOptimizationCollection_st *Next;
-
-} _cmsOptimizationCollection;
-
-
-// The built-in list. We currently implement 4 types of optimizations. Joining of curves, matrix-shaper, linearization and resampling
-static _cmsOptimizationCollection DefaultOptimization[] = {
-
- { OptimizeByJoiningCurves, &DefaultOptimization[1] },
- { OptimizeMatrixShaper, &DefaultOptimization[2] },
- { OptimizeByComputingLinearization, &DefaultOptimization[3] },
- { OptimizeByResampling, NULL }
-};
-
-// The linked list head
-_cmsOptimizationPluginChunkType _cmsOptimizationPluginChunk = { NULL };
-
-
-// Duplicates the zone of memory used by the plug-in in the new context
-static
-void DupPluginOptimizationList(struct _cmsContext_struct* ctx,
- const struct _cmsContext_struct* src)
-{
- _cmsOptimizationPluginChunkType newHead = { NULL };
- _cmsOptimizationCollection* entry;
- _cmsOptimizationCollection* Anterior = NULL;
- _cmsOptimizationPluginChunkType* head = (_cmsOptimizationPluginChunkType*) src->chunks[OptimizationPlugin];
-
- _cmsAssert(ctx != NULL);
- _cmsAssert(head != NULL);
-
- // Walk the list copying all nodes
- for (entry = head->OptimizationCollection;
- entry != NULL;
- entry = entry ->Next) {
-
- _cmsOptimizationCollection *newEntry = ( _cmsOptimizationCollection *) _cmsSubAllocDup(ctx ->MemPool, entry, sizeof(_cmsOptimizationCollection));
-
- if (newEntry == NULL)
- return;
-
- // We want to keep the linked list order, so this is a little bit tricky
- newEntry -> Next = NULL;
- if (Anterior)
- Anterior -> Next = newEntry;
-
- Anterior = newEntry;
-
- if (newHead.OptimizationCollection == NULL)
- newHead.OptimizationCollection = newEntry;
- }
-
- ctx ->chunks[OptimizationPlugin] = _cmsSubAllocDup(ctx->MemPool, &newHead, sizeof(_cmsOptimizationPluginChunkType));
-}
-
-void _cmsAllocOptimizationPluginChunk(struct _cmsContext_struct* ctx,
- const struct _cmsContext_struct* src)
-{
- if (src != NULL) {
-
- // Copy all linked list
- DupPluginOptimizationList(ctx, src);
- }
- else {
- static _cmsOptimizationPluginChunkType OptimizationPluginChunkType = { NULL };
- ctx ->chunks[OptimizationPlugin] = _cmsSubAllocDup(ctx ->MemPool, &OptimizationPluginChunkType, sizeof(_cmsOptimizationPluginChunkType));
- }
-}
-
-
-// Register new ways to optimize
-cmsBool _cmsRegisterOptimizationPlugin(cmsContext ContextID, cmsPluginBase* Data)
-{
- cmsPluginOptimization* Plugin = (cmsPluginOptimization*) Data;
- _cmsOptimizationPluginChunkType* ctx = ( _cmsOptimizationPluginChunkType*) _cmsContextGetClientChunk(ContextID, OptimizationPlugin);
- _cmsOptimizationCollection* fl;
-
- if (Data == NULL) {
-
- ctx->OptimizationCollection = NULL;
- return TRUE;
- }
-
- // Optimizer callback is required
- if (Plugin ->OptimizePtr == NULL) return FALSE;
-
- fl = (_cmsOptimizationCollection*) _cmsPluginMalloc(ContextID, sizeof(_cmsOptimizationCollection));
- if (fl == NULL) return FALSE;
-
- // Copy the parameters
- fl ->OptimizePtr = Plugin ->OptimizePtr;
-
- // Keep linked list
- fl ->Next = ctx->OptimizationCollection;
-
- // Set the head
- ctx ->OptimizationCollection = fl;
-
- // All is ok
- return TRUE;
-}
-
-// The entry point for LUT optimization
-cmsBool CMSEXPORT _cmsOptimizePipeline(cmsContext ContextID,
- cmsPipeline** PtrLut,
- cmsUInt32Number Intent,
- cmsUInt32Number* InputFormat,
- cmsUInt32Number* OutputFormat,
- cmsUInt32Number* dwFlags)
-{
- _cmsOptimizationPluginChunkType* ctx = ( _cmsOptimizationPluginChunkType*) _cmsContextGetClientChunk(ContextID, OptimizationPlugin);
- _cmsOptimizationCollection* Opts;
- cmsBool AnySuccess = FALSE;
- cmsStage* mpe;
-
- // A CLUT is being asked, so force this specific optimization
- if (*dwFlags & cmsFLAGS_FORCE_CLUT) {
-
- PreOptimize(*PtrLut);
- return OptimizeByResampling(PtrLut, Intent, InputFormat, OutputFormat, dwFlags);
- }
-
- // Anything to optimize?
- if ((*PtrLut) ->Elements == NULL) {
- _cmsPipelineSetOptimizationParameters(*PtrLut, FastIdentity16, (void*) *PtrLut, NULL, NULL);
- return TRUE;
- }
-
- // Named color pipelines cannot be optimized
- for (mpe = cmsPipelineGetPtrToFirstStage(*PtrLut);
- mpe != NULL;
- mpe = cmsStageNext(mpe)) {
- if (cmsStageType(mpe) == cmsSigNamedColorElemType) return FALSE;
- }
-
- // Try to get rid of identities and trivial conversions.
- AnySuccess = PreOptimize(*PtrLut);
-
- // After removal do we end with an identity?
- if ((*PtrLut) ->Elements == NULL) {
- _cmsPipelineSetOptimizationParameters(*PtrLut, FastIdentity16, (void*) *PtrLut, NULL, NULL);
- return TRUE;
- }
-
- // Do not optimize, keep all precision
- if (*dwFlags & cmsFLAGS_NOOPTIMIZE)
- return FALSE;
-
- // Try plug-in optimizations
- for (Opts = ctx->OptimizationCollection;
- Opts != NULL;
- Opts = Opts ->Next) {
-
- // If one schema succeeded, we are done
- if (Opts ->OptimizePtr(PtrLut, Intent, InputFormat, OutputFormat, dwFlags)) {
-
- return TRUE; // Optimized!
- }
- }
-
- // Try built-in optimizations
- for (Opts = DefaultOptimization;
- Opts != NULL;
- Opts = Opts ->Next) {
-
- if (Opts ->OptimizePtr(PtrLut, Intent, InputFormat, OutputFormat, dwFlags)) {
-
- return TRUE;
- }
- }
-
- // Only simple optimizations succeeded
- return AnySuccess;
-}
-
-
-
diff --git a/contrib/libs/lcms2/src/cmspack.c b/contrib/libs/lcms2/src/cmspack.c
deleted file mode 100644
index c191896c08..0000000000
--- a/contrib/libs/lcms2/src/cmspack.c
+++ /dev/null
@@ -1,4056 +0,0 @@
-//---------------------------------------------------------------------------------
-//
-// Little Color Management System
-// Copyright (c) 1998-2023 Marti Maria Saguer
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//---------------------------------------------------------------------------------
-//
-
-#include "lcms2_internal.h"
-
-// This module handles all formats supported by lcms. There are two flavors, 16 bits and
-// floating point. Floating point is supported only in a subset, those formats holding
-// cmsFloat32Number (4 bytes per component) and double (marked as 0 bytes per component
-// as special case)
-
-// ---------------------------------------------------------------------------
-
-
-// This macro return words stored as big endian
-#define CHANGE_ENDIAN(w) (cmsUInt16Number) ((cmsUInt16Number) ((w)<<8)|((w)>>8))
-
-// These macros handles reversing (negative)
-#define REVERSE_FLAVOR_8(x) ((cmsUInt8Number) (0xff-(x)))
-#define REVERSE_FLAVOR_16(x) ((cmsUInt16Number)(0xffff-(x)))
-
-// * 0xffff / 0xff00 = (255 * 257) / (255 * 256) = 257 / 256
-cmsINLINE cmsUInt16Number FomLabV2ToLabV4(cmsUInt16Number x)
-{
- int a = (x << 8 | x) >> 8; // * 257 / 256
- if ( a > 0xffff) return 0xffff;
- return (cmsUInt16Number) a;
-}
-
-// * 0xf00 / 0xffff = * 256 / 257
-cmsINLINE cmsUInt16Number FomLabV4ToLabV2(cmsUInt16Number x)
-{
- return (cmsUInt16Number) (((x << 8) + 0x80) / 257);
-}
-
-
-typedef struct {
- cmsUInt32Number Type;
- cmsUInt32Number Mask;
- cmsFormatter16 Frm;
-
-} cmsFormatters16;
-
-typedef struct {
- cmsUInt32Number Type;
- cmsUInt32Number Mask;
- cmsFormatterFloat Frm;
-
-} cmsFormattersFloat;
-
-
-#define ANYSPACE COLORSPACE_SH(31)
-#define ANYCHANNELS CHANNELS_SH(15)
-#define ANYEXTRA EXTRA_SH(7)
-#define ANYPLANAR PLANAR_SH(1)
-#define ANYENDIAN ENDIAN16_SH(1)
-#define ANYSWAP DOSWAP_SH(1)
-#define ANYSWAPFIRST SWAPFIRST_SH(1)
-#define ANYFLAVOR FLAVOR_SH(1)
-#define ANYPREMUL PREMUL_SH(1)
-
-
-// Suppress waning about info never being used
-
-#ifdef _MSC_VER
-#pragma warning(disable : 4100)
-#endif
-
-// Unpacking routines (16 bits) ----------------------------------------------------------------------------------------
-
-
-// Does almost everything but is slow
-static
-cmsUInt8Number* UnrollChunkyBytes(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- cmsUInt32Number nChan = T_CHANNELS(info -> InputFormat);
- cmsUInt32Number DoSwap = T_DOSWAP(info ->InputFormat);
- cmsUInt32Number Reverse = T_FLAVOR(info ->InputFormat);
- cmsUInt32Number SwapFirst = T_SWAPFIRST(info -> InputFormat);
- cmsUInt32Number Extra = T_EXTRA(info -> InputFormat);
- cmsUInt32Number Premul = T_PREMUL(info->InputFormat);
-
- cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
- cmsUInt32Number v;
- cmsUInt32Number i;
- cmsUInt32Number alpha_factor = 1;
-
- if (ExtraFirst) {
-
- if (Premul && Extra)
- alpha_factor = _cmsToFixedDomain(FROM_8_TO_16(accum[0]));
-
- accum += Extra;
- }
- else
- {
- if (Premul && Extra)
- alpha_factor = _cmsToFixedDomain(FROM_8_TO_16(accum[nChan]));
- }
-
- for (i=0; i < nChan; i++) {
-
- cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
-
- v = FROM_8_TO_16(*accum);
- v = Reverse ? REVERSE_FLAVOR_16(v) : v;
-
- if (Premul && alpha_factor > 0)
- {
- v = ((cmsUInt32Number)((cmsUInt32Number)v << 16) / alpha_factor);
- if (v > 0xffff) v = 0xffff;
- }
-
- wIn[index] = (cmsUInt16Number) v;
- accum++;
- }
-
- if (!ExtraFirst) {
- accum += Extra;
- }
-
- if (Extra == 0 && SwapFirst) {
- cmsUInt16Number tmp = wIn[0];
-
- memmove(&wIn[0], &wIn[1], (nChan-1) * sizeof(cmsUInt16Number));
- wIn[nChan-1] = tmp;
- }
-
- return accum;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-
-}
-
-
-// Extra channels are just ignored because come in the next planes
-static
-cmsUInt8Number* UnrollPlanarBytes(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- cmsUInt32Number nChan = T_CHANNELS(info -> InputFormat);
- cmsUInt32Number DoSwap = T_DOSWAP(info ->InputFormat);
- cmsUInt32Number SwapFirst = T_SWAPFIRST(info ->InputFormat);
- cmsUInt32Number Reverse = T_FLAVOR(info ->InputFormat);
- cmsUInt32Number i;
- cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
- cmsUInt32Number Extra = T_EXTRA(info->InputFormat);
- cmsUInt32Number Premul = T_PREMUL(info->InputFormat);
- cmsUInt8Number* Init = accum;
- cmsUInt32Number alpha_factor = 1;
-
- if (ExtraFirst) {
-
- if (Premul && Extra)
- alpha_factor = _cmsToFixedDomain(FROM_8_TO_16(accum[0]));
-
-
- accum += Extra * Stride;
- }
- else
- {
- if (Premul && Extra)
- alpha_factor = _cmsToFixedDomain(FROM_8_TO_16(accum[(nChan) * Stride]));
- }
-
- for (i=0; i < nChan; i++) {
-
- cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
- cmsUInt32Number v = FROM_8_TO_16(*accum);
-
- v = Reverse ? REVERSE_FLAVOR_16(v) : v;
-
- if (Premul && alpha_factor > 0)
- {
- v = ((cmsUInt32Number)((cmsUInt32Number)v << 16) / alpha_factor);
- if (v > 0xffff) v = 0xffff;
- }
-
- wIn[index] = (cmsUInt16Number) v;
- accum += Stride;
- }
-
- return (Init + 1);
-}
-
-
-// Special cases, provided for performance
-static
-cmsUInt8Number* Unroll4Bytes(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- wIn[0] = FROM_8_TO_16(*accum); accum++; // C
- wIn[1] = FROM_8_TO_16(*accum); accum++; // M
- wIn[2] = FROM_8_TO_16(*accum); accum++; // Y
- wIn[3] = FROM_8_TO_16(*accum); accum++; // K
-
- return accum;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* Unroll4BytesReverse(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- wIn[0] = FROM_8_TO_16(REVERSE_FLAVOR_8(*accum)); accum++; // C
- wIn[1] = FROM_8_TO_16(REVERSE_FLAVOR_8(*accum)); accum++; // M
- wIn[2] = FROM_8_TO_16(REVERSE_FLAVOR_8(*accum)); accum++; // Y
- wIn[3] = FROM_8_TO_16(REVERSE_FLAVOR_8(*accum)); accum++; // K
-
- return accum;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* Unroll4BytesSwapFirst(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- wIn[3] = FROM_8_TO_16(*accum); accum++; // K
- wIn[0] = FROM_8_TO_16(*accum); accum++; // C
- wIn[1] = FROM_8_TO_16(*accum); accum++; // M
- wIn[2] = FROM_8_TO_16(*accum); accum++; // Y
-
- return accum;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-// KYMC
-static
-cmsUInt8Number* Unroll4BytesSwap(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- wIn[3] = FROM_8_TO_16(*accum); accum++; // K
- wIn[2] = FROM_8_TO_16(*accum); accum++; // Y
- wIn[1] = FROM_8_TO_16(*accum); accum++; // M
- wIn[0] = FROM_8_TO_16(*accum); accum++; // C
-
- return accum;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* Unroll4BytesSwapSwapFirst(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- wIn[2] = FROM_8_TO_16(*accum); accum++; // K
- wIn[1] = FROM_8_TO_16(*accum); accum++; // Y
- wIn[0] = FROM_8_TO_16(*accum); accum++; // M
- wIn[3] = FROM_8_TO_16(*accum); accum++; // C
-
- return accum;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* Unroll3Bytes(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- wIn[0] = FROM_8_TO_16(*accum); accum++; // R
- wIn[1] = FROM_8_TO_16(*accum); accum++; // G
- wIn[2] = FROM_8_TO_16(*accum); accum++; // B
-
- return accum;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* Unroll3BytesSkip1Swap(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- accum++; // A
- wIn[2] = FROM_8_TO_16(*accum); accum++; // B
- wIn[1] = FROM_8_TO_16(*accum); accum++; // G
- wIn[0] = FROM_8_TO_16(*accum); accum++; // R
-
- return accum;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* Unroll3BytesSkip1SwapSwapFirst(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- wIn[2] = FROM_8_TO_16(*accum); accum++; // B
- wIn[1] = FROM_8_TO_16(*accum); accum++; // G
- wIn[0] = FROM_8_TO_16(*accum); accum++; // R
- accum++; // A
-
- return accum;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* Unroll3BytesSkip1SwapFirst(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- accum++; // A
- wIn[0] = FROM_8_TO_16(*accum); accum++; // R
- wIn[1] = FROM_8_TO_16(*accum); accum++; // G
- wIn[2] = FROM_8_TO_16(*accum); accum++; // B
-
- return accum;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-
-// BRG
-static
-cmsUInt8Number* Unroll3BytesSwap(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- wIn[2] = FROM_8_TO_16(*accum); accum++; // B
- wIn[1] = FROM_8_TO_16(*accum); accum++; // G
- wIn[0] = FROM_8_TO_16(*accum); accum++; // R
-
- return accum;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* UnrollLabV2_8(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- wIn[0] = FomLabV2ToLabV4(FROM_8_TO_16(*accum)); accum++; // L
- wIn[1] = FomLabV2ToLabV4(FROM_8_TO_16(*accum)); accum++; // a
- wIn[2] = FomLabV2ToLabV4(FROM_8_TO_16(*accum)); accum++; // b
-
- return accum;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* UnrollALabV2_8(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- accum++; // A
- wIn[0] = FomLabV2ToLabV4(FROM_8_TO_16(*accum)); accum++; // L
- wIn[1] = FomLabV2ToLabV4(FROM_8_TO_16(*accum)); accum++; // a
- wIn[2] = FomLabV2ToLabV4(FROM_8_TO_16(*accum)); accum++; // b
-
- return accum;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* UnrollLabV2_16(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- wIn[0] = FomLabV2ToLabV4(*(cmsUInt16Number*) accum); accum += 2; // L
- wIn[1] = FomLabV2ToLabV4(*(cmsUInt16Number*) accum); accum += 2; // a
- wIn[2] = FomLabV2ToLabV4(*(cmsUInt16Number*) accum); accum += 2; // b
-
- return accum;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-// for duplex
-static
-cmsUInt8Number* Unroll2Bytes(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- wIn[0] = FROM_8_TO_16(*accum); accum++; // ch1
- wIn[1] = FROM_8_TO_16(*accum); accum++; // ch2
-
- return accum;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-
-
-
-// Monochrome duplicates L into RGB for null-transforms
-static
-cmsUInt8Number* Unroll1Byte(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- wIn[0] = wIn[1] = wIn[2] = FROM_8_TO_16(*accum); accum++; // L
-
- return accum;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-
-static
-cmsUInt8Number* Unroll1ByteSkip1(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- wIn[0] = wIn[1] = wIn[2] = FROM_8_TO_16(*accum); accum++; // L
- accum += 1;
-
- return accum;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* Unroll1ByteSkip2(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- wIn[0] = wIn[1] = wIn[2] = FROM_8_TO_16(*accum); accum++; // L
- accum += 2;
-
- return accum;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* Unroll1ByteReversed(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- wIn[0] = wIn[1] = wIn[2] = REVERSE_FLAVOR_16(FROM_8_TO_16(*accum)); accum++; // L
-
- return accum;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-
-static
-cmsUInt8Number* UnrollAnyWords(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- cmsUInt32Number nChan = T_CHANNELS(info -> InputFormat);
- cmsUInt32Number SwapEndian = T_ENDIAN16(info -> InputFormat);
- cmsUInt32Number DoSwap = T_DOSWAP(info ->InputFormat);
- cmsUInt32Number Reverse = T_FLAVOR(info ->InputFormat);
- cmsUInt32Number SwapFirst = T_SWAPFIRST(info -> InputFormat);
- cmsUInt32Number Extra = T_EXTRA(info -> InputFormat);
- cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
- cmsUInt32Number i;
-
- if (ExtraFirst) {
- accum += Extra * sizeof(cmsUInt16Number);
- }
-
- for (i=0; i < nChan; i++) {
-
- cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
- cmsUInt16Number v = *(cmsUInt16Number*) accum;
-
- if (SwapEndian)
- v = CHANGE_ENDIAN(v);
-
- wIn[index] = Reverse ? REVERSE_FLAVOR_16(v) : v;
-
- accum += sizeof(cmsUInt16Number);
- }
-
- if (!ExtraFirst) {
- accum += Extra * sizeof(cmsUInt16Number);
- }
-
- if (Extra == 0 && SwapFirst) {
-
- cmsUInt16Number tmp = wIn[0];
-
- memmove(&wIn[0], &wIn[1], (nChan-1) * sizeof(cmsUInt16Number));
- wIn[nChan-1] = tmp;
- }
-
- return accum;
-
- cmsUNUSED_PARAMETER(Stride);
-}
-
-
-static
-cmsUInt8Number* UnrollAnyWordsPremul(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- cmsUInt32Number nChan = T_CHANNELS(info -> InputFormat);
- cmsUInt32Number SwapEndian = T_ENDIAN16(info -> InputFormat);
- cmsUInt32Number DoSwap = T_DOSWAP(info ->InputFormat);
- cmsUInt32Number Reverse = T_FLAVOR(info ->InputFormat);
- cmsUInt32Number SwapFirst = T_SWAPFIRST(info -> InputFormat);
- cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
- cmsUInt32Number i;
-
- cmsUInt16Number alpha = (ExtraFirst ? accum[0] : accum[nChan - 1]);
- cmsUInt32Number alpha_factor = _cmsToFixedDomain(FROM_8_TO_16(alpha));
-
- if (ExtraFirst) {
- accum += sizeof(cmsUInt16Number);
- }
-
- for (i=0; i < nChan; i++) {
-
- cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
- cmsUInt32Number v = *(cmsUInt16Number*) accum;
-
- if (SwapEndian)
- v = CHANGE_ENDIAN(v);
-
- if (alpha_factor > 0) {
-
- v = (v << 16) / alpha_factor;
- if (v > 0xffff) v = 0xffff;
- }
-
- wIn[index] = (cmsUInt16Number) (Reverse ? REVERSE_FLAVOR_16(v) : v);
-
- accum += sizeof(cmsUInt16Number);
- }
-
- if (!ExtraFirst) {
- accum += sizeof(cmsUInt16Number);
- }
-
- return accum;
-
- cmsUNUSED_PARAMETER(Stride);
-}
-
-
-
-static
-cmsUInt8Number* UnrollPlanarWords(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- cmsUInt32Number nChan = T_CHANNELS(info -> InputFormat);
- cmsUInt32Number DoSwap= T_DOSWAP(info ->InputFormat);
- cmsUInt32Number Reverse= T_FLAVOR(info ->InputFormat);
- cmsUInt32Number SwapEndian = T_ENDIAN16(info -> InputFormat);
- cmsUInt32Number i;
- cmsUInt8Number* Init = accum;
-
- if (DoSwap) {
- accum += T_EXTRA(info -> InputFormat) * Stride;
- }
-
- for (i=0; i < nChan; i++) {
-
- cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
- cmsUInt16Number v = *(cmsUInt16Number*) accum;
-
- if (SwapEndian)
- v = CHANGE_ENDIAN(v);
-
- wIn[index] = Reverse ? REVERSE_FLAVOR_16(v) : v;
-
- accum += Stride;
- }
-
- return (Init + sizeof(cmsUInt16Number));
-}
-
-static
-cmsUInt8Number* UnrollPlanarWordsPremul(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- cmsUInt32Number nChan = T_CHANNELS(info -> InputFormat);
- cmsUInt32Number DoSwap= T_DOSWAP(info ->InputFormat);
- cmsUInt32Number SwapFirst = T_SWAPFIRST(info->InputFormat);
- cmsUInt32Number Reverse= T_FLAVOR(info ->InputFormat);
- cmsUInt32Number SwapEndian = T_ENDIAN16(info -> InputFormat);
- cmsUInt32Number i;
- cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
- cmsUInt8Number* Init = accum;
-
- cmsUInt16Number alpha = (ExtraFirst ? accum[0] : accum[(nChan - 1) * Stride]);
- cmsUInt32Number alpha_factor = _cmsToFixedDomain(FROM_8_TO_16(alpha));
-
- if (ExtraFirst) {
- accum += Stride;
- }
-
- for (i=0; i < nChan; i++) {
-
- cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
- cmsUInt32Number v = (cmsUInt32Number) *(cmsUInt16Number*) accum;
-
- if (SwapEndian)
- v = CHANGE_ENDIAN(v);
-
- if (alpha_factor > 0) {
-
- v = (v << 16) / alpha_factor;
- if (v > 0xffff) v = 0xffff;
- }
-
- wIn[index] = (cmsUInt16Number) (Reverse ? REVERSE_FLAVOR_16(v) : v);
-
- accum += Stride;
- }
-
- return (Init + sizeof(cmsUInt16Number));
-}
-
-static
-cmsUInt8Number* Unroll4Words(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- wIn[0] = *(cmsUInt16Number*) accum; accum+= 2; // C
- wIn[1] = *(cmsUInt16Number*) accum; accum+= 2; // M
- wIn[2] = *(cmsUInt16Number*) accum; accum+= 2; // Y
- wIn[3] = *(cmsUInt16Number*) accum; accum+= 2; // K
-
- return accum;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* Unroll4WordsReverse(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- wIn[0] = REVERSE_FLAVOR_16(*(cmsUInt16Number*) accum); accum+= 2; // C
- wIn[1] = REVERSE_FLAVOR_16(*(cmsUInt16Number*) accum); accum+= 2; // M
- wIn[2] = REVERSE_FLAVOR_16(*(cmsUInt16Number*) accum); accum+= 2; // Y
- wIn[3] = REVERSE_FLAVOR_16(*(cmsUInt16Number*) accum); accum+= 2; // K
-
- return accum;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* Unroll4WordsSwapFirst(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- wIn[3] = *(cmsUInt16Number*) accum; accum+= 2; // K
- wIn[0] = *(cmsUInt16Number*) accum; accum+= 2; // C
- wIn[1] = *(cmsUInt16Number*) accum; accum+= 2; // M
- wIn[2] = *(cmsUInt16Number*) accum; accum+= 2; // Y
-
- return accum;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-// KYMC
-static
-cmsUInt8Number* Unroll4WordsSwap(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- wIn[3] = *(cmsUInt16Number*) accum; accum+= 2; // K
- wIn[2] = *(cmsUInt16Number*) accum; accum+= 2; // Y
- wIn[1] = *(cmsUInt16Number*) accum; accum+= 2; // M
- wIn[0] = *(cmsUInt16Number*) accum; accum+= 2; // C
-
- return accum;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* Unroll4WordsSwapSwapFirst(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- wIn[2] = *(cmsUInt16Number*) accum; accum+= 2; // K
- wIn[1] = *(cmsUInt16Number*) accum; accum+= 2; // Y
- wIn[0] = *(cmsUInt16Number*) accum; accum+= 2; // M
- wIn[3] = *(cmsUInt16Number*) accum; accum+= 2; // C
-
- return accum;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* Unroll3Words(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- wIn[0] = *(cmsUInt16Number*) accum; accum+= 2; // C R
- wIn[1] = *(cmsUInt16Number*) accum; accum+= 2; // M G
- wIn[2] = *(cmsUInt16Number*) accum; accum+= 2; // Y B
-
- return accum;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* Unroll3WordsSwap(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- wIn[2] = *(cmsUInt16Number*) accum; accum+= 2; // C R
- wIn[1] = *(cmsUInt16Number*) accum; accum+= 2; // M G
- wIn[0] = *(cmsUInt16Number*) accum; accum+= 2; // Y B
-
- return accum;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* Unroll3WordsSkip1Swap(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- accum += 2; // A
- wIn[2] = *(cmsUInt16Number*) accum; accum += 2; // R
- wIn[1] = *(cmsUInt16Number*) accum; accum += 2; // G
- wIn[0] = *(cmsUInt16Number*) accum; accum += 2; // B
-
- return accum;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* Unroll3WordsSkip1SwapFirst(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- accum += 2; // A
- wIn[0] = *(cmsUInt16Number*) accum; accum += 2; // R
- wIn[1] = *(cmsUInt16Number*) accum; accum += 2; // G
- wIn[2] = *(cmsUInt16Number*) accum; accum += 2; // B
-
- return accum;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* Unroll1Word(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- wIn[0] = wIn[1] = wIn[2] = *(cmsUInt16Number*) accum; accum+= 2; // L
-
- return accum;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* Unroll1WordReversed(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- wIn[0] = wIn[1] = wIn[2] = REVERSE_FLAVOR_16(*(cmsUInt16Number*) accum); accum+= 2;
-
- return accum;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* Unroll1WordSkip3(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- wIn[0] = wIn[1] = wIn[2] = *(cmsUInt16Number*) accum;
-
- accum += 8;
-
- return accum;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* Unroll2Words(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- wIn[0] = *(cmsUInt16Number*) accum; accum += 2; // ch1
- wIn[1] = *(cmsUInt16Number*) accum; accum += 2; // ch2
-
- return accum;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-
-// This is a conversion of Lab double to 16 bits
-static
-cmsUInt8Number* UnrollLabDoubleTo16(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- if (T_PLANAR(info -> InputFormat)) {
-
- cmsCIELab Lab;
- cmsUInt8Number* pos_L;
- cmsUInt8Number* pos_a;
- cmsUInt8Number* pos_b;
-
- pos_L = accum;
- pos_a = accum + Stride;
- pos_b = accum + Stride * 2;
-
- Lab.L = *(cmsFloat64Number*) pos_L;
- Lab.a = *(cmsFloat64Number*) pos_a;
- Lab.b = *(cmsFloat64Number*) pos_b;
-
- cmsFloat2LabEncoded(wIn, &Lab);
- return accum + sizeof(cmsFloat64Number);
- }
- else {
-
- cmsFloat2LabEncoded(wIn, (cmsCIELab*) accum);
- accum += sizeof(cmsCIELab) + T_EXTRA(info ->InputFormat) * sizeof(cmsFloat64Number);
- return accum;
- }
-}
-
-
-// This is a conversion of Lab float to 16 bits
-static
-cmsUInt8Number* UnrollLabFloatTo16(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- cmsCIELab Lab;
-
- if (T_PLANAR(info -> InputFormat)) {
-
- cmsUInt8Number* pos_L;
- cmsUInt8Number* pos_a;
- cmsUInt8Number* pos_b;
-
- pos_L = accum;
- pos_a = accum + Stride;
- pos_b = accum + Stride * 2;
-
- Lab.L = *(cmsFloat32Number*)pos_L;
- Lab.a = *(cmsFloat32Number*)pos_a;
- Lab.b = *(cmsFloat32Number*)pos_b;
-
- cmsFloat2LabEncoded(wIn, &Lab);
- return accum + sizeof(cmsFloat32Number);
- }
- else {
-
- Lab.L = ((cmsFloat32Number*) accum)[0];
- Lab.a = ((cmsFloat32Number*) accum)[1];
- Lab.b = ((cmsFloat32Number*) accum)[2];
-
- cmsFloat2LabEncoded(wIn, &Lab);
- accum += (3 + T_EXTRA(info ->InputFormat)) * sizeof(cmsFloat32Number);
- return accum;
- }
-}
-
-// This is a conversion of XYZ double to 16 bits
-static
-cmsUInt8Number* UnrollXYZDoubleTo16(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- if (T_PLANAR(info -> InputFormat)) {
-
- cmsCIEXYZ XYZ;
- cmsUInt8Number* pos_X;
- cmsUInt8Number* pos_Y;
- cmsUInt8Number* pos_Z;
-
- pos_X = accum;
- pos_Y = accum + Stride;
- pos_Z = accum + Stride * 2;
-
- XYZ.X = *(cmsFloat64Number*)pos_X;
- XYZ.Y = *(cmsFloat64Number*)pos_Y;
- XYZ.Z = *(cmsFloat64Number*)pos_Z;
-
- cmsFloat2XYZEncoded(wIn, &XYZ);
-
- return accum + sizeof(cmsFloat64Number);
-
- }
-
- else {
- cmsFloat2XYZEncoded(wIn, (cmsCIEXYZ*) accum);
- accum += sizeof(cmsCIEXYZ) + T_EXTRA(info ->InputFormat) * sizeof(cmsFloat64Number);
-
- return accum;
- }
-}
-
-// This is a conversion of XYZ float to 16 bits
-static
-cmsUInt8Number* UnrollXYZFloatTo16(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- if (T_PLANAR(info -> InputFormat)) {
-
- cmsCIEXYZ XYZ;
- cmsUInt8Number* pos_X;
- cmsUInt8Number* pos_Y;
- cmsUInt8Number* pos_Z;
-
- pos_X = accum;
- pos_Y = accum + Stride;
- pos_Z = accum + Stride * 2;
-
- XYZ.X = *(cmsFloat32Number*)pos_X;
- XYZ.Y = *(cmsFloat32Number*)pos_Y;
- XYZ.Z = *(cmsFloat32Number*)pos_Z;
-
- cmsFloat2XYZEncoded(wIn, &XYZ);
-
- return accum + sizeof(cmsFloat32Number);
-
- }
-
- else {
- cmsFloat32Number* Pt = (cmsFloat32Number*) accum;
- cmsCIEXYZ XYZ;
-
- XYZ.X = Pt[0];
- XYZ.Y = Pt[1];
- XYZ.Z = Pt[2];
- cmsFloat2XYZEncoded(wIn, &XYZ);
-
- accum += 3 * sizeof(cmsFloat32Number) + T_EXTRA(info ->InputFormat) * sizeof(cmsFloat32Number);
-
- return accum;
- }
-}
-
-// Check if space is marked as ink
-cmsINLINE cmsBool IsInkSpace(cmsUInt32Number Type)
-{
- switch (T_COLORSPACE(Type)) {
-
- case PT_CMY:
- case PT_CMYK:
- case PT_MCH5:
- case PT_MCH6:
- case PT_MCH7:
- case PT_MCH8:
- case PT_MCH9:
- case PT_MCH10:
- case PT_MCH11:
- case PT_MCH12:
- case PT_MCH13:
- case PT_MCH14:
- case PT_MCH15: return TRUE;
-
- default: return FALSE;
- }
-}
-
-// Return the size in bytes of a given formatter
-static
-cmsUInt32Number PixelSize(cmsUInt32Number Format)
-{
- cmsUInt32Number fmt_bytes = T_BYTES(Format);
-
- // For double, the T_BYTES field is zero
- if (fmt_bytes == 0)
- return sizeof(cmsUInt64Number);
-
- // Otherwise, it is already correct for all formats
- return fmt_bytes;
-}
-
-// Inks does come in percentage, remaining cases are between 0..1.0, again to 16 bits
-static
-cmsUInt8Number* UnrollDoubleTo16(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
-
- cmsUInt32Number nChan = T_CHANNELS(info -> InputFormat);
- cmsUInt32Number DoSwap = T_DOSWAP(info ->InputFormat);
- cmsUInt32Number Reverse = T_FLAVOR(info ->InputFormat);
- cmsUInt32Number SwapFirst = T_SWAPFIRST(info -> InputFormat);
- cmsUInt32Number Extra = T_EXTRA(info -> InputFormat);
- cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
- cmsUInt32Number Planar = T_PLANAR(info -> InputFormat);
- cmsFloat64Number v;
- cmsUInt16Number vi;
- cmsUInt32Number i, start = 0;
- cmsFloat64Number maximum = IsInkSpace(info ->InputFormat) ? 655.35 : 65535.0;
-
-
- Stride /= PixelSize(info->InputFormat);
-
- if (ExtraFirst)
- start = Extra;
-
- for (i=0; i < nChan; i++) {
-
- cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
-
- if (Planar)
- v = (cmsFloat32Number) ((cmsFloat64Number*) accum)[(i + start) * Stride];
- else
- v = (cmsFloat32Number) ((cmsFloat64Number*) accum)[i + start];
-
- vi = _cmsQuickSaturateWord(v * maximum);
-
- if (Reverse)
- vi = REVERSE_FLAVOR_16(vi);
-
- wIn[index] = vi;
- }
-
-
- if (Extra == 0 && SwapFirst) {
- cmsUInt16Number tmp = wIn[0];
-
- memmove(&wIn[0], &wIn[1], (nChan-1) * sizeof(cmsUInt16Number));
- wIn[nChan-1] = tmp;
- }
-
- if (T_PLANAR(info -> InputFormat))
- return accum + sizeof(cmsFloat64Number);
- else
- return accum + (nChan + Extra) * sizeof(cmsFloat64Number);
-}
-
-
-
-static
-cmsUInt8Number* UnrollFloatTo16(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
-
- cmsUInt32Number nChan = T_CHANNELS(info -> InputFormat);
- cmsUInt32Number DoSwap = T_DOSWAP(info ->InputFormat);
- cmsUInt32Number Reverse = T_FLAVOR(info ->InputFormat);
- cmsUInt32Number SwapFirst = T_SWAPFIRST(info -> InputFormat);
- cmsUInt32Number Extra = T_EXTRA(info -> InputFormat);
- cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
- cmsUInt32Number Planar = T_PLANAR(info -> InputFormat);
- cmsFloat32Number v;
- cmsUInt16Number vi;
- cmsUInt32Number i, start = 0;
- cmsFloat64Number maximum = IsInkSpace(info ->InputFormat) ? 655.35 : 65535.0;
-
- Stride /= PixelSize(info->InputFormat);
-
- if (ExtraFirst)
- start = Extra;
-
- for (i=0; i < nChan; i++) {
-
- cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
-
- if (Planar)
- v = (cmsFloat32Number) ((cmsFloat32Number*) accum)[(i + start) * Stride];
- else
- v = (cmsFloat32Number) ((cmsFloat32Number*) accum)[i + start];
-
- vi = _cmsQuickSaturateWord(v * maximum);
-
- if (Reverse)
- vi = REVERSE_FLAVOR_16(vi);
-
- wIn[index] = vi;
- }
-
-
- if (Extra == 0 && SwapFirst) {
- cmsUInt16Number tmp = wIn[0];
-
- memmove(&wIn[0], &wIn[1], (nChan-1) * sizeof(cmsUInt16Number));
- wIn[nChan-1] = tmp;
- }
-
- if (T_PLANAR(info -> InputFormat))
- return accum + sizeof(cmsFloat32Number);
- else
- return accum + (nChan + Extra) * sizeof(cmsFloat32Number);
-}
-
-
-
-
-// For 1 channel, we need to duplicate data (it comes in 0..1.0 range)
-static
-cmsUInt8Number* UnrollDouble1Chan(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- cmsFloat64Number* Inks = (cmsFloat64Number*) accum;
-
- wIn[0] = wIn[1] = wIn[2] = _cmsQuickSaturateWord(Inks[0] * 65535.0);
-
- return accum + sizeof(cmsFloat64Number);
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-//-------------------------------------------------------------------------------------------------------------------
-
-// For anything going from cmsUInt8Number
-static
-cmsUInt8Number* Unroll8ToFloat(_cmsTRANSFORM* info,
- cmsFloat32Number wIn[],
- cmsUInt8Number* accum,
- cmsUInt32Number Stride)
-{
-
- cmsUInt32Number nChan = T_CHANNELS(info->InputFormat);
- cmsUInt32Number DoSwap = T_DOSWAP(info->InputFormat);
- cmsUInt32Number Reverse = T_FLAVOR(info->InputFormat);
- cmsUInt32Number SwapFirst = T_SWAPFIRST(info->InputFormat);
- cmsUInt32Number Extra = T_EXTRA(info->InputFormat);
- cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
- cmsUInt32Number Planar = T_PLANAR(info->InputFormat);
- cmsFloat32Number v;
- cmsUInt32Number i, start = 0;
-
- Stride /= PixelSize(info->InputFormat);
-
- if (ExtraFirst)
- start = Extra;
-
- for (i = 0; i < nChan; i++) {
-
- cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
-
- if (Planar)
- v = (cmsFloat32Number) ((cmsUInt8Number *)accum)[(i + start) * Stride];
- else
- v = (cmsFloat32Number) ((cmsUInt8Number *)accum)[i + start];
-
- v /= 255.0F;
-
- wIn[index] = Reverse ? 1 - v : v;
- }
-
-
- if (Extra == 0 && SwapFirst) {
- cmsFloat32Number tmp = wIn[0];
-
- memmove(&wIn[0], &wIn[1], (nChan - 1) * sizeof(cmsFloat32Number));
- wIn[nChan - 1] = tmp;
- }
-
- if (T_PLANAR(info->InputFormat))
- return accum + sizeof(cmsUInt8Number);
- else
- return accum + (nChan + Extra) * sizeof(cmsUInt8Number);
-}
-
-
-// For anything going from cmsUInt16Number
-static
-cmsUInt8Number* Unroll16ToFloat(_cmsTRANSFORM* info,
- cmsFloat32Number wIn[],
- cmsUInt8Number* accum,
- cmsUInt32Number Stride)
-{
-
- cmsUInt32Number nChan = T_CHANNELS(info->InputFormat);
- cmsUInt32Number DoSwap = T_DOSWAP(info->InputFormat);
- cmsUInt32Number Reverse = T_FLAVOR(info->InputFormat);
- cmsUInt32Number SwapFirst = T_SWAPFIRST(info->InputFormat);
- cmsUInt32Number Extra = T_EXTRA(info->InputFormat);
- cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
- cmsUInt32Number Planar = T_PLANAR(info->InputFormat);
- cmsFloat32Number v;
- cmsUInt32Number i, start = 0;
-
- Stride /= PixelSize(info->InputFormat);
-
- if (ExtraFirst)
- start = Extra;
-
- for (i = 0; i < nChan; i++) {
-
- cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
-
- if (Planar)
- v = (cmsFloat32Number)((cmsUInt16Number*)accum)[(i + start) * Stride];
- else
- v = (cmsFloat32Number)((cmsUInt16Number*)accum)[i + start];
-
- v /= 65535.0F;
-
- wIn[index] = Reverse ? 1 - v : v;
- }
-
-
- if (Extra == 0 && SwapFirst) {
- cmsFloat32Number tmp = wIn[0];
-
- memmove(&wIn[0], &wIn[1], (nChan - 1) * sizeof(cmsFloat32Number));
- wIn[nChan - 1] = tmp;
- }
-
- if (T_PLANAR(info->InputFormat))
- return accum + sizeof(cmsUInt16Number);
- else
- return accum + (nChan + Extra) * sizeof(cmsUInt16Number);
-}
-
-
-// For anything going from cmsFloat32Number
-static
-cmsUInt8Number* UnrollFloatsToFloat(_cmsTRANSFORM* info,
- cmsFloat32Number wIn[],
- cmsUInt8Number* accum,
- cmsUInt32Number Stride)
-{
-
- cmsUInt32Number nChan = T_CHANNELS(info->InputFormat);
- cmsUInt32Number DoSwap = T_DOSWAP(info->InputFormat);
- cmsUInt32Number Reverse = T_FLAVOR(info->InputFormat);
- cmsUInt32Number SwapFirst = T_SWAPFIRST(info->InputFormat);
- cmsUInt32Number Extra = T_EXTRA(info->InputFormat);
- cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
- cmsUInt32Number Planar = T_PLANAR(info->InputFormat);
- cmsUInt32Number Premul = T_PREMUL(info->InputFormat);
- cmsFloat32Number v;
- cmsUInt32Number i, start = 0;
- cmsFloat32Number maximum = IsInkSpace(info->InputFormat) ? 100.0F : 1.0F;
- cmsFloat32Number alpha_factor = 1.0f;
- cmsFloat32Number* ptr = (cmsFloat32Number*)accum;
-
- Stride /= PixelSize(info->InputFormat);
-
- if (Premul && Extra)
- {
- if (Planar)
- alpha_factor = (ExtraFirst ? ptr[0] : ptr[nChan * Stride]) / maximum;
- else
- alpha_factor = (ExtraFirst ? ptr[0] : ptr[nChan]) / maximum;
- }
-
- if (ExtraFirst)
- start = Extra;
-
- for (i=0; i < nChan; i++) {
-
- cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
-
- if (Planar)
- v = ptr[(i + start) * Stride];
- else
- v = ptr[i + start];
-
- if (Premul && alpha_factor > 0)
- v /= alpha_factor;
-
- v /= maximum;
-
- wIn[index] = Reverse ? 1 - v : v;
- }
-
-
- if (Extra == 0 && SwapFirst) {
- cmsFloat32Number tmp = wIn[0];
-
- memmove(&wIn[0], &wIn[1], (nChan-1) * sizeof(cmsFloat32Number));
- wIn[nChan-1] = tmp;
- }
-
- if (T_PLANAR(info -> InputFormat))
- return accum + sizeof(cmsFloat32Number);
- else
- return accum + (nChan + Extra) * sizeof(cmsFloat32Number);
-}
-
-// For anything going from double
-
-static
-cmsUInt8Number* UnrollDoublesToFloat(_cmsTRANSFORM* info,
- cmsFloat32Number wIn[],
- cmsUInt8Number* accum,
- cmsUInt32Number Stride)
-{
-
- cmsUInt32Number nChan = T_CHANNELS(info->InputFormat);
- cmsUInt32Number DoSwap = T_DOSWAP(info->InputFormat);
- cmsUInt32Number Reverse = T_FLAVOR(info->InputFormat);
- cmsUInt32Number SwapFirst = T_SWAPFIRST(info->InputFormat);
- cmsUInt32Number Extra = T_EXTRA(info->InputFormat);
- cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
- cmsUInt32Number Planar = T_PLANAR(info->InputFormat);
- cmsUInt32Number Premul = T_PREMUL(info->InputFormat);
- cmsFloat64Number v;
- cmsUInt32Number i, start = 0;
- cmsFloat64Number maximum = IsInkSpace(info ->InputFormat) ? 100.0 : 1.0;
- cmsFloat64Number alpha_factor = 1.0;
- cmsFloat64Number* ptr = (cmsFloat64Number*)accum;
-
- Stride /= PixelSize(info->InputFormat);
-
- if (Premul && Extra)
- {
- if (Planar)
- alpha_factor = (ExtraFirst ? ptr[0] : ptr[(nChan) * Stride]) / maximum;
- else
- alpha_factor = (ExtraFirst ? ptr[0] : ptr[nChan]) / maximum;
- }
-
- if (ExtraFirst)
- start = Extra;
-
- for (i=0; i < nChan; i++) {
-
- cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
-
- if (Planar)
- v = (cmsFloat64Number) ((cmsFloat64Number*) accum)[(i + start) * Stride];
- else
- v = (cmsFloat64Number) ((cmsFloat64Number*) accum)[i + start];
-
-
- if (Premul && alpha_factor > 0)
- v /= alpha_factor;
-
- v /= maximum;
-
- wIn[index] = (cmsFloat32Number) (Reverse ? 1.0 - v : v);
- }
-
-
- if (Extra == 0 && SwapFirst) {
- cmsFloat32Number tmp = wIn[0];
-
- memmove(&wIn[0], &wIn[1], (nChan-1) * sizeof(cmsFloat32Number));
- wIn[nChan-1] = tmp;
- }
-
- if (T_PLANAR(info -> InputFormat))
- return accum + sizeof(cmsFloat64Number);
- else
- return accum + (nChan + Extra) * sizeof(cmsFloat64Number);
-}
-
-
-
-// From Lab double to cmsFloat32Number
-static
-cmsUInt8Number* UnrollLabDoubleToFloat(_cmsTRANSFORM* info,
- cmsFloat32Number wIn[],
- cmsUInt8Number* accum,
- cmsUInt32Number Stride)
-{
- cmsFloat64Number* Pt = (cmsFloat64Number*) accum;
-
- if (T_PLANAR(info -> InputFormat)) {
-
- Stride /= PixelSize(info->InputFormat);
-
- wIn[0] = (cmsFloat32Number) (Pt[0] / 100.0); // from 0..100 to 0..1
- wIn[1] = (cmsFloat32Number) ((Pt[Stride] + 128) / 255.0); // form -128..+127 to 0..1
- wIn[2] = (cmsFloat32Number) ((Pt[Stride*2] + 128) / 255.0);
-
- return accum + sizeof(cmsFloat64Number);
- }
- else {
-
- wIn[0] = (cmsFloat32Number) (Pt[0] / 100.0); // from 0..100 to 0..1
- wIn[1] = (cmsFloat32Number) ((Pt[1] + 128) / 255.0); // form -128..+127 to 0..1
- wIn[2] = (cmsFloat32Number) ((Pt[2] + 128) / 255.0);
-
- accum += sizeof(cmsFloat64Number)*(3 + T_EXTRA(info ->InputFormat));
- return accum;
- }
-}
-
-// From Lab double to cmsFloat32Number
-static
-cmsUInt8Number* UnrollLabFloatToFloat(_cmsTRANSFORM* info,
- cmsFloat32Number wIn[],
- cmsUInt8Number* accum,
- cmsUInt32Number Stride)
-{
- cmsFloat32Number* Pt = (cmsFloat32Number*) accum;
-
- if (T_PLANAR(info -> InputFormat)) {
-
- Stride /= PixelSize(info->InputFormat);
-
- wIn[0] = (cmsFloat32Number) (Pt[0] / 100.0); // from 0..100 to 0..1
- wIn[1] = (cmsFloat32Number) ((Pt[Stride] + 128) / 255.0); // form -128..+127 to 0..1
- wIn[2] = (cmsFloat32Number) ((Pt[Stride*2] + 128) / 255.0);
-
- return accum + sizeof(cmsFloat32Number);
- }
- else {
-
- wIn[0] = (cmsFloat32Number) (Pt[0] / 100.0); // from 0..100 to 0..1
- wIn[1] = (cmsFloat32Number) ((Pt[1] + 128) / 255.0); // form -128..+127 to 0..1
- wIn[2] = (cmsFloat32Number) ((Pt[2] + 128) / 255.0);
-
- accum += sizeof(cmsFloat32Number)*(3 + T_EXTRA(info ->InputFormat));
- return accum;
- }
-}
-
-// 1.15 fixed point, that means maximum value is MAX_ENCODEABLE_XYZ (0xFFFF)
-static
-cmsUInt8Number* UnrollXYZDoubleToFloat(_cmsTRANSFORM* info,
- cmsFloat32Number wIn[],
- cmsUInt8Number* accum,
- cmsUInt32Number Stride)
-{
- cmsFloat64Number* Pt = (cmsFloat64Number*) accum;
-
- if (T_PLANAR(info -> InputFormat)) {
-
- Stride /= PixelSize(info->InputFormat);
-
- wIn[0] = (cmsFloat32Number) (Pt[0] / MAX_ENCODEABLE_XYZ);
- wIn[1] = (cmsFloat32Number) (Pt[Stride] / MAX_ENCODEABLE_XYZ);
- wIn[2] = (cmsFloat32Number) (Pt[Stride*2] / MAX_ENCODEABLE_XYZ);
-
- return accum + sizeof(cmsFloat64Number);
- }
- else {
-
- wIn[0] = (cmsFloat32Number) (Pt[0] / MAX_ENCODEABLE_XYZ);
- wIn[1] = (cmsFloat32Number) (Pt[1] / MAX_ENCODEABLE_XYZ);
- wIn[2] = (cmsFloat32Number) (Pt[2] / MAX_ENCODEABLE_XYZ);
-
- accum += sizeof(cmsFloat64Number)*(3 + T_EXTRA(info ->InputFormat));
- return accum;
- }
-}
-
-static
-cmsUInt8Number* UnrollXYZFloatToFloat(_cmsTRANSFORM* info,
- cmsFloat32Number wIn[],
- cmsUInt8Number* accum,
- cmsUInt32Number Stride)
-{
- cmsFloat32Number* Pt = (cmsFloat32Number*) accum;
-
- if (T_PLANAR(info -> InputFormat)) {
-
- Stride /= PixelSize(info->InputFormat);
-
- wIn[0] = (cmsFloat32Number) (Pt[0] / MAX_ENCODEABLE_XYZ);
- wIn[1] = (cmsFloat32Number) (Pt[Stride] / MAX_ENCODEABLE_XYZ);
- wIn[2] = (cmsFloat32Number) (Pt[Stride*2] / MAX_ENCODEABLE_XYZ);
-
- return accum + sizeof(cmsFloat32Number);
- }
- else {
-
- wIn[0] = (cmsFloat32Number) (Pt[0] / MAX_ENCODEABLE_XYZ);
- wIn[1] = (cmsFloat32Number) (Pt[1] / MAX_ENCODEABLE_XYZ);
- wIn[2] = (cmsFloat32Number) (Pt[2] / MAX_ENCODEABLE_XYZ);
-
- accum += sizeof(cmsFloat32Number)*(3 + T_EXTRA(info ->InputFormat));
- return accum;
- }
-}
-
-
-cmsINLINE void lab4toFloat(cmsFloat32Number wIn[], cmsUInt16Number lab4[3])
-{
- cmsFloat32Number L = (cmsFloat32Number) lab4[0] / 655.35F;
- cmsFloat32Number a = ((cmsFloat32Number) lab4[1] / 257.0F) - 128.0F;
- cmsFloat32Number b = ((cmsFloat32Number) lab4[2] / 257.0F) - 128.0F;
-
- wIn[0] = (L / 100.0F); // from 0..100 to 0..1
- wIn[1] = ((a + 128.0F) / 255.0F); // form -128..+127 to 0..1
- wIn[2] = ((b + 128.0F) / 255.0F);
-
-}
-
-static
-cmsUInt8Number* UnrollLabV2_8ToFloat(_cmsTRANSFORM* info,
- cmsFloat32Number wIn[],
- cmsUInt8Number* accum,
- cmsUInt32Number Stride)
-{
- cmsUInt16Number lab4[3];
-
- lab4[0] = FomLabV2ToLabV4(FROM_8_TO_16(*accum)); accum++; // L
- lab4[1] = FomLabV2ToLabV4(FROM_8_TO_16(*accum)); accum++; // a
- lab4[2] = FomLabV2ToLabV4(FROM_8_TO_16(*accum)); accum++; // b
-
- lab4toFloat(wIn, lab4);
-
- return accum;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* UnrollALabV2_8ToFloat(_cmsTRANSFORM* info,
- cmsFloat32Number wIn[],
- cmsUInt8Number* accum,
- cmsUInt32Number Stride)
-{
- cmsUInt16Number lab4[3];
-
- accum++; // A
- lab4[0] = FomLabV2ToLabV4(FROM_8_TO_16(*accum)); accum++; // L
- lab4[1] = FomLabV2ToLabV4(FROM_8_TO_16(*accum)); accum++; // a
- lab4[2] = FomLabV2ToLabV4(FROM_8_TO_16(*accum)); accum++; // b
-
- lab4toFloat(wIn, lab4);
-
- return accum;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* UnrollLabV2_16ToFloat(_cmsTRANSFORM* info,
- cmsFloat32Number wIn[],
- cmsUInt8Number* accum,
- cmsUInt32Number Stride)
-{
- cmsUInt16Number lab4[3];
-
- lab4[0] = FomLabV2ToLabV4(*(cmsUInt16Number*) accum); accum += 2; // L
- lab4[1] = FomLabV2ToLabV4(*(cmsUInt16Number*) accum); accum += 2; // a
- lab4[2] = FomLabV2ToLabV4(*(cmsUInt16Number*) accum); accum += 2; // b
-
- lab4toFloat(wIn, lab4);
-
- return accum;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-
-// Packing routines -----------------------------------------------------------------------------------------------------------
-
-
-// Generic chunky for byte
-static
-cmsUInt8Number* PackChunkyBytes(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- cmsUInt32Number nChan = T_CHANNELS(info->OutputFormat);
- cmsUInt32Number DoSwap = T_DOSWAP(info->OutputFormat);
- cmsUInt32Number Reverse = T_FLAVOR(info->OutputFormat);
- cmsUInt32Number Extra = T_EXTRA(info->OutputFormat);
- cmsUInt32Number SwapFirst = T_SWAPFIRST(info->OutputFormat);
- cmsUInt32Number Premul = T_PREMUL(info->OutputFormat);
- cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
- cmsUInt8Number* swap1;
- cmsUInt16Number v = 0;
- cmsUInt32Number i;
- cmsUInt32Number alpha_factor = 0;
-
- swap1 = output;
-
- if (ExtraFirst) {
-
- if (Premul && Extra)
- alpha_factor = _cmsToFixedDomain(FROM_8_TO_16(output[0]));
-
- output += Extra;
- }
- else
- {
- if (Premul && Extra)
- alpha_factor = _cmsToFixedDomain(FROM_8_TO_16(output[nChan]));
- }
-
- for (i=0; i < nChan; i++) {
-
- cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
-
- v = wOut[index];
-
- if (Reverse)
- v = REVERSE_FLAVOR_16(v);
-
- if (Premul)
- {
- v = (cmsUInt16Number)((cmsUInt32Number)((cmsUInt32Number)v * alpha_factor + 0x8000) >> 16);
- }
-
- *output++ = FROM_16_TO_8(v);
- }
-
- if (!ExtraFirst) {
- output += Extra;
- }
-
- if (Extra == 0 && SwapFirst) {
-
- memmove(swap1 + 1, swap1, nChan-1);
- *swap1 = FROM_16_TO_8(v);
- }
-
- return output;
-
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* PackChunkyWords(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- cmsUInt32Number nChan = T_CHANNELS(info->OutputFormat);
- cmsUInt32Number SwapEndian = T_ENDIAN16(info->OutputFormat);
- cmsUInt32Number DoSwap = T_DOSWAP(info->OutputFormat);
- cmsUInt32Number Reverse = T_FLAVOR(info->OutputFormat);
- cmsUInt32Number Extra = T_EXTRA(info->OutputFormat);
- cmsUInt32Number SwapFirst = T_SWAPFIRST(info->OutputFormat);
- cmsUInt32Number Premul = T_PREMUL(info->OutputFormat);
- cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
- cmsUInt16Number* swap1;
- cmsUInt16Number v = 0;
- cmsUInt32Number i;
- cmsUInt32Number alpha_factor = 0;
-
- swap1 = (cmsUInt16Number*) output;
-
- if (ExtraFirst) {
-
- if (Premul && Extra)
- alpha_factor = _cmsToFixedDomain(*(cmsUInt16Number*) output);
-
- output += Extra * sizeof(cmsUInt16Number);
- }
- else
- {
- if (Premul && Extra)
- alpha_factor = _cmsToFixedDomain(((cmsUInt16Number*) output)[nChan]);
- }
-
- for (i=0; i < nChan; i++) {
-
- cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
-
- v = wOut[index];
-
- if (SwapEndian)
- v = CHANGE_ENDIAN(v);
-
- if (Reverse)
- v = REVERSE_FLAVOR_16(v);
-
- if (Premul)
- {
- v = (cmsUInt16Number)((cmsUInt32Number)((cmsUInt32Number)v * alpha_factor + 0x8000) >> 16);
- }
-
- *(cmsUInt16Number*) output = v;
-
- output += sizeof(cmsUInt16Number);
- }
-
- if (!ExtraFirst) {
- output += Extra * sizeof(cmsUInt16Number);
- }
-
- if (Extra == 0 && SwapFirst) {
-
- memmove(swap1 + 1, swap1, (nChan-1)* sizeof(cmsUInt16Number));
- *swap1 = v;
- }
-
- return output;
-
- cmsUNUSED_PARAMETER(Stride);
-}
-
-
-
-static
-cmsUInt8Number* PackPlanarBytes(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- cmsUInt32Number nChan = T_CHANNELS(info->OutputFormat);
- cmsUInt32Number DoSwap = T_DOSWAP(info->OutputFormat);
- cmsUInt32Number SwapFirst = T_SWAPFIRST(info->OutputFormat);
- cmsUInt32Number Reverse = T_FLAVOR(info->OutputFormat);
- cmsUInt32Number Extra = T_EXTRA(info->OutputFormat);
- cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
- cmsUInt32Number Premul = T_PREMUL(info->OutputFormat);
- cmsUInt32Number i;
- cmsUInt8Number* Init = output;
- cmsUInt32Number alpha_factor = 0;
-
-
- if (ExtraFirst) {
-
- if (Premul && Extra)
- alpha_factor = _cmsToFixedDomain(FROM_8_TO_16(output[0]));
-
- output += Extra * Stride;
- }
- else
- {
- if (Premul && Extra)
- alpha_factor = _cmsToFixedDomain(FROM_8_TO_16(output[nChan * Stride]));
- }
-
-
- for (i=0; i < nChan; i++) {
-
- cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
- cmsUInt16Number v = wOut[index];
-
- if (Reverse)
- v = REVERSE_FLAVOR_16(v);
-
- if (Premul)
- {
- v = (cmsUInt16Number)((cmsUInt32Number)((cmsUInt32Number)v * alpha_factor + 0x8000) >> 16);
- }
-
- *(cmsUInt8Number*)output = FROM_16_TO_8(v);
-
- output += Stride;
- }
-
- return (Init + 1);
-
- cmsUNUSED_PARAMETER(Stride);
-}
-
-
-static
-cmsUInt8Number* PackPlanarWords(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- cmsUInt32Number nChan = T_CHANNELS(info->OutputFormat);
- cmsUInt32Number DoSwap = T_DOSWAP(info->OutputFormat);
- cmsUInt32Number SwapFirst = T_SWAPFIRST(info->OutputFormat);
- cmsUInt32Number Reverse = T_FLAVOR(info->OutputFormat);
- cmsUInt32Number Extra = T_EXTRA(info->OutputFormat);
- cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
- cmsUInt32Number Premul = T_PREMUL(info->OutputFormat);
- cmsUInt32Number SwapEndian = T_ENDIAN16(info->OutputFormat);
- cmsUInt32Number i;
- cmsUInt8Number* Init = output;
- cmsUInt16Number v;
- cmsUInt32Number alpha_factor = 0;
-
- if (ExtraFirst) {
-
- if (Premul && Extra)
- alpha_factor = _cmsToFixedDomain(((cmsUInt16Number*) output)[0]);
-
- output += Extra * Stride;
- }
- else
- {
- if (Premul && Extra)
- alpha_factor = _cmsToFixedDomain(((cmsUInt16Number*)output)[nChan * Stride]);
- }
-
- for (i=0; i < nChan; i++) {
-
- cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
-
- v = wOut[index];
-
- if (SwapEndian)
- v = CHANGE_ENDIAN(v);
-
- if (Reverse)
- v = REVERSE_FLAVOR_16(v);
-
- if (Premul)
- {
- v = (cmsUInt16Number)((cmsUInt32Number)((cmsUInt32Number)v * alpha_factor + 0x8000) >> 16);
- }
-
- *(cmsUInt16Number*) output = v;
- output += Stride;
- }
-
- return (Init + sizeof(cmsUInt16Number));
-}
-
-// CMYKcm (unrolled for speed)
-
-static
-cmsUInt8Number* Pack6Bytes(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- *output++ = FROM_16_TO_8(wOut[0]);
- *output++ = FROM_16_TO_8(wOut[1]);
- *output++ = FROM_16_TO_8(wOut[2]);
- *output++ = FROM_16_TO_8(wOut[3]);
- *output++ = FROM_16_TO_8(wOut[4]);
- *output++ = FROM_16_TO_8(wOut[5]);
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-// KCMYcm
-
-static
-cmsUInt8Number* Pack6BytesSwap(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- *output++ = FROM_16_TO_8(wOut[5]);
- *output++ = FROM_16_TO_8(wOut[4]);
- *output++ = FROM_16_TO_8(wOut[3]);
- *output++ = FROM_16_TO_8(wOut[2]);
- *output++ = FROM_16_TO_8(wOut[1]);
- *output++ = FROM_16_TO_8(wOut[0]);
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-// CMYKcm
-static
-cmsUInt8Number* Pack6Words(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- *(cmsUInt16Number*) output = wOut[0];
- output+= 2;
- *(cmsUInt16Number*) output = wOut[1];
- output+= 2;
- *(cmsUInt16Number*) output = wOut[2];
- output+= 2;
- *(cmsUInt16Number*) output = wOut[3];
- output+= 2;
- *(cmsUInt16Number*) output = wOut[4];
- output+= 2;
- *(cmsUInt16Number*) output = wOut[5];
- output+= 2;
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-// KCMYcm
-static
-cmsUInt8Number* Pack6WordsSwap(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- *(cmsUInt16Number*) output = wOut[5];
- output+= 2;
- *(cmsUInt16Number*) output = wOut[4];
- output+= 2;
- *(cmsUInt16Number*) output = wOut[3];
- output+= 2;
- *(cmsUInt16Number*) output = wOut[2];
- output+= 2;
- *(cmsUInt16Number*) output = wOut[1];
- output+= 2;
- *(cmsUInt16Number*) output = wOut[0];
- output+= 2;
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-
-static
-cmsUInt8Number* Pack4Bytes(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- *output++ = FROM_16_TO_8(wOut[0]);
- *output++ = FROM_16_TO_8(wOut[1]);
- *output++ = FROM_16_TO_8(wOut[2]);
- *output++ = FROM_16_TO_8(wOut[3]);
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* Pack4BytesReverse(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- *output++ = REVERSE_FLAVOR_8(FROM_16_TO_8(wOut[0]));
- *output++ = REVERSE_FLAVOR_8(FROM_16_TO_8(wOut[1]));
- *output++ = REVERSE_FLAVOR_8(FROM_16_TO_8(wOut[2]));
- *output++ = REVERSE_FLAVOR_8(FROM_16_TO_8(wOut[3]));
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-
-static
-cmsUInt8Number* Pack4BytesSwapFirst(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- *output++ = FROM_16_TO_8(wOut[3]);
- *output++ = FROM_16_TO_8(wOut[0]);
- *output++ = FROM_16_TO_8(wOut[1]);
- *output++ = FROM_16_TO_8(wOut[2]);
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-// ABGR
-static
-cmsUInt8Number* Pack4BytesSwap(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- *output++ = FROM_16_TO_8(wOut[3]);
- *output++ = FROM_16_TO_8(wOut[2]);
- *output++ = FROM_16_TO_8(wOut[1]);
- *output++ = FROM_16_TO_8(wOut[0]);
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* Pack4BytesSwapSwapFirst(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- *output++ = FROM_16_TO_8(wOut[2]);
- *output++ = FROM_16_TO_8(wOut[1]);
- *output++ = FROM_16_TO_8(wOut[0]);
- *output++ = FROM_16_TO_8(wOut[3]);
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* Pack4Words(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- *(cmsUInt16Number*) output = wOut[0];
- output+= 2;
- *(cmsUInt16Number*) output = wOut[1];
- output+= 2;
- *(cmsUInt16Number*) output = wOut[2];
- output+= 2;
- *(cmsUInt16Number*) output = wOut[3];
- output+= 2;
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* Pack4WordsReverse(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- *(cmsUInt16Number*) output = REVERSE_FLAVOR_16(wOut[0]);
- output+= 2;
- *(cmsUInt16Number*) output = REVERSE_FLAVOR_16(wOut[1]);
- output+= 2;
- *(cmsUInt16Number*) output = REVERSE_FLAVOR_16(wOut[2]);
- output+= 2;
- *(cmsUInt16Number*) output = REVERSE_FLAVOR_16(wOut[3]);
- output+= 2;
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-// ABGR
-static
-cmsUInt8Number* Pack4WordsSwap(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- *(cmsUInt16Number*) output = wOut[3];
- output+= 2;
- *(cmsUInt16Number*) output = wOut[2];
- output+= 2;
- *(cmsUInt16Number*) output = wOut[1];
- output+= 2;
- *(cmsUInt16Number*) output = wOut[0];
- output+= 2;
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-// CMYK
-static
-cmsUInt8Number* Pack4WordsBigEndian(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- *(cmsUInt16Number*) output = CHANGE_ENDIAN(wOut[0]);
- output+= 2;
- *(cmsUInt16Number*) output = CHANGE_ENDIAN(wOut[1]);
- output+= 2;
- *(cmsUInt16Number*) output = CHANGE_ENDIAN(wOut[2]);
- output+= 2;
- *(cmsUInt16Number*) output = CHANGE_ENDIAN(wOut[3]);
- output+= 2;
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-
-static
-cmsUInt8Number* PackLabV2_8(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- *output++ = FROM_16_TO_8(FomLabV4ToLabV2(wOut[0]));
- *output++ = FROM_16_TO_8(FomLabV4ToLabV2(wOut[1]));
- *output++ = FROM_16_TO_8(FomLabV4ToLabV2(wOut[2]));
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* PackALabV2_8(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- output++;
- *output++ = FROM_16_TO_8(FomLabV4ToLabV2(wOut[0]));
- *output++ = FROM_16_TO_8(FomLabV4ToLabV2(wOut[1]));
- *output++ = FROM_16_TO_8(FomLabV4ToLabV2(wOut[2]));
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* PackLabV2_16(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- *(cmsUInt16Number*) output = FomLabV4ToLabV2(wOut[0]);
- output += 2;
- *(cmsUInt16Number*) output = FomLabV4ToLabV2(wOut[1]);
- output += 2;
- *(cmsUInt16Number*) output = FomLabV4ToLabV2(wOut[2]);
- output += 2;
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* Pack3Bytes(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- *output++ = FROM_16_TO_8(wOut[0]);
- *output++ = FROM_16_TO_8(wOut[1]);
- *output++ = FROM_16_TO_8(wOut[2]);
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* Pack3BytesOptimized(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- *output++ = (wOut[0] & 0xFFU);
- *output++ = (wOut[1] & 0xFFU);
- *output++ = (wOut[2] & 0xFFU);
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* Pack3BytesSwap(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- *output++ = FROM_16_TO_8(wOut[2]);
- *output++ = FROM_16_TO_8(wOut[1]);
- *output++ = FROM_16_TO_8(wOut[0]);
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* Pack3BytesSwapOptimized(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- *output++ = (wOut[2] & 0xFFU);
- *output++ = (wOut[1] & 0xFFU);
- *output++ = (wOut[0] & 0xFFU);
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-
-static
-cmsUInt8Number* Pack3Words(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- *(cmsUInt16Number*) output = wOut[0];
- output+= 2;
- *(cmsUInt16Number*) output = wOut[1];
- output+= 2;
- *(cmsUInt16Number*) output = wOut[2];
- output+= 2;
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* Pack3WordsSwap(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- *(cmsUInt16Number*) output = wOut[2];
- output+= 2;
- *(cmsUInt16Number*) output = wOut[1];
- output+= 2;
- *(cmsUInt16Number*) output = wOut[0];
- output+= 2;
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* Pack3WordsBigEndian(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- *(cmsUInt16Number*) output = CHANGE_ENDIAN(wOut[0]);
- output+= 2;
- *(cmsUInt16Number*) output = CHANGE_ENDIAN(wOut[1]);
- output+= 2;
- *(cmsUInt16Number*) output = CHANGE_ENDIAN(wOut[2]);
- output+= 2;
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* Pack3BytesAndSkip1(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- *output++ = FROM_16_TO_8(wOut[0]);
- *output++ = FROM_16_TO_8(wOut[1]);
- *output++ = FROM_16_TO_8(wOut[2]);
- output++;
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* Pack3BytesAndSkip1Optimized(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- *output++ = (wOut[0] & 0xFFU);
- *output++ = (wOut[1] & 0xFFU);
- *output++ = (wOut[2] & 0xFFU);
- output++;
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-
-static
-cmsUInt8Number* Pack3BytesAndSkip1SwapFirst(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- output++;
- *output++ = FROM_16_TO_8(wOut[0]);
- *output++ = FROM_16_TO_8(wOut[1]);
- *output++ = FROM_16_TO_8(wOut[2]);
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* Pack3BytesAndSkip1SwapFirstOptimized(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- output++;
- *output++ = (wOut[0] & 0xFFU);
- *output++ = (wOut[1] & 0xFFU);
- *output++ = (wOut[2] & 0xFFU);
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* Pack3BytesAndSkip1Swap(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- output++;
- *output++ = FROM_16_TO_8(wOut[2]);
- *output++ = FROM_16_TO_8(wOut[1]);
- *output++ = FROM_16_TO_8(wOut[0]);
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* Pack3BytesAndSkip1SwapOptimized(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- output++;
- *output++ = (wOut[2] & 0xFFU);
- *output++ = (wOut[1] & 0xFFU);
- *output++ = (wOut[0] & 0xFFU);
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-
-static
-cmsUInt8Number* Pack3BytesAndSkip1SwapSwapFirst(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- *output++ = FROM_16_TO_8(wOut[2]);
- *output++ = FROM_16_TO_8(wOut[1]);
- *output++ = FROM_16_TO_8(wOut[0]);
- output++;
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* Pack3BytesAndSkip1SwapSwapFirstOptimized(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- *output++ = (wOut[2] & 0xFFU);
- *output++ = (wOut[1] & 0xFFU);
- *output++ = (wOut[0] & 0xFFU);
- output++;
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* Pack3WordsAndSkip1(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- *(cmsUInt16Number*) output = wOut[0];
- output+= 2;
- *(cmsUInt16Number*) output = wOut[1];
- output+= 2;
- *(cmsUInt16Number*) output = wOut[2];
- output+= 2;
- output+= 2;
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* Pack3WordsAndSkip1Swap(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- output+= 2;
- *(cmsUInt16Number*) output = wOut[2];
- output+= 2;
- *(cmsUInt16Number*) output = wOut[1];
- output+= 2;
- *(cmsUInt16Number*) output = wOut[0];
- output+= 2;
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-
-static
-cmsUInt8Number* Pack3WordsAndSkip1SwapFirst(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- output+= 2;
- *(cmsUInt16Number*) output = wOut[0];
- output+= 2;
- *(cmsUInt16Number*) output = wOut[1];
- output+= 2;
- *(cmsUInt16Number*) output = wOut[2];
- output+= 2;
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-
-static
-cmsUInt8Number* Pack3WordsAndSkip1SwapSwapFirst(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- *(cmsUInt16Number*) output = wOut[2];
- output+= 2;
- *(cmsUInt16Number*) output = wOut[1];
- output+= 2;
- *(cmsUInt16Number*) output = wOut[0];
- output+= 2;
- output+= 2;
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-
-
-static
-cmsUInt8Number* Pack1Byte(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- *output++ = FROM_16_TO_8(wOut[0]);
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-
-static
-cmsUInt8Number* Pack1ByteReversed(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- *output++ = FROM_16_TO_8(REVERSE_FLAVOR_16(wOut[0]));
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-
-static
-cmsUInt8Number* Pack1ByteSkip1(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- *output++ = FROM_16_TO_8(wOut[0]);
- output++;
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-
-static
-cmsUInt8Number* Pack1ByteSkip1SwapFirst(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- output++;
- *output++ = FROM_16_TO_8(wOut[0]);
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* Pack1Word(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- *(cmsUInt16Number*) output = wOut[0];
- output+= 2;
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-
-static
-cmsUInt8Number* Pack1WordReversed(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- *(cmsUInt16Number*) output = REVERSE_FLAVOR_16(wOut[0]);
- output+= 2;
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* Pack1WordBigEndian(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- *(cmsUInt16Number*) output = CHANGE_ENDIAN(wOut[0]);
- output+= 2;
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-
-static
-cmsUInt8Number* Pack1WordSkip1(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- *(cmsUInt16Number*) output = wOut[0];
- output+= 4;
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* Pack1WordSkip1SwapFirst(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- output += 2;
- *(cmsUInt16Number*) output = wOut[0];
- output+= 2;
-
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-
-// Unencoded Float values -- don't try optimize speed
-static
-cmsUInt8Number* PackLabDoubleFrom16(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
-
- if (T_PLANAR(info -> OutputFormat)) {
-
- cmsCIELab Lab;
- cmsFloat64Number* Out = (cmsFloat64Number*) output;
- cmsLabEncoded2Float(&Lab, wOut);
-
- Out[0] = Lab.L;
- Out[Stride] = Lab.a;
- Out[Stride*2] = Lab.b;
-
- return output + sizeof(cmsFloat64Number);
- }
- else {
-
- cmsLabEncoded2Float((cmsCIELab*) output, wOut);
- return output + (sizeof(cmsCIELab) + T_EXTRA(info ->OutputFormat) * sizeof(cmsFloat64Number));
- }
-}
-
-
-static
-cmsUInt8Number* PackLabFloatFrom16(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- cmsCIELab Lab;
- cmsLabEncoded2Float(&Lab, wOut);
-
- if (T_PLANAR(info -> OutputFormat)) {
-
- cmsFloat32Number* Out = (cmsFloat32Number*) output;
-
- Stride /= PixelSize(info->OutputFormat);
-
- Out[0] = (cmsFloat32Number)Lab.L;
- Out[Stride] = (cmsFloat32Number)Lab.a;
- Out[Stride*2] = (cmsFloat32Number)Lab.b;
-
- return output + sizeof(cmsFloat32Number);
- }
- else {
-
- ((cmsFloat32Number*) output)[0] = (cmsFloat32Number) Lab.L;
- ((cmsFloat32Number*) output)[1] = (cmsFloat32Number) Lab.a;
- ((cmsFloat32Number*) output)[2] = (cmsFloat32Number) Lab.b;
-
- return output + (3 + T_EXTRA(info ->OutputFormat)) * sizeof(cmsFloat32Number);
- }
-}
-
-static
-cmsUInt8Number* PackXYZDoubleFrom16(CMSREGISTER _cmsTRANSFORM* Info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- if (T_PLANAR(Info -> OutputFormat)) {
-
- cmsCIEXYZ XYZ;
- cmsFloat64Number* Out = (cmsFloat64Number*) output;
- cmsXYZEncoded2Float(&XYZ, wOut);
-
- Stride /= PixelSize(Info->OutputFormat);
-
- Out[0] = XYZ.X;
- Out[Stride] = XYZ.Y;
- Out[Stride*2] = XYZ.Z;
-
- return output + sizeof(cmsFloat64Number);
-
- }
- else {
-
- cmsXYZEncoded2Float((cmsCIEXYZ*) output, wOut);
-
- return output + (sizeof(cmsCIEXYZ) + T_EXTRA(Info ->OutputFormat) * sizeof(cmsFloat64Number));
- }
-}
-
-static
-cmsUInt8Number* PackXYZFloatFrom16(CMSREGISTER _cmsTRANSFORM* Info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- if (T_PLANAR(Info -> OutputFormat)) {
-
- cmsCIEXYZ XYZ;
- cmsFloat32Number* Out = (cmsFloat32Number*) output;
- cmsXYZEncoded2Float(&XYZ, wOut);
-
- Stride /= PixelSize(Info->OutputFormat);
-
- Out[0] = (cmsFloat32Number) XYZ.X;
- Out[Stride] = (cmsFloat32Number) XYZ.Y;
- Out[Stride*2] = (cmsFloat32Number) XYZ.Z;
-
- return output + sizeof(cmsFloat32Number);
-
- }
- else {
-
- cmsCIEXYZ XYZ;
- cmsFloat32Number* Out = (cmsFloat32Number*) output;
- cmsXYZEncoded2Float(&XYZ, wOut);
-
- Out[0] = (cmsFloat32Number) XYZ.X;
- Out[1] = (cmsFloat32Number) XYZ.Y;
- Out[2] = (cmsFloat32Number) XYZ.Z;
-
- return output + (3 * sizeof(cmsFloat32Number) + T_EXTRA(Info ->OutputFormat) * sizeof(cmsFloat32Number));
- }
-}
-
-static
-cmsUInt8Number* PackDoubleFrom16(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- cmsUInt32Number nChan = T_CHANNELS(info -> OutputFormat);
- cmsUInt32Number DoSwap = T_DOSWAP(info ->OutputFormat);
- cmsUInt32Number Reverse = T_FLAVOR(info ->OutputFormat);
- cmsUInt32Number Extra = T_EXTRA(info -> OutputFormat);
- cmsUInt32Number SwapFirst = T_SWAPFIRST(info -> OutputFormat);
- cmsUInt32Number Planar = T_PLANAR(info -> OutputFormat);
- cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
- cmsFloat64Number maximum = IsInkSpace(info ->OutputFormat) ? 655.35 : 65535.0;
- cmsFloat64Number v = 0;
- cmsFloat64Number* swap1 = (cmsFloat64Number*) output;
- cmsUInt32Number i, start = 0;
-
- Stride /= PixelSize(info->OutputFormat);
-
- if (ExtraFirst)
- start = Extra;
-
- for (i=0; i < nChan; i++) {
-
- cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
-
- v = (cmsFloat64Number) wOut[index] / maximum;
-
- if (Reverse)
- v = maximum - v;
-
- if (Planar)
- ((cmsFloat64Number*) output)[(i + start) * Stride]= v;
- else
- ((cmsFloat64Number*) output)[i + start] = v;
- }
-
-
- if (Extra == 0 && SwapFirst) {
-
- memmove(swap1 + 1, swap1, (nChan-1)* sizeof(cmsFloat64Number));
- *swap1 = v;
- }
-
- if (T_PLANAR(info -> OutputFormat))
- return output + sizeof(cmsFloat64Number);
- else
- return output + (nChan + Extra) * sizeof(cmsFloat64Number);
-
-}
-
-
-static
-cmsUInt8Number* PackFloatFrom16(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- cmsUInt32Number nChan = T_CHANNELS(info->OutputFormat);
- cmsUInt32Number DoSwap = T_DOSWAP(info->OutputFormat);
- cmsUInt32Number Reverse = T_FLAVOR(info->OutputFormat);
- cmsUInt32Number Extra = T_EXTRA(info->OutputFormat);
- cmsUInt32Number SwapFirst = T_SWAPFIRST(info->OutputFormat);
- cmsUInt32Number Planar = T_PLANAR(info->OutputFormat);
- cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
- cmsFloat64Number maximum = IsInkSpace(info->OutputFormat) ? 655.35 : 65535.0;
- cmsFloat64Number v = 0;
- cmsFloat32Number* swap1 = (cmsFloat32Number*)output;
- cmsUInt32Number i, start = 0;
-
- Stride /= PixelSize(info->OutputFormat);
-
- if (ExtraFirst)
- start = Extra;
-
- for (i = 0; i < nChan; i++) {
-
- cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
-
- v = (cmsFloat64Number)wOut[index] / maximum;
-
- if (Reverse)
- v = maximum - v;
-
- if (Planar)
- ((cmsFloat32Number*)output)[(i + start) * Stride] = (cmsFloat32Number)v;
- else
- ((cmsFloat32Number*)output)[i + start] = (cmsFloat32Number)v;
- }
-
-
- if (Extra == 0 && SwapFirst) {
-
- memmove(swap1 + 1, swap1, (nChan - 1)* sizeof(cmsFloat32Number));
- *swap1 = (cmsFloat32Number)v;
- }
-
- if (T_PLANAR(info->OutputFormat))
- return output + sizeof(cmsFloat32Number);
- else
- return output + (nChan + Extra) * sizeof(cmsFloat32Number);
-}
-
-
-
-// --------------------------------------------------------------------------------------------------------
-
-static
-cmsUInt8Number* PackBytesFromFloat(_cmsTRANSFORM* info,
- cmsFloat32Number wOut[],
- cmsUInt8Number* output,
- cmsUInt32Number Stride)
-{
- cmsUInt32Number nChan = T_CHANNELS(info->OutputFormat);
- cmsUInt32Number DoSwap = T_DOSWAP(info->OutputFormat);
- cmsUInt32Number Reverse = T_FLAVOR(info->OutputFormat);
- cmsUInt32Number Extra = T_EXTRA(info->OutputFormat);
- cmsUInt32Number SwapFirst = T_SWAPFIRST(info->OutputFormat);
- cmsUInt32Number Planar = T_PLANAR(info->OutputFormat);
- cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
- cmsUInt8Number* swap1 = (cmsUInt8Number*)output;
- cmsFloat64Number v = 0;
- cmsUInt8Number vv = 0;
- cmsUInt32Number i, start = 0;
-
- if (ExtraFirst)
- start = Extra;
-
- for (i = 0; i < nChan; i++) {
-
- cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
-
- v = wOut[index] * 65535.0;
-
- if (Reverse)
- v = 65535.0 - v;
-
- vv = FROM_16_TO_8(_cmsQuickSaturateWord(v));
-
- if (Planar)
- ((cmsUInt8Number*)output)[(i + start) * Stride] = vv;
- else
- ((cmsUInt8Number*)output)[i + start] = vv;
- }
-
-
- if (Extra == 0 && SwapFirst) {
-
- memmove(swap1 + 1, swap1, (nChan - 1) * sizeof(cmsUInt8Number));
- *swap1 = vv;
- }
-
- if (T_PLANAR(info->OutputFormat))
- return output + sizeof(cmsUInt8Number);
- else
- return output + (nChan + Extra) * sizeof(cmsUInt8Number);
-}
-
-static
-cmsUInt8Number* PackWordsFromFloat(_cmsTRANSFORM* info,
- cmsFloat32Number wOut[],
- cmsUInt8Number* output,
- cmsUInt32Number Stride)
-{
- cmsUInt32Number nChan = T_CHANNELS(info->OutputFormat);
- cmsUInt32Number DoSwap = T_DOSWAP(info->OutputFormat);
- cmsUInt32Number Reverse = T_FLAVOR(info->OutputFormat);
- cmsUInt32Number Extra = T_EXTRA(info->OutputFormat);
- cmsUInt32Number SwapFirst = T_SWAPFIRST(info->OutputFormat);
- cmsUInt32Number Planar = T_PLANAR(info->OutputFormat);
- cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
- cmsUInt16Number* swap1 = (cmsUInt16Number*)output;
- cmsFloat64Number v = 0;
- cmsUInt16Number vv = 0;
- cmsUInt32Number i, start = 0;
-
- if (ExtraFirst)
- start = Extra;
-
- for (i = 0; i < nChan; i++) {
-
- cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
-
- v = wOut[index] * 65535.0;
-
- if (Reverse)
- v = 65535.0 - v;
-
- vv = _cmsQuickSaturateWord(v);
-
- if (Planar)
- ((cmsUInt16Number*)output)[(i + start) * Stride] = vv;
- else
- ((cmsUInt16Number*)output)[i + start] = vv;
- }
-
- if (Extra == 0 && SwapFirst) {
-
- memmove(swap1 + 1, swap1, (nChan - 1) * sizeof(cmsUInt16Number));
- *swap1 = vv;
- }
-
- if (T_PLANAR(info->OutputFormat))
- return output + sizeof(cmsUInt16Number);
- else
- return output + (nChan + Extra) * sizeof(cmsUInt16Number);
-}
-
-
-static
-cmsUInt8Number* PackFloatsFromFloat(_cmsTRANSFORM* info,
- cmsFloat32Number wOut[],
- cmsUInt8Number* output,
- cmsUInt32Number Stride)
-{
- cmsUInt32Number nChan = T_CHANNELS(info->OutputFormat);
- cmsUInt32Number DoSwap = T_DOSWAP(info->OutputFormat);
- cmsUInt32Number Reverse = T_FLAVOR(info->OutputFormat);
- cmsUInt32Number Extra = T_EXTRA(info->OutputFormat);
- cmsUInt32Number SwapFirst = T_SWAPFIRST(info->OutputFormat);
- cmsUInt32Number Planar = T_PLANAR(info->OutputFormat);
- cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
- cmsFloat64Number maximum = IsInkSpace(info->OutputFormat) ? 100.0 : 1.0;
- cmsFloat32Number* swap1 = (cmsFloat32Number*)output;
- cmsFloat64Number v = 0;
- cmsUInt32Number i, start = 0;
-
- Stride /= PixelSize(info->OutputFormat);
-
- if (ExtraFirst)
- start = Extra;
-
- for (i = 0; i < nChan; i++) {
-
- cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
-
- v = wOut[index] * maximum;
-
- if (Reverse)
- v = maximum - v;
-
- if (Planar)
- ((cmsFloat32Number*)output)[(i + start)* Stride] = (cmsFloat32Number)v;
- else
- ((cmsFloat32Number*)output)[i + start] = (cmsFloat32Number)v;
- }
-
-
- if (Extra == 0 && SwapFirst) {
-
- memmove(swap1 + 1, swap1, (nChan - 1)* sizeof(cmsFloat32Number));
- *swap1 = (cmsFloat32Number)v;
- }
-
- if (T_PLANAR(info->OutputFormat))
- return output + sizeof(cmsFloat32Number);
- else
- return output + (nChan + Extra) * sizeof(cmsFloat32Number);
-}
-
-static
-cmsUInt8Number* PackDoublesFromFloat(_cmsTRANSFORM* info,
- cmsFloat32Number wOut[],
- cmsUInt8Number* output,
- cmsUInt32Number Stride)
-{
- cmsUInt32Number nChan = T_CHANNELS(info->OutputFormat);
- cmsUInt32Number DoSwap = T_DOSWAP(info->OutputFormat);
- cmsUInt32Number Reverse = T_FLAVOR(info->OutputFormat);
- cmsUInt32Number Extra = T_EXTRA(info->OutputFormat);
- cmsUInt32Number SwapFirst = T_SWAPFIRST(info->OutputFormat);
- cmsUInt32Number Planar = T_PLANAR(info->OutputFormat);
- cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
- cmsFloat64Number maximum = IsInkSpace(info->OutputFormat) ? 100.0 : 1.0;
- cmsFloat64Number v = 0;
- cmsFloat64Number* swap1 = (cmsFloat64Number*)output;
- cmsUInt32Number i, start = 0;
-
- Stride /= PixelSize(info->OutputFormat);
-
- if (ExtraFirst)
- start = Extra;
-
- for (i = 0; i < nChan; i++) {
-
- cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
-
- v = wOut[index] * maximum;
-
- if (Reverse)
- v = maximum - v;
-
- if (Planar)
- ((cmsFloat64Number*)output)[(i + start) * Stride] = v;
- else
- ((cmsFloat64Number*)output)[i + start] = v;
- }
-
- if (Extra == 0 && SwapFirst) {
-
- memmove(swap1 + 1, swap1, (nChan - 1)* sizeof(cmsFloat64Number));
- *swap1 = v;
- }
-
-
- if (T_PLANAR(info->OutputFormat))
- return output + sizeof(cmsFloat64Number);
- else
- return output + (nChan + Extra) * sizeof(cmsFloat64Number);
-
-}
-
-static
-cmsUInt8Number* PackLabFloatFromFloat(_cmsTRANSFORM* Info,
- cmsFloat32Number wOut[],
- cmsUInt8Number* output,
- cmsUInt32Number Stride)
-{
- cmsFloat32Number* Out = (cmsFloat32Number*) output;
-
- if (T_PLANAR(Info -> OutputFormat)) {
-
- Stride /= PixelSize(Info->OutputFormat);
-
- Out[0] = (cmsFloat32Number) (wOut[0] * 100.0);
- Out[Stride] = (cmsFloat32Number) (wOut[1] * 255.0 - 128.0);
- Out[Stride*2] = (cmsFloat32Number) (wOut[2] * 255.0 - 128.0);
-
- return output + sizeof(cmsFloat32Number);
- }
- else {
-
- Out[0] = (cmsFloat32Number) (wOut[0] * 100.0);
- Out[1] = (cmsFloat32Number) (wOut[1] * 255.0 - 128.0);
- Out[2] = (cmsFloat32Number) (wOut[2] * 255.0 - 128.0);
-
- return output + (sizeof(cmsFloat32Number)*3 + T_EXTRA(Info ->OutputFormat) * sizeof(cmsFloat32Number));
- }
-
-}
-
-
-static
-cmsUInt8Number* PackLabDoubleFromFloat(_cmsTRANSFORM* Info,
- cmsFloat32Number wOut[],
- cmsUInt8Number* output,
- cmsUInt32Number Stride)
-{
- cmsFloat64Number* Out = (cmsFloat64Number*) output;
-
- if (T_PLANAR(Info -> OutputFormat)) {
-
- Stride /= PixelSize(Info->OutputFormat);
-
- Out[0] = (cmsFloat64Number) (wOut[0] * 100.0);
- Out[Stride] = (cmsFloat64Number) (wOut[1] * 255.0 - 128.0);
- Out[Stride*2] = (cmsFloat64Number) (wOut[2] * 255.0 - 128.0);
-
- return output + sizeof(cmsFloat64Number);
- }
- else {
-
- Out[0] = (cmsFloat64Number) (wOut[0] * 100.0);
- Out[1] = (cmsFloat64Number) (wOut[1] * 255.0 - 128.0);
- Out[2] = (cmsFloat64Number) (wOut[2] * 255.0 - 128.0);
-
- return output + (sizeof(cmsFloat64Number)*3 + T_EXTRA(Info ->OutputFormat) * sizeof(cmsFloat64Number));
- }
-
-}
-
-
-static
-cmsUInt8Number* PackEncodedBytesLabV2FromFloat(_cmsTRANSFORM* Info,
- cmsFloat32Number wOut[],
- cmsUInt8Number* output,
- cmsUInt32Number Stride)
-{
- cmsCIELab Lab;
- cmsUInt16Number wlab[3];
-
- Lab.L = (cmsFloat64Number)(wOut[0] * 100.0);
- Lab.a = (cmsFloat64Number)(wOut[1] * 255.0 - 128.0);
- Lab.b = (cmsFloat64Number)(wOut[2] * 255.0 - 128.0);
-
- cmsFloat2LabEncoded(wlab, &Lab);
-
- if (T_PLANAR(Info -> OutputFormat)) {
-
- Stride /= PixelSize(Info->OutputFormat);
-
- output[0] = wlab[0] >> 8;
- output[Stride] = wlab[1] >> 8;
- output[Stride*2] = wlab[2] >> 8;
-
- return output + 1;
- }
- else {
-
- output[0] = wlab[0] >> 8;
- output[1] = wlab[1] >> 8;
- output[2] = wlab[2] >> 8;
-
- return output + (3 + T_EXTRA(Info ->OutputFormat));
- }
-}
-
-static
-cmsUInt8Number* PackEncodedWordsLabV2FromFloat(_cmsTRANSFORM* Info,
- cmsFloat32Number wOut[],
- cmsUInt8Number* output,
- cmsUInt32Number Stride)
-{
- cmsCIELab Lab;
- cmsUInt16Number wlab[3];
-
- Lab.L = (cmsFloat64Number)(wOut[0] * 100.0);
- Lab.a = (cmsFloat64Number)(wOut[1] * 255.0 - 128.0);
- Lab.b = (cmsFloat64Number)(wOut[2] * 255.0 - 128.0);
-
- cmsFloat2LabEncodedV2(wlab, &Lab);
-
- if (T_PLANAR(Info -> OutputFormat)) {
-
- Stride /= PixelSize(Info->OutputFormat);
-
- ((cmsUInt16Number*) output)[0] = wlab[0];
- ((cmsUInt16Number*) output)[Stride] = wlab[1];
- ((cmsUInt16Number*) output)[Stride*2] = wlab[2];
-
- return output + sizeof(cmsUInt16Number);
- }
- else {
-
- ((cmsUInt16Number*) output)[0] = wlab[0];
- ((cmsUInt16Number*) output)[1] = wlab[1];
- ((cmsUInt16Number*) output)[2] = wlab[2];
-
- return output + (3 + T_EXTRA(Info ->OutputFormat)) * sizeof(cmsUInt16Number);
- }
-}
-
-
-// From 0..1 range to 0..MAX_ENCODEABLE_XYZ
-static
-cmsUInt8Number* PackXYZFloatFromFloat(_cmsTRANSFORM* Info,
- cmsFloat32Number wOut[],
- cmsUInt8Number* output,
- cmsUInt32Number Stride)
-{
- cmsFloat32Number* Out = (cmsFloat32Number*) output;
-
- if (T_PLANAR(Info -> OutputFormat)) {
-
- Stride /= PixelSize(Info->OutputFormat);
-
- Out[0] = (cmsFloat32Number) (wOut[0] * MAX_ENCODEABLE_XYZ);
- Out[Stride] = (cmsFloat32Number) (wOut[1] * MAX_ENCODEABLE_XYZ);
- Out[Stride*2] = (cmsFloat32Number) (wOut[2] * MAX_ENCODEABLE_XYZ);
-
- return output + sizeof(cmsFloat32Number);
- }
- else {
-
- Out[0] = (cmsFloat32Number) (wOut[0] * MAX_ENCODEABLE_XYZ);
- Out[1] = (cmsFloat32Number) (wOut[1] * MAX_ENCODEABLE_XYZ);
- Out[2] = (cmsFloat32Number) (wOut[2] * MAX_ENCODEABLE_XYZ);
-
- return output + (sizeof(cmsFloat32Number)*3 + T_EXTRA(Info ->OutputFormat) * sizeof(cmsFloat32Number));
- }
-
-}
-
-// Same, but convert to double
-static
-cmsUInt8Number* PackXYZDoubleFromFloat(_cmsTRANSFORM* Info,
- cmsFloat32Number wOut[],
- cmsUInt8Number* output,
- cmsUInt32Number Stride)
-{
- cmsFloat64Number* Out = (cmsFloat64Number*) output;
-
- if (T_PLANAR(Info -> OutputFormat)) {
-
- Stride /= PixelSize(Info->OutputFormat);
-
- Out[0] = (cmsFloat64Number) (wOut[0] * MAX_ENCODEABLE_XYZ);
- Out[Stride] = (cmsFloat64Number) (wOut[1] * MAX_ENCODEABLE_XYZ);
- Out[Stride*2] = (cmsFloat64Number) (wOut[2] * MAX_ENCODEABLE_XYZ);
-
- return output + sizeof(cmsFloat64Number);
- }
- else {
-
- Out[0] = (cmsFloat64Number) (wOut[0] * MAX_ENCODEABLE_XYZ);
- Out[1] = (cmsFloat64Number) (wOut[1] * MAX_ENCODEABLE_XYZ);
- Out[2] = (cmsFloat64Number) (wOut[2] * MAX_ENCODEABLE_XYZ);
-
- return output + (sizeof(cmsFloat64Number)*3 + T_EXTRA(Info ->OutputFormat) * sizeof(cmsFloat64Number));
- }
-
-}
-
-
-// ----------------------------------------------------------------------------------------------------------------
-
-#ifndef CMS_NO_HALF_SUPPORT
-
-// Decodes an stream of half floats to wIn[] described by input format
-
-static
-cmsUInt8Number* UnrollHalfTo16(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
-
- cmsUInt32Number nChan = T_CHANNELS(info -> InputFormat);
- cmsUInt32Number DoSwap = T_DOSWAP(info ->InputFormat);
- cmsUInt32Number Reverse = T_FLAVOR(info ->InputFormat);
- cmsUInt32Number SwapFirst = T_SWAPFIRST(info -> InputFormat);
- cmsUInt32Number Extra = T_EXTRA(info -> InputFormat);
- cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
- cmsUInt32Number Planar = T_PLANAR(info -> InputFormat);
- cmsFloat32Number v;
- cmsUInt32Number i, start = 0;
- cmsFloat32Number maximum = IsInkSpace(info ->InputFormat) ? 655.35F : 65535.0F;
-
-
- Stride /= PixelSize(info->OutputFormat);
-
- if (ExtraFirst)
- start = Extra;
-
- for (i=0; i < nChan; i++) {
-
- cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
-
- if (Planar)
- v = _cmsHalf2Float ( ((cmsUInt16Number*) accum)[(i + start) * Stride] );
- else
- v = _cmsHalf2Float ( ((cmsUInt16Number*) accum)[i + start] ) ;
-
- if (Reverse) v = maximum - v;
-
- wIn[index] = _cmsQuickSaturateWord((cmsFloat64Number) v * maximum);
- }
-
-
- if (Extra == 0 && SwapFirst) {
- cmsUInt16Number tmp = wIn[0];
-
- memmove(&wIn[0], &wIn[1], (nChan-1) * sizeof(cmsUInt16Number));
- wIn[nChan-1] = tmp;
- }
-
- if (T_PLANAR(info -> InputFormat))
- return accum + sizeof(cmsUInt16Number);
- else
- return accum + (nChan + Extra) * sizeof(cmsUInt16Number);
-}
-
-// Decodes an stream of half floats to wIn[] described by input format
-
-static
-cmsUInt8Number* UnrollHalfToFloat(_cmsTRANSFORM* info,
- cmsFloat32Number wIn[],
- cmsUInt8Number* accum,
- cmsUInt32Number Stride)
-{
-
- cmsUInt32Number nChan = T_CHANNELS(info -> InputFormat);
- cmsUInt32Number DoSwap = T_DOSWAP(info ->InputFormat);
- cmsUInt32Number Reverse = T_FLAVOR(info ->InputFormat);
- cmsUInt32Number SwapFirst = T_SWAPFIRST(info -> InputFormat);
- cmsUInt32Number Extra = T_EXTRA(info -> InputFormat);
- cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
- cmsUInt32Number Planar = T_PLANAR(info -> InputFormat);
- cmsFloat32Number v;
- cmsUInt32Number i, start = 0;
- cmsFloat32Number maximum = IsInkSpace(info ->InputFormat) ? 100.0F : 1.0F;
-
- Stride /= PixelSize(info->OutputFormat);
-
- if (ExtraFirst)
- start = Extra;
-
- for (i=0; i < nChan; i++) {
-
- cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
-
- if (Planar)
- v = _cmsHalf2Float ( ((cmsUInt16Number*) accum)[(i + start) * Stride] );
- else
- v = _cmsHalf2Float ( ((cmsUInt16Number*) accum)[i + start] ) ;
-
- v /= maximum;
-
- wIn[index] = Reverse ? 1 - v : v;
- }
-
-
- if (Extra == 0 && SwapFirst) {
- cmsFloat32Number tmp = wIn[0];
-
- memmove(&wIn[0], &wIn[1], (nChan-1) * sizeof(cmsFloat32Number));
- wIn[nChan-1] = tmp;
- }
-
- if (T_PLANAR(info -> InputFormat))
- return accum + sizeof(cmsUInt16Number);
- else
- return accum + (nChan + Extra) * sizeof(cmsUInt16Number);
-}
-
-
-static
-cmsUInt8Number* PackHalfFrom16(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- cmsUInt32Number nChan = T_CHANNELS(info->OutputFormat);
- cmsUInt32Number DoSwap = T_DOSWAP(info->OutputFormat);
- cmsUInt32Number Reverse = T_FLAVOR(info->OutputFormat);
- cmsUInt32Number Extra = T_EXTRA(info->OutputFormat);
- cmsUInt32Number SwapFirst = T_SWAPFIRST(info->OutputFormat);
- cmsUInt32Number Planar = T_PLANAR(info->OutputFormat);
- cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
- cmsFloat32Number maximum = IsInkSpace(info->OutputFormat) ? 655.35F : 65535.0F;
- cmsFloat32Number v = 0;
- cmsUInt16Number* swap1 = (cmsUInt16Number*)output;
- cmsUInt32Number i, start = 0;
-
- Stride /= PixelSize(info->OutputFormat);
-
- if (ExtraFirst)
- start = Extra;
-
- for (i = 0; i < nChan; i++) {
-
- cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
-
- v = (cmsFloat32Number)wOut[index] / maximum;
-
- if (Reverse)
- v = maximum - v;
-
- if (Planar)
- ((cmsUInt16Number*)output)[(i + start) * Stride] = _cmsFloat2Half(v);
- else
- ((cmsUInt16Number*)output)[i + start] = _cmsFloat2Half(v);
- }
-
-
- if (Extra == 0 && SwapFirst) {
-
- memmove(swap1 + 1, swap1, (nChan - 1)* sizeof(cmsUInt16Number));
- *swap1 = _cmsFloat2Half(v);
- }
-
- if (T_PLANAR(info->OutputFormat))
- return output + sizeof(cmsUInt16Number);
- else
- return output + (nChan + Extra) * sizeof(cmsUInt16Number);
-}
-
-
-
-static
-cmsUInt8Number* PackHalfFromFloat(_cmsTRANSFORM* info,
- cmsFloat32Number wOut[],
- cmsUInt8Number* output,
- cmsUInt32Number Stride)
-{
- cmsUInt32Number nChan = T_CHANNELS(info->OutputFormat);
- cmsUInt32Number DoSwap = T_DOSWAP(info->OutputFormat);
- cmsUInt32Number Reverse = T_FLAVOR(info->OutputFormat);
- cmsUInt32Number Extra = T_EXTRA(info->OutputFormat);
- cmsUInt32Number SwapFirst = T_SWAPFIRST(info->OutputFormat);
- cmsUInt32Number Planar = T_PLANAR(info->OutputFormat);
- cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
- cmsFloat32Number maximum = IsInkSpace(info->OutputFormat) ? 100.0F : 1.0F;
- cmsUInt16Number* swap1 = (cmsUInt16Number*)output;
- cmsFloat32Number v = 0;
- cmsUInt32Number i, start = 0;
-
- Stride /= PixelSize(info->OutputFormat);
-
- if (ExtraFirst)
- start = Extra;
-
- for (i = 0; i < nChan; i++) {
-
- cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
-
- v = wOut[index] * maximum;
-
- if (Reverse)
- v = maximum - v;
-
- if (Planar)
- ((cmsUInt16Number*)output)[(i + start)* Stride] = _cmsFloat2Half(v);
- else
- ((cmsUInt16Number*)output)[i + start] = _cmsFloat2Half(v);
- }
-
-
- if (Extra == 0 && SwapFirst) {
-
- memmove(swap1 + 1, swap1, (nChan - 1)* sizeof(cmsUInt16Number));
- *swap1 = (cmsUInt16Number)_cmsFloat2Half(v);
- }
-
- if (T_PLANAR(info->OutputFormat))
- return output + sizeof(cmsUInt16Number);
- else
- return output + (nChan + Extra)* sizeof(cmsUInt16Number);
-}
-
-#endif
-
-// ----------------------------------------------------------------------------------------------------------------
-
-
-static const cmsFormatters16 InputFormatters16[] = {
-
- // Type Mask Function
- // ---------------------------- ------------------------------------ ----------------------------
- { TYPE_Lab_DBL, ANYPLANAR|ANYEXTRA, UnrollLabDoubleTo16},
- { TYPE_XYZ_DBL, ANYPLANAR|ANYEXTRA, UnrollXYZDoubleTo16},
- { TYPE_Lab_FLT, ANYPLANAR|ANYEXTRA, UnrollLabFloatTo16},
- { TYPE_XYZ_FLT, ANYPLANAR|ANYEXTRA, UnrollXYZFloatTo16},
- { TYPE_GRAY_DBL, 0, UnrollDouble1Chan},
- { FLOAT_SH(1)|BYTES_SH(0), ANYCHANNELS|ANYPLANAR|ANYSWAPFIRST|ANYFLAVOR|
- ANYSWAP|ANYEXTRA|ANYSPACE, UnrollDoubleTo16},
- { FLOAT_SH(1)|BYTES_SH(4), ANYCHANNELS|ANYPLANAR|ANYSWAPFIRST|ANYFLAVOR|
- ANYSWAP|ANYEXTRA|ANYSPACE, UnrollFloatTo16},
-#ifndef CMS_NO_HALF_SUPPORT
- { FLOAT_SH(1)|BYTES_SH(2), ANYCHANNELS|ANYPLANAR|ANYSWAPFIRST|ANYFLAVOR|
- ANYEXTRA|ANYSWAP|ANYSPACE, UnrollHalfTo16},
-#endif
-
- { CHANNELS_SH(1)|BYTES_SH(1), ANYSPACE, Unroll1Byte},
- { CHANNELS_SH(1)|BYTES_SH(1)|EXTRA_SH(1), ANYSPACE, Unroll1ByteSkip1},
- { CHANNELS_SH(1)|BYTES_SH(1)|EXTRA_SH(2), ANYSPACE, Unroll1ByteSkip2},
- { CHANNELS_SH(1)|BYTES_SH(1)|FLAVOR_SH(1), ANYSPACE, Unroll1ByteReversed},
- { COLORSPACE_SH(PT_MCH2)|CHANNELS_SH(2)|BYTES_SH(1), 0, Unroll2Bytes},
-
- { TYPE_LabV2_8, 0, UnrollLabV2_8 },
- { TYPE_ALabV2_8, 0, UnrollALabV2_8 },
- { TYPE_LabV2_16, 0, UnrollLabV2_16 },
-
- { CHANNELS_SH(3)|BYTES_SH(1), ANYSPACE, Unroll3Bytes},
- { CHANNELS_SH(3)|BYTES_SH(1)|DOSWAP_SH(1), ANYSPACE, Unroll3BytesSwap},
- { CHANNELS_SH(3)|EXTRA_SH(1)|BYTES_SH(1)|DOSWAP_SH(1), ANYSPACE, Unroll3BytesSkip1Swap},
- { CHANNELS_SH(3)|EXTRA_SH(1)|BYTES_SH(1)|SWAPFIRST_SH(1), ANYSPACE, Unroll3BytesSkip1SwapFirst},
-
- { CHANNELS_SH(3)|EXTRA_SH(1)|BYTES_SH(1)|DOSWAP_SH(1)|SWAPFIRST_SH(1),
- ANYSPACE, Unroll3BytesSkip1SwapSwapFirst},
-
- { CHANNELS_SH(4)|BYTES_SH(1), ANYSPACE, Unroll4Bytes},
- { CHANNELS_SH(4)|BYTES_SH(1)|FLAVOR_SH(1), ANYSPACE, Unroll4BytesReverse},
- { CHANNELS_SH(4)|BYTES_SH(1)|SWAPFIRST_SH(1), ANYSPACE, Unroll4BytesSwapFirst},
- { CHANNELS_SH(4)|BYTES_SH(1)|DOSWAP_SH(1), ANYSPACE, Unroll4BytesSwap},
- { CHANNELS_SH(4)|BYTES_SH(1)|DOSWAP_SH(1)|SWAPFIRST_SH(1), ANYSPACE, Unroll4BytesSwapSwapFirst},
-
- { BYTES_SH(1)|PLANAR_SH(1), ANYFLAVOR|ANYSWAPFIRST|ANYPREMUL|
- ANYSWAP|ANYEXTRA|ANYCHANNELS|ANYSPACE, UnrollPlanarBytes},
-
- { BYTES_SH(1), ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYPREMUL|
- ANYEXTRA|ANYCHANNELS|ANYSPACE, UnrollChunkyBytes},
-
- { CHANNELS_SH(1)|BYTES_SH(2), ANYSPACE, Unroll1Word},
- { CHANNELS_SH(1)|BYTES_SH(2)|FLAVOR_SH(1), ANYSPACE, Unroll1WordReversed},
- { CHANNELS_SH(1)|BYTES_SH(2)|EXTRA_SH(3), ANYSPACE, Unroll1WordSkip3},
-
- { CHANNELS_SH(2)|BYTES_SH(2), ANYSPACE, Unroll2Words},
- { CHANNELS_SH(3)|BYTES_SH(2), ANYSPACE, Unroll3Words},
- { CHANNELS_SH(4)|BYTES_SH(2), ANYSPACE, Unroll4Words},
-
- { CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1), ANYSPACE, Unroll3WordsSwap},
- { CHANNELS_SH(3)|BYTES_SH(2)|EXTRA_SH(1)|SWAPFIRST_SH(1), ANYSPACE, Unroll3WordsSkip1SwapFirst},
- { CHANNELS_SH(3)|BYTES_SH(2)|EXTRA_SH(1)|DOSWAP_SH(1), ANYSPACE, Unroll3WordsSkip1Swap},
- { CHANNELS_SH(4)|BYTES_SH(2)|FLAVOR_SH(1), ANYSPACE, Unroll4WordsReverse},
- { CHANNELS_SH(4)|BYTES_SH(2)|SWAPFIRST_SH(1), ANYSPACE, Unroll4WordsSwapFirst},
- { CHANNELS_SH(4)|BYTES_SH(2)|DOSWAP_SH(1), ANYSPACE, Unroll4WordsSwap},
- { CHANNELS_SH(4)|BYTES_SH(2)|DOSWAP_SH(1)|SWAPFIRST_SH(1), ANYSPACE, Unroll4WordsSwapSwapFirst},
-
-
- { BYTES_SH(2)|PLANAR_SH(1), ANYFLAVOR|ANYSWAP|ANYENDIAN|ANYEXTRA|ANYCHANNELS|ANYSPACE, UnrollPlanarWords},
- { BYTES_SH(2), ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYENDIAN|ANYEXTRA|ANYCHANNELS|ANYSPACE, UnrollAnyWords},
-
- { BYTES_SH(2)|PLANAR_SH(1), ANYFLAVOR|ANYSWAP|ANYENDIAN|ANYEXTRA|ANYCHANNELS|ANYSPACE|PREMUL_SH(1), UnrollPlanarWordsPremul},
- { BYTES_SH(2), ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYENDIAN|ANYEXTRA|ANYCHANNELS|ANYSPACE|PREMUL_SH(1), UnrollAnyWordsPremul}
-
-};
-
-
-
-static const cmsFormattersFloat InputFormattersFloat[] = {
-
- // Type Mask Function
- // ---------------------------- ------------------------------------ ----------------------------
- { TYPE_Lab_DBL, ANYPLANAR|ANYEXTRA, UnrollLabDoubleToFloat},
- { TYPE_Lab_FLT, ANYPLANAR|ANYEXTRA, UnrollLabFloatToFloat},
-
- { TYPE_XYZ_DBL, ANYPLANAR|ANYEXTRA, UnrollXYZDoubleToFloat},
- { TYPE_XYZ_FLT, ANYPLANAR|ANYEXTRA, UnrollXYZFloatToFloat},
-
- { FLOAT_SH(1)|BYTES_SH(4), ANYPLANAR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA|
- ANYPREMUL|ANYCHANNELS|ANYSPACE, UnrollFloatsToFloat},
-
- { FLOAT_SH(1)|BYTES_SH(0), ANYPLANAR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA|
- ANYCHANNELS|ANYSPACE|ANYPREMUL, UnrollDoublesToFloat},
-
- { TYPE_LabV2_8, 0, UnrollLabV2_8ToFloat },
- { TYPE_ALabV2_8, 0, UnrollALabV2_8ToFloat },
- { TYPE_LabV2_16, 0, UnrollLabV2_16ToFloat },
-
- { BYTES_SH(1), ANYPLANAR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA|
- ANYCHANNELS|ANYSPACE, Unroll8ToFloat},
-
- { BYTES_SH(2), ANYPLANAR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA|
- ANYCHANNELS|ANYSPACE, Unroll16ToFloat},
-#ifndef CMS_NO_HALF_SUPPORT
- { FLOAT_SH(1)|BYTES_SH(2), ANYPLANAR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA|
- ANYCHANNELS|ANYSPACE, UnrollHalfToFloat},
-#endif
-};
-
-
-// Bit fields set to one in the mask are not compared
-static
-cmsFormatter _cmsGetStockInputFormatter(cmsUInt32Number dwInput, cmsUInt32Number dwFlags)
-{
- cmsUInt32Number i;
- cmsFormatter fr;
-
- switch (dwFlags) {
-
- case CMS_PACK_FLAGS_16BITS: {
- for (i=0; i < sizeof(InputFormatters16) / sizeof(cmsFormatters16); i++) {
- const cmsFormatters16* f = InputFormatters16 + i;
-
- if ((dwInput & ~f ->Mask) == f ->Type) {
- fr.Fmt16 = f ->Frm;
- return fr;
- }
- }
- }
- break;
-
- case CMS_PACK_FLAGS_FLOAT: {
- for (i=0; i < sizeof(InputFormattersFloat) / sizeof(cmsFormattersFloat); i++) {
- const cmsFormattersFloat* f = InputFormattersFloat + i;
-
- if ((dwInput & ~f ->Mask) == f ->Type) {
- fr.FmtFloat = f ->Frm;
- return fr;
- }
- }
- }
- break;
-
- default:;
-
- }
-
- fr.Fmt16 = NULL;
- return fr;
-}
-
-static const cmsFormatters16 OutputFormatters16[] = {
- // Type Mask Function
- // ---------------------------- ------------------------------------ ----------------------------
-
- { TYPE_Lab_DBL, ANYPLANAR|ANYEXTRA, PackLabDoubleFrom16},
- { TYPE_XYZ_DBL, ANYPLANAR|ANYEXTRA, PackXYZDoubleFrom16},
-
- { TYPE_Lab_FLT, ANYPLANAR|ANYEXTRA, PackLabFloatFrom16},
- { TYPE_XYZ_FLT, ANYPLANAR|ANYEXTRA, PackXYZFloatFrom16},
-
- { FLOAT_SH(1)|BYTES_SH(0), ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|
- ANYCHANNELS|ANYPLANAR|ANYEXTRA|ANYSPACE, PackDoubleFrom16},
- { FLOAT_SH(1)|BYTES_SH(4), ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|
- ANYCHANNELS|ANYPLANAR|ANYEXTRA|ANYSPACE, PackFloatFrom16},
-#ifndef CMS_NO_HALF_SUPPORT
- { FLOAT_SH(1)|BYTES_SH(2), ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|
- ANYCHANNELS|ANYPLANAR|ANYEXTRA|ANYSPACE, PackHalfFrom16},
-#endif
-
- { CHANNELS_SH(1)|BYTES_SH(1), ANYSPACE, Pack1Byte},
- { CHANNELS_SH(1)|BYTES_SH(1)|EXTRA_SH(1), ANYSPACE, Pack1ByteSkip1},
- { CHANNELS_SH(1)|BYTES_SH(1)|EXTRA_SH(1)|SWAPFIRST_SH(1), ANYSPACE, Pack1ByteSkip1SwapFirst},
-
- { CHANNELS_SH(1)|BYTES_SH(1)|FLAVOR_SH(1), ANYSPACE, Pack1ByteReversed},
-
- { TYPE_LabV2_8, 0, PackLabV2_8 },
- { TYPE_ALabV2_8, 0, PackALabV2_8 },
- { TYPE_LabV2_16, 0, PackLabV2_16 },
-
- { CHANNELS_SH(3)|BYTES_SH(1)|OPTIMIZED_SH(1), ANYSPACE, Pack3BytesOptimized},
- { CHANNELS_SH(3)|BYTES_SH(1)|EXTRA_SH(1)|OPTIMIZED_SH(1), ANYSPACE, Pack3BytesAndSkip1Optimized},
- { CHANNELS_SH(3)|BYTES_SH(1)|EXTRA_SH(1)|SWAPFIRST_SH(1)|OPTIMIZED_SH(1),
- ANYSPACE, Pack3BytesAndSkip1SwapFirstOptimized},
- { CHANNELS_SH(3)|BYTES_SH(1)|EXTRA_SH(1)|DOSWAP_SH(1)|SWAPFIRST_SH(1)|OPTIMIZED_SH(1),
- ANYSPACE, Pack3BytesAndSkip1SwapSwapFirstOptimized},
- { CHANNELS_SH(3)|BYTES_SH(1)|DOSWAP_SH(1)|EXTRA_SH(1)|OPTIMIZED_SH(1),
- ANYSPACE, Pack3BytesAndSkip1SwapOptimized},
- { CHANNELS_SH(3)|BYTES_SH(1)|DOSWAP_SH(1)|OPTIMIZED_SH(1), ANYSPACE, Pack3BytesSwapOptimized},
-
-
-
- { CHANNELS_SH(3)|BYTES_SH(1), ANYSPACE, Pack3Bytes},
- { CHANNELS_SH(3)|BYTES_SH(1)|EXTRA_SH(1), ANYSPACE, Pack3BytesAndSkip1},
- { CHANNELS_SH(3)|BYTES_SH(1)|EXTRA_SH(1)|SWAPFIRST_SH(1), ANYSPACE, Pack3BytesAndSkip1SwapFirst},
- { CHANNELS_SH(3)|BYTES_SH(1)|EXTRA_SH(1)|DOSWAP_SH(1)|SWAPFIRST_SH(1),
- ANYSPACE, Pack3BytesAndSkip1SwapSwapFirst},
- { CHANNELS_SH(3)|BYTES_SH(1)|DOSWAP_SH(1)|EXTRA_SH(1), ANYSPACE, Pack3BytesAndSkip1Swap},
- { CHANNELS_SH(3)|BYTES_SH(1)|DOSWAP_SH(1), ANYSPACE, Pack3BytesSwap},
- { CHANNELS_SH(4)|BYTES_SH(1), ANYSPACE, Pack4Bytes},
- { CHANNELS_SH(4)|BYTES_SH(1)|FLAVOR_SH(1), ANYSPACE, Pack4BytesReverse},
- { CHANNELS_SH(4)|BYTES_SH(1)|SWAPFIRST_SH(1), ANYSPACE, Pack4BytesSwapFirst},
- { CHANNELS_SH(4)|BYTES_SH(1)|DOSWAP_SH(1), ANYSPACE, Pack4BytesSwap},
- { CHANNELS_SH(4)|BYTES_SH(1)|DOSWAP_SH(1)|SWAPFIRST_SH(1), ANYSPACE, Pack4BytesSwapSwapFirst},
- { CHANNELS_SH(6)|BYTES_SH(1), ANYSPACE, Pack6Bytes},
- { CHANNELS_SH(6)|BYTES_SH(1)|DOSWAP_SH(1), ANYSPACE, Pack6BytesSwap},
-
- { BYTES_SH(1), ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA|ANYCHANNELS|
- ANYSPACE|ANYPREMUL, PackChunkyBytes},
-
- { BYTES_SH(1)|PLANAR_SH(1), ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA|
- ANYCHANNELS|ANYSPACE|ANYPREMUL, PackPlanarBytes},
-
-
- { CHANNELS_SH(1)|BYTES_SH(2), ANYSPACE, Pack1Word},
- { CHANNELS_SH(1)|BYTES_SH(2)|EXTRA_SH(1), ANYSPACE, Pack1WordSkip1},
- { CHANNELS_SH(1)|BYTES_SH(2)|EXTRA_SH(1)|SWAPFIRST_SH(1), ANYSPACE, Pack1WordSkip1SwapFirst},
- { CHANNELS_SH(1)|BYTES_SH(2)|FLAVOR_SH(1), ANYSPACE, Pack1WordReversed},
- { CHANNELS_SH(1)|BYTES_SH(2)|ENDIAN16_SH(1), ANYSPACE, Pack1WordBigEndian},
- { CHANNELS_SH(3)|BYTES_SH(2), ANYSPACE, Pack3Words},
- { CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1), ANYSPACE, Pack3WordsSwap},
- { CHANNELS_SH(3)|BYTES_SH(2)|ENDIAN16_SH(1), ANYSPACE, Pack3WordsBigEndian},
- { CHANNELS_SH(3)|BYTES_SH(2)|EXTRA_SH(1), ANYSPACE, Pack3WordsAndSkip1},
- { CHANNELS_SH(3)|BYTES_SH(2)|EXTRA_SH(1)|DOSWAP_SH(1), ANYSPACE, Pack3WordsAndSkip1Swap},
- { CHANNELS_SH(3)|BYTES_SH(2)|EXTRA_SH(1)|SWAPFIRST_SH(1), ANYSPACE, Pack3WordsAndSkip1SwapFirst},
-
- { CHANNELS_SH(3)|BYTES_SH(2)|EXTRA_SH(1)|DOSWAP_SH(1)|SWAPFIRST_SH(1),
- ANYSPACE, Pack3WordsAndSkip1SwapSwapFirst},
-
- { CHANNELS_SH(4)|BYTES_SH(2), ANYSPACE, Pack4Words},
- { CHANNELS_SH(4)|BYTES_SH(2)|FLAVOR_SH(1), ANYSPACE, Pack4WordsReverse},
- { CHANNELS_SH(4)|BYTES_SH(2)|DOSWAP_SH(1), ANYSPACE, Pack4WordsSwap},
- { CHANNELS_SH(4)|BYTES_SH(2)|ENDIAN16_SH(1), ANYSPACE, Pack4WordsBigEndian},
-
- { CHANNELS_SH(6)|BYTES_SH(2), ANYSPACE, Pack6Words},
- { CHANNELS_SH(6)|BYTES_SH(2)|DOSWAP_SH(1), ANYSPACE, Pack6WordsSwap},
-
- { BYTES_SH(2), ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYENDIAN|
- ANYEXTRA|ANYCHANNELS|ANYSPACE|ANYPREMUL, PackChunkyWords},
- { BYTES_SH(2)|PLANAR_SH(1), ANYFLAVOR|ANYENDIAN|ANYSWAP|ANYEXTRA|
- ANYCHANNELS|ANYSPACE|ANYPREMUL, PackPlanarWords}
-
-};
-
-
-static const cmsFormattersFloat OutputFormattersFloat[] = {
- // Type Mask Function
- // ---------------------------- --------------------------------------------------- ----------------------------
- { TYPE_Lab_FLT, ANYPLANAR|ANYEXTRA, PackLabFloatFromFloat},
- { TYPE_XYZ_FLT, ANYPLANAR|ANYEXTRA, PackXYZFloatFromFloat},
-
- { TYPE_Lab_DBL, ANYPLANAR|ANYEXTRA, PackLabDoubleFromFloat},
- { TYPE_XYZ_DBL, ANYPLANAR|ANYEXTRA, PackXYZDoubleFromFloat},
-
- { TYPE_LabV2_8, ANYPLANAR|ANYEXTRA, PackEncodedBytesLabV2FromFloat},
- { TYPE_LabV2_16, ANYPLANAR|ANYEXTRA, PackEncodedWordsLabV2FromFloat},
-
- { FLOAT_SH(1)|BYTES_SH(4), ANYPLANAR|
- ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA|ANYCHANNELS|ANYSPACE, PackFloatsFromFloat },
- { FLOAT_SH(1)|BYTES_SH(0), ANYPLANAR|
- ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA|ANYCHANNELS|ANYSPACE, PackDoublesFromFloat },
-
- { BYTES_SH(2), ANYPLANAR|
- ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA|ANYCHANNELS|ANYSPACE, PackWordsFromFloat },
-
- { BYTES_SH(1), ANYPLANAR|
- ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA|ANYCHANNELS|ANYSPACE, PackBytesFromFloat },
-
-#ifndef CMS_NO_HALF_SUPPORT
- { FLOAT_SH(1)|BYTES_SH(2),
- ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA|ANYCHANNELS|ANYSPACE, PackHalfFromFloat },
-#endif
-
-};
-
-
-// Bit fields set to one in the mask are not compared
-static
-cmsFormatter _cmsGetStockOutputFormatter(cmsUInt32Number dwInput, cmsUInt32Number dwFlags)
-{
- cmsUInt32Number i;
- cmsFormatter fr;
-
- // Optimization is only a hint
- dwInput &= ~OPTIMIZED_SH(1);
-
- switch (dwFlags)
- {
-
- case CMS_PACK_FLAGS_16BITS: {
-
- for (i=0; i < sizeof(OutputFormatters16) / sizeof(cmsFormatters16); i++) {
- const cmsFormatters16* f = OutputFormatters16 + i;
-
- if ((dwInput & ~f ->Mask) == f ->Type) {
- fr.Fmt16 = f ->Frm;
- return fr;
- }
- }
- }
- break;
-
- case CMS_PACK_FLAGS_FLOAT: {
-
- for (i=0; i < sizeof(OutputFormattersFloat) / sizeof(cmsFormattersFloat); i++) {
- const cmsFormattersFloat* f = OutputFormattersFloat + i;
-
- if ((dwInput & ~f ->Mask) == f ->Type) {
- fr.FmtFloat = f ->Frm;
- return fr;
- }
- }
- }
- break;
-
- default:;
-
- }
-
- fr.Fmt16 = NULL;
- return fr;
-}
-
-
-typedef struct _cms_formatters_factory_list {
-
- cmsFormatterFactory Factory;
- struct _cms_formatters_factory_list *Next;
-
-} cmsFormattersFactoryList;
-
-_cmsFormattersPluginChunkType _cmsFormattersPluginChunk = { NULL };
-
-
-// Duplicates the zone of memory used by the plug-in in the new context
-static
-void DupFormatterFactoryList(struct _cmsContext_struct* ctx,
- const struct _cmsContext_struct* src)
-{
- _cmsFormattersPluginChunkType newHead = { NULL };
- cmsFormattersFactoryList* entry;
- cmsFormattersFactoryList* Anterior = NULL;
- _cmsFormattersPluginChunkType* head = (_cmsFormattersPluginChunkType*) src->chunks[FormattersPlugin];
-
- _cmsAssert(head != NULL);
-
- // Walk the list copying all nodes
- for (entry = head->FactoryList;
- entry != NULL;
- entry = entry ->Next) {
-
- cmsFormattersFactoryList *newEntry = ( cmsFormattersFactoryList *) _cmsSubAllocDup(ctx ->MemPool, entry, sizeof(cmsFormattersFactoryList));
-
- if (newEntry == NULL)
- return;
-
- // We want to keep the linked list order, so this is a little bit tricky
- newEntry -> Next = NULL;
- if (Anterior)
- Anterior -> Next = newEntry;
-
- Anterior = newEntry;
-
- if (newHead.FactoryList == NULL)
- newHead.FactoryList = newEntry;
- }
-
- ctx ->chunks[FormattersPlugin] = _cmsSubAllocDup(ctx->MemPool, &newHead, sizeof(_cmsFormattersPluginChunkType));
-}
-
-// The interpolation plug-in memory chunk allocator/dup
-void _cmsAllocFormattersPluginChunk(struct _cmsContext_struct* ctx,
- const struct _cmsContext_struct* src)
-{
- _cmsAssert(ctx != NULL);
-
- if (src != NULL) {
-
- // Duplicate the LIST
- DupFormatterFactoryList(ctx, src);
- }
- else {
- static _cmsFormattersPluginChunkType FormattersPluginChunk = { NULL };
- ctx ->chunks[FormattersPlugin] = _cmsSubAllocDup(ctx ->MemPool, &FormattersPluginChunk, sizeof(_cmsFormattersPluginChunkType));
- }
-}
-
-
-
-// Formatters management
-cmsBool _cmsRegisterFormattersPlugin(cmsContext ContextID, cmsPluginBase* Data)
-{
- _cmsFormattersPluginChunkType* ctx = ( _cmsFormattersPluginChunkType*) _cmsContextGetClientChunk(ContextID, FormattersPlugin);
- cmsPluginFormatters* Plugin = (cmsPluginFormatters*) Data;
- cmsFormattersFactoryList* fl ;
-
- // Reset to built-in defaults
- if (Data == NULL) {
-
- ctx ->FactoryList = NULL;
- return TRUE;
- }
-
- fl = (cmsFormattersFactoryList*) _cmsPluginMalloc(ContextID, sizeof(cmsFormattersFactoryList));
- if (fl == NULL) return FALSE;
-
- fl ->Factory = Plugin ->FormattersFactory;
-
- fl ->Next = ctx -> FactoryList;
- ctx ->FactoryList = fl;
-
- return TRUE;
-}
-
-cmsFormatter CMSEXPORT _cmsGetFormatter(cmsContext ContextID,
- cmsUInt32Number Type, // Specific type, i.e. TYPE_RGB_8
- cmsFormatterDirection Dir,
- cmsUInt32Number dwFlags)
-{
- _cmsFormattersPluginChunkType* ctx = ( _cmsFormattersPluginChunkType*) _cmsContextGetClientChunk(ContextID, FormattersPlugin);
- cmsFormattersFactoryList* f;
-
- if (T_CHANNELS(Type) == 0) {
- static const cmsFormatter nullFormatter = { 0 };
- return nullFormatter;
- }
-
- for (f =ctx->FactoryList; f != NULL; f = f ->Next) {
-
- cmsFormatter fn = f ->Factory(Type, Dir, dwFlags);
- if (fn.Fmt16 != NULL) return fn;
- }
-
- // Revert to default
- if (Dir == cmsFormatterInput)
- return _cmsGetStockInputFormatter(Type, dwFlags);
- else
- return _cmsGetStockOutputFormatter(Type, dwFlags);
-}
-
-
-// Return whatever given formatter refers to float values
-cmsBool _cmsFormatterIsFloat(cmsUInt32Number Type)
-{
- return T_FLOAT(Type) ? TRUE : FALSE;
-}
-
-// Return whatever given formatter refers to 8 bits
-cmsBool _cmsFormatterIs8bit(cmsUInt32Number Type)
-{
- cmsUInt32Number Bytes = T_BYTES(Type);
-
- return (Bytes == 1);
-}
-
-// Build a suitable formatter for the colorspace of this profile
-cmsUInt32Number CMSEXPORT cmsFormatterForColorspaceOfProfile(cmsHPROFILE hProfile, cmsUInt32Number nBytes, cmsBool lIsFloat)
-{
-
- cmsColorSpaceSignature ColorSpace = cmsGetColorSpace(hProfile);
- cmsUInt32Number ColorSpaceBits = (cmsUInt32Number) _cmsLCMScolorSpace(ColorSpace);
- cmsInt32Number nOutputChans = cmsChannelsOfColorSpace(ColorSpace);
- cmsUInt32Number Float = lIsFloat ? 1U : 0;
-
- // Unsupported color space?
- if (nOutputChans < 0) return 0;
-
- // Create a fake formatter for result
- return FLOAT_SH(Float) | COLORSPACE_SH(ColorSpaceBits) | BYTES_SH(nBytes) | CHANNELS_SH(nOutputChans);
-}
-
-// Build a suitable formatter for the colorspace of this profile
-cmsUInt32Number CMSEXPORT cmsFormatterForPCSOfProfile(cmsHPROFILE hProfile, cmsUInt32Number nBytes, cmsBool lIsFloat)
-{
-
- cmsColorSpaceSignature ColorSpace = cmsGetPCS(hProfile);
-
- cmsUInt32Number ColorSpaceBits = (cmsUInt32Number) _cmsLCMScolorSpace(ColorSpace);
- cmsInt32Number nOutputChans = cmsChannelsOfColorSpace(ColorSpace);
- cmsUInt32Number Float = lIsFloat ? 1U : 0;
-
- // Unsupported color space?
- if (nOutputChans < 0) return 0;
-
- // Create a fake formatter for result
- return FLOAT_SH(Float) | COLORSPACE_SH(ColorSpaceBits) | BYTES_SH(nBytes) | CHANNELS_SH(nOutputChans);
-}
-
diff --git a/contrib/libs/lcms2/src/cmspcs.c b/contrib/libs/lcms2/src/cmspcs.c
deleted file mode 100644
index e11f87c23a..0000000000
--- a/contrib/libs/lcms2/src/cmspcs.c
+++ /dev/null
@@ -1,950 +0,0 @@
-//---------------------------------------------------------------------------------
-//
-// Little Color Management System
-// Copyright (c) 1998-2023 Marti Maria Saguer
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//---------------------------------------------------------------------------------
-//
-
-#include "lcms2_internal.h"
-
-// inter PCS conversions XYZ <-> CIE L* a* b*
-/*
-
-
- CIE 15:2004 CIELab is defined as:
-
- L* = 116*f(Y/Yn) - 16 0 <= L* <= 100
- a* = 500*[f(X/Xn) - f(Y/Yn)]
- b* = 200*[f(Y/Yn) - f(Z/Zn)]
-
- and
-
- f(t) = t^(1/3) 1 >= t > (24/116)^3
- (841/108)*t + (16/116) 0 <= t <= (24/116)^3
-
-
- Reverse transform is:
-
- X = Xn*[a* / 500 + (L* + 16) / 116] ^ 3 if (X/Xn) > (24/116)
- = Xn*(a* / 500 + L* / 116) / 7.787 if (X/Xn) <= (24/116)
-
-
-
- PCS in Lab2 is encoded as:
-
- 8 bit Lab PCS:
-
- L* 0..100 into a 0..ff byte.
- a* t + 128 range is -128.0 +127.0
- b*
-
- 16 bit Lab PCS:
-
- L* 0..100 into a 0..ff00 word.
- a* t + 128 range is -128.0 +127.9961
- b*
-
-
-
-Interchange Space Component Actual Range Encoded Range
-CIE XYZ X 0 -> 1.99997 0x0000 -> 0xffff
-CIE XYZ Y 0 -> 1.99997 0x0000 -> 0xffff
-CIE XYZ Z 0 -> 1.99997 0x0000 -> 0xffff
-
-Version 2,3
------------
-
-CIELAB (16 bit) L* 0 -> 100.0 0x0000 -> 0xff00
-CIELAB (16 bit) a* -128.0 -> +127.996 0x0000 -> 0x8000 -> 0xffff
-CIELAB (16 bit) b* -128.0 -> +127.996 0x0000 -> 0x8000 -> 0xffff
-
-
-Version 4
----------
-
-CIELAB (16 bit) L* 0 -> 100.0 0x0000 -> 0xffff
-CIELAB (16 bit) a* -128.0 -> +127 0x0000 -> 0x8080 -> 0xffff
-CIELAB (16 bit) b* -128.0 -> +127 0x0000 -> 0x8080 -> 0xffff
-
-*/
-
-// Conversions
-void CMSEXPORT cmsXYZ2xyY(cmsCIExyY* Dest, const cmsCIEXYZ* Source)
-{
- cmsFloat64Number ISum;
-
- ISum = 1./(Source -> X + Source -> Y + Source -> Z);
-
- Dest -> x = (Source -> X) * ISum;
- Dest -> y = (Source -> Y) * ISum;
- Dest -> Y = Source -> Y;
-}
-
-void CMSEXPORT cmsxyY2XYZ(cmsCIEXYZ* Dest, const cmsCIExyY* Source)
-{
- Dest -> X = (Source -> x / Source -> y) * Source -> Y;
- Dest -> Y = Source -> Y;
- Dest -> Z = ((1 - Source -> x - Source -> y) / Source -> y) * Source -> Y;
-}
-
-/*
- The break point (24/116)^3 = (6/29)^3 is a very small amount of tristimulus
- primary (0.008856). Generally, this only happens for
- nearly ideal blacks and for some orange / amber colors in transmission mode.
- For example, the Z value of the orange turn indicator lamp lens on an
- automobile will often be below this value. But the Z does not
- contribute to the perceived color directly.
-*/
-
-static
-cmsFloat64Number f(cmsFloat64Number t)
-{
- const cmsFloat64Number Limit = (24.0/116.0) * (24.0/116.0) * (24.0/116.0);
-
- if (t <= Limit)
- return (841.0/108.0) * t + (16.0/116.0);
- else
- return pow(t, 1.0/3.0);
-}
-
-static
-cmsFloat64Number f_1(cmsFloat64Number t)
-{
- const cmsFloat64Number Limit = (24.0/116.0);
-
- if (t <= Limit) {
- return (108.0/841.0) * (t - (16.0/116.0));
- }
-
- return t * t * t;
-}
-
-
-// Standard XYZ to Lab. it can handle negative XZY numbers in some cases
-void CMSEXPORT cmsXYZ2Lab(const cmsCIEXYZ* WhitePoint, cmsCIELab* Lab, const cmsCIEXYZ* xyz)
-{
- cmsFloat64Number fx, fy, fz;
-
- if (WhitePoint == NULL)
- WhitePoint = cmsD50_XYZ();
-
- fx = f(xyz->X / WhitePoint->X);
- fy = f(xyz->Y / WhitePoint->Y);
- fz = f(xyz->Z / WhitePoint->Z);
-
- Lab->L = 116.0*fy - 16.0;
- Lab->a = 500.0*(fx - fy);
- Lab->b = 200.0*(fy - fz);
-}
-
-
-// Standard XYZ to Lab. It can return negative XYZ in some cases
-void CMSEXPORT cmsLab2XYZ(const cmsCIEXYZ* WhitePoint, cmsCIEXYZ* xyz, const cmsCIELab* Lab)
-{
- cmsFloat64Number x, y, z;
-
- if (WhitePoint == NULL)
- WhitePoint = cmsD50_XYZ();
-
- y = (Lab-> L + 16.0) / 116.0;
- x = y + 0.002 * Lab -> a;
- z = y - 0.005 * Lab -> b;
-
- xyz -> X = f_1(x) * WhitePoint -> X;
- xyz -> Y = f_1(y) * WhitePoint -> Y;
- xyz -> Z = f_1(z) * WhitePoint -> Z;
-
-}
-
-static
-cmsFloat64Number L2float2(cmsUInt16Number v)
-{
- return (cmsFloat64Number) v / 652.800;
-}
-
-// the a/b part
-static
-cmsFloat64Number ab2float2(cmsUInt16Number v)
-{
- return ((cmsFloat64Number) v / 256.0) - 128.0;
-}
-
-static
-cmsUInt16Number L2Fix2(cmsFloat64Number L)
-{
- return _cmsQuickSaturateWord(L * 652.8);
-}
-
-static
-cmsUInt16Number ab2Fix2(cmsFloat64Number ab)
-{
- return _cmsQuickSaturateWord((ab + 128.0) * 256.0);
-}
-
-
-static
-cmsFloat64Number L2float4(cmsUInt16Number v)
-{
- return (cmsFloat64Number) v / 655.35;
-}
-
-// the a/b part
-static
-cmsFloat64Number ab2float4(cmsUInt16Number v)
-{
- return ((cmsFloat64Number) v / 257.0) - 128.0;
-}
-
-
-void CMSEXPORT cmsLabEncoded2FloatV2(cmsCIELab* Lab, const cmsUInt16Number wLab[3])
-{
- Lab->L = L2float2(wLab[0]);
- Lab->a = ab2float2(wLab[1]);
- Lab->b = ab2float2(wLab[2]);
-}
-
-
-void CMSEXPORT cmsLabEncoded2Float(cmsCIELab* Lab, const cmsUInt16Number wLab[3])
-{
- Lab->L = L2float4(wLab[0]);
- Lab->a = ab2float4(wLab[1]);
- Lab->b = ab2float4(wLab[2]);
-}
-
-static
-cmsFloat64Number Clamp_L_doubleV2(cmsFloat64Number L)
-{
- const cmsFloat64Number L_max = (cmsFloat64Number) (0xFFFF * 100.0) / 0xFF00;
-
- if (L < 0) L = 0;
- if (L > L_max) L = L_max;
-
- return L;
-}
-
-
-static
-cmsFloat64Number Clamp_ab_doubleV2(cmsFloat64Number ab)
-{
- if (ab < MIN_ENCODEABLE_ab2) ab = MIN_ENCODEABLE_ab2;
- if (ab > MAX_ENCODEABLE_ab2) ab = MAX_ENCODEABLE_ab2;
-
- return ab;
-}
-
-void CMSEXPORT cmsFloat2LabEncodedV2(cmsUInt16Number wLab[3], const cmsCIELab* fLab)
-{
- cmsCIELab Lab;
-
- Lab.L = Clamp_L_doubleV2(fLab ->L);
- Lab.a = Clamp_ab_doubleV2(fLab ->a);
- Lab.b = Clamp_ab_doubleV2(fLab ->b);
-
- wLab[0] = L2Fix2(Lab.L);
- wLab[1] = ab2Fix2(Lab.a);
- wLab[2] = ab2Fix2(Lab.b);
-}
-
-
-static
-cmsFloat64Number Clamp_L_doubleV4(cmsFloat64Number L)
-{
- if (L < 0) L = 0;
- if (L > 100.0) L = 100.0;
-
- return L;
-}
-
-static
-cmsFloat64Number Clamp_ab_doubleV4(cmsFloat64Number ab)
-{
- if (ab < MIN_ENCODEABLE_ab4) ab = MIN_ENCODEABLE_ab4;
- if (ab > MAX_ENCODEABLE_ab4) ab = MAX_ENCODEABLE_ab4;
-
- return ab;
-}
-
-static
-cmsUInt16Number L2Fix4(cmsFloat64Number L)
-{
- return _cmsQuickSaturateWord(L * 655.35);
-}
-
-static
-cmsUInt16Number ab2Fix4(cmsFloat64Number ab)
-{
- return _cmsQuickSaturateWord((ab + 128.0) * 257.0);
-}
-
-void CMSEXPORT cmsFloat2LabEncoded(cmsUInt16Number wLab[3], const cmsCIELab* fLab)
-{
- cmsCIELab Lab;
-
- Lab.L = Clamp_L_doubleV4(fLab ->L);
- Lab.a = Clamp_ab_doubleV4(fLab ->a);
- Lab.b = Clamp_ab_doubleV4(fLab ->b);
-
- wLab[0] = L2Fix4(Lab.L);
- wLab[1] = ab2Fix4(Lab.a);
- wLab[2] = ab2Fix4(Lab.b);
-}
-
-// Auxiliary: convert to Radians
-static
-cmsFloat64Number RADIANS(cmsFloat64Number deg)
-{
- return (deg * M_PI) / 180.;
-}
-
-
-// Auxiliary: atan2 but operating in degrees and returning 0 if a==b==0
-static
-cmsFloat64Number atan2deg(cmsFloat64Number a, cmsFloat64Number b)
-{
- cmsFloat64Number h;
-
- if (a == 0 && b == 0)
- h = 0;
- else
- h = atan2(a, b);
-
- h *= (180. / M_PI);
-
- while (h > 360.)
- h -= 360.;
-
- while ( h < 0)
- h += 360.;
-
- return h;
-}
-
-
-// Auxiliary: Square
-static
-cmsFloat64Number Sqr(cmsFloat64Number v)
-{
- return v * v;
-}
-// From cylindrical coordinates. No check is performed, then negative values are allowed
-void CMSEXPORT cmsLab2LCh(cmsCIELCh* LCh, const cmsCIELab* Lab)
-{
- LCh -> L = Lab -> L;
- LCh -> C = pow(Sqr(Lab ->a) + Sqr(Lab ->b), 0.5);
- LCh -> h = atan2deg(Lab ->b, Lab ->a);
-}
-
-
-// To cylindrical coordinates. No check is performed, then negative values are allowed
-void CMSEXPORT cmsLCh2Lab(cmsCIELab* Lab, const cmsCIELCh* LCh)
-{
- cmsFloat64Number h = (LCh -> h * M_PI) / 180.0;
-
- Lab -> L = LCh -> L;
- Lab -> a = LCh -> C * cos(h);
- Lab -> b = LCh -> C * sin(h);
-}
-
-// In XYZ All 3 components are encoded using 1.15 fixed point
-static
-cmsUInt16Number XYZ2Fix(cmsFloat64Number d)
-{
- return _cmsQuickSaturateWord(d * 32768.0);
-}
-
-void CMSEXPORT cmsFloat2XYZEncoded(cmsUInt16Number XYZ[3], const cmsCIEXYZ* fXYZ)
-{
- cmsCIEXYZ xyz;
-
- xyz.X = fXYZ -> X;
- xyz.Y = fXYZ -> Y;
- xyz.Z = fXYZ -> Z;
-
- // Clamp to encodeable values.
- if (xyz.Y <= 0) {
-
- xyz.X = 0;
- xyz.Y = 0;
- xyz.Z = 0;
- }
-
- if (xyz.X > MAX_ENCODEABLE_XYZ)
- xyz.X = MAX_ENCODEABLE_XYZ;
-
- if (xyz.X < 0)
- xyz.X = 0;
-
- if (xyz.Y > MAX_ENCODEABLE_XYZ)
- xyz.Y = MAX_ENCODEABLE_XYZ;
-
- if (xyz.Y < 0)
- xyz.Y = 0;
-
- if (xyz.Z > MAX_ENCODEABLE_XYZ)
- xyz.Z = MAX_ENCODEABLE_XYZ;
-
- if (xyz.Z < 0)
- xyz.Z = 0;
-
-
- XYZ[0] = XYZ2Fix(xyz.X);
- XYZ[1] = XYZ2Fix(xyz.Y);
- XYZ[2] = XYZ2Fix(xyz.Z);
-}
-
-
-// To convert from Fixed 1.15 point to cmsFloat64Number
-static
-cmsFloat64Number XYZ2float(cmsUInt16Number v)
-{
- cmsS15Fixed16Number fix32;
-
- // From 1.15 to 15.16
- fix32 = v << 1;
-
- // From fixed 15.16 to cmsFloat64Number
- return _cms15Fixed16toDouble(fix32);
-}
-
-
-void CMSEXPORT cmsXYZEncoded2Float(cmsCIEXYZ* fXYZ, const cmsUInt16Number XYZ[3])
-{
- fXYZ -> X = XYZ2float(XYZ[0]);
- fXYZ -> Y = XYZ2float(XYZ[1]);
- fXYZ -> Z = XYZ2float(XYZ[2]);
-}
-
-
-// Returns dE on two Lab values
-cmsFloat64Number CMSEXPORT cmsDeltaE(const cmsCIELab* Lab1, const cmsCIELab* Lab2)
-{
- cmsFloat64Number dL, da, db;
-
- dL = fabs(Lab1 -> L - Lab2 -> L);
- da = fabs(Lab1 -> a - Lab2 -> a);
- db = fabs(Lab1 -> b - Lab2 -> b);
-
- return pow(Sqr(dL) + Sqr(da) + Sqr(db), 0.5);
-}
-
-
-// Return the CIE94 Delta E
-cmsFloat64Number CMSEXPORT cmsCIE94DeltaE(const cmsCIELab* Lab1, const cmsCIELab* Lab2)
-{
- cmsCIELCh LCh1, LCh2;
- cmsFloat64Number dE, dL, dC, dh, dhsq;
- cmsFloat64Number c12, sc, sh;
-
- dL = fabs(Lab1 ->L - Lab2 ->L);
-
- cmsLab2LCh(&LCh1, Lab1);
- cmsLab2LCh(&LCh2, Lab2);
-
- dC = fabs(LCh1.C - LCh2.C);
- dE = cmsDeltaE(Lab1, Lab2);
-
- dhsq = Sqr(dE) - Sqr(dL) - Sqr(dC);
- if (dhsq < 0)
- dh = 0;
- else
- dh = pow(dhsq, 0.5);
-
- c12 = sqrt(LCh1.C * LCh2.C);
-
- sc = 1.0 + (0.048 * c12);
- sh = 1.0 + (0.014 * c12);
-
- return sqrt(Sqr(dL) + Sqr(dC) / Sqr(sc) + Sqr(dh) / Sqr(sh));
-}
-
-
-// Auxiliary
-static
-cmsFloat64Number ComputeLBFD(const cmsCIELab* Lab)
-{
- cmsFloat64Number yt;
-
- if (Lab->L > 7.996969)
- yt = (Sqr((Lab->L+16)/116)*((Lab->L+16)/116))*100;
- else
- yt = 100 * (Lab->L / 903.3);
-
- return (54.6 * (M_LOG10E * (log(yt + 1.5))) - 9.6);
-}
-
-
-
-// bfd - gets BFD(1:1) difference between Lab1, Lab2
-cmsFloat64Number CMSEXPORT cmsBFDdeltaE(const cmsCIELab* Lab1, const cmsCIELab* Lab2)
-{
- cmsFloat64Number lbfd1,lbfd2,AveC,Aveh,dE,deltaL,
- deltaC,deltah,dc,t,g,dh,rh,rc,rt,bfd;
- cmsCIELCh LCh1, LCh2;
-
-
- lbfd1 = ComputeLBFD(Lab1);
- lbfd2 = ComputeLBFD(Lab2);
- deltaL = lbfd2 - lbfd1;
-
- cmsLab2LCh(&LCh1, Lab1);
- cmsLab2LCh(&LCh2, Lab2);
-
- deltaC = LCh2.C - LCh1.C;
- AveC = (LCh1.C+LCh2.C)/2;
- Aveh = (LCh1.h+LCh2.h)/2;
-
- dE = cmsDeltaE(Lab1, Lab2);
-
- if (Sqr(dE)>(Sqr(Lab2->L-Lab1->L)+Sqr(deltaC)))
- deltah = sqrt(Sqr(dE)-Sqr(Lab2->L-Lab1->L)-Sqr(deltaC));
- else
- deltah =0;
-
-
- dc = 0.035 * AveC / (1 + 0.00365 * AveC)+0.521;
- g = sqrt(Sqr(Sqr(AveC))/(Sqr(Sqr(AveC))+14000));
- t = 0.627+(0.055*cos((Aveh-254)/(180/M_PI))-
- 0.040*cos((2*Aveh-136)/(180/M_PI))+
- 0.070*cos((3*Aveh-31)/(180/M_PI))+
- 0.049*cos((4*Aveh+114)/(180/M_PI))-
- 0.015*cos((5*Aveh-103)/(180/M_PI)));
-
- dh = dc*(g*t+1-g);
- rh = -0.260*cos((Aveh-308)/(180/M_PI))-
- 0.379*cos((2*Aveh-160)/(180/M_PI))-
- 0.636*cos((3*Aveh+254)/(180/M_PI))+
- 0.226*cos((4*Aveh+140)/(180/M_PI))-
- 0.194*cos((5*Aveh+280)/(180/M_PI));
-
- rc = sqrt((AveC*AveC*AveC*AveC*AveC*AveC)/((AveC*AveC*AveC*AveC*AveC*AveC)+70000000));
- rt = rh*rc;
-
- bfd = sqrt(Sqr(deltaL)+Sqr(deltaC/dc)+Sqr(deltah/dh)+(rt*(deltaC/dc)*(deltah/dh)));
-
- return bfd;
-}
-
-
-// cmc - CMC(l:c) difference between Lab1, Lab2
-cmsFloat64Number CMSEXPORT cmsCMCdeltaE(const cmsCIELab* Lab1, const cmsCIELab* Lab2, cmsFloat64Number l, cmsFloat64Number c)
-{
- cmsFloat64Number dE,dL,dC,dh,sl,sc,sh,t,f,cmc;
- cmsCIELCh LCh1, LCh2;
-
- if (Lab1 ->L == 0 && Lab2 ->L == 0) return 0;
-
- cmsLab2LCh(&LCh1, Lab1);
- cmsLab2LCh(&LCh2, Lab2);
-
-
- dL = Lab2->L-Lab1->L;
- dC = LCh2.C-LCh1.C;
-
- dE = cmsDeltaE(Lab1, Lab2);
-
- if (Sqr(dE)>(Sqr(dL)+Sqr(dC)))
- dh = sqrt(Sqr(dE)-Sqr(dL)-Sqr(dC));
- else
- dh =0;
-
- if ((LCh1.h > 164) && (LCh1.h < 345))
- t = 0.56 + fabs(0.2 * cos(((LCh1.h + 168)/(180/M_PI))));
- else
- t = 0.36 + fabs(0.4 * cos(((LCh1.h + 35 )/(180/M_PI))));
-
- sc = 0.0638 * LCh1.C / (1 + 0.0131 * LCh1.C) + 0.638;
- sl = 0.040975 * Lab1->L /(1 + 0.01765 * Lab1->L);
-
- if (Lab1->L<16)
- sl = 0.511;
-
- f = sqrt((LCh1.C * LCh1.C * LCh1.C * LCh1.C)/((LCh1.C * LCh1.C * LCh1.C * LCh1.C)+1900));
- sh = sc*(t*f+1-f);
- cmc = sqrt(Sqr(dL/(l*sl))+Sqr(dC/(c*sc))+Sqr(dh/sh));
-
- return cmc;
-}
-
-// dE2000 The weightings KL, KC and KH can be modified to reflect the relative
-// importance of lightness, chroma and hue in different industrial applications
-cmsFloat64Number CMSEXPORT cmsCIE2000DeltaE(const cmsCIELab* Lab1, const cmsCIELab* Lab2,
- cmsFloat64Number Kl, cmsFloat64Number Kc, cmsFloat64Number Kh)
-{
- cmsFloat64Number L1 = Lab1->L;
- cmsFloat64Number a1 = Lab1->a;
- cmsFloat64Number b1 = Lab1->b;
- cmsFloat64Number C = sqrt( Sqr(a1) + Sqr(b1) );
-
- cmsFloat64Number Ls = Lab2 ->L;
- cmsFloat64Number as = Lab2 ->a;
- cmsFloat64Number bs = Lab2 ->b;
- cmsFloat64Number Cs = sqrt( Sqr(as) + Sqr(bs) );
-
- cmsFloat64Number G = 0.5 * ( 1 - sqrt(pow((C + Cs) / 2 , 7.0) / (pow((C + Cs) / 2, 7.0) + pow(25.0, 7.0) ) ));
-
- cmsFloat64Number a_p = (1 + G ) * a1;
- cmsFloat64Number b_p = b1;
- cmsFloat64Number C_p = sqrt( Sqr(a_p) + Sqr(b_p));
- cmsFloat64Number h_p = atan2deg(b_p, a_p);
-
-
- cmsFloat64Number a_ps = (1 + G) * as;
- cmsFloat64Number b_ps = bs;
- cmsFloat64Number C_ps = sqrt(Sqr(a_ps) + Sqr(b_ps));
- cmsFloat64Number h_ps = atan2deg(b_ps, a_ps);
-
- cmsFloat64Number meanC_p =(C_p + C_ps) / 2;
-
- cmsFloat64Number hps_plus_hp = h_ps + h_p;
- cmsFloat64Number hps_minus_hp = h_ps - h_p;
-
- cmsFloat64Number meanh_p = fabs(hps_minus_hp) <= 180.000001 ? (hps_plus_hp)/2 :
- (hps_plus_hp) < 360 ? (hps_plus_hp + 360)/2 :
- (hps_plus_hp - 360)/2;
-
- cmsFloat64Number delta_h = (hps_minus_hp) <= -180.000001 ? (hps_minus_hp + 360) :
- (hps_minus_hp) > 180 ? (hps_minus_hp - 360) :
- (hps_minus_hp);
- cmsFloat64Number delta_L = (Ls - L1);
- cmsFloat64Number delta_C = (C_ps - C_p );
-
-
- cmsFloat64Number delta_H =2 * sqrt(C_ps*C_p) * sin(RADIANS(delta_h) / 2);
-
- cmsFloat64Number T = 1 - 0.17 * cos(RADIANS(meanh_p-30))
- + 0.24 * cos(RADIANS(2*meanh_p))
- + 0.32 * cos(RADIANS(3*meanh_p + 6))
- - 0.2 * cos(RADIANS(4*meanh_p - 63));
-
- cmsFloat64Number Sl = 1 + (0.015 * Sqr((Ls + L1) /2- 50) )/ sqrt(20 + Sqr( (Ls+L1)/2 - 50) );
-
- cmsFloat64Number Sc = 1 + 0.045 * (C_p + C_ps)/2;
- cmsFloat64Number Sh = 1 + 0.015 * ((C_ps + C_p)/2) * T;
-
- cmsFloat64Number delta_ro = 30 * exp( -Sqr(((meanh_p - 275 ) / 25)));
-
- cmsFloat64Number Rc = 2 * sqrt(( pow(meanC_p, 7.0) )/( pow(meanC_p, 7.0) + pow(25.0, 7.0)));
-
- cmsFloat64Number Rt = -sin(2 * RADIANS(delta_ro)) * Rc;
-
- cmsFloat64Number deltaE00 = sqrt( Sqr(delta_L /(Sl * Kl)) +
- Sqr(delta_C/(Sc * Kc)) +
- Sqr(delta_H/(Sh * Kh)) +
- Rt*(delta_C/(Sc * Kc)) * (delta_H / (Sh * Kh)));
-
- return deltaE00;
-}
-
-// This function returns a number of gridpoints to be used as LUT table. It assumes same number
-// of gripdpoints in all dimensions. Flags may override the choice.
-cmsUInt32Number CMSEXPORT _cmsReasonableGridpointsByColorspace(cmsColorSpaceSignature Colorspace, cmsUInt32Number dwFlags)
-{
- cmsUInt32Number nChannels;
-
- // Already specified?
- if (dwFlags & 0x00FF0000) {
- // Yes, grab'em
- return (dwFlags >> 16) & 0xFF;
- }
-
- nChannels = cmsChannelsOf(Colorspace);
-
- // HighResPrecalc is maximum resolution
- if (dwFlags & cmsFLAGS_HIGHRESPRECALC) {
-
- if (nChannels > 4)
- return 7; // 7 for Hifi
-
- if (nChannels == 4) // 23 for CMYK
- return 23;
-
- return 49; // 49 for RGB and others
- }
-
-
- // LowResPrecal is lower resolution
- if (dwFlags & cmsFLAGS_LOWRESPRECALC) {
-
- if (nChannels > 4)
- return 6; // 6 for more than 4 channels
-
- if (nChannels == 1)
- return 33; // For monochrome
-
- return 17; // 17 for remaining
- }
-
- // Default values
- if (nChannels > 4)
- return 7; // 7 for Hifi
-
- if (nChannels == 4)
- return 17; // 17 for CMYK
-
- return 33; // 33 for RGB
-}
-
-
-cmsBool _cmsEndPointsBySpace(cmsColorSpaceSignature Space,
- cmsUInt16Number **White,
- cmsUInt16Number **Black,
- cmsUInt32Number *nOutputs)
-{
- // Only most common spaces
-
- static cmsUInt16Number RGBblack[4] = { 0, 0, 0 };
- static cmsUInt16Number RGBwhite[4] = { 0xffff, 0xffff, 0xffff };
- static cmsUInt16Number CMYKblack[4] = { 0xffff, 0xffff, 0xffff, 0xffff }; // 400% of ink
- static cmsUInt16Number CMYKwhite[4] = { 0, 0, 0, 0 };
- static cmsUInt16Number LABblack[4] = { 0, 0x8080, 0x8080 }; // V4 Lab encoding
- static cmsUInt16Number LABwhite[4] = { 0xFFFF, 0x8080, 0x8080 };
- static cmsUInt16Number CMYblack[4] = { 0xffff, 0xffff, 0xffff };
- static cmsUInt16Number CMYwhite[4] = { 0, 0, 0 };
- static cmsUInt16Number Grayblack[4] = { 0 };
- static cmsUInt16Number GrayWhite[4] = { 0xffff };
-
- switch (Space) {
-
- case cmsSigGrayData: if (White) *White = GrayWhite;
- if (Black) *Black = Grayblack;
- if (nOutputs) *nOutputs = 1;
- return TRUE;
-
- case cmsSigRgbData: if (White) *White = RGBwhite;
- if (Black) *Black = RGBblack;
- if (nOutputs) *nOutputs = 3;
- return TRUE;
-
- case cmsSigLabData: if (White) *White = LABwhite;
- if (Black) *Black = LABblack;
- if (nOutputs) *nOutputs = 3;
- return TRUE;
-
- case cmsSigCmykData: if (White) *White = CMYKwhite;
- if (Black) *Black = CMYKblack;
- if (nOutputs) *nOutputs = 4;
- return TRUE;
-
- case cmsSigCmyData: if (White) *White = CMYwhite;
- if (Black) *Black = CMYblack;
- if (nOutputs) *nOutputs = 3;
- return TRUE;
-
- default:;
- }
-
- return FALSE;
-}
-
-
-
-// Several utilities -------------------------------------------------------
-
-// Translate from our colorspace to ICC representation
-
-cmsColorSpaceSignature CMSEXPORT _cmsICCcolorSpace(int OurNotation)
-{
- switch (OurNotation) {
-
- case 1:
- case PT_GRAY: return cmsSigGrayData;
-
- case 2:
- case PT_RGB: return cmsSigRgbData;
-
- case PT_CMY: return cmsSigCmyData;
- case PT_CMYK: return cmsSigCmykData;
- case PT_YCbCr:return cmsSigYCbCrData;
- case PT_YUV: return cmsSigLuvData;
- case PT_XYZ: return cmsSigXYZData;
-
- case PT_LabV2:
- case PT_Lab: return cmsSigLabData;
-
- case PT_YUVK: return cmsSigLuvKData;
- case PT_HSV: return cmsSigHsvData;
- case PT_HLS: return cmsSigHlsData;
- case PT_Yxy: return cmsSigYxyData;
-
- case PT_MCH1: return cmsSigMCH1Data;
- case PT_MCH2: return cmsSigMCH2Data;
- case PT_MCH3: return cmsSigMCH3Data;
- case PT_MCH4: return cmsSigMCH4Data;
- case PT_MCH5: return cmsSigMCH5Data;
- case PT_MCH6: return cmsSigMCH6Data;
- case PT_MCH7: return cmsSigMCH7Data;
- case PT_MCH8: return cmsSigMCH8Data;
-
- case PT_MCH9: return cmsSigMCH9Data;
- case PT_MCH10: return cmsSigMCHAData;
- case PT_MCH11: return cmsSigMCHBData;
- case PT_MCH12: return cmsSigMCHCData;
- case PT_MCH13: return cmsSigMCHDData;
- case PT_MCH14: return cmsSigMCHEData;
- case PT_MCH15: return cmsSigMCHFData;
-
- default: return (cmsColorSpaceSignature) 0;
- }
-}
-
-
-int CMSEXPORT _cmsLCMScolorSpace(cmsColorSpaceSignature ProfileSpace)
-{
- switch (ProfileSpace) {
-
- case cmsSigGrayData: return PT_GRAY;
- case cmsSigRgbData: return PT_RGB;
- case cmsSigCmyData: return PT_CMY;
- case cmsSigCmykData: return PT_CMYK;
- case cmsSigYCbCrData:return PT_YCbCr;
- case cmsSigLuvData: return PT_YUV;
- case cmsSigXYZData: return PT_XYZ;
- case cmsSigLabData: return PT_Lab;
- case cmsSigLuvKData: return PT_YUVK;
- case cmsSigHsvData: return PT_HSV;
- case cmsSigHlsData: return PT_HLS;
- case cmsSigYxyData: return PT_Yxy;
-
- case cmsSig1colorData:
- case cmsSigMCH1Data: return PT_MCH1;
-
- case cmsSig2colorData:
- case cmsSigMCH2Data: return PT_MCH2;
-
- case cmsSig3colorData:
- case cmsSigMCH3Data: return PT_MCH3;
-
- case cmsSig4colorData:
- case cmsSigMCH4Data: return PT_MCH4;
-
- case cmsSig5colorData:
- case cmsSigMCH5Data: return PT_MCH5;
-
- case cmsSig6colorData:
- case cmsSigMCH6Data: return PT_MCH6;
-
- case cmsSigMCH7Data:
- case cmsSig7colorData:return PT_MCH7;
-
- case cmsSigMCH8Data:
- case cmsSig8colorData:return PT_MCH8;
-
- case cmsSigMCH9Data:
- case cmsSig9colorData:return PT_MCH9;
-
- case cmsSigMCHAData:
- case cmsSig10colorData:return PT_MCH10;
-
- case cmsSigMCHBData:
- case cmsSig11colorData:return PT_MCH11;
-
- case cmsSigMCHCData:
- case cmsSig12colorData:return PT_MCH12;
-
- case cmsSigMCHDData:
- case cmsSig13colorData:return PT_MCH13;
-
- case cmsSigMCHEData:
- case cmsSig14colorData:return PT_MCH14;
-
- case cmsSigMCHFData:
- case cmsSig15colorData:return PT_MCH15;
-
- default: return (cmsColorSpaceSignature) 0;
- }
-}
-
-
-cmsInt32Number CMSEXPORT cmsChannelsOfColorSpace(cmsColorSpaceSignature ColorSpace)
-{
- switch (ColorSpace) {
-
- case cmsSigMCH1Data:
- case cmsSig1colorData:
- case cmsSigGrayData: return 1;
-
- case cmsSigMCH2Data:
- case cmsSig2colorData: return 2;
-
- case cmsSigXYZData:
- case cmsSigLabData:
- case cmsSigLuvData:
- case cmsSigYCbCrData:
- case cmsSigYxyData:
- case cmsSigRgbData:
- case cmsSigHsvData:
- case cmsSigHlsData:
- case cmsSigCmyData:
- case cmsSigMCH3Data:
- case cmsSig3colorData: return 3;
-
- case cmsSigLuvKData:
- case cmsSigCmykData:
- case cmsSigMCH4Data:
- case cmsSig4colorData: return 4;
-
- case cmsSigMCH5Data:
- case cmsSig5colorData: return 5;
-
- case cmsSigMCH6Data:
- case cmsSig6colorData: return 6;
-
- case cmsSigMCH7Data:
- case cmsSig7colorData: return 7;
-
- case cmsSigMCH8Data:
- case cmsSig8colorData: return 8;
-
- case cmsSigMCH9Data:
- case cmsSig9colorData: return 9;
-
- case cmsSigMCHAData:
- case cmsSig10colorData: return 10;
-
- case cmsSigMCHBData:
- case cmsSig11colorData: return 11;
-
- case cmsSigMCHCData:
- case cmsSig12colorData: return 12;
-
- case cmsSigMCHDData:
- case cmsSig13colorData: return 13;
-
- case cmsSigMCHEData:
- case cmsSig14colorData: return 14;
-
- case cmsSigMCHFData:
- case cmsSig15colorData: return 15;
-
- default: return -1;
- }
-}
-
-/**
-* DEPRECATED: Provided for compatibility only
-*/
-cmsUInt32Number CMSEXPORT cmsChannelsOf(cmsColorSpaceSignature ColorSpace)
-{
- int n = cmsChannelsOfColorSpace(ColorSpace);
- if (n < 0) return 3;
- return (cmsUInt32Number)n;
-} \ No newline at end of file
diff --git a/contrib/libs/lcms2/src/cmsplugin.c b/contrib/libs/lcms2/src/cmsplugin.c
deleted file mode 100644
index e278832813..0000000000
--- a/contrib/libs/lcms2/src/cmsplugin.c
+++ /dev/null
@@ -1,1052 +0,0 @@
-//---------------------------------------------------------------------------------
-//
-// Little Color Management System
-// Copyright (c) 1998-2023 Marti Maria Saguer
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//---------------------------------------------------------------------------------
-//
-
-#include "lcms2_internal.h"
-
-
-// ----------------------------------------------------------------------------------
-// Encoding & Decoding support functions
-// ----------------------------------------------------------------------------------
-
-// Little-Endian to Big-Endian
-
-// Adjust a word value after being read/ before being written from/to an ICC profile
-cmsUInt16Number CMSEXPORT _cmsAdjustEndianess16(cmsUInt16Number Word)
-{
-#ifndef CMS_USE_BIG_ENDIAN
-
- cmsUInt8Number* pByte = (cmsUInt8Number*) &Word;
- cmsUInt8Number tmp;
-
- tmp = pByte[0];
- pByte[0] = pByte[1];
- pByte[1] = tmp;
-#endif
-
- return Word;
-}
-
-
-// Transports to properly encoded values - note that icc profiles does use big endian notation.
-
-// 1 2 3 4
-// 4 3 2 1
-
-cmsUInt32Number CMSEXPORT _cmsAdjustEndianess32(cmsUInt32Number DWord)
-{
-#ifndef CMS_USE_BIG_ENDIAN
-
- cmsUInt8Number* pByte = (cmsUInt8Number*) &DWord;
- cmsUInt8Number temp1;
- cmsUInt8Number temp2;
-
- temp1 = *pByte++;
- temp2 = *pByte++;
- *(pByte-1) = *pByte;
- *pByte++ = temp2;
- *(pByte-3) = *pByte;
- *pByte = temp1;
-#endif
- return DWord;
-}
-
-// 1 2 3 4 5 6 7 8
-// 8 7 6 5 4 3 2 1
-
-void CMSEXPORT _cmsAdjustEndianess64(cmsUInt64Number* Result, cmsUInt64Number* QWord)
-{
-
-#ifndef CMS_USE_BIG_ENDIAN
-
- cmsUInt8Number* pIn = (cmsUInt8Number*) QWord;
- cmsUInt8Number* pOut = (cmsUInt8Number*) Result;
-
- _cmsAssert(Result != NULL);
-
- pOut[7] = pIn[0];
- pOut[6] = pIn[1];
- pOut[5] = pIn[2];
- pOut[4] = pIn[3];
- pOut[3] = pIn[4];
- pOut[2] = pIn[5];
- pOut[1] = pIn[6];
- pOut[0] = pIn[7];
-
-#else
- _cmsAssert(Result != NULL);
-
-# ifdef CMS_DONT_USE_INT64
- (*Result)[0] = (*QWord)[0];
- (*Result)[1] = (*QWord)[1];
-# else
- *Result = *QWord;
-# endif
-#endif
-}
-
-// Auxiliary -- read 8, 16 and 32-bit numbers
-cmsBool CMSEXPORT _cmsReadUInt8Number(cmsIOHANDLER* io, cmsUInt8Number* n)
-{
- cmsUInt8Number tmp;
-
- _cmsAssert(io != NULL);
-
- if (io -> Read(io, &tmp, sizeof(cmsUInt8Number), 1) != 1)
- return FALSE;
-
- if (n != NULL) *n = tmp;
- return TRUE;
-}
-
-cmsBool CMSEXPORT _cmsReadUInt16Number(cmsIOHANDLER* io, cmsUInt16Number* n)
-{
- cmsUInt16Number tmp;
-
- _cmsAssert(io != NULL);
-
- if (io -> Read(io, &tmp, sizeof(cmsUInt16Number), 1) != 1)
- return FALSE;
-
- if (n != NULL) *n = _cmsAdjustEndianess16(tmp);
- return TRUE;
-}
-
-cmsBool CMSEXPORT _cmsReadUInt16Array(cmsIOHANDLER* io, cmsUInt32Number n, cmsUInt16Number* Array)
-{
- cmsUInt32Number i;
-
- _cmsAssert(io != NULL);
-
- for (i=0; i < n; i++) {
-
- if (Array != NULL) {
- if (!_cmsReadUInt16Number(io, Array + i)) return FALSE;
- }
- else {
- if (!_cmsReadUInt16Number(io, NULL)) return FALSE;
- }
-
- }
- return TRUE;
-}
-
-cmsBool CMSEXPORT _cmsReadUInt32Number(cmsIOHANDLER* io, cmsUInt32Number* n)
-{
- cmsUInt32Number tmp;
-
- _cmsAssert(io != NULL);
-
- if (io -> Read(io, &tmp, sizeof(cmsUInt32Number), 1) != 1)
- return FALSE;
-
- if (n != NULL) *n = _cmsAdjustEndianess32(tmp);
- return TRUE;
-}
-
-cmsBool CMSEXPORT _cmsReadFloat32Number(cmsIOHANDLER* io, cmsFloat32Number* n)
-{
- union typeConverter {
- cmsUInt32Number integer;
- cmsFloat32Number floating_point;
- } tmp;
-
- _cmsAssert(io != NULL);
-
- if (io->Read(io, &tmp.integer, sizeof(cmsUInt32Number), 1) != 1)
- return FALSE;
-
- if (n != NULL) {
-
- tmp.integer = _cmsAdjustEndianess32(tmp.integer);
- *n = tmp.floating_point;
-
- // Safeguard which covers against absurd values
- if (*n > 1E+20 || *n < -1E+20) return FALSE;
-
- #if defined(_MSC_VER) && _MSC_VER < 1800
- return TRUE;
- #elif defined (__BORLANDC__)
- return TRUE;
- #elif !defined(_MSC_VER) && (defined(__STDC_VERSION__) && __STDC_VERSION__ < 199901L)
- return TRUE;
- #else
-
- // fpclassify() required by C99 (only provided by MSVC >= 1800, VS2013 onwards)
- return ((fpclassify(*n) == FP_ZERO) || (fpclassify(*n) == FP_NORMAL));
- #endif
- }
-
- return TRUE;
-}
-
-
-cmsBool CMSEXPORT _cmsReadUInt64Number(cmsIOHANDLER* io, cmsUInt64Number* n)
-{
- cmsUInt64Number tmp;
-
- _cmsAssert(io != NULL);
-
- if (io -> Read(io, &tmp, sizeof(cmsUInt64Number), 1) != 1)
- return FALSE;
-
- if (n != NULL) {
-
- _cmsAdjustEndianess64(n, &tmp);
- }
-
- return TRUE;
-}
-
-
-cmsBool CMSEXPORT _cmsRead15Fixed16Number(cmsIOHANDLER* io, cmsFloat64Number* n)
-{
- cmsUInt32Number tmp;
-
- _cmsAssert(io != NULL);
-
- if (io -> Read(io, &tmp, sizeof(cmsUInt32Number), 1) != 1)
- return FALSE;
-
- if (n != NULL) {
- *n = _cms15Fixed16toDouble((cmsS15Fixed16Number) _cmsAdjustEndianess32(tmp));
- }
-
- return TRUE;
-}
-
-
-cmsBool CMSEXPORT _cmsReadXYZNumber(cmsIOHANDLER* io, cmsCIEXYZ* XYZ)
-{
- cmsEncodedXYZNumber xyz;
-
- _cmsAssert(io != NULL);
-
- if (io ->Read(io, &xyz, sizeof(cmsEncodedXYZNumber), 1) != 1) return FALSE;
-
- if (XYZ != NULL) {
-
- XYZ->X = _cms15Fixed16toDouble((cmsS15Fixed16Number) _cmsAdjustEndianess32((cmsUInt32Number) xyz.X));
- XYZ->Y = _cms15Fixed16toDouble((cmsS15Fixed16Number) _cmsAdjustEndianess32((cmsUInt32Number) xyz.Y));
- XYZ->Z = _cms15Fixed16toDouble((cmsS15Fixed16Number) _cmsAdjustEndianess32((cmsUInt32Number) xyz.Z));
- }
- return TRUE;
-}
-
-cmsBool CMSEXPORT _cmsWriteUInt8Number(cmsIOHANDLER* io, cmsUInt8Number n)
-{
- _cmsAssert(io != NULL);
-
- if (io -> Write(io, sizeof(cmsUInt8Number), &n) != 1)
- return FALSE;
-
- return TRUE;
-}
-
-cmsBool CMSEXPORT _cmsWriteUInt16Number(cmsIOHANDLER* io, cmsUInt16Number n)
-{
- cmsUInt16Number tmp;
-
- _cmsAssert(io != NULL);
-
- tmp = _cmsAdjustEndianess16(n);
- if (io -> Write(io, sizeof(cmsUInt16Number), &tmp) != 1)
- return FALSE;
-
- return TRUE;
-}
-
-cmsBool CMSEXPORT _cmsWriteUInt16Array(cmsIOHANDLER* io, cmsUInt32Number n, const cmsUInt16Number* Array)
-{
- cmsUInt32Number i;
-
- _cmsAssert(io != NULL);
- _cmsAssert(Array != NULL);
-
- for (i=0; i < n; i++) {
- if (!_cmsWriteUInt16Number(io, Array[i])) return FALSE;
- }
-
- return TRUE;
-}
-
-cmsBool CMSEXPORT _cmsWriteUInt32Number(cmsIOHANDLER* io, cmsUInt32Number n)
-{
- cmsUInt32Number tmp;
-
- _cmsAssert(io != NULL);
-
- tmp = _cmsAdjustEndianess32(n);
- if (io -> Write(io, sizeof(cmsUInt32Number), &tmp) != 1)
- return FALSE;
-
- return TRUE;
-}
-
-
-cmsBool CMSEXPORT _cmsWriteFloat32Number(cmsIOHANDLER* io, cmsFloat32Number n)
-{
- union typeConverter {
- cmsUInt32Number integer;
- cmsFloat32Number floating_point;
- } tmp;
-
- tmp.floating_point = n;
- tmp.integer = _cmsAdjustEndianess32(tmp.integer);
- if (io -> Write(io, sizeof(cmsUInt32Number), &tmp.integer) != 1)
- return FALSE;
-
- return TRUE;
-}
-
-cmsBool CMSEXPORT _cmsWriteUInt64Number(cmsIOHANDLER* io, cmsUInt64Number* n)
-{
- cmsUInt64Number tmp;
-
- _cmsAssert(io != NULL);
-
- _cmsAdjustEndianess64(&tmp, n);
- if (io -> Write(io, sizeof(cmsUInt64Number), &tmp) != 1)
- return FALSE;
-
- return TRUE;
-}
-
-cmsBool CMSEXPORT _cmsWrite15Fixed16Number(cmsIOHANDLER* io, cmsFloat64Number n)
-{
- cmsUInt32Number tmp;
-
- _cmsAssert(io != NULL);
-
- tmp = _cmsAdjustEndianess32((cmsUInt32Number) _cmsDoubleTo15Fixed16(n));
- if (io -> Write(io, sizeof(cmsUInt32Number), &tmp) != 1)
- return FALSE;
-
- return TRUE;
-}
-
-cmsBool CMSEXPORT _cmsWriteXYZNumber(cmsIOHANDLER* io, const cmsCIEXYZ* XYZ)
-{
- cmsEncodedXYZNumber xyz;
-
- _cmsAssert(io != NULL);
- _cmsAssert(XYZ != NULL);
-
- xyz.X = (cmsS15Fixed16Number) _cmsAdjustEndianess32((cmsUInt32Number) _cmsDoubleTo15Fixed16(XYZ->X));
- xyz.Y = (cmsS15Fixed16Number) _cmsAdjustEndianess32((cmsUInt32Number) _cmsDoubleTo15Fixed16(XYZ->Y));
- xyz.Z = (cmsS15Fixed16Number) _cmsAdjustEndianess32((cmsUInt32Number) _cmsDoubleTo15Fixed16(XYZ->Z));
-
- return io -> Write(io, sizeof(cmsEncodedXYZNumber), &xyz);
-}
-
-// from Fixed point 8.8 to double
-cmsFloat64Number CMSEXPORT _cms8Fixed8toDouble(cmsUInt16Number fixed8)
-{
- return fixed8 / 256.0;
-}
-
-cmsUInt16Number CMSEXPORT _cmsDoubleTo8Fixed8(cmsFloat64Number val)
-{
- cmsS15Fixed16Number GammaFixed32 = _cmsDoubleTo15Fixed16(val);
- return (cmsUInt16Number) ((GammaFixed32 >> 8) & 0xFFFF);
-}
-
-// from Fixed point 15.16 to double
-cmsFloat64Number CMSEXPORT _cms15Fixed16toDouble(cmsS15Fixed16Number fix32)
-{
- return fix32 / 65536.0;
-}
-
-// from double to Fixed point 15.16
-cmsS15Fixed16Number CMSEXPORT _cmsDoubleTo15Fixed16(cmsFloat64Number v)
-{
- return ((cmsS15Fixed16Number) floor((v)*65536.0 + 0.5));
-}
-
-// Date/Time functions
-
-void CMSEXPORT _cmsDecodeDateTimeNumber(const cmsDateTimeNumber *Source, struct tm *Dest)
-{
-
- _cmsAssert(Dest != NULL);
- _cmsAssert(Source != NULL);
-
- Dest->tm_sec = _cmsAdjustEndianess16(Source->seconds);
- Dest->tm_min = _cmsAdjustEndianess16(Source->minutes);
- Dest->tm_hour = _cmsAdjustEndianess16(Source->hours);
- Dest->tm_mday = _cmsAdjustEndianess16(Source->day);
- Dest->tm_mon = _cmsAdjustEndianess16(Source->month) - 1;
- Dest->tm_year = _cmsAdjustEndianess16(Source->year) - 1900;
- Dest->tm_wday = -1;
- Dest->tm_yday = -1;
- Dest->tm_isdst = 0;
-}
-
-void CMSEXPORT _cmsEncodeDateTimeNumber(cmsDateTimeNumber *Dest, const struct tm *Source)
-{
- _cmsAssert(Dest != NULL);
- _cmsAssert(Source != NULL);
-
- Dest->seconds = _cmsAdjustEndianess16((cmsUInt16Number) Source->tm_sec);
- Dest->minutes = _cmsAdjustEndianess16((cmsUInt16Number) Source->tm_min);
- Dest->hours = _cmsAdjustEndianess16((cmsUInt16Number) Source->tm_hour);
- Dest->day = _cmsAdjustEndianess16((cmsUInt16Number) Source->tm_mday);
- Dest->month = _cmsAdjustEndianess16((cmsUInt16Number) (Source->tm_mon + 1));
- Dest->year = _cmsAdjustEndianess16((cmsUInt16Number) (Source->tm_year + 1900));
-}
-
-// Read base and return type base
-cmsTagTypeSignature CMSEXPORT _cmsReadTypeBase(cmsIOHANDLER* io)
-{
- _cmsTagBase Base;
-
- _cmsAssert(io != NULL);
-
- if (io -> Read(io, &Base, sizeof(_cmsTagBase), 1) != 1)
- return (cmsTagTypeSignature) 0;
-
- return (cmsTagTypeSignature) _cmsAdjustEndianess32(Base.sig);
-}
-
-// Setup base marker
-cmsBool CMSEXPORT _cmsWriteTypeBase(cmsIOHANDLER* io, cmsTagTypeSignature sig)
-{
- _cmsTagBase Base;
-
- _cmsAssert(io != NULL);
-
- Base.sig = (cmsTagTypeSignature) _cmsAdjustEndianess32(sig);
- memset(&Base.reserved, 0, sizeof(Base.reserved));
- return io -> Write(io, sizeof(_cmsTagBase), &Base);
-}
-
-cmsBool CMSEXPORT _cmsReadAlignment(cmsIOHANDLER* io)
-{
- cmsUInt8Number Buffer[4];
- cmsUInt32Number NextAligned, At;
- cmsUInt32Number BytesToNextAlignedPos;
-
- _cmsAssert(io != NULL);
-
- At = io -> Tell(io);
- NextAligned = _cmsALIGNLONG(At);
- BytesToNextAlignedPos = NextAligned - At;
- if (BytesToNextAlignedPos == 0) return TRUE;
- if (BytesToNextAlignedPos > 4) return FALSE;
-
- return (io ->Read(io, Buffer, BytesToNextAlignedPos, 1) == 1);
-}
-
-cmsBool CMSEXPORT _cmsWriteAlignment(cmsIOHANDLER* io)
-{
- cmsUInt8Number Buffer[4];
- cmsUInt32Number NextAligned, At;
- cmsUInt32Number BytesToNextAlignedPos;
-
- _cmsAssert(io != NULL);
-
- At = io -> Tell(io);
- NextAligned = _cmsALIGNLONG(At);
- BytesToNextAlignedPos = NextAligned - At;
- if (BytesToNextAlignedPos == 0) return TRUE;
- if (BytesToNextAlignedPos > 4) return FALSE;
-
- memset(Buffer, 0, BytesToNextAlignedPos);
- return io -> Write(io, BytesToNextAlignedPos, Buffer);
-}
-
-
-// To deal with text streams. 2K at most
-cmsBool CMSEXPORT _cmsIOPrintf(cmsIOHANDLER* io, const char* frm, ...)
-{
- va_list args;
- int len;
- cmsUInt8Number Buffer[2048];
- cmsBool rc;
- cmsUInt8Number* ptr;
-
- _cmsAssert(io != NULL);
- _cmsAssert(frm != NULL);
-
- va_start(args, frm);
-
- len = vsnprintf((char*) Buffer, 2047, frm, args);
- if (len < 0) {
- va_end(args);
- return FALSE; // Truncated, which is a fatal error for us
- }
-
- // setlocale may be active, no commas are needed in PS generator
- // and PS generator is our only client
- for (ptr = Buffer; *ptr; ptr++)
- {
- if (*ptr == ',') *ptr = '.';
- }
-
- rc = io ->Write(io, (cmsUInt32Number) len, Buffer);
-
- va_end(args);
-
- return rc;
-}
-
-
-// Plugin memory management -------------------------------------------------------------------------------------------------
-
-// Specialized malloc for plug-ins, that is freed upon exit.
-void* _cmsPluginMalloc(cmsContext ContextID, cmsUInt32Number size)
-{
- struct _cmsContext_struct* ctx = _cmsGetContext(ContextID);
-
- if (ctx ->MemPool == NULL) {
-
- if (ContextID == NULL) {
-
- ctx->MemPool = _cmsCreateSubAlloc(0, 2*1024);
- if (ctx->MemPool == NULL) return NULL;
- }
- else {
- cmsSignalError(ContextID, cmsERROR_CORRUPTION_DETECTED, "NULL memory pool on context");
- return NULL;
- }
- }
-
- return _cmsSubAlloc(ctx->MemPool, size);
-}
-
-
-// Main plug-in dispatcher
-cmsBool CMSEXPORT cmsPlugin(void* Plug_in)
-{
- return cmsPluginTHR(NULL, Plug_in);
-}
-
-cmsBool CMSEXPORT cmsPluginTHR(cmsContext id, void* Plug_in)
-{
- cmsPluginBase* Plugin;
-
- for (Plugin = (cmsPluginBase*) Plug_in;
- Plugin != NULL;
- Plugin = Plugin -> Next) {
-
- if (Plugin -> Magic != cmsPluginMagicNumber) {
- cmsSignalError(id, cmsERROR_UNKNOWN_EXTENSION, "Unrecognized plugin");
- return FALSE;
- }
-
- if (Plugin ->ExpectedVersion > LCMS_VERSION) {
- cmsSignalError(id, cmsERROR_UNKNOWN_EXTENSION, "plugin needs Little CMS %d, current version is %d",
- Plugin ->ExpectedVersion, LCMS_VERSION);
- return FALSE;
- }
-
- switch (Plugin -> Type) {
-
- case cmsPluginMemHandlerSig:
- if (!_cmsRegisterMemHandlerPlugin(id, Plugin)) return FALSE;
- break;
-
- case cmsPluginInterpolationSig:
- if (!_cmsRegisterInterpPlugin(id, Plugin)) return FALSE;
- break;
-
- case cmsPluginTagTypeSig:
- if (!_cmsRegisterTagTypePlugin(id, Plugin)) return FALSE;
- break;
-
- case cmsPluginTagSig:
- if (!_cmsRegisterTagPlugin(id, Plugin)) return FALSE;
- break;
-
- case cmsPluginFormattersSig:
- if (!_cmsRegisterFormattersPlugin(id, Plugin)) return FALSE;
- break;
-
- case cmsPluginRenderingIntentSig:
- if (!_cmsRegisterRenderingIntentPlugin(id, Plugin)) return FALSE;
- break;
-
- case cmsPluginParametricCurveSig:
- if (!_cmsRegisterParametricCurvesPlugin(id, Plugin)) return FALSE;
- break;
-
- case cmsPluginMultiProcessElementSig:
- if (!_cmsRegisterMultiProcessElementPlugin(id, Plugin)) return FALSE;
- break;
-
- case cmsPluginOptimizationSig:
- if (!_cmsRegisterOptimizationPlugin(id, Plugin)) return FALSE;
- break;
-
- case cmsPluginTransformSig:
- if (!_cmsRegisterTransformPlugin(id, Plugin)) return FALSE;
- break;
-
- case cmsPluginMutexSig:
- if (!_cmsRegisterMutexPlugin(id, Plugin)) return FALSE;
- break;
-
- case cmsPluginParalellizationSig:
- if (!_cmsRegisterParallelizationPlugin(id, Plugin)) return FALSE;
- break;
-
- default:
- cmsSignalError(id, cmsERROR_UNKNOWN_EXTENSION, "Unrecognized plugin type '%X'", Plugin -> Type);
- return FALSE;
- }
- }
-
- // Keep a reference to the plug-in
- return TRUE;
-}
-
-
-// Revert all plug-ins to default
-void CMSEXPORT cmsUnregisterPlugins(void)
-{
- cmsUnregisterPluginsTHR(NULL);
-}
-
-
-// The Global storage for system context. This is the one and only global variable
-// pointers structure. All global vars are referenced here.
-static struct _cmsContext_struct globalContext = {
-
- NULL, // Not in the linked list
- NULL, // No suballocator
- {
- NULL, // UserPtr,
- &_cmsLogErrorChunk, // Logger,
- &_cmsAlarmCodesChunk, // AlarmCodes,
- &_cmsAdaptationStateChunk, // AdaptationState,
- &_cmsMemPluginChunk, // MemPlugin,
- &_cmsInterpPluginChunk, // InterpPlugin,
- &_cmsCurvesPluginChunk, // CurvesPlugin,
- &_cmsFormattersPluginChunk, // FormattersPlugin,
- &_cmsTagTypePluginChunk, // TagTypePlugin,
- &_cmsTagPluginChunk, // TagPlugin,
- &_cmsIntentsPluginChunk, // IntentPlugin,
- &_cmsMPETypePluginChunk, // MPEPlugin,
- &_cmsOptimizationPluginChunk, // OptimizationPlugin,
- &_cmsTransformPluginChunk, // TransformPlugin,
- &_cmsMutexPluginChunk, // MutexPlugin,
- &_cmsParallelizationPluginChunk // ParallelizationPlugin
- },
-
- { NULL, NULL, NULL, NULL, NULL, NULL } // The default memory allocator is not used for context 0
-};
-
-
-// The context pool (linked list head)
-static _cmsMutex _cmsContextPoolHeadMutex = CMS_MUTEX_INITIALIZER;
-static struct _cmsContext_struct* _cmsContextPoolHead = NULL;
-
-
-// Make sure context is initialized (needed on windows)
-static
-cmsBool InitContextMutex(void)
-{
- // See the comments regarding locking in lcms2_internal.h
- // for an explanation of why we need the following code.
-#ifndef CMS_NO_PTHREADS
-#ifdef CMS_IS_WINDOWS_
-#ifndef CMS_RELY_ON_WINDOWS_STATIC_MUTEX_INIT
-
- static cmsBool already_initialized = FALSE;
-
- if (!already_initialized)
- {
- static HANDLE _cmsWindowsInitMutex = NULL;
- static volatile HANDLE* mutex = &_cmsWindowsInitMutex;
-
- if (*mutex == NULL)
- {
- HANDLE p = CreateMutex(NULL, FALSE, NULL);
- if (p && InterlockedCompareExchangePointer((void**)mutex, (void*)p, NULL) != NULL)
- CloseHandle(p);
- }
- if (*mutex == NULL || WaitForSingleObject(*mutex, INFINITE) == WAIT_FAILED)
- {
- cmsSignalError(0, cmsERROR_INTERNAL, "Mutex lock failed");
- return FALSE;
- }
- if (((void**)&_cmsContextPoolHeadMutex)[0] == NULL)
- InitializeCriticalSection(&_cmsContextPoolHeadMutex);
- if (*mutex == NULL || !ReleaseMutex(*mutex))
- {
- cmsSignalError(0, cmsERROR_INTERNAL, "Mutex unlock failed");
- return FALSE;
- }
- already_initialized = TRUE;
- }
-#endif
-#endif
-#endif
-
- return TRUE;
-}
-
-
-
-// Internal, get associated pointer, with guessing. Never returns NULL.
-struct _cmsContext_struct* _cmsGetContext(cmsContext ContextID)
-{
- struct _cmsContext_struct* id = (struct _cmsContext_struct*) ContextID;
- struct _cmsContext_struct* ctx;
-
- // On 0, use global settings
- if (id == NULL)
- return &globalContext;
-
- InitContextMutex();
-
- // Search
- _cmsEnterCriticalSectionPrimitive(&_cmsContextPoolHeadMutex);
-
- for (ctx = _cmsContextPoolHead;
- ctx != NULL;
- ctx = ctx ->Next) {
-
- // Found it?
- if (id == ctx)
- {
- _cmsLeaveCriticalSectionPrimitive(&_cmsContextPoolHeadMutex);
- return ctx; // New-style context
- }
- }
-
- _cmsLeaveCriticalSectionPrimitive(&_cmsContextPoolHeadMutex);
- return &globalContext;
-}
-
-
-// Internal: get the memory area associanted with each context client
-// Returns the block assigned to the specific zone. Never return NULL.
-void* _cmsContextGetClientChunk(cmsContext ContextID, _cmsMemoryClient mc)
-{
- struct _cmsContext_struct* ctx;
- void *ptr;
-
- if ((int) mc < 0 || mc >= MemoryClientMax) {
-
- cmsSignalError(ContextID, cmsERROR_INTERNAL, "Bad context client -- possible corruption");
-
- // This is catastrophic. Should never reach here
- _cmsAssert(0);
-
- // Reverts to global context
- return globalContext.chunks[UserPtr];
- }
-
- ctx = _cmsGetContext(ContextID);
- ptr = ctx ->chunks[mc];
-
- if (ptr != NULL)
- return ptr;
-
- // A null ptr means no special settings for that context, and this
- // reverts to Context0 globals
- return globalContext.chunks[mc];
-}
-
-
-// This function returns the given context its default pristine state,
-// as no plug-ins were declared. There is no way to unregister a single
-// plug-in, as a single call to cmsPluginTHR() function may register
-// many different plug-ins simultaneously, then there is no way to
-// identify which plug-in to unregister.
-void CMSEXPORT cmsUnregisterPluginsTHR(cmsContext ContextID)
-{
- _cmsRegisterMemHandlerPlugin(ContextID, NULL);
- _cmsRegisterInterpPlugin(ContextID, NULL);
- _cmsRegisterTagTypePlugin(ContextID, NULL);
- _cmsRegisterTagPlugin(ContextID, NULL);
- _cmsRegisterFormattersPlugin(ContextID, NULL);
- _cmsRegisterRenderingIntentPlugin(ContextID, NULL);
- _cmsRegisterParametricCurvesPlugin(ContextID, NULL);
- _cmsRegisterMultiProcessElementPlugin(ContextID, NULL);
- _cmsRegisterOptimizationPlugin(ContextID, NULL);
- _cmsRegisterTransformPlugin(ContextID, NULL);
- _cmsRegisterMutexPlugin(ContextID, NULL);
- _cmsRegisterParallelizationPlugin(ContextID, NULL);
-
-}
-
-
-// Returns the memory manager plug-in, if any, from the Plug-in bundle
-static
-cmsPluginMemHandler* _cmsFindMemoryPlugin(void* PluginBundle)
-{
- cmsPluginBase* Plugin;
-
- for (Plugin = (cmsPluginBase*) PluginBundle;
- Plugin != NULL;
- Plugin = Plugin -> Next) {
-
- if (Plugin -> Magic == cmsPluginMagicNumber &&
- Plugin -> ExpectedVersion <= LCMS_VERSION &&
- Plugin -> Type == cmsPluginMemHandlerSig) {
-
- // Found!
- return (cmsPluginMemHandler*) Plugin;
- }
- }
-
- // Nope, revert to defaults
- return NULL;
-}
-
-
-// Creates a new context with optional associated plug-ins. Caller may also specify an optional pointer to user-defined
-// data that will be forwarded to plug-ins and logger.
-cmsContext CMSEXPORT cmsCreateContext(void* Plugin, void* UserData)
-{
- struct _cmsContext_struct* ctx;
- struct _cmsContext_struct fakeContext;
-
- if (!InitContextMutex()) return NULL;
-
- _cmsInstallAllocFunctions(_cmsFindMemoryPlugin(Plugin), &fakeContext.DefaultMemoryManager);
-
- fakeContext.chunks[UserPtr] = UserData;
- fakeContext.chunks[MemPlugin] = &fakeContext.DefaultMemoryManager;
-
- // Create the context structure.
- ctx = (struct _cmsContext_struct*) _cmsMalloc(&fakeContext, sizeof(struct _cmsContext_struct));
- if (ctx == NULL)
- return NULL; // Something very wrong happened!
-
- // Init the structure and the memory manager
- memset(ctx, 0, sizeof(struct _cmsContext_struct));
-
- // Keep memory manager
- memcpy(&ctx->DefaultMemoryManager, &fakeContext.DefaultMemoryManager, sizeof(_cmsMemPluginChunk));
-
- // Maintain the linked list (with proper locking)
- _cmsEnterCriticalSectionPrimitive(&_cmsContextPoolHeadMutex);
- ctx ->Next = _cmsContextPoolHead;
- _cmsContextPoolHead = ctx;
- _cmsLeaveCriticalSectionPrimitive(&_cmsContextPoolHeadMutex);
-
- ctx ->chunks[UserPtr] = UserData;
- ctx ->chunks[MemPlugin] = &ctx->DefaultMemoryManager;
-
- // Now we can allocate the pool by using default memory manager
- ctx ->MemPool = _cmsCreateSubAlloc(ctx, 22 * sizeof(void*)); // default size about 22 pointers
- if (ctx ->MemPool == NULL) {
-
- cmsDeleteContext(ctx);
- return NULL;
- }
-
- _cmsAllocLogErrorChunk(ctx, NULL);
- _cmsAllocAlarmCodesChunk(ctx, NULL);
- _cmsAllocAdaptationStateChunk(ctx, NULL);
- _cmsAllocMemPluginChunk(ctx, NULL);
- _cmsAllocInterpPluginChunk(ctx, NULL);
- _cmsAllocCurvesPluginChunk(ctx, NULL);
- _cmsAllocFormattersPluginChunk(ctx, NULL);
- _cmsAllocTagTypePluginChunk(ctx, NULL);
- _cmsAllocMPETypePluginChunk(ctx, NULL);
- _cmsAllocTagPluginChunk(ctx, NULL);
- _cmsAllocIntentsPluginChunk(ctx, NULL);
- _cmsAllocOptimizationPluginChunk(ctx, NULL);
- _cmsAllocTransformPluginChunk(ctx, NULL);
- _cmsAllocMutexPluginChunk(ctx, NULL);
- _cmsAllocParallelizationPluginChunk(ctx, NULL);
-
- // Setup the plug-ins
- if (!cmsPluginTHR(ctx, Plugin)) {
-
- cmsDeleteContext(ctx);
- return NULL;
- }
-
- return (cmsContext) ctx;
-}
-
-// Duplicates a context with all associated plug-ins.
-// Caller may specify an optional pointer to user-defined
-// data that will be forwarded to plug-ins and logger.
-cmsContext CMSEXPORT cmsDupContext(cmsContext ContextID, void* NewUserData)
-{
- int i;
- struct _cmsContext_struct* ctx;
- const struct _cmsContext_struct* src = _cmsGetContext(ContextID);
-
- void* userData = (NewUserData != NULL) ? NewUserData : src -> chunks[UserPtr];
-
-
- ctx = (struct _cmsContext_struct*) _cmsMalloc(ContextID, sizeof(struct _cmsContext_struct));
- if (ctx == NULL)
- return NULL; // Something very wrong happened
-
- if (!InitContextMutex()) return NULL;
-
- // Setup default memory allocators
- memcpy(&ctx->DefaultMemoryManager, &src->DefaultMemoryManager, sizeof(ctx->DefaultMemoryManager));
-
- // Maintain the linked list
- _cmsEnterCriticalSectionPrimitive(&_cmsContextPoolHeadMutex);
- ctx ->Next = _cmsContextPoolHead;
- _cmsContextPoolHead = ctx;
- _cmsLeaveCriticalSectionPrimitive(&_cmsContextPoolHeadMutex);
-
- ctx ->chunks[UserPtr] = userData;
- ctx ->chunks[MemPlugin] = &ctx->DefaultMemoryManager;
-
- ctx ->MemPool = _cmsCreateSubAlloc(ctx, 22 * sizeof(void*));
- if (ctx ->MemPool == NULL) {
-
- cmsDeleteContext(ctx);
- return NULL;
- }
-
- // Allocate all required chunks.
- _cmsAllocLogErrorChunk(ctx, src);
- _cmsAllocAlarmCodesChunk(ctx, src);
- _cmsAllocAdaptationStateChunk(ctx, src);
- _cmsAllocMemPluginChunk(ctx, src);
- _cmsAllocInterpPluginChunk(ctx, src);
- _cmsAllocCurvesPluginChunk(ctx, src);
- _cmsAllocFormattersPluginChunk(ctx, src);
- _cmsAllocTagTypePluginChunk(ctx, src);
- _cmsAllocMPETypePluginChunk(ctx, src);
- _cmsAllocTagPluginChunk(ctx, src);
- _cmsAllocIntentsPluginChunk(ctx, src);
- _cmsAllocOptimizationPluginChunk(ctx, src);
- _cmsAllocTransformPluginChunk(ctx, src);
- _cmsAllocMutexPluginChunk(ctx, src);
- _cmsAllocParallelizationPluginChunk(ctx, src);
-
- // Make sure no one failed
- for (i=Logger; i < MemoryClientMax; i++) {
-
- if (src ->chunks[i] == NULL) {
- cmsDeleteContext((cmsContext) ctx);
- return NULL;
- }
- }
-
- return (cmsContext) ctx;
-}
-
-
-// Frees any resources associated with the given context,
-// and destroys the context placeholder.
-// The ContextID can no longer be used in any THR operation.
-void CMSEXPORT cmsDeleteContext(cmsContext ContextID)
-{
- if (ContextID == NULL) {
-
- cmsUnregisterPlugins();
- if (globalContext.MemPool != NULL)
- _cmsSubAllocDestroy(globalContext.MemPool);
- globalContext.MemPool = NULL;
- }
- else {
-
- struct _cmsContext_struct* ctx = (struct _cmsContext_struct*) ContextID;
- struct _cmsContext_struct fakeContext;
- struct _cmsContext_struct* prev;
-
-
- InitContextMutex();
-
- memcpy(&fakeContext.DefaultMemoryManager, &ctx->DefaultMemoryManager, sizeof(ctx->DefaultMemoryManager));
-
- fakeContext.chunks[UserPtr] = ctx ->chunks[UserPtr];
- fakeContext.chunks[MemPlugin] = &fakeContext.DefaultMemoryManager;
-
- // Get rid of plugins
- cmsUnregisterPluginsTHR(ContextID);
-
- // Since all memory is allocated in the private pool, all what we need to do is destroy the pool
- if (ctx -> MemPool != NULL)
- _cmsSubAllocDestroy(ctx ->MemPool);
- ctx -> MemPool = NULL;
-
- // Maintain list
- _cmsEnterCriticalSectionPrimitive(&_cmsContextPoolHeadMutex);
- if (_cmsContextPoolHead == ctx) {
-
- _cmsContextPoolHead = ctx->Next;
- }
- else {
-
- // Search for previous
- for (prev = _cmsContextPoolHead;
- prev != NULL;
- prev = prev ->Next)
- {
- if (prev -> Next == ctx) {
- prev -> Next = ctx ->Next;
- break;
- }
- }
- }
- _cmsLeaveCriticalSectionPrimitive(&_cmsContextPoolHeadMutex);
-
- // free the memory block itself
- _cmsFree(&fakeContext, ctx);
- }
-}
-
-// Returns the user data associated to the given ContextID, or NULL if no user data was attached on context creation
-void* CMSEXPORT cmsGetContextUserData(cmsContext ContextID)
-{
- return _cmsContextGetClientChunk(ContextID, UserPtr);
-}
-
-
-// Use context mutex to provide thread-safe time
-cmsBool _cmsGetTime(struct tm* ptr_time)
-{
- struct tm* t;
-#if defined(HAVE_GMTIME_R) || defined(HAVE_GMTIME_S)
- struct tm tm;
-#endif
-
- time_t now = time(NULL);
-
-#ifdef HAVE_GMTIME_R
- t = gmtime_r(&now, &tm);
-#elif defined(HAVE_GMTIME_S)
- t = gmtime_s(&tm, &now) == 0 ? &tm : NULL;
-#else
- if (!InitContextMutex()) return FALSE;
-
- _cmsEnterCriticalSectionPrimitive(&_cmsContextPoolHeadMutex);
- t = gmtime(&now);
- _cmsLeaveCriticalSectionPrimitive(&_cmsContextPoolHeadMutex);
-#endif
-
- if (t == NULL)
- return FALSE;
- else {
- *ptr_time = *t;
- return TRUE;
- }
-}
diff --git a/contrib/libs/lcms2/src/cmsps2.c b/contrib/libs/lcms2/src/cmsps2.c
deleted file mode 100644
index eea1629d35..0000000000
--- a/contrib/libs/lcms2/src/cmsps2.c
+++ /dev/null
@@ -1,1583 +0,0 @@
-//---------------------------------------------------------------------------------
-//
-// Little Color Management System
-// Copyright (c) 1998-2023 Marti Maria Saguer
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//---------------------------------------------------------------------------------
-//
-
-#include "lcms2_internal.h"
-
-// PostScript ColorRenderingDictionary and ColorSpaceArray
-
-
-#define MAXPSCOLS 60 // Columns on tables
-
-/*
- Implementation
- --------------
-
- PostScript does use XYZ as its internal PCS. But since PostScript
- interpolation tables are limited to 8 bits, I use Lab as a way to
- improve the accuracy, favoring perceptual results. So, for the creation
- of each CRD, CSA the profiles are converted to Lab via a device
- link between profile -> Lab or Lab -> profile. The PS code necessary to
- convert Lab <-> XYZ is also included.
-
-
-
- Color Space Arrays (CSA)
- ==================================================================================
-
- In order to obtain precision, code chooses between three ways to implement
- the device -> XYZ transform. These cases identifies monochrome profiles (often
- implemented as a set of curves), matrix-shaper and Pipeline-based.
-
- Monochrome
- -----------
-
- This is implemented as /CIEBasedA CSA. The prelinearization curve is
- placed into /DecodeA section, and matrix equals to D50. Since here is
- no interpolation tables, I do the conversion directly to XYZ
-
- NOTE: CLUT-based monochrome profiles are NOT supported. So, cmsFLAGS_MATRIXINPUT
- flag is forced on such profiles.
-
- [ /CIEBasedA
- <<
- /DecodeA { transfer function } bind
- /MatrixA [D50]
- /RangeLMN [ 0.0 cmsD50X 0.0 cmsD50Y 0.0 cmsD50Z ]
- /WhitePoint [D50]
- /BlackPoint [BP]
- /RenderingIntent (intent)
- >>
- ]
-
- On simpler profiles, the PCS is already XYZ, so no conversion is required.
-
-
- Matrix-shaper based
- -------------------
-
- This is implemented both with /CIEBasedABC or /CIEBasedDEF depending on the
- profile implementation. Since here there are no interpolation tables, I do
- the conversion directly to XYZ
-
-
-
- [ /CIEBasedABC
- <<
- /DecodeABC [ {transfer1} {transfer2} {transfer3} ]
- /MatrixABC [Matrix]
- /RangeLMN [ 0.0 cmsD50X 0.0 cmsD50Y 0.0 cmsD50Z ]
- /DecodeLMN [ { / 2} dup dup ]
- /WhitePoint [D50]
- /BlackPoint [BP]
- /RenderingIntent (intent)
- >>
- ]
-
-
- CLUT based
- ----------
-
- Lab is used in such cases.
-
- [ /CIEBasedDEF
- <<
- /DecodeDEF [ <prelinearization> ]
- /Table [ p p p [<...>]]
- /RangeABC [ 0 1 0 1 0 1]
- /DecodeABC[ <postlinearization> ]
- /RangeLMN [ -0.236 1.254 0 1 -0.635 1.640 ]
- % -128/500 1+127/500 0 1 -127/200 1+128/200
- /MatrixABC [ 1 1 1 1 0 0 0 0 -1]
- /WhitePoint [D50]
- /BlackPoint [BP]
- /RenderingIntent (intent)
- ]
-
-
- Color Rendering Dictionaries (CRD)
- ==================================
- These are always implemented as CLUT, and always are using Lab. Since CRD are expected to
- be used as resources, the code adds the definition as well.
-
- <<
- /ColorRenderingType 1
- /WhitePoint [ D50 ]
- /BlackPoint [BP]
- /MatrixPQR [ Bradford ]
- /RangePQR [-0.125 1.375 -0.125 1.375 -0.125 1.375 ]
- /TransformPQR [
- {4 index 3 get div 2 index 3 get mul exch pop exch pop exch pop exch pop } bind
- {4 index 4 get div 2 index 4 get mul exch pop exch pop exch pop exch pop } bind
- {4 index 5 get div 2 index 5 get mul exch pop exch pop exch pop exch pop } bind
- ]
- /MatrixABC <...>
- /EncodeABC <...>
- /RangeABC <.. used for XYZ -> Lab>
- /EncodeLMN
- /RenderTable [ p p p [<...>]]
-
- /RenderingIntent (Perceptual)
- >>
- /Current exch /ColorRendering defineresource pop
-
-
- The following stages are used to convert from XYZ to Lab
- --------------------------------------------------------
-
- Input is given at LMN stage on X, Y, Z
-
- Encode LMN gives us f(X/Xn), f(Y/Yn), f(Z/Zn)
-
- /EncodeLMN [
-
- { 0.964200 div dup 0.008856 le {7.787 mul 16 116 div add}{1 3 div exp} ifelse } bind
- { 1.000000 div dup 0.008856 le {7.787 mul 16 116 div add}{1 3 div exp} ifelse } bind
- { 0.824900 div dup 0.008856 le {7.787 mul 16 116 div add}{1 3 div exp} ifelse } bind
-
- ]
-
-
- MatrixABC is used to compute f(Y/Yn), f(X/Xn) - f(Y/Yn), f(Y/Yn) - f(Z/Zn)
-
- | 0 1 0|
- | 1 -1 0|
- | 0 1 -1|
-
- /MatrixABC [ 0 1 0 1 -1 1 0 0 -1 ]
-
- EncodeABC finally gives Lab values.
-
- /EncodeABC [
- { 116 mul 16 sub 100 div } bind
- { 500 mul 128 add 255 div } bind
- { 200 mul 128 add 255 div } bind
- ]
-
- The following stages are used to convert Lab to XYZ
- ----------------------------------------------------
-
- /RangeABC [ 0 1 0 1 0 1]
- /DecodeABC [ { 100 mul 16 add 116 div } bind
- { 255 mul 128 sub 500 div } bind
- { 255 mul 128 sub 200 div } bind
- ]
-
- /MatrixABC [ 1 1 1 1 0 0 0 0 -1]
- /DecodeLMN [
- {dup 6 29 div ge {dup dup mul mul} {4 29 div sub 108 841 div mul} ifelse 0.964200 mul} bind
- {dup 6 29 div ge {dup dup mul mul} {4 29 div sub 108 841 div mul} ifelse } bind
- {dup 6 29 div ge {dup dup mul mul} {4 29 div sub 108 841 div mul} ifelse 0.824900 mul} bind
- ]
-
-
-*/
-
-/*
-
- PostScript algorithms discussion.
- =========================================================================================================
-
- 1D interpolation algorithm
-
-
- 1D interpolation (float)
- ------------------------
-
- val2 = Domain * Value;
-
- cell0 = (int) floor(val2);
- cell1 = (int) ceil(val2);
-
- rest = val2 - cell0;
-
- y0 = LutTable[cell0] ;
- y1 = LutTable[cell1] ;
-
- y = y0 + (y1 - y0) * rest;
-
-
-
- PostScript code Stack
- ================================================
-
- { % v
- <check 0..1.0>
- [array] % v tab
- dup % v tab tab
- length 1 sub % v tab dom
-
- 3 -1 roll % tab dom v
-
- mul % tab val2
- dup % tab val2 val2
- dup % tab val2 val2 val2
- floor cvi % tab val2 val2 cell0
- exch % tab val2 cell0 val2
- ceiling cvi % tab val2 cell0 cell1
-
- 3 index % tab val2 cell0 cell1 tab
- exch % tab val2 cell0 tab cell1
- get % tab val2 cell0 y1
-
- 4 -1 roll % val2 cell0 y1 tab
- 3 -1 roll % val2 y1 tab cell0
- get % val2 y1 y0
-
- dup % val2 y1 y0 y0
- 3 1 roll % val2 y0 y1 y0
-
- sub % val2 y0 (y1-y0)
- 3 -1 roll % y0 (y1-y0) val2
- dup % y0 (y1-y0) val2 val2
- floor cvi % y0 (y1-y0) val2 floor(val2)
- sub % y0 (y1-y0) rest
- mul % y0 t1
- add % y
- 65535 div % result
-
- } bind
-
-
-*/
-
-
-// This struct holds the memory block currently being write
-typedef struct {
- _cmsStageCLutData* Pipeline;
- cmsIOHANDLER* m;
-
- int FirstComponent;
- int SecondComponent;
-
- const char* PreMaj;
- const char* PostMaj;
- const char* PreMin;
- const char* PostMin;
-
- int FixWhite; // Force mapping of pure white
-
- cmsColorSpaceSignature ColorSpace; // ColorSpace of profile
-
-
-} cmsPsSamplerCargo;
-
-static int _cmsPSActualColumn = 0;
-
-
-// Convert to byte
-static
-cmsUInt8Number Word2Byte(cmsUInt16Number w)
-{
- return (cmsUInt8Number) floor((cmsFloat64Number) w / 257.0 + 0.5);
-}
-
-
-// Write a cooked byte
-static
-void WriteByte(cmsIOHANDLER* m, cmsUInt8Number b)
-{
- _cmsIOPrintf(m, "%02x", b);
- _cmsPSActualColumn += 2;
-
- if (_cmsPSActualColumn > MAXPSCOLS) {
-
- _cmsIOPrintf(m, "\n");
- _cmsPSActualColumn = 0;
- }
-}
-
-// ----------------------------------------------------------------- PostScript generation
-
-
-// Removes offending carriage returns
-
-static
-char* RemoveCR(const char* txt)
-{
- static char Buffer[2048];
- char* pt;
-
- strncpy(Buffer, txt, 2047);
- Buffer[2047] = 0;
- for (pt = Buffer; *pt; pt++)
- if (*pt == '\n' || *pt == '\r') *pt = ' ';
-
- return Buffer;
-
-}
-
-static
-void EmitHeader(cmsIOHANDLER* m, const char* Title, cmsHPROFILE hProfile)
-{
- time_t timer;
- cmsMLU *Description, *Copyright;
- char DescASCII[256], CopyrightASCII[256];
-
- time(&timer);
-
- Description = (cmsMLU*) cmsReadTag(hProfile, cmsSigProfileDescriptionTag);
- Copyright = (cmsMLU*) cmsReadTag(hProfile, cmsSigCopyrightTag);
-
- DescASCII[0] = DescASCII[255] = 0;
- CopyrightASCII[0] = CopyrightASCII[255] = 0;
-
- if (Description != NULL) cmsMLUgetASCII(Description, cmsNoLanguage, cmsNoCountry, DescASCII, 255);
- if (Copyright != NULL) cmsMLUgetASCII(Copyright, cmsNoLanguage, cmsNoCountry, CopyrightASCII, 255);
-
- _cmsIOPrintf(m, "%%!PS-Adobe-3.0\n");
- _cmsIOPrintf(m, "%%\n");
- _cmsIOPrintf(m, "%% %s\n", Title);
- _cmsIOPrintf(m, "%% Source: %s\n", RemoveCR(DescASCII));
- _cmsIOPrintf(m, "%% %s\n", RemoveCR(CopyrightASCII));
- _cmsIOPrintf(m, "%% Created: %s", ctime(&timer)); // ctime appends a \n!!!
- _cmsIOPrintf(m, "%%\n");
- _cmsIOPrintf(m, "%%%%BeginResource\n");
-
-}
-
-
-// Emits White & Black point. White point is always D50, Black point is the device
-// Black point adapted to D50.
-
-static
-void EmitWhiteBlackD50(cmsIOHANDLER* m, cmsCIEXYZ* BlackPoint)
-{
-
- _cmsIOPrintf(m, "/BlackPoint [%f %f %f]\n", BlackPoint -> X,
- BlackPoint -> Y,
- BlackPoint -> Z);
-
- _cmsIOPrintf(m, "/WhitePoint [%f %f %f]\n", cmsD50_XYZ()->X,
- cmsD50_XYZ()->Y,
- cmsD50_XYZ()->Z);
-}
-
-
-static
-void EmitRangeCheck(cmsIOHANDLER* m)
-{
- _cmsIOPrintf(m, "dup 0.0 lt { pop 0.0 } if "
- "dup 1.0 gt { pop 1.0 } if ");
-
-}
-
-// Does write the intent
-
-static
-void EmitIntent(cmsIOHANDLER* m, cmsUInt32Number RenderingIntent)
-{
- const char *intent;
-
- switch (RenderingIntent) {
-
- case INTENT_PERCEPTUAL: intent = "Perceptual"; break;
- case INTENT_RELATIVE_COLORIMETRIC: intent = "RelativeColorimetric"; break;
- case INTENT_ABSOLUTE_COLORIMETRIC: intent = "AbsoluteColorimetric"; break;
- case INTENT_SATURATION: intent = "Saturation"; break;
-
- default: intent = "Undefined"; break;
- }
-
- _cmsIOPrintf(m, "/RenderingIntent (%s)\n", intent );
-}
-
-//
-// Convert L* to Y
-//
-// Y = Yn*[ (L* + 16) / 116] ^ 3 if (L*) >= 6 / 29
-// = Yn*( L* / 116) / 7.787 if (L*) < 6 / 29
-//
-
-// Lab -> XYZ, see the discussion above
-
-static
-void EmitLab2XYZ(cmsIOHANDLER* m)
-{
- _cmsIOPrintf(m, "/RangeABC [ 0 1 0 1 0 1]\n");
- _cmsIOPrintf(m, "/DecodeABC [\n");
- _cmsIOPrintf(m, "{100 mul 16 add 116 div } bind\n");
- _cmsIOPrintf(m, "{255 mul 128 sub 500 div } bind\n");
- _cmsIOPrintf(m, "{255 mul 128 sub 200 div } bind\n");
- _cmsIOPrintf(m, "]\n");
- _cmsIOPrintf(m, "/MatrixABC [ 1 1 1 1 0 0 0 0 -1]\n");
- _cmsIOPrintf(m, "/RangeLMN [ -0.236 1.254 0 1 -0.635 1.640 ]\n");
- _cmsIOPrintf(m, "/DecodeLMN [\n");
- _cmsIOPrintf(m, "{dup 6 29 div ge {dup dup mul mul} {4 29 div sub 108 841 div mul} ifelse 0.964200 mul} bind\n");
- _cmsIOPrintf(m, "{dup 6 29 div ge {dup dup mul mul} {4 29 div sub 108 841 div mul} ifelse } bind\n");
- _cmsIOPrintf(m, "{dup 6 29 div ge {dup dup mul mul} {4 29 div sub 108 841 div mul} ifelse 0.824900 mul} bind\n");
- _cmsIOPrintf(m, "]\n");
-}
-
-
-
-// Outputs a table of words. It does use 16 bits
-
-static
-void Emit1Gamma(cmsIOHANDLER* m, cmsToneCurve* Table)
-{
- cmsUInt32Number i;
- cmsFloat64Number gamma;
-
- /**
- * On error, empty tables or lienar assume gamma 1.0
- */
- if (Table == NULL ||
- Table->nEntries <= 0 ||
- cmsIsToneCurveLinear(Table)) {
-
- _cmsIOPrintf(m, "{ 1 } bind ");
- return;
- }
-
-
- // Check if is really an exponential. If so, emit "exp"
- gamma = cmsEstimateGamma(Table, 0.001);
- if (gamma > 0) {
- _cmsIOPrintf(m, "{ %g exp } bind ", gamma);
- return;
- }
-
- _cmsIOPrintf(m, "{ ");
-
- // Bounds check
- EmitRangeCheck(m);
-
- // Emit intepolation code
-
- // PostScript code Stack
- // =============== ========================
- // v
- _cmsIOPrintf(m, " [");
-
- for (i=0; i < Table->nEntries; i++) {
- if (i % 10 == 0)
- _cmsIOPrintf(m, "\n ");
- _cmsIOPrintf(m, "%d ", Table->Table16[i]);
- }
-
- _cmsIOPrintf(m, "] "); // v tab
-
- _cmsIOPrintf(m, "dup "); // v tab tab
- _cmsIOPrintf(m, "length 1 sub "); // v tab dom
- _cmsIOPrintf(m, "3 -1 roll "); // tab dom v
- _cmsIOPrintf(m, "mul "); // tab val2
- _cmsIOPrintf(m, "dup "); // tab val2 val2
- _cmsIOPrintf(m, "dup "); // tab val2 val2 val2
- _cmsIOPrintf(m, "floor cvi "); // tab val2 val2 cell0
- _cmsIOPrintf(m, "exch "); // tab val2 cell0 val2
- _cmsIOPrintf(m, "ceiling cvi "); // tab val2 cell0 cell1
- _cmsIOPrintf(m, "3 index "); // tab val2 cell0 cell1 tab
- _cmsIOPrintf(m, "exch "); // tab val2 cell0 tab cell1
- _cmsIOPrintf(m, "get\n "); // tab val2 cell0 y1
- _cmsIOPrintf(m, "4 -1 roll "); // val2 cell0 y1 tab
- _cmsIOPrintf(m, "3 -1 roll "); // val2 y1 tab cell0
- _cmsIOPrintf(m, "get "); // val2 y1 y0
- _cmsIOPrintf(m, "dup "); // val2 y1 y0 y0
- _cmsIOPrintf(m, "3 1 roll "); // val2 y0 y1 y0
- _cmsIOPrintf(m, "sub "); // val2 y0 (y1-y0)
- _cmsIOPrintf(m, "3 -1 roll "); // y0 (y1-y0) val2
- _cmsIOPrintf(m, "dup "); // y0 (y1-y0) val2 val2
- _cmsIOPrintf(m, "floor cvi "); // y0 (y1-y0) val2 floor(val2)
- _cmsIOPrintf(m, "sub "); // y0 (y1-y0) rest
- _cmsIOPrintf(m, "mul "); // y0 t1
- _cmsIOPrintf(m, "add "); // y
- _cmsIOPrintf(m, "65535 div\n"); // result
-
- _cmsIOPrintf(m, " } bind ");
-}
-
-
-// Compare gamma table
-
-static
-cmsBool GammaTableEquals(cmsUInt16Number* g1, cmsUInt16Number* g2, cmsUInt32Number nG1, cmsUInt32Number nG2)
-{
- if (nG1 != nG2) return FALSE;
- return memcmp(g1, g2, nG1 * sizeof(cmsUInt16Number)) == 0;
-}
-
-
-// Does write a set of gamma curves
-
-static
-void EmitNGamma(cmsIOHANDLER* m, cmsUInt32Number n, cmsToneCurve* g[])
-{
- cmsUInt32Number i;
-
-
- for( i=0; i < n; i++ )
- {
- if (g[i] == NULL) return; // Error
-
- if (i > 0 && GammaTableEquals(g[i-1]->Table16, g[i]->Table16, g[i-1]->nEntries, g[i]->nEntries)) {
-
- _cmsIOPrintf(m, "dup ");
- }
- else {
- Emit1Gamma(m, g[i]);
- }
- }
-
-}
-
-
-// Following code dumps a LUT onto memory stream
-
-
-// This is the sampler. Intended to work in SAMPLER_INSPECT mode,
-// that is, the callback will be called for each knot with
-//
-// In[] The grid location coordinates, normalized to 0..ffff
-// Out[] The Pipeline values, normalized to 0..ffff
-//
-// Returning a value other than 0 does terminate the sampling process
-//
-// Each row contains Pipeline values for all but first component. So, I
-// detect row changing by keeping a copy of last value of first
-// component. -1 is used to mark beginning of whole block.
-
-static
-int OutputValueSampler(CMSREGISTER const cmsUInt16Number In[], CMSREGISTER cmsUInt16Number Out[], CMSREGISTER void* Cargo)
-{
- cmsPsSamplerCargo* sc = (cmsPsSamplerCargo*) Cargo;
- cmsUInt32Number i;
-
-
- if (sc -> FixWhite) {
-
- if (In[0] == 0xFFFF) { // Only in L* = 100, ab = [-8..8]
-
- if ((In[1] >= 0x7800 && In[1] <= 0x8800) &&
- (In[2] >= 0x7800 && In[2] <= 0x8800)) {
-
- cmsUInt16Number* Black;
- cmsUInt16Number* White;
- cmsUInt32Number nOutputs;
-
- if (!_cmsEndPointsBySpace(sc ->ColorSpace, &White, &Black, &nOutputs))
- return 0;
-
- for (i=0; i < nOutputs; i++)
- Out[i] = White[i];
- }
-
-
- }
- }
-
-
- // Hadle the parenthesis on rows
-
- if (In[0] != sc ->FirstComponent) {
-
- if (sc ->FirstComponent != -1) {
-
- _cmsIOPrintf(sc ->m, sc ->PostMin);
- sc ->SecondComponent = -1;
- _cmsIOPrintf(sc ->m, sc ->PostMaj);
- }
-
- // Begin block
- _cmsPSActualColumn = 0;
-
- _cmsIOPrintf(sc ->m, sc ->PreMaj);
- sc ->FirstComponent = In[0];
- }
-
-
- if (In[1] != sc ->SecondComponent) {
-
- if (sc ->SecondComponent != -1) {
-
- _cmsIOPrintf(sc ->m, sc ->PostMin);
- }
-
- _cmsIOPrintf(sc ->m, sc ->PreMin);
- sc ->SecondComponent = In[1];
- }
-
- // Dump table.
-
- for (i=0; i < sc -> Pipeline ->Params->nOutputs; i++) {
-
- cmsUInt16Number wWordOut = Out[i];
- cmsUInt8Number wByteOut; // Value as byte
-
-
- // We always deal with Lab4
-
- wByteOut = Word2Byte(wWordOut);
- WriteByte(sc -> m, wByteOut);
- }
-
- return 1;
-}
-
-// Writes a Pipeline on memstream. Could be 8 or 16 bits based
-
-static
-void WriteCLUT(cmsIOHANDLER* m, cmsStage* mpe, const char* PreMaj,
- const char* PostMaj,
- const char* PreMin,
- const char* PostMin,
- int FixWhite,
- cmsColorSpaceSignature ColorSpace)
-{
- cmsUInt32Number i;
- cmsPsSamplerCargo sc;
-
- sc.FirstComponent = -1;
- sc.SecondComponent = -1;
- sc.Pipeline = (_cmsStageCLutData *) mpe ->Data;
- sc.m = m;
- sc.PreMaj = PreMaj;
- sc.PostMaj= PostMaj;
-
- sc.PreMin = PreMin;
- sc.PostMin = PostMin;
- sc.FixWhite = FixWhite;
- sc.ColorSpace = ColorSpace;
-
- if (sc.Pipeline != NULL && sc.Pipeline->Params != NULL) {
-
- _cmsIOPrintf(m, "[");
-
- for (i = 0; i < sc.Pipeline->Params->nInputs; i++)
- _cmsIOPrintf(m, " %d ", sc.Pipeline->Params->nSamples[i]);
-
- _cmsIOPrintf(m, " [\n");
-
- cmsStageSampleCLut16bit(mpe, OutputValueSampler, (void*)&sc, SAMPLER_INSPECT);
-
- _cmsIOPrintf(m, PostMin);
- _cmsIOPrintf(m, PostMaj);
- _cmsIOPrintf(m, "] ");
- }
-
-}
-
-
-// Dumps CIEBasedA Color Space Array
-
-static
-int EmitCIEBasedA(cmsIOHANDLER* m, cmsToneCurve* Curve, cmsCIEXYZ* BlackPoint)
-{
-
- _cmsIOPrintf(m, "[ /CIEBasedA\n");
- _cmsIOPrintf(m, " <<\n");
-
- _cmsIOPrintf(m, "/DecodeA ");
-
- Emit1Gamma(m, Curve);
-
- _cmsIOPrintf(m, " \n");
-
- _cmsIOPrintf(m, "/MatrixA [ 0.9642 1.0000 0.8249 ]\n");
- _cmsIOPrintf(m, "/RangeLMN [ 0.0 0.9642 0.0 1.0000 0.0 0.8249 ]\n");
-
- EmitWhiteBlackD50(m, BlackPoint);
- EmitIntent(m, INTENT_PERCEPTUAL);
-
- _cmsIOPrintf(m, ">>\n");
- _cmsIOPrintf(m, "]\n");
-
- return 1;
-}
-
-
-// Dumps CIEBasedABC Color Space Array
-
-static
-int EmitCIEBasedABC(cmsIOHANDLER* m, cmsFloat64Number* Matrix, cmsToneCurve** CurveSet, cmsCIEXYZ* BlackPoint)
-{
- int i;
-
- _cmsIOPrintf(m, "[ /CIEBasedABC\n");
- _cmsIOPrintf(m, "<<\n");
- _cmsIOPrintf(m, "/DecodeABC [ ");
-
- EmitNGamma(m, 3, CurveSet);
-
- _cmsIOPrintf(m, "]\n");
-
- _cmsIOPrintf(m, "/MatrixABC [ " );
-
- for( i=0; i < 3; i++ ) {
-
- _cmsIOPrintf(m, "%.6f %.6f %.6f ", Matrix[i + 3*0],
- Matrix[i + 3*1],
- Matrix[i + 3*2]);
- }
-
-
- _cmsIOPrintf(m, "]\n");
-
- _cmsIOPrintf(m, "/RangeLMN [ 0.0 0.9642 0.0 1.0000 0.0 0.8249 ]\n");
-
- EmitWhiteBlackD50(m, BlackPoint);
- EmitIntent(m, INTENT_PERCEPTUAL);
-
- _cmsIOPrintf(m, ">>\n");
- _cmsIOPrintf(m, "]\n");
-
-
- return 1;
-}
-
-
-static
-int EmitCIEBasedDEF(cmsIOHANDLER* m, cmsPipeline* Pipeline, cmsUInt32Number Intent, cmsCIEXYZ* BlackPoint)
-{
- const char* PreMaj;
- const char* PostMaj;
- const char* PreMin, *PostMin;
- cmsStage* mpe;
-
- mpe = Pipeline->Elements;
-
- switch (cmsStageInputChannels(mpe)) {
- case 3:
- _cmsIOPrintf(m, "[ /CIEBasedDEF\n");
- PreMaj = "<";
- PostMaj = ">\n";
- PreMin = PostMin = "";
- break;
-
- case 4:
- _cmsIOPrintf(m, "[ /CIEBasedDEFG\n");
- PreMaj = "[";
- PostMaj = "]\n";
- PreMin = "<";
- PostMin = ">\n";
- break;
-
- default:
- return 0;
-
- }
-
- _cmsIOPrintf(m, "<<\n");
-
- if (cmsStageType(mpe) == cmsSigCurveSetElemType) {
-
- _cmsIOPrintf(m, "/DecodeDEF [ ");
- EmitNGamma(m, cmsStageOutputChannels(mpe), _cmsStageGetPtrToCurveSet(mpe));
- _cmsIOPrintf(m, "]\n");
-
- mpe = mpe ->Next;
- }
-
- if (cmsStageType(mpe) == cmsSigCLutElemType) {
-
- _cmsIOPrintf(m, "/Table ");
- WriteCLUT(m, mpe, PreMaj, PostMaj, PreMin, PostMin, FALSE, (cmsColorSpaceSignature) 0);
- _cmsIOPrintf(m, "]\n");
- }
-
- EmitLab2XYZ(m);
- EmitWhiteBlackD50(m, BlackPoint);
- EmitIntent(m, Intent);
-
- _cmsIOPrintf(m, " >>\n");
- _cmsIOPrintf(m, "]\n");
-
- return 1;
-}
-
-// Generates a curve from a gray profile
-
-static
-cmsToneCurve* ExtractGray2Y(cmsContext ContextID, cmsHPROFILE hProfile, cmsUInt32Number Intent)
-{
- cmsToneCurve* Out = cmsBuildTabulatedToneCurve16(ContextID, 256, NULL);
- cmsHPROFILE hXYZ = cmsCreateXYZProfile();
- cmsHTRANSFORM xform = cmsCreateTransformTHR(ContextID, hProfile, TYPE_GRAY_8, hXYZ, TYPE_XYZ_DBL, Intent, cmsFLAGS_NOOPTIMIZE);
- int i;
-
- if (Out != NULL && xform != NULL) {
- for (i=0; i < 256; i++) {
-
- cmsUInt8Number Gray = (cmsUInt8Number) i;
- cmsCIEXYZ XYZ;
-
- cmsDoTransform(xform, &Gray, &XYZ, 1);
-
- Out ->Table16[i] =_cmsQuickSaturateWord(XYZ.Y * 65535.0);
- }
- }
-
- if (xform) cmsDeleteTransform(xform);
- if (hXYZ) cmsCloseProfile(hXYZ);
- return Out;
-}
-
-
-
-// Because PostScript has only 8 bits in /Table, we should use
-// a more perceptually uniform space... I do choose Lab.
-
-static
-int WriteInputLUT(cmsIOHANDLER* m, cmsHPROFILE hProfile, cmsUInt32Number Intent, cmsUInt32Number dwFlags)
-{
- cmsHPROFILE hLab;
- cmsHTRANSFORM xform;
- cmsUInt32Number nChannels;
- cmsUInt32Number InputFormat;
- int rc;
- cmsHPROFILE Profiles[2];
- cmsCIEXYZ BlackPointAdaptedToD50;
-
- // Does create a device-link based transform.
- // The DeviceLink is next dumped as working CSA.
-
- InputFormat = cmsFormatterForColorspaceOfProfile(hProfile, 2, FALSE);
- nChannels = T_CHANNELS(InputFormat);
-
-
- cmsDetectBlackPoint(&BlackPointAdaptedToD50, hProfile, Intent, 0);
-
- // Adjust output to Lab4
- hLab = cmsCreateLab4ProfileTHR(m ->ContextID, NULL);
-
- Profiles[0] = hProfile;
- Profiles[1] = hLab;
-
- xform = cmsCreateMultiprofileTransform(Profiles, 2, InputFormat, TYPE_Lab_DBL, Intent, 0);
- cmsCloseProfile(hLab);
-
- if (xform == NULL) {
-
- cmsSignalError(m ->ContextID, cmsERROR_COLORSPACE_CHECK, "Cannot create transform Profile -> Lab");
- return 0;
- }
-
- // Only 1, 3 and 4 channels are allowed
-
- switch (nChannels) {
-
- case 1: {
- cmsToneCurve* Gray2Y = ExtractGray2Y(m ->ContextID, hProfile, Intent);
- EmitCIEBasedA(m, Gray2Y, &BlackPointAdaptedToD50);
- cmsFreeToneCurve(Gray2Y);
- }
- break;
-
- case 3:
- case 4: {
- cmsUInt32Number OutFrm = TYPE_Lab_16;
- cmsPipeline* DeviceLink;
- _cmsTRANSFORM* v = (_cmsTRANSFORM*) xform;
-
- DeviceLink = cmsPipelineDup(v ->Lut);
- if (DeviceLink == NULL) return 0;
-
- dwFlags |= cmsFLAGS_FORCE_CLUT;
- _cmsOptimizePipeline(m->ContextID, &DeviceLink, Intent, &InputFormat, &OutFrm, &dwFlags);
-
- rc = EmitCIEBasedDEF(m, DeviceLink, Intent, &BlackPointAdaptedToD50);
- cmsPipelineFree(DeviceLink);
- if (rc == 0) return 0;
- }
- break;
-
- default:
-
- cmsSignalError(m ->ContextID, cmsERROR_COLORSPACE_CHECK, "Only 3, 4 channels are supported for CSA. This profile has %d channels.", nChannels);
- return 0;
- }
-
-
- cmsDeleteTransform(xform);
-
- return 1;
-}
-
-static
-cmsFloat64Number* GetPtrToMatrix(const cmsStage* mpe)
-{
- _cmsStageMatrixData* Data = (_cmsStageMatrixData*) mpe ->Data;
-
- return Data -> Double;
-}
-
-
-// Does create CSA based on matrix-shaper. Allowed types are gray and RGB based
-static
-int WriteInputMatrixShaper(cmsIOHANDLER* m, cmsHPROFILE hProfile, cmsStage* Matrix, cmsStage* Shaper)
-{
- cmsColorSpaceSignature ColorSpace;
- int rc;
- cmsCIEXYZ BlackPointAdaptedToD50;
-
- ColorSpace = cmsGetColorSpace(hProfile);
-
- cmsDetectBlackPoint(&BlackPointAdaptedToD50, hProfile, INTENT_RELATIVE_COLORIMETRIC, 0);
-
- if (ColorSpace == cmsSigGrayData) {
-
- cmsToneCurve** ShaperCurve = _cmsStageGetPtrToCurveSet(Shaper);
- rc = EmitCIEBasedA(m, ShaperCurve[0], &BlackPointAdaptedToD50);
-
- }
- else
- if (ColorSpace == cmsSigRgbData) {
-
- cmsMAT3 Mat;
- int i, j;
-
- memmove(&Mat, GetPtrToMatrix(Matrix), sizeof(Mat));
-
- for (i = 0; i < 3; i++)
- for (j = 0; j < 3; j++)
- Mat.v[i].n[j] *= MAX_ENCODEABLE_XYZ;
-
- rc = EmitCIEBasedABC(m, (cmsFloat64Number *) &Mat,
- _cmsStageGetPtrToCurveSet(Shaper),
- &BlackPointAdaptedToD50);
- }
- else {
-
- cmsSignalError(m->ContextID, cmsERROR_COLORSPACE_CHECK, "Profile is not suitable for CSA. Unsupported colorspace.");
- return 0;
- }
-
- return rc;
-}
-
-
-
-// Creates a PostScript color list from a named profile data.
-// This is a HP extension, and it works in Lab instead of XYZ
-
-static
-int WriteNamedColorCSA(cmsIOHANDLER* m, cmsHPROFILE hNamedColor, cmsUInt32Number Intent)
-{
- cmsHTRANSFORM xform;
- cmsHPROFILE hLab;
- cmsUInt32Number i, nColors;
- char ColorName[cmsMAX_PATH];
- cmsNAMEDCOLORLIST* NamedColorList;
-
- hLab = cmsCreateLab4ProfileTHR(m ->ContextID, NULL);
- xform = cmsCreateTransform(hNamedColor, TYPE_NAMED_COLOR_INDEX, hLab, TYPE_Lab_DBL, Intent, 0);
- cmsCloseProfile(hLab);
-
- if (xform == NULL) return 0;
-
- NamedColorList = cmsGetNamedColorList(xform);
- if (NamedColorList == NULL) {
- cmsDeleteTransform(xform);
- return 0;
- }
-
- _cmsIOPrintf(m, "<<\n");
- _cmsIOPrintf(m, "(colorlistcomment) (%s)\n", "Named color CSA");
- _cmsIOPrintf(m, "(Prefix) [ (Pantone ) (PANTONE ) ]\n");
- _cmsIOPrintf(m, "(Suffix) [ ( CV) ( CVC) ( C) ]\n");
-
- nColors = cmsNamedColorCount(NamedColorList);
-
- for (i=0; i < nColors; i++) {
-
- cmsUInt16Number In[1];
- cmsCIELab Lab;
-
- In[0] = (cmsUInt16Number) i;
-
- if (!cmsNamedColorInfo(NamedColorList, i, ColorName, NULL, NULL, NULL, NULL))
- continue;
-
- cmsDoTransform(xform, In, &Lab, 1);
- _cmsIOPrintf(m, " (%s) [ %.3f %.3f %.3f ]\n", ColorName, Lab.L, Lab.a, Lab.b);
- }
-
- _cmsIOPrintf(m, ">>\n");
-
- cmsDeleteTransform(xform);
- return 1;
-}
-
-
-// Does create a Color Space Array on XYZ colorspace for PostScript usage
-static
-cmsUInt32Number GenerateCSA(cmsContext ContextID,
- cmsHPROFILE hProfile,
- cmsUInt32Number Intent,
- cmsUInt32Number dwFlags,
- cmsIOHANDLER* mem)
-{
- cmsUInt32Number dwBytesUsed;
- cmsPipeline* lut = NULL;
- cmsStage* Matrix, *Shaper;
-
-
- // Is a named color profile?
- if (cmsGetDeviceClass(hProfile) == cmsSigNamedColorClass) {
-
- if (!WriteNamedColorCSA(mem, hProfile, Intent)) goto Error;
- }
- else {
-
-
- // Any profile class are allowed (including devicelink), but
- // output (PCS) colorspace must be XYZ or Lab
- cmsColorSpaceSignature ColorSpace = cmsGetPCS(hProfile);
-
- if (ColorSpace != cmsSigXYZData &&
- ColorSpace != cmsSigLabData) {
-
- cmsSignalError(ContextID, cmsERROR_COLORSPACE_CHECK, "Invalid output color space");
- goto Error;
- }
-
-
- // Read the lut with all necessary conversion stages
- lut = _cmsReadInputLUT(hProfile, Intent);
- if (lut == NULL) goto Error;
-
-
- // Tone curves + matrix can be implemented without any LUT
- if (cmsPipelineCheckAndRetreiveStages(lut, 2, cmsSigCurveSetElemType, cmsSigMatrixElemType, &Shaper, &Matrix)) {
-
- if (!WriteInputMatrixShaper(mem, hProfile, Matrix, Shaper)) goto Error;
-
- }
- else {
- // We need a LUT for the rest
- if (!WriteInputLUT(mem, hProfile, Intent, dwFlags)) goto Error;
- }
- }
-
-
- // Done, keep memory usage
- dwBytesUsed = mem ->UsedSpace;
-
- // Get rid of LUT
- if (lut != NULL) cmsPipelineFree(lut);
-
- // Finally, return used byte count
- return dwBytesUsed;
-
-Error:
- if (lut != NULL) cmsPipelineFree(lut);
- return 0;
-}
-
-// ------------------------------------------------------ Color Rendering Dictionary (CRD)
-
-
-
-/*
-
- Black point compensation plus chromatic adaptation:
-
- Step 1 - Chromatic adaptation
- =============================
-
- WPout
- X = ------- PQR
- Wpin
-
- Step 2 - Black point compensation
- =================================
-
- (WPout - BPout)*X - WPout*(BPin - BPout)
- out = ---------------------------------------
- WPout - BPin
-
-
- Algorithm discussion
- ====================
-
- TransformPQR(WPin, BPin, WPout, BPout, PQR)
-
- Wpin,etc= { Xws Yws Zws Pws Qws Rws }
-
-
- Algorithm Stack 0...n
- ===========================================================
- PQR BPout WPout BPin WPin
- 4 index 3 get WPin PQR BPout WPout BPin WPin
- div (PQR/WPin) BPout WPout BPin WPin
- 2 index 3 get WPout (PQR/WPin) BPout WPout BPin WPin
- mult WPout*(PQR/WPin) BPout WPout BPin WPin
-
- 2 index 3 get WPout WPout*(PQR/WPin) BPout WPout BPin WPin
- 2 index 3 get BPout WPout WPout*(PQR/WPin) BPout WPout BPin WPin
- sub (WPout-BPout) WPout*(PQR/WPin) BPout WPout BPin WPin
- mult (WPout-BPout)* WPout*(PQR/WPin) BPout WPout BPin WPin
-
- 2 index 3 get WPout (BPout-WPout)* WPout*(PQR/WPin) BPout WPout BPin WPin
- 4 index 3 get BPin WPout (BPout-WPout)* WPout*(PQR/WPin) BPout WPout BPin WPin
- 3 index 3 get BPout BPin WPout (BPout-WPout)* WPout*(PQR/WPin) BPout WPout BPin WPin
-
- sub (BPin-BPout) WPout (BPout-WPout)* WPout*(PQR/WPin) BPout WPout BPin WPin
- mult (BPin-BPout)*WPout (BPout-WPout)* WPout*(PQR/WPin) BPout WPout BPin WPin
- sub (BPout-WPout)* WPout*(PQR/WPin)-(BPin-BPout)*WPout BPout WPout BPin WPin
-
- 3 index 3 get BPin (BPout-WPout)* WPout*(PQR/WPin)-(BPin-BPout)*WPout BPout WPout BPin WPin
- 3 index 3 get WPout BPin (BPout-WPout)* WPout*(PQR/WPin)-(BPin-BPout)*WPout BPout WPout BPin WPin
- exch
- sub (WPout-BPin) (BPout-WPout)* WPout*(PQR/WPin)-(BPin-BPout)*WPout BPout WPout BPin WPin
- div
-
- exch pop
- exch pop
- exch pop
- exch pop
-
-*/
-
-
-static
-void EmitPQRStage(cmsIOHANDLER* m, cmsHPROFILE hProfile, int DoBPC, int lIsAbsolute)
-{
-
-
- if (lIsAbsolute) {
-
- // For absolute colorimetric intent, encode back to relative
- // and generate a relative Pipeline
-
- // Relative encoding is obtained across XYZpcs*(D50/WhitePoint)
-
- cmsCIEXYZ White;
-
- _cmsReadMediaWhitePoint(&White, hProfile);
-
- _cmsIOPrintf(m,"/MatrixPQR [1 0 0 0 1 0 0 0 1 ]\n");
- _cmsIOPrintf(m,"/RangePQR [ -0.5 2 -0.5 2 -0.5 2 ]\n");
-
- _cmsIOPrintf(m, "%% Absolute colorimetric -- encode to relative to maximize LUT usage\n"
- "/TransformPQR [\n"
- "{0.9642 mul %g div exch pop exch pop exch pop exch pop} bind\n"
- "{1.0000 mul %g div exch pop exch pop exch pop exch pop} bind\n"
- "{0.8249 mul %g div exch pop exch pop exch pop exch pop} bind\n]\n",
- White.X, White.Y, White.Z);
- return;
- }
-
-
- _cmsIOPrintf(m,"%% Bradford Cone Space\n"
- "/MatrixPQR [0.8951 -0.7502 0.0389 0.2664 1.7135 -0.0685 -0.1614 0.0367 1.0296 ] \n");
-
- _cmsIOPrintf(m, "/RangePQR [ -0.5 2 -0.5 2 -0.5 2 ]\n");
-
-
- // No BPC
-
- if (!DoBPC) {
-
- _cmsIOPrintf(m, "%% VonKries-like transform in Bradford Cone Space\n"
- "/TransformPQR [\n"
- "{exch pop exch 3 get mul exch pop exch 3 get div} bind\n"
- "{exch pop exch 4 get mul exch pop exch 4 get div} bind\n"
- "{exch pop exch 5 get mul exch pop exch 5 get div} bind\n]\n");
- } else {
-
- // BPC
-
- _cmsIOPrintf(m, "%% VonKries-like transform in Bradford Cone Space plus BPC\n"
- "/TransformPQR [\n");
-
- _cmsIOPrintf(m, "{4 index 3 get div 2 index 3 get mul "
- "2 index 3 get 2 index 3 get sub mul "
- "2 index 3 get 4 index 3 get 3 index 3 get sub mul sub "
- "3 index 3 get 3 index 3 get exch sub div "
- "exch pop exch pop exch pop exch pop } bind\n");
-
- _cmsIOPrintf(m, "{4 index 4 get div 2 index 4 get mul "
- "2 index 4 get 2 index 4 get sub mul "
- "2 index 4 get 4 index 4 get 3 index 4 get sub mul sub "
- "3 index 4 get 3 index 4 get exch sub div "
- "exch pop exch pop exch pop exch pop } bind\n");
-
- _cmsIOPrintf(m, "{4 index 5 get div 2 index 5 get mul "
- "2 index 5 get 2 index 5 get sub mul "
- "2 index 5 get 4 index 5 get 3 index 5 get sub mul sub "
- "3 index 5 get 3 index 5 get exch sub div "
- "exch pop exch pop exch pop exch pop } bind\n]\n");
-
- }
-}
-
-
-static
-void EmitXYZ2Lab(cmsIOHANDLER* m)
-{
- _cmsIOPrintf(m, "/RangeLMN [ -0.635 2.0 0 2 -0.635 2.0 ]\n");
- _cmsIOPrintf(m, "/EncodeLMN [\n");
- _cmsIOPrintf(m, "{ 0.964200 div dup 0.008856 le {7.787 mul 16 116 div add}{1 3 div exp} ifelse } bind\n");
- _cmsIOPrintf(m, "{ 1.000000 div dup 0.008856 le {7.787 mul 16 116 div add}{1 3 div exp} ifelse } bind\n");
- _cmsIOPrintf(m, "{ 0.824900 div dup 0.008856 le {7.787 mul 16 116 div add}{1 3 div exp} ifelse } bind\n");
- _cmsIOPrintf(m, "]\n");
- _cmsIOPrintf(m, "/MatrixABC [ 0 1 0 1 -1 1 0 0 -1 ]\n");
- _cmsIOPrintf(m, "/EncodeABC [\n");
-
-
- _cmsIOPrintf(m, "{ 116 mul 16 sub 100 div } bind\n");
- _cmsIOPrintf(m, "{ 500 mul 128 add 256 div } bind\n");
- _cmsIOPrintf(m, "{ 200 mul 128 add 256 div } bind\n");
-
-
- _cmsIOPrintf(m, "]\n");
-
-
-}
-
-// Due to impedance mismatch between XYZ and almost all RGB and CMYK spaces
-// I choose to dump LUTS in Lab instead of XYZ. There is still a lot of wasted
-// space on 3D CLUT, but since space seems not to be a problem here, 33 points
-// would give a reasonable accuracy. Note also that CRD tables must operate in
-// 8 bits.
-
-static
-int WriteOutputLUT(cmsIOHANDLER* m, cmsHPROFILE hProfile, cmsUInt32Number Intent, cmsUInt32Number dwFlags)
-{
- cmsHPROFILE hLab;
- cmsHTRANSFORM xform;
- cmsUInt32Number i, nChannels;
- cmsUInt32Number OutputFormat;
- _cmsTRANSFORM* v;
- cmsPipeline* DeviceLink;
- cmsHPROFILE Profiles[3];
- cmsCIEXYZ BlackPointAdaptedToD50;
- cmsBool lDoBPC = (cmsBool) (dwFlags & cmsFLAGS_BLACKPOINTCOMPENSATION);
- cmsBool lFixWhite = (cmsBool) !(dwFlags & cmsFLAGS_NOWHITEONWHITEFIXUP);
- cmsUInt32Number InFrm = TYPE_Lab_16;
- cmsUInt32Number RelativeEncodingIntent;
- cmsColorSpaceSignature ColorSpace;
- cmsStage* first;
-
- hLab = cmsCreateLab4ProfileTHR(m ->ContextID, NULL);
- if (hLab == NULL) return 0;
-
- OutputFormat = cmsFormatterForColorspaceOfProfile(hProfile, 2, FALSE);
- nChannels = T_CHANNELS(OutputFormat);
-
- ColorSpace = cmsGetColorSpace(hProfile);
-
- // For absolute colorimetric, the LUT is encoded as relative in order to preserve precision.
-
- RelativeEncodingIntent = Intent;
- if (RelativeEncodingIntent == INTENT_ABSOLUTE_COLORIMETRIC)
- RelativeEncodingIntent = INTENT_RELATIVE_COLORIMETRIC;
-
-
- // Use V4 Lab always
- Profiles[0] = hLab;
- Profiles[1] = hProfile;
-
- xform = cmsCreateMultiprofileTransformTHR(m ->ContextID,
- Profiles, 2, TYPE_Lab_DBL,
- OutputFormat, RelativeEncodingIntent, 0);
- cmsCloseProfile(hLab);
-
- if (xform == NULL) {
- cmsSignalError(m ->ContextID, cmsERROR_COLORSPACE_CHECK, "Cannot create transform Lab -> Profile in CRD creation");
- return 0;
- }
-
- // Get a copy of the internal devicelink
- v = (_cmsTRANSFORM*) xform;
- DeviceLink = cmsPipelineDup(v ->Lut);
- if (DeviceLink == NULL) {
- cmsDeleteTransform(xform);
- return 0;
- }
-
- // We need a CLUT
- dwFlags |= cmsFLAGS_FORCE_CLUT;
- _cmsOptimizePipeline(m->ContextID, &DeviceLink, RelativeEncodingIntent, &InFrm, &OutputFormat, &dwFlags);
-
- _cmsIOPrintf(m, "<<\n");
- _cmsIOPrintf(m, "/ColorRenderingType 1\n");
-
-
- cmsDetectBlackPoint(&BlackPointAdaptedToD50, hProfile, Intent, 0);
-
- // Emit headers, etc.
- EmitWhiteBlackD50(m, &BlackPointAdaptedToD50);
- EmitPQRStage(m, hProfile, lDoBPC, Intent == INTENT_ABSOLUTE_COLORIMETRIC);
- EmitXYZ2Lab(m);
-
-
- // FIXUP: map Lab (100, 0, 0) to perfect white, because the particular encoding for Lab
- // does map a=b=0 not falling into any specific node. Since range a,b goes -128..127,
- // zero is slightly moved towards right, so assure next node (in L=100 slice) is mapped to
- // zero. This would sacrifice a bit of highlights, but failure to do so would cause
- // scum dot. Ouch.
-
- if (Intent == INTENT_ABSOLUTE_COLORIMETRIC)
- lFixWhite = FALSE;
-
- _cmsIOPrintf(m, "/RenderTable ");
-
- first = cmsPipelineGetPtrToFirstStage(DeviceLink);
- if (first != NULL) {
- WriteCLUT(m, first, "<", ">\n", "", "", lFixWhite, ColorSpace);
- }
-
- _cmsIOPrintf(m, " %d {} bind ", nChannels);
-
- for (i=1; i < nChannels; i++)
- _cmsIOPrintf(m, "dup ");
-
- _cmsIOPrintf(m, "]\n");
-
- EmitIntent(m, Intent);
-
- _cmsIOPrintf(m, ">>\n");
-
- if (!(dwFlags & cmsFLAGS_NODEFAULTRESOURCEDEF)) {
-
- _cmsIOPrintf(m, "/Current exch /ColorRendering defineresource pop\n");
- }
-
- cmsPipelineFree(DeviceLink);
- cmsDeleteTransform(xform);
-
- return 1;
-}
-
-
-// Builds a ASCII string containing colorant list in 0..1.0 range
-static
-void BuildColorantList(char *Colorant, cmsUInt32Number nColorant, cmsUInt16Number Out[])
-{
- char Buff[32];
- cmsUInt32Number j;
-
- Colorant[0] = 0;
- if (nColorant > cmsMAXCHANNELS)
- nColorant = cmsMAXCHANNELS;
-
- for (j = 0; j < nColorant; j++) {
-
- snprintf(Buff, 31, "%.3f", Out[j] / 65535.0);
- Buff[31] = 0;
- strcat(Colorant, Buff);
- if (j < nColorant - 1)
- strcat(Colorant, " ");
-
- }
-}
-
-
-// Creates a PostScript color list from a named profile data.
-// This is a HP extension.
-
-static
-int WriteNamedColorCRD(cmsIOHANDLER* m, cmsHPROFILE hNamedColor, cmsUInt32Number Intent, cmsUInt32Number dwFlags)
-{
- cmsHTRANSFORM xform;
- cmsUInt32Number i, nColors, nColorant;
- cmsUInt32Number OutputFormat;
- char ColorName[cmsMAX_PATH];
- char Colorant[512];
- cmsNAMEDCOLORLIST* NamedColorList;
-
-
- OutputFormat = cmsFormatterForColorspaceOfProfile(hNamedColor, 2, FALSE);
- nColorant = T_CHANNELS(OutputFormat);
-
-
- xform = cmsCreateTransform(hNamedColor, TYPE_NAMED_COLOR_INDEX, NULL, OutputFormat, Intent, dwFlags);
- if (xform == NULL) return 0;
-
-
- NamedColorList = cmsGetNamedColorList(xform);
- if (NamedColorList == NULL) {
- cmsDeleteTransform(xform);
- return 0;
- }
-
- _cmsIOPrintf(m, "<<\n");
- _cmsIOPrintf(m, "(colorlistcomment) (%s) \n", "Named profile");
- _cmsIOPrintf(m, "(Prefix) [ (Pantone ) (PANTONE ) ]\n");
- _cmsIOPrintf(m, "(Suffix) [ ( CV) ( CVC) ( C) ]\n");
-
- nColors = cmsNamedColorCount(NamedColorList);
-
- for (i=0; i < nColors; i++) {
-
- cmsUInt16Number In[1];
- cmsUInt16Number Out[cmsMAXCHANNELS];
-
- In[0] = (cmsUInt16Number) i;
-
- if (!cmsNamedColorInfo(NamedColorList, i, ColorName, NULL, NULL, NULL, NULL))
- continue;
-
- cmsDoTransform(xform, In, Out, 1);
- BuildColorantList(Colorant, nColorant, Out);
- _cmsIOPrintf(m, " (%s) [ %s ]\n", ColorName, Colorant);
- }
-
- _cmsIOPrintf(m, " >>");
-
- if (!(dwFlags & cmsFLAGS_NODEFAULTRESOURCEDEF)) {
-
- _cmsIOPrintf(m, " /Current exch /HPSpotTable defineresource pop\n");
- }
-
- cmsDeleteTransform(xform);
- return 1;
-}
-
-
-
-// This one does create a Color Rendering Dictionary.
-// CRD are always LUT-Based, no matter if profile is
-// implemented as matrix-shaper.
-
-static
-cmsUInt32Number GenerateCRD(cmsContext ContextID,
- cmsHPROFILE hProfile,
- cmsUInt32Number Intent, cmsUInt32Number dwFlags,
- cmsIOHANDLER* mem)
-{
- cmsUInt32Number dwBytesUsed;
-
- if (!(dwFlags & cmsFLAGS_NODEFAULTRESOURCEDEF)) {
-
- EmitHeader(mem, "Color Rendering Dictionary (CRD)", hProfile);
- }
-
-
- // Is a named color profile?
- if (cmsGetDeviceClass(hProfile) == cmsSigNamedColorClass) {
-
- if (!WriteNamedColorCRD(mem, hProfile, Intent, dwFlags)) {
- return 0;
- }
- }
- else {
-
- // CRD are always implemented as LUT
-
- if (!WriteOutputLUT(mem, hProfile, Intent, dwFlags)) {
- return 0;
- }
- }
-
- if (!(dwFlags & cmsFLAGS_NODEFAULTRESOURCEDEF)) {
-
- _cmsIOPrintf(mem, "%%%%EndResource\n");
- _cmsIOPrintf(mem, "\n%% CRD End\n");
- }
-
- // Done, keep memory usage
- dwBytesUsed = mem ->UsedSpace;
-
- // Finally, return used byte count
- return dwBytesUsed;
-
- cmsUNUSED_PARAMETER(ContextID);
-}
-
-
-
-
-cmsUInt32Number CMSEXPORT cmsGetPostScriptColorResource(cmsContext ContextID,
- cmsPSResourceType Type,
- cmsHPROFILE hProfile,
- cmsUInt32Number Intent,
- cmsUInt32Number dwFlags,
- cmsIOHANDLER* io)
-{
- cmsUInt32Number rc;
-
-
- switch (Type) {
-
- case cmsPS_RESOURCE_CSA:
- rc = GenerateCSA(ContextID, hProfile, Intent, dwFlags, io);
- break;
-
- default:
- case cmsPS_RESOURCE_CRD:
- rc = GenerateCRD(ContextID, hProfile, Intent, dwFlags, io);
- break;
- }
-
- return rc;
-}
-
-
-
-cmsUInt32Number CMSEXPORT cmsGetPostScriptCRD(cmsContext ContextID,
- cmsHPROFILE hProfile,
- cmsUInt32Number Intent, cmsUInt32Number dwFlags,
- void* Buffer, cmsUInt32Number dwBufferLen)
-{
- cmsIOHANDLER* mem;
- cmsUInt32Number dwBytesUsed;
-
- // Set up the serialization engine
- if (Buffer == NULL)
- mem = cmsOpenIOhandlerFromNULL(ContextID);
- else
- mem = cmsOpenIOhandlerFromMem(ContextID, Buffer, dwBufferLen, "w");
-
- if (!mem) return 0;
-
- dwBytesUsed = cmsGetPostScriptColorResource(ContextID, cmsPS_RESOURCE_CRD, hProfile, Intent, dwFlags, mem);
-
- // Get rid of memory stream
- cmsCloseIOhandler(mem);
-
- return dwBytesUsed;
-}
-
-
-
-// Does create a Color Space Array on XYZ colorspace for PostScript usage
-cmsUInt32Number CMSEXPORT cmsGetPostScriptCSA(cmsContext ContextID,
- cmsHPROFILE hProfile,
- cmsUInt32Number Intent,
- cmsUInt32Number dwFlags,
- void* Buffer,
- cmsUInt32Number dwBufferLen)
-{
- cmsIOHANDLER* mem;
- cmsUInt32Number dwBytesUsed;
-
- if (Buffer == NULL)
- mem = cmsOpenIOhandlerFromNULL(ContextID);
- else
- mem = cmsOpenIOhandlerFromMem(ContextID, Buffer, dwBufferLen, "w");
-
- if (!mem) return 0;
-
- dwBytesUsed = cmsGetPostScriptColorResource(ContextID, cmsPS_RESOURCE_CSA, hProfile, Intent, dwFlags, mem);
-
- // Get rid of memory stream
- cmsCloseIOhandler(mem);
-
- return dwBytesUsed;
-
-}
diff --git a/contrib/libs/lcms2/src/cmssamp.c b/contrib/libs/lcms2/src/cmssamp.c
deleted file mode 100644
index 0cee16a9ec..0000000000
--- a/contrib/libs/lcms2/src/cmssamp.c
+++ /dev/null
@@ -1,552 +0,0 @@
-//---------------------------------------------------------------------------------
-//
-// Little Color Management System
-// Copyright (c) 1998-2023 Marti Maria Saguer
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//---------------------------------------------------------------------------------
-//
-
-#include "lcms2_internal.h"
-
-
-#define cmsmin(a, b) (((a) < (b)) ? (a) : (b))
-#define cmsmax(a, b) (((a) > (b)) ? (a) : (b))
-
-// This file contains routines for resampling and LUT optimization, black point detection
-// and black preservation.
-
-// Black point detection -------------------------------------------------------------------------
-
-
-// PCS -> PCS round trip transform, always uses relative intent on the device -> pcs
-static
-cmsHTRANSFORM CreateRoundtripXForm(cmsHPROFILE hProfile, cmsUInt32Number nIntent)
-{
- cmsContext ContextID = cmsGetProfileContextID(hProfile);
- cmsHPROFILE hLab = cmsCreateLab4ProfileTHR(ContextID, NULL);
- cmsHTRANSFORM xform;
- cmsBool BPC[4] = { FALSE, FALSE, FALSE, FALSE };
- cmsFloat64Number States[4] = { 1.0, 1.0, 1.0, 1.0 };
- cmsHPROFILE hProfiles[4];
- cmsUInt32Number Intents[4];
-
- hProfiles[0] = hLab; hProfiles[1] = hProfile; hProfiles[2] = hProfile; hProfiles[3] = hLab;
- Intents[0] = INTENT_RELATIVE_COLORIMETRIC; Intents[1] = nIntent; Intents[2] = INTENT_RELATIVE_COLORIMETRIC; Intents[3] = INTENT_RELATIVE_COLORIMETRIC;
-
- xform = cmsCreateExtendedTransform(ContextID, 4, hProfiles, BPC, Intents,
- States, NULL, 0, TYPE_Lab_DBL, TYPE_Lab_DBL, cmsFLAGS_NOCACHE|cmsFLAGS_NOOPTIMIZE);
-
- cmsCloseProfile(hLab);
- return xform;
-}
-
-// Use darker colorants to obtain black point. This works in the relative colorimetric intent and
-// assumes more ink results in darker colors. No ink limit is assumed.
-static
-cmsBool BlackPointAsDarkerColorant(cmsHPROFILE hInput,
- cmsUInt32Number Intent,
- cmsCIEXYZ* BlackPoint,
- cmsUInt32Number dwFlags)
-{
- cmsUInt16Number *Black;
- cmsHTRANSFORM xform;
- cmsColorSpaceSignature Space;
- cmsUInt32Number nChannels;
- cmsUInt32Number dwFormat;
- cmsHPROFILE hLab;
- cmsCIELab Lab;
- cmsCIEXYZ BlackXYZ;
- cmsContext ContextID = cmsGetProfileContextID(hInput);
-
- // If the profile does not support input direction, assume Black point 0
- if (!cmsIsIntentSupported(hInput, Intent, LCMS_USED_AS_INPUT)) {
-
- BlackPoint -> X = BlackPoint ->Y = BlackPoint -> Z = 0.0;
- return FALSE;
- }
-
- // Create a formatter which has n channels and no floating point
- dwFormat = cmsFormatterForColorspaceOfProfile(hInput, 2, FALSE);
-
- // Try to get black by using black colorant
- Space = cmsGetColorSpace(hInput);
-
- // This function returns darker colorant in 16 bits for several spaces
- if (!_cmsEndPointsBySpace(Space, NULL, &Black, &nChannels)) {
-
- BlackPoint -> X = BlackPoint ->Y = BlackPoint -> Z = 0.0;
- return FALSE;
- }
-
- if (nChannels != T_CHANNELS(dwFormat)) {
- BlackPoint -> X = BlackPoint ->Y = BlackPoint -> Z = 0.0;
- return FALSE;
- }
-
- // Lab will be used as the output space, but lab2 will avoid recursion
- hLab = cmsCreateLab2ProfileTHR(ContextID, NULL);
- if (hLab == NULL) {
- BlackPoint -> X = BlackPoint ->Y = BlackPoint -> Z = 0.0;
- return FALSE;
- }
-
- // Create the transform
- xform = cmsCreateTransformTHR(ContextID, hInput, dwFormat,
- hLab, TYPE_Lab_DBL, Intent, cmsFLAGS_NOOPTIMIZE|cmsFLAGS_NOCACHE);
- cmsCloseProfile(hLab);
-
- if (xform == NULL) {
-
- // Something went wrong. Get rid of open resources and return zero as black
- BlackPoint -> X = BlackPoint ->Y = BlackPoint -> Z = 0.0;
- return FALSE;
- }
-
- // Convert black to Lab
- cmsDoTransform(xform, Black, &Lab, 1);
-
- // Force it to be neutral, check for inconsistencies
- Lab.a = Lab.b = 0;
- if (Lab.L > 50 || Lab.L < 0) Lab.L = 0;
-
- // Free the resources
- cmsDeleteTransform(xform);
-
- // Convert from Lab (which is now clipped) to XYZ.
- cmsLab2XYZ(NULL, &BlackXYZ, &Lab);
-
- if (BlackPoint != NULL)
- *BlackPoint = BlackXYZ;
-
- return TRUE;
-
- cmsUNUSED_PARAMETER(dwFlags);
-}
-
-// Get a black point of output CMYK profile, discounting any ink-limiting embedded
-// in the profile. For doing that, we use perceptual intent in input direction:
-// Lab (0, 0, 0) -> [Perceptual] Profile -> CMYK -> [Rel. colorimetric] Profile -> Lab
-static
-cmsBool BlackPointUsingPerceptualBlack(cmsCIEXYZ* BlackPoint, cmsHPROFILE hProfile)
-{
- cmsHTRANSFORM hRoundTrip;
- cmsCIELab LabIn, LabOut;
- cmsCIEXYZ BlackXYZ;
-
- // Is the intent supported by the profile?
- if (!cmsIsIntentSupported(hProfile, INTENT_PERCEPTUAL, LCMS_USED_AS_INPUT)) {
-
- BlackPoint -> X = BlackPoint ->Y = BlackPoint -> Z = 0.0;
- return TRUE;
- }
-
- hRoundTrip = CreateRoundtripXForm(hProfile, INTENT_PERCEPTUAL);
- if (hRoundTrip == NULL) {
- BlackPoint -> X = BlackPoint ->Y = BlackPoint -> Z = 0.0;
- return FALSE;
- }
-
- LabIn.L = LabIn.a = LabIn.b = 0;
- cmsDoTransform(hRoundTrip, &LabIn, &LabOut, 1);
-
- // Clip Lab to reasonable limits
- if (LabOut.L > 50) LabOut.L = 50;
- LabOut.a = LabOut.b = 0;
-
- cmsDeleteTransform(hRoundTrip);
-
- // Convert it to XYZ
- cmsLab2XYZ(NULL, &BlackXYZ, &LabOut);
-
- if (BlackPoint != NULL)
- *BlackPoint = BlackXYZ;
-
- return TRUE;
-}
-
-// This function shouldn't exist at all -- there is such quantity of broken
-// profiles on black point tag, that we must somehow fix chromaticity to
-// avoid huge tint when doing Black point compensation. This function does
-// just that. There is a special flag for using black point tag, but turned
-// off by default because it is bogus on most profiles. The detection algorithm
-// involves to turn BP to neutral and to use only L component.
-cmsBool CMSEXPORT cmsDetectBlackPoint(cmsCIEXYZ* BlackPoint, cmsHPROFILE hProfile, cmsUInt32Number Intent, cmsUInt32Number dwFlags)
-{
- cmsProfileClassSignature devClass;
-
- // Make sure the device class is adequate
- devClass = cmsGetDeviceClass(hProfile);
- if (devClass == cmsSigLinkClass ||
- devClass == cmsSigAbstractClass ||
- devClass == cmsSigNamedColorClass) {
- BlackPoint -> X = BlackPoint ->Y = BlackPoint -> Z = 0.0;
- return FALSE;
- }
-
- // Make sure intent is adequate
- if (Intent != INTENT_PERCEPTUAL &&
- Intent != INTENT_RELATIVE_COLORIMETRIC &&
- Intent != INTENT_SATURATION) {
- BlackPoint -> X = BlackPoint ->Y = BlackPoint -> Z = 0.0;
- return FALSE;
- }
-
- // v4 + perceptual & saturation intents does have its own black point, and it is
- // well specified enough to use it. Black point tag is deprecated in V4.
- if ((cmsGetEncodedICCversion(hProfile) >= 0x4000000) &&
- (Intent == INTENT_PERCEPTUAL || Intent == INTENT_SATURATION)) {
-
- // Matrix shaper share MRC & perceptual intents
- if (cmsIsMatrixShaper(hProfile))
- return BlackPointAsDarkerColorant(hProfile, INTENT_RELATIVE_COLORIMETRIC, BlackPoint, 0);
-
- // Get Perceptual black out of v4 profiles. That is fixed for perceptual & saturation intents
- BlackPoint -> X = cmsPERCEPTUAL_BLACK_X;
- BlackPoint -> Y = cmsPERCEPTUAL_BLACK_Y;
- BlackPoint -> Z = cmsPERCEPTUAL_BLACK_Z;
-
- return TRUE;
- }
-
-
-#ifdef CMS_USE_PROFILE_BLACK_POINT_TAG
-
- // v2, v4 rel/abs colorimetric
- if (cmsIsTag(hProfile, cmsSigMediaBlackPointTag) &&
- Intent == INTENT_RELATIVE_COLORIMETRIC) {
-
- cmsCIEXYZ *BlackPtr, BlackXYZ, UntrustedBlackPoint, TrustedBlackPoint, MediaWhite;
- cmsCIELab Lab;
-
- // If black point is specified, then use it,
-
- BlackPtr = cmsReadTag(hProfile, cmsSigMediaBlackPointTag);
- if (BlackPtr != NULL) {
-
- BlackXYZ = *BlackPtr;
- _cmsReadMediaWhitePoint(&MediaWhite, hProfile);
-
- // Black point is absolute XYZ, so adapt to D50 to get PCS value
- cmsAdaptToIlluminant(&UntrustedBlackPoint, &MediaWhite, cmsD50_XYZ(), &BlackXYZ);
-
- // Force a=b=0 to get rid of any chroma
- cmsXYZ2Lab(NULL, &Lab, &UntrustedBlackPoint);
- Lab.a = Lab.b = 0;
- if (Lab.L > 50) Lab.L = 50; // Clip to L* <= 50
- cmsLab2XYZ(NULL, &TrustedBlackPoint, &Lab);
-
- if (BlackPoint != NULL)
- *BlackPoint = TrustedBlackPoint;
-
- return TRUE;
- }
- }
-#endif
-
- // That is about v2 profiles.
-
- // If output profile, discount ink-limiting and that's all
- if (Intent == INTENT_RELATIVE_COLORIMETRIC &&
- (cmsGetDeviceClass(hProfile) == cmsSigOutputClass) &&
- (cmsGetColorSpace(hProfile) == cmsSigCmykData))
- return BlackPointUsingPerceptualBlack(BlackPoint, hProfile);
-
- // Nope, compute BP using current intent.
- return BlackPointAsDarkerColorant(hProfile, Intent, BlackPoint, dwFlags);
-}
-
-
-
-// ---------------------------------------------------------------------------------------------------------
-
-// Least Squares Fit of a Quadratic Curve to Data
-// http://www.personal.psu.edu/jhm/f90/lectures/lsq2.html
-
-static
-cmsFloat64Number RootOfLeastSquaresFitQuadraticCurve(int n, cmsFloat64Number x[], cmsFloat64Number y[])
-{
- double sum_x = 0, sum_x2 = 0, sum_x3 = 0, sum_x4 = 0;
- double sum_y = 0, sum_yx = 0, sum_yx2 = 0;
- double d, a, b, c;
- int i;
- cmsMAT3 m;
- cmsVEC3 v, res;
-
- if (n < 4) return 0;
-
- for (i=0; i < n; i++) {
-
- double xn = x[i];
- double yn = y[i];
-
- sum_x += xn;
- sum_x2 += xn*xn;
- sum_x3 += xn*xn*xn;
- sum_x4 += xn*xn*xn*xn;
-
- sum_y += yn;
- sum_yx += yn*xn;
- sum_yx2 += yn*xn*xn;
- }
-
- _cmsVEC3init(&m.v[0], n, sum_x, sum_x2);
- _cmsVEC3init(&m.v[1], sum_x, sum_x2, sum_x3);
- _cmsVEC3init(&m.v[2], sum_x2, sum_x3, sum_x4);
-
- _cmsVEC3init(&v, sum_y, sum_yx, sum_yx2);
-
- if (!_cmsMAT3solve(&res, &m, &v)) return 0;
-
-
- a = res.n[2];
- b = res.n[1];
- c = res.n[0];
-
- if (fabs(a) < 1.0E-10) {
-
- if (fabs(b) < 1.0E-10) return 0;
- return cmsmin(0, cmsmax(50, -c/b ));
- }
- else {
-
- d = b*b - 4.0 * a * c;
- if (d <= 0) {
- return 0;
- }
- else {
-
- double rt;
-
- if (fabs(a) < 1.0E-10) return 0;
-
- rt = (-b + sqrt(d)) / (2.0 * a);
-
- return cmsmax(0, cmsmin(50, rt));
- }
- }
-
-}
-
-
-
-// Calculates the black point of a destination profile.
-// This algorithm comes from the Adobe paper disclosing its black point compensation method.
-cmsBool CMSEXPORT cmsDetectDestinationBlackPoint(cmsCIEXYZ* BlackPoint, cmsHPROFILE hProfile, cmsUInt32Number Intent, cmsUInt32Number dwFlags)
-{
- cmsColorSpaceSignature ColorSpace;
- cmsHTRANSFORM hRoundTrip = NULL;
- cmsCIELab InitialLab, destLab, Lab;
- cmsFloat64Number inRamp[256], outRamp[256];
- cmsFloat64Number MinL, MaxL;
- cmsBool NearlyStraightMidrange = TRUE;
- cmsFloat64Number yRamp[256];
- cmsFloat64Number x[256], y[256];
- cmsFloat64Number lo, hi;
- int n, l;
- cmsProfileClassSignature devClass;
-
- // Make sure the device class is adequate
- devClass = cmsGetDeviceClass(hProfile);
- if (devClass == cmsSigLinkClass ||
- devClass == cmsSigAbstractClass ||
- devClass == cmsSigNamedColorClass) {
- BlackPoint -> X = BlackPoint ->Y = BlackPoint -> Z = 0.0;
- return FALSE;
- }
-
- // Make sure intent is adequate
- if (Intent != INTENT_PERCEPTUAL &&
- Intent != INTENT_RELATIVE_COLORIMETRIC &&
- Intent != INTENT_SATURATION) {
- BlackPoint -> X = BlackPoint ->Y = BlackPoint -> Z = 0.0;
- return FALSE;
- }
-
-
- // v4 + perceptual & saturation intents does have its own black point, and it is
- // well specified enough to use it. Black point tag is deprecated in V4.
- if ((cmsGetEncodedICCversion(hProfile) >= 0x4000000) &&
- (Intent == INTENT_PERCEPTUAL || Intent == INTENT_SATURATION)) {
-
- // Matrix shaper share MRC & perceptual intents
- if (cmsIsMatrixShaper(hProfile))
- return BlackPointAsDarkerColorant(hProfile, INTENT_RELATIVE_COLORIMETRIC, BlackPoint, 0);
-
- // Get Perceptual black out of v4 profiles. That is fixed for perceptual & saturation intents
- BlackPoint -> X = cmsPERCEPTUAL_BLACK_X;
- BlackPoint -> Y = cmsPERCEPTUAL_BLACK_Y;
- BlackPoint -> Z = cmsPERCEPTUAL_BLACK_Z;
- return TRUE;
- }
-
-
- // Check if the profile is lut based and gray, rgb or cmyk (7.2 in Adobe's document)
- ColorSpace = cmsGetColorSpace(hProfile);
- if (!cmsIsCLUT(hProfile, Intent, LCMS_USED_AS_OUTPUT ) ||
- (ColorSpace != cmsSigGrayData &&
- ColorSpace != cmsSigRgbData &&
- ColorSpace != cmsSigCmykData)) {
-
- // In this case, handle as input case
- return cmsDetectBlackPoint(BlackPoint, hProfile, Intent, dwFlags);
- }
-
- // It is one of the valid cases!, use Adobe algorithm
-
-
- // Set a first guess, that should work on good profiles.
- if (Intent == INTENT_RELATIVE_COLORIMETRIC) {
-
- cmsCIEXYZ IniXYZ;
-
- // calculate initial Lab as source black point
- if (!cmsDetectBlackPoint(&IniXYZ, hProfile, Intent, dwFlags)) {
- return FALSE;
- }
-
- // convert the XYZ to lab
- cmsXYZ2Lab(NULL, &InitialLab, &IniXYZ);
-
- } else {
-
- // set the initial Lab to zero, that should be the black point for perceptual and saturation
- InitialLab.L = 0;
- InitialLab.a = 0;
- InitialLab.b = 0;
- }
-
-
- // Step 2
- // ======
-
- // Create a roundtrip. Define a Transform BT for all x in L*a*b*
- hRoundTrip = CreateRoundtripXForm(hProfile, Intent);
- if (hRoundTrip == NULL) return FALSE;
-
- // Compute ramps
-
- for (l=0; l < 256; l++) {
-
- Lab.L = (cmsFloat64Number) (l * 100.0) / 255.0;
- Lab.a = cmsmin(50, cmsmax(-50, InitialLab.a));
- Lab.b = cmsmin(50, cmsmax(-50, InitialLab.b));
-
- cmsDoTransform(hRoundTrip, &Lab, &destLab, 1);
-
- inRamp[l] = Lab.L;
- outRamp[l] = destLab.L;
- }
-
- // Make monotonic
- for (l = 254; l > 0; --l) {
- outRamp[l] = cmsmin(outRamp[l], outRamp[l+1]);
- }
-
- // Check
- if (! (outRamp[0] < outRamp[255])) {
-
- cmsDeleteTransform(hRoundTrip);
- BlackPoint -> X = BlackPoint ->Y = BlackPoint -> Z = 0.0;
- return FALSE;
- }
-
-
- // Test for mid range straight (only on relative colorimetric)
- NearlyStraightMidrange = TRUE;
- MinL = outRamp[0]; MaxL = outRamp[255];
- if (Intent == INTENT_RELATIVE_COLORIMETRIC) {
-
- for (l=0; l < 256; l++) {
-
- if (! ((inRamp[l] <= MinL + 0.2 * (MaxL - MinL) ) ||
- (fabs(inRamp[l] - outRamp[l]) < 4.0 )))
- NearlyStraightMidrange = FALSE;
- }
-
- // If the mid range is straight (as determined above) then the
- // DestinationBlackPoint shall be the same as initialLab.
- // Otherwise, the DestinationBlackPoint shall be determined
- // using curve fitting.
- if (NearlyStraightMidrange) {
-
- cmsLab2XYZ(NULL, BlackPoint, &InitialLab);
- cmsDeleteTransform(hRoundTrip);
- return TRUE;
- }
- }
-
-
- // curve fitting: The round-trip curve normally looks like a nearly constant section at the black point,
- // with a corner and a nearly straight line to the white point.
- for (l=0; l < 256; l++) {
-
- yRamp[l] = (outRamp[l] - MinL) / (MaxL - MinL);
- }
-
- // find the black point using the least squares error quadratic curve fitting
- if (Intent == INTENT_RELATIVE_COLORIMETRIC) {
- lo = 0.1;
- hi = 0.5;
- }
- else {
-
- // Perceptual and saturation
- lo = 0.03;
- hi = 0.25;
- }
-
- // Capture shadow points for the fitting.
- n = 0;
- for (l=0; l < 256; l++) {
-
- cmsFloat64Number ff = yRamp[l];
-
- if (ff >= lo && ff < hi) {
- x[n] = inRamp[l];
- y[n] = yRamp[l];
- n++;
- }
- }
-
-
- // No suitable points
- if (n < 3 ) {
- cmsDeleteTransform(hRoundTrip);
- BlackPoint -> X = BlackPoint ->Y = BlackPoint -> Z = 0.0;
- return FALSE;
- }
-
-
- // fit and get the vertex of quadratic curve
- Lab.L = RootOfLeastSquaresFitQuadraticCurve(n, x, y);
-
- if (Lab.L < 0.0) { // clip to zero L* if the vertex is negative
- Lab.L = 0;
- }
-
- Lab.a = InitialLab.a;
- Lab.b = InitialLab.b;
-
- cmsLab2XYZ(NULL, BlackPoint, &Lab);
-
- cmsDeleteTransform(hRoundTrip);
- return TRUE;
-}
diff --git a/contrib/libs/lcms2/src/cmssm.c b/contrib/libs/lcms2/src/cmssm.c
deleted file mode 100644
index 5c1e430a8c..0000000000
--- a/contrib/libs/lcms2/src/cmssm.c
+++ /dev/null
@@ -1,736 +0,0 @@
-//---------------------------------------------------------------------------------
-//
-// Little Color Management System
-// Copyright (c) 1998-2023 Marti Maria Saguer
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//---------------------------------------------------------------------------------
-//
-
-#include "lcms2_internal.h"
-
-
-// ------------------------------------------------------------------------
-
-// Gamut boundary description by using Jan Morovic's Segment maxima method
-// Many thanks to Jan for allowing me to use his algorithm.
-
-// r = C*
-// alpha = Hab
-// theta = L*
-
-#define SECTORS 16 // number of divisions in alpha and theta
-
-// Spherical coordinates
-typedef struct {
-
- cmsFloat64Number r;
- cmsFloat64Number alpha;
- cmsFloat64Number theta;
-
-} cmsSpherical;
-
-typedef enum {
- GP_EMPTY,
- GP_SPECIFIED,
- GP_MODELED
-
- } GDBPointType;
-
-
-typedef struct {
-
- GDBPointType Type;
- cmsSpherical p; // Keep also alpha & theta of maximum
-
-} cmsGDBPoint;
-
-
-typedef struct {
-
- cmsContext ContextID;
- cmsGDBPoint Gamut[SECTORS][SECTORS];
-
-} cmsGDB;
-
-
-// A line using the parametric form
-// P = a + t*u
-typedef struct {
-
- cmsVEC3 a;
- cmsVEC3 u;
-
-} cmsLine;
-
-
-// A plane using the parametric form
-// Q = b + r*v + s*w
-typedef struct {
-
- cmsVEC3 b;
- cmsVEC3 v;
- cmsVEC3 w;
-
-} cmsPlane;
-
-
-
-// --------------------------------------------------------------------------------------------
-
-// ATAN2() which always returns degree positive numbers
-
-static
-cmsFloat64Number _cmsAtan2(cmsFloat64Number y, cmsFloat64Number x)
-{
- cmsFloat64Number a;
-
- // Deal with undefined case
- if (x == 0.0 && y == 0.0) return 0;
-
- a = (atan2(y, x) * 180.0) / M_PI;
-
- while (a < 0) {
- a += 360;
- }
-
- return a;
-}
-
-// Convert to spherical coordinates
-static
-void ToSpherical(cmsSpherical* sp, const cmsVEC3* v)
-{
-
- cmsFloat64Number L, a, b;
-
- L = v ->n[VX];
- a = v ->n[VY];
- b = v ->n[VZ];
-
- sp ->r = sqrt( L*L + a*a + b*b );
-
- if (sp ->r == 0) {
- sp ->alpha = sp ->theta = 0;
- return;
- }
-
- sp ->alpha = _cmsAtan2(a, b);
- sp ->theta = _cmsAtan2(sqrt(a*a + b*b), L);
-}
-
-
-// Convert to cartesian from spherical
-static
-void ToCartesian(cmsVEC3* v, const cmsSpherical* sp)
-{
- cmsFloat64Number sin_alpha;
- cmsFloat64Number cos_alpha;
- cmsFloat64Number sin_theta;
- cmsFloat64Number cos_theta;
- cmsFloat64Number L, a, b;
-
- sin_alpha = sin((M_PI * sp ->alpha) / 180.0);
- cos_alpha = cos((M_PI * sp ->alpha) / 180.0);
- sin_theta = sin((M_PI * sp ->theta) / 180.0);
- cos_theta = cos((M_PI * sp ->theta) / 180.0);
-
- a = sp ->r * sin_theta * sin_alpha;
- b = sp ->r * sin_theta * cos_alpha;
- L = sp ->r * cos_theta;
-
- v ->n[VX] = L;
- v ->n[VY] = a;
- v ->n[VZ] = b;
-}
-
-
-// Quantize sector of a spherical coordinate. Saturate 360, 180 to last sector
-// The limits are the centers of each sector, so
-static
-void QuantizeToSector(const cmsSpherical* sp, int* alpha, int* theta)
-{
- *alpha = (int) floor(((sp->alpha * (SECTORS)) / 360.0) );
- *theta = (int) floor(((sp->theta * (SECTORS)) / 180.0) );
-
- if (*alpha >= SECTORS)
- *alpha = SECTORS-1;
- if (*theta >= SECTORS)
- *theta = SECTORS-1;
-}
-
-
-// Line determined by 2 points
-static
-void LineOf2Points(cmsLine* line, cmsVEC3* a, cmsVEC3* b)
-{
-
- _cmsVEC3init(&line ->a, a ->n[VX], a ->n[VY], a ->n[VZ]);
- _cmsVEC3init(&line ->u, b ->n[VX] - a ->n[VX],
- b ->n[VY] - a ->n[VY],
- b ->n[VZ] - a ->n[VZ]);
-}
-
-
-// Evaluate parametric line
-static
-void GetPointOfLine(cmsVEC3* p, const cmsLine* line, cmsFloat64Number t)
-{
- p ->n[VX] = line ->a.n[VX] + t * line->u.n[VX];
- p ->n[VY] = line ->a.n[VY] + t * line->u.n[VY];
- p ->n[VZ] = line ->a.n[VZ] + t * line->u.n[VZ];
-}
-
-
-
-/*
- Closest point in sector line1 to sector line2 (both are defined as 0 <=t <= 1)
- http://softsurfer.com/Archive/algorithm_0106/algorithm_0106.htm
-
- Copyright 2001, softSurfer (www.softsurfer.com)
- This code may be freely used and modified for any purpose
- providing that this copyright notice is included with it.
- SoftSurfer makes no warranty for this code, and cannot be held
- liable for any real or imagined damage resulting from its use.
- Users of this code must verify correctness for their application.
-
-*/
-
-static
-cmsBool ClosestLineToLine(cmsVEC3* r, const cmsLine* line1, const cmsLine* line2)
-{
- cmsFloat64Number a, b, c, d, e, D;
- cmsFloat64Number sc, sN, sD;
- //cmsFloat64Number tc; // left for future use
- cmsFloat64Number tN, tD;
- cmsVEC3 w0;
-
- _cmsVEC3minus(&w0, &line1 ->a, &line2 ->a);
-
- a = _cmsVEC3dot(&line1 ->u, &line1 ->u);
- b = _cmsVEC3dot(&line1 ->u, &line2 ->u);
- c = _cmsVEC3dot(&line2 ->u, &line2 ->u);
- d = _cmsVEC3dot(&line1 ->u, &w0);
- e = _cmsVEC3dot(&line2 ->u, &w0);
-
- D = a*c - b * b; // Denominator
- sD = tD = D; // default sD = D >= 0
-
- if (D < MATRIX_DET_TOLERANCE) { // the lines are almost parallel
-
- sN = 0.0; // force using point P0 on segment S1
- sD = 1.0; // to prevent possible division by 0.0 later
- tN = e;
- tD = c;
- }
- else { // get the closest points on the infinite lines
-
- sN = (b*e - c*d);
- tN = (a*e - b*d);
-
- if (sN < 0.0) { // sc < 0 => the s=0 edge is visible
-
- sN = 0.0;
- tN = e;
- tD = c;
- }
- else if (sN > sD) { // sc > 1 => the s=1 edge is visible
- sN = sD;
- tN = e + b;
- tD = c;
- }
- }
-
- if (tN < 0.0) { // tc < 0 => the t=0 edge is visible
-
- tN = 0.0;
- // recompute sc for this edge
- if (-d < 0.0)
- sN = 0.0;
- else if (-d > a)
- sN = sD;
- else {
- sN = -d;
- sD = a;
- }
- }
- else if (tN > tD) { // tc > 1 => the t=1 edge is visible
-
- tN = tD;
-
- // recompute sc for this edge
- if ((-d + b) < 0.0)
- sN = 0;
- else if ((-d + b) > a)
- sN = sD;
- else {
- sN = (-d + b);
- sD = a;
- }
- }
- // finally do the division to get sc and tc
- sc = (fabs(sN) < MATRIX_DET_TOLERANCE ? 0.0 : sN / sD);
- //tc = (fabs(tN) < MATRIX_DET_TOLERANCE ? 0.0 : tN / tD); // left for future use.
-
- GetPointOfLine(r, line1, sc);
- return TRUE;
-}
-
-
-
-// ------------------------------------------------------------------ Wrapper
-
-
-// Allocate & free structure
-cmsHANDLE CMSEXPORT cmsGBDAlloc(cmsContext ContextID)
-{
- cmsGDB* gbd = (cmsGDB*) _cmsMallocZero(ContextID, sizeof(cmsGDB));
- if (gbd == NULL) return NULL;
-
- gbd -> ContextID = ContextID;
-
- return (cmsHANDLE) gbd;
-}
-
-
-void CMSEXPORT cmsGBDFree(cmsHANDLE hGBD)
-{
- cmsGDB* gbd = (cmsGDB*) hGBD;
- if (hGBD != NULL)
- _cmsFree(gbd->ContextID, (void*) gbd);
-}
-
-
-// Auxiliary to retrieve a pointer to the segmentr containing the Lab value
-static
-cmsGDBPoint* GetPoint(cmsGDB* gbd, const cmsCIELab* Lab, cmsSpherical* sp)
-{
- cmsVEC3 v;
- int alpha, theta;
-
- // Housekeeping
- _cmsAssert(gbd != NULL);
- _cmsAssert(Lab != NULL);
- _cmsAssert(sp != NULL);
-
- // Center L* by subtracting half of its domain, that's 50
- _cmsVEC3init(&v, Lab ->L - 50.0, Lab ->a, Lab ->b);
-
- // Convert to spherical coordinates
- ToSpherical(sp, &v);
-
- if (sp ->r < 0 || sp ->alpha < 0 || sp->theta < 0) {
- cmsSignalError(gbd ->ContextID, cmsERROR_RANGE, "spherical value out of range");
- return NULL;
- }
-
- // On which sector it falls?
- QuantizeToSector(sp, &alpha, &theta);
-
- if (alpha < 0 || theta < 0 || alpha >= SECTORS || theta >= SECTORS) {
- cmsSignalError(gbd ->ContextID, cmsERROR_RANGE, " quadrant out of range");
- return NULL;
- }
-
- // Get pointer to the sector
- return &gbd ->Gamut[theta][alpha];
-}
-
-// Add a point to gamut descriptor. Point to add is in Lab color space.
-// GBD is centered on a=b=0 and L*=50
-cmsBool CMSEXPORT cmsGDBAddPoint(cmsHANDLE hGBD, const cmsCIELab* Lab)
-{
- cmsGDB* gbd = (cmsGDB*) hGBD;
- cmsGDBPoint* ptr;
- cmsSpherical sp;
-
-
- // Get pointer to the sector
- ptr = GetPoint(gbd, Lab, &sp);
- if (ptr == NULL) return FALSE;
-
- // If no samples at this sector, add it
- if (ptr ->Type == GP_EMPTY) {
-
- ptr -> Type = GP_SPECIFIED;
- ptr -> p = sp;
- }
- else {
-
-
- // Substitute only if radius is greater
- if (sp.r > ptr -> p.r) {
-
- ptr -> Type = GP_SPECIFIED;
- ptr -> p = sp;
- }
- }
-
- return TRUE;
-}
-
-// Check if a given point falls inside gamut
-cmsBool CMSEXPORT cmsGDBCheckPoint(cmsHANDLE hGBD, const cmsCIELab* Lab)
-{
- cmsGDB* gbd = (cmsGDB*) hGBD;
- cmsGDBPoint* ptr;
- cmsSpherical sp;
-
- // Get pointer to the sector
- ptr = GetPoint(gbd, Lab, &sp);
- if (ptr == NULL) return FALSE;
-
- // If no samples at this sector, return no data
- if (ptr ->Type == GP_EMPTY) return FALSE;
-
- // In gamut only if radius is greater
-
- return (sp.r <= ptr -> p.r);
-}
-
-// -----------------------------------------------------------------------------------------------------------------------
-
-// Find near sectors. The list of sectors found is returned on Close[].
-// The function returns the number of sectors as well.
-
-// 24 9 10 11 12
-// 23 8 1 2 13
-// 22 7 * 3 14
-// 21 6 5 4 15
-// 20 19 18 17 16
-//
-// Those are the relative movements
-// {-2,-2}, {-1, -2}, {0, -2}, {+1, -2}, {+2, -2},
-// {-2,-1}, {-1, -1}, {0, -1}, {+1, -1}, {+2, -1},
-// {-2, 0}, {-1, 0}, {0, 0}, {+1, 0}, {+2, 0},
-// {-2,+1}, {-1, +1}, {0, +1}, {+1, +1}, {+2, +1},
-// {-2,+2}, {-1, +2}, {0, +2}, {+1, +2}, {+2, +2}};
-
-
-static
-const struct _spiral {
-
- int AdvX, AdvY;
-
- } Spiral[] = { {0, -1}, {+1, -1}, {+1, 0}, {+1, +1}, {0, +1}, {-1, +1},
- {-1, 0}, {-1, -1}, {-1, -2}, {0, -2}, {+1, -2}, {+2, -2},
- {+2, -1}, {+2, 0}, {+2, +1}, {+2, +2}, {+1, +2}, {0, +2},
- {-1, +2}, {-2, +2}, {-2, +1}, {-2, 0}, {-2, -1}, {-2, -2} };
-
-#define NSTEPS (sizeof(Spiral) / sizeof(struct _spiral))
-
-static
-int FindNearSectors(cmsGDB* gbd, int alpha, int theta, cmsGDBPoint* Close[])
-{
- int nSectors = 0;
- int a, t;
- cmsUInt32Number i;
- cmsGDBPoint* pt;
-
- for (i=0; i < NSTEPS; i++) {
-
- a = alpha + Spiral[i].AdvX;
- t = theta + Spiral[i].AdvY;
-
- // Cycle at the end
- a %= SECTORS;
- t %= SECTORS;
-
- // Cycle at the begin
- if (a < 0) a = SECTORS + a;
- if (t < 0) t = SECTORS + t;
-
- pt = &gbd ->Gamut[t][a];
-
- if (pt -> Type != GP_EMPTY) {
-
- Close[nSectors++] = pt;
- }
- }
-
- return nSectors;
-}
-
-
-// Interpolate a missing sector. Method identifies whatever this is top, bottom or mid
-static
-cmsBool InterpolateMissingSector(cmsGDB* gbd, int alpha, int theta)
-{
- cmsSpherical sp;
- cmsVEC3 Lab;
- cmsVEC3 Centre;
- cmsLine ray;
- int nCloseSectors;
- cmsGDBPoint* Close[NSTEPS + 1];
- cmsSpherical closel, templ;
- cmsLine edge;
- int k, m;
-
- // Is that point already specified?
- if (gbd ->Gamut[theta][alpha].Type != GP_EMPTY) return TRUE;
-
- // Fill close points
- nCloseSectors = FindNearSectors(gbd, alpha, theta, Close);
-
-
- // Find a central point on the sector
- sp.alpha = (cmsFloat64Number) ((alpha + 0.5) * 360.0) / (SECTORS);
- sp.theta = (cmsFloat64Number) ((theta + 0.5) * 180.0) / (SECTORS);
- sp.r = 50.0;
-
- // Convert to Cartesian
- ToCartesian(&Lab, &sp);
-
- // Create a ray line from centre to this point
- _cmsVEC3init(&Centre, 50.0, 0, 0);
- LineOf2Points(&ray, &Lab, &Centre);
-
- // For all close sectors
- closel.r = 0.0;
- closel.alpha = 0;
- closel.theta = 0;
-
- for (k=0; k < nCloseSectors; k++) {
-
- for(m = k+1; m < nCloseSectors; m++) {
-
- cmsVEC3 temp, a1, a2;
-
- // A line from sector to sector
- ToCartesian(&a1, &Close[k]->p);
- ToCartesian(&a2, &Close[m]->p);
-
- LineOf2Points(&edge, &a1, &a2);
-
- // Find a line
- ClosestLineToLine(&temp, &ray, &edge);
-
- // Convert to spherical
- ToSpherical(&templ, &temp);
-
-
- if ( templ.r > closel.r &&
- templ.theta >= (theta*180.0/SECTORS) &&
- templ.theta <= ((theta+1)*180.0/SECTORS) &&
- templ.alpha >= (alpha*360.0/SECTORS) &&
- templ.alpha <= ((alpha+1)*360.0/SECTORS)) {
-
- closel = templ;
- }
- }
- }
-
- gbd ->Gamut[theta][alpha].p = closel;
- gbd ->Gamut[theta][alpha].Type = GP_MODELED;
-
- return TRUE;
-
-}
-
-
-// Interpolate missing parts. The algorithm fist computes slices at
-// theta=0 and theta=Max.
-cmsBool CMSEXPORT cmsGDBCompute(cmsHANDLE hGBD, cmsUInt32Number dwFlags)
-{
- int alpha, theta;
- cmsGDB* gbd = (cmsGDB*) hGBD;
-
- _cmsAssert(hGBD != NULL);
-
- // Interpolate black
- for (alpha = 0; alpha < SECTORS; alpha++) {
-
- if (!InterpolateMissingSector(gbd, alpha, 0)) return FALSE;
- }
-
- // Interpolate white
- for (alpha = 0; alpha < SECTORS; alpha++) {
-
- if (!InterpolateMissingSector(gbd, alpha, SECTORS-1)) return FALSE;
- }
-
-
- // Interpolate Mid
- for (theta = 1; theta < SECTORS; theta++) {
- for (alpha = 0; alpha < SECTORS; alpha++) {
-
- if (!InterpolateMissingSector(gbd, alpha, theta)) return FALSE;
- }
- }
-
- // Done
- return TRUE;
-
- cmsUNUSED_PARAMETER(dwFlags);
-}
-
-
-
-
-// --------------------------------------------------------------------------------------------------------
-
-// Great for debug, but not suitable for real use
-
-#if 0
-cmsBool cmsGBDdumpVRML(cmsHANDLE hGBD, const char* fname)
-{
- FILE* fp;
- int i, j;
- cmsGDB* gbd = (cmsGDB*) hGBD;
- cmsGDBPoint* pt;
-
- fp = fopen (fname, "wt");
- if (fp == NULL)
- return FALSE;
-
- fprintf (fp, "#VRML V2.0 utf8\n");
-
- // set the viewing orientation and distance
- fprintf (fp, "DEF CamTest Group {\n");
- fprintf (fp, "\tchildren [\n");
- fprintf (fp, "\t\tDEF Cameras Group {\n");
- fprintf (fp, "\t\t\tchildren [\n");
- fprintf (fp, "\t\t\t\tDEF DefaultView Viewpoint {\n");
- fprintf (fp, "\t\t\t\t\tposition 0 0 340\n");
- fprintf (fp, "\t\t\t\t\torientation 0 0 1 0\n");
- fprintf (fp, "\t\t\t\t\tdescription \"default view\"\n");
- fprintf (fp, "\t\t\t\t}\n");
- fprintf (fp, "\t\t\t]\n");
- fprintf (fp, "\t\t},\n");
- fprintf (fp, "\t]\n");
- fprintf (fp, "}\n");
-
- // Output the background stuff
- fprintf (fp, "Background {\n");
- fprintf (fp, "\tskyColor [\n");
- fprintf (fp, "\t\t.5 .5 .5\n");
- fprintf (fp, "\t]\n");
- fprintf (fp, "}\n");
-
- // Output the shape stuff
- fprintf (fp, "Transform {\n");
- fprintf (fp, "\tscale .3 .3 .3\n");
- fprintf (fp, "\tchildren [\n");
-
- // Draw the axes as a shape:
- fprintf (fp, "\t\tShape {\n");
- fprintf (fp, "\t\t\tappearance Appearance {\n");
- fprintf (fp, "\t\t\t\tmaterial Material {\n");
- fprintf (fp, "\t\t\t\t\tdiffuseColor 0 0.8 0\n");
- fprintf (fp, "\t\t\t\t\temissiveColor 1.0 1.0 1.0\n");
- fprintf (fp, "\t\t\t\t\tshininess 0.8\n");
- fprintf (fp, "\t\t\t\t}\n");
- fprintf (fp, "\t\t\t}\n");
- fprintf (fp, "\t\t\tgeometry IndexedLineSet {\n");
- fprintf (fp, "\t\t\t\tcoord Coordinate {\n");
- fprintf (fp, "\t\t\t\t\tpoint [\n");
- fprintf (fp, "\t\t\t\t\t0.0 0.0 0.0,\n");
- fprintf (fp, "\t\t\t\t\t%f 0.0 0.0,\n", 255.0);
- fprintf (fp, "\t\t\t\t\t0.0 %f 0.0,\n", 255.0);
- fprintf (fp, "\t\t\t\t\t0.0 0.0 %f]\n", 255.0);
- fprintf (fp, "\t\t\t\t}\n");
- fprintf (fp, "\t\t\t\tcoordIndex [\n");
- fprintf (fp, "\t\t\t\t\t0, 1, -1\n");
- fprintf (fp, "\t\t\t\t\t0, 2, -1\n");
- fprintf (fp, "\t\t\t\t\t0, 3, -1]\n");
- fprintf (fp, "\t\t\t}\n");
- fprintf (fp, "\t\t}\n");
-
-
- fprintf (fp, "\t\tShape {\n");
- fprintf (fp, "\t\t\tappearance Appearance {\n");
- fprintf (fp, "\t\t\t\tmaterial Material {\n");
- fprintf (fp, "\t\t\t\t\tdiffuseColor 0 0.8 0\n");
- fprintf (fp, "\t\t\t\t\temissiveColor 1 1 1\n");
- fprintf (fp, "\t\t\t\t\tshininess 0.8\n");
- fprintf (fp, "\t\t\t\t}\n");
- fprintf (fp, "\t\t\t}\n");
- fprintf (fp, "\t\t\tgeometry PointSet {\n");
-
- // fill in the points here
- fprintf (fp, "\t\t\t\tcoord Coordinate {\n");
- fprintf (fp, "\t\t\t\t\tpoint [\n");
-
- // We need to transverse all gamut hull.
- for (i=0; i < SECTORS; i++)
- for (j=0; j < SECTORS; j++) {
-
- cmsVEC3 v;
-
- pt = &gbd ->Gamut[i][j];
- ToCartesian(&v, &pt ->p);
-
- fprintf (fp, "\t\t\t\t\t%g %g %g", v.n[0]+50, v.n[1], v.n[2]);
-
- if ((j == SECTORS - 1) && (i == SECTORS - 1))
- fprintf (fp, "]\n");
- else
- fprintf (fp, ",\n");
-
- }
-
- fprintf (fp, "\t\t\t\t}\n");
-
-
-
- // fill in the face colors
- fprintf (fp, "\t\t\t\tcolor Color {\n");
- fprintf (fp, "\t\t\t\t\tcolor [\n");
-
- for (i=0; i < SECTORS; i++)
- for (j=0; j < SECTORS; j++) {
-
- cmsVEC3 v;
-
- pt = &gbd ->Gamut[i][j];
-
-
- ToCartesian(&v, &pt ->p);
-
-
- if (pt ->Type == GP_EMPTY)
- fprintf (fp, "\t\t\t\t\t%g %g %g", 0.0, 0.0, 0.0);
- else
- if (pt ->Type == GP_MODELED)
- fprintf (fp, "\t\t\t\t\t%g %g %g", 1.0, .5, .5);
- else {
- fprintf (fp, "\t\t\t\t\t%g %g %g", 1.0, 1.0, 1.0);
-
- }
-
- if ((j == SECTORS - 1) && (i == SECTORS - 1))
- fprintf (fp, "]\n");
- else
- fprintf (fp, ",\n");
- }
- fprintf (fp, "\t\t\t}\n");
-
-
- fprintf (fp, "\t\t\t}\n");
- fprintf (fp, "\t\t}\n");
- fprintf (fp, "\t]\n");
- fprintf (fp, "}\n");
-
- fclose (fp);
-
- return TRUE;
-}
-#endif
-
diff --git a/contrib/libs/lcms2/src/cmstypes.c b/contrib/libs/lcms2/src/cmstypes.c
deleted file mode 100644
index 8eabe1f079..0000000000
--- a/contrib/libs/lcms2/src/cmstypes.c
+++ /dev/null
@@ -1,6054 +0,0 @@
-//---------------------------------------------------------------------------------
-//
-// Little Color Management System
-// Copyright (c) 1998-2023 Marti Maria Saguer
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//---------------------------------------------------------------------------------
-//
-
-#include "lcms2_internal.h"
-
-// Tag Serialization -----------------------------------------------------------------------------
-// This file implements every single tag and tag type as described in the ICC spec. Some types
-// have been deprecated, like ncl and Data. There is no implementation for those types as there
-// are no profiles holding them. The programmer can also extend this list by defining his own types
-// by using the appropriate plug-in. There are three types of plug ins regarding that. First type
-// allows to define new tags using any existing type. Next plug-in type allows to define new types
-// and the third one is very specific: allows to extend the number of elements in the multiprocessing
-// elements special type.
-//--------------------------------------------------------------------------------------------------
-
-// Some broken types
-#define cmsCorbisBrokenXYZtype ((cmsTagTypeSignature) 0x17A505B8)
-#define cmsMonacoBrokenCurveType ((cmsTagTypeSignature) 0x9478ee00)
-
-// This is the linked list that keeps track of the defined types
-typedef struct _cmsTagTypeLinkedList_st {
-
- cmsTagTypeHandler Handler;
- struct _cmsTagTypeLinkedList_st* Next;
-
-} _cmsTagTypeLinkedList;
-
-// Some macros to define callbacks.
-#define READ_FN(x) Type_##x##_Read
-#define WRITE_FN(x) Type_##x##_Write
-#define FREE_FN(x) Type_##x##_Free
-#define DUP_FN(x) Type_##x##_Dup
-
-// Helper macro to define a handler. Callbacks do have a fixed naming convention.
-#define TYPE_HANDLER(t, x) { (t), READ_FN(x), WRITE_FN(x), DUP_FN(x), FREE_FN(x), NULL, 0 }
-
-// Helper macro to define a MPE handler. Callbacks do have a fixed naming convention
-#define TYPE_MPE_HANDLER(t, x) { (t), READ_FN(x), WRITE_FN(x), GenericMPEdup, GenericMPEfree, NULL, 0 }
-
-// Infinites
-#define MINUS_INF (-1E22F)
-#define PLUS_INF (+1E22F)
-
-
-// Register a new type handler. This routine is shared between normal types and MPE. LinkedList points to the optional list head
-static
-cmsBool RegisterTypesPlugin(cmsContext id, cmsPluginBase* Data, _cmsMemoryClient pos)
-{
- cmsPluginTagType* Plugin = (cmsPluginTagType*) Data;
- _cmsTagTypePluginChunkType* ctx = ( _cmsTagTypePluginChunkType*) _cmsContextGetClientChunk(id, pos);
- _cmsTagTypeLinkedList *pt;
-
- // Calling the function with NULL as plug-in would unregister the plug in.
- if (Data == NULL) {
-
- // There is no need to set free the memory, as pool is destroyed as a whole.
- ctx ->TagTypes = NULL;
- return TRUE;
- }
-
- // Registering happens in plug-in memory pool.
- pt = (_cmsTagTypeLinkedList*) _cmsPluginMalloc(id, sizeof(_cmsTagTypeLinkedList));
- if (pt == NULL) return FALSE;
-
- pt ->Handler = Plugin ->Handler;
- pt ->Next = ctx ->TagTypes;
-
- ctx ->TagTypes = pt;
-
- return TRUE;
-}
-
-// Return handler for a given type or NULL if not found. Shared between normal types and MPE. It first tries the additions
-// made by plug-ins and then the built-in defaults.
-static
-cmsTagTypeHandler* GetHandler(cmsTagTypeSignature sig, _cmsTagTypeLinkedList* PluginLinkedList, _cmsTagTypeLinkedList* DefaultLinkedList)
-{
- _cmsTagTypeLinkedList* pt;
-
- for (pt = PluginLinkedList;
- pt != NULL;
- pt = pt ->Next) {
-
- if (sig == pt -> Handler.Signature) return &pt ->Handler;
- }
-
- for (pt = DefaultLinkedList;
- pt != NULL;
- pt = pt ->Next) {
-
- if (sig == pt -> Handler.Signature) return &pt ->Handler;
- }
-
- return NULL;
-}
-
-
-// Auxiliary to convert UTF-32 to UTF-16 in some cases
-static
-cmsBool _cmsWriteWCharArray(cmsIOHANDLER* io, cmsUInt32Number n, const wchar_t* Array)
-{
- cmsUInt32Number i;
-
- _cmsAssert(io != NULL);
- _cmsAssert(!(Array == NULL && n > 0));
-
- for (i=0; i < n; i++) {
- if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) Array[i])) return FALSE;
- }
-
- return TRUE;
-}
-
-// Try to promote correctly to wchar_t when 32 bits
-cmsINLINE cmsBool is_surrogate(cmsUInt32Number uc) { return (uc - 0xd800u) < 2048u; }
-cmsINLINE cmsBool is_high_surrogate(cmsUInt32Number uc) { return (uc & 0xfffffc00) == 0xd800; }
-cmsINLINE cmsBool is_low_surrogate(cmsUInt32Number uc) { return (uc & 0xfffffc00) == 0xdc00; }
-
-cmsINLINE cmsUInt32Number surrogate_to_utf32(cmsUInt32Number high, cmsUInt32Number low)
-{
- return (high << 10) + low - 0x35fdc00;
-}
-
-cmsINLINE cmsBool convert_utf16_to_utf32(cmsIOHANDLER* io, cmsInt32Number n, wchar_t* output)
-{
- cmsUInt16Number uc;
-
- while (n > 0)
- {
- if (!_cmsReadUInt16Number(io, &uc)) return FALSE;
- n--;
-
- if (!is_surrogate(uc))
- {
- *output++ = (wchar_t)uc;
- }
- else {
-
- cmsUInt16Number low;
-
- if (!_cmsReadUInt16Number(io, &low)) return FALSE;
- n--;
-
- if (is_high_surrogate(uc) && is_low_surrogate(low))
- *output++ = (wchar_t)surrogate_to_utf32(uc, low);
- else
- return FALSE; // Corrupted string, just ignore
- }
- }
-
- return TRUE;
-}
-
-
-// Auxiliary to read an array of wchar_t
-static
-cmsBool _cmsReadWCharArray(cmsIOHANDLER* io, cmsUInt32Number n, wchar_t* Array)
-{
- cmsUInt32Number i;
- cmsUInt16Number tmp;
- cmsBool is32 = sizeof(wchar_t) > sizeof(cmsUInt16Number);
-
- _cmsAssert(io != NULL);
-
- if (is32 && Array != NULL)
- {
- return convert_utf16_to_utf32(io, n, Array);
- }
-
- for (i=0; i < n; i++) {
-
- if (Array != NULL) {
-
- if (!_cmsReadUInt16Number(io, &tmp)) return FALSE;
- Array[i] = (wchar_t) tmp;
- }
- else {
- if (!_cmsReadUInt16Number(io, NULL)) return FALSE;
- }
-
- }
- return TRUE;
-}
-
-// To deal with position tables
-typedef cmsBool (* PositionTableEntryFn)(struct _cms_typehandler_struct* self,
- cmsIOHANDLER* io,
- void* Cargo,
- cmsUInt32Number n,
- cmsUInt32Number SizeOfTag);
-
-// Helper function to deal with position tables as described in ICC spec 4.3
-// A table of n elements is read, where first comes n records containing offsets and sizes and
-// then a block containing the data itself. This allows to reuse same data in more than one entry
-static
-cmsBool ReadPositionTable(struct _cms_typehandler_struct* self,
- cmsIOHANDLER* io,
- cmsUInt32Number Count,
- cmsUInt32Number BaseOffset,
- void *Cargo,
- PositionTableEntryFn ElementFn)
-{
- cmsUInt32Number i;
- cmsUInt32Number *ElementOffsets = NULL, *ElementSizes = NULL;
- cmsUInt32Number currentPosition;
-
- currentPosition = io->Tell(io);
-
- // Verify there is enough space left to read at least two cmsUInt32Number items for Count items.
- if (((io->ReportedSize - currentPosition) / (2 * sizeof(cmsUInt32Number))) < Count)
- return FALSE;
-
- // Let's take the offsets to each element
- ElementOffsets = (cmsUInt32Number *) _cmsCalloc(io ->ContextID, Count, sizeof(cmsUInt32Number));
- if (ElementOffsets == NULL) goto Error;
-
- ElementSizes = (cmsUInt32Number *) _cmsCalloc(io ->ContextID, Count, sizeof(cmsUInt32Number));
- if (ElementSizes == NULL) goto Error;
-
- for (i=0; i < Count; i++) {
-
- if (!_cmsReadUInt32Number(io, &ElementOffsets[i])) goto Error;
- if (!_cmsReadUInt32Number(io, &ElementSizes[i])) goto Error;
-
- ElementOffsets[i] += BaseOffset;
- }
-
- // Seek to each element and read it
- for (i=0; i < Count; i++) {
-
- if (!io -> Seek(io, ElementOffsets[i])) goto Error;
-
- // This is the reader callback
- if (!ElementFn(self, io, Cargo, i, ElementSizes[i])) goto Error;
- }
-
- // Success
- if (ElementOffsets != NULL) _cmsFree(io ->ContextID, ElementOffsets);
- if (ElementSizes != NULL) _cmsFree(io ->ContextID, ElementSizes);
- return TRUE;
-
-Error:
- if (ElementOffsets != NULL) _cmsFree(io ->ContextID, ElementOffsets);
- if (ElementSizes != NULL) _cmsFree(io ->ContextID, ElementSizes);
- return FALSE;
-}
-
-// Same as anterior, but for write position tables
-static
-cmsBool WritePositionTable(struct _cms_typehandler_struct* self,
- cmsIOHANDLER* io,
- cmsUInt32Number SizeOfTag,
- cmsUInt32Number Count,
- cmsUInt32Number BaseOffset,
- void *Cargo,
- PositionTableEntryFn ElementFn)
-{
- cmsUInt32Number i;
- cmsUInt32Number DirectoryPos, CurrentPos, Before;
- cmsUInt32Number *ElementOffsets = NULL, *ElementSizes = NULL;
-
- // Create table
- ElementOffsets = (cmsUInt32Number *) _cmsCalloc(io ->ContextID, Count, sizeof(cmsUInt32Number));
- if (ElementOffsets == NULL) goto Error;
-
- ElementSizes = (cmsUInt32Number *) _cmsCalloc(io ->ContextID, Count, sizeof(cmsUInt32Number));
- if (ElementSizes == NULL) goto Error;
-
- // Keep starting position of curve offsets
- DirectoryPos = io ->Tell(io);
-
- // Write a fake directory to be filled latter on
- for (i=0; i < Count; i++) {
-
- if (!_cmsWriteUInt32Number(io, 0)) goto Error; // Offset
- if (!_cmsWriteUInt32Number(io, 0)) goto Error; // size
- }
-
- // Write each element. Keep track of the size as well.
- for (i=0; i < Count; i++) {
-
- Before = io ->Tell(io);
- ElementOffsets[i] = Before - BaseOffset;
-
- // Callback to write...
- if (!ElementFn(self, io, Cargo, i, SizeOfTag)) goto Error;
-
- // Now the size
- ElementSizes[i] = io ->Tell(io) - Before;
- }
-
- // Write the directory
- CurrentPos = io ->Tell(io);
- if (!io ->Seek(io, DirectoryPos)) goto Error;
-
- for (i=0; i < Count; i++) {
- if (!_cmsWriteUInt32Number(io, ElementOffsets[i])) goto Error;
- if (!_cmsWriteUInt32Number(io, ElementSizes[i])) goto Error;
- }
-
- if (!io ->Seek(io, CurrentPos)) goto Error;
-
- if (ElementOffsets != NULL) _cmsFree(io ->ContextID, ElementOffsets);
- if (ElementSizes != NULL) _cmsFree(io ->ContextID, ElementSizes);
- return TRUE;
-
-Error:
- if (ElementOffsets != NULL) _cmsFree(io ->ContextID, ElementOffsets);
- if (ElementSizes != NULL) _cmsFree(io ->ContextID, ElementSizes);
- return FALSE;
-}
-
-
-// ********************************************************************************
-// Type XYZ. Only one value is allowed
-// ********************************************************************************
-
-//The XYZType contains an array of three encoded values for the XYZ tristimulus
-//values. Tristimulus values must be non-negative. The signed encoding allows for
-//implementation optimizations by minimizing the number of fixed formats.
-
-
-static
-void *Type_XYZ_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
-{
- cmsCIEXYZ* xyz;
-
- *nItems = 0;
- xyz = (cmsCIEXYZ*) _cmsMallocZero(self ->ContextID, sizeof(cmsCIEXYZ));
- if (xyz == NULL) return NULL;
-
- if (!_cmsReadXYZNumber(io, xyz)) {
- _cmsFree(self ->ContextID, xyz);
- return NULL;
- }
-
- *nItems = 1;
- return (void*) xyz;
-
- cmsUNUSED_PARAMETER(SizeOfTag);
-}
-
-static
-cmsBool Type_XYZ_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
-{
- return _cmsWriteXYZNumber(io, (cmsCIEXYZ*) Ptr);
-
- cmsUNUSED_PARAMETER(nItems);
- cmsUNUSED_PARAMETER(self);
-}
-
-static
-void* Type_XYZ_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
-{
- return _cmsDupMem(self ->ContextID, Ptr, sizeof(cmsCIEXYZ));
-
- cmsUNUSED_PARAMETER(n);
-}
-
-static
-void Type_XYZ_Free(struct _cms_typehandler_struct* self, void *Ptr)
-{
- _cmsFree(self ->ContextID, Ptr);
-}
-
-
-static
-cmsTagTypeSignature DecideXYZtype(cmsFloat64Number ICCVersion, const void *Data)
-{
- return cmsSigXYZType;
-
- cmsUNUSED_PARAMETER(ICCVersion);
- cmsUNUSED_PARAMETER(Data);
-}
-
-
-// ********************************************************************************
-// Type chromaticity. Only one value is allowed
-// ********************************************************************************
-// The chromaticity tag type provides basic chromaticity data and type of
-// phosphors or colorants of a monitor to applications and utilities.
-
-static
-void *Type_Chromaticity_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
-{
- cmsCIExyYTRIPLE* chrm;
- cmsUInt16Number nChans, Table;
-
- *nItems = 0;
- chrm = (cmsCIExyYTRIPLE*) _cmsMallocZero(self ->ContextID, sizeof(cmsCIExyYTRIPLE));
- if (chrm == NULL) return NULL;
-
- if (!_cmsReadUInt16Number(io, &nChans)) goto Error;
-
- // Let's recover from a bug introduced in early versions of lcms1
- if (nChans == 0 && SizeOfTag == 32) {
-
- if (!_cmsReadUInt16Number(io, NULL)) goto Error;
- if (!_cmsReadUInt16Number(io, &nChans)) goto Error;
- }
-
- if (nChans != 3) goto Error;
-
- if (!_cmsReadUInt16Number(io, &Table)) goto Error;
-
- if (!_cmsRead15Fixed16Number(io, &chrm ->Red.x)) goto Error;
- if (!_cmsRead15Fixed16Number(io, &chrm ->Red.y)) goto Error;
-
- chrm ->Red.Y = 1.0;
-
- if (!_cmsRead15Fixed16Number(io, &chrm ->Green.x)) goto Error;
- if (!_cmsRead15Fixed16Number(io, &chrm ->Green.y)) goto Error;
-
- chrm ->Green.Y = 1.0;
-
- if (!_cmsRead15Fixed16Number(io, &chrm ->Blue.x)) goto Error;
- if (!_cmsRead15Fixed16Number(io, &chrm ->Blue.y)) goto Error;
-
- chrm ->Blue.Y = 1.0;
-
- *nItems = 1;
- return (void*) chrm;
-
-Error:
- _cmsFree(self ->ContextID, (void*) chrm);
- return NULL;
-
- cmsUNUSED_PARAMETER(SizeOfTag);
-}
-
-static
-cmsBool SaveOneChromaticity(cmsFloat64Number x, cmsFloat64Number y, cmsIOHANDLER* io)
-{
- if (!_cmsWriteUInt32Number(io, (cmsUInt32Number) _cmsDoubleTo15Fixed16(x))) return FALSE;
- if (!_cmsWriteUInt32Number(io, (cmsUInt32Number) _cmsDoubleTo15Fixed16(y))) return FALSE;
-
- return TRUE;
-}
-
-static
-cmsBool Type_Chromaticity_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
-{
- cmsCIExyYTRIPLE* chrm = (cmsCIExyYTRIPLE*) Ptr;
-
- if (!_cmsWriteUInt16Number(io, 3)) return FALSE; // nChannels
- if (!_cmsWriteUInt16Number(io, 0)) return FALSE; // Table
-
- if (!SaveOneChromaticity(chrm -> Red.x, chrm -> Red.y, io)) return FALSE;
- if (!SaveOneChromaticity(chrm -> Green.x, chrm -> Green.y, io)) return FALSE;
- if (!SaveOneChromaticity(chrm -> Blue.x, chrm -> Blue.y, io)) return FALSE;
-
- return TRUE;
-
- cmsUNUSED_PARAMETER(nItems);
- cmsUNUSED_PARAMETER(self);
-}
-
-static
-void* Type_Chromaticity_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
-{
- return _cmsDupMem(self ->ContextID, Ptr, sizeof(cmsCIExyYTRIPLE));
-
- cmsUNUSED_PARAMETER(n);
-}
-
-static
-void Type_Chromaticity_Free(struct _cms_typehandler_struct* self, void* Ptr)
-{
- _cmsFree(self ->ContextID, Ptr);
-}
-
-
-// ********************************************************************************
-// Type cmsSigColorantOrderType
-// ********************************************************************************
-
-// This is an optional tag which specifies the laydown order in which colorants will
-// be printed on an n-colorant device. The laydown order may be the same as the
-// channel generation order listed in the colorantTableTag or the channel order of a
-// colour space such as CMYK, in which case this tag is not needed. When this is not
-// the case (for example, ink-towers sometimes use the order KCMY), this tag may be
-// used to specify the laydown order of the colorants.
-
-
-static
-void *Type_ColorantOrderType_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
-{
- cmsUInt8Number* ColorantOrder;
- cmsUInt32Number Count;
-
- *nItems = 0;
- if (!_cmsReadUInt32Number(io, &Count)) return NULL;
- if (Count > cmsMAXCHANNELS) return NULL;
-
- ColorantOrder = (cmsUInt8Number*) _cmsCalloc(self ->ContextID, cmsMAXCHANNELS, sizeof(cmsUInt8Number));
- if (ColorantOrder == NULL) return NULL;
-
- // We use FF as end marker
- memset(ColorantOrder, 0xFF, cmsMAXCHANNELS * sizeof(cmsUInt8Number));
-
- if (io ->Read(io, ColorantOrder, sizeof(cmsUInt8Number), Count) != Count) {
-
- _cmsFree(self ->ContextID, (void*) ColorantOrder);
- return NULL;
- }
-
- *nItems = 1;
- return (void*) ColorantOrder;
-
- cmsUNUSED_PARAMETER(SizeOfTag);
-}
-
-static
-cmsBool Type_ColorantOrderType_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
-{
- cmsUInt8Number* ColorantOrder = (cmsUInt8Number*) Ptr;
- cmsUInt32Number i, sz, Count;
-
- // Get the length
- for (Count=i=0; i < cmsMAXCHANNELS; i++) {
- if (ColorantOrder[i] != 0xFF) Count++;
- }
-
- if (!_cmsWriteUInt32Number(io, Count)) return FALSE;
-
- sz = Count * sizeof(cmsUInt8Number);
- if (!io -> Write(io, sz, ColorantOrder)) return FALSE;
-
- return TRUE;
-
- cmsUNUSED_PARAMETER(nItems);
- cmsUNUSED_PARAMETER(self);
-}
-
-static
-void* Type_ColorantOrderType_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
-{
- return _cmsDupMem(self ->ContextID, Ptr, cmsMAXCHANNELS * sizeof(cmsUInt8Number));
-
- cmsUNUSED_PARAMETER(n);
-}
-
-
-static
-void Type_ColorantOrderType_Free(struct _cms_typehandler_struct* self, void* Ptr)
-{
- _cmsFree(self ->ContextID, Ptr);
-}
-
-// ********************************************************************************
-// Type cmsSigS15Fixed16ArrayType
-// ********************************************************************************
-// This type represents an array of generic 4-byte/32-bit fixed point quantity.
-// The number of values is determined from the size of the tag.
-
-static
-void *Type_S15Fixed16_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
-{
- cmsFloat64Number* array_double;
- cmsUInt32Number i, n;
-
- *nItems = 0;
- n = SizeOfTag / sizeof(cmsUInt32Number);
- array_double = (cmsFloat64Number*) _cmsCalloc(self ->ContextID, n, sizeof(cmsFloat64Number));
- if (array_double == NULL) return NULL;
-
- for (i=0; i < n; i++) {
-
- if (!_cmsRead15Fixed16Number(io, &array_double[i])) {
-
- _cmsFree(self ->ContextID, array_double);
- return NULL;
- }
- }
-
- *nItems = n;
- return (void*) array_double;
-}
-
-static
-cmsBool Type_S15Fixed16_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
-{
- cmsFloat64Number* Value = (cmsFloat64Number*) Ptr;
- cmsUInt32Number i;
-
- for (i=0; i < nItems; i++) {
-
- if (!_cmsWrite15Fixed16Number(io, Value[i])) return FALSE;
- }
-
- return TRUE;
-
- cmsUNUSED_PARAMETER(self);
-}
-
-static
-void* Type_S15Fixed16_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
-{
- return _cmsDupMem(self ->ContextID, Ptr, n * sizeof(cmsFloat64Number));
-}
-
-
-static
-void Type_S15Fixed16_Free(struct _cms_typehandler_struct* self, void* Ptr)
-{
- _cmsFree(self ->ContextID, Ptr);
-}
-
-// ********************************************************************************
-// Type cmsSigU16Fixed16ArrayType
-// ********************************************************************************
-// This type represents an array of generic 4-byte/32-bit quantity.
-// The number of values is determined from the size of the tag.
-
-
-static
-void *Type_U16Fixed16_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
-{
- cmsFloat64Number* array_double;
- cmsUInt32Number v;
- cmsUInt32Number i, n;
-
- *nItems = 0;
- n = SizeOfTag / sizeof(cmsUInt32Number);
- array_double = (cmsFloat64Number*) _cmsCalloc(self ->ContextID, n, sizeof(cmsFloat64Number));
- if (array_double == NULL) return NULL;
-
- for (i=0; i < n; i++) {
-
- if (!_cmsReadUInt32Number(io, &v)) {
- _cmsFree(self ->ContextID, (void*) array_double);
- return NULL;
- }
-
- // Convert to cmsFloat64Number
- array_double[i] = (cmsFloat64Number) (v / 65536.0);
- }
-
- *nItems = n;
- return (void*) array_double;
-}
-
-static
-cmsBool Type_U16Fixed16_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
-{
- cmsFloat64Number* Value = (cmsFloat64Number*) Ptr;
- cmsUInt32Number i;
-
- for (i=0; i < nItems; i++) {
-
- cmsUInt32Number v = (cmsUInt32Number) floor(Value[i]*65536.0 + 0.5);
-
- if (!_cmsWriteUInt32Number(io, v)) return FALSE;
- }
-
- return TRUE;
-
- cmsUNUSED_PARAMETER(self);
-}
-
-
-static
-void* Type_U16Fixed16_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
-{
- return _cmsDupMem(self ->ContextID, Ptr, n * sizeof(cmsFloat64Number));
-}
-
-static
-void Type_U16Fixed16_Free(struct _cms_typehandler_struct* self, void* Ptr)
-{
- _cmsFree(self ->ContextID, Ptr);
-}
-
-// ********************************************************************************
-// Type cmsSigSignatureType
-// ********************************************************************************
-//
-// The signatureType contains a four-byte sequence, Sequences of less than four
-// characters are padded at the end with spaces, 20h.
-// Typically this type is used for registered tags that can be displayed on many
-// development systems as a sequence of four characters.
-
-static
-void *Type_Signature_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
-{
- cmsSignature* SigPtr = (cmsSignature*) _cmsMalloc(self ->ContextID, sizeof(cmsSignature));
- if (SigPtr == NULL) return NULL;
-
- if (!_cmsReadUInt32Number(io, SigPtr)) return NULL;
- *nItems = 1;
-
- return SigPtr;
-
- cmsUNUSED_PARAMETER(SizeOfTag);
-}
-
-static
-cmsBool Type_Signature_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
-{
- cmsSignature* SigPtr = (cmsSignature*) Ptr;
-
- return _cmsWriteUInt32Number(io, *SigPtr);
-
- cmsUNUSED_PARAMETER(nItems);
- cmsUNUSED_PARAMETER(self);
-}
-
-static
-void* Type_Signature_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
-{
- return _cmsDupMem(self ->ContextID, Ptr, n * sizeof(cmsSignature));
-}
-
-static
-void Type_Signature_Free(struct _cms_typehandler_struct* self, void* Ptr)
-{
- _cmsFree(self ->ContextID, Ptr);
-}
-
-
-// ********************************************************************************
-// Type cmsSigTextType
-// ********************************************************************************
-//
-// The textType is a simple text structure that contains a 7-bit ASCII text string.
-// The length of the string is obtained by subtracting 8 from the element size portion
-// of the tag itself. This string must be terminated with a 00h byte.
-
-static
-void *Type_Text_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
-{
- char* Text = NULL;
- cmsMLU* mlu = NULL;
-
- // Create a container
- mlu = cmsMLUalloc(self ->ContextID, 1);
- if (mlu == NULL) return NULL;
-
- *nItems = 0;
-
- // We need to store the "\0" at the end, so +1
- if (SizeOfTag == UINT_MAX) goto Error;
-
- Text = (char*) _cmsMalloc(self ->ContextID, SizeOfTag + 1);
- if (Text == NULL) goto Error;
-
- if (io -> Read(io, Text, sizeof(char), SizeOfTag) != SizeOfTag) goto Error;
-
- // Make sure text is properly ended
- Text[SizeOfTag] = 0;
- *nItems = 1;
-
- // Keep the result
- if (!cmsMLUsetASCII(mlu, cmsNoLanguage, cmsNoCountry, Text)) goto Error;
-
- _cmsFree(self ->ContextID, Text);
- return (void*) mlu;
-
-Error:
- if (mlu != NULL)
- cmsMLUfree(mlu);
- if (Text != NULL)
- _cmsFree(self ->ContextID, Text);
-
- return NULL;
-}
-
-// The conversion implies to choose a language. So, we choose the actual language.
-static
-cmsBool Type_Text_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
-{
- cmsMLU* mlu = (cmsMLU*) Ptr;
- cmsUInt32Number size;
- cmsBool rc;
- char* Text;
-
- // Get the size of the string. Note there is an extra "\0" at the end
- size = cmsMLUgetASCII(mlu, cmsNoLanguage, cmsNoCountry, NULL, 0);
- if (size == 0) return FALSE; // Cannot be zero!
-
- // Create memory
- Text = (char*) _cmsMalloc(self ->ContextID, size);
- if (Text == NULL) return FALSE;
-
- cmsMLUgetASCII(mlu, cmsNoLanguage, cmsNoCountry, Text, size);
-
- // Write it, including separator
- rc = io ->Write(io, size, Text);
-
- _cmsFree(self ->ContextID, Text);
- return rc;
-
- cmsUNUSED_PARAMETER(nItems);
-}
-
-static
-void* Type_Text_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
-{
- return (void*) cmsMLUdup((cmsMLU*) Ptr);
-
- cmsUNUSED_PARAMETER(n);
- cmsUNUSED_PARAMETER(self);
-}
-
-
-static
-void Type_Text_Free(struct _cms_typehandler_struct* self, void* Ptr)
-{
- cmsMLU* mlu = (cmsMLU*) Ptr;
- cmsMLUfree(mlu);
- return;
-
- cmsUNUSED_PARAMETER(self);
-}
-
-static
-cmsTagTypeSignature DecideTextType(cmsFloat64Number ICCVersion, const void *Data)
-{
- if (ICCVersion >= 4.0)
- return cmsSigMultiLocalizedUnicodeType;
-
- return cmsSigTextType;
-
- cmsUNUSED_PARAMETER(Data);
-}
-
-
-// ********************************************************************************
-// Type cmsSigDataType
-// ********************************************************************************
-
-// General purpose data type
-static
-void *Type_Data_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
-{
- cmsICCData* BinData;
- cmsUInt32Number LenOfData;
-
- *nItems = 0;
-
- if (SizeOfTag < sizeof(cmsUInt32Number)) return NULL;
-
- LenOfData = SizeOfTag - sizeof(cmsUInt32Number);
- if (LenOfData > INT_MAX) return NULL;
-
- BinData = (cmsICCData*) _cmsMalloc(self ->ContextID, sizeof(cmsICCData) + LenOfData - 1);
- if (BinData == NULL) return NULL;
-
- BinData ->len = LenOfData;
- if (!_cmsReadUInt32Number(io, &BinData->flag)) {
- _cmsFree(self ->ContextID, BinData);
- return NULL;
- }
-
- if (io -> Read(io, BinData ->data, sizeof(cmsUInt8Number), LenOfData) != LenOfData) {
-
- _cmsFree(self ->ContextID, BinData);
- return NULL;
- }
-
- *nItems = 1;
-
- return (void*) BinData;
-}
-
-
-static
-cmsBool Type_Data_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
-{
- cmsICCData* BinData = (cmsICCData*) Ptr;
-
- if (!_cmsWriteUInt32Number(io, BinData ->flag)) return FALSE;
-
- return io ->Write(io, BinData ->len, BinData ->data);
-
- cmsUNUSED_PARAMETER(nItems);
- cmsUNUSED_PARAMETER(self);
-}
-
-
-static
-void* Type_Data_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
-{
- cmsICCData* BinData = (cmsICCData*) Ptr;
-
- return _cmsDupMem(self ->ContextID, Ptr, sizeof(cmsICCData) + BinData ->len - 1);
-
- cmsUNUSED_PARAMETER(n);
-}
-
-static
-void Type_Data_Free(struct _cms_typehandler_struct* self, void* Ptr)
-{
- _cmsFree(self ->ContextID, Ptr);
-}
-
-// ********************************************************************************
-// Type cmsSigTextDescriptionType
-// ********************************************************************************
-
-static
-void *Type_Text_Description_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
-{
- char* Text = NULL;
- wchar_t* UnicodeString = NULL;
- cmsMLU* mlu = NULL;
- cmsUInt32Number AsciiCount;
- cmsUInt32Number i, UnicodeCode, UnicodeCount;
- cmsUInt16Number ScriptCodeCode, Dummy;
- cmsUInt8Number ScriptCodeCount;
-
- *nItems = 0;
-
- // One dword should be there
- if (SizeOfTag < sizeof(cmsUInt32Number)) return NULL;
-
- // Read len of ASCII
- if (!_cmsReadUInt32Number(io, &AsciiCount)) return NULL;
- SizeOfTag -= sizeof(cmsUInt32Number);
-
- // Check for size
- if (SizeOfTag < AsciiCount) return NULL;
-
- // All seems Ok, allocate the container
- mlu = cmsMLUalloc(self ->ContextID, 2);
- if (mlu == NULL) return NULL;
-
- // As many memory as size of tag
- Text = (char*) _cmsMalloc(self ->ContextID, AsciiCount + 1);
- if (Text == NULL) goto Error;
-
- // Read it
- if (io ->Read(io, Text, sizeof(char), AsciiCount) != AsciiCount) goto Error;
- SizeOfTag -= AsciiCount;
-
- // Make sure there is a terminator
- Text[AsciiCount] = 0;
-
- // Set the MLU entry. From here we can be tolerant to wrong types
- if (!cmsMLUsetASCII(mlu, cmsNoLanguage, cmsNoCountry, Text)) goto Error;
- _cmsFree(self ->ContextID, (void*) Text);
- Text = NULL;
-
- // Skip Unicode code
- if (SizeOfTag < 2* sizeof(cmsUInt32Number)) goto Done;
- if (!_cmsReadUInt32Number(io, &UnicodeCode)) goto Done;
- if (!_cmsReadUInt32Number(io, &UnicodeCount)) goto Done;
- SizeOfTag -= 2* sizeof(cmsUInt32Number);
-
- if (UnicodeCount == 0 || SizeOfTag < UnicodeCount*sizeof(cmsUInt16Number)) goto Done;
-
- UnicodeString = (wchar_t*)_cmsMallocZero(self->ContextID, (UnicodeCount + 1) * sizeof(wchar_t));
- if (UnicodeString == NULL) goto Done;
-
- if (!_cmsReadWCharArray(io, UnicodeCount, UnicodeString)) {
- _cmsFree(self->ContextID, (void*)UnicodeString);
- goto Done;
- }
-
- UnicodeString[UnicodeCount] = 0;
-
- if (!cmsMLUsetWide(mlu, cmsV2Unicode, cmsV2Unicode, UnicodeString)) {
- _cmsFree(self->ContextID, (void*)UnicodeString);
- goto Done;
- }
-
- _cmsFree(self->ContextID, (void*)UnicodeString);
- UnicodeString = NULL;
-
- SizeOfTag -= UnicodeCount*sizeof(cmsUInt16Number);
-
- // Skip ScriptCode code if present. Some buggy profiles does have less
- // data that strictly required. We need to skip it as this type may come
- // embedded in other types.
-
- if (SizeOfTag >= sizeof(cmsUInt16Number) + sizeof(cmsUInt8Number) + 67) {
-
- if (!_cmsReadUInt16Number(io, &ScriptCodeCode)) goto Done;
- if (!_cmsReadUInt8Number(io, &ScriptCodeCount)) goto Done;
-
- // Skip rest of tag
- for (i=0; i < 67; i++) {
- if (!io ->Read(io, &Dummy, sizeof(cmsUInt8Number), 1)) goto Error;
- }
- }
-
-Done:
-
- *nItems = 1;
- return mlu;
-
-Error:
- if (UnicodeString) _cmsFree(self->ContextID, (void*)UnicodeString);
- if (Text) _cmsFree(self ->ContextID, (void*) Text);
- if (mlu) cmsMLUfree(mlu);
- return NULL;
-}
-
-
-// This tag can come IN UNALIGNED SIZE. In order to prevent issues, we force zeros on description to align it
-static
-cmsBool Type_Text_Description_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
-{
- cmsMLU* mlu = (cmsMLU*) Ptr;
- char *Text = NULL;
- wchar_t *Wide = NULL;
- cmsUInt32Number len, len_text, len_tag_requirement, len_aligned;
- cmsBool rc = FALSE;
- char Filler[68];
-
- // Used below for writing zeroes
- memset(Filler, 0, sizeof(Filler));
-
- // Get the len of string
- len = cmsMLUgetASCII(mlu, cmsNoLanguage, cmsNoCountry, NULL, 0);
-
- // Specification ICC.1:2001-04 (v2.4.0): It has been found that textDescriptionType can contain misaligned data
- //(see clause 4.1 for the definition of 'aligned'). Because the Unicode language
- // code and Unicode count immediately follow the ASCII description, their
- // alignment is not correct if the ASCII count is not a multiple of four. The
- // ScriptCode code is misaligned when the ASCII count is odd. Profile reading and
- // writing software must be written carefully in order to handle these alignment
- // problems.
- //
- // The above last sentence suggest to handle alignment issues in the
- // parser. The provided example (Table 69 on Page 60) makes this clear.
- // The padding only in the ASCII count is not sufficient for a aligned tag
- // size, with the same text size in ASCII and Unicode.
-
- // Null strings
- if (len <= 0) {
-
- Text = (char*) _cmsDupMem(self ->ContextID, "", sizeof(char));
- Wide = (wchar_t*) _cmsDupMem(self ->ContextID, L"", sizeof(wchar_t));
- }
- else {
- // Create independent buffers
- Text = (char*) _cmsCalloc(self ->ContextID, len, sizeof(char));
- if (Text == NULL) goto Error;
-
- Wide = (wchar_t*) _cmsCalloc(self ->ContextID, len, sizeof(wchar_t));
- if (Wide == NULL) goto Error;
-
- // Get both representations.
- cmsMLUgetASCII(mlu, cmsNoLanguage, cmsNoCountry, Text, len * sizeof(char));
- cmsMLUgetWide(mlu, cmsV2Unicode, cmsV2Unicode, Wide, len * sizeof(wchar_t));
- }
-
- // Tell the real text len including the null terminator and padding
- len_text = (cmsUInt32Number) strlen(Text) + 1;
- // Compute an total tag size requirement
- len_tag_requirement = (8+4+len_text+4+4+2*len_text+2+1+67);
- len_aligned = _cmsALIGNLONG(len_tag_requirement);
-
- // * cmsUInt32Number count; * Description length
- // * cmsInt8Number desc[count] * NULL terminated ascii string
- // * cmsUInt32Number ucLangCode; * UniCode language code
- // * cmsUInt32Number ucCount; * UniCode description length
- // * cmsInt16Number ucDesc[ucCount];* The UniCode description
- // * cmsUInt16Number scCode; * ScriptCode code
- // * cmsUInt8Number scCount; * ScriptCode count
- // * cmsInt8Number scDesc[67]; * ScriptCode Description
-
- if (!_cmsWriteUInt32Number(io, len_text)) goto Error;
- if (!io ->Write(io, len_text, Text)) goto Error;
-
- if (!_cmsWriteUInt32Number(io, 0)) goto Error; // ucLanguageCode
-
- if (!_cmsWriteUInt32Number(io, len_text)) goto Error;
- // Note that in some compilers sizeof(cmsUInt16Number) != sizeof(wchar_t)
- if (!_cmsWriteWCharArray(io, len_text, Wide)) goto Error;
-
- // ScriptCode Code & count (unused)
- if (!_cmsWriteUInt16Number(io, 0)) goto Error;
- if (!_cmsWriteUInt8Number(io, 0)) goto Error;
-
- if (!io ->Write(io, 67, Filler)) goto Error;
-
- // possibly add pad at the end of tag
- if(len_aligned - len_tag_requirement > 0)
- if (!io ->Write(io, len_aligned - len_tag_requirement, Filler)) goto Error;
-
- rc = TRUE;
-
-Error:
- if (Text) _cmsFree(self ->ContextID, Text);
- if (Wide) _cmsFree(self ->ContextID, Wide);
-
- return rc;
-
- cmsUNUSED_PARAMETER(nItems);
-}
-
-
-static
-void* Type_Text_Description_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
-{
- return (void*) cmsMLUdup((cmsMLU*) Ptr);
-
- cmsUNUSED_PARAMETER(n);
- cmsUNUSED_PARAMETER(self);
-}
-
-static
-void Type_Text_Description_Free(struct _cms_typehandler_struct* self, void* Ptr)
-{
- cmsMLU* mlu = (cmsMLU*) Ptr;
-
- cmsMLUfree(mlu);
- return;
-
- cmsUNUSED_PARAMETER(self);
-}
-
-
-static
-cmsTagTypeSignature DecideTextDescType(cmsFloat64Number ICCVersion, const void *Data)
-{
- if (ICCVersion >= 4.0)
- return cmsSigMultiLocalizedUnicodeType;
-
- return cmsSigTextDescriptionType;
-
- cmsUNUSED_PARAMETER(Data);
-}
-
-
-// ********************************************************************************
-// Type cmsSigCurveType
-// ********************************************************************************
-
-static
-void *Type_Curve_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
-{
- cmsUInt32Number Count;
- cmsToneCurve* NewGamma;
-
- *nItems = 0;
- if (!_cmsReadUInt32Number(io, &Count)) return NULL;
-
- switch (Count) {
-
- case 0: // Linear.
- {
- cmsFloat64Number SingleGamma = 1.0;
-
- NewGamma = cmsBuildParametricToneCurve(self ->ContextID, 1, &SingleGamma);
- if (!NewGamma) return NULL;
- *nItems = 1;
- return NewGamma;
- }
-
- case 1: // Specified as the exponent of gamma function
- {
- cmsUInt16Number SingleGammaFixed;
- cmsFloat64Number SingleGamma;
-
- if (!_cmsReadUInt16Number(io, &SingleGammaFixed)) return NULL;
- SingleGamma = _cms8Fixed8toDouble(SingleGammaFixed);
-
- *nItems = 1;
- return cmsBuildParametricToneCurve(self ->ContextID, 1, &SingleGamma);
- }
-
- default: // Curve
-
- if (Count > 0x7FFF)
- return NULL; // This is to prevent bad guys for doing bad things
-
- NewGamma = cmsBuildTabulatedToneCurve16(self ->ContextID, Count, NULL);
- if (!NewGamma) return NULL;
-
- if (!_cmsReadUInt16Array(io, Count, NewGamma -> Table16)) {
- cmsFreeToneCurve(NewGamma);
- return NULL;
- }
-
- *nItems = 1;
- return NewGamma;
- }
-
- cmsUNUSED_PARAMETER(SizeOfTag);
-}
-
-
-static
-cmsBool Type_Curve_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
-{
- cmsToneCurve* Curve = (cmsToneCurve*) Ptr;
-
- if (Curve ->nSegments == 1 && Curve ->Segments[0].Type == 1) {
-
- // Single gamma, preserve number
- cmsUInt16Number SingleGammaFixed = _cmsDoubleTo8Fixed8(Curve ->Segments[0].Params[0]);
-
- if (!_cmsWriteUInt32Number(io, 1)) return FALSE;
- if (!_cmsWriteUInt16Number(io, SingleGammaFixed)) return FALSE;
- return TRUE;
-
- }
-
- if (!_cmsWriteUInt32Number(io, Curve ->nEntries)) return FALSE;
- return _cmsWriteUInt16Array(io, Curve ->nEntries, Curve ->Table16);
-
- cmsUNUSED_PARAMETER(nItems);
- cmsUNUSED_PARAMETER(self);
-}
-
-
-static
-void* Type_Curve_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
-{
- return (void*) cmsDupToneCurve((cmsToneCurve*) Ptr);
-
- cmsUNUSED_PARAMETER(n);
- cmsUNUSED_PARAMETER(self);
-}
-
-static
-void Type_Curve_Free(struct _cms_typehandler_struct* self, void* Ptr)
-{
- cmsToneCurve* gamma = (cmsToneCurve*) Ptr;
-
- cmsFreeToneCurve(gamma);
- return;
-
- cmsUNUSED_PARAMETER(self);
-}
-
-
-// ********************************************************************************
-// Type cmsSigParametricCurveType
-// ********************************************************************************
-
-
-// Decide which curve type to use on writing
-static
-cmsTagTypeSignature DecideCurveType(cmsFloat64Number ICCVersion, const void *Data)
-{
- cmsToneCurve* Curve = (cmsToneCurve*) Data;
-
- if (ICCVersion < 4.0) return cmsSigCurveType;
- if (Curve ->nSegments != 1) return cmsSigCurveType; // Only 1-segment curves can be saved as parametric
- if (Curve ->Segments[0].Type < 0) return cmsSigCurveType; // Only non-inverted curves
- if (Curve ->Segments[0].Type > 5) return cmsSigCurveType; // Only ICC parametric curves
-
- return cmsSigParametricCurveType;
-}
-
-static
-void *Type_ParametricCurve_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
-{
- static const int ParamsByType[] = { 1, 3, 4, 5, 7 };
- cmsFloat64Number Params[10];
- cmsUInt16Number Type;
- int i, n;
- cmsToneCurve* NewGamma;
-
- if (!_cmsReadUInt16Number(io, &Type)) return NULL;
- if (!_cmsReadUInt16Number(io, NULL)) return NULL; // Reserved
-
- if (Type > 4) {
-
- cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unknown parametric curve type '%d'", Type);
- return NULL;
- }
-
- memset(Params, 0, sizeof(Params));
- n = ParamsByType[Type];
-
- for (i=0; i < n; i++) {
-
- if (!_cmsRead15Fixed16Number(io, &Params[i])) return NULL;
- }
-
- NewGamma = cmsBuildParametricToneCurve(self ->ContextID, Type+1, Params);
-
- *nItems = 1;
- return NewGamma;
-
- cmsUNUSED_PARAMETER(SizeOfTag);
-}
-
-
-static
-cmsBool Type_ParametricCurve_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
-{
- cmsToneCurve* Curve = (cmsToneCurve*) Ptr;
- int i, nParams, typen;
- static const int ParamsByType[] = { 0, 1, 3, 4, 5, 7 };
-
- typen = Curve -> Segments[0].Type;
-
- if (Curve ->nSegments > 1 || typen < 1) {
-
- cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Multisegment or Inverted parametric curves cannot be written");
- return FALSE;
- }
-
- if (typen > 5) {
- cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unsupported parametric curve");
- return FALSE;
- }
-
- nParams = ParamsByType[typen];
-
- if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) (Curve ->Segments[0].Type - 1))) return FALSE;
- if (!_cmsWriteUInt16Number(io, 0)) return FALSE; // Reserved
-
- for (i=0; i < nParams; i++) {
-
- if (!_cmsWrite15Fixed16Number(io, Curve -> Segments[0].Params[i])) return FALSE;
- }
-
- return TRUE;
-
- cmsUNUSED_PARAMETER(nItems);
-}
-
-static
-void* Type_ParametricCurve_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
-{
- return (void*) cmsDupToneCurve((cmsToneCurve*) Ptr);
-
- cmsUNUSED_PARAMETER(n);
- cmsUNUSED_PARAMETER(self);
-}
-
-static
-void Type_ParametricCurve_Free(struct _cms_typehandler_struct* self, void* Ptr)
-{
- cmsToneCurve* gamma = (cmsToneCurve*) Ptr;
-
- cmsFreeToneCurve(gamma);
- return;
-
- cmsUNUSED_PARAMETER(self);
-}
-
-
-// ********************************************************************************
-// Type cmsSigDateTimeType
-// ********************************************************************************
-
-// A 12-byte value representation of the time and date, where the byte usage is assigned
-// as specified in table 1. The actual values are encoded as 16-bit unsigned integers
-// (uInt16Number - see 5.1.6).
-//
-// All the dateTimeNumber values in a profile shall be in Coordinated Universal Time
-// (UTC, also known as GMT or ZULU Time). Profile writers are required to convert local
-// time to UTC when setting these values. Programs that display these values may show
-// the dateTimeNumber as UTC, show the equivalent local time (at current locale), or
-// display both UTC and local versions of the dateTimeNumber.
-
-static
-void *Type_DateTime_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
-{
- cmsDateTimeNumber timestamp;
- struct tm * NewDateTime;
-
- *nItems = 0;
- NewDateTime = (struct tm*) _cmsMalloc(self ->ContextID, sizeof(struct tm));
- if (NewDateTime == NULL) return NULL;
-
- if (io->Read(io, &timestamp, sizeof(cmsDateTimeNumber), 1) != 1) return NULL;
-
- _cmsDecodeDateTimeNumber(&timestamp, NewDateTime);
-
- *nItems = 1;
- return NewDateTime;
-
- cmsUNUSED_PARAMETER(SizeOfTag);
-}
-
-
-static
-cmsBool Type_DateTime_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
-{
- struct tm * DateTime = (struct tm*) Ptr;
- cmsDateTimeNumber timestamp;
-
- _cmsEncodeDateTimeNumber(&timestamp, DateTime);
- if (!io ->Write(io, sizeof(cmsDateTimeNumber), &timestamp)) return FALSE;
-
- return TRUE;
-
- cmsUNUSED_PARAMETER(nItems);
- cmsUNUSED_PARAMETER(self);
-}
-
-static
-void* Type_DateTime_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
-{
- return _cmsDupMem(self ->ContextID, Ptr, sizeof(struct tm));
-
- cmsUNUSED_PARAMETER(n);
-}
-
-static
-void Type_DateTime_Free(struct _cms_typehandler_struct* self, void* Ptr)
-{
- _cmsFree(self ->ContextID, Ptr);
-}
-
-
-
-// ********************************************************************************
-// Type icMeasurementType
-// ********************************************************************************
-
-/*
-The measurementType information refers only to the internal profile data and is
-meant to provide profile makers an alternative to the default measurement
-specifications.
-*/
-
-static
-void *Type_Measurement_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
-{
- cmsICCMeasurementConditions mc;
-
-
- memset(&mc, 0, sizeof(mc));
-
- if (!_cmsReadUInt32Number(io, &mc.Observer)) return NULL;
- if (!_cmsReadXYZNumber(io, &mc.Backing)) return NULL;
- if (!_cmsReadUInt32Number(io, &mc.Geometry)) return NULL;
- if (!_cmsRead15Fixed16Number(io, &mc.Flare)) return NULL;
- if (!_cmsReadUInt32Number(io, &mc.IlluminantType)) return NULL;
-
- *nItems = 1;
- return _cmsDupMem(self ->ContextID, &mc, sizeof(cmsICCMeasurementConditions));
-
- cmsUNUSED_PARAMETER(SizeOfTag);
-}
-
-
-static
-cmsBool Type_Measurement_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
-{
- cmsICCMeasurementConditions* mc =(cmsICCMeasurementConditions*) Ptr;
-
- if (!_cmsWriteUInt32Number(io, mc->Observer)) return FALSE;
- if (!_cmsWriteXYZNumber(io, &mc->Backing)) return FALSE;
- if (!_cmsWriteUInt32Number(io, mc->Geometry)) return FALSE;
- if (!_cmsWrite15Fixed16Number(io, mc->Flare)) return FALSE;
- if (!_cmsWriteUInt32Number(io, mc->IlluminantType)) return FALSE;
-
- return TRUE;
-
- cmsUNUSED_PARAMETER(nItems);
- cmsUNUSED_PARAMETER(self);
-}
-
-static
-void* Type_Measurement_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
-{
- return _cmsDupMem(self ->ContextID, Ptr, sizeof(cmsICCMeasurementConditions));
-
- cmsUNUSED_PARAMETER(n);
-}
-
-static
-void Type_Measurement_Free(struct _cms_typehandler_struct* self, void* Ptr)
-{
- _cmsFree(self ->ContextID, Ptr);
-}
-
-
-// ********************************************************************************
-// Type cmsSigMultiLocalizedUnicodeType
-// ********************************************************************************
-//
-// Do NOT trust SizeOfTag as there is an issue on the definition of profileSequenceDescTag. See the TechNote from
-// Max Derhak and Rohit Patil about this: basically the size of the string table should be guessed and cannot be
-// taken from the size of tag if this tag is embedded as part of bigger structures (profileSequenceDescTag, for instance)
-//
-
-static
-void *Type_MLU_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
-{
- cmsMLU* mlu;
- cmsUInt32Number Count, RecLen, NumOfWchar;
- cmsUInt32Number SizeOfHeader;
- cmsUInt32Number Len, Offset;
- cmsUInt32Number i;
- wchar_t* Block;
- cmsUInt32Number BeginOfThisString, EndOfThisString, LargestPosition;
-
- *nItems = 0;
- if (!_cmsReadUInt32Number(io, &Count)) return NULL;
- if (!_cmsReadUInt32Number(io, &RecLen)) return NULL;
-
- if (RecLen != 12) {
-
- cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "multiLocalizedUnicodeType of len != 12 is not supported.");
- return NULL;
- }
-
- mlu = cmsMLUalloc(self ->ContextID, Count);
- if (mlu == NULL) return NULL;
-
- mlu ->UsedEntries = Count;
-
- SizeOfHeader = 12 * Count + sizeof(_cmsTagBase);
- LargestPosition = 0;
-
- for (i=0; i < Count; i++) {
-
- if (!_cmsReadUInt16Number(io, &mlu ->Entries[i].Language)) goto Error;
- if (!_cmsReadUInt16Number(io, &mlu ->Entries[i].Country)) goto Error;
-
- // Now deal with Len and offset.
- if (!_cmsReadUInt32Number(io, &Len)) goto Error;
- if (!_cmsReadUInt32Number(io, &Offset)) goto Error;
-
- // Offset MUST be even because it indexes a block of utf16 chars.
- // Tricky profiles that uses odd positions will not work anyway
- // because the whole utf16 block is previously converted to wchar_t
- // and sizeof this type may be of 4 bytes. On Linux systems, for example.
- if (Offset & 1) goto Error;
-
- // Check for overflow
- if (Offset < (SizeOfHeader + 8)) goto Error;
- if (((Offset + Len) < Len) || ((Offset + Len) > SizeOfTag + 8)) goto Error;
-
- // True begin of the string
- BeginOfThisString = Offset - SizeOfHeader - 8;
-
- // Adjust to wchar_t elements
- mlu ->Entries[i].Len = (Len * sizeof(wchar_t)) / sizeof(cmsUInt16Number);
- mlu ->Entries[i].StrW = (BeginOfThisString * sizeof(wchar_t)) / sizeof(cmsUInt16Number);
-
- // To guess maximum size, add offset + len
- EndOfThisString = BeginOfThisString + Len;
- if (EndOfThisString > LargestPosition)
- LargestPosition = EndOfThisString;
- }
-
- // Now read the remaining of tag and fill all strings. Subtract the directory
- SizeOfTag = (LargestPosition * sizeof(wchar_t)) / sizeof(cmsUInt16Number);
- if (SizeOfTag == 0)
- {
- Block = NULL;
- }
- else
- {
- // Make sure this is an even utf16 size.
- if (SizeOfTag & 1) goto Error;
-
- Block = (wchar_t*) _cmsCalloc(self ->ContextID, 1, SizeOfTag);
- if (Block == NULL) goto Error;
-
- NumOfWchar = SizeOfTag / sizeof(wchar_t);
- if (!_cmsReadWCharArray(io, NumOfWchar, Block)) {
- _cmsFree(self->ContextID, Block);
- goto Error;
- }
- }
-
- mlu ->MemPool = Block;
- mlu ->PoolSize = SizeOfTag;
- mlu ->PoolUsed = SizeOfTag;
-
- *nItems = 1;
- return (void*) mlu;
-
-Error:
- if (mlu) cmsMLUfree(mlu);
- return NULL;
-}
-
-static
-cmsBool Type_MLU_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
-{
- cmsMLU* mlu =(cmsMLU*) Ptr;
- cmsUInt32Number HeaderSize;
- cmsUInt32Number Len, Offset;
- cmsUInt32Number i;
-
- if (Ptr == NULL) {
-
- // Empty placeholder
- if (!_cmsWriteUInt32Number(io, 0)) return FALSE;
- if (!_cmsWriteUInt32Number(io, 12)) return FALSE;
- return TRUE;
- }
-
- if (!_cmsWriteUInt32Number(io, mlu ->UsedEntries)) return FALSE;
- if (!_cmsWriteUInt32Number(io, 12)) return FALSE;
-
- HeaderSize = 12 * mlu ->UsedEntries + sizeof(_cmsTagBase);
-
- for (i=0; i < mlu ->UsedEntries; i++) {
-
- Len = mlu ->Entries[i].Len;
- Offset = mlu ->Entries[i].StrW;
-
- Len = (Len * sizeof(cmsUInt16Number)) / sizeof(wchar_t);
- Offset = (Offset * sizeof(cmsUInt16Number)) / sizeof(wchar_t) + HeaderSize + 8;
-
- if (!_cmsWriteUInt16Number(io, mlu ->Entries[i].Language)) return FALSE;
- if (!_cmsWriteUInt16Number(io, mlu ->Entries[i].Country)) return FALSE;
- if (!_cmsWriteUInt32Number(io, Len)) return FALSE;
- if (!_cmsWriteUInt32Number(io, Offset)) return FALSE;
- }
-
- if (!_cmsWriteWCharArray(io, mlu ->PoolUsed / sizeof(wchar_t), (wchar_t*) mlu ->MemPool)) return FALSE;
-
- return TRUE;
-
- cmsUNUSED_PARAMETER(nItems);
- cmsUNUSED_PARAMETER(self);
-}
-
-
-static
-void* Type_MLU_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
-{
- return (void*) cmsMLUdup((cmsMLU*) Ptr);
-
- cmsUNUSED_PARAMETER(n);
- cmsUNUSED_PARAMETER(self);
-}
-
-static
-void Type_MLU_Free(struct _cms_typehandler_struct* self, void* Ptr)
-{
- cmsMLUfree((cmsMLU*) Ptr);
- return;
-
- cmsUNUSED_PARAMETER(self);
-}
-
-
-// ********************************************************************************
-// Type cmsSigLut8Type
-// ********************************************************************************
-
-// Decide which LUT type to use on writing
-static
-cmsTagTypeSignature DecideLUTtypeA2B(cmsFloat64Number ICCVersion, const void *Data)
-{
- cmsPipeline* Lut = (cmsPipeline*) Data;
-
- if (ICCVersion < 4.0) {
- if (Lut ->SaveAs8Bits) return cmsSigLut8Type;
- return cmsSigLut16Type;
- }
- else {
- return cmsSigLutAtoBType;
- }
-}
-
-static
-cmsTagTypeSignature DecideLUTtypeB2A(cmsFloat64Number ICCVersion, const void *Data)
-{
- cmsPipeline* Lut = (cmsPipeline*) Data;
-
- if (ICCVersion < 4.0) {
- if (Lut ->SaveAs8Bits) return cmsSigLut8Type;
- return cmsSigLut16Type;
- }
- else {
- return cmsSigLutBtoAType;
- }
-}
-
-/*
-This structure represents a colour transform using tables of 8-bit precision.
-This type contains four processing elements: a 3 by 3 matrix (which shall be
-the identity matrix unless the input colour space is XYZ), a set of one dimensional
-input tables, a multidimensional lookup table, and a set of one dimensional output
-tables. Data is processed using these elements via the following sequence:
-(matrix) -> (1d input tables) -> (multidimensional lookup table - CLUT) -> (1d output tables)
-
-Byte Position Field Length (bytes) Content Encoded as...
-8 1 Number of Input Channels (i) uInt8Number
-9 1 Number of Output Channels (o) uInt8Number
-10 1 Number of CLUT grid points (identical for each side) (g) uInt8Number
-11 1 Reserved for padding (fill with 00h)
-
-12..15 4 Encoded e00 parameter s15Fixed16Number
-*/
-
-
-// Read 8 bit tables as gamma functions
-static
-cmsBool Read8bitTables(cmsContext ContextID, cmsIOHANDLER* io, cmsPipeline* lut, cmsUInt32Number nChannels)
-{
- cmsUInt8Number* Temp = NULL;
- cmsUInt32Number i, j;
- cmsToneCurve* Tables[cmsMAXCHANNELS];
-
- if (nChannels > cmsMAXCHANNELS) return FALSE;
- if (nChannels <= 0) return FALSE;
-
- memset(Tables, 0, sizeof(Tables));
-
- Temp = (cmsUInt8Number*) _cmsMalloc(ContextID, 256);
- if (Temp == NULL) return FALSE;
-
- for (i=0; i < nChannels; i++) {
- Tables[i] = cmsBuildTabulatedToneCurve16(ContextID, 256, NULL);
- if (Tables[i] == NULL) goto Error;
- }
-
- for (i=0; i < nChannels; i++) {
-
- if (io ->Read(io, Temp, 256, 1) != 1) goto Error;
-
- for (j=0; j < 256; j++)
- Tables[i]->Table16[j] = (cmsUInt16Number) FROM_8_TO_16(Temp[j]);
- }
-
- _cmsFree(ContextID, Temp);
- Temp = NULL;
-
- if (!cmsPipelineInsertStage(lut, cmsAT_END, cmsStageAllocToneCurves(ContextID, nChannels, Tables)))
- goto Error;
-
- for (i=0; i < nChannels; i++)
- cmsFreeToneCurve(Tables[i]);
-
- return TRUE;
-
-Error:
- for (i=0; i < nChannels; i++) {
- if (Tables[i]) cmsFreeToneCurve(Tables[i]);
- }
-
- if (Temp) _cmsFree(ContextID, Temp);
- return FALSE;
-}
-
-
-static
-cmsBool Write8bitTables(cmsContext ContextID, cmsIOHANDLER* io, cmsUInt32Number n, _cmsStageToneCurvesData* Tables)
-{
- int j;
- cmsUInt32Number i;
- cmsUInt8Number val;
-
- for (i=0; i < n; i++) {
-
- if (Tables) {
-
- // Usual case of identity curves
- if ((Tables ->TheCurves[i]->nEntries == 2) &&
- (Tables->TheCurves[i]->Table16[0] == 0) &&
- (Tables->TheCurves[i]->Table16[1] == 65535)) {
-
- for (j=0; j < 256; j++) {
- if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) j)) return FALSE;
- }
- }
- else
- if (Tables ->TheCurves[i]->nEntries != 256) {
- cmsSignalError(ContextID, cmsERROR_RANGE, "LUT8 needs 256 entries on prelinearization");
- return FALSE;
- }
- else
- for (j=0; j < 256; j++) {
-
- val = (cmsUInt8Number) FROM_16_TO_8(Tables->TheCurves[i]->Table16[j]);
-
- if (!_cmsWriteUInt8Number(io, val)) return FALSE;
- }
- }
- }
- return TRUE;
-}
-
-
-// Check overflow
-static
-cmsUInt32Number uipow(cmsUInt32Number n, cmsUInt32Number a, cmsUInt32Number b)
-{
- cmsUInt32Number rv = 1, rc;
-
- if (a == 0) return 0;
- if (n == 0) return 0;
-
- for (; b > 0; b--) {
-
- rv *= a;
-
- // Check for overflow
- if (rv > UINT_MAX / a) return (cmsUInt32Number) -1;
-
- }
-
- rc = rv * n;
-
- if (rv != rc / n) return (cmsUInt32Number) -1;
- return rc;
-}
-
-
-// That will create a MPE LUT with Matrix, pre tables, CLUT and post tables.
-// 8 bit lut may be scaled easily to v4 PCS, but we need also to properly adjust
-// PCS on BToAxx tags and AtoB if abstract. We need to fix input direction.
-
-static
-void *Type_LUT8_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
-{
- cmsUInt8Number InputChannels, OutputChannels, CLUTpoints;
- cmsUInt8Number* Temp = NULL;
- cmsPipeline* NewLUT = NULL;
- cmsUInt32Number nTabSize, i;
- cmsFloat64Number Matrix[3*3];
-
- *nItems = 0;
-
- if (!_cmsReadUInt8Number(io, &InputChannels)) goto Error;
- if (!_cmsReadUInt8Number(io, &OutputChannels)) goto Error;
- if (!_cmsReadUInt8Number(io, &CLUTpoints)) goto Error;
-
- if (CLUTpoints == 1) goto Error; // Impossible value, 0 for no CLUT and then 2 at least
-
- // Padding
- if (!_cmsReadUInt8Number(io, NULL)) goto Error;
-
- // Do some checking
- if (InputChannels == 0 || InputChannels > cmsMAXCHANNELS) goto Error;
- if (OutputChannels == 0 || OutputChannels > cmsMAXCHANNELS) goto Error;
-
- // Allocates an empty Pipeline
- NewLUT = cmsPipelineAlloc(self ->ContextID, InputChannels, OutputChannels);
- if (NewLUT == NULL) goto Error;
-
- // Read the Matrix
- if (!_cmsRead15Fixed16Number(io, &Matrix[0])) goto Error;
- if (!_cmsRead15Fixed16Number(io, &Matrix[1])) goto Error;
- if (!_cmsRead15Fixed16Number(io, &Matrix[2])) goto Error;
- if (!_cmsRead15Fixed16Number(io, &Matrix[3])) goto Error;
- if (!_cmsRead15Fixed16Number(io, &Matrix[4])) goto Error;
- if (!_cmsRead15Fixed16Number(io, &Matrix[5])) goto Error;
- if (!_cmsRead15Fixed16Number(io, &Matrix[6])) goto Error;
- if (!_cmsRead15Fixed16Number(io, &Matrix[7])) goto Error;
- if (!_cmsRead15Fixed16Number(io, &Matrix[8])) goto Error;
-
-
- // Only operates if not identity...
- if ((InputChannels == 3) && !_cmsMAT3isIdentity((cmsMAT3*) Matrix)) {
-
- if (!cmsPipelineInsertStage(NewLUT, cmsAT_BEGIN, cmsStageAllocMatrix(self ->ContextID, 3, 3, Matrix, NULL)))
- goto Error;
- }
-
- // Get input tables
- if (!Read8bitTables(self ->ContextID, io, NewLUT, InputChannels)) goto Error;
-
- // Get 3D CLUT. Check the overflow....
- nTabSize = uipow(OutputChannels, CLUTpoints, InputChannels);
- if (nTabSize == (cmsUInt32Number) -1) goto Error;
- if (nTabSize > 0) {
-
- cmsUInt16Number *PtrW, *T;
-
- PtrW = T = (cmsUInt16Number*) _cmsCalloc(self ->ContextID, nTabSize, sizeof(cmsUInt16Number));
- if (T == NULL) goto Error;
-
- Temp = (cmsUInt8Number*) _cmsMalloc(self ->ContextID, nTabSize);
- if (Temp == NULL) {
- _cmsFree(self ->ContextID, T);
- goto Error;
- }
-
- if (io ->Read(io, Temp, nTabSize, 1) != 1) {
- _cmsFree(self ->ContextID, T);
- _cmsFree(self ->ContextID, Temp);
- goto Error;
- }
-
- for (i = 0; i < nTabSize; i++) {
-
- *PtrW++ = FROM_8_TO_16(Temp[i]);
- }
- _cmsFree(self ->ContextID, Temp);
- Temp = NULL;
-
- if (!cmsPipelineInsertStage(NewLUT, cmsAT_END, cmsStageAllocCLut16bit(self ->ContextID, CLUTpoints, InputChannels, OutputChannels, T))) {
- _cmsFree(self ->ContextID, T);
- goto Error;
- }
- _cmsFree(self ->ContextID, T);
- }
-
-
- // Get output tables
- if (!Read8bitTables(self ->ContextID, io, NewLUT, OutputChannels)) goto Error;
-
- *nItems = 1;
- return NewLUT;
-
-Error:
- if (NewLUT != NULL) cmsPipelineFree(NewLUT);
- return NULL;
-
- cmsUNUSED_PARAMETER(SizeOfTag);
-}
-
-// We only allow a specific MPE structure: Matrix plus prelin, plus clut, plus post-lin.
-static
-cmsBool Type_LUT8_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
-{
- cmsUInt32Number j, nTabSize, i;
- cmsUInt8Number val;
- cmsPipeline* NewLUT = (cmsPipeline*) Ptr;
- cmsStage* mpe;
- _cmsStageToneCurvesData* PreMPE = NULL, *PostMPE = NULL;
- _cmsStageMatrixData* MatMPE = NULL;
- _cmsStageCLutData* clut = NULL;
- cmsUInt32Number clutPoints;
-
- // Disassemble the LUT into components.
- mpe = NewLUT -> Elements;
-
- if (mpe == NULL) { // Should never be empty. Corrupted?
- cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "empty LUT8 is not supported");
- return FALSE;
- }
-
- if (mpe ->Type == cmsSigMatrixElemType) {
-
- if (mpe->InputChannels != 3 || mpe->OutputChannels != 3) return FALSE;
- MatMPE = (_cmsStageMatrixData*) mpe ->Data;
- mpe = mpe -> Next;
- }
-
- if (mpe != NULL && mpe ->Type == cmsSigCurveSetElemType) {
- PreMPE = (_cmsStageToneCurvesData*) mpe ->Data;
- mpe = mpe -> Next;
- }
-
- if (mpe != NULL && mpe ->Type == cmsSigCLutElemType) {
- clut = (_cmsStageCLutData*) mpe -> Data;
- mpe = mpe ->Next;
- }
-
- if (mpe != NULL && mpe ->Type == cmsSigCurveSetElemType) {
- PostMPE = (_cmsStageToneCurvesData*) mpe ->Data;
- mpe = mpe -> Next;
- }
-
- // That should be all
- if (mpe != NULL) {
- cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "LUT is not suitable to be saved as LUT8");
- return FALSE;
- }
-
- if (clut == NULL)
- clutPoints = 0;
- else {
- // Lut8 only allows same CLUT points in all dimensions
- clutPoints = clut->Params->nSamples[0];
- for (i = 1; i < cmsPipelineInputChannels(NewLUT); i++) {
- if (clut->Params->nSamples[i] != clutPoints) {
- cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "LUT with different samples per dimension not suitable to be saved as LUT16");
- return FALSE;
- }
- }
- }
-
- if (!_cmsWriteUInt8Number(io, (cmsUInt8Number)cmsPipelineInputChannels(NewLUT))) return FALSE;
- if (!_cmsWriteUInt8Number(io, (cmsUInt8Number)cmsPipelineOutputChannels(NewLUT))) return FALSE;
- if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) clutPoints)) return FALSE;
- if (!_cmsWriteUInt8Number(io, 0)) return FALSE; // Padding
-
- if (MatMPE != NULL) {
-
- for (i = 0; i < 9; i++)
- {
- if (!_cmsWrite15Fixed16Number(io, MatMPE->Double[i])) return FALSE;
- }
- }
- else {
-
- if (!_cmsWrite15Fixed16Number(io, 1)) return FALSE;
- if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
- if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
- if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
- if (!_cmsWrite15Fixed16Number(io, 1)) return FALSE;
- if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
- if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
- if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
- if (!_cmsWrite15Fixed16Number(io, 1)) return FALSE;
- }
-
- // The prelinearization table
- if (!Write8bitTables(self ->ContextID, io, NewLUT ->InputChannels, PreMPE)) return FALSE;
-
- nTabSize = uipow(NewLUT->OutputChannels, clutPoints, NewLUT ->InputChannels);
- if (nTabSize == (cmsUInt32Number) -1) return FALSE;
- if (nTabSize > 0) {
-
- // The 3D CLUT.
- if (clut != NULL) {
-
- for (j=0; j < nTabSize; j++) {
-
- val = (cmsUInt8Number) FROM_16_TO_8(clut ->Tab.T[j]);
- if (!_cmsWriteUInt8Number(io, val)) return FALSE;
- }
- }
- }
-
- // The postlinearization table
- if (!Write8bitTables(self ->ContextID, io, NewLUT ->OutputChannels, PostMPE)) return FALSE;
-
- return TRUE;
-
- cmsUNUSED_PARAMETER(nItems);
-}
-
-
-static
-void* Type_LUT8_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
-{
- return (void*) cmsPipelineDup((cmsPipeline*) Ptr);
-
- cmsUNUSED_PARAMETER(n);
- cmsUNUSED_PARAMETER(self);
-}
-
-static
-void Type_LUT8_Free(struct _cms_typehandler_struct* self, void* Ptr)
-{
- cmsPipelineFree((cmsPipeline*) Ptr);
- return;
-
- cmsUNUSED_PARAMETER(self);
-}
-
-// ********************************************************************************
-// Type cmsSigLut16Type
-// ********************************************************************************
-
-// Read 16 bit tables as gamma functions
-static
-cmsBool Read16bitTables(cmsContext ContextID, cmsIOHANDLER* io, cmsPipeline* lut,
- cmsUInt32Number nChannels, cmsUInt32Number nEntries)
-{
- cmsUInt32Number i;
- cmsToneCurve* Tables[cmsMAXCHANNELS];
-
- // Maybe an empty table? (this is a lcms extension)
- if (nEntries <= 0) return TRUE;
-
- // Check for malicious profiles
- if (nEntries < 2) return FALSE;
- if (nChannels > cmsMAXCHANNELS) return FALSE;
-
- // Init table to zero
- memset(Tables, 0, sizeof(Tables));
-
- for (i=0; i < nChannels; i++) {
-
- Tables[i] = cmsBuildTabulatedToneCurve16(ContextID, nEntries, NULL);
- if (Tables[i] == NULL) goto Error;
-
- if (!_cmsReadUInt16Array(io, nEntries, Tables[i]->Table16)) goto Error;
- }
-
-
- // Add the table (which may certainly be an identity, but this is up to the optimizer, not the reading code)
- if (!cmsPipelineInsertStage(lut, cmsAT_END, cmsStageAllocToneCurves(ContextID, nChannels, Tables)))
- goto Error;
-
- for (i=0; i < nChannels; i++)
- cmsFreeToneCurve(Tables[i]);
-
- return TRUE;
-
-Error:
- for (i=0; i < nChannels; i++) {
- if (Tables[i]) cmsFreeToneCurve(Tables[i]);
- }
-
- return FALSE;
-}
-
-static
-cmsBool Write16bitTables(cmsContext ContextID, cmsIOHANDLER* io, _cmsStageToneCurvesData* Tables)
-{
- cmsUInt32Number j;
- cmsUInt32Number i;
- cmsUInt16Number val;
- cmsUInt32Number nEntries;
-
- _cmsAssert(Tables != NULL);
-
- for (i=0; i < Tables ->nCurves; i++) {
-
- nEntries = Tables->TheCurves[i]->nEntries;
-
- for (j=0; j < nEntries; j++) {
-
- val = Tables->TheCurves[i]->Table16[j];
- if (!_cmsWriteUInt16Number(io, val)) return FALSE;
- }
- }
- return TRUE;
-
- cmsUNUSED_PARAMETER(ContextID);
-}
-
-static
-void *Type_LUT16_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
-{
- cmsUInt8Number InputChannels, OutputChannels, CLUTpoints;
- cmsPipeline* NewLUT = NULL;
- cmsUInt32Number nTabSize;
- cmsFloat64Number Matrix[3*3];
- cmsUInt16Number InputEntries, OutputEntries;
-
- *nItems = 0;
-
- if (!_cmsReadUInt8Number(io, &InputChannels)) return NULL;
- if (!_cmsReadUInt8Number(io, &OutputChannels)) return NULL;
- if (!_cmsReadUInt8Number(io, &CLUTpoints)) return NULL; // 255 maximum
-
- // Padding
- if (!_cmsReadUInt8Number(io, NULL)) return NULL;
-
- // Do some checking
- if (InputChannels == 0 || InputChannels > cmsMAXCHANNELS) goto Error;
- if (OutputChannels == 0 || OutputChannels > cmsMAXCHANNELS) goto Error;
-
- // Allocates an empty LUT
- NewLUT = cmsPipelineAlloc(self ->ContextID, InputChannels, OutputChannels);
- if (NewLUT == NULL) goto Error;
-
- // Read the Matrix
- if (!_cmsRead15Fixed16Number(io, &Matrix[0])) goto Error;
- if (!_cmsRead15Fixed16Number(io, &Matrix[1])) goto Error;
- if (!_cmsRead15Fixed16Number(io, &Matrix[2])) goto Error;
- if (!_cmsRead15Fixed16Number(io, &Matrix[3])) goto Error;
- if (!_cmsRead15Fixed16Number(io, &Matrix[4])) goto Error;
- if (!_cmsRead15Fixed16Number(io, &Matrix[5])) goto Error;
- if (!_cmsRead15Fixed16Number(io, &Matrix[6])) goto Error;
- if (!_cmsRead15Fixed16Number(io, &Matrix[7])) goto Error;
- if (!_cmsRead15Fixed16Number(io, &Matrix[8])) goto Error;
-
-
- // Only operates on 3 channels
- if ((InputChannels == 3) && !_cmsMAT3isIdentity((cmsMAT3*) Matrix)) {
-
- if (!cmsPipelineInsertStage(NewLUT, cmsAT_END, cmsStageAllocMatrix(self ->ContextID, 3, 3, Matrix, NULL)))
- goto Error;
- }
-
- if (!_cmsReadUInt16Number(io, &InputEntries)) goto Error;
- if (!_cmsReadUInt16Number(io, &OutputEntries)) goto Error;
-
- if (InputEntries > 0x7FFF || OutputEntries > 0x7FFF) goto Error;
- if (CLUTpoints == 1) goto Error; // Impossible value, 0 for no CLUT and then 2 at least
-
- // Get input tables
- if (!Read16bitTables(self ->ContextID, io, NewLUT, InputChannels, InputEntries)) goto Error;
-
- // Get 3D CLUT
- nTabSize = uipow(OutputChannels, CLUTpoints, InputChannels);
- if (nTabSize == (cmsUInt32Number) -1) goto Error;
- if (nTabSize > 0) {
-
- cmsUInt16Number *T;
-
- T = (cmsUInt16Number*) _cmsCalloc(self ->ContextID, nTabSize, sizeof(cmsUInt16Number));
- if (T == NULL) goto Error;
-
- if (!_cmsReadUInt16Array(io, nTabSize, T)) {
- _cmsFree(self ->ContextID, T);
- goto Error;
- }
-
- if (!cmsPipelineInsertStage(NewLUT, cmsAT_END, cmsStageAllocCLut16bit(self ->ContextID, CLUTpoints, InputChannels, OutputChannels, T))) {
- _cmsFree(self ->ContextID, T);
- goto Error;
- }
- _cmsFree(self ->ContextID, T);
- }
-
-
- // Get output tables
- if (!Read16bitTables(self ->ContextID, io, NewLUT, OutputChannels, OutputEntries)) goto Error;
-
- *nItems = 1;
- return NewLUT;
-
-Error:
- if (NewLUT != NULL) cmsPipelineFree(NewLUT);
- return NULL;
-
- cmsUNUSED_PARAMETER(SizeOfTag);
-}
-
-// We only allow some specific MPE structures: Matrix plus prelin, plus clut, plus post-lin.
-// Some empty defaults are created for missing parts
-
-static
-cmsBool Type_LUT16_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
-{
- cmsUInt32Number nTabSize;
- cmsPipeline* NewLUT = (cmsPipeline*) Ptr;
- cmsStage* mpe;
- _cmsStageToneCurvesData* PreMPE = NULL, *PostMPE = NULL;
- _cmsStageMatrixData* MatMPE = NULL;
- _cmsStageCLutData* clut = NULL;
- cmsUInt32Number i, InputChannels, OutputChannels, clutPoints;
-
- // Disassemble the LUT into components.
- mpe = NewLUT -> Elements;
- if (mpe != NULL && mpe ->Type == cmsSigMatrixElemType) {
-
- MatMPE = (_cmsStageMatrixData*) mpe ->Data;
- if (mpe->InputChannels != 3 || mpe->OutputChannels != 3) return FALSE;
- mpe = mpe -> Next;
- }
-
-
- if (mpe != NULL && mpe ->Type == cmsSigCurveSetElemType) {
- PreMPE = (_cmsStageToneCurvesData*) mpe ->Data;
- mpe = mpe -> Next;
- }
-
- if (mpe != NULL && mpe ->Type == cmsSigCLutElemType) {
- clut = (_cmsStageCLutData*) mpe -> Data;
- mpe = mpe ->Next;
- }
-
- if (mpe != NULL && mpe ->Type == cmsSigCurveSetElemType) {
- PostMPE = (_cmsStageToneCurvesData*) mpe ->Data;
- mpe = mpe -> Next;
- }
-
- // That should be all
- if (mpe != NULL) {
- cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "LUT is not suitable to be saved as LUT16");
- return FALSE;
- }
-
- InputChannels = cmsPipelineInputChannels(NewLUT);
- OutputChannels = cmsPipelineOutputChannels(NewLUT);
-
- if (clut == NULL)
- clutPoints = 0;
- else {
- // Lut16 only allows same CLUT points in all dimensions
- clutPoints = clut->Params->nSamples[0];
- for (i = 1; i < InputChannels; i++) {
- if (clut->Params->nSamples[i] != clutPoints) {
- cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "LUT with different samples per dimension not suitable to be saved as LUT16");
- return FALSE;
- }
- }
- }
-
- if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) InputChannels)) return FALSE;
- if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) OutputChannels)) return FALSE;
- if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) clutPoints)) return FALSE;
- if (!_cmsWriteUInt8Number(io, 0)) return FALSE; // Padding
-
- if (MatMPE != NULL) {
-
- for (i = 0; i < 9; i++)
- {
- if (!_cmsWrite15Fixed16Number(io, MatMPE->Double[i])) return FALSE;
- }
-
- }
- else {
-
- if (!_cmsWrite15Fixed16Number(io, 1)) return FALSE;
- if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
- if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
- if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
- if (!_cmsWrite15Fixed16Number(io, 1)) return FALSE;
- if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
- if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
- if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
- if (!_cmsWrite15Fixed16Number(io, 1)) return FALSE;
- }
-
-
- if (PreMPE != NULL) {
- if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) PreMPE ->TheCurves[0]->nEntries)) return FALSE;
- } else {
- if (!_cmsWriteUInt16Number(io, 2)) return FALSE;
- }
-
- if (PostMPE != NULL) {
- if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) PostMPE ->TheCurves[0]->nEntries)) return FALSE;
- } else {
- if (!_cmsWriteUInt16Number(io, 2)) return FALSE;
-
- }
-
- // The prelinearization table
-
- if (PreMPE != NULL) {
- if (!Write16bitTables(self ->ContextID, io, PreMPE)) return FALSE;
- }
- else {
- for (i=0; i < InputChannels; i++) {
-
- if (!_cmsWriteUInt16Number(io, 0)) return FALSE;
- if (!_cmsWriteUInt16Number(io, 0xffff)) return FALSE;
- }
- }
-
- nTabSize = uipow(OutputChannels, clutPoints, InputChannels);
- if (nTabSize == (cmsUInt32Number) -1) return FALSE;
- if (nTabSize > 0) {
- // The 3D CLUT.
- if (clut != NULL) {
- if (!_cmsWriteUInt16Array(io, nTabSize, clut->Tab.T)) return FALSE;
- }
- }
-
- // The postlinearization table
- if (PostMPE != NULL) {
- if (!Write16bitTables(self ->ContextID, io, PostMPE)) return FALSE;
- }
- else {
- for (i=0; i < OutputChannels; i++) {
-
- if (!_cmsWriteUInt16Number(io, 0)) return FALSE;
- if (!_cmsWriteUInt16Number(io, 0xffff)) return FALSE;
- }
- }
-
- return TRUE;
-
- cmsUNUSED_PARAMETER(nItems);
-}
-
-static
-void* Type_LUT16_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
-{
- return (void*) cmsPipelineDup((cmsPipeline*) Ptr);
-
- cmsUNUSED_PARAMETER(n);
- cmsUNUSED_PARAMETER(self);
-}
-
-static
-void Type_LUT16_Free(struct _cms_typehandler_struct* self, void* Ptr)
-{
- cmsPipelineFree((cmsPipeline*) Ptr);
- return;
-
- cmsUNUSED_PARAMETER(self);
-}
-
-
-// ********************************************************************************
-// Type cmsSigLutAToBType
-// ********************************************************************************
-
-
-// V4 stuff. Read matrix for LutAtoB and LutBtoA
-
-static
-cmsStage* ReadMatrix(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number Offset)
-{
- cmsFloat64Number dMat[3*3];
- cmsFloat64Number dOff[3];
- cmsStage* Mat;
-
- // Go to address
- if (!io -> Seek(io, Offset)) return NULL;
-
- // Read the Matrix
- if (!_cmsRead15Fixed16Number(io, &dMat[0])) return NULL;
- if (!_cmsRead15Fixed16Number(io, &dMat[1])) return NULL;
- if (!_cmsRead15Fixed16Number(io, &dMat[2])) return NULL;
- if (!_cmsRead15Fixed16Number(io, &dMat[3])) return NULL;
- if (!_cmsRead15Fixed16Number(io, &dMat[4])) return NULL;
- if (!_cmsRead15Fixed16Number(io, &dMat[5])) return NULL;
- if (!_cmsRead15Fixed16Number(io, &dMat[6])) return NULL;
- if (!_cmsRead15Fixed16Number(io, &dMat[7])) return NULL;
- if (!_cmsRead15Fixed16Number(io, &dMat[8])) return NULL;
-
- if (!_cmsRead15Fixed16Number(io, &dOff[0])) return NULL;
- if (!_cmsRead15Fixed16Number(io, &dOff[1])) return NULL;
- if (!_cmsRead15Fixed16Number(io, &dOff[2])) return NULL;
-
- Mat = cmsStageAllocMatrix(self ->ContextID, 3, 3, dMat, dOff);
-
- return Mat;
-}
-
-
-
-
-// V4 stuff. Read CLUT part for LutAtoB and LutBtoA
-
-static
-cmsStage* ReadCLUT(struct _cms_typehandler_struct* self, cmsIOHANDLER* io,
- cmsUInt32Number Offset, cmsUInt32Number InputChannels, cmsUInt32Number OutputChannels)
-{
- cmsUInt8Number gridPoints8[cmsMAXCHANNELS]; // Number of grid points in each dimension.
- cmsUInt32Number GridPoints[cmsMAXCHANNELS], i;
- cmsUInt8Number Precision;
- cmsStage* CLUT;
- _cmsStageCLutData* Data;
-
- if (!io -> Seek(io, Offset)) return NULL;
- if (io -> Read(io, gridPoints8, cmsMAXCHANNELS, 1) != 1) return NULL;
-
-
- for (i=0; i < cmsMAXCHANNELS; i++) {
-
- if (gridPoints8[i] == 1) return NULL; // Impossible value, 0 for no CLUT and then 2 at least
- GridPoints[i] = gridPoints8[i];
- }
-
- if (!_cmsReadUInt8Number(io, &Precision)) return NULL;
-
- if (!_cmsReadUInt8Number(io, NULL)) return NULL;
- if (!_cmsReadUInt8Number(io, NULL)) return NULL;
- if (!_cmsReadUInt8Number(io, NULL)) return NULL;
-
- CLUT = cmsStageAllocCLut16bitGranular(self ->ContextID, GridPoints, InputChannels, OutputChannels, NULL);
- if (CLUT == NULL) return NULL;
-
- Data = (_cmsStageCLutData*) CLUT ->Data;
-
- // Precision can be 1 or 2 bytes
- if (Precision == 1) {
-
- cmsUInt8Number v;
-
- for (i=0; i < Data ->nEntries; i++) {
-
- if (io ->Read(io, &v, sizeof(cmsUInt8Number), 1) != 1) {
- cmsStageFree(CLUT);
- return NULL;
- }
- Data ->Tab.T[i] = FROM_8_TO_16(v);
- }
-
- }
- else
- if (Precision == 2) {
-
- if (!_cmsReadUInt16Array(io, Data->nEntries, Data ->Tab.T)) {
- cmsStageFree(CLUT);
- return NULL;
- }
- }
- else {
- cmsStageFree(CLUT);
- cmsSignalError(self ->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unknown precision of '%d'", Precision);
- return NULL;
- }
-
- return CLUT;
-}
-
-static
-cmsToneCurve* ReadEmbeddedCurve(struct _cms_typehandler_struct* self, cmsIOHANDLER* io)
-{
- cmsTagTypeSignature BaseType;
- cmsUInt32Number nItems;
-
- BaseType = _cmsReadTypeBase(io);
- switch (BaseType) {
-
- case cmsSigCurveType:
- return (cmsToneCurve*) Type_Curve_Read(self, io, &nItems, 0);
-
- case cmsSigParametricCurveType:
- return (cmsToneCurve*) Type_ParametricCurve_Read(self, io, &nItems, 0);
-
- default:
- {
- char String[5];
-
- _cmsTagSignature2String(String, (cmsTagSignature) BaseType);
- cmsSignalError(self ->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unknown curve type '%s'", String);
- }
- return NULL;
- }
-}
-
-
-// Read a set of curves from specific offset
-static
-cmsStage* ReadSetOfCurves(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number Offset, cmsUInt32Number nCurves)
-{
- cmsToneCurve* Curves[cmsMAXCHANNELS];
- cmsUInt32Number i;
- cmsStage* Lin = NULL;
-
- if (nCurves > cmsMAXCHANNELS) return FALSE;
-
- if (!io -> Seek(io, Offset)) return FALSE;
-
- for (i=0; i < nCurves; i++)
- Curves[i] = NULL;
-
- for (i=0; i < nCurves; i++) {
-
- Curves[i] = ReadEmbeddedCurve(self, io);
- if (Curves[i] == NULL) goto Error;
- if (!_cmsReadAlignment(io)) goto Error;
-
- }
-
- Lin = cmsStageAllocToneCurves(self ->ContextID, nCurves, Curves);
-
-Error:
- for (i=0; i < nCurves; i++)
- cmsFreeToneCurve(Curves[i]);
-
- return Lin;
-}
-
-
-// LutAtoB type
-
-// This structure represents a colour transform. The type contains up to five processing
-// elements which are stored in the AtoBTag tag in the following order: a set of one
-// dimensional curves, a 3 by 3 matrix with offset terms, a set of one dimensional curves,
-// a multidimensional lookup table, and a set of one dimensional output curves.
-// Data are processed using these elements via the following sequence:
-//
-//("A" curves) -> (multidimensional lookup table - CLUT) -> ("M" curves) -> (matrix) -> ("B" curves).
-//
-/*
-It is possible to use any or all of these processing elements. At least one processing element
-must be included.Only the following combinations are allowed:
-
-B
-M - Matrix - B
-A - CLUT - B
-A - CLUT - M - Matrix - B
-
-*/
-
-static
-void* Type_LUTA2B_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
-{
- cmsUInt32Number BaseOffset;
- cmsUInt8Number inputChan; // Number of input channels
- cmsUInt8Number outputChan; // Number of output channels
- cmsUInt32Number offsetB; // Offset to first "B" curve
- cmsUInt32Number offsetMat; // Offset to matrix
- cmsUInt32Number offsetM; // Offset to first "M" curve
- cmsUInt32Number offsetC; // Offset to CLUT
- cmsUInt32Number offsetA; // Offset to first "A" curve
- cmsPipeline* NewLUT = NULL;
-
-
- BaseOffset = io ->Tell(io) - sizeof(_cmsTagBase);
-
- if (!_cmsReadUInt8Number(io, &inputChan)) return NULL;
- if (!_cmsReadUInt8Number(io, &outputChan)) return NULL;
-
- if (!_cmsReadUInt16Number(io, NULL)) return NULL;
-
- if (!_cmsReadUInt32Number(io, &offsetB)) return NULL;
- if (!_cmsReadUInt32Number(io, &offsetMat)) return NULL;
- if (!_cmsReadUInt32Number(io, &offsetM)) return NULL;
- if (!_cmsReadUInt32Number(io, &offsetC)) return NULL;
- if (!_cmsReadUInt32Number(io, &offsetA)) return NULL;
-
- if (inputChan == 0 || inputChan >= cmsMAXCHANNELS) return NULL;
- if (outputChan == 0 || outputChan >= cmsMAXCHANNELS) return NULL;
-
- // Allocates an empty LUT
- NewLUT = cmsPipelineAlloc(self ->ContextID, inputChan, outputChan);
- if (NewLUT == NULL) return NULL;
-
- if (offsetA!= 0) {
- if (!cmsPipelineInsertStage(NewLUT, cmsAT_END, ReadSetOfCurves(self, io, BaseOffset + offsetA, inputChan)))
- goto Error;
- }
-
- if (offsetC != 0) {
- if (!cmsPipelineInsertStage(NewLUT, cmsAT_END, ReadCLUT(self, io, BaseOffset + offsetC, inputChan, outputChan)))
- goto Error;
- }
-
- if (offsetM != 0) {
- if (!cmsPipelineInsertStage(NewLUT, cmsAT_END, ReadSetOfCurves(self, io, BaseOffset + offsetM, outputChan)))
- goto Error;
- }
-
- if (offsetMat != 0) {
- if (!cmsPipelineInsertStage(NewLUT, cmsAT_END, ReadMatrix(self, io, BaseOffset + offsetMat)))
- goto Error;
- }
-
- if (offsetB != 0) {
- if (!cmsPipelineInsertStage(NewLUT, cmsAT_END, ReadSetOfCurves(self, io, BaseOffset + offsetB, outputChan)))
- goto Error;
- }
-
- *nItems = 1;
- return NewLUT;
-Error:
- cmsPipelineFree(NewLUT);
- return NULL;
-
- cmsUNUSED_PARAMETER(SizeOfTag);
-}
-
-// Write a set of curves
-static
-cmsBool WriteMatrix(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsStage* mpe)
-{
- cmsUInt32Number i, n;
-
- _cmsStageMatrixData* m = (_cmsStageMatrixData*) mpe -> Data;
-
- n = mpe->InputChannels * mpe->OutputChannels;
-
- // Write the Matrix
- for (i = 0; i < n; i++)
- {
- if (!_cmsWrite15Fixed16Number(io, m->Double[i])) return FALSE;
- }
-
- if (m->Offset != NULL) {
-
- for (i = 0; i < mpe->OutputChannels; i++)
- {
- if (!_cmsWrite15Fixed16Number(io, m->Offset[i])) return FALSE;
- }
- }
- else {
- for (i = 0; i < mpe->OutputChannels; i++)
- {
- if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
- }
- }
-
-
- return TRUE;
-
- cmsUNUSED_PARAMETER(self);
-}
-
-
-// Write a set of curves
-static
-cmsBool WriteSetOfCurves(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsTagTypeSignature Type, cmsStage* mpe)
-{
- cmsUInt32Number i, n;
- cmsTagTypeSignature CurrentType;
- cmsToneCurve** Curves;
-
-
- n = cmsStageOutputChannels(mpe);
- Curves = _cmsStageGetPtrToCurveSet(mpe);
-
- for (i=0; i < n; i++) {
-
- // If this is a table-based curve, use curve type even on V4
- CurrentType = Type;
-
- if ((Curves[i] ->nSegments == 0) || // 16 bits tabulated
- ((Curves[i]->nSegments == 3) && (Curves[i] ->Segments[1].Type == 0)) ) // Floating-point tabulated
- CurrentType = cmsSigCurveType;
- else
- if (Curves[i] ->Segments[0].Type < 0)
- CurrentType = cmsSigCurveType;
-
- if (!_cmsWriteTypeBase(io, CurrentType)) return FALSE;
-
- switch (CurrentType) {
-
- case cmsSigCurveType:
- if (!Type_Curve_Write(self, io, Curves[i], 1)) return FALSE;
- break;
-
- case cmsSigParametricCurveType:
- if (!Type_ParametricCurve_Write(self, io, Curves[i], 1)) return FALSE;
- break;
-
- default:
- {
- char String[5];
-
- _cmsTagSignature2String(String, (cmsTagSignature) Type);
- cmsSignalError(self ->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unknown curve type '%s'", String);
- }
- return FALSE;
- }
-
- if (!_cmsWriteAlignment(io)) return FALSE;
- }
-
-
- return TRUE;
-}
-
-
-static
-cmsBool WriteCLUT(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt8Number Precision, cmsStage* mpe)
-{
- cmsUInt8Number gridPoints[cmsMAXCHANNELS]; // Number of grid points in each dimension.
- cmsUInt32Number i;
- _cmsStageCLutData* CLUT = ( _cmsStageCLutData*) mpe -> Data;
-
- if (CLUT ->HasFloatValues) {
- cmsSignalError(self ->ContextID, cmsERROR_NOT_SUITABLE, "Cannot save floating point data, CLUT are 8 or 16 bit only");
- return FALSE;
- }
-
- memset(gridPoints, 0, sizeof(gridPoints));
- for (i=0; i < (cmsUInt32Number) CLUT ->Params ->nInputs; i++)
- gridPoints[i] = (cmsUInt8Number) CLUT ->Params ->nSamples[i];
-
- if (!io -> Write(io, cmsMAXCHANNELS*sizeof(cmsUInt8Number), gridPoints)) return FALSE;
-
- if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) Precision)) return FALSE;
- if (!_cmsWriteUInt8Number(io, 0)) return FALSE;
- if (!_cmsWriteUInt8Number(io, 0)) return FALSE;
- if (!_cmsWriteUInt8Number(io, 0)) return FALSE;
-
- // Precision can be 1 or 2 bytes
- if (Precision == 1) {
-
- for (i=0; i < CLUT->nEntries; i++) {
-
- if (!_cmsWriteUInt8Number(io, FROM_16_TO_8(CLUT->Tab.T[i]))) return FALSE;
- }
- }
- else
- if (Precision == 2) {
-
- if (!_cmsWriteUInt16Array(io, CLUT->nEntries, CLUT ->Tab.T)) return FALSE;
- }
- else {
- cmsSignalError(self ->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unknown precision of '%d'", Precision);
- return FALSE;
- }
-
- if (!_cmsWriteAlignment(io)) return FALSE;
-
- return TRUE;
-}
-
-
-
-
-static
-cmsBool Type_LUTA2B_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
-{
- cmsPipeline* Lut = (cmsPipeline*) Ptr;
- cmsUInt32Number inputChan, outputChan;
- cmsStage *A = NULL, *B = NULL, *M = NULL;
- cmsStage * Matrix = NULL;
- cmsStage * CLUT = NULL;
- cmsUInt32Number offsetB = 0, offsetMat = 0, offsetM = 0, offsetC = 0, offsetA = 0;
- cmsUInt32Number BaseOffset, DirectoryPos, CurrentPos;
-
- // Get the base for all offsets
- BaseOffset = io ->Tell(io) - sizeof(_cmsTagBase);
-
- if (Lut ->Elements != NULL)
- if (!cmsPipelineCheckAndRetreiveStages(Lut, 1, cmsSigCurveSetElemType, &B))
- if (!cmsPipelineCheckAndRetreiveStages(Lut, 3, cmsSigCurveSetElemType, cmsSigMatrixElemType, cmsSigCurveSetElemType, &M, &Matrix, &B))
- if (!cmsPipelineCheckAndRetreiveStages(Lut, 3, cmsSigCurveSetElemType, cmsSigCLutElemType, cmsSigCurveSetElemType, &A, &CLUT, &B))
- if (!cmsPipelineCheckAndRetreiveStages(Lut, 5, cmsSigCurveSetElemType, cmsSigCLutElemType, cmsSigCurveSetElemType,
- cmsSigMatrixElemType, cmsSigCurveSetElemType, &A, &CLUT, &M, &Matrix, &B)) {
-
- cmsSignalError(self->ContextID, cmsERROR_NOT_SUITABLE, "LUT is not suitable to be saved as LutAToB");
- return FALSE;
- }
-
- // Get input, output channels
- inputChan = cmsPipelineInputChannels(Lut);
- outputChan = cmsPipelineOutputChannels(Lut);
-
- // Write channel count
- if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) inputChan)) return FALSE;
- if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) outputChan)) return FALSE;
- if (!_cmsWriteUInt16Number(io, 0)) return FALSE;
-
- // Keep directory to be filled latter
- DirectoryPos = io ->Tell(io);
-
- // Write the directory
- if (!_cmsWriteUInt32Number(io, 0)) return FALSE;
- if (!_cmsWriteUInt32Number(io, 0)) return FALSE;
- if (!_cmsWriteUInt32Number(io, 0)) return FALSE;
- if (!_cmsWriteUInt32Number(io, 0)) return FALSE;
- if (!_cmsWriteUInt32Number(io, 0)) return FALSE;
-
- if (A != NULL) {
-
- offsetA = io ->Tell(io) - BaseOffset;
- if (!WriteSetOfCurves(self, io, cmsSigParametricCurveType, A)) return FALSE;
- }
-
- if (CLUT != NULL) {
- offsetC = io ->Tell(io) - BaseOffset;
- if (!WriteCLUT(self, io, (Lut ->SaveAs8Bits ? 1U : 2U), CLUT)) return FALSE;
-
- }
- if (M != NULL) {
-
- offsetM = io ->Tell(io) - BaseOffset;
- if (!WriteSetOfCurves(self, io, cmsSigParametricCurveType, M)) return FALSE;
- }
-
- if (Matrix != NULL) {
- offsetMat = io ->Tell(io) - BaseOffset;
- if (!WriteMatrix(self, io, Matrix)) return FALSE;
- }
-
- if (B != NULL) {
-
- offsetB = io ->Tell(io) - BaseOffset;
- if (!WriteSetOfCurves(self, io, cmsSigParametricCurveType, B)) return FALSE;
- }
-
- CurrentPos = io ->Tell(io);
-
- if (!io ->Seek(io, DirectoryPos)) return FALSE;
-
- if (!_cmsWriteUInt32Number(io, offsetB)) return FALSE;
- if (!_cmsWriteUInt32Number(io, offsetMat)) return FALSE;
- if (!_cmsWriteUInt32Number(io, offsetM)) return FALSE;
- if (!_cmsWriteUInt32Number(io, offsetC)) return FALSE;
- if (!_cmsWriteUInt32Number(io, offsetA)) return FALSE;
-
- if (!io ->Seek(io, CurrentPos)) return FALSE;
-
- return TRUE;
-
- cmsUNUSED_PARAMETER(nItems);
-}
-
-
-static
-void* Type_LUTA2B_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
-{
- return (void*) cmsPipelineDup((cmsPipeline*) Ptr);
-
- cmsUNUSED_PARAMETER(n);
- cmsUNUSED_PARAMETER(self);
-}
-
-static
-void Type_LUTA2B_Free(struct _cms_typehandler_struct* self, void* Ptr)
-{
- cmsPipelineFree((cmsPipeline*) Ptr);
- return;
-
- cmsUNUSED_PARAMETER(self);
-}
-
-
-// LutBToA type
-
-static
-void* Type_LUTB2A_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
-{
- cmsUInt8Number inputChan; // Number of input channels
- cmsUInt8Number outputChan; // Number of output channels
- cmsUInt32Number BaseOffset; // Actual position in file
- cmsUInt32Number offsetB; // Offset to first "B" curve
- cmsUInt32Number offsetMat; // Offset to matrix
- cmsUInt32Number offsetM; // Offset to first "M" curve
- cmsUInt32Number offsetC; // Offset to CLUT
- cmsUInt32Number offsetA; // Offset to first "A" curve
- cmsPipeline* NewLUT = NULL;
-
-
- BaseOffset = io ->Tell(io) - sizeof(_cmsTagBase);
-
- if (!_cmsReadUInt8Number(io, &inputChan)) return NULL;
- if (!_cmsReadUInt8Number(io, &outputChan)) return NULL;
-
- if (inputChan == 0 || inputChan >= cmsMAXCHANNELS) return NULL;
- if (outputChan == 0 || outputChan >= cmsMAXCHANNELS) return NULL;
-
- // Padding
- if (!_cmsReadUInt16Number(io, NULL)) return NULL;
-
- if (!_cmsReadUInt32Number(io, &offsetB)) return NULL;
- if (!_cmsReadUInt32Number(io, &offsetMat)) return NULL;
- if (!_cmsReadUInt32Number(io, &offsetM)) return NULL;
- if (!_cmsReadUInt32Number(io, &offsetC)) return NULL;
- if (!_cmsReadUInt32Number(io, &offsetA)) return NULL;
-
- // Allocates an empty LUT
- NewLUT = cmsPipelineAlloc(self ->ContextID, inputChan, outputChan);
- if (NewLUT == NULL) return NULL;
-
- if (offsetB != 0) {
- if (!cmsPipelineInsertStage(NewLUT, cmsAT_END, ReadSetOfCurves(self, io, BaseOffset + offsetB, inputChan)))
- goto Error;
- }
-
- if (offsetMat != 0) {
- if (!cmsPipelineInsertStage(NewLUT, cmsAT_END, ReadMatrix(self, io, BaseOffset + offsetMat)))
- goto Error;
- }
-
- if (offsetM != 0) {
- if (!cmsPipelineInsertStage(NewLUT, cmsAT_END, ReadSetOfCurves(self, io, BaseOffset + offsetM, inputChan)))
- goto Error;
- }
-
- if (offsetC != 0) {
- if (!cmsPipelineInsertStage(NewLUT, cmsAT_END, ReadCLUT(self, io, BaseOffset + offsetC, inputChan, outputChan)))
- goto Error;
- }
-
- if (offsetA!= 0) {
- if (!cmsPipelineInsertStage(NewLUT, cmsAT_END, ReadSetOfCurves(self, io, BaseOffset + offsetA, outputChan)))
- goto Error;
- }
-
- *nItems = 1;
- return NewLUT;
-Error:
- cmsPipelineFree(NewLUT);
- return NULL;
-
- cmsUNUSED_PARAMETER(SizeOfTag);
-}
-
-
-/*
-B
-B - Matrix - M
-B - CLUT - A
-B - Matrix - M - CLUT - A
-*/
-
-static
-cmsBool Type_LUTB2A_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
-{
- cmsPipeline* Lut = (cmsPipeline*) Ptr;
- cmsUInt32Number inputChan, outputChan;
- cmsStage *A = NULL, *B = NULL, *M = NULL;
- cmsStage *Matrix = NULL;
- cmsStage *CLUT = NULL;
- cmsUInt32Number offsetB = 0, offsetMat = 0, offsetM = 0, offsetC = 0, offsetA = 0;
- cmsUInt32Number BaseOffset, DirectoryPos, CurrentPos;
-
-
- BaseOffset = io ->Tell(io) - sizeof(_cmsTagBase);
-
- if (!cmsPipelineCheckAndRetreiveStages(Lut, 1, cmsSigCurveSetElemType, &B))
- if (!cmsPipelineCheckAndRetreiveStages(Lut, 3, cmsSigCurveSetElemType, cmsSigMatrixElemType, cmsSigCurveSetElemType, &B, &Matrix, &M))
- if (!cmsPipelineCheckAndRetreiveStages(Lut, 3, cmsSigCurveSetElemType, cmsSigCLutElemType, cmsSigCurveSetElemType, &B, &CLUT, &A))
- if (!cmsPipelineCheckAndRetreiveStages(Lut, 5, cmsSigCurveSetElemType, cmsSigMatrixElemType, cmsSigCurveSetElemType,
- cmsSigCLutElemType, cmsSigCurveSetElemType, &B, &Matrix, &M, &CLUT, &A)) {
- cmsSignalError(self->ContextID, cmsERROR_NOT_SUITABLE, "LUT is not suitable to be saved as LutBToA");
- return FALSE;
- }
-
- inputChan = cmsPipelineInputChannels(Lut);
- outputChan = cmsPipelineOutputChannels(Lut);
-
- if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) inputChan)) return FALSE;
- if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) outputChan)) return FALSE;
- if (!_cmsWriteUInt16Number(io, 0)) return FALSE;
-
- DirectoryPos = io ->Tell(io);
-
- if (!_cmsWriteUInt32Number(io, 0)) return FALSE;
- if (!_cmsWriteUInt32Number(io, 0)) return FALSE;
- if (!_cmsWriteUInt32Number(io, 0)) return FALSE;
- if (!_cmsWriteUInt32Number(io, 0)) return FALSE;
- if (!_cmsWriteUInt32Number(io, 0)) return FALSE;
-
- if (A != NULL) {
-
- offsetA = io ->Tell(io) - BaseOffset;
- if (!WriteSetOfCurves(self, io, cmsSigParametricCurveType, A)) return FALSE;
- }
-
- if (CLUT != NULL) {
- offsetC = io ->Tell(io) - BaseOffset;
- if (!WriteCLUT(self, io, (Lut ->SaveAs8Bits ? 1U : 2U), CLUT)) return FALSE;
-
- }
- if (M != NULL) {
-
- offsetM = io ->Tell(io) - BaseOffset;
- if (!WriteSetOfCurves(self, io, cmsSigParametricCurveType, M)) return FALSE;
- }
-
- if (Matrix != NULL) {
- offsetMat = io ->Tell(io) - BaseOffset;
- if (!WriteMatrix(self, io, Matrix)) return FALSE;
- }
-
- if (B != NULL) {
-
- offsetB = io ->Tell(io) - BaseOffset;
- if (!WriteSetOfCurves(self, io, cmsSigParametricCurveType, B)) return FALSE;
- }
-
- CurrentPos = io ->Tell(io);
-
- if (!io ->Seek(io, DirectoryPos)) return FALSE;
-
- if (!_cmsWriteUInt32Number(io, offsetB)) return FALSE;
- if (!_cmsWriteUInt32Number(io, offsetMat)) return FALSE;
- if (!_cmsWriteUInt32Number(io, offsetM)) return FALSE;
- if (!_cmsWriteUInt32Number(io, offsetC)) return FALSE;
- if (!_cmsWriteUInt32Number(io, offsetA)) return FALSE;
-
- if (!io ->Seek(io, CurrentPos)) return FALSE;
-
- return TRUE;
-
- cmsUNUSED_PARAMETER(nItems);
-}
-
-
-
-static
-void* Type_LUTB2A_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
-{
- return (void*) cmsPipelineDup((cmsPipeline*) Ptr);
-
- cmsUNUSED_PARAMETER(n);
- cmsUNUSED_PARAMETER(self);
-}
-
-static
-void Type_LUTB2A_Free(struct _cms_typehandler_struct* self, void* Ptr)
-{
- cmsPipelineFree((cmsPipeline*) Ptr);
- return;
-
- cmsUNUSED_PARAMETER(self);
-}
-
-
-
-// ********************************************************************************
-// Type cmsSigColorantTableType
-// ********************************************************************************
-/*
-The purpose of this tag is to identify the colorants used in the profile by a
-unique name and set of XYZ or L*a*b* values to give the colorant an unambiguous
-value. The first colorant listed is the colorant of the first device channel of
-a lut tag. The second colorant listed is the colorant of the second device channel
-of a lut tag, and so on.
-*/
-
-static
-void *Type_ColorantTable_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
-{
- cmsUInt32Number i, Count;
- cmsNAMEDCOLORLIST* List;
- char Name[34];
- cmsUInt16Number PCS[3];
-
-
- if (!_cmsReadUInt32Number(io, &Count)) return NULL;
-
- if (Count > cmsMAXCHANNELS) {
- cmsSignalError(self->ContextID, cmsERROR_RANGE, "Too many colorants '%d'", Count);
- return NULL;
- }
-
- List = cmsAllocNamedColorList(self ->ContextID, Count, 0, "", "");
- if (List == NULL)
- return NULL;
-
- for (i=0; i < Count; i++) {
-
- if (io ->Read(io, Name, 32, 1) != 1) goto Error;
- Name[32] = 0;
-
- if (!_cmsReadUInt16Array(io, 3, PCS)) goto Error;
-
- if (!cmsAppendNamedColor(List, Name, PCS, NULL)) goto Error;
-
- }
-
- *nItems = 1;
- return List;
-
-Error:
- *nItems = 0;
- cmsFreeNamedColorList(List);
- return NULL;
-
- cmsUNUSED_PARAMETER(SizeOfTag);
-}
-
-
-
-// Saves a colorant table. It is using the named color structure for simplicity sake
-static
-cmsBool Type_ColorantTable_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
-{
- cmsNAMEDCOLORLIST* NamedColorList = (cmsNAMEDCOLORLIST*) Ptr;
- cmsUInt32Number i, nColors;
-
- nColors = cmsNamedColorCount(NamedColorList);
-
- if (!_cmsWriteUInt32Number(io, nColors)) return FALSE;
-
- for (i=0; i < nColors; i++) {
-
- char root[cmsMAX_PATH];
- cmsUInt16Number PCS[3];
-
- memset(root, 0, sizeof(root));
-
- if (!cmsNamedColorInfo(NamedColorList, i, root, NULL, NULL, PCS, NULL)) return 0;
- root[32] = 0;
-
- if (!io ->Write(io, 32, root)) return FALSE;
- if (!_cmsWriteUInt16Array(io, 3, PCS)) return FALSE;
- }
-
- return TRUE;
-
- cmsUNUSED_PARAMETER(nItems);
- cmsUNUSED_PARAMETER(self);
-}
-
-
-static
-void* Type_ColorantTable_Dup(struct _cms_typehandler_struct* self, const void* Ptr, cmsUInt32Number n)
-{
- cmsNAMEDCOLORLIST* nc = (cmsNAMEDCOLORLIST*) Ptr;
- return (void*) cmsDupNamedColorList(nc);
-
- cmsUNUSED_PARAMETER(n);
- cmsUNUSED_PARAMETER(self);
-}
-
-
-static
-void Type_ColorantTable_Free(struct _cms_typehandler_struct* self, void* Ptr)
-{
- cmsFreeNamedColorList((cmsNAMEDCOLORLIST*) Ptr);
- return;
-
- cmsUNUSED_PARAMETER(self);
-}
-
-
-// ********************************************************************************
-// Type cmsSigNamedColor2Type
-// ********************************************************************************
-//
-//The namedColor2Type is a count value and array of structures that provide color
-//coordinates for 7-bit ASCII color names. For each named color, a PCS and optional
-//device representation of the color are given. Both representations are 16-bit values.
-//The device representation corresponds to the header's 'color space of data' field.
-//This representation should be consistent with the 'number of device components'
-//field in the namedColor2Type. If this field is 0, device coordinates are not provided.
-//The PCS representation corresponds to the header's PCS field. The PCS representation
-//is always provided. Color names are fixed-length, 32-byte fields including null
-//termination. In order to maintain maximum portability, it is strongly recommended
-//that special characters of the 7-bit ASCII set not be used.
-
-static
-void *Type_NamedColor_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
-{
- cmsUInt32Number vendorFlag; // Bottom 16 bits for ICC use
- cmsUInt32Number count; // Count of named colors
- cmsUInt32Number nDeviceCoords; // Num of device coordinates
- char prefix[32]; // Prefix for each color name
- char suffix[32]; // Suffix for each color name
- cmsNAMEDCOLORLIST* v;
- cmsUInt32Number i;
-
-
- *nItems = 0;
- if (!_cmsReadUInt32Number(io, &vendorFlag)) return NULL;
- if (!_cmsReadUInt32Number(io, &count)) return NULL;
- if (!_cmsReadUInt32Number(io, &nDeviceCoords)) return NULL;
-
- if (io -> Read(io, prefix, 32, 1) != 1) return NULL;
- if (io -> Read(io, suffix, 32, 1) != 1) return NULL;
-
- prefix[31] = suffix[31] = 0;
-
- v = cmsAllocNamedColorList(self ->ContextID, count, nDeviceCoords, prefix, suffix);
- if (v == NULL) {
- cmsSignalError(self->ContextID, cmsERROR_RANGE, "Too many named colors '%d'", count);
- return NULL;
- }
-
- if (nDeviceCoords > cmsMAXCHANNELS) {
- cmsSignalError(self->ContextID, cmsERROR_RANGE, "Too many device coordinates '%d'", nDeviceCoords);
- goto Error;
- }
- for (i=0; i < count; i++) {
-
- cmsUInt16Number PCS[3];
- cmsUInt16Number Colorant[cmsMAXCHANNELS];
- char Root[33];
-
- memset(Colorant, 0, sizeof(Colorant));
- if (io -> Read(io, Root, 32, 1) != 1) goto Error;
- Root[32] = 0; // To prevent exploits
-
- if (!_cmsReadUInt16Array(io, 3, PCS)) goto Error;
- if (!_cmsReadUInt16Array(io, nDeviceCoords, Colorant)) goto Error;
-
- if (!cmsAppendNamedColor(v, Root, PCS, Colorant)) goto Error;
- }
-
- *nItems = 1;
- return (void*) v ;
-
-Error:
- cmsFreeNamedColorList(v);
- return NULL;
-
- cmsUNUSED_PARAMETER(SizeOfTag);
-}
-
-
-// Saves a named color list into a named color profile
-static
-cmsBool Type_NamedColor_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
-{
- cmsNAMEDCOLORLIST* NamedColorList = (cmsNAMEDCOLORLIST*) Ptr;
- char prefix[33]; // Prefix for each color name
- char suffix[33]; // Suffix for each color name
- cmsUInt32Number i, nColors;
-
- nColors = cmsNamedColorCount(NamedColorList);
-
- if (!_cmsWriteUInt32Number(io, 0)) return FALSE;
- if (!_cmsWriteUInt32Number(io, nColors)) return FALSE;
- if (!_cmsWriteUInt32Number(io, NamedColorList ->ColorantCount)) return FALSE;
-
- memcpy(prefix, (const char*) NamedColorList->Prefix, sizeof(prefix));
- memcpy(suffix, (const char*) NamedColorList->Suffix, sizeof(suffix));
-
- suffix[32] = prefix[32] = 0;
-
- if (!io ->Write(io, 32, prefix)) return FALSE;
- if (!io ->Write(io, 32, suffix)) return FALSE;
-
- for (i=0; i < nColors; i++) {
-
- cmsUInt16Number PCS[3];
- cmsUInt16Number Colorant[cmsMAXCHANNELS];
- char Root[cmsMAX_PATH];
-
- memset(Root, 0, sizeof(Root));
- memset(PCS, 0, sizeof(PCS));
- memset(Colorant, 0, sizeof(Colorant));
-
- if (!cmsNamedColorInfo(NamedColorList, i, Root, NULL, NULL, PCS, Colorant)) return 0;
- Root[32] = 0;
- if (!io ->Write(io, 32 , Root)) return FALSE;
- if (!_cmsWriteUInt16Array(io, 3, PCS)) return FALSE;
- if (!_cmsWriteUInt16Array(io, NamedColorList ->ColorantCount, Colorant)) return FALSE;
- }
-
- return TRUE;
-
- cmsUNUSED_PARAMETER(nItems);
- cmsUNUSED_PARAMETER(self);
-}
-
-static
-void* Type_NamedColor_Dup(struct _cms_typehandler_struct* self, const void* Ptr, cmsUInt32Number n)
-{
- cmsNAMEDCOLORLIST* nc = (cmsNAMEDCOLORLIST*) Ptr;
-
- return (void*) cmsDupNamedColorList(nc);
-
- cmsUNUSED_PARAMETER(n);
- cmsUNUSED_PARAMETER(self);
-}
-
-
-static
-void Type_NamedColor_Free(struct _cms_typehandler_struct* self, void* Ptr)
-{
- cmsFreeNamedColorList((cmsNAMEDCOLORLIST*) Ptr);
- return;
-
- cmsUNUSED_PARAMETER(self);
-}
-
-
-// ********************************************************************************
-// Type cmsSigProfileSequenceDescType
-// ********************************************************************************
-
-// This type is an array of structures, each of which contains information from the
-// header fields and tags from the original profiles which were combined to create
-// the final profile. The order of the structures is the order in which the profiles
-// were combined and includes a structure for the final profile. This provides a
-// description of the profile sequence from source to destination,
-// typically used with the DeviceLink profile.
-
-static
-cmsBool ReadEmbeddedText(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsMLU** mlu, cmsUInt32Number SizeOfTag)
-{
- cmsTagTypeSignature BaseType;
- cmsUInt32Number nItems;
-
- BaseType = _cmsReadTypeBase(io);
-
- switch (BaseType) {
-
- case cmsSigTextType:
- if (*mlu) cmsMLUfree(*mlu);
- *mlu = (cmsMLU*)Type_Text_Read(self, io, &nItems, SizeOfTag);
- return (*mlu != NULL);
-
- case cmsSigTextDescriptionType:
- if (*mlu) cmsMLUfree(*mlu);
- *mlu = (cmsMLU*) Type_Text_Description_Read(self, io, &nItems, SizeOfTag);
- return (*mlu != NULL);
-
- /*
- TBD: Size is needed for MLU, and we have no idea on which is the available size
- */
-
- case cmsSigMultiLocalizedUnicodeType:
- if (*mlu) cmsMLUfree(*mlu);
- *mlu = (cmsMLU*) Type_MLU_Read(self, io, &nItems, SizeOfTag);
- return (*mlu != NULL);
-
- default: return FALSE;
- }
-}
-
-
-static
-void *Type_ProfileSequenceDesc_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
-{
- cmsSEQ* OutSeq;
- cmsUInt32Number i, Count;
-
- *nItems = 0;
-
- if (!_cmsReadUInt32Number(io, &Count)) return NULL;
-
- if (SizeOfTag < sizeof(cmsUInt32Number)) return NULL;
- SizeOfTag -= sizeof(cmsUInt32Number);
-
-
- OutSeq = cmsAllocProfileSequenceDescription(self ->ContextID, Count);
- if (OutSeq == NULL) return NULL;
-
- OutSeq ->n = Count;
-
- // Get structures as well
-
- for (i=0; i < Count; i++) {
-
- cmsPSEQDESC* sec = &OutSeq -> seq[i];
-
- if (!_cmsReadUInt32Number(io, &sec ->deviceMfg)) goto Error;
- if (SizeOfTag < sizeof(cmsUInt32Number)) goto Error;
- SizeOfTag -= sizeof(cmsUInt32Number);
-
- if (!_cmsReadUInt32Number(io, &sec ->deviceModel)) goto Error;
- if (SizeOfTag < sizeof(cmsUInt32Number)) goto Error;
- SizeOfTag -= sizeof(cmsUInt32Number);
-
- if (!_cmsReadUInt64Number(io, &sec ->attributes)) goto Error;
- if (SizeOfTag < sizeof(cmsUInt64Number)) goto Error;
- SizeOfTag -= sizeof(cmsUInt64Number);
-
- if (!_cmsReadUInt32Number(io, (cmsUInt32Number *)&sec ->technology)) goto Error;
- if (SizeOfTag < sizeof(cmsUInt32Number)) goto Error;
- SizeOfTag -= sizeof(cmsUInt32Number);
-
- if (!ReadEmbeddedText(self, io, &sec ->Manufacturer, SizeOfTag)) goto Error;
- if (!ReadEmbeddedText(self, io, &sec ->Model, SizeOfTag)) goto Error;
- }
-
- *nItems = 1;
- return OutSeq;
-
-Error:
- cmsFreeProfileSequenceDescription(OutSeq);
- return NULL;
-}
-
-
-// Aux--Embed a text description type. It can be of type text description or multilocalized unicode
-// and it depends of the version number passed on cmsTagDescriptor structure instead of stack
-static
-cmsBool SaveDescription(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsMLU* Text)
-{
- if (self ->ICCVersion < 0x4000000) {
-
- if (!_cmsWriteTypeBase(io, cmsSigTextDescriptionType)) return FALSE;
- return Type_Text_Description_Write(self, io, Text, 1);
- }
- else {
- if (!_cmsWriteTypeBase(io, cmsSigMultiLocalizedUnicodeType)) return FALSE;
- return Type_MLU_Write(self, io, Text, 1);
- }
-}
-
-
-static
-cmsBool Type_ProfileSequenceDesc_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
-{
- cmsSEQ* Seq = (cmsSEQ*) Ptr;
- cmsUInt32Number i;
-
- if (!_cmsWriteUInt32Number(io, Seq->n)) return FALSE;
-
- for (i=0; i < Seq ->n; i++) {
-
- cmsPSEQDESC* sec = &Seq -> seq[i];
-
- if (!_cmsWriteUInt32Number(io, sec ->deviceMfg)) return FALSE;
- if (!_cmsWriteUInt32Number(io, sec ->deviceModel)) return FALSE;
- if (!_cmsWriteUInt64Number(io, &sec ->attributes)) return FALSE;
- if (!_cmsWriteUInt32Number(io, sec ->technology)) return FALSE;
-
- if (!SaveDescription(self, io, sec ->Manufacturer)) return FALSE;
- if (!SaveDescription(self, io, sec ->Model)) return FALSE;
- }
-
- return TRUE;
-
- cmsUNUSED_PARAMETER(nItems);
-}
-
-
-static
-void* Type_ProfileSequenceDesc_Dup(struct _cms_typehandler_struct* self, const void* Ptr, cmsUInt32Number n)
-{
- return (void*) cmsDupProfileSequenceDescription((cmsSEQ*) Ptr);
-
- cmsUNUSED_PARAMETER(n);
- cmsUNUSED_PARAMETER(self);
-}
-
-static
-void Type_ProfileSequenceDesc_Free(struct _cms_typehandler_struct* self, void* Ptr)
-{
- cmsFreeProfileSequenceDescription((cmsSEQ*) Ptr);
- return;
-
- cmsUNUSED_PARAMETER(self);
-}
-
-
-// ********************************************************************************
-// Type cmsSigProfileSequenceIdType
-// ********************************************************************************
-/*
-In certain workflows using ICC Device Link Profiles, it is necessary to identify the
-original profiles that were combined to create the Device Link Profile.
-This type is an array of structures, each of which contains information for
-identification of a profile used in a sequence
-*/
-
-
-static
-cmsBool ReadSeqID(struct _cms_typehandler_struct* self,
- cmsIOHANDLER* io,
- void* Cargo,
- cmsUInt32Number n,
- cmsUInt32Number SizeOfTag)
-{
- cmsSEQ* OutSeq = (cmsSEQ*) Cargo;
- cmsPSEQDESC* seq = &OutSeq ->seq[n];
-
- if (io -> Read(io, seq ->ProfileID.ID8, 16, 1) != 1) return FALSE;
- if (!ReadEmbeddedText(self, io, &seq ->Description, SizeOfTag)) return FALSE;
-
- return TRUE;
-}
-
-
-
-static
-void *Type_ProfileSequenceId_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
-{
- cmsSEQ* OutSeq;
- cmsUInt32Number Count;
- cmsUInt32Number BaseOffset;
-
- *nItems = 0;
-
- // Get actual position as a basis for element offsets
- BaseOffset = io ->Tell(io) - sizeof(_cmsTagBase);
-
- // Get table count
- if (!_cmsReadUInt32Number(io, &Count)) return NULL;
-
- // Allocate an empty structure
- OutSeq = cmsAllocProfileSequenceDescription(self ->ContextID, Count);
- if (OutSeq == NULL) return NULL;
-
-
- // Read the position table
- if (!ReadPositionTable(self, io, Count, BaseOffset, OutSeq, ReadSeqID)) {
-
- cmsFreeProfileSequenceDescription(OutSeq);
- return NULL;
- }
-
- // Success
- *nItems = 1;
- return OutSeq;
-
- cmsUNUSED_PARAMETER(SizeOfTag);
-}
-
-
-static
-cmsBool WriteSeqID(struct _cms_typehandler_struct* self,
- cmsIOHANDLER* io,
- void* Cargo,
- cmsUInt32Number n,
- cmsUInt32Number SizeOfTag)
-{
- cmsSEQ* Seq = (cmsSEQ*) Cargo;
-
- if (!io ->Write(io, 16, Seq ->seq[n].ProfileID.ID8)) return FALSE;
-
- // Store here the MLU
- if (!SaveDescription(self, io, Seq ->seq[n].Description)) return FALSE;
-
- return TRUE;
-
- cmsUNUSED_PARAMETER(SizeOfTag);
-}
-
-static
-cmsBool Type_ProfileSequenceId_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
-{
- cmsSEQ* Seq = (cmsSEQ*) Ptr;
- cmsUInt32Number BaseOffset;
-
- // Keep the base offset
- BaseOffset = io ->Tell(io) - sizeof(_cmsTagBase);
-
- // This is the table count
- if (!_cmsWriteUInt32Number(io, Seq ->n)) return FALSE;
-
- // This is the position table and content
- if (!WritePositionTable(self, io, 0, Seq ->n, BaseOffset, Seq, WriteSeqID)) return FALSE;
-
- return TRUE;
-
- cmsUNUSED_PARAMETER(nItems);
-}
-
-static
-void* Type_ProfileSequenceId_Dup(struct _cms_typehandler_struct* self, const void* Ptr, cmsUInt32Number n)
-{
- return (void*) cmsDupProfileSequenceDescription((cmsSEQ*) Ptr);
-
- cmsUNUSED_PARAMETER(n);
- cmsUNUSED_PARAMETER(self);
-}
-
-static
-void Type_ProfileSequenceId_Free(struct _cms_typehandler_struct* self, void* Ptr)
-{
- cmsFreeProfileSequenceDescription((cmsSEQ*) Ptr);
- return;
-
- cmsUNUSED_PARAMETER(self);
-}
-
-
-// ********************************************************************************
-// Type cmsSigUcrBgType
-// ********************************************************************************
-/*
-This type contains curves representing the under color removal and black
-generation and a text string which is a general description of the method used
-for the ucr/bg.
-*/
-
-static
-void *Type_UcrBg_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
-{
- cmsUcrBg* n = (cmsUcrBg*) _cmsMallocZero(self ->ContextID, sizeof(cmsUcrBg));
- cmsUInt32Number CountUcr, CountBg;
- cmsInt32Number SignedSizeOfTag = (cmsInt32Number)SizeOfTag;
- char* ASCIIString;
-
- *nItems = 0;
- if (n == NULL) return NULL;
-
- // First curve is Under color removal
-
- if (SignedSizeOfTag < (cmsInt32Number) sizeof(cmsUInt32Number)) return NULL;
- if (!_cmsReadUInt32Number(io, &CountUcr)) return NULL;
- SignedSizeOfTag -= sizeof(cmsUInt32Number);
-
- n ->Ucr = cmsBuildTabulatedToneCurve16(self ->ContextID, CountUcr, NULL);
- if (n ->Ucr == NULL) goto error;
-
- if (SignedSizeOfTag < (cmsInt32Number)(CountUcr * sizeof(cmsUInt16Number))) goto error;
- if (!_cmsReadUInt16Array(io, CountUcr, n ->Ucr->Table16)) goto error;
-
- SignedSizeOfTag -= CountUcr * sizeof(cmsUInt16Number);
-
- // Second curve is Black generation
-
- if (SignedSizeOfTag < (cmsInt32Number)sizeof(cmsUInt32Number)) goto error;
- if (!_cmsReadUInt32Number(io, &CountBg)) goto error;
- SignedSizeOfTag -= sizeof(cmsUInt32Number);
-
- n ->Bg = cmsBuildTabulatedToneCurve16(self ->ContextID, CountBg, NULL);
- if (n ->Bg == NULL) goto error;
-
- if (SignedSizeOfTag < (cmsInt32Number) (CountBg * sizeof(cmsUInt16Number))) goto error;
- if (!_cmsReadUInt16Array(io, CountBg, n ->Bg->Table16)) goto error;
- SignedSizeOfTag -= CountBg * sizeof(cmsUInt16Number);
-
- if (SignedSizeOfTag < 0 || SignedSizeOfTag > 32000) goto error;
-
- // Now comes the text. The length is specified by the tag size
- n ->Desc = cmsMLUalloc(self ->ContextID, 1);
- if (n ->Desc == NULL) goto error;
-
- ASCIIString = (char*) _cmsMalloc(self ->ContextID, SignedSizeOfTag + 1);
- if (io->Read(io, ASCIIString, sizeof(char), SignedSizeOfTag) != (cmsUInt32Number)SignedSizeOfTag)
- {
- _cmsFree(self->ContextID, ASCIIString);
- goto error;
- }
-
- ASCIIString[SignedSizeOfTag] = 0;
- cmsMLUsetASCII(n ->Desc, cmsNoLanguage, cmsNoCountry, ASCIIString);
- _cmsFree(self ->ContextID, ASCIIString);
-
- *nItems = 1;
- return (void*) n;
-
-error:
-
- if (n->Ucr) cmsFreeToneCurve(n->Ucr);
- if (n->Bg) cmsFreeToneCurve(n->Bg);
- if (n->Desc) cmsMLUfree(n->Desc);
- _cmsFree(self->ContextID, n);
- *nItems = 0;
- return NULL;
-
-}
-
-static
-cmsBool Type_UcrBg_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
-{
- cmsUcrBg* Value = (cmsUcrBg*) Ptr;
- cmsUInt32Number TextSize;
- char* Text;
-
- // First curve is Under color removal
- if (!_cmsWriteUInt32Number(io, Value ->Ucr ->nEntries)) return FALSE;
- if (!_cmsWriteUInt16Array(io, Value ->Ucr ->nEntries, Value ->Ucr ->Table16)) return FALSE;
-
- // Then black generation
- if (!_cmsWriteUInt32Number(io, Value ->Bg ->nEntries)) return FALSE;
- if (!_cmsWriteUInt16Array(io, Value ->Bg ->nEntries, Value ->Bg ->Table16)) return FALSE;
-
- // Now comes the text. The length is specified by the tag size
- TextSize = cmsMLUgetASCII(Value ->Desc, cmsNoLanguage, cmsNoCountry, NULL, 0);
- Text = (char*) _cmsMalloc(self ->ContextID, TextSize);
- if (cmsMLUgetASCII(Value ->Desc, cmsNoLanguage, cmsNoCountry, Text, TextSize) != TextSize) return FALSE;
-
- if (!io ->Write(io, TextSize, Text)) return FALSE;
- _cmsFree(self ->ContextID, Text);
-
- return TRUE;
-
- cmsUNUSED_PARAMETER(nItems);
-}
-
-static
-void* Type_UcrBg_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
-{
- cmsUcrBg* Src = (cmsUcrBg*) Ptr;
- cmsUcrBg* NewUcrBg = (cmsUcrBg*) _cmsMallocZero(self ->ContextID, sizeof(cmsUcrBg));
-
- if (NewUcrBg == NULL) return NULL;
-
- NewUcrBg ->Bg = cmsDupToneCurve(Src ->Bg);
- NewUcrBg ->Ucr = cmsDupToneCurve(Src ->Ucr);
- NewUcrBg ->Desc = cmsMLUdup(Src ->Desc);
-
- return (void*) NewUcrBg;
-
- cmsUNUSED_PARAMETER(n);
-}
-
-static
-void Type_UcrBg_Free(struct _cms_typehandler_struct* self, void *Ptr)
-{
- cmsUcrBg* Src = (cmsUcrBg*) Ptr;
-
- if (Src ->Ucr) cmsFreeToneCurve(Src ->Ucr);
- if (Src ->Bg) cmsFreeToneCurve(Src ->Bg);
- if (Src ->Desc) cmsMLUfree(Src ->Desc);
-
- _cmsFree(self ->ContextID, Ptr);
-}
-
-// ********************************************************************************
-// Type cmsSigCrdInfoType
-// ********************************************************************************
-
-/*
-This type contains the PostScript product name to which this profile corresponds
-and the names of the companion CRDs. Recall that a single profile can generate
-multiple CRDs. It is implemented as a MLU being the language code "PS" and then
-country varies for each element:
-
- nm: PostScript product name
- #0: Rendering intent 0 CRD name
- #1: Rendering intent 1 CRD name
- #2: Rendering intent 2 CRD name
- #3: Rendering intent 3 CRD name
-*/
-
-
-
-// Auxiliary, read an string specified as count + string
-static
-cmsBool ReadCountAndString(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsMLU* mlu, cmsUInt32Number* SizeOfTag, const char* Section)
-{
- cmsUInt32Number Count;
- char* Text;
-
- if (*SizeOfTag < sizeof(cmsUInt32Number)) return FALSE;
-
- if (!_cmsReadUInt32Number(io, &Count)) return FALSE;
-
- if (Count > UINT_MAX - sizeof(cmsUInt32Number)) return FALSE;
- if (*SizeOfTag < Count + sizeof(cmsUInt32Number)) return FALSE;
-
- Text = (char*) _cmsMalloc(self ->ContextID, Count+1);
- if (Text == NULL) return FALSE;
-
- if (io ->Read(io, Text, sizeof(cmsUInt8Number), Count) != Count) {
- _cmsFree(self ->ContextID, Text);
- return FALSE;
- }
-
- Text[Count] = 0;
-
- cmsMLUsetASCII(mlu, "PS", Section, Text);
- _cmsFree(self ->ContextID, Text);
-
- *SizeOfTag -= (Count + sizeof(cmsUInt32Number));
- return TRUE;
-}
-
-static
-cmsBool WriteCountAndString(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsMLU* mlu, const char* Section)
-{
- cmsUInt32Number TextSize;
- char* Text;
-
- TextSize = cmsMLUgetASCII(mlu, "PS", Section, NULL, 0);
- Text = (char*) _cmsMalloc(self ->ContextID, TextSize);
-
- if (!_cmsWriteUInt32Number(io, TextSize)) return FALSE;
-
- if (cmsMLUgetASCII(mlu, "PS", Section, Text, TextSize) == 0) return FALSE;
-
- if (!io ->Write(io, TextSize, Text)) return FALSE;
- _cmsFree(self ->ContextID, Text);
-
- return TRUE;
-}
-
-static
-void *Type_CrdInfo_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
-{
- cmsMLU* mlu = cmsMLUalloc(self ->ContextID, 5);
-
- *nItems = 0;
- if (!ReadCountAndString(self, io, mlu, &SizeOfTag, "nm")) goto Error;
- if (!ReadCountAndString(self, io, mlu, &SizeOfTag, "#0")) goto Error;
- if (!ReadCountAndString(self, io, mlu, &SizeOfTag, "#1")) goto Error;
- if (!ReadCountAndString(self, io, mlu, &SizeOfTag, "#2")) goto Error;
- if (!ReadCountAndString(self, io, mlu, &SizeOfTag, "#3")) goto Error;
-
- *nItems = 1;
- return (void*) mlu;
-
-Error:
- cmsMLUfree(mlu);
- return NULL;
-
-}
-
-static
-cmsBool Type_CrdInfo_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
-{
-
- cmsMLU* mlu = (cmsMLU*) Ptr;
-
- if (!WriteCountAndString(self, io, mlu, "nm")) goto Error;
- if (!WriteCountAndString(self, io, mlu, "#0")) goto Error;
- if (!WriteCountAndString(self, io, mlu, "#1")) goto Error;
- if (!WriteCountAndString(self, io, mlu, "#2")) goto Error;
- if (!WriteCountAndString(self, io, mlu, "#3")) goto Error;
-
- return TRUE;
-
-Error:
- return FALSE;
-
- cmsUNUSED_PARAMETER(nItems);
-}
-
-
-static
-void* Type_CrdInfo_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
-{
- return (void*) cmsMLUdup((cmsMLU*) Ptr);
-
- cmsUNUSED_PARAMETER(n);
- cmsUNUSED_PARAMETER(self);
-}
-
-static
-void Type_CrdInfo_Free(struct _cms_typehandler_struct* self, void *Ptr)
-{
- cmsMLUfree((cmsMLU*) Ptr);
- return;
-
- cmsUNUSED_PARAMETER(self);
-}
-
-// ********************************************************************************
-// Type cmsSigScreeningType
-// ********************************************************************************
-//
-//The screeningType describes various screening parameters including screen
-//frequency, screening angle, and spot shape.
-
-static
-void *Type_Screening_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
-{
- cmsScreening* sc = NULL;
- cmsUInt32Number i;
-
- sc = (cmsScreening*) _cmsMallocZero(self ->ContextID, sizeof(cmsScreening));
- if (sc == NULL) return NULL;
-
- *nItems = 0;
-
- if (!_cmsReadUInt32Number(io, &sc ->Flag)) goto Error;
- if (!_cmsReadUInt32Number(io, &sc ->nChannels)) goto Error;
-
- if (sc ->nChannels > cmsMAXCHANNELS - 1)
- sc ->nChannels = cmsMAXCHANNELS - 1;
-
- for (i=0; i < sc ->nChannels; i++) {
-
- if (!_cmsRead15Fixed16Number(io, &sc ->Channels[i].Frequency)) goto Error;
- if (!_cmsRead15Fixed16Number(io, &sc ->Channels[i].ScreenAngle)) goto Error;
- if (!_cmsReadUInt32Number(io, &sc ->Channels[i].SpotShape)) goto Error;
- }
-
-
- *nItems = 1;
-
- return (void*) sc;
-
-Error:
- if (sc != NULL)
- _cmsFree(self ->ContextID, sc);
-
- return NULL;
-
- cmsUNUSED_PARAMETER(SizeOfTag);
-}
-
-
-static
-cmsBool Type_Screening_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
-{
- cmsScreening* sc = (cmsScreening* ) Ptr;
- cmsUInt32Number i;
-
- if (!_cmsWriteUInt32Number(io, sc ->Flag)) return FALSE;
- if (!_cmsWriteUInt32Number(io, sc ->nChannels)) return FALSE;
-
- for (i=0; i < sc ->nChannels; i++) {
-
- if (!_cmsWrite15Fixed16Number(io, sc ->Channels[i].Frequency)) return FALSE;
- if (!_cmsWrite15Fixed16Number(io, sc ->Channels[i].ScreenAngle)) return FALSE;
- if (!_cmsWriteUInt32Number(io, sc ->Channels[i].SpotShape)) return FALSE;
- }
-
- return TRUE;
-
- cmsUNUSED_PARAMETER(nItems);
- cmsUNUSED_PARAMETER(self);
-}
-
-
-static
-void* Type_Screening_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
-{
- return _cmsDupMem(self ->ContextID, Ptr, sizeof(cmsScreening));
-
- cmsUNUSED_PARAMETER(n);
-}
-
-
-static
-void Type_Screening_Free(struct _cms_typehandler_struct* self, void* Ptr)
-{
- _cmsFree(self ->ContextID, Ptr);
-}
-
-// ********************************************************************************
-// Type cmsSigViewingConditionsType
-// ********************************************************************************
-//
-//This type represents a set of viewing condition parameters including:
-//CIE 'absolute' illuminant white point tristimulus values and CIE 'absolute'
-//surround tristimulus values.
-
-static
-void *Type_ViewingConditions_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
-{
- cmsICCViewingConditions* vc = NULL;
-
- vc = (cmsICCViewingConditions*) _cmsMallocZero(self ->ContextID, sizeof(cmsICCViewingConditions));
- if (vc == NULL) return NULL;
-
- *nItems = 0;
-
- if (!_cmsReadXYZNumber(io, &vc ->IlluminantXYZ)) goto Error;
- if (!_cmsReadXYZNumber(io, &vc ->SurroundXYZ)) goto Error;
- if (!_cmsReadUInt32Number(io, &vc ->IlluminantType)) goto Error;
-
- *nItems = 1;
-
- return (void*) vc;
-
-Error:
- if (vc != NULL)
- _cmsFree(self ->ContextID, vc);
-
- return NULL;
-
- cmsUNUSED_PARAMETER(SizeOfTag);
-}
-
-
-static
-cmsBool Type_ViewingConditions_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
-{
- cmsICCViewingConditions* sc = (cmsICCViewingConditions* ) Ptr;
-
- if (!_cmsWriteXYZNumber(io, &sc ->IlluminantXYZ)) return FALSE;
- if (!_cmsWriteXYZNumber(io, &sc ->SurroundXYZ)) return FALSE;
- if (!_cmsWriteUInt32Number(io, sc ->IlluminantType)) return FALSE;
-
- return TRUE;
-
- cmsUNUSED_PARAMETER(nItems);
- cmsUNUSED_PARAMETER(self);
-}
-
-
-static
-void* Type_ViewingConditions_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
-{
- return _cmsDupMem(self->ContextID, Ptr, sizeof(cmsICCViewingConditions));
-
- cmsUNUSED_PARAMETER(n);
-}
-
-
-static
-void Type_ViewingConditions_Free(struct _cms_typehandler_struct* self, void* Ptr)
-{
- _cmsFree(self ->ContextID, Ptr);
-}
-
-
-// ********************************************************************************
-// Type cmsSigMultiProcessElementType
-// ********************************************************************************
-
-
-static
-void* GenericMPEdup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
-{
- return (void*) cmsStageDup((cmsStage*) Ptr);
-
- cmsUNUSED_PARAMETER(n);
- cmsUNUSED_PARAMETER(self);
-}
-
-static
-void GenericMPEfree(struct _cms_typehandler_struct* self, void *Ptr)
-{
- cmsStageFree((cmsStage*) Ptr);
- return;
-
- cmsUNUSED_PARAMETER(self);
-}
-
-// Each curve is stored in one or more curve segments, with break-points specified between curve segments.
-// The first curve segment always starts at -Infinity, and the last curve segment always ends at +Infinity. The
-// first and last curve segments shall be specified in terms of a formula, whereas the other segments shall be
-// specified either in terms of a formula, or by a sampled curve.
-
-
-// Read an embedded segmented curve
-static
-cmsToneCurve* ReadSegmentedCurve(struct _cms_typehandler_struct* self, cmsIOHANDLER* io)
-{
- cmsCurveSegSignature ElementSig;
- cmsUInt32Number i, j;
- cmsUInt16Number nSegments;
- cmsCurveSegment* Segments;
- cmsToneCurve* Curve;
- cmsFloat32Number PrevBreak = MINUS_INF; // - infinite
-
- // Take signature and channels for each element.
- if (!_cmsReadUInt32Number(io, (cmsUInt32Number*) &ElementSig)) return NULL;
-
- // That should be a segmented curve
- if (ElementSig != cmsSigSegmentedCurve) return NULL;
-
- if (!_cmsReadUInt32Number(io, NULL)) return NULL;
- if (!_cmsReadUInt16Number(io, &nSegments)) return NULL;
- if (!_cmsReadUInt16Number(io, NULL)) return NULL;
-
- if (nSegments < 1) return NULL;
- Segments = (cmsCurveSegment*) _cmsCalloc(self ->ContextID, nSegments, sizeof(cmsCurveSegment));
- if (Segments == NULL) return NULL;
-
- // Read breakpoints
- for (i=0; i < (cmsUInt32Number) nSegments - 1; i++) {
-
- Segments[i].x0 = PrevBreak;
- if (!_cmsReadFloat32Number(io, &Segments[i].x1)) goto Error;
- PrevBreak = Segments[i].x1;
- }
-
- Segments[nSegments-1].x0 = PrevBreak;
- Segments[nSegments-1].x1 = PLUS_INF; // A big cmsFloat32Number number
-
- // Read segments
- for (i=0; i < nSegments; i++) {
-
- if (!_cmsReadUInt32Number(io, (cmsUInt32Number*) &ElementSig)) goto Error;
- if (!_cmsReadUInt32Number(io, NULL)) goto Error;
-
- switch (ElementSig) {
-
- case cmsSigFormulaCurveSeg: {
-
- cmsUInt16Number Type;
- cmsUInt32Number ParamsByType[] = { 4, 5, 5 };
-
- if (!_cmsReadUInt16Number(io, &Type)) goto Error;
- if (!_cmsReadUInt16Number(io, NULL)) goto Error;
-
- Segments[i].Type = Type + 6;
- if (Type > 2) goto Error;
-
- for (j = 0; j < ParamsByType[Type]; j++) {
-
- cmsFloat32Number f;
- if (!_cmsReadFloat32Number(io, &f)) goto Error;
- Segments[i].Params[j] = f;
- }
- }
- break;
-
-
- case cmsSigSampledCurveSeg: {
- cmsUInt32Number Count;
-
- if (!_cmsReadUInt32Number(io, &Count)) goto Error;
-
- // The first point is implicit in the last stage, we allocate an extra note to be populated latter on
- Count++;
- Segments[i].nGridPoints = Count;
- Segments[i].SampledPoints = (cmsFloat32Number*)_cmsCalloc(self->ContextID, Count, sizeof(cmsFloat32Number));
- if (Segments[i].SampledPoints == NULL) goto Error;
-
- Segments[i].SampledPoints[0] = 0;
- for (j = 1; j < Count; j++) {
- if (!_cmsReadFloat32Number(io, &Segments[i].SampledPoints[j])) goto Error;
- }
- }
- break;
-
- default:
- {
- char String[5];
-
- _cmsTagSignature2String(String, (cmsTagSignature) ElementSig);
- cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unknown curve element type '%s' found.", String);
- }
- goto Error;
-
- }
- }
-
- Curve = cmsBuildSegmentedToneCurve(self ->ContextID, nSegments, Segments);
-
- for (i=0; i < nSegments; i++) {
- if (Segments[i].SampledPoints) _cmsFree(self ->ContextID, Segments[i].SampledPoints);
- }
- _cmsFree(self ->ContextID, Segments);
-
- // Explore for missing implicit points
- for (i = 0; i < nSegments; i++) {
-
- // If sampled curve, fix it
- if (Curve->Segments[i].Type == 0) {
-
- Curve->Segments[i].SampledPoints[0] = cmsEvalToneCurveFloat(Curve, Curve->Segments[i].x0);
- }
- }
-
- return Curve;
-
-Error:
- if (Segments) {
- for (i=0; i < nSegments; i++) {
- if (Segments[i].SampledPoints) _cmsFree(self ->ContextID, Segments[i].SampledPoints);
- }
- _cmsFree(self ->ContextID, Segments);
- }
- return NULL;
-}
-
-
-static
-cmsBool ReadMPECurve(struct _cms_typehandler_struct* self,
- cmsIOHANDLER* io,
- void* Cargo,
- cmsUInt32Number n,
- cmsUInt32Number SizeOfTag)
-{
- cmsToneCurve** GammaTables = ( cmsToneCurve**) Cargo;
-
- GammaTables[n] = ReadSegmentedCurve(self, io);
- return (GammaTables[n] != NULL);
-
- cmsUNUSED_PARAMETER(SizeOfTag);
-}
-
-static
-void *Type_MPEcurve_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
-{
- cmsStage* mpe = NULL;
- cmsUInt16Number InputChans, OutputChans;
- cmsUInt32Number i, BaseOffset;
- cmsToneCurve** GammaTables;
-
- *nItems = 0;
-
- // Get actual position as a basis for element offsets
- BaseOffset = io ->Tell(io) - sizeof(_cmsTagBase);
-
- if (!_cmsReadUInt16Number(io, &InputChans)) return NULL;
- if (!_cmsReadUInt16Number(io, &OutputChans)) return NULL;
-
- if (InputChans != OutputChans) return NULL;
-
- GammaTables = (cmsToneCurve**) _cmsCalloc(self ->ContextID, InputChans, sizeof(cmsToneCurve*));
- if (GammaTables == NULL) return NULL;
-
- if (ReadPositionTable(self, io, InputChans, BaseOffset, GammaTables, ReadMPECurve)) {
-
- mpe = cmsStageAllocToneCurves(self ->ContextID, InputChans, GammaTables);
- }
- else {
- mpe = NULL;
- }
-
- for (i=0; i < InputChans; i++) {
- if (GammaTables[i]) cmsFreeToneCurve(GammaTables[i]);
- }
-
- _cmsFree(self ->ContextID, GammaTables);
- *nItems = (mpe != NULL) ? 1U : 0;
- return mpe;
-
- cmsUNUSED_PARAMETER(SizeOfTag);
-}
-
-
-// Write a single segmented curve. NO CHECK IS PERFORMED ON VALIDITY
-static
-cmsBool WriteSegmentedCurve(cmsIOHANDLER* io, cmsToneCurve* g)
-{
- cmsUInt32Number i, j;
- cmsCurveSegment* Segments = g ->Segments;
- cmsUInt32Number nSegments = g ->nSegments;
-
- if (!_cmsWriteUInt32Number(io, cmsSigSegmentedCurve)) goto Error;
- if (!_cmsWriteUInt32Number(io, 0)) goto Error;
- if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) nSegments)) goto Error;
- if (!_cmsWriteUInt16Number(io, 0)) goto Error;
-
- // Write the break-points
- for (i=0; i < nSegments - 1; i++) {
- if (!_cmsWriteFloat32Number(io, Segments[i].x1)) goto Error;
- }
-
- // Write the segments
- for (i=0; i < g ->nSegments; i++) {
-
- cmsCurveSegment* ActualSeg = Segments + i;
-
- if (ActualSeg -> Type == 0) {
-
- // This is a sampled curve. First point is implicit in the ICC format, but not in our representation
- if (!_cmsWriteUInt32Number(io, (cmsUInt32Number) cmsSigSampledCurveSeg)) goto Error;
- if (!_cmsWriteUInt32Number(io, 0)) goto Error;
- if (!_cmsWriteUInt32Number(io, ActualSeg -> nGridPoints - 1)) goto Error;
-
- for (j=1; j < g ->Segments[i].nGridPoints; j++) {
- if (!_cmsWriteFloat32Number(io, ActualSeg -> SampledPoints[j])) goto Error;
- }
-
- }
- else {
- int Type;
- cmsUInt32Number ParamsByType[] = { 4, 5, 5 };
-
- // This is a formula-based
- if (!_cmsWriteUInt32Number(io, (cmsUInt32Number) cmsSigFormulaCurveSeg)) goto Error;
- if (!_cmsWriteUInt32Number(io, 0)) goto Error;
-
- // We only allow 1, 2 and 3 as types
- Type = ActualSeg ->Type - 6;
- if (Type > 2 || Type < 0) goto Error;
-
- if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) Type)) goto Error;
- if (!_cmsWriteUInt16Number(io, 0)) goto Error;
-
- for (j=0; j < ParamsByType[Type]; j++) {
- if (!_cmsWriteFloat32Number(io, (cmsFloat32Number) ActualSeg ->Params[j])) goto Error;
- }
- }
-
- // It seems there is no need to align. Code is here, and for safety commented out
- // if (!_cmsWriteAlignment(io)) goto Error;
- }
-
- return TRUE;
-
-Error:
- return FALSE;
-}
-
-
-static
-cmsBool WriteMPECurve(struct _cms_typehandler_struct* self,
- cmsIOHANDLER* io,
- void* Cargo,
- cmsUInt32Number n,
- cmsUInt32Number SizeOfTag)
-{
- _cmsStageToneCurvesData* Curves = (_cmsStageToneCurvesData*) Cargo;
-
- return WriteSegmentedCurve(io, Curves ->TheCurves[n]);
-
- cmsUNUSED_PARAMETER(SizeOfTag);
- cmsUNUSED_PARAMETER(self);
-}
-
-// Write a curve, checking first for validity
-static
-cmsBool Type_MPEcurve_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
-{
- cmsUInt32Number BaseOffset;
- cmsStage* mpe = (cmsStage*) Ptr;
- _cmsStageToneCurvesData* Curves = (_cmsStageToneCurvesData*) mpe ->Data;
-
- BaseOffset = io ->Tell(io) - sizeof(_cmsTagBase);
-
- // Write the header. Since those are curves, input and output channels are same
- if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) mpe ->InputChannels)) return FALSE;
- if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) mpe ->InputChannels)) return FALSE;
-
- if (!WritePositionTable(self, io, 0,
- mpe ->InputChannels, BaseOffset, Curves, WriteMPECurve)) return FALSE;
-
-
- return TRUE;
-
- cmsUNUSED_PARAMETER(nItems);
-}
-
-
-
-// The matrix is organized as an array of PxQ+Q elements, where P is the number of input channels to the
-// matrix, and Q is the number of output channels. The matrix elements are each float32Numbers. The array
-// is organized as follows:
-// array = [e11, e12, ..., e1P, e21, e22, ..., e2P, ..., eQ1, eQ2, ..., eQP, e1, e2, ..., eQ]
-
-static
-void *Type_MPEmatrix_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
-{
- cmsStage* mpe;
- cmsUInt16Number InputChans, OutputChans;
- cmsUInt32Number nElems, i;
- cmsFloat64Number* Matrix;
- cmsFloat64Number* Offsets;
-
- if (!_cmsReadUInt16Number(io, &InputChans)) return NULL;
- if (!_cmsReadUInt16Number(io, &OutputChans)) return NULL;
-
-
- // Input and output chans may be ANY (up to 0xffff),
- // but we choose to limit to 16 channels for now
- if (InputChans >= cmsMAXCHANNELS) return NULL;
- if (OutputChans >= cmsMAXCHANNELS) return NULL;
-
- nElems = (cmsUInt32Number) InputChans * OutputChans;
-
- Matrix = (cmsFloat64Number*) _cmsCalloc(self ->ContextID, nElems, sizeof(cmsFloat64Number));
- if (Matrix == NULL) return NULL;
-
- Offsets = (cmsFloat64Number*) _cmsCalloc(self ->ContextID, OutputChans, sizeof(cmsFloat64Number));
- if (Offsets == NULL) {
-
- _cmsFree(self ->ContextID, Matrix);
- return NULL;
- }
-
- for (i=0; i < nElems; i++) {
-
- cmsFloat32Number v;
-
- if (!_cmsReadFloat32Number(io, &v)) {
- _cmsFree(self ->ContextID, Matrix);
- _cmsFree(self ->ContextID, Offsets);
- return NULL;
- }
- Matrix[i] = v;
- }
-
-
- for (i=0; i < OutputChans; i++) {
-
- cmsFloat32Number v;
-
- if (!_cmsReadFloat32Number(io, &v)) {
- _cmsFree(self ->ContextID, Matrix);
- _cmsFree(self ->ContextID, Offsets);
- return NULL;
- }
- Offsets[i] = v;
- }
-
-
- mpe = cmsStageAllocMatrix(self ->ContextID, OutputChans, InputChans, Matrix, Offsets);
- _cmsFree(self ->ContextID, Matrix);
- _cmsFree(self ->ContextID, Offsets);
-
- *nItems = 1;
-
- return mpe;
-
- cmsUNUSED_PARAMETER(SizeOfTag);
-}
-
-static
-cmsBool Type_MPEmatrix_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
-{
- cmsUInt32Number i, nElems;
- cmsStage* mpe = (cmsStage*) Ptr;
- _cmsStageMatrixData* Matrix = (_cmsStageMatrixData*) mpe ->Data;
-
- if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) mpe ->InputChannels)) return FALSE;
- if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) mpe ->OutputChannels)) return FALSE;
-
- nElems = mpe ->InputChannels * mpe ->OutputChannels;
-
- for (i=0; i < nElems; i++) {
- if (!_cmsWriteFloat32Number(io, (cmsFloat32Number) Matrix->Double[i])) return FALSE;
- }
-
-
- for (i=0; i < mpe ->OutputChannels; i++) {
-
- if (Matrix ->Offset == NULL) {
-
- if (!_cmsWriteFloat32Number(io, 0)) return FALSE;
- }
- else {
- if (!_cmsWriteFloat32Number(io, (cmsFloat32Number) Matrix->Offset[i])) return FALSE;
- }
- }
-
- return TRUE;
-
- cmsUNUSED_PARAMETER(nItems);
- cmsUNUSED_PARAMETER(self);
-}
-
-
-
-static
-void *Type_MPEclut_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
-{
- cmsStage* mpe = NULL;
- cmsUInt16Number InputChans, OutputChans;
- cmsUInt8Number Dimensions8[16];
- cmsUInt32Number i, nMaxGrids, GridPoints[MAX_INPUT_DIMENSIONS];
- _cmsStageCLutData* clut;
-
- if (!_cmsReadUInt16Number(io, &InputChans)) return NULL;
- if (!_cmsReadUInt16Number(io, &OutputChans)) return NULL;
-
- if (InputChans == 0 || InputChans >= cmsMAXCHANNELS) goto Error;
- if (OutputChans == 0 || OutputChans >= cmsMAXCHANNELS) goto Error;
-
- if (io ->Read(io, Dimensions8, sizeof(cmsUInt8Number), 16) != 16)
- goto Error;
-
- // Copy MAX_INPUT_DIMENSIONS at most. Expand to cmsUInt32Number
- nMaxGrids = InputChans > MAX_INPUT_DIMENSIONS ? (cmsUInt32Number) MAX_INPUT_DIMENSIONS : InputChans;
-
- for (i = 0; i < nMaxGrids; i++) {
- if (Dimensions8[i] == 1) goto Error; // Impossible value, 0 for no CLUT and then 2 at least
- GridPoints[i] = (cmsUInt32Number)Dimensions8[i];
- }
-
- // Allocate the true CLUT
- mpe = cmsStageAllocCLutFloatGranular(self ->ContextID, GridPoints, InputChans, OutputChans, NULL);
- if (mpe == NULL) goto Error;
-
- // Read and sanitize the data
- clut = (_cmsStageCLutData*) mpe ->Data;
- for (i=0; i < clut ->nEntries; i++) {
-
- if (!_cmsReadFloat32Number(io, &clut->Tab.TFloat[i])) goto Error;
- }
-
- *nItems = 1;
- return mpe;
-
-Error:
- *nItems = 0;
- if (mpe != NULL) cmsStageFree(mpe);
- return NULL;
-
- cmsUNUSED_PARAMETER(SizeOfTag);
-}
-
-// Write a CLUT in floating point
-static
-cmsBool Type_MPEclut_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
-{
- cmsUInt8Number Dimensions8[16]; // 16 because the spec says 16 and not max number of channels
- cmsUInt32Number i;
- cmsStage* mpe = (cmsStage*) Ptr;
- _cmsStageCLutData* clut = (_cmsStageCLutData*) mpe ->Data;
-
- // Check for maximum number of channels supported by lcms
- if (mpe -> InputChannels > MAX_INPUT_DIMENSIONS) return FALSE;
-
- // Only floats are supported in MPE
- if (clut ->HasFloatValues == FALSE) return FALSE;
-
- if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) mpe ->InputChannels)) return FALSE;
- if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) mpe ->OutputChannels)) return FALSE;
-
- memset(Dimensions8, 0, sizeof(Dimensions8));
-
- for (i=0; i < mpe ->InputChannels; i++)
- Dimensions8[i] = (cmsUInt8Number) clut ->Params ->nSamples[i];
-
- if (!io ->Write(io, 16, Dimensions8)) return FALSE;
-
- for (i=0; i < clut ->nEntries; i++) {
-
- if (!_cmsWriteFloat32Number(io, clut ->Tab.TFloat[i])) return FALSE;
- }
-
- return TRUE;
-
- cmsUNUSED_PARAMETER(nItems);
- cmsUNUSED_PARAMETER(self);
-}
-
-
-
-// This is the list of built-in MPE types
-static _cmsTagTypeLinkedList SupportedMPEtypes[] = {
-
-{{ (cmsTagTypeSignature) cmsSigBAcsElemType, NULL, NULL, NULL, NULL, NULL, 0 }, &SupportedMPEtypes[1] }, // Ignore those elements for now
-{{ (cmsTagTypeSignature) cmsSigEAcsElemType, NULL, NULL, NULL, NULL, NULL, 0 }, &SupportedMPEtypes[2] }, // (That's what the spec says)
-
-{TYPE_MPE_HANDLER((cmsTagTypeSignature) cmsSigCurveSetElemType, MPEcurve), &SupportedMPEtypes[3] },
-{TYPE_MPE_HANDLER((cmsTagTypeSignature) cmsSigMatrixElemType, MPEmatrix), &SupportedMPEtypes[4] },
-{TYPE_MPE_HANDLER((cmsTagTypeSignature) cmsSigCLutElemType, MPEclut), NULL },
-};
-
-_cmsTagTypePluginChunkType _cmsMPETypePluginChunk = { NULL };
-
-static
-cmsBool ReadMPEElem(struct _cms_typehandler_struct* self,
- cmsIOHANDLER* io,
- void* Cargo,
- cmsUInt32Number n,
- cmsUInt32Number SizeOfTag)
-{
- cmsStageSignature ElementSig;
- cmsTagTypeHandler* TypeHandler;
- cmsUInt32Number nItems;
- cmsPipeline *NewLUT = (cmsPipeline *) Cargo;
- _cmsTagTypePluginChunkType* MPETypePluginChunk = ( _cmsTagTypePluginChunkType*) _cmsContextGetClientChunk(self->ContextID, MPEPlugin);
-
-
- // Take signature and channels for each element.
- if (!_cmsReadUInt32Number(io, (cmsUInt32Number*) &ElementSig)) return FALSE;
-
- // The reserved placeholder
- if (!_cmsReadUInt32Number(io, NULL)) return FALSE;
-
- // Read diverse MPE types
- TypeHandler = GetHandler((cmsTagTypeSignature) ElementSig, MPETypePluginChunk ->TagTypes, SupportedMPEtypes);
- if (TypeHandler == NULL) {
-
- char String[5];
-
- _cmsTagSignature2String(String, (cmsTagSignature) ElementSig);
-
- // An unknown element was found.
- cmsSignalError(self ->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unknown MPE type '%s' found.", String);
- return FALSE;
- }
-
- // If no read method, just ignore the element (valid for cmsSigBAcsElemType and cmsSigEAcsElemType)
- // Read the MPE. No size is given
- if (TypeHandler ->ReadPtr != NULL) {
-
- // This is a real element which should be read and processed
- if (!cmsPipelineInsertStage(NewLUT, cmsAT_END, (cmsStage*) TypeHandler ->ReadPtr(self, io, &nItems, SizeOfTag)))
- return FALSE;
- }
-
- return TRUE;
-
- cmsUNUSED_PARAMETER(SizeOfTag);
- cmsUNUSED_PARAMETER(n);
-}
-
-
-// This is the main dispatcher for MPE
-static
-void *Type_MPE_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
-{
- cmsUInt16Number InputChans, OutputChans;
- cmsUInt32Number ElementCount;
- cmsPipeline *NewLUT = NULL;
- cmsUInt32Number BaseOffset;
-
- // Get actual position as a basis for element offsets
- BaseOffset = io ->Tell(io) - sizeof(_cmsTagBase);
-
- // Read channels and element count
- if (!_cmsReadUInt16Number(io, &InputChans)) return NULL;
- if (!_cmsReadUInt16Number(io, &OutputChans)) return NULL;
-
- if (InputChans == 0 || InputChans >= cmsMAXCHANNELS) return NULL;
- if (OutputChans == 0 || OutputChans >= cmsMAXCHANNELS) return NULL;
-
- // Allocates an empty LUT
- NewLUT = cmsPipelineAlloc(self ->ContextID, InputChans, OutputChans);
- if (NewLUT == NULL) return NULL;
-
- if (!_cmsReadUInt32Number(io, &ElementCount)) goto Error;
- if (!ReadPositionTable(self, io, ElementCount, BaseOffset, NewLUT, ReadMPEElem)) goto Error;
-
- // Check channel count
- if (InputChans != NewLUT->InputChannels ||
- OutputChans != NewLUT->OutputChannels) goto Error;
-
- // Success
- *nItems = 1;
- return NewLUT;
-
- // Error
-Error:
- if (NewLUT != NULL) cmsPipelineFree(NewLUT);
- *nItems = 0;
- return NULL;
-
- cmsUNUSED_PARAMETER(SizeOfTag);
-}
-
-
-
-// This one is a little bit more complex, so we don't use position tables this time.
-static
-cmsBool Type_MPE_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
-{
- cmsUInt32Number i, BaseOffset, DirectoryPos, CurrentPos;
- cmsUInt32Number inputChan, outputChan;
- cmsUInt32Number ElemCount;
- cmsUInt32Number *ElementOffsets = NULL, *ElementSizes = NULL, Before;
- cmsStageSignature ElementSig;
- cmsPipeline* Lut = (cmsPipeline*) Ptr;
- cmsStage* Elem = Lut ->Elements;
- cmsTagTypeHandler* TypeHandler;
- _cmsTagTypePluginChunkType* MPETypePluginChunk = ( _cmsTagTypePluginChunkType*) _cmsContextGetClientChunk(self->ContextID, MPEPlugin);
-
- BaseOffset = io ->Tell(io) - sizeof(_cmsTagBase);
-
- inputChan = cmsPipelineInputChannels(Lut);
- outputChan = cmsPipelineOutputChannels(Lut);
- ElemCount = cmsPipelineStageCount(Lut);
-
- ElementOffsets = (cmsUInt32Number *) _cmsCalloc(self ->ContextID, ElemCount, sizeof(cmsUInt32Number));
- if (ElementOffsets == NULL) goto Error;
-
- ElementSizes = (cmsUInt32Number *) _cmsCalloc(self ->ContextID, ElemCount, sizeof(cmsUInt32Number));
- if (ElementSizes == NULL) goto Error;
-
- // Write the head
- if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) inputChan)) goto Error;
- if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) outputChan)) goto Error;
- if (!_cmsWriteUInt32Number(io, (cmsUInt16Number) ElemCount)) goto Error;
-
- DirectoryPos = io ->Tell(io);
-
- // Write a fake directory to be filled latter on
- for (i=0; i < ElemCount; i++) {
- if (!_cmsWriteUInt32Number(io, 0)) goto Error; // Offset
- if (!_cmsWriteUInt32Number(io, 0)) goto Error; // size
- }
-
- // Write each single tag. Keep track of the size as well.
- for (i=0; i < ElemCount; i++) {
-
- ElementOffsets[i] = io ->Tell(io) - BaseOffset;
-
- ElementSig = Elem ->Type;
-
- TypeHandler = GetHandler((cmsTagTypeSignature) ElementSig, MPETypePluginChunk->TagTypes, SupportedMPEtypes);
- if (TypeHandler == NULL) {
-
- char String[5];
-
- _cmsTagSignature2String(String, (cmsTagSignature) ElementSig);
-
- // An unknown element was found.
- cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Found unknown MPE type '%s'", String);
- goto Error;
- }
-
- if (!_cmsWriteUInt32Number(io, ElementSig)) goto Error;
- if (!_cmsWriteUInt32Number(io, 0)) goto Error;
- Before = io ->Tell(io);
- if (!TypeHandler ->WritePtr(self, io, Elem, 1)) goto Error;
- if (!_cmsWriteAlignment(io)) goto Error;
-
- ElementSizes[i] = io ->Tell(io) - Before;
-
- Elem = Elem ->Next;
- }
-
- // Write the directory
- CurrentPos = io ->Tell(io);
-
- if (!io ->Seek(io, DirectoryPos)) goto Error;
-
- for (i=0; i < ElemCount; i++) {
- if (!_cmsWriteUInt32Number(io, ElementOffsets[i])) goto Error;
- if (!_cmsWriteUInt32Number(io, ElementSizes[i])) goto Error;
- }
-
- if (!io ->Seek(io, CurrentPos)) goto Error;
-
- if (ElementOffsets != NULL) _cmsFree(self ->ContextID, ElementOffsets);
- if (ElementSizes != NULL) _cmsFree(self ->ContextID, ElementSizes);
- return TRUE;
-
-Error:
- if (ElementOffsets != NULL) _cmsFree(self ->ContextID, ElementOffsets);
- if (ElementSizes != NULL) _cmsFree(self ->ContextID, ElementSizes);
- return FALSE;
-
- cmsUNUSED_PARAMETER(nItems);
-}
-
-
-static
-void* Type_MPE_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
-{
- return (void*) cmsPipelineDup((cmsPipeline*) Ptr);
-
- cmsUNUSED_PARAMETER(n);
- cmsUNUSED_PARAMETER(self);
-}
-
-static
-void Type_MPE_Free(struct _cms_typehandler_struct* self, void *Ptr)
-{
- cmsPipelineFree((cmsPipeline*) Ptr);
- return;
-
- cmsUNUSED_PARAMETER(self);
-}
-
-
-// ********************************************************************************
-// Type cmsSigVcgtType
-// ********************************************************************************
-
-
-#define cmsVideoCardGammaTableType 0
-#define cmsVideoCardGammaFormulaType 1
-
-// Used internally
-typedef struct {
- double Gamma;
- double Min;
- double Max;
-} _cmsVCGTGAMMA;
-
-
-static
-void *Type_vcgt_Read(struct _cms_typehandler_struct* self,
- cmsIOHANDLER* io,
- cmsUInt32Number* nItems,
- cmsUInt32Number SizeOfTag)
-{
- cmsUInt32Number TagType, n, i;
- cmsToneCurve** Curves;
-
- *nItems = 0;
-
- // Read tag type
- if (!_cmsReadUInt32Number(io, &TagType)) return NULL;
-
- // Allocate space for the array
- Curves = ( cmsToneCurve**) _cmsCalloc(self ->ContextID, 3, sizeof(cmsToneCurve*));
- if (Curves == NULL) return NULL;
-
- // There are two possible flavors
- switch (TagType) {
-
- // Gamma is stored as a table
- case cmsVideoCardGammaTableType:
- {
- cmsUInt16Number nChannels, nElems, nBytes;
-
- // Check channel count, which should be 3 (we don't support monochrome this time)
- if (!_cmsReadUInt16Number(io, &nChannels)) goto Error;
-
- if (nChannels != 3) {
- cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unsupported number of channels for VCGT '%d'", nChannels);
- goto Error;
- }
-
- // Get Table element count and bytes per element
- if (!_cmsReadUInt16Number(io, &nElems)) goto Error;
- if (!_cmsReadUInt16Number(io, &nBytes)) goto Error;
-
- // Adobe's quirk fixup. Fixing broken profiles...
- if (nElems == 256 && nBytes == 1 && SizeOfTag == 1576)
- nBytes = 2;
-
-
- // Populate tone curves
- for (n=0; n < 3; n++) {
-
- Curves[n] = cmsBuildTabulatedToneCurve16(self ->ContextID, nElems, NULL);
- if (Curves[n] == NULL) goto Error;
-
- // On depending on byte depth
- switch (nBytes) {
-
- // One byte, 0..255
- case 1:
- for (i=0; i < nElems; i++) {
-
- cmsUInt8Number v;
-
- if (!_cmsReadUInt8Number(io, &v)) goto Error;
- Curves[n] ->Table16[i] = FROM_8_TO_16(v);
- }
- break;
-
- // One word 0..65535
- case 2:
- if (!_cmsReadUInt16Array(io, nElems, Curves[n]->Table16)) goto Error;
- break;
-
- // Unsupported
- default:
- cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unsupported bit depth for VCGT '%d'", nBytes * 8);
- goto Error;
- }
- } // For all 3 channels
- }
- break;
-
- // In this case, gamma is stored as a formula
- case cmsVideoCardGammaFormulaType:
- {
- _cmsVCGTGAMMA Colorant[3];
-
- // Populate tone curves
- for (n=0; n < 3; n++) {
-
- double Params[10];
-
- if (!_cmsRead15Fixed16Number(io, &Colorant[n].Gamma)) goto Error;
- if (!_cmsRead15Fixed16Number(io, &Colorant[n].Min)) goto Error;
- if (!_cmsRead15Fixed16Number(io, &Colorant[n].Max)) goto Error;
-
- // Parametric curve type 5 is:
- // Y = (aX + b)^Gamma + e | X >= d
- // Y = cX + f | X < d
-
- // vcgt formula is:
- // Y = (Max - Min) * (X ^ Gamma) + Min
-
- // So, the translation is
- // a = (Max - Min) ^ ( 1 / Gamma)
- // e = Min
- // b=c=d=f=0
-
- Params[0] = Colorant[n].Gamma;
- Params[1] = pow((Colorant[n].Max - Colorant[n].Min), (1.0 / Colorant[n].Gamma));
- Params[2] = 0;
- Params[3] = 0;
- Params[4] = 0;
- Params[5] = Colorant[n].Min;
- Params[6] = 0;
-
- Curves[n] = cmsBuildParametricToneCurve(self ->ContextID, 5, Params);
- if (Curves[n] == NULL) goto Error;
- }
- }
- break;
-
- // Unsupported
- default:
- cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unsupported tag type for VCGT '%d'", TagType);
- goto Error;
- }
-
- *nItems = 1;
- return (void*) Curves;
-
-// Regret, free all resources
-Error:
-
- cmsFreeToneCurveTriple(Curves);
- _cmsFree(self ->ContextID, Curves);
- return NULL;
-
- cmsUNUSED_PARAMETER(SizeOfTag);
-}
-
-
-// We don't support all flavors, only 16bits tables and formula
-static
-cmsBool Type_vcgt_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
-{
- cmsToneCurve** Curves = (cmsToneCurve**) Ptr;
- cmsUInt32Number i, j;
-
- if (cmsGetToneCurveParametricType(Curves[0]) == 5 &&
- cmsGetToneCurveParametricType(Curves[1]) == 5 &&
- cmsGetToneCurveParametricType(Curves[2]) == 5) {
-
- if (!_cmsWriteUInt32Number(io, cmsVideoCardGammaFormulaType)) return FALSE;
-
- // Save parameters
- for (i=0; i < 3; i++) {
-
- _cmsVCGTGAMMA v;
-
- v.Gamma = Curves[i] ->Segments[0].Params[0];
- v.Min = Curves[i] ->Segments[0].Params[5];
- v.Max = pow(Curves[i] ->Segments[0].Params[1], v.Gamma) + v.Min;
-
- if (!_cmsWrite15Fixed16Number(io, v.Gamma)) return FALSE;
- if (!_cmsWrite15Fixed16Number(io, v.Min)) return FALSE;
- if (!_cmsWrite15Fixed16Number(io, v.Max)) return FALSE;
- }
- }
-
- else {
-
- // Always store as a table of 256 words
- if (!_cmsWriteUInt32Number(io, cmsVideoCardGammaTableType)) return FALSE;
- if (!_cmsWriteUInt16Number(io, 3)) return FALSE;
- if (!_cmsWriteUInt16Number(io, 256)) return FALSE;
- if (!_cmsWriteUInt16Number(io, 2)) return FALSE;
-
- for (i=0; i < 3; i++) {
- for (j=0; j < 256; j++) {
-
- cmsFloat32Number v = cmsEvalToneCurveFloat(Curves[i], (cmsFloat32Number) (j / 255.0));
- cmsUInt16Number n = _cmsQuickSaturateWord(v * 65535.0);
-
- if (!_cmsWriteUInt16Number(io, n)) return FALSE;
- }
- }
- }
-
- return TRUE;
-
- cmsUNUSED_PARAMETER(self);
- cmsUNUSED_PARAMETER(nItems);
-}
-
-static
-void* Type_vcgt_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
-{
- cmsToneCurve** OldCurves = (cmsToneCurve**) Ptr;
- cmsToneCurve** NewCurves;
-
- NewCurves = ( cmsToneCurve**) _cmsCalloc(self ->ContextID, 3, sizeof(cmsToneCurve*));
- if (NewCurves == NULL) return NULL;
-
- NewCurves[0] = cmsDupToneCurve(OldCurves[0]);
- NewCurves[1] = cmsDupToneCurve(OldCurves[1]);
- NewCurves[2] = cmsDupToneCurve(OldCurves[2]);
-
- return (void*) NewCurves;
-
- cmsUNUSED_PARAMETER(n);
-}
-
-
-static
-void Type_vcgt_Free(struct _cms_typehandler_struct* self, void* Ptr)
-{
- cmsFreeToneCurveTriple((cmsToneCurve**) Ptr);
- _cmsFree(self ->ContextID, Ptr);
-}
-
-
-// ********************************************************************************
-// Type cmsSigDictType
-// ********************************************************************************
-
-// Single column of the table can point to wchar or MLUC elements. Holds arrays of data
-typedef struct {
- cmsContext ContextID;
- cmsUInt32Number *Offsets;
- cmsUInt32Number *Sizes;
-} _cmsDICelem;
-
-typedef struct {
- _cmsDICelem Name, Value, DisplayName, DisplayValue;
-
-} _cmsDICarray;
-
-// Allocate an empty array element
-static
-cmsBool AllocElem(cmsContext ContextID, _cmsDICelem* e, cmsUInt32Number Count)
-{
- e->Offsets = (cmsUInt32Number *) _cmsCalloc(ContextID, Count, sizeof(cmsUInt32Number));
- if (e->Offsets == NULL) return FALSE;
-
- e->Sizes = (cmsUInt32Number *) _cmsCalloc(ContextID, Count, sizeof(cmsUInt32Number));
- if (e->Sizes == NULL) {
-
- _cmsFree(ContextID, e -> Offsets);
- return FALSE;
- }
-
- e ->ContextID = ContextID;
- return TRUE;
-}
-
-// Free an array element
-static
-void FreeElem(_cmsDICelem* e)
-{
- if (e ->Offsets != NULL) _cmsFree(e -> ContextID, e -> Offsets);
- if (e ->Sizes != NULL) _cmsFree(e -> ContextID, e -> Sizes);
- e->Offsets = e ->Sizes = NULL;
-}
-
-// Get rid of whole array
-static
-void FreeArray( _cmsDICarray* a)
-{
- if (a ->Name.Offsets != NULL) FreeElem(&a->Name);
- if (a ->Value.Offsets != NULL) FreeElem(&a ->Value);
- if (a ->DisplayName.Offsets != NULL) FreeElem(&a->DisplayName);
- if (a ->DisplayValue.Offsets != NULL) FreeElem(&a ->DisplayValue);
-}
-
-
-// Allocate whole array
-static
-cmsBool AllocArray(cmsContext ContextID, _cmsDICarray* a, cmsUInt32Number Count, cmsUInt32Number Length)
-{
- // Empty values
- memset(a, 0, sizeof(_cmsDICarray));
-
- // On depending on record size, create column arrays
- if (!AllocElem(ContextID, &a ->Name, Count)) goto Error;
- if (!AllocElem(ContextID, &a ->Value, Count)) goto Error;
-
- if (Length > 16) {
- if (!AllocElem(ContextID, &a -> DisplayName, Count)) goto Error;
-
- }
- if (Length > 24) {
- if (!AllocElem(ContextID, &a ->DisplayValue, Count)) goto Error;
- }
- return TRUE;
-
-Error:
- FreeArray(a);
- return FALSE;
-}
-
-// Read one element
-static
-cmsBool ReadOneElem(cmsIOHANDLER* io, _cmsDICelem* e, cmsUInt32Number i, cmsUInt32Number BaseOffset)
-{
- if (!_cmsReadUInt32Number(io, &e->Offsets[i])) return FALSE;
- if (!_cmsReadUInt32Number(io, &e ->Sizes[i])) return FALSE;
-
- // An offset of zero has special meaning and shall be preserved
- if (e ->Offsets[i] > 0)
- e ->Offsets[i] += BaseOffset;
- return TRUE;
-}
-
-
-static
-cmsBool ReadOffsetArray(cmsIOHANDLER* io, _cmsDICarray* a,
- cmsUInt32Number Count, cmsUInt32Number Length, cmsUInt32Number BaseOffset,
- cmsInt32Number* SignedSizeOfTagPtr)
-{
- cmsUInt32Number i;
- cmsInt32Number SignedSizeOfTag = *SignedSizeOfTagPtr;
-
- // Read column arrays
- for (i=0; i < Count; i++) {
-
- if (SignedSizeOfTag < 4 * (cmsInt32Number) sizeof(cmsUInt32Number)) return FALSE;
- SignedSizeOfTag -= 4 * sizeof(cmsUInt32Number);
-
- if (!ReadOneElem(io, &a -> Name, i, BaseOffset)) return FALSE;
- if (!ReadOneElem(io, &a -> Value, i, BaseOffset)) return FALSE;
-
- if (Length > 16) {
-
- if (SignedSizeOfTag < 2 * (cmsInt32Number) sizeof(cmsUInt32Number)) return FALSE;
- SignedSizeOfTag -= 2 * sizeof(cmsUInt32Number);
-
- if (!ReadOneElem(io, &a ->DisplayName, i, BaseOffset)) return FALSE;
-
- }
-
- if (Length > 24) {
-
- if (SignedSizeOfTag < 2 * (cmsInt32Number) sizeof(cmsUInt32Number)) return FALSE;
- SignedSizeOfTag -= 2 * (cmsInt32Number) sizeof(cmsUInt32Number);
-
- if (!ReadOneElem(io, & a -> DisplayValue, i, BaseOffset)) return FALSE;
- }
- }
-
- *SignedSizeOfTagPtr = SignedSizeOfTag;
- return TRUE;
-}
-
-
-// Write one element
-static
-cmsBool WriteOneElem(cmsIOHANDLER* io, _cmsDICelem* e, cmsUInt32Number i)
-{
- if (!_cmsWriteUInt32Number(io, e->Offsets[i])) return FALSE;
- if (!_cmsWriteUInt32Number(io, e ->Sizes[i])) return FALSE;
-
- return TRUE;
-}
-
-static
-cmsBool WriteOffsetArray(cmsIOHANDLER* io, _cmsDICarray* a, cmsUInt32Number Count, cmsUInt32Number Length)
-{
- cmsUInt32Number i;
-
- for (i=0; i < Count; i++) {
-
- if (!WriteOneElem(io, &a -> Name, i)) return FALSE;
- if (!WriteOneElem(io, &a -> Value, i)) return FALSE;
-
- if (Length > 16) {
-
- if (!WriteOneElem(io, &a -> DisplayName, i)) return FALSE;
- }
-
- if (Length > 24) {
-
- if (!WriteOneElem(io, &a -> DisplayValue, i)) return FALSE;
- }
- }
-
- return TRUE;
-}
-
-static
-cmsBool ReadOneWChar(cmsIOHANDLER* io, _cmsDICelem* e, cmsUInt32Number i, wchar_t ** wcstr)
-{
-
- cmsUInt32Number nChars;
-
- // Special case for undefined strings (see ICC Votable
- // Proposal Submission, Dictionary Type and Metadata TAG Definition)
- if (e -> Offsets[i] == 0) {
-
- *wcstr = NULL;
- return TRUE;
- }
-
- if (!io -> Seek(io, e -> Offsets[i])) return FALSE;
-
- nChars = e ->Sizes[i] / sizeof(cmsUInt16Number);
-
-
- *wcstr = (wchar_t*) _cmsMallocZero(e ->ContextID, (nChars + 1) * sizeof(wchar_t));
- if (*wcstr == NULL) return FALSE;
-
- if (!_cmsReadWCharArray(io, nChars, *wcstr)) {
- _cmsFree(e ->ContextID, *wcstr);
- return FALSE;
- }
-
- // End of string marker
- (*wcstr)[nChars] = 0;
- return TRUE;
-}
-
-static
-cmsUInt32Number mywcslen(const wchar_t *s)
-{
- const wchar_t *p;
-
- p = s;
- while (*p)
- p++;
-
- return (cmsUInt32Number)(p - s);
-}
-
-static
-cmsBool WriteOneWChar(cmsIOHANDLER* io, _cmsDICelem* e, cmsUInt32Number i, const wchar_t * wcstr, cmsUInt32Number BaseOffset)
-{
- cmsUInt32Number Before = io ->Tell(io);
- cmsUInt32Number n;
-
- e ->Offsets[i] = Before - BaseOffset;
-
- if (wcstr == NULL) {
- e ->Sizes[i] = 0;
- e ->Offsets[i] = 0;
- return TRUE;
- }
-
- n = mywcslen(wcstr);
- if (!_cmsWriteWCharArray(io, n, wcstr)) return FALSE;
-
- e ->Sizes[i] = io ->Tell(io) - Before;
- return TRUE;
-}
-
-static
-cmsBool ReadOneMLUC(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, _cmsDICelem* e, cmsUInt32Number i, cmsMLU** mlu)
-{
- cmsUInt32Number nItems = 0;
-
- // A way to get null MLUCs
- if (e -> Offsets[i] == 0 || e ->Sizes[i] == 0) {
-
- *mlu = NULL;
- return TRUE;
- }
-
- if (!io -> Seek(io, e -> Offsets[i])) return FALSE;
-
- *mlu = (cmsMLU*) Type_MLU_Read(self, io, &nItems, e ->Sizes[i]);
- return *mlu != NULL;
-}
-
-static
-cmsBool WriteOneMLUC(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, _cmsDICelem* e, cmsUInt32Number i, const cmsMLU* mlu, cmsUInt32Number BaseOffset)
-{
- cmsUInt32Number Before;
-
- // Special case for undefined strings (see ICC Votable
- // Proposal Submission, Dictionary Type and Metadata TAG Definition)
- if (mlu == NULL) {
- e ->Sizes[i] = 0;
- e ->Offsets[i] = 0;
- return TRUE;
- }
-
- Before = io ->Tell(io);
- if (e->Offsets != NULL)
- e ->Offsets[i] = Before - BaseOffset;
-
- if (!Type_MLU_Write(self, io, (void*) mlu, 1)) return FALSE;
-
- if (e->Sizes != NULL)
- e ->Sizes[i] = io ->Tell(io) - Before;
- return TRUE;
-}
-
-
-static
-void *Type_Dictionary_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
-{
- cmsHANDLE hDict = NULL;
- cmsUInt32Number i, Count, Length;
- cmsUInt32Number BaseOffset;
- _cmsDICarray a;
- wchar_t *NameWCS = NULL, *ValueWCS = NULL;
- cmsMLU *DisplayNameMLU = NULL, *DisplayValueMLU=NULL;
- cmsBool rc;
- cmsInt32Number SignedSizeOfTag = (cmsInt32Number)SizeOfTag;
-
- *nItems = 0;
- memset(&a, 0, sizeof(a));
-
- // Get actual position as a basis for element offsets
- BaseOffset = io ->Tell(io) - sizeof(_cmsTagBase);
-
- // Get name-value record count
- SignedSizeOfTag -= sizeof(cmsUInt32Number);
- if (SignedSizeOfTag < 0) goto Error;
- if (!_cmsReadUInt32Number(io, &Count)) return NULL;
-
- // Get rec length
- SignedSizeOfTag -= sizeof(cmsUInt32Number);
- if (SignedSizeOfTag < 0) goto Error;
- if (!_cmsReadUInt32Number(io, &Length)) return NULL;
-
-
- // Check for valid lengths
- if (Length != 16 && Length != 24 && Length != 32) {
- cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unknown record length in dictionary '%d'", Length);
- return NULL;
- }
-
- // Creates an empty dictionary
- hDict = cmsDictAlloc(self -> ContextID);
- if (hDict == NULL) return NULL;
-
- // On depending on record size, create column arrays
- if (!AllocArray(self -> ContextID, &a, Count, Length)) goto Error;
-
- // Read column arrays
- if (!ReadOffsetArray(io, &a, Count, Length, BaseOffset, &SignedSizeOfTag)) goto Error;
-
- // Seek to each element and read it
- for (i=0; i < Count; i++) {
-
- if (!ReadOneWChar(io, &a.Name, i, &NameWCS)) goto Error;
- if (!ReadOneWChar(io, &a.Value, i, &ValueWCS)) goto Error;
-
- if (Length > 16) {
- if (!ReadOneMLUC(self, io, &a.DisplayName, i, &DisplayNameMLU)) goto Error;
- }
-
- if (Length > 24) {
- if (!ReadOneMLUC(self, io, &a.DisplayValue, i, &DisplayValueMLU)) goto Error;
- }
-
- if (NameWCS == NULL || ValueWCS == NULL) {
-
- cmsSignalError(self->ContextID, cmsERROR_CORRUPTION_DETECTED, "Bad dictionary Name/Value");
- rc = FALSE;
- }
- else {
-
- rc = cmsDictAddEntry(hDict, NameWCS, ValueWCS, DisplayNameMLU, DisplayValueMLU);
- }
-
- if (NameWCS != NULL) _cmsFree(self ->ContextID, NameWCS);
- if (ValueWCS != NULL) _cmsFree(self ->ContextID, ValueWCS);
- if (DisplayNameMLU != NULL) cmsMLUfree(DisplayNameMLU);
- if (DisplayValueMLU != NULL) cmsMLUfree(DisplayValueMLU);
-
- if (!rc) goto Error;
- }
-
- FreeArray(&a);
- *nItems = 1;
- return (void*) hDict;
-
-Error:
- FreeArray(&a);
- if (hDict != NULL) cmsDictFree(hDict);
- return NULL;
-}
-
-
-static
-cmsBool Type_Dictionary_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
-{
- cmsHANDLE hDict = (cmsHANDLE) Ptr;
- const cmsDICTentry* p;
- cmsBool AnyName, AnyValue;
- cmsUInt32Number i, Count, Length;
- cmsUInt32Number DirectoryPos, CurrentPos, BaseOffset;
- _cmsDICarray a;
-
- if (hDict == NULL) return FALSE;
-
- BaseOffset = io ->Tell(io) - sizeof(_cmsTagBase);
-
- // Let's inspect the dictionary
- Count = 0; AnyName = FALSE; AnyValue = FALSE;
- for (p = cmsDictGetEntryList(hDict); p != NULL; p = cmsDictNextEntry(p)) {
-
- if (p ->DisplayName != NULL) AnyName = TRUE;
- if (p ->DisplayValue != NULL) AnyValue = TRUE;
- Count++;
- }
-
- Length = 16;
- if (AnyName) Length += 8;
- if (AnyValue) Length += 8;
-
- if (!_cmsWriteUInt32Number(io, Count)) return FALSE;
- if (!_cmsWriteUInt32Number(io, Length)) return FALSE;
-
- // Keep starting position of offsets table
- DirectoryPos = io ->Tell(io);
-
- // Allocate offsets array
- if (!AllocArray(self ->ContextID, &a, Count, Length)) goto Error;
-
- // Write a fake directory to be filled latter on
- if (!WriteOffsetArray(io, &a, Count, Length)) goto Error;
-
- // Write each element. Keep track of the size as well.
- p = cmsDictGetEntryList(hDict);
- for (i=0; i < Count; i++) {
-
- if (!WriteOneWChar(io, &a.Name, i, p ->Name, BaseOffset)) goto Error;
- if (!WriteOneWChar(io, &a.Value, i, p ->Value, BaseOffset)) goto Error;
-
- if (p ->DisplayName != NULL) {
- if (!WriteOneMLUC(self, io, &a.DisplayName, i, p ->DisplayName, BaseOffset)) goto Error;
- }
-
- if (p ->DisplayValue != NULL) {
- if (!WriteOneMLUC(self, io, &a.DisplayValue, i, p ->DisplayValue, BaseOffset)) goto Error;
- }
-
- p = cmsDictNextEntry(p);
- }
-
- // Write the directory
- CurrentPos = io ->Tell(io);
- if (!io ->Seek(io, DirectoryPos)) goto Error;
-
- if (!WriteOffsetArray(io, &a, Count, Length)) goto Error;
-
- if (!io ->Seek(io, CurrentPos)) goto Error;
-
- FreeArray(&a);
- return TRUE;
-
-Error:
- FreeArray(&a);
- return FALSE;
-
- cmsUNUSED_PARAMETER(nItems);
-}
-
-
-static
-void* Type_Dictionary_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
-{
- return (void*) cmsDictDup((cmsHANDLE) Ptr);
-
- cmsUNUSED_PARAMETER(n);
- cmsUNUSED_PARAMETER(self);
-}
-
-
-static
-void Type_Dictionary_Free(struct _cms_typehandler_struct* self, void* Ptr)
-{
- cmsDictFree((cmsHANDLE) Ptr);
- cmsUNUSED_PARAMETER(self);
-}
-
-// cicp VideoSignalType
-
-static
-void* Type_VideoSignal_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
-{
- cmsVideoSignalType* cicp = NULL;
-
- if (SizeOfTag != 8) return NULL;
-
- if (!_cmsReadUInt32Number(io, NULL)) return NULL;
-
- cicp = (cmsVideoSignalType*)_cmsCalloc(self->ContextID, 1, sizeof(cmsVideoSignalType));
- if (cicp == NULL) return NULL;
-
- if (!_cmsReadUInt8Number(io, &cicp->ColourPrimaries)) goto Error;
- if (!_cmsReadUInt8Number(io, &cicp->TransferCharacteristics)) goto Error;
- if (!_cmsReadUInt8Number(io, &cicp->MatrixCoefficients)) goto Error;
- if (!_cmsReadUInt8Number(io, &cicp->VideoFullRangeFlag)) goto Error;
-
- // Success
- *nItems = 1;
- return cicp;
-
-Error:
- if (cicp != NULL) _cmsFree(self->ContextID, cicp);
- return NULL;
-}
-
-static
-cmsBool Type_VideoSignal_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
-{
- cmsVideoSignalType* cicp = (cmsVideoSignalType*)Ptr;
-
- if (!_cmsWriteUInt32Number(io, 0)) return FALSE;
- if (!_cmsWriteUInt8Number(io, cicp->ColourPrimaries)) return FALSE;
- if (!_cmsWriteUInt8Number(io, cicp->TransferCharacteristics)) return FALSE;
- if (!_cmsWriteUInt8Number(io, cicp->MatrixCoefficients)) return FALSE;
- if (!_cmsWriteUInt8Number(io, cicp->VideoFullRangeFlag)) return FALSE;
-
- return TRUE;
-
- cmsUNUSED_PARAMETER(self);
- cmsUNUSED_PARAMETER(nItems);
-}
-
-void* Type_VideoSignal_Dup(struct _cms_typehandler_struct* self, const void* Ptr, cmsUInt32Number n)
-{
- return _cmsDupMem(self->ContextID, Ptr, sizeof(cmsVideoSignalType));
-
- cmsUNUSED_PARAMETER(n);
-}
-
-
-static
-void Type_VideoSignal_Free(struct _cms_typehandler_struct* self, void* Ptr)
-{
- _cmsFree(self->ContextID, Ptr);
-}
-
-
-// ********************************************************************************
-// Microsoft's MHC2 Type support
-// ********************************************************************************
-
-static
-void SetIdentity(cmsFloat64Number XYZ2XYZmatrix[3][4])
-{
- XYZ2XYZmatrix[0][0] = 1.0; XYZ2XYZmatrix[0][1] = 0.0; XYZ2XYZmatrix[0][2] = 0.0; XYZ2XYZmatrix[0][3] = 0.0;
- XYZ2XYZmatrix[1][0] = 0.0; XYZ2XYZmatrix[1][1] = 1.0; XYZ2XYZmatrix[1][2] = 0.0; XYZ2XYZmatrix[1][3] = 0.0;
- XYZ2XYZmatrix[2][0] = 0.0; XYZ2XYZmatrix[2][1] = 0.0; XYZ2XYZmatrix[2][2] = 1.0; XYZ2XYZmatrix[2][3] = 0.0;
-}
-
-static
-cmsBool CloseEnough(cmsFloat64Number a, cmsFloat64Number b)
-{
- return fabs(b - a) < (1.0 / 65535.0);
-}
-
-cmsBool IsIdentity(cmsFloat64Number XYZ2XYZmatrix[3][4])
-{
- cmsFloat64Number Identity[3][4];
- int i, j;
-
- SetIdentity(Identity);
-
- for (i = 0; i < 3; i++)
- for (j = 0; j < 4; j++)
- if (!CloseEnough(XYZ2XYZmatrix[i][j], Identity[i][j])) return FALSE;
-
- return TRUE;
-}
-
-static
-void Type_MHC2_Free(struct _cms_typehandler_struct* self, void* Ptr)
-{
- cmsMHC2Type* mhc2 = (cmsMHC2Type*)Ptr;
-
- if (mhc2->RedCurve != NULL) _cmsFree(self->ContextID, mhc2->RedCurve);
- if (mhc2->GreenCurve != NULL) _cmsFree(self->ContextID, mhc2->GreenCurve);
- if (mhc2->BlueCurve != NULL) _cmsFree(self->ContextID, mhc2->BlueCurve);
-
- _cmsFree(self->ContextID, Ptr);
-}
-
-void* Type_MHC2_Dup(struct _cms_typehandler_struct* self, const void* Ptr, cmsUInt32Number n)
-{
- cmsMHC2Type* mhc2 = _cmsDupMem(self->ContextID, Ptr, sizeof(cmsMHC2Type));
-
- mhc2->RedCurve = _cmsDupMem(self->ContextID, mhc2->RedCurve, mhc2->CurveEntries*sizeof(cmsFloat64Number));
- mhc2->GreenCurve = _cmsDupMem(self->ContextID, mhc2->GreenCurve, mhc2->CurveEntries * sizeof(cmsFloat64Number));
- mhc2->BlueCurve = _cmsDupMem(self->ContextID, mhc2->BlueCurve, mhc2->CurveEntries * sizeof(cmsFloat64Number));
-
- if (mhc2->RedCurve == NULL ||
- mhc2->GreenCurve == NULL ||
- mhc2->BlueCurve == NULL) {
-
- Type_MHC2_Free(self, mhc2);
- return NULL;
- }
-
- return mhc2;
-
- cmsUNUSED_PARAMETER(n);
-}
-
-
-static
-cmsBool WriteDoubles(cmsIOHANDLER* io, cmsUInt32Number n, cmsFloat64Number* Values)
-{
- cmsUInt32Number i;
-
- for (i = 0; i < n; i++) {
-
- if (!_cmsWrite15Fixed16Number(io, *Values++)) return FALSE;
- }
-
- return TRUE;
-}
-
-static
-cmsBool Type_MHC2_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
-{
- cmsMHC2Type* mhc2 = (cmsMHC2Type*)Ptr;
- cmsUInt32Number BaseOffset = io->Tell(io) - sizeof(_cmsTagBase);
- cmsUInt32Number TablesOffsetPos;
- cmsUInt32Number MatrixOffset;
- cmsUInt32Number OffsetRedTable, OffsetGreenTable, OffsetBlueTable;
-
- if (!_cmsWriteUInt32Number(io, 0)) return FALSE;
- if (!_cmsWriteUInt32Number(io, mhc2->CurveEntries)) return FALSE;
-
- if (!_cmsWrite15Fixed16Number(io, mhc2->MinLuminance)) return FALSE;
- if (!_cmsWrite15Fixed16Number(io, mhc2->PeakLuminance)) return FALSE;
-
- TablesOffsetPos = io->Tell(io);
-
- if (!_cmsWriteUInt32Number(io, 0)) return FALSE; // Matrix
- if (!_cmsWriteUInt32Number(io, 0)) return FALSE; // Curve R
- if (!_cmsWriteUInt32Number(io, 0)) return FALSE; // Curve G
- if (!_cmsWriteUInt32Number(io, 0)) return FALSE; // Curve B
-
-
- if (IsIdentity(mhc2->XYZ2XYZmatrix))
- {
- MatrixOffset = 0;
- }
- else
- {
- MatrixOffset = io->Tell(io) - BaseOffset;
- if (!WriteDoubles(io, 3 * 4, &mhc2->XYZ2XYZmatrix[0][0])) return FALSE;
- }
-
- OffsetRedTable = io->Tell(io) - BaseOffset;
- if (!WriteDoubles(io, mhc2->CurveEntries, mhc2->RedCurve)) return FALSE;
- OffsetGreenTable = io->Tell(io) - BaseOffset;
- if (!WriteDoubles(io, mhc2->CurveEntries, mhc2->GreenCurve)) return FALSE;
- OffsetBlueTable = io->Tell(io) - BaseOffset;
- if (!WriteDoubles(io, mhc2->CurveEntries, mhc2->BlueCurve)) return FALSE;
-
- if (!io->Seek(io, TablesOffsetPos)) return FALSE;
-
- if (!_cmsWriteUInt32Number(io, MatrixOffset)) return FALSE;
- if (!_cmsWriteUInt32Number(io, OffsetRedTable)) return FALSE;
- if (!_cmsWriteUInt32Number(io, OffsetGreenTable)) return FALSE;
- if (!_cmsWriteUInt32Number(io, OffsetBlueTable)) return FALSE;
-
- return TRUE;
-
- cmsUNUSED_PARAMETER(self);
- cmsUNUSED_PARAMETER(nItems);
-}
-
-
-static
-cmsBool ReadDoublesAt(cmsIOHANDLER* io, cmsUInt32Number At, cmsUInt32Number n, cmsFloat64Number* Values)
-{
- cmsUInt32Number CurrentPos = io->Tell(io);
- cmsUInt32Number i;
-
- if (!io->Seek(io, At)) return FALSE;
-
- for (i = 0; i < n; i++) {
-
- if (!_cmsRead15Fixed16Number(io, Values++)) return FALSE;
- }
-
- if (!io->Seek(io, CurrentPos)) return FALSE;
-
- return TRUE;
-}
-
-static
-void* Type_MHC2_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
-{
- cmsMHC2Type* mhc2 = NULL;
-
- cmsUInt32Number BaseOffset = io->Tell(io) - sizeof(_cmsTagBase);
- cmsUInt32Number MatrixOffset;
- cmsUInt32Number OffsetRedTable, OffsetGreenTable, OffsetBlueTable;
-
- if (!_cmsReadUInt32Number(io, NULL)) return NULL;
-
- mhc2 = (cmsMHC2Type*)_cmsCalloc(self->ContextID, 1, sizeof(cmsMHC2Type));
- if (mhc2 == NULL) return NULL;
-
- if (!_cmsReadUInt32Number(io, &mhc2->CurveEntries)) goto Error;
-
- if (mhc2->CurveEntries > 4096) goto Error;
-
- mhc2->RedCurve = (cmsFloat64Number*)_cmsCalloc(self->ContextID, mhc2->CurveEntries, sizeof(cmsFloat64Number));
- mhc2->GreenCurve = (cmsFloat64Number*)_cmsCalloc(self->ContextID, mhc2->CurveEntries, sizeof(cmsFloat64Number));
- mhc2->BlueCurve = (cmsFloat64Number*)_cmsCalloc(self->ContextID, mhc2->CurveEntries, sizeof(cmsFloat64Number));
-
- if (mhc2->RedCurve == NULL ||
- mhc2->GreenCurve == NULL ||
- mhc2->BlueCurve == NULL) goto Error;
-
- if (!_cmsRead15Fixed16Number(io, &mhc2->MinLuminance)) goto Error;
- if (!_cmsRead15Fixed16Number(io, &mhc2->PeakLuminance)) goto Error;
-
- if (!_cmsReadUInt32Number(io, &MatrixOffset)) goto Error;
- if (!_cmsReadUInt32Number(io, &OffsetRedTable)) goto Error;
- if (!_cmsReadUInt32Number(io, &OffsetGreenTable)) goto Error;
- if (!_cmsReadUInt32Number(io, &OffsetBlueTable)) goto Error;
-
- if (MatrixOffset == 0)
- SetIdentity(mhc2->XYZ2XYZmatrix);
- else
- {
- if (!ReadDoublesAt(io, BaseOffset + MatrixOffset, 3*4, &mhc2->XYZ2XYZmatrix[0][0])) goto Error;
- }
-
- if (!ReadDoublesAt(io, BaseOffset + OffsetRedTable, mhc2->CurveEntries, mhc2->RedCurve)) goto Error;
- if (!ReadDoublesAt(io, BaseOffset + OffsetGreenTable, mhc2->CurveEntries, mhc2->GreenCurve)) goto Error;
- if (!ReadDoublesAt(io, BaseOffset + OffsetBlueTable, mhc2->CurveEntries, mhc2->BlueCurve)) goto Error;
-
- // Success
- *nItems = 1;
- return mhc2;
-
-Error:
- Type_MHC2_Free(self, mhc2);
- return NULL;
-
- cmsUNUSED_PARAMETER(SizeOfTag);
-}
-
-
-
-// ********************************************************************************
-// Type support main routines
-// ********************************************************************************
-
-
-// This is the list of built-in types
-static const _cmsTagTypeLinkedList SupportedTagTypes[] = {
-
-{TYPE_HANDLER(cmsSigChromaticityType, Chromaticity), (_cmsTagTypeLinkedList*) &SupportedTagTypes[1] },
-{TYPE_HANDLER(cmsSigColorantOrderType, ColorantOrderType), (_cmsTagTypeLinkedList*) &SupportedTagTypes[2] },
-{TYPE_HANDLER(cmsSigS15Fixed16ArrayType, S15Fixed16), (_cmsTagTypeLinkedList*) &SupportedTagTypes[3] },
-{TYPE_HANDLER(cmsSigU16Fixed16ArrayType, U16Fixed16), (_cmsTagTypeLinkedList*) &SupportedTagTypes[4] },
-{TYPE_HANDLER(cmsSigTextType, Text), (_cmsTagTypeLinkedList*) &SupportedTagTypes[5] },
-{TYPE_HANDLER(cmsSigTextDescriptionType, Text_Description), (_cmsTagTypeLinkedList*) &SupportedTagTypes[6] },
-{TYPE_HANDLER(cmsSigCurveType, Curve), (_cmsTagTypeLinkedList*) &SupportedTagTypes[7] },
-{TYPE_HANDLER(cmsSigParametricCurveType, ParametricCurve), (_cmsTagTypeLinkedList*) &SupportedTagTypes[8] },
-{TYPE_HANDLER(cmsSigDateTimeType, DateTime), (_cmsTagTypeLinkedList*) &SupportedTagTypes[9] },
-{TYPE_HANDLER(cmsSigLut8Type, LUT8), (_cmsTagTypeLinkedList*) &SupportedTagTypes[10] },
-{TYPE_HANDLER(cmsSigLut16Type, LUT16), (_cmsTagTypeLinkedList*) &SupportedTagTypes[11] },
-{TYPE_HANDLER(cmsSigColorantTableType, ColorantTable), (_cmsTagTypeLinkedList*) &SupportedTagTypes[12] },
-{TYPE_HANDLER(cmsSigNamedColor2Type, NamedColor), (_cmsTagTypeLinkedList*) &SupportedTagTypes[13] },
-{TYPE_HANDLER(cmsSigMultiLocalizedUnicodeType, MLU), (_cmsTagTypeLinkedList*) &SupportedTagTypes[14] },
-{TYPE_HANDLER(cmsSigProfileSequenceDescType, ProfileSequenceDesc),(_cmsTagTypeLinkedList*) &SupportedTagTypes[15] },
-{TYPE_HANDLER(cmsSigSignatureType, Signature), (_cmsTagTypeLinkedList*) &SupportedTagTypes[16] },
-{TYPE_HANDLER(cmsSigMeasurementType, Measurement), (_cmsTagTypeLinkedList*) &SupportedTagTypes[17] },
-{TYPE_HANDLER(cmsSigDataType, Data), (_cmsTagTypeLinkedList*) &SupportedTagTypes[18] },
-{TYPE_HANDLER(cmsSigLutAtoBType, LUTA2B), (_cmsTagTypeLinkedList*) &SupportedTagTypes[19] },
-{TYPE_HANDLER(cmsSigLutBtoAType, LUTB2A), (_cmsTagTypeLinkedList*) &SupportedTagTypes[20] },
-{TYPE_HANDLER(cmsSigUcrBgType, UcrBg), (_cmsTagTypeLinkedList*) &SupportedTagTypes[21] },
-{TYPE_HANDLER(cmsSigCrdInfoType, CrdInfo), (_cmsTagTypeLinkedList*) &SupportedTagTypes[22] },
-{TYPE_HANDLER(cmsSigMultiProcessElementType, MPE), (_cmsTagTypeLinkedList*) &SupportedTagTypes[23] },
-{TYPE_HANDLER(cmsSigScreeningType, Screening), (_cmsTagTypeLinkedList*) &SupportedTagTypes[24] },
-{TYPE_HANDLER(cmsSigViewingConditionsType, ViewingConditions), (_cmsTagTypeLinkedList*) &SupportedTagTypes[25] },
-{TYPE_HANDLER(cmsSigXYZType, XYZ), (_cmsTagTypeLinkedList*) &SupportedTagTypes[26] },
-{TYPE_HANDLER(cmsCorbisBrokenXYZtype, XYZ), (_cmsTagTypeLinkedList*) &SupportedTagTypes[27] },
-{TYPE_HANDLER(cmsMonacoBrokenCurveType, Curve), (_cmsTagTypeLinkedList*) &SupportedTagTypes[28] },
-{TYPE_HANDLER(cmsSigProfileSequenceIdType, ProfileSequenceId), (_cmsTagTypeLinkedList*) &SupportedTagTypes[29] },
-{TYPE_HANDLER(cmsSigDictType, Dictionary), (_cmsTagTypeLinkedList*) &SupportedTagTypes[30] },
-{TYPE_HANDLER(cmsSigcicpType, VideoSignal), (_cmsTagTypeLinkedList*) &SupportedTagTypes[31] },
-{TYPE_HANDLER(cmsSigVcgtType, vcgt), (_cmsTagTypeLinkedList*) &SupportedTagTypes[32] },
-{TYPE_HANDLER(cmsSigMHC2Type, MHC2), NULL }
-};
-
-
-_cmsTagTypePluginChunkType _cmsTagTypePluginChunk = { NULL };
-
-
-
-// Duplicates the zone of memory used by the plug-in in the new context
-static
-void DupTagTypeList(struct _cmsContext_struct* ctx,
- const struct _cmsContext_struct* src,
- int loc)
-{
- _cmsTagTypePluginChunkType newHead = { NULL };
- _cmsTagTypeLinkedList* entry;
- _cmsTagTypeLinkedList* Anterior = NULL;
- _cmsTagTypePluginChunkType* head = (_cmsTagTypePluginChunkType*) src->chunks[loc];
-
- // Walk the list copying all nodes
- for (entry = head->TagTypes;
- entry != NULL;
- entry = entry ->Next) {
-
- _cmsTagTypeLinkedList *newEntry = ( _cmsTagTypeLinkedList *) _cmsSubAllocDup(ctx ->MemPool, entry, sizeof(_cmsTagTypeLinkedList));
-
- if (newEntry == NULL)
- return;
-
- // We want to keep the linked list order, so this is a little bit tricky
- newEntry -> Next = NULL;
- if (Anterior)
- Anterior -> Next = newEntry;
-
- Anterior = newEntry;
-
- if (newHead.TagTypes == NULL)
- newHead.TagTypes = newEntry;
- }
-
- ctx ->chunks[loc] = _cmsSubAllocDup(ctx->MemPool, &newHead, sizeof(_cmsTagTypePluginChunkType));
-}
-
-
-void _cmsAllocTagTypePluginChunk(struct _cmsContext_struct* ctx,
- const struct _cmsContext_struct* src)
-{
- if (src != NULL) {
-
- // Duplicate the LIST
- DupTagTypeList(ctx, src, TagTypePlugin);
- }
- else {
- static _cmsTagTypePluginChunkType TagTypePluginChunk = { NULL };
- ctx ->chunks[TagTypePlugin] = _cmsSubAllocDup(ctx ->MemPool, &TagTypePluginChunk, sizeof(_cmsTagTypePluginChunkType));
- }
-}
-
-void _cmsAllocMPETypePluginChunk(struct _cmsContext_struct* ctx,
- const struct _cmsContext_struct* src)
-{
- if (src != NULL) {
-
- // Duplicate the LIST
- DupTagTypeList(ctx, src, MPEPlugin);
- }
- else {
- static _cmsTagTypePluginChunkType TagTypePluginChunk = { NULL };
- ctx ->chunks[MPEPlugin] = _cmsSubAllocDup(ctx ->MemPool, &TagTypePluginChunk, sizeof(_cmsTagTypePluginChunkType));
- }
-
-}
-
-
-// Both kind of plug-ins share same structure
-cmsBool _cmsRegisterTagTypePlugin(cmsContext id, cmsPluginBase* Data)
-{
- return RegisterTypesPlugin(id, Data, TagTypePlugin);
-}
-
-cmsBool _cmsRegisterMultiProcessElementPlugin(cmsContext id, cmsPluginBase* Data)
-{
- return RegisterTypesPlugin(id, Data,MPEPlugin);
-}
-
-
-// Wrapper for tag types
-cmsTagTypeHandler* _cmsGetTagTypeHandler(cmsContext ContextID, cmsTagTypeSignature sig)
-{
- _cmsTagTypePluginChunkType* ctx = ( _cmsTagTypePluginChunkType*) _cmsContextGetClientChunk(ContextID, TagTypePlugin);
-
- return GetHandler(sig, ctx->TagTypes, (_cmsTagTypeLinkedList*) SupportedTagTypes);
-}
-
-// ********************************************************************************
-// Tag support main routines
-// ********************************************************************************
-
-typedef struct _cmsTagLinkedList_st {
-
- cmsTagSignature Signature;
- cmsTagDescriptor Descriptor;
- struct _cmsTagLinkedList_st* Next;
-
-} _cmsTagLinkedList;
-
-// This is the list of built-in tags. The data of this list can be modified by plug-ins
-static _cmsTagLinkedList SupportedTags[] = {
-
- { cmsSigAToB0Tag, { 1, 3, { cmsSigLut16Type, cmsSigLutAtoBType, cmsSigLut8Type}, DecideLUTtypeA2B}, &SupportedTags[1]},
- { cmsSigAToB1Tag, { 1, 3, { cmsSigLut16Type, cmsSigLutAtoBType, cmsSigLut8Type}, DecideLUTtypeA2B}, &SupportedTags[2]},
- { cmsSigAToB2Tag, { 1, 3, { cmsSigLut16Type, cmsSigLutAtoBType, cmsSigLut8Type}, DecideLUTtypeA2B}, &SupportedTags[3]},
- { cmsSigBToA0Tag, { 1, 3, { cmsSigLut16Type, cmsSigLutBtoAType, cmsSigLut8Type}, DecideLUTtypeB2A}, &SupportedTags[4]},
- { cmsSigBToA1Tag, { 1, 3, { cmsSigLut16Type, cmsSigLutBtoAType, cmsSigLut8Type}, DecideLUTtypeB2A}, &SupportedTags[5]},
- { cmsSigBToA2Tag, { 1, 3, { cmsSigLut16Type, cmsSigLutBtoAType, cmsSigLut8Type}, DecideLUTtypeB2A}, &SupportedTags[6]},
-
- // Allow corbis and its broken XYZ type
- { cmsSigRedColorantTag, { 1, 2, { cmsSigXYZType, cmsCorbisBrokenXYZtype }, DecideXYZtype}, &SupportedTags[7]},
- { cmsSigGreenColorantTag, { 1, 2, { cmsSigXYZType, cmsCorbisBrokenXYZtype }, DecideXYZtype}, &SupportedTags[8]},
- { cmsSigBlueColorantTag, { 1, 2, { cmsSigXYZType, cmsCorbisBrokenXYZtype }, DecideXYZtype}, &SupportedTags[9]},
-
- { cmsSigRedTRCTag, { 1, 3, { cmsSigCurveType, cmsSigParametricCurveType, cmsMonacoBrokenCurveType }, DecideCurveType}, &SupportedTags[10]},
- { cmsSigGreenTRCTag, { 1, 3, { cmsSigCurveType, cmsSigParametricCurveType, cmsMonacoBrokenCurveType }, DecideCurveType}, &SupportedTags[11]},
- { cmsSigBlueTRCTag, { 1, 3, { cmsSigCurveType, cmsSigParametricCurveType, cmsMonacoBrokenCurveType }, DecideCurveType}, &SupportedTags[12]},
-
- { cmsSigCalibrationDateTimeTag, { 1, 1, { cmsSigDateTimeType }, NULL}, &SupportedTags[13]},
- { cmsSigCharTargetTag, { 1, 1, { cmsSigTextType }, NULL}, &SupportedTags[14]},
-
- { cmsSigChromaticAdaptationTag, { 9, 1, { cmsSigS15Fixed16ArrayType }, NULL}, &SupportedTags[15]},
- { cmsSigChromaticityTag, { 1, 1, { cmsSigChromaticityType }, NULL}, &SupportedTags[16]},
- { cmsSigColorantOrderTag, { 1, 1, { cmsSigColorantOrderType }, NULL}, &SupportedTags[17]},
- { cmsSigColorantTableTag, { 1, 1, { cmsSigColorantTableType }, NULL}, &SupportedTags[18]},
- { cmsSigColorantTableOutTag, { 1, 1, { cmsSigColorantTableType }, NULL}, &SupportedTags[19]},
-
- { cmsSigCopyrightTag, { 1, 3, { cmsSigTextType, cmsSigMultiLocalizedUnicodeType, cmsSigTextDescriptionType}, DecideTextType}, &SupportedTags[20]},
- { cmsSigDateTimeTag, { 1, 1, { cmsSigDateTimeType }, NULL}, &SupportedTags[21]},
-
- { cmsSigDeviceMfgDescTag, { 1, 3, { cmsSigTextDescriptionType, cmsSigMultiLocalizedUnicodeType, cmsSigTextType}, DecideTextDescType}, &SupportedTags[22]},
- { cmsSigDeviceModelDescTag, { 1, 3, { cmsSigTextDescriptionType, cmsSigMultiLocalizedUnicodeType, cmsSigTextType}, DecideTextDescType}, &SupportedTags[23]},
-
- { cmsSigGamutTag, { 1, 3, { cmsSigLut16Type, cmsSigLutBtoAType, cmsSigLut8Type }, DecideLUTtypeB2A}, &SupportedTags[24]},
-
- { cmsSigGrayTRCTag, { 1, 2, { cmsSigCurveType, cmsSigParametricCurveType }, DecideCurveType}, &SupportedTags[25]},
- { cmsSigLuminanceTag, { 1, 1, { cmsSigXYZType }, NULL}, &SupportedTags[26]},
-
- { cmsSigMediaBlackPointTag, { 1, 2, { cmsSigXYZType, cmsCorbisBrokenXYZtype }, NULL}, &SupportedTags[27]},
- { cmsSigMediaWhitePointTag, { 1, 2, { cmsSigXYZType, cmsCorbisBrokenXYZtype }, NULL}, &SupportedTags[28]},
-
- { cmsSigNamedColor2Tag, { 1, 1, { cmsSigNamedColor2Type }, NULL}, &SupportedTags[29]},
-
- { cmsSigPreview0Tag, { 1, 3, { cmsSigLut16Type, cmsSigLutBtoAType, cmsSigLut8Type }, DecideLUTtypeB2A}, &SupportedTags[30]},
- { cmsSigPreview1Tag, { 1, 3, { cmsSigLut16Type, cmsSigLutBtoAType, cmsSigLut8Type }, DecideLUTtypeB2A}, &SupportedTags[31]},
- { cmsSigPreview2Tag, { 1, 3, { cmsSigLut16Type, cmsSigLutBtoAType, cmsSigLut8Type }, DecideLUTtypeB2A}, &SupportedTags[32]},
-
- { cmsSigProfileDescriptionTag, { 1, 3, { cmsSigTextDescriptionType, cmsSigMultiLocalizedUnicodeType, cmsSigTextType}, DecideTextDescType}, &SupportedTags[33]},
- { cmsSigProfileSequenceDescTag, { 1, 1, { cmsSigProfileSequenceDescType }, NULL}, &SupportedTags[34]},
- { cmsSigTechnologyTag, { 1, 1, { cmsSigSignatureType }, NULL}, &SupportedTags[35]},
-
- { cmsSigColorimetricIntentImageStateTag, { 1, 1, { cmsSigSignatureType }, NULL}, &SupportedTags[36]},
- { cmsSigPerceptualRenderingIntentGamutTag, { 1, 1, { cmsSigSignatureType }, NULL}, &SupportedTags[37]},
- { cmsSigSaturationRenderingIntentGamutTag, { 1, 1, { cmsSigSignatureType }, NULL}, &SupportedTags[38]},
-
- { cmsSigMeasurementTag, { 1, 1, { cmsSigMeasurementType }, NULL}, &SupportedTags[39]},
-
- { cmsSigPs2CRD0Tag, { 1, 1, { cmsSigDataType }, NULL}, &SupportedTags[40]},
- { cmsSigPs2CRD1Tag, { 1, 1, { cmsSigDataType }, NULL}, &SupportedTags[41]},
- { cmsSigPs2CRD2Tag, { 1, 1, { cmsSigDataType }, NULL}, &SupportedTags[42]},
- { cmsSigPs2CRD3Tag, { 1, 1, { cmsSigDataType }, NULL}, &SupportedTags[43]},
- { cmsSigPs2CSATag, { 1, 1, { cmsSigDataType }, NULL}, &SupportedTags[44]},
- { cmsSigPs2RenderingIntentTag, { 1, 1, { cmsSigDataType }, NULL}, &SupportedTags[45]},
-
- { cmsSigViewingCondDescTag, { 1, 3, { cmsSigTextDescriptionType, cmsSigMultiLocalizedUnicodeType, cmsSigTextType}, DecideTextDescType}, &SupportedTags[46]},
-
- { cmsSigUcrBgTag, { 1, 1, { cmsSigUcrBgType}, NULL}, &SupportedTags[47]},
- { cmsSigCrdInfoTag, { 1, 1, { cmsSigCrdInfoType}, NULL}, &SupportedTags[48]},
-
- { cmsSigDToB0Tag, { 1, 1, { cmsSigMultiProcessElementType}, NULL}, &SupportedTags[49]},
- { cmsSigDToB1Tag, { 1, 1, { cmsSigMultiProcessElementType}, NULL}, &SupportedTags[50]},
- { cmsSigDToB2Tag, { 1, 1, { cmsSigMultiProcessElementType}, NULL}, &SupportedTags[51]},
- { cmsSigDToB3Tag, { 1, 1, { cmsSigMultiProcessElementType}, NULL}, &SupportedTags[52]},
- { cmsSigBToD0Tag, { 1, 1, { cmsSigMultiProcessElementType}, NULL}, &SupportedTags[53]},
- { cmsSigBToD1Tag, { 1, 1, { cmsSigMultiProcessElementType}, NULL}, &SupportedTags[54]},
- { cmsSigBToD2Tag, { 1, 1, { cmsSigMultiProcessElementType}, NULL}, &SupportedTags[55]},
- { cmsSigBToD3Tag, { 1, 1, { cmsSigMultiProcessElementType}, NULL}, &SupportedTags[56]},
-
- { cmsSigScreeningDescTag, { 1, 1, { cmsSigTextDescriptionType }, NULL}, &SupportedTags[57]},
- { cmsSigViewingConditionsTag, { 1, 1, { cmsSigViewingConditionsType }, NULL}, &SupportedTags[58]},
-
- { cmsSigScreeningTag, { 1, 1, { cmsSigScreeningType}, NULL }, &SupportedTags[59]},
- { cmsSigVcgtTag, { 1, 1, { cmsSigVcgtType}, NULL }, &SupportedTags[60]},
- { cmsSigMetaTag, { 1, 1, { cmsSigDictType}, NULL }, &SupportedTags[61]},
- { cmsSigProfileSequenceIdTag, { 1, 1, { cmsSigProfileSequenceIdType}, NULL }, &SupportedTags[62]},
-
- { cmsSigProfileDescriptionMLTag,{ 1, 1, { cmsSigMultiLocalizedUnicodeType}, NULL}, &SupportedTags[63]},
- { cmsSigcicpTag, { 1, 1, { cmsSigcicpType}, NULL }, &SupportedTags[64]},
-
- { cmsSigArgyllArtsTag, { 9, 1, { cmsSigS15Fixed16ArrayType}, NULL}, &SupportedTags[65]},
- { cmsSigMHC2Tag, { 1, 1, { cmsSigMHC2Type }, NULL}, NULL}
-
-};
-
-/*
- Not supported Why
- ======================= =========================================
- cmsSigOutputResponseTag ==> WARNING, POSSIBLE PATENT ON THIS SUBJECT!
- cmsSigNamedColorTag ==> Deprecated
- cmsSigDataTag ==> Ancient, unused
- cmsSigDeviceSettingsTag ==> Deprecated, useless
-*/
-
-
-_cmsTagPluginChunkType _cmsTagPluginChunk = { NULL };
-
-
-// Duplicates the zone of memory used by the plug-in in the new context
-static
-void DupTagList(struct _cmsContext_struct* ctx,
- const struct _cmsContext_struct* src)
-{
- _cmsTagPluginChunkType newHead = { NULL };
- _cmsTagLinkedList* entry;
- _cmsTagLinkedList* Anterior = NULL;
- _cmsTagPluginChunkType* head = (_cmsTagPluginChunkType*) src->chunks[TagPlugin];
-
- // Walk the list copying all nodes
- for (entry = head->Tag;
- entry != NULL;
- entry = entry ->Next) {
-
- _cmsTagLinkedList *newEntry = ( _cmsTagLinkedList *) _cmsSubAllocDup(ctx ->MemPool, entry, sizeof(_cmsTagLinkedList));
-
- if (newEntry == NULL)
- return;
-
- // We want to keep the linked list order, so this is a little bit tricky
- newEntry -> Next = NULL;
- if (Anterior)
- Anterior -> Next = newEntry;
-
- Anterior = newEntry;
-
- if (newHead.Tag == NULL)
- newHead.Tag = newEntry;
- }
-
- ctx ->chunks[TagPlugin] = _cmsSubAllocDup(ctx->MemPool, &newHead, sizeof(_cmsTagPluginChunkType));
-}
-
-void _cmsAllocTagPluginChunk(struct _cmsContext_struct* ctx,
- const struct _cmsContext_struct* src)
-{
- if (src != NULL) {
-
- DupTagList(ctx, src);
- }
- else {
- static _cmsTagPluginChunkType TagPluginChunk = { NULL };
- ctx ->chunks[TagPlugin] = _cmsSubAllocDup(ctx ->MemPool, &TagPluginChunk, sizeof(_cmsTagPluginChunkType));
- }
-
-}
-
-cmsBool _cmsRegisterTagPlugin(cmsContext id, cmsPluginBase* Data)
-{
- cmsPluginTag* Plugin = (cmsPluginTag*) Data;
- _cmsTagLinkedList *pt;
- _cmsTagPluginChunkType* TagPluginChunk = ( _cmsTagPluginChunkType*) _cmsContextGetClientChunk(id, TagPlugin);
-
- if (Data == NULL) {
-
- TagPluginChunk->Tag = NULL;
- return TRUE;
- }
-
- pt = (_cmsTagLinkedList*) _cmsPluginMalloc(id, sizeof(_cmsTagLinkedList));
- if (pt == NULL) return FALSE;
-
- pt ->Signature = Plugin ->Signature;
- pt ->Descriptor = Plugin ->Descriptor;
- pt ->Next = TagPluginChunk ->Tag;
-
- TagPluginChunk ->Tag = pt;
-
- return TRUE;
-}
-
-// Return a descriptor for a given tag or NULL
-cmsTagDescriptor* _cmsGetTagDescriptor(cmsContext ContextID, cmsTagSignature sig)
-{
- _cmsTagLinkedList* pt;
- _cmsTagPluginChunkType* TagPluginChunk = ( _cmsTagPluginChunkType*) _cmsContextGetClientChunk(ContextID, TagPlugin);
-
- for (pt = TagPluginChunk->Tag;
- pt != NULL;
- pt = pt ->Next) {
-
- if (sig == pt -> Signature) return &pt ->Descriptor;
- }
-
- for (pt = SupportedTags;
- pt != NULL;
- pt = pt ->Next) {
-
- if (sig == pt -> Signature) return &pt ->Descriptor;
- }
-
- return NULL;
-}
-
diff --git a/contrib/libs/lcms2/src/cmsvirt.c b/contrib/libs/lcms2/src/cmsvirt.c
deleted file mode 100644
index 3d662b2cc6..0000000000
--- a/contrib/libs/lcms2/src/cmsvirt.c
+++ /dev/null
@@ -1,1341 +0,0 @@
-//---------------------------------------------------------------------------------
-//
-// Little Color Management System
-// Copyright (c) 1998-2023 Marti Maria Saguer
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//---------------------------------------------------------------------------------
-//
-
-#include "lcms2_internal.h"
-
-// Virtual (built-in) profiles
-// -----------------------------------------------------------------------------------
-
-static
-cmsBool SetTextTags(cmsHPROFILE hProfile, const wchar_t* Description)
-{
- cmsMLU *DescriptionMLU, *CopyrightMLU;
- cmsBool rc = FALSE;
- cmsContext ContextID = cmsGetProfileContextID(hProfile);
-
- DescriptionMLU = cmsMLUalloc(ContextID, 1);
- CopyrightMLU = cmsMLUalloc(ContextID, 1);
-
- if (DescriptionMLU == NULL || CopyrightMLU == NULL) goto Error;
-
- if (!cmsMLUsetWide(DescriptionMLU, "en", "US", Description)) goto Error;
- if (!cmsMLUsetWide(CopyrightMLU, "en", "US", L"No copyright, use freely")) goto Error;
-
- if (!cmsWriteTag(hProfile, cmsSigProfileDescriptionTag, DescriptionMLU)) goto Error;
- if (!cmsWriteTag(hProfile, cmsSigCopyrightTag, CopyrightMLU)) goto Error;
-
- rc = TRUE;
-
-Error:
-
- if (DescriptionMLU)
- cmsMLUfree(DescriptionMLU);
- if (CopyrightMLU)
- cmsMLUfree(CopyrightMLU);
- return rc;
-}
-
-
-static
-cmsBool SetSeqDescTag(cmsHPROFILE hProfile, const char* Model)
-{
- cmsBool rc = FALSE;
- cmsContext ContextID = cmsGetProfileContextID(hProfile);
- cmsSEQ* Seq = cmsAllocProfileSequenceDescription(ContextID, 1);
-
- if (Seq == NULL) return FALSE;
-
- Seq->seq[0].deviceMfg = (cmsSignature) 0;
- Seq->seq[0].deviceModel = (cmsSignature) 0;
-
-#ifdef CMS_DONT_USE_INT64
- Seq->seq[0].attributes[0] = 0;
- Seq->seq[0].attributes[1] = 0;
-#else
- Seq->seq[0].attributes = 0;
-#endif
-
- Seq->seq[0].technology = (cmsTechnologySignature) 0;
-
- cmsMLUsetASCII( Seq->seq[0].Manufacturer, cmsNoLanguage, cmsNoCountry, "Little CMS");
- cmsMLUsetASCII( Seq->seq[0].Model, cmsNoLanguage, cmsNoCountry, Model);
-
- if (!_cmsWriteProfileSequence(hProfile, Seq)) goto Error;
-
- rc = TRUE;
-
-Error:
- if (Seq)
- cmsFreeProfileSequenceDescription(Seq);
-
- return rc;
-}
-
-
-
-// This function creates a profile based on White point, primaries and
-// transfer functions.
-cmsHPROFILE CMSEXPORT cmsCreateRGBProfileTHR(cmsContext ContextID,
- const cmsCIExyY* WhitePoint,
- const cmsCIExyYTRIPLE* Primaries,
- cmsToneCurve* const TransferFunction[3])
-{
- cmsHPROFILE hICC;
- cmsMAT3 MColorants;
- cmsCIEXYZTRIPLE Colorants;
- cmsCIExyY MaxWhite;
- cmsMAT3 CHAD;
- cmsCIEXYZ WhitePointXYZ;
-
- hICC = cmsCreateProfilePlaceholder(ContextID);
- if (!hICC) // can't allocate
- return NULL;
-
- cmsSetProfileVersion(hICC, 4.4);
-
- cmsSetDeviceClass(hICC, cmsSigDisplayClass);
- cmsSetColorSpace(hICC, cmsSigRgbData);
- cmsSetPCS(hICC, cmsSigXYZData);
-
- cmsSetHeaderRenderingIntent(hICC, INTENT_PERCEPTUAL);
-
-
- // Implement profile using following tags:
- //
- // 1 cmsSigProfileDescriptionTag
- // 2 cmsSigMediaWhitePointTag
- // 3 cmsSigRedColorantTag
- // 4 cmsSigGreenColorantTag
- // 5 cmsSigBlueColorantTag
- // 6 cmsSigRedTRCTag
- // 7 cmsSigGreenTRCTag
- // 8 cmsSigBlueTRCTag
- // 9 Chromatic adaptation Tag
- // This conforms a standard RGB DisplayProfile as says ICC, and then I add (As per addendum II)
- // 10 cmsSigChromaticityTag
-
-
- if (!SetTextTags(hICC, L"RGB built-in")) goto Error;
-
- if (WhitePoint) {
-
- if (!cmsWriteTag(hICC, cmsSigMediaWhitePointTag, cmsD50_XYZ())) goto Error;
-
- cmsxyY2XYZ(&WhitePointXYZ, WhitePoint);
- _cmsAdaptationMatrix(&CHAD, NULL, &WhitePointXYZ, cmsD50_XYZ());
-
- // This is a V4 tag, but many CMM does read and understand it no matter which version
- if (!cmsWriteTag(hICC, cmsSigChromaticAdaptationTag, (void*) &CHAD)) goto Error;
- }
-
- if (WhitePoint && Primaries) {
-
- MaxWhite.x = WhitePoint -> x;
- MaxWhite.y = WhitePoint -> y;
- MaxWhite.Y = 1.0;
-
- if (!_cmsBuildRGB2XYZtransferMatrix(&MColorants, &MaxWhite, Primaries)) goto Error;
-
- Colorants.Red.X = MColorants.v[0].n[0];
- Colorants.Red.Y = MColorants.v[1].n[0];
- Colorants.Red.Z = MColorants.v[2].n[0];
-
- Colorants.Green.X = MColorants.v[0].n[1];
- Colorants.Green.Y = MColorants.v[1].n[1];
- Colorants.Green.Z = MColorants.v[2].n[1];
-
- Colorants.Blue.X = MColorants.v[0].n[2];
- Colorants.Blue.Y = MColorants.v[1].n[2];
- Colorants.Blue.Z = MColorants.v[2].n[2];
-
- if (!cmsWriteTag(hICC, cmsSigRedColorantTag, (void*) &Colorants.Red)) goto Error;
- if (!cmsWriteTag(hICC, cmsSigBlueColorantTag, (void*) &Colorants.Blue)) goto Error;
- if (!cmsWriteTag(hICC, cmsSigGreenColorantTag, (void*) &Colorants.Green)) goto Error;
- }
-
-
- if (TransferFunction) {
-
- // Tries to minimize space. Thanks to Richard Hughes for this nice idea
- if (!cmsWriteTag(hICC, cmsSigRedTRCTag, (void*) TransferFunction[0])) goto Error;
-
- if (TransferFunction[1] == TransferFunction[0]) {
-
- if (!cmsLinkTag (hICC, cmsSigGreenTRCTag, cmsSigRedTRCTag)) goto Error;
-
- } else {
-
- if (!cmsWriteTag(hICC, cmsSigGreenTRCTag, (void*) TransferFunction[1])) goto Error;
- }
-
- if (TransferFunction[2] == TransferFunction[0]) {
-
- if (!cmsLinkTag (hICC, cmsSigBlueTRCTag, cmsSigRedTRCTag)) goto Error;
-
- } else {
-
- if (!cmsWriteTag(hICC, cmsSigBlueTRCTag, (void*) TransferFunction[2])) goto Error;
- }
- }
-
- if (Primaries) {
- if (!cmsWriteTag(hICC, cmsSigChromaticityTag, (void*) Primaries)) goto Error;
- }
-
-
- return hICC;
-
-Error:
- if (hICC)
- cmsCloseProfile(hICC);
- return NULL;
-}
-
-cmsHPROFILE CMSEXPORT cmsCreateRGBProfile(const cmsCIExyY* WhitePoint,
- const cmsCIExyYTRIPLE* Primaries,
- cmsToneCurve* const TransferFunction[3])
-{
- return cmsCreateRGBProfileTHR(NULL, WhitePoint, Primaries, TransferFunction);
-}
-
-
-
-// This function creates a profile based on White point and transfer function.
-cmsHPROFILE CMSEXPORT cmsCreateGrayProfileTHR(cmsContext ContextID,
- const cmsCIExyY* WhitePoint,
- const cmsToneCurve* TransferFunction)
-{
- cmsHPROFILE hICC;
- cmsCIEXYZ tmp;
-
- hICC = cmsCreateProfilePlaceholder(ContextID);
- if (!hICC) // can't allocate
- return NULL;
-
- cmsSetProfileVersion(hICC, 4.4);
-
- cmsSetDeviceClass(hICC, cmsSigDisplayClass);
- cmsSetColorSpace(hICC, cmsSigGrayData);
- cmsSetPCS(hICC, cmsSigXYZData);
- cmsSetHeaderRenderingIntent(hICC, INTENT_PERCEPTUAL);
-
-
- // Implement profile using following tags:
- //
- // 1 cmsSigProfileDescriptionTag
- // 2 cmsSigMediaWhitePointTag
- // 3 cmsSigGrayTRCTag
-
- // This conforms a standard Gray DisplayProfile
-
- // Fill-in the tags
-
- if (!SetTextTags(hICC, L"gray built-in")) goto Error;
-
-
- if (WhitePoint) {
-
- cmsxyY2XYZ(&tmp, WhitePoint);
- if (!cmsWriteTag(hICC, cmsSigMediaWhitePointTag, (void*) &tmp)) goto Error;
- }
-
- if (TransferFunction) {
-
- if (!cmsWriteTag(hICC, cmsSigGrayTRCTag, (void*) TransferFunction)) goto Error;
- }
-
- return hICC;
-
-Error:
- if (hICC)
- cmsCloseProfile(hICC);
- return NULL;
-}
-
-
-
-cmsHPROFILE CMSEXPORT cmsCreateGrayProfile(const cmsCIExyY* WhitePoint,
- const cmsToneCurve* TransferFunction)
-{
- return cmsCreateGrayProfileTHR(NULL, WhitePoint, TransferFunction);
-}
-
-// This is a devicelink operating in the target colorspace with as many transfer functions as components
-
-cmsHPROFILE CMSEXPORT cmsCreateLinearizationDeviceLinkTHR(cmsContext ContextID,
- cmsColorSpaceSignature ColorSpace,
- cmsToneCurve* const TransferFunctions[])
-{
- cmsHPROFILE hICC;
- cmsPipeline* Pipeline;
- cmsInt32Number nChannels;
-
- hICC = cmsCreateProfilePlaceholder(ContextID);
- if (!hICC)
- return NULL;
-
- cmsSetProfileVersion(hICC, 4.4);
-
- cmsSetDeviceClass(hICC, cmsSigLinkClass);
- cmsSetColorSpace(hICC, ColorSpace);
- cmsSetPCS(hICC, ColorSpace);
-
- cmsSetHeaderRenderingIntent(hICC, INTENT_PERCEPTUAL);
-
- // Set up channels
- nChannels = cmsChannelsOfColorSpace(ColorSpace);
-
- // Creates a Pipeline with prelinearization step only
- Pipeline = cmsPipelineAlloc(ContextID, nChannels, nChannels);
- if (Pipeline == NULL) goto Error;
-
-
- // Copy tables to Pipeline
- if (!cmsPipelineInsertStage(Pipeline, cmsAT_BEGIN, cmsStageAllocToneCurves(ContextID, nChannels, TransferFunctions)))
- goto Error;
-
- // Create tags
- if (!SetTextTags(hICC, L"Linearization built-in")) goto Error;
- if (!cmsWriteTag(hICC, cmsSigAToB0Tag, (void*) Pipeline)) goto Error;
- if (!SetSeqDescTag(hICC, "Linearization built-in")) goto Error;
-
- // Pipeline is already on virtual profile
- cmsPipelineFree(Pipeline);
-
- // Ok, done
- return hICC;
-
-Error:
- cmsPipelineFree(Pipeline);
- if (hICC)
- cmsCloseProfile(hICC);
-
-
- return NULL;
-}
-
-cmsHPROFILE CMSEXPORT cmsCreateLinearizationDeviceLink(cmsColorSpaceSignature ColorSpace,
- cmsToneCurve* const TransferFunctions[])
-{
- return cmsCreateLinearizationDeviceLinkTHR(NULL, ColorSpace, TransferFunctions);
-}
-
-// Ink-limiting algorithm
-//
-// Sum = C + M + Y + K
-// If Sum > InkLimit
-// Ratio= 1 - (Sum - InkLimit) / (C + M + Y)
-// if Ratio <0
-// Ratio=0
-// endif
-// Else
-// Ratio=1
-// endif
-//
-// C = Ratio * C
-// M = Ratio * M
-// Y = Ratio * Y
-// K: Does not change
-
-static
-int InkLimitingSampler(CMSREGISTER const cmsUInt16Number In[], CMSREGISTER cmsUInt16Number Out[], CMSREGISTER void* Cargo)
-{
- cmsFloat64Number InkLimit = *(cmsFloat64Number *) Cargo;
- cmsFloat64Number SumCMY, SumCMYK, Ratio;
-
- InkLimit = (InkLimit * 655.35);
-
- SumCMY = (cmsFloat64Number) In[0] + In[1] + In[2];
- SumCMYK = SumCMY + In[3];
-
- if (SumCMYK > InkLimit) {
-
- Ratio = 1 - ((SumCMYK - InkLimit) / SumCMY);
- if (Ratio < 0)
- Ratio = 0;
- }
- else Ratio = 1;
-
- Out[0] = _cmsQuickSaturateWord(In[0] * Ratio); // C
- Out[1] = _cmsQuickSaturateWord(In[1] * Ratio); // M
- Out[2] = _cmsQuickSaturateWord(In[2] * Ratio); // Y
-
- Out[3] = In[3]; // K (untouched)
-
- return TRUE;
-}
-
-// This is a devicelink operating in CMYK for ink-limiting
-
-cmsHPROFILE CMSEXPORT cmsCreateInkLimitingDeviceLinkTHR(cmsContext ContextID,
- cmsColorSpaceSignature ColorSpace,
- cmsFloat64Number Limit)
-{
- cmsHPROFILE hICC;
- cmsPipeline* LUT;
- cmsStage* CLUT;
- cmsInt32Number nChannels;
-
- if (ColorSpace != cmsSigCmykData) {
- cmsSignalError(ContextID, cmsERROR_COLORSPACE_CHECK, "InkLimiting: Only CMYK currently supported");
- return NULL;
- }
-
- if (Limit < 0.0 || Limit > 400) {
-
- cmsSignalError(ContextID, cmsERROR_RANGE, "InkLimiting: Limit should be between 1..400");
- if (Limit < 1) Limit = 1;
- if (Limit > 400) Limit = 400;
- }
-
- hICC = cmsCreateProfilePlaceholder(ContextID);
- if (!hICC) // can't allocate
- return NULL;
-
- cmsSetProfileVersion(hICC, 4.4);
-
- cmsSetDeviceClass(hICC, cmsSigLinkClass);
- cmsSetColorSpace(hICC, ColorSpace);
- cmsSetPCS(hICC, ColorSpace);
-
- cmsSetHeaderRenderingIntent(hICC, INTENT_PERCEPTUAL);
-
-
- // Creates a Pipeline with 3D grid only
- LUT = cmsPipelineAlloc(ContextID, 4, 4);
- if (LUT == NULL) goto Error;
-
-
- nChannels = cmsChannelsOf(ColorSpace);
-
- CLUT = cmsStageAllocCLut16bit(ContextID, 17, nChannels, nChannels, NULL);
- if (CLUT == NULL) goto Error;
-
- if (!cmsStageSampleCLut16bit(CLUT, InkLimitingSampler, (void*) &Limit, 0)) goto Error;
-
- if (!cmsPipelineInsertStage(LUT, cmsAT_BEGIN, _cmsStageAllocIdentityCurves(ContextID, nChannels)) ||
- !cmsPipelineInsertStage(LUT, cmsAT_END, CLUT) ||
- !cmsPipelineInsertStage(LUT, cmsAT_END, _cmsStageAllocIdentityCurves(ContextID, nChannels)))
- goto Error;
-
- // Create tags
- if (!SetTextTags(hICC, L"ink-limiting built-in")) goto Error;
-
- if (!cmsWriteTag(hICC, cmsSigAToB0Tag, (void*) LUT)) goto Error;
- if (!SetSeqDescTag(hICC, "ink-limiting built-in")) goto Error;
-
- // cmsPipeline is already on virtual profile
- cmsPipelineFree(LUT);
-
- // Ok, done
- return hICC;
-
-Error:
- if (LUT != NULL)
- cmsPipelineFree(LUT);
-
- if (hICC != NULL)
- cmsCloseProfile(hICC);
-
- return NULL;
-}
-
-cmsHPROFILE CMSEXPORT cmsCreateInkLimitingDeviceLink(cmsColorSpaceSignature ColorSpace, cmsFloat64Number Limit)
-{
- return cmsCreateInkLimitingDeviceLinkTHR(NULL, ColorSpace, Limit);
-}
-
-
-// Creates a fake Lab identity.
-cmsHPROFILE CMSEXPORT cmsCreateLab2ProfileTHR(cmsContext ContextID, const cmsCIExyY* WhitePoint)
-{
- cmsHPROFILE hProfile;
- cmsPipeline* LUT = NULL;
-
- hProfile = cmsCreateRGBProfileTHR(ContextID, WhitePoint == NULL ? cmsD50_xyY() : WhitePoint, NULL, NULL);
- if (hProfile == NULL) return NULL;
-
- cmsSetProfileVersion(hProfile, 2.1);
-
- cmsSetDeviceClass(hProfile, cmsSigAbstractClass);
- cmsSetColorSpace(hProfile, cmsSigLabData);
- cmsSetPCS(hProfile, cmsSigLabData);
-
- if (!SetTextTags(hProfile, L"Lab identity built-in")) return NULL;
-
- // An identity LUT is all we need
- LUT = cmsPipelineAlloc(ContextID, 3, 3);
- if (LUT == NULL) goto Error;
-
- if (!cmsPipelineInsertStage(LUT, cmsAT_BEGIN, _cmsStageAllocIdentityCLut(ContextID, 3)))
- goto Error;
-
- if (!cmsWriteTag(hProfile, cmsSigAToB0Tag, LUT)) goto Error;
- cmsPipelineFree(LUT);
-
- return hProfile;
-
-Error:
-
- if (LUT != NULL)
- cmsPipelineFree(LUT);
-
- if (hProfile != NULL)
- cmsCloseProfile(hProfile);
-
- return NULL;
-}
-
-
-cmsHPROFILE CMSEXPORT cmsCreateLab2Profile(const cmsCIExyY* WhitePoint)
-{
- return cmsCreateLab2ProfileTHR(NULL, WhitePoint);
-}
-
-
-// Creates a fake Lab V4 identity.
-cmsHPROFILE CMSEXPORT cmsCreateLab4ProfileTHR(cmsContext ContextID, const cmsCIExyY* WhitePoint)
-{
- cmsHPROFILE hProfile;
- cmsPipeline* LUT = NULL;
-
- hProfile = cmsCreateRGBProfileTHR(ContextID, WhitePoint == NULL ? cmsD50_xyY() : WhitePoint, NULL, NULL);
- if (hProfile == NULL) return NULL;
-
- cmsSetProfileVersion(hProfile, 4.4);
-
- cmsSetDeviceClass(hProfile, cmsSigAbstractClass);
- cmsSetColorSpace(hProfile, cmsSigLabData);
- cmsSetPCS(hProfile, cmsSigLabData);
-
- if (!SetTextTags(hProfile, L"Lab identity built-in")) goto Error;
-
- // An empty LUTs is all we need
- LUT = cmsPipelineAlloc(ContextID, 3, 3);
- if (LUT == NULL) goto Error;
-
- if (!cmsPipelineInsertStage(LUT, cmsAT_BEGIN, _cmsStageAllocIdentityCurves(ContextID, 3)))
- goto Error;
-
- if (!cmsWriteTag(hProfile, cmsSigAToB0Tag, LUT)) goto Error;
- cmsPipelineFree(LUT);
-
- return hProfile;
-
-Error:
-
- if (LUT != NULL)
- cmsPipelineFree(LUT);
-
- if (hProfile != NULL)
- cmsCloseProfile(hProfile);
-
- return NULL;
-}
-
-cmsHPROFILE CMSEXPORT cmsCreateLab4Profile(const cmsCIExyY* WhitePoint)
-{
- return cmsCreateLab4ProfileTHR(NULL, WhitePoint);
-}
-
-
-// Creates a fake XYZ identity
-cmsHPROFILE CMSEXPORT cmsCreateXYZProfileTHR(cmsContext ContextID)
-{
- cmsHPROFILE hProfile;
- cmsPipeline* LUT = NULL;
-
- hProfile = cmsCreateRGBProfileTHR(ContextID, cmsD50_xyY(), NULL, NULL);
- if (hProfile == NULL) return NULL;
-
- cmsSetProfileVersion(hProfile, 4.4);
-
- cmsSetDeviceClass(hProfile, cmsSigAbstractClass);
- cmsSetColorSpace(hProfile, cmsSigXYZData);
- cmsSetPCS(hProfile, cmsSigXYZData);
-
- if (!SetTextTags(hProfile, L"XYZ identity built-in")) goto Error;
-
- // An identity LUT is all we need
- LUT = cmsPipelineAlloc(ContextID, 3, 3);
- if (LUT == NULL) goto Error;
-
- if (!cmsPipelineInsertStage(LUT, cmsAT_BEGIN, _cmsStageAllocIdentityCurves(ContextID, 3)))
- goto Error;
-
- if (!cmsWriteTag(hProfile, cmsSigAToB0Tag, LUT)) goto Error;
- cmsPipelineFree(LUT);
-
- return hProfile;
-
-Error:
-
- if (LUT != NULL)
- cmsPipelineFree(LUT);
-
- if (hProfile != NULL)
- cmsCloseProfile(hProfile);
-
- return NULL;
-}
-
-
-cmsHPROFILE CMSEXPORT cmsCreateXYZProfile(void)
-{
- return cmsCreateXYZProfileTHR(NULL);
-}
-
-
-//sRGB Curves are defined by:
-//
-//If R'sRGB,G'sRGB, B'sRGB < 0.04045
-//
-// R = R'sRGB / 12.92
-// G = G'sRGB / 12.92
-// B = B'sRGB / 12.92
-//
-//
-//else if R'sRGB,G'sRGB, B'sRGB >= 0.04045
-//
-// R = ((R'sRGB + 0.055) / 1.055)^2.4
-// G = ((G'sRGB + 0.055) / 1.055)^2.4
-// B = ((B'sRGB + 0.055) / 1.055)^2.4
-
-static
-cmsToneCurve* Build_sRGBGamma(cmsContext ContextID)
-{
- cmsFloat64Number Parameters[5];
-
- Parameters[0] = 2.4;
- Parameters[1] = 1. / 1.055;
- Parameters[2] = 0.055 / 1.055;
- Parameters[3] = 1. / 12.92;
- Parameters[4] = 0.04045;
-
- return cmsBuildParametricToneCurve(ContextID, 4, Parameters);
-}
-
-// Create the ICC virtual profile for sRGB space
-cmsHPROFILE CMSEXPORT cmsCreate_sRGBProfileTHR(cmsContext ContextID)
-{
- cmsCIExyY D65 = { 0.3127, 0.3290, 1.0 };
- cmsCIExyYTRIPLE Rec709Primaries = {
- {0.6400, 0.3300, 1.0},
- {0.3000, 0.6000, 1.0},
- {0.1500, 0.0600, 1.0}
- };
- cmsToneCurve* Gamma22[3];
- cmsHPROFILE hsRGB;
-
- // cmsWhitePointFromTemp(&D65, 6504);
- Gamma22[0] = Gamma22[1] = Gamma22[2] = Build_sRGBGamma(ContextID);
- if (Gamma22[0] == NULL) return NULL;
-
- hsRGB = cmsCreateRGBProfileTHR(ContextID, &D65, &Rec709Primaries, Gamma22);
- cmsFreeToneCurve(Gamma22[0]);
- if (hsRGB == NULL) return NULL;
-
- if (!SetTextTags(hsRGB, L"sRGB built-in")) {
- cmsCloseProfile(hsRGB);
- return NULL;
- }
-
- return hsRGB;
-}
-
-cmsHPROFILE CMSEXPORT cmsCreate_sRGBProfile(void)
-{
- return cmsCreate_sRGBProfileTHR(NULL);
-}
-
-/**
-* Oklab colorspace profile (experimental)
-*
-* This virtual profile cannot be saved as an ICC file
-*/
-cmsHPROFILE cmsCreate_OkLabProfile(cmsContext ctx)
-{
- cmsStage* XYZPCS = _cmsStageNormalizeFromXyzFloat(ctx);
- cmsStage* PCSXYZ = _cmsStageNormalizeToXyzFloat(ctx);
-
- const double M_D65_D50[] =
- {
- 1.047886, 0.022919, -0.050216,
- 0.029582, 0.990484, -0.017079,
- -0.009252, 0.015073, 0.751678
- };
-
- const double M_D50_D65[] =
- {
- 0.955512609517083, -0.023073214184645, 0.063308961782107,
- -0.028324949364887, 1.009942432477107, 0.021054814890112,
- 0.012328875695483, -0.020535835374141, 1.330713916450354
- };
-
- cmsStage* D65toD50 = cmsStageAllocMatrix(ctx, 3, 3, M_D65_D50, NULL);
- cmsStage* D50toD65 = cmsStageAllocMatrix(ctx, 3, 3, M_D50_D65, NULL);
-
- const double M_D65_LMS[] =
- {
- 0.8189330101, 0.3618667424, -0.1288597137,
- 0.0329845436, 0.9293118715, 0.0361456387,
- 0.0482003018, 0.2643662691, 0.6338517070
- };
-
- const double M_LMS_D65[] =
- {
- 1.227013851103521, -0.557799980651822, 0.281256148966468,
- -0.040580178423281, 1.112256869616830, -0.071676678665601,
- -0.076381284505707, -0.421481978418013, 1.586163220440795
- };
-
- cmsStage* D65toLMS = cmsStageAllocMatrix(ctx, 3, 3, M_D65_LMS, NULL);
- cmsStage* LMStoD65 = cmsStageAllocMatrix(ctx, 3, 3, M_LMS_D65, NULL);
-
- cmsToneCurve* CubeRoot = cmsBuildGamma(ctx, 1.0 / 3.0);
- cmsToneCurve* Cube = cmsBuildGamma(ctx, 3.0);
-
- cmsToneCurve* Roots[3] = { CubeRoot, CubeRoot, CubeRoot };
- cmsToneCurve* Cubes[3] = { Cube, Cube, Cube };
-
- cmsStage* NonLinearityFw = cmsStageAllocToneCurves(ctx, 3, Roots);
- cmsStage* NonLinearityRv = cmsStageAllocToneCurves(ctx, 3, Cubes);
-
- const double M_LMSprime_OkLab[] =
- {
- 0.2104542553, 0.7936177850, -0.0040720468,
- 1.9779984951, -2.4285922050, 0.4505937099,
- 0.0259040371, 0.7827717662, -0.8086757660
- };
-
- const double M_OkLab_LMSprime[] =
- {
- 0.999999998450520, 0.396337792173768, 0.215803758060759,
- 1.000000008881761, -0.105561342323656, -0.063854174771706,
- 1.000000054672411, -0.089484182094966, -1.291485537864092
- };
-
- cmsStage* LMSprime_OkLab = cmsStageAllocMatrix(ctx, 3, 3, M_LMSprime_OkLab, NULL);
- cmsStage* OkLab_LMSprime = cmsStageAllocMatrix(ctx, 3, 3, M_OkLab_LMSprime, NULL);
-
- cmsPipeline* AToB = cmsPipelineAlloc(ctx, 3, 3);
- cmsPipeline* BToA = cmsPipelineAlloc(ctx, 3, 3);
-
- cmsHPROFILE hProfile = cmsCreateProfilePlaceholder(ctx);
-
- cmsSetProfileVersion(hProfile, 4.4);
-
- cmsSetDeviceClass(hProfile, cmsSigColorSpaceClass);
- cmsSetColorSpace(hProfile, cmsSig3colorData);
- cmsSetPCS(hProfile, cmsSigXYZData);
-
- cmsSetHeaderRenderingIntent(hProfile, INTENT_RELATIVE_COLORIMETRIC);
-
- /**
- * Conversion PCS (XYZ/D50) to OkLab
- */
- if (!cmsPipelineInsertStage(BToA, cmsAT_END, PCSXYZ)) goto error;
- if (!cmsPipelineInsertStage(BToA, cmsAT_END, D50toD65)) goto error;
- if (!cmsPipelineInsertStage(BToA, cmsAT_END, D65toLMS)) goto error;
- if (!cmsPipelineInsertStage(BToA, cmsAT_END, NonLinearityFw)) goto error;
- if (!cmsPipelineInsertStage(BToA, cmsAT_END, LMSprime_OkLab)) goto error;
-
- if (!cmsWriteTag(hProfile, cmsSigBToA0Tag, BToA)) goto error;
-
- if (!cmsPipelineInsertStage(AToB, cmsAT_END, OkLab_LMSprime)) goto error;
- if (!cmsPipelineInsertStage(AToB, cmsAT_END, NonLinearityRv)) goto error;
- if (!cmsPipelineInsertStage(AToB, cmsAT_END, LMStoD65)) goto error;
- if (!cmsPipelineInsertStage(AToB, cmsAT_END, D65toD50)) goto error;
- if (!cmsPipelineInsertStage(AToB, cmsAT_END, XYZPCS)) goto error;
-
- if (!cmsWriteTag(hProfile, cmsSigAToB0Tag, AToB)) goto error;
-
- cmsPipelineFree(BToA);
- cmsPipelineFree(AToB);
-
- cmsFreeToneCurve(CubeRoot);
- cmsFreeToneCurve(Cube);
-
- return hProfile;
-
-error:
- cmsPipelineFree(BToA);
- cmsPipelineFree(AToB);
-
- cmsFreeToneCurve(CubeRoot);
- cmsFreeToneCurve(Cube);
- cmsCloseProfile(hProfile);
-
- return NULL;
-
-}
-
-
-typedef struct {
- cmsFloat64Number Brightness;
- cmsFloat64Number Contrast;
- cmsFloat64Number Hue;
- cmsFloat64Number Saturation;
- cmsBool lAdjustWP;
- cmsCIEXYZ WPsrc, WPdest;
-
-} BCHSWADJUSTS, *LPBCHSWADJUSTS;
-
-
-static
-int bchswSampler(CMSREGISTER const cmsUInt16Number In[], CMSREGISTER cmsUInt16Number Out[], CMSREGISTER void* Cargo)
-{
- cmsCIELab LabIn, LabOut;
- cmsCIELCh LChIn, LChOut;
- cmsCIEXYZ XYZ;
- LPBCHSWADJUSTS bchsw = (LPBCHSWADJUSTS) Cargo;
-
-
- cmsLabEncoded2Float(&LabIn, In);
-
-
- cmsLab2LCh(&LChIn, &LabIn);
-
- // Do some adjusts on LCh
-
- LChOut.L = LChIn.L * bchsw ->Contrast + bchsw ->Brightness;
- LChOut.C = LChIn.C + bchsw -> Saturation;
- LChOut.h = LChIn.h + bchsw -> Hue;
-
-
- cmsLCh2Lab(&LabOut, &LChOut);
-
- // Move white point in Lab
- if (bchsw->lAdjustWP) {
- cmsLab2XYZ(&bchsw->WPsrc, &XYZ, &LabOut);
- cmsXYZ2Lab(&bchsw->WPdest, &LabOut, &XYZ);
- }
-
- // Back to encoded
-
- cmsFloat2LabEncoded(Out, &LabOut);
-
- return TRUE;
-}
-
-
-// Creates an abstract profile operating in Lab space for Brightness,
-// contrast, Saturation and white point displacement
-
-cmsHPROFILE CMSEXPORT cmsCreateBCHSWabstractProfileTHR(cmsContext ContextID,
- cmsUInt32Number nLUTPoints,
- cmsFloat64Number Bright,
- cmsFloat64Number Contrast,
- cmsFloat64Number Hue,
- cmsFloat64Number Saturation,
- cmsUInt32Number TempSrc,
- cmsUInt32Number TempDest)
-{
- cmsHPROFILE hICC;
- cmsPipeline* Pipeline;
- BCHSWADJUSTS bchsw;
- cmsCIExyY WhitePnt;
- cmsStage* CLUT;
- cmsUInt32Number Dimensions[MAX_INPUT_DIMENSIONS];
- cmsUInt32Number i;
-
- bchsw.Brightness = Bright;
- bchsw.Contrast = Contrast;
- bchsw.Hue = Hue;
- bchsw.Saturation = Saturation;
- if (TempSrc == TempDest) {
-
- bchsw.lAdjustWP = FALSE;
- }
- else {
- bchsw.lAdjustWP = TRUE;
- cmsWhitePointFromTemp(&WhitePnt, TempSrc);
- cmsxyY2XYZ(&bchsw.WPsrc, &WhitePnt);
- cmsWhitePointFromTemp(&WhitePnt, TempDest);
- cmsxyY2XYZ(&bchsw.WPdest, &WhitePnt);
-
- }
-
- hICC = cmsCreateProfilePlaceholder(ContextID);
- if (!hICC) // can't allocate
- return NULL;
-
- cmsSetDeviceClass(hICC, cmsSigAbstractClass);
- cmsSetColorSpace(hICC, cmsSigLabData);
- cmsSetPCS(hICC, cmsSigLabData);
-
- cmsSetHeaderRenderingIntent(hICC, INTENT_PERCEPTUAL);
-
- // Creates a Pipeline with 3D grid only
- Pipeline = cmsPipelineAlloc(ContextID, 3, 3);
- if (Pipeline == NULL) {
- cmsCloseProfile(hICC);
- return NULL;
- }
-
- for (i=0; i < MAX_INPUT_DIMENSIONS; i++) Dimensions[i] = nLUTPoints;
- CLUT = cmsStageAllocCLut16bitGranular(ContextID, Dimensions, 3, 3, NULL);
- if (CLUT == NULL) goto Error;
-
-
- if (!cmsStageSampleCLut16bit(CLUT, bchswSampler, (void*) &bchsw, 0)) {
-
- // Shouldn't reach here
- goto Error;
- }
-
- if (!cmsPipelineInsertStage(Pipeline, cmsAT_END, CLUT)) {
- goto Error;
- }
-
- // Create tags
- if (!SetTextTags(hICC, L"BCHS built-in")) return NULL;
-
- cmsWriteTag(hICC, cmsSigMediaWhitePointTag, (void*) cmsD50_XYZ());
-
- cmsWriteTag(hICC, cmsSigAToB0Tag, (void*) Pipeline);
-
- // Pipeline is already on virtual profile
- cmsPipelineFree(Pipeline);
-
- // Ok, done
- return hICC;
-
-Error:
- cmsPipelineFree(Pipeline);
- cmsCloseProfile(hICC);
- return NULL;
-}
-
-
-CMSAPI cmsHPROFILE CMSEXPORT cmsCreateBCHSWabstractProfile(cmsUInt32Number nLUTPoints,
- cmsFloat64Number Bright,
- cmsFloat64Number Contrast,
- cmsFloat64Number Hue,
- cmsFloat64Number Saturation,
- cmsUInt32Number TempSrc,
- cmsUInt32Number TempDest)
-{
- return cmsCreateBCHSWabstractProfileTHR(NULL, nLUTPoints, Bright, Contrast, Hue, Saturation, TempSrc, TempDest);
-}
-
-
-// Creates a fake NULL profile. This profile return 1 channel as always 0.
-// Is useful only for gamut checking tricks
-cmsHPROFILE CMSEXPORT cmsCreateNULLProfileTHR(cmsContext ContextID)
-{
- cmsHPROFILE hProfile;
- cmsPipeline* LUT = NULL;
- cmsStage* PostLin;
- cmsStage* OutLin;
- cmsToneCurve* EmptyTab[3];
- cmsUInt16Number Zero[2] = { 0, 0 };
- const cmsFloat64Number PickLstarMatrix[] = { 1, 0, 0 };
-
- hProfile = cmsCreateProfilePlaceholder(ContextID);
- if (!hProfile) // can't allocate
- return NULL;
-
- cmsSetProfileVersion(hProfile, 4.4);
-
- if (!SetTextTags(hProfile, L"NULL profile built-in")) goto Error;
-
-
- cmsSetDeviceClass(hProfile, cmsSigOutputClass);
- cmsSetColorSpace(hProfile, cmsSigGrayData);
- cmsSetPCS(hProfile, cmsSigLabData);
-
- // Create a valid ICC 4 structure
- LUT = cmsPipelineAlloc(ContextID, 3, 1);
- if (LUT == NULL) goto Error;
-
- EmptyTab[0] = EmptyTab[1] = EmptyTab[2] = cmsBuildTabulatedToneCurve16(ContextID, 2, Zero);
- PostLin = cmsStageAllocToneCurves(ContextID, 3, EmptyTab);
- OutLin = cmsStageAllocToneCurves(ContextID, 1, EmptyTab);
- cmsFreeToneCurve(EmptyTab[0]);
-
- if (!cmsPipelineInsertStage(LUT, cmsAT_END, PostLin))
- goto Error;
-
- if (!cmsPipelineInsertStage(LUT, cmsAT_END, cmsStageAllocMatrix(ContextID, 1, 3, PickLstarMatrix, NULL)))
- goto Error;
-
- if (!cmsPipelineInsertStage(LUT, cmsAT_END, OutLin))
- goto Error;
-
- if (!cmsWriteTag(hProfile, cmsSigBToA0Tag, (void*) LUT)) goto Error;
- if (!cmsWriteTag(hProfile, cmsSigMediaWhitePointTag, cmsD50_XYZ())) goto Error;
-
- cmsPipelineFree(LUT);
- return hProfile;
-
-Error:
-
- if (LUT != NULL)
- cmsPipelineFree(LUT);
-
- if (hProfile != NULL)
- cmsCloseProfile(hProfile);
-
- return NULL;
-}
-
-cmsHPROFILE CMSEXPORT cmsCreateNULLProfile(void)
-{
- return cmsCreateNULLProfileTHR(NULL);
-}
-
-
-static
-int IsPCS(cmsColorSpaceSignature ColorSpace)
-{
- return (ColorSpace == cmsSigXYZData ||
- ColorSpace == cmsSigLabData);
-}
-
-
-static
-void FixColorSpaces(cmsHPROFILE hProfile,
- cmsColorSpaceSignature ColorSpace,
- cmsColorSpaceSignature PCS,
- cmsUInt32Number dwFlags)
-{
- if (dwFlags & cmsFLAGS_GUESSDEVICECLASS) {
-
- if (IsPCS(ColorSpace) && IsPCS(PCS)) {
-
- cmsSetDeviceClass(hProfile, cmsSigAbstractClass);
- cmsSetColorSpace(hProfile, ColorSpace);
- cmsSetPCS(hProfile, PCS);
- return;
- }
-
- if (IsPCS(ColorSpace) && !IsPCS(PCS)) {
-
- cmsSetDeviceClass(hProfile, cmsSigOutputClass);
- cmsSetPCS(hProfile, ColorSpace);
- cmsSetColorSpace(hProfile, PCS);
- return;
- }
-
- if (IsPCS(PCS) && !IsPCS(ColorSpace)) {
-
- cmsSetDeviceClass(hProfile, cmsSigInputClass);
- cmsSetColorSpace(hProfile, ColorSpace);
- cmsSetPCS(hProfile, PCS);
- return;
- }
- }
-
- cmsSetDeviceClass(hProfile, cmsSigLinkClass);
- cmsSetColorSpace(hProfile, ColorSpace);
- cmsSetPCS(hProfile, PCS);
-}
-
-
-
-// This function creates a named color profile dumping all the contents of transform to a single profile
-// In this way, LittleCMS may be used to "group" several named color databases into a single profile.
-// It has, however, several minor limitations. PCS is always Lab, which is not very critic since this
-// is the normal PCS for named color profiles.
-static
-cmsHPROFILE CreateNamedColorDevicelink(cmsHTRANSFORM xform)
-{
- _cmsTRANSFORM* v = (_cmsTRANSFORM*) xform;
- cmsHPROFILE hICC = NULL;
- cmsUInt32Number i, nColors;
- cmsNAMEDCOLORLIST *nc2 = NULL, *Original = NULL;
-
- // Create an empty placeholder
- hICC = cmsCreateProfilePlaceholder(v->ContextID);
- if (hICC == NULL) return NULL;
-
- // Critical information
- cmsSetDeviceClass(hICC, cmsSigNamedColorClass);
- cmsSetColorSpace(hICC, v ->ExitColorSpace);
- cmsSetPCS(hICC, cmsSigLabData);
-
- // Tag profile with information
- if (!SetTextTags(hICC, L"Named color devicelink")) goto Error;
-
- Original = cmsGetNamedColorList(xform);
- if (Original == NULL) goto Error;
-
- nColors = cmsNamedColorCount(Original);
- nc2 = cmsDupNamedColorList(Original);
- if (nc2 == NULL) goto Error;
-
- // Colorant count now depends on the output space
- nc2 ->ColorantCount = cmsPipelineOutputChannels(v ->Lut);
-
- // Make sure we have proper formatters
- cmsChangeBuffersFormat(xform, TYPE_NAMED_COLOR_INDEX,
- FLOAT_SH(0) | COLORSPACE_SH(_cmsLCMScolorSpace(v ->ExitColorSpace))
- | BYTES_SH(2) | CHANNELS_SH(cmsChannelsOfColorSpace(v ->ExitColorSpace)));
-
- // Apply the transfor to colorants.
- for (i=0; i < nColors; i++) {
- cmsDoTransform(xform, &i, nc2 ->List[i].DeviceColorant, 1);
- }
-
- if (!cmsWriteTag(hICC, cmsSigNamedColor2Tag, (void*) nc2)) goto Error;
- cmsFreeNamedColorList(nc2);
-
- return hICC;
-
-Error:
- if (hICC != NULL) cmsCloseProfile(hICC);
- return NULL;
-}
-
-
-// This structure holds information about which MPU can be stored on a profile based on the version
-
-typedef struct {
- cmsBool IsV4; // Is a V4 tag?
- cmsTagSignature RequiredTag; // Set to 0 for both types
- cmsTagTypeSignature LutType; // The LUT type
- int nTypes; // Number of types (up to 5)
- cmsStageSignature MpeTypes[5]; // 5 is the maximum number
-
-} cmsAllowedLUT;
-
-#define cmsSig0 ((cmsTagSignature) 0)
-
-static const cmsAllowedLUT AllowedLUTTypes[] = {
-
- { FALSE, cmsSig0, cmsSigLut16Type, 4, { cmsSigMatrixElemType, cmsSigCurveSetElemType, cmsSigCLutElemType, cmsSigCurveSetElemType } },
- { FALSE, cmsSig0, cmsSigLut16Type, 3, { cmsSigCurveSetElemType, cmsSigCLutElemType, cmsSigCurveSetElemType } },
- { FALSE, cmsSig0, cmsSigLut16Type, 2, { cmsSigCurveSetElemType, cmsSigCLutElemType } },
- { TRUE, cmsSig0, cmsSigLutAtoBType, 1, { cmsSigCurveSetElemType } },
- { TRUE , cmsSigAToB0Tag, cmsSigLutAtoBType, 3, { cmsSigCurveSetElemType, cmsSigMatrixElemType, cmsSigCurveSetElemType } },
- { TRUE , cmsSigAToB0Tag, cmsSigLutAtoBType, 3, { cmsSigCurveSetElemType, cmsSigCLutElemType, cmsSigCurveSetElemType } },
- { TRUE , cmsSigAToB0Tag, cmsSigLutAtoBType, 5, { cmsSigCurveSetElemType, cmsSigCLutElemType, cmsSigCurveSetElemType, cmsSigMatrixElemType, cmsSigCurveSetElemType }},
- { TRUE , cmsSigBToA0Tag, cmsSigLutBtoAType, 1, { cmsSigCurveSetElemType }},
- { TRUE , cmsSigBToA0Tag, cmsSigLutBtoAType, 3, { cmsSigCurveSetElemType, cmsSigMatrixElemType, cmsSigCurveSetElemType }},
- { TRUE , cmsSigBToA0Tag, cmsSigLutBtoAType, 3, { cmsSigCurveSetElemType, cmsSigCLutElemType, cmsSigCurveSetElemType }},
- { TRUE , cmsSigBToA0Tag, cmsSigLutBtoAType, 5, { cmsSigCurveSetElemType, cmsSigMatrixElemType, cmsSigCurveSetElemType, cmsSigCLutElemType, cmsSigCurveSetElemType }}
-};
-
-#define SIZE_OF_ALLOWED_LUT (sizeof(AllowedLUTTypes)/sizeof(cmsAllowedLUT))
-
-// Check a single entry
-static
-cmsBool CheckOne(const cmsAllowedLUT* Tab, const cmsPipeline* Lut)
-{
- cmsStage* mpe;
- int n;
-
- for (n=0, mpe = Lut ->Elements; mpe != NULL; mpe = mpe ->Next, n++) {
-
- if (n >= Tab ->nTypes) return FALSE;
- if (cmsStageType(mpe) != Tab ->MpeTypes[n]) return FALSE;
- }
-
- return (n == Tab ->nTypes);
-}
-
-
-static
-const cmsAllowedLUT* FindCombination(const cmsPipeline* Lut, cmsBool IsV4, cmsTagSignature DestinationTag)
-{
- cmsUInt32Number n;
-
- for (n=0; n < SIZE_OF_ALLOWED_LUT; n++) {
-
- const cmsAllowedLUT* Tab = AllowedLUTTypes + n;
-
- if (IsV4 ^ Tab -> IsV4) continue;
- if ((Tab ->RequiredTag != 0) && (Tab ->RequiredTag != DestinationTag)) continue;
-
- if (CheckOne(Tab, Lut)) return Tab;
- }
-
- return NULL;
-}
-
-
-// Does convert a transform into a device link profile
-cmsHPROFILE CMSEXPORT cmsTransform2DeviceLink(cmsHTRANSFORM hTransform, cmsFloat64Number Version, cmsUInt32Number dwFlags)
-{
- cmsHPROFILE hProfile = NULL;
- cmsUInt32Number FrmIn, FrmOut;
- cmsInt32Number ChansIn, ChansOut;
- int ColorSpaceBitsIn, ColorSpaceBitsOut;
- _cmsTRANSFORM* xform = (_cmsTRANSFORM*) hTransform;
- cmsPipeline* LUT = NULL;
- cmsStage* mpe;
- cmsContext ContextID = cmsGetTransformContextID(hTransform);
- const cmsAllowedLUT* AllowedLUT;
- cmsTagSignature DestinationTag;
- cmsProfileClassSignature deviceClass;
-
- _cmsAssert(hTransform != NULL);
-
- // Check if the pipeline holding is valid
- if (xform -> Lut == NULL) return NULL;
-
- // Get the first mpe to check for named color
- mpe = cmsPipelineGetPtrToFirstStage(xform ->Lut);
-
- // Check if is a named color transform
- if (mpe != NULL) {
-
- if (cmsStageType(mpe) == cmsSigNamedColorElemType) {
- return CreateNamedColorDevicelink(hTransform);
- }
- }
-
- // First thing to do is to get a copy of the transformation
- LUT = cmsPipelineDup(xform ->Lut);
- if (LUT == NULL) return NULL;
-
- // Time to fix the Lab2/Lab4 issue.
- if ((xform ->EntryColorSpace == cmsSigLabData) && (Version < 4.0)) {
-
- if (!cmsPipelineInsertStage(LUT, cmsAT_BEGIN, _cmsStageAllocLabV2ToV4curves(ContextID)))
- goto Error;
- }
-
- // On the output side too. Note that due to V2/V4 PCS encoding on lab we cannot fix white misalignments
- if ((xform ->ExitColorSpace) == cmsSigLabData && (Version < 4.0)) {
-
- dwFlags |= cmsFLAGS_NOWHITEONWHITEFIXUP;
- if (!cmsPipelineInsertStage(LUT, cmsAT_END, _cmsStageAllocLabV4ToV2(ContextID)))
- goto Error;
- }
-
-
- hProfile = cmsCreateProfilePlaceholder(ContextID);
- if (!hProfile) goto Error; // can't allocate
-
- cmsSetProfileVersion(hProfile, Version);
-
- FixColorSpaces(hProfile, xform -> EntryColorSpace, xform -> ExitColorSpace, dwFlags);
-
- // Optimize the LUT and precalculate a devicelink
-
- ChansIn = cmsChannelsOfColorSpace(xform -> EntryColorSpace);
- ChansOut = cmsChannelsOfColorSpace(xform -> ExitColorSpace);
-
- ColorSpaceBitsIn = _cmsLCMScolorSpace(xform -> EntryColorSpace);
- ColorSpaceBitsOut = _cmsLCMScolorSpace(xform -> ExitColorSpace);
-
- FrmIn = COLORSPACE_SH(ColorSpaceBitsIn) | CHANNELS_SH(ChansIn)|BYTES_SH(2);
- FrmOut = COLORSPACE_SH(ColorSpaceBitsOut) | CHANNELS_SH(ChansOut)|BYTES_SH(2);
-
- deviceClass = cmsGetDeviceClass(hProfile);
-
- if (deviceClass == cmsSigOutputClass)
- DestinationTag = cmsSigBToA0Tag;
- else
- DestinationTag = cmsSigAToB0Tag;
-
- // Check if the profile/version can store the result
- if (dwFlags & cmsFLAGS_FORCE_CLUT)
- AllowedLUT = NULL;
- else
- AllowedLUT = FindCombination(LUT, Version >= 4.0, DestinationTag);
-
- if (AllowedLUT == NULL) {
-
- // Try to optimize
- _cmsOptimizePipeline(ContextID, &LUT, xform ->RenderingIntent, &FrmIn, &FrmOut, &dwFlags);
- AllowedLUT = FindCombination(LUT, Version >= 4.0, DestinationTag);
-
- }
-
- // If no way, then force CLUT that for sure can be written
- if (AllowedLUT == NULL) {
-
- cmsStage* FirstStage;
- cmsStage* LastStage;
-
- dwFlags |= cmsFLAGS_FORCE_CLUT;
- _cmsOptimizePipeline(ContextID, &LUT, xform ->RenderingIntent, &FrmIn, &FrmOut, &dwFlags);
-
- // Put identity curves if needed
- FirstStage = cmsPipelineGetPtrToFirstStage(LUT);
- if (FirstStage != NULL && FirstStage ->Type != cmsSigCurveSetElemType)
- if (!cmsPipelineInsertStage(LUT, cmsAT_BEGIN, _cmsStageAllocIdentityCurves(ContextID, ChansIn)))
- goto Error;
-
- LastStage = cmsPipelineGetPtrToLastStage(LUT);
- if (LastStage != NULL && LastStage ->Type != cmsSigCurveSetElemType)
- if (!cmsPipelineInsertStage(LUT, cmsAT_END, _cmsStageAllocIdentityCurves(ContextID, ChansOut)))
- goto Error;
-
- AllowedLUT = FindCombination(LUT, Version >= 4.0, DestinationTag);
- }
-
- // Somethings is wrong...
- if (AllowedLUT == NULL) {
- goto Error;
- }
-
-
- if (dwFlags & cmsFLAGS_8BITS_DEVICELINK)
- cmsPipelineSetSaveAs8bitsFlag(LUT, TRUE);
-
- // Tag profile with information
- if (!SetTextTags(hProfile, L"devicelink")) goto Error;
-
- // Store result
- if (!cmsWriteTag(hProfile, DestinationTag, LUT)) goto Error;
-
-
- if (xform -> InputColorant != NULL) {
- if (!cmsWriteTag(hProfile, cmsSigColorantTableTag, xform->InputColorant)) goto Error;
- }
-
- if (xform -> OutputColorant != NULL) {
- if (!cmsWriteTag(hProfile, cmsSigColorantTableOutTag, xform->OutputColorant)) goto Error;
- }
-
- if ((deviceClass == cmsSigLinkClass) && (xform ->Sequence != NULL)) {
- if (!_cmsWriteProfileSequence(hProfile, xform ->Sequence)) goto Error;
- }
-
- // Set the white point
- if (deviceClass == cmsSigInputClass) {
- if (!cmsWriteTag(hProfile, cmsSigMediaWhitePointTag, &xform ->EntryWhitePoint)) goto Error;
- }
- else {
- if (!cmsWriteTag(hProfile, cmsSigMediaWhitePointTag, &xform ->ExitWhitePoint)) goto Error;
- }
-
-
- // Per 7.2.15 in spec 4.3
- cmsSetHeaderRenderingIntent(hProfile, xform ->RenderingIntent);
-
- cmsPipelineFree(LUT);
- return hProfile;
-
-Error:
- if (LUT != NULL) cmsPipelineFree(LUT);
- cmsCloseProfile(hProfile);
- return NULL;
-}
diff --git a/contrib/libs/lcms2/src/cmswtpnt.c b/contrib/libs/lcms2/src/cmswtpnt.c
deleted file mode 100644
index a73eaa7e36..0000000000
--- a/contrib/libs/lcms2/src/cmswtpnt.c
+++ /dev/null
@@ -1,353 +0,0 @@
-//---------------------------------------------------------------------------------
-//
-// Little Color Management System
-// Copyright (c) 1998-2023 Marti Maria Saguer
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//---------------------------------------------------------------------------------
-//
-
-#include "lcms2_internal.h"
-
-
-// D50 - Widely used
-const cmsCIEXYZ* CMSEXPORT cmsD50_XYZ(void)
-{
- static cmsCIEXYZ D50XYZ = {cmsD50X, cmsD50Y, cmsD50Z};
-
- return &D50XYZ;
-}
-
-const cmsCIExyY* CMSEXPORT cmsD50_xyY(void)
-{
- static cmsCIExyY D50xyY;
-
- cmsXYZ2xyY(&D50xyY, cmsD50_XYZ());
-
- return &D50xyY;
-}
-
-// Obtains WhitePoint from Temperature
-cmsBool CMSEXPORT cmsWhitePointFromTemp(cmsCIExyY* WhitePoint, cmsFloat64Number TempK)
-{
- cmsFloat64Number x, y;
- cmsFloat64Number T, T2, T3;
- // cmsFloat64Number M1, M2;
-
- _cmsAssert(WhitePoint != NULL);
-
- T = TempK;
- T2 = T*T; // Square
- T3 = T2*T; // Cube
-
- // For correlated color temperature (T) between 4000K and 7000K:
-
- if (T >= 4000. && T <= 7000.)
- {
- x = -4.6070*(1E9/T3) + 2.9678*(1E6/T2) + 0.09911*(1E3/T) + 0.244063;
- }
- else
- // or for correlated color temperature (T) between 7000K and 25000K:
-
- if (T > 7000.0 && T <= 25000.0)
- {
- x = -2.0064*(1E9/T3) + 1.9018*(1E6/T2) + 0.24748*(1E3/T) + 0.237040;
- }
- else {
- cmsSignalError(0, cmsERROR_RANGE, "cmsWhitePointFromTemp: invalid temp");
- return FALSE;
- }
-
- // Obtain y(x)
- y = -3.000*(x*x) + 2.870*x - 0.275;
-
- // wave factors (not used, but here for futures extensions)
-
- // M1 = (-1.3515 - 1.7703*x + 5.9114 *y)/(0.0241 + 0.2562*x - 0.7341*y);
- // M2 = (0.0300 - 31.4424*x + 30.0717*y)/(0.0241 + 0.2562*x - 0.7341*y);
-
- WhitePoint -> x = x;
- WhitePoint -> y = y;
- WhitePoint -> Y = 1.0;
-
- return TRUE;
-}
-
-
-
-typedef struct {
-
- cmsFloat64Number mirek; // temp (in microreciprocal kelvin)
- cmsFloat64Number ut; // u coord of intersection w/ blackbody locus
- cmsFloat64Number vt; // v coord of intersection w/ blackbody locus
- cmsFloat64Number tt; // slope of ISOTEMPERATURE. line
-
- } ISOTEMPERATURE;
-
-static const ISOTEMPERATURE isotempdata[] = {
-// {Mirek, Ut, Vt, Tt }
- {0, 0.18006, 0.26352, -0.24341},
- {10, 0.18066, 0.26589, -0.25479},
- {20, 0.18133, 0.26846, -0.26876},
- {30, 0.18208, 0.27119, -0.28539},
- {40, 0.18293, 0.27407, -0.30470},
- {50, 0.18388, 0.27709, -0.32675},
- {60, 0.18494, 0.28021, -0.35156},
- {70, 0.18611, 0.28342, -0.37915},
- {80, 0.18740, 0.28668, -0.40955},
- {90, 0.18880, 0.28997, -0.44278},
- {100, 0.19032, 0.29326, -0.47888},
- {125, 0.19462, 0.30141, -0.58204},
- {150, 0.19962, 0.30921, -0.70471},
- {175, 0.20525, 0.31647, -0.84901},
- {200, 0.21142, 0.32312, -1.0182 },
- {225, 0.21807, 0.32909, -1.2168 },
- {250, 0.22511, 0.33439, -1.4512 },
- {275, 0.23247, 0.33904, -1.7298 },
- {300, 0.24010, 0.34308, -2.0637 },
- {325, 0.24702, 0.34655, -2.4681 },
- {350, 0.25591, 0.34951, -2.9641 },
- {375, 0.26400, 0.35200, -3.5814 },
- {400, 0.27218, 0.35407, -4.3633 },
- {425, 0.28039, 0.35577, -5.3762 },
- {450, 0.28863, 0.35714, -6.7262 },
- {475, 0.29685, 0.35823, -8.5955 },
- {500, 0.30505, 0.35907, -11.324 },
- {525, 0.31320, 0.35968, -15.628 },
- {550, 0.32129, 0.36011, -23.325 },
- {575, 0.32931, 0.36038, -40.770 },
- {600, 0.33724, 0.36051, -116.45 }
-};
-
-#define NISO sizeof(isotempdata)/sizeof(ISOTEMPERATURE)
-
-
-// Robertson's method
-cmsBool CMSEXPORT cmsTempFromWhitePoint(cmsFloat64Number* TempK, const cmsCIExyY* WhitePoint)
-{
- cmsUInt32Number j;
- cmsFloat64Number us,vs;
- cmsFloat64Number uj,vj,tj,di,dj,mi,mj;
- cmsFloat64Number xs, ys;
-
- _cmsAssert(WhitePoint != NULL);
- _cmsAssert(TempK != NULL);
-
- di = mi = 0;
- xs = WhitePoint -> x;
- ys = WhitePoint -> y;
-
- // convert (x,y) to CIE 1960 (u,WhitePoint)
-
- us = (2*xs) / (-xs + 6*ys + 1.5);
- vs = (3*ys) / (-xs + 6*ys + 1.5);
-
-
- for (j=0; j < NISO; j++) {
-
- uj = isotempdata[j].ut;
- vj = isotempdata[j].vt;
- tj = isotempdata[j].tt;
- mj = isotempdata[j].mirek;
-
- dj = ((vs - vj) - tj * (us - uj)) / sqrt(1.0 + tj * tj);
-
- if ((j != 0) && (di/dj < 0.0)) {
-
- // Found a match
- *TempK = 1000000.0 / (mi + (di / (di - dj)) * (mj - mi));
- return TRUE;
- }
-
- di = dj;
- mi = mj;
- }
-
- // Not found
- return FALSE;
-}
-
-
-// Compute chromatic adaptation matrix using Chad as cone matrix
-
-static
-cmsBool ComputeChromaticAdaptation(cmsMAT3* Conversion,
- const cmsCIEXYZ* SourceWhitePoint,
- const cmsCIEXYZ* DestWhitePoint,
- const cmsMAT3* Chad)
-
-{
-
- cmsMAT3 Chad_Inv;
- cmsVEC3 ConeSourceXYZ, ConeSourceRGB;
- cmsVEC3 ConeDestXYZ, ConeDestRGB;
- cmsMAT3 Cone, Tmp;
-
-
- Tmp = *Chad;
- if (!_cmsMAT3inverse(&Tmp, &Chad_Inv)) return FALSE;
-
- _cmsVEC3init(&ConeSourceXYZ, SourceWhitePoint -> X,
- SourceWhitePoint -> Y,
- SourceWhitePoint -> Z);
-
- _cmsVEC3init(&ConeDestXYZ, DestWhitePoint -> X,
- DestWhitePoint -> Y,
- DestWhitePoint -> Z);
-
- _cmsMAT3eval(&ConeSourceRGB, Chad, &ConeSourceXYZ);
- _cmsMAT3eval(&ConeDestRGB, Chad, &ConeDestXYZ);
-
- if ((fabs(ConeSourceRGB.n[0]) < MATRIX_DET_TOLERANCE) ||
- (fabs(ConeSourceRGB.n[1]) < MATRIX_DET_TOLERANCE) ||
- (fabs(ConeSourceRGB.n[2]) < MATRIX_DET_TOLERANCE)) return FALSE;
-
- // Build matrix
- _cmsVEC3init(&Cone.v[0], ConeDestRGB.n[0]/ConeSourceRGB.n[0], 0.0, 0.0);
- _cmsVEC3init(&Cone.v[1], 0.0, ConeDestRGB.n[1]/ConeSourceRGB.n[1], 0.0);
- _cmsVEC3init(&Cone.v[2], 0.0, 0.0, ConeDestRGB.n[2]/ConeSourceRGB.n[2]);
-
- // Normalize
- _cmsMAT3per(&Tmp, &Cone, Chad);
- _cmsMAT3per(Conversion, &Chad_Inv, &Tmp);
-
- return TRUE;
-}
-
-// Returns the final chrmatic adaptation from illuminant FromIll to Illuminant ToIll
-// The cone matrix can be specified in ConeMatrix. If NULL, Bradford is assumed
-cmsBool _cmsAdaptationMatrix(cmsMAT3* r, const cmsMAT3* ConeMatrix, const cmsCIEXYZ* FromIll, const cmsCIEXYZ* ToIll)
-{
- cmsMAT3 LamRigg = {{ // Bradford matrix
- {{ 0.8951, 0.2664, -0.1614 }},
- {{ -0.7502, 1.7135, 0.0367 }},
- {{ 0.0389, -0.0685, 1.0296 }}
- }};
-
- if (ConeMatrix == NULL)
- ConeMatrix = &LamRigg;
-
- return ComputeChromaticAdaptation(r, FromIll, ToIll, ConeMatrix);
-}
-
-// Same as anterior, but assuming D50 destination. White point is given in xyY
-static
-cmsBool _cmsAdaptMatrixToD50(cmsMAT3* r, const cmsCIExyY* SourceWhitePt)
-{
- cmsCIEXYZ Dn;
- cmsMAT3 Bradford;
- cmsMAT3 Tmp;
-
- cmsxyY2XYZ(&Dn, SourceWhitePt);
-
- if (!_cmsAdaptationMatrix(&Bradford, NULL, &Dn, cmsD50_XYZ())) return FALSE;
-
- Tmp = *r;
- _cmsMAT3per(r, &Bradford, &Tmp);
-
- return TRUE;
-}
-
-// Build a White point, primary chromas transfer matrix from RGB to CIE XYZ
-// This is just an approximation, I am not handling all the non-linear
-// aspects of the RGB to XYZ process, and assuming that the gamma correction
-// has transitive property in the transformation chain.
-//
-// the algorithm:
-//
-// - First I build the absolute conversion matrix using
-// primaries in XYZ. This matrix is next inverted
-// - Then I eval the source white point across this matrix
-// obtaining the coefficients of the transformation
-// - Then, I apply these coefficients to the original matrix
-//
-cmsBool _cmsBuildRGB2XYZtransferMatrix(cmsMAT3* r, const cmsCIExyY* WhitePt, const cmsCIExyYTRIPLE* Primrs)
-{
- cmsVEC3 WhitePoint, Coef;
- cmsMAT3 Result, Primaries;
- cmsFloat64Number xn, yn;
- cmsFloat64Number xr, yr;
- cmsFloat64Number xg, yg;
- cmsFloat64Number xb, yb;
-
- xn = WhitePt -> x;
- yn = WhitePt -> y;
- xr = Primrs -> Red.x;
- yr = Primrs -> Red.y;
- xg = Primrs -> Green.x;
- yg = Primrs -> Green.y;
- xb = Primrs -> Blue.x;
- yb = Primrs -> Blue.y;
-
- // Build Primaries matrix
- _cmsVEC3init(&Primaries.v[0], xr, xg, xb);
- _cmsVEC3init(&Primaries.v[1], yr, yg, yb);
- _cmsVEC3init(&Primaries.v[2], (1-xr-yr), (1-xg-yg), (1-xb-yb));
-
-
- // Result = Primaries ^ (-1) inverse matrix
- if (!_cmsMAT3inverse(&Primaries, &Result))
- return FALSE;
-
-
- _cmsVEC3init(&WhitePoint, xn/yn, 1.0, (1.0-xn-yn)/yn);
-
- // Across inverse primaries ...
- _cmsMAT3eval(&Coef, &Result, &WhitePoint);
-
- // Give us the Coefs, then I build transformation matrix
- _cmsVEC3init(&r -> v[0], Coef.n[VX]*xr, Coef.n[VY]*xg, Coef.n[VZ]*xb);
- _cmsVEC3init(&r -> v[1], Coef.n[VX]*yr, Coef.n[VY]*yg, Coef.n[VZ]*yb);
- _cmsVEC3init(&r -> v[2], Coef.n[VX]*(1.0-xr-yr), Coef.n[VY]*(1.0-xg-yg), Coef.n[VZ]*(1.0-xb-yb));
-
-
- return _cmsAdaptMatrixToD50(r, WhitePt);
-
-}
-
-
-// Adapts a color to a given illuminant. Original color is expected to have
-// a SourceWhitePt white point.
-cmsBool CMSEXPORT cmsAdaptToIlluminant(cmsCIEXYZ* Result,
- const cmsCIEXYZ* SourceWhitePt,
- const cmsCIEXYZ* Illuminant,
- const cmsCIEXYZ* Value)
-{
- cmsMAT3 Bradford;
- cmsVEC3 In, Out;
-
- _cmsAssert(Result != NULL);
- _cmsAssert(SourceWhitePt != NULL);
- _cmsAssert(Illuminant != NULL);
- _cmsAssert(Value != NULL);
-
- if (!_cmsAdaptationMatrix(&Bradford, NULL, SourceWhitePt, Illuminant)) return FALSE;
-
- _cmsVEC3init(&In, Value -> X, Value -> Y, Value -> Z);
- _cmsMAT3eval(&Out, &Bradford, &In);
-
- Result -> X = Out.n[0];
- Result -> Y = Out.n[1];
- Result -> Z = Out.n[2];
-
- return TRUE;
-}
-
-
diff --git a/contrib/libs/lcms2/src/cmsxform.c b/contrib/libs/lcms2/src/cmsxform.c
deleted file mode 100644
index 8fe6b6b974..0000000000
--- a/contrib/libs/lcms2/src/cmsxform.c
+++ /dev/null
@@ -1,1458 +0,0 @@
-//---------------------------------------------------------------------------------
-//
-// Little Color Management System
-// Copyright (c) 1998-2023 Marti Maria Saguer
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//---------------------------------------------------------------------------------
-//
-
-#include "lcms2_internal.h"
-
-// Transformations stuff
-// -----------------------------------------------------------------------
-
-#define DEFAULT_OBSERVER_ADAPTATION_STATE 1.0
-
-// The Context0 observer adaptation state.
-_cmsAdaptationStateChunkType _cmsAdaptationStateChunk = { DEFAULT_OBSERVER_ADAPTATION_STATE };
-
-// Init and duplicate observer adaptation state
-void _cmsAllocAdaptationStateChunk(struct _cmsContext_struct* ctx,
- const struct _cmsContext_struct* src)
-{
- static _cmsAdaptationStateChunkType AdaptationStateChunk = { DEFAULT_OBSERVER_ADAPTATION_STATE };
- void* from;
-
- if (src != NULL) {
- from = src ->chunks[AdaptationStateContext];
- }
- else {
- from = &AdaptationStateChunk;
- }
-
- ctx ->chunks[AdaptationStateContext] = _cmsSubAllocDup(ctx ->MemPool, from, sizeof(_cmsAdaptationStateChunkType));
-}
-
-
-// Sets adaptation state for absolute colorimetric intent in the given context. Adaptation state applies on all
-// but cmsCreateExtendedTransformTHR(). Little CMS can handle incomplete adaptation states.
-cmsFloat64Number CMSEXPORT cmsSetAdaptationStateTHR(cmsContext ContextID, cmsFloat64Number d)
-{
- cmsFloat64Number prev;
- _cmsAdaptationStateChunkType* ptr = (_cmsAdaptationStateChunkType*) _cmsContextGetClientChunk(ContextID, AdaptationStateContext);
-
- // Get previous value for return
- prev = ptr ->AdaptationState;
-
- // Set the value if d is positive or zero
- if (d >= 0.0) {
-
- ptr ->AdaptationState = d;
- }
-
- // Always return previous value
- return prev;
-}
-
-
-// The adaptation state may be defaulted by this function. If you don't like it, use the extended transform routine
-cmsFloat64Number CMSEXPORT cmsSetAdaptationState(cmsFloat64Number d)
-{
- return cmsSetAdaptationStateTHR(NULL, d);
-}
-
-// -----------------------------------------------------------------------
-
-// Alarm codes for 16-bit transformations, because the fixed range of containers there are
-// no values left to mark out of gamut.
-
-#define DEFAULT_ALARM_CODES_VALUE {0x7F00, 0x7F00, 0x7F00, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
-
-_cmsAlarmCodesChunkType _cmsAlarmCodesChunk = { DEFAULT_ALARM_CODES_VALUE };
-
-// Sets the codes used to mark out-out-gamut on Proofing transforms for a given context. Values are meant to be
-// encoded in 16 bits.
-void CMSEXPORT cmsSetAlarmCodesTHR(cmsContext ContextID, const cmsUInt16Number AlarmCodesP[cmsMAXCHANNELS])
-{
- _cmsAlarmCodesChunkType* ContextAlarmCodes = (_cmsAlarmCodesChunkType*) _cmsContextGetClientChunk(ContextID, AlarmCodesContext);
-
- _cmsAssert(ContextAlarmCodes != NULL); // Can't happen
-
- memcpy(ContextAlarmCodes->AlarmCodes, AlarmCodesP, sizeof(ContextAlarmCodes->AlarmCodes));
-}
-
-// Gets the current codes used to mark out-out-gamut on Proofing transforms for the given context.
-// Values are meant to be encoded in 16 bits.
-void CMSEXPORT cmsGetAlarmCodesTHR(cmsContext ContextID, cmsUInt16Number AlarmCodesP[cmsMAXCHANNELS])
-{
- _cmsAlarmCodesChunkType* ContextAlarmCodes = (_cmsAlarmCodesChunkType*) _cmsContextGetClientChunk(ContextID, AlarmCodesContext);
-
- _cmsAssert(ContextAlarmCodes != NULL); // Can't happen
-
- memcpy(AlarmCodesP, ContextAlarmCodes->AlarmCodes, sizeof(ContextAlarmCodes->AlarmCodes));
-}
-
-void CMSEXPORT cmsSetAlarmCodes(const cmsUInt16Number NewAlarm[cmsMAXCHANNELS])
-{
- _cmsAssert(NewAlarm != NULL);
-
- cmsSetAlarmCodesTHR(NULL, NewAlarm);
-}
-
-void CMSEXPORT cmsGetAlarmCodes(cmsUInt16Number OldAlarm[cmsMAXCHANNELS])
-{
- _cmsAssert(OldAlarm != NULL);
- cmsGetAlarmCodesTHR(NULL, OldAlarm);
-}
-
-
-// Init and duplicate alarm codes
-void _cmsAllocAlarmCodesChunk(struct _cmsContext_struct* ctx,
- const struct _cmsContext_struct* src)
-{
- static _cmsAlarmCodesChunkType AlarmCodesChunk = { DEFAULT_ALARM_CODES_VALUE };
- void* from;
-
- if (src != NULL) {
- from = src ->chunks[AlarmCodesContext];
- }
- else {
- from = &AlarmCodesChunk;
- }
-
- ctx ->chunks[AlarmCodesContext] = _cmsSubAllocDup(ctx ->MemPool, from, sizeof(_cmsAlarmCodesChunkType));
-}
-
-// -----------------------------------------------------------------------
-
-// Get rid of transform resources
-void CMSEXPORT cmsDeleteTransform(cmsHTRANSFORM hTransform)
-{
- _cmsTRANSFORM* p = (_cmsTRANSFORM*) hTransform;
-
- _cmsAssert(p != NULL);
-
- if (p -> GamutCheck)
- cmsPipelineFree(p -> GamutCheck);
-
- if (p -> Lut)
- cmsPipelineFree(p -> Lut);
-
- if (p ->InputColorant)
- cmsFreeNamedColorList(p ->InputColorant);
-
- if (p -> OutputColorant)
- cmsFreeNamedColorList(p ->OutputColorant);
-
- if (p ->Sequence)
- cmsFreeProfileSequenceDescription(p ->Sequence);
-
- if (p ->UserData)
- p ->FreeUserData(p ->ContextID, p ->UserData);
-
- _cmsFree(p ->ContextID, (void *) p);
-}
-
-
-static
-cmsUInt32Number PixelSize(cmsUInt32Number Format)
-{
- cmsUInt32Number fmt_bytes = T_BYTES(Format);
-
- // For double, the T_BYTES field is zero
- if (fmt_bytes == 0)
- return sizeof(cmsUInt64Number);
-
- // Otherwise, it is already correct for all formats
- return fmt_bytes;
-}
-
-
-
-
-// Apply transform.
-void CMSEXPORT cmsDoTransform(cmsHTRANSFORM Transform,
- const void* InputBuffer,
- void* OutputBuffer,
- cmsUInt32Number Size)
-
-{
- _cmsTRANSFORM* p = (_cmsTRANSFORM*) Transform;
- cmsStride stride;
-
- stride.BytesPerLineIn = 0; // Not used
- stride.BytesPerLineOut = 0;
- stride.BytesPerPlaneIn = Size * PixelSize(p->InputFormat);
- stride.BytesPerPlaneOut = Size * PixelSize(p->OutputFormat);
-
- p -> xform(p, InputBuffer, OutputBuffer, Size, 1, &stride);
-}
-
-
-// This is a legacy stride for planar
-void CMSEXPORT cmsDoTransformStride(cmsHTRANSFORM Transform,
- const void* InputBuffer,
- void* OutputBuffer,
- cmsUInt32Number Size, cmsUInt32Number Stride)
-
-{
- _cmsTRANSFORM* p = (_cmsTRANSFORM*) Transform;
- cmsStride stride;
-
- stride.BytesPerLineIn = 0;
- stride.BytesPerLineOut = 0;
- stride.BytesPerPlaneIn = Stride;
- stride.BytesPerPlaneOut = Stride;
-
- p -> xform(p, InputBuffer, OutputBuffer, Size, 1, &stride);
-}
-
-// This is the "fast" function for plugins
-void CMSEXPORT cmsDoTransformLineStride(cmsHTRANSFORM Transform,
- const void* InputBuffer,
- void* OutputBuffer,
- cmsUInt32Number PixelsPerLine,
- cmsUInt32Number LineCount,
- cmsUInt32Number BytesPerLineIn,
- cmsUInt32Number BytesPerLineOut,
- cmsUInt32Number BytesPerPlaneIn,
- cmsUInt32Number BytesPerPlaneOut)
-
-{
- _cmsTRANSFORM* p = (_cmsTRANSFORM*) Transform;
- cmsStride stride;
-
- stride.BytesPerLineIn = BytesPerLineIn;
- stride.BytesPerLineOut = BytesPerLineOut;
- stride.BytesPerPlaneIn = BytesPerPlaneIn;
- stride.BytesPerPlaneOut = BytesPerPlaneOut;
-
- p->xform(p, InputBuffer, OutputBuffer, PixelsPerLine, LineCount, &stride);
-}
-
-
-
-// Transform routines ----------------------------------------------------------------------------------------------------------
-
-// Float xform converts floats. Since there are no performance issues, one routine does all job, including gamut check.
-// Note that because extended range, we can use a -1.0 value for out of gamut in this case.
-static
-void FloatXFORM(_cmsTRANSFORM* p,
- const void* in,
- void* out,
- cmsUInt32Number PixelsPerLine,
- cmsUInt32Number LineCount,
- const cmsStride* Stride)
-{
- cmsUInt8Number* accum;
- cmsUInt8Number* output;
- cmsFloat32Number fIn[cmsMAXCHANNELS], fOut[cmsMAXCHANNELS];
- cmsFloat32Number OutOfGamut;
- cmsUInt32Number i, j, c, strideIn, strideOut;
-
- _cmsHandleExtraChannels(p, in, out, PixelsPerLine, LineCount, Stride);
-
- strideIn = 0;
- strideOut = 0;
- memset(fIn, 0, sizeof(fIn));
- memset(fOut, 0, sizeof(fOut));
-
- for (i = 0; i < LineCount; i++) {
-
- accum = (cmsUInt8Number*)in + strideIn;
- output = (cmsUInt8Number*)out + strideOut;
-
- for (j = 0; j < PixelsPerLine; j++) {
-
- accum = p->FromInputFloat(p, fIn, accum, Stride->BytesPerPlaneIn);
-
- // Any gamut check to do?
- if (p->GamutCheck != NULL) {
-
- // Evaluate gamut marker.
- cmsPipelineEvalFloat(fIn, &OutOfGamut, p->GamutCheck);
-
- // Is current color out of gamut?
- if (OutOfGamut > 0.0) {
-
- // Certainly, out of gamut
- for (c = 0; c < cmsMAXCHANNELS; c++)
- fOut[c] = -1.0;
-
- }
- else {
- // No, proceed normally
- cmsPipelineEvalFloat(fIn, fOut, p->Lut);
- }
- }
- else {
-
- // No gamut check at all
- cmsPipelineEvalFloat(fIn, fOut, p->Lut);
- }
-
-
- output = p->ToOutputFloat(p, fOut, output, Stride->BytesPerPlaneOut);
- }
-
- strideIn += Stride->BytesPerLineIn;
- strideOut += Stride->BytesPerLineOut;
- }
-
-}
-
-
-static
-void NullFloatXFORM(_cmsTRANSFORM* p,
- const void* in,
- void* out,
- cmsUInt32Number PixelsPerLine,
- cmsUInt32Number LineCount,
- const cmsStride* Stride)
-
-{
- cmsUInt8Number* accum;
- cmsUInt8Number* output;
- cmsFloat32Number fIn[cmsMAXCHANNELS];
- cmsUInt32Number i, j, strideIn, strideOut;
-
- _cmsHandleExtraChannels(p, in, out, PixelsPerLine, LineCount, Stride);
-
- strideIn = 0;
- strideOut = 0;
- memset(fIn, 0, sizeof(fIn));
-
- for (i = 0; i < LineCount; i++) {
-
- accum = (cmsUInt8Number*) in + strideIn;
- output = (cmsUInt8Number*) out + strideOut;
-
- for (j = 0; j < PixelsPerLine; j++) {
-
- accum = p->FromInputFloat(p, fIn, accum, Stride ->BytesPerPlaneIn);
- output = p->ToOutputFloat(p, fIn, output, Stride->BytesPerPlaneOut);
- }
-
- strideIn += Stride->BytesPerLineIn;
- strideOut += Stride->BytesPerLineOut;
- }
-}
-
-// 16 bit precision -----------------------------------------------------------------------------------------------------------
-
-// Null transformation, only applies formatters. No cache
-static
-void NullXFORM(_cmsTRANSFORM* p,
- const void* in,
- void* out,
- cmsUInt32Number PixelsPerLine,
- cmsUInt32Number LineCount,
- const cmsStride* Stride)
-{
- cmsUInt8Number* accum;
- cmsUInt8Number* output;
- cmsUInt16Number wIn[cmsMAXCHANNELS];
- cmsUInt32Number i, j, strideIn, strideOut;
-
- _cmsHandleExtraChannels(p, in, out, PixelsPerLine, LineCount, Stride);
-
- strideIn = 0;
- strideOut = 0;
- memset(wIn, 0, sizeof(wIn));
-
- for (i = 0; i < LineCount; i++) {
-
- accum = (cmsUInt8Number*)in + strideIn;
- output = (cmsUInt8Number*)out + strideOut;
-
- for (j = 0; j < PixelsPerLine; j++) {
-
- accum = p->FromInput(p, wIn, accum, Stride->BytesPerPlaneIn);
- output = p->ToOutput(p, wIn, output, Stride->BytesPerPlaneOut);
- }
-
- strideIn += Stride->BytesPerLineIn;
- strideOut += Stride->BytesPerLineOut;
- }
-
-}
-
-
-// No gamut check, no cache, 16 bits
-static
-void PrecalculatedXFORM(_cmsTRANSFORM* p,
- const void* in,
- void* out,
- cmsUInt32Number PixelsPerLine,
- cmsUInt32Number LineCount,
- const cmsStride* Stride)
-{
- CMSREGISTER cmsUInt8Number* accum;
- CMSREGISTER cmsUInt8Number* output;
- cmsUInt16Number wIn[cmsMAXCHANNELS], wOut[cmsMAXCHANNELS];
- cmsUInt32Number i, j, strideIn, strideOut;
-
- _cmsHandleExtraChannels(p, in, out, PixelsPerLine, LineCount, Stride);
-
- strideIn = 0;
- strideOut = 0;
- memset(wIn, 0, sizeof(wIn));
- memset(wOut, 0, sizeof(wOut));
-
- for (i = 0; i < LineCount; i++) {
-
- accum = (cmsUInt8Number*)in + strideIn;
- output = (cmsUInt8Number*)out + strideOut;
-
- for (j = 0; j < PixelsPerLine; j++) {
-
- accum = p->FromInput(p, wIn, accum, Stride->BytesPerPlaneIn);
- p->Lut->Eval16Fn(wIn, wOut, p->Lut->Data);
- output = p->ToOutput(p, wOut, output, Stride->BytesPerPlaneOut);
- }
-
- strideIn += Stride->BytesPerLineIn;
- strideOut += Stride->BytesPerLineOut;
- }
-
-}
-
-
-// Auxiliary: Handle precalculated gamut check. The retrieval of context may be alittle bit slow, but this function is not critical.
-static
-void TransformOnePixelWithGamutCheck(_cmsTRANSFORM* p,
- const cmsUInt16Number wIn[],
- cmsUInt16Number wOut[])
-{
- cmsUInt16Number wOutOfGamut;
-
- p ->GamutCheck ->Eval16Fn(wIn, &wOutOfGamut, p ->GamutCheck ->Data);
- if (wOutOfGamut >= 1) {
-
- cmsUInt32Number i;
- _cmsAlarmCodesChunkType* ContextAlarmCodes = (_cmsAlarmCodesChunkType*) _cmsContextGetClientChunk(p->ContextID, AlarmCodesContext);
-
- for (i=0; i < p ->Lut->OutputChannels; i++) {
-
- wOut[i] = ContextAlarmCodes ->AlarmCodes[i];
- }
- }
- else
- p ->Lut ->Eval16Fn(wIn, wOut, p -> Lut->Data);
-}
-
-// Gamut check, No cache, 16 bits.
-static
-void PrecalculatedXFORMGamutCheck(_cmsTRANSFORM* p,
- const void* in,
- void* out,
- cmsUInt32Number PixelsPerLine,
- cmsUInt32Number LineCount,
- const cmsStride* Stride)
-{
- cmsUInt8Number* accum;
- cmsUInt8Number* output;
- cmsUInt16Number wIn[cmsMAXCHANNELS], wOut[cmsMAXCHANNELS];
- cmsUInt32Number i, j, strideIn, strideOut;
-
- _cmsHandleExtraChannels(p, in, out, PixelsPerLine, LineCount, Stride);
-
- strideIn = 0;
- strideOut = 0;
- memset(wIn, 0, sizeof(wIn));
- memset(wOut, 0, sizeof(wOut));
-
- for (i = 0; i < LineCount; i++) {
-
- accum = (cmsUInt8Number*)in + strideIn;
- output = (cmsUInt8Number*)out + strideOut;
-
- for (j = 0; j < PixelsPerLine; j++) {
-
- accum = p->FromInput(p, wIn, accum, Stride->BytesPerPlaneIn);
- TransformOnePixelWithGamutCheck(p, wIn, wOut);
- output = p->ToOutput(p, wOut, output, Stride->BytesPerPlaneOut);
- }
-
- strideIn += Stride->BytesPerLineIn;
- strideOut += Stride->BytesPerLineOut;
- }
-}
-
-
-// No gamut check, Cache, 16 bits,
-static
-void CachedXFORM(_cmsTRANSFORM* p,
- const void* in,
- void* out,
- cmsUInt32Number PixelsPerLine,
- cmsUInt32Number LineCount,
- const cmsStride* Stride)
-{
- cmsUInt8Number* accum;
- cmsUInt8Number* output;
- cmsUInt16Number wIn[cmsMAXCHANNELS], wOut[cmsMAXCHANNELS];
- _cmsCACHE Cache;
- cmsUInt32Number i, j, strideIn, strideOut;
-
- _cmsHandleExtraChannels(p, in, out, PixelsPerLine, LineCount, Stride);
-
- // Empty buffers for quick memcmp
- memset(wIn, 0, sizeof(wIn));
- memset(wOut, 0, sizeof(wOut));
-
- // Get copy of zero cache
- memcpy(&Cache, &p->Cache, sizeof(Cache));
-
- strideIn = 0;
- strideOut = 0;
-
- for (i = 0; i < LineCount; i++) {
-
- accum = (cmsUInt8Number*)in + strideIn;
- output = (cmsUInt8Number*)out + strideOut;
-
- for (j = 0; j < PixelsPerLine; j++) {
-
- accum = p->FromInput(p, wIn, accum, Stride->BytesPerPlaneIn);
-
- if (memcmp(wIn, Cache.CacheIn, sizeof(Cache.CacheIn)) == 0) {
-
- memcpy(wOut, Cache.CacheOut, sizeof(Cache.CacheOut));
- }
- else {
- p->Lut->Eval16Fn(wIn, wOut, p->Lut->Data);
-
- memcpy(Cache.CacheIn, wIn, sizeof(Cache.CacheIn));
- memcpy(Cache.CacheOut, wOut, sizeof(Cache.CacheOut));
- }
-
- output = p->ToOutput(p, wOut, output, Stride->BytesPerPlaneOut);
- }
-
- strideIn += Stride->BytesPerLineIn;
- strideOut += Stride->BytesPerLineOut;
- }
-}
-
-// All those nice features together
-static
-void CachedXFORMGamutCheck(_cmsTRANSFORM* p,
- const void* in,
- void* out,
- cmsUInt32Number PixelsPerLine,
- cmsUInt32Number LineCount,
- const cmsStride* Stride)
-{
- cmsUInt8Number* accum;
- cmsUInt8Number* output;
- cmsUInt16Number wIn[cmsMAXCHANNELS], wOut[cmsMAXCHANNELS];
- _cmsCACHE Cache;
- cmsUInt32Number i, j, strideIn, strideOut;
-
- _cmsHandleExtraChannels(p, in, out, PixelsPerLine, LineCount, Stride);
-
- // Empty buffers for quick memcmp
- memset(wIn, 0, sizeof(wIn));
- memset(wOut, 0, sizeof(wOut));
-
- // Get copy of zero cache
- memcpy(&Cache, &p->Cache, sizeof(Cache));
-
- strideIn = 0;
- strideOut = 0;
-
- for (i = 0; i < LineCount; i++) {
-
- accum = (cmsUInt8Number*)in + strideIn;
- output = (cmsUInt8Number*)out + strideOut;
-
- for (j = 0; j < PixelsPerLine; j++) {
-
- accum = p->FromInput(p, wIn, accum, Stride->BytesPerPlaneIn);
-
- if (memcmp(wIn, Cache.CacheIn, sizeof(Cache.CacheIn)) == 0) {
-
- memcpy(wOut, Cache.CacheOut, sizeof(Cache.CacheOut));
- }
- else {
- TransformOnePixelWithGamutCheck(p, wIn, wOut);
-
- memcpy(Cache.CacheIn, wIn, sizeof(Cache.CacheIn));
- memcpy(Cache.CacheOut, wOut, sizeof(Cache.CacheOut));
- }
-
- output = p->ToOutput(p, wOut, output, Stride->BytesPerPlaneOut);
- }
-
- strideIn += Stride->BytesPerLineIn;
- strideOut += Stride->BytesPerLineOut;
- }
-}
-
-// Transform plug-ins ----------------------------------------------------------------------------------------------------
-
-// List of used-defined transform factories
-typedef struct _cmsTransformCollection_st {
-
- _cmsTransform2Factory Factory;
- cmsBool OldXform; // Factory returns xform function in the old style
-
- struct _cmsTransformCollection_st *Next;
-
-} _cmsTransformCollection;
-
-// The linked list head
-_cmsTransformPluginChunkType _cmsTransformPluginChunk = { NULL };
-
-
-// Duplicates the zone of memory used by the plug-in in the new context
-static
-void DupPluginTransformList(struct _cmsContext_struct* ctx,
- const struct _cmsContext_struct* src)
-{
- _cmsTransformPluginChunkType newHead = { NULL };
- _cmsTransformCollection* entry;
- _cmsTransformCollection* Anterior = NULL;
- _cmsTransformPluginChunkType* head = (_cmsTransformPluginChunkType*) src->chunks[TransformPlugin];
-
- // Walk the list copying all nodes
- for (entry = head->TransformCollection;
- entry != NULL;
- entry = entry ->Next) {
-
- _cmsTransformCollection *newEntry = ( _cmsTransformCollection *) _cmsSubAllocDup(ctx ->MemPool, entry, sizeof(_cmsTransformCollection));
-
- if (newEntry == NULL)
- return;
-
- // We want to keep the linked list order, so this is a little bit tricky
- newEntry -> Next = NULL;
- if (Anterior)
- Anterior -> Next = newEntry;
-
- Anterior = newEntry;
-
- if (newHead.TransformCollection == NULL)
- newHead.TransformCollection = newEntry;
- }
-
- ctx ->chunks[TransformPlugin] = _cmsSubAllocDup(ctx->MemPool, &newHead, sizeof(_cmsTransformPluginChunkType));
-}
-
-// Allocates memory for transform plugin factory
-void _cmsAllocTransformPluginChunk(struct _cmsContext_struct* ctx,
- const struct _cmsContext_struct* src)
-{
- if (src != NULL) {
-
- // Copy all linked list
- DupPluginTransformList(ctx, src);
- }
- else {
- static _cmsTransformPluginChunkType TransformPluginChunkType = { NULL };
- ctx ->chunks[TransformPlugin] = _cmsSubAllocDup(ctx ->MemPool, &TransformPluginChunkType, sizeof(_cmsTransformPluginChunkType));
- }
-}
-
-// Adaptor for old versions of plug-in
-static
-void _cmsTransform2toTransformAdaptor(struct _cmstransform_struct *CMMcargo,
- const void* InputBuffer,
- void* OutputBuffer,
- cmsUInt32Number PixelsPerLine,
- cmsUInt32Number LineCount,
- const cmsStride* Stride)
-{
-
- cmsUInt32Number i, strideIn, strideOut;
-
- _cmsHandleExtraChannels(CMMcargo, InputBuffer, OutputBuffer, PixelsPerLine, LineCount, Stride);
-
- strideIn = 0;
- strideOut = 0;
-
- for (i = 0; i < LineCount; i++) {
-
- void *accum = (cmsUInt8Number*)InputBuffer + strideIn;
- void *output = (cmsUInt8Number*)OutputBuffer + strideOut;
-
- CMMcargo->OldXform(CMMcargo, accum, output, PixelsPerLine, Stride->BytesPerPlaneIn);
-
- strideIn += Stride->BytesPerLineIn;
- strideOut += Stride->BytesPerLineOut;
- }
-}
-
-
-
-// Register new ways to transform
-cmsBool _cmsRegisterTransformPlugin(cmsContext ContextID, cmsPluginBase* Data)
-{
- cmsPluginTransform* Plugin = (cmsPluginTransform*) Data;
- _cmsTransformCollection* fl;
- _cmsTransformPluginChunkType* ctx = ( _cmsTransformPluginChunkType*) _cmsContextGetClientChunk(ContextID,TransformPlugin);
-
- if (Data == NULL) {
-
- // Free the chain. Memory is safely freed at exit
- ctx->TransformCollection = NULL;
- return TRUE;
- }
-
- // Factory callback is required
- if (Plugin->factories.xform == NULL) return FALSE;
-
-
- fl = (_cmsTransformCollection*) _cmsPluginMalloc(ContextID, sizeof(_cmsTransformCollection));
- if (fl == NULL) return FALSE;
-
- // Check for full xform plug-ins previous to 2.8, we would need an adapter in that case
- if (Plugin->base.ExpectedVersion < 2080) {
-
- fl->OldXform = TRUE;
- }
- else
- fl->OldXform = FALSE;
-
- // Copy the parameters
- fl->Factory = Plugin->factories.xform;
-
- // Keep linked list
- fl ->Next = ctx->TransformCollection;
- ctx->TransformCollection = fl;
-
- // All is ok
- return TRUE;
-}
-
-
-void CMSEXPORT _cmsSetTransformUserData(struct _cmstransform_struct *CMMcargo, void* ptr, _cmsFreeUserDataFn FreePrivateDataFn)
-{
- _cmsAssert(CMMcargo != NULL);
- CMMcargo ->UserData = ptr;
- CMMcargo ->FreeUserData = FreePrivateDataFn;
-}
-
-// returns the pointer defined by the plug-in to store private data
-void * CMSEXPORT _cmsGetTransformUserData(struct _cmstransform_struct *CMMcargo)
-{
- _cmsAssert(CMMcargo != NULL);
- return CMMcargo ->UserData;
-}
-
-// returns the current formatters
-void CMSEXPORT _cmsGetTransformFormatters16(struct _cmstransform_struct *CMMcargo, cmsFormatter16* FromInput, cmsFormatter16* ToOutput)
-{
- _cmsAssert(CMMcargo != NULL);
- if (FromInput) *FromInput = CMMcargo ->FromInput;
- if (ToOutput) *ToOutput = CMMcargo ->ToOutput;
-}
-
-void CMSEXPORT _cmsGetTransformFormattersFloat(struct _cmstransform_struct *CMMcargo, cmsFormatterFloat* FromInput, cmsFormatterFloat* ToOutput)
-{
- _cmsAssert(CMMcargo != NULL);
- if (FromInput) *FromInput = CMMcargo ->FromInputFloat;
- if (ToOutput) *ToOutput = CMMcargo ->ToOutputFloat;
-}
-
-// returns original flags
-cmsUInt32Number CMSEXPORT _cmsGetTransformFlags(struct _cmstransform_struct* CMMcargo)
-{
- _cmsAssert(CMMcargo != NULL);
- return CMMcargo->dwOriginalFlags;
-}
-
-// Returns the worker callback for parallelization plug-ins
-_cmsTransform2Fn CMSEXPORT _cmsGetTransformWorker(struct _cmstransform_struct* CMMcargo)
-{
- _cmsAssert(CMMcargo != NULL);
- return CMMcargo->Worker;
-}
-
-// This field holds maximum number of workers or -1 to auto
-cmsInt32Number CMSEXPORT _cmsGetTransformMaxWorkers(struct _cmstransform_struct* CMMcargo)
-{
- _cmsAssert(CMMcargo != NULL);
- return CMMcargo->MaxWorkers;
-}
-
-// This field is actually unused and reserved
-cmsUInt32Number CMSEXPORT _cmsGetTransformWorkerFlags(struct _cmstransform_struct* CMMcargo)
-{
- _cmsAssert(CMMcargo != NULL);
- return CMMcargo->WorkerFlags;
-}
-
-// In the case there is a parallelization plug-in, let it to do its job
-static
-void ParalellizeIfSuitable(_cmsTRANSFORM* p)
-{
- _cmsParallelizationPluginChunkType* ctx = (_cmsParallelizationPluginChunkType*)_cmsContextGetClientChunk(p->ContextID, ParallelizationPlugin);
-
- _cmsAssert(p != NULL);
- if (ctx != NULL && ctx->SchedulerFn != NULL) {
-
- p->Worker = p->xform;
- p->xform = ctx->SchedulerFn;
- p->MaxWorkers = ctx->MaxWorkers;
- p->WorkerFlags = ctx->WorkerFlags;
- }
-}
-
-
-/**
-* An empty unroll to avoid a check with NULL on cmsDoTransform()
-*/
-static
-cmsUInt8Number* UnrollNothing(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- return accum;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(wIn);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-static
-cmsUInt8Number* PackNothing(CMSREGISTER _cmsTRANSFORM* info,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- return output;
-
- cmsUNUSED_PARAMETER(info);
- cmsUNUSED_PARAMETER(wOut);
- cmsUNUSED_PARAMETER(Stride);
-}
-
-// Allocate transform struct and set it to defaults. Ask the optimization plug-in about if those formats are proper
-// for separated transforms. If this is the case,
-static
-_cmsTRANSFORM* AllocEmptyTransform(cmsContext ContextID, cmsPipeline* lut,
- cmsUInt32Number Intent, cmsUInt32Number* InputFormat, cmsUInt32Number* OutputFormat, cmsUInt32Number* dwFlags)
-{
- _cmsTransformPluginChunkType* ctx = ( _cmsTransformPluginChunkType*) _cmsContextGetClientChunk(ContextID, TransformPlugin);
- _cmsTransformCollection* Plugin;
-
- // Allocate needed memory
- _cmsTRANSFORM* p = (_cmsTRANSFORM*)_cmsMallocZero(ContextID, sizeof(_cmsTRANSFORM));
- if (!p) {
- cmsPipelineFree(lut);
- return NULL;
- }
-
- // Store the proposed pipeline
- p->Lut = lut;
-
- // Let's see if any plug-in want to do the transform by itself
- if (p->Lut != NULL) {
-
- if (!(*dwFlags & cmsFLAGS_NOOPTIMIZE))
- {
- for (Plugin = ctx->TransformCollection;
- Plugin != NULL;
- Plugin = Plugin->Next) {
-
- if (Plugin->Factory(&p->xform, &p->UserData, &p->FreeUserData, &p->Lut, InputFormat, OutputFormat, dwFlags)) {
-
- // Last plugin in the declaration order takes control. We just keep
- // the original parameters as a logging.
- // Note that cmsFLAGS_CAN_CHANGE_FORMATTER is not set, so by default
- // an optimized transform is not reusable. The plug-in can, however, change
- // the flags and make it suitable.
-
- p->ContextID = ContextID;
- p->InputFormat = *InputFormat;
- p->OutputFormat = *OutputFormat;
- p->dwOriginalFlags = *dwFlags;
-
- // Fill the formatters just in case the optimized routine is interested.
- // No error is thrown if the formatter doesn't exist. It is up to the optimization
- // factory to decide what to do in those cases.
- p->FromInput = _cmsGetFormatter(ContextID, *InputFormat, cmsFormatterInput, CMS_PACK_FLAGS_16BITS).Fmt16;
- p->ToOutput = _cmsGetFormatter(ContextID, *OutputFormat, cmsFormatterOutput, CMS_PACK_FLAGS_16BITS).Fmt16;
- p->FromInputFloat = _cmsGetFormatter(ContextID, *InputFormat, cmsFormatterInput, CMS_PACK_FLAGS_FLOAT).FmtFloat;
- p->ToOutputFloat = _cmsGetFormatter(ContextID, *OutputFormat, cmsFormatterOutput, CMS_PACK_FLAGS_FLOAT).FmtFloat;
-
- // Save the day? (Ignore the warning)
- if (Plugin->OldXform) {
- p->OldXform = (_cmsTransformFn)(void*)p->xform;
- p->xform = _cmsTransform2toTransformAdaptor;
- }
-
- ParalellizeIfSuitable(p);
- return p;
- }
- }
- }
-
- // Not suitable for the transform plug-in, let's check the pipeline plug-in
- _cmsOptimizePipeline(ContextID, &p->Lut, Intent, InputFormat, OutputFormat, dwFlags);
- }
-
- // Check whatever this is a true floating point transform
- if (_cmsFormatterIsFloat(*InputFormat) || _cmsFormatterIsFloat(*OutputFormat)) {
-
- // Get formatter function always return a valid union, but the contents of this union may be NULL.
- p ->FromInputFloat = _cmsGetFormatter(ContextID, *InputFormat, cmsFormatterInput, CMS_PACK_FLAGS_FLOAT).FmtFloat;
- p ->ToOutputFloat = _cmsGetFormatter(ContextID, *OutputFormat, cmsFormatterOutput, CMS_PACK_FLAGS_FLOAT).FmtFloat;
- *dwFlags |= cmsFLAGS_CAN_CHANGE_FORMATTER;
-
- if (p ->FromInputFloat == NULL || p ->ToOutputFloat == NULL) {
-
- cmsSignalError(ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unsupported raster format");
- cmsDeleteTransform(p);
- return NULL;
- }
-
- if (*dwFlags & cmsFLAGS_NULLTRANSFORM) {
-
- p ->xform = NullFloatXFORM;
- }
- else {
- // Float transforms don't use cache, always are non-NULL
- p ->xform = FloatXFORM;
- }
-
- }
- else {
-
- // Formats are intended to be changed before use
- if (*InputFormat == 0 && *OutputFormat == 0) {
- p->FromInput = UnrollNothing;
- p->ToOutput = PackNothing;
- *dwFlags |= cmsFLAGS_CAN_CHANGE_FORMATTER;
- }
- else {
-
- cmsUInt32Number BytesPerPixelInput;
-
- p ->FromInput = _cmsGetFormatter(ContextID, *InputFormat, cmsFormatterInput, CMS_PACK_FLAGS_16BITS).Fmt16;
- p ->ToOutput = _cmsGetFormatter(ContextID, *OutputFormat, cmsFormatterOutput, CMS_PACK_FLAGS_16BITS).Fmt16;
-
- if (p ->FromInput == NULL || p ->ToOutput == NULL) {
-
- cmsSignalError(ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unsupported raster format");
- cmsDeleteTransform(p);
- return NULL;
- }
-
- BytesPerPixelInput = T_BYTES(*InputFormat);
- if (BytesPerPixelInput == 0 || BytesPerPixelInput >= 2)
- *dwFlags |= cmsFLAGS_CAN_CHANGE_FORMATTER;
-
- }
-
- if (*dwFlags & cmsFLAGS_NULLTRANSFORM) {
-
- p ->xform = NullXFORM;
- }
- else {
- if (*dwFlags & cmsFLAGS_NOCACHE) {
-
- if (*dwFlags & cmsFLAGS_GAMUTCHECK)
- p ->xform = PrecalculatedXFORMGamutCheck; // Gamut check, no cache
- else
- p ->xform = PrecalculatedXFORM; // No cache, no gamut check
- }
- else {
-
- if (*dwFlags & cmsFLAGS_GAMUTCHECK)
- p ->xform = CachedXFORMGamutCheck; // Gamut check, cache
- else
- p ->xform = CachedXFORM; // No gamut check, cache
-
- }
- }
- }
-
- /**
- * Check consistency for alpha channel copy
- */
- if (*dwFlags & cmsFLAGS_COPY_ALPHA)
- {
- if (T_EXTRA(*InputFormat) != T_EXTRA(*OutputFormat))
- {
- cmsSignalError(ContextID, cmsERROR_NOT_SUITABLE, "Mismatched alpha channels");
- cmsDeleteTransform(p);
- return NULL;
- }
- }
-
- p ->InputFormat = *InputFormat;
- p ->OutputFormat = *OutputFormat;
- p ->dwOriginalFlags = *dwFlags;
- p ->ContextID = ContextID;
- p ->UserData = NULL;
- ParalellizeIfSuitable(p);
- return p;
-}
-
-static
-cmsBool GetXFormColorSpaces(cmsUInt32Number nProfiles, cmsHPROFILE hProfiles[], cmsColorSpaceSignature* Input, cmsColorSpaceSignature* Output)
-{
- cmsColorSpaceSignature ColorSpaceIn, ColorSpaceOut;
- cmsColorSpaceSignature PostColorSpace;
- cmsUInt32Number i;
-
- if (nProfiles == 0) return FALSE;
- if (hProfiles[0] == NULL) return FALSE;
-
- *Input = PostColorSpace = cmsGetColorSpace(hProfiles[0]);
-
- for (i=0; i < nProfiles; i++) {
-
- cmsProfileClassSignature cls;
- cmsHPROFILE hProfile = hProfiles[i];
-
- int lIsInput = (PostColorSpace != cmsSigXYZData) &&
- (PostColorSpace != cmsSigLabData);
-
- if (hProfile == NULL) return FALSE;
-
- cls = cmsGetDeviceClass(hProfile);
-
- if (cls == cmsSigNamedColorClass) {
-
- ColorSpaceIn = cmsSig1colorData;
- ColorSpaceOut = (nProfiles > 1) ? cmsGetPCS(hProfile) : cmsGetColorSpace(hProfile);
- }
- else
- if (lIsInput || (cls == cmsSigLinkClass)) {
-
- ColorSpaceIn = cmsGetColorSpace(hProfile);
- ColorSpaceOut = cmsGetPCS(hProfile);
- }
- else
- {
- ColorSpaceIn = cmsGetPCS(hProfile);
- ColorSpaceOut = cmsGetColorSpace(hProfile);
- }
-
- if (i==0)
- *Input = ColorSpaceIn;
-
- PostColorSpace = ColorSpaceOut;
- }
-
- *Output = PostColorSpace;
-
- return TRUE;
-}
-
-// Check colorspace
-static
-cmsBool IsProperColorSpace(cmsColorSpaceSignature Check, cmsUInt32Number dwFormat)
-{
- int Space1 = (int) T_COLORSPACE(dwFormat);
- int Space2 = _cmsLCMScolorSpace(Check);
-
- if (Space1 == PT_ANY) return TRUE;
- if (Space1 == Space2) return TRUE;
-
- if (Space1 == PT_LabV2 && Space2 == PT_Lab) return TRUE;
- if (Space1 == PT_Lab && Space2 == PT_LabV2) return TRUE;
-
- return FALSE;
-}
-
-// ----------------------------------------------------------------------------------------------------------------
-
-// Jun-21-2000: Some profiles (those that comes with W2K) comes
-// with the media white (media black?) x 100. Add a sanity check
-
-static
-void NormalizeXYZ(cmsCIEXYZ* Dest)
-{
- while (Dest -> X > 2. &&
- Dest -> Y > 2. &&
- Dest -> Z > 2.) {
-
- Dest -> X /= 10.;
- Dest -> Y /= 10.;
- Dest -> Z /= 10.;
- }
-}
-
-static
-void SetWhitePoint(cmsCIEXYZ* wtPt, const cmsCIEXYZ* src)
-{
- if (src == NULL) {
- wtPt ->X = cmsD50X;
- wtPt ->Y = cmsD50Y;
- wtPt ->Z = cmsD50Z;
- }
- else {
- wtPt ->X = src->X;
- wtPt ->Y = src->Y;
- wtPt ->Z = src->Z;
-
- NormalizeXYZ(wtPt);
- }
-
-}
-
-// New to lcms 2.0 -- have all parameters available.
-cmsHTRANSFORM CMSEXPORT cmsCreateExtendedTransform(cmsContext ContextID,
- cmsUInt32Number nProfiles, cmsHPROFILE hProfiles[],
- cmsBool BPC[],
- cmsUInt32Number Intents[],
- cmsFloat64Number AdaptationStates[],
- cmsHPROFILE hGamutProfile,
- cmsUInt32Number nGamutPCSposition,
- cmsUInt32Number InputFormat,
- cmsUInt32Number OutputFormat,
- cmsUInt32Number dwFlags)
-{
- _cmsTRANSFORM* xform;
- cmsColorSpaceSignature EntryColorSpace;
- cmsColorSpaceSignature ExitColorSpace;
- cmsPipeline* Lut;
- cmsUInt32Number LastIntent = Intents[nProfiles-1];
-
- // If it is a fake transform
- if (dwFlags & cmsFLAGS_NULLTRANSFORM)
- {
- return AllocEmptyTransform(ContextID, NULL, INTENT_PERCEPTUAL, &InputFormat, &OutputFormat, &dwFlags);
- }
-
- // If gamut check is requested, make sure we have a gamut profile
- if (dwFlags & cmsFLAGS_GAMUTCHECK) {
- if (hGamutProfile == NULL) dwFlags &= ~cmsFLAGS_GAMUTCHECK;
- }
-
- // On floating point transforms, inhibit cache
- if (_cmsFormatterIsFloat(InputFormat) || _cmsFormatterIsFloat(OutputFormat))
- dwFlags |= cmsFLAGS_NOCACHE;
-
- // Mark entry/exit spaces
- if (!GetXFormColorSpaces(nProfiles, hProfiles, &EntryColorSpace, &ExitColorSpace)) {
- cmsSignalError(ContextID, cmsERROR_NULL, "NULL input profiles on transform");
- return NULL;
- }
-
- // Check if proper colorspaces
- if (!IsProperColorSpace(EntryColorSpace, InputFormat)) {
- cmsSignalError(ContextID, cmsERROR_COLORSPACE_CHECK, "Wrong input color space on transform");
- return NULL;
- }
-
- if (!IsProperColorSpace(ExitColorSpace, OutputFormat)) {
- cmsSignalError(ContextID, cmsERROR_COLORSPACE_CHECK, "Wrong output color space on transform");
- return NULL;
- }
-
- // Check whatever the transform is 16 bits and involves linear RGB in first profile. If so, disable optimizations
- if (EntryColorSpace == cmsSigRgbData && T_BYTES(InputFormat) == 2 && !(dwFlags & cmsFLAGS_NOOPTIMIZE))
- {
- cmsFloat64Number gamma = cmsDetectRGBProfileGamma(hProfiles[0], 0.1);
-
- if (gamma > 0 && gamma < 1.6)
- dwFlags |= cmsFLAGS_NOOPTIMIZE;
- }
-
- // Create a pipeline with all transformations
- Lut = _cmsLinkProfiles(ContextID, nProfiles, Intents, hProfiles, BPC, AdaptationStates, dwFlags);
- if (Lut == NULL) {
- cmsSignalError(ContextID, cmsERROR_NOT_SUITABLE, "Couldn't link the profiles");
- return NULL;
- }
-
- // Check channel count
- if ((cmsChannelsOfColorSpace(EntryColorSpace) != (cmsInt32Number) cmsPipelineInputChannels(Lut)) ||
- (cmsChannelsOfColorSpace(ExitColorSpace) != (cmsInt32Number) cmsPipelineOutputChannels(Lut))) {
- cmsPipelineFree(Lut);
- cmsSignalError(ContextID, cmsERROR_NOT_SUITABLE, "Channel count doesn't match. Profile is corrupted");
- return NULL;
- }
-
-
- // All seems ok
- xform = AllocEmptyTransform(ContextID, Lut, LastIntent, &InputFormat, &OutputFormat, &dwFlags);
- if (xform == NULL) {
- return NULL;
- }
-
- // Keep values
- xform ->EntryColorSpace = EntryColorSpace;
- xform ->ExitColorSpace = ExitColorSpace;
- xform ->RenderingIntent = Intents[nProfiles-1];
-
- // Take white points
- SetWhitePoint(&xform->EntryWhitePoint, (cmsCIEXYZ*) cmsReadTag(hProfiles[0], cmsSigMediaWhitePointTag));
- SetWhitePoint(&xform->ExitWhitePoint, (cmsCIEXYZ*) cmsReadTag(hProfiles[nProfiles-1], cmsSigMediaWhitePointTag));
-
-
- // Create a gamut check LUT if requested
- if (hGamutProfile != NULL && (dwFlags & cmsFLAGS_GAMUTCHECK))
- xform ->GamutCheck = _cmsCreateGamutCheckPipeline(ContextID, hProfiles,
- BPC, Intents,
- AdaptationStates,
- nGamutPCSposition,
- hGamutProfile);
-
-
- // Try to read input and output colorant table
- if (cmsIsTag(hProfiles[0], cmsSigColorantTableTag)) {
-
- // Input table can only come in this way.
- xform ->InputColorant = cmsDupNamedColorList((cmsNAMEDCOLORLIST*) cmsReadTag(hProfiles[0], cmsSigColorantTableTag));
- }
-
- // Output is a little bit more complex.
- if (cmsGetDeviceClass(hProfiles[nProfiles-1]) == cmsSigLinkClass) {
-
- // This tag may exist only on devicelink profiles.
- if (cmsIsTag(hProfiles[nProfiles-1], cmsSigColorantTableOutTag)) {
-
- // It may be NULL if error
- xform ->OutputColorant = cmsDupNamedColorList((cmsNAMEDCOLORLIST*) cmsReadTag(hProfiles[nProfiles-1], cmsSigColorantTableOutTag));
- }
-
- } else {
-
- if (cmsIsTag(hProfiles[nProfiles-1], cmsSigColorantTableTag)) {
-
- xform -> OutputColorant = cmsDupNamedColorList((cmsNAMEDCOLORLIST*) cmsReadTag(hProfiles[nProfiles-1], cmsSigColorantTableTag));
- }
- }
-
- // Store the sequence of profiles
- if (dwFlags & cmsFLAGS_KEEP_SEQUENCE) {
- xform ->Sequence = _cmsCompileProfileSequence(ContextID, nProfiles, hProfiles);
- }
- else
- xform ->Sequence = NULL;
-
- // If this is a cached transform, init first value, which is zero (16 bits only)
- if (!(dwFlags & cmsFLAGS_NOCACHE)) {
-
- memset(&xform ->Cache.CacheIn, 0, sizeof(xform ->Cache.CacheIn));
-
- if (xform ->GamutCheck != NULL) {
- TransformOnePixelWithGamutCheck(xform, xform ->Cache.CacheIn, xform->Cache.CacheOut);
- }
- else {
-
- xform ->Lut ->Eval16Fn(xform ->Cache.CacheIn, xform->Cache.CacheOut, xform -> Lut->Data);
- }
-
- }
-
- return (cmsHTRANSFORM) xform;
-}
-
-// Multiprofile transforms: Gamut check is not available here, as it is unclear from which profile the gamut comes.
-cmsHTRANSFORM CMSEXPORT cmsCreateMultiprofileTransformTHR(cmsContext ContextID,
- cmsHPROFILE hProfiles[],
- cmsUInt32Number nProfiles,
- cmsUInt32Number InputFormat,
- cmsUInt32Number OutputFormat,
- cmsUInt32Number Intent,
- cmsUInt32Number dwFlags)
-{
- cmsUInt32Number i;
- cmsBool BPC[256];
- cmsUInt32Number Intents[256];
- cmsFloat64Number AdaptationStates[256];
-
- if (nProfiles <= 0 || nProfiles > 255) {
- cmsSignalError(ContextID, cmsERROR_RANGE, "Wrong number of profiles. 1..255 expected, %d found.", nProfiles);
- return NULL;
- }
-
- for (i=0; i < nProfiles; i++) {
- BPC[i] = dwFlags & cmsFLAGS_BLACKPOINTCOMPENSATION ? TRUE : FALSE;
- Intents[i] = Intent;
- AdaptationStates[i] = cmsSetAdaptationStateTHR(ContextID, -1);
- }
-
-
- return cmsCreateExtendedTransform(ContextID, nProfiles, hProfiles, BPC, Intents, AdaptationStates, NULL, 0, InputFormat, OutputFormat, dwFlags);
-}
-
-
-
-cmsHTRANSFORM CMSEXPORT cmsCreateMultiprofileTransform(cmsHPROFILE hProfiles[],
- cmsUInt32Number nProfiles,
- cmsUInt32Number InputFormat,
- cmsUInt32Number OutputFormat,
- cmsUInt32Number Intent,
- cmsUInt32Number dwFlags)
-{
-
- if (nProfiles <= 0 || nProfiles > 255) {
- cmsSignalError(NULL, cmsERROR_RANGE, "Wrong number of profiles. 1..255 expected, %d found.", nProfiles);
- return NULL;
- }
-
- return cmsCreateMultiprofileTransformTHR(cmsGetProfileContextID(hProfiles[0]),
- hProfiles,
- nProfiles,
- InputFormat,
- OutputFormat,
- Intent,
- dwFlags);
-}
-
-cmsHTRANSFORM CMSEXPORT cmsCreateTransformTHR(cmsContext ContextID,
- cmsHPROFILE Input,
- cmsUInt32Number InputFormat,
- cmsHPROFILE Output,
- cmsUInt32Number OutputFormat,
- cmsUInt32Number Intent,
- cmsUInt32Number dwFlags)
-{
-
- cmsHPROFILE hArray[2];
-
- hArray[0] = Input;
- hArray[1] = Output;
-
- return cmsCreateMultiprofileTransformTHR(ContextID, hArray, Output == NULL ? 1U : 2U, InputFormat, OutputFormat, Intent, dwFlags);
-}
-
-CMSAPI cmsHTRANSFORM CMSEXPORT cmsCreateTransform(cmsHPROFILE Input,
- cmsUInt32Number InputFormat,
- cmsHPROFILE Output,
- cmsUInt32Number OutputFormat,
- cmsUInt32Number Intent,
- cmsUInt32Number dwFlags)
-{
- return cmsCreateTransformTHR(cmsGetProfileContextID(Input), Input, InputFormat, Output, OutputFormat, Intent, dwFlags);
-}
-
-
-cmsHTRANSFORM CMSEXPORT cmsCreateProofingTransformTHR(cmsContext ContextID,
- cmsHPROFILE InputProfile,
- cmsUInt32Number InputFormat,
- cmsHPROFILE OutputProfile,
- cmsUInt32Number OutputFormat,
- cmsHPROFILE ProofingProfile,
- cmsUInt32Number nIntent,
- cmsUInt32Number ProofingIntent,
- cmsUInt32Number dwFlags)
-{
- cmsHPROFILE hArray[4];
- cmsUInt32Number Intents[4];
- cmsBool BPC[4];
- cmsFloat64Number Adaptation[4];
- cmsBool DoBPC = (dwFlags & cmsFLAGS_BLACKPOINTCOMPENSATION) ? TRUE : FALSE;
-
-
- hArray[0] = InputProfile; hArray[1] = ProofingProfile; hArray[2] = ProofingProfile; hArray[3] = OutputProfile;
- Intents[0] = nIntent; Intents[1] = nIntent; Intents[2] = INTENT_RELATIVE_COLORIMETRIC; Intents[3] = ProofingIntent;
- BPC[0] = DoBPC; BPC[1] = DoBPC; BPC[2] = 0; BPC[3] = 0;
-
- Adaptation[0] = Adaptation[1] = Adaptation[2] = Adaptation[3] = cmsSetAdaptationStateTHR(ContextID, -1);
-
- if (!(dwFlags & (cmsFLAGS_SOFTPROOFING|cmsFLAGS_GAMUTCHECK)))
- return cmsCreateTransformTHR(ContextID, InputProfile, InputFormat, OutputProfile, OutputFormat, nIntent, dwFlags);
-
- return cmsCreateExtendedTransform(ContextID, 4, hArray, BPC, Intents, Adaptation,
- ProofingProfile, 1, InputFormat, OutputFormat, dwFlags);
-
-}
-
-
-cmsHTRANSFORM CMSEXPORT cmsCreateProofingTransform(cmsHPROFILE InputProfile,
- cmsUInt32Number InputFormat,
- cmsHPROFILE OutputProfile,
- cmsUInt32Number OutputFormat,
- cmsHPROFILE ProofingProfile,
- cmsUInt32Number nIntent,
- cmsUInt32Number ProofingIntent,
- cmsUInt32Number dwFlags)
-{
- return cmsCreateProofingTransformTHR(cmsGetProfileContextID(InputProfile),
- InputProfile,
- InputFormat,
- OutputProfile,
- OutputFormat,
- ProofingProfile,
- nIntent,
- ProofingIntent,
- dwFlags);
-}
-
-
-// Grab the ContextID from an open transform. Returns NULL if a NULL transform is passed
-cmsContext CMSEXPORT cmsGetTransformContextID(cmsHTRANSFORM hTransform)
-{
- _cmsTRANSFORM* xform = (_cmsTRANSFORM*) hTransform;
-
- if (xform == NULL) return NULL;
- return xform -> ContextID;
-}
-
-// Grab the input/output formats
-cmsUInt32Number CMSEXPORT cmsGetTransformInputFormat(cmsHTRANSFORM hTransform)
-{
- _cmsTRANSFORM* xform = (_cmsTRANSFORM*) hTransform;
-
- if (xform == NULL) return 0;
- return xform->InputFormat;
-}
-
-cmsUInt32Number CMSEXPORT cmsGetTransformOutputFormat(cmsHTRANSFORM hTransform)
-{
- _cmsTRANSFORM* xform = (_cmsTRANSFORM*) hTransform;
-
- if (xform == NULL) return 0;
- return xform->OutputFormat;
-}
-
-// For backwards compatibility
-cmsBool CMSEXPORT cmsChangeBuffersFormat(cmsHTRANSFORM hTransform,
- cmsUInt32Number InputFormat,
- cmsUInt32Number OutputFormat)
-{
- _cmsTRANSFORM* xform = (_cmsTRANSFORM*) hTransform;
- cmsFormatter16 FromInput, ToOutput;
-
-
- // We only can afford to change formatters if previous transform is at least 16 bits
- if (!(xform ->dwOriginalFlags & cmsFLAGS_CAN_CHANGE_FORMATTER)) {
-
- cmsSignalError(xform ->ContextID, cmsERROR_NOT_SUITABLE, "cmsChangeBuffersFormat works only on transforms created originally with at least 16 bits of precision");
- return FALSE;
- }
-
- FromInput = _cmsGetFormatter(xform->ContextID, InputFormat, cmsFormatterInput, CMS_PACK_FLAGS_16BITS).Fmt16;
- ToOutput = _cmsGetFormatter(xform->ContextID, OutputFormat, cmsFormatterOutput, CMS_PACK_FLAGS_16BITS).Fmt16;
-
- if (FromInput == NULL || ToOutput == NULL) {
-
- cmsSignalError(xform -> ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unsupported raster format");
- return FALSE;
- }
-
- xform ->InputFormat = InputFormat;
- xform ->OutputFormat = OutputFormat;
- xform ->FromInput = FromInput;
- xform ->ToOutput = ToOutput;
- return TRUE;
-}
diff --git a/contrib/libs/lcms2/src/lcms2_internal.h b/contrib/libs/lcms2/src/lcms2_internal.h
deleted file mode 100644
index 8e78a71e6e..0000000000
--- a/contrib/libs/lcms2/src/lcms2_internal.h
+++ /dev/null
@@ -1,1157 +0,0 @@
-
-//
-// Little Color Management System
-// Copyright (c) 1998-2023 Marti Maria Saguer
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//---------------------------------------------------------------------------------
-//
-
-#ifndef _lcms_internal_H
-
-// Include plug-in foundation
-#ifndef _lcms_plugin_H
-# include "lcms2_plugin.h"
-#endif
-
-// ctype is part of C99 as per 7.1.2
-#include <ctype.h>
-
-// assert macro is part of C99 as per 7.2
-#include <assert.h>
-
-// Some needed constants
-#ifndef M_PI
-# define M_PI 3.14159265358979323846
-#endif
-
-#ifndef M_LOG10E
-# define M_LOG10E 0.434294481903251827651
-#endif
-
-// BorlandC 5.5, VC2003 are broken on that
-#if defined(__BORLANDC__) || (defined(_MSC_VER) && (_MSC_VER < 1400)) // 1400 == VC++ 8.0
-#define sinf(x) (float)sin((float)x)
-#define sqrtf(x) (float)sqrt((float)x)
-#endif
-
-
-// Alignment of ICC file format uses 4 bytes (cmsUInt32Number)
-#define _cmsALIGNLONG(x) (((x)+(sizeof(cmsUInt32Number)-1)) & ~(sizeof(cmsUInt32Number)-1))
-
-// Alignment to memory pointer
-
-// (Ultra)SPARC with gcc requires ptr alignment of 8 bytes
-// even though sizeof(void *) is only four: for greatest flexibility
-// allow the build to specify ptr alignment.
-#ifndef CMS_PTR_ALIGNMENT
-# define CMS_PTR_ALIGNMENT sizeof(void *)
-#endif
-
-#define _cmsALIGNMEM(x) (((x)+(CMS_PTR_ALIGNMENT - 1)) & ~(CMS_PTR_ALIGNMENT - 1))
-
-// Maximum encodeable values in floating point
-#define MAX_ENCODEABLE_XYZ (1.0 + 32767.0/32768.0)
-#define MIN_ENCODEABLE_ab2 (-128.0)
-#define MAX_ENCODEABLE_ab2 ((65535.0/256.0) - 128.0)
-#define MIN_ENCODEABLE_ab4 (-128.0)
-#define MAX_ENCODEABLE_ab4 (127.0)
-
-// Maximum of channels for internal pipeline evaluation
-#define MAX_STAGE_CHANNELS 128
-
-// Unused parameter warning suppression
-#define cmsUNUSED_PARAMETER(x) ((void)x)
-
-// The specification for "inline" is section 6.7.4 of the C99 standard (ISO/IEC 9899:1999).
-// unfortunately VisualC++ does not conform that
-#if defined(_MSC_VER) || defined(__BORLANDC__)
-# define cmsINLINE __inline
-#else
-# define cmsINLINE static inline
-#endif
-
-// Allow signed overflow, we know this is harmless in this particular context
-#if defined(__clang__)
-# define CMS_NO_SANITIZE __attribute__((no_sanitize("signed-integer-overflow")))
-#else
-# define CMS_NO_SANITIZE
-#endif
-
-// Other replacement functions
-#ifdef _MSC_VER
-# ifndef snprintf
-# define snprintf _snprintf
-# endif
-# ifndef vsnprintf
-# define vsnprintf _vsnprintf
-# endif
-
-/// Properly define some macros to accommodate
-/// older MSVC versions.
-# if defined(_MSC_VER) && _MSC_VER <= 1700
- #include <float.h>
- #define isnan _isnan
- #define isinf(x) (!_finite((x)))
-# endif
-
-#if !defined(_MSC_VER) && (defined(__STDC_VERSION__) && __STDC_VERSION__ < 199901L)
- #if !defined(isinf)
- #define isinf(x) (!finite((x)))
- #endif
-#endif
-
-
-#endif
-
-// A fast way to convert from/to 16 <-> 8 bits
-#define FROM_8_TO_16(rgb) (cmsUInt16Number) ((((cmsUInt16Number) (rgb)) << 8)|(rgb))
-#define FROM_16_TO_8(rgb) (cmsUInt8Number) ((((cmsUInt32Number)(rgb) * 65281U + 8388608U) >> 24) & 0xFFU)
-
-// Code analysis is broken on asserts
-#ifdef _MSC_VER
-# if (_MSC_VER >= 1500)
-# define _cmsAssert(a) { assert((a)); __analysis_assume((a)); }
-# else
-# define _cmsAssert(a) assert((a))
-# endif
-#else
-# define _cmsAssert(a) assert((a))
-#endif
-
-//---------------------------------------------------------------------------------
-
-// Determinant lower than that are assumed zero (used on matrix invert)
-#define MATRIX_DET_TOLERANCE 0.0001
-
-//---------------------------------------------------------------------------------
-
-// Fixed point
-#define FIXED_TO_INT(x) ((x)>>16)
-#define FIXED_REST_TO_INT(x) ((x)&0xFFFFU)
-#define ROUND_FIXED_TO_INT(x) (((x)+0x8000)>>16)
-
-cmsINLINE cmsS15Fixed16Number _cmsToFixedDomain(int a) { return a + ((a + 0x7fff) / 0xffff); }
-cmsINLINE int _cmsFromFixedDomain(cmsS15Fixed16Number a) { return a - ((a + 0x7fff) >> 16); }
-
-// -----------------------------------------------------------------------------------------------------------
-
-// Fast floor conversion logic. Thanks to Sree Kotay and Stuart Nixon
-// note than this only works in the range ..-32767...+32767 because
-// mantissa is interpreted as 15.16 fixed point.
-// The union is to avoid pointer aliasing overoptimization.
-cmsINLINE int _cmsQuickFloor(cmsFloat64Number val)
-{
-#ifdef CMS_DONT_USE_FAST_FLOOR
- return (int) floor(val);
-#else
- const cmsFloat64Number _lcms_double2fixmagic = 68719476736.0 * 1.5; // 2^36 * 1.5, (52-16=36) uses limited precision to floor
- union {
- cmsFloat64Number val;
- int halves[2];
- } temp;
-
- temp.val = val + _lcms_double2fixmagic;
-
-#ifdef CMS_USE_BIG_ENDIAN
- return temp.halves[1] >> 16;
-#else
- return temp.halves[0] >> 16;
-#endif
-#endif
-}
-
-// Fast floor restricted to 0..65535.0
-cmsINLINE cmsUInt16Number _cmsQuickFloorWord(cmsFloat64Number d)
-{
- return (cmsUInt16Number) _cmsQuickFloor(d - 32767.0) + 32767U;
-}
-
-// Floor to word, taking care of saturation
-cmsINLINE cmsUInt16Number _cmsQuickSaturateWord(cmsFloat64Number d)
-{
- d += 0.5;
- if (d <= 0) return 0;
- if (d >= 65535.0) return 0xffff;
-
- return _cmsQuickFloorWord(d);
-}
-
-// Test bed entry points---------------------------------------------------------------
-#define CMSCHECKPOINT CMSAPI
-
-// Pthread support --------------------------------------------------------------------
-#ifndef CMS_NO_PTHREADS
-
-// This is the threading support. Unfortunately, it has to be platform-dependent because
-// windows does not support pthreads.
-#ifdef CMS_IS_WINDOWS_
-
-#define WIN32_LEAN_AND_MEAN 1
-#include <windows.h>
-
-
-// The locking scheme in LCMS requires a single 'top level' mutex
-// to work. This is actually implemented on Windows as a
-// CriticalSection, because they are lighter weight. With
-// pthreads, this is statically inited. Unfortunately, windows
-// can't officially statically init critical sections.
-//
-// We can work around this in 2 ways.
-//
-// 1) We can use a proper mutex purely to protect the init
-// of the CriticalSection. This in turns requires us to protect
-// the Mutex creation, which we can do using the snappily
-// named InterlockedCompareExchangePointer API (present on
-// windows XP and above).
-//
-// 2) In cases where we want to work on pre-Windows XP, we
-// can use an even more horrible hack described below.
-//
-// So why wouldn't we always use 2)? Because not calling
-// the init function for a critical section means it fails
-// testing with ApplicationVerifier (and presumably similar
-// tools).
-//
-// We therefore default to 1, and people who want to be able
-// to run on pre-Windows XP boxes can build with:
-// CMS_RELY_ON_WINDOWS_STATIC_MUTEX_INIT
-// defined. This is automatically set for builds using
-// versions of MSVC that don't have this API available.
-//
-// From: http://locklessinc.com/articles/pthreads_on_windows/
-// The pthreads API has an initialization macro that has no correspondence to anything in
-// the windows API. By investigating the internal definition of the critical section type,
-// one may work out how to initialize one without calling InitializeCriticalSection().
-// The trick here is that InitializeCriticalSection() is not allowed to fail. It tries
-// to allocate a critical section debug object, but if no memory is available, it sets
-// the pointer to a specific value. (One would expect that value to be NULL, but it is
-// actually (void *)-1 for some reason.) Thus we can use this special value for that
-// pointer, and the critical section code will work.
-
-// The other important part of the critical section type to initialize is the number
-// of waiters. This controls whether or not the mutex is locked. Fortunately, this
-// part of the critical section is unlikely to change. Apparently, many programs
-// already test critical sections to see if they are locked using this value, so
-// Microsoft felt that it was necessary to keep it set at -1 for an unlocked critical
-// section, even when they changed the underlying algorithm to be more scalable.
-// The final parts of the critical section object are unimportant, and can be set
-// to zero for their defaults. This yields to an initialization macro:
-
-typedef CRITICAL_SECTION _cmsMutex;
-
-#ifdef _MSC_VER
-# if (_MSC_VER >= 1800)
-# pragma warning(disable : 26135)
-# pragma warning(disable : 4127)
-# endif
-#endif
-
-#ifndef CMS_RELY_ON_WINDOWS_STATIC_MUTEX_INIT
-// If we are building with a version of MSVC smaller
-// than 1400 (i.e. before VS2005) then we don't have
-// the InterlockedCompareExchangePointer API, so use
-// the old version.
-# ifdef _MSC_VER
-# if _MSC_VER < 1400
-# define CMS_RELY_ON_WINDOWS_STATIC_MUTEX_INIT
-# endif
-# endif
-#endif
-
-#ifdef CMS_RELY_ON_WINDOWS_STATIC_MUTEX_INIT
-# define CMS_MUTEX_INITIALIZER {(PRTL_CRITICAL_SECTION_DEBUG) -1,-1,0,0,0,0}
-#else
-# define CMS_MUTEX_INITIALIZER {(PRTL_CRITICAL_SECTION_DEBUG)NULL,-1,0,0,0,0}
-#endif
-
-cmsINLINE int _cmsLockPrimitive(_cmsMutex *m)
-{
- EnterCriticalSection(m);
- return 0;
-}
-
-cmsINLINE int _cmsUnlockPrimitive(_cmsMutex *m)
-{
- LeaveCriticalSection(m);
- return 0;
-}
-
-cmsINLINE int _cmsInitMutexPrimitive(_cmsMutex *m)
-{
- InitializeCriticalSection(m);
- return 0;
-}
-
-cmsINLINE int _cmsDestroyMutexPrimitive(_cmsMutex *m)
-{
- DeleteCriticalSection(m);
- return 0;
-}
-
-cmsINLINE int _cmsEnterCriticalSectionPrimitive(_cmsMutex *m)
-{
- EnterCriticalSection(m);
- return 0;
-}
-
-cmsINLINE int _cmsLeaveCriticalSectionPrimitive(_cmsMutex *m)
-{
- LeaveCriticalSection(m);
- return 0;
-}
-
-#else
-
-// Rest of the wide world
-#include <pthread.h>
-
-#define CMS_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
-typedef pthread_mutex_t _cmsMutex;
-
-
-cmsINLINE int _cmsLockPrimitive(_cmsMutex *m)
-{
- return pthread_mutex_lock(m);
-}
-
-cmsINLINE int _cmsUnlockPrimitive(_cmsMutex *m)
-{
- return pthread_mutex_unlock(m);
-}
-
-cmsINLINE int _cmsInitMutexPrimitive(_cmsMutex *m)
-{
- return pthread_mutex_init(m, NULL);
-}
-
-cmsINLINE int _cmsDestroyMutexPrimitive(_cmsMutex *m)
-{
- return pthread_mutex_destroy(m);
-}
-
-cmsINLINE int _cmsEnterCriticalSectionPrimitive(_cmsMutex *m)
-{
- return pthread_mutex_lock(m);
-}
-
-cmsINLINE int _cmsLeaveCriticalSectionPrimitive(_cmsMutex *m)
-{
- return pthread_mutex_unlock(m);
-}
-
-#endif
-#else
-
-#define CMS_MUTEX_INITIALIZER 0
-typedef int _cmsMutex;
-
-
-cmsINLINE int _cmsLockPrimitive(_cmsMutex *m)
-{
- cmsUNUSED_PARAMETER(m);
- return 0;
-}
-
-cmsINLINE int _cmsUnlockPrimitive(_cmsMutex *m)
-{
- cmsUNUSED_PARAMETER(m);
- return 0;
-}
-
-cmsINLINE int _cmsInitMutexPrimitive(_cmsMutex *m)
-{
- cmsUNUSED_PARAMETER(m);
- return 0;
-}
-
-cmsINLINE int _cmsDestroyMutexPrimitive(_cmsMutex *m)
-{
- cmsUNUSED_PARAMETER(m);
- return 0;
-}
-
-cmsINLINE int _cmsEnterCriticalSectionPrimitive(_cmsMutex *m)
-{
- cmsUNUSED_PARAMETER(m);
- return 0;
-}
-
-cmsINLINE int _cmsLeaveCriticalSectionPrimitive(_cmsMutex *m)
-{
- cmsUNUSED_PARAMETER(m);
- return 0;
-}
-#endif
-
-// Plug-In registration ---------------------------------------------------------------
-
-// Specialized function for plug-in memory management. No pairing free() since whole pool is freed at once.
-void* _cmsPluginMalloc(cmsContext ContextID, cmsUInt32Number size);
-
-// Memory management
-cmsBool _cmsRegisterMemHandlerPlugin(cmsContext ContextID, cmsPluginBase* Plugin);
-
-// Interpolation
-cmsBool _cmsRegisterInterpPlugin(cmsContext ContextID, cmsPluginBase* Plugin);
-
-// Parametric curves
-cmsBool _cmsRegisterParametricCurvesPlugin(cmsContext ContextID, cmsPluginBase* Plugin);
-
-// Formatters management
-cmsBool _cmsRegisterFormattersPlugin(cmsContext ContextID, cmsPluginBase* Plugin);
-
-// Tag type management
-cmsBool _cmsRegisterTagTypePlugin(cmsContext ContextID, cmsPluginBase* Plugin);
-
-// Tag management
-cmsBool _cmsRegisterTagPlugin(cmsContext ContextID, cmsPluginBase* Plugin);
-
-// Intent management
-cmsBool _cmsRegisterRenderingIntentPlugin(cmsContext ContextID, cmsPluginBase* Plugin);
-
-// Multi Process elements
-cmsBool _cmsRegisterMultiProcessElementPlugin(cmsContext ContextID, cmsPluginBase* Plugin);
-
-// Optimization
-cmsBool _cmsRegisterOptimizationPlugin(cmsContext ContextID, cmsPluginBase* Plugin);
-
-// Transform
-cmsBool _cmsRegisterTransformPlugin(cmsContext ContextID, cmsPluginBase* Plugin);
-
-// Mutex
-cmsBool _cmsRegisterMutexPlugin(cmsContext ContextID, cmsPluginBase* Plugin);
-
-// Paralellization
-cmsBool _cmsRegisterParallelizationPlugin(cmsContext ContextID, cmsPluginBase* Plugin);
-
-// ---------------------------------------------------------------------------------------------------------
-
-// Suballocators.
-typedef struct _cmsSubAllocator_chunk_st {
-
- cmsUInt8Number* Block;
- cmsUInt32Number BlockSize;
- cmsUInt32Number Used;
-
- struct _cmsSubAllocator_chunk_st* next;
-
-} _cmsSubAllocator_chunk;
-
-
-typedef struct {
-
- cmsContext ContextID;
- _cmsSubAllocator_chunk* h;
-
-} _cmsSubAllocator;
-
-
-_cmsSubAllocator* _cmsCreateSubAlloc(cmsContext ContextID, cmsUInt32Number Initial);
-void _cmsSubAllocDestroy(_cmsSubAllocator* s);
-void* _cmsSubAlloc(_cmsSubAllocator* s, cmsUInt32Number size);
-void* _cmsSubAllocDup(_cmsSubAllocator* s, const void *ptr, cmsUInt32Number size);
-
-// ----------------------------------------------------------------------------------
-
-// The context clients.
-typedef enum {
-
- UserPtr, // User-defined pointer
- Logger,
- AlarmCodesContext,
- AdaptationStateContext,
- MemPlugin,
- InterpPlugin,
- CurvesPlugin,
- FormattersPlugin,
- TagTypePlugin,
- TagPlugin,
- IntentPlugin,
- MPEPlugin,
- OptimizationPlugin,
- TransformPlugin,
- MutexPlugin,
- ParallelizationPlugin,
-
- // Last in list
- MemoryClientMax
-
-} _cmsMemoryClient;
-
-
-// Container for memory management plug-in.
-typedef struct {
-
- _cmsMallocFnPtrType MallocPtr;
- _cmsMalloZerocFnPtrType MallocZeroPtr;
- _cmsFreeFnPtrType FreePtr;
- _cmsReallocFnPtrType ReallocPtr;
- _cmsCallocFnPtrType CallocPtr;
- _cmsDupFnPtrType DupPtr;
-
-} _cmsMemPluginChunkType;
-
-// Copy memory management function pointers from plug-in to chunk, taking care of missing routines
-void _cmsInstallAllocFunctions(cmsPluginMemHandler* Plugin, _cmsMemPluginChunkType* ptr);
-
-// Internal structure for context
-struct _cmsContext_struct {
-
- struct _cmsContext_struct* Next; // Points to next context in the new style
- _cmsSubAllocator* MemPool; // The memory pool that stores context data
-
- void* chunks[MemoryClientMax]; // array of pointers to client chunks. Memory itself is held in the suballocator.
- // If NULL, then it reverts to global Context0
-
- _cmsMemPluginChunkType DefaultMemoryManager; // The allocators used for creating the context itself. Cannot be overridden
-};
-
-// Returns a pointer to a valid context structure, including the global one if id is zero.
-// Verifies the magic number.
-struct _cmsContext_struct* _cmsGetContext(cmsContext ContextID);
-
-// Returns the block assigned to the specific zone.
-void* _cmsContextGetClientChunk(cmsContext id, _cmsMemoryClient mc);
-
-
-// Chunks of context memory by plug-in client -------------------------------------------------------
-
-// Those structures encapsulates all variables needed by the several context clients (mostly plug-ins)
-
-// Container for error logger -- not a plug-in
-typedef struct {
-
- cmsLogErrorHandlerFunction LogErrorHandler; // Set to NULL for Context0 fallback
-
-} _cmsLogErrorChunkType;
-
-// The global Context0 storage for error logger
-extern _cmsLogErrorChunkType _cmsLogErrorChunk;
-
-// Allocate and init error logger container.
-void _cmsAllocLogErrorChunk(struct _cmsContext_struct* ctx,
- const struct _cmsContext_struct* src);
-
-// Container for alarm codes -- not a plug-in
-typedef struct {
-
- cmsUInt16Number AlarmCodes[cmsMAXCHANNELS];
-
-} _cmsAlarmCodesChunkType;
-
-// The global Context0 storage for alarm codes
-extern _cmsAlarmCodesChunkType _cmsAlarmCodesChunk;
-
-// Allocate and init alarm codes container.
-void _cmsAllocAlarmCodesChunk(struct _cmsContext_struct* ctx,
- const struct _cmsContext_struct* src);
-
-// Container for adaptation state -- not a plug-in
-typedef struct {
-
- cmsFloat64Number AdaptationState;
-
-} _cmsAdaptationStateChunkType;
-
-// The global Context0 storage for adaptation state
-extern _cmsAdaptationStateChunkType _cmsAdaptationStateChunk;
-
-// Allocate and init adaptation state container.
-void _cmsAllocAdaptationStateChunk(struct _cmsContext_struct* ctx,
- const struct _cmsContext_struct* src);
-
-
-// The global Context0 storage for memory management
-extern _cmsMemPluginChunkType _cmsMemPluginChunk;
-
-// Allocate and init memory management container.
-void _cmsAllocMemPluginChunk(struct _cmsContext_struct* ctx,
- const struct _cmsContext_struct* src);
-
-// Container for interpolation plug-in
-typedef struct {
-
- cmsInterpFnFactory Interpolators;
-
-} _cmsInterpPluginChunkType;
-
-// The global Context0 storage for interpolation plug-in
-extern _cmsInterpPluginChunkType _cmsInterpPluginChunk;
-
-// Allocate and init interpolation container.
-void _cmsAllocInterpPluginChunk(struct _cmsContext_struct* ctx,
- const struct _cmsContext_struct* src);
-
-// Container for parametric curves plug-in
-typedef struct {
-
- struct _cmsParametricCurvesCollection_st* ParametricCurves;
-
-} _cmsCurvesPluginChunkType;
-
-// The global Context0 storage for tone curves plug-in
-extern _cmsCurvesPluginChunkType _cmsCurvesPluginChunk;
-
-// Allocate and init parametric curves container.
-void _cmsAllocCurvesPluginChunk(struct _cmsContext_struct* ctx,
- const struct _cmsContext_struct* src);
-
-// Container for formatters plug-in
-typedef struct {
-
- struct _cms_formatters_factory_list* FactoryList;
-
-} _cmsFormattersPluginChunkType;
-
-// The global Context0 storage for formatters plug-in
-extern _cmsFormattersPluginChunkType _cmsFormattersPluginChunk;
-
-// Allocate and init formatters container.
-void _cmsAllocFormattersPluginChunk(struct _cmsContext_struct* ctx,
- const struct _cmsContext_struct* src);
-
-// This chunk type is shared by TagType plug-in and MPE Plug-in
-typedef struct {
-
- struct _cmsTagTypeLinkedList_st* TagTypes;
-
-} _cmsTagTypePluginChunkType;
-
-
-// The global Context0 storage for tag types plug-in
-extern _cmsTagTypePluginChunkType _cmsTagTypePluginChunk;
-
-
-// The global Context0 storage for mult process elements plug-in
-extern _cmsTagTypePluginChunkType _cmsMPETypePluginChunk;
-
-// Allocate and init Tag types container.
-void _cmsAllocTagTypePluginChunk(struct _cmsContext_struct* ctx,
- const struct _cmsContext_struct* src);
-// Allocate and init MPE container.
-void _cmsAllocMPETypePluginChunk(struct _cmsContext_struct* ctx,
- const struct _cmsContext_struct* src);
-// Container for tag plug-in
-typedef struct {
-
- struct _cmsTagLinkedList_st* Tag;
-
-} _cmsTagPluginChunkType;
-
-
-// The global Context0 storage for tag plug-in
-extern _cmsTagPluginChunkType _cmsTagPluginChunk;
-
-// Allocate and init Tag container.
-void _cmsAllocTagPluginChunk(struct _cmsContext_struct* ctx,
- const struct _cmsContext_struct* src);
-
-// Container for intents plug-in
-typedef struct {
-
- struct _cms_intents_list* Intents;
-
-} _cmsIntentsPluginChunkType;
-
-
-// The global Context0 storage for intents plug-in
-extern _cmsIntentsPluginChunkType _cmsIntentsPluginChunk;
-
-// Allocate and init intents container.
-void _cmsAllocIntentsPluginChunk(struct _cmsContext_struct* ctx,
- const struct _cmsContext_struct* src);
-
-// Container for optimization plug-in
-typedef struct {
-
- struct _cmsOptimizationCollection_st* OptimizationCollection;
-
-} _cmsOptimizationPluginChunkType;
-
-
-// The global Context0 storage for optimizers plug-in
-extern _cmsOptimizationPluginChunkType _cmsOptimizationPluginChunk;
-
-// Allocate and init optimizers container.
-void _cmsAllocOptimizationPluginChunk(struct _cmsContext_struct* ctx,
- const struct _cmsContext_struct* src);
-
-// Container for transform plug-in
-typedef struct {
-
- struct _cmsTransformCollection_st* TransformCollection;
-
-} _cmsTransformPluginChunkType;
-
-// The global Context0 storage for full-transform replacement plug-in
-extern _cmsTransformPluginChunkType _cmsTransformPluginChunk;
-
-// Allocate and init transform container.
-void _cmsAllocTransformPluginChunk(struct _cmsContext_struct* ctx,
- const struct _cmsContext_struct* src);
-
-// Container for mutex plug-in
-typedef struct {
-
- _cmsCreateMutexFnPtrType CreateMutexPtr;
- _cmsDestroyMutexFnPtrType DestroyMutexPtr;
- _cmsLockMutexFnPtrType LockMutexPtr;
- _cmsUnlockMutexFnPtrType UnlockMutexPtr;
-
-} _cmsMutexPluginChunkType;
-
-// The global Context0 storage for mutex plug-in
-extern _cmsMutexPluginChunkType _cmsMutexPluginChunk;
-
-// Allocate and init mutex container.
-void _cmsAllocMutexPluginChunk(struct _cmsContext_struct* ctx,
- const struct _cmsContext_struct* src);
-
-// Container for parallelization plug-in
-typedef struct {
-
- cmsInt32Number MaxWorkers; // Number of workers to do as maximum
- cmsInt32Number WorkerFlags; // reserved
- _cmsTransform2Fn SchedulerFn; // callback to setup functions
-
-} _cmsParallelizationPluginChunkType;
-
-// The global Context0 storage for parallelization plug-in
-extern _cmsParallelizationPluginChunkType _cmsParallelizationPluginChunk;
-
-// Allocate parallelization container.
-void _cmsAllocParallelizationPluginChunk(struct _cmsContext_struct* ctx,
- const struct _cmsContext_struct* src);
-
-
-
-// ----------------------------------------------------------------------------------
-// MLU internal representation
-typedef struct {
-
- cmsUInt16Number Language;
- cmsUInt16Number Country;
-
- cmsUInt32Number StrW; // Offset to current unicode string
- cmsUInt32Number Len; // Length in bytes
-
-} _cmsMLUentry;
-
-struct _cms_MLU_struct {
-
- cmsContext ContextID;
-
- // The directory
- cmsUInt32Number AllocatedEntries;
- cmsUInt32Number UsedEntries;
- _cmsMLUentry* Entries; // Array of pointers to strings allocated in MemPool
-
- // The Pool
- cmsUInt32Number PoolSize; // The maximum allocated size
- cmsUInt32Number PoolUsed; // The used size
- void* MemPool; // Pointer to begin of memory pool
-};
-
-// Named color list internal representation
-typedef struct {
-
- char Name[cmsMAX_PATH];
- cmsUInt16Number PCS[3];
- cmsUInt16Number DeviceColorant[cmsMAXCHANNELS];
-
-} _cmsNAMEDCOLOR;
-
-struct _cms_NAMEDCOLORLIST_struct {
-
- cmsUInt32Number nColors;
- cmsUInt32Number Allocated;
- cmsUInt32Number ColorantCount;
-
- char Prefix[33]; // Prefix and suffix are defined to be 32 characters at most
- char Suffix[33];
-
- _cmsNAMEDCOLOR* List;
-
- cmsContext ContextID;
-};
-
-
-// ----------------------------------------------------------------------------------
-
-// This is the internal struct holding profile details.
-
-// Maximum supported tags in a profile
-#define MAX_TABLE_TAG 100
-
-typedef struct _cms_iccprofile_struct {
-
- // I/O handler
- cmsIOHANDLER* IOhandler;
-
- // The thread ID
- cmsContext ContextID;
-
- // Creation time
- struct tm Created;
-
- // Color management module identification
- cmsUInt32Number CMM;
-
- // Only most important items found in ICC profiles
- cmsUInt32Number Version;
- cmsProfileClassSignature DeviceClass;
- cmsColorSpaceSignature ColorSpace;
- cmsColorSpaceSignature PCS;
- cmsUInt32Number RenderingIntent;
-
- cmsPlatformSignature platform;
- cmsUInt32Number flags;
- cmsUInt32Number manufacturer, model;
- cmsUInt64Number attributes;
- cmsUInt32Number creator;
-
- cmsProfileID ProfileID;
-
- // Dictionary
- cmsUInt32Number TagCount;
- cmsTagSignature TagNames[MAX_TABLE_TAG];
- cmsTagSignature TagLinked[MAX_TABLE_TAG]; // The tag to which is linked (0=none)
- cmsUInt32Number TagSizes[MAX_TABLE_TAG]; // Size on disk
- cmsUInt32Number TagOffsets[MAX_TABLE_TAG];
- cmsBool TagSaveAsRaw[MAX_TABLE_TAG]; // True to write uncooked
- void * TagPtrs[MAX_TABLE_TAG];
- cmsTagTypeHandler* TagTypeHandlers[MAX_TABLE_TAG]; // Same structure may be serialized on different types
- // depending on profile version, so we keep track of the
- // type handler for each tag in the list.
- // Special
- cmsBool IsWrite;
-
- // Keep a mutex for cmsReadTag -- Note that this only works if the user includes a mutex plugin
- void * UsrMutex;
-
-} _cmsICCPROFILE;
-
-// IO helpers for profiles
-cmsBool _cmsReadHeader(_cmsICCPROFILE* Icc);
-cmsBool _cmsWriteHeader(_cmsICCPROFILE* Icc, cmsUInt32Number UsedSpace);
-int _cmsSearchTag(_cmsICCPROFILE* Icc, cmsTagSignature sig, cmsBool lFollowLinks);
-
-// Tag types
-cmsTagTypeHandler* _cmsGetTagTypeHandler(cmsContext ContextID, cmsTagTypeSignature sig);
-cmsTagTypeSignature _cmsGetTagTrueType(cmsHPROFILE hProfile, cmsTagSignature sig);
-cmsTagDescriptor* _cmsGetTagDescriptor(cmsContext ContextID, cmsTagSignature sig);
-
-// Error logging ---------------------------------------------------------------------------------------------------------
-
-void _cmsTagSignature2String(char String[5], cmsTagSignature sig);
-
-// Interpolation ---------------------------------------------------------------------------------------------------------
-
-CMSCHECKPOINT cmsInterpParams* CMSEXPORT _cmsComputeInterpParams(cmsContext ContextID, cmsUInt32Number nSamples, cmsUInt32Number InputChan, cmsUInt32Number OutputChan, const void* Table, cmsUInt32Number dwFlags);
-cmsInterpParams* _cmsComputeInterpParamsEx(cmsContext ContextID, const cmsUInt32Number nSamples[], cmsUInt32Number InputChan, cmsUInt32Number OutputChan, const void* Table, cmsUInt32Number dwFlags);
-CMSCHECKPOINT void CMSEXPORT _cmsFreeInterpParams(cmsInterpParams* p);
-cmsBool _cmsSetInterpolationRoutine(cmsContext ContextID, cmsInterpParams* p);
-
-// Curves ----------------------------------------------------------------------------------------------------------------
-
-// This struct holds information about a segment, plus a pointer to the function that implements the evaluation.
-// In the case of table-based, Eval pointer is set to NULL
-
-// The gamma function main structure
-struct _cms_curve_struct {
-
- cmsInterpParams* InterpParams; // Private optimizations for interpolation
-
- cmsUInt32Number nSegments; // Number of segments in the curve. Zero for a 16-bit based tables
- cmsCurveSegment* Segments; // The segments
- cmsInterpParams** SegInterp; // Array of private optimizations for interpolation in table-based segments
-
- cmsParametricCurveEvaluator* Evals; // Evaluators (one per segment)
-
- // 16 bit Table-based representation follows
- cmsUInt32Number nEntries; // Number of table elements
- cmsUInt16Number* Table16; // The table itself.
-};
-
-
-// Pipelines & Stages ---------------------------------------------------------------------------------------------
-
-// A single stage
-struct _cmsStage_struct {
-
- cmsContext ContextID;
-
- cmsStageSignature Type; // Identifies the stage
- cmsStageSignature Implements; // Identifies the *function* of the stage (for optimizations)
-
- cmsUInt32Number InputChannels; // Input channels -- for optimization purposes
- cmsUInt32Number OutputChannels; // Output channels -- for optimization purposes
-
- _cmsStageEvalFn EvalPtr; // Points to fn that evaluates the stage (always in floating point)
- _cmsStageDupElemFn DupElemPtr; // Points to a fn that duplicates the *data* of the stage
- _cmsStageFreeElemFn FreePtr; // Points to a fn that sets the *data* of the stage free
-
- // A generic pointer to whatever memory needed by the stage
- void* Data;
-
- // Maintains linked list (used internally)
- struct _cmsStage_struct* Next;
-};
-
-
-// Special Stages (cannot be saved)
-CMSCHECKPOINT cmsStage* CMSEXPORT _cmsStageAllocLab2XYZ(cmsContext ContextID);
-CMSCHECKPOINT cmsStage* CMSEXPORT _cmsStageAllocXYZ2Lab(cmsContext ContextID);
-cmsStage* _cmsStageAllocLabPrelin(cmsContext ContextID);
-CMSCHECKPOINT cmsStage* CMSEXPORT _cmsStageAllocLabV2ToV4(cmsContext ContextID);
-cmsStage* _cmsStageAllocLabV2ToV4curves(cmsContext ContextID);
-CMSCHECKPOINT cmsStage* CMSEXPORT _cmsStageAllocLabV4ToV2(cmsContext ContextID);
-CMSCHECKPOINT cmsStage* CMSEXPORT _cmsStageAllocNamedColor(cmsNAMEDCOLORLIST* NamedColorList, cmsBool UsePCS);
-CMSCHECKPOINT cmsStage* CMSEXPORT _cmsStageAllocIdentityCurves(cmsContext ContextID, cmsUInt32Number nChannels);
-CMSCHECKPOINT cmsStage* CMSEXPORT _cmsStageAllocIdentityCLut(cmsContext ContextID, cmsUInt32Number nChan);
-cmsStage* _cmsStageNormalizeFromLabFloat(cmsContext ContextID);
-cmsStage* _cmsStageNormalizeFromXyzFloat(cmsContext ContextID);
-cmsStage* _cmsStageNormalizeToLabFloat(cmsContext ContextID);
-cmsStage* _cmsStageNormalizeToXyzFloat(cmsContext ContextID);
-cmsStage* _cmsStageClipNegatives(cmsContext ContextID, cmsUInt32Number nChannels);
-
-
-// For curve set only
-cmsToneCurve** _cmsStageGetPtrToCurveSet(const cmsStage* mpe);
-
-struct _cmsPipeline_struct {
-
- cmsStage* Elements; // Points to elements chain
- cmsUInt32Number InputChannels, OutputChannels;
-
- // Data & evaluators
- void *Data;
-
- _cmsPipelineEval16Fn Eval16Fn;
- _cmsPipelineEvalFloatFn EvalFloatFn;
- _cmsFreeUserDataFn FreeDataFn;
- _cmsDupUserDataFn DupDataFn;
-
- cmsContext ContextID; // Environment
-
- cmsBool SaveAs8Bits; // Implementation-specific: save as 8 bits if possible
-};
-
-// LUT reading & creation -------------------------------------------------------------------------------------------
-
-// Read tags using low-level function, provide necessary glue code to adapt versions, etc. All those return a brand new copy
-// of the LUTS, since ownership of original is up to the profile. The user should free allocated resources.
-
-CMSCHECKPOINT cmsPipeline* CMSEXPORT _cmsReadInputLUT(cmsHPROFILE hProfile, cmsUInt32Number Intent);
-CMSCHECKPOINT cmsPipeline* CMSEXPORT _cmsReadOutputLUT(cmsHPROFILE hProfile, cmsUInt32Number Intent);
-CMSCHECKPOINT cmsPipeline* CMSEXPORT _cmsReadDevicelinkLUT(cmsHPROFILE hProfile, cmsUInt32Number Intent);
-
-// Special values
-cmsBool _cmsReadMediaWhitePoint(cmsCIEXYZ* Dest, cmsHPROFILE hProfile);
-cmsBool _cmsReadCHAD(cmsMAT3* Dest, cmsHPROFILE hProfile);
-
-// Profile linker --------------------------------------------------------------------------------------------------
-
-// Link several profiles to obtain a single LUT modelling the whole color transform. Intents, Black point
-// compensation and Adaptation parameters may vary across profiles. BPC and Adaptation refers to the PCS
-// after the profile. I.e, BPC[0] refers to connexion between profile(0) and profile(1)
-cmsPipeline* _cmsLinkProfiles(cmsContext ContextID,
- cmsUInt32Number nProfiles,
- cmsUInt32Number TheIntents[],
- cmsHPROFILE hProfiles[],
- cmsBool BPC[],
- cmsFloat64Number AdaptationStates[],
- cmsUInt32Number dwFlags);
-
-// Sequence --------------------------------------------------------------------------------------------------------
-
-cmsSEQ* _cmsReadProfileSequence(cmsHPROFILE hProfile);
-cmsBool _cmsWriteProfileSequence(cmsHPROFILE hProfile, const cmsSEQ* seq);
-cmsSEQ* _cmsCompileProfileSequence(cmsContext ContextID, cmsUInt32Number nProfiles, cmsHPROFILE hProfiles[]);
-
-
-// LUT optimization ------------------------------------------------------------------------------------------------
-
-CMSCHECKPOINT cmsUInt16Number CMSEXPORT _cmsQuantizeVal(cmsFloat64Number i, cmsUInt32Number MaxSamples);
-
-CMSAPI cmsUInt32Number CMSEXPORT _cmsReasonableGridpointsByColorspace(cmsColorSpaceSignature Colorspace, cmsUInt32Number dwFlags);
-
-cmsBool _cmsEndPointsBySpace(cmsColorSpaceSignature Space,
- cmsUInt16Number **White,
- cmsUInt16Number **Black,
- cmsUInt32Number *nOutputs);
-
-CMSAPI cmsBool CMSEXPORT _cmsOptimizePipeline(cmsContext ContextID,
- cmsPipeline** Lut,
- cmsUInt32Number Intent,
- cmsUInt32Number* InputFormat,
- cmsUInt32Number* OutputFormat,
- cmsUInt32Number* dwFlags );
-
-
-// Hi level LUT building ----------------------------------------------------------------------------------------------
-
-cmsPipeline* _cmsCreateGamutCheckPipeline(cmsContext ContextID,
- cmsHPROFILE hProfiles[],
- cmsBool BPC[],
- cmsUInt32Number Intents[],
- cmsFloat64Number AdaptationStates[],
- cmsUInt32Number nGamutPCSposition,
- cmsHPROFILE hGamut);
-
-
-// Formatters ------------------------------------------------------------------------------------------------------------
-
-#define cmsFLAGS_CAN_CHANGE_FORMATTER 0x02000000 // Allow change buffer format
-
-cmsBool _cmsFormatterIsFloat(cmsUInt32Number Type);
-cmsBool _cmsFormatterIs8bit(cmsUInt32Number Type);
-
-CMSCHECKPOINT cmsFormatter CMSEXPORT _cmsGetFormatter(cmsContext ContextID,
- cmsUInt32Number Type, // Specific type, i.e. TYPE_RGB_8
- cmsFormatterDirection Dir,
- cmsUInt32Number dwFlags);
-
-
-#ifndef CMS_NO_HALF_SUPPORT
-
-// Half float
-CMSCHECKPOINT cmsFloat32Number CMSEXPORT _cmsHalf2Float(cmsUInt16Number h);
-CMSCHECKPOINT cmsUInt16Number CMSEXPORT _cmsFloat2Half(cmsFloat32Number flt);
-
-#endif
-
-// Transform logic ------------------------------------------------------------------------------------------------------
-
-struct _cmstransform_struct;
-
-typedef struct {
-
- // 1-pixel cache (16 bits only)
- cmsUInt16Number CacheIn[cmsMAXCHANNELS];
- cmsUInt16Number CacheOut[cmsMAXCHANNELS];
-
-} _cmsCACHE;
-
-
-
-// Transformation
-typedef struct _cmstransform_struct {
-
- cmsUInt32Number InputFormat, OutputFormat; // Keep formats for further reference
-
- // Points to transform code
- _cmsTransform2Fn xform;
-
- // Formatters, cannot be embedded into LUT because cache
- cmsFormatter16 FromInput;
- cmsFormatter16 ToOutput;
-
- cmsFormatterFloat FromInputFloat;
- cmsFormatterFloat ToOutputFloat;
-
- // 1-pixel cache seed for zero as input (16 bits, read only)
- _cmsCACHE Cache;
-
- // A Pipeline holding the full (optimized) transform
- cmsPipeline* Lut;
-
- // A Pipeline holding the gamut check. It goes from the input space to bilevel
- cmsPipeline* GamutCheck;
-
- // Colorant tables
- cmsNAMEDCOLORLIST* InputColorant; // Input Colorant table
- cmsNAMEDCOLORLIST* OutputColorant; // Colorant table (for n chans > CMYK)
-
- // Informational only
- cmsColorSpaceSignature EntryColorSpace;
- cmsColorSpaceSignature ExitColorSpace;
-
- // White points (informative only)
- cmsCIEXYZ EntryWhitePoint;
- cmsCIEXYZ ExitWhitePoint;
-
- // Profiles used to create the transform
- cmsSEQ* Sequence;
-
- cmsUInt32Number dwOriginalFlags;
- cmsFloat64Number AdaptationState;
-
- // The intent of this transform. That is usually the last intent in the profilechain, but may differ
- cmsUInt32Number RenderingIntent;
-
- // An id that uniquely identifies the running context. May be null.
- cmsContext ContextID;
-
- // A user-defined pointer that can be used to store data for transform plug-ins
- void* UserData;
- _cmsFreeUserDataFn FreeUserData;
-
- // A way to provide backwards compatibility with full xform plugins
- _cmsTransformFn OldXform;
-
- // A one-worker transform entry for parallelization
- _cmsTransform2Fn Worker;
- cmsInt32Number MaxWorkers;
- cmsUInt32Number WorkerFlags;
-
-} _cmsTRANSFORM;
-
-// Copies extra channels from input to output if the original flags in the transform structure
-// instructs to do so. This function is called on all standard transform functions.
-void _cmsHandleExtraChannels(_cmsTRANSFORM* p, const void* in,
- void* out,
- cmsUInt32Number PixelsPerLine,
- cmsUInt32Number LineCount,
- const cmsStride* Stride);
-
-// -----------------------------------------------------------------------------------------------------------------------
-
-cmsHTRANSFORM _cmsChain2Lab(cmsContext ContextID,
- cmsUInt32Number nProfiles,
- cmsUInt32Number InputFormat,
- cmsUInt32Number OutputFormat,
- const cmsUInt32Number Intents[],
- const cmsHPROFILE hProfiles[],
- const cmsBool BPC[],
- const cmsFloat64Number AdaptationStates[],
- cmsUInt32Number dwFlags);
-
-
-cmsToneCurve* _cmsBuildKToneCurve(cmsContext ContextID,
- cmsUInt32Number nPoints,
- cmsUInt32Number nProfiles,
- const cmsUInt32Number Intents[],
- const cmsHPROFILE hProfiles[],
- const cmsBool BPC[],
- const cmsFloat64Number AdaptationStates[],
- cmsUInt32Number dwFlags);
-
-cmsBool _cmsAdaptationMatrix(cmsMAT3* r, const cmsMAT3* ConeMatrix, const cmsCIEXYZ* FromIll, const cmsCIEXYZ* ToIll);
-
-cmsBool _cmsBuildRGB2XYZtransferMatrix(cmsMAT3* r, const cmsCIExyY* WhitePoint, const cmsCIExyYTRIPLE* Primaries);
-
-
-// thread-safe gettime
-cmsBool _cmsGetTime(struct tm* ptr_time);
-
-#define _lcms_internal_H
-#endif
diff --git a/contrib/libs/lcms2/utils/common/utils.h b/contrib/libs/lcms2/utils/common/utils.h
deleted file mode 100644
index 3f040f906a..0000000000
--- a/contrib/libs/lcms2/utils/common/utils.h
+++ /dev/null
@@ -1,101 +0,0 @@
-
-//---------------------------------------------------------------------------------
-//
-// Little Color Management System
-// Copyright (c) 1998-2023 Marti Maria Saguer
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//---------------------------------------------------------------------------------
-
-#ifndef _lcms_utils_h
-
-// Deal with Microsoft's attempt at deprecating C standard runtime functions
-#ifdef _MSC_VER
-# if (_MSC_VER >= 1400)
-# ifndef _CRT_SECURE_NO_DEPRECATE
-# define _CRT_SECURE_NO_DEPRECATE
-# endif
-# ifndef _CRT_SECURE_NO_WARNINGS
-# define _CRT_SECURE_NO_WARNINGS
-# endif
-# endif
-#endif
-
-#include "lcms2.h"
-
-#include <string.h>
-#include <stdarg.h>
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <math.h>
-#include <wchar.h>
-
-// Avoid warnings
-
-#define UTILS_UNUSED_PARAMETER(x) ((void)x)
-
-// Init the utility functions
-
-void InitUtils(const char* PName);
-
-// Fatal Error (print the message and exit(1))---------------------------------------------
-
-extern int Verbose;
-
-void FatalError(const char *frm, ...);
-
-// xgetopt() interface -------------------------------------------------------------
-
-extern int xoptind;
-extern char *xoptarg;
-
-int xgetopt(int argc, char *argv[], char *optionS);
-
-// The stock profile utility -------------------------------------------------------
-
-cmsHPROFILE OpenStockProfile(cmsContext ContextID, const char* File);
-
-// The print info utility ----------------------------------------------------------
-
-void PrintProfileInformation(cmsHPROFILE h);
-
-// ---------------------------------------------------------------------------------
-
-void PrintRenderingIntents(void);
-void PrintBuiltins(void);
-
-// ---------------------------------------------------------------------------------
-
-cmsBool SaveMemoryBlock(const cmsUInt8Number* Buffer, cmsUInt32Number dwLen, const char* Filename);
-
-// ---------------------------------------------------------------------------------
-
-// Return a pixel type on depending on the number of channels
-int PixelTypeFromChanCount(int ColorChannels);
-
-// ------------------------------------------------------------------------------
-
-// Return number of channels of pixel type
-int ChanCountFromPixelType(int ColorChannels);
-
-#define _lcms_utils_h
-#endif
diff --git a/contrib/libs/lcms2/utils/common/vprf.c b/contrib/libs/lcms2/utils/common/vprf.c
deleted file mode 100644
index ae23d70483..0000000000
--- a/contrib/libs/lcms2/utils/common/vprf.c
+++ /dev/null
@@ -1,336 +0,0 @@
-//---------------------------------------------------------------------------------
-//
-// Little Color Management System
-// Copyright (c) 1998-2023 Marti Maria Saguer
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//---------------------------------------------------------------------------------
-//
-
-#include "utils.h"
-
-
-int Verbose = 0;
-
-static char ProgramName[256] = "";
-
-void FatalError(const char *frm, ...)
-{
- va_list args;
-
- va_start(args, frm);
- fprintf(stderr, "[%s fatal error]: ", ProgramName);
- vfprintf(stderr, frm, args);
- fprintf(stderr, "\n");
- va_end(args);
-
- exit(1);
-}
-
-// Show errors to the end user (unless quiet option)
-static
-void MyErrorLogHandler(cmsContext ContextID, cmsUInt32Number ErrorCode, const char *Text)
-{
- if (Verbose >= 0)
- fprintf(stderr, "[%s]: %s\n", ProgramName, Text);
-
- UTILS_UNUSED_PARAMETER(ErrorCode);
- UTILS_UNUSED_PARAMETER(ContextID);
-}
-
-
-void InitUtils(const char* PName)
-{
- strncpy(ProgramName, PName, sizeof(ProgramName));
- ProgramName[sizeof(ProgramName)-1] = 0;
-
- cmsSetLogErrorHandler(MyErrorLogHandler);
-}
-
-
-// Virtual profiles are handled here.
-cmsHPROFILE OpenStockProfile(cmsContext ContextID, const char* File)
-{
- if (!File)
- return cmsCreate_sRGBProfileTHR(ContextID);
-
- if (cmsstrcasecmp(File, "*Lab2") == 0)
- return cmsCreateLab2ProfileTHR(ContextID, NULL);
-
- if (cmsstrcasecmp(File, "*Lab4") == 0)
- return cmsCreateLab4ProfileTHR(ContextID, NULL);
-
- if (cmsstrcasecmp(File, "*Lab") == 0)
- return cmsCreateLab4ProfileTHR(ContextID, NULL);
-
- if (cmsstrcasecmp(File, "*LabD65") == 0) {
-
- cmsCIExyY D65xyY;
-
- cmsWhitePointFromTemp( &D65xyY, 6504);
- return cmsCreateLab4ProfileTHR(ContextID, &D65xyY);
- }
-
- if (cmsstrcasecmp(File, "*XYZ") == 0)
- return cmsCreateXYZProfileTHR(ContextID);
-
- if (cmsstrcasecmp(File, "*Gray22") == 0) {
-
- cmsToneCurve* Curve = cmsBuildGamma(ContextID, 2.2);
- cmsHPROFILE hProfile = cmsCreateGrayProfileTHR(ContextID, cmsD50_xyY(), Curve);
- cmsFreeToneCurve(Curve);
- return hProfile;
- }
-
- if (cmsstrcasecmp(File, "*Gray30") == 0) {
-
- cmsToneCurve* Curve = cmsBuildGamma(ContextID, 3.0);
- cmsHPROFILE hProfile = cmsCreateGrayProfileTHR(ContextID, cmsD50_xyY(), Curve);
- cmsFreeToneCurve(Curve);
- return hProfile;
- }
-
- if (cmsstrcasecmp(File, "*srgb") == 0)
- return cmsCreate_sRGBProfileTHR(ContextID);
-
- if (cmsstrcasecmp(File, "*null") == 0)
- return cmsCreateNULLProfileTHR(ContextID);
-
-
- if (cmsstrcasecmp(File, "*Lin2222") == 0) {
-
- cmsToneCurve* Gamma = cmsBuildGamma(0, 2.2);
- cmsToneCurve* Gamma4[4];
- cmsHPROFILE hProfile;
-
- Gamma4[0] = Gamma4[1] = Gamma4[2] = Gamma4[3] = Gamma;
- hProfile = cmsCreateLinearizationDeviceLink(cmsSigCmykData, Gamma4);
- cmsFreeToneCurve(Gamma);
- return hProfile;
- }
-
-
- return cmsOpenProfileFromFileTHR(ContextID, File, "r");
-}
-
-// Help on available built-ins
-void PrintBuiltins(void)
-{
- fprintf(stderr, "\nBuilt-in profiles:\n\n");
- fprintf(stderr, "\t*Lab2 -- D50-based v2 CIEL*a*b\n"
- "\t*Lab4 -- D50-based v4 CIEL*a*b\n"
- "\t*Lab -- D50-based v4 CIEL*a*b\n"
- "\t*XYZ -- CIE XYZ (PCS)\n"
- "\t*sRGB -- sRGB color space\n"
- "\t*Gray22 - Monochrome of Gamma 2.2\n"
- "\t*Gray30 - Monochrome of Gamma 3.0\n"
- "\t*null - Monochrome black for all input\n"
- "\t*Lin2222- CMYK linearization of gamma 2.2 on each channel\n\n");
-}
-
-
-// Auxiliary for printing information on profile
-static
-void PrintInfo(cmsHPROFILE h, cmsInfoType Info)
-{
- char* text;
- int len;
-
- len = cmsGetProfileInfoASCII(h, Info, "en", "US", NULL, 0);
- if (len == 0) return;
-
- text = (char*) malloc(len * sizeof(char));
- if (text == NULL) return;
-
- cmsGetProfileInfoASCII(h, Info, "en", "US", text, len);
-
- if (strlen(text) > 0)
- printf("%s\n", text);
-
- free(text);
-}
-
-
-
-// Displays the colorant table
-static
-void PrintColorantTable(cmsHPROFILE hInput, cmsTagSignature Sig, const char* Title)
-{
- cmsNAMEDCOLORLIST* list;
- int i, n;
-
- if (cmsIsTag(hInput, Sig)) {
-
- printf("%s:\n", Title);
-
- list = (cmsNAMEDCOLORLIST*) cmsReadTag(hInput, Sig);
- if (list == NULL) {
- printf("(Unavailable)\n");
- return;
- }
-
- n = cmsNamedColorCount(list);
- for (i=0; i < n; i++) {
-
- char Name[cmsMAX_PATH];
-
- cmsNamedColorInfo(list, i, Name, NULL, NULL, NULL, NULL);
- printf("\t%s\n", Name);
- }
-
- printf("\n");
- }
-
-}
-
-
-void PrintProfileInformation(cmsHPROFILE hInput)
-{
- if (hInput == NULL) {
- fprintf(stderr, "*Wrong or corrupted profile*\n");
- return;
- }
-
- PrintInfo(hInput, cmsInfoDescription);
- PrintInfo(hInput, cmsInfoManufacturer);
- PrintInfo(hInput, cmsInfoModel);
- PrintInfo(hInput, cmsInfoCopyright);
-
- if (Verbose > 2) {
-
- PrintColorantTable(hInput, cmsSigColorantTableTag, "Input colorant table");
- PrintColorantTable(hInput, cmsSigColorantTableOutTag, "Input colorant out table");
- }
-
- printf("\n");
-}
-
-// -----------------------------------------------------------------------------
-
-
-void PrintRenderingIntents(void)
-{
- cmsUInt32Number Codes[200];
- char* Descriptions[200];
- cmsUInt32Number n, i;
-
- fprintf(stderr, "-t<n> rendering intent:\n\n");
-
- n = cmsGetSupportedIntents(200, Codes, Descriptions);
-
- for (i=0; i < n; i++) {
- fprintf(stderr, "\t%u - %s\n", Codes[i], Descriptions[i]);
- }
- fprintf(stderr, "\n");
-}
-
-
-
-// ------------------------------------------------------------------------------
-
-cmsBool SaveMemoryBlock(const cmsUInt8Number* Buffer, cmsUInt32Number dwLen, const char* Filename)
-{
- FILE* out = fopen(Filename, "wb");
- if (out == NULL) {
- FatalError("Cannot create '%s'", Filename);
- return FALSE;
- }
-
- if (fwrite(Buffer, 1, dwLen, out) != dwLen) {
- FatalError("Cannot write %ld bytes to %s", (long) dwLen, Filename);
- return FALSE;
- }
-
- if (fclose(out) != 0) {
- FatalError("Error flushing file '%s'", Filename);
- return FALSE;
- }
-
- return TRUE;
-}
-
-// ------------------------------------------------------------------------------
-
-// Return a pixel type on depending on the number of channels
-int PixelTypeFromChanCount(int ColorChannels)
-{
- switch (ColorChannels) {
-
- case 1: return PT_GRAY;
- case 2: return PT_MCH2;
- case 3: return PT_MCH3;
- case 4: return PT_CMYK;
- case 5: return PT_MCH5;
- case 6: return PT_MCH6;
- case 7: return PT_MCH7;
- case 8: return PT_MCH8;
- case 9: return PT_MCH9;
- case 10: return PT_MCH10;
- case 11: return PT_MCH11;
- case 12: return PT_MCH12;
- case 13: return PT_MCH13;
- case 14: return PT_MCH14;
- case 15: return PT_MCH15;
-
- default:
-
- FatalError("What a weird separation of %d channels?!?!", ColorChannels);
- return -1;
- }
-}
-
-
-// ------------------------------------------------------------------------------
-
-// Return number of channels of pixel type
-int ChanCountFromPixelType(int ColorChannels)
-{
- switch (ColorChannels) {
-
- case PT_GRAY: return 1;
-
- case PT_RGB:
- case PT_CMY:
- case PT_Lab:
- case PT_YUV:
- case PT_YCbCr: return 3;
-
- case PT_CMYK: return 4 ;
- case PT_MCH2: return 2 ;
- case PT_MCH3: return 3 ;
- case PT_MCH4: return 4 ;
- case PT_MCH5: return 5 ;
- case PT_MCH6: return 6 ;
- case PT_MCH7: return 7 ;
- case PT_MCH8: return 8 ;
- case PT_MCH9: return 9 ;
- case PT_MCH10: return 10;
- case PT_MCH11: return 11;
- case PT_MCH12: return 12;
- case PT_MCH13: return 12;
- case PT_MCH14: return 14;
- case PT_MCH15: return 15;
-
- default:
-
- FatalError("Unsupported color space of %d channels", ColorChannels);
- return -1;
- }
-}
diff --git a/contrib/libs/lcms2/utils/common/xgetopt.c b/contrib/libs/lcms2/utils/common/xgetopt.c
deleted file mode 100644
index 2a93456016..0000000000
--- a/contrib/libs/lcms2/utils/common/xgetopt.c
+++ /dev/null
@@ -1,100 +0,0 @@
-
-//---------------------------------------------------------------------------------
-//
-// Little Color Management System
-// Copyright (c) 1998-2023 Marti Maria Saguer
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//---------------------------------------------------------------------------------
-//
-// xgetopt.c -- loosely based on System V getopt()
-//
-// option ::= SW [optLetter]* [argLetter space* argument]
-//
-
-#include <string.h>
-#include <stdio.h>
-
-int xoptind = 1;
-char *xoptarg;
-
-static char *nextArg = NULL;
-
-#define SW '-'
-
-
-int xgetopt(int argc, char* argv[], char* optionS)
-{
- unsigned char ch;
- char* optP;
-
- if (argc > xoptind)
- {
-
- if (nextArg == NULL)
- {
- if ((nextArg = argv[xoptind]) == NULL || *(nextArg++) != SW) goto end_eof;
- }
-
- if ((ch = *(nextArg++)) == 0)
- {
- xoptind++;
- goto end_eof;
- }
-
- if (ch == ':' || (optP = strchr(optionS, ch)) == NULL)
- goto end_error;
-
- if (*(++optP) == ':')
- {
- xoptind++;
-
- if (*nextArg == 0)
- {
- if (argc <= xoptind) goto end_error;
- nextArg = argv[xoptind++];
- }
-
- xoptarg = nextArg;
- nextArg = NULL;
-
- }
- else
- {
- if (*nextArg == 0)
- {
- xoptind++;
- nextArg = NULL;
- }
-
- xoptarg = NULL;
- }
-
- return ch;
- }
-
-end_eof:
- xoptarg = nextArg = NULL;
- return EOF;
-
-end_error:
- xoptarg = NULL;
- return '?';
-}
diff --git a/contrib/libs/lcms2/utils/jpgicc/.yandex_meta/licenses.list.txt b/contrib/libs/lcms2/utils/jpgicc/.yandex_meta/licenses.list.txt
deleted file mode 100644
index 5b5ec8330a..0000000000
--- a/contrib/libs/lcms2/utils/jpgicc/.yandex_meta/licenses.list.txt
+++ /dev/null
@@ -1,148 +0,0 @@
-====================COPYRIGHT====================
-// Copyright (c) 1998-2023 Marti Maria Saguer
-
-
-====================COPYRIGHT====================
-Copyright property of CompuServe Incorporated
-
-====================COPYRIGHT====================
-It is copyright by the Free Software Foundation but is freely distributable.
-The same holds for its supporting scripts (config.guess, config.sub,
-ltmain.sh). Another support script, install-sh, is copyright by X Consortium
-but is also freely distributable.
-
-
-====================COPYRIGHT====================
-This software is copyright (C) 1991-2013, Thomas G. Lane, Guido Vollbeding.
-All Rights Reserved except as specified below.
-
-
-====================File: AUTHORS====================
-
-Main Author
-------------
-Marti Maria
-
-
-Contributors
-------------
-Bob Friesenhahn
-Kai-Uwe Behrmann
-Stuart Nixon
-Jordi Vilar
-Richard Hughes
-Auke Nauta
-Chris Evans (Google)
-Lorenzo Ridolfi
-Robin Watts (Artifex)
-Shawn Pedersen
-Andrew Brygin
-Samuli Suominen
-Florian Höch
-Aurelien Jarno
-Claudiu Cebuc
-Michael Vhrel (Artifex)
-Michal Cihar
-Daniel Kaneider
-Mateusz Jurczyk (Google)
-Paul Miller
-Sébastien Léon
-Christian Schmitz
-XhmikosR
-Stanislav Brabec (SuSe)
-Leonhard Gruenschloss (Google)
-Patrick Noffke
-Christopher James Halse Rogers
-John Hein
-Thomas Weber (Debian)
-Mark Allen
-Noel Carboni
-Sergei Trofimovic
-Philipp Knechtges
-Amyspark
-Lovell Fuller
-Eli Schwartz
-Diogo Teles Sant'Anna
-
-Special Thanks
---------------
-Artifex software
-AlienSkin software
-libVIPS
-Jan Morovic
-Jos Vernon (WebSupergoo)
-Harald Schneider (Maxon)
-Christian Albrecht
-Dimitrios Anastassakis
-Lemke Software
-Tim Zaman
-
-
-====================IJG====================
-In legalese:
-
-The authors make NO WARRANTY or representation, either express or implied,
-with respect to this software, its quality, accuracy, merchantability, or
-fitness for a particular purpose. This software is provided "AS IS", and you,
-its user, assume the entire risk as to its quality and accuracy.
-
-This software is copyright (C) 1991-2013, Thomas G. Lane, Guido Vollbeding.
-All Rights Reserved except as specified below.
-
-Permission is hereby granted to use, copy, modify, and distribute this
-software (or portions thereof) for any purpose, without fee, subject to these
-conditions:
-(1) If any part of the source code for this software is distributed, then this
-README file must be included, with this copyright and no-warranty notice
-unaltered; and any additions, deletions, or changes to the original files
-must be clearly indicated in accompanying documentation.
-(2) If only executable code is distributed, then the accompanying
-documentation must state that "this software is based in part on the work of
-the Independent JPEG Group".
-(3) Permission for use of this software is granted only if the user accepts
-full responsibility for any undesirable consequences; the authors accept
-NO LIABILITY for damages of any kind.
-
-These conditions apply to any software derived from or based on the IJG code,
-not just to the unmodified library. If you use our work, you ought to
-acknowledge us.
-
-Permission is NOT granted for the use of any IJG author's name or company name
-in advertising or publicity relating to this software or products derived from
-it. This software may be referred to only as "the Independent JPEG Group's
-software".
-
-We specifically permit and encourage the use of this software as the basis of
-commercial products, provided that all warranty or liability claims are
-assumed by the product vendor.
-
-
-====================IJG====================
-In plain English:
-
-1. We don't promise that this software works. (But if you find any bugs,
- please let us know!)
-2. You can use this software for whatever you want. You don't have to pay us.
-3. You may not pretend that you wrote this software. If you use it in a
- program, you must acknowledge somewhere in your documentation that
- you've used the IJG code.
-
-
-====================MIT====================
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/contrib/libs/lcms2/utils/jpgicc/LICENSE_iccjpeg b/contrib/libs/lcms2/utils/jpgicc/LICENSE_iccjpeg
deleted file mode 100755
index b77d4cbff4..0000000000
--- a/contrib/libs/lcms2/utils/jpgicc/LICENSE_iccjpeg
+++ /dev/null
@@ -1,67 +0,0 @@
-
-THIS LICENSE APPLIES ONLY TO iccjpeg.c file
------
-In plain English:
-
-1. We don't promise that this software works. (But if you find any bugs,
- please let us know!)
-2. You can use this software for whatever you want. You don't have to pay us.
-3. You may not pretend that you wrote this software. If you use it in a
- program, you must acknowledge somewhere in your documentation that
- you've used the IJG code.
-
-In legalese:
-
-The authors make NO WARRANTY or representation, either express or implied,
-with respect to this software, its quality, accuracy, merchantability, or
-fitness for a particular purpose. This software is provided "AS IS", and you,
-its user, assume the entire risk as to its quality and accuracy.
-
-This software is copyright (C) 1991-2013, Thomas G. Lane, Guido Vollbeding.
-All Rights Reserved except as specified below.
-
-Permission is hereby granted to use, copy, modify, and distribute this
-software (or portions thereof) for any purpose, without fee, subject to these
-conditions:
-(1) If any part of the source code for this software is distributed, then this
-README file must be included, with this copyright and no-warranty notice
-unaltered; and any additions, deletions, or changes to the original files
-must be clearly indicated in accompanying documentation.
-(2) If only executable code is distributed, then the accompanying
-documentation must state that "this software is based in part on the work of
-the Independent JPEG Group".
-(3) Permission for use of this software is granted only if the user accepts
-full responsibility for any undesirable consequences; the authors accept
-NO LIABILITY for damages of any kind.
-
-These conditions apply to any software derived from or based on the IJG code,
-not just to the unmodified library. If you use our work, you ought to
-acknowledge us.
-
-Permission is NOT granted for the use of any IJG author's name or company name
-in advertising or publicity relating to this software or products derived from
-it. This software may be referred to only as "the Independent JPEG Group's
-software".
-
-We specifically permit and encourage the use of this software as the basis of
-commercial products, provided that all warranty or liability claims are
-assumed by the product vendor.
-
-
-The Unix configuration script "configure" was produced with GNU Autoconf.
-It is copyright by the Free Software Foundation but is freely distributable.
-The same holds for its supporting scripts (config.guess, config.sub,
-ltmain.sh). Another support script, install-sh, is copyright by X Consortium
-but is also freely distributable.
-
-The IJG distribution formerly included code to read and write GIF files.
-To avoid entanglement with the Unisys LZW patent, GIF reading support has
-been removed altogether, and the GIF writer has been simplified to produce
-"uncompressed GIFs". This technique does not use the LZW algorithm; the
-resulting GIF files are larger than usual, but are readable by all standard
-GIF decoders.
-
-We are required to state that
- "The Graphics Interchange Format(c) is the Copyright property of
- CompuServe Incorporated. GIF(sm) is a Service Mark property of
- CompuServe Incorporated."
diff --git a/contrib/libs/lcms2/utils/jpgicc/iccjpeg.c b/contrib/libs/lcms2/utils/jpgicc/iccjpeg.c
deleted file mode 100644
index d08b4bd081..0000000000
--- a/contrib/libs/lcms2/utils/jpgicc/iccjpeg.c
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * iccprofile.c
- *
- * This file provides code to read and write International Color Consortium
- * (ICC) device profiles embedded in JFIF JPEG image files. The ICC has
- * defined a standard format for including such data in JPEG "APP2" markers.
- * The code given here does not know anything about the internal structure
- * of the ICC profile data; it just knows how to put the profile data into
- * a JPEG file being written, or get it back out when reading.
- *
- * This code depends on new features added to the IJG JPEG library as of
- * IJG release 6b; it will not compile or work with older IJG versions.
- *
- * NOTE: this code would need surgery to work on 16-bit-int machines
- * with ICC profiles exceeding 64K bytes in size. If you need to do that,
- * change all the "unsigned int" variables to "INT32". You'll also need
- * to find a malloc() replacement that can allocate more than 64K.
- */
-
-#include "iccjpeg.h"
-#include <stdlib.h> /* define malloc() */
-
-
-/*
- * Since an ICC profile can be larger than the maximum size of a JPEG marker
- * (64K), we need provisions to split it into multiple markers. The format
- * defined by the ICC specifies one or more APP2 markers containing the
- * following data:
- * Identifying string ASCII "ICC_PROFILE\0" (12 bytes)
- * Marker sequence number 1 for first APP2, 2 for next, etc (1 byte)
- * Number of markers Total number of APP2's used (1 byte)
- * Profile data (remainder of APP2 data)
- * Decoders should use the marker sequence numbers to reassemble the profile,
- * rather than assuming that the APP2 markers appear in the correct sequence.
- */
-
-#define ICC_MARKER (JPEG_APP0 + 2) /* JPEG marker code for ICC */
-#define ICC_OVERHEAD_LEN 14 /* size of non-profile data in APP2 */
-#define MAX_BYTES_IN_MARKER 65533 /* maximum data len of a JPEG marker */
-#define MAX_DATA_BYTES_IN_MARKER (MAX_BYTES_IN_MARKER - ICC_OVERHEAD_LEN)
-
-
-/*
- * This routine writes the given ICC profile data into a JPEG file.
- * It *must* be called AFTER calling jpeg_start_compress() and BEFORE
- * the first call to jpeg_write_scanlines().
- * (This ordering ensures that the APP2 marker(s) will appear after the
- * SOI and JFIF or Adobe markers, but before all else.)
- */
-
-void
-write_icc_profile (j_compress_ptr cinfo,
- const JOCTET *icc_data_ptr,
- unsigned int icc_data_len)
-{
- unsigned int num_markers; /* total number of markers we'll write */
- int cur_marker = 1; /* per spec, counting starts at 1 */
- unsigned int length; /* number of bytes to write in this marker */
-
- /* Calculate the number of markers we'll need, rounding up of course */
- num_markers = icc_data_len / MAX_DATA_BYTES_IN_MARKER;
- if (num_markers * MAX_DATA_BYTES_IN_MARKER != icc_data_len)
- num_markers++;
-
- while (icc_data_len > 0) {
- /* length of profile to put in this marker */
- length = icc_data_len;
- if (length > MAX_DATA_BYTES_IN_MARKER)
- length = MAX_DATA_BYTES_IN_MARKER;
- icc_data_len -= length;
-
- /* Write the JPEG marker header (APP2 code and marker length) */
- jpeg_write_m_header(cinfo, ICC_MARKER,
- (unsigned int) (length + ICC_OVERHEAD_LEN));
-
- /* Write the marker identifying string "ICC_PROFILE" (null-terminated).
- * We code it in this less-than-transparent way so that the code works
- * even if the local character set is not ASCII.
- */
- jpeg_write_m_byte(cinfo, 0x49);
- jpeg_write_m_byte(cinfo, 0x43);
- jpeg_write_m_byte(cinfo, 0x43);
- jpeg_write_m_byte(cinfo, 0x5F);
- jpeg_write_m_byte(cinfo, 0x50);
- jpeg_write_m_byte(cinfo, 0x52);
- jpeg_write_m_byte(cinfo, 0x4F);
- jpeg_write_m_byte(cinfo, 0x46);
- jpeg_write_m_byte(cinfo, 0x49);
- jpeg_write_m_byte(cinfo, 0x4C);
- jpeg_write_m_byte(cinfo, 0x45);
- jpeg_write_m_byte(cinfo, 0x0);
-
- /* Add the sequencing info */
- jpeg_write_m_byte(cinfo, cur_marker);
- jpeg_write_m_byte(cinfo, (int) num_markers);
-
- /* Add the profile data */
- while (length--) {
- jpeg_write_m_byte(cinfo, *icc_data_ptr);
- icc_data_ptr++;
- }
- cur_marker++;
- }
-}
-
-
-/*
- * Prepare for reading an ICC profile
- */
-
-void
-setup_read_icc_profile (j_decompress_ptr cinfo)
-{
- /* Tell the library to keep any APP2 data it may find */
- jpeg_save_markers(cinfo, ICC_MARKER, 0xFFFF);
-}
-
-
-/*
- * Handy subroutine to test whether a saved marker is an ICC profile marker.
- */
-
-static boolean
-marker_is_icc (jpeg_saved_marker_ptr marker)
-{
- return
- marker->marker == ICC_MARKER &&
- marker->data_length >= ICC_OVERHEAD_LEN &&
- /* verify the identifying string */
- GETJOCTET(marker->data[0]) == 0x49 &&
- GETJOCTET(marker->data[1]) == 0x43 &&
- GETJOCTET(marker->data[2]) == 0x43 &&
- GETJOCTET(marker->data[3]) == 0x5F &&
- GETJOCTET(marker->data[4]) == 0x50 &&
- GETJOCTET(marker->data[5]) == 0x52 &&
- GETJOCTET(marker->data[6]) == 0x4F &&
- GETJOCTET(marker->data[7]) == 0x46 &&
- GETJOCTET(marker->data[8]) == 0x49 &&
- GETJOCTET(marker->data[9]) == 0x4C &&
- GETJOCTET(marker->data[10]) == 0x45 &&
- GETJOCTET(marker->data[11]) == 0x0;
-}
-
-
-/*
- * See if there was an ICC profile in the JPEG file being read;
- * if so, reassemble and return the profile data.
- *
- * TRUE is returned if an ICC profile was found, FALSE if not.
- * If TRUE is returned, *icc_data_ptr is set to point to the
- * returned data, and *icc_data_len is set to its length.
- *
- * IMPORTANT: the data at **icc_data_ptr has been allocated with malloc()
- * and must be freed by the caller with free() when the caller no longer
- * needs it. (Alternatively, we could write this routine to use the
- * IJG library's memory allocator, so that the data would be freed implicitly
- * at jpeg_finish_decompress() time. But it seems likely that many apps
- * will prefer to have the data stick around after decompression finishes.)
- *
- * NOTE: if the file contains invalid ICC APP2 markers, we just silently
- * return FALSE. You might want to issue an error message instead.
- */
-
-boolean
-read_icc_profile (j_decompress_ptr cinfo,
- JOCTET **icc_data_ptr,
- unsigned int *icc_data_len)
-{
- jpeg_saved_marker_ptr marker;
- int num_markers = 0;
- int seq_no;
- JOCTET *icc_data;
- unsigned int total_length;
-#define MAX_SEQ_NO 255 /* sufficient since marker numbers are bytes */
- char marker_present[MAX_SEQ_NO+1]; /* 1 if marker found */
- unsigned int data_length[MAX_SEQ_NO+1]; /* size of profile data in marker */
- unsigned int data_offset[MAX_SEQ_NO+1]; /* offset for data in marker */
-
- *icc_data_ptr = NULL; /* avoid confusion if FALSE return */
- *icc_data_len = 0;
-
- /* This first pass over the saved markers discovers whether there are
- * any ICC markers and verifies the consistency of the marker numbering.
- */
-
- for (seq_no = 1; seq_no <= MAX_SEQ_NO; seq_no++)
- marker_present[seq_no] = 0;
-
- for (marker = cinfo->marker_list; marker != NULL; marker = marker->next) {
- if (marker_is_icc(marker)) {
- if (num_markers == 0)
- num_markers = GETJOCTET(marker->data[13]);
- else if (num_markers != GETJOCTET(marker->data[13]))
- return FALSE; /* inconsistent num_markers fields */
- seq_no = GETJOCTET(marker->data[12]);
- if (seq_no <= 0 || seq_no > num_markers)
- return FALSE; /* bogus sequence number */
- if (marker_present[seq_no])
- return FALSE; /* duplicate sequence numbers */
- marker_present[seq_no] = 1;
- data_length[seq_no] = marker->data_length - ICC_OVERHEAD_LEN;
- }
- }
-
- if (num_markers == 0)
- return FALSE;
-
- /* Check for missing markers, count total space needed,
- * compute offset of each marker's part of the data.
- */
-
- total_length = 0;
- for (seq_no = 1; seq_no <= num_markers; seq_no++) {
- if (marker_present[seq_no] == 0)
- return FALSE; /* missing sequence number */
- data_offset[seq_no] = total_length;
- total_length += data_length[seq_no];
- }
-
- if (total_length == 0)
- return FALSE; /* found only empty markers? */
-
- /* Allocate space for assembled data */
- icc_data = (JOCTET *) malloc(total_length * sizeof(JOCTET));
- if (icc_data == NULL)
- return FALSE; /* oops, out of memory */
-
- /* and fill it in */
- for (marker = cinfo->marker_list; marker != NULL; marker = marker->next) {
- if (marker_is_icc(marker)) {
- JOCTET FAR *src_ptr;
- JOCTET *dst_ptr;
- unsigned int length;
- seq_no = GETJOCTET(marker->data[12]);
- dst_ptr = icc_data + data_offset[seq_no];
- src_ptr = marker->data + ICC_OVERHEAD_LEN;
- length = data_length[seq_no];
- while (length--) {
- *dst_ptr++ = *src_ptr++;
- }
- }
- }
-
- *icc_data_ptr = icc_data;
- *icc_data_len = total_length;
-
- return TRUE;
-}
diff --git a/contrib/libs/lcms2/utils/jpgicc/iccjpeg.h b/contrib/libs/lcms2/utils/jpgicc/iccjpeg.h
deleted file mode 100644
index 5e1888d9ef..0000000000
--- a/contrib/libs/lcms2/utils/jpgicc/iccjpeg.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * iccprofile.h
- *
- * This file provides code to read and write International Color Consortium
- * (ICC) device profiles embedded in JFIF JPEG image files. The ICC has
- * defined a standard format for including such data in JPEG "APP2" markers.
- * The code given here does not know anything about the internal structure
- * of the ICC profile data; it just knows how to put the profile data into
- * a JPEG file being written, or get it back out when reading.
- *
- * This code depends on new features added to the IJG JPEG library as of
- * IJG release 6b; it will not compile or work with older IJG versions.
- *
- * NOTE: this code would need surgery to work on 16-bit-int machines
- * with ICC profiles exceeding 64K bytes in size. See iccprofile.c
- * for details.
- */
-
-#include <stdio.h> /* needed to define "FILE", "NULL" */
-#include "jpeglib.h"
-
-
-/*
- * This routine writes the given ICC profile data into a JPEG file.
- * It *must* be called AFTER calling jpeg_start_compress() and BEFORE
- * the first call to jpeg_write_scanlines().
- * (This ordering ensures that the APP2 marker(s) will appear after the
- * SOI and JFIF or Adobe markers, but before all else.)
- */
-
-extern void write_icc_profile JPP((j_compress_ptr cinfo,
- const JOCTET *icc_data_ptr,
- unsigned int icc_data_len));
-
-
-/*
- * Reading a JPEG file that may contain an ICC profile requires two steps:
- *
- * 1. After jpeg_create_decompress() but before jpeg_read_header(),
- * call setup_read_icc_profile(). This routine tells the IJG library
- * to save in memory any APP2 markers it may find in the file.
- *
- * 2. After jpeg_read_header(), call read_icc_profile() to find out
- * whether there was a profile and obtain it if so.
- */
-
-
-/*
- * Prepare for reading an ICC profile
- */
-
-extern void setup_read_icc_profile JPP((j_decompress_ptr cinfo));
-
-
-/*
- * See if there was an ICC profile in the JPEG file being read;
- * if so, reassemble and return the profile data.
- *
- * TRUE is returned if an ICC profile was found, FALSE if not.
- * If TRUE is returned, *icc_data_ptr is set to point to the
- * returned data, and *icc_data_len is set to its length.
- *
- * IMPORTANT: the data at **icc_data_ptr has been allocated with malloc()
- * and must be freed by the caller with free() when the caller no longer
- * needs it. (Alternatively, we could write this routine to use the
- * IJG library's memory allocator, so that the data would be freed implicitly
- * at jpeg_finish_decompress() time. But it seems likely that many apps
- * will prefer to have the data stick around after decompression finishes.)
- */
-
-extern boolean read_icc_profile JPP((j_decompress_ptr cinfo,
- JOCTET **icc_data_ptr,
- unsigned int *icc_data_len));
diff --git a/contrib/libs/lcms2/utils/jpgicc/jpgicc.c b/contrib/libs/lcms2/utils/jpgicc/jpgicc.c
deleted file mode 100644
index e4ac4c4fa2..0000000000
--- a/contrib/libs/lcms2/utils/jpgicc/jpgicc.c
+++ /dev/null
@@ -1,1279 +0,0 @@
-//---------------------------------------------------------------------------------
-//
-// Little Color Management System
-// Copyright (c) 1998-2023 Marti Maria Saguer
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-// This program does apply profiles to (some) JPEG files
-
-
-#include "utils.h"
-
-#include "jpeglib.h"
-#include "iccjpeg.h"
-
-// Flags
-static cmsBool BlackPointCompensation = FALSE;
-static cmsBool IgnoreEmbedded = FALSE;
-static cmsBool GamutCheck = FALSE;
-static cmsBool lIsITUFax = FALSE;
-static cmsBool lIsPhotoshopApp13 = FALSE;
-static cmsBool lIsEXIF;
-static cmsBool lIsDeviceLink = FALSE;
-static cmsBool EmbedProfile = FALSE;
-
-static const char* SaveEmbedded = NULL;
-
-static int Intent = INTENT_PERCEPTUAL;
-static int ProofingIntent = INTENT_PERCEPTUAL;
-static int PrecalcMode = 1;
-
-static int jpegQuality = 75;
-
-static cmsFloat64Number ObserverAdaptationState = 0;
-
-
-static char *cInpProf = NULL;
-static char *cOutProf = NULL;
-static char *cProofing = NULL;
-
-static FILE * InFile;
-static FILE * OutFile;
-
-static struct jpeg_decompress_struct Decompressor;
-static struct jpeg_compress_struct Compressor;
-
-
-static struct my_error_mgr {
-
- struct jpeg_error_mgr pub; // "public" fields
- void* Cargo; // "private" fields
-
-} ErrorHandler;
-
-
-cmsUInt16Number Alarm[cmsMAXCHANNELS] = {128,128,128,0};
-
-
-static
-void my_error_exit (j_common_ptr cinfo)
-{
- char buffer[JMSG_LENGTH_MAX];
-
- (*cinfo->err->format_message) (cinfo, buffer);
- FatalError(buffer);
-}
-
-/*
-Definition of the APPn Markers Defined for continuous-tone G3FAX
-
-The application code APP1 initiates identification of the image as
-a G3FAX application and defines the spatial resolution and subsampling.
-This marker directly follows the SOI marker. The data format will be as follows:
-
-X'FFE1' (APP1), length, FAX identifier, version, spatial resolution.
-
-The above terms are defined as follows:
-
-Length: (Two octets) Total APP1 field octet count including the octet count itself, but excluding the APP1
-marker.
-
-FAX identifier: (Six octets) X'47', X'33', X'46', X'41', X'58', X'00'. This X'00'-terminated string "G3FAX"
-uniquely identifies this APP1 marker.
-
-Version: (Two octets) X'07CA'. This string specifies the year of approval of the standard, for identification
-in the case of future revision (for example, 1994).
-
-Spatial Resolution: (Two octets) Lightness pixel density in pels/25.4 mm. The basic value is 200. Allowed values are
-100, 200, 300, 400, 600 and 1200 pels/25.4 mm, with square (or equivalent) pels.
-
-NOTE - The functional equivalence of inch-based and mm-based resolutions is maintained. For example, the 200 x 200
-*/
-
-static
-cmsBool IsITUFax(jpeg_saved_marker_ptr ptr)
-{
- while (ptr)
- {
- if (ptr -> marker == (JPEG_APP0 + 1) && ptr -> data_length > 5) {
-
- const char* data = (const char*) ptr -> data;
-
- if (strcmp(data, "G3FAX") == 0) return TRUE;
- }
-
- ptr = ptr -> next;
- }
-
- return FALSE;
-}
-
-// Save a ITU T.42/Fax marker with defaults on boundaries. This is the only mode we support right now.
-static
-void SetITUFax(j_compress_ptr cinfo)
-{
- unsigned char Marker[] = "G3FAX\x00\0x07\xCA\x00\xC8";
-
- jpeg_write_marker(cinfo, (JPEG_APP0 + 1), Marker, 10);
-}
-
-
-// Build a profile for decoding ITU T.42/Fax JPEG streams.
-// The profile has an additional ability in the input direction of
-// gamut compress values between 85 < a < -85 and -75 < b < 125. This conforms
-// the default range for ITU/T.42 -- See RFC 2301, section 6.2.3 for details
-
-// L* = [0, 100]
-// a* = [-85, 85]
-// b* = [-75, 125]
-
-
-// These functions does convert the encoding of ITUFAX to floating point
-// and vice-versa. No gamut mapping is performed yet.
-
-static
-void ITU2Lab(const cmsUInt16Number In[3], cmsCIELab* Lab)
-{
- Lab -> L = (double) In[0] / 655.35;
- Lab -> a = (double) 170.* (In[1] - 32768.) / 65535.;
- Lab -> b = (double) 200.* (In[2] - 24576.) / 65535.;
-}
-
-static
-void Lab2ITU(const cmsCIELab* Lab, cmsUInt16Number Out[3])
-{
- Out[0] = (cmsUInt16Number) floor((double) (Lab -> L / 100.)* 65535. );
- Out[1] = (cmsUInt16Number) floor((double) (Lab -> a / 170.)* 65535. + 32768. );
- Out[2] = (cmsUInt16Number) floor((double) (Lab -> b / 200.)* 65535. + 24576. );
-}
-
-// These are the samplers-- They are passed as callbacks to cmsStageSampleCLut16bit()
-// then, cmsSample3DGrid() will sweel whole Lab gamut calling these functions
-// once for each node. In[] will contain the Lab PCS value to convert to ITUFAX
-// on PCS2ITU, or the ITUFAX value to convert to Lab in ITU2PCS
-// You can change the number of sample points if desired, the algorithm will
-// remain same. 33 points gives good accuracy, but you can reduce to 22 or less
-// is space is critical
-
-#define GRID_POINTS 33
-
-static
-int PCS2ITU(register const cmsUInt16Number In[], register cmsUInt16Number Out[], register void* Cargo)
-{
- cmsCIELab Lab;
-
- cmsLabEncoded2Float(&Lab, In);
- cmsDesaturateLab(&Lab, 85, -85, 125, -75); // This function does the necessary gamut remapping
- Lab2ITU(&Lab, Out);
- return TRUE;
-
- UTILS_UNUSED_PARAMETER(Cargo);
-}
-
-
-static
-int ITU2PCS( register const cmsUInt16Number In[], register cmsUInt16Number Out[], register void* Cargo)
-{
- cmsCIELab Lab;
-
- ITU2Lab(In, &Lab);
- cmsFloat2LabEncoded(Out, &Lab);
- return TRUE;
-
- UTILS_UNUSED_PARAMETER(Cargo);
-}
-
-// This function does create the virtual input profile, which decodes ITU to the profile connection space
-static
-cmsHPROFILE CreateITU2PCS_ICC(void)
-{
- cmsHPROFILE hProfile;
- cmsPipeline* AToB0;
- cmsStage* ColorMap;
-
- AToB0 = cmsPipelineAlloc(0, 3, 3);
- if (AToB0 == NULL) return NULL;
-
- ColorMap = cmsStageAllocCLut16bit(0, GRID_POINTS, 3, 3, NULL);
- if (ColorMap == NULL) return NULL;
-
- cmsPipelineInsertStage(AToB0, cmsAT_BEGIN, ColorMap);
- cmsStageSampleCLut16bit(ColorMap, ITU2PCS, NULL, 0);
-
- hProfile = cmsCreateProfilePlaceholder(0);
- if (hProfile == NULL) {
- cmsPipelineFree(AToB0);
- return NULL;
- }
-
- cmsWriteTag(hProfile, cmsSigAToB0Tag, AToB0);
- cmsSetColorSpace(hProfile, cmsSigLabData);
- cmsSetPCS(hProfile, cmsSigLabData);
- cmsSetDeviceClass(hProfile, cmsSigColorSpaceClass);
- cmsPipelineFree(AToB0);
-
- return hProfile;
-}
-
-
-// This function does create the virtual output profile, with the necessary gamut mapping
-static
-cmsHPROFILE CreatePCS2ITU_ICC(void)
-{
- cmsHPROFILE hProfile;
- cmsPipeline* BToA0;
- cmsStage* ColorMap;
-
- BToA0 = cmsPipelineAlloc(0, 3, 3);
- if (BToA0 == NULL) return NULL;
-
- ColorMap = cmsStageAllocCLut16bit(0, GRID_POINTS, 3, 3, NULL);
- if (ColorMap == NULL) return NULL;
-
- cmsPipelineInsertStage(BToA0, cmsAT_BEGIN, ColorMap);
- cmsStageSampleCLut16bit(ColorMap, PCS2ITU, NULL, 0);
-
- hProfile = cmsCreateProfilePlaceholder(0);
- if (hProfile == NULL) {
- cmsPipelineFree(BToA0);
- return NULL;
- }
-
- cmsWriteTag(hProfile, cmsSigBToA0Tag, BToA0);
- cmsSetColorSpace(hProfile, cmsSigLabData);
- cmsSetPCS(hProfile, cmsSigLabData);
- cmsSetDeviceClass(hProfile, cmsSigColorSpaceClass);
-
- cmsPipelineFree(BToA0);
-
- return hProfile;
-}
-
-
-
-#define PS_FIXED_TO_FLOAT(h, l) ((float) (h) + ((float) (l)/(1<<16)))
-
-static
-cmsBool ProcessPhotoshopAPP13(JOCTET *data, int datalen)
-{
- int i;
-
- for (i = 14; i < datalen; )
- {
- long len;
- unsigned int type;
-
- if (!(GETJOCTET(data[i] ) == 0x38 &&
- GETJOCTET(data[i+1]) == 0x42 &&
- GETJOCTET(data[i+2]) == 0x49 &&
- GETJOCTET(data[i+3]) == 0x4D)) break; // Not recognized
-
- i += 4; // identifying string
-
- type = (unsigned int) (GETJOCTET(data[i]<<8) + GETJOCTET(data[i+1]));
-
- i += 2; // resource type
-
- i += GETJOCTET(data[i]) + ((GETJOCTET(data[i]) & 1) ? 1 : 2); // resource name
-
- len = ((((GETJOCTET(data[i]<<8) + GETJOCTET(data[i+1]))<<8) +
- GETJOCTET(data[i+2]))<<8) + GETJOCTET(data[i+3]);
-
- if (len < 0) return FALSE; // Keep bug hunters away
-
- i += 4; // Size
-
- if (type == 0x03ED && len >= 16) {
-
- Decompressor.X_density = (UINT16) PS_FIXED_TO_FLOAT(GETJOCTET(data[i]<<8) + GETJOCTET(data[i+1]),
- GETJOCTET(data[i+2]<<8) + GETJOCTET(data[i+3]));
- Decompressor.Y_density = (UINT16) PS_FIXED_TO_FLOAT(GETJOCTET(data[i+8]<<8) + GETJOCTET(data[i+9]),
- GETJOCTET(data[i+10]<<8) + GETJOCTET(data[i+11]));
-
- // Set the density unit to 1 since the
- // Vertical and Horizontal resolutions
- // are specified in Pixels per inch
-
- Decompressor.density_unit = 0x01;
- return TRUE;
-
- }
-
- i += len + ((len & 1) ? 1 : 0); // Alignment
- }
- return FALSE;
-}
-
-
-static
-cmsBool HandlePhotoshopAPP13(jpeg_saved_marker_ptr ptr)
-{
- while (ptr) {
-
- if (ptr -> marker == (JPEG_APP0 + 13) && ptr -> data_length > 9)
- {
- JOCTET* data = ptr -> data;
-
- if(GETJOCTET(data[0]) == 0x50 &&
- GETJOCTET(data[1]) == 0x68 &&
- GETJOCTET(data[2]) == 0x6F &&
- GETJOCTET(data[3]) == 0x74 &&
- GETJOCTET(data[4]) == 0x6F &&
- GETJOCTET(data[5]) == 0x73 &&
- GETJOCTET(data[6]) == 0x68 &&
- GETJOCTET(data[7]) == 0x6F &&
- GETJOCTET(data[8]) == 0x70) {
-
- ProcessPhotoshopAPP13(data, ptr -> data_length);
- return TRUE;
- }
- }
-
- ptr = ptr -> next;
- }
-
- return FALSE;
-}
-
-
-typedef unsigned short uint16_t;
-typedef unsigned char uint8_t;
-typedef unsigned int uint32_t;
-
-#define INTEL_BYTE_ORDER 0x4949
-#define XRESOLUTION 0x011a
-#define YRESOLUTION 0x011b
-#define RESOLUTION_UNIT 0x128
-
-// Abort if crafted file
-static
-void craftedFile(void)
-{
- FatalError("Corrupted EXIF data");
-}
-
-// Read a 16-bit word
-static
-uint16_t read16(uint8_t* arr, size_t pos, int swapBytes, size_t max)
-{
- if (pos + 2 >= max)
- {
- craftedFile();
- return 0;
- }
- else
- {
- uint8_t b1 = arr[pos];
- uint8_t b2 = arr[pos + 1];
-
- return (swapBytes) ? ((b2 << 8) | b1) : ((b1 << 8) | b2);
- }
-}
-
-
-// Read a 32-bit word
-static
-uint32_t read32(uint8_t* arr, size_t pos, int swapBytes, size_t max)
-{
-
- if (pos + 4 >= max)
- {
- craftedFile();
- return 0;
- }
- else
- {
- if (!swapBytes) {
-
- return (arr[pos] << 24) | (arr[pos + 1] << 16) | (arr[pos + 2] << 8) | arr[pos + 3];
- }
-
- return arr[pos] | (arr[pos + 1] << 8) | (arr[pos + 2] << 16) | (arr[pos + 3] << 24);
- }
-}
-
-
-
-static
-int read_tag(uint8_t* arr, int pos, int swapBytes, void* dest, size_t max)
-{
- // Format should be 5 over here (rational)
- uint32_t format = read16(arr, pos + 2, swapBytes, max);
- // Components should be 1
- uint32_t components = read32(arr, pos + 4, swapBytes, max);
- // Points to the value
- uint32_t offset;
-
- // sanity
- if (components != 1) return 0;
-
- if (format == 3)
- offset = pos + 8;
- else
- offset = read32(arr, pos + 8, swapBytes, max);
-
- switch (format) {
-
- case 5: // Rational
- {
- double num = read32(arr, offset, swapBytes, max);
- double den = read32(arr, offset + 4, swapBytes, max);
- *(double *) dest = num / den;
- }
- break;
-
- case 3: // uint 16
- *(int*) dest = read16(arr, offset, swapBytes, max);
- break;
-
- default: return 0;
- }
-
- return 1;
-}
-
-
-
-// Handler for EXIF data
-static
-cmsBool HandleEXIF(struct jpeg_decompress_struct* cinfo)
-{
- jpeg_saved_marker_ptr ptr;
- uint32_t ifd_ofs;
- int pos = 0, swapBytes = 0;
- uint32_t i, numEntries;
- double XRes = -1, YRes = -1;
- int Unit = 2; // Inches
-
-
- for (ptr = cinfo ->marker_list; ptr; ptr = ptr ->next) {
-
- if ((ptr ->marker == JPEG_APP0+1) && ptr ->data_length > 6) {
-
- JOCTET* data = ptr -> data;
- size_t max = ptr->data_length;
-
- if (memcmp(data, "Exif\0\0", 6) == 0) {
-
- data += 6; // Skip EXIF marker
-
- // 8 byte TIFF header
- // first two determine byte order
- pos = 0;
- if (read16(data, pos, 0, max) == INTEL_BYTE_ORDER) {
- swapBytes = 1;
- }
-
- pos += 2;
-
- // next two bytes are always 0x002A (TIFF version)
- pos += 2;
-
- // offset to Image File Directory (includes the previous 8 bytes)
- ifd_ofs = read32(data, pos, swapBytes, max);
-
- // Search the directory for resolution tags
- numEntries = read16(data, ifd_ofs, swapBytes, max);
-
- for (i=0; i < numEntries; i++) {
-
- uint32_t entryOffset = ifd_ofs + 2 + (12 * i);
- uint32_t tag = read16(data, entryOffset, swapBytes, max);
-
- switch (tag) {
-
- case RESOLUTION_UNIT:
- if (!read_tag(data, entryOffset, swapBytes, &Unit, max)) return FALSE;
- break;
-
- case XRESOLUTION:
- if (!read_tag(data, entryOffset, swapBytes, &XRes, max)) return FALSE;
- break;
-
- case YRESOLUTION:
- if (!read_tag(data, entryOffset, swapBytes, &YRes, max)) return FALSE;
- break;
-
- default:;
- }
-
- }
-
- // Proceed if all found
-
- if (XRes != -1 && YRes != -1)
- {
-
- // 1 = None
- // 2 = inches
- // 3 = cm
-
- switch (Unit) {
-
- case 2:
-
- cinfo ->X_density = (UINT16) floor(XRes + 0.5);
- cinfo ->Y_density = (UINT16) floor(YRes + 0.5);
- break;
-
- case 1:
-
- cinfo ->X_density = (UINT16) floor(XRes * 2.54 + 0.5);
- cinfo ->Y_density = (UINT16) floor(YRes * 2.54 + 0.5);
- break;
-
- default: return FALSE;
- }
-
- cinfo ->density_unit = 1; /* 1 for dots/inch, or 2 for dots/cm.*/
-
- }
-
-
- }
- }
- }
- return FALSE;
-}
-
-
-static
-cmsBool OpenInput(const char* FileName)
-{
- int m;
-
- lIsITUFax = FALSE;
- InFile = fopen(FileName, "rb");
- if (InFile == NULL) {
- FatalError("Cannot open '%s'", FileName);
- }
-
- // Now we can initialize the JPEG decompression object.
- Decompressor.err = jpeg_std_error(&ErrorHandler.pub);
- ErrorHandler.pub.error_exit = my_error_exit;
- ErrorHandler.pub.output_message = my_error_exit;
-
- jpeg_create_decompress(&Decompressor);
- jpeg_stdio_src(&Decompressor, InFile);
-
- for (m = 0; m < 16; m++)
- jpeg_save_markers(&Decompressor, JPEG_APP0 + m, 0xFFFF);
-
- // setup_read_icc_profile(&Decompressor);
-
- fseek(InFile, 0, SEEK_SET);
- jpeg_read_header(&Decompressor, TRUE);
-
- return TRUE;
-}
-
-
-static
-cmsBool OpenOutput(const char* FileName)
-{
-
- OutFile = fopen(FileName, "wb");
- if (OutFile == NULL) {
- FatalError("Cannot create '%s'", FileName);
-
- }
-
- Compressor.err = jpeg_std_error(&ErrorHandler.pub);
- ErrorHandler.pub.error_exit = my_error_exit;
- ErrorHandler.pub.output_message = my_error_exit;
-
- Compressor.input_components = Compressor.num_components = 4;
-
- jpeg_create_compress(&Compressor);
- jpeg_stdio_dest(&Compressor, OutFile);
- return TRUE;
-}
-
-static
-cmsBool Done(void)
-{
- jpeg_destroy_decompress(&Decompressor);
- jpeg_destroy_compress(&Compressor);
- return fclose(InFile) + fclose(OutFile);
-
-}
-
-
-// Build up the pixeltype descriptor
-
-static
-cmsUInt32Number GetInputPixelType(void)
-{
- int space, bps, extra, ColorChannels, Flavor;
-
- lIsITUFax = IsITUFax(Decompressor.marker_list);
- lIsPhotoshopApp13 = HandlePhotoshopAPP13(Decompressor.marker_list);
- lIsEXIF = HandleEXIF(&Decompressor);
-
- ColorChannels = Decompressor.num_components;
- extra = 0; // Alpha = None
- bps = 1; // 8 bits
- Flavor = 0; // Vanilla
-
- if (lIsITUFax) {
-
- space = PT_Lab;
- Decompressor.out_color_space = JCS_YCbCr; // Fake to don't touch
- }
- else
- switch (Decompressor.jpeg_color_space) {
-
- case JCS_GRAYSCALE: // monochrome
- space = PT_GRAY;
- Decompressor.out_color_space = JCS_GRAYSCALE;
- break;
-
- case JCS_RGB: // red/green/blue
- space = PT_RGB;
- Decompressor.out_color_space = JCS_RGB;
- break;
-
- case JCS_YCbCr: // Y/Cb/Cr (also known as YUV)
- space = PT_RGB; // Let IJG code to do the conversion
- Decompressor.out_color_space = JCS_RGB;
- break;
-
- case JCS_CMYK: // C/M/Y/K
- space = PT_CMYK;
- Decompressor.out_color_space = JCS_CMYK;
- if (Decompressor.saw_Adobe_marker) // Adobe keeps CMYK inverted, so change flavor
- Flavor = 1; // from vanilla to chocolate
- break;
-
- case JCS_YCCK: // Y/Cb/Cr/K
- space = PT_CMYK;
- Decompressor.out_color_space = JCS_CMYK;
- if (Decompressor.saw_Adobe_marker) // ditto
- Flavor = 1;
- break;
-
- default:
- FatalError("Unsupported color space (0x%x)", Decompressor.jpeg_color_space);
- return 0;
- }
-
- return (EXTRA_SH(extra)|CHANNELS_SH(ColorChannels)|BYTES_SH(bps)|COLORSPACE_SH(space)|FLAVOR_SH(Flavor));
-}
-
-
-// Rearrange pixel type to build output descriptor
-static
-cmsUInt32Number ComputeOutputFormatDescriptor(cmsUInt32Number dwInput, int OutColorSpace)
-{
- int IsPlanar = T_PLANAR(dwInput);
- int Channels = 0;
- int Flavor = 0;
-
- switch (OutColorSpace) {
-
- case PT_GRAY:
- Channels = 1;
- break;
- case PT_RGB:
- case PT_CMY:
- case PT_Lab:
- case PT_YUV:
- case PT_YCbCr:
- Channels = 3;
- break;
-
- case PT_CMYK:
- if (Compressor.write_Adobe_marker) // Adobe keeps CMYK inverted, so change flavor to chocolate
- Flavor = 1;
- Channels = 4;
- break;
- default:
- FatalError("Unsupported output color space");
- }
-
- return (COLORSPACE_SH(OutColorSpace)|PLANAR_SH(IsPlanar)|CHANNELS_SH(Channels)|BYTES_SH(1)|FLAVOR_SH(Flavor));
-}
-
-
-// Equivalence between ICC color spaces and lcms color spaces
-static
-int GetProfileColorSpace(cmsHPROFILE hProfile)
-{
- cmsColorSpaceSignature ProfileSpace = cmsGetColorSpace(hProfile);
-
- return _cmsLCMScolorSpace(ProfileSpace);
-}
-
-static
-int GetDevicelinkColorSpace(cmsHPROFILE hProfile)
-{
- cmsColorSpaceSignature ProfileSpace = cmsGetPCS(hProfile);
-
- return _cmsLCMScolorSpace(ProfileSpace);
-}
-
-
-// From TRANSUPP
-
-static
-void jcopy_markers_execute(j_decompress_ptr srcinfo, j_compress_ptr dstinfo)
-{
- jpeg_saved_marker_ptr marker;
-
- /* In the current implementation, we don't actually need to examine the
- * option flag here; we just copy everything that got saved.
- * But to avoid confusion, we do not output JFIF and Adobe APP14 markers
- * if the encoder library already wrote one.
- */
- for (marker = srcinfo->marker_list; marker != NULL; marker = marker->next) {
-
- if (dstinfo->write_JFIF_header &&
- marker->marker == JPEG_APP0 &&
- marker->data_length >= 5 &&
- GETJOCTET(marker->data[0]) == 0x4A &&
- GETJOCTET(marker->data[1]) == 0x46 &&
- GETJOCTET(marker->data[2]) == 0x49 &&
- GETJOCTET(marker->data[3]) == 0x46 &&
- GETJOCTET(marker->data[4]) == 0)
- continue; /* reject duplicate JFIF */
-
- if (dstinfo->write_Adobe_marker &&
- marker->marker == JPEG_APP0+14 &&
- marker->data_length >= 5 &&
- GETJOCTET(marker->data[0]) == 0x41 &&
- GETJOCTET(marker->data[1]) == 0x64 &&
- GETJOCTET(marker->data[2]) == 0x6F &&
- GETJOCTET(marker->data[3]) == 0x62 &&
- GETJOCTET(marker->data[4]) == 0x65)
- continue; /* reject duplicate Adobe */
-
- jpeg_write_marker(dstinfo, marker->marker,
- marker->data, marker->data_length);
- }
-}
-
-static
-void WriteOutputFields(int OutputColorSpace)
-{
- J_COLOR_SPACE in_space, jpeg_space;
- int components;
-
- switch (OutputColorSpace) {
-
- case PT_GRAY: in_space = jpeg_space = JCS_GRAYSCALE;
- components = 1;
- break;
-
- case PT_RGB: in_space = JCS_RGB;
- jpeg_space = JCS_YCbCr;
- components = 3;
- break; // red/green/blue
-
- case PT_YCbCr: in_space = jpeg_space = JCS_YCbCr;
- components = 3;
- break; // Y/Cb/Cr (also known as YUV)
-
- case PT_CMYK: in_space = JCS_CMYK;
- jpeg_space = JCS_YCCK;
- components = 4;
- break; // C/M/Y/components
-
- case PT_Lab: in_space = jpeg_space = JCS_YCbCr;
- components = 3;
- break; // Fake to don't touch
- default:
- FatalError("Unsupported output color space");
- return;
- }
-
-
- if (jpegQuality >= 100) {
-
- // avoid destructive conversion when asking for lossless compression
- jpeg_space = in_space;
- }
-
- Compressor.in_color_space = in_space;
- Compressor.jpeg_color_space = jpeg_space;
- Compressor.input_components = Compressor.num_components = components;
- jpeg_set_defaults(&Compressor);
- jpeg_set_colorspace(&Compressor, jpeg_space);
-
-
- // Make sure to pass resolution through
- if (OutputColorSpace == PT_CMYK)
- Compressor.write_JFIF_header = 1;
-
- // Avoid subsampling on high quality factor
- jpeg_set_quality(&Compressor, jpegQuality, 1);
- if (jpegQuality >= 70) {
-
- int i;
- for(i=0; i < Compressor.num_components; i++) {
-
- Compressor.comp_info[i].h_samp_factor = 1;
- Compressor.comp_info[i].v_samp_factor = 1;
- }
-
- }
-
-}
-
-
-static
-void DoEmbedProfile(const char* ProfileFile)
-{
- FILE* f;
- size_t size, EmbedLen;
- cmsUInt8Number* EmbedBuffer;
-
- f = fopen(ProfileFile, "rb");
- if (f == NULL) return;
-
- size = cmsfilelength(f);
- EmbedBuffer = (cmsUInt8Number*) malloc(size + 1);
- EmbedLen = fread(EmbedBuffer, 1, size, f);
- fclose(f);
- EmbedBuffer[EmbedLen] = 0;
-
- write_icc_profile (&Compressor, EmbedBuffer, (unsigned int) EmbedLen);
- free(EmbedBuffer);
-}
-
-
-
-static
-int DoTransform(cmsHTRANSFORM hXForm, int OutputColorSpace)
-{
- JSAMPROW ScanLineIn;
- JSAMPROW ScanLineOut;
-
-
- //Preserve resolution values from the original
- // (Thanks to Robert Bergs for finding out this bug)
- Compressor.density_unit = Decompressor.density_unit;
- Compressor.X_density = Decompressor.X_density;
- Compressor.Y_density = Decompressor.Y_density;
-
- // Compressor.write_JFIF_header = 1;
-
- jpeg_start_decompress(&Decompressor);
- jpeg_start_compress(&Compressor, TRUE);
-
- if (OutputColorSpace == PT_Lab)
- SetITUFax(&Compressor);
-
- // Embed the profile if needed
- if (EmbedProfile && cOutProf)
- DoEmbedProfile(cOutProf);
-
- ScanLineIn = (JSAMPROW) malloc((size_t) Decompressor.output_width * Decompressor.num_components);
- ScanLineOut = (JSAMPROW) malloc((size_t) Compressor.image_width * Compressor.num_components);
-
- while (Decompressor.output_scanline <
- Decompressor.output_height) {
-
- jpeg_read_scanlines(&Decompressor, &ScanLineIn, 1);
-
- cmsDoTransform(hXForm, ScanLineIn, ScanLineOut, Decompressor.output_width);
-
- jpeg_write_scanlines(&Compressor, &ScanLineOut, 1);
- }
-
- free(ScanLineIn);
- free(ScanLineOut);
-
- jpeg_finish_decompress(&Decompressor);
- jpeg_finish_compress(&Compressor);
-
- return TRUE;
-}
-
-
-
-// Transform one image
-
-static
-int TransformImage(char *cDefInpProf, char *cOutputProf)
-{
- cmsHPROFILE hIn, hOut, hProof;
- cmsHTRANSFORM xform;
- cmsUInt32Number wInput, wOutput;
- int OutputColorSpace;
- cmsUInt32Number dwFlags = 0;
- cmsUInt32Number EmbedLen;
- cmsUInt8Number* EmbedBuffer;
-
-
- cmsSetAdaptationState(ObserverAdaptationState);
-
- if (BlackPointCompensation) {
-
- dwFlags |= cmsFLAGS_BLACKPOINTCOMPENSATION;
- }
-
-
- switch (PrecalcMode) {
-
- case 0: dwFlags |= cmsFLAGS_NOOPTIMIZE; break;
- case 2: dwFlags |= cmsFLAGS_HIGHRESPRECALC; break;
- case 3: dwFlags |= cmsFLAGS_LOWRESPRECALC; break;
- default:;
- }
-
-
- if (GamutCheck) {
- dwFlags |= cmsFLAGS_GAMUTCHECK;
- cmsSetAlarmCodes(Alarm);
- }
-
- // Take input color space
- wInput = GetInputPixelType();
-
- if (lIsDeviceLink) {
-
- hIn = cmsOpenProfileFromFile(cDefInpProf, "r");
- hOut = NULL;
- hProof = NULL;
- }
- else {
-
- if (!IgnoreEmbedded && read_icc_profile(&Decompressor, &EmbedBuffer, &EmbedLen))
- {
- hIn = cmsOpenProfileFromMem(EmbedBuffer, EmbedLen);
-
- if (Verbose) {
-
- fprintf(stdout, " (Embedded profile found)\n");
- PrintProfileInformation(hIn);
- fflush(stdout);
- }
-
- if (hIn != NULL && SaveEmbedded != NULL)
- SaveMemoryBlock(EmbedBuffer, EmbedLen, SaveEmbedded);
-
- free(EmbedBuffer);
- }
- else
- {
- // Default for ITU/Fax
- if (cDefInpProf == NULL && T_COLORSPACE(wInput) == PT_Lab)
- cDefInpProf = "*Lab";
-
- if (cDefInpProf != NULL && cmsstrcasecmp(cDefInpProf, "*lab") == 0)
- hIn = CreateITU2PCS_ICC();
- else
- hIn = OpenStockProfile(0, cDefInpProf);
- }
-
- if (cOutputProf != NULL && cmsstrcasecmp(cOutputProf, "*lab") == 0)
- hOut = CreatePCS2ITU_ICC();
- else
- hOut = OpenStockProfile(0, cOutputProf);
-
- hProof = NULL;
- if (cProofing != NULL) {
-
- hProof = OpenStockProfile(0, cProofing);
- if (hProof == NULL) {
- FatalError("Proofing profile couldn't be read.");
- }
- dwFlags |= cmsFLAGS_SOFTPROOFING;
- }
- }
-
- if (!hIn)
- FatalError("Input profile couldn't be read.");
- if (!lIsDeviceLink && !hOut)
- FatalError("Output profile couldn't be read.");
-
- // Assure both, input profile and input JPEG are on same colorspace
- if (cmsGetColorSpace(hIn) != _cmsICCcolorSpace(T_COLORSPACE(wInput)))
- FatalError("Input profile is not operating in proper color space");
-
-
- // Output colorspace is given by output profile
-
- if (lIsDeviceLink) {
- OutputColorSpace = GetDevicelinkColorSpace(hIn);
- }
- else {
- OutputColorSpace = GetProfileColorSpace(hOut);
- }
-
- jpeg_copy_critical_parameters(&Decompressor, &Compressor);
-
- WriteOutputFields(OutputColorSpace);
-
- wOutput = ComputeOutputFormatDescriptor(wInput, OutputColorSpace);
-
-
- xform = cmsCreateProofingTransform(hIn, wInput,
- hOut, wOutput,
- hProof, Intent,
- ProofingIntent, dwFlags);
- if (xform == NULL)
- FatalError("Cannot transform by using the profiles");
-
- DoTransform(xform, OutputColorSpace);
-
-
- jcopy_markers_execute(&Decompressor, &Compressor);
-
- cmsDeleteTransform(xform);
- cmsCloseProfile(hIn);
- cmsCloseProfile(hOut);
- if (hProof) cmsCloseProfile(hProof);
-
- return 1;
-}
-
-
-static
-void Help(int level)
-{
-
- UTILS_UNUSED_PARAMETER(level);
-
- fprintf(stderr, "usage: jpgicc [flags] input.jpg output.jpg\n");
-
- fprintf(stderr, "\nflags:\n\n");
- fprintf(stderr, "-v - Verbose\n");
- fprintf(stderr, "-i<profile> - Input profile (defaults to sRGB)\n");
- fprintf(stderr, "-o<profile> - Output profile (defaults to sRGB)\n");
-
- PrintBuiltins();
-
- PrintRenderingIntents();
-
-
- fprintf(stderr, "-b - Black point compensation\n");
- fprintf(stderr, "-d<0..1> - Observer adaptation state (abs.col. only)\n");
- fprintf(stderr, "-n - Ignore embedded profile\n");
- fprintf(stderr, "-e - Embed destination profile\n");
- fprintf(stderr, "-s<new profile> - Save embedded profile as <new profile>\n");
-
- fprintf(stderr, "\n");
-
- fprintf(stderr, "-c<0,1,2,3> - Precalculates transform (0=Off, 1=Normal, 2=Hi-res, 3=LoRes) [defaults to 1]\n");
- fprintf(stderr, "\n");
-
- fprintf(stderr, "-p<profile> - Soft proof profile\n");
- fprintf(stderr, "-m<0,1,2,3> - SoftProof intent\n");
- fprintf(stderr, "-g - Marks out-of-gamut colors on softproof\n");
- fprintf(stderr, "-!<r>,<g>,<b> - Out-of-gamut marker channel values\n");
-
- fprintf(stderr, "\n");
- fprintf(stderr, "-q<0..100> - Output JPEG quality\n");
-
- fprintf(stderr, "Examples:\n\n"
- "To color correct from scanner to sRGB:\n"
- "\tjpgicc -iscanner.icm in.jpg out.jpg\n"
- "To convert from monitor1 to monitor2:\n"
- "\tjpgicc -imon1.icm -omon2.icm in.jpg out.jpg\n"
- "To make a CMYK separation:\n"
- "\tjpgicc -oprinter.icm inrgb.jpg outcmyk.jpg\n"
- "To recover sRGB from a CMYK separation:\n"
- "\tjpgicc -iprinter.icm incmyk.jpg outrgb.jpg\n"
- "To convert from CIELab ITU/Fax JPEG to sRGB\n"
- "\tjpgicc in.jpg out.jpg\n\n");
-
-
- fprintf(stderr, "This program is intended to be a demo of the Little CMS\n"
- "color engine. Both lcms and this program are open source.\n"
- "You can obtain both in source code at https://www.littlecms.com\n"
- "For suggestions, comments, bug reports etc. send mail to\n"
- "info@littlecms.com\n\n");
-
- exit(0);
-}
-
-
-// The toggles stuff
-
-static
-void HandleSwitches(int argc, char *argv[])
-{
- int s;
-
- while ((s=xgetopt(argc,argv,"bBnNvVGgh:H:i:I:o:O:P:p:t:T:c:C:Q:q:M:m:L:l:eEs:S:!:D:d:-:")) != EOF) {
-
- switch (s)
- {
-
- case '-':
- if (strcmp(xoptarg, "help") == 0)
- {
- Help(0);
- }
- else
- {
- FatalError("Unknown option - run without args to see valid ones.\n");
- }
- break;
-
- case 'b':
- case 'B':
- BlackPointCompensation = TRUE;
- break;
-
- case 'd':
- case 'D': ObserverAdaptationState = atof(xoptarg);
- if (ObserverAdaptationState < 0 ||
- ObserverAdaptationState > 1.0)
- FatalError("Adaptation state should be 0..1");
- break;
-
- case 'v':
- case 'V':
- Verbose = TRUE;
- break;
-
- case 'i':
- case 'I':
- if (lIsDeviceLink)
- FatalError("Device-link already specified");
-
- cInpProf = xoptarg;
- break;
-
- case 'o':
- case 'O':
- if (lIsDeviceLink)
- FatalError("Device-link already specified");
-
- cOutProf = xoptarg;
- break;
-
- case 'l':
- case 'L':
- if (cInpProf != NULL || cOutProf != NULL)
- FatalError("input/output profiles already specified");
-
- cInpProf = xoptarg;
- lIsDeviceLink = TRUE;
- break;
-
- case 'p':
- case 'P':
- cProofing = xoptarg;
- break;
-
- case 't':
- case 'T':
- Intent = atoi(xoptarg);
- break;
-
- case 'N':
- case 'n':
- IgnoreEmbedded = TRUE;
- break;
-
- case 'e':
- case 'E':
- EmbedProfile = TRUE;
- break;
-
-
- case 'g':
- case 'G':
- GamutCheck = TRUE;
- break;
-
- case 'c':
- case 'C':
- PrecalcMode = atoi(xoptarg);
- if (PrecalcMode < 0 || PrecalcMode > 2)
- FatalError("Unknown precalc mode '%d'", PrecalcMode);
- break;
-
- case 'H':
- case 'h': {
-
- int a = atoi(xoptarg);
- Help(a);
- }
- break;
-
- case 'q':
- case 'Q':
- jpegQuality = atoi(xoptarg);
- if (jpegQuality > 100) jpegQuality = 100;
- if (jpegQuality < 0) jpegQuality = 0;
- break;
-
- case 'm':
- case 'M':
- ProofingIntent = atoi(xoptarg);
- break;
-
- case 's':
- case 'S': SaveEmbedded = xoptarg;
- break;
-
- case '!':
- if (sscanf(xoptarg, "%hu,%hu,%hu", &Alarm[0], &Alarm[1], &Alarm[2]) == 3) {
- int i;
- for (i=0; i < 3; i++) {
- Alarm[i] = (Alarm[i] << 8) | Alarm[i];
- }
- }
- break;
-
- default:
-
- FatalError("Unknown option - run without args to see valid ones");
- }
-
- }
-}
-
-
-int main(int argc, char* argv[])
-{
-
- fprintf(stderr, "Little CMS ICC profile applier for JPEG - v3.4 [LittleCMS %2.2f]\n\n", cmsGetEncodedCMMversion() / 1000.0);
- fprintf(stderr, "Copyright (c) 1998-2023 Marti Maria Saguer. See COPYING file for details.\n");
- fflush(stderr);
-
- InitUtils("jpgicc");
-
- HandleSwitches(argc, argv);
-
- if ((argc - xoptind) != 2) {
- Help(0);
- }
-
- OpenInput(argv[xoptind]);
- OpenOutput(argv[xoptind+1]);
-
- TransformImage(cInpProf, cOutProf);
-
-
- if (Verbose) { fprintf(stdout, "\n"); fflush(stdout); }
-
- Done();
-
- return 0;
-}
-
-
-
diff --git a/contrib/libs/lcms2/utils/jpgicc/ya.make b/contrib/libs/lcms2/utils/jpgicc/ya.make
deleted file mode 100644
index f92e446ed3..0000000000
--- a/contrib/libs/lcms2/utils/jpgicc/ya.make
+++ /dev/null
@@ -1,62 +0,0 @@
-# Generated by devtools/yamaker.
-
-PROGRAM()
-
-LICENSE(
- IJG AND
- MIT
-)
-
-LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
-
-VERSION(2.16)
-
-PEERDIR(
- contrib/libs/lcms2
- contrib/libs/libjpeg-turbo
-)
-
-ADDINCL(
- contrib/libs/lcms2/include
- contrib/libs/lcms2/utils/common
- contrib/libs/lcms2/utils/jpgicc
- contrib/libs/libjpeg-turbo
-)
-
-NO_COMPILER_WARNINGS()
-
-NO_RUNTIME()
-
-CFLAGS(
- -DHAVE_DLFCN_H=1
- -DHAVE_FUNC_ATTRIBUTE_VISIBILITY=1
- -DHAVE_GMTIME_R=1
- -DHAVE_INTTYPES_H=1
- -DHAVE_PTHREAD=1
- -DHAVE_PTHREAD_PRIO_INHERIT=1
- -DHAVE_STDINT_H=1
- -DHAVE_STDIO_H=1
- -DHAVE_STDLIB_H=1
- -DHAVE_STRINGS_H=1
- -DHAVE_STRING_H=1
- -DHAVE_SYS_STAT_H=1
- -DHAVE_SYS_TYPES_H=1
- -DHAVE_TIFFCONF_H=1
- -DHAVE_UNISTD_H=1
- -DHasJPEG=1
- -DHasTHREADS=1
- -DHasTIFF=1
- -DHasZLIB=1
- -DLT_OBJDIR=\".libs/\"
-)
-
-SRCDIR(contrib/libs/lcms2/utils)
-
-SRCS(
- common/vprf.c
- common/xgetopt.c
- jpgicc/iccjpeg.c
- jpgicc/jpgicc.c
-)
-
-END()
diff --git a/contrib/libs/lcms2/utils/linkicc/.yandex_meta/licenses.list.txt b/contrib/libs/lcms2/utils/linkicc/.yandex_meta/licenses.list.txt
deleted file mode 100644
index 7accfb5141..0000000000
--- a/contrib/libs/lcms2/utils/linkicc/.yandex_meta/licenses.list.txt
+++ /dev/null
@@ -1,83 +0,0 @@
-====================COPYRIGHT====================
-// Copyright (c) 1998-2023 Marti Maria Saguer
-
-
-====================File: AUTHORS====================
-
-Main Author
-------------
-Marti Maria
-
-
-Contributors
-------------
-Bob Friesenhahn
-Kai-Uwe Behrmann
-Stuart Nixon
-Jordi Vilar
-Richard Hughes
-Auke Nauta
-Chris Evans (Google)
-Lorenzo Ridolfi
-Robin Watts (Artifex)
-Shawn Pedersen
-Andrew Brygin
-Samuli Suominen
-Florian Höch
-Aurelien Jarno
-Claudiu Cebuc
-Michael Vhrel (Artifex)
-Michal Cihar
-Daniel Kaneider
-Mateusz Jurczyk (Google)
-Paul Miller
-Sébastien Léon
-Christian Schmitz
-XhmikosR
-Stanislav Brabec (SuSe)
-Leonhard Gruenschloss (Google)
-Patrick Noffke
-Christopher James Halse Rogers
-John Hein
-Thomas Weber (Debian)
-Mark Allen
-Noel Carboni
-Sergei Trofimovic
-Philipp Knechtges
-Amyspark
-Lovell Fuller
-Eli Schwartz
-Diogo Teles Sant'Anna
-
-Special Thanks
---------------
-Artifex software
-AlienSkin software
-libVIPS
-Jan Morovic
-Jos Vernon (WebSupergoo)
-Harald Schneider (Maxon)
-Christian Albrecht
-Dimitrios Anastassakis
-Lemke Software
-Tim Zaman
-
-
-====================MIT====================
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/contrib/libs/lcms2/utils/linkicc/linkicc.c b/contrib/libs/lcms2/utils/linkicc/linkicc.c
deleted file mode 100644
index a227ed26f8..0000000000
--- a/contrib/libs/lcms2/utils/linkicc/linkicc.c
+++ /dev/null
@@ -1,380 +0,0 @@
-//---------------------------------------------------------------------------------
-//
-// Little Color Management System
-// Copyright (c) 1998-2023 Marti Maria Saguer
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//---------------------------------------------------------------------------------
-
-#include "utils.h"
-
-// ---------------------------------------------------------------------------------
-
-static char* Description = "Devicelink profile";
-static char* Copyright = "No copyright, use freely";
-static int Intent = INTENT_PERCEPTUAL;
-static char* cOutProf = "devicelink.icc";
-static int PrecalcMode = 1;
-static int NumOfGridPoints = 0;
-
-static cmsFloat64Number ObserverAdaptationState = 1.0; // According ICC 4.2 this is the default
-
-static cmsBool BlackPointCompensation = FALSE;
-
-static cmsFloat64Number InkLimit = 400;
-static cmsBool lUse8bits = FALSE;
-static cmsBool TagResult = FALSE;
-static cmsBool KeepLinearization = FALSE;
-static cmsFloat64Number Version = 4.3;
-
-
-// The manual
-static
-int Help(int level)
-{
- UTILS_UNUSED_PARAMETER(level);
-
- fprintf(stderr, "\nlinkicc: Links profiles into a single devicelink.\n");
-
- fprintf(stderr, "\n");
- fprintf(stderr, "usage: linkicc [flags] <profiles>\n\n");
- fprintf(stderr, "flags:\n\n");
- fprintf(stderr, "-o<profile> - Output devicelink profile. [defaults to 'devicelink.icc']\n");
-
- PrintRenderingIntents();
-
- fprintf(stderr, "-c<0,1,2> - Precision (0=LowRes, 1=Normal, 2=Hi-res) [defaults to 1]\n");
- fprintf(stderr, "-n<gridpoints> - Alternate way to set precision, number of CLUT points\n");
- fprintf(stderr, "-d<description> - description text (quotes can be used)\n");
- fprintf(stderr, "-y<copyright> - copyright notice (quotes can be used)\n");
-
- fprintf(stderr, "\n-k<0..400> - Ink-limiting in %% (CMYK only)\n");
- fprintf(stderr, "-8 - Creates 8-bit devicelink\n");
- fprintf(stderr, "-x - Creatively, guess deviceclass of resulting profile.\n");
- fprintf(stderr, "-b - Black point compensation\n");
- fprintf(stderr, "-a<0..1> - Observer adaptation state (abs.col. only)\n\n");
- fprintf(stderr, "-l - Use linearization curves (may affect accuracy)\n");
- fprintf(stderr, "-r<v.r> - Profile version. (CAUTION: may change the profile implementation)\n");
- fprintf(stderr, "\n");
- fprintf(stderr, "Colorspaces must be paired except Lab/XYZ, that can be interchanged.\n\n");
-
- PrintBuiltins();
-
- fprintf(stderr, "\nExamples:\n\n"
- "To create 'devicelink.icm' from a.icc to b.icc:\n"
- "\tlinkicc a.icc b.icc\n\n"
- "To create 'out.icc' from sRGB to cmyk.icc:\n"
- "\tlinkicc -o out.icc *sRGB cmyk.icc\n\n"
- "To create a sRGB input profile working in Lab:\n"
- "\tlinkicc -x -o sRGBLab.icc *sRGB *Lab\n\n"
- "To create a XYZ -> sRGB output profile:\n"
- "\tlinkicc -x -o sRGBLab.icc *XYZ *sRGB\n\n"
- "To create a abstract profile doing softproof for cmyk.icc:\n"
- "\tlinkicc -t1 -x -o softproof.icc *Lab cmyk.icc cmyk.icc *Lab\n\n"
- "To create a 'grayer' sRGB input profile:\n"
- "\tlinkicc -x -o grayer.icc *sRGB gray.icc gray.icc *Lab\n\n"
- "To embed ink limiting into a cmyk output profile:\n"
- "\tlinkicc -x -o cmyklimited.icc -k 250 cmyk.icc *Lab\n\n");
-
- fprintf(stderr, "This program is intended to be a demo of the Little CMS\n"
- "color engine. Both lcms and this program are open source.\n"
- "You can obtain both in source code at https://www.littlecms.com\n"
- "For suggestions, comments, bug reports etc. send mail to\n"
- "info@littlecms.com\n\n");
-
- exit(0);
-}
-
-// The toggles stuff
-static
-void HandleSwitches(int argc, char *argv[])
-{
- int s;
-
- while ((s = xgetopt(argc,argv,"a:A:BbC:c:D:d:h:H:k:K:lLn:N:O:o:r:R:T:t:V:v:xX8y:Y:-:")) != EOF) {
-
- switch (s) {
-
- case '-':
- if (strcmp(xoptarg, "help") == 0)
- {
- Help(0);
- }
- else
- {
- FatalError("Unknown option - run without args to see valid ones.\n");
- }
- break;
-
- case 'a':
- case 'A':
- ObserverAdaptationState = atof(xoptarg);
- if (ObserverAdaptationState < 0 ||
- ObserverAdaptationState > 1.0)
- FatalError("Adaptation state should be 0..1");
- break;
-
- case 'b':
- case 'B':
- BlackPointCompensation = TRUE;
- break;
-
- case 'c':
- case 'C':
- PrecalcMode = atoi(xoptarg);
- if (PrecalcMode < 0 || PrecalcMode > 2) {
- FatalError("Unknown precalc mode '%d'", PrecalcMode);
- }
- break;
-
- case 'd':
- case 'D':
- // Doing that is correct and safe: Description points to memory allocated in the command line.
- // same for Copyright and output devicelink.
- Description = xoptarg;
- break;
-
- case 'h':
- case 'H':
- Help(atoi(xoptarg));
- return;
-
- case 'k':
- case 'K':
- InkLimit = atof(xoptarg);
- if (InkLimit < 0.0 || InkLimit > 400.0) {
- FatalError("Ink limit must be 0%%..400%%");
- }
- break;
-
-
- case 'l':
- case 'L': KeepLinearization = TRUE;
- break;
-
- case 'n':
- case 'N':
- if (PrecalcMode != 1) {
- FatalError("Precalc mode already specified");
- }
- NumOfGridPoints = atoi(xoptarg);
- break;
-
- case 'o':
- case 'O':
- cOutProf = xoptarg;
- break;
-
-
- case 'r':
- case 'R':
- Version = atof(xoptarg);
- if (Version < 2.0 || Version > 4.3) {
- fprintf(stderr, "WARNING: lcms was not aware of this version, tag types may be wrong!\n");
- }
- break;
-
- case 't':
- case 'T':
- Intent = atoi(xoptarg); // Will be validated latter on
- break;
-
- case 'V':
- case 'v':
- Verbose = atoi(xoptarg);
- if (Verbose < 0 || Verbose > 3) {
- FatalError("Unknown verbosity level '%d'", Verbose);
- }
- break;
-
- case '8':
- lUse8bits = TRUE;
- break;
-
-
-
- case 'y':
- case 'Y':
- Copyright = xoptarg;
- break;
-
-
-
- case 'x':
- case 'X': TagResult = TRUE;
- break;
-
-
- default:
-
- FatalError("Unknown option - run without args to see valid ones.\n");
- }
- }
-}
-
-// Set the copyright and description
-static
-cmsBool SetTextTags(cmsHPROFILE hProfile)
-{
- cmsMLU *DescriptionMLU, *CopyrightMLU;
- cmsBool rc = FALSE;
- cmsContext ContextID = cmsGetProfileContextID(hProfile);
-
- DescriptionMLU = cmsMLUalloc(ContextID, 1);
- CopyrightMLU = cmsMLUalloc(ContextID, 1);
-
- if (DescriptionMLU == NULL || CopyrightMLU == NULL) goto Error;
-
- if (!cmsMLUsetASCII(DescriptionMLU, "en", "US", Description)) goto Error;
- if (!cmsMLUsetASCII(CopyrightMLU, "en", "US", Copyright)) goto Error;
-
- if (!cmsWriteTag(hProfile, cmsSigProfileDescriptionTag, DescriptionMLU)) goto Error;
- if (!cmsWriteTag(hProfile, cmsSigCopyrightTag, CopyrightMLU)) goto Error;
-
- rc = TRUE;
-
-Error:
-
- if (DescriptionMLU)
- cmsMLUfree(DescriptionMLU);
- if (CopyrightMLU)
- cmsMLUfree(CopyrightMLU);
- return rc;
-}
-
-
-
-int main(int argc, char *argv[])
-{
- int i, nargs, rc;
- cmsHPROFILE Profiles[257];
- cmsHPROFILE hProfile;
- cmsUInt32Number dwFlags;
- cmsHTRANSFORM hTransform = NULL;
-
- // Here we are
- fprintf(stderr, "Little CMS ICC device link generator - v3.2 [LittleCMS %2.2f]\n", cmsGetEncodedCMMversion() / 1000.0);
- fprintf(stderr, "Copyright (c) 1998-2023 Marti Maria Saguer. See COPYING file for details.\n");
- fflush(stderr);
-
- // Initialize
- InitUtils("linkicc");
- rc = 0;
-
- // Get the options
- HandleSwitches(argc, argv);
-
- // How many profiles to link?
- nargs = (argc - xoptind);
- if (nargs < 1)
- return Help(0);
-
- if (nargs > 255) {
- FatalError("Holy profile! what are you trying to do with so many profiles!?");
- goto Cleanup;
- }
-
- // Open all profiles
- memset(Profiles, 0, sizeof(Profiles));
- for (i=0; i < nargs; i++) {
-
- Profiles[i] = OpenStockProfile(0, argv[i + xoptind]);
- if (Profiles[i] == NULL) goto Cleanup;
-
- if (Verbose >= 1) {
- PrintProfileInformation(Profiles[i]);
- }
- }
-
- // Ink limiting
- if (InkLimit != 400.0) {
- cmsColorSpaceSignature EndingColorSpace = cmsGetColorSpace(Profiles[nargs-1]);
- Profiles[nargs++] = cmsCreateInkLimitingDeviceLink(EndingColorSpace, InkLimit);
- }
-
- // Set the flags
- dwFlags = cmsFLAGS_KEEP_SEQUENCE;
- switch (PrecalcMode) {
-
- case 0: dwFlags |= cmsFLAGS_LOWRESPRECALC; break;
- case 2: dwFlags |= cmsFLAGS_HIGHRESPRECALC; break;
- case 1:
- if (NumOfGridPoints > 0)
- dwFlags |= cmsFLAGS_GRIDPOINTS(NumOfGridPoints);
- break;
-
- default:
- {
- FatalError("Unknown precalculation mode '%d'", PrecalcMode);
- goto Cleanup;
- }
- }
-
- if (BlackPointCompensation)
- dwFlags |= cmsFLAGS_BLACKPOINTCOMPENSATION;
-
- if (TagResult)
- dwFlags |= cmsFLAGS_GUESSDEVICECLASS;
-
- if (KeepLinearization)
- dwFlags |= cmsFLAGS_CLUT_PRE_LINEARIZATION|cmsFLAGS_CLUT_POST_LINEARIZATION;
-
- if (lUse8bits) dwFlags |= cmsFLAGS_8BITS_DEVICELINK;
-
- cmsSetAdaptationState(ObserverAdaptationState);
-
- // Create the color transform. Specify 0 for the format is safe as the transform
- // is intended to be used only for the devicelink.
- hTransform = cmsCreateMultiprofileTransform(Profiles, nargs, 0, 0, Intent, dwFlags|cmsFLAGS_NOOPTIMIZE);
- if (hTransform == NULL) {
- FatalError("Transform creation failed");
- goto Cleanup;
- }
-
- hProfile = cmsTransform2DeviceLink(hTransform, Version, dwFlags);
- if (hProfile == NULL) {
- FatalError("Devicelink creation failed");
- goto Cleanup;
- }
-
- SetTextTags(hProfile);
- cmsSetHeaderRenderingIntent(hProfile, Intent);
-
- if (cmsSaveProfileToFile(hProfile, cOutProf)) {
-
- if (Verbose > 0)
- fprintf(stderr, "Ok");
- }
- else
- FatalError("Error saving file!");
-
- cmsCloseProfile(hProfile);
-
-
-Cleanup:
-
- if (hTransform != NULL) cmsDeleteTransform(hTransform);
- for (i=0; i < nargs; i++) {
-
- if (Profiles[i] != NULL) cmsCloseProfile(Profiles[i]);
- }
-
- return rc;
-}
diff --git a/contrib/libs/lcms2/utils/linkicc/ya.make b/contrib/libs/lcms2/utils/linkicc/ya.make
deleted file mode 100644
index 615968d9cb..0000000000
--- a/contrib/libs/lcms2/utils/linkicc/ya.make
+++ /dev/null
@@ -1,56 +0,0 @@
-# Generated by devtools/yamaker.
-
-PROGRAM()
-
-LICENSE(MIT)
-
-LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
-
-VERSION(2.16)
-
-PEERDIR(
- contrib/libs/lcms2
-)
-
-ADDINCL(
- contrib/libs/lcms2/include
- contrib/libs/lcms2/utils/common
- contrib/libs/lcms2/utils/linkicc
-)
-
-NO_COMPILER_WARNINGS()
-
-NO_RUNTIME()
-
-CFLAGS(
- -DHAVE_DLFCN_H=1
- -DHAVE_FUNC_ATTRIBUTE_VISIBILITY=1
- -DHAVE_GMTIME_R=1
- -DHAVE_INTTYPES_H=1
- -DHAVE_PTHREAD=1
- -DHAVE_PTHREAD_PRIO_INHERIT=1
- -DHAVE_STDINT_H=1
- -DHAVE_STDIO_H=1
- -DHAVE_STDLIB_H=1
- -DHAVE_STRINGS_H=1
- -DHAVE_STRING_H=1
- -DHAVE_SYS_STAT_H=1
- -DHAVE_SYS_TYPES_H=1
- -DHAVE_TIFFCONF_H=1
- -DHAVE_UNISTD_H=1
- -DHasJPEG=1
- -DHasTHREADS=1
- -DHasTIFF=1
- -DHasZLIB=1
- -DLT_OBJDIR=\".libs/\"
-)
-
-SRCDIR(contrib/libs/lcms2/utils)
-
-SRCS(
- common/vprf.c
- common/xgetopt.c
- linkicc/linkicc.c
-)
-
-END()
diff --git a/contrib/libs/lcms2/utils/psicc/.yandex_meta/licenses.list.txt b/contrib/libs/lcms2/utils/psicc/.yandex_meta/licenses.list.txt
deleted file mode 100644
index 7accfb5141..0000000000
--- a/contrib/libs/lcms2/utils/psicc/.yandex_meta/licenses.list.txt
+++ /dev/null
@@ -1,83 +0,0 @@
-====================COPYRIGHT====================
-// Copyright (c) 1998-2023 Marti Maria Saguer
-
-
-====================File: AUTHORS====================
-
-Main Author
-------------
-Marti Maria
-
-
-Contributors
-------------
-Bob Friesenhahn
-Kai-Uwe Behrmann
-Stuart Nixon
-Jordi Vilar
-Richard Hughes
-Auke Nauta
-Chris Evans (Google)
-Lorenzo Ridolfi
-Robin Watts (Artifex)
-Shawn Pedersen
-Andrew Brygin
-Samuli Suominen
-Florian Höch
-Aurelien Jarno
-Claudiu Cebuc
-Michael Vhrel (Artifex)
-Michal Cihar
-Daniel Kaneider
-Mateusz Jurczyk (Google)
-Paul Miller
-Sébastien Léon
-Christian Schmitz
-XhmikosR
-Stanislav Brabec (SuSe)
-Leonhard Gruenschloss (Google)
-Patrick Noffke
-Christopher James Halse Rogers
-John Hein
-Thomas Weber (Debian)
-Mark Allen
-Noel Carboni
-Sergei Trofimovic
-Philipp Knechtges
-Amyspark
-Lovell Fuller
-Eli Schwartz
-Diogo Teles Sant'Anna
-
-Special Thanks
---------------
-Artifex software
-AlienSkin software
-libVIPS
-Jan Morovic
-Jos Vernon (WebSupergoo)
-Harald Schneider (Maxon)
-Christian Albrecht
-Dimitrios Anastassakis
-Lemke Software
-Tim Zaman
-
-
-====================MIT====================
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/contrib/libs/lcms2/utils/psicc/psicc.c b/contrib/libs/lcms2/utils/psicc/psicc.c
deleted file mode 100644
index 97d3f0760d..0000000000
--- a/contrib/libs/lcms2/utils/psicc/psicc.c
+++ /dev/null
@@ -1,249 +0,0 @@
-//---------------------------------------------------------------------------------
-//
-// Little Color Management System
-// Copyright (c) 1998-2023 Marti Maria Saguer
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//---------------------------------------------------------------------------------
-
-#include "utils.h"
-
-// ------------------------------------------------------------------------
-
-static char *cInProf = NULL;
-static char *cOutProf = NULL;
-static int Intent = INTENT_PERCEPTUAL;
-static FILE* OutFile;
-static int BlackPointCompensation = FALSE;
-static int Undecorated = FALSE;
-static int PrecalcMode = 1;
-static int NumOfGridPoints = 0;
-
-
-
-static
-void Help(void)
-{
- fprintf(stderr, "usage: psicc [flags] [<Output file>]\n\n");
-
- fprintf(stderr, "flags:\n\n");
-
- fprintf(stderr, "-i<profile> - Input profile: Generates Color Space Array (CSA)\n");
- fprintf(stderr, "-o<profile> - Output profile: Generates Color Rendering Dictionary(CRD)\n");
-
- fprintf(stderr, "-t<0,1,2,3> - Intent (0=Perceptual, 1=Colorimetric, 2=Saturation, 3=Absolute)\n");
-
- fprintf(stderr, "-b - Black point compensation (CRD only)\n");
- fprintf(stderr, "-u - Do NOT generate resource name on CRD\n");
- fprintf(stderr, "-c<0,1,2> - Precision (0=LowRes, 1=Normal (default), 2=Hi-res) (CRD only)\n");
- fprintf(stderr, "-n<gridpoints> - Alternate way to set precision, number of CLUT points (CRD only)\n");
-
- fprintf(stderr, "\n");
- fprintf(stderr, "If no output file is specified, output goes to stdout.\n\n");
- fprintf(stderr, "This program is intended to be a demo of the little cms\n"
- "engine. Both lcms and this program are freeware. You can\n"
- "obtain both in source code at https://www.littlecms.com\n"
- "For suggestions, comments, bug reports etc. send mail to\n"
- "info@littlecms.com\n\n");
-
- exit(0);
-}
-
-// The toggles stuff
-
-static
-void HandleSwitches(int argc, char *argv[])
-{
- int s;
-
- while ((s = xgetopt(argc,argv,"uUbBI:i:O:o:T:t:c:C:n:N:-:")) != EOF) {
-
- switch (s)
- {
-
- case '-':
- if (strcmp(xoptarg, "help") == 0)
- {
- Help();
- }
- else
- {
- FatalError("Unknown option - run without args to see valid ones.\n");
- }
- break;
-
- case 'i':
- case 'I':
- cInProf = xoptarg;
- break;
-
- case 'o':
- case 'O':
- cOutProf = xoptarg;
- break;
-
- case 'b':
- case 'B': BlackPointCompensation =TRUE;
- break;
-
-
- case 't':
- case 'T':
- Intent = atoi(xoptarg);
- if (Intent > 3) Intent = 3;
- if (Intent < 0) Intent = 0;
- break;
-
- case 'U':
- case 'u':
- Undecorated = TRUE;
- break;
-
- case 'c':
- case 'C':
- PrecalcMode = atoi(xoptarg);
- if (PrecalcMode < 0 || PrecalcMode > 2)
- FatalError("ERROR: Unknown precalc mode '%d'", PrecalcMode);
- break;
-
-
- case 'n':
- case 'N':
- if (PrecalcMode != 1)
- FatalError("Precalc mode already specified");
- NumOfGridPoints = atoi(xoptarg);
- break;
-
-
- default:
-
- FatalError("Unknown option - run without args to see valid ones.\n");
- }
- }
-}
-
-
-
-
-static
-void GenerateCSA(void)
-{
- cmsHPROFILE hProfile = OpenStockProfile(0, cInProf);
- size_t n;
- char* Buffer;
-
- if (hProfile == NULL) return;
-
- n = cmsGetPostScriptCSA(0, hProfile, Intent, 0, NULL, 0);
- if (n == 0) return;
-
- Buffer = (char*) malloc(n + 1);
- if (Buffer != NULL) {
-
- cmsGetPostScriptCSA(0, hProfile, Intent, 0, Buffer, (cmsUInt32Number) n);
- Buffer[n] = 0;
-
- fprintf(OutFile, "%s", Buffer);
-
- free(Buffer);
- }
-
- cmsCloseProfile(hProfile);
-}
-
-
-static
-void GenerateCRD(void)
-{
- cmsHPROFILE hProfile = OpenStockProfile(0, cOutProf);
- size_t n;
- char* Buffer;
- cmsUInt32Number dwFlags = 0;
-
- if (hProfile == NULL) return;
-
- if (BlackPointCompensation) dwFlags |= cmsFLAGS_BLACKPOINTCOMPENSATION;
- if (Undecorated) dwFlags |= cmsFLAGS_NODEFAULTRESOURCEDEF;
-
- switch (PrecalcMode) {
-
- case 0: dwFlags |= cmsFLAGS_LOWRESPRECALC; break;
- case 2: dwFlags |= cmsFLAGS_HIGHRESPRECALC; break;
- case 1:
- if (NumOfGridPoints > 0)
- dwFlags |= cmsFLAGS_GRIDPOINTS(NumOfGridPoints);
- break;
-
- default: FatalError("ERROR: Unknown precalculation mode '%d'", PrecalcMode);
- }
-
- n = cmsGetPostScriptCRD(0, hProfile, Intent, dwFlags, NULL, 0);
- if (n == 0) return;
-
- Buffer = (char*) malloc(n + 1);
- if (Buffer == NULL) return;
- cmsGetPostScriptCRD(0, hProfile, Intent, dwFlags, Buffer, (cmsUInt32Number) n);
- Buffer[n] = 0;
-
- fprintf(OutFile, "%s", Buffer);
- free(Buffer);
- cmsCloseProfile(hProfile);
-}
-
-
-int main(int argc, char *argv[])
-{
- int nargs;
-
- fprintf(stderr, "Little CMS ICC PostScript generator - v2.1 [LittleCMS %2.2f]\n", cmsGetEncodedCMMversion() / 1000.0);
- fprintf(stderr, "Copyright (c) 1998-2023 Marti Maria Saguer. See COPYING file for details.\n");
- fflush(stderr);
-
- // Initialize
- InitUtils("psicc");
-
- HandleSwitches(argc, argv);
-
- nargs = (argc - xoptind);
- if (nargs != 0 && nargs != 1)
- Help();
-
- if (cInProf == NULL && cOutProf == NULL)
- Help();
-
- if (nargs == 0)
- OutFile = stdout;
- else
- OutFile = fopen(argv[xoptind], "wt");
-
- if (cInProf != NULL)
- GenerateCSA();
-
- if (cOutProf != NULL)
- GenerateCRD();
-
- if (nargs == 1) {
- fclose(OutFile);
- }
-
- return 0;
-}
-
-
diff --git a/contrib/libs/lcms2/utils/psicc/ya.make b/contrib/libs/lcms2/utils/psicc/ya.make
deleted file mode 100644
index 259253b8cd..0000000000
--- a/contrib/libs/lcms2/utils/psicc/ya.make
+++ /dev/null
@@ -1,56 +0,0 @@
-# Generated by devtools/yamaker.
-
-PROGRAM()
-
-LICENSE(MIT)
-
-LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
-
-VERSION(2.16)
-
-PEERDIR(
- contrib/libs/lcms2
-)
-
-ADDINCL(
- contrib/libs/lcms2/include
- contrib/libs/lcms2/utils/common
- contrib/libs/lcms2/utils/psicc
-)
-
-NO_COMPILER_WARNINGS()
-
-NO_RUNTIME()
-
-CFLAGS(
- -DHAVE_DLFCN_H=1
- -DHAVE_FUNC_ATTRIBUTE_VISIBILITY=1
- -DHAVE_GMTIME_R=1
- -DHAVE_INTTYPES_H=1
- -DHAVE_PTHREAD=1
- -DHAVE_PTHREAD_PRIO_INHERIT=1
- -DHAVE_STDINT_H=1
- -DHAVE_STDIO_H=1
- -DHAVE_STDLIB_H=1
- -DHAVE_STRINGS_H=1
- -DHAVE_STRING_H=1
- -DHAVE_SYS_STAT_H=1
- -DHAVE_SYS_TYPES_H=1
- -DHAVE_TIFFCONF_H=1
- -DHAVE_UNISTD_H=1
- -DHasJPEG=1
- -DHasTHREADS=1
- -DHasTIFF=1
- -DHasZLIB=1
- -DLT_OBJDIR=\".libs/\"
-)
-
-SRCDIR(contrib/libs/lcms2/utils)
-
-SRCS(
- common/vprf.c
- common/xgetopt.c
- psicc/psicc.c
-)
-
-END()
diff --git a/contrib/libs/lcms2/utils/tificc/.yandex_meta/licenses.list.txt b/contrib/libs/lcms2/utils/tificc/.yandex_meta/licenses.list.txt
deleted file mode 100644
index 7accfb5141..0000000000
--- a/contrib/libs/lcms2/utils/tificc/.yandex_meta/licenses.list.txt
+++ /dev/null
@@ -1,83 +0,0 @@
-====================COPYRIGHT====================
-// Copyright (c) 1998-2023 Marti Maria Saguer
-
-
-====================File: AUTHORS====================
-
-Main Author
-------------
-Marti Maria
-
-
-Contributors
-------------
-Bob Friesenhahn
-Kai-Uwe Behrmann
-Stuart Nixon
-Jordi Vilar
-Richard Hughes
-Auke Nauta
-Chris Evans (Google)
-Lorenzo Ridolfi
-Robin Watts (Artifex)
-Shawn Pedersen
-Andrew Brygin
-Samuli Suominen
-Florian Höch
-Aurelien Jarno
-Claudiu Cebuc
-Michael Vhrel (Artifex)
-Michal Cihar
-Daniel Kaneider
-Mateusz Jurczyk (Google)
-Paul Miller
-Sébastien Léon
-Christian Schmitz
-XhmikosR
-Stanislav Brabec (SuSe)
-Leonhard Gruenschloss (Google)
-Patrick Noffke
-Christopher James Halse Rogers
-John Hein
-Thomas Weber (Debian)
-Mark Allen
-Noel Carboni
-Sergei Trofimovic
-Philipp Knechtges
-Amyspark
-Lovell Fuller
-Eli Schwartz
-Diogo Teles Sant'Anna
-
-Special Thanks
---------------
-Artifex software
-AlienSkin software
-libVIPS
-Jan Morovic
-Jos Vernon (WebSupergoo)
-Harald Schneider (Maxon)
-Christian Albrecht
-Dimitrios Anastassakis
-Lemke Software
-Tim Zaman
-
-
-====================MIT====================
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/contrib/libs/lcms2/utils/tificc/tificc.c b/contrib/libs/lcms2/utils/tificc/tificc.c
deleted file mode 100644
index 1607fa6243..0000000000
--- a/contrib/libs/lcms2/utils/tificc/tificc.c
+++ /dev/null
@@ -1,1308 +0,0 @@
-//---------------------------------------------------------------------------------
-//
-// Little Color Management System
-// Copyright (c) 1998-2023 Marti Maria Saguer
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//---------------------------------------------------------------------------------
-
-// This program does apply profiles to (some) TIFF files
-
-#include "lcms2_plugin.h"
-#include "tiffio.h"
-#include "utils.h"
-
-// Fix broken libtiff 4.3.0, thanks to Bob Friesenhahn for uncovering this
-
-#if defined(HAVE_STDINT_H) && (TIFFLIB_VERSION >= 20201219)
-#include <stdint.h>
-# undef cmsUInt16Number
-# define cmsUInt16Number uint16_t
-# undef cmsUInt32Number
-# define cmsUInt32Number uint32_t
-#endif /* TIFFLIB_VERSION */
-
-// Flags
-
-static cmsBool BlackWhiteCompensation = FALSE;
-static cmsBool IgnoreEmbedded = FALSE;
-static cmsBool EmbedProfile = FALSE;
-static int PixelDepth = 8;
-static cmsBool GamutCheck = FALSE;
-static cmsBool lIsDeviceLink = FALSE;
-static cmsBool lIsCUBE = FALSE;
-static cmsBool StoreAsAlpha = FALSE;
-
-static int Intent = INTENT_PERCEPTUAL;
-static int ProofingIntent = INTENT_PERCEPTUAL;
-static int PrecalcMode = 1;
-static cmsFloat64Number InkLimit = 400;
-
-static cmsFloat64Number ObserverAdaptationState = 1.0; // According ICC 4.3 this is the default
-
-static const char *cInpProf = NULL;
-static const char *cOutProf = NULL;
-static const char *cProofing = NULL;
-
-static const char* SaveEmbedded = NULL;
-
-// Console error & warning
-static
-void ConsoleWarningHandler(const char* module, const char* fmt, va_list ap)
-{
- if (Verbose) {
-
- fprintf(stderr, "Warning: ");
-
- if (module != NULL)
- fprintf(stderr, "[%s] ", module);
-
- vfprintf(stderr, fmt, ap);
- fprintf(stderr, "\n");
- fflush(stderr);
- }
-}
-
-static
-void ConsoleErrorHandler(const char* module, const char* fmt, va_list ap)
-{
- if (Verbose) {
-
- fprintf(stderr, "Error: ");
-
- if (module != NULL)
- fprintf(stderr, "[%s] ", module);
-
- vfprintf(stderr, fmt, ap);
- fprintf(stderr, "\n");
- fflush(stderr);
- }
-
-}
-
-
-// Issue a warning
-static
-void Warning(const char *frm, ...)
-{
- va_list args;
-
- va_start(args, frm);
- ConsoleWarningHandler("tificc", frm, args);
- va_end(args);
-}
-
-
-
-// Out of memory is a fatal error
-static
-void OutOfMem(cmsUInt32Number size)
-{
- FatalError("Out of memory on allocating %d bytes.", size);
-}
-
-
-// -----------------------------------------------------------------------------------------------
-// Lab plug-in
-// In TIFF, Lab is encoded in a different way, so let's use the plug-in
-// capabilities of lcms2 to change the meaning of TYPE_Lab_8.
-
-#define LABTIFF_SH(m) ((m) << 30)
-#define T_LABTIFF(m) (((m)>>30)&1)
-
-// * 0xffff / 0xff00 = (255 * 257) / (255 * 256) = 257 / 256
-static
-int FromLabV2ToLabV4(int x)
-{
- int a;
-
- a = ((x << 8) | x) >> 8; // * 257 / 256
- if ( a > 0xffff) return 0xffff;
- return a;
-}
-
-// * 0xf00 / 0xffff = * 256 / 257
-static
-int FromLabV4ToLabV2(int x)
-{
- return ((x << 8) + 0x80) / 257;
-}
-
-
-// Formatter for 8bit Lab TIFF (photometric 8)
-static
-unsigned char* UnrollTIFFLab8(struct _cmstransform_struct* CMMcargo,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride)
-{
- wIn[0] = (cmsUInt16Number) FromLabV2ToLabV4((accum[0]) << 8);
- wIn[1] = (cmsUInt16Number) FromLabV2ToLabV4(((accum[1] > 127) ? (accum[1] - 128) : (accum[1] + 128)) << 8);
- wIn[2] = (cmsUInt16Number) FromLabV2ToLabV4(((accum[2] > 127) ? (accum[2] - 128) : (accum[2] + 128)) << 8);
-
- return accum + 3;
-
- UTILS_UNUSED_PARAMETER(Stride);
- UTILS_UNUSED_PARAMETER(CMMcargo);
-}
-
-// Formatter for 16bit Lab TIFF (photometric 8)
-static
-unsigned char* UnrollTIFFLab16(struct _cmstransform_struct* CMMcargo,
- CMSREGISTER cmsUInt16Number wIn[],
- CMSREGISTER cmsUInt8Number* accum,
- CMSREGISTER cmsUInt32Number Stride )
-{
- cmsUInt16Number* accum16 = (cmsUInt16Number*) accum;
-
- wIn[0] = (cmsUInt16Number) FromLabV2ToLabV4(accum16[0]);
- wIn[1] = (cmsUInt16Number) FromLabV2ToLabV4(((accum16[1] > 0x7f00) ? (accum16[1] - 0x8000) : (accum16[1] + 0x8000)) );
- wIn[2] = (cmsUInt16Number) FromLabV2ToLabV4(((accum16[2] > 0x7f00) ? (accum16[2] - 0x8000) : (accum16[2] + 0x8000)) );
-
- return accum + 3 * sizeof(cmsUInt16Number);
-
- UTILS_UNUSED_PARAMETER(Stride);
- UTILS_UNUSED_PARAMETER(CMMcargo);
-}
-
-
-static
-unsigned char* PackTIFFLab8(struct _cmstransform_struct* CMMcargo,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- int a, b;
-
- *output++ = (cmsUInt8Number) (FromLabV4ToLabV2(wOut[0] + 0x0080) >> 8);
-
- a = (FromLabV4ToLabV2(wOut[1]) + 0x0080) >> 8;
- b = (FromLabV4ToLabV2(wOut[2]) + 0x0080) >> 8;
-
- *output++ = (cmsUInt8Number) ((a < 128) ? (a + 128) : (a - 128));
- *output++ = (cmsUInt8Number) ((b < 128) ? (b + 128) : (b - 128));
-
- return output;
-
- UTILS_UNUSED_PARAMETER(Stride);
- UTILS_UNUSED_PARAMETER(CMMcargo);
-}
-
-
-static
-unsigned char* PackTIFFLabA8(struct _cmstransform_struct* CMMcargo,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- int a, b;
-
- *output++ = (cmsUInt8Number) (FromLabV4ToLabV2(wOut[0] + 0x0080) >> 8);
-
- a = (FromLabV4ToLabV2(wOut[1]) + 0x0080) >> 8;
- b = (FromLabV4ToLabV2(wOut[2]) + 0x0080) >> 8;
-
- *output++ = (cmsUInt8Number) ((a < 128) ? (a + 128) : (a - 128));
- *output++ = (cmsUInt8Number) ((b < 128) ? (b + 128) : (b - 128));
-
- output++; // Alpha
-
- return output;
-
- UTILS_UNUSED_PARAMETER(Stride);
- UTILS_UNUSED_PARAMETER(CMMcargo);
-}
-
-
-static
-unsigned char* PackTIFFLab16(struct _cmstransform_struct* CMMcargo,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- int a, b;
- cmsUInt16Number* output16 = (cmsUInt16Number*) output;
-
- *output16++ = (cmsUInt16Number) FromLabV4ToLabV2(wOut[0]);
-
- a = FromLabV4ToLabV2(wOut[1]);
- b = FromLabV4ToLabV2(wOut[2]);
-
- *output16++ = (cmsUInt16Number) ((a < 0x7f00) ? (a + 0x8000) : (a - 0x8000));
- *output16++ = (cmsUInt16Number) ((b < 0x7f00) ? (b + 0x8000) : (b - 0x8000));
-
- return (cmsUInt8Number*) output16;
-
- UTILS_UNUSED_PARAMETER(Stride);
- UTILS_UNUSED_PARAMETER(CMMcargo);
-}
-
-static
-unsigned char* PackTIFFLabA16(struct _cmstransform_struct* CMMcargo,
- CMSREGISTER cmsUInt16Number wOut[],
- CMSREGISTER cmsUInt8Number* output,
- CMSREGISTER cmsUInt32Number Stride)
-{
- int a, b;
- cmsUInt16Number* output16 = (cmsUInt16Number*) output;
-
- *output16++ = (cmsUInt16Number) FromLabV4ToLabV2(wOut[0]);
-
- a = FromLabV4ToLabV2(wOut[1]);
- b = FromLabV4ToLabV2(wOut[2]);
-
- *output16++ = (cmsUInt16Number) ((a < 0x7f00) ? (a + 0x8000) : (a - 0x8000));
- *output16++ = (cmsUInt16Number) ((b < 0x7f00) ? (b + 0x8000) : (b - 0x8000));
-
- output16++; // Alpha
-
- return (cmsUInt8Number*) output16;
-
- UTILS_UNUSED_PARAMETER(Stride);
- UTILS_UNUSED_PARAMETER(CMMcargo);
-}
-
-
-static
-cmsFormatter TiffFormatterFactory(cmsUInt32Number Type,
- cmsFormatterDirection Dir,
- cmsUInt32Number dwFlags)
-{
- cmsFormatter Result = { NULL };
- int bps = T_BYTES(Type);
- int IsTiffSpecial = T_LABTIFF(Type);
-
- if (IsTiffSpecial && !(dwFlags & CMS_PACK_FLAGS_FLOAT))
- {
- if (Dir == cmsFormatterInput)
- {
- Result.Fmt16 = (bps == 1) ? UnrollTIFFLab8 : UnrollTIFFLab16;
- }
- else
- {
- if (T_EXTRA(Type) == 1)
- Result.Fmt16 = (bps == 1) ? PackTIFFLabA8 : PackTIFFLabA16;
- else
- if (T_EXTRA(Type) == 0)
- Result.Fmt16 = (bps == 1) ? PackTIFFLab8 : PackTIFFLab16;
- }
- }
-
- return Result;
-}
-
-static cmsPluginFormatters TiffLabPlugin = { {cmsPluginMagicNumber, 2000, cmsPluginFormattersSig, NULL}, TiffFormatterFactory };
-
-// -----------------------------------------------------------------------------------------------
-
-// Build up the pixeltype descriptor
-static
-cmsUInt32Number GetInputPixelType(TIFF *Bank)
-{
- cmsUInt16Number Photometric, bps, spp, extra, PlanarConfig, *info;
- cmsUInt16Number Compression;
- int ColorChannels;
- int IsPremul = FALSE, IsPlanar = FALSE, IsFlt = FALSE, IsReverse = FALSE;
- int labTiffSpecial = FALSE;
- int pt = PT_ANY;
-
- TIFFGetFieldDefaulted(Bank, TIFFTAG_BITSPERSAMPLE, &bps);
-
- if (bps == 1)
- FatalError("Sorry, bilevel TIFFs has nothing to do with ICC profiles");
-
- if (bps != 8 && bps != 16 && bps != 32)
- FatalError("Sorry, 8, 16 or 32 bits per sample only");
-
-
- TIFFGetFieldDefaulted(Bank, TIFFTAG_PLANARCONFIG, &PlanarConfig);
-
- switch (PlanarConfig) {
-
- case PLANARCONFIG_CONTIG: IsPlanar = 0; break;
- case PLANARCONFIG_SEPARATE: IsPlanar = 1; break;
- default:
-
- FatalError("Unsupported planar configuration (=%d) ", (int) PlanarConfig);
- }
-
- TIFFGetFieldDefaulted(Bank, TIFFTAG_SAMPLESPERPIXEL, &spp);
-
- // If Samples per pixel == 1, PlanarConfiguration is irrelevant and need not to be included.
- if (spp == 1) IsPlanar = 0;
-
- // Any alpha?
- TIFFGetFieldDefaulted(Bank, TIFFTAG_EXTRASAMPLES, &extra, &info);
-
- // Read alpha channels as colorant?
- if (StoreAsAlpha) {
-
- ColorChannels = spp;
- extra = 0;
- }
- else
- ColorChannels = spp - extra;
-
- // Is alpha premultiplied ?
- IsPremul = ((extra == 1) && (info[0] == EXTRASAMPLE_ASSOCALPHA));
-
-
- // Get photometric interpretation and proceed accordly
- TIFFGetField(Bank, TIFFTAG_PHOTOMETRIC, &Photometric);
-
- switch (Photometric) {
-
- case PHOTOMETRIC_MINISWHITE:
-
- IsReverse = 1;
-
- // ... fall through ...
-
- case PHOTOMETRIC_MINISBLACK:
- pt = PT_GRAY;
- break;
-
- case PHOTOMETRIC_RGB:
- pt = PT_RGB;
- if (ColorChannels < 3)
- FatalError("Sorry, RGB needs at least 3 samples per pixel");
- break;
-
- case PHOTOMETRIC_PALETTE:
- FatalError("Sorry, palette images not supported");
- break;
-
- case PHOTOMETRIC_SEPARATED:
- pt = PixelTypeFromChanCount(ColorChannels);
- break;
-
- case PHOTOMETRIC_YCBCR:
- TIFFGetField(Bank, TIFFTAG_COMPRESSION, &Compression);
- {
- cmsUInt16Number subx, suby;
-
- pt = PT_YCbCr;
- TIFFGetFieldDefaulted(Bank, TIFFTAG_YCBCRSUBSAMPLING, &subx, &suby);
- if (subx != 1 || suby != 1)
- FatalError("Sorry, subsampled images are not supported");
- }
- break;
-
- // Two Lab flavours
- case PHOTOMETRIC_ICCLAB:
- pt = PT_Lab;
- break;
-
- case PHOTOMETRIC_CIELAB:
- pt = PT_Lab;
- labTiffSpecial = TRUE;
- break;
-
- // CIE Log2(L) (u',v')
- case PHOTOMETRIC_LOGLUV:
-
- TIFFSetField(Bank, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_16BIT);
- pt = PT_YUV; // *ICCSpace = icSigLuvData;
- bps = 16; // 16 bits forced by LibTiff
- break;
-
- default:
- FatalError("Unsupported TIFF color space (Photometric %d)", Photometric);
- }
-
- // Convert bits per sample to bytes per sample
-
- bps >>= 3;
- IsFlt = (bps == 0) || (bps == 4);
-
- return (FLOAT_SH(IsFlt) | COLORSPACE_SH(pt) | PLANAR_SH(IsPlanar) | EXTRA_SH(extra) | PREMUL_SH(IsPremul) |
- CHANNELS_SH(ColorChannels) | BYTES_SH(bps) | FLAVOR_SH(IsReverse) | LABTIFF_SH(labTiffSpecial));
-}
-
-
-// Rearrange pixel type to build output descriptor
-
-static
-cmsUInt32Number ComputeOutputFormatDescriptor(cmsUInt32Number dwInput, int OutColorSpace, int bps)
-{
- int IsPlanar = T_PLANAR(dwInput);
- int Channels = ChanCountFromPixelType(OutColorSpace);
- int IsFlt = (bps == 0) || (bps == 4);
- int labTiffSpecial = FALSE;
- int Extra = T_EXTRA(dwInput);
- int IsPremul = T_PREMUL(dwInput);
-
- if (OutColorSpace == PT_Lab)
- labTiffSpecial = TRUE;
-
- return (FLOAT_SH(IsFlt) | COLORSPACE_SH(OutColorSpace) | PLANAR_SH(IsPlanar) |
- CHANNELS_SH(Channels) | BYTES_SH(bps) | EXTRA_SH(Extra) | PREMUL_SH(IsPremul) |
- LABTIFF_SH(labTiffSpecial));
-}
-
-
-
-// Tile based transforms
-static
-int TileBasedXform(cmsHTRANSFORM hXForm, TIFF* in, TIFF* out, int nPlanes)
-{
- tsize_t BufSizeIn = TIFFTileSize(in);
- tsize_t BufSizeOut = TIFFTileSize(out);
- unsigned char *BufferIn, *BufferOut;
- ttile_t i, TileCount = TIFFNumberOfTiles(in) / nPlanes;
- cmsUInt32Number tw, tl;
- int PixelCount, j;
-
- // Check for bad tiffs
- if (BufSizeIn > INT_MAX || BufSizeOut > INT_MAX)
- FatalError("Probably corrupted TIFF, tile too big.");
-
- TIFFGetFieldDefaulted(in, TIFFTAG_TILEWIDTH, &tw);
- TIFFGetFieldDefaulted(in, TIFFTAG_TILELENGTH, &tl);
-
- PixelCount = (int) tw * tl;
-
- BufferIn = (unsigned char *) _TIFFmalloc(BufSizeIn * nPlanes);
- if (!BufferIn) OutOfMem((cmsUInt32Number) BufSizeIn * nPlanes);
-
- BufferOut = (unsigned char *) _TIFFmalloc(BufSizeOut * nPlanes);
- if (!BufferOut) OutOfMem((cmsUInt32Number) BufSizeOut * nPlanes);
-
-
- for (i = 0; i < TileCount; i++) {
-
- for (j=0; j < nPlanes; j++) {
-
- if (TIFFReadEncodedTile(in, i + (j* TileCount),
- BufferIn + (j*BufSizeIn), BufSizeIn) < 0) goto cleanup;
- }
-
- if (PixelCount < 0)
- FatalError("TIFF is corrupted");
-
- cmsDoTransform(hXForm, BufferIn, BufferOut, PixelCount);
-
- for (j=0; j < nPlanes; j++) {
-
- if (TIFFWriteEncodedTile(out, i + (j*TileCount),
- BufferOut + (j*BufSizeOut), BufSizeOut) < 0) goto cleanup;
- }
- }
-
- _TIFFfree(BufferIn);
- _TIFFfree(BufferOut);
- return 1;
-
-
-cleanup:
-
- _TIFFfree(BufferIn);
- _TIFFfree(BufferOut);
- return 0;
-}
-
-
-// Strip based transforms
-static
-int StripBasedXform(cmsHTRANSFORM hXForm, TIFF* in, TIFF* out, int nPlanes)
-{
- tsize_t BufSizeIn = TIFFStripSize(in);
- tsize_t BufSizeOut = TIFFStripSize(out);
- unsigned char *BufferIn, *BufferOut;
- ttile_t i, StripCount = TIFFNumberOfStrips(in) / nPlanes;
- cmsUInt32Number sw;
- cmsUInt32Number sl;
- cmsUInt32Number iml;
- int j;
- int PixelCount;
-
- // Check for bad tiffs
- if (BufSizeIn > INT_MAX || BufSizeOut > INT_MAX)
- FatalError("Probably corrupted TIFF, strip too big.");
-
- TIFFGetFieldDefaulted(in, TIFFTAG_IMAGEWIDTH, &sw);
- TIFFGetFieldDefaulted(in, TIFFTAG_ROWSPERSTRIP, &sl);
- TIFFGetFieldDefaulted(in, TIFFTAG_IMAGELENGTH, &iml);
-
- // It is possible to get infinite rows per strip
- if (sl == 0 || sl > iml)
- sl = iml; // One strip for whole image
-
- BufferIn = (unsigned char *) _TIFFmalloc(BufSizeIn * nPlanes);
- if (!BufferIn) OutOfMem((cmsUInt32Number) BufSizeIn * nPlanes);
-
- BufferOut = (unsigned char *) _TIFFmalloc(BufSizeOut * nPlanes);
- if (!BufferOut) OutOfMem((cmsUInt32Number) BufSizeOut * nPlanes);
-
-
- for (i = 0; i < StripCount; i++) {
-
- for (j=0; j < nPlanes; j++) {
-
- if (TIFFReadEncodedStrip(in, i + (j * StripCount),
- BufferIn + (j * BufSizeIn), BufSizeIn) < 0) goto cleanup;
- }
-
- PixelCount = (int) sw * (iml < sl ? iml : sl);
- iml -= sl;
-
- if (PixelCount < 0)
- FatalError("TIFF is corrupted");
-
- cmsDoTransform(hXForm, BufferIn, BufferOut, PixelCount);
-
- for (j=0; j < nPlanes; j++) {
- if (TIFFWriteEncodedStrip(out, i + (j * StripCount),
- BufferOut + j * BufSizeOut, BufSizeOut) < 0) goto cleanup;
- }
-
- }
-
- _TIFFfree(BufferIn);
- _TIFFfree(BufferOut);
- return 1;
-
-cleanup:
-
- _TIFFfree(BufferIn);
- _TIFFfree(BufferOut);
- return 0;
-}
-
-
-// Fill the array with a short value
-static
-void fillArray(cmsInt16Number array[], cmsInt16Number val, cmsUInt32Number size)
-{
- cmsUInt32Number i;
-
- size /= sizeof(cmsInt16Number);
- for (i = 0; i < size; i++)
- array[i] = val;
-
-}
-
-// Creates minimum required tags
-static
-void WriteOutputTags(TIFF* out, int Colorspace, int BytesPerSample, int AlphaChannels, int IsPremul)
-{
- int BitsPerSample = (8 * BytesPerSample);
- int nChannels = ChanCountFromPixelType(Colorspace);
-
-
- TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, BitsPerSample);
- TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, nChannels + AlphaChannels);
-
- if (AlphaChannels > 0)
- {
- cmsInt16Number Extra[20];
-
- if (IsPremul)
- fillArray(Extra, EXTRASAMPLE_ASSOCALPHA, sizeof(Extra));
- else
- fillArray(Extra, EXTRASAMPLE_UNASSALPHA, sizeof(Extra));
-
- TIFFSetField(out, TIFFTAG_EXTRASAMPLES, AlphaChannels, Extra);
- }
-
- switch (Colorspace) {
-
- case PT_GRAY:
- TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
-
- break;
-
- case PT_RGB:
- TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
- break;
-
- case PT_CMY:
- TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_SEPARATED);
- TIFFSetField(out, TIFFTAG_INKSET, INKSET_MULTIINK);
- break;
-
- case PT_CMYK:
- TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_SEPARATED);
- TIFFSetField(out, TIFFTAG_INKSET, INKSET_CMYK);
- break;
-
- case PT_Lab:
- if (BitsPerSample == 16)
- TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_CIELAB);
- else
- TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_CIELAB);
- break;
-
-
- // Multi-ink separations
- case PT_MCH2:
- case PT_MCH3:
- case PT_MCH4:
- case PT_MCH5:
- case PT_MCH6:
- case PT_MCH7:
- case PT_MCH8:
- case PT_MCH9:
- case PT_MCH10:
- case PT_MCH11:
- case PT_MCH12:
- case PT_MCH13:
- case PT_MCH14:
- case PT_MCH15:
-
- TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_SEPARATED);
-
- if (StoreAsAlpha && nChannels >= 4) {
-
- cmsInt16Number Extra[20];
-
- fillArray(Extra, EXTRASAMPLE_UNASSALPHA, sizeof(Extra));
-
- // CMYK plus extra alpha
- TIFFSetField(out, TIFFTAG_EXTRASAMPLES, nChannels - 4, Extra);
- TIFFSetField(out, TIFFTAG_INKSET, INKSET_CMYK);
- TIFFSetField(out, TIFFTAG_NUMBEROFINKS, 4);
- }
- else {
- TIFFSetField(out, TIFFTAG_INKSET, INKSET_MULTIINK);
- TIFFSetField(out, TIFFTAG_NUMBEROFINKS, nChannels);
- }
- break;
-
-
- default:
- FatalError("Unsupported output colorspace");
- }
-
- if (PixelDepth == 32)
- TIFFSetField(out, TIFFTAG_SAMPLEFORMAT,
- SAMPLEFORMAT_IEEEFP,
- SAMPLEFORMAT_IEEEFP,
- SAMPLEFORMAT_IEEEFP,
- SAMPLEFORMAT_IEEEFP);
-}
-
-
-// Copies a bunch of tags
-
-static
-void CopyOtherTags(TIFF* in, TIFF* out)
-{
-#define CopyField(tag, v) \
- if (TIFFGetField(in, tag, &v)) TIFFSetField(out, tag, v)
-
-
- short shortv;
- unsigned short compression;
- cmsUInt32Number ow, ol;
- cmsFloat32Number floatv;
- char *stringv;
- cmsUInt32Number longv;
-
- CopyField(TIFFTAG_SUBFILETYPE, longv);
-
- TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &ow);
- TIFFGetField(in, TIFFTAG_IMAGELENGTH, &ol);
-
- TIFFSetField(out, TIFFTAG_IMAGEWIDTH, ow);
- TIFFSetField(out, TIFFTAG_IMAGELENGTH, ol);
-
- CopyField(TIFFTAG_PLANARCONFIG, shortv);
- CopyField(TIFFTAG_COMPRESSION, compression);
-
- // This is tricky, libtiff would access predictor in a wrong way
- // if the codec is none of those
- if (compression == COMPRESSION_LZW ||
- compression == 34925 /*COMPRESSION_LZMA*/ ||
- compression == COMPRESSION_PIXARLOG ||
- compression == COMPRESSION_DEFLATE ||
- compression == COMPRESSION_ADOBE_DEFLATE ||
- compression == 50000 /*COMPRESSION_ZSTD*/)
- {
- if (PixelDepth != 32)
- CopyField(TIFFTAG_PREDICTOR, shortv);
- }
-
- CopyField(TIFFTAG_THRESHHOLDING, shortv);
- CopyField(TIFFTAG_FILLORDER, shortv);
- CopyField(TIFFTAG_ORIENTATION, shortv);
- CopyField(TIFFTAG_MINSAMPLEVALUE, shortv);
- CopyField(TIFFTAG_MAXSAMPLEVALUE, shortv);
- CopyField(TIFFTAG_XRESOLUTION, floatv);
- CopyField(TIFFTAG_YRESOLUTION, floatv);
- CopyField(TIFFTAG_RESOLUTIONUNIT, shortv);
- CopyField(TIFFTAG_ROWSPERSTRIP, longv);
- CopyField(TIFFTAG_XPOSITION, floatv);
- CopyField(TIFFTAG_YPOSITION, floatv);
- CopyField(TIFFTAG_IMAGEDEPTH, longv);
- CopyField(TIFFTAG_TILEDEPTH, longv);
-
- CopyField(TIFFTAG_TILEWIDTH, longv);
- CopyField(TIFFTAG_TILELENGTH, longv);
-
- CopyField(TIFFTAG_ARTIST, stringv);
- CopyField(TIFFTAG_IMAGEDESCRIPTION, stringv);
- CopyField(TIFFTAG_MAKE, stringv);
- CopyField(TIFFTAG_MODEL, stringv);
-
- CopyField(TIFFTAG_DATETIME, stringv);
- CopyField(TIFFTAG_HOSTCOMPUTER, stringv);
- CopyField(TIFFTAG_PAGENAME, stringv);
- CopyField(TIFFTAG_DOCUMENTNAME, stringv);
-
-}
-
-
-static
-void DoEmbedProfile(TIFF* Out, const char* ProfileFile)
-{
- FILE* f;
- cmsInt32Number size;
- cmsUInt32Number EmbedLen;
- cmsUInt8Number* EmbedBuffer;
-
- f = fopen(ProfileFile, "rb");
- if (f == NULL) return;
-
- size = cmsfilelength(f);
- if (size < 0) return;
-
- EmbedBuffer = (cmsUInt8Number*) malloc((size_t) size + 1);
- if (EmbedBuffer == NULL) {
- OutOfMem(size+1);
- return;
- }
-
- EmbedLen = (cmsUInt32Number) fread(EmbedBuffer, 1, (size_t) size, f);
-
- if (EmbedLen != (cmsUInt32Number) size)
- FatalError("Cannot read %ld bytes to %s", (long) size, ProfileFile);
-
- fclose(f);
- EmbedBuffer[EmbedLen] = 0;
-
- TIFFSetField(Out, TIFFTAG_ICCPROFILE, EmbedLen, EmbedBuffer);
- free(EmbedBuffer);
-}
-
-
-// Read or create a ICC profile from the TIFF data
-static
-cmsHPROFILE GetTIFFProfile(TIFF* in)
-{
- cmsCIExyYTRIPLE Primaries;
- cmsFloat32Number* chr;
- cmsCIExyY WhitePoint;
- cmsFloat32Number* wp;
- int i;
- cmsToneCurve* Curve[3];
- cmsUInt16Number *gmr, *gmg, *gmb;
- cmsHPROFILE hProfile;
- cmsUInt32Number EmbedLen;
- cmsUInt8Number* EmbedBuffer;
-
- if (IgnoreEmbedded) return NULL;
-
- if (TIFFGetField(in, TIFFTAG_ICCPROFILE, &EmbedLen, &EmbedBuffer)) {
-
- hProfile = cmsOpenProfileFromMem(EmbedBuffer, EmbedLen);
-
- // Print description found in the profile
- if (Verbose && (hProfile != NULL)) {
-
- fprintf(stdout, "\n[Embedded profile]\n");
- PrintProfileInformation(hProfile);
- fflush(stdout);
- }
-
- if (hProfile != NULL && SaveEmbedded != NULL)
- SaveMemoryBlock(EmbedBuffer, EmbedLen, SaveEmbedded);
-
- if (hProfile) return hProfile;
- }
-
- // Try to see if "colorimetric" tiff
- if (TIFFGetField(in, TIFFTAG_PRIMARYCHROMATICITIES, &chr)) {
-
- Primaries.Red.x = chr[0];
- Primaries.Red.y = chr[1];
- Primaries.Green.x = chr[2];
- Primaries.Green.y = chr[3];
- Primaries.Blue.x = chr[4];
- Primaries.Blue.y = chr[5];
-
- Primaries.Red.Y = Primaries.Green.Y = Primaries.Blue.Y = 1.0;
-
- if (TIFFGetField(in, TIFFTAG_WHITEPOINT, &wp)) {
-
- WhitePoint.x = wp[0];
- WhitePoint.y = wp[1];
- WhitePoint.Y = 1.0;
-
- // Transfer function is a bit harder....
- TIFFGetFieldDefaulted(in, TIFFTAG_TRANSFERFUNCTION,
- &gmr,
- &gmg,
- &gmb);
-
- Curve[0] = cmsBuildTabulatedToneCurve16(NULL, 256, gmr);
- Curve[1] = cmsBuildTabulatedToneCurve16(NULL, 256, gmg);
- Curve[2] = cmsBuildTabulatedToneCurve16(NULL, 256, gmb);
-
- hProfile = cmsCreateRGBProfileTHR(NULL, &WhitePoint, &Primaries, Curve);
-
- for (i=0; i < 3; i++)
- cmsFreeToneCurve(Curve[i]);
-
- if (Verbose) {
- fprintf(stdout, "\n[Colorimetric TIFF]\n");
- }
-
-
- return hProfile;
- }
- }
-
- return NULL;
-}
-
-
-// Transform one image
-static
-int TransformImage(TIFF* in, TIFF* out, const char *cDefInpProf)
-{
- cmsHPROFILE hIn, hOut, hProof, hInkLimit = NULL;
- cmsHTRANSFORM xform;
- cmsUInt32Number wInput, wOutput;
- int OutputColorSpace;
- int BytesPerSample = PixelDepth / 8;
- cmsUInt32Number dwFlags;
- int nPlanes;
-
- // Default options
- dwFlags = cmsFLAGS_COPY_ALPHA;
-
- // Observer adaptation state (only meaningful on absolute colorimetric intent)
- cmsSetAdaptationState(ObserverAdaptationState);
-
- if (EmbedProfile && cOutProf)
- DoEmbedProfile(out, cOutProf);
-
- if (BlackWhiteCompensation)
- dwFlags |= cmsFLAGS_BLACKPOINTCOMPENSATION;
-
- switch (PrecalcMode) {
-
- case 0: dwFlags |= cmsFLAGS_NOOPTIMIZE; break;
- case 2: dwFlags |= cmsFLAGS_HIGHRESPRECALC; break;
- case 3: dwFlags |= cmsFLAGS_LOWRESPRECALC; break;
- case 1: break;
-
- default: FatalError("Unknown precalculation mode '%d'", PrecalcMode);
- }
-
- if (GamutCheck)
- dwFlags |= cmsFLAGS_GAMUTCHECK;
-
- hProof = NULL;
- hOut = NULL;
-
- if (lIsDeviceLink) {
-
- if (lIsCUBE)
- hIn = cmsCreateDeviceLinkFromCubeFile(cDefInpProf);
- else
- hIn = cmsOpenProfileFromFile(cDefInpProf, "r");
- }
- else {
-
- hIn = GetTIFFProfile(in);
-
- if (hIn == NULL)
- hIn = OpenStockProfile(NULL, cDefInpProf);
-
- hOut = OpenStockProfile(NULL, cOutProf);
-
- if (cProofing != NULL) {
-
- hProof = OpenStockProfile(NULL, cProofing);
- dwFlags |= cmsFLAGS_SOFTPROOFING;
- }
- }
-
- // Take input color space
- wInput = GetInputPixelType(in);
-
- // Assure both, input profile and input TIFF are on same colorspace
- if (_cmsLCMScolorSpace(cmsGetColorSpace(hIn)) != (int) T_COLORSPACE(wInput))
- FatalError("Input profile is not operating in proper color space (%d)", T_COLORSPACE(wInput));
-
-
- if (!lIsDeviceLink)
- OutputColorSpace = _cmsLCMScolorSpace(cmsGetColorSpace(hOut));
- else
- OutputColorSpace = _cmsLCMScolorSpace(cmsGetPCS(hIn));
-
- wOutput = ComputeOutputFormatDescriptor(wInput, OutputColorSpace, BytesPerSample);
-
- WriteOutputTags(out, OutputColorSpace, BytesPerSample, T_EXTRA(wOutput), T_PREMUL(wOutput));
- CopyOtherTags(in, out);
-
- // Ink limit
- if (InkLimit != 400.0 &&
- (OutputColorSpace == PT_CMYK || OutputColorSpace == PT_CMY)) {
-
- cmsHPROFILE hProfiles[10];
- int nProfiles = 0;
-
- hInkLimit = cmsCreateInkLimitingDeviceLink(cmsGetColorSpace(hOut), InkLimit);
-
- hProfiles[nProfiles++] = hIn;
- if (hProof) {
- hProfiles[nProfiles++] = hProof;
- hProfiles[nProfiles++] = hProof;
- }
-
- hProfiles[nProfiles++] = hOut;
- hProfiles[nProfiles++] = hInkLimit;
-
- xform = cmsCreateMultiprofileTransform(hProfiles, nProfiles,
- wInput, wOutput, Intent, dwFlags);
-
- }
- else {
-
- xform = cmsCreateProofingTransform(hIn, wInput,
- hOut, wOutput,
- hProof, Intent,
- ProofingIntent,
- dwFlags);
- }
-
- cmsCloseProfile(hIn);
- cmsCloseProfile(hOut);
-
- if (hInkLimit)
- cmsCloseProfile(hInkLimit);
- if (hProof)
- cmsCloseProfile(hProof);
-
- if (xform == NULL) return 0;
-
- // Planar stuff
- if (T_PLANAR(wInput))
- nPlanes = T_CHANNELS(wInput) + T_EXTRA(wInput);
- else
- nPlanes = 1;
-
-
- // Handle tile by tile or strip by strip
- if (TIFFIsTiled(in)) {
-
- TileBasedXform(xform, in, out, nPlanes);
- }
- else {
- StripBasedXform(xform, in, out, nPlanes);
- }
-
-
- cmsDeleteTransform(xform);
-
- TIFFWriteDirectory(out);
-
- return 1;
-}
-
-
-// Print help
-static
-void Help(int level)
-{
- UTILS_UNUSED_PARAMETER(level);
-
- fprintf(stderr, "Little CMS ICC profile applier for TIFF - v8.0 [LittleCMS %2.2f]\n", cmsGetEncodedCMMversion() / 1000.0);
- fprintf(stderr, "Copyright (c) 1998-2023 Marti Maria Saguer. See COPYING file for details.\n");
- fflush(stderr);
-
- fprintf(stderr, "usage: tificc [flags] input.tif output.tif\n");
-
- fprintf(stderr, "\nflags:\n\n");
- fprintf(stderr, "-v - Verbose\n");
- fprintf(stderr, "-i<profile> - Input profile (defaults to sRGB)\n");
- fprintf(stderr, "-o<profile> - Output profile (defaults to sRGB)\n");
- fprintf(stderr, "-l<profile> - Transform by device-link profile\n");
- fprintf(stderr, "-u<profile> - Transform by CUBE colormap\n");
-
- PrintBuiltins();
-
- PrintRenderingIntents();
-
- fprintf(stderr, "-b - Black point compensation\n");
- fprintf(stderr, "-d<0..1> - Observer adaptation state (abs.col. only)\n");
-
- fprintf(stderr, "-c<0,1,2,3> - Precalculates transform (0=Off, 1=Normal, 2=Hi-res, 3=LoRes)\n");
- fprintf(stderr, "\n");
-
- fprintf(stderr, "-w<8,16,32> - Output depth. Use 32 for floating-point\n\n");
- fprintf(stderr, "-a - Handle channels > 4 as alpha\n");
-
- fprintf(stderr, "-n - Ignore embedded profile on input\n");
- fprintf(stderr, "-e - Embed destination profile\n");
- fprintf(stderr, "-s<new profile> - Save embedded profile as <new profile>\n");
- fprintf(stderr, "\n");
-
-
- fprintf(stderr, "-p<profile> - Soft proof profile\n");
- fprintf(stderr, "-m<n> - Soft proof intent\n");
- fprintf(stderr, "\tThat is the intent used to translate the simulation to the output device.\n\tNote that the simulated intent is set by using -t not by -m\n");
- fprintf(stderr, "-g - Marks out-of-gamut colors on softproof\n");
-
- fprintf(stderr, "\n");
-
- fprintf(stderr, "-k<0..400> - Ink-limiting in %% (CMYK only)\n");
- fprintf(stderr, "\n");
-
-
- fprintf(stderr, "Examples:\n\n"
- "To color correct from scanner to sRGB:\n"
- "\ttificc -iscanner.icm in.tif out.tif\n"
- "To convert from monitor1 to monitor2:\n"
- "\ttificc -imon1.icm -omon2.icm in.tif out.tif\n"
- "To make a CMYK separation:\n"
- "\ttificc -oprinter.icm inrgb.tif outcmyk.tif\n"
- "To recover sRGB from a CMYK separation:\n"
- "\ttificc -iprinter.icm incmyk.tif outrgb.tif\n"
- "To soft-proof how behaves Probev1_ICCv4.icc on perceptual:\n"
- "\ttifficc -t0 -p Probev1_ICCv4.icc -m1 infile.tif out.tif\n"
- "To convert from CIELab TIFF to sRGB\n"
- "\ttificc -i*Lab in.tif out.tif\n\n");
-
-
- fprintf(stderr, "This program is intended to be a demo of the Little CMS\n"
- "color engine. Both lcms and this program are open source.\n"
- "You can obtain both in source code at https://www.littlecms.com\n"
- "For suggestions, comments, bug reports etc. send mail to\n"
- "info@littlecms.com\n\n");
-
- exit(0);
-}
-
-
-// The toggles stuff
-
-static
-void HandleSwitches(int argc, char *argv[])
-{
- int s;
-
- while ((s=xgetopt(argc,argv,"aAeEbBw:W:nNvVGgh:H:i:I:o:O:P:p:t:T:c:C:l:L:u:U:M:m:K:k:S:s:D:d:-:")) != EOF) {
-
- switch (s) {
-
-
- case '-':
- if (strcmp(xoptarg, "help") == 0)
- {
- Help(0);
- }
- else
- {
- FatalError("Unknown option - run without args to see valid ones.\n");
- }
- break;
-
- case 'a':
- case 'A':
- StoreAsAlpha = TRUE;
- break;
- case 'b':
- case 'B':
- BlackWhiteCompensation = TRUE;
- break;
-
- case 'c':
- case 'C':
- PrecalcMode = atoi(xoptarg);
- if (PrecalcMode < 0 || PrecalcMode > 3)
- FatalError("Unknown precalc mode '%d'", PrecalcMode);
- break;
-
- case 'd':
- case 'D': ObserverAdaptationState = atof(xoptarg);
- if (ObserverAdaptationState < 0 ||
- ObserverAdaptationState > 1.0)
- Warning("Adaptation state should be 0..1");
- break;
-
- case 'e':
- case 'E':
- EmbedProfile = TRUE;
- break;
-
- case 'g':
- case 'G':
- GamutCheck = TRUE;
- break;
-
- case 'v':
- case 'V':
- Verbose = TRUE;
- break;
-
- case 'i':
- case 'I':
- if (lIsDeviceLink)
- FatalError("Device-link already specified");
-
- cInpProf = xoptarg;
- break;
-
- case 'o':
- case 'O':
- if (lIsDeviceLink)
- FatalError("Device-link already specified");
-
- cOutProf = xoptarg;
- break;
-
- case 'l':
- case 'L':
- if (cInpProf != NULL || cOutProf != NULL)
- FatalError("input/output profiles already specified");
-
- cInpProf = xoptarg;
- lIsDeviceLink = TRUE;
- lIsCUBE = FALSE;
- break;
-
- case 'u':
- case 'U':
- if (cInpProf != NULL || cOutProf != NULL)
- FatalError("input/output profiles already specified");
-
- cInpProf = xoptarg;
- lIsDeviceLink = TRUE;
- lIsCUBE = TRUE;
- break;
-
- case 'p':
- case 'P':
- cProofing = xoptarg;
- break;
-
- case 't':
- case 'T':
- Intent = atoi(xoptarg);
- break;
-
- case 'm':
- case 'M':
- ProofingIntent = atoi(xoptarg);
- break;
-
- case 'N':
- case 'n':
- IgnoreEmbedded = TRUE;
- break;
-
- case 'W':
- case 'w':
- PixelDepth = atoi(xoptarg);
- if (PixelDepth != 8 && PixelDepth != 16 && PixelDepth != 32)
- FatalError("Only 8, 16 and 32 bps are supported");
- break;
-
- case 'k':
- case 'K':
- InkLimit = atof(xoptarg);
- if (InkLimit < 0.0 || InkLimit > 400.0)
- FatalError("Ink limit must be 0%%..400%%");
- break;
-
-
- case 's':
- case 'S': SaveEmbedded = xoptarg;
- break;
-
- case 'H':
- case 'h': {
-
- int a = atoi(xoptarg);
- Help(a);
- }
- break;
-
- default:
-
- FatalError("Unknown option - run without args to see valid ones");
- }
-
- }
-}
-
-
-// The main sink
-
-int main(int argc, char* argv[])
-{
- TIFF *in, *out;
-
- cmsPlugin(&TiffLabPlugin);
-
- InitUtils("tificc");
-
- HandleSwitches(argc, argv);
-
- if ((argc - xoptind) != 2) {
-
- Help(0);
- }
-
-
- TIFFSetErrorHandler(ConsoleErrorHandler);
- TIFFSetWarningHandler(ConsoleWarningHandler);
-
- in = TIFFOpen(argv[xoptind], "r");
- if (in == NULL) FatalError("Unable to open '%s'", argv[xoptind]);
-
- out = TIFFOpen(argv[xoptind+1], "w");
-
- if (out == NULL) {
-
- TIFFClose(in);
- FatalError("Unable to write '%s'", argv[xoptind+1]);
- }
-
- do {
-
- TransformImage(in, out, cInpProf);
-
-
- } while (TIFFReadDirectory(in));
-
-
- if (Verbose) { fprintf(stdout, "\n"); fflush(stdout); }
-
- TIFFClose(in);
- TIFFClose(out);
-
- return 0;
-}
-
diff --git a/contrib/libs/lcms2/utils/tificc/ya.make b/contrib/libs/lcms2/utils/tificc/ya.make
deleted file mode 100644
index cc462e387c..0000000000
--- a/contrib/libs/lcms2/utils/tificc/ya.make
+++ /dev/null
@@ -1,57 +0,0 @@
-# Generated by devtools/yamaker.
-
-PROGRAM()
-
-LICENSE(MIT)
-
-LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
-
-VERSION(2.16)
-
-PEERDIR(
- contrib/libs/lcms2
- contrib/libs/libtiff
-)
-
-ADDINCL(
- contrib/libs/lcms2/include
- contrib/libs/lcms2/utils/common
- contrib/libs/lcms2/utils/tificc
-)
-
-NO_COMPILER_WARNINGS()
-
-NO_RUNTIME()
-
-CFLAGS(
- -DHAVE_DLFCN_H=1
- -DHAVE_FUNC_ATTRIBUTE_VISIBILITY=1
- -DHAVE_GMTIME_R=1
- -DHAVE_INTTYPES_H=1
- -DHAVE_PTHREAD=1
- -DHAVE_PTHREAD_PRIO_INHERIT=1
- -DHAVE_STDINT_H=1
- -DHAVE_STDIO_H=1
- -DHAVE_STDLIB_H=1
- -DHAVE_STRINGS_H=1
- -DHAVE_STRING_H=1
- -DHAVE_SYS_STAT_H=1
- -DHAVE_SYS_TYPES_H=1
- -DHAVE_TIFFCONF_H=1
- -DHAVE_UNISTD_H=1
- -DHasJPEG=1
- -DHasTHREADS=1
- -DHasTIFF=1
- -DHasZLIB=1
- -DLT_OBJDIR=\".libs/\"
-)
-
-SRCDIR(contrib/libs/lcms2/utils)
-
-SRCS(
- common/vprf.c
- common/xgetopt.c
- tificc/tificc.c
-)
-
-END()
diff --git a/contrib/libs/lcms2/utils/transicc/.yandex_meta/licenses.list.txt b/contrib/libs/lcms2/utils/transicc/.yandex_meta/licenses.list.txt
deleted file mode 100644
index 7accfb5141..0000000000
--- a/contrib/libs/lcms2/utils/transicc/.yandex_meta/licenses.list.txt
+++ /dev/null
@@ -1,83 +0,0 @@
-====================COPYRIGHT====================
-// Copyright (c) 1998-2023 Marti Maria Saguer
-
-
-====================File: AUTHORS====================
-
-Main Author
-------------
-Marti Maria
-
-
-Contributors
-------------
-Bob Friesenhahn
-Kai-Uwe Behrmann
-Stuart Nixon
-Jordi Vilar
-Richard Hughes
-Auke Nauta
-Chris Evans (Google)
-Lorenzo Ridolfi
-Robin Watts (Artifex)
-Shawn Pedersen
-Andrew Brygin
-Samuli Suominen
-Florian Höch
-Aurelien Jarno
-Claudiu Cebuc
-Michael Vhrel (Artifex)
-Michal Cihar
-Daniel Kaneider
-Mateusz Jurczyk (Google)
-Paul Miller
-Sébastien Léon
-Christian Schmitz
-XhmikosR
-Stanislav Brabec (SuSe)
-Leonhard Gruenschloss (Google)
-Patrick Noffke
-Christopher James Halse Rogers
-John Hein
-Thomas Weber (Debian)
-Mark Allen
-Noel Carboni
-Sergei Trofimovic
-Philipp Knechtges
-Amyspark
-Lovell Fuller
-Eli Schwartz
-Diogo Teles Sant'Anna
-
-Special Thanks
---------------
-Artifex software
-AlienSkin software
-libVIPS
-Jan Morovic
-Jos Vernon (WebSupergoo)
-Harald Schneider (Maxon)
-Christian Albrecht
-Dimitrios Anastassakis
-Lemke Software
-Tim Zaman
-
-
-====================MIT====================
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/contrib/libs/lcms2/utils/transicc/transicc.c b/contrib/libs/lcms2/utils/transicc/transicc.c
deleted file mode 100644
index debaeb4fe2..0000000000
--- a/contrib/libs/lcms2/utils/transicc/transicc.c
+++ /dev/null
@@ -1,1331 +0,0 @@
-//---------------------------------------------------------------------------------
-//
-// Little Color Management System
-// Copyright (c) 1998-2023 Marti Maria Saguer
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//---------------------------------------------------------------------------------
-//
-
-#include "utils.h"
-
-#ifndef _MSC_VER
-# include <unistd.h>
-#endif
-
-#ifdef CMS_IS_WINDOWS_
-# include <io.h>
-#endif
-
-#define MAX_INPUT_BUFFER 4096
-
-// Global options
-
-static cmsBool InHexa = FALSE;
-static cmsBool GamutCheck = FALSE;
-static cmsBool Width16 = FALSE;
-static cmsBool BlackPointCompensation = FALSE;
-static cmsBool lIsDeviceLink = FALSE;
-static cmsBool lQuantize = FALSE;
-static cmsBool lUnbounded = TRUE;
-static cmsBool lIsFloat = TRUE;
-
-static cmsUInt32Number Intent = INTENT_PERCEPTUAL;
-static cmsUInt32Number ProofingIntent = INTENT_PERCEPTUAL;
-
-static int PrecalcMode = 0;
-
-// --------------------------------------------------------------
-
-static char *cInProf = NULL;
-static char *cOutProf = NULL;
-static char *cProofing = NULL;
-
-static char *IncludePart = NULL;
-
-static cmsHANDLE hIT8in = NULL; // CGATS input
-static cmsHANDLE hIT8out = NULL; // CGATS output
-
-static char CGATSPatch[1024]; // Actual Patch Name
-static char CGATSoutFilename[cmsMAX_PATH];
-
-static int nMaxPatches;
-
-static cmsHTRANSFORM hTrans, hTransXYZ, hTransLab;
-static cmsBool InputNamedColor = FALSE;
-
-static cmsColorSpaceSignature InputColorSpace, OutputColorSpace;
-
-static cmsNAMEDCOLORLIST* InputColorant = NULL;
-static cmsNAMEDCOLORLIST* OutputColorant = NULL;
-
-static cmsFloat64Number InputRange, OutputRange;
-
-
-// isatty replacement
-#ifdef _MSC_VER
-#define xisatty(x) _isatty( _fileno( (x) ) )
-#else
-#define xisatty(x) isatty( fileno( (x) ) )
-#endif
-
-//---------------------------------------------------------------------------------------------------
-
-// Print usage to stderr
-static
-void Help(void)
-{
-
- fprintf(stderr, "usage: transicc [flags] [CGATS input] [CGATS output]\n\n");
-
- fprintf(stderr, "flags:\n\n");
- fprintf(stderr, "-v<0..3> - Verbosity level\n");
-
- fprintf(stderr, "-e[op] - Encoded representation of numbers\n");
- fprintf(stderr, "\t-w - use 16 bits\n");
- fprintf(stderr, "\t-x - Hexadecimal\n\n");
-
- fprintf(stderr, "-s - bounded mode (clip negatives and highlights)\n");
- fprintf(stderr, "-q - Quantize (round decimals)\n\n");
-
- fprintf(stderr, "-i<profile> - Input profile (defaults to sRGB)\n");
- fprintf(stderr, "-o<profile> - Output profile (defaults to sRGB)\n");
- fprintf(stderr, "-l<profile> - Transform by device-link profile\n");
-
- PrintBuiltins();
-
- PrintRenderingIntents();
-
- fprintf(stderr, "\n");
-
- fprintf(stderr, "-d<0..1> - Observer adaptation state (abs.col. only)\n\n");
-
- fprintf(stderr, "-b - Black point compensation\n");
-
- fprintf(stderr, "-c<0,1,2,3> Precalculates transform (0=Off, 1=Normal, 2=Hi-res, 3=LoRes)\n\n");
- fprintf(stderr, "-n - Terse output, intended for pipe usage\n");
-
- fprintf(stderr, "-p<profile> - Soft proof profile\n");
- fprintf(stderr, "-m<0,1,2,3> - Soft proof intent\n");
- fprintf(stderr, "-g - Marks out-of-gamut colors on softproof\n\n");
-
-
-
- fprintf(stderr, "This program is intended to be a demo of the Little CMS\n"
- "color engine. Both lcms and this program are open source.\n"
- "You can obtain both in source code at https://www.littlecms.com\n"
- "For suggestions, comments, bug reports etc. send mail to\n"
- "info@littlecms.com\n\n");
-
-}
-
-
-
-// The toggles stuff
-
-static
-void HandleSwitches(int argc, char *argv[])
-{
- int s;
-
- while ((s = xgetopt(argc, argv,
- "bBC:c:d:D:eEgGI:i:L:l:m:M:nNO:o:p:P:QqSsT:t:V:v:WwxX!:-:")) != EOF) {
-
- switch (s){
-
- case '-':
- if (strcmp(xoptarg, "help") == 0)
- {
- Help();
- exit(0);
- }
- else
- {
- FatalError("Unknown option - run without args to see valid ones.\n");
- }
- break;
-
- case '!':
- IncludePart = xoptarg;
- break;
-
- case 'b':
- case 'B':
- BlackPointCompensation = TRUE;
- break;
-
- case 'c':
- case 'C':
- PrecalcMode = atoi(xoptarg);
- if (PrecalcMode < 0 || PrecalcMode > 3)
- FatalError("Unknown precalc mode '%d'", PrecalcMode);
- break;
-
- case 'd':
- case 'D': {
- cmsFloat64Number ObserverAdaptationState = atof(xoptarg);
- if (ObserverAdaptationState < 0 ||
- ObserverAdaptationState > 1.0)
- FatalError("Adaptation states should be between 0 and 1");
-
- cmsSetAdaptationState(ObserverAdaptationState);
- }
- break;
-
- case 'e':
- case 'E':
- lIsFloat = FALSE;
- break;
-
- case 'g':
- case 'G':
- GamutCheck = TRUE;
- break;
-
- case 'i':
- case 'I':
- if (lIsDeviceLink)
- FatalError("icctrans: Device-link already specified");
-
- cInProf = xoptarg;
- break;
-
- case 'l':
- case 'L':
- cInProf = xoptarg;
- lIsDeviceLink = TRUE;
- break;
-
- // No extra intents for proofing
- case 'm':
- case 'M':
- ProofingIntent = atoi(xoptarg);
- if (ProofingIntent > 3)
- FatalError("Unknown Proofing Intent '%d'", ProofingIntent);
- break;
-
- // For compatibility
- case 'n':
- case 'N':
- Verbose = 0;
- break;
-
- // Output profile
- case 'o':
- case 'O':
- if (lIsDeviceLink)
- FatalError("icctrans: Device-link already specified");
- cOutProf = xoptarg;
- break;
-
- // Proofing profile
- case 'p':
- case 'P':
- cProofing = xoptarg;
- break;
-
- // Quantize (get rid of decimals)
- case 'q':
- case 'Q':
- lQuantize = TRUE;
- break;
-
- // Inhibit unbounded mode
- case 's':
- case 'S':
- lUnbounded = FALSE;
- break;
-
- // The intent
- case 't':
- case 'T':
- Intent = atoi(xoptarg);
- break;
-
- // Verbosity level
- case 'V':
- case 'v':
- Verbose = atoi(xoptarg);
- if (Verbose < 0 || Verbose > 3) {
- FatalError("Unknown verbosity level '%d'", Verbose);
- }
- break;
-
- // Wide (16 bits)
- case 'W':
- case 'w':
- Width16 = TRUE;
- break;
-
- // Hexadecimal
- case 'x':
- case 'X':
- InHexa = TRUE;
- break;
-
- default:
- FatalError("Unknown option - run without args to see valid ones.\n");
- }
- }
-
-
- // If output CGATS involved, switch to float
- if ((argc - xoptind) > 2) {
- lIsFloat = TRUE;
- }
-}
-
-
-
-static
-void SetRange(cmsFloat64Number range, cmsBool IsInput)
-{
- if (IsInput)
- InputRange = range;
- else
- OutputRange = range;
-}
-
-// Populate a named color list with usual component names.
-// I am using the first Colorant channel to store the range, but it works since
-// this space is not used anyway.
-static
-cmsNAMEDCOLORLIST* ComponentNames(cmsColorSpaceSignature space, cmsBool IsInput)
-{
- cmsNAMEDCOLORLIST* out;
- int i, n;
- char Buffer[cmsMAX_PATH];
-
- out = cmsAllocNamedColorList(0, 12, cmsMAXCHANNELS, "", "");
- if (out == NULL) return NULL;
-
- switch (space) {
-
- case cmsSigXYZData:
- SetRange(100, IsInput);
- cmsAppendNamedColor(out, "X", NULL, NULL);
- cmsAppendNamedColor(out, "Y", NULL, NULL);
- cmsAppendNamedColor(out, "Z", NULL, NULL);
- break;
-
- case cmsSigLabData:
- SetRange(1, IsInput);
- cmsAppendNamedColor(out, "L*", NULL, NULL);
- cmsAppendNamedColor(out, "a*", NULL, NULL);
- cmsAppendNamedColor(out, "b*", NULL, NULL);
- break;
-
- case cmsSigLuvData:
- SetRange(1, IsInput);
- cmsAppendNamedColor(out, "L", NULL, NULL);
- cmsAppendNamedColor(out, "u", NULL, NULL);
- cmsAppendNamedColor(out, "v", NULL, NULL);
- break;
-
- case cmsSigYCbCrData:
- SetRange(255, IsInput);
- cmsAppendNamedColor(out, "Y", NULL, NULL );
- cmsAppendNamedColor(out, "Cb", NULL, NULL);
- cmsAppendNamedColor(out, "Cr", NULL, NULL);
- break;
-
-
- case cmsSigYxyData:
- SetRange(1, IsInput);
- cmsAppendNamedColor(out, "Y", NULL, NULL);
- cmsAppendNamedColor(out, "x", NULL, NULL);
- cmsAppendNamedColor(out, "y", NULL, NULL);
- break;
-
- case cmsSigRgbData:
- SetRange(255, IsInput);
- cmsAppendNamedColor(out, "R", NULL, NULL);
- cmsAppendNamedColor(out, "G", NULL, NULL);
- cmsAppendNamedColor(out, "B", NULL, NULL);
- break;
-
- case cmsSigGrayData:
- SetRange(255, IsInput);
- cmsAppendNamedColor(out, "G", NULL, NULL);
- break;
-
- case cmsSigHsvData:
- SetRange(255, IsInput);
- cmsAppendNamedColor(out, "H", NULL, NULL);
- cmsAppendNamedColor(out, "s", NULL, NULL);
- cmsAppendNamedColor(out, "v", NULL, NULL);
- break;
-
- case cmsSigHlsData:
- SetRange(255, IsInput);
- cmsAppendNamedColor(out, "H", NULL, NULL);
- cmsAppendNamedColor(out, "l", NULL, NULL);
- cmsAppendNamedColor(out, "s", NULL, NULL);
- break;
-
- case cmsSigCmykData:
- SetRange(1, IsInput);
- cmsAppendNamedColor(out, "C", NULL, NULL);
- cmsAppendNamedColor(out, "M", NULL, NULL);
- cmsAppendNamedColor(out, "Y", NULL, NULL);
- cmsAppendNamedColor(out, "K", NULL, NULL);
- break;
-
- case cmsSigCmyData:
- SetRange(1, IsInput);
- cmsAppendNamedColor(out, "C", NULL, NULL);
- cmsAppendNamedColor(out, "M", NULL, NULL);
- cmsAppendNamedColor(out, "Y", NULL, NULL);
- break;
-
- default:
-
- SetRange(1, IsInput);
-
- n = cmsChannelsOfColorSpace(space);
-
- for (i=0; i < n; i++) {
-
- sprintf(Buffer, "Channel #%d", i + 1);
- cmsAppendNamedColor(out, Buffer, NULL, NULL);
- }
- }
-
- return out;
-
-}
-
-
-// Creates all needed color transforms
-static
-cmsBool OpenTransforms(void)
-{
- cmsHPROFILE hInput, hOutput, hProof;
- cmsUInt32Number dwIn, dwOut, dwFlags;
- cmsNAMEDCOLORLIST* List;
- int i;
-
- // We don't need cache
- dwFlags = cmsFLAGS_NOCACHE;
-
- if (lIsDeviceLink) {
-
- hInput = OpenStockProfile(0, cInProf);
- if (hInput == NULL) return FALSE;
- hOutput = NULL;
- hProof = NULL;
-
- if (cmsGetDeviceClass(hInput) == cmsSigNamedColorClass) {
- OutputColorSpace = cmsGetColorSpace(hInput);
- InputColorSpace = cmsGetPCS(hInput);
- }
- else {
- InputColorSpace = cmsGetColorSpace(hInput);
- OutputColorSpace = cmsGetPCS(hInput);
- }
-
- // Read colorant tables if present
- if (cmsIsTag(hInput, cmsSigColorantTableTag)) {
- List = cmsReadTag(hInput, cmsSigColorantTableTag);
- InputColorant = cmsDupNamedColorList(List);
- InputRange = 1;
- }
- else InputColorant = ComponentNames(InputColorSpace, TRUE);
-
- if (cmsIsTag(hInput, cmsSigColorantTableOutTag)){
-
- List = cmsReadTag(hInput, cmsSigColorantTableOutTag);
- OutputColorant = cmsDupNamedColorList(List);
- OutputRange = 1;
- }
- else OutputColorant = ComponentNames(OutputColorSpace, FALSE);
-
- }
- else {
-
- hInput = OpenStockProfile(0, cInProf);
- if (hInput == NULL) return FALSE;
-
- hOutput = OpenStockProfile(0, cOutProf);
- if (hOutput == NULL) return FALSE;
- hProof = NULL;
-
-
- if (cmsGetDeviceClass(hInput) == cmsSigLinkClass ||
- cmsGetDeviceClass(hOutput) == cmsSigLinkClass)
- FatalError("Use -l flag for devicelink profiles!\n");
-
-
- InputColorSpace = cmsGetColorSpace(hInput);
- OutputColorSpace = cmsGetColorSpace(hOutput);
-
- // Read colorant tables if present
- if (cmsIsTag(hInput, cmsSigColorantTableTag)) {
- List = cmsReadTag(hInput, cmsSigColorantTableTag);
- InputColorant = cmsDupNamedColorList(List);
- if (cmsNamedColorCount(InputColorant) <= 3)
- SetRange(255, TRUE);
- else
- SetRange(1, TRUE); // Inks are already divided by 100 in the formatter
-
- }
- else InputColorant = ComponentNames(InputColorSpace, TRUE);
-
- if (cmsIsTag(hOutput, cmsSigColorantTableTag)){
-
- List = cmsReadTag(hOutput, cmsSigColorantTableTag);
- OutputColorant = cmsDupNamedColorList(List);
- if (cmsNamedColorCount(OutputColorant) <= 3)
- SetRange(255, FALSE);
- else
- SetRange(1, FALSE); // Inks are already divided by 100 in the formatter
- }
- else OutputColorant = ComponentNames(OutputColorSpace, FALSE);
-
-
- if (cProofing != NULL) {
-
- hProof = OpenStockProfile(0, cProofing);
- if (hProof == NULL) return FALSE;
- dwFlags |= cmsFLAGS_SOFTPROOFING;
- }
- }
-
- // Print information on profiles
- if (Verbose > 2) {
-
- printf("Profile:\n");
- PrintProfileInformation(hInput);
-
- if (hOutput) {
-
- printf("Output profile:\n");
- PrintProfileInformation(hOutput);
- }
-
- if (hProof != NULL) {
- printf("Proofing profile:\n");
- PrintProfileInformation(hProof);
- }
- }
-
-
- // Input is always in floating point
- dwIn = cmsFormatterForColorspaceOfProfile(hInput, 0, TRUE);
-
- if (lIsDeviceLink) {
-
- dwOut = cmsFormatterForPCSOfProfile(hInput, lIsFloat ? 0 : 2, lIsFloat);
- }
- else {
-
- // 16 bits or floating point (only on output)
- dwOut = cmsFormatterForColorspaceOfProfile(hOutput, lIsFloat ? 0 : 2, lIsFloat);
- }
-
- // For named color, there is a specialized formatter
- if (cmsGetDeviceClass(hInput) == cmsSigNamedColorClass) {
-
- dwIn = TYPE_NAMED_COLOR_INDEX;
- InputNamedColor = TRUE;
- }
-
- // Precision mode
- switch (PrecalcMode) {
-
- case 0: dwFlags |= cmsFLAGS_NOOPTIMIZE; break;
- case 2: dwFlags |= cmsFLAGS_HIGHRESPRECALC; break;
- case 3: dwFlags |= cmsFLAGS_LOWRESPRECALC; break;
- case 1: break;
-
- default:
- FatalError("Unknown precalculation mode '%d'", PrecalcMode);
- }
-
-
- if (BlackPointCompensation)
- dwFlags |= cmsFLAGS_BLACKPOINTCOMPENSATION;
-
-
- if (GamutCheck) {
-
- cmsUInt16Number Alarm[cmsMAXCHANNELS];
-
- if (hProof == NULL)
- FatalError("I need proofing profile -p for gamut checking!");
-
- for (i=0; i < cmsMAXCHANNELS; i++)
- Alarm[i] = 0xFFFF;
-
- cmsSetAlarmCodes(Alarm);
- dwFlags |= cmsFLAGS_GAMUTCHECK;
- }
-
-
- // The main transform
- hTrans = cmsCreateProofingTransform(hInput, dwIn, hOutput, dwOut, hProof, Intent, ProofingIntent, dwFlags);
-
- if (hProof) cmsCloseProfile(hProof);
-
- if (hTrans == NULL) return FALSE;
-
-
- // PCS Dump if requested
- hTransXYZ = NULL; hTransLab = NULL;
-
- if (hOutput && Verbose > 1) {
-
- cmsHPROFILE hXYZ = cmsCreateXYZProfile();
- cmsHPROFILE hLab = cmsCreateLab4Profile(NULL);
-
- hTransXYZ = cmsCreateTransform(hInput, dwIn, hXYZ, lIsFloat ? TYPE_XYZ_DBL : TYPE_XYZ_16, Intent, cmsFLAGS_NOCACHE);
- if (hTransXYZ == NULL) return FALSE;
-
- hTransLab = cmsCreateTransform(hInput, dwIn, hLab, lIsFloat? TYPE_Lab_DBL : TYPE_Lab_16, Intent, cmsFLAGS_NOCACHE);
- if (hTransLab == NULL) return FALSE;
-
- cmsCloseProfile(hXYZ);
- cmsCloseProfile(hLab);
- }
-
- if (hInput) cmsCloseProfile(hInput);
- if (hOutput) cmsCloseProfile(hOutput);
-
- return TRUE;
-}
-
-
-// Free open resources
-static
-void CloseTransforms(void)
-{
- if (InputColorant) cmsFreeNamedColorList(InputColorant);
- if (OutputColorant) cmsFreeNamedColorList(OutputColorant);
-
- if (hTrans) cmsDeleteTransform(hTrans);
- if (hTransLab) cmsDeleteTransform(hTransLab);
- if (hTransXYZ) cmsDeleteTransform(hTransXYZ);
-
-}
-
-// ---------------------------------------------------------------------------------------------------
-
-// Get input from user
-static
-void GetLine(char* Buffer, const char* frm, ...)
-{
- int res;
- va_list args;
-
- va_start(args, frm);
-
- do {
- if (xisatty(stdin))
- vfprintf(stderr, frm, args);
-
- res = scanf("%4095s", Buffer);
-
- if (res < 0 || toupper(Buffer[0]) == 'Q') { // Quit?
-
- CloseTransforms();
-
- if (xisatty(stdin))
- fprintf(stderr, "Done.\n");
-
- exit(0);
- }
- } while (res == 0);
-
- va_end(args);
-}
-
-
-// Print a value which is given in double floating point
-static
-void PrintFloatResults(cmsFloat64Number Value[])
-{
- cmsUInt32Number i, n;
- char ChannelName[cmsMAX_PATH];
- cmsFloat64Number v;
-
- n = cmsChannelsOfColorSpace(OutputColorSpace);
- for (i=0; i < n; i++) {
-
- if (OutputColorant != NULL) {
-
- cmsNamedColorInfo(OutputColorant, i, ChannelName, NULL, NULL, NULL, NULL);
- }
- else {
- OutputRange = 1;
- sprintf(ChannelName, "Channel #%u", i + 1);
- }
-
- v = (cmsFloat64Number) Value[i]* OutputRange;
-
- if (lQuantize)
- v = floor(v + 0.5);
-
- if (!lUnbounded) {
-
- if (v < 0)
- v = 0;
- if (v > OutputRange)
- v = OutputRange;
- }
-
- if (Verbose <= 0)
- printf("%.4f ", v);
- else
- printf("%s=%.4f ", ChannelName, v);
- }
-
- printf("\n");
-}
-
-
-// Get a named-color index
-static
-cmsUInt16Number GetIndex(void)
-{
- char Buffer[4096], Name[cmsMAX_PATH], Prefix[40], Suffix[40];
- int index, max;
- const cmsNAMEDCOLORLIST* NamedColorList;
-
- NamedColorList = cmsGetNamedColorList(hTrans);
- if (NamedColorList == NULL) return 0;
-
- max = cmsNamedColorCount(NamedColorList)-1;
-
- GetLine(Buffer, "Color index (0..%d)? ", max);
- index = atoi(Buffer);
-
- if (index > max)
- FatalError("Named color %d out of range!", index);
-
- cmsNamedColorInfo(NamedColorList, index, Name, Prefix, Suffix, NULL, NULL);
-
- printf("\n%s %s %s\n", Prefix, Name, Suffix);
-
- return (cmsUInt16Number) index;
-}
-
-// Read values from a text file or terminal
-static
-void TakeFloatValues(cmsFloat64Number Float[])
-{
- cmsUInt32Number i, n;
- char ChannelName[cmsMAX_PATH];
- char Buffer[4096];
-
- if (xisatty(stdin))
- fprintf(stderr, "\nEnter values, 'q' to quit\n");
-
- if (InputNamedColor) {
-
- // This is named color index, which is always cmsUInt16Number
- cmsUInt16Number index = GetIndex();
- memcpy(Float, &index, sizeof(cmsUInt16Number));
- return;
- }
-
- n = cmsChannelsOfColorSpace(InputColorSpace);
- for (i=0; i < n; i++) {
-
- if (InputColorant) {
- cmsNamedColorInfo(InputColorant, i, ChannelName, NULL, NULL, NULL, NULL);
- }
- else {
- InputRange = 1;
- sprintf(ChannelName, "Channel #%u", i+1);
- }
-
- GetLine(Buffer, "%s? ", ChannelName);
-
- Float[i] = (cmsFloat64Number) atof(Buffer) / InputRange;
- }
-
- if (xisatty(stdin))
- fprintf(stderr, "\n");
-}
-
-static
-void PrintPCSFloat(cmsFloat64Number Input[])
-{
- if (Verbose > 1 && hTransXYZ && hTransLab) {
-
- cmsCIEXYZ XYZ = { 0, 0, 0 };
- cmsCIELab Lab = { 0, 0, 0 };
-
- if (hTransXYZ) cmsDoTransform(hTransXYZ, Input, &XYZ, 1);
- if (hTransLab) cmsDoTransform(hTransLab, Input, &Lab, 1);
-
- printf("[PCS] Lab=(%.4f,%.4f,%.4f) XYZ=(%.4f,%.4f,%.4f)\n", Lab.L, Lab.a, Lab.b,
- XYZ.X * 100.0, XYZ.Y * 100.0, XYZ.Z * 100.0);
-
- }
-}
-
-
-
-
-// -----------------------------------------------------------------------------------------------
-
-static
-void PrintEncodedResults(cmsUInt16Number Encoded[])
-{
- cmsUInt32Number i, n;
- char ChannelName[cmsMAX_PATH];
- cmsUInt32Number v;
-
- n = cmsChannelsOfColorSpace(OutputColorSpace);
- for (i=0; i < n; i++) {
-
- if (OutputColorant != NULL) {
-
- cmsNamedColorInfo(OutputColorant, i, ChannelName, NULL, NULL, NULL, NULL);
- }
- else {
- sprintf(ChannelName, "Channel #%u", i + 1);
- }
-
- if (Verbose > 0)
- printf("%s=", ChannelName);
-
- v = Encoded[i];
-
- if (InHexa) {
-
- if (Width16)
- printf("0x%04X ", (int) floor(v + .5));
- else
- printf("0x%02X ", (int) floor(v / 257. + .5));
-
- } else {
-
- if (Width16)
- printf("%d ", (int) floor(v + .5));
- else
- printf("%d ", (int) floor(v / 257. + .5));
- }
-
- }
-
- printf("\n");
-}
-
-// Print XYZ/Lab values on verbose mode
-
-static
-void PrintPCSEncoded(cmsFloat64Number Input[])
-{
- if (Verbose > 1 && hTransXYZ && hTransLab) {
-
- cmsUInt16Number XYZ[3], Lab[3];
-
- if (hTransXYZ) cmsDoTransform(hTransXYZ, Input, XYZ, 1);
- if (hTransLab) cmsDoTransform(hTransLab, Input, Lab, 1);
-
- printf("[PCS] Lab=(0x%04X,0x%04X,0x%04X) XYZ=(0x%04X,0x%04X,0x%04X)\n", Lab[0], Lab[1], Lab[2],
- XYZ[0], XYZ[1], XYZ[2]);
-
- }
-}
-
-
-// --------------------------------------------------------------------------------------
-
-
-
-// Take a value from IT8 and scale it accordly to fill a cmsUInt16Number (0..FFFF)
-
-static
-cmsFloat64Number GetIT8Val(const char* Name, cmsFloat64Number Max)
-{
- const char* Val = cmsIT8GetData(hIT8in, CGATSPatch, Name);
-
- if (Val == NULL)
- FatalError("Field '%s' not found", Name);
-
- return atof(Val) / Max;
-
-}
-
-
-// Read input values from CGATS file.
-
-static
-void TakeCGATSValues(int nPatch, cmsFloat64Number Float[])
-{
-
- // At first take the name if SAMPLE_ID is present
- if (cmsIT8GetPatchName(hIT8in, nPatch, CGATSPatch) == NULL) {
- FatalError("Sorry, I need 'SAMPLE_ID' on input CGATS to operate.");
- }
-
-
- // Special handling for named color profiles.
- // Lookup the name in the names database (the transform)
-
- if (InputNamedColor) {
-
- const cmsNAMEDCOLORLIST* NamedColorList;
- int index;
-
- NamedColorList = cmsGetNamedColorList(hTrans);
- if (NamedColorList == NULL)
- FatalError("Malformed named color profile");
-
- index = cmsNamedColorIndex(NamedColorList, CGATSPatch);
- if (index < 0)
- FatalError("Named color '%s' not found in the profile", CGATSPatch);
-
- Float[0] = index;
- return;
- }
-
- // Color is not a spot color, proceed.
-
- switch (InputColorSpace) {
-
- // Encoding should follow CGATS specification.
-
- case cmsSigXYZData:
- Float[0] = cmsIT8GetDataDbl(hIT8in, CGATSPatch, "XYZ_X") / 100.0;
- Float[1] = cmsIT8GetDataDbl(hIT8in, CGATSPatch, "XYZ_Y") / 100.0;
- Float[2] = cmsIT8GetDataDbl(hIT8in, CGATSPatch, "XYZ_Z") / 100.0;
- break;
-
- case cmsSigLabData:
- Float[0] = cmsIT8GetDataDbl(hIT8in, CGATSPatch, "LAB_L");
- Float[1] = cmsIT8GetDataDbl(hIT8in, CGATSPatch, "LAB_A");
- Float[2] = cmsIT8GetDataDbl(hIT8in, CGATSPatch, "LAB_B");
- break;
-
-
- case cmsSigRgbData:
- Float[0] = GetIT8Val("RGB_R", 255.0);
- Float[1] = GetIT8Val("RGB_G", 255.0);
- Float[2] = GetIT8Val("RGB_B", 255.0);
- break;
-
- case cmsSigGrayData:
- Float[0] = GetIT8Val("GRAY", 255.0);
- break;
-
- case cmsSigCmykData:
- Float[0] = GetIT8Val("CMYK_C", 1.0);
- Float[1] = GetIT8Val("CMYK_M", 1.0);
- Float[2] = GetIT8Val("CMYK_Y", 1.0);
- Float[3] = GetIT8Val("CMYK_K", 1.0);
- break;
-
- case cmsSigCmyData:
- Float[0] = GetIT8Val("CMY_C", 1.0);
- Float[1] = GetIT8Val("CMY_M", 1.0);
- Float[2] = GetIT8Val("CMY_Y", 1.0);
- break;
-
- case cmsSig1colorData:
- case cmsSig2colorData:
- case cmsSig3colorData:
- case cmsSig4colorData:
- case cmsSig5colorData:
- case cmsSig6colorData:
- case cmsSig7colorData:
- case cmsSig8colorData:
- case cmsSig9colorData:
- case cmsSig10colorData:
- case cmsSig11colorData:
- case cmsSig12colorData:
- case cmsSig13colorData:
- case cmsSig14colorData:
- case cmsSig15colorData:
- {
- cmsUInt32Number i, n;
-
- n = cmsChannelsOfColorSpace(InputColorSpace);
- for (i=0; i < n; i++) {
-
- char Buffer[255];
-
- sprintf(Buffer, "%uCLR_%u", n, i+1);
- Float[i] = GetIT8Val(Buffer, 100.0);
- }
-
- }
- break;
-
- default:
- {
- cmsUInt32Number i, n;
-
- n = cmsChannelsOfColorSpace(InputColorSpace);
- for (i=0; i < n; i++) {
-
- char Buffer[255];
-
- sprintf(Buffer, "CHAN_%u", i+1);
- Float[i] = GetIT8Val(Buffer, 1.0);
- }
-
- }
- }
-
-}
-
-static
-void SetCGATSfld(const char* Col, cmsFloat64Number Val)
-{
- if (lQuantize)
- Val = floor(Val + 0.5);
-
- if (!cmsIT8SetDataDbl(hIT8out, CGATSPatch, Col, Val)) {
- FatalError("couldn't set '%s' on output cgats '%s'", Col, CGATSoutFilename);
- }
-}
-
-
-
-static
-void PutCGATSValues(cmsFloat64Number Float[])
-{
- cmsIT8SetData(hIT8out, CGATSPatch, "SAMPLE_ID", CGATSPatch);
- switch (OutputColorSpace) {
-
-
- // Encoding should follow CGATS specification.
-
- case cmsSigXYZData:
-
- SetCGATSfld("XYZ_X", Float[0] * 100.0);
- SetCGATSfld("XYZ_Y", Float[1] * 100.0);
- SetCGATSfld("XYZ_Z", Float[2] * 100.0);
- break;
-
- case cmsSigLabData:
-
- SetCGATSfld("LAB_L", Float[0]);
- SetCGATSfld("LAB_A", Float[1]);
- SetCGATSfld("LAB_B", Float[2]);
- break;
-
-
- case cmsSigRgbData:
- SetCGATSfld("RGB_R", Float[0] * 255.0);
- SetCGATSfld("RGB_G", Float[1] * 255.0);
- SetCGATSfld("RGB_B", Float[2] * 255.0);
- break;
-
- case cmsSigGrayData:
- SetCGATSfld("GRAY", Float[0] * 255.0);
- break;
-
- case cmsSigCmykData:
- SetCGATSfld("CMYK_C", Float[0]);
- SetCGATSfld("CMYK_M", Float[1]);
- SetCGATSfld("CMYK_Y", Float[2]);
- SetCGATSfld("CMYK_K", Float[3]);
- break;
-
- case cmsSigCmyData:
- SetCGATSfld("CMY_C", Float[0]);
- SetCGATSfld("CMY_M", Float[1]);
- SetCGATSfld("CMY_Y", Float[2]);
- break;
-
- case cmsSig1colorData:
- case cmsSig2colorData:
- case cmsSig3colorData:
- case cmsSig4colorData:
- case cmsSig5colorData:
- case cmsSig6colorData:
- case cmsSig7colorData:
- case cmsSig8colorData:
- case cmsSig9colorData:
- case cmsSig10colorData:
- case cmsSig11colorData:
- case cmsSig12colorData:
- case cmsSig13colorData:
- case cmsSig14colorData:
- case cmsSig15colorData:
- {
-
- cmsInt32Number i, n;
-
- n = cmsChannelsOfColorSpace(InputColorSpace);
- for (i=0; i < n; i++) {
-
- char Buffer[255];
-
- sprintf(Buffer, "%uCLR_%u", n, i+1);
-
- SetCGATSfld(Buffer, Float[i] * 100.0);
- }
- }
- break;
-
- default:
- {
-
- cmsInt32Number i, n;
-
- n = cmsChannelsOfColorSpace(InputColorSpace);
- for (i=0; i < n; i++) {
-
- char Buffer[255];
-
- sprintf(Buffer, "CHAN_%u", i+1);
-
- SetCGATSfld(Buffer, Float[i]);
- }
- }
- }
-}
-
-
-
-// Create data format
-static
-void SetOutputDataFormat(void)
-{
- cmsIT8DefineDblFormat(hIT8out, "%.4g");
- cmsIT8SetPropertyStr(hIT8out, "ORIGINATOR", "icctrans");
-
- if (IncludePart != NULL)
- cmsIT8SetPropertyStr(hIT8out, ".INCLUDE", IncludePart);
-
- cmsIT8SetComment(hIT8out, "Data follows");
- cmsIT8SetPropertyDbl(hIT8out, "NUMBER_OF_SETS", nMaxPatches);
-
-
- switch (OutputColorSpace) {
-
-
- // Encoding should follow CGATS specification.
-
- case cmsSigXYZData:
- cmsIT8SetPropertyDbl(hIT8out, "NUMBER_OF_FIELDS", 4);
- cmsIT8SetDataFormat(hIT8out, 0, "SAMPLE_ID");
- cmsIT8SetDataFormat(hIT8out, 1, "XYZ_X");
- cmsIT8SetDataFormat(hIT8out, 2, "XYZ_Y");
- cmsIT8SetDataFormat(hIT8out, 3, "XYZ_Z");
- break;
-
- case cmsSigLabData:
- cmsIT8SetPropertyDbl(hIT8out, "NUMBER_OF_FIELDS", 4);
- cmsIT8SetDataFormat(hIT8out, 0, "SAMPLE_ID");
- cmsIT8SetDataFormat(hIT8out, 1, "LAB_L");
- cmsIT8SetDataFormat(hIT8out, 2, "LAB_A");
- cmsIT8SetDataFormat(hIT8out, 3, "LAB_B");
- break;
-
-
- case cmsSigRgbData:
- cmsIT8SetPropertyDbl(hIT8out, "NUMBER_OF_FIELDS", 4);
- cmsIT8SetDataFormat(hIT8out, 0, "SAMPLE_ID");
- cmsIT8SetDataFormat(hIT8out, 1, "RGB_R");
- cmsIT8SetDataFormat(hIT8out, 2, "RGB_G");
- cmsIT8SetDataFormat(hIT8out, 3, "RGB_B");
- break;
-
- case cmsSigGrayData:
- cmsIT8SetPropertyDbl(hIT8out, "NUMBER_OF_FIELDS", 2);
- cmsIT8SetDataFormat(hIT8out, 0, "SAMPLE_ID");
- cmsIT8SetDataFormat(hIT8out, 1, "GRAY");
- break;
-
- case cmsSigCmykData:
- cmsIT8SetPropertyDbl(hIT8out, "NUMBER_OF_FIELDS", 5);
- cmsIT8SetDataFormat(hIT8out, 0, "SAMPLE_ID");
- cmsIT8SetDataFormat(hIT8out, 1, "CMYK_C");
- cmsIT8SetDataFormat(hIT8out, 2, "CMYK_M");
- cmsIT8SetDataFormat(hIT8out, 3, "CMYK_Y");
- cmsIT8SetDataFormat(hIT8out, 4, "CMYK_K");
- break;
-
- case cmsSigCmyData:
- cmsIT8SetPropertyDbl(hIT8out, "NUMBER_OF_FIELDS", 4);
- cmsIT8SetDataFormat(hIT8out, 0, "SAMPLE_ID");
- cmsIT8SetDataFormat(hIT8out, 1, "CMY_C");
- cmsIT8SetDataFormat(hIT8out, 2, "CMY_M");
- cmsIT8SetDataFormat(hIT8out, 3, "CMY_Y");
- break;
-
- case cmsSig1colorData:
- case cmsSig2colorData:
- case cmsSig3colorData:
- case cmsSig4colorData:
- case cmsSig5colorData:
- case cmsSig6colorData:
- case cmsSig7colorData:
- case cmsSig8colorData:
- case cmsSig9colorData:
- case cmsSig10colorData:
- case cmsSig11colorData:
- case cmsSig12colorData:
- case cmsSig13colorData:
- case cmsSig14colorData:
- case cmsSig15colorData:
- {
- int i, n;
- char Buffer[255];
-
- n = cmsChannelsOfColorSpace(OutputColorSpace);
- cmsIT8SetPropertyDbl(hIT8out, "NUMBER_OF_FIELDS", n+1);
- cmsIT8SetDataFormat(hIT8out, 0, "SAMPLE_ID");
-
- for (i=1; i <= n; i++) {
- sprintf(Buffer, "%dCLR_%d", n, i);
- cmsIT8SetDataFormat(hIT8out, i, Buffer);
- }
- }
- break;
-
- default: {
-
- int i, n;
- char Buffer[255];
-
- n = cmsChannelsOfColorSpace(OutputColorSpace);
- cmsIT8SetPropertyDbl(hIT8out, "NUMBER_OF_FIELDS", n+1);
- cmsIT8SetDataFormat(hIT8out, 0, "SAMPLE_ID");
-
- for (i=1; i <= n; i++) {
- sprintf(Buffer, "CHAN_%d", i);
- cmsIT8SetDataFormat(hIT8out, i, Buffer);
- }
- }
- }
-}
-
-// Open CGATS if specified
-
-static
-void OpenCGATSFiles(int argc, char *argv[])
-{
- int nParams = argc - xoptind;
-
- if (nParams >= 1) {
-
- hIT8in = cmsIT8LoadFromFile(0, argv[xoptind]);
-
- if (hIT8in == NULL)
- FatalError("'%s' is not recognized as a CGATS file", argv[xoptind]);
-
- nMaxPatches = (int) cmsIT8GetPropertyDbl(hIT8in, "NUMBER_OF_SETS");
- }
-
- if (nParams == 2) {
-
- hIT8out = cmsIT8Alloc(NULL);
- SetOutputDataFormat();
- strncpy(CGATSoutFilename, argv[xoptind+1], cmsMAX_PATH-1);
- }
-
- if (nParams > 2) FatalError("Too many CGATS files");
-}
-
-
-
-// The main sink
-int main(int argc, char *argv[])
-{
- cmsUInt16Number Output[cmsMAXCHANNELS];
- cmsFloat64Number OutputFloat[cmsMAXCHANNELS];
- cmsFloat64Number InputFloat[cmsMAXCHANNELS];
-
- int nPatch = 0;
-
- fprintf(stderr, "LittleCMS ColorSpace conversion calculator - 5.1 [LittleCMS %2.2f]\n", cmsGetEncodedCMMversion() / 1000.0);
- fprintf(stderr, "Copyright (c) 1998-2023 Marti Maria Saguer. See COPYING file for details.\n");
- fflush(stderr);
-
- InitUtils("transicc");
-
- Verbose = 1;
-
- if (argc == 1) {
-
- Help();
- return 0;
- }
-
- HandleSwitches(argc, argv);
-
- // Open profiles, create transforms
- if (!OpenTransforms()) return 1;
-
- // Open CGATS input if specified
- OpenCGATSFiles(argc, argv);
-
- // Main loop: read all values and convert them
- for(;;) {
-
- if (hIT8in != NULL) {
-
- if (nPatch >= nMaxPatches) break;
- TakeCGATSValues(nPatch++, InputFloat);
-
- } else {
-
- if (feof(stdin)) break;
- TakeFloatValues(InputFloat);
-
- }
-
- if (lIsFloat)
- cmsDoTransform(hTrans, InputFloat, OutputFloat, 1);
- else
- cmsDoTransform(hTrans, InputFloat, Output, 1);
-
-
- if (hIT8out != NULL) {
-
- PutCGATSValues(OutputFloat);
- }
- else {
-
- if (lIsFloat) {
- PrintFloatResults(OutputFloat); PrintPCSFloat(InputFloat);
- }
- else {
- PrintEncodedResults(Output); PrintPCSEncoded(InputFloat);
- }
-
- }
- }
-
-
- // Cleanup
- CloseTransforms();
-
- if (hIT8in)
- cmsIT8Free(hIT8in);
-
- if (hIT8out) {
- cmsIT8SaveToFile(hIT8out, CGATSoutFilename);
- cmsIT8Free(hIT8out);
- }
-
- // All is ok
- return 0;
-}
-
-
diff --git a/contrib/libs/lcms2/utils/transicc/ya.make b/contrib/libs/lcms2/utils/transicc/ya.make
deleted file mode 100644
index 8b97c1a44f..0000000000
--- a/contrib/libs/lcms2/utils/transicc/ya.make
+++ /dev/null
@@ -1,56 +0,0 @@
-# Generated by devtools/yamaker.
-
-PROGRAM()
-
-LICENSE(MIT)
-
-LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
-
-VERSION(2.16)
-
-PEERDIR(
- contrib/libs/lcms2
-)
-
-ADDINCL(
- contrib/libs/lcms2/include
- contrib/libs/lcms2/utils/common
- contrib/libs/lcms2/utils/transicc
-)
-
-NO_COMPILER_WARNINGS()
-
-NO_RUNTIME()
-
-CFLAGS(
- -DHAVE_DLFCN_H=1
- -DHAVE_FUNC_ATTRIBUTE_VISIBILITY=1
- -DHAVE_GMTIME_R=1
- -DHAVE_INTTYPES_H=1
- -DHAVE_PTHREAD=1
- -DHAVE_PTHREAD_PRIO_INHERIT=1
- -DHAVE_STDINT_H=1
- -DHAVE_STDIO_H=1
- -DHAVE_STDLIB_H=1
- -DHAVE_STRINGS_H=1
- -DHAVE_STRING_H=1
- -DHAVE_SYS_STAT_H=1
- -DHAVE_SYS_TYPES_H=1
- -DHAVE_TIFFCONF_H=1
- -DHAVE_UNISTD_H=1
- -DHasJPEG=1
- -DHasTHREADS=1
- -DHasTIFF=1
- -DHasZLIB=1
- -DLT_OBJDIR=\".libs/\"
-)
-
-SRCDIR(contrib/libs/lcms2/utils)
-
-SRCS(
- common/vprf.c
- common/xgetopt.c
- transicc/transicc.c
-)
-
-END()
diff --git a/contrib/libs/lcms2/ya.make b/contrib/libs/lcms2/ya.make
deleted file mode 100644
index 3d4c621b73..0000000000
--- a/contrib/libs/lcms2/ya.make
+++ /dev/null
@@ -1,94 +0,0 @@
-# Generated by devtools/yamaker from nixpkgs 22.11.
-
-LIBRARY()
-
-LICENSE(
- MIT AND
- Softsurfer
-)
-
-LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
-
-VERSION(2.16)
-
-ORIGINAL_SOURCE(https://github.com/mm2/Little-CMS/archive/lcms2.16.tar.gz)
-
-ADDINCL(
- contrib/libs/lcms2/include
- contrib/libs/lcms2/src
-)
-
-NO_COMPILER_WARNINGS()
-
-NO_RUNTIME()
-
-CFLAGS(
- -DHAVE_DLFCN_H=1
- -DHAVE_FUNC_ATTRIBUTE_VISIBILITY=1
- -DHAVE_INTTYPES_H=1
- -DHAVE_PTHREAD=1
- -DHAVE_PTHREAD_PRIO_INHERIT=1
- -DHAVE_STDINT_H=1
- -DHAVE_STDIO_H=1
- -DHAVE_STDLIB_H=1
- -DHAVE_STRINGS_H=1
- -DHAVE_STRING_H=1
- -DHAVE_SYS_STAT_H=1
- -DHAVE_SYS_TYPES_H=1
- -DHAVE_TIFFCONF_H=1
- -DHAVE_UNISTD_H=1
- -DHasJPEG=1
- -DHasTHREADS=1
- -DHasTIFF=1
- -DHasZLIB=1
- -DLT_OBJDIR=\".libs/\"
-)
-
-IF (OS_WINDOWS)
- CFLAGS(
- -DHAVE_GMTIME_S=1
- )
-ELSE()
- CFLAGS(
- -DHAVE_GMTIME_R=1
- )
-ENDIF()
-
-SRCS(
- src/cmsalpha.c
- src/cmscam02.c
- src/cmscgats.c
- src/cmscnvrt.c
- src/cmserr.c
- src/cmsgamma.c
- src/cmsgmt.c
- src/cmshalf.c
- src/cmsintrp.c
- src/cmsio0.c
- src/cmsio1.c
- src/cmslut.c
- src/cmsmd5.c
- src/cmsmtrx.c
- src/cmsnamed.c
- src/cmsopt.c
- src/cmspack.c
- src/cmspcs.c
- src/cmsplugin.c
- src/cmsps2.c
- src/cmssamp.c
- src/cmssm.c
- src/cmstypes.c
- src/cmsvirt.c
- src/cmswtpnt.c
- src/cmsxform.c
-)
-
-END()
-
-RECURSE(
- utils/jpgicc
- utils/linkicc
- utils/psicc
- utils/tificc
- utils/transicc
-)
diff --git a/contrib/libs/libjpeg-turbo/.yandex_meta/__init__.py b/contrib/libs/libjpeg-turbo/.yandex_meta/__init__.py
deleted file mode 100644
index f978cc5d12..0000000000
--- a/contrib/libs/libjpeg-turbo/.yandex_meta/__init__.py
+++ /dev/null
@@ -1,117 +0,0 @@
-import shutil
-
-from devtools.yamaker.arcpath import ArcPath
-from devtools.yamaker import fileutil
-from devtools.yamaker import pathutil
-from devtools.yamaker.modules import Program, Linkable, Recursable, Switch
-from devtools.yamaker.project import CMakeNinjaNixProject
-
-
-def post_build(self):
- # neon-compat.h is replaced during CMake build upon native / cross-compilation under arm.
- # As we do not run such compilation, we have to generate corresponding source manually.
- shutil.copy(
- f"{self.srcdir}/simd/arm/neon-compat.h.in",
- f"{self.dstdir}/simd/arm/neon-compat.h",
- )
- fileutil.re_sub_file(f"{self.dstdir}/simd/arm/neon-compat.h", r"\#cmakedefine", "// #cmakedefine")
-
-
-def post_install(self):
- for prj, m in self.yamakes.items():
- if isinstance(m, Program):
- m.PEERDIR.add(self.arcdir)
-
- with self.yamakes["."] as m:
- # These flags break build of libjpeg-turbo with local xcode toolchain.
- # (`ya make --maps-mobile --target-platform=local-iossim-arm64' at the time)
- m.CFLAGS.remove("-DELF")
- m.CFLAGS.remove("-D__x86_64__")
-
- m.ADDINCL.remove(self.arcdir + "/simd/x86_64")
- m.ADDINCL.remove(self.arcdir + "/simd/nasm")
- m.ADDINCL.add(ArcPath(f"{self.arcdir}/simd/nasm", FOR="asm"))
- m.after("CFLAGS", Switch({"SANITIZER_TYPE": Linkable(CFLAGS=["-DWITH_SANITIZER"])}))
- m.after("ADDINCL", Switch({"OS_DARWIN OR OS_IOS": "SET(ASM_PREFIX '_')"}))
-
- # Sources from simd/arm/aarch64/*-neon.c are included into other sources.
- # This heuristics is used to detect whether the source should be compiled directly.
- def is_direct_source(src):
- return pathutil.is_source(src) and "ext" not in src
-
- amd64 = {s for s in m.SRCS if s.startswith("simd/")}
- i386 = fileutil.files(self.dstdir + "/simd/i386", rel=self.dstdir, test=is_direct_source)
- arm = fileutil.files(self.dstdir + "/simd/arm/aarch32", rel=self.dstdir, test=is_direct_source)
- arm64 = [
- src for src in fileutil.listdir(f"{self.dstdir}/simd/arm", rel=self.dstdir) if is_direct_source(src)
- ] + [
- src for src in fileutil.listdir(f"{self.dstdir}/simd/arm/aarch64", rel=self.dstdir) if is_direct_source(src)
- ]
- simd_none = ["jsimd_none.c"]
-
- # This file contains the older GNU Assembler implementation of the Neon SIMD
- # extensions for certain algorithms.
- # We are using clang 12+ which has a full set of Neon intrinsics
- arm64.remove("simd/arm/aarch64/jsimd_neon.S")
-
- m.SRCS -= amd64
- m.before(
- "SRCS",
- Switch(
- [
- ("OS_ANDROID", Linkable(SRCS=simd_none)),
- ("ARCH_I386", Linkable(SRCS=i386)),
- ("ARCH_X86_64", Linkable(SRCS=amd64)),
- ("ARCH_ARM7 AND NOT MSVC", Linkable(SRCS=arm)),
- (
- "ARCH_ARM64 AND NOT MSVC",
- Linkable(SRCS=arm64, ADDINCL=[f"{self.arcdir}/simd/arm"]),
- ),
- ("default", Linkable(SRCS=simd_none)),
- ]
- ),
- )
-
- m.after(
- "RECURSE",
- Switch(
- [
- (
- "NOT OS_ANDROID AND NOT OS_IOS",
- Recursable(RECURSE_FOR_TESTS=["ut"]),
- ),
- ]
- ),
- )
-
-
-libjpeg_turbo = CMakeNinjaNixProject(
- arcdir="contrib/libs/libjpeg-turbo",
- nixattr="libjpeg",
- owners=["g:cpp-contrib", "g:avatars"],
- ignore_commands={"bash", "sed"},
- install_targets={"turbojpeg", "cjpeg", "djpeg", "tjunittest", "jpegtran"},
- put={
- "turbojpeg": ".",
- "cjpeg": "cjpeg",
- "djpeg": "djpeg",
- "jpegtran": "jpegtran",
- "tjunittest": "tjunittest",
- },
- platform_dispatchers=["jconfigint.h"],
- copy_sources=[
- "simd/arm/",
- "simd/i386/",
- "simd/nasm/",
- "simd/x86_64/",
- "jsimd_none.c",
- ],
- keep_paths={
- "ut/*.py",
- "ut/canondata/",
- "ut/ya.make",
- "testimages/",
- },
- post_build=post_build,
- post_install=post_install,
-)
diff --git a/contrib/libs/libjpeg-turbo/.yandex_meta/devtools.copyrights.report b/contrib/libs/libjpeg-turbo/.yandex_meta/devtools.copyrights.report
deleted file mode 100644
index 7a5226dbd1..0000000000
--- a/contrib/libs/libjpeg-turbo/.yandex_meta/devtools.copyrights.report
+++ /dev/null
@@ -1,2326 +0,0 @@
-# File format ($ symbol means the beginning of a line):
-#
-# $ # this message
-# $ # =======================
-# $ # comments (all commentaries should starts with some number of spaces and # symbol)
-# $ IGNORE_FILES {file1.ext1} {file2.ext2} - (optional) ignore listed files when generating license macro and credits
-# $ RENAME {original license id} TO {new license id} # user comments - (optional) use {new license id} instead {original license id} in ya.make files
-# $ # user comments
-# $
-# ${action} {license id} {license text hash}
-# $BELONGS ./ya/make/file/relative/path/1/ya.make ./ya/make/2/ya.make
-# ${all_file_action} filename
-# $ # user commentaries (many lines)
-# $ generated description - files with this license, license text... (some number of lines that starts with some number of spaces, do not modify)
-# ${action} {license spdx} {license text hash}
-# $BELONGS ./ya/make/file/relative/path/3/ya.make
-# ${all_file_action} filename
-# $ # user commentaries
-# $ generated description
-# $ ...
-#
-# You can modify action, all_file_action and add commentaries
-# Available actions:
-# keep - keep license in contrib and use in credits
-# skip - skip license
-# remove - remove all files with this license
-# rename - save license text/links into licenses texts file, but not store SPDX into LINCENSE macro. You should store correct license id into devtools.license.spdx.txt file
-#
-# {all file action} records will be generated when license text contains filename that exists on filesystem (in contrib directory)
-# We suppose that that files can contain some license info
-# Available all file actions:
-# FILE_IGNORE - ignore file (do nothing)
-# FILE_INCLUDE - include all file data into licenses text file
-# =======================
-
-KEEP COPYRIGHT_SERVICE_LABEL 001270d0986e016a64e4488c035ddac5
-BELONGS ya.make
- License text:
- ; Copyright (C) 2011, 2016, D. R. Commander.
- ; Copyright (C) 2015, Intel Corporation.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- simd/i386/jcgray-avx2.asm [4:5]
- simd/i386/jcgray-mmx.asm [4:5]
- simd/i386/jcgray-sse2.asm [4:4]
- simd/i386/jcgryext-avx2.asm [4:5]
- simd/i386/jcgryext-mmx.asm [4:5]
- simd/i386/jcgryext-sse2.asm [4:4]
- simd/x86_64/jcgray-avx2.asm [4:5]
- simd/x86_64/jcgray-sse2.asm [4:4]
- simd/x86_64/jcgryext-avx2.asm [4:6]
- simd/x86_64/jcgryext-sse2.asm [4:5]
-
-KEEP COPYRIGHT_SERVICE_LABEL 03620b5e1cb0526b5c8fb74838b3a3ef
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdmainct.c at line 8
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jdmainct.c [5:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL 048093befc4541c84a0b4aff0eb0e58a
-BELONGS ya.make
- License text:
- * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- * Copyright (C) 2009-2011, 2014, 2016, 2018, 2022, D. R. Commander.
- * Copyright (C) 2015-2016, 2018, Matthieu Darbois.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- simd/x86_64/jsimd.c [4:6]
-
-KEEP COPYRIGHT_SERVICE_LABEL 05117f6a64c717808d7abe982066f754
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jddctmgr.c at line 11
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jddctmgr.c [5:12]
-
-KEEP COPYRIGHT_SERVICE_LABEL 07e12474a71a9c9264beced90941125c
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: simd/arm/aarch64/jchuff-neon.c at line 9, simd/arm/jchuff.h at line 10, simd/arm/jcphuff-neon.c at line 9, simd/arm/jquanti-neon.c at line 9, simd/arm/neon-compat.h at line 8
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- simd/arm/aarch64/jchuff-neon.c [4:4]
- simd/arm/jchuff.h [5:11]
- simd/arm/jcphuff-neon.c [4:4]
- simd/arm/jquanti-neon.c [4:4]
- simd/arm/neon-compat.h [3:3]
-
-KEEP COPYRIGHT_SERVICE_LABEL 085866dc673ec19d97c4979b0d3203f8
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jquant2.c at line 8
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jquant2.c [5:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL 090deb413327d7c4ccdeb6f33c67502b
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jcapimin.c at line 9, jcprepct.c at line 9, jerror.c at line 9, jinclude.h at line 9, jutils.c at line 9
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jcapimin.c [5:10]
- jcprepct.c [5:9]
- jerror.c [5:9]
- jinclude.h [5:9]
- jutils.c [5:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL 09adeb42ae4a6bea0b7aa5aaf65de91a
-BELONGS ya.make
- License text:
- ; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- ; Copyright (C) 2009, 2016, 2020, D. R. Commander.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- simd/x86_64/jfdctint-sse2.asm [4:5]
- simd/x86_64/jidctint-sse2.asm [4:6]
-
-KEEP COPYRIGHT_SERVICE_LABEL 0ae009ac16fbacd31d4b77e95303858a
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: cderror.h at line 9, cdjpeg.h at line 9, jccoefct.c at line 9, jcomapi.c at line 9, jdcoefct.c at line 9, jdcoefct.h at line 9, jerror.h at line 9
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- cderror.h [5:10]
- cdjpeg.h [5:10]
- jccoefct.c [5:8]
- jcomapi.c [5:8]
- jdcoefct.c [5:11]
- jdcoefct.h [5:10]
- jerror.h [5:10]
-
-KEEP COPYRIGHT_SERVICE_LABEL 0b0ac4cd285016cb09b8319e3f765270
-BELONGS ya.make
- License text:
- * Copyright (C)2011, 2019 D. R. Commander. All Rights Reserved.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- tjutil.c [2:2]
-
-KEEP COPYRIGHT_SERVICE_LABEL 0d16e03bc8aea0727b77e84f46679705
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdmaster.h at line 6
- License text:
- * Copyright (C) 1991-1995, Thomas G. Lane.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jdmaster.h [5:7]
-
-KEEP COPYRIGHT_SERVICE_LABEL 0f8337340bfc4fc39a2fe07a61afd6b0
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdarith.c at line 8
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jdarith.c [5:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL 0f897163c7037d3f0adbe0fe504532f8
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jcmarker.c at line 9
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jcmarker.c [5:10]
-
-KEEP COPYRIGHT_SERVICE_LABEL 10c71bcfc53b06ea8660c6ef781bbbe9
-BELONGS ya.make
- License text:
- ; Copyright 2009, 2012 Pierre Ossman <ossman@cendio.se> for Cendio AB
- ; Copyright (C) 2012, 2016, D. R. Commander.
- ; Copyright (C) 2015, Intel Corporation.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- simd/i386/jdcolext-avx2.asm [4:6]
- simd/i386/jdcolext-sse2.asm [4:5]
- simd/i386/jdmrgext-avx2.asm [4:6]
- simd/i386/jdmrgext-sse2.asm [4:5]
-
-KEEP COPYRIGHT_SERVICE_LABEL 11e733d6a587075ab68bcc53d29822a6
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: djpeg.c at line 10, jdapistd.c at line 10, jdinput.c at line 10, jdmaster.c at line 10, jdsample.c at line 10, jpegint.h at line 10, jpeglib.h at line 10
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- djpeg.c [5:11]
- jdapistd.c [5:10]
- jdinput.c [5:10]
- jdmaster.c [5:12]
- jdsample.c [5:13]
- jpegint.h [5:12]
- jpeglib.h [5:11]
-
-KEEP COPYRIGHT_SERVICE_LABEL 1249c3d3fb0e107f4cabda7b2efba8b8
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jcphuff.c at line 11, jdphuff.c at line 11, jdtrans.c at line 11
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jcphuff.c [5:12]
- jdphuff.c [5:9]
- jdtrans.c [5:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL 152add89d1791fb293414e86b81304ef
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdapimin.c at line 8
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jdapimin.c [5:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL 165527239955f985662e0f2fe1203f1b
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: transupp.c at line 8, transupp.h at line 8
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- transupp.c [5:9]
- transupp.h [5:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL 1acdcc86793fefc64c4fe4c565b2f14f
-BELONGS ya.make
- License text:
- * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- * Copyright (C) 2011, 2014, D. R. Commander.
- * Copyright (C) 2015-2016, 2018, Matthieu Darbois.
- * Copyright (C) 2020, Arm Limited.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jsimd.h [4:7]
- jsimd_none.c [4:7]
- simd/arm/aarch32/jsimd.c [4:9]
- simd/arm/aarch32/jsimd_neon.S [10:10]
- simd/arm/aarch64/jsimd.c [4:8]
- simd/arm/aarch64/jsimd_neon.S [10:10]
- simd/i386/jsimd.c [4:6]
- simd/jsimd.h [4:10]
- simd/x86_64/jsimd.c [4:6]
-
-KEEP COPYRIGHT_SERVICE_LABEL 1ad7e944e1e9a46ed48b14a55138bda8
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jpegint.h at line 11
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jpegint.h [5:12]
-
-KEEP COPYRIGHT_SERVICE_LABEL 1afd790e43464ee897b6f4dad7e6ce6d
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: rdtarga.c at line 9
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- rdtarga.c [5:10]
-
-KEEP COPYRIGHT_SERVICE_LABEL 1b892e92391ba1d018a5507c7b63228c
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jcarith.c at line 8
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jcarith.c [5:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL 1ba19ef1d18e94a36d48de79900507c6
-BELONGS ya.make
- License text:
- ; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- ; Copyright (C) 2009, 2016, 2018, D. R. Commander.
- ; Copyright (C) 2016, Matthieu Darbois.
- ; Copyright (C) 2018, Matthias Räncker.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- simd/x86_64/jquanti-avx2.asm [4:7]
-
-KEEP COPYRIGHT_SERVICE_LABEL 1e45cf53e9734d2459db159d28f16e4b
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jinclude.h at line 8
- License text:
- * Copyright (C) 1991-1994, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jinclude.h [5:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL 1e540cb130e098262d5aec64669768fd
-BELONGS ya.make
- License text:
- ; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- ; Copyright (C) 2016, 2018, D. R. Commander.
- ; Copyright (C) 2016, Matthieu Darbois.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- simd/i386/jquanti-avx2.asm [4:6]
- simd/x86_64/jquanti-avx2.asm [4:7]
-
-KEEP COPYRIGHT_SERVICE_LABEL 1e9cc28e6b04389db80412d634fddb7e
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdhuff.c at line 9
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jdhuff.c [5:10]
-
-KEEP COPYRIGHT_SERVICE_LABEL 1f57de85739b7a14cfcd6ca84f7bfb7e
-BELONGS ya.make
- License text:
- * Copyright (C) 2009-2011, Nokia Corporation and/or its subsidiary(-ies).
- * All Rights Reserved.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- simd/arm/aarch32/jsimd_neon.S [4:5]
- simd/arm/aarch64/jsimd_neon.S [4:5]
-
-KEEP COPYRIGHT_SERVICE_LABEL 1fb659a53f330f9569a89bd858ef3ce1
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdcol565.c at line 9
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jdcol565.c [5:10]
-
-KEEP COPYRIGHT_SERVICE_LABEL 20b2a093ccd5225bc6fc55fe4031949c
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdmrgext.c at line 8
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jdmrgext.c [5:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL 212c71fc80caadb4a16b0e0298e0ca71
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdcoefct.c at line 10
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jdcoefct.c [5:11]
-
-KEEP COPYRIGHT_SERVICE_LABEL 23088d1c57488b04621001ac1f22cd37
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdcoefct.h at line 9
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jdcoefct.h [5:10]
-
-KEEP COPYRIGHT_SERVICE_LABEL 233835017fd9ed43858ecd8787bb95f6
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: cderror.h at line 9
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- cderror.h [5:10]
-
-KEEP COPYRIGHT_SERVICE_LABEL 25274b14836176e3a440bcf831a85954
-BELONGS ya.make
- License text:
- * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- * Copyright (C) 2011, 2014, D. R. Commander.
- * Copyright (C) 2015-2016, 2018, Matthieu Darbois.
- * Copyright (C) 2020, Arm Limited.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jsimd.h [4:7]
-
-KEEP COPYRIGHT_SERVICE_LABEL 260db70ba88e7f60351667e8f9254026
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: cjpeg.c at line 9, jcmarker.c at line 9, jcparam.c at line 9, jdmarker.c at line 9, jerror.c at line 9, jidctint.c at line 9, jpeglib.h at line 9, jstdhuff.c at line 9
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- cjpeg.c [5:10]
- jcmarker.c [5:10]
- jcparam.c [5:10]
- jdmarker.c [5:9]
- jerror.c [5:9]
- jidctint.c [5:10]
- jpeglib.h [5:11]
- jstdhuff.c [5:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL 263caad4ba33bd3ef6290d6aeecbe970
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jchuff.c at line 11
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jchuff.c [5:12]
-
-KEEP COPYRIGHT_SERVICE_LABEL 2672fb937e60710dec1b0b8a7906d209
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jcparam.c at line 9
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jcparam.c [5:10]
-
-KEEP COPYRIGHT_SERVICE_LABEL 26eb00d97e3ef709d9a86754532ff978
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- LICENSE.md [94:94]
- jversion.h [39:51]
- turbojpeg.c [2:2]
-
-KEEP COPYRIGHT_SERVICE_LABEL 295e5b669dd969a48ac39f34bc8fd7d3
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdcolor.c at line 11
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jdcolor.c [5:12]
-
-KEEP COPYRIGHT_SERVICE_LABEL 29b99ba4246a9d3cc7b50e48a274da0d
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: rdbmp.c at line 10
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- rdbmp.c [5:11]
-
-KEEP COPYRIGHT_SERVICE_LABEL 2abf650befa8dcfcd29490f514c687d3
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdapistd.c at line 9
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jdapistd.c [5:10]
-
-KEEP COPYRIGHT_SERVICE_LABEL 2e20febfc45f1f8ef6742ee1936089c4
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- simd/jsimd.h [4:10]
-
-KEEP COPYRIGHT_SERVICE_LABEL 366e4b10a51306ff66614307ac53900d
-BELONGS ya.make
- License text:
- ; Copyright 2009, 2012 Pierre Ossman <ossman@cendio.se> for Cendio AB
- ; Copyright (C) 2012, 2016, D. R. Commander.
- ; Copyright (C) 2015, Intel Corporation.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- simd/i386/jdcolext-avx2.asm [4:6]
- simd/i386/jdcolext-sse2.asm [4:5]
- simd/i386/jdmrgext-avx2.asm [4:6]
- simd/i386/jdmrgext-sse2.asm [4:5]
- simd/x86_64/jdcolext-avx2.asm [4:7]
- simd/x86_64/jdcolext-sse2.asm [4:6]
- simd/x86_64/jdmrgext-avx2.asm [4:7]
- simd/x86_64/jdmrgext-sse2.asm [4:6]
-
-KEEP COPYRIGHT_SERVICE_LABEL 36e84c409abecc7cefe7cd5dfd105381
-BELONGS ya.make
- License text:
- * Copyright (C)2009-2015, 2017, 2020-2021 D. R. Commander.
- * All Rights Reserved.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- turbojpeg.h [2:3]
-
-KEEP COPYRIGHT_SERVICE_LABEL 39c71721bea6dbebf0fe12a4104a16ba
-BELONGS ya.make
- License text:
- * Copyright (C)2016, 2018-2019, 2022 D. R. Commander. All Rights Reserved.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- md5/md5hl.c [9:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL 3d8a221d5e85eceaf22464a0b1bc72cd
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdinput.c at line 9
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jdinput.c [5:10]
-
-KEEP COPYRIGHT_SERVICE_LABEL 3ff1e15ee5c983f31a11845ba1303bdd
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: simd/arm/jchuff.h at line 10
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- simd/arm/jchuff.h [5:11]
-
-KEEP COPYRIGHT_SERVICE_LABEL 4292948c897bb7af094f64c57edbd8ef
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jerror.h at line 9
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jerror.h [5:10]
-
-KEEP COPYRIGHT_SERVICE_LABEL 44be2ad22f421bfaf11c38a97ec194fa
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdatadst-tj.c at line 9
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jdatadst-tj.c [5:10]
-
-KEEP COPYRIGHT_SERVICE_LABEL 44c57ae8756c03a43cc49d652ea73313
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jccolext.c at line 8, jccolor.c at line 8, jcsample.c at line 8, jdsample.c at line 8, jdsample.h at line 8, jfdctint.c at line 8, jquant1.c at line 8, jquant2.c at line 8, jutils.c at line 8, rdswitch.c at line 8, rdtarga.c at line 8, wrppm.c at line 8, wrtarga.c at line 8
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jccolext.c [5:9]
- jccolor.c [5:11]
- jcsample.c [5:11]
- jdsample.c [5:13]
- jdsample.h [5:7]
- jfdctint.c [5:9]
- jquant1.c [5:9]
- jquant2.c [5:9]
- jutils.c [5:9]
- rdswitch.c [5:9]
- rdtarga.c [5:10]
- wrppm.c [5:10]
- wrtarga.c [5:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL 450015c7f57bc091445dc56f6b2cdfc0
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: wrppm.c at line 9
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- wrppm.c [5:10]
-
-KEEP COPYRIGHT_SERVICE_LABEL 45dfad5b2ebfed97272719e6f1ef717c
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: rdgif.c at line 9
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- rdgif.c [5:10]
-
-KEEP COPYRIGHT_SERVICE_LABEL 4636a62a8d91a4cbe9262bf83287b971
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jcicc.c at line 6, jdicc.c at line 6
- License text:
- * Copyright (C) 1997-1998, Thomas G. Lane, Todd Newman.
- * Copyright (C) 2017, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jcicc.c [4:7]
- jdicc.c [4:7]
-
-KEEP COPYRIGHT_SERVICE_LABEL 47fc44857c47b9fc7886e2d4af29d56d
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jversion.h [39:51]
-
-KEEP COPYRIGHT_SERVICE_LABEL 480cafc45780df29ac6b7113176124d9
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jmemnobs.c at line 8
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jmemnobs.c [5:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL 4855c5404dbb62841cec15bacf070c2e
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jchuff.c at line 11, jcphuff.c at line 11, jsimd.h at line 10, jsimd_none.c at line 10, simd/arm/aarch32/jccolext-neon.c at line 10, simd/arm/aarch32/jchuff-neon.c at line 10, simd/arm/aarch32/jsimd.c at line 10, simd/arm/aarch64/jccolext-neon.c at line 10, simd/arm/aarch64/jsimd.c at line 10, simd/arm/align.h at line 8, simd/arm/jccolor-neon.c at line 10, simd/arm/jcgray-neon.c at line 10, simd/arm/jcgryext-neon.c at line 10, simd/arm/jcsample-neon.c at line 10, simd/arm/jdcolext-neon.c at line 10, simd/arm/jdcolor-neon.c at line 10, simd/arm/jdmerge-neon.c at line 10, simd/arm/jdmrgext-neon.c at line 10, simd/arm/jdsample-neon.c at line 10, simd/arm/jfdctfst-neon.c at line 10, simd/arm/jfdctint-neon.c at line 10, simd/arm/jidctfst-neon.c at line 10, simd/arm/jidctint-neon.c at line 10, simd/arm/jidctred-neon.c at line 10, simd/jsimd.h at line 10
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jchuff.c [5:12]
- jcphuff.c [5:12]
- jsimd.h [4:7]
- jsimd_none.c [4:7]
- simd/arm/aarch32/jccolext-neon.c [4:4]
- simd/arm/aarch32/jchuff-neon.c [4:4]
- simd/arm/aarch32/jsimd.c [4:9]
- simd/arm/aarch64/jccolext-neon.c [4:4]
- simd/arm/aarch64/jsimd.c [4:8]
- simd/arm/align.h [2:2]
- simd/arm/jccolor-neon.c [4:4]
- simd/arm/jcgray-neon.c [4:4]
- simd/arm/jcgryext-neon.c [4:4]
- simd/arm/jcsample-neon.c [4:4]
- simd/arm/jdcolext-neon.c [4:4]
- simd/arm/jdcolor-neon.c [4:4]
- simd/arm/jdmerge-neon.c [4:4]
- simd/arm/jdmrgext-neon.c [4:4]
- simd/arm/jdsample-neon.c [4:4]
- simd/arm/jfdctfst-neon.c [4:4]
- simd/arm/jfdctint-neon.c [4:4]
- simd/arm/jidctfst-neon.c [4:4]
- simd/arm/jidctint-neon.c [4:4]
- simd/arm/jidctred-neon.c [4:4]
- simd/jsimd.h [4:10]
-
-KEEP COPYRIGHT_SERVICE_LABEL 4a3493336b28feee7d6c4e061d0a2d2b
-BELONGS ya.make
- License text:
- * Author: Siarhei Siamashka <siarhei.siamashka@nokia.com>
- * Copyright (C) 2013-2014, Linaro Limited. All Rights Reserved.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- simd/arm/aarch64/jsimd_neon.S [6:7]
-
-KEEP COPYRIGHT_SERVICE_LABEL 4f6b6761b55823e2cea9a9046a1374b4
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdmrg565.c at line 9
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jdmrg565.c [5:10]
-
-KEEP COPYRIGHT_SERVICE_LABEL 501d9d9fd254b645bfdd5c1afeaf2b7b
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jmemsys.h at line 8
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jmemsys.h [5:8]
-
-KEEP COPYRIGHT_SERVICE_LABEL 518ffe97c21503649bc9db24a865cf6b
-BELONGS ya.make
- License text:
- ; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- ; Copyright (C) 2010, 2016, 2018-2019, D. R. Commander.
- ; Copyright (C) 2018, Matthieu Darbois.
- ; Copyright (C) 2018, Matthias Räncker.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- simd/nasm/jsimdext.inc [4:7]
-
-KEEP COPYRIGHT_SERVICE_LABEL 519b50edb8a80de408600b1899cfb023
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jfdctint.c at line 8, jidctint.c at line 8
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jfdctint.c [5:9]
- jidctint.c [5:10]
-
-KEEP COPYRIGHT_SERVICE_LABEL 51bad5f487918501ea2be46512c58c6b
-BELONGS ya.make
- License text:
- Copyright (c) 1991-2022 The libjpeg-turbo Project
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jversion.h [53:54]
-
-KEEP COPYRIGHT_SERVICE_LABEL 52ef6eff15e58ea7a30014a18522a0b8
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- simd/jsimd.h [4:10]
-
-KEEP COPYRIGHT_SERVICE_LABEL 55d69ef5c2827524a7c5cdd2ef41b997
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- simd/jsimd.h [4:10]
-
-KEEP COPYRIGHT_SERVICE_LABEL 56675cea16b7bae01af08a1aea00daaa
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jversion.h at line 8
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jversion.h [5:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL 5aa53b258f764fbe51be48c4ab1f1d1f
-BELONGS ya.make
- License text:
- ; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- ; Copyright (C) 2009, 2016, 2018, 2020, D. R. Commander.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- simd/i386/jfdctint-avx2.asm [4:5]
- simd/i386/jidctint-avx2.asm [4:5]
- simd/x86_64/jfdctint-avx2.asm [4:5]
- simd/x86_64/jidctint-avx2.asm [4:6]
-
-KEEP COPYRIGHT_SERVICE_LABEL 5b4d2ba74e51eb91bbd5aef822f9aae3
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jpegtran.c at line 8
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jpegtran.c [5:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL 5be2bec78aaafa60d86afed2fe95055c
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: djpeg.c at line 10
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- djpeg.c [5:11]
-
-KEEP COPYRIGHT_SERVICE_LABEL 5f6a538b377c16ee13ee1496c713b176
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- simd/x86_64/jdcolext-avx2.asm [4:7]
- simd/x86_64/jdcolext-sse2.asm [4:6]
- simd/x86_64/jdmrgext-avx2.asm [4:7]
- simd/x86_64/jdmrgext-sse2.asm [4:6]
-
-KEEP COPYRIGHT_SERVICE_LABEL 600b52ef1b2e8a91bced51054f66f3b1
-BELONGS ya.make
- License text:
- * "How to Optimize for the Pentium Processors", Copyright (c) 1996, 1997 by
- * Agner Fog. This code assumes we are on a two's complement machine.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jchuff.c [583:584]
- jcphuff.c [521:522]
-
-KEEP COPYRIGHT_SERVICE_LABEL 60905578d76ff9b2e20929c31ca32f13
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdhuff.h at line 9
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jdhuff.h [5:10]
-
-KEEP COPYRIGHT_SERVICE_LABEL 60bbb1946c5720a631b0e530309742ec
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jchuff.c at line 11, simd/i386/jchuff-sse2.asm at line 10, simd/x86_64/jchuff-sse2.asm at line 10
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jchuff.c [5:12]
- simd/i386/jchuff-sse2.asm [4:6]
- simd/x86_64/jchuff-sse2.asm [4:6]
-
-KEEP COPYRIGHT_SERVICE_LABEL 660eca46c511999474ff8017e496f51c
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jversion.h [39:51]
-
-KEEP COPYRIGHT_SERVICE_LABEL 6671698e9a2a769e8f652725e0cd494a
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: cdjpeg.h at line 9
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- cdjpeg.h [5:10]
-
-KEEP COPYRIGHT_SERVICE_LABEL 66e5c8e9af8d0ef7cf8741f0659c1e0c
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jpegtran.c at line 8
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jpegtran.c [5:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL 6810534b9bd4aab0c6b7827b6c0f1fd9
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jcinit.c at line 8, jdmerge.h at line 8, jdtrans.c at line 8, simd/arm/aarch32/jccolext-neon.c at line 8, simd/arm/jccolor-neon.c at line 8, simd/arm/jdcolext-neon.c at line 8, simd/arm/jdmrgext-neon.c at line 8, simd/arm/jdsample-neon.c at line 8, simd/arm/jfdctint-neon.c at line 8, simd/arm/jidctint-neon.c at line 8, simd/arm/jidctred-neon.c at line 8, simd/arm/neon-compat.h at line 5
- License text:
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2020, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jcinit.c [5:9]
- jdmerge.h [5:9]
- jdtrans.c [5:9]
- simd/arm/aarch32/jccolext-neon.c [5:5]
- simd/arm/jccolor-neon.c [5:5]
- simd/arm/jdcolext-neon.c [5:5]
- simd/arm/jdmrgext-neon.c [5:5]
- simd/arm/jdsample-neon.c [5:5]
- simd/arm/jfdctint-neon.c [5:5]
- simd/arm/jidctint-neon.c [5:5]
- simd/arm/jidctred-neon.c [5:5]
- simd/arm/neon-compat.h [2:2]
-
-KEEP COPYRIGHT_SERVICE_LABEL 6813c2b6fb9997bdcb51ad621d1a371b
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdmarker.c at line 8
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jdmarker.c [5:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL 6aff4539cc564a76b36cfd2daf2e3833
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jchuff.c at line 11, jdhuff.c at line 11, jdhuff.h at line 11, simd/arm/jchuff.h at line 11, simd/i386/jchuff-sse2.asm at line 10, simd/nasm/jsimdext.inc at line 10, simd/x86_64/jccolext-avx2.asm at line 10, simd/x86_64/jccolext-sse2.asm at line 10, simd/x86_64/jcgryext-avx2.asm at line 10, simd/x86_64/jcgryext-sse2.asm at line 10, simd/x86_64/jchuff-sse2.asm at line 10, simd/x86_64/jcsample-avx2.asm at line 10, simd/x86_64/jcsample-sse2.asm at line 10, simd/x86_64/jdcolext-avx2.asm at line 10, simd/x86_64/jdcolext-sse2.asm at line 10, simd/x86_64/jdmrgext-avx2.asm at line 10, simd/x86_64/jdmrgext-sse2.asm at line 10, simd/x86_64/jdsample-avx2.asm at line 10, simd/x86_64/jdsample-sse2.asm at line 10, simd/x86_64/jidctflt-sse2.asm at line 10, simd/x86_64/jidctfst-sse2.asm at line 10, simd/x86_64/jidctint-avx2.asm at line 10, simd/x86_64/jidctint-sse2.asm at line 10, simd/x86_64/jidctred-sse2.asm at line 10, simd/x86_64/jquantf-sse2.asm at line 10, simd/x86_64/jquanti-avx2.asm at line 10, simd/x86_64/jquanti-sse2.asm at line 10
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jchuff.c [5:12]
- jdhuff.c [5:10]
- jdhuff.h [5:10]
- simd/arm/jchuff.h [5:11]
- simd/i386/jchuff-sse2.asm [4:6]
- simd/nasm/jsimdext.inc [4:7]
- simd/x86_64/jccolext-avx2.asm [4:6]
- simd/x86_64/jccolext-sse2.asm [4:5]
- simd/x86_64/jcgryext-avx2.asm [4:6]
- simd/x86_64/jcgryext-sse2.asm [4:5]
- simd/x86_64/jchuff-sse2.asm [4:6]
- simd/x86_64/jcsample-avx2.asm [4:7]
- simd/x86_64/jcsample-sse2.asm [4:6]
- simd/x86_64/jdcolext-avx2.asm [4:7]
- simd/x86_64/jdcolext-sse2.asm [4:6]
- simd/x86_64/jdmrgext-avx2.asm [4:7]
- simd/x86_64/jdmrgext-sse2.asm [4:6]
- simd/x86_64/jdsample-avx2.asm [4:7]
- simd/x86_64/jdsample-sse2.asm [4:6]
- simd/x86_64/jidctflt-sse2.asm [4:6]
- simd/x86_64/jidctfst-sse2.asm [4:6]
- simd/x86_64/jidctint-avx2.asm [4:6]
- simd/x86_64/jidctint-sse2.asm [4:6]
- simd/x86_64/jidctred-sse2.asm [4:6]
- simd/x86_64/jquantf-sse2.asm [4:6]
- simd/x86_64/jquanti-avx2.asm [4:7]
- simd/x86_64/jquanti-sse2.asm [4:6]
-
-KEEP COPYRIGHT_SERVICE_LABEL 6b27b02a83f5acbedf97e2af93f106ce
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: rdswitch.c at line 8
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- rdswitch.c [5:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL 6e387c76ad0c9566059a9f9d957682f1
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jversion.h [39:51]
-
-KEEP COPYRIGHT_SERVICE_LABEL 6eb2b24499a14d2c8a22f88b12735a09
-BELONGS ya.make
- License text:
- ; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- ; Copyright (C) 2016, 2018, D. R. Commander.
- ; Copyright (C) 2016, Matthieu Darbois.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- simd/i386/jquanti-avx2.asm [4:6]
-
-KEEP COPYRIGHT_SERVICE_LABEL 6eb3d0c5f735d6c9284f341dc1236bed
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdphuff.c at line 8
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jdphuff.c [5:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL 703a7a65a9b856b35aa7c7808a7287fc
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jquant1.c at line 8
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jquant1.c [5:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL 70c1e29ed3f2dcad843e598653327b67
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- simd/arm/aarch32/jsimd.c [4:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL 710c192b250d11a53da1e5f641633af5
-BELONGS ya.make
- License text:
- * Copyright (C) 2016, Siarhei Siamashka. All Rights Reserved.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- simd/arm/aarch64/jsimd_neon.S [11:11]
-
-KEEP COPYRIGHT_SERVICE_LABEL 73b8c8c41571d643184b1c9d911eca42
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdmaster.c at line 11
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jdmaster.c [5:12]
-
-KEEP COPYRIGHT_SERVICE_LABEL 742c1fe44d959285f890f38257b78a56
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- simd/arm/aarch64/jsimd.c [4:8]
-
-KEEP COPYRIGHT_SERVICE_LABEL 7620be1aff6ecbf9c6bdaeacf1b9cc57
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- rdgif.c [26:32]
-
-KEEP COPYRIGHT_SERVICE_LABEL 77086af1369f22e7eb3a40f2c5a423e9
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jcphuff.c at line 11, simd/i386/jcphuff-sse2.asm at line 10, simd/x86_64/jcphuff-sse2.asm at line 11
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jcphuff.c [5:12]
- simd/i386/jcphuff-sse2.asm [4:4]
- simd/x86_64/jcphuff-sse2.asm [5:5]
-
-KEEP COPYRIGHT_SERVICE_LABEL 7868e712d11159d5f95f6227307c9ea9
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jccolor.c at line 10, jcsample.c at line 10, jdsample.c at line 10
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jccolor.c [5:11]
- jcsample.c [5:11]
- jdsample.c [5:13]
-
-KEEP COPYRIGHT_SERVICE_LABEL 79ef6f7b35853561e461606aaf6f3d14
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jidctflt.c at line 9
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jidctflt.c [5:10]
-
-KEEP COPYRIGHT_SERVICE_LABEL 7e31d53b19f09cda635bcecb2051e38c
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: rdppm.c at line 9
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- rdppm.c [5:10]
-
-KEEP COPYRIGHT_SERVICE_LABEL 7e915a2a5af4ecd6601c584b49121ec7
-BELONGS ya.make
- License text:
- Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- LICENSE.md [95:95]
-
-KEEP COPYRIGHT_SERVICE_LABEL 804ebbe411e8d8ad599ecb18d89742e7
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jcdctmgr.c at line 10, jsimd.h at line 15, jsimd_none.c at line 15, jsimddct.h at line 12, simd/arm/aarch32/jsimd.c at line 17, simd/arm/aarch64/jsimd.c at line 16, simd/i386/jccolext-avx2.asm at line 13, simd/i386/jccolext-mmx.asm at line 13, simd/i386/jccolext-sse2.asm at line 12, simd/i386/jccolor-avx2.asm at line 13, simd/i386/jccolor-mmx.asm at line 13, simd/i386/jccolor-sse2.asm at line 12, simd/i386/jcgray-avx2.asm at line 13, simd/i386/jcgray-mmx.asm at line 13, simd/i386/jcgray-sse2.asm at line 12, simd/i386/jcgryext-avx2.asm at line 13, simd/i386/jcgryext-mmx.asm at line 13, simd/i386/jcgryext-sse2.asm at line 12, simd/i386/jchuff-sse2.asm at line 14, simd/i386/jcphuff-sse2.asm at line 12, simd/i386/jcsample-avx2.asm at line 14, simd/i386/jcsample-mmx.asm at line 13, simd/i386/jcsample-sse2.asm at line 13, simd/i386/jdcolext-avx2.asm at line 14, simd/i386/jdcolext-mmx.asm at line 13, simd/i386/jdcolext-sse2.asm at line 13, simd/i386/jdcolor-avx2.asm at line 14, simd/i386/jdcolor-mmx.asm at line 13, simd/i386/jdcolor-sse2.asm at line 13, simd/i386/jdmerge-avx2.asm at line 14, simd/i386/jdmerge-mmx.asm at line 13, simd/i386/jdmerge-sse2.asm at line 13, simd/i386/jdmrgext-avx2.asm at line 14, simd/i386/jdmrgext-mmx.asm at line 13, simd/i386/jdmrgext-sse2.asm at line 13, simd/i386/jdsample-avx2.asm at line 14, simd/i386/jdsample-mmx.asm at line 13, simd/i386/jdsample-sse2.asm at line 13, simd/i386/jfdctflt-3dn.asm at line 13, simd/i386/jfdctflt-sse.asm at line 13, simd/i386/jfdctfst-mmx.asm at line 13, simd/i386/jfdctfst-sse2.asm at line 13, simd/i386/jfdctint-avx2.asm at line 13, simd/i386/jfdctint-mmx.asm at line 13, simd/i386/jfdctint-sse2.asm at line 13, simd/i386/jidctflt-3dn.asm at line 13, simd/i386/jidctflt-sse.asm at line 13, simd/i386/jidctflt-sse2.asm at line 13, simd/i386/jidctfst-mmx.asm at line 13, simd/i386/jidctfst-sse2.asm at line 13, simd/i386/jidctint-avx2.asm at line 13, simd/i386/jidctint-mmx.asm at line 13, simd/i386/jidctint-sse2.asm at line 13, simd/i386/jidctred-mmx.asm at line 13, simd/i386/jidctred-sse2.asm at line 13, simd/i386/jquant-3dn.asm at line 13, simd/i386/jquant-mmx.asm at line 13, simd/i386/jquant-sse.asm at line 13, simd/i386/jquantf-sse2.asm at line 13, simd/i386/jquanti-avx2.asm at line 14, simd/i386/jquanti-sse2.asm at line 13, simd/i386/jsimd.c at line 14, simd/i386/jsimdcpu.asm at line 13, simd/jsimd.h at line 18, simd/nasm/jcolsamp.inc at line 13, simd/nasm/jdct.inc at line 13, simd/nasm/jsimdext.inc at line 16, simd/x86_64/jccolext-avx2.asm at line 14, simd/x86_64/jccolext-sse2.asm at line 13, simd/x86_64/jccolor-avx2.asm at line 13, simd/x86_64/jccolor-sse2.asm at line 12, simd/x86_64/jcgray-avx2.asm at line 13, simd/x86_64/jcgray-sse2.asm at line 12, simd/x86_64/jcgryext-avx2.asm at line 14, simd/x86_64/jcgryext-sse2.asm at line 13, simd/x86_64/jchuff-sse2.asm at line 14, simd/x86_64/jcphuff-sse2.asm at line 13, simd/x86_64/jcsample-avx2.asm at line 15, simd/x86_64/jcsample-sse2.asm at line 14, simd/x86_64/jdcolext-avx2.asm at line 15, simd/x86_64/jdcolext-sse2.asm at line 14, simd/x86_64/jdcolor-avx2.asm at line 14, simd/x86_64/jdcolor-sse2.asm at line 13, simd/x86_64/jdmerge-avx2.asm at line 14, simd/x86_64/jdmerge-sse2.asm at line 13, simd/x86_64/jdmrgext-avx2.asm at line 15, simd/x86_64/jdmrgext-sse2.asm at line 14, simd/x86_64/jdsample-avx2.asm at line 15, simd/x86_64/jdsample-sse2.asm at line 14, simd/x86_64/jfdctflt-sse.asm at line 13, simd/x86_64/jfdctfst-sse2.asm at line 13, simd/x86_64/jfdctint-avx2.asm at line 13, simd/x86_64/jfdctint-sse2.asm at line 13, simd/x86_64/jidctflt-sse2.asm at line 14, simd/x86_64/jidctfst-sse2.asm at line 14, simd/x86_64/jidctint-avx2.asm at line 14, simd/x86_64/jidctint-sse2.asm at line 14, simd/x86_64/jidctred-sse2.asm at line 14, simd/x86_64/jquantf-sse2.asm at line 14, simd/x86_64/jquanti-avx2.asm at line 15, simd/x86_64/jquanti-sse2.asm at line 14, simd/x86_64/jsimd.c at line 14, simd/x86_64/jsimdcpu.asm at line 14
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jcdctmgr.c [5:11]
- jsimd.h [10:11]
- jsimd_none.c [10:11]
- jsimddct.h [7:8]
- simd/arm/aarch32/jsimd.c [12:13]
- simd/arm/aarch64/jsimd.c [11:12]
- simd/i386/jccolext-avx2.asm [8:9]
- simd/i386/jccolext-mmx.asm [8:9]
- simd/i386/jccolext-sse2.asm [7:8]
- simd/i386/jccolor-avx2.asm [8:9]
- simd/i386/jccolor-mmx.asm [8:9]
- simd/i386/jccolor-sse2.asm [7:8]
- simd/i386/jcgray-avx2.asm [8:9]
- simd/i386/jcgray-mmx.asm [8:9]
- simd/i386/jcgray-sse2.asm [7:8]
- simd/i386/jcgryext-avx2.asm [8:9]
- simd/i386/jcgryext-mmx.asm [8:9]
- simd/i386/jcgryext-sse2.asm [7:8]
- simd/i386/jchuff-sse2.asm [9:10]
- simd/i386/jcphuff-sse2.asm [7:8]
- simd/i386/jcsample-avx2.asm [9:10]
- simd/i386/jcsample-mmx.asm [8:9]
- simd/i386/jcsample-sse2.asm [8:9]
- simd/i386/jdcolext-avx2.asm [9:10]
- simd/i386/jdcolext-mmx.asm [8:9]
- simd/i386/jdcolext-sse2.asm [8:9]
- simd/i386/jdcolor-avx2.asm [9:10]
- simd/i386/jdcolor-mmx.asm [8:9]
- simd/i386/jdcolor-sse2.asm [8:9]
- simd/i386/jdmerge-avx2.asm [9:10]
- simd/i386/jdmerge-mmx.asm [8:9]
- simd/i386/jdmerge-sse2.asm [8:9]
- simd/i386/jdmrgext-avx2.asm [9:10]
- simd/i386/jdmrgext-mmx.asm [8:9]
- simd/i386/jdmrgext-sse2.asm [8:9]
- simd/i386/jdsample-avx2.asm [9:10]
- simd/i386/jdsample-mmx.asm [8:9]
- simd/i386/jdsample-sse2.asm [8:9]
- simd/i386/jfdctflt-3dn.asm [8:9]
- simd/i386/jfdctflt-sse.asm [8:9]
- simd/i386/jfdctfst-mmx.asm [8:9]
- simd/i386/jfdctfst-sse2.asm [8:9]
- simd/i386/jfdctint-avx2.asm [8:9]
- simd/i386/jfdctint-mmx.asm [8:9]
- simd/i386/jfdctint-sse2.asm [8:9]
- simd/i386/jidctflt-3dn.asm [8:9]
- simd/i386/jidctflt-sse.asm [8:9]
- simd/i386/jidctflt-sse2.asm [8:9]
- simd/i386/jidctfst-mmx.asm [8:9]
- simd/i386/jidctfst-sse2.asm [8:9]
- simd/i386/jidctint-avx2.asm [8:9]
- simd/i386/jidctint-mmx.asm [8:9]
- simd/i386/jidctint-sse2.asm [8:9]
- simd/i386/jidctred-mmx.asm [8:9]
- simd/i386/jidctred-sse2.asm [8:9]
- simd/i386/jquant-3dn.asm [8:9]
- simd/i386/jquant-mmx.asm [8:9]
- simd/i386/jquant-sse.asm [8:9]
- simd/i386/jquantf-sse2.asm [8:9]
- simd/i386/jquanti-avx2.asm [9:10]
- simd/i386/jquanti-sse2.asm [8:9]
- simd/i386/jsimd.c [9:10]
- simd/i386/jsimdcpu.asm [8:9]
- simd/jsimd.h [13:14]
- simd/nasm/jcolsamp.inc [8:9]
- simd/nasm/jdct.inc [8:9]
- simd/nasm/jsimdext.inc [11:11]
- simd/x86_64/jccolext-avx2.asm [9:10]
- simd/x86_64/jccolext-sse2.asm [8:9]
- simd/x86_64/jccolor-avx2.asm [8:9]
- simd/x86_64/jccolor-sse2.asm [7:8]
- simd/x86_64/jcgray-avx2.asm [8:9]
- simd/x86_64/jcgray-sse2.asm [7:8]
- simd/x86_64/jcgryext-avx2.asm [9:10]
- simd/x86_64/jcgryext-sse2.asm [8:9]
- simd/x86_64/jchuff-sse2.asm [9:10]
- simd/x86_64/jcphuff-sse2.asm [8:9]
- simd/x86_64/jcsample-avx2.asm [10:11]
- simd/x86_64/jcsample-sse2.asm [9:10]
- simd/x86_64/jdcolext-avx2.asm [10:11]
- simd/x86_64/jdcolext-sse2.asm [9:10]
- simd/x86_64/jdcolor-avx2.asm [9:10]
- simd/x86_64/jdcolor-sse2.asm [8:9]
- simd/x86_64/jdmerge-avx2.asm [9:10]
- simd/x86_64/jdmerge-sse2.asm [8:9]
- simd/x86_64/jdmrgext-avx2.asm [10:11]
- simd/x86_64/jdmrgext-sse2.asm [9:10]
- simd/x86_64/jdsample-avx2.asm [10:11]
- simd/x86_64/jdsample-sse2.asm [9:10]
- simd/x86_64/jfdctflt-sse.asm [8:9]
- simd/x86_64/jfdctfst-sse2.asm [8:9]
- simd/x86_64/jfdctint-avx2.asm [8:9]
- simd/x86_64/jfdctint-sse2.asm [8:9]
- simd/x86_64/jidctflt-sse2.asm [9:10]
- simd/x86_64/jidctfst-sse2.asm [9:10]
- simd/x86_64/jidctint-avx2.asm [9:10]
- simd/x86_64/jidctint-sse2.asm [9:10]
- simd/x86_64/jidctred-sse2.asm [9:10]
- simd/x86_64/jquantf-sse2.asm [9:10]
- simd/x86_64/jquanti-avx2.asm [10:11]
- simd/x86_64/jquanti-sse2.asm [9:10]
- simd/x86_64/jsimd.c [9:10]
- simd/x86_64/jsimdcpu.asm [9:10]
-
-KEEP COPYRIGHT_SERVICE_LABEL 841a525ae27626ed264dbe00d00a50d9
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: wrgif.c at line 9
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- wrgif.c [5:10]
-
-KEEP COPYRIGHT_SERVICE_LABEL 8a887c76bccbc11714f8d4f377b95b34
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: cmyk.h at line 5, jmemnobs.c at line 6
- License text:
- * Copyright (C) 2017-2018, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- cmyk.h [4:6]
- jmemnobs.c [5:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL 8ec1376dfe31abfe479581e655244a78
-BELONGS ya.make
- License text:
- ; Copyright (C) 2009-2011, 2014-2016, 2019, 2021, D. R. Commander.
- ; Copyright (C) 2015, Matthieu Darbois.
- ; Copyright (C) 2018, Matthias Räncker.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- simd/x86_64/jchuff-sse2.asm [4:6]
-
-KEEP COPYRIGHT_SERVICE_LABEL 8ec859db1c818c3ffcdea4ac4c67cc71
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdcolext.c at line 8
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jdcolext.c [5:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL 9355530111ca8edfbad01e55c12ca46b
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: cdjpeg.c at line 8
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- cdjpeg.c [5:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL 9493f64c85084bcb6137535faf2ccf64
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jversion.h [39:51]
-
-KEEP COPYRIGHT_SERVICE_LABEL 950b3ffbdef23456bf92191ac52dde37
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jcsample.c at line 10
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jcsample.c [5:11]
-
-KEEP COPYRIGHT_SERVICE_LABEL 9c0396a7c7f9feca6c67ec7d838f5e6a
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jaricom.c at line 8
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jaricom.c [5:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL 9c62a8ffaa91ca3d9db9dd6ce8d27046
-BELONGS ya.make
- License text:
- ; Copyright (C) 2009-2011, 2014-2017, 2019, D. R. Commander.
- ; Copyright (C) 2015, Matthieu Darbois.
- ; Copyright (C) 2018, Matthias Räncker.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- simd/i386/jchuff-sse2.asm [4:6]
-
-KEEP COPYRIGHT_SERVICE_LABEL 9cdcdd341cb0968b2686cc191166f66d
-BELONGS ya.make
- License text:
- * Copyright (C)2021 Alex Richardson. All Rights Reserved.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- turbojpeg.c [3:3]
-
-KEEP COPYRIGHT_SERVICE_LABEL 9e8576d91d041270c2093c39ed8552e2
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jctrans.c at line 9
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jctrans.c [5:10]
-
-KEEP COPYRIGHT_SERVICE_LABEL a20f5da1eab75f941a731e130170bf39
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jccolext.c at line 8, jccolor.c at line 8
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jccolext.c [5:9]
- jccolor.c [5:11]
-
-KEEP COPYRIGHT_SERVICE_LABEL a2cad7c40e9595118b83ad65dafbcb1a
-BELONGS ya.make
- License text:
- * Copyright (C)2018 D. R. Commander. All Rights Reserved.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- md5/md5.h [3:3]
-
-KEEP COPYRIGHT_SERVICE_LABEL a445cd203767825e67800b0e187c4dcc
-BELONGS ya.make
- License text:
- * Author: Ragesh Radhakrishnan <ragesh.r@linaro.org>
- * Copyright (C) 2014-2016, 2020, D. R. Commander. All Rights Reserved.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- simd/arm/aarch64/jsimd_neon.S [8:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL a447aefd06b7c3fac740b17f813cc6e9
-BELONGS ya.make
- License text:
- This software is copyright (C) 1991-2020, Thomas G. Lane, Guido Vollbeding.
- All Rights Reserved except as specified below.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- README.ijg [131:132]
-
-KEEP COPYRIGHT_SERVICE_LABEL a700f333696ed15104933df52cf87650
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: wrbmp.c at line 9
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- wrbmp.c [5:10]
-
-KEEP COPYRIGHT_SERVICE_LABEL aa77cee5a8d8195aa2fa1f0fa5c1ebf2
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jversion.h [39:51]
-
-KEEP COPYRIGHT_SERVICE_LABEL aaa3eec797321b0f95bb1e9795f5f34e
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jpegcomp.h at line 5
- License text:
- * Copyright (C) 2010, 2020, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jpegcomp.h [4:6]
-
-KEEP COPYRIGHT_SERVICE_LABEL aacf1ca190af1314c3f58142073cff60
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdmerge.c at line 10
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jdmerge.c [5:11]
-
-KEEP COPYRIGHT_SERVICE_LABEL abf878d43b9b17d0a011b9f80bc0877b
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jctrans.c at line 9, simd/arm/aarch64/jchuff-neon.c at line 9
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jctrans.c [5:10]
- simd/arm/aarch64/jchuff-neon.c [5:5]
-
-KEEP COPYRIGHT_SERVICE_LABEL ac3e7a3bb6a2deb63101c7131904439b
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jddctmgr.c at line 11
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jddctmgr.c [5:12]
-
-KEEP COPYRIGHT_SERVICE_LABEL ada0032ea1af459292f235d45dd781ab
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jversion.h [39:51]
-
-KEEP COPYRIGHT_SERVICE_LABEL b03629274bce5be6f0f958bd8b73c07d
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdcoefct.c at line 10
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jdcoefct.c [5:11]
-
-KEEP COPYRIGHT_SERVICE_LABEL b0db1bfcd800910a02844b4274371034
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jmemmgr.c at line 8
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jmemmgr.c [5:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL b3b7c4fd496ec8e05dd719ced067a03d
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: cjpeg.c at line 9
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- cjpeg.c [5:10]
-
-KEEP COPYRIGHT_SERVICE_LABEL b3e70f7a6097bfd26df9355302310ed6
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jversion.h [39:51]
-
-KEEP COPYRIGHT_SERVICE_LABEL b410f4fd6c5f864842fda8c62b52df9d
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdsample.c at line 12
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jdsample.c [5:13]
-
-KEEP COPYRIGHT_SERVICE_LABEL b441984d0e96238fe18b18f11ab30548
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- simd/arm/aarch32/jsimd.c [4:9]
- simd/arm/aarch64/jsimd.c [4:8]
-
-KEEP COPYRIGHT_SERVICE_LABEL b4629da5b909ea766e7b89c13fbf25c3
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: wrtarga.c at line 8
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- wrtarga.c [5:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL b46db839fb63c2710a25a86daad4bb99
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jversion.h [39:51]
-
-KEEP COPYRIGHT_SERVICE_LABEL b6850ac833f644f5afb115dc21780dba
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- simd/arm/aarch32/jsimd.c [4:9]
- simd/i386/jsimd.c [4:6]
-
-KEEP COPYRIGHT_SERVICE_LABEL badd6e1fefe09e0efd808152660be992
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jstdhuff.c at line 8
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jstdhuff.c [5:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL bd72d4f6ff636a488895c66e5498d9e4
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- simd/arm/aarch32/jsimd_neon.S [8:8]
- simd/jsimd.h [4:10]
-
-KEEP COPYRIGHT_SERVICE_LABEL c045da8003fea9b4c2d930832f2d1afc
-BELONGS ya.make
- License text:
- ; Copyright (C) 2009, 2016, D. R. Commander.
- ; Copyright (C) 2015, Intel Corporation.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- simd/i386/jccolor-avx2.asm [4:5]
- simd/i386/jccolor-mmx.asm [4:5]
- simd/i386/jccolor-sse2.asm [4:4]
- simd/i386/jdcolor-mmx.asm [4:5]
- simd/i386/jdcolor-sse2.asm [4:5]
- simd/i386/jdmerge-avx2.asm [4:6]
- simd/i386/jdmerge-mmx.asm [4:5]
- simd/i386/jdmerge-sse2.asm [4:5]
- simd/x86_64/jccolext-avx2.asm [4:6]
- simd/x86_64/jccolext-sse2.asm [4:5]
- simd/x86_64/jccolor-avx2.asm [4:5]
- simd/x86_64/jccolor-sse2.asm [4:4]
- simd/x86_64/jcsample-avx2.asm [4:7]
- simd/x86_64/jcsample-sse2.asm [4:6]
- simd/x86_64/jdcolor-avx2.asm [4:6]
- simd/x86_64/jdcolor-sse2.asm [4:5]
- simd/x86_64/jdmerge-avx2.asm [4:6]
- simd/x86_64/jdmerge-sse2.asm [4:5]
- simd/x86_64/jdsample-avx2.asm [4:7]
- simd/x86_64/jdsample-sse2.asm [4:6]
- simd/x86_64/jfdctflt-sse.asm [4:5]
- simd/x86_64/jfdctfst-sse2.asm [4:5]
- simd/x86_64/jidctflt-sse2.asm [4:6]
- simd/x86_64/jidctfst-sse2.asm [4:6]
- simd/x86_64/jidctred-sse2.asm [4:6]
- simd/x86_64/jquantf-sse2.asm [4:6]
- simd/x86_64/jquanti-sse2.asm [4:6]
-
-KEEP COPYRIGHT_SERVICE_LABEL c7de5e9b8afc872ee77656f5bafcf523
-BELONGS ya.make
- License text:
- * Copyright (C)2009-2014, 2017-2019, 2022 D. R. Commander.
- * All Rights Reserved.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- tjunittest.c [2:3]
-
-KEEP COPYRIGHT_SERVICE_LABEL c9e55c94ede47423b60bd1b0381f63a3
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jcicc.c at line 6, jdicc.c at line 6
- License text:
- * Copyright (C) 1997-1998, Thomas G. Lane, Todd Newman.
- * Copyright (C) 2017, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jcicc.c [4:7]
- jdicc.c [4:7]
-
-KEEP COPYRIGHT_SERVICE_LABEL caa45dec4c6ae6a1395050b3920a6223
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jmorecfg.h at line 9
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jmorecfg.h [5:10]
-
-KEEP COPYRIGHT_SERVICE_LABEL cca2e965350198f9e77d99a7186169c6
-BELONGS ya.make
- License text:
- * Copyright (C)2011, 2022 D. R. Commander. All Rights Reserved.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- tjutil.h [2:2]
-
-KEEP COPYRIGHT_SERVICE_LABEL cd2a60027b7103634f7daee878afa300
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jversion.h [39:51]
-
-KEEP COPYRIGHT_SERVICE_LABEL cd5311d9588f1f80a8f857322ae710df
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jversion.h [39:51]
-
-KEEP COPYRIGHT_SERVICE_LABEL cf6108444471809417e1ff2e1ff10c66
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jcapimin.c at line 9, jdapimin.c at line 9, jidctflt.c at line 9, jidctfst.c at line 9, jidctred.c at line 9
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jcapimin.c [5:10]
- jdapimin.c [5:9]
- jidctflt.c [5:10]
- jidctfst.c [5:9]
- jidctred.c [5:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL cf74f8592696addc8b7f018fef34b4a3
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdatadst.c at line 9, jdatasrc.c at line 9
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jdatadst.c [5:10]
- jdatasrc.c [5:10]
-
-KEEP COPYRIGHT_SERVICE_LABEL d0282fea7b77a6dc36ff090a1ac5d3f4
-BELONGS ya.make
- License text:
- ** Copyright (C) 1988 by Jef Poskanzer.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- rdcolmap.c [31:31]
- rdppm.c [33:33]
-
-KEEP COPYRIGHT_SERVICE_LABEL d0fc83990d55b2f4c8030d020a836049
-BELONGS ya.make
- License text:
- ; Copyright (C) 2015, Intel Corporation.
- ; Copyright (C) 2016, D. R. Commander.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- simd/i386/jccolext-avx2.asm [4:5]
- simd/i386/jccolext-mmx.asm [4:5]
- simd/i386/jccolext-sse2.asm [4:4]
- simd/i386/jcsample-avx2.asm [4:6]
- simd/i386/jcsample-mmx.asm [4:5]
- simd/i386/jcsample-sse2.asm [4:5]
- simd/i386/jdcolext-mmx.asm [4:5]
- simd/i386/jdcolor-avx2.asm [4:6]
- simd/i386/jdmrgext-mmx.asm [4:5]
- simd/i386/jdsample-avx2.asm [4:6]
- simd/i386/jdsample-mmx.asm [4:5]
- simd/i386/jdsample-sse2.asm [4:5]
- simd/i386/jfdctflt-3dn.asm [4:5]
- simd/i386/jfdctflt-sse.asm [4:5]
- simd/i386/jfdctfst-mmx.asm [4:5]
- simd/i386/jfdctfst-sse2.asm [4:5]
- simd/i386/jidctflt-3dn.asm [4:5]
- simd/i386/jidctflt-sse.asm [4:5]
- simd/i386/jidctflt-sse2.asm [4:5]
- simd/i386/jidctfst-mmx.asm [4:5]
- simd/i386/jidctfst-sse2.asm [4:5]
- simd/i386/jidctred-mmx.asm [4:5]
- simd/i386/jidctred-sse2.asm [4:5]
- simd/i386/jquant-3dn.asm [4:5]
- simd/i386/jquant-mmx.asm [4:5]
- simd/i386/jquant-sse.asm [4:5]
- simd/i386/jquantf-sse2.asm [4:5]
- simd/i386/jquanti-sse2.asm [4:5]
- simd/i386/jsimdcpu.asm [4:5]
- simd/x86_64/jsimdcpu.asm [4:5]
-
-KEEP COPYRIGHT_SERVICE_LABEL d5fdb3ce18ba6b39a74ec7cea4de37ab
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdsample.c at line 12
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jdsample.c [5:13]
-
-KEEP COPYRIGHT_SERVICE_LABEL d6496c342f8b2770becfe0cd5be87a4e
-BELONGS ya.make
- License text:
- ; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- ; Copyright (C) 2010, 2016, 2018-2019, D. R. Commander.
- ; Copyright (C) 2018, Matthieu Darbois.
- ; Copyright (C) 2018, Matthias Räncker.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- simd/nasm/jsimdext.inc [4:7]
-
-KEEP COPYRIGHT_SERVICE_LABEL d74e6a7613a45e0d47d696d49409e0de
-BELONGS ya.make
- License text:
- * Author: Siarhei Siamashka <siarhei.siamashka@nokia.com>
- * Copyright (C) 2014, Siarhei Siamashka. All Rights Reserved.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- simd/arm/aarch32/jsimd_neon.S [6:7]
-
-KEEP COPYRIGHT_SERVICE_LABEL d790272c7994ded60847851f8d898fd3
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdcol565.c at line 9, jdcolor.c at line 9, jdmaster.c at line 9, jdmerge.c at line 9, jdmrg565.c at line 9, wrbmp.c at line 9
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jdcol565.c [5:10]
- jdcolor.c [5:12]
- jdmaster.c [5:12]
- jdmerge.c [5:11]
- jdmrg565.c [5:10]
- wrbmp.c [5:10]
-
-KEEP COPYRIGHT_SERVICE_LABEL d7bcb9862eed9e8b3be25e9b9c3c4ee1
-BELONGS ya.make
- License text:
- ; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- ; Copyright (C) 2016, 2020, D. R. Commander.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- simd/i386/jfdctint-mmx.asm [4:5]
- simd/i386/jfdctint-sse2.asm [4:5]
- simd/i386/jidctint-mmx.asm [4:5]
- simd/i386/jidctint-sse2.asm [4:5]
-
-KEEP COPYRIGHT_SERVICE_LABEL d7cbc4888488ae9309e299e88d442551
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jversion.h [39:51]
-
-KEEP COPYRIGHT_SERVICE_LABEL d8571b0bd95f27ba489c62714ff09a44
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdatasrc-tj.c at line 9
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jdatasrc-tj.c [5:10]
-
-KEEP COPYRIGHT_SERVICE_LABEL dd41d14be2162054f1b10aa961d71da7
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jpeglib.h at line 10
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jpeglib.h [5:11]
-
-KEEP COPYRIGHT_SERVICE_LABEL e151cf32655a7d62804025b92dc0da5a
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jsimd_none.c [4:7]
-
-KEEP COPYRIGHT_SERVICE_LABEL e395a64659058a5d7d2f78850dd6d40f
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jversion.h at line 8
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jversion.h [5:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL e6ec6317701aca001fa77e6537f8c99d
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: transupp.c at line 8
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- transupp.c [5:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL ea6ca264cbf0bd46b9c85409e9a6108b
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: transupp.h at line 8
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- transupp.h [5:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL eb22a1dc175d45a0ad730840e22ed3b4
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jccolor.c at line 10, jcdctmgr.c at line 10, jcsample.c at line 10, jdcoefct.c at line 10, jdcoefct.h at line 10, jdcolor.c at line 10, jddctmgr.c at line 10, jdmerge.c at line 10, jdsample.c at line 10, jsimd.h at line 9, jsimd_none.c at line 9, jsimddct.h at line 9, simd/arm/aarch32/jsimd.c at line 9, simd/arm/aarch64/jsimd.c at line 9, simd/i386/jccolext-mmx.asm at line 9, simd/i386/jccolor-mmx.asm at line 9, simd/i386/jcgray-mmx.asm at line 9, simd/i386/jcgryext-mmx.asm at line 9, simd/i386/jcsample-avx2.asm at line 9, simd/i386/jcsample-mmx.asm at line 9, simd/i386/jcsample-sse2.asm at line 9, simd/i386/jdcolext-mmx.asm at line 9, simd/i386/jdcolor-avx2.asm at line 9, simd/i386/jdcolor-mmx.asm at line 9, simd/i386/jdcolor-sse2.asm at line 9, simd/i386/jdmerge-avx2.asm at line 9, simd/i386/jdmerge-mmx.asm at line 9, simd/i386/jdmerge-sse2.asm at line 9, simd/i386/jdmrgext-mmx.asm at line 9, simd/i386/jdsample-avx2.asm at line 9, simd/i386/jdsample-mmx.asm at line 9, simd/i386/jdsample-sse2.asm at line 9, simd/i386/jfdctflt-3dn.asm at line 9, simd/i386/jfdctflt-sse.asm at line 9, simd/i386/jfdctfst-mmx.asm at line 9, simd/i386/jfdctfst-sse2.asm at line 9, simd/i386/jfdctint-avx2.asm at line 9, simd/i386/jfdctint-mmx.asm at line 9, simd/i386/jfdctint-sse2.asm at line 9, simd/i386/jidctflt-3dn.asm at line 9, simd/i386/jidctflt-sse.asm at line 9, simd/i386/jidctflt-sse2.asm at line 9, simd/i386/jidctfst-mmx.asm at line 9, simd/i386/jidctfst-sse2.asm at line 9, simd/i386/jidctint-avx2.asm at line 9, simd/i386/jidctint-mmx.asm at line 9, simd/i386/jidctint-sse2.asm at line 9, simd/i386/jidctred-mmx.asm at line 9, simd/i386/jidctred-sse2.asm at line 9, simd/i386/jquant-3dn.asm at line 9, simd/i386/jquant-mmx.asm at line 9, simd/i386/jquant-sse.asm at line 9, simd/i386/jquantf-sse2.asm at line 9, simd/i386/jquanti-avx2.asm at line 9, simd/i386/jquanti-sse2.asm at line 9, simd/i386/jsimd.c at line 9, simd/i386/jsimdcpu.asm at line 9, simd/jsimd.h at line 9, simd/nasm/jcolsamp.inc at line 9, simd/nasm/jdct.inc at line 9, simd/nasm/jsimdext.inc at line 9, simd/x86_64/jcsample-avx2.asm at line 9, simd/x86_64/jcsample-sse2.asm at line 9, simd/x86_64/jdcolor-avx2.asm at line 9, simd/x86_64/jdcolor-sse2.asm at line 9, simd/x86_64/jdmerge-avx2.asm at line 9, simd/x86_64/jdmerge-sse2.asm at line 9, simd/x86_64/jdsample-avx2.asm at line 9, simd/x86_64/jdsample-sse2.asm at line 9, simd/x86_64/jfdctflt-sse.asm at line 9, simd/x86_64/jfdctfst-sse2.asm at line 9, simd/x86_64/jfdctint-avx2.asm at line 9, simd/x86_64/jfdctint-sse2.asm at line 9, simd/x86_64/jidctflt-sse2.asm at line 9, simd/x86_64/jidctfst-sse2.asm at line 9, simd/x86_64/jidctint-avx2.asm at line 9, simd/x86_64/jidctint-sse2.asm at line 9, simd/x86_64/jidctred-sse2.asm at line 9, simd/x86_64/jquantf-sse2.asm at line 9, simd/x86_64/jquanti-avx2.asm at line 9, simd/x86_64/jquanti-sse2.asm at line 9, simd/x86_64/jsimd.c at line 9, simd/x86_64/jsimdcpu.asm at line 9
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jccolor.c [5:11]
- jcdctmgr.c [5:11]
- jcsample.c [5:11]
- jdcoefct.c [5:11]
- jdcoefct.h [5:10]
- jdcolor.c [5:12]
- jddctmgr.c [5:12]
- jdmerge.c [5:11]
- jdsample.c [5:13]
- jsimd.h [4:7]
- jsimd_none.c [4:7]
- jsimddct.h [4:4]
- simd/arm/aarch32/jsimd.c [4:9]
- simd/arm/aarch64/jsimd.c [4:8]
- simd/i386/jccolext-mmx.asm [4:5]
- simd/i386/jccolor-mmx.asm [4:5]
- simd/i386/jcgray-mmx.asm [4:5]
- simd/i386/jcgryext-mmx.asm [4:5]
- simd/i386/jcsample-avx2.asm [4:6]
- simd/i386/jcsample-mmx.asm [4:5]
- simd/i386/jcsample-sse2.asm [4:5]
- simd/i386/jdcolext-mmx.asm [4:5]
- simd/i386/jdcolor-avx2.asm [4:6]
- simd/i386/jdcolor-mmx.asm [4:5]
- simd/i386/jdcolor-sse2.asm [4:5]
- simd/i386/jdmerge-avx2.asm [4:6]
- simd/i386/jdmerge-mmx.asm [4:5]
- simd/i386/jdmerge-sse2.asm [4:5]
- simd/i386/jdmrgext-mmx.asm [4:5]
- simd/i386/jdsample-avx2.asm [4:6]
- simd/i386/jdsample-mmx.asm [4:5]
- simd/i386/jdsample-sse2.asm [4:5]
- simd/i386/jfdctflt-3dn.asm [4:5]
- simd/i386/jfdctflt-sse.asm [4:5]
- simd/i386/jfdctfst-mmx.asm [4:5]
- simd/i386/jfdctfst-sse2.asm [4:5]
- simd/i386/jfdctint-avx2.asm [4:5]
- simd/i386/jfdctint-mmx.asm [4:5]
- simd/i386/jfdctint-sse2.asm [4:5]
- simd/i386/jidctflt-3dn.asm [4:5]
- simd/i386/jidctflt-sse.asm [4:5]
- simd/i386/jidctflt-sse2.asm [4:5]
- simd/i386/jidctfst-mmx.asm [4:5]
- simd/i386/jidctfst-sse2.asm [4:5]
- simd/i386/jidctint-avx2.asm [4:5]
- simd/i386/jidctint-mmx.asm [4:5]
- simd/i386/jidctint-sse2.asm [4:5]
- simd/i386/jidctred-mmx.asm [4:5]
- simd/i386/jidctred-sse2.asm [4:5]
- simd/i386/jquant-3dn.asm [4:5]
- simd/i386/jquant-mmx.asm [4:5]
- simd/i386/jquant-sse.asm [4:5]
- simd/i386/jquantf-sse2.asm [4:5]
- simd/i386/jquanti-avx2.asm [4:6]
- simd/i386/jquanti-sse2.asm [4:5]
- simd/i386/jsimd.c [4:6]
- simd/i386/jsimdcpu.asm [4:5]
- simd/jsimd.h [4:10]
- simd/nasm/jcolsamp.inc [4:5]
- simd/nasm/jdct.inc [4:5]
- simd/nasm/jsimdext.inc [4:7]
- simd/x86_64/jcsample-avx2.asm [4:7]
- simd/x86_64/jcsample-sse2.asm [4:6]
- simd/x86_64/jdcolor-avx2.asm [4:6]
- simd/x86_64/jdcolor-sse2.asm [4:5]
- simd/x86_64/jdmerge-avx2.asm [4:6]
- simd/x86_64/jdmerge-sse2.asm [4:5]
- simd/x86_64/jdsample-avx2.asm [4:7]
- simd/x86_64/jdsample-sse2.asm [4:6]
- simd/x86_64/jfdctflt-sse.asm [4:5]
- simd/x86_64/jfdctfst-sse2.asm [4:5]
- simd/x86_64/jfdctint-avx2.asm [4:5]
- simd/x86_64/jfdctint-sse2.asm [4:5]
- simd/x86_64/jidctflt-sse2.asm [4:6]
- simd/x86_64/jidctfst-sse2.asm [4:6]
- simd/x86_64/jidctint-avx2.asm [4:6]
- simd/x86_64/jidctint-sse2.asm [4:6]
- simd/x86_64/jidctred-sse2.asm [4:6]
- simd/x86_64/jquantf-sse2.asm [4:6]
- simd/x86_64/jquanti-avx2.asm [4:7]
- simd/x86_64/jquanti-sse2.asm [4:6]
- simd/x86_64/jsimd.c [4:6]
- simd/x86_64/jsimdcpu.asm [4:5]
-
-KEEP COPYRIGHT_SERVICE_LABEL ec0537a229e1880f54c1d10e8cd723c3
-BELONGS ya.make
- License text:
- ; Copyright (C) 2015, Intel Corporation.
- ; Copyright (C) 2016, D. R. Commander.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- simd/i386/jccolext-avx2.asm [4:5]
- simd/i386/jccolor-avx2.asm [4:5]
- simd/i386/jcgray-avx2.asm [4:5]
- simd/i386/jcgryext-avx2.asm [4:5]
- simd/i386/jcsample-avx2.asm [4:6]
- simd/i386/jdcolext-avx2.asm [4:6]
- simd/i386/jdcolor-avx2.asm [4:6]
- simd/i386/jdmerge-avx2.asm [4:6]
- simd/i386/jdmrgext-avx2.asm [4:6]
- simd/i386/jdsample-avx2.asm [4:6]
- simd/nasm/jcolsamp.inc [4:5]
- simd/x86_64/jccolext-avx2.asm [4:6]
- simd/x86_64/jccolor-avx2.asm [4:5]
- simd/x86_64/jcgray-avx2.asm [4:5]
- simd/x86_64/jcgryext-avx2.asm [4:6]
- simd/x86_64/jcsample-avx2.asm [4:7]
- simd/x86_64/jdcolext-avx2.asm [4:7]
- simd/x86_64/jdcolor-avx2.asm [4:6]
- simd/x86_64/jdmerge-avx2.asm [4:6]
- simd/x86_64/jdmrgext-avx2.asm [4:7]
- simd/x86_64/jdsample-avx2.asm [4:7]
-
-KEEP COPYRIGHT_SERVICE_LABEL ec07749745840029e5c8b2f2f7870201
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdct.h at line 8, jfdctfst.c at line 8, jidctfst.c at line 8, jidctred.c at line 8, simd/arm/aarch32/jsimd_neon.S at line 12
- License text:
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2015, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jdct.h [5:9]
- jfdctfst.c [5:9]
- jidctfst.c [5:9]
- jidctred.c [5:9]
- simd/arm/aarch32/jsimd_neon.S [9:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL ec986a301f4f1cd97fd36cfe73b186b7
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jcdctmgr.c at line 10
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jcdctmgr.c [5:11]
-
-KEEP COPYRIGHT_SERVICE_LABEL ef292409cf51b45110665ff46607bac2
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- wrgif.c [21:30]
-
-KEEP COPYRIGHT_SERVICE_LABEL f3ec844f0de8ce7cc9534e740161ff67
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jcmaster.c at line 9
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jcmaster.c [5:10]
-
-KEEP COPYRIGHT_SERVICE_LABEL f45beec025a14f11290ad8d8146e8b44
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jcphuff.c at line 11
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jcphuff.c [5:12]
-
-KEEP COPYRIGHT_SERVICE_LABEL f4d6b1166506be518b06a0d3ff4fb5a3
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: cdjpeg.c at line 8, djpeg.c at line 8, jchuff.c at line 8, jchuff.h at line 8, jcinit.c at line 8, jcmaster.c at line 8, jdcol565.c at line 8, jdcolext.c at line 8, jdcolor.c at line 8, jdhuff.c at line 8, jdhuff.h at line 8, jdinput.c at line 8, jdmaster.c at line 8, jmemmgr.c at line 8, jmorecfg.h at line 8, jpegint.h at line 8, rdgif.c at line 8, rdppm.c at line 8, simd/arm/jchuff.h at line 8, wrgif.c at line 8
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- cdjpeg.c [5:9]
- djpeg.c [5:11]
- jchuff.c [5:12]
- jchuff.h [5:8]
- jcinit.c [5:9]
- jcmaster.c [5:10]
- jdcol565.c [5:10]
- jdcolext.c [5:9]
- jdcolor.c [5:12]
- jdhuff.c [5:10]
- jdhuff.h [5:10]
- jdinput.c [5:10]
- jdmaster.c [5:12]
- jmemmgr.c [5:9]
- jmorecfg.h [5:10]
- jpegint.h [5:12]
- rdgif.c [5:10]
- rdppm.c [5:10]
- simd/arm/jchuff.h [5:11]
- wrgif.c [5:10]
-
-KEEP COPYRIGHT_SERVICE_LABEL f992ae275ee011ff1e8c9f49c3ce89da
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jcapistd.c at line 6, jcdctmgr.c at line 7, jcmainct.c at line 7, jcprepct.c at line 7, jdapistd.c at line 7, jdatadst-tj.c at line 7, jdatadst.c at line 7, jdatasrc-tj.c at line 7, jdatasrc.c at line 7, jdct.h at line 7, jddctmgr.c at line 7, jdmainct.c at line 7, jdmainct.h at line 7, jdmerge.c at line 7, jdmerge.h at line 7, jdmrg565.c at line 7, jdmrgext.c at line 7, jdpostct.c at line 7, jfdctflt.c at line 6, jfdctfst.c at line 7, rdbmp.c at line 7, rdcolmap.c at line 6, wrbmp.c at line 7
- License text:
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * This file is part of the Independent JPEG Group's software.
- * For conditions of distribution and use, see the accompanying README.ijg
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jcapistd.c [4:6]
- jcdctmgr.c [5:11]
- jcmainct.c [5:8]
- jcprepct.c [5:9]
- jdapistd.c [5:10]
- jdatadst-tj.c [5:10]
- jdatadst.c [5:10]
- jdatasrc-tj.c [5:10]
- jdatasrc.c [5:10]
- jdct.h [5:9]
- jddctmgr.c [5:12]
- jdmainct.c [5:9]
- jdmainct.h [5:7]
- jdmerge.c [5:11]
- jdmerge.h [5:9]
- jdmrg565.c [5:10]
- jdmrgext.c [5:9]
- jdpostct.c [5:8]
- jfdctflt.c [4:6]
- jfdctfst.c [5:9]
- rdbmp.c [5:11]
- rdcolmap.c [4:6]
- wrbmp.c [5:10]
-
-KEEP COPYRIGHT_SERVICE_LABEL fb1969d8022279f91786a49876542048
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jcphuff.c at line 11, jpegint.h at line 11
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jcphuff.c [5:12]
- jpegint.h [5:12]
-
-KEEP COPYRIGHT_SERVICE_LABEL ff4f68c38d54f4ee28ddb06f4c22e5e5
-BELONGS ya.make
- License text:
- * Copyright (C)2018, D. R. Commander. All Rights Reserved.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- md5/md5.c [18:18]
- simd/nasm/jdct.inc [4:5]
diff --git a/contrib/libs/libjpeg-turbo/.yandex_meta/devtools.licenses.report b/contrib/libs/libjpeg-turbo/.yandex_meta/devtools.licenses.report
deleted file mode 100644
index 5de2d998a7..0000000000
--- a/contrib/libs/libjpeg-turbo/.yandex_meta/devtools.licenses.report
+++ /dev/null
@@ -1,786 +0,0 @@
-# File format ($ symbol means the beginning of a line):
-#
-# $ # this message
-# $ # =======================
-# $ # comments (all commentaries should starts with some number of spaces and # symbol)
-# ${action} {license spdx} {license text hash}
-# $BELONGS ./ya/make/file/relative/path/1/ya.make ./ya/make/2/ya.make
-# ${all_file_action} filename
-# $ # user commentaries (many lines)
-# $ generated description - files with this license, license text... (some number of lines that starts with some number of spaces, do not modify)
-# ${action} {license spdx} {license text hash}
-# $BELONGS ./ya/make/file/relative/path/3/ya.make
-# ${all_file_action} filename
-# $ # user commentaries
-# $ generated description
-# $ ...
-#
-# You can modify action, all_file_action and add commentaries
-# Available actions:
-# keep - keep license in contrib and use in credits
-# skip - skip license
-# remove - remove all files with this license
-# rename - save license text/links into licenses texts file, but not store SPDX into LINCENSE macro. You should store correct license id into devtools.license.spdx.txt file
-#
-# {all file action} records will be generated when license text contains filename that exists on filesystem (in contrib directory)
-# We suppose that that files can contain some license info
-# Available all file actions:
-# FILE_IGNORE - ignore file (do nothing)
-# FILE_INCLUDE - include all file data into licenses text file
-# =======================
-
-SKIP Zlib 0b2c2142ae5163b2338d3444a664a4d2
-BELONGS ya.make
-FILE_IGNORE simd/nasm/jsimdext.inc found in files: jsimd.h at line 11, jsimd_none.c at line 11, jsimddct.h at line 8, simd/arm/aarch32/jsimd.c at line 13, simd/arm/aarch64/jsimd.c at line 12, simd/i386/jsimd.c at line 10, simd/jsimd.h at line 14, simd/x86_64/jsimd.c at line 10
- License text:
- * For conditions of distribution and use, see copyright notice in jsimdext.inc
- Scancode info:
- Original SPDX id: Zlib
- Score : 100.00
- Match type : REFERENCE
- Links : http://www.gzip.org/zlib/zlib_license.html, http://www.zlib.net/, https://spdx.org/licenses/Zlib
- Files with this license:
- jsimd.h [11:11]
- jsimd_none.c [11:11]
- jsimddct.h [8:8]
- simd/arm/aarch32/jsimd.c [13:13]
- simd/arm/aarch64/jsimd.c [12:12]
- simd/i386/jsimd.c [10:10]
- simd/jsimd.h [14:14]
- simd/x86_64/jsimd.c [10:10]
-
-KEEP BSD-3-Clause 11d698b5bde51c49edd95b88f640964c
-BELONGS ya.make
- License text:
- libjpeg-turbo is covered by three compatible BSD-style open source licenses.
- Scancode info:
- Original SPDX id: BSD-3-Clause
- Score : 90.00
- Match type : REFERENCE
- Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
- Files with this license:
- README.md [30:30]
-
-KEEP Zlib 1661ad60dffa54137d6416dfd7689e04
-BELONGS ya.make
- License text:
- - Clause 2 of the zlib License
- Scancode info:
- Original SPDX id: Zlib
- Score : 100.00
- Match type : REFERENCE
- Links : http://www.gzip.org/zlib/zlib_license.html, http://www.zlib.net/, https://spdx.org/licenses/Zlib
- Files with this license:
- LICENSE.md [47:47]
-
-KEEP BSD-3-Clause 215800e23d49e25c39ec19c06b3a4b7e
-BELONGS ya.make
- License text:
- - The Modified (3-clause) BSD License, which is listed below
- Scancode info:
- Original SPDX id: BSD-3-Clause
- Score : 100.00
- Match type : REFERENCE
- Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
- Files with this license:
- LICENSE.md [12:12]
-
-KEEP BSD-3-Clause 23f26458908411db285fd7e9618d0400
-BELONGS ya.make
- License text:
- - Clause 1 of the Modified BSD License
- Scancode info:
- Original SPDX id: BSD-3-Clause
- Score : 99.00
- Match type : REFERENCE
- Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
- Files with this license:
- LICENSE.md [37:37]
-
-KEEP BSD-3-Clause 2493102f4ead68ded4257981325eec7a
-BELONGS ya.make
- License text:
- libjpeg-turbo is covered by three compatible BSD-style open source licenses:
- Scancode info:
- Original SPDX id: BSD-3-Clause
- Score : 90.00
- Match type : REFERENCE
- Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
- Files with this license:
- LICENSE.md [4:4]
-
-KEEP BSD-3-Clause 2795fc0c0a7bc60174daf8e80fd02db8
-BELONGS ya.make
- License text:
- - IJG License
- - Modified BSD License
- Scancode info:
- Original SPDX id: BSD-3-Clause
- Score : 16.00
- Match type : REFERENCE
- Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
- Files with this license:
- LICENSE.md [86:87]
-
-KEEP Public-Domain 3845d6ef049b415f8f54f4d7e362f22e
-BELONGS ya.make
- License text:
- * The algorithm is due to Ron Rivest. This code was
- * written by Colin Plumb in 1993, no copyright is claimed.
- * This code is in the public domain; do with it what you wish.
- Scancode info:
- Original SPDX id: LicenseRef-scancode-public-domain
- Score : 100.00
- Match type : TEXT
- Links : http://www.linfo.org/publicdomain.html, https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/public-domain.LICENSE
- Files with this license:
- md5/md5.c [3:5]
-
-KEEP BSD-3-Clause AND BSD-3-Clause 4694a148911c95fc84a45824e7b3c243
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: BSD-3-Clause
- Score : 99.53
- Match type : TEXT
- Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
- Files with this license:
- md5/md5.h [5:27]
- md5/md5hl.c [11:33]
- tjunittest.c [5:27]
- tjutil.c [4:26]
- tjutil.h [4:26]
- turbojpeg.c [5:27]
- turbojpeg.h [5:27]
- Scancode info:
- Original SPDX id: BSD-3-Clause
- Score : 98.60
- Match type : TEXT
- Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
- Files with this license:
- md5/md5.c [20:42]
-
-KEEP Zlib 49b2005eb74289158192a07e3d97f167
-BELONGS ya.make
- License text:
- - Clauses 1 and 3 of the zlib License
- Scancode info:
- Original SPDX id: Zlib
- Score : 100.00
- Match type : REFERENCE
- Links : http://www.gzip.org/zlib/zlib_license.html, http://www.zlib.net/, https://spdx.org/licenses/Zlib
- Files with this license:
- LICENSE.md [38:38]
-
-KEEP IJG 49f21ef3a9ec8414db54cb3989614ee3
-BELONGS ya.make
- License text:
- * This file was part of the Independent JPEG Group's software:
- Scancode info:
- Original SPDX id: IJG
- Score : 100.00
- Match type : NOTICE
- Links : http://fedoraproject.org/wiki/Licensing/IJG, https://spdx.org/licenses/IJG
- Files with this license:
- cderror.h [4:4]
- cdjpeg.c [4:4]
- cdjpeg.h [4:4]
- cjpeg.c [4:4]
- djpeg.c [4:4]
- jaricom.c [4:4]
- jcapimin.c [4:4]
- jcarith.c [4:4]
- jccoefct.c [4:4]
- jccolext.c [4:4]
- jccolor.c [4:4]
- jcdctmgr.c [4:4]
- jchuff.c [4:4]
- jchuff.h [4:4]
- jcinit.c [4:4]
- jcmainct.c [4:4]
- jcmarker.c [4:4]
- jcmaster.c [4:4]
- jcomapi.c [4:4]
- jcparam.c [4:4]
- jcphuff.c [4:4]
- jcsample.c [4:4]
- jctrans.c [4:4]
- jdapimin.c [4:4]
- jdapistd.c [4:4]
- jdarith.c [4:4]
- jdatadst-tj.c [4:4]
- jdatadst.c [4:4]
- jdatasrc-tj.c [4:4]
- jdatasrc.c [4:4]
- jdcoefct.c [4:4]
- jdcoefct.h [4:4]
- jdcol565.c [4:4]
- jdcolext.c [4:4]
- jdcolor.c [4:4]
- jdct.h [4:4]
- jddctmgr.c [4:4]
- jdhuff.c [4:4]
- jdhuff.h [4:4]
- jdinput.c [4:4]
- jdmainct.c [4:4]
- jdmainct.h [4:4]
- jdmarker.c [4:4]
- jdmaster.c [4:4]
- jdmaster.h [4:4]
- jdmerge.c [4:4]
- jdmerge.h [4:4]
- jdmrg565.c [4:4]
- jdmrgext.c [4:4]
- jdphuff.c [4:4]
- jdpostct.c [4:4]
- jdsample.c [4:4]
- jdsample.h [4:4]
- jdtrans.c [4:4]
- jerror.c [4:4]
- jerror.h [4:4]
- jfdctfst.c [4:4]
- jfdctint.c [4:4]
- jidctflt.c [4:4]
- jidctfst.c [4:4]
- jidctint.c [4:4]
- jidctred.c [4:4]
- jinclude.h [4:4]
- jmemmgr.c [4:4]
- jmemnobs.c [4:4]
- jmemsys.h [4:4]
- jmorecfg.h [4:4]
- jpegint.h [4:4]
- jpeglib.h [4:4]
- jpegtran.c [4:4]
- jquant1.c [4:4]
- jquant2.c [4:4]
- jstdhuff.c [4:4]
- jutils.c [4:4]
- jversion.h [4:4]
- rdbmp.c [4:4]
- rdgif.c [4:4]
- rdppm.c [4:4]
- rdswitch.c [4:4]
- rdtarga.c [4:4]
- simd/arm/jchuff.h [4:4]
- transupp.c [4:4]
- transupp.h [4:4]
- wrbmp.c [4:4]
- wrgif.c [4:4]
- wrppm.c [4:4]
- wrtarga.c [4:4]
-
-KEEP Zlib 5627c2f3c456186103c1295c24b27409
-BELONGS ya.make
- License text:
- conditions of the zlib License, this would have effectively placed
- Scancode info:
- Original SPDX id: Zlib
- Score : 100.00
- Match type : REFERENCE
- Links : http://www.gzip.org/zlib/zlib_license.html, http://www.zlib.net/, https://spdx.org/licenses/Zlib
- Files with this license:
- LICENSE.md [127:127]
-
-KEEP BSD-3-Clause 67ada8383dd2efffa1e47a6970948655
-BELONGS ya.make
- License text:
- - Clause 2 of the Modified BSD License
- Scancode info:
- Original SPDX id: BSD-3-Clause
- Score : 99.00
- Match type : REFERENCE
- Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
- Files with this license:
- LICENSE.md [72:72]
-
-KEEP Zlib 758530b81bedb384e1d293db2dc592cf
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: Zlib
- Score : 100.00
- Match type : TEXT
- Links : http://www.gzip.org/zlib/zlib_license.html, http://www.zlib.net/, https://spdx.org/licenses/Zlib
- Files with this license:
- simd/nasm/jsimdext.inc [13:27]
-
-KEEP IJG 7aecae112681f0e63e5d5f9a9342893a
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jcapistd.c at line 6, jfdctflt.c at line 6, rdcolmap.c at line 6
- License text:
- * This file is part of the Independent JPEG Group's software.
- * For conditions of distribution and use, see the accompanying README.ijg
- Scancode info:
- Original SPDX id: IJG
- Score : 95.24
- Match type : REFERENCE
- Links : http://fedoraproject.org/wiki/Licensing/IJG, https://spdx.org/licenses/IJG
- Files with this license:
- jcapistd.c [5:6]
- jfdctflt.c [5:6]
- rdcolmap.c [5:6]
-
-KEEP IJG 7e97c9e006fbb17d004858a2472e48cd
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: IJG
- Score : 100.00
- Match type : REFERENCE
- Links : http://fedoraproject.org/wiki/Licensing/IJG, https://spdx.org/licenses/IJG
- Files with this license:
- README.ijg [112:122]
-
-KEEP BSD-3-Clause 8cfc9281adee4768f2232b6e22a82a6d
-BELONGS ya.make
- License text:
- The Modified (3-clause) BSD License
- Scancode info:
- Original SPDX id: BSD-3-Clause
- Score : 100.00
- Match type : REFERENCE
- Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
- Files with this license:
- LICENSE.md [91:91]
-
-KEEP BSD-3-Clause 9778dab78425d5cabd719681a55257aa
-BELONGS ya.make
- License text:
- The zlib License could have been used instead of the Modified (3-clause) BSD
- License, and since the IJG License effectively subsumes the distribution
- Scancode info:
- Original SPDX id: BSD-3-Clause
- Score : 100.00
- Match type : REFERENCE
- Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
- Files with this license:
- LICENSE.md [125:126]
-
-KEEP BSD-3-Clause 98d00c840630f45af91f7f4204a1191c
-BELONGS ya.make
- License text:
- - Clause 3 of the Modified BSD License
- Scancode info:
- Original SPDX id: BSD-3-Clause
- Score : 99.00
- Match type : REFERENCE
- Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
- Files with this license:
- LICENSE.md [79:79]
-
-SKIP Unknown 9ceeef4406e152a852bacc703754696c
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: cderror.h at line 9, cdjpeg.c at line 8, cdjpeg.h at line 9, cjpeg.c at line 9, cmyk.h at line 5, djpeg.c at line 10, jaricom.c at line 8, jcapimin.c at line 9, jcarith.c at line 8, jccoefct.c at line 8, jccolext.c at line 8, jccolor.c at line 10, jcdctmgr.c at line 10, jchuff.c at line 11, jchuff.h at line 8, jcicc.c at line 6, jcinit.c at line 8, jcmainct.c at line 8, jcmarker.c at line 9, jcmaster.c at line 9, jcomapi.c at line 8, jcparam.c at line 9, jcphuff.c at line 11, jcprepct.c at line 8, jcsample.c at line 10, jctrans.c at line 9, jdapimin.c at line 8, jdapistd.c at line 9, jdarith.c at line 8, jdatadst-tj.c at line 9, jdatadst.c at line 9, jdatasrc-tj.c at line 9, jdatasrc.c at line 9, jdcoefct.c at line 10, jdcoefct.h at line 9, jdcol565.c at line 9, jdcolext.c at line 8, jdcolor.c at line 11, jdct.h at line 8, jddctmgr.c at line 11, jdhuff.c at line 9, jdhuff.h at line 9, jdicc.c at line 6, jdinput.c at line 9, jdmainct.c at line 8, jdmainct.h at line 6, jdmarker.c at line 8, jdmaster.c at line 11, jdmaster.h at line 6, jdmerge.c at line 10, jdmerge.h at line 8, jdmrg565.c at line 9, jdmrgext.c at line 8, jdphuff.c at line 8, jdpostct.c at line 8, jdsample.c at line 12, jdsample.h at line 6, jdtrans.c at line 8, jerror.c at line 8, jerror.h at line 9, jfdctfst.c at line 8, jfdctint.c at line 8, jidctflt.c at line 9, jidctfst.c at line 8, jidctint.c at line 9, jidctred.c at line 8, jinclude.h at line 8, jmemmgr.c at line 8, jmemnobs.c at line 8, jmemsys.h at line 8, jmorecfg.h at line 9, jpegcomp.h at line 5, jpegint.h at line 11, jpeglib.h at line 10, jpegtran.c at line 8, jquant1.c at line 8, jquant2.c at line 8, jstdhuff.c at line 8, jutils.c at line 8, jversion.h at line 8, rdbmp.c at line 10, rdppm.c at line 9, rdswitch.c at line 8, rdtarga.c at line 9, simd/arm/jchuff.h at line 10, transupp.c at line 8, transupp.h at line 8, wrbmp.c at line 9, wrppm.c at line 9, wrtarga.c at line 8
- # whole file README.ijg allready included
- License text:
- * For conditions of distribution and use, see the accompanying README.ijg
- Scancode info:
- Original SPDX id: LicenseRef-scancode-unknown-license-reference
- Score : 90.91
- Match type : REFERENCE
- Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/unknown-license-reference.LICENSE
- Files with this license:
- cderror.h [9:9]
- cdjpeg.c [8:8]
- cdjpeg.h [9:9]
- cjpeg.c [9:9]
- cmyk.h [5:5]
- djpeg.c [10:10]
- jaricom.c [8:8]
- jcapimin.c [9:9]
- jcarith.c [8:8]
- jccoefct.c [8:8]
- jccolext.c [8:8]
- jccolor.c [10:10]
- jcdctmgr.c [10:10]
- jchuff.c [11:11]
- jchuff.h [8:8]
- jcicc.c [6:6]
- jcinit.c [8:8]
- jcmainct.c [8:8]
- jcmarker.c [9:9]
- jcmaster.c [9:9]
- jcomapi.c [8:8]
- jcparam.c [9:9]
- jcphuff.c [11:11]
- jcprepct.c [8:8]
- jcsample.c [10:10]
- jctrans.c [9:9]
- jdapimin.c [8:8]
- jdapistd.c [9:9]
- jdarith.c [8:8]
- jdatadst-tj.c [9:9]
- jdatadst.c [9:9]
- jdatasrc-tj.c [9:9]
- jdatasrc.c [9:9]
- jdcoefct.c [10:10]
- jdcoefct.h [9:9]
- jdcol565.c [9:9]
- jdcolext.c [8:8]
- jdcolor.c [11:11]
- jdct.h [8:8]
- jddctmgr.c [11:11]
- jdhuff.c [9:9]
- jdhuff.h [9:9]
- jdicc.c [6:6]
- jdinput.c [9:9]
- jdmainct.c [8:8]
- jdmainct.h [6:6]
- jdmarker.c [8:8]
- jdmaster.c [11:11]
- jdmaster.h [6:6]
- jdmerge.c [10:10]
- jdmerge.h [8:8]
- jdmrg565.c [9:9]
- jdmrgext.c [8:8]
- jdphuff.c [8:8]
- jdpostct.c [8:8]
- jdsample.c [12:12]
- jdsample.h [6:6]
- jdtrans.c [8:8]
- jerror.c [8:8]
- jerror.h [9:9]
- jfdctfst.c [8:8]
- jfdctint.c [8:8]
- jidctflt.c [9:9]
- jidctfst.c [8:8]
- jidctint.c [9:9]
- jidctred.c [8:8]
- jinclude.h [8:8]
- jmemmgr.c [8:8]
- jmemnobs.c [8:8]
- jmemsys.h [8:8]
- jmorecfg.h [9:9]
- jpegcomp.h [5:5]
- jpegint.h [11:11]
- jpeglib.h [10:10]
- jpegtran.c [8:8]
- jquant1.c [8:8]
- jquant2.c [8:8]
- jstdhuff.c [8:8]
- jutils.c [8:8]
- jversion.h [8:8]
- rdbmp.c [10:10]
- rdppm.c [9:9]
- rdswitch.c [8:8]
- rdtarga.c [9:9]
- simd/arm/jchuff.h [10:10]
- transupp.c [8:8]
- transupp.h [8:8]
- wrbmp.c [9:9]
- wrppm.c [9:9]
- wrtarga.c [8:8]
-
-KEEP BSD-3-Clause a0b6446928d785cae9f3fe14c47db8ad
-BELONGS ya.make
- License text:
- %define GOT_SYMBOL __GLOBAL_OFFSET_TABLE_ ; BSD-style a.out supports PIC
- Scancode info:
- Original SPDX id: BSD-3-Clause
- Score : 90.00
- Match type : REFERENCE
- Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
- Files with this license:
- simd/nasm/jsimdext.inc [104:104]
-
-KEEP Libpbm a8c59a0b9632a2c400a492ddc5396cdc
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: LicenseRef-scancode-libpbm
- Score : 100.00
- Match type : TEXT
- Links : http://web.mit.edu/tex/fontutil/fontutils-0.6/pbm/libpbm1.c, https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/libpbm.LICENSE
- Files with this license:
- rdgif.c [27:32]
-
-KEEP IJG b162017eb4edf0bae69328dcb47110fe
-BELONGS ya.make
- License text:
- This software is based in part on the work of the Independent JPEG
- Group.
- Scancode info:
- Original SPDX id: IJG
- Score : 100.00
- Match type : REFERENCE
- Links : http://fedoraproject.org/wiki/Licensing/IJG, https://spdx.org/licenses/IJG
- Files with this license:
- LICENSE.md [61:62]
-
-KEEP IJG c0840233d37a3eb9fec3920f0bf1099a
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: IJG
- Score : 97.95
- Match type : TEXT
- Links : http://fedoraproject.org/wiki/Licensing/IJG, https://spdx.org/licenses/IJG
- Files with this license:
- README.ijg [124:159]
-
-SKIP LicenseRef-scancode-unknown-license-reference AND BSD-3-Clause c728e0ae174c1d6b24a9a96924a2e696
-BELONGS ya.make
- # Changelog
- License text:
- libjpeg-turbo, in its entirety, to be re-licensed under a BSD-style license.
- Scancode info:
- Original SPDX id: LicenseRef-scancode-unknown-license-reference
- Score : 11.00
- Match type : INTRO
- Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/unknown-license-reference.LICENSE
- Files with this license:
- ChangeLog.md [1655:1655]
- Scancode info:
- Original SPDX id: BSD-3-Clause
- Score : 90.00
- Match type : REFERENCE
- Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
- Files with this license:
- ChangeLog.md [1655:1655]
-
-KEEP Libpbm d0197b151ef3a1429e6ed9d61db1ebb9
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: LicenseRef-scancode-libpbm
- Score : 100.00
- Match type : TEXT
- Links : http://web.mit.edu/tex/fontutil/fontutils-0.6/pbm/libpbm1.c, https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/libpbm.LICENSE
- Files with this license:
- wrgif.c [25:30]
-
-KEEP BSD-3-Clause d9457e4e3957eac6bc3c63d753bb59e3
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: BSD-3-Clause
- Score : 99.53
- Match type : TEXT
- Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
- Files with this license:
- LICENSE.md [97:119]
-
-KEEP Zlib d955ed8aa78d34e13a45d6a5c53a6a8b
-BELONGS ya.make
- License text:
- - The [zlib License](https://opensource.org/licenses/Zlib)
- Scancode info:
- Original SPDX id: Zlib
- Score : 100.00
- Match type : REFERENCE
- Links : http://www.gzip.org/zlib/zlib_license.html, http://www.zlib.net/, https://spdx.org/licenses/Zlib
- Files with this license:
- LICENSE.md [17:17]
-
-KEEP Zlib e016c8b3c4399311d17cf74e14e4c31b
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: Zlib
- Score : 100.00
- Match type : TEXT
- Links : http://www.gzip.org/zlib/zlib_license.html, http://www.zlib.net/, https://spdx.org/licenses/Zlib
- Files with this license:
- simd/arm/aarch32/jccolext-neon.c [7:21]
- simd/arm/aarch32/jchuff-neon.c [6:20]
- simd/arm/aarch32/jsimd_neon.S [12:26]
- simd/arm/aarch64/jccolext-neon.c [6:20]
- simd/arm/aarch64/jchuff-neon.c [7:21]
- simd/arm/aarch64/jsimd_neon.S [13:27]
- simd/arm/align.h [4:18]
- simd/arm/jccolor-neon.c [7:21]
- simd/arm/jcgray-neon.c [6:20]
- simd/arm/jcgryext-neon.c [6:20]
- simd/arm/jcphuff-neon.c [6:20]
- simd/arm/jcsample-neon.c [6:20]
- simd/arm/jdcolext-neon.c [7:21]
- simd/arm/jdcolor-neon.c [6:20]
- simd/arm/jdmerge-neon.c [6:20]
- simd/arm/jdmrgext-neon.c [7:21]
- simd/arm/jdsample-neon.c [7:21]
- simd/arm/jfdctfst-neon.c [6:20]
- simd/arm/jfdctint-neon.c [7:21]
- simd/arm/jidctfst-neon.c [6:20]
- simd/arm/jidctint-neon.c [7:21]
- simd/arm/jidctred-neon.c [7:21]
- simd/arm/jquanti-neon.c [6:20]
- simd/arm/neon-compat.h [5:19]
-
-KEEP Beerware e3d7d35bd114ad8c198d3b24c4a2fc3a
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: Beerware
- Score : 100.00
- Match type : TEXT
- Links : http://people.freebsd.org/~phk/, https://spdx.org/licenses/Beerware
- Files with this license:
- md5/md5hl.c [3:6]
-
-KEEP Libpbm e450a16e6dcc10f1721ab5ee51897340
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: LicenseRef-scancode-libpbm
- Score : 100.00
- Match type : TEXT
- Links : http://web.mit.edu/tex/fontutil/fontutils-0.6/pbm/libpbm1.c, https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/libpbm.LICENSE
- Files with this license:
- rdcolmap.c [33:38]
- rdppm.c [35:40]
-
-KEEP Zlib e4be14a7c287c27d28e8f07bf3795a43
-BELONGS ya.make
- License text:
- The zlib License could have been used instead of the Modified (3-clause) BSD
- Scancode info:
- Original SPDX id: Zlib
- Score : 100.00
- Match type : REFERENCE
- Links : http://www.gzip.org/zlib/zlib_license.html, http://www.zlib.net/, https://spdx.org/licenses/Zlib
- Files with this license:
- LICENSE.md [125:125]
-
-KEEP IJG eacab87ea58123f318c9a6b4b065125e
-BELONGS ya.make
- License text:
- - The IJG (Independent JPEG Group) License, which is listed in
- Scancode info:
- Original SPDX id: IJG
- Score : 22.00
- Match type : REFERENCE
- Links : http://fedoraproject.org/wiki/Licensing/IJG, https://spdx.org/licenses/IJG
- Files with this license:
- LICENSE.md [6:6]
-
-KEEP Zlib eec9b0748d14af0b992aa3b313ad57ab
-BELONGS ya.make
- License text:
- - Modified BSD License
- - zlib License
- Scancode info:
- Original SPDX id: Zlib
- Score : 100.00
- Match type : TAG
- Links : http://www.gzip.org/zlib/zlib_license.html, http://www.zlib.net/, https://spdx.org/licenses/Zlib
- Files with this license:
- LICENSE.md [87:88]
-
-KEEP BSD-3-Clause f3fe094edad919ad2298437096b480ef
-BELONGS ya.make
- License text:
- your product documentation must include the text of the Modified BSD
- License (see below.)
- Scancode info:
- Original SPDX id: BSD-3-Clause
- Score : 99.00
- Match type : REFERENCE
- Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
- Files with this license:
- LICENSE.md [68:69]
-
-KEEP Zlib fe97964e6f5a4e0cdab61e2d6f2ba391
-BELONGS ya.make
-FILE_IGNORE simd/nasm/jsimdext.inc found in files: simd/i386/jccolext-avx2.asm at line 9, simd/i386/jccolext-mmx.asm at line 9, simd/i386/jccolext-sse2.asm at line 8, simd/i386/jccolor-avx2.asm at line 9, simd/i386/jccolor-mmx.asm at line 9, simd/i386/jccolor-sse2.asm at line 8, simd/i386/jcgray-avx2.asm at line 9, simd/i386/jcgray-mmx.asm at line 9, simd/i386/jcgray-sse2.asm at line 8, simd/i386/jcgryext-avx2.asm at line 9, simd/i386/jcgryext-mmx.asm at line 9, simd/i386/jcgryext-sse2.asm at line 8, simd/i386/jchuff-sse2.asm at line 10, simd/i386/jcphuff-sse2.asm at line 8, simd/i386/jcsample-avx2.asm at line 10, simd/i386/jcsample-mmx.asm at line 9, simd/i386/jcsample-sse2.asm at line 9, simd/i386/jdcolext-avx2.asm at line 10, simd/i386/jdcolext-mmx.asm at line 9, simd/i386/jdcolext-sse2.asm at line 9, simd/i386/jdcolor-avx2.asm at line 10, simd/i386/jdcolor-mmx.asm at line 9, simd/i386/jdcolor-sse2.asm at line 9, simd/i386/jdmerge-avx2.asm at line 10, simd/i386/jdmerge-mmx.asm at line 9, simd/i386/jdmerge-sse2.asm at line 9, simd/i386/jdmrgext-avx2.asm at line 10, simd/i386/jdmrgext-mmx.asm at line 9, simd/i386/jdmrgext-sse2.asm at line 9, simd/i386/jdsample-avx2.asm at line 10, simd/i386/jdsample-mmx.asm at line 9, simd/i386/jdsample-sse2.asm at line 9, simd/i386/jfdctflt-3dn.asm at line 9, simd/i386/jfdctflt-sse.asm at line 9, simd/i386/jfdctfst-mmx.asm at line 9, simd/i386/jfdctfst-sse2.asm at line 9, simd/i386/jfdctint-avx2.asm at line 9, simd/i386/jfdctint-mmx.asm at line 9, simd/i386/jfdctint-sse2.asm at line 9, simd/i386/jidctflt-3dn.asm at line 9, simd/i386/jidctflt-sse.asm at line 9, simd/i386/jidctflt-sse2.asm at line 9, simd/i386/jidctfst-mmx.asm at line 9, simd/i386/jidctfst-sse2.asm at line 9, simd/i386/jidctint-avx2.asm at line 9, simd/i386/jidctint-mmx.asm at line 9, simd/i386/jidctint-sse2.asm at line 9, simd/i386/jidctred-mmx.asm at line 9, simd/i386/jidctred-sse2.asm at line 9, simd/i386/jquant-3dn.asm at line 9, simd/i386/jquant-mmx.asm at line 9, simd/i386/jquant-sse.asm at line 9, simd/i386/jquantf-sse2.asm at line 9, simd/i386/jquanti-avx2.asm at line 10, simd/i386/jquanti-sse2.asm at line 9, simd/i386/jsimdcpu.asm at line 9, simd/nasm/jcolsamp.inc at line 9, simd/nasm/jdct.inc at line 9, simd/x86_64/jccolext-avx2.asm at line 10, simd/x86_64/jccolext-sse2.asm at line 9, simd/x86_64/jccolor-avx2.asm at line 9, simd/x86_64/jccolor-sse2.asm at line 8, simd/x86_64/jcgray-avx2.asm at line 9, simd/x86_64/jcgray-sse2.asm at line 8, simd/x86_64/jcgryext-avx2.asm at line 10, simd/x86_64/jcgryext-sse2.asm at line 9, simd/x86_64/jchuff-sse2.asm at line 10, simd/x86_64/jcphuff-sse2.asm at line 9, simd/x86_64/jcsample-avx2.asm at line 11, simd/x86_64/jcsample-sse2.asm at line 10, simd/x86_64/jdcolext-avx2.asm at line 11, simd/x86_64/jdcolext-sse2.asm at line 10, simd/x86_64/jdcolor-avx2.asm at line 10, simd/x86_64/jdcolor-sse2.asm at line 9, simd/x86_64/jdmerge-avx2.asm at line 10, simd/x86_64/jdmerge-sse2.asm at line 9, simd/x86_64/jdmrgext-avx2.asm at line 11, simd/x86_64/jdmrgext-sse2.asm at line 10, simd/x86_64/jdsample-avx2.asm at line 11, simd/x86_64/jdsample-sse2.asm at line 10, simd/x86_64/jfdctflt-sse.asm at line 9, simd/x86_64/jfdctfst-sse2.asm at line 9, simd/x86_64/jfdctint-avx2.asm at line 9, simd/x86_64/jfdctint-sse2.asm at line 9, simd/x86_64/jidctflt-sse2.asm at line 10, simd/x86_64/jidctfst-sse2.asm at line 10, simd/x86_64/jidctint-avx2.asm at line 10, simd/x86_64/jidctint-sse2.asm at line 10, simd/x86_64/jidctred-sse2.asm at line 10, simd/x86_64/jquantf-sse2.asm at line 10, simd/x86_64/jquanti-avx2.asm at line 11, simd/x86_64/jquanti-sse2.asm at line 10, simd/x86_64/jsimdcpu.asm at line 10
- License text:
- ; For conditions of distribution and use, see copyright notice in jsimdext.inc
- Scancode info:
- Original SPDX id: Zlib
- Score : 100.00
- Match type : REFERENCE
- Links : http://www.gzip.org/zlib/zlib_license.html, http://www.zlib.net/, https://spdx.org/licenses/Zlib
- Files with this license:
- simd/i386/jccolext-avx2.asm [9:9]
- simd/i386/jccolext-mmx.asm [9:9]
- simd/i386/jccolext-sse2.asm [8:8]
- simd/i386/jccolor-avx2.asm [9:9]
- simd/i386/jccolor-mmx.asm [9:9]
- simd/i386/jccolor-sse2.asm [8:8]
- simd/i386/jcgray-avx2.asm [9:9]
- simd/i386/jcgray-mmx.asm [9:9]
- simd/i386/jcgray-sse2.asm [8:8]
- simd/i386/jcgryext-avx2.asm [9:9]
- simd/i386/jcgryext-mmx.asm [9:9]
- simd/i386/jcgryext-sse2.asm [8:8]
- simd/i386/jchuff-sse2.asm [10:10]
- simd/i386/jcphuff-sse2.asm [8:8]
- simd/i386/jcsample-avx2.asm [10:10]
- simd/i386/jcsample-mmx.asm [9:9]
- simd/i386/jcsample-sse2.asm [9:9]
- simd/i386/jdcolext-avx2.asm [10:10]
- simd/i386/jdcolext-mmx.asm [9:9]
- simd/i386/jdcolext-sse2.asm [9:9]
- simd/i386/jdcolor-avx2.asm [10:10]
- simd/i386/jdcolor-mmx.asm [9:9]
- simd/i386/jdcolor-sse2.asm [9:9]
- simd/i386/jdmerge-avx2.asm [10:10]
- simd/i386/jdmerge-mmx.asm [9:9]
- simd/i386/jdmerge-sse2.asm [9:9]
- simd/i386/jdmrgext-avx2.asm [10:10]
- simd/i386/jdmrgext-mmx.asm [9:9]
- simd/i386/jdmrgext-sse2.asm [9:9]
- simd/i386/jdsample-avx2.asm [10:10]
- simd/i386/jdsample-mmx.asm [9:9]
- simd/i386/jdsample-sse2.asm [9:9]
- simd/i386/jfdctflt-3dn.asm [9:9]
- simd/i386/jfdctflt-sse.asm [9:9]
- simd/i386/jfdctfst-mmx.asm [9:9]
- simd/i386/jfdctfst-sse2.asm [9:9]
- simd/i386/jfdctint-avx2.asm [9:9]
- simd/i386/jfdctint-mmx.asm [9:9]
- simd/i386/jfdctint-sse2.asm [9:9]
- simd/i386/jidctflt-3dn.asm [9:9]
- simd/i386/jidctflt-sse.asm [9:9]
- simd/i386/jidctflt-sse2.asm [9:9]
- simd/i386/jidctfst-mmx.asm [9:9]
- simd/i386/jidctfst-sse2.asm [9:9]
- simd/i386/jidctint-avx2.asm [9:9]
- simd/i386/jidctint-mmx.asm [9:9]
- simd/i386/jidctint-sse2.asm [9:9]
- simd/i386/jidctred-mmx.asm [9:9]
- simd/i386/jidctred-sse2.asm [9:9]
- simd/i386/jquant-3dn.asm [9:9]
- simd/i386/jquant-mmx.asm [9:9]
- simd/i386/jquant-sse.asm [9:9]
- simd/i386/jquantf-sse2.asm [9:9]
- simd/i386/jquanti-avx2.asm [10:10]
- simd/i386/jquanti-sse2.asm [9:9]
- simd/i386/jsimdcpu.asm [9:9]
- simd/nasm/jcolsamp.inc [9:9]
- simd/nasm/jdct.inc [9:9]
- simd/x86_64/jccolext-avx2.asm [10:10]
- simd/x86_64/jccolext-sse2.asm [9:9]
- simd/x86_64/jccolor-avx2.asm [9:9]
- simd/x86_64/jccolor-sse2.asm [8:8]
- simd/x86_64/jcgray-avx2.asm [9:9]
- simd/x86_64/jcgray-sse2.asm [8:8]
- simd/x86_64/jcgryext-avx2.asm [10:10]
- simd/x86_64/jcgryext-sse2.asm [9:9]
- simd/x86_64/jchuff-sse2.asm [10:10]
- simd/x86_64/jcphuff-sse2.asm [9:9]
- simd/x86_64/jcsample-avx2.asm [11:11]
- simd/x86_64/jcsample-sse2.asm [10:10]
- simd/x86_64/jdcolext-avx2.asm [11:11]
- simd/x86_64/jdcolext-sse2.asm [10:10]
- simd/x86_64/jdcolor-avx2.asm [10:10]
- simd/x86_64/jdcolor-sse2.asm [9:9]
- simd/x86_64/jdmerge-avx2.asm [10:10]
- simd/x86_64/jdmerge-sse2.asm [9:9]
- simd/x86_64/jdmrgext-avx2.asm [11:11]
- simd/x86_64/jdmrgext-sse2.asm [10:10]
- simd/x86_64/jdsample-avx2.asm [11:11]
- simd/x86_64/jdsample-sse2.asm [10:10]
- simd/x86_64/jfdctflt-sse.asm [9:9]
- simd/x86_64/jfdctfst-sse2.asm [9:9]
- simd/x86_64/jfdctint-avx2.asm [9:9]
- simd/x86_64/jfdctint-sse2.asm [9:9]
- simd/x86_64/jidctflt-sse2.asm [10:10]
- simd/x86_64/jidctfst-sse2.asm [10:10]
- simd/x86_64/jidctint-avx2.asm [10:10]
- simd/x86_64/jidctint-sse2.asm [10:10]
- simd/x86_64/jidctred-sse2.asm [10:10]
- simd/x86_64/jquantf-sse2.asm [10:10]
- simd/x86_64/jquanti-avx2.asm [11:11]
- simd/x86_64/jquanti-sse2.asm [10:10]
- simd/x86_64/jsimdcpu.asm [10:10]
diff --git a/contrib/libs/libjpeg-turbo/.yandex_meta/licenses.list.txt b/contrib/libs/libjpeg-turbo/.yandex_meta/licenses.list.txt
deleted file mode 100644
index 38d58a719d..0000000000
--- a/contrib/libs/libjpeg-turbo/.yandex_meta/licenses.list.txt
+++ /dev/null
@@ -1,1431 +0,0 @@
-====================BSD-3-Clause====================
- - Clause 1 of the Modified BSD License
-
-
-====================BSD-3-Clause====================
- - Clause 2 of the Modified BSD License
-
-
-====================BSD-3-Clause====================
- your product documentation must include the text of the Modified BSD
- License (see below.)
-
-
-====================BSD-3-Clause====================
- - Clause 3 of the Modified BSD License
-
-
-====================BSD-3-Clause====================
- - IJG License
- - Modified BSD License
-
-
-====================BSD-3-Clause====================
-%define GOT_SYMBOL __GLOBAL_OFFSET_TABLE_ ; BSD-style a.out supports PIC
-
-
-====================BSD-3-Clause====================
-- The Modified (3-clause) BSD License, which is listed below
-
-
-====================BSD-3-Clause====================
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-- Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-- Neither the name of the libjpeg-turbo Project nor the names of its
- contributors may be used to endorse or promote products derived from this
- software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS",
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
-
-
-====================BSD-3-Clause====================
-The Modified (3-clause) BSD License
-
-
-====================BSD-3-Clause====================
-The zlib License could have been used instead of the Modified (3-clause) BSD
-License, and since the IJG License effectively subsumes the distribution
-
-
-====================BSD-3-Clause====================
-libjpeg-turbo is covered by three compatible BSD-style open source licenses.
-
-
-====================BSD-3-Clause====================
-libjpeg-turbo is covered by three compatible BSD-style open source licenses:
-
-
-====================BSD-3-Clause AND BSD-3-Clause====================
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * - Neither the name of the libjpeg-turbo Project nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS",
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
-
-
-====================Beerware====================
- * "THE BEER-WARE LICENSE" (Revision 42):
- * <phk@FreeBSD.org> wrote this file. As long as you retain this notice you
- * can do whatever you want with this stuff. If we meet some day, and you think
- * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
-
-
-====================COPYRIGHT====================
- * "How to Optimize for the Pentium Processors", Copyright (c) 1996, 1997 by
- * Agner Fog. This code assumes we are on a two's complement machine.
-
-
-====================COPYRIGHT====================
- * Author: Ragesh Radhakrishnan <ragesh.r@linaro.org>
- * Copyright (C) 2014-2016, 2020, D. R. Commander. All Rights Reserved.
-
-
-====================COPYRIGHT====================
- * Author: Siarhei Siamashka <siarhei.siamashka@nokia.com>
- * Copyright (C) 2013-2014, Linaro Limited. All Rights Reserved.
-
-
-====================COPYRIGHT====================
- * Author: Siarhei Siamashka <siarhei.siamashka@nokia.com>
- * Copyright (C) 2014, Siarhei Siamashka. All Rights Reserved.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1991-1994, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1991-1995, Thomas G. Lane.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1991-1996, Thomas G. Lane.
- * Modified 2009 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2017, 2019-2020, 2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1991-1996, Thomas G. Lane.
- * Modified 2017 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2018, 2021-2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1991-1996, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2009, 2014-2015, 2020, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1991-1996, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2009, 2015, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1991-1996, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2009-2012, 2015, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1991-1996, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2018, 2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1991-1996, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2015, 2020, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1991-1996, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2017, 2019, 2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1991-1996, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- * Copyright (C) 2009-2012, 2015, D. R. Commander.
- * Copyright (C) 2014, MIPS Technologies, Inc., California.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1991-1996, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- * Copyright (C) 2010, 2015-2016, D. R. Commander.
- * Copyright (C) 2014, MIPS Technologies, Inc., California.
- * Copyright (C) 2015, Google, Inc.
- * Copyright (C) 2019-2020, Arm Limited.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1991-1996, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- * Copyright (C) 2014, MIPS Technologies, Inc., California.
- * Copyright (C) 2015, 2019, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * Modifications:
- * Copyright (C) 2013, Linaro Limited.
- * Copyright (C) 2014-2015, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * Modified 1997-2009 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2009, 2011, 2014-2015, 2018, 2020, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * Modified 1997-2009 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2015-2016, 2019, 2021, D. R. Commander.
- * Copyright (C) 2015, Google, Inc.
- * Copyright (C) 2021, Alex Richardson.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * Modified 2002-2009 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2009-2011, 2016, 2019, 2022, D. R. Commander.
- * Copyright (C) 2013, Linaro Limited.
- * Copyright (C) 2015, Google, Inc.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * Modified 2003-2010 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2016, 2018, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * Modified 2009 by Bill Allombert, Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2015-2017, 2020-2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * Modified 2011 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- * Copyright (C) 2009, 2011-2012, 2014-2015, D. R. Commander.
- * Copyright (C) 2013, Linaro Limited.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * Modified 2013-2019 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2010-2011, 2013-2017, 2019-2020, 2022, D. R. Commander.
- * Copyright (C) 2015, Google, Inc.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * Modified 2015-2019 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2015, 2017, 2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * Modified 2019 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2021-2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2009, 2011, 2015, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2009, 2018, 2021, D. R. Commander.
- * Copyright (C) 2018, Matthias Räncker.
- * Copyright (C) 2020-2021, Arm Limited.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2009-2011, 2014-2016, 2018-2022, D. R. Commander.
- * Copyright (C) 2015, Matthieu Darbois.
- * Copyright (C) 2018, Matthias Räncker.
- * Copyright (C) 2020, Arm Limited.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2009-2011, 2016, 2018-2019, D. R. Commander.
- * Copyright (C) 2018, Matthias Räncker.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2016, 2018, 2022, D. R. Commander.
- * Copyright (C) 2015, Google, Inc.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2010-2011, 2015-2016, 2021, D. R. Commander.
- * Copyright (C) 2018, Matthias Räncker.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2016, 2021-2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2019, 2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2020, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1991-1998, Thomas G. Lane.
- * Modified 2002-2009 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2009-2011, 2013-2014, 2016-2017, 2020, D. R. Commander.
- * Copyright (C) 2015, Google, Inc.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1991-1998, Thomas G. Lane.
- * Modified 2003-2008 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2009-2011, 2018, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1991-1998, Thomas G. Lane.
- * Modified 2003-2010 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2010, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1991-1998, Thomas G. Lane.
- * Modified 2003-2011 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2013-2014, 2017, 2019-2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1991-1998, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2012, 2015, 2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1991-1998, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2013, 2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1991-2020, Thomas G. Lane, Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2012-2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1992-1996, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2017-2018, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1992-1997, Thomas G. Lane.
- * It was modified by The libjpeg-turbo Project to include only code and
- * information relevant to libjpeg-turbo.
- * For conditions of distribution and use, see the accompanying README.ijg
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * Modified 2002-2010 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- * Copyright (C) 2010, 2015, 2022, D. R. Commander.
- * Copyright (C) 2013, MIPS Technologies, Inc., California.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * Modified 2009-2011 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2011, 2016, 2019, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * Modified 2009-2012 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2011, 2014, 2016, 2019, 2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * Modified 2009-2012 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2013, 2016, 2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * Modified 2009-2017 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Modified 2011 by Siarhei Siamashka.
- * Copyright (C) 2015, 2017-2018, 2021-2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * This file is part of the Independent JPEG Group's software.
- * For conditions of distribution and use, see the accompanying README.ijg
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 1999-2006, MIYASAKA Masaru.
- * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- * Copyright (C) 2011, 2014-2015, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2015-2020, 2022, D. R. Commander.
- * Copyright (C) 2015, Google, Inc.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2016, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2011, 2015, 2020, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2013, Linaro Limited.
- * Copyright (C) 2014-2015, 2017, 2019, 2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2013, Linaro Limited.
- * Copyright (C) 2014-2015, 2018, 2020, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2015, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- * Copyright (C) 2009, 2011, 2014-2015, 2020, D. R. Commander.
- * Copyright (C) 2013, Linaro Limited.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1994-1997, Thomas G. Lane.
- * Modified 1997-2009 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2014, 2017, 2021-2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1994-1997, Thomas G. Lane.
- * Modified 2009-2017 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2021, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1994-1997, Thomas G. Lane.
- * Modified 2019 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2017, 2019, 2021, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1994-1997, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- * Copyright (C) 2010, 2015-2016, 2019-2020, 2022, D. R. Commander.
- * Copyright (C) 2015, 2020, Google, Inc.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1994-1997, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- * Copyright (C) 2020, Google, Inc.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1994-1998, Thomas G. Lane.
- * Modified 2003-2010 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1994-1998, Thomas G. Lane.
- * Modified 2010 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2014, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1994-1998, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2016, 2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1995-1997, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2011, 2015, 2018, 2021-2022, D. R. Commander.
- * Copyright (C) 2016, 2018, Matthieu Darbois.
- * Copyright (C) 2020, Arm Limited.
- * Copyright (C) 2021, Alex Richardson.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1995-1997, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2015-2016, 2018-2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1995-1998, Thomas G. Lane.
- * Modified 2000-2009 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2020, 2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1995-2019, Thomas G. Lane, Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2014, 2017, 2019-2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1997-1998, Thomas G. Lane, Todd Newman.
- * Copyright (C) 2017, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1997-2019, Thomas G. Lane, Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2017, 2021-2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1997-2019, Thomas G. Lane, Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2017, 2021, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 2009-2011, Nokia Corporation and/or its subsidiary(-ies).
- * All Rights Reserved.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 2010, 2020, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 2016, Siarhei Siamashka. All Rights Reserved.
-
-
-====================COPYRIGHT====================
- * Copyright (C) 2017-2018, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Copyright (C)2009-2014, 2017-2019, 2022 D. R. Commander.
- * All Rights Reserved.
-
-
-====================COPYRIGHT====================
- * Copyright (C)2009-2015, 2017, 2020-2021 D. R. Commander.
- * All Rights Reserved.
-
-
-====================COPYRIGHT====================
- * Copyright (C)2011, 2019 D. R. Commander. All Rights Reserved.
-
-
-====================COPYRIGHT====================
- * Copyright (C)2011, 2022 D. R. Commander. All Rights Reserved.
-
-
-====================COPYRIGHT====================
- * Copyright (C)2016, 2018-2019, 2022 D. R. Commander. All Rights Reserved.
-
-
-====================COPYRIGHT====================
- * Copyright (C)2018 D. R. Commander. All Rights Reserved.
-
-
-====================COPYRIGHT====================
- * Copyright (C)2018, D. R. Commander. All Rights Reserved.
-
-
-====================COPYRIGHT====================
- * Copyright (C)2021 Alex Richardson. All Rights Reserved.
-
-
-====================COPYRIGHT====================
- * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- * Copyright (C) 2009-2011, 2014, 2016, 2018, 2022, D. R. Commander.
- * Copyright (C) 2015-2016, 2018, Matthieu Darbois.
-
-
-====================COPYRIGHT====================
- * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- * Copyright (C) 2009-2011, 2014, D. R. Commander.
- * Copyright (C) 2015-2016, 2018, Matthieu Darbois.
- * Copyright (C) 2020, Arm Limited.
-
-
-====================COPYRIGHT====================
- * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- * Copyright (C) 2011, 2014, D. R. Commander.
- * Copyright (C) 2015-2016, 2018, Matthieu Darbois.
- * Copyright (C) 2020, Arm Limited.
-
-
-====================COPYRIGHT====================
- * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- * Copyright (C) 2011, 2014-2016, 2018, 2020, D. R. Commander.
- * Copyright (C) 2013-2014, MIPS Technologies, Inc., California.
- * Copyright (C) 2014, Linaro Limited.
- * Copyright (C) 2015-2016, 2018, Matthieu Darbois.
- * Copyright (C) 2016-2018, Loongson Technology Corporation Limited, BeiJing.
- * Copyright (C) 2020, Arm Limited.
-
-
-====================COPYRIGHT====================
- * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- * Copyright (C) 2011, Nokia Corporation and/or its subsidiary(-ies).
- * Copyright (C) 2009-2011, 2013-2014, 2016, 2018, 2020, 2022, D. R. Commander.
- * Copyright (C) 2015-2016, 2018, Matthieu Darbois.
- * Copyright (C) 2020, Arm Limited.
-
-
-====================COPYRIGHT====================
- * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- * Copyright (C) 2011, Nokia Corporation and/or its subsidiary(-ies).
- * Copyright (C) 2009-2011, 2013-2014, 2016, 2018, 2022, D. R. Commander.
- * Copyright (C) 2015-2016, 2018, Matthieu Darbois.
- * Copyright (C) 2019, Google LLC.
- * Copyright (C) 2020, Arm Limited.
-
-
-====================COPYRIGHT====================
- * Developed 1997-2009 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2015, 2018, 2021-2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Developed 1997-2009 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2015, 2018, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * Developed 1997-2015 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2015-2020, 2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
-
-
-====================COPYRIGHT====================
- * of Feb. 1991. That file contains the following copyright notice:
- * Based on GIFENCODE by David Rowley <mgardi@watdscu.waterloo.edu>.
- * Lempel-Ziv compression based on "compress" by Spencer W. Thomas et al.
- * Copyright (C) 1989 by Jef Poskanzer.
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose and without fee is hereby granted, provided
- * that the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation. This software is provided "as is" without express or
- * implied warranty.
-
-
-====================COPYRIGHT====================
- * | Copyright 1990, David Koblas. |
- * | Permission to use, copy, modify, and distribute this software |
- * | and its documentation for any purpose and without fee is hereby |
- * | granted, provided that the above copyright notice appear in all |
- * | copies and that both that copyright notice and this permission |
- * | notice appear in supporting documentation. This software is |
- * | provided "as is" without express or implied warranty. |
-
-
-====================COPYRIGHT====================
-#define JCOPYRIGHT \
- "Copyright (C) 2009-2022 D. R. Commander\n" \
- "Copyright (C) 2015, 2020 Google, Inc.\n" \
- "Copyright (C) 2019-2020 Arm Limited\n" \
- "Copyright (C) 2015-2016, 2018 Matthieu Darbois\n" \
- "Copyright (C) 2011-2016 Siarhei Siamashka\n" \
- "Copyright (C) 2015 Intel Corporation\n" \
- "Copyright (C) 2013-2014 Linaro Limited\n" \
- "Copyright (C) 2013-2014 MIPS Technologies, Inc.\n" \
- "Copyright (C) 2009, 2012 Pierre Ossman for Cendio AB\n" \
- "Copyright (C) 2009-2011 Nokia Corporation and/or its subsidiary(-ies)\n" \
- "Copyright (C) 1999-2006 MIYASAKA Masaru\n" \
- "Copyright (C) 1991-2020 Thomas G. Lane, Guido Vollbeding"
-
-
-====================COPYRIGHT====================
-** Copyright (C) 1988 by Jef Poskanzer.
-
-
-====================COPYRIGHT====================
-; Copyright (C) 2009, 2016, D. R. Commander.
-; Copyright (C) 2015, Intel Corporation.
-
-
-====================COPYRIGHT====================
-; Copyright (C) 2009-2011, 2014-2016, 2019, 2021, D. R. Commander.
-; Copyright (C) 2015, Matthieu Darbois.
-; Copyright (C) 2018, Matthias Räncker.
-
-
-====================COPYRIGHT====================
-; Copyright (C) 2009-2011, 2014-2017, 2019, D. R. Commander.
-; Copyright (C) 2015, Matthieu Darbois.
-; Copyright (C) 2018, Matthias Räncker.
-
-
-====================COPYRIGHT====================
-; Copyright (C) 2011, 2016, D. R. Commander.
-; Copyright (C) 2015, Intel Corporation.
-
-
-====================COPYRIGHT====================
-; Copyright (C) 2015, Intel Corporation.
-; Copyright (C) 2016, D. R. Commander.
-
-
-====================COPYRIGHT====================
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, 2016, 2018, 2020, D. R. Commander.
-
-
-====================COPYRIGHT====================
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, 2016, 2018, D. R. Commander.
-; Copyright (C) 2016, Matthieu Darbois.
-; Copyright (C) 2018, Matthias Räncker.
-
-
-====================COPYRIGHT====================
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, 2016, 2020, D. R. Commander.
-
-
-====================COPYRIGHT====================
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2010, 2016, 2018-2019, D. R. Commander.
-; Copyright (C) 2018, Matthieu Darbois.
-; Copyright (C) 2018, Matthias Räncker.
-
-
-====================COPYRIGHT====================
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2016, 2018, D. R. Commander.
-; Copyright (C) 2016, Matthieu Darbois.
-
-
-====================COPYRIGHT====================
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2016, 2020, D. R. Commander.
-
-
-====================COPYRIGHT====================
-; Copyright 2009, 2012 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, 2012, 2016, D. R. Commander.
-; Copyright (C) 2015, Intel Corporation.
-; Copyright (C) 2018, Matthias Räncker.
-
-
-====================COPYRIGHT====================
-; Copyright 2009, 2012 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2012, 2016, D. R. Commander.
-; Copyright (C) 2015, Intel Corporation.
-
-
-====================COPYRIGHT====================
-Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
-
-
-====================COPYRIGHT====================
-Copyright (c) 1991-2022 The libjpeg-turbo Project
-
-====================COPYRIGHT====================
-This software is copyright (C) 1991-2020, Thomas G. Lane, Guido Vollbeding.
-All Rights Reserved except as specified below.
-
-
-====================File: README.ijg====================
-libjpeg-turbo note: This file has been modified by The libjpeg-turbo Project
-to include only information relevant to libjpeg-turbo, to wordsmith certain
-sections, and to remove impolitic language that existed in the libjpeg v8
-README. It is included only for reference. Please see README.md for
-information specific to libjpeg-turbo.
-
-
-The Independent JPEG Group's JPEG software
-==========================================
-
-This distribution contains a release of the Independent JPEG Group's free JPEG
-software. You are welcome to redistribute this software and to use it for any
-purpose, subject to the conditions under LEGAL ISSUES, below.
-
-This software is the work of Tom Lane, Guido Vollbeding, Philip Gladstone,
-Bill Allombert, Jim Boucher, Lee Crocker, Bob Friesenhahn, Ben Jackson,
-Julian Minguillon, Luis Ortiz, George Phillips, Davide Rossi, Ge' Weijers,
-and other members of the Independent JPEG Group.
-
-IJG is not affiliated with the ISO/IEC JTC1/SC29/WG1 standards committee
-(also known as JPEG, together with ITU-T SG16).
-
-
-DOCUMENTATION ROADMAP
-=====================
-
-This file contains the following sections:
-
-OVERVIEW General description of JPEG and the IJG software.
-LEGAL ISSUES Copyright, lack of warranty, terms of distribution.
-REFERENCES Where to learn more about JPEG.
-ARCHIVE LOCATIONS Where to find newer versions of this software.
-FILE FORMAT WARS Software *not* to get.
-TO DO Plans for future IJG releases.
-
-Other documentation files in the distribution are:
-
-User documentation:
- usage.txt Usage instructions for cjpeg, djpeg, jpegtran,
- rdjpgcom, and wrjpgcom.
- *.1 Unix-style man pages for programs (same info as usage.txt).
- wizard.txt Advanced usage instructions for JPEG wizards only.
- change.log Version-to-version change highlights.
-Programmer and internal documentation:
- libjpeg.txt How to use the JPEG library in your own programs.
- example.txt Sample code for calling the JPEG library.
- structure.txt Overview of the JPEG library's internal structure.
- coderules.txt Coding style rules --- please read if you contribute code.
-
-Please read at least usage.txt. Some information can also be found in the JPEG
-FAQ (Frequently Asked Questions) article. See ARCHIVE LOCATIONS below to find
-out where to obtain the FAQ article.
-
-If you want to understand how the JPEG code works, we suggest reading one or
-more of the REFERENCES, then looking at the documentation files (in roughly
-the order listed) before diving into the code.
-
-
-OVERVIEW
-========
-
-This package contains C software to implement JPEG image encoding, decoding,
-and transcoding. JPEG (pronounced "jay-peg") is a standardized compression
-method for full-color and grayscale images. JPEG's strong suit is compressing
-photographic images or other types of images that have smooth color and
-brightness transitions between neighboring pixels. Images with sharp lines or
-other abrupt features may not compress well with JPEG, and a higher JPEG
-quality may have to be used to avoid visible compression artifacts with such
-images.
-
-JPEG is lossy, meaning that the output pixels are not necessarily identical to
-the input pixels. However, on photographic content and other "smooth" images,
-very good compression ratios can be obtained with no visible compression
-artifacts, and extremely high compression ratios are possible if you are
-willing to sacrifice image quality (by reducing the "quality" setting in the
-compressor.)
-
-This software implements JPEG baseline, extended-sequential, and progressive
-compression processes. Provision is made for supporting all variants of these
-processes, although some uncommon parameter settings aren't implemented yet.
-We have made no provision for supporting the hierarchical or lossless
-processes defined in the standard.
-
-We provide a set of library routines for reading and writing JPEG image files,
-plus two sample applications "cjpeg" and "djpeg", which use the library to
-perform conversion between JPEG and some other popular image file formats.
-The library is intended to be reused in other applications.
-
-In order to support file conversion and viewing software, we have included
-considerable functionality beyond the bare JPEG coding/decoding capability;
-for example, the color quantization modules are not strictly part of JPEG
-decoding, but they are essential for output to colormapped file formats or
-colormapped displays. These extra functions can be compiled out of the
-library if not required for a particular application.
-
-We have also included "jpegtran", a utility for lossless transcoding between
-different JPEG processes, and "rdjpgcom" and "wrjpgcom", two simple
-applications for inserting and extracting textual comments in JFIF files.
-
-The emphasis in designing this software has been on achieving portability and
-flexibility, while also making it fast enough to be useful. In particular,
-the software is not intended to be read as a tutorial on JPEG. (See the
-REFERENCES section for introductory material.) Rather, it is intended to
-be reliable, portable, industrial-strength code. We do not claim to have
-achieved that goal in every aspect of the software, but we strive for it.
-
-We welcome the use of this software as a component of commercial products.
-No royalty is required, but we do ask for an acknowledgement in product
-documentation, as described under LEGAL ISSUES.
-
-
-LEGAL ISSUES
-============
-
-In plain English:
-
-1. We don't promise that this software works. (But if you find any bugs,
- please let us know!)
-2. You can use this software for whatever you want. You don't have to pay us.
-3. You may not pretend that you wrote this software. If you use it in a
- program, you must acknowledge somewhere in your documentation that
- you've used the IJG code.
-
-In legalese:
-
-The authors make NO WARRANTY or representation, either express or implied,
-with respect to this software, its quality, accuracy, merchantability, or
-fitness for a particular purpose. This software is provided "AS IS", and you,
-its user, assume the entire risk as to its quality and accuracy.
-
-This software is copyright (C) 1991-2020, Thomas G. Lane, Guido Vollbeding.
-All Rights Reserved except as specified below.
-
-Permission is hereby granted to use, copy, modify, and distribute this
-software (or portions thereof) for any purpose, without fee, subject to these
-conditions:
-(1) If any part of the source code for this software is distributed, then this
-README file must be included, with this copyright and no-warranty notice
-unaltered; and any additions, deletions, or changes to the original files
-must be clearly indicated in accompanying documentation.
-(2) If only executable code is distributed, then the accompanying
-documentation must state that "this software is based in part on the work of
-the Independent JPEG Group".
-(3) Permission for use of this software is granted only if the user accepts
-full responsibility for any undesirable consequences; the authors accept
-NO LIABILITY for damages of any kind.
-
-These conditions apply to any software derived from or based on the IJG code,
-not just to the unmodified library. If you use our work, you ought to
-acknowledge us.
-
-Permission is NOT granted for the use of any IJG author's name or company name
-in advertising or publicity relating to this software or products derived from
-it. This software may be referred to only as "the Independent JPEG Group's
-software".
-
-We specifically permit and encourage the use of this software as the basis of
-commercial products, provided that all warranty or liability claims are
-assumed by the product vendor.
-
-
-REFERENCES
-==========
-
-We recommend reading one or more of these references before trying to
-understand the innards of the JPEG software.
-
-The best short technical introduction to the JPEG compression algorithm is
- Wallace, Gregory K. "The JPEG Still Picture Compression Standard",
- Communications of the ACM, April 1991 (vol. 34 no. 4), pp. 30-44.
-(Adjacent articles in that issue discuss MPEG motion picture compression,
-applications of JPEG, and related topics.) If you don't have the CACM issue
-handy, a PDF file containing a revised version of Wallace's article is
-available at http://www.ijg.org/files/Wallace.JPEG.pdf. The file (actually
-a preprint for an article that appeared in IEEE Trans. Consumer Electronics)
-omits the sample images that appeared in CACM, but it includes corrections
-and some added material. Note: the Wallace article is copyright ACM and IEEE,
-and it may not be used for commercial purposes.
-
-A somewhat less technical, more leisurely introduction to JPEG can be found in
-"The Data Compression Book" by Mark Nelson and Jean-loup Gailly, published by
-M&T Books (New York), 2nd ed. 1996, ISBN 1-55851-434-1. This book provides
-good explanations and example C code for a multitude of compression methods
-including JPEG. It is an excellent source if you are comfortable reading C
-code but don't know much about data compression in general. The book's JPEG
-sample code is far from industrial-strength, but when you are ready to look
-at a full implementation, you've got one here...
-
-The best currently available description of JPEG is the textbook "JPEG Still
-Image Data Compression Standard" by William B. Pennebaker and Joan L.
-Mitchell, published by Van Nostrand Reinhold, 1993, ISBN 0-442-01272-1.
-Price US$59.95, 638 pp. The book includes the complete text of the ISO JPEG
-standards (DIS 10918-1 and draft DIS 10918-2).
-
-The original JPEG standard is divided into two parts, Part 1 being the actual
-specification, while Part 2 covers compliance testing methods. Part 1 is
-titled "Digital Compression and Coding of Continuous-tone Still Images,
-Part 1: Requirements and guidelines" and has document numbers ISO/IEC IS
-10918-1, ITU-T T.81. Part 2 is titled "Digital Compression and Coding of
-Continuous-tone Still Images, Part 2: Compliance testing" and has document
-numbers ISO/IEC IS 10918-2, ITU-T T.83.
-
-The JPEG standard does not specify all details of an interchangeable file
-format. For the omitted details, we follow the "JFIF" conventions, revision
-1.02. JFIF version 1 has been adopted as ISO/IEC 10918-5 (05/2013) and
-Recommendation ITU-T T.871 (05/2011): Information technology - Digital
-compression and coding of continuous-tone still images: JPEG File Interchange
-Format (JFIF). It is available as a free download in PDF file format from
-https://www.iso.org/standard/54989.html and http://www.itu.int/rec/T-REC-T.871.
-A PDF file of the older JFIF 1.02 specification is available at
-http://www.w3.org/Graphics/JPEG/jfif3.pdf.
-
-The TIFF 6.0 file format specification can be obtained from
-http://mirrors.ctan.org/graphics/tiff/TIFF6.ps.gz. The JPEG incorporation
-scheme found in the TIFF 6.0 spec of 3-June-92 has a number of serious
-problems. IJG does not recommend use of the TIFF 6.0 design (TIFF Compression
-tag 6). Instead, we recommend the JPEG design proposed by TIFF Technical Note
-#2 (Compression tag 7). Copies of this Note can be obtained from
-http://www.ijg.org/files/. It is expected that the next revision
-of the TIFF spec will replace the 6.0 JPEG design with the Note's design.
-Although IJG's own code does not support TIFF/JPEG, the free libtiff library
-uses our library to implement TIFF/JPEG per the Note.
-
-
-ARCHIVE LOCATIONS
-=================
-
-The "official" archive site for this software is www.ijg.org.
-The most recent released version can always be found there in
-directory "files".
-
-The JPEG FAQ (Frequently Asked Questions) article is a source of some
-general information about JPEG. It is available at
-http://www.faqs.org/faqs/jpeg-faq.
-
-
-FILE FORMAT COMPATIBILITY
-=========================
-
-This software implements ITU T.81 | ISO/IEC 10918 with some extensions from
-ITU T.871 | ISO/IEC 10918-5 (JPEG File Interchange Format-- see REFERENCES).
-Informally, the term "JPEG image" or "JPEG file" most often refers to JFIF or
-a subset thereof, but there are other formats containing the name "JPEG" that
-are incompatible with the DCT-based JPEG standard or with JFIF (for instance,
-JPEG 2000 and JPEG XR). This software therefore does not support these
-formats. Indeed, one of the original reasons for developing this free software
-was to help force convergence on a common, interoperable format standard for
-JPEG files.
-
-JFIF is a minimal or "low end" representation. TIFF/JPEG (TIFF revision 6.0 as
-modified by TIFF Technical Note #2) can be used for "high end" applications
-that need to record a lot of additional data about an image.
-
-
-TO DO
-=====
-
-Please send bug reports, offers of help, etc. to jpeg-info@jpegclub.org.
-
-
-====================IJG====================
- This software is based in part on the work of the Independent JPEG
- Group.
-
-
-====================IJG====================
- * This file is part of the Independent JPEG Group's software.
- * For conditions of distribution and use, see the accompanying README.ijg
-
-
-====================IJG====================
- * This file was part of the Independent JPEG Group's software:
-
-
-====================IJG====================
-- The IJG (Independent JPEG Group) License, which is listed in
-
-
-====================IJG====================
-In legalese:
-
-The authors make NO WARRANTY or representation, either express or implied,
-with respect to this software, its quality, accuracy, merchantability, or
-fitness for a particular purpose. This software is provided "AS IS", and you,
-its user, assume the entire risk as to its quality and accuracy.
-
-This software is copyright (C) 1991-2020, Thomas G. Lane, Guido Vollbeding.
-All Rights Reserved except as specified below.
-
-Permission is hereby granted to use, copy, modify, and distribute this
-software (or portions thereof) for any purpose, without fee, subject to these
-conditions:
-(1) If any part of the source code for this software is distributed, then this
-README file must be included, with this copyright and no-warranty notice
-unaltered; and any additions, deletions, or changes to the original files
-must be clearly indicated in accompanying documentation.
-(2) If only executable code is distributed, then the accompanying
-documentation must state that "this software is based in part on the work of
-the Independent JPEG Group".
-(3) Permission for use of this software is granted only if the user accepts
-full responsibility for any undesirable consequences; the authors accept
-NO LIABILITY for damages of any kind.
-
-These conditions apply to any software derived from or based on the IJG code,
-not just to the unmodified library. If you use our work, you ought to
-acknowledge us.
-
-Permission is NOT granted for the use of any IJG author's name or company name
-in advertising or publicity relating to this software or products derived from
-it. This software may be referred to only as "the Independent JPEG Group's
-software".
-
-We specifically permit and encourage the use of this software as the basis of
-commercial products, provided that all warranty or liability claims are
-assumed by the product vendor.
-
-
-====================IJG====================
-LEGAL ISSUES
-============
-
-In plain English:
-
-1. We don't promise that this software works. (But if you find any bugs,
- please let us know!)
-2. You can use this software for whatever you want. You don't have to pay us.
-3. You may not pretend that you wrote this software. If you use it in a
- program, you must acknowledge somewhere in your documentation that
- you've used the IJG code.
-
-
-====================Libpbm====================
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose and without fee is hereby granted, provided
- * that the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation. This software is provided "as is" without express or
- * implied warranty.
-
-
-====================Libpbm====================
- * | Permission to use, copy, modify, and distribute this software |
- * | and its documentation for any purpose and without fee is hereby |
- * | granted, provided that the above copyright notice appear in all |
- * | copies and that both that copyright notice and this permission |
- * | notice appear in supporting documentation. This software is |
- * | provided "as is" without express or implied warranty. |
-
-
-====================Libpbm====================
-** Permission to use, copy, modify, and distribute this software and its
-** documentation for any purpose and without fee is hereby granted, provided
-** that the above copyright notice appear in all copies and that both that
-** copyright notice and this permission notice appear in supporting
-** documentation. This software is provided "as is" without express or
-** implied warranty.
-
-
-====================Public-Domain====================
- * The algorithm is due to Ron Rivest. This code was
- * written by Colin Plumb in 1993, no copyright is claimed.
- * This code is in the public domain; do with it what you wish.
-
-
-====================Zlib====================
- - Clause 2 of the zlib License
-
-
-====================Zlib====================
- - Clauses 1 and 3 of the zlib License
-
-
-====================Zlib====================
- - Modified BSD License
- - zlib License
-
-
-====================Zlib====================
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- * claim that you wrote the original software. If you use this software
- * in a product, an acknowledgment in the product documentation would be
- * appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must not be
- * misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source distribution.
-
-
-====================Zlib====================
-- The [zlib License](https://opensource.org/licenses/Zlib)
-
-
-====================Zlib====================
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-
-
-====================Zlib====================
-; This software is provided 'as-is', without any express or implied
-; warranty. In no event will the authors be held liable for any damages
-; arising from the use of this software.
-;
-; Permission is granted to anyone to use this software for any purpose,
-; including commercial applications, and to alter it and redistribute it
-; freely, subject to the following restrictions:
-;
-; 1. The origin of this software must not be misrepresented; you must not
-; claim that you wrote the original software. If you use this software
-; in a product, an acknowledgment in the product documentation would be
-; appreciated but is not required.
-; 2. Altered source versions must be plainly marked as such, and must not be
-; misrepresented as being the original software.
-; 3. This notice may not be removed or altered from any source distribution.
-
-
-====================Zlib====================
-The zlib License could have been used instead of the Modified (3-clause) BSD
-
-
-====================Zlib====================
-conditions of the zlib License, this would have effectively placed
diff --git a/contrib/libs/libjpeg-turbo/.yandex_meta/override.nix b/contrib/libs/libjpeg-turbo/.yandex_meta/override.nix
deleted file mode 100644
index 7a009c2bed..0000000000
--- a/contrib/libs/libjpeg-turbo/.yandex_meta/override.nix
+++ /dev/null
@@ -1,12 +0,0 @@
-pkgs: attrs: with pkgs; with attrs; rec {
- version = "2.1.4";
-
- src = fetchFromGitHub {
- owner = "libjpeg-turbo";
- repo = "libjpeg-turbo";
- rev = "${version}";
- hash = "sha256-1NRoVIL3zXX1D6iOf2FCrwBEcDW7TYFbdIbCTjY1m8Q=";
- };
-
- patches = [];
-}
diff --git a/contrib/libs/libjpeg-turbo/BUILDING.md b/contrib/libs/libjpeg-turbo/BUILDING.md
deleted file mode 100644
index 2ce65d6177..0000000000
--- a/contrib/libs/libjpeg-turbo/BUILDING.md
+++ /dev/null
@@ -1,714 +0,0 @@
-Building libjpeg-turbo
-======================
-
-
-Build Requirements
-------------------
-
-
-### All Systems
-
-- [CMake](http://www.cmake.org) v2.8.12 or later
-
-- [NASM](http://www.nasm.us) or [Yasm](http://yasm.tortall.net)
- (if building x86 or x86-64 SIMD extensions)
- * If using NASM, 2.13 or later is required.
- * If using Yasm, 1.2.0 or later is required.
- * If building on macOS, NASM or Yasm can be obtained from
- [MacPorts](http://www.macports.org/) or [Homebrew](http://brew.sh/).
- - NOTE: Currently, if it is desirable to hide the SIMD function symbols in
- Mac executables or shared libraries that statically link with
- libjpeg-turbo, then NASM 2.14 or later or Yasm must be used when
- building libjpeg-turbo.
- * If NASM or Yasm is not in your `PATH`, then you can specify the full path
- to the assembler by using either the `CMAKE_ASM_NASM_COMPILER` CMake
- variable or the `ASM_NASM` environment variable. On Windows, use forward
- slashes rather than backslashes in the path (for example,
- **c:/nasm/nasm.exe**).
- * NASM and Yasm are located in the CRB (Code Ready Builder) repository on
- Red Hat Enterprise Linux 8 and in the PowerTools repository on RHEL
- derivatives, which is not enabled by default.
-
-### Un*x Platforms (including Linux, Mac, FreeBSD, Solaris, and Cygwin)
-
-- GCC v4.1 (or later) or Clang recommended for best performance
-
-- If building the TurboJPEG Java wrapper, JDK or OpenJDK 1.5 or later is
- required. Most modern Linux distributions, as well as Solaris 10 and later,
- include JDK or OpenJDK. For other systems, you can obtain the Oracle Java
- Development Kit from
- <http://www.oracle.com/technetwork/java/javase/downloads>.
-
- * If using JDK 11 or later, CMake 3.10.x or later must also be used.
-
-### Windows
-
-- Microsoft Visual C++ 2005 or later
-
- If you don't already have Visual C++, then the easiest way to get it is by
- installing
- [Visual Studio Community Edition](https://visualstudio.microsoft.com),
- which includes everything necessary to build libjpeg-turbo.
-
- * You can also download and install the standalone Windows SDK (for Windows 7
- or later), which includes command-line versions of the 32-bit and 64-bit
- Visual C++ compilers.
- * If you intend to build libjpeg-turbo from the command line, then add the
- appropriate compiler and SDK directories to the `INCLUDE`, `LIB`, and
- `PATH` environment variables. This is generally accomplished by
- executing `vcvars32.bat` or `vcvars64.bat`, which are located in the same
- directory as the compiler.
- * If built with Visual C++ 2015 or later, the libjpeg-turbo static libraries
- cannot be used with earlier versions of Visual C++, and vice versa.
- * The libjpeg API DLL (**jpeg{version}.dll**) will depend on the C run-time
- DLLs corresponding to the version of Visual C++ that was used to build it.
-
- ... OR ...
-
-- MinGW
-
- [MSYS2](http://msys2.github.io/) or [tdm-gcc](http://tdm-gcc.tdragon.net/)
- recommended if building on a Windows machine. Both distributions install a
- Start Menu link that can be used to launch a command prompt with the
- appropriate compiler paths automatically set.
-
-- If building the TurboJPEG Java wrapper, JDK 1.5 or later is required. This
- can be downloaded from
- <http://www.oracle.com/technetwork/java/javase/downloads>.
-
- * If using JDK 11 or later, CMake 3.10.x or later must also be used.
-
-
-Sub-Project Builds
-------------------
-
-The libjpeg-turbo build system does not support being included as a sub-project
-using the CMake `add_subdirectory()` function. Use the CMake
-`ExternalProject_Add()` function instead.
-
-
-Out-of-Tree Builds
-------------------
-
-Binary objects, libraries, and executables are generated in the directory from
-which CMake is executed (the "binary directory"), and this directory need not
-necessarily be the same as the libjpeg-turbo source directory. You can create
-multiple independent binary directories, in which different versions of
-libjpeg-turbo can be built from the same source tree using different compilers
-or settings. In the sections below, *{build_directory}* refers to the binary
-directory, whereas *{source_directory}* refers to the libjpeg-turbo source
-directory. For in-tree builds, these directories are the same.
-
-
-Ninja
------
-
-If using Ninja, then replace `make` or `nmake` with `ninja`, and replace the
-CMake generator (specified with the `-G` option) with `Ninja`, in all of the
-procedures and recipes below.
-
-
-Build Procedure
----------------
-
-NOTE: The build procedures below assume that CMake is invoked from the command
-line, but all of these procedures can be adapted to the CMake GUI as
-well.
-
-
-### Un*x
-
-The following procedure will build libjpeg-turbo on Unix and Unix-like systems.
-(On Solaris, this generates a 32-bit build. See "Build Recipes" below for
-64-bit build instructions.)
-
- cd {build_directory}
- cmake -G"Unix Makefiles" [additional CMake flags] {source_directory}
- make
-
-This will generate the following files under *{build_directory}*:
-
-**libjpeg.a**<br>
-Static link library for the libjpeg API
-
-**libjpeg.so.{version}** (Linux, Unix)<br>
-**libjpeg.{version}.dylib** (Mac)<br>
-**cygjpeg-{version}.dll** (Cygwin)<br>
-Shared library for the libjpeg API
-
-By default, *{version}* is 62.2.0, 7.2.0, or 8.1.2, depending on whether
-libjpeg v6b (default), v7, or v8 emulation is enabled. If using Cygwin,
-*{version}* is 62, 7, or 8.
-
-**libjpeg.so** (Linux, Unix)<br>
-**libjpeg.dylib** (Mac)<br>
-Development symlink for the libjpeg API
-
-**libjpeg.dll.a** (Cygwin)<br>
-Import library for the libjpeg API
-
-**libturbojpeg.a**<br>
-Static link library for the TurboJPEG API
-
-**libturbojpeg.so.0.2.0** (Linux, Unix)<br>
-**libturbojpeg.0.2.0.dylib** (Mac)<br>
-**cygturbojpeg-0.dll** (Cygwin)<br>
-Shared library for the TurboJPEG API
-
-**libturbojpeg.so** (Linux, Unix)<br>
-**libturbojpeg.dylib** (Mac)<br>
-Development symlink for the TurboJPEG API
-
-**libturbojpeg.dll.a** (Cygwin)<br>
-Import library for the TurboJPEG API
-
-
-### Visual C++ (Command Line)
-
- cd {build_directory}
- cmake -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=Release [additional CMake flags] {source_directory}
- nmake
-
-This will build either a 32-bit or a 64-bit version of libjpeg-turbo, depending
-on which version of **cl.exe** is in the `PATH`.
-
-The following files will be generated under *{build_directory}*:
-
-**jpeg-static.lib**<br>
-Static link library for the libjpeg API
-
-**jpeg{version}.dll**<br>
-DLL for the libjpeg API
-
-**jpeg.lib**<br>
-Import library for the libjpeg API
-
-**turbojpeg-static.lib**<br>
-Static link library for the TurboJPEG API
-
-**turbojpeg.dll**<br>
-DLL for the TurboJPEG API
-
-**turbojpeg.lib**<br>
-Import library for the TurboJPEG API
-
-*{version}* is 62, 7, or 8, depending on whether libjpeg v6b (default), v7, or
-v8 emulation is enabled.
-
-
-### Visual C++ (IDE)
-
-Choose the appropriate CMake generator option for your version of Visual Studio
-(run `cmake` with no arguments for a list of available generators.) For
-instance:
-
- cd {build_directory}
- cmake -G"Visual Studio 10" [additional CMake flags] {source_directory}
-
-NOTE: Add "Win64" to the generator name (for example, "Visual Studio 10 Win64")
-to build a 64-bit version of libjpeg-turbo. A separate build directory must be
-used for 32-bit and 64-bit builds.
-
-You can then open **ALL_BUILD.vcproj** in Visual Studio and build one of the
-configurations in that project ("Debug", "Release", etc.) to generate a full
-build of libjpeg-turbo.
-
-This will generate the following files under *{build_directory}*:
-
-**{configuration}/jpeg-static.lib**<br>
-Static link library for the libjpeg API
-
-**{configuration}/jpeg{version}.dll**<br>
-DLL for the libjpeg API
-
-**{configuration}/jpeg.lib**<br>
-Import library for the libjpeg API
-
-**{configuration}/turbojpeg-static.lib**<br>
-Static link library for the TurboJPEG API
-
-**{configuration}/turbojpeg.dll**<br>
-DLL for the TurboJPEG API
-
-**{configuration}/turbojpeg.lib**<br>
-Import library for the TurboJPEG API
-
-*{configuration}* is Debug, Release, RelWithDebInfo, or MinSizeRel, depending
-on the configuration you built in the IDE, and *{version}* is 62, 7, or 8,
-depending on whether libjpeg v6b (default), v7, or v8 emulation is enabled.
-
-
-### MinGW
-
-NOTE: This assumes that you are building on a Windows machine using the MSYS
-environment. If you are cross-compiling on a Un*x platform (including Mac and
-Cygwin), then see "Build Recipes" below.
-
- cd {build_directory}
- cmake -G"MSYS Makefiles" [additional CMake flags] {source_directory}
- make
-
-This will generate the following files under *{build_directory}*:
-
-**libjpeg.a**<br>
-Static link library for the libjpeg API
-
-**libjpeg-{version}.dll**<br>
-DLL for the libjpeg API
-
-**libjpeg.dll.a**<br>
-Import library for the libjpeg API
-
-**libturbojpeg.a**<br>
-Static link library for the TurboJPEG API
-
-**libturbojpeg.dll**<br>
-DLL for the TurboJPEG API
-
-**libturbojpeg.dll.a**<br>
-Import library for the TurboJPEG API
-
-*{version}* is 62, 7, or 8, depending on whether libjpeg v6b (default), v7, or
-v8 emulation is enabled.
-
-
-### Debug Build
-
-Add `-DCMAKE_BUILD_TYPE=Debug` to the CMake command line. Or, if building
-with NMake, remove `-DCMAKE_BUILD_TYPE=Release` (Debug builds are the default
-with NMake.)
-
-
-### libjpeg v7 or v8 API/ABI Emulation
-
-Add `-DWITH_JPEG7=1` to the CMake command line to build a version of
-libjpeg-turbo that is API/ABI-compatible with libjpeg v7. Add `-DWITH_JPEG8=1`
-to the CMake command line to build a version of libjpeg-turbo that is
-API/ABI-compatible with libjpeg v8. See [README.md](README.md) for more
-information about libjpeg v7 and v8 emulation.
-
-
-### In-Memory Source/Destination Managers
-
-When using libjpeg v6b or v7 API/ABI emulation, add `-DWITH_MEM_SRCDST=0` to
-the CMake command line to build a version of libjpeg-turbo that lacks the
-`jpeg_mem_src()` and `jpeg_mem_dest()` functions. These functions were not
-part of the original libjpeg v6b and v7 APIs, so removing them ensures strict
-conformance with those APIs. See [README.md](README.md) for more information.
-
-
-### Arithmetic Coding Support
-
-Since the patent on arithmetic coding has expired, this functionality has been
-included in this release of libjpeg-turbo. libjpeg-turbo's implementation is
-based on the implementation in libjpeg v8, but it works when emulating libjpeg
-v7 or v6b as well. The default is to enable both arithmetic encoding and
-decoding, but those who have philosophical objections to arithmetic coding can
-add `-DWITH_ARITH_ENC=0` or `-DWITH_ARITH_DEC=0` to the CMake command line to
-disable encoding or decoding (respectively.)
-
-
-### TurboJPEG Java Wrapper
-
-Add `-DWITH_JAVA=1` to the CMake command line to incorporate an optional Java
-Native Interface (JNI) wrapper into the TurboJPEG shared library and build the
-Java front-end classes to support it. This allows the TurboJPEG shared library
-to be used directly from Java applications. See [java/README](java/README) for
-more details.
-
-If Java is not in your `PATH`, or if you wish to use an alternate JDK to
-build/test libjpeg-turbo, then (prior to running CMake) set the `JAVA_HOME`
-environment variable to the location of the JDK that you wish to use. The
-`Java_JAVAC_EXECUTABLE`, `Java_JAVA_EXECUTABLE`, and `Java_JAR_EXECUTABLE`
-CMake variables can also be used to specify alternate commands or locations for
-javac, jar, and java (respectively.) You can also set the
-`CMAKE_JAVA_COMPILE_FLAGS` CMake variable or the `JAVAFLAGS` environment
-variable to specify arguments that should be passed to the Java compiler when
-building the TurboJPEG classes, and the `JAVAARGS` CMake variable to specify
-arguments that should be passed to the JRE when running the TurboJPEG Java unit
-tests.
-
-
-Build Recipes
--------------
-
-
-### 32-bit Build on 64-bit Linux/Unix
-
-Use export/setenv to set the following environment variables before running
-CMake:
-
- CFLAGS=-m32
- LDFLAGS=-m32
-
-
-### 64-bit Build on Solaris
-
-Use export/setenv to set the following environment variables before running
-CMake:
-
- CFLAGS=-m64
- LDFLAGS=-m64
-
-
-### Other Compilers
-
-On Un*x systems, prior to running CMake, you can set the `CC` environment
-variable to the command used to invoke the C compiler.
-
-
-### 32-bit MinGW Build on Un*x (including Mac and Cygwin)
-
-Create a file called **toolchain.cmake** under *{build_directory}*, with the
-following contents:
-
- set(CMAKE_SYSTEM_NAME Windows)
- set(CMAKE_SYSTEM_PROCESSOR X86)
- set(CMAKE_C_COMPILER {mingw_binary_path}/i686-w64-mingw32-gcc)
- set(CMAKE_RC_COMPILER {mingw_binary_path}/i686-w64-mingw32-windres)
-
-*{mingw\_binary\_path}* is the directory under which the MinGW binaries are
-located (usually **/usr/bin**.) Next, execute the following commands:
-
- cd {build_directory}
- cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
- [additional CMake flags] {source_directory}
- make
-
-
-### 64-bit MinGW Build on Un*x (including Mac and Cygwin)
-
-Create a file called **toolchain.cmake** under *{build_directory}*, with the
-following contents:
-
- set(CMAKE_SYSTEM_NAME Windows)
- set(CMAKE_SYSTEM_PROCESSOR AMD64)
- set(CMAKE_C_COMPILER {mingw_binary_path}/x86_64-w64-mingw32-gcc)
- set(CMAKE_RC_COMPILER {mingw_binary_path}/x86_64-w64-mingw32-windres)
-
-*{mingw\_binary\_path}* is the directory under which the MinGW binaries are
-located (usually **/usr/bin**.) Next, execute the following commands:
-
- cd {build_directory}
- cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
- [additional CMake flags] {source_directory}
- make
-
-
-Building libjpeg-turbo for iOS
-------------------------------
-
-iOS platforms, such as the iPhone and iPad, use Arm processors, and all
-currently supported models include Neon instructions. Thus, they can take
-advantage of libjpeg-turbo's SIMD extensions to significantly accelerate JPEG
-compression/decompression. This section describes how to build libjpeg-turbo
-for these platforms.
-
-
-### Armv8 (64-bit)
-
-**Xcode 5 or later required, Xcode 6.3.x or later recommended**
-
-The following script demonstrates how to build libjpeg-turbo to run on the
-iPhone 5S/iPad Mini 2/iPad Air and newer.
-
- IOS_PLATFORMDIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform
- IOS_SYSROOT=($IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS*.sdk)
- export CFLAGS="-Wall -arch arm64 -miphoneos-version-min=8.0 -funwind-tables"
-
- cd {build_directory}
-
- cat <<EOF >toolchain.cmake
- set(CMAKE_SYSTEM_NAME Darwin)
- set(CMAKE_SYSTEM_PROCESSOR aarch64)
- set(CMAKE_C_COMPILER /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang)
- EOF
-
- cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
- -DCMAKE_OSX_SYSROOT=${IOS_SYSROOT[0]} \
- [additional CMake flags] {source_directory}
- make
-
-
-Building libjpeg-turbo for Android
-----------------------------------
-
-Building libjpeg-turbo for Android platforms requires v13b or later of the
-[Android NDK](https://developer.android.com/tools/sdk/ndk).
-
-
-### Armv7 (32-bit)
-
-**NDK r19 or later with Clang recommended**
-
-The following is a general recipe script that can be modified for your specific
-needs.
-
- # Set these variables to suit your needs
- NDK_PATH={full path to the NDK directory-- for example,
- /opt/android/android-ndk-r16b}
- TOOLCHAIN={"gcc" or "clang"-- "gcc" must be used with NDK r16b and earlier,
- and "clang" must be used with NDK r17c and later}
- ANDROID_VERSION={the minimum version of Android to support-- for example,
- "16", "19", etc.}
-
- cd {build_directory}
- cmake -G"Unix Makefiles" \
- -DANDROID_ABI=armeabi-v7a \
- -DANDROID_ARM_MODE=arm \
- -DANDROID_PLATFORM=android-${ANDROID_VERSION} \
- -DANDROID_TOOLCHAIN=${TOOLCHAIN} \
- -DCMAKE_ASM_FLAGS="--target=arm-linux-androideabi${ANDROID_VERSION}" \
- -DCMAKE_TOOLCHAIN_FILE=${NDK_PATH}/build/cmake/android.toolchain.cmake \
- [additional CMake flags] {source_directory}
- make
-
-
-### Armv8 (64-bit)
-
-**Clang recommended**
-
-The following is a general recipe script that can be modified for your specific
-needs.
-
- # Set these variables to suit your needs
- NDK_PATH={full path to the NDK directory-- for example,
- /opt/android/android-ndk-r16b}
- TOOLCHAIN={"gcc" or "clang"-- "gcc" must be used with NDK r14b and earlier,
- and "clang" must be used with NDK r17c and later}
- ANDROID_VERSION={the minimum version of Android to support. "21" or later
- is required for a 64-bit build.}
-
- cd {build_directory}
- cmake -G"Unix Makefiles" \
- -DANDROID_ABI=arm64-v8a \
- -DANDROID_ARM_MODE=arm \
- -DANDROID_PLATFORM=android-${ANDROID_VERSION} \
- -DANDROID_TOOLCHAIN=${TOOLCHAIN} \
- -DCMAKE_ASM_FLAGS="--target=aarch64-linux-android${ANDROID_VERSION}" \
- -DCMAKE_TOOLCHAIN_FILE=${NDK_PATH}/build/cmake/android.toolchain.cmake \
- [additional CMake flags] {source_directory}
- make
-
-
-### x86 (32-bit)
-
-The following is a general recipe script that can be modified for your specific
-needs.
-
- # Set these variables to suit your needs
- NDK_PATH={full path to the NDK directory-- for example,
- /opt/android/android-ndk-r16b}
- TOOLCHAIN={"gcc" or "clang"-- "gcc" must be used with NDK r14b and earlier,
- and "clang" must be used with NDK r17c and later}
- ANDROID_VERSION={The minimum version of Android to support-- for example,
- "16", "19", etc.}
-
- cd {build_directory}
- cmake -G"Unix Makefiles" \
- -DANDROID_ABI=x86 \
- -DANDROID_PLATFORM=android-${ANDROID_VERSION} \
- -DANDROID_TOOLCHAIN=${TOOLCHAIN} \
- -DCMAKE_TOOLCHAIN_FILE=${NDK_PATH}/build/cmake/android.toolchain.cmake \
- [additional CMake flags] {source_directory}
- make
-
-
-### x86-64 (64-bit)
-
-The following is a general recipe script that can be modified for your specific
-needs.
-
- # Set these variables to suit your needs
- NDK_PATH={full path to the NDK directory-- for example,
- /opt/android/android-ndk-r16b}
- TOOLCHAIN={"gcc" or "clang"-- "gcc" must be used with NDK r14b and earlier,
- and "clang" must be used with NDK r17c and later}
- ANDROID_VERSION={the minimum version of Android to support. "21" or later
- is required for a 64-bit build.}
-
- cd {build_directory}
- cmake -G"Unix Makefiles" \
- -DANDROID_ABI=x86_64 \
- -DANDROID_PLATFORM=android-${ANDROID_VERSION} \
- -DANDROID_TOOLCHAIN=${TOOLCHAIN} \
- -DCMAKE_TOOLCHAIN_FILE=${NDK_PATH}/build/cmake/android.toolchain.cmake \
- [additional CMake flags] {source_directory}
- make
-
-
-Advanced CMake Options
-----------------------
-
-To list and configure other CMake options not specifically mentioned in this
-guide, run
-
- ccmake {source_directory}
-
-or
-
- cmake-gui {source_directory}
-
-from the build directory after initially configuring the build. CCMake is a
-text-based interactive version of CMake, and CMake-GUI is a GUI version. Both
-will display all variables that are relevant to the libjpeg-turbo build, their
-current values, and a help string describing what they do.
-
-
-Installing libjpeg-turbo
-========================
-
-You can use the build system to install libjpeg-turbo (as opposed to creating
-an installer package.) To do this, run `make install` or `nmake install`
-(or build the "install" target in the Visual Studio IDE.) Running
-`make uninstall` or `nmake uninstall` (or building the "uninstall" target in
-the Visual Studio IDE) will uninstall libjpeg-turbo.
-
-The `CMAKE_INSTALL_PREFIX` CMake variable can be modified in order to install
-libjpeg-turbo into a directory of your choosing. If you don't specify
-`CMAKE_INSTALL_PREFIX`, then the default is:
-
-**c:\libjpeg-turbo**<br>
-Visual Studio 32-bit build
-
-**c:\libjpeg-turbo64**<br>
-Visual Studio 64-bit build
-
-**c:\libjpeg-turbo-gcc**<br>
-MinGW 32-bit build
-
-**c:\libjpeg-turbo-gcc64**<br>
-MinGW 64-bit build
-
-**/opt/libjpeg-turbo**<br>
-Un*x
-
-The default value of `CMAKE_INSTALL_PREFIX` causes the libjpeg-turbo files to
-be installed with a directory structure resembling that of the official
-libjpeg-turbo binary packages. Changing the value of `CMAKE_INSTALL_PREFIX`
-(for instance, to **/usr/local**) causes the libjpeg-turbo files to be
-installed with a directory structure that conforms to GNU standards.
-
-The `CMAKE_INSTALL_BINDIR`, `CMAKE_INSTALL_DATAROOTDIR`,
-`CMAKE_INSTALL_DOCDIR`, `CMAKE_INSTALL_INCLUDEDIR`, `CMAKE_INSTALL_JAVADIR`,
-`CMAKE_INSTALL_LIBDIR`, and `CMAKE_INSTALL_MANDIR` CMake variables allow a
-finer degree of control over where specific files in the libjpeg-turbo
-distribution should be installed. These directory variables can either be
-specified as absolute paths or as paths relative to `CMAKE_INSTALL_PREFIX` (for
-instance, setting `CMAKE_INSTALL_DOCDIR` to **doc** would cause the
-documentation to be installed in **${CMAKE\_INSTALL\_PREFIX}/doc**.) If a
-directory variable contains the name of another directory variable in angle
-brackets, then its final value will depend on the final value of that other
-variable. For instance, the default value of `CMAKE_INSTALL_MANDIR` is
-**\<CMAKE\_INSTALL\_DATAROOTDIR\>/man**.
-
-NOTE: If setting one of these directory variables to a relative path using the
-CMake command line, you must specify that the variable is of type `PATH`.
-For example:
-
- cmake -G"{generator type}" -DCMAKE_INSTALL_LIBDIR:PATH=lib {source_directory}
-
-Otherwise, CMake will assume that the path is relative to the build directory
-rather than the install directory.
-
-
-Creating Distribution Packages
-==============================
-
-The following commands can be used to create various types of distribution
-packages:
-
-
-Linux
------
-
- make rpm
-
-Create Red Hat-style binary RPM package. Requires RPM v4 or later.
-
- make srpm
-
-This runs `make dist` to create a pristine source tarball, then creates a
-Red Hat-style source RPM package from the tarball. Requires RPM v4 or later.
-
- make deb
-
-Create Debian-style binary package. Requires dpkg.
-
-
-Mac
----
-
- make dmg
-
-Create Mac package/disk image. This requires pkgbuild and productbuild, which
-are installed by default on OS X/macOS 10.7 and later.
-
-In order to create a Mac package/disk image that contains universal
-x86-64/Arm binaries, set the following CMake variable:
-
-* `ARMV8_BUILD`: Directory containing an Armv8 (64-bit) iOS or macOS build of
- libjpeg-turbo to include in the universal binaries
-
-You should first use CMake to configure an Armv8 sub-build of libjpeg-turbo
-(see "Building libjpeg-turbo for iOS" above, if applicable) in a build
-directory that matches the one specified in the aforementioned CMake variable.
-Next, configure the primary (x86-64) build of libjpeg-turbo as an out-of-tree
-build, specifying the aforementioned CMake variable, and build it. Once the
-primary build has been built, run `make dmg` from the build directory. The
-packaging system will build the sub-build, use lipo to combine it with the
-primary build into a single set of universal binaries, then package the
-universal binaries.
-
-
-Windows
--------
-
-If using NMake:
-
- cd {build_directory}
- nmake installer
-
-If using MinGW:
-
- cd {build_directory}
- make installer
-
-If using the Visual Studio IDE, build the "installer" target.
-
-The installer package (libjpeg-turbo-*{version}*[-gcc|-vc][64].exe) will be
-located under *{build_directory}*. If building using the Visual Studio IDE,
-then the installer package will be located in a subdirectory with the same name
-as the configuration you built (such as *{build_directory}*\Debug\ or
-*{build_directory}*\Release\).
-
-Building a Windows installer requires the
-[Nullsoft Install System](http://nsis.sourceforge.net/). makensis.exe should
-be in your `PATH`.
-
-
-Regression testing
-==================
-
-The most common way to test libjpeg-turbo is by invoking `make test` (Un*x) or
-`nmake test` (Windows command line) or by building the "RUN_TESTS" target
-(Visual Studio IDE), once the build has completed. This runs a series of tests
-to ensure that mathematical compatibility has been maintained between
-libjpeg-turbo and libjpeg v6b. This also invokes the TurboJPEG unit tests,
-which ensure that the colorspace extensions, YUV encoding, decompression
-scaling, and other features of the TurboJPEG C and Java APIs are working
-properly (and, by extension, that the equivalent features of the underlying
-libjpeg API are also working.)
-
-Invoking `make testclean` (Un*x) or `nmake testclean` (Windows command line) or
-building the "testclean" target (Visual Studio IDE) will clean up the output
-images generated by the tests.
-
-On Un*x platforms, more extensive tests of the TurboJPEG C and Java wrappers
-can be run by invoking `make tjtest`. These extended TurboJPEG tests
-essentially iterate through all of the available features of the TurboJPEG APIs
-that are not covered by the TurboJPEG unit tests (including the lossless
-transform options) and compare the images generated by each feature to images
-generated using the equivalent feature in the libjpeg API. The extended
-TurboJPEG tests are meant to test for regressions in the TurboJPEG wrappers,
-not in the underlying libjpeg API library.
diff --git a/contrib/libs/libjpeg-turbo/ChangeLog.md b/contrib/libs/libjpeg-turbo/ChangeLog.md
deleted file mode 100644
index b0d166ea10..0000000000
--- a/contrib/libs/libjpeg-turbo/ChangeLog.md
+++ /dev/null
@@ -1,1874 +0,0 @@
-2.1.4
-=====
-
-### Significant changes relative to 2.1.3
-
-1. Fixed a regression introduced in 2.1.3 that caused build failures with
-Visual Studio 2010.
-
-2. The `tjDecompressHeader3()` function in the TurboJPEG C API and the
-`TJDecompressor.setSourceImage()` method in the TurboJPEG Java API now accept
-"abbreviated table specification" (AKA "tables-only") datastreams, which can be
-used to prime the decompressor with quantization and Huffman tables that can be
-used when decompressing subsequent "abbreviated image" datastreams.
-
-3. libjpeg-turbo now performs run-time detection of AltiVec instructions on
-OS X/PowerPC systems if AltiVec instructions are not enabled at compile time.
-This allows both AltiVec-equipped (PowerPC G4 and G5) and non-AltiVec-equipped
-(PowerPC G3) CPUs to be supported using the same build of libjpeg-turbo.
-
-4. Fixed an error ("Bogus virtual array access") that occurred when attempting
-to decompress a progressive JPEG image with a height less than or equal to one
-iMCU (8 * the vertical sampling factor) using buffered-image mode with
-interblock smoothing enabled. This was a regression introduced by
-2.1 beta1[6(b)].
-
-5. Fixed two issues that prevented partial image decompression from working
-properly with buffered-image mode:
-
- - Attempting to call `jpeg_crop_scanline()` after
-`jpeg_start_decompress()` but before `jpeg_start_output()` resulted in an error
-("Improper call to JPEG library in state 207".)
- - Attempting to use `jpeg_skip_scanlines()` resulted in an error ("Bogus
-virtual array access") under certain circumstances.
-
-
-2.1.3
-=====
-
-### Significant changes relative to 2.1.2
-
-1. Fixed a regression introduced by 2.0 beta1[7] whereby cjpeg compressed PGM
-input files into full-color JPEG images unless the `-grayscale` option was
-used.
-
-2. cjpeg now automatically compresses GIF and 8-bit BMP input files into
-grayscale JPEG images if the input files contain only shades of gray.
-
-3. The build system now enables the intrinsics implementation of the AArch64
-(Arm 64-bit) Neon SIMD extensions by default when using GCC 12 or later.
-
-4. Fixed a segfault that occurred while decompressing a 4:2:0 JPEG image using
-the merged (non-fancy) upsampling algorithms (that is, with
-`cinfo.do_fancy_upsampling` set to `FALSE`) along with `jpeg_crop_scanline()`.
-Specifically, the segfault occurred if the number of bytes remaining in the
-output buffer was less than the number of bytes required to represent one
-uncropped scanline of the output image. For that reason, the issue could only
-be reproduced using the libjpeg API, not using djpeg.
-
-
-2.1.2
-=====
-
-### Significant changes relative to 2.1.1
-
-1. Fixed a regression introduced by 2.1 beta1[13] that caused the remaining
-GAS implementations of AArch64 (Arm 64-bit) Neon SIMD functions (which are used
-by default with GCC for performance reasons) to be placed in the `.rodata`
-section rather than in the `.text` section. This caused the GNU linker to
-automatically place the `.rodata` section in an executable segment, which
-prevented libjpeg-turbo from working properly with other linkers and also
-represented a potential security risk.
-
-2. Fixed an issue whereby the `tjTransform()` function incorrectly computed the
-MCU block size for 4:4:4 JPEG images with non-unary sampling factors and thus
-unduly rejected some cropping regions, even though those regions aligned with
-8x8 MCU block boundaries.
-
-3. Fixed a regression introduced by 2.1 beta1[13] that caused the build system
-to enable the Arm Neon SIMD extensions when targetting Armv6 and other legacy
-architectures that do not support Neon instructions.
-
-4. libjpeg-turbo now performs run-time detection of AltiVec instructions on
-FreeBSD/PowerPC systems if AltiVec instructions are not enabled at compile
-time. This allows both AltiVec-equipped and non-AltiVec-equipped CPUs to be
-supported using the same build of libjpeg-turbo.
-
-5. cjpeg now accepts a `-strict` argument similar to that of djpeg and
-jpegtran, which causes the compressor to abort if an LZW-compressed GIF input
-image contains incomplete or corrupt image data.
-
-
-2.1.1
-=====
-
-### Significant changes relative to 2.1.0
-
-1. Fixed a regression introduced in 2.1.0 that caused build failures with
-non-GCC-compatible compilers for Un*x/Arm platforms.
-
-2. Fixed a regression introduced by 2.1 beta1[13] that prevented the Arm 32-bit
-(AArch32) Neon SIMD extensions from building unless the C compiler flags
-included `-mfloat-abi=softfp` or `-mfloat-abi=hard`.
-
-3. Fixed an issue in the AArch32 Neon SIMD Huffman encoder whereby reliance on
-undefined C compiler behavior led to crashes ("SIGBUS: illegal alignment") on
-Android systems when running AArch32/Thumb builds of libjpeg-turbo built with
-recent versions of Clang.
-
-4. Added a command-line argument (`-copy icc`) to jpegtran that causes it to
-copy only the ICC profile markers from the source file and discard any other
-metadata.
-
-5. libjpeg-turbo should now build and run on CHERI-enabled architectures, which
-use capability pointers that are larger than the size of `size_t`.
-
-6. Fixed a regression (CVE-2021-37972) introduced by 2.1 beta1[5] that caused a
-segfault in the 64-bit SSE2 Huffman encoder when attempting to losslessly
-transform a specially-crafted malformed JPEG image.
-
-
-2.1.0
-=====
-
-### Significant changes relative to 2.1 beta1
-
-1. Fixed a regression introduced by 2.1 beta1[6(b)] whereby attempting to
-decompress certain progressive JPEG images with one or more component planes of
-width 8 or less caused a buffer overrun.
-
-2. Fixed a regression introduced by 2.1 beta1[6(b)] whereby attempting to
-decompress a specially-crafted malformed progressive JPEG image caused the
-block smoothing algorithm to read from uninitialized memory.
-
-3. Fixed an issue in the Arm Neon SIMD Huffman encoders that caused the
-encoders to generate incorrect results when using the Clang compiler with
-Visual Studio.
-
-4. Fixed a floating point exception (CVE-2021-20205) that occurred when
-attempting to compress a specially-crafted malformed GIF image with a specified
-image width of 0 using cjpeg.
-
-5. Fixed a regression introduced by 2.0 beta1[15] whereby attempting to
-generate a progressive JPEG image on an SSE2-capable CPU using a scan script
-containing one or more scans with lengths divisible by 32 and non-zero
-successive approximation low bit positions would, under certain circumstances,
-result in an error ("Missing Huffman code table entry") and an invalid JPEG
-image.
-
-6. Introduced a new flag (`TJFLAG_LIMITSCANS` in the TurboJPEG C API and
-`TJ.FLAG_LIMIT_SCANS` in the TurboJPEG Java API) and a corresponding TJBench
-command-line argument (`-limitscans`) that causes the TurboJPEG decompression
-and transform functions/operations to return/throw an error if a progressive
-JPEG image contains an unreasonably large number of scans. This allows
-applications that use the TurboJPEG API to guard against an exploit of the
-progressive JPEG format described in the report
-["Two Issues with the JPEG Standard"](https://libjpeg-turbo.org/pmwiki/uploads/About/TwoIssueswiththeJPEGStandard.pdf).
-
-7. The PPM reader now throws an error, rather than segfaulting (due to a buffer
-overrun) or generating incorrect pixels, if an application attempts to use the
-`tjLoadImage()` function to load a 16-bit binary PPM file (a binary PPM file
-with a maximum value greater than 255) into a grayscale image buffer or to load
-a 16-bit binary PGM file into an RGB image buffer.
-
-8. Fixed an issue in the PPM reader that caused incorrect pixels to be
-generated when using the `tjLoadImage()` function to load a 16-bit binary PPM
-file into an extended RGB image buffer.
-
-9. Fixed an issue whereby, if a JPEG buffer was automatically re-allocated by
-one of the TurboJPEG compression or transform functions and an error
-subsequently occurred during compression or transformation, the JPEG buffer
-pointer passed by the application was not updated when the function returned.
-
-
-2.0.90 (2.1 beta1)
-==================
-
-### Significant changes relative to 2.0.6:
-
-1. The build system, x86-64 SIMD extensions, and accelerated Huffman codec now
-support the x32 ABI on Linux, which allows for using x86-64 instructions with
-32-bit pointers. The x32 ABI is generally enabled by adding `-mx32` to the
-compiler flags.
-
- Caveats:
- - CMake 3.9.0 or later is required in order for the build system to
-automatically detect an x32 build.
- - Java does not support the x32 ABI, and thus the TurboJPEG Java API will
-automatically be disabled with x32 builds.
-
-2. Added Loongson MMI SIMD implementations of the RGB-to-grayscale, 4:2:2 fancy
-chroma upsampling, 4:2:2 and 4:2:0 merged chroma upsampling/color conversion,
-and fast integer DCT/IDCT algorithms. Relative to libjpeg-turbo 2.0.x, this
-speeds up:
-
- - the compression of RGB source images into grayscale JPEG images by
-approximately 20%
- - the decompression of 4:2:2 JPEG images by approximately 40-60% when
-using fancy upsampling
- - the decompression of 4:2:2 and 4:2:0 JPEG images by approximately
-15-20% when using merged upsampling
- - the compression of RGB source images by approximately 30-45% when using
-the fast integer DCT
- - the decompression of JPEG images into RGB destination images by
-approximately 2x when using the fast integer IDCT
-
- The overall decompression speedup for RGB images is now approximately
-2.3-3.7x (compared to 2-3.5x with libjpeg-turbo 2.0.x.)
-
-3. 32-bit (Armv7 or Armv7s) iOS builds of libjpeg-turbo are no longer
-supported, and the libjpeg-turbo build system can no longer be used to package
-such builds. 32-bit iOS apps cannot run in iOS 11 and later, and the App Store
-no longer allows them.
-
-4. 32-bit (i386) OS X/macOS builds of libjpeg-turbo are no longer supported,
-and the libjpeg-turbo build system can no longer be used to package such
-builds. 32-bit Mac applications cannot run in macOS 10.15 "Catalina" and
-later, and the App Store no longer allows them.
-
-5. The SSE2 (x86 SIMD) and C Huffman encoding algorithms have been
-significantly optimized, resulting in a measured average overall compression
-speedup of 12-28% for 64-bit code and 22-52% for 32-bit code on various Intel
-and AMD CPUs, as well as a measured average overall compression speedup of
-0-23% on platforms that do not have a SIMD-accelerated Huffman encoding
-implementation.
-
-6. The block smoothing algorithm that is applied by default when decompressing
-progressive Huffman-encoded JPEG images has been improved in the following
-ways:
-
- - The algorithm is now more fault-tolerant. Previously, if a particular
-scan was incomplete, then the smoothing parameters for the incomplete scan
-would be applied to the entire output image, including the parts of the image
-that were generated by the prior (complete) scan. Visually, this had the
-effect of removing block smoothing from lower-frequency scans if they were
-followed by an incomplete higher-frequency scan. libjpeg-turbo now applies
-block smoothing parameters to each iMCU row based on which scan generated the
-pixels in that row, rather than always using the block smoothing parameters for
-the most recent scan.
- - When applying block smoothing to DC scans, a Gaussian-like kernel with a
-5x5 window is used to reduce the "blocky" appearance.
-
-7. Added SIMD acceleration for progressive Huffman encoding on Arm platforms.
-This speeds up the compression of full-color progressive JPEGs by about 30-40%
-on average (relative to libjpeg-turbo 2.0.x) when using modern Arm CPUs.
-
-8. Added configure-time and run-time auto-detection of Loongson MMI SIMD
-instructions, so that the Loongson MMI SIMD extensions can be included in any
-MIPS64 libjpeg-turbo build.
-
-9. Added fault tolerance features to djpeg and jpegtran, mainly to demonstrate
-methods by which applications can guard against the exploits of the JPEG format
-described in the report
-["Two Issues with the JPEG Standard"](https://libjpeg-turbo.org/pmwiki/uploads/About/TwoIssueswiththeJPEGStandard.pdf).
-
- - Both programs now accept a `-maxscans` argument, which can be used to
-limit the number of allowable scans in the input file.
- - Both programs now accept a `-strict` argument, which can be used to
-treat all warnings as fatal.
-
-10. CMake package config files are now included for both the libjpeg and
-TurboJPEG API libraries. This facilitates using libjpeg-turbo with CMake's
-`find_package()` function. For example:
-
- find_package(libjpeg-turbo CONFIG REQUIRED)
-
- add_executable(libjpeg_program libjpeg_program.c)
- target_link_libraries(libjpeg_program PUBLIC libjpeg-turbo::jpeg)
-
- add_executable(libjpeg_program_static libjpeg_program.c)
- target_link_libraries(libjpeg_program_static PUBLIC
- libjpeg-turbo::jpeg-static)
-
- add_executable(turbojpeg_program turbojpeg_program.c)
- target_link_libraries(turbojpeg_program PUBLIC
- libjpeg-turbo::turbojpeg)
-
- add_executable(turbojpeg_program_static turbojpeg_program.c)
- target_link_libraries(turbojpeg_program_static PUBLIC
- libjpeg-turbo::turbojpeg-static)
-
-11. Since the Unisys LZW patent has long expired, cjpeg and djpeg can now
-read/write both LZW-compressed and uncompressed GIF files (feature ported from
-jpeg-6a and jpeg-9d.)
-
-12. jpegtran now includes the `-wipe` and `-drop` options from jpeg-9a and
-jpeg-9d, as well as the ability to expand the image size using the `-crop`
-option. Refer to jpegtran.1 or usage.txt for more details.
-
-13. Added a complete intrinsics implementation of the Arm Neon SIMD extensions,
-thus providing SIMD acceleration on Arm platforms for all of the algorithms
-that are SIMD-accelerated on x86 platforms. This new implementation is
-significantly faster in some cases than the old GAS implementation--
-depending on the algorithms used, the type of CPU core, and the compiler. GCC,
-as of this writing, does not provide a full or optimal set of Neon intrinsics,
-so for performance reasons, the default when building libjpeg-turbo with GCC is
-to continue using the GAS implementation of the following algorithms:
-
- - 32-bit RGB-to-YCbCr color conversion
- - 32-bit fast and accurate inverse DCT
- - 64-bit RGB-to-YCbCr and YCbCr-to-RGB color conversion
- - 64-bit accurate forward and inverse DCT
- - 64-bit Huffman encoding
-
- A new CMake variable (`NEON_INTRINSICS`) can be used to override this
-default.
-
- Since the new intrinsics implementation includes SIMD acceleration
-for merged upsampling/color conversion, 1.5.1[5] is no longer necessary and has
-been reverted.
-
-14. The Arm Neon SIMD extensions can now be built using Visual Studio.
-
-15. The build system can now be used to generate a universal x86-64 + Armv8
-libjpeg-turbo SDK package for both iOS and macOS.
-
-
-2.0.6
-=====
-
-### Significant changes relative to 2.0.5:
-
-1. Fixed "using JNI after critical get" errors that occurred on Android
-platforms when using any of the YUV encoding/compression/decompression/decoding
-methods in the TurboJPEG Java API.
-
-2. Fixed or worked around multiple issues with `jpeg_skip_scanlines()`:
-
- - Fixed segfaults or "Corrupt JPEG data: premature end of data segment"
-errors in `jpeg_skip_scanlines()` that occurred when decompressing 4:2:2 or
-4:2:0 JPEG images using merged (non-fancy) upsampling/color conversion (that
-is, when setting `cinfo.do_fancy_upsampling` to `FALSE`.) 2.0.0[6] was a
-similar fix, but it did not cover all cases.
- - `jpeg_skip_scanlines()` now throws an error if two-pass color
-quantization is enabled. Two-pass color quantization never worked properly
-with `jpeg_skip_scanlines()`, and the issues could not readily be fixed.
- - Fixed an issue whereby `jpeg_skip_scanlines()` always returned 0 when
-skipping past the end of an image.
-
-3. The Arm 64-bit (Armv8) Neon SIMD extensions can now be built using MinGW
-toolchains targetting Arm64 (AArch64) Windows binaries.
-
-4. Fixed unexpected visual artifacts that occurred when using
-`jpeg_crop_scanline()` and interblock smoothing while decompressing only the DC
-scan of a progressive JPEG image.
-
-5. Fixed an issue whereby libjpeg-turbo would not build if 12-bit-per-component
-JPEG support (`WITH_12BIT`) was enabled along with libjpeg v7 or libjpeg v8
-API/ABI emulation (`WITH_JPEG7` or `WITH_JPEG8`.)
-
-
-2.0.5
-=====
-
-### Significant changes relative to 2.0.4:
-
-1. Worked around issues in the MIPS DSPr2 SIMD extensions that caused failures
-in the libjpeg-turbo regression tests. Specifically, the
-`jsimd_h2v1_downsample_dspr2()` and `jsimd_h2v2_downsample_dspr2()` functions
-in the MIPS DSPr2 SIMD extensions are now disabled until/unless they can be
-fixed, and other functions that are incompatible with big endian MIPS CPUs are
-disabled when building libjpeg-turbo for such CPUs.
-
-2. Fixed an oversight in the `TJCompressor.compress(int)` method in the
-TurboJPEG Java API that caused an error ("java.lang.IllegalStateException: No
-source image is associated with this instance") when attempting to use that
-method to compress a YUV image.
-
-3. Fixed an issue (CVE-2020-13790) in the PPM reader that caused a buffer
-overrun in cjpeg, TJBench, or the `tjLoadImage()` function if one of the values
-in a binary PPM/PGM input file exceeded the maximum value defined in the file's
-header and that maximum value was less than 255. libjpeg-turbo 1.5.0 already
-included a similar fix for binary PPM/PGM files with maximum values greater
-than 255.
-
-4. The TurboJPEG API library's global error handler, which is used in functions
-such as `tjBufSize()` and `tjLoadImage()` that do not require a TurboJPEG
-instance handle, is now thread-safe on platforms that support thread-local
-storage.
-
-
-2.0.4
-=====
-
-### Significant changes relative to 2.0.3:
-
-1. Fixed a regression in the Windows packaging system (introduced by
-2.0 beta1[2]) whereby, if both the 64-bit libjpeg-turbo SDK for GCC and the
-64-bit libjpeg-turbo SDK for Visual C++ were installed on the same system, only
-one of them could be uninstalled.
-
-2. Fixed a signed integer overflow and subsequent segfault that occurred when
-attempting to decompress images with more than 715827882 pixels using the
-64-bit C version of TJBench.
-
-3. Fixed out-of-bounds write in `tjDecompressToYUV2()` and
-`tjDecompressToYUVPlanes()` (sometimes manifesting as a double free) that
-occurred when attempting to decompress grayscale JPEG images that were
-compressed with a sampling factor other than 1 (for instance, with
-`cjpeg -grayscale -sample 2x2`).
-
-4. Fixed a regression introduced by 2.0.2[5] that caused the TurboJPEG API to
-incorrectly identify some JPEG images with unusual sampling factors as 4:4:4
-JPEG images. This was known to cause a buffer overflow when attempting to
-decompress some such images using `tjDecompressToYUV2()` or
-`tjDecompressToYUVPlanes()`.
-
-5. Fixed an issue (CVE-2020-17541), detected by ASan, whereby attempting to
-losslessly transform a specially-crafted malformed JPEG image containing an
-extremely-high-frequency coefficient block (junk image data that could never be
-generated by a legitimate JPEG compressor) could cause the Huffman encoder's
-local buffer to be overrun. (Refer to 1.4.0[9] and 1.4beta1[15].) Given that
-the buffer overrun was fully contained within the stack and did not cause a
-segfault or other user-visible errant behavior, and given that the lossless
-transformer (unlike the decompressor) is not generally exposed to arbitrary
-data exploits, this issue did not likely pose a security risk.
-
-6. The Arm 64-bit (Armv8) Neon SIMD assembly code now stores constants in a
-separate read-only data section rather than in the text section, to support
-execute-only memory layouts.
-
-
-2.0.3
-=====
-
-### Significant changes relative to 2.0.2:
-
-1. Fixed "using JNI after critical get" errors that occurred on Android
-platforms when passing invalid arguments to certain methods in the TurboJPEG
-Java API.
-
-2. Fixed a regression in the SIMD feature detection code, introduced by
-the AVX2 SIMD extensions (2.0 beta1[1]), that was known to cause an illegal
-instruction exception, in rare cases, on CPUs that lack support for CPUID leaf
-07H (or on which the maximum CPUID leaf has been limited by way of a BIOS
-setting.)
-
-3. The 4:4:0 (h1v2) fancy (smooth) chroma upsampling algorithm in the
-decompressor now uses a similar bias pattern to that of the 4:2:2 (h2v1) fancy
-chroma upsampling algorithm, rounding up or down the upsampled result for
-alternate pixels rather than always rounding down. This ensures that,
-regardless of whether a 4:2:2 JPEG image is rotated or transposed prior to
-decompression (in the frequency domain) or after decompression (in the spatial
-domain), the final image will be similar.
-
-4. Fixed an integer overflow and subsequent segfault that occurred when
-attempting to compress or decompress images with more than 1 billion pixels
-using the TurboJPEG API.
-
-5. Fixed a regression introduced by 2.0 beta1[15] whereby attempting to
-generate a progressive JPEG image on an SSE2-capable CPU using a scan script
-containing one or more scans with lengths divisible by 16 would result in an
-error ("Missing Huffman code table entry") and an invalid JPEG image.
-
-6. Fixed an issue whereby `tjDecodeYUV()` and `tjDecodeYUVPlanes()` would throw
-an error ("Invalid progressive parameters") or a warning ("Inconsistent
-progression sequence") if passed a TurboJPEG instance that was previously used
-to decompress a progressive JPEG image.
-
-
-2.0.2
-=====
-
-### Significant changes relative to 2.0.1:
-
-1. Fixed a regression introduced by 2.0.1[5] that prevented a runtime search
-path (rpath) from being embedded in the libjpeg-turbo shared libraries and
-executables for macOS and iOS. This caused a fatal error of the form
-"dyld: Library not loaded" when attempting to use one of the executables,
-unless `DYLD_LIBRARY_PATH` was explicitly set to the location of the
-libjpeg-turbo shared libraries.
-
-2. Fixed an integer overflow and subsequent segfault (CVE-2018-20330) that
-occurred when attempting to load a BMP file with more than 1 billion pixels
-using the `tjLoadImage()` function.
-
-3. Fixed a buffer overrun (CVE-2018-19664) that occurred when attempting to
-decompress a specially-crafted malformed JPEG image to a 256-color BMP using
-djpeg.
-
-4. Fixed a floating point exception that occurred when attempting to
-decompress a specially-crafted malformed JPEG image with a specified image
-width or height of 0 using the C version of TJBench.
-
-5. The TurboJPEG API will now decompress 4:4:4 JPEG images with 2x1, 1x2, 3x1,
-or 1x3 luminance and chrominance sampling factors. This is a non-standard way
-of specifying 1x subsampling (normally 4:4:4 JPEGs have 1x1 luminance and
-chrominance sampling factors), but the JPEG format and the libjpeg API both
-allow it.
-
-6. Fixed a regression introduced by 2.0 beta1[7] that caused djpeg to generate
-incorrect PPM images when used with the `-colors` option.
-
-7. Fixed an issue whereby a static build of libjpeg-turbo (a build in which
-`ENABLE_SHARED` is `0`) could not be installed using the Visual Studio IDE.
-
-8. Fixed a severe performance issue in the Loongson MMI SIMD extensions that
-occurred when compressing RGB images whose image rows were not 64-bit-aligned.
-
-
-2.0.1
-=====
-
-### Significant changes relative to 2.0.0:
-
-1. Fixed a regression introduced with the new CMake-based Un*x build system,
-whereby jconfig.h could cause compiler warnings of the form
-`"HAVE_*_H" redefined` if it was included by downstream Autotools-based
-projects that used `AC_CHECK_HEADERS()` to check for the existence of locale.h,
-stddef.h, or stdlib.h.
-
-2. The `jsimd_quantize_float_dspr2()` and `jsimd_convsamp_float_dspr2()`
-functions in the MIPS DSPr2 SIMD extensions are now disabled at compile time
-if the soft float ABI is enabled. Those functions use instructions that are
-incompatible with the soft float ABI.
-
-3. Fixed a regression in the SIMD feature detection code, introduced by
-the AVX2 SIMD extensions (2.0 beta1[1]), that caused libjpeg-turbo to crash on
-Windows 7 if Service Pack 1 was not installed.
-
-4. Fixed out-of-bounds read in cjpeg that occurred when attempting to compress
-a specially-crafted malformed color-index (8-bit-per-sample) Targa file in
-which some of the samples (color indices) exceeded the bounds of the Targa
-file's color table.
-
-5. Fixed an issue whereby installing a fully static build of libjpeg-turbo
-(a build in which `CFLAGS` contains `-static` and `ENABLE_SHARED` is `0`) would
-fail with "No valid ELF RPATH or RUNPATH entry exists in the file."
-
-
-2.0.0
-=====
-
-### Significant changes relative to 2.0 beta1:
-
-1. The TurboJPEG API can now decompress CMYK JPEG images that have subsampled M
-and Y components (not to be confused with YCCK JPEG images, in which the C/M/Y
-components have been transformed into luma and chroma.) Previously, an error
-was generated ("Could not determine subsampling type for JPEG image") when such
-an image was passed to `tjDecompressHeader3()`, `tjTransform()`,
-`tjDecompressToYUVPlanes()`, `tjDecompressToYUV2()`, or the equivalent Java
-methods.
-
-2. Fixed an issue (CVE-2018-11813) whereby a specially-crafted malformed input
-file (specifically, a file with a valid Targa header but incomplete pixel data)
-would cause cjpeg to generate a JPEG file that was potentially thousands of
-times larger than the input file. The Targa reader in cjpeg was not properly
-detecting that the end of the input file had been reached prematurely, so after
-all valid pixels had been read from the input, the reader injected dummy pixels
-with values of 255 into the JPEG compressor until the number of pixels
-specified in the Targa header had been compressed. The Targa reader in cjpeg
-now behaves like the PPM reader and aborts compression if the end of the input
-file is reached prematurely. Because this issue only affected cjpeg and not
-the underlying library, and because it did not involve any out-of-bounds reads
-or other exploitable behaviors, it was not believed to represent a security
-threat.
-
-3. Fixed an issue whereby the `tjLoadImage()` and `tjSaveImage()` functions
-would produce a "Bogus message code" error message if the underlying bitmap and
-PPM readers/writers threw an error that was specific to the readers/writers
-(as opposed to a general libjpeg API error.)
-
-4. Fixed an issue (CVE-2018-1152) whereby a specially-crafted malformed BMP
-file, one in which the header specified an image width of 1073741824 pixels,
-would trigger a floating point exception (division by zero) in the
-`tjLoadImage()` function when attempting to load the BMP file into a
-4-component image buffer.
-
-5. Fixed an issue whereby certain combinations of calls to
-`jpeg_skip_scanlines()` and `jpeg_read_scanlines()` could trigger an infinite
-loop when decompressing progressive JPEG images that use vertical chroma
-subsampling (for instance, 4:2:0 or 4:4:0.)
-
-6. Fixed a segfault in `jpeg_skip_scanlines()` that occurred when decompressing
-a 4:2:2 or 4:2:0 JPEG image using the merged (non-fancy) upsampling algorithms
-(that is, when setting `cinfo.do_fancy_upsampling` to `FALSE`.)
-
-7. The new CMake-based build system will now disable the MIPS DSPr2 SIMD
-extensions if it detects that the compiler does not support DSPr2 instructions.
-
-8. Fixed out-of-bounds read in cjpeg (CVE-2018-14498) that occurred when
-attempting to compress a specially-crafted malformed color-index
-(8-bit-per-sample) BMP file in which some of the samples (color indices)
-exceeded the bounds of the BMP file's color table.
-
-9. Fixed a signed integer overflow in the progressive Huffman decoder, detected
-by the Clang and GCC undefined behavior sanitizers, that could be triggered by
-attempting to decompress a specially-crafted malformed JPEG image. This issue
-did not pose a security threat, but removing the warning made it easier to
-detect actual security issues, should they arise in the future.
-
-
-1.5.90 (2.0 beta1)
-==================
-
-### Significant changes relative to 1.5.3:
-
-1. Added AVX2 SIMD implementations of the colorspace conversion, chroma
-downsampling and upsampling, integer quantization and sample conversion, and
-accurate integer DCT/IDCT algorithms. When using the accurate integer DCT/IDCT
-algorithms on AVX2-equipped CPUs, the compression of RGB images is
-approximately 13-36% (avg. 22%) faster (relative to libjpeg-turbo 1.5.x) with
-64-bit code and 11-21% (avg. 17%) faster with 32-bit code, and the
-decompression of RGB images is approximately 9-35% (avg. 17%) faster with
-64-bit code and 7-17% (avg. 12%) faster with 32-bit code. (As tested on a
-3 GHz Intel Core i7. Actual mileage may vary.)
-
-2. Overhauled the build system to use CMake on all platforms, and removed the
-autotools-based build system. This decision resulted from extensive
-discussions within the libjpeg-turbo community. libjpeg-turbo traditionally
-used CMake only for Windows builds, but there was an increasing amount of
-demand to extend CMake support to other platforms. However, because of the
-unique nature of our code base (the need to support different assemblers on
-each platform, the need for Java support, etc.), providing dual build systems
-as other OSS imaging libraries do (including libpng and libtiff) would have
-created a maintenance burden. The use of CMake greatly simplifies some aspects
-of our build system, owing to CMake's built-in support for various assemblers,
-Java, and unit testing, as well as generally fewer quirks that have to be
-worked around in order to implement our packaging system. Eliminating
-autotools puts our project slightly at odds with the traditional practices of
-the OSS community, since most "system libraries" tend to be built with
-autotools, but it is believed that the benefits of this move outweigh the
-risks. In addition to providing a unified build environment, switching to
-CMake allows for the use of various build tools and IDEs that aren't supported
-under autotools, including XCode, Ninja, and Eclipse. It also eliminates the
-need to install autotools via MacPorts/Homebrew on OS X and allows
-libjpeg-turbo to be configured without the use of a terminal/command prompt.
-Extensive testing was conducted to ensure that all features provided by the
-autotools-based build system are provided by the new build system.
-
-3. The libjpeg API in this version of libjpeg-turbo now includes two additional
-functions, `jpeg_read_icc_profile()` and `jpeg_write_icc_profile()`, that can
-be used to extract ICC profile data from a JPEG file while decompressing or to
-embed ICC profile data in a JPEG file while compressing or transforming. This
-eliminates the need for downstream projects, such as color management libraries
-and browsers, to include their own glueware for accomplishing this.
-
-4. Improved error handling in the TurboJPEG API library:
-
- - Introduced a new function (`tjGetErrorStr2()`) in the TurboJPEG C API
-that allows compression/decompression/transform error messages to be retrieved
-in a thread-safe manner. Retrieving error messages from global functions, such
-as `tjInitCompress()` or `tjBufSize()`, is still thread-unsafe, but since those
-functions will only throw errors if passed an invalid argument or if a memory
-allocation failure occurs, thread safety is not as much of a concern.
- - Introduced a new function (`tjGetErrorCode()`) in the TurboJPEG C API
-and a new method (`TJException.getErrorCode()`) in the TurboJPEG Java API that
-can be used to determine the severity of the last
-compression/decompression/transform error. This allows applications to
-choose whether to ignore warnings (non-fatal errors) from the underlying
-libjpeg API or to treat them as fatal.
- - Introduced a new flag (`TJFLAG_STOPONWARNING` in the TurboJPEG C API and
-`TJ.FLAG_STOPONWARNING` in the TurboJPEG Java API) that causes the library to
-immediately halt a compression/decompression/transform operation if it
-encounters a warning from the underlying libjpeg API (the default behavior is
-to allow the operation to complete unless a fatal error is encountered.)
-
-5. Introduced a new flag in the TurboJPEG C and Java APIs (`TJFLAG_PROGRESSIVE`
-and `TJ.FLAG_PROGRESSIVE`, respectively) that causes the library to use
-progressive entropy coding in JPEG images generated by compression and
-transform operations. Additionally, a new transform option
-(`TJXOPT_PROGRESSIVE` in the C API and `TJTransform.OPT_PROGRESSIVE` in the
-Java API) has been introduced, allowing progressive entropy coding to be
-enabled for selected transforms in a multi-transform operation.
-
-6. Introduced a new transform option in the TurboJPEG API (`TJXOPT_COPYNONE` in
-the C API and `TJTransform.OPT_COPYNONE` in the Java API) that allows the
-copying of markers (including EXIF and ICC profile data) to be disabled for a
-particular transform.
-
-7. Added two functions to the TurboJPEG C API (`tjLoadImage()` and
-`tjSaveImage()`) that can be used to load/save a BMP or PPM/PGM image to/from a
-memory buffer with a specified pixel format and layout. These functions
-replace the project-private (and slow) bmp API, which was previously used by
-TJBench, and they also provide a convenient way for first-time users of
-libjpeg-turbo to quickly develop a complete JPEG compression/decompression
-program.
-
-8. The TurboJPEG C API now includes a new convenience array (`tjAlphaOffset[]`)
-that contains the alpha component index for each pixel format (or -1 if the
-pixel format lacks an alpha component.) The TurboJPEG Java API now includes a
-new method (`TJ.getAlphaOffset()`) that returns the same value. In addition,
-the `tjRedOffset[]`, `tjGreenOffset[]`, and `tjBlueOffset[]` arrays-- and the
-corresponding `TJ.getRedOffset()`, `TJ.getGreenOffset()`, and
-`TJ.getBlueOffset()` methods-- now return -1 for `TJPF_GRAY`/`TJ.PF_GRAY`
-rather than 0. This allows programs to easily determine whether a pixel format
-has red, green, blue, and alpha components.
-
-9. Added a new example (tjexample.c) that demonstrates the basic usage of the
-TurboJPEG C API. This example mirrors the functionality of TJExample.java.
-Both files are now included in the libjpeg-turbo documentation.
-
-10. Fixed two signed integer overflows in the arithmetic decoder, detected by
-the Clang undefined behavior sanitizer, that could be triggered by attempting
-to decompress a specially-crafted malformed JPEG image. These issues did not
-pose a security threat, but removing the warnings makes it easier to detect
-actual security issues, should they arise in the future.
-
-11. Fixed a bug in the merged 4:2:0 upsampling/dithered RGB565 color conversion
-algorithm that caused incorrect dithering in the output image. This algorithm
-now produces bitwise-identical results to the unmerged algorithms.
-
-12. The SIMD function symbols for x86[-64]/ELF, MIPS/ELF, macOS/x86[-64] (if
-libjpeg-turbo is built with Yasm), and iOS/Arm[64] builds are now private.
-This prevents those symbols from being exposed in applications or shared
-libraries that link statically with libjpeg-turbo.
-
-13. Added Loongson MMI SIMD implementations of the RGB-to-YCbCr and
-YCbCr-to-RGB colorspace conversion, 4:2:0 chroma downsampling, 4:2:0 fancy
-chroma upsampling, integer quantization, and accurate integer DCT/IDCT
-algorithms. When using the accurate integer DCT/IDCT, this speeds up the
-compression of RGB images by approximately 70-100% and the decompression of RGB
-images by approximately 2-3.5x.
-
-14. Fixed a build error when building with older MinGW releases (regression
-caused by 1.5.1[7].)
-
-15. Added SIMD acceleration for progressive Huffman encoding on SSE2-capable
-x86 and x86-64 platforms. This speeds up the compression of full-color
-progressive JPEGs by about 85-90% on average (relative to libjpeg-turbo 1.5.x)
-when using modern Intel and AMD CPUs.
-
-
-1.5.3
-=====
-
-### Significant changes relative to 1.5.2:
-
-1. Fixed a NullPointerException in the TurboJPEG Java wrapper that occurred
-when using the YUVImage constructor that creates an instance backed by separate
-image planes and allocates memory for the image planes.
-
-2. Fixed an issue whereby the Java version of TJUnitTest would fail when
-testing BufferedImage encoding/decoding on big endian systems.
-
-3. Fixed a segfault in djpeg that would occur if an output format other than
-PPM/PGM was selected along with the `-crop` option. The `-crop` option now
-works with the GIF and Targa formats as well (unfortunately, it cannot be made
-to work with the BMP and RLE formats due to the fact that those output engines
-write scanlines in bottom-up order.) djpeg will now exit gracefully if an
-output format other than PPM/PGM, GIF, or Targa is selected along with the
-`-crop` option.
-
-4. Fixed an issue (CVE-2017-15232) whereby `jpeg_skip_scanlines()` would
-segfault if color quantization was enabled.
-
-5. TJBench (both C and Java versions) will now display usage information if any
-command-line argument is unrecognized. This prevents the program from silently
-ignoring typos.
-
-6. Fixed an access violation in tjbench.exe (Windows) that occurred when the
-program was used to decompress an existing JPEG image.
-
-7. Fixed an ArrayIndexOutOfBoundsException in the TJExample Java program that
-occurred when attempting to decompress a JPEG image that had been compressed
-with 4:1:1 chrominance subsampling.
-
-8. Fixed an issue whereby, when using `jpeg_skip_scanlines()` to skip to the
-end of a single-scan (non-progressive) image, subsequent calls to
-`jpeg_consume_input()` would return `JPEG_SUSPENDED` rather than
-`JPEG_REACHED_EOI`.
-
-9. `jpeg_crop_scanline()` now works correctly when decompressing grayscale JPEG
-images that were compressed with a sampling factor other than 1 (for instance,
-with `cjpeg -grayscale -sample 2x2`).
-
-
-1.5.2
-=====
-
-### Significant changes relative to 1.5.1:
-
-1. Fixed a regression introduced by 1.5.1[7] that prevented libjpeg-turbo from
-building with Android NDK platforms prior to android-21 (5.0).
-
-2. Fixed a regression introduced by 1.5.1[1] that prevented the MIPS DSPR2 SIMD
-code in libjpeg-turbo from building.
-
-3. Fixed a regression introduced by 1.5 beta1[11] that prevented the Java
-version of TJBench from outputting any reference images (the `-nowrite` switch
-was accidentally enabled by default.)
-
-4. libjpeg-turbo should now build and run with full AltiVec SIMD acceleration
-on PowerPC-based AmigaOS 4 and OpenBSD systems.
-
-5. Fixed build and runtime errors on Windows that occurred when building
-libjpeg-turbo with libjpeg v7 API/ABI emulation and the in-memory
-source/destination managers. Due to an oversight, the `jpeg_skip_scanlines()`
-and `jpeg_crop_scanline()` functions were not being included in jpeg7.dll when
-libjpeg-turbo was built with `-DWITH_JPEG7=1` and `-DWITH_MEMSRCDST=1`.
-
-6. Fixed "Bogus virtual array access" error that occurred when using the
-lossless crop feature in jpegtran or the TurboJPEG API, if libjpeg-turbo was
-built with libjpeg v7 API/ABI emulation. This was apparently a long-standing
-bug that has existed since the introduction of libjpeg v7/v8 API/ABI emulation
-in libjpeg-turbo v1.1.
-
-7. The lossless transform features in jpegtran and the TurboJPEG API will now
-always attempt to adjust the EXIF image width and height tags if the image size
-changed as a result of the transform. This behavior has always existed when
-using libjpeg v8 API/ABI emulation. It was supposed to be available with
-libjpeg v7 API/ABI emulation as well but did not work properly due to a bug.
-Furthermore, there was never any good reason not to enable it with libjpeg v6b
-API/ABI emulation, since the behavior is entirely internal. Note that
-`-copy all` must be passed to jpegtran in order to transfer the EXIF tags from
-the source image to the destination image.
-
-8. Fixed several memory leaks in the TurboJPEG API library that could occur
-if the library was built with certain compilers and optimization levels
-(known to occur with GCC 4.x and clang with `-O1` and higher but not with
-GCC 5.x or 6.x) and one of the underlying libjpeg API functions threw an error
-after a TurboJPEG API function allocated a local buffer.
-
-9. The libjpeg-turbo memory manager will now honor the `max_memory_to_use`
-structure member in jpeg\_memory\_mgr, which can be set to the maximum amount
-of memory (in bytes) that libjpeg-turbo should use during decompression or
-multi-pass (including progressive) compression. This limit can also be set
-using the `JPEGMEM` environment variable or using the `-maxmemory` switch in
-cjpeg/djpeg/jpegtran (refer to the respective man pages for more details.)
-This has been a documented feature of libjpeg since v5, but the
-`malloc()`/`free()` implementation of the memory manager (jmemnobs.c) never
-implemented the feature. Restricting libjpeg-turbo's memory usage is useful
-for two reasons: it allows testers to more easily work around the 2 GB limit
-in libFuzzer, and it allows developers of security-sensitive applications to
-more easily defend against one of the progressive JPEG exploits (LJT-01-004)
-identified in
-[this report](http://www.libjpeg-turbo.org/pmwiki/uploads/About/TwoIssueswiththeJPEGStandard.pdf).
-
-10. TJBench will now run each benchmark for 1 second prior to starting the
-timer, in order to improve the consistency of the results. Furthermore, the
-`-warmup` option is now used to specify the amount of warmup time rather than
-the number of warmup iterations.
-
-11. Fixed an error (`short jump is out of range`) that occurred when assembling
-the 32-bit x86 SIMD extensions with NASM versions prior to 2.04. This was a
-regression introduced by 1.5 beta1[12].
-
-
-1.5.1
-=====
-
-### Significant changes relative to 1.5.0:
-
-1. Previously, the undocumented `JSIMD_FORCE*` environment variables could be
-used to force-enable a particular SIMD instruction set if multiple instruction
-sets were available on a particular platform. On x86 platforms, where CPU
-feature detection is bulletproof and multiple SIMD instruction sets are
-available, it makes sense for those environment variables to allow forcing the
-use of an instruction set only if that instruction set is available. However,
-since the ARM implementations of libjpeg-turbo can only use one SIMD
-instruction set, and since their feature detection code is less bulletproof
-(parsing /proc/cpuinfo), it makes sense for the `JSIMD_FORCENEON` environment
-variable to bypass the feature detection code and really force the use of NEON
-instructions. A new environment variable (`JSIMD_FORCEDSPR2`) was introduced
-in the MIPS implementation for the same reasons, and the existing
-`JSIMD_FORCENONE` environment variable was extended to that implementation.
-These environment variables provide a workaround for those attempting to test
-ARM and MIPS builds of libjpeg-turbo in QEMU, which passes through
-/proc/cpuinfo from the host system.
-
-2. libjpeg-turbo previously assumed that AltiVec instructions were always
-available on PowerPC platforms, which led to "illegal instruction" errors when
-running on PowerPC chips that lack AltiVec support (such as the older 7xx/G3
-and newer e5500 series.) libjpeg-turbo now examines /proc/cpuinfo on
-Linux/Android systems and enables AltiVec instructions only if the CPU supports
-them. It also now provides two environment variables, `JSIMD_FORCEALTIVEC` and
-`JSIMD_FORCENONE`, to force-enable and force-disable AltiVec instructions in
-environments where /proc/cpuinfo is an unreliable means of CPU feature
-detection (such as when running in QEMU.) On OS X, libjpeg-turbo continues to
-assume that AltiVec support is always available, which means that libjpeg-turbo
-cannot be used with G3 Macs unless you set the environment variable
-`JSIMD_FORCENONE` to `1`.
-
-3. Fixed an issue whereby 64-bit ARM (AArch64) builds of libjpeg-turbo would
-crash when built with recent releases of the Clang/LLVM compiler. This was
-caused by an ABI conformance issue in some of libjpeg-turbo's 64-bit NEON SIMD
-routines. Those routines were incorrectly using 64-bit instructions to
-transfer a 32-bit JDIMENSION argument, whereas the ABI allows the upper
-(unused) 32 bits of a 32-bit argument's register to be undefined. The new
-Clang/LLVM optimizer uses load combining to transfer multiple adjacent 32-bit
-structure members into a single 64-bit register, and this exposed the ABI
-conformance issue.
-
-4. Fancy upsampling is now supported when decompressing JPEG images that use
-4:4:0 (h1v2) chroma subsampling. These images are generated when losslessly
-rotating or transposing JPEG images that use 4:2:2 (h2v1) chroma subsampling.
-The h1v2 fancy upsampling algorithm is not currently SIMD-accelerated.
-
-5. If merged upsampling isn't SIMD-accelerated but YCbCr-to-RGB conversion is,
-then libjpeg-turbo will now disable merged upsampling when decompressing YCbCr
-JPEG images into RGB or extended RGB output images. This significantly speeds
-up the decompression of 4:2:0 and 4:2:2 JPEGs on ARM platforms if fancy
-upsampling is not used (for example, if the `-nosmooth` option to djpeg is
-specified.)
-
-6. The TurboJPEG API will now decompress 4:2:2 and 4:4:0 JPEG images with
-2x2 luminance sampling factors and 2x1 or 1x2 chrominance sampling factors.
-This is a non-standard way of specifying 2x subsampling (normally 4:2:2 JPEGs
-have 2x1 luminance and 1x1 chrominance sampling factors, and 4:4:0 JPEGs have
-1x2 luminance and 1x1 chrominance sampling factors), but the JPEG format and
-the libjpeg API both allow it.
-
-7. Fixed an unsigned integer overflow in the libjpeg memory manager, detected
-by the Clang undefined behavior sanitizer, that could be triggered by
-attempting to decompress a specially-crafted malformed JPEG image. This issue
-affected only 32-bit code and did not pose a security threat, but removing the
-warning makes it easier to detect actual security issues, should they arise in
-the future.
-
-8. Fixed additional negative left shifts and other issues reported by the GCC
-and Clang undefined behavior sanitizers when attempting to decompress
-specially-crafted malformed JPEG images. None of these issues posed a security
-threat, but removing the warnings makes it easier to detect actual security
-issues, should they arise in the future.
-
-9. Fixed an out-of-bounds array reference, introduced by 1.4.90[2] (partial
-image decompression) and detected by the Clang undefined behavior sanitizer,
-that could be triggered by a specially-crafted malformed JPEG image with more
-than four components. Because the out-of-bounds reference was still within the
-same structure, it was not known to pose a security threat, but removing the
-warning makes it easier to detect actual security issues, should they arise in
-the future.
-
-10. Fixed another ABI conformance issue in the 64-bit ARM (AArch64) NEON SIMD
-code. Some of the routines were incorrectly reading and storing data below the
-stack pointer, which caused segfaults in certain applications under specific
-circumstances.
-
-
-1.5.0
-=====
-
-### Significant changes relative to 1.5 beta1:
-
-1. Fixed an issue whereby a malformed motion-JPEG frame could cause the "fast
-path" of libjpeg-turbo's Huffman decoder to read from uninitialized memory.
-
-2. Added libjpeg-turbo version and build information to the global string table
-of the libjpeg and TurboJPEG API libraries. This is a common practice in other
-infrastructure libraries, such as OpenSSL and libpng, because it makes it easy
-to examine an application binary and determine which version of the library the
-application was linked against.
-
-3. Fixed a couple of issues in the PPM reader that would cause buffer overruns
-in cjpeg if one of the values in a binary PPM/PGM input file exceeded the
-maximum value defined in the file's header and that maximum value was greater
-than 255. libjpeg-turbo 1.4.2 already included a similar fix for ASCII PPM/PGM
-files. Note that these issues were not security bugs, since they were confined
-to the cjpeg program and did not affect any of the libjpeg-turbo libraries.
-
-4. Fixed an issue whereby attempting to decompress a JPEG file with a corrupt
-header using the `tjDecompressToYUV2()` function would cause the function to
-abort without returning an error and, under certain circumstances, corrupt the
-stack. This only occurred if `tjDecompressToYUV2()` was called prior to
-calling `tjDecompressHeader3()`, or if the return value from
-`tjDecompressHeader3()` was ignored (both cases represent incorrect usage of
-the TurboJPEG API.)
-
-5. Fixed an issue in the ARM 32-bit SIMD-accelerated Huffman encoder that
-prevented the code from assembling properly with clang.
-
-6. The `jpeg_stdio_src()`, `jpeg_mem_src()`, `jpeg_stdio_dest()`, and
-`jpeg_mem_dest()` functions in the libjpeg API will now throw an error if a
-source/destination manager has already been assigned to the compress or
-decompress object by a different function or by the calling program. This
-prevents these functions from attempting to reuse a source/destination manager
-structure that was allocated elsewhere, because there is no way to ensure that
-it would be big enough to accommodate the new source/destination manager.
-
-
-1.4.90 (1.5 beta1)
-==================
-
-### Significant changes relative to 1.4.2:
-
-1. Added full SIMD acceleration for PowerPC platforms using AltiVec VMX
-(128-bit SIMD) instructions. Although the performance of libjpeg-turbo on
-PowerPC was already good, due to the increased number of registers available
-to the compiler vs. x86, it was still possible to speed up compression by about
-3-4x and decompression by about 2-2.5x (relative to libjpeg v6b) through the
-use of AltiVec instructions.
-
-2. Added two new libjpeg API functions (`jpeg_skip_scanlines()` and
-`jpeg_crop_scanline()`) that can be used to partially decode a JPEG image. See
-[libjpeg.txt](libjpeg.txt) for more details.
-
-3. The TJCompressor and TJDecompressor classes in the TurboJPEG Java API now
-implement the Closeable interface, so those classes can be used with a
-try-with-resources statement.
-
-4. The TurboJPEG Java classes now throw unchecked idiomatic exceptions
-(IllegalArgumentException, IllegalStateException) for unrecoverable errors
-caused by incorrect API usage, and those classes throw a new checked exception
-type (TJException) for errors that are passed through from the C library.
-
-5. Source buffers for the TurboJPEG C API functions, as well as the
-`jpeg_mem_src()` function in the libjpeg API, are now declared as const
-pointers. This facilitates passing read-only buffers to those functions and
-ensures the caller that the source buffer will not be modified. This should
-not create any backward API or ABI incompatibilities with prior libjpeg-turbo
-releases.
-
-6. The MIPS DSPr2 SIMD code can now be compiled to support either FR=0 or FR=1
-FPUs.
-
-7. Fixed additional negative left shifts and other issues reported by the GCC
-and Clang undefined behavior sanitizers. Most of these issues affected only
-32-bit code, and none of them was known to pose a security threat, but removing
-the warnings makes it easier to detect actual security issues, should they
-arise in the future.
-
-8. Removed the unnecessary `.arch` directive from the ARM64 NEON SIMD code.
-This directive was preventing the code from assembling using the clang
-integrated assembler.
-
-9. Fixed a regression caused by 1.4.1[6] that prevented 32-bit and 64-bit
-libjpeg-turbo RPMs from being installed simultaneously on recent Red Hat/Fedora
-distributions. This was due to the addition of a macro in jconfig.h that
-allows the Huffman codec to determine the word size at compile time. Since
-that macro differs between 32-bit and 64-bit builds, this caused a conflict
-between the i386 and x86_64 RPMs (any differing files, other than executables,
-are not allowed when 32-bit and 64-bit RPMs are installed simultaneously.)
-Since the macro is used only internally, it has been moved into jconfigint.h.
-
-10. The x86-64 SIMD code can now be disabled at run time by setting the
-`JSIMD_FORCENONE` environment variable to `1` (the other SIMD implementations
-already had this capability.)
-
-11. Added a new command-line argument to TJBench (`-nowrite`) that prevents the
-benchmark from outputting any images. This removes any potential operating
-system overhead that might be caused by lazy writes to disk and thus improves
-the consistency of the performance measurements.
-
-12. Added SIMD acceleration for Huffman encoding on SSE2-capable x86 and x86-64
-platforms. This speeds up the compression of full-color JPEGs by about 10-15%
-on average (relative to libjpeg-turbo 1.4.x) when using modern Intel and AMD
-CPUs. Additionally, this works around an issue in the clang optimizer that
-prevents it (as of this writing) from achieving the same performance as GCC
-when compiling the C version of the Huffman encoder
-(<https://llvm.org/bugs/show_bug.cgi?id=16035>). For the purposes of
-benchmarking or regression testing, SIMD-accelerated Huffman encoding can be
-disabled by setting the `JSIMD_NOHUFFENC` environment variable to `1`.
-
-13. Added ARM 64-bit (ARMv8) NEON SIMD implementations of the commonly-used
-compression algorithms (including the accurate integer forward DCT and h2v2 &
-h2v1 downsampling algorithms, which are not accelerated in the 32-bit NEON
-implementation.) This speeds up the compression of full-color JPEGs by about
-75% on average on a Cavium ThunderX processor and by about 2-2.5x on average on
-Cortex-A53 and Cortex-A57 cores.
-
-14. Added SIMD acceleration for Huffman encoding on NEON-capable ARM 32-bit
-and 64-bit platforms.
-
- For 32-bit code, this speeds up the compression of full-color JPEGs by
-about 30% on average on a typical iOS device (iPhone 4S, Cortex-A9) and by
-about 6-7% on average on a typical Android device (Nexus 5X, Cortex-A53 and
-Cortex-A57), relative to libjpeg-turbo 1.4.x. Note that the larger speedup
-under iOS is due to the fact that iOS builds use LLVM, which does not optimize
-the C Huffman encoder as well as GCC does.
-
- For 64-bit code, NEON-accelerated Huffman encoding speeds up the
-compression of full-color JPEGs by about 40% on average on a typical iOS device
-(iPhone 5S, Apple A7) and by about 7-8% on average on a typical Android device
-(Nexus 5X, Cortex-A53 and Cortex-A57), in addition to the speedup described in
-[13] above.
-
- For the purposes of benchmarking or regression testing, SIMD-accelerated
-Huffman encoding can be disabled by setting the `JSIMD_NOHUFFENC` environment
-variable to `1`.
-
-15. pkg-config (.pc) scripts are now included for both the libjpeg and
-TurboJPEG API libraries on Un*x systems. Note that if a project's build system
-relies on these scripts, then it will not be possible to build that project
-with libjpeg or with a prior version of libjpeg-turbo.
-
-16. Optimized the ARM 64-bit (ARMv8) NEON SIMD decompression routines to
-improve performance on CPUs with in-order pipelines. This speeds up the
-decompression of full-color JPEGs by nearly 2x on average on a Cavium ThunderX
-processor and by about 15% on average on a Cortex-A53 core.
-
-17. Fixed an issue in the accelerated Huffman decoder that could have caused
-the decoder to read past the end of the input buffer when a malformed,
-specially-crafted JPEG image was being decompressed. In prior versions of
-libjpeg-turbo, the accelerated Huffman decoder was invoked (in most cases) only
-if there were > 128 bytes of data in the input buffer. However, it is possible
-to construct a JPEG image in which a single Huffman block is over 430 bytes
-long, so this version of libjpeg-turbo activates the accelerated Huffman
-decoder only if there are > 512 bytes of data in the input buffer.
-
-18. Fixed a memory leak in tjunittest encountered when running the program
-with the `-yuv` option.
-
-
-1.4.2
-=====
-
-### Significant changes relative to 1.4.1:
-
-1. Fixed an issue whereby cjpeg would segfault if a Windows bitmap with a
-negative width or height was used as an input image (Windows bitmaps can have
-a negative height if they are stored in top-down order, but such files are
-rare and not supported by libjpeg-turbo.)
-
-2. Fixed an issue whereby, under certain circumstances, libjpeg-turbo would
-incorrectly encode certain JPEG images when quality=100 and the fast integer
-forward DCT were used. This was known to cause `make test` to fail when the
-library was built with `-march=haswell` on x86 systems.
-
-3. Fixed an issue whereby libjpeg-turbo would crash when built with the latest
-& greatest development version of the Clang/LLVM compiler. This was caused by
-an x86-64 ABI conformance issue in some of libjpeg-turbo's 64-bit SSE2 SIMD
-routines. Those routines were incorrectly using a 64-bit `mov` instruction to
-transfer a 32-bit JDIMENSION argument, whereas the x86-64 ABI allows the upper
-(unused) 32 bits of a 32-bit argument's register to be undefined. The new
-Clang/LLVM optimizer uses load combining to transfer multiple adjacent 32-bit
-structure members into a single 64-bit register, and this exposed the ABI
-conformance issue.
-
-4. Fixed a bug in the MIPS DSPr2 4:2:0 "plain" (non-fancy and non-merged)
-upsampling routine that caused a buffer overflow (and subsequent segfault) when
-decompressing a 4:2:0 JPEG image whose scaled output width was less than 16
-pixels. The "plain" upsampling routines are normally only used when
-decompressing a non-YCbCr JPEG image, but they are also used when decompressing
-a JPEG image whose scaled output height is 1.
-
-5. Fixed various negative left shifts and other issues reported by the GCC and
-Clang undefined behavior sanitizers. None of these was known to pose a
-security threat, but removing the warnings makes it easier to detect actual
-security issues, should they arise in the future.
-
-
-1.4.1
-=====
-
-### Significant changes relative to 1.4.0:
-
-1. tjbench now properly handles CMYK/YCCK JPEG files. Passing an argument of
-`-cmyk` (instead of, for instance, `-rgb`) will cause tjbench to internally
-convert the source bitmap to CMYK prior to compression, to generate YCCK JPEG
-files, and to internally convert the decompressed CMYK pixels back to RGB after
-decompression (the latter is done automatically if a CMYK or YCCK JPEG is
-passed to tjbench as a source image.) The CMYK<->RGB conversion operation is
-not benchmarked. NOTE: The quick & dirty CMYK<->RGB conversions that tjbench
-uses are suitable for testing only. Proper conversion between CMYK and RGB
-requires a color management system.
-
-2. `make test` now performs additional bitwise regression tests using tjbench,
-mainly for the purpose of testing compression from/decompression to a subregion
-of a larger image buffer.
-
-3. `make test` no longer tests the regression of the floating point DCT/IDCT
-by default, since the results of those tests can vary if the algorithms in
-question are not implemented using SIMD instructions on a particular platform.
-See the comments in [Makefile.am](Makefile.am) for information on how to
-re-enable the tests and to specify an expected result for them based on the
-particulars of your platform.
-
-4. The NULL color conversion routines have been significantly optimized,
-which speeds up the compression of RGB and CMYK JPEGs by 5-20% when using
-64-bit code and 0-3% when using 32-bit code, and the decompression of those
-images by 10-30% when using 64-bit code and 3-12% when using 32-bit code.
-
-5. Fixed an "illegal instruction" error that occurred when djpeg from a
-SIMD-enabled libjpeg-turbo MIPS build was executed with the `-nosmooth` option
-on a MIPS machine that lacked DSPr2 support. The MIPS SIMD routines for h2v1
-and h2v2 merged upsampling were not properly checking for the existence of
-DSPr2.
-
-6. Performance has been improved significantly on 64-bit non-Linux and
-non-Windows platforms (generally 10-20% faster compression and 5-10% faster
-decompression.) Due to an oversight, the 64-bit version of the accelerated
-Huffman codec was not being compiled in when libjpeg-turbo was built on
-platforms other than Windows or Linux. Oops.
-
-7. Fixed an extremely rare bug in the Huffman encoder that caused 64-bit
-builds of libjpeg-turbo to incorrectly encode a few specific test images when
-quality=98, an optimized Huffman table, and the accurate integer forward DCT
-were used.
-
-8. The Windows (CMake) build system now supports building only static or only
-shared libraries. This is accomplished by adding either `-DENABLE_STATIC=0` or
-`-DENABLE_SHARED=0` to the CMake command line.
-
-9. TurboJPEG API functions will now return an error code if a warning is
-triggered in the underlying libjpeg API. For instance, if a JPEG file is
-corrupt, the TurboJPEG decompression functions will attempt to decompress
-as much of the image as possible, but those functions will now return -1 to
-indicate that the decompression was not entirely successful.
-
-10. Fixed a bug in the MIPS DSPr2 4:2:2 fancy upsampling routine that caused a
-buffer overflow (and subsequent segfault) when decompressing a 4:2:2 JPEG image
-in which the right-most MCU was 5 or 6 pixels wide.
-
-
-1.4.0
-=====
-
-### Significant changes relative to 1.4 beta1:
-
-1. Fixed a build issue on OS X PowerPC platforms (md5cmp failed to build
-because OS X does not provide the `le32toh()` and `htole32()` functions.)
-
-2. The non-SIMD RGB565 color conversion code did not work correctly on big
-endian machines. This has been fixed.
-
-3. Fixed an issue in `tjPlaneSizeYUV()` whereby it would erroneously return 1
-instead of -1 if `componentID` was > 0 and `subsamp` was `TJSAMP_GRAY`.
-
-3. Fixed an issue in `tjBufSizeYUV2()` whereby it would erroneously return 0
-instead of -1 if `width` was < 1.
-
-5. The Huffman encoder now uses `clz` and `bsr` instructions for bit counting
-on ARM64 platforms (see 1.4 beta1[5].)
-
-6. The `close()` method in the TJCompressor and TJDecompressor Java classes is
-now idempotent. Previously, that method would call the native `tjDestroy()`
-function even if the TurboJPEG instance had already been destroyed. This
-caused an exception to be thrown during finalization, if the `close()` method
-had already been called. The exception was caught, but it was still an
-expensive operation.
-
-7. The TurboJPEG API previously generated an error (`Could not determine
-subsampling type for JPEG image`) when attempting to decompress grayscale JPEG
-images that were compressed with a sampling factor other than 1 (for instance,
-with `cjpeg -grayscale -sample 2x2`). Subsampling technically has no meaning
-with grayscale JPEGs, and thus the horizontal and vertical sampling factors
-for such images are ignored by the decompressor. However, the TurboJPEG API
-was being too rigid and was expecting the sampling factors to be equal to 1
-before it treated the image as a grayscale JPEG.
-
-8. cjpeg, djpeg, and jpegtran now accept an argument of `-version`, which will
-print the library version and exit.
-
-9. Referring to 1.4 beta1[15], another extremely rare circumstance was
-discovered under which the Huffman encoder's local buffer can be overrun
-when a buffered destination manager is being used and an
-extremely-high-frequency block (basically junk image data) is being encoded.
-Even though the Huffman local buffer was increased from 128 bytes to 136 bytes
-to address the previous issue, the new issue caused even the larger buffer to
-be overrun. Further analysis reveals that, in the absolute worst case (such as
-setting alternating AC coefficients to 32767 and -32768 in the JPEG scanning
-order), the Huffman encoder can produce encoded blocks that approach double the
-size of the unencoded blocks. Thus, the Huffman local buffer was increased to
-256 bytes, which should prevent any such issue from re-occurring in the future.
-
-10. The new `tjPlaneSizeYUV()`, `tjPlaneWidth()`, and `tjPlaneHeight()`
-functions were not actually usable on any platform except OS X and Windows,
-because those functions were not included in the libturbojpeg mapfile. This
-has been fixed.
-
-11. Restored the `JPP()`, `JMETHOD()`, and `FAR` macros in the libjpeg-turbo
-header files. The `JPP()` and `JMETHOD()` macros were originally implemented
-in libjpeg as a way of supporting non-ANSI compilers that lacked support for
-prototype parameters. libjpeg-turbo has never supported such compilers, but
-some software packages still use the macros to define their own prototypes.
-Similarly, libjpeg-turbo has never supported MS-DOS and other platforms that
-have far symbols, but some software packages still use the `FAR` macro. A
-pretty good argument can be made that this is a bad practice on the part of the
-software in question, but since this affects more than one package, it's just
-easier to fix it here.
-
-12. Fixed issues that were preventing the ARM 64-bit SIMD code from compiling
-for iOS, and included an ARMv8 architecture in all of the binaries installed by
-the "official" libjpeg-turbo SDK for OS X.
-
-
-1.3.90 (1.4 beta1)
-==================
-
-### Significant changes relative to 1.3.1:
-
-1. New features in the TurboJPEG API:
-
- - YUV planar images can now be generated with an arbitrary line padding
-(previously only 4-byte padding, which was compatible with X Video, was
-supported.)
- - The decompress-to-YUV function has been extended to support image
-scaling.
- - JPEG images can now be compressed from YUV planar source images.
- - YUV planar images can now be decoded into RGB or grayscale images.
- - 4:1:1 subsampling is now supported. This is mainly included for
-compatibility, since 4:1:1 is not fully accelerated in libjpeg-turbo and has no
-significant advantages relative to 4:2:0.
- - CMYK images are now supported. This feature allows CMYK source images
-to be compressed to YCCK JPEGs and YCCK or CMYK JPEGs to be decompressed to
-CMYK destination images. Conversion between CMYK/YCCK and RGB or YUV images is
-not supported. Such conversion requires a color management system and is thus
-out of scope for a codec library.
- - The handling of YUV images in the Java API has been significantly
-refactored and should now be much more intuitive.
- - The Java API now supports encoding a YUV image from an arbitrary
-position in a large image buffer.
- - All of the YUV functions now have a corresponding function that operates
-on separate image planes instead of a unified image buffer. This allows for
-compressing/decoding from or decompressing/encoding to a subregion of a larger
-YUV image. It also allows for handling YUV formats that swap the order of the
-U and V planes.
-
-2. Added SIMD acceleration for DSPr2-capable MIPS platforms. This speeds up
-the compression of full-color JPEGs by 70-80% on such platforms and
-decompression by 25-35%.
-
-3. If an application attempts to decompress a Huffman-coded JPEG image whose
-header does not contain Huffman tables, libjpeg-turbo will now insert the
-default Huffman tables. In order to save space, many motion JPEG video frames
-are encoded without the default Huffman tables, so these frames can now be
-successfully decompressed by libjpeg-turbo without additional work on the part
-of the application. An application can still override the Huffman tables, for
-instance to re-use tables from a previous frame of the same video.
-
-4. The Mac packaging system now uses pkgbuild and productbuild rather than
-PackageMaker (which is obsolete and no longer supported.) This means that
-OS X 10.6 "Snow Leopard" or later must be used when packaging libjpeg-turbo,
-although the packages produced can be installed on OS X 10.5 "Leopard" or
-later. OS X 10.4 "Tiger" is no longer supported.
-
-5. The Huffman encoder now uses `clz` and `bsr` instructions for bit counting
-on ARM platforms rather than a lookup table. This reduces the memory footprint
-by 64k, which may be important for some mobile applications. Out of four
-Android devices that were tested, two demonstrated a small overall performance
-loss (~3-4% on average) with ARMv6 code and a small gain (also ~3-4%) with
-ARMv7 code when enabling this new feature, but the other two devices
-demonstrated a significant overall performance gain with both ARMv6 and ARMv7
-code (~10-20%) when enabling the feature. Actual mileage may vary.
-
-6. Worked around an issue with Visual C++ 2010 and later that caused incorrect
-pixels to be generated when decompressing a JPEG image to a 256-color bitmap,
-if compiler optimization was enabled when libjpeg-turbo was built. This caused
-the regression tests to fail when doing a release build under Visual C++ 2010
-and later.
-
-7. Improved the accuracy and performance of the non-SIMD implementation of the
-floating point inverse DCT (using code borrowed from libjpeg v8a and later.)
-The accuracy of this implementation now matches the accuracy of the SSE/SSE2
-implementation. Note, however, that the floating point DCT/IDCT algorithms are
-mainly a legacy feature. They generally do not produce significantly better
-accuracy than the accurate integer DCT/IDCT algorithms, and they are quite a
-bit slower.
-
-8. Added a new output colorspace (`JCS_RGB565`) to the libjpeg API that allows
-for decompressing JPEG images into RGB565 (16-bit) pixels. If dithering is not
-used, then this code path is SIMD-accelerated on ARM platforms.
-
-9. Numerous obsolete features, such as support for non-ANSI compilers and
-support for the MS-DOS memory model, were removed from the libjpeg code,
-greatly improving its readability and making it easier to maintain and extend.
-
-10. Fixed a segfault that occurred when calling `output_message()` with
-`msg_code` set to `JMSG_COPYRIGHT`.
-
-11. Fixed an issue whereby wrjpgcom was allowing comments longer than 65k
-characters to be passed on the command line, which was causing it to generate
-incorrect JPEG files.
-
-12. Fixed a bug in the build system that was causing the Windows version of
-wrjpgcom to be built using the rdjpgcom source code.
-
-13. Restored 12-bit-per-component JPEG support. A 12-bit version of
-libjpeg-turbo can now be built by passing an argument of `--with-12bit` to
-configure (Unix) or `-DWITH_12BIT=1` to cmake (Windows.) 12-bit JPEG support
-is included only for convenience. Enabling this feature disables all of the
-performance features in libjpeg-turbo, as well as arithmetic coding and the
-TurboJPEG API. The resulting library still contains the other libjpeg-turbo
-features (such as the colorspace extensions), but in general, it performs no
-faster than libjpeg v6b.
-
-14. Added ARM 64-bit SIMD acceleration for the YCC-to-RGB color conversion
-and IDCT algorithms (both are used during JPEG decompression.) For unknown
-reasons (probably related to clang), this code cannot currently be compiled for
-iOS.
-
-15. Fixed an extremely rare bug (CVE-2014-9092) that could cause the Huffman
-encoder's local buffer to overrun when a very high-frequency MCU is compressed
-using quality 100 and no subsampling, and when the JPEG output buffer is being
-dynamically resized by the destination manager. This issue was so rare that,
-even with a test program specifically designed to make the bug occur (by
-injecting random high-frequency YUV data into the compressor), it was
-reproducible only once in about every 25 million iterations.
-
-16. Fixed an oversight in the TurboJPEG C wrapper: if any of the JPEG
-compression functions was called repeatedly with the same
-automatically-allocated destination buffer, then TurboJPEG would erroneously
-assume that the `jpegSize` parameter was equal to the size of the buffer, when
-in fact that parameter was probably equal to the size of the most recently
-compressed JPEG image. If the size of the previous JPEG image was not as large
-as the current JPEG image, then TurboJPEG would unnecessarily reallocate the
-destination buffer.
-
-
-1.3.1
-=====
-
-### Significant changes relative to 1.3.0:
-
-1. On Un*x systems, `make install` now installs the libjpeg-turbo libraries
-into /opt/libjpeg-turbo/lib32 by default on any 32-bit system, not just x86,
-and into /opt/libjpeg-turbo/lib64 by default on any 64-bit system, not just
-x86-64. You can override this by overriding either the `prefix` or `libdir`
-configure variables.
-
-2. The Windows installer now places a copy of the TurboJPEG DLLs in the same
-directory as the rest of the libjpeg-turbo binaries. This was mainly done
-to support TurboVNC 1.3, which bundles the DLLs in its Windows installation.
-When using a 32-bit version of CMake on 64-bit Windows, it is impossible to
-access the c:\WINDOWS\system32 directory, which made it impossible for the
-TurboVNC build scripts to bundle the 64-bit TurboJPEG DLL.
-
-3. Fixed a bug whereby attempting to encode a progressive JPEG with arithmetic
-entropy coding (by passing arguments of `-progressive -arithmetic` to cjpeg or
-jpegtran, for instance) would result in an error, `Requested feature was
-omitted at compile time`.
-
-4. Fixed a couple of issues (CVE-2013-6629 and CVE-2013-6630) whereby malformed
-JPEG images would cause libjpeg-turbo to use uninitialized memory during
-decompression.
-
-5. Fixed an error (`Buffer passed to JPEG library is too small`) that occurred
-when calling the TurboJPEG YUV encoding function with a very small (< 5x5)
-source image, and added a unit test to check for this error.
-
-6. The Java classes should now build properly under Visual Studio 2010 and
-later.
-
-7. Fixed an issue that prevented SRPMs generated using the in-tree packaging
-tools from being rebuilt on certain newer Linux distributions.
-
-8. Numerous minor fixes to eliminate compilation and build/packaging system
-warnings, fix cosmetic issues, improve documentation clarity, and other general
-source cleanup.
-
-
-1.3.0
-=====
-
-### Significant changes relative to 1.3 beta1:
-
-1. `make test` now works properly on FreeBSD, and it no longer requires the
-md5sum executable to be present on other Un*x platforms.
-
-2. Overhauled the packaging system:
-
- - To avoid conflict with vendor-supplied libjpeg-turbo packages, the
-official RPMs and DEBs for libjpeg-turbo have been renamed to
-"libjpeg-turbo-official".
- - The TurboJPEG libraries are now located under /opt/libjpeg-turbo in the
-official Linux and Mac packages, to avoid conflict with vendor-supplied
-packages and also to streamline the packaging system.
- - Release packages are now created with the directory structure defined
-by the configure variables `prefix`, `bindir`, `libdir`, etc. (Un\*x) or by the
-`CMAKE_INSTALL_PREFIX` variable (Windows.) The exception is that the docs are
-always located under the system default documentation directory on Un\*x and
-Mac systems, and on Windows, the TurboJPEG DLL is always located in the Windows
-system directory.
- - To avoid confusion, official libjpeg-turbo packages on Linux/Unix
-platforms (except for Mac) will always install the 32-bit libraries in
-/opt/libjpeg-turbo/lib32 and the 64-bit libraries in /opt/libjpeg-turbo/lib64.
- - Fixed an issue whereby, in some cases, the libjpeg-turbo executables on
-Un*x systems were not properly linking with the shared libraries installed by
-the same package.
- - Fixed an issue whereby building the "installer" target on Windows when
-`WITH_JAVA=1` would fail if the TurboJPEG JAR had not been previously built.
- - Building the "install" target on Windows now installs files into the
-same places that the installer does.
-
-3. Fixed a Huffman encoder bug that prevented I/O suspension from working
-properly.
-
-
-1.2.90 (1.3 beta1)
-==================
-
-### Significant changes relative to 1.2.1:
-
-1. Added support for additional scaling factors (3/8, 5/8, 3/4, 7/8, 9/8, 5/4,
-11/8, 3/2, 13/8, 7/4, 15/8, and 2) when decompressing. Note that the IDCT will
-not be SIMD-accelerated when using any of these new scaling factors.
-
-2. The TurboJPEG dynamic library is now versioned. It was not strictly
-necessary to do so, because TurboJPEG uses versioned symbols, and if a function
-changes in an ABI-incompatible way, that function is renamed and a legacy
-function is provided to maintain backward compatibility. However, certain
-Linux distro maintainers have a policy against accepting any library that isn't
-versioned.
-
-3. Extended the TurboJPEG Java API so that it can be used to compress a JPEG
-image from and decompress a JPEG image to an arbitrary position in a large
-image buffer.
-
-4. The `tjDecompressToYUV()` function now supports the `TJFLAG_FASTDCT` flag.
-
-5. The 32-bit supplementary package for amd64 Debian systems now provides
-symlinks in /usr/lib/i386-linux-gnu for the TurboJPEG libraries in /usr/lib32.
-This allows those libraries to be used on MultiArch-compatible systems (such as
-Ubuntu 11 and later) without setting the linker path.
-
-6. The TurboJPEG Java wrapper should now find the JNI library on Mac systems
-without having to pass `-Djava.library.path=/usr/lib` to java.
-
-7. TJBench has been ported to Java to provide a convenient way of validating
-the performance of the TurboJPEG Java API. It can be run with
-`java -cp turbojpeg.jar TJBench`.
-
-8. cjpeg can now be used to generate JPEG files with the RGB colorspace
-(feature ported from jpeg-8d.)
-
-9. The width and height in the `-crop` argument passed to jpegtran can now be
-suffixed with `f` to indicate that, when the upper left corner of the cropping
-region is automatically moved to the nearest iMCU boundary, the bottom right
-corner should be moved by the same amount. In other words, this feature causes
-jpegtran to strictly honor the specified width/height rather than the specified
-bottom right corner (feature ported from jpeg-8d.)
-
-10. JPEG files using the RGB colorspace can now be decompressed into grayscale
-images (feature ported from jpeg-8d.)
-
-11. Fixed a regression caused by 1.2.1[7] whereby the build would fail with
-multiple "Mismatch in operand sizes" errors when attempting to build the x86
-SIMD code with NASM 0.98.
-
-12. The in-memory source/destination managers (`jpeg_mem_src()` and
-`jpeg_mem_dest()`) are now included by default when building libjpeg-turbo with
-libjpeg v6b or v7 emulation, so that programs can take advantage of these
-functions without requiring the use of the backward-incompatible libjpeg v8
-ABI. The "age number" of the libjpeg-turbo library on Un*x systems has been
-incremented by 1 to reflect this. You can disable this feature with a
-configure/CMake switch in order to retain strict API/ABI compatibility with the
-libjpeg v6b or v7 API/ABI (or with previous versions of libjpeg-turbo.) See
-[README.md](README.md) for more details.
-
-13. Added ARMv7s architecture to libjpeg.a and libturbojpeg.a in the official
-libjpeg-turbo binary package for OS X, so that those libraries can be used to
-build applications that leverage the faster CPUs in the iPhone 5 and iPad 4.
-
-
-1.2.1
-=====
-
-### Significant changes relative to 1.2.0:
-
-1. Creating or decoding a JPEG file that uses the RGB colorspace should now
-properly work when the input or output colorspace is one of the libjpeg-turbo
-colorspace extensions.
-
-2. When libjpeg-turbo was built without SIMD support and merged (non-fancy)
-upsampling was used along with an alpha-enabled colorspace during
-decompression, the unused byte of the decompressed pixels was not being set to
-0xFF. This has been fixed. TJUnitTest has also been extended to test for the
-correct behavior of the colorspace extensions when merged upsampling is used.
-
-3. Fixed a bug whereby the libjpeg-turbo SSE2 SIMD code would not preserve the
-upper 64 bits of xmm6 and xmm7 on Win64 platforms, which violated the Win64
-calling conventions.
-
-4. Fixed a regression (CVE-2012-2806) caused by 1.2.0[6] whereby decompressing
-corrupt JPEG images (specifically, images in which the component count was
-erroneously set to a large value) would cause libjpeg-turbo to segfault.
-
-5. Worked around a severe performance issue with "Bobcat" (AMD Embedded APU)
-processors. The `MASKMOVDQU` instruction, which was used by the libjpeg-turbo
-SSE2 SIMD code, is apparently implemented in microcode on AMD processors, and
-it is painfully slow on Bobcat processors in particular. Eliminating the use
-of this instruction improved performance by an order of magnitude on Bobcat
-processors and by a small amount (typically 5%) on AMD desktop processors.
-
-6. Added SIMD acceleration for performing 4:2:2 upsampling on NEON-capable ARM
-platforms. This speeds up the decompression of 4:2:2 JPEGs by 20-25% on such
-platforms.
-
-7. Fixed a regression caused by 1.2.0[2] whereby, on Linux/x86 platforms
-running the 32-bit SSE2 SIMD code in libjpeg-turbo, decompressing a 4:2:0 or
-4:2:2 JPEG image into a 32-bit (RGBX, BGRX, etc.) buffer without using fancy
-upsampling would produce several incorrect columns of pixels at the right-hand
-side of the output image if each row in the output image was not evenly
-divisible by 16 bytes.
-
-8. Fixed an issue whereby attempting to build the SIMD extensions with Xcode
-4.3 on OS X platforms would cause NASM to return numerous errors of the form
-"'%define' expects a macro identifier".
-
-9. Added flags to the TurboJPEG API that allow the caller to force the use of
-either the fast or the accurate DCT/IDCT algorithms in the underlying codec.
-
-
-1.2.0
-=====
-
-### Significant changes relative to 1.2 beta1:
-
-1. Fixed build issue with Yasm on Unix systems (the libjpeg-turbo build system
-was not adding the current directory to the assembler include path, so Yasm
-was not able to find jsimdcfg.inc.)
-
-2. Fixed out-of-bounds read in SSE2 SIMD code that occurred when decompressing
-a JPEG image to a bitmap buffer whose size was not a multiple of 16 bytes.
-This was more of an annoyance than an actual bug, since it did not cause any
-actual run-time problems, but the issue showed up when running libjpeg-turbo in
-valgrind. See <http://crbug.com/72399> for more information.
-
-3. Added a compile-time macro (`LIBJPEG_TURBO_VERSION`) that can be used to
-check the version of libjpeg-turbo against which an application was compiled.
-
-4. Added new RGBA/BGRA/ABGR/ARGB colorspace extension constants (libjpeg API)
-and pixel formats (TurboJPEG API), which allow applications to specify that,
-when decompressing to a 4-component RGB buffer, the unused byte should be set
-to 0xFF so that it can be interpreted as an opaque alpha channel.
-
-5. Fixed regression issue whereby DevIL failed to build against libjpeg-turbo
-because libjpeg-turbo's distributed version of jconfig.h contained an `INLINE`
-macro, which conflicted with a similar macro in DevIL. This macro is used only
-internally when building libjpeg-turbo, so it was moved into config.h.
-
-6. libjpeg-turbo will now correctly decompress erroneous CMYK/YCCK JPEGs whose
-K component is assigned a component ID of 1 instead of 4. Although these files
-are in violation of the spec, other JPEG implementations handle them
-correctly.
-
-7. Added ARMv6 and ARMv7 architectures to libjpeg.a and libturbojpeg.a in
-the official libjpeg-turbo binary package for OS X, so that those libraries can
-be used to build both OS X and iOS applications.
-
-
-1.1.90 (1.2 beta1)
-==================
-
-### Significant changes relative to 1.1.1:
-
-1. Added a Java wrapper for the TurboJPEG API. See [java/README](java/README)
-for more details.
-
-2. The TurboJPEG API can now be used to scale down images during
-decompression.
-
-3. Added SIMD routines for RGB-to-grayscale color conversion, which
-significantly improves the performance of grayscale JPEG compression from an
-RGB source image.
-
-4. Improved the performance of the C color conversion routines, which are used
-on platforms for which SIMD acceleration is not available.
-
-5. Added a function to the TurboJPEG API that performs lossless transforms.
-This function is implemented using the same back end as jpegtran, but it
-performs transcoding entirely in memory and allows multiple transforms and/or
-crop operations to be batched together, so the source coefficients only need to
-be read once. This is useful when generating image tiles from a single source
-JPEG.
-
-6. Added tests for the new TurboJPEG scaled decompression and lossless
-transform features to tjbench (the TurboJPEG benchmark, formerly called
-"jpgtest".)
-
-7. Added support for 4:4:0 (transposed 4:2:2) subsampling in TurboJPEG, which
-was necessary in order for it to read 4:2:2 JPEG files that had been losslessly
-transposed or rotated 90 degrees.
-
-8. All legacy VirtualGL code has been re-factored, and this has allowed
-libjpeg-turbo, in its entirety, to be re-licensed under a BSD-style license.
-
-9. libjpeg-turbo can now be built with Yasm.
-
-10. Added SIMD acceleration for ARM Linux and iOS platforms that support
-NEON instructions.
-
-11. Refactored the TurboJPEG C API and documented it using Doxygen. The
-TurboJPEG 1.2 API uses pixel formats to define the size and component order of
-the uncompressed source/destination images, and it includes a more efficient
-version of `TJBUFSIZE()` that computes a worst-case JPEG size based on the
-level of chrominance subsampling. The refactored implementation of the
-TurboJPEG API now uses the libjpeg memory source and destination managers,
-which allows the TurboJPEG compressor to grow the JPEG buffer as necessary.
-
-12. Eliminated errors in the output of jpegtran on Windows that occurred when
-the application was invoked using I/O redirection
-(`jpegtran <input.jpg >output.jpg`.)
-
-13. The inclusion of libjpeg v7 and v8 emulation as well as arithmetic coding
-support in libjpeg-turbo v1.1.0 introduced several new error constants in
-jerror.h, and these were mistakenly enabled for all emulation modes, causing
-the error enum in libjpeg-turbo to sometimes have different values than the
-same enum in libjpeg. This represents an ABI incompatibility, and it caused
-problems with rare applications that took specific action based on a particular
-error value. The fix was to include the new error constants conditionally
-based on whether libjpeg v7 or v8 emulation was enabled.
-
-14. Fixed an issue whereby Windows applications that used libjpeg-turbo would
-fail to compile if the Windows system headers were included before jpeglib.h.
-This issue was caused by a conflict in the definition of the INT32 type.
-
-15. Fixed 32-bit supplementary package for amd64 Debian systems, which was
-broken by enhancements to the packaging system in 1.1.
-
-16. When decompressing a JPEG image using an output colorspace of
-`JCS_EXT_RGBX`, `JCS_EXT_BGRX`, `JCS_EXT_XBGR`, or `JCS_EXT_XRGB`,
-libjpeg-turbo will now set the unused byte to 0xFF, which allows applications
-to interpret that byte as an alpha channel (0xFF = opaque).
-
-
-1.1.1
-=====
-
-### Significant changes relative to 1.1.0:
-
-1. Fixed a 1-pixel error in row 0, column 21 of the luminance plane generated
-by `tjEncodeYUV()`.
-
-2. libjpeg-turbo's accelerated Huffman decoder previously ignored unexpected
-markers found in the middle of the JPEG data stream during decompression. It
-will now hand off decoding of a particular block to the unaccelerated Huffman
-decoder if an unexpected marker is found, so that the unaccelerated Huffman
-decoder can generate an appropriate warning.
-
-3. Older versions of MinGW64 prefixed symbol names with underscores by
-default, which differed from the behavior of 64-bit Visual C++. MinGW64 1.0
-has adopted the behavior of 64-bit Visual C++ as the default, so to accommodate
-this, the libjpeg-turbo SIMD function names are no longer prefixed with an
-underscore when building with MinGW64. This means that, when building
-libjpeg-turbo with older versions of MinGW64, you will now have to add
-`-fno-leading-underscore` to the `CFLAGS`.
-
-4. Fixed a regression bug in the NSIS script that caused the Windows installer
-build to fail when using the Visual Studio IDE.
-
-5. Fixed a bug in `jpeg_read_coefficients()` whereby it would not initialize
-`cinfo->image_width` and `cinfo->image_height` if libjpeg v7 or v8 emulation
-was enabled. This specifically caused the jpegoptim program to fail if it was
-linked against a version of libjpeg-turbo that was built with libjpeg v7 or v8
-emulation.
-
-6. Eliminated excessive I/O overhead that occurred when reading BMP files in
-cjpeg.
-
-7. Eliminated errors in the output of cjpeg on Windows that occurred when the
-application was invoked using I/O redirection (`cjpeg <inputfile >output.jpg`.)
-
-
-1.1.0
-=====
-
-### Significant changes relative to 1.1 beta1:
-
-1. The algorithm used by the SIMD quantization function cannot produce correct
-results when the JPEG quality is >= 98 and the fast integer forward DCT is
-used. Thus, the non-SIMD quantization function is now used for those cases,
-and libjpeg-turbo should now produce identical output to libjpeg v6b in all
-cases.
-
-2. Despite the above, the fast integer forward DCT still degrades somewhat for
-JPEG qualities greater than 95, so the TurboJPEG wrapper will now automatically
-use the accurate integer forward DCT when generating JPEG images of quality 96
-or greater. This reduces compression performance by as much as 15% for these
-high-quality images but is necessary to ensure that the images are perceptually
-lossless. It also ensures that the library can avoid the performance pitfall
-created by [1].
-
-3. Ported jpgtest.cxx to pure C to avoid the need for a C++ compiler.
-
-4. Fixed visual artifacts in grayscale JPEG compression caused by a typo in
-the RGB-to-luminance lookup tables.
-
-5. The Windows distribution packages now include the libjpeg run-time programs
-(cjpeg, etc.)
-
-6. All packages now include jpgtest.
-
-7. The TurboJPEG dynamic library now uses versioned symbols.
-
-8. Added two new TurboJPEG API functions, `tjEncodeYUV()` and
-`tjDecompressToYUV()`, to replace the somewhat hackish `TJ_YUV` flag.
-
-
-1.0.90 (1.1 beta1)
-==================
-
-### Significant changes relative to 1.0.1:
-
-1. Added emulation of the libjpeg v7 and v8 APIs and ABIs. See
-[README.md](README.md) for more details. This feature was sponsored by
-CamTrace SAS.
-
-2. Created a new CMake-based build system for the Visual C++ and MinGW builds.
-
-3. Grayscale bitmaps can now be compressed from/decompressed to using the
-TurboJPEG API.
-
-4. jpgtest can now be used to test decompression performance with existing
-JPEG images.
-
-5. If the default install prefix (/opt/libjpeg-turbo) is used, then
-`make install` now creates /opt/libjpeg-turbo/lib32 and
-/opt/libjpeg-turbo/lib64 sym links to duplicate the behavior of the binary
-packages.
-
-6. All symbols in the libjpeg-turbo dynamic library are now versioned, even
-when the library is built with libjpeg v6b emulation.
-
-7. Added arithmetic encoding and decoding support (can be disabled with
-configure or CMake options)
-
-8. Added a `TJ_YUV` flag to the TurboJPEG API, which causes both the compressor
-and decompressor to output planar YUV images.
-
-9. Added an extended version of `tjDecompressHeader()` to the TurboJPEG API,
-which allows the caller to determine the type of subsampling used in a JPEG
-image.
-
-10. Added further protections against invalid Huffman codes.
-
-
-1.0.1
-=====
-
-### Significant changes relative to 1.0.0:
-
-1. The Huffman decoder will now handle erroneous Huffman codes (for instance,
-from a corrupt JPEG image.) Previously, these would cause libjpeg-turbo to
-crash under certain circumstances.
-
-2. Fixed typo in SIMD dispatch routines that was causing 4:2:2 upsampling to
-be used instead of 4:2:0 when decompressing JPEG images using SSE2 code.
-
-3. The configure script will now automatically determine whether the
-`INCOMPLETE_TYPES_BROKEN` macro should be defined.
-
-
-1.0.0
-=====
-
-### Significant changes relative to 0.0.93:
-
-1. 2983700: Further FreeBSD build tweaks (no longer necessary to specify
-`--host` when configuring on a 64-bit system)
-
-2. Created symlinks in the Unix/Linux packages so that the TurboJPEG
-include file can always be found in /opt/libjpeg-turbo/include, the 32-bit
-static libraries can always be found in /opt/libjpeg-turbo/lib32, and the
-64-bit static libraries can always be found in /opt/libjpeg-turbo/lib64.
-
-3. The Unix/Linux distribution packages now include the libjpeg run-time
-programs (cjpeg, etc.) and man pages.
-
-4. Created a 32-bit supplementary package for amd64 Debian systems, which
-contains just the 32-bit libjpeg-turbo libraries.
-
-5. Moved the libraries from */lib32 to */lib in the i386 Debian package.
-
-6. Include distribution package for Cygwin
-
-7. No longer necessary to specify `--without-simd` on non-x86 architectures,
-and unit tests now work on those architectures.
-
-
-0.0.93
-======
-
-### Significant changes since 0.0.91:
-
-1. 2982659: Fixed x86-64 build on FreeBSD systems
-
-2. 2988188: Added support for Windows 64-bit systems
-
-
-0.0.91
-======
-
-### Significant changes relative to 0.0.90:
-
-1. Added documentation to .deb packages
-
-2. 2968313: Fixed data corruption issues when decompressing large JPEG images
-and/or using buffered I/O with the libjpeg-turbo decompressor
-
-
-0.0.90
-======
-
-Initial release
diff --git a/contrib/libs/libjpeg-turbo/LICENSE.md b/contrib/libs/libjpeg-turbo/LICENSE.md
deleted file mode 100644
index d753e1d76a..0000000000
--- a/contrib/libs/libjpeg-turbo/LICENSE.md
+++ /dev/null
@@ -1,132 +0,0 @@
-libjpeg-turbo Licenses
-======================
-
-libjpeg-turbo is covered by three compatible BSD-style open source licenses:
-
-- The IJG (Independent JPEG Group) License, which is listed in
- [README.ijg](README.ijg)
-
- This license applies to the libjpeg API library and associated programs
- (any code inherited from libjpeg, and any modifications to that code.)
-
-- The Modified (3-clause) BSD License, which is listed below
-
- This license covers the TurboJPEG API library and associated programs, as
- well as the build system.
-
-- The [zlib License](https://opensource.org/licenses/Zlib)
-
- This license is a subset of the other two, and it covers the libjpeg-turbo
- SIMD extensions.
-
-
-Complying with the libjpeg-turbo Licenses
-=========================================
-
-This section provides a roll-up of the libjpeg-turbo licensing terms, to the
-best of our understanding.
-
-1. If you are distributing a modified version of the libjpeg-turbo source,
- then:
-
- 1. You cannot alter or remove any existing copyright or license notices
- from the source.
-
- **Origin**
- - Clause 1 of the IJG License
- - Clause 1 of the Modified BSD License
- - Clauses 1 and 3 of the zlib License
-
- 2. You must add your own copyright notice to the header of each source
- file you modified, so others can tell that you modified that file (if
- there is not an existing copyright header in that file, then you can
- simply add a notice stating that you modified the file.)
-
- **Origin**
- - Clause 1 of the IJG License
- - Clause 2 of the zlib License
-
- 3. You must include the IJG README file, and you must not alter any of the
- copyright or license text in that file.
-
- **Origin**
- - Clause 1 of the IJG License
-
-2. If you are distributing only libjpeg-turbo binaries without the source, or
- if you are distributing an application that statically links with
- libjpeg-turbo, then:
-
- 1. Your product documentation must include a message stating:
-
- This software is based in part on the work of the Independent JPEG
- Group.
-
- **Origin**
- - Clause 2 of the IJG license
-
- 2. If your binary distribution includes or uses the TurboJPEG API, then
- your product documentation must include the text of the Modified BSD
- License (see below.)
-
- **Origin**
- - Clause 2 of the Modified BSD License
-
-3. You cannot use the name of the IJG or The libjpeg-turbo Project or the
- contributors thereof in advertising, publicity, etc.
-
- **Origin**
- - IJG License
- - Clause 3 of the Modified BSD License
-
-4. The IJG and The libjpeg-turbo Project do not warrant libjpeg-turbo to be
- free of defects, nor do we accept any liability for undesirable
- consequences resulting from your use of the software.
-
- **Origin**
- - IJG License
- - Modified BSD License
- - zlib License
-
-
-The Modified (3-clause) BSD License
-===================================
-
-Copyright (C)2009-2022 D. R. Commander. All Rights Reserved.<br>
-Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-- Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-- Neither the name of the libjpeg-turbo Project nor the names of its
- contributors may be used to endorse or promote products derived from this
- software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS",
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
-
-
-Why Three Licenses?
-===================
-
-The zlib License could have been used instead of the Modified (3-clause) BSD
-License, and since the IJG License effectively subsumes the distribution
-conditions of the zlib License, this would have effectively placed
-libjpeg-turbo binary distributions under the IJG License. However, the IJG
-License specifically refers to the Independent JPEG Group and does not extend
-attribution and endorsement protections to other entities. Thus, it was
-desirable to choose a license that granted us the same protections for new code
-that were granted to the IJG for code derived from their software.
diff --git a/contrib/libs/libjpeg-turbo/README.ijg b/contrib/libs/libjpeg-turbo/README.ijg
deleted file mode 100644
index 9453c19501..0000000000
--- a/contrib/libs/libjpeg-turbo/README.ijg
+++ /dev/null
@@ -1,258 +0,0 @@
-libjpeg-turbo note: This file has been modified by The libjpeg-turbo Project
-to include only information relevant to libjpeg-turbo, to wordsmith certain
-sections, and to remove impolitic language that existed in the libjpeg v8
-README. It is included only for reference. Please see README.md for
-information specific to libjpeg-turbo.
-
-
-The Independent JPEG Group's JPEG software
-==========================================
-
-This distribution contains a release of the Independent JPEG Group's free JPEG
-software. You are welcome to redistribute this software and to use it for any
-purpose, subject to the conditions under LEGAL ISSUES, below.
-
-This software is the work of Tom Lane, Guido Vollbeding, Philip Gladstone,
-Bill Allombert, Jim Boucher, Lee Crocker, Bob Friesenhahn, Ben Jackson,
-Julian Minguillon, Luis Ortiz, George Phillips, Davide Rossi, Ge' Weijers,
-and other members of the Independent JPEG Group.
-
-IJG is not affiliated with the ISO/IEC JTC1/SC29/WG1 standards committee
-(also known as JPEG, together with ITU-T SG16).
-
-
-DOCUMENTATION ROADMAP
-=====================
-
-This file contains the following sections:
-
-OVERVIEW General description of JPEG and the IJG software.
-LEGAL ISSUES Copyright, lack of warranty, terms of distribution.
-REFERENCES Where to learn more about JPEG.
-ARCHIVE LOCATIONS Where to find newer versions of this software.
-FILE FORMAT WARS Software *not* to get.
-TO DO Plans for future IJG releases.
-
-Other documentation files in the distribution are:
-
-User documentation:
- usage.txt Usage instructions for cjpeg, djpeg, jpegtran,
- rdjpgcom, and wrjpgcom.
- *.1 Unix-style man pages for programs (same info as usage.txt).
- wizard.txt Advanced usage instructions for JPEG wizards only.
- change.log Version-to-version change highlights.
-Programmer and internal documentation:
- libjpeg.txt How to use the JPEG library in your own programs.
- example.txt Sample code for calling the JPEG library.
- structure.txt Overview of the JPEG library's internal structure.
- coderules.txt Coding style rules --- please read if you contribute code.
-
-Please read at least usage.txt. Some information can also be found in the JPEG
-FAQ (Frequently Asked Questions) article. See ARCHIVE LOCATIONS below to find
-out where to obtain the FAQ article.
-
-If you want to understand how the JPEG code works, we suggest reading one or
-more of the REFERENCES, then looking at the documentation files (in roughly
-the order listed) before diving into the code.
-
-
-OVERVIEW
-========
-
-This package contains C software to implement JPEG image encoding, decoding,
-and transcoding. JPEG (pronounced "jay-peg") is a standardized compression
-method for full-color and grayscale images. JPEG's strong suit is compressing
-photographic images or other types of images that have smooth color and
-brightness transitions between neighboring pixels. Images with sharp lines or
-other abrupt features may not compress well with JPEG, and a higher JPEG
-quality may have to be used to avoid visible compression artifacts with such
-images.
-
-JPEG is lossy, meaning that the output pixels are not necessarily identical to
-the input pixels. However, on photographic content and other "smooth" images,
-very good compression ratios can be obtained with no visible compression
-artifacts, and extremely high compression ratios are possible if you are
-willing to sacrifice image quality (by reducing the "quality" setting in the
-compressor.)
-
-This software implements JPEG baseline, extended-sequential, and progressive
-compression processes. Provision is made for supporting all variants of these
-processes, although some uncommon parameter settings aren't implemented yet.
-We have made no provision for supporting the hierarchical or lossless
-processes defined in the standard.
-
-We provide a set of library routines for reading and writing JPEG image files,
-plus two sample applications "cjpeg" and "djpeg", which use the library to
-perform conversion between JPEG and some other popular image file formats.
-The library is intended to be reused in other applications.
-
-In order to support file conversion and viewing software, we have included
-considerable functionality beyond the bare JPEG coding/decoding capability;
-for example, the color quantization modules are not strictly part of JPEG
-decoding, but they are essential for output to colormapped file formats or
-colormapped displays. These extra functions can be compiled out of the
-library if not required for a particular application.
-
-We have also included "jpegtran", a utility for lossless transcoding between
-different JPEG processes, and "rdjpgcom" and "wrjpgcom", two simple
-applications for inserting and extracting textual comments in JFIF files.
-
-The emphasis in designing this software has been on achieving portability and
-flexibility, while also making it fast enough to be useful. In particular,
-the software is not intended to be read as a tutorial on JPEG. (See the
-REFERENCES section for introductory material.) Rather, it is intended to
-be reliable, portable, industrial-strength code. We do not claim to have
-achieved that goal in every aspect of the software, but we strive for it.
-
-We welcome the use of this software as a component of commercial products.
-No royalty is required, but we do ask for an acknowledgement in product
-documentation, as described under LEGAL ISSUES.
-
-
-LEGAL ISSUES
-============
-
-In plain English:
-
-1. We don't promise that this software works. (But if you find any bugs,
- please let us know!)
-2. You can use this software for whatever you want. You don't have to pay us.
-3. You may not pretend that you wrote this software. If you use it in a
- program, you must acknowledge somewhere in your documentation that
- you've used the IJG code.
-
-In legalese:
-
-The authors make NO WARRANTY or representation, either express or implied,
-with respect to this software, its quality, accuracy, merchantability, or
-fitness for a particular purpose. This software is provided "AS IS", and you,
-its user, assume the entire risk as to its quality and accuracy.
-
-This software is copyright (C) 1991-2020, Thomas G. Lane, Guido Vollbeding.
-All Rights Reserved except as specified below.
-
-Permission is hereby granted to use, copy, modify, and distribute this
-software (or portions thereof) for any purpose, without fee, subject to these
-conditions:
-(1) If any part of the source code for this software is distributed, then this
-README file must be included, with this copyright and no-warranty notice
-unaltered; and any additions, deletions, or changes to the original files
-must be clearly indicated in accompanying documentation.
-(2) If only executable code is distributed, then the accompanying
-documentation must state that "this software is based in part on the work of
-the Independent JPEG Group".
-(3) Permission for use of this software is granted only if the user accepts
-full responsibility for any undesirable consequences; the authors accept
-NO LIABILITY for damages of any kind.
-
-These conditions apply to any software derived from or based on the IJG code,
-not just to the unmodified library. If you use our work, you ought to
-acknowledge us.
-
-Permission is NOT granted for the use of any IJG author's name or company name
-in advertising or publicity relating to this software or products derived from
-it. This software may be referred to only as "the Independent JPEG Group's
-software".
-
-We specifically permit and encourage the use of this software as the basis of
-commercial products, provided that all warranty or liability claims are
-assumed by the product vendor.
-
-
-REFERENCES
-==========
-
-We recommend reading one or more of these references before trying to
-understand the innards of the JPEG software.
-
-The best short technical introduction to the JPEG compression algorithm is
- Wallace, Gregory K. "The JPEG Still Picture Compression Standard",
- Communications of the ACM, April 1991 (vol. 34 no. 4), pp. 30-44.
-(Adjacent articles in that issue discuss MPEG motion picture compression,
-applications of JPEG, and related topics.) If you don't have the CACM issue
-handy, a PDF file containing a revised version of Wallace's article is
-available at http://www.ijg.org/files/Wallace.JPEG.pdf. The file (actually
-a preprint for an article that appeared in IEEE Trans. Consumer Electronics)
-omits the sample images that appeared in CACM, but it includes corrections
-and some added material. Note: the Wallace article is copyright ACM and IEEE,
-and it may not be used for commercial purposes.
-
-A somewhat less technical, more leisurely introduction to JPEG can be found in
-"The Data Compression Book" by Mark Nelson and Jean-loup Gailly, published by
-M&T Books (New York), 2nd ed. 1996, ISBN 1-55851-434-1. This book provides
-good explanations and example C code for a multitude of compression methods
-including JPEG. It is an excellent source if you are comfortable reading C
-code but don't know much about data compression in general. The book's JPEG
-sample code is far from industrial-strength, but when you are ready to look
-at a full implementation, you've got one here...
-
-The best currently available description of JPEG is the textbook "JPEG Still
-Image Data Compression Standard" by William B. Pennebaker and Joan L.
-Mitchell, published by Van Nostrand Reinhold, 1993, ISBN 0-442-01272-1.
-Price US$59.95, 638 pp. The book includes the complete text of the ISO JPEG
-standards (DIS 10918-1 and draft DIS 10918-2).
-
-The original JPEG standard is divided into two parts, Part 1 being the actual
-specification, while Part 2 covers compliance testing methods. Part 1 is
-titled "Digital Compression and Coding of Continuous-tone Still Images,
-Part 1: Requirements and guidelines" and has document numbers ISO/IEC IS
-10918-1, ITU-T T.81. Part 2 is titled "Digital Compression and Coding of
-Continuous-tone Still Images, Part 2: Compliance testing" and has document
-numbers ISO/IEC IS 10918-2, ITU-T T.83.
-
-The JPEG standard does not specify all details of an interchangeable file
-format. For the omitted details, we follow the "JFIF" conventions, revision
-1.02. JFIF version 1 has been adopted as ISO/IEC 10918-5 (05/2013) and
-Recommendation ITU-T T.871 (05/2011): Information technology - Digital
-compression and coding of continuous-tone still images: JPEG File Interchange
-Format (JFIF). It is available as a free download in PDF file format from
-https://www.iso.org/standard/54989.html and http://www.itu.int/rec/T-REC-T.871.
-A PDF file of the older JFIF 1.02 specification is available at
-http://www.w3.org/Graphics/JPEG/jfif3.pdf.
-
-The TIFF 6.0 file format specification can be obtained from
-http://mirrors.ctan.org/graphics/tiff/TIFF6.ps.gz. The JPEG incorporation
-scheme found in the TIFF 6.0 spec of 3-June-92 has a number of serious
-problems. IJG does not recommend use of the TIFF 6.0 design (TIFF Compression
-tag 6). Instead, we recommend the JPEG design proposed by TIFF Technical Note
-#2 (Compression tag 7). Copies of this Note can be obtained from
-http://www.ijg.org/files/. It is expected that the next revision
-of the TIFF spec will replace the 6.0 JPEG design with the Note's design.
-Although IJG's own code does not support TIFF/JPEG, the free libtiff library
-uses our library to implement TIFF/JPEG per the Note.
-
-
-ARCHIVE LOCATIONS
-=================
-
-The "official" archive site for this software is www.ijg.org.
-The most recent released version can always be found there in
-directory "files".
-
-The JPEG FAQ (Frequently Asked Questions) article is a source of some
-general information about JPEG. It is available at
-http://www.faqs.org/faqs/jpeg-faq.
-
-
-FILE FORMAT COMPATIBILITY
-=========================
-
-This software implements ITU T.81 | ISO/IEC 10918 with some extensions from
-ITU T.871 | ISO/IEC 10918-5 (JPEG File Interchange Format-- see REFERENCES).
-Informally, the term "JPEG image" or "JPEG file" most often refers to JFIF or
-a subset thereof, but there are other formats containing the name "JPEG" that
-are incompatible with the DCT-based JPEG standard or with JFIF (for instance,
-JPEG 2000 and JPEG XR). This software therefore does not support these
-formats. Indeed, one of the original reasons for developing this free software
-was to help force convergence on a common, interoperable format standard for
-JPEG files.
-
-JFIF is a minimal or "low end" representation. TIFF/JPEG (TIFF revision 6.0 as
-modified by TIFF Technical Note #2) can be used for "high end" applications
-that need to record a lot of additional data about an image.
-
-
-TO DO
-=====
-
-Please send bug reports, offers of help, etc. to jpeg-info@jpegclub.org.
diff --git a/contrib/libs/libjpeg-turbo/README.md b/contrib/libs/libjpeg-turbo/README.md
deleted file mode 100644
index 01e391ea7c..0000000000
--- a/contrib/libs/libjpeg-turbo/README.md
+++ /dev/null
@@ -1,357 +0,0 @@
-Background
-==========
-
-libjpeg-turbo is a JPEG image codec that uses SIMD instructions to accelerate
-baseline JPEG compression and decompression on x86, x86-64, Arm, PowerPC, and
-MIPS systems, as well as progressive JPEG compression on x86, x86-64, and Arm
-systems. On such systems, libjpeg-turbo is generally 2-6x as fast as libjpeg,
-all else being equal. On other types of systems, libjpeg-turbo can still
-outperform libjpeg by a significant amount, by virtue of its highly-optimized
-Huffman coding routines. In many cases, the performance of libjpeg-turbo
-rivals that of proprietary high-speed JPEG codecs.
-
-libjpeg-turbo implements both the traditional libjpeg API as well as the less
-powerful but more straightforward TurboJPEG API. libjpeg-turbo also features
-colorspace extensions that allow it to compress from/decompress to 32-bit and
-big-endian pixel buffers (RGBX, XBGR, etc.), as well as a full-featured Java
-interface.
-
-libjpeg-turbo was originally based on libjpeg/SIMD, an MMX-accelerated
-derivative of libjpeg v6b developed by Miyasaka Masaru. The TigerVNC and
-VirtualGL projects made numerous enhancements to the codec in 2009, and in
-early 2010, libjpeg-turbo spun off into an independent project, with the goal
-of making high-speed JPEG compression/decompression technology available to a
-broader range of users and developers.
-
-
-License
-=======
-
-libjpeg-turbo is covered by three compatible BSD-style open source licenses.
-Refer to [LICENSE.md](LICENSE.md) for a roll-up of license terms.
-
-
-Building libjpeg-turbo
-======================
-
-Refer to [BUILDING.md](BUILDING.md) for complete instructions.
-
-
-Using libjpeg-turbo
-===================
-
-libjpeg-turbo includes two APIs that can be used to compress and decompress
-JPEG images:
-
-- **TurboJPEG API**<br>
- This API provides an easy-to-use interface for compressing and decompressing
- JPEG images in memory. It also provides some functionality that would not be
- straightforward to achieve using the underlying libjpeg API, such as
- generating planar YUV images and performing multiple simultaneous lossless
- transforms on an image. The Java interface for libjpeg-turbo is written on
- top of the TurboJPEG API. The TurboJPEG API is recommended for first-time
- users of libjpeg-turbo. Refer to [tjexample.c](tjexample.c) and
- [TJExample.java](java/TJExample.java) for examples of its usage and to
- <http://libjpeg-turbo.org/Documentation/Documentation> for API documentation.
-
-- **libjpeg API**<br>
- This is the de facto industry-standard API for compressing and decompressing
- JPEG images. It is more difficult to use than the TurboJPEG API but also
- more powerful. The libjpeg API implementation in libjpeg-turbo is both
- API/ABI-compatible and mathematically compatible with libjpeg v6b. It can
- also optionally be configured to be API/ABI-compatible with libjpeg v7 and v8
- (see below.) Refer to [cjpeg.c](cjpeg.c) and [djpeg.c](djpeg.c) for examples
- of its usage and to [libjpeg.txt](libjpeg.txt) for API documentation.
-
-There is no significant performance advantage to either API when both are used
-to perform similar operations.
-
-Colorspace Extensions
----------------------
-
-libjpeg-turbo includes extensions that allow JPEG images to be compressed
-directly from (and decompressed directly to) buffers that use BGR, BGRX,
-RGBX, XBGR, and XRGB pixel ordering. This is implemented with ten new
-colorspace constants:
-
- JCS_EXT_RGB /* red/green/blue */
- JCS_EXT_RGBX /* red/green/blue/x */
- JCS_EXT_BGR /* blue/green/red */
- JCS_EXT_BGRX /* blue/green/red/x */
- JCS_EXT_XBGR /* x/blue/green/red */
- JCS_EXT_XRGB /* x/red/green/blue */
- JCS_EXT_RGBA /* red/green/blue/alpha */
- JCS_EXT_BGRA /* blue/green/red/alpha */
- JCS_EXT_ABGR /* alpha/blue/green/red */
- JCS_EXT_ARGB /* alpha/red/green/blue */
-
-Setting `cinfo.in_color_space` (compression) or `cinfo.out_color_space`
-(decompression) to one of these values will cause libjpeg-turbo to read the
-red, green, and blue values from (or write them to) the appropriate position in
-the pixel when compressing from/decompressing to an RGB buffer.
-
-Your application can check for the existence of these extensions at compile
-time with:
-
- #ifdef JCS_EXTENSIONS
-
-At run time, attempting to use these extensions with a libjpeg implementation
-that does not support them will result in a "Bogus input colorspace" error.
-Applications can trap this error in order to test whether run-time support is
-available for the colorspace extensions.
-
-When using the RGBX, BGRX, XBGR, and XRGB colorspaces during decompression, the
-X byte is undefined, and in order to ensure the best performance, libjpeg-turbo
-can set that byte to whatever value it wishes. If an application expects the X
-byte to be used as an alpha channel, then it should specify `JCS_EXT_RGBA`,
-`JCS_EXT_BGRA`, `JCS_EXT_ABGR`, or `JCS_EXT_ARGB`. When these colorspace
-constants are used, the X byte is guaranteed to be 0xFF, which is interpreted
-as opaque.
-
-Your application can check for the existence of the alpha channel colorspace
-extensions at compile time with:
-
- #ifdef JCS_ALPHA_EXTENSIONS
-
-[jcstest.c](jcstest.c), located in the libjpeg-turbo source tree, demonstrates
-how to check for the existence of the colorspace extensions at compile time and
-run time.
-
-libjpeg v7 and v8 API/ABI Emulation
------------------------------------
-
-With libjpeg v7 and v8, new features were added that necessitated extending the
-compression and decompression structures. Unfortunately, due to the exposed
-nature of those structures, extending them also necessitated breaking backward
-ABI compatibility with previous libjpeg releases. Thus, programs that were
-built to use libjpeg v7 or v8 did not work with libjpeg-turbo, since it is
-based on the libjpeg v6b code base. Although libjpeg v7 and v8 are not
-as widely used as v6b, enough programs (including a few Linux distros) made
-the switch that there was a demand to emulate the libjpeg v7 and v8 ABIs
-in libjpeg-turbo. It should be noted, however, that this feature was added
-primarily so that applications that had already been compiled to use libjpeg
-v7+ could take advantage of accelerated baseline JPEG encoding/decoding
-without recompiling. libjpeg-turbo does not claim to support all of the
-libjpeg v7+ features, nor to produce identical output to libjpeg v7+ in all
-cases (see below.)
-
-By passing an argument of `-DWITH_JPEG7=1` or `-DWITH_JPEG8=1` to `cmake`, you
-can build a version of libjpeg-turbo that emulates the libjpeg v7 or v8 ABI, so
-that programs that are built against libjpeg v7 or v8 can be run with
-libjpeg-turbo. The following section describes which libjpeg v7+ features are
-supported and which aren't.
-
-### Support for libjpeg v7 and v8 Features
-
-#### Fully supported
-
-- **libjpeg API: IDCT scaling extensions in decompressor**<br>
- libjpeg-turbo supports IDCT scaling with scaling factors of 1/8, 1/4, 3/8,
- 1/2, 5/8, 3/4, 7/8, 9/8, 5/4, 11/8, 3/2, 13/8, 7/4, 15/8, and 2/1 (only 1/4
- and 1/2 are SIMD-accelerated.)
-
-- **libjpeg API: Arithmetic coding**
-
-- **libjpeg API: In-memory source and destination managers**<br>
- See notes below.
-
-- **cjpeg: Separate quality settings for luminance and chrominance**<br>
- Note that the libpjeg v7+ API was extended to accommodate this feature only
- for convenience purposes. It has always been possible to implement this
- feature with libjpeg v6b (see rdswitch.c for an example.)
-
-- **cjpeg: 32-bit BMP support**
-
-- **cjpeg: `-rgb` option**
-
-- **jpegtran: Lossless cropping**
-
-- **jpegtran: `-perfect` option**
-
-- **jpegtran: Forcing width/height when performing lossless crop**
-
-- **rdjpgcom: `-raw` option**
-
-- **rdjpgcom: Locale awareness**
-
-
-#### Not supported
-
-NOTE: As of this writing, extensive research has been conducted into the
-usefulness of DCT scaling as a means of data reduction and SmartScale as a
-means of quality improvement. Readers are invited to peruse the research at
-<http://www.libjpeg-turbo.org/About/SmartScale> and draw their own conclusions,
-but it is the general belief of our project that these features have not
-demonstrated sufficient usefulness to justify inclusion in libjpeg-turbo.
-
-- **libjpeg API: DCT scaling in compressor**<br>
- `cinfo.scale_num` and `cinfo.scale_denom` are silently ignored.
- There is no technical reason why DCT scaling could not be supported when
- emulating the libjpeg v7+ API/ABI, but without the SmartScale extension (see
- below), only scaling factors of 1/2, 8/15, 4/7, 8/13, 2/3, 8/11, 4/5, and
- 8/9 would be available, which is of limited usefulness.
-
-- **libjpeg API: SmartScale**<br>
- `cinfo.block_size` is silently ignored.
- SmartScale is an extension to the JPEG format that allows for DCT block
- sizes other than 8x8. Providing support for this new format would be
- feasible (particularly without full acceleration.) However, until/unless
- the format becomes either an official industry standard or, at minimum, an
- accepted solution in the community, we are hesitant to implement it, as
- there is no sense of whether or how it might change in the future. It is
- our belief that SmartScale has not demonstrated sufficient usefulness as a
- lossless format nor as a means of quality enhancement, and thus our primary
- interest in providing this feature would be as a means of supporting
- additional DCT scaling factors.
-
-- **libjpeg API: Fancy downsampling in compressor**<br>
- `cinfo.do_fancy_downsampling` is silently ignored.
- This requires the DCT scaling feature, which is not supported.
-
-- **jpegtran: Scaling**<br>
- This requires both the DCT scaling and SmartScale features, which are not
- supported.
-
-- **Lossless RGB JPEG files**<br>
- This requires the SmartScale feature, which is not supported.
-
-### What About libjpeg v9?
-
-libjpeg v9 introduced yet another field to the JPEG compression structure
-(`color_transform`), thus making the ABI backward incompatible with that of
-libjpeg v8. This new field was introduced solely for the purpose of supporting
-lossless SmartScale encoding. Furthermore, there was actually no reason to
-extend the API in this manner, as the color transform could have just as easily
-been activated by way of a new JPEG colorspace constant, thus preserving
-backward ABI compatibility.
-
-Our research (see link above) has shown that lossless SmartScale does not
-generally accomplish anything that can't already be accomplished better with
-existing, standard lossless formats. Therefore, at this time it is our belief
-that there is not sufficient technical justification for software projects to
-upgrade from libjpeg v8 to libjpeg v9, and thus there is not sufficient
-technical justification for us to emulate the libjpeg v9 ABI.
-
-In-Memory Source/Destination Managers
--------------------------------------
-
-By default, libjpeg-turbo 1.3 and later includes the `jpeg_mem_src()` and
-`jpeg_mem_dest()` functions, even when not emulating the libjpeg v8 API/ABI.
-Previously, it was necessary to build libjpeg-turbo from source with libjpeg v8
-API/ABI emulation in order to use the in-memory source/destination managers,
-but several projects requested that those functions be included when emulating
-the libjpeg v6b API/ABI as well. This allows the use of those functions by
-programs that need them, without breaking ABI compatibility for programs that
-don't, and it allows those functions to be provided in the "official"
-libjpeg-turbo binaries.
-
-Those who are concerned about maintaining strict conformance with the libjpeg
-v6b or v7 API can pass an argument of `-DWITH_MEM_SRCDST=0` to `cmake` prior to
-building libjpeg-turbo. This will restore the pre-1.3 behavior, in which
-`jpeg_mem_src()` and `jpeg_mem_dest()` are only included when emulating the
-libjpeg v8 API/ABI.
-
-On Un*x systems, including the in-memory source/destination managers changes
-the dynamic library version from 62.2.0 to 62.3.0 if using libjpeg v6b API/ABI
-emulation and from 7.2.0 to 7.3.0 if using libjpeg v7 API/ABI emulation.
-
-Note that, on most Un*x systems, the dynamic linker will not look for a
-function in a library until that function is actually used. Thus, if a program
-is built against libjpeg-turbo 1.3+ and uses `jpeg_mem_src()` or
-`jpeg_mem_dest()`, that program will not fail if run against an older version
-of libjpeg-turbo or against libjpeg v7- until the program actually tries to
-call `jpeg_mem_src()` or `jpeg_mem_dest()`. Such is not the case on Windows.
-If a program is built against the libjpeg-turbo 1.3+ DLL and uses
-`jpeg_mem_src()` or `jpeg_mem_dest()`, then it must use the libjpeg-turbo 1.3+
-DLL at run time.
-
-Both cjpeg and djpeg have been extended to allow testing the in-memory
-source/destination manager functions. See their respective man pages for more
-details.
-
-
-Mathematical Compatibility
-==========================
-
-For the most part, libjpeg-turbo should produce identical output to libjpeg
-v6b. The one exception to this is when using the floating point DCT/IDCT, in
-which case the outputs of libjpeg v6b and libjpeg-turbo can differ for the
-following reasons:
-
-- The SSE/SSE2 floating point DCT implementation in libjpeg-turbo is ever so
- slightly more accurate than the implementation in libjpeg v6b, but not by
- any amount perceptible to human vision (generally in the range of 0.01 to
- 0.08 dB gain in PNSR.)
-
-- When not using the SIMD extensions, libjpeg-turbo uses the more accurate
- (and slightly faster) floating point IDCT algorithm introduced in libjpeg
- v8a as opposed to the algorithm used in libjpeg v6b. It should be noted,
- however, that this algorithm basically brings the accuracy of the floating
- point IDCT in line with the accuracy of the accurate integer IDCT. The
- floating point DCT/IDCT algorithms are mainly a legacy feature, and they do
- not produce significantly more accuracy than the accurate integer algorithms
- (to put numbers on this, the typical difference in PNSR between the two
- algorithms is less than 0.10 dB, whereas changing the quality level by 1 in
- the upper range of the quality scale is typically more like a 1.0 dB
- difference.)
-
-- If the floating point algorithms in libjpeg-turbo are not implemented using
- SIMD instructions on a particular platform, then the accuracy of the
- floating point DCT/IDCT can depend on the compiler settings.
-
-While libjpeg-turbo does emulate the libjpeg v8 API/ABI, under the hood it is
-still using the same algorithms as libjpeg v6b, so there are several specific
-cases in which libjpeg-turbo cannot be expected to produce the same output as
-libjpeg v8:
-
-- When decompressing using scaling factors of 1/2 and 1/4, because libjpeg v8
- implements those scaling algorithms differently than libjpeg v6b does, and
- libjpeg-turbo's SIMD extensions are based on the libjpeg v6b behavior.
-
-- When using chrominance subsampling, because libjpeg v8 implements this
- with its DCT/IDCT scaling algorithms rather than with a separate
- downsampling/upsampling algorithm. In our testing, the subsampled/upsampled
- output of libjpeg v8 is less accurate than that of libjpeg v6b for this
- reason.
-
-- When decompressing using a scaling factor > 1 and merged (AKA "non-fancy" or
- "non-smooth") chrominance upsampling, because libjpeg v8 does not support
- merged upsampling with scaling factors > 1.
-
-
-Performance Pitfalls
-====================
-
-Restart Markers
----------------
-
-The optimized Huffman decoder in libjpeg-turbo does not handle restart markers
-in a way that makes the rest of the libjpeg infrastructure happy, so it is
-necessary to use the slow Huffman decoder when decompressing a JPEG image that
-has restart markers. This can cause the decompression performance to drop by
-as much as 20%, but the performance will still be much greater than that of
-libjpeg. Many consumer packages, such as Photoshop, use restart markers when
-generating JPEG images, so images generated by those programs will experience
-this issue.
-
-Fast Integer Forward DCT at High Quality Levels
------------------------------------------------
-
-The algorithm used by the SIMD-accelerated quantization function cannot produce
-correct results whenever the fast integer forward DCT is used along with a JPEG
-quality of 98-100. Thus, libjpeg-turbo must use the non-SIMD quantization
-function in those cases. This causes performance to drop by as much as 40%.
-It is therefore strongly advised that you use the accurate integer forward DCT
-whenever encoding images with a JPEG quality of 98 or higher.
-
-
-Memory Debugger Pitfalls
-========================
-
-Valgrind and Memory Sanitizer (MSan) can generate false positives
-(specifically, incorrect reports of uninitialized memory accesses) when used
-with libjpeg-turbo's SIMD extensions. It is generally recommended that the
-SIMD extensions be disabled, either by passing an argument of `-DWITH_SIMD=0`
-to `cmake` when configuring the build or by setting the environment variable
-`JSIMD_FORCENONE` to `1` at run time, when testing libjpeg-turbo with Valgrind,
-MSan, or other memory debuggers.
diff --git a/contrib/libs/libjpeg-turbo/cderror.h b/contrib/libs/libjpeg-turbo/cderror.h
deleted file mode 100644
index 2844346ee3..0000000000
--- a/contrib/libs/libjpeg-turbo/cderror.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * cderror.h
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1994-1997, Thomas G. Lane.
- * Modified 2009-2017 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2021, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file defines the error and message codes for the cjpeg/djpeg
- * applications. These strings are not needed as part of the JPEG library
- * proper.
- * Edit this file to add new codes, or to translate the message strings to
- * some other language.
- */
-
-/*
- * To define the enum list of message codes, include this file without
- * defining macro JMESSAGE. To create a message string table, include it
- * again with a suitable JMESSAGE definition (see jerror.c for an example).
- */
-#ifndef JMESSAGE
-#ifndef CDERROR_H
-#define CDERROR_H
-/* First time through, define the enum list */
-#define JMAKE_ENUM_LIST
-#else
-/* Repeated inclusions of this file are no-ops unless JMESSAGE is defined */
-#define JMESSAGE(code, string)
-#endif /* CDERROR_H */
-#endif /* JMESSAGE */
-
-#ifdef JMAKE_ENUM_LIST
-
-typedef enum {
-
-#define JMESSAGE(code, string) code,
-
-#endif /* JMAKE_ENUM_LIST */
-
-JMESSAGE(JMSG_FIRSTADDONCODE = 1000, NULL) /* Must be first entry! */
-
-#ifdef BMP_SUPPORTED
-JMESSAGE(JERR_BMP_BADCMAP, "Unsupported BMP colormap format")
-JMESSAGE(JERR_BMP_BADDEPTH, "Only 8-, 24-, and 32-bit BMP files are supported")
-JMESSAGE(JERR_BMP_BADHEADER, "Invalid BMP file: bad header length")
-JMESSAGE(JERR_BMP_BADPLANES, "Invalid BMP file: biPlanes not equal to 1")
-JMESSAGE(JERR_BMP_COLORSPACE, "BMP output must be grayscale or RGB")
-JMESSAGE(JERR_BMP_COMPRESSED, "Sorry, compressed BMPs not yet supported")
-JMESSAGE(JERR_BMP_EMPTY, "Empty BMP image")
-JMESSAGE(JERR_BMP_NOT, "Not a BMP file - does not start with BM")
-JMESSAGE(JERR_BMP_OUTOFRANGE, "Numeric value out of range in BMP file")
-JMESSAGE(JTRC_BMP, "%ux%u %d-bit BMP image")
-JMESSAGE(JTRC_BMP_MAPPED, "%ux%u 8-bit colormapped BMP image")
-JMESSAGE(JTRC_BMP_OS2, "%ux%u %d-bit OS2 BMP image")
-JMESSAGE(JTRC_BMP_OS2_MAPPED, "%ux%u 8-bit colormapped OS2 BMP image")
-#endif /* BMP_SUPPORTED */
-
-#ifdef GIF_SUPPORTED
-JMESSAGE(JERR_GIF_BUG, "GIF output got confused")
-JMESSAGE(JERR_GIF_CODESIZE, "Bogus GIF codesize %d")
-JMESSAGE(JERR_GIF_COLORSPACE, "GIF output must be grayscale or RGB")
-JMESSAGE(JERR_GIF_EMPTY, "Empty GIF image")
-JMESSAGE(JERR_GIF_IMAGENOTFOUND, "Too few images in GIF file")
-JMESSAGE(JERR_GIF_NOT, "Not a GIF file")
-JMESSAGE(JTRC_GIF, "%ux%ux%d GIF image")
-JMESSAGE(JTRC_GIF_BADVERSION,
- "Warning: unexpected GIF version number '%c%c%c'")
-JMESSAGE(JTRC_GIF_EXTENSION, "Ignoring GIF extension block of type 0x%02x")
-JMESSAGE(JTRC_GIF_NONSQUARE, "Caution: nonsquare pixels in input")
-JMESSAGE(JWRN_GIF_BADDATA, "Corrupt data in GIF file")
-JMESSAGE(JWRN_GIF_CHAR, "Bogus char 0x%02x in GIF file, ignoring")
-JMESSAGE(JWRN_GIF_ENDCODE, "Premature end of GIF image")
-JMESSAGE(JWRN_GIF_NOMOREDATA, "Ran out of GIF bits")
-#endif /* GIF_SUPPORTED */
-
-#ifdef PPM_SUPPORTED
-JMESSAGE(JERR_PPM_COLORSPACE, "PPM output must be grayscale or RGB")
-JMESSAGE(JERR_PPM_NONNUMERIC, "Nonnumeric data in PPM file")
-JMESSAGE(JERR_PPM_NOT, "Not a PPM/PGM file")
-JMESSAGE(JERR_PPM_OUTOFRANGE, "Numeric value out of range in PPM file")
-JMESSAGE(JTRC_PGM, "%ux%u PGM image")
-JMESSAGE(JTRC_PGM_TEXT, "%ux%u text PGM image")
-JMESSAGE(JTRC_PPM, "%ux%u PPM image")
-JMESSAGE(JTRC_PPM_TEXT, "%ux%u text PPM image")
-#endif /* PPM_SUPPORTED */
-
-#ifdef TARGA_SUPPORTED
-JMESSAGE(JERR_TGA_BADCMAP, "Unsupported Targa colormap format")
-JMESSAGE(JERR_TGA_BADPARMS, "Invalid or unsupported Targa file")
-JMESSAGE(JERR_TGA_COLORSPACE, "Targa output must be grayscale or RGB")
-JMESSAGE(JTRC_TGA, "%ux%u RGB Targa image")
-JMESSAGE(JTRC_TGA_GRAY, "%ux%u grayscale Targa image")
-JMESSAGE(JTRC_TGA_MAPPED, "%ux%u colormapped Targa image")
-#else
-JMESSAGE(JERR_TGA_NOTCOMP, "Targa support was not compiled")
-#endif /* TARGA_SUPPORTED */
-
-JMESSAGE(JERR_BAD_CMAP_FILE,
- "Color map file is invalid or of unsupported format")
-JMESSAGE(JERR_TOO_MANY_COLORS,
- "Output file format cannot handle %d colormap entries")
-JMESSAGE(JERR_UNGETC_FAILED, "ungetc failed")
-#ifdef TARGA_SUPPORTED
-JMESSAGE(JERR_UNKNOWN_FORMAT,
- "Unrecognized input file format --- perhaps you need -targa")
-#else
-JMESSAGE(JERR_UNKNOWN_FORMAT, "Unrecognized input file format")
-#endif
-JMESSAGE(JERR_UNSUPPORTED_FORMAT, "Unsupported output file format")
-
-#ifdef JMAKE_ENUM_LIST
-
- JMSG_LASTADDONCODE
-} ADDON_MESSAGE_CODE;
-
-#undef JMAKE_ENUM_LIST
-#endif /* JMAKE_ENUM_LIST */
-
-/* Zap JMESSAGE macro so that future re-inclusions do nothing by default */
-#undef JMESSAGE
diff --git a/contrib/libs/libjpeg-turbo/cdjpeg.c b/contrib/libs/libjpeg-turbo/cdjpeg.c
deleted file mode 100644
index 304a665017..0000000000
--- a/contrib/libs/libjpeg-turbo/cdjpeg.c
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * cdjpeg.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2019, 2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains common support routines used by the IJG application
- * programs (cjpeg, djpeg, jpegtran).
- */
-
-#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
-#include <ctype.h> /* to declare isupper(), tolower() */
-#ifdef USE_SETMODE
-#include <fcntl.h> /* to declare setmode()'s parameter macros */
-/* If you have setmode() but not <io.h>, just delete this line: */
-#include <io.h> /* to declare setmode() */
-#endif
-
-
-/*
- * Optional progress monitor: display a percent-done figure on stderr.
- */
-
-METHODDEF(void)
-progress_monitor(j_common_ptr cinfo)
-{
- cd_progress_ptr prog = (cd_progress_ptr)cinfo->progress;
-
- if (prog->max_scans != 0 && cinfo->is_decompressor) {
- int scan_no = ((j_decompress_ptr)cinfo)->input_scan_number;
-
- if (scan_no > (int)prog->max_scans) {
- fprintf(stderr, "Scan number %d exceeds maximum scans (%u)\n", scan_no,
- prog->max_scans);
- exit(EXIT_FAILURE);
- }
- }
-
- if (prog->report) {
- int total_passes = prog->pub.total_passes + prog->total_extra_passes;
- int percent_done =
- (int)(prog->pub.pass_counter * 100L / prog->pub.pass_limit);
-
- if (percent_done != prog->percent_done) {
- prog->percent_done = percent_done;
- if (total_passes > 1) {
- fprintf(stderr, "\rPass %d/%d: %3d%% ",
- prog->pub.completed_passes + prog->completed_extra_passes + 1,
- total_passes, percent_done);
- } else {
- fprintf(stderr, "\r %3d%% ", percent_done);
- }
- fflush(stderr);
- }
- }
-}
-
-
-GLOBAL(void)
-start_progress_monitor(j_common_ptr cinfo, cd_progress_ptr progress)
-{
- /* Enable progress display, unless trace output is on */
- if (cinfo->err->trace_level == 0) {
- progress->pub.progress_monitor = progress_monitor;
- progress->completed_extra_passes = 0;
- progress->total_extra_passes = 0;
- progress->max_scans = 0;
- progress->report = FALSE;
- progress->percent_done = -1;
- cinfo->progress = &progress->pub;
- }
-}
-
-
-GLOBAL(void)
-end_progress_monitor(j_common_ptr cinfo)
-{
- /* Clear away progress display */
- if (cinfo->err->trace_level == 0) {
- fprintf(stderr, "\r \r");
- fflush(stderr);
- }
-}
-
-
-/*
- * Case-insensitive matching of possibly-abbreviated keyword switches.
- * keyword is the constant keyword (must be lower case already),
- * minchars is length of minimum legal abbreviation.
- */
-
-GLOBAL(boolean)
-keymatch(char *arg, const char *keyword, int minchars)
-{
- register int ca, ck;
- register int nmatched = 0;
-
- while ((ca = *arg++) != '\0') {
- if ((ck = *keyword++) == '\0')
- return FALSE; /* arg longer than keyword, no good */
- if (isupper(ca)) /* force arg to lcase (assume ck is already) */
- ca = tolower(ca);
- if (ca != ck)
- return FALSE; /* no good */
- nmatched++; /* count matched characters */
- }
- /* reached end of argument; fail if it's too short for unique abbrev */
- if (nmatched < minchars)
- return FALSE;
- return TRUE; /* A-OK */
-}
-
-
-/*
- * Routines to establish binary I/O mode for stdin and stdout.
- * Non-Unix systems often require some hacking to get out of text mode.
- */
-
-GLOBAL(FILE *)
-read_stdin(void)
-{
- FILE *input_file = stdin;
-
-#ifdef USE_SETMODE /* need to hack file mode? */
- setmode(fileno(stdin), O_BINARY);
-#endif
-#ifdef USE_FDOPEN /* need to re-open in binary mode? */
- if ((input_file = fdopen(fileno(stdin), READ_BINARY)) == NULL) {
- fprintf(stderr, "Cannot reopen stdin\n");
- exit(EXIT_FAILURE);
- }
-#endif
- return input_file;
-}
-
-
-GLOBAL(FILE *)
-write_stdout(void)
-{
- FILE *output_file = stdout;
-
-#ifdef USE_SETMODE /* need to hack file mode? */
- setmode(fileno(stdout), O_BINARY);
-#endif
-#ifdef USE_FDOPEN /* need to re-open in binary mode? */
- if ((output_file = fdopen(fileno(stdout), WRITE_BINARY)) == NULL) {
- fprintf(stderr, "Cannot reopen stdout\n");
- exit(EXIT_FAILURE);
- }
-#endif
- return output_file;
-}
diff --git a/contrib/libs/libjpeg-turbo/cdjpeg.h b/contrib/libs/libjpeg-turbo/cdjpeg.h
deleted file mode 100644
index 082687ce06..0000000000
--- a/contrib/libs/libjpeg-turbo/cdjpeg.h
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * cdjpeg.h
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1994-1997, Thomas G. Lane.
- * Modified 2019 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2017, 2019, 2021, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains common declarations for the sample applications
- * cjpeg and djpeg. It is NOT used by the core JPEG library.
- */
-
-#define JPEG_CJPEG_DJPEG /* define proper options in jconfig.h */
-#define JPEG_INTERNAL_OPTIONS /* cjpeg.c,djpeg.c need to see xxx_SUPPORTED */
-#include "jinclude.h"
-#include "jpeglib.h"
-#include "jerror.h" /* get library error codes too */
-#include "cderror.h" /* get application-specific error codes */
-
-
-/*
- * Object interface for cjpeg's source file decoding modules
- */
-
-typedef struct cjpeg_source_struct *cjpeg_source_ptr;
-
-struct cjpeg_source_struct {
- void (*start_input) (j_compress_ptr cinfo, cjpeg_source_ptr sinfo);
- JDIMENSION (*get_pixel_rows) (j_compress_ptr cinfo, cjpeg_source_ptr sinfo);
- void (*finish_input) (j_compress_ptr cinfo, cjpeg_source_ptr sinfo);
-
- FILE *input_file;
-
- JSAMPARRAY buffer;
- JDIMENSION buffer_height;
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
- JDIMENSION max_pixels;
-#endif
-};
-
-
-/*
- * Object interface for djpeg's output file encoding modules
- */
-
-typedef struct djpeg_dest_struct *djpeg_dest_ptr;
-
-struct djpeg_dest_struct {
- /* start_output is called after jpeg_start_decompress finishes.
- * The color map will be ready at this time, if one is needed.
- */
- void (*start_output) (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo);
- /* Emit the specified number of pixel rows from the buffer. */
- void (*put_pixel_rows) (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
- JDIMENSION rows_supplied);
- /* Finish up at the end of the image. */
- void (*finish_output) (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo);
- /* Re-calculate buffer dimensions based on output dimensions (for use with
- partial image decompression.) If this is NULL, then the output format
- does not support partial image decompression (BMP, in particular, cannot
- support partial decompression because it uses an inversion buffer to write
- the image in bottom-up order.) */
- void (*calc_buffer_dimensions) (j_decompress_ptr cinfo,
- djpeg_dest_ptr dinfo);
-
-
- /* Target file spec; filled in by djpeg.c after object is created. */
- FILE *output_file;
-
- /* Output pixel-row buffer. Created by module init or start_output.
- * Width is cinfo->output_width * cinfo->output_components;
- * height is buffer_height.
- */
- JSAMPARRAY buffer;
- JDIMENSION buffer_height;
-};
-
-
-/*
- * cjpeg/djpeg may need to perform extra passes to convert to or from
- * the source/destination file format. The JPEG library does not know
- * about these passes, but we'd like them to be counted by the progress
- * monitor. We use an expanded progress monitor object to hold the
- * additional pass count.
- */
-
-struct cdjpeg_progress_mgr {
- struct jpeg_progress_mgr pub; /* fields known to JPEG library */
- int completed_extra_passes; /* extra passes completed */
- int total_extra_passes; /* total extra */
- JDIMENSION max_scans; /* abort if the number of scans exceeds this
- value and the value is non-zero */
- boolean report; /* whether or not to report progress */
- /* last printed percentage stored here to avoid multiple printouts */
- int percent_done;
-};
-
-typedef struct cdjpeg_progress_mgr *cd_progress_ptr;
-
-
-/* Module selection routines for I/O modules. */
-
-EXTERN(cjpeg_source_ptr) jinit_read_bmp(j_compress_ptr cinfo,
- boolean use_inversion_array);
-EXTERN(djpeg_dest_ptr) jinit_write_bmp(j_decompress_ptr cinfo, boolean is_os2,
- boolean use_inversion_array);
-EXTERN(cjpeg_source_ptr) jinit_read_gif(j_compress_ptr cinfo);
-EXTERN(djpeg_dest_ptr) jinit_write_gif(j_decompress_ptr cinfo, boolean is_lzw);
-EXTERN(cjpeg_source_ptr) jinit_read_ppm(j_compress_ptr cinfo);
-EXTERN(djpeg_dest_ptr) jinit_write_ppm(j_decompress_ptr cinfo);
-EXTERN(cjpeg_source_ptr) jinit_read_targa(j_compress_ptr cinfo);
-EXTERN(djpeg_dest_ptr) jinit_write_targa(j_decompress_ptr cinfo);
-
-/* cjpeg support routines (in rdswitch.c) */
-
-EXTERN(boolean) read_quant_tables(j_compress_ptr cinfo, char *filename,
- boolean force_baseline);
-EXTERN(boolean) read_scan_script(j_compress_ptr cinfo, char *filename);
-EXTERN(boolean) set_quality_ratings(j_compress_ptr cinfo, char *arg,
- boolean force_baseline);
-EXTERN(boolean) set_quant_slots(j_compress_ptr cinfo, char *arg);
-EXTERN(boolean) set_sample_factors(j_compress_ptr cinfo, char *arg);
-
-/* djpeg support routines (in rdcolmap.c) */
-
-EXTERN(void) read_color_map(j_decompress_ptr cinfo, FILE *infile);
-
-/* common support routines (in cdjpeg.c) */
-
-EXTERN(void) start_progress_monitor(j_common_ptr cinfo,
- cd_progress_ptr progress);
-EXTERN(void) end_progress_monitor(j_common_ptr cinfo);
-EXTERN(boolean) keymatch(char *arg, const char *keyword, int minchars);
-EXTERN(FILE *) read_stdin(void);
-EXTERN(FILE *) write_stdout(void);
-
-/* miscellaneous useful macros */
-
-#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */
-#define READ_BINARY "r"
-#define WRITE_BINARY "w"
-#else
-#define READ_BINARY "rb"
-#define WRITE_BINARY "wb"
-#endif
-
-#ifndef EXIT_FAILURE /* define exit() codes if not provided */
-#define EXIT_FAILURE 1
-#endif
-#ifndef EXIT_SUCCESS
-#define EXIT_SUCCESS 0
-#endif
-#ifndef EXIT_WARNING
-#define EXIT_WARNING 2
-#endif
-
-#define IsExtRGB(cs) \
- (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
diff --git a/contrib/libs/libjpeg-turbo/cjpeg.c b/contrib/libs/libjpeg-turbo/cjpeg.c
deleted file mode 100644
index dae18a3fc1..0000000000
--- a/contrib/libs/libjpeg-turbo/cjpeg.c
+++ /dev/null
@@ -1,762 +0,0 @@
-/*
- * cjpeg.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1998, Thomas G. Lane.
- * Modified 2003-2011 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2013-2014, 2017, 2019-2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains a command-line user interface for the JPEG compressor.
- * It should work on any system with Unix- or MS-DOS-style command lines.
- *
- * Two different command line styles are permitted, depending on the
- * compile-time switch TWO_FILE_COMMANDLINE:
- * cjpeg [options] inputfile outputfile
- * cjpeg [options] [inputfile]
- * In the second style, output is always to standard output, which you'd
- * normally redirect to a file or pipe to some other program. Input is
- * either from a named file or from standard input (typically redirected).
- * The second style is convenient on Unix but is unhelpful on systems that
- * don't support pipes. Also, you MUST use the first style if your system
- * doesn't do binary I/O to stdin/stdout.
- * To simplify script writing, the "-outfile" switch is provided. The syntax
- * cjpeg [options] -outfile outputfile inputfile
- * works regardless of which command line style is used.
- */
-
-#ifdef _MSC_VER
-#define _CRT_SECURE_NO_DEPRECATE
-#endif
-
-#ifdef CJPEG_FUZZER
-#define JPEG_INTERNALS
-#endif
-#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
-#include "jversion.h" /* for version message */
-#include "jconfigint.h"
-
-
-/* Create the add-on message string table. */
-
-#define JMESSAGE(code, string) string,
-
-static const char * const cdjpeg_message_table[] = {
-#include "cderror.h"
- NULL
-};
-
-
-/*
- * This routine determines what format the input file is,
- * and selects the appropriate input-reading module.
- *
- * To determine which family of input formats the file belongs to,
- * we may look only at the first byte of the file, since C does not
- * guarantee that more than one character can be pushed back with ungetc.
- * Looking at additional bytes would require one of these approaches:
- * 1) assume we can fseek() the input file (fails for piped input);
- * 2) assume we can push back more than one character (works in
- * some C implementations, but unportable);
- * 3) provide our own buffering (breaks input readers that want to use
- * stdio directly);
- * or 4) don't put back the data, and modify the input_init methods to assume
- * they start reading after the start of file.
- * #1 is attractive for MS-DOS but is untenable on Unix.
- *
- * The most portable solution for file types that can't be identified by their
- * first byte is to make the user tell us what they are. This is also the
- * only approach for "raw" file types that contain only arbitrary values.
- * We presently apply this method for Targa files. Most of the time Targa
- * files start with 0x00, so we recognize that case. Potentially, however,
- * a Targa file could start with any byte value (byte 0 is the length of the
- * seldom-used ID field), so we provide a switch to force Targa input mode.
- */
-
-static boolean is_targa; /* records user -targa switch */
-
-
-LOCAL(cjpeg_source_ptr)
-select_file_type(j_compress_ptr cinfo, FILE *infile)
-{
- int c;
-
- if (is_targa) {
-#ifdef TARGA_SUPPORTED
- return jinit_read_targa(cinfo);
-#else
- ERREXIT(cinfo, JERR_TGA_NOTCOMP);
-#endif
- }
-
- if ((c = getc(infile)) == EOF)
- ERREXIT(cinfo, JERR_INPUT_EMPTY);
- if (ungetc(c, infile) == EOF)
- ERREXIT(cinfo, JERR_UNGETC_FAILED);
-
- switch (c) {
-#ifdef BMP_SUPPORTED
- case 'B':
- return jinit_read_bmp(cinfo, TRUE);
-#endif
-#ifdef GIF_SUPPORTED
- case 'G':
- return jinit_read_gif(cinfo);
-#endif
-#ifdef PPM_SUPPORTED
- case 'P':
- return jinit_read_ppm(cinfo);
-#endif
-#ifdef TARGA_SUPPORTED
- case 0x00:
- return jinit_read_targa(cinfo);
-#endif
- default:
- ERREXIT(cinfo, JERR_UNKNOWN_FORMAT);
- break;
- }
-
- return NULL; /* suppress compiler warnings */
-}
-
-
-/*
- * Argument-parsing code.
- * The switch parser is designed to be useful with DOS-style command line
- * syntax, ie, intermixed switches and file names, where only the switches
- * to the left of a given file name affect processing of that file.
- * The main program in this file doesn't actually use this capability...
- */
-
-
-static const char *progname; /* program name for error messages */
-static char *icc_filename; /* for -icc switch */
-static char *outfilename; /* for -outfile switch */
-boolean memdst; /* for -memdst switch */
-boolean report; /* for -report switch */
-boolean strict; /* for -strict switch */
-
-
-#ifdef CJPEG_FUZZER
-
-#include <setjmp.h>
-
-struct my_error_mgr {
- struct jpeg_error_mgr pub;
- jmp_buf setjmp_buffer;
-};
-
-void my_error_exit(j_common_ptr cinfo)
-{
- struct my_error_mgr *myerr = (struct my_error_mgr *)cinfo->err;
-
- longjmp(myerr->setjmp_buffer, 1);
-}
-
-static void my_emit_message_fuzzer(j_common_ptr cinfo, int msg_level)
-{
- if (msg_level < 0)
- cinfo->err->num_warnings++;
-}
-
-#define HANDLE_ERROR() { \
- if (cinfo.global_state > CSTATE_START) { \
- if (memdst && outbuffer) \
- (*cinfo.dest->term_destination) (&cinfo); \
- jpeg_abort_compress(&cinfo); \
- } \
- jpeg_destroy_compress(&cinfo); \
- if (input_file != stdin && input_file != NULL) \
- fclose(input_file); \
- if (memdst) \
- free(outbuffer); \
- return EXIT_FAILURE; \
-}
-
-#endif
-
-
-LOCAL(void)
-usage(void)
-/* complain about bad command line */
-{
- fprintf(stderr, "usage: %s [switches] ", progname);
-#ifdef TWO_FILE_COMMANDLINE
- fprintf(stderr, "inputfile outputfile\n");
-#else
- fprintf(stderr, "[inputfile]\n");
-#endif
-
- fprintf(stderr, "Switches (names may be abbreviated):\n");
- fprintf(stderr, " -quality N[,...] Compression quality (0..100; 5-95 is most useful range,\n");
- fprintf(stderr, " default is 75)\n");
- fprintf(stderr, " -grayscale Create monochrome JPEG file\n");
- fprintf(stderr, " -rgb Create RGB JPEG file\n");
-#ifdef ENTROPY_OPT_SUPPORTED
- fprintf(stderr, " -optimize Optimize Huffman table (smaller file, but slow compression)\n");
-#endif
-#ifdef C_PROGRESSIVE_SUPPORTED
- fprintf(stderr, " -progressive Create progressive JPEG file\n");
-#endif
-#ifdef TARGA_SUPPORTED
- fprintf(stderr, " -targa Input file is Targa format (usually not needed)\n");
-#endif
- fprintf(stderr, "Switches for advanced users:\n");
-#ifdef C_ARITH_CODING_SUPPORTED
- fprintf(stderr, " -arithmetic Use arithmetic coding\n");
-#endif
-#ifdef DCT_ISLOW_SUPPORTED
- fprintf(stderr, " -dct int Use accurate integer DCT method%s\n",
- (JDCT_DEFAULT == JDCT_ISLOW ? " (default)" : ""));
-#endif
-#ifdef DCT_IFAST_SUPPORTED
- fprintf(stderr, " -dct fast Use less accurate integer DCT method [legacy feature]%s\n",
- (JDCT_DEFAULT == JDCT_IFAST ? " (default)" : ""));
-#endif
-#ifdef DCT_FLOAT_SUPPORTED
- fprintf(stderr, " -dct float Use floating-point DCT method [legacy feature]%s\n",
- (JDCT_DEFAULT == JDCT_FLOAT ? " (default)" : ""));
-#endif
- fprintf(stderr, " -icc FILE Embed ICC profile contained in FILE\n");
- fprintf(stderr, " -restart N Set restart interval in rows, or in blocks with B\n");
-#ifdef INPUT_SMOOTHING_SUPPORTED
- fprintf(stderr, " -smooth N Smooth dithered input (N=1..100 is strength)\n");
-#endif
- fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n");
- fprintf(stderr, " -outfile name Specify name for output file\n");
-#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
- fprintf(stderr, " -memdst Compress to memory instead of file (useful for benchmarking)\n");
-#endif
- fprintf(stderr, " -report Report compression progress\n");
- fprintf(stderr, " -strict Treat all warnings as fatal\n");
- fprintf(stderr, " -verbose or -debug Emit debug output\n");
- fprintf(stderr, " -version Print version information and exit\n");
- fprintf(stderr, "Switches for wizards:\n");
- fprintf(stderr, " -baseline Force baseline quantization tables\n");
- fprintf(stderr, " -qtables FILE Use quantization tables given in FILE\n");
- fprintf(stderr, " -qslots N[,...] Set component quantization tables\n");
- fprintf(stderr, " -sample HxV[,...] Set component sampling factors\n");
-#ifdef C_MULTISCAN_FILES_SUPPORTED
- fprintf(stderr, " -scans FILE Create multi-scan JPEG per script FILE\n");
-#endif
- exit(EXIT_FAILURE);
-}
-
-
-LOCAL(int)
-parse_switches(j_compress_ptr cinfo, int argc, char **argv,
- int last_file_arg_seen, boolean for_real)
-/* Parse optional switches.
- * Returns argv[] index of first file-name argument (== argc if none).
- * Any file names with indexes <= last_file_arg_seen are ignored;
- * they have presumably been processed in a previous iteration.
- * (Pass 0 for last_file_arg_seen on the first or only iteration.)
- * for_real is FALSE on the first (dummy) pass; we may skip any expensive
- * processing.
- */
-{
- int argn;
- char *arg;
- boolean force_baseline;
- boolean simple_progressive;
- char *qualityarg = NULL; /* saves -quality parm if any */
- char *qtablefile = NULL; /* saves -qtables filename if any */
- char *qslotsarg = NULL; /* saves -qslots parm if any */
- char *samplearg = NULL; /* saves -sample parm if any */
- char *scansarg = NULL; /* saves -scans parm if any */
-
- /* Set up default JPEG parameters. */
-
- force_baseline = FALSE; /* by default, allow 16-bit quantizers */
- simple_progressive = FALSE;
- is_targa = FALSE;
- icc_filename = NULL;
- outfilename = NULL;
- memdst = FALSE;
- report = FALSE;
- strict = FALSE;
- cinfo->err->trace_level = 0;
-
- /* Scan command line options, adjust parameters */
-
- for (argn = 1; argn < argc; argn++) {
- arg = argv[argn];
- if (*arg != '-') {
- /* Not a switch, must be a file name argument */
- if (argn <= last_file_arg_seen) {
- outfilename = NULL; /* -outfile applies to just one input file */
- continue; /* ignore this name if previously processed */
- }
- break; /* else done parsing switches */
- }
- arg++; /* advance past switch marker character */
-
- if (keymatch(arg, "arithmetic", 1)) {
- /* Use arithmetic coding. */
-#ifdef C_ARITH_CODING_SUPPORTED
- cinfo->arith_code = TRUE;
-#else
- fprintf(stderr, "%s: sorry, arithmetic coding not supported\n",
- progname);
- exit(EXIT_FAILURE);
-#endif
-
- } else if (keymatch(arg, "baseline", 1)) {
- /* Force baseline-compatible output (8-bit quantizer values). */
- force_baseline = TRUE;
-
- } else if (keymatch(arg, "dct", 2)) {
- /* Select DCT algorithm. */
- if (++argn >= argc) /* advance to next argument */
- usage();
- if (keymatch(argv[argn], "int", 1)) {
- cinfo->dct_method = JDCT_ISLOW;
- } else if (keymatch(argv[argn], "fast", 2)) {
- cinfo->dct_method = JDCT_IFAST;
- } else if (keymatch(argv[argn], "float", 2)) {
- cinfo->dct_method = JDCT_FLOAT;
- } else
- usage();
-
- } else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) {
- /* Enable debug printouts. */
- /* On first -d, print version identification */
- static boolean printed_version = FALSE;
-
- if (!printed_version) {
- fprintf(stderr, "%s version %s (build %s)\n",
- PACKAGE_NAME, VERSION, BUILD);
- fprintf(stderr, "%s\n\n", JCOPYRIGHT);
- fprintf(stderr, "Emulating The Independent JPEG Group's software, version %s\n\n",
- JVERSION);
- printed_version = TRUE;
- }
- cinfo->err->trace_level++;
-
- } else if (keymatch(arg, "version", 4)) {
- fprintf(stderr, "%s version %s (build %s)\n",
- PACKAGE_NAME, VERSION, BUILD);
- exit(EXIT_SUCCESS);
-
- } else if (keymatch(arg, "grayscale", 2) ||
- keymatch(arg, "greyscale", 2)) {
- /* Force a monochrome JPEG file to be generated. */
- jpeg_set_colorspace(cinfo, JCS_GRAYSCALE);
-
- } else if (keymatch(arg, "rgb", 3)) {
- /* Force an RGB JPEG file to be generated. */
- jpeg_set_colorspace(cinfo, JCS_RGB);
-
- } else if (keymatch(arg, "icc", 1)) {
- /* Set ICC filename. */
- if (++argn >= argc) /* advance to next argument */
- usage();
- icc_filename = argv[argn];
-
- } else if (keymatch(arg, "maxmemory", 3)) {
- /* Maximum memory in Kb (or Mb with 'm'). */
- long lval;
- char ch = 'x';
-
- if (++argn >= argc) /* advance to next argument */
- usage();
- if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1)
- usage();
- if (ch == 'm' || ch == 'M')
- lval *= 1000L;
- cinfo->mem->max_memory_to_use = lval * 1000L;
-
- } else if (keymatch(arg, "optimize", 1) || keymatch(arg, "optimise", 1)) {
- /* Enable entropy parm optimization. */
-#ifdef ENTROPY_OPT_SUPPORTED
- cinfo->optimize_coding = TRUE;
-#else
- fprintf(stderr, "%s: sorry, entropy optimization was not compiled in\n",
- progname);
- exit(EXIT_FAILURE);
-#endif
-
- } else if (keymatch(arg, "outfile", 4)) {
- /* Set output file name. */
- if (++argn >= argc) /* advance to next argument */
- usage();
- outfilename = argv[argn]; /* save it away for later use */
-
- } else if (keymatch(arg, "progressive", 1)) {
- /* Select simple progressive mode. */
-#ifdef C_PROGRESSIVE_SUPPORTED
- simple_progressive = TRUE;
- /* We must postpone execution until num_components is known. */
-#else
- fprintf(stderr, "%s: sorry, progressive output was not compiled in\n",
- progname);
- exit(EXIT_FAILURE);
-#endif
-
- } else if (keymatch(arg, "memdst", 2)) {
- /* Use in-memory destination manager */
-#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
- memdst = TRUE;
-#else
- fprintf(stderr, "%s: sorry, in-memory destination manager was not compiled in\n",
- progname);
- exit(EXIT_FAILURE);
-#endif
-
- } else if (keymatch(arg, "quality", 1)) {
- /* Quality ratings (quantization table scaling factors). */
- if (++argn >= argc) /* advance to next argument */
- usage();
- qualityarg = argv[argn];
-
- } else if (keymatch(arg, "qslots", 2)) {
- /* Quantization table slot numbers. */
- if (++argn >= argc) /* advance to next argument */
- usage();
- qslotsarg = argv[argn];
- /* Must delay setting qslots until after we have processed any
- * colorspace-determining switches, since jpeg_set_colorspace sets
- * default quant table numbers.
- */
-
- } else if (keymatch(arg, "qtables", 2)) {
- /* Quantization tables fetched from file. */
- if (++argn >= argc) /* advance to next argument */
- usage();
- qtablefile = argv[argn];
- /* We postpone actually reading the file in case -quality comes later. */
-
- } else if (keymatch(arg, "report", 3)) {
- report = TRUE;
-
- } else if (keymatch(arg, "restart", 1)) {
- /* Restart interval in MCU rows (or in MCUs with 'b'). */
- long lval;
- char ch = 'x';
-
- if (++argn >= argc) /* advance to next argument */
- usage();
- if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1)
- usage();
- if (lval < 0 || lval > 65535L)
- usage();
- if (ch == 'b' || ch == 'B') {
- cinfo->restart_interval = (unsigned int)lval;
- cinfo->restart_in_rows = 0; /* else prior '-restart n' overrides me */
- } else {
- cinfo->restart_in_rows = (int)lval;
- /* restart_interval will be computed during startup */
- }
-
- } else if (keymatch(arg, "sample", 2)) {
- /* Set sampling factors. */
- if (++argn >= argc) /* advance to next argument */
- usage();
- samplearg = argv[argn];
- /* Must delay setting sample factors until after we have processed any
- * colorspace-determining switches, since jpeg_set_colorspace sets
- * default sampling factors.
- */
-
- } else if (keymatch(arg, "scans", 4)) {
- /* Set scan script. */
-#ifdef C_MULTISCAN_FILES_SUPPORTED
- if (++argn >= argc) /* advance to next argument */
- usage();
- scansarg = argv[argn];
- /* We must postpone reading the file in case -progressive appears. */
-#else
- fprintf(stderr, "%s: sorry, multi-scan output was not compiled in\n",
- progname);
- exit(EXIT_FAILURE);
-#endif
-
- } else if (keymatch(arg, "smooth", 2)) {
- /* Set input smoothing factor. */
- int val;
-
- if (++argn >= argc) /* advance to next argument */
- usage();
- if (sscanf(argv[argn], "%d", &val) != 1)
- usage();
- if (val < 0 || val > 100)
- usage();
- cinfo->smoothing_factor = val;
-
- } else if (keymatch(arg, "strict", 2)) {
- strict = TRUE;
-
- } else if (keymatch(arg, "targa", 1)) {
- /* Input file is Targa format. */
- is_targa = TRUE;
-
- } else {
- usage(); /* bogus switch */
- }
- }
-
- /* Post-switch-scanning cleanup */
-
- if (for_real) {
-
- /* Set quantization tables for selected quality. */
- /* Some or all may be overridden if -qtables is present. */
- if (qualityarg != NULL) /* process -quality if it was present */
- if (!set_quality_ratings(cinfo, qualityarg, force_baseline))
- usage();
-
- if (qtablefile != NULL) /* process -qtables if it was present */
- if (!read_quant_tables(cinfo, qtablefile, force_baseline))
- usage();
-
- if (qslotsarg != NULL) /* process -qslots if it was present */
- if (!set_quant_slots(cinfo, qslotsarg))
- usage();
-
- if (samplearg != NULL) /* process -sample if it was present */
- if (!set_sample_factors(cinfo, samplearg))
- usage();
-
-#ifdef C_PROGRESSIVE_SUPPORTED
- if (simple_progressive) /* process -progressive; -scans can override */
- jpeg_simple_progression(cinfo);
-#endif
-
-#ifdef C_MULTISCAN_FILES_SUPPORTED
- if (scansarg != NULL) /* process -scans if it was present */
- if (!read_scan_script(cinfo, scansarg))
- usage();
-#endif
- }
-
- return argn; /* return index of next arg (file name) */
-}
-
-
-METHODDEF(void)
-my_emit_message(j_common_ptr cinfo, int msg_level)
-{
- if (msg_level < 0) {
- /* Treat warning as fatal */
- cinfo->err->error_exit(cinfo);
- } else {
- if (cinfo->err->trace_level >= msg_level)
- cinfo->err->output_message(cinfo);
- }
-}
-
-
-/*
- * The main program.
- */
-
-int
-main(int argc, char **argv)
-{
- struct jpeg_compress_struct cinfo;
-#ifdef CJPEG_FUZZER
- struct my_error_mgr myerr;
- struct jpeg_error_mgr &jerr = myerr.pub;
-#else
- struct jpeg_error_mgr jerr;
-#endif
- struct cdjpeg_progress_mgr progress;
- int file_index;
- cjpeg_source_ptr src_mgr;
- FILE *input_file = NULL;
- FILE *icc_file;
- JOCTET *icc_profile = NULL;
- long icc_len = 0;
- FILE *output_file = NULL;
- unsigned char *outbuffer = NULL;
- unsigned long outsize = 0;
- JDIMENSION num_scanlines;
-
- progname = argv[0];
- if (progname == NULL || progname[0] == 0)
- progname = "cjpeg"; /* in case C library doesn't provide it */
-
- /* Initialize the JPEG compression object with default error handling. */
- cinfo.err = jpeg_std_error(&jerr);
- jpeg_create_compress(&cinfo);
- /* Add some application-specific error messages (from cderror.h) */
- jerr.addon_message_table = cdjpeg_message_table;
- jerr.first_addon_message = JMSG_FIRSTADDONCODE;
- jerr.last_addon_message = JMSG_LASTADDONCODE;
-
- /* Initialize JPEG parameters.
- * Much of this may be overridden later.
- * In particular, we don't yet know the input file's color space,
- * but we need to provide some value for jpeg_set_defaults() to work.
- */
-
- cinfo.in_color_space = JCS_RGB; /* arbitrary guess */
- jpeg_set_defaults(&cinfo);
-
- /* Scan command line to find file names.
- * It is convenient to use just one switch-parsing routine, but the switch
- * values read here are ignored; we will rescan the switches after opening
- * the input file.
- */
-
- file_index = parse_switches(&cinfo, argc, argv, 0, FALSE);
-
- if (strict)
- jerr.emit_message = my_emit_message;
-
-#ifdef TWO_FILE_COMMANDLINE
- if (!memdst) {
- /* Must have either -outfile switch or explicit output file name */
- if (outfilename == NULL) {
- if (file_index != argc - 2) {
- fprintf(stderr, "%s: must name one input and one output file\n",
- progname);
- usage();
- }
- outfilename = argv[file_index + 1];
- } else {
- if (file_index != argc - 1) {
- fprintf(stderr, "%s: must name one input and one output file\n",
- progname);
- usage();
- }
- }
- }
-#else
- /* Unix style: expect zero or one file name */
- if (file_index < argc - 1) {
- fprintf(stderr, "%s: only one input file\n", progname);
- usage();
- }
-#endif /* TWO_FILE_COMMANDLINE */
-
- /* Open the input file. */
- if (file_index < argc) {
- if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) {
- fprintf(stderr, "%s: can't open %s\n", progname, argv[file_index]);
- exit(EXIT_FAILURE);
- }
- } else {
- /* default input file is stdin */
- input_file = read_stdin();
- }
-
- /* Open the output file. */
- if (outfilename != NULL) {
- if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) {
- fprintf(stderr, "%s: can't open %s\n", progname, outfilename);
- exit(EXIT_FAILURE);
- }
- } else if (!memdst) {
- /* default output file is stdout */
- output_file = write_stdout();
- }
-
- if (icc_filename != NULL) {
- if ((icc_file = fopen(icc_filename, READ_BINARY)) == NULL) {
- fprintf(stderr, "%s: can't open %s\n", progname, icc_filename);
- exit(EXIT_FAILURE);
- }
- if (fseek(icc_file, 0, SEEK_END) < 0 ||
- (icc_len = ftell(icc_file)) < 1 ||
- fseek(icc_file, 0, SEEK_SET) < 0) {
- fprintf(stderr, "%s: can't determine size of %s\n", progname,
- icc_filename);
- exit(EXIT_FAILURE);
- }
- if ((icc_profile = (JOCTET *)malloc(icc_len)) == NULL) {
- fprintf(stderr, "%s: can't allocate memory for ICC profile\n", progname);
- fclose(icc_file);
- exit(EXIT_FAILURE);
- }
- if (fread(icc_profile, icc_len, 1, icc_file) < 1) {
- fprintf(stderr, "%s: can't read ICC profile from %s\n", progname,
- icc_filename);
- free(icc_profile);
- fclose(icc_file);
- exit(EXIT_FAILURE);
- }
- fclose(icc_file);
- }
-
-#ifdef CJPEG_FUZZER
- jerr.error_exit = my_error_exit;
- jerr.emit_message = my_emit_message_fuzzer;
- if (setjmp(myerr.setjmp_buffer))
- HANDLE_ERROR()
-#endif
-
- if (report) {
- start_progress_monitor((j_common_ptr)&cinfo, &progress);
- progress.report = report;
- }
-
- /* Figure out the input file format, and set up to read it. */
- src_mgr = select_file_type(&cinfo, input_file);
- src_mgr->input_file = input_file;
-#ifdef CJPEG_FUZZER
- src_mgr->max_pixels = 1048576;
-#endif
-
- /* Read the input file header to obtain file size & colorspace. */
- (*src_mgr->start_input) (&cinfo, src_mgr);
-
- /* Now that we know input colorspace, fix colorspace-dependent defaults */
- jpeg_default_colorspace(&cinfo);
-
- /* Adjust default compression parameters by re-parsing the options */
- file_index = parse_switches(&cinfo, argc, argv, 0, TRUE);
-
- /* Specify data destination for compression */
-#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
- if (memdst)
- jpeg_mem_dest(&cinfo, &outbuffer, &outsize);
- else
-#endif
- jpeg_stdio_dest(&cinfo, output_file);
-
-#ifdef CJPEG_FUZZER
- if (setjmp(myerr.setjmp_buffer))
- HANDLE_ERROR()
-#endif
-
- /* Start compressor */
- jpeg_start_compress(&cinfo, TRUE);
-
- if (icc_profile != NULL)
- jpeg_write_icc_profile(&cinfo, icc_profile, (unsigned int)icc_len);
-
- /* Process data */
- while (cinfo.next_scanline < cinfo.image_height) {
- num_scanlines = (*src_mgr->get_pixel_rows) (&cinfo, src_mgr);
- (void)jpeg_write_scanlines(&cinfo, src_mgr->buffer, num_scanlines);
- }
-
- /* Finish compression and release memory */
- (*src_mgr->finish_input) (&cinfo, src_mgr);
- jpeg_finish_compress(&cinfo);
- jpeg_destroy_compress(&cinfo);
-
- /* Close files, if we opened them */
- if (input_file != stdin)
- fclose(input_file);
- if (output_file != stdout && output_file != NULL)
- fclose(output_file);
-
- if (report)
- end_progress_monitor((j_common_ptr)&cinfo);
-
- if (memdst) {
-#ifndef CJPEG_FUZZER
- fprintf(stderr, "Compressed size: %lu bytes\n", outsize);
-#endif
- free(outbuffer);
- }
-
- free(icc_profile);
-
- /* All done. */
- return (jerr.num_warnings ? EXIT_WARNING : EXIT_SUCCESS);
-}
diff --git a/contrib/libs/libjpeg-turbo/cjpeg/ya.make b/contrib/libs/libjpeg-turbo/cjpeg/ya.make
deleted file mode 100644
index 6e53b51c5a..0000000000
--- a/contrib/libs/libjpeg-turbo/cjpeg/ya.make
+++ /dev/null
@@ -1,38 +0,0 @@
-# Generated by devtools/yamaker.
-
-PROGRAM()
-
-WITHOUT_LICENSE_TEXTS()
-
-PEERDIR(
- contrib/libs/libjpeg-turbo
-)
-
-ADDINCL(
- contrib/libs/libjpeg-turbo
-)
-
-NO_COMPILER_WARNINGS()
-
-NO_RUNTIME()
-
-CFLAGS(
- -DBMP_SUPPORTED
- -DGIF_SUPPORTED
- -DPPM_SUPPORTED
- -DTARGA_SUPPORTED
-)
-
-SRCDIR(contrib/libs/libjpeg-turbo)
-
-SRCS(
- cdjpeg.c
- cjpeg.c
- rdbmp.c
- rdgif.c
- rdppm.c
- rdswitch.c
- rdtarga.c
-)
-
-END()
diff --git a/contrib/libs/libjpeg-turbo/cmyk.h b/contrib/libs/libjpeg-turbo/cmyk.h
deleted file mode 100644
index 48187a8f5d..0000000000
--- a/contrib/libs/libjpeg-turbo/cmyk.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * cmyk.h
- *
- * Copyright (C) 2017-2018, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains convenience functions for performing quick & dirty
- * CMYK<->RGB conversion. This algorithm is suitable for testing purposes
- * only. Properly converting between CMYK and RGB requires a color management
- * system.
- */
-
-#ifndef CMYK_H
-#define CMYK_H
-
-#include <jinclude.h>
-#define JPEG_INTERNALS
-#include <jpeglib.h>
-#include "jconfigint.h"
-
-
-/* Fully reversible */
-
-INLINE
-LOCAL(void)
-rgb_to_cmyk(JSAMPLE r, JSAMPLE g, JSAMPLE b, JSAMPLE *c, JSAMPLE *m,
- JSAMPLE *y, JSAMPLE *k)
-{
- double ctmp = 1.0 - ((double)r / 255.0);
- double mtmp = 1.0 - ((double)g / 255.0);
- double ytmp = 1.0 - ((double)b / 255.0);
- double ktmp = MIN(MIN(ctmp, mtmp), ytmp);
-
- if (ktmp == 1.0) ctmp = mtmp = ytmp = 0.0;
- else {
- ctmp = (ctmp - ktmp) / (1.0 - ktmp);
- mtmp = (mtmp - ktmp) / (1.0 - ktmp);
- ytmp = (ytmp - ktmp) / (1.0 - ktmp);
- }
- *c = (JSAMPLE)(255.0 - ctmp * 255.0 + 0.5);
- *m = (JSAMPLE)(255.0 - mtmp * 255.0 + 0.5);
- *y = (JSAMPLE)(255.0 - ytmp * 255.0 + 0.5);
- *k = (JSAMPLE)(255.0 - ktmp * 255.0 + 0.5);
-}
-
-
-/* Fully reversible only for C/M/Y/K values generated with rgb_to_cmyk() */
-
-INLINE
-LOCAL(void)
-cmyk_to_rgb(JSAMPLE c, JSAMPLE m, JSAMPLE y, JSAMPLE k, JSAMPLE *r, JSAMPLE *g,
- JSAMPLE *b)
-{
- *r = (JSAMPLE)((double)c * (double)k / 255.0 + 0.5);
- *g = (JSAMPLE)((double)m * (double)k / 255.0 + 0.5);
- *b = (JSAMPLE)((double)y * (double)k / 255.0 + 0.5);
-}
-
-
-#endif /* CMYK_H */
diff --git a/contrib/libs/libjpeg-turbo/djpeg.c b/contrib/libs/libjpeg-turbo/djpeg.c
deleted file mode 100644
index 7666e3fec0..0000000000
--- a/contrib/libs/libjpeg-turbo/djpeg.c
+++ /dev/null
@@ -1,853 +0,0 @@
-/*
- * djpeg.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * Modified 2013-2019 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2010-2011, 2013-2017, 2019-2020, 2022, D. R. Commander.
- * Copyright (C) 2015, Google, Inc.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains a command-line user interface for the JPEG decompressor.
- * It should work on any system with Unix- or MS-DOS-style command lines.
- *
- * Two different command line styles are permitted, depending on the
- * compile-time switch TWO_FILE_COMMANDLINE:
- * djpeg [options] inputfile outputfile
- * djpeg [options] [inputfile]
- * In the second style, output is always to standard output, which you'd
- * normally redirect to a file or pipe to some other program. Input is
- * either from a named file or from standard input (typically redirected).
- * The second style is convenient on Unix but is unhelpful on systems that
- * don't support pipes. Also, you MUST use the first style if your system
- * doesn't do binary I/O to stdin/stdout.
- * To simplify script writing, the "-outfile" switch is provided. The syntax
- * djpeg [options] -outfile outputfile inputfile
- * works regardless of which command line style is used.
- */
-
-#ifdef _MSC_VER
-#define _CRT_SECURE_NO_DEPRECATE
-#endif
-
-#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
-#include "jversion.h" /* for version message */
-#include "jconfigint.h"
-
-#include <ctype.h> /* to declare isprint() */
-
-
-/* Create the add-on message string table. */
-
-#define JMESSAGE(code, string) string,
-
-static const char * const cdjpeg_message_table[] = {
-#include "cderror.h"
- NULL
-};
-
-
-/*
- * This list defines the known output image formats
- * (not all of which need be supported by a given version).
- * You can change the default output format by defining DEFAULT_FMT;
- * indeed, you had better do so if you undefine PPM_SUPPORTED.
- */
-
-typedef enum {
- FMT_BMP, /* BMP format (Windows flavor) */
- FMT_GIF, /* GIF format (LZW-compressed) */
- FMT_GIF0, /* GIF format (uncompressed) */
- FMT_OS2, /* BMP format (OS/2 flavor) */
- FMT_PPM, /* PPM/PGM (PBMPLUS formats) */
- FMT_TARGA, /* Targa format */
- FMT_TIFF /* TIFF format */
-} IMAGE_FORMATS;
-
-#ifndef DEFAULT_FMT /* so can override from CFLAGS in Makefile */
-#define DEFAULT_FMT FMT_PPM
-#endif
-
-static IMAGE_FORMATS requested_fmt;
-
-
-/*
- * Argument-parsing code.
- * The switch parser is designed to be useful with DOS-style command line
- * syntax, ie, intermixed switches and file names, where only the switches
- * to the left of a given file name affect processing of that file.
- * The main program in this file doesn't actually use this capability...
- */
-
-
-static const char *progname; /* program name for error messages */
-static char *icc_filename; /* for -icc switch */
-JDIMENSION max_scans; /* for -maxscans switch */
-static char *outfilename; /* for -outfile switch */
-boolean memsrc; /* for -memsrc switch */
-boolean report; /* for -report switch */
-boolean skip, crop;
-JDIMENSION skip_start, skip_end;
-JDIMENSION crop_x, crop_y, crop_width, crop_height;
-boolean strict; /* for -strict switch */
-#define INPUT_BUF_SIZE 4096
-
-
-LOCAL(void)
-usage(void)
-/* complain about bad command line */
-{
- fprintf(stderr, "usage: %s [switches] ", progname);
-#ifdef TWO_FILE_COMMANDLINE
- fprintf(stderr, "inputfile outputfile\n");
-#else
- fprintf(stderr, "[inputfile]\n");
-#endif
-
- fprintf(stderr, "Switches (names may be abbreviated):\n");
- fprintf(stderr, " -colors N Reduce image to no more than N colors\n");
- fprintf(stderr, " -fast Fast, low-quality processing\n");
- fprintf(stderr, " -grayscale Force grayscale output\n");
- fprintf(stderr, " -rgb Force RGB output\n");
- fprintf(stderr, " -rgb565 Force RGB565 output\n");
-#ifdef IDCT_SCALING_SUPPORTED
- fprintf(stderr, " -scale M/N Scale output image by fraction M/N, eg, 1/8\n");
-#endif
-#ifdef BMP_SUPPORTED
- fprintf(stderr, " -bmp Select BMP output format (Windows style)%s\n",
- (DEFAULT_FMT == FMT_BMP ? " (default)" : ""));
-#endif
-#ifdef GIF_SUPPORTED
- fprintf(stderr, " -gif Select GIF output format (LZW-compressed)%s\n",
- (DEFAULT_FMT == FMT_GIF ? " (default)" : ""));
- fprintf(stderr, " -gif0 Select GIF output format (uncompressed)%s\n",
- (DEFAULT_FMT == FMT_GIF0 ? " (default)" : ""));
-#endif
-#ifdef BMP_SUPPORTED
- fprintf(stderr, " -os2 Select BMP output format (OS/2 style)%s\n",
- (DEFAULT_FMT == FMT_OS2 ? " (default)" : ""));
-#endif
-#ifdef PPM_SUPPORTED
- fprintf(stderr, " -pnm Select PBMPLUS (PPM/PGM) output format%s\n",
- (DEFAULT_FMT == FMT_PPM ? " (default)" : ""));
-#endif
-#ifdef TARGA_SUPPORTED
- fprintf(stderr, " -targa Select Targa output format%s\n",
- (DEFAULT_FMT == FMT_TARGA ? " (default)" : ""));
-#endif
- fprintf(stderr, "Switches for advanced users:\n");
-#ifdef DCT_ISLOW_SUPPORTED
- fprintf(stderr, " -dct int Use accurate integer DCT method%s\n",
- (JDCT_DEFAULT == JDCT_ISLOW ? " (default)" : ""));
-#endif
-#ifdef DCT_IFAST_SUPPORTED
- fprintf(stderr, " -dct fast Use less accurate integer DCT method [legacy feature]%s\n",
- (JDCT_DEFAULT == JDCT_IFAST ? " (default)" : ""));
-#endif
-#ifdef DCT_FLOAT_SUPPORTED
- fprintf(stderr, " -dct float Use floating-point DCT method [legacy feature]%s\n",
- (JDCT_DEFAULT == JDCT_FLOAT ? " (default)" : ""));
-#endif
- fprintf(stderr, " -dither fs Use F-S dithering (default)\n");
- fprintf(stderr, " -dither none Don't use dithering in quantization\n");
- fprintf(stderr, " -dither ordered Use ordered dither (medium speed, quality)\n");
- fprintf(stderr, " -icc FILE Extract ICC profile to FILE\n");
-#ifdef QUANT_2PASS_SUPPORTED
- fprintf(stderr, " -map FILE Map to colors used in named image file\n");
-#endif
- fprintf(stderr, " -nosmooth Don't use high-quality upsampling\n");
-#ifdef QUANT_1PASS_SUPPORTED
- fprintf(stderr, " -onepass Use 1-pass quantization (fast, low quality)\n");
-#endif
- fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n");
- fprintf(stderr, " -maxscans N Maximum number of scans to allow in input file\n");
- fprintf(stderr, " -outfile name Specify name for output file\n");
-#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
- fprintf(stderr, " -memsrc Load input file into memory before decompressing\n");
-#endif
- fprintf(stderr, " -report Report decompression progress\n");
- fprintf(stderr, " -skip Y0,Y1 Decompress all rows except those between Y0 and Y1 (inclusive)\n");
- fprintf(stderr, " -crop WxH+X+Y Decompress only a rectangular subregion of the image\n");
- fprintf(stderr, " [requires PBMPLUS (PPM/PGM), GIF, or Targa output format]\n");
- fprintf(stderr, " -strict Treat all warnings as fatal\n");
- fprintf(stderr, " -verbose or -debug Emit debug output\n");
- fprintf(stderr, " -version Print version information and exit\n");
- exit(EXIT_FAILURE);
-}
-
-
-LOCAL(int)
-parse_switches(j_decompress_ptr cinfo, int argc, char **argv,
- int last_file_arg_seen, boolean for_real)
-/* Parse optional switches.
- * Returns argv[] index of first file-name argument (== argc if none).
- * Any file names with indexes <= last_file_arg_seen are ignored;
- * they have presumably been processed in a previous iteration.
- * (Pass 0 for last_file_arg_seen on the first or only iteration.)
- * for_real is FALSE on the first (dummy) pass; we may skip any expensive
- * processing.
- */
-{
- int argn;
- char *arg;
-
- /* Set up default JPEG parameters. */
- requested_fmt = DEFAULT_FMT; /* set default output file format */
- icc_filename = NULL;
- max_scans = 0;
- outfilename = NULL;
- memsrc = FALSE;
- report = FALSE;
- skip = FALSE;
- crop = FALSE;
- strict = FALSE;
- cinfo->err->trace_level = 0;
-
- /* Scan command line options, adjust parameters */
-
- for (argn = 1; argn < argc; argn++) {
- arg = argv[argn];
- if (*arg != '-') {
- /* Not a switch, must be a file name argument */
- if (argn <= last_file_arg_seen) {
- outfilename = NULL; /* -outfile applies to just one input file */
- continue; /* ignore this name if previously processed */
- }
- break; /* else done parsing switches */
- }
- arg++; /* advance past switch marker character */
-
- if (keymatch(arg, "bmp", 1)) {
- /* BMP output format (Windows flavor). */
- requested_fmt = FMT_BMP;
-
- } else if (keymatch(arg, "colors", 1) || keymatch(arg, "colours", 1) ||
- keymatch(arg, "quantize", 1) || keymatch(arg, "quantise", 1)) {
- /* Do color quantization. */
- int val;
-
- if (++argn >= argc) /* advance to next argument */
- usage();
- if (sscanf(argv[argn], "%d", &val) != 1)
- usage();
- cinfo->desired_number_of_colors = val;
- cinfo->quantize_colors = TRUE;
-
- } else if (keymatch(arg, "dct", 2)) {
- /* Select IDCT algorithm. */
- if (++argn >= argc) /* advance to next argument */
- usage();
- if (keymatch(argv[argn], "int", 1)) {
- cinfo->dct_method = JDCT_ISLOW;
- } else if (keymatch(argv[argn], "fast", 2)) {
- cinfo->dct_method = JDCT_IFAST;
- } else if (keymatch(argv[argn], "float", 2)) {
- cinfo->dct_method = JDCT_FLOAT;
- } else
- usage();
-
- } else if (keymatch(arg, "dither", 2)) {
- /* Select dithering algorithm. */
- if (++argn >= argc) /* advance to next argument */
- usage();
- if (keymatch(argv[argn], "fs", 2)) {
- cinfo->dither_mode = JDITHER_FS;
- } else if (keymatch(argv[argn], "none", 2)) {
- cinfo->dither_mode = JDITHER_NONE;
- } else if (keymatch(argv[argn], "ordered", 2)) {
- cinfo->dither_mode = JDITHER_ORDERED;
- } else
- usage();
-
- } else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) {
- /* Enable debug printouts. */
- /* On first -d, print version identification */
- static boolean printed_version = FALSE;
-
- if (!printed_version) {
- fprintf(stderr, "%s version %s (build %s)\n",
- PACKAGE_NAME, VERSION, BUILD);
- fprintf(stderr, "%s\n\n", JCOPYRIGHT);
- fprintf(stderr, "Emulating The Independent JPEG Group's software, version %s\n\n",
- JVERSION);
- printed_version = TRUE;
- }
- cinfo->err->trace_level++;
-
- } else if (keymatch(arg, "version", 4)) {
- fprintf(stderr, "%s version %s (build %s)\n",
- PACKAGE_NAME, VERSION, BUILD);
- exit(EXIT_SUCCESS);
-
- } else if (keymatch(arg, "fast", 1)) {
- /* Select recommended processing options for quick-and-dirty output. */
- cinfo->two_pass_quantize = FALSE;
- cinfo->dither_mode = JDITHER_ORDERED;
- if (!cinfo->quantize_colors) /* don't override an earlier -colors */
- cinfo->desired_number_of_colors = 216;
- cinfo->dct_method = JDCT_FASTEST;
- cinfo->do_fancy_upsampling = FALSE;
-
- } else if (keymatch(arg, "gif", 1)) {
- /* GIF output format (LZW-compressed). */
- requested_fmt = FMT_GIF;
-
- } else if (keymatch(arg, "gif0", 4)) {
- /* GIF output format (uncompressed). */
- requested_fmt = FMT_GIF0;
-
- } else if (keymatch(arg, "grayscale", 2) ||
- keymatch(arg, "greyscale", 2)) {
- /* Force monochrome output. */
- cinfo->out_color_space = JCS_GRAYSCALE;
-
- } else if (keymatch(arg, "rgb", 2)) {
- /* Force RGB output. */
- cinfo->out_color_space = JCS_RGB;
-
- } else if (keymatch(arg, "rgb565", 2)) {
- /* Force RGB565 output. */
- cinfo->out_color_space = JCS_RGB565;
-
- } else if (keymatch(arg, "icc", 1)) {
- /* Set ICC filename. */
- if (++argn >= argc) /* advance to next argument */
- usage();
- icc_filename = argv[argn];
- jpeg_save_markers(cinfo, JPEG_APP0 + 2, 0xFFFF);
-
- } else if (keymatch(arg, "map", 3)) {
- /* Quantize to a color map taken from an input file. */
- if (++argn >= argc) /* advance to next argument */
- usage();
- if (for_real) { /* too expensive to do twice! */
-#ifdef QUANT_2PASS_SUPPORTED /* otherwise can't quantize to supplied map */
- FILE *mapfile;
-
- if ((mapfile = fopen(argv[argn], READ_BINARY)) == NULL) {
- fprintf(stderr, "%s: can't open %s\n", progname, argv[argn]);
- exit(EXIT_FAILURE);
- }
- read_color_map(cinfo, mapfile);
- fclose(mapfile);
- cinfo->quantize_colors = TRUE;
-#else
- ERREXIT(cinfo, JERR_NOT_COMPILED);
-#endif
- }
-
- } else if (keymatch(arg, "maxmemory", 3)) {
- /* Maximum memory in Kb (or Mb with 'm'). */
- long lval;
- char ch = 'x';
-
- if (++argn >= argc) /* advance to next argument */
- usage();
- if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1)
- usage();
- if (ch == 'm' || ch == 'M')
- lval *= 1000L;
- cinfo->mem->max_memory_to_use = lval * 1000L;
-
- } else if (keymatch(arg, "maxscans", 4)) {
- if (++argn >= argc) /* advance to next argument */
- usage();
- if (sscanf(argv[argn], "%u", &max_scans) != 1)
- usage();
-
- } else if (keymatch(arg, "nosmooth", 3)) {
- /* Suppress fancy upsampling */
- cinfo->do_fancy_upsampling = FALSE;
-
- } else if (keymatch(arg, "onepass", 3)) {
- /* Use fast one-pass quantization. */
- cinfo->two_pass_quantize = FALSE;
-
- } else if (keymatch(arg, "os2", 3)) {
- /* BMP output format (OS/2 flavor). */
- requested_fmt = FMT_OS2;
-
- } else if (keymatch(arg, "outfile", 4)) {
- /* Set output file name. */
- if (++argn >= argc) /* advance to next argument */
- usage();
- outfilename = argv[argn]; /* save it away for later use */
-
- } else if (keymatch(arg, "memsrc", 2)) {
- /* Use in-memory source manager */
-#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
- memsrc = TRUE;
-#else
- fprintf(stderr, "%s: sorry, in-memory source manager was not compiled in\n",
- progname);
- exit(EXIT_FAILURE);
-#endif
-
- } else if (keymatch(arg, "pnm", 1) || keymatch(arg, "ppm", 1)) {
- /* PPM/PGM output format. */
- requested_fmt = FMT_PPM;
-
- } else if (keymatch(arg, "report", 2)) {
- report = TRUE;
-
- } else if (keymatch(arg, "scale", 2)) {
- /* Scale the output image by a fraction M/N. */
- if (++argn >= argc) /* advance to next argument */
- usage();
- if (sscanf(argv[argn], "%u/%u",
- &cinfo->scale_num, &cinfo->scale_denom) != 2)
- usage();
-
- } else if (keymatch(arg, "skip", 2)) {
- if (++argn >= argc)
- usage();
- if (sscanf(argv[argn], "%u,%u", &skip_start, &skip_end) != 2 ||
- skip_start > skip_end)
- usage();
- skip = TRUE;
-
- } else if (keymatch(arg, "crop", 2)) {
- char c;
- if (++argn >= argc)
- usage();
- if (sscanf(argv[argn], "%u%c%u+%u+%u", &crop_width, &c, &crop_height,
- &crop_x, &crop_y) != 5 ||
- (c != 'X' && c != 'x') || crop_width < 1 || crop_height < 1)
- usage();
- crop = TRUE;
-
- } else if (keymatch(arg, "strict", 2)) {
- strict = TRUE;
-
- } else if (keymatch(arg, "targa", 1)) {
- /* Targa output format. */
- requested_fmt = FMT_TARGA;
-
- } else {
- usage(); /* bogus switch */
- }
- }
-
- return argn; /* return index of next arg (file name) */
-}
-
-
-/*
- * Marker processor for COM and interesting APPn markers.
- * This replaces the library's built-in processor, which just skips the marker.
- * We want to print out the marker as text, to the extent possible.
- * Note this code relies on a non-suspending data source.
- */
-
-LOCAL(unsigned int)
-jpeg_getc(j_decompress_ptr cinfo)
-/* Read next byte */
-{
- struct jpeg_source_mgr *datasrc = cinfo->src;
-
- if (datasrc->bytes_in_buffer == 0) {
- if (!(*datasrc->fill_input_buffer) (cinfo))
- ERREXIT(cinfo, JERR_CANT_SUSPEND);
- }
- datasrc->bytes_in_buffer--;
- return *datasrc->next_input_byte++;
-}
-
-
-METHODDEF(boolean)
-print_text_marker(j_decompress_ptr cinfo)
-{
- boolean traceit = (cinfo->err->trace_level >= 1);
- long length;
- unsigned int ch;
- unsigned int lastch = 0;
-
- length = jpeg_getc(cinfo) << 8;
- length += jpeg_getc(cinfo);
- length -= 2; /* discount the length word itself */
-
- if (traceit) {
- if (cinfo->unread_marker == JPEG_COM)
- fprintf(stderr, "Comment, length %ld:\n", (long)length);
- else /* assume it is an APPn otherwise */
- fprintf(stderr, "APP%d, length %ld:\n",
- cinfo->unread_marker - JPEG_APP0, (long)length);
- }
-
- while (--length >= 0) {
- ch = jpeg_getc(cinfo);
- if (traceit) {
- /* Emit the character in a readable form.
- * Nonprintables are converted to \nnn form,
- * while \ is converted to \\.
- * Newlines in CR, CR/LF, or LF form will be printed as one newline.
- */
- if (ch == '\r') {
- fprintf(stderr, "\n");
- } else if (ch == '\n') {
- if (lastch != '\r')
- fprintf(stderr, "\n");
- } else if (ch == '\\') {
- fprintf(stderr, "\\\\");
- } else if (isprint(ch)) {
- putc(ch, stderr);
- } else {
- fprintf(stderr, "\\%03o", ch);
- }
- lastch = ch;
- }
- }
-
- if (traceit)
- fprintf(stderr, "\n");
-
- return TRUE;
-}
-
-
-METHODDEF(void)
-my_emit_message(j_common_ptr cinfo, int msg_level)
-{
- if (msg_level < 0) {
- /* Treat warning as fatal */
- cinfo->err->error_exit(cinfo);
- } else {
- if (cinfo->err->trace_level >= msg_level)
- cinfo->err->output_message(cinfo);
- }
-}
-
-
-/*
- * The main program.
- */
-
-int
-main(int argc, char **argv)
-{
- struct jpeg_decompress_struct cinfo;
- struct jpeg_error_mgr jerr;
- struct cdjpeg_progress_mgr progress;
- int file_index;
- djpeg_dest_ptr dest_mgr = NULL;
- FILE *input_file;
- FILE *output_file;
- unsigned char *inbuffer = NULL;
-#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
- unsigned long insize = 0;
-#endif
- JDIMENSION num_scanlines;
-
- progname = argv[0];
- if (progname == NULL || progname[0] == 0)
- progname = "djpeg"; /* in case C library doesn't provide it */
-
- /* Initialize the JPEG decompression object with default error handling. */
- cinfo.err = jpeg_std_error(&jerr);
- jpeg_create_decompress(&cinfo);
- /* Add some application-specific error messages (from cderror.h) */
- jerr.addon_message_table = cdjpeg_message_table;
- jerr.first_addon_message = JMSG_FIRSTADDONCODE;
- jerr.last_addon_message = JMSG_LASTADDONCODE;
-
- /* Insert custom marker processor for COM and APP12.
- * APP12 is used by some digital camera makers for textual info,
- * so we provide the ability to display it as text.
- * If you like, additional APPn marker types can be selected for display,
- * but don't try to override APP0 or APP14 this way (see libjpeg.txt).
- */
- jpeg_set_marker_processor(&cinfo, JPEG_COM, print_text_marker);
- jpeg_set_marker_processor(&cinfo, JPEG_APP0 + 12, print_text_marker);
-
- /* Scan command line to find file names. */
- /* It is convenient to use just one switch-parsing routine, but the switch
- * values read here are ignored; we will rescan the switches after opening
- * the input file.
- * (Exception: tracing level set here controls verbosity for COM markers
- * found during jpeg_read_header...)
- */
-
- file_index = parse_switches(&cinfo, argc, argv, 0, FALSE);
-
- if (strict)
- jerr.emit_message = my_emit_message;
-
-#ifdef TWO_FILE_COMMANDLINE
- /* Must have either -outfile switch or explicit output file name */
- if (outfilename == NULL) {
- if (file_index != argc - 2) {
- fprintf(stderr, "%s: must name one input and one output file\n",
- progname);
- usage();
- }
- outfilename = argv[file_index + 1];
- } else {
- if (file_index != argc - 1) {
- fprintf(stderr, "%s: must name one input and one output file\n",
- progname);
- usage();
- }
- }
-#else
- /* Unix style: expect zero or one file name */
- if (file_index < argc - 1) {
- fprintf(stderr, "%s: only one input file\n", progname);
- usage();
- }
-#endif /* TWO_FILE_COMMANDLINE */
-
- /* Open the input file. */
- if (file_index < argc) {
- if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) {
- fprintf(stderr, "%s: can't open %s\n", progname, argv[file_index]);
- exit(EXIT_FAILURE);
- }
- } else {
- /* default input file is stdin */
- input_file = read_stdin();
- }
-
- /* Open the output file. */
- if (outfilename != NULL) {
- if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) {
- fprintf(stderr, "%s: can't open %s\n", progname, outfilename);
- exit(EXIT_FAILURE);
- }
- } else {
- /* default output file is stdout */
- output_file = write_stdout();
- }
-
- if (report || max_scans != 0) {
- start_progress_monitor((j_common_ptr)&cinfo, &progress);
- progress.report = report;
- progress.max_scans = max_scans;
- }
-
- /* Specify data source for decompression */
-#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
- if (memsrc) {
- size_t nbytes;
- do {
- inbuffer = (unsigned char *)realloc(inbuffer, insize + INPUT_BUF_SIZE);
- if (inbuffer == NULL) {
- fprintf(stderr, "%s: memory allocation failure\n", progname);
- exit(EXIT_FAILURE);
- }
- nbytes = fread(&inbuffer[insize], 1, INPUT_BUF_SIZE, input_file);
- if (nbytes < INPUT_BUF_SIZE && ferror(input_file)) {
- if (file_index < argc)
- fprintf(stderr, "%s: can't read from %s\n", progname,
- argv[file_index]);
- else
- fprintf(stderr, "%s: can't read from stdin\n", progname);
- }
- insize += (unsigned long)nbytes;
- } while (nbytes == INPUT_BUF_SIZE);
- fprintf(stderr, "Compressed size: %lu bytes\n", insize);
- jpeg_mem_src(&cinfo, inbuffer, insize);
- } else
-#endif
- jpeg_stdio_src(&cinfo, input_file);
-
- /* Read file header, set default decompression parameters */
- (void)jpeg_read_header(&cinfo, TRUE);
-
- /* Adjust default decompression parameters by re-parsing the options */
- file_index = parse_switches(&cinfo, argc, argv, 0, TRUE);
-
- /* Initialize the output module now to let it override any crucial
- * option settings (for instance, GIF wants to force color quantization).
- */
- switch (requested_fmt) {
-#ifdef BMP_SUPPORTED
- case FMT_BMP:
- dest_mgr = jinit_write_bmp(&cinfo, FALSE, TRUE);
- break;
- case FMT_OS2:
- dest_mgr = jinit_write_bmp(&cinfo, TRUE, TRUE);
- break;
-#endif
-#ifdef GIF_SUPPORTED
- case FMT_GIF:
- dest_mgr = jinit_write_gif(&cinfo, TRUE);
- break;
- case FMT_GIF0:
- dest_mgr = jinit_write_gif(&cinfo, FALSE);
- break;
-#endif
-#ifdef PPM_SUPPORTED
- case FMT_PPM:
- dest_mgr = jinit_write_ppm(&cinfo);
- break;
-#endif
-#ifdef TARGA_SUPPORTED
- case FMT_TARGA:
- dest_mgr = jinit_write_targa(&cinfo);
- break;
-#endif
- default:
- ERREXIT(&cinfo, JERR_UNSUPPORTED_FORMAT);
- break;
- }
- dest_mgr->output_file = output_file;
-
- /* Start decompressor */
- (void)jpeg_start_decompress(&cinfo);
-
- /* Skip rows */
- if (skip) {
- JDIMENSION tmp;
-
- /* Check for valid skip_end. We cannot check this value until after
- * jpeg_start_decompress() is called. Note that we have already verified
- * that skip_start <= skip_end.
- */
- if (skip_end > cinfo.output_height - 1) {
- fprintf(stderr, "%s: skip region exceeds image height %u\n", progname,
- cinfo.output_height);
- exit(EXIT_FAILURE);
- }
-
- /* Write output file header. This is a hack to ensure that the destination
- * manager creates an output image of the proper size.
- */
- tmp = cinfo.output_height;
- cinfo.output_height -= (skip_end - skip_start + 1);
- (*dest_mgr->start_output) (&cinfo, dest_mgr);
- cinfo.output_height = tmp;
-
- /* Process data */
- while (cinfo.output_scanline < skip_start) {
- num_scanlines = jpeg_read_scanlines(&cinfo, dest_mgr->buffer,
- dest_mgr->buffer_height);
- (*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines);
- }
- if ((tmp = jpeg_skip_scanlines(&cinfo, skip_end - skip_start + 1)) !=
- skip_end - skip_start + 1) {
- fprintf(stderr, "%s: jpeg_skip_scanlines() returned %u rather than %u\n",
- progname, tmp, skip_end - skip_start + 1);
- exit(EXIT_FAILURE);
- }
- while (cinfo.output_scanline < cinfo.output_height) {
- num_scanlines = jpeg_read_scanlines(&cinfo, dest_mgr->buffer,
- dest_mgr->buffer_height);
- (*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines);
- }
-
- /* Decompress a subregion */
- } else if (crop) {
- JDIMENSION tmp;
-
- /* Check for valid crop dimensions. We cannot check these values until
- * after jpeg_start_decompress() is called.
- */
- if (crop_x + crop_width > cinfo.output_width ||
- crop_y + crop_height > cinfo.output_height) {
- fprintf(stderr, "%s: crop dimensions exceed image dimensions %u x %u\n",
- progname, cinfo.output_width, cinfo.output_height);
- exit(EXIT_FAILURE);
- }
-
- jpeg_crop_scanline(&cinfo, &crop_x, &crop_width);
- if (dest_mgr->calc_buffer_dimensions)
- (*dest_mgr->calc_buffer_dimensions) (&cinfo, dest_mgr);
- else
- ERREXIT(&cinfo, JERR_UNSUPPORTED_FORMAT);
-
- /* Write output file header. This is a hack to ensure that the destination
- * manager creates an output image of the proper size.
- */
- tmp = cinfo.output_height;
- cinfo.output_height = crop_height;
- (*dest_mgr->start_output) (&cinfo, dest_mgr);
- cinfo.output_height = tmp;
-
- /* Process data */
- if ((tmp = jpeg_skip_scanlines(&cinfo, crop_y)) != crop_y) {
- fprintf(stderr, "%s: jpeg_skip_scanlines() returned %u rather than %u\n",
- progname, tmp, crop_y);
- exit(EXIT_FAILURE);
- }
- while (cinfo.output_scanline < crop_y + crop_height) {
- num_scanlines = jpeg_read_scanlines(&cinfo, dest_mgr->buffer,
- dest_mgr->buffer_height);
- (*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines);
- }
- if ((tmp =
- jpeg_skip_scanlines(&cinfo,
- cinfo.output_height - crop_y - crop_height)) !=
- cinfo.output_height - crop_y - crop_height) {
- fprintf(stderr, "%s: jpeg_skip_scanlines() returned %u rather than %u\n",
- progname, tmp, cinfo.output_height - crop_y - crop_height);
- exit(EXIT_FAILURE);
- }
-
- /* Normal full-image decompress */
- } else {
- /* Write output file header */
- (*dest_mgr->start_output) (&cinfo, dest_mgr);
-
- /* Process data */
- while (cinfo.output_scanline < cinfo.output_height) {
- num_scanlines = jpeg_read_scanlines(&cinfo, dest_mgr->buffer,
- dest_mgr->buffer_height);
- (*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines);
- }
- }
-
- /* Hack: count final pass as done in case finish_output does an extra pass.
- * The library won't have updated completed_passes.
- */
- if (report || max_scans != 0)
- progress.pub.completed_passes = progress.pub.total_passes;
-
- if (icc_filename != NULL) {
- FILE *icc_file;
- JOCTET *icc_profile;
- unsigned int icc_len;
-
- if ((icc_file = fopen(icc_filename, WRITE_BINARY)) == NULL) {
- fprintf(stderr, "%s: can't open %s\n", progname, icc_filename);
- exit(EXIT_FAILURE);
- }
- if (jpeg_read_icc_profile(&cinfo, &icc_profile, &icc_len)) {
- if (fwrite(icc_profile, icc_len, 1, icc_file) < 1) {
- fprintf(stderr, "%s: can't read ICC profile from %s\n", progname,
- icc_filename);
- free(icc_profile);
- fclose(icc_file);
- exit(EXIT_FAILURE);
- }
- free(icc_profile);
- fclose(icc_file);
- } else if (cinfo.err->msg_code != JWRN_BOGUS_ICC)
- fprintf(stderr, "%s: no ICC profile data in JPEG file\n", progname);
- }
-
- /* Finish decompression and release memory.
- * I must do it in this order because output module has allocated memory
- * of lifespan JPOOL_IMAGE; it needs to finish before releasing memory.
- */
- (*dest_mgr->finish_output) (&cinfo, dest_mgr);
- (void)jpeg_finish_decompress(&cinfo);
- jpeg_destroy_decompress(&cinfo);
-
- /* Close files, if we opened them */
- if (input_file != stdin)
- fclose(input_file);
- if (output_file != stdout)
- fclose(output_file);
-
- if (report || max_scans != 0)
- end_progress_monitor((j_common_ptr)&cinfo);
-
- if (memsrc)
- free(inbuffer);
-
- /* All done. */
- exit(jerr.num_warnings ? EXIT_WARNING : EXIT_SUCCESS);
- return 0; /* suppress no-return-value warnings */
-}
diff --git a/contrib/libs/libjpeg-turbo/djpeg/ya.make b/contrib/libs/libjpeg-turbo/djpeg/ya.make
deleted file mode 100644
index adeccd41d0..0000000000
--- a/contrib/libs/libjpeg-turbo/djpeg/ya.make
+++ /dev/null
@@ -1,39 +0,0 @@
-# Generated by devtools/yamaker.
-
-PROGRAM()
-
-WITHOUT_LICENSE_TEXTS()
-
-PEERDIR(
- contrib/libs/libjpeg-turbo
-)
-
-ADDINCL(
- contrib/libs/libjpeg-turbo
-)
-
-NO_COMPILER_WARNINGS()
-
-NO_RUNTIME()
-
-CFLAGS(
- -DBMP_SUPPORTED
- -DGIF_SUPPORTED
- -DPPM_SUPPORTED
- -DTARGA_SUPPORTED
-)
-
-SRCDIR(contrib/libs/libjpeg-turbo)
-
-SRCS(
- cdjpeg.c
- djpeg.c
- rdcolmap.c
- rdswitch.c
- wrbmp.c
- wrgif.c
- wrppm.c
- wrtarga.c
-)
-
-END()
diff --git a/contrib/libs/libjpeg-turbo/jaricom.c b/contrib/libs/libjpeg-turbo/jaricom.c
deleted file mode 100644
index 215640cc44..0000000000
--- a/contrib/libs/libjpeg-turbo/jaricom.c
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * jaricom.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Developed 1997-2009 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2015, 2018, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains probability estimation tables for common use in
- * arithmetic entropy encoding and decoding routines.
- *
- * This data represents Table D.2 in
- * Recommendation ITU-T T.81 (1992) | ISO/IEC 10918-1:1994 and Table 24 in
- * Recommendation ITU-T T.82 (1993) | ISO/IEC 11544:1993.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-
-/* The following #define specifies the packing of the four components
- * into the compact JLONG representation.
- * Note that this formula must match the actual arithmetic encoder
- * and decoder implementation. The implementation has to be changed
- * if this formula is changed.
- * The current organization is leaned on Markus Kuhn's JBIG
- * implementation (jbig_tab.c).
- */
-
-#define V(i, a, b, c, d) \
- (((JLONG)a << 16) | ((JLONG)c << 8) | ((JLONG)d << 7) | b)
-
-const JLONG jpeg_aritab[113 + 1] = {
-/*
- * Index, Qe_Value, Next_Index_LPS, Next_Index_MPS, Switch_MPS
- */
- V( 0, 0x5a1d, 1, 1, 1 ),
- V( 1, 0x2586, 14, 2, 0 ),
- V( 2, 0x1114, 16, 3, 0 ),
- V( 3, 0x080b, 18, 4, 0 ),
- V( 4, 0x03d8, 20, 5, 0 ),
- V( 5, 0x01da, 23, 6, 0 ),
- V( 6, 0x00e5, 25, 7, 0 ),
- V( 7, 0x006f, 28, 8, 0 ),
- V( 8, 0x0036, 30, 9, 0 ),
- V( 9, 0x001a, 33, 10, 0 ),
- V( 10, 0x000d, 35, 11, 0 ),
- V( 11, 0x0006, 9, 12, 0 ),
- V( 12, 0x0003, 10, 13, 0 ),
- V( 13, 0x0001, 12, 13, 0 ),
- V( 14, 0x5a7f, 15, 15, 1 ),
- V( 15, 0x3f25, 36, 16, 0 ),
- V( 16, 0x2cf2, 38, 17, 0 ),
- V( 17, 0x207c, 39, 18, 0 ),
- V( 18, 0x17b9, 40, 19, 0 ),
- V( 19, 0x1182, 42, 20, 0 ),
- V( 20, 0x0cef, 43, 21, 0 ),
- V( 21, 0x09a1, 45, 22, 0 ),
- V( 22, 0x072f, 46, 23, 0 ),
- V( 23, 0x055c, 48, 24, 0 ),
- V( 24, 0x0406, 49, 25, 0 ),
- V( 25, 0x0303, 51, 26, 0 ),
- V( 26, 0x0240, 52, 27, 0 ),
- V( 27, 0x01b1, 54, 28, 0 ),
- V( 28, 0x0144, 56, 29, 0 ),
- V( 29, 0x00f5, 57, 30, 0 ),
- V( 30, 0x00b7, 59, 31, 0 ),
- V( 31, 0x008a, 60, 32, 0 ),
- V( 32, 0x0068, 62, 33, 0 ),
- V( 33, 0x004e, 63, 34, 0 ),
- V( 34, 0x003b, 32, 35, 0 ),
- V( 35, 0x002c, 33, 9, 0 ),
- V( 36, 0x5ae1, 37, 37, 1 ),
- V( 37, 0x484c, 64, 38, 0 ),
- V( 38, 0x3a0d, 65, 39, 0 ),
- V( 39, 0x2ef1, 67, 40, 0 ),
- V( 40, 0x261f, 68, 41, 0 ),
- V( 41, 0x1f33, 69, 42, 0 ),
- V( 42, 0x19a8, 70, 43, 0 ),
- V( 43, 0x1518, 72, 44, 0 ),
- V( 44, 0x1177, 73, 45, 0 ),
- V( 45, 0x0e74, 74, 46, 0 ),
- V( 46, 0x0bfb, 75, 47, 0 ),
- V( 47, 0x09f8, 77, 48, 0 ),
- V( 48, 0x0861, 78, 49, 0 ),
- V( 49, 0x0706, 79, 50, 0 ),
- V( 50, 0x05cd, 48, 51, 0 ),
- V( 51, 0x04de, 50, 52, 0 ),
- V( 52, 0x040f, 50, 53, 0 ),
- V( 53, 0x0363, 51, 54, 0 ),
- V( 54, 0x02d4, 52, 55, 0 ),
- V( 55, 0x025c, 53, 56, 0 ),
- V( 56, 0x01f8, 54, 57, 0 ),
- V( 57, 0x01a4, 55, 58, 0 ),
- V( 58, 0x0160, 56, 59, 0 ),
- V( 59, 0x0125, 57, 60, 0 ),
- V( 60, 0x00f6, 58, 61, 0 ),
- V( 61, 0x00cb, 59, 62, 0 ),
- V( 62, 0x00ab, 61, 63, 0 ),
- V( 63, 0x008f, 61, 32, 0 ),
- V( 64, 0x5b12, 65, 65, 1 ),
- V( 65, 0x4d04, 80, 66, 0 ),
- V( 66, 0x412c, 81, 67, 0 ),
- V( 67, 0x37d8, 82, 68, 0 ),
- V( 68, 0x2fe8, 83, 69, 0 ),
- V( 69, 0x293c, 84, 70, 0 ),
- V( 70, 0x2379, 86, 71, 0 ),
- V( 71, 0x1edf, 87, 72, 0 ),
- V( 72, 0x1aa9, 87, 73, 0 ),
- V( 73, 0x174e, 72, 74, 0 ),
- V( 74, 0x1424, 72, 75, 0 ),
- V( 75, 0x119c, 74, 76, 0 ),
- V( 76, 0x0f6b, 74, 77, 0 ),
- V( 77, 0x0d51, 75, 78, 0 ),
- V( 78, 0x0bb6, 77, 79, 0 ),
- V( 79, 0x0a40, 77, 48, 0 ),
- V( 80, 0x5832, 80, 81, 1 ),
- V( 81, 0x4d1c, 88, 82, 0 ),
- V( 82, 0x438e, 89, 83, 0 ),
- V( 83, 0x3bdd, 90, 84, 0 ),
- V( 84, 0x34ee, 91, 85, 0 ),
- V( 85, 0x2eae, 92, 86, 0 ),
- V( 86, 0x299a, 93, 87, 0 ),
- V( 87, 0x2516, 86, 71, 0 ),
- V( 88, 0x5570, 88, 89, 1 ),
- V( 89, 0x4ca9, 95, 90, 0 ),
- V( 90, 0x44d9, 96, 91, 0 ),
- V( 91, 0x3e22, 97, 92, 0 ),
- V( 92, 0x3824, 99, 93, 0 ),
- V( 93, 0x32b4, 99, 94, 0 ),
- V( 94, 0x2e17, 93, 86, 0 ),
- V( 95, 0x56a8, 95, 96, 1 ),
- V( 96, 0x4f46, 101, 97, 0 ),
- V( 97, 0x47e5, 102, 98, 0 ),
- V( 98, 0x41cf, 103, 99, 0 ),
- V( 99, 0x3c3d, 104, 100, 0 ),
- V( 100, 0x375e, 99, 93, 0 ),
- V( 101, 0x5231, 105, 102, 0 ),
- V( 102, 0x4c0f, 106, 103, 0 ),
- V( 103, 0x4639, 107, 104, 0 ),
- V( 104, 0x415e, 103, 99, 0 ),
- V( 105, 0x5627, 105, 106, 1 ),
- V( 106, 0x50e7, 108, 107, 0 ),
- V( 107, 0x4b85, 109, 103, 0 ),
- V( 108, 0x5597, 110, 109, 0 ),
- V( 109, 0x504f, 111, 107, 0 ),
- V( 110, 0x5a10, 110, 111, 1 ),
- V( 111, 0x5522, 112, 109, 0 ),
- V( 112, 0x59eb, 112, 111, 1 ),
-/*
- * This last entry is used for fixed probability estimate of 0.5
- * as recommended in Section 10.3 Table 5 of ITU-T Rec. T.851.
- */
- V( 113, 0x5a1d, 113, 113, 0 )
-};
diff --git a/contrib/libs/libjpeg-turbo/jcapimin.c b/contrib/libs/libjpeg-turbo/jcapimin.c
deleted file mode 100644
index 84e7ecc9a7..0000000000
--- a/contrib/libs/libjpeg-turbo/jcapimin.c
+++ /dev/null
@@ -1,295 +0,0 @@
-/*
- * jcapimin.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1994-1998, Thomas G. Lane.
- * Modified 2003-2010 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains application interface code for the compression half
- * of the JPEG library. These are the "minimum" API routines that may be
- * needed in either the normal full-compression case or the transcoding-only
- * case.
- *
- * Most of the routines intended to be called directly by an application
- * are in this file or in jcapistd.c. But also see jcparam.c for
- * parameter-setup helper routines, jcomapi.c for routines shared by
- * compression and decompression, and jctrans.c for the transcoding case.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-
-
-/*
- * Initialization of a JPEG compression object.
- * The error manager must already be set up (in case memory manager fails).
- */
-
-GLOBAL(void)
-jpeg_CreateCompress(j_compress_ptr cinfo, int version, size_t structsize)
-{
- int i;
-
- /* Guard against version mismatches between library and caller. */
- cinfo->mem = NULL; /* so jpeg_destroy knows mem mgr not called */
- if (version != JPEG_LIB_VERSION)
- ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version);
- if (structsize != sizeof(struct jpeg_compress_struct))
- ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE,
- (int)sizeof(struct jpeg_compress_struct), (int)structsize);
-
- /* For debugging purposes, we zero the whole master structure.
- * But the application has already set the err pointer, and may have set
- * client_data, so we have to save and restore those fields.
- * Note: if application hasn't set client_data, tools like Purify may
- * complain here.
- */
- {
- struct jpeg_error_mgr *err = cinfo->err;
- void *client_data = cinfo->client_data; /* ignore Purify complaint here */
- memset(cinfo, 0, sizeof(struct jpeg_compress_struct));
- cinfo->err = err;
- cinfo->client_data = client_data;
- }
- cinfo->is_decompressor = FALSE;
-
- /* Initialize a memory manager instance for this object */
- jinit_memory_mgr((j_common_ptr)cinfo);
-
- /* Zero out pointers to permanent structures. */
- cinfo->progress = NULL;
- cinfo->dest = NULL;
-
- cinfo->comp_info = NULL;
-
- for (i = 0; i < NUM_QUANT_TBLS; i++) {
- cinfo->quant_tbl_ptrs[i] = NULL;
-#if JPEG_LIB_VERSION >= 70
- cinfo->q_scale_factor[i] = 100;
-#endif
- }
-
- for (i = 0; i < NUM_HUFF_TBLS; i++) {
- cinfo->dc_huff_tbl_ptrs[i] = NULL;
- cinfo->ac_huff_tbl_ptrs[i] = NULL;
- }
-
-#if JPEG_LIB_VERSION >= 80
- /* Must do it here for emit_dqt in case jpeg_write_tables is used */
- cinfo->block_size = DCTSIZE;
- cinfo->natural_order = jpeg_natural_order;
- cinfo->lim_Se = DCTSIZE2 - 1;
-#endif
-
- cinfo->script_space = NULL;
-
- cinfo->input_gamma = 1.0; /* in case application forgets */
-
- /* OK, I'm ready */
- cinfo->global_state = CSTATE_START;
-}
-
-
-/*
- * Destruction of a JPEG compression object
- */
-
-GLOBAL(void)
-jpeg_destroy_compress(j_compress_ptr cinfo)
-{
- jpeg_destroy((j_common_ptr)cinfo); /* use common routine */
-}
-
-
-/*
- * Abort processing of a JPEG compression operation,
- * but don't destroy the object itself.
- */
-
-GLOBAL(void)
-jpeg_abort_compress(j_compress_ptr cinfo)
-{
- jpeg_abort((j_common_ptr)cinfo); /* use common routine */
-}
-
-
-/*
- * Forcibly suppress or un-suppress all quantization and Huffman tables.
- * Marks all currently defined tables as already written (if suppress)
- * or not written (if !suppress). This will control whether they get emitted
- * by a subsequent jpeg_start_compress call.
- *
- * This routine is exported for use by applications that want to produce
- * abbreviated JPEG datastreams. It logically belongs in jcparam.c, but
- * since it is called by jpeg_start_compress, we put it here --- otherwise
- * jcparam.o would be linked whether the application used it or not.
- */
-
-GLOBAL(void)
-jpeg_suppress_tables(j_compress_ptr cinfo, boolean suppress)
-{
- int i;
- JQUANT_TBL *qtbl;
- JHUFF_TBL *htbl;
-
- for (i = 0; i < NUM_QUANT_TBLS; i++) {
- if ((qtbl = cinfo->quant_tbl_ptrs[i]) != NULL)
- qtbl->sent_table = suppress;
- }
-
- for (i = 0; i < NUM_HUFF_TBLS; i++) {
- if ((htbl = cinfo->dc_huff_tbl_ptrs[i]) != NULL)
- htbl->sent_table = suppress;
- if ((htbl = cinfo->ac_huff_tbl_ptrs[i]) != NULL)
- htbl->sent_table = suppress;
- }
-}
-
-
-/*
- * Finish JPEG compression.
- *
- * If a multipass operating mode was selected, this may do a great deal of
- * work including most of the actual output.
- */
-
-GLOBAL(void)
-jpeg_finish_compress(j_compress_ptr cinfo)
-{
- JDIMENSION iMCU_row;
-
- if (cinfo->global_state == CSTATE_SCANNING ||
- cinfo->global_state == CSTATE_RAW_OK) {
- /* Terminate first pass */
- if (cinfo->next_scanline < cinfo->image_height)
- ERREXIT(cinfo, JERR_TOO_LITTLE_DATA);
- (*cinfo->master->finish_pass) (cinfo);
- } else if (cinfo->global_state != CSTATE_WRCOEFS)
- ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
- /* Perform any remaining passes */
- while (!cinfo->master->is_last_pass) {
- (*cinfo->master->prepare_for_pass) (cinfo);
- for (iMCU_row = 0; iMCU_row < cinfo->total_iMCU_rows; iMCU_row++) {
- if (cinfo->progress != NULL) {
- cinfo->progress->pass_counter = (long)iMCU_row;
- cinfo->progress->pass_limit = (long)cinfo->total_iMCU_rows;
- (*cinfo->progress->progress_monitor) ((j_common_ptr)cinfo);
- }
- /* We bypass the main controller and invoke coef controller directly;
- * all work is being done from the coefficient buffer.
- */
- if (!(*cinfo->coef->compress_data) (cinfo, (JSAMPIMAGE)NULL))
- ERREXIT(cinfo, JERR_CANT_SUSPEND);
- }
- (*cinfo->master->finish_pass) (cinfo);
- }
- /* Write EOI, do final cleanup */
- (*cinfo->marker->write_file_trailer) (cinfo);
- (*cinfo->dest->term_destination) (cinfo);
- /* We can use jpeg_abort to release memory and reset global_state */
- jpeg_abort((j_common_ptr)cinfo);
-}
-
-
-/*
- * Write a special marker.
- * This is only recommended for writing COM or APPn markers.
- * Must be called after jpeg_start_compress() and before
- * first call to jpeg_write_scanlines() or jpeg_write_raw_data().
- */
-
-GLOBAL(void)
-jpeg_write_marker(j_compress_ptr cinfo, int marker, const JOCTET *dataptr,
- unsigned int datalen)
-{
- void (*write_marker_byte) (j_compress_ptr info, int val);
-
- if (cinfo->next_scanline != 0 ||
- (cinfo->global_state != CSTATE_SCANNING &&
- cinfo->global_state != CSTATE_RAW_OK &&
- cinfo->global_state != CSTATE_WRCOEFS))
- ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
-
- (*cinfo->marker->write_marker_header) (cinfo, marker, datalen);
- write_marker_byte = cinfo->marker->write_marker_byte; /* copy for speed */
- while (datalen--) {
- (*write_marker_byte) (cinfo, *dataptr);
- dataptr++;
- }
-}
-
-/* Same, but piecemeal. */
-
-GLOBAL(void)
-jpeg_write_m_header(j_compress_ptr cinfo, int marker, unsigned int datalen)
-{
- if (cinfo->next_scanline != 0 ||
- (cinfo->global_state != CSTATE_SCANNING &&
- cinfo->global_state != CSTATE_RAW_OK &&
- cinfo->global_state != CSTATE_WRCOEFS))
- ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
-
- (*cinfo->marker->write_marker_header) (cinfo, marker, datalen);
-}
-
-GLOBAL(void)
-jpeg_write_m_byte(j_compress_ptr cinfo, int val)
-{
- (*cinfo->marker->write_marker_byte) (cinfo, val);
-}
-
-
-/*
- * Alternate compression function: just write an abbreviated table file.
- * Before calling this, all parameters and a data destination must be set up.
- *
- * To produce a pair of files containing abbreviated tables and abbreviated
- * image data, one would proceed as follows:
- *
- * initialize JPEG object
- * set JPEG parameters
- * set destination to table file
- * jpeg_write_tables(cinfo);
- * set destination to image file
- * jpeg_start_compress(cinfo, FALSE);
- * write data...
- * jpeg_finish_compress(cinfo);
- *
- * jpeg_write_tables has the side effect of marking all tables written
- * (same as jpeg_suppress_tables(..., TRUE)). Thus a subsequent start_compress
- * will not re-emit the tables unless it is passed write_all_tables=TRUE.
- */
-
-GLOBAL(void)
-jpeg_write_tables(j_compress_ptr cinfo)
-{
- if (cinfo->global_state != CSTATE_START)
- ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
-
- /* (Re)initialize error mgr and destination modules */
- (*cinfo->err->reset_error_mgr) ((j_common_ptr)cinfo);
- (*cinfo->dest->init_destination) (cinfo);
- /* Initialize the marker writer ... bit of a crock to do it here. */
- jinit_marker_writer(cinfo);
- /* Write them tables! */
- (*cinfo->marker->write_tables_only) (cinfo);
- /* And clean up. */
- (*cinfo->dest->term_destination) (cinfo);
- /*
- * In library releases up through v6a, we called jpeg_abort() here to free
- * any working memory allocated by the destination manager and marker
- * writer. Some applications had a problem with that: they allocated space
- * of their own from the library memory manager, and didn't want it to go
- * away during write_tables. So now we do nothing. This will cause a
- * memory leak if an app calls write_tables repeatedly without doing a full
- * compression cycle or otherwise resetting the JPEG object. However, that
- * seems less bad than unexpectedly freeing memory in the normal case.
- * An app that prefers the old behavior can call jpeg_abort for itself after
- * each call to jpeg_write_tables().
- */
-}
diff --git a/contrib/libs/libjpeg-turbo/jcapistd.c b/contrib/libs/libjpeg-turbo/jcapistd.c
deleted file mode 100644
index aa2aad9f66..0000000000
--- a/contrib/libs/libjpeg-turbo/jcapistd.c
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * jcapistd.c
- *
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * This file is part of the Independent JPEG Group's software.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains application interface code for the compression half
- * of the JPEG library. These are the "standard" API routines that are
- * used in the normal full-compression case. They are not used by a
- * transcoding-only application. Note that if an application links in
- * jpeg_start_compress, it will end up linking in the entire compressor.
- * We thus must separate this file from jcapimin.c to avoid linking the
- * whole compression library into a transcoder.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-
-
-/*
- * Compression initialization.
- * Before calling this, all parameters and a data destination must be set up.
- *
- * We require a write_all_tables parameter as a failsafe check when writing
- * multiple datastreams from the same compression object. Since prior runs
- * will have left all the tables marked sent_table=TRUE, a subsequent run
- * would emit an abbreviated stream (no tables) by default. This may be what
- * is wanted, but for safety's sake it should not be the default behavior:
- * programmers should have to make a deliberate choice to emit abbreviated
- * images. Therefore the documentation and examples should encourage people
- * to pass write_all_tables=TRUE; then it will take active thought to do the
- * wrong thing.
- */
-
-GLOBAL(void)
-jpeg_start_compress(j_compress_ptr cinfo, boolean write_all_tables)
-{
- if (cinfo->global_state != CSTATE_START)
- ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
-
- if (write_all_tables)
- jpeg_suppress_tables(cinfo, FALSE); /* mark all tables to be written */
-
- /* (Re)initialize error mgr and destination modules */
- (*cinfo->err->reset_error_mgr) ((j_common_ptr)cinfo);
- (*cinfo->dest->init_destination) (cinfo);
- /* Perform master selection of active modules */
- jinit_compress_master(cinfo);
- /* Set up for the first pass */
- (*cinfo->master->prepare_for_pass) (cinfo);
- /* Ready for application to drive first pass through jpeg_write_scanlines
- * or jpeg_write_raw_data.
- */
- cinfo->next_scanline = 0;
- cinfo->global_state = (cinfo->raw_data_in ? CSTATE_RAW_OK : CSTATE_SCANNING);
-}
-
-
-/*
- * Write some scanlines of data to the JPEG compressor.
- *
- * The return value will be the number of lines actually written.
- * This should be less than the supplied num_lines only in case that
- * the data destination module has requested suspension of the compressor,
- * or if more than image_height scanlines are passed in.
- *
- * Note: we warn about excess calls to jpeg_write_scanlines() since
- * this likely signals an application programmer error. However,
- * excess scanlines passed in the last valid call are *silently* ignored,
- * so that the application need not adjust num_lines for end-of-image
- * when using a multiple-scanline buffer.
- */
-
-GLOBAL(JDIMENSION)
-jpeg_write_scanlines(j_compress_ptr cinfo, JSAMPARRAY scanlines,
- JDIMENSION num_lines)
-{
- JDIMENSION row_ctr, rows_left;
-
- if (cinfo->global_state != CSTATE_SCANNING)
- ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
- if (cinfo->next_scanline >= cinfo->image_height)
- WARNMS(cinfo, JWRN_TOO_MUCH_DATA);
-
- /* Call progress monitor hook if present */
- if (cinfo->progress != NULL) {
- cinfo->progress->pass_counter = (long)cinfo->next_scanline;
- cinfo->progress->pass_limit = (long)cinfo->image_height;
- (*cinfo->progress->progress_monitor) ((j_common_ptr)cinfo);
- }
-
- /* Give master control module another chance if this is first call to
- * jpeg_write_scanlines. This lets output of the frame/scan headers be
- * delayed so that application can write COM, etc, markers between
- * jpeg_start_compress and jpeg_write_scanlines.
- */
- if (cinfo->master->call_pass_startup)
- (*cinfo->master->pass_startup) (cinfo);
-
- /* Ignore any extra scanlines at bottom of image. */
- rows_left = cinfo->image_height - cinfo->next_scanline;
- if (num_lines > rows_left)
- num_lines = rows_left;
-
- row_ctr = 0;
- (*cinfo->main->process_data) (cinfo, scanlines, &row_ctr, num_lines);
- cinfo->next_scanline += row_ctr;
- return row_ctr;
-}
-
-
-/*
- * Alternate entry point to write raw data.
- * Processes exactly one iMCU row per call, unless suspended.
- */
-
-GLOBAL(JDIMENSION)
-jpeg_write_raw_data(j_compress_ptr cinfo, JSAMPIMAGE data,
- JDIMENSION num_lines)
-{
- JDIMENSION lines_per_iMCU_row;
-
- if (cinfo->global_state != CSTATE_RAW_OK)
- ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
- if (cinfo->next_scanline >= cinfo->image_height) {
- WARNMS(cinfo, JWRN_TOO_MUCH_DATA);
- return 0;
- }
-
- /* Call progress monitor hook if present */
- if (cinfo->progress != NULL) {
- cinfo->progress->pass_counter = (long)cinfo->next_scanline;
- cinfo->progress->pass_limit = (long)cinfo->image_height;
- (*cinfo->progress->progress_monitor) ((j_common_ptr)cinfo);
- }
-
- /* Give master control module another chance if this is first call to
- * jpeg_write_raw_data. This lets output of the frame/scan headers be
- * delayed so that application can write COM, etc, markers between
- * jpeg_start_compress and jpeg_write_raw_data.
- */
- if (cinfo->master->call_pass_startup)
- (*cinfo->master->pass_startup) (cinfo);
-
- /* Verify that at least one iMCU row has been passed. */
- lines_per_iMCU_row = cinfo->max_v_samp_factor * DCTSIZE;
- if (num_lines < lines_per_iMCU_row)
- ERREXIT(cinfo, JERR_BUFFER_SIZE);
-
- /* Directly compress the row. */
- if (!(*cinfo->coef->compress_data) (cinfo, data)) {
- /* If compressor did not consume the whole row, suspend processing. */
- return 0;
- }
-
- /* OK, we processed one iMCU row. */
- cinfo->next_scanline += lines_per_iMCU_row;
- return lines_per_iMCU_row;
-}
diff --git a/contrib/libs/libjpeg-turbo/jcarith.c b/contrib/libs/libjpeg-turbo/jcarith.c
deleted file mode 100644
index b1720521bf..0000000000
--- a/contrib/libs/libjpeg-turbo/jcarith.c
+++ /dev/null
@@ -1,932 +0,0 @@
-/*
- * jcarith.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Developed 1997-2009 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2015, 2018, 2021-2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains portable arithmetic entropy encoding routines for JPEG
- * (implementing Recommendation ITU-T T.81 | ISO/IEC 10918-1).
- *
- * Both sequential and progressive modes are supported in this single module.
- *
- * Suspension is not currently supported in this module.
- *
- * NOTE: All referenced figures are from
- * Recommendation ITU-T T.81 (1992) | ISO/IEC 10918-1:1994.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-
-
-/* Expanded entropy encoder object for arithmetic encoding. */
-
-typedef struct {
- struct jpeg_entropy_encoder pub; /* public fields */
-
- JLONG c; /* C register, base of coding interval, layout as in sec. D.1.3 */
- JLONG a; /* A register, normalized size of coding interval */
- JLONG sc; /* counter for stacked 0xFF values which might overflow */
- JLONG zc; /* counter for pending 0x00 output values which might *
- * be discarded at the end ("Pacman" termination) */
- int ct; /* bit shift counter, determines when next byte will be written */
- int buffer; /* buffer for most recent output byte != 0xFF */
-
- int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */
- int dc_context[MAX_COMPS_IN_SCAN]; /* context index for DC conditioning */
-
- unsigned int restarts_to_go; /* MCUs left in this restart interval */
- int next_restart_num; /* next restart number to write (0-7) */
-
- /* Pointers to statistics areas (these workspaces have image lifespan) */
- unsigned char *dc_stats[NUM_ARITH_TBLS];
- unsigned char *ac_stats[NUM_ARITH_TBLS];
-
- /* Statistics bin for coding with fixed probability 0.5 */
- unsigned char fixed_bin[4];
-} arith_entropy_encoder;
-
-typedef arith_entropy_encoder *arith_entropy_ptr;
-
-/* The following two definitions specify the allocation chunk size
- * for the statistics area.
- * According to sections F.1.4.4.1.3 and F.1.4.4.2, we need at least
- * 49 statistics bins for DC, and 245 statistics bins for AC coding.
- *
- * We use a compact representation with 1 byte per statistics bin,
- * thus the numbers directly represent byte sizes.
- * This 1 byte per statistics bin contains the meaning of the MPS
- * (more probable symbol) in the highest bit (mask 0x80), and the
- * index into the probability estimation state machine table
- * in the lower bits (mask 0x7F).
- */
-
-#define DC_STAT_BINS 64
-#define AC_STAT_BINS 256
-
-/* NOTE: Uncomment the following #define if you want to use the
- * given formula for calculating the AC conditioning parameter Kx
- * for spectral selection progressive coding in section G.1.3.2
- * of the spec (Kx = Kmin + SRL (8 + Se - Kmin) 4).
- * Although the spec and P&M authors claim that this "has proven
- * to give good results for 8 bit precision samples", I'm not
- * convinced yet that this is really beneficial.
- * Early tests gave only very marginal compression enhancements
- * (a few - around 5 or so - bytes even for very large files),
- * which would turn out rather negative if we'd suppress the
- * DAC (Define Arithmetic Conditioning) marker segments for
- * the default parameters in the future.
- * Note that currently the marker writing module emits 12-byte
- * DAC segments for a full-component scan in a color image.
- * This is not worth worrying about IMHO. However, since the
- * spec defines the default values to be used if the tables
- * are omitted (unlike Huffman tables, which are required
- * anyway), one might optimize this behaviour in the future,
- * and then it would be disadvantageous to use custom tables if
- * they don't provide sufficient gain to exceed the DAC size.
- *
- * On the other hand, I'd consider it as a reasonable result
- * that the conditioning has no significant influence on the
- * compression performance. This means that the basic
- * statistical model is already rather stable.
- *
- * Thus, at the moment, we use the default conditioning values
- * anyway, and do not use the custom formula.
- *
-#define CALCULATE_SPECTRAL_CONDITIONING
- */
-
-/* IRIGHT_SHIFT is like RIGHT_SHIFT, but works on int rather than JLONG.
- * We assume that int right shift is unsigned if JLONG right shift is,
- * which should be safe.
- */
-
-#ifdef RIGHT_SHIFT_IS_UNSIGNED
-#define ISHIFT_TEMPS int ishift_temp;
-#define IRIGHT_SHIFT(x, shft) \
- ((ishift_temp = (x)) < 0 ? \
- (ishift_temp >> (shft)) | ((~0) << (16 - (shft))) : \
- (ishift_temp >> (shft)))
-#else
-#define ISHIFT_TEMPS
-#define IRIGHT_SHIFT(x, shft) ((x) >> (shft))
-#endif
-
-
-LOCAL(void)
-emit_byte(int val, j_compress_ptr cinfo)
-/* Write next output byte; we do not support suspension in this module. */
-{
- struct jpeg_destination_mgr *dest = cinfo->dest;
-
- *dest->next_output_byte++ = (JOCTET)val;
- if (--dest->free_in_buffer == 0)
- if (!(*dest->empty_output_buffer) (cinfo))
- ERREXIT(cinfo, JERR_CANT_SUSPEND);
-}
-
-
-/*
- * Finish up at the end of an arithmetic-compressed scan.
- */
-
-METHODDEF(void)
-finish_pass(j_compress_ptr cinfo)
-{
- arith_entropy_ptr e = (arith_entropy_ptr)cinfo->entropy;
- JLONG temp;
-
- /* Section D.1.8: Termination of encoding */
-
- /* Find the e->c in the coding interval with the largest
- * number of trailing zero bits */
- if ((temp = (e->a - 1 + e->c) & 0xFFFF0000UL) < e->c)
- e->c = temp + 0x8000L;
- else
- e->c = temp;
- /* Send remaining bytes to output */
- e->c <<= e->ct;
- if (e->c & 0xF8000000UL) {
- /* One final overflow has to be handled */
- if (e->buffer >= 0) {
- if (e->zc)
- do emit_byte(0x00, cinfo);
- while (--e->zc);
- emit_byte(e->buffer + 1, cinfo);
- if (e->buffer + 1 == 0xFF)
- emit_byte(0x00, cinfo);
- }
- e->zc += e->sc; /* carry-over converts stacked 0xFF bytes to 0x00 */
- e->sc = 0;
- } else {
- if (e->buffer == 0)
- ++e->zc;
- else if (e->buffer >= 0) {
- if (e->zc)
- do emit_byte(0x00, cinfo);
- while (--e->zc);
- emit_byte(e->buffer, cinfo);
- }
- if (e->sc) {
- if (e->zc)
- do emit_byte(0x00, cinfo);
- while (--e->zc);
- do {
- emit_byte(0xFF, cinfo);
- emit_byte(0x00, cinfo);
- } while (--e->sc);
- }
- }
- /* Output final bytes only if they are not 0x00 */
- if (e->c & 0x7FFF800L) {
- if (e->zc) /* output final pending zero bytes */
- do emit_byte(0x00, cinfo);
- while (--e->zc);
- emit_byte((e->c >> 19) & 0xFF, cinfo);
- if (((e->c >> 19) & 0xFF) == 0xFF)
- emit_byte(0x00, cinfo);
- if (e->c & 0x7F800L) {
- emit_byte((e->c >> 11) & 0xFF, cinfo);
- if (((e->c >> 11) & 0xFF) == 0xFF)
- emit_byte(0x00, cinfo);
- }
- }
-}
-
-
-/*
- * The core arithmetic encoding routine (common in JPEG and JBIG).
- * This needs to go as fast as possible.
- * Machine-dependent optimization facilities
- * are not utilized in this portable implementation.
- * However, this code should be fairly efficient and
- * may be a good base for further optimizations anyway.
- *
- * Parameter 'val' to be encoded may be 0 or 1 (binary decision).
- *
- * Note: I've added full "Pacman" termination support to the
- * byte output routines, which is equivalent to the optional
- * Discard_final_zeros procedure (Figure D.15) in the spec.
- * Thus, we always produce the shortest possible output
- * stream compliant to the spec (no trailing zero bytes,
- * except for FF stuffing).
- *
- * I've also introduced a new scheme for accessing
- * the probability estimation state machine table,
- * derived from Markus Kuhn's JBIG implementation.
- */
-
-LOCAL(void)
-arith_encode(j_compress_ptr cinfo, unsigned char *st, int val)
-{
- register arith_entropy_ptr e = (arith_entropy_ptr)cinfo->entropy;
- register unsigned char nl, nm;
- register JLONG qe, temp;
- register int sv;
-
- /* Fetch values from our compact representation of Table D.2:
- * Qe values and probability estimation state machine
- */
- sv = *st;
- qe = jpeg_aritab[sv & 0x7F]; /* => Qe_Value */
- nl = qe & 0xFF; qe >>= 8; /* Next_Index_LPS + Switch_MPS */
- nm = qe & 0xFF; qe >>= 8; /* Next_Index_MPS */
-
- /* Encode & estimation procedures per sections D.1.4 & D.1.5 */
- e->a -= qe;
- if (val != (sv >> 7)) {
- /* Encode the less probable symbol */
- if (e->a >= qe) {
- /* If the interval size (qe) for the less probable symbol (LPS)
- * is larger than the interval size for the MPS, then exchange
- * the two symbols for coding efficiency, otherwise code the LPS
- * as usual: */
- e->c += e->a;
- e->a = qe;
- }
- *st = (sv & 0x80) ^ nl; /* Estimate_after_LPS */
- } else {
- /* Encode the more probable symbol */
- if (e->a >= 0x8000L)
- return; /* A >= 0x8000 -> ready, no renormalization required */
- if (e->a < qe) {
- /* If the interval size (qe) for the less probable symbol (LPS)
- * is larger than the interval size for the MPS, then exchange
- * the two symbols for coding efficiency: */
- e->c += e->a;
- e->a = qe;
- }
- *st = (sv & 0x80) ^ nm; /* Estimate_after_MPS */
- }
-
- /* Renormalization & data output per section D.1.6 */
- do {
- e->a <<= 1;
- e->c <<= 1;
- if (--e->ct == 0) {
- /* Another byte is ready for output */
- temp = e->c >> 19;
- if (temp > 0xFF) {
- /* Handle overflow over all stacked 0xFF bytes */
- if (e->buffer >= 0) {
- if (e->zc)
- do emit_byte(0x00, cinfo);
- while (--e->zc);
- emit_byte(e->buffer + 1, cinfo);
- if (e->buffer + 1 == 0xFF)
- emit_byte(0x00, cinfo);
- }
- e->zc += e->sc; /* carry-over converts stacked 0xFF bytes to 0x00 */
- e->sc = 0;
- /* Note: The 3 spacer bits in the C register guarantee
- * that the new buffer byte can't be 0xFF here
- * (see page 160 in the P&M JPEG book). */
- e->buffer = temp & 0xFF; /* new output byte, might overflow later */
- } else if (temp == 0xFF) {
- ++e->sc; /* stack 0xFF byte (which might overflow later) */
- } else {
- /* Output all stacked 0xFF bytes, they will not overflow any more */
- if (e->buffer == 0)
- ++e->zc;
- else if (e->buffer >= 0) {
- if (e->zc)
- do emit_byte(0x00, cinfo);
- while (--e->zc);
- emit_byte(e->buffer, cinfo);
- }
- if (e->sc) {
- if (e->zc)
- do emit_byte(0x00, cinfo);
- while (--e->zc);
- do {
- emit_byte(0xFF, cinfo);
- emit_byte(0x00, cinfo);
- } while (--e->sc);
- }
- e->buffer = temp & 0xFF; /* new output byte (can still overflow) */
- }
- e->c &= 0x7FFFFL;
- e->ct += 8;
- }
- } while (e->a < 0x8000L);
-}
-
-
-/*
- * Emit a restart marker & resynchronize predictions.
- */
-
-LOCAL(void)
-emit_restart(j_compress_ptr cinfo, int restart_num)
-{
- arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
- int ci;
- jpeg_component_info *compptr;
-
- finish_pass(cinfo);
-
- emit_byte(0xFF, cinfo);
- emit_byte(JPEG_RST0 + restart_num, cinfo);
-
- /* Re-initialize statistics areas */
- for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
- compptr = cinfo->cur_comp_info[ci];
- /* DC needs no table for refinement scan */
- if (cinfo->progressive_mode == 0 || (cinfo->Ss == 0 && cinfo->Ah == 0)) {
- memset(entropy->dc_stats[compptr->dc_tbl_no], 0, DC_STAT_BINS);
- /* Reset DC predictions to 0 */
- entropy->last_dc_val[ci] = 0;
- entropy->dc_context[ci] = 0;
- }
- /* AC needs no table when not present */
- if (cinfo->progressive_mode == 0 || cinfo->Se) {
- memset(entropy->ac_stats[compptr->ac_tbl_no], 0, AC_STAT_BINS);
- }
- }
-
- /* Reset arithmetic encoding variables */
- entropy->c = 0;
- entropy->a = 0x10000L;
- entropy->sc = 0;
- entropy->zc = 0;
- entropy->ct = 11;
- entropy->buffer = -1; /* empty */
-}
-
-
-/*
- * MCU encoding for DC initial scan (either spectral selection,
- * or first pass of successive approximation).
- */
-
-METHODDEF(boolean)
-encode_mcu_DC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
-{
- arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
- JBLOCKROW block;
- unsigned char *st;
- int blkn, ci, tbl;
- int v, v2, m;
- ISHIFT_TEMPS
-
- /* Emit restart marker if needed */
- if (cinfo->restart_interval) {
- if (entropy->restarts_to_go == 0) {
- emit_restart(cinfo, entropy->next_restart_num);
- entropy->restarts_to_go = cinfo->restart_interval;
- entropy->next_restart_num++;
- entropy->next_restart_num &= 7;
- }
- entropy->restarts_to_go--;
- }
-
- /* Encode the MCU data blocks */
- for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
- block = MCU_data[blkn];
- ci = cinfo->MCU_membership[blkn];
- tbl = cinfo->cur_comp_info[ci]->dc_tbl_no;
-
- /* Compute the DC value after the required point transform by Al.
- * This is simply an arithmetic right shift.
- */
- m = IRIGHT_SHIFT((int)((*block)[0]), cinfo->Al);
-
- /* Sections F.1.4.1 & F.1.4.4.1: Encoding of DC coefficients */
-
- /* Table F.4: Point to statistics bin S0 for DC coefficient coding */
- st = entropy->dc_stats[tbl] + entropy->dc_context[ci];
-
- /* Figure F.4: Encode_DC_DIFF */
- if ((v = m - entropy->last_dc_val[ci]) == 0) {
- arith_encode(cinfo, st, 0);
- entropy->dc_context[ci] = 0; /* zero diff category */
- } else {
- entropy->last_dc_val[ci] = m;
- arith_encode(cinfo, st, 1);
- /* Figure F.6: Encoding nonzero value v */
- /* Figure F.7: Encoding the sign of v */
- if (v > 0) {
- arith_encode(cinfo, st + 1, 0); /* Table F.4: SS = S0 + 1 */
- st += 2; /* Table F.4: SP = S0 + 2 */
- entropy->dc_context[ci] = 4; /* small positive diff category */
- } else {
- v = -v;
- arith_encode(cinfo, st + 1, 1); /* Table F.4: SS = S0 + 1 */
- st += 3; /* Table F.4: SN = S0 + 3 */
- entropy->dc_context[ci] = 8; /* small negative diff category */
- }
- /* Figure F.8: Encoding the magnitude category of v */
- m = 0;
- if (v -= 1) {
- arith_encode(cinfo, st, 1);
- m = 1;
- v2 = v;
- st = entropy->dc_stats[tbl] + 20; /* Table F.4: X1 = 20 */
- while (v2 >>= 1) {
- arith_encode(cinfo, st, 1);
- m <<= 1;
- st += 1;
- }
- }
- arith_encode(cinfo, st, 0);
- /* Section F.1.4.4.1.2: Establish dc_context conditioning category */
- if (m < (int)((1L << cinfo->arith_dc_L[tbl]) >> 1))
- entropy->dc_context[ci] = 0; /* zero diff category */
- else if (m > (int)((1L << cinfo->arith_dc_U[tbl]) >> 1))
- entropy->dc_context[ci] += 8; /* large diff category */
- /* Figure F.9: Encoding the magnitude bit pattern of v */
- st += 14;
- while (m >>= 1)
- arith_encode(cinfo, st, (m & v) ? 1 : 0);
- }
- }
-
- return TRUE;
-}
-
-
-/*
- * MCU encoding for AC initial scan (either spectral selection,
- * or first pass of successive approximation).
- */
-
-METHODDEF(boolean)
-encode_mcu_AC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
-{
- arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
- JBLOCKROW block;
- unsigned char *st;
- int tbl, k, ke;
- int v, v2, m;
-
- /* Emit restart marker if needed */
- if (cinfo->restart_interval) {
- if (entropy->restarts_to_go == 0) {
- emit_restart(cinfo, entropy->next_restart_num);
- entropy->restarts_to_go = cinfo->restart_interval;
- entropy->next_restart_num++;
- entropy->next_restart_num &= 7;
- }
- entropy->restarts_to_go--;
- }
-
- /* Encode the MCU data block */
- block = MCU_data[0];
- tbl = cinfo->cur_comp_info[0]->ac_tbl_no;
-
- /* Sections F.1.4.2 & F.1.4.4.2: Encoding of AC coefficients */
-
- /* Establish EOB (end-of-block) index */
- for (ke = cinfo->Se; ke > 0; ke--)
- /* We must apply the point transform by Al. For AC coefficients this
- * is an integer division with rounding towards 0. To do this portably
- * in C, we shift after obtaining the absolute value.
- */
- if ((v = (*block)[jpeg_natural_order[ke]]) >= 0) {
- if (v >>= cinfo->Al) break;
- } else {
- v = -v;
- if (v >>= cinfo->Al) break;
- }
-
- /* Figure F.5: Encode_AC_Coefficients */
- for (k = cinfo->Ss; k <= ke; k++) {
- st = entropy->ac_stats[tbl] + 3 * (k - 1);
- arith_encode(cinfo, st, 0); /* EOB decision */
- for (;;) {
- if ((v = (*block)[jpeg_natural_order[k]]) >= 0) {
- if (v >>= cinfo->Al) {
- arith_encode(cinfo, st + 1, 1);
- arith_encode(cinfo, entropy->fixed_bin, 0);
- break;
- }
- } else {
- v = -v;
- if (v >>= cinfo->Al) {
- arith_encode(cinfo, st + 1, 1);
- arith_encode(cinfo, entropy->fixed_bin, 1);
- break;
- }
- }
- arith_encode(cinfo, st + 1, 0); st += 3; k++;
- }
- st += 2;
- /* Figure F.8: Encoding the magnitude category of v */
- m = 0;
- if (v -= 1) {
- arith_encode(cinfo, st, 1);
- m = 1;
- v2 = v;
- if (v2 >>= 1) {
- arith_encode(cinfo, st, 1);
- m <<= 1;
- st = entropy->ac_stats[tbl] +
- (k <= cinfo->arith_ac_K[tbl] ? 189 : 217);
- while (v2 >>= 1) {
- arith_encode(cinfo, st, 1);
- m <<= 1;
- st += 1;
- }
- }
- }
- arith_encode(cinfo, st, 0);
- /* Figure F.9: Encoding the magnitude bit pattern of v */
- st += 14;
- while (m >>= 1)
- arith_encode(cinfo, st, (m & v) ? 1 : 0);
- }
- /* Encode EOB decision only if k <= cinfo->Se */
- if (k <= cinfo->Se) {
- st = entropy->ac_stats[tbl] + 3 * (k - 1);
- arith_encode(cinfo, st, 1);
- }
-
- return TRUE;
-}
-
-
-/*
- * MCU encoding for DC successive approximation refinement scan.
- */
-
-METHODDEF(boolean)
-encode_mcu_DC_refine(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
-{
- arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
- unsigned char *st;
- int Al, blkn;
-
- /* Emit restart marker if needed */
- if (cinfo->restart_interval) {
- if (entropy->restarts_to_go == 0) {
- emit_restart(cinfo, entropy->next_restart_num);
- entropy->restarts_to_go = cinfo->restart_interval;
- entropy->next_restart_num++;
- entropy->next_restart_num &= 7;
- }
- entropy->restarts_to_go--;
- }
-
- st = entropy->fixed_bin; /* use fixed probability estimation */
- Al = cinfo->Al;
-
- /* Encode the MCU data blocks */
- for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
- /* We simply emit the Al'th bit of the DC coefficient value. */
- arith_encode(cinfo, st, (MCU_data[blkn][0][0] >> Al) & 1);
- }
-
- return TRUE;
-}
-
-
-/*
- * MCU encoding for AC successive approximation refinement scan.
- */
-
-METHODDEF(boolean)
-encode_mcu_AC_refine(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
-{
- arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
- JBLOCKROW block;
- unsigned char *st;
- int tbl, k, ke, kex;
- int v;
-
- /* Emit restart marker if needed */
- if (cinfo->restart_interval) {
- if (entropy->restarts_to_go == 0) {
- emit_restart(cinfo, entropy->next_restart_num);
- entropy->restarts_to_go = cinfo->restart_interval;
- entropy->next_restart_num++;
- entropy->next_restart_num &= 7;
- }
- entropy->restarts_to_go--;
- }
-
- /* Encode the MCU data block */
- block = MCU_data[0];
- tbl = cinfo->cur_comp_info[0]->ac_tbl_no;
-
- /* Section G.1.3.3: Encoding of AC coefficients */
-
- /* Establish EOB (end-of-block) index */
- for (ke = cinfo->Se; ke > 0; ke--)
- /* We must apply the point transform by Al. For AC coefficients this
- * is an integer division with rounding towards 0. To do this portably
- * in C, we shift after obtaining the absolute value.
- */
- if ((v = (*block)[jpeg_natural_order[ke]]) >= 0) {
- if (v >>= cinfo->Al) break;
- } else {
- v = -v;
- if (v >>= cinfo->Al) break;
- }
-
- /* Establish EOBx (previous stage end-of-block) index */
- for (kex = ke; kex > 0; kex--)
- if ((v = (*block)[jpeg_natural_order[kex]]) >= 0) {
- if (v >>= cinfo->Ah) break;
- } else {
- v = -v;
- if (v >>= cinfo->Ah) break;
- }
-
- /* Figure G.10: Encode_AC_Coefficients_SA */
- for (k = cinfo->Ss; k <= ke; k++) {
- st = entropy->ac_stats[tbl] + 3 * (k - 1);
- if (k > kex)
- arith_encode(cinfo, st, 0); /* EOB decision */
- for (;;) {
- if ((v = (*block)[jpeg_natural_order[k]]) >= 0) {
- if (v >>= cinfo->Al) {
- if (v >> 1) /* previously nonzero coef */
- arith_encode(cinfo, st + 2, (v & 1));
- else { /* newly nonzero coef */
- arith_encode(cinfo, st + 1, 1);
- arith_encode(cinfo, entropy->fixed_bin, 0);
- }
- break;
- }
- } else {
- v = -v;
- if (v >>= cinfo->Al) {
- if (v >> 1) /* previously nonzero coef */
- arith_encode(cinfo, st + 2, (v & 1));
- else { /* newly nonzero coef */
- arith_encode(cinfo, st + 1, 1);
- arith_encode(cinfo, entropy->fixed_bin, 1);
- }
- break;
- }
- }
- arith_encode(cinfo, st + 1, 0); st += 3; k++;
- }
- }
- /* Encode EOB decision only if k <= cinfo->Se */
- if (k <= cinfo->Se) {
- st = entropy->ac_stats[tbl] + 3 * (k - 1);
- arith_encode(cinfo, st, 1);
- }
-
- return TRUE;
-}
-
-
-/*
- * Encode and output one MCU's worth of arithmetic-compressed coefficients.
- */
-
-METHODDEF(boolean)
-encode_mcu(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
-{
- arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
- jpeg_component_info *compptr;
- JBLOCKROW block;
- unsigned char *st;
- int blkn, ci, tbl, k, ke;
- int v, v2, m;
-
- /* Emit restart marker if needed */
- if (cinfo->restart_interval) {
- if (entropy->restarts_to_go == 0) {
- emit_restart(cinfo, entropy->next_restart_num);
- entropy->restarts_to_go = cinfo->restart_interval;
- entropy->next_restart_num++;
- entropy->next_restart_num &= 7;
- }
- entropy->restarts_to_go--;
- }
-
- /* Encode the MCU data blocks */
- for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
- block = MCU_data[blkn];
- ci = cinfo->MCU_membership[blkn];
- compptr = cinfo->cur_comp_info[ci];
-
- /* Sections F.1.4.1 & F.1.4.4.1: Encoding of DC coefficients */
-
- tbl = compptr->dc_tbl_no;
-
- /* Table F.4: Point to statistics bin S0 for DC coefficient coding */
- st = entropy->dc_stats[tbl] + entropy->dc_context[ci];
-
- /* Figure F.4: Encode_DC_DIFF */
- if ((v = (*block)[0] - entropy->last_dc_val[ci]) == 0) {
- arith_encode(cinfo, st, 0);
- entropy->dc_context[ci] = 0; /* zero diff category */
- } else {
- entropy->last_dc_val[ci] = (*block)[0];
- arith_encode(cinfo, st, 1);
- /* Figure F.6: Encoding nonzero value v */
- /* Figure F.7: Encoding the sign of v */
- if (v > 0) {
- arith_encode(cinfo, st + 1, 0); /* Table F.4: SS = S0 + 1 */
- st += 2; /* Table F.4: SP = S0 + 2 */
- entropy->dc_context[ci] = 4; /* small positive diff category */
- } else {
- v = -v;
- arith_encode(cinfo, st + 1, 1); /* Table F.4: SS = S0 + 1 */
- st += 3; /* Table F.4: SN = S0 + 3 */
- entropy->dc_context[ci] = 8; /* small negative diff category */
- }
- /* Figure F.8: Encoding the magnitude category of v */
- m = 0;
- if (v -= 1) {
- arith_encode(cinfo, st, 1);
- m = 1;
- v2 = v;
- st = entropy->dc_stats[tbl] + 20; /* Table F.4: X1 = 20 */
- while (v2 >>= 1) {
- arith_encode(cinfo, st, 1);
- m <<= 1;
- st += 1;
- }
- }
- arith_encode(cinfo, st, 0);
- /* Section F.1.4.4.1.2: Establish dc_context conditioning category */
- if (m < (int)((1L << cinfo->arith_dc_L[tbl]) >> 1))
- entropy->dc_context[ci] = 0; /* zero diff category */
- else if (m > (int)((1L << cinfo->arith_dc_U[tbl]) >> 1))
- entropy->dc_context[ci] += 8; /* large diff category */
- /* Figure F.9: Encoding the magnitude bit pattern of v */
- st += 14;
- while (m >>= 1)
- arith_encode(cinfo, st, (m & v) ? 1 : 0);
- }
-
- /* Sections F.1.4.2 & F.1.4.4.2: Encoding of AC coefficients */
-
- tbl = compptr->ac_tbl_no;
-
- /* Establish EOB (end-of-block) index */
- for (ke = DCTSIZE2 - 1; ke > 0; ke--)
- if ((*block)[jpeg_natural_order[ke]]) break;
-
- /* Figure F.5: Encode_AC_Coefficients */
- for (k = 1; k <= ke; k++) {
- st = entropy->ac_stats[tbl] + 3 * (k - 1);
- arith_encode(cinfo, st, 0); /* EOB decision */
- while ((v = (*block)[jpeg_natural_order[k]]) == 0) {
- arith_encode(cinfo, st + 1, 0); st += 3; k++;
- }
- arith_encode(cinfo, st + 1, 1);
- /* Figure F.6: Encoding nonzero value v */
- /* Figure F.7: Encoding the sign of v */
- if (v > 0) {
- arith_encode(cinfo, entropy->fixed_bin, 0);
- } else {
- v = -v;
- arith_encode(cinfo, entropy->fixed_bin, 1);
- }
- st += 2;
- /* Figure F.8: Encoding the magnitude category of v */
- m = 0;
- if (v -= 1) {
- arith_encode(cinfo, st, 1);
- m = 1;
- v2 = v;
- if (v2 >>= 1) {
- arith_encode(cinfo, st, 1);
- m <<= 1;
- st = entropy->ac_stats[tbl] +
- (k <= cinfo->arith_ac_K[tbl] ? 189 : 217);
- while (v2 >>= 1) {
- arith_encode(cinfo, st, 1);
- m <<= 1;
- st += 1;
- }
- }
- }
- arith_encode(cinfo, st, 0);
- /* Figure F.9: Encoding the magnitude bit pattern of v */
- st += 14;
- while (m >>= 1)
- arith_encode(cinfo, st, (m & v) ? 1 : 0);
- }
- /* Encode EOB decision only if k <= DCTSIZE2 - 1 */
- if (k <= DCTSIZE2 - 1) {
- st = entropy->ac_stats[tbl] + 3 * (k - 1);
- arith_encode(cinfo, st, 1);
- }
- }
-
- return TRUE;
-}
-
-
-/*
- * Initialize for an arithmetic-compressed scan.
- */
-
-METHODDEF(void)
-start_pass(j_compress_ptr cinfo, boolean gather_statistics)
-{
- arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
- int ci, tbl;
- jpeg_component_info *compptr;
-
- if (gather_statistics)
- /* Make sure to avoid that in the master control logic!
- * We are fully adaptive here and need no extra
- * statistics gathering pass!
- */
- ERREXIT(cinfo, JERR_NOTIMPL);
-
- /* We assume jcmaster.c already validated the progressive scan parameters. */
-
- /* Select execution routines */
- if (cinfo->progressive_mode) {
- if (cinfo->Ah == 0) {
- if (cinfo->Ss == 0)
- entropy->pub.encode_mcu = encode_mcu_DC_first;
- else
- entropy->pub.encode_mcu = encode_mcu_AC_first;
- } else {
- if (cinfo->Ss == 0)
- entropy->pub.encode_mcu = encode_mcu_DC_refine;
- else
- entropy->pub.encode_mcu = encode_mcu_AC_refine;
- }
- } else
- entropy->pub.encode_mcu = encode_mcu;
-
- /* Allocate & initialize requested statistics areas */
- for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
- compptr = cinfo->cur_comp_info[ci];
- /* DC needs no table for refinement scan */
- if (cinfo->progressive_mode == 0 || (cinfo->Ss == 0 && cinfo->Ah == 0)) {
- tbl = compptr->dc_tbl_no;
- if (tbl < 0 || tbl >= NUM_ARITH_TBLS)
- ERREXIT1(cinfo, JERR_NO_ARITH_TABLE, tbl);
- if (entropy->dc_stats[tbl] == NULL)
- entropy->dc_stats[tbl] = (unsigned char *)(*cinfo->mem->alloc_small)
- ((j_common_ptr)cinfo, JPOOL_IMAGE, DC_STAT_BINS);
- memset(entropy->dc_stats[tbl], 0, DC_STAT_BINS);
- /* Initialize DC predictions to 0 */
- entropy->last_dc_val[ci] = 0;
- entropy->dc_context[ci] = 0;
- }
- /* AC needs no table when not present */
- if (cinfo->progressive_mode == 0 || cinfo->Se) {
- tbl = compptr->ac_tbl_no;
- if (tbl < 0 || tbl >= NUM_ARITH_TBLS)
- ERREXIT1(cinfo, JERR_NO_ARITH_TABLE, tbl);
- if (entropy->ac_stats[tbl] == NULL)
- entropy->ac_stats[tbl] = (unsigned char *)(*cinfo->mem->alloc_small)
- ((j_common_ptr)cinfo, JPOOL_IMAGE, AC_STAT_BINS);
- memset(entropy->ac_stats[tbl], 0, AC_STAT_BINS);
-#ifdef CALCULATE_SPECTRAL_CONDITIONING
- if (cinfo->progressive_mode)
- /* Section G.1.3.2: Set appropriate arithmetic conditioning value Kx */
- cinfo->arith_ac_K[tbl] = cinfo->Ss +
- ((8 + cinfo->Se - cinfo->Ss) >> 4);
-#endif
- }
- }
-
- /* Initialize arithmetic encoding variables */
- entropy->c = 0;
- entropy->a = 0x10000L;
- entropy->sc = 0;
- entropy->zc = 0;
- entropy->ct = 11;
- entropy->buffer = -1; /* empty */
-
- /* Initialize restart stuff */
- entropy->restarts_to_go = cinfo->restart_interval;
- entropy->next_restart_num = 0;
-}
-
-
-/*
- * Module initialization routine for arithmetic entropy encoding.
- */
-
-GLOBAL(void)
-jinit_arith_encoder(j_compress_ptr cinfo)
-{
- arith_entropy_ptr entropy;
- int i;
-
- entropy = (arith_entropy_ptr)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- sizeof(arith_entropy_encoder));
- cinfo->entropy = (struct jpeg_entropy_encoder *)entropy;
- entropy->pub.start_pass = start_pass;
- entropy->pub.finish_pass = finish_pass;
-
- /* Mark tables unallocated */
- for (i = 0; i < NUM_ARITH_TBLS; i++) {
- entropy->dc_stats[i] = NULL;
- entropy->ac_stats[i] = NULL;
- }
-
- /* Initialize index for fixed probability estimation */
- entropy->fixed_bin[0] = 113;
-}
diff --git a/contrib/libs/libjpeg-turbo/jccoefct.c b/contrib/libs/libjpeg-turbo/jccoefct.c
deleted file mode 100644
index 068232a527..0000000000
--- a/contrib/libs/libjpeg-turbo/jccoefct.c
+++ /dev/null
@@ -1,449 +0,0 @@
-/*
- * jccoefct.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1994-1997, Thomas G. Lane.
- * It was modified by The libjpeg-turbo Project to include only code and
- * information relevant to libjpeg-turbo.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains the coefficient buffer controller for compression.
- * This controller is the top level of the JPEG compressor proper.
- * The coefficient buffer lies between forward-DCT and entropy encoding steps.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-
-
-/* We use a full-image coefficient buffer when doing Huffman optimization,
- * and also for writing multiple-scan JPEG files. In all cases, the DCT
- * step is run during the first pass, and subsequent passes need only read
- * the buffered coefficients.
- */
-#ifdef ENTROPY_OPT_SUPPORTED
-#define FULL_COEF_BUFFER_SUPPORTED
-#else
-#ifdef C_MULTISCAN_FILES_SUPPORTED
-#define FULL_COEF_BUFFER_SUPPORTED
-#endif
-#endif
-
-
-/* Private buffer controller object */
-
-typedef struct {
- struct jpeg_c_coef_controller pub; /* public fields */
-
- JDIMENSION iMCU_row_num; /* iMCU row # within image */
- JDIMENSION mcu_ctr; /* counts MCUs processed in current row */
- int MCU_vert_offset; /* counts MCU rows within iMCU row */
- int MCU_rows_per_iMCU_row; /* number of such rows needed */
-
- /* For single-pass compression, it's sufficient to buffer just one MCU
- * (although this may prove a bit slow in practice). We allocate a
- * workspace of C_MAX_BLOCKS_IN_MCU coefficient blocks, and reuse it for each
- * MCU constructed and sent. In multi-pass modes, this array points to the
- * current MCU's blocks within the virtual arrays.
- */
- JBLOCKROW MCU_buffer[C_MAX_BLOCKS_IN_MCU];
-
- /* In multi-pass modes, we need a virtual block array for each component. */
- jvirt_barray_ptr whole_image[MAX_COMPONENTS];
-} my_coef_controller;
-
-typedef my_coef_controller *my_coef_ptr;
-
-
-/* Forward declarations */
-METHODDEF(boolean) compress_data(j_compress_ptr cinfo, JSAMPIMAGE input_buf);
-#ifdef FULL_COEF_BUFFER_SUPPORTED
-METHODDEF(boolean) compress_first_pass(j_compress_ptr cinfo,
- JSAMPIMAGE input_buf);
-METHODDEF(boolean) compress_output(j_compress_ptr cinfo, JSAMPIMAGE input_buf);
-#endif
-
-
-LOCAL(void)
-start_iMCU_row(j_compress_ptr cinfo)
-/* Reset within-iMCU-row counters for a new row */
-{
- my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
-
- /* In an interleaved scan, an MCU row is the same as an iMCU row.
- * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows.
- * But at the bottom of the image, process only what's left.
- */
- if (cinfo->comps_in_scan > 1) {
- coef->MCU_rows_per_iMCU_row = 1;
- } else {
- if (coef->iMCU_row_num < (cinfo->total_iMCU_rows - 1))
- coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor;
- else
- coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height;
- }
-
- coef->mcu_ctr = 0;
- coef->MCU_vert_offset = 0;
-}
-
-
-/*
- * Initialize for a processing pass.
- */
-
-METHODDEF(void)
-start_pass_coef(j_compress_ptr cinfo, J_BUF_MODE pass_mode)
-{
- my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
-
- coef->iMCU_row_num = 0;
- start_iMCU_row(cinfo);
-
- switch (pass_mode) {
- case JBUF_PASS_THRU:
- if (coef->whole_image[0] != NULL)
- ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
- coef->pub.compress_data = compress_data;
- break;
-#ifdef FULL_COEF_BUFFER_SUPPORTED
- case JBUF_SAVE_AND_PASS:
- if (coef->whole_image[0] == NULL)
- ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
- coef->pub.compress_data = compress_first_pass;
- break;
- case JBUF_CRANK_DEST:
- if (coef->whole_image[0] == NULL)
- ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
- coef->pub.compress_data = compress_output;
- break;
-#endif
- default:
- ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
- break;
- }
-}
-
-
-/*
- * Process some data in the single-pass case.
- * We process the equivalent of one fully interleaved MCU row ("iMCU" row)
- * per call, ie, v_samp_factor block rows for each component in the image.
- * Returns TRUE if the iMCU row is completed, FALSE if suspended.
- *
- * NB: input_buf contains a plane for each component in image,
- * which we index according to the component's SOF position.
- */
-
-METHODDEF(boolean)
-compress_data(j_compress_ptr cinfo, JSAMPIMAGE input_buf)
-{
- my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
- JDIMENSION MCU_col_num; /* index of current MCU within row */
- JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
- JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
- int blkn, bi, ci, yindex, yoffset, blockcnt;
- JDIMENSION ypos, xpos;
- jpeg_component_info *compptr;
-
- /* Loop to write as much as one whole iMCU row */
- for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
- yoffset++) {
- for (MCU_col_num = coef->mcu_ctr; MCU_col_num <= last_MCU_col;
- MCU_col_num++) {
- /* Determine where data comes from in input_buf and do the DCT thing.
- * Each call on forward_DCT processes a horizontal row of DCT blocks
- * as wide as an MCU; we rely on having allocated the MCU_buffer[] blocks
- * sequentially. Dummy blocks at the right or bottom edge are filled in
- * specially. The data in them does not matter for image reconstruction,
- * so we fill them with values that will encode to the smallest amount of
- * data, viz: all zeroes in the AC entries, DC entries equal to previous
- * block's DC value. (Thanks to Thomas Kinsman for this idea.)
- */
- blkn = 0;
- for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
- compptr = cinfo->cur_comp_info[ci];
- blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width :
- compptr->last_col_width;
- xpos = MCU_col_num * compptr->MCU_sample_width;
- ypos = yoffset * DCTSIZE; /* ypos == (yoffset+yindex) * DCTSIZE */
- for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
- if (coef->iMCU_row_num < last_iMCU_row ||
- yoffset + yindex < compptr->last_row_height) {
- (*cinfo->fdct->forward_DCT) (cinfo, compptr,
- input_buf[compptr->component_index],
- coef->MCU_buffer[blkn],
- ypos, xpos, (JDIMENSION)blockcnt);
- if (blockcnt < compptr->MCU_width) {
- /* Create some dummy blocks at the right edge of the image. */
- jzero_far((void *)coef->MCU_buffer[blkn + blockcnt],
- (compptr->MCU_width - blockcnt) * sizeof(JBLOCK));
- for (bi = blockcnt; bi < compptr->MCU_width; bi++) {
- coef->MCU_buffer[blkn + bi][0][0] =
- coef->MCU_buffer[blkn + bi - 1][0][0];
- }
- }
- } else {
- /* Create a row of dummy blocks at the bottom of the image. */
- jzero_far((void *)coef->MCU_buffer[blkn],
- compptr->MCU_width * sizeof(JBLOCK));
- for (bi = 0; bi < compptr->MCU_width; bi++) {
- coef->MCU_buffer[blkn + bi][0][0] =
- coef->MCU_buffer[blkn - 1][0][0];
- }
- }
- blkn += compptr->MCU_width;
- ypos += DCTSIZE;
- }
- }
- /* Try to write the MCU. In event of a suspension failure, we will
- * re-DCT the MCU on restart (a bit inefficient, could be fixed...)
- */
- if (!(*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) {
- /* Suspension forced; update state counters and exit */
- coef->MCU_vert_offset = yoffset;
- coef->mcu_ctr = MCU_col_num;
- return FALSE;
- }
- }
- /* Completed an MCU row, but perhaps not an iMCU row */
- coef->mcu_ctr = 0;
- }
- /* Completed the iMCU row, advance counters for next one */
- coef->iMCU_row_num++;
- start_iMCU_row(cinfo);
- return TRUE;
-}
-
-
-#ifdef FULL_COEF_BUFFER_SUPPORTED
-
-/*
- * Process some data in the first pass of a multi-pass case.
- * We process the equivalent of one fully interleaved MCU row ("iMCU" row)
- * per call, ie, v_samp_factor block rows for each component in the image.
- * This amount of data is read from the source buffer, DCT'd and quantized,
- * and saved into the virtual arrays. We also generate suitable dummy blocks
- * as needed at the right and lower edges. (The dummy blocks are constructed
- * in the virtual arrays, which have been padded appropriately.) This makes
- * it possible for subsequent passes not to worry about real vs. dummy blocks.
- *
- * We must also emit the data to the entropy encoder. This is conveniently
- * done by calling compress_output() after we've loaded the current strip
- * of the virtual arrays.
- *
- * NB: input_buf contains a plane for each component in image. All
- * components are DCT'd and loaded into the virtual arrays in this pass.
- * However, it may be that only a subset of the components are emitted to
- * the entropy encoder during this first pass; be careful about looking
- * at the scan-dependent variables (MCU dimensions, etc).
- */
-
-METHODDEF(boolean)
-compress_first_pass(j_compress_ptr cinfo, JSAMPIMAGE input_buf)
-{
- my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
- JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
- JDIMENSION blocks_across, MCUs_across, MCUindex;
- int bi, ci, h_samp_factor, block_row, block_rows, ndummy;
- JCOEF lastDC;
- jpeg_component_info *compptr;
- JBLOCKARRAY buffer;
- JBLOCKROW thisblockrow, lastblockrow;
-
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
- ci++, compptr++) {
- /* Align the virtual buffer for this component. */
- buffer = (*cinfo->mem->access_virt_barray)
- ((j_common_ptr)cinfo, coef->whole_image[ci],
- coef->iMCU_row_num * compptr->v_samp_factor,
- (JDIMENSION)compptr->v_samp_factor, TRUE);
- /* Count non-dummy DCT block rows in this iMCU row. */
- if (coef->iMCU_row_num < last_iMCU_row)
- block_rows = compptr->v_samp_factor;
- else {
- /* NB: can't use last_row_height here, since may not be set! */
- block_rows = (int)(compptr->height_in_blocks % compptr->v_samp_factor);
- if (block_rows == 0) block_rows = compptr->v_samp_factor;
- }
- blocks_across = compptr->width_in_blocks;
- h_samp_factor = compptr->h_samp_factor;
- /* Count number of dummy blocks to be added at the right margin. */
- ndummy = (int)(blocks_across % h_samp_factor);
- if (ndummy > 0)
- ndummy = h_samp_factor - ndummy;
- /* Perform DCT for all non-dummy blocks in this iMCU row. Each call
- * on forward_DCT processes a complete horizontal row of DCT blocks.
- */
- for (block_row = 0; block_row < block_rows; block_row++) {
- thisblockrow = buffer[block_row];
- (*cinfo->fdct->forward_DCT) (cinfo, compptr,
- input_buf[ci], thisblockrow,
- (JDIMENSION)(block_row * DCTSIZE),
- (JDIMENSION)0, blocks_across);
- if (ndummy > 0) {
- /* Create dummy blocks at the right edge of the image. */
- thisblockrow += blocks_across; /* => first dummy block */
- jzero_far((void *)thisblockrow, ndummy * sizeof(JBLOCK));
- lastDC = thisblockrow[-1][0];
- for (bi = 0; bi < ndummy; bi++) {
- thisblockrow[bi][0] = lastDC;
- }
- }
- }
- /* If at end of image, create dummy block rows as needed.
- * The tricky part here is that within each MCU, we want the DC values
- * of the dummy blocks to match the last real block's DC value.
- * This squeezes a few more bytes out of the resulting file...
- */
- if (coef->iMCU_row_num == last_iMCU_row) {
- blocks_across += ndummy; /* include lower right corner */
- MCUs_across = blocks_across / h_samp_factor;
- for (block_row = block_rows; block_row < compptr->v_samp_factor;
- block_row++) {
- thisblockrow = buffer[block_row];
- lastblockrow = buffer[block_row - 1];
- jzero_far((void *)thisblockrow,
- (size_t)(blocks_across * sizeof(JBLOCK)));
- for (MCUindex = 0; MCUindex < MCUs_across; MCUindex++) {
- lastDC = lastblockrow[h_samp_factor - 1][0];
- for (bi = 0; bi < h_samp_factor; bi++) {
- thisblockrow[bi][0] = lastDC;
- }
- thisblockrow += h_samp_factor; /* advance to next MCU in row */
- lastblockrow += h_samp_factor;
- }
- }
- }
- }
- /* NB: compress_output will increment iMCU_row_num if successful.
- * A suspension return will result in redoing all the work above next time.
- */
-
- /* Emit data to the entropy encoder, sharing code with subsequent passes */
- return compress_output(cinfo, input_buf);
-}
-
-
-/*
- * Process some data in subsequent passes of a multi-pass case.
- * We process the equivalent of one fully interleaved MCU row ("iMCU" row)
- * per call, ie, v_samp_factor block rows for each component in the scan.
- * The data is obtained from the virtual arrays and fed to the entropy coder.
- * Returns TRUE if the iMCU row is completed, FALSE if suspended.
- *
- * NB: input_buf is ignored; it is likely to be a NULL pointer.
- */
-
-METHODDEF(boolean)
-compress_output(j_compress_ptr cinfo, JSAMPIMAGE input_buf)
-{
- my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
- JDIMENSION MCU_col_num; /* index of current MCU within row */
- int blkn, ci, xindex, yindex, yoffset;
- JDIMENSION start_col;
- JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN];
- JBLOCKROW buffer_ptr;
- jpeg_component_info *compptr;
-
- /* Align the virtual buffers for the components used in this scan.
- * NB: during first pass, this is safe only because the buffers will
- * already be aligned properly, so jmemmgr.c won't need to do any I/O.
- */
- for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
- compptr = cinfo->cur_comp_info[ci];
- buffer[ci] = (*cinfo->mem->access_virt_barray)
- ((j_common_ptr)cinfo, coef->whole_image[compptr->component_index],
- coef->iMCU_row_num * compptr->v_samp_factor,
- (JDIMENSION)compptr->v_samp_factor, FALSE);
- }
-
- /* Loop to process one whole iMCU row */
- for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
- yoffset++) {
- for (MCU_col_num = coef->mcu_ctr; MCU_col_num < cinfo->MCUs_per_row;
- MCU_col_num++) {
- /* Construct list of pointers to DCT blocks belonging to this MCU */
- blkn = 0; /* index of current DCT block within MCU */
- for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
- compptr = cinfo->cur_comp_info[ci];
- start_col = MCU_col_num * compptr->MCU_width;
- for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
- buffer_ptr = buffer[ci][yindex + yoffset] + start_col;
- for (xindex = 0; xindex < compptr->MCU_width; xindex++) {
- coef->MCU_buffer[blkn++] = buffer_ptr++;
- }
- }
- }
- /* Try to write the MCU. */
- if (!(*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) {
- /* Suspension forced; update state counters and exit */
- coef->MCU_vert_offset = yoffset;
- coef->mcu_ctr = MCU_col_num;
- return FALSE;
- }
- }
- /* Completed an MCU row, but perhaps not an iMCU row */
- coef->mcu_ctr = 0;
- }
- /* Completed the iMCU row, advance counters for next one */
- coef->iMCU_row_num++;
- start_iMCU_row(cinfo);
- return TRUE;
-}
-
-#endif /* FULL_COEF_BUFFER_SUPPORTED */
-
-
-/*
- * Initialize coefficient buffer controller.
- */
-
-GLOBAL(void)
-jinit_c_coef_controller(j_compress_ptr cinfo, boolean need_full_buffer)
-{
- my_coef_ptr coef;
-
- coef = (my_coef_ptr)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- sizeof(my_coef_controller));
- cinfo->coef = (struct jpeg_c_coef_controller *)coef;
- coef->pub.start_pass = start_pass_coef;
-
- /* Create the coefficient buffer. */
- if (need_full_buffer) {
-#ifdef FULL_COEF_BUFFER_SUPPORTED
- /* Allocate a full-image virtual array for each component, */
- /* padded to a multiple of samp_factor DCT blocks in each direction. */
- int ci;
- jpeg_component_info *compptr;
-
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
- ci++, compptr++) {
- coef->whole_image[ci] = (*cinfo->mem->request_virt_barray)
- ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE,
- (JDIMENSION)jround_up((long)compptr->width_in_blocks,
- (long)compptr->h_samp_factor),
- (JDIMENSION)jround_up((long)compptr->height_in_blocks,
- (long)compptr->v_samp_factor),
- (JDIMENSION)compptr->v_samp_factor);
- }
-#else
- ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
-#endif
- } else {
- /* We only need a single-MCU buffer. */
- JBLOCKROW buffer;
- int i;
-
- buffer = (JBLOCKROW)
- (*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- C_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK));
- for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) {
- coef->MCU_buffer[i] = buffer + i;
- }
- coef->whole_image[0] = NULL; /* flag for no virtual arrays */
- }
-}
diff --git a/contrib/libs/libjpeg-turbo/jccolext.c b/contrib/libs/libjpeg-turbo/jccolext.c
deleted file mode 100644
index 303b322ce6..0000000000
--- a/contrib/libs/libjpeg-turbo/jccolext.c
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * jccolext.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1996, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2009-2012, 2015, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains input colorspace conversion routines.
- */
-
-
-/* This file is included by jccolor.c */
-
-
-/*
- * Convert some rows of samples to the JPEG colorspace.
- *
- * Note that we change from the application's interleaved-pixel format
- * to our internal noninterleaved, one-plane-per-component format.
- * The input buffer is therefore three times as wide as the output buffer.
- *
- * A starting row offset is provided only for the output buffer. The caller
- * can easily adjust the passed input_buf value to accommodate any row
- * offset required on that side.
- */
-
-INLINE
-LOCAL(void)
-rgb_ycc_convert_internal(j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPIMAGE output_buf, JDIMENSION output_row,
- int num_rows)
-{
- my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
- register int r, g, b;
- register JLONG *ctab = cconvert->rgb_ycc_tab;
- register JSAMPROW inptr;
- register JSAMPROW outptr0, outptr1, outptr2;
- register JDIMENSION col;
- JDIMENSION num_cols = cinfo->image_width;
-
- while (--num_rows >= 0) {
- inptr = *input_buf++;
- outptr0 = output_buf[0][output_row];
- outptr1 = output_buf[1][output_row];
- outptr2 = output_buf[2][output_row];
- output_row++;
- for (col = 0; col < num_cols; col++) {
- r = inptr[RGB_RED];
- g = inptr[RGB_GREEN];
- b = inptr[RGB_BLUE];
- inptr += RGB_PIXELSIZE;
- /* If the inputs are 0..MAXJSAMPLE, the outputs of these equations
- * must be too; we do not need an explicit range-limiting operation.
- * Hence the value being shifted is never negative, and we don't
- * need the general RIGHT_SHIFT macro.
- */
- /* Y */
- outptr0[col] = (JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
- ctab[b + B_Y_OFF]) >> SCALEBITS);
- /* Cb */
- outptr1[col] = (JSAMPLE)((ctab[r + R_CB_OFF] + ctab[g + G_CB_OFF] +
- ctab[b + B_CB_OFF]) >> SCALEBITS);
- /* Cr */
- outptr2[col] = (JSAMPLE)((ctab[r + R_CR_OFF] + ctab[g + G_CR_OFF] +
- ctab[b + B_CR_OFF]) >> SCALEBITS);
- }
- }
-}
-
-
-/**************** Cases other than RGB -> YCbCr **************/
-
-
-/*
- * Convert some rows of samples to the JPEG colorspace.
- * This version handles RGB->grayscale conversion, which is the same
- * as the RGB->Y portion of RGB->YCbCr.
- * We assume rgb_ycc_start has been called (we only use the Y tables).
- */
-
-INLINE
-LOCAL(void)
-rgb_gray_convert_internal(j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPIMAGE output_buf, JDIMENSION output_row,
- int num_rows)
-{
- my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
- register int r, g, b;
- register JLONG *ctab = cconvert->rgb_ycc_tab;
- register JSAMPROW inptr;
- register JSAMPROW outptr;
- register JDIMENSION col;
- JDIMENSION num_cols = cinfo->image_width;
-
- while (--num_rows >= 0) {
- inptr = *input_buf++;
- outptr = output_buf[0][output_row];
- output_row++;
- for (col = 0; col < num_cols; col++) {
- r = inptr[RGB_RED];
- g = inptr[RGB_GREEN];
- b = inptr[RGB_BLUE];
- inptr += RGB_PIXELSIZE;
- /* Y */
- outptr[col] = (JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
- ctab[b + B_Y_OFF]) >> SCALEBITS);
- }
- }
-}
-
-
-/*
- * Convert some rows of samples to the JPEG colorspace.
- * This version handles extended RGB->plain RGB conversion
- */
-
-INLINE
-LOCAL(void)
-rgb_rgb_convert_internal(j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPIMAGE output_buf, JDIMENSION output_row,
- int num_rows)
-{
- register JSAMPROW inptr;
- register JSAMPROW outptr0, outptr1, outptr2;
- register JDIMENSION col;
- JDIMENSION num_cols = cinfo->image_width;
-
- while (--num_rows >= 0) {
- inptr = *input_buf++;
- outptr0 = output_buf[0][output_row];
- outptr1 = output_buf[1][output_row];
- outptr2 = output_buf[2][output_row];
- output_row++;
- for (col = 0; col < num_cols; col++) {
- outptr0[col] = inptr[RGB_RED];
- outptr1[col] = inptr[RGB_GREEN];
- outptr2[col] = inptr[RGB_BLUE];
- inptr += RGB_PIXELSIZE;
- }
- }
-}
diff --git a/contrib/libs/libjpeg-turbo/jccolor.c b/contrib/libs/libjpeg-turbo/jccolor.c
deleted file mode 100644
index bdc563c723..0000000000
--- a/contrib/libs/libjpeg-turbo/jccolor.c
+++ /dev/null
@@ -1,710 +0,0 @@
-/*
- * jccolor.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1996, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- * Copyright (C) 2009-2012, 2015, D. R. Commander.
- * Copyright (C) 2014, MIPS Technologies, Inc., California.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains input colorspace conversion routines.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-#include "jsimd.h"
-#include "jconfigint.h"
-
-
-/* Private subobject */
-
-typedef struct {
- struct jpeg_color_converter pub; /* public fields */
-
- /* Private state for RGB->YCC conversion */
- JLONG *rgb_ycc_tab; /* => table for RGB to YCbCr conversion */
-} my_color_converter;
-
-typedef my_color_converter *my_cconvert_ptr;
-
-
-/**************** RGB -> YCbCr conversion: most common case **************/
-
-/*
- * YCbCr is defined per CCIR 601-1, except that Cb and Cr are
- * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5.
- * The conversion equations to be implemented are therefore
- * Y = 0.29900 * R + 0.58700 * G + 0.11400 * B
- * Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + CENTERJSAMPLE
- * Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + CENTERJSAMPLE
- * (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.)
- * Note: older versions of the IJG code used a zero offset of MAXJSAMPLE/2,
- * rather than CENTERJSAMPLE, for Cb and Cr. This gave equal positive and
- * negative swings for Cb/Cr, but meant that grayscale values (Cb=Cr=0)
- * were not represented exactly. Now we sacrifice exact representation of
- * maximum red and maximum blue in order to get exact grayscales.
- *
- * To avoid floating-point arithmetic, we represent the fractional constants
- * as integers scaled up by 2^16 (about 4 digits precision); we have to divide
- * the products by 2^16, with appropriate rounding, to get the correct answer.
- *
- * For even more speed, we avoid doing any multiplications in the inner loop
- * by precalculating the constants times R,G,B for all possible values.
- * For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table);
- * for 12-bit samples it is still acceptable. It's not very reasonable for
- * 16-bit samples, but if you want lossless storage you shouldn't be changing
- * colorspace anyway.
- * The CENTERJSAMPLE offsets and the rounding fudge-factor of 0.5 are included
- * in the tables to save adding them separately in the inner loop.
- */
-
-#define SCALEBITS 16 /* speediest right-shift on some machines */
-#define CBCR_OFFSET ((JLONG)CENTERJSAMPLE << SCALEBITS)
-#define ONE_HALF ((JLONG)1 << (SCALEBITS - 1))
-#define FIX(x) ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
-
-/* We allocate one big table and divide it up into eight parts, instead of
- * doing eight alloc_small requests. This lets us use a single table base
- * address, which can be held in a register in the inner loops on many
- * machines (more than can hold all eight addresses, anyway).
- */
-
-#define R_Y_OFF 0 /* offset to R => Y section */
-#define G_Y_OFF (1 * (MAXJSAMPLE + 1)) /* offset to G => Y section */
-#define B_Y_OFF (2 * (MAXJSAMPLE + 1)) /* etc. */
-#define R_CB_OFF (3 * (MAXJSAMPLE + 1))
-#define G_CB_OFF (4 * (MAXJSAMPLE + 1))
-#define B_CB_OFF (5 * (MAXJSAMPLE + 1))
-#define R_CR_OFF B_CB_OFF /* B=>Cb, R=>Cr are the same */
-#define G_CR_OFF (6 * (MAXJSAMPLE + 1))
-#define B_CR_OFF (7 * (MAXJSAMPLE + 1))
-#define TABLE_SIZE (8 * (MAXJSAMPLE + 1))
-
-
-/* Include inline routines for colorspace extensions */
-
-#include "jccolext.c"
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_PIXELSIZE
-
-#define RGB_RED EXT_RGB_RED
-#define RGB_GREEN EXT_RGB_GREEN
-#define RGB_BLUE EXT_RGB_BLUE
-#define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
-#define rgb_ycc_convert_internal extrgb_ycc_convert_internal
-#define rgb_gray_convert_internal extrgb_gray_convert_internal
-#define rgb_rgb_convert_internal extrgb_rgb_convert_internal
-#include "jccolext.c"
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_PIXELSIZE
-#undef rgb_ycc_convert_internal
-#undef rgb_gray_convert_internal
-#undef rgb_rgb_convert_internal
-
-#define RGB_RED EXT_RGBX_RED
-#define RGB_GREEN EXT_RGBX_GREEN
-#define RGB_BLUE EXT_RGBX_BLUE
-#define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
-#define rgb_ycc_convert_internal extrgbx_ycc_convert_internal
-#define rgb_gray_convert_internal extrgbx_gray_convert_internal
-#define rgb_rgb_convert_internal extrgbx_rgb_convert_internal
-#include "jccolext.c"
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_PIXELSIZE
-#undef rgb_ycc_convert_internal
-#undef rgb_gray_convert_internal
-#undef rgb_rgb_convert_internal
-
-#define RGB_RED EXT_BGR_RED
-#define RGB_GREEN EXT_BGR_GREEN
-#define RGB_BLUE EXT_BGR_BLUE
-#define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
-#define rgb_ycc_convert_internal extbgr_ycc_convert_internal
-#define rgb_gray_convert_internal extbgr_gray_convert_internal
-#define rgb_rgb_convert_internal extbgr_rgb_convert_internal
-#include "jccolext.c"
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_PIXELSIZE
-#undef rgb_ycc_convert_internal
-#undef rgb_gray_convert_internal
-#undef rgb_rgb_convert_internal
-
-#define RGB_RED EXT_BGRX_RED
-#define RGB_GREEN EXT_BGRX_GREEN
-#define RGB_BLUE EXT_BGRX_BLUE
-#define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
-#define rgb_ycc_convert_internal extbgrx_ycc_convert_internal
-#define rgb_gray_convert_internal extbgrx_gray_convert_internal
-#define rgb_rgb_convert_internal extbgrx_rgb_convert_internal
-#include "jccolext.c"
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_PIXELSIZE
-#undef rgb_ycc_convert_internal
-#undef rgb_gray_convert_internal
-#undef rgb_rgb_convert_internal
-
-#define RGB_RED EXT_XBGR_RED
-#define RGB_GREEN EXT_XBGR_GREEN
-#define RGB_BLUE EXT_XBGR_BLUE
-#define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
-#define rgb_ycc_convert_internal extxbgr_ycc_convert_internal
-#define rgb_gray_convert_internal extxbgr_gray_convert_internal
-#define rgb_rgb_convert_internal extxbgr_rgb_convert_internal
-#include "jccolext.c"
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_PIXELSIZE
-#undef rgb_ycc_convert_internal
-#undef rgb_gray_convert_internal
-#undef rgb_rgb_convert_internal
-
-#define RGB_RED EXT_XRGB_RED
-#define RGB_GREEN EXT_XRGB_GREEN
-#define RGB_BLUE EXT_XRGB_BLUE
-#define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
-#define rgb_ycc_convert_internal extxrgb_ycc_convert_internal
-#define rgb_gray_convert_internal extxrgb_gray_convert_internal
-#define rgb_rgb_convert_internal extxrgb_rgb_convert_internal
-#include "jccolext.c"
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_PIXELSIZE
-#undef rgb_ycc_convert_internal
-#undef rgb_gray_convert_internal
-#undef rgb_rgb_convert_internal
-
-
-/*
- * Initialize for RGB->YCC colorspace conversion.
- */
-
-METHODDEF(void)
-rgb_ycc_start(j_compress_ptr cinfo)
-{
- my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
- JLONG *rgb_ycc_tab;
- JLONG i;
-
- /* Allocate and fill in the conversion tables. */
- cconvert->rgb_ycc_tab = rgb_ycc_tab = (JLONG *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- (TABLE_SIZE * sizeof(JLONG)));
-
- for (i = 0; i <= MAXJSAMPLE; i++) {
- rgb_ycc_tab[i + R_Y_OFF] = FIX(0.29900) * i;
- rgb_ycc_tab[i + G_Y_OFF] = FIX(0.58700) * i;
- rgb_ycc_tab[i + B_Y_OFF] = FIX(0.11400) * i + ONE_HALF;
- rgb_ycc_tab[i + R_CB_OFF] = (-FIX(0.16874)) * i;
- rgb_ycc_tab[i + G_CB_OFF] = (-FIX(0.33126)) * i;
- /* We use a rounding fudge-factor of 0.5-epsilon for Cb and Cr.
- * This ensures that the maximum output will round to MAXJSAMPLE
- * not MAXJSAMPLE+1, and thus that we don't have to range-limit.
- */
- rgb_ycc_tab[i + B_CB_OFF] = FIX(0.50000) * i + CBCR_OFFSET + ONE_HALF - 1;
-/* B=>Cb and R=>Cr tables are the same
- rgb_ycc_tab[i + R_CR_OFF] = FIX(0.50000) * i + CBCR_OFFSET + ONE_HALF - 1;
-*/
- rgb_ycc_tab[i + G_CR_OFF] = (-FIX(0.41869)) * i;
- rgb_ycc_tab[i + B_CR_OFF] = (-FIX(0.08131)) * i;
- }
-}
-
-
-/*
- * Convert some rows of samples to the JPEG colorspace.
- */
-
-METHODDEF(void)
-rgb_ycc_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPIMAGE output_buf, JDIMENSION output_row, int num_rows)
-{
- switch (cinfo->in_color_space) {
- case JCS_EXT_RGB:
- extrgb_ycc_convert_internal(cinfo, input_buf, output_buf, output_row,
- num_rows);
- break;
- case JCS_EXT_RGBX:
- case JCS_EXT_RGBA:
- extrgbx_ycc_convert_internal(cinfo, input_buf, output_buf, output_row,
- num_rows);
- break;
- case JCS_EXT_BGR:
- extbgr_ycc_convert_internal(cinfo, input_buf, output_buf, output_row,
- num_rows);
- break;
- case JCS_EXT_BGRX:
- case JCS_EXT_BGRA:
- extbgrx_ycc_convert_internal(cinfo, input_buf, output_buf, output_row,
- num_rows);
- break;
- case JCS_EXT_XBGR:
- case JCS_EXT_ABGR:
- extxbgr_ycc_convert_internal(cinfo, input_buf, output_buf, output_row,
- num_rows);
- break;
- case JCS_EXT_XRGB:
- case JCS_EXT_ARGB:
- extxrgb_ycc_convert_internal(cinfo, input_buf, output_buf, output_row,
- num_rows);
- break;
- default:
- rgb_ycc_convert_internal(cinfo, input_buf, output_buf, output_row,
- num_rows);
- break;
- }
-}
-
-
-/**************** Cases other than RGB -> YCbCr **************/
-
-
-/*
- * Convert some rows of samples to the JPEG colorspace.
- */
-
-METHODDEF(void)
-rgb_gray_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPIMAGE output_buf, JDIMENSION output_row, int num_rows)
-{
- switch (cinfo->in_color_space) {
- case JCS_EXT_RGB:
- extrgb_gray_convert_internal(cinfo, input_buf, output_buf, output_row,
- num_rows);
- break;
- case JCS_EXT_RGBX:
- case JCS_EXT_RGBA:
- extrgbx_gray_convert_internal(cinfo, input_buf, output_buf, output_row,
- num_rows);
- break;
- case JCS_EXT_BGR:
- extbgr_gray_convert_internal(cinfo, input_buf, output_buf, output_row,
- num_rows);
- break;
- case JCS_EXT_BGRX:
- case JCS_EXT_BGRA:
- extbgrx_gray_convert_internal(cinfo, input_buf, output_buf, output_row,
- num_rows);
- break;
- case JCS_EXT_XBGR:
- case JCS_EXT_ABGR:
- extxbgr_gray_convert_internal(cinfo, input_buf, output_buf, output_row,
- num_rows);
- break;
- case JCS_EXT_XRGB:
- case JCS_EXT_ARGB:
- extxrgb_gray_convert_internal(cinfo, input_buf, output_buf, output_row,
- num_rows);
- break;
- default:
- rgb_gray_convert_internal(cinfo, input_buf, output_buf, output_row,
- num_rows);
- break;
- }
-}
-
-
-/*
- * Extended RGB to plain RGB conversion
- */
-
-METHODDEF(void)
-rgb_rgb_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPIMAGE output_buf, JDIMENSION output_row, int num_rows)
-{
- switch (cinfo->in_color_space) {
- case JCS_EXT_RGB:
- extrgb_rgb_convert_internal(cinfo, input_buf, output_buf, output_row,
- num_rows);
- break;
- case JCS_EXT_RGBX:
- case JCS_EXT_RGBA:
- extrgbx_rgb_convert_internal(cinfo, input_buf, output_buf, output_row,
- num_rows);
- break;
- case JCS_EXT_BGR:
- extbgr_rgb_convert_internal(cinfo, input_buf, output_buf, output_row,
- num_rows);
- break;
- case JCS_EXT_BGRX:
- case JCS_EXT_BGRA:
- extbgrx_rgb_convert_internal(cinfo, input_buf, output_buf, output_row,
- num_rows);
- break;
- case JCS_EXT_XBGR:
- case JCS_EXT_ABGR:
- extxbgr_rgb_convert_internal(cinfo, input_buf, output_buf, output_row,
- num_rows);
- break;
- case JCS_EXT_XRGB:
- case JCS_EXT_ARGB:
- extxrgb_rgb_convert_internal(cinfo, input_buf, output_buf, output_row,
- num_rows);
- break;
- default:
- rgb_rgb_convert_internal(cinfo, input_buf, output_buf, output_row,
- num_rows);
- break;
- }
-}
-
-
-/*
- * Convert some rows of samples to the JPEG colorspace.
- * This version handles Adobe-style CMYK->YCCK conversion,
- * where we convert R=1-C, G=1-M, and B=1-Y to YCbCr using the same
- * conversion as above, while passing K (black) unchanged.
- * We assume rgb_ycc_start has been called.
- */
-
-METHODDEF(void)
-cmyk_ycck_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPIMAGE output_buf, JDIMENSION output_row, int num_rows)
-{
- my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
- register int r, g, b;
- register JLONG *ctab = cconvert->rgb_ycc_tab;
- register JSAMPROW inptr;
- register JSAMPROW outptr0, outptr1, outptr2, outptr3;
- register JDIMENSION col;
- JDIMENSION num_cols = cinfo->image_width;
-
- while (--num_rows >= 0) {
- inptr = *input_buf++;
- outptr0 = output_buf[0][output_row];
- outptr1 = output_buf[1][output_row];
- outptr2 = output_buf[2][output_row];
- outptr3 = output_buf[3][output_row];
- output_row++;
- for (col = 0; col < num_cols; col++) {
- r = MAXJSAMPLE - inptr[0];
- g = MAXJSAMPLE - inptr[1];
- b = MAXJSAMPLE - inptr[2];
- /* K passes through as-is */
- outptr3[col] = inptr[3];
- inptr += 4;
- /* If the inputs are 0..MAXJSAMPLE, the outputs of these equations
- * must be too; we do not need an explicit range-limiting operation.
- * Hence the value being shifted is never negative, and we don't
- * need the general RIGHT_SHIFT macro.
- */
- /* Y */
- outptr0[col] = (JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
- ctab[b + B_Y_OFF]) >> SCALEBITS);
- /* Cb */
- outptr1[col] = (JSAMPLE)((ctab[r + R_CB_OFF] + ctab[g + G_CB_OFF] +
- ctab[b + B_CB_OFF]) >> SCALEBITS);
- /* Cr */
- outptr2[col] = (JSAMPLE)((ctab[r + R_CR_OFF] + ctab[g + G_CR_OFF] +
- ctab[b + B_CR_OFF]) >> SCALEBITS);
- }
- }
-}
-
-
-/*
- * Convert some rows of samples to the JPEG colorspace.
- * This version handles grayscale output with no conversion.
- * The source can be either plain grayscale or YCbCr (since Y == gray).
- */
-
-METHODDEF(void)
-grayscale_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPIMAGE output_buf, JDIMENSION output_row, int num_rows)
-{
- register JSAMPROW inptr;
- register JSAMPROW outptr;
- register JDIMENSION col;
- JDIMENSION num_cols = cinfo->image_width;
- int instride = cinfo->input_components;
-
- while (--num_rows >= 0) {
- inptr = *input_buf++;
- outptr = output_buf[0][output_row];
- output_row++;
- for (col = 0; col < num_cols; col++) {
- outptr[col] = inptr[0];
- inptr += instride;
- }
- }
-}
-
-
-/*
- * Convert some rows of samples to the JPEG colorspace.
- * This version handles multi-component colorspaces without conversion.
- * We assume input_components == num_components.
- */
-
-METHODDEF(void)
-null_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows)
-{
- register JSAMPROW inptr;
- register JSAMPROW outptr, outptr0, outptr1, outptr2, outptr3;
- register JDIMENSION col;
- register int ci;
- int nc = cinfo->num_components;
- JDIMENSION num_cols = cinfo->image_width;
-
- if (nc == 3) {
- while (--num_rows >= 0) {
- inptr = *input_buf++;
- outptr0 = output_buf[0][output_row];
- outptr1 = output_buf[1][output_row];
- outptr2 = output_buf[2][output_row];
- output_row++;
- for (col = 0; col < num_cols; col++) {
- outptr0[col] = *inptr++;
- outptr1[col] = *inptr++;
- outptr2[col] = *inptr++;
- }
- }
- } else if (nc == 4) {
- while (--num_rows >= 0) {
- inptr = *input_buf++;
- outptr0 = output_buf[0][output_row];
- outptr1 = output_buf[1][output_row];
- outptr2 = output_buf[2][output_row];
- outptr3 = output_buf[3][output_row];
- output_row++;
- for (col = 0; col < num_cols; col++) {
- outptr0[col] = *inptr++;
- outptr1[col] = *inptr++;
- outptr2[col] = *inptr++;
- outptr3[col] = *inptr++;
- }
- }
- } else {
- while (--num_rows >= 0) {
- /* It seems fastest to make a separate pass for each component. */
- for (ci = 0; ci < nc; ci++) {
- inptr = *input_buf;
- outptr = output_buf[ci][output_row];
- for (col = 0; col < num_cols; col++) {
- outptr[col] = inptr[ci];
- inptr += nc;
- }
- }
- input_buf++;
- output_row++;
- }
- }
-}
-
-
-/*
- * Empty method for start_pass.
- */
-
-METHODDEF(void)
-null_method(j_compress_ptr cinfo)
-{
- /* no work needed */
-}
-
-
-/*
- * Module initialization routine for input colorspace conversion.
- */
-
-GLOBAL(void)
-jinit_color_converter(j_compress_ptr cinfo)
-{
- my_cconvert_ptr cconvert;
-
- cconvert = (my_cconvert_ptr)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- sizeof(my_color_converter));
- cinfo->cconvert = (struct jpeg_color_converter *)cconvert;
- /* set start_pass to null method until we find out differently */
- cconvert->pub.start_pass = null_method;
-
- /* Make sure input_components agrees with in_color_space */
- switch (cinfo->in_color_space) {
- case JCS_GRAYSCALE:
- if (cinfo->input_components != 1)
- ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
- break;
-
- case JCS_RGB:
- case JCS_EXT_RGB:
- case JCS_EXT_RGBX:
- case JCS_EXT_BGR:
- case JCS_EXT_BGRX:
- case JCS_EXT_XBGR:
- case JCS_EXT_XRGB:
- case JCS_EXT_RGBA:
- case JCS_EXT_BGRA:
- case JCS_EXT_ABGR:
- case JCS_EXT_ARGB:
- if (cinfo->input_components != rgb_pixelsize[cinfo->in_color_space])
- ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
- break;
-
- case JCS_YCbCr:
- if (cinfo->input_components != 3)
- ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
- break;
-
- case JCS_CMYK:
- case JCS_YCCK:
- if (cinfo->input_components != 4)
- ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
- break;
-
- default: /* JCS_UNKNOWN can be anything */
- if (cinfo->input_components < 1)
- ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
- break;
- }
-
- /* Check num_components, set conversion method based on requested space */
- switch (cinfo->jpeg_color_space) {
- case JCS_GRAYSCALE:
- if (cinfo->num_components != 1)
- ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
- if (cinfo->in_color_space == JCS_GRAYSCALE)
- cconvert->pub.color_convert = grayscale_convert;
- else if (cinfo->in_color_space == JCS_RGB ||
- cinfo->in_color_space == JCS_EXT_RGB ||
- cinfo->in_color_space == JCS_EXT_RGBX ||
- cinfo->in_color_space == JCS_EXT_BGR ||
- cinfo->in_color_space == JCS_EXT_BGRX ||
- cinfo->in_color_space == JCS_EXT_XBGR ||
- cinfo->in_color_space == JCS_EXT_XRGB ||
- cinfo->in_color_space == JCS_EXT_RGBA ||
- cinfo->in_color_space == JCS_EXT_BGRA ||
- cinfo->in_color_space == JCS_EXT_ABGR ||
- cinfo->in_color_space == JCS_EXT_ARGB) {
- if (jsimd_can_rgb_gray())
- cconvert->pub.color_convert = jsimd_rgb_gray_convert;
- else {
- cconvert->pub.start_pass = rgb_ycc_start;
- cconvert->pub.color_convert = rgb_gray_convert;
- }
- } else if (cinfo->in_color_space == JCS_YCbCr)
- cconvert->pub.color_convert = grayscale_convert;
- else
- ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
- break;
-
- case JCS_RGB:
- if (cinfo->num_components != 3)
- ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
- if (rgb_red[cinfo->in_color_space] == 0 &&
- rgb_green[cinfo->in_color_space] == 1 &&
- rgb_blue[cinfo->in_color_space] == 2 &&
- rgb_pixelsize[cinfo->in_color_space] == 3) {
-#if defined(__mips__)
- if (jsimd_c_can_null_convert())
- cconvert->pub.color_convert = jsimd_c_null_convert;
- else
-#endif
- cconvert->pub.color_convert = null_convert;
- } else if (cinfo->in_color_space == JCS_RGB ||
- cinfo->in_color_space == JCS_EXT_RGB ||
- cinfo->in_color_space == JCS_EXT_RGBX ||
- cinfo->in_color_space == JCS_EXT_BGR ||
- cinfo->in_color_space == JCS_EXT_BGRX ||
- cinfo->in_color_space == JCS_EXT_XBGR ||
- cinfo->in_color_space == JCS_EXT_XRGB ||
- cinfo->in_color_space == JCS_EXT_RGBA ||
- cinfo->in_color_space == JCS_EXT_BGRA ||
- cinfo->in_color_space == JCS_EXT_ABGR ||
- cinfo->in_color_space == JCS_EXT_ARGB)
- cconvert->pub.color_convert = rgb_rgb_convert;
- else
- ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
- break;
-
- case JCS_YCbCr:
- if (cinfo->num_components != 3)
- ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
- if (cinfo->in_color_space == JCS_RGB ||
- cinfo->in_color_space == JCS_EXT_RGB ||
- cinfo->in_color_space == JCS_EXT_RGBX ||
- cinfo->in_color_space == JCS_EXT_BGR ||
- cinfo->in_color_space == JCS_EXT_BGRX ||
- cinfo->in_color_space == JCS_EXT_XBGR ||
- cinfo->in_color_space == JCS_EXT_XRGB ||
- cinfo->in_color_space == JCS_EXT_RGBA ||
- cinfo->in_color_space == JCS_EXT_BGRA ||
- cinfo->in_color_space == JCS_EXT_ABGR ||
- cinfo->in_color_space == JCS_EXT_ARGB) {
- if (jsimd_can_rgb_ycc())
- cconvert->pub.color_convert = jsimd_rgb_ycc_convert;
- else {
- cconvert->pub.start_pass = rgb_ycc_start;
- cconvert->pub.color_convert = rgb_ycc_convert;
- }
- } else if (cinfo->in_color_space == JCS_YCbCr) {
-#if defined(__mips__)
- if (jsimd_c_can_null_convert())
- cconvert->pub.color_convert = jsimd_c_null_convert;
- else
-#endif
- cconvert->pub.color_convert = null_convert;
- } else
- ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
- break;
-
- case JCS_CMYK:
- if (cinfo->num_components != 4)
- ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
- if (cinfo->in_color_space == JCS_CMYK) {
-#if defined(__mips__)
- if (jsimd_c_can_null_convert())
- cconvert->pub.color_convert = jsimd_c_null_convert;
- else
-#endif
- cconvert->pub.color_convert = null_convert;
- } else
- ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
- break;
-
- case JCS_YCCK:
- if (cinfo->num_components != 4)
- ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
- if (cinfo->in_color_space == JCS_CMYK) {
- cconvert->pub.start_pass = rgb_ycc_start;
- cconvert->pub.color_convert = cmyk_ycck_convert;
- } else if (cinfo->in_color_space == JCS_YCCK) {
-#if defined(__mips__)
- if (jsimd_c_can_null_convert())
- cconvert->pub.color_convert = jsimd_c_null_convert;
- else
-#endif
- cconvert->pub.color_convert = null_convert;
- } else
- ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
- break;
-
- default: /* allow null conversion of JCS_UNKNOWN */
- if (cinfo->jpeg_color_space != cinfo->in_color_space ||
- cinfo->num_components != cinfo->input_components)
- ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
-#if defined(__mips__)
- if (jsimd_c_can_null_convert())
- cconvert->pub.color_convert = jsimd_c_null_convert;
- else
-#endif
- cconvert->pub.color_convert = null_convert;
- break;
- }
-}
diff --git a/contrib/libs/libjpeg-turbo/jcdctmgr.c b/contrib/libs/libjpeg-turbo/jcdctmgr.c
deleted file mode 100644
index 7dae17a6e1..0000000000
--- a/contrib/libs/libjpeg-turbo/jcdctmgr.c
+++ /dev/null
@@ -1,720 +0,0 @@
-/*
- * jcdctmgr.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 1999-2006, MIYASAKA Masaru.
- * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- * Copyright (C) 2011, 2014-2015, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains the forward-DCT management logic.
- * This code selects a particular DCT implementation to be used,
- * and it performs related housekeeping chores including coefficient
- * quantization.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-#include "jdct.h" /* Private declarations for DCT subsystem */
-#include "jsimddct.h"
-
-
-/* Private subobject for this module */
-
-typedef void (*forward_DCT_method_ptr) (DCTELEM *data);
-typedef void (*float_DCT_method_ptr) (FAST_FLOAT *data);
-
-typedef void (*convsamp_method_ptr) (JSAMPARRAY sample_data,
- JDIMENSION start_col,
- DCTELEM *workspace);
-typedef void (*float_convsamp_method_ptr) (JSAMPARRAY sample_data,
- JDIMENSION start_col,
- FAST_FLOAT *workspace);
-
-typedef void (*quantize_method_ptr) (JCOEFPTR coef_block, DCTELEM *divisors,
- DCTELEM *workspace);
-typedef void (*float_quantize_method_ptr) (JCOEFPTR coef_block,
- FAST_FLOAT *divisors,
- FAST_FLOAT *workspace);
-
-METHODDEF(void) quantize(JCOEFPTR, DCTELEM *, DCTELEM *);
-
-typedef struct {
- struct jpeg_forward_dct pub; /* public fields */
-
- /* Pointer to the DCT routine actually in use */
- forward_DCT_method_ptr dct;
- convsamp_method_ptr convsamp;
- quantize_method_ptr quantize;
-
- /* The actual post-DCT divisors --- not identical to the quant table
- * entries, because of scaling (especially for an unnormalized DCT).
- * Each table is given in normal array order.
- */
- DCTELEM *divisors[NUM_QUANT_TBLS];
-
- /* work area for FDCT subroutine */
- DCTELEM *workspace;
-
-#ifdef DCT_FLOAT_SUPPORTED
- /* Same as above for the floating-point case. */
- float_DCT_method_ptr float_dct;
- float_convsamp_method_ptr float_convsamp;
- float_quantize_method_ptr float_quantize;
- FAST_FLOAT *float_divisors[NUM_QUANT_TBLS];
- FAST_FLOAT *float_workspace;
-#endif
-} my_fdct_controller;
-
-typedef my_fdct_controller *my_fdct_ptr;
-
-
-#if BITS_IN_JSAMPLE == 8
-
-/*
- * Find the highest bit in an integer through binary search.
- */
-
-LOCAL(int)
-flss(UINT16 val)
-{
- int bit;
-
- bit = 16;
-
- if (!val)
- return 0;
-
- if (!(val & 0xff00)) {
- bit -= 8;
- val <<= 8;
- }
- if (!(val & 0xf000)) {
- bit -= 4;
- val <<= 4;
- }
- if (!(val & 0xc000)) {
- bit -= 2;
- val <<= 2;
- }
- if (!(val & 0x8000)) {
- bit -= 1;
- val <<= 1;
- }
-
- return bit;
-}
-
-
-/*
- * Compute values to do a division using reciprocal.
- *
- * This implementation is based on an algorithm described in
- * "How to optimize for the Pentium family of microprocessors"
- * (http://www.agner.org/assem/).
- * More information about the basic algorithm can be found in
- * the paper "Integer Division Using Reciprocals" by Robert Alverson.
- *
- * The basic idea is to replace x/d by x * d^-1. In order to store
- * d^-1 with enough precision we shift it left a few places. It turns
- * out that this algoright gives just enough precision, and also fits
- * into DCTELEM:
- *
- * b = (the number of significant bits in divisor) - 1
- * r = (word size) + b
- * f = 2^r / divisor
- *
- * f will not be an integer for most cases, so we need to compensate
- * for the rounding error introduced:
- *
- * no fractional part:
- *
- * result = input >> r
- *
- * fractional part of f < 0.5:
- *
- * round f down to nearest integer
- * result = ((input + 1) * f) >> r
- *
- * fractional part of f > 0.5:
- *
- * round f up to nearest integer
- * result = (input * f) >> r
- *
- * This is the original algorithm that gives truncated results. But we
- * want properly rounded results, so we replace "input" with
- * "input + divisor/2".
- *
- * In order to allow SIMD implementations we also tweak the values to
- * allow the same calculation to be made at all times:
- *
- * dctbl[0] = f rounded to nearest integer
- * dctbl[1] = divisor / 2 (+ 1 if fractional part of f < 0.5)
- * dctbl[2] = 1 << ((word size) * 2 - r)
- * dctbl[3] = r - (word size)
- *
- * dctbl[2] is for stupid instruction sets where the shift operation
- * isn't member wise (e.g. MMX).
- *
- * The reason dctbl[2] and dctbl[3] reduce the shift with (word size)
- * is that most SIMD implementations have a "multiply and store top
- * half" operation.
- *
- * Lastly, we store each of the values in their own table instead
- * of in a consecutive manner, yet again in order to allow SIMD
- * routines.
- */
-
-LOCAL(int)
-compute_reciprocal(UINT16 divisor, DCTELEM *dtbl)
-{
- UDCTELEM2 fq, fr;
- UDCTELEM c;
- int b, r;
-
- if (divisor == 1) {
- /* divisor == 1 means unquantized, so these reciprocal/correction/shift
- * values will cause the C quantization algorithm to act like the
- * identity function. Since only the C quantization algorithm is used in
- * these cases, the scale value is irrelevant.
- */
- dtbl[DCTSIZE2 * 0] = (DCTELEM)1; /* reciprocal */
- dtbl[DCTSIZE2 * 1] = (DCTELEM)0; /* correction */
- dtbl[DCTSIZE2 * 2] = (DCTELEM)1; /* scale */
- dtbl[DCTSIZE2 * 3] = -(DCTELEM)(sizeof(DCTELEM) * 8); /* shift */
- return 0;
- }
-
- b = flss(divisor) - 1;
- r = sizeof(DCTELEM) * 8 + b;
-
- fq = ((UDCTELEM2)1 << r) / divisor;
- fr = ((UDCTELEM2)1 << r) % divisor;
-
- c = divisor / 2; /* for rounding */
-
- if (fr == 0) { /* divisor is power of two */
- /* fq will be one bit too large to fit in DCTELEM, so adjust */
- fq >>= 1;
- r--;
- } else if (fr <= (divisor / 2U)) { /* fractional part is < 0.5 */
- c++;
- } else { /* fractional part is > 0.5 */
- fq++;
- }
-
- dtbl[DCTSIZE2 * 0] = (DCTELEM)fq; /* reciprocal */
- dtbl[DCTSIZE2 * 1] = (DCTELEM)c; /* correction + roundfactor */
-#ifdef WITH_SIMD
- dtbl[DCTSIZE2 * 2] = (DCTELEM)(1 << (sizeof(DCTELEM) * 8 * 2 - r)); /* scale */
-#else
- dtbl[DCTSIZE2 * 2] = 1;
-#endif
- dtbl[DCTSIZE2 * 3] = (DCTELEM)r - sizeof(DCTELEM) * 8; /* shift */
-
- if (r <= 16) return 0;
- else return 1;
-}
-
-#endif
-
-
-/*
- * Initialize for a processing pass.
- * Verify that all referenced Q-tables are present, and set up
- * the divisor table for each one.
- * In the current implementation, DCT of all components is done during
- * the first pass, even if only some components will be output in the
- * first scan. Hence all components should be examined here.
- */
-
-METHODDEF(void)
-start_pass_fdctmgr(j_compress_ptr cinfo)
-{
- my_fdct_ptr fdct = (my_fdct_ptr)cinfo->fdct;
- int ci, qtblno, i;
- jpeg_component_info *compptr;
- JQUANT_TBL *qtbl;
- DCTELEM *dtbl;
-
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
- ci++, compptr++) {
- qtblno = compptr->quant_tbl_no;
- /* Make sure specified quantization table is present */
- if (qtblno < 0 || qtblno >= NUM_QUANT_TBLS ||
- cinfo->quant_tbl_ptrs[qtblno] == NULL)
- ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno);
- qtbl = cinfo->quant_tbl_ptrs[qtblno];
- /* Compute divisors for this quant table */
- /* We may do this more than once for same table, but it's not a big deal */
- switch (cinfo->dct_method) {
-#ifdef DCT_ISLOW_SUPPORTED
- case JDCT_ISLOW:
- /* For LL&M IDCT method, divisors are equal to raw quantization
- * coefficients multiplied by 8 (to counteract scaling).
- */
- if (fdct->divisors[qtblno] == NULL) {
- fdct->divisors[qtblno] = (DCTELEM *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- (DCTSIZE2 * 4) * sizeof(DCTELEM));
- }
- dtbl = fdct->divisors[qtblno];
- for (i = 0; i < DCTSIZE2; i++) {
-#if BITS_IN_JSAMPLE == 8
- if (!compute_reciprocal(qtbl->quantval[i] << 3, &dtbl[i]) &&
- fdct->quantize == jsimd_quantize)
- fdct->quantize = quantize;
-#else
- dtbl[i] = ((DCTELEM)qtbl->quantval[i]) << 3;
-#endif
- }
- break;
-#endif
-#ifdef DCT_IFAST_SUPPORTED
- case JDCT_IFAST:
- {
- /* For AA&N IDCT method, divisors are equal to quantization
- * coefficients scaled by scalefactor[row]*scalefactor[col], where
- * scalefactor[0] = 1
- * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7
- * We apply a further scale factor of 8.
- */
-#define CONST_BITS 14
- static const INT16 aanscales[DCTSIZE2] = {
- /* precomputed values scaled up by 14 bits */
- 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520,
- 22725, 31521, 29692, 26722, 22725, 17855, 12299, 6270,
- 21407, 29692, 27969, 25172, 21407, 16819, 11585, 5906,
- 19266, 26722, 25172, 22654, 19266, 15137, 10426, 5315,
- 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520,
- 12873, 17855, 16819, 15137, 12873, 10114, 6967, 3552,
- 8867, 12299, 11585, 10426, 8867, 6967, 4799, 2446,
- 4520, 6270, 5906, 5315, 4520, 3552, 2446, 1247
- };
- SHIFT_TEMPS
-
- if (fdct->divisors[qtblno] == NULL) {
- fdct->divisors[qtblno] = (DCTELEM *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- (DCTSIZE2 * 4) * sizeof(DCTELEM));
- }
- dtbl = fdct->divisors[qtblno];
- for (i = 0; i < DCTSIZE2; i++) {
-#if BITS_IN_JSAMPLE == 8
- if (!compute_reciprocal(
- DESCALE(MULTIPLY16V16((JLONG)qtbl->quantval[i],
- (JLONG)aanscales[i]),
- CONST_BITS - 3), &dtbl[i]) &&
- fdct->quantize == jsimd_quantize)
- fdct->quantize = quantize;
-#else
- dtbl[i] = (DCTELEM)
- DESCALE(MULTIPLY16V16((JLONG)qtbl->quantval[i],
- (JLONG)aanscales[i]),
- CONST_BITS - 3);
-#endif
- }
- }
- break;
-#endif
-#ifdef DCT_FLOAT_SUPPORTED
- case JDCT_FLOAT:
- {
- /* For float AA&N IDCT method, divisors are equal to quantization
- * coefficients scaled by scalefactor[row]*scalefactor[col], where
- * scalefactor[0] = 1
- * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7
- * We apply a further scale factor of 8.
- * What's actually stored is 1/divisor so that the inner loop can
- * use a multiplication rather than a division.
- */
- FAST_FLOAT *fdtbl;
- int row, col;
- static const double aanscalefactor[DCTSIZE] = {
- 1.0, 1.387039845, 1.306562965, 1.175875602,
- 1.0, 0.785694958, 0.541196100, 0.275899379
- };
-
- if (fdct->float_divisors[qtblno] == NULL) {
- fdct->float_divisors[qtblno] = (FAST_FLOAT *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- DCTSIZE2 * sizeof(FAST_FLOAT));
- }
- fdtbl = fdct->float_divisors[qtblno];
- i = 0;
- for (row = 0; row < DCTSIZE; row++) {
- for (col = 0; col < DCTSIZE; col++) {
- fdtbl[i] = (FAST_FLOAT)
- (1.0 / (((double)qtbl->quantval[i] *
- aanscalefactor[row] * aanscalefactor[col] * 8.0)));
- i++;
- }
- }
- }
- break;
-#endif
- default:
- ERREXIT(cinfo, JERR_NOT_COMPILED);
- break;
- }
- }
-}
-
-
-/*
- * Load data into workspace, applying unsigned->signed conversion.
- */
-
-METHODDEF(void)
-convsamp(JSAMPARRAY sample_data, JDIMENSION start_col, DCTELEM *workspace)
-{
- register DCTELEM *workspaceptr;
- register JSAMPROW elemptr;
- register int elemr;
-
- workspaceptr = workspace;
- for (elemr = 0; elemr < DCTSIZE; elemr++) {
- elemptr = sample_data[elemr] + start_col;
-
-#if DCTSIZE == 8 /* unroll the inner loop */
- *workspaceptr++ = (*elemptr++) - CENTERJSAMPLE;
- *workspaceptr++ = (*elemptr++) - CENTERJSAMPLE;
- *workspaceptr++ = (*elemptr++) - CENTERJSAMPLE;
- *workspaceptr++ = (*elemptr++) - CENTERJSAMPLE;
- *workspaceptr++ = (*elemptr++) - CENTERJSAMPLE;
- *workspaceptr++ = (*elemptr++) - CENTERJSAMPLE;
- *workspaceptr++ = (*elemptr++) - CENTERJSAMPLE;
- *workspaceptr++ = (*elemptr++) - CENTERJSAMPLE;
-#else
- {
- register int elemc;
- for (elemc = DCTSIZE; elemc > 0; elemc--)
- *workspaceptr++ = (*elemptr++) - CENTERJSAMPLE;
- }
-#endif
- }
-}
-
-
-/*
- * Quantize/descale the coefficients, and store into coef_blocks[].
- */
-
-METHODDEF(void)
-quantize(JCOEFPTR coef_block, DCTELEM *divisors, DCTELEM *workspace)
-{
- int i;
- DCTELEM temp;
- JCOEFPTR output_ptr = coef_block;
-
-#if BITS_IN_JSAMPLE == 8
-
- UDCTELEM recip, corr;
- int shift;
- UDCTELEM2 product;
-
- for (i = 0; i < DCTSIZE2; i++) {
- temp = workspace[i];
- recip = divisors[i + DCTSIZE2 * 0];
- corr = divisors[i + DCTSIZE2 * 1];
- shift = divisors[i + DCTSIZE2 * 3];
-
- if (temp < 0) {
- temp = -temp;
- product = (UDCTELEM2)(temp + corr) * recip;
- product >>= shift + sizeof(DCTELEM) * 8;
- temp = (DCTELEM)product;
- temp = -temp;
- } else {
- product = (UDCTELEM2)(temp + corr) * recip;
- product >>= shift + sizeof(DCTELEM) * 8;
- temp = (DCTELEM)product;
- }
- output_ptr[i] = (JCOEF)temp;
- }
-
-#else
-
- register DCTELEM qval;
-
- for (i = 0; i < DCTSIZE2; i++) {
- qval = divisors[i];
- temp = workspace[i];
- /* Divide the coefficient value by qval, ensuring proper rounding.
- * Since C does not specify the direction of rounding for negative
- * quotients, we have to force the dividend positive for portability.
- *
- * In most files, at least half of the output values will be zero
- * (at default quantization settings, more like three-quarters...)
- * so we should ensure that this case is fast. On many machines,
- * a comparison is enough cheaper than a divide to make a special test
- * a win. Since both inputs will be nonnegative, we need only test
- * for a < b to discover whether a/b is 0.
- * If your machine's division is fast enough, define FAST_DIVIDE.
- */
-#ifdef FAST_DIVIDE
-#define DIVIDE_BY(a, b) a /= b
-#else
-#define DIVIDE_BY(a, b) if (a >= b) a /= b; else a = 0
-#endif
- if (temp < 0) {
- temp = -temp;
- temp += qval >> 1; /* for rounding */
- DIVIDE_BY(temp, qval);
- temp = -temp;
- } else {
- temp += qval >> 1; /* for rounding */
- DIVIDE_BY(temp, qval);
- }
- output_ptr[i] = (JCOEF)temp;
- }
-
-#endif
-
-}
-
-
-/*
- * Perform forward DCT on one or more blocks of a component.
- *
- * The input samples are taken from the sample_data[] array starting at
- * position start_row/start_col, and moving to the right for any additional
- * blocks. The quantized coefficients are returned in coef_blocks[].
- */
-
-METHODDEF(void)
-forward_DCT(j_compress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
- JDIMENSION start_row, JDIMENSION start_col, JDIMENSION num_blocks)
-/* This version is used for integer DCT implementations. */
-{
- /* This routine is heavily used, so it's worth coding it tightly. */
- my_fdct_ptr fdct = (my_fdct_ptr)cinfo->fdct;
- DCTELEM *divisors = fdct->divisors[compptr->quant_tbl_no];
- DCTELEM *workspace;
- JDIMENSION bi;
-
- /* Make sure the compiler doesn't look up these every pass */
- forward_DCT_method_ptr do_dct = fdct->dct;
- convsamp_method_ptr do_convsamp = fdct->convsamp;
- quantize_method_ptr do_quantize = fdct->quantize;
- workspace = fdct->workspace;
-
- sample_data += start_row; /* fold in the vertical offset once */
-
- for (bi = 0; bi < num_blocks; bi++, start_col += DCTSIZE) {
- /* Load data into workspace, applying unsigned->signed conversion */
- (*do_convsamp) (sample_data, start_col, workspace);
-
- /* Perform the DCT */
- (*do_dct) (workspace);
-
- /* Quantize/descale the coefficients, and store into coef_blocks[] */
- (*do_quantize) (coef_blocks[bi], divisors, workspace);
- }
-}
-
-
-#ifdef DCT_FLOAT_SUPPORTED
-
-METHODDEF(void)
-convsamp_float(JSAMPARRAY sample_data, JDIMENSION start_col,
- FAST_FLOAT *workspace)
-{
- register FAST_FLOAT *workspaceptr;
- register JSAMPROW elemptr;
- register int elemr;
-
- workspaceptr = workspace;
- for (elemr = 0; elemr < DCTSIZE; elemr++) {
- elemptr = sample_data[elemr] + start_col;
-#if DCTSIZE == 8 /* unroll the inner loop */
- *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - CENTERJSAMPLE);
- *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - CENTERJSAMPLE);
- *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - CENTERJSAMPLE);
- *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - CENTERJSAMPLE);
- *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - CENTERJSAMPLE);
- *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - CENTERJSAMPLE);
- *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - CENTERJSAMPLE);
- *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - CENTERJSAMPLE);
-#else
- {
- register int elemc;
- for (elemc = DCTSIZE; elemc > 0; elemc--)
- *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - CENTERJSAMPLE);
- }
-#endif
- }
-}
-
-
-METHODDEF(void)
-quantize_float(JCOEFPTR coef_block, FAST_FLOAT *divisors,
- FAST_FLOAT *workspace)
-{
- register FAST_FLOAT temp;
- register int i;
- register JCOEFPTR output_ptr = coef_block;
-
- for (i = 0; i < DCTSIZE2; i++) {
- /* Apply the quantization and scaling factor */
- temp = workspace[i] * divisors[i];
-
- /* Round to nearest integer.
- * Since C does not specify the direction of rounding for negative
- * quotients, we have to force the dividend positive for portability.
- * The maximum coefficient size is +-16K (for 12-bit data), so this
- * code should work for either 16-bit or 32-bit ints.
- */
- output_ptr[i] = (JCOEF)((int)(temp + (FAST_FLOAT)16384.5) - 16384);
- }
-}
-
-
-METHODDEF(void)
-forward_DCT_float(j_compress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
- JDIMENSION start_row, JDIMENSION start_col,
- JDIMENSION num_blocks)
-/* This version is used for floating-point DCT implementations. */
-{
- /* This routine is heavily used, so it's worth coding it tightly. */
- my_fdct_ptr fdct = (my_fdct_ptr)cinfo->fdct;
- FAST_FLOAT *divisors = fdct->float_divisors[compptr->quant_tbl_no];
- FAST_FLOAT *workspace;
- JDIMENSION bi;
-
-
- /* Make sure the compiler doesn't look up these every pass */
- float_DCT_method_ptr do_dct = fdct->float_dct;
- float_convsamp_method_ptr do_convsamp = fdct->float_convsamp;
- float_quantize_method_ptr do_quantize = fdct->float_quantize;
- workspace = fdct->float_workspace;
-
- sample_data += start_row; /* fold in the vertical offset once */
-
- for (bi = 0; bi < num_blocks; bi++, start_col += DCTSIZE) {
- /* Load data into workspace, applying unsigned->signed conversion */
- (*do_convsamp) (sample_data, start_col, workspace);
-
- /* Perform the DCT */
- (*do_dct) (workspace);
-
- /* Quantize/descale the coefficients, and store into coef_blocks[] */
- (*do_quantize) (coef_blocks[bi], divisors, workspace);
- }
-}
-
-#endif /* DCT_FLOAT_SUPPORTED */
-
-
-/*
- * Initialize FDCT manager.
- */
-
-GLOBAL(void)
-jinit_forward_dct(j_compress_ptr cinfo)
-{
- my_fdct_ptr fdct;
- int i;
-
- fdct = (my_fdct_ptr)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- sizeof(my_fdct_controller));
- cinfo->fdct = (struct jpeg_forward_dct *)fdct;
- fdct->pub.start_pass = start_pass_fdctmgr;
-
- /* First determine the DCT... */
- switch (cinfo->dct_method) {
-#ifdef DCT_ISLOW_SUPPORTED
- case JDCT_ISLOW:
- fdct->pub.forward_DCT = forward_DCT;
- if (jsimd_can_fdct_islow())
- fdct->dct = jsimd_fdct_islow;
- else
- fdct->dct = jpeg_fdct_islow;
- break;
-#endif
-#ifdef DCT_IFAST_SUPPORTED
- case JDCT_IFAST:
- fdct->pub.forward_DCT = forward_DCT;
- if (jsimd_can_fdct_ifast())
- fdct->dct = jsimd_fdct_ifast;
- else
- fdct->dct = jpeg_fdct_ifast;
- break;
-#endif
-#ifdef DCT_FLOAT_SUPPORTED
- case JDCT_FLOAT:
- fdct->pub.forward_DCT = forward_DCT_float;
- if (jsimd_can_fdct_float())
- fdct->float_dct = jsimd_fdct_float;
- else
- fdct->float_dct = jpeg_fdct_float;
- break;
-#endif
- default:
- ERREXIT(cinfo, JERR_NOT_COMPILED);
- break;
- }
-
- /* ...then the supporting stages. */
- switch (cinfo->dct_method) {
-#ifdef DCT_ISLOW_SUPPORTED
- case JDCT_ISLOW:
-#endif
-#ifdef DCT_IFAST_SUPPORTED
- case JDCT_IFAST:
-#endif
-#if defined(DCT_ISLOW_SUPPORTED) || defined(DCT_IFAST_SUPPORTED)
- if (jsimd_can_convsamp())
- fdct->convsamp = jsimd_convsamp;
- else
- fdct->convsamp = convsamp;
- if (jsimd_can_quantize())
- fdct->quantize = jsimd_quantize;
- else
- fdct->quantize = quantize;
- break;
-#endif
-#ifdef DCT_FLOAT_SUPPORTED
- case JDCT_FLOAT:
- if (jsimd_can_convsamp_float())
- fdct->float_convsamp = jsimd_convsamp_float;
- else
- fdct->float_convsamp = convsamp_float;
- if (jsimd_can_quantize_float())
- fdct->float_quantize = jsimd_quantize_float;
- else
- fdct->float_quantize = quantize_float;
- break;
-#endif
- default:
- ERREXIT(cinfo, JERR_NOT_COMPILED);
- break;
- }
-
- /* Allocate workspace memory */
-#ifdef DCT_FLOAT_SUPPORTED
- if (cinfo->dct_method == JDCT_FLOAT)
- fdct->float_workspace = (FAST_FLOAT *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- sizeof(FAST_FLOAT) * DCTSIZE2);
- else
-#endif
- fdct->workspace = (DCTELEM *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- sizeof(DCTELEM) * DCTSIZE2);
-
- /* Mark divisor tables unallocated */
- for (i = 0; i < NUM_QUANT_TBLS; i++) {
- fdct->divisors[i] = NULL;
-#ifdef DCT_FLOAT_SUPPORTED
- fdct->float_divisors[i] = NULL;
-#endif
- }
-}
diff --git a/contrib/libs/libjpeg-turbo/jchuff.c b/contrib/libs/libjpeg-turbo/jchuff.c
deleted file mode 100644
index f4dfa1cb54..0000000000
--- a/contrib/libs/libjpeg-turbo/jchuff.c
+++ /dev/null
@@ -1,1137 +0,0 @@
-/*
- * jchuff.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2009-2011, 2014-2016, 2018-2022, D. R. Commander.
- * Copyright (C) 2015, Matthieu Darbois.
- * Copyright (C) 2018, Matthias Räncker.
- * Copyright (C) 2020, Arm Limited.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains Huffman entropy encoding routines.
- *
- * Much of the complexity here has to do with supporting output suspension.
- * If the data destination module demands suspension, we want to be able to
- * back up to the start of the current MCU. To do this, we copy state
- * variables into local working storage, and update them back to the
- * permanent JPEG objects only upon successful completion of an MCU.
- *
- * NOTE: All referenced figures are from
- * Recommendation ITU-T T.81 (1992) | ISO/IEC 10918-1:1994.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-#include "jsimd.h"
-#include "jconfigint.h"
-#include <limits.h>
-
-/*
- * NOTE: If USE_CLZ_INTRINSIC is defined, then clz/bsr instructions will be
- * used for bit counting rather than the lookup table. This will reduce the
- * memory footprint by 64k, which is important for some mobile applications
- * that create many isolated instances of libjpeg-turbo (web browsers, for
- * instance.) This may improve performance on some mobile platforms as well.
- * This feature is enabled by default only on Arm processors, because some x86
- * chips have a slow implementation of bsr, and the use of clz/bsr cannot be
- * shown to have a significant performance impact even on the x86 chips that
- * have a fast implementation of it. When building for Armv6, you can
- * explicitly disable the use of clz/bsr by adding -mthumb to the compiler
- * flags (this defines __thumb__).
- */
-
-/* NOTE: Both GCC and Clang define __GNUC__ */
-#if (defined(__GNUC__) && (defined(__arm__) || defined(__aarch64__))) || \
- defined(_M_ARM) || defined(_M_ARM64)
-#if !defined(__thumb__) || defined(__thumb2__)
-#define USE_CLZ_INTRINSIC
-#endif
-#endif
-
-#ifdef USE_CLZ_INTRINSIC
-#if defined(_MSC_VER) && !defined(__clang__)
-#define JPEG_NBITS_NONZERO(x) (32 - _CountLeadingZeros(x))
-#else
-#define JPEG_NBITS_NONZERO(x) (32 - __builtin_clz(x))
-#endif
-#define JPEG_NBITS(x) (x ? JPEG_NBITS_NONZERO(x) : 0)
-#else
-#include "jpeg_nbits_table.h"
-#define JPEG_NBITS(x) (jpeg_nbits_table[x])
-#define JPEG_NBITS_NONZERO(x) JPEG_NBITS(x)
-#endif
-
-
-/* Expanded entropy encoder object for Huffman encoding.
- *
- * The savable_state subrecord contains fields that change within an MCU,
- * but must not be updated permanently until we complete the MCU.
- */
-
-#if defined(__x86_64__) && defined(__ILP32__)
-typedef unsigned long long bit_buf_type;
-#else
-typedef size_t bit_buf_type;
-#endif
-
-/* NOTE: The more optimal Huffman encoding algorithm is only used by the
- * intrinsics implementation of the Arm Neon SIMD extensions, which is why we
- * retain the old Huffman encoder behavior when using the GAS implementation.
- */
-#if defined(WITH_SIMD) && !(defined(__arm__) || defined(__aarch64__) || \
- defined(_M_ARM) || defined(_M_ARM64))
-typedef unsigned long long simd_bit_buf_type;
-#else
-typedef bit_buf_type simd_bit_buf_type;
-#endif
-
-#if (defined(SIZEOF_SIZE_T) && SIZEOF_SIZE_T == 8) || defined(_WIN64) || \
- (defined(__x86_64__) && defined(__ILP32__))
-#define BIT_BUF_SIZE 64
-#elif (defined(SIZEOF_SIZE_T) && SIZEOF_SIZE_T == 4) || defined(_WIN32)
-#define BIT_BUF_SIZE 32
-#else
-#error Cannot determine word size
-#endif
-#define SIMD_BIT_BUF_SIZE (sizeof(simd_bit_buf_type) * 8)
-
-typedef struct {
- union {
- bit_buf_type c;
- simd_bit_buf_type simd;
- } put_buffer; /* current bit accumulation buffer */
- int free_bits; /* # of bits available in it */
- /* (Neon GAS: # of bits now in it) */
- int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */
-} savable_state;
-
-typedef struct {
- struct jpeg_entropy_encoder pub; /* public fields */
-
- savable_state saved; /* Bit buffer & DC state at start of MCU */
-
- /* These fields are NOT loaded into local working state. */
- unsigned int restarts_to_go; /* MCUs left in this restart interval */
- int next_restart_num; /* next restart number to write (0-7) */
-
- /* Pointers to derived tables (these workspaces have image lifespan) */
- c_derived_tbl *dc_derived_tbls[NUM_HUFF_TBLS];
- c_derived_tbl *ac_derived_tbls[NUM_HUFF_TBLS];
-
-#ifdef ENTROPY_OPT_SUPPORTED /* Statistics tables for optimization */
- long *dc_count_ptrs[NUM_HUFF_TBLS];
- long *ac_count_ptrs[NUM_HUFF_TBLS];
-#endif
-
- int simd;
-} huff_entropy_encoder;
-
-typedef huff_entropy_encoder *huff_entropy_ptr;
-
-/* Working state while writing an MCU.
- * This struct contains all the fields that are needed by subroutines.
- */
-
-typedef struct {
- JOCTET *next_output_byte; /* => next byte to write in buffer */
- size_t free_in_buffer; /* # of byte spaces remaining in buffer */
- savable_state cur; /* Current bit buffer & DC state */
- j_compress_ptr cinfo; /* dump_buffer needs access to this */
- int simd;
-} working_state;
-
-
-/* Forward declarations */
-METHODDEF(boolean) encode_mcu_huff(j_compress_ptr cinfo, JBLOCKROW *MCU_data);
-METHODDEF(void) finish_pass_huff(j_compress_ptr cinfo);
-#ifdef ENTROPY_OPT_SUPPORTED
-METHODDEF(boolean) encode_mcu_gather(j_compress_ptr cinfo,
- JBLOCKROW *MCU_data);
-METHODDEF(void) finish_pass_gather(j_compress_ptr cinfo);
-#endif
-
-
-/*
- * Initialize for a Huffman-compressed scan.
- * If gather_statistics is TRUE, we do not output anything during the scan,
- * just count the Huffman symbols used and generate Huffman code tables.
- */
-
-METHODDEF(void)
-start_pass_huff(j_compress_ptr cinfo, boolean gather_statistics)
-{
- huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
- int ci, dctbl, actbl;
- jpeg_component_info *compptr;
-
- if (gather_statistics) {
-#ifdef ENTROPY_OPT_SUPPORTED
- entropy->pub.encode_mcu = encode_mcu_gather;
- entropy->pub.finish_pass = finish_pass_gather;
-#else
- ERREXIT(cinfo, JERR_NOT_COMPILED);
-#endif
- } else {
- entropy->pub.encode_mcu = encode_mcu_huff;
- entropy->pub.finish_pass = finish_pass_huff;
- }
-
- entropy->simd = jsimd_can_huff_encode_one_block();
-
- for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
- compptr = cinfo->cur_comp_info[ci];
- dctbl = compptr->dc_tbl_no;
- actbl = compptr->ac_tbl_no;
- if (gather_statistics) {
-#ifdef ENTROPY_OPT_SUPPORTED
- /* Check for invalid table indexes */
- /* (make_c_derived_tbl does this in the other path) */
- if (dctbl < 0 || dctbl >= NUM_HUFF_TBLS)
- ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, dctbl);
- if (actbl < 0 || actbl >= NUM_HUFF_TBLS)
- ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, actbl);
- /* Allocate and zero the statistics tables */
- /* Note that jpeg_gen_optimal_table expects 257 entries in each table! */
- if (entropy->dc_count_ptrs[dctbl] == NULL)
- entropy->dc_count_ptrs[dctbl] = (long *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- 257 * sizeof(long));
- memset(entropy->dc_count_ptrs[dctbl], 0, 257 * sizeof(long));
- if (entropy->ac_count_ptrs[actbl] == NULL)
- entropy->ac_count_ptrs[actbl] = (long *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- 257 * sizeof(long));
- memset(entropy->ac_count_ptrs[actbl], 0, 257 * sizeof(long));
-#endif
- } else {
- /* Compute derived values for Huffman tables */
- /* We may do this more than once for a table, but it's not expensive */
- jpeg_make_c_derived_tbl(cinfo, TRUE, dctbl,
- &entropy->dc_derived_tbls[dctbl]);
- jpeg_make_c_derived_tbl(cinfo, FALSE, actbl,
- &entropy->ac_derived_tbls[actbl]);
- }
- /* Initialize DC predictions to 0 */
- entropy->saved.last_dc_val[ci] = 0;
- }
-
- /* Initialize bit buffer to empty */
- if (entropy->simd) {
- entropy->saved.put_buffer.simd = 0;
-#if defined(__aarch64__) && !defined(NEON_INTRINSICS)
- entropy->saved.free_bits = 0;
-#else
- entropy->saved.free_bits = SIMD_BIT_BUF_SIZE;
-#endif
- } else {
- entropy->saved.put_buffer.c = 0;
- entropy->saved.free_bits = BIT_BUF_SIZE;
- }
-
- /* Initialize restart stuff */
- entropy->restarts_to_go = cinfo->restart_interval;
- entropy->next_restart_num = 0;
-}
-
-
-/*
- * Compute the derived values for a Huffman table.
- * This routine also performs some validation checks on the table.
- *
- * Note this is also used by jcphuff.c.
- */
-
-GLOBAL(void)
-jpeg_make_c_derived_tbl(j_compress_ptr cinfo, boolean isDC, int tblno,
- c_derived_tbl **pdtbl)
-{
- JHUFF_TBL *htbl;
- c_derived_tbl *dtbl;
- int p, i, l, lastp, si, maxsymbol;
- char huffsize[257];
- unsigned int huffcode[257];
- unsigned int code;
-
- /* Note that huffsize[] and huffcode[] are filled in code-length order,
- * paralleling the order of the symbols themselves in htbl->huffval[].
- */
-
- /* Find the input Huffman table */
- if (tblno < 0 || tblno >= NUM_HUFF_TBLS)
- ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno);
- htbl =
- isDC ? cinfo->dc_huff_tbl_ptrs[tblno] : cinfo->ac_huff_tbl_ptrs[tblno];
- if (htbl == NULL)
- ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno);
-
- /* Allocate a workspace if we haven't already done so. */
- if (*pdtbl == NULL)
- *pdtbl = (c_derived_tbl *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- sizeof(c_derived_tbl));
- dtbl = *pdtbl;
-
- /* Figure C.1: make table of Huffman code length for each symbol */
-
- p = 0;
- for (l = 1; l <= 16; l++) {
- i = (int)htbl->bits[l];
- if (i < 0 || p + i > 256) /* protect against table overrun */
- ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
- while (i--)
- huffsize[p++] = (char)l;
- }
- huffsize[p] = 0;
- lastp = p;
-
- /* Figure C.2: generate the codes themselves */
- /* We also validate that the counts represent a legal Huffman code tree. */
-
- code = 0;
- si = huffsize[0];
- p = 0;
- while (huffsize[p]) {
- while (((int)huffsize[p]) == si) {
- huffcode[p++] = code;
- code++;
- }
- /* code is now 1 more than the last code used for codelength si; but
- * it must still fit in si bits, since no code is allowed to be all ones.
- */
- if (((JLONG)code) >= (((JLONG)1) << si))
- ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
- code <<= 1;
- si++;
- }
-
- /* Figure C.3: generate encoding tables */
- /* These are code and size indexed by symbol value */
-
- /* Set all codeless symbols to have code length 0;
- * this lets us detect duplicate VAL entries here, and later
- * allows emit_bits to detect any attempt to emit such symbols.
- */
- memset(dtbl->ehufco, 0, sizeof(dtbl->ehufco));
- memset(dtbl->ehufsi, 0, sizeof(dtbl->ehufsi));
-
- /* This is also a convenient place to check for out-of-range
- * and duplicated VAL entries. We allow 0..255 for AC symbols
- * but only 0..15 for DC. (We could constrain them further
- * based on data depth and mode, but this seems enough.)
- */
- maxsymbol = isDC ? 15 : 255;
-
- for (p = 0; p < lastp; p++) {
- i = htbl->huffval[p];
- if (i < 0 || i > maxsymbol || dtbl->ehufsi[i])
- ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
- dtbl->ehufco[i] = huffcode[p];
- dtbl->ehufsi[i] = huffsize[p];
- }
-}
-
-
-/* Outputting bytes to the file */
-
-/* Emit a byte, taking 'action' if must suspend. */
-#define emit_byte(state, val, action) { \
- *(state)->next_output_byte++ = (JOCTET)(val); \
- if (--(state)->free_in_buffer == 0) \
- if (!dump_buffer(state)) \
- { action; } \
-}
-
-
-LOCAL(boolean)
-dump_buffer(working_state *state)
-/* Empty the output buffer; return TRUE if successful, FALSE if must suspend */
-{
- struct jpeg_destination_mgr *dest = state->cinfo->dest;
-
- if (!(*dest->empty_output_buffer) (state->cinfo))
- return FALSE;
- /* After a successful buffer dump, must reset buffer pointers */
- state->next_output_byte = dest->next_output_byte;
- state->free_in_buffer = dest->free_in_buffer;
- return TRUE;
-}
-
-
-/* Outputting bits to the file */
-
-/* Output byte b and, speculatively, an additional 0 byte. 0xFF must be
- * encoded as 0xFF 0x00, so the output buffer pointer is advanced by 2 if the
- * byte is 0xFF. Otherwise, the output buffer pointer is advanced by 1, and
- * the speculative 0 byte will be overwritten by the next byte.
- */
-#define EMIT_BYTE(b) { \
- buffer[0] = (JOCTET)(b); \
- buffer[1] = 0; \
- buffer -= -2 + ((JOCTET)(b) < 0xFF); \
-}
-
-/* Output the entire bit buffer. If there are no 0xFF bytes in it, then write
- * directly to the output buffer. Otherwise, use the EMIT_BYTE() macro to
- * encode 0xFF as 0xFF 0x00.
- */
-#if BIT_BUF_SIZE == 64
-
-#define FLUSH() { \
- if (put_buffer & 0x8080808080808080 & ~(put_buffer + 0x0101010101010101)) { \
- EMIT_BYTE(put_buffer >> 56) \
- EMIT_BYTE(put_buffer >> 48) \
- EMIT_BYTE(put_buffer >> 40) \
- EMIT_BYTE(put_buffer >> 32) \
- EMIT_BYTE(put_buffer >> 24) \
- EMIT_BYTE(put_buffer >> 16) \
- EMIT_BYTE(put_buffer >> 8) \
- EMIT_BYTE(put_buffer ) \
- } else { \
- buffer[0] = (JOCTET)(put_buffer >> 56); \
- buffer[1] = (JOCTET)(put_buffer >> 48); \
- buffer[2] = (JOCTET)(put_buffer >> 40); \
- buffer[3] = (JOCTET)(put_buffer >> 32); \
- buffer[4] = (JOCTET)(put_buffer >> 24); \
- buffer[5] = (JOCTET)(put_buffer >> 16); \
- buffer[6] = (JOCTET)(put_buffer >> 8); \
- buffer[7] = (JOCTET)(put_buffer); \
- buffer += 8; \
- } \
-}
-
-#else
-
-#define FLUSH() { \
- if (put_buffer & 0x80808080 & ~(put_buffer + 0x01010101)) { \
- EMIT_BYTE(put_buffer >> 24) \
- EMIT_BYTE(put_buffer >> 16) \
- EMIT_BYTE(put_buffer >> 8) \
- EMIT_BYTE(put_buffer ) \
- } else { \
- buffer[0] = (JOCTET)(put_buffer >> 24); \
- buffer[1] = (JOCTET)(put_buffer >> 16); \
- buffer[2] = (JOCTET)(put_buffer >> 8); \
- buffer[3] = (JOCTET)(put_buffer); \
- buffer += 4; \
- } \
-}
-
-#endif
-
-/* Fill the bit buffer to capacity with the leading bits from code, then output
- * the bit buffer and put the remaining bits from code into the bit buffer.
- */
-#define PUT_AND_FLUSH(code, size) { \
- put_buffer = (put_buffer << (size + free_bits)) | (code >> -free_bits); \
- FLUSH() \
- free_bits += BIT_BUF_SIZE; \
- put_buffer = code; \
-}
-
-/* Insert code into the bit buffer and output the bit buffer if needed.
- * NOTE: We can't flush with free_bits == 0, since the left shift in
- * PUT_AND_FLUSH() would have undefined behavior.
- */
-#define PUT_BITS(code, size) { \
- free_bits -= size; \
- if (free_bits < 0) \
- PUT_AND_FLUSH(code, size) \
- else \
- put_buffer = (put_buffer << size) | code; \
-}
-
-#define PUT_CODE(code, size) { \
- temp &= (((JLONG)1) << nbits) - 1; \
- temp |= code << nbits; \
- nbits += size; \
- PUT_BITS(temp, nbits) \
-}
-
-
-/* Although it is exceedingly rare, it is possible for a Huffman-encoded
- * coefficient block to be larger than the 128-byte unencoded block. For each
- * of the 64 coefficients, PUT_BITS is invoked twice, and each invocation can
- * theoretically store 16 bits (for a maximum of 2048 bits or 256 bytes per
- * encoded block.) If, for instance, one artificially sets the AC
- * coefficients to alternating values of 32767 and -32768 (using the JPEG
- * scanning order-- 1, 8, 16, etc.), then this will produce an encoded block
- * larger than 200 bytes.
- */
-#define BUFSIZE (DCTSIZE2 * 8)
-
-#define LOAD_BUFFER() { \
- if (state->free_in_buffer < BUFSIZE) { \
- localbuf = 1; \
- buffer = _buffer; \
- } else \
- buffer = state->next_output_byte; \
-}
-
-#define STORE_BUFFER() { \
- if (localbuf) { \
- size_t bytes, bytestocopy; \
- bytes = buffer - _buffer; \
- buffer = _buffer; \
- while (bytes > 0) { \
- bytestocopy = MIN(bytes, state->free_in_buffer); \
- memcpy(state->next_output_byte, buffer, bytestocopy); \
- state->next_output_byte += bytestocopy; \
- buffer += bytestocopy; \
- state->free_in_buffer -= bytestocopy; \
- if (state->free_in_buffer == 0) \
- if (!dump_buffer(state)) return FALSE; \
- bytes -= bytestocopy; \
- } \
- } else { \
- state->free_in_buffer -= (buffer - state->next_output_byte); \
- state->next_output_byte = buffer; \
- } \
-}
-
-
-LOCAL(boolean)
-flush_bits(working_state *state)
-{
- JOCTET _buffer[BUFSIZE], *buffer, temp;
- simd_bit_buf_type put_buffer; int put_bits;
- int localbuf = 0;
-
- if (state->simd) {
-#if defined(__aarch64__) && !defined(NEON_INTRINSICS)
- put_bits = state->cur.free_bits;
-#else
- put_bits = SIMD_BIT_BUF_SIZE - state->cur.free_bits;
-#endif
- put_buffer = state->cur.put_buffer.simd;
- } else {
- put_bits = BIT_BUF_SIZE - state->cur.free_bits;
- put_buffer = state->cur.put_buffer.c;
- }
-
- LOAD_BUFFER()
-
- while (put_bits >= 8) {
- put_bits -= 8;
- temp = (JOCTET)(put_buffer >> put_bits);
- EMIT_BYTE(temp)
- }
- if (put_bits) {
- /* fill partial byte with ones */
- temp = (JOCTET)((put_buffer << (8 - put_bits)) | (0xFF >> put_bits));
- EMIT_BYTE(temp)
- }
-
- if (state->simd) { /* and reset bit buffer to empty */
- state->cur.put_buffer.simd = 0;
-#if defined(__aarch64__) && !defined(NEON_INTRINSICS)
- state->cur.free_bits = 0;
-#else
- state->cur.free_bits = SIMD_BIT_BUF_SIZE;
-#endif
- } else {
- state->cur.put_buffer.c = 0;
- state->cur.free_bits = BIT_BUF_SIZE;
- }
- STORE_BUFFER()
-
- return TRUE;
-}
-
-
-/* Encode a single block's worth of coefficients */
-
-LOCAL(boolean)
-encode_one_block_simd(working_state *state, JCOEFPTR block, int last_dc_val,
- c_derived_tbl *dctbl, c_derived_tbl *actbl)
-{
- JOCTET _buffer[BUFSIZE], *buffer;
- int localbuf = 0;
-
- LOAD_BUFFER()
-
- buffer = jsimd_huff_encode_one_block(state, buffer, block, last_dc_val,
- dctbl, actbl);
-
- STORE_BUFFER()
-
- return TRUE;
-}
-
-LOCAL(boolean)
-encode_one_block(working_state *state, JCOEFPTR block, int last_dc_val,
- c_derived_tbl *dctbl, c_derived_tbl *actbl)
-{
- int temp, nbits, free_bits;
- bit_buf_type put_buffer;
- JOCTET _buffer[BUFSIZE], *buffer;
- int localbuf = 0;
-
- free_bits = state->cur.free_bits;
- put_buffer = state->cur.put_buffer.c;
- LOAD_BUFFER()
-
- /* Encode the DC coefficient difference per section F.1.2.1 */
-
- temp = block[0] - last_dc_val;
-
- /* This is a well-known technique for obtaining the absolute value without a
- * branch. It is derived from an assembly language technique presented in
- * "How to Optimize for the Pentium Processors", Copyright (c) 1996, 1997 by
- * Agner Fog. This code assumes we are on a two's complement machine.
- */
- nbits = temp >> (CHAR_BIT * sizeof(int) - 1);
- temp += nbits;
- nbits ^= temp;
-
- /* Find the number of bits needed for the magnitude of the coefficient */
- nbits = JPEG_NBITS(nbits);
-
- /* Emit the Huffman-coded symbol for the number of bits.
- * Emit that number of bits of the value, if positive,
- * or the complement of its magnitude, if negative.
- */
- PUT_CODE(dctbl->ehufco[nbits], dctbl->ehufsi[nbits])
-
- /* Encode the AC coefficients per section F.1.2.2 */
-
- {
- int r = 0; /* r = run length of zeros */
-
-/* Manually unroll the k loop to eliminate the counter variable. This
- * improves performance greatly on systems with a limited number of
- * registers (such as x86.)
- */
-#define kloop(jpeg_natural_order_of_k) { \
- if ((temp = block[jpeg_natural_order_of_k]) == 0) { \
- r += 16; \
- } else { \
- /* Branch-less absolute value, bitwise complement, etc., same as above */ \
- nbits = temp >> (CHAR_BIT * sizeof(int) - 1); \
- temp += nbits; \
- nbits ^= temp; \
- nbits = JPEG_NBITS_NONZERO(nbits); \
- /* if run length > 15, must emit special run-length-16 codes (0xF0) */ \
- while (r >= 16 * 16) { \
- r -= 16 * 16; \
- PUT_BITS(actbl->ehufco[0xf0], actbl->ehufsi[0xf0]) \
- } \
- /* Emit Huffman symbol for run length / number of bits */ \
- r += nbits; \
- PUT_CODE(actbl->ehufco[r], actbl->ehufsi[r]) \
- r = 0; \
- } \
-}
-
- /* One iteration for each value in jpeg_natural_order[] */
- kloop(1); kloop(8); kloop(16); kloop(9); kloop(2); kloop(3);
- kloop(10); kloop(17); kloop(24); kloop(32); kloop(25); kloop(18);
- kloop(11); kloop(4); kloop(5); kloop(12); kloop(19); kloop(26);
- kloop(33); kloop(40); kloop(48); kloop(41); kloop(34); kloop(27);
- kloop(20); kloop(13); kloop(6); kloop(7); kloop(14); kloop(21);
- kloop(28); kloop(35); kloop(42); kloop(49); kloop(56); kloop(57);
- kloop(50); kloop(43); kloop(36); kloop(29); kloop(22); kloop(15);
- kloop(23); kloop(30); kloop(37); kloop(44); kloop(51); kloop(58);
- kloop(59); kloop(52); kloop(45); kloop(38); kloop(31); kloop(39);
- kloop(46); kloop(53); kloop(60); kloop(61); kloop(54); kloop(47);
- kloop(55); kloop(62); kloop(63);
-
- /* If the last coef(s) were zero, emit an end-of-block code */
- if (r > 0) {
- PUT_BITS(actbl->ehufco[0], actbl->ehufsi[0])
- }
- }
-
- state->cur.put_buffer.c = put_buffer;
- state->cur.free_bits = free_bits;
- STORE_BUFFER()
-
- return TRUE;
-}
-
-
-/*
- * Emit a restart marker & resynchronize predictions.
- */
-
-LOCAL(boolean)
-emit_restart(working_state *state, int restart_num)
-{
- int ci;
-
- if (!flush_bits(state))
- return FALSE;
-
- emit_byte(state, 0xFF, return FALSE);
- emit_byte(state, JPEG_RST0 + restart_num, return FALSE);
-
- /* Re-initialize DC predictions to 0 */
- for (ci = 0; ci < state->cinfo->comps_in_scan; ci++)
- state->cur.last_dc_val[ci] = 0;
-
- /* The restart counter is not updated until we successfully write the MCU. */
-
- return TRUE;
-}
-
-
-/*
- * Encode and output one MCU's worth of Huffman-compressed coefficients.
- */
-
-METHODDEF(boolean)
-encode_mcu_huff(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
-{
- huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
- working_state state;
- int blkn, ci;
- jpeg_component_info *compptr;
-
- /* Load up working state */
- state.next_output_byte = cinfo->dest->next_output_byte;
- state.free_in_buffer = cinfo->dest->free_in_buffer;
- state.cur = entropy->saved;
- state.cinfo = cinfo;
- state.simd = entropy->simd;
-
- /* Emit restart marker if needed */
- if (cinfo->restart_interval) {
- if (entropy->restarts_to_go == 0)
- if (!emit_restart(&state, entropy->next_restart_num))
- return FALSE;
- }
-
- /* Encode the MCU data blocks */
- if (entropy->simd) {
- for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
- ci = cinfo->MCU_membership[blkn];
- compptr = cinfo->cur_comp_info[ci];
- if (!encode_one_block_simd(&state,
- MCU_data[blkn][0], state.cur.last_dc_val[ci],
- entropy->dc_derived_tbls[compptr->dc_tbl_no],
- entropy->ac_derived_tbls[compptr->ac_tbl_no]))
- return FALSE;
- /* Update last_dc_val */
- state.cur.last_dc_val[ci] = MCU_data[blkn][0][0];
- }
- } else {
- for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
- ci = cinfo->MCU_membership[blkn];
- compptr = cinfo->cur_comp_info[ci];
- if (!encode_one_block(&state,
- MCU_data[blkn][0], state.cur.last_dc_val[ci],
- entropy->dc_derived_tbls[compptr->dc_tbl_no],
- entropy->ac_derived_tbls[compptr->ac_tbl_no]))
- return FALSE;
- /* Update last_dc_val */
- state.cur.last_dc_val[ci] = MCU_data[blkn][0][0];
- }
- }
-
- /* Completed MCU, so update state */
- cinfo->dest->next_output_byte = state.next_output_byte;
- cinfo->dest->free_in_buffer = state.free_in_buffer;
- entropy->saved = state.cur;
-
- /* Update restart-interval state too */
- if (cinfo->restart_interval) {
- if (entropy->restarts_to_go == 0) {
- entropy->restarts_to_go = cinfo->restart_interval;
- entropy->next_restart_num++;
- entropy->next_restart_num &= 7;
- }
- entropy->restarts_to_go--;
- }
-
- return TRUE;
-}
-
-
-/*
- * Finish up at the end of a Huffman-compressed scan.
- */
-
-METHODDEF(void)
-finish_pass_huff(j_compress_ptr cinfo)
-{
- huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
- working_state state;
-
- /* Load up working state ... flush_bits needs it */
- state.next_output_byte = cinfo->dest->next_output_byte;
- state.free_in_buffer = cinfo->dest->free_in_buffer;
- state.cur = entropy->saved;
- state.cinfo = cinfo;
- state.simd = entropy->simd;
-
- /* Flush out the last data */
- if (!flush_bits(&state))
- ERREXIT(cinfo, JERR_CANT_SUSPEND);
-
- /* Update state */
- cinfo->dest->next_output_byte = state.next_output_byte;
- cinfo->dest->free_in_buffer = state.free_in_buffer;
- entropy->saved = state.cur;
-}
-
-
-/*
- * Huffman coding optimization.
- *
- * We first scan the supplied data and count the number of uses of each symbol
- * that is to be Huffman-coded. (This process MUST agree with the code above.)
- * Then we build a Huffman coding tree for the observed counts.
- * Symbols which are not needed at all for the particular image are not
- * assigned any code, which saves space in the DHT marker as well as in
- * the compressed data.
- */
-
-#ifdef ENTROPY_OPT_SUPPORTED
-
-
-/* Process a single block's worth of coefficients */
-
-LOCAL(void)
-htest_one_block(j_compress_ptr cinfo, JCOEFPTR block, int last_dc_val,
- long dc_counts[], long ac_counts[])
-{
- register int temp;
- register int nbits;
- register int k, r;
-
- /* Encode the DC coefficient difference per section F.1.2.1 */
-
- temp = block[0] - last_dc_val;
- if (temp < 0)
- temp = -temp;
-
- /* Find the number of bits needed for the magnitude of the coefficient */
- nbits = 0;
- while (temp) {
- nbits++;
- temp >>= 1;
- }
- /* Check for out-of-range coefficient values.
- * Since we're encoding a difference, the range limit is twice as much.
- */
- if (nbits > MAX_COEF_BITS + 1)
- ERREXIT(cinfo, JERR_BAD_DCT_COEF);
-
- /* Count the Huffman symbol for the number of bits */
- dc_counts[nbits]++;
-
- /* Encode the AC coefficients per section F.1.2.2 */
-
- r = 0; /* r = run length of zeros */
-
- for (k = 1; k < DCTSIZE2; k++) {
- if ((temp = block[jpeg_natural_order[k]]) == 0) {
- r++;
- } else {
- /* if run length > 15, must emit special run-length-16 codes (0xF0) */
- while (r > 15) {
- ac_counts[0xF0]++;
- r -= 16;
- }
-
- /* Find the number of bits needed for the magnitude of the coefficient */
- if (temp < 0)
- temp = -temp;
-
- /* Find the number of bits needed for the magnitude of the coefficient */
- nbits = 1; /* there must be at least one 1 bit */
- while ((temp >>= 1))
- nbits++;
- /* Check for out-of-range coefficient values */
- if (nbits > MAX_COEF_BITS)
- ERREXIT(cinfo, JERR_BAD_DCT_COEF);
-
- /* Count Huffman symbol for run length / number of bits */
- ac_counts[(r << 4) + nbits]++;
-
- r = 0;
- }
- }
-
- /* If the last coef(s) were zero, emit an end-of-block code */
- if (r > 0)
- ac_counts[0]++;
-}
-
-
-/*
- * Trial-encode one MCU's worth of Huffman-compressed coefficients.
- * No data is actually output, so no suspension return is possible.
- */
-
-METHODDEF(boolean)
-encode_mcu_gather(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
-{
- huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
- int blkn, ci;
- jpeg_component_info *compptr;
-
- /* Take care of restart intervals if needed */
- if (cinfo->restart_interval) {
- if (entropy->restarts_to_go == 0) {
- /* Re-initialize DC predictions to 0 */
- for (ci = 0; ci < cinfo->comps_in_scan; ci++)
- entropy->saved.last_dc_val[ci] = 0;
- /* Update restart state */
- entropy->restarts_to_go = cinfo->restart_interval;
- }
- entropy->restarts_to_go--;
- }
-
- for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
- ci = cinfo->MCU_membership[blkn];
- compptr = cinfo->cur_comp_info[ci];
- htest_one_block(cinfo, MCU_data[blkn][0], entropy->saved.last_dc_val[ci],
- entropy->dc_count_ptrs[compptr->dc_tbl_no],
- entropy->ac_count_ptrs[compptr->ac_tbl_no]);
- entropy->saved.last_dc_val[ci] = MCU_data[blkn][0][0];
- }
-
- return TRUE;
-}
-
-
-/*
- * Generate the best Huffman code table for the given counts, fill htbl.
- * Note this is also used by jcphuff.c.
- *
- * The JPEG standard requires that no symbol be assigned a codeword of all
- * one bits (so that padding bits added at the end of a compressed segment
- * can't look like a valid code). Because of the canonical ordering of
- * codewords, this just means that there must be an unused slot in the
- * longest codeword length category. Annex K (Clause K.2) of
- * Rec. ITU-T T.81 (1992) | ISO/IEC 10918-1:1994 suggests reserving such a slot
- * by pretending that symbol 256 is a valid symbol with count 1. In theory
- * that's not optimal; giving it count zero but including it in the symbol set
- * anyway should give a better Huffman code. But the theoretically better code
- * actually seems to come out worse in practice, because it produces more
- * all-ones bytes (which incur stuffed zero bytes in the final file). In any
- * case the difference is tiny.
- *
- * The JPEG standard requires Huffman codes to be no more than 16 bits long.
- * If some symbols have a very small but nonzero probability, the Huffman tree
- * must be adjusted to meet the code length restriction. We currently use
- * the adjustment method suggested in JPEG section K.2. This method is *not*
- * optimal; it may not choose the best possible limited-length code. But
- * typically only very-low-frequency symbols will be given less-than-optimal
- * lengths, so the code is almost optimal. Experimental comparisons against
- * an optimal limited-length-code algorithm indicate that the difference is
- * microscopic --- usually less than a hundredth of a percent of total size.
- * So the extra complexity of an optimal algorithm doesn't seem worthwhile.
- */
-
-GLOBAL(void)
-jpeg_gen_optimal_table(j_compress_ptr cinfo, JHUFF_TBL *htbl, long freq[])
-{
-#define MAX_CLEN 32 /* assumed maximum initial code length */
- UINT8 bits[MAX_CLEN + 1]; /* bits[k] = # of symbols with code length k */
- int codesize[257]; /* codesize[k] = code length of symbol k */
- int others[257]; /* next symbol in current branch of tree */
- int c1, c2;
- int p, i, j;
- long v;
-
- /* This algorithm is explained in section K.2 of the JPEG standard */
-
- memset(bits, 0, sizeof(bits));
- memset(codesize, 0, sizeof(codesize));
- for (i = 0; i < 257; i++)
- others[i] = -1; /* init links to empty */
-
- freq[256] = 1; /* make sure 256 has a nonzero count */
- /* Including the pseudo-symbol 256 in the Huffman procedure guarantees
- * that no real symbol is given code-value of all ones, because 256
- * will be placed last in the largest codeword category.
- */
-
- /* Huffman's basic algorithm to assign optimal code lengths to symbols */
-
- for (;;) {
- /* Find the smallest nonzero frequency, set c1 = its symbol */
- /* In case of ties, take the larger symbol number */
- c1 = -1;
- v = 1000000000L;
- for (i = 0; i <= 256; i++) {
- if (freq[i] && freq[i] <= v) {
- v = freq[i];
- c1 = i;
- }
- }
-
- /* Find the next smallest nonzero frequency, set c2 = its symbol */
- /* In case of ties, take the larger symbol number */
- c2 = -1;
- v = 1000000000L;
- for (i = 0; i <= 256; i++) {
- if (freq[i] && freq[i] <= v && i != c1) {
- v = freq[i];
- c2 = i;
- }
- }
-
- /* Done if we've merged everything into one frequency */
- if (c2 < 0)
- break;
-
- /* Else merge the two counts/trees */
- freq[c1] += freq[c2];
- freq[c2] = 0;
-
- /* Increment the codesize of everything in c1's tree branch */
- codesize[c1]++;
- while (others[c1] >= 0) {
- c1 = others[c1];
- codesize[c1]++;
- }
-
- others[c1] = c2; /* chain c2 onto c1's tree branch */
-
- /* Increment the codesize of everything in c2's tree branch */
- codesize[c2]++;
- while (others[c2] >= 0) {
- c2 = others[c2];
- codesize[c2]++;
- }
- }
-
- /* Now count the number of symbols of each code length */
- for (i = 0; i <= 256; i++) {
- if (codesize[i]) {
- /* The JPEG standard seems to think that this can't happen, */
- /* but I'm paranoid... */
- if (codesize[i] > MAX_CLEN)
- ERREXIT(cinfo, JERR_HUFF_CLEN_OVERFLOW);
-
- bits[codesize[i]]++;
- }
- }
-
- /* JPEG doesn't allow symbols with code lengths over 16 bits, so if the pure
- * Huffman procedure assigned any such lengths, we must adjust the coding.
- * Here is what Rec. ITU-T T.81 | ISO/IEC 10918-1 says about how this next
- * bit works: Since symbols are paired for the longest Huffman code, the
- * symbols are removed from this length category two at a time. The prefix
- * for the pair (which is one bit shorter) is allocated to one of the pair;
- * then, skipping the BITS entry for that prefix length, a code word from the
- * next shortest nonzero BITS entry is converted into a prefix for two code
- * words one bit longer.
- */
-
- for (i = MAX_CLEN; i > 16; i--) {
- while (bits[i] > 0) {
- j = i - 2; /* find length of new prefix to be used */
- while (bits[j] == 0)
- j--;
-
- bits[i] -= 2; /* remove two symbols */
- bits[i - 1]++; /* one goes in this length */
- bits[j + 1] += 2; /* two new symbols in this length */
- bits[j]--; /* symbol of this length is now a prefix */
- }
- }
-
- /* Remove the count for the pseudo-symbol 256 from the largest codelength */
- while (bits[i] == 0) /* find largest codelength still in use */
- i--;
- bits[i]--;
-
- /* Return final symbol counts (only for lengths 0..16) */
- memcpy(htbl->bits, bits, sizeof(htbl->bits));
-
- /* Return a list of the symbols sorted by code length */
- /* It's not real clear to me why we don't need to consider the codelength
- * changes made above, but Rec. ITU-T T.81 | ISO/IEC 10918-1 seems to think
- * this works.
- */
- p = 0;
- for (i = 1; i <= MAX_CLEN; i++) {
- for (j = 0; j <= 255; j++) {
- if (codesize[j] == i) {
- htbl->huffval[p] = (UINT8)j;
- p++;
- }
- }
- }
-
- /* Set sent_table FALSE so updated table will be written to JPEG file. */
- htbl->sent_table = FALSE;
-}
-
-
-/*
- * Finish up a statistics-gathering pass and create the new Huffman tables.
- */
-
-METHODDEF(void)
-finish_pass_gather(j_compress_ptr cinfo)
-{
- huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
- int ci, dctbl, actbl;
- jpeg_component_info *compptr;
- JHUFF_TBL **htblptr;
- boolean did_dc[NUM_HUFF_TBLS];
- boolean did_ac[NUM_HUFF_TBLS];
-
- /* It's important not to apply jpeg_gen_optimal_table more than once
- * per table, because it clobbers the input frequency counts!
- */
- memset(did_dc, 0, sizeof(did_dc));
- memset(did_ac, 0, sizeof(did_ac));
-
- for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
- compptr = cinfo->cur_comp_info[ci];
- dctbl = compptr->dc_tbl_no;
- actbl = compptr->ac_tbl_no;
- if (!did_dc[dctbl]) {
- htblptr = &cinfo->dc_huff_tbl_ptrs[dctbl];
- if (*htblptr == NULL)
- *htblptr = jpeg_alloc_huff_table((j_common_ptr)cinfo);
- jpeg_gen_optimal_table(cinfo, *htblptr, entropy->dc_count_ptrs[dctbl]);
- did_dc[dctbl] = TRUE;
- }
- if (!did_ac[actbl]) {
- htblptr = &cinfo->ac_huff_tbl_ptrs[actbl];
- if (*htblptr == NULL)
- *htblptr = jpeg_alloc_huff_table((j_common_ptr)cinfo);
- jpeg_gen_optimal_table(cinfo, *htblptr, entropy->ac_count_ptrs[actbl]);
- did_ac[actbl] = TRUE;
- }
- }
-}
-
-
-#endif /* ENTROPY_OPT_SUPPORTED */
-
-
-/*
- * Module initialization routine for Huffman entropy encoding.
- */
-
-GLOBAL(void)
-jinit_huff_encoder(j_compress_ptr cinfo)
-{
- huff_entropy_ptr entropy;
- int i;
-
- entropy = (huff_entropy_ptr)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- sizeof(huff_entropy_encoder));
- cinfo->entropy = (struct jpeg_entropy_encoder *)entropy;
- entropy->pub.start_pass = start_pass_huff;
-
- /* Mark tables unallocated */
- for (i = 0; i < NUM_HUFF_TBLS; i++) {
- entropy->dc_derived_tbls[i] = entropy->ac_derived_tbls[i] = NULL;
-#ifdef ENTROPY_OPT_SUPPORTED
- entropy->dc_count_ptrs[i] = entropy->ac_count_ptrs[i] = NULL;
-#endif
- }
-}
diff --git a/contrib/libs/libjpeg-turbo/jchuff.h b/contrib/libs/libjpeg-turbo/jchuff.h
deleted file mode 100644
index 314a2325c9..0000000000
--- a/contrib/libs/libjpeg-turbo/jchuff.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * jchuff.h
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * It was modified by The libjpeg-turbo Project to include only code relevant
- * to libjpeg-turbo.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains declarations for Huffman entropy encoding routines
- * that are shared between the sequential encoder (jchuff.c) and the
- * progressive encoder (jcphuff.c). No other modules need to see these.
- */
-
-/* The legal range of a DCT coefficient is
- * -1024 .. +1023 for 8-bit data;
- * -16384 .. +16383 for 12-bit data.
- * Hence the magnitude should always fit in 10 or 14 bits respectively.
- */
-
-#if BITS_IN_JSAMPLE == 8
-#define MAX_COEF_BITS 10
-#else
-#define MAX_COEF_BITS 14
-#endif
-
-/* Derived data constructed for each Huffman table */
-
-typedef struct {
- unsigned int ehufco[256]; /* code for each symbol */
- char ehufsi[256]; /* length of code for each symbol */
- /* If no code has been allocated for a symbol S, ehufsi[S] contains 0 */
-} c_derived_tbl;
-
-/* Expand a Huffman table definition into the derived format */
-EXTERN(void) jpeg_make_c_derived_tbl(j_compress_ptr cinfo, boolean isDC,
- int tblno, c_derived_tbl **pdtbl);
-
-/* Generate an optimal table definition given the specified counts */
-EXTERN(void) jpeg_gen_optimal_table(j_compress_ptr cinfo, JHUFF_TBL *htbl,
- long freq[]);
diff --git a/contrib/libs/libjpeg-turbo/jcicc.c b/contrib/libs/libjpeg-turbo/jcicc.c
deleted file mode 100644
index 11037ff694..0000000000
--- a/contrib/libs/libjpeg-turbo/jcicc.c
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * jcicc.c
- *
- * Copyright (C) 1997-1998, Thomas G. Lane, Todd Newman.
- * Copyright (C) 2017, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file provides code to write International Color Consortium (ICC) device
- * profiles embedded in JFIF JPEG image files. The ICC has defined a standard
- * for including such data in JPEG "APP2" markers. The code given here does
- * not know anything about the internal structure of the ICC profile data; it
- * just knows how to embed the profile data in a JPEG file while writing it.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-#include "jerror.h"
-
-
-/*
- * Since an ICC profile can be larger than the maximum size of a JPEG marker
- * (64K), we need provisions to split it into multiple markers. The format
- * defined by the ICC specifies one or more APP2 markers containing the
- * following data:
- * Identifying string ASCII "ICC_PROFILE\0" (12 bytes)
- * Marker sequence number 1 for first APP2, 2 for next, etc (1 byte)
- * Number of markers Total number of APP2's used (1 byte)
- * Profile data (remainder of APP2 data)
- * Decoders should use the marker sequence numbers to reassemble the profile,
- * rather than assuming that the APP2 markers appear in the correct sequence.
- */
-
-#define ICC_MARKER (JPEG_APP0 + 2) /* JPEG marker code for ICC */
-#define ICC_OVERHEAD_LEN 14 /* size of non-profile data in APP2 */
-#define MAX_BYTES_IN_MARKER 65533 /* maximum data len of a JPEG marker */
-#define MAX_DATA_BYTES_IN_MARKER (MAX_BYTES_IN_MARKER - ICC_OVERHEAD_LEN)
-
-
-/*
- * This routine writes the given ICC profile data into a JPEG file. It *must*
- * be called AFTER calling jpeg_start_compress() and BEFORE the first call to
- * jpeg_write_scanlines(). (This ordering ensures that the APP2 marker(s) will
- * appear after the SOI and JFIF or Adobe markers, but before all else.)
- */
-
-GLOBAL(void)
-jpeg_write_icc_profile(j_compress_ptr cinfo, const JOCTET *icc_data_ptr,
- unsigned int icc_data_len)
-{
- unsigned int num_markers; /* total number of markers we'll write */
- int cur_marker = 1; /* per spec, counting starts at 1 */
- unsigned int length; /* number of bytes to write in this marker */
-
- if (icc_data_ptr == NULL || icc_data_len == 0)
- ERREXIT(cinfo, JERR_BUFFER_SIZE);
- if (cinfo->global_state < CSTATE_SCANNING)
- ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
-
- /* Calculate the number of markers we'll need, rounding up of course */
- num_markers = icc_data_len / MAX_DATA_BYTES_IN_MARKER;
- if (num_markers * MAX_DATA_BYTES_IN_MARKER != icc_data_len)
- num_markers++;
-
- while (icc_data_len > 0) {
- /* length of profile to put in this marker */
- length = icc_data_len;
- if (length > MAX_DATA_BYTES_IN_MARKER)
- length = MAX_DATA_BYTES_IN_MARKER;
- icc_data_len -= length;
-
- /* Write the JPEG marker header (APP2 code and marker length) */
- jpeg_write_m_header(cinfo, ICC_MARKER,
- (unsigned int)(length + ICC_OVERHEAD_LEN));
-
- /* Write the marker identifying string "ICC_PROFILE" (null-terminated). We
- * code it in this less-than-transparent way so that the code works even if
- * the local character set is not ASCII.
- */
- jpeg_write_m_byte(cinfo, 0x49);
- jpeg_write_m_byte(cinfo, 0x43);
- jpeg_write_m_byte(cinfo, 0x43);
- jpeg_write_m_byte(cinfo, 0x5F);
- jpeg_write_m_byte(cinfo, 0x50);
- jpeg_write_m_byte(cinfo, 0x52);
- jpeg_write_m_byte(cinfo, 0x4F);
- jpeg_write_m_byte(cinfo, 0x46);
- jpeg_write_m_byte(cinfo, 0x49);
- jpeg_write_m_byte(cinfo, 0x4C);
- jpeg_write_m_byte(cinfo, 0x45);
- jpeg_write_m_byte(cinfo, 0x0);
-
- /* Add the sequencing info */
- jpeg_write_m_byte(cinfo, cur_marker);
- jpeg_write_m_byte(cinfo, (int)num_markers);
-
- /* Add the profile data */
- while (length--) {
- jpeg_write_m_byte(cinfo, *icc_data_ptr);
- icc_data_ptr++;
- }
- cur_marker++;
- }
-}
diff --git a/contrib/libs/libjpeg-turbo/jcinit.c b/contrib/libs/libjpeg-turbo/jcinit.c
deleted file mode 100644
index 157353a22e..0000000000
--- a/contrib/libs/libjpeg-turbo/jcinit.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * jcinit.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2020, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains initialization logic for the JPEG compressor.
- * This routine is in charge of selecting the modules to be executed and
- * making an initialization call to each one.
- *
- * Logically, this code belongs in jcmaster.c. It's split out because
- * linking this routine implies linking the entire compression library.
- * For a transcoding-only application, we want to be able to use jcmaster.c
- * without linking in the whole library.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-#include "jpegcomp.h"
-
-
-/*
- * Master selection of compression modules.
- * This is done once at the start of processing an image. We determine
- * which modules will be used and give them appropriate initialization calls.
- */
-
-GLOBAL(void)
-jinit_compress_master(j_compress_ptr cinfo)
-{
- /* Initialize master control (includes parameter checking/processing) */
- jinit_c_master_control(cinfo, FALSE /* full compression */);
-
- /* Preprocessing */
- if (!cinfo->raw_data_in) {
- jinit_color_converter(cinfo);
- jinit_downsampler(cinfo);
- jinit_c_prep_controller(cinfo, FALSE /* never need full buffer here */);
- }
- /* Forward DCT */
- jinit_forward_dct(cinfo);
- /* Entropy encoding: either Huffman or arithmetic coding. */
- if (cinfo->arith_code) {
-#ifdef C_ARITH_CODING_SUPPORTED
- jinit_arith_encoder(cinfo);
-#else
- ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
-#endif
- } else {
- if (cinfo->progressive_mode) {
-#ifdef C_PROGRESSIVE_SUPPORTED
- jinit_phuff_encoder(cinfo);
-#else
- ERREXIT(cinfo, JERR_NOT_COMPILED);
-#endif
- } else
- jinit_huff_encoder(cinfo);
- }
-
- /* Need a full-image coefficient buffer in any multi-pass mode. */
- jinit_c_coef_controller(cinfo, (boolean)(cinfo->num_scans > 1 ||
- cinfo->optimize_coding));
- jinit_c_main_controller(cinfo, FALSE /* never need full buffer here */);
-
- jinit_marker_writer(cinfo);
-
- /* We can now tell the memory manager to allocate virtual arrays. */
- (*cinfo->mem->realize_virt_arrays) ((j_common_ptr)cinfo);
-
- /* Write the datastream header (SOI) immediately.
- * Frame and scan headers are postponed till later.
- * This lets application insert special markers after the SOI.
- */
- (*cinfo->marker->write_file_header) (cinfo);
-}
diff --git a/contrib/libs/libjpeg-turbo/jcmainct.c b/contrib/libs/libjpeg-turbo/jcmainct.c
deleted file mode 100644
index 3f23028c46..0000000000
--- a/contrib/libs/libjpeg-turbo/jcmainct.c
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * jcmainct.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * It was modified by The libjpeg-turbo Project to include only code relevant
- * to libjpeg-turbo.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains the main buffer controller for compression.
- * The main buffer lies between the pre-processor and the JPEG
- * compressor proper; it holds downsampled data in the JPEG colorspace.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-
-
-/* Private buffer controller object */
-
-typedef struct {
- struct jpeg_c_main_controller pub; /* public fields */
-
- JDIMENSION cur_iMCU_row; /* number of current iMCU row */
- JDIMENSION rowgroup_ctr; /* counts row groups received in iMCU row */
- boolean suspended; /* remember if we suspended output */
- J_BUF_MODE pass_mode; /* current operating mode */
-
- /* If using just a strip buffer, this points to the entire set of buffers
- * (we allocate one for each component). In the full-image case, this
- * points to the currently accessible strips of the virtual arrays.
- */
- JSAMPARRAY buffer[MAX_COMPONENTS];
-} my_main_controller;
-
-typedef my_main_controller *my_main_ptr;
-
-
-/* Forward declarations */
-METHODDEF(void) process_data_simple_main(j_compress_ptr cinfo,
- JSAMPARRAY input_buf,
- JDIMENSION *in_row_ctr,
- JDIMENSION in_rows_avail);
-
-
-/*
- * Initialize for a processing pass.
- */
-
-METHODDEF(void)
-start_pass_main(j_compress_ptr cinfo, J_BUF_MODE pass_mode)
-{
- my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
-
- /* Do nothing in raw-data mode. */
- if (cinfo->raw_data_in)
- return;
-
- if (pass_mode != JBUF_PASS_THRU)
- ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
-
- main_ptr->cur_iMCU_row = 0; /* initialize counters */
- main_ptr->rowgroup_ctr = 0;
- main_ptr->suspended = FALSE;
- main_ptr->pass_mode = pass_mode; /* save mode for use by process_data */
- main_ptr->pub.process_data = process_data_simple_main;
-}
-
-
-/*
- * Process some data.
- * This routine handles the simple pass-through mode,
- * where we have only a strip buffer.
- */
-
-METHODDEF(void)
-process_data_simple_main(j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail)
-{
- my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
-
- while (main_ptr->cur_iMCU_row < cinfo->total_iMCU_rows) {
- /* Read input data if we haven't filled the main buffer yet */
- if (main_ptr->rowgroup_ctr < DCTSIZE)
- (*cinfo->prep->pre_process_data) (cinfo, input_buf, in_row_ctr,
- in_rows_avail, main_ptr->buffer,
- &main_ptr->rowgroup_ctr,
- (JDIMENSION)DCTSIZE);
-
- /* If we don't have a full iMCU row buffered, return to application for
- * more data. Note that preprocessor will always pad to fill the iMCU row
- * at the bottom of the image.
- */
- if (main_ptr->rowgroup_ctr != DCTSIZE)
- return;
-
- /* Send the completed row to the compressor */
- if (!(*cinfo->coef->compress_data) (cinfo, main_ptr->buffer)) {
- /* If compressor did not consume the whole row, then we must need to
- * suspend processing and return to the application. In this situation
- * we pretend we didn't yet consume the last input row; otherwise, if
- * it happened to be the last row of the image, the application would
- * think we were done.
- */
- if (!main_ptr->suspended) {
- (*in_row_ctr)--;
- main_ptr->suspended = TRUE;
- }
- return;
- }
- /* We did finish the row. Undo our little suspension hack if a previous
- * call suspended; then mark the main buffer empty.
- */
- if (main_ptr->suspended) {
- (*in_row_ctr)++;
- main_ptr->suspended = FALSE;
- }
- main_ptr->rowgroup_ctr = 0;
- main_ptr->cur_iMCU_row++;
- }
-}
-
-
-/*
- * Initialize main buffer controller.
- */
-
-GLOBAL(void)
-jinit_c_main_controller(j_compress_ptr cinfo, boolean need_full_buffer)
-{
- my_main_ptr main_ptr;
- int ci;
- jpeg_component_info *compptr;
-
- main_ptr = (my_main_ptr)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- sizeof(my_main_controller));
- cinfo->main = (struct jpeg_c_main_controller *)main_ptr;
- main_ptr->pub.start_pass = start_pass_main;
-
- /* We don't need to create a buffer in raw-data mode. */
- if (cinfo->raw_data_in)
- return;
-
- /* Create the buffer. It holds downsampled data, so each component
- * may be of a different size.
- */
- if (need_full_buffer) {
- ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
- } else {
- /* Allocate a strip buffer for each component */
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
- ci++, compptr++) {
- main_ptr->buffer[ci] = (*cinfo->mem->alloc_sarray)
- ((j_common_ptr)cinfo, JPOOL_IMAGE,
- compptr->width_in_blocks * DCTSIZE,
- (JDIMENSION)(compptr->v_samp_factor * DCTSIZE));
- }
- }
-}
diff --git a/contrib/libs/libjpeg-turbo/jcmarker.c b/contrib/libs/libjpeg-turbo/jcmarker.c
deleted file mode 100644
index 801fbab4ef..0000000000
--- a/contrib/libs/libjpeg-turbo/jcmarker.c
+++ /dev/null
@@ -1,664 +0,0 @@
-/*
- * jcmarker.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1998, Thomas G. Lane.
- * Modified 2003-2010 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2010, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains routines to write JPEG datastream markers.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-#include "jpegcomp.h"
-
-
-typedef enum { /* JPEG marker codes */
- M_SOF0 = 0xc0,
- M_SOF1 = 0xc1,
- M_SOF2 = 0xc2,
- M_SOF3 = 0xc3,
-
- M_SOF5 = 0xc5,
- M_SOF6 = 0xc6,
- M_SOF7 = 0xc7,
-
- M_JPG = 0xc8,
- M_SOF9 = 0xc9,
- M_SOF10 = 0xca,
- M_SOF11 = 0xcb,
-
- M_SOF13 = 0xcd,
- M_SOF14 = 0xce,
- M_SOF15 = 0xcf,
-
- M_DHT = 0xc4,
-
- M_DAC = 0xcc,
-
- M_RST0 = 0xd0,
- M_RST1 = 0xd1,
- M_RST2 = 0xd2,
- M_RST3 = 0xd3,
- M_RST4 = 0xd4,
- M_RST5 = 0xd5,
- M_RST6 = 0xd6,
- M_RST7 = 0xd7,
-
- M_SOI = 0xd8,
- M_EOI = 0xd9,
- M_SOS = 0xda,
- M_DQT = 0xdb,
- M_DNL = 0xdc,
- M_DRI = 0xdd,
- M_DHP = 0xde,
- M_EXP = 0xdf,
-
- M_APP0 = 0xe0,
- M_APP1 = 0xe1,
- M_APP2 = 0xe2,
- M_APP3 = 0xe3,
- M_APP4 = 0xe4,
- M_APP5 = 0xe5,
- M_APP6 = 0xe6,
- M_APP7 = 0xe7,
- M_APP8 = 0xe8,
- M_APP9 = 0xe9,
- M_APP10 = 0xea,
- M_APP11 = 0xeb,
- M_APP12 = 0xec,
- M_APP13 = 0xed,
- M_APP14 = 0xee,
- M_APP15 = 0xef,
-
- M_JPG0 = 0xf0,
- M_JPG13 = 0xfd,
- M_COM = 0xfe,
-
- M_TEM = 0x01,
-
- M_ERROR = 0x100
-} JPEG_MARKER;
-
-
-/* Private state */
-
-typedef struct {
- struct jpeg_marker_writer pub; /* public fields */
-
- unsigned int last_restart_interval; /* last DRI value emitted; 0 after SOI */
-} my_marker_writer;
-
-typedef my_marker_writer *my_marker_ptr;
-
-
-/*
- * Basic output routines.
- *
- * Note that we do not support suspension while writing a marker.
- * Therefore, an application using suspension must ensure that there is
- * enough buffer space for the initial markers (typ. 600-700 bytes) before
- * calling jpeg_start_compress, and enough space to write the trailing EOI
- * (a few bytes) before calling jpeg_finish_compress. Multipass compression
- * modes are not supported at all with suspension, so those two are the only
- * points where markers will be written.
- */
-
-LOCAL(void)
-emit_byte(j_compress_ptr cinfo, int val)
-/* Emit a byte */
-{
- struct jpeg_destination_mgr *dest = cinfo->dest;
-
- *(dest->next_output_byte)++ = (JOCTET)val;
- if (--dest->free_in_buffer == 0) {
- if (!(*dest->empty_output_buffer) (cinfo))
- ERREXIT(cinfo, JERR_CANT_SUSPEND);
- }
-}
-
-
-LOCAL(void)
-emit_marker(j_compress_ptr cinfo, JPEG_MARKER mark)
-/* Emit a marker code */
-{
- emit_byte(cinfo, 0xFF);
- emit_byte(cinfo, (int)mark);
-}
-
-
-LOCAL(void)
-emit_2bytes(j_compress_ptr cinfo, int value)
-/* Emit a 2-byte integer; these are always MSB first in JPEG files */
-{
- emit_byte(cinfo, (value >> 8) & 0xFF);
- emit_byte(cinfo, value & 0xFF);
-}
-
-
-/*
- * Routines to write specific marker types.
- */
-
-LOCAL(int)
-emit_dqt(j_compress_ptr cinfo, int index)
-/* Emit a DQT marker */
-/* Returns the precision used (0 = 8bits, 1 = 16bits) for baseline checking */
-{
- JQUANT_TBL *qtbl = cinfo->quant_tbl_ptrs[index];
- int prec;
- int i;
-
- if (qtbl == NULL)
- ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, index);
-
- prec = 0;
- for (i = 0; i < DCTSIZE2; i++) {
- if (qtbl->quantval[i] > 255)
- prec = 1;
- }
-
- if (!qtbl->sent_table) {
- emit_marker(cinfo, M_DQT);
-
- emit_2bytes(cinfo, prec ? DCTSIZE2 * 2 + 1 + 2 : DCTSIZE2 + 1 + 2);
-
- emit_byte(cinfo, index + (prec << 4));
-
- for (i = 0; i < DCTSIZE2; i++) {
- /* The table entries must be emitted in zigzag order. */
- unsigned int qval = qtbl->quantval[jpeg_natural_order[i]];
- if (prec)
- emit_byte(cinfo, (int)(qval >> 8));
- emit_byte(cinfo, (int)(qval & 0xFF));
- }
-
- qtbl->sent_table = TRUE;
- }
-
- return prec;
-}
-
-
-LOCAL(void)
-emit_dht(j_compress_ptr cinfo, int index, boolean is_ac)
-/* Emit a DHT marker */
-{
- JHUFF_TBL *htbl;
- int length, i;
-
- if (is_ac) {
- htbl = cinfo->ac_huff_tbl_ptrs[index];
- index += 0x10; /* output index has AC bit set */
- } else {
- htbl = cinfo->dc_huff_tbl_ptrs[index];
- }
-
- if (htbl == NULL)
- ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, index);
-
- if (!htbl->sent_table) {
- emit_marker(cinfo, M_DHT);
-
- length = 0;
- for (i = 1; i <= 16; i++)
- length += htbl->bits[i];
-
- emit_2bytes(cinfo, length + 2 + 1 + 16);
- emit_byte(cinfo, index);
-
- for (i = 1; i <= 16; i++)
- emit_byte(cinfo, htbl->bits[i]);
-
- for (i = 0; i < length; i++)
- emit_byte(cinfo, htbl->huffval[i]);
-
- htbl->sent_table = TRUE;
- }
-}
-
-
-LOCAL(void)
-emit_dac(j_compress_ptr cinfo)
-/* Emit a DAC marker */
-/* Since the useful info is so small, we want to emit all the tables in */
-/* one DAC marker. Therefore this routine does its own scan of the table. */
-{
-#ifdef C_ARITH_CODING_SUPPORTED
- char dc_in_use[NUM_ARITH_TBLS];
- char ac_in_use[NUM_ARITH_TBLS];
- int length, i;
- jpeg_component_info *compptr;
-
- for (i = 0; i < NUM_ARITH_TBLS; i++)
- dc_in_use[i] = ac_in_use[i] = 0;
-
- for (i = 0; i < cinfo->comps_in_scan; i++) {
- compptr = cinfo->cur_comp_info[i];
- /* DC needs no table for refinement scan */
- if (cinfo->Ss == 0 && cinfo->Ah == 0)
- dc_in_use[compptr->dc_tbl_no] = 1;
- /* AC needs no table when not present */
- if (cinfo->Se)
- ac_in_use[compptr->ac_tbl_no] = 1;
- }
-
- length = 0;
- for (i = 0; i < NUM_ARITH_TBLS; i++)
- length += dc_in_use[i] + ac_in_use[i];
-
- if (length) {
- emit_marker(cinfo, M_DAC);
-
- emit_2bytes(cinfo, length * 2 + 2);
-
- for (i = 0; i < NUM_ARITH_TBLS; i++) {
- if (dc_in_use[i]) {
- emit_byte(cinfo, i);
- emit_byte(cinfo, cinfo->arith_dc_L[i] + (cinfo->arith_dc_U[i] << 4));
- }
- if (ac_in_use[i]) {
- emit_byte(cinfo, i + 0x10);
- emit_byte(cinfo, cinfo->arith_ac_K[i]);
- }
- }
- }
-#endif /* C_ARITH_CODING_SUPPORTED */
-}
-
-
-LOCAL(void)
-emit_dri(j_compress_ptr cinfo)
-/* Emit a DRI marker */
-{
- emit_marker(cinfo, M_DRI);
-
- emit_2bytes(cinfo, 4); /* fixed length */
-
- emit_2bytes(cinfo, (int)cinfo->restart_interval);
-}
-
-
-LOCAL(void)
-emit_sof(j_compress_ptr cinfo, JPEG_MARKER code)
-/* Emit a SOF marker */
-{
- int ci;
- jpeg_component_info *compptr;
-
- emit_marker(cinfo, code);
-
- emit_2bytes(cinfo, 3 * cinfo->num_components + 2 + 5 + 1); /* length */
-
- /* Make sure image isn't bigger than SOF field can handle */
- if ((long)cinfo->_jpeg_height > 65535L || (long)cinfo->_jpeg_width > 65535L)
- ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int)65535);
-
- emit_byte(cinfo, cinfo->data_precision);
- emit_2bytes(cinfo, (int)cinfo->_jpeg_height);
- emit_2bytes(cinfo, (int)cinfo->_jpeg_width);
-
- emit_byte(cinfo, cinfo->num_components);
-
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
- ci++, compptr++) {
- emit_byte(cinfo, compptr->component_id);
- emit_byte(cinfo, (compptr->h_samp_factor << 4) + compptr->v_samp_factor);
- emit_byte(cinfo, compptr->quant_tbl_no);
- }
-}
-
-
-LOCAL(void)
-emit_sos(j_compress_ptr cinfo)
-/* Emit a SOS marker */
-{
- int i, td, ta;
- jpeg_component_info *compptr;
-
- emit_marker(cinfo, M_SOS);
-
- emit_2bytes(cinfo, 2 * cinfo->comps_in_scan + 2 + 1 + 3); /* length */
-
- emit_byte(cinfo, cinfo->comps_in_scan);
-
- for (i = 0; i < cinfo->comps_in_scan; i++) {
- compptr = cinfo->cur_comp_info[i];
- emit_byte(cinfo, compptr->component_id);
-
- /* We emit 0 for unused field(s); this is recommended by the P&M text
- * but does not seem to be specified in the standard.
- */
-
- /* DC needs no table for refinement scan */
- td = cinfo->Ss == 0 && cinfo->Ah == 0 ? compptr->dc_tbl_no : 0;
- /* AC needs no table when not present */
- ta = cinfo->Se ? compptr->ac_tbl_no : 0;
-
- emit_byte(cinfo, (td << 4) + ta);
- }
-
- emit_byte(cinfo, cinfo->Ss);
- emit_byte(cinfo, cinfo->Se);
- emit_byte(cinfo, (cinfo->Ah << 4) + cinfo->Al);
-}
-
-
-LOCAL(void)
-emit_jfif_app0(j_compress_ptr cinfo)
-/* Emit a JFIF-compliant APP0 marker */
-{
- /*
- * Length of APP0 block (2 bytes)
- * Block ID (4 bytes - ASCII "JFIF")
- * Zero byte (1 byte to terminate the ID string)
- * Version Major, Minor (2 bytes - major first)
- * Units (1 byte - 0x00 = none, 0x01 = inch, 0x02 = cm)
- * Xdpu (2 bytes - dots per unit horizontal)
- * Ydpu (2 bytes - dots per unit vertical)
- * Thumbnail X size (1 byte)
- * Thumbnail Y size (1 byte)
- */
-
- emit_marker(cinfo, M_APP0);
-
- emit_2bytes(cinfo, 2 + 4 + 1 + 2 + 1 + 2 + 2 + 1 + 1); /* length */
-
- emit_byte(cinfo, 0x4A); /* Identifier: ASCII "JFIF" */
- emit_byte(cinfo, 0x46);
- emit_byte(cinfo, 0x49);
- emit_byte(cinfo, 0x46);
- emit_byte(cinfo, 0);
- emit_byte(cinfo, cinfo->JFIF_major_version); /* Version fields */
- emit_byte(cinfo, cinfo->JFIF_minor_version);
- emit_byte(cinfo, cinfo->density_unit); /* Pixel size information */
- emit_2bytes(cinfo, (int)cinfo->X_density);
- emit_2bytes(cinfo, (int)cinfo->Y_density);
- emit_byte(cinfo, 0); /* No thumbnail image */
- emit_byte(cinfo, 0);
-}
-
-
-LOCAL(void)
-emit_adobe_app14(j_compress_ptr cinfo)
-/* Emit an Adobe APP14 marker */
-{
- /*
- * Length of APP14 block (2 bytes)
- * Block ID (5 bytes - ASCII "Adobe")
- * Version Number (2 bytes - currently 100)
- * Flags0 (2 bytes - currently 0)
- * Flags1 (2 bytes - currently 0)
- * Color transform (1 byte)
- *
- * Although Adobe TN 5116 mentions Version = 101, all the Adobe files
- * now in circulation seem to use Version = 100, so that's what we write.
- *
- * We write the color transform byte as 1 if the JPEG color space is
- * YCbCr, 2 if it's YCCK, 0 otherwise. Adobe's definition has to do with
- * whether the encoder performed a transformation, which is pretty useless.
- */
-
- emit_marker(cinfo, M_APP14);
-
- emit_2bytes(cinfo, 2 + 5 + 2 + 2 + 2 + 1); /* length */
-
- emit_byte(cinfo, 0x41); /* Identifier: ASCII "Adobe" */
- emit_byte(cinfo, 0x64);
- emit_byte(cinfo, 0x6F);
- emit_byte(cinfo, 0x62);
- emit_byte(cinfo, 0x65);
- emit_2bytes(cinfo, 100); /* Version */
- emit_2bytes(cinfo, 0); /* Flags0 */
- emit_2bytes(cinfo, 0); /* Flags1 */
- switch (cinfo->jpeg_color_space) {
- case JCS_YCbCr:
- emit_byte(cinfo, 1); /* Color transform = 1 */
- break;
- case JCS_YCCK:
- emit_byte(cinfo, 2); /* Color transform = 2 */
- break;
- default:
- emit_byte(cinfo, 0); /* Color transform = 0 */
- break;
- }
-}
-
-
-/*
- * These routines allow writing an arbitrary marker with parameters.
- * The only intended use is to emit COM or APPn markers after calling
- * write_file_header and before calling write_frame_header.
- * Other uses are not guaranteed to produce desirable results.
- * Counting the parameter bytes properly is the caller's responsibility.
- */
-
-METHODDEF(void)
-write_marker_header(j_compress_ptr cinfo, int marker, unsigned int datalen)
-/* Emit an arbitrary marker header */
-{
- if (datalen > (unsigned int)65533) /* safety check */
- ERREXIT(cinfo, JERR_BAD_LENGTH);
-
- emit_marker(cinfo, (JPEG_MARKER)marker);
-
- emit_2bytes(cinfo, (int)(datalen + 2)); /* total length */
-}
-
-METHODDEF(void)
-write_marker_byte(j_compress_ptr cinfo, int val)
-/* Emit one byte of marker parameters following write_marker_header */
-{
- emit_byte(cinfo, val);
-}
-
-
-/*
- * Write datastream header.
- * This consists of an SOI and optional APPn markers.
- * We recommend use of the JFIF marker, but not the Adobe marker,
- * when using YCbCr or grayscale data. The JFIF marker should NOT
- * be used for any other JPEG colorspace. The Adobe marker is helpful
- * to distinguish RGB, CMYK, and YCCK colorspaces.
- * Note that an application can write additional header markers after
- * jpeg_start_compress returns.
- */
-
-METHODDEF(void)
-write_file_header(j_compress_ptr cinfo)
-{
- my_marker_ptr marker = (my_marker_ptr)cinfo->marker;
-
- emit_marker(cinfo, M_SOI); /* first the SOI */
-
- /* SOI is defined to reset restart interval to 0 */
- marker->last_restart_interval = 0;
-
- if (cinfo->write_JFIF_header) /* next an optional JFIF APP0 */
- emit_jfif_app0(cinfo);
- if (cinfo->write_Adobe_marker) /* next an optional Adobe APP14 */
- emit_adobe_app14(cinfo);
-}
-
-
-/*
- * Write frame header.
- * This consists of DQT and SOFn markers.
- * Note that we do not emit the SOF until we have emitted the DQT(s).
- * This avoids compatibility problems with incorrect implementations that
- * try to error-check the quant table numbers as soon as they see the SOF.
- */
-
-METHODDEF(void)
-write_frame_header(j_compress_ptr cinfo)
-{
- int ci, prec;
- boolean is_baseline;
- jpeg_component_info *compptr;
-
- /* Emit DQT for each quantization table.
- * Note that emit_dqt() suppresses any duplicate tables.
- */
- prec = 0;
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
- ci++, compptr++) {
- prec += emit_dqt(cinfo, compptr->quant_tbl_no);
- }
- /* now prec is nonzero iff there are any 16-bit quant tables. */
-
- /* Check for a non-baseline specification.
- * Note we assume that Huffman table numbers won't be changed later.
- */
- if (cinfo->arith_code || cinfo->progressive_mode ||
- cinfo->data_precision != 8) {
- is_baseline = FALSE;
- } else {
- is_baseline = TRUE;
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
- ci++, compptr++) {
- if (compptr->dc_tbl_no > 1 || compptr->ac_tbl_no > 1)
- is_baseline = FALSE;
- }
- if (prec && is_baseline) {
- is_baseline = FALSE;
- /* If it's baseline except for quantizer size, warn the user */
- TRACEMS(cinfo, 0, JTRC_16BIT_TABLES);
- }
- }
-
- /* Emit the proper SOF marker */
- if (cinfo->arith_code) {
- if (cinfo->progressive_mode)
- emit_sof(cinfo, M_SOF10); /* SOF code for progressive arithmetic */
- else
- emit_sof(cinfo, M_SOF9); /* SOF code for sequential arithmetic */
- } else {
- if (cinfo->progressive_mode)
- emit_sof(cinfo, M_SOF2); /* SOF code for progressive Huffman */
- else if (is_baseline)
- emit_sof(cinfo, M_SOF0); /* SOF code for baseline implementation */
- else
- emit_sof(cinfo, M_SOF1); /* SOF code for non-baseline Huffman file */
- }
-}
-
-
-/*
- * Write scan header.
- * This consists of DHT or DAC markers, optional DRI, and SOS.
- * Compressed data will be written following the SOS.
- */
-
-METHODDEF(void)
-write_scan_header(j_compress_ptr cinfo)
-{
- my_marker_ptr marker = (my_marker_ptr)cinfo->marker;
- int i;
- jpeg_component_info *compptr;
-
- if (cinfo->arith_code) {
- /* Emit arith conditioning info. We may have some duplication
- * if the file has multiple scans, but it's so small it's hardly
- * worth worrying about.
- */
- emit_dac(cinfo);
- } else {
- /* Emit Huffman tables.
- * Note that emit_dht() suppresses any duplicate tables.
- */
- for (i = 0; i < cinfo->comps_in_scan; i++) {
- compptr = cinfo->cur_comp_info[i];
- /* DC needs no table for refinement scan */
- if (cinfo->Ss == 0 && cinfo->Ah == 0)
- emit_dht(cinfo, compptr->dc_tbl_no, FALSE);
- /* AC needs no table when not present */
- if (cinfo->Se)
- emit_dht(cinfo, compptr->ac_tbl_no, TRUE);
- }
- }
-
- /* Emit DRI if required --- note that DRI value could change for each scan.
- * We avoid wasting space with unnecessary DRIs, however.
- */
- if (cinfo->restart_interval != marker->last_restart_interval) {
- emit_dri(cinfo);
- marker->last_restart_interval = cinfo->restart_interval;
- }
-
- emit_sos(cinfo);
-}
-
-
-/*
- * Write datastream trailer.
- */
-
-METHODDEF(void)
-write_file_trailer(j_compress_ptr cinfo)
-{
- emit_marker(cinfo, M_EOI);
-}
-
-
-/*
- * Write an abbreviated table-specification datastream.
- * This consists of SOI, DQT and DHT tables, and EOI.
- * Any table that is defined and not marked sent_table = TRUE will be
- * emitted. Note that all tables will be marked sent_table = TRUE at exit.
- */
-
-METHODDEF(void)
-write_tables_only(j_compress_ptr cinfo)
-{
- int i;
-
- emit_marker(cinfo, M_SOI);
-
- for (i = 0; i < NUM_QUANT_TBLS; i++) {
- if (cinfo->quant_tbl_ptrs[i] != NULL)
- (void)emit_dqt(cinfo, i);
- }
-
- if (!cinfo->arith_code) {
- for (i = 0; i < NUM_HUFF_TBLS; i++) {
- if (cinfo->dc_huff_tbl_ptrs[i] != NULL)
- emit_dht(cinfo, i, FALSE);
- if (cinfo->ac_huff_tbl_ptrs[i] != NULL)
- emit_dht(cinfo, i, TRUE);
- }
- }
-
- emit_marker(cinfo, M_EOI);
-}
-
-
-/*
- * Initialize the marker writer module.
- */
-
-GLOBAL(void)
-jinit_marker_writer(j_compress_ptr cinfo)
-{
- my_marker_ptr marker;
-
- /* Create the subobject */
- marker = (my_marker_ptr)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- sizeof(my_marker_writer));
- cinfo->marker = (struct jpeg_marker_writer *)marker;
- /* Initialize method pointers */
- marker->pub.write_file_header = write_file_header;
- marker->pub.write_frame_header = write_frame_header;
- marker->pub.write_scan_header = write_scan_header;
- marker->pub.write_file_trailer = write_file_trailer;
- marker->pub.write_tables_only = write_tables_only;
- marker->pub.write_marker_header = write_marker_header;
- marker->pub.write_marker_byte = write_marker_byte;
- /* Initialize private state */
- marker->last_restart_interval = 0;
-}
diff --git a/contrib/libs/libjpeg-turbo/jcmaster.c b/contrib/libs/libjpeg-turbo/jcmaster.c
deleted file mode 100644
index c2b2600031..0000000000
--- a/contrib/libs/libjpeg-turbo/jcmaster.c
+++ /dev/null
@@ -1,640 +0,0 @@
-/*
- * jcmaster.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * Modified 2003-2010 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2016, 2018, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains master control logic for the JPEG compressor.
- * These routines are concerned with parameter validation, initial setup,
- * and inter-pass control (determining the number of passes and the work
- * to be done in each pass).
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-#include "jpegcomp.h"
-#include "jconfigint.h"
-
-
-/* Private state */
-
-typedef enum {
- main_pass, /* input data, also do first output step */
- huff_opt_pass, /* Huffman code optimization pass */
- output_pass /* data output pass */
-} c_pass_type;
-
-typedef struct {
- struct jpeg_comp_master pub; /* public fields */
-
- c_pass_type pass_type; /* the type of the current pass */
-
- int pass_number; /* # of passes completed */
- int total_passes; /* total # of passes needed */
-
- int scan_number; /* current index in scan_info[] */
-
- /*
- * This is here so we can add libjpeg-turbo version/build information to the
- * global string table without introducing a new global symbol. Adding this
- * information to the global string table allows one to examine a binary
- * object and determine which version of libjpeg-turbo it was built from or
- * linked against.
- */
- const char *jpeg_version;
-
-} my_comp_master;
-
-typedef my_comp_master *my_master_ptr;
-
-
-/*
- * Support routines that do various essential calculations.
- */
-
-#if JPEG_LIB_VERSION >= 70
-/*
- * Compute JPEG image dimensions and related values.
- * NOTE: this is exported for possible use by application.
- * Hence it mustn't do anything that can't be done twice.
- */
-
-GLOBAL(void)
-jpeg_calc_jpeg_dimensions(j_compress_ptr cinfo)
-/* Do computations that are needed before master selection phase */
-{
- /* Hardwire it to "no scaling" */
- cinfo->jpeg_width = cinfo->image_width;
- cinfo->jpeg_height = cinfo->image_height;
- cinfo->min_DCT_h_scaled_size = DCTSIZE;
- cinfo->min_DCT_v_scaled_size = DCTSIZE;
-}
-#endif
-
-
-LOCAL(void)
-initial_setup(j_compress_ptr cinfo, boolean transcode_only)
-/* Do computations that are needed before master selection phase */
-{
- int ci;
- jpeg_component_info *compptr;
- long samplesperrow;
- JDIMENSION jd_samplesperrow;
-
-#if JPEG_LIB_VERSION >= 70
-#if JPEG_LIB_VERSION >= 80
- if (!transcode_only)
-#endif
- jpeg_calc_jpeg_dimensions(cinfo);
-#endif
-
- /* Sanity check on image dimensions */
- if (cinfo->_jpeg_height <= 0 || cinfo->_jpeg_width <= 0 ||
- cinfo->num_components <= 0 || cinfo->input_components <= 0)
- ERREXIT(cinfo, JERR_EMPTY_IMAGE);
-
- /* Make sure image isn't bigger than I can handle */
- if ((long)cinfo->_jpeg_height > (long)JPEG_MAX_DIMENSION ||
- (long)cinfo->_jpeg_width > (long)JPEG_MAX_DIMENSION)
- ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int)JPEG_MAX_DIMENSION);
-
- /* Width of an input scanline must be representable as JDIMENSION. */
- samplesperrow = (long)cinfo->image_width * (long)cinfo->input_components;
- jd_samplesperrow = (JDIMENSION)samplesperrow;
- if ((long)jd_samplesperrow != samplesperrow)
- ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
-
- /* For now, precision must match compiled-in value... */
- if (cinfo->data_precision != BITS_IN_JSAMPLE)
- ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
-
- /* Check that number of components won't exceed internal array sizes */
- if (cinfo->num_components > MAX_COMPONENTS)
- ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components,
- MAX_COMPONENTS);
-
- /* Compute maximum sampling factors; check factor validity */
- cinfo->max_h_samp_factor = 1;
- cinfo->max_v_samp_factor = 1;
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
- ci++, compptr++) {
- if (compptr->h_samp_factor <= 0 ||
- compptr->h_samp_factor > MAX_SAMP_FACTOR ||
- compptr->v_samp_factor <= 0 ||
- compptr->v_samp_factor > MAX_SAMP_FACTOR)
- ERREXIT(cinfo, JERR_BAD_SAMPLING);
- cinfo->max_h_samp_factor = MAX(cinfo->max_h_samp_factor,
- compptr->h_samp_factor);
- cinfo->max_v_samp_factor = MAX(cinfo->max_v_samp_factor,
- compptr->v_samp_factor);
- }
-
- /* Compute dimensions of components */
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
- ci++, compptr++) {
- /* Fill in the correct component_index value; don't rely on application */
- compptr->component_index = ci;
- /* For compression, we never do DCT scaling. */
-#if JPEG_LIB_VERSION >= 70
- compptr->DCT_h_scaled_size = compptr->DCT_v_scaled_size = DCTSIZE;
-#else
- compptr->DCT_scaled_size = DCTSIZE;
-#endif
- /* Size in DCT blocks */
- compptr->width_in_blocks = (JDIMENSION)
- jdiv_round_up((long)cinfo->_jpeg_width * (long)compptr->h_samp_factor,
- (long)(cinfo->max_h_samp_factor * DCTSIZE));
- compptr->height_in_blocks = (JDIMENSION)
- jdiv_round_up((long)cinfo->_jpeg_height * (long)compptr->v_samp_factor,
- (long)(cinfo->max_v_samp_factor * DCTSIZE));
- /* Size in samples */
- compptr->downsampled_width = (JDIMENSION)
- jdiv_round_up((long)cinfo->_jpeg_width * (long)compptr->h_samp_factor,
- (long)cinfo->max_h_samp_factor);
- compptr->downsampled_height = (JDIMENSION)
- jdiv_round_up((long)cinfo->_jpeg_height * (long)compptr->v_samp_factor,
- (long)cinfo->max_v_samp_factor);
- /* Mark component needed (this flag isn't actually used for compression) */
- compptr->component_needed = TRUE;
- }
-
- /* Compute number of fully interleaved MCU rows (number of times that
- * main controller will call coefficient controller).
- */
- cinfo->total_iMCU_rows = (JDIMENSION)
- jdiv_round_up((long)cinfo->_jpeg_height,
- (long)(cinfo->max_v_samp_factor * DCTSIZE));
-}
-
-
-#ifdef C_MULTISCAN_FILES_SUPPORTED
-
-LOCAL(void)
-validate_script(j_compress_ptr cinfo)
-/* Verify that the scan script in cinfo->scan_info[] is valid; also
- * determine whether it uses progressive JPEG, and set cinfo->progressive_mode.
- */
-{
- const jpeg_scan_info *scanptr;
- int scanno, ncomps, ci, coefi, thisi;
- int Ss, Se, Ah, Al;
- boolean component_sent[MAX_COMPONENTS];
-#ifdef C_PROGRESSIVE_SUPPORTED
- int *last_bitpos_ptr;
- int last_bitpos[MAX_COMPONENTS][DCTSIZE2];
- /* -1 until that coefficient has been seen; then last Al for it */
-#endif
-
- if (cinfo->num_scans <= 0)
- ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, 0);
-
- /* For sequential JPEG, all scans must have Ss=0, Se=DCTSIZE2-1;
- * for progressive JPEG, no scan can have this.
- */
- scanptr = cinfo->scan_info;
- if (scanptr->Ss != 0 || scanptr->Se != DCTSIZE2 - 1) {
-#ifdef C_PROGRESSIVE_SUPPORTED
- cinfo->progressive_mode = TRUE;
- last_bitpos_ptr = &last_bitpos[0][0];
- for (ci = 0; ci < cinfo->num_components; ci++)
- for (coefi = 0; coefi < DCTSIZE2; coefi++)
- *last_bitpos_ptr++ = -1;
-#else
- ERREXIT(cinfo, JERR_NOT_COMPILED);
-#endif
- } else {
- cinfo->progressive_mode = FALSE;
- for (ci = 0; ci < cinfo->num_components; ci++)
- component_sent[ci] = FALSE;
- }
-
- for (scanno = 1; scanno <= cinfo->num_scans; scanptr++, scanno++) {
- /* Validate component indexes */
- ncomps = scanptr->comps_in_scan;
- if (ncomps <= 0 || ncomps > MAX_COMPS_IN_SCAN)
- ERREXIT2(cinfo, JERR_COMPONENT_COUNT, ncomps, MAX_COMPS_IN_SCAN);
- for (ci = 0; ci < ncomps; ci++) {
- thisi = scanptr->component_index[ci];
- if (thisi < 0 || thisi >= cinfo->num_components)
- ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno);
- /* Components must appear in SOF order within each scan */
- if (ci > 0 && thisi <= scanptr->component_index[ci - 1])
- ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno);
- }
- /* Validate progression parameters */
- Ss = scanptr->Ss;
- Se = scanptr->Se;
- Ah = scanptr->Ah;
- Al = scanptr->Al;
- if (cinfo->progressive_mode) {
-#ifdef C_PROGRESSIVE_SUPPORTED
- /* Rec. ITU-T T.81 | ISO/IEC 10918-1 simply gives the ranges 0..13 for Ah
- * and Al, but that seems wrong: the upper bound ought to depend on data
- * precision. Perhaps they really meant 0..N+1 for N-bit precision.
- * Here we allow 0..10 for 8-bit data; Al larger than 10 results in
- * out-of-range reconstructed DC values during the first DC scan,
- * which might cause problems for some decoders.
- */
-#if BITS_IN_JSAMPLE == 8
-#define MAX_AH_AL 10
-#else
-#define MAX_AH_AL 13
-#endif
- if (Ss < 0 || Ss >= DCTSIZE2 || Se < Ss || Se >= DCTSIZE2 ||
- Ah < 0 || Ah > MAX_AH_AL || Al < 0 || Al > MAX_AH_AL)
- ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
- if (Ss == 0) {
- if (Se != 0) /* DC and AC together not OK */
- ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
- } else {
- if (ncomps != 1) /* AC scans must be for only one component */
- ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
- }
- for (ci = 0; ci < ncomps; ci++) {
- last_bitpos_ptr = &last_bitpos[scanptr->component_index[ci]][0];
- if (Ss != 0 && last_bitpos_ptr[0] < 0) /* AC without prior DC scan */
- ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
- for (coefi = Ss; coefi <= Se; coefi++) {
- if (last_bitpos_ptr[coefi] < 0) {
- /* first scan of this coefficient */
- if (Ah != 0)
- ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
- } else {
- /* not first scan */
- if (Ah != last_bitpos_ptr[coefi] || Al != Ah - 1)
- ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
- }
- last_bitpos_ptr[coefi] = Al;
- }
- }
-#endif
- } else {
- /* For sequential JPEG, all progression parameters must be these: */
- if (Ss != 0 || Se != DCTSIZE2 - 1 || Ah != 0 || Al != 0)
- ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
- /* Make sure components are not sent twice */
- for (ci = 0; ci < ncomps; ci++) {
- thisi = scanptr->component_index[ci];
- if (component_sent[thisi])
- ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno);
- component_sent[thisi] = TRUE;
- }
- }
- }
-
- /* Now verify that everything got sent. */
- if (cinfo->progressive_mode) {
-#ifdef C_PROGRESSIVE_SUPPORTED
- /* For progressive mode, we only check that at least some DC data
- * got sent for each component; the spec does not require that all bits
- * of all coefficients be transmitted. Would it be wiser to enforce
- * transmission of all coefficient bits??
- */
- for (ci = 0; ci < cinfo->num_components; ci++) {
- if (last_bitpos[ci][0] < 0)
- ERREXIT(cinfo, JERR_MISSING_DATA);
- }
-#endif
- } else {
- for (ci = 0; ci < cinfo->num_components; ci++) {
- if (!component_sent[ci])
- ERREXIT(cinfo, JERR_MISSING_DATA);
- }
- }
-}
-
-#endif /* C_MULTISCAN_FILES_SUPPORTED */
-
-
-LOCAL(void)
-select_scan_parameters(j_compress_ptr cinfo)
-/* Set up the scan parameters for the current scan */
-{
- int ci;
-
-#ifdef C_MULTISCAN_FILES_SUPPORTED
- if (cinfo->scan_info != NULL) {
- /* Prepare for current scan --- the script is already validated */
- my_master_ptr master = (my_master_ptr)cinfo->master;
- const jpeg_scan_info *scanptr = cinfo->scan_info + master->scan_number;
-
- cinfo->comps_in_scan = scanptr->comps_in_scan;
- for (ci = 0; ci < scanptr->comps_in_scan; ci++) {
- cinfo->cur_comp_info[ci] =
- &cinfo->comp_info[scanptr->component_index[ci]];
- }
- cinfo->Ss = scanptr->Ss;
- cinfo->Se = scanptr->Se;
- cinfo->Ah = scanptr->Ah;
- cinfo->Al = scanptr->Al;
- } else
-#endif
- {
- /* Prepare for single sequential-JPEG scan containing all components */
- if (cinfo->num_components > MAX_COMPS_IN_SCAN)
- ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components,
- MAX_COMPS_IN_SCAN);
- cinfo->comps_in_scan = cinfo->num_components;
- for (ci = 0; ci < cinfo->num_components; ci++) {
- cinfo->cur_comp_info[ci] = &cinfo->comp_info[ci];
- }
- cinfo->Ss = 0;
- cinfo->Se = DCTSIZE2 - 1;
- cinfo->Ah = 0;
- cinfo->Al = 0;
- }
-}
-
-
-LOCAL(void)
-per_scan_setup(j_compress_ptr cinfo)
-/* Do computations that are needed before processing a JPEG scan */
-/* cinfo->comps_in_scan and cinfo->cur_comp_info[] are already set */
-{
- int ci, mcublks, tmp;
- jpeg_component_info *compptr;
-
- if (cinfo->comps_in_scan == 1) {
-
- /* Noninterleaved (single-component) scan */
- compptr = cinfo->cur_comp_info[0];
-
- /* Overall image size in MCUs */
- cinfo->MCUs_per_row = compptr->width_in_blocks;
- cinfo->MCU_rows_in_scan = compptr->height_in_blocks;
-
- /* For noninterleaved scan, always one block per MCU */
- compptr->MCU_width = 1;
- compptr->MCU_height = 1;
- compptr->MCU_blocks = 1;
- compptr->MCU_sample_width = DCTSIZE;
- compptr->last_col_width = 1;
- /* For noninterleaved scans, it is convenient to define last_row_height
- * as the number of block rows present in the last iMCU row.
- */
- tmp = (int)(compptr->height_in_blocks % compptr->v_samp_factor);
- if (tmp == 0) tmp = compptr->v_samp_factor;
- compptr->last_row_height = tmp;
-
- /* Prepare array describing MCU composition */
- cinfo->blocks_in_MCU = 1;
- cinfo->MCU_membership[0] = 0;
-
- } else {
-
- /* Interleaved (multi-component) scan */
- if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN)
- ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan,
- MAX_COMPS_IN_SCAN);
-
- /* Overall image size in MCUs */
- cinfo->MCUs_per_row = (JDIMENSION)
- jdiv_round_up((long)cinfo->_jpeg_width,
- (long)(cinfo->max_h_samp_factor * DCTSIZE));
- cinfo->MCU_rows_in_scan = (JDIMENSION)
- jdiv_round_up((long)cinfo->_jpeg_height,
- (long)(cinfo->max_v_samp_factor * DCTSIZE));
-
- cinfo->blocks_in_MCU = 0;
-
- for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
- compptr = cinfo->cur_comp_info[ci];
- /* Sampling factors give # of blocks of component in each MCU */
- compptr->MCU_width = compptr->h_samp_factor;
- compptr->MCU_height = compptr->v_samp_factor;
- compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height;
- compptr->MCU_sample_width = compptr->MCU_width * DCTSIZE;
- /* Figure number of non-dummy blocks in last MCU column & row */
- tmp = (int)(compptr->width_in_blocks % compptr->MCU_width);
- if (tmp == 0) tmp = compptr->MCU_width;
- compptr->last_col_width = tmp;
- tmp = (int)(compptr->height_in_blocks % compptr->MCU_height);
- if (tmp == 0) tmp = compptr->MCU_height;
- compptr->last_row_height = tmp;
- /* Prepare array describing MCU composition */
- mcublks = compptr->MCU_blocks;
- if (cinfo->blocks_in_MCU + mcublks > C_MAX_BLOCKS_IN_MCU)
- ERREXIT(cinfo, JERR_BAD_MCU_SIZE);
- while (mcublks-- > 0) {
- cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci;
- }
- }
-
- }
-
- /* Convert restart specified in rows to actual MCU count. */
- /* Note that count must fit in 16 bits, so we provide limiting. */
- if (cinfo->restart_in_rows > 0) {
- long nominal = (long)cinfo->restart_in_rows * (long)cinfo->MCUs_per_row;
- cinfo->restart_interval = (unsigned int)MIN(nominal, 65535L);
- }
-}
-
-
-/*
- * Per-pass setup.
- * This is called at the beginning of each pass. We determine which modules
- * will be active during this pass and give them appropriate start_pass calls.
- * We also set is_last_pass to indicate whether any more passes will be
- * required.
- */
-
-METHODDEF(void)
-prepare_for_pass(j_compress_ptr cinfo)
-{
- my_master_ptr master = (my_master_ptr)cinfo->master;
-
- switch (master->pass_type) {
- case main_pass:
- /* Initial pass: will collect input data, and do either Huffman
- * optimization or data output for the first scan.
- */
- select_scan_parameters(cinfo);
- per_scan_setup(cinfo);
- if (!cinfo->raw_data_in) {
- (*cinfo->cconvert->start_pass) (cinfo);
- (*cinfo->downsample->start_pass) (cinfo);
- (*cinfo->prep->start_pass) (cinfo, JBUF_PASS_THRU);
- }
- (*cinfo->fdct->start_pass) (cinfo);
- (*cinfo->entropy->start_pass) (cinfo, cinfo->optimize_coding);
- (*cinfo->coef->start_pass) (cinfo,
- (master->total_passes > 1 ?
- JBUF_SAVE_AND_PASS : JBUF_PASS_THRU));
- (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU);
- if (cinfo->optimize_coding) {
- /* No immediate data output; postpone writing frame/scan headers */
- master->pub.call_pass_startup = FALSE;
- } else {
- /* Will write frame/scan headers at first jpeg_write_scanlines call */
- master->pub.call_pass_startup = TRUE;
- }
- break;
-#ifdef ENTROPY_OPT_SUPPORTED
- case huff_opt_pass:
- /* Do Huffman optimization for a scan after the first one. */
- select_scan_parameters(cinfo);
- per_scan_setup(cinfo);
- if (cinfo->Ss != 0 || cinfo->Ah == 0 || cinfo->arith_code) {
- (*cinfo->entropy->start_pass) (cinfo, TRUE);
- (*cinfo->coef->start_pass) (cinfo, JBUF_CRANK_DEST);
- master->pub.call_pass_startup = FALSE;
- break;
- }
- /* Special case: Huffman DC refinement scans need no Huffman table
- * and therefore we can skip the optimization pass for them.
- */
- master->pass_type = output_pass;
- master->pass_number++;
-#endif
- FALLTHROUGH /*FALLTHROUGH*/
- case output_pass:
- /* Do a data-output pass. */
- /* We need not repeat per-scan setup if prior optimization pass did it. */
- if (!cinfo->optimize_coding) {
- select_scan_parameters(cinfo);
- per_scan_setup(cinfo);
- }
- (*cinfo->entropy->start_pass) (cinfo, FALSE);
- (*cinfo->coef->start_pass) (cinfo, JBUF_CRANK_DEST);
- /* We emit frame/scan headers now */
- if (master->scan_number == 0)
- (*cinfo->marker->write_frame_header) (cinfo);
- (*cinfo->marker->write_scan_header) (cinfo);
- master->pub.call_pass_startup = FALSE;
- break;
- default:
- ERREXIT(cinfo, JERR_NOT_COMPILED);
- }
-
- master->pub.is_last_pass = (master->pass_number == master->total_passes - 1);
-
- /* Set up progress monitor's pass info if present */
- if (cinfo->progress != NULL) {
- cinfo->progress->completed_passes = master->pass_number;
- cinfo->progress->total_passes = master->total_passes;
- }
-}
-
-
-/*
- * Special start-of-pass hook.
- * This is called by jpeg_write_scanlines if call_pass_startup is TRUE.
- * In single-pass processing, we need this hook because we don't want to
- * write frame/scan headers during jpeg_start_compress; we want to let the
- * application write COM markers etc. between jpeg_start_compress and the
- * jpeg_write_scanlines loop.
- * In multi-pass processing, this routine is not used.
- */
-
-METHODDEF(void)
-pass_startup(j_compress_ptr cinfo)
-{
- cinfo->master->call_pass_startup = FALSE; /* reset flag so call only once */
-
- (*cinfo->marker->write_frame_header) (cinfo);
- (*cinfo->marker->write_scan_header) (cinfo);
-}
-
-
-/*
- * Finish up at end of pass.
- */
-
-METHODDEF(void)
-finish_pass_master(j_compress_ptr cinfo)
-{
- my_master_ptr master = (my_master_ptr)cinfo->master;
-
- /* The entropy coder always needs an end-of-pass call,
- * either to analyze statistics or to flush its output buffer.
- */
- (*cinfo->entropy->finish_pass) (cinfo);
-
- /* Update state for next pass */
- switch (master->pass_type) {
- case main_pass:
- /* next pass is either output of scan 0 (after optimization)
- * or output of scan 1 (if no optimization).
- */
- master->pass_type = output_pass;
- if (!cinfo->optimize_coding)
- master->scan_number++;
- break;
- case huff_opt_pass:
- /* next pass is always output of current scan */
- master->pass_type = output_pass;
- break;
- case output_pass:
- /* next pass is either optimization or output of next scan */
- if (cinfo->optimize_coding)
- master->pass_type = huff_opt_pass;
- master->scan_number++;
- break;
- }
-
- master->pass_number++;
-}
-
-
-/*
- * Initialize master compression control.
- */
-
-GLOBAL(void)
-jinit_c_master_control(j_compress_ptr cinfo, boolean transcode_only)
-{
- my_master_ptr master;
-
- master = (my_master_ptr)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- sizeof(my_comp_master));
- cinfo->master = (struct jpeg_comp_master *)master;
- master->pub.prepare_for_pass = prepare_for_pass;
- master->pub.pass_startup = pass_startup;
- master->pub.finish_pass = finish_pass_master;
- master->pub.is_last_pass = FALSE;
-
- /* Validate parameters, determine derived values */
- initial_setup(cinfo, transcode_only);
-
- if (cinfo->scan_info != NULL) {
-#ifdef C_MULTISCAN_FILES_SUPPORTED
- validate_script(cinfo);
-#else
- ERREXIT(cinfo, JERR_NOT_COMPILED);
-#endif
- } else {
- cinfo->progressive_mode = FALSE;
- cinfo->num_scans = 1;
- }
-
- if (cinfo->progressive_mode && !cinfo->arith_code) /* TEMPORARY HACK ??? */
- cinfo->optimize_coding = TRUE; /* assume default tables no good for progressive mode */
-
- /* Initialize my private state */
- if (transcode_only) {
- /* no main pass in transcoding */
- if (cinfo->optimize_coding)
- master->pass_type = huff_opt_pass;
- else
- master->pass_type = output_pass;
- } else {
- /* for normal compression, first pass is always this type: */
- master->pass_type = main_pass;
- }
- master->scan_number = 0;
- master->pass_number = 0;
- if (cinfo->optimize_coding)
- master->total_passes = cinfo->num_scans * 2;
- else
- master->total_passes = cinfo->num_scans;
-
- master->jpeg_version = PACKAGE_NAME " version " VERSION " (build " BUILD ")";
-}
diff --git a/contrib/libs/libjpeg-turbo/jcomapi.c b/contrib/libs/libjpeg-turbo/jcomapi.c
deleted file mode 100644
index efbb8357b0..0000000000
--- a/contrib/libs/libjpeg-turbo/jcomapi.c
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * jcomapi.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1994-1997, Thomas G. Lane.
- * It was modified by The libjpeg-turbo Project to include only code relevant
- * to libjpeg-turbo.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains application interface routines that are used for both
- * compression and decompression.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-
-
-/*
- * Abort processing of a JPEG compression or decompression operation,
- * but don't destroy the object itself.
- *
- * For this, we merely clean up all the nonpermanent memory pools.
- * Note that temp files (virtual arrays) are not allowed to belong to
- * the permanent pool, so we will be able to close all temp files here.
- * Closing a data source or destination, if necessary, is the application's
- * responsibility.
- */
-
-GLOBAL(void)
-jpeg_abort(j_common_ptr cinfo)
-{
- int pool;
-
- /* Do nothing if called on a not-initialized or destroyed JPEG object. */
- if (cinfo->mem == NULL)
- return;
-
- /* Releasing pools in reverse order might help avoid fragmentation
- * with some (brain-damaged) malloc libraries.
- */
- for (pool = JPOOL_NUMPOOLS - 1; pool > JPOOL_PERMANENT; pool--) {
- (*cinfo->mem->free_pool) (cinfo, pool);
- }
-
- /* Reset overall state for possible reuse of object */
- if (cinfo->is_decompressor) {
- cinfo->global_state = DSTATE_START;
- /* Try to keep application from accessing now-deleted marker list.
- * A bit kludgy to do it here, but this is the most central place.
- */
- ((j_decompress_ptr)cinfo)->marker_list = NULL;
- } else {
- cinfo->global_state = CSTATE_START;
- }
-}
-
-
-/*
- * Destruction of a JPEG object.
- *
- * Everything gets deallocated except the master jpeg_compress_struct itself
- * and the error manager struct. Both of these are supplied by the application
- * and must be freed, if necessary, by the application. (Often they are on
- * the stack and so don't need to be freed anyway.)
- * Closing a data source or destination, if necessary, is the application's
- * responsibility.
- */
-
-GLOBAL(void)
-jpeg_destroy(j_common_ptr cinfo)
-{
- /* We need only tell the memory manager to release everything. */
- /* NB: mem pointer is NULL if memory mgr failed to initialize. */
- if (cinfo->mem != NULL)
- (*cinfo->mem->self_destruct) (cinfo);
- cinfo->mem = NULL; /* be safe if jpeg_destroy is called twice */
- cinfo->global_state = 0; /* mark it destroyed */
-}
-
-
-/*
- * Convenience routines for allocating quantization and Huffman tables.
- * (Would jutils.c be a more reasonable place to put these?)
- */
-
-GLOBAL(JQUANT_TBL *)
-jpeg_alloc_quant_table(j_common_ptr cinfo)
-{
- JQUANT_TBL *tbl;
-
- tbl = (JQUANT_TBL *)
- (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, sizeof(JQUANT_TBL));
- tbl->sent_table = FALSE; /* make sure this is false in any new table */
- return tbl;
-}
-
-
-GLOBAL(JHUFF_TBL *)
-jpeg_alloc_huff_table(j_common_ptr cinfo)
-{
- JHUFF_TBL *tbl;
-
- tbl = (JHUFF_TBL *)
- (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, sizeof(JHUFF_TBL));
- tbl->sent_table = FALSE; /* make sure this is false in any new table */
- return tbl;
-}
diff --git a/contrib/libs/libjpeg-turbo/jconfig.h b/contrib/libs/libjpeg-turbo/jconfig.h
deleted file mode 100644
index 7dffead627..0000000000
--- a/contrib/libs/libjpeg-turbo/jconfig.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Version ID for the JPEG library.
- * Might be useful for tests like "#if JPEG_LIB_VERSION >= 60".
- */
-#define JPEG_LIB_VERSION 62
-
-/* libjpeg-turbo version */
-#define LIBJPEG_TURBO_VERSION 2.1.4
-
-/* libjpeg-turbo version in integer form */
-#define LIBJPEG_TURBO_VERSION_NUMBER 2001004
-
-/* Support arithmetic encoding */
-#define C_ARITH_CODING_SUPPORTED 1
-
-/* Support arithmetic decoding */
-#define D_ARITH_CODING_SUPPORTED 1
-
-/* Support in-memory source/destination managers */
-#define MEM_SRCDST_SUPPORTED 1
-
-/* Use accelerated SIMD routines. */
-#define WITH_SIMD 1
-
-/*
- * Define BITS_IN_JSAMPLE as either
- * 8 for 8-bit sample values (the usual setting)
- * 12 for 12-bit sample values
- * Only 8 and 12 are legal data precisions for lossy JPEG according to the
- * JPEG standard, and the IJG code does not support anything else!
- * We do not support run-time selection of data precision, sorry.
- */
-
-#define BITS_IN_JSAMPLE 8 /* use 8 or 12 */
-
-/* Define if your (broken) compiler shifts signed values as if they were
- unsigned. */
-/* #undef RIGHT_SHIFT_IS_UNSIGNED */
diff --git a/contrib/libs/libjpeg-turbo/jconfigint-android.h b/contrib/libs/libjpeg-turbo/jconfigint-android.h
deleted file mode 100644
index 0b86dcac5d..0000000000
--- a/contrib/libs/libjpeg-turbo/jconfigint-android.h
+++ /dev/null
@@ -1 +0,0 @@
-#include "jconfigint-linux.h"
diff --git a/contrib/libs/libjpeg-turbo/jconfigint-armv7a.h b/contrib/libs/libjpeg-turbo/jconfigint-armv7a.h
deleted file mode 100644
index 4535ac46ee..0000000000
--- a/contrib/libs/libjpeg-turbo/jconfigint-armv7a.h
+++ /dev/null
@@ -1,2 +0,0 @@
-#undef SIZEOF_SIZE_T
-#define SIZEOF_SIZE_T 4
diff --git a/contrib/libs/libjpeg-turbo/jconfigint-armv8a.h b/contrib/libs/libjpeg-turbo/jconfigint-armv8a.h
deleted file mode 100644
index 4a6d57652d..0000000000
--- a/contrib/libs/libjpeg-turbo/jconfigint-armv8a.h
+++ /dev/null
@@ -1 +0,0 @@
-#define NEON_INTRINSICS 1
diff --git a/contrib/libs/libjpeg-turbo/jconfigint-ios.h b/contrib/libs/libjpeg-turbo/jconfigint-ios.h
deleted file mode 100644
index 0b86dcac5d..0000000000
--- a/contrib/libs/libjpeg-turbo/jconfigint-ios.h
+++ /dev/null
@@ -1 +0,0 @@
-#include "jconfigint-linux.h"
diff --git a/contrib/libs/libjpeg-turbo/jconfigint-linux.h b/contrib/libs/libjpeg-turbo/jconfigint-linux.h
deleted file mode 100644
index 5dfd556850..0000000000
--- a/contrib/libs/libjpeg-turbo/jconfigint-linux.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* libjpeg-turbo build number */
-#define BUILD "19800101"
-
-/* Compiler's inline keyword */
-#undef inline
-
-/* How to obtain function inlining. */
-#define INLINE __inline__ __attribute__((always_inline))
-
-/* How to obtain thread-local storage */
-#define THREAD_LOCAL __thread
-
-/* Define to the full name of this package. */
-#define PACKAGE_NAME "libjpeg-turbo"
-
-/* Version number of package */
-#define VERSION "2.1.4"
-
-/* The size of `size_t', as computed by sizeof. */
-#define SIZEOF_SIZE_T 8
-
-/* Define if your compiler has __builtin_ctzl() and sizeof(unsigned long) == sizeof(size_t). */
-#define HAVE_BUILTIN_CTZL
-
-/* Define to 1 if you have the <intrin.h> header file. */
-/* #undef HAVE_INTRIN_H */
-
-#if defined(_MSC_VER) && defined(HAVE_INTRIN_H)
-#if (SIZEOF_SIZE_T == 8)
-#define HAVE_BITSCANFORWARD64
-#elif (SIZEOF_SIZE_T == 4)
-#define HAVE_BITSCANFORWARD
-#endif
-#endif
-
-#if defined(__has_attribute)
-#if __has_attribute(fallthrough)
-#define FALLTHROUGH __attribute__((fallthrough));
-#else
-#define FALLTHROUGH
-#endif
-#else
-#define FALLTHROUGH
-#endif
diff --git a/contrib/libs/libjpeg-turbo/jconfigint-osx.h b/contrib/libs/libjpeg-turbo/jconfigint-osx.h
deleted file mode 100644
index 0b86dcac5d..0000000000
--- a/contrib/libs/libjpeg-turbo/jconfigint-osx.h
+++ /dev/null
@@ -1 +0,0 @@
-#include "jconfigint-linux.h"
diff --git a/contrib/libs/libjpeg-turbo/jconfigint-win.h b/contrib/libs/libjpeg-turbo/jconfigint-win.h
deleted file mode 100644
index 9fb8aaddfd..0000000000
--- a/contrib/libs/libjpeg-turbo/jconfigint-win.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#include "jconfigint-linux.h"
-
-#undef INLINE
-#define INLINE __forceinline
-
-#undef HAVE_BUILTIN_CTZL
-
-#undef WEAK
-#define WEAK
-
-#undef THREAD_LOCAL
-#define THREAD_LOCAL __declspec(thread)
diff --git a/contrib/libs/libjpeg-turbo/jconfigint-x86.h b/contrib/libs/libjpeg-turbo/jconfigint-x86.h
deleted file mode 100644
index 4535ac46ee..0000000000
--- a/contrib/libs/libjpeg-turbo/jconfigint-x86.h
+++ /dev/null
@@ -1,2 +0,0 @@
-#undef SIZEOF_SIZE_T
-#define SIZEOF_SIZE_T 4
diff --git a/contrib/libs/libjpeg-turbo/jconfigint.h b/contrib/libs/libjpeg-turbo/jconfigint.h
deleted file mode 100644
index 7c29fcac08..0000000000
--- a/contrib/libs/libjpeg-turbo/jconfigint.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#pragma once
-
-#if defined(__ANDROID__)
-# include "jconfigint-android.h"
-#elif defined(__IOS__)
-# include "jconfigint-ios.h"
-#elif defined(__APPLE__)
-# include "jconfigint-osx.h"
-#elif defined(_MSC_VER)
-# include "jconfigint-win.h"
-#else
-# include "jconfigint-linux.h"
-#endif
-
-#if defined(__arm__) || defined(__ARM__)
-# include "jconfigint-armv7a.h"
-#endif
-
-#if defined(__aarch64__) || defined(_M_ARM64)
-# include "jconfigint-armv8a.h"
-#endif
-
-#if defined(__i686__) || defined(_M_IX86)
-# include "jconfigint-x86.h"
-#endif
diff --git a/contrib/libs/libjpeg-turbo/jcparam.c b/contrib/libs/libjpeg-turbo/jcparam.c
deleted file mode 100644
index 5bc7174dcb..0000000000
--- a/contrib/libs/libjpeg-turbo/jcparam.c
+++ /dev/null
@@ -1,541 +0,0 @@
-/*
- * jcparam.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1998, Thomas G. Lane.
- * Modified 2003-2008 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2009-2011, 2018, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains optional default-setting code for the JPEG compressor.
- * Applications do not have to use this file, but those that don't use it
- * must know a lot more about the innards of the JPEG code.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-#include "jstdhuff.c"
-
-
-/*
- * Quantization table setup routines
- */
-
-GLOBAL(void)
-jpeg_add_quant_table(j_compress_ptr cinfo, int which_tbl,
- const unsigned int *basic_table, int scale_factor,
- boolean force_baseline)
-/* Define a quantization table equal to the basic_table times
- * a scale factor (given as a percentage).
- * If force_baseline is TRUE, the computed quantization table entries
- * are limited to 1..255 for JPEG baseline compatibility.
- */
-{
- JQUANT_TBL **qtblptr;
- int i;
- long temp;
-
- /* Safety check to ensure start_compress not called yet. */
- if (cinfo->global_state != CSTATE_START)
- ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
-
- if (which_tbl < 0 || which_tbl >= NUM_QUANT_TBLS)
- ERREXIT1(cinfo, JERR_DQT_INDEX, which_tbl);
-
- qtblptr = &cinfo->quant_tbl_ptrs[which_tbl];
-
- if (*qtblptr == NULL)
- *qtblptr = jpeg_alloc_quant_table((j_common_ptr)cinfo);
-
- for (i = 0; i < DCTSIZE2; i++) {
- temp = ((long)basic_table[i] * scale_factor + 50L) / 100L;
- /* limit the values to the valid range */
- if (temp <= 0L) temp = 1L;
- if (temp > 32767L) temp = 32767L; /* max quantizer needed for 12 bits */
- if (force_baseline && temp > 255L)
- temp = 255L; /* limit to baseline range if requested */
- (*qtblptr)->quantval[i] = (UINT16)temp;
- }
-
- /* Initialize sent_table FALSE so table will be written to JPEG file. */
- (*qtblptr)->sent_table = FALSE;
-}
-
-
-/* These are the sample quantization tables given in Annex K (Clause K.1) of
- * Recommendation ITU-T T.81 (1992) | ISO/IEC 10918-1:1994.
- * The spec says that the values given produce "good" quality, and
- * when divided by 2, "very good" quality.
- */
-static const unsigned int std_luminance_quant_tbl[DCTSIZE2] = {
- 16, 11, 10, 16, 24, 40, 51, 61,
- 12, 12, 14, 19, 26, 58, 60, 55,
- 14, 13, 16, 24, 40, 57, 69, 56,
- 14, 17, 22, 29, 51, 87, 80, 62,
- 18, 22, 37, 56, 68, 109, 103, 77,
- 24, 35, 55, 64, 81, 104, 113, 92,
- 49, 64, 78, 87, 103, 121, 120, 101,
- 72, 92, 95, 98, 112, 100, 103, 99
-};
-static const unsigned int std_chrominance_quant_tbl[DCTSIZE2] = {
- 17, 18, 24, 47, 99, 99, 99, 99,
- 18, 21, 26, 66, 99, 99, 99, 99,
- 24, 26, 56, 99, 99, 99, 99, 99,
- 47, 66, 99, 99, 99, 99, 99, 99,
- 99, 99, 99, 99, 99, 99, 99, 99,
- 99, 99, 99, 99, 99, 99, 99, 99,
- 99, 99, 99, 99, 99, 99, 99, 99,
- 99, 99, 99, 99, 99, 99, 99, 99
-};
-
-
-#if JPEG_LIB_VERSION >= 70
-GLOBAL(void)
-jpeg_default_qtables(j_compress_ptr cinfo, boolean force_baseline)
-/* Set or change the 'quality' (quantization) setting, using default tables
- * and straight percentage-scaling quality scales.
- * This entry point allows different scalings for luminance and chrominance.
- */
-{
- /* Set up two quantization tables using the specified scaling */
- jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl,
- cinfo->q_scale_factor[0], force_baseline);
- jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl,
- cinfo->q_scale_factor[1], force_baseline);
-}
-#endif
-
-
-GLOBAL(void)
-jpeg_set_linear_quality(j_compress_ptr cinfo, int scale_factor,
- boolean force_baseline)
-/* Set or change the 'quality' (quantization) setting, using default tables
- * and a straight percentage-scaling quality scale. In most cases it's better
- * to use jpeg_set_quality (below); this entry point is provided for
- * applications that insist on a linear percentage scaling.
- */
-{
- /* Set up two quantization tables using the specified scaling */
- jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl,
- scale_factor, force_baseline);
- jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl,
- scale_factor, force_baseline);
-}
-
-
-GLOBAL(int)
-jpeg_quality_scaling(int quality)
-/* Convert a user-specified quality rating to a percentage scaling factor
- * for an underlying quantization table, using our recommended scaling curve.
- * The input 'quality' factor should be 0 (terrible) to 100 (very good).
- */
-{
- /* Safety limit on quality factor. Convert 0 to 1 to avoid zero divide. */
- if (quality <= 0) quality = 1;
- if (quality > 100) quality = 100;
-
- /* The basic table is used as-is (scaling 100) for a quality of 50.
- * Qualities 50..100 are converted to scaling percentage 200 - 2*Q;
- * note that at Q=100 the scaling is 0, which will cause jpeg_add_quant_table
- * to make all the table entries 1 (hence, minimum quantization loss).
- * Qualities 1..50 are converted to scaling percentage 5000/Q.
- */
- if (quality < 50)
- quality = 5000 / quality;
- else
- quality = 200 - quality * 2;
-
- return quality;
-}
-
-
-GLOBAL(void)
-jpeg_set_quality(j_compress_ptr cinfo, int quality, boolean force_baseline)
-/* Set or change the 'quality' (quantization) setting, using default tables.
- * This is the standard quality-adjusting entry point for typical user
- * interfaces; only those who want detailed control over quantization tables
- * would use the preceding three routines directly.
- */
-{
- /* Convert user 0-100 rating to percentage scaling */
- quality = jpeg_quality_scaling(quality);
-
- /* Set up standard quality tables */
- jpeg_set_linear_quality(cinfo, quality, force_baseline);
-}
-
-
-/*
- * Default parameter setup for compression.
- *
- * Applications that don't choose to use this routine must do their
- * own setup of all these parameters. Alternately, you can call this
- * to establish defaults and then alter parameters selectively. This
- * is the recommended approach since, if we add any new parameters,
- * your code will still work (they'll be set to reasonable defaults).
- */
-
-GLOBAL(void)
-jpeg_set_defaults(j_compress_ptr cinfo)
-{
- int i;
-
- /* Safety check to ensure start_compress not called yet. */
- if (cinfo->global_state != CSTATE_START)
- ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
-
- /* Allocate comp_info array large enough for maximum component count.
- * Array is made permanent in case application wants to compress
- * multiple images at same param settings.
- */
- if (cinfo->comp_info == NULL)
- cinfo->comp_info = (jpeg_component_info *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
- MAX_COMPONENTS * sizeof(jpeg_component_info));
-
- /* Initialize everything not dependent on the color space */
-
-#if JPEG_LIB_VERSION >= 70
- cinfo->scale_num = 1; /* 1:1 scaling */
- cinfo->scale_denom = 1;
-#endif
- cinfo->data_precision = BITS_IN_JSAMPLE;
- /* Set up two quantization tables using default quality of 75 */
- jpeg_set_quality(cinfo, 75, TRUE);
- /* Set up two Huffman tables */
- std_huff_tables((j_common_ptr)cinfo);
-
- /* Initialize default arithmetic coding conditioning */
- for (i = 0; i < NUM_ARITH_TBLS; i++) {
- cinfo->arith_dc_L[i] = 0;
- cinfo->arith_dc_U[i] = 1;
- cinfo->arith_ac_K[i] = 5;
- }
-
- /* Default is no multiple-scan output */
- cinfo->scan_info = NULL;
- cinfo->num_scans = 0;
-
- /* Expect normal source image, not raw downsampled data */
- cinfo->raw_data_in = FALSE;
-
- /* Use Huffman coding, not arithmetic coding, by default */
- cinfo->arith_code = FALSE;
-
- /* By default, don't do extra passes to optimize entropy coding */
- cinfo->optimize_coding = FALSE;
- /* The standard Huffman tables are only valid for 8-bit data precision.
- * If the precision is higher, force optimization on so that usable
- * tables will be computed. This test can be removed if default tables
- * are supplied that are valid for the desired precision.
- */
- if (cinfo->data_precision > 8)
- cinfo->optimize_coding = TRUE;
-
- /* By default, use the simpler non-cosited sampling alignment */
- cinfo->CCIR601_sampling = FALSE;
-
-#if JPEG_LIB_VERSION >= 70
- /* By default, apply fancy downsampling */
- cinfo->do_fancy_downsampling = TRUE;
-#endif
-
- /* No input smoothing */
- cinfo->smoothing_factor = 0;
-
- /* DCT algorithm preference */
- cinfo->dct_method = JDCT_DEFAULT;
-
- /* No restart markers */
- cinfo->restart_interval = 0;
- cinfo->restart_in_rows = 0;
-
- /* Fill in default JFIF marker parameters. Note that whether the marker
- * will actually be written is determined by jpeg_set_colorspace.
- *
- * By default, the library emits JFIF version code 1.01.
- * An application that wants to emit JFIF 1.02 extension markers should set
- * JFIF_minor_version to 2. We could probably get away with just defaulting
- * to 1.02, but there may still be some decoders in use that will complain
- * about that; saying 1.01 should minimize compatibility problems.
- */
- cinfo->JFIF_major_version = 1; /* Default JFIF version = 1.01 */
- cinfo->JFIF_minor_version = 1;
- cinfo->density_unit = 0; /* Pixel size is unknown by default */
- cinfo->X_density = 1; /* Pixel aspect ratio is square by default */
- cinfo->Y_density = 1;
-
- /* Choose JPEG colorspace based on input space, set defaults accordingly */
-
- jpeg_default_colorspace(cinfo);
-}
-
-
-/*
- * Select an appropriate JPEG colorspace for in_color_space.
- */
-
-GLOBAL(void)
-jpeg_default_colorspace(j_compress_ptr cinfo)
-{
- switch (cinfo->in_color_space) {
- case JCS_GRAYSCALE:
- jpeg_set_colorspace(cinfo, JCS_GRAYSCALE);
- break;
- case JCS_RGB:
- case JCS_EXT_RGB:
- case JCS_EXT_RGBX:
- case JCS_EXT_BGR:
- case JCS_EXT_BGRX:
- case JCS_EXT_XBGR:
- case JCS_EXT_XRGB:
- case JCS_EXT_RGBA:
- case JCS_EXT_BGRA:
- case JCS_EXT_ABGR:
- case JCS_EXT_ARGB:
- jpeg_set_colorspace(cinfo, JCS_YCbCr);
- break;
- case JCS_YCbCr:
- jpeg_set_colorspace(cinfo, JCS_YCbCr);
- break;
- case JCS_CMYK:
- jpeg_set_colorspace(cinfo, JCS_CMYK); /* By default, no translation */
- break;
- case JCS_YCCK:
- jpeg_set_colorspace(cinfo, JCS_YCCK);
- break;
- case JCS_UNKNOWN:
- jpeg_set_colorspace(cinfo, JCS_UNKNOWN);
- break;
- default:
- ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
- }
-}
-
-
-/*
- * Set the JPEG colorspace, and choose colorspace-dependent default values.
- */
-
-GLOBAL(void)
-jpeg_set_colorspace(j_compress_ptr cinfo, J_COLOR_SPACE colorspace)
-{
- jpeg_component_info *compptr;
- int ci;
-
-#define SET_COMP(index, id, hsamp, vsamp, quant, dctbl, actbl) \
- (compptr = &cinfo->comp_info[index], \
- compptr->component_id = (id), \
- compptr->h_samp_factor = (hsamp), \
- compptr->v_samp_factor = (vsamp), \
- compptr->quant_tbl_no = (quant), \
- compptr->dc_tbl_no = (dctbl), \
- compptr->ac_tbl_no = (actbl) )
-
- /* Safety check to ensure start_compress not called yet. */
- if (cinfo->global_state != CSTATE_START)
- ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
-
- /* For all colorspaces, we use Q and Huff tables 0 for luminance components,
- * tables 1 for chrominance components.
- */
-
- cinfo->jpeg_color_space = colorspace;
-
- cinfo->write_JFIF_header = FALSE; /* No marker for non-JFIF colorspaces */
- cinfo->write_Adobe_marker = FALSE; /* write no Adobe marker by default */
-
- switch (colorspace) {
- case JCS_GRAYSCALE:
- cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */
- cinfo->num_components = 1;
- /* JFIF specifies component ID 1 */
- SET_COMP(0, 1, 1, 1, 0, 0, 0);
- break;
- case JCS_RGB:
- cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag RGB */
- cinfo->num_components = 3;
- SET_COMP(0, 0x52 /* 'R' */, 1, 1, 0, 0, 0);
- SET_COMP(1, 0x47 /* 'G' */, 1, 1, 0, 0, 0);
- SET_COMP(2, 0x42 /* 'B' */, 1, 1, 0, 0, 0);
- break;
- case JCS_YCbCr:
- cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */
- cinfo->num_components = 3;
- /* JFIF specifies component IDs 1,2,3 */
- /* We default to 2x2 subsamples of chrominance */
- SET_COMP(0, 1, 2, 2, 0, 0, 0);
- SET_COMP(1, 2, 1, 1, 1, 1, 1);
- SET_COMP(2, 3, 1, 1, 1, 1, 1);
- break;
- case JCS_CMYK:
- cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag CMYK */
- cinfo->num_components = 4;
- SET_COMP(0, 0x43 /* 'C' */, 1, 1, 0, 0, 0);
- SET_COMP(1, 0x4D /* 'M' */, 1, 1, 0, 0, 0);
- SET_COMP(2, 0x59 /* 'Y' */, 1, 1, 0, 0, 0);
- SET_COMP(3, 0x4B /* 'K' */, 1, 1, 0, 0, 0);
- break;
- case JCS_YCCK:
- cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag YCCK */
- cinfo->num_components = 4;
- SET_COMP(0, 1, 2, 2, 0, 0, 0);
- SET_COMP(1, 2, 1, 1, 1, 1, 1);
- SET_COMP(2, 3, 1, 1, 1, 1, 1);
- SET_COMP(3, 4, 2, 2, 0, 0, 0);
- break;
- case JCS_UNKNOWN:
- cinfo->num_components = cinfo->input_components;
- if (cinfo->num_components < 1 || cinfo->num_components > MAX_COMPONENTS)
- ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components,
- MAX_COMPONENTS);
- for (ci = 0; ci < cinfo->num_components; ci++) {
- SET_COMP(ci, ci, 1, 1, 0, 0, 0);
- }
- break;
- default:
- ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
- }
-}
-
-
-#ifdef C_PROGRESSIVE_SUPPORTED
-
-LOCAL(jpeg_scan_info *)
-fill_a_scan(jpeg_scan_info *scanptr, int ci, int Ss, int Se, int Ah, int Al)
-/* Support routine: generate one scan for specified component */
-{
- scanptr->comps_in_scan = 1;
- scanptr->component_index[0] = ci;
- scanptr->Ss = Ss;
- scanptr->Se = Se;
- scanptr->Ah = Ah;
- scanptr->Al = Al;
- scanptr++;
- return scanptr;
-}
-
-LOCAL(jpeg_scan_info *)
-fill_scans(jpeg_scan_info *scanptr, int ncomps, int Ss, int Se, int Ah, int Al)
-/* Support routine: generate one scan for each component */
-{
- int ci;
-
- for (ci = 0; ci < ncomps; ci++) {
- scanptr->comps_in_scan = 1;
- scanptr->component_index[0] = ci;
- scanptr->Ss = Ss;
- scanptr->Se = Se;
- scanptr->Ah = Ah;
- scanptr->Al = Al;
- scanptr++;
- }
- return scanptr;
-}
-
-LOCAL(jpeg_scan_info *)
-fill_dc_scans(jpeg_scan_info *scanptr, int ncomps, int Ah, int Al)
-/* Support routine: generate interleaved DC scan if possible, else N scans */
-{
- int ci;
-
- if (ncomps <= MAX_COMPS_IN_SCAN) {
- /* Single interleaved DC scan */
- scanptr->comps_in_scan = ncomps;
- for (ci = 0; ci < ncomps; ci++)
- scanptr->component_index[ci] = ci;
- scanptr->Ss = scanptr->Se = 0;
- scanptr->Ah = Ah;
- scanptr->Al = Al;
- scanptr++;
- } else {
- /* Noninterleaved DC scan for each component */
- scanptr = fill_scans(scanptr, ncomps, 0, 0, Ah, Al);
- }
- return scanptr;
-}
-
-
-/*
- * Create a recommended progressive-JPEG script.
- * cinfo->num_components and cinfo->jpeg_color_space must be correct.
- */
-
-GLOBAL(void)
-jpeg_simple_progression(j_compress_ptr cinfo)
-{
- int ncomps = cinfo->num_components;
- int nscans;
- jpeg_scan_info *scanptr;
-
- /* Safety check to ensure start_compress not called yet. */
- if (cinfo->global_state != CSTATE_START)
- ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
-
- /* Figure space needed for script. Calculation must match code below! */
- if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) {
- /* Custom script for YCbCr color images. */
- nscans = 10;
- } else {
- /* All-purpose script for other color spaces. */
- if (ncomps > MAX_COMPS_IN_SCAN)
- nscans = 6 * ncomps; /* 2 DC + 4 AC scans per component */
- else
- nscans = 2 + 4 * ncomps; /* 2 DC scans; 4 AC scans per component */
- }
-
- /* Allocate space for script.
- * We need to put it in the permanent pool in case the application performs
- * multiple compressions without changing the settings. To avoid a memory
- * leak if jpeg_simple_progression is called repeatedly for the same JPEG
- * object, we try to re-use previously allocated space, and we allocate
- * enough space to handle YCbCr even if initially asked for grayscale.
- */
- if (cinfo->script_space == NULL || cinfo->script_space_size < nscans) {
- cinfo->script_space_size = MAX(nscans, 10);
- cinfo->script_space = (jpeg_scan_info *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
- cinfo->script_space_size * sizeof(jpeg_scan_info));
- }
- scanptr = cinfo->script_space;
- cinfo->scan_info = scanptr;
- cinfo->num_scans = nscans;
-
- if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) {
- /* Custom script for YCbCr color images. */
- /* Initial DC scan */
- scanptr = fill_dc_scans(scanptr, ncomps, 0, 1);
- /* Initial AC scan: get some luma data out in a hurry */
- scanptr = fill_a_scan(scanptr, 0, 1, 5, 0, 2);
- /* Chroma data is too small to be worth expending many scans on */
- scanptr = fill_a_scan(scanptr, 2, 1, 63, 0, 1);
- scanptr = fill_a_scan(scanptr, 1, 1, 63, 0, 1);
- /* Complete spectral selection for luma AC */
- scanptr = fill_a_scan(scanptr, 0, 6, 63, 0, 2);
- /* Refine next bit of luma AC */
- scanptr = fill_a_scan(scanptr, 0, 1, 63, 2, 1);
- /* Finish DC successive approximation */
- scanptr = fill_dc_scans(scanptr, ncomps, 1, 0);
- /* Finish AC successive approximation */
- scanptr = fill_a_scan(scanptr, 2, 1, 63, 1, 0);
- scanptr = fill_a_scan(scanptr, 1, 1, 63, 1, 0);
- /* Luma bottom bit comes last since it's usually largest scan */
- scanptr = fill_a_scan(scanptr, 0, 1, 63, 1, 0);
- } else {
- /* All-purpose script for other color spaces. */
- /* Successive approximation first pass */
- scanptr = fill_dc_scans(scanptr, ncomps, 0, 1);
- scanptr = fill_scans(scanptr, ncomps, 1, 5, 0, 2);
- scanptr = fill_scans(scanptr, ncomps, 6, 63, 0, 2);
- /* Successive approximation second pass */
- scanptr = fill_scans(scanptr, ncomps, 1, 63, 2, 1);
- /* Successive approximation final pass */
- scanptr = fill_dc_scans(scanptr, ncomps, 1, 0);
- scanptr = fill_scans(scanptr, ncomps, 1, 63, 1, 0);
- }
-}
-
-#endif /* C_PROGRESSIVE_SUPPORTED */
diff --git a/contrib/libs/libjpeg-turbo/jcphuff.c b/contrib/libs/libjpeg-turbo/jcphuff.c
deleted file mode 100644
index 872e570bff..0000000000
--- a/contrib/libs/libjpeg-turbo/jcphuff.c
+++ /dev/null
@@ -1,1114 +0,0 @@
-/*
- * jcphuff.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1995-1997, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2011, 2015, 2018, 2021-2022, D. R. Commander.
- * Copyright (C) 2016, 2018, Matthieu Darbois.
- * Copyright (C) 2020, Arm Limited.
- * Copyright (C) 2021, Alex Richardson.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains Huffman entropy encoding routines for progressive JPEG.
- *
- * We do not support output suspension in this module, since the library
- * currently does not allow multiple-scan files to be written with output
- * suspension.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-#include "jsimd.h"
-#include "jconfigint.h"
-#include <limits.h>
-
-#ifdef HAVE_INTRIN_H
-#include <intrin.h>
-#ifdef _MSC_VER
-#ifdef HAVE_BITSCANFORWARD64
-#pragma intrinsic(_BitScanForward64)
-#endif
-#ifdef HAVE_BITSCANFORWARD
-#pragma intrinsic(_BitScanForward)
-#endif
-#endif
-#endif
-
-#ifdef C_PROGRESSIVE_SUPPORTED
-
-/*
- * NOTE: If USE_CLZ_INTRINSIC is defined, then clz/bsr instructions will be
- * used for bit counting rather than the lookup table. This will reduce the
- * memory footprint by 64k, which is important for some mobile applications
- * that create many isolated instances of libjpeg-turbo (web browsers, for
- * instance.) This may improve performance on some mobile platforms as well.
- * This feature is enabled by default only on Arm processors, because some x86
- * chips have a slow implementation of bsr, and the use of clz/bsr cannot be
- * shown to have a significant performance impact even on the x86 chips that
- * have a fast implementation of it. When building for Armv6, you can
- * explicitly disable the use of clz/bsr by adding -mthumb to the compiler
- * flags (this defines __thumb__).
- */
-
-/* NOTE: Both GCC and Clang define __GNUC__ */
-#if (defined(__GNUC__) && (defined(__arm__) || defined(__aarch64__))) || \
- defined(_M_ARM) || defined(_M_ARM64)
-#if !defined(__thumb__) || defined(__thumb2__)
-#define USE_CLZ_INTRINSIC
-#endif
-#endif
-
-#ifdef USE_CLZ_INTRINSIC
-#if defined(_MSC_VER) && !defined(__clang__)
-#define JPEG_NBITS_NONZERO(x) (32 - _CountLeadingZeros(x))
-#else
-#define JPEG_NBITS_NONZERO(x) (32 - __builtin_clz(x))
-#endif
-#define JPEG_NBITS(x) (x ? JPEG_NBITS_NONZERO(x) : 0)
-#else
-#include "jpeg_nbits_table.h"
-#define JPEG_NBITS(x) (jpeg_nbits_table[x])
-#define JPEG_NBITS_NONZERO(x) JPEG_NBITS(x)
-#endif
-
-
-/* Expanded entropy encoder object for progressive Huffman encoding. */
-
-typedef struct {
- struct jpeg_entropy_encoder pub; /* public fields */
-
- /* Pointer to routine to prepare data for encode_mcu_AC_first() */
- void (*AC_first_prepare) (const JCOEF *block,
- const int *jpeg_natural_order_start, int Sl,
- int Al, JCOEF *values, size_t *zerobits);
- /* Pointer to routine to prepare data for encode_mcu_AC_refine() */
- int (*AC_refine_prepare) (const JCOEF *block,
- const int *jpeg_natural_order_start, int Sl,
- int Al, JCOEF *absvalues, size_t *bits);
-
- /* Mode flag: TRUE for optimization, FALSE for actual data output */
- boolean gather_statistics;
-
- /* Bit-level coding status.
- * next_output_byte/free_in_buffer are local copies of cinfo->dest fields.
- */
- JOCTET *next_output_byte; /* => next byte to write in buffer */
- size_t free_in_buffer; /* # of byte spaces remaining in buffer */
- size_t put_buffer; /* current bit-accumulation buffer */
- int put_bits; /* # of bits now in it */
- j_compress_ptr cinfo; /* link to cinfo (needed for dump_buffer) */
-
- /* Coding status for DC components */
- int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */
-
- /* Coding status for AC components */
- int ac_tbl_no; /* the table number of the single component */
- unsigned int EOBRUN; /* run length of EOBs */
- unsigned int BE; /* # of buffered correction bits before MCU */
- char *bit_buffer; /* buffer for correction bits (1 per char) */
- /* packing correction bits tightly would save some space but cost time... */
-
- unsigned int restarts_to_go; /* MCUs left in this restart interval */
- int next_restart_num; /* next restart number to write (0-7) */
-
- /* Pointers to derived tables (these workspaces have image lifespan).
- * Since any one scan codes only DC or only AC, we only need one set
- * of tables, not one for DC and one for AC.
- */
- c_derived_tbl *derived_tbls[NUM_HUFF_TBLS];
-
- /* Statistics tables for optimization; again, one set is enough */
- long *count_ptrs[NUM_HUFF_TBLS];
-} phuff_entropy_encoder;
-
-typedef phuff_entropy_encoder *phuff_entropy_ptr;
-
-/* MAX_CORR_BITS is the number of bits the AC refinement correction-bit
- * buffer can hold. Larger sizes may slightly improve compression, but
- * 1000 is already well into the realm of overkill.
- * The minimum safe size is 64 bits.
- */
-
-#define MAX_CORR_BITS 1000 /* Max # of correction bits I can buffer */
-
-/* IRIGHT_SHIFT is like RIGHT_SHIFT, but works on int rather than JLONG.
- * We assume that int right shift is unsigned if JLONG right shift is,
- * which should be safe.
- */
-
-#ifdef RIGHT_SHIFT_IS_UNSIGNED
-#define ISHIFT_TEMPS int ishift_temp;
-#define IRIGHT_SHIFT(x, shft) \
- ((ishift_temp = (x)) < 0 ? \
- (ishift_temp >> (shft)) | ((~0) << (16 - (shft))) : \
- (ishift_temp >> (shft)))
-#else
-#define ISHIFT_TEMPS
-#define IRIGHT_SHIFT(x, shft) ((x) >> (shft))
-#endif
-
-#define PAD(v, p) ((v + (p) - 1) & (~((p) - 1)))
-
-/* Forward declarations */
-METHODDEF(boolean) encode_mcu_DC_first(j_compress_ptr cinfo,
- JBLOCKROW *MCU_data);
-METHODDEF(void) encode_mcu_AC_first_prepare
- (const JCOEF *block, const int *jpeg_natural_order_start, int Sl, int Al,
- JCOEF *values, size_t *zerobits);
-METHODDEF(boolean) encode_mcu_AC_first(j_compress_ptr cinfo,
- JBLOCKROW *MCU_data);
-METHODDEF(boolean) encode_mcu_DC_refine(j_compress_ptr cinfo,
- JBLOCKROW *MCU_data);
-METHODDEF(int) encode_mcu_AC_refine_prepare
- (const JCOEF *block, const int *jpeg_natural_order_start, int Sl, int Al,
- JCOEF *absvalues, size_t *bits);
-METHODDEF(boolean) encode_mcu_AC_refine(j_compress_ptr cinfo,
- JBLOCKROW *MCU_data);
-METHODDEF(void) finish_pass_phuff(j_compress_ptr cinfo);
-METHODDEF(void) finish_pass_gather_phuff(j_compress_ptr cinfo);
-
-
-/* Count bit loop zeroes */
-INLINE
-METHODDEF(int)
-count_zeroes(size_t *x)
-{
-#if defined(HAVE_BUILTIN_CTZL)
- int result;
- result = __builtin_ctzl(*x);
- *x >>= result;
-#elif defined(HAVE_BITSCANFORWARD64)
- unsigned long result;
- _BitScanForward64(&result, *x);
- *x >>= result;
-#elif defined(HAVE_BITSCANFORWARD)
- unsigned long result;
- _BitScanForward(&result, *x);
- *x >>= result;
-#else
- int result = 0;
- while ((*x & 1) == 0) {
- ++result;
- *x >>= 1;
- }
-#endif
- return (int)result;
-}
-
-
-/*
- * Initialize for a Huffman-compressed scan using progressive JPEG.
- */
-
-METHODDEF(void)
-start_pass_phuff(j_compress_ptr cinfo, boolean gather_statistics)
-{
- phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
- boolean is_DC_band;
- int ci, tbl;
- jpeg_component_info *compptr;
-
- entropy->cinfo = cinfo;
- entropy->gather_statistics = gather_statistics;
-
- is_DC_band = (cinfo->Ss == 0);
-
- /* We assume jcmaster.c already validated the scan parameters. */
-
- /* Select execution routines */
- if (cinfo->Ah == 0) {
- if (is_DC_band)
- entropy->pub.encode_mcu = encode_mcu_DC_first;
- else
- entropy->pub.encode_mcu = encode_mcu_AC_first;
- if (jsimd_can_encode_mcu_AC_first_prepare())
- entropy->AC_first_prepare = jsimd_encode_mcu_AC_first_prepare;
- else
- entropy->AC_first_prepare = encode_mcu_AC_first_prepare;
- } else {
- if (is_DC_band)
- entropy->pub.encode_mcu = encode_mcu_DC_refine;
- else {
- entropy->pub.encode_mcu = encode_mcu_AC_refine;
- if (jsimd_can_encode_mcu_AC_refine_prepare())
- entropy->AC_refine_prepare = jsimd_encode_mcu_AC_refine_prepare;
- else
- entropy->AC_refine_prepare = encode_mcu_AC_refine_prepare;
- /* AC refinement needs a correction bit buffer */
- if (entropy->bit_buffer == NULL)
- entropy->bit_buffer = (char *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- MAX_CORR_BITS * sizeof(char));
- }
- }
- if (gather_statistics)
- entropy->pub.finish_pass = finish_pass_gather_phuff;
- else
- entropy->pub.finish_pass = finish_pass_phuff;
-
- /* Only DC coefficients may be interleaved, so cinfo->comps_in_scan = 1
- * for AC coefficients.
- */
- for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
- compptr = cinfo->cur_comp_info[ci];
- /* Initialize DC predictions to 0 */
- entropy->last_dc_val[ci] = 0;
- /* Get table index */
- if (is_DC_band) {
- if (cinfo->Ah != 0) /* DC refinement needs no table */
- continue;
- tbl = compptr->dc_tbl_no;
- } else {
- entropy->ac_tbl_no = tbl = compptr->ac_tbl_no;
- }
- if (gather_statistics) {
- /* Check for invalid table index */
- /* (make_c_derived_tbl does this in the other path) */
- if (tbl < 0 || tbl >= NUM_HUFF_TBLS)
- ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tbl);
- /* Allocate and zero the statistics tables */
- /* Note that jpeg_gen_optimal_table expects 257 entries in each table! */
- if (entropy->count_ptrs[tbl] == NULL)
- entropy->count_ptrs[tbl] = (long *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- 257 * sizeof(long));
- memset(entropy->count_ptrs[tbl], 0, 257 * sizeof(long));
- } else {
- /* Compute derived values for Huffman table */
- /* We may do this more than once for a table, but it's not expensive */
- jpeg_make_c_derived_tbl(cinfo, is_DC_band, tbl,
- &entropy->derived_tbls[tbl]);
- }
- }
-
- /* Initialize AC stuff */
- entropy->EOBRUN = 0;
- entropy->BE = 0;
-
- /* Initialize bit buffer to empty */
- entropy->put_buffer = 0;
- entropy->put_bits = 0;
-
- /* Initialize restart stuff */
- entropy->restarts_to_go = cinfo->restart_interval;
- entropy->next_restart_num = 0;
-}
-
-
-/* Outputting bytes to the file.
- * NB: these must be called only when actually outputting,
- * that is, entropy->gather_statistics == FALSE.
- */
-
-/* Emit a byte */
-#define emit_byte(entropy, val) { \
- *(entropy)->next_output_byte++ = (JOCTET)(val); \
- if (--(entropy)->free_in_buffer == 0) \
- dump_buffer(entropy); \
-}
-
-
-LOCAL(void)
-dump_buffer(phuff_entropy_ptr entropy)
-/* Empty the output buffer; we do not support suspension in this module. */
-{
- struct jpeg_destination_mgr *dest = entropy->cinfo->dest;
-
- if (!(*dest->empty_output_buffer) (entropy->cinfo))
- ERREXIT(entropy->cinfo, JERR_CANT_SUSPEND);
- /* After a successful buffer dump, must reset buffer pointers */
- entropy->next_output_byte = dest->next_output_byte;
- entropy->free_in_buffer = dest->free_in_buffer;
-}
-
-
-/* Outputting bits to the file */
-
-/* Only the right 24 bits of put_buffer are used; the valid bits are
- * left-justified in this part. At most 16 bits can be passed to emit_bits
- * in one call, and we never retain more than 7 bits in put_buffer
- * between calls, so 24 bits are sufficient.
- */
-
-LOCAL(void)
-emit_bits(phuff_entropy_ptr entropy, unsigned int code, int size)
-/* Emit some bits, unless we are in gather mode */
-{
- /* This routine is heavily used, so it's worth coding tightly. */
- register size_t put_buffer = (size_t)code;
- register int put_bits = entropy->put_bits;
-
- /* if size is 0, caller used an invalid Huffman table entry */
- if (size == 0)
- ERREXIT(entropy->cinfo, JERR_HUFF_MISSING_CODE);
-
- if (entropy->gather_statistics)
- return; /* do nothing if we're only getting stats */
-
- put_buffer &= (((size_t)1) << size) - 1; /* mask off any extra bits in code */
-
- put_bits += size; /* new number of bits in buffer */
-
- put_buffer <<= 24 - put_bits; /* align incoming bits */
-
- put_buffer |= entropy->put_buffer; /* and merge with old buffer contents */
-
- while (put_bits >= 8) {
- int c = (int)((put_buffer >> 16) & 0xFF);
-
- emit_byte(entropy, c);
- if (c == 0xFF) { /* need to stuff a zero byte? */
- emit_byte(entropy, 0);
- }
- put_buffer <<= 8;
- put_bits -= 8;
- }
-
- entropy->put_buffer = put_buffer; /* update variables */
- entropy->put_bits = put_bits;
-}
-
-
-LOCAL(void)
-flush_bits(phuff_entropy_ptr entropy)
-{
- emit_bits(entropy, 0x7F, 7); /* fill any partial byte with ones */
- entropy->put_buffer = 0; /* and reset bit-buffer to empty */
- entropy->put_bits = 0;
-}
-
-
-/*
- * Emit (or just count) a Huffman symbol.
- */
-
-LOCAL(void)
-emit_symbol(phuff_entropy_ptr entropy, int tbl_no, int symbol)
-{
- if (entropy->gather_statistics)
- entropy->count_ptrs[tbl_no][symbol]++;
- else {
- c_derived_tbl *tbl = entropy->derived_tbls[tbl_no];
- emit_bits(entropy, tbl->ehufco[symbol], tbl->ehufsi[symbol]);
- }
-}
-
-
-/*
- * Emit bits from a correction bit buffer.
- */
-
-LOCAL(void)
-emit_buffered_bits(phuff_entropy_ptr entropy, char *bufstart,
- unsigned int nbits)
-{
- if (entropy->gather_statistics)
- return; /* no real work */
-
- while (nbits > 0) {
- emit_bits(entropy, (unsigned int)(*bufstart), 1);
- bufstart++;
- nbits--;
- }
-}
-
-
-/*
- * Emit any pending EOBRUN symbol.
- */
-
-LOCAL(void)
-emit_eobrun(phuff_entropy_ptr entropy)
-{
- register int temp, nbits;
-
- if (entropy->EOBRUN > 0) { /* if there is any pending EOBRUN */
- temp = entropy->EOBRUN;
- nbits = JPEG_NBITS_NONZERO(temp) - 1;
- /* safety check: shouldn't happen given limited correction-bit buffer */
- if (nbits > 14)
- ERREXIT(entropy->cinfo, JERR_HUFF_MISSING_CODE);
-
- emit_symbol(entropy, entropy->ac_tbl_no, nbits << 4);
- if (nbits)
- emit_bits(entropy, entropy->EOBRUN, nbits);
-
- entropy->EOBRUN = 0;
-
- /* Emit any buffered correction bits */
- emit_buffered_bits(entropy, entropy->bit_buffer, entropy->BE);
- entropy->BE = 0;
- }
-}
-
-
-/*
- * Emit a restart marker & resynchronize predictions.
- */
-
-LOCAL(void)
-emit_restart(phuff_entropy_ptr entropy, int restart_num)
-{
- int ci;
-
- emit_eobrun(entropy);
-
- if (!entropy->gather_statistics) {
- flush_bits(entropy);
- emit_byte(entropy, 0xFF);
- emit_byte(entropy, JPEG_RST0 + restart_num);
- }
-
- if (entropy->cinfo->Ss == 0) {
- /* Re-initialize DC predictions to 0 */
- for (ci = 0; ci < entropy->cinfo->comps_in_scan; ci++)
- entropy->last_dc_val[ci] = 0;
- } else {
- /* Re-initialize all AC-related fields to 0 */
- entropy->EOBRUN = 0;
- entropy->BE = 0;
- }
-}
-
-
-/*
- * MCU encoding for DC initial scan (either spectral selection,
- * or first pass of successive approximation).
- */
-
-METHODDEF(boolean)
-encode_mcu_DC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
-{
- phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
- register int temp, temp2, temp3;
- register int nbits;
- int blkn, ci;
- int Al = cinfo->Al;
- JBLOCKROW block;
- jpeg_component_info *compptr;
- ISHIFT_TEMPS
-
- entropy->next_output_byte = cinfo->dest->next_output_byte;
- entropy->free_in_buffer = cinfo->dest->free_in_buffer;
-
- /* Emit restart marker if needed */
- if (cinfo->restart_interval)
- if (entropy->restarts_to_go == 0)
- emit_restart(entropy, entropy->next_restart_num);
-
- /* Encode the MCU data blocks */
- for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
- block = MCU_data[blkn];
- ci = cinfo->MCU_membership[blkn];
- compptr = cinfo->cur_comp_info[ci];
-
- /* Compute the DC value after the required point transform by Al.
- * This is simply an arithmetic right shift.
- */
- temp2 = IRIGHT_SHIFT((int)((*block)[0]), Al);
-
- /* DC differences are figured on the point-transformed values. */
- temp = temp2 - entropy->last_dc_val[ci];
- entropy->last_dc_val[ci] = temp2;
-
- /* Encode the DC coefficient difference per section G.1.2.1 */
-
- /* This is a well-known technique for obtaining the absolute value without
- * a branch. It is derived from an assembly language technique presented
- * in "How to Optimize for the Pentium Processors", Copyright (c) 1996,
- * 1997 by Agner Fog.
- */
- temp3 = temp >> (CHAR_BIT * sizeof(int) - 1);
- temp ^= temp3;
- temp -= temp3; /* temp is abs value of input */
- /* For a negative input, want temp2 = bitwise complement of abs(input) */
- temp2 = temp ^ temp3;
-
- /* Find the number of bits needed for the magnitude of the coefficient */
- nbits = JPEG_NBITS(temp);
- /* Check for out-of-range coefficient values.
- * Since we're encoding a difference, the range limit is twice as much.
- */
- if (nbits > MAX_COEF_BITS + 1)
- ERREXIT(cinfo, JERR_BAD_DCT_COEF);
-
- /* Count/emit the Huffman-coded symbol for the number of bits */
- emit_symbol(entropy, compptr->dc_tbl_no, nbits);
-
- /* Emit that number of bits of the value, if positive, */
- /* or the complement of its magnitude, if negative. */
- if (nbits) /* emit_bits rejects calls with size 0 */
- emit_bits(entropy, (unsigned int)temp2, nbits);
- }
-
- cinfo->dest->next_output_byte = entropy->next_output_byte;
- cinfo->dest->free_in_buffer = entropy->free_in_buffer;
-
- /* Update restart-interval state too */
- if (cinfo->restart_interval) {
- if (entropy->restarts_to_go == 0) {
- entropy->restarts_to_go = cinfo->restart_interval;
- entropy->next_restart_num++;
- entropy->next_restart_num &= 7;
- }
- entropy->restarts_to_go--;
- }
-
- return TRUE;
-}
-
-
-/*
- * Data preparation for encode_mcu_AC_first().
- */
-
-#define COMPUTE_ABSVALUES_AC_FIRST(Sl) { \
- for (k = 0; k < Sl; k++) { \
- temp = block[jpeg_natural_order_start[k]]; \
- if (temp == 0) \
- continue; \
- /* We must apply the point transform by Al. For AC coefficients this \
- * is an integer division with rounding towards 0. To do this portably \
- * in C, we shift after obtaining the absolute value; so the code is \
- * interwoven with finding the abs value (temp) and output bits (temp2). \
- */ \
- temp2 = temp >> (CHAR_BIT * sizeof(int) - 1); \
- temp ^= temp2; \
- temp -= temp2; /* temp is abs value of input */ \
- temp >>= Al; /* apply the point transform */ \
- /* Watch out for case that nonzero coef is zero after point transform */ \
- if (temp == 0) \
- continue; \
- /* For a negative coef, want temp2 = bitwise complement of abs(coef) */ \
- temp2 ^= temp; \
- values[k] = (JCOEF)temp; \
- values[k + DCTSIZE2] = (JCOEF)temp2; \
- zerobits |= ((size_t)1U) << k; \
- } \
-}
-
-METHODDEF(void)
-encode_mcu_AC_first_prepare(const JCOEF *block,
- const int *jpeg_natural_order_start, int Sl,
- int Al, JCOEF *values, size_t *bits)
-{
- register int k, temp, temp2;
- size_t zerobits = 0U;
- int Sl0 = Sl;
-
-#if SIZEOF_SIZE_T == 4
- if (Sl0 > 32)
- Sl0 = 32;
-#endif
-
- COMPUTE_ABSVALUES_AC_FIRST(Sl0);
-
- bits[0] = zerobits;
-#if SIZEOF_SIZE_T == 4
- zerobits = 0U;
-
- if (Sl > 32) {
- Sl -= 32;
- jpeg_natural_order_start += 32;
- values += 32;
-
- COMPUTE_ABSVALUES_AC_FIRST(Sl);
- }
- bits[1] = zerobits;
-#endif
-}
-
-/*
- * MCU encoding for AC initial scan (either spectral selection,
- * or first pass of successive approximation).
- */
-
-#define ENCODE_COEFS_AC_FIRST(label) { \
- while (zerobits) { \
- r = count_zeroes(&zerobits); \
- cvalue += r; \
-label \
- temp = cvalue[0]; \
- temp2 = cvalue[DCTSIZE2]; \
- \
- /* if run length > 15, must emit special run-length-16 codes (0xF0) */ \
- while (r > 15) { \
- emit_symbol(entropy, entropy->ac_tbl_no, 0xF0); \
- r -= 16; \
- } \
- \
- /* Find the number of bits needed for the magnitude of the coefficient */ \
- nbits = JPEG_NBITS_NONZERO(temp); /* there must be at least one 1 bit */ \
- /* Check for out-of-range coefficient values */ \
- if (nbits > MAX_COEF_BITS) \
- ERREXIT(cinfo, JERR_BAD_DCT_COEF); \
- \
- /* Count/emit Huffman symbol for run length / number of bits */ \
- emit_symbol(entropy, entropy->ac_tbl_no, (r << 4) + nbits); \
- \
- /* Emit that number of bits of the value, if positive, */ \
- /* or the complement of its magnitude, if negative. */ \
- emit_bits(entropy, (unsigned int)temp2, nbits); \
- \
- cvalue++; \
- zerobits >>= 1; \
- } \
-}
-
-METHODDEF(boolean)
-encode_mcu_AC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
-{
- phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
- register int temp, temp2;
- register int nbits, r;
- int Sl = cinfo->Se - cinfo->Ss + 1;
- int Al = cinfo->Al;
- JCOEF values_unaligned[2 * DCTSIZE2 + 15];
- JCOEF *values;
- const JCOEF *cvalue;
- size_t zerobits;
- size_t bits[8 / SIZEOF_SIZE_T];
-
- entropy->next_output_byte = cinfo->dest->next_output_byte;
- entropy->free_in_buffer = cinfo->dest->free_in_buffer;
-
- /* Emit restart marker if needed */
- if (cinfo->restart_interval)
- if (entropy->restarts_to_go == 0)
- emit_restart(entropy, entropy->next_restart_num);
-
-#ifdef WITH_SIMD
- cvalue = values = (JCOEF *)PAD((JUINTPTR)values_unaligned, 16);
-#else
- /* Not using SIMD, so alignment is not needed */
- cvalue = values = values_unaligned;
-#endif
-
- /* Prepare data */
- entropy->AC_first_prepare(MCU_data[0][0], jpeg_natural_order + cinfo->Ss,
- Sl, Al, values, bits);
-
- zerobits = bits[0];
-#if SIZEOF_SIZE_T == 4
- zerobits |= bits[1];
-#endif
-
- /* Emit any pending EOBRUN */
- if (zerobits && (entropy->EOBRUN > 0))
- emit_eobrun(entropy);
-
-#if SIZEOF_SIZE_T == 4
- zerobits = bits[0];
-#endif
-
- /* Encode the AC coefficients per section G.1.2.2, fig. G.3 */
-
- ENCODE_COEFS_AC_FIRST((void)0;);
-
-#if SIZEOF_SIZE_T == 4
- zerobits = bits[1];
- if (zerobits) {
- int diff = ((values + DCTSIZE2 / 2) - cvalue);
- r = count_zeroes(&zerobits);
- r += diff;
- cvalue += r;
- goto first_iter_ac_first;
- }
-
- ENCODE_COEFS_AC_FIRST(first_iter_ac_first:);
-#endif
-
- if (cvalue < (values + Sl)) { /* If there are trailing zeroes, */
- entropy->EOBRUN++; /* count an EOB */
- if (entropy->EOBRUN == 0x7FFF)
- emit_eobrun(entropy); /* force it out to avoid overflow */
- }
-
- cinfo->dest->next_output_byte = entropy->next_output_byte;
- cinfo->dest->free_in_buffer = entropy->free_in_buffer;
-
- /* Update restart-interval state too */
- if (cinfo->restart_interval) {
- if (entropy->restarts_to_go == 0) {
- entropy->restarts_to_go = cinfo->restart_interval;
- entropy->next_restart_num++;
- entropy->next_restart_num &= 7;
- }
- entropy->restarts_to_go--;
- }
-
- return TRUE;
-}
-
-
-/*
- * MCU encoding for DC successive approximation refinement scan.
- * Note: we assume such scans can be multi-component, although the spec
- * is not very clear on the point.
- */
-
-METHODDEF(boolean)
-encode_mcu_DC_refine(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
-{
- phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
- register int temp;
- int blkn;
- int Al = cinfo->Al;
- JBLOCKROW block;
-
- entropy->next_output_byte = cinfo->dest->next_output_byte;
- entropy->free_in_buffer = cinfo->dest->free_in_buffer;
-
- /* Emit restart marker if needed */
- if (cinfo->restart_interval)
- if (entropy->restarts_to_go == 0)
- emit_restart(entropy, entropy->next_restart_num);
-
- /* Encode the MCU data blocks */
- for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
- block = MCU_data[blkn];
-
- /* We simply emit the Al'th bit of the DC coefficient value. */
- temp = (*block)[0];
- emit_bits(entropy, (unsigned int)(temp >> Al), 1);
- }
-
- cinfo->dest->next_output_byte = entropy->next_output_byte;
- cinfo->dest->free_in_buffer = entropy->free_in_buffer;
-
- /* Update restart-interval state too */
- if (cinfo->restart_interval) {
- if (entropy->restarts_to_go == 0) {
- entropy->restarts_to_go = cinfo->restart_interval;
- entropy->next_restart_num++;
- entropy->next_restart_num &= 7;
- }
- entropy->restarts_to_go--;
- }
-
- return TRUE;
-}
-
-
-/*
- * Data preparation for encode_mcu_AC_refine().
- */
-
-#define COMPUTE_ABSVALUES_AC_REFINE(Sl, koffset) { \
- /* It is convenient to make a pre-pass to determine the transformed \
- * coefficients' absolute values and the EOB position. \
- */ \
- for (k = 0; k < Sl; k++) { \
- temp = block[jpeg_natural_order_start[k]]; \
- /* We must apply the point transform by Al. For AC coefficients this \
- * is an integer division with rounding towards 0. To do this portably \
- * in C, we shift after obtaining the absolute value. \
- */ \
- temp2 = temp >> (CHAR_BIT * sizeof(int) - 1); \
- temp ^= temp2; \
- temp -= temp2; /* temp is abs value of input */ \
- temp >>= Al; /* apply the point transform */ \
- if (temp != 0) { \
- zerobits |= ((size_t)1U) << k; \
- signbits |= ((size_t)(temp2 + 1)) << k; \
- } \
- absvalues[k] = (JCOEF)temp; /* save abs value for main pass */ \
- if (temp == 1) \
- EOB = k + koffset; /* EOB = index of last newly-nonzero coef */ \
- } \
-}
-
-METHODDEF(int)
-encode_mcu_AC_refine_prepare(const JCOEF *block,
- const int *jpeg_natural_order_start, int Sl,
- int Al, JCOEF *absvalues, size_t *bits)
-{
- register int k, temp, temp2;
- int EOB = 0;
- size_t zerobits = 0U, signbits = 0U;
- int Sl0 = Sl;
-
-#if SIZEOF_SIZE_T == 4
- if (Sl0 > 32)
- Sl0 = 32;
-#endif
-
- COMPUTE_ABSVALUES_AC_REFINE(Sl0, 0);
-
- bits[0] = zerobits;
-#if SIZEOF_SIZE_T == 8
- bits[1] = signbits;
-#else
- bits[2] = signbits;
-
- zerobits = 0U;
- signbits = 0U;
-
- if (Sl > 32) {
- Sl -= 32;
- jpeg_natural_order_start += 32;
- absvalues += 32;
-
- COMPUTE_ABSVALUES_AC_REFINE(Sl, 32);
- }
-
- bits[1] = zerobits;
- bits[3] = signbits;
-#endif
-
- return EOB;
-}
-
-
-/*
- * MCU encoding for AC successive approximation refinement scan.
- */
-
-#define ENCODE_COEFS_AC_REFINE(label) { \
- while (zerobits) { \
- idx = count_zeroes(&zerobits); \
- r += idx; \
- cabsvalue += idx; \
- signbits >>= idx; \
-label \
- /* Emit any required ZRLs, but not if they can be folded into EOB */ \
- while (r > 15 && (cabsvalue <= EOBPTR)) { \
- /* emit any pending EOBRUN and the BE correction bits */ \
- emit_eobrun(entropy); \
- /* Emit ZRL */ \
- emit_symbol(entropy, entropy->ac_tbl_no, 0xF0); \
- r -= 16; \
- /* Emit buffered correction bits that must be associated with ZRL */ \
- emit_buffered_bits(entropy, BR_buffer, BR); \
- BR_buffer = entropy->bit_buffer; /* BE bits are gone now */ \
- BR = 0; \
- } \
- \
- temp = *cabsvalue++; \
- \
- /* If the coef was previously nonzero, it only needs a correction bit. \
- * NOTE: a straight translation of the spec's figure G.7 would suggest \
- * that we also need to test r > 15. But if r > 15, we can only get here \
- * if k > EOB, which implies that this coefficient is not 1. \
- */ \
- if (temp > 1) { \
- /* The correction bit is the next bit of the absolute value. */ \
- BR_buffer[BR++] = (char)(temp & 1); \
- signbits >>= 1; \
- zerobits >>= 1; \
- continue; \
- } \
- \
- /* Emit any pending EOBRUN and the BE correction bits */ \
- emit_eobrun(entropy); \
- \
- /* Count/emit Huffman symbol for run length / number of bits */ \
- emit_symbol(entropy, entropy->ac_tbl_no, (r << 4) + 1); \
- \
- /* Emit output bit for newly-nonzero coef */ \
- temp = signbits & 1; /* ((*block)[jpeg_natural_order_start[k]] < 0) ? 0 : 1 */ \
- emit_bits(entropy, (unsigned int)temp, 1); \
- \
- /* Emit buffered correction bits that must be associated with this code */ \
- emit_buffered_bits(entropy, BR_buffer, BR); \
- BR_buffer = entropy->bit_buffer; /* BE bits are gone now */ \
- BR = 0; \
- r = 0; /* reset zero run length */ \
- signbits >>= 1; \
- zerobits >>= 1; \
- } \
-}
-
-METHODDEF(boolean)
-encode_mcu_AC_refine(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
-{
- phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
- register int temp, r, idx;
- char *BR_buffer;
- unsigned int BR;
- int Sl = cinfo->Se - cinfo->Ss + 1;
- int Al = cinfo->Al;
- JCOEF absvalues_unaligned[DCTSIZE2 + 15];
- JCOEF *absvalues;
- const JCOEF *cabsvalue, *EOBPTR;
- size_t zerobits, signbits;
- size_t bits[16 / SIZEOF_SIZE_T];
-
- entropy->next_output_byte = cinfo->dest->next_output_byte;
- entropy->free_in_buffer = cinfo->dest->free_in_buffer;
-
- /* Emit restart marker if needed */
- if (cinfo->restart_interval)
- if (entropy->restarts_to_go == 0)
- emit_restart(entropy, entropy->next_restart_num);
-
-#ifdef WITH_SIMD
- cabsvalue = absvalues = (JCOEF *)PAD((JUINTPTR)absvalues_unaligned, 16);
-#else
- /* Not using SIMD, so alignment is not needed */
- cabsvalue = absvalues = absvalues_unaligned;
-#endif
-
- /* Prepare data */
- EOBPTR = absvalues +
- entropy->AC_refine_prepare(MCU_data[0][0], jpeg_natural_order + cinfo->Ss,
- Sl, Al, absvalues, bits);
-
- /* Encode the AC coefficients per section G.1.2.3, fig. G.7 */
-
- r = 0; /* r = run length of zeros */
- BR = 0; /* BR = count of buffered bits added now */
- BR_buffer = entropy->bit_buffer + entropy->BE; /* Append bits to buffer */
-
- zerobits = bits[0];
-#if SIZEOF_SIZE_T == 8
- signbits = bits[1];
-#else
- signbits = bits[2];
-#endif
- ENCODE_COEFS_AC_REFINE((void)0;);
-
-#if SIZEOF_SIZE_T == 4
- zerobits = bits[1];
- signbits = bits[3];
-
- if (zerobits) {
- int diff = ((absvalues + DCTSIZE2 / 2) - cabsvalue);
- idx = count_zeroes(&zerobits);
- signbits >>= idx;
- idx += diff;
- r += idx;
- cabsvalue += idx;
- goto first_iter_ac_refine;
- }
-
- ENCODE_COEFS_AC_REFINE(first_iter_ac_refine:);
-#endif
-
- r |= (int)((absvalues + Sl) - cabsvalue);
-
- if (r > 0 || BR > 0) { /* If there are trailing zeroes, */
- entropy->EOBRUN++; /* count an EOB */
- entropy->BE += BR; /* concat my correction bits to older ones */
- /* We force out the EOB if we risk either:
- * 1. overflow of the EOB counter;
- * 2. overflow of the correction bit buffer during the next MCU.
- */
- if (entropy->EOBRUN == 0x7FFF ||
- entropy->BE > (MAX_CORR_BITS - DCTSIZE2 + 1))
- emit_eobrun(entropy);
- }
-
- cinfo->dest->next_output_byte = entropy->next_output_byte;
- cinfo->dest->free_in_buffer = entropy->free_in_buffer;
-
- /* Update restart-interval state too */
- if (cinfo->restart_interval) {
- if (entropy->restarts_to_go == 0) {
- entropy->restarts_to_go = cinfo->restart_interval;
- entropy->next_restart_num++;
- entropy->next_restart_num &= 7;
- }
- entropy->restarts_to_go--;
- }
-
- return TRUE;
-}
-
-
-/*
- * Finish up at the end of a Huffman-compressed progressive scan.
- */
-
-METHODDEF(void)
-finish_pass_phuff(j_compress_ptr cinfo)
-{
- phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
-
- entropy->next_output_byte = cinfo->dest->next_output_byte;
- entropy->free_in_buffer = cinfo->dest->free_in_buffer;
-
- /* Flush out any buffered data */
- emit_eobrun(entropy);
- flush_bits(entropy);
-
- cinfo->dest->next_output_byte = entropy->next_output_byte;
- cinfo->dest->free_in_buffer = entropy->free_in_buffer;
-}
-
-
-/*
- * Finish up a statistics-gathering pass and create the new Huffman tables.
- */
-
-METHODDEF(void)
-finish_pass_gather_phuff(j_compress_ptr cinfo)
-{
- phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
- boolean is_DC_band;
- int ci, tbl;
- jpeg_component_info *compptr;
- JHUFF_TBL **htblptr;
- boolean did[NUM_HUFF_TBLS];
-
- /* Flush out buffered data (all we care about is counting the EOB symbol) */
- emit_eobrun(entropy);
-
- is_DC_band = (cinfo->Ss == 0);
-
- /* It's important not to apply jpeg_gen_optimal_table more than once
- * per table, because it clobbers the input frequency counts!
- */
- memset(did, 0, sizeof(did));
-
- for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
- compptr = cinfo->cur_comp_info[ci];
- if (is_DC_band) {
- if (cinfo->Ah != 0) /* DC refinement needs no table */
- continue;
- tbl = compptr->dc_tbl_no;
- } else {
- tbl = compptr->ac_tbl_no;
- }
- if (!did[tbl]) {
- if (is_DC_band)
- htblptr = &cinfo->dc_huff_tbl_ptrs[tbl];
- else
- htblptr = &cinfo->ac_huff_tbl_ptrs[tbl];
- if (*htblptr == NULL)
- *htblptr = jpeg_alloc_huff_table((j_common_ptr)cinfo);
- jpeg_gen_optimal_table(cinfo, *htblptr, entropy->count_ptrs[tbl]);
- did[tbl] = TRUE;
- }
- }
-}
-
-
-/*
- * Module initialization routine for progressive Huffman entropy encoding.
- */
-
-GLOBAL(void)
-jinit_phuff_encoder(j_compress_ptr cinfo)
-{
- phuff_entropy_ptr entropy;
- int i;
-
- entropy = (phuff_entropy_ptr)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- sizeof(phuff_entropy_encoder));
- cinfo->entropy = (struct jpeg_entropy_encoder *)entropy;
- entropy->pub.start_pass = start_pass_phuff;
-
- /* Mark tables unallocated */
- for (i = 0; i < NUM_HUFF_TBLS; i++) {
- entropy->derived_tbls[i] = NULL;
- entropy->count_ptrs[i] = NULL;
- }
- entropy->bit_buffer = NULL; /* needed only in AC refinement scan */
-}
-
-#endif /* C_PROGRESSIVE_SUPPORTED */
diff --git a/contrib/libs/libjpeg-turbo/jcprepct.c b/contrib/libs/libjpeg-turbo/jcprepct.c
deleted file mode 100644
index f27cc34507..0000000000
--- a/contrib/libs/libjpeg-turbo/jcprepct.c
+++ /dev/null
@@ -1,351 +0,0 @@
-/*
- * jcprepct.c
- *
- * This file is part of the Independent JPEG Group's software:
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains the compression preprocessing controller.
- * This controller manages the color conversion, downsampling,
- * and edge expansion steps.
- *
- * Most of the complexity here is associated with buffering input rows
- * as required by the downsampler. See the comments at the head of
- * jcsample.c for the downsampler's needs.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-
-
-/* At present, jcsample.c can request context rows only for smoothing.
- * In the future, we might also need context rows for CCIR601 sampling
- * or other more-complex downsampling procedures. The code to support
- * context rows should be compiled only if needed.
- */
-#ifdef INPUT_SMOOTHING_SUPPORTED
-#define CONTEXT_ROWS_SUPPORTED
-#endif
-
-
-/*
- * For the simple (no-context-row) case, we just need to buffer one
- * row group's worth of pixels for the downsampling step. At the bottom of
- * the image, we pad to a full row group by replicating the last pixel row.
- * The downsampler's last output row is then replicated if needed to pad
- * out to a full iMCU row.
- *
- * When providing context rows, we must buffer three row groups' worth of
- * pixels. Three row groups are physically allocated, but the row pointer
- * arrays are made five row groups high, with the extra pointers above and
- * below "wrapping around" to point to the last and first real row groups.
- * This allows the downsampler to access the proper context rows.
- * At the top and bottom of the image, we create dummy context rows by
- * copying the first or last real pixel row. This copying could be avoided
- * by pointer hacking as is done in jdmainct.c, but it doesn't seem worth the
- * trouble on the compression side.
- */
-
-
-/* Private buffer controller object */
-
-typedef struct {
- struct jpeg_c_prep_controller pub; /* public fields */
-
- /* Downsampling input buffer. This buffer holds color-converted data
- * until we have enough to do a downsample step.
- */
- JSAMPARRAY color_buf[MAX_COMPONENTS];
-
- JDIMENSION rows_to_go; /* counts rows remaining in source image */
- int next_buf_row; /* index of next row to store in color_buf */
-
-#ifdef CONTEXT_ROWS_SUPPORTED /* only needed for context case */
- int this_row_group; /* starting row index of group to process */
- int next_buf_stop; /* downsample when we reach this index */
-#endif
-} my_prep_controller;
-
-typedef my_prep_controller *my_prep_ptr;
-
-
-/*
- * Initialize for a processing pass.
- */
-
-METHODDEF(void)
-start_pass_prep(j_compress_ptr cinfo, J_BUF_MODE pass_mode)
-{
- my_prep_ptr prep = (my_prep_ptr)cinfo->prep;
-
- if (pass_mode != JBUF_PASS_THRU)
- ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
-
- /* Initialize total-height counter for detecting bottom of image */
- prep->rows_to_go = cinfo->image_height;
- /* Mark the conversion buffer empty */
- prep->next_buf_row = 0;
-#ifdef CONTEXT_ROWS_SUPPORTED
- /* Preset additional state variables for context mode.
- * These aren't used in non-context mode, so we needn't test which mode.
- */
- prep->this_row_group = 0;
- /* Set next_buf_stop to stop after two row groups have been read in. */
- prep->next_buf_stop = 2 * cinfo->max_v_samp_factor;
-#endif
-}
-
-
-/*
- * Expand an image vertically from height input_rows to height output_rows,
- * by duplicating the bottom row.
- */
-
-LOCAL(void)
-expand_bottom_edge(JSAMPARRAY image_data, JDIMENSION num_cols, int input_rows,
- int output_rows)
-{
- register int row;
-
- for (row = input_rows; row < output_rows; row++) {
- jcopy_sample_rows(image_data, input_rows - 1, image_data, row, 1,
- num_cols);
- }
-}
-
-
-/*
- * Process some data in the simple no-context case.
- *
- * Preprocessor output data is counted in "row groups". A row group
- * is defined to be v_samp_factor sample rows of each component.
- * Downsampling will produce this much data from each max_v_samp_factor
- * input rows.
- */
-
-METHODDEF(void)
-pre_process_data(j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail,
- JSAMPIMAGE output_buf, JDIMENSION *out_row_group_ctr,
- JDIMENSION out_row_groups_avail)
-{
- my_prep_ptr prep = (my_prep_ptr)cinfo->prep;
- int numrows, ci;
- JDIMENSION inrows;
- jpeg_component_info *compptr;
-
- while (*in_row_ctr < in_rows_avail &&
- *out_row_group_ctr < out_row_groups_avail) {
- /* Do color conversion to fill the conversion buffer. */
- inrows = in_rows_avail - *in_row_ctr;
- numrows = cinfo->max_v_samp_factor - prep->next_buf_row;
- numrows = (int)MIN((JDIMENSION)numrows, inrows);
- (*cinfo->cconvert->color_convert) (cinfo, input_buf + *in_row_ctr,
- prep->color_buf,
- (JDIMENSION)prep->next_buf_row,
- numrows);
- *in_row_ctr += numrows;
- prep->next_buf_row += numrows;
- prep->rows_to_go -= numrows;
- /* If at bottom of image, pad to fill the conversion buffer. */
- if (prep->rows_to_go == 0 &&
- prep->next_buf_row < cinfo->max_v_samp_factor) {
- for (ci = 0; ci < cinfo->num_components; ci++) {
- expand_bottom_edge(prep->color_buf[ci], cinfo->image_width,
- prep->next_buf_row, cinfo->max_v_samp_factor);
- }
- prep->next_buf_row = cinfo->max_v_samp_factor;
- }
- /* If we've filled the conversion buffer, empty it. */
- if (prep->next_buf_row == cinfo->max_v_samp_factor) {
- (*cinfo->downsample->downsample) (cinfo,
- prep->color_buf, (JDIMENSION)0,
- output_buf, *out_row_group_ctr);
- prep->next_buf_row = 0;
- (*out_row_group_ctr)++;
- }
- /* If at bottom of image, pad the output to a full iMCU height.
- * Note we assume the caller is providing a one-iMCU-height output buffer!
- */
- if (prep->rows_to_go == 0 && *out_row_group_ctr < out_row_groups_avail) {
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
- ci++, compptr++) {
- expand_bottom_edge(output_buf[ci], compptr->width_in_blocks * DCTSIZE,
- (int)(*out_row_group_ctr * compptr->v_samp_factor),
- (int)(out_row_groups_avail * compptr->v_samp_factor));
- }
- *out_row_group_ctr = out_row_groups_avail;
- break; /* can exit outer loop without test */
- }
- }
-}
-
-
-#ifdef CONTEXT_ROWS_SUPPORTED
-
-/*
- * Process some data in the context case.
- */
-
-METHODDEF(void)
-pre_process_context(j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail,
- JSAMPIMAGE output_buf, JDIMENSION *out_row_group_ctr,
- JDIMENSION out_row_groups_avail)
-{
- my_prep_ptr prep = (my_prep_ptr)cinfo->prep;
- int numrows, ci;
- int buf_height = cinfo->max_v_samp_factor * 3;
- JDIMENSION inrows;
-
- while (*out_row_group_ctr < out_row_groups_avail) {
- if (*in_row_ctr < in_rows_avail) {
- /* Do color conversion to fill the conversion buffer. */
- inrows = in_rows_avail - *in_row_ctr;
- numrows = prep->next_buf_stop - prep->next_buf_row;
- numrows = (int)MIN((JDIMENSION)numrows, inrows);
- (*cinfo->cconvert->color_convert) (cinfo, input_buf + *in_row_ctr,
- prep->color_buf,
- (JDIMENSION)prep->next_buf_row,
- numrows);
- /* Pad at top of image, if first time through */
- if (prep->rows_to_go == cinfo->image_height) {
- for (ci = 0; ci < cinfo->num_components; ci++) {
- int row;
- for (row = 1; row <= cinfo->max_v_samp_factor; row++) {
- jcopy_sample_rows(prep->color_buf[ci], 0, prep->color_buf[ci],
- -row, 1, cinfo->image_width);
- }
- }
- }
- *in_row_ctr += numrows;
- prep->next_buf_row += numrows;
- prep->rows_to_go -= numrows;
- } else {
- /* Return for more data, unless we are at the bottom of the image. */
- if (prep->rows_to_go != 0)
- break;
- /* When at bottom of image, pad to fill the conversion buffer. */
- if (prep->next_buf_row < prep->next_buf_stop) {
- for (ci = 0; ci < cinfo->num_components; ci++) {
- expand_bottom_edge(prep->color_buf[ci], cinfo->image_width,
- prep->next_buf_row, prep->next_buf_stop);
- }
- prep->next_buf_row = prep->next_buf_stop;
- }
- }
- /* If we've gotten enough data, downsample a row group. */
- if (prep->next_buf_row == prep->next_buf_stop) {
- (*cinfo->downsample->downsample) (cinfo, prep->color_buf,
- (JDIMENSION)prep->this_row_group,
- output_buf, *out_row_group_ctr);
- (*out_row_group_ctr)++;
- /* Advance pointers with wraparound as necessary. */
- prep->this_row_group += cinfo->max_v_samp_factor;
- if (prep->this_row_group >= buf_height)
- prep->this_row_group = 0;
- if (prep->next_buf_row >= buf_height)
- prep->next_buf_row = 0;
- prep->next_buf_stop = prep->next_buf_row + cinfo->max_v_samp_factor;
- }
- }
-}
-
-
-/*
- * Create the wrapped-around downsampling input buffer needed for context mode.
- */
-
-LOCAL(void)
-create_context_buffer(j_compress_ptr cinfo)
-{
- my_prep_ptr prep = (my_prep_ptr)cinfo->prep;
- int rgroup_height = cinfo->max_v_samp_factor;
- int ci, i;
- jpeg_component_info *compptr;
- JSAMPARRAY true_buffer, fake_buffer;
-
- /* Grab enough space for fake row pointers for all the components;
- * we need five row groups' worth of pointers for each component.
- */
- fake_buffer = (JSAMPARRAY)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- (cinfo->num_components * 5 * rgroup_height) *
- sizeof(JSAMPROW));
-
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
- ci++, compptr++) {
- /* Allocate the actual buffer space (3 row groups) for this component.
- * We make the buffer wide enough to allow the downsampler to edge-expand
- * horizontally within the buffer, if it so chooses.
- */
- true_buffer = (*cinfo->mem->alloc_sarray)
- ((j_common_ptr)cinfo, JPOOL_IMAGE,
- (JDIMENSION)(((long)compptr->width_in_blocks * DCTSIZE *
- cinfo->max_h_samp_factor) / compptr->h_samp_factor),
- (JDIMENSION)(3 * rgroup_height));
- /* Copy true buffer row pointers into the middle of the fake row array */
- memcpy(fake_buffer + rgroup_height, true_buffer,
- 3 * rgroup_height * sizeof(JSAMPROW));
- /* Fill in the above and below wraparound pointers */
- for (i = 0; i < rgroup_height; i++) {
- fake_buffer[i] = true_buffer[2 * rgroup_height + i];
- fake_buffer[4 * rgroup_height + i] = true_buffer[i];
- }
- prep->color_buf[ci] = fake_buffer + rgroup_height;
- fake_buffer += 5 * rgroup_height; /* point to space for next component */
- }
-}
-
-#endif /* CONTEXT_ROWS_SUPPORTED */
-
-
-/*
- * Initialize preprocessing controller.
- */
-
-GLOBAL(void)
-jinit_c_prep_controller(j_compress_ptr cinfo, boolean need_full_buffer)
-{
- my_prep_ptr prep;
- int ci;
- jpeg_component_info *compptr;
-
- if (need_full_buffer) /* safety check */
- ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
-
- prep = (my_prep_ptr)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- sizeof(my_prep_controller));
- cinfo->prep = (struct jpeg_c_prep_controller *)prep;
- prep->pub.start_pass = start_pass_prep;
-
- /* Allocate the color conversion buffer.
- * We make the buffer wide enough to allow the downsampler to edge-expand
- * horizontally within the buffer, if it so chooses.
- */
- if (cinfo->downsample->need_context_rows) {
- /* Set up to provide context rows */
-#ifdef CONTEXT_ROWS_SUPPORTED
- prep->pub.pre_process_data = pre_process_context;
- create_context_buffer(cinfo);
-#else
- ERREXIT(cinfo, JERR_NOT_COMPILED);
-#endif
- } else {
- /* No context, just make it tall enough for one row group */
- prep->pub.pre_process_data = pre_process_data;
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
- ci++, compptr++) {
- prep->color_buf[ci] = (*cinfo->mem->alloc_sarray)
- ((j_common_ptr)cinfo, JPOOL_IMAGE,
- (JDIMENSION)(((long)compptr->width_in_blocks * DCTSIZE *
- cinfo->max_h_samp_factor) / compptr->h_samp_factor),
- (JDIMENSION)cinfo->max_v_samp_factor);
- }
- }
-}
diff --git a/contrib/libs/libjpeg-turbo/jcsample.c b/contrib/libs/libjpeg-turbo/jcsample.c
deleted file mode 100644
index e8515ebf0f..0000000000
--- a/contrib/libs/libjpeg-turbo/jcsample.c
+++ /dev/null
@@ -1,522 +0,0 @@
-/*
- * jcsample.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1996, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- * Copyright (C) 2014, MIPS Technologies, Inc., California.
- * Copyright (C) 2015, 2019, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains downsampling routines.
- *
- * Downsampling input data is counted in "row groups". A row group
- * is defined to be max_v_samp_factor pixel rows of each component,
- * from which the downsampler produces v_samp_factor sample rows.
- * A single row group is processed in each call to the downsampler module.
- *
- * The downsampler is responsible for edge-expansion of its output data
- * to fill an integral number of DCT blocks horizontally. The source buffer
- * may be modified if it is helpful for this purpose (the source buffer is
- * allocated wide enough to correspond to the desired output width).
- * The caller (the prep controller) is responsible for vertical padding.
- *
- * The downsampler may request "context rows" by setting need_context_rows
- * during startup. In this case, the input arrays will contain at least
- * one row group's worth of pixels above and below the passed-in data;
- * the caller will create dummy rows at image top and bottom by replicating
- * the first or last real pixel row.
- *
- * An excellent reference for image resampling is
- * Digital Image Warping, George Wolberg, 1990.
- * Pub. by IEEE Computer Society Press, Los Alamitos, CA. ISBN 0-8186-8944-7.
- *
- * The downsampling algorithm used here is a simple average of the source
- * pixels covered by the output pixel. The hi-falutin sampling literature
- * refers to this as a "box filter". In general the characteristics of a box
- * filter are not very good, but for the specific cases we normally use (1:1
- * and 2:1 ratios) the box is equivalent to a "triangle filter" which is not
- * nearly so bad. If you intend to use other sampling ratios, you'd be well
- * advised to improve this code.
- *
- * A simple input-smoothing capability is provided. This is mainly intended
- * for cleaning up color-dithered GIF input files (if you find it inadequate,
- * we suggest using an external filtering program such as pnmconvol). When
- * enabled, each input pixel P is replaced by a weighted sum of itself and its
- * eight neighbors. P's weight is 1-8*SF and each neighbor's weight is SF,
- * where SF = (smoothing_factor / 1024).
- * Currently, smoothing is only supported for 2h2v sampling factors.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-#include "jsimd.h"
-
-
-/* Pointer to routine to downsample a single component */
-typedef void (*downsample1_ptr) (j_compress_ptr cinfo,
- jpeg_component_info *compptr,
- JSAMPARRAY input_data,
- JSAMPARRAY output_data);
-
-/* Private subobject */
-
-typedef struct {
- struct jpeg_downsampler pub; /* public fields */
-
- /* Downsampling method pointers, one per component */
- downsample1_ptr methods[MAX_COMPONENTS];
-} my_downsampler;
-
-typedef my_downsampler *my_downsample_ptr;
-
-
-/*
- * Initialize for a downsampling pass.
- */
-
-METHODDEF(void)
-start_pass_downsample(j_compress_ptr cinfo)
-{
- /* no work for now */
-}
-
-
-/*
- * Expand a component horizontally from width input_cols to width output_cols,
- * by duplicating the rightmost samples.
- */
-
-LOCAL(void)
-expand_right_edge(JSAMPARRAY image_data, int num_rows, JDIMENSION input_cols,
- JDIMENSION output_cols)
-{
- register JSAMPROW ptr;
- register JSAMPLE pixval;
- register int count;
- int row;
- int numcols = (int)(output_cols - input_cols);
-
- if (numcols > 0) {
- for (row = 0; row < num_rows; row++) {
- ptr = image_data[row] + input_cols;
- pixval = ptr[-1];
- for (count = numcols; count > 0; count--)
- *ptr++ = pixval;
- }
- }
-}
-
-
-/*
- * Do downsampling for a whole row group (all components).
- *
- * In this version we simply downsample each component independently.
- */
-
-METHODDEF(void)
-sep_downsample(j_compress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION in_row_index, JSAMPIMAGE output_buf,
- JDIMENSION out_row_group_index)
-{
- my_downsample_ptr downsample = (my_downsample_ptr)cinfo->downsample;
- int ci;
- jpeg_component_info *compptr;
- JSAMPARRAY in_ptr, out_ptr;
-
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
- ci++, compptr++) {
- in_ptr = input_buf[ci] + in_row_index;
- out_ptr = output_buf[ci] + (out_row_group_index * compptr->v_samp_factor);
- (*downsample->methods[ci]) (cinfo, compptr, in_ptr, out_ptr);
- }
-}
-
-
-/*
- * Downsample pixel values of a single component.
- * One row group is processed per call.
- * This version handles arbitrary integral sampling ratios, without smoothing.
- * Note that this version is not actually used for customary sampling ratios.
- */
-
-METHODDEF(void)
-int_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY output_data)
-{
- int inrow, outrow, h_expand, v_expand, numpix, numpix2, h, v;
- JDIMENSION outcol, outcol_h; /* outcol_h == outcol*h_expand */
- JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE;
- JSAMPROW inptr, outptr;
- JLONG outvalue;
-
- h_expand = cinfo->max_h_samp_factor / compptr->h_samp_factor;
- v_expand = cinfo->max_v_samp_factor / compptr->v_samp_factor;
- numpix = h_expand * v_expand;
- numpix2 = numpix / 2;
-
- /* Expand input data enough to let all the output samples be generated
- * by the standard loop. Special-casing padded output would be more
- * efficient.
- */
- expand_right_edge(input_data, cinfo->max_v_samp_factor, cinfo->image_width,
- output_cols * h_expand);
-
- inrow = 0;
- for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) {
- outptr = output_data[outrow];
- for (outcol = 0, outcol_h = 0; outcol < output_cols;
- outcol++, outcol_h += h_expand) {
- outvalue = 0;
- for (v = 0; v < v_expand; v++) {
- inptr = input_data[inrow + v] + outcol_h;
- for (h = 0; h < h_expand; h++) {
- outvalue += (JLONG)(*inptr++);
- }
- }
- *outptr++ = (JSAMPLE)((outvalue + numpix2) / numpix);
- }
- inrow += v_expand;
- }
-}
-
-
-/*
- * Downsample pixel values of a single component.
- * This version handles the special case of a full-size component,
- * without smoothing.
- */
-
-METHODDEF(void)
-fullsize_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY output_data)
-{
- /* Copy the data */
- jcopy_sample_rows(input_data, 0, output_data, 0, cinfo->max_v_samp_factor,
- cinfo->image_width);
- /* Edge-expand */
- expand_right_edge(output_data, cinfo->max_v_samp_factor, cinfo->image_width,
- compptr->width_in_blocks * DCTSIZE);
-}
-
-
-/*
- * Downsample pixel values of a single component.
- * This version handles the common case of 2:1 horizontal and 1:1 vertical,
- * without smoothing.
- *
- * A note about the "bias" calculations: when rounding fractional values to
- * integer, we do not want to always round 0.5 up to the next integer.
- * If we did that, we'd introduce a noticeable bias towards larger values.
- * Instead, this code is arranged so that 0.5 will be rounded up or down at
- * alternate pixel locations (a simple ordered dither pattern).
- */
-
-METHODDEF(void)
-h2v1_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY output_data)
-{
- int outrow;
- JDIMENSION outcol;
- JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE;
- register JSAMPROW inptr, outptr;
- register int bias;
-
- /* Expand input data enough to let all the output samples be generated
- * by the standard loop. Special-casing padded output would be more
- * efficient.
- */
- expand_right_edge(input_data, cinfo->max_v_samp_factor, cinfo->image_width,
- output_cols * 2);
-
- for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) {
- outptr = output_data[outrow];
- inptr = input_data[outrow];
- bias = 0; /* bias = 0,1,0,1,... for successive samples */
- for (outcol = 0; outcol < output_cols; outcol++) {
- *outptr++ = (JSAMPLE)((inptr[0] + inptr[1] + bias) >> 1);
- bias ^= 1; /* 0=>1, 1=>0 */
- inptr += 2;
- }
- }
-}
-
-
-/*
- * Downsample pixel values of a single component.
- * This version handles the standard case of 2:1 horizontal and 2:1 vertical,
- * without smoothing.
- */
-
-METHODDEF(void)
-h2v2_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY output_data)
-{
- int inrow, outrow;
- JDIMENSION outcol;
- JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE;
- register JSAMPROW inptr0, inptr1, outptr;
- register int bias;
-
- /* Expand input data enough to let all the output samples be generated
- * by the standard loop. Special-casing padded output would be more
- * efficient.
- */
- expand_right_edge(input_data, cinfo->max_v_samp_factor, cinfo->image_width,
- output_cols * 2);
-
- inrow = 0;
- for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) {
- outptr = output_data[outrow];
- inptr0 = input_data[inrow];
- inptr1 = input_data[inrow + 1];
- bias = 1; /* bias = 1,2,1,2,... for successive samples */
- for (outcol = 0; outcol < output_cols; outcol++) {
- *outptr++ =
- (JSAMPLE)((inptr0[0] + inptr0[1] + inptr1[0] + inptr1[1] + bias) >> 2);
- bias ^= 3; /* 1=>2, 2=>1 */
- inptr0 += 2; inptr1 += 2;
- }
- inrow += 2;
- }
-}
-
-
-#ifdef INPUT_SMOOTHING_SUPPORTED
-
-/*
- * Downsample pixel values of a single component.
- * This version handles the standard case of 2:1 horizontal and 2:1 vertical,
- * with smoothing. One row of context is required.
- */
-
-METHODDEF(void)
-h2v2_smooth_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY output_data)
-{
- int inrow, outrow;
- JDIMENSION colctr;
- JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE;
- register JSAMPROW inptr0, inptr1, above_ptr, below_ptr, outptr;
- JLONG membersum, neighsum, memberscale, neighscale;
-
- /* Expand input data enough to let all the output samples be generated
- * by the standard loop. Special-casing padded output would be more
- * efficient.
- */
- expand_right_edge(input_data - 1, cinfo->max_v_samp_factor + 2,
- cinfo->image_width, output_cols * 2);
-
- /* We don't bother to form the individual "smoothed" input pixel values;
- * we can directly compute the output which is the average of the four
- * smoothed values. Each of the four member pixels contributes a fraction
- * (1-8*SF) to its own smoothed image and a fraction SF to each of the three
- * other smoothed pixels, therefore a total fraction (1-5*SF)/4 to the final
- * output. The four corner-adjacent neighbor pixels contribute a fraction
- * SF to just one smoothed pixel, or SF/4 to the final output; while the
- * eight edge-adjacent neighbors contribute SF to each of two smoothed
- * pixels, or SF/2 overall. In order to use integer arithmetic, these
- * factors are scaled by 2^16 = 65536.
- * Also recall that SF = smoothing_factor / 1024.
- */
-
- memberscale = 16384 - cinfo->smoothing_factor * 80; /* scaled (1-5*SF)/4 */
- neighscale = cinfo->smoothing_factor * 16; /* scaled SF/4 */
-
- inrow = 0;
- for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) {
- outptr = output_data[outrow];
- inptr0 = input_data[inrow];
- inptr1 = input_data[inrow + 1];
- above_ptr = input_data[inrow - 1];
- below_ptr = input_data[inrow + 2];
-
- /* Special case for first column: pretend column -1 is same as column 0 */
- membersum = inptr0[0] + inptr0[1] + inptr1[0] + inptr1[1];
- neighsum = above_ptr[0] + above_ptr[1] + below_ptr[0] + below_ptr[1] +
- inptr0[0] + inptr0[2] + inptr1[0] + inptr1[2];
- neighsum += neighsum;
- neighsum += above_ptr[0] + above_ptr[2] + below_ptr[0] + below_ptr[2];
- membersum = membersum * memberscale + neighsum * neighscale;
- *outptr++ = (JSAMPLE)((membersum + 32768) >> 16);
- inptr0 += 2; inptr1 += 2; above_ptr += 2; below_ptr += 2;
-
- for (colctr = output_cols - 2; colctr > 0; colctr--) {
- /* sum of pixels directly mapped to this output element */
- membersum = inptr0[0] + inptr0[1] + inptr1[0] + inptr1[1];
- /* sum of edge-neighbor pixels */
- neighsum = above_ptr[0] + above_ptr[1] + below_ptr[0] + below_ptr[1] +
- inptr0[-1] + inptr0[2] + inptr1[-1] + inptr1[2];
- /* The edge-neighbors count twice as much as corner-neighbors */
- neighsum += neighsum;
- /* Add in the corner-neighbors */
- neighsum += above_ptr[-1] + above_ptr[2] + below_ptr[-1] + below_ptr[2];
- /* form final output scaled up by 2^16 */
- membersum = membersum * memberscale + neighsum * neighscale;
- /* round, descale and output it */
- *outptr++ = (JSAMPLE)((membersum + 32768) >> 16);
- inptr0 += 2; inptr1 += 2; above_ptr += 2; below_ptr += 2;
- }
-
- /* Special case for last column */
- membersum = inptr0[0] + inptr0[1] + inptr1[0] + inptr1[1];
- neighsum = above_ptr[0] + above_ptr[1] + below_ptr[0] + below_ptr[1] +
- inptr0[-1] + inptr0[1] + inptr1[-1] + inptr1[1];
- neighsum += neighsum;
- neighsum += above_ptr[-1] + above_ptr[1] + below_ptr[-1] + below_ptr[1];
- membersum = membersum * memberscale + neighsum * neighscale;
- *outptr = (JSAMPLE)((membersum + 32768) >> 16);
-
- inrow += 2;
- }
-}
-
-
-/*
- * Downsample pixel values of a single component.
- * This version handles the special case of a full-size component,
- * with smoothing. One row of context is required.
- */
-
-METHODDEF(void)
-fullsize_smooth_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY output_data)
-{
- int outrow;
- JDIMENSION colctr;
- JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE;
- register JSAMPROW inptr, above_ptr, below_ptr, outptr;
- JLONG membersum, neighsum, memberscale, neighscale;
- int colsum, lastcolsum, nextcolsum;
-
- /* Expand input data enough to let all the output samples be generated
- * by the standard loop. Special-casing padded output would be more
- * efficient.
- */
- expand_right_edge(input_data - 1, cinfo->max_v_samp_factor + 2,
- cinfo->image_width, output_cols);
-
- /* Each of the eight neighbor pixels contributes a fraction SF to the
- * smoothed pixel, while the main pixel contributes (1-8*SF). In order
- * to use integer arithmetic, these factors are multiplied by 2^16 = 65536.
- * Also recall that SF = smoothing_factor / 1024.
- */
-
- memberscale = 65536L - cinfo->smoothing_factor * 512L; /* scaled 1-8*SF */
- neighscale = cinfo->smoothing_factor * 64; /* scaled SF */
-
- for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) {
- outptr = output_data[outrow];
- inptr = input_data[outrow];
- above_ptr = input_data[outrow - 1];
- below_ptr = input_data[outrow + 1];
-
- /* Special case for first column */
- colsum = (*above_ptr++) + (*below_ptr++) + inptr[0];
- membersum = *inptr++;
- nextcolsum = above_ptr[0] + below_ptr[0] + inptr[0];
- neighsum = colsum + (colsum - membersum) + nextcolsum;
- membersum = membersum * memberscale + neighsum * neighscale;
- *outptr++ = (JSAMPLE)((membersum + 32768) >> 16);
- lastcolsum = colsum; colsum = nextcolsum;
-
- for (colctr = output_cols - 2; colctr > 0; colctr--) {
- membersum = *inptr++;
- above_ptr++; below_ptr++;
- nextcolsum = above_ptr[0] + below_ptr[0] + inptr[0];
- neighsum = lastcolsum + (colsum - membersum) + nextcolsum;
- membersum = membersum * memberscale + neighsum * neighscale;
- *outptr++ = (JSAMPLE)((membersum + 32768) >> 16);
- lastcolsum = colsum; colsum = nextcolsum;
- }
-
- /* Special case for last column */
- membersum = *inptr;
- neighsum = lastcolsum + (colsum - membersum) + colsum;
- membersum = membersum * memberscale + neighsum * neighscale;
- *outptr = (JSAMPLE)((membersum + 32768) >> 16);
-
- }
-}
-
-#endif /* INPUT_SMOOTHING_SUPPORTED */
-
-
-/*
- * Module initialization routine for downsampling.
- * Note that we must select a routine for each component.
- */
-
-GLOBAL(void)
-jinit_downsampler(j_compress_ptr cinfo)
-{
- my_downsample_ptr downsample;
- int ci;
- jpeg_component_info *compptr;
- boolean smoothok = TRUE;
-
- downsample = (my_downsample_ptr)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- sizeof(my_downsampler));
- cinfo->downsample = (struct jpeg_downsampler *)downsample;
- downsample->pub.start_pass = start_pass_downsample;
- downsample->pub.downsample = sep_downsample;
- downsample->pub.need_context_rows = FALSE;
-
- if (cinfo->CCIR601_sampling)
- ERREXIT(cinfo, JERR_CCIR601_NOTIMPL);
-
- /* Verify we can handle the sampling factors, and set up method pointers */
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
- ci++, compptr++) {
- if (compptr->h_samp_factor == cinfo->max_h_samp_factor &&
- compptr->v_samp_factor == cinfo->max_v_samp_factor) {
-#ifdef INPUT_SMOOTHING_SUPPORTED
- if (cinfo->smoothing_factor) {
- downsample->methods[ci] = fullsize_smooth_downsample;
- downsample->pub.need_context_rows = TRUE;
- } else
-#endif
- downsample->methods[ci] = fullsize_downsample;
- } else if (compptr->h_samp_factor * 2 == cinfo->max_h_samp_factor &&
- compptr->v_samp_factor == cinfo->max_v_samp_factor) {
- smoothok = FALSE;
- if (jsimd_can_h2v1_downsample())
- downsample->methods[ci] = jsimd_h2v1_downsample;
- else
- downsample->methods[ci] = h2v1_downsample;
- } else if (compptr->h_samp_factor * 2 == cinfo->max_h_samp_factor &&
- compptr->v_samp_factor * 2 == cinfo->max_v_samp_factor) {
-#ifdef INPUT_SMOOTHING_SUPPORTED
- if (cinfo->smoothing_factor) {
-#if defined(__mips__)
- if (jsimd_can_h2v2_smooth_downsample())
- downsample->methods[ci] = jsimd_h2v2_smooth_downsample;
- else
-#endif
- downsample->methods[ci] = h2v2_smooth_downsample;
- downsample->pub.need_context_rows = TRUE;
- } else
-#endif
- {
- if (jsimd_can_h2v2_downsample())
- downsample->methods[ci] = jsimd_h2v2_downsample;
- else
- downsample->methods[ci] = h2v2_downsample;
- }
- } else if ((cinfo->max_h_samp_factor % compptr->h_samp_factor) == 0 &&
- (cinfo->max_v_samp_factor % compptr->v_samp_factor) == 0) {
- smoothok = FALSE;
- downsample->methods[ci] = int_downsample;
- } else
- ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL);
- }
-
-#ifdef INPUT_SMOOTHING_SUPPORTED
- if (cinfo->smoothing_factor && !smoothok)
- TRACEMS(cinfo, 0, JTRC_SMOOTH_NOTIMPL);
-#endif
-}
diff --git a/contrib/libs/libjpeg-turbo/jctrans.c b/contrib/libs/libjpeg-turbo/jctrans.c
deleted file mode 100644
index e121028ec7..0000000000
--- a/contrib/libs/libjpeg-turbo/jctrans.c
+++ /dev/null
@@ -1,401 +0,0 @@
-/*
- * jctrans.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1995-1998, Thomas G. Lane.
- * Modified 2000-2009 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2020, 2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains library routines for transcoding compression,
- * that is, writing raw DCT coefficient arrays to an output JPEG file.
- * The routines in jcapimin.c will also be needed by a transcoder.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-#include "jpegcomp.h"
-
-
-/* Forward declarations */
-LOCAL(void) transencode_master_selection(j_compress_ptr cinfo,
- jvirt_barray_ptr *coef_arrays);
-LOCAL(void) transencode_coef_controller(j_compress_ptr cinfo,
- jvirt_barray_ptr *coef_arrays);
-
-
-/*
- * Compression initialization for writing raw-coefficient data.
- * Before calling this, all parameters and a data destination must be set up.
- * Call jpeg_finish_compress() to actually write the data.
- *
- * The number of passed virtual arrays must match cinfo->num_components.
- * Note that the virtual arrays need not be filled or even realized at
- * the time write_coefficients is called; indeed, if the virtual arrays
- * were requested from this compression object's memory manager, they
- * typically will be realized during this routine and filled afterwards.
- */
-
-GLOBAL(void)
-jpeg_write_coefficients(j_compress_ptr cinfo, jvirt_barray_ptr *coef_arrays)
-{
- if (cinfo->global_state != CSTATE_START)
- ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
- /* Mark all tables to be written */
- jpeg_suppress_tables(cinfo, FALSE);
- /* (Re)initialize error mgr and destination modules */
- (*cinfo->err->reset_error_mgr) ((j_common_ptr)cinfo);
- (*cinfo->dest->init_destination) (cinfo);
- /* Perform master selection of active modules */
- transencode_master_selection(cinfo, coef_arrays);
- /* Wait for jpeg_finish_compress() call */
- cinfo->next_scanline = 0; /* so jpeg_write_marker works */
- cinfo->global_state = CSTATE_WRCOEFS;
-}
-
-
-/*
- * Initialize the compression object with default parameters,
- * then copy from the source object all parameters needed for lossless
- * transcoding. Parameters that can be varied without loss (such as
- * scan script and Huffman optimization) are left in their default states.
- */
-
-GLOBAL(void)
-jpeg_copy_critical_parameters(j_decompress_ptr srcinfo, j_compress_ptr dstinfo)
-{
- JQUANT_TBL **qtblptr;
- jpeg_component_info *incomp, *outcomp;
- JQUANT_TBL *c_quant, *slot_quant;
- int tblno, ci, coefi;
-
- /* Safety check to ensure start_compress not called yet. */
- if (dstinfo->global_state != CSTATE_START)
- ERREXIT1(dstinfo, JERR_BAD_STATE, dstinfo->global_state);
- /* Copy fundamental image dimensions */
- dstinfo->image_width = srcinfo->image_width;
- dstinfo->image_height = srcinfo->image_height;
- dstinfo->input_components = srcinfo->num_components;
- dstinfo->in_color_space = srcinfo->jpeg_color_space;
-#if JPEG_LIB_VERSION >= 70
- dstinfo->jpeg_width = srcinfo->output_width;
- dstinfo->jpeg_height = srcinfo->output_height;
- dstinfo->min_DCT_h_scaled_size = srcinfo->min_DCT_h_scaled_size;
- dstinfo->min_DCT_v_scaled_size = srcinfo->min_DCT_v_scaled_size;
-#endif
- /* Initialize all parameters to default values */
- jpeg_set_defaults(dstinfo);
- /* jpeg_set_defaults may choose wrong colorspace, eg YCbCr if input is RGB.
- * Fix it to get the right header markers for the image colorspace.
- */
- jpeg_set_colorspace(dstinfo, srcinfo->jpeg_color_space);
- dstinfo->data_precision = srcinfo->data_precision;
- dstinfo->CCIR601_sampling = srcinfo->CCIR601_sampling;
- /* Copy the source's quantization tables. */
- for (tblno = 0; tblno < NUM_QUANT_TBLS; tblno++) {
- if (srcinfo->quant_tbl_ptrs[tblno] != NULL) {
- qtblptr = &dstinfo->quant_tbl_ptrs[tblno];
- if (*qtblptr == NULL)
- *qtblptr = jpeg_alloc_quant_table((j_common_ptr)dstinfo);
- memcpy((*qtblptr)->quantval, srcinfo->quant_tbl_ptrs[tblno]->quantval,
- sizeof((*qtblptr)->quantval));
- (*qtblptr)->sent_table = FALSE;
- }
- }
- /* Copy the source's per-component info.
- * Note we assume jpeg_set_defaults has allocated the dest comp_info array.
- */
- dstinfo->num_components = srcinfo->num_components;
- if (dstinfo->num_components < 1 || dstinfo->num_components > MAX_COMPONENTS)
- ERREXIT2(dstinfo, JERR_COMPONENT_COUNT, dstinfo->num_components,
- MAX_COMPONENTS);
- for (ci = 0, incomp = srcinfo->comp_info, outcomp = dstinfo->comp_info;
- ci < dstinfo->num_components; ci++, incomp++, outcomp++) {
- outcomp->component_id = incomp->component_id;
- outcomp->h_samp_factor = incomp->h_samp_factor;
- outcomp->v_samp_factor = incomp->v_samp_factor;
- outcomp->quant_tbl_no = incomp->quant_tbl_no;
- /* Make sure saved quantization table for component matches the qtable
- * slot. If not, the input file re-used this qtable slot.
- * IJG encoder currently cannot duplicate this.
- */
- tblno = outcomp->quant_tbl_no;
- if (tblno < 0 || tblno >= NUM_QUANT_TBLS ||
- srcinfo->quant_tbl_ptrs[tblno] == NULL)
- ERREXIT1(dstinfo, JERR_NO_QUANT_TABLE, tblno);
- slot_quant = srcinfo->quant_tbl_ptrs[tblno];
- c_quant = incomp->quant_table;
- if (c_quant != NULL) {
- for (coefi = 0; coefi < DCTSIZE2; coefi++) {
- if (c_quant->quantval[coefi] != slot_quant->quantval[coefi])
- ERREXIT1(dstinfo, JERR_MISMATCHED_QUANT_TABLE, tblno);
- }
- }
- /* Note: we do not copy the source's Huffman table assignments;
- * instead we rely on jpeg_set_colorspace to have made a suitable choice.
- */
- }
- /* Also copy JFIF version and resolution information, if available.
- * Strictly speaking this isn't "critical" info, but it's nearly
- * always appropriate to copy it if available. In particular,
- * if the application chooses to copy JFIF 1.02 extension markers from
- * the source file, we need to copy the version to make sure we don't
- * emit a file that has 1.02 extensions but a claimed version of 1.01.
- * We will *not*, however, copy version info from mislabeled "2.01" files.
- */
- if (srcinfo->saw_JFIF_marker) {
- if (srcinfo->JFIF_major_version == 1) {
- dstinfo->JFIF_major_version = srcinfo->JFIF_major_version;
- dstinfo->JFIF_minor_version = srcinfo->JFIF_minor_version;
- }
- dstinfo->density_unit = srcinfo->density_unit;
- dstinfo->X_density = srcinfo->X_density;
- dstinfo->Y_density = srcinfo->Y_density;
- }
-}
-
-
-/*
- * Master selection of compression modules for transcoding.
- * This substitutes for jcinit.c's initialization of the full compressor.
- */
-
-LOCAL(void)
-transencode_master_selection(j_compress_ptr cinfo,
- jvirt_barray_ptr *coef_arrays)
-{
- /* Although we don't actually use input_components for transcoding,
- * jcmaster.c's initial_setup will complain if input_components is 0.
- */
- cinfo->input_components = 1;
- /* Initialize master control (includes parameter checking/processing) */
- jinit_c_master_control(cinfo, TRUE /* transcode only */);
-
- /* Entropy encoding: either Huffman or arithmetic coding. */
- if (cinfo->arith_code) {
-#ifdef C_ARITH_CODING_SUPPORTED
- jinit_arith_encoder(cinfo);
-#else
- ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
-#endif
- } else {
- if (cinfo->progressive_mode) {
-#ifdef C_PROGRESSIVE_SUPPORTED
- jinit_phuff_encoder(cinfo);
-#else
- ERREXIT(cinfo, JERR_NOT_COMPILED);
-#endif
- } else
- jinit_huff_encoder(cinfo);
- }
-
- /* We need a special coefficient buffer controller. */
- transencode_coef_controller(cinfo, coef_arrays);
-
- jinit_marker_writer(cinfo);
-
- /* We can now tell the memory manager to allocate virtual arrays. */
- (*cinfo->mem->realize_virt_arrays) ((j_common_ptr)cinfo);
-
- /* Write the datastream header (SOI, JFIF) immediately.
- * Frame and scan headers are postponed till later.
- * This lets application insert special markers after the SOI.
- */
- (*cinfo->marker->write_file_header) (cinfo);
-}
-
-
-/*
- * The rest of this file is a special implementation of the coefficient
- * buffer controller. This is similar to jccoefct.c, but it handles only
- * output from presupplied virtual arrays. Furthermore, we generate any
- * dummy padding blocks on-the-fly rather than expecting them to be present
- * in the arrays.
- */
-
-/* Private buffer controller object */
-
-typedef struct {
- struct jpeg_c_coef_controller pub; /* public fields */
-
- JDIMENSION iMCU_row_num; /* iMCU row # within image */
- JDIMENSION mcu_ctr; /* counts MCUs processed in current row */
- int MCU_vert_offset; /* counts MCU rows within iMCU row */
- int MCU_rows_per_iMCU_row; /* number of such rows needed */
-
- /* Virtual block array for each component. */
- jvirt_barray_ptr *whole_image;
-
- /* Workspace for constructing dummy blocks at right/bottom edges. */
- JBLOCKROW dummy_buffer[C_MAX_BLOCKS_IN_MCU];
-} my_coef_controller;
-
-typedef my_coef_controller *my_coef_ptr;
-
-
-LOCAL(void)
-start_iMCU_row(j_compress_ptr cinfo)
-/* Reset within-iMCU-row counters for a new row */
-{
- my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
-
- /* In an interleaved scan, an MCU row is the same as an iMCU row.
- * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows.
- * But at the bottom of the image, process only what's left.
- */
- if (cinfo->comps_in_scan > 1) {
- coef->MCU_rows_per_iMCU_row = 1;
- } else {
- if (coef->iMCU_row_num < (cinfo->total_iMCU_rows - 1))
- coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor;
- else
- coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height;
- }
-
- coef->mcu_ctr = 0;
- coef->MCU_vert_offset = 0;
-}
-
-
-/*
- * Initialize for a processing pass.
- */
-
-METHODDEF(void)
-start_pass_coef(j_compress_ptr cinfo, J_BUF_MODE pass_mode)
-{
- my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
-
- if (pass_mode != JBUF_CRANK_DEST)
- ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
-
- coef->iMCU_row_num = 0;
- start_iMCU_row(cinfo);
-}
-
-
-/*
- * Process some data.
- * We process the equivalent of one fully interleaved MCU row ("iMCU" row)
- * per call, ie, v_samp_factor block rows for each component in the scan.
- * The data is obtained from the virtual arrays and fed to the entropy coder.
- * Returns TRUE if the iMCU row is completed, FALSE if suspended.
- *
- * NB: input_buf is ignored; it is likely to be a NULL pointer.
- */
-
-METHODDEF(boolean)
-compress_output(j_compress_ptr cinfo, JSAMPIMAGE input_buf)
-{
- my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
- JDIMENSION MCU_col_num; /* index of current MCU within row */
- JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
- JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
- int blkn, ci, xindex, yindex, yoffset, blockcnt;
- JDIMENSION start_col;
- JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN];
- JBLOCKROW MCU_buffer[C_MAX_BLOCKS_IN_MCU];
- JBLOCKROW buffer_ptr;
- jpeg_component_info *compptr;
-
- /* Align the virtual buffers for the components used in this scan. */
- for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
- compptr = cinfo->cur_comp_info[ci];
- buffer[ci] = (*cinfo->mem->access_virt_barray)
- ((j_common_ptr)cinfo, coef->whole_image[compptr->component_index],
- coef->iMCU_row_num * compptr->v_samp_factor,
- (JDIMENSION)compptr->v_samp_factor, FALSE);
- }
-
- /* Loop to process one whole iMCU row */
- for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
- yoffset++) {
- for (MCU_col_num = coef->mcu_ctr; MCU_col_num < cinfo->MCUs_per_row;
- MCU_col_num++) {
- /* Construct list of pointers to DCT blocks belonging to this MCU */
- blkn = 0; /* index of current DCT block within MCU */
- for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
- compptr = cinfo->cur_comp_info[ci];
- start_col = MCU_col_num * compptr->MCU_width;
- blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width :
- compptr->last_col_width;
- for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
- if (coef->iMCU_row_num < last_iMCU_row ||
- yindex + yoffset < compptr->last_row_height) {
- /* Fill in pointers to real blocks in this row */
- buffer_ptr = buffer[ci][yindex + yoffset] + start_col;
- for (xindex = 0; xindex < blockcnt; xindex++)
- MCU_buffer[blkn++] = buffer_ptr++;
- } else {
- /* At bottom of image, need a whole row of dummy blocks */
- xindex = 0;
- }
- /* Fill in any dummy blocks needed in this row.
- * Dummy blocks are filled in the same way as in jccoefct.c:
- * all zeroes in the AC entries, DC entries equal to previous
- * block's DC value. The init routine has already zeroed the
- * AC entries, so we need only set the DC entries correctly.
- */
- for (; xindex < compptr->MCU_width; xindex++) {
- MCU_buffer[blkn] = coef->dummy_buffer[blkn];
- MCU_buffer[blkn][0][0] = MCU_buffer[blkn - 1][0][0];
- blkn++;
- }
- }
- }
- /* Try to write the MCU. */
- if (!(*cinfo->entropy->encode_mcu) (cinfo, MCU_buffer)) {
- /* Suspension forced; update state counters and exit */
- coef->MCU_vert_offset = yoffset;
- coef->mcu_ctr = MCU_col_num;
- return FALSE;
- }
- }
- /* Completed an MCU row, but perhaps not an iMCU row */
- coef->mcu_ctr = 0;
- }
- /* Completed the iMCU row, advance counters for next one */
- coef->iMCU_row_num++;
- start_iMCU_row(cinfo);
- return TRUE;
-}
-
-
-/*
- * Initialize coefficient buffer controller.
- *
- * Each passed coefficient array must be the right size for that
- * coefficient: width_in_blocks wide and height_in_blocks high,
- * with unitheight at least v_samp_factor.
- */
-
-LOCAL(void)
-transencode_coef_controller(j_compress_ptr cinfo,
- jvirt_barray_ptr *coef_arrays)
-{
- my_coef_ptr coef;
- JBLOCKROW buffer;
- int i;
-
- coef = (my_coef_ptr)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- sizeof(my_coef_controller));
- cinfo->coef = (struct jpeg_c_coef_controller *)coef;
- coef->pub.start_pass = start_pass_coef;
- coef->pub.compress_data = compress_output;
-
- /* Save pointer to virtual arrays */
- coef->whole_image = coef_arrays;
-
- /* Allocate and pre-zero space for dummy DCT blocks. */
- buffer = (JBLOCKROW)
- (*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- C_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK));
- jzero_far((void *)buffer, C_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK));
- for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) {
- coef->dummy_buffer[i] = buffer + i;
- }
-}
diff --git a/contrib/libs/libjpeg-turbo/jdapimin.c b/contrib/libs/libjpeg-turbo/jdapimin.c
deleted file mode 100644
index f50c27edc3..0000000000
--- a/contrib/libs/libjpeg-turbo/jdapimin.c
+++ /dev/null
@@ -1,408 +0,0 @@
-/*
- * jdapimin.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1994-1998, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2016, 2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains application interface code for the decompression half
- * of the JPEG library. These are the "minimum" API routines that may be
- * needed in either the normal full-decompression case or the
- * transcoding-only case.
- *
- * Most of the routines intended to be called directly by an application
- * are in this file or in jdapistd.c. But also see jcomapi.c for routines
- * shared by compression and decompression, and jdtrans.c for the transcoding
- * case.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-#include "jdmaster.h"
-#include "jconfigint.h"
-
-
-/*
- * Initialization of a JPEG decompression object.
- * The error manager must already be set up (in case memory manager fails).
- */
-
-GLOBAL(void)
-jpeg_CreateDecompress(j_decompress_ptr cinfo, int version, size_t structsize)
-{
- int i;
-
- /* Guard against version mismatches between library and caller. */
- cinfo->mem = NULL; /* so jpeg_destroy knows mem mgr not called */
- if (version != JPEG_LIB_VERSION)
- ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version);
- if (structsize != sizeof(struct jpeg_decompress_struct))
- ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE,
- (int)sizeof(struct jpeg_decompress_struct), (int)structsize);
-
- /* For debugging purposes, we zero the whole master structure.
- * But the application has already set the err pointer, and may have set
- * client_data, so we have to save and restore those fields.
- * Note: if application hasn't set client_data, tools like Purify may
- * complain here.
- */
- {
- struct jpeg_error_mgr *err = cinfo->err;
- void *client_data = cinfo->client_data; /* ignore Purify complaint here */
- memset(cinfo, 0, sizeof(struct jpeg_decompress_struct));
- cinfo->err = err;
- cinfo->client_data = client_data;
- }
- cinfo->is_decompressor = TRUE;
-
- /* Initialize a memory manager instance for this object */
- jinit_memory_mgr((j_common_ptr)cinfo);
-
- /* Zero out pointers to permanent structures. */
- cinfo->progress = NULL;
- cinfo->src = NULL;
-
- for (i = 0; i < NUM_QUANT_TBLS; i++)
- cinfo->quant_tbl_ptrs[i] = NULL;
-
- for (i = 0; i < NUM_HUFF_TBLS; i++) {
- cinfo->dc_huff_tbl_ptrs[i] = NULL;
- cinfo->ac_huff_tbl_ptrs[i] = NULL;
- }
-
- /* Initialize marker processor so application can override methods
- * for COM, APPn markers before calling jpeg_read_header.
- */
- cinfo->marker_list = NULL;
- jinit_marker_reader(cinfo);
-
- /* And initialize the overall input controller. */
- jinit_input_controller(cinfo);
-
- /* OK, I'm ready */
- cinfo->global_state = DSTATE_START;
-
- /* The master struct is used to store extension parameters, so we allocate it
- * here.
- */
- cinfo->master = (struct jpeg_decomp_master *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
- sizeof(my_decomp_master));
- memset(cinfo->master, 0, sizeof(my_decomp_master));
-}
-
-
-/*
- * Destruction of a JPEG decompression object
- */
-
-GLOBAL(void)
-jpeg_destroy_decompress(j_decompress_ptr cinfo)
-{
- jpeg_destroy((j_common_ptr)cinfo); /* use common routine */
-}
-
-
-/*
- * Abort processing of a JPEG decompression operation,
- * but don't destroy the object itself.
- */
-
-GLOBAL(void)
-jpeg_abort_decompress(j_decompress_ptr cinfo)
-{
- jpeg_abort((j_common_ptr)cinfo); /* use common routine */
-}
-
-
-/*
- * Set default decompression parameters.
- */
-
-LOCAL(void)
-default_decompress_parms(j_decompress_ptr cinfo)
-{
- /* Guess the input colorspace, and set output colorspace accordingly. */
- /* (Wish JPEG committee had provided a real way to specify this...) */
- /* Note application may override our guesses. */
- switch (cinfo->num_components) {
- case 1:
- cinfo->jpeg_color_space = JCS_GRAYSCALE;
- cinfo->out_color_space = JCS_GRAYSCALE;
- break;
-
- case 3:
- if (cinfo->saw_JFIF_marker) {
- cinfo->jpeg_color_space = JCS_YCbCr; /* JFIF implies YCbCr */
- } else if (cinfo->saw_Adobe_marker) {
- switch (cinfo->Adobe_transform) {
- case 0:
- cinfo->jpeg_color_space = JCS_RGB;
- break;
- case 1:
- cinfo->jpeg_color_space = JCS_YCbCr;
- break;
- default:
- WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform);
- cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */
- break;
- }
- } else {
- /* Saw no special markers, try to guess from the component IDs */
- int cid0 = cinfo->comp_info[0].component_id;
- int cid1 = cinfo->comp_info[1].component_id;
- int cid2 = cinfo->comp_info[2].component_id;
-
- if (cid0 == 1 && cid1 == 2 && cid2 == 3)
- cinfo->jpeg_color_space = JCS_YCbCr; /* assume JFIF w/out marker */
- else if (cid0 == 82 && cid1 == 71 && cid2 == 66)
- cinfo->jpeg_color_space = JCS_RGB; /* ASCII 'R', 'G', 'B' */
- else {
- TRACEMS3(cinfo, 1, JTRC_UNKNOWN_IDS, cid0, cid1, cid2);
- cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */
- }
- }
- /* Always guess RGB is proper output colorspace. */
- cinfo->out_color_space = JCS_RGB;
- break;
-
- case 4:
- if (cinfo->saw_Adobe_marker) {
- switch (cinfo->Adobe_transform) {
- case 0:
- cinfo->jpeg_color_space = JCS_CMYK;
- break;
- case 2:
- cinfo->jpeg_color_space = JCS_YCCK;
- break;
- default:
- WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform);
- cinfo->jpeg_color_space = JCS_YCCK; /* assume it's YCCK */
- break;
- }
- } else {
- /* No special markers, assume straight CMYK. */
- cinfo->jpeg_color_space = JCS_CMYK;
- }
- cinfo->out_color_space = JCS_CMYK;
- break;
-
- default:
- cinfo->jpeg_color_space = JCS_UNKNOWN;
- cinfo->out_color_space = JCS_UNKNOWN;
- break;
- }
-
- /* Set defaults for other decompression parameters. */
- cinfo->scale_num = 1; /* 1:1 scaling */
- cinfo->scale_denom = 1;
- cinfo->output_gamma = 1.0;
- cinfo->buffered_image = FALSE;
- cinfo->raw_data_out = FALSE;
- cinfo->dct_method = JDCT_DEFAULT;
- cinfo->do_fancy_upsampling = TRUE;
- cinfo->do_block_smoothing = TRUE;
- cinfo->quantize_colors = FALSE;
- /* We set these in case application only sets quantize_colors. */
- cinfo->dither_mode = JDITHER_FS;
-#ifdef QUANT_2PASS_SUPPORTED
- cinfo->two_pass_quantize = TRUE;
-#else
- cinfo->two_pass_quantize = FALSE;
-#endif
- cinfo->desired_number_of_colors = 256;
- cinfo->colormap = NULL;
- /* Initialize for no mode change in buffered-image mode. */
- cinfo->enable_1pass_quant = FALSE;
- cinfo->enable_external_quant = FALSE;
- cinfo->enable_2pass_quant = FALSE;
-}
-
-
-/*
- * Decompression startup: read start of JPEG datastream to see what's there.
- * Need only initialize JPEG object and supply a data source before calling.
- *
- * This routine will read as far as the first SOS marker (ie, actual start of
- * compressed data), and will save all tables and parameters in the JPEG
- * object. It will also initialize the decompression parameters to default
- * values, and finally return JPEG_HEADER_OK. On return, the application may
- * adjust the decompression parameters and then call jpeg_start_decompress.
- * (Or, if the application only wanted to determine the image parameters,
- * the data need not be decompressed. In that case, call jpeg_abort or
- * jpeg_destroy to release any temporary space.)
- * If an abbreviated (tables only) datastream is presented, the routine will
- * return JPEG_HEADER_TABLES_ONLY upon reaching EOI. The application may then
- * re-use the JPEG object to read the abbreviated image datastream(s).
- * It is unnecessary (but OK) to call jpeg_abort in this case.
- * The JPEG_SUSPENDED return code only occurs if the data source module
- * requests suspension of the decompressor. In this case the application
- * should load more source data and then re-call jpeg_read_header to resume
- * processing.
- * If a non-suspending data source is used and require_image is TRUE, then the
- * return code need not be inspected since only JPEG_HEADER_OK is possible.
- *
- * This routine is now just a front end to jpeg_consume_input, with some
- * extra error checking.
- */
-
-GLOBAL(int)
-jpeg_read_header(j_decompress_ptr cinfo, boolean require_image)
-{
- int retcode;
-
- if (cinfo->global_state != DSTATE_START &&
- cinfo->global_state != DSTATE_INHEADER)
- ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
-
- retcode = jpeg_consume_input(cinfo);
-
- switch (retcode) {
- case JPEG_REACHED_SOS:
- retcode = JPEG_HEADER_OK;
- break;
- case JPEG_REACHED_EOI:
- if (require_image) /* Complain if application wanted an image */
- ERREXIT(cinfo, JERR_NO_IMAGE);
- /* Reset to start state; it would be safer to require the application to
- * call jpeg_abort, but we can't change it now for compatibility reasons.
- * A side effect is to free any temporary memory (there shouldn't be any).
- */
- jpeg_abort((j_common_ptr)cinfo); /* sets state = DSTATE_START */
- retcode = JPEG_HEADER_TABLES_ONLY;
- break;
- case JPEG_SUSPENDED:
- /* no work */
- break;
- }
-
- return retcode;
-}
-
-
-/*
- * Consume data in advance of what the decompressor requires.
- * This can be called at any time once the decompressor object has
- * been created and a data source has been set up.
- *
- * This routine is essentially a state machine that handles a couple
- * of critical state-transition actions, namely initial setup and
- * transition from header scanning to ready-for-start_decompress.
- * All the actual input is done via the input controller's consume_input
- * method.
- */
-
-GLOBAL(int)
-jpeg_consume_input(j_decompress_ptr cinfo)
-{
- int retcode = JPEG_SUSPENDED;
-
- /* NB: every possible DSTATE value should be listed in this switch */
- switch (cinfo->global_state) {
- case DSTATE_START:
- /* Start-of-datastream actions: reset appropriate modules */
- (*cinfo->inputctl->reset_input_controller) (cinfo);
- /* Initialize application's data source module */
- (*cinfo->src->init_source) (cinfo);
- cinfo->global_state = DSTATE_INHEADER;
- FALLTHROUGH /*FALLTHROUGH*/
- case DSTATE_INHEADER:
- retcode = (*cinfo->inputctl->consume_input) (cinfo);
- if (retcode == JPEG_REACHED_SOS) { /* Found SOS, prepare to decompress */
- /* Set up default parameters based on header data */
- default_decompress_parms(cinfo);
- /* Set global state: ready for start_decompress */
- cinfo->global_state = DSTATE_READY;
- }
- break;
- case DSTATE_READY:
- /* Can't advance past first SOS until start_decompress is called */
- retcode = JPEG_REACHED_SOS;
- break;
- case DSTATE_PRELOAD:
- case DSTATE_PRESCAN:
- case DSTATE_SCANNING:
- case DSTATE_RAW_OK:
- case DSTATE_BUFIMAGE:
- case DSTATE_BUFPOST:
- case DSTATE_STOPPING:
- retcode = (*cinfo->inputctl->consume_input) (cinfo);
- break;
- default:
- ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
- }
- return retcode;
-}
-
-
-/*
- * Have we finished reading the input file?
- */
-
-GLOBAL(boolean)
-jpeg_input_complete(j_decompress_ptr cinfo)
-{
- /* Check for valid jpeg object */
- if (cinfo->global_state < DSTATE_START ||
- cinfo->global_state > DSTATE_STOPPING)
- ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
- return cinfo->inputctl->eoi_reached;
-}
-
-
-/*
- * Is there more than one scan?
- */
-
-GLOBAL(boolean)
-jpeg_has_multiple_scans(j_decompress_ptr cinfo)
-{
- /* Only valid after jpeg_read_header completes */
- if (cinfo->global_state < DSTATE_READY ||
- cinfo->global_state > DSTATE_STOPPING)
- ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
- return cinfo->inputctl->has_multiple_scans;
-}
-
-
-/*
- * Finish JPEG decompression.
- *
- * This will normally just verify the file trailer and release temp storage.
- *
- * Returns FALSE if suspended. The return value need be inspected only if
- * a suspending data source is used.
- */
-
-GLOBAL(boolean)
-jpeg_finish_decompress(j_decompress_ptr cinfo)
-{
- if ((cinfo->global_state == DSTATE_SCANNING ||
- cinfo->global_state == DSTATE_RAW_OK) && !cinfo->buffered_image) {
- /* Terminate final pass of non-buffered mode */
- if (cinfo->output_scanline < cinfo->output_height)
- ERREXIT(cinfo, JERR_TOO_LITTLE_DATA);
- (*cinfo->master->finish_output_pass) (cinfo);
- cinfo->global_state = DSTATE_STOPPING;
- } else if (cinfo->global_state == DSTATE_BUFIMAGE) {
- /* Finishing after a buffered-image operation */
- cinfo->global_state = DSTATE_STOPPING;
- } else if (cinfo->global_state != DSTATE_STOPPING) {
- /* STOPPING = repeat call after a suspension, anything else is error */
- ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
- }
- /* Read until EOI */
- while (!cinfo->inputctl->eoi_reached) {
- if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED)
- return FALSE; /* Suspend, come back later */
- }
- /* Do final cleanup */
- (*cinfo->src->term_source) (cinfo);
- /* We can use jpeg_abort to release memory and reset global_state */
- jpeg_abort((j_common_ptr)cinfo);
- return TRUE;
-}
diff --git a/contrib/libs/libjpeg-turbo/jdapistd.c b/contrib/libs/libjpeg-turbo/jdapistd.c
deleted file mode 100644
index 02cd0cb93a..0000000000
--- a/contrib/libs/libjpeg-turbo/jdapistd.c
+++ /dev/null
@@ -1,689 +0,0 @@
-/*
- * jdapistd.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2015-2020, 2022, D. R. Commander.
- * Copyright (C) 2015, Google, Inc.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains application interface code for the decompression half
- * of the JPEG library. These are the "standard" API routines that are
- * used in the normal full-decompression case. They are not used by a
- * transcoding-only application. Note that if an application links in
- * jpeg_start_decompress, it will end up linking in the entire decompressor.
- * We thus must separate this file from jdapimin.c to avoid linking the
- * whole decompression library into a transcoder.
- */
-
-#include "jinclude.h"
-#include "jdmainct.h"
-#include "jdcoefct.h"
-#include "jdmaster.h"
-#include "jdmerge.h"
-#include "jdsample.h"
-#include "jmemsys.h"
-
-/* Forward declarations */
-LOCAL(boolean) output_pass_setup(j_decompress_ptr cinfo);
-
-
-/*
- * Decompression initialization.
- * jpeg_read_header must be completed before calling this.
- *
- * If a multipass operating mode was selected, this will do all but the
- * last pass, and thus may take a great deal of time.
- *
- * Returns FALSE if suspended. The return value need be inspected only if
- * a suspending data source is used.
- */
-
-GLOBAL(boolean)
-jpeg_start_decompress(j_decompress_ptr cinfo)
-{
- if (cinfo->global_state == DSTATE_READY) {
- /* First call: initialize master control, select active modules */
- jinit_master_decompress(cinfo);
- if (cinfo->buffered_image) {
- /* No more work here; expecting jpeg_start_output next */
- cinfo->global_state = DSTATE_BUFIMAGE;
- return TRUE;
- }
- cinfo->global_state = DSTATE_PRELOAD;
- }
- if (cinfo->global_state == DSTATE_PRELOAD) {
- /* If file has multiple scans, absorb them all into the coef buffer */
- if (cinfo->inputctl->has_multiple_scans) {
-#ifdef D_MULTISCAN_FILES_SUPPORTED
- for (;;) {
- int retcode;
- /* Call progress monitor hook if present */
- if (cinfo->progress != NULL)
- (*cinfo->progress->progress_monitor) ((j_common_ptr)cinfo);
- /* Absorb some more input */
- retcode = (*cinfo->inputctl->consume_input) (cinfo);
- if (retcode == JPEG_SUSPENDED)
- return FALSE;
- if (retcode == JPEG_REACHED_EOI)
- break;
- /* Advance progress counter if appropriate */
- if (cinfo->progress != NULL &&
- (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) {
- if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) {
- /* jdmaster underestimated number of scans; ratchet up one scan */
- cinfo->progress->pass_limit += (long)cinfo->total_iMCU_rows;
- }
- }
- }
-#else
- ERREXIT(cinfo, JERR_NOT_COMPILED);
-#endif /* D_MULTISCAN_FILES_SUPPORTED */
- }
- cinfo->output_scan_number = cinfo->input_scan_number;
- } else if (cinfo->global_state != DSTATE_PRESCAN)
- ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
- /* Perform any dummy output passes, and set up for the final pass */
- return output_pass_setup(cinfo);
-}
-
-
-/*
- * Set up for an output pass, and perform any dummy pass(es) needed.
- * Common subroutine for jpeg_start_decompress and jpeg_start_output.
- * Entry: global_state = DSTATE_PRESCAN only if previously suspended.
- * Exit: If done, returns TRUE and sets global_state for proper output mode.
- * If suspended, returns FALSE and sets global_state = DSTATE_PRESCAN.
- */
-
-LOCAL(boolean)
-output_pass_setup(j_decompress_ptr cinfo)
-{
- if (cinfo->global_state != DSTATE_PRESCAN) {
- /* First call: do pass setup */
- (*cinfo->master->prepare_for_output_pass) (cinfo);
- cinfo->output_scanline = 0;
- cinfo->global_state = DSTATE_PRESCAN;
- }
- /* Loop over any required dummy passes */
- while (cinfo->master->is_dummy_pass) {
-#ifdef QUANT_2PASS_SUPPORTED
- /* Crank through the dummy pass */
- while (cinfo->output_scanline < cinfo->output_height) {
- JDIMENSION last_scanline;
- /* Call progress monitor hook if present */
- if (cinfo->progress != NULL) {
- cinfo->progress->pass_counter = (long)cinfo->output_scanline;
- cinfo->progress->pass_limit = (long)cinfo->output_height;
- (*cinfo->progress->progress_monitor) ((j_common_ptr)cinfo);
- }
- /* Process some data */
- last_scanline = cinfo->output_scanline;
- (*cinfo->main->process_data) (cinfo, (JSAMPARRAY)NULL,
- &cinfo->output_scanline, (JDIMENSION)0);
- if (cinfo->output_scanline == last_scanline)
- return FALSE; /* No progress made, must suspend */
- }
- /* Finish up dummy pass, and set up for another one */
- (*cinfo->master->finish_output_pass) (cinfo);
- (*cinfo->master->prepare_for_output_pass) (cinfo);
- cinfo->output_scanline = 0;
-#else
- ERREXIT(cinfo, JERR_NOT_COMPILED);
-#endif /* QUANT_2PASS_SUPPORTED */
- }
- /* Ready for application to drive output pass through
- * jpeg_read_scanlines or jpeg_read_raw_data.
- */
- cinfo->global_state = cinfo->raw_data_out ? DSTATE_RAW_OK : DSTATE_SCANNING;
- return TRUE;
-}
-
-
-/*
- * Enable partial scanline decompression
- *
- * Must be called after jpeg_start_decompress() and before any calls to
- * jpeg_read_scanlines() or jpeg_skip_scanlines().
- *
- * Refer to libjpeg.txt for more information.
- */
-
-GLOBAL(void)
-jpeg_crop_scanline(j_decompress_ptr cinfo, JDIMENSION *xoffset,
- JDIMENSION *width)
-{
- int ci, align, orig_downsampled_width;
- JDIMENSION input_xoffset;
- boolean reinit_upsampler = FALSE;
- jpeg_component_info *compptr;
-#ifdef UPSAMPLE_MERGING_SUPPORTED
- my_master_ptr master = (my_master_ptr)cinfo->master;
-#endif
-
- if ((cinfo->global_state != DSTATE_SCANNING &&
- cinfo->global_state != DSTATE_BUFIMAGE) || cinfo->output_scanline != 0)
- ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
-
- if (!xoffset || !width)
- ERREXIT(cinfo, JERR_BAD_CROP_SPEC);
-
- /* xoffset and width must fall within the output image dimensions. */
- if (*width == 0 || *xoffset + *width > cinfo->output_width)
- ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
-
- /* No need to do anything if the caller wants the entire width. */
- if (*width == cinfo->output_width)
- return;
-
- /* Ensuring the proper alignment of xoffset is tricky. At minimum, it
- * must align with an MCU boundary, because:
- *
- * (1) The IDCT is performed in blocks, and it is not feasible to modify
- * the algorithm so that it can transform partial blocks.
- * (2) Because of the SIMD extensions, any input buffer passed to the
- * upsampling and color conversion routines must be aligned to the
- * SIMD word size (for instance, 128-bit in the case of SSE2.) The
- * easiest way to accomplish this without copying data is to ensure
- * that upsampling and color conversion begin at the start of the
- * first MCU column that will be inverse transformed.
- *
- * In practice, we actually impose a stricter alignment requirement. We
- * require that xoffset be a multiple of the maximum MCU column width of all
- * of the components (the "iMCU column width.") This is to simplify the
- * single-pass decompression case, allowing us to use the same MCU column
- * width for all of the components.
- */
- if (cinfo->comps_in_scan == 1 && cinfo->num_components == 1)
- align = cinfo->_min_DCT_scaled_size;
- else
- align = cinfo->_min_DCT_scaled_size * cinfo->max_h_samp_factor;
-
- /* Adjust xoffset to the nearest iMCU boundary <= the requested value */
- input_xoffset = *xoffset;
- *xoffset = (input_xoffset / align) * align;
-
- /* Adjust the width so that the right edge of the output image is as
- * requested (only the left edge is altered.) It is important that calling
- * programs check this value after this function returns, so that they can
- * allocate an output buffer with the appropriate size.
- */
- *width = *width + input_xoffset - *xoffset;
- cinfo->output_width = *width;
-#ifdef UPSAMPLE_MERGING_SUPPORTED
- if (master->using_merged_upsample && cinfo->max_v_samp_factor == 2) {
- my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
- upsample->out_row_width =
- cinfo->output_width * cinfo->out_color_components;
- }
-#endif
-
- /* Set the first and last iMCU columns that we must decompress. These values
- * will be used in single-scan decompressions.
- */
- cinfo->master->first_iMCU_col = (JDIMENSION)(long)(*xoffset) / (long)align;
- cinfo->master->last_iMCU_col =
- (JDIMENSION)jdiv_round_up((long)(*xoffset + cinfo->output_width),
- (long)align) - 1;
-
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
- ci++, compptr++) {
- int hsf = (cinfo->comps_in_scan == 1 && cinfo->num_components == 1) ?
- 1 : compptr->h_samp_factor;
-
- /* Set downsampled_width to the new output width. */
- orig_downsampled_width = compptr->downsampled_width;
- compptr->downsampled_width =
- (JDIMENSION)jdiv_round_up((long)(cinfo->output_width *
- compptr->h_samp_factor),
- (long)cinfo->max_h_samp_factor);
- if (compptr->downsampled_width < 2 && orig_downsampled_width >= 2)
- reinit_upsampler = TRUE;
-
- /* Set the first and last iMCU columns that we must decompress. These
- * values will be used in multi-scan decompressions.
- */
- cinfo->master->first_MCU_col[ci] =
- (JDIMENSION)(long)(*xoffset * hsf) / (long)align;
- cinfo->master->last_MCU_col[ci] =
- (JDIMENSION)jdiv_round_up((long)((*xoffset + cinfo->output_width) * hsf),
- (long)align) - 1;
- }
-
- if (reinit_upsampler) {
- cinfo->master->jinit_upsampler_no_alloc = TRUE;
- jinit_upsampler(cinfo);
- cinfo->master->jinit_upsampler_no_alloc = FALSE;
- }
-}
-
-
-/*
- * Read some scanlines of data from the JPEG decompressor.
- *
- * The return value will be the number of lines actually read.
- * This may be less than the number requested in several cases,
- * including bottom of image, data source suspension, and operating
- * modes that emit multiple scanlines at a time.
- *
- * Note: we warn about excess calls to jpeg_read_scanlines() since
- * this likely signals an application programmer error. However,
- * an oversize buffer (max_lines > scanlines remaining) is not an error.
- */
-
-GLOBAL(JDIMENSION)
-jpeg_read_scanlines(j_decompress_ptr cinfo, JSAMPARRAY scanlines,
- JDIMENSION max_lines)
-{
- JDIMENSION row_ctr;
-
- if (cinfo->global_state != DSTATE_SCANNING)
- ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
- if (cinfo->output_scanline >= cinfo->output_height) {
- WARNMS(cinfo, JWRN_TOO_MUCH_DATA);
- return 0;
- }
-
- /* Call progress monitor hook if present */
- if (cinfo->progress != NULL) {
- cinfo->progress->pass_counter = (long)cinfo->output_scanline;
- cinfo->progress->pass_limit = (long)cinfo->output_height;
- (*cinfo->progress->progress_monitor) ((j_common_ptr)cinfo);
- }
-
- /* Process some data */
- row_ctr = 0;
- (*cinfo->main->process_data) (cinfo, scanlines, &row_ctr, max_lines);
- cinfo->output_scanline += row_ctr;
- return row_ctr;
-}
-
-
-/* Dummy color convert function used by jpeg_skip_scanlines() */
-LOCAL(void)
-noop_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
-{
-}
-
-
-/* Dummy quantize function used by jpeg_skip_scanlines() */
-LOCAL(void)
-noop_quantize(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPARRAY output_buf, int num_rows)
-{
-}
-
-
-/*
- * In some cases, it is best to call jpeg_read_scanlines() and discard the
- * output, rather than skipping the scanlines, because this allows us to
- * maintain the internal state of the context-based upsampler. In these cases,
- * we set up and tear down a dummy color converter in order to avoid valgrind
- * errors and to achieve the best possible performance.
- */
-
-LOCAL(void)
-read_and_discard_scanlines(j_decompress_ptr cinfo, JDIMENSION num_lines)
-{
- JDIMENSION n;
-#ifdef UPSAMPLE_MERGING_SUPPORTED
- my_master_ptr master = (my_master_ptr)cinfo->master;
-#endif
- JSAMPLE dummy_sample[1] = { 0 };
- JSAMPROW dummy_row = dummy_sample;
- JSAMPARRAY scanlines = NULL;
- void (*color_convert) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf,
- int num_rows) = NULL;
- void (*color_quantize) (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPARRAY output_buf, int num_rows) = NULL;
-
- if (cinfo->cconvert && cinfo->cconvert->color_convert) {
- color_convert = cinfo->cconvert->color_convert;
- cinfo->cconvert->color_convert = noop_convert;
- /* This just prevents UBSan from complaining about adding 0 to a NULL
- * pointer. The pointer isn't actually used.
- */
- scanlines = &dummy_row;
- }
-
- if (cinfo->cquantize && cinfo->cquantize->color_quantize) {
- color_quantize = cinfo->cquantize->color_quantize;
- cinfo->cquantize->color_quantize = noop_quantize;
- }
-
-#ifdef UPSAMPLE_MERGING_SUPPORTED
- if (master->using_merged_upsample && cinfo->max_v_samp_factor == 2) {
- my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
- scanlines = &upsample->spare_row;
- }
-#endif
-
- for (n = 0; n < num_lines; n++)
- jpeg_read_scanlines(cinfo, scanlines, 1);
-
- if (color_convert)
- cinfo->cconvert->color_convert = color_convert;
-
- if (color_quantize)
- cinfo->cquantize->color_quantize = color_quantize;
-}
-
-
-/*
- * Called by jpeg_skip_scanlines(). This partially skips a decompress block by
- * incrementing the rowgroup counter.
- */
-
-LOCAL(void)
-increment_simple_rowgroup_ctr(j_decompress_ptr cinfo, JDIMENSION rows)
-{
- JDIMENSION rows_left;
- my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
- my_master_ptr master = (my_master_ptr)cinfo->master;
-
- if (master->using_merged_upsample && cinfo->max_v_samp_factor == 2) {
- read_and_discard_scanlines(cinfo, rows);
- return;
- }
-
- /* Increment the counter to the next row group after the skipped rows. */
- main_ptr->rowgroup_ctr += rows / cinfo->max_v_samp_factor;
-
- /* Partially skipping a row group would involve modifying the internal state
- * of the upsampler, so read the remaining rows into a dummy buffer instead.
- */
- rows_left = rows % cinfo->max_v_samp_factor;
- cinfo->output_scanline += rows - rows_left;
-
- read_and_discard_scanlines(cinfo, rows_left);
-}
-
-/*
- * Skips some scanlines of data from the JPEG decompressor.
- *
- * The return value will be the number of lines actually skipped. If skipping
- * num_lines would move beyond the end of the image, then the actual number of
- * lines remaining in the image is returned. Otherwise, the return value will
- * be equal to num_lines.
- *
- * Refer to libjpeg.txt for more information.
- */
-
-GLOBAL(JDIMENSION)
-jpeg_skip_scanlines(j_decompress_ptr cinfo, JDIMENSION num_lines)
-{
- my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
- my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
- my_master_ptr master = (my_master_ptr)cinfo->master;
- my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
- JDIMENSION i, x;
- int y;
- JDIMENSION lines_per_iMCU_row, lines_left_in_iMCU_row, lines_after_iMCU_row;
- JDIMENSION lines_to_skip, lines_to_read;
-
- /* Two-pass color quantization is not supported. */
- if (cinfo->quantize_colors && cinfo->two_pass_quantize)
- ERREXIT(cinfo, JERR_NOTIMPL);
-
- if (cinfo->global_state != DSTATE_SCANNING)
- ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
-
- /* Do not skip past the bottom of the image. */
- if (cinfo->output_scanline + num_lines >= cinfo->output_height) {
- num_lines = cinfo->output_height - cinfo->output_scanline;
- cinfo->output_scanline = cinfo->output_height;
- (*cinfo->inputctl->finish_input_pass) (cinfo);
- cinfo->inputctl->eoi_reached = TRUE;
- return num_lines;
- }
-
- if (num_lines == 0)
- return 0;
-
- lines_per_iMCU_row = cinfo->_min_DCT_scaled_size * cinfo->max_v_samp_factor;
- lines_left_in_iMCU_row =
- (lines_per_iMCU_row - (cinfo->output_scanline % lines_per_iMCU_row)) %
- lines_per_iMCU_row;
- lines_after_iMCU_row = num_lines - lines_left_in_iMCU_row;
-
- /* Skip the lines remaining in the current iMCU row. When upsampling
- * requires context rows, we need the previous and next rows in order to read
- * the current row. This adds some complexity.
- */
- if (cinfo->upsample->need_context_rows) {
- /* If the skipped lines would not move us past the current iMCU row, we
- * read the lines and ignore them. There might be a faster way of doing
- * this, but we are facing increasing complexity for diminishing returns.
- * The increasing complexity would be a by-product of meddling with the
- * state machine used to skip context rows. Near the end of an iMCU row,
- * the next iMCU row may have already been entropy-decoded. In this unique
- * case, we will read the next iMCU row if we cannot skip past it as well.
- */
- if ((num_lines < lines_left_in_iMCU_row + 1) ||
- (lines_left_in_iMCU_row <= 1 && main_ptr->buffer_full &&
- lines_after_iMCU_row < lines_per_iMCU_row + 1)) {
- read_and_discard_scanlines(cinfo, num_lines);
- return num_lines;
- }
-
- /* If the next iMCU row has already been entropy-decoded, make sure that
- * we do not skip too far.
- */
- if (lines_left_in_iMCU_row <= 1 && main_ptr->buffer_full) {
- cinfo->output_scanline += lines_left_in_iMCU_row + lines_per_iMCU_row;
- lines_after_iMCU_row -= lines_per_iMCU_row;
- } else {
- cinfo->output_scanline += lines_left_in_iMCU_row;
- }
-
- /* If we have just completed the first block, adjust the buffer pointers */
- if (main_ptr->iMCU_row_ctr == 0 ||
- (main_ptr->iMCU_row_ctr == 1 && lines_left_in_iMCU_row > 2))
- set_wraparound_pointers(cinfo);
- main_ptr->buffer_full = FALSE;
- main_ptr->rowgroup_ctr = 0;
- main_ptr->context_state = CTX_PREPARE_FOR_IMCU;
- if (!master->using_merged_upsample) {
- upsample->next_row_out = cinfo->max_v_samp_factor;
- upsample->rows_to_go = cinfo->output_height - cinfo->output_scanline;
- }
- }
-
- /* Skipping is much simpler when context rows are not required. */
- else {
- if (num_lines < lines_left_in_iMCU_row) {
- increment_simple_rowgroup_ctr(cinfo, num_lines);
- return num_lines;
- } else {
- cinfo->output_scanline += lines_left_in_iMCU_row;
- main_ptr->buffer_full = FALSE;
- main_ptr->rowgroup_ctr = 0;
- if (!master->using_merged_upsample) {
- upsample->next_row_out = cinfo->max_v_samp_factor;
- upsample->rows_to_go = cinfo->output_height - cinfo->output_scanline;
- }
- }
- }
-
- /* Calculate how many full iMCU rows we can skip. */
- if (cinfo->upsample->need_context_rows)
- lines_to_skip = ((lines_after_iMCU_row - 1) / lines_per_iMCU_row) *
- lines_per_iMCU_row;
- else
- lines_to_skip = (lines_after_iMCU_row / lines_per_iMCU_row) *
- lines_per_iMCU_row;
- /* Calculate the number of lines that remain to be skipped after skipping all
- * of the full iMCU rows that we can. We will not read these lines unless we
- * have to.
- */
- lines_to_read = lines_after_iMCU_row - lines_to_skip;
-
- /* For images requiring multiple scans (progressive, non-interleaved, etc.),
- * all of the entropy decoding occurs in jpeg_start_decompress(), assuming
- * that the input data source is non-suspending. This makes skipping easy.
- */
- if (cinfo->inputctl->has_multiple_scans || cinfo->buffered_image) {
- if (cinfo->upsample->need_context_rows) {
- cinfo->output_scanline += lines_to_skip;
- cinfo->output_iMCU_row += lines_to_skip / lines_per_iMCU_row;
- main_ptr->iMCU_row_ctr += lines_to_skip / lines_per_iMCU_row;
- /* It is complex to properly move to the middle of a context block, so
- * read the remaining lines instead of skipping them.
- */
- read_and_discard_scanlines(cinfo, lines_to_read);
- } else {
- cinfo->output_scanline += lines_to_skip;
- cinfo->output_iMCU_row += lines_to_skip / lines_per_iMCU_row;
- increment_simple_rowgroup_ctr(cinfo, lines_to_read);
- }
- if (!master->using_merged_upsample)
- upsample->rows_to_go = cinfo->output_height - cinfo->output_scanline;
- return num_lines;
- }
-
- /* Skip the iMCU rows that we can safely skip. */
- for (i = 0; i < lines_to_skip; i += lines_per_iMCU_row) {
- for (y = 0; y < coef->MCU_rows_per_iMCU_row; y++) {
- for (x = 0; x < cinfo->MCUs_per_row; x++) {
- /* Calling decode_mcu() with a NULL pointer causes it to discard the
- * decoded coefficients. This is ~5% faster for large subsets, but
- * it's tough to tell a difference for smaller images.
- */
- if (!cinfo->entropy->insufficient_data)
- cinfo->master->last_good_iMCU_row = cinfo->input_iMCU_row;
- (*cinfo->entropy->decode_mcu) (cinfo, NULL);
- }
- }
- cinfo->input_iMCU_row++;
- cinfo->output_iMCU_row++;
- if (cinfo->input_iMCU_row < cinfo->total_iMCU_rows)
- start_iMCU_row(cinfo);
- else
- (*cinfo->inputctl->finish_input_pass) (cinfo);
- }
- cinfo->output_scanline += lines_to_skip;
-
- if (cinfo->upsample->need_context_rows) {
- /* Context-based upsampling keeps track of iMCU rows. */
- main_ptr->iMCU_row_ctr += lines_to_skip / lines_per_iMCU_row;
-
- /* It is complex to properly move to the middle of a context block, so
- * read the remaining lines instead of skipping them.
- */
- read_and_discard_scanlines(cinfo, lines_to_read);
- } else {
- increment_simple_rowgroup_ctr(cinfo, lines_to_read);
- }
-
- /* Since skipping lines involves skipping the upsampling step, the value of
- * "rows_to_go" will become invalid unless we set it here. NOTE: This is a
- * bit odd, since "rows_to_go" seems to be redundantly keeping track of
- * output_scanline.
- */
- if (!master->using_merged_upsample)
- upsample->rows_to_go = cinfo->output_height - cinfo->output_scanline;
-
- /* Always skip the requested number of lines. */
- return num_lines;
-}
-
-/*
- * Alternate entry point to read raw data.
- * Processes exactly one iMCU row per call, unless suspended.
- */
-
-GLOBAL(JDIMENSION)
-jpeg_read_raw_data(j_decompress_ptr cinfo, JSAMPIMAGE data,
- JDIMENSION max_lines)
-{
- JDIMENSION lines_per_iMCU_row;
-
- if (cinfo->global_state != DSTATE_RAW_OK)
- ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
- if (cinfo->output_scanline >= cinfo->output_height) {
- WARNMS(cinfo, JWRN_TOO_MUCH_DATA);
- return 0;
- }
-
- /* Call progress monitor hook if present */
- if (cinfo->progress != NULL) {
- cinfo->progress->pass_counter = (long)cinfo->output_scanline;
- cinfo->progress->pass_limit = (long)cinfo->output_height;
- (*cinfo->progress->progress_monitor) ((j_common_ptr)cinfo);
- }
-
- /* Verify that at least one iMCU row can be returned. */
- lines_per_iMCU_row = cinfo->max_v_samp_factor * cinfo->_min_DCT_scaled_size;
- if (max_lines < lines_per_iMCU_row)
- ERREXIT(cinfo, JERR_BUFFER_SIZE);
-
- /* Decompress directly into user's buffer. */
- if (!(*cinfo->coef->decompress_data) (cinfo, data))
- return 0; /* suspension forced, can do nothing more */
-
- /* OK, we processed one iMCU row. */
- cinfo->output_scanline += lines_per_iMCU_row;
- return lines_per_iMCU_row;
-}
-
-
-/* Additional entry points for buffered-image mode. */
-
-#ifdef D_MULTISCAN_FILES_SUPPORTED
-
-/*
- * Initialize for an output pass in buffered-image mode.
- */
-
-GLOBAL(boolean)
-jpeg_start_output(j_decompress_ptr cinfo, int scan_number)
-{
- if (cinfo->global_state != DSTATE_BUFIMAGE &&
- cinfo->global_state != DSTATE_PRESCAN)
- ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
- /* Limit scan number to valid range */
- if (scan_number <= 0)
- scan_number = 1;
- if (cinfo->inputctl->eoi_reached && scan_number > cinfo->input_scan_number)
- scan_number = cinfo->input_scan_number;
- cinfo->output_scan_number = scan_number;
- /* Perform any dummy output passes, and set up for the real pass */
- return output_pass_setup(cinfo);
-}
-
-
-/*
- * Finish up after an output pass in buffered-image mode.
- *
- * Returns FALSE if suspended. The return value need be inspected only if
- * a suspending data source is used.
- */
-
-GLOBAL(boolean)
-jpeg_finish_output(j_decompress_ptr cinfo)
-{
- if ((cinfo->global_state == DSTATE_SCANNING ||
- cinfo->global_state == DSTATE_RAW_OK) && cinfo->buffered_image) {
- /* Terminate this pass. */
- /* We do not require the whole pass to have been completed. */
- (*cinfo->master->finish_output_pass) (cinfo);
- cinfo->global_state = DSTATE_BUFPOST;
- } else if (cinfo->global_state != DSTATE_BUFPOST) {
- /* BUFPOST = repeat call after a suspension, anything else is error */
- ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
- }
- /* Read markers looking for SOS or EOI */
- while (cinfo->input_scan_number <= cinfo->output_scan_number &&
- !cinfo->inputctl->eoi_reached) {
- if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED)
- return FALSE; /* Suspend, come back later */
- }
- cinfo->global_state = DSTATE_BUFIMAGE;
- return TRUE;
-}
-
-#endif /* D_MULTISCAN_FILES_SUPPORTED */
diff --git a/contrib/libs/libjpeg-turbo/jdarith.c b/contrib/libs/libjpeg-turbo/jdarith.c
deleted file mode 100644
index 21575e80c7..0000000000
--- a/contrib/libs/libjpeg-turbo/jdarith.c
+++ /dev/null
@@ -1,782 +0,0 @@
-/*
- * jdarith.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Developed 1997-2015 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2015-2020, 2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains portable arithmetic entropy encoding routines for JPEG
- * (implementing Recommendation ITU-T T.81 | ISO/IEC 10918-1).
- *
- * Both sequential and progressive modes are supported in this single module.
- *
- * Suspension is not currently supported in this module.
- *
- * NOTE: All referenced figures are from
- * Recommendation ITU-T T.81 (1992) | ISO/IEC 10918-1:1994.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-
-
-#define NEG_1 ((unsigned int)-1)
-
-
-/* Expanded entropy decoder object for arithmetic decoding. */
-
-typedef struct {
- struct jpeg_entropy_decoder pub; /* public fields */
-
- JLONG c; /* C register, base of coding interval + input bit buffer */
- JLONG a; /* A register, normalized size of coding interval */
- int ct; /* bit shift counter, # of bits left in bit buffer part of C */
- /* init: ct = -16 */
- /* run: ct = 0..7 */
- /* error: ct = -1 */
- int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */
- int dc_context[MAX_COMPS_IN_SCAN]; /* context index for DC conditioning */
-
- unsigned int restarts_to_go; /* MCUs left in this restart interval */
-
- /* Pointers to statistics areas (these workspaces have image lifespan) */
- unsigned char *dc_stats[NUM_ARITH_TBLS];
- unsigned char *ac_stats[NUM_ARITH_TBLS];
-
- /* Statistics bin for coding with fixed probability 0.5 */
- unsigned char fixed_bin[4];
-} arith_entropy_decoder;
-
-typedef arith_entropy_decoder *arith_entropy_ptr;
-
-/* The following two definitions specify the allocation chunk size
- * for the statistics area.
- * According to sections F.1.4.4.1.3 and F.1.4.4.2, we need at least
- * 49 statistics bins for DC, and 245 statistics bins for AC coding.
- *
- * We use a compact representation with 1 byte per statistics bin,
- * thus the numbers directly represent byte sizes.
- * This 1 byte per statistics bin contains the meaning of the MPS
- * (more probable symbol) in the highest bit (mask 0x80), and the
- * index into the probability estimation state machine table
- * in the lower bits (mask 0x7F).
- */
-
-#define DC_STAT_BINS 64
-#define AC_STAT_BINS 256
-
-
-LOCAL(int)
-get_byte(j_decompress_ptr cinfo)
-/* Read next input byte; we do not support suspension in this module. */
-{
- struct jpeg_source_mgr *src = cinfo->src;
-
- if (src->bytes_in_buffer == 0)
- if (!(*src->fill_input_buffer) (cinfo))
- ERREXIT(cinfo, JERR_CANT_SUSPEND);
- src->bytes_in_buffer--;
- return *src->next_input_byte++;
-}
-
-
-/*
- * The core arithmetic decoding routine (common in JPEG and JBIG).
- * This needs to go as fast as possible.
- * Machine-dependent optimization facilities
- * are not utilized in this portable implementation.
- * However, this code should be fairly efficient and
- * may be a good base for further optimizations anyway.
- *
- * Return value is 0 or 1 (binary decision).
- *
- * Note: I've changed the handling of the code base & bit
- * buffer register C compared to other implementations
- * based on the standards layout & procedures.
- * While it also contains both the actual base of the
- * coding interval (16 bits) and the next-bits buffer,
- * the cut-point between these two parts is floating
- * (instead of fixed) with the bit shift counter CT.
- * Thus, we also need only one (variable instead of
- * fixed size) shift for the LPS/MPS decision, and
- * we can do away with any renormalization update
- * of C (except for new data insertion, of course).
- *
- * I've also introduced a new scheme for accessing
- * the probability estimation state machine table,
- * derived from Markus Kuhn's JBIG implementation.
- */
-
-LOCAL(int)
-arith_decode(j_decompress_ptr cinfo, unsigned char *st)
-{
- register arith_entropy_ptr e = (arith_entropy_ptr)cinfo->entropy;
- register unsigned char nl, nm;
- register JLONG qe, temp;
- register int sv, data;
-
- /* Renormalization & data input per section D.2.6 */
- while (e->a < 0x8000L) {
- if (--e->ct < 0) {
- /* Need to fetch next data byte */
- if (cinfo->unread_marker)
- data = 0; /* stuff zero data */
- else {
- data = get_byte(cinfo); /* read next input byte */
- if (data == 0xFF) { /* zero stuff or marker code */
- do data = get_byte(cinfo);
- while (data == 0xFF); /* swallow extra 0xFF bytes */
- if (data == 0)
- data = 0xFF; /* discard stuffed zero byte */
- else {
- /* Note: Different from the Huffman decoder, hitting
- * a marker while processing the compressed data
- * segment is legal in arithmetic coding.
- * The convention is to supply zero data
- * then until decoding is complete.
- */
- cinfo->unread_marker = data;
- data = 0;
- }
- }
- }
- e->c = (e->c << 8) | data; /* insert data into C register */
- if ((e->ct += 8) < 0) /* update bit shift counter */
- /* Need more initial bytes */
- if (++e->ct == 0)
- /* Got 2 initial bytes -> re-init A and exit loop */
- e->a = 0x8000L; /* => e->a = 0x10000L after loop exit */
- }
- e->a <<= 1;
- }
-
- /* Fetch values from our compact representation of Table D.2:
- * Qe values and probability estimation state machine
- */
- sv = *st;
- qe = jpeg_aritab[sv & 0x7F]; /* => Qe_Value */
- nl = qe & 0xFF; qe >>= 8; /* Next_Index_LPS + Switch_MPS */
- nm = qe & 0xFF; qe >>= 8; /* Next_Index_MPS */
-
- /* Decode & estimation procedures per sections D.2.4 & D.2.5 */
- temp = e->a - qe;
- e->a = temp;
- temp <<= e->ct;
- if (e->c >= temp) {
- e->c -= temp;
- /* Conditional LPS (less probable symbol) exchange */
- if (e->a < qe) {
- e->a = qe;
- *st = (sv & 0x80) ^ nm; /* Estimate_after_MPS */
- } else {
- e->a = qe;
- *st = (sv & 0x80) ^ nl; /* Estimate_after_LPS */
- sv ^= 0x80; /* Exchange LPS/MPS */
- }
- } else if (e->a < 0x8000L) {
- /* Conditional MPS (more probable symbol) exchange */
- if (e->a < qe) {
- *st = (sv & 0x80) ^ nl; /* Estimate_after_LPS */
- sv ^= 0x80; /* Exchange LPS/MPS */
- } else {
- *st = (sv & 0x80) ^ nm; /* Estimate_after_MPS */
- }
- }
-
- return sv >> 7;
-}
-
-
-/*
- * Check for a restart marker & resynchronize decoder.
- */
-
-LOCAL(void)
-process_restart(j_decompress_ptr cinfo)
-{
- arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
- int ci;
- jpeg_component_info *compptr;
-
- /* Advance past the RSTn marker */
- if (!(*cinfo->marker->read_restart_marker) (cinfo))
- ERREXIT(cinfo, JERR_CANT_SUSPEND);
-
- /* Re-initialize statistics areas */
- for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
- compptr = cinfo->cur_comp_info[ci];
- if (!cinfo->progressive_mode || (cinfo->Ss == 0 && cinfo->Ah == 0)) {
- memset(entropy->dc_stats[compptr->dc_tbl_no], 0, DC_STAT_BINS);
- /* Reset DC predictions to 0 */
- entropy->last_dc_val[ci] = 0;
- entropy->dc_context[ci] = 0;
- }
- if (!cinfo->progressive_mode || cinfo->Ss) {
- memset(entropy->ac_stats[compptr->ac_tbl_no], 0, AC_STAT_BINS);
- }
- }
-
- /* Reset arithmetic decoding variables */
- entropy->c = 0;
- entropy->a = 0;
- entropy->ct = -16; /* force reading 2 initial bytes to fill C */
-
- /* Reset restart counter */
- entropy->restarts_to_go = cinfo->restart_interval;
-}
-
-
-/*
- * Arithmetic MCU decoding.
- * Each of these routines decodes and returns one MCU's worth of
- * arithmetic-compressed coefficients.
- * The coefficients are reordered from zigzag order into natural array order,
- * but are not dequantized.
- *
- * The i'th block of the MCU is stored into the block pointed to by
- * MCU_data[i]. WE ASSUME THIS AREA IS INITIALLY ZEROED BY THE CALLER.
- */
-
-/*
- * MCU decoding for DC initial scan (either spectral selection,
- * or first pass of successive approximation).
- */
-
-METHODDEF(boolean)
-decode_mcu_DC_first(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
-{
- arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
- JBLOCKROW block;
- unsigned char *st;
- int blkn, ci, tbl, sign;
- int v, m;
-
- /* Process restart marker if needed */
- if (cinfo->restart_interval) {
- if (entropy->restarts_to_go == 0)
- process_restart(cinfo);
- entropy->restarts_to_go--;
- }
-
- if (entropy->ct == -1) return TRUE; /* if error do nothing */
-
- /* Outer loop handles each block in the MCU */
-
- for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
- block = MCU_data[blkn];
- ci = cinfo->MCU_membership[blkn];
- tbl = cinfo->cur_comp_info[ci]->dc_tbl_no;
-
- /* Sections F.2.4.1 & F.1.4.4.1: Decoding of DC coefficients */
-
- /* Table F.4: Point to statistics bin S0 for DC coefficient coding */
- st = entropy->dc_stats[tbl] + entropy->dc_context[ci];
-
- /* Figure F.19: Decode_DC_DIFF */
- if (arith_decode(cinfo, st) == 0)
- entropy->dc_context[ci] = 0;
- else {
- /* Figure F.21: Decoding nonzero value v */
- /* Figure F.22: Decoding the sign of v */
- sign = arith_decode(cinfo, st + 1);
- st += 2; st += sign;
- /* Figure F.23: Decoding the magnitude category of v */
- if ((m = arith_decode(cinfo, st)) != 0) {
- st = entropy->dc_stats[tbl] + 20; /* Table F.4: X1 = 20 */
- while (arith_decode(cinfo, st)) {
- if ((m <<= 1) == 0x8000) {
- WARNMS(cinfo, JWRN_ARITH_BAD_CODE);
- entropy->ct = -1; /* magnitude overflow */
- return TRUE;
- }
- st += 1;
- }
- }
- /* Section F.1.4.4.1.2: Establish dc_context conditioning category */
- if (m < (int)((1L << cinfo->arith_dc_L[tbl]) >> 1))
- entropy->dc_context[ci] = 0; /* zero diff category */
- else if (m > (int)((1L << cinfo->arith_dc_U[tbl]) >> 1))
- entropy->dc_context[ci] = 12 + (sign * 4); /* large diff category */
- else
- entropy->dc_context[ci] = 4 + (sign * 4); /* small diff category */
- v = m;
- /* Figure F.24: Decoding the magnitude bit pattern of v */
- st += 14;
- while (m >>= 1)
- if (arith_decode(cinfo, st)) v |= m;
- v += 1; if (sign) v = -v;
- entropy->last_dc_val[ci] = (entropy->last_dc_val[ci] + v) & 0xffff;
- }
-
- /* Scale and output the DC coefficient (assumes jpeg_natural_order[0]=0) */
- (*block)[0] = (JCOEF)LEFT_SHIFT(entropy->last_dc_val[ci], cinfo->Al);
- }
-
- return TRUE;
-}
-
-
-/*
- * MCU decoding for AC initial scan (either spectral selection,
- * or first pass of successive approximation).
- */
-
-METHODDEF(boolean)
-decode_mcu_AC_first(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
-{
- arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
- JBLOCKROW block;
- unsigned char *st;
- int tbl, sign, k;
- int v, m;
-
- /* Process restart marker if needed */
- if (cinfo->restart_interval) {
- if (entropy->restarts_to_go == 0)
- process_restart(cinfo);
- entropy->restarts_to_go--;
- }
-
- if (entropy->ct == -1) return TRUE; /* if error do nothing */
-
- /* There is always only one block per MCU */
- block = MCU_data[0];
- tbl = cinfo->cur_comp_info[0]->ac_tbl_no;
-
- /* Sections F.2.4.2 & F.1.4.4.2: Decoding of AC coefficients */
-
- /* Figure F.20: Decode_AC_coefficients */
- for (k = cinfo->Ss; k <= cinfo->Se; k++) {
- st = entropy->ac_stats[tbl] + 3 * (k - 1);
- if (arith_decode(cinfo, st)) break; /* EOB flag */
- while (arith_decode(cinfo, st + 1) == 0) {
- st += 3; k++;
- if (k > cinfo->Se) {
- WARNMS(cinfo, JWRN_ARITH_BAD_CODE);
- entropy->ct = -1; /* spectral overflow */
- return TRUE;
- }
- }
- /* Figure F.21: Decoding nonzero value v */
- /* Figure F.22: Decoding the sign of v */
- sign = arith_decode(cinfo, entropy->fixed_bin);
- st += 2;
- /* Figure F.23: Decoding the magnitude category of v */
- if ((m = arith_decode(cinfo, st)) != 0) {
- if (arith_decode(cinfo, st)) {
- m <<= 1;
- st = entropy->ac_stats[tbl] +
- (k <= cinfo->arith_ac_K[tbl] ? 189 : 217);
- while (arith_decode(cinfo, st)) {
- if ((m <<= 1) == 0x8000) {
- WARNMS(cinfo, JWRN_ARITH_BAD_CODE);
- entropy->ct = -1; /* magnitude overflow */
- return TRUE;
- }
- st += 1;
- }
- }
- }
- v = m;
- /* Figure F.24: Decoding the magnitude bit pattern of v */
- st += 14;
- while (m >>= 1)
- if (arith_decode(cinfo, st)) v |= m;
- v += 1; if (sign) v = -v;
- /* Scale and output coefficient in natural (dezigzagged) order */
- (*block)[jpeg_natural_order[k]] = (JCOEF)((unsigned)v << cinfo->Al);
- }
-
- return TRUE;
-}
-
-
-/*
- * MCU decoding for DC successive approximation refinement scan.
- */
-
-METHODDEF(boolean)
-decode_mcu_DC_refine(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
-{
- arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
- unsigned char *st;
- int p1, blkn;
-
- /* Process restart marker if needed */
- if (cinfo->restart_interval) {
- if (entropy->restarts_to_go == 0)
- process_restart(cinfo);
- entropy->restarts_to_go--;
- }
-
- st = entropy->fixed_bin; /* use fixed probability estimation */
- p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */
-
- /* Outer loop handles each block in the MCU */
-
- for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
- /* Encoded data is simply the next bit of the two's-complement DC value */
- if (arith_decode(cinfo, st))
- MCU_data[blkn][0][0] |= p1;
- }
-
- return TRUE;
-}
-
-
-/*
- * MCU decoding for AC successive approximation refinement scan.
- */
-
-METHODDEF(boolean)
-decode_mcu_AC_refine(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
-{
- arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
- JBLOCKROW block;
- JCOEFPTR thiscoef;
- unsigned char *st;
- int tbl, k, kex;
- int p1, m1;
-
- /* Process restart marker if needed */
- if (cinfo->restart_interval) {
- if (entropy->restarts_to_go == 0)
- process_restart(cinfo);
- entropy->restarts_to_go--;
- }
-
- if (entropy->ct == -1) return TRUE; /* if error do nothing */
-
- /* There is always only one block per MCU */
- block = MCU_data[0];
- tbl = cinfo->cur_comp_info[0]->ac_tbl_no;
-
- p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */
- m1 = (NEG_1) << cinfo->Al; /* -1 in the bit position being coded */
-
- /* Establish EOBx (previous stage end-of-block) index */
- for (kex = cinfo->Se; kex > 0; kex--)
- if ((*block)[jpeg_natural_order[kex]]) break;
-
- for (k = cinfo->Ss; k <= cinfo->Se; k++) {
- st = entropy->ac_stats[tbl] + 3 * (k - 1);
- if (k > kex)
- if (arith_decode(cinfo, st)) break; /* EOB flag */
- for (;;) {
- thiscoef = *block + jpeg_natural_order[k];
- if (*thiscoef) { /* previously nonzero coef */
- if (arith_decode(cinfo, st + 2)) {
- if (*thiscoef < 0)
- *thiscoef += (JCOEF)m1;
- else
- *thiscoef += (JCOEF)p1;
- }
- break;
- }
- if (arith_decode(cinfo, st + 1)) { /* newly nonzero coef */
- if (arith_decode(cinfo, entropy->fixed_bin))
- *thiscoef = (JCOEF)m1;
- else
- *thiscoef = (JCOEF)p1;
- break;
- }
- st += 3; k++;
- if (k > cinfo->Se) {
- WARNMS(cinfo, JWRN_ARITH_BAD_CODE);
- entropy->ct = -1; /* spectral overflow */
- return TRUE;
- }
- }
- }
-
- return TRUE;
-}
-
-
-/*
- * Decode one MCU's worth of arithmetic-compressed coefficients.
- */
-
-METHODDEF(boolean)
-decode_mcu(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
-{
- arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
- jpeg_component_info *compptr;
- JBLOCKROW block;
- unsigned char *st;
- int blkn, ci, tbl, sign, k;
- int v, m;
-
- /* Process restart marker if needed */
- if (cinfo->restart_interval) {
- if (entropy->restarts_to_go == 0)
- process_restart(cinfo);
- entropy->restarts_to_go--;
- }
-
- if (entropy->ct == -1) return TRUE; /* if error do nothing */
-
- /* Outer loop handles each block in the MCU */
-
- for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
- block = MCU_data ? MCU_data[blkn] : NULL;
- ci = cinfo->MCU_membership[blkn];
- compptr = cinfo->cur_comp_info[ci];
-
- /* Sections F.2.4.1 & F.1.4.4.1: Decoding of DC coefficients */
-
- tbl = compptr->dc_tbl_no;
-
- /* Table F.4: Point to statistics bin S0 for DC coefficient coding */
- st = entropy->dc_stats[tbl] + entropy->dc_context[ci];
-
- /* Figure F.19: Decode_DC_DIFF */
- if (arith_decode(cinfo, st) == 0)
- entropy->dc_context[ci] = 0;
- else {
- /* Figure F.21: Decoding nonzero value v */
- /* Figure F.22: Decoding the sign of v */
- sign = arith_decode(cinfo, st + 1);
- st += 2; st += sign;
- /* Figure F.23: Decoding the magnitude category of v */
- if ((m = arith_decode(cinfo, st)) != 0) {
- st = entropy->dc_stats[tbl] + 20; /* Table F.4: X1 = 20 */
- while (arith_decode(cinfo, st)) {
- if ((m <<= 1) == 0x8000) {
- WARNMS(cinfo, JWRN_ARITH_BAD_CODE);
- entropy->ct = -1; /* magnitude overflow */
- return TRUE;
- }
- st += 1;
- }
- }
- /* Section F.1.4.4.1.2: Establish dc_context conditioning category */
- if (m < (int)((1L << cinfo->arith_dc_L[tbl]) >> 1))
- entropy->dc_context[ci] = 0; /* zero diff category */
- else if (m > (int)((1L << cinfo->arith_dc_U[tbl]) >> 1))
- entropy->dc_context[ci] = 12 + (sign * 4); /* large diff category */
- else
- entropy->dc_context[ci] = 4 + (sign * 4); /* small diff category */
- v = m;
- /* Figure F.24: Decoding the magnitude bit pattern of v */
- st += 14;
- while (m >>= 1)
- if (arith_decode(cinfo, st)) v |= m;
- v += 1; if (sign) v = -v;
- entropy->last_dc_val[ci] = (entropy->last_dc_val[ci] + v) & 0xffff;
- }
-
- if (block)
- (*block)[0] = (JCOEF)entropy->last_dc_val[ci];
-
- /* Sections F.2.4.2 & F.1.4.4.2: Decoding of AC coefficients */
-
- tbl = compptr->ac_tbl_no;
-
- /* Figure F.20: Decode_AC_coefficients */
- for (k = 1; k <= DCTSIZE2 - 1; k++) {
- st = entropy->ac_stats[tbl] + 3 * (k - 1);
- if (arith_decode(cinfo, st)) break; /* EOB flag */
- while (arith_decode(cinfo, st + 1) == 0) {
- st += 3; k++;
- if (k > DCTSIZE2 - 1) {
- WARNMS(cinfo, JWRN_ARITH_BAD_CODE);
- entropy->ct = -1; /* spectral overflow */
- return TRUE;
- }
- }
- /* Figure F.21: Decoding nonzero value v */
- /* Figure F.22: Decoding the sign of v */
- sign = arith_decode(cinfo, entropy->fixed_bin);
- st += 2;
- /* Figure F.23: Decoding the magnitude category of v */
- if ((m = arith_decode(cinfo, st)) != 0) {
- if (arith_decode(cinfo, st)) {
- m <<= 1;
- st = entropy->ac_stats[tbl] +
- (k <= cinfo->arith_ac_K[tbl] ? 189 : 217);
- while (arith_decode(cinfo, st)) {
- if ((m <<= 1) == 0x8000) {
- WARNMS(cinfo, JWRN_ARITH_BAD_CODE);
- entropy->ct = -1; /* magnitude overflow */
- return TRUE;
- }
- st += 1;
- }
- }
- }
- v = m;
- /* Figure F.24: Decoding the magnitude bit pattern of v */
- st += 14;
- while (m >>= 1)
- if (arith_decode(cinfo, st)) v |= m;
- v += 1; if (sign) v = -v;
- if (block)
- (*block)[jpeg_natural_order[k]] = (JCOEF)v;
- }
- }
-
- return TRUE;
-}
-
-
-/*
- * Initialize for an arithmetic-compressed scan.
- */
-
-METHODDEF(void)
-start_pass(j_decompress_ptr cinfo)
-{
- arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
- int ci, tbl;
- jpeg_component_info *compptr;
-
- if (cinfo->progressive_mode) {
- /* Validate progressive scan parameters */
- if (cinfo->Ss == 0) {
- if (cinfo->Se != 0)
- goto bad;
- } else {
- /* need not check Ss/Se < 0 since they came from unsigned bytes */
- if (cinfo->Se < cinfo->Ss || cinfo->Se > DCTSIZE2 - 1)
- goto bad;
- /* AC scans may have only one component */
- if (cinfo->comps_in_scan != 1)
- goto bad;
- }
- if (cinfo->Ah != 0) {
- /* Successive approximation refinement scan: must have Al = Ah-1. */
- if (cinfo->Ah - 1 != cinfo->Al)
- goto bad;
- }
- if (cinfo->Al > 13) { /* need not check for < 0 */
-bad:
- ERREXIT4(cinfo, JERR_BAD_PROGRESSION,
- cinfo->Ss, cinfo->Se, cinfo->Ah, cinfo->Al);
- }
- /* Update progression status, and verify that scan order is legal.
- * Note that inter-scan inconsistencies are treated as warnings
- * not fatal errors ... not clear if this is right way to behave.
- */
- for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
- int coefi, cindex = cinfo->cur_comp_info[ci]->component_index;
- int *coef_bit_ptr = &cinfo->coef_bits[cindex][0];
- int *prev_coef_bit_ptr =
- &cinfo->coef_bits[cindex + cinfo->num_components][0];
- if (cinfo->Ss && coef_bit_ptr[0] < 0) /* AC without prior DC scan */
- WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, 0);
- for (coefi = MIN(cinfo->Ss, 1); coefi <= MAX(cinfo->Se, 9); coefi++) {
- if (cinfo->input_scan_number > 1)
- prev_coef_bit_ptr[coefi] = coef_bit_ptr[coefi];
- else
- prev_coef_bit_ptr[coefi] = 0;
- }
- for (coefi = cinfo->Ss; coefi <= cinfo->Se; coefi++) {
- int expected = (coef_bit_ptr[coefi] < 0) ? 0 : coef_bit_ptr[coefi];
- if (cinfo->Ah != expected)
- WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, coefi);
- coef_bit_ptr[coefi] = cinfo->Al;
- }
- }
- /* Select MCU decoding routine */
- if (cinfo->Ah == 0) {
- if (cinfo->Ss == 0)
- entropy->pub.decode_mcu = decode_mcu_DC_first;
- else
- entropy->pub.decode_mcu = decode_mcu_AC_first;
- } else {
- if (cinfo->Ss == 0)
- entropy->pub.decode_mcu = decode_mcu_DC_refine;
- else
- entropy->pub.decode_mcu = decode_mcu_AC_refine;
- }
- } else {
- /* Check that the scan parameters Ss, Se, Ah/Al are OK for sequential JPEG.
- * This ought to be an error condition, but we make it a warning.
- */
- if (cinfo->Ss != 0 || cinfo->Se != DCTSIZE2 - 1 ||
- cinfo->Ah != 0 || cinfo->Al != 0)
- WARNMS(cinfo, JWRN_NOT_SEQUENTIAL);
- /* Select MCU decoding routine */
- entropy->pub.decode_mcu = decode_mcu;
- }
-
- /* Allocate & initialize requested statistics areas */
- for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
- compptr = cinfo->cur_comp_info[ci];
- if (!cinfo->progressive_mode || (cinfo->Ss == 0 && cinfo->Ah == 0)) {
- tbl = compptr->dc_tbl_no;
- if (tbl < 0 || tbl >= NUM_ARITH_TBLS)
- ERREXIT1(cinfo, JERR_NO_ARITH_TABLE, tbl);
- if (entropy->dc_stats[tbl] == NULL)
- entropy->dc_stats[tbl] = (unsigned char *)(*cinfo->mem->alloc_small)
- ((j_common_ptr)cinfo, JPOOL_IMAGE, DC_STAT_BINS);
- memset(entropy->dc_stats[tbl], 0, DC_STAT_BINS);
- /* Initialize DC predictions to 0 */
- entropy->last_dc_val[ci] = 0;
- entropy->dc_context[ci] = 0;
- }
- if (!cinfo->progressive_mode || cinfo->Ss) {
- tbl = compptr->ac_tbl_no;
- if (tbl < 0 || tbl >= NUM_ARITH_TBLS)
- ERREXIT1(cinfo, JERR_NO_ARITH_TABLE, tbl);
- if (entropy->ac_stats[tbl] == NULL)
- entropy->ac_stats[tbl] = (unsigned char *)(*cinfo->mem->alloc_small)
- ((j_common_ptr)cinfo, JPOOL_IMAGE, AC_STAT_BINS);
- memset(entropy->ac_stats[tbl], 0, AC_STAT_BINS);
- }
- }
-
- /* Initialize arithmetic decoding variables */
- entropy->c = 0;
- entropy->a = 0;
- entropy->ct = -16; /* force reading 2 initial bytes to fill C */
- entropy->pub.insufficient_data = FALSE;
-
- /* Initialize restart counter */
- entropy->restarts_to_go = cinfo->restart_interval;
-}
-
-
-/*
- * Module initialization routine for arithmetic entropy decoding.
- */
-
-GLOBAL(void)
-jinit_arith_decoder(j_decompress_ptr cinfo)
-{
- arith_entropy_ptr entropy;
- int i;
-
- entropy = (arith_entropy_ptr)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- sizeof(arith_entropy_decoder));
- cinfo->entropy = (struct jpeg_entropy_decoder *)entropy;
- entropy->pub.start_pass = start_pass;
-
- /* Mark tables unallocated */
- for (i = 0; i < NUM_ARITH_TBLS; i++) {
- entropy->dc_stats[i] = NULL;
- entropy->ac_stats[i] = NULL;
- }
-
- /* Initialize index for fixed probability estimation */
- entropy->fixed_bin[0] = 113;
-
- if (cinfo->progressive_mode) {
- /* Create progression status table */
- int *coef_bit_ptr, ci;
- cinfo->coef_bits = (int (*)[DCTSIZE2])
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- cinfo->num_components * 2 * DCTSIZE2 *
- sizeof(int));
- coef_bit_ptr = &cinfo->coef_bits[0][0];
- for (ci = 0; ci < cinfo->num_components; ci++)
- for (i = 0; i < DCTSIZE2; i++)
- *coef_bit_ptr++ = -1;
- }
-}
diff --git a/contrib/libs/libjpeg-turbo/jdatadst-tj.c b/contrib/libs/libjpeg-turbo/jdatadst-tj.c
deleted file mode 100644
index e10d98127b..0000000000
--- a/contrib/libs/libjpeg-turbo/jdatadst-tj.c
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * jdatadst-tj.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * Modified 2009-2012 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2011, 2014, 2016, 2019, 2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains compression data destination routines for the case of
- * emitting JPEG data to memory or to a file (or any stdio stream).
- * While these routines are sufficient for most applications,
- * some will want to use a different destination manager.
- * IMPORTANT: we assume that fwrite() will correctly transcribe an array of
- * JOCTETs into 8-bit-wide elements on external storage. If char is wider
- * than 8 bits on your machine, you may need to do some tweaking.
- */
-
-/* this is not a core library module, so it doesn't define JPEG_INTERNALS */
-#include "jinclude.h"
-#include "jpeglib.h"
-#include "jerror.h"
-
-void jpeg_mem_dest_tj(j_compress_ptr cinfo, unsigned char **outbuffer,
- unsigned long *outsize, boolean alloc);
-
-
-#define OUTPUT_BUF_SIZE 4096 /* choose an efficiently fwrite'able size */
-
-
-/* Expanded data destination object for memory output */
-
-typedef struct {
- struct jpeg_destination_mgr pub; /* public fields */
-
- unsigned char **outbuffer; /* target buffer */
- unsigned long *outsize;
- unsigned char *newbuffer; /* newly allocated buffer */
- JOCTET *buffer; /* start of buffer */
- size_t bufsize;
- boolean alloc;
-} my_mem_destination_mgr;
-
-typedef my_mem_destination_mgr *my_mem_dest_ptr;
-
-
-/*
- * Initialize destination --- called by jpeg_start_compress
- * before any data is actually written.
- */
-
-METHODDEF(void)
-init_mem_destination(j_compress_ptr cinfo)
-{
- /* no work necessary here */
-}
-
-
-/*
- * Empty the output buffer --- called whenever buffer fills up.
- *
- * In typical applications, this should write the entire output buffer
- * (ignoring the current state of next_output_byte & free_in_buffer),
- * reset the pointer & count to the start of the buffer, and return TRUE
- * indicating that the buffer has been dumped.
- *
- * In applications that need to be able to suspend compression due to output
- * overrun, a FALSE return indicates that the buffer cannot be emptied now.
- * In this situation, the compressor will return to its caller (possibly with
- * an indication that it has not accepted all the supplied scanlines). The
- * application should resume compression after it has made more room in the
- * output buffer. Note that there are substantial restrictions on the use of
- * suspension --- see the documentation.
- *
- * When suspending, the compressor will back up to a convenient restart point
- * (typically the start of the current MCU). next_output_byte & free_in_buffer
- * indicate where the restart point will be if the current call returns FALSE.
- * Data beyond this point will be regenerated after resumption, so do not
- * write it out when emptying the buffer externally.
- */
-
-METHODDEF(boolean)
-empty_mem_output_buffer(j_compress_ptr cinfo)
-{
- size_t nextsize;
- JOCTET *nextbuffer;
- my_mem_dest_ptr dest = (my_mem_dest_ptr)cinfo->dest;
-
- if (!dest->alloc) ERREXIT(cinfo, JERR_BUFFER_SIZE);
-
- /* Try to allocate new buffer with double size */
- nextsize = dest->bufsize * 2;
- nextbuffer = (JOCTET *)malloc(nextsize);
-
- if (nextbuffer == NULL)
- ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10);
-
- memcpy(nextbuffer, dest->buffer, dest->bufsize);
-
- free(dest->newbuffer);
-
- dest->newbuffer = nextbuffer;
-
- dest->pub.next_output_byte = nextbuffer + dest->bufsize;
- dest->pub.free_in_buffer = dest->bufsize;
-
- dest->buffer = nextbuffer;
- dest->bufsize = nextsize;
-
- return TRUE;
-}
-
-
-/*
- * Terminate destination --- called by jpeg_finish_compress
- * after all data has been written. Usually needs to flush buffer.
- *
- * NB: *not* called by jpeg_abort or jpeg_destroy; surrounding
- * application must deal with any cleanup that should happen even
- * for error exit.
- */
-
-METHODDEF(void)
-term_mem_destination(j_compress_ptr cinfo)
-{
- my_mem_dest_ptr dest = (my_mem_dest_ptr)cinfo->dest;
-
- if (dest->alloc) *dest->outbuffer = dest->buffer;
- *dest->outsize = (unsigned long)(dest->bufsize - dest->pub.free_in_buffer);
-}
-
-
-/*
- * Prepare for output to a memory buffer.
- * The caller may supply an own initial buffer with appropriate size.
- * Otherwise, or when the actual data output exceeds the given size,
- * the library adapts the buffer size as necessary.
- * The standard library functions malloc/free are used for allocating
- * larger memory, so the buffer is available to the application after
- * finishing compression, and then the application is responsible for
- * freeing the requested memory.
- */
-
-GLOBAL(void)
-jpeg_mem_dest_tj(j_compress_ptr cinfo, unsigned char **outbuffer,
- unsigned long *outsize, boolean alloc)
-{
- boolean reused = FALSE;
- my_mem_dest_ptr dest;
-
- if (outbuffer == NULL || outsize == NULL) /* sanity check */
- ERREXIT(cinfo, JERR_BUFFER_SIZE);
-
- /* The destination object is made permanent so that multiple JPEG images
- * can be written to the same buffer without re-executing jpeg_mem_dest.
- */
- if (cinfo->dest == NULL) { /* first time for this JPEG object? */
- cinfo->dest = (struct jpeg_destination_mgr *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
- sizeof(my_mem_destination_mgr));
- dest = (my_mem_dest_ptr)cinfo->dest;
- dest->newbuffer = NULL;
- dest->buffer = NULL;
- } else if (cinfo->dest->init_destination != init_mem_destination) {
- /* It is unsafe to reuse the existing destination manager unless it was
- * created by this function.
- */
- ERREXIT(cinfo, JERR_BUFFER_SIZE);
- }
-
- dest = (my_mem_dest_ptr)cinfo->dest;
- dest->pub.init_destination = init_mem_destination;
- dest->pub.empty_output_buffer = empty_mem_output_buffer;
- dest->pub.term_destination = term_mem_destination;
- if (dest->buffer == *outbuffer && *outbuffer != NULL && alloc)
- reused = TRUE;
- dest->outbuffer = outbuffer;
- dest->outsize = outsize;
- dest->alloc = alloc;
-
- if (*outbuffer == NULL || *outsize == 0) {
- if (alloc) {
- /* Allocate initial buffer */
- dest->newbuffer = *outbuffer = (unsigned char *)malloc(OUTPUT_BUF_SIZE);
- if (dest->newbuffer == NULL)
- ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10);
- *outsize = OUTPUT_BUF_SIZE;
- } else
- ERREXIT(cinfo, JERR_BUFFER_SIZE);
- }
-
- dest->pub.next_output_byte = dest->buffer = *outbuffer;
- if (!reused)
- dest->bufsize = *outsize;
- dest->pub.free_in_buffer = dest->bufsize;
-}
diff --git a/contrib/libs/libjpeg-turbo/jdatadst.c b/contrib/libs/libjpeg-turbo/jdatadst.c
deleted file mode 100644
index 6b4fed2339..0000000000
--- a/contrib/libs/libjpeg-turbo/jdatadst.c
+++ /dev/null
@@ -1,287 +0,0 @@
-/*
- * jdatadst.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * Modified 2009-2012 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2013, 2016, 2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains compression data destination routines for the case of
- * emitting JPEG data to memory or to a file (or any stdio stream).
- * While these routines are sufficient for most applications,
- * some will want to use a different destination manager.
- * IMPORTANT: we assume that fwrite() will correctly transcribe an array of
- * JOCTETs into 8-bit-wide elements on external storage. If char is wider
- * than 8 bits on your machine, you may need to do some tweaking.
- */
-
-/* this is not a core library module, so it doesn't define JPEG_INTERNALS */
-#include "jinclude.h"
-#include "jpeglib.h"
-#include "jerror.h"
-
-
-/* Expanded data destination object for stdio output */
-
-typedef struct {
- struct jpeg_destination_mgr pub; /* public fields */
-
- FILE *outfile; /* target stream */
- JOCTET *buffer; /* start of buffer */
-} my_destination_mgr;
-
-typedef my_destination_mgr *my_dest_ptr;
-
-#define OUTPUT_BUF_SIZE 4096 /* choose an efficiently fwrite'able size */
-
-
-#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
-/* Expanded data destination object for memory output */
-
-typedef struct {
- struct jpeg_destination_mgr pub; /* public fields */
-
- unsigned char **outbuffer; /* target buffer */
- unsigned long *outsize;
- unsigned char *newbuffer; /* newly allocated buffer */
- JOCTET *buffer; /* start of buffer */
- size_t bufsize;
-} my_mem_destination_mgr;
-
-typedef my_mem_destination_mgr *my_mem_dest_ptr;
-#endif
-
-
-/*
- * Initialize destination --- called by jpeg_start_compress
- * before any data is actually written.
- */
-
-METHODDEF(void)
-init_destination(j_compress_ptr cinfo)
-{
- my_dest_ptr dest = (my_dest_ptr)cinfo->dest;
-
- /* Allocate the output buffer --- it will be released when done with image */
- dest->buffer = (JOCTET *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- OUTPUT_BUF_SIZE * sizeof(JOCTET));
-
- dest->pub.next_output_byte = dest->buffer;
- dest->pub.free_in_buffer = OUTPUT_BUF_SIZE;
-}
-
-#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
-METHODDEF(void)
-init_mem_destination(j_compress_ptr cinfo)
-{
- /* no work necessary here */
-}
-#endif
-
-
-/*
- * Empty the output buffer --- called whenever buffer fills up.
- *
- * In typical applications, this should write the entire output buffer
- * (ignoring the current state of next_output_byte & free_in_buffer),
- * reset the pointer & count to the start of the buffer, and return TRUE
- * indicating that the buffer has been dumped.
- *
- * In applications that need to be able to suspend compression due to output
- * overrun, a FALSE return indicates that the buffer cannot be emptied now.
- * In this situation, the compressor will return to its caller (possibly with
- * an indication that it has not accepted all the supplied scanlines). The
- * application should resume compression after it has made more room in the
- * output buffer. Note that there are substantial restrictions on the use of
- * suspension --- see the documentation.
- *
- * When suspending, the compressor will back up to a convenient restart point
- * (typically the start of the current MCU). next_output_byte & free_in_buffer
- * indicate where the restart point will be if the current call returns FALSE.
- * Data beyond this point will be regenerated after resumption, so do not
- * write it out when emptying the buffer externally.
- */
-
-METHODDEF(boolean)
-empty_output_buffer(j_compress_ptr cinfo)
-{
- my_dest_ptr dest = (my_dest_ptr)cinfo->dest;
-
- if (fwrite(dest->buffer, 1, OUTPUT_BUF_SIZE, dest->outfile) !=
- (size_t)OUTPUT_BUF_SIZE)
- ERREXIT(cinfo, JERR_FILE_WRITE);
-
- dest->pub.next_output_byte = dest->buffer;
- dest->pub.free_in_buffer = OUTPUT_BUF_SIZE;
-
- return TRUE;
-}
-
-#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
-METHODDEF(boolean)
-empty_mem_output_buffer(j_compress_ptr cinfo)
-{
- size_t nextsize;
- JOCTET *nextbuffer;
- my_mem_dest_ptr dest = (my_mem_dest_ptr)cinfo->dest;
-
- /* Try to allocate new buffer with double size */
- nextsize = dest->bufsize * 2;
- nextbuffer = (JOCTET *)malloc(nextsize);
-
- if (nextbuffer == NULL)
- ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10);
-
- memcpy(nextbuffer, dest->buffer, dest->bufsize);
-
- free(dest->newbuffer);
-
- dest->newbuffer = nextbuffer;
-
- dest->pub.next_output_byte = nextbuffer + dest->bufsize;
- dest->pub.free_in_buffer = dest->bufsize;
-
- dest->buffer = nextbuffer;
- dest->bufsize = nextsize;
-
- return TRUE;
-}
-#endif
-
-
-/*
- * Terminate destination --- called by jpeg_finish_compress
- * after all data has been written. Usually needs to flush buffer.
- *
- * NB: *not* called by jpeg_abort or jpeg_destroy; surrounding
- * application must deal with any cleanup that should happen even
- * for error exit.
- */
-
-METHODDEF(void)
-term_destination(j_compress_ptr cinfo)
-{
- my_dest_ptr dest = (my_dest_ptr)cinfo->dest;
- size_t datacount = OUTPUT_BUF_SIZE - dest->pub.free_in_buffer;
-
- /* Write any data remaining in the buffer */
- if (datacount > 0) {
- if (fwrite(dest->buffer, 1, datacount, dest->outfile) != datacount)
- ERREXIT(cinfo, JERR_FILE_WRITE);
- }
- fflush(dest->outfile);
- /* Make sure we wrote the output file OK */
- if (ferror(dest->outfile))
- ERREXIT(cinfo, JERR_FILE_WRITE);
-}
-
-#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
-METHODDEF(void)
-term_mem_destination(j_compress_ptr cinfo)
-{
- my_mem_dest_ptr dest = (my_mem_dest_ptr)cinfo->dest;
-
- *dest->outbuffer = dest->buffer;
- *dest->outsize = (unsigned long)(dest->bufsize - dest->pub.free_in_buffer);
-}
-#endif
-
-
-/*
- * Prepare for output to a stdio stream.
- * The caller must have already opened the stream, and is responsible
- * for closing it after finishing compression.
- */
-
-GLOBAL(void)
-jpeg_stdio_dest(j_compress_ptr cinfo, FILE *outfile)
-{
- my_dest_ptr dest;
-
- /* The destination object is made permanent so that multiple JPEG images
- * can be written to the same file without re-executing jpeg_stdio_dest.
- */
- if (cinfo->dest == NULL) { /* first time for this JPEG object? */
- cinfo->dest = (struct jpeg_destination_mgr *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
- sizeof(my_destination_mgr));
- } else if (cinfo->dest->init_destination != init_destination) {
- /* It is unsafe to reuse the existing destination manager unless it was
- * created by this function. Otherwise, there is no guarantee that the
- * opaque structure is the right size. Note that we could just create a
- * new structure, but the old structure would not be freed until
- * jpeg_destroy_compress() was called.
- */
- ERREXIT(cinfo, JERR_BUFFER_SIZE);
- }
-
- dest = (my_dest_ptr)cinfo->dest;
- dest->pub.init_destination = init_destination;
- dest->pub.empty_output_buffer = empty_output_buffer;
- dest->pub.term_destination = term_destination;
- dest->outfile = outfile;
-}
-
-
-#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
-/*
- * Prepare for output to a memory buffer.
- * The caller may supply an own initial buffer with appropriate size.
- * Otherwise, or when the actual data output exceeds the given size,
- * the library adapts the buffer size as necessary.
- * The standard library functions malloc/free are used for allocating
- * larger memory, so the buffer is available to the application after
- * finishing compression, and then the application is responsible for
- * freeing the requested memory.
- * Note: An initial buffer supplied by the caller is expected to be
- * managed by the application. The library does not free such buffer
- * when allocating a larger buffer.
- */
-
-GLOBAL(void)
-jpeg_mem_dest(j_compress_ptr cinfo, unsigned char **outbuffer,
- unsigned long *outsize)
-{
- my_mem_dest_ptr dest;
-
- if (outbuffer == NULL || outsize == NULL) /* sanity check */
- ERREXIT(cinfo, JERR_BUFFER_SIZE);
-
- /* The destination object is made permanent so that multiple JPEG images
- * can be written to the same buffer without re-executing jpeg_mem_dest.
- */
- if (cinfo->dest == NULL) { /* first time for this JPEG object? */
- cinfo->dest = (struct jpeg_destination_mgr *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
- sizeof(my_mem_destination_mgr));
- } else if (cinfo->dest->init_destination != init_mem_destination) {
- /* It is unsafe to reuse the existing destination manager unless it was
- * created by this function.
- */
- ERREXIT(cinfo, JERR_BUFFER_SIZE);
- }
-
- dest = (my_mem_dest_ptr)cinfo->dest;
- dest->pub.init_destination = init_mem_destination;
- dest->pub.empty_output_buffer = empty_mem_output_buffer;
- dest->pub.term_destination = term_mem_destination;
- dest->outbuffer = outbuffer;
- dest->outsize = outsize;
- dest->newbuffer = NULL;
-
- if (*outbuffer == NULL || *outsize == 0) {
- /* Allocate initial buffer */
- dest->newbuffer = *outbuffer = (unsigned char *)malloc(OUTPUT_BUF_SIZE);
- if (dest->newbuffer == NULL)
- ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10);
- *outsize = OUTPUT_BUF_SIZE;
- }
-
- dest->pub.next_output_byte = dest->buffer = *outbuffer;
- dest->pub.free_in_buffer = dest->bufsize = *outsize;
-}
-#endif
diff --git a/contrib/libs/libjpeg-turbo/jdatasrc-tj.c b/contrib/libs/libjpeg-turbo/jdatasrc-tj.c
deleted file mode 100644
index 69fb5eaacd..0000000000
--- a/contrib/libs/libjpeg-turbo/jdatasrc-tj.c
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * jdatasrc-tj.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * Modified 2009-2011 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2011, 2016, 2019, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains decompression data source routines for the case of
- * reading JPEG data from memory or from a file (or any stdio stream).
- * While these routines are sufficient for most applications,
- * some will want to use a different source manager.
- * IMPORTANT: we assume that fread() will correctly transcribe an array of
- * JOCTETs from 8-bit-wide elements on external storage. If char is wider
- * than 8 bits on your machine, you may need to do some tweaking.
- */
-
-/* this is not a core library module, so it doesn't define JPEG_INTERNALS */
-#include "jinclude.h"
-#include "jpeglib.h"
-#include "jerror.h"
-
-void jpeg_mem_src_tj(j_decompress_ptr cinfo, const unsigned char *inbuffer,
- unsigned long insize);
-
-
-/*
- * Initialize source --- called by jpeg_read_header
- * before any data is actually read.
- */
-
-METHODDEF(void)
-init_mem_source(j_decompress_ptr cinfo)
-{
- /* no work necessary here */
-}
-
-
-/*
- * Fill the input buffer --- called whenever buffer is emptied.
- *
- * In typical applications, this should read fresh data into the buffer
- * (ignoring the current state of next_input_byte & bytes_in_buffer),
- * reset the pointer & count to the start of the buffer, and return TRUE
- * indicating that the buffer has been reloaded. It is not necessary to
- * fill the buffer entirely, only to obtain at least one more byte.
- *
- * There is no such thing as an EOF return. If the end of the file has been
- * reached, the routine has a choice of ERREXIT() or inserting fake data into
- * the buffer. In most cases, generating a warning message and inserting a
- * fake EOI marker is the best course of action --- this will allow the
- * decompressor to output however much of the image is there. However,
- * the resulting error message is misleading if the real problem is an empty
- * input file, so we handle that case specially.
- *
- * In applications that need to be able to suspend compression due to input
- * not being available yet, a FALSE return indicates that no more data can be
- * obtained right now, but more may be forthcoming later. In this situation,
- * the decompressor will return to its caller (with an indication of the
- * number of scanlines it has read, if any). The application should resume
- * decompression after it has loaded more data into the input buffer. Note
- * that there are substantial restrictions on the use of suspension --- see
- * the documentation.
- *
- * When suspending, the decompressor will back up to a convenient restart point
- * (typically the start of the current MCU). next_input_byte & bytes_in_buffer
- * indicate where the restart point will be if the current call returns FALSE.
- * Data beyond this point must be rescanned after resumption, so move it to
- * the front of the buffer rather than discarding it.
- */
-
-METHODDEF(boolean)
-fill_mem_input_buffer(j_decompress_ptr cinfo)
-{
- static const JOCTET mybuffer[4] = {
- (JOCTET)0xFF, (JOCTET)JPEG_EOI, 0, 0
- };
-
- /* The whole JPEG data is expected to reside in the supplied memory
- * buffer, so any request for more data beyond the given buffer size
- * is treated as an error.
- */
- WARNMS(cinfo, JWRN_JPEG_EOF);
-
- /* Insert a fake EOI marker */
-
- cinfo->src->next_input_byte = mybuffer;
- cinfo->src->bytes_in_buffer = 2;
-
- return TRUE;
-}
-
-
-/*
- * Skip data --- used to skip over a potentially large amount of
- * uninteresting data (such as an APPn marker).
- *
- * Writers of suspendable-input applications must note that skip_input_data
- * is not granted the right to give a suspension return. If the skip extends
- * beyond the data currently in the buffer, the buffer can be marked empty so
- * that the next read will cause a fill_input_buffer call that can suspend.
- * Arranging for additional bytes to be discarded before reloading the input
- * buffer is the application writer's problem.
- */
-
-METHODDEF(void)
-skip_input_data(j_decompress_ptr cinfo, long num_bytes)
-{
- struct jpeg_source_mgr *src = cinfo->src;
-
- /* Just a dumb implementation for now. Could use fseek() except
- * it doesn't work on pipes. Not clear that being smart is worth
- * any trouble anyway --- large skips are infrequent.
- */
- if (num_bytes > 0) {
- while (num_bytes > (long)src->bytes_in_buffer) {
- num_bytes -= (long)src->bytes_in_buffer;
- (void)(*src->fill_input_buffer) (cinfo);
- /* note we assume that fill_input_buffer will never return FALSE,
- * so suspension need not be handled.
- */
- }
- src->next_input_byte += (size_t)num_bytes;
- src->bytes_in_buffer -= (size_t)num_bytes;
- }
-}
-
-
-/*
- * An additional method that can be provided by data source modules is the
- * resync_to_restart method for error recovery in the presence of RST markers.
- * For the moment, this source module just uses the default resync method
- * provided by the JPEG library. That method assumes that no backtracking
- * is possible.
- */
-
-
-/*
- * Terminate source --- called by jpeg_finish_decompress
- * after all data has been read. Often a no-op.
- *
- * NB: *not* called by jpeg_abort or jpeg_destroy; surrounding
- * application must deal with any cleanup that should happen even
- * for error exit.
- */
-
-METHODDEF(void)
-term_source(j_decompress_ptr cinfo)
-{
- /* no work necessary here */
-}
-
-
-/*
- * Prepare for input from a supplied memory buffer.
- * The buffer must contain the whole JPEG data.
- */
-
-GLOBAL(void)
-jpeg_mem_src_tj(j_decompress_ptr cinfo, const unsigned char *inbuffer,
- unsigned long insize)
-{
- struct jpeg_source_mgr *src;
-
- if (inbuffer == NULL || insize == 0) /* Treat empty input as fatal error */
- ERREXIT(cinfo, JERR_INPUT_EMPTY);
-
- /* The source object is made permanent so that a series of JPEG images
- * can be read from the same buffer by calling jpeg_mem_src only before
- * the first one.
- */
- if (cinfo->src == NULL) { /* first time for this JPEG object? */
- cinfo->src = (struct jpeg_source_mgr *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
- sizeof(struct jpeg_source_mgr));
- } else if (cinfo->src->init_source != init_mem_source) {
- /* It is unsafe to reuse the existing source manager unless it was created
- * by this function.
- */
- ERREXIT(cinfo, JERR_BUFFER_SIZE);
- }
-
- src = cinfo->src;
- src->init_source = init_mem_source;
- src->fill_input_buffer = fill_mem_input_buffer;
- src->skip_input_data = skip_input_data;
- src->resync_to_restart = jpeg_resync_to_restart; /* use default method */
- src->term_source = term_source;
- src->bytes_in_buffer = (size_t)insize;
- src->next_input_byte = (const JOCTET *)inbuffer;
-}
diff --git a/contrib/libs/libjpeg-turbo/jdatasrc.c b/contrib/libs/libjpeg-turbo/jdatasrc.c
deleted file mode 100644
index e36a30d894..0000000000
--- a/contrib/libs/libjpeg-turbo/jdatasrc.c
+++ /dev/null
@@ -1,295 +0,0 @@
-/*
- * jdatasrc.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * Modified 2009-2011 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2013, 2016, 2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains decompression data source routines for the case of
- * reading JPEG data from memory or from a file (or any stdio stream).
- * While these routines are sufficient for most applications,
- * some will want to use a different source manager.
- * IMPORTANT: we assume that fread() will correctly transcribe an array of
- * JOCTETs from 8-bit-wide elements on external storage. If char is wider
- * than 8 bits on your machine, you may need to do some tweaking.
- */
-
-/* this is not a core library module, so it doesn't define JPEG_INTERNALS */
-#include "jinclude.h"
-#include "jpeglib.h"
-#include "jerror.h"
-
-
-/* Expanded data source object for stdio input */
-
-typedef struct {
- struct jpeg_source_mgr pub; /* public fields */
-
- FILE *infile; /* source stream */
- JOCTET *buffer; /* start of buffer */
- boolean start_of_file; /* have we gotten any data yet? */
-} my_source_mgr;
-
-typedef my_source_mgr *my_src_ptr;
-
-#define INPUT_BUF_SIZE 4096 /* choose an efficiently fread'able size */
-
-
-/*
- * Initialize source --- called by jpeg_read_header
- * before any data is actually read.
- */
-
-METHODDEF(void)
-init_source(j_decompress_ptr cinfo)
-{
- my_src_ptr src = (my_src_ptr)cinfo->src;
-
- /* We reset the empty-input-file flag for each image,
- * but we don't clear the input buffer.
- * This is correct behavior for reading a series of images from one source.
- */
- src->start_of_file = TRUE;
-}
-
-#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
-METHODDEF(void)
-init_mem_source(j_decompress_ptr cinfo)
-{
- /* no work necessary here */
-}
-#endif
-
-
-/*
- * Fill the input buffer --- called whenever buffer is emptied.
- *
- * In typical applications, this should read fresh data into the buffer
- * (ignoring the current state of next_input_byte & bytes_in_buffer),
- * reset the pointer & count to the start of the buffer, and return TRUE
- * indicating that the buffer has been reloaded. It is not necessary to
- * fill the buffer entirely, only to obtain at least one more byte.
- *
- * There is no such thing as an EOF return. If the end of the file has been
- * reached, the routine has a choice of ERREXIT() or inserting fake data into
- * the buffer. In most cases, generating a warning message and inserting a
- * fake EOI marker is the best course of action --- this will allow the
- * decompressor to output however much of the image is there. However,
- * the resulting error message is misleading if the real problem is an empty
- * input file, so we handle that case specially.
- *
- * In applications that need to be able to suspend compression due to input
- * not being available yet, a FALSE return indicates that no more data can be
- * obtained right now, but more may be forthcoming later. In this situation,
- * the decompressor will return to its caller (with an indication of the
- * number of scanlines it has read, if any). The application should resume
- * decompression after it has loaded more data into the input buffer. Note
- * that there are substantial restrictions on the use of suspension --- see
- * the documentation.
- *
- * When suspending, the decompressor will back up to a convenient restart point
- * (typically the start of the current MCU). next_input_byte & bytes_in_buffer
- * indicate where the restart point will be if the current call returns FALSE.
- * Data beyond this point must be rescanned after resumption, so move it to
- * the front of the buffer rather than discarding it.
- */
-
-METHODDEF(boolean)
-fill_input_buffer(j_decompress_ptr cinfo)
-{
- my_src_ptr src = (my_src_ptr)cinfo->src;
- size_t nbytes;
-
- nbytes = fread(src->buffer, 1, INPUT_BUF_SIZE, src->infile);
-
- if (nbytes <= 0) {
- if (src->start_of_file) /* Treat empty input file as fatal error */
- ERREXIT(cinfo, JERR_INPUT_EMPTY);
- WARNMS(cinfo, JWRN_JPEG_EOF);
- /* Insert a fake EOI marker */
- src->buffer[0] = (JOCTET)0xFF;
- src->buffer[1] = (JOCTET)JPEG_EOI;
- nbytes = 2;
- }
-
- src->pub.next_input_byte = src->buffer;
- src->pub.bytes_in_buffer = nbytes;
- src->start_of_file = FALSE;
-
- return TRUE;
-}
-
-#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
-METHODDEF(boolean)
-fill_mem_input_buffer(j_decompress_ptr cinfo)
-{
- static const JOCTET mybuffer[4] = {
- (JOCTET)0xFF, (JOCTET)JPEG_EOI, 0, 0
- };
-
- /* The whole JPEG data is expected to reside in the supplied memory
- * buffer, so any request for more data beyond the given buffer size
- * is treated as an error.
- */
- WARNMS(cinfo, JWRN_JPEG_EOF);
-
- /* Insert a fake EOI marker */
-
- cinfo->src->next_input_byte = mybuffer;
- cinfo->src->bytes_in_buffer = 2;
-
- return TRUE;
-}
-#endif
-
-
-/*
- * Skip data --- used to skip over a potentially large amount of
- * uninteresting data (such as an APPn marker).
- *
- * Writers of suspendable-input applications must note that skip_input_data
- * is not granted the right to give a suspension return. If the skip extends
- * beyond the data currently in the buffer, the buffer can be marked empty so
- * that the next read will cause a fill_input_buffer call that can suspend.
- * Arranging for additional bytes to be discarded before reloading the input
- * buffer is the application writer's problem.
- */
-
-METHODDEF(void)
-skip_input_data(j_decompress_ptr cinfo, long num_bytes)
-{
- struct jpeg_source_mgr *src = cinfo->src;
-
- /* Just a dumb implementation for now. Could use fseek() except
- * it doesn't work on pipes. Not clear that being smart is worth
- * any trouble anyway --- large skips are infrequent.
- */
- if (num_bytes > 0) {
- while (num_bytes > (long)src->bytes_in_buffer) {
- num_bytes -= (long)src->bytes_in_buffer;
- (void)(*src->fill_input_buffer) (cinfo);
- /* note we assume that fill_input_buffer will never return FALSE,
- * so suspension need not be handled.
- */
- }
- src->next_input_byte += (size_t)num_bytes;
- src->bytes_in_buffer -= (size_t)num_bytes;
- }
-}
-
-
-/*
- * An additional method that can be provided by data source modules is the
- * resync_to_restart method for error recovery in the presence of RST markers.
- * For the moment, this source module just uses the default resync method
- * provided by the JPEG library. That method assumes that no backtracking
- * is possible.
- */
-
-
-/*
- * Terminate source --- called by jpeg_finish_decompress
- * after all data has been read. Often a no-op.
- *
- * NB: *not* called by jpeg_abort or jpeg_destroy; surrounding
- * application must deal with any cleanup that should happen even
- * for error exit.
- */
-
-METHODDEF(void)
-term_source(j_decompress_ptr cinfo)
-{
- /* no work necessary here */
-}
-
-
-/*
- * Prepare for input from a stdio stream.
- * The caller must have already opened the stream, and is responsible
- * for closing it after finishing decompression.
- */
-
-GLOBAL(void)
-jpeg_stdio_src(j_decompress_ptr cinfo, FILE *infile)
-{
- my_src_ptr src;
-
- /* The source object and input buffer are made permanent so that a series
- * of JPEG images can be read from the same file by calling jpeg_stdio_src
- * only before the first one. (If we discarded the buffer at the end of
- * one image, we'd likely lose the start of the next one.)
- */
- if (cinfo->src == NULL) { /* first time for this JPEG object? */
- cinfo->src = (struct jpeg_source_mgr *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
- sizeof(my_source_mgr));
- src = (my_src_ptr)cinfo->src;
- src->buffer = (JOCTET *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
- INPUT_BUF_SIZE * sizeof(JOCTET));
- } else if (cinfo->src->init_source != init_source) {
- /* It is unsafe to reuse the existing source manager unless it was created
- * by this function. Otherwise, there is no guarantee that the opaque
- * structure is the right size. Note that we could just create a new
- * structure, but the old structure would not be freed until
- * jpeg_destroy_decompress() was called.
- */
- ERREXIT(cinfo, JERR_BUFFER_SIZE);
- }
-
- src = (my_src_ptr)cinfo->src;
- src->pub.init_source = init_source;
- src->pub.fill_input_buffer = fill_input_buffer;
- src->pub.skip_input_data = skip_input_data;
- src->pub.resync_to_restart = jpeg_resync_to_restart; /* use default method */
- src->pub.term_source = term_source;
- src->infile = infile;
- src->pub.bytes_in_buffer = 0; /* forces fill_input_buffer on first read */
- src->pub.next_input_byte = NULL; /* until buffer loaded */
-}
-
-
-#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
-/*
- * Prepare for input from a supplied memory buffer.
- * The buffer must contain the whole JPEG data.
- */
-
-GLOBAL(void)
-jpeg_mem_src(j_decompress_ptr cinfo, const unsigned char *inbuffer,
- unsigned long insize)
-{
- struct jpeg_source_mgr *src;
-
- if (inbuffer == NULL || insize == 0) /* Treat empty input as fatal error */
- ERREXIT(cinfo, JERR_INPUT_EMPTY);
-
- /* The source object is made permanent so that a series of JPEG images
- * can be read from the same buffer by calling jpeg_mem_src only before
- * the first one.
- */
- if (cinfo->src == NULL) { /* first time for this JPEG object? */
- cinfo->src = (struct jpeg_source_mgr *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
- sizeof(struct jpeg_source_mgr));
- } else if (cinfo->src->init_source != init_mem_source) {
- /* It is unsafe to reuse the existing source manager unless it was created
- * by this function.
- */
- ERREXIT(cinfo, JERR_BUFFER_SIZE);
- }
-
- src = cinfo->src;
- src->init_source = init_mem_source;
- src->fill_input_buffer = fill_mem_input_buffer;
- src->skip_input_data = skip_input_data;
- src->resync_to_restart = jpeg_resync_to_restart; /* use default method */
- src->term_source = term_source;
- src->bytes_in_buffer = (size_t)insize;
- src->next_input_byte = (const JOCTET *)inbuffer;
-}
-#endif
diff --git a/contrib/libs/libjpeg-turbo/jdcoefct.c b/contrib/libs/libjpeg-turbo/jdcoefct.c
deleted file mode 100644
index 88e10c08cb..0000000000
--- a/contrib/libs/libjpeg-turbo/jdcoefct.c
+++ /dev/null
@@ -1,878 +0,0 @@
-/*
- * jdcoefct.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1994-1997, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- * Copyright (C) 2010, 2015-2016, 2019-2020, 2022, D. R. Commander.
- * Copyright (C) 2015, 2020, Google, Inc.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains the coefficient buffer controller for decompression.
- * This controller is the top level of the JPEG decompressor proper.
- * The coefficient buffer lies between entropy decoding and inverse-DCT steps.
- *
- * In buffered-image mode, this controller is the interface between
- * input-oriented processing and output-oriented processing.
- * Also, the input side (only) is used when reading a file for transcoding.
- */
-
-#include "jinclude.h"
-#include "jdcoefct.h"
-#include "jpegcomp.h"
-
-
-/* Forward declarations */
-METHODDEF(int) decompress_onepass(j_decompress_ptr cinfo,
- JSAMPIMAGE output_buf);
-#ifdef D_MULTISCAN_FILES_SUPPORTED
-METHODDEF(int) decompress_data(j_decompress_ptr cinfo, JSAMPIMAGE output_buf);
-#endif
-#ifdef BLOCK_SMOOTHING_SUPPORTED
-LOCAL(boolean) smoothing_ok(j_decompress_ptr cinfo);
-METHODDEF(int) decompress_smooth_data(j_decompress_ptr cinfo,
- JSAMPIMAGE output_buf);
-#endif
-
-
-/*
- * Initialize for an input processing pass.
- */
-
-METHODDEF(void)
-start_input_pass(j_decompress_ptr cinfo)
-{
- cinfo->input_iMCU_row = 0;
- start_iMCU_row(cinfo);
-}
-
-
-/*
- * Initialize for an output processing pass.
- */
-
-METHODDEF(void)
-start_output_pass(j_decompress_ptr cinfo)
-{
-#ifdef BLOCK_SMOOTHING_SUPPORTED
- my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
-
- /* If multipass, check to see whether to use block smoothing on this pass */
- if (coef->pub.coef_arrays != NULL) {
- if (cinfo->do_block_smoothing && smoothing_ok(cinfo))
- coef->pub.decompress_data = decompress_smooth_data;
- else
- coef->pub.decompress_data = decompress_data;
- }
-#endif
- cinfo->output_iMCU_row = 0;
-}
-
-
-/*
- * Decompress and return some data in the single-pass case.
- * Always attempts to emit one fully interleaved MCU row ("iMCU" row).
- * Input and output must run in lockstep since we have only a one-MCU buffer.
- * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED.
- *
- * NB: output_buf contains a plane for each component in image,
- * which we index according to the component's SOF position.
- */
-
-METHODDEF(int)
-decompress_onepass(j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
-{
- my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
- JDIMENSION MCU_col_num; /* index of current MCU within row */
- JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
- JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
- int blkn, ci, xindex, yindex, yoffset, useful_width;
- JSAMPARRAY output_ptr;
- JDIMENSION start_col, output_col;
- jpeg_component_info *compptr;
- inverse_DCT_method_ptr inverse_DCT;
-
- /* Loop to process as much as one whole iMCU row */
- for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
- yoffset++) {
- for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col;
- MCU_col_num++) {
- /* Try to fetch an MCU. Entropy decoder expects buffer to be zeroed. */
- jzero_far((void *)coef->MCU_buffer[0],
- (size_t)(cinfo->blocks_in_MCU * sizeof(JBLOCK)));
- if (!cinfo->entropy->insufficient_data)
- cinfo->master->last_good_iMCU_row = cinfo->input_iMCU_row;
- if (!(*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {
- /* Suspension forced; update state counters and exit */
- coef->MCU_vert_offset = yoffset;
- coef->MCU_ctr = MCU_col_num;
- return JPEG_SUSPENDED;
- }
-
- /* Only perform the IDCT on blocks that are contained within the desired
- * cropping region.
- */
- if (MCU_col_num >= cinfo->master->first_iMCU_col &&
- MCU_col_num <= cinfo->master->last_iMCU_col) {
- /* Determine where data should go in output_buf and do the IDCT thing.
- * We skip dummy blocks at the right and bottom edges (but blkn gets
- * incremented past them!). Note the inner loop relies on having
- * allocated the MCU_buffer[] blocks sequentially.
- */
- blkn = 0; /* index of current DCT block within MCU */
- for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
- compptr = cinfo->cur_comp_info[ci];
- /* Don't bother to IDCT an uninteresting component. */
- if (!compptr->component_needed) {
- blkn += compptr->MCU_blocks;
- continue;
- }
- inverse_DCT = cinfo->idct->inverse_DCT[compptr->component_index];
- useful_width = (MCU_col_num < last_MCU_col) ?
- compptr->MCU_width : compptr->last_col_width;
- output_ptr = output_buf[compptr->component_index] +
- yoffset * compptr->_DCT_scaled_size;
- start_col = (MCU_col_num - cinfo->master->first_iMCU_col) *
- compptr->MCU_sample_width;
- for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
- if (cinfo->input_iMCU_row < last_iMCU_row ||
- yoffset + yindex < compptr->last_row_height) {
- output_col = start_col;
- for (xindex = 0; xindex < useful_width; xindex++) {
- (*inverse_DCT) (cinfo, compptr,
- (JCOEFPTR)coef->MCU_buffer[blkn + xindex],
- output_ptr, output_col);
- output_col += compptr->_DCT_scaled_size;
- }
- }
- blkn += compptr->MCU_width;
- output_ptr += compptr->_DCT_scaled_size;
- }
- }
- }
- }
- /* Completed an MCU row, but perhaps not an iMCU row */
- coef->MCU_ctr = 0;
- }
- /* Completed the iMCU row, advance counters for next one */
- cinfo->output_iMCU_row++;
- if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) {
- start_iMCU_row(cinfo);
- return JPEG_ROW_COMPLETED;
- }
- /* Completed the scan */
- (*cinfo->inputctl->finish_input_pass) (cinfo);
- return JPEG_SCAN_COMPLETED;
-}
-
-
-/*
- * Dummy consume-input routine for single-pass operation.
- */
-
-METHODDEF(int)
-dummy_consume_data(j_decompress_ptr cinfo)
-{
- return JPEG_SUSPENDED; /* Always indicate nothing was done */
-}
-
-
-#ifdef D_MULTISCAN_FILES_SUPPORTED
-
-/*
- * Consume input data and store it in the full-image coefficient buffer.
- * We read as much as one fully interleaved MCU row ("iMCU" row) per call,
- * ie, v_samp_factor block rows for each component in the scan.
- * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED.
- */
-
-METHODDEF(int)
-consume_data(j_decompress_ptr cinfo)
-{
- my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
- JDIMENSION MCU_col_num; /* index of current MCU within row */
- int blkn, ci, xindex, yindex, yoffset;
- JDIMENSION start_col;
- JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN];
- JBLOCKROW buffer_ptr;
- jpeg_component_info *compptr;
-
- /* Align the virtual buffers for the components used in this scan. */
- for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
- compptr = cinfo->cur_comp_info[ci];
- buffer[ci] = (*cinfo->mem->access_virt_barray)
- ((j_common_ptr)cinfo, coef->whole_image[compptr->component_index],
- cinfo->input_iMCU_row * compptr->v_samp_factor,
- (JDIMENSION)compptr->v_samp_factor, TRUE);
- /* Note: entropy decoder expects buffer to be zeroed,
- * but this is handled automatically by the memory manager
- * because we requested a pre-zeroed array.
- */
- }
-
- /* Loop to process one whole iMCU row */
- for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
- yoffset++) {
- for (MCU_col_num = coef->MCU_ctr; MCU_col_num < cinfo->MCUs_per_row;
- MCU_col_num++) {
- /* Construct list of pointers to DCT blocks belonging to this MCU */
- blkn = 0; /* index of current DCT block within MCU */
- for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
- compptr = cinfo->cur_comp_info[ci];
- start_col = MCU_col_num * compptr->MCU_width;
- for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
- buffer_ptr = buffer[ci][yindex + yoffset] + start_col;
- for (xindex = 0; xindex < compptr->MCU_width; xindex++) {
- coef->MCU_buffer[blkn++] = buffer_ptr++;
- }
- }
- }
- if (!cinfo->entropy->insufficient_data)
- cinfo->master->last_good_iMCU_row = cinfo->input_iMCU_row;
- /* Try to fetch the MCU. */
- if (!(*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {
- /* Suspension forced; update state counters and exit */
- coef->MCU_vert_offset = yoffset;
- coef->MCU_ctr = MCU_col_num;
- return JPEG_SUSPENDED;
- }
- }
- /* Completed an MCU row, but perhaps not an iMCU row */
- coef->MCU_ctr = 0;
- }
- /* Completed the iMCU row, advance counters for next one */
- if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) {
- start_iMCU_row(cinfo);
- return JPEG_ROW_COMPLETED;
- }
- /* Completed the scan */
- (*cinfo->inputctl->finish_input_pass) (cinfo);
- return JPEG_SCAN_COMPLETED;
-}
-
-
-/*
- * Decompress and return some data in the multi-pass case.
- * Always attempts to emit one fully interleaved MCU row ("iMCU" row).
- * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED.
- *
- * NB: output_buf contains a plane for each component in image.
- */
-
-METHODDEF(int)
-decompress_data(j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
-{
- my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
- JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
- JDIMENSION block_num;
- int ci, block_row, block_rows;
- JBLOCKARRAY buffer;
- JBLOCKROW buffer_ptr;
- JSAMPARRAY output_ptr;
- JDIMENSION output_col;
- jpeg_component_info *compptr;
- inverse_DCT_method_ptr inverse_DCT;
-
- /* Force some input to be done if we are getting ahead of the input. */
- while (cinfo->input_scan_number < cinfo->output_scan_number ||
- (cinfo->input_scan_number == cinfo->output_scan_number &&
- cinfo->input_iMCU_row <= cinfo->output_iMCU_row)) {
- if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED)
- return JPEG_SUSPENDED;
- }
-
- /* OK, output from the virtual arrays. */
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
- ci++, compptr++) {
- /* Don't bother to IDCT an uninteresting component. */
- if (!compptr->component_needed)
- continue;
- /* Align the virtual buffer for this component. */
- buffer = (*cinfo->mem->access_virt_barray)
- ((j_common_ptr)cinfo, coef->whole_image[ci],
- cinfo->output_iMCU_row * compptr->v_samp_factor,
- (JDIMENSION)compptr->v_samp_factor, FALSE);
- /* Count non-dummy DCT block rows in this iMCU row. */
- if (cinfo->output_iMCU_row < last_iMCU_row)
- block_rows = compptr->v_samp_factor;
- else {
- /* NB: can't use last_row_height here; it is input-side-dependent! */
- block_rows = (int)(compptr->height_in_blocks % compptr->v_samp_factor);
- if (block_rows == 0) block_rows = compptr->v_samp_factor;
- }
- inverse_DCT = cinfo->idct->inverse_DCT[ci];
- output_ptr = output_buf[ci];
- /* Loop over all DCT blocks to be processed. */
- for (block_row = 0; block_row < block_rows; block_row++) {
- buffer_ptr = buffer[block_row] + cinfo->master->first_MCU_col[ci];
- output_col = 0;
- for (block_num = cinfo->master->first_MCU_col[ci];
- block_num <= cinfo->master->last_MCU_col[ci]; block_num++) {
- (*inverse_DCT) (cinfo, compptr, (JCOEFPTR)buffer_ptr, output_ptr,
- output_col);
- buffer_ptr++;
- output_col += compptr->_DCT_scaled_size;
- }
- output_ptr += compptr->_DCT_scaled_size;
- }
- }
-
- if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows)
- return JPEG_ROW_COMPLETED;
- return JPEG_SCAN_COMPLETED;
-}
-
-#endif /* D_MULTISCAN_FILES_SUPPORTED */
-
-
-#ifdef BLOCK_SMOOTHING_SUPPORTED
-
-/*
- * This code applies interblock smoothing; the first 9 AC coefficients are
- * estimated from the DC values of a DCT block and its 24 neighboring blocks.
- * We apply smoothing only for progressive JPEG decoding, and only if
- * the coefficients it can estimate are not yet known to full precision.
- */
-
-/* Natural-order array positions of the first 9 zigzag-order coefficients */
-#define Q01_POS 1
-#define Q10_POS 8
-#define Q20_POS 16
-#define Q11_POS 9
-#define Q02_POS 2
-#define Q03_POS 3
-#define Q12_POS 10
-#define Q21_POS 17
-#define Q30_POS 24
-
-/*
- * Determine whether block smoothing is applicable and safe.
- * We also latch the current states of the coef_bits[] entries for the
- * AC coefficients; otherwise, if the input side of the decompressor
- * advances into a new scan, we might think the coefficients are known
- * more accurately than they really are.
- */
-
-LOCAL(boolean)
-smoothing_ok(j_decompress_ptr cinfo)
-{
- my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
- boolean smoothing_useful = FALSE;
- int ci, coefi;
- jpeg_component_info *compptr;
- JQUANT_TBL *qtable;
- int *coef_bits, *prev_coef_bits;
- int *coef_bits_latch, *prev_coef_bits_latch;
-
- if (!cinfo->progressive_mode || cinfo->coef_bits == NULL)
- return FALSE;
-
- /* Allocate latch area if not already done */
- if (coef->coef_bits_latch == NULL)
- coef->coef_bits_latch = (int *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- cinfo->num_components * 2 *
- (SAVED_COEFS * sizeof(int)));
- coef_bits_latch = coef->coef_bits_latch;
- prev_coef_bits_latch =
- &coef->coef_bits_latch[cinfo->num_components * SAVED_COEFS];
-
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
- ci++, compptr++) {
- /* All components' quantization values must already be latched. */
- if ((qtable = compptr->quant_table) == NULL)
- return FALSE;
- /* Verify DC & first 9 AC quantizers are nonzero to avoid zero-divide. */
- if (qtable->quantval[0] == 0 ||
- qtable->quantval[Q01_POS] == 0 ||
- qtable->quantval[Q10_POS] == 0 ||
- qtable->quantval[Q20_POS] == 0 ||
- qtable->quantval[Q11_POS] == 0 ||
- qtable->quantval[Q02_POS] == 0 ||
- qtable->quantval[Q03_POS] == 0 ||
- qtable->quantval[Q12_POS] == 0 ||
- qtable->quantval[Q21_POS] == 0 ||
- qtable->quantval[Q30_POS] == 0)
- return FALSE;
- /* DC values must be at least partly known for all components. */
- coef_bits = cinfo->coef_bits[ci];
- prev_coef_bits = cinfo->coef_bits[ci + cinfo->num_components];
- if (coef_bits[0] < 0)
- return FALSE;
- coef_bits_latch[0] = coef_bits[0];
- /* Block smoothing is helpful if some AC coefficients remain inaccurate. */
- for (coefi = 1; coefi < SAVED_COEFS; coefi++) {
- if (cinfo->input_scan_number > 1)
- prev_coef_bits_latch[coefi] = prev_coef_bits[coefi];
- else
- prev_coef_bits_latch[coefi] = -1;
- coef_bits_latch[coefi] = coef_bits[coefi];
- if (coef_bits[coefi] != 0)
- smoothing_useful = TRUE;
- }
- coef_bits_latch += SAVED_COEFS;
- prev_coef_bits_latch += SAVED_COEFS;
- }
-
- return smoothing_useful;
-}
-
-
-/*
- * Variant of decompress_data for use when doing block smoothing.
- */
-
-METHODDEF(int)
-decompress_smooth_data(j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
-{
- my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
- JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
- JDIMENSION block_num, last_block_column;
- int ci, block_row, block_rows, access_rows;
- JBLOCKARRAY buffer;
- JBLOCKROW buffer_ptr, prev_prev_block_row, prev_block_row;
- JBLOCKROW next_block_row, next_next_block_row;
- JSAMPARRAY output_ptr;
- JDIMENSION output_col;
- jpeg_component_info *compptr;
- inverse_DCT_method_ptr inverse_DCT;
- boolean change_dc;
- JCOEF *workspace;
- int *coef_bits;
- JQUANT_TBL *quanttbl;
- JLONG Q00, Q01, Q02, Q03 = 0, Q10, Q11, Q12 = 0, Q20, Q21 = 0, Q30 = 0, num;
- int DC01, DC02, DC03, DC04, DC05, DC06, DC07, DC08, DC09, DC10, DC11, DC12,
- DC13, DC14, DC15, DC16, DC17, DC18, DC19, DC20, DC21, DC22, DC23, DC24,
- DC25;
- int Al, pred;
-
- /* Keep a local variable to avoid looking it up more than once */
- workspace = coef->workspace;
-
- /* Force some input to be done if we are getting ahead of the input. */
- while (cinfo->input_scan_number <= cinfo->output_scan_number &&
- !cinfo->inputctl->eoi_reached) {
- if (cinfo->input_scan_number == cinfo->output_scan_number) {
- /* If input is working on current scan, we ordinarily want it to
- * have completed the current row. But if input scan is DC,
- * we want it to keep two rows ahead so that next two block rows' DC
- * values are up to date.
- */
- JDIMENSION delta = (cinfo->Ss == 0) ? 2 : 0;
- if (cinfo->input_iMCU_row > cinfo->output_iMCU_row + delta)
- break;
- }
- if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED)
- return JPEG_SUSPENDED;
- }
-
- /* OK, output from the virtual arrays. */
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
- ci++, compptr++) {
- /* Don't bother to IDCT an uninteresting component. */
- if (!compptr->component_needed)
- continue;
- /* Count non-dummy DCT block rows in this iMCU row. */
- if (cinfo->output_iMCU_row + 1 < last_iMCU_row) {
- block_rows = compptr->v_samp_factor;
- access_rows = block_rows * 3; /* this and next two iMCU rows */
- } else if (cinfo->output_iMCU_row < last_iMCU_row) {
- block_rows = compptr->v_samp_factor;
- access_rows = block_rows * 2; /* this and next iMCU row */
- } else {
- /* NB: can't use last_row_height here; it is input-side-dependent! */
- block_rows = (int)(compptr->height_in_blocks % compptr->v_samp_factor);
- if (block_rows == 0) block_rows = compptr->v_samp_factor;
- access_rows = block_rows; /* this iMCU row only */
- }
- /* Align the virtual buffer for this component. */
- if (cinfo->output_iMCU_row > 1) {
- access_rows += 2 * compptr->v_samp_factor; /* prior two iMCU rows too */
- buffer = (*cinfo->mem->access_virt_barray)
- ((j_common_ptr)cinfo, coef->whole_image[ci],
- (cinfo->output_iMCU_row - 2) * compptr->v_samp_factor,
- (JDIMENSION)access_rows, FALSE);
- buffer += 2 * compptr->v_samp_factor; /* point to current iMCU row */
- } else if (cinfo->output_iMCU_row > 0) {
- buffer = (*cinfo->mem->access_virt_barray)
- ((j_common_ptr)cinfo, coef->whole_image[ci],
- (cinfo->output_iMCU_row - 1) * compptr->v_samp_factor,
- (JDIMENSION)access_rows, FALSE);
- buffer += compptr->v_samp_factor; /* point to current iMCU row */
- } else {
- buffer = (*cinfo->mem->access_virt_barray)
- ((j_common_ptr)cinfo, coef->whole_image[ci],
- (JDIMENSION)0, (JDIMENSION)access_rows, FALSE);
- }
- /* Fetch component-dependent info.
- * If the current scan is incomplete, then we use the component-dependent
- * info from the previous scan.
- */
- if (cinfo->output_iMCU_row > cinfo->master->last_good_iMCU_row)
- coef_bits =
- coef->coef_bits_latch + ((ci + cinfo->num_components) * SAVED_COEFS);
- else
- coef_bits = coef->coef_bits_latch + (ci * SAVED_COEFS);
-
- /* We only do DC interpolation if no AC coefficient data is available. */
- change_dc =
- coef_bits[1] == -1 && coef_bits[2] == -1 && coef_bits[3] == -1 &&
- coef_bits[4] == -1 && coef_bits[5] == -1 && coef_bits[6] == -1 &&
- coef_bits[7] == -1 && coef_bits[8] == -1 && coef_bits[9] == -1;
-
- quanttbl = compptr->quant_table;
- Q00 = quanttbl->quantval[0];
- Q01 = quanttbl->quantval[Q01_POS];
- Q10 = quanttbl->quantval[Q10_POS];
- Q20 = quanttbl->quantval[Q20_POS];
- Q11 = quanttbl->quantval[Q11_POS];
- Q02 = quanttbl->quantval[Q02_POS];
- if (change_dc) {
- Q03 = quanttbl->quantval[Q03_POS];
- Q12 = quanttbl->quantval[Q12_POS];
- Q21 = quanttbl->quantval[Q21_POS];
- Q30 = quanttbl->quantval[Q30_POS];
- }
- inverse_DCT = cinfo->idct->inverse_DCT[ci];
- output_ptr = output_buf[ci];
- /* Loop over all DCT blocks to be processed. */
- for (block_row = 0; block_row < block_rows; block_row++) {
- buffer_ptr = buffer[block_row] + cinfo->master->first_MCU_col[ci];
-
- if (block_row > 0 || cinfo->output_iMCU_row > 0)
- prev_block_row =
- buffer[block_row - 1] + cinfo->master->first_MCU_col[ci];
- else
- prev_block_row = buffer_ptr;
-
- if (block_row > 1 || cinfo->output_iMCU_row > 1)
- prev_prev_block_row =
- buffer[block_row - 2] + cinfo->master->first_MCU_col[ci];
- else
- prev_prev_block_row = prev_block_row;
-
- if (block_row < block_rows - 1 || cinfo->output_iMCU_row < last_iMCU_row)
- next_block_row =
- buffer[block_row + 1] + cinfo->master->first_MCU_col[ci];
- else
- next_block_row = buffer_ptr;
-
- if (block_row < block_rows - 2 ||
- cinfo->output_iMCU_row + 1 < last_iMCU_row)
- next_next_block_row =
- buffer[block_row + 2] + cinfo->master->first_MCU_col[ci];
- else
- next_next_block_row = next_block_row;
-
- /* We fetch the surrounding DC values using a sliding-register approach.
- * Initialize all 25 here so as to do the right thing on narrow pics.
- */
- DC01 = DC02 = DC03 = DC04 = DC05 = (int)prev_prev_block_row[0][0];
- DC06 = DC07 = DC08 = DC09 = DC10 = (int)prev_block_row[0][0];
- DC11 = DC12 = DC13 = DC14 = DC15 = (int)buffer_ptr[0][0];
- DC16 = DC17 = DC18 = DC19 = DC20 = (int)next_block_row[0][0];
- DC21 = DC22 = DC23 = DC24 = DC25 = (int)next_next_block_row[0][0];
- output_col = 0;
- last_block_column = compptr->width_in_blocks - 1;
- for (block_num = cinfo->master->first_MCU_col[ci];
- block_num <= cinfo->master->last_MCU_col[ci]; block_num++) {
- /* Fetch current DCT block into workspace so we can modify it. */
- jcopy_block_row(buffer_ptr, (JBLOCKROW)workspace, (JDIMENSION)1);
- /* Update DC values */
- if (block_num == cinfo->master->first_MCU_col[ci] &&
- block_num < last_block_column) {
- DC04 = (int)prev_prev_block_row[1][0];
- DC09 = (int)prev_block_row[1][0];
- DC14 = (int)buffer_ptr[1][0];
- DC19 = (int)next_block_row[1][0];
- DC24 = (int)next_next_block_row[1][0];
- }
- if (block_num + 1 < last_block_column) {
- DC05 = (int)prev_prev_block_row[2][0];
- DC10 = (int)prev_block_row[2][0];
- DC15 = (int)buffer_ptr[2][0];
- DC20 = (int)next_block_row[2][0];
- DC25 = (int)next_next_block_row[2][0];
- }
- /* If DC interpolation is enabled, compute coefficient estimates using
- * a Gaussian-like kernel, keeping the averages of the DC values.
- *
- * If DC interpolation is disabled, compute coefficient estimates using
- * an algorithm similar to the one described in Section K.8 of the JPEG
- * standard, except applied to a 5x5 window rather than a 3x3 window.
- *
- * An estimate is applied only if the coefficient is still zero and is
- * not known to be fully accurate.
- */
- /* AC01 */
- if ((Al = coef_bits[1]) != 0 && workspace[1] == 0) {
- num = Q00 * (change_dc ?
- (-DC01 - DC02 + DC04 + DC05 - 3 * DC06 + 13 * DC07 -
- 13 * DC09 + 3 * DC10 - 3 * DC11 + 38 * DC12 - 38 * DC14 +
- 3 * DC15 - 3 * DC16 + 13 * DC17 - 13 * DC19 + 3 * DC20 -
- DC21 - DC22 + DC24 + DC25) :
- (-7 * DC11 + 50 * DC12 - 50 * DC14 + 7 * DC15));
- if (num >= 0) {
- pred = (int)(((Q01 << 7) + num) / (Q01 << 8));
- if (Al > 0 && pred >= (1 << Al))
- pred = (1 << Al) - 1;
- } else {
- pred = (int)(((Q01 << 7) - num) / (Q01 << 8));
- if (Al > 0 && pred >= (1 << Al))
- pred = (1 << Al) - 1;
- pred = -pred;
- }
- workspace[1] = (JCOEF)pred;
- }
- /* AC10 */
- if ((Al = coef_bits[2]) != 0 && workspace[8] == 0) {
- num = Q00 * (change_dc ?
- (-DC01 - 3 * DC02 - 3 * DC03 - 3 * DC04 - DC05 - DC06 +
- 13 * DC07 + 38 * DC08 + 13 * DC09 - DC10 + DC16 -
- 13 * DC17 - 38 * DC18 - 13 * DC19 + DC20 + DC21 +
- 3 * DC22 + 3 * DC23 + 3 * DC24 + DC25) :
- (-7 * DC03 + 50 * DC08 - 50 * DC18 + 7 * DC23));
- if (num >= 0) {
- pred = (int)(((Q10 << 7) + num) / (Q10 << 8));
- if (Al > 0 && pred >= (1 << Al))
- pred = (1 << Al) - 1;
- } else {
- pred = (int)(((Q10 << 7) - num) / (Q10 << 8));
- if (Al > 0 && pred >= (1 << Al))
- pred = (1 << Al) - 1;
- pred = -pred;
- }
- workspace[8] = (JCOEF)pred;
- }
- /* AC20 */
- if ((Al = coef_bits[3]) != 0 && workspace[16] == 0) {
- num = Q00 * (change_dc ?
- (DC03 + 2 * DC07 + 7 * DC08 + 2 * DC09 - 5 * DC12 - 14 * DC13 -
- 5 * DC14 + 2 * DC17 + 7 * DC18 + 2 * DC19 + DC23) :
- (-DC03 + 13 * DC08 - 24 * DC13 + 13 * DC18 - DC23));
- if (num >= 0) {
- pred = (int)(((Q20 << 7) + num) / (Q20 << 8));
- if (Al > 0 && pred >= (1 << Al))
- pred = (1 << Al) - 1;
- } else {
- pred = (int)(((Q20 << 7) - num) / (Q20 << 8));
- if (Al > 0 && pred >= (1 << Al))
- pred = (1 << Al) - 1;
- pred = -pred;
- }
- workspace[16] = (JCOEF)pred;
- }
- /* AC11 */
- if ((Al = coef_bits[4]) != 0 && workspace[9] == 0) {
- num = Q00 * (change_dc ?
- (-DC01 + DC05 + 9 * DC07 - 9 * DC09 - 9 * DC17 +
- 9 * DC19 + DC21 - DC25) :
- (DC10 + DC16 - 10 * DC17 + 10 * DC19 - DC02 - DC20 + DC22 -
- DC24 + DC04 - DC06 + 10 * DC07 - 10 * DC09));
- if (num >= 0) {
- pred = (int)(((Q11 << 7) + num) / (Q11 << 8));
- if (Al > 0 && pred >= (1 << Al))
- pred = (1 << Al) - 1;
- } else {
- pred = (int)(((Q11 << 7) - num) / (Q11 << 8));
- if (Al > 0 && pred >= (1 << Al))
- pred = (1 << Al) - 1;
- pred = -pred;
- }
- workspace[9] = (JCOEF)pred;
- }
- /* AC02 */
- if ((Al = coef_bits[5]) != 0 && workspace[2] == 0) {
- num = Q00 * (change_dc ?
- (2 * DC07 - 5 * DC08 + 2 * DC09 + DC11 + 7 * DC12 - 14 * DC13 +
- 7 * DC14 + DC15 + 2 * DC17 - 5 * DC18 + 2 * DC19) :
- (-DC11 + 13 * DC12 - 24 * DC13 + 13 * DC14 - DC15));
- if (num >= 0) {
- pred = (int)(((Q02 << 7) + num) / (Q02 << 8));
- if (Al > 0 && pred >= (1 << Al))
- pred = (1 << Al) - 1;
- } else {
- pred = (int)(((Q02 << 7) - num) / (Q02 << 8));
- if (Al > 0 && pred >= (1 << Al))
- pred = (1 << Al) - 1;
- pred = -pred;
- }
- workspace[2] = (JCOEF)pred;
- }
- if (change_dc) {
- /* AC03 */
- if ((Al = coef_bits[6]) != 0 && workspace[3] == 0) {
- num = Q00 * (DC07 - DC09 + 2 * DC12 - 2 * DC14 + DC17 - DC19);
- if (num >= 0) {
- pred = (int)(((Q03 << 7) + num) / (Q03 << 8));
- if (Al > 0 && pred >= (1 << Al))
- pred = (1 << Al) - 1;
- } else {
- pred = (int)(((Q03 << 7) - num) / (Q03 << 8));
- if (Al > 0 && pred >= (1 << Al))
- pred = (1 << Al) - 1;
- pred = -pred;
- }
- workspace[3] = (JCOEF)pred;
- }
- /* AC12 */
- if ((Al = coef_bits[7]) != 0 && workspace[10] == 0) {
- num = Q00 * (DC07 - 3 * DC08 + DC09 - DC17 + 3 * DC18 - DC19);
- if (num >= 0) {
- pred = (int)(((Q12 << 7) + num) / (Q12 << 8));
- if (Al > 0 && pred >= (1 << Al))
- pred = (1 << Al) - 1;
- } else {
- pred = (int)(((Q12 << 7) - num) / (Q12 << 8));
- if (Al > 0 && pred >= (1 << Al))
- pred = (1 << Al) - 1;
- pred = -pred;
- }
- workspace[10] = (JCOEF)pred;
- }
- /* AC21 */
- if ((Al = coef_bits[8]) != 0 && workspace[17] == 0) {
- num = Q00 * (DC07 - DC09 - 3 * DC12 + 3 * DC14 + DC17 - DC19);
- if (num >= 0) {
- pred = (int)(((Q21 << 7) + num) / (Q21 << 8));
- if (Al > 0 && pred >= (1 << Al))
- pred = (1 << Al) - 1;
- } else {
- pred = (int)(((Q21 << 7) - num) / (Q21 << 8));
- if (Al > 0 && pred >= (1 << Al))
- pred = (1 << Al) - 1;
- pred = -pred;
- }
- workspace[17] = (JCOEF)pred;
- }
- /* AC30 */
- if ((Al = coef_bits[9]) != 0 && workspace[24] == 0) {
- num = Q00 * (DC07 + 2 * DC08 + DC09 - DC17 - 2 * DC18 - DC19);
- if (num >= 0) {
- pred = (int)(((Q30 << 7) + num) / (Q30 << 8));
- if (Al > 0 && pred >= (1 << Al))
- pred = (1 << Al) - 1;
- } else {
- pred = (int)(((Q30 << 7) - num) / (Q30 << 8));
- if (Al > 0 && pred >= (1 << Al))
- pred = (1 << Al) - 1;
- pred = -pred;
- }
- workspace[24] = (JCOEF)pred;
- }
- /* coef_bits[0] is non-negative. Otherwise this function would not
- * be called.
- */
- num = Q00 *
- (-2 * DC01 - 6 * DC02 - 8 * DC03 - 6 * DC04 - 2 * DC05 -
- 6 * DC06 + 6 * DC07 + 42 * DC08 + 6 * DC09 - 6 * DC10 -
- 8 * DC11 + 42 * DC12 + 152 * DC13 + 42 * DC14 - 8 * DC15 -
- 6 * DC16 + 6 * DC17 + 42 * DC18 + 6 * DC19 - 6 * DC20 -
- 2 * DC21 - 6 * DC22 - 8 * DC23 - 6 * DC24 - 2 * DC25);
- if (num >= 0) {
- pred = (int)(((Q00 << 7) + num) / (Q00 << 8));
- } else {
- pred = (int)(((Q00 << 7) - num) / (Q00 << 8));
- pred = -pred;
- }
- workspace[0] = (JCOEF)pred;
- } /* change_dc */
-
- /* OK, do the IDCT */
- (*inverse_DCT) (cinfo, compptr, (JCOEFPTR)workspace, output_ptr,
- output_col);
- /* Advance for next column */
- DC01 = DC02; DC02 = DC03; DC03 = DC04; DC04 = DC05;
- DC06 = DC07; DC07 = DC08; DC08 = DC09; DC09 = DC10;
- DC11 = DC12; DC12 = DC13; DC13 = DC14; DC14 = DC15;
- DC16 = DC17; DC17 = DC18; DC18 = DC19; DC19 = DC20;
- DC21 = DC22; DC22 = DC23; DC23 = DC24; DC24 = DC25;
- buffer_ptr++, prev_block_row++, next_block_row++,
- prev_prev_block_row++, next_next_block_row++;
- output_col += compptr->_DCT_scaled_size;
- }
- output_ptr += compptr->_DCT_scaled_size;
- }
- }
-
- if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows)
- return JPEG_ROW_COMPLETED;
- return JPEG_SCAN_COMPLETED;
-}
-
-#endif /* BLOCK_SMOOTHING_SUPPORTED */
-
-
-/*
- * Initialize coefficient buffer controller.
- */
-
-GLOBAL(void)
-jinit_d_coef_controller(j_decompress_ptr cinfo, boolean need_full_buffer)
-{
- my_coef_ptr coef;
-
- coef = (my_coef_ptr)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- sizeof(my_coef_controller));
- cinfo->coef = (struct jpeg_d_coef_controller *)coef;
- coef->pub.start_input_pass = start_input_pass;
- coef->pub.start_output_pass = start_output_pass;
-#ifdef BLOCK_SMOOTHING_SUPPORTED
- coef->coef_bits_latch = NULL;
-#endif
-
- /* Create the coefficient buffer. */
- if (need_full_buffer) {
-#ifdef D_MULTISCAN_FILES_SUPPORTED
- /* Allocate a full-image virtual array for each component, */
- /* padded to a multiple of samp_factor DCT blocks in each direction. */
- /* Note we ask for a pre-zeroed array. */
- int ci, access_rows;
- jpeg_component_info *compptr;
-
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
- ci++, compptr++) {
- access_rows = compptr->v_samp_factor;
-#ifdef BLOCK_SMOOTHING_SUPPORTED
- /* If block smoothing could be used, need a bigger window */
- if (cinfo->progressive_mode)
- access_rows *= 5;
-#endif
- coef->whole_image[ci] = (*cinfo->mem->request_virt_barray)
- ((j_common_ptr)cinfo, JPOOL_IMAGE, TRUE,
- (JDIMENSION)jround_up((long)compptr->width_in_blocks,
- (long)compptr->h_samp_factor),
- (JDIMENSION)jround_up((long)compptr->height_in_blocks,
- (long)compptr->v_samp_factor),
- (JDIMENSION)access_rows);
- }
- coef->pub.consume_data = consume_data;
- coef->pub.decompress_data = decompress_data;
- coef->pub.coef_arrays = coef->whole_image; /* link to virtual arrays */
-#else
- ERREXIT(cinfo, JERR_NOT_COMPILED);
-#endif
- } else {
- /* We only need a single-MCU buffer. */
- JBLOCKROW buffer;
- int i;
-
- buffer = (JBLOCKROW)
- (*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- D_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK));
- for (i = 0; i < D_MAX_BLOCKS_IN_MCU; i++) {
- coef->MCU_buffer[i] = buffer + i;
- }
- coef->pub.consume_data = dummy_consume_data;
- coef->pub.decompress_data = decompress_onepass;
- coef->pub.coef_arrays = NULL; /* flag for no virtual arrays */
- }
-
- /* Allocate the workspace buffer */
- coef->workspace = (JCOEF *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- sizeof(JCOEF) * DCTSIZE2);
-}
diff --git a/contrib/libs/libjpeg-turbo/jdcoefct.h b/contrib/libs/libjpeg-turbo/jdcoefct.h
deleted file mode 100644
index 9a0e780663..0000000000
--- a/contrib/libs/libjpeg-turbo/jdcoefct.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * jdcoefct.h
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1994-1997, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- * Copyright (C) 2020, Google, Inc.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- */
-
-#define JPEG_INTERNALS
-#include "jpeglib.h"
-
-
-/* Block smoothing is only applicable for progressive JPEG, so: */
-#ifndef D_PROGRESSIVE_SUPPORTED
-#undef BLOCK_SMOOTHING_SUPPORTED
-#endif
-
-
-/* Private buffer controller object */
-
-typedef struct {
- struct jpeg_d_coef_controller pub; /* public fields */
-
- /* These variables keep track of the current location of the input side. */
- /* cinfo->input_iMCU_row is also used for this. */
- JDIMENSION MCU_ctr; /* counts MCUs processed in current row */
- int MCU_vert_offset; /* counts MCU rows within iMCU row */
- int MCU_rows_per_iMCU_row; /* number of such rows needed */
-
- /* The output side's location is represented by cinfo->output_iMCU_row. */
-
- /* In single-pass modes, it's sufficient to buffer just one MCU.
- * We allocate a workspace of D_MAX_BLOCKS_IN_MCU coefficient blocks,
- * and let the entropy decoder write into that workspace each time.
- * In multi-pass modes, this array points to the current MCU's blocks
- * within the virtual arrays; it is used only by the input side.
- */
- JBLOCKROW MCU_buffer[D_MAX_BLOCKS_IN_MCU];
-
- /* Temporary workspace for one MCU */
- JCOEF *workspace;
-
-#ifdef D_MULTISCAN_FILES_SUPPORTED
- /* In multi-pass modes, we need a virtual block array for each component. */
- jvirt_barray_ptr whole_image[MAX_COMPONENTS];
-#endif
-
-#ifdef BLOCK_SMOOTHING_SUPPORTED
- /* When doing block smoothing, we latch coefficient Al values here */
- int *coef_bits_latch;
-#define SAVED_COEFS 10 /* we save coef_bits[0..9] */
-#endif
-} my_coef_controller;
-
-typedef my_coef_controller *my_coef_ptr;
-
-
-LOCAL(void)
-start_iMCU_row(j_decompress_ptr cinfo)
-/* Reset within-iMCU-row counters for a new row (input side) */
-{
- my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
-
- /* In an interleaved scan, an MCU row is the same as an iMCU row.
- * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows.
- * But at the bottom of the image, process only what's left.
- */
- if (cinfo->comps_in_scan > 1) {
- coef->MCU_rows_per_iMCU_row = 1;
- } else {
- if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows - 1))
- coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor;
- else
- coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height;
- }
-
- coef->MCU_ctr = 0;
- coef->MCU_vert_offset = 0;
-}
diff --git a/contrib/libs/libjpeg-turbo/jdcol565.c b/contrib/libs/libjpeg-turbo/jdcol565.c
deleted file mode 100644
index 53c7bd9187..0000000000
--- a/contrib/libs/libjpeg-turbo/jdcol565.c
+++ /dev/null
@@ -1,384 +0,0 @@
-/*
- * jdcol565.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * Modifications:
- * Copyright (C) 2013, Linaro Limited.
- * Copyright (C) 2014-2015, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains output colorspace conversion routines.
- */
-
-/* This file is included by jdcolor.c */
-
-
-INLINE
-LOCAL(void)
-ycc_rgb565_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf,
- int num_rows)
-{
- my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
- register int y, cb, cr;
- register JSAMPROW outptr;
- register JSAMPROW inptr0, inptr1, inptr2;
- register JDIMENSION col;
- JDIMENSION num_cols = cinfo->output_width;
- /* copy these pointers into registers if possible */
- register JSAMPLE *range_limit = cinfo->sample_range_limit;
- register int *Crrtab = cconvert->Cr_r_tab;
- register int *Cbbtab = cconvert->Cb_b_tab;
- register JLONG *Crgtab = cconvert->Cr_g_tab;
- register JLONG *Cbgtab = cconvert->Cb_g_tab;
- SHIFT_TEMPS
-
- while (--num_rows >= 0) {
- JLONG rgb;
- unsigned int r, g, b;
- inptr0 = input_buf[0][input_row];
- inptr1 = input_buf[1][input_row];
- inptr2 = input_buf[2][input_row];
- input_row++;
- outptr = *output_buf++;
-
- if (PACK_NEED_ALIGNMENT(outptr)) {
- y = *inptr0++;
- cb = *inptr1++;
- cr = *inptr2++;
- r = range_limit[y + Crrtab[cr]];
- g = range_limit[y + ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
- SCALEBITS))];
- b = range_limit[y + Cbbtab[cb]];
- rgb = PACK_SHORT_565(r, g, b);
- *(INT16 *)outptr = (INT16)rgb;
- outptr += 2;
- num_cols--;
- }
- for (col = 0; col < (num_cols >> 1); col++) {
- y = *inptr0++;
- cb = *inptr1++;
- cr = *inptr2++;
- r = range_limit[y + Crrtab[cr]];
- g = range_limit[y + ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
- SCALEBITS))];
- b = range_limit[y + Cbbtab[cb]];
- rgb = PACK_SHORT_565(r, g, b);
-
- y = *inptr0++;
- cb = *inptr1++;
- cr = *inptr2++;
- r = range_limit[y + Crrtab[cr]];
- g = range_limit[y + ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
- SCALEBITS))];
- b = range_limit[y + Cbbtab[cb]];
- rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
-
- WRITE_TWO_ALIGNED_PIXELS(outptr, rgb);
- outptr += 4;
- }
- if (num_cols & 1) {
- y = *inptr0;
- cb = *inptr1;
- cr = *inptr2;
- r = range_limit[y + Crrtab[cr]];
- g = range_limit[y + ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
- SCALEBITS))];
- b = range_limit[y + Cbbtab[cb]];
- rgb = PACK_SHORT_565(r, g, b);
- *(INT16 *)outptr = (INT16)rgb;
- }
- }
-}
-
-
-INLINE
-LOCAL(void)
-ycc_rgb565D_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf,
- int num_rows)
-{
- my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
- register int y, cb, cr;
- register JSAMPROW outptr;
- register JSAMPROW inptr0, inptr1, inptr2;
- register JDIMENSION col;
- JDIMENSION num_cols = cinfo->output_width;
- /* copy these pointers into registers if possible */
- register JSAMPLE *range_limit = cinfo->sample_range_limit;
- register int *Crrtab = cconvert->Cr_r_tab;
- register int *Cbbtab = cconvert->Cb_b_tab;
- register JLONG *Crgtab = cconvert->Cr_g_tab;
- register JLONG *Cbgtab = cconvert->Cb_g_tab;
- JLONG d0 = dither_matrix[cinfo->output_scanline & DITHER_MASK];
- SHIFT_TEMPS
-
- while (--num_rows >= 0) {
- JLONG rgb;
- unsigned int r, g, b;
-
- inptr0 = input_buf[0][input_row];
- inptr1 = input_buf[1][input_row];
- inptr2 = input_buf[2][input_row];
- input_row++;
- outptr = *output_buf++;
- if (PACK_NEED_ALIGNMENT(outptr)) {
- y = *inptr0++;
- cb = *inptr1++;
- cr = *inptr2++;
- r = range_limit[DITHER_565_R(y + Crrtab[cr], d0)];
- g = range_limit[DITHER_565_G(y +
- ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
- SCALEBITS)), d0)];
- b = range_limit[DITHER_565_B(y + Cbbtab[cb], d0)];
- rgb = PACK_SHORT_565(r, g, b);
- *(INT16 *)outptr = (INT16)rgb;
- outptr += 2;
- num_cols--;
- }
- for (col = 0; col < (num_cols >> 1); col++) {
- y = *inptr0++;
- cb = *inptr1++;
- cr = *inptr2++;
- r = range_limit[DITHER_565_R(y + Crrtab[cr], d0)];
- g = range_limit[DITHER_565_G(y +
- ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
- SCALEBITS)), d0)];
- b = range_limit[DITHER_565_B(y + Cbbtab[cb], d0)];
- d0 = DITHER_ROTATE(d0);
- rgb = PACK_SHORT_565(r, g, b);
-
- y = *inptr0++;
- cb = *inptr1++;
- cr = *inptr2++;
- r = range_limit[DITHER_565_R(y + Crrtab[cr], d0)];
- g = range_limit[DITHER_565_G(y +
- ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
- SCALEBITS)), d0)];
- b = range_limit[DITHER_565_B(y + Cbbtab[cb], d0)];
- d0 = DITHER_ROTATE(d0);
- rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
-
- WRITE_TWO_ALIGNED_PIXELS(outptr, rgb);
- outptr += 4;
- }
- if (num_cols & 1) {
- y = *inptr0;
- cb = *inptr1;
- cr = *inptr2;
- r = range_limit[DITHER_565_R(y + Crrtab[cr], d0)];
- g = range_limit[DITHER_565_G(y +
- ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
- SCALEBITS)), d0)];
- b = range_limit[DITHER_565_B(y + Cbbtab[cb], d0)];
- rgb = PACK_SHORT_565(r, g, b);
- *(INT16 *)outptr = (INT16)rgb;
- }
- }
-}
-
-
-INLINE
-LOCAL(void)
-rgb_rgb565_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf,
- int num_rows)
-{
- register JSAMPROW outptr;
- register JSAMPROW inptr0, inptr1, inptr2;
- register JDIMENSION col;
- JDIMENSION num_cols = cinfo->output_width;
- SHIFT_TEMPS
-
- while (--num_rows >= 0) {
- JLONG rgb;
- unsigned int r, g, b;
-
- inptr0 = input_buf[0][input_row];
- inptr1 = input_buf[1][input_row];
- inptr2 = input_buf[2][input_row];
- input_row++;
- outptr = *output_buf++;
- if (PACK_NEED_ALIGNMENT(outptr)) {
- r = *inptr0++;
- g = *inptr1++;
- b = *inptr2++;
- rgb = PACK_SHORT_565(r, g, b);
- *(INT16 *)outptr = (INT16)rgb;
- outptr += 2;
- num_cols--;
- }
- for (col = 0; col < (num_cols >> 1); col++) {
- r = *inptr0++;
- g = *inptr1++;
- b = *inptr2++;
- rgb = PACK_SHORT_565(r, g, b);
-
- r = *inptr0++;
- g = *inptr1++;
- b = *inptr2++;
- rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
-
- WRITE_TWO_ALIGNED_PIXELS(outptr, rgb);
- outptr += 4;
- }
- if (num_cols & 1) {
- r = *inptr0;
- g = *inptr1;
- b = *inptr2;
- rgb = PACK_SHORT_565(r, g, b);
- *(INT16 *)outptr = (INT16)rgb;
- }
- }
-}
-
-
-INLINE
-LOCAL(void)
-rgb_rgb565D_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf,
- int num_rows)
-{
- register JSAMPROW outptr;
- register JSAMPROW inptr0, inptr1, inptr2;
- register JDIMENSION col;
- register JSAMPLE *range_limit = cinfo->sample_range_limit;
- JDIMENSION num_cols = cinfo->output_width;
- JLONG d0 = dither_matrix[cinfo->output_scanline & DITHER_MASK];
- SHIFT_TEMPS
-
- while (--num_rows >= 0) {
- JLONG rgb;
- unsigned int r, g, b;
-
- inptr0 = input_buf[0][input_row];
- inptr1 = input_buf[1][input_row];
- inptr2 = input_buf[2][input_row];
- input_row++;
- outptr = *output_buf++;
- if (PACK_NEED_ALIGNMENT(outptr)) {
- r = range_limit[DITHER_565_R(*inptr0++, d0)];
- g = range_limit[DITHER_565_G(*inptr1++, d0)];
- b = range_limit[DITHER_565_B(*inptr2++, d0)];
- rgb = PACK_SHORT_565(r, g, b);
- *(INT16 *)outptr = (INT16)rgb;
- outptr += 2;
- num_cols--;
- }
- for (col = 0; col < (num_cols >> 1); col++) {
- r = range_limit[DITHER_565_R(*inptr0++, d0)];
- g = range_limit[DITHER_565_G(*inptr1++, d0)];
- b = range_limit[DITHER_565_B(*inptr2++, d0)];
- d0 = DITHER_ROTATE(d0);
- rgb = PACK_SHORT_565(r, g, b);
-
- r = range_limit[DITHER_565_R(*inptr0++, d0)];
- g = range_limit[DITHER_565_G(*inptr1++, d0)];
- b = range_limit[DITHER_565_B(*inptr2++, d0)];
- d0 = DITHER_ROTATE(d0);
- rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
-
- WRITE_TWO_ALIGNED_PIXELS(outptr, rgb);
- outptr += 4;
- }
- if (num_cols & 1) {
- r = range_limit[DITHER_565_R(*inptr0, d0)];
- g = range_limit[DITHER_565_G(*inptr1, d0)];
- b = range_limit[DITHER_565_B(*inptr2, d0)];
- rgb = PACK_SHORT_565(r, g, b);
- *(INT16 *)outptr = (INT16)rgb;
- }
- }
-}
-
-
-INLINE
-LOCAL(void)
-gray_rgb565_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf,
- int num_rows)
-{
- register JSAMPROW inptr, outptr;
- register JDIMENSION col;
- JDIMENSION num_cols = cinfo->output_width;
-
- while (--num_rows >= 0) {
- JLONG rgb;
- unsigned int g;
-
- inptr = input_buf[0][input_row++];
- outptr = *output_buf++;
- if (PACK_NEED_ALIGNMENT(outptr)) {
- g = *inptr++;
- rgb = PACK_SHORT_565(g, g, g);
- *(INT16 *)outptr = (INT16)rgb;
- outptr += 2;
- num_cols--;
- }
- for (col = 0; col < (num_cols >> 1); col++) {
- g = *inptr++;
- rgb = PACK_SHORT_565(g, g, g);
- g = *inptr++;
- rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(g, g, g));
- WRITE_TWO_ALIGNED_PIXELS(outptr, rgb);
- outptr += 4;
- }
- if (num_cols & 1) {
- g = *inptr;
- rgb = PACK_SHORT_565(g, g, g);
- *(INT16 *)outptr = (INT16)rgb;
- }
- }
-}
-
-
-INLINE
-LOCAL(void)
-gray_rgb565D_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf,
- int num_rows)
-{
- register JSAMPROW inptr, outptr;
- register JDIMENSION col;
- register JSAMPLE *range_limit = cinfo->sample_range_limit;
- JDIMENSION num_cols = cinfo->output_width;
- JLONG d0 = dither_matrix[cinfo->output_scanline & DITHER_MASK];
-
- while (--num_rows >= 0) {
- JLONG rgb;
- unsigned int g;
-
- inptr = input_buf[0][input_row++];
- outptr = *output_buf++;
- if (PACK_NEED_ALIGNMENT(outptr)) {
- g = *inptr++;
- g = range_limit[DITHER_565_R(g, d0)];
- rgb = PACK_SHORT_565(g, g, g);
- *(INT16 *)outptr = (INT16)rgb;
- outptr += 2;
- num_cols--;
- }
- for (col = 0; col < (num_cols >> 1); col++) {
- g = *inptr++;
- g = range_limit[DITHER_565_R(g, d0)];
- rgb = PACK_SHORT_565(g, g, g);
- d0 = DITHER_ROTATE(d0);
-
- g = *inptr++;
- g = range_limit[DITHER_565_R(g, d0)];
- rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(g, g, g));
- d0 = DITHER_ROTATE(d0);
-
- WRITE_TWO_ALIGNED_PIXELS(outptr, rgb);
- outptr += 4;
- }
- if (num_cols & 1) {
- g = *inptr;
- g = range_limit[DITHER_565_R(g, d0)];
- rgb = PACK_SHORT_565(g, g, g);
- *(INT16 *)outptr = (INT16)rgb;
- }
- }
-}
diff --git a/contrib/libs/libjpeg-turbo/jdcolext.c b/contrib/libs/libjpeg-turbo/jdcolext.c
deleted file mode 100644
index 863c7a2fbc..0000000000
--- a/contrib/libs/libjpeg-turbo/jdcolext.c
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * jdcolext.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2009, 2011, 2015, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains output colorspace conversion routines.
- */
-
-
-/* This file is included by jdcolor.c */
-
-
-/*
- * Convert some rows of samples to the output colorspace.
- *
- * Note that we change from noninterleaved, one-plane-per-component format
- * to interleaved-pixel format. The output buffer is therefore three times
- * as wide as the input buffer.
- * A starting row offset is provided only for the input buffer. The caller
- * can easily adjust the passed output_buf value to accommodate any row
- * offset required on that side.
- */
-
-INLINE
-LOCAL(void)
-ycc_rgb_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf,
- int num_rows)
-{
- my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
- register int y, cb, cr;
- register JSAMPROW outptr;
- register JSAMPROW inptr0, inptr1, inptr2;
- register JDIMENSION col;
- JDIMENSION num_cols = cinfo->output_width;
- /* copy these pointers into registers if possible */
- register JSAMPLE *range_limit = cinfo->sample_range_limit;
- register int *Crrtab = cconvert->Cr_r_tab;
- register int *Cbbtab = cconvert->Cb_b_tab;
- register JLONG *Crgtab = cconvert->Cr_g_tab;
- register JLONG *Cbgtab = cconvert->Cb_g_tab;
- SHIFT_TEMPS
-
- while (--num_rows >= 0) {
- inptr0 = input_buf[0][input_row];
- inptr1 = input_buf[1][input_row];
- inptr2 = input_buf[2][input_row];
- input_row++;
- outptr = *output_buf++;
- for (col = 0; col < num_cols; col++) {
- y = inptr0[col];
- cb = inptr1[col];
- cr = inptr2[col];
- /* Range-limiting is essential due to noise introduced by DCT losses. */
- outptr[RGB_RED] = range_limit[y + Crrtab[cr]];
- outptr[RGB_GREEN] = range_limit[y +
- ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
- SCALEBITS))];
- outptr[RGB_BLUE] = range_limit[y + Cbbtab[cb]];
- /* Set unused byte to 0xFF so it can be interpreted as an opaque */
- /* alpha channel value */
-#ifdef RGB_ALPHA
- outptr[RGB_ALPHA] = 0xFF;
-#endif
- outptr += RGB_PIXELSIZE;
- }
- }
-}
-
-
-/*
- * Convert grayscale to RGB: just duplicate the graylevel three times.
- * This is provided to support applications that don't want to cope
- * with grayscale as a separate case.
- */
-
-INLINE
-LOCAL(void)
-gray_rgb_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf,
- int num_rows)
-{
- register JSAMPROW inptr, outptr;
- register JDIMENSION col;
- JDIMENSION num_cols = cinfo->output_width;
-
- while (--num_rows >= 0) {
- inptr = input_buf[0][input_row++];
- outptr = *output_buf++;
- for (col = 0; col < num_cols; col++) {
- outptr[RGB_RED] = outptr[RGB_GREEN] = outptr[RGB_BLUE] = inptr[col];
- /* Set unused byte to 0xFF so it can be interpreted as an opaque */
- /* alpha channel value */
-#ifdef RGB_ALPHA
- outptr[RGB_ALPHA] = 0xFF;
-#endif
- outptr += RGB_PIXELSIZE;
- }
- }
-}
-
-
-/*
- * Convert RGB to extended RGB: just swap the order of source pixels
- */
-
-INLINE
-LOCAL(void)
-rgb_rgb_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf,
- int num_rows)
-{
- register JSAMPROW inptr0, inptr1, inptr2;
- register JSAMPROW outptr;
- register JDIMENSION col;
- JDIMENSION num_cols = cinfo->output_width;
-
- while (--num_rows >= 0) {
- inptr0 = input_buf[0][input_row];
- inptr1 = input_buf[1][input_row];
- inptr2 = input_buf[2][input_row];
- input_row++;
- outptr = *output_buf++;
- for (col = 0; col < num_cols; col++) {
- outptr[RGB_RED] = inptr0[col];
- outptr[RGB_GREEN] = inptr1[col];
- outptr[RGB_BLUE] = inptr2[col];
- /* Set unused byte to 0xFF so it can be interpreted as an opaque */
- /* alpha channel value */
-#ifdef RGB_ALPHA
- outptr[RGB_ALPHA] = 0xFF;
-#endif
- outptr += RGB_PIXELSIZE;
- }
- }
-}
diff --git a/contrib/libs/libjpeg-turbo/jdcolor.c b/contrib/libs/libjpeg-turbo/jdcolor.c
deleted file mode 100644
index 8da2b4eaf2..0000000000
--- a/contrib/libs/libjpeg-turbo/jdcolor.c
+++ /dev/null
@@ -1,882 +0,0 @@
-/*
- * jdcolor.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * Modified 2011 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- * Copyright (C) 2009, 2011-2012, 2014-2015, D. R. Commander.
- * Copyright (C) 2013, Linaro Limited.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains output colorspace conversion routines.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-#include "jsimd.h"
-#include "jconfigint.h"
-
-
-/* Private subobject */
-
-typedef struct {
- struct jpeg_color_deconverter pub; /* public fields */
-
- /* Private state for YCC->RGB conversion */
- int *Cr_r_tab; /* => table for Cr to R conversion */
- int *Cb_b_tab; /* => table for Cb to B conversion */
- JLONG *Cr_g_tab; /* => table for Cr to G conversion */
- JLONG *Cb_g_tab; /* => table for Cb to G conversion */
-
- /* Private state for RGB->Y conversion */
- JLONG *rgb_y_tab; /* => table for RGB to Y conversion */
-} my_color_deconverter;
-
-typedef my_color_deconverter *my_cconvert_ptr;
-
-
-/**************** YCbCr -> RGB conversion: most common case **************/
-/**************** RGB -> Y conversion: less common case **************/
-
-/*
- * YCbCr is defined per CCIR 601-1, except that Cb and Cr are
- * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5.
- * The conversion equations to be implemented are therefore
- *
- * R = Y + 1.40200 * Cr
- * G = Y - 0.34414 * Cb - 0.71414 * Cr
- * B = Y + 1.77200 * Cb
- *
- * Y = 0.29900 * R + 0.58700 * G + 0.11400 * B
- *
- * where Cb and Cr represent the incoming values less CENTERJSAMPLE.
- * (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.)
- *
- * To avoid floating-point arithmetic, we represent the fractional constants
- * as integers scaled up by 2^16 (about 4 digits precision); we have to divide
- * the products by 2^16, with appropriate rounding, to get the correct answer.
- * Notice that Y, being an integral input, does not contribute any fraction
- * so it need not participate in the rounding.
- *
- * For even more speed, we avoid doing any multiplications in the inner loop
- * by precalculating the constants times Cb and Cr for all possible values.
- * For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table);
- * for 12-bit samples it is still acceptable. It's not very reasonable for
- * 16-bit samples, but if you want lossless storage you shouldn't be changing
- * colorspace anyway.
- * The Cr=>R and Cb=>B values can be rounded to integers in advance; the
- * values for the G calculation are left scaled up, since we must add them
- * together before rounding.
- */
-
-#define SCALEBITS 16 /* speediest right-shift on some machines */
-#define ONE_HALF ((JLONG)1 << (SCALEBITS - 1))
-#define FIX(x) ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
-
-/* We allocate one big table for RGB->Y conversion and divide it up into
- * three parts, instead of doing three alloc_small requests. This lets us
- * use a single table base address, which can be held in a register in the
- * inner loops on many machines (more than can hold all three addresses,
- * anyway).
- */
-
-#define R_Y_OFF 0 /* offset to R => Y section */
-#define G_Y_OFF (1 * (MAXJSAMPLE + 1)) /* offset to G => Y section */
-#define B_Y_OFF (2 * (MAXJSAMPLE + 1)) /* etc. */
-#define TABLE_SIZE (3 * (MAXJSAMPLE + 1))
-
-
-/* Include inline routines for colorspace extensions */
-
-#include "jdcolext.c"
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_PIXELSIZE
-
-#define RGB_RED EXT_RGB_RED
-#define RGB_GREEN EXT_RGB_GREEN
-#define RGB_BLUE EXT_RGB_BLUE
-#define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
-#define ycc_rgb_convert_internal ycc_extrgb_convert_internal
-#define gray_rgb_convert_internal gray_extrgb_convert_internal
-#define rgb_rgb_convert_internal rgb_extrgb_convert_internal
-#include "jdcolext.c"
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_PIXELSIZE
-#undef ycc_rgb_convert_internal
-#undef gray_rgb_convert_internal
-#undef rgb_rgb_convert_internal
-
-#define RGB_RED EXT_RGBX_RED
-#define RGB_GREEN EXT_RGBX_GREEN
-#define RGB_BLUE EXT_RGBX_BLUE
-#define RGB_ALPHA 3
-#define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
-#define ycc_rgb_convert_internal ycc_extrgbx_convert_internal
-#define gray_rgb_convert_internal gray_extrgbx_convert_internal
-#define rgb_rgb_convert_internal rgb_extrgbx_convert_internal
-#include "jdcolext.c"
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_ALPHA
-#undef RGB_PIXELSIZE
-#undef ycc_rgb_convert_internal
-#undef gray_rgb_convert_internal
-#undef rgb_rgb_convert_internal
-
-#define RGB_RED EXT_BGR_RED
-#define RGB_GREEN EXT_BGR_GREEN
-#define RGB_BLUE EXT_BGR_BLUE
-#define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
-#define ycc_rgb_convert_internal ycc_extbgr_convert_internal
-#define gray_rgb_convert_internal gray_extbgr_convert_internal
-#define rgb_rgb_convert_internal rgb_extbgr_convert_internal
-#include "jdcolext.c"
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_PIXELSIZE
-#undef ycc_rgb_convert_internal
-#undef gray_rgb_convert_internal
-#undef rgb_rgb_convert_internal
-
-#define RGB_RED EXT_BGRX_RED
-#define RGB_GREEN EXT_BGRX_GREEN
-#define RGB_BLUE EXT_BGRX_BLUE
-#define RGB_ALPHA 3
-#define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
-#define ycc_rgb_convert_internal ycc_extbgrx_convert_internal
-#define gray_rgb_convert_internal gray_extbgrx_convert_internal
-#define rgb_rgb_convert_internal rgb_extbgrx_convert_internal
-#include "jdcolext.c"
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_ALPHA
-#undef RGB_PIXELSIZE
-#undef ycc_rgb_convert_internal
-#undef gray_rgb_convert_internal
-#undef rgb_rgb_convert_internal
-
-#define RGB_RED EXT_XBGR_RED
-#define RGB_GREEN EXT_XBGR_GREEN
-#define RGB_BLUE EXT_XBGR_BLUE
-#define RGB_ALPHA 0
-#define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
-#define ycc_rgb_convert_internal ycc_extxbgr_convert_internal
-#define gray_rgb_convert_internal gray_extxbgr_convert_internal
-#define rgb_rgb_convert_internal rgb_extxbgr_convert_internal
-#include "jdcolext.c"
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_ALPHA
-#undef RGB_PIXELSIZE
-#undef ycc_rgb_convert_internal
-#undef gray_rgb_convert_internal
-#undef rgb_rgb_convert_internal
-
-#define RGB_RED EXT_XRGB_RED
-#define RGB_GREEN EXT_XRGB_GREEN
-#define RGB_BLUE EXT_XRGB_BLUE
-#define RGB_ALPHA 0
-#define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
-#define ycc_rgb_convert_internal ycc_extxrgb_convert_internal
-#define gray_rgb_convert_internal gray_extxrgb_convert_internal
-#define rgb_rgb_convert_internal rgb_extxrgb_convert_internal
-#include "jdcolext.c"
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_ALPHA
-#undef RGB_PIXELSIZE
-#undef ycc_rgb_convert_internal
-#undef gray_rgb_convert_internal
-#undef rgb_rgb_convert_internal
-
-
-/*
- * Initialize tables for YCC->RGB colorspace conversion.
- */
-
-LOCAL(void)
-build_ycc_rgb_table(j_decompress_ptr cinfo)
-{
- my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
- int i;
- JLONG x;
- SHIFT_TEMPS
-
- cconvert->Cr_r_tab = (int *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- (MAXJSAMPLE + 1) * sizeof(int));
- cconvert->Cb_b_tab = (int *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- (MAXJSAMPLE + 1) * sizeof(int));
- cconvert->Cr_g_tab = (JLONG *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- (MAXJSAMPLE + 1) * sizeof(JLONG));
- cconvert->Cb_g_tab = (JLONG *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- (MAXJSAMPLE + 1) * sizeof(JLONG));
-
- for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) {
- /* i is the actual input pixel value, in the range 0..MAXJSAMPLE */
- /* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */
- /* Cr=>R value is nearest int to 1.40200 * x */
- cconvert->Cr_r_tab[i] = (int)
- RIGHT_SHIFT(FIX(1.40200) * x + ONE_HALF, SCALEBITS);
- /* Cb=>B value is nearest int to 1.77200 * x */
- cconvert->Cb_b_tab[i] = (int)
- RIGHT_SHIFT(FIX(1.77200) * x + ONE_HALF, SCALEBITS);
- /* Cr=>G value is scaled-up -0.71414 * x */
- cconvert->Cr_g_tab[i] = (-FIX(0.71414)) * x;
- /* Cb=>G value is scaled-up -0.34414 * x */
- /* We also add in ONE_HALF so that need not do it in inner loop */
- cconvert->Cb_g_tab[i] = (-FIX(0.34414)) * x + ONE_HALF;
- }
-}
-
-
-/*
- * Convert some rows of samples to the output colorspace.
- */
-
-METHODDEF(void)
-ycc_rgb_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
-{
- switch (cinfo->out_color_space) {
- case JCS_EXT_RGB:
- ycc_extrgb_convert_internal(cinfo, input_buf, input_row, output_buf,
- num_rows);
- break;
- case JCS_EXT_RGBX:
- case JCS_EXT_RGBA:
- ycc_extrgbx_convert_internal(cinfo, input_buf, input_row, output_buf,
- num_rows);
- break;
- case JCS_EXT_BGR:
- ycc_extbgr_convert_internal(cinfo, input_buf, input_row, output_buf,
- num_rows);
- break;
- case JCS_EXT_BGRX:
- case JCS_EXT_BGRA:
- ycc_extbgrx_convert_internal(cinfo, input_buf, input_row, output_buf,
- num_rows);
- break;
- case JCS_EXT_XBGR:
- case JCS_EXT_ABGR:
- ycc_extxbgr_convert_internal(cinfo, input_buf, input_row, output_buf,
- num_rows);
- break;
- case JCS_EXT_XRGB:
- case JCS_EXT_ARGB:
- ycc_extxrgb_convert_internal(cinfo, input_buf, input_row, output_buf,
- num_rows);
- break;
- default:
- ycc_rgb_convert_internal(cinfo, input_buf, input_row, output_buf,
- num_rows);
- break;
- }
-}
-
-
-/**************** Cases other than YCbCr -> RGB **************/
-
-
-/*
- * Initialize for RGB->grayscale colorspace conversion.
- */
-
-LOCAL(void)
-build_rgb_y_table(j_decompress_ptr cinfo)
-{
- my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
- JLONG *rgb_y_tab;
- JLONG i;
-
- /* Allocate and fill in the conversion tables. */
- cconvert->rgb_y_tab = rgb_y_tab = (JLONG *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- (TABLE_SIZE * sizeof(JLONG)));
-
- for (i = 0; i <= MAXJSAMPLE; i++) {
- rgb_y_tab[i + R_Y_OFF] = FIX(0.29900) * i;
- rgb_y_tab[i + G_Y_OFF] = FIX(0.58700) * i;
- rgb_y_tab[i + B_Y_OFF] = FIX(0.11400) * i + ONE_HALF;
- }
-}
-
-
-/*
- * Convert RGB to grayscale.
- */
-
-METHODDEF(void)
-rgb_gray_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
-{
- my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
- register int r, g, b;
- register JLONG *ctab = cconvert->rgb_y_tab;
- register JSAMPROW outptr;
- register JSAMPROW inptr0, inptr1, inptr2;
- register JDIMENSION col;
- JDIMENSION num_cols = cinfo->output_width;
-
- while (--num_rows >= 0) {
- inptr0 = input_buf[0][input_row];
- inptr1 = input_buf[1][input_row];
- inptr2 = input_buf[2][input_row];
- input_row++;
- outptr = *output_buf++;
- for (col = 0; col < num_cols; col++) {
- r = inptr0[col];
- g = inptr1[col];
- b = inptr2[col];
- /* Y */
- outptr[col] = (JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
- ctab[b + B_Y_OFF]) >> SCALEBITS);
- }
- }
-}
-
-
-/*
- * Color conversion for no colorspace change: just copy the data,
- * converting from separate-planes to interleaved representation.
- */
-
-METHODDEF(void)
-null_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
-{
- register JSAMPROW inptr, inptr0, inptr1, inptr2, inptr3, outptr;
- register JDIMENSION col;
- register int num_components = cinfo->num_components;
- JDIMENSION num_cols = cinfo->output_width;
- int ci;
-
- if (num_components == 3) {
- while (--num_rows >= 0) {
- inptr0 = input_buf[0][input_row];
- inptr1 = input_buf[1][input_row];
- inptr2 = input_buf[2][input_row];
- input_row++;
- outptr = *output_buf++;
- for (col = 0; col < num_cols; col++) {
- *outptr++ = inptr0[col];
- *outptr++ = inptr1[col];
- *outptr++ = inptr2[col];
- }
- }
- } else if (num_components == 4) {
- while (--num_rows >= 0) {
- inptr0 = input_buf[0][input_row];
- inptr1 = input_buf[1][input_row];
- inptr2 = input_buf[2][input_row];
- inptr3 = input_buf[3][input_row];
- input_row++;
- outptr = *output_buf++;
- for (col = 0; col < num_cols; col++) {
- *outptr++ = inptr0[col];
- *outptr++ = inptr1[col];
- *outptr++ = inptr2[col];
- *outptr++ = inptr3[col];
- }
- }
- } else {
- while (--num_rows >= 0) {
- for (ci = 0; ci < num_components; ci++) {
- inptr = input_buf[ci][input_row];
- outptr = *output_buf;
- for (col = 0; col < num_cols; col++) {
- outptr[ci] = inptr[col];
- outptr += num_components;
- }
- }
- output_buf++;
- input_row++;
- }
- }
-}
-
-
-/*
- * Color conversion for grayscale: just copy the data.
- * This also works for YCbCr -> grayscale conversion, in which
- * we just copy the Y (luminance) component and ignore chrominance.
- */
-
-METHODDEF(void)
-grayscale_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
-{
- jcopy_sample_rows(input_buf[0], (int)input_row, output_buf, 0, num_rows,
- cinfo->output_width);
-}
-
-
-/*
- * Convert grayscale to RGB
- */
-
-METHODDEF(void)
-gray_rgb_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
-{
- switch (cinfo->out_color_space) {
- case JCS_EXT_RGB:
- gray_extrgb_convert_internal(cinfo, input_buf, input_row, output_buf,
- num_rows);
- break;
- case JCS_EXT_RGBX:
- case JCS_EXT_RGBA:
- gray_extrgbx_convert_internal(cinfo, input_buf, input_row, output_buf,
- num_rows);
- break;
- case JCS_EXT_BGR:
- gray_extbgr_convert_internal(cinfo, input_buf, input_row, output_buf,
- num_rows);
- break;
- case JCS_EXT_BGRX:
- case JCS_EXT_BGRA:
- gray_extbgrx_convert_internal(cinfo, input_buf, input_row, output_buf,
- num_rows);
- break;
- case JCS_EXT_XBGR:
- case JCS_EXT_ABGR:
- gray_extxbgr_convert_internal(cinfo, input_buf, input_row, output_buf,
- num_rows);
- break;
- case JCS_EXT_XRGB:
- case JCS_EXT_ARGB:
- gray_extxrgb_convert_internal(cinfo, input_buf, input_row, output_buf,
- num_rows);
- break;
- default:
- gray_rgb_convert_internal(cinfo, input_buf, input_row, output_buf,
- num_rows);
- break;
- }
-}
-
-
-/*
- * Convert plain RGB to extended RGB
- */
-
-METHODDEF(void)
-rgb_rgb_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
-{
- switch (cinfo->out_color_space) {
- case JCS_EXT_RGB:
- rgb_extrgb_convert_internal(cinfo, input_buf, input_row, output_buf,
- num_rows);
- break;
- case JCS_EXT_RGBX:
- case JCS_EXT_RGBA:
- rgb_extrgbx_convert_internal(cinfo, input_buf, input_row, output_buf,
- num_rows);
- break;
- case JCS_EXT_BGR:
- rgb_extbgr_convert_internal(cinfo, input_buf, input_row, output_buf,
- num_rows);
- break;
- case JCS_EXT_BGRX:
- case JCS_EXT_BGRA:
- rgb_extbgrx_convert_internal(cinfo, input_buf, input_row, output_buf,
- num_rows);
- break;
- case JCS_EXT_XBGR:
- case JCS_EXT_ABGR:
- rgb_extxbgr_convert_internal(cinfo, input_buf, input_row, output_buf,
- num_rows);
- break;
- case JCS_EXT_XRGB:
- case JCS_EXT_ARGB:
- rgb_extxrgb_convert_internal(cinfo, input_buf, input_row, output_buf,
- num_rows);
- break;
- default:
- rgb_rgb_convert_internal(cinfo, input_buf, input_row, output_buf,
- num_rows);
- break;
- }
-}
-
-
-/*
- * Adobe-style YCCK->CMYK conversion.
- * We convert YCbCr to R=1-C, G=1-M, and B=1-Y using the same
- * conversion as above, while passing K (black) unchanged.
- * We assume build_ycc_rgb_table has been called.
- */
-
-METHODDEF(void)
-ycck_cmyk_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
-{
- my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
- register int y, cb, cr;
- register JSAMPROW outptr;
- register JSAMPROW inptr0, inptr1, inptr2, inptr3;
- register JDIMENSION col;
- JDIMENSION num_cols = cinfo->output_width;
- /* copy these pointers into registers if possible */
- register JSAMPLE *range_limit = cinfo->sample_range_limit;
- register int *Crrtab = cconvert->Cr_r_tab;
- register int *Cbbtab = cconvert->Cb_b_tab;
- register JLONG *Crgtab = cconvert->Cr_g_tab;
- register JLONG *Cbgtab = cconvert->Cb_g_tab;
- SHIFT_TEMPS
-
- while (--num_rows >= 0) {
- inptr0 = input_buf[0][input_row];
- inptr1 = input_buf[1][input_row];
- inptr2 = input_buf[2][input_row];
- inptr3 = input_buf[3][input_row];
- input_row++;
- outptr = *output_buf++;
- for (col = 0; col < num_cols; col++) {
- y = inptr0[col];
- cb = inptr1[col];
- cr = inptr2[col];
- /* Range-limiting is essential due to noise introduced by DCT losses. */
- outptr[0] = range_limit[MAXJSAMPLE - (y + Crrtab[cr])]; /* red */
- outptr[1] = range_limit[MAXJSAMPLE - (y + /* green */
- ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
- SCALEBITS)))];
- outptr[2] = range_limit[MAXJSAMPLE - (y + Cbbtab[cb])]; /* blue */
- /* K passes through unchanged */
- outptr[3] = inptr3[col];
- outptr += 4;
- }
- }
-}
-
-
-/*
- * RGB565 conversion
- */
-
-#define PACK_SHORT_565_LE(r, g, b) \
- ((((r) << 8) & 0xF800) | (((g) << 3) & 0x7E0) | ((b) >> 3))
-#define PACK_SHORT_565_BE(r, g, b) \
- (((r) & 0xF8) | ((g) >> 5) | (((g) << 11) & 0xE000) | (((b) << 5) & 0x1F00))
-
-#define PACK_TWO_PIXELS_LE(l, r) ((r << 16) | l)
-#define PACK_TWO_PIXELS_BE(l, r) ((l << 16) | r)
-
-#define PACK_NEED_ALIGNMENT(ptr) (((size_t)(ptr)) & 3)
-
-#define WRITE_TWO_ALIGNED_PIXELS(addr, pixels) ((*(int *)(addr)) = pixels)
-
-#define DITHER_565_R(r, dither) ((r) + ((dither) & 0xFF))
-#define DITHER_565_G(g, dither) ((g) + (((dither) & 0xFF) >> 1))
-#define DITHER_565_B(b, dither) ((b) + ((dither) & 0xFF))
-
-
-/* Declarations for ordered dithering
- *
- * We use a 4x4 ordered dither array packed into 32 bits. This array is
- * sufficient for dithering RGB888 to RGB565.
- */
-
-#define DITHER_MASK 0x3
-#define DITHER_ROTATE(x) ((((x) & 0xFF) << 24) | (((x) >> 8) & 0x00FFFFFF))
-static const JLONG dither_matrix[4] = {
- 0x0008020A,
- 0x0C040E06,
- 0x030B0109,
- 0x0F070D05
-};
-
-
-static INLINE boolean is_big_endian(void)
-{
- int test_value = 1;
- if (*(char *)&test_value != 1)
- return TRUE;
- return FALSE;
-}
-
-
-/* Include inline routines for RGB565 conversion */
-
-#define PACK_SHORT_565 PACK_SHORT_565_LE
-#define PACK_TWO_PIXELS PACK_TWO_PIXELS_LE
-#define ycc_rgb565_convert_internal ycc_rgb565_convert_le
-#define ycc_rgb565D_convert_internal ycc_rgb565D_convert_le
-#define rgb_rgb565_convert_internal rgb_rgb565_convert_le
-#define rgb_rgb565D_convert_internal rgb_rgb565D_convert_le
-#define gray_rgb565_convert_internal gray_rgb565_convert_le
-#define gray_rgb565D_convert_internal gray_rgb565D_convert_le
-#include "jdcol565.c"
-#undef PACK_SHORT_565
-#undef PACK_TWO_PIXELS
-#undef ycc_rgb565_convert_internal
-#undef ycc_rgb565D_convert_internal
-#undef rgb_rgb565_convert_internal
-#undef rgb_rgb565D_convert_internal
-#undef gray_rgb565_convert_internal
-#undef gray_rgb565D_convert_internal
-
-#define PACK_SHORT_565 PACK_SHORT_565_BE
-#define PACK_TWO_PIXELS PACK_TWO_PIXELS_BE
-#define ycc_rgb565_convert_internal ycc_rgb565_convert_be
-#define ycc_rgb565D_convert_internal ycc_rgb565D_convert_be
-#define rgb_rgb565_convert_internal rgb_rgb565_convert_be
-#define rgb_rgb565D_convert_internal rgb_rgb565D_convert_be
-#define gray_rgb565_convert_internal gray_rgb565_convert_be
-#define gray_rgb565D_convert_internal gray_rgb565D_convert_be
-#include "jdcol565.c"
-#undef PACK_SHORT_565
-#undef PACK_TWO_PIXELS
-#undef ycc_rgb565_convert_internal
-#undef ycc_rgb565D_convert_internal
-#undef rgb_rgb565_convert_internal
-#undef rgb_rgb565D_convert_internal
-#undef gray_rgb565_convert_internal
-#undef gray_rgb565D_convert_internal
-
-
-METHODDEF(void)
-ycc_rgb565_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
-{
- if (is_big_endian())
- ycc_rgb565_convert_be(cinfo, input_buf, input_row, output_buf, num_rows);
- else
- ycc_rgb565_convert_le(cinfo, input_buf, input_row, output_buf, num_rows);
-}
-
-
-METHODDEF(void)
-ycc_rgb565D_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
-{
- if (is_big_endian())
- ycc_rgb565D_convert_be(cinfo, input_buf, input_row, output_buf, num_rows);
- else
- ycc_rgb565D_convert_le(cinfo, input_buf, input_row, output_buf, num_rows);
-}
-
-
-METHODDEF(void)
-rgb_rgb565_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
-{
- if (is_big_endian())
- rgb_rgb565_convert_be(cinfo, input_buf, input_row, output_buf, num_rows);
- else
- rgb_rgb565_convert_le(cinfo, input_buf, input_row, output_buf, num_rows);
-}
-
-
-METHODDEF(void)
-rgb_rgb565D_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
-{
- if (is_big_endian())
- rgb_rgb565D_convert_be(cinfo, input_buf, input_row, output_buf, num_rows);
- else
- rgb_rgb565D_convert_le(cinfo, input_buf, input_row, output_buf, num_rows);
-}
-
-
-METHODDEF(void)
-gray_rgb565_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
-{
- if (is_big_endian())
- gray_rgb565_convert_be(cinfo, input_buf, input_row, output_buf, num_rows);
- else
- gray_rgb565_convert_le(cinfo, input_buf, input_row, output_buf, num_rows);
-}
-
-
-METHODDEF(void)
-gray_rgb565D_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
-{
- if (is_big_endian())
- gray_rgb565D_convert_be(cinfo, input_buf, input_row, output_buf, num_rows);
- else
- gray_rgb565D_convert_le(cinfo, input_buf, input_row, output_buf, num_rows);
-}
-
-
-/*
- * Empty method for start_pass.
- */
-
-METHODDEF(void)
-start_pass_dcolor(j_decompress_ptr cinfo)
-{
- /* no work needed */
-}
-
-
-/*
- * Module initialization routine for output colorspace conversion.
- */
-
-GLOBAL(void)
-jinit_color_deconverter(j_decompress_ptr cinfo)
-{
- my_cconvert_ptr cconvert;
- int ci;
-
- cconvert = (my_cconvert_ptr)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- sizeof(my_color_deconverter));
- cinfo->cconvert = (struct jpeg_color_deconverter *)cconvert;
- cconvert->pub.start_pass = start_pass_dcolor;
-
- /* Make sure num_components agrees with jpeg_color_space */
- switch (cinfo->jpeg_color_space) {
- case JCS_GRAYSCALE:
- if (cinfo->num_components != 1)
- ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
- break;
-
- case JCS_RGB:
- case JCS_YCbCr:
- if (cinfo->num_components != 3)
- ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
- break;
-
- case JCS_CMYK:
- case JCS_YCCK:
- if (cinfo->num_components != 4)
- ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
- break;
-
- default: /* JCS_UNKNOWN can be anything */
- if (cinfo->num_components < 1)
- ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
- break;
- }
-
- /* Set out_color_components and conversion method based on requested space.
- * Also clear the component_needed flags for any unused components,
- * so that earlier pipeline stages can avoid useless computation.
- */
-
- switch (cinfo->out_color_space) {
- case JCS_GRAYSCALE:
- cinfo->out_color_components = 1;
- if (cinfo->jpeg_color_space == JCS_GRAYSCALE ||
- cinfo->jpeg_color_space == JCS_YCbCr) {
- cconvert->pub.color_convert = grayscale_convert;
- /* For color->grayscale conversion, only the Y (0) component is needed */
- for (ci = 1; ci < cinfo->num_components; ci++)
- cinfo->comp_info[ci].component_needed = FALSE;
- } else if (cinfo->jpeg_color_space == JCS_RGB) {
- cconvert->pub.color_convert = rgb_gray_convert;
- build_rgb_y_table(cinfo);
- } else
- ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
- break;
-
- case JCS_RGB:
- case JCS_EXT_RGB:
- case JCS_EXT_RGBX:
- case JCS_EXT_BGR:
- case JCS_EXT_BGRX:
- case JCS_EXT_XBGR:
- case JCS_EXT_XRGB:
- case JCS_EXT_RGBA:
- case JCS_EXT_BGRA:
- case JCS_EXT_ABGR:
- case JCS_EXT_ARGB:
- cinfo->out_color_components = rgb_pixelsize[cinfo->out_color_space];
- if (cinfo->jpeg_color_space == JCS_YCbCr) {
- if (jsimd_can_ycc_rgb())
- cconvert->pub.color_convert = jsimd_ycc_rgb_convert;
- else {
- cconvert->pub.color_convert = ycc_rgb_convert;
- build_ycc_rgb_table(cinfo);
- }
- } else if (cinfo->jpeg_color_space == JCS_GRAYSCALE) {
- cconvert->pub.color_convert = gray_rgb_convert;
- } else if (cinfo->jpeg_color_space == JCS_RGB) {
- if (rgb_red[cinfo->out_color_space] == 0 &&
- rgb_green[cinfo->out_color_space] == 1 &&
- rgb_blue[cinfo->out_color_space] == 2 &&
- rgb_pixelsize[cinfo->out_color_space] == 3)
- cconvert->pub.color_convert = null_convert;
- else
- cconvert->pub.color_convert = rgb_rgb_convert;
- } else
- ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
- break;
-
- case JCS_RGB565:
- cinfo->out_color_components = 3;
- if (cinfo->dither_mode == JDITHER_NONE) {
- if (cinfo->jpeg_color_space == JCS_YCbCr) {
- if (jsimd_can_ycc_rgb565())
- cconvert->pub.color_convert = jsimd_ycc_rgb565_convert;
- else {
- cconvert->pub.color_convert = ycc_rgb565_convert;
- build_ycc_rgb_table(cinfo);
- }
- } else if (cinfo->jpeg_color_space == JCS_GRAYSCALE) {
- cconvert->pub.color_convert = gray_rgb565_convert;
- } else if (cinfo->jpeg_color_space == JCS_RGB) {
- cconvert->pub.color_convert = rgb_rgb565_convert;
- } else
- ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
- } else {
- /* only ordered dithering is supported */
- if (cinfo->jpeg_color_space == JCS_YCbCr) {
- cconvert->pub.color_convert = ycc_rgb565D_convert;
- build_ycc_rgb_table(cinfo);
- } else if (cinfo->jpeg_color_space == JCS_GRAYSCALE) {
- cconvert->pub.color_convert = gray_rgb565D_convert;
- } else if (cinfo->jpeg_color_space == JCS_RGB) {
- cconvert->pub.color_convert = rgb_rgb565D_convert;
- } else
- ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
- }
- break;
-
- case JCS_CMYK:
- cinfo->out_color_components = 4;
- if (cinfo->jpeg_color_space == JCS_YCCK) {
- cconvert->pub.color_convert = ycck_cmyk_convert;
- build_ycc_rgb_table(cinfo);
- } else if (cinfo->jpeg_color_space == JCS_CMYK) {
- cconvert->pub.color_convert = null_convert;
- } else
- ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
- break;
-
- default:
- /* Permit null conversion to same output space */
- if (cinfo->out_color_space == cinfo->jpeg_color_space) {
- cinfo->out_color_components = cinfo->num_components;
- cconvert->pub.color_convert = null_convert;
- } else /* unsupported non-null conversion */
- ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
- break;
- }
-
- if (cinfo->quantize_colors)
- cinfo->output_components = 1; /* single colormapped output component */
- else
- cinfo->output_components = cinfo->out_color_components;
-}
diff --git a/contrib/libs/libjpeg-turbo/jdct.h b/contrib/libs/libjpeg-turbo/jdct.h
deleted file mode 100644
index 66d1718b77..0000000000
--- a/contrib/libs/libjpeg-turbo/jdct.h
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * jdct.h
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2015, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This include file contains common declarations for the forward and
- * inverse DCT modules. These declarations are private to the DCT managers
- * (jcdctmgr.c, jddctmgr.c) and the individual DCT algorithms.
- * The individual DCT algorithms are kept in separate files to ease
- * machine-dependent tuning (e.g., assembly coding).
- */
-
-
-/*
- * A forward DCT routine is given a pointer to a work area of type DCTELEM[];
- * the DCT is to be performed in-place in that buffer. Type DCTELEM is int
- * for 8-bit samples, JLONG for 12-bit samples. (NOTE: Floating-point DCT
- * implementations use an array of type FAST_FLOAT, instead.)
- * The DCT inputs are expected to be signed (range +-CENTERJSAMPLE).
- * The DCT outputs are returned scaled up by a factor of 8; they therefore
- * have a range of +-8K for 8-bit data, +-128K for 12-bit data. This
- * convention improves accuracy in integer implementations and saves some
- * work in floating-point ones.
- * Quantization of the output coefficients is done by jcdctmgr.c. This
- * step requires an unsigned type and also one with twice the bits.
- */
-
-#if BITS_IN_JSAMPLE == 8
-#ifndef WITH_SIMD
-typedef int DCTELEM; /* 16 or 32 bits is fine */
-typedef unsigned int UDCTELEM;
-typedef unsigned long long UDCTELEM2;
-#else
-typedef short DCTELEM; /* prefer 16 bit with SIMD for parellelism */
-typedef unsigned short UDCTELEM;
-typedef unsigned int UDCTELEM2;
-#endif
-#else
-typedef JLONG DCTELEM; /* must have 32 bits */
-typedef unsigned long long UDCTELEM2;
-#endif
-
-
-/*
- * An inverse DCT routine is given a pointer to the input JBLOCK and a pointer
- * to an output sample array. The routine must dequantize the input data as
- * well as perform the IDCT; for dequantization, it uses the multiplier table
- * pointed to by compptr->dct_table. The output data is to be placed into the
- * sample array starting at a specified column. (Any row offset needed will
- * be applied to the array pointer before it is passed to the IDCT code.)
- * Note that the number of samples emitted by the IDCT routine is
- * DCT_scaled_size * DCT_scaled_size.
- */
-
-/* typedef inverse_DCT_method_ptr is declared in jpegint.h */
-
-/*
- * Each IDCT routine has its own ideas about the best dct_table element type.
- */
-
-typedef MULTIPLIER ISLOW_MULT_TYPE; /* short or int, whichever is faster */
-#if BITS_IN_JSAMPLE == 8
-typedef MULTIPLIER IFAST_MULT_TYPE; /* 16 bits is OK, use short if faster */
-#define IFAST_SCALE_BITS 2 /* fractional bits in scale factors */
-#else
-typedef JLONG IFAST_MULT_TYPE; /* need 32 bits for scaled quantizers */
-#define IFAST_SCALE_BITS 13 /* fractional bits in scale factors */
-#endif
-typedef FAST_FLOAT FLOAT_MULT_TYPE; /* preferred floating type */
-
-
-/*
- * Each IDCT routine is responsible for range-limiting its results and
- * converting them to unsigned form (0..MAXJSAMPLE). The raw outputs could
- * be quite far out of range if the input data is corrupt, so a bulletproof
- * range-limiting step is required. We use a mask-and-table-lookup method
- * to do the combined operations quickly. See the comments with
- * prepare_range_limit_table (in jdmaster.c) for more info.
- */
-
-#define IDCT_range_limit(cinfo) ((cinfo)->sample_range_limit + CENTERJSAMPLE)
-
-#define RANGE_MASK (MAXJSAMPLE * 4 + 3) /* 2 bits wider than legal samples */
-
-
-/* Extern declarations for the forward and inverse DCT routines. */
-
-EXTERN(void) jpeg_fdct_islow(DCTELEM *data);
-EXTERN(void) jpeg_fdct_ifast(DCTELEM *data);
-EXTERN(void) jpeg_fdct_float(FAST_FLOAT *data);
-
-EXTERN(void) jpeg_idct_islow(j_decompress_ptr cinfo,
- jpeg_component_info *compptr, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col);
-EXTERN(void) jpeg_idct_ifast(j_decompress_ptr cinfo,
- jpeg_component_info *compptr, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col);
-EXTERN(void) jpeg_idct_float(j_decompress_ptr cinfo,
- jpeg_component_info *compptr, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col);
-EXTERN(void) jpeg_idct_7x7(j_decompress_ptr cinfo,
- jpeg_component_info *compptr, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col);
-EXTERN(void) jpeg_idct_6x6(j_decompress_ptr cinfo,
- jpeg_component_info *compptr, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col);
-EXTERN(void) jpeg_idct_5x5(j_decompress_ptr cinfo,
- jpeg_component_info *compptr, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col);
-EXTERN(void) jpeg_idct_4x4(j_decompress_ptr cinfo,
- jpeg_component_info *compptr, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col);
-EXTERN(void) jpeg_idct_3x3(j_decompress_ptr cinfo,
- jpeg_component_info *compptr, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col);
-EXTERN(void) jpeg_idct_2x2(j_decompress_ptr cinfo,
- jpeg_component_info *compptr, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col);
-EXTERN(void) jpeg_idct_1x1(j_decompress_ptr cinfo,
- jpeg_component_info *compptr, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col);
-EXTERN(void) jpeg_idct_9x9(j_decompress_ptr cinfo,
- jpeg_component_info *compptr, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col);
-EXTERN(void) jpeg_idct_10x10(j_decompress_ptr cinfo,
- jpeg_component_info *compptr, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col);
-EXTERN(void) jpeg_idct_11x11(j_decompress_ptr cinfo,
- jpeg_component_info *compptr, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col);
-EXTERN(void) jpeg_idct_12x12(j_decompress_ptr cinfo,
- jpeg_component_info *compptr, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col);
-EXTERN(void) jpeg_idct_13x13(j_decompress_ptr cinfo,
- jpeg_component_info *compptr, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col);
-EXTERN(void) jpeg_idct_14x14(j_decompress_ptr cinfo,
- jpeg_component_info *compptr, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col);
-EXTERN(void) jpeg_idct_15x15(j_decompress_ptr cinfo,
- jpeg_component_info *compptr, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col);
-EXTERN(void) jpeg_idct_16x16(j_decompress_ptr cinfo,
- jpeg_component_info *compptr, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col);
-
-
-/*
- * Macros for handling fixed-point arithmetic; these are used by many
- * but not all of the DCT/IDCT modules.
- *
- * All values are expected to be of type JLONG.
- * Fractional constants are scaled left by CONST_BITS bits.
- * CONST_BITS is defined within each module using these macros,
- * and may differ from one module to the next.
- */
-
-#define ONE ((JLONG)1)
-#define CONST_SCALE (ONE << CONST_BITS)
-
-/* Convert a positive real constant to an integer scaled by CONST_SCALE.
- * Caution: some C compilers fail to reduce "FIX(constant)" at compile time,
- * thus causing a lot of useless floating-point operations at run time.
- */
-
-#define FIX(x) ((JLONG)((x) * CONST_SCALE + 0.5))
-
-/* Descale and correctly round a JLONG value that's scaled by N bits.
- * We assume RIGHT_SHIFT rounds towards minus infinity, so adding
- * the fudge factor is correct for either sign of X.
- */
-
-#define DESCALE(x, n) RIGHT_SHIFT((x) + (ONE << ((n) - 1)), n)
-
-/* Multiply a JLONG variable by a JLONG constant to yield a JLONG result.
- * This macro is used only when the two inputs will actually be no more than
- * 16 bits wide, so that a 16x16->32 bit multiply can be used instead of a
- * full 32x32 multiply. This provides a useful speedup on many machines.
- * Unfortunately there is no way to specify a 16x16->32 multiply portably
- * in C, but some C compilers will do the right thing if you provide the
- * correct combination of casts.
- */
-
-#ifdef SHORTxSHORT_32 /* may work if 'int' is 32 bits */
-#define MULTIPLY16C16(var, const) (((INT16)(var)) * ((INT16)(const)))
-#endif
-#ifdef SHORTxLCONST_32 /* known to work with Microsoft C 6.0 */
-#define MULTIPLY16C16(var, const) (((INT16)(var)) * ((JLONG)(const)))
-#endif
-
-#ifndef MULTIPLY16C16 /* default definition */
-#define MULTIPLY16C16(var, const) ((var) * (const))
-#endif
-
-/* Same except both inputs are variables. */
-
-#ifdef SHORTxSHORT_32 /* may work if 'int' is 32 bits */
-#define MULTIPLY16V16(var1, var2) (((INT16)(var1)) * ((INT16)(var2)))
-#endif
-
-#ifndef MULTIPLY16V16 /* default definition */
-#define MULTIPLY16V16(var1, var2) ((var1) * (var2))
-#endif
diff --git a/contrib/libs/libjpeg-turbo/jddctmgr.c b/contrib/libs/libjpeg-turbo/jddctmgr.c
deleted file mode 100644
index e78d7bebe2..0000000000
--- a/contrib/libs/libjpeg-turbo/jddctmgr.c
+++ /dev/null
@@ -1,352 +0,0 @@
-/*
- * jddctmgr.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * Modified 2002-2010 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- * Copyright (C) 2010, 2015, 2022, D. R. Commander.
- * Copyright (C) 2013, MIPS Technologies, Inc., California.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains the inverse-DCT management logic.
- * This code selects a particular IDCT implementation to be used,
- * and it performs related housekeeping chores. No code in this file
- * is executed per IDCT step, only during output pass setup.
- *
- * Note that the IDCT routines are responsible for performing coefficient
- * dequantization as well as the IDCT proper. This module sets up the
- * dequantization multiplier table needed by the IDCT routine.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-#include "jdct.h" /* Private declarations for DCT subsystem */
-#include "jsimddct.h"
-#include "jpegcomp.h"
-
-
-/*
- * The decompressor input side (jdinput.c) saves away the appropriate
- * quantization table for each component at the start of the first scan
- * involving that component. (This is necessary in order to correctly
- * decode files that reuse Q-table slots.)
- * When we are ready to make an output pass, the saved Q-table is converted
- * to a multiplier table that will actually be used by the IDCT routine.
- * The multiplier table contents are IDCT-method-dependent. To support
- * application changes in IDCT method between scans, we can remake the
- * multiplier tables if necessary.
- * In buffered-image mode, the first output pass may occur before any data
- * has been seen for some components, and thus before their Q-tables have
- * been saved away. To handle this case, multiplier tables are preset
- * to zeroes; the result of the IDCT will be a neutral gray level.
- */
-
-
-/* Private subobject for this module */
-
-typedef struct {
- struct jpeg_inverse_dct pub; /* public fields */
-
- /* This array contains the IDCT method code that each multiplier table
- * is currently set up for, or -1 if it's not yet set up.
- * The actual multiplier tables are pointed to by dct_table in the
- * per-component comp_info structures.
- */
- int cur_method[MAX_COMPONENTS];
-} my_idct_controller;
-
-typedef my_idct_controller *my_idct_ptr;
-
-
-/* Allocated multiplier tables: big enough for any supported variant */
-
-typedef union {
- ISLOW_MULT_TYPE islow_array[DCTSIZE2];
-#ifdef DCT_IFAST_SUPPORTED
- IFAST_MULT_TYPE ifast_array[DCTSIZE2];
-#endif
-#ifdef DCT_FLOAT_SUPPORTED
- FLOAT_MULT_TYPE float_array[DCTSIZE2];
-#endif
-} multiplier_table;
-
-
-/* The current scaled-IDCT routines require ISLOW-style multiplier tables,
- * so be sure to compile that code if either ISLOW or SCALING is requested.
- */
-#ifdef DCT_ISLOW_SUPPORTED
-#define PROVIDE_ISLOW_TABLES
-#else
-#ifdef IDCT_SCALING_SUPPORTED
-#define PROVIDE_ISLOW_TABLES
-#endif
-#endif
-
-
-/*
- * Prepare for an output pass.
- * Here we select the proper IDCT routine for each component and build
- * a matching multiplier table.
- */
-
-METHODDEF(void)
-start_pass(j_decompress_ptr cinfo)
-{
- my_idct_ptr idct = (my_idct_ptr)cinfo->idct;
- int ci, i;
- jpeg_component_info *compptr;
- int method = 0;
- inverse_DCT_method_ptr method_ptr = NULL;
- JQUANT_TBL *qtbl;
-
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
- ci++, compptr++) {
- /* Select the proper IDCT routine for this component's scaling */
- switch (compptr->_DCT_scaled_size) {
-#ifdef IDCT_SCALING_SUPPORTED
- case 1:
- method_ptr = jpeg_idct_1x1;
- method = JDCT_ISLOW; /* jidctred uses islow-style table */
- break;
- case 2:
- if (jsimd_can_idct_2x2())
- method_ptr = jsimd_idct_2x2;
- else
- method_ptr = jpeg_idct_2x2;
- method = JDCT_ISLOW; /* jidctred uses islow-style table */
- break;
- case 3:
- method_ptr = jpeg_idct_3x3;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
- break;
- case 4:
- if (jsimd_can_idct_4x4())
- method_ptr = jsimd_idct_4x4;
- else
- method_ptr = jpeg_idct_4x4;
- method = JDCT_ISLOW; /* jidctred uses islow-style table */
- break;
- case 5:
- method_ptr = jpeg_idct_5x5;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
- break;
- case 6:
-#if defined(__mips__)
- if (jsimd_can_idct_6x6())
- method_ptr = jsimd_idct_6x6;
- else
-#endif
- method_ptr = jpeg_idct_6x6;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
- break;
- case 7:
- method_ptr = jpeg_idct_7x7;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
- break;
-#endif
- case DCTSIZE:
- switch (cinfo->dct_method) {
-#ifdef DCT_ISLOW_SUPPORTED
- case JDCT_ISLOW:
- if (jsimd_can_idct_islow())
- method_ptr = jsimd_idct_islow;
- else
- method_ptr = jpeg_idct_islow;
- method = JDCT_ISLOW;
- break;
-#endif
-#ifdef DCT_IFAST_SUPPORTED
- case JDCT_IFAST:
- if (jsimd_can_idct_ifast())
- method_ptr = jsimd_idct_ifast;
- else
- method_ptr = jpeg_idct_ifast;
- method = JDCT_IFAST;
- break;
-#endif
-#ifdef DCT_FLOAT_SUPPORTED
- case JDCT_FLOAT:
- if (jsimd_can_idct_float())
- method_ptr = jsimd_idct_float;
- else
- method_ptr = jpeg_idct_float;
- method = JDCT_FLOAT;
- break;
-#endif
- default:
- ERREXIT(cinfo, JERR_NOT_COMPILED);
- break;
- }
- break;
-#ifdef IDCT_SCALING_SUPPORTED
- case 9:
- method_ptr = jpeg_idct_9x9;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
- break;
- case 10:
- method_ptr = jpeg_idct_10x10;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
- break;
- case 11:
- method_ptr = jpeg_idct_11x11;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
- break;
- case 12:
-#if defined(__mips__)
- if (jsimd_can_idct_12x12())
- method_ptr = jsimd_idct_12x12;
- else
-#endif
- method_ptr = jpeg_idct_12x12;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
- break;
- case 13:
- method_ptr = jpeg_idct_13x13;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
- break;
- case 14:
- method_ptr = jpeg_idct_14x14;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
- break;
- case 15:
- method_ptr = jpeg_idct_15x15;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
- break;
- case 16:
- method_ptr = jpeg_idct_16x16;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
- break;
-#endif
- default:
- ERREXIT1(cinfo, JERR_BAD_DCTSIZE, compptr->_DCT_scaled_size);
- break;
- }
- idct->pub.inverse_DCT[ci] = method_ptr;
- /* Create multiplier table from quant table.
- * However, we can skip this if the component is uninteresting
- * or if we already built the table. Also, if no quant table
- * has yet been saved for the component, we leave the
- * multiplier table all-zero; we'll be reading zeroes from the
- * coefficient controller's buffer anyway.
- */
- if (!compptr->component_needed || idct->cur_method[ci] == method)
- continue;
- qtbl = compptr->quant_table;
- if (qtbl == NULL) /* happens if no data yet for component */
- continue;
- idct->cur_method[ci] = method;
- switch (method) {
-#ifdef PROVIDE_ISLOW_TABLES
- case JDCT_ISLOW:
- {
- /* For LL&M IDCT method, multipliers are equal to raw quantization
- * coefficients, but are stored as ints to ensure access efficiency.
- */
- ISLOW_MULT_TYPE *ismtbl = (ISLOW_MULT_TYPE *)compptr->dct_table;
- for (i = 0; i < DCTSIZE2; i++) {
- ismtbl[i] = (ISLOW_MULT_TYPE)qtbl->quantval[i];
- }
- }
- break;
-#endif
-#ifdef DCT_IFAST_SUPPORTED
- case JDCT_IFAST:
- {
- /* For AA&N IDCT method, multipliers are equal to quantization
- * coefficients scaled by scalefactor[row]*scalefactor[col], where
- * scalefactor[0] = 1
- * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7
- * For integer operation, the multiplier table is to be scaled by
- * IFAST_SCALE_BITS.
- */
- IFAST_MULT_TYPE *ifmtbl = (IFAST_MULT_TYPE *)compptr->dct_table;
-#define CONST_BITS 14
- static const INT16 aanscales[DCTSIZE2] = {
- /* precomputed values scaled up by 14 bits */
- 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520,
- 22725, 31521, 29692, 26722, 22725, 17855, 12299, 6270,
- 21407, 29692, 27969, 25172, 21407, 16819, 11585, 5906,
- 19266, 26722, 25172, 22654, 19266, 15137, 10426, 5315,
- 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520,
- 12873, 17855, 16819, 15137, 12873, 10114, 6967, 3552,
- 8867, 12299, 11585, 10426, 8867, 6967, 4799, 2446,
- 4520, 6270, 5906, 5315, 4520, 3552, 2446, 1247
- };
- SHIFT_TEMPS
-
- for (i = 0; i < DCTSIZE2; i++) {
- ifmtbl[i] = (IFAST_MULT_TYPE)
- DESCALE(MULTIPLY16V16((JLONG)qtbl->quantval[i],
- (JLONG)aanscales[i]),
- CONST_BITS - IFAST_SCALE_BITS);
- }
- }
- break;
-#endif
-#ifdef DCT_FLOAT_SUPPORTED
- case JDCT_FLOAT:
- {
- /* For float AA&N IDCT method, multipliers are equal to quantization
- * coefficients scaled by scalefactor[row]*scalefactor[col], where
- * scalefactor[0] = 1
- * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7
- */
- FLOAT_MULT_TYPE *fmtbl = (FLOAT_MULT_TYPE *)compptr->dct_table;
- int row, col;
- static const double aanscalefactor[DCTSIZE] = {
- 1.0, 1.387039845, 1.306562965, 1.175875602,
- 1.0, 0.785694958, 0.541196100, 0.275899379
- };
-
- i = 0;
- for (row = 0; row < DCTSIZE; row++) {
- for (col = 0; col < DCTSIZE; col++) {
- fmtbl[i] = (FLOAT_MULT_TYPE)
- ((double)qtbl->quantval[i] *
- aanscalefactor[row] * aanscalefactor[col]);
- i++;
- }
- }
- }
- break;
-#endif
- default:
- ERREXIT(cinfo, JERR_NOT_COMPILED);
- break;
- }
- }
-}
-
-
-/*
- * Initialize IDCT manager.
- */
-
-GLOBAL(void)
-jinit_inverse_dct(j_decompress_ptr cinfo)
-{
- my_idct_ptr idct;
- int ci;
- jpeg_component_info *compptr;
-
- idct = (my_idct_ptr)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- sizeof(my_idct_controller));
- cinfo->idct = (struct jpeg_inverse_dct *)idct;
- idct->pub.start_pass = start_pass;
-
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
- ci++, compptr++) {
- /* Allocate and pre-zero a multiplier table for each component */
- compptr->dct_table =
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- sizeof(multiplier_table));
- memset(compptr->dct_table, 0, sizeof(multiplier_table));
- /* Mark multiplier table not yet set up for any method */
- idct->cur_method[ci] = -1;
- }
-}
diff --git a/contrib/libs/libjpeg-turbo/jdhuff.c b/contrib/libs/libjpeg-turbo/jdhuff.c
deleted file mode 100644
index 679d221685..0000000000
--- a/contrib/libs/libjpeg-turbo/jdhuff.c
+++ /dev/null
@@ -1,834 +0,0 @@
-/*
- * jdhuff.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2009-2011, 2016, 2018-2019, D. R. Commander.
- * Copyright (C) 2018, Matthias Räncker.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains Huffman entropy decoding routines.
- *
- * Much of the complexity here has to do with supporting input suspension.
- * If the data source module demands suspension, we want to be able to back
- * up to the start of the current MCU. To do this, we copy state variables
- * into local working storage, and update them back to the permanent
- * storage only upon successful completion of an MCU.
- *
- * NOTE: All referenced figures are from
- * Recommendation ITU-T T.81 (1992) | ISO/IEC 10918-1:1994.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-#include "jdhuff.h" /* Declarations shared with jdphuff.c */
-#include "jpegcomp.h"
-#include "jstdhuff.c"
-
-
-/*
- * Expanded entropy decoder object for Huffman decoding.
- *
- * The savable_state subrecord contains fields that change within an MCU,
- * but must not be updated permanently until we complete the MCU.
- */
-
-typedef struct {
- int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */
-} savable_state;
-
-typedef struct {
- struct jpeg_entropy_decoder pub; /* public fields */
-
- /* These fields are loaded into local variables at start of each MCU.
- * In case of suspension, we exit WITHOUT updating them.
- */
- bitread_perm_state bitstate; /* Bit buffer at start of MCU */
- savable_state saved; /* Other state at start of MCU */
-
- /* These fields are NOT loaded into local working state. */
- unsigned int restarts_to_go; /* MCUs left in this restart interval */
-
- /* Pointers to derived tables (these workspaces have image lifespan) */
- d_derived_tbl *dc_derived_tbls[NUM_HUFF_TBLS];
- d_derived_tbl *ac_derived_tbls[NUM_HUFF_TBLS];
-
- /* Precalculated info set up by start_pass for use in decode_mcu: */
-
- /* Pointers to derived tables to be used for each block within an MCU */
- d_derived_tbl *dc_cur_tbls[D_MAX_BLOCKS_IN_MCU];
- d_derived_tbl *ac_cur_tbls[D_MAX_BLOCKS_IN_MCU];
- /* Whether we care about the DC and AC coefficient values for each block */
- boolean dc_needed[D_MAX_BLOCKS_IN_MCU];
- boolean ac_needed[D_MAX_BLOCKS_IN_MCU];
-} huff_entropy_decoder;
-
-typedef huff_entropy_decoder *huff_entropy_ptr;
-
-
-/*
- * Initialize for a Huffman-compressed scan.
- */
-
-METHODDEF(void)
-start_pass_huff_decoder(j_decompress_ptr cinfo)
-{
- huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
- int ci, blkn, dctbl, actbl;
- d_derived_tbl **pdtbl;
- jpeg_component_info *compptr;
-
- /* Check that the scan parameters Ss, Se, Ah/Al are OK for sequential JPEG.
- * This ought to be an error condition, but we make it a warning because
- * there are some baseline files out there with all zeroes in these bytes.
- */
- if (cinfo->Ss != 0 || cinfo->Se != DCTSIZE2 - 1 ||
- cinfo->Ah != 0 || cinfo->Al != 0)
- WARNMS(cinfo, JWRN_NOT_SEQUENTIAL);
-
- for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
- compptr = cinfo->cur_comp_info[ci];
- dctbl = compptr->dc_tbl_no;
- actbl = compptr->ac_tbl_no;
- /* Compute derived values for Huffman tables */
- /* We may do this more than once for a table, but it's not expensive */
- pdtbl = (d_derived_tbl **)(entropy->dc_derived_tbls) + dctbl;
- jpeg_make_d_derived_tbl(cinfo, TRUE, dctbl, pdtbl);
- pdtbl = (d_derived_tbl **)(entropy->ac_derived_tbls) + actbl;
- jpeg_make_d_derived_tbl(cinfo, FALSE, actbl, pdtbl);
- /* Initialize DC predictions to 0 */
- entropy->saved.last_dc_val[ci] = 0;
- }
-
- /* Precalculate decoding info for each block in an MCU of this scan */
- for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
- ci = cinfo->MCU_membership[blkn];
- compptr = cinfo->cur_comp_info[ci];
- /* Precalculate which table to use for each block */
- entropy->dc_cur_tbls[blkn] = entropy->dc_derived_tbls[compptr->dc_tbl_no];
- entropy->ac_cur_tbls[blkn] = entropy->ac_derived_tbls[compptr->ac_tbl_no];
- /* Decide whether we really care about the coefficient values */
- if (compptr->component_needed) {
- entropy->dc_needed[blkn] = TRUE;
- /* we don't need the ACs if producing a 1/8th-size image */
- entropy->ac_needed[blkn] = (compptr->_DCT_scaled_size > 1);
- } else {
- entropy->dc_needed[blkn] = entropy->ac_needed[blkn] = FALSE;
- }
- }
-
- /* Initialize bitread state variables */
- entropy->bitstate.bits_left = 0;
- entropy->bitstate.get_buffer = 0; /* unnecessary, but keeps Purify quiet */
- entropy->pub.insufficient_data = FALSE;
-
- /* Initialize restart counter */
- entropy->restarts_to_go = cinfo->restart_interval;
-}
-
-
-/*
- * Compute the derived values for a Huffman table.
- * This routine also performs some validation checks on the table.
- *
- * Note this is also used by jdphuff.c.
- */
-
-GLOBAL(void)
-jpeg_make_d_derived_tbl(j_decompress_ptr cinfo, boolean isDC, int tblno,
- d_derived_tbl **pdtbl)
-{
- JHUFF_TBL *htbl;
- d_derived_tbl *dtbl;
- int p, i, l, si, numsymbols;
- int lookbits, ctr;
- char huffsize[257];
- unsigned int huffcode[257];
- unsigned int code;
-
- /* Note that huffsize[] and huffcode[] are filled in code-length order,
- * paralleling the order of the symbols themselves in htbl->huffval[].
- */
-
- /* Find the input Huffman table */
- if (tblno < 0 || tblno >= NUM_HUFF_TBLS)
- ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno);
- htbl =
- isDC ? cinfo->dc_huff_tbl_ptrs[tblno] : cinfo->ac_huff_tbl_ptrs[tblno];
- if (htbl == NULL)
- ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno);
-
- /* Allocate a workspace if we haven't already done so. */
- if (*pdtbl == NULL)
- *pdtbl = (d_derived_tbl *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- sizeof(d_derived_tbl));
- dtbl = *pdtbl;
- dtbl->pub = htbl; /* fill in back link */
-
- /* Figure C.1: make table of Huffman code length for each symbol */
-
- p = 0;
- for (l = 1; l <= 16; l++) {
- i = (int)htbl->bits[l];
- if (i < 0 || p + i > 256) /* protect against table overrun */
- ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
- while (i--)
- huffsize[p++] = (char)l;
- }
- huffsize[p] = 0;
- numsymbols = p;
-
- /* Figure C.2: generate the codes themselves */
- /* We also validate that the counts represent a legal Huffman code tree. */
-
- code = 0;
- si = huffsize[0];
- p = 0;
- while (huffsize[p]) {
- while (((int)huffsize[p]) == si) {
- huffcode[p++] = code;
- code++;
- }
- /* code is now 1 more than the last code used for codelength si; but
- * it must still fit in si bits, since no code is allowed to be all ones.
- */
- if (((JLONG)code) >= (((JLONG)1) << si))
- ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
- code <<= 1;
- si++;
- }
-
- /* Figure F.15: generate decoding tables for bit-sequential decoding */
-
- p = 0;
- for (l = 1; l <= 16; l++) {
- if (htbl->bits[l]) {
- /* valoffset[l] = huffval[] index of 1st symbol of code length l,
- * minus the minimum code of length l
- */
- dtbl->valoffset[l] = (JLONG)p - (JLONG)huffcode[p];
- p += htbl->bits[l];
- dtbl->maxcode[l] = huffcode[p - 1]; /* maximum code of length l */
- } else {
- dtbl->maxcode[l] = -1; /* -1 if no codes of this length */
- }
- }
- dtbl->valoffset[17] = 0;
- dtbl->maxcode[17] = 0xFFFFFL; /* ensures jpeg_huff_decode terminates */
-
- /* Compute lookahead tables to speed up decoding.
- * First we set all the table entries to 0, indicating "too long";
- * then we iterate through the Huffman codes that are short enough and
- * fill in all the entries that correspond to bit sequences starting
- * with that code.
- */
-
- for (i = 0; i < (1 << HUFF_LOOKAHEAD); i++)
- dtbl->lookup[i] = (HUFF_LOOKAHEAD + 1) << HUFF_LOOKAHEAD;
-
- p = 0;
- for (l = 1; l <= HUFF_LOOKAHEAD; l++) {
- for (i = 1; i <= (int)htbl->bits[l]; i++, p++) {
- /* l = current code's length, p = its index in huffcode[] & huffval[]. */
- /* Generate left-justified code followed by all possible bit sequences */
- lookbits = huffcode[p] << (HUFF_LOOKAHEAD - l);
- for (ctr = 1 << (HUFF_LOOKAHEAD - l); ctr > 0; ctr--) {
- dtbl->lookup[lookbits] = (l << HUFF_LOOKAHEAD) | htbl->huffval[p];
- lookbits++;
- }
- }
- }
-
- /* Validate symbols as being reasonable.
- * For AC tables, we make no check, but accept all byte values 0..255.
- * For DC tables, we require the symbols to be in range 0..15.
- * (Tighter bounds could be applied depending on the data depth and mode,
- * but this is sufficient to ensure safe decoding.)
- */
- if (isDC) {
- for (i = 0; i < numsymbols; i++) {
- int sym = htbl->huffval[i];
- if (sym < 0 || sym > 15)
- ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
- }
- }
-}
-
-
-/*
- * Out-of-line code for bit fetching (shared with jdphuff.c).
- * See jdhuff.h for info about usage.
- * Note: current values of get_buffer and bits_left are passed as parameters,
- * but are returned in the corresponding fields of the state struct.
- *
- * On most machines MIN_GET_BITS should be 25 to allow the full 32-bit width
- * of get_buffer to be used. (On machines with wider words, an even larger
- * buffer could be used.) However, on some machines 32-bit shifts are
- * quite slow and take time proportional to the number of places shifted.
- * (This is true with most PC compilers, for instance.) In this case it may
- * be a win to set MIN_GET_BITS to the minimum value of 15. This reduces the
- * average shift distance at the cost of more calls to jpeg_fill_bit_buffer.
- */
-
-#ifdef SLOW_SHIFT_32
-#define MIN_GET_BITS 15 /* minimum allowable value */
-#else
-#define MIN_GET_BITS (BIT_BUF_SIZE - 7)
-#endif
-
-
-GLOBAL(boolean)
-jpeg_fill_bit_buffer(bitread_working_state *state,
- register bit_buf_type get_buffer, register int bits_left,
- int nbits)
-/* Load up the bit buffer to a depth of at least nbits */
-{
- /* Copy heavily used state fields into locals (hopefully registers) */
- register const JOCTET *next_input_byte = state->next_input_byte;
- register size_t bytes_in_buffer = state->bytes_in_buffer;
- j_decompress_ptr cinfo = state->cinfo;
-
- /* Attempt to load at least MIN_GET_BITS bits into get_buffer. */
- /* (It is assumed that no request will be for more than that many bits.) */
- /* We fail to do so only if we hit a marker or are forced to suspend. */
-
- if (cinfo->unread_marker == 0) { /* cannot advance past a marker */
- while (bits_left < MIN_GET_BITS) {
- register int c;
-
- /* Attempt to read a byte */
- if (bytes_in_buffer == 0) {
- if (!(*cinfo->src->fill_input_buffer) (cinfo))
- return FALSE;
- next_input_byte = cinfo->src->next_input_byte;
- bytes_in_buffer = cinfo->src->bytes_in_buffer;
- }
- bytes_in_buffer--;
- c = *next_input_byte++;
-
- /* If it's 0xFF, check and discard stuffed zero byte */
- if (c == 0xFF) {
- /* Loop here to discard any padding FF's on terminating marker,
- * so that we can save a valid unread_marker value. NOTE: we will
- * accept multiple FF's followed by a 0 as meaning a single FF data
- * byte. This data pattern is not valid according to the standard.
- */
- do {
- if (bytes_in_buffer == 0) {
- if (!(*cinfo->src->fill_input_buffer) (cinfo))
- return FALSE;
- next_input_byte = cinfo->src->next_input_byte;
- bytes_in_buffer = cinfo->src->bytes_in_buffer;
- }
- bytes_in_buffer--;
- c = *next_input_byte++;
- } while (c == 0xFF);
-
- if (c == 0) {
- /* Found FF/00, which represents an FF data byte */
- c = 0xFF;
- } else {
- /* Oops, it's actually a marker indicating end of compressed data.
- * Save the marker code for later use.
- * Fine point: it might appear that we should save the marker into
- * bitread working state, not straight into permanent state. But
- * once we have hit a marker, we cannot need to suspend within the
- * current MCU, because we will read no more bytes from the data
- * source. So it is OK to update permanent state right away.
- */
- cinfo->unread_marker = c;
- /* See if we need to insert some fake zero bits. */
- goto no_more_bytes;
- }
- }
-
- /* OK, load c into get_buffer */
- get_buffer = (get_buffer << 8) | c;
- bits_left += 8;
- } /* end while */
- } else {
-no_more_bytes:
- /* We get here if we've read the marker that terminates the compressed
- * data segment. There should be enough bits in the buffer register
- * to satisfy the request; if so, no problem.
- */
- if (nbits > bits_left) {
- /* Uh-oh. Report corrupted data to user and stuff zeroes into
- * the data stream, so that we can produce some kind of image.
- * We use a nonvolatile flag to ensure that only one warning message
- * appears per data segment.
- */
- if (!cinfo->entropy->insufficient_data) {
- WARNMS(cinfo, JWRN_HIT_MARKER);
- cinfo->entropy->insufficient_data = TRUE;
- }
- /* Fill the buffer with zero bits */
- get_buffer <<= MIN_GET_BITS - bits_left;
- bits_left = MIN_GET_BITS;
- }
- }
-
- /* Unload the local registers */
- state->next_input_byte = next_input_byte;
- state->bytes_in_buffer = bytes_in_buffer;
- state->get_buffer = get_buffer;
- state->bits_left = bits_left;
-
- return TRUE;
-}
-
-
-/* Macro version of the above, which performs much better but does not
- handle markers. We have to hand off any blocks with markers to the
- slower routines. */
-
-#define GET_BYTE { \
- register int c0, c1; \
- c0 = *buffer++; \
- c1 = *buffer; \
- /* Pre-execute most common case */ \
- get_buffer = (get_buffer << 8) | c0; \
- bits_left += 8; \
- if (c0 == 0xFF) { \
- /* Pre-execute case of FF/00, which represents an FF data byte */ \
- buffer++; \
- if (c1 != 0) { \
- /* Oops, it's actually a marker indicating end of compressed data. */ \
- cinfo->unread_marker = c1; \
- /* Back out pre-execution and fill the buffer with zero bits */ \
- buffer -= 2; \
- get_buffer &= ~0xFF; \
- } \
- } \
-}
-
-#if SIZEOF_SIZE_T == 8 || defined(_WIN64) || (defined(__x86_64__) && defined(__ILP32__))
-
-/* Pre-fetch 48 bytes, because the holding register is 64-bit */
-#define FILL_BIT_BUFFER_FAST \
- if (bits_left <= 16) { \
- GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
- }
-
-#else
-
-/* Pre-fetch 16 bytes, because the holding register is 32-bit */
-#define FILL_BIT_BUFFER_FAST \
- if (bits_left <= 16) { \
- GET_BYTE GET_BYTE \
- }
-
-#endif
-
-
-/*
- * Out-of-line code for Huffman code decoding.
- * See jdhuff.h for info about usage.
- */
-
-GLOBAL(int)
-jpeg_huff_decode(bitread_working_state *state,
- register bit_buf_type get_buffer, register int bits_left,
- d_derived_tbl *htbl, int min_bits)
-{
- register int l = min_bits;
- register JLONG code;
-
- /* HUFF_DECODE has determined that the code is at least min_bits */
- /* bits long, so fetch that many bits in one swoop. */
-
- CHECK_BIT_BUFFER(*state, l, return -1);
- code = GET_BITS(l);
-
- /* Collect the rest of the Huffman code one bit at a time. */
- /* This is per Figure F.16. */
-
- while (code > htbl->maxcode[l]) {
- code <<= 1;
- CHECK_BIT_BUFFER(*state, 1, return -1);
- code |= GET_BITS(1);
- l++;
- }
-
- /* Unload the local registers */
- state->get_buffer = get_buffer;
- state->bits_left = bits_left;
-
- /* With garbage input we may reach the sentinel value l = 17. */
-
- if (l > 16) {
- WARNMS(state->cinfo, JWRN_HUFF_BAD_CODE);
- return 0; /* fake a zero as the safest result */
- }
-
- return htbl->pub->huffval[(int)(code + htbl->valoffset[l])];
-}
-
-
-/*
- * Figure F.12: extend sign bit.
- * On some machines, a shift and add will be faster than a table lookup.
- */
-
-#define AVOID_TABLES
-#ifdef AVOID_TABLES
-
-#define NEG_1 ((unsigned int)-1)
-#define HUFF_EXTEND(x, s) \
- ((x) + ((((x) - (1 << ((s) - 1))) >> 31) & (((NEG_1) << (s)) + 1)))
-
-#else
-
-#define HUFF_EXTEND(x, s) \
- ((x) < extend_test[s] ? (x) + extend_offset[s] : (x))
-
-static const int extend_test[16] = { /* entry n is 2**(n-1) */
- 0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080,
- 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000
-};
-
-static const int extend_offset[16] = { /* entry n is (-1 << n) + 1 */
- 0, ((-1) << 1) + 1, ((-1) << 2) + 1, ((-1) << 3) + 1, ((-1) << 4) + 1,
- ((-1) << 5) + 1, ((-1) << 6) + 1, ((-1) << 7) + 1, ((-1) << 8) + 1,
- ((-1) << 9) + 1, ((-1) << 10) + 1, ((-1) << 11) + 1, ((-1) << 12) + 1,
- ((-1) << 13) + 1, ((-1) << 14) + 1, ((-1) << 15) + 1
-};
-
-#endif /* AVOID_TABLES */
-
-
-/*
- * Check for a restart marker & resynchronize decoder.
- * Returns FALSE if must suspend.
- */
-
-LOCAL(boolean)
-process_restart(j_decompress_ptr cinfo)
-{
- huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
- int ci;
-
- /* Throw away any unused bits remaining in bit buffer; */
- /* include any full bytes in next_marker's count of discarded bytes */
- cinfo->marker->discarded_bytes += entropy->bitstate.bits_left / 8;
- entropy->bitstate.bits_left = 0;
-
- /* Advance past the RSTn marker */
- if (!(*cinfo->marker->read_restart_marker) (cinfo))
- return FALSE;
-
- /* Re-initialize DC predictions to 0 */
- for (ci = 0; ci < cinfo->comps_in_scan; ci++)
- entropy->saved.last_dc_val[ci] = 0;
-
- /* Reset restart counter */
- entropy->restarts_to_go = cinfo->restart_interval;
-
- /* Reset out-of-data flag, unless read_restart_marker left us smack up
- * against a marker. In that case we will end up treating the next data
- * segment as empty, and we can avoid producing bogus output pixels by
- * leaving the flag set.
- */
- if (cinfo->unread_marker == 0)
- entropy->pub.insufficient_data = FALSE;
-
- return TRUE;
-}
-
-
-#if defined(__has_feature)
-#if __has_feature(undefined_behavior_sanitizer)
-__attribute__((no_sanitize("signed-integer-overflow"),
- no_sanitize("unsigned-integer-overflow")))
-#endif
-#endif
-LOCAL(boolean)
-decode_mcu_slow(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
-{
- huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
- BITREAD_STATE_VARS;
- int blkn;
- savable_state state;
- /* Outer loop handles each block in the MCU */
-
- /* Load up working state */
- BITREAD_LOAD_STATE(cinfo, entropy->bitstate);
- state = entropy->saved;
-
- for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
- JBLOCKROW block = MCU_data ? MCU_data[blkn] : NULL;
- d_derived_tbl *dctbl = entropy->dc_cur_tbls[blkn];
- d_derived_tbl *actbl = entropy->ac_cur_tbls[blkn];
- register int s, k, r;
-
- /* Decode a single block's worth of coefficients */
-
- /* Section F.2.2.1: decode the DC coefficient difference */
- HUFF_DECODE(s, br_state, dctbl, return FALSE, label1);
- if (s) {
- CHECK_BIT_BUFFER(br_state, s, return FALSE);
- r = GET_BITS(s);
- s = HUFF_EXTEND(r, s);
- }
-
- if (entropy->dc_needed[blkn]) {
- /* Convert DC difference to actual value, update last_dc_val */
- int ci = cinfo->MCU_membership[blkn];
- /* Certain malformed JPEG images produce repeated DC coefficient
- * differences of 2047 or -2047, which causes state.last_dc_val[ci] to
- * grow until it overflows or underflows a 32-bit signed integer. This
- * behavior is, to the best of our understanding, innocuous, and it is
- * unclear how to work around it without potentially affecting
- * performance. Thus, we (hopefully temporarily) suppress UBSan integer
- * overflow errors for this function and decode_mcu_fast().
- */
- s += state.last_dc_val[ci];
- state.last_dc_val[ci] = s;
- if (block) {
- /* Output the DC coefficient (assumes jpeg_natural_order[0] = 0) */
- (*block)[0] = (JCOEF)s;
- }
- }
-
- if (entropy->ac_needed[blkn] && block) {
-
- /* Section F.2.2.2: decode the AC coefficients */
- /* Since zeroes are skipped, output area must be cleared beforehand */
- for (k = 1; k < DCTSIZE2; k++) {
- HUFF_DECODE(s, br_state, actbl, return FALSE, label2);
-
- r = s >> 4;
- s &= 15;
-
- if (s) {
- k += r;
- CHECK_BIT_BUFFER(br_state, s, return FALSE);
- r = GET_BITS(s);
- s = HUFF_EXTEND(r, s);
- /* Output coefficient in natural (dezigzagged) order.
- * Note: the extra entries in jpeg_natural_order[] will save us
- * if k >= DCTSIZE2, which could happen if the data is corrupted.
- */
- (*block)[jpeg_natural_order[k]] = (JCOEF)s;
- } else {
- if (r != 15)
- break;
- k += 15;
- }
- }
-
- } else {
-
- /* Section F.2.2.2: decode the AC coefficients */
- /* In this path we just discard the values */
- for (k = 1; k < DCTSIZE2; k++) {
- HUFF_DECODE(s, br_state, actbl, return FALSE, label3);
-
- r = s >> 4;
- s &= 15;
-
- if (s) {
- k += r;
- CHECK_BIT_BUFFER(br_state, s, return FALSE);
- DROP_BITS(s);
- } else {
- if (r != 15)
- break;
- k += 15;
- }
- }
- }
- }
-
- /* Completed MCU, so update state */
- BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
- entropy->saved = state;
- return TRUE;
-}
-
-
-#if defined(__has_feature)
-#if __has_feature(undefined_behavior_sanitizer)
-__attribute__((no_sanitize("signed-integer-overflow"),
- no_sanitize("unsigned-integer-overflow")))
-#endif
-#endif
-LOCAL(boolean)
-decode_mcu_fast(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
-{
- huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
- BITREAD_STATE_VARS;
- JOCTET *buffer;
- int blkn;
- savable_state state;
- /* Outer loop handles each block in the MCU */
-
- /* Load up working state */
- BITREAD_LOAD_STATE(cinfo, entropy->bitstate);
- buffer = (JOCTET *)br_state.next_input_byte;
- state = entropy->saved;
-
- for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
- JBLOCKROW block = MCU_data ? MCU_data[blkn] : NULL;
- d_derived_tbl *dctbl = entropy->dc_cur_tbls[blkn];
- d_derived_tbl *actbl = entropy->ac_cur_tbls[blkn];
- register int s, k, r, l;
-
- HUFF_DECODE_FAST(s, l, dctbl);
- if (s) {
- FILL_BIT_BUFFER_FAST
- r = GET_BITS(s);
- s = HUFF_EXTEND(r, s);
- }
-
- if (entropy->dc_needed[blkn]) {
- int ci = cinfo->MCU_membership[blkn];
- /* Refer to the comment in decode_mcu_slow() regarding the supression of
- * a UBSan integer overflow error in this line of code.
- */
- s += state.last_dc_val[ci];
- state.last_dc_val[ci] = s;
- if (block)
- (*block)[0] = (JCOEF)s;
- }
-
- if (entropy->ac_needed[blkn] && block) {
-
- for (k = 1; k < DCTSIZE2; k++) {
- HUFF_DECODE_FAST(s, l, actbl);
- r = s >> 4;
- s &= 15;
-
- if (s) {
- k += r;
- FILL_BIT_BUFFER_FAST
- r = GET_BITS(s);
- s = HUFF_EXTEND(r, s);
- (*block)[jpeg_natural_order[k]] = (JCOEF)s;
- } else {
- if (r != 15) break;
- k += 15;
- }
- }
-
- } else {
-
- for (k = 1; k < DCTSIZE2; k++) {
- HUFF_DECODE_FAST(s, l, actbl);
- r = s >> 4;
- s &= 15;
-
- if (s) {
- k += r;
- FILL_BIT_BUFFER_FAST
- DROP_BITS(s);
- } else {
- if (r != 15) break;
- k += 15;
- }
- }
- }
- }
-
- if (cinfo->unread_marker != 0) {
- cinfo->unread_marker = 0;
- return FALSE;
- }
-
- br_state.bytes_in_buffer -= (buffer - br_state.next_input_byte);
- br_state.next_input_byte = buffer;
- BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
- entropy->saved = state;
- return TRUE;
-}
-
-
-/*
- * Decode and return one MCU's worth of Huffman-compressed coefficients.
- * The coefficients are reordered from zigzag order into natural array order,
- * but are not dequantized.
- *
- * The i'th block of the MCU is stored into the block pointed to by
- * MCU_data[i]. WE ASSUME THIS AREA HAS BEEN ZEROED BY THE CALLER.
- * (Wholesale zeroing is usually a little faster than retail...)
- *
- * Returns FALSE if data source requested suspension. In that case no
- * changes have been made to permanent state. (Exception: some output
- * coefficients may already have been assigned. This is harmless for
- * this module, since we'll just re-assign them on the next call.)
- */
-
-#define BUFSIZE (DCTSIZE2 * 8)
-
-METHODDEF(boolean)
-decode_mcu(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
-{
- huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
- int usefast = 1;
-
- /* Process restart marker if needed; may have to suspend */
- if (cinfo->restart_interval) {
- if (entropy->restarts_to_go == 0)
- if (!process_restart(cinfo))
- return FALSE;
- usefast = 0;
- }
-
- if (cinfo->src->bytes_in_buffer < BUFSIZE * (size_t)cinfo->blocks_in_MCU ||
- cinfo->unread_marker != 0)
- usefast = 0;
-
- /* If we've run out of data, just leave the MCU set to zeroes.
- * This way, we return uniform gray for the remainder of the segment.
- */
- if (!entropy->pub.insufficient_data) {
-
- if (usefast) {
- if (!decode_mcu_fast(cinfo, MCU_data)) goto use_slow;
- } else {
-use_slow:
- if (!decode_mcu_slow(cinfo, MCU_data)) return FALSE;
- }
-
- }
-
- /* Account for restart interval (no-op if not using restarts) */
- if (cinfo->restart_interval)
- entropy->restarts_to_go--;
-
- return TRUE;
-}
-
-
-/*
- * Module initialization routine for Huffman entropy decoding.
- */
-
-GLOBAL(void)
-jinit_huff_decoder(j_decompress_ptr cinfo)
-{
- huff_entropy_ptr entropy;
- int i;
-
- /* Motion JPEG frames typically do not include the Huffman tables if they
- are the default tables. Thus, if the tables are not set by the time
- the Huffman decoder is initialized (usually within the body of
- jpeg_start_decompress()), we set them to default values. */
- std_huff_tables((j_common_ptr)cinfo);
-
- entropy = (huff_entropy_ptr)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- sizeof(huff_entropy_decoder));
- cinfo->entropy = (struct jpeg_entropy_decoder *)entropy;
- entropy->pub.start_pass = start_pass_huff_decoder;
- entropy->pub.decode_mcu = decode_mcu;
-
- /* Mark tables unallocated */
- for (i = 0; i < NUM_HUFF_TBLS; i++) {
- entropy->dc_derived_tbls[i] = entropy->ac_derived_tbls[i] = NULL;
- }
-}
diff --git a/contrib/libs/libjpeg-turbo/jdhuff.h b/contrib/libs/libjpeg-turbo/jdhuff.h
deleted file mode 100644
index cfa0b7f558..0000000000
--- a/contrib/libs/libjpeg-turbo/jdhuff.h
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * jdhuff.h
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2010-2011, 2015-2016, 2021, D. R. Commander.
- * Copyright (C) 2018, Matthias Räncker.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains declarations for Huffman entropy decoding routines
- * that are shared between the sequential decoder (jdhuff.c) and the
- * progressive decoder (jdphuff.c). No other modules need to see these.
- */
-
-#include "jconfigint.h"
-
-
-/* Derived data constructed for each Huffman table */
-
-#define HUFF_LOOKAHEAD 8 /* # of bits of lookahead */
-
-typedef struct {
- /* Basic tables: (element [0] of each array is unused) */
- JLONG maxcode[18]; /* largest code of length k (-1 if none) */
- /* (maxcode[17] is a sentinel to ensure jpeg_huff_decode terminates) */
- JLONG valoffset[18]; /* huffval[] offset for codes of length k */
- /* valoffset[k] = huffval[] index of 1st symbol of code length k, less
- * the smallest code of length k; so given a code of length k, the
- * corresponding symbol is huffval[code + valoffset[k]]
- */
-
- /* Link to public Huffman table (needed only in jpeg_huff_decode) */
- JHUFF_TBL *pub;
-
- /* Lookahead table: indexed by the next HUFF_LOOKAHEAD bits of
- * the input data stream. If the next Huffman code is no more
- * than HUFF_LOOKAHEAD bits long, we can obtain its length and
- * the corresponding symbol directly from this tables.
- *
- * The lower 8 bits of each table entry contain the number of
- * bits in the corresponding Huffman code, or HUFF_LOOKAHEAD + 1
- * if too long. The next 8 bits of each entry contain the
- * symbol.
- */
- int lookup[1 << HUFF_LOOKAHEAD];
-} d_derived_tbl;
-
-/* Expand a Huffman table definition into the derived format */
-EXTERN(void) jpeg_make_d_derived_tbl(j_decompress_ptr cinfo, boolean isDC,
- int tblno, d_derived_tbl **pdtbl);
-
-
-/*
- * Fetching the next N bits from the input stream is a time-critical operation
- * for the Huffman decoders. We implement it with a combination of inline
- * macros and out-of-line subroutines. Note that N (the number of bits
- * demanded at one time) never exceeds 15 for JPEG use.
- *
- * We read source bytes into get_buffer and dole out bits as needed.
- * If get_buffer already contains enough bits, they are fetched in-line
- * by the macros CHECK_BIT_BUFFER and GET_BITS. When there aren't enough
- * bits, jpeg_fill_bit_buffer is called; it will attempt to fill get_buffer
- * as full as possible (not just to the number of bits needed; this
- * prefetching reduces the overhead cost of calling jpeg_fill_bit_buffer).
- * Note that jpeg_fill_bit_buffer may return FALSE to indicate suspension.
- * On TRUE return, jpeg_fill_bit_buffer guarantees that get_buffer contains
- * at least the requested number of bits --- dummy zeroes are inserted if
- * necessary.
- */
-
-#if !defined(_WIN32) && !defined(SIZEOF_SIZE_T)
-#error Cannot determine word size
-#endif
-
-#if SIZEOF_SIZE_T == 8 || defined(_WIN64)
-
-typedef size_t bit_buf_type; /* type of bit-extraction buffer */
-#define BIT_BUF_SIZE 64 /* size of buffer in bits */
-
-#elif defined(__x86_64__) && defined(__ILP32__)
-
-typedef unsigned long long bit_buf_type; /* type of bit-extraction buffer */
-#define BIT_BUF_SIZE 64 /* size of buffer in bits */
-
-#else
-
-typedef unsigned long bit_buf_type; /* type of bit-extraction buffer */
-#define BIT_BUF_SIZE 32 /* size of buffer in bits */
-
-#endif
-
-/* If long is > 32 bits on your machine, and shifting/masking longs is
- * reasonably fast, making bit_buf_type be long and setting BIT_BUF_SIZE
- * appropriately should be a win. Unfortunately we can't define the size
- * with something like #define BIT_BUF_SIZE (sizeof(bit_buf_type)*8)
- * because not all machines measure sizeof in 8-bit bytes.
- */
-
-typedef struct { /* Bitreading state saved across MCUs */
- bit_buf_type get_buffer; /* current bit-extraction buffer */
- int bits_left; /* # of unused bits in it */
-} bitread_perm_state;
-
-typedef struct { /* Bitreading working state within an MCU */
- /* Current data source location */
- /* We need a copy, rather than munging the original, in case of suspension */
- const JOCTET *next_input_byte; /* => next byte to read from source */
- size_t bytes_in_buffer; /* # of bytes remaining in source buffer */
- /* Bit input buffer --- note these values are kept in register variables,
- * not in this struct, inside the inner loops.
- */
- bit_buf_type get_buffer; /* current bit-extraction buffer */
- int bits_left; /* # of unused bits in it */
- /* Pointer needed by jpeg_fill_bit_buffer. */
- j_decompress_ptr cinfo; /* back link to decompress master record */
-} bitread_working_state;
-
-/* Macros to declare and load/save bitread local variables. */
-#define BITREAD_STATE_VARS \
- register bit_buf_type get_buffer; \
- register int bits_left; \
- bitread_working_state br_state
-
-#define BITREAD_LOAD_STATE(cinfop, permstate) \
- br_state.cinfo = cinfop; \
- br_state.next_input_byte = cinfop->src->next_input_byte; \
- br_state.bytes_in_buffer = cinfop->src->bytes_in_buffer; \
- get_buffer = permstate.get_buffer; \
- bits_left = permstate.bits_left;
-
-#define BITREAD_SAVE_STATE(cinfop, permstate) \
- cinfop->src->next_input_byte = br_state.next_input_byte; \
- cinfop->src->bytes_in_buffer = br_state.bytes_in_buffer; \
- permstate.get_buffer = get_buffer; \
- permstate.bits_left = bits_left
-
-/*
- * These macros provide the in-line portion of bit fetching.
- * Use CHECK_BIT_BUFFER to ensure there are N bits in get_buffer
- * before using GET_BITS, PEEK_BITS, or DROP_BITS.
- * The variables get_buffer and bits_left are assumed to be locals,
- * but the state struct might not be (jpeg_huff_decode needs this).
- * CHECK_BIT_BUFFER(state, n, action);
- * Ensure there are N bits in get_buffer; if suspend, take action.
- * val = GET_BITS(n);
- * Fetch next N bits.
- * val = PEEK_BITS(n);
- * Fetch next N bits without removing them from the buffer.
- * DROP_BITS(n);
- * Discard next N bits.
- * The value N should be a simple variable, not an expression, because it
- * is evaluated multiple times.
- */
-
-#define CHECK_BIT_BUFFER(state, nbits, action) { \
- if (bits_left < (nbits)) { \
- if (!jpeg_fill_bit_buffer(&(state), get_buffer, bits_left, nbits)) \
- { action; } \
- get_buffer = (state).get_buffer; bits_left = (state).bits_left; \
- } \
-}
-
-#define GET_BITS(nbits) \
- (((int)(get_buffer >> (bits_left -= (nbits)))) & ((1 << (nbits)) - 1))
-
-#define PEEK_BITS(nbits) \
- (((int)(get_buffer >> (bits_left - (nbits)))) & ((1 << (nbits)) - 1))
-
-#define DROP_BITS(nbits) \
- (bits_left -= (nbits))
-
-/* Load up the bit buffer to a depth of at least nbits */
-EXTERN(boolean) jpeg_fill_bit_buffer(bitread_working_state *state,
- register bit_buf_type get_buffer,
- register int bits_left, int nbits);
-
-
-/*
- * Code for extracting next Huffman-coded symbol from input bit stream.
- * Again, this is time-critical and we make the main paths be macros.
- *
- * We use a lookahead table to process codes of up to HUFF_LOOKAHEAD bits
- * without looping. Usually, more than 95% of the Huffman codes will be 8
- * or fewer bits long. The few overlength codes are handled with a loop,
- * which need not be inline code.
- *
- * Notes about the HUFF_DECODE macro:
- * 1. Near the end of the data segment, we may fail to get enough bits
- * for a lookahead. In that case, we do it the hard way.
- * 2. If the lookahead table contains no entry, the next code must be
- * more than HUFF_LOOKAHEAD bits long.
- * 3. jpeg_huff_decode returns -1 if forced to suspend.
- */
-
-#define HUFF_DECODE(result, state, htbl, failaction, slowlabel) { \
- register int nb, look; \
- if (bits_left < HUFF_LOOKAHEAD) { \
- if (!jpeg_fill_bit_buffer(&state, get_buffer, bits_left, 0)) \
- { failaction; } \
- get_buffer = state.get_buffer; bits_left = state.bits_left; \
- if (bits_left < HUFF_LOOKAHEAD) { \
- nb = 1; goto slowlabel; \
- } \
- } \
- look = PEEK_BITS(HUFF_LOOKAHEAD); \
- if ((nb = (htbl->lookup[look] >> HUFF_LOOKAHEAD)) <= HUFF_LOOKAHEAD) { \
- DROP_BITS(nb); \
- result = htbl->lookup[look] & ((1 << HUFF_LOOKAHEAD) - 1); \
- } else { \
-slowlabel: \
- if ((result = \
- jpeg_huff_decode(&state, get_buffer, bits_left, htbl, nb)) < 0) \
- { failaction; } \
- get_buffer = state.get_buffer; bits_left = state.bits_left; \
- } \
-}
-
-#define HUFF_DECODE_FAST(s, nb, htbl) \
- FILL_BIT_BUFFER_FAST; \
- s = PEEK_BITS(HUFF_LOOKAHEAD); \
- s = htbl->lookup[s]; \
- nb = s >> HUFF_LOOKAHEAD; \
- /* Pre-execute the common case of nb <= HUFF_LOOKAHEAD */ \
- DROP_BITS(nb); \
- s = s & ((1 << HUFF_LOOKAHEAD) - 1); \
- if (nb > HUFF_LOOKAHEAD) { \
- /* Equivalent of jpeg_huff_decode() */ \
- /* Don't use GET_BITS() here because we don't want to modify bits_left */ \
- s = (get_buffer >> bits_left) & ((1 << (nb)) - 1); \
- while (s > htbl->maxcode[nb]) { \
- s <<= 1; \
- s |= GET_BITS(1); \
- nb++; \
- } \
- if (nb > 16) \
- s = 0; \
- else \
- s = htbl->pub->huffval[(int)(s + htbl->valoffset[nb]) & 0xFF]; \
- }
-
-/* Out-of-line case for Huffman code fetching */
-EXTERN(int) jpeg_huff_decode(bitread_working_state *state,
- register bit_buf_type get_buffer,
- register int bits_left, d_derived_tbl *htbl,
- int min_bits);
diff --git a/contrib/libs/libjpeg-turbo/jdicc.c b/contrib/libs/libjpeg-turbo/jdicc.c
deleted file mode 100644
index 50aa9a9676..0000000000
--- a/contrib/libs/libjpeg-turbo/jdicc.c
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * jdicc.c
- *
- * Copyright (C) 1997-1998, Thomas G. Lane, Todd Newman.
- * Copyright (C) 2017, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file provides code to read International Color Consortium (ICC) device
- * profiles embedded in JFIF JPEG image files. The ICC has defined a standard
- * for including such data in JPEG "APP2" markers. The code given here does
- * not know anything about the internal structure of the ICC profile data; it
- * just knows how to get the profile data from a JPEG file while reading it.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-#include "jerror.h"
-
-
-#define ICC_MARKER (JPEG_APP0 + 2) /* JPEG marker code for ICC */
-#define ICC_OVERHEAD_LEN 14 /* size of non-profile data in APP2 */
-
-
-/*
- * Handy subroutine to test whether a saved marker is an ICC profile marker.
- */
-
-LOCAL(boolean)
-marker_is_icc(jpeg_saved_marker_ptr marker)
-{
- return
- marker->marker == ICC_MARKER &&
- marker->data_length >= ICC_OVERHEAD_LEN &&
- /* verify the identifying string */
- marker->data[0] == 0x49 &&
- marker->data[1] == 0x43 &&
- marker->data[2] == 0x43 &&
- marker->data[3] == 0x5F &&
- marker->data[4] == 0x50 &&
- marker->data[5] == 0x52 &&
- marker->data[6] == 0x4F &&
- marker->data[7] == 0x46 &&
- marker->data[8] == 0x49 &&
- marker->data[9] == 0x4C &&
- marker->data[10] == 0x45 &&
- marker->data[11] == 0x0;
-}
-
-
-/*
- * See if there was an ICC profile in the JPEG file being read; if so,
- * reassemble and return the profile data.
- *
- * TRUE is returned if an ICC profile was found, FALSE if not. If TRUE is
- * returned, *icc_data_ptr is set to point to the returned data, and
- * *icc_data_len is set to its length.
- *
- * IMPORTANT: the data at *icc_data_ptr is allocated with malloc() and must be
- * freed by the caller with free() when the caller no longer needs it.
- * (Alternatively, we could write this routine to use the IJG library's memory
- * allocator, so that the data would be freed implicitly when
- * jpeg_finish_decompress() is called. But it seems likely that many
- * applications will prefer to have the data stick around after decompression
- * finishes.)
- */
-
-GLOBAL(boolean)
-jpeg_read_icc_profile(j_decompress_ptr cinfo, JOCTET **icc_data_ptr,
- unsigned int *icc_data_len)
-{
- jpeg_saved_marker_ptr marker;
- int num_markers = 0;
- int seq_no;
- JOCTET *icc_data;
- unsigned int total_length;
-#define MAX_SEQ_NO 255 /* sufficient since marker numbers are bytes */
- char marker_present[MAX_SEQ_NO + 1]; /* 1 if marker found */
- unsigned int data_length[MAX_SEQ_NO + 1]; /* size of profile data in marker */
- unsigned int data_offset[MAX_SEQ_NO + 1]; /* offset for data in marker */
-
- if (icc_data_ptr == NULL || icc_data_len == NULL)
- ERREXIT(cinfo, JERR_BUFFER_SIZE);
- if (cinfo->global_state < DSTATE_READY)
- ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
-
- *icc_data_ptr = NULL; /* avoid confusion if FALSE return */
- *icc_data_len = 0;
-
- /* This first pass over the saved markers discovers whether there are
- * any ICC markers and verifies the consistency of the marker numbering.
- */
-
- for (seq_no = 1; seq_no <= MAX_SEQ_NO; seq_no++)
- marker_present[seq_no] = 0;
-
- for (marker = cinfo->marker_list; marker != NULL; marker = marker->next) {
- if (marker_is_icc(marker)) {
- if (num_markers == 0)
- num_markers = marker->data[13];
- else if (num_markers != marker->data[13]) {
- WARNMS(cinfo, JWRN_BOGUS_ICC); /* inconsistent num_markers fields */
- return FALSE;
- }
- seq_no = marker->data[12];
- if (seq_no <= 0 || seq_no > num_markers) {
- WARNMS(cinfo, JWRN_BOGUS_ICC); /* bogus sequence number */
- return FALSE;
- }
- if (marker_present[seq_no]) {
- WARNMS(cinfo, JWRN_BOGUS_ICC); /* duplicate sequence numbers */
- return FALSE;
- }
- marker_present[seq_no] = 1;
- data_length[seq_no] = marker->data_length - ICC_OVERHEAD_LEN;
- }
- }
-
- if (num_markers == 0)
- return FALSE;
-
- /* Check for missing markers, count total space needed,
- * compute offset of each marker's part of the data.
- */
-
- total_length = 0;
- for (seq_no = 1; seq_no <= num_markers; seq_no++) {
- if (marker_present[seq_no] == 0) {
- WARNMS(cinfo, JWRN_BOGUS_ICC); /* missing sequence number */
- return FALSE;
- }
- data_offset[seq_no] = total_length;
- total_length += data_length[seq_no];
- }
-
- if (total_length == 0) {
- WARNMS(cinfo, JWRN_BOGUS_ICC); /* found only empty markers? */
- return FALSE;
- }
-
- /* Allocate space for assembled data */
- icc_data = (JOCTET *)malloc(total_length * sizeof(JOCTET));
- if (icc_data == NULL)
- ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 11); /* oops, out of memory */
-
- /* and fill it in */
- for (marker = cinfo->marker_list; marker != NULL; marker = marker->next) {
- if (marker_is_icc(marker)) {
- JOCTET FAR *src_ptr;
- JOCTET *dst_ptr;
- unsigned int length;
- seq_no = marker->data[12];
- dst_ptr = icc_data + data_offset[seq_no];
- src_ptr = marker->data + ICC_OVERHEAD_LEN;
- length = data_length[seq_no];
- while (length--) {
- *dst_ptr++ = *src_ptr++;
- }
- }
- }
-
- *icc_data_ptr = icc_data;
- *icc_data_len = total_length;
-
- return TRUE;
-}
diff --git a/contrib/libs/libjpeg-turbo/jdinput.c b/contrib/libs/libjpeg-turbo/jdinput.c
deleted file mode 100644
index 1bc5aff1a7..0000000000
--- a/contrib/libs/libjpeg-turbo/jdinput.c
+++ /dev/null
@@ -1,408 +0,0 @@
-/*
- * jdinput.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2016, 2018, 2022, D. R. Commander.
- * Copyright (C) 2015, Google, Inc.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains input control logic for the JPEG decompressor.
- * These routines are concerned with controlling the decompressor's input
- * processing (marker reading and coefficient decoding). The actual input
- * reading is done in jdmarker.c, jdhuff.c, and jdphuff.c.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-#include "jpegcomp.h"
-
-
-/* Private state */
-
-typedef struct {
- struct jpeg_input_controller pub; /* public fields */
-
- boolean inheaders; /* TRUE until first SOS is reached */
-} my_input_controller;
-
-typedef my_input_controller *my_inputctl_ptr;
-
-
-/* Forward declarations */
-METHODDEF(int) consume_markers(j_decompress_ptr cinfo);
-
-
-/*
- * Routines to calculate various quantities related to the size of the image.
- */
-
-LOCAL(void)
-initial_setup(j_decompress_ptr cinfo)
-/* Called once, when first SOS marker is reached */
-{
- int ci;
- jpeg_component_info *compptr;
-
- /* Make sure image isn't bigger than I can handle */
- if ((long)cinfo->image_height > (long)JPEG_MAX_DIMENSION ||
- (long)cinfo->image_width > (long)JPEG_MAX_DIMENSION)
- ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int)JPEG_MAX_DIMENSION);
-
- /* For now, precision must match compiled-in value... */
- if (cinfo->data_precision != BITS_IN_JSAMPLE)
- ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
-
- /* Check that number of components won't exceed internal array sizes */
- if (cinfo->num_components > MAX_COMPONENTS)
- ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components,
- MAX_COMPONENTS);
-
- /* Compute maximum sampling factors; check factor validity */
- cinfo->max_h_samp_factor = 1;
- cinfo->max_v_samp_factor = 1;
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
- ci++, compptr++) {
- if (compptr->h_samp_factor <= 0 ||
- compptr->h_samp_factor > MAX_SAMP_FACTOR ||
- compptr->v_samp_factor <= 0 ||
- compptr->v_samp_factor > MAX_SAMP_FACTOR)
- ERREXIT(cinfo, JERR_BAD_SAMPLING);
- cinfo->max_h_samp_factor = MAX(cinfo->max_h_samp_factor,
- compptr->h_samp_factor);
- cinfo->max_v_samp_factor = MAX(cinfo->max_v_samp_factor,
- compptr->v_samp_factor);
- }
-
-#if JPEG_LIB_VERSION >= 80
- cinfo->block_size = DCTSIZE;
- cinfo->natural_order = jpeg_natural_order;
- cinfo->lim_Se = DCTSIZE2 - 1;
-#endif
-
- /* We initialize DCT_scaled_size and min_DCT_scaled_size to DCTSIZE.
- * In the full decompressor, this will be overridden by jdmaster.c;
- * but in the transcoder, jdmaster.c is not used, so we must do it here.
- */
-#if JPEG_LIB_VERSION >= 70
- cinfo->min_DCT_h_scaled_size = cinfo->min_DCT_v_scaled_size = DCTSIZE;
-#else
- cinfo->min_DCT_scaled_size = DCTSIZE;
-#endif
-
- /* Compute dimensions of components */
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
- ci++, compptr++) {
-#if JPEG_LIB_VERSION >= 70
- compptr->DCT_h_scaled_size = compptr->DCT_v_scaled_size = DCTSIZE;
-#else
- compptr->DCT_scaled_size = DCTSIZE;
-#endif
- /* Size in DCT blocks */
- compptr->width_in_blocks = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_width * (long)compptr->h_samp_factor,
- (long)(cinfo->max_h_samp_factor * DCTSIZE));
- compptr->height_in_blocks = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_height * (long)compptr->v_samp_factor,
- (long)(cinfo->max_v_samp_factor * DCTSIZE));
- /* Set the first and last MCU columns to decompress from multi-scan images.
- * By default, decompress all of the MCU columns.
- */
- cinfo->master->first_MCU_col[ci] = 0;
- cinfo->master->last_MCU_col[ci] = compptr->width_in_blocks - 1;
- /* downsampled_width and downsampled_height will also be overridden by
- * jdmaster.c if we are doing full decompression. The transcoder library
- * doesn't use these values, but the calling application might.
- */
- /* Size in samples */
- compptr->downsampled_width = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_width * (long)compptr->h_samp_factor,
- (long)cinfo->max_h_samp_factor);
- compptr->downsampled_height = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_height * (long)compptr->v_samp_factor,
- (long)cinfo->max_v_samp_factor);
- /* Mark component needed, until color conversion says otherwise */
- compptr->component_needed = TRUE;
- /* Mark no quantization table yet saved for component */
- compptr->quant_table = NULL;
- }
-
- /* Compute number of fully interleaved MCU rows. */
- cinfo->total_iMCU_rows = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_height,
- (long)(cinfo->max_v_samp_factor * DCTSIZE));
-
- /* Decide whether file contains multiple scans */
- if (cinfo->comps_in_scan < cinfo->num_components || cinfo->progressive_mode)
- cinfo->inputctl->has_multiple_scans = TRUE;
- else
- cinfo->inputctl->has_multiple_scans = FALSE;
-}
-
-
-LOCAL(void)
-per_scan_setup(j_decompress_ptr cinfo)
-/* Do computations that are needed before processing a JPEG scan */
-/* cinfo->comps_in_scan and cinfo->cur_comp_info[] were set from SOS marker */
-{
- int ci, mcublks, tmp;
- jpeg_component_info *compptr;
-
- if (cinfo->comps_in_scan == 1) {
-
- /* Noninterleaved (single-component) scan */
- compptr = cinfo->cur_comp_info[0];
-
- /* Overall image size in MCUs */
- cinfo->MCUs_per_row = compptr->width_in_blocks;
- cinfo->MCU_rows_in_scan = compptr->height_in_blocks;
-
- /* For noninterleaved scan, always one block per MCU */
- compptr->MCU_width = 1;
- compptr->MCU_height = 1;
- compptr->MCU_blocks = 1;
- compptr->MCU_sample_width = compptr->_DCT_scaled_size;
- compptr->last_col_width = 1;
- /* For noninterleaved scans, it is convenient to define last_row_height
- * as the number of block rows present in the last iMCU row.
- */
- tmp = (int)(compptr->height_in_blocks % compptr->v_samp_factor);
- if (tmp == 0) tmp = compptr->v_samp_factor;
- compptr->last_row_height = tmp;
-
- /* Prepare array describing MCU composition */
- cinfo->blocks_in_MCU = 1;
- cinfo->MCU_membership[0] = 0;
-
- } else {
-
- /* Interleaved (multi-component) scan */
- if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN)
- ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan,
- MAX_COMPS_IN_SCAN);
-
- /* Overall image size in MCUs */
- cinfo->MCUs_per_row = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_width,
- (long)(cinfo->max_h_samp_factor * DCTSIZE));
- cinfo->MCU_rows_in_scan = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_height,
- (long)(cinfo->max_v_samp_factor * DCTSIZE));
-
- cinfo->blocks_in_MCU = 0;
-
- for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
- compptr = cinfo->cur_comp_info[ci];
- /* Sampling factors give # of blocks of component in each MCU */
- compptr->MCU_width = compptr->h_samp_factor;
- compptr->MCU_height = compptr->v_samp_factor;
- compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height;
- compptr->MCU_sample_width = compptr->MCU_width *
- compptr->_DCT_scaled_size;
- /* Figure number of non-dummy blocks in last MCU column & row */
- tmp = (int)(compptr->width_in_blocks % compptr->MCU_width);
- if (tmp == 0) tmp = compptr->MCU_width;
- compptr->last_col_width = tmp;
- tmp = (int)(compptr->height_in_blocks % compptr->MCU_height);
- if (tmp == 0) tmp = compptr->MCU_height;
- compptr->last_row_height = tmp;
- /* Prepare array describing MCU composition */
- mcublks = compptr->MCU_blocks;
- if (cinfo->blocks_in_MCU + mcublks > D_MAX_BLOCKS_IN_MCU)
- ERREXIT(cinfo, JERR_BAD_MCU_SIZE);
- while (mcublks-- > 0) {
- cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci;
- }
- }
-
- }
-}
-
-
-/*
- * Save away a copy of the Q-table referenced by each component present
- * in the current scan, unless already saved during a prior scan.
- *
- * In a multiple-scan JPEG file, the encoder could assign different components
- * the same Q-table slot number, but change table definitions between scans
- * so that each component uses a different Q-table. (The IJG encoder is not
- * currently capable of doing this, but other encoders might.) Since we want
- * to be able to dequantize all the components at the end of the file, this
- * means that we have to save away the table actually used for each component.
- * We do this by copying the table at the start of the first scan containing
- * the component.
- * Rec. ITU-T T.81 | ISO/IEC 10918-1 prohibits the encoder from changing the
- * contents of a Q-table slot between scans of a component using that slot. If
- * the encoder does so anyway, this decoder will simply use the Q-table values
- * that were current at the start of the first scan for the component.
- *
- * The decompressor output side looks only at the saved quant tables,
- * not at the current Q-table slots.
- */
-
-LOCAL(void)
-latch_quant_tables(j_decompress_ptr cinfo)
-{
- int ci, qtblno;
- jpeg_component_info *compptr;
- JQUANT_TBL *qtbl;
-
- for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
- compptr = cinfo->cur_comp_info[ci];
- /* No work if we already saved Q-table for this component */
- if (compptr->quant_table != NULL)
- continue;
- /* Make sure specified quantization table is present */
- qtblno = compptr->quant_tbl_no;
- if (qtblno < 0 || qtblno >= NUM_QUANT_TBLS ||
- cinfo->quant_tbl_ptrs[qtblno] == NULL)
- ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno);
- /* OK, save away the quantization table */
- qtbl = (JQUANT_TBL *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- sizeof(JQUANT_TBL));
- memcpy(qtbl, cinfo->quant_tbl_ptrs[qtblno], sizeof(JQUANT_TBL));
- compptr->quant_table = qtbl;
- }
-}
-
-
-/*
- * Initialize the input modules to read a scan of compressed data.
- * The first call to this is done by jdmaster.c after initializing
- * the entire decompressor (during jpeg_start_decompress).
- * Subsequent calls come from consume_markers, below.
- */
-
-METHODDEF(void)
-start_input_pass(j_decompress_ptr cinfo)
-{
- per_scan_setup(cinfo);
- latch_quant_tables(cinfo);
- (*cinfo->entropy->start_pass) (cinfo);
- (*cinfo->coef->start_input_pass) (cinfo);
- cinfo->inputctl->consume_input = cinfo->coef->consume_data;
-}
-
-
-/*
- * Finish up after inputting a compressed-data scan.
- * This is called by the coefficient controller after it's read all
- * the expected data of the scan.
- */
-
-METHODDEF(void)
-finish_input_pass(j_decompress_ptr cinfo)
-{
- cinfo->inputctl->consume_input = consume_markers;
-}
-
-
-/*
- * Read JPEG markers before, between, or after compressed-data scans.
- * Change state as necessary when a new scan is reached.
- * Return value is JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI.
- *
- * The consume_input method pointer points either here or to the
- * coefficient controller's consume_data routine, depending on whether
- * we are reading a compressed data segment or inter-segment markers.
- */
-
-METHODDEF(int)
-consume_markers(j_decompress_ptr cinfo)
-{
- my_inputctl_ptr inputctl = (my_inputctl_ptr)cinfo->inputctl;
- int val;
-
- if (inputctl->pub.eoi_reached) /* After hitting EOI, read no further */
- return JPEG_REACHED_EOI;
-
- val = (*cinfo->marker->read_markers) (cinfo);
-
- switch (val) {
- case JPEG_REACHED_SOS: /* Found SOS */
- if (inputctl->inheaders) { /* 1st SOS */
- initial_setup(cinfo);
- inputctl->inheaders = FALSE;
- /* Note: start_input_pass must be called by jdmaster.c
- * before any more input can be consumed. jdapimin.c is
- * responsible for enforcing this sequencing.
- */
- } else { /* 2nd or later SOS marker */
- if (!inputctl->pub.has_multiple_scans)
- ERREXIT(cinfo, JERR_EOI_EXPECTED); /* Oops, I wasn't expecting this! */
- start_input_pass(cinfo);
- }
- break;
- case JPEG_REACHED_EOI: /* Found EOI */
- inputctl->pub.eoi_reached = TRUE;
- if (inputctl->inheaders) { /* Tables-only datastream, apparently */
- if (cinfo->marker->saw_SOF)
- ERREXIT(cinfo, JERR_SOF_NO_SOS);
- } else {
- /* Prevent infinite loop in coef ctlr's decompress_data routine
- * if user set output_scan_number larger than number of scans.
- */
- if (cinfo->output_scan_number > cinfo->input_scan_number)
- cinfo->output_scan_number = cinfo->input_scan_number;
- }
- break;
- case JPEG_SUSPENDED:
- break;
- }
-
- return val;
-}
-
-
-/*
- * Reset state to begin a fresh datastream.
- */
-
-METHODDEF(void)
-reset_input_controller(j_decompress_ptr cinfo)
-{
- my_inputctl_ptr inputctl = (my_inputctl_ptr)cinfo->inputctl;
-
- inputctl->pub.consume_input = consume_markers;
- inputctl->pub.has_multiple_scans = FALSE; /* "unknown" would be better */
- inputctl->pub.eoi_reached = FALSE;
- inputctl->inheaders = TRUE;
- /* Reset other modules */
- (*cinfo->err->reset_error_mgr) ((j_common_ptr)cinfo);
- (*cinfo->marker->reset_marker_reader) (cinfo);
- /* Reset progression state -- would be cleaner if entropy decoder did this */
- cinfo->coef_bits = NULL;
-}
-
-
-/*
- * Initialize the input controller module.
- * This is called only once, when the decompression object is created.
- */
-
-GLOBAL(void)
-jinit_input_controller(j_decompress_ptr cinfo)
-{
- my_inputctl_ptr inputctl;
-
- /* Create subobject in permanent pool */
- inputctl = (my_inputctl_ptr)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
- sizeof(my_input_controller));
- cinfo->inputctl = (struct jpeg_input_controller *)inputctl;
- /* Initialize method pointers */
- inputctl->pub.consume_input = consume_markers;
- inputctl->pub.reset_input_controller = reset_input_controller;
- inputctl->pub.start_input_pass = start_input_pass;
- inputctl->pub.finish_input_pass = finish_input_pass;
- /* Initialize state: can't use reset_input_controller since we don't
- * want to try to reset other modules yet.
- */
- inputctl->pub.has_multiple_scans = FALSE; /* "unknown" would be better */
- inputctl->pub.eoi_reached = FALSE;
- inputctl->inheaders = TRUE;
-}
diff --git a/contrib/libs/libjpeg-turbo/jdmainct.c b/contrib/libs/libjpeg-turbo/jdmainct.c
deleted file mode 100644
index f466b259f0..0000000000
--- a/contrib/libs/libjpeg-turbo/jdmainct.c
+++ /dev/null
@@ -1,461 +0,0 @@
-/*
- * jdmainct.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2016, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains the main buffer controller for decompression.
- * The main buffer lies between the JPEG decompressor proper and the
- * post-processor; it holds downsampled data in the JPEG colorspace.
- *
- * Note that this code is bypassed in raw-data mode, since the application
- * supplies the equivalent of the main buffer in that case.
- */
-
-#include "jinclude.h"
-#include "jdmainct.h"
-#include "jconfigint.h"
-
-
-/*
- * In the current system design, the main buffer need never be a full-image
- * buffer; any full-height buffers will be found inside the coefficient or
- * postprocessing controllers. Nonetheless, the main controller is not
- * trivial. Its responsibility is to provide context rows for upsampling/
- * rescaling, and doing this in an efficient fashion is a bit tricky.
- *
- * Postprocessor input data is counted in "row groups". A row group
- * is defined to be (v_samp_factor * DCT_scaled_size / min_DCT_scaled_size)
- * sample rows of each component. (We require DCT_scaled_size values to be
- * chosen such that these numbers are integers. In practice DCT_scaled_size
- * values will likely be powers of two, so we actually have the stronger
- * condition that DCT_scaled_size / min_DCT_scaled_size is an integer.)
- * Upsampling will typically produce max_v_samp_factor pixel rows from each
- * row group (times any additional scale factor that the upsampler is
- * applying).
- *
- * The coefficient controller will deliver data to us one iMCU row at a time;
- * each iMCU row contains v_samp_factor * DCT_scaled_size sample rows, or
- * exactly min_DCT_scaled_size row groups. (This amount of data corresponds
- * to one row of MCUs when the image is fully interleaved.) Note that the
- * number of sample rows varies across components, but the number of row
- * groups does not. Some garbage sample rows may be included in the last iMCU
- * row at the bottom of the image.
- *
- * Depending on the vertical scaling algorithm used, the upsampler may need
- * access to the sample row(s) above and below its current input row group.
- * The upsampler is required to set need_context_rows TRUE at global selection
- * time if so. When need_context_rows is FALSE, this controller can simply
- * obtain one iMCU row at a time from the coefficient controller and dole it
- * out as row groups to the postprocessor.
- *
- * When need_context_rows is TRUE, this controller guarantees that the buffer
- * passed to postprocessing contains at least one row group's worth of samples
- * above and below the row group(s) being processed. Note that the context
- * rows "above" the first passed row group appear at negative row offsets in
- * the passed buffer. At the top and bottom of the image, the required
- * context rows are manufactured by duplicating the first or last real sample
- * row; this avoids having special cases in the upsampling inner loops.
- *
- * The amount of context is fixed at one row group just because that's a
- * convenient number for this controller to work with. The existing
- * upsamplers really only need one sample row of context. An upsampler
- * supporting arbitrary output rescaling might wish for more than one row
- * group of context when shrinking the image; tough, we don't handle that.
- * (This is justified by the assumption that downsizing will be handled mostly
- * by adjusting the DCT_scaled_size values, so that the actual scale factor at
- * the upsample step needn't be much less than one.)
- *
- * To provide the desired context, we have to retain the last two row groups
- * of one iMCU row while reading in the next iMCU row. (The last row group
- * can't be processed until we have another row group for its below-context,
- * and so we have to save the next-to-last group too for its above-context.)
- * We could do this most simply by copying data around in our buffer, but
- * that'd be very slow. We can avoid copying any data by creating a rather
- * strange pointer structure. Here's how it works. We allocate a workspace
- * consisting of M+2 row groups (where M = min_DCT_scaled_size is the number
- * of row groups per iMCU row). We create two sets of redundant pointers to
- * the workspace. Labeling the physical row groups 0 to M+1, the synthesized
- * pointer lists look like this:
- * M+1 M-1
- * master pointer --> 0 master pointer --> 0
- * 1 1
- * ... ...
- * M-3 M-3
- * M-2 M
- * M-1 M+1
- * M M-2
- * M+1 M-1
- * 0 0
- * We read alternate iMCU rows using each master pointer; thus the last two
- * row groups of the previous iMCU row remain un-overwritten in the workspace.
- * The pointer lists are set up so that the required context rows appear to
- * be adjacent to the proper places when we pass the pointer lists to the
- * upsampler.
- *
- * The above pictures describe the normal state of the pointer lists.
- * At top and bottom of the image, we diddle the pointer lists to duplicate
- * the first or last sample row as necessary (this is cheaper than copying
- * sample rows around).
- *
- * This scheme breaks down if M < 2, ie, min_DCT_scaled_size is 1. In that
- * situation each iMCU row provides only one row group so the buffering logic
- * must be different (eg, we must read two iMCU rows before we can emit the
- * first row group). For now, we simply do not support providing context
- * rows when min_DCT_scaled_size is 1. That combination seems unlikely to
- * be worth providing --- if someone wants a 1/8th-size preview, they probably
- * want it quick and dirty, so a context-free upsampler is sufficient.
- */
-
-
-/* Forward declarations */
-METHODDEF(void) process_data_simple_main(j_decompress_ptr cinfo,
- JSAMPARRAY output_buf,
- JDIMENSION *out_row_ctr,
- JDIMENSION out_rows_avail);
-METHODDEF(void) process_data_context_main(j_decompress_ptr cinfo,
- JSAMPARRAY output_buf,
- JDIMENSION *out_row_ctr,
- JDIMENSION out_rows_avail);
-#ifdef QUANT_2PASS_SUPPORTED
-METHODDEF(void) process_data_crank_post(j_decompress_ptr cinfo,
- JSAMPARRAY output_buf,
- JDIMENSION *out_row_ctr,
- JDIMENSION out_rows_avail);
-#endif
-
-
-LOCAL(void)
-alloc_funny_pointers(j_decompress_ptr cinfo)
-/* Allocate space for the funny pointer lists.
- * This is done only once, not once per pass.
- */
-{
- my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
- int ci, rgroup;
- int M = cinfo->_min_DCT_scaled_size;
- jpeg_component_info *compptr;
- JSAMPARRAY xbuf;
-
- /* Get top-level space for component array pointers.
- * We alloc both arrays with one call to save a few cycles.
- */
- main_ptr->xbuffer[0] = (JSAMPIMAGE)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- cinfo->num_components * 2 * sizeof(JSAMPARRAY));
- main_ptr->xbuffer[1] = main_ptr->xbuffer[0] + cinfo->num_components;
-
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
- ci++, compptr++) {
- rgroup = (compptr->v_samp_factor * compptr->_DCT_scaled_size) /
- cinfo->_min_DCT_scaled_size; /* height of a row group of component */
- /* Get space for pointer lists --- M+4 row groups in each list.
- * We alloc both pointer lists with one call to save a few cycles.
- */
- xbuf = (JSAMPARRAY)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- 2 * (rgroup * (M + 4)) * sizeof(JSAMPROW));
- xbuf += rgroup; /* want one row group at negative offsets */
- main_ptr->xbuffer[0][ci] = xbuf;
- xbuf += rgroup * (M + 4);
- main_ptr->xbuffer[1][ci] = xbuf;
- }
-}
-
-
-LOCAL(void)
-make_funny_pointers(j_decompress_ptr cinfo)
-/* Create the funny pointer lists discussed in the comments above.
- * The actual workspace is already allocated (in main_ptr->buffer),
- * and the space for the pointer lists is allocated too.
- * This routine just fills in the curiously ordered lists.
- * This will be repeated at the beginning of each pass.
- */
-{
- my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
- int ci, i, rgroup;
- int M = cinfo->_min_DCT_scaled_size;
- jpeg_component_info *compptr;
- JSAMPARRAY buf, xbuf0, xbuf1;
-
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
- ci++, compptr++) {
- rgroup = (compptr->v_samp_factor * compptr->_DCT_scaled_size) /
- cinfo->_min_DCT_scaled_size; /* height of a row group of component */
- xbuf0 = main_ptr->xbuffer[0][ci];
- xbuf1 = main_ptr->xbuffer[1][ci];
- /* First copy the workspace pointers as-is */
- buf = main_ptr->buffer[ci];
- for (i = 0; i < rgroup * (M + 2); i++) {
- xbuf0[i] = xbuf1[i] = buf[i];
- }
- /* In the second list, put the last four row groups in swapped order */
- for (i = 0; i < rgroup * 2; i++) {
- xbuf1[rgroup * (M - 2) + i] = buf[rgroup * M + i];
- xbuf1[rgroup * M + i] = buf[rgroup * (M - 2) + i];
- }
- /* The wraparound pointers at top and bottom will be filled later
- * (see set_wraparound_pointers, below). Initially we want the "above"
- * pointers to duplicate the first actual data line. This only needs
- * to happen in xbuffer[0].
- */
- for (i = 0; i < rgroup; i++) {
- xbuf0[i - rgroup] = xbuf0[0];
- }
- }
-}
-
-
-LOCAL(void)
-set_bottom_pointers(j_decompress_ptr cinfo)
-/* Change the pointer lists to duplicate the last sample row at the bottom
- * of the image. whichptr indicates which xbuffer holds the final iMCU row.
- * Also sets rowgroups_avail to indicate number of nondummy row groups in row.
- */
-{
- my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
- int ci, i, rgroup, iMCUheight, rows_left;
- jpeg_component_info *compptr;
- JSAMPARRAY xbuf;
-
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
- ci++, compptr++) {
- /* Count sample rows in one iMCU row and in one row group */
- iMCUheight = compptr->v_samp_factor * compptr->_DCT_scaled_size;
- rgroup = iMCUheight / cinfo->_min_DCT_scaled_size;
- /* Count nondummy sample rows remaining for this component */
- rows_left = (int)(compptr->downsampled_height % (JDIMENSION)iMCUheight);
- if (rows_left == 0) rows_left = iMCUheight;
- /* Count nondummy row groups. Should get same answer for each component,
- * so we need only do it once.
- */
- if (ci == 0) {
- main_ptr->rowgroups_avail = (JDIMENSION)((rows_left - 1) / rgroup + 1);
- }
- /* Duplicate the last real sample row rgroup*2 times; this pads out the
- * last partial rowgroup and ensures at least one full rowgroup of context.
- */
- xbuf = main_ptr->xbuffer[main_ptr->whichptr][ci];
- for (i = 0; i < rgroup * 2; i++) {
- xbuf[rows_left + i] = xbuf[rows_left - 1];
- }
- }
-}
-
-
-/*
- * Initialize for a processing pass.
- */
-
-METHODDEF(void)
-start_pass_main(j_decompress_ptr cinfo, J_BUF_MODE pass_mode)
-{
- my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
-
- switch (pass_mode) {
- case JBUF_PASS_THRU:
- if (cinfo->upsample->need_context_rows) {
- main_ptr->pub.process_data = process_data_context_main;
- make_funny_pointers(cinfo); /* Create the xbuffer[] lists */
- main_ptr->whichptr = 0; /* Read first iMCU row into xbuffer[0] */
- main_ptr->context_state = CTX_PREPARE_FOR_IMCU;
- main_ptr->iMCU_row_ctr = 0;
- } else {
- /* Simple case with no context needed */
- main_ptr->pub.process_data = process_data_simple_main;
- }
- main_ptr->buffer_full = FALSE; /* Mark buffer empty */
- main_ptr->rowgroup_ctr = 0;
- break;
-#ifdef QUANT_2PASS_SUPPORTED
- case JBUF_CRANK_DEST:
- /* For last pass of 2-pass quantization, just crank the postprocessor */
- main_ptr->pub.process_data = process_data_crank_post;
- break;
-#endif
- default:
- ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
- break;
- }
-}
-
-
-/*
- * Process some data.
- * This handles the simple case where no context is required.
- */
-
-METHODDEF(void)
-process_data_simple_main(j_decompress_ptr cinfo, JSAMPARRAY output_buf,
- JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
-{
- my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
- JDIMENSION rowgroups_avail;
-
- /* Read input data if we haven't filled the main buffer yet */
- if (!main_ptr->buffer_full) {
- if (!(*cinfo->coef->decompress_data) (cinfo, main_ptr->buffer))
- return; /* suspension forced, can do nothing more */
- main_ptr->buffer_full = TRUE; /* OK, we have an iMCU row to work with */
- }
-
- /* There are always min_DCT_scaled_size row groups in an iMCU row. */
- rowgroups_avail = (JDIMENSION)cinfo->_min_DCT_scaled_size;
- /* Note: at the bottom of the image, we may pass extra garbage row groups
- * to the postprocessor. The postprocessor has to check for bottom
- * of image anyway (at row resolution), so no point in us doing it too.
- */
-
- /* Feed the postprocessor */
- (*cinfo->post->post_process_data) (cinfo, main_ptr->buffer,
- &main_ptr->rowgroup_ctr, rowgroups_avail,
- output_buf, out_row_ctr, out_rows_avail);
-
- /* Has postprocessor consumed all the data yet? If so, mark buffer empty */
- if (main_ptr->rowgroup_ctr >= rowgroups_avail) {
- main_ptr->buffer_full = FALSE;
- main_ptr->rowgroup_ctr = 0;
- }
-}
-
-
-/*
- * Process some data.
- * This handles the case where context rows must be provided.
- */
-
-METHODDEF(void)
-process_data_context_main(j_decompress_ptr cinfo, JSAMPARRAY output_buf,
- JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
-{
- my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
-
- /* Read input data if we haven't filled the main buffer yet */
- if (!main_ptr->buffer_full) {
- if (!(*cinfo->coef->decompress_data) (cinfo,
- main_ptr->xbuffer[main_ptr->whichptr]))
- return; /* suspension forced, can do nothing more */
- main_ptr->buffer_full = TRUE; /* OK, we have an iMCU row to work with */
- main_ptr->iMCU_row_ctr++; /* count rows received */
- }
-
- /* Postprocessor typically will not swallow all the input data it is handed
- * in one call (due to filling the output buffer first). Must be prepared
- * to exit and restart. This switch lets us keep track of how far we got.
- * Note that each case falls through to the next on successful completion.
- */
- switch (main_ptr->context_state) {
- case CTX_POSTPONED_ROW:
- /* Call postprocessor using previously set pointers for postponed row */
- (*cinfo->post->post_process_data) (cinfo,
- main_ptr->xbuffer[main_ptr->whichptr],
- &main_ptr->rowgroup_ctr,
- main_ptr->rowgroups_avail, output_buf,
- out_row_ctr, out_rows_avail);
- if (main_ptr->rowgroup_ctr < main_ptr->rowgroups_avail)
- return; /* Need to suspend */
- main_ptr->context_state = CTX_PREPARE_FOR_IMCU;
- if (*out_row_ctr >= out_rows_avail)
- return; /* Postprocessor exactly filled output buf */
- FALLTHROUGH /*FALLTHROUGH*/
- case CTX_PREPARE_FOR_IMCU:
- /* Prepare to process first M-1 row groups of this iMCU row */
- main_ptr->rowgroup_ctr = 0;
- main_ptr->rowgroups_avail = (JDIMENSION)(cinfo->_min_DCT_scaled_size - 1);
- /* Check for bottom of image: if so, tweak pointers to "duplicate"
- * the last sample row, and adjust rowgroups_avail to ignore padding rows.
- */
- if (main_ptr->iMCU_row_ctr == cinfo->total_iMCU_rows)
- set_bottom_pointers(cinfo);
- main_ptr->context_state = CTX_PROCESS_IMCU;
- FALLTHROUGH /*FALLTHROUGH*/
- case CTX_PROCESS_IMCU:
- /* Call postprocessor using previously set pointers */
- (*cinfo->post->post_process_data) (cinfo,
- main_ptr->xbuffer[main_ptr->whichptr],
- &main_ptr->rowgroup_ctr,
- main_ptr->rowgroups_avail, output_buf,
- out_row_ctr, out_rows_avail);
- if (main_ptr->rowgroup_ctr < main_ptr->rowgroups_avail)
- return; /* Need to suspend */
- /* After the first iMCU, change wraparound pointers to normal state */
- if (main_ptr->iMCU_row_ctr == 1)
- set_wraparound_pointers(cinfo);
- /* Prepare to load new iMCU row using other xbuffer list */
- main_ptr->whichptr ^= 1; /* 0=>1 or 1=>0 */
- main_ptr->buffer_full = FALSE;
- /* Still need to process last row group of this iMCU row, */
- /* which is saved at index M+1 of the other xbuffer */
- main_ptr->rowgroup_ctr = (JDIMENSION)(cinfo->_min_DCT_scaled_size + 1);
- main_ptr->rowgroups_avail = (JDIMENSION)(cinfo->_min_DCT_scaled_size + 2);
- main_ptr->context_state = CTX_POSTPONED_ROW;
- }
-}
-
-
-/*
- * Process some data.
- * Final pass of two-pass quantization: just call the postprocessor.
- * Source data will be the postprocessor controller's internal buffer.
- */
-
-#ifdef QUANT_2PASS_SUPPORTED
-
-METHODDEF(void)
-process_data_crank_post(j_decompress_ptr cinfo, JSAMPARRAY output_buf,
- JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
-{
- (*cinfo->post->post_process_data) (cinfo, (JSAMPIMAGE)NULL,
- (JDIMENSION *)NULL, (JDIMENSION)0,
- output_buf, out_row_ctr, out_rows_avail);
-}
-
-#endif /* QUANT_2PASS_SUPPORTED */
-
-
-/*
- * Initialize main buffer controller.
- */
-
-GLOBAL(void)
-jinit_d_main_controller(j_decompress_ptr cinfo, boolean need_full_buffer)
-{
- my_main_ptr main_ptr;
- int ci, rgroup, ngroups;
- jpeg_component_info *compptr;
-
- main_ptr = (my_main_ptr)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- sizeof(my_main_controller));
- cinfo->main = (struct jpeg_d_main_controller *)main_ptr;
- main_ptr->pub.start_pass = start_pass_main;
-
- if (need_full_buffer) /* shouldn't happen */
- ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
-
- /* Allocate the workspace.
- * ngroups is the number of row groups we need.
- */
- if (cinfo->upsample->need_context_rows) {
- if (cinfo->_min_DCT_scaled_size < 2) /* unsupported, see comments above */
- ERREXIT(cinfo, JERR_NOTIMPL);
- alloc_funny_pointers(cinfo); /* Alloc space for xbuffer[] lists */
- ngroups = cinfo->_min_DCT_scaled_size + 2;
- } else {
- ngroups = cinfo->_min_DCT_scaled_size;
- }
-
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
- ci++, compptr++) {
- rgroup = (compptr->v_samp_factor * compptr->_DCT_scaled_size) /
- cinfo->_min_DCT_scaled_size; /* height of a row group of component */
- main_ptr->buffer[ci] = (*cinfo->mem->alloc_sarray)
- ((j_common_ptr)cinfo, JPOOL_IMAGE,
- compptr->width_in_blocks * compptr->_DCT_scaled_size,
- (JDIMENSION)(rgroup * ngroups));
- }
-}
diff --git a/contrib/libs/libjpeg-turbo/jdmainct.h b/contrib/libs/libjpeg-turbo/jdmainct.h
deleted file mode 100644
index 37b201ca88..0000000000
--- a/contrib/libs/libjpeg-turbo/jdmainct.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * jdmainct.h
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- */
-
-#define JPEG_INTERNALS
-#include "jpeglib.h"
-#include "jpegcomp.h"
-
-
-/* Private buffer controller object */
-
-typedef struct {
- struct jpeg_d_main_controller pub; /* public fields */
-
- /* Pointer to allocated workspace (M or M+2 row groups). */
- JSAMPARRAY buffer[MAX_COMPONENTS];
-
- boolean buffer_full; /* Have we gotten an iMCU row from decoder? */
- JDIMENSION rowgroup_ctr; /* counts row groups output to postprocessor */
-
- /* Remaining fields are only used in the context case. */
-
- /* These are the master pointers to the funny-order pointer lists. */
- JSAMPIMAGE xbuffer[2]; /* pointers to weird pointer lists */
-
- int whichptr; /* indicates which pointer set is now in use */
- int context_state; /* process_data state machine status */
- JDIMENSION rowgroups_avail; /* row groups available to postprocessor */
- JDIMENSION iMCU_row_ctr; /* counts iMCU rows to detect image top/bot */
-} my_main_controller;
-
-typedef my_main_controller *my_main_ptr;
-
-
-/* context_state values: */
-#define CTX_PREPARE_FOR_IMCU 0 /* need to prepare for MCU row */
-#define CTX_PROCESS_IMCU 1 /* feeding iMCU to postprocessor */
-#define CTX_POSTPONED_ROW 2 /* feeding postponed row group */
-
-
-LOCAL(void)
-set_wraparound_pointers(j_decompress_ptr cinfo)
-/* Set up the "wraparound" pointers at top and bottom of the pointer lists.
- * This changes the pointer list state from top-of-image to the normal state.
- */
-{
- my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
- int ci, i, rgroup;
- int M = cinfo->_min_DCT_scaled_size;
- jpeg_component_info *compptr;
- JSAMPARRAY xbuf0, xbuf1;
-
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
- ci++, compptr++) {
- rgroup = (compptr->v_samp_factor * compptr->_DCT_scaled_size) /
- cinfo->_min_DCT_scaled_size; /* height of a row group of component */
- xbuf0 = main_ptr->xbuffer[0][ci];
- xbuf1 = main_ptr->xbuffer[1][ci];
- for (i = 0; i < rgroup; i++) {
- xbuf0[i - rgroup] = xbuf0[rgroup * (M + 1) + i];
- xbuf1[i - rgroup] = xbuf1[rgroup * (M + 1) + i];
- xbuf0[rgroup * (M + 2) + i] = xbuf0[i];
- xbuf1[rgroup * (M + 2) + i] = xbuf1[i];
- }
- }
-}
diff --git a/contrib/libs/libjpeg-turbo/jdmarker.c b/contrib/libs/libjpeg-turbo/jdmarker.c
deleted file mode 100644
index f7eba615fd..0000000000
--- a/contrib/libs/libjpeg-turbo/jdmarker.c
+++ /dev/null
@@ -1,1374 +0,0 @@
-/*
- * jdmarker.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1998, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2012, 2015, 2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains routines to decode JPEG datastream markers.
- * Most of the complexity arises from our desire to support input
- * suspension: if not all of the data for a marker is available,
- * we must exit back to the application. On resumption, we reprocess
- * the marker.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-
-
-typedef enum { /* JPEG marker codes */
- M_SOF0 = 0xc0,
- M_SOF1 = 0xc1,
- M_SOF2 = 0xc2,
- M_SOF3 = 0xc3,
-
- M_SOF5 = 0xc5,
- M_SOF6 = 0xc6,
- M_SOF7 = 0xc7,
-
- M_JPG = 0xc8,
- M_SOF9 = 0xc9,
- M_SOF10 = 0xca,
- M_SOF11 = 0xcb,
-
- M_SOF13 = 0xcd,
- M_SOF14 = 0xce,
- M_SOF15 = 0xcf,
-
- M_DHT = 0xc4,
-
- M_DAC = 0xcc,
-
- M_RST0 = 0xd0,
- M_RST1 = 0xd1,
- M_RST2 = 0xd2,
- M_RST3 = 0xd3,
- M_RST4 = 0xd4,
- M_RST5 = 0xd5,
- M_RST6 = 0xd6,
- M_RST7 = 0xd7,
-
- M_SOI = 0xd8,
- M_EOI = 0xd9,
- M_SOS = 0xda,
- M_DQT = 0xdb,
- M_DNL = 0xdc,
- M_DRI = 0xdd,
- M_DHP = 0xde,
- M_EXP = 0xdf,
-
- M_APP0 = 0xe0,
- M_APP1 = 0xe1,
- M_APP2 = 0xe2,
- M_APP3 = 0xe3,
- M_APP4 = 0xe4,
- M_APP5 = 0xe5,
- M_APP6 = 0xe6,
- M_APP7 = 0xe7,
- M_APP8 = 0xe8,
- M_APP9 = 0xe9,
- M_APP10 = 0xea,
- M_APP11 = 0xeb,
- M_APP12 = 0xec,
- M_APP13 = 0xed,
- M_APP14 = 0xee,
- M_APP15 = 0xef,
-
- M_JPG0 = 0xf0,
- M_JPG13 = 0xfd,
- M_COM = 0xfe,
-
- M_TEM = 0x01,
-
- M_ERROR = 0x100
-} JPEG_MARKER;
-
-
-/* Private state */
-
-typedef struct {
- struct jpeg_marker_reader pub; /* public fields */
-
- /* Application-overridable marker processing methods */
- jpeg_marker_parser_method process_COM;
- jpeg_marker_parser_method process_APPn[16];
-
- /* Limit on marker data length to save for each marker type */
- unsigned int length_limit_COM;
- unsigned int length_limit_APPn[16];
-
- /* Status of COM/APPn marker saving */
- jpeg_saved_marker_ptr cur_marker; /* NULL if not processing a marker */
- unsigned int bytes_read; /* data bytes read so far in marker */
- /* Note: cur_marker is not linked into marker_list until it's all read. */
-} my_marker_reader;
-
-typedef my_marker_reader *my_marker_ptr;
-
-
-/*
- * Macros for fetching data from the data source module.
- *
- * At all times, cinfo->src->next_input_byte and ->bytes_in_buffer reflect
- * the current restart point; we update them only when we have reached a
- * suitable place to restart if a suspension occurs.
- */
-
-/* Declare and initialize local copies of input pointer/count */
-#define INPUT_VARS(cinfo) \
- struct jpeg_source_mgr *datasrc = (cinfo)->src; \
- const JOCTET *next_input_byte = datasrc->next_input_byte; \
- size_t bytes_in_buffer = datasrc->bytes_in_buffer
-
-/* Unload the local copies --- do this only at a restart boundary */
-#define INPUT_SYNC(cinfo) \
- ( datasrc->next_input_byte = next_input_byte, \
- datasrc->bytes_in_buffer = bytes_in_buffer )
-
-/* Reload the local copies --- used only in MAKE_BYTE_AVAIL */
-#define INPUT_RELOAD(cinfo) \
- ( next_input_byte = datasrc->next_input_byte, \
- bytes_in_buffer = datasrc->bytes_in_buffer )
-
-/* Internal macro for INPUT_BYTE and INPUT_2BYTES: make a byte available.
- * Note we do *not* do INPUT_SYNC before calling fill_input_buffer,
- * but we must reload the local copies after a successful fill.
- */
-#define MAKE_BYTE_AVAIL(cinfo, action) \
- if (bytes_in_buffer == 0) { \
- if (!(*datasrc->fill_input_buffer) (cinfo)) \
- { action; } \
- INPUT_RELOAD(cinfo); \
- }
-
-/* Read a byte into variable V.
- * If must suspend, take the specified action (typically "return FALSE").
- */
-#define INPUT_BYTE(cinfo, V, action) \
- MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
- bytes_in_buffer--; \
- V = *next_input_byte++; )
-
-/* As above, but read two bytes interpreted as an unsigned 16-bit integer.
- * V should be declared unsigned int or perhaps JLONG.
- */
-#define INPUT_2BYTES(cinfo, V, action) \
- MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
- bytes_in_buffer--; \
- V = ((unsigned int)(*next_input_byte++)) << 8; \
- MAKE_BYTE_AVAIL(cinfo, action); \
- bytes_in_buffer--; \
- V += *next_input_byte++; )
-
-
-/*
- * Routines to process JPEG markers.
- *
- * Entry condition: JPEG marker itself has been read and its code saved
- * in cinfo->unread_marker; input restart point is just after the marker.
- *
- * Exit: if return TRUE, have read and processed any parameters, and have
- * updated the restart point to point after the parameters.
- * If return FALSE, was forced to suspend before reaching end of
- * marker parameters; restart point has not been moved. Same routine
- * will be called again after application supplies more input data.
- *
- * This approach to suspension assumes that all of a marker's parameters
- * can fit into a single input bufferload. This should hold for "normal"
- * markers. Some COM/APPn markers might have large parameter segments
- * that might not fit. If we are simply dropping such a marker, we use
- * skip_input_data to get past it, and thereby put the problem on the
- * source manager's shoulders. If we are saving the marker's contents
- * into memory, we use a slightly different convention: when forced to
- * suspend, the marker processor updates the restart point to the end of
- * what it's consumed (ie, the end of the buffer) before returning FALSE.
- * On resumption, cinfo->unread_marker still contains the marker code,
- * but the data source will point to the next chunk of marker data.
- * The marker processor must retain internal state to deal with this.
- *
- * Note that we don't bother to avoid duplicate trace messages if a
- * suspension occurs within marker parameters. Other side effects
- * require more care.
- */
-
-
-LOCAL(boolean)
-get_soi(j_decompress_ptr cinfo)
-/* Process an SOI marker */
-{
- int i;
-
- TRACEMS(cinfo, 1, JTRC_SOI);
-
- if (cinfo->marker->saw_SOI)
- ERREXIT(cinfo, JERR_SOI_DUPLICATE);
-
- /* Reset all parameters that are defined to be reset by SOI */
-
- for (i = 0; i < NUM_ARITH_TBLS; i++) {
- cinfo->arith_dc_L[i] = 0;
- cinfo->arith_dc_U[i] = 1;
- cinfo->arith_ac_K[i] = 5;
- }
- cinfo->restart_interval = 0;
-
- /* Set initial assumptions for colorspace etc */
-
- cinfo->jpeg_color_space = JCS_UNKNOWN;
- cinfo->CCIR601_sampling = FALSE; /* Assume non-CCIR sampling??? */
-
- cinfo->saw_JFIF_marker = FALSE;
- cinfo->JFIF_major_version = 1; /* set default JFIF APP0 values */
- cinfo->JFIF_minor_version = 1;
- cinfo->density_unit = 0;
- cinfo->X_density = 1;
- cinfo->Y_density = 1;
- cinfo->saw_Adobe_marker = FALSE;
- cinfo->Adobe_transform = 0;
-
- cinfo->marker->saw_SOI = TRUE;
-
- return TRUE;
-}
-
-
-LOCAL(boolean)
-get_sof(j_decompress_ptr cinfo, boolean is_prog, boolean is_arith)
-/* Process a SOFn marker */
-{
- JLONG length;
- int c, ci;
- jpeg_component_info *compptr;
- INPUT_VARS(cinfo);
-
- cinfo->progressive_mode = is_prog;
- cinfo->arith_code = is_arith;
-
- INPUT_2BYTES(cinfo, length, return FALSE);
-
- INPUT_BYTE(cinfo, cinfo->data_precision, return FALSE);
- INPUT_2BYTES(cinfo, cinfo->image_height, return FALSE);
- INPUT_2BYTES(cinfo, cinfo->image_width, return FALSE);
- INPUT_BYTE(cinfo, cinfo->num_components, return FALSE);
-
- length -= 8;
-
- TRACEMS4(cinfo, 1, JTRC_SOF, cinfo->unread_marker,
- (int)cinfo->image_width, (int)cinfo->image_height,
- cinfo->num_components);
-
- if (cinfo->marker->saw_SOF)
- ERREXIT(cinfo, JERR_SOF_DUPLICATE);
-
- /* We don't support files in which the image height is initially specified */
- /* as 0 and is later redefined by DNL. As long as we have to check that, */
- /* might as well have a general sanity check. */
- if (cinfo->image_height <= 0 || cinfo->image_width <= 0 ||
- cinfo->num_components <= 0)
- ERREXIT(cinfo, JERR_EMPTY_IMAGE);
-
- if (length != (cinfo->num_components * 3))
- ERREXIT(cinfo, JERR_BAD_LENGTH);
-
- if (cinfo->comp_info == NULL) /* do only once, even if suspend */
- cinfo->comp_info = (jpeg_component_info *)(*cinfo->mem->alloc_small)
- ((j_common_ptr)cinfo, JPOOL_IMAGE,
- cinfo->num_components * sizeof(jpeg_component_info));
-
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
- ci++, compptr++) {
- compptr->component_index = ci;
- INPUT_BYTE(cinfo, compptr->component_id, return FALSE);
- INPUT_BYTE(cinfo, c, return FALSE);
- compptr->h_samp_factor = (c >> 4) & 15;
- compptr->v_samp_factor = (c ) & 15;
- INPUT_BYTE(cinfo, compptr->quant_tbl_no, return FALSE);
-
- TRACEMS4(cinfo, 1, JTRC_SOF_COMPONENT,
- compptr->component_id, compptr->h_samp_factor,
- compptr->v_samp_factor, compptr->quant_tbl_no);
- }
-
- cinfo->marker->saw_SOF = TRUE;
-
- INPUT_SYNC(cinfo);
- return TRUE;
-}
-
-
-LOCAL(boolean)
-get_sos(j_decompress_ptr cinfo)
-/* Process a SOS marker */
-{
- JLONG length;
- int i, ci, n, c, cc, pi;
- jpeg_component_info *compptr;
- INPUT_VARS(cinfo);
-
- if (!cinfo->marker->saw_SOF)
- ERREXIT(cinfo, JERR_SOS_NO_SOF);
-
- INPUT_2BYTES(cinfo, length, return FALSE);
-
- INPUT_BYTE(cinfo, n, return FALSE); /* Number of components */
-
- TRACEMS1(cinfo, 1, JTRC_SOS, n);
-
- if (length != (n * 2 + 6) || n < 1 || n > MAX_COMPS_IN_SCAN)
- ERREXIT(cinfo, JERR_BAD_LENGTH);
-
- cinfo->comps_in_scan = n;
-
- /* Collect the component-spec parameters */
-
- for (i = 0; i < MAX_COMPS_IN_SCAN; i++)
- cinfo->cur_comp_info[i] = NULL;
-
- for (i = 0; i < n; i++) {
- INPUT_BYTE(cinfo, cc, return FALSE);
- INPUT_BYTE(cinfo, c, return FALSE);
-
- for (ci = 0, compptr = cinfo->comp_info;
- ci < cinfo->num_components && ci < MAX_COMPS_IN_SCAN;
- ci++, compptr++) {
- if (cc == compptr->component_id && !cinfo->cur_comp_info[ci])
- goto id_found;
- }
-
- ERREXIT1(cinfo, JERR_BAD_COMPONENT_ID, cc);
-
-id_found:
-
- cinfo->cur_comp_info[i] = compptr;
- compptr->dc_tbl_no = (c >> 4) & 15;
- compptr->ac_tbl_no = (c ) & 15;
-
- TRACEMS3(cinfo, 1, JTRC_SOS_COMPONENT, cc,
- compptr->dc_tbl_no, compptr->ac_tbl_no);
-
- /* This CSi (cc) should differ from the previous CSi */
- for (pi = 0; pi < i; pi++) {
- if (cinfo->cur_comp_info[pi] == compptr) {
- ERREXIT1(cinfo, JERR_BAD_COMPONENT_ID, cc);
- }
- }
- }
-
- /* Collect the additional scan parameters Ss, Se, Ah/Al. */
- INPUT_BYTE(cinfo, c, return FALSE);
- cinfo->Ss = c;
- INPUT_BYTE(cinfo, c, return FALSE);
- cinfo->Se = c;
- INPUT_BYTE(cinfo, c, return FALSE);
- cinfo->Ah = (c >> 4) & 15;
- cinfo->Al = (c ) & 15;
-
- TRACEMS4(cinfo, 1, JTRC_SOS_PARAMS, cinfo->Ss, cinfo->Se,
- cinfo->Ah, cinfo->Al);
-
- /* Prepare to scan data & restart markers */
- cinfo->marker->next_restart_num = 0;
-
- /* Count another SOS marker */
- cinfo->input_scan_number++;
-
- INPUT_SYNC(cinfo);
- return TRUE;
-}
-
-
-#ifdef D_ARITH_CODING_SUPPORTED
-
-LOCAL(boolean)
-get_dac(j_decompress_ptr cinfo)
-/* Process a DAC marker */
-{
- JLONG length;
- int index, val;
- INPUT_VARS(cinfo);
-
- INPUT_2BYTES(cinfo, length, return FALSE);
- length -= 2;
-
- while (length > 0) {
- INPUT_BYTE(cinfo, index, return FALSE);
- INPUT_BYTE(cinfo, val, return FALSE);
-
- length -= 2;
-
- TRACEMS2(cinfo, 1, JTRC_DAC, index, val);
-
- if (index < 0 || index >= (2 * NUM_ARITH_TBLS))
- ERREXIT1(cinfo, JERR_DAC_INDEX, index);
-
- if (index >= NUM_ARITH_TBLS) { /* define AC table */
- cinfo->arith_ac_K[index - NUM_ARITH_TBLS] = (UINT8)val;
- } else { /* define DC table */
- cinfo->arith_dc_L[index] = (UINT8)(val & 0x0F);
- cinfo->arith_dc_U[index] = (UINT8)(val >> 4);
- if (cinfo->arith_dc_L[index] > cinfo->arith_dc_U[index])
- ERREXIT1(cinfo, JERR_DAC_VALUE, val);
- }
- }
-
- if (length != 0)
- ERREXIT(cinfo, JERR_BAD_LENGTH);
-
- INPUT_SYNC(cinfo);
- return TRUE;
-}
-
-#else /* !D_ARITH_CODING_SUPPORTED */
-
-#define get_dac(cinfo) skip_variable(cinfo)
-
-#endif /* D_ARITH_CODING_SUPPORTED */
-
-
-LOCAL(boolean)
-get_dht(j_decompress_ptr cinfo)
-/* Process a DHT marker */
-{
- JLONG length;
- UINT8 bits[17];
- UINT8 huffval[256];
- int i, index, count;
- JHUFF_TBL **htblptr;
- INPUT_VARS(cinfo);
-
- INPUT_2BYTES(cinfo, length, return FALSE);
- length -= 2;
-
- while (length > 16) {
- INPUT_BYTE(cinfo, index, return FALSE);
-
- TRACEMS1(cinfo, 1, JTRC_DHT, index);
-
- bits[0] = 0;
- count = 0;
- for (i = 1; i <= 16; i++) {
- INPUT_BYTE(cinfo, bits[i], return FALSE);
- count += bits[i];
- }
-
- length -= 1 + 16;
-
- TRACEMS8(cinfo, 2, JTRC_HUFFBITS,
- bits[1], bits[2], bits[3], bits[4],
- bits[5], bits[6], bits[7], bits[8]);
- TRACEMS8(cinfo, 2, JTRC_HUFFBITS,
- bits[9], bits[10], bits[11], bits[12],
- bits[13], bits[14], bits[15], bits[16]);
-
- /* Here we just do minimal validation of the counts to avoid walking
- * off the end of our table space. jdhuff.c will check more carefully.
- */
- if (count > 256 || ((JLONG)count) > length)
- ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
-
- for (i = 0; i < count; i++)
- INPUT_BYTE(cinfo, huffval[i], return FALSE);
-
- memset(&huffval[count], 0, (256 - count) * sizeof(UINT8));
-
- length -= count;
-
- if (index & 0x10) { /* AC table definition */
- index -= 0x10;
- if (index < 0 || index >= NUM_HUFF_TBLS)
- ERREXIT1(cinfo, JERR_DHT_INDEX, index);
- htblptr = &cinfo->ac_huff_tbl_ptrs[index];
- } else { /* DC table definition */
- if (index < 0 || index >= NUM_HUFF_TBLS)
- ERREXIT1(cinfo, JERR_DHT_INDEX, index);
- htblptr = &cinfo->dc_huff_tbl_ptrs[index];
- }
-
- if (*htblptr == NULL)
- *htblptr = jpeg_alloc_huff_table((j_common_ptr)cinfo);
-
- memcpy((*htblptr)->bits, bits, sizeof((*htblptr)->bits));
- memcpy((*htblptr)->huffval, huffval, sizeof((*htblptr)->huffval));
- }
-
- if (length != 0)
- ERREXIT(cinfo, JERR_BAD_LENGTH);
-
- INPUT_SYNC(cinfo);
- return TRUE;
-}
-
-
-LOCAL(boolean)
-get_dqt(j_decompress_ptr cinfo)
-/* Process a DQT marker */
-{
- JLONG length;
- int n, i, prec;
- unsigned int tmp;
- JQUANT_TBL *quant_ptr;
- INPUT_VARS(cinfo);
-
- INPUT_2BYTES(cinfo, length, return FALSE);
- length -= 2;
-
- while (length > 0) {
- INPUT_BYTE(cinfo, n, return FALSE);
- prec = n >> 4;
- n &= 0x0F;
-
- TRACEMS2(cinfo, 1, JTRC_DQT, n, prec);
-
- if (n >= NUM_QUANT_TBLS)
- ERREXIT1(cinfo, JERR_DQT_INDEX, n);
-
- if (cinfo->quant_tbl_ptrs[n] == NULL)
- cinfo->quant_tbl_ptrs[n] = jpeg_alloc_quant_table((j_common_ptr)cinfo);
- quant_ptr = cinfo->quant_tbl_ptrs[n];
-
- for (i = 0; i < DCTSIZE2; i++) {
- if (prec)
- INPUT_2BYTES(cinfo, tmp, return FALSE);
- else
- INPUT_BYTE(cinfo, tmp, return FALSE);
- /* We convert the zigzag-order table to natural array order. */
- quant_ptr->quantval[jpeg_natural_order[i]] = (UINT16)tmp;
- }
-
- if (cinfo->err->trace_level >= 2) {
- for (i = 0; i < DCTSIZE2; i += 8) {
- TRACEMS8(cinfo, 2, JTRC_QUANTVALS,
- quant_ptr->quantval[i], quant_ptr->quantval[i + 1],
- quant_ptr->quantval[i + 2], quant_ptr->quantval[i + 3],
- quant_ptr->quantval[i + 4], quant_ptr->quantval[i + 5],
- quant_ptr->quantval[i + 6], quant_ptr->quantval[i + 7]);
- }
- }
-
- length -= DCTSIZE2 + 1;
- if (prec) length -= DCTSIZE2;
- }
-
- if (length != 0)
- ERREXIT(cinfo, JERR_BAD_LENGTH);
-
- INPUT_SYNC(cinfo);
- return TRUE;
-}
-
-
-LOCAL(boolean)
-get_dri(j_decompress_ptr cinfo)
-/* Process a DRI marker */
-{
- JLONG length;
- unsigned int tmp;
- INPUT_VARS(cinfo);
-
- INPUT_2BYTES(cinfo, length, return FALSE);
-
- if (length != 4)
- ERREXIT(cinfo, JERR_BAD_LENGTH);
-
- INPUT_2BYTES(cinfo, tmp, return FALSE);
-
- TRACEMS1(cinfo, 1, JTRC_DRI, tmp);
-
- cinfo->restart_interval = tmp;
-
- INPUT_SYNC(cinfo);
- return TRUE;
-}
-
-
-/*
- * Routines for processing APPn and COM markers.
- * These are either saved in memory or discarded, per application request.
- * APP0 and APP14 are specially checked to see if they are
- * JFIF and Adobe markers, respectively.
- */
-
-#define APP0_DATA_LEN 14 /* Length of interesting data in APP0 */
-#define APP14_DATA_LEN 12 /* Length of interesting data in APP14 */
-#define APPN_DATA_LEN 14 /* Must be the largest of the above!! */
-
-
-LOCAL(void)
-examine_app0(j_decompress_ptr cinfo, JOCTET *data, unsigned int datalen,
- JLONG remaining)
-/* Examine first few bytes from an APP0.
- * Take appropriate action if it is a JFIF marker.
- * datalen is # of bytes at data[], remaining is length of rest of marker data.
- */
-{
- JLONG totallen = (JLONG)datalen + remaining;
-
- if (datalen >= APP0_DATA_LEN &&
- data[0] == 0x4A &&
- data[1] == 0x46 &&
- data[2] == 0x49 &&
- data[3] == 0x46 &&
- data[4] == 0) {
- /* Found JFIF APP0 marker: save info */
- cinfo->saw_JFIF_marker = TRUE;
- cinfo->JFIF_major_version = data[5];
- cinfo->JFIF_minor_version = data[6];
- cinfo->density_unit = data[7];
- cinfo->X_density = (data[8] << 8) + data[9];
- cinfo->Y_density = (data[10] << 8) + data[11];
- /* Check version.
- * Major version must be 1, anything else signals an incompatible change.
- * (We used to treat this as an error, but now it's a nonfatal warning,
- * because some bozo at Hijaak couldn't read the spec.)
- * Minor version should be 0..2, but process anyway if newer.
- */
- if (cinfo->JFIF_major_version != 1)
- WARNMS2(cinfo, JWRN_JFIF_MAJOR,
- cinfo->JFIF_major_version, cinfo->JFIF_minor_version);
- /* Generate trace messages */
- TRACEMS5(cinfo, 1, JTRC_JFIF,
- cinfo->JFIF_major_version, cinfo->JFIF_minor_version,
- cinfo->X_density, cinfo->Y_density, cinfo->density_unit);
- /* Validate thumbnail dimensions and issue appropriate messages */
- if (data[12] | data[13])
- TRACEMS2(cinfo, 1, JTRC_JFIF_THUMBNAIL, data[12], data[13]);
- totallen -= APP0_DATA_LEN;
- if (totallen != ((JLONG)data[12] * (JLONG)data[13] * (JLONG)3))
- TRACEMS1(cinfo, 1, JTRC_JFIF_BADTHUMBNAILSIZE, (int)totallen);
- } else if (datalen >= 6 &&
- data[0] == 0x4A &&
- data[1] == 0x46 &&
- data[2] == 0x58 &&
- data[3] == 0x58 &&
- data[4] == 0) {
- /* Found JFIF "JFXX" extension APP0 marker */
- /* The library doesn't actually do anything with these,
- * but we try to produce a helpful trace message.
- */
- switch (data[5]) {
- case 0x10:
- TRACEMS1(cinfo, 1, JTRC_THUMB_JPEG, (int)totallen);
- break;
- case 0x11:
- TRACEMS1(cinfo, 1, JTRC_THUMB_PALETTE, (int)totallen);
- break;
- case 0x13:
- TRACEMS1(cinfo, 1, JTRC_THUMB_RGB, (int)totallen);
- break;
- default:
- TRACEMS2(cinfo, 1, JTRC_JFIF_EXTENSION, data[5], (int)totallen);
- break;
- }
- } else {
- /* Start of APP0 does not match "JFIF" or "JFXX", or too short */
- TRACEMS1(cinfo, 1, JTRC_APP0, (int)totallen);
- }
-}
-
-
-LOCAL(void)
-examine_app14(j_decompress_ptr cinfo, JOCTET *data, unsigned int datalen,
- JLONG remaining)
-/* Examine first few bytes from an APP14.
- * Take appropriate action if it is an Adobe marker.
- * datalen is # of bytes at data[], remaining is length of rest of marker data.
- */
-{
- unsigned int version, flags0, flags1, transform;
-
- if (datalen >= APP14_DATA_LEN &&
- data[0] == 0x41 &&
- data[1] == 0x64 &&
- data[2] == 0x6F &&
- data[3] == 0x62 &&
- data[4] == 0x65) {
- /* Found Adobe APP14 marker */
- version = (data[5] << 8) + data[6];
- flags0 = (data[7] << 8) + data[8];
- flags1 = (data[9] << 8) + data[10];
- transform = data[11];
- TRACEMS4(cinfo, 1, JTRC_ADOBE, version, flags0, flags1, transform);
- cinfo->saw_Adobe_marker = TRUE;
- cinfo->Adobe_transform = (UINT8)transform;
- } else {
- /* Start of APP14 does not match "Adobe", or too short */
- TRACEMS1(cinfo, 1, JTRC_APP14, (int)(datalen + remaining));
- }
-}
-
-
-METHODDEF(boolean)
-get_interesting_appn(j_decompress_ptr cinfo)
-/* Process an APP0 or APP14 marker without saving it */
-{
- JLONG length;
- JOCTET b[APPN_DATA_LEN];
- unsigned int i, numtoread;
- INPUT_VARS(cinfo);
-
- INPUT_2BYTES(cinfo, length, return FALSE);
- length -= 2;
-
- /* get the interesting part of the marker data */
- if (length >= APPN_DATA_LEN)
- numtoread = APPN_DATA_LEN;
- else if (length > 0)
- numtoread = (unsigned int)length;
- else
- numtoread = 0;
- for (i = 0; i < numtoread; i++)
- INPUT_BYTE(cinfo, b[i], return FALSE);
- length -= numtoread;
-
- /* process it */
- switch (cinfo->unread_marker) {
- case M_APP0:
- examine_app0(cinfo, (JOCTET *)b, numtoread, length);
- break;
- case M_APP14:
- examine_app14(cinfo, (JOCTET *)b, numtoread, length);
- break;
- default:
- /* can't get here unless jpeg_save_markers chooses wrong processor */
- ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker);
- break;
- }
-
- /* skip any remaining data -- could be lots */
- INPUT_SYNC(cinfo);
- if (length > 0)
- (*cinfo->src->skip_input_data) (cinfo, (long)length);
-
- return TRUE;
-}
-
-
-#ifdef SAVE_MARKERS_SUPPORTED
-
-METHODDEF(boolean)
-save_marker(j_decompress_ptr cinfo)
-/* Save an APPn or COM marker into the marker list */
-{
- my_marker_ptr marker = (my_marker_ptr)cinfo->marker;
- jpeg_saved_marker_ptr cur_marker = marker->cur_marker;
- unsigned int bytes_read, data_length;
- JOCTET *data;
- JLONG length = 0;
- INPUT_VARS(cinfo);
-
- if (cur_marker == NULL) {
- /* begin reading a marker */
- INPUT_2BYTES(cinfo, length, return FALSE);
- length -= 2;
- if (length >= 0) { /* watch out for bogus length word */
- /* figure out how much we want to save */
- unsigned int limit;
- if (cinfo->unread_marker == (int)M_COM)
- limit = marker->length_limit_COM;
- else
- limit = marker->length_limit_APPn[cinfo->unread_marker - (int)M_APP0];
- if ((unsigned int)length < limit)
- limit = (unsigned int)length;
- /* allocate and initialize the marker item */
- cur_marker = (jpeg_saved_marker_ptr)
- (*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- sizeof(struct jpeg_marker_struct) + limit);
- cur_marker->next = NULL;
- cur_marker->marker = (UINT8)cinfo->unread_marker;
- cur_marker->original_length = (unsigned int)length;
- cur_marker->data_length = limit;
- /* data area is just beyond the jpeg_marker_struct */
- data = cur_marker->data = (JOCTET *)(cur_marker + 1);
- marker->cur_marker = cur_marker;
- marker->bytes_read = 0;
- bytes_read = 0;
- data_length = limit;
- } else {
- /* deal with bogus length word */
- bytes_read = data_length = 0;
- data = NULL;
- }
- } else {
- /* resume reading a marker */
- bytes_read = marker->bytes_read;
- data_length = cur_marker->data_length;
- data = cur_marker->data + bytes_read;
- }
-
- while (bytes_read < data_length) {
- INPUT_SYNC(cinfo); /* move the restart point to here */
- marker->bytes_read = bytes_read;
- /* If there's not at least one byte in buffer, suspend */
- MAKE_BYTE_AVAIL(cinfo, return FALSE);
- /* Copy bytes with reasonable rapidity */
- while (bytes_read < data_length && bytes_in_buffer > 0) {
- *data++ = *next_input_byte++;
- bytes_in_buffer--;
- bytes_read++;
- }
- }
-
- /* Done reading what we want to read */
- if (cur_marker != NULL) { /* will be NULL if bogus length word */
- /* Add new marker to end of list */
- if (cinfo->marker_list == NULL) {
- cinfo->marker_list = cur_marker;
- } else {
- jpeg_saved_marker_ptr prev = cinfo->marker_list;
- while (prev->next != NULL)
- prev = prev->next;
- prev->next = cur_marker;
- }
- /* Reset pointer & calc remaining data length */
- data = cur_marker->data;
- length = cur_marker->original_length - data_length;
- }
- /* Reset to initial state for next marker */
- marker->cur_marker = NULL;
-
- /* Process the marker if interesting; else just make a generic trace msg */
- switch (cinfo->unread_marker) {
- case M_APP0:
- examine_app0(cinfo, data, data_length, length);
- break;
- case M_APP14:
- examine_app14(cinfo, data, data_length, length);
- break;
- default:
- TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker,
- (int)(data_length + length));
- break;
- }
-
- /* skip any remaining data -- could be lots */
- INPUT_SYNC(cinfo); /* do before skip_input_data */
- if (length > 0)
- (*cinfo->src->skip_input_data) (cinfo, (long)length);
-
- return TRUE;
-}
-
-#endif /* SAVE_MARKERS_SUPPORTED */
-
-
-METHODDEF(boolean)
-skip_variable(j_decompress_ptr cinfo)
-/* Skip over an unknown or uninteresting variable-length marker */
-{
- JLONG length;
- INPUT_VARS(cinfo);
-
- INPUT_2BYTES(cinfo, length, return FALSE);
- length -= 2;
-
- TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker, (int)length);
-
- INPUT_SYNC(cinfo); /* do before skip_input_data */
- if (length > 0)
- (*cinfo->src->skip_input_data) (cinfo, (long)length);
-
- return TRUE;
-}
-
-
-/*
- * Find the next JPEG marker, save it in cinfo->unread_marker.
- * Returns FALSE if had to suspend before reaching a marker;
- * in that case cinfo->unread_marker is unchanged.
- *
- * Note that the result might not be a valid marker code,
- * but it will never be 0 or FF.
- */
-
-LOCAL(boolean)
-next_marker(j_decompress_ptr cinfo)
-{
- int c;
- INPUT_VARS(cinfo);
-
- for (;;) {
- INPUT_BYTE(cinfo, c, return FALSE);
- /* Skip any non-FF bytes.
- * This may look a bit inefficient, but it will not occur in a valid file.
- * We sync after each discarded byte so that a suspending data source
- * can discard the byte from its buffer.
- */
- while (c != 0xFF) {
- cinfo->marker->discarded_bytes++;
- INPUT_SYNC(cinfo);
- INPUT_BYTE(cinfo, c, return FALSE);
- }
- /* This loop swallows any duplicate FF bytes. Extra FFs are legal as
- * pad bytes, so don't count them in discarded_bytes. We assume there
- * will not be so many consecutive FF bytes as to overflow a suspending
- * data source's input buffer.
- */
- do {
- INPUT_BYTE(cinfo, c, return FALSE);
- } while (c == 0xFF);
- if (c != 0)
- break; /* found a valid marker, exit loop */
- /* Reach here if we found a stuffed-zero data sequence (FF/00).
- * Discard it and loop back to try again.
- */
- cinfo->marker->discarded_bytes += 2;
- INPUT_SYNC(cinfo);
- }
-
- if (cinfo->marker->discarded_bytes != 0) {
- WARNMS2(cinfo, JWRN_EXTRANEOUS_DATA, cinfo->marker->discarded_bytes, c);
- cinfo->marker->discarded_bytes = 0;
- }
-
- cinfo->unread_marker = c;
-
- INPUT_SYNC(cinfo);
- return TRUE;
-}
-
-
-LOCAL(boolean)
-first_marker(j_decompress_ptr cinfo)
-/* Like next_marker, but used to obtain the initial SOI marker. */
-/* For this marker, we do not allow preceding garbage or fill; otherwise,
- * we might well scan an entire input file before realizing it ain't JPEG.
- * If an application wants to process non-JFIF files, it must seek to the
- * SOI before calling the JPEG library.
- */
-{
- int c, c2;
- INPUT_VARS(cinfo);
-
- INPUT_BYTE(cinfo, c, return FALSE);
- INPUT_BYTE(cinfo, c2, return FALSE);
- if (c != 0xFF || c2 != (int)M_SOI)
- ERREXIT2(cinfo, JERR_NO_SOI, c, c2);
-
- cinfo->unread_marker = c2;
-
- INPUT_SYNC(cinfo);
- return TRUE;
-}
-
-
-/*
- * Read markers until SOS or EOI.
- *
- * Returns same codes as are defined for jpeg_consume_input:
- * JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI.
- */
-
-METHODDEF(int)
-read_markers(j_decompress_ptr cinfo)
-{
- /* Outer loop repeats once for each marker. */
- for (;;) {
- /* Collect the marker proper, unless we already did. */
- /* NB: first_marker() enforces the requirement that SOI appear first. */
- if (cinfo->unread_marker == 0) {
- if (!cinfo->marker->saw_SOI) {
- if (!first_marker(cinfo))
- return JPEG_SUSPENDED;
- } else {
- if (!next_marker(cinfo))
- return JPEG_SUSPENDED;
- }
- }
- /* At this point cinfo->unread_marker contains the marker code and the
- * input point is just past the marker proper, but before any parameters.
- * A suspension will cause us to return with this state still true.
- */
- switch (cinfo->unread_marker) {
- case M_SOI:
- if (!get_soi(cinfo))
- return JPEG_SUSPENDED;
- break;
-
- case M_SOF0: /* Baseline */
- case M_SOF1: /* Extended sequential, Huffman */
- if (!get_sof(cinfo, FALSE, FALSE))
- return JPEG_SUSPENDED;
- break;
-
- case M_SOF2: /* Progressive, Huffman */
- if (!get_sof(cinfo, TRUE, FALSE))
- return JPEG_SUSPENDED;
- break;
-
- case M_SOF9: /* Extended sequential, arithmetic */
- if (!get_sof(cinfo, FALSE, TRUE))
- return JPEG_SUSPENDED;
- break;
-
- case M_SOF10: /* Progressive, arithmetic */
- if (!get_sof(cinfo, TRUE, TRUE))
- return JPEG_SUSPENDED;
- break;
-
- /* Currently unsupported SOFn types */
- case M_SOF3: /* Lossless, Huffman */
- case M_SOF5: /* Differential sequential, Huffman */
- case M_SOF6: /* Differential progressive, Huffman */
- case M_SOF7: /* Differential lossless, Huffman */
- case M_JPG: /* Reserved for JPEG extensions */
- case M_SOF11: /* Lossless, arithmetic */
- case M_SOF13: /* Differential sequential, arithmetic */
- case M_SOF14: /* Differential progressive, arithmetic */
- case M_SOF15: /* Differential lossless, arithmetic */
- ERREXIT1(cinfo, JERR_SOF_UNSUPPORTED, cinfo->unread_marker);
- break;
-
- case M_SOS:
- if (!get_sos(cinfo))
- return JPEG_SUSPENDED;
- cinfo->unread_marker = 0; /* processed the marker */
- return JPEG_REACHED_SOS;
-
- case M_EOI:
- TRACEMS(cinfo, 1, JTRC_EOI);
- cinfo->unread_marker = 0; /* processed the marker */
- return JPEG_REACHED_EOI;
-
- case M_DAC:
- if (!get_dac(cinfo))
- return JPEG_SUSPENDED;
- break;
-
- case M_DHT:
- if (!get_dht(cinfo))
- return JPEG_SUSPENDED;
- break;
-
- case M_DQT:
- if (!get_dqt(cinfo))
- return JPEG_SUSPENDED;
- break;
-
- case M_DRI:
- if (!get_dri(cinfo))
- return JPEG_SUSPENDED;
- break;
-
- case M_APP0:
- case M_APP1:
- case M_APP2:
- case M_APP3:
- case M_APP4:
- case M_APP5:
- case M_APP6:
- case M_APP7:
- case M_APP8:
- case M_APP9:
- case M_APP10:
- case M_APP11:
- case M_APP12:
- case M_APP13:
- case M_APP14:
- case M_APP15:
- if (!(*((my_marker_ptr)cinfo->marker)->process_APPn[
- cinfo->unread_marker - (int)M_APP0]) (cinfo))
- return JPEG_SUSPENDED;
- break;
-
- case M_COM:
- if (!(*((my_marker_ptr)cinfo->marker)->process_COM) (cinfo))
- return JPEG_SUSPENDED;
- break;
-
- case M_RST0: /* these are all parameterless */
- case M_RST1:
- case M_RST2:
- case M_RST3:
- case M_RST4:
- case M_RST5:
- case M_RST6:
- case M_RST7:
- case M_TEM:
- TRACEMS1(cinfo, 1, JTRC_PARMLESS_MARKER, cinfo->unread_marker);
- break;
-
- case M_DNL: /* Ignore DNL ... perhaps the wrong thing */
- if (!skip_variable(cinfo))
- return JPEG_SUSPENDED;
- break;
-
- default: /* must be DHP, EXP, JPGn, or RESn */
- /* For now, we treat the reserved markers as fatal errors since they are
- * likely to be used to signal incompatible JPEG Part 3 extensions.
- * Once the JPEG 3 version-number marker is well defined, this code
- * ought to change!
- */
- ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker);
- break;
- }
- /* Successfully processed marker, so reset state variable */
- cinfo->unread_marker = 0;
- } /* end loop */
-}
-
-
-/*
- * Read a restart marker, which is expected to appear next in the datastream;
- * if the marker is not there, take appropriate recovery action.
- * Returns FALSE if suspension is required.
- *
- * This is called by the entropy decoder after it has read an appropriate
- * number of MCUs. cinfo->unread_marker may be nonzero if the entropy decoder
- * has already read a marker from the data source. Under normal conditions
- * cinfo->unread_marker will be reset to 0 before returning; if not reset,
- * it holds a marker which the decoder will be unable to read past.
- */
-
-METHODDEF(boolean)
-read_restart_marker(j_decompress_ptr cinfo)
-{
- /* Obtain a marker unless we already did. */
- /* Note that next_marker will complain if it skips any data. */
- if (cinfo->unread_marker == 0) {
- if (!next_marker(cinfo))
- return FALSE;
- }
-
- if (cinfo->unread_marker ==
- ((int)M_RST0 + cinfo->marker->next_restart_num)) {
- /* Normal case --- swallow the marker and let entropy decoder continue */
- TRACEMS1(cinfo, 3, JTRC_RST, cinfo->marker->next_restart_num);
- cinfo->unread_marker = 0;
- } else {
- /* Uh-oh, the restart markers have been messed up. */
- /* Let the data source manager determine how to resync. */
- if (!(*cinfo->src->resync_to_restart) (cinfo,
- cinfo->marker->next_restart_num))
- return FALSE;
- }
-
- /* Update next-restart state */
- cinfo->marker->next_restart_num = (cinfo->marker->next_restart_num + 1) & 7;
-
- return TRUE;
-}
-
-
-/*
- * This is the default resync_to_restart method for data source managers
- * to use if they don't have any better approach. Some data source managers
- * may be able to back up, or may have additional knowledge about the data
- * which permits a more intelligent recovery strategy; such managers would
- * presumably supply their own resync method.
- *
- * read_restart_marker calls resync_to_restart if it finds a marker other than
- * the restart marker it was expecting. (This code is *not* used unless
- * a nonzero restart interval has been declared.) cinfo->unread_marker is
- * the marker code actually found (might be anything, except 0 or FF).
- * The desired restart marker number (0..7) is passed as a parameter.
- * This routine is supposed to apply whatever error recovery strategy seems
- * appropriate in order to position the input stream to the next data segment.
- * Note that cinfo->unread_marker is treated as a marker appearing before
- * the current data-source input point; usually it should be reset to zero
- * before returning.
- * Returns FALSE if suspension is required.
- *
- * This implementation is substantially constrained by wanting to treat the
- * input as a data stream; this means we can't back up. Therefore, we have
- * only the following actions to work with:
- * 1. Simply discard the marker and let the entropy decoder resume at next
- * byte of file.
- * 2. Read forward until we find another marker, discarding intervening
- * data. (In theory we could look ahead within the current bufferload,
- * without having to discard data if we don't find the desired marker.
- * This idea is not implemented here, in part because it makes behavior
- * dependent on buffer size and chance buffer-boundary positions.)
- * 3. Leave the marker unread (by failing to zero cinfo->unread_marker).
- * This will cause the entropy decoder to process an empty data segment,
- * inserting dummy zeroes, and then we will reprocess the marker.
- *
- * #2 is appropriate if we think the desired marker lies ahead, while #3 is
- * appropriate if the found marker is a future restart marker (indicating
- * that we have missed the desired restart marker, probably because it got
- * corrupted).
- * We apply #2 or #3 if the found marker is a restart marker no more than
- * two counts behind or ahead of the expected one. We also apply #2 if the
- * found marker is not a legal JPEG marker code (it's certainly bogus data).
- * If the found marker is a restart marker more than 2 counts away, we do #1
- * (too much risk that the marker is erroneous; with luck we will be able to
- * resync at some future point).
- * For any valid non-restart JPEG marker, we apply #3. This keeps us from
- * overrunning the end of a scan. An implementation limited to single-scan
- * files might find it better to apply #2 for markers other than EOI, since
- * any other marker would have to be bogus data in that case.
- */
-
-GLOBAL(boolean)
-jpeg_resync_to_restart(j_decompress_ptr cinfo, int desired)
-{
- int marker = cinfo->unread_marker;
- int action = 1;
-
- /* Always put up a warning. */
- WARNMS2(cinfo, JWRN_MUST_RESYNC, marker, desired);
-
- /* Outer loop handles repeated decision after scanning forward. */
- for (;;) {
- if (marker < (int)M_SOF0)
- action = 2; /* invalid marker */
- else if (marker < (int)M_RST0 || marker > (int)M_RST7)
- action = 3; /* valid non-restart marker */
- else {
- if (marker == ((int)M_RST0 + ((desired + 1) & 7)) ||
- marker == ((int)M_RST0 + ((desired + 2) & 7)))
- action = 3; /* one of the next two expected restarts */
- else if (marker == ((int)M_RST0 + ((desired - 1) & 7)) ||
- marker == ((int)M_RST0 + ((desired - 2) & 7)))
- action = 2; /* a prior restart, so advance */
- else
- action = 1; /* desired restart or too far away */
- }
- TRACEMS2(cinfo, 4, JTRC_RECOVERY_ACTION, marker, action);
- switch (action) {
- case 1:
- /* Discard marker and let entropy decoder resume processing. */
- cinfo->unread_marker = 0;
- return TRUE;
- case 2:
- /* Scan to the next marker, and repeat the decision loop. */
- if (!next_marker(cinfo))
- return FALSE;
- marker = cinfo->unread_marker;
- break;
- case 3:
- /* Return without advancing past this marker. */
- /* Entropy decoder will be forced to process an empty segment. */
- return TRUE;
- }
- } /* end loop */
-}
-
-
-/*
- * Reset marker processing state to begin a fresh datastream.
- */
-
-METHODDEF(void)
-reset_marker_reader(j_decompress_ptr cinfo)
-{
- my_marker_ptr marker = (my_marker_ptr)cinfo->marker;
-
- cinfo->comp_info = NULL; /* until allocated by get_sof */
- cinfo->input_scan_number = 0; /* no SOS seen yet */
- cinfo->unread_marker = 0; /* no pending marker */
- marker->pub.saw_SOI = FALSE; /* set internal state too */
- marker->pub.saw_SOF = FALSE;
- marker->pub.discarded_bytes = 0;
- marker->cur_marker = NULL;
-}
-
-
-/*
- * Initialize the marker reader module.
- * This is called only once, when the decompression object is created.
- */
-
-GLOBAL(void)
-jinit_marker_reader(j_decompress_ptr cinfo)
-{
- my_marker_ptr marker;
- int i;
-
- /* Create subobject in permanent pool */
- marker = (my_marker_ptr)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
- sizeof(my_marker_reader));
- cinfo->marker = (struct jpeg_marker_reader *)marker;
- /* Initialize public method pointers */
- marker->pub.reset_marker_reader = reset_marker_reader;
- marker->pub.read_markers = read_markers;
- marker->pub.read_restart_marker = read_restart_marker;
- /* Initialize COM/APPn processing.
- * By default, we examine and then discard APP0 and APP14,
- * but simply discard COM and all other APPn.
- */
- marker->process_COM = skip_variable;
- marker->length_limit_COM = 0;
- for (i = 0; i < 16; i++) {
- marker->process_APPn[i] = skip_variable;
- marker->length_limit_APPn[i] = 0;
- }
- marker->process_APPn[0] = get_interesting_appn;
- marker->process_APPn[14] = get_interesting_appn;
- /* Reset marker processing state */
- reset_marker_reader(cinfo);
-}
-
-
-/*
- * Control saving of COM and APPn markers into marker_list.
- */
-
-#ifdef SAVE_MARKERS_SUPPORTED
-
-GLOBAL(void)
-jpeg_save_markers(j_decompress_ptr cinfo, int marker_code,
- unsigned int length_limit)
-{
- my_marker_ptr marker = (my_marker_ptr)cinfo->marker;
- long maxlength;
- jpeg_marker_parser_method processor;
-
- /* Length limit mustn't be larger than what we can allocate
- * (should only be a concern in a 16-bit environment).
- */
- maxlength = cinfo->mem->max_alloc_chunk - sizeof(struct jpeg_marker_struct);
- if (((long)length_limit) > maxlength)
- length_limit = (unsigned int)maxlength;
-
- /* Choose processor routine to use.
- * APP0/APP14 have special requirements.
- */
- if (length_limit) {
- processor = save_marker;
- /* If saving APP0/APP14, save at least enough for our internal use. */
- if (marker_code == (int)M_APP0 && length_limit < APP0_DATA_LEN)
- length_limit = APP0_DATA_LEN;
- else if (marker_code == (int)M_APP14 && length_limit < APP14_DATA_LEN)
- length_limit = APP14_DATA_LEN;
- } else {
- processor = skip_variable;
- /* If discarding APP0/APP14, use our regular on-the-fly processor. */
- if (marker_code == (int)M_APP0 || marker_code == (int)M_APP14)
- processor = get_interesting_appn;
- }
-
- if (marker_code == (int)M_COM) {
- marker->process_COM = processor;
- marker->length_limit_COM = length_limit;
- } else if (marker_code >= (int)M_APP0 && marker_code <= (int)M_APP15) {
- marker->process_APPn[marker_code - (int)M_APP0] = processor;
- marker->length_limit_APPn[marker_code - (int)M_APP0] = length_limit;
- } else
- ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, marker_code);
-}
-
-#endif /* SAVE_MARKERS_SUPPORTED */
-
-
-/*
- * Install a special processing method for COM or APPn markers.
- */
-
-GLOBAL(void)
-jpeg_set_marker_processor(j_decompress_ptr cinfo, int marker_code,
- jpeg_marker_parser_method routine)
-{
- my_marker_ptr marker = (my_marker_ptr)cinfo->marker;
-
- if (marker_code == (int)M_COM)
- marker->process_COM = routine;
- else if (marker_code >= (int)M_APP0 && marker_code <= (int)M_APP15)
- marker->process_APPn[marker_code - (int)M_APP0] = routine;
- else
- ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, marker_code);
-}
diff --git a/contrib/libs/libjpeg-turbo/jdmaster.c b/contrib/libs/libjpeg-turbo/jdmaster.c
deleted file mode 100644
index a3690bf560..0000000000
--- a/contrib/libs/libjpeg-turbo/jdmaster.c
+++ /dev/null
@@ -1,726 +0,0 @@
-/*
- * jdmaster.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * Modified 2002-2009 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2009-2011, 2016, 2019, 2022, D. R. Commander.
- * Copyright (C) 2013, Linaro Limited.
- * Copyright (C) 2015, Google, Inc.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains master control logic for the JPEG decompressor.
- * These routines are concerned with selecting the modules to be executed
- * and with determining the number of passes and the work to be done in each
- * pass.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-#include "jpegcomp.h"
-#include "jdmaster.h"
-
-
-/*
- * Determine whether merged upsample/color conversion should be used.
- * CRUCIAL: this must match the actual capabilities of jdmerge.c!
- */
-
-LOCAL(boolean)
-use_merged_upsample(j_decompress_ptr cinfo)
-{
-#ifdef UPSAMPLE_MERGING_SUPPORTED
- /* Merging is the equivalent of plain box-filter upsampling */
- if (cinfo->do_fancy_upsampling || cinfo->CCIR601_sampling)
- return FALSE;
- /* jdmerge.c only supports YCC=>RGB and YCC=>RGB565 color conversion */
- if (cinfo->jpeg_color_space != JCS_YCbCr || cinfo->num_components != 3 ||
- (cinfo->out_color_space != JCS_RGB &&
- cinfo->out_color_space != JCS_RGB565 &&
- cinfo->out_color_space != JCS_EXT_RGB &&
- cinfo->out_color_space != JCS_EXT_RGBX &&
- cinfo->out_color_space != JCS_EXT_BGR &&
- cinfo->out_color_space != JCS_EXT_BGRX &&
- cinfo->out_color_space != JCS_EXT_XBGR &&
- cinfo->out_color_space != JCS_EXT_XRGB &&
- cinfo->out_color_space != JCS_EXT_RGBA &&
- cinfo->out_color_space != JCS_EXT_BGRA &&
- cinfo->out_color_space != JCS_EXT_ABGR &&
- cinfo->out_color_space != JCS_EXT_ARGB))
- return FALSE;
- if ((cinfo->out_color_space == JCS_RGB565 &&
- cinfo->out_color_components != 3) ||
- (cinfo->out_color_space != JCS_RGB565 &&
- cinfo->out_color_components != rgb_pixelsize[cinfo->out_color_space]))
- return FALSE;
- /* and it only handles 2h1v or 2h2v sampling ratios */
- if (cinfo->comp_info[0].h_samp_factor != 2 ||
- cinfo->comp_info[1].h_samp_factor != 1 ||
- cinfo->comp_info[2].h_samp_factor != 1 ||
- cinfo->comp_info[0].v_samp_factor > 2 ||
- cinfo->comp_info[1].v_samp_factor != 1 ||
- cinfo->comp_info[2].v_samp_factor != 1)
- return FALSE;
- /* furthermore, it doesn't work if we've scaled the IDCTs differently */
- if (cinfo->comp_info[0]._DCT_scaled_size != cinfo->_min_DCT_scaled_size ||
- cinfo->comp_info[1]._DCT_scaled_size != cinfo->_min_DCT_scaled_size ||
- cinfo->comp_info[2]._DCT_scaled_size != cinfo->_min_DCT_scaled_size)
- return FALSE;
- /* ??? also need to test for upsample-time rescaling, when & if supported */
- return TRUE; /* by golly, it'll work... */
-#else
- return FALSE;
-#endif
-}
-
-
-/*
- * Compute output image dimensions and related values.
- * NOTE: this is exported for possible use by application.
- * Hence it mustn't do anything that can't be done twice.
- */
-
-#if JPEG_LIB_VERSION >= 80
-GLOBAL(void)
-#else
-LOCAL(void)
-#endif
-jpeg_core_output_dimensions(j_decompress_ptr cinfo)
-/* Do computations that are needed before master selection phase.
- * This function is used for transcoding and full decompression.
- */
-{
-#ifdef IDCT_SCALING_SUPPORTED
- int ci;
- jpeg_component_info *compptr;
-
- /* Compute actual output image dimensions and DCT scaling choices. */
- if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom) {
- /* Provide 1/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_width, (long)DCTSIZE);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_height, (long)DCTSIZE);
- cinfo->_min_DCT_h_scaled_size = 1;
- cinfo->_min_DCT_v_scaled_size = 1;
- } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 2) {
- /* Provide 2/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_width * 2L, (long)DCTSIZE);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_height * 2L, (long)DCTSIZE);
- cinfo->_min_DCT_h_scaled_size = 2;
- cinfo->_min_DCT_v_scaled_size = 2;
- } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 3) {
- /* Provide 3/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_width * 3L, (long)DCTSIZE);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_height * 3L, (long)DCTSIZE);
- cinfo->_min_DCT_h_scaled_size = 3;
- cinfo->_min_DCT_v_scaled_size = 3;
- } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 4) {
- /* Provide 4/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_width * 4L, (long)DCTSIZE);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_height * 4L, (long)DCTSIZE);
- cinfo->_min_DCT_h_scaled_size = 4;
- cinfo->_min_DCT_v_scaled_size = 4;
- } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 5) {
- /* Provide 5/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_width * 5L, (long)DCTSIZE);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_height * 5L, (long)DCTSIZE);
- cinfo->_min_DCT_h_scaled_size = 5;
- cinfo->_min_DCT_v_scaled_size = 5;
- } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 6) {
- /* Provide 6/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_width * 6L, (long)DCTSIZE);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_height * 6L, (long)DCTSIZE);
- cinfo->_min_DCT_h_scaled_size = 6;
- cinfo->_min_DCT_v_scaled_size = 6;
- } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 7) {
- /* Provide 7/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_width * 7L, (long)DCTSIZE);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_height * 7L, (long)DCTSIZE);
- cinfo->_min_DCT_h_scaled_size = 7;
- cinfo->_min_DCT_v_scaled_size = 7;
- } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 8) {
- /* Provide 8/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_width * 8L, (long)DCTSIZE);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_height * 8L, (long)DCTSIZE);
- cinfo->_min_DCT_h_scaled_size = 8;
- cinfo->_min_DCT_v_scaled_size = 8;
- } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 9) {
- /* Provide 9/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_width * 9L, (long)DCTSIZE);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_height * 9L, (long)DCTSIZE);
- cinfo->_min_DCT_h_scaled_size = 9;
- cinfo->_min_DCT_v_scaled_size = 9;
- } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 10) {
- /* Provide 10/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_width * 10L, (long)DCTSIZE);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_height * 10L, (long)DCTSIZE);
- cinfo->_min_DCT_h_scaled_size = 10;
- cinfo->_min_DCT_v_scaled_size = 10;
- } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 11) {
- /* Provide 11/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_width * 11L, (long)DCTSIZE);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_height * 11L, (long)DCTSIZE);
- cinfo->_min_DCT_h_scaled_size = 11;
- cinfo->_min_DCT_v_scaled_size = 11;
- } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 12) {
- /* Provide 12/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_width * 12L, (long)DCTSIZE);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_height * 12L, (long)DCTSIZE);
- cinfo->_min_DCT_h_scaled_size = 12;
- cinfo->_min_DCT_v_scaled_size = 12;
- } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 13) {
- /* Provide 13/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_width * 13L, (long)DCTSIZE);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_height * 13L, (long)DCTSIZE);
- cinfo->_min_DCT_h_scaled_size = 13;
- cinfo->_min_DCT_v_scaled_size = 13;
- } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 14) {
- /* Provide 14/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_width * 14L, (long)DCTSIZE);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_height * 14L, (long)DCTSIZE);
- cinfo->_min_DCT_h_scaled_size = 14;
- cinfo->_min_DCT_v_scaled_size = 14;
- } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 15) {
- /* Provide 15/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_width * 15L, (long)DCTSIZE);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_height * 15L, (long)DCTSIZE);
- cinfo->_min_DCT_h_scaled_size = 15;
- cinfo->_min_DCT_v_scaled_size = 15;
- } else {
- /* Provide 16/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_width * 16L, (long)DCTSIZE);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_height * 16L, (long)DCTSIZE);
- cinfo->_min_DCT_h_scaled_size = 16;
- cinfo->_min_DCT_v_scaled_size = 16;
- }
-
- /* Recompute dimensions of components */
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
- ci++, compptr++) {
- compptr->_DCT_h_scaled_size = cinfo->_min_DCT_h_scaled_size;
- compptr->_DCT_v_scaled_size = cinfo->_min_DCT_v_scaled_size;
- }
-
-#else /* !IDCT_SCALING_SUPPORTED */
-
- /* Hardwire it to "no scaling" */
- cinfo->output_width = cinfo->image_width;
- cinfo->output_height = cinfo->image_height;
- /* jdinput.c has already initialized DCT_scaled_size,
- * and has computed unscaled downsampled_width and downsampled_height.
- */
-
-#endif /* IDCT_SCALING_SUPPORTED */
-}
-
-
-/*
- * Compute output image dimensions and related values.
- * NOTE: this is exported for possible use by application.
- * Hence it mustn't do anything that can't be done twice.
- * Also note that it may be called before the master module is initialized!
- */
-
-GLOBAL(void)
-jpeg_calc_output_dimensions(j_decompress_ptr cinfo)
-/* Do computations that are needed before master selection phase */
-{
-#ifdef IDCT_SCALING_SUPPORTED
- int ci;
- jpeg_component_info *compptr;
-#endif
-
- /* Prevent application from calling me at wrong times */
- if (cinfo->global_state != DSTATE_READY)
- ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
-
- /* Compute core output image dimensions and DCT scaling choices. */
- jpeg_core_output_dimensions(cinfo);
-
-#ifdef IDCT_SCALING_SUPPORTED
-
- /* In selecting the actual DCT scaling for each component, we try to
- * scale up the chroma components via IDCT scaling rather than upsampling.
- * This saves time if the upsampler gets to use 1:1 scaling.
- * Note this code adapts subsampling ratios which are powers of 2.
- */
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
- ci++, compptr++) {
- int ssize = cinfo->_min_DCT_scaled_size;
- while (ssize < DCTSIZE &&
- ((cinfo->max_h_samp_factor * cinfo->_min_DCT_scaled_size) %
- (compptr->h_samp_factor * ssize * 2) == 0) &&
- ((cinfo->max_v_samp_factor * cinfo->_min_DCT_scaled_size) %
- (compptr->v_samp_factor * ssize * 2) == 0)) {
- ssize = ssize * 2;
- }
-#if JPEG_LIB_VERSION >= 70
- compptr->DCT_h_scaled_size = compptr->DCT_v_scaled_size = ssize;
-#else
- compptr->DCT_scaled_size = ssize;
-#endif
- }
-
- /* Recompute downsampled dimensions of components;
- * application needs to know these if using raw downsampled data.
- */
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
- ci++, compptr++) {
- /* Size in samples, after IDCT scaling */
- compptr->downsampled_width = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_width *
- (long)(compptr->h_samp_factor * compptr->_DCT_scaled_size),
- (long)(cinfo->max_h_samp_factor * DCTSIZE));
- compptr->downsampled_height = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_height *
- (long)(compptr->v_samp_factor * compptr->_DCT_scaled_size),
- (long)(cinfo->max_v_samp_factor * DCTSIZE));
- }
-
-#else /* !IDCT_SCALING_SUPPORTED */
-
- /* Hardwire it to "no scaling" */
- cinfo->output_width = cinfo->image_width;
- cinfo->output_height = cinfo->image_height;
- /* jdinput.c has already initialized DCT_scaled_size to DCTSIZE,
- * and has computed unscaled downsampled_width and downsampled_height.
- */
-
-#endif /* IDCT_SCALING_SUPPORTED */
-
- /* Report number of components in selected colorspace. */
- /* Probably this should be in the color conversion module... */
- switch (cinfo->out_color_space) {
- case JCS_GRAYSCALE:
- cinfo->out_color_components = 1;
- break;
- case JCS_RGB:
- case JCS_EXT_RGB:
- case JCS_EXT_RGBX:
- case JCS_EXT_BGR:
- case JCS_EXT_BGRX:
- case JCS_EXT_XBGR:
- case JCS_EXT_XRGB:
- case JCS_EXT_RGBA:
- case JCS_EXT_BGRA:
- case JCS_EXT_ABGR:
- case JCS_EXT_ARGB:
- cinfo->out_color_components = rgb_pixelsize[cinfo->out_color_space];
- break;
- case JCS_YCbCr:
- case JCS_RGB565:
- cinfo->out_color_components = 3;
- break;
- case JCS_CMYK:
- case JCS_YCCK:
- cinfo->out_color_components = 4;
- break;
- default: /* else must be same colorspace as in file */
- cinfo->out_color_components = cinfo->num_components;
- break;
- }
- cinfo->output_components = (cinfo->quantize_colors ? 1 :
- cinfo->out_color_components);
-
- /* See if upsampler will want to emit more than one row at a time */
- if (use_merged_upsample(cinfo))
- cinfo->rec_outbuf_height = cinfo->max_v_samp_factor;
- else
- cinfo->rec_outbuf_height = 1;
-}
-
-
-/*
- * Several decompression processes need to range-limit values to the range
- * 0..MAXJSAMPLE; the input value may fall somewhat outside this range
- * due to noise introduced by quantization, roundoff error, etc. These
- * processes are inner loops and need to be as fast as possible. On most
- * machines, particularly CPUs with pipelines or instruction prefetch,
- * a (subscript-check-less) C table lookup
- * x = sample_range_limit[x];
- * is faster than explicit tests
- * if (x < 0) x = 0;
- * else if (x > MAXJSAMPLE) x = MAXJSAMPLE;
- * These processes all use a common table prepared by the routine below.
- *
- * For most steps we can mathematically guarantee that the initial value
- * of x is within MAXJSAMPLE+1 of the legal range, so a table running from
- * -(MAXJSAMPLE+1) to 2*MAXJSAMPLE+1 is sufficient. But for the initial
- * limiting step (just after the IDCT), a wildly out-of-range value is
- * possible if the input data is corrupt. To avoid any chance of indexing
- * off the end of memory and getting a bad-pointer trap, we perform the
- * post-IDCT limiting thus:
- * x = range_limit[x & MASK];
- * where MASK is 2 bits wider than legal sample data, ie 10 bits for 8-bit
- * samples. Under normal circumstances this is more than enough range and
- * a correct output will be generated; with bogus input data the mask will
- * cause wraparound, and we will safely generate a bogus-but-in-range output.
- * For the post-IDCT step, we want to convert the data from signed to unsigned
- * representation by adding CENTERJSAMPLE at the same time that we limit it.
- * So the post-IDCT limiting table ends up looking like this:
- * CENTERJSAMPLE,CENTERJSAMPLE+1,...,MAXJSAMPLE,
- * MAXJSAMPLE (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times),
- * 0 (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times),
- * 0,1,...,CENTERJSAMPLE-1
- * Negative inputs select values from the upper half of the table after
- * masking.
- *
- * We can save some space by overlapping the start of the post-IDCT table
- * with the simpler range limiting table. The post-IDCT table begins at
- * sample_range_limit + CENTERJSAMPLE.
- */
-
-LOCAL(void)
-prepare_range_limit_table(j_decompress_ptr cinfo)
-/* Allocate and fill in the sample_range_limit table */
-{
- JSAMPLE *table;
- int i;
-
- table = (JSAMPLE *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- (5 * (MAXJSAMPLE + 1) + CENTERJSAMPLE) * sizeof(JSAMPLE));
- table += (MAXJSAMPLE + 1); /* allow negative subscripts of simple table */
- cinfo->sample_range_limit = table;
- /* First segment of "simple" table: limit[x] = 0 for x < 0 */
- memset(table - (MAXJSAMPLE + 1), 0, (MAXJSAMPLE + 1) * sizeof(JSAMPLE));
- /* Main part of "simple" table: limit[x] = x */
- for (i = 0; i <= MAXJSAMPLE; i++)
- table[i] = (JSAMPLE)i;
- table += CENTERJSAMPLE; /* Point to where post-IDCT table starts */
- /* End of simple table, rest of first half of post-IDCT table */
- for (i = CENTERJSAMPLE; i < 2 * (MAXJSAMPLE + 1); i++)
- table[i] = MAXJSAMPLE;
- /* Second half of post-IDCT table */
- memset(table + (2 * (MAXJSAMPLE + 1)), 0,
- (2 * (MAXJSAMPLE + 1) - CENTERJSAMPLE) * sizeof(JSAMPLE));
- memcpy(table + (4 * (MAXJSAMPLE + 1) - CENTERJSAMPLE),
- cinfo->sample_range_limit, CENTERJSAMPLE * sizeof(JSAMPLE));
-}
-
-
-/*
- * Master selection of decompression modules.
- * This is done once at jpeg_start_decompress time. We determine
- * which modules will be used and give them appropriate initialization calls.
- * We also initialize the decompressor input side to begin consuming data.
- *
- * Since jpeg_read_header has finished, we know what is in the SOF
- * and (first) SOS markers. We also have all the application parameter
- * settings.
- */
-
-LOCAL(void)
-master_selection(j_decompress_ptr cinfo)
-{
- my_master_ptr master = (my_master_ptr)cinfo->master;
- boolean use_c_buffer;
- long samplesperrow;
- JDIMENSION jd_samplesperrow;
-
- /* Initialize dimensions and other stuff */
- jpeg_calc_output_dimensions(cinfo);
- prepare_range_limit_table(cinfo);
-
- /* Width of an output scanline must be representable as JDIMENSION. */
- samplesperrow = (long)cinfo->output_width *
- (long)cinfo->out_color_components;
- jd_samplesperrow = (JDIMENSION)samplesperrow;
- if ((long)jd_samplesperrow != samplesperrow)
- ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
-
- /* Initialize my private state */
- master->pass_number = 0;
- master->using_merged_upsample = use_merged_upsample(cinfo);
-
- /* Color quantizer selection */
- master->quantizer_1pass = NULL;
- master->quantizer_2pass = NULL;
- /* No mode changes if not using buffered-image mode. */
- if (!cinfo->quantize_colors || !cinfo->buffered_image) {
- cinfo->enable_1pass_quant = FALSE;
- cinfo->enable_external_quant = FALSE;
- cinfo->enable_2pass_quant = FALSE;
- }
- if (cinfo->quantize_colors) {
- if (cinfo->raw_data_out)
- ERREXIT(cinfo, JERR_NOTIMPL);
- /* 2-pass quantizer only works in 3-component color space. */
- if (cinfo->out_color_components != 3) {
- cinfo->enable_1pass_quant = TRUE;
- cinfo->enable_external_quant = FALSE;
- cinfo->enable_2pass_quant = FALSE;
- cinfo->colormap = NULL;
- } else if (cinfo->colormap != NULL) {
- cinfo->enable_external_quant = TRUE;
- } else if (cinfo->two_pass_quantize) {
- cinfo->enable_2pass_quant = TRUE;
- } else {
- cinfo->enable_1pass_quant = TRUE;
- }
-
- if (cinfo->enable_1pass_quant) {
-#ifdef QUANT_1PASS_SUPPORTED
- jinit_1pass_quantizer(cinfo);
- master->quantizer_1pass = cinfo->cquantize;
-#else
- ERREXIT(cinfo, JERR_NOT_COMPILED);
-#endif
- }
-
- /* We use the 2-pass code to map to external colormaps. */
- if (cinfo->enable_2pass_quant || cinfo->enable_external_quant) {
-#ifdef QUANT_2PASS_SUPPORTED
- jinit_2pass_quantizer(cinfo);
- master->quantizer_2pass = cinfo->cquantize;
-#else
- ERREXIT(cinfo, JERR_NOT_COMPILED);
-#endif
- }
- /* If both quantizers are initialized, the 2-pass one is left active;
- * this is necessary for starting with quantization to an external map.
- */
- }
-
- /* Post-processing: in particular, color conversion first */
- if (!cinfo->raw_data_out) {
- if (master->using_merged_upsample) {
-#ifdef UPSAMPLE_MERGING_SUPPORTED
- jinit_merged_upsampler(cinfo); /* does color conversion too */
-#else
- ERREXIT(cinfo, JERR_NOT_COMPILED);
-#endif
- } else {
- jinit_color_deconverter(cinfo);
- jinit_upsampler(cinfo);
- }
- jinit_d_post_controller(cinfo, cinfo->enable_2pass_quant);
- }
- /* Inverse DCT */
- jinit_inverse_dct(cinfo);
- /* Entropy decoding: either Huffman or arithmetic coding. */
- if (cinfo->arith_code) {
-#ifdef D_ARITH_CODING_SUPPORTED
- jinit_arith_decoder(cinfo);
-#else
- ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
-#endif
- } else {
- if (cinfo->progressive_mode) {
-#ifdef D_PROGRESSIVE_SUPPORTED
- jinit_phuff_decoder(cinfo);
-#else
- ERREXIT(cinfo, JERR_NOT_COMPILED);
-#endif
- } else
- jinit_huff_decoder(cinfo);
- }
-
- /* Initialize principal buffer controllers. */
- use_c_buffer = cinfo->inputctl->has_multiple_scans || cinfo->buffered_image;
- jinit_d_coef_controller(cinfo, use_c_buffer);
-
- if (!cinfo->raw_data_out)
- jinit_d_main_controller(cinfo, FALSE /* never need full buffer here */);
-
- /* We can now tell the memory manager to allocate virtual arrays. */
- (*cinfo->mem->realize_virt_arrays) ((j_common_ptr)cinfo);
-
- /* Initialize input side of decompressor to consume first scan. */
- (*cinfo->inputctl->start_input_pass) (cinfo);
-
- /* Set the first and last iMCU columns to decompress from single-scan images.
- * By default, decompress all of the iMCU columns.
- */
- cinfo->master->first_iMCU_col = 0;
- cinfo->master->last_iMCU_col = cinfo->MCUs_per_row - 1;
- cinfo->master->last_good_iMCU_row = 0;
-
-#ifdef D_MULTISCAN_FILES_SUPPORTED
- /* If jpeg_start_decompress will read the whole file, initialize
- * progress monitoring appropriately. The input step is counted
- * as one pass.
- */
- if (cinfo->progress != NULL && !cinfo->buffered_image &&
- cinfo->inputctl->has_multiple_scans) {
- int nscans;
- /* Estimate number of scans to set pass_limit. */
- if (cinfo->progressive_mode) {
- /* Arbitrarily estimate 2 interleaved DC scans + 3 AC scans/component. */
- nscans = 2 + 3 * cinfo->num_components;
- } else {
- /* For a nonprogressive multiscan file, estimate 1 scan per component. */
- nscans = cinfo->num_components;
- }
- cinfo->progress->pass_counter = 0L;
- cinfo->progress->pass_limit = (long)cinfo->total_iMCU_rows * nscans;
- cinfo->progress->completed_passes = 0;
- cinfo->progress->total_passes = (cinfo->enable_2pass_quant ? 3 : 2);
- /* Count the input pass as done */
- master->pass_number++;
- }
-#endif /* D_MULTISCAN_FILES_SUPPORTED */
-}
-
-
-/*
- * Per-pass setup.
- * This is called at the beginning of each output pass. We determine which
- * modules will be active during this pass and give them appropriate
- * start_pass calls. We also set is_dummy_pass to indicate whether this
- * is a "real" output pass or a dummy pass for color quantization.
- * (In the latter case, jdapistd.c will crank the pass to completion.)
- */
-
-METHODDEF(void)
-prepare_for_output_pass(j_decompress_ptr cinfo)
-{
- my_master_ptr master = (my_master_ptr)cinfo->master;
-
- if (master->pub.is_dummy_pass) {
-#ifdef QUANT_2PASS_SUPPORTED
- /* Final pass of 2-pass quantization */
- master->pub.is_dummy_pass = FALSE;
- (*cinfo->cquantize->start_pass) (cinfo, FALSE);
- (*cinfo->post->start_pass) (cinfo, JBUF_CRANK_DEST);
- (*cinfo->main->start_pass) (cinfo, JBUF_CRANK_DEST);
-#else
- ERREXIT(cinfo, JERR_NOT_COMPILED);
-#endif /* QUANT_2PASS_SUPPORTED */
- } else {
- if (cinfo->quantize_colors && cinfo->colormap == NULL) {
- /* Select new quantization method */
- if (cinfo->two_pass_quantize && cinfo->enable_2pass_quant) {
- cinfo->cquantize = master->quantizer_2pass;
- master->pub.is_dummy_pass = TRUE;
- } else if (cinfo->enable_1pass_quant) {
- cinfo->cquantize = master->quantizer_1pass;
- } else {
- ERREXIT(cinfo, JERR_MODE_CHANGE);
- }
- }
- (*cinfo->idct->start_pass) (cinfo);
- (*cinfo->coef->start_output_pass) (cinfo);
- if (!cinfo->raw_data_out) {
- if (!master->using_merged_upsample)
- (*cinfo->cconvert->start_pass) (cinfo);
- (*cinfo->upsample->start_pass) (cinfo);
- if (cinfo->quantize_colors)
- (*cinfo->cquantize->start_pass) (cinfo, master->pub.is_dummy_pass);
- (*cinfo->post->start_pass) (cinfo,
- (master->pub.is_dummy_pass ? JBUF_SAVE_AND_PASS : JBUF_PASS_THRU));
- (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU);
- }
- }
-
- /* Set up progress monitor's pass info if present */
- if (cinfo->progress != NULL) {
- cinfo->progress->completed_passes = master->pass_number;
- cinfo->progress->total_passes = master->pass_number +
- (master->pub.is_dummy_pass ? 2 : 1);
- /* In buffered-image mode, we assume one more output pass if EOI not
- * yet reached, but no more passes if EOI has been reached.
- */
- if (cinfo->buffered_image && !cinfo->inputctl->eoi_reached) {
- cinfo->progress->total_passes += (cinfo->enable_2pass_quant ? 2 : 1);
- }
- }
-}
-
-
-/*
- * Finish up at end of an output pass.
- */
-
-METHODDEF(void)
-finish_output_pass(j_decompress_ptr cinfo)
-{
- my_master_ptr master = (my_master_ptr)cinfo->master;
-
- if (cinfo->quantize_colors)
- (*cinfo->cquantize->finish_pass) (cinfo);
- master->pass_number++;
-}
-
-
-#ifdef D_MULTISCAN_FILES_SUPPORTED
-
-/*
- * Switch to a new external colormap between output passes.
- */
-
-GLOBAL(void)
-jpeg_new_colormap(j_decompress_ptr cinfo)
-{
- my_master_ptr master = (my_master_ptr)cinfo->master;
-
- /* Prevent application from calling me at wrong times */
- if (cinfo->global_state != DSTATE_BUFIMAGE)
- ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
-
- if (cinfo->quantize_colors && cinfo->enable_external_quant &&
- cinfo->colormap != NULL) {
- /* Select 2-pass quantizer for external colormap use */
- cinfo->cquantize = master->quantizer_2pass;
- /* Notify quantizer of colormap change */
- (*cinfo->cquantize->new_color_map) (cinfo);
- master->pub.is_dummy_pass = FALSE; /* just in case */
- } else
- ERREXIT(cinfo, JERR_MODE_CHANGE);
-}
-
-#endif /* D_MULTISCAN_FILES_SUPPORTED */
-
-
-/*
- * Initialize master decompression control and select active modules.
- * This is performed at the start of jpeg_start_decompress.
- */
-
-GLOBAL(void)
-jinit_master_decompress(j_decompress_ptr cinfo)
-{
- my_master_ptr master = (my_master_ptr)cinfo->master;
-
- master->pub.prepare_for_output_pass = prepare_for_output_pass;
- master->pub.finish_output_pass = finish_output_pass;
-
- master->pub.is_dummy_pass = FALSE;
- master->pub.jinit_upsampler_no_alloc = FALSE;
-
- master_selection(cinfo);
-}
diff --git a/contrib/libs/libjpeg-turbo/jdmaster.h b/contrib/libs/libjpeg-turbo/jdmaster.h
deleted file mode 100644
index 76897e2820..0000000000
--- a/contrib/libs/libjpeg-turbo/jdmaster.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * jdmaster.h
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1995, Thomas G. Lane.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains the master control structure for the JPEG decompressor.
- */
-
-/* Private state */
-
-typedef struct {
- struct jpeg_decomp_master pub; /* public fields */
-
- int pass_number; /* # of passes completed */
-
- boolean using_merged_upsample; /* TRUE if using merged upsample/cconvert */
-
- /* Saved references to initialized quantizer modules,
- * in case we need to switch modes.
- */
- struct jpeg_color_quantizer *quantizer_1pass;
- struct jpeg_color_quantizer *quantizer_2pass;
-} my_decomp_master;
-
-typedef my_decomp_master *my_master_ptr;
diff --git a/contrib/libs/libjpeg-turbo/jdmerge.c b/contrib/libs/libjpeg-turbo/jdmerge.c
deleted file mode 100644
index 3a456d6581..0000000000
--- a/contrib/libs/libjpeg-turbo/jdmerge.c
+++ /dev/null
@@ -1,588 +0,0 @@
-/*
- * jdmerge.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- * Copyright (C) 2009, 2011, 2014-2015, 2020, D. R. Commander.
- * Copyright (C) 2013, Linaro Limited.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains code for merged upsampling/color conversion.
- *
- * This file combines functions from jdsample.c and jdcolor.c;
- * read those files first to understand what's going on.
- *
- * When the chroma components are to be upsampled by simple replication
- * (ie, box filtering), we can save some work in color conversion by
- * calculating all the output pixels corresponding to a pair of chroma
- * samples at one time. In the conversion equations
- * R = Y + K1 * Cr
- * G = Y + K2 * Cb + K3 * Cr
- * B = Y + K4 * Cb
- * only the Y term varies among the group of pixels corresponding to a pair
- * of chroma samples, so the rest of the terms can be calculated just once.
- * At typical sampling ratios, this eliminates half or three-quarters of the
- * multiplications needed for color conversion.
- *
- * This file currently provides implementations for the following cases:
- * YCbCr => RGB color conversion only.
- * Sampling ratios of 2h1v or 2h2v.
- * No scaling needed at upsample time.
- * Corner-aligned (non-CCIR601) sampling alignment.
- * Other special cases could be added, but in most applications these are
- * the only common cases. (For uncommon cases we fall back on the more
- * general code in jdsample.c and jdcolor.c.)
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-#include "jdmerge.h"
-#include "jsimd.h"
-#include "jconfigint.h"
-
-#ifdef UPSAMPLE_MERGING_SUPPORTED
-
-
-#define SCALEBITS 16 /* speediest right-shift on some machines */
-#define ONE_HALF ((JLONG)1 << (SCALEBITS - 1))
-#define FIX(x) ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
-
-
-/* Include inline routines for colorspace extensions */
-
-#include "jdmrgext.c"
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_PIXELSIZE
-
-#define RGB_RED EXT_RGB_RED
-#define RGB_GREEN EXT_RGB_GREEN
-#define RGB_BLUE EXT_RGB_BLUE
-#define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
-#define h2v1_merged_upsample_internal extrgb_h2v1_merged_upsample_internal
-#define h2v2_merged_upsample_internal extrgb_h2v2_merged_upsample_internal
-#include "jdmrgext.c"
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_PIXELSIZE
-#undef h2v1_merged_upsample_internal
-#undef h2v2_merged_upsample_internal
-
-#define RGB_RED EXT_RGBX_RED
-#define RGB_GREEN EXT_RGBX_GREEN
-#define RGB_BLUE EXT_RGBX_BLUE
-#define RGB_ALPHA 3
-#define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
-#define h2v1_merged_upsample_internal extrgbx_h2v1_merged_upsample_internal
-#define h2v2_merged_upsample_internal extrgbx_h2v2_merged_upsample_internal
-#include "jdmrgext.c"
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_ALPHA
-#undef RGB_PIXELSIZE
-#undef h2v1_merged_upsample_internal
-#undef h2v2_merged_upsample_internal
-
-#define RGB_RED EXT_BGR_RED
-#define RGB_GREEN EXT_BGR_GREEN
-#define RGB_BLUE EXT_BGR_BLUE
-#define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
-#define h2v1_merged_upsample_internal extbgr_h2v1_merged_upsample_internal
-#define h2v2_merged_upsample_internal extbgr_h2v2_merged_upsample_internal
-#include "jdmrgext.c"
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_PIXELSIZE
-#undef h2v1_merged_upsample_internal
-#undef h2v2_merged_upsample_internal
-
-#define RGB_RED EXT_BGRX_RED
-#define RGB_GREEN EXT_BGRX_GREEN
-#define RGB_BLUE EXT_BGRX_BLUE
-#define RGB_ALPHA 3
-#define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
-#define h2v1_merged_upsample_internal extbgrx_h2v1_merged_upsample_internal
-#define h2v2_merged_upsample_internal extbgrx_h2v2_merged_upsample_internal
-#include "jdmrgext.c"
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_ALPHA
-#undef RGB_PIXELSIZE
-#undef h2v1_merged_upsample_internal
-#undef h2v2_merged_upsample_internal
-
-#define RGB_RED EXT_XBGR_RED
-#define RGB_GREEN EXT_XBGR_GREEN
-#define RGB_BLUE EXT_XBGR_BLUE
-#define RGB_ALPHA 0
-#define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
-#define h2v1_merged_upsample_internal extxbgr_h2v1_merged_upsample_internal
-#define h2v2_merged_upsample_internal extxbgr_h2v2_merged_upsample_internal
-#include "jdmrgext.c"
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_ALPHA
-#undef RGB_PIXELSIZE
-#undef h2v1_merged_upsample_internal
-#undef h2v2_merged_upsample_internal
-
-#define RGB_RED EXT_XRGB_RED
-#define RGB_GREEN EXT_XRGB_GREEN
-#define RGB_BLUE EXT_XRGB_BLUE
-#define RGB_ALPHA 0
-#define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
-#define h2v1_merged_upsample_internal extxrgb_h2v1_merged_upsample_internal
-#define h2v2_merged_upsample_internal extxrgb_h2v2_merged_upsample_internal
-#include "jdmrgext.c"
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_ALPHA
-#undef RGB_PIXELSIZE
-#undef h2v1_merged_upsample_internal
-#undef h2v2_merged_upsample_internal
-
-
-/*
- * Initialize tables for YCC->RGB colorspace conversion.
- * This is taken directly from jdcolor.c; see that file for more info.
- */
-
-LOCAL(void)
-build_ycc_rgb_table(j_decompress_ptr cinfo)
-{
- my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
- int i;
- JLONG x;
- SHIFT_TEMPS
-
- upsample->Cr_r_tab = (int *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- (MAXJSAMPLE + 1) * sizeof(int));
- upsample->Cb_b_tab = (int *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- (MAXJSAMPLE + 1) * sizeof(int));
- upsample->Cr_g_tab = (JLONG *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- (MAXJSAMPLE + 1) * sizeof(JLONG));
- upsample->Cb_g_tab = (JLONG *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- (MAXJSAMPLE + 1) * sizeof(JLONG));
-
- for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) {
- /* i is the actual input pixel value, in the range 0..MAXJSAMPLE */
- /* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */
- /* Cr=>R value is nearest int to 1.40200 * x */
- upsample->Cr_r_tab[i] = (int)
- RIGHT_SHIFT(FIX(1.40200) * x + ONE_HALF, SCALEBITS);
- /* Cb=>B value is nearest int to 1.77200 * x */
- upsample->Cb_b_tab[i] = (int)
- RIGHT_SHIFT(FIX(1.77200) * x + ONE_HALF, SCALEBITS);
- /* Cr=>G value is scaled-up -0.71414 * x */
- upsample->Cr_g_tab[i] = (-FIX(0.71414)) * x;
- /* Cb=>G value is scaled-up -0.34414 * x */
- /* We also add in ONE_HALF so that need not do it in inner loop */
- upsample->Cb_g_tab[i] = (-FIX(0.34414)) * x + ONE_HALF;
- }
-}
-
-
-/*
- * Initialize for an upsampling pass.
- */
-
-METHODDEF(void)
-start_pass_merged_upsample(j_decompress_ptr cinfo)
-{
- my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
-
- /* Mark the spare buffer empty */
- upsample->spare_full = FALSE;
- /* Initialize total-height counter for detecting bottom of image */
- upsample->rows_to_go = cinfo->output_height;
-}
-
-
-/*
- * Control routine to do upsampling (and color conversion).
- *
- * The control routine just handles the row buffering considerations.
- */
-
-METHODDEF(void)
-merged_2v_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION *in_row_group_ctr,
- JDIMENSION in_row_groups_avail, JSAMPARRAY output_buf,
- JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
-/* 2:1 vertical sampling case: may need a spare row. */
-{
- my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
- JSAMPROW work_ptrs[2];
- JDIMENSION num_rows; /* number of rows returned to caller */
-
- if (upsample->spare_full) {
- /* If we have a spare row saved from a previous cycle, just return it. */
- JDIMENSION size = upsample->out_row_width;
- if (cinfo->out_color_space == JCS_RGB565)
- size = cinfo->output_width * 2;
- jcopy_sample_rows(&upsample->spare_row, 0, output_buf + *out_row_ctr, 0, 1,
- size);
- num_rows = 1;
- upsample->spare_full = FALSE;
- } else {
- /* Figure number of rows to return to caller. */
- num_rows = 2;
- /* Not more than the distance to the end of the image. */
- if (num_rows > upsample->rows_to_go)
- num_rows = upsample->rows_to_go;
- /* And not more than what the client can accept: */
- out_rows_avail -= *out_row_ctr;
- if (num_rows > out_rows_avail)
- num_rows = out_rows_avail;
- /* Create output pointer array for upsampler. */
- work_ptrs[0] = output_buf[*out_row_ctr];
- if (num_rows > 1) {
- work_ptrs[1] = output_buf[*out_row_ctr + 1];
- } else {
- work_ptrs[1] = upsample->spare_row;
- upsample->spare_full = TRUE;
- }
- /* Now do the upsampling. */
- (*upsample->upmethod) (cinfo, input_buf, *in_row_group_ctr, work_ptrs);
- }
-
- /* Adjust counts */
- *out_row_ctr += num_rows;
- upsample->rows_to_go -= num_rows;
- /* When the buffer is emptied, declare this input row group consumed */
- if (!upsample->spare_full)
- (*in_row_group_ctr)++;
-}
-
-
-METHODDEF(void)
-merged_1v_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION *in_row_group_ctr,
- JDIMENSION in_row_groups_avail, JSAMPARRAY output_buf,
- JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
-/* 1:1 vertical sampling case: much easier, never need a spare row. */
-{
- my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
-
- /* Just do the upsampling. */
- (*upsample->upmethod) (cinfo, input_buf, *in_row_group_ctr,
- output_buf + *out_row_ctr);
- /* Adjust counts */
- (*out_row_ctr)++;
- (*in_row_group_ctr)++;
-}
-
-
-/*
- * These are the routines invoked by the control routines to do
- * the actual upsampling/conversion. One row group is processed per call.
- *
- * Note: since we may be writing directly into application-supplied buffers,
- * we have to be honest about the output width; we can't assume the buffer
- * has been rounded up to an even width.
- */
-
-
-/*
- * Upsample and color convert for the case of 2:1 horizontal and 1:1 vertical.
- */
-
-METHODDEF(void)
-h2v1_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
-{
- switch (cinfo->out_color_space) {
- case JCS_EXT_RGB:
- extrgb_h2v1_merged_upsample_internal(cinfo, input_buf, in_row_group_ctr,
- output_buf);
- break;
- case JCS_EXT_RGBX:
- case JCS_EXT_RGBA:
- extrgbx_h2v1_merged_upsample_internal(cinfo, input_buf, in_row_group_ctr,
- output_buf);
- break;
- case JCS_EXT_BGR:
- extbgr_h2v1_merged_upsample_internal(cinfo, input_buf, in_row_group_ctr,
- output_buf);
- break;
- case JCS_EXT_BGRX:
- case JCS_EXT_BGRA:
- extbgrx_h2v1_merged_upsample_internal(cinfo, input_buf, in_row_group_ctr,
- output_buf);
- break;
- case JCS_EXT_XBGR:
- case JCS_EXT_ABGR:
- extxbgr_h2v1_merged_upsample_internal(cinfo, input_buf, in_row_group_ctr,
- output_buf);
- break;
- case JCS_EXT_XRGB:
- case JCS_EXT_ARGB:
- extxrgb_h2v1_merged_upsample_internal(cinfo, input_buf, in_row_group_ctr,
- output_buf);
- break;
- default:
- h2v1_merged_upsample_internal(cinfo, input_buf, in_row_group_ctr,
- output_buf);
- break;
- }
-}
-
-
-/*
- * Upsample and color convert for the case of 2:1 horizontal and 2:1 vertical.
- */
-
-METHODDEF(void)
-h2v2_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
-{
- switch (cinfo->out_color_space) {
- case JCS_EXT_RGB:
- extrgb_h2v2_merged_upsample_internal(cinfo, input_buf, in_row_group_ctr,
- output_buf);
- break;
- case JCS_EXT_RGBX:
- case JCS_EXT_RGBA:
- extrgbx_h2v2_merged_upsample_internal(cinfo, input_buf, in_row_group_ctr,
- output_buf);
- break;
- case JCS_EXT_BGR:
- extbgr_h2v2_merged_upsample_internal(cinfo, input_buf, in_row_group_ctr,
- output_buf);
- break;
- case JCS_EXT_BGRX:
- case JCS_EXT_BGRA:
- extbgrx_h2v2_merged_upsample_internal(cinfo, input_buf, in_row_group_ctr,
- output_buf);
- break;
- case JCS_EXT_XBGR:
- case JCS_EXT_ABGR:
- extxbgr_h2v2_merged_upsample_internal(cinfo, input_buf, in_row_group_ctr,
- output_buf);
- break;
- case JCS_EXT_XRGB:
- case JCS_EXT_ARGB:
- extxrgb_h2v2_merged_upsample_internal(cinfo, input_buf, in_row_group_ctr,
- output_buf);
- break;
- default:
- h2v2_merged_upsample_internal(cinfo, input_buf, in_row_group_ctr,
- output_buf);
- break;
- }
-}
-
-
-/*
- * RGB565 conversion
- */
-
-#define PACK_SHORT_565_LE(r, g, b) \
- ((((r) << 8) & 0xF800) | (((g) << 3) & 0x7E0) | ((b) >> 3))
-#define PACK_SHORT_565_BE(r, g, b) \
- (((r) & 0xF8) | ((g) >> 5) | (((g) << 11) & 0xE000) | (((b) << 5) & 0x1F00))
-
-#define PACK_TWO_PIXELS_LE(l, r) ((r << 16) | l)
-#define PACK_TWO_PIXELS_BE(l, r) ((l << 16) | r)
-
-#define WRITE_TWO_PIXELS_LE(addr, pixels) { \
- ((INT16 *)(addr))[0] = (INT16)(pixels); \
- ((INT16 *)(addr))[1] = (INT16)((pixels) >> 16); \
-}
-#define WRITE_TWO_PIXELS_BE(addr, pixels) { \
- ((INT16 *)(addr))[1] = (INT16)(pixels); \
- ((INT16 *)(addr))[0] = (INT16)((pixels) >> 16); \
-}
-
-#define DITHER_565_R(r, dither) ((r) + ((dither) & 0xFF))
-#define DITHER_565_G(g, dither) ((g) + (((dither) & 0xFF) >> 1))
-#define DITHER_565_B(b, dither) ((b) + ((dither) & 0xFF))
-
-
-/* Declarations for ordered dithering
- *
- * We use a 4x4 ordered dither array packed into 32 bits. This array is
- * sufficient for dithering RGB888 to RGB565.
- */
-
-#define DITHER_MASK 0x3
-#define DITHER_ROTATE(x) ((((x) & 0xFF) << 24) | (((x) >> 8) & 0x00FFFFFF))
-static const JLONG dither_matrix[4] = {
- 0x0008020A,
- 0x0C040E06,
- 0x030B0109,
- 0x0F070D05
-};
-
-
-/* Include inline routines for RGB565 conversion */
-
-#define PACK_SHORT_565 PACK_SHORT_565_LE
-#define PACK_TWO_PIXELS PACK_TWO_PIXELS_LE
-#define WRITE_TWO_PIXELS WRITE_TWO_PIXELS_LE
-#define h2v1_merged_upsample_565_internal h2v1_merged_upsample_565_le
-#define h2v1_merged_upsample_565D_internal h2v1_merged_upsample_565D_le
-#define h2v2_merged_upsample_565_internal h2v2_merged_upsample_565_le
-#define h2v2_merged_upsample_565D_internal h2v2_merged_upsample_565D_le
-#include "jdmrg565.c"
-#undef PACK_SHORT_565
-#undef PACK_TWO_PIXELS
-#undef WRITE_TWO_PIXELS
-#undef h2v1_merged_upsample_565_internal
-#undef h2v1_merged_upsample_565D_internal
-#undef h2v2_merged_upsample_565_internal
-#undef h2v2_merged_upsample_565D_internal
-
-#define PACK_SHORT_565 PACK_SHORT_565_BE
-#define PACK_TWO_PIXELS PACK_TWO_PIXELS_BE
-#define WRITE_TWO_PIXELS WRITE_TWO_PIXELS_BE
-#define h2v1_merged_upsample_565_internal h2v1_merged_upsample_565_be
-#define h2v1_merged_upsample_565D_internal h2v1_merged_upsample_565D_be
-#define h2v2_merged_upsample_565_internal h2v2_merged_upsample_565_be
-#define h2v2_merged_upsample_565D_internal h2v2_merged_upsample_565D_be
-#include "jdmrg565.c"
-#undef PACK_SHORT_565
-#undef PACK_TWO_PIXELS
-#undef WRITE_TWO_PIXELS
-#undef h2v1_merged_upsample_565_internal
-#undef h2v1_merged_upsample_565D_internal
-#undef h2v2_merged_upsample_565_internal
-#undef h2v2_merged_upsample_565D_internal
-
-
-static INLINE boolean is_big_endian(void)
-{
- int test_value = 1;
- if (*(char *)&test_value != 1)
- return TRUE;
- return FALSE;
-}
-
-
-METHODDEF(void)
-h2v1_merged_upsample_565(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
-{
- if (is_big_endian())
- h2v1_merged_upsample_565_be(cinfo, input_buf, in_row_group_ctr,
- output_buf);
- else
- h2v1_merged_upsample_565_le(cinfo, input_buf, in_row_group_ctr,
- output_buf);
-}
-
-
-METHODDEF(void)
-h2v1_merged_upsample_565D(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
-{
- if (is_big_endian())
- h2v1_merged_upsample_565D_be(cinfo, input_buf, in_row_group_ctr,
- output_buf);
- else
- h2v1_merged_upsample_565D_le(cinfo, input_buf, in_row_group_ctr,
- output_buf);
-}
-
-
-METHODDEF(void)
-h2v2_merged_upsample_565(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
-{
- if (is_big_endian())
- h2v2_merged_upsample_565_be(cinfo, input_buf, in_row_group_ctr,
- output_buf);
- else
- h2v2_merged_upsample_565_le(cinfo, input_buf, in_row_group_ctr,
- output_buf);
-}
-
-
-METHODDEF(void)
-h2v2_merged_upsample_565D(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
-{
- if (is_big_endian())
- h2v2_merged_upsample_565D_be(cinfo, input_buf, in_row_group_ctr,
- output_buf);
- else
- h2v2_merged_upsample_565D_le(cinfo, input_buf, in_row_group_ctr,
- output_buf);
-}
-
-
-/*
- * Module initialization routine for merged upsampling/color conversion.
- *
- * NB: this is called under the conditions determined by use_merged_upsample()
- * in jdmaster.c. That routine MUST correspond to the actual capabilities
- * of this module; no safety checks are made here.
- */
-
-GLOBAL(void)
-jinit_merged_upsampler(j_decompress_ptr cinfo)
-{
- my_merged_upsample_ptr upsample;
-
- upsample = (my_merged_upsample_ptr)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- sizeof(my_merged_upsampler));
- cinfo->upsample = (struct jpeg_upsampler *)upsample;
- upsample->pub.start_pass = start_pass_merged_upsample;
- upsample->pub.need_context_rows = FALSE;
-
- upsample->out_row_width = cinfo->output_width * cinfo->out_color_components;
-
- if (cinfo->max_v_samp_factor == 2) {
- upsample->pub.upsample = merged_2v_upsample;
- if (jsimd_can_h2v2_merged_upsample())
- upsample->upmethod = jsimd_h2v2_merged_upsample;
- else
- upsample->upmethod = h2v2_merged_upsample;
- if (cinfo->out_color_space == JCS_RGB565) {
- if (cinfo->dither_mode != JDITHER_NONE) {
- upsample->upmethod = h2v2_merged_upsample_565D;
- } else {
- upsample->upmethod = h2v2_merged_upsample_565;
- }
- }
- /* Allocate a spare row buffer */
- upsample->spare_row = (JSAMPROW)
- (*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- (size_t)(upsample->out_row_width * sizeof(JSAMPLE)));
- } else {
- upsample->pub.upsample = merged_1v_upsample;
- if (jsimd_can_h2v1_merged_upsample())
- upsample->upmethod = jsimd_h2v1_merged_upsample;
- else
- upsample->upmethod = h2v1_merged_upsample;
- if (cinfo->out_color_space == JCS_RGB565) {
- if (cinfo->dither_mode != JDITHER_NONE) {
- upsample->upmethod = h2v1_merged_upsample_565D;
- } else {
- upsample->upmethod = h2v1_merged_upsample_565;
- }
- }
- /* No spare row needed */
- upsample->spare_row = NULL;
- }
-
- build_ycc_rgb_table(cinfo);
-}
-
-#endif /* UPSAMPLE_MERGING_SUPPORTED */
diff --git a/contrib/libs/libjpeg-turbo/jdmerge.h b/contrib/libs/libjpeg-turbo/jdmerge.h
deleted file mode 100644
index b583396b10..0000000000
--- a/contrib/libs/libjpeg-turbo/jdmerge.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * jdmerge.h
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2020, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- */
-
-#define JPEG_INTERNALS
-#include "jpeglib.h"
-
-#ifdef UPSAMPLE_MERGING_SUPPORTED
-
-
-/* Private subobject */
-
-typedef struct {
- struct jpeg_upsampler pub; /* public fields */
-
- /* Pointer to routine to do actual upsampling/conversion of one row group */
- void (*upmethod) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf);
-
- /* Private state for YCC->RGB conversion */
- int *Cr_r_tab; /* => table for Cr to R conversion */
- int *Cb_b_tab; /* => table for Cb to B conversion */
- JLONG *Cr_g_tab; /* => table for Cr to G conversion */
- JLONG *Cb_g_tab; /* => table for Cb to G conversion */
-
- /* For 2:1 vertical sampling, we produce two output rows at a time.
- * We need a "spare" row buffer to hold the second output row if the
- * application provides just a one-row buffer; we also use the spare
- * to discard the dummy last row if the image height is odd.
- */
- JSAMPROW spare_row;
- boolean spare_full; /* T if spare buffer is occupied */
-
- JDIMENSION out_row_width; /* samples per output row */
- JDIMENSION rows_to_go; /* counts rows remaining in image */
-} my_merged_upsampler;
-
-typedef my_merged_upsampler *my_merged_upsample_ptr;
-
-#endif /* UPSAMPLE_MERGING_SUPPORTED */
diff --git a/contrib/libs/libjpeg-turbo/jdmrg565.c b/contrib/libs/libjpeg-turbo/jdmrg565.c
deleted file mode 100644
index 980a4e216e..0000000000
--- a/contrib/libs/libjpeg-turbo/jdmrg565.c
+++ /dev/null
@@ -1,354 +0,0 @@
-/*
- * jdmrg565.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2013, Linaro Limited.
- * Copyright (C) 2014-2015, 2018, 2020, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains code for merged upsampling/color conversion.
- */
-
-
-INLINE
-LOCAL(void)
-h2v1_merged_upsample_565_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf)
-{
- my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
- register int y, cred, cgreen, cblue;
- int cb, cr;
- register JSAMPROW outptr;
- JSAMPROW inptr0, inptr1, inptr2;
- JDIMENSION col;
- /* copy these pointers into registers if possible */
- register JSAMPLE *range_limit = cinfo->sample_range_limit;
- int *Crrtab = upsample->Cr_r_tab;
- int *Cbbtab = upsample->Cb_b_tab;
- JLONG *Crgtab = upsample->Cr_g_tab;
- JLONG *Cbgtab = upsample->Cb_g_tab;
- unsigned int r, g, b;
- JLONG rgb;
- SHIFT_TEMPS
-
- inptr0 = input_buf[0][in_row_group_ctr];
- inptr1 = input_buf[1][in_row_group_ctr];
- inptr2 = input_buf[2][in_row_group_ctr];
- outptr = output_buf[0];
-
- /* Loop for each pair of output pixels */
- for (col = cinfo->output_width >> 1; col > 0; col--) {
- /* Do the chroma part of the calculation */
- cb = *inptr1++;
- cr = *inptr2++;
- cred = Crrtab[cr];
- cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
- cblue = Cbbtab[cb];
-
- /* Fetch 2 Y values and emit 2 pixels */
- y = *inptr0++;
- r = range_limit[y + cred];
- g = range_limit[y + cgreen];
- b = range_limit[y + cblue];
- rgb = PACK_SHORT_565(r, g, b);
-
- y = *inptr0++;
- r = range_limit[y + cred];
- g = range_limit[y + cgreen];
- b = range_limit[y + cblue];
- rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
-
- WRITE_TWO_PIXELS(outptr, rgb);
- outptr += 4;
- }
-
- /* If image width is odd, do the last output column separately */
- if (cinfo->output_width & 1) {
- cb = *inptr1;
- cr = *inptr2;
- cred = Crrtab[cr];
- cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
- cblue = Cbbtab[cb];
- y = *inptr0;
- r = range_limit[y + cred];
- g = range_limit[y + cgreen];
- b = range_limit[y + cblue];
- rgb = PACK_SHORT_565(r, g, b);
- *(INT16 *)outptr = (INT16)rgb;
- }
-}
-
-
-INLINE
-LOCAL(void)
-h2v1_merged_upsample_565D_internal(j_decompress_ptr cinfo,
- JSAMPIMAGE input_buf,
- JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf)
-{
- my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
- register int y, cred, cgreen, cblue;
- int cb, cr;
- register JSAMPROW outptr;
- JSAMPROW inptr0, inptr1, inptr2;
- JDIMENSION col;
- /* copy these pointers into registers if possible */
- register JSAMPLE *range_limit = cinfo->sample_range_limit;
- int *Crrtab = upsample->Cr_r_tab;
- int *Cbbtab = upsample->Cb_b_tab;
- JLONG *Crgtab = upsample->Cr_g_tab;
- JLONG *Cbgtab = upsample->Cb_g_tab;
- JLONG d0 = dither_matrix[cinfo->output_scanline & DITHER_MASK];
- unsigned int r, g, b;
- JLONG rgb;
- SHIFT_TEMPS
-
- inptr0 = input_buf[0][in_row_group_ctr];
- inptr1 = input_buf[1][in_row_group_ctr];
- inptr2 = input_buf[2][in_row_group_ctr];
- outptr = output_buf[0];
-
- /* Loop for each pair of output pixels */
- for (col = cinfo->output_width >> 1; col > 0; col--) {
- /* Do the chroma part of the calculation */
- cb = *inptr1++;
- cr = *inptr2++;
- cred = Crrtab[cr];
- cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
- cblue = Cbbtab[cb];
-
- /* Fetch 2 Y values and emit 2 pixels */
- y = *inptr0++;
- r = range_limit[DITHER_565_R(y + cred, d0)];
- g = range_limit[DITHER_565_G(y + cgreen, d0)];
- b = range_limit[DITHER_565_B(y + cblue, d0)];
- d0 = DITHER_ROTATE(d0);
- rgb = PACK_SHORT_565(r, g, b);
-
- y = *inptr0++;
- r = range_limit[DITHER_565_R(y + cred, d0)];
- g = range_limit[DITHER_565_G(y + cgreen, d0)];
- b = range_limit[DITHER_565_B(y + cblue, d0)];
- d0 = DITHER_ROTATE(d0);
- rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
-
- WRITE_TWO_PIXELS(outptr, rgb);
- outptr += 4;
- }
-
- /* If image width is odd, do the last output column separately */
- if (cinfo->output_width & 1) {
- cb = *inptr1;
- cr = *inptr2;
- cred = Crrtab[cr];
- cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
- cblue = Cbbtab[cb];
- y = *inptr0;
- r = range_limit[DITHER_565_R(y + cred, d0)];
- g = range_limit[DITHER_565_G(y + cgreen, d0)];
- b = range_limit[DITHER_565_B(y + cblue, d0)];
- rgb = PACK_SHORT_565(r, g, b);
- *(INT16 *)outptr = (INT16)rgb;
- }
-}
-
-
-INLINE
-LOCAL(void)
-h2v2_merged_upsample_565_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf)
-{
- my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
- register int y, cred, cgreen, cblue;
- int cb, cr;
- register JSAMPROW outptr0, outptr1;
- JSAMPROW inptr00, inptr01, inptr1, inptr2;
- JDIMENSION col;
- /* copy these pointers into registers if possible */
- register JSAMPLE *range_limit = cinfo->sample_range_limit;
- int *Crrtab = upsample->Cr_r_tab;
- int *Cbbtab = upsample->Cb_b_tab;
- JLONG *Crgtab = upsample->Cr_g_tab;
- JLONG *Cbgtab = upsample->Cb_g_tab;
- unsigned int r, g, b;
- JLONG rgb;
- SHIFT_TEMPS
-
- inptr00 = input_buf[0][in_row_group_ctr * 2];
- inptr01 = input_buf[0][in_row_group_ctr * 2 + 1];
- inptr1 = input_buf[1][in_row_group_ctr];
- inptr2 = input_buf[2][in_row_group_ctr];
- outptr0 = output_buf[0];
- outptr1 = output_buf[1];
-
- /* Loop for each group of output pixels */
- for (col = cinfo->output_width >> 1; col > 0; col--) {
- /* Do the chroma part of the calculation */
- cb = *inptr1++;
- cr = *inptr2++;
- cred = Crrtab[cr];
- cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
- cblue = Cbbtab[cb];
-
- /* Fetch 4 Y values and emit 4 pixels */
- y = *inptr00++;
- r = range_limit[y + cred];
- g = range_limit[y + cgreen];
- b = range_limit[y + cblue];
- rgb = PACK_SHORT_565(r, g, b);
-
- y = *inptr00++;
- r = range_limit[y + cred];
- g = range_limit[y + cgreen];
- b = range_limit[y + cblue];
- rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
-
- WRITE_TWO_PIXELS(outptr0, rgb);
- outptr0 += 4;
-
- y = *inptr01++;
- r = range_limit[y + cred];
- g = range_limit[y + cgreen];
- b = range_limit[y + cblue];
- rgb = PACK_SHORT_565(r, g, b);
-
- y = *inptr01++;
- r = range_limit[y + cred];
- g = range_limit[y + cgreen];
- b = range_limit[y + cblue];
- rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
-
- WRITE_TWO_PIXELS(outptr1, rgb);
- outptr1 += 4;
- }
-
- /* If image width is odd, do the last output column separately */
- if (cinfo->output_width & 1) {
- cb = *inptr1;
- cr = *inptr2;
- cred = Crrtab[cr];
- cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
- cblue = Cbbtab[cb];
-
- y = *inptr00;
- r = range_limit[y + cred];
- g = range_limit[y + cgreen];
- b = range_limit[y + cblue];
- rgb = PACK_SHORT_565(r, g, b);
- *(INT16 *)outptr0 = (INT16)rgb;
-
- y = *inptr01;
- r = range_limit[y + cred];
- g = range_limit[y + cgreen];
- b = range_limit[y + cblue];
- rgb = PACK_SHORT_565(r, g, b);
- *(INT16 *)outptr1 = (INT16)rgb;
- }
-}
-
-
-INLINE
-LOCAL(void)
-h2v2_merged_upsample_565D_internal(j_decompress_ptr cinfo,
- JSAMPIMAGE input_buf,
- JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf)
-{
- my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
- register int y, cred, cgreen, cblue;
- int cb, cr;
- register JSAMPROW outptr0, outptr1;
- JSAMPROW inptr00, inptr01, inptr1, inptr2;
- JDIMENSION col;
- /* copy these pointers into registers if possible */
- register JSAMPLE *range_limit = cinfo->sample_range_limit;
- int *Crrtab = upsample->Cr_r_tab;
- int *Cbbtab = upsample->Cb_b_tab;
- JLONG *Crgtab = upsample->Cr_g_tab;
- JLONG *Cbgtab = upsample->Cb_g_tab;
- JLONG d0 = dither_matrix[cinfo->output_scanline & DITHER_MASK];
- JLONG d1 = dither_matrix[(cinfo->output_scanline + 1) & DITHER_MASK];
- unsigned int r, g, b;
- JLONG rgb;
- SHIFT_TEMPS
-
- inptr00 = input_buf[0][in_row_group_ctr * 2];
- inptr01 = input_buf[0][in_row_group_ctr * 2 + 1];
- inptr1 = input_buf[1][in_row_group_ctr];
- inptr2 = input_buf[2][in_row_group_ctr];
- outptr0 = output_buf[0];
- outptr1 = output_buf[1];
-
- /* Loop for each group of output pixels */
- for (col = cinfo->output_width >> 1; col > 0; col--) {
- /* Do the chroma part of the calculation */
- cb = *inptr1++;
- cr = *inptr2++;
- cred = Crrtab[cr];
- cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
- cblue = Cbbtab[cb];
-
- /* Fetch 4 Y values and emit 4 pixels */
- y = *inptr00++;
- r = range_limit[DITHER_565_R(y + cred, d0)];
- g = range_limit[DITHER_565_G(y + cgreen, d0)];
- b = range_limit[DITHER_565_B(y + cblue, d0)];
- d0 = DITHER_ROTATE(d0);
- rgb = PACK_SHORT_565(r, g, b);
-
- y = *inptr00++;
- r = range_limit[DITHER_565_R(y + cred, d0)];
- g = range_limit[DITHER_565_G(y + cgreen, d0)];
- b = range_limit[DITHER_565_B(y + cblue, d0)];
- d0 = DITHER_ROTATE(d0);
- rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
-
- WRITE_TWO_PIXELS(outptr0, rgb);
- outptr0 += 4;
-
- y = *inptr01++;
- r = range_limit[DITHER_565_R(y + cred, d1)];
- g = range_limit[DITHER_565_G(y + cgreen, d1)];
- b = range_limit[DITHER_565_B(y + cblue, d1)];
- d1 = DITHER_ROTATE(d1);
- rgb = PACK_SHORT_565(r, g, b);
-
- y = *inptr01++;
- r = range_limit[DITHER_565_R(y + cred, d1)];
- g = range_limit[DITHER_565_G(y + cgreen, d1)];
- b = range_limit[DITHER_565_B(y + cblue, d1)];
- d1 = DITHER_ROTATE(d1);
- rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
-
- WRITE_TWO_PIXELS(outptr1, rgb);
- outptr1 += 4;
- }
-
- /* If image width is odd, do the last output column separately */
- if (cinfo->output_width & 1) {
- cb = *inptr1;
- cr = *inptr2;
- cred = Crrtab[cr];
- cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
- cblue = Cbbtab[cb];
-
- y = *inptr00;
- r = range_limit[DITHER_565_R(y + cred, d0)];
- g = range_limit[DITHER_565_G(y + cgreen, d0)];
- b = range_limit[DITHER_565_B(y + cblue, d0)];
- rgb = PACK_SHORT_565(r, g, b);
- *(INT16 *)outptr0 = (INT16)rgb;
-
- y = *inptr01;
- r = range_limit[DITHER_565_R(y + cred, d1)];
- g = range_limit[DITHER_565_G(y + cgreen, d1)];
- b = range_limit[DITHER_565_B(y + cblue, d1)];
- rgb = PACK_SHORT_565(r, g, b);
- *(INT16 *)outptr1 = (INT16)rgb;
- }
-}
diff --git a/contrib/libs/libjpeg-turbo/jdmrgext.c b/contrib/libs/libjpeg-turbo/jdmrgext.c
deleted file mode 100644
index 9bf4f1a307..0000000000
--- a/contrib/libs/libjpeg-turbo/jdmrgext.c
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * jdmrgext.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2011, 2015, 2020, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains code for merged upsampling/color conversion.
- */
-
-
-/* This file is included by jdmerge.c */
-
-
-/*
- * Upsample and color convert for the case of 2:1 horizontal and 1:1 vertical.
- */
-
-INLINE
-LOCAL(void)
-h2v1_merged_upsample_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf)
-{
- my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
- register int y, cred, cgreen, cblue;
- int cb, cr;
- register JSAMPROW outptr;
- JSAMPROW inptr0, inptr1, inptr2;
- JDIMENSION col;
- /* copy these pointers into registers if possible */
- register JSAMPLE *range_limit = cinfo->sample_range_limit;
- int *Crrtab = upsample->Cr_r_tab;
- int *Cbbtab = upsample->Cb_b_tab;
- JLONG *Crgtab = upsample->Cr_g_tab;
- JLONG *Cbgtab = upsample->Cb_g_tab;
- SHIFT_TEMPS
-
- inptr0 = input_buf[0][in_row_group_ctr];
- inptr1 = input_buf[1][in_row_group_ctr];
- inptr2 = input_buf[2][in_row_group_ctr];
- outptr = output_buf[0];
- /* Loop for each pair of output pixels */
- for (col = cinfo->output_width >> 1; col > 0; col--) {
- /* Do the chroma part of the calculation */
- cb = *inptr1++;
- cr = *inptr2++;
- cred = Crrtab[cr];
- cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
- cblue = Cbbtab[cb];
- /* Fetch 2 Y values and emit 2 pixels */
- y = *inptr0++;
- outptr[RGB_RED] = range_limit[y + cred];
- outptr[RGB_GREEN] = range_limit[y + cgreen];
- outptr[RGB_BLUE] = range_limit[y + cblue];
-#ifdef RGB_ALPHA
- outptr[RGB_ALPHA] = 0xFF;
-#endif
- outptr += RGB_PIXELSIZE;
- y = *inptr0++;
- outptr[RGB_RED] = range_limit[y + cred];
- outptr[RGB_GREEN] = range_limit[y + cgreen];
- outptr[RGB_BLUE] = range_limit[y + cblue];
-#ifdef RGB_ALPHA
- outptr[RGB_ALPHA] = 0xFF;
-#endif
- outptr += RGB_PIXELSIZE;
- }
- /* If image width is odd, do the last output column separately */
- if (cinfo->output_width & 1) {
- cb = *inptr1;
- cr = *inptr2;
- cred = Crrtab[cr];
- cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
- cblue = Cbbtab[cb];
- y = *inptr0;
- outptr[RGB_RED] = range_limit[y + cred];
- outptr[RGB_GREEN] = range_limit[y + cgreen];
- outptr[RGB_BLUE] = range_limit[y + cblue];
-#ifdef RGB_ALPHA
- outptr[RGB_ALPHA] = 0xFF;
-#endif
- }
-}
-
-
-/*
- * Upsample and color convert for the case of 2:1 horizontal and 2:1 vertical.
- */
-
-INLINE
-LOCAL(void)
-h2v2_merged_upsample_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf)
-{
- my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
- register int y, cred, cgreen, cblue;
- int cb, cr;
- register JSAMPROW outptr0, outptr1;
- JSAMPROW inptr00, inptr01, inptr1, inptr2;
- JDIMENSION col;
- /* copy these pointers into registers if possible */
- register JSAMPLE *range_limit = cinfo->sample_range_limit;
- int *Crrtab = upsample->Cr_r_tab;
- int *Cbbtab = upsample->Cb_b_tab;
- JLONG *Crgtab = upsample->Cr_g_tab;
- JLONG *Cbgtab = upsample->Cb_g_tab;
- SHIFT_TEMPS
-
- inptr00 = input_buf[0][in_row_group_ctr * 2];
- inptr01 = input_buf[0][in_row_group_ctr * 2 + 1];
- inptr1 = input_buf[1][in_row_group_ctr];
- inptr2 = input_buf[2][in_row_group_ctr];
- outptr0 = output_buf[0];
- outptr1 = output_buf[1];
- /* Loop for each group of output pixels */
- for (col = cinfo->output_width >> 1; col > 0; col--) {
- /* Do the chroma part of the calculation */
- cb = *inptr1++;
- cr = *inptr2++;
- cred = Crrtab[cr];
- cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
- cblue = Cbbtab[cb];
- /* Fetch 4 Y values and emit 4 pixels */
- y = *inptr00++;
- outptr0[RGB_RED] = range_limit[y + cred];
- outptr0[RGB_GREEN] = range_limit[y + cgreen];
- outptr0[RGB_BLUE] = range_limit[y + cblue];
-#ifdef RGB_ALPHA
- outptr0[RGB_ALPHA] = 0xFF;
-#endif
- outptr0 += RGB_PIXELSIZE;
- y = *inptr00++;
- outptr0[RGB_RED] = range_limit[y + cred];
- outptr0[RGB_GREEN] = range_limit[y + cgreen];
- outptr0[RGB_BLUE] = range_limit[y + cblue];
-#ifdef RGB_ALPHA
- outptr0[RGB_ALPHA] = 0xFF;
-#endif
- outptr0 += RGB_PIXELSIZE;
- y = *inptr01++;
- outptr1[RGB_RED] = range_limit[y + cred];
- outptr1[RGB_GREEN] = range_limit[y + cgreen];
- outptr1[RGB_BLUE] = range_limit[y + cblue];
-#ifdef RGB_ALPHA
- outptr1[RGB_ALPHA] = 0xFF;
-#endif
- outptr1 += RGB_PIXELSIZE;
- y = *inptr01++;
- outptr1[RGB_RED] = range_limit[y + cred];
- outptr1[RGB_GREEN] = range_limit[y + cgreen];
- outptr1[RGB_BLUE] = range_limit[y + cblue];
-#ifdef RGB_ALPHA
- outptr1[RGB_ALPHA] = 0xFF;
-#endif
- outptr1 += RGB_PIXELSIZE;
- }
- /* If image width is odd, do the last output column separately */
- if (cinfo->output_width & 1) {
- cb = *inptr1;
- cr = *inptr2;
- cred = Crrtab[cr];
- cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
- cblue = Cbbtab[cb];
- y = *inptr00;
- outptr0[RGB_RED] = range_limit[y + cred];
- outptr0[RGB_GREEN] = range_limit[y + cgreen];
- outptr0[RGB_BLUE] = range_limit[y + cblue];
-#ifdef RGB_ALPHA
- outptr0[RGB_ALPHA] = 0xFF;
-#endif
- y = *inptr01;
- outptr1[RGB_RED] = range_limit[y + cred];
- outptr1[RGB_GREEN] = range_limit[y + cgreen];
- outptr1[RGB_BLUE] = range_limit[y + cblue];
-#ifdef RGB_ALPHA
- outptr1[RGB_ALPHA] = 0xFF;
-#endif
- }
-}
diff --git a/contrib/libs/libjpeg-turbo/jdphuff.c b/contrib/libs/libjpeg-turbo/jdphuff.c
deleted file mode 100644
index 9680ebcbd0..0000000000
--- a/contrib/libs/libjpeg-turbo/jdphuff.c
+++ /dev/null
@@ -1,679 +0,0 @@
-/*
- * jdphuff.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1995-1997, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2015-2016, 2018-2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains Huffman entropy decoding routines for progressive JPEG.
- *
- * Much of the complexity here has to do with supporting input suspension.
- * If the data source module demands suspension, we want to be able to back
- * up to the start of the current MCU. To do this, we copy state variables
- * into local working storage, and update them back to the permanent
- * storage only upon successful completion of an MCU.
- *
- * NOTE: All referenced figures are from
- * Recommendation ITU-T T.81 (1992) | ISO/IEC 10918-1:1994.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-#include "jdhuff.h" /* Declarations shared with jdhuff.c */
-#include <limits.h>
-
-
-#ifdef D_PROGRESSIVE_SUPPORTED
-
-/*
- * Expanded entropy decoder object for progressive Huffman decoding.
- *
- * The savable_state subrecord contains fields that change within an MCU,
- * but must not be updated permanently until we complete the MCU.
- */
-
-typedef struct {
- unsigned int EOBRUN; /* remaining EOBs in EOBRUN */
- int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */
-} savable_state;
-
-typedef struct {
- struct jpeg_entropy_decoder pub; /* public fields */
-
- /* These fields are loaded into local variables at start of each MCU.
- * In case of suspension, we exit WITHOUT updating them.
- */
- bitread_perm_state bitstate; /* Bit buffer at start of MCU */
- savable_state saved; /* Other state at start of MCU */
-
- /* These fields are NOT loaded into local working state. */
- unsigned int restarts_to_go; /* MCUs left in this restart interval */
-
- /* Pointers to derived tables (these workspaces have image lifespan) */
- d_derived_tbl *derived_tbls[NUM_HUFF_TBLS];
-
- d_derived_tbl *ac_derived_tbl; /* active table during an AC scan */
-} phuff_entropy_decoder;
-
-typedef phuff_entropy_decoder *phuff_entropy_ptr;
-
-/* Forward declarations */
-METHODDEF(boolean) decode_mcu_DC_first(j_decompress_ptr cinfo,
- JBLOCKROW *MCU_data);
-METHODDEF(boolean) decode_mcu_AC_first(j_decompress_ptr cinfo,
- JBLOCKROW *MCU_data);
-METHODDEF(boolean) decode_mcu_DC_refine(j_decompress_ptr cinfo,
- JBLOCKROW *MCU_data);
-METHODDEF(boolean) decode_mcu_AC_refine(j_decompress_ptr cinfo,
- JBLOCKROW *MCU_data);
-
-
-/*
- * Initialize for a Huffman-compressed scan.
- */
-
-METHODDEF(void)
-start_pass_phuff_decoder(j_decompress_ptr cinfo)
-{
- phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
- boolean is_DC_band, bad;
- int ci, coefi, tbl;
- d_derived_tbl **pdtbl;
- int *coef_bit_ptr, *prev_coef_bit_ptr;
- jpeg_component_info *compptr;
-
- is_DC_band = (cinfo->Ss == 0);
-
- /* Validate scan parameters */
- bad = FALSE;
- if (is_DC_band) {
- if (cinfo->Se != 0)
- bad = TRUE;
- } else {
- /* need not check Ss/Se < 0 since they came from unsigned bytes */
- if (cinfo->Ss > cinfo->Se || cinfo->Se >= DCTSIZE2)
- bad = TRUE;
- /* AC scans may have only one component */
- if (cinfo->comps_in_scan != 1)
- bad = TRUE;
- }
- if (cinfo->Ah != 0) {
- /* Successive approximation refinement scan: must have Al = Ah-1. */
- if (cinfo->Al != cinfo->Ah - 1)
- bad = TRUE;
- }
- if (cinfo->Al > 13) /* need not check for < 0 */
- bad = TRUE;
- /* Arguably the maximum Al value should be less than 13 for 8-bit precision,
- * but the spec doesn't say so, and we try to be liberal about what we
- * accept. Note: large Al values could result in out-of-range DC
- * coefficients during early scans, leading to bizarre displays due to
- * overflows in the IDCT math. But we won't crash.
- */
- if (bad)
- ERREXIT4(cinfo, JERR_BAD_PROGRESSION,
- cinfo->Ss, cinfo->Se, cinfo->Ah, cinfo->Al);
- /* Update progression status, and verify that scan order is legal.
- * Note that inter-scan inconsistencies are treated as warnings
- * not fatal errors ... not clear if this is right way to behave.
- */
- for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
- int cindex = cinfo->cur_comp_info[ci]->component_index;
- coef_bit_ptr = &cinfo->coef_bits[cindex][0];
- prev_coef_bit_ptr = &cinfo->coef_bits[cindex + cinfo->num_components][0];
- if (!is_DC_band && coef_bit_ptr[0] < 0) /* AC without prior DC scan */
- WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, 0);
- for (coefi = MIN(cinfo->Ss, 1); coefi <= MAX(cinfo->Se, 9); coefi++) {
- if (cinfo->input_scan_number > 1)
- prev_coef_bit_ptr[coefi] = coef_bit_ptr[coefi];
- else
- prev_coef_bit_ptr[coefi] = 0;
- }
- for (coefi = cinfo->Ss; coefi <= cinfo->Se; coefi++) {
- int expected = (coef_bit_ptr[coefi] < 0) ? 0 : coef_bit_ptr[coefi];
- if (cinfo->Ah != expected)
- WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, coefi);
- coef_bit_ptr[coefi] = cinfo->Al;
- }
- }
-
- /* Select MCU decoding routine */
- if (cinfo->Ah == 0) {
- if (is_DC_band)
- entropy->pub.decode_mcu = decode_mcu_DC_first;
- else
- entropy->pub.decode_mcu = decode_mcu_AC_first;
- } else {
- if (is_DC_band)
- entropy->pub.decode_mcu = decode_mcu_DC_refine;
- else
- entropy->pub.decode_mcu = decode_mcu_AC_refine;
- }
-
- for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
- compptr = cinfo->cur_comp_info[ci];
- /* Make sure requested tables are present, and compute derived tables.
- * We may build same derived table more than once, but it's not expensive.
- */
- if (is_DC_band) {
- if (cinfo->Ah == 0) { /* DC refinement needs no table */
- tbl = compptr->dc_tbl_no;
- pdtbl = (d_derived_tbl **)(entropy->derived_tbls) + tbl;
- jpeg_make_d_derived_tbl(cinfo, TRUE, tbl, pdtbl);
- }
- } else {
- tbl = compptr->ac_tbl_no;
- pdtbl = (d_derived_tbl **)(entropy->derived_tbls) + tbl;
- jpeg_make_d_derived_tbl(cinfo, FALSE, tbl, pdtbl);
- /* remember the single active table */
- entropy->ac_derived_tbl = entropy->derived_tbls[tbl];
- }
- /* Initialize DC predictions to 0 */
- entropy->saved.last_dc_val[ci] = 0;
- }
-
- /* Initialize bitread state variables */
- entropy->bitstate.bits_left = 0;
- entropy->bitstate.get_buffer = 0; /* unnecessary, but keeps Purify quiet */
- entropy->pub.insufficient_data = FALSE;
-
- /* Initialize private state variables */
- entropy->saved.EOBRUN = 0;
-
- /* Initialize restart counter */
- entropy->restarts_to_go = cinfo->restart_interval;
-}
-
-
-/*
- * Figure F.12: extend sign bit.
- * On some machines, a shift and add will be faster than a table lookup.
- */
-
-#define AVOID_TABLES
-#ifdef AVOID_TABLES
-
-#define NEG_1 ((unsigned)-1)
-#define HUFF_EXTEND(x, s) \
- ((x) < (1 << ((s) - 1)) ? (x) + (((NEG_1) << (s)) + 1) : (x))
-
-#else
-
-#define HUFF_EXTEND(x, s) \
- ((x) < extend_test[s] ? (x) + extend_offset[s] : (x))
-
-static const int extend_test[16] = { /* entry n is 2**(n-1) */
- 0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080,
- 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000
-};
-
-static const int extend_offset[16] = { /* entry n is (-1 << n) + 1 */
- 0, ((-1) << 1) + 1, ((-1) << 2) + 1, ((-1) << 3) + 1, ((-1) << 4) + 1,
- ((-1) << 5) + 1, ((-1) << 6) + 1, ((-1) << 7) + 1, ((-1) << 8) + 1,
- ((-1) << 9) + 1, ((-1) << 10) + 1, ((-1) << 11) + 1, ((-1) << 12) + 1,
- ((-1) << 13) + 1, ((-1) << 14) + 1, ((-1) << 15) + 1
-};
-
-#endif /* AVOID_TABLES */
-
-
-/*
- * Check for a restart marker & resynchronize decoder.
- * Returns FALSE if must suspend.
- */
-
-LOCAL(boolean)
-process_restart(j_decompress_ptr cinfo)
-{
- phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
- int ci;
-
- /* Throw away any unused bits remaining in bit buffer; */
- /* include any full bytes in next_marker's count of discarded bytes */
- cinfo->marker->discarded_bytes += entropy->bitstate.bits_left / 8;
- entropy->bitstate.bits_left = 0;
-
- /* Advance past the RSTn marker */
- if (!(*cinfo->marker->read_restart_marker) (cinfo))
- return FALSE;
-
- /* Re-initialize DC predictions to 0 */
- for (ci = 0; ci < cinfo->comps_in_scan; ci++)
- entropy->saved.last_dc_val[ci] = 0;
- /* Re-init EOB run count, too */
- entropy->saved.EOBRUN = 0;
-
- /* Reset restart counter */
- entropy->restarts_to_go = cinfo->restart_interval;
-
- /* Reset out-of-data flag, unless read_restart_marker left us smack up
- * against a marker. In that case we will end up treating the next data
- * segment as empty, and we can avoid producing bogus output pixels by
- * leaving the flag set.
- */
- if (cinfo->unread_marker == 0)
- entropy->pub.insufficient_data = FALSE;
-
- return TRUE;
-}
-
-
-/*
- * Huffman MCU decoding.
- * Each of these routines decodes and returns one MCU's worth of
- * Huffman-compressed coefficients.
- * The coefficients are reordered from zigzag order into natural array order,
- * but are not dequantized.
- *
- * The i'th block of the MCU is stored into the block pointed to by
- * MCU_data[i]. WE ASSUME THIS AREA IS INITIALLY ZEROED BY THE CALLER.
- *
- * We return FALSE if data source requested suspension. In that case no
- * changes have been made to permanent state. (Exception: some output
- * coefficients may already have been assigned. This is harmless for
- * spectral selection, since we'll just re-assign them on the next call.
- * Successive approximation AC refinement has to be more careful, however.)
- */
-
-/*
- * MCU decoding for DC initial scan (either spectral selection,
- * or first pass of successive approximation).
- */
-
-METHODDEF(boolean)
-decode_mcu_DC_first(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
-{
- phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
- int Al = cinfo->Al;
- register int s, r;
- int blkn, ci;
- JBLOCKROW block;
- BITREAD_STATE_VARS;
- savable_state state;
- d_derived_tbl *tbl;
- jpeg_component_info *compptr;
-
- /* Process restart marker if needed; may have to suspend */
- if (cinfo->restart_interval) {
- if (entropy->restarts_to_go == 0)
- if (!process_restart(cinfo))
- return FALSE;
- }
-
- /* If we've run out of data, just leave the MCU set to zeroes.
- * This way, we return uniform gray for the remainder of the segment.
- */
- if (!entropy->pub.insufficient_data) {
-
- /* Load up working state */
- BITREAD_LOAD_STATE(cinfo, entropy->bitstate);
- state = entropy->saved;
-
- /* Outer loop handles each block in the MCU */
-
- for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
- block = MCU_data[blkn];
- ci = cinfo->MCU_membership[blkn];
- compptr = cinfo->cur_comp_info[ci];
- tbl = entropy->derived_tbls[compptr->dc_tbl_no];
-
- /* Decode a single block's worth of coefficients */
-
- /* Section F.2.2.1: decode the DC coefficient difference */
- HUFF_DECODE(s, br_state, tbl, return FALSE, label1);
- if (s) {
- CHECK_BIT_BUFFER(br_state, s, return FALSE);
- r = GET_BITS(s);
- s = HUFF_EXTEND(r, s);
- }
-
- /* Convert DC difference to actual value, update last_dc_val */
- if ((state.last_dc_val[ci] >= 0 &&
- s > INT_MAX - state.last_dc_val[ci]) ||
- (state.last_dc_val[ci] < 0 && s < INT_MIN - state.last_dc_val[ci]))
- ERREXIT(cinfo, JERR_BAD_DCT_COEF);
- s += state.last_dc_val[ci];
- state.last_dc_val[ci] = s;
- /* Scale and output the coefficient (assumes jpeg_natural_order[0]=0) */
- (*block)[0] = (JCOEF)LEFT_SHIFT(s, Al);
- }
-
- /* Completed MCU, so update state */
- BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
- entropy->saved = state;
- }
-
- /* Account for restart interval (no-op if not using restarts) */
- if (cinfo->restart_interval)
- entropy->restarts_to_go--;
-
- return TRUE;
-}
-
-
-/*
- * MCU decoding for AC initial scan (either spectral selection,
- * or first pass of successive approximation).
- */
-
-METHODDEF(boolean)
-decode_mcu_AC_first(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
-{
- phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
- int Se = cinfo->Se;
- int Al = cinfo->Al;
- register int s, k, r;
- unsigned int EOBRUN;
- JBLOCKROW block;
- BITREAD_STATE_VARS;
- d_derived_tbl *tbl;
-
- /* Process restart marker if needed; may have to suspend */
- if (cinfo->restart_interval) {
- if (entropy->restarts_to_go == 0)
- if (!process_restart(cinfo))
- return FALSE;
- }
-
- /* If we've run out of data, just leave the MCU set to zeroes.
- * This way, we return uniform gray for the remainder of the segment.
- */
- if (!entropy->pub.insufficient_data) {
-
- /* Load up working state.
- * We can avoid loading/saving bitread state if in an EOB run.
- */
- EOBRUN = entropy->saved.EOBRUN; /* only part of saved state we need */
-
- /* There is always only one block per MCU */
-
- if (EOBRUN > 0) /* if it's a band of zeroes... */
- EOBRUN--; /* ...process it now (we do nothing) */
- else {
- BITREAD_LOAD_STATE(cinfo, entropy->bitstate);
- block = MCU_data[0];
- tbl = entropy->ac_derived_tbl;
-
- for (k = cinfo->Ss; k <= Se; k++) {
- HUFF_DECODE(s, br_state, tbl, return FALSE, label2);
- r = s >> 4;
- s &= 15;
- if (s) {
- k += r;
- CHECK_BIT_BUFFER(br_state, s, return FALSE);
- r = GET_BITS(s);
- s = HUFF_EXTEND(r, s);
- /* Scale and output coefficient in natural (dezigzagged) order */
- (*block)[jpeg_natural_order[k]] = (JCOEF)LEFT_SHIFT(s, Al);
- } else {
- if (r == 15) { /* ZRL */
- k += 15; /* skip 15 zeroes in band */
- } else { /* EOBr, run length is 2^r + appended bits */
- EOBRUN = 1 << r;
- if (r) { /* EOBr, r > 0 */
- CHECK_BIT_BUFFER(br_state, r, return FALSE);
- r = GET_BITS(r);
- EOBRUN += r;
- }
- EOBRUN--; /* this band is processed at this moment */
- break; /* force end-of-band */
- }
- }
- }
-
- BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
- }
-
- /* Completed MCU, so update state */
- entropy->saved.EOBRUN = EOBRUN; /* only part of saved state we need */
- }
-
- /* Account for restart interval (no-op if not using restarts) */
- if (cinfo->restart_interval)
- entropy->restarts_to_go--;
-
- return TRUE;
-}
-
-
-/*
- * MCU decoding for DC successive approximation refinement scan.
- * Note: we assume such scans can be multi-component, although the spec
- * is not very clear on the point.
- */
-
-METHODDEF(boolean)
-decode_mcu_DC_refine(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
-{
- phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
- int p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */
- int blkn;
- JBLOCKROW block;
- BITREAD_STATE_VARS;
-
- /* Process restart marker if needed; may have to suspend */
- if (cinfo->restart_interval) {
- if (entropy->restarts_to_go == 0)
- if (!process_restart(cinfo))
- return FALSE;
- }
-
- /* Not worth the cycles to check insufficient_data here,
- * since we will not change the data anyway if we read zeroes.
- */
-
- /* Load up working state */
- BITREAD_LOAD_STATE(cinfo, entropy->bitstate);
-
- /* Outer loop handles each block in the MCU */
-
- for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
- block = MCU_data[blkn];
-
- /* Encoded data is simply the next bit of the two's-complement DC value */
- CHECK_BIT_BUFFER(br_state, 1, return FALSE);
- if (GET_BITS(1))
- (*block)[0] |= p1;
- /* Note: since we use |=, repeating the assignment later is safe */
- }
-
- /* Completed MCU, so update state */
- BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
-
- /* Account for restart interval (no-op if not using restarts) */
- if (cinfo->restart_interval)
- entropy->restarts_to_go--;
-
- return TRUE;
-}
-
-
-/*
- * MCU decoding for AC successive approximation refinement scan.
- */
-
-METHODDEF(boolean)
-decode_mcu_AC_refine(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
-{
- phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
- int Se = cinfo->Se;
- int p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */
- int m1 = (NEG_1) << cinfo->Al; /* -1 in the bit position being coded */
- register int s, k, r;
- unsigned int EOBRUN;
- JBLOCKROW block;
- JCOEFPTR thiscoef;
- BITREAD_STATE_VARS;
- d_derived_tbl *tbl;
- int num_newnz;
- int newnz_pos[DCTSIZE2];
-
- /* Process restart marker if needed; may have to suspend */
- if (cinfo->restart_interval) {
- if (entropy->restarts_to_go == 0)
- if (!process_restart(cinfo))
- return FALSE;
- }
-
- /* If we've run out of data, don't modify the MCU.
- */
- if (!entropy->pub.insufficient_data) {
-
- /* Load up working state */
- BITREAD_LOAD_STATE(cinfo, entropy->bitstate);
- EOBRUN = entropy->saved.EOBRUN; /* only part of saved state we need */
-
- /* There is always only one block per MCU */
- block = MCU_data[0];
- tbl = entropy->ac_derived_tbl;
-
- /* If we are forced to suspend, we must undo the assignments to any newly
- * nonzero coefficients in the block, because otherwise we'd get confused
- * next time about which coefficients were already nonzero.
- * But we need not undo addition of bits to already-nonzero coefficients;
- * instead, we can test the current bit to see if we already did it.
- */
- num_newnz = 0;
-
- /* initialize coefficient loop counter to start of band */
- k = cinfo->Ss;
-
- if (EOBRUN == 0) {
- for (; k <= Se; k++) {
- HUFF_DECODE(s, br_state, tbl, goto undoit, label3);
- r = s >> 4;
- s &= 15;
- if (s) {
- if (s != 1) /* size of new coef should always be 1 */
- WARNMS(cinfo, JWRN_HUFF_BAD_CODE);
- CHECK_BIT_BUFFER(br_state, 1, goto undoit);
- if (GET_BITS(1))
- s = p1; /* newly nonzero coef is positive */
- else
- s = m1; /* newly nonzero coef is negative */
- } else {
- if (r != 15) {
- EOBRUN = 1 << r; /* EOBr, run length is 2^r + appended bits */
- if (r) {
- CHECK_BIT_BUFFER(br_state, r, goto undoit);
- r = GET_BITS(r);
- EOBRUN += r;
- }
- break; /* rest of block is handled by EOB logic */
- }
- /* note s = 0 for processing ZRL */
- }
- /* Advance over already-nonzero coefs and r still-zero coefs,
- * appending correction bits to the nonzeroes. A correction bit is 1
- * if the absolute value of the coefficient must be increased.
- */
- do {
- thiscoef = *block + jpeg_natural_order[k];
- if (*thiscoef != 0) {
- CHECK_BIT_BUFFER(br_state, 1, goto undoit);
- if (GET_BITS(1)) {
- if ((*thiscoef & p1) == 0) { /* do nothing if already set it */
- if (*thiscoef >= 0)
- *thiscoef += (JCOEF)p1;
- else
- *thiscoef += (JCOEF)m1;
- }
- }
- } else {
- if (--r < 0)
- break; /* reached target zero coefficient */
- }
- k++;
- } while (k <= Se);
- if (s) {
- int pos = jpeg_natural_order[k];
- /* Output newly nonzero coefficient */
- (*block)[pos] = (JCOEF)s;
- /* Remember its position in case we have to suspend */
- newnz_pos[num_newnz++] = pos;
- }
- }
- }
-
- if (EOBRUN > 0) {
- /* Scan any remaining coefficient positions after the end-of-band
- * (the last newly nonzero coefficient, if any). Append a correction
- * bit to each already-nonzero coefficient. A correction bit is 1
- * if the absolute value of the coefficient must be increased.
- */
- for (; k <= Se; k++) {
- thiscoef = *block + jpeg_natural_order[k];
- if (*thiscoef != 0) {
- CHECK_BIT_BUFFER(br_state, 1, goto undoit);
- if (GET_BITS(1)) {
- if ((*thiscoef & p1) == 0) { /* do nothing if already changed it */
- if (*thiscoef >= 0)
- *thiscoef += (JCOEF)p1;
- else
- *thiscoef += (JCOEF)m1;
- }
- }
- }
- }
- /* Count one block completed in EOB run */
- EOBRUN--;
- }
-
- /* Completed MCU, so update state */
- BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
- entropy->saved.EOBRUN = EOBRUN; /* only part of saved state we need */
- }
-
- /* Account for restart interval (no-op if not using restarts) */
- if (cinfo->restart_interval)
- entropy->restarts_to_go--;
-
- return TRUE;
-
-undoit:
- /* Re-zero any output coefficients that we made newly nonzero */
- while (num_newnz > 0)
- (*block)[newnz_pos[--num_newnz]] = 0;
-
- return FALSE;
-}
-
-
-/*
- * Module initialization routine for progressive Huffman entropy decoding.
- */
-
-GLOBAL(void)
-jinit_phuff_decoder(j_decompress_ptr cinfo)
-{
- phuff_entropy_ptr entropy;
- int *coef_bit_ptr;
- int ci, i;
-
- entropy = (phuff_entropy_ptr)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- sizeof(phuff_entropy_decoder));
- cinfo->entropy = (struct jpeg_entropy_decoder *)entropy;
- entropy->pub.start_pass = start_pass_phuff_decoder;
-
- /* Mark derived tables unallocated */
- for (i = 0; i < NUM_HUFF_TBLS; i++) {
- entropy->derived_tbls[i] = NULL;
- }
-
- /* Create progression status table */
- cinfo->coef_bits = (int (*)[DCTSIZE2])
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- cinfo->num_components * 2 * DCTSIZE2 *
- sizeof(int));
- coef_bit_ptr = &cinfo->coef_bits[0][0];
- for (ci = 0; ci < cinfo->num_components; ci++)
- for (i = 0; i < DCTSIZE2; i++)
- *coef_bit_ptr++ = -1;
-}
-
-#endif /* D_PROGRESSIVE_SUPPORTED */
diff --git a/contrib/libs/libjpeg-turbo/jdpostct.c b/contrib/libs/libjpeg-turbo/jdpostct.c
deleted file mode 100644
index 6a2cf5c1b3..0000000000
--- a/contrib/libs/libjpeg-turbo/jdpostct.c
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- * jdpostct.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * It was modified by The libjpeg-turbo Project to include only code relevant
- * to libjpeg-turbo.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains the decompression postprocessing controller.
- * This controller manages the upsampling, color conversion, and color
- * quantization/reduction steps; specifically, it controls the buffering
- * between upsample/color conversion and color quantization/reduction.
- *
- * If no color quantization/reduction is required, then this module has no
- * work to do, and it just hands off to the upsample/color conversion code.
- * An integrated upsample/convert/quantize process would replace this module
- * entirely.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-
-
-/* Private buffer controller object */
-
-typedef struct {
- struct jpeg_d_post_controller pub; /* public fields */
-
- /* Color quantization source buffer: this holds output data from
- * the upsample/color conversion step to be passed to the quantizer.
- * For two-pass color quantization, we need a full-image buffer;
- * for one-pass operation, a strip buffer is sufficient.
- */
- jvirt_sarray_ptr whole_image; /* virtual array, or NULL if one-pass */
- JSAMPARRAY buffer; /* strip buffer, or current strip of virtual */
- JDIMENSION strip_height; /* buffer size in rows */
- /* for two-pass mode only: */
- JDIMENSION starting_row; /* row # of first row in current strip */
- JDIMENSION next_row; /* index of next row to fill/empty in strip */
-} my_post_controller;
-
-typedef my_post_controller *my_post_ptr;
-
-
-/* Forward declarations */
-METHODDEF(void) post_process_1pass(j_decompress_ptr cinfo,
- JSAMPIMAGE input_buf,
- JDIMENSION *in_row_group_ctr,
- JDIMENSION in_row_groups_avail,
- JSAMPARRAY output_buf,
- JDIMENSION *out_row_ctr,
- JDIMENSION out_rows_avail);
-#ifdef QUANT_2PASS_SUPPORTED
-METHODDEF(void) post_process_prepass(j_decompress_ptr cinfo,
- JSAMPIMAGE input_buf,
- JDIMENSION *in_row_group_ctr,
- JDIMENSION in_row_groups_avail,
- JSAMPARRAY output_buf,
- JDIMENSION *out_row_ctr,
- JDIMENSION out_rows_avail);
-METHODDEF(void) post_process_2pass(j_decompress_ptr cinfo,
- JSAMPIMAGE input_buf,
- JDIMENSION *in_row_group_ctr,
- JDIMENSION in_row_groups_avail,
- JSAMPARRAY output_buf,
- JDIMENSION *out_row_ctr,
- JDIMENSION out_rows_avail);
-#endif
-
-
-/*
- * Initialize for a processing pass.
- */
-
-METHODDEF(void)
-start_pass_dpost(j_decompress_ptr cinfo, J_BUF_MODE pass_mode)
-{
- my_post_ptr post = (my_post_ptr)cinfo->post;
-
- switch (pass_mode) {
- case JBUF_PASS_THRU:
- if (cinfo->quantize_colors) {
- /* Single-pass processing with color quantization. */
- post->pub.post_process_data = post_process_1pass;
- /* We could be doing buffered-image output before starting a 2-pass
- * color quantization; in that case, jinit_d_post_controller did not
- * allocate a strip buffer. Use the virtual-array buffer as workspace.
- */
- if (post->buffer == NULL) {
- post->buffer = (*cinfo->mem->access_virt_sarray)
- ((j_common_ptr)cinfo, post->whole_image,
- (JDIMENSION)0, post->strip_height, TRUE);
- }
- } else {
- /* For single-pass processing without color quantization,
- * I have no work to do; just call the upsampler directly.
- */
- post->pub.post_process_data = cinfo->upsample->upsample;
- }
- break;
-#ifdef QUANT_2PASS_SUPPORTED
- case JBUF_SAVE_AND_PASS:
- /* First pass of 2-pass quantization */
- if (post->whole_image == NULL)
- ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
- post->pub.post_process_data = post_process_prepass;
- break;
- case JBUF_CRANK_DEST:
- /* Second pass of 2-pass quantization */
- if (post->whole_image == NULL)
- ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
- post->pub.post_process_data = post_process_2pass;
- break;
-#endif /* QUANT_2PASS_SUPPORTED */
- default:
- ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
- break;
- }
- post->starting_row = post->next_row = 0;
-}
-
-
-/*
- * Process some data in the one-pass (strip buffer) case.
- * This is used for color precision reduction as well as one-pass quantization.
- */
-
-METHODDEF(void)
-post_process_1pass(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION *in_row_group_ctr,
- JDIMENSION in_row_groups_avail, JSAMPARRAY output_buf,
- JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
-{
- my_post_ptr post = (my_post_ptr)cinfo->post;
- JDIMENSION num_rows, max_rows;
-
- /* Fill the buffer, but not more than what we can dump out in one go. */
- /* Note we rely on the upsampler to detect bottom of image. */
- max_rows = out_rows_avail - *out_row_ctr;
- if (max_rows > post->strip_height)
- max_rows = post->strip_height;
- num_rows = 0;
- (*cinfo->upsample->upsample) (cinfo, input_buf, in_row_group_ctr,
- in_row_groups_avail, post->buffer, &num_rows,
- max_rows);
- /* Quantize and emit data. */
- (*cinfo->cquantize->color_quantize) (cinfo, post->buffer,
- output_buf + *out_row_ctr,
- (int)num_rows);
- *out_row_ctr += num_rows;
-}
-
-
-#ifdef QUANT_2PASS_SUPPORTED
-
-/*
- * Process some data in the first pass of 2-pass quantization.
- */
-
-METHODDEF(void)
-post_process_prepass(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION *in_row_group_ctr,
- JDIMENSION in_row_groups_avail, JSAMPARRAY output_buf,
- JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
-{
- my_post_ptr post = (my_post_ptr)cinfo->post;
- JDIMENSION old_next_row, num_rows;
-
- /* Reposition virtual buffer if at start of strip. */
- if (post->next_row == 0) {
- post->buffer = (*cinfo->mem->access_virt_sarray)
- ((j_common_ptr)cinfo, post->whole_image,
- post->starting_row, post->strip_height, TRUE);
- }
-
- /* Upsample some data (up to a strip height's worth). */
- old_next_row = post->next_row;
- (*cinfo->upsample->upsample) (cinfo, input_buf, in_row_group_ctr,
- in_row_groups_avail, post->buffer,
- &post->next_row, post->strip_height);
-
- /* Allow quantizer to scan new data. No data is emitted, */
- /* but we advance out_row_ctr so outer loop can tell when we're done. */
- if (post->next_row > old_next_row) {
- num_rows = post->next_row - old_next_row;
- (*cinfo->cquantize->color_quantize) (cinfo, post->buffer + old_next_row,
- (JSAMPARRAY)NULL, (int)num_rows);
- *out_row_ctr += num_rows;
- }
-
- /* Advance if we filled the strip. */
- if (post->next_row >= post->strip_height) {
- post->starting_row += post->strip_height;
- post->next_row = 0;
- }
-}
-
-
-/*
- * Process some data in the second pass of 2-pass quantization.
- */
-
-METHODDEF(void)
-post_process_2pass(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION *in_row_group_ctr,
- JDIMENSION in_row_groups_avail, JSAMPARRAY output_buf,
- JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
-{
- my_post_ptr post = (my_post_ptr)cinfo->post;
- JDIMENSION num_rows, max_rows;
-
- /* Reposition virtual buffer if at start of strip. */
- if (post->next_row == 0) {
- post->buffer = (*cinfo->mem->access_virt_sarray)
- ((j_common_ptr)cinfo, post->whole_image,
- post->starting_row, post->strip_height, FALSE);
- }
-
- /* Determine number of rows to emit. */
- num_rows = post->strip_height - post->next_row; /* available in strip */
- max_rows = out_rows_avail - *out_row_ctr; /* available in output area */
- if (num_rows > max_rows)
- num_rows = max_rows;
- /* We have to check bottom of image here, can't depend on upsampler. */
- max_rows = cinfo->output_height - post->starting_row;
- if (num_rows > max_rows)
- num_rows = max_rows;
-
- /* Quantize and emit data. */
- (*cinfo->cquantize->color_quantize) (cinfo, post->buffer + post->next_row,
- output_buf + *out_row_ctr,
- (int)num_rows);
- *out_row_ctr += num_rows;
-
- /* Advance if we filled the strip. */
- post->next_row += num_rows;
- if (post->next_row >= post->strip_height) {
- post->starting_row += post->strip_height;
- post->next_row = 0;
- }
-}
-
-#endif /* QUANT_2PASS_SUPPORTED */
-
-
-/*
- * Initialize postprocessing controller.
- */
-
-GLOBAL(void)
-jinit_d_post_controller(j_decompress_ptr cinfo, boolean need_full_buffer)
-{
- my_post_ptr post;
-
- post = (my_post_ptr)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- sizeof(my_post_controller));
- cinfo->post = (struct jpeg_d_post_controller *)post;
- post->pub.start_pass = start_pass_dpost;
- post->whole_image = NULL; /* flag for no virtual arrays */
- post->buffer = NULL; /* flag for no strip buffer */
-
- /* Create the quantization buffer, if needed */
- if (cinfo->quantize_colors) {
- /* The buffer strip height is max_v_samp_factor, which is typically
- * an efficient number of rows for upsampling to return.
- * (In the presence of output rescaling, we might want to be smarter?)
- */
- post->strip_height = (JDIMENSION)cinfo->max_v_samp_factor;
- if (need_full_buffer) {
- /* Two-pass color quantization: need full-image storage. */
- /* We round up the number of rows to a multiple of the strip height. */
-#ifdef QUANT_2PASS_SUPPORTED
- post->whole_image = (*cinfo->mem->request_virt_sarray)
- ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE,
- cinfo->output_width * cinfo->out_color_components,
- (JDIMENSION)jround_up((long)cinfo->output_height,
- (long)post->strip_height),
- post->strip_height);
-#else
- ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
-#endif /* QUANT_2PASS_SUPPORTED */
- } else {
- /* One-pass color quantization: just make a strip buffer. */
- post->buffer = (*cinfo->mem->alloc_sarray)
- ((j_common_ptr)cinfo, JPOOL_IMAGE,
- cinfo->output_width * cinfo->out_color_components,
- post->strip_height);
- }
- }
-}
diff --git a/contrib/libs/libjpeg-turbo/jdsample.c b/contrib/libs/libjpeg-turbo/jdsample.c
deleted file mode 100644
index eaad72a030..0000000000
--- a/contrib/libs/libjpeg-turbo/jdsample.c
+++ /dev/null
@@ -1,524 +0,0 @@
-/*
- * jdsample.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1996, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- * Copyright (C) 2010, 2015-2016, D. R. Commander.
- * Copyright (C) 2014, MIPS Technologies, Inc., California.
- * Copyright (C) 2015, Google, Inc.
- * Copyright (C) 2019-2020, Arm Limited.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains upsampling routines.
- *
- * Upsampling input data is counted in "row groups". A row group
- * is defined to be (v_samp_factor * DCT_scaled_size / min_DCT_scaled_size)
- * sample rows of each component. Upsampling will normally produce
- * max_v_samp_factor pixel rows from each row group (but this could vary
- * if the upsampler is applying a scale factor of its own).
- *
- * An excellent reference for image resampling is
- * Digital Image Warping, George Wolberg, 1990.
- * Pub. by IEEE Computer Society Press, Los Alamitos, CA. ISBN 0-8186-8944-7.
- */
-
-#include "jinclude.h"
-#include "jdsample.h"
-#include "jsimd.h"
-#include "jpegcomp.h"
-
-
-
-/*
- * Initialize for an upsampling pass.
- */
-
-METHODDEF(void)
-start_pass_upsample(j_decompress_ptr cinfo)
-{
- my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
-
- /* Mark the conversion buffer empty */
- upsample->next_row_out = cinfo->max_v_samp_factor;
- /* Initialize total-height counter for detecting bottom of image */
- upsample->rows_to_go = cinfo->output_height;
-}
-
-
-/*
- * Control routine to do upsampling (and color conversion).
- *
- * In this version we upsample each component independently.
- * We upsample one row group into the conversion buffer, then apply
- * color conversion a row at a time.
- */
-
-METHODDEF(void)
-sep_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION *in_row_group_ctr, JDIMENSION in_row_groups_avail,
- JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
- JDIMENSION out_rows_avail)
-{
- my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
- int ci;
- jpeg_component_info *compptr;
- JDIMENSION num_rows;
-
- /* Fill the conversion buffer, if it's empty */
- if (upsample->next_row_out >= cinfo->max_v_samp_factor) {
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
- ci++, compptr++) {
- /* Invoke per-component upsample method. Notice we pass a POINTER
- * to color_buf[ci], so that fullsize_upsample can change it.
- */
- (*upsample->methods[ci]) (cinfo, compptr,
- input_buf[ci] + (*in_row_group_ctr * upsample->rowgroup_height[ci]),
- upsample->color_buf + ci);
- }
- upsample->next_row_out = 0;
- }
-
- /* Color-convert and emit rows */
-
- /* How many we have in the buffer: */
- num_rows = (JDIMENSION)(cinfo->max_v_samp_factor - upsample->next_row_out);
- /* Not more than the distance to the end of the image. Need this test
- * in case the image height is not a multiple of max_v_samp_factor:
- */
- if (num_rows > upsample->rows_to_go)
- num_rows = upsample->rows_to_go;
- /* And not more than what the client can accept: */
- out_rows_avail -= *out_row_ctr;
- if (num_rows > out_rows_avail)
- num_rows = out_rows_avail;
-
- (*cinfo->cconvert->color_convert) (cinfo, upsample->color_buf,
- (JDIMENSION)upsample->next_row_out,
- output_buf + *out_row_ctr, (int)num_rows);
-
- /* Adjust counts */
- *out_row_ctr += num_rows;
- upsample->rows_to_go -= num_rows;
- upsample->next_row_out += num_rows;
- /* When the buffer is emptied, declare this input row group consumed */
- if (upsample->next_row_out >= cinfo->max_v_samp_factor)
- (*in_row_group_ctr)++;
-}
-
-
-/*
- * These are the routines invoked by sep_upsample to upsample pixel values
- * of a single component. One row group is processed per call.
- */
-
-
-/*
- * For full-size components, we just make color_buf[ci] point at the
- * input buffer, and thus avoid copying any data. Note that this is
- * safe only because sep_upsample doesn't declare the input row group
- * "consumed" until we are done color converting and emitting it.
- */
-
-METHODDEF(void)
-fullsize_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
-{
- *output_data_ptr = input_data;
-}
-
-
-/*
- * This is a no-op version used for "uninteresting" components.
- * These components will not be referenced by color conversion.
- */
-
-METHODDEF(void)
-noop_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
-{
- *output_data_ptr = NULL; /* safety check */
-}
-
-
-/*
- * This version handles any integral sampling ratios.
- * This is not used for typical JPEG files, so it need not be fast.
- * Nor, for that matter, is it particularly accurate: the algorithm is
- * simple replication of the input pixel onto the corresponding output
- * pixels. The hi-falutin sampling literature refers to this as a
- * "box filter". A box filter tends to introduce visible artifacts,
- * so if you are actually going to use 3:1 or 4:1 sampling ratios
- * you would be well advised to improve this code.
- */
-
-METHODDEF(void)
-int_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
-{
- my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
- JSAMPARRAY output_data = *output_data_ptr;
- register JSAMPROW inptr, outptr;
- register JSAMPLE invalue;
- register int h;
- JSAMPROW outend;
- int h_expand, v_expand;
- int inrow, outrow;
-
- h_expand = upsample->h_expand[compptr->component_index];
- v_expand = upsample->v_expand[compptr->component_index];
-
- inrow = outrow = 0;
- while (outrow < cinfo->max_v_samp_factor) {
- /* Generate one output row with proper horizontal expansion */
- inptr = input_data[inrow];
- outptr = output_data[outrow];
- outend = outptr + cinfo->output_width;
- while (outptr < outend) {
- invalue = *inptr++;
- for (h = h_expand; h > 0; h--) {
- *outptr++ = invalue;
- }
- }
- /* Generate any additional output rows by duplicating the first one */
- if (v_expand > 1) {
- jcopy_sample_rows(output_data, outrow, output_data, outrow + 1,
- v_expand - 1, cinfo->output_width);
- }
- inrow++;
- outrow += v_expand;
- }
-}
-
-
-/*
- * Fast processing for the common case of 2:1 horizontal and 1:1 vertical.
- * It's still a box filter.
- */
-
-METHODDEF(void)
-h2v1_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
-{
- JSAMPARRAY output_data = *output_data_ptr;
- register JSAMPROW inptr, outptr;
- register JSAMPLE invalue;
- JSAMPROW outend;
- int inrow;
-
- for (inrow = 0; inrow < cinfo->max_v_samp_factor; inrow++) {
- inptr = input_data[inrow];
- outptr = output_data[inrow];
- outend = outptr + cinfo->output_width;
- while (outptr < outend) {
- invalue = *inptr++;
- *outptr++ = invalue;
- *outptr++ = invalue;
- }
- }
-}
-
-
-/*
- * Fast processing for the common case of 2:1 horizontal and 2:1 vertical.
- * It's still a box filter.
- */
-
-METHODDEF(void)
-h2v2_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
-{
- JSAMPARRAY output_data = *output_data_ptr;
- register JSAMPROW inptr, outptr;
- register JSAMPLE invalue;
- JSAMPROW outend;
- int inrow, outrow;
-
- inrow = outrow = 0;
- while (outrow < cinfo->max_v_samp_factor) {
- inptr = input_data[inrow];
- outptr = output_data[outrow];
- outend = outptr + cinfo->output_width;
- while (outptr < outend) {
- invalue = *inptr++;
- *outptr++ = invalue;
- *outptr++ = invalue;
- }
- jcopy_sample_rows(output_data, outrow, output_data, outrow + 1, 1,
- cinfo->output_width);
- inrow++;
- outrow += 2;
- }
-}
-
-
-/*
- * Fancy processing for the common case of 2:1 horizontal and 1:1 vertical.
- *
- * The upsampling algorithm is linear interpolation between pixel centers,
- * also known as a "triangle filter". This is a good compromise between
- * speed and visual quality. The centers of the output pixels are 1/4 and 3/4
- * of the way between input pixel centers.
- *
- * A note about the "bias" calculations: when rounding fractional values to
- * integer, we do not want to always round 0.5 up to the next integer.
- * If we did that, we'd introduce a noticeable bias towards larger values.
- * Instead, this code is arranged so that 0.5 will be rounded up or down at
- * alternate pixel locations (a simple ordered dither pattern).
- */
-
-METHODDEF(void)
-h2v1_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
-{
- JSAMPARRAY output_data = *output_data_ptr;
- register JSAMPROW inptr, outptr;
- register int invalue;
- register JDIMENSION colctr;
- int inrow;
-
- for (inrow = 0; inrow < cinfo->max_v_samp_factor; inrow++) {
- inptr = input_data[inrow];
- outptr = output_data[inrow];
- /* Special case for first column */
- invalue = *inptr++;
- *outptr++ = (JSAMPLE)invalue;
- *outptr++ = (JSAMPLE)((invalue * 3 + inptr[0] + 2) >> 2);
-
- for (colctr = compptr->downsampled_width - 2; colctr > 0; colctr--) {
- /* General case: 3/4 * nearer pixel + 1/4 * further pixel */
- invalue = (*inptr++) * 3;
- *outptr++ = (JSAMPLE)((invalue + inptr[-2] + 1) >> 2);
- *outptr++ = (JSAMPLE)((invalue + inptr[0] + 2) >> 2);
- }
-
- /* Special case for last column */
- invalue = *inptr;
- *outptr++ = (JSAMPLE)((invalue * 3 + inptr[-1] + 1) >> 2);
- *outptr++ = (JSAMPLE)invalue;
- }
-}
-
-
-/*
- * Fancy processing for 1:1 horizontal and 2:1 vertical (4:4:0 subsampling).
- *
- * This is a less common case, but it can be encountered when losslessly
- * rotating/transposing a JPEG file that uses 4:2:2 chroma subsampling.
- */
-
-METHODDEF(void)
-h1v2_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
-{
- JSAMPARRAY output_data = *output_data_ptr;
- JSAMPROW inptr0, inptr1, outptr;
-#if BITS_IN_JSAMPLE == 8
- int thiscolsum, bias;
-#else
- JLONG thiscolsum, bias;
-#endif
- JDIMENSION colctr;
- int inrow, outrow, v;
-
- inrow = outrow = 0;
- while (outrow < cinfo->max_v_samp_factor) {
- for (v = 0; v < 2; v++) {
- /* inptr0 points to nearest input row, inptr1 points to next nearest */
- inptr0 = input_data[inrow];
- if (v == 0) { /* next nearest is row above */
- inptr1 = input_data[inrow - 1];
- bias = 1;
- } else { /* next nearest is row below */
- inptr1 = input_data[inrow + 1];
- bias = 2;
- }
- outptr = output_data[outrow++];
-
- for (colctr = 0; colctr < compptr->downsampled_width; colctr++) {
- thiscolsum = (*inptr0++) * 3 + (*inptr1++);
- *outptr++ = (JSAMPLE)((thiscolsum + bias) >> 2);
- }
- }
- inrow++;
- }
-}
-
-
-/*
- * Fancy processing for the common case of 2:1 horizontal and 2:1 vertical.
- * Again a triangle filter; see comments for h2v1 case, above.
- *
- * It is OK for us to reference the adjacent input rows because we demanded
- * context from the main buffer controller (see initialization code).
- */
-
-METHODDEF(void)
-h2v2_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
-{
- JSAMPARRAY output_data = *output_data_ptr;
- register JSAMPROW inptr0, inptr1, outptr;
-#if BITS_IN_JSAMPLE == 8
- register int thiscolsum, lastcolsum, nextcolsum;
-#else
- register JLONG thiscolsum, lastcolsum, nextcolsum;
-#endif
- register JDIMENSION colctr;
- int inrow, outrow, v;
-
- inrow = outrow = 0;
- while (outrow < cinfo->max_v_samp_factor) {
- for (v = 0; v < 2; v++) {
- /* inptr0 points to nearest input row, inptr1 points to next nearest */
- inptr0 = input_data[inrow];
- if (v == 0) /* next nearest is row above */
- inptr1 = input_data[inrow - 1];
- else /* next nearest is row below */
- inptr1 = input_data[inrow + 1];
- outptr = output_data[outrow++];
-
- /* Special case for first column */
- thiscolsum = (*inptr0++) * 3 + (*inptr1++);
- nextcolsum = (*inptr0++) * 3 + (*inptr1++);
- *outptr++ = (JSAMPLE)((thiscolsum * 4 + 8) >> 4);
- *outptr++ = (JSAMPLE)((thiscolsum * 3 + nextcolsum + 7) >> 4);
- lastcolsum = thiscolsum; thiscolsum = nextcolsum;
-
- for (colctr = compptr->downsampled_width - 2; colctr > 0; colctr--) {
- /* General case: 3/4 * nearer pixel + 1/4 * further pixel in each */
- /* dimension, thus 9/16, 3/16, 3/16, 1/16 overall */
- nextcolsum = (*inptr0++) * 3 + (*inptr1++);
- *outptr++ = (JSAMPLE)((thiscolsum * 3 + lastcolsum + 8) >> 4);
- *outptr++ = (JSAMPLE)((thiscolsum * 3 + nextcolsum + 7) >> 4);
- lastcolsum = thiscolsum; thiscolsum = nextcolsum;
- }
-
- /* Special case for last column */
- *outptr++ = (JSAMPLE)((thiscolsum * 3 + lastcolsum + 8) >> 4);
- *outptr++ = (JSAMPLE)((thiscolsum * 4 + 7) >> 4);
- }
- inrow++;
- }
-}
-
-
-/*
- * Module initialization routine for upsampling.
- */
-
-GLOBAL(void)
-jinit_upsampler(j_decompress_ptr cinfo)
-{
- my_upsample_ptr upsample;
- int ci;
- jpeg_component_info *compptr;
- boolean need_buffer, do_fancy;
- int h_in_group, v_in_group, h_out_group, v_out_group;
-
- if (!cinfo->master->jinit_upsampler_no_alloc) {
- upsample = (my_upsample_ptr)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- sizeof(my_upsampler));
- cinfo->upsample = (struct jpeg_upsampler *)upsample;
- upsample->pub.start_pass = start_pass_upsample;
- upsample->pub.upsample = sep_upsample;
- upsample->pub.need_context_rows = FALSE; /* until we find out differently */
- } else
- upsample = (my_upsample_ptr)cinfo->upsample;
-
- if (cinfo->CCIR601_sampling) /* this isn't supported */
- ERREXIT(cinfo, JERR_CCIR601_NOTIMPL);
-
- /* jdmainct.c doesn't support context rows when min_DCT_scaled_size = 1,
- * so don't ask for it.
- */
- do_fancy = cinfo->do_fancy_upsampling && cinfo->_min_DCT_scaled_size > 1;
-
- /* Verify we can handle the sampling factors, select per-component methods,
- * and create storage as needed.
- */
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
- ci++, compptr++) {
- /* Compute size of an "input group" after IDCT scaling. This many samples
- * are to be converted to max_h_samp_factor * max_v_samp_factor pixels.
- */
- h_in_group = (compptr->h_samp_factor * compptr->_DCT_scaled_size) /
- cinfo->_min_DCT_scaled_size;
- v_in_group = (compptr->v_samp_factor * compptr->_DCT_scaled_size) /
- cinfo->_min_DCT_scaled_size;
- h_out_group = cinfo->max_h_samp_factor;
- v_out_group = cinfo->max_v_samp_factor;
- upsample->rowgroup_height[ci] = v_in_group; /* save for use later */
- need_buffer = TRUE;
- if (!compptr->component_needed) {
- /* Don't bother to upsample an uninteresting component. */
- upsample->methods[ci] = noop_upsample;
- need_buffer = FALSE;
- } else if (h_in_group == h_out_group && v_in_group == v_out_group) {
- /* Fullsize components can be processed without any work. */
- upsample->methods[ci] = fullsize_upsample;
- need_buffer = FALSE;
- } else if (h_in_group * 2 == h_out_group && v_in_group == v_out_group) {
- /* Special cases for 2h1v upsampling */
- if (do_fancy && compptr->downsampled_width > 2) {
- if (jsimd_can_h2v1_fancy_upsample())
- upsample->methods[ci] = jsimd_h2v1_fancy_upsample;
- else
- upsample->methods[ci] = h2v1_fancy_upsample;
- } else {
- if (jsimd_can_h2v1_upsample())
- upsample->methods[ci] = jsimd_h2v1_upsample;
- else
- upsample->methods[ci] = h2v1_upsample;
- }
- } else if (h_in_group == h_out_group &&
- v_in_group * 2 == v_out_group && do_fancy) {
- /* Non-fancy upsampling is handled by the generic method */
-#if defined(__arm__) || defined(__aarch64__) || \
- defined(_M_ARM) || defined(_M_ARM64)
- if (jsimd_can_h1v2_fancy_upsample())
- upsample->methods[ci] = jsimd_h1v2_fancy_upsample;
- else
-#endif
- upsample->methods[ci] = h1v2_fancy_upsample;
- upsample->pub.need_context_rows = TRUE;
- } else if (h_in_group * 2 == h_out_group &&
- v_in_group * 2 == v_out_group) {
- /* Special cases for 2h2v upsampling */
- if (do_fancy && compptr->downsampled_width > 2) {
- if (jsimd_can_h2v2_fancy_upsample())
- upsample->methods[ci] = jsimd_h2v2_fancy_upsample;
- else
- upsample->methods[ci] = h2v2_fancy_upsample;
- upsample->pub.need_context_rows = TRUE;
- } else {
- if (jsimd_can_h2v2_upsample())
- upsample->methods[ci] = jsimd_h2v2_upsample;
- else
- upsample->methods[ci] = h2v2_upsample;
- }
- } else if ((h_out_group % h_in_group) == 0 &&
- (v_out_group % v_in_group) == 0) {
- /* Generic integral-factors upsampling method */
-#if defined(__mips__)
- if (jsimd_can_int_upsample())
- upsample->methods[ci] = jsimd_int_upsample;
- else
-#endif
- upsample->methods[ci] = int_upsample;
- upsample->h_expand[ci] = (UINT8)(h_out_group / h_in_group);
- upsample->v_expand[ci] = (UINT8)(v_out_group / v_in_group);
- } else
- ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL);
- if (need_buffer && !cinfo->master->jinit_upsampler_no_alloc) {
- upsample->color_buf[ci] = (*cinfo->mem->alloc_sarray)
- ((j_common_ptr)cinfo, JPOOL_IMAGE,
- (JDIMENSION)jround_up((long)cinfo->output_width,
- (long)cinfo->max_h_samp_factor),
- (JDIMENSION)cinfo->max_v_samp_factor);
- }
- }
-}
diff --git a/contrib/libs/libjpeg-turbo/jdsample.h b/contrib/libs/libjpeg-turbo/jdsample.h
deleted file mode 100644
index a6bf08a032..0000000000
--- a/contrib/libs/libjpeg-turbo/jdsample.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * jdsample.h
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1996, Thomas G. Lane.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- */
-
-#define JPEG_INTERNALS
-#include "jpeglib.h"
-
-
-/* Pointer to routine to upsample a single component */
-typedef void (*upsample1_ptr) (j_decompress_ptr cinfo,
- jpeg_component_info *compptr,
- JSAMPARRAY input_data,
- JSAMPARRAY *output_data_ptr);
-
-/* Private subobject */
-
-typedef struct {
- struct jpeg_upsampler pub; /* public fields */
-
- /* Color conversion buffer. When using separate upsampling and color
- * conversion steps, this buffer holds one upsampled row group until it
- * has been color converted and output.
- * Note: we do not allocate any storage for component(s) which are full-size,
- * ie do not need rescaling. The corresponding entry of color_buf[] is
- * simply set to point to the input data array, thereby avoiding copying.
- */
- JSAMPARRAY color_buf[MAX_COMPONENTS];
-
- /* Per-component upsampling method pointers */
- upsample1_ptr methods[MAX_COMPONENTS];
-
- int next_row_out; /* counts rows emitted from color_buf */
- JDIMENSION rows_to_go; /* counts rows remaining in image */
-
- /* Height of an input row group for each component. */
- int rowgroup_height[MAX_COMPONENTS];
-
- /* These arrays save pixel expansion factors so that int_expand need not
- * recompute them each time. They are unused for other upsampling methods.
- */
- UINT8 h_expand[MAX_COMPONENTS];
- UINT8 v_expand[MAX_COMPONENTS];
-} my_upsampler;
-
-typedef my_upsampler *my_upsample_ptr;
diff --git a/contrib/libs/libjpeg-turbo/jdtrans.c b/contrib/libs/libjpeg-turbo/jdtrans.c
deleted file mode 100644
index d7ec4b83b3..0000000000
--- a/contrib/libs/libjpeg-turbo/jdtrans.c
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * jdtrans.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1995-1997, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2020, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains library routines for transcoding decompression,
- * that is, reading raw DCT coefficient arrays from an input JPEG file.
- * The routines in jdapimin.c will also be needed by a transcoder.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-#include "jpegcomp.h"
-
-
-/* Forward declarations */
-LOCAL(void) transdecode_master_selection(j_decompress_ptr cinfo);
-
-
-/*
- * Read the coefficient arrays from a JPEG file.
- * jpeg_read_header must be completed before calling this.
- *
- * The entire image is read into a set of virtual coefficient-block arrays,
- * one per component. The return value is a pointer to the array of
- * virtual-array descriptors. These can be manipulated directly via the
- * JPEG memory manager, or handed off to jpeg_write_coefficients().
- * To release the memory occupied by the virtual arrays, call
- * jpeg_finish_decompress() when done with the data.
- *
- * An alternative usage is to simply obtain access to the coefficient arrays
- * during a buffered-image-mode decompression operation. This is allowed
- * after any jpeg_finish_output() call. The arrays can be accessed until
- * jpeg_finish_decompress() is called. (Note that any call to the library
- * may reposition the arrays, so don't rely on access_virt_barray() results
- * to stay valid across library calls.)
- *
- * Returns NULL if suspended. This case need be checked only if
- * a suspending data source is used.
- */
-
-GLOBAL(jvirt_barray_ptr *)
-jpeg_read_coefficients(j_decompress_ptr cinfo)
-{
- if (cinfo->global_state == DSTATE_READY) {
- /* First call: initialize active modules */
- transdecode_master_selection(cinfo);
- cinfo->global_state = DSTATE_RDCOEFS;
- }
- if (cinfo->global_state == DSTATE_RDCOEFS) {
- /* Absorb whole file into the coef buffer */
- for (;;) {
- int retcode;
- /* Call progress monitor hook if present */
- if (cinfo->progress != NULL)
- (*cinfo->progress->progress_monitor) ((j_common_ptr)cinfo);
- /* Absorb some more input */
- retcode = (*cinfo->inputctl->consume_input) (cinfo);
- if (retcode == JPEG_SUSPENDED)
- return NULL;
- if (retcode == JPEG_REACHED_EOI)
- break;
- /* Advance progress counter if appropriate */
- if (cinfo->progress != NULL &&
- (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) {
- if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) {
- /* startup underestimated number of scans; ratchet up one scan */
- cinfo->progress->pass_limit += (long)cinfo->total_iMCU_rows;
- }
- }
- }
- /* Set state so that jpeg_finish_decompress does the right thing */
- cinfo->global_state = DSTATE_STOPPING;
- }
- /* At this point we should be in state DSTATE_STOPPING if being used
- * standalone, or in state DSTATE_BUFIMAGE if being invoked to get access
- * to the coefficients during a full buffered-image-mode decompression.
- */
- if ((cinfo->global_state == DSTATE_STOPPING ||
- cinfo->global_state == DSTATE_BUFIMAGE) && cinfo->buffered_image) {
- return cinfo->coef->coef_arrays;
- }
- /* Oops, improper usage */
- ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
- return NULL; /* keep compiler happy */
-}
-
-
-/*
- * Master selection of decompression modules for transcoding.
- * This substitutes for jdmaster.c's initialization of the full decompressor.
- */
-
-LOCAL(void)
-transdecode_master_selection(j_decompress_ptr cinfo)
-{
- /* This is effectively a buffered-image operation. */
- cinfo->buffered_image = TRUE;
-
-#if JPEG_LIB_VERSION >= 80
- /* Compute output image dimensions and related values. */
- jpeg_core_output_dimensions(cinfo);
-#endif
-
- /* Entropy decoding: either Huffman or arithmetic coding. */
- if (cinfo->arith_code) {
-#ifdef D_ARITH_CODING_SUPPORTED
- jinit_arith_decoder(cinfo);
-#else
- ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
-#endif
- } else {
- if (cinfo->progressive_mode) {
-#ifdef D_PROGRESSIVE_SUPPORTED
- jinit_phuff_decoder(cinfo);
-#else
- ERREXIT(cinfo, JERR_NOT_COMPILED);
-#endif
- } else
- jinit_huff_decoder(cinfo);
- }
-
- /* Always get a full-image coefficient buffer. */
- jinit_d_coef_controller(cinfo, TRUE);
-
- /* We can now tell the memory manager to allocate virtual arrays. */
- (*cinfo->mem->realize_virt_arrays) ((j_common_ptr)cinfo);
-
- /* Initialize input side of decompressor to consume first scan. */
- (*cinfo->inputctl->start_input_pass) (cinfo);
-
- /* Initialize progress monitoring. */
- if (cinfo->progress != NULL) {
- int nscans;
- /* Estimate number of scans to set pass_limit. */
- if (cinfo->progressive_mode) {
- /* Arbitrarily estimate 2 interleaved DC scans + 3 AC scans/component. */
- nscans = 2 + 3 * cinfo->num_components;
- } else if (cinfo->inputctl->has_multiple_scans) {
- /* For a nonprogressive multiscan file, estimate 1 scan per component. */
- nscans = cinfo->num_components;
- } else {
- nscans = 1;
- }
- cinfo->progress->pass_counter = 0L;
- cinfo->progress->pass_limit = (long)cinfo->total_iMCU_rows * nscans;
- cinfo->progress->completed_passes = 0;
- cinfo->progress->total_passes = 1;
- }
-}
diff --git a/contrib/libs/libjpeg-turbo/jerror.c b/contrib/libs/libjpeg-turbo/jerror.c
deleted file mode 100644
index d0ab5b88b0..0000000000
--- a/contrib/libs/libjpeg-turbo/jerror.c
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * jerror.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1998, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains simple error-reporting and trace-message routines.
- * These are suitable for Unix-like systems and others where writing to
- * stderr is the right thing to do. Many applications will want to replace
- * some or all of these routines.
- *
- * If you define USE_WINDOWS_MESSAGEBOX in jconfig.h or in the makefile,
- * you get a Windows-specific hack to display error messages in a dialog box.
- * It ain't much, but it beats dropping error messages into the bit bucket,
- * which is what happens to output to stderr under most Windows C compilers.
- *
- * These routines are used by both the compression and decompression code.
- */
-
-/* this is not a core library module, so it doesn't define JPEG_INTERNALS */
-#include "jinclude.h"
-#include "jpeglib.h"
-#include "jversion.h"
-#include "jerror.h"
-
-#ifdef USE_WINDOWS_MESSAGEBOX
-#include <windows.h>
-#endif
-
-#ifndef EXIT_FAILURE /* define exit() codes if not provided */
-#define EXIT_FAILURE 1
-#endif
-
-
-/*
- * Create the message string table.
- * We do this from the master message list in jerror.h by re-reading
- * jerror.h with a suitable definition for macro JMESSAGE.
- * The message table is made an external symbol just in case any applications
- * want to refer to it directly.
- */
-
-#define JMESSAGE(code, string) string,
-
-const char * const jpeg_std_message_table[] = {
-#include "jerror.h"
- NULL
-};
-
-
-/*
- * Error exit handler: must not return to caller.
- *
- * Applications may override this if they want to get control back after
- * an error. Typically one would longjmp somewhere instead of exiting.
- * The setjmp buffer can be made a private field within an expanded error
- * handler object. Note that the info needed to generate an error message
- * is stored in the error object, so you can generate the message now or
- * later, at your convenience.
- * You should make sure that the JPEG object is cleaned up (with jpeg_abort
- * or jpeg_destroy) at some point.
- */
-
-METHODDEF(void)
-error_exit(j_common_ptr cinfo)
-{
- /* Always display the message */
- (*cinfo->err->output_message) (cinfo);
-
- /* Let the memory manager delete any temp files before we die */
- jpeg_destroy(cinfo);
-
- exit(EXIT_FAILURE);
-}
-
-
-/*
- * Actual output of an error or trace message.
- * Applications may override this method to send JPEG messages somewhere
- * other than stderr.
- *
- * On Windows, printing to stderr is generally completely useless,
- * so we provide optional code to produce an error-dialog popup.
- * Most Windows applications will still prefer to override this routine,
- * but if they don't, it'll do something at least marginally useful.
- *
- * NOTE: to use the library in an environment that doesn't support the
- * C stdio library, you may have to delete the call to fprintf() entirely,
- * not just not use this routine.
- */
-
-METHODDEF(void)
-output_message(j_common_ptr cinfo)
-{
- char buffer[JMSG_LENGTH_MAX];
-
- /* Create the message */
- (*cinfo->err->format_message) (cinfo, buffer);
-
-#ifdef USE_WINDOWS_MESSAGEBOX
- /* Display it in a message dialog box */
- MessageBox(GetActiveWindow(), buffer, "JPEG Library Error",
- MB_OK | MB_ICONERROR);
-#else
- /* Send it to stderr, adding a newline */
- fprintf(stderr, "%s\n", buffer);
-#endif
-}
-
-
-/*
- * Decide whether to emit a trace or warning message.
- * msg_level is one of:
- * -1: recoverable corrupt-data warning, may want to abort.
- * 0: important advisory messages (always display to user).
- * 1: first level of tracing detail.
- * 2,3,...: successively more detailed tracing messages.
- * An application might override this method if it wanted to abort on warnings
- * or change the policy about which messages to display.
- */
-
-METHODDEF(void)
-emit_message(j_common_ptr cinfo, int msg_level)
-{
- struct jpeg_error_mgr *err = cinfo->err;
-
- if (msg_level < 0) {
- /* It's a warning message. Since corrupt files may generate many warnings,
- * the policy implemented here is to show only the first warning,
- * unless trace_level >= 3.
- */
- if (err->num_warnings == 0 || err->trace_level >= 3)
- (*err->output_message) (cinfo);
- /* Always count warnings in num_warnings. */
- err->num_warnings++;
- } else {
- /* It's a trace message. Show it if trace_level >= msg_level. */
- if (err->trace_level >= msg_level)
- (*err->output_message) (cinfo);
- }
-}
-
-
-/*
- * Format a message string for the most recent JPEG error or message.
- * The message is stored into buffer, which should be at least JMSG_LENGTH_MAX
- * characters. Note that no '\n' character is added to the string.
- * Few applications should need to override this method.
- */
-
-METHODDEF(void)
-format_message(j_common_ptr cinfo, char *buffer)
-{
- struct jpeg_error_mgr *err = cinfo->err;
- int msg_code = err->msg_code;
- const char *msgtext = NULL;
- const char *msgptr;
- char ch;
- boolean isstring;
-
- /* Look up message string in proper table */
- if (msg_code > 0 && msg_code <= err->last_jpeg_message) {
- msgtext = err->jpeg_message_table[msg_code];
- } else if (err->addon_message_table != NULL &&
- msg_code >= err->first_addon_message &&
- msg_code <= err->last_addon_message) {
- msgtext = err->addon_message_table[msg_code - err->first_addon_message];
- }
-
- /* Defend against bogus message number */
- if (msgtext == NULL) {
- err->msg_parm.i[0] = msg_code;
- msgtext = err->jpeg_message_table[0];
- }
-
- /* Check for string parameter, as indicated by %s in the message text */
- isstring = FALSE;
- msgptr = msgtext;
- while ((ch = *msgptr++) != '\0') {
- if (ch == '%') {
- if (*msgptr == 's') isstring = TRUE;
- break;
- }
- }
-
- /* Format the message into the passed buffer */
- if (isstring)
- SNPRINTF(buffer, JMSG_LENGTH_MAX, msgtext, err->msg_parm.s);
- else
- SNPRINTF(buffer, JMSG_LENGTH_MAX, msgtext,
- err->msg_parm.i[0], err->msg_parm.i[1],
- err->msg_parm.i[2], err->msg_parm.i[3],
- err->msg_parm.i[4], err->msg_parm.i[5],
- err->msg_parm.i[6], err->msg_parm.i[7]);
-}
-
-
-/*
- * Reset error state variables at start of a new image.
- * This is called during compression startup to reset trace/error
- * processing to default state, without losing any application-specific
- * method pointers. An application might possibly want to override
- * this method if it has additional error processing state.
- */
-
-METHODDEF(void)
-reset_error_mgr(j_common_ptr cinfo)
-{
- cinfo->err->num_warnings = 0;
- /* trace_level is not reset since it is an application-supplied parameter */
- cinfo->err->msg_code = 0; /* may be useful as a flag for "no error" */
-}
-
-
-/*
- * Fill in the standard error-handling methods in a jpeg_error_mgr object.
- * Typical call is:
- * struct jpeg_compress_struct cinfo;
- * struct jpeg_error_mgr err;
- *
- * cinfo.err = jpeg_std_error(&err);
- * after which the application may override some of the methods.
- */
-
-GLOBAL(struct jpeg_error_mgr *)
-jpeg_std_error(struct jpeg_error_mgr *err)
-{
- err->error_exit = error_exit;
- err->emit_message = emit_message;
- err->output_message = output_message;
- err->format_message = format_message;
- err->reset_error_mgr = reset_error_mgr;
-
- err->trace_level = 0; /* default = no tracing */
- err->num_warnings = 0; /* no warnings emitted yet */
- err->msg_code = 0; /* may be useful as a flag for "no error" */
-
- /* Initialize message table pointers */
- err->jpeg_message_table = jpeg_std_message_table;
- err->last_jpeg_message = (int)JMSG_LASTMSGCODE - 1;
-
- err->addon_message_table = NULL;
- err->first_addon_message = 0; /* for safety */
- err->last_addon_message = 0;
-
- return err;
-}
diff --git a/contrib/libs/libjpeg-turbo/jerror.h b/contrib/libs/libjpeg-turbo/jerror.h
deleted file mode 100644
index eb44a1140a..0000000000
--- a/contrib/libs/libjpeg-turbo/jerror.h
+++ /dev/null
@@ -1,331 +0,0 @@
-/*
- * jerror.h
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1994-1997, Thomas G. Lane.
- * Modified 1997-2009 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2014, 2017, 2021-2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file defines the error and message codes for the JPEG library.
- * Edit this file to add new codes, or to translate the message strings to
- * some other language.
- * A set of error-reporting macros are defined too. Some applications using
- * the JPEG library may wish to include this file to get the error codes
- * and/or the macros.
- */
-
-/*
- * To define the enum list of message codes, include this file without
- * defining macro JMESSAGE. To create a message string table, include it
- * again with a suitable JMESSAGE definition (see jerror.c for an example).
- */
-#ifndef JMESSAGE
-#ifndef JERROR_H
-/* First time through, define the enum list */
-#define JMAKE_ENUM_LIST
-#else
-/* Repeated inclusions of this file are no-ops unless JMESSAGE is defined */
-#define JMESSAGE(code, string)
-#endif /* JERROR_H */
-#endif /* JMESSAGE */
-
-#ifdef JMAKE_ENUM_LIST
-
-typedef enum {
-
-#define JMESSAGE(code, string) code,
-
-#endif /* JMAKE_ENUM_LIST */
-
-JMESSAGE(JMSG_NOMESSAGE, "Bogus message code %d") /* Must be first entry! */
-
-/* For maintenance convenience, list is alphabetical by message code name */
-#if JPEG_LIB_VERSION < 70
-JMESSAGE(JERR_ARITH_NOTIMPL, "Sorry, arithmetic coding is not implemented")
-#endif
-JMESSAGE(JERR_BAD_ALIGN_TYPE, "ALIGN_TYPE is wrong, please fix")
-JMESSAGE(JERR_BAD_ALLOC_CHUNK, "MAX_ALLOC_CHUNK is wrong, please fix")
-JMESSAGE(JERR_BAD_BUFFER_MODE, "Bogus buffer control mode")
-JMESSAGE(JERR_BAD_COMPONENT_ID, "Invalid component ID %d in SOS")
-#if JPEG_LIB_VERSION >= 70
-JMESSAGE(JERR_BAD_CROP_SPEC, "Invalid crop request")
-#endif
-JMESSAGE(JERR_BAD_DCT_COEF, "DCT coefficient out of range")
-JMESSAGE(JERR_BAD_DCTSIZE, "IDCT output block size %d not supported")
-#if JPEG_LIB_VERSION >= 70
-JMESSAGE(JERR_BAD_DROP_SAMPLING,
- "Component index %d: mismatching sampling ratio %d:%d, %d:%d, %c")
-#endif
-JMESSAGE(JERR_BAD_HUFF_TABLE, "Bogus Huffman table definition")
-JMESSAGE(JERR_BAD_IN_COLORSPACE, "Bogus input colorspace")
-JMESSAGE(JERR_BAD_J_COLORSPACE, "Bogus JPEG colorspace")
-JMESSAGE(JERR_BAD_LENGTH, "Bogus marker length")
-JMESSAGE(JERR_BAD_LIB_VERSION,
- "Wrong JPEG library version: library is %d, caller expects %d")
-JMESSAGE(JERR_BAD_MCU_SIZE, "Sampling factors too large for interleaved scan")
-JMESSAGE(JERR_BAD_POOL_ID, "Invalid memory pool code %d")
-JMESSAGE(JERR_BAD_PRECISION, "Unsupported JPEG data precision %d")
-JMESSAGE(JERR_BAD_PROGRESSION,
- "Invalid progressive parameters Ss=%d Se=%d Ah=%d Al=%d")
-JMESSAGE(JERR_BAD_PROG_SCRIPT,
- "Invalid progressive parameters at scan script entry %d")
-JMESSAGE(JERR_BAD_SAMPLING, "Bogus sampling factors")
-JMESSAGE(JERR_BAD_SCAN_SCRIPT, "Invalid scan script at entry %d")
-JMESSAGE(JERR_BAD_STATE, "Improper call to JPEG library in state %d")
-JMESSAGE(JERR_BAD_STRUCT_SIZE,
- "JPEG parameter struct mismatch: library thinks size is %u, caller expects %u")
-JMESSAGE(JERR_BAD_VIRTUAL_ACCESS, "Bogus virtual array access")
-JMESSAGE(JERR_BUFFER_SIZE, "Buffer passed to JPEG library is too small")
-JMESSAGE(JERR_CANT_SUSPEND, "Suspension not allowed here")
-JMESSAGE(JERR_CCIR601_NOTIMPL, "CCIR601 sampling not implemented yet")
-JMESSAGE(JERR_COMPONENT_COUNT, "Too many color components: %d, max %d")
-JMESSAGE(JERR_CONVERSION_NOTIMPL, "Unsupported color conversion request")
-JMESSAGE(JERR_DAC_INDEX, "Bogus DAC index %d")
-JMESSAGE(JERR_DAC_VALUE, "Bogus DAC value 0x%x")
-JMESSAGE(JERR_DHT_INDEX, "Bogus DHT index %d")
-JMESSAGE(JERR_DQT_INDEX, "Bogus DQT index %d")
-JMESSAGE(JERR_EMPTY_IMAGE, "Empty JPEG image (DNL not supported)")
-JMESSAGE(JERR_EMS_READ, "Read from EMS failed")
-JMESSAGE(JERR_EMS_WRITE, "Write to EMS failed")
-JMESSAGE(JERR_EOI_EXPECTED, "Didn't expect more than one scan")
-JMESSAGE(JERR_FILE_READ, "Input file read error")
-JMESSAGE(JERR_FILE_WRITE, "Output file write error --- out of disk space?")
-JMESSAGE(JERR_FRACT_SAMPLE_NOTIMPL, "Fractional sampling not implemented yet")
-JMESSAGE(JERR_HUFF_CLEN_OVERFLOW, "Huffman code size table overflow")
-JMESSAGE(JERR_HUFF_MISSING_CODE, "Missing Huffman code table entry")
-JMESSAGE(JERR_IMAGE_TOO_BIG, "Maximum supported image dimension is %u pixels")
-JMESSAGE(JERR_INPUT_EMPTY, "Empty input file")
-JMESSAGE(JERR_INPUT_EOF, "Premature end of input file")
-JMESSAGE(JERR_MISMATCHED_QUANT_TABLE,
- "Cannot transcode due to multiple use of quantization table %d")
-JMESSAGE(JERR_MISSING_DATA, "Scan script does not transmit all data")
-JMESSAGE(JERR_MODE_CHANGE, "Invalid color quantization mode change")
-JMESSAGE(JERR_NOTIMPL, "Requested features are incompatible")
-JMESSAGE(JERR_NOT_COMPILED, "Requested feature was omitted at compile time")
-#if JPEG_LIB_VERSION >= 70
-JMESSAGE(JERR_NO_ARITH_TABLE, "Arithmetic table 0x%02x was not defined")
-#endif
-JMESSAGE(JERR_NO_BACKING_STORE, "Backing store not supported")
-JMESSAGE(JERR_NO_HUFF_TABLE, "Huffman table 0x%02x was not defined")
-JMESSAGE(JERR_NO_IMAGE, "JPEG datastream contains no image")
-JMESSAGE(JERR_NO_QUANT_TABLE, "Quantization table 0x%02x was not defined")
-JMESSAGE(JERR_NO_SOI, "Not a JPEG file: starts with 0x%02x 0x%02x")
-JMESSAGE(JERR_OUT_OF_MEMORY, "Insufficient memory (case %d)")
-JMESSAGE(JERR_QUANT_COMPONENTS,
- "Cannot quantize more than %d color components")
-JMESSAGE(JERR_QUANT_FEW_COLORS, "Cannot quantize to fewer than %d colors")
-JMESSAGE(JERR_QUANT_MANY_COLORS, "Cannot quantize to more than %d colors")
-JMESSAGE(JERR_SOF_DUPLICATE, "Invalid JPEG file structure: two SOF markers")
-JMESSAGE(JERR_SOF_NO_SOS, "Invalid JPEG file structure: missing SOS marker")
-JMESSAGE(JERR_SOF_UNSUPPORTED, "Unsupported JPEG process: SOF type 0x%02x")
-JMESSAGE(JERR_SOI_DUPLICATE, "Invalid JPEG file structure: two SOI markers")
-JMESSAGE(JERR_SOS_NO_SOF, "Invalid JPEG file structure: SOS before SOF")
-JMESSAGE(JERR_TFILE_CREATE, "Failed to create temporary file %s")
-JMESSAGE(JERR_TFILE_READ, "Read failed on temporary file")
-JMESSAGE(JERR_TFILE_SEEK, "Seek failed on temporary file")
-JMESSAGE(JERR_TFILE_WRITE,
- "Write failed on temporary file --- out of disk space?")
-JMESSAGE(JERR_TOO_LITTLE_DATA, "Application transferred too few scanlines")
-JMESSAGE(JERR_UNKNOWN_MARKER, "Unsupported marker type 0x%02x")
-JMESSAGE(JERR_VIRTUAL_BUG, "Virtual array controller messed up")
-JMESSAGE(JERR_WIDTH_OVERFLOW, "Image too wide for this implementation")
-JMESSAGE(JERR_XMS_READ, "Read from XMS failed")
-JMESSAGE(JERR_XMS_WRITE, "Write to XMS failed")
-JMESSAGE(JMSG_COPYRIGHT, JCOPYRIGHT_SHORT)
-JMESSAGE(JMSG_VERSION, JVERSION)
-JMESSAGE(JTRC_16BIT_TABLES,
- "Caution: quantization tables are too coarse for baseline JPEG")
-JMESSAGE(JTRC_ADOBE,
- "Adobe APP14 marker: version %d, flags 0x%04x 0x%04x, transform %d")
-JMESSAGE(JTRC_APP0, "Unknown APP0 marker (not JFIF), length %u")
-JMESSAGE(JTRC_APP14, "Unknown APP14 marker (not Adobe), length %u")
-JMESSAGE(JTRC_DAC, "Define Arithmetic Table 0x%02x: 0x%02x")
-JMESSAGE(JTRC_DHT, "Define Huffman Table 0x%02x")
-JMESSAGE(JTRC_DQT, "Define Quantization Table %d precision %d")
-JMESSAGE(JTRC_DRI, "Define Restart Interval %u")
-JMESSAGE(JTRC_EMS_CLOSE, "Freed EMS handle %u")
-JMESSAGE(JTRC_EMS_OPEN, "Obtained EMS handle %u")
-JMESSAGE(JTRC_EOI, "End Of Image")
-JMESSAGE(JTRC_HUFFBITS, " %3d %3d %3d %3d %3d %3d %3d %3d")
-JMESSAGE(JTRC_JFIF, "JFIF APP0 marker: version %d.%02d, density %dx%d %d")
-JMESSAGE(JTRC_JFIF_BADTHUMBNAILSIZE,
- "Warning: thumbnail image size does not match data length %u")
-JMESSAGE(JTRC_JFIF_EXTENSION, "JFIF extension marker: type 0x%02x, length %u")
-JMESSAGE(JTRC_JFIF_THUMBNAIL, " with %d x %d thumbnail image")
-JMESSAGE(JTRC_MISC_MARKER, "Miscellaneous marker 0x%02x, length %u")
-JMESSAGE(JTRC_PARMLESS_MARKER, "Unexpected marker 0x%02x")
-JMESSAGE(JTRC_QUANTVALS, " %4u %4u %4u %4u %4u %4u %4u %4u")
-JMESSAGE(JTRC_QUANT_3_NCOLORS, "Quantizing to %d = %d*%d*%d colors")
-JMESSAGE(JTRC_QUANT_NCOLORS, "Quantizing to %d colors")
-JMESSAGE(JTRC_QUANT_SELECTED, "Selected %d colors for quantization")
-JMESSAGE(JTRC_RECOVERY_ACTION, "At marker 0x%02x, recovery action %d")
-JMESSAGE(JTRC_RST, "RST%d")
-JMESSAGE(JTRC_SMOOTH_NOTIMPL,
- "Smoothing not supported with nonstandard sampling ratios")
-JMESSAGE(JTRC_SOF, "Start Of Frame 0x%02x: width=%u, height=%u, components=%d")
-JMESSAGE(JTRC_SOF_COMPONENT, " Component %d: %dhx%dv q=%d")
-JMESSAGE(JTRC_SOI, "Start of Image")
-JMESSAGE(JTRC_SOS, "Start Of Scan: %d components")
-JMESSAGE(JTRC_SOS_COMPONENT, " Component %d: dc=%d ac=%d")
-JMESSAGE(JTRC_SOS_PARAMS, " Ss=%d, Se=%d, Ah=%d, Al=%d")
-JMESSAGE(JTRC_TFILE_CLOSE, "Closed temporary file %s")
-JMESSAGE(JTRC_TFILE_OPEN, "Opened temporary file %s")
-JMESSAGE(JTRC_THUMB_JPEG,
- "JFIF extension marker: JPEG-compressed thumbnail image, length %u")
-JMESSAGE(JTRC_THUMB_PALETTE,
- "JFIF extension marker: palette thumbnail image, length %u")
-JMESSAGE(JTRC_THUMB_RGB,
- "JFIF extension marker: RGB thumbnail image, length %u")
-JMESSAGE(JTRC_UNKNOWN_IDS,
- "Unrecognized component IDs %d %d %d, assuming YCbCr")
-JMESSAGE(JTRC_XMS_CLOSE, "Freed XMS handle %u")
-JMESSAGE(JTRC_XMS_OPEN, "Obtained XMS handle %u")
-JMESSAGE(JWRN_ADOBE_XFORM, "Unknown Adobe color transform code %d")
-#if JPEG_LIB_VERSION >= 70
-JMESSAGE(JWRN_ARITH_BAD_CODE, "Corrupt JPEG data: bad arithmetic code")
-#endif
-JMESSAGE(JWRN_BOGUS_PROGRESSION,
- "Inconsistent progression sequence for component %d coefficient %d")
-JMESSAGE(JWRN_EXTRANEOUS_DATA,
- "Corrupt JPEG data: %u extraneous bytes before marker 0x%02x")
-JMESSAGE(JWRN_HIT_MARKER, "Corrupt JPEG data: premature end of data segment")
-JMESSAGE(JWRN_HUFF_BAD_CODE, "Corrupt JPEG data: bad Huffman code")
-JMESSAGE(JWRN_JFIF_MAJOR, "Warning: unknown JFIF revision number %d.%02d")
-JMESSAGE(JWRN_JPEG_EOF, "Premature end of JPEG file")
-JMESSAGE(JWRN_MUST_RESYNC,
- "Corrupt JPEG data: found marker 0x%02x instead of RST%d")
-JMESSAGE(JWRN_NOT_SEQUENTIAL, "Invalid SOS parameters for sequential JPEG")
-JMESSAGE(JWRN_TOO_MUCH_DATA, "Application transferred too many scanlines")
-#if JPEG_LIB_VERSION < 70
-JMESSAGE(JERR_BAD_CROP_SPEC, "Invalid crop request")
-#if defined(C_ARITH_CODING_SUPPORTED) || defined(D_ARITH_CODING_SUPPORTED)
-JMESSAGE(JERR_NO_ARITH_TABLE, "Arithmetic table 0x%02x was not defined")
-JMESSAGE(JWRN_ARITH_BAD_CODE, "Corrupt JPEG data: bad arithmetic code")
-#endif
-#endif
-JMESSAGE(JWRN_BOGUS_ICC, "Corrupt JPEG data: bad ICC marker")
-#if JPEG_LIB_VERSION < 70
-JMESSAGE(JERR_BAD_DROP_SAMPLING,
- "Component index %d: mismatching sampling ratio %d:%d, %d:%d, %c")
-#endif
-
-#ifdef JMAKE_ENUM_LIST
-
- JMSG_LASTMSGCODE
-} J_MESSAGE_CODE;
-
-#undef JMAKE_ENUM_LIST
-#endif /* JMAKE_ENUM_LIST */
-
-/* Zap JMESSAGE macro so that future re-inclusions do nothing by default */
-#undef JMESSAGE
-
-
-#ifndef JERROR_H
-#define JERROR_H
-
-/* Macros to simplify using the error and trace message stuff */
-/* The first parameter is either type of cinfo pointer */
-
-/* Fatal errors (print message and exit) */
-#define ERREXIT(cinfo, code) \
- ((cinfo)->err->msg_code = (code), \
- (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
-#define ERREXIT1(cinfo, code, p1) \
- ((cinfo)->err->msg_code = (code), \
- (cinfo)->err->msg_parm.i[0] = (p1), \
- (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
-#define ERREXIT2(cinfo, code, p1, p2) \
- ((cinfo)->err->msg_code = (code), \
- (cinfo)->err->msg_parm.i[0] = (p1), \
- (cinfo)->err->msg_parm.i[1] = (p2), \
- (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
-#define ERREXIT3(cinfo, code, p1, p2, p3) \
- ((cinfo)->err->msg_code = (code), \
- (cinfo)->err->msg_parm.i[0] = (p1), \
- (cinfo)->err->msg_parm.i[1] = (p2), \
- (cinfo)->err->msg_parm.i[2] = (p3), \
- (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
-#define ERREXIT4(cinfo, code, p1, p2, p3, p4) \
- ((cinfo)->err->msg_code = (code), \
- (cinfo)->err->msg_parm.i[0] = (p1), \
- (cinfo)->err->msg_parm.i[1] = (p2), \
- (cinfo)->err->msg_parm.i[2] = (p3), \
- (cinfo)->err->msg_parm.i[3] = (p4), \
- (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
-#define ERREXIT6(cinfo, code, p1, p2, p3, p4, p5, p6) \
- ((cinfo)->err->msg_code = (code), \
- (cinfo)->err->msg_parm.i[0] = (p1), \
- (cinfo)->err->msg_parm.i[1] = (p2), \
- (cinfo)->err->msg_parm.i[2] = (p3), \
- (cinfo)->err->msg_parm.i[3] = (p4), \
- (cinfo)->err->msg_parm.i[4] = (p5), \
- (cinfo)->err->msg_parm.i[5] = (p6), \
- (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
-#define ERREXITS(cinfo, code, str) \
- ((cinfo)->err->msg_code = (code), \
- strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \
- (cinfo)->err->msg_parm.s[JMSG_STR_PARM_MAX - 1] = '\0', \
- (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
-
-#define MAKESTMT(stuff) do { stuff } while (0)
-
-/* Nonfatal errors (we can keep going, but the data is probably corrupt) */
-#define WARNMS(cinfo, code) \
- ((cinfo)->err->msg_code = (code), \
- (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), -1))
-#define WARNMS1(cinfo, code, p1) \
- ((cinfo)->err->msg_code = (code), \
- (cinfo)->err->msg_parm.i[0] = (p1), \
- (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), -1))
-#define WARNMS2(cinfo, code, p1, p2) \
- ((cinfo)->err->msg_code = (code), \
- (cinfo)->err->msg_parm.i[0] = (p1), \
- (cinfo)->err->msg_parm.i[1] = (p2), \
- (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), -1))
-
-/* Informational/debugging messages */
-#define TRACEMS(cinfo, lvl, code) \
- ((cinfo)->err->msg_code = (code), \
- (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
-#define TRACEMS1(cinfo, lvl, code, p1) \
- ((cinfo)->err->msg_code = (code), \
- (cinfo)->err->msg_parm.i[0] = (p1), \
- (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
-#define TRACEMS2(cinfo, lvl, code, p1, p2) \
- ((cinfo)->err->msg_code = (code), \
- (cinfo)->err->msg_parm.i[0] = (p1), \
- (cinfo)->err->msg_parm.i[1] = (p2), \
- (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
-#define TRACEMS3(cinfo, lvl, code, p1, p2, p3) \
- MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
- _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); \
- (cinfo)->err->msg_code = (code); \
- (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
-#define TRACEMS4(cinfo, lvl, code, p1, p2, p3, p4) \
- MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
- _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \
- (cinfo)->err->msg_code = (code); \
- (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
-#define TRACEMS5(cinfo, lvl, code, p1, p2, p3, p4, p5) \
- MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
- _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \
- _mp[4] = (p5); \
- (cinfo)->err->msg_code = (code); \
- (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
-#define TRACEMS8(cinfo, lvl, code, p1, p2, p3, p4, p5, p6, p7, p8) \
- MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
- _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \
- _mp[4] = (p5); _mp[5] = (p6); _mp[6] = (p7); _mp[7] = (p8); \
- (cinfo)->err->msg_code = (code); \
- (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
-#define TRACEMSS(cinfo, lvl, code, str) \
- ((cinfo)->err->msg_code = (code), \
- strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \
- (cinfo)->err->msg_parm.s[JMSG_STR_PARM_MAX - 1] = '\0', \
- (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
-
-#endif /* JERROR_H */
diff --git a/contrib/libs/libjpeg-turbo/jfdctflt.c b/contrib/libs/libjpeg-turbo/jfdctflt.c
deleted file mode 100644
index ab6f6d0825..0000000000
--- a/contrib/libs/libjpeg-turbo/jfdctflt.c
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * jfdctflt.c
- *
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * This file is part of the Independent JPEG Group's software.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains a floating-point implementation of the
- * forward DCT (Discrete Cosine Transform).
- *
- * This implementation should be more accurate than either of the integer
- * DCT implementations. However, it may not give the same results on all
- * machines because of differences in roundoff behavior. Speed will depend
- * on the hardware's floating point capacity.
- *
- * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT
- * on each column. Direct algorithms are also available, but they are
- * much more complex and seem not to be any faster when reduced to code.
- *
- * This implementation is based on Arai, Agui, and Nakajima's algorithm for
- * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in
- * Japanese, but the algorithm is described in the Pennebaker & Mitchell
- * JPEG textbook (see REFERENCES section in file README.ijg). The following
- * code is based directly on figure 4-8 in P&M.
- * While an 8-point DCT cannot be done in less than 11 multiplies, it is
- * possible to arrange the computation so that many of the multiplies are
- * simple scalings of the final outputs. These multiplies can then be
- * folded into the multiplications or divisions by the JPEG quantization
- * table entries. The AA&N method leaves only 5 multiplies and 29 adds
- * to be done in the DCT itself.
- * The primary disadvantage of this method is that with a fixed-point
- * implementation, accuracy is lost due to imprecise representation of the
- * scaled quantization values. However, that problem does not arise if
- * we use floating point arithmetic.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-#include "jdct.h" /* Private declarations for DCT subsystem */
-
-#ifdef DCT_FLOAT_SUPPORTED
-
-
-/*
- * This module is specialized to the case DCTSIZE = 8.
- */
-
-#if DCTSIZE != 8
- Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */
-#endif
-
-
-/*
- * Perform the forward DCT on one block of samples.
- */
-
-GLOBAL(void)
-jpeg_fdct_float(FAST_FLOAT *data)
-{
- FAST_FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
- FAST_FLOAT tmp10, tmp11, tmp12, tmp13;
- FAST_FLOAT z1, z2, z3, z4, z5, z11, z13;
- FAST_FLOAT *dataptr;
- int ctr;
-
- /* Pass 1: process rows. */
-
- dataptr = data;
- for (ctr = DCTSIZE - 1; ctr >= 0; ctr--) {
- tmp0 = dataptr[0] + dataptr[7];
- tmp7 = dataptr[0] - dataptr[7];
- tmp1 = dataptr[1] + dataptr[6];
- tmp6 = dataptr[1] - dataptr[6];
- tmp2 = dataptr[2] + dataptr[5];
- tmp5 = dataptr[2] - dataptr[5];
- tmp3 = dataptr[3] + dataptr[4];
- tmp4 = dataptr[3] - dataptr[4];
-
- /* Even part */
-
- tmp10 = tmp0 + tmp3; /* phase 2 */
- tmp13 = tmp0 - tmp3;
- tmp11 = tmp1 + tmp2;
- tmp12 = tmp1 - tmp2;
-
- dataptr[0] = tmp10 + tmp11; /* phase 3 */
- dataptr[4] = tmp10 - tmp11;
-
- z1 = (tmp12 + tmp13) * ((FAST_FLOAT)0.707106781); /* c4 */
- dataptr[2] = tmp13 + z1; /* phase 5 */
- dataptr[6] = tmp13 - z1;
-
- /* Odd part */
-
- tmp10 = tmp4 + tmp5; /* phase 2 */
- tmp11 = tmp5 + tmp6;
- tmp12 = tmp6 + tmp7;
-
- /* The rotator is modified from fig 4-8 to avoid extra negations. */
- z5 = (tmp10 - tmp12) * ((FAST_FLOAT)0.382683433); /* c6 */
- z2 = ((FAST_FLOAT)0.541196100) * tmp10 + z5; /* c2-c6 */
- z4 = ((FAST_FLOAT)1.306562965) * tmp12 + z5; /* c2+c6 */
- z3 = tmp11 * ((FAST_FLOAT)0.707106781); /* c4 */
-
- z11 = tmp7 + z3; /* phase 5 */
- z13 = tmp7 - z3;
-
- dataptr[5] = z13 + z2; /* phase 6 */
- dataptr[3] = z13 - z2;
- dataptr[1] = z11 + z4;
- dataptr[7] = z11 - z4;
-
- dataptr += DCTSIZE; /* advance pointer to next row */
- }
-
- /* Pass 2: process columns. */
-
- dataptr = data;
- for (ctr = DCTSIZE - 1; ctr >= 0; ctr--) {
- tmp0 = dataptr[DCTSIZE * 0] + dataptr[DCTSIZE * 7];
- tmp7 = dataptr[DCTSIZE * 0] - dataptr[DCTSIZE * 7];
- tmp1 = dataptr[DCTSIZE * 1] + dataptr[DCTSIZE * 6];
- tmp6 = dataptr[DCTSIZE * 1] - dataptr[DCTSIZE * 6];
- tmp2 = dataptr[DCTSIZE * 2] + dataptr[DCTSIZE * 5];
- tmp5 = dataptr[DCTSIZE * 2] - dataptr[DCTSIZE * 5];
- tmp3 = dataptr[DCTSIZE * 3] + dataptr[DCTSIZE * 4];
- tmp4 = dataptr[DCTSIZE * 3] - dataptr[DCTSIZE * 4];
-
- /* Even part */
-
- tmp10 = tmp0 + tmp3; /* phase 2 */
- tmp13 = tmp0 - tmp3;
- tmp11 = tmp1 + tmp2;
- tmp12 = tmp1 - tmp2;
-
- dataptr[DCTSIZE * 0] = tmp10 + tmp11; /* phase 3 */
- dataptr[DCTSIZE * 4] = tmp10 - tmp11;
-
- z1 = (tmp12 + tmp13) * ((FAST_FLOAT)0.707106781); /* c4 */
- dataptr[DCTSIZE * 2] = tmp13 + z1; /* phase 5 */
- dataptr[DCTSIZE * 6] = tmp13 - z1;
-
- /* Odd part */
-
- tmp10 = tmp4 + tmp5; /* phase 2 */
- tmp11 = tmp5 + tmp6;
- tmp12 = tmp6 + tmp7;
-
- /* The rotator is modified from fig 4-8 to avoid extra negations. */
- z5 = (tmp10 - tmp12) * ((FAST_FLOAT)0.382683433); /* c6 */
- z2 = ((FAST_FLOAT)0.541196100) * tmp10 + z5; /* c2-c6 */
- z4 = ((FAST_FLOAT)1.306562965) * tmp12 + z5; /* c2+c6 */
- z3 = tmp11 * ((FAST_FLOAT)0.707106781); /* c4 */
-
- z11 = tmp7 + z3; /* phase 5 */
- z13 = tmp7 - z3;
-
- dataptr[DCTSIZE * 5] = z13 + z2; /* phase 6 */
- dataptr[DCTSIZE * 3] = z13 - z2;
- dataptr[DCTSIZE * 1] = z11 + z4;
- dataptr[DCTSIZE * 7] = z11 - z4;
-
- dataptr++; /* advance pointer to next column */
- }
-}
-
-#endif /* DCT_FLOAT_SUPPORTED */
diff --git a/contrib/libs/libjpeg-turbo/jfdctfst.c b/contrib/libs/libjpeg-turbo/jfdctfst.c
deleted file mode 100644
index 4c9ce0de8f..0000000000
--- a/contrib/libs/libjpeg-turbo/jfdctfst.c
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * jfdctfst.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2015, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains a fast, not so accurate integer implementation of the
- * forward DCT (Discrete Cosine Transform).
- *
- * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT
- * on each column. Direct algorithms are also available, but they are
- * much more complex and seem not to be any faster when reduced to code.
- *
- * This implementation is based on Arai, Agui, and Nakajima's algorithm for
- * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in
- * Japanese, but the algorithm is described in the Pennebaker & Mitchell
- * JPEG textbook (see REFERENCES section in file README.ijg). The following
- * code is based directly on figure 4-8 in P&M.
- * While an 8-point DCT cannot be done in less than 11 multiplies, it is
- * possible to arrange the computation so that many of the multiplies are
- * simple scalings of the final outputs. These multiplies can then be
- * folded into the multiplications or divisions by the JPEG quantization
- * table entries. The AA&N method leaves only 5 multiplies and 29 adds
- * to be done in the DCT itself.
- * The primary disadvantage of this method is that with fixed-point math,
- * accuracy is lost due to imprecise representation of the scaled
- * quantization values. The smaller the quantization table entry, the less
- * precise the scaled value, so this implementation does worse with high-
- * quality-setting files than with low-quality ones.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-#include "jdct.h" /* Private declarations for DCT subsystem */
-
-#ifdef DCT_IFAST_SUPPORTED
-
-
-/*
- * This module is specialized to the case DCTSIZE = 8.
- */
-
-#if DCTSIZE != 8
- Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */
-#endif
-
-
-/* Scaling decisions are generally the same as in the LL&M algorithm;
- * see jfdctint.c for more details. However, we choose to descale
- * (right shift) multiplication products as soon as they are formed,
- * rather than carrying additional fractional bits into subsequent additions.
- * This compromises accuracy slightly, but it lets us save a few shifts.
- * More importantly, 16-bit arithmetic is then adequate (for 8-bit samples)
- * everywhere except in the multiplications proper; this saves a good deal
- * of work on 16-bit-int machines.
- *
- * Again to save a few shifts, the intermediate results between pass 1 and
- * pass 2 are not upscaled, but are represented only to integral precision.
- *
- * A final compromise is to represent the multiplicative constants to only
- * 8 fractional bits, rather than 13. This saves some shifting work on some
- * machines, and may also reduce the cost of multiplication (since there
- * are fewer one-bits in the constants).
- */
-
-#define CONST_BITS 8
-
-
-/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus
- * causing a lot of useless floating-point operations at run time.
- * To get around this we use the following pre-calculated constants.
- * If you change CONST_BITS you may want to add appropriate values.
- * (With a reasonable C compiler, you can just rely on the FIX() macro...)
- */
-
-#if CONST_BITS == 8
-#define FIX_0_382683433 ((JLONG)98) /* FIX(0.382683433) */
-#define FIX_0_541196100 ((JLONG)139) /* FIX(0.541196100) */
-#define FIX_0_707106781 ((JLONG)181) /* FIX(0.707106781) */
-#define FIX_1_306562965 ((JLONG)334) /* FIX(1.306562965) */
-#else
-#define FIX_0_382683433 FIX(0.382683433)
-#define FIX_0_541196100 FIX(0.541196100)
-#define FIX_0_707106781 FIX(0.707106781)
-#define FIX_1_306562965 FIX(1.306562965)
-#endif
-
-
-/* We can gain a little more speed, with a further compromise in accuracy,
- * by omitting the addition in a descaling shift. This yields an incorrectly
- * rounded result half the time...
- */
-
-#ifndef USE_ACCURATE_ROUNDING
-#undef DESCALE
-#define DESCALE(x, n) RIGHT_SHIFT(x, n)
-#endif
-
-
-/* Multiply a DCTELEM variable by an JLONG constant, and immediately
- * descale to yield a DCTELEM result.
- */
-
-#define MULTIPLY(var, const) ((DCTELEM)DESCALE((var) * (const), CONST_BITS))
-
-
-/*
- * Perform the forward DCT on one block of samples.
- */
-
-GLOBAL(void)
-jpeg_fdct_ifast(DCTELEM *data)
-{
- DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
- DCTELEM tmp10, tmp11, tmp12, tmp13;
- DCTELEM z1, z2, z3, z4, z5, z11, z13;
- DCTELEM *dataptr;
- int ctr;
- SHIFT_TEMPS
-
- /* Pass 1: process rows. */
-
- dataptr = data;
- for (ctr = DCTSIZE - 1; ctr >= 0; ctr--) {
- tmp0 = dataptr[0] + dataptr[7];
- tmp7 = dataptr[0] - dataptr[7];
- tmp1 = dataptr[1] + dataptr[6];
- tmp6 = dataptr[1] - dataptr[6];
- tmp2 = dataptr[2] + dataptr[5];
- tmp5 = dataptr[2] - dataptr[5];
- tmp3 = dataptr[3] + dataptr[4];
- tmp4 = dataptr[3] - dataptr[4];
-
- /* Even part */
-
- tmp10 = tmp0 + tmp3; /* phase 2 */
- tmp13 = tmp0 - tmp3;
- tmp11 = tmp1 + tmp2;
- tmp12 = tmp1 - tmp2;
-
- dataptr[0] = tmp10 + tmp11; /* phase 3 */
- dataptr[4] = tmp10 - tmp11;
-
- z1 = MULTIPLY(tmp12 + tmp13, FIX_0_707106781); /* c4 */
- dataptr[2] = tmp13 + z1; /* phase 5 */
- dataptr[6] = tmp13 - z1;
-
- /* Odd part */
-
- tmp10 = tmp4 + tmp5; /* phase 2 */
- tmp11 = tmp5 + tmp6;
- tmp12 = tmp6 + tmp7;
-
- /* The rotator is modified from fig 4-8 to avoid extra negations. */
- z5 = MULTIPLY(tmp10 - tmp12, FIX_0_382683433); /* c6 */
- z2 = MULTIPLY(tmp10, FIX_0_541196100) + z5; /* c2-c6 */
- z4 = MULTIPLY(tmp12, FIX_1_306562965) + z5; /* c2+c6 */
- z3 = MULTIPLY(tmp11, FIX_0_707106781); /* c4 */
-
- z11 = tmp7 + z3; /* phase 5 */
- z13 = tmp7 - z3;
-
- dataptr[5] = z13 + z2; /* phase 6 */
- dataptr[3] = z13 - z2;
- dataptr[1] = z11 + z4;
- dataptr[7] = z11 - z4;
-
- dataptr += DCTSIZE; /* advance pointer to next row */
- }
-
- /* Pass 2: process columns. */
-
- dataptr = data;
- for (ctr = DCTSIZE - 1; ctr >= 0; ctr--) {
- tmp0 = dataptr[DCTSIZE * 0] + dataptr[DCTSIZE * 7];
- tmp7 = dataptr[DCTSIZE * 0] - dataptr[DCTSIZE * 7];
- tmp1 = dataptr[DCTSIZE * 1] + dataptr[DCTSIZE * 6];
- tmp6 = dataptr[DCTSIZE * 1] - dataptr[DCTSIZE * 6];
- tmp2 = dataptr[DCTSIZE * 2] + dataptr[DCTSIZE * 5];
- tmp5 = dataptr[DCTSIZE * 2] - dataptr[DCTSIZE * 5];
- tmp3 = dataptr[DCTSIZE * 3] + dataptr[DCTSIZE * 4];
- tmp4 = dataptr[DCTSIZE * 3] - dataptr[DCTSIZE * 4];
-
- /* Even part */
-
- tmp10 = tmp0 + tmp3; /* phase 2 */
- tmp13 = tmp0 - tmp3;
- tmp11 = tmp1 + tmp2;
- tmp12 = tmp1 - tmp2;
-
- dataptr[DCTSIZE * 0] = tmp10 + tmp11; /* phase 3 */
- dataptr[DCTSIZE * 4] = tmp10 - tmp11;
-
- z1 = MULTIPLY(tmp12 + tmp13, FIX_0_707106781); /* c4 */
- dataptr[DCTSIZE * 2] = tmp13 + z1; /* phase 5 */
- dataptr[DCTSIZE * 6] = tmp13 - z1;
-
- /* Odd part */
-
- tmp10 = tmp4 + tmp5; /* phase 2 */
- tmp11 = tmp5 + tmp6;
- tmp12 = tmp6 + tmp7;
-
- /* The rotator is modified from fig 4-8 to avoid extra negations. */
- z5 = MULTIPLY(tmp10 - tmp12, FIX_0_382683433); /* c6 */
- z2 = MULTIPLY(tmp10, FIX_0_541196100) + z5; /* c2-c6 */
- z4 = MULTIPLY(tmp12, FIX_1_306562965) + z5; /* c2+c6 */
- z3 = MULTIPLY(tmp11, FIX_0_707106781); /* c4 */
-
- z11 = tmp7 + z3; /* phase 5 */
- z13 = tmp7 - z3;
-
- dataptr[DCTSIZE * 5] = z13 + z2; /* phase 6 */
- dataptr[DCTSIZE * 3] = z13 - z2;
- dataptr[DCTSIZE * 1] = z11 + z4;
- dataptr[DCTSIZE * 7] = z11 - z4;
-
- dataptr++; /* advance pointer to next column */
- }
-}
-
-#endif /* DCT_IFAST_SUPPORTED */
diff --git a/contrib/libs/libjpeg-turbo/jfdctint.c b/contrib/libs/libjpeg-turbo/jfdctint.c
deleted file mode 100644
index c95a3a7fb8..0000000000
--- a/contrib/libs/libjpeg-turbo/jfdctint.c
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- * jfdctint.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1996, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2015, 2020, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains a slower but more accurate integer implementation of the
- * forward DCT (Discrete Cosine Transform).
- *
- * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT
- * on each column. Direct algorithms are also available, but they are
- * much more complex and seem not to be any faster when reduced to code.
- *
- * This implementation is based on an algorithm described in
- * C. Loeffler, A. Ligtenberg and G. Moschytz, "Practical Fast 1-D DCT
- * Algorithms with 11 Multiplications", Proc. Int'l. Conf. on Acoustics,
- * Speech, and Signal Processing 1989 (ICASSP '89), pp. 988-991.
- * The primary algorithm described there uses 11 multiplies and 29 adds.
- * We use their alternate method with 12 multiplies and 32 adds.
- * The advantage of this method is that no data path contains more than one
- * multiplication; this allows a very simple and accurate implementation in
- * scaled fixed-point arithmetic, with a minimal number of shifts.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-#include "jdct.h" /* Private declarations for DCT subsystem */
-
-#ifdef DCT_ISLOW_SUPPORTED
-
-
-/*
- * This module is specialized to the case DCTSIZE = 8.
- */
-
-#if DCTSIZE != 8
- Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */
-#endif
-
-
-/*
- * The poop on this scaling stuff is as follows:
- *
- * Each 1-D DCT step produces outputs which are a factor of sqrt(N)
- * larger than the true DCT outputs. The final outputs are therefore
- * a factor of N larger than desired; since N=8 this can be cured by
- * a simple right shift at the end of the algorithm. The advantage of
- * this arrangement is that we save two multiplications per 1-D DCT,
- * because the y0 and y4 outputs need not be divided by sqrt(N).
- * In the IJG code, this factor of 8 is removed by the quantization step
- * (in jcdctmgr.c), NOT in this module.
- *
- * We have to do addition and subtraction of the integer inputs, which
- * is no problem, and multiplication by fractional constants, which is
- * a problem to do in integer arithmetic. We multiply all the constants
- * by CONST_SCALE and convert them to integer constants (thus retaining
- * CONST_BITS bits of precision in the constants). After doing a
- * multiplication we have to divide the product by CONST_SCALE, with proper
- * rounding, to produce the correct output. This division can be done
- * cheaply as a right shift of CONST_BITS bits. We postpone shifting
- * as long as possible so that partial sums can be added together with
- * full fractional precision.
- *
- * The outputs of the first pass are scaled up by PASS1_BITS bits so that
- * they are represented to better-than-integral precision. These outputs
- * require BITS_IN_JSAMPLE + PASS1_BITS + 3 bits; this fits in a 16-bit word
- * with the recommended scaling. (For 12-bit sample data, the intermediate
- * array is JLONG anyway.)
- *
- * To avoid overflow of the 32-bit intermediate results in pass 2, we must
- * have BITS_IN_JSAMPLE + CONST_BITS + PASS1_BITS <= 26. Error analysis
- * shows that the values given below are the most effective.
- */
-
-#if BITS_IN_JSAMPLE == 8
-#define CONST_BITS 13
-#define PASS1_BITS 2
-#else
-#define CONST_BITS 13
-#define PASS1_BITS 1 /* lose a little precision to avoid overflow */
-#endif
-
-/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus
- * causing a lot of useless floating-point operations at run time.
- * To get around this we use the following pre-calculated constants.
- * If you change CONST_BITS you may want to add appropriate values.
- * (With a reasonable C compiler, you can just rely on the FIX() macro...)
- */
-
-#if CONST_BITS == 13
-#define FIX_0_298631336 ((JLONG)2446) /* FIX(0.298631336) */
-#define FIX_0_390180644 ((JLONG)3196) /* FIX(0.390180644) */
-#define FIX_0_541196100 ((JLONG)4433) /* FIX(0.541196100) */
-#define FIX_0_765366865 ((JLONG)6270) /* FIX(0.765366865) */
-#define FIX_0_899976223 ((JLONG)7373) /* FIX(0.899976223) */
-#define FIX_1_175875602 ((JLONG)9633) /* FIX(1.175875602) */
-#define FIX_1_501321110 ((JLONG)12299) /* FIX(1.501321110) */
-#define FIX_1_847759065 ((JLONG)15137) /* FIX(1.847759065) */
-#define FIX_1_961570560 ((JLONG)16069) /* FIX(1.961570560) */
-#define FIX_2_053119869 ((JLONG)16819) /* FIX(2.053119869) */
-#define FIX_2_562915447 ((JLONG)20995) /* FIX(2.562915447) */
-#define FIX_3_072711026 ((JLONG)25172) /* FIX(3.072711026) */
-#else
-#define FIX_0_298631336 FIX(0.298631336)
-#define FIX_0_390180644 FIX(0.390180644)
-#define FIX_0_541196100 FIX(0.541196100)
-#define FIX_0_765366865 FIX(0.765366865)
-#define FIX_0_899976223 FIX(0.899976223)
-#define FIX_1_175875602 FIX(1.175875602)
-#define FIX_1_501321110 FIX(1.501321110)
-#define FIX_1_847759065 FIX(1.847759065)
-#define FIX_1_961570560 FIX(1.961570560)
-#define FIX_2_053119869 FIX(2.053119869)
-#define FIX_2_562915447 FIX(2.562915447)
-#define FIX_3_072711026 FIX(3.072711026)
-#endif
-
-
-/* Multiply an JLONG variable by an JLONG constant to yield an JLONG result.
- * For 8-bit samples with the recommended scaling, all the variable
- * and constant values involved are no more than 16 bits wide, so a
- * 16x16->32 bit multiply can be used instead of a full 32x32 multiply.
- * For 12-bit samples, a full 32-bit multiplication will be needed.
- */
-
-#if BITS_IN_JSAMPLE == 8
-#define MULTIPLY(var, const) MULTIPLY16C16(var, const)
-#else
-#define MULTIPLY(var, const) ((var) * (const))
-#endif
-
-
-/*
- * Perform the forward DCT on one block of samples.
- */
-
-GLOBAL(void)
-jpeg_fdct_islow(DCTELEM *data)
-{
- JLONG tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
- JLONG tmp10, tmp11, tmp12, tmp13;
- JLONG z1, z2, z3, z4, z5;
- DCTELEM *dataptr;
- int ctr;
- SHIFT_TEMPS
-
- /* Pass 1: process rows. */
- /* Note results are scaled up by sqrt(8) compared to a true DCT; */
- /* furthermore, we scale the results by 2**PASS1_BITS. */
-
- dataptr = data;
- for (ctr = DCTSIZE - 1; ctr >= 0; ctr--) {
- tmp0 = dataptr[0] + dataptr[7];
- tmp7 = dataptr[0] - dataptr[7];
- tmp1 = dataptr[1] + dataptr[6];
- tmp6 = dataptr[1] - dataptr[6];
- tmp2 = dataptr[2] + dataptr[5];
- tmp5 = dataptr[2] - dataptr[5];
- tmp3 = dataptr[3] + dataptr[4];
- tmp4 = dataptr[3] - dataptr[4];
-
- /* Even part per LL&M figure 1 --- note that published figure is faulty;
- * rotator "sqrt(2)*c1" should be "sqrt(2)*c6".
- */
-
- tmp10 = tmp0 + tmp3;
- tmp13 = tmp0 - tmp3;
- tmp11 = tmp1 + tmp2;
- tmp12 = tmp1 - tmp2;
-
- dataptr[0] = (DCTELEM)LEFT_SHIFT(tmp10 + tmp11, PASS1_BITS);
- dataptr[4] = (DCTELEM)LEFT_SHIFT(tmp10 - tmp11, PASS1_BITS);
-
- z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100);
- dataptr[2] = (DCTELEM)DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865),
- CONST_BITS - PASS1_BITS);
- dataptr[6] = (DCTELEM)DESCALE(z1 + MULTIPLY(tmp12, -FIX_1_847759065),
- CONST_BITS - PASS1_BITS);
-
- /* Odd part per figure 8 --- note paper omits factor of sqrt(2).
- * cK represents cos(K*pi/16).
- * i0..i3 in the paper are tmp4..tmp7 here.
- */
-
- z1 = tmp4 + tmp7;
- z2 = tmp5 + tmp6;
- z3 = tmp4 + tmp6;
- z4 = tmp5 + tmp7;
- z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */
-
- tmp4 = MULTIPLY(tmp4, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */
- tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */
- tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */
- tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */
- z1 = MULTIPLY(z1, -FIX_0_899976223); /* sqrt(2) * ( c7-c3) */
- z2 = MULTIPLY(z2, -FIX_2_562915447); /* sqrt(2) * (-c1-c3) */
- z3 = MULTIPLY(z3, -FIX_1_961570560); /* sqrt(2) * (-c3-c5) */
- z4 = MULTIPLY(z4, -FIX_0_390180644); /* sqrt(2) * ( c5-c3) */
-
- z3 += z5;
- z4 += z5;
-
- dataptr[7] = (DCTELEM)DESCALE(tmp4 + z1 + z3, CONST_BITS - PASS1_BITS);
- dataptr[5] = (DCTELEM)DESCALE(tmp5 + z2 + z4, CONST_BITS - PASS1_BITS);
- dataptr[3] = (DCTELEM)DESCALE(tmp6 + z2 + z3, CONST_BITS - PASS1_BITS);
- dataptr[1] = (DCTELEM)DESCALE(tmp7 + z1 + z4, CONST_BITS - PASS1_BITS);
-
- dataptr += DCTSIZE; /* advance pointer to next row */
- }
-
- /* Pass 2: process columns.
- * We remove the PASS1_BITS scaling, but leave the results scaled up
- * by an overall factor of 8.
- */
-
- dataptr = data;
- for (ctr = DCTSIZE - 1; ctr >= 0; ctr--) {
- tmp0 = dataptr[DCTSIZE * 0] + dataptr[DCTSIZE * 7];
- tmp7 = dataptr[DCTSIZE * 0] - dataptr[DCTSIZE * 7];
- tmp1 = dataptr[DCTSIZE * 1] + dataptr[DCTSIZE * 6];
- tmp6 = dataptr[DCTSIZE * 1] - dataptr[DCTSIZE * 6];
- tmp2 = dataptr[DCTSIZE * 2] + dataptr[DCTSIZE * 5];
- tmp5 = dataptr[DCTSIZE * 2] - dataptr[DCTSIZE * 5];
- tmp3 = dataptr[DCTSIZE * 3] + dataptr[DCTSIZE * 4];
- tmp4 = dataptr[DCTSIZE * 3] - dataptr[DCTSIZE * 4];
-
- /* Even part per LL&M figure 1 --- note that published figure is faulty;
- * rotator "sqrt(2)*c1" should be "sqrt(2)*c6".
- */
-
- tmp10 = tmp0 + tmp3;
- tmp13 = tmp0 - tmp3;
- tmp11 = tmp1 + tmp2;
- tmp12 = tmp1 - tmp2;
-
- dataptr[DCTSIZE * 0] = (DCTELEM)DESCALE(tmp10 + tmp11, PASS1_BITS);
- dataptr[DCTSIZE * 4] = (DCTELEM)DESCALE(tmp10 - tmp11, PASS1_BITS);
-
- z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100);
- dataptr[DCTSIZE * 2] =
- (DCTELEM)DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865),
- CONST_BITS + PASS1_BITS);
- dataptr[DCTSIZE * 6] =
- (DCTELEM)DESCALE(z1 + MULTIPLY(tmp12, -FIX_1_847759065),
- CONST_BITS + PASS1_BITS);
-
- /* Odd part per figure 8 --- note paper omits factor of sqrt(2).
- * cK represents cos(K*pi/16).
- * i0..i3 in the paper are tmp4..tmp7 here.
- */
-
- z1 = tmp4 + tmp7;
- z2 = tmp5 + tmp6;
- z3 = tmp4 + tmp6;
- z4 = tmp5 + tmp7;
- z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */
-
- tmp4 = MULTIPLY(tmp4, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */
- tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */
- tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */
- tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */
- z1 = MULTIPLY(z1, -FIX_0_899976223); /* sqrt(2) * ( c7-c3) */
- z2 = MULTIPLY(z2, -FIX_2_562915447); /* sqrt(2) * (-c1-c3) */
- z3 = MULTIPLY(z3, -FIX_1_961570560); /* sqrt(2) * (-c3-c5) */
- z4 = MULTIPLY(z4, -FIX_0_390180644); /* sqrt(2) * ( c5-c3) */
-
- z3 += z5;
- z4 += z5;
-
- dataptr[DCTSIZE * 7] = (DCTELEM)DESCALE(tmp4 + z1 + z3,
- CONST_BITS + PASS1_BITS);
- dataptr[DCTSIZE * 5] = (DCTELEM)DESCALE(tmp5 + z2 + z4,
- CONST_BITS + PASS1_BITS);
- dataptr[DCTSIZE * 3] = (DCTELEM)DESCALE(tmp6 + z2 + z3,
- CONST_BITS + PASS1_BITS);
- dataptr[DCTSIZE * 1] = (DCTELEM)DESCALE(tmp7 + z1 + z4,
- CONST_BITS + PASS1_BITS);
-
- dataptr++; /* advance pointer to next column */
- }
-}
-
-#endif /* DCT_ISLOW_SUPPORTED */
diff --git a/contrib/libs/libjpeg-turbo/jidctflt.c b/contrib/libs/libjpeg-turbo/jidctflt.c
deleted file mode 100644
index 5aee74e232..0000000000
--- a/contrib/libs/libjpeg-turbo/jidctflt.c
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- * jidctflt.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1994-1998, Thomas G. Lane.
- * Modified 2010 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2014, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains a floating-point implementation of the
- * inverse DCT (Discrete Cosine Transform). In the IJG code, this routine
- * must also perform dequantization of the input coefficients.
- *
- * This implementation should be more accurate than either of the integer
- * IDCT implementations. However, it may not give the same results on all
- * machines because of differences in roundoff behavior. Speed will depend
- * on the hardware's floating point capacity.
- *
- * A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT
- * on each row (or vice versa, but it's more convenient to emit a row at
- * a time). Direct algorithms are also available, but they are much more
- * complex and seem not to be any faster when reduced to code.
- *
- * This implementation is based on Arai, Agui, and Nakajima's algorithm for
- * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in
- * Japanese, but the algorithm is described in the Pennebaker & Mitchell
- * JPEG textbook (see REFERENCES section in file README.ijg). The following
- * code is based directly on figure 4-8 in P&M.
- * While an 8-point DCT cannot be done in less than 11 multiplies, it is
- * possible to arrange the computation so that many of the multiplies are
- * simple scalings of the final outputs. These multiplies can then be
- * folded into the multiplications or divisions by the JPEG quantization
- * table entries. The AA&N method leaves only 5 multiplies and 29 adds
- * to be done in the DCT itself.
- * The primary disadvantage of this method is that with a fixed-point
- * implementation, accuracy is lost due to imprecise representation of the
- * scaled quantization values. However, that problem does not arise if
- * we use floating point arithmetic.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-#include "jdct.h" /* Private declarations for DCT subsystem */
-
-#ifdef DCT_FLOAT_SUPPORTED
-
-
-/*
- * This module is specialized to the case DCTSIZE = 8.
- */
-
-#if DCTSIZE != 8
- Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */
-#endif
-
-
-/* Dequantize a coefficient by multiplying it by the multiplier-table
- * entry; produce a float result.
- */
-
-#define DEQUANTIZE(coef, quantval) (((FAST_FLOAT)(coef)) * (quantval))
-
-
-/*
- * Perform dequantization and inverse DCT on one block of coefficients.
- */
-
-GLOBAL(void)
-jpeg_idct_float(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
- FAST_FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
- FAST_FLOAT tmp10, tmp11, tmp12, tmp13;
- FAST_FLOAT z5, z10, z11, z12, z13;
- JCOEFPTR inptr;
- FLOAT_MULT_TYPE *quantptr;
- FAST_FLOAT *wsptr;
- JSAMPROW outptr;
- JSAMPLE *range_limit = cinfo->sample_range_limit;
- int ctr;
- FAST_FLOAT workspace[DCTSIZE2]; /* buffers data between passes */
-#define _0_125 ((FLOAT_MULT_TYPE)0.125)
-
- /* Pass 1: process columns from input, store into work array. */
-
- inptr = coef_block;
- quantptr = (FLOAT_MULT_TYPE *)compptr->dct_table;
- wsptr = workspace;
- for (ctr = DCTSIZE; ctr > 0; ctr--) {
- /* Due to quantization, we will usually find that many of the input
- * coefficients are zero, especially the AC terms. We can exploit this
- * by short-circuiting the IDCT calculation for any column in which all
- * the AC terms are zero. In that case each output is equal to the
- * DC coefficient (with scale factor as needed).
- * With typical images and quantization tables, half or more of the
- * column DCT calculations can be simplified this way.
- */
-
- if (inptr[DCTSIZE * 1] == 0 && inptr[DCTSIZE * 2] == 0 &&
- inptr[DCTSIZE * 3] == 0 && inptr[DCTSIZE * 4] == 0 &&
- inptr[DCTSIZE * 5] == 0 && inptr[DCTSIZE * 6] == 0 &&
- inptr[DCTSIZE * 7] == 0) {
- /* AC terms all zero */
- FAST_FLOAT dcval = DEQUANTIZE(inptr[DCTSIZE * 0],
- quantptr[DCTSIZE * 0] * _0_125);
-
- wsptr[DCTSIZE * 0] = dcval;
- wsptr[DCTSIZE * 1] = dcval;
- wsptr[DCTSIZE * 2] = dcval;
- wsptr[DCTSIZE * 3] = dcval;
- wsptr[DCTSIZE * 4] = dcval;
- wsptr[DCTSIZE * 5] = dcval;
- wsptr[DCTSIZE * 6] = dcval;
- wsptr[DCTSIZE * 7] = dcval;
-
- inptr++; /* advance pointers to next column */
- quantptr++;
- wsptr++;
- continue;
- }
-
- /* Even part */
-
- tmp0 = DEQUANTIZE(inptr[DCTSIZE * 0], quantptr[DCTSIZE * 0] * _0_125);
- tmp1 = DEQUANTIZE(inptr[DCTSIZE * 2], quantptr[DCTSIZE * 2] * _0_125);
- tmp2 = DEQUANTIZE(inptr[DCTSIZE * 4], quantptr[DCTSIZE * 4] * _0_125);
- tmp3 = DEQUANTIZE(inptr[DCTSIZE * 6], quantptr[DCTSIZE * 6] * _0_125);
-
- tmp10 = tmp0 + tmp2; /* phase 3 */
- tmp11 = tmp0 - tmp2;
-
- tmp13 = tmp1 + tmp3; /* phases 5-3 */
- tmp12 = (tmp1 - tmp3) * ((FAST_FLOAT)1.414213562) - tmp13; /* 2*c4 */
-
- tmp0 = tmp10 + tmp13; /* phase 2 */
- tmp3 = tmp10 - tmp13;
- tmp1 = tmp11 + tmp12;
- tmp2 = tmp11 - tmp12;
-
- /* Odd part */
-
- tmp4 = DEQUANTIZE(inptr[DCTSIZE * 1], quantptr[DCTSIZE * 1] * _0_125);
- tmp5 = DEQUANTIZE(inptr[DCTSIZE * 3], quantptr[DCTSIZE * 3] * _0_125);
- tmp6 = DEQUANTIZE(inptr[DCTSIZE * 5], quantptr[DCTSIZE * 5] * _0_125);
- tmp7 = DEQUANTIZE(inptr[DCTSIZE * 7], quantptr[DCTSIZE * 7] * _0_125);
-
- z13 = tmp6 + tmp5; /* phase 6 */
- z10 = tmp6 - tmp5;
- z11 = tmp4 + tmp7;
- z12 = tmp4 - tmp7;
-
- tmp7 = z11 + z13; /* phase 5 */
- tmp11 = (z11 - z13) * ((FAST_FLOAT)1.414213562); /* 2*c4 */
-
- z5 = (z10 + z12) * ((FAST_FLOAT)1.847759065); /* 2*c2 */
- tmp10 = z5 - z12 * ((FAST_FLOAT)1.082392200); /* 2*(c2-c6) */
- tmp12 = z5 - z10 * ((FAST_FLOAT)2.613125930); /* 2*(c2+c6) */
-
- tmp6 = tmp12 - tmp7; /* phase 2 */
- tmp5 = tmp11 - tmp6;
- tmp4 = tmp10 - tmp5;
-
- wsptr[DCTSIZE * 0] = tmp0 + tmp7;
- wsptr[DCTSIZE * 7] = tmp0 - tmp7;
- wsptr[DCTSIZE * 1] = tmp1 + tmp6;
- wsptr[DCTSIZE * 6] = tmp1 - tmp6;
- wsptr[DCTSIZE * 2] = tmp2 + tmp5;
- wsptr[DCTSIZE * 5] = tmp2 - tmp5;
- wsptr[DCTSIZE * 3] = tmp3 + tmp4;
- wsptr[DCTSIZE * 4] = tmp3 - tmp4;
-
- inptr++; /* advance pointers to next column */
- quantptr++;
- wsptr++;
- }
-
- /* Pass 2: process rows from work array, store into output array. */
-
- wsptr = workspace;
- for (ctr = 0; ctr < DCTSIZE; ctr++) {
- outptr = output_buf[ctr] + output_col;
- /* Rows of zeroes can be exploited in the same way as we did with columns.
- * However, the column calculation has created many nonzero AC terms, so
- * the simplification applies less often (typically 5% to 10% of the time).
- * And testing floats for zero is relatively expensive, so we don't bother.
- */
-
- /* Even part */
-
- /* Apply signed->unsigned and prepare float->int conversion */
- z5 = wsptr[0] + ((FAST_FLOAT)CENTERJSAMPLE + (FAST_FLOAT)0.5);
- tmp10 = z5 + wsptr[4];
- tmp11 = z5 - wsptr[4];
-
- tmp13 = wsptr[2] + wsptr[6];
- tmp12 = (wsptr[2] - wsptr[6]) * ((FAST_FLOAT)1.414213562) - tmp13;
-
- tmp0 = tmp10 + tmp13;
- tmp3 = tmp10 - tmp13;
- tmp1 = tmp11 + tmp12;
- tmp2 = tmp11 - tmp12;
-
- /* Odd part */
-
- z13 = wsptr[5] + wsptr[3];
- z10 = wsptr[5] - wsptr[3];
- z11 = wsptr[1] + wsptr[7];
- z12 = wsptr[1] - wsptr[7];
-
- tmp7 = z11 + z13;
- tmp11 = (z11 - z13) * ((FAST_FLOAT)1.414213562);
-
- z5 = (z10 + z12) * ((FAST_FLOAT)1.847759065); /* 2*c2 */
- tmp10 = z5 - z12 * ((FAST_FLOAT)1.082392200); /* 2*(c2-c6) */
- tmp12 = z5 - z10 * ((FAST_FLOAT)2.613125930); /* 2*(c2+c6) */
-
- tmp6 = tmp12 - tmp7;
- tmp5 = tmp11 - tmp6;
- tmp4 = tmp10 - tmp5;
-
- /* Final output stage: float->int conversion and range-limit */
-
- outptr[0] = range_limit[((int)(tmp0 + tmp7)) & RANGE_MASK];
- outptr[7] = range_limit[((int)(tmp0 - tmp7)) & RANGE_MASK];
- outptr[1] = range_limit[((int)(tmp1 + tmp6)) & RANGE_MASK];
- outptr[6] = range_limit[((int)(tmp1 - tmp6)) & RANGE_MASK];
- outptr[2] = range_limit[((int)(tmp2 + tmp5)) & RANGE_MASK];
- outptr[5] = range_limit[((int)(tmp2 - tmp5)) & RANGE_MASK];
- outptr[3] = range_limit[((int)(tmp3 + tmp4)) & RANGE_MASK];
- outptr[4] = range_limit[((int)(tmp3 - tmp4)) & RANGE_MASK];
-
- wsptr += DCTSIZE; /* advance pointer to next row */
- }
-}
-
-#endif /* DCT_FLOAT_SUPPORTED */
diff --git a/contrib/libs/libjpeg-turbo/jidctfst.c b/contrib/libs/libjpeg-turbo/jidctfst.c
deleted file mode 100644
index 89a20c937b..0000000000
--- a/contrib/libs/libjpeg-turbo/jidctfst.c
+++ /dev/null
@@ -1,371 +0,0 @@
-/*
- * jidctfst.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1994-1998, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2015, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains a fast, not so accurate integer implementation of the
- * inverse DCT (Discrete Cosine Transform). In the IJG code, this routine
- * must also perform dequantization of the input coefficients.
- *
- * A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT
- * on each row (or vice versa, but it's more convenient to emit a row at
- * a time). Direct algorithms are also available, but they are much more
- * complex and seem not to be any faster when reduced to code.
- *
- * This implementation is based on Arai, Agui, and Nakajima's algorithm for
- * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in
- * Japanese, but the algorithm is described in the Pennebaker & Mitchell
- * JPEG textbook (see REFERENCES section in file README.ijg). The following
- * code is based directly on figure 4-8 in P&M.
- * While an 8-point DCT cannot be done in less than 11 multiplies, it is
- * possible to arrange the computation so that many of the multiplies are
- * simple scalings of the final outputs. These multiplies can then be
- * folded into the multiplications or divisions by the JPEG quantization
- * table entries. The AA&N method leaves only 5 multiplies and 29 adds
- * to be done in the DCT itself.
- * The primary disadvantage of this method is that with fixed-point math,
- * accuracy is lost due to imprecise representation of the scaled
- * quantization values. The smaller the quantization table entry, the less
- * precise the scaled value, so this implementation does worse with high-
- * quality-setting files than with low-quality ones.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-#include "jdct.h" /* Private declarations for DCT subsystem */
-
-#ifdef DCT_IFAST_SUPPORTED
-
-
-/*
- * This module is specialized to the case DCTSIZE = 8.
- */
-
-#if DCTSIZE != 8
- Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */
-#endif
-
-
-/* Scaling decisions are generally the same as in the LL&M algorithm;
- * see jidctint.c for more details. However, we choose to descale
- * (right shift) multiplication products as soon as they are formed,
- * rather than carrying additional fractional bits into subsequent additions.
- * This compromises accuracy slightly, but it lets us save a few shifts.
- * More importantly, 16-bit arithmetic is then adequate (for 8-bit samples)
- * everywhere except in the multiplications proper; this saves a good deal
- * of work on 16-bit-int machines.
- *
- * The dequantized coefficients are not integers because the AA&N scaling
- * factors have been incorporated. We represent them scaled up by PASS1_BITS,
- * so that the first and second IDCT rounds have the same input scaling.
- * For 8-bit JSAMPLEs, we choose IFAST_SCALE_BITS = PASS1_BITS so as to
- * avoid a descaling shift; this compromises accuracy rather drastically
- * for small quantization table entries, but it saves a lot of shifts.
- * For 12-bit JSAMPLEs, there's no hope of using 16x16 multiplies anyway,
- * so we use a much larger scaling factor to preserve accuracy.
- *
- * A final compromise is to represent the multiplicative constants to only
- * 8 fractional bits, rather than 13. This saves some shifting work on some
- * machines, and may also reduce the cost of multiplication (since there
- * are fewer one-bits in the constants).
- */
-
-#if BITS_IN_JSAMPLE == 8
-#define CONST_BITS 8
-#define PASS1_BITS 2
-#else
-#define CONST_BITS 8
-#define PASS1_BITS 1 /* lose a little precision to avoid overflow */
-#endif
-
-/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus
- * causing a lot of useless floating-point operations at run time.
- * To get around this we use the following pre-calculated constants.
- * If you change CONST_BITS you may want to add appropriate values.
- * (With a reasonable C compiler, you can just rely on the FIX() macro...)
- */
-
-#if CONST_BITS == 8
-#define FIX_1_082392200 ((JLONG)277) /* FIX(1.082392200) */
-#define FIX_1_414213562 ((JLONG)362) /* FIX(1.414213562) */
-#define FIX_1_847759065 ((JLONG)473) /* FIX(1.847759065) */
-#define FIX_2_613125930 ((JLONG)669) /* FIX(2.613125930) */
-#else
-#define FIX_1_082392200 FIX(1.082392200)
-#define FIX_1_414213562 FIX(1.414213562)
-#define FIX_1_847759065 FIX(1.847759065)
-#define FIX_2_613125930 FIX(2.613125930)
-#endif
-
-
-/* We can gain a little more speed, with a further compromise in accuracy,
- * by omitting the addition in a descaling shift. This yields an incorrectly
- * rounded result half the time...
- */
-
-#ifndef USE_ACCURATE_ROUNDING
-#undef DESCALE
-#define DESCALE(x, n) RIGHT_SHIFT(x, n)
-#endif
-
-
-/* Multiply a DCTELEM variable by an JLONG constant, and immediately
- * descale to yield a DCTELEM result.
- */
-
-#define MULTIPLY(var, const) ((DCTELEM)DESCALE((var) * (const), CONST_BITS))
-
-
-/* Dequantize a coefficient by multiplying it by the multiplier-table
- * entry; produce a DCTELEM result. For 8-bit data a 16x16->16
- * multiplication will do. For 12-bit data, the multiplier table is
- * declared JLONG, so a 32-bit multiply will be used.
- */
-
-#if BITS_IN_JSAMPLE == 8
-#define DEQUANTIZE(coef, quantval) (((IFAST_MULT_TYPE)(coef)) * (quantval))
-#else
-#define DEQUANTIZE(coef, quantval) \
- DESCALE((coef) * (quantval), IFAST_SCALE_BITS - PASS1_BITS)
-#endif
-
-
-/* Like DESCALE, but applies to a DCTELEM and produces an int.
- * We assume that int right shift is unsigned if JLONG right shift is.
- */
-
-#ifdef RIGHT_SHIFT_IS_UNSIGNED
-#define ISHIFT_TEMPS DCTELEM ishift_temp;
-#if BITS_IN_JSAMPLE == 8
-#define DCTELEMBITS 16 /* DCTELEM may be 16 or 32 bits */
-#else
-#define DCTELEMBITS 32 /* DCTELEM must be 32 bits */
-#endif
-#define IRIGHT_SHIFT(x, shft) \
- ((ishift_temp = (x)) < 0 ? \
- (ishift_temp >> (shft)) | ((~((DCTELEM)0)) << (DCTELEMBITS - (shft))) : \
- (ishift_temp >> (shft)))
-#else
-#define ISHIFT_TEMPS
-#define IRIGHT_SHIFT(x, shft) ((x) >> (shft))
-#endif
-
-#ifdef USE_ACCURATE_ROUNDING
-#define IDESCALE(x, n) ((int)IRIGHT_SHIFT((x) + (1 << ((n) - 1)), n))
-#else
-#define IDESCALE(x, n) ((int)IRIGHT_SHIFT(x, n))
-#endif
-
-
-/*
- * Perform dequantization and inverse DCT on one block of coefficients.
- */
-
-GLOBAL(void)
-jpeg_idct_ifast(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
- DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
- DCTELEM tmp10, tmp11, tmp12, tmp13;
- DCTELEM z5, z10, z11, z12, z13;
- JCOEFPTR inptr;
- IFAST_MULT_TYPE *quantptr;
- int *wsptr;
- JSAMPROW outptr;
- JSAMPLE *range_limit = IDCT_range_limit(cinfo);
- int ctr;
- int workspace[DCTSIZE2]; /* buffers data between passes */
- SHIFT_TEMPS /* for DESCALE */
- ISHIFT_TEMPS /* for IDESCALE */
-
- /* Pass 1: process columns from input, store into work array. */
-
- inptr = coef_block;
- quantptr = (IFAST_MULT_TYPE *)compptr->dct_table;
- wsptr = workspace;
- for (ctr = DCTSIZE; ctr > 0; ctr--) {
- /* Due to quantization, we will usually find that many of the input
- * coefficients are zero, especially the AC terms. We can exploit this
- * by short-circuiting the IDCT calculation for any column in which all
- * the AC terms are zero. In that case each output is equal to the
- * DC coefficient (with scale factor as needed).
- * With typical images and quantization tables, half or more of the
- * column DCT calculations can be simplified this way.
- */
-
- if (inptr[DCTSIZE * 1] == 0 && inptr[DCTSIZE * 2] == 0 &&
- inptr[DCTSIZE * 3] == 0 && inptr[DCTSIZE * 4] == 0 &&
- inptr[DCTSIZE * 5] == 0 && inptr[DCTSIZE * 6] == 0 &&
- inptr[DCTSIZE * 7] == 0) {
- /* AC terms all zero */
- int dcval = (int)DEQUANTIZE(inptr[DCTSIZE * 0], quantptr[DCTSIZE * 0]);
-
- wsptr[DCTSIZE * 0] = dcval;
- wsptr[DCTSIZE * 1] = dcval;
- wsptr[DCTSIZE * 2] = dcval;
- wsptr[DCTSIZE * 3] = dcval;
- wsptr[DCTSIZE * 4] = dcval;
- wsptr[DCTSIZE * 5] = dcval;
- wsptr[DCTSIZE * 6] = dcval;
- wsptr[DCTSIZE * 7] = dcval;
-
- inptr++; /* advance pointers to next column */
- quantptr++;
- wsptr++;
- continue;
- }
-
- /* Even part */
-
- tmp0 = DEQUANTIZE(inptr[DCTSIZE * 0], quantptr[DCTSIZE * 0]);
- tmp1 = DEQUANTIZE(inptr[DCTSIZE * 2], quantptr[DCTSIZE * 2]);
- tmp2 = DEQUANTIZE(inptr[DCTSIZE * 4], quantptr[DCTSIZE * 4]);
- tmp3 = DEQUANTIZE(inptr[DCTSIZE * 6], quantptr[DCTSIZE * 6]);
-
- tmp10 = tmp0 + tmp2; /* phase 3 */
- tmp11 = tmp0 - tmp2;
-
- tmp13 = tmp1 + tmp3; /* phases 5-3 */
- tmp12 = MULTIPLY(tmp1 - tmp3, FIX_1_414213562) - tmp13; /* 2*c4 */
-
- tmp0 = tmp10 + tmp13; /* phase 2 */
- tmp3 = tmp10 - tmp13;
- tmp1 = tmp11 + tmp12;
- tmp2 = tmp11 - tmp12;
-
- /* Odd part */
-
- tmp4 = DEQUANTIZE(inptr[DCTSIZE * 1], quantptr[DCTSIZE * 1]);
- tmp5 = DEQUANTIZE(inptr[DCTSIZE * 3], quantptr[DCTSIZE * 3]);
- tmp6 = DEQUANTIZE(inptr[DCTSIZE * 5], quantptr[DCTSIZE * 5]);
- tmp7 = DEQUANTIZE(inptr[DCTSIZE * 7], quantptr[DCTSIZE * 7]);
-
- z13 = tmp6 + tmp5; /* phase 6 */
- z10 = tmp6 - tmp5;
- z11 = tmp4 + tmp7;
- z12 = tmp4 - tmp7;
-
- tmp7 = z11 + z13; /* phase 5 */
- tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */
-
- z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */
- tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; /* 2*(c2-c6) */
- tmp12 = MULTIPLY(z10, -FIX_2_613125930) + z5; /* -2*(c2+c6) */
-
- tmp6 = tmp12 - tmp7; /* phase 2 */
- tmp5 = tmp11 - tmp6;
- tmp4 = tmp10 + tmp5;
-
- wsptr[DCTSIZE * 0] = (int)(tmp0 + tmp7);
- wsptr[DCTSIZE * 7] = (int)(tmp0 - tmp7);
- wsptr[DCTSIZE * 1] = (int)(tmp1 + tmp6);
- wsptr[DCTSIZE * 6] = (int)(tmp1 - tmp6);
- wsptr[DCTSIZE * 2] = (int)(tmp2 + tmp5);
- wsptr[DCTSIZE * 5] = (int)(tmp2 - tmp5);
- wsptr[DCTSIZE * 4] = (int)(tmp3 + tmp4);
- wsptr[DCTSIZE * 3] = (int)(tmp3 - tmp4);
-
- inptr++; /* advance pointers to next column */
- quantptr++;
- wsptr++;
- }
-
- /* Pass 2: process rows from work array, store into output array. */
- /* Note that we must descale the results by a factor of 8 == 2**3, */
- /* and also undo the PASS1_BITS scaling. */
-
- wsptr = workspace;
- for (ctr = 0; ctr < DCTSIZE; ctr++) {
- outptr = output_buf[ctr] + output_col;
- /* Rows of zeroes can be exploited in the same way as we did with columns.
- * However, the column calculation has created many nonzero AC terms, so
- * the simplification applies less often (typically 5% to 10% of the time).
- * On machines with very fast multiplication, it's possible that the
- * test takes more time than it's worth. In that case this section
- * may be commented out.
- */
-
-#ifndef NO_ZERO_ROW_TEST
- if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && wsptr[4] == 0 &&
- wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) {
- /* AC terms all zero */
- JSAMPLE dcval =
- range_limit[IDESCALE(wsptr[0], PASS1_BITS + 3) & RANGE_MASK];
-
- outptr[0] = dcval;
- outptr[1] = dcval;
- outptr[2] = dcval;
- outptr[3] = dcval;
- outptr[4] = dcval;
- outptr[5] = dcval;
- outptr[6] = dcval;
- outptr[7] = dcval;
-
- wsptr += DCTSIZE; /* advance pointer to next row */
- continue;
- }
-#endif
-
- /* Even part */
-
- tmp10 = ((DCTELEM)wsptr[0] + (DCTELEM)wsptr[4]);
- tmp11 = ((DCTELEM)wsptr[0] - (DCTELEM)wsptr[4]);
-
- tmp13 = ((DCTELEM)wsptr[2] + (DCTELEM)wsptr[6]);
- tmp12 =
- MULTIPLY((DCTELEM)wsptr[2] - (DCTELEM)wsptr[6], FIX_1_414213562) - tmp13;
-
- tmp0 = tmp10 + tmp13;
- tmp3 = tmp10 - tmp13;
- tmp1 = tmp11 + tmp12;
- tmp2 = tmp11 - tmp12;
-
- /* Odd part */
-
- z13 = (DCTELEM)wsptr[5] + (DCTELEM)wsptr[3];
- z10 = (DCTELEM)wsptr[5] - (DCTELEM)wsptr[3];
- z11 = (DCTELEM)wsptr[1] + (DCTELEM)wsptr[7];
- z12 = (DCTELEM)wsptr[1] - (DCTELEM)wsptr[7];
-
- tmp7 = z11 + z13; /* phase 5 */
- tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */
-
- z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */
- tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; /* 2*(c2-c6) */
- tmp12 = MULTIPLY(z10, -FIX_2_613125930) + z5; /* -2*(c2+c6) */
-
- tmp6 = tmp12 - tmp7; /* phase 2 */
- tmp5 = tmp11 - tmp6;
- tmp4 = tmp10 + tmp5;
-
- /* Final output stage: scale down by a factor of 8 and range-limit */
-
- outptr[0] =
- range_limit[IDESCALE(tmp0 + tmp7, PASS1_BITS + 3) & RANGE_MASK];
- outptr[7] =
- range_limit[IDESCALE(tmp0 - tmp7, PASS1_BITS + 3) & RANGE_MASK];
- outptr[1] =
- range_limit[IDESCALE(tmp1 + tmp6, PASS1_BITS + 3) & RANGE_MASK];
- outptr[6] =
- range_limit[IDESCALE(tmp1 - tmp6, PASS1_BITS + 3) & RANGE_MASK];
- outptr[2] =
- range_limit[IDESCALE(tmp2 + tmp5, PASS1_BITS + 3) & RANGE_MASK];
- outptr[5] =
- range_limit[IDESCALE(tmp2 - tmp5, PASS1_BITS + 3) & RANGE_MASK];
- outptr[4] =
- range_limit[IDESCALE(tmp3 + tmp4, PASS1_BITS + 3) & RANGE_MASK];
- outptr[3] =
- range_limit[IDESCALE(tmp3 - tmp4, PASS1_BITS + 3) & RANGE_MASK];
-
- wsptr += DCTSIZE; /* advance pointer to next row */
- }
-}
-
-#endif /* DCT_IFAST_SUPPORTED */
diff --git a/contrib/libs/libjpeg-turbo/jidctint.c b/contrib/libs/libjpeg-turbo/jidctint.c
deleted file mode 100644
index bb08748019..0000000000
--- a/contrib/libs/libjpeg-turbo/jidctint.c
+++ /dev/null
@@ -1,2627 +0,0 @@
-/*
- * jidctint.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1998, Thomas G. Lane.
- * Modification developed 2002-2018 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2015, 2020, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains a slower but more accurate integer implementation of the
- * inverse DCT (Discrete Cosine Transform). In the IJG code, this routine
- * must also perform dequantization of the input coefficients.
- *
- * A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT
- * on each row (or vice versa, but it's more convenient to emit a row at
- * a time). Direct algorithms are also available, but they are much more
- * complex and seem not to be any faster when reduced to code.
- *
- * This implementation is based on an algorithm described in
- * C. Loeffler, A. Ligtenberg and G. Moschytz, "Practical Fast 1-D DCT
- * Algorithms with 11 Multiplications", Proc. Int'l. Conf. on Acoustics,
- * Speech, and Signal Processing 1989 (ICASSP '89), pp. 988-991.
- * The primary algorithm described there uses 11 multiplies and 29 adds.
- * We use their alternate method with 12 multiplies and 32 adds.
- * The advantage of this method is that no data path contains more than one
- * multiplication; this allows a very simple and accurate implementation in
- * scaled fixed-point arithmetic, with a minimal number of shifts.
- *
- * We also provide IDCT routines with various output sample block sizes for
- * direct resolution reduction or enlargement without additional resampling:
- * NxN (N=1...16) pixels for one 8x8 input DCT block.
- *
- * For N<8 we simply take the corresponding low-frequency coefficients of
- * the 8x8 input DCT block and apply an NxN point IDCT on the sub-block
- * to yield the downscaled outputs.
- * This can be seen as direct low-pass downsampling from the DCT domain
- * point of view rather than the usual spatial domain point of view,
- * yielding significant computational savings and results at least
- * as good as common bilinear (averaging) spatial downsampling.
- *
- * For N>8 we apply a partial NxN IDCT on the 8 input coefficients as
- * lower frequencies and higher frequencies assumed to be zero.
- * It turns out that the computational effort is similar to the 8x8 IDCT
- * regarding the output size.
- * Furthermore, the scaling and descaling is the same for all IDCT sizes.
- *
- * CAUTION: We rely on the FIX() macro except for the N=1,2,4,8 cases
- * since there would be too many additional constants to pre-calculate.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-#include "jdct.h" /* Private declarations for DCT subsystem */
-
-#ifdef DCT_ISLOW_SUPPORTED
-
-
-/*
- * This module is specialized to the case DCTSIZE = 8.
- */
-
-#if DCTSIZE != 8
- Sorry, this code only copes with 8x8 DCT blocks. /* deliberate syntax err */
-#endif
-
-
-/*
- * The poop on this scaling stuff is as follows:
- *
- * Each 1-D IDCT step produces outputs which are a factor of sqrt(N)
- * larger than the true IDCT outputs. The final outputs are therefore
- * a factor of N larger than desired; since N=8 this can be cured by
- * a simple right shift at the end of the algorithm. The advantage of
- * this arrangement is that we save two multiplications per 1-D IDCT,
- * because the y0 and y4 inputs need not be divided by sqrt(N).
- *
- * We have to do addition and subtraction of the integer inputs, which
- * is no problem, and multiplication by fractional constants, which is
- * a problem to do in integer arithmetic. We multiply all the constants
- * by CONST_SCALE and convert them to integer constants (thus retaining
- * CONST_BITS bits of precision in the constants). After doing a
- * multiplication we have to divide the product by CONST_SCALE, with proper
- * rounding, to produce the correct output. This division can be done
- * cheaply as a right shift of CONST_BITS bits. We postpone shifting
- * as long as possible so that partial sums can be added together with
- * full fractional precision.
- *
- * The outputs of the first pass are scaled up by PASS1_BITS bits so that
- * they are represented to better-than-integral precision. These outputs
- * require BITS_IN_JSAMPLE + PASS1_BITS + 3 bits; this fits in a 16-bit word
- * with the recommended scaling. (To scale up 12-bit sample data further, an
- * intermediate JLONG array would be needed.)
- *
- * To avoid overflow of the 32-bit intermediate results in pass 2, we must
- * have BITS_IN_JSAMPLE + CONST_BITS + PASS1_BITS <= 26. Error analysis
- * shows that the values given below are the most effective.
- */
-
-#if BITS_IN_JSAMPLE == 8
-#define CONST_BITS 13
-#define PASS1_BITS 2
-#else
-#define CONST_BITS 13
-#define PASS1_BITS 1 /* lose a little precision to avoid overflow */
-#endif
-
-/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus
- * causing a lot of useless floating-point operations at run time.
- * To get around this we use the following pre-calculated constants.
- * If you change CONST_BITS you may want to add appropriate values.
- * (With a reasonable C compiler, you can just rely on the FIX() macro...)
- */
-
-#if CONST_BITS == 13
-#define FIX_0_298631336 ((JLONG)2446) /* FIX(0.298631336) */
-#define FIX_0_390180644 ((JLONG)3196) /* FIX(0.390180644) */
-#define FIX_0_541196100 ((JLONG)4433) /* FIX(0.541196100) */
-#define FIX_0_765366865 ((JLONG)6270) /* FIX(0.765366865) */
-#define FIX_0_899976223 ((JLONG)7373) /* FIX(0.899976223) */
-#define FIX_1_175875602 ((JLONG)9633) /* FIX(1.175875602) */
-#define FIX_1_501321110 ((JLONG)12299) /* FIX(1.501321110) */
-#define FIX_1_847759065 ((JLONG)15137) /* FIX(1.847759065) */
-#define FIX_1_961570560 ((JLONG)16069) /* FIX(1.961570560) */
-#define FIX_2_053119869 ((JLONG)16819) /* FIX(2.053119869) */
-#define FIX_2_562915447 ((JLONG)20995) /* FIX(2.562915447) */
-#define FIX_3_072711026 ((JLONG)25172) /* FIX(3.072711026) */
-#else
-#define FIX_0_298631336 FIX(0.298631336)
-#define FIX_0_390180644 FIX(0.390180644)
-#define FIX_0_541196100 FIX(0.541196100)
-#define FIX_0_765366865 FIX(0.765366865)
-#define FIX_0_899976223 FIX(0.899976223)
-#define FIX_1_175875602 FIX(1.175875602)
-#define FIX_1_501321110 FIX(1.501321110)
-#define FIX_1_847759065 FIX(1.847759065)
-#define FIX_1_961570560 FIX(1.961570560)
-#define FIX_2_053119869 FIX(2.053119869)
-#define FIX_2_562915447 FIX(2.562915447)
-#define FIX_3_072711026 FIX(3.072711026)
-#endif
-
-
-/* Multiply an JLONG variable by an JLONG constant to yield an JLONG result.
- * For 8-bit samples with the recommended scaling, all the variable
- * and constant values involved are no more than 16 bits wide, so a
- * 16x16->32 bit multiply can be used instead of a full 32x32 multiply.
- * For 12-bit samples, a full 32-bit multiplication will be needed.
- */
-
-#if BITS_IN_JSAMPLE == 8
-#define MULTIPLY(var, const) MULTIPLY16C16(var, const)
-#else
-#define MULTIPLY(var, const) ((var) * (const))
-#endif
-
-
-/* Dequantize a coefficient by multiplying it by the multiplier-table
- * entry; produce an int result. In this module, both inputs and result
- * are 16 bits or less, so either int or short multiply will work.
- */
-
-#define DEQUANTIZE(coef, quantval) (((ISLOW_MULT_TYPE)(coef)) * (quantval))
-
-
-/*
- * Perform dequantization and inverse DCT on one block of coefficients.
- */
-
-GLOBAL(void)
-jpeg_idct_islow(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
- JLONG tmp0, tmp1, tmp2, tmp3;
- JLONG tmp10, tmp11, tmp12, tmp13;
- JLONG z1, z2, z3, z4, z5;
- JCOEFPTR inptr;
- ISLOW_MULT_TYPE *quantptr;
- int *wsptr;
- JSAMPROW outptr;
- JSAMPLE *range_limit = IDCT_range_limit(cinfo);
- int ctr;
- int workspace[DCTSIZE2]; /* buffers data between passes */
- SHIFT_TEMPS
-
- /* Pass 1: process columns from input, store into work array. */
- /* Note results are scaled up by sqrt(8) compared to a true IDCT; */
- /* furthermore, we scale the results by 2**PASS1_BITS. */
-
- inptr = coef_block;
- quantptr = (ISLOW_MULT_TYPE *)compptr->dct_table;
- wsptr = workspace;
- for (ctr = DCTSIZE; ctr > 0; ctr--) {
- /* Due to quantization, we will usually find that many of the input
- * coefficients are zero, especially the AC terms. We can exploit this
- * by short-circuiting the IDCT calculation for any column in which all
- * the AC terms are zero. In that case each output is equal to the
- * DC coefficient (with scale factor as needed).
- * With typical images and quantization tables, half or more of the
- * column DCT calculations can be simplified this way.
- */
-
- if (inptr[DCTSIZE * 1] == 0 && inptr[DCTSIZE * 2] == 0 &&
- inptr[DCTSIZE * 3] == 0 && inptr[DCTSIZE * 4] == 0 &&
- inptr[DCTSIZE * 5] == 0 && inptr[DCTSIZE * 6] == 0 &&
- inptr[DCTSIZE * 7] == 0) {
- /* AC terms all zero */
- int dcval = LEFT_SHIFT(DEQUANTIZE(inptr[DCTSIZE * 0],
- quantptr[DCTSIZE * 0]), PASS1_BITS);
-
- wsptr[DCTSIZE * 0] = dcval;
- wsptr[DCTSIZE * 1] = dcval;
- wsptr[DCTSIZE * 2] = dcval;
- wsptr[DCTSIZE * 3] = dcval;
- wsptr[DCTSIZE * 4] = dcval;
- wsptr[DCTSIZE * 5] = dcval;
- wsptr[DCTSIZE * 6] = dcval;
- wsptr[DCTSIZE * 7] = dcval;
-
- inptr++; /* advance pointers to next column */
- quantptr++;
- wsptr++;
- continue;
- }
-
- /* Even part: reverse the even part of the forward DCT. */
- /* The rotator is sqrt(2)*c(-6). */
-
- z2 = DEQUANTIZE(inptr[DCTSIZE * 2], quantptr[DCTSIZE * 2]);
- z3 = DEQUANTIZE(inptr[DCTSIZE * 6], quantptr[DCTSIZE * 6]);
-
- z1 = MULTIPLY(z2 + z3, FIX_0_541196100);
- tmp2 = z1 + MULTIPLY(z3, -FIX_1_847759065);
- tmp3 = z1 + MULTIPLY(z2, FIX_0_765366865);
-
- z2 = DEQUANTIZE(inptr[DCTSIZE * 0], quantptr[DCTSIZE * 0]);
- z3 = DEQUANTIZE(inptr[DCTSIZE * 4], quantptr[DCTSIZE * 4]);
-
- tmp0 = LEFT_SHIFT(z2 + z3, CONST_BITS);
- tmp1 = LEFT_SHIFT(z2 - z3, CONST_BITS);
-
- tmp10 = tmp0 + tmp3;
- tmp13 = tmp0 - tmp3;
- tmp11 = tmp1 + tmp2;
- tmp12 = tmp1 - tmp2;
-
- /* Odd part per figure 8; the matrix is unitary and hence its
- * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively.
- */
-
- tmp0 = DEQUANTIZE(inptr[DCTSIZE * 7], quantptr[DCTSIZE * 7]);
- tmp1 = DEQUANTIZE(inptr[DCTSIZE * 5], quantptr[DCTSIZE * 5]);
- tmp2 = DEQUANTIZE(inptr[DCTSIZE * 3], quantptr[DCTSIZE * 3]);
- tmp3 = DEQUANTIZE(inptr[DCTSIZE * 1], quantptr[DCTSIZE * 1]);
-
- z1 = tmp0 + tmp3;
- z2 = tmp1 + tmp2;
- z3 = tmp0 + tmp2;
- z4 = tmp1 + tmp3;
- z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */
-
- tmp0 = MULTIPLY(tmp0, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */
- tmp1 = MULTIPLY(tmp1, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */
- tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */
- tmp3 = MULTIPLY(tmp3, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */
- z1 = MULTIPLY(z1, -FIX_0_899976223); /* sqrt(2) * ( c7-c3) */
- z2 = MULTIPLY(z2, -FIX_2_562915447); /* sqrt(2) * (-c1-c3) */
- z3 = MULTIPLY(z3, -FIX_1_961570560); /* sqrt(2) * (-c3-c5) */
- z4 = MULTIPLY(z4, -FIX_0_390180644); /* sqrt(2) * ( c5-c3) */
-
- z3 += z5;
- z4 += z5;
-
- tmp0 += z1 + z3;
- tmp1 += z2 + z4;
- tmp2 += z2 + z3;
- tmp3 += z1 + z4;
-
- /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
-
- wsptr[DCTSIZE * 0] = (int)DESCALE(tmp10 + tmp3, CONST_BITS - PASS1_BITS);
- wsptr[DCTSIZE * 7] = (int)DESCALE(tmp10 - tmp3, CONST_BITS - PASS1_BITS);
- wsptr[DCTSIZE * 1] = (int)DESCALE(tmp11 + tmp2, CONST_BITS - PASS1_BITS);
- wsptr[DCTSIZE * 6] = (int)DESCALE(tmp11 - tmp2, CONST_BITS - PASS1_BITS);
- wsptr[DCTSIZE * 2] = (int)DESCALE(tmp12 + tmp1, CONST_BITS - PASS1_BITS);
- wsptr[DCTSIZE * 5] = (int)DESCALE(tmp12 - tmp1, CONST_BITS - PASS1_BITS);
- wsptr[DCTSIZE * 3] = (int)DESCALE(tmp13 + tmp0, CONST_BITS - PASS1_BITS);
- wsptr[DCTSIZE * 4] = (int)DESCALE(tmp13 - tmp0, CONST_BITS - PASS1_BITS);
-
- inptr++; /* advance pointers to next column */
- quantptr++;
- wsptr++;
- }
-
- /* Pass 2: process rows from work array, store into output array. */
- /* Note that we must descale the results by a factor of 8 == 2**3, */
- /* and also undo the PASS1_BITS scaling. */
-
- wsptr = workspace;
- for (ctr = 0; ctr < DCTSIZE; ctr++) {
- outptr = output_buf[ctr] + output_col;
- /* Rows of zeroes can be exploited in the same way as we did with columns.
- * However, the column calculation has created many nonzero AC terms, so
- * the simplification applies less often (typically 5% to 10% of the time).
- * On machines with very fast multiplication, it's possible that the
- * test takes more time than it's worth. In that case this section
- * may be commented out.
- */
-
-#ifndef NO_ZERO_ROW_TEST
- if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && wsptr[4] == 0 &&
- wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) {
- /* AC terms all zero */
- JSAMPLE dcval = range_limit[(int)DESCALE((JLONG)wsptr[0],
- PASS1_BITS + 3) & RANGE_MASK];
-
- outptr[0] = dcval;
- outptr[1] = dcval;
- outptr[2] = dcval;
- outptr[3] = dcval;
- outptr[4] = dcval;
- outptr[5] = dcval;
- outptr[6] = dcval;
- outptr[7] = dcval;
-
- wsptr += DCTSIZE; /* advance pointer to next row */
- continue;
- }
-#endif
-
- /* Even part: reverse the even part of the forward DCT. */
- /* The rotator is sqrt(2)*c(-6). */
-
- z2 = (JLONG)wsptr[2];
- z3 = (JLONG)wsptr[6];
-
- z1 = MULTIPLY(z2 + z3, FIX_0_541196100);
- tmp2 = z1 + MULTIPLY(z3, -FIX_1_847759065);
- tmp3 = z1 + MULTIPLY(z2, FIX_0_765366865);
-
- tmp0 = LEFT_SHIFT((JLONG)wsptr[0] + (JLONG)wsptr[4], CONST_BITS);
- tmp1 = LEFT_SHIFT((JLONG)wsptr[0] - (JLONG)wsptr[4], CONST_BITS);
-
- tmp10 = tmp0 + tmp3;
- tmp13 = tmp0 - tmp3;
- tmp11 = tmp1 + tmp2;
- tmp12 = tmp1 - tmp2;
-
- /* Odd part per figure 8; the matrix is unitary and hence its
- * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively.
- */
-
- tmp0 = (JLONG)wsptr[7];
- tmp1 = (JLONG)wsptr[5];
- tmp2 = (JLONG)wsptr[3];
- tmp3 = (JLONG)wsptr[1];
-
- z1 = tmp0 + tmp3;
- z2 = tmp1 + tmp2;
- z3 = tmp0 + tmp2;
- z4 = tmp1 + tmp3;
- z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */
-
- tmp0 = MULTIPLY(tmp0, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */
- tmp1 = MULTIPLY(tmp1, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */
- tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */
- tmp3 = MULTIPLY(tmp3, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */
- z1 = MULTIPLY(z1, -FIX_0_899976223); /* sqrt(2) * ( c7-c3) */
- z2 = MULTIPLY(z2, -FIX_2_562915447); /* sqrt(2) * (-c1-c3) */
- z3 = MULTIPLY(z3, -FIX_1_961570560); /* sqrt(2) * (-c3-c5) */
- z4 = MULTIPLY(z4, -FIX_0_390180644); /* sqrt(2) * ( c5-c3) */
-
- z3 += z5;
- z4 += z5;
-
- tmp0 += z1 + z3;
- tmp1 += z2 + z4;
- tmp2 += z2 + z3;
- tmp3 += z1 + z4;
-
- /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
-
- outptr[0] = range_limit[(int)DESCALE(tmp10 + tmp3,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[7] = range_limit[(int)DESCALE(tmp10 - tmp3,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[1] = range_limit[(int)DESCALE(tmp11 + tmp2,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[6] = range_limit[(int)DESCALE(tmp11 - tmp2,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[2] = range_limit[(int)DESCALE(tmp12 + tmp1,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[5] = range_limit[(int)DESCALE(tmp12 - tmp1,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[3] = range_limit[(int)DESCALE(tmp13 + tmp0,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[4] = range_limit[(int)DESCALE(tmp13 - tmp0,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
-
- wsptr += DCTSIZE; /* advance pointer to next row */
- }
-}
-
-#ifdef IDCT_SCALING_SUPPORTED
-
-
-/*
- * Perform dequantization and inverse DCT on one block of coefficients,
- * producing a reduced-size 7x7 output block.
- *
- * Optimized algorithm with 12 multiplications in the 1-D kernel.
- * cK represents sqrt(2) * cos(K*pi/14).
- */
-
-GLOBAL(void)
-jpeg_idct_7x7(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
- JLONG tmp0, tmp1, tmp2, tmp10, tmp11, tmp12, tmp13;
- JLONG z1, z2, z3;
- JCOEFPTR inptr;
- ISLOW_MULT_TYPE *quantptr;
- int *wsptr;
- JSAMPROW outptr;
- JSAMPLE *range_limit = IDCT_range_limit(cinfo);
- int ctr;
- int workspace[7 * 7]; /* buffers data between passes */
- SHIFT_TEMPS
-
- /* Pass 1: process columns from input, store into work array. */
-
- inptr = coef_block;
- quantptr = (ISLOW_MULT_TYPE *)compptr->dct_table;
- wsptr = workspace;
- for (ctr = 0; ctr < 7; ctr++, inptr++, quantptr++, wsptr++) {
- /* Even part */
-
- tmp13 = DEQUANTIZE(inptr[DCTSIZE * 0], quantptr[DCTSIZE * 0]);
- tmp13 = LEFT_SHIFT(tmp13, CONST_BITS);
- /* Add fudge factor here for final descale. */
- tmp13 += ONE << (CONST_BITS - PASS1_BITS - 1);
-
- z1 = DEQUANTIZE(inptr[DCTSIZE * 2], quantptr[DCTSIZE * 2]);
- z2 = DEQUANTIZE(inptr[DCTSIZE * 4], quantptr[DCTSIZE * 4]);
- z3 = DEQUANTIZE(inptr[DCTSIZE * 6], quantptr[DCTSIZE * 6]);
-
- tmp10 = MULTIPLY(z2 - z3, FIX(0.881747734)); /* c4 */
- tmp12 = MULTIPLY(z1 - z2, FIX(0.314692123)); /* c6 */
- tmp11 = tmp10 + tmp12 + tmp13 - MULTIPLY(z2, FIX(1.841218003)); /* c2+c4-c6 */
- tmp0 = z1 + z3;
- z2 -= tmp0;
- tmp0 = MULTIPLY(tmp0, FIX(1.274162392)) + tmp13; /* c2 */
- tmp10 += tmp0 - MULTIPLY(z3, FIX(0.077722536)); /* c2-c4-c6 */
- tmp12 += tmp0 - MULTIPLY(z1, FIX(2.470602249)); /* c2+c4+c6 */
- tmp13 += MULTIPLY(z2, FIX(1.414213562)); /* c0 */
-
- /* Odd part */
-
- z1 = DEQUANTIZE(inptr[DCTSIZE * 1], quantptr[DCTSIZE * 1]);
- z2 = DEQUANTIZE(inptr[DCTSIZE * 3], quantptr[DCTSIZE * 3]);
- z3 = DEQUANTIZE(inptr[DCTSIZE * 5], quantptr[DCTSIZE * 5]);
-
- tmp1 = MULTIPLY(z1 + z2, FIX(0.935414347)); /* (c3+c1-c5)/2 */
- tmp2 = MULTIPLY(z1 - z2, FIX(0.170262339)); /* (c3+c5-c1)/2 */
- tmp0 = tmp1 - tmp2;
- tmp1 += tmp2;
- tmp2 = MULTIPLY(z2 + z3, -FIX(1.378756276)); /* -c1 */
- tmp1 += tmp2;
- z2 = MULTIPLY(z1 + z3, FIX(0.613604268)); /* c5 */
- tmp0 += z2;
- tmp2 += z2 + MULTIPLY(z3, FIX(1.870828693)); /* c3+c1-c5 */
-
- /* Final output stage */
-
- wsptr[7 * 0] = (int)RIGHT_SHIFT(tmp10 + tmp0, CONST_BITS - PASS1_BITS);
- wsptr[7 * 6] = (int)RIGHT_SHIFT(tmp10 - tmp0, CONST_BITS - PASS1_BITS);
- wsptr[7 * 1] = (int)RIGHT_SHIFT(tmp11 + tmp1, CONST_BITS - PASS1_BITS);
- wsptr[7 * 5] = (int)RIGHT_SHIFT(tmp11 - tmp1, CONST_BITS - PASS1_BITS);
- wsptr[7 * 2] = (int)RIGHT_SHIFT(tmp12 + tmp2, CONST_BITS - PASS1_BITS);
- wsptr[7 * 4] = (int)RIGHT_SHIFT(tmp12 - tmp2, CONST_BITS - PASS1_BITS);
- wsptr[7 * 3] = (int)RIGHT_SHIFT(tmp13, CONST_BITS - PASS1_BITS);
- }
-
- /* Pass 2: process 7 rows from work array, store into output array. */
-
- wsptr = workspace;
- for (ctr = 0; ctr < 7; ctr++) {
- outptr = output_buf[ctr] + output_col;
-
- /* Even part */
-
- /* Add fudge factor here for final descale. */
- tmp13 = (JLONG)wsptr[0] + (ONE << (PASS1_BITS + 2));
- tmp13 = LEFT_SHIFT(tmp13, CONST_BITS);
-
- z1 = (JLONG)wsptr[2];
- z2 = (JLONG)wsptr[4];
- z3 = (JLONG)wsptr[6];
-
- tmp10 = MULTIPLY(z2 - z3, FIX(0.881747734)); /* c4 */
- tmp12 = MULTIPLY(z1 - z2, FIX(0.314692123)); /* c6 */
- tmp11 = tmp10 + tmp12 + tmp13 - MULTIPLY(z2, FIX(1.841218003)); /* c2+c4-c6 */
- tmp0 = z1 + z3;
- z2 -= tmp0;
- tmp0 = MULTIPLY(tmp0, FIX(1.274162392)) + tmp13; /* c2 */
- tmp10 += tmp0 - MULTIPLY(z3, FIX(0.077722536)); /* c2-c4-c6 */
- tmp12 += tmp0 - MULTIPLY(z1, FIX(2.470602249)); /* c2+c4+c6 */
- tmp13 += MULTIPLY(z2, FIX(1.414213562)); /* c0 */
-
- /* Odd part */
-
- z1 = (JLONG)wsptr[1];
- z2 = (JLONG)wsptr[3];
- z3 = (JLONG)wsptr[5];
-
- tmp1 = MULTIPLY(z1 + z2, FIX(0.935414347)); /* (c3+c1-c5)/2 */
- tmp2 = MULTIPLY(z1 - z2, FIX(0.170262339)); /* (c3+c5-c1)/2 */
- tmp0 = tmp1 - tmp2;
- tmp1 += tmp2;
- tmp2 = MULTIPLY(z2 + z3, -FIX(1.378756276)); /* -c1 */
- tmp1 += tmp2;
- z2 = MULTIPLY(z1 + z3, FIX(0.613604268)); /* c5 */
- tmp0 += z2;
- tmp2 += z2 + MULTIPLY(z3, FIX(1.870828693)); /* c3+c1-c5 */
-
- /* Final output stage */
-
- outptr[0] = range_limit[(int)RIGHT_SHIFT(tmp10 + tmp0,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[6] = range_limit[(int)RIGHT_SHIFT(tmp10 - tmp0,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[1] = range_limit[(int)RIGHT_SHIFT(tmp11 + tmp1,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[5] = range_limit[(int)RIGHT_SHIFT(tmp11 - tmp1,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[2] = range_limit[(int)RIGHT_SHIFT(tmp12 + tmp2,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[4] = range_limit[(int)RIGHT_SHIFT(tmp12 - tmp2,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[3] = range_limit[(int)RIGHT_SHIFT(tmp13,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
-
- wsptr += 7; /* advance pointer to next row */
- }
-}
-
-
-/*
- * Perform dequantization and inverse DCT on one block of coefficients,
- * producing a reduced-size 6x6 output block.
- *
- * Optimized algorithm with 3 multiplications in the 1-D kernel.
- * cK represents sqrt(2) * cos(K*pi/12).
- */
-
-GLOBAL(void)
-jpeg_idct_6x6(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
- JLONG tmp0, tmp1, tmp2, tmp10, tmp11, tmp12;
- JLONG z1, z2, z3;
- JCOEFPTR inptr;
- ISLOW_MULT_TYPE *quantptr;
- int *wsptr;
- JSAMPROW outptr;
- JSAMPLE *range_limit = IDCT_range_limit(cinfo);
- int ctr;
- int workspace[6 * 6]; /* buffers data between passes */
- SHIFT_TEMPS
-
- /* Pass 1: process columns from input, store into work array. */
-
- inptr = coef_block;
- quantptr = (ISLOW_MULT_TYPE *)compptr->dct_table;
- wsptr = workspace;
- for (ctr = 0; ctr < 6; ctr++, inptr++, quantptr++, wsptr++) {
- /* Even part */
-
- tmp0 = DEQUANTIZE(inptr[DCTSIZE * 0], quantptr[DCTSIZE * 0]);
- tmp0 = LEFT_SHIFT(tmp0, CONST_BITS);
- /* Add fudge factor here for final descale. */
- tmp0 += ONE << (CONST_BITS - PASS1_BITS - 1);
- tmp2 = DEQUANTIZE(inptr[DCTSIZE * 4], quantptr[DCTSIZE * 4]);
- tmp10 = MULTIPLY(tmp2, FIX(0.707106781)); /* c4 */
- tmp1 = tmp0 + tmp10;
- tmp11 = RIGHT_SHIFT(tmp0 - tmp10 - tmp10, CONST_BITS - PASS1_BITS);
- tmp10 = DEQUANTIZE(inptr[DCTSIZE * 2], quantptr[DCTSIZE * 2]);
- tmp0 = MULTIPLY(tmp10, FIX(1.224744871)); /* c2 */
- tmp10 = tmp1 + tmp0;
- tmp12 = tmp1 - tmp0;
-
- /* Odd part */
-
- z1 = DEQUANTIZE(inptr[DCTSIZE * 1], quantptr[DCTSIZE * 1]);
- z2 = DEQUANTIZE(inptr[DCTSIZE * 3], quantptr[DCTSIZE * 3]);
- z3 = DEQUANTIZE(inptr[DCTSIZE * 5], quantptr[DCTSIZE * 5]);
- tmp1 = MULTIPLY(z1 + z3, FIX(0.366025404)); /* c5 */
- tmp0 = tmp1 + LEFT_SHIFT(z1 + z2, CONST_BITS);
- tmp2 = tmp1 + LEFT_SHIFT(z3 - z2, CONST_BITS);
- tmp1 = LEFT_SHIFT(z1 - z2 - z3, PASS1_BITS);
-
- /* Final output stage */
-
- wsptr[6 * 0] = (int)RIGHT_SHIFT(tmp10 + tmp0, CONST_BITS - PASS1_BITS);
- wsptr[6 * 5] = (int)RIGHT_SHIFT(tmp10 - tmp0, CONST_BITS - PASS1_BITS);
- wsptr[6 * 1] = (int)(tmp11 + tmp1);
- wsptr[6 * 4] = (int)(tmp11 - tmp1);
- wsptr[6 * 2] = (int)RIGHT_SHIFT(tmp12 + tmp2, CONST_BITS - PASS1_BITS);
- wsptr[6 * 3] = (int)RIGHT_SHIFT(tmp12 - tmp2, CONST_BITS - PASS1_BITS);
- }
-
- /* Pass 2: process 6 rows from work array, store into output array. */
-
- wsptr = workspace;
- for (ctr = 0; ctr < 6; ctr++) {
- outptr = output_buf[ctr] + output_col;
-
- /* Even part */
-
- /* Add fudge factor here for final descale. */
- tmp0 = (JLONG)wsptr[0] + (ONE << (PASS1_BITS + 2));
- tmp0 = LEFT_SHIFT(tmp0, CONST_BITS);
- tmp2 = (JLONG)wsptr[4];
- tmp10 = MULTIPLY(tmp2, FIX(0.707106781)); /* c4 */
- tmp1 = tmp0 + tmp10;
- tmp11 = tmp0 - tmp10 - tmp10;
- tmp10 = (JLONG)wsptr[2];
- tmp0 = MULTIPLY(tmp10, FIX(1.224744871)); /* c2 */
- tmp10 = tmp1 + tmp0;
- tmp12 = tmp1 - tmp0;
-
- /* Odd part */
-
- z1 = (JLONG)wsptr[1];
- z2 = (JLONG)wsptr[3];
- z3 = (JLONG)wsptr[5];
- tmp1 = MULTIPLY(z1 + z3, FIX(0.366025404)); /* c5 */
- tmp0 = tmp1 + LEFT_SHIFT(z1 + z2, CONST_BITS);
- tmp2 = tmp1 + LEFT_SHIFT(z3 - z2, CONST_BITS);
- tmp1 = LEFT_SHIFT(z1 - z2 - z3, CONST_BITS);
-
- /* Final output stage */
-
- outptr[0] = range_limit[(int)RIGHT_SHIFT(tmp10 + tmp0,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[5] = range_limit[(int)RIGHT_SHIFT(tmp10 - tmp0,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[1] = range_limit[(int)RIGHT_SHIFT(tmp11 + tmp1,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[4] = range_limit[(int)RIGHT_SHIFT(tmp11 - tmp1,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[2] = range_limit[(int)RIGHT_SHIFT(tmp12 + tmp2,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[3] = range_limit[(int)RIGHT_SHIFT(tmp12 - tmp2,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
-
- wsptr += 6; /* advance pointer to next row */
- }
-}
-
-
-/*
- * Perform dequantization and inverse DCT on one block of coefficients,
- * producing a reduced-size 5x5 output block.
- *
- * Optimized algorithm with 5 multiplications in the 1-D kernel.
- * cK represents sqrt(2) * cos(K*pi/10).
- */
-
-GLOBAL(void)
-jpeg_idct_5x5(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
- JLONG tmp0, tmp1, tmp10, tmp11, tmp12;
- JLONG z1, z2, z3;
- JCOEFPTR inptr;
- ISLOW_MULT_TYPE *quantptr;
- int *wsptr;
- JSAMPROW outptr;
- JSAMPLE *range_limit = IDCT_range_limit(cinfo);
- int ctr;
- int workspace[5 * 5]; /* buffers data between passes */
- SHIFT_TEMPS
-
- /* Pass 1: process columns from input, store into work array. */
-
- inptr = coef_block;
- quantptr = (ISLOW_MULT_TYPE *)compptr->dct_table;
- wsptr = workspace;
- for (ctr = 0; ctr < 5; ctr++, inptr++, quantptr++, wsptr++) {
- /* Even part */
-
- tmp12 = DEQUANTIZE(inptr[DCTSIZE * 0], quantptr[DCTSIZE * 0]);
- tmp12 = LEFT_SHIFT(tmp12, CONST_BITS);
- /* Add fudge factor here for final descale. */
- tmp12 += ONE << (CONST_BITS - PASS1_BITS - 1);
- tmp0 = DEQUANTIZE(inptr[DCTSIZE * 2], quantptr[DCTSIZE * 2]);
- tmp1 = DEQUANTIZE(inptr[DCTSIZE * 4], quantptr[DCTSIZE * 4]);
- z1 = MULTIPLY(tmp0 + tmp1, FIX(0.790569415)); /* (c2+c4)/2 */
- z2 = MULTIPLY(tmp0 - tmp1, FIX(0.353553391)); /* (c2-c4)/2 */
- z3 = tmp12 + z2;
- tmp10 = z3 + z1;
- tmp11 = z3 - z1;
- tmp12 -= LEFT_SHIFT(z2, 2);
-
- /* Odd part */
-
- z2 = DEQUANTIZE(inptr[DCTSIZE * 1], quantptr[DCTSIZE * 1]);
- z3 = DEQUANTIZE(inptr[DCTSIZE * 3], quantptr[DCTSIZE * 3]);
-
- z1 = MULTIPLY(z2 + z3, FIX(0.831253876)); /* c3 */
- tmp0 = z1 + MULTIPLY(z2, FIX(0.513743148)); /* c1-c3 */
- tmp1 = z1 - MULTIPLY(z3, FIX(2.176250899)); /* c1+c3 */
-
- /* Final output stage */
-
- wsptr[5 * 0] = (int)RIGHT_SHIFT(tmp10 + tmp0, CONST_BITS - PASS1_BITS);
- wsptr[5 * 4] = (int)RIGHT_SHIFT(tmp10 - tmp0, CONST_BITS - PASS1_BITS);
- wsptr[5 * 1] = (int)RIGHT_SHIFT(tmp11 + tmp1, CONST_BITS - PASS1_BITS);
- wsptr[5 * 3] = (int)RIGHT_SHIFT(tmp11 - tmp1, CONST_BITS - PASS1_BITS);
- wsptr[5 * 2] = (int)RIGHT_SHIFT(tmp12, CONST_BITS - PASS1_BITS);
- }
-
- /* Pass 2: process 5 rows from work array, store into output array. */
-
- wsptr = workspace;
- for (ctr = 0; ctr < 5; ctr++) {
- outptr = output_buf[ctr] + output_col;
-
- /* Even part */
-
- /* Add fudge factor here for final descale. */
- tmp12 = (JLONG)wsptr[0] + (ONE << (PASS1_BITS + 2));
- tmp12 = LEFT_SHIFT(tmp12, CONST_BITS);
- tmp0 = (JLONG)wsptr[2];
- tmp1 = (JLONG)wsptr[4];
- z1 = MULTIPLY(tmp0 + tmp1, FIX(0.790569415)); /* (c2+c4)/2 */
- z2 = MULTIPLY(tmp0 - tmp1, FIX(0.353553391)); /* (c2-c4)/2 */
- z3 = tmp12 + z2;
- tmp10 = z3 + z1;
- tmp11 = z3 - z1;
- tmp12 -= LEFT_SHIFT(z2, 2);
-
- /* Odd part */
-
- z2 = (JLONG)wsptr[1];
- z3 = (JLONG)wsptr[3];
-
- z1 = MULTIPLY(z2 + z3, FIX(0.831253876)); /* c3 */
- tmp0 = z1 + MULTIPLY(z2, FIX(0.513743148)); /* c1-c3 */
- tmp1 = z1 - MULTIPLY(z3, FIX(2.176250899)); /* c1+c3 */
-
- /* Final output stage */
-
- outptr[0] = range_limit[(int)RIGHT_SHIFT(tmp10 + tmp0,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[4] = range_limit[(int)RIGHT_SHIFT(tmp10 - tmp0,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[1] = range_limit[(int)RIGHT_SHIFT(tmp11 + tmp1,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[3] = range_limit[(int)RIGHT_SHIFT(tmp11 - tmp1,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[2] = range_limit[(int)RIGHT_SHIFT(tmp12,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
-
- wsptr += 5; /* advance pointer to next row */
- }
-}
-
-
-/*
- * Perform dequantization and inverse DCT on one block of coefficients,
- * producing a reduced-size 3x3 output block.
- *
- * Optimized algorithm with 2 multiplications in the 1-D kernel.
- * cK represents sqrt(2) * cos(K*pi/6).
- */
-
-GLOBAL(void)
-jpeg_idct_3x3(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
- JLONG tmp0, tmp2, tmp10, tmp12;
- JCOEFPTR inptr;
- ISLOW_MULT_TYPE *quantptr;
- int *wsptr;
- JSAMPROW outptr;
- JSAMPLE *range_limit = IDCT_range_limit(cinfo);
- int ctr;
- int workspace[3 * 3]; /* buffers data between passes */
- SHIFT_TEMPS
-
- /* Pass 1: process columns from input, store into work array. */
-
- inptr = coef_block;
- quantptr = (ISLOW_MULT_TYPE *)compptr->dct_table;
- wsptr = workspace;
- for (ctr = 0; ctr < 3; ctr++, inptr++, quantptr++, wsptr++) {
- /* Even part */
-
- tmp0 = DEQUANTIZE(inptr[DCTSIZE * 0], quantptr[DCTSIZE * 0]);
- tmp0 = LEFT_SHIFT(tmp0, CONST_BITS);
- /* Add fudge factor here for final descale. */
- tmp0 += ONE << (CONST_BITS - PASS1_BITS - 1);
- tmp2 = DEQUANTIZE(inptr[DCTSIZE * 2], quantptr[DCTSIZE * 2]);
- tmp12 = MULTIPLY(tmp2, FIX(0.707106781)); /* c2 */
- tmp10 = tmp0 + tmp12;
- tmp2 = tmp0 - tmp12 - tmp12;
-
- /* Odd part */
-
- tmp12 = DEQUANTIZE(inptr[DCTSIZE * 1], quantptr[DCTSIZE * 1]);
- tmp0 = MULTIPLY(tmp12, FIX(1.224744871)); /* c1 */
-
- /* Final output stage */
-
- wsptr[3 * 0] = (int)RIGHT_SHIFT(tmp10 + tmp0, CONST_BITS - PASS1_BITS);
- wsptr[3 * 2] = (int)RIGHT_SHIFT(tmp10 - tmp0, CONST_BITS - PASS1_BITS);
- wsptr[3 * 1] = (int)RIGHT_SHIFT(tmp2, CONST_BITS - PASS1_BITS);
- }
-
- /* Pass 2: process 3 rows from work array, store into output array. */
-
- wsptr = workspace;
- for (ctr = 0; ctr < 3; ctr++) {
- outptr = output_buf[ctr] + output_col;
-
- /* Even part */
-
- /* Add fudge factor here for final descale. */
- tmp0 = (JLONG)wsptr[0] + (ONE << (PASS1_BITS + 2));
- tmp0 = LEFT_SHIFT(tmp0, CONST_BITS);
- tmp2 = (JLONG)wsptr[2];
- tmp12 = MULTIPLY(tmp2, FIX(0.707106781)); /* c2 */
- tmp10 = tmp0 + tmp12;
- tmp2 = tmp0 - tmp12 - tmp12;
-
- /* Odd part */
-
- tmp12 = (JLONG)wsptr[1];
- tmp0 = MULTIPLY(tmp12, FIX(1.224744871)); /* c1 */
-
- /* Final output stage */
-
- outptr[0] = range_limit[(int)RIGHT_SHIFT(tmp10 + tmp0,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[2] = range_limit[(int)RIGHT_SHIFT(tmp10 - tmp0,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[1] = range_limit[(int)RIGHT_SHIFT(tmp2,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
-
- wsptr += 3; /* advance pointer to next row */
- }
-}
-
-
-/*
- * Perform dequantization and inverse DCT on one block of coefficients,
- * producing a 9x9 output block.
- *
- * Optimized algorithm with 10 multiplications in the 1-D kernel.
- * cK represents sqrt(2) * cos(K*pi/18).
- */
-
-GLOBAL(void)
-jpeg_idct_9x9(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
- JLONG tmp0, tmp1, tmp2, tmp3, tmp10, tmp11, tmp12, tmp13, tmp14;
- JLONG z1, z2, z3, z4;
- JCOEFPTR inptr;
- ISLOW_MULT_TYPE *quantptr;
- int *wsptr;
- JSAMPROW outptr;
- JSAMPLE *range_limit = IDCT_range_limit(cinfo);
- int ctr;
- int workspace[8 * 9]; /* buffers data between passes */
- SHIFT_TEMPS
-
- /* Pass 1: process columns from input, store into work array. */
-
- inptr = coef_block;
- quantptr = (ISLOW_MULT_TYPE *)compptr->dct_table;
- wsptr = workspace;
- for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) {
- /* Even part */
-
- tmp0 = DEQUANTIZE(inptr[DCTSIZE * 0], quantptr[DCTSIZE * 0]);
- tmp0 = LEFT_SHIFT(tmp0, CONST_BITS);
- /* Add fudge factor here for final descale. */
- tmp0 += ONE << (CONST_BITS - PASS1_BITS - 1);
-
- z1 = DEQUANTIZE(inptr[DCTSIZE * 2], quantptr[DCTSIZE * 2]);
- z2 = DEQUANTIZE(inptr[DCTSIZE * 4], quantptr[DCTSIZE * 4]);
- z3 = DEQUANTIZE(inptr[DCTSIZE * 6], quantptr[DCTSIZE * 6]);
-
- tmp3 = MULTIPLY(z3, FIX(0.707106781)); /* c6 */
- tmp1 = tmp0 + tmp3;
- tmp2 = tmp0 - tmp3 - tmp3;
-
- tmp0 = MULTIPLY(z1 - z2, FIX(0.707106781)); /* c6 */
- tmp11 = tmp2 + tmp0;
- tmp14 = tmp2 - tmp0 - tmp0;
-
- tmp0 = MULTIPLY(z1 + z2, FIX(1.328926049)); /* c2 */
- tmp2 = MULTIPLY(z1, FIX(1.083350441)); /* c4 */
- tmp3 = MULTIPLY(z2, FIX(0.245575608)); /* c8 */
-
- tmp10 = tmp1 + tmp0 - tmp3;
- tmp12 = tmp1 - tmp0 + tmp2;
- tmp13 = tmp1 - tmp2 + tmp3;
-
- /* Odd part */
-
- z1 = DEQUANTIZE(inptr[DCTSIZE * 1], quantptr[DCTSIZE * 1]);
- z2 = DEQUANTIZE(inptr[DCTSIZE * 3], quantptr[DCTSIZE * 3]);
- z3 = DEQUANTIZE(inptr[DCTSIZE * 5], quantptr[DCTSIZE * 5]);
- z4 = DEQUANTIZE(inptr[DCTSIZE * 7], quantptr[DCTSIZE * 7]);
-
- z2 = MULTIPLY(z2, -FIX(1.224744871)); /* -c3 */
-
- tmp2 = MULTIPLY(z1 + z3, FIX(0.909038955)); /* c5 */
- tmp3 = MULTIPLY(z1 + z4, FIX(0.483689525)); /* c7 */
- tmp0 = tmp2 + tmp3 - z2;
- tmp1 = MULTIPLY(z3 - z4, FIX(1.392728481)); /* c1 */
- tmp2 += z2 - tmp1;
- tmp3 += z2 + tmp1;
- tmp1 = MULTIPLY(z1 - z3 - z4, FIX(1.224744871)); /* c3 */
-
- /* Final output stage */
-
- wsptr[8 * 0] = (int)RIGHT_SHIFT(tmp10 + tmp0, CONST_BITS - PASS1_BITS);
- wsptr[8 * 8] = (int)RIGHT_SHIFT(tmp10 - tmp0, CONST_BITS - PASS1_BITS);
- wsptr[8 * 1] = (int)RIGHT_SHIFT(tmp11 + tmp1, CONST_BITS - PASS1_BITS);
- wsptr[8 * 7] = (int)RIGHT_SHIFT(tmp11 - tmp1, CONST_BITS - PASS1_BITS);
- wsptr[8 * 2] = (int)RIGHT_SHIFT(tmp12 + tmp2, CONST_BITS - PASS1_BITS);
- wsptr[8 * 6] = (int)RIGHT_SHIFT(tmp12 - tmp2, CONST_BITS - PASS1_BITS);
- wsptr[8 * 3] = (int)RIGHT_SHIFT(tmp13 + tmp3, CONST_BITS - PASS1_BITS);
- wsptr[8 * 5] = (int)RIGHT_SHIFT(tmp13 - tmp3, CONST_BITS - PASS1_BITS);
- wsptr[8 * 4] = (int)RIGHT_SHIFT(tmp14, CONST_BITS - PASS1_BITS);
- }
-
- /* Pass 2: process 9 rows from work array, store into output array. */
-
- wsptr = workspace;
- for (ctr = 0; ctr < 9; ctr++) {
- outptr = output_buf[ctr] + output_col;
-
- /* Even part */
-
- /* Add fudge factor here for final descale. */
- tmp0 = (JLONG)wsptr[0] + (ONE << (PASS1_BITS + 2));
- tmp0 = LEFT_SHIFT(tmp0, CONST_BITS);
-
- z1 = (JLONG)wsptr[2];
- z2 = (JLONG)wsptr[4];
- z3 = (JLONG)wsptr[6];
-
- tmp3 = MULTIPLY(z3, FIX(0.707106781)); /* c6 */
- tmp1 = tmp0 + tmp3;
- tmp2 = tmp0 - tmp3 - tmp3;
-
- tmp0 = MULTIPLY(z1 - z2, FIX(0.707106781)); /* c6 */
- tmp11 = tmp2 + tmp0;
- tmp14 = tmp2 - tmp0 - tmp0;
-
- tmp0 = MULTIPLY(z1 + z2, FIX(1.328926049)); /* c2 */
- tmp2 = MULTIPLY(z1, FIX(1.083350441)); /* c4 */
- tmp3 = MULTIPLY(z2, FIX(0.245575608)); /* c8 */
-
- tmp10 = tmp1 + tmp0 - tmp3;
- tmp12 = tmp1 - tmp0 + tmp2;
- tmp13 = tmp1 - tmp2 + tmp3;
-
- /* Odd part */
-
- z1 = (JLONG)wsptr[1];
- z2 = (JLONG)wsptr[3];
- z3 = (JLONG)wsptr[5];
- z4 = (JLONG)wsptr[7];
-
- z2 = MULTIPLY(z2, -FIX(1.224744871)); /* -c3 */
-
- tmp2 = MULTIPLY(z1 + z3, FIX(0.909038955)); /* c5 */
- tmp3 = MULTIPLY(z1 + z4, FIX(0.483689525)); /* c7 */
- tmp0 = tmp2 + tmp3 - z2;
- tmp1 = MULTIPLY(z3 - z4, FIX(1.392728481)); /* c1 */
- tmp2 += z2 - tmp1;
- tmp3 += z2 + tmp1;
- tmp1 = MULTIPLY(z1 - z3 - z4, FIX(1.224744871)); /* c3 */
-
- /* Final output stage */
-
- outptr[0] = range_limit[(int)RIGHT_SHIFT(tmp10 + tmp0,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[8] = range_limit[(int)RIGHT_SHIFT(tmp10 - tmp0,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[1] = range_limit[(int)RIGHT_SHIFT(tmp11 + tmp1,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[7] = range_limit[(int)RIGHT_SHIFT(tmp11 - tmp1,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[2] = range_limit[(int)RIGHT_SHIFT(tmp12 + tmp2,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[6] = range_limit[(int)RIGHT_SHIFT(tmp12 - tmp2,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[3] = range_limit[(int)RIGHT_SHIFT(tmp13 + tmp3,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[5] = range_limit[(int)RIGHT_SHIFT(tmp13 - tmp3,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[4] = range_limit[(int)RIGHT_SHIFT(tmp14,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
-
- wsptr += 8; /* advance pointer to next row */
- }
-}
-
-
-/*
- * Perform dequantization and inverse DCT on one block of coefficients,
- * producing a 10x10 output block.
- *
- * Optimized algorithm with 12 multiplications in the 1-D kernel.
- * cK represents sqrt(2) * cos(K*pi/20).
- */
-
-GLOBAL(void)
-jpeg_idct_10x10(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
- JLONG tmp10, tmp11, tmp12, tmp13, tmp14;
- JLONG tmp20, tmp21, tmp22, tmp23, tmp24;
- JLONG z1, z2, z3, z4, z5;
- JCOEFPTR inptr;
- ISLOW_MULT_TYPE *quantptr;
- int *wsptr;
- JSAMPROW outptr;
- JSAMPLE *range_limit = IDCT_range_limit(cinfo);
- int ctr;
- int workspace[8 * 10]; /* buffers data between passes */
- SHIFT_TEMPS
-
- /* Pass 1: process columns from input, store into work array. */
-
- inptr = coef_block;
- quantptr = (ISLOW_MULT_TYPE *)compptr->dct_table;
- wsptr = workspace;
- for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) {
- /* Even part */
-
- z3 = DEQUANTIZE(inptr[DCTSIZE * 0], quantptr[DCTSIZE * 0]);
- z3 = LEFT_SHIFT(z3, CONST_BITS);
- /* Add fudge factor here for final descale. */
- z3 += ONE << (CONST_BITS - PASS1_BITS - 1);
- z4 = DEQUANTIZE(inptr[DCTSIZE * 4], quantptr[DCTSIZE * 4]);
- z1 = MULTIPLY(z4, FIX(1.144122806)); /* c4 */
- z2 = MULTIPLY(z4, FIX(0.437016024)); /* c8 */
- tmp10 = z3 + z1;
- tmp11 = z3 - z2;
-
- tmp22 = RIGHT_SHIFT(z3 - LEFT_SHIFT(z1 - z2, 1),
- CONST_BITS - PASS1_BITS); /* c0 = (c4-c8)*2 */
-
- z2 = DEQUANTIZE(inptr[DCTSIZE * 2], quantptr[DCTSIZE * 2]);
- z3 = DEQUANTIZE(inptr[DCTSIZE * 6], quantptr[DCTSIZE * 6]);
-
- z1 = MULTIPLY(z2 + z3, FIX(0.831253876)); /* c6 */
- tmp12 = z1 + MULTIPLY(z2, FIX(0.513743148)); /* c2-c6 */
- tmp13 = z1 - MULTIPLY(z3, FIX(2.176250899)); /* c2+c6 */
-
- tmp20 = tmp10 + tmp12;
- tmp24 = tmp10 - tmp12;
- tmp21 = tmp11 + tmp13;
- tmp23 = tmp11 - tmp13;
-
- /* Odd part */
-
- z1 = DEQUANTIZE(inptr[DCTSIZE * 1], quantptr[DCTSIZE * 1]);
- z2 = DEQUANTIZE(inptr[DCTSIZE * 3], quantptr[DCTSIZE * 3]);
- z3 = DEQUANTIZE(inptr[DCTSIZE * 5], quantptr[DCTSIZE * 5]);
- z4 = DEQUANTIZE(inptr[DCTSIZE * 7], quantptr[DCTSIZE * 7]);
-
- tmp11 = z2 + z4;
- tmp13 = z2 - z4;
-
- tmp12 = MULTIPLY(tmp13, FIX(0.309016994)); /* (c3-c7)/2 */
- z5 = LEFT_SHIFT(z3, CONST_BITS);
-
- z2 = MULTIPLY(tmp11, FIX(0.951056516)); /* (c3+c7)/2 */
- z4 = z5 + tmp12;
-
- tmp10 = MULTIPLY(z1, FIX(1.396802247)) + z2 + z4; /* c1 */
- tmp14 = MULTIPLY(z1, FIX(0.221231742)) - z2 + z4; /* c9 */
-
- z2 = MULTIPLY(tmp11, FIX(0.587785252)); /* (c1-c9)/2 */
- z4 = z5 - tmp12 - LEFT_SHIFT(tmp13, CONST_BITS - 1);
-
- tmp12 = LEFT_SHIFT(z1 - tmp13 - z3, PASS1_BITS);
-
- tmp11 = MULTIPLY(z1, FIX(1.260073511)) - z2 - z4; /* c3 */
- tmp13 = MULTIPLY(z1, FIX(0.642039522)) - z2 + z4; /* c7 */
-
- /* Final output stage */
-
- wsptr[8 * 0] = (int)RIGHT_SHIFT(tmp20 + tmp10, CONST_BITS - PASS1_BITS);
- wsptr[8 * 9] = (int)RIGHT_SHIFT(tmp20 - tmp10, CONST_BITS - PASS1_BITS);
- wsptr[8 * 1] = (int)RIGHT_SHIFT(tmp21 + tmp11, CONST_BITS - PASS1_BITS);
- wsptr[8 * 8] = (int)RIGHT_SHIFT(tmp21 - tmp11, CONST_BITS - PASS1_BITS);
- wsptr[8 * 2] = (int)(tmp22 + tmp12);
- wsptr[8 * 7] = (int)(tmp22 - tmp12);
- wsptr[8 * 3] = (int)RIGHT_SHIFT(tmp23 + tmp13, CONST_BITS - PASS1_BITS);
- wsptr[8 * 6] = (int)RIGHT_SHIFT(tmp23 - tmp13, CONST_BITS - PASS1_BITS);
- wsptr[8 * 4] = (int)RIGHT_SHIFT(tmp24 + tmp14, CONST_BITS - PASS1_BITS);
- wsptr[8 * 5] = (int)RIGHT_SHIFT(tmp24 - tmp14, CONST_BITS - PASS1_BITS);
- }
-
- /* Pass 2: process 10 rows from work array, store into output array. */
-
- wsptr = workspace;
- for (ctr = 0; ctr < 10; ctr++) {
- outptr = output_buf[ctr] + output_col;
-
- /* Even part */
-
- /* Add fudge factor here for final descale. */
- z3 = (JLONG)wsptr[0] + (ONE << (PASS1_BITS + 2));
- z3 = LEFT_SHIFT(z3, CONST_BITS);
- z4 = (JLONG)wsptr[4];
- z1 = MULTIPLY(z4, FIX(1.144122806)); /* c4 */
- z2 = MULTIPLY(z4, FIX(0.437016024)); /* c8 */
- tmp10 = z3 + z1;
- tmp11 = z3 - z2;
-
- tmp22 = z3 - LEFT_SHIFT(z1 - z2, 1); /* c0 = (c4-c8)*2 */
-
- z2 = (JLONG)wsptr[2];
- z3 = (JLONG)wsptr[6];
-
- z1 = MULTIPLY(z2 + z3, FIX(0.831253876)); /* c6 */
- tmp12 = z1 + MULTIPLY(z2, FIX(0.513743148)); /* c2-c6 */
- tmp13 = z1 - MULTIPLY(z3, FIX(2.176250899)); /* c2+c6 */
-
- tmp20 = tmp10 + tmp12;
- tmp24 = tmp10 - tmp12;
- tmp21 = tmp11 + tmp13;
- tmp23 = tmp11 - tmp13;
-
- /* Odd part */
-
- z1 = (JLONG)wsptr[1];
- z2 = (JLONG)wsptr[3];
- z3 = (JLONG)wsptr[5];
- z3 = LEFT_SHIFT(z3, CONST_BITS);
- z4 = (JLONG)wsptr[7];
-
- tmp11 = z2 + z4;
- tmp13 = z2 - z4;
-
- tmp12 = MULTIPLY(tmp13, FIX(0.309016994)); /* (c3-c7)/2 */
-
- z2 = MULTIPLY(tmp11, FIX(0.951056516)); /* (c3+c7)/2 */
- z4 = z3 + tmp12;
-
- tmp10 = MULTIPLY(z1, FIX(1.396802247)) + z2 + z4; /* c1 */
- tmp14 = MULTIPLY(z1, FIX(0.221231742)) - z2 + z4; /* c9 */
-
- z2 = MULTIPLY(tmp11, FIX(0.587785252)); /* (c1-c9)/2 */
- z4 = z3 - tmp12 - LEFT_SHIFT(tmp13, CONST_BITS - 1);
-
- tmp12 = LEFT_SHIFT(z1 - tmp13, CONST_BITS) - z3;
-
- tmp11 = MULTIPLY(z1, FIX(1.260073511)) - z2 - z4; /* c3 */
- tmp13 = MULTIPLY(z1, FIX(0.642039522)) - z2 + z4; /* c7 */
-
- /* Final output stage */
-
- outptr[0] = range_limit[(int)RIGHT_SHIFT(tmp20 + tmp10,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[9] = range_limit[(int)RIGHT_SHIFT(tmp20 - tmp10,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[1] = range_limit[(int)RIGHT_SHIFT(tmp21 + tmp11,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[8] = range_limit[(int)RIGHT_SHIFT(tmp21 - tmp11,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[2] = range_limit[(int)RIGHT_SHIFT(tmp22 + tmp12,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[7] = range_limit[(int)RIGHT_SHIFT(tmp22 - tmp12,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[3] = range_limit[(int)RIGHT_SHIFT(tmp23 + tmp13,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[6] = range_limit[(int)RIGHT_SHIFT(tmp23 - tmp13,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[4] = range_limit[(int)RIGHT_SHIFT(tmp24 + tmp14,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[5] = range_limit[(int)RIGHT_SHIFT(tmp24 - tmp14,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
-
- wsptr += 8; /* advance pointer to next row */
- }
-}
-
-
-/*
- * Perform dequantization and inverse DCT on one block of coefficients,
- * producing an 11x11 output block.
- *
- * Optimized algorithm with 24 multiplications in the 1-D kernel.
- * cK represents sqrt(2) * cos(K*pi/22).
- */
-
-GLOBAL(void)
-jpeg_idct_11x11(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
- JLONG tmp10, tmp11, tmp12, tmp13, tmp14;
- JLONG tmp20, tmp21, tmp22, tmp23, tmp24, tmp25;
- JLONG z1, z2, z3, z4;
- JCOEFPTR inptr;
- ISLOW_MULT_TYPE *quantptr;
- int *wsptr;
- JSAMPROW outptr;
- JSAMPLE *range_limit = IDCT_range_limit(cinfo);
- int ctr;
- int workspace[8 * 11]; /* buffers data between passes */
- SHIFT_TEMPS
-
- /* Pass 1: process columns from input, store into work array. */
-
- inptr = coef_block;
- quantptr = (ISLOW_MULT_TYPE *)compptr->dct_table;
- wsptr = workspace;
- for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) {
- /* Even part */
-
- tmp10 = DEQUANTIZE(inptr[DCTSIZE * 0], quantptr[DCTSIZE * 0]);
- tmp10 = LEFT_SHIFT(tmp10, CONST_BITS);
- /* Add fudge factor here for final descale. */
- tmp10 += ONE << (CONST_BITS - PASS1_BITS - 1);
-
- z1 = DEQUANTIZE(inptr[DCTSIZE * 2], quantptr[DCTSIZE * 2]);
- z2 = DEQUANTIZE(inptr[DCTSIZE * 4], quantptr[DCTSIZE * 4]);
- z3 = DEQUANTIZE(inptr[DCTSIZE * 6], quantptr[DCTSIZE * 6]);
-
- tmp20 = MULTIPLY(z2 - z3, FIX(2.546640132)); /* c2+c4 */
- tmp23 = MULTIPLY(z2 - z1, FIX(0.430815045)); /* c2-c6 */
- z4 = z1 + z3;
- tmp24 = MULTIPLY(z4, -FIX(1.155664402)); /* -(c2-c10) */
- z4 -= z2;
- tmp25 = tmp10 + MULTIPLY(z4, FIX(1.356927976)); /* c2 */
- tmp21 = tmp20 + tmp23 + tmp25 -
- MULTIPLY(z2, FIX(1.821790775)); /* c2+c4+c10-c6 */
- tmp20 += tmp25 + MULTIPLY(z3, FIX(2.115825087)); /* c4+c6 */
- tmp23 += tmp25 - MULTIPLY(z1, FIX(1.513598477)); /* c6+c8 */
- tmp24 += tmp25;
- tmp22 = tmp24 - MULTIPLY(z3, FIX(0.788749120)); /* c8+c10 */
- tmp24 += MULTIPLY(z2, FIX(1.944413522)) - /* c2+c8 */
- MULTIPLY(z1, FIX(1.390975730)); /* c4+c10 */
- tmp25 = tmp10 - MULTIPLY(z4, FIX(1.414213562)); /* c0 */
-
- /* Odd part */
-
- z1 = DEQUANTIZE(inptr[DCTSIZE * 1], quantptr[DCTSIZE * 1]);
- z2 = DEQUANTIZE(inptr[DCTSIZE * 3], quantptr[DCTSIZE * 3]);
- z3 = DEQUANTIZE(inptr[DCTSIZE * 5], quantptr[DCTSIZE * 5]);
- z4 = DEQUANTIZE(inptr[DCTSIZE * 7], quantptr[DCTSIZE * 7]);
-
- tmp11 = z1 + z2;
- tmp14 = MULTIPLY(tmp11 + z3 + z4, FIX(0.398430003)); /* c9 */
- tmp11 = MULTIPLY(tmp11, FIX(0.887983902)); /* c3-c9 */
- tmp12 = MULTIPLY(z1 + z3, FIX(0.670361295)); /* c5-c9 */
- tmp13 = tmp14 + MULTIPLY(z1 + z4, FIX(0.366151574)); /* c7-c9 */
- tmp10 = tmp11 + tmp12 + tmp13 -
- MULTIPLY(z1, FIX(0.923107866)); /* c7+c5+c3-c1-2*c9 */
- z1 = tmp14 - MULTIPLY(z2 + z3, FIX(1.163011579)); /* c7+c9 */
- tmp11 += z1 + MULTIPLY(z2, FIX(2.073276588)); /* c1+c7+3*c9-c3 */
- tmp12 += z1 - MULTIPLY(z3, FIX(1.192193623)); /* c3+c5-c7-c9 */
- z1 = MULTIPLY(z2 + z4, -FIX(1.798248910)); /* -(c1+c9) */
- tmp11 += z1;
- tmp13 += z1 + MULTIPLY(z4, FIX(2.102458632)); /* c1+c5+c9-c7 */
- tmp14 += MULTIPLY(z2, -FIX(1.467221301)) + /* -(c5+c9) */
- MULTIPLY(z3, FIX(1.001388905)) - /* c1-c9 */
- MULTIPLY(z4, FIX(1.684843907)); /* c3+c9 */
-
- /* Final output stage */
-
- wsptr[8 * 0] = (int)RIGHT_SHIFT(tmp20 + tmp10, CONST_BITS - PASS1_BITS);
- wsptr[8 * 10] = (int)RIGHT_SHIFT(tmp20 - tmp10, CONST_BITS - PASS1_BITS);
- wsptr[8 * 1] = (int)RIGHT_SHIFT(tmp21 + tmp11, CONST_BITS - PASS1_BITS);
- wsptr[8 * 9] = (int)RIGHT_SHIFT(tmp21 - tmp11, CONST_BITS - PASS1_BITS);
- wsptr[8 * 2] = (int)RIGHT_SHIFT(tmp22 + tmp12, CONST_BITS - PASS1_BITS);
- wsptr[8 * 8] = (int)RIGHT_SHIFT(tmp22 - tmp12, CONST_BITS - PASS1_BITS);
- wsptr[8 * 3] = (int)RIGHT_SHIFT(tmp23 + tmp13, CONST_BITS - PASS1_BITS);
- wsptr[8 * 7] = (int)RIGHT_SHIFT(tmp23 - tmp13, CONST_BITS - PASS1_BITS);
- wsptr[8 * 4] = (int)RIGHT_SHIFT(tmp24 + tmp14, CONST_BITS - PASS1_BITS);
- wsptr[8 * 6] = (int)RIGHT_SHIFT(tmp24 - tmp14, CONST_BITS - PASS1_BITS);
- wsptr[8 * 5] = (int)RIGHT_SHIFT(tmp25, CONST_BITS - PASS1_BITS);
- }
-
- /* Pass 2: process 11 rows from work array, store into output array. */
-
- wsptr = workspace;
- for (ctr = 0; ctr < 11; ctr++) {
- outptr = output_buf[ctr] + output_col;
-
- /* Even part */
-
- /* Add fudge factor here for final descale. */
- tmp10 = (JLONG)wsptr[0] + (ONE << (PASS1_BITS + 2));
- tmp10 = LEFT_SHIFT(tmp10, CONST_BITS);
-
- z1 = (JLONG)wsptr[2];
- z2 = (JLONG)wsptr[4];
- z3 = (JLONG)wsptr[6];
-
- tmp20 = MULTIPLY(z2 - z3, FIX(2.546640132)); /* c2+c4 */
- tmp23 = MULTIPLY(z2 - z1, FIX(0.430815045)); /* c2-c6 */
- z4 = z1 + z3;
- tmp24 = MULTIPLY(z4, -FIX(1.155664402)); /* -(c2-c10) */
- z4 -= z2;
- tmp25 = tmp10 + MULTIPLY(z4, FIX(1.356927976)); /* c2 */
- tmp21 = tmp20 + tmp23 + tmp25 -
- MULTIPLY(z2, FIX(1.821790775)); /* c2+c4+c10-c6 */
- tmp20 += tmp25 + MULTIPLY(z3, FIX(2.115825087)); /* c4+c6 */
- tmp23 += tmp25 - MULTIPLY(z1, FIX(1.513598477)); /* c6+c8 */
- tmp24 += tmp25;
- tmp22 = tmp24 - MULTIPLY(z3, FIX(0.788749120)); /* c8+c10 */
- tmp24 += MULTIPLY(z2, FIX(1.944413522)) - /* c2+c8 */
- MULTIPLY(z1, FIX(1.390975730)); /* c4+c10 */
- tmp25 = tmp10 - MULTIPLY(z4, FIX(1.414213562)); /* c0 */
-
- /* Odd part */
-
- z1 = (JLONG)wsptr[1];
- z2 = (JLONG)wsptr[3];
- z3 = (JLONG)wsptr[5];
- z4 = (JLONG)wsptr[7];
-
- tmp11 = z1 + z2;
- tmp14 = MULTIPLY(tmp11 + z3 + z4, FIX(0.398430003)); /* c9 */
- tmp11 = MULTIPLY(tmp11, FIX(0.887983902)); /* c3-c9 */
- tmp12 = MULTIPLY(z1 + z3, FIX(0.670361295)); /* c5-c9 */
- tmp13 = tmp14 + MULTIPLY(z1 + z4, FIX(0.366151574)); /* c7-c9 */
- tmp10 = tmp11 + tmp12 + tmp13 -
- MULTIPLY(z1, FIX(0.923107866)); /* c7+c5+c3-c1-2*c9 */
- z1 = tmp14 - MULTIPLY(z2 + z3, FIX(1.163011579)); /* c7+c9 */
- tmp11 += z1 + MULTIPLY(z2, FIX(2.073276588)); /* c1+c7+3*c9-c3 */
- tmp12 += z1 - MULTIPLY(z3, FIX(1.192193623)); /* c3+c5-c7-c9 */
- z1 = MULTIPLY(z2 + z4, -FIX(1.798248910)); /* -(c1+c9) */
- tmp11 += z1;
- tmp13 += z1 + MULTIPLY(z4, FIX(2.102458632)); /* c1+c5+c9-c7 */
- tmp14 += MULTIPLY(z2, -FIX(1.467221301)) + /* -(c5+c9) */
- MULTIPLY(z3, FIX(1.001388905)) - /* c1-c9 */
- MULTIPLY(z4, FIX(1.684843907)); /* c3+c9 */
-
- /* Final output stage */
-
- outptr[0] = range_limit[(int)RIGHT_SHIFT(tmp20 + tmp10,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[10] = range_limit[(int)RIGHT_SHIFT(tmp20 - tmp10,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[1] = range_limit[(int)RIGHT_SHIFT(tmp21 + tmp11,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[9] = range_limit[(int)RIGHT_SHIFT(tmp21 - tmp11,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[2] = range_limit[(int)RIGHT_SHIFT(tmp22 + tmp12,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[8] = range_limit[(int)RIGHT_SHIFT(tmp22 - tmp12,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[3] = range_limit[(int)RIGHT_SHIFT(tmp23 + tmp13,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[7] = range_limit[(int)RIGHT_SHIFT(tmp23 - tmp13,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[4] = range_limit[(int)RIGHT_SHIFT(tmp24 + tmp14,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[6] = range_limit[(int)RIGHT_SHIFT(tmp24 - tmp14,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[5] = range_limit[(int)RIGHT_SHIFT(tmp25,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
-
- wsptr += 8; /* advance pointer to next row */
- }
-}
-
-
-/*
- * Perform dequantization and inverse DCT on one block of coefficients,
- * producing a 12x12 output block.
- *
- * Optimized algorithm with 15 multiplications in the 1-D kernel.
- * cK represents sqrt(2) * cos(K*pi/24).
- */
-
-GLOBAL(void)
-jpeg_idct_12x12(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
- JLONG tmp10, tmp11, tmp12, tmp13, tmp14, tmp15;
- JLONG tmp20, tmp21, tmp22, tmp23, tmp24, tmp25;
- JLONG z1, z2, z3, z4;
- JCOEFPTR inptr;
- ISLOW_MULT_TYPE *quantptr;
- int *wsptr;
- JSAMPROW outptr;
- JSAMPLE *range_limit = IDCT_range_limit(cinfo);
- int ctr;
- int workspace[8 * 12]; /* buffers data between passes */
- SHIFT_TEMPS
-
- /* Pass 1: process columns from input, store into work array. */
-
- inptr = coef_block;
- quantptr = (ISLOW_MULT_TYPE *)compptr->dct_table;
- wsptr = workspace;
- for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) {
- /* Even part */
-
- z3 = DEQUANTIZE(inptr[DCTSIZE * 0], quantptr[DCTSIZE * 0]);
- z3 = LEFT_SHIFT(z3, CONST_BITS);
- /* Add fudge factor here for final descale. */
- z3 += ONE << (CONST_BITS - PASS1_BITS - 1);
-
- z4 = DEQUANTIZE(inptr[DCTSIZE * 4], quantptr[DCTSIZE * 4]);
- z4 = MULTIPLY(z4, FIX(1.224744871)); /* c4 */
-
- tmp10 = z3 + z4;
- tmp11 = z3 - z4;
-
- z1 = DEQUANTIZE(inptr[DCTSIZE * 2], quantptr[DCTSIZE * 2]);
- z4 = MULTIPLY(z1, FIX(1.366025404)); /* c2 */
- z1 = LEFT_SHIFT(z1, CONST_BITS);
- z2 = DEQUANTIZE(inptr[DCTSIZE * 6], quantptr[DCTSIZE * 6]);
- z2 = LEFT_SHIFT(z2, CONST_BITS);
-
- tmp12 = z1 - z2;
-
- tmp21 = z3 + tmp12;
- tmp24 = z3 - tmp12;
-
- tmp12 = z4 + z2;
-
- tmp20 = tmp10 + tmp12;
- tmp25 = tmp10 - tmp12;
-
- tmp12 = z4 - z1 - z2;
-
- tmp22 = tmp11 + tmp12;
- tmp23 = tmp11 - tmp12;
-
- /* Odd part */
-
- z1 = DEQUANTIZE(inptr[DCTSIZE * 1], quantptr[DCTSIZE * 1]);
- z2 = DEQUANTIZE(inptr[DCTSIZE * 3], quantptr[DCTSIZE * 3]);
- z3 = DEQUANTIZE(inptr[DCTSIZE * 5], quantptr[DCTSIZE * 5]);
- z4 = DEQUANTIZE(inptr[DCTSIZE * 7], quantptr[DCTSIZE * 7]);
-
- tmp11 = MULTIPLY(z2, FIX(1.306562965)); /* c3 */
- tmp14 = MULTIPLY(z2, -FIX_0_541196100); /* -c9 */
-
- tmp10 = z1 + z3;
- tmp15 = MULTIPLY(tmp10 + z4, FIX(0.860918669)); /* c7 */
- tmp12 = tmp15 + MULTIPLY(tmp10, FIX(0.261052384)); /* c5-c7 */
- tmp10 = tmp12 + tmp11 + MULTIPLY(z1, FIX(0.280143716)); /* c1-c5 */
- tmp13 = MULTIPLY(z3 + z4, -FIX(1.045510580)); /* -(c7+c11) */
- tmp12 += tmp13 + tmp14 - MULTIPLY(z3, FIX(1.478575242)); /* c1+c5-c7-c11 */
- tmp13 += tmp15 - tmp11 + MULTIPLY(z4, FIX(1.586706681)); /* c1+c11 */
- tmp15 += tmp14 - MULTIPLY(z1, FIX(0.676326758)) - /* c7-c11 */
- MULTIPLY(z4, FIX(1.982889723)); /* c5+c7 */
-
- z1 -= z4;
- z2 -= z3;
- z3 = MULTIPLY(z1 + z2, FIX_0_541196100); /* c9 */
- tmp11 = z3 + MULTIPLY(z1, FIX_0_765366865); /* c3-c9 */
- tmp14 = z3 - MULTIPLY(z2, FIX_1_847759065); /* c3+c9 */
-
- /* Final output stage */
-
- wsptr[8 * 0] = (int)RIGHT_SHIFT(tmp20 + tmp10, CONST_BITS - PASS1_BITS);
- wsptr[8 * 11] = (int)RIGHT_SHIFT(tmp20 - tmp10, CONST_BITS - PASS1_BITS);
- wsptr[8 * 1] = (int)RIGHT_SHIFT(tmp21 + tmp11, CONST_BITS - PASS1_BITS);
- wsptr[8 * 10] = (int)RIGHT_SHIFT(tmp21 - tmp11, CONST_BITS - PASS1_BITS);
- wsptr[8 * 2] = (int)RIGHT_SHIFT(tmp22 + tmp12, CONST_BITS - PASS1_BITS);
- wsptr[8 * 9] = (int)RIGHT_SHIFT(tmp22 - tmp12, CONST_BITS - PASS1_BITS);
- wsptr[8 * 3] = (int)RIGHT_SHIFT(tmp23 + tmp13, CONST_BITS - PASS1_BITS);
- wsptr[8 * 8] = (int)RIGHT_SHIFT(tmp23 - tmp13, CONST_BITS - PASS1_BITS);
- wsptr[8 * 4] = (int)RIGHT_SHIFT(tmp24 + tmp14, CONST_BITS - PASS1_BITS);
- wsptr[8 * 7] = (int)RIGHT_SHIFT(tmp24 - tmp14, CONST_BITS - PASS1_BITS);
- wsptr[8 * 5] = (int)RIGHT_SHIFT(tmp25 + tmp15, CONST_BITS - PASS1_BITS);
- wsptr[8 * 6] = (int)RIGHT_SHIFT(tmp25 - tmp15, CONST_BITS - PASS1_BITS);
- }
-
- /* Pass 2: process 12 rows from work array, store into output array. */
-
- wsptr = workspace;
- for (ctr = 0; ctr < 12; ctr++) {
- outptr = output_buf[ctr] + output_col;
-
- /* Even part */
-
- /* Add fudge factor here for final descale. */
- z3 = (JLONG)wsptr[0] + (ONE << (PASS1_BITS + 2));
- z3 = LEFT_SHIFT(z3, CONST_BITS);
-
- z4 = (JLONG)wsptr[4];
- z4 = MULTIPLY(z4, FIX(1.224744871)); /* c4 */
-
- tmp10 = z3 + z4;
- tmp11 = z3 - z4;
-
- z1 = (JLONG)wsptr[2];
- z4 = MULTIPLY(z1, FIX(1.366025404)); /* c2 */
- z1 = LEFT_SHIFT(z1, CONST_BITS);
- z2 = (JLONG)wsptr[6];
- z2 = LEFT_SHIFT(z2, CONST_BITS);
-
- tmp12 = z1 - z2;
-
- tmp21 = z3 + tmp12;
- tmp24 = z3 - tmp12;
-
- tmp12 = z4 + z2;
-
- tmp20 = tmp10 + tmp12;
- tmp25 = tmp10 - tmp12;
-
- tmp12 = z4 - z1 - z2;
-
- tmp22 = tmp11 + tmp12;
- tmp23 = tmp11 - tmp12;
-
- /* Odd part */
-
- z1 = (JLONG)wsptr[1];
- z2 = (JLONG)wsptr[3];
- z3 = (JLONG)wsptr[5];
- z4 = (JLONG)wsptr[7];
-
- tmp11 = MULTIPLY(z2, FIX(1.306562965)); /* c3 */
- tmp14 = MULTIPLY(z2, -FIX_0_541196100); /* -c9 */
-
- tmp10 = z1 + z3;
- tmp15 = MULTIPLY(tmp10 + z4, FIX(0.860918669)); /* c7 */
- tmp12 = tmp15 + MULTIPLY(tmp10, FIX(0.261052384)); /* c5-c7 */
- tmp10 = tmp12 + tmp11 + MULTIPLY(z1, FIX(0.280143716)); /* c1-c5 */
- tmp13 = MULTIPLY(z3 + z4, -FIX(1.045510580)); /* -(c7+c11) */
- tmp12 += tmp13 + tmp14 - MULTIPLY(z3, FIX(1.478575242)); /* c1+c5-c7-c11 */
- tmp13 += tmp15 - tmp11 + MULTIPLY(z4, FIX(1.586706681)); /* c1+c11 */
- tmp15 += tmp14 - MULTIPLY(z1, FIX(0.676326758)) - /* c7-c11 */
- MULTIPLY(z4, FIX(1.982889723)); /* c5+c7 */
-
- z1 -= z4;
- z2 -= z3;
- z3 = MULTIPLY(z1 + z2, FIX_0_541196100); /* c9 */
- tmp11 = z3 + MULTIPLY(z1, FIX_0_765366865); /* c3-c9 */
- tmp14 = z3 - MULTIPLY(z2, FIX_1_847759065); /* c3+c9 */
-
- /* Final output stage */
-
- outptr[0] = range_limit[(int)RIGHT_SHIFT(tmp20 + tmp10,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[11] = range_limit[(int)RIGHT_SHIFT(tmp20 - tmp10,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[1] = range_limit[(int)RIGHT_SHIFT(tmp21 + tmp11,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[10] = range_limit[(int)RIGHT_SHIFT(tmp21 - tmp11,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[2] = range_limit[(int)RIGHT_SHIFT(tmp22 + tmp12,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[9] = range_limit[(int)RIGHT_SHIFT(tmp22 - tmp12,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[3] = range_limit[(int)RIGHT_SHIFT(tmp23 + tmp13,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[8] = range_limit[(int)RIGHT_SHIFT(tmp23 - tmp13,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[4] = range_limit[(int)RIGHT_SHIFT(tmp24 + tmp14,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[7] = range_limit[(int)RIGHT_SHIFT(tmp24 - tmp14,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[5] = range_limit[(int)RIGHT_SHIFT(tmp25 + tmp15,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[6] = range_limit[(int)RIGHT_SHIFT(tmp25 - tmp15,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
-
- wsptr += 8; /* advance pointer to next row */
- }
-}
-
-
-/*
- * Perform dequantization and inverse DCT on one block of coefficients,
- * producing a 13x13 output block.
- *
- * Optimized algorithm with 29 multiplications in the 1-D kernel.
- * cK represents sqrt(2) * cos(K*pi/26).
- */
-
-GLOBAL(void)
-jpeg_idct_13x13(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
- JLONG tmp10, tmp11, tmp12, tmp13, tmp14, tmp15;
- JLONG tmp20, tmp21, tmp22, tmp23, tmp24, tmp25, tmp26;
- JLONG z1, z2, z3, z4;
- JCOEFPTR inptr;
- ISLOW_MULT_TYPE *quantptr;
- int *wsptr;
- JSAMPROW outptr;
- JSAMPLE *range_limit = IDCT_range_limit(cinfo);
- int ctr;
- int workspace[8 * 13]; /* buffers data between passes */
- SHIFT_TEMPS
-
- /* Pass 1: process columns from input, store into work array. */
-
- inptr = coef_block;
- quantptr = (ISLOW_MULT_TYPE *)compptr->dct_table;
- wsptr = workspace;
- for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) {
- /* Even part */
-
- z1 = DEQUANTIZE(inptr[DCTSIZE * 0], quantptr[DCTSIZE * 0]);
- z1 = LEFT_SHIFT(z1, CONST_BITS);
- /* Add fudge factor here for final descale. */
- z1 += ONE << (CONST_BITS - PASS1_BITS - 1);
-
- z2 = DEQUANTIZE(inptr[DCTSIZE * 2], quantptr[DCTSIZE * 2]);
- z3 = DEQUANTIZE(inptr[DCTSIZE * 4], quantptr[DCTSIZE * 4]);
- z4 = DEQUANTIZE(inptr[DCTSIZE * 6], quantptr[DCTSIZE * 6]);
-
- tmp10 = z3 + z4;
- tmp11 = z3 - z4;
-
- tmp12 = MULTIPLY(tmp10, FIX(1.155388986)); /* (c4+c6)/2 */
- tmp13 = MULTIPLY(tmp11, FIX(0.096834934)) + z1; /* (c4-c6)/2 */
-
- tmp20 = MULTIPLY(z2, FIX(1.373119086)) + tmp12 + tmp13; /* c2 */
- tmp22 = MULTIPLY(z2, FIX(0.501487041)) - tmp12 + tmp13; /* c10 */
-
- tmp12 = MULTIPLY(tmp10, FIX(0.316450131)); /* (c8-c12)/2 */
- tmp13 = MULTIPLY(tmp11, FIX(0.486914739)) + z1; /* (c8+c12)/2 */
-
- tmp21 = MULTIPLY(z2, FIX(1.058554052)) - tmp12 + tmp13; /* c6 */
- tmp25 = MULTIPLY(z2, -FIX(1.252223920)) + tmp12 + tmp13; /* c4 */
-
- tmp12 = MULTIPLY(tmp10, FIX(0.435816023)); /* (c2-c10)/2 */
- tmp13 = MULTIPLY(tmp11, FIX(0.937303064)) - z1; /* (c2+c10)/2 */
-
- tmp23 = MULTIPLY(z2, -FIX(0.170464608)) - tmp12 - tmp13; /* c12 */
- tmp24 = MULTIPLY(z2, -FIX(0.803364869)) + tmp12 - tmp13; /* c8 */
-
- tmp26 = MULTIPLY(tmp11 - z2, FIX(1.414213562)) + z1; /* c0 */
-
- /* Odd part */
-
- z1 = DEQUANTIZE(inptr[DCTSIZE * 1], quantptr[DCTSIZE * 1]);
- z2 = DEQUANTIZE(inptr[DCTSIZE * 3], quantptr[DCTSIZE * 3]);
- z3 = DEQUANTIZE(inptr[DCTSIZE * 5], quantptr[DCTSIZE * 5]);
- z4 = DEQUANTIZE(inptr[DCTSIZE * 7], quantptr[DCTSIZE * 7]);
-
- tmp11 = MULTIPLY(z1 + z2, FIX(1.322312651)); /* c3 */
- tmp12 = MULTIPLY(z1 + z3, FIX(1.163874945)); /* c5 */
- tmp15 = z1 + z4;
- tmp13 = MULTIPLY(tmp15, FIX(0.937797057)); /* c7 */
- tmp10 = tmp11 + tmp12 + tmp13 -
- MULTIPLY(z1, FIX(2.020082300)); /* c7+c5+c3-c1 */
- tmp14 = MULTIPLY(z2 + z3, -FIX(0.338443458)); /* -c11 */
- tmp11 += tmp14 + MULTIPLY(z2, FIX(0.837223564)); /* c5+c9+c11-c3 */
- tmp12 += tmp14 - MULTIPLY(z3, FIX(1.572116027)); /* c1+c5-c9-c11 */
- tmp14 = MULTIPLY(z2 + z4, -FIX(1.163874945)); /* -c5 */
- tmp11 += tmp14;
- tmp13 += tmp14 + MULTIPLY(z4, FIX(2.205608352)); /* c3+c5+c9-c7 */
- tmp14 = MULTIPLY(z3 + z4, -FIX(0.657217813)); /* -c9 */
- tmp12 += tmp14;
- tmp13 += tmp14;
- tmp15 = MULTIPLY(tmp15, FIX(0.338443458)); /* c11 */
- tmp14 = tmp15 + MULTIPLY(z1, FIX(0.318774355)) - /* c9-c11 */
- MULTIPLY(z2, FIX(0.466105296)); /* c1-c7 */
- z1 = MULTIPLY(z3 - z2, FIX(0.937797057)); /* c7 */
- tmp14 += z1;
- tmp15 += z1 + MULTIPLY(z3, FIX(0.384515595)) - /* c3-c7 */
- MULTIPLY(z4, FIX(1.742345811)); /* c1+c11 */
-
- /* Final output stage */
-
- wsptr[8 * 0] = (int)RIGHT_SHIFT(tmp20 + tmp10, CONST_BITS - PASS1_BITS);
- wsptr[8 * 12] = (int)RIGHT_SHIFT(tmp20 - tmp10, CONST_BITS - PASS1_BITS);
- wsptr[8 * 1] = (int)RIGHT_SHIFT(tmp21 + tmp11, CONST_BITS - PASS1_BITS);
- wsptr[8 * 11] = (int)RIGHT_SHIFT(tmp21 - tmp11, CONST_BITS - PASS1_BITS);
- wsptr[8 * 2] = (int)RIGHT_SHIFT(tmp22 + tmp12, CONST_BITS - PASS1_BITS);
- wsptr[8 * 10] = (int)RIGHT_SHIFT(tmp22 - tmp12, CONST_BITS - PASS1_BITS);
- wsptr[8 * 3] = (int)RIGHT_SHIFT(tmp23 + tmp13, CONST_BITS - PASS1_BITS);
- wsptr[8 * 9] = (int)RIGHT_SHIFT(tmp23 - tmp13, CONST_BITS - PASS1_BITS);
- wsptr[8 * 4] = (int)RIGHT_SHIFT(tmp24 + tmp14, CONST_BITS - PASS1_BITS);
- wsptr[8 * 8] = (int)RIGHT_SHIFT(tmp24 - tmp14, CONST_BITS - PASS1_BITS);
- wsptr[8 * 5] = (int)RIGHT_SHIFT(tmp25 + tmp15, CONST_BITS - PASS1_BITS);
- wsptr[8 * 7] = (int)RIGHT_SHIFT(tmp25 - tmp15, CONST_BITS - PASS1_BITS);
- wsptr[8 * 6] = (int)RIGHT_SHIFT(tmp26, CONST_BITS - PASS1_BITS);
- }
-
- /* Pass 2: process 13 rows from work array, store into output array. */
-
- wsptr = workspace;
- for (ctr = 0; ctr < 13; ctr++) {
- outptr = output_buf[ctr] + output_col;
-
- /* Even part */
-
- /* Add fudge factor here for final descale. */
- z1 = (JLONG)wsptr[0] + (ONE << (PASS1_BITS + 2));
- z1 = LEFT_SHIFT(z1, CONST_BITS);
-
- z2 = (JLONG)wsptr[2];
- z3 = (JLONG)wsptr[4];
- z4 = (JLONG)wsptr[6];
-
- tmp10 = z3 + z4;
- tmp11 = z3 - z4;
-
- tmp12 = MULTIPLY(tmp10, FIX(1.155388986)); /* (c4+c6)/2 */
- tmp13 = MULTIPLY(tmp11, FIX(0.096834934)) + z1; /* (c4-c6)/2 */
-
- tmp20 = MULTIPLY(z2, FIX(1.373119086)) + tmp12 + tmp13; /* c2 */
- tmp22 = MULTIPLY(z2, FIX(0.501487041)) - tmp12 + tmp13; /* c10 */
-
- tmp12 = MULTIPLY(tmp10, FIX(0.316450131)); /* (c8-c12)/2 */
- tmp13 = MULTIPLY(tmp11, FIX(0.486914739)) + z1; /* (c8+c12)/2 */
-
- tmp21 = MULTIPLY(z2, FIX(1.058554052)) - tmp12 + tmp13; /* c6 */
- tmp25 = MULTIPLY(z2, -FIX(1.252223920)) + tmp12 + tmp13; /* c4 */
-
- tmp12 = MULTIPLY(tmp10, FIX(0.435816023)); /* (c2-c10)/2 */
- tmp13 = MULTIPLY(tmp11, FIX(0.937303064)) - z1; /* (c2+c10)/2 */
-
- tmp23 = MULTIPLY(z2, -FIX(0.170464608)) - tmp12 - tmp13; /* c12 */
- tmp24 = MULTIPLY(z2, -FIX(0.803364869)) + tmp12 - tmp13; /* c8 */
-
- tmp26 = MULTIPLY(tmp11 - z2, FIX(1.414213562)) + z1; /* c0 */
-
- /* Odd part */
-
- z1 = (JLONG)wsptr[1];
- z2 = (JLONG)wsptr[3];
- z3 = (JLONG)wsptr[5];
- z4 = (JLONG)wsptr[7];
-
- tmp11 = MULTIPLY(z1 + z2, FIX(1.322312651)); /* c3 */
- tmp12 = MULTIPLY(z1 + z3, FIX(1.163874945)); /* c5 */
- tmp15 = z1 + z4;
- tmp13 = MULTIPLY(tmp15, FIX(0.937797057)); /* c7 */
- tmp10 = tmp11 + tmp12 + tmp13 -
- MULTIPLY(z1, FIX(2.020082300)); /* c7+c5+c3-c1 */
- tmp14 = MULTIPLY(z2 + z3, -FIX(0.338443458)); /* -c11 */
- tmp11 += tmp14 + MULTIPLY(z2, FIX(0.837223564)); /* c5+c9+c11-c3 */
- tmp12 += tmp14 - MULTIPLY(z3, FIX(1.572116027)); /* c1+c5-c9-c11 */
- tmp14 = MULTIPLY(z2 + z4, -FIX(1.163874945)); /* -c5 */
- tmp11 += tmp14;
- tmp13 += tmp14 + MULTIPLY(z4, FIX(2.205608352)); /* c3+c5+c9-c7 */
- tmp14 = MULTIPLY(z3 + z4, -FIX(0.657217813)); /* -c9 */
- tmp12 += tmp14;
- tmp13 += tmp14;
- tmp15 = MULTIPLY(tmp15, FIX(0.338443458)); /* c11 */
- tmp14 = tmp15 + MULTIPLY(z1, FIX(0.318774355)) - /* c9-c11 */
- MULTIPLY(z2, FIX(0.466105296)); /* c1-c7 */
- z1 = MULTIPLY(z3 - z2, FIX(0.937797057)); /* c7 */
- tmp14 += z1;
- tmp15 += z1 + MULTIPLY(z3, FIX(0.384515595)) - /* c3-c7 */
- MULTIPLY(z4, FIX(1.742345811)); /* c1+c11 */
-
- /* Final output stage */
-
- outptr[0] = range_limit[(int)RIGHT_SHIFT(tmp20 + tmp10,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[12] = range_limit[(int)RIGHT_SHIFT(tmp20 - tmp10,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[1] = range_limit[(int)RIGHT_SHIFT(tmp21 + tmp11,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[11] = range_limit[(int)RIGHT_SHIFT(tmp21 - tmp11,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[2] = range_limit[(int)RIGHT_SHIFT(tmp22 + tmp12,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[10] = range_limit[(int)RIGHT_SHIFT(tmp22 - tmp12,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[3] = range_limit[(int)RIGHT_SHIFT(tmp23 + tmp13,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[9] = range_limit[(int)RIGHT_SHIFT(tmp23 - tmp13,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[4] = range_limit[(int)RIGHT_SHIFT(tmp24 + tmp14,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[8] = range_limit[(int)RIGHT_SHIFT(tmp24 - tmp14,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[5] = range_limit[(int)RIGHT_SHIFT(tmp25 + tmp15,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[7] = range_limit[(int)RIGHT_SHIFT(tmp25 - tmp15,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[6] = range_limit[(int)RIGHT_SHIFT(tmp26,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
-
- wsptr += 8; /* advance pointer to next row */
- }
-}
-
-
-/*
- * Perform dequantization and inverse DCT on one block of coefficients,
- * producing a 14x14 output block.
- *
- * Optimized algorithm with 20 multiplications in the 1-D kernel.
- * cK represents sqrt(2) * cos(K*pi/28).
- */
-
-GLOBAL(void)
-jpeg_idct_14x14(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
- JLONG tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp16;
- JLONG tmp20, tmp21, tmp22, tmp23, tmp24, tmp25, tmp26;
- JLONG z1, z2, z3, z4;
- JCOEFPTR inptr;
- ISLOW_MULT_TYPE *quantptr;
- int *wsptr;
- JSAMPROW outptr;
- JSAMPLE *range_limit = IDCT_range_limit(cinfo);
- int ctr;
- int workspace[8 * 14]; /* buffers data between passes */
- SHIFT_TEMPS
-
- /* Pass 1: process columns from input, store into work array. */
-
- inptr = coef_block;
- quantptr = (ISLOW_MULT_TYPE *)compptr->dct_table;
- wsptr = workspace;
- for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) {
- /* Even part */
-
- z1 = DEQUANTIZE(inptr[DCTSIZE * 0], quantptr[DCTSIZE * 0]);
- z1 = LEFT_SHIFT(z1, CONST_BITS);
- /* Add fudge factor here for final descale. */
- z1 += ONE << (CONST_BITS - PASS1_BITS - 1);
- z4 = DEQUANTIZE(inptr[DCTSIZE * 4], quantptr[DCTSIZE * 4]);
- z2 = MULTIPLY(z4, FIX(1.274162392)); /* c4 */
- z3 = MULTIPLY(z4, FIX(0.314692123)); /* c12 */
- z4 = MULTIPLY(z4, FIX(0.881747734)); /* c8 */
-
- tmp10 = z1 + z2;
- tmp11 = z1 + z3;
- tmp12 = z1 - z4;
-
- tmp23 = RIGHT_SHIFT(z1 - LEFT_SHIFT(z2 + z3 - z4, 1),
- CONST_BITS - PASS1_BITS); /* c0 = (c4+c12-c8)*2 */
-
- z1 = DEQUANTIZE(inptr[DCTSIZE * 2], quantptr[DCTSIZE * 2]);
- z2 = DEQUANTIZE(inptr[DCTSIZE * 6], quantptr[DCTSIZE * 6]);
-
- z3 = MULTIPLY(z1 + z2, FIX(1.105676686)); /* c6 */
-
- tmp13 = z3 + MULTIPLY(z1, FIX(0.273079590)); /* c2-c6 */
- tmp14 = z3 - MULTIPLY(z2, FIX(1.719280954)); /* c6+c10 */
- tmp15 = MULTIPLY(z1, FIX(0.613604268)) - /* c10 */
- MULTIPLY(z2, FIX(1.378756276)); /* c2 */
-
- tmp20 = tmp10 + tmp13;
- tmp26 = tmp10 - tmp13;
- tmp21 = tmp11 + tmp14;
- tmp25 = tmp11 - tmp14;
- tmp22 = tmp12 + tmp15;
- tmp24 = tmp12 - tmp15;
-
- /* Odd part */
-
- z1 = DEQUANTIZE(inptr[DCTSIZE * 1], quantptr[DCTSIZE * 1]);
- z2 = DEQUANTIZE(inptr[DCTSIZE * 3], quantptr[DCTSIZE * 3]);
- z3 = DEQUANTIZE(inptr[DCTSIZE * 5], quantptr[DCTSIZE * 5]);
- z4 = DEQUANTIZE(inptr[DCTSIZE * 7], quantptr[DCTSIZE * 7]);
- tmp13 = LEFT_SHIFT(z4, CONST_BITS);
-
- tmp14 = z1 + z3;
- tmp11 = MULTIPLY(z1 + z2, FIX(1.334852607)); /* c3 */
- tmp12 = MULTIPLY(tmp14, FIX(1.197448846)); /* c5 */
- tmp10 = tmp11 + tmp12 + tmp13 - MULTIPLY(z1, FIX(1.126980169)); /* c3+c5-c1 */
- tmp14 = MULTIPLY(tmp14, FIX(0.752406978)); /* c9 */
- tmp16 = tmp14 - MULTIPLY(z1, FIX(1.061150426)); /* c9+c11-c13 */
- z1 -= z2;
- tmp15 = MULTIPLY(z1, FIX(0.467085129)) - tmp13; /* c11 */
- tmp16 += tmp15;
- z1 += z4;
- z4 = MULTIPLY(z2 + z3, -FIX(0.158341681)) - tmp13; /* -c13 */
- tmp11 += z4 - MULTIPLY(z2, FIX(0.424103948)); /* c3-c9-c13 */
- tmp12 += z4 - MULTIPLY(z3, FIX(2.373959773)); /* c3+c5-c13 */
- z4 = MULTIPLY(z3 - z2, FIX(1.405321284)); /* c1 */
- tmp14 += z4 + tmp13 - MULTIPLY(z3, FIX(1.6906431334)); /* c1+c9-c11 */
- tmp15 += z4 + MULTIPLY(z2, FIX(0.674957567)); /* c1+c11-c5 */
-
- tmp13 = LEFT_SHIFT(z1 - z3, PASS1_BITS);
-
- /* Final output stage */
-
- wsptr[8 * 0] = (int)RIGHT_SHIFT(tmp20 + tmp10, CONST_BITS - PASS1_BITS);
- wsptr[8 * 13] = (int)RIGHT_SHIFT(tmp20 - tmp10, CONST_BITS - PASS1_BITS);
- wsptr[8 * 1] = (int)RIGHT_SHIFT(tmp21 + tmp11, CONST_BITS - PASS1_BITS);
- wsptr[8 * 12] = (int)RIGHT_SHIFT(tmp21 - tmp11, CONST_BITS - PASS1_BITS);
- wsptr[8 * 2] = (int)RIGHT_SHIFT(tmp22 + tmp12, CONST_BITS - PASS1_BITS);
- wsptr[8 * 11] = (int)RIGHT_SHIFT(tmp22 - tmp12, CONST_BITS - PASS1_BITS);
- wsptr[8 * 3] = (int)(tmp23 + tmp13);
- wsptr[8 * 10] = (int)(tmp23 - tmp13);
- wsptr[8 * 4] = (int)RIGHT_SHIFT(tmp24 + tmp14, CONST_BITS - PASS1_BITS);
- wsptr[8 * 9] = (int)RIGHT_SHIFT(tmp24 - tmp14, CONST_BITS - PASS1_BITS);
- wsptr[8 * 5] = (int)RIGHT_SHIFT(tmp25 + tmp15, CONST_BITS - PASS1_BITS);
- wsptr[8 * 8] = (int)RIGHT_SHIFT(tmp25 - tmp15, CONST_BITS - PASS1_BITS);
- wsptr[8 * 6] = (int)RIGHT_SHIFT(tmp26 + tmp16, CONST_BITS - PASS1_BITS);
- wsptr[8 * 7] = (int)RIGHT_SHIFT(tmp26 - tmp16, CONST_BITS - PASS1_BITS);
- }
-
- /* Pass 2: process 14 rows from work array, store into output array. */
-
- wsptr = workspace;
- for (ctr = 0; ctr < 14; ctr++) {
- outptr = output_buf[ctr] + output_col;
-
- /* Even part */
-
- /* Add fudge factor here for final descale. */
- z1 = (JLONG)wsptr[0] + (ONE << (PASS1_BITS + 2));
- z1 = LEFT_SHIFT(z1, CONST_BITS);
- z4 = (JLONG)wsptr[4];
- z2 = MULTIPLY(z4, FIX(1.274162392)); /* c4 */
- z3 = MULTIPLY(z4, FIX(0.314692123)); /* c12 */
- z4 = MULTIPLY(z4, FIX(0.881747734)); /* c8 */
-
- tmp10 = z1 + z2;
- tmp11 = z1 + z3;
- tmp12 = z1 - z4;
-
- tmp23 = z1 - LEFT_SHIFT(z2 + z3 - z4, 1); /* c0 = (c4+c12-c8)*2 */
-
- z1 = (JLONG)wsptr[2];
- z2 = (JLONG)wsptr[6];
-
- z3 = MULTIPLY(z1 + z2, FIX(1.105676686)); /* c6 */
-
- tmp13 = z3 + MULTIPLY(z1, FIX(0.273079590)); /* c2-c6 */
- tmp14 = z3 - MULTIPLY(z2, FIX(1.719280954)); /* c6+c10 */
- tmp15 = MULTIPLY(z1, FIX(0.613604268)) - /* c10 */
- MULTIPLY(z2, FIX(1.378756276)); /* c2 */
-
- tmp20 = tmp10 + tmp13;
- tmp26 = tmp10 - tmp13;
- tmp21 = tmp11 + tmp14;
- tmp25 = tmp11 - tmp14;
- tmp22 = tmp12 + tmp15;
- tmp24 = tmp12 - tmp15;
-
- /* Odd part */
-
- z1 = (JLONG)wsptr[1];
- z2 = (JLONG)wsptr[3];
- z3 = (JLONG)wsptr[5];
- z4 = (JLONG)wsptr[7];
- z4 = LEFT_SHIFT(z4, CONST_BITS);
-
- tmp14 = z1 + z3;
- tmp11 = MULTIPLY(z1 + z2, FIX(1.334852607)); /* c3 */
- tmp12 = MULTIPLY(tmp14, FIX(1.197448846)); /* c5 */
- tmp10 = tmp11 + tmp12 + z4 - MULTIPLY(z1, FIX(1.126980169)); /* c3+c5-c1 */
- tmp14 = MULTIPLY(tmp14, FIX(0.752406978)); /* c9 */
- tmp16 = tmp14 - MULTIPLY(z1, FIX(1.061150426)); /* c9+c11-c13 */
- z1 -= z2;
- tmp15 = MULTIPLY(z1, FIX(0.467085129)) - z4; /* c11 */
- tmp16 += tmp15;
- tmp13 = MULTIPLY(z2 + z3, -FIX(0.158341681)) - z4; /* -c13 */
- tmp11 += tmp13 - MULTIPLY(z2, FIX(0.424103948)); /* c3-c9-c13 */
- tmp12 += tmp13 - MULTIPLY(z3, FIX(2.373959773)); /* c3+c5-c13 */
- tmp13 = MULTIPLY(z3 - z2, FIX(1.405321284)); /* c1 */
- tmp14 += tmp13 + z4 - MULTIPLY(z3, FIX(1.6906431334)); /* c1+c9-c11 */
- tmp15 += tmp13 + MULTIPLY(z2, FIX(0.674957567)); /* c1+c11-c5 */
-
- tmp13 = LEFT_SHIFT(z1 - z3, CONST_BITS) + z4;
-
- /* Final output stage */
-
- outptr[0] = range_limit[(int)RIGHT_SHIFT(tmp20 + tmp10,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[13] = range_limit[(int)RIGHT_SHIFT(tmp20 - tmp10,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[1] = range_limit[(int)RIGHT_SHIFT(tmp21 + tmp11,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[12] = range_limit[(int)RIGHT_SHIFT(tmp21 - tmp11,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[2] = range_limit[(int)RIGHT_SHIFT(tmp22 + tmp12,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[11] = range_limit[(int)RIGHT_SHIFT(tmp22 - tmp12,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[3] = range_limit[(int)RIGHT_SHIFT(tmp23 + tmp13,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[10] = range_limit[(int)RIGHT_SHIFT(tmp23 - tmp13,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[4] = range_limit[(int)RIGHT_SHIFT(tmp24 + tmp14,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[9] = range_limit[(int)RIGHT_SHIFT(tmp24 - tmp14,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[5] = range_limit[(int)RIGHT_SHIFT(tmp25 + tmp15,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[8] = range_limit[(int)RIGHT_SHIFT(tmp25 - tmp15,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[6] = range_limit[(int)RIGHT_SHIFT(tmp26 + tmp16,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[7] = range_limit[(int)RIGHT_SHIFT(tmp26 - tmp16,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
-
- wsptr += 8; /* advance pointer to next row */
- }
-}
-
-
-/*
- * Perform dequantization and inverse DCT on one block of coefficients,
- * producing a 15x15 output block.
- *
- * Optimized algorithm with 22 multiplications in the 1-D kernel.
- * cK represents sqrt(2) * cos(K*pi/30).
- */
-
-GLOBAL(void)
-jpeg_idct_15x15(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
- JLONG tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp16;
- JLONG tmp20, tmp21, tmp22, tmp23, tmp24, tmp25, tmp26, tmp27;
- JLONG z1, z2, z3, z4;
- JCOEFPTR inptr;
- ISLOW_MULT_TYPE *quantptr;
- int *wsptr;
- JSAMPROW outptr;
- JSAMPLE *range_limit = IDCT_range_limit(cinfo);
- int ctr;
- int workspace[8 * 15]; /* buffers data between passes */
- SHIFT_TEMPS
-
- /* Pass 1: process columns from input, store into work array. */
-
- inptr = coef_block;
- quantptr = (ISLOW_MULT_TYPE *)compptr->dct_table;
- wsptr = workspace;
- for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) {
- /* Even part */
-
- z1 = DEQUANTIZE(inptr[DCTSIZE * 0], quantptr[DCTSIZE * 0]);
- z1 = LEFT_SHIFT(z1, CONST_BITS);
- /* Add fudge factor here for final descale. */
- z1 += ONE << (CONST_BITS - PASS1_BITS - 1);
-
- z2 = DEQUANTIZE(inptr[DCTSIZE * 2], quantptr[DCTSIZE * 2]);
- z3 = DEQUANTIZE(inptr[DCTSIZE * 4], quantptr[DCTSIZE * 4]);
- z4 = DEQUANTIZE(inptr[DCTSIZE * 6], quantptr[DCTSIZE * 6]);
-
- tmp10 = MULTIPLY(z4, FIX(0.437016024)); /* c12 */
- tmp11 = MULTIPLY(z4, FIX(1.144122806)); /* c6 */
-
- tmp12 = z1 - tmp10;
- tmp13 = z1 + tmp11;
- z1 -= LEFT_SHIFT(tmp11 - tmp10, 1); /* c0 = (c6-c12)*2 */
-
- z4 = z2 - z3;
- z3 += z2;
- tmp10 = MULTIPLY(z3, FIX(1.337628990)); /* (c2+c4)/2 */
- tmp11 = MULTIPLY(z4, FIX(0.045680613)); /* (c2-c4)/2 */
- z2 = MULTIPLY(z2, FIX(1.439773946)); /* c4+c14 */
-
- tmp20 = tmp13 + tmp10 + tmp11;
- tmp23 = tmp12 - tmp10 + tmp11 + z2;
-
- tmp10 = MULTIPLY(z3, FIX(0.547059574)); /* (c8+c14)/2 */
- tmp11 = MULTIPLY(z4, FIX(0.399234004)); /* (c8-c14)/2 */
-
- tmp25 = tmp13 - tmp10 - tmp11;
- tmp26 = tmp12 + tmp10 - tmp11 - z2;
-
- tmp10 = MULTIPLY(z3, FIX(0.790569415)); /* (c6+c12)/2 */
- tmp11 = MULTIPLY(z4, FIX(0.353553391)); /* (c6-c12)/2 */
-
- tmp21 = tmp12 + tmp10 + tmp11;
- tmp24 = tmp13 - tmp10 + tmp11;
- tmp11 += tmp11;
- tmp22 = z1 + tmp11; /* c10 = c6-c12 */
- tmp27 = z1 - tmp11 - tmp11; /* c0 = (c6-c12)*2 */
-
- /* Odd part */
-
- z1 = DEQUANTIZE(inptr[DCTSIZE * 1], quantptr[DCTSIZE * 1]);
- z2 = DEQUANTIZE(inptr[DCTSIZE * 3], quantptr[DCTSIZE * 3]);
- z4 = DEQUANTIZE(inptr[DCTSIZE * 5], quantptr[DCTSIZE * 5]);
- z3 = MULTIPLY(z4, FIX(1.224744871)); /* c5 */
- z4 = DEQUANTIZE(inptr[DCTSIZE * 7], quantptr[DCTSIZE * 7]);
-
- tmp13 = z2 - z4;
- tmp15 = MULTIPLY(z1 + tmp13, FIX(0.831253876)); /* c9 */
- tmp11 = tmp15 + MULTIPLY(z1, FIX(0.513743148)); /* c3-c9 */
- tmp14 = tmp15 - MULTIPLY(tmp13, FIX(2.176250899)); /* c3+c9 */
-
- tmp13 = MULTIPLY(z2, -FIX(0.831253876)); /* -c9 */
- tmp15 = MULTIPLY(z2, -FIX(1.344997024)); /* -c3 */
- z2 = z1 - z4;
- tmp12 = z3 + MULTIPLY(z2, FIX(1.406466353)); /* c1 */
-
- tmp10 = tmp12 + MULTIPLY(z4, FIX(2.457431844)) - tmp15; /* c1+c7 */
- tmp16 = tmp12 - MULTIPLY(z1, FIX(1.112434820)) + tmp13; /* c1-c13 */
- tmp12 = MULTIPLY(z2, FIX(1.224744871)) - z3; /* c5 */
- z2 = MULTIPLY(z1 + z4, FIX(0.575212477)); /* c11 */
- tmp13 += z2 + MULTIPLY(z1, FIX(0.475753014)) - z3; /* c7-c11 */
- tmp15 += z2 - MULTIPLY(z4, FIX(0.869244010)) + z3; /* c11+c13 */
-
- /* Final output stage */
-
- wsptr[8 * 0] = (int)RIGHT_SHIFT(tmp20 + tmp10, CONST_BITS - PASS1_BITS);
- wsptr[8 * 14] = (int)RIGHT_SHIFT(tmp20 - tmp10, CONST_BITS - PASS1_BITS);
- wsptr[8 * 1] = (int)RIGHT_SHIFT(tmp21 + tmp11, CONST_BITS - PASS1_BITS);
- wsptr[8 * 13] = (int)RIGHT_SHIFT(tmp21 - tmp11, CONST_BITS - PASS1_BITS);
- wsptr[8 * 2] = (int)RIGHT_SHIFT(tmp22 + tmp12, CONST_BITS - PASS1_BITS);
- wsptr[8 * 12] = (int)RIGHT_SHIFT(tmp22 - tmp12, CONST_BITS - PASS1_BITS);
- wsptr[8 * 3] = (int)RIGHT_SHIFT(tmp23 + tmp13, CONST_BITS - PASS1_BITS);
- wsptr[8 * 11] = (int)RIGHT_SHIFT(tmp23 - tmp13, CONST_BITS - PASS1_BITS);
- wsptr[8 * 4] = (int)RIGHT_SHIFT(tmp24 + tmp14, CONST_BITS - PASS1_BITS);
- wsptr[8 * 10] = (int)RIGHT_SHIFT(tmp24 - tmp14, CONST_BITS - PASS1_BITS);
- wsptr[8 * 5] = (int)RIGHT_SHIFT(tmp25 + tmp15, CONST_BITS - PASS1_BITS);
- wsptr[8 * 9] = (int)RIGHT_SHIFT(tmp25 - tmp15, CONST_BITS - PASS1_BITS);
- wsptr[8 * 6] = (int)RIGHT_SHIFT(tmp26 + tmp16, CONST_BITS - PASS1_BITS);
- wsptr[8 * 8] = (int)RIGHT_SHIFT(tmp26 - tmp16, CONST_BITS - PASS1_BITS);
- wsptr[8 * 7] = (int)RIGHT_SHIFT(tmp27, CONST_BITS - PASS1_BITS);
- }
-
- /* Pass 2: process 15 rows from work array, store into output array. */
-
- wsptr = workspace;
- for (ctr = 0; ctr < 15; ctr++) {
- outptr = output_buf[ctr] + output_col;
-
- /* Even part */
-
- /* Add fudge factor here for final descale. */
- z1 = (JLONG)wsptr[0] + (ONE << (PASS1_BITS + 2));
- z1 = LEFT_SHIFT(z1, CONST_BITS);
-
- z2 = (JLONG)wsptr[2];
- z3 = (JLONG)wsptr[4];
- z4 = (JLONG)wsptr[6];
-
- tmp10 = MULTIPLY(z4, FIX(0.437016024)); /* c12 */
- tmp11 = MULTIPLY(z4, FIX(1.144122806)); /* c6 */
-
- tmp12 = z1 - tmp10;
- tmp13 = z1 + tmp11;
- z1 -= LEFT_SHIFT(tmp11 - tmp10, 1); /* c0 = (c6-c12)*2 */
-
- z4 = z2 - z3;
- z3 += z2;
- tmp10 = MULTIPLY(z3, FIX(1.337628990)); /* (c2+c4)/2 */
- tmp11 = MULTIPLY(z4, FIX(0.045680613)); /* (c2-c4)/2 */
- z2 = MULTIPLY(z2, FIX(1.439773946)); /* c4+c14 */
-
- tmp20 = tmp13 + tmp10 + tmp11;
- tmp23 = tmp12 - tmp10 + tmp11 + z2;
-
- tmp10 = MULTIPLY(z3, FIX(0.547059574)); /* (c8+c14)/2 */
- tmp11 = MULTIPLY(z4, FIX(0.399234004)); /* (c8-c14)/2 */
-
- tmp25 = tmp13 - tmp10 - tmp11;
- tmp26 = tmp12 + tmp10 - tmp11 - z2;
-
- tmp10 = MULTIPLY(z3, FIX(0.790569415)); /* (c6+c12)/2 */
- tmp11 = MULTIPLY(z4, FIX(0.353553391)); /* (c6-c12)/2 */
-
- tmp21 = tmp12 + tmp10 + tmp11;
- tmp24 = tmp13 - tmp10 + tmp11;
- tmp11 += tmp11;
- tmp22 = z1 + tmp11; /* c10 = c6-c12 */
- tmp27 = z1 - tmp11 - tmp11; /* c0 = (c6-c12)*2 */
-
- /* Odd part */
-
- z1 = (JLONG)wsptr[1];
- z2 = (JLONG)wsptr[3];
- z4 = (JLONG)wsptr[5];
- z3 = MULTIPLY(z4, FIX(1.224744871)); /* c5 */
- z4 = (JLONG)wsptr[7];
-
- tmp13 = z2 - z4;
- tmp15 = MULTIPLY(z1 + tmp13, FIX(0.831253876)); /* c9 */
- tmp11 = tmp15 + MULTIPLY(z1, FIX(0.513743148)); /* c3-c9 */
- tmp14 = tmp15 - MULTIPLY(tmp13, FIX(2.176250899)); /* c3+c9 */
-
- tmp13 = MULTIPLY(z2, -FIX(0.831253876)); /* -c9 */
- tmp15 = MULTIPLY(z2, -FIX(1.344997024)); /* -c3 */
- z2 = z1 - z4;
- tmp12 = z3 + MULTIPLY(z2, FIX(1.406466353)); /* c1 */
-
- tmp10 = tmp12 + MULTIPLY(z4, FIX(2.457431844)) - tmp15; /* c1+c7 */
- tmp16 = tmp12 - MULTIPLY(z1, FIX(1.112434820)) + tmp13; /* c1-c13 */
- tmp12 = MULTIPLY(z2, FIX(1.224744871)) - z3; /* c5 */
- z2 = MULTIPLY(z1 + z4, FIX(0.575212477)); /* c11 */
- tmp13 += z2 + MULTIPLY(z1, FIX(0.475753014)) - z3; /* c7-c11 */
- tmp15 += z2 - MULTIPLY(z4, FIX(0.869244010)) + z3; /* c11+c13 */
-
- /* Final output stage */
-
- outptr[0] = range_limit[(int)RIGHT_SHIFT(tmp20 + tmp10,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[14] = range_limit[(int)RIGHT_SHIFT(tmp20 - tmp10,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[1] = range_limit[(int)RIGHT_SHIFT(tmp21 + tmp11,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[13] = range_limit[(int)RIGHT_SHIFT(tmp21 - tmp11,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[2] = range_limit[(int)RIGHT_SHIFT(tmp22 + tmp12,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[12] = range_limit[(int)RIGHT_SHIFT(tmp22 - tmp12,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[3] = range_limit[(int)RIGHT_SHIFT(tmp23 + tmp13,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[11] = range_limit[(int)RIGHT_SHIFT(tmp23 - tmp13,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[4] = range_limit[(int)RIGHT_SHIFT(tmp24 + tmp14,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[10] = range_limit[(int)RIGHT_SHIFT(tmp24 - tmp14,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[5] = range_limit[(int)RIGHT_SHIFT(tmp25 + tmp15,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[9] = range_limit[(int)RIGHT_SHIFT(tmp25 - tmp15,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[6] = range_limit[(int)RIGHT_SHIFT(tmp26 + tmp16,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[8] = range_limit[(int)RIGHT_SHIFT(tmp26 - tmp16,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[7] = range_limit[(int)RIGHT_SHIFT(tmp27,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
-
- wsptr += 8; /* advance pointer to next row */
- }
-}
-
-
-/*
- * Perform dequantization and inverse DCT on one block of coefficients,
- * producing a 16x16 output block.
- *
- * Optimized algorithm with 28 multiplications in the 1-D kernel.
- * cK represents sqrt(2) * cos(K*pi/32).
- */
-
-GLOBAL(void)
-jpeg_idct_16x16(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
- JLONG tmp0, tmp1, tmp2, tmp3, tmp10, tmp11, tmp12, tmp13;
- JLONG tmp20, tmp21, tmp22, tmp23, tmp24, tmp25, tmp26, tmp27;
- JLONG z1, z2, z3, z4;
- JCOEFPTR inptr;
- ISLOW_MULT_TYPE *quantptr;
- int *wsptr;
- JSAMPROW outptr;
- JSAMPLE *range_limit = IDCT_range_limit(cinfo);
- int ctr;
- int workspace[8 * 16]; /* buffers data between passes */
- SHIFT_TEMPS
-
- /* Pass 1: process columns from input, store into work array. */
-
- inptr = coef_block;
- quantptr = (ISLOW_MULT_TYPE *)compptr->dct_table;
- wsptr = workspace;
- for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) {
- /* Even part */
-
- tmp0 = DEQUANTIZE(inptr[DCTSIZE * 0], quantptr[DCTSIZE * 0]);
- tmp0 = LEFT_SHIFT(tmp0, CONST_BITS);
- /* Add fudge factor here for final descale. */
- tmp0 += ONE << (CONST_BITS - PASS1_BITS - 1);
-
- z1 = DEQUANTIZE(inptr[DCTSIZE * 4], quantptr[DCTSIZE * 4]);
- tmp1 = MULTIPLY(z1, FIX(1.306562965)); /* c4[16] = c2[8] */
- tmp2 = MULTIPLY(z1, FIX_0_541196100); /* c12[16] = c6[8] */
-
- tmp10 = tmp0 + tmp1;
- tmp11 = tmp0 - tmp1;
- tmp12 = tmp0 + tmp2;
- tmp13 = tmp0 - tmp2;
-
- z1 = DEQUANTIZE(inptr[DCTSIZE * 2], quantptr[DCTSIZE * 2]);
- z2 = DEQUANTIZE(inptr[DCTSIZE * 6], quantptr[DCTSIZE * 6]);
- z3 = z1 - z2;
- z4 = MULTIPLY(z3, FIX(0.275899379)); /* c14[16] = c7[8] */
- z3 = MULTIPLY(z3, FIX(1.387039845)); /* c2[16] = c1[8] */
-
- tmp0 = z3 + MULTIPLY(z2, FIX_2_562915447); /* (c6+c2)[16] = (c3+c1)[8] */
- tmp1 = z4 + MULTIPLY(z1, FIX_0_899976223); /* (c6-c14)[16] = (c3-c7)[8] */
- tmp2 = z3 - MULTIPLY(z1, FIX(0.601344887)); /* (c2-c10)[16] = (c1-c5)[8] */
- tmp3 = z4 - MULTIPLY(z2, FIX(0.509795579)); /* (c10-c14)[16] = (c5-c7)[8] */
-
- tmp20 = tmp10 + tmp0;
- tmp27 = tmp10 - tmp0;
- tmp21 = tmp12 + tmp1;
- tmp26 = tmp12 - tmp1;
- tmp22 = tmp13 + tmp2;
- tmp25 = tmp13 - tmp2;
- tmp23 = tmp11 + tmp3;
- tmp24 = tmp11 - tmp3;
-
- /* Odd part */
-
- z1 = DEQUANTIZE(inptr[DCTSIZE * 1], quantptr[DCTSIZE * 1]);
- z2 = DEQUANTIZE(inptr[DCTSIZE * 3], quantptr[DCTSIZE * 3]);
- z3 = DEQUANTIZE(inptr[DCTSIZE * 5], quantptr[DCTSIZE * 5]);
- z4 = DEQUANTIZE(inptr[DCTSIZE * 7], quantptr[DCTSIZE * 7]);
-
- tmp11 = z1 + z3;
-
- tmp1 = MULTIPLY(z1 + z2, FIX(1.353318001)); /* c3 */
- tmp2 = MULTIPLY(tmp11, FIX(1.247225013)); /* c5 */
- tmp3 = MULTIPLY(z1 + z4, FIX(1.093201867)); /* c7 */
- tmp10 = MULTIPLY(z1 - z4, FIX(0.897167586)); /* c9 */
- tmp11 = MULTIPLY(tmp11, FIX(0.666655658)); /* c11 */
- tmp12 = MULTIPLY(z1 - z2, FIX(0.410524528)); /* c13 */
- tmp0 = tmp1 + tmp2 + tmp3 -
- MULTIPLY(z1, FIX(2.286341144)); /* c7+c5+c3-c1 */
- tmp13 = tmp10 + tmp11 + tmp12 -
- MULTIPLY(z1, FIX(1.835730603)); /* c9+c11+c13-c15 */
- z1 = MULTIPLY(z2 + z3, FIX(0.138617169)); /* c15 */
- tmp1 += z1 + MULTIPLY(z2, FIX(0.071888074)); /* c9+c11-c3-c15 */
- tmp2 += z1 - MULTIPLY(z3, FIX(1.125726048)); /* c5+c7+c15-c3 */
- z1 = MULTIPLY(z3 - z2, FIX(1.407403738)); /* c1 */
- tmp11 += z1 - MULTIPLY(z3, FIX(0.766367282)); /* c1+c11-c9-c13 */
- tmp12 += z1 + MULTIPLY(z2, FIX(1.971951411)); /* c1+c5+c13-c7 */
- z2 += z4;
- z1 = MULTIPLY(z2, -FIX(0.666655658)); /* -c11 */
- tmp1 += z1;
- tmp3 += z1 + MULTIPLY(z4, FIX(1.065388962)); /* c3+c11+c15-c7 */
- z2 = MULTIPLY(z2, -FIX(1.247225013)); /* -c5 */
- tmp10 += z2 + MULTIPLY(z4, FIX(3.141271809)); /* c1+c5+c9-c13 */
- tmp12 += z2;
- z2 = MULTIPLY(z3 + z4, -FIX(1.353318001)); /* -c3 */
- tmp2 += z2;
- tmp3 += z2;
- z2 = MULTIPLY(z4 - z3, FIX(0.410524528)); /* c13 */
- tmp10 += z2;
- tmp11 += z2;
-
- /* Final output stage */
-
- wsptr[8 * 0] = (int)RIGHT_SHIFT(tmp20 + tmp0, CONST_BITS - PASS1_BITS);
- wsptr[8 * 15] = (int)RIGHT_SHIFT(tmp20 - tmp0, CONST_BITS - PASS1_BITS);
- wsptr[8 * 1] = (int)RIGHT_SHIFT(tmp21 + tmp1, CONST_BITS - PASS1_BITS);
- wsptr[8 * 14] = (int)RIGHT_SHIFT(tmp21 - tmp1, CONST_BITS - PASS1_BITS);
- wsptr[8 * 2] = (int)RIGHT_SHIFT(tmp22 + tmp2, CONST_BITS - PASS1_BITS);
- wsptr[8 * 13] = (int)RIGHT_SHIFT(tmp22 - tmp2, CONST_BITS - PASS1_BITS);
- wsptr[8 * 3] = (int)RIGHT_SHIFT(tmp23 + tmp3, CONST_BITS - PASS1_BITS);
- wsptr[8 * 12] = (int)RIGHT_SHIFT(tmp23 - tmp3, CONST_BITS - PASS1_BITS);
- wsptr[8 * 4] = (int)RIGHT_SHIFT(tmp24 + tmp10, CONST_BITS - PASS1_BITS);
- wsptr[8 * 11] = (int)RIGHT_SHIFT(tmp24 - tmp10, CONST_BITS - PASS1_BITS);
- wsptr[8 * 5] = (int)RIGHT_SHIFT(tmp25 + tmp11, CONST_BITS - PASS1_BITS);
- wsptr[8 * 10] = (int)RIGHT_SHIFT(tmp25 - tmp11, CONST_BITS - PASS1_BITS);
- wsptr[8 * 6] = (int)RIGHT_SHIFT(tmp26 + tmp12, CONST_BITS - PASS1_BITS);
- wsptr[8 * 9] = (int)RIGHT_SHIFT(tmp26 - tmp12, CONST_BITS - PASS1_BITS);
- wsptr[8 * 7] = (int)RIGHT_SHIFT(tmp27 + tmp13, CONST_BITS - PASS1_BITS);
- wsptr[8 * 8] = (int)RIGHT_SHIFT(tmp27 - tmp13, CONST_BITS - PASS1_BITS);
- }
-
- /* Pass 2: process 16 rows from work array, store into output array. */
-
- wsptr = workspace;
- for (ctr = 0; ctr < 16; ctr++) {
- outptr = output_buf[ctr] + output_col;
-
- /* Even part */
-
- /* Add fudge factor here for final descale. */
- tmp0 = (JLONG)wsptr[0] + (ONE << (PASS1_BITS + 2));
- tmp0 = LEFT_SHIFT(tmp0, CONST_BITS);
-
- z1 = (JLONG)wsptr[4];
- tmp1 = MULTIPLY(z1, FIX(1.306562965)); /* c4[16] = c2[8] */
- tmp2 = MULTIPLY(z1, FIX_0_541196100); /* c12[16] = c6[8] */
-
- tmp10 = tmp0 + tmp1;
- tmp11 = tmp0 - tmp1;
- tmp12 = tmp0 + tmp2;
- tmp13 = tmp0 - tmp2;
-
- z1 = (JLONG)wsptr[2];
- z2 = (JLONG)wsptr[6];
- z3 = z1 - z2;
- z4 = MULTIPLY(z3, FIX(0.275899379)); /* c14[16] = c7[8] */
- z3 = MULTIPLY(z3, FIX(1.387039845)); /* c2[16] = c1[8] */
-
- tmp0 = z3 + MULTIPLY(z2, FIX_2_562915447); /* (c6+c2)[16] = (c3+c1)[8] */
- tmp1 = z4 + MULTIPLY(z1, FIX_0_899976223); /* (c6-c14)[16] = (c3-c7)[8] */
- tmp2 = z3 - MULTIPLY(z1, FIX(0.601344887)); /* (c2-c10)[16] = (c1-c5)[8] */
- tmp3 = z4 - MULTIPLY(z2, FIX(0.509795579)); /* (c10-c14)[16] = (c5-c7)[8] */
-
- tmp20 = tmp10 + tmp0;
- tmp27 = tmp10 - tmp0;
- tmp21 = tmp12 + tmp1;
- tmp26 = tmp12 - tmp1;
- tmp22 = tmp13 + tmp2;
- tmp25 = tmp13 - tmp2;
- tmp23 = tmp11 + tmp3;
- tmp24 = tmp11 - tmp3;
-
- /* Odd part */
-
- z1 = (JLONG)wsptr[1];
- z2 = (JLONG)wsptr[3];
- z3 = (JLONG)wsptr[5];
- z4 = (JLONG)wsptr[7];
-
- tmp11 = z1 + z3;
-
- tmp1 = MULTIPLY(z1 + z2, FIX(1.353318001)); /* c3 */
- tmp2 = MULTIPLY(tmp11, FIX(1.247225013)); /* c5 */
- tmp3 = MULTIPLY(z1 + z4, FIX(1.093201867)); /* c7 */
- tmp10 = MULTIPLY(z1 - z4, FIX(0.897167586)); /* c9 */
- tmp11 = MULTIPLY(tmp11, FIX(0.666655658)); /* c11 */
- tmp12 = MULTIPLY(z1 - z2, FIX(0.410524528)); /* c13 */
- tmp0 = tmp1 + tmp2 + tmp3 -
- MULTIPLY(z1, FIX(2.286341144)); /* c7+c5+c3-c1 */
- tmp13 = tmp10 + tmp11 + tmp12 -
- MULTIPLY(z1, FIX(1.835730603)); /* c9+c11+c13-c15 */
- z1 = MULTIPLY(z2 + z3, FIX(0.138617169)); /* c15 */
- tmp1 += z1 + MULTIPLY(z2, FIX(0.071888074)); /* c9+c11-c3-c15 */
- tmp2 += z1 - MULTIPLY(z3, FIX(1.125726048)); /* c5+c7+c15-c3 */
- z1 = MULTIPLY(z3 - z2, FIX(1.407403738)); /* c1 */
- tmp11 += z1 - MULTIPLY(z3, FIX(0.766367282)); /* c1+c11-c9-c13 */
- tmp12 += z1 + MULTIPLY(z2, FIX(1.971951411)); /* c1+c5+c13-c7 */
- z2 += z4;
- z1 = MULTIPLY(z2, -FIX(0.666655658)); /* -c11 */
- tmp1 += z1;
- tmp3 += z1 + MULTIPLY(z4, FIX(1.065388962)); /* c3+c11+c15-c7 */
- z2 = MULTIPLY(z2, -FIX(1.247225013)); /* -c5 */
- tmp10 += z2 + MULTIPLY(z4, FIX(3.141271809)); /* c1+c5+c9-c13 */
- tmp12 += z2;
- z2 = MULTIPLY(z3 + z4, -FIX(1.353318001)); /* -c3 */
- tmp2 += z2;
- tmp3 += z2;
- z2 = MULTIPLY(z4 - z3, FIX(0.410524528)); /* c13 */
- tmp10 += z2;
- tmp11 += z2;
-
- /* Final output stage */
-
- outptr[0] = range_limit[(int)RIGHT_SHIFT(tmp20 + tmp0,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[15] = range_limit[(int)RIGHT_SHIFT(tmp20 - tmp0,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[1] = range_limit[(int)RIGHT_SHIFT(tmp21 + tmp1,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[14] = range_limit[(int)RIGHT_SHIFT(tmp21 - tmp1,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[2] = range_limit[(int)RIGHT_SHIFT(tmp22 + tmp2,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[13] = range_limit[(int)RIGHT_SHIFT(tmp22 - tmp2,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[3] = range_limit[(int)RIGHT_SHIFT(tmp23 + tmp3,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[12] = range_limit[(int)RIGHT_SHIFT(tmp23 - tmp3,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[4] = range_limit[(int)RIGHT_SHIFT(tmp24 + tmp10,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[11] = range_limit[(int)RIGHT_SHIFT(tmp24 - tmp10,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[5] = range_limit[(int)RIGHT_SHIFT(tmp25 + tmp11,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[10] = range_limit[(int)RIGHT_SHIFT(tmp25 - tmp11,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[6] = range_limit[(int)RIGHT_SHIFT(tmp26 + tmp12,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[9] = range_limit[(int)RIGHT_SHIFT(tmp26 - tmp12,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[7] = range_limit[(int)RIGHT_SHIFT(tmp27 + tmp13,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
- outptr[8] = range_limit[(int)RIGHT_SHIFT(tmp27 - tmp13,
- CONST_BITS + PASS1_BITS + 3) &
- RANGE_MASK];
-
- wsptr += 8; /* advance pointer to next row */
- }
-}
-
-#endif /* IDCT_SCALING_SUPPORTED */
-#endif /* DCT_ISLOW_SUPPORTED */
diff --git a/contrib/libs/libjpeg-turbo/jidctred.c b/contrib/libs/libjpeg-turbo/jidctred.c
deleted file mode 100644
index 1dd65a94d9..0000000000
--- a/contrib/libs/libjpeg-turbo/jidctred.c
+++ /dev/null
@@ -1,409 +0,0 @@
-/*
- * jidctred.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1994-1998, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2015, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains inverse-DCT routines that produce reduced-size output:
- * either 4x4, 2x2, or 1x1 pixels from an 8x8 DCT block.
- *
- * The implementation is based on the Loeffler, Ligtenberg and Moschytz (LL&M)
- * algorithm used in jidctint.c. We simply replace each 8-to-8 1-D IDCT step
- * with an 8-to-4 step that produces the four averages of two adjacent outputs
- * (or an 8-to-2 step producing two averages of four outputs, for 2x2 output).
- * These steps were derived by computing the corresponding values at the end
- * of the normal LL&M code, then simplifying as much as possible.
- *
- * 1x1 is trivial: just take the DC coefficient divided by 8.
- *
- * See jidctint.c for additional comments.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-#include "jdct.h" /* Private declarations for DCT subsystem */
-
-#ifdef IDCT_SCALING_SUPPORTED
-
-
-/*
- * This module is specialized to the case DCTSIZE = 8.
- */
-
-#if DCTSIZE != 8
- Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */
-#endif
-
-
-/* Scaling is the same as in jidctint.c. */
-
-#if BITS_IN_JSAMPLE == 8
-#define CONST_BITS 13
-#define PASS1_BITS 2
-#else
-#define CONST_BITS 13
-#define PASS1_BITS 1 /* lose a little precision to avoid overflow */
-#endif
-
-/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus
- * causing a lot of useless floating-point operations at run time.
- * To get around this we use the following pre-calculated constants.
- * If you change CONST_BITS you may want to add appropriate values.
- * (With a reasonable C compiler, you can just rely on the FIX() macro...)
- */
-
-#if CONST_BITS == 13
-#define FIX_0_211164243 ((JLONG)1730) /* FIX(0.211164243) */
-#define FIX_0_509795579 ((JLONG)4176) /* FIX(0.509795579) */
-#define FIX_0_601344887 ((JLONG)4926) /* FIX(0.601344887) */
-#define FIX_0_720959822 ((JLONG)5906) /* FIX(0.720959822) */
-#define FIX_0_765366865 ((JLONG)6270) /* FIX(0.765366865) */
-#define FIX_0_850430095 ((JLONG)6967) /* FIX(0.850430095) */
-#define FIX_0_899976223 ((JLONG)7373) /* FIX(0.899976223) */
-#define FIX_1_061594337 ((JLONG)8697) /* FIX(1.061594337) */
-#define FIX_1_272758580 ((JLONG)10426) /* FIX(1.272758580) */
-#define FIX_1_451774981 ((JLONG)11893) /* FIX(1.451774981) */
-#define FIX_1_847759065 ((JLONG)15137) /* FIX(1.847759065) */
-#define FIX_2_172734803 ((JLONG)17799) /* FIX(2.172734803) */
-#define FIX_2_562915447 ((JLONG)20995) /* FIX(2.562915447) */
-#define FIX_3_624509785 ((JLONG)29692) /* FIX(3.624509785) */
-#else
-#define FIX_0_211164243 FIX(0.211164243)
-#define FIX_0_509795579 FIX(0.509795579)
-#define FIX_0_601344887 FIX(0.601344887)
-#define FIX_0_720959822 FIX(0.720959822)
-#define FIX_0_765366865 FIX(0.765366865)
-#define FIX_0_850430095 FIX(0.850430095)
-#define FIX_0_899976223 FIX(0.899976223)
-#define FIX_1_061594337 FIX(1.061594337)
-#define FIX_1_272758580 FIX(1.272758580)
-#define FIX_1_451774981 FIX(1.451774981)
-#define FIX_1_847759065 FIX(1.847759065)
-#define FIX_2_172734803 FIX(2.172734803)
-#define FIX_2_562915447 FIX(2.562915447)
-#define FIX_3_624509785 FIX(3.624509785)
-#endif
-
-
-/* Multiply a JLONG variable by a JLONG constant to yield a JLONG result.
- * For 8-bit samples with the recommended scaling, all the variable
- * and constant values involved are no more than 16 bits wide, so a
- * 16x16->32 bit multiply can be used instead of a full 32x32 multiply.
- * For 12-bit samples, a full 32-bit multiplication will be needed.
- */
-
-#if BITS_IN_JSAMPLE == 8
-#define MULTIPLY(var, const) MULTIPLY16C16(var, const)
-#else
-#define MULTIPLY(var, const) ((var) * (const))
-#endif
-
-
-/* Dequantize a coefficient by multiplying it by the multiplier-table
- * entry; produce an int result. In this module, both inputs and result
- * are 16 bits or less, so either int or short multiply will work.
- */
-
-#define DEQUANTIZE(coef, quantval) (((ISLOW_MULT_TYPE)(coef)) * (quantval))
-
-
-/*
- * Perform dequantization and inverse DCT on one block of coefficients,
- * producing a reduced-size 4x4 output block.
- */
-
-GLOBAL(void)
-jpeg_idct_4x4(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
- JLONG tmp0, tmp2, tmp10, tmp12;
- JLONG z1, z2, z3, z4;
- JCOEFPTR inptr;
- ISLOW_MULT_TYPE *quantptr;
- int *wsptr;
- JSAMPROW outptr;
- JSAMPLE *range_limit = IDCT_range_limit(cinfo);
- int ctr;
- int workspace[DCTSIZE * 4]; /* buffers data between passes */
- SHIFT_TEMPS
-
- /* Pass 1: process columns from input, store into work array. */
-
- inptr = coef_block;
- quantptr = (ISLOW_MULT_TYPE *)compptr->dct_table;
- wsptr = workspace;
- for (ctr = DCTSIZE; ctr > 0; inptr++, quantptr++, wsptr++, ctr--) {
- /* Don't bother to process column 4, because second pass won't use it */
- if (ctr == DCTSIZE - 4)
- continue;
- if (inptr[DCTSIZE * 1] == 0 && inptr[DCTSIZE * 2] == 0 &&
- inptr[DCTSIZE * 3] == 0 && inptr[DCTSIZE * 5] == 0 &&
- inptr[DCTSIZE * 6] == 0 && inptr[DCTSIZE * 7] == 0) {
- /* AC terms all zero; we need not examine term 4 for 4x4 output */
- int dcval = LEFT_SHIFT(DEQUANTIZE(inptr[DCTSIZE * 0],
- quantptr[DCTSIZE * 0]), PASS1_BITS);
-
- wsptr[DCTSIZE * 0] = dcval;
- wsptr[DCTSIZE * 1] = dcval;
- wsptr[DCTSIZE * 2] = dcval;
- wsptr[DCTSIZE * 3] = dcval;
-
- continue;
- }
-
- /* Even part */
-
- tmp0 = DEQUANTIZE(inptr[DCTSIZE * 0], quantptr[DCTSIZE * 0]);
- tmp0 = LEFT_SHIFT(tmp0, CONST_BITS + 1);
-
- z2 = DEQUANTIZE(inptr[DCTSIZE * 2], quantptr[DCTSIZE * 2]);
- z3 = DEQUANTIZE(inptr[DCTSIZE * 6], quantptr[DCTSIZE * 6]);
-
- tmp2 = MULTIPLY(z2, FIX_1_847759065) + MULTIPLY(z3, -FIX_0_765366865);
-
- tmp10 = tmp0 + tmp2;
- tmp12 = tmp0 - tmp2;
-
- /* Odd part */
-
- z1 = DEQUANTIZE(inptr[DCTSIZE * 7], quantptr[DCTSIZE * 7]);
- z2 = DEQUANTIZE(inptr[DCTSIZE * 5], quantptr[DCTSIZE * 5]);
- z3 = DEQUANTIZE(inptr[DCTSIZE * 3], quantptr[DCTSIZE * 3]);
- z4 = DEQUANTIZE(inptr[DCTSIZE * 1], quantptr[DCTSIZE * 1]);
-
- tmp0 = MULTIPLY(z1, -FIX_0_211164243) + /* sqrt(2) * ( c3-c1) */
- MULTIPLY(z2, FIX_1_451774981) + /* sqrt(2) * ( c3+c7) */
- MULTIPLY(z3, -FIX_2_172734803) + /* sqrt(2) * (-c1-c5) */
- MULTIPLY(z4, FIX_1_061594337); /* sqrt(2) * ( c5+c7) */
-
- tmp2 = MULTIPLY(z1, -FIX_0_509795579) + /* sqrt(2) * (c7-c5) */
- MULTIPLY(z2, -FIX_0_601344887) + /* sqrt(2) * (c5-c1) */
- MULTIPLY(z3, FIX_0_899976223) + /* sqrt(2) * (c3-c7) */
- MULTIPLY(z4, FIX_2_562915447); /* sqrt(2) * (c1+c3) */
-
- /* Final output stage */
-
- wsptr[DCTSIZE * 0] =
- (int)DESCALE(tmp10 + tmp2, CONST_BITS - PASS1_BITS + 1);
- wsptr[DCTSIZE * 3] =
- (int)DESCALE(tmp10 - tmp2, CONST_BITS - PASS1_BITS + 1);
- wsptr[DCTSIZE * 1] =
- (int)DESCALE(tmp12 + tmp0, CONST_BITS - PASS1_BITS + 1);
- wsptr[DCTSIZE * 2] =
- (int)DESCALE(tmp12 - tmp0, CONST_BITS - PASS1_BITS + 1);
- }
-
- /* Pass 2: process 4 rows from work array, store into output array. */
-
- wsptr = workspace;
- for (ctr = 0; ctr < 4; ctr++) {
- outptr = output_buf[ctr] + output_col;
- /* It's not clear whether a zero row test is worthwhile here ... */
-
-#ifndef NO_ZERO_ROW_TEST
- if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 &&
- wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) {
- /* AC terms all zero */
- JSAMPLE dcval = range_limit[(int)DESCALE((JLONG)wsptr[0],
- PASS1_BITS + 3) & RANGE_MASK];
-
- outptr[0] = dcval;
- outptr[1] = dcval;
- outptr[2] = dcval;
- outptr[3] = dcval;
-
- wsptr += DCTSIZE; /* advance pointer to next row */
- continue;
- }
-#endif
-
- /* Even part */
-
- tmp0 = LEFT_SHIFT((JLONG)wsptr[0], CONST_BITS + 1);
-
- tmp2 = MULTIPLY((JLONG)wsptr[2], FIX_1_847759065) +
- MULTIPLY((JLONG)wsptr[6], -FIX_0_765366865);
-
- tmp10 = tmp0 + tmp2;
- tmp12 = tmp0 - tmp2;
-
- /* Odd part */
-
- z1 = (JLONG)wsptr[7];
- z2 = (JLONG)wsptr[5];
- z3 = (JLONG)wsptr[3];
- z4 = (JLONG)wsptr[1];
-
- tmp0 = MULTIPLY(z1, -FIX_0_211164243) + /* sqrt(2) * ( c3-c1) */
- MULTIPLY(z2, FIX_1_451774981) + /* sqrt(2) * ( c3+c7) */
- MULTIPLY(z3, -FIX_2_172734803) + /* sqrt(2) * (-c1-c5) */
- MULTIPLY(z4, FIX_1_061594337); /* sqrt(2) * ( c5+c7) */
-
- tmp2 = MULTIPLY(z1, -FIX_0_509795579) + /* sqrt(2) * (c7-c5) */
- MULTIPLY(z2, -FIX_0_601344887) + /* sqrt(2) * (c5-c1) */
- MULTIPLY(z3, FIX_0_899976223) + /* sqrt(2) * (c3-c7) */
- MULTIPLY(z4, FIX_2_562915447); /* sqrt(2) * (c1+c3) */
-
- /* Final output stage */
-
- outptr[0] = range_limit[(int)DESCALE(tmp10 + tmp2,
- CONST_BITS + PASS1_BITS + 3 + 1) &
- RANGE_MASK];
- outptr[3] = range_limit[(int)DESCALE(tmp10 - tmp2,
- CONST_BITS + PASS1_BITS + 3 + 1) &
- RANGE_MASK];
- outptr[1] = range_limit[(int)DESCALE(tmp12 + tmp0,
- CONST_BITS + PASS1_BITS + 3 + 1) &
- RANGE_MASK];
- outptr[2] = range_limit[(int)DESCALE(tmp12 - tmp0,
- CONST_BITS + PASS1_BITS + 3 + 1) &
- RANGE_MASK];
-
- wsptr += DCTSIZE; /* advance pointer to next row */
- }
-}
-
-
-/*
- * Perform dequantization and inverse DCT on one block of coefficients,
- * producing a reduced-size 2x2 output block.
- */
-
-GLOBAL(void)
-jpeg_idct_2x2(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
- JLONG tmp0, tmp10, z1;
- JCOEFPTR inptr;
- ISLOW_MULT_TYPE *quantptr;
- int *wsptr;
- JSAMPROW outptr;
- JSAMPLE *range_limit = IDCT_range_limit(cinfo);
- int ctr;
- int workspace[DCTSIZE * 2]; /* buffers data between passes */
- SHIFT_TEMPS
-
- /* Pass 1: process columns from input, store into work array. */
-
- inptr = coef_block;
- quantptr = (ISLOW_MULT_TYPE *)compptr->dct_table;
- wsptr = workspace;
- for (ctr = DCTSIZE; ctr > 0; inptr++, quantptr++, wsptr++, ctr--) {
- /* Don't bother to process columns 2,4,6 */
- if (ctr == DCTSIZE - 2 || ctr == DCTSIZE - 4 || ctr == DCTSIZE - 6)
- continue;
- if (inptr[DCTSIZE * 1] == 0 && inptr[DCTSIZE * 3] == 0 &&
- inptr[DCTSIZE * 5] == 0 && inptr[DCTSIZE * 7] == 0) {
- /* AC terms all zero; we need not examine terms 2,4,6 for 2x2 output */
- int dcval = LEFT_SHIFT(DEQUANTIZE(inptr[DCTSIZE * 0],
- quantptr[DCTSIZE * 0]), PASS1_BITS);
-
- wsptr[DCTSIZE * 0] = dcval;
- wsptr[DCTSIZE * 1] = dcval;
-
- continue;
- }
-
- /* Even part */
-
- z1 = DEQUANTIZE(inptr[DCTSIZE * 0], quantptr[DCTSIZE * 0]);
- tmp10 = LEFT_SHIFT(z1, CONST_BITS + 2);
-
- /* Odd part */
-
- z1 = DEQUANTIZE(inptr[DCTSIZE * 7], quantptr[DCTSIZE * 7]);
- tmp0 = MULTIPLY(z1, -FIX_0_720959822); /* sqrt(2) * ( c7-c5+c3-c1) */
- z1 = DEQUANTIZE(inptr[DCTSIZE * 5], quantptr[DCTSIZE * 5]);
- tmp0 += MULTIPLY(z1, FIX_0_850430095); /* sqrt(2) * (-c1+c3+c5+c7) */
- z1 = DEQUANTIZE(inptr[DCTSIZE * 3], quantptr[DCTSIZE * 3]);
- tmp0 += MULTIPLY(z1, -FIX_1_272758580); /* sqrt(2) * (-c1+c3-c5-c7) */
- z1 = DEQUANTIZE(inptr[DCTSIZE * 1], quantptr[DCTSIZE * 1]);
- tmp0 += MULTIPLY(z1, FIX_3_624509785); /* sqrt(2) * ( c1+c3+c5+c7) */
-
- /* Final output stage */
-
- wsptr[DCTSIZE * 0] =
- (int)DESCALE(tmp10 + tmp0, CONST_BITS - PASS1_BITS + 2);
- wsptr[DCTSIZE * 1] =
- (int)DESCALE(tmp10 - tmp0, CONST_BITS - PASS1_BITS + 2);
- }
-
- /* Pass 2: process 2 rows from work array, store into output array. */
-
- wsptr = workspace;
- for (ctr = 0; ctr < 2; ctr++) {
- outptr = output_buf[ctr] + output_col;
- /* It's not clear whether a zero row test is worthwhile here ... */
-
-#ifndef NO_ZERO_ROW_TEST
- if (wsptr[1] == 0 && wsptr[3] == 0 && wsptr[5] == 0 && wsptr[7] == 0) {
- /* AC terms all zero */
- JSAMPLE dcval = range_limit[(int)DESCALE((JLONG)wsptr[0],
- PASS1_BITS + 3) & RANGE_MASK];
-
- outptr[0] = dcval;
- outptr[1] = dcval;
-
- wsptr += DCTSIZE; /* advance pointer to next row */
- continue;
- }
-#endif
-
- /* Even part */
-
- tmp10 = LEFT_SHIFT((JLONG)wsptr[0], CONST_BITS + 2);
-
- /* Odd part */
-
- tmp0 = MULTIPLY((JLONG)wsptr[7], -FIX_0_720959822) + /* sqrt(2) * ( c7-c5+c3-c1) */
- MULTIPLY((JLONG)wsptr[5], FIX_0_850430095) + /* sqrt(2) * (-c1+c3+c5+c7) */
- MULTIPLY((JLONG)wsptr[3], -FIX_1_272758580) + /* sqrt(2) * (-c1+c3-c5-c7) */
- MULTIPLY((JLONG)wsptr[1], FIX_3_624509785); /* sqrt(2) * ( c1+c3+c5+c7) */
-
- /* Final output stage */
-
- outptr[0] = range_limit[(int)DESCALE(tmp10 + tmp0,
- CONST_BITS + PASS1_BITS + 3 + 2) &
- RANGE_MASK];
- outptr[1] = range_limit[(int)DESCALE(tmp10 - tmp0,
- CONST_BITS + PASS1_BITS + 3 + 2) &
- RANGE_MASK];
-
- wsptr += DCTSIZE; /* advance pointer to next row */
- }
-}
-
-
-/*
- * Perform dequantization and inverse DCT on one block of coefficients,
- * producing a reduced-size 1x1 output block.
- */
-
-GLOBAL(void)
-jpeg_idct_1x1(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
- int dcval;
- ISLOW_MULT_TYPE *quantptr;
- JSAMPLE *range_limit = IDCT_range_limit(cinfo);
- SHIFT_TEMPS
-
- /* We hardly need an inverse DCT routine for this: just take the
- * average pixel value, which is one-eighth of the DC coefficient.
- */
- quantptr = (ISLOW_MULT_TYPE *)compptr->dct_table;
- dcval = DEQUANTIZE(coef_block[0], quantptr[0]);
- dcval = (int)DESCALE((JLONG)dcval, 3);
-
- output_buf[0][output_col] = range_limit[dcval & RANGE_MASK];
-}
-
-#endif /* IDCT_SCALING_SUPPORTED */
diff --git a/contrib/libs/libjpeg-turbo/jinclude.h b/contrib/libs/libjpeg-turbo/jinclude.h
deleted file mode 100644
index 8910e620f0..0000000000
--- a/contrib/libs/libjpeg-turbo/jinclude.h
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * jinclude.h
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1994, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file exists to provide a single place to fix any problems with
- * including the wrong system include files. (Common problems are taken
- * care of by the standard jconfig symbols, but on really weird systems
- * you may have to edit this file.)
- *
- * NOTE: this file is NOT intended to be included by applications using the
- * JPEG library. Most applications need only include jpeglib.h.
- */
-
-#ifndef __JINCLUDE_H__
-#define __JINCLUDE_H__
-
-/* Include auto-config file to find out which system include files we need. */
-
-#include "jconfig.h" /* auto configuration options */
-#include "jconfigint.h"
-#define JCONFIG_INCLUDED /* so that jpeglib.h doesn't do it again */
-
-/*
- * Note that the core JPEG library does not require <stdio.h>;
- * only the default error handler and data source/destination modules do.
- * But we must pull it in because of the references to FILE in jpeglib.h.
- * You can remove those references if you want to compile without <stdio.h>.
- */
-
-#include <stddef.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-/*
- * These macros/inline functions facilitate using Microsoft's "safe string"
- * functions with Visual Studio builds without the need to scatter #ifdefs
- * throughout the code base.
- */
-
-
-#ifdef _MSC_VER
-
-#define SNPRINTF(str, n, format, ...) \
- _snprintf_s(str, n, _TRUNCATE, format, ##__VA_ARGS__)
-
-#else
-
-#define SNPRINTF snprintf
-
-#endif
-
-
-#ifndef NO_GETENV
-
-#ifdef _MSC_VER
-
-static INLINE int GETENV_S(char *buffer, size_t buffer_size, const char *name)
-{
- size_t required_size;
-
- return (int)getenv_s(&required_size, buffer, buffer_size, name);
-}
-
-#else /* _MSC_VER */
-
-#include <errno.h>
-
-/* This provides a similar interface to the Microsoft/C11 getenv_s() function,
- * but other than parameter validation, it has no advantages over getenv().
- */
-
-static INLINE int GETENV_S(char *buffer, size_t buffer_size, const char *name)
-{
- char *env;
-
- if (!buffer) {
- if (buffer_size == 0)
- return 0;
- else
- return (errno = EINVAL);
- }
- if (buffer_size == 0)
- return (errno = EINVAL);
- if (!name) {
- *buffer = 0;
- return 0;
- }
-
- env = getenv(name);
- if (!env)
- {
- *buffer = 0;
- return 0;
- }
-
- if (strlen(env) + 1 > buffer_size) {
- *buffer = 0;
- return ERANGE;
- }
-
- strncpy(buffer, env, buffer_size);
-
- return 0;
-}
-
-#endif /* _MSC_VER */
-
-#endif /* NO_GETENV */
-
-
-#ifndef NO_PUTENV
-
-#ifdef _WIN32
-
-#define PUTENV_S(name, value) _putenv_s(name, value)
-
-#else
-
-/* This provides a similar interface to the Microsoft _putenv_s() function, but
- * other than parameter validation, it has no advantages over setenv().
- */
-
-static INLINE int PUTENV_S(const char *name, const char *value)
-{
- if (!name || !value)
- return (errno = EINVAL);
-
- setenv(name, value, 1);
-
- return errno;
-}
-
-#endif /* _WIN32 */
-
-#endif /* NO_PUTENV */
-
-#ifdef WITH_SANITIZER
-# define malloc(sz) calloc((sz), 1)
-#endif
-
-
-#endif /* JINCLUDE_H */
diff --git a/contrib/libs/libjpeg-turbo/jmemmgr.c b/contrib/libs/libjpeg-turbo/jmemmgr.c
deleted file mode 100644
index a40446f6ac..0000000000
--- a/contrib/libs/libjpeg-turbo/jmemmgr.c
+++ /dev/null
@@ -1,1180 +0,0 @@
-/*
- * jmemmgr.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2016, 2021-2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains the JPEG system-independent memory management
- * routines. This code is usable across a wide variety of machines; most
- * of the system dependencies have been isolated in a separate file.
- * The major functions provided here are:
- * * pool-based allocation and freeing of memory;
- * * policy decisions about how to divide available memory among the
- * virtual arrays;
- * * control logic for swapping virtual arrays between main memory and
- * backing storage.
- * The separate system-dependent file provides the actual backing-storage
- * access code, and it contains the policy decision about how much total
- * main memory to use.
- * This file is system-dependent in the sense that some of its functions
- * are unnecessary in some systems. For example, if there is enough virtual
- * memory so that backing storage will never be used, much of the virtual
- * array control logic could be removed. (Of course, if you have that much
- * memory then you shouldn't care about a little bit of unused code...)
- */
-
-#define JPEG_INTERNALS
-#define AM_MEMORY_MANAGER /* we define jvirt_Xarray_control structs */
-#include "jinclude.h"
-#include "jpeglib.h"
-#include "jmemsys.h" /* import the system-dependent declarations */
-#if !defined(_MSC_VER) || _MSC_VER > 1600
-#include <stdint.h>
-#endif
-#include <limits.h>
-
-
-LOCAL(size_t)
-round_up_pow2(size_t a, size_t b)
-/* a rounded up to the next multiple of b, i.e. ceil(a/b)*b */
-/* Assumes a >= 0, b > 0, and b is a power of 2 */
-{
- return ((a + b - 1) & (~(b - 1)));
-}
-
-
-/*
- * Some important notes:
- * The allocation routines provided here must never return NULL.
- * They should exit to error_exit if unsuccessful.
- *
- * It's not a good idea to try to merge the sarray and barray routines,
- * even though they are textually almost the same, because samples are
- * usually stored as bytes while coefficients are shorts or ints. Thus,
- * in machines where byte pointers have a different representation from
- * word pointers, the resulting machine code could not be the same.
- */
-
-
-/*
- * Many machines require storage alignment: longs must start on 4-byte
- * boundaries, doubles on 8-byte boundaries, etc. On such machines, malloc()
- * always returns pointers that are multiples of the worst-case alignment
- * requirement, and we had better do so too.
- * There isn't any really portable way to determine the worst-case alignment
- * requirement. This module assumes that the alignment requirement is
- * multiples of ALIGN_SIZE.
- * By default, we define ALIGN_SIZE as the maximum of sizeof(double) and
- * sizeof(void *). This is necessary on some workstations (where doubles
- * really do need 8-byte alignment) and will work fine on nearly everything.
- * We use the maximum of sizeof(double) and sizeof(void *) since sizeof(double)
- * may be insufficient, for example, on CHERI-enabled platforms with 16-byte
- * pointers and a 16-byte alignment requirement. If your machine has lesser
- * alignment needs, you can save a few bytes by making ALIGN_SIZE smaller.
- * The only place I know of where this will NOT work is certain Macintosh
- * 680x0 compilers that define double as a 10-byte IEEE extended float.
- * Doing 10-byte alignment is counterproductive because longwords won't be
- * aligned well. Put "#define ALIGN_SIZE 4" in jconfig.h if you have
- * such a compiler.
- */
-
-#ifndef ALIGN_SIZE /* so can override from jconfig.h */
-#ifndef WITH_SIMD
-#define ALIGN_SIZE MAX(sizeof(void *), sizeof(double))
-#else
-#define ALIGN_SIZE 32 /* Most of the SIMD instructions we support require
- 16-byte (128-bit) alignment, but AVX2 requires
- 32-byte alignment. */
-#endif
-#endif
-
-/*
- * We allocate objects from "pools", where each pool is gotten with a single
- * request to jpeg_get_small() or jpeg_get_large(). There is no per-object
- * overhead within a pool, except for alignment padding. Each pool has a
- * header with a link to the next pool of the same class.
- * Small and large pool headers are identical.
- */
-
-typedef struct small_pool_struct *small_pool_ptr;
-
-typedef struct small_pool_struct {
- small_pool_ptr next; /* next in list of pools */
- size_t bytes_used; /* how many bytes already used within pool */
- size_t bytes_left; /* bytes still available in this pool */
-} small_pool_hdr;
-
-typedef struct large_pool_struct *large_pool_ptr;
-
-typedef struct large_pool_struct {
- large_pool_ptr next; /* next in list of pools */
- size_t bytes_used; /* how many bytes already used within pool */
- size_t bytes_left; /* bytes still available in this pool */
-} large_pool_hdr;
-
-/*
- * Here is the full definition of a memory manager object.
- */
-
-typedef struct {
- struct jpeg_memory_mgr pub; /* public fields */
-
- /* Each pool identifier (lifetime class) names a linked list of pools. */
- small_pool_ptr small_list[JPOOL_NUMPOOLS];
- large_pool_ptr large_list[JPOOL_NUMPOOLS];
-
- /* Since we only have one lifetime class of virtual arrays, only one
- * linked list is necessary (for each datatype). Note that the virtual
- * array control blocks being linked together are actually stored somewhere
- * in the small-pool list.
- */
- jvirt_sarray_ptr virt_sarray_list;
- jvirt_barray_ptr virt_barray_list;
-
- /* This counts total space obtained from jpeg_get_small/large */
- size_t total_space_allocated;
-
- /* alloc_sarray and alloc_barray set this value for use by virtual
- * array routines.
- */
- JDIMENSION last_rowsperchunk; /* from most recent alloc_sarray/barray */
-} my_memory_mgr;
-
-typedef my_memory_mgr *my_mem_ptr;
-
-
-/*
- * The control blocks for virtual arrays.
- * Note that these blocks are allocated in the "small" pool area.
- * System-dependent info for the associated backing store (if any) is hidden
- * inside the backing_store_info struct.
- */
-
-struct jvirt_sarray_control {
- JSAMPARRAY mem_buffer; /* => the in-memory buffer */
- JDIMENSION rows_in_array; /* total virtual array height */
- JDIMENSION samplesperrow; /* width of array (and of memory buffer) */
- JDIMENSION maxaccess; /* max rows accessed by access_virt_sarray */
- JDIMENSION rows_in_mem; /* height of memory buffer */
- JDIMENSION rowsperchunk; /* allocation chunk size in mem_buffer */
- JDIMENSION cur_start_row; /* first logical row # in the buffer */
- JDIMENSION first_undef_row; /* row # of first uninitialized row */
- boolean pre_zero; /* pre-zero mode requested? */
- boolean dirty; /* do current buffer contents need written? */
- boolean b_s_open; /* is backing-store data valid? */
- jvirt_sarray_ptr next; /* link to next virtual sarray control block */
- backing_store_info b_s_info; /* System-dependent control info */
-};
-
-struct jvirt_barray_control {
- JBLOCKARRAY mem_buffer; /* => the in-memory buffer */
- JDIMENSION rows_in_array; /* total virtual array height */
- JDIMENSION blocksperrow; /* width of array (and of memory buffer) */
- JDIMENSION maxaccess; /* max rows accessed by access_virt_barray */
- JDIMENSION rows_in_mem; /* height of memory buffer */
- JDIMENSION rowsperchunk; /* allocation chunk size in mem_buffer */
- JDIMENSION cur_start_row; /* first logical row # in the buffer */
- JDIMENSION first_undef_row; /* row # of first uninitialized row */
- boolean pre_zero; /* pre-zero mode requested? */
- boolean dirty; /* do current buffer contents need written? */
- boolean b_s_open; /* is backing-store data valid? */
- jvirt_barray_ptr next; /* link to next virtual barray control block */
- backing_store_info b_s_info; /* System-dependent control info */
-};
-
-
-#ifdef MEM_STATS /* optional extra stuff for statistics */
-
-LOCAL(void)
-print_mem_stats(j_common_ptr cinfo, int pool_id)
-{
- my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
- small_pool_ptr shdr_ptr;
- large_pool_ptr lhdr_ptr;
-
- /* Since this is only a debugging stub, we can cheat a little by using
- * fprintf directly rather than going through the trace message code.
- * This is helpful because message parm array can't handle longs.
- */
- fprintf(stderr, "Freeing pool %d, total space = %ld\n",
- pool_id, mem->total_space_allocated);
-
- for (lhdr_ptr = mem->large_list[pool_id]; lhdr_ptr != NULL;
- lhdr_ptr = lhdr_ptr->next) {
- fprintf(stderr, " Large chunk used %ld\n", (long)lhdr_ptr->bytes_used);
- }
-
- for (shdr_ptr = mem->small_list[pool_id]; shdr_ptr != NULL;
- shdr_ptr = shdr_ptr->next) {
- fprintf(stderr, " Small chunk used %ld free %ld\n",
- (long)shdr_ptr->bytes_used, (long)shdr_ptr->bytes_left);
- }
-}
-
-#endif /* MEM_STATS */
-
-
-LOCAL(void)
-out_of_memory(j_common_ptr cinfo, int which)
-/* Report an out-of-memory error and stop execution */
-/* If we compiled MEM_STATS support, report alloc requests before dying */
-{
-#ifdef MEM_STATS
- cinfo->err->trace_level = 2; /* force self_destruct to report stats */
-#endif
- ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, which);
-}
-
-
-/*
- * Allocation of "small" objects.
- *
- * For these, we use pooled storage. When a new pool must be created,
- * we try to get enough space for the current request plus a "slop" factor,
- * where the slop will be the amount of leftover space in the new pool.
- * The speed vs. space tradeoff is largely determined by the slop values.
- * A different slop value is provided for each pool class (lifetime),
- * and we also distinguish the first pool of a class from later ones.
- * NOTE: the values given work fairly well on both 16- and 32-bit-int
- * machines, but may be too small if longs are 64 bits or more.
- *
- * Since we do not know what alignment malloc() gives us, we have to
- * allocate ALIGN_SIZE-1 extra space per pool to have room for alignment
- * adjustment.
- */
-
-static const size_t first_pool_slop[JPOOL_NUMPOOLS] = {
- 1600, /* first PERMANENT pool */
- 16000 /* first IMAGE pool */
-};
-
-static const size_t extra_pool_slop[JPOOL_NUMPOOLS] = {
- 0, /* additional PERMANENT pools */
- 5000 /* additional IMAGE pools */
-};
-
-#define MIN_SLOP 50 /* greater than 0 to avoid futile looping */
-
-
-METHODDEF(void *)
-alloc_small(j_common_ptr cinfo, int pool_id, size_t sizeofobject)
-/* Allocate a "small" object */
-{
- my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
- small_pool_ptr hdr_ptr, prev_hdr_ptr;
- char *data_ptr;
- size_t min_request, slop;
-
- /*
- * Round up the requested size to a multiple of ALIGN_SIZE in order
- * to assure alignment for the next object allocated in the same pool
- * and so that algorithms can straddle outside the proper area up
- * to the next alignment.
- */
- if (sizeofobject > MAX_ALLOC_CHUNK) {
- /* This prevents overflow/wrap-around in round_up_pow2() if sizeofobject
- is close to SIZE_MAX. */
- out_of_memory(cinfo, 7);
- }
- sizeofobject = round_up_pow2(sizeofobject, ALIGN_SIZE);
-
- /* Check for unsatisfiable request (do now to ensure no overflow below) */
- if ((sizeof(small_pool_hdr) + sizeofobject + ALIGN_SIZE - 1) >
- MAX_ALLOC_CHUNK)
- out_of_memory(cinfo, 1); /* request exceeds malloc's ability */
-
- /* See if space is available in any existing pool */
- if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS)
- ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */
- prev_hdr_ptr = NULL;
- hdr_ptr = mem->small_list[pool_id];
- while (hdr_ptr != NULL) {
- if (hdr_ptr->bytes_left >= sizeofobject)
- break; /* found pool with enough space */
- prev_hdr_ptr = hdr_ptr;
- hdr_ptr = hdr_ptr->next;
- }
-
- /* Time to make a new pool? */
- if (hdr_ptr == NULL) {
- /* min_request is what we need now, slop is what will be leftover */
- min_request = sizeof(small_pool_hdr) + sizeofobject + ALIGN_SIZE - 1;
- if (prev_hdr_ptr == NULL) /* first pool in class? */
- slop = first_pool_slop[pool_id];
- else
- slop = extra_pool_slop[pool_id];
- /* Don't ask for more than MAX_ALLOC_CHUNK */
- if (slop > (size_t)(MAX_ALLOC_CHUNK - min_request))
- slop = (size_t)(MAX_ALLOC_CHUNK - min_request);
- /* Try to get space, if fail reduce slop and try again */
- for (;;) {
- hdr_ptr = (small_pool_ptr)jpeg_get_small(cinfo, min_request + slop);
- if (hdr_ptr != NULL)
- break;
- slop /= 2;
- if (slop < MIN_SLOP) /* give up when it gets real small */
- out_of_memory(cinfo, 2); /* jpeg_get_small failed */
- }
- mem->total_space_allocated += min_request + slop;
- /* Success, initialize the new pool header and add to end of list */
- hdr_ptr->next = NULL;
- hdr_ptr->bytes_used = 0;
- hdr_ptr->bytes_left = sizeofobject + slop;
- if (prev_hdr_ptr == NULL) /* first pool in class? */
- mem->small_list[pool_id] = hdr_ptr;
- else
- prev_hdr_ptr->next = hdr_ptr;
- }
-
- /* OK, allocate the object from the current pool */
- data_ptr = (char *)hdr_ptr; /* point to first data byte in pool... */
- data_ptr += sizeof(small_pool_hdr); /* ...by skipping the header... */
- if ((size_t)data_ptr % ALIGN_SIZE) /* ...and adjust for alignment */
- data_ptr += ALIGN_SIZE - (size_t)data_ptr % ALIGN_SIZE;
- data_ptr += hdr_ptr->bytes_used; /* point to place for object */
- hdr_ptr->bytes_used += sizeofobject;
- hdr_ptr->bytes_left -= sizeofobject;
-
- return (void *)data_ptr;
-}
-
-
-/*
- * Allocation of "large" objects.
- *
- * The external semantics of these are the same as "small" objects. However,
- * the pool management heuristics are quite different. We assume that each
- * request is large enough that it may as well be passed directly to
- * jpeg_get_large; the pool management just links everything together
- * so that we can free it all on demand.
- * Note: the major use of "large" objects is in JSAMPARRAY and JBLOCKARRAY
- * structures. The routines that create these structures (see below)
- * deliberately bunch rows together to ensure a large request size.
- */
-
-METHODDEF(void *)
-alloc_large(j_common_ptr cinfo, int pool_id, size_t sizeofobject)
-/* Allocate a "large" object */
-{
- my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
- large_pool_ptr hdr_ptr;
- char *data_ptr;
-
- /*
- * Round up the requested size to a multiple of ALIGN_SIZE so that
- * algorithms can straddle outside the proper area up to the next
- * alignment.
- */
- if (sizeofobject > MAX_ALLOC_CHUNK) {
- /* This prevents overflow/wrap-around in round_up_pow2() if sizeofobject
- is close to SIZE_MAX. */
- out_of_memory(cinfo, 8);
- }
- sizeofobject = round_up_pow2(sizeofobject, ALIGN_SIZE);
-
- /* Check for unsatisfiable request (do now to ensure no overflow below) */
- if ((sizeof(large_pool_hdr) + sizeofobject + ALIGN_SIZE - 1) >
- MAX_ALLOC_CHUNK)
- out_of_memory(cinfo, 3); /* request exceeds malloc's ability */
-
- /* Always make a new pool */
- if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS)
- ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */
-
- hdr_ptr = (large_pool_ptr)jpeg_get_large(cinfo, sizeofobject +
- sizeof(large_pool_hdr) +
- ALIGN_SIZE - 1);
- if (hdr_ptr == NULL)
- out_of_memory(cinfo, 4); /* jpeg_get_large failed */
- mem->total_space_allocated += sizeofobject + sizeof(large_pool_hdr) +
- ALIGN_SIZE - 1;
-
- /* Success, initialize the new pool header and add to list */
- hdr_ptr->next = mem->large_list[pool_id];
- /* We maintain space counts in each pool header for statistical purposes,
- * even though they are not needed for allocation.
- */
- hdr_ptr->bytes_used = sizeofobject;
- hdr_ptr->bytes_left = 0;
- mem->large_list[pool_id] = hdr_ptr;
-
- data_ptr = (char *)hdr_ptr; /* point to first data byte in pool... */
- data_ptr += sizeof(small_pool_hdr); /* ...by skipping the header... */
- if ((size_t)data_ptr % ALIGN_SIZE) /* ...and adjust for alignment */
- data_ptr += ALIGN_SIZE - (size_t)data_ptr % ALIGN_SIZE;
-
- return (void *)data_ptr;
-}
-
-
-/*
- * Creation of 2-D sample arrays.
- *
- * To minimize allocation overhead and to allow I/O of large contiguous
- * blocks, we allocate the sample rows in groups of as many rows as possible
- * without exceeding MAX_ALLOC_CHUNK total bytes per allocation request.
- * NB: the virtual array control routines, later in this file, know about
- * this chunking of rows. The rowsperchunk value is left in the mem manager
- * object so that it can be saved away if this sarray is the workspace for
- * a virtual array.
- *
- * Since we are often upsampling with a factor 2, we align the size (not
- * the start) to 2 * ALIGN_SIZE so that the upsampling routines don't have
- * to be as careful about size.
- */
-
-METHODDEF(JSAMPARRAY)
-alloc_sarray(j_common_ptr cinfo, int pool_id, JDIMENSION samplesperrow,
- JDIMENSION numrows)
-/* Allocate a 2-D sample array */
-{
- my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
- JSAMPARRAY result;
- JSAMPROW workspace;
- JDIMENSION rowsperchunk, currow, i;
- long ltemp;
-
- /* Make sure each row is properly aligned */
- if ((ALIGN_SIZE % sizeof(JSAMPLE)) != 0)
- out_of_memory(cinfo, 5); /* safety check */
-
- if (samplesperrow > MAX_ALLOC_CHUNK) {
- /* This prevents overflow/wrap-around in round_up_pow2() if sizeofobject
- is close to SIZE_MAX. */
- out_of_memory(cinfo, 9);
- }
- samplesperrow = (JDIMENSION)round_up_pow2(samplesperrow, (2 * ALIGN_SIZE) /
- sizeof(JSAMPLE));
-
- /* Calculate max # of rows allowed in one allocation chunk */
- ltemp = (MAX_ALLOC_CHUNK - sizeof(large_pool_hdr)) /
- ((long)samplesperrow * sizeof(JSAMPLE));
- if (ltemp <= 0)
- ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
- if (ltemp < (long)numrows)
- rowsperchunk = (JDIMENSION)ltemp;
- else
- rowsperchunk = numrows;
- mem->last_rowsperchunk = rowsperchunk;
-
- /* Get space for row pointers (small object) */
- result = (JSAMPARRAY)alloc_small(cinfo, pool_id,
- (size_t)(numrows * sizeof(JSAMPROW)));
-
- /* Get the rows themselves (large objects) */
- currow = 0;
- while (currow < numrows) {
- rowsperchunk = MIN(rowsperchunk, numrows - currow);
- workspace = (JSAMPROW)alloc_large(cinfo, pool_id,
- (size_t)((size_t)rowsperchunk * (size_t)samplesperrow *
- sizeof(JSAMPLE)));
- for (i = rowsperchunk; i > 0; i--) {
- result[currow++] = workspace;
- workspace += samplesperrow;
- }
- }
-
- return result;
-}
-
-
-/*
- * Creation of 2-D coefficient-block arrays.
- * This is essentially the same as the code for sample arrays, above.
- */
-
-METHODDEF(JBLOCKARRAY)
-alloc_barray(j_common_ptr cinfo, int pool_id, JDIMENSION blocksperrow,
- JDIMENSION numrows)
-/* Allocate a 2-D coefficient-block array */
-{
- my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
- JBLOCKARRAY result;
- JBLOCKROW workspace;
- JDIMENSION rowsperchunk, currow, i;
- long ltemp;
-
- /* Make sure each row is properly aligned */
- if ((sizeof(JBLOCK) % ALIGN_SIZE) != 0)
- out_of_memory(cinfo, 6); /* safety check */
-
- /* Calculate max # of rows allowed in one allocation chunk */
- ltemp = (MAX_ALLOC_CHUNK - sizeof(large_pool_hdr)) /
- ((long)blocksperrow * sizeof(JBLOCK));
- if (ltemp <= 0)
- ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
- if (ltemp < (long)numrows)
- rowsperchunk = (JDIMENSION)ltemp;
- else
- rowsperchunk = numrows;
- mem->last_rowsperchunk = rowsperchunk;
-
- /* Get space for row pointers (small object) */
- result = (JBLOCKARRAY)alloc_small(cinfo, pool_id,
- (size_t)(numrows * sizeof(JBLOCKROW)));
-
- /* Get the rows themselves (large objects) */
- currow = 0;
- while (currow < numrows) {
- rowsperchunk = MIN(rowsperchunk, numrows - currow);
- workspace = (JBLOCKROW)alloc_large(cinfo, pool_id,
- (size_t)((size_t)rowsperchunk * (size_t)blocksperrow *
- sizeof(JBLOCK)));
- for (i = rowsperchunk; i > 0; i--) {
- result[currow++] = workspace;
- workspace += blocksperrow;
- }
- }
-
- return result;
-}
-
-
-/*
- * About virtual array management:
- *
- * The above "normal" array routines are only used to allocate strip buffers
- * (as wide as the image, but just a few rows high). Full-image-sized buffers
- * are handled as "virtual" arrays. The array is still accessed a strip at a
- * time, but the memory manager must save the whole array for repeated
- * accesses. The intended implementation is that there is a strip buffer in
- * memory (as high as is possible given the desired memory limit), plus a
- * backing file that holds the rest of the array.
- *
- * The request_virt_array routines are told the total size of the image and
- * the maximum number of rows that will be accessed at once. The in-memory
- * buffer must be at least as large as the maxaccess value.
- *
- * The request routines create control blocks but not the in-memory buffers.
- * That is postponed until realize_virt_arrays is called. At that time the
- * total amount of space needed is known (approximately, anyway), so free
- * memory can be divided up fairly.
- *
- * The access_virt_array routines are responsible for making a specific strip
- * area accessible (after reading or writing the backing file, if necessary).
- * Note that the access routines are told whether the caller intends to modify
- * the accessed strip; during a read-only pass this saves having to rewrite
- * data to disk. The access routines are also responsible for pre-zeroing
- * any newly accessed rows, if pre-zeroing was requested.
- *
- * In current usage, the access requests are usually for nonoverlapping
- * strips; that is, successive access start_row numbers differ by exactly
- * num_rows = maxaccess. This means we can get good performance with simple
- * buffer dump/reload logic, by making the in-memory buffer be a multiple
- * of the access height; then there will never be accesses across bufferload
- * boundaries. The code will still work with overlapping access requests,
- * but it doesn't handle bufferload overlaps very efficiently.
- */
-
-
-METHODDEF(jvirt_sarray_ptr)
-request_virt_sarray(j_common_ptr cinfo, int pool_id, boolean pre_zero,
- JDIMENSION samplesperrow, JDIMENSION numrows,
- JDIMENSION maxaccess)
-/* Request a virtual 2-D sample array */
-{
- my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
- jvirt_sarray_ptr result;
-
- /* Only IMAGE-lifetime virtual arrays are currently supported */
- if (pool_id != JPOOL_IMAGE)
- ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */
-
- /* get control block */
- result = (jvirt_sarray_ptr)alloc_small(cinfo, pool_id,
- sizeof(struct jvirt_sarray_control));
-
- result->mem_buffer = NULL; /* marks array not yet realized */
- result->rows_in_array = numrows;
- result->samplesperrow = samplesperrow;
- result->maxaccess = maxaccess;
- result->pre_zero = pre_zero;
- result->b_s_open = FALSE; /* no associated backing-store object */
- result->next = mem->virt_sarray_list; /* add to list of virtual arrays */
- mem->virt_sarray_list = result;
-
- return result;
-}
-
-
-METHODDEF(jvirt_barray_ptr)
-request_virt_barray(j_common_ptr cinfo, int pool_id, boolean pre_zero,
- JDIMENSION blocksperrow, JDIMENSION numrows,
- JDIMENSION maxaccess)
-/* Request a virtual 2-D coefficient-block array */
-{
- my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
- jvirt_barray_ptr result;
-
- /* Only IMAGE-lifetime virtual arrays are currently supported */
- if (pool_id != JPOOL_IMAGE)
- ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */
-
- /* get control block */
- result = (jvirt_barray_ptr)alloc_small(cinfo, pool_id,
- sizeof(struct jvirt_barray_control));
-
- result->mem_buffer = NULL; /* marks array not yet realized */
- result->rows_in_array = numrows;
- result->blocksperrow = blocksperrow;
- result->maxaccess = maxaccess;
- result->pre_zero = pre_zero;
- result->b_s_open = FALSE; /* no associated backing-store object */
- result->next = mem->virt_barray_list; /* add to list of virtual arrays */
- mem->virt_barray_list = result;
-
- return result;
-}
-
-
-METHODDEF(void)
-realize_virt_arrays(j_common_ptr cinfo)
-/* Allocate the in-memory buffers for any unrealized virtual arrays */
-{
- my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
- size_t space_per_minheight, maximum_space, avail_mem;
- size_t minheights, max_minheights;
- jvirt_sarray_ptr sptr;
- jvirt_barray_ptr bptr;
-
- /* Compute the minimum space needed (maxaccess rows in each buffer)
- * and the maximum space needed (full image height in each buffer).
- * These may be of use to the system-dependent jpeg_mem_available routine.
- */
- space_per_minheight = 0;
- maximum_space = 0;
- for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) {
- if (sptr->mem_buffer == NULL) { /* if not realized yet */
- size_t new_space = (long)sptr->rows_in_array *
- (long)sptr->samplesperrow * sizeof(JSAMPLE);
-
- space_per_minheight += (long)sptr->maxaccess *
- (long)sptr->samplesperrow * sizeof(JSAMPLE);
- if (SIZE_MAX - maximum_space < new_space)
- out_of_memory(cinfo, 10);
- maximum_space += new_space;
- }
- }
- for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) {
- if (bptr->mem_buffer == NULL) { /* if not realized yet */
- size_t new_space = (long)bptr->rows_in_array *
- (long)bptr->blocksperrow * sizeof(JBLOCK);
-
- space_per_minheight += (long)bptr->maxaccess *
- (long)bptr->blocksperrow * sizeof(JBLOCK);
- if (SIZE_MAX - maximum_space < new_space)
- out_of_memory(cinfo, 11);
- maximum_space += new_space;
- }
- }
-
- if (space_per_minheight <= 0)
- return; /* no unrealized arrays, no work */
-
- /* Determine amount of memory to actually use; this is system-dependent. */
- avail_mem = jpeg_mem_available(cinfo, space_per_minheight, maximum_space,
- mem->total_space_allocated);
-
- /* If the maximum space needed is available, make all the buffers full
- * height; otherwise parcel it out with the same number of minheights
- * in each buffer.
- */
- if (avail_mem >= maximum_space)
- max_minheights = 1000000000L;
- else {
- max_minheights = avail_mem / space_per_minheight;
- /* If there doesn't seem to be enough space, try to get the minimum
- * anyway. This allows a "stub" implementation of jpeg_mem_available().
- */
- if (max_minheights <= 0)
- max_minheights = 1;
- }
-
- /* Allocate the in-memory buffers and initialize backing store as needed. */
-
- for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) {
- if (sptr->mem_buffer == NULL) { /* if not realized yet */
- minheights = ((long)sptr->rows_in_array - 1L) / sptr->maxaccess + 1L;
- if (minheights <= max_minheights) {
- /* This buffer fits in memory */
- sptr->rows_in_mem = sptr->rows_in_array;
- } else {
- /* It doesn't fit in memory, create backing store. */
- sptr->rows_in_mem = (JDIMENSION)(max_minheights * sptr->maxaccess);
- jpeg_open_backing_store(cinfo, &sptr->b_s_info,
- (long)sptr->rows_in_array *
- (long)sptr->samplesperrow *
- (long)sizeof(JSAMPLE));
- sptr->b_s_open = TRUE;
- }
- sptr->mem_buffer = alloc_sarray(cinfo, JPOOL_IMAGE,
- sptr->samplesperrow, sptr->rows_in_mem);
- sptr->rowsperchunk = mem->last_rowsperchunk;
- sptr->cur_start_row = 0;
- sptr->first_undef_row = 0;
- sptr->dirty = FALSE;
- }
- }
-
- for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) {
- if (bptr->mem_buffer == NULL) { /* if not realized yet */
- minheights = ((long)bptr->rows_in_array - 1L) / bptr->maxaccess + 1L;
- if (minheights <= max_minheights) {
- /* This buffer fits in memory */
- bptr->rows_in_mem = bptr->rows_in_array;
- } else {
- /* It doesn't fit in memory, create backing store. */
- bptr->rows_in_mem = (JDIMENSION)(max_minheights * bptr->maxaccess);
- jpeg_open_backing_store(cinfo, &bptr->b_s_info,
- (long)bptr->rows_in_array *
- (long)bptr->blocksperrow *
- (long)sizeof(JBLOCK));
- bptr->b_s_open = TRUE;
- }
- bptr->mem_buffer = alloc_barray(cinfo, JPOOL_IMAGE,
- bptr->blocksperrow, bptr->rows_in_mem);
- bptr->rowsperchunk = mem->last_rowsperchunk;
- bptr->cur_start_row = 0;
- bptr->first_undef_row = 0;
- bptr->dirty = FALSE;
- }
- }
-}
-
-
-LOCAL(void)
-do_sarray_io(j_common_ptr cinfo, jvirt_sarray_ptr ptr, boolean writing)
-/* Do backing store read or write of a virtual sample array */
-{
- long bytesperrow, file_offset, byte_count, rows, thisrow, i;
-
- bytesperrow = (long)ptr->samplesperrow * sizeof(JSAMPLE);
- file_offset = ptr->cur_start_row * bytesperrow;
- /* Loop to read or write each allocation chunk in mem_buffer */
- for (i = 0; i < (long)ptr->rows_in_mem; i += ptr->rowsperchunk) {
- /* One chunk, but check for short chunk at end of buffer */
- rows = MIN((long)ptr->rowsperchunk, (long)ptr->rows_in_mem - i);
- /* Transfer no more than is currently defined */
- thisrow = (long)ptr->cur_start_row + i;
- rows = MIN(rows, (long)ptr->first_undef_row - thisrow);
- /* Transfer no more than fits in file */
- rows = MIN(rows, (long)ptr->rows_in_array - thisrow);
- if (rows <= 0) /* this chunk might be past end of file! */
- break;
- byte_count = rows * bytesperrow;
- if (writing)
- (*ptr->b_s_info.write_backing_store) (cinfo, &ptr->b_s_info,
- (void *)ptr->mem_buffer[i],
- file_offset, byte_count);
- else
- (*ptr->b_s_info.read_backing_store) (cinfo, &ptr->b_s_info,
- (void *)ptr->mem_buffer[i],
- file_offset, byte_count);
- file_offset += byte_count;
- }
-}
-
-
-LOCAL(void)
-do_barray_io(j_common_ptr cinfo, jvirt_barray_ptr ptr, boolean writing)
-/* Do backing store read or write of a virtual coefficient-block array */
-{
- long bytesperrow, file_offset, byte_count, rows, thisrow, i;
-
- bytesperrow = (long)ptr->blocksperrow * sizeof(JBLOCK);
- file_offset = ptr->cur_start_row * bytesperrow;
- /* Loop to read or write each allocation chunk in mem_buffer */
- for (i = 0; i < (long)ptr->rows_in_mem; i += ptr->rowsperchunk) {
- /* One chunk, but check for short chunk at end of buffer */
- rows = MIN((long)ptr->rowsperchunk, (long)ptr->rows_in_mem - i);
- /* Transfer no more than is currently defined */
- thisrow = (long)ptr->cur_start_row + i;
- rows = MIN(rows, (long)ptr->first_undef_row - thisrow);
- /* Transfer no more than fits in file */
- rows = MIN(rows, (long)ptr->rows_in_array - thisrow);
- if (rows <= 0) /* this chunk might be past end of file! */
- break;
- byte_count = rows * bytesperrow;
- if (writing)
- (*ptr->b_s_info.write_backing_store) (cinfo, &ptr->b_s_info,
- (void *)ptr->mem_buffer[i],
- file_offset, byte_count);
- else
- (*ptr->b_s_info.read_backing_store) (cinfo, &ptr->b_s_info,
- (void *)ptr->mem_buffer[i],
- file_offset, byte_count);
- file_offset += byte_count;
- }
-}
-
-
-METHODDEF(JSAMPARRAY)
-access_virt_sarray(j_common_ptr cinfo, jvirt_sarray_ptr ptr,
- JDIMENSION start_row, JDIMENSION num_rows, boolean writable)
-/* Access the part of a virtual sample array starting at start_row */
-/* and extending for num_rows rows. writable is true if */
-/* caller intends to modify the accessed area. */
-{
- JDIMENSION end_row = start_row + num_rows;
- JDIMENSION undef_row;
-
- /* debugging check */
- if (end_row > ptr->rows_in_array || num_rows > ptr->maxaccess ||
- ptr->mem_buffer == NULL)
- ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS);
-
- /* Make the desired part of the virtual array accessible */
- if (start_row < ptr->cur_start_row ||
- end_row > ptr->cur_start_row + ptr->rows_in_mem) {
- if (!ptr->b_s_open)
- ERREXIT(cinfo, JERR_VIRTUAL_BUG);
- /* Flush old buffer contents if necessary */
- if (ptr->dirty) {
- do_sarray_io(cinfo, ptr, TRUE);
- ptr->dirty = FALSE;
- }
- /* Decide what part of virtual array to access.
- * Algorithm: if target address > current window, assume forward scan,
- * load starting at target address. If target address < current window,
- * assume backward scan, load so that target area is top of window.
- * Note that when switching from forward write to forward read, will have
- * start_row = 0, so the limiting case applies and we load from 0 anyway.
- */
- if (start_row > ptr->cur_start_row) {
- ptr->cur_start_row = start_row;
- } else {
- /* use long arithmetic here to avoid overflow & unsigned problems */
- long ltemp;
-
- ltemp = (long)end_row - (long)ptr->rows_in_mem;
- if (ltemp < 0)
- ltemp = 0; /* don't fall off front end of file */
- ptr->cur_start_row = (JDIMENSION)ltemp;
- }
- /* Read in the selected part of the array.
- * During the initial write pass, we will do no actual read
- * because the selected part is all undefined.
- */
- do_sarray_io(cinfo, ptr, FALSE);
- }
- /* Ensure the accessed part of the array is defined; prezero if needed.
- * To improve locality of access, we only prezero the part of the array
- * that the caller is about to access, not the entire in-memory array.
- */
- if (ptr->first_undef_row < end_row) {
- if (ptr->first_undef_row < start_row) {
- if (writable) /* writer skipped over a section of array */
- ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS);
- undef_row = start_row; /* but reader is allowed to read ahead */
- } else {
- undef_row = ptr->first_undef_row;
- }
- if (writable)
- ptr->first_undef_row = end_row;
- if (ptr->pre_zero) {
- size_t bytesperrow = (size_t)ptr->samplesperrow * sizeof(JSAMPLE);
- undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */
- end_row -= ptr->cur_start_row;
- while (undef_row < end_row) {
- jzero_far((void *)ptr->mem_buffer[undef_row], bytesperrow);
- undef_row++;
- }
- } else {
- if (!writable) /* reader looking at undefined data */
- ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS);
- }
- }
- /* Flag the buffer dirty if caller will write in it */
- if (writable)
- ptr->dirty = TRUE;
- /* Return address of proper part of the buffer */
- return ptr->mem_buffer + (start_row - ptr->cur_start_row);
-}
-
-
-METHODDEF(JBLOCKARRAY)
-access_virt_barray(j_common_ptr cinfo, jvirt_barray_ptr ptr,
- JDIMENSION start_row, JDIMENSION num_rows, boolean writable)
-/* Access the part of a virtual block array starting at start_row */
-/* and extending for num_rows rows. writable is true if */
-/* caller intends to modify the accessed area. */
-{
- JDIMENSION end_row = start_row + num_rows;
- JDIMENSION undef_row;
-
- /* debugging check */
- if (end_row > ptr->rows_in_array || num_rows > ptr->maxaccess ||
- ptr->mem_buffer == NULL)
- ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS);
-
- /* Make the desired part of the virtual array accessible */
- if (start_row < ptr->cur_start_row ||
- end_row > ptr->cur_start_row + ptr->rows_in_mem) {
- if (!ptr->b_s_open)
- ERREXIT(cinfo, JERR_VIRTUAL_BUG);
- /* Flush old buffer contents if necessary */
- if (ptr->dirty) {
- do_barray_io(cinfo, ptr, TRUE);
- ptr->dirty = FALSE;
- }
- /* Decide what part of virtual array to access.
- * Algorithm: if target address > current window, assume forward scan,
- * load starting at target address. If target address < current window,
- * assume backward scan, load so that target area is top of window.
- * Note that when switching from forward write to forward read, will have
- * start_row = 0, so the limiting case applies and we load from 0 anyway.
- */
- if (start_row > ptr->cur_start_row) {
- ptr->cur_start_row = start_row;
- } else {
- /* use long arithmetic here to avoid overflow & unsigned problems */
- long ltemp;
-
- ltemp = (long)end_row - (long)ptr->rows_in_mem;
- if (ltemp < 0)
- ltemp = 0; /* don't fall off front end of file */
- ptr->cur_start_row = (JDIMENSION)ltemp;
- }
- /* Read in the selected part of the array.
- * During the initial write pass, we will do no actual read
- * because the selected part is all undefined.
- */
- do_barray_io(cinfo, ptr, FALSE);
- }
- /* Ensure the accessed part of the array is defined; prezero if needed.
- * To improve locality of access, we only prezero the part of the array
- * that the caller is about to access, not the entire in-memory array.
- */
- if (ptr->first_undef_row < end_row) {
- if (ptr->first_undef_row < start_row) {
- if (writable) /* writer skipped over a section of array */
- ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS);
- undef_row = start_row; /* but reader is allowed to read ahead */
- } else {
- undef_row = ptr->first_undef_row;
- }
- if (writable)
- ptr->first_undef_row = end_row;
- if (ptr->pre_zero) {
- size_t bytesperrow = (size_t)ptr->blocksperrow * sizeof(JBLOCK);
- undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */
- end_row -= ptr->cur_start_row;
- while (undef_row < end_row) {
- jzero_far((void *)ptr->mem_buffer[undef_row], bytesperrow);
- undef_row++;
- }
- } else {
- if (!writable) /* reader looking at undefined data */
- ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS);
- }
- }
- /* Flag the buffer dirty if caller will write in it */
- if (writable)
- ptr->dirty = TRUE;
- /* Return address of proper part of the buffer */
- return ptr->mem_buffer + (start_row - ptr->cur_start_row);
-}
-
-
-/*
- * Release all objects belonging to a specified pool.
- */
-
-METHODDEF(void)
-free_pool(j_common_ptr cinfo, int pool_id)
-{
- my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
- small_pool_ptr shdr_ptr;
- large_pool_ptr lhdr_ptr;
- size_t space_freed;
-
- if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS)
- ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */
-
-#ifdef MEM_STATS
- if (cinfo->err->trace_level > 1)
- print_mem_stats(cinfo, pool_id); /* print pool's memory usage statistics */
-#endif
-
- /* If freeing IMAGE pool, close any virtual arrays first */
- if (pool_id == JPOOL_IMAGE) {
- jvirt_sarray_ptr sptr;
- jvirt_barray_ptr bptr;
-
- for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) {
- if (sptr->b_s_open) { /* there may be no backing store */
- sptr->b_s_open = FALSE; /* prevent recursive close if error */
- (*sptr->b_s_info.close_backing_store) (cinfo, &sptr->b_s_info);
- }
- }
- mem->virt_sarray_list = NULL;
- for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) {
- if (bptr->b_s_open) { /* there may be no backing store */
- bptr->b_s_open = FALSE; /* prevent recursive close if error */
- (*bptr->b_s_info.close_backing_store) (cinfo, &bptr->b_s_info);
- }
- }
- mem->virt_barray_list = NULL;
- }
-
- /* Release large objects */
- lhdr_ptr = mem->large_list[pool_id];
- mem->large_list[pool_id] = NULL;
-
- while (lhdr_ptr != NULL) {
- large_pool_ptr next_lhdr_ptr = lhdr_ptr->next;
- space_freed = lhdr_ptr->bytes_used +
- lhdr_ptr->bytes_left +
- sizeof(large_pool_hdr) + ALIGN_SIZE - 1;
- jpeg_free_large(cinfo, (void *)lhdr_ptr, space_freed);
- mem->total_space_allocated -= space_freed;
- lhdr_ptr = next_lhdr_ptr;
- }
-
- /* Release small objects */
- shdr_ptr = mem->small_list[pool_id];
- mem->small_list[pool_id] = NULL;
-
- while (shdr_ptr != NULL) {
- small_pool_ptr next_shdr_ptr = shdr_ptr->next;
- space_freed = shdr_ptr->bytes_used + shdr_ptr->bytes_left +
- sizeof(small_pool_hdr) + ALIGN_SIZE - 1;
- jpeg_free_small(cinfo, (void *)shdr_ptr, space_freed);
- mem->total_space_allocated -= space_freed;
- shdr_ptr = next_shdr_ptr;
- }
-}
-
-
-/*
- * Close up shop entirely.
- * Note that this cannot be called unless cinfo->mem is non-NULL.
- */
-
-METHODDEF(void)
-self_destruct(j_common_ptr cinfo)
-{
- int pool;
-
- /* Close all backing store, release all memory.
- * Releasing pools in reverse order might help avoid fragmentation
- * with some (brain-damaged) malloc libraries.
- */
- for (pool = JPOOL_NUMPOOLS - 1; pool >= JPOOL_PERMANENT; pool--) {
- free_pool(cinfo, pool);
- }
-
- /* Release the memory manager control block too. */
- jpeg_free_small(cinfo, (void *)cinfo->mem, sizeof(my_memory_mgr));
- cinfo->mem = NULL; /* ensures I will be called only once */
-
- jpeg_mem_term(cinfo); /* system-dependent cleanup */
-}
-
-
-/*
- * Memory manager initialization.
- * When this is called, only the error manager pointer is valid in cinfo!
- */
-
-GLOBAL(void)
-jinit_memory_mgr(j_common_ptr cinfo)
-{
- my_mem_ptr mem;
- long max_to_use;
- int pool;
- size_t test_mac;
-
- cinfo->mem = NULL; /* for safety if init fails */
-
- /* Check for configuration errors.
- * sizeof(ALIGN_TYPE) should be a power of 2; otherwise, it probably
- * doesn't reflect any real hardware alignment requirement.
- * The test is a little tricky: for X>0, X and X-1 have no one-bits
- * in common if and only if X is a power of 2, ie has only one one-bit.
- * Some compilers may give an "unreachable code" warning here; ignore it.
- */
- if ((ALIGN_SIZE & (ALIGN_SIZE - 1)) != 0)
- ERREXIT(cinfo, JERR_BAD_ALIGN_TYPE);
- /* MAX_ALLOC_CHUNK must be representable as type size_t, and must be
- * a multiple of ALIGN_SIZE.
- * Again, an "unreachable code" warning may be ignored here.
- * But a "constant too large" warning means you need to fix MAX_ALLOC_CHUNK.
- */
- test_mac = (size_t)MAX_ALLOC_CHUNK;
- if ((long)test_mac != MAX_ALLOC_CHUNK ||
- (MAX_ALLOC_CHUNK % ALIGN_SIZE) != 0)
- ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK);
-
- max_to_use = jpeg_mem_init(cinfo); /* system-dependent initialization */
-
- /* Attempt to allocate memory manager's control block */
- mem = (my_mem_ptr)jpeg_get_small(cinfo, sizeof(my_memory_mgr));
-
- if (mem == NULL) {
- jpeg_mem_term(cinfo); /* system-dependent cleanup */
- ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 0);
- }
-
- /* OK, fill in the method pointers */
- mem->pub.alloc_small = alloc_small;
- mem->pub.alloc_large = alloc_large;
- mem->pub.alloc_sarray = alloc_sarray;
- mem->pub.alloc_barray = alloc_barray;
- mem->pub.request_virt_sarray = request_virt_sarray;
- mem->pub.request_virt_barray = request_virt_barray;
- mem->pub.realize_virt_arrays = realize_virt_arrays;
- mem->pub.access_virt_sarray = access_virt_sarray;
- mem->pub.access_virt_barray = access_virt_barray;
- mem->pub.free_pool = free_pool;
- mem->pub.self_destruct = self_destruct;
-
- /* Make MAX_ALLOC_CHUNK accessible to other modules */
- mem->pub.max_alloc_chunk = MAX_ALLOC_CHUNK;
-
- /* Initialize working state */
- mem->pub.max_memory_to_use = max_to_use;
-
- for (pool = JPOOL_NUMPOOLS - 1; pool >= JPOOL_PERMANENT; pool--) {
- mem->small_list[pool] = NULL;
- mem->large_list[pool] = NULL;
- }
- mem->virt_sarray_list = NULL;
- mem->virt_barray_list = NULL;
-
- mem->total_space_allocated = sizeof(my_memory_mgr);
-
- /* Declare ourselves open for business */
- cinfo->mem = &mem->pub;
-
- /* Check for an environment variable JPEGMEM; if found, override the
- * default max_memory setting from jpeg_mem_init. Note that the
- * surrounding application may again override this value.
- * If your system doesn't support getenv(), define NO_GETENV to disable
- * this feature.
- */
-#ifndef NO_GETENV
- {
- char memenv[30] = { 0 };
-
- if (!GETENV_S(memenv, 30, "JPEGMEM") && strlen(memenv) > 0) {
- char ch = 'x';
-
-#ifdef _MSC_VER
- if (sscanf_s(memenv, "%ld%c", &max_to_use, &ch, 1) > 0) {
-#else
- if (sscanf(memenv, "%ld%c", &max_to_use, &ch) > 0) {
-#endif
- if (ch == 'm' || ch == 'M')
- max_to_use *= 1000L;
- mem->pub.max_memory_to_use = max_to_use * 1000L;
- }
- }
- }
-#endif
-
-}
diff --git a/contrib/libs/libjpeg-turbo/jmemnobs.c b/contrib/libs/libjpeg-turbo/jmemnobs.c
deleted file mode 100644
index cd6571ba1c..0000000000
--- a/contrib/libs/libjpeg-turbo/jmemnobs.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * jmemnobs.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1992-1996, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2017-2018, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file provides a really simple implementation of the system-
- * dependent portion of the JPEG memory manager. This implementation
- * assumes that no backing-store files are needed: all required space
- * can be obtained from malloc().
- * This is very portable in the sense that it'll compile on almost anything,
- * but you'd better have lots of main memory (or virtual memory) if you want
- * to process big images.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-#include "jmemsys.h" /* import the system-dependent declarations */
-
-
-/*
- * Memory allocation and freeing are controlled by the regular library
- * routines malloc() and free().
- */
-
-GLOBAL(void *)
-jpeg_get_small(j_common_ptr cinfo, size_t sizeofobject)
-{
- return (void *)malloc(sizeofobject);
-}
-
-GLOBAL(void)
-jpeg_free_small(j_common_ptr cinfo, void *object, size_t sizeofobject)
-{
- free(object);
-}
-
-
-/*
- * "Large" objects are treated the same as "small" ones.
- */
-
-GLOBAL(void *)
-jpeg_get_large(j_common_ptr cinfo, size_t sizeofobject)
-{
- return (void *)malloc(sizeofobject);
-}
-
-GLOBAL(void)
-jpeg_free_large(j_common_ptr cinfo, void *object, size_t sizeofobject)
-{
- free(object);
-}
-
-
-/*
- * This routine computes the total memory space available for allocation.
- */
-
-GLOBAL(size_t)
-jpeg_mem_available(j_common_ptr cinfo, size_t min_bytes_needed,
- size_t max_bytes_needed, size_t already_allocated)
-{
- if (cinfo->mem->max_memory_to_use) {
- if ((size_t)cinfo->mem->max_memory_to_use > already_allocated)
- return cinfo->mem->max_memory_to_use - already_allocated;
- else
- return 0;
- } else {
- /* Here we always say, "we got all you want bud!" */
- return max_bytes_needed;
- }
-}
-
-
-/*
- * Backing store (temporary file) management.
- * Since jpeg_mem_available always promised the moon,
- * this should never be called and we can just error out.
- */
-
-GLOBAL(void)
-jpeg_open_backing_store(j_common_ptr cinfo, backing_store_ptr info,
- long total_bytes_needed)
-{
- ERREXIT(cinfo, JERR_NO_BACKING_STORE);
-}
-
-
-/*
- * These routines take care of any system-dependent initialization and
- * cleanup required. Here, there isn't any.
- */
-
-GLOBAL(long)
-jpeg_mem_init(j_common_ptr cinfo)
-{
- return 0; /* just set max_memory_to_use to 0 */
-}
-
-GLOBAL(void)
-jpeg_mem_term(j_common_ptr cinfo)
-{
- /* no work */
-}
diff --git a/contrib/libs/libjpeg-turbo/jmemsys.h b/contrib/libs/libjpeg-turbo/jmemsys.h
deleted file mode 100644
index 9229550afd..0000000000
--- a/contrib/libs/libjpeg-turbo/jmemsys.h
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * jmemsys.h
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1992-1997, Thomas G. Lane.
- * It was modified by The libjpeg-turbo Project to include only code and
- * information relevant to libjpeg-turbo.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This include file defines the interface between the system-independent
- * and system-dependent portions of the JPEG memory manager. No other
- * modules need include it. (The system-independent portion is jmemmgr.c;
- * there are several different versions of the system-dependent portion.)
- *
- * This file works as-is for the system-dependent memory managers supplied
- * in the IJG distribution. You may need to modify it if you write a
- * custom memory manager. If system-dependent changes are needed in
- * this file, the best method is to #ifdef them based on a configuration
- * symbol supplied in jconfig.h.
- */
-
-
-/*
- * These two functions are used to allocate and release small chunks of
- * memory. (Typically the total amount requested through jpeg_get_small is
- * no more than 20K or so; this will be requested in chunks of a few K each.)
- * Behavior should be the same as for the standard library functions malloc
- * and free; in particular, jpeg_get_small must return NULL on failure.
- * On most systems, these ARE malloc and free. jpeg_free_small is passed the
- * size of the object being freed, just in case it's needed.
- */
-
-EXTERN(void *) jpeg_get_small(j_common_ptr cinfo, size_t sizeofobject);
-EXTERN(void) jpeg_free_small(j_common_ptr cinfo, void *object,
- size_t sizeofobject);
-
-/*
- * These two functions are used to allocate and release large chunks of
- * memory (up to the total free space designated by jpeg_mem_available).
- * These are identical to the jpeg_get/free_small routines; but we keep them
- * separate anyway, in case a different allocation strategy is desirable for
- * large chunks.
- */
-
-EXTERN(void *) jpeg_get_large(j_common_ptr cinfo, size_t sizeofobject);
-EXTERN(void) jpeg_free_large(j_common_ptr cinfo, void *object,
- size_t sizeofobject);
-
-/*
- * The macro MAX_ALLOC_CHUNK designates the maximum number of bytes that may
- * be requested in a single call to jpeg_get_large (and jpeg_get_small for that
- * matter, but that case should never come into play). This macro was needed
- * to model the 64Kb-segment-size limit of far addressing on 80x86 machines.
- * On machines with flat address spaces, any large constant may be used.
- *
- * NB: jmemmgr.c expects that MAX_ALLOC_CHUNK will be representable as type
- * size_t and will be a multiple of sizeof(align_type).
- */
-
-#ifndef MAX_ALLOC_CHUNK /* may be overridden in jconfig.h */
-#define MAX_ALLOC_CHUNK 1000000000L
-#endif
-
-/*
- * This routine computes the total space still available for allocation by
- * jpeg_get_large. If more space than this is needed, backing store will be
- * used. NOTE: any memory already allocated must not be counted.
- *
- * There is a minimum space requirement, corresponding to the minimum
- * feasible buffer sizes; jmemmgr.c will request that much space even if
- * jpeg_mem_available returns zero. The maximum space needed, enough to hold
- * all working storage in memory, is also passed in case it is useful.
- * Finally, the total space already allocated is passed. If no better
- * method is available, cinfo->mem->max_memory_to_use - already_allocated
- * is often a suitable calculation.
- *
- * It is OK for jpeg_mem_available to underestimate the space available
- * (that'll just lead to more backing-store access than is really necessary).
- * However, an overestimate will lead to failure. Hence it's wise to subtract
- * a slop factor from the true available space. 5% should be enough.
- *
- * On machines with lots of virtual memory, any large constant may be returned.
- * Conversely, zero may be returned to always use the minimum amount of memory.
- */
-
-EXTERN(size_t) jpeg_mem_available(j_common_ptr cinfo, size_t min_bytes_needed,
- size_t max_bytes_needed,
- size_t already_allocated);
-
-
-/*
- * This structure holds whatever state is needed to access a single
- * backing-store object. The read/write/close method pointers are called
- * by jmemmgr.c to manipulate the backing-store object; all other fields
- * are private to the system-dependent backing store routines.
- */
-
-#define TEMP_NAME_LENGTH 64 /* max length of a temporary file's name */
-
-
-#ifdef USE_MSDOS_MEMMGR /* DOS-specific junk */
-
-typedef unsigned short XMSH; /* type of extended-memory handles */
-typedef unsigned short EMSH; /* type of expanded-memory handles */
-
-typedef union {
- short file_handle; /* DOS file handle if it's a temp file */
- XMSH xms_handle; /* handle if it's a chunk of XMS */
- EMSH ems_handle; /* handle if it's a chunk of EMS */
-} handle_union;
-
-#endif /* USE_MSDOS_MEMMGR */
-
-#ifdef USE_MAC_MEMMGR /* Mac-specific junk */
-#include <Files.h>
-#endif /* USE_MAC_MEMMGR */
-
-
-typedef struct backing_store_struct *backing_store_ptr;
-
-typedef struct backing_store_struct {
- /* Methods for reading/writing/closing this backing-store object */
- void (*read_backing_store) (j_common_ptr cinfo, backing_store_ptr info,
- void *buffer_address, long file_offset,
- long byte_count);
- void (*write_backing_store) (j_common_ptr cinfo, backing_store_ptr info,
- void *buffer_address, long file_offset,
- long byte_count);
- void (*close_backing_store) (j_common_ptr cinfo, backing_store_ptr info);
-
- /* Private fields for system-dependent backing-store management */
-#ifdef USE_MSDOS_MEMMGR
- /* For the MS-DOS manager (jmemdos.c), we need: */
- handle_union handle; /* reference to backing-store storage object */
- char temp_name[TEMP_NAME_LENGTH]; /* name if it's a file */
-#else
-#ifdef USE_MAC_MEMMGR
- /* For the Mac manager (jmemmac.c), we need: */
- short temp_file; /* file reference number to temp file */
- FSSpec tempSpec; /* the FSSpec for the temp file */
- char temp_name[TEMP_NAME_LENGTH]; /* name if it's a file */
-#else
- /* For a typical implementation with temp files, we need: */
- FILE *temp_file; /* stdio reference to temp file */
- char temp_name[TEMP_NAME_LENGTH]; /* name of temp file */
-#endif
-#endif
-} backing_store_info;
-
-
-/*
- * Initial opening of a backing-store object. This must fill in the
- * read/write/close pointers in the object. The read/write routines
- * may take an error exit if the specified maximum file size is exceeded.
- * (If jpeg_mem_available always returns a large value, this routine can
- * just take an error exit.)
- */
-
-EXTERN(void) jpeg_open_backing_store(j_common_ptr cinfo,
- backing_store_ptr info,
- long total_bytes_needed);
-
-
-/*
- * These routines take care of any system-dependent initialization and
- * cleanup required. jpeg_mem_init will be called before anything is
- * allocated (and, therefore, nothing in cinfo is of use except the error
- * manager pointer). It should return a suitable default value for
- * max_memory_to_use; this may subsequently be overridden by the surrounding
- * application. (Note that max_memory_to_use is only important if
- * jpeg_mem_available chooses to consult it ... no one else will.)
- * jpeg_mem_term may assume that all requested memory has been freed and that
- * all opened backing-store objects have been closed.
- */
-
-EXTERN(long) jpeg_mem_init(j_common_ptr cinfo);
-EXTERN(void) jpeg_mem_term(j_common_ptr cinfo);
diff --git a/contrib/libs/libjpeg-turbo/jmorecfg.h b/contrib/libs/libjpeg-turbo/jmorecfg.h
deleted file mode 100644
index aabd91b9fc..0000000000
--- a/contrib/libs/libjpeg-turbo/jmorecfg.h
+++ /dev/null
@@ -1,382 +0,0 @@
-/*
- * jmorecfg.h
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * Modified 1997-2009 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2009, 2011, 2014-2015, 2018, 2020, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains additional configuration options that customize the
- * JPEG software for special applications or support machine-dependent
- * optimizations. Most users will not need to touch this file.
- */
-
-
-/*
- * Maximum number of components (color channels) allowed in JPEG image.
- * To meet the letter of Rec. ITU-T T.81 | ISO/IEC 10918-1, set this to 255.
- * However, darn few applications need more than 4 channels (maybe 5 for CMYK +
- * alpha mask). We recommend 10 as a reasonable compromise; use 4 if you are
- * really short on memory. (Each allowed component costs a hundred or so
- * bytes of storage, whether actually used in an image or not.)
- */
-
-#define MAX_COMPONENTS 10 /* maximum number of image components */
-
-
-/*
- * Basic data types.
- * You may need to change these if you have a machine with unusual data
- * type sizes; for example, "char" not 8 bits, "short" not 16 bits,
- * or "long" not 32 bits. We don't care whether "int" is 16 or 32 bits,
- * but it had better be at least 16.
- */
-
-/* Representation of a single sample (pixel element value).
- * We frequently allocate large arrays of these, so it's important to keep
- * them small. But if you have memory to burn and access to char or short
- * arrays is very slow on your hardware, you might want to change these.
- */
-
-#if BITS_IN_JSAMPLE == 8
-/* JSAMPLE should be the smallest type that will hold the values 0..255.
- */
-
-typedef unsigned char JSAMPLE;
-#define GETJSAMPLE(value) ((int)(value))
-
-#define MAXJSAMPLE 255
-#define CENTERJSAMPLE 128
-
-#endif /* BITS_IN_JSAMPLE == 8 */
-
-
-#if BITS_IN_JSAMPLE == 12
-/* JSAMPLE should be the smallest type that will hold the values 0..4095.
- * On nearly all machines "short" will do nicely.
- */
-
-typedef short JSAMPLE;
-#define GETJSAMPLE(value) ((int)(value))
-
-#define MAXJSAMPLE 4095
-#define CENTERJSAMPLE 2048
-
-#endif /* BITS_IN_JSAMPLE == 12 */
-
-
-/* Representation of a DCT frequency coefficient.
- * This should be a signed value of at least 16 bits; "short" is usually OK.
- * Again, we allocate large arrays of these, but you can change to int
- * if you have memory to burn and "short" is really slow.
- */
-
-typedef short JCOEF;
-
-
-/* Compressed datastreams are represented as arrays of JOCTET.
- * These must be EXACTLY 8 bits wide, at least once they are written to
- * external storage. Note that when using the stdio data source/destination
- * managers, this is also the data type passed to fread/fwrite.
- */
-
-typedef unsigned char JOCTET;
-#define GETJOCTET(value) (value)
-
-
-/* These typedefs are used for various table entries and so forth.
- * They must be at least as wide as specified; but making them too big
- * won't cost a huge amount of memory, so we don't provide special
- * extraction code like we did for JSAMPLE. (In other words, these
- * typedefs live at a different point on the speed/space tradeoff curve.)
- */
-
-/* UINT8 must hold at least the values 0..255. */
-
-typedef unsigned char UINT8;
-
-/* UINT16 must hold at least the values 0..65535. */
-
-typedef unsigned short UINT16;
-
-/* INT16 must hold at least the values -32768..32767. */
-
-#ifndef XMD_H /* X11/xmd.h correctly defines INT16 */
-typedef short INT16;
-#endif
-
-/* INT32 must hold at least signed 32-bit values.
- *
- * NOTE: The INT32 typedef dates back to libjpeg v5 (1994.) Integers were
- * sometimes 16-bit back then (MS-DOS), which is why INT32 is typedef'd to
- * long. It also wasn't common (or at least as common) in 1994 for INT32 to be
- * defined by platform headers. Since then, however, INT32 is defined in
- * several other common places:
- *
- * Xmd.h (X11 header) typedefs INT32 to int on 64-bit platforms and long on
- * 32-bit platforms (i.e always a 32-bit signed type.)
- *
- * basetsd.h (Win32 header) typedefs INT32 to int (always a 32-bit signed type
- * on modern platforms.)
- *
- * qglobal.h (Qt header) typedefs INT32 to int (always a 32-bit signed type on
- * modern platforms.)
- *
- * This is a recipe for conflict, since "long" and "int" aren't always
- * compatible types. Since the definition of INT32 has technically been part
- * of the libjpeg API for more than 20 years, we can't remove it, but we do not
- * use it internally any longer. We instead define a separate type (JLONG)
- * for internal use, which ensures that internal behavior will always be the
- * same regardless of any external headers that may be included.
- */
-
-#ifndef XMD_H /* X11/xmd.h correctly defines INT32 */
-#ifndef _BASETSD_H_ /* Microsoft defines it in basetsd.h */
-#ifndef _BASETSD_H /* MinGW is slightly different */
-#ifndef QGLOBAL_H /* Qt defines it in qglobal.h */
-//typedef long INT32;
-#endif
-#endif
-#endif
-#endif
-
-/* Datatype used for image dimensions. The JPEG standard only supports
- * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore
- * "unsigned int" is sufficient on all machines. However, if you need to
- * handle larger images and you don't mind deviating from the spec, you
- * can change this datatype. (Note that changing this datatype will
- * potentially require modifying the SIMD code. The x86-64 SIMD extensions,
- * in particular, assume a 32-bit JDIMENSION.)
- */
-
-typedef unsigned int JDIMENSION;
-
-#define JPEG_MAX_DIMENSION 65500L /* a tad under 64K to prevent overflows */
-
-
-/* These macros are used in all function definitions and extern declarations.
- * You could modify them if you need to change function linkage conventions;
- * in particular, you'll need to do that to make the library a Windows DLL.
- * Another application is to make all functions global for use with debuggers
- * or code profilers that require it.
- */
-
-/* a function called through method pointers: */
-#define METHODDEF(type) static type
-/* a function used only in its module: */
-#define LOCAL(type) static type
-/* a function referenced thru EXTERNs: */
-#define GLOBAL(type) type
-/* a reference to a GLOBAL function: */
-#define EXTERN(type) extern type
-
-
-/* Originally, this macro was used as a way of defining function prototypes
- * for both modern compilers as well as older compilers that did not support
- * prototype parameters. libjpeg-turbo has never supported these older,
- * non-ANSI compilers, but the macro is still included because there is some
- * software out there that uses it.
- */
-
-#define JMETHOD(type, methodname, arglist) type (*methodname) arglist
-
-
-/* libjpeg-turbo no longer supports platforms that have far symbols (MS-DOS),
- * but again, some software relies on this macro.
- */
-
-#undef FAR
-#define FAR
-
-
-/*
- * On a few systems, type boolean and/or its values FALSE, TRUE may appear
- * in standard header files. Or you may have conflicts with application-
- * specific header files that you want to include together with these files.
- * Defining HAVE_BOOLEAN before including jpeglib.h should make it work.
- */
-
-#ifndef HAVE_BOOLEAN
-typedef int boolean;
-#endif
-#ifndef FALSE /* in case these macros already exist */
-#define FALSE 0 /* values of boolean */
-#endif
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-
-/*
- * The remaining options affect code selection within the JPEG library,
- * but they don't need to be visible to most applications using the library.
- * To minimize application namespace pollution, the symbols won't be
- * defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined.
- */
-
-#ifdef JPEG_INTERNALS
-#define JPEG_INTERNAL_OPTIONS
-#endif
-
-#ifdef JPEG_INTERNAL_OPTIONS
-
-
-/*
- * These defines indicate whether to include various optional functions.
- * Undefining some of these symbols will produce a smaller but less capable
- * library. Note that you can leave certain source files out of the
- * compilation/linking process if you've #undef'd the corresponding symbols.
- * (You may HAVE to do that if your compiler doesn't like null source files.)
- */
-
-/* Capability options common to encoder and decoder: */
-
-#define DCT_ISLOW_SUPPORTED /* accurate integer method */
-#define DCT_IFAST_SUPPORTED /* less accurate int method [legacy feature] */
-#define DCT_FLOAT_SUPPORTED /* floating-point method [legacy feature] */
-
-/* Encoder capability options: */
-
-#define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
-#define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
-#define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */
-/* Note: if you selected 12-bit data precision, it is dangerous to turn off
- * ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only good for 8-bit
- * precision, so jchuff.c normally uses entropy optimization to compute
- * usable tables for higher precision. If you don't want to do optimization,
- * you'll have to supply different default Huffman tables.
- * The exact same statements apply for progressive JPEG: the default tables
- * don't work for progressive mode. (This may get fixed, however.)
- */
-#define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */
-
-/* Decoder capability options: */
-
-#define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
-#define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
-#define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */
-#define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */
-#define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */
-#undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */
-#define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */
-#define QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */
-#define QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */
-
-/* more capability options later, no doubt */
-
-
-/*
- * The RGB_RED, RGB_GREEN, RGB_BLUE, and RGB_PIXELSIZE macros are a vestigial
- * feature of libjpeg. The idea was that, if an application developer needed
- * to compress from/decompress to a BGR/BGRX/RGBX/XBGR/XRGB buffer, they could
- * change these macros, rebuild libjpeg, and link their application statically
- * with it. In reality, few people ever did this, because there were some
- * severe restrictions involved (cjpeg and djpeg no longer worked properly,
- * compressing/decompressing RGB JPEGs no longer worked properly, and the color
- * quantizer wouldn't work with pixel sizes other than 3.) Furthermore, since
- * all of the O/S-supplied versions of libjpeg were built with the default
- * values of RGB_RED, RGB_GREEN, RGB_BLUE, and RGB_PIXELSIZE, many applications
- * have come to regard these values as immutable.
- *
- * The libjpeg-turbo colorspace extensions provide a much cleaner way of
- * compressing from/decompressing to buffers with arbitrary component orders
- * and pixel sizes. Thus, we do not support changing the values of RGB_RED,
- * RGB_GREEN, RGB_BLUE, or RGB_PIXELSIZE. In addition to the restrictions
- * listed above, changing these values will also break the SIMD extensions and
- * the regression tests.
- */
-
-#define RGB_RED 0 /* Offset of Red in an RGB scanline element */
-#define RGB_GREEN 1 /* Offset of Green */
-#define RGB_BLUE 2 /* Offset of Blue */
-#define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */
-
-#define JPEG_NUMCS 17
-
-#define EXT_RGB_RED 0
-#define EXT_RGB_GREEN 1
-#define EXT_RGB_BLUE 2
-#define EXT_RGB_PIXELSIZE 3
-
-#define EXT_RGBX_RED 0
-#define EXT_RGBX_GREEN 1
-#define EXT_RGBX_BLUE 2
-#define EXT_RGBX_PIXELSIZE 4
-
-#define EXT_BGR_RED 2
-#define EXT_BGR_GREEN 1
-#define EXT_BGR_BLUE 0
-#define EXT_BGR_PIXELSIZE 3
-
-#define EXT_BGRX_RED 2
-#define EXT_BGRX_GREEN 1
-#define EXT_BGRX_BLUE 0
-#define EXT_BGRX_PIXELSIZE 4
-
-#define EXT_XBGR_RED 3
-#define EXT_XBGR_GREEN 2
-#define EXT_XBGR_BLUE 1
-#define EXT_XBGR_PIXELSIZE 4
-
-#define EXT_XRGB_RED 1
-#define EXT_XRGB_GREEN 2
-#define EXT_XRGB_BLUE 3
-#define EXT_XRGB_PIXELSIZE 4
-
-static const int rgb_red[JPEG_NUMCS] = {
- -1, -1, RGB_RED, -1, -1, -1, EXT_RGB_RED, EXT_RGBX_RED,
- EXT_BGR_RED, EXT_BGRX_RED, EXT_XBGR_RED, EXT_XRGB_RED,
- EXT_RGBX_RED, EXT_BGRX_RED, EXT_XBGR_RED, EXT_XRGB_RED,
- -1
-};
-
-static const int rgb_green[JPEG_NUMCS] = {
- -1, -1, RGB_GREEN, -1, -1, -1, EXT_RGB_GREEN, EXT_RGBX_GREEN,
- EXT_BGR_GREEN, EXT_BGRX_GREEN, EXT_XBGR_GREEN, EXT_XRGB_GREEN,
- EXT_RGBX_GREEN, EXT_BGRX_GREEN, EXT_XBGR_GREEN, EXT_XRGB_GREEN,
- -1
-};
-
-static const int rgb_blue[JPEG_NUMCS] = {
- -1, -1, RGB_BLUE, -1, -1, -1, EXT_RGB_BLUE, EXT_RGBX_BLUE,
- EXT_BGR_BLUE, EXT_BGRX_BLUE, EXT_XBGR_BLUE, EXT_XRGB_BLUE,
- EXT_RGBX_BLUE, EXT_BGRX_BLUE, EXT_XBGR_BLUE, EXT_XRGB_BLUE,
- -1
-};
-
-static const int rgb_pixelsize[JPEG_NUMCS] = {
- -1, -1, RGB_PIXELSIZE, -1, -1, -1, EXT_RGB_PIXELSIZE, EXT_RGBX_PIXELSIZE,
- EXT_BGR_PIXELSIZE, EXT_BGRX_PIXELSIZE, EXT_XBGR_PIXELSIZE, EXT_XRGB_PIXELSIZE,
- EXT_RGBX_PIXELSIZE, EXT_BGRX_PIXELSIZE, EXT_XBGR_PIXELSIZE, EXT_XRGB_PIXELSIZE,
- -1
-};
-
-/* Definitions for speed-related optimizations. */
-
-/* On some machines (notably 68000 series) "int" is 32 bits, but multiplying
- * two 16-bit shorts is faster than multiplying two ints. Define MULTIPLIER
- * as short on such a machine. MULTIPLIER must be at least 16 bits wide.
- */
-
-#ifndef MULTIPLIER
-#ifndef WITH_SIMD
-#define MULTIPLIER int /* type for fastest integer multiply */
-#else
-#define MULTIPLIER short /* prefer 16-bit with SIMD for parellelism */
-#endif
-#endif
-
-
-/* FAST_FLOAT should be either float or double, whichever is done faster
- * by your compiler. (Note that this type is only used in the floating point
- * DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.)
- */
-
-#ifndef FAST_FLOAT
-#define FAST_FLOAT float
-#endif
-
-#endif /* JPEG_INTERNAL_OPTIONS */
diff --git a/contrib/libs/libjpeg-turbo/jpeg_nbits_table.h b/contrib/libs/libjpeg-turbo/jpeg_nbits_table.h
deleted file mode 100644
index fcf73878c3..0000000000
--- a/contrib/libs/libjpeg-turbo/jpeg_nbits_table.h
+++ /dev/null
@@ -1,4098 +0,0 @@
-static const unsigned char jpeg_nbits_table[65536] = {
- 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16
-};
diff --git a/contrib/libs/libjpeg-turbo/jpegcomp.h b/contrib/libs/libjpeg-turbo/jpegcomp.h
deleted file mode 100644
index c4834ac0df..0000000000
--- a/contrib/libs/libjpeg-turbo/jpegcomp.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * jpegcomp.h
- *
- * Copyright (C) 2010, 2020, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * JPEG compatibility macros
- * These declarations are considered internal to the JPEG library; most
- * applications using the library shouldn't need to include this file.
- */
-
-#if JPEG_LIB_VERSION >= 70
-#define _DCT_scaled_size DCT_h_scaled_size
-#define _DCT_h_scaled_size DCT_h_scaled_size
-#define _DCT_v_scaled_size DCT_v_scaled_size
-#define _min_DCT_scaled_size min_DCT_h_scaled_size
-#define _min_DCT_h_scaled_size min_DCT_h_scaled_size
-#define _min_DCT_v_scaled_size min_DCT_v_scaled_size
-#define _jpeg_width jpeg_width
-#define _jpeg_height jpeg_height
-#define JERR_ARITH_NOTIMPL JERR_NOT_COMPILED
-#else
-#define _DCT_scaled_size DCT_scaled_size
-#define _DCT_h_scaled_size DCT_scaled_size
-#define _DCT_v_scaled_size DCT_scaled_size
-#define _min_DCT_scaled_size min_DCT_scaled_size
-#define _min_DCT_h_scaled_size min_DCT_scaled_size
-#define _min_DCT_v_scaled_size min_DCT_scaled_size
-#define _jpeg_width image_width
-#define _jpeg_height image_height
-#endif
diff --git a/contrib/libs/libjpeg-turbo/jpegint.h b/contrib/libs/libjpeg-turbo/jpegint.h
deleted file mode 100644
index 6af9e2a179..0000000000
--- a/contrib/libs/libjpeg-turbo/jpegint.h
+++ /dev/null
@@ -1,375 +0,0 @@
-/*
- * jpegint.h
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * Modified 1997-2009 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2015-2016, 2019, 2021, D. R. Commander.
- * Copyright (C) 2015, Google, Inc.
- * Copyright (C) 2021, Alex Richardson.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file provides common declarations for the various JPEG modules.
- * These declarations are considered internal to the JPEG library; most
- * applications using the library shouldn't need to include this file.
- */
-
-
-/* Declarations for both compression & decompression */
-
-typedef enum { /* Operating modes for buffer controllers */
- JBUF_PASS_THRU, /* Plain stripwise operation */
- /* Remaining modes require a full-image buffer to have been created */
- JBUF_SAVE_SOURCE, /* Run source subobject only, save output */
- JBUF_CRANK_DEST, /* Run dest subobject only, using saved data */
- JBUF_SAVE_AND_PASS /* Run both subobjects, save output */
-} J_BUF_MODE;
-
-/* Values of global_state field (jdapi.c has some dependencies on ordering!) */
-#define CSTATE_START 100 /* after create_compress */
-#define CSTATE_SCANNING 101 /* start_compress done, write_scanlines OK */
-#define CSTATE_RAW_OK 102 /* start_compress done, write_raw_data OK */
-#define CSTATE_WRCOEFS 103 /* jpeg_write_coefficients done */
-#define DSTATE_START 200 /* after create_decompress */
-#define DSTATE_INHEADER 201 /* reading header markers, no SOS yet */
-#define DSTATE_READY 202 /* found SOS, ready for start_decompress */
-#define DSTATE_PRELOAD 203 /* reading multiscan file in start_decompress*/
-#define DSTATE_PRESCAN 204 /* performing dummy pass for 2-pass quant */
-#define DSTATE_SCANNING 205 /* start_decompress done, read_scanlines OK */
-#define DSTATE_RAW_OK 206 /* start_decompress done, read_raw_data OK */
-#define DSTATE_BUFIMAGE 207 /* expecting jpeg_start_output */
-#define DSTATE_BUFPOST 208 /* looking for SOS/EOI in jpeg_finish_output */
-#define DSTATE_RDCOEFS 209 /* reading file in jpeg_read_coefficients */
-#define DSTATE_STOPPING 210 /* looking for EOI in jpeg_finish_decompress */
-
-
-/* JLONG must hold at least signed 32-bit values. */
-typedef long JLONG;
-
-/* JUINTPTR must hold pointer values. */
-#ifdef __UINTPTR_TYPE__
-/*
- * __UINTPTR_TYPE__ is GNU-specific and available in GCC 4.6+ and Clang 3.0+.
- * Fortunately, that is sufficient to support the few architectures for which
- * sizeof(void *) != sizeof(size_t). The only other options would require C99
- * or Clang-specific builtins.
- */
-typedef __UINTPTR_TYPE__ JUINTPTR;
-#else
-typedef size_t JUINTPTR;
-#endif
-
-/*
- * Left shift macro that handles a negative operand without causing any
- * sanitizer warnings
- */
-
-#define LEFT_SHIFT(a, b) ((JLONG)((unsigned long)(a) << (b)))
-
-
-/* Declarations for compression modules */
-
-/* Master control module */
-struct jpeg_comp_master {
- void (*prepare_for_pass) (j_compress_ptr cinfo);
- void (*pass_startup) (j_compress_ptr cinfo);
- void (*finish_pass) (j_compress_ptr cinfo);
-
- /* State variables made visible to other modules */
- boolean call_pass_startup; /* True if pass_startup must be called */
- boolean is_last_pass; /* True during last pass */
-};
-
-/* Main buffer control (downsampled-data buffer) */
-struct jpeg_c_main_controller {
- void (*start_pass) (j_compress_ptr cinfo, J_BUF_MODE pass_mode);
- void (*process_data) (j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail);
-};
-
-/* Compression preprocessing (downsampling input buffer control) */
-struct jpeg_c_prep_controller {
- void (*start_pass) (j_compress_ptr cinfo, J_BUF_MODE pass_mode);
- void (*pre_process_data) (j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail,
- JSAMPIMAGE output_buf,
- JDIMENSION *out_row_group_ctr,
- JDIMENSION out_row_groups_avail);
-};
-
-/* Coefficient buffer control */
-struct jpeg_c_coef_controller {
- void (*start_pass) (j_compress_ptr cinfo, J_BUF_MODE pass_mode);
- boolean (*compress_data) (j_compress_ptr cinfo, JSAMPIMAGE input_buf);
-};
-
-/* Colorspace conversion */
-struct jpeg_color_converter {
- void (*start_pass) (j_compress_ptr cinfo);
- void (*color_convert) (j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPIMAGE output_buf, JDIMENSION output_row,
- int num_rows);
-};
-
-/* Downsampling */
-struct jpeg_downsampler {
- void (*start_pass) (j_compress_ptr cinfo);
- void (*downsample) (j_compress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION in_row_index, JSAMPIMAGE output_buf,
- JDIMENSION out_row_group_index);
-
- boolean need_context_rows; /* TRUE if need rows above & below */
-};
-
-/* Forward DCT (also controls coefficient quantization) */
-struct jpeg_forward_dct {
- void (*start_pass) (j_compress_ptr cinfo);
- /* perhaps this should be an array??? */
- void (*forward_DCT) (j_compress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
- JDIMENSION start_row, JDIMENSION start_col,
- JDIMENSION num_blocks);
-};
-
-/* Entropy encoding */
-struct jpeg_entropy_encoder {
- void (*start_pass) (j_compress_ptr cinfo, boolean gather_statistics);
- boolean (*encode_mcu) (j_compress_ptr cinfo, JBLOCKROW *MCU_data);
- void (*finish_pass) (j_compress_ptr cinfo);
-};
-
-/* Marker writing */
-struct jpeg_marker_writer {
- void (*write_file_header) (j_compress_ptr cinfo);
- void (*write_frame_header) (j_compress_ptr cinfo);
- void (*write_scan_header) (j_compress_ptr cinfo);
- void (*write_file_trailer) (j_compress_ptr cinfo);
- void (*write_tables_only) (j_compress_ptr cinfo);
- /* These routines are exported to allow insertion of extra markers */
- /* Probably only COM and APPn markers should be written this way */
- void (*write_marker_header) (j_compress_ptr cinfo, int marker,
- unsigned int datalen);
- void (*write_marker_byte) (j_compress_ptr cinfo, int val);
-};
-
-
-/* Declarations for decompression modules */
-
-/* Master control module */
-struct jpeg_decomp_master {
- void (*prepare_for_output_pass) (j_decompress_ptr cinfo);
- void (*finish_output_pass) (j_decompress_ptr cinfo);
-
- /* State variables made visible to other modules */
- boolean is_dummy_pass; /* True during 1st pass for 2-pass quant */
-
- /* Partial decompression variables */
- JDIMENSION first_iMCU_col;
- JDIMENSION last_iMCU_col;
- JDIMENSION first_MCU_col[MAX_COMPONENTS];
- JDIMENSION last_MCU_col[MAX_COMPONENTS];
- boolean jinit_upsampler_no_alloc;
-
- /* Last iMCU row that was successfully decoded */
- JDIMENSION last_good_iMCU_row;
-};
-
-/* Input control module */
-struct jpeg_input_controller {
- int (*consume_input) (j_decompress_ptr cinfo);
- void (*reset_input_controller) (j_decompress_ptr cinfo);
- void (*start_input_pass) (j_decompress_ptr cinfo);
- void (*finish_input_pass) (j_decompress_ptr cinfo);
-
- /* State variables made visible to other modules */
- boolean has_multiple_scans; /* True if file has multiple scans */
- boolean eoi_reached; /* True when EOI has been consumed */
-};
-
-/* Main buffer control (downsampled-data buffer) */
-struct jpeg_d_main_controller {
- void (*start_pass) (j_decompress_ptr cinfo, J_BUF_MODE pass_mode);
- void (*process_data) (j_decompress_ptr cinfo, JSAMPARRAY output_buf,
- JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail);
-};
-
-/* Coefficient buffer control */
-struct jpeg_d_coef_controller {
- void (*start_input_pass) (j_decompress_ptr cinfo);
- int (*consume_data) (j_decompress_ptr cinfo);
- void (*start_output_pass) (j_decompress_ptr cinfo);
- int (*decompress_data) (j_decompress_ptr cinfo, JSAMPIMAGE output_buf);
- /* Pointer to array of coefficient virtual arrays, or NULL if none */
- jvirt_barray_ptr *coef_arrays;
-};
-
-/* Decompression postprocessing (color quantization buffer control) */
-struct jpeg_d_post_controller {
- void (*start_pass) (j_decompress_ptr cinfo, J_BUF_MODE pass_mode);
- void (*post_process_data) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION *in_row_group_ctr,
- JDIMENSION in_row_groups_avail,
- JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
- JDIMENSION out_rows_avail);
-};
-
-/* Marker reading & parsing */
-struct jpeg_marker_reader {
- void (*reset_marker_reader) (j_decompress_ptr cinfo);
- /* Read markers until SOS or EOI.
- * Returns same codes as are defined for jpeg_consume_input:
- * JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI.
- */
- int (*read_markers) (j_decompress_ptr cinfo);
- /* Read a restart marker --- exported for use by entropy decoder only */
- jpeg_marker_parser_method read_restart_marker;
-
- /* State of marker reader --- nominally internal, but applications
- * supplying COM or APPn handlers might like to know the state.
- */
- boolean saw_SOI; /* found SOI? */
- boolean saw_SOF; /* found SOF? */
- int next_restart_num; /* next restart number expected (0-7) */
- unsigned int discarded_bytes; /* # of bytes skipped looking for a marker */
-};
-
-/* Entropy decoding */
-struct jpeg_entropy_decoder {
- void (*start_pass) (j_decompress_ptr cinfo);
- boolean (*decode_mcu) (j_decompress_ptr cinfo, JBLOCKROW *MCU_data);
-
- /* This is here to share code between baseline and progressive decoders; */
- /* other modules probably should not use it */
- boolean insufficient_data; /* set TRUE after emitting warning */
-};
-
-/* Inverse DCT (also performs dequantization) */
-typedef void (*inverse_DCT_method_ptr) (j_decompress_ptr cinfo,
- jpeg_component_info *compptr,
- JCOEFPTR coef_block,
- JSAMPARRAY output_buf,
- JDIMENSION output_col);
-
-struct jpeg_inverse_dct {
- void (*start_pass) (j_decompress_ptr cinfo);
- /* It is useful to allow each component to have a separate IDCT method. */
- inverse_DCT_method_ptr inverse_DCT[MAX_COMPONENTS];
-};
-
-/* Upsampling (note that upsampler must also call color converter) */
-struct jpeg_upsampler {
- void (*start_pass) (j_decompress_ptr cinfo);
- void (*upsample) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION *in_row_group_ctr,
- JDIMENSION in_row_groups_avail, JSAMPARRAY output_buf,
- JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail);
-
- boolean need_context_rows; /* TRUE if need rows above & below */
-};
-
-/* Colorspace conversion */
-struct jpeg_color_deconverter {
- void (*start_pass) (j_decompress_ptr cinfo);
- void (*color_convert) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf,
- int num_rows);
-};
-
-/* Color quantization or color precision reduction */
-struct jpeg_color_quantizer {
- void (*start_pass) (j_decompress_ptr cinfo, boolean is_pre_scan);
- void (*color_quantize) (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPARRAY output_buf, int num_rows);
- void (*finish_pass) (j_decompress_ptr cinfo);
- void (*new_color_map) (j_decompress_ptr cinfo);
-};
-
-
-/* Miscellaneous useful macros */
-
-#undef MAX
-#define MAX(a, b) ((a) > (b) ? (a) : (b))
-#undef MIN
-#define MIN(a, b) ((a) < (b) ? (a) : (b))
-
-
-/* We assume that right shift corresponds to signed division by 2 with
- * rounding towards minus infinity. This is correct for typical "arithmetic
- * shift" instructions that shift in copies of the sign bit. But some
- * C compilers implement >> with an unsigned shift. For these machines you
- * must define RIGHT_SHIFT_IS_UNSIGNED.
- * RIGHT_SHIFT provides a proper signed right shift of a JLONG quantity.
- * It is only applied with constant shift counts. SHIFT_TEMPS must be
- * included in the variables of any routine using RIGHT_SHIFT.
- */
-
-#ifdef RIGHT_SHIFT_IS_UNSIGNED
-#define SHIFT_TEMPS JLONG shift_temp;
-#define RIGHT_SHIFT(x, shft) \
- ((shift_temp = (x)) < 0 ? \
- (shift_temp >> (shft)) | ((~((JLONG)0)) << (32 - (shft))) : \
- (shift_temp >> (shft)))
-#else
-#define SHIFT_TEMPS
-#define RIGHT_SHIFT(x, shft) ((x) >> (shft))
-#endif
-
-
-/* Compression module initialization routines */
-EXTERN(void) jinit_compress_master(j_compress_ptr cinfo);
-EXTERN(void) jinit_c_master_control(j_compress_ptr cinfo,
- boolean transcode_only);
-EXTERN(void) jinit_c_main_controller(j_compress_ptr cinfo,
- boolean need_full_buffer);
-EXTERN(void) jinit_c_prep_controller(j_compress_ptr cinfo,
- boolean need_full_buffer);
-EXTERN(void) jinit_c_coef_controller(j_compress_ptr cinfo,
- boolean need_full_buffer);
-EXTERN(void) jinit_color_converter(j_compress_ptr cinfo);
-EXTERN(void) jinit_downsampler(j_compress_ptr cinfo);
-EXTERN(void) jinit_forward_dct(j_compress_ptr cinfo);
-EXTERN(void) jinit_huff_encoder(j_compress_ptr cinfo);
-EXTERN(void) jinit_phuff_encoder(j_compress_ptr cinfo);
-EXTERN(void) jinit_arith_encoder(j_compress_ptr cinfo);
-EXTERN(void) jinit_marker_writer(j_compress_ptr cinfo);
-/* Decompression module initialization routines */
-EXTERN(void) jinit_master_decompress(j_decompress_ptr cinfo);
-EXTERN(void) jinit_d_main_controller(j_decompress_ptr cinfo,
- boolean need_full_buffer);
-EXTERN(void) jinit_d_coef_controller(j_decompress_ptr cinfo,
- boolean need_full_buffer);
-EXTERN(void) jinit_d_post_controller(j_decompress_ptr cinfo,
- boolean need_full_buffer);
-EXTERN(void) jinit_input_controller(j_decompress_ptr cinfo);
-EXTERN(void) jinit_marker_reader(j_decompress_ptr cinfo);
-EXTERN(void) jinit_huff_decoder(j_decompress_ptr cinfo);
-EXTERN(void) jinit_phuff_decoder(j_decompress_ptr cinfo);
-EXTERN(void) jinit_arith_decoder(j_decompress_ptr cinfo);
-EXTERN(void) jinit_inverse_dct(j_decompress_ptr cinfo);
-EXTERN(void) jinit_upsampler(j_decompress_ptr cinfo);
-EXTERN(void) jinit_color_deconverter(j_decompress_ptr cinfo);
-EXTERN(void) jinit_1pass_quantizer(j_decompress_ptr cinfo);
-EXTERN(void) jinit_2pass_quantizer(j_decompress_ptr cinfo);
-EXTERN(void) jinit_merged_upsampler(j_decompress_ptr cinfo);
-/* Memory manager initialization */
-EXTERN(void) jinit_memory_mgr(j_common_ptr cinfo);
-
-/* Utility routines in jutils.c */
-EXTERN(long) jdiv_round_up(long a, long b);
-EXTERN(long) jround_up(long a, long b);
-EXTERN(void) jcopy_sample_rows(JSAMPARRAY input_array, int source_row,
- JSAMPARRAY output_array, int dest_row,
- int num_rows, JDIMENSION num_cols);
-EXTERN(void) jcopy_block_row(JBLOCKROW input_row, JBLOCKROW output_row,
- JDIMENSION num_blocks);
-EXTERN(void) jzero_far(void *target, size_t bytestozero);
-/* Constant tables in jutils.c */
-#if 0 /* This table is not actually needed in v6a */
-extern const int jpeg_zigzag_order[]; /* natural coef order to zigzag order */
-#endif
-extern const int jpeg_natural_order[]; /* zigzag coef order to natural order */
-
-/* Arithmetic coding probability estimation tables in jaricom.c */
-extern const JLONG jpeg_aritab[];
diff --git a/contrib/libs/libjpeg-turbo/jpeglib.h b/contrib/libs/libjpeg-turbo/jpeglib.h
deleted file mode 100644
index d7664f0630..0000000000
--- a/contrib/libs/libjpeg-turbo/jpeglib.h
+++ /dev/null
@@ -1,1132 +0,0 @@
-/*
- * jpeglib.h
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1998, Thomas G. Lane.
- * Modified 2002-2009 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2009-2011, 2013-2014, 2016-2017, 2020, D. R. Commander.
- * Copyright (C) 2015, Google, Inc.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file defines the application interface for the JPEG library.
- * Most applications using the library need only include this file,
- * and perhaps jerror.h if they want to know the exact error codes.
- */
-
-#ifndef JPEGLIB_H
-#define JPEGLIB_H
-
-/*
- * First we include the configuration files that record how this
- * installation of the JPEG library is set up. jconfig.h can be
- * generated automatically for many systems. jmorecfg.h contains
- * manual configuration options that most people need not worry about.
- */
-
-#ifndef JCONFIG_INCLUDED /* in case jinclude.h already did */
-#include "jconfig.h" /* widely used configuration options */
-#endif
-#include "jmorecfg.h" /* seldom changed options */
-
-
-#ifdef __cplusplus
-#ifndef DONT_USE_EXTERN_C
-extern "C" {
-#endif
-#endif
-
-
-/* Various constants determining the sizes of things.
- * All of these are specified by the JPEG standard, so don't change them
- * if you want to be compatible.
- */
-
-#define DCTSIZE 8 /* The basic DCT block is 8x8 samples */
-#define DCTSIZE2 64 /* DCTSIZE squared; # of elements in a block */
-#define NUM_QUANT_TBLS 4 /* Quantization tables are numbered 0..3 */
-#define NUM_HUFF_TBLS 4 /* Huffman tables are numbered 0..3 */
-#define NUM_ARITH_TBLS 16 /* Arith-coding tables are numbered 0..15 */
-#define MAX_COMPS_IN_SCAN 4 /* JPEG limit on # of components in one scan */
-#define MAX_SAMP_FACTOR 4 /* JPEG limit on sampling factors */
-/* Unfortunately, some bozo at Adobe saw no reason to be bound by the standard;
- * the PostScript DCT filter can emit files with many more than 10 blocks/MCU.
- * If you happen to run across such a file, you can up D_MAX_BLOCKS_IN_MCU
- * to handle it. We even let you do this from the jconfig.h file. However,
- * we strongly discourage changing C_MAX_BLOCKS_IN_MCU; just because Adobe
- * sometimes emits noncompliant files doesn't mean you should too.
- */
-#define C_MAX_BLOCKS_IN_MCU 10 /* compressor's limit on blocks per MCU */
-#ifndef D_MAX_BLOCKS_IN_MCU
-#define D_MAX_BLOCKS_IN_MCU 10 /* decompressor's limit on blocks per MCU */
-#endif
-
-
-/* Data structures for images (arrays of samples and of DCT coefficients).
- */
-
-typedef JSAMPLE *JSAMPROW; /* ptr to one image row of pixel samples. */
-typedef JSAMPROW *JSAMPARRAY; /* ptr to some rows (a 2-D sample array) */
-typedef JSAMPARRAY *JSAMPIMAGE; /* a 3-D sample array: top index is color */
-
-typedef JCOEF JBLOCK[DCTSIZE2]; /* one block of coefficients */
-typedef JBLOCK *JBLOCKROW; /* pointer to one row of coefficient blocks */
-typedef JBLOCKROW *JBLOCKARRAY; /* a 2-D array of coefficient blocks */
-typedef JBLOCKARRAY *JBLOCKIMAGE; /* a 3-D array of coefficient blocks */
-
-typedef JCOEF *JCOEFPTR; /* useful in a couple of places */
-
-
-/* Types for JPEG compression parameters and working tables. */
-
-
-/* DCT coefficient quantization tables. */
-
-typedef struct {
- /* This array gives the coefficient quantizers in natural array order
- * (not the zigzag order in which they are stored in a JPEG DQT marker).
- * CAUTION: IJG versions prior to v6a kept this array in zigzag order.
- */
- UINT16 quantval[DCTSIZE2]; /* quantization step for each coefficient */
- /* This field is used only during compression. It's initialized FALSE when
- * the table is created, and set TRUE when it's been output to the file.
- * You could suppress output of a table by setting this to TRUE.
- * (See jpeg_suppress_tables for an example.)
- */
- boolean sent_table; /* TRUE when table has been output */
-} JQUANT_TBL;
-
-
-/* Huffman coding tables. */
-
-typedef struct {
- /* These two fields directly represent the contents of a JPEG DHT marker */
- UINT8 bits[17]; /* bits[k] = # of symbols with codes of */
- /* length k bits; bits[0] is unused */
- UINT8 huffval[256]; /* The symbols, in order of incr code length */
- /* This field is used only during compression. It's initialized FALSE when
- * the table is created, and set TRUE when it's been output to the file.
- * You could suppress output of a table by setting this to TRUE.
- * (See jpeg_suppress_tables for an example.)
- */
- boolean sent_table; /* TRUE when table has been output */
-} JHUFF_TBL;
-
-
-/* Basic info about one component (color channel). */
-
-typedef struct {
- /* These values are fixed over the whole image. */
- /* For compression, they must be supplied by parameter setup; */
- /* for decompression, they are read from the SOF marker. */
- int component_id; /* identifier for this component (0..255) */
- int component_index; /* its index in SOF or cinfo->comp_info[] */
- int h_samp_factor; /* horizontal sampling factor (1..4) */
- int v_samp_factor; /* vertical sampling factor (1..4) */
- int quant_tbl_no; /* quantization table selector (0..3) */
- /* These values may vary between scans. */
- /* For compression, they must be supplied by parameter setup; */
- /* for decompression, they are read from the SOS marker. */
- /* The decompressor output side may not use these variables. */
- int dc_tbl_no; /* DC entropy table selector (0..3) */
- int ac_tbl_no; /* AC entropy table selector (0..3) */
-
- /* Remaining fields should be treated as private by applications. */
-
- /* These values are computed during compression or decompression startup: */
- /* Component's size in DCT blocks.
- * Any dummy blocks added to complete an MCU are not counted; therefore
- * these values do not depend on whether a scan is interleaved or not.
- */
- JDIMENSION width_in_blocks;
- JDIMENSION height_in_blocks;
- /* Size of a DCT block in samples. Always DCTSIZE for compression.
- * For decompression this is the size of the output from one DCT block,
- * reflecting any scaling we choose to apply during the IDCT step.
- * Values from 1 to 16 are supported.
- * Note that different components may receive different IDCT scalings.
- */
-#if JPEG_LIB_VERSION >= 70
- int DCT_h_scaled_size;
- int DCT_v_scaled_size;
-#else
- int DCT_scaled_size;
-#endif
- /* The downsampled dimensions are the component's actual, unpadded number
- * of samples at the main buffer (preprocessing/compression interface), thus
- * downsampled_width = ceil(image_width * Hi/Hmax)
- * and similarly for height. For decompression, IDCT scaling is included, so
- * downsampled_width = ceil(image_width * Hi/Hmax * DCT_[h_]scaled_size/DCTSIZE)
- */
- JDIMENSION downsampled_width; /* actual width in samples */
- JDIMENSION downsampled_height; /* actual height in samples */
- /* This flag is used only for decompression. In cases where some of the
- * components will be ignored (eg grayscale output from YCbCr image),
- * we can skip most computations for the unused components.
- */
- boolean component_needed; /* do we need the value of this component? */
-
- /* These values are computed before starting a scan of the component. */
- /* The decompressor output side may not use these variables. */
- int MCU_width; /* number of blocks per MCU, horizontally */
- int MCU_height; /* number of blocks per MCU, vertically */
- int MCU_blocks; /* MCU_width * MCU_height */
- int MCU_sample_width; /* MCU width in samples, MCU_width*DCT_[h_]scaled_size */
- int last_col_width; /* # of non-dummy blocks across in last MCU */
- int last_row_height; /* # of non-dummy blocks down in last MCU */
-
- /* Saved quantization table for component; NULL if none yet saved.
- * See jdinput.c comments about the need for this information.
- * This field is currently used only for decompression.
- */
- JQUANT_TBL *quant_table;
-
- /* Private per-component storage for DCT or IDCT subsystem. */
- void *dct_table;
-} jpeg_component_info;
-
-
-/* The script for encoding a multiple-scan file is an array of these: */
-
-typedef struct {
- int comps_in_scan; /* number of components encoded in this scan */
- int component_index[MAX_COMPS_IN_SCAN]; /* their SOF/comp_info[] indexes */
- int Ss, Se; /* progressive JPEG spectral selection parms */
- int Ah, Al; /* progressive JPEG successive approx. parms */
-} jpeg_scan_info;
-
-/* The decompressor can save APPn and COM markers in a list of these: */
-
-typedef struct jpeg_marker_struct *jpeg_saved_marker_ptr;
-
-struct jpeg_marker_struct {
- jpeg_saved_marker_ptr next; /* next in list, or NULL */
- UINT8 marker; /* marker code: JPEG_COM, or JPEG_APP0+n */
- unsigned int original_length; /* # bytes of data in the file */
- unsigned int data_length; /* # bytes of data saved at data[] */
- JOCTET *data; /* the data contained in the marker */
- /* the marker length word is not counted in data_length or original_length */
-};
-
-/* Known color spaces. */
-
-#define JCS_EXTENSIONS 1
-#define JCS_ALPHA_EXTENSIONS 1
-
-typedef enum {
- JCS_UNKNOWN, /* error/unspecified */
- JCS_GRAYSCALE, /* monochrome */
- JCS_RGB, /* red/green/blue as specified by the RGB_RED,
- RGB_GREEN, RGB_BLUE, and RGB_PIXELSIZE macros */
- JCS_YCbCr, /* Y/Cb/Cr (also known as YUV) */
- JCS_CMYK, /* C/M/Y/K */
- JCS_YCCK, /* Y/Cb/Cr/K */
- JCS_EXT_RGB, /* red/green/blue */
- JCS_EXT_RGBX, /* red/green/blue/x */
- JCS_EXT_BGR, /* blue/green/red */
- JCS_EXT_BGRX, /* blue/green/red/x */
- JCS_EXT_XBGR, /* x/blue/green/red */
- JCS_EXT_XRGB, /* x/red/green/blue */
- /* When out_color_space it set to JCS_EXT_RGBX, JCS_EXT_BGRX, JCS_EXT_XBGR,
- or JCS_EXT_XRGB during decompression, the X byte is undefined, and in
- order to ensure the best performance, libjpeg-turbo can set that byte to
- whatever value it wishes. Use the following colorspace constants to
- ensure that the X byte is set to 0xFF, so that it can be interpreted as an
- opaque alpha channel. */
- JCS_EXT_RGBA, /* red/green/blue/alpha */
- JCS_EXT_BGRA, /* blue/green/red/alpha */
- JCS_EXT_ABGR, /* alpha/blue/green/red */
- JCS_EXT_ARGB, /* alpha/red/green/blue */
- JCS_RGB565 /* 5-bit red/6-bit green/5-bit blue */
-} J_COLOR_SPACE;
-
-/* DCT/IDCT algorithm options. */
-
-typedef enum {
- JDCT_ISLOW, /* accurate integer method */
- JDCT_IFAST, /* less accurate integer method [legacy feature] */
- JDCT_FLOAT /* floating-point method [legacy feature] */
-} J_DCT_METHOD;
-
-#ifndef JDCT_DEFAULT /* may be overridden in jconfig.h */
-#define JDCT_DEFAULT JDCT_ISLOW
-#endif
-#ifndef JDCT_FASTEST /* may be overridden in jconfig.h */
-#define JDCT_FASTEST JDCT_IFAST
-#endif
-
-/* Dithering options for decompression. */
-
-typedef enum {
- JDITHER_NONE, /* no dithering */
- JDITHER_ORDERED, /* simple ordered dither */
- JDITHER_FS /* Floyd-Steinberg error diffusion dither */
-} J_DITHER_MODE;
-
-
-/* Common fields between JPEG compression and decompression master structs. */
-
-#define jpeg_common_fields \
- struct jpeg_error_mgr *err; /* Error handler module */ \
- struct jpeg_memory_mgr *mem; /* Memory manager module */ \
- struct jpeg_progress_mgr *progress; /* Progress monitor, or NULL if none */ \
- void *client_data; /* Available for use by application */ \
- boolean is_decompressor; /* So common code can tell which is which */ \
- int global_state /* For checking call sequence validity */
-
-/* Routines that are to be used by both halves of the library are declared
- * to receive a pointer to this structure. There are no actual instances of
- * jpeg_common_struct, only of jpeg_compress_struct and jpeg_decompress_struct.
- */
-struct jpeg_common_struct {
- jpeg_common_fields; /* Fields common to both master struct types */
- /* Additional fields follow in an actual jpeg_compress_struct or
- * jpeg_decompress_struct. All three structs must agree on these
- * initial fields! (This would be a lot cleaner in C++.)
- */
-};
-
-typedef struct jpeg_common_struct *j_common_ptr;
-typedef struct jpeg_compress_struct *j_compress_ptr;
-typedef struct jpeg_decompress_struct *j_decompress_ptr;
-
-
-/* Master record for a compression instance */
-
-struct jpeg_compress_struct {
- jpeg_common_fields; /* Fields shared with jpeg_decompress_struct */
-
- /* Destination for compressed data */
- struct jpeg_destination_mgr *dest;
-
- /* Description of source image --- these fields must be filled in by
- * outer application before starting compression. in_color_space must
- * be correct before you can even call jpeg_set_defaults().
- */
-
- JDIMENSION image_width; /* input image width */
- JDIMENSION image_height; /* input image height */
- int input_components; /* # of color components in input image */
- J_COLOR_SPACE in_color_space; /* colorspace of input image */
-
- double input_gamma; /* image gamma of input image */
-
- /* Compression parameters --- these fields must be set before calling
- * jpeg_start_compress(). We recommend calling jpeg_set_defaults() to
- * initialize everything to reasonable defaults, then changing anything
- * the application specifically wants to change. That way you won't get
- * burnt when new parameters are added. Also note that there are several
- * helper routines to simplify changing parameters.
- */
-
-#if JPEG_LIB_VERSION >= 70
- unsigned int scale_num, scale_denom; /* fraction by which to scale image */
-
- JDIMENSION jpeg_width; /* scaled JPEG image width */
- JDIMENSION jpeg_height; /* scaled JPEG image height */
- /* Dimensions of actual JPEG image that will be written to file,
- * derived from input dimensions by scaling factors above.
- * These fields are computed by jpeg_start_compress().
- * You can also use jpeg_calc_jpeg_dimensions() to determine these values
- * in advance of calling jpeg_start_compress().
- */
-#endif
-
- int data_precision; /* bits of precision in image data */
-
- int num_components; /* # of color components in JPEG image */
- J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */
-
- jpeg_component_info *comp_info;
- /* comp_info[i] describes component that appears i'th in SOF */
-
- JQUANT_TBL *quant_tbl_ptrs[NUM_QUANT_TBLS];
-#if JPEG_LIB_VERSION >= 70
- int q_scale_factor[NUM_QUANT_TBLS];
-#endif
- /* ptrs to coefficient quantization tables, or NULL if not defined,
- * and corresponding scale factors (percentage, initialized 100).
- */
-
- JHUFF_TBL *dc_huff_tbl_ptrs[NUM_HUFF_TBLS];
- JHUFF_TBL *ac_huff_tbl_ptrs[NUM_HUFF_TBLS];
- /* ptrs to Huffman coding tables, or NULL if not defined */
-
- UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */
- UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */
- UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */
-
- int num_scans; /* # of entries in scan_info array */
- const jpeg_scan_info *scan_info; /* script for multi-scan file, or NULL */
- /* The default value of scan_info is NULL, which causes a single-scan
- * sequential JPEG file to be emitted. To create a multi-scan file,
- * set num_scans and scan_info to point to an array of scan definitions.
- */
-
- boolean raw_data_in; /* TRUE=caller supplies downsampled data */
- boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */
- boolean optimize_coding; /* TRUE=optimize entropy encoding parms */
- boolean CCIR601_sampling; /* TRUE=first samples are cosited */
-#if JPEG_LIB_VERSION >= 70
- boolean do_fancy_downsampling; /* TRUE=apply fancy downsampling */
-#endif
- int smoothing_factor; /* 1..100, or 0 for no input smoothing */
- J_DCT_METHOD dct_method; /* DCT algorithm selector */
-
- /* The restart interval can be specified in absolute MCUs by setting
- * restart_interval, or in MCU rows by setting restart_in_rows
- * (in which case the correct restart_interval will be figured
- * for each scan).
- */
- unsigned int restart_interval; /* MCUs per restart, or 0 for no restart */
- int restart_in_rows; /* if > 0, MCU rows per restart interval */
-
- /* Parameters controlling emission of special markers. */
-
- boolean write_JFIF_header; /* should a JFIF marker be written? */
- UINT8 JFIF_major_version; /* What to write for the JFIF version number */
- UINT8 JFIF_minor_version;
- /* These three values are not used by the JPEG code, merely copied */
- /* into the JFIF APP0 marker. density_unit can be 0 for unknown, */
- /* 1 for dots/inch, or 2 for dots/cm. Note that the pixel aspect */
- /* ratio is defined by X_density/Y_density even when density_unit=0. */
- UINT8 density_unit; /* JFIF code for pixel size units */
- UINT16 X_density; /* Horizontal pixel density */
- UINT16 Y_density; /* Vertical pixel density */
- boolean write_Adobe_marker; /* should an Adobe marker be written? */
-
- /* State variable: index of next scanline to be written to
- * jpeg_write_scanlines(). Application may use this to control its
- * processing loop, e.g., "while (next_scanline < image_height)".
- */
-
- JDIMENSION next_scanline; /* 0 .. image_height-1 */
-
- /* Remaining fields are known throughout compressor, but generally
- * should not be touched by a surrounding application.
- */
-
- /*
- * These fields are computed during compression startup
- */
- boolean progressive_mode; /* TRUE if scan script uses progressive mode */
- int max_h_samp_factor; /* largest h_samp_factor */
- int max_v_samp_factor; /* largest v_samp_factor */
-
-#if JPEG_LIB_VERSION >= 70
- int min_DCT_h_scaled_size; /* smallest DCT_h_scaled_size of any component */
- int min_DCT_v_scaled_size; /* smallest DCT_v_scaled_size of any component */
-#endif
-
- JDIMENSION total_iMCU_rows; /* # of iMCU rows to be input to coef ctlr */
- /* The coefficient controller receives data in units of MCU rows as defined
- * for fully interleaved scans (whether the JPEG file is interleaved or not).
- * There are v_samp_factor * DCTSIZE sample rows of each component in an
- * "iMCU" (interleaved MCU) row.
- */
-
- /*
- * These fields are valid during any one scan.
- * They describe the components and MCUs actually appearing in the scan.
- */
- int comps_in_scan; /* # of JPEG components in this scan */
- jpeg_component_info *cur_comp_info[MAX_COMPS_IN_SCAN];
- /* *cur_comp_info[i] describes component that appears i'th in SOS */
-
- JDIMENSION MCUs_per_row; /* # of MCUs across the image */
- JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */
-
- int blocks_in_MCU; /* # of DCT blocks per MCU */
- int MCU_membership[C_MAX_BLOCKS_IN_MCU];
- /* MCU_membership[i] is index in cur_comp_info of component owning */
- /* i'th block in an MCU */
-
- int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */
-
-#if JPEG_LIB_VERSION >= 80
- int block_size; /* the basic DCT block size: 1..16 */
- const int *natural_order; /* natural-order position array */
- int lim_Se; /* min( Se, DCTSIZE2-1 ) */
-#endif
-
- /*
- * Links to compression subobjects (methods and private variables of modules)
- */
- struct jpeg_comp_master *master;
- struct jpeg_c_main_controller *main;
- struct jpeg_c_prep_controller *prep;
- struct jpeg_c_coef_controller *coef;
- struct jpeg_marker_writer *marker;
- struct jpeg_color_converter *cconvert;
- struct jpeg_downsampler *downsample;
- struct jpeg_forward_dct *fdct;
- struct jpeg_entropy_encoder *entropy;
- jpeg_scan_info *script_space; /* workspace for jpeg_simple_progression */
- int script_space_size;
-};
-
-
-/* Master record for a decompression instance */
-
-struct jpeg_decompress_struct {
- jpeg_common_fields; /* Fields shared with jpeg_compress_struct */
-
- /* Source of compressed data */
- struct jpeg_source_mgr *src;
-
- /* Basic description of image --- filled in by jpeg_read_header(). */
- /* Application may inspect these values to decide how to process image. */
-
- JDIMENSION image_width; /* nominal image width (from SOF marker) */
- JDIMENSION image_height; /* nominal image height */
- int num_components; /* # of color components in JPEG image */
- J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */
-
- /* Decompression processing parameters --- these fields must be set before
- * calling jpeg_start_decompress(). Note that jpeg_read_header() initializes
- * them to default values.
- */
-
- J_COLOR_SPACE out_color_space; /* colorspace for output */
-
- unsigned int scale_num, scale_denom; /* fraction by which to scale image */
-
- double output_gamma; /* image gamma wanted in output */
-
- boolean buffered_image; /* TRUE=multiple output passes */
- boolean raw_data_out; /* TRUE=downsampled data wanted */
-
- J_DCT_METHOD dct_method; /* IDCT algorithm selector */
- boolean do_fancy_upsampling; /* TRUE=apply fancy upsampling */
- boolean do_block_smoothing; /* TRUE=apply interblock smoothing */
-
- boolean quantize_colors; /* TRUE=colormapped output wanted */
- /* the following are ignored if not quantize_colors: */
- J_DITHER_MODE dither_mode; /* type of color dithering to use */
- boolean two_pass_quantize; /* TRUE=use two-pass color quantization */
- int desired_number_of_colors; /* max # colors to use in created colormap */
- /* these are significant only in buffered-image mode: */
- boolean enable_1pass_quant; /* enable future use of 1-pass quantizer */
- boolean enable_external_quant;/* enable future use of external colormap */
- boolean enable_2pass_quant; /* enable future use of 2-pass quantizer */
-
- /* Description of actual output image that will be returned to application.
- * These fields are computed by jpeg_start_decompress().
- * You can also use jpeg_calc_output_dimensions() to determine these values
- * in advance of calling jpeg_start_decompress().
- */
-
- JDIMENSION output_width; /* scaled image width */
- JDIMENSION output_height; /* scaled image height */
- int out_color_components; /* # of color components in out_color_space */
- int output_components; /* # of color components returned */
- /* output_components is 1 (a colormap index) when quantizing colors;
- * otherwise it equals out_color_components.
- */
- int rec_outbuf_height; /* min recommended height of scanline buffer */
- /* If the buffer passed to jpeg_read_scanlines() is less than this many rows
- * high, space and time will be wasted due to unnecessary data copying.
- * Usually rec_outbuf_height will be 1 or 2, at most 4.
- */
-
- /* When quantizing colors, the output colormap is described by these fields.
- * The application can supply a colormap by setting colormap non-NULL before
- * calling jpeg_start_decompress; otherwise a colormap is created during
- * jpeg_start_decompress or jpeg_start_output.
- * The map has out_color_components rows and actual_number_of_colors columns.
- */
- int actual_number_of_colors; /* number of entries in use */
- JSAMPARRAY colormap; /* The color map as a 2-D pixel array */
-
- /* State variables: these variables indicate the progress of decompression.
- * The application may examine these but must not modify them.
- */
-
- /* Row index of next scanline to be read from jpeg_read_scanlines().
- * Application may use this to control its processing loop, e.g.,
- * "while (output_scanline < output_height)".
- */
- JDIMENSION output_scanline; /* 0 .. output_height-1 */
-
- /* Current input scan number and number of iMCU rows completed in scan.
- * These indicate the progress of the decompressor input side.
- */
- int input_scan_number; /* Number of SOS markers seen so far */
- JDIMENSION input_iMCU_row; /* Number of iMCU rows completed */
-
- /* The "output scan number" is the notional scan being displayed by the
- * output side. The decompressor will not allow output scan/row number
- * to get ahead of input scan/row, but it can fall arbitrarily far behind.
- */
- int output_scan_number; /* Nominal scan number being displayed */
- JDIMENSION output_iMCU_row; /* Number of iMCU rows read */
-
- /* Current progression status. coef_bits[c][i] indicates the precision
- * with which component c's DCT coefficient i (in zigzag order) is known.
- * It is -1 when no data has yet been received, otherwise it is the point
- * transform (shift) value for the most recent scan of the coefficient
- * (thus, 0 at completion of the progression).
- * This pointer is NULL when reading a non-progressive file.
- */
- int (*coef_bits)[DCTSIZE2]; /* -1 or current Al value for each coef */
-
- /* Internal JPEG parameters --- the application usually need not look at
- * these fields. Note that the decompressor output side may not use
- * any parameters that can change between scans.
- */
-
- /* Quantization and Huffman tables are carried forward across input
- * datastreams when processing abbreviated JPEG datastreams.
- */
-
- JQUANT_TBL *quant_tbl_ptrs[NUM_QUANT_TBLS];
- /* ptrs to coefficient quantization tables, or NULL if not defined */
-
- JHUFF_TBL *dc_huff_tbl_ptrs[NUM_HUFF_TBLS];
- JHUFF_TBL *ac_huff_tbl_ptrs[NUM_HUFF_TBLS];
- /* ptrs to Huffman coding tables, or NULL if not defined */
-
- /* These parameters are never carried across datastreams, since they
- * are given in SOF/SOS markers or defined to be reset by SOI.
- */
-
- int data_precision; /* bits of precision in image data */
-
- jpeg_component_info *comp_info;
- /* comp_info[i] describes component that appears i'th in SOF */
-
-#if JPEG_LIB_VERSION >= 80
- boolean is_baseline; /* TRUE if Baseline SOF0 encountered */
-#endif
- boolean progressive_mode; /* TRUE if SOFn specifies progressive mode */
- boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */
-
- UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */
- UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */
- UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */
-
- unsigned int restart_interval; /* MCUs per restart interval, or 0 for no restart */
-
- /* These fields record data obtained from optional markers recognized by
- * the JPEG library.
- */
- boolean saw_JFIF_marker; /* TRUE iff a JFIF APP0 marker was found */
- /* Data copied from JFIF marker; only valid if saw_JFIF_marker is TRUE: */
- UINT8 JFIF_major_version; /* JFIF version number */
- UINT8 JFIF_minor_version;
- UINT8 density_unit; /* JFIF code for pixel size units */
- UINT16 X_density; /* Horizontal pixel density */
- UINT16 Y_density; /* Vertical pixel density */
- boolean saw_Adobe_marker; /* TRUE iff an Adobe APP14 marker was found */
- UINT8 Adobe_transform; /* Color transform code from Adobe marker */
-
- boolean CCIR601_sampling; /* TRUE=first samples are cosited */
-
- /* Aside from the specific data retained from APPn markers known to the
- * library, the uninterpreted contents of any or all APPn and COM markers
- * can be saved in a list for examination by the application.
- */
- jpeg_saved_marker_ptr marker_list; /* Head of list of saved markers */
-
- /* Remaining fields are known throughout decompressor, but generally
- * should not be touched by a surrounding application.
- */
-
- /*
- * These fields are computed during decompression startup
- */
- int max_h_samp_factor; /* largest h_samp_factor */
- int max_v_samp_factor; /* largest v_samp_factor */
-
-#if JPEG_LIB_VERSION >= 70
- int min_DCT_h_scaled_size; /* smallest DCT_h_scaled_size of any component */
- int min_DCT_v_scaled_size; /* smallest DCT_v_scaled_size of any component */
-#else
- int min_DCT_scaled_size; /* smallest DCT_scaled_size of any component */
-#endif
-
- JDIMENSION total_iMCU_rows; /* # of iMCU rows in image */
- /* The coefficient controller's input and output progress is measured in
- * units of "iMCU" (interleaved MCU) rows. These are the same as MCU rows
- * in fully interleaved JPEG scans, but are used whether the scan is
- * interleaved or not. We define an iMCU row as v_samp_factor DCT block
- * rows of each component. Therefore, the IDCT output contains
- * v_samp_factor*DCT_[v_]scaled_size sample rows of a component per iMCU row.
- */
-
- JSAMPLE *sample_range_limit; /* table for fast range-limiting */
-
- /*
- * These fields are valid during any one scan.
- * They describe the components and MCUs actually appearing in the scan.
- * Note that the decompressor output side must not use these fields.
- */
- int comps_in_scan; /* # of JPEG components in this scan */
- jpeg_component_info *cur_comp_info[MAX_COMPS_IN_SCAN];
- /* *cur_comp_info[i] describes component that appears i'th in SOS */
-
- JDIMENSION MCUs_per_row; /* # of MCUs across the image */
- JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */
-
- int blocks_in_MCU; /* # of DCT blocks per MCU */
- int MCU_membership[D_MAX_BLOCKS_IN_MCU];
- /* MCU_membership[i] is index in cur_comp_info of component owning */
- /* i'th block in an MCU */
-
- int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */
-
-#if JPEG_LIB_VERSION >= 80
- /* These fields are derived from Se of first SOS marker.
- */
- int block_size; /* the basic DCT block size: 1..16 */
- const int *natural_order; /* natural-order position array for entropy decode */
- int lim_Se; /* min( Se, DCTSIZE2-1 ) for entropy decode */
-#endif
-
- /* This field is shared between entropy decoder and marker parser.
- * It is either zero or the code of a JPEG marker that has been
- * read from the data source, but has not yet been processed.
- */
- int unread_marker;
-
- /*
- * Links to decompression subobjects (methods, private variables of modules)
- */
- struct jpeg_decomp_master *master;
- struct jpeg_d_main_controller *main;
- struct jpeg_d_coef_controller *coef;
- struct jpeg_d_post_controller *post;
- struct jpeg_input_controller *inputctl;
- struct jpeg_marker_reader *marker;
- struct jpeg_entropy_decoder *entropy;
- struct jpeg_inverse_dct *idct;
- struct jpeg_upsampler *upsample;
- struct jpeg_color_deconverter *cconvert;
- struct jpeg_color_quantizer *cquantize;
-};
-
-
-/* "Object" declarations for JPEG modules that may be supplied or called
- * directly by the surrounding application.
- * As with all objects in the JPEG library, these structs only define the
- * publicly visible methods and state variables of a module. Additional
- * private fields may exist after the public ones.
- */
-
-
-/* Error handler object */
-
-struct jpeg_error_mgr {
- /* Error exit handler: does not return to caller */
- void (*error_exit) (j_common_ptr cinfo);
- /* Conditionally emit a trace or warning message */
- void (*emit_message) (j_common_ptr cinfo, int msg_level);
- /* Routine that actually outputs a trace or error message */
- void (*output_message) (j_common_ptr cinfo);
- /* Format a message string for the most recent JPEG error or message */
- void (*format_message) (j_common_ptr cinfo, char *buffer);
-#define JMSG_LENGTH_MAX 200 /* recommended size of format_message buffer */
- /* Reset error state variables at start of a new image */
- void (*reset_error_mgr) (j_common_ptr cinfo);
-
- /* The message ID code and any parameters are saved here.
- * A message can have one string parameter or up to 8 int parameters.
- */
- int msg_code;
-#define JMSG_STR_PARM_MAX 80
- union {
- int i[8];
- char s[JMSG_STR_PARM_MAX];
- } msg_parm;
-
- /* Standard state variables for error facility */
-
- int trace_level; /* max msg_level that will be displayed */
-
- /* For recoverable corrupt-data errors, we emit a warning message,
- * but keep going unless emit_message chooses to abort. emit_message
- * should count warnings in num_warnings. The surrounding application
- * can check for bad data by seeing if num_warnings is nonzero at the
- * end of processing.
- */
- long num_warnings; /* number of corrupt-data warnings */
-
- /* These fields point to the table(s) of error message strings.
- * An application can change the table pointer to switch to a different
- * message list (typically, to change the language in which errors are
- * reported). Some applications may wish to add additional error codes
- * that will be handled by the JPEG library error mechanism; the second
- * table pointer is used for this purpose.
- *
- * First table includes all errors generated by JPEG library itself.
- * Error code 0 is reserved for a "no such error string" message.
- */
- const char * const *jpeg_message_table; /* Library errors */
- int last_jpeg_message; /* Table contains strings 0..last_jpeg_message */
- /* Second table can be added by application (see cjpeg/djpeg for example).
- * It contains strings numbered first_addon_message..last_addon_message.
- */
- const char * const *addon_message_table; /* Non-library errors */
- int first_addon_message; /* code for first string in addon table */
- int last_addon_message; /* code for last string in addon table */
-};
-
-
-/* Progress monitor object */
-
-struct jpeg_progress_mgr {
- void (*progress_monitor) (j_common_ptr cinfo);
-
- long pass_counter; /* work units completed in this pass */
- long pass_limit; /* total number of work units in this pass */
- int completed_passes; /* passes completed so far */
- int total_passes; /* total number of passes expected */
-};
-
-
-/* Data destination object for compression */
-
-struct jpeg_destination_mgr {
- JOCTET *next_output_byte; /* => next byte to write in buffer */
- size_t free_in_buffer; /* # of byte spaces remaining in buffer */
-
- void (*init_destination) (j_compress_ptr cinfo);
- boolean (*empty_output_buffer) (j_compress_ptr cinfo);
- void (*term_destination) (j_compress_ptr cinfo);
-};
-
-
-/* Data source object for decompression */
-
-struct jpeg_source_mgr {
- const JOCTET *next_input_byte; /* => next byte to read from buffer */
- size_t bytes_in_buffer; /* # of bytes remaining in buffer */
-
- void (*init_source) (j_decompress_ptr cinfo);
- boolean (*fill_input_buffer) (j_decompress_ptr cinfo);
- void (*skip_input_data) (j_decompress_ptr cinfo, long num_bytes);
- boolean (*resync_to_restart) (j_decompress_ptr cinfo, int desired);
- void (*term_source) (j_decompress_ptr cinfo);
-};
-
-
-/* Memory manager object.
- * Allocates "small" objects (a few K total), "large" objects (tens of K),
- * and "really big" objects (virtual arrays with backing store if needed).
- * The memory manager does not allow individual objects to be freed; rather,
- * each created object is assigned to a pool, and whole pools can be freed
- * at once. This is faster and more convenient than remembering exactly what
- * to free, especially where malloc()/free() are not too speedy.
- * NB: alloc routines never return NULL. They exit to error_exit if not
- * successful.
- */
-
-#define JPOOL_PERMANENT 0 /* lasts until master record is destroyed */
-#define JPOOL_IMAGE 1 /* lasts until done with image/datastream */
-#define JPOOL_NUMPOOLS 2
-
-typedef struct jvirt_sarray_control *jvirt_sarray_ptr;
-typedef struct jvirt_barray_control *jvirt_barray_ptr;
-
-
-struct jpeg_memory_mgr {
- /* Method pointers */
- void *(*alloc_small) (j_common_ptr cinfo, int pool_id, size_t sizeofobject);
- void *(*alloc_large) (j_common_ptr cinfo, int pool_id,
- size_t sizeofobject);
- JSAMPARRAY (*alloc_sarray) (j_common_ptr cinfo, int pool_id,
- JDIMENSION samplesperrow, JDIMENSION numrows);
- JBLOCKARRAY (*alloc_barray) (j_common_ptr cinfo, int pool_id,
- JDIMENSION blocksperrow, JDIMENSION numrows);
- jvirt_sarray_ptr (*request_virt_sarray) (j_common_ptr cinfo, int pool_id,
- boolean pre_zero,
- JDIMENSION samplesperrow,
- JDIMENSION numrows,
- JDIMENSION maxaccess);
- jvirt_barray_ptr (*request_virt_barray) (j_common_ptr cinfo, int pool_id,
- boolean pre_zero,
- JDIMENSION blocksperrow,
- JDIMENSION numrows,
- JDIMENSION maxaccess);
- void (*realize_virt_arrays) (j_common_ptr cinfo);
- JSAMPARRAY (*access_virt_sarray) (j_common_ptr cinfo, jvirt_sarray_ptr ptr,
- JDIMENSION start_row, JDIMENSION num_rows,
- boolean writable);
- JBLOCKARRAY (*access_virt_barray) (j_common_ptr cinfo, jvirt_barray_ptr ptr,
- JDIMENSION start_row, JDIMENSION num_rows,
- boolean writable);
- void (*free_pool) (j_common_ptr cinfo, int pool_id);
- void (*self_destruct) (j_common_ptr cinfo);
-
- /* Limit on memory allocation for this JPEG object. (Note that this is
- * merely advisory, not a guaranteed maximum; it only affects the space
- * used for virtual-array buffers.) May be changed by outer application
- * after creating the JPEG object.
- */
- long max_memory_to_use;
-
- /* Maximum allocation request accepted by alloc_large. */
- long max_alloc_chunk;
-};
-
-
-/* Routine signature for application-supplied marker processing methods.
- * Need not pass marker code since it is stored in cinfo->unread_marker.
- */
-typedef boolean (*jpeg_marker_parser_method) (j_decompress_ptr cinfo);
-
-
-/* Originally, this macro was used as a way of defining function prototypes
- * for both modern compilers as well as older compilers that did not support
- * prototype parameters. libjpeg-turbo has never supported these older,
- * non-ANSI compilers, but the macro is still included because there is some
- * software out there that uses it.
- */
-
-#define JPP(arglist) arglist
-
-
-/* Default error-management setup */
-EXTERN(struct jpeg_error_mgr *) jpeg_std_error(struct jpeg_error_mgr *err);
-
-/* Initialization of JPEG compression objects.
- * jpeg_create_compress() and jpeg_create_decompress() are the exported
- * names that applications should call. These expand to calls on
- * jpeg_CreateCompress and jpeg_CreateDecompress with additional information
- * passed for version mismatch checking.
- * NB: you must set up the error-manager BEFORE calling jpeg_create_xxx.
- */
-#define jpeg_create_compress(cinfo) \
- jpeg_CreateCompress((cinfo), JPEG_LIB_VERSION, \
- (size_t)sizeof(struct jpeg_compress_struct))
-#define jpeg_create_decompress(cinfo) \
- jpeg_CreateDecompress((cinfo), JPEG_LIB_VERSION, \
- (size_t)sizeof(struct jpeg_decompress_struct))
-EXTERN(void) jpeg_CreateCompress(j_compress_ptr cinfo, int version,
- size_t structsize);
-EXTERN(void) jpeg_CreateDecompress(j_decompress_ptr cinfo, int version,
- size_t structsize);
-/* Destruction of JPEG compression objects */
-EXTERN(void) jpeg_destroy_compress(j_compress_ptr cinfo);
-EXTERN(void) jpeg_destroy_decompress(j_decompress_ptr cinfo);
-
-/* Standard data source and destination managers: stdio streams. */
-/* Caller is responsible for opening the file before and closing after. */
-EXTERN(void) jpeg_stdio_dest(j_compress_ptr cinfo, FILE *outfile);
-EXTERN(void) jpeg_stdio_src(j_decompress_ptr cinfo, FILE *infile);
-
-#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
-/* Data source and destination managers: memory buffers. */
-EXTERN(void) jpeg_mem_dest(j_compress_ptr cinfo, unsigned char **outbuffer,
- unsigned long *outsize);
-EXTERN(void) jpeg_mem_src(j_decompress_ptr cinfo,
- const unsigned char *inbuffer, unsigned long insize);
-#endif
-
-/* Default parameter setup for compression */
-EXTERN(void) jpeg_set_defaults(j_compress_ptr cinfo);
-/* Compression parameter setup aids */
-EXTERN(void) jpeg_set_colorspace(j_compress_ptr cinfo,
- J_COLOR_SPACE colorspace);
-EXTERN(void) jpeg_default_colorspace(j_compress_ptr cinfo);
-EXTERN(void) jpeg_set_quality(j_compress_ptr cinfo, int quality,
- boolean force_baseline);
-EXTERN(void) jpeg_set_linear_quality(j_compress_ptr cinfo, int scale_factor,
- boolean force_baseline);
-#if JPEG_LIB_VERSION >= 70
-EXTERN(void) jpeg_default_qtables(j_compress_ptr cinfo,
- boolean force_baseline);
-#endif
-EXTERN(void) jpeg_add_quant_table(j_compress_ptr cinfo, int which_tbl,
- const unsigned int *basic_table,
- int scale_factor, boolean force_baseline);
-EXTERN(int) jpeg_quality_scaling(int quality);
-EXTERN(void) jpeg_simple_progression(j_compress_ptr cinfo);
-EXTERN(void) jpeg_suppress_tables(j_compress_ptr cinfo, boolean suppress);
-EXTERN(JQUANT_TBL *) jpeg_alloc_quant_table(j_common_ptr cinfo);
-EXTERN(JHUFF_TBL *) jpeg_alloc_huff_table(j_common_ptr cinfo);
-
-/* Main entry points for compression */
-EXTERN(void) jpeg_start_compress(j_compress_ptr cinfo,
- boolean write_all_tables);
-EXTERN(JDIMENSION) jpeg_write_scanlines(j_compress_ptr cinfo,
- JSAMPARRAY scanlines,
- JDIMENSION num_lines);
-EXTERN(void) jpeg_finish_compress(j_compress_ptr cinfo);
-
-#if JPEG_LIB_VERSION >= 70
-/* Precalculate JPEG dimensions for current compression parameters. */
-EXTERN(void) jpeg_calc_jpeg_dimensions(j_compress_ptr cinfo);
-#endif
-
-/* Replaces jpeg_write_scanlines when writing raw downsampled data. */
-EXTERN(JDIMENSION) jpeg_write_raw_data(j_compress_ptr cinfo, JSAMPIMAGE data,
- JDIMENSION num_lines);
-
-/* Write a special marker. See libjpeg.txt concerning safe usage. */
-EXTERN(void) jpeg_write_marker(j_compress_ptr cinfo, int marker,
- const JOCTET *dataptr, unsigned int datalen);
-/* Same, but piecemeal. */
-EXTERN(void) jpeg_write_m_header(j_compress_ptr cinfo, int marker,
- unsigned int datalen);
-EXTERN(void) jpeg_write_m_byte(j_compress_ptr cinfo, int val);
-
-/* Alternate compression function: just write an abbreviated table file */
-EXTERN(void) jpeg_write_tables(j_compress_ptr cinfo);
-
-/* Write ICC profile. See libjpeg.txt for usage information. */
-EXTERN(void) jpeg_write_icc_profile(j_compress_ptr cinfo,
- const JOCTET *icc_data_ptr,
- unsigned int icc_data_len);
-
-
-/* Decompression startup: read start of JPEG datastream to see what's there */
-EXTERN(int) jpeg_read_header(j_decompress_ptr cinfo, boolean require_image);
-/* Return value is one of: */
-#define JPEG_SUSPENDED 0 /* Suspended due to lack of input data */
-#define JPEG_HEADER_OK 1 /* Found valid image datastream */
-#define JPEG_HEADER_TABLES_ONLY 2 /* Found valid table-specs-only datastream */
-/* If you pass require_image = TRUE (normal case), you need not check for
- * a TABLES_ONLY return code; an abbreviated file will cause an error exit.
- * JPEG_SUSPENDED is only possible if you use a data source module that can
- * give a suspension return (the stdio source module doesn't).
- */
-
-/* Main entry points for decompression */
-EXTERN(boolean) jpeg_start_decompress(j_decompress_ptr cinfo);
-EXTERN(JDIMENSION) jpeg_read_scanlines(j_decompress_ptr cinfo,
- JSAMPARRAY scanlines,
- JDIMENSION max_lines);
-EXTERN(JDIMENSION) jpeg_skip_scanlines(j_decompress_ptr cinfo,
- JDIMENSION num_lines);
-EXTERN(void) jpeg_crop_scanline(j_decompress_ptr cinfo, JDIMENSION *xoffset,
- JDIMENSION *width);
-EXTERN(boolean) jpeg_finish_decompress(j_decompress_ptr cinfo);
-
-/* Replaces jpeg_read_scanlines when reading raw downsampled data. */
-EXTERN(JDIMENSION) jpeg_read_raw_data(j_decompress_ptr cinfo, JSAMPIMAGE data,
- JDIMENSION max_lines);
-
-/* Additional entry points for buffered-image mode. */
-EXTERN(boolean) jpeg_has_multiple_scans(j_decompress_ptr cinfo);
-EXTERN(boolean) jpeg_start_output(j_decompress_ptr cinfo, int scan_number);
-EXTERN(boolean) jpeg_finish_output(j_decompress_ptr cinfo);
-EXTERN(boolean) jpeg_input_complete(j_decompress_ptr cinfo);
-EXTERN(void) jpeg_new_colormap(j_decompress_ptr cinfo);
-EXTERN(int) jpeg_consume_input(j_decompress_ptr cinfo);
-/* Return value is one of: */
-/* #define JPEG_SUSPENDED 0 Suspended due to lack of input data */
-#define JPEG_REACHED_SOS 1 /* Reached start of new scan */
-#define JPEG_REACHED_EOI 2 /* Reached end of image */
-#define JPEG_ROW_COMPLETED 3 /* Completed one iMCU row */
-#define JPEG_SCAN_COMPLETED 4 /* Completed last iMCU row of a scan */
-
-/* Precalculate output dimensions for current decompression parameters. */
-#if JPEG_LIB_VERSION >= 80
-EXTERN(void) jpeg_core_output_dimensions(j_decompress_ptr cinfo);
-#endif
-EXTERN(void) jpeg_calc_output_dimensions(j_decompress_ptr cinfo);
-
-/* Control saving of COM and APPn markers into marker_list. */
-EXTERN(void) jpeg_save_markers(j_decompress_ptr cinfo, int marker_code,
- unsigned int length_limit);
-
-/* Install a special processing method for COM or APPn markers. */
-EXTERN(void) jpeg_set_marker_processor(j_decompress_ptr cinfo,
- int marker_code,
- jpeg_marker_parser_method routine);
-
-/* Read or write raw DCT coefficients --- useful for lossless transcoding. */
-EXTERN(jvirt_barray_ptr *) jpeg_read_coefficients(j_decompress_ptr cinfo);
-EXTERN(void) jpeg_write_coefficients(j_compress_ptr cinfo,
- jvirt_barray_ptr *coef_arrays);
-EXTERN(void) jpeg_copy_critical_parameters(j_decompress_ptr srcinfo,
- j_compress_ptr dstinfo);
-
-/* If you choose to abort compression or decompression before completing
- * jpeg_finish_(de)compress, then you need to clean up to release memory,
- * temporary files, etc. You can just call jpeg_destroy_(de)compress
- * if you're done with the JPEG object, but if you want to clean it up and
- * reuse it, call this:
- */
-EXTERN(void) jpeg_abort_compress(j_compress_ptr cinfo);
-EXTERN(void) jpeg_abort_decompress(j_decompress_ptr cinfo);
-
-/* Generic versions of jpeg_abort and jpeg_destroy that work on either
- * flavor of JPEG object. These may be more convenient in some places.
- */
-EXTERN(void) jpeg_abort(j_common_ptr cinfo);
-EXTERN(void) jpeg_destroy(j_common_ptr cinfo);
-
-/* Default restart-marker-resync procedure for use by data source modules */
-EXTERN(boolean) jpeg_resync_to_restart(j_decompress_ptr cinfo, int desired);
-
-/* Read ICC profile. See libjpeg.txt for usage information. */
-EXTERN(boolean) jpeg_read_icc_profile(j_decompress_ptr cinfo,
- JOCTET **icc_data_ptr,
- unsigned int *icc_data_len);
-
-
-/* These marker codes are exported since applications and data source modules
- * are likely to want to use them.
- */
-
-#define JPEG_RST0 0xD0 /* RST0 marker code */
-#define JPEG_EOI 0xD9 /* EOI marker code */
-#define JPEG_APP0 0xE0 /* APP0 marker code */
-#define JPEG_COM 0xFE /* COM marker code */
-
-
-/* If we have a brain-damaged compiler that emits warnings (or worse, errors)
- * for structure definitions that are never filled in, keep it quiet by
- * supplying dummy definitions for the various substructures.
- */
-
-#ifdef INCOMPLETE_TYPES_BROKEN
-#ifndef JPEG_INTERNALS /* will be defined in jpegint.h */
-struct jvirt_sarray_control { long dummy; };
-struct jvirt_barray_control { long dummy; };
-struct jpeg_comp_master { long dummy; };
-struct jpeg_c_main_controller { long dummy; };
-struct jpeg_c_prep_controller { long dummy; };
-struct jpeg_c_coef_controller { long dummy; };
-struct jpeg_marker_writer { long dummy; };
-struct jpeg_color_converter { long dummy; };
-struct jpeg_downsampler { long dummy; };
-struct jpeg_forward_dct { long dummy; };
-struct jpeg_entropy_encoder { long dummy; };
-struct jpeg_decomp_master { long dummy; };
-struct jpeg_d_main_controller { long dummy; };
-struct jpeg_d_coef_controller { long dummy; };
-struct jpeg_d_post_controller { long dummy; };
-struct jpeg_input_controller { long dummy; };
-struct jpeg_marker_reader { long dummy; };
-struct jpeg_entropy_decoder { long dummy; };
-struct jpeg_inverse_dct { long dummy; };
-struct jpeg_upsampler { long dummy; };
-struct jpeg_color_deconverter { long dummy; };
-struct jpeg_color_quantizer { long dummy; };
-#endif /* JPEG_INTERNALS */
-#endif /* INCOMPLETE_TYPES_BROKEN */
-
-
-/*
- * The JPEG library modules define JPEG_INTERNALS before including this file.
- * The internal structure declarations are read only when that is true.
- * Applications using the library should not include jpegint.h, but may wish
- * to include jerror.h.
- */
-
-#ifdef JPEG_INTERNALS
-#include "jpegint.h" /* fetch private declarations */
-#include "jerror.h" /* fetch error codes too */
-#endif
-
-#ifdef __cplusplus
-#ifndef DONT_USE_EXTERN_C
-}
-#endif
-#endif
-
-#endif /* JPEGLIB_H */
diff --git a/contrib/libs/libjpeg-turbo/jpegtran.c b/contrib/libs/libjpeg-turbo/jpegtran.c
deleted file mode 100644
index d1552ec7d5..0000000000
--- a/contrib/libs/libjpeg-turbo/jpegtran.c
+++ /dev/null
@@ -1,728 +0,0 @@
-/*
- * jpegtran.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1995-2019, Thomas G. Lane, Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2014, 2017, 2019-2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains a command-line user interface for JPEG transcoding.
- * It is very similar to cjpeg.c, and partly to djpeg.c, but provides
- * lossless transcoding between different JPEG file formats. It also
- * provides some lossless and sort-of-lossless transformations of JPEG data.
- */
-
-#ifdef _MSC_VER
-#define _CRT_SECURE_NO_DEPRECATE
-#endif
-
-#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
-#include "transupp.h" /* Support routines for jpegtran */
-#include "jversion.h" /* for version message */
-#include "jconfigint.h"
-
-
-/*
- * Argument-parsing code.
- * The switch parser is designed to be useful with DOS-style command line
- * syntax, ie, intermixed switches and file names, where only the switches
- * to the left of a given file name affect processing of that file.
- * The main program in this file doesn't actually use this capability...
- */
-
-
-static const char *progname; /* program name for error messages */
-static char *icc_filename; /* for -icc switch */
-JDIMENSION max_scans; /* for -maxscans switch */
-static char *outfilename; /* for -outfile switch */
-static char *dropfilename; /* for -drop switch */
-boolean report; /* for -report switch */
-boolean strict; /* for -strict switch */
-static JCOPY_OPTION copyoption; /* -copy switch */
-static jpeg_transform_info transformoption; /* image transformation options */
-
-
-LOCAL(void)
-usage(void)
-/* complain about bad command line */
-{
- fprintf(stderr, "usage: %s [switches] ", progname);
-#ifdef TWO_FILE_COMMANDLINE
- fprintf(stderr, "inputfile outputfile\n");
-#else
- fprintf(stderr, "[inputfile]\n");
-#endif
-
- fprintf(stderr, "Switches (names may be abbreviated):\n");
- fprintf(stderr, " -copy none Copy no extra markers from source file\n");
- fprintf(stderr, " -copy comments Copy only comment markers (default)\n");
- fprintf(stderr, " -copy icc Copy only ICC profile markers\n");
- fprintf(stderr, " -copy all Copy all extra markers\n");
-#ifdef ENTROPY_OPT_SUPPORTED
- fprintf(stderr, " -optimize Optimize Huffman table (smaller file, but slow compression)\n");
-#endif
-#ifdef C_PROGRESSIVE_SUPPORTED
- fprintf(stderr, " -progressive Create progressive JPEG file\n");
-#endif
- fprintf(stderr, "Switches for modifying the image:\n");
-#if TRANSFORMS_SUPPORTED
- fprintf(stderr, " -crop WxH+X+Y Crop to a rectangular region\n");
- fprintf(stderr, " -drop +X+Y filename Drop (insert) another image\n");
- fprintf(stderr, " -flip [horizontal|vertical] Mirror image (left-right or top-bottom)\n");
- fprintf(stderr, " -grayscale Reduce to grayscale (omit color data)\n");
- fprintf(stderr, " -perfect Fail if there is non-transformable edge blocks\n");
- fprintf(stderr, " -rotate [90|180|270] Rotate image (degrees clockwise)\n");
-#endif
-#if TRANSFORMS_SUPPORTED
- fprintf(stderr, " -transpose Transpose image\n");
- fprintf(stderr, " -transverse Transverse transpose image\n");
- fprintf(stderr, " -trim Drop non-transformable edge blocks\n");
- fprintf(stderr, " with -drop: Requantize drop file to match source file\n");
- fprintf(stderr, " -wipe WxH+X+Y Wipe (gray out) a rectangular region\n");
-#endif
- fprintf(stderr, "Switches for advanced users:\n");
-#ifdef C_ARITH_CODING_SUPPORTED
- fprintf(stderr, " -arithmetic Use arithmetic coding\n");
-#endif
- fprintf(stderr, " -icc FILE Embed ICC profile contained in FILE\n");
- fprintf(stderr, " -restart N Set restart interval in rows, or in blocks with B\n");
- fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n");
- fprintf(stderr, " -maxscans N Maximum number of scans to allow in input file\n");
- fprintf(stderr, " -outfile name Specify name for output file\n");
- fprintf(stderr, " -report Report transformation progress\n");
- fprintf(stderr, " -strict Treat all warnings as fatal\n");
- fprintf(stderr, " -verbose or -debug Emit debug output\n");
- fprintf(stderr, " -version Print version information and exit\n");
- fprintf(stderr, "Switches for wizards:\n");
-#ifdef C_MULTISCAN_FILES_SUPPORTED
- fprintf(stderr, " -scans FILE Create multi-scan JPEG per script FILE\n");
-#endif
- exit(EXIT_FAILURE);
-}
-
-
-LOCAL(void)
-select_transform(JXFORM_CODE transform)
-/* Silly little routine to detect multiple transform options,
- * which we can't handle.
- */
-{
-#if TRANSFORMS_SUPPORTED
- if (transformoption.transform == JXFORM_NONE ||
- transformoption.transform == transform) {
- transformoption.transform = transform;
- } else {
- fprintf(stderr, "%s: can only do one image transformation at a time\n",
- progname);
- usage();
- }
-#else
- fprintf(stderr, "%s: sorry, image transformation was not compiled\n",
- progname);
- exit(EXIT_FAILURE);
-#endif
-}
-
-
-LOCAL(int)
-parse_switches(j_compress_ptr cinfo, int argc, char **argv,
- int last_file_arg_seen, boolean for_real)
-/* Parse optional switches.
- * Returns argv[] index of first file-name argument (== argc if none).
- * Any file names with indexes <= last_file_arg_seen are ignored;
- * they have presumably been processed in a previous iteration.
- * (Pass 0 for last_file_arg_seen on the first or only iteration.)
- * for_real is FALSE on the first (dummy) pass; we may skip any expensive
- * processing.
- */
-{
- int argn;
- char *arg;
- boolean simple_progressive;
- char *scansarg = NULL; /* saves -scans parm if any */
-
- /* Set up default JPEG parameters. */
- simple_progressive = FALSE;
- icc_filename = NULL;
- max_scans = 0;
- outfilename = NULL;
- report = FALSE;
- strict = FALSE;
- copyoption = JCOPYOPT_DEFAULT;
- transformoption.transform = JXFORM_NONE;
- transformoption.perfect = FALSE;
- transformoption.trim = FALSE;
- transformoption.force_grayscale = FALSE;
- transformoption.crop = FALSE;
- transformoption.slow_hflip = FALSE;
- cinfo->err->trace_level = 0;
-
- /* Scan command line options, adjust parameters */
-
- for (argn = 1; argn < argc; argn++) {
- arg = argv[argn];
- if (*arg != '-') {
- /* Not a switch, must be a file name argument */
- if (argn <= last_file_arg_seen) {
- outfilename = NULL; /* -outfile applies to just one input file */
- continue; /* ignore this name if previously processed */
- }
- break; /* else done parsing switches */
- }
- arg++; /* advance past switch marker character */
-
- if (keymatch(arg, "arithmetic", 1)) {
- /* Use arithmetic coding. */
-#ifdef C_ARITH_CODING_SUPPORTED
- cinfo->arith_code = TRUE;
-#else
- fprintf(stderr, "%s: sorry, arithmetic coding not supported\n",
- progname);
- exit(EXIT_FAILURE);
-#endif
-
- } else if (keymatch(arg, "copy", 2)) {
- /* Select which extra markers to copy. */
- if (++argn >= argc) /* advance to next argument */
- usage();
- if (keymatch(argv[argn], "none", 1)) {
- copyoption = JCOPYOPT_NONE;
- } else if (keymatch(argv[argn], "comments", 1)) {
- copyoption = JCOPYOPT_COMMENTS;
- } else if (keymatch(argv[argn], "icc", 1)) {
- copyoption = JCOPYOPT_ICC;
- } else if (keymatch(argv[argn], "all", 1)) {
- copyoption = JCOPYOPT_ALL;
- } else
- usage();
-
- } else if (keymatch(arg, "crop", 2)) {
- /* Perform lossless cropping. */
-#if TRANSFORMS_SUPPORTED
- if (++argn >= argc) /* advance to next argument */
- usage();
- if (transformoption.crop /* reject multiple crop/drop/wipe requests */ ||
- !jtransform_parse_crop_spec(&transformoption, argv[argn])) {
- fprintf(stderr, "%s: bogus -crop argument '%s'\n",
- progname, argv[argn]);
- exit(EXIT_FAILURE);
- }
-#else
- select_transform(JXFORM_NONE); /* force an error */
-#endif
-
- } else if (keymatch(arg, "drop", 2)) {
-#if TRANSFORMS_SUPPORTED
- if (++argn >= argc) /* advance to next argument */
- usage();
- if (transformoption.crop /* reject multiple crop/drop/wipe requests */ ||
- !jtransform_parse_crop_spec(&transformoption, argv[argn]) ||
- transformoption.crop_width_set != JCROP_UNSET ||
- transformoption.crop_height_set != JCROP_UNSET) {
- fprintf(stderr, "%s: bogus -drop argument '%s'\n",
- progname, argv[argn]);
- exit(EXIT_FAILURE);
- }
- if (++argn >= argc) /* advance to next argument */
- usage();
- dropfilename = argv[argn];
- select_transform(JXFORM_DROP);
-#else
- select_transform(JXFORM_NONE); /* force an error */
-#endif
-
- } else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) {
- /* Enable debug printouts. */
- /* On first -d, print version identification */
- static boolean printed_version = FALSE;
-
- if (!printed_version) {
- fprintf(stderr, "%s version %s (build %s)\n",
- PACKAGE_NAME, VERSION, BUILD);
- fprintf(stderr, "%s\n\n", JCOPYRIGHT);
- fprintf(stderr, "Emulating The Independent JPEG Group's software, version %s\n\n",
- JVERSION);
- printed_version = TRUE;
- }
- cinfo->err->trace_level++;
-
- } else if (keymatch(arg, "version", 4)) {
- fprintf(stderr, "%s version %s (build %s)\n",
- PACKAGE_NAME, VERSION, BUILD);
- exit(EXIT_SUCCESS);
-
- } else if (keymatch(arg, "flip", 1)) {
- /* Mirror left-right or top-bottom. */
- if (++argn >= argc) /* advance to next argument */
- usage();
- if (keymatch(argv[argn], "horizontal", 1))
- select_transform(JXFORM_FLIP_H);
- else if (keymatch(argv[argn], "vertical", 1))
- select_transform(JXFORM_FLIP_V);
- else
- usage();
-
- } else if (keymatch(arg, "grayscale", 1) ||
- keymatch(arg, "greyscale", 1)) {
- /* Force to grayscale. */
-#if TRANSFORMS_SUPPORTED
- transformoption.force_grayscale = TRUE;
-#else
- select_transform(JXFORM_NONE); /* force an error */
-#endif
-
- } else if (keymatch(arg, "icc", 1)) {
- /* Set ICC filename. */
- if (++argn >= argc) /* advance to next argument */
- usage();
- icc_filename = argv[argn];
-
- } else if (keymatch(arg, "maxmemory", 3)) {
- /* Maximum memory in Kb (or Mb with 'm'). */
- long lval;
- char ch = 'x';
-
- if (++argn >= argc) /* advance to next argument */
- usage();
- if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1)
- usage();
- if (ch == 'm' || ch == 'M')
- lval *= 1000L;
- cinfo->mem->max_memory_to_use = lval * 1000L;
-
- } else if (keymatch(arg, "maxscans", 4)) {
- if (++argn >= argc) /* advance to next argument */
- usage();
- if (sscanf(argv[argn], "%u", &max_scans) != 1)
- usage();
-
- } else if (keymatch(arg, "optimize", 1) || keymatch(arg, "optimise", 1)) {
- /* Enable entropy parm optimization. */
-#ifdef ENTROPY_OPT_SUPPORTED
- cinfo->optimize_coding = TRUE;
-#else
- fprintf(stderr, "%s: sorry, entropy optimization was not compiled\n",
- progname);
- exit(EXIT_FAILURE);
-#endif
-
- } else if (keymatch(arg, "outfile", 4)) {
- /* Set output file name. */
- if (++argn >= argc) /* advance to next argument */
- usage();
- outfilename = argv[argn]; /* save it away for later use */
-
- } else if (keymatch(arg, "perfect", 2)) {
- /* Fail if there is any partial edge MCUs that the transform can't
- * handle. */
- transformoption.perfect = TRUE;
-
- } else if (keymatch(arg, "progressive", 2)) {
- /* Select simple progressive mode. */
-#ifdef C_PROGRESSIVE_SUPPORTED
- simple_progressive = TRUE;
- /* We must postpone execution until num_components is known. */
-#else
- fprintf(stderr, "%s: sorry, progressive output was not compiled\n",
- progname);
- exit(EXIT_FAILURE);
-#endif
-
- } else if (keymatch(arg, "report", 3)) {
- report = TRUE;
-
- } else if (keymatch(arg, "restart", 1)) {
- /* Restart interval in MCU rows (or in MCUs with 'b'). */
- long lval;
- char ch = 'x';
-
- if (++argn >= argc) /* advance to next argument */
- usage();
- if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1)
- usage();
- if (lval < 0 || lval > 65535L)
- usage();
- if (ch == 'b' || ch == 'B') {
- cinfo->restart_interval = (unsigned int)lval;
- cinfo->restart_in_rows = 0; /* else prior '-restart n' overrides me */
- } else {
- cinfo->restart_in_rows = (int)lval;
- /* restart_interval will be computed during startup */
- }
-
- } else if (keymatch(arg, "rotate", 2)) {
- /* Rotate 90, 180, or 270 degrees (measured clockwise). */
- if (++argn >= argc) /* advance to next argument */
- usage();
- if (keymatch(argv[argn], "90", 2))
- select_transform(JXFORM_ROT_90);
- else if (keymatch(argv[argn], "180", 3))
- select_transform(JXFORM_ROT_180);
- else if (keymatch(argv[argn], "270", 3))
- select_transform(JXFORM_ROT_270);
- else
- usage();
-
- } else if (keymatch(arg, "scans", 1)) {
- /* Set scan script. */
-#ifdef C_MULTISCAN_FILES_SUPPORTED
- if (++argn >= argc) /* advance to next argument */
- usage();
- scansarg = argv[argn];
- /* We must postpone reading the file in case -progressive appears. */
-#else
- fprintf(stderr, "%s: sorry, multi-scan output was not compiled\n",
- progname);
- exit(EXIT_FAILURE);
-#endif
-
- } else if (keymatch(arg, "strict", 2)) {
- strict = TRUE;
-
- } else if (keymatch(arg, "transpose", 1)) {
- /* Transpose (across UL-to-LR axis). */
- select_transform(JXFORM_TRANSPOSE);
-
- } else if (keymatch(arg, "transverse", 6)) {
- /* Transverse transpose (across UR-to-LL axis). */
- select_transform(JXFORM_TRANSVERSE);
-
- } else if (keymatch(arg, "trim", 3)) {
- /* Trim off any partial edge MCUs that the transform can't handle. */
- transformoption.trim = TRUE;
-
- } else if (keymatch(arg, "wipe", 1)) {
-#if TRANSFORMS_SUPPORTED
- if (++argn >= argc) /* advance to next argument */
- usage();
- if (transformoption.crop /* reject multiple crop/drop/wipe requests */ ||
- !jtransform_parse_crop_spec(&transformoption, argv[argn])) {
- fprintf(stderr, "%s: bogus -wipe argument '%s'\n",
- progname, argv[argn]);
- exit(EXIT_FAILURE);
- }
- select_transform(JXFORM_WIPE);
-#else
- select_transform(JXFORM_NONE); /* force an error */
-#endif
-
- } else {
- usage(); /* bogus switch */
- }
- }
-
- /* Post-switch-scanning cleanup */
-
- if (for_real) {
-
-#ifdef C_PROGRESSIVE_SUPPORTED
- if (simple_progressive) /* process -progressive; -scans can override */
- jpeg_simple_progression(cinfo);
-#endif
-
-#ifdef C_MULTISCAN_FILES_SUPPORTED
- if (scansarg != NULL) /* process -scans if it was present */
- if (!read_scan_script(cinfo, scansarg))
- usage();
-#endif
- }
-
- return argn; /* return index of next arg (file name) */
-}
-
-
-METHODDEF(void)
-my_emit_message(j_common_ptr cinfo, int msg_level)
-{
- if (msg_level < 0) {
- /* Treat warning as fatal */
- cinfo->err->error_exit(cinfo);
- } else {
- if (cinfo->err->trace_level >= msg_level)
- cinfo->err->output_message(cinfo);
- }
-}
-
-
-/*
- * The main program.
- */
-
-int
-main(int argc, char **argv)
-{
- struct jpeg_decompress_struct srcinfo;
-#if TRANSFORMS_SUPPORTED
- struct jpeg_decompress_struct dropinfo;
- struct jpeg_error_mgr jdroperr;
- FILE *drop_file;
-#endif
- struct jpeg_compress_struct dstinfo;
- struct jpeg_error_mgr jsrcerr, jdsterr;
- struct cdjpeg_progress_mgr src_progress, dst_progress;
- jvirt_barray_ptr *src_coef_arrays;
- jvirt_barray_ptr *dst_coef_arrays;
- int file_index;
- /* We assume all-in-memory processing and can therefore use only a
- * single file pointer for sequential input and output operation.
- */
- FILE *fp;
- FILE *icc_file;
- JOCTET *icc_profile = NULL;
- long icc_len = 0;
-
- progname = argv[0];
- if (progname == NULL || progname[0] == 0)
- progname = "jpegtran"; /* in case C library doesn't provide it */
-
- /* Initialize the JPEG decompression object with default error handling. */
- srcinfo.err = jpeg_std_error(&jsrcerr);
- jpeg_create_decompress(&srcinfo);
- /* Initialize the JPEG compression object with default error handling. */
- dstinfo.err = jpeg_std_error(&jdsterr);
- jpeg_create_compress(&dstinfo);
-
- /* Scan command line to find file names.
- * It is convenient to use just one switch-parsing routine, but the switch
- * values read here are mostly ignored; we will rescan the switches after
- * opening the input file. Also note that most of the switches affect the
- * destination JPEG object, so we parse into that and then copy over what
- * needs to affect the source too.
- */
-
- file_index = parse_switches(&dstinfo, argc, argv, 0, FALSE);
- jsrcerr.trace_level = jdsterr.trace_level;
- srcinfo.mem->max_memory_to_use = dstinfo.mem->max_memory_to_use;
-
- if (strict)
- jsrcerr.emit_message = my_emit_message;
-
-#ifdef TWO_FILE_COMMANDLINE
- /* Must have either -outfile switch or explicit output file name */
- if (outfilename == NULL) {
- if (file_index != argc - 2) {
- fprintf(stderr, "%s: must name one input and one output file\n",
- progname);
- usage();
- }
- outfilename = argv[file_index + 1];
- } else {
- if (file_index != argc - 1) {
- fprintf(stderr, "%s: must name one input and one output file\n",
- progname);
- usage();
- }
- }
-#else
- /* Unix style: expect zero or one file name */
- if (file_index < argc - 1) {
- fprintf(stderr, "%s: only one input file\n", progname);
- usage();
- }
-#endif /* TWO_FILE_COMMANDLINE */
-
- /* Open the input file. */
- if (file_index < argc) {
- if ((fp = fopen(argv[file_index], READ_BINARY)) == NULL) {
- fprintf(stderr, "%s: can't open %s for reading\n", progname,
- argv[file_index]);
- exit(EXIT_FAILURE);
- }
- } else {
- /* default input file is stdin */
- fp = read_stdin();
- }
-
- if (icc_filename != NULL) {
- if ((icc_file = fopen(icc_filename, READ_BINARY)) == NULL) {
- fprintf(stderr, "%s: can't open %s\n", progname, icc_filename);
- exit(EXIT_FAILURE);
- }
- if (fseek(icc_file, 0, SEEK_END) < 0 ||
- (icc_len = ftell(icc_file)) < 1 ||
- fseek(icc_file, 0, SEEK_SET) < 0) {
- fprintf(stderr, "%s: can't determine size of %s\n", progname,
- icc_filename);
- exit(EXIT_FAILURE);
- }
- if ((icc_profile = (JOCTET *)malloc(icc_len)) == NULL) {
- fprintf(stderr, "%s: can't allocate memory for ICC profile\n", progname);
- fclose(icc_file);
- exit(EXIT_FAILURE);
- }
- if (fread(icc_profile, icc_len, 1, icc_file) < 1) {
- fprintf(stderr, "%s: can't read ICC profile from %s\n", progname,
- icc_filename);
- free(icc_profile);
- fclose(icc_file);
- exit(EXIT_FAILURE);
- }
- fclose(icc_file);
- if (copyoption == JCOPYOPT_ALL)
- copyoption = JCOPYOPT_ALL_EXCEPT_ICC;
- if (copyoption == JCOPYOPT_ICC)
- copyoption = JCOPYOPT_NONE;
- }
-
- if (report) {
- start_progress_monitor((j_common_ptr)&dstinfo, &dst_progress);
- dst_progress.report = report;
- }
- if (report || max_scans != 0) {
- start_progress_monitor((j_common_ptr)&srcinfo, &src_progress);
- src_progress.report = report;
- src_progress.max_scans = max_scans;
- }
-#if TRANSFORMS_SUPPORTED
- /* Open the drop file. */
- if (dropfilename != NULL) {
- if ((drop_file = fopen(dropfilename, READ_BINARY)) == NULL) {
- fprintf(stderr, "%s: can't open %s for reading\n", progname,
- dropfilename);
- exit(EXIT_FAILURE);
- }
- dropinfo.err = jpeg_std_error(&jdroperr);
- jpeg_create_decompress(&dropinfo);
- jpeg_stdio_src(&dropinfo, drop_file);
- } else {
- drop_file = NULL;
- }
-#endif
-
- /* Specify data source for decompression */
- jpeg_stdio_src(&srcinfo, fp);
-
- /* Enable saving of extra markers that we want to copy */
- jcopy_markers_setup(&srcinfo, copyoption);
-
- /* Read file header */
- (void)jpeg_read_header(&srcinfo, TRUE);
-
-#if TRANSFORMS_SUPPORTED
- if (dropfilename != NULL) {
- (void)jpeg_read_header(&dropinfo, TRUE);
- transformoption.crop_width = dropinfo.image_width;
- transformoption.crop_width_set = JCROP_POS;
- transformoption.crop_height = dropinfo.image_height;
- transformoption.crop_height_set = JCROP_POS;
- transformoption.drop_ptr = &dropinfo;
- }
-#endif
-
- /* Any space needed by a transform option must be requested before
- * jpeg_read_coefficients so that memory allocation will be done right.
- */
-#if TRANSFORMS_SUPPORTED
- /* Fail right away if -perfect is given and transformation is not perfect.
- */
- if (!jtransform_request_workspace(&srcinfo, &transformoption)) {
- fprintf(stderr, "%s: transformation is not perfect\n", progname);
- exit(EXIT_FAILURE);
- }
-#endif
-
- /* Read source file as DCT coefficients */
- src_coef_arrays = jpeg_read_coefficients(&srcinfo);
-
-#if TRANSFORMS_SUPPORTED
- if (dropfilename != NULL) {
- transformoption.drop_coef_arrays = jpeg_read_coefficients(&dropinfo);
- }
-#endif
-
- /* Initialize destination compression parameters from source values */
- jpeg_copy_critical_parameters(&srcinfo, &dstinfo);
-
- /* Adjust destination parameters if required by transform options;
- * also find out which set of coefficient arrays will hold the output.
- */
-#if TRANSFORMS_SUPPORTED
- dst_coef_arrays = jtransform_adjust_parameters(&srcinfo, &dstinfo,
- src_coef_arrays,
- &transformoption);
-#else
- dst_coef_arrays = src_coef_arrays;
-#endif
-
- /* Close input file, if we opened it.
- * Note: we assume that jpeg_read_coefficients consumed all input
- * until JPEG_REACHED_EOI, and that jpeg_finish_decompress will
- * only consume more while (!cinfo->inputctl->eoi_reached).
- * We cannot call jpeg_finish_decompress here since we still need the
- * virtual arrays allocated from the source object for processing.
- */
- if (fp != stdin)
- fclose(fp);
-
- /* Open the output file. */
- if (outfilename != NULL) {
- if ((fp = fopen(outfilename, WRITE_BINARY)) == NULL) {
- fprintf(stderr, "%s: can't open %s for writing\n", progname,
- outfilename);
- exit(EXIT_FAILURE);
- }
- } else {
- /* default output file is stdout */
- fp = write_stdout();
- }
-
- /* Adjust default compression parameters by re-parsing the options */
- file_index = parse_switches(&dstinfo, argc, argv, 0, TRUE);
-
- /* Specify data destination for compression */
- jpeg_stdio_dest(&dstinfo, fp);
-
- /* Start compressor (note no image data is actually written here) */
- jpeg_write_coefficients(&dstinfo, dst_coef_arrays);
-
- /* Copy to the output file any extra markers that we want to preserve */
- jcopy_markers_execute(&srcinfo, &dstinfo, copyoption);
-
- if (icc_profile != NULL)
- jpeg_write_icc_profile(&dstinfo, icc_profile, (unsigned int)icc_len);
-
- /* Execute image transformation, if any */
-#if TRANSFORMS_SUPPORTED
- jtransform_execute_transformation(&srcinfo, &dstinfo, src_coef_arrays,
- &transformoption);
-#endif
-
- /* Finish compression and release memory */
- jpeg_finish_compress(&dstinfo);
- jpeg_destroy_compress(&dstinfo);
-#if TRANSFORMS_SUPPORTED
- if (dropfilename != NULL) {
- (void)jpeg_finish_decompress(&dropinfo);
- jpeg_destroy_decompress(&dropinfo);
- }
-#endif
- (void)jpeg_finish_decompress(&srcinfo);
- jpeg_destroy_decompress(&srcinfo);
-
- /* Close output file, if we opened it */
- if (fp != stdout)
- fclose(fp);
-#if TRANSFORMS_SUPPORTED
- if (drop_file != NULL)
- fclose(drop_file);
-#endif
-
- if (report)
- end_progress_monitor((j_common_ptr)&dstinfo);
- if (report || max_scans != 0)
- end_progress_monitor((j_common_ptr)&srcinfo);
-
- free(icc_profile);
-
- /* All done. */
-#if TRANSFORMS_SUPPORTED
- if (dropfilename != NULL)
- exit(jsrcerr.num_warnings + jdroperr.num_warnings +
- jdsterr.num_warnings ? EXIT_WARNING : EXIT_SUCCESS);
-#endif
- exit(jsrcerr.num_warnings + jdsterr.num_warnings ?
- EXIT_WARNING : EXIT_SUCCESS);
- return 0; /* suppress no-return-value warnings */
-}
diff --git a/contrib/libs/libjpeg-turbo/jpegtran/ya.make b/contrib/libs/libjpeg-turbo/jpegtran/ya.make
deleted file mode 100644
index 62ca681a31..0000000000
--- a/contrib/libs/libjpeg-turbo/jpegtran/ya.make
+++ /dev/null
@@ -1,28 +0,0 @@
-# Generated by devtools/yamaker.
-
-PROGRAM()
-
-WITHOUT_LICENSE_TEXTS()
-
-PEERDIR(
- contrib/libs/libjpeg-turbo
-)
-
-ADDINCL(
- contrib/libs/libjpeg-turbo
-)
-
-NO_COMPILER_WARNINGS()
-
-NO_RUNTIME()
-
-SRCDIR(contrib/libs/libjpeg-turbo)
-
-SRCS(
- cdjpeg.c
- jpegtran.c
- rdswitch.c
- transupp.c
-)
-
-END()
diff --git a/contrib/libs/libjpeg-turbo/jquant1.c b/contrib/libs/libjpeg-turbo/jquant1.c
deleted file mode 100644
index 73b83e16e5..0000000000
--- a/contrib/libs/libjpeg-turbo/jquant1.c
+++ /dev/null
@@ -1,856 +0,0 @@
-/*
- * jquant1.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1996, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2009, 2015, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains 1-pass color quantization (color mapping) routines.
- * These routines provide mapping to a fixed color map using equally spaced
- * color values. Optional Floyd-Steinberg or ordered dithering is available.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-
-#ifdef QUANT_1PASS_SUPPORTED
-
-
-/*
- * The main purpose of 1-pass quantization is to provide a fast, if not very
- * high quality, colormapped output capability. A 2-pass quantizer usually
- * gives better visual quality; however, for quantized grayscale output this
- * quantizer is perfectly adequate. Dithering is highly recommended with this
- * quantizer, though you can turn it off if you really want to.
- *
- * In 1-pass quantization the colormap must be chosen in advance of seeing the
- * image. We use a map consisting of all combinations of Ncolors[i] color
- * values for the i'th component. The Ncolors[] values are chosen so that
- * their product, the total number of colors, is no more than that requested.
- * (In most cases, the product will be somewhat less.)
- *
- * Since the colormap is orthogonal, the representative value for each color
- * component can be determined without considering the other components;
- * then these indexes can be combined into a colormap index by a standard
- * N-dimensional-array-subscript calculation. Most of the arithmetic involved
- * can be precalculated and stored in the lookup table colorindex[].
- * colorindex[i][j] maps pixel value j in component i to the nearest
- * representative value (grid plane) for that component; this index is
- * multiplied by the array stride for component i, so that the
- * index of the colormap entry closest to a given pixel value is just
- * sum( colorindex[component-number][pixel-component-value] )
- * Aside from being fast, this scheme allows for variable spacing between
- * representative values with no additional lookup cost.
- *
- * If gamma correction has been applied in color conversion, it might be wise
- * to adjust the color grid spacing so that the representative colors are
- * equidistant in linear space. At this writing, gamma correction is not
- * implemented by jdcolor, so nothing is done here.
- */
-
-
-/* Declarations for ordered dithering.
- *
- * We use a standard 16x16 ordered dither array. The basic concept of ordered
- * dithering is described in many references, for instance Dale Schumacher's
- * chapter II.2 of Graphics Gems II (James Arvo, ed. Academic Press, 1991).
- * In place of Schumacher's comparisons against a "threshold" value, we add a
- * "dither" value to the input pixel and then round the result to the nearest
- * output value. The dither value is equivalent to (0.5 - threshold) times
- * the distance between output values. For ordered dithering, we assume that
- * the output colors are equally spaced; if not, results will probably be
- * worse, since the dither may be too much or too little at a given point.
- *
- * The normal calculation would be to form pixel value + dither, range-limit
- * this to 0..MAXJSAMPLE, and then index into the colorindex table as usual.
- * We can skip the separate range-limiting step by extending the colorindex
- * table in both directions.
- */
-
-#define ODITHER_SIZE 16 /* dimension of dither matrix */
-/* NB: if ODITHER_SIZE is not a power of 2, ODITHER_MASK uses will break */
-#define ODITHER_CELLS (ODITHER_SIZE * ODITHER_SIZE) /* # cells in matrix */
-#define ODITHER_MASK (ODITHER_SIZE - 1) /* mask for wrapping around
- counters */
-
-typedef int ODITHER_MATRIX[ODITHER_SIZE][ODITHER_SIZE];
-typedef int (*ODITHER_MATRIX_PTR)[ODITHER_SIZE];
-
-static const UINT8 base_dither_matrix[ODITHER_SIZE][ODITHER_SIZE] = {
- /* Bayer's order-4 dither array. Generated by the code given in
- * Stephen Hawley's article "Ordered Dithering" in Graphics Gems I.
- * The values in this array must range from 0 to ODITHER_CELLS-1.
- */
- { 0,192, 48,240, 12,204, 60,252, 3,195, 51,243, 15,207, 63,255 },
- { 128, 64,176,112,140, 76,188,124,131, 67,179,115,143, 79,191,127 },
- { 32,224, 16,208, 44,236, 28,220, 35,227, 19,211, 47,239, 31,223 },
- { 160, 96,144, 80,172,108,156, 92,163, 99,147, 83,175,111,159, 95 },
- { 8,200, 56,248, 4,196, 52,244, 11,203, 59,251, 7,199, 55,247 },
- { 136, 72,184,120,132, 68,180,116,139, 75,187,123,135, 71,183,119 },
- { 40,232, 24,216, 36,228, 20,212, 43,235, 27,219, 39,231, 23,215 },
- { 168,104,152, 88,164,100,148, 84,171,107,155, 91,167,103,151, 87 },
- { 2,194, 50,242, 14,206, 62,254, 1,193, 49,241, 13,205, 61,253 },
- { 130, 66,178,114,142, 78,190,126,129, 65,177,113,141, 77,189,125 },
- { 34,226, 18,210, 46,238, 30,222, 33,225, 17,209, 45,237, 29,221 },
- { 162, 98,146, 82,174,110,158, 94,161, 97,145, 81,173,109,157, 93 },
- { 10,202, 58,250, 6,198, 54,246, 9,201, 57,249, 5,197, 53,245 },
- { 138, 74,186,122,134, 70,182,118,137, 73,185,121,133, 69,181,117 },
- { 42,234, 26,218, 38,230, 22,214, 41,233, 25,217, 37,229, 21,213 },
- { 170,106,154, 90,166,102,150, 86,169,105,153, 89,165,101,149, 85 }
-};
-
-
-/* Declarations for Floyd-Steinberg dithering.
- *
- * Errors are accumulated into the array fserrors[], at a resolution of
- * 1/16th of a pixel count. The error at a given pixel is propagated
- * to its not-yet-processed neighbors using the standard F-S fractions,
- * ... (here) 7/16
- * 3/16 5/16 1/16
- * We work left-to-right on even rows, right-to-left on odd rows.
- *
- * We can get away with a single array (holding one row's worth of errors)
- * by using it to store the current row's errors at pixel columns not yet
- * processed, but the next row's errors at columns already processed. We
- * need only a few extra variables to hold the errors immediately around the
- * current column. (If we are lucky, those variables are in registers, but
- * even if not, they're probably cheaper to access than array elements are.)
- *
- * The fserrors[] array is indexed [component#][position].
- * We provide (#columns + 2) entries per component; the extra entry at each
- * end saves us from special-casing the first and last pixels.
- */
-
-#if BITS_IN_JSAMPLE == 8
-typedef INT16 FSERROR; /* 16 bits should be enough */
-typedef int LOCFSERROR; /* use 'int' for calculation temps */
-#else
-typedef JLONG FSERROR; /* may need more than 16 bits */
-typedef JLONG LOCFSERROR; /* be sure calculation temps are big enough */
-#endif
-
-typedef FSERROR *FSERRPTR; /* pointer to error array */
-
-
-/* Private subobject */
-
-#define MAX_Q_COMPS 4 /* max components I can handle */
-
-typedef struct {
- struct jpeg_color_quantizer pub; /* public fields */
-
- /* Initially allocated colormap is saved here */
- JSAMPARRAY sv_colormap; /* The color map as a 2-D pixel array */
- int sv_actual; /* number of entries in use */
-
- JSAMPARRAY colorindex; /* Precomputed mapping for speed */
- /* colorindex[i][j] = index of color closest to pixel value j in component i,
- * premultiplied as described above. Since colormap indexes must fit into
- * JSAMPLEs, the entries of this array will too.
- */
- boolean is_padded; /* is the colorindex padded for odither? */
-
- int Ncolors[MAX_Q_COMPS]; /* # of values allocated to each component */
-
- /* Variables for ordered dithering */
- int row_index; /* cur row's vertical index in dither matrix */
- ODITHER_MATRIX_PTR odither[MAX_Q_COMPS]; /* one dither array per component */
-
- /* Variables for Floyd-Steinberg dithering */
- FSERRPTR fserrors[MAX_Q_COMPS]; /* accumulated errors */
- boolean on_odd_row; /* flag to remember which row we are on */
-} my_cquantizer;
-
-typedef my_cquantizer *my_cquantize_ptr;
-
-
-/*
- * Policy-making subroutines for create_colormap and create_colorindex.
- * These routines determine the colormap to be used. The rest of the module
- * only assumes that the colormap is orthogonal.
- *
- * * select_ncolors decides how to divvy up the available colors
- * among the components.
- * * output_value defines the set of representative values for a component.
- * * largest_input_value defines the mapping from input values to
- * representative values for a component.
- * Note that the latter two routines may impose different policies for
- * different components, though this is not currently done.
- */
-
-
-LOCAL(int)
-select_ncolors(j_decompress_ptr cinfo, int Ncolors[])
-/* Determine allocation of desired colors to components, */
-/* and fill in Ncolors[] array to indicate choice. */
-/* Return value is total number of colors (product of Ncolors[] values). */
-{
- int nc = cinfo->out_color_components; /* number of color components */
- int max_colors = cinfo->desired_number_of_colors;
- int total_colors, iroot, i, j;
- boolean changed;
- long temp;
- int RGB_order[3] = { RGB_GREEN, RGB_RED, RGB_BLUE };
- RGB_order[0] = rgb_green[cinfo->out_color_space];
- RGB_order[1] = rgb_red[cinfo->out_color_space];
- RGB_order[2] = rgb_blue[cinfo->out_color_space];
-
- /* We can allocate at least the nc'th root of max_colors per component. */
- /* Compute floor(nc'th root of max_colors). */
- iroot = 1;
- do {
- iroot++;
- temp = iroot; /* set temp = iroot ** nc */
- for (i = 1; i < nc; i++)
- temp *= iroot;
- } while (temp <= (long)max_colors); /* repeat till iroot exceeds root */
- iroot--; /* now iroot = floor(root) */
-
- /* Must have at least 2 color values per component */
- if (iroot < 2)
- ERREXIT1(cinfo, JERR_QUANT_FEW_COLORS, (int)temp);
-
- /* Initialize to iroot color values for each component */
- total_colors = 1;
- for (i = 0; i < nc; i++) {
- Ncolors[i] = iroot;
- total_colors *= iroot;
- }
- /* We may be able to increment the count for one or more components without
- * exceeding max_colors, though we know not all can be incremented.
- * Sometimes, the first component can be incremented more than once!
- * (Example: for 16 colors, we start at 2*2*2, go to 3*2*2, then 4*2*2.)
- * In RGB colorspace, try to increment G first, then R, then B.
- */
- do {
- changed = FALSE;
- for (i = 0; i < nc; i++) {
- j = (cinfo->out_color_space == JCS_RGB ? RGB_order[i] : i);
- /* calculate new total_colors if Ncolors[j] is incremented */
- temp = total_colors / Ncolors[j];
- temp *= Ncolors[j] + 1; /* done in long arith to avoid oflo */
- if (temp > (long)max_colors)
- break; /* won't fit, done with this pass */
- Ncolors[j]++; /* OK, apply the increment */
- total_colors = (int)temp;
- changed = TRUE;
- }
- } while (changed);
-
- return total_colors;
-}
-
-
-LOCAL(int)
-output_value(j_decompress_ptr cinfo, int ci, int j, int maxj)
-/* Return j'th output value, where j will range from 0 to maxj */
-/* The output values must fall in 0..MAXJSAMPLE in increasing order */
-{
- /* We always provide values 0 and MAXJSAMPLE for each component;
- * any additional values are equally spaced between these limits.
- * (Forcing the upper and lower values to the limits ensures that
- * dithering can't produce a color outside the selected gamut.)
- */
- return (int)(((JLONG)j * MAXJSAMPLE + maxj / 2) / maxj);
-}
-
-
-LOCAL(int)
-largest_input_value(j_decompress_ptr cinfo, int ci, int j, int maxj)
-/* Return largest input value that should map to j'th output value */
-/* Must have largest(j=0) >= 0, and largest(j=maxj) >= MAXJSAMPLE */
-{
- /* Breakpoints are halfway between values returned by output_value */
- return (int)(((JLONG)(2 * j + 1) * MAXJSAMPLE + maxj) / (2 * maxj));
-}
-
-
-/*
- * Create the colormap.
- */
-
-LOCAL(void)
-create_colormap(j_decompress_ptr cinfo)
-{
- my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
- JSAMPARRAY colormap; /* Created colormap */
- int total_colors; /* Number of distinct output colors */
- int i, j, k, nci, blksize, blkdist, ptr, val;
-
- /* Select number of colors for each component */
- total_colors = select_ncolors(cinfo, cquantize->Ncolors);
-
- /* Report selected color counts */
- if (cinfo->out_color_components == 3)
- TRACEMS4(cinfo, 1, JTRC_QUANT_3_NCOLORS, total_colors,
- cquantize->Ncolors[0], cquantize->Ncolors[1],
- cquantize->Ncolors[2]);
- else
- TRACEMS1(cinfo, 1, JTRC_QUANT_NCOLORS, total_colors);
-
- /* Allocate and fill in the colormap. */
- /* The colors are ordered in the map in standard row-major order, */
- /* i.e. rightmost (highest-indexed) color changes most rapidly. */
-
- colormap = (*cinfo->mem->alloc_sarray)
- ((j_common_ptr)cinfo, JPOOL_IMAGE,
- (JDIMENSION)total_colors, (JDIMENSION)cinfo->out_color_components);
-
- /* blksize is number of adjacent repeated entries for a component */
- /* blkdist is distance between groups of identical entries for a component */
- blkdist = total_colors;
-
- for (i = 0; i < cinfo->out_color_components; i++) {
- /* fill in colormap entries for i'th color component */
- nci = cquantize->Ncolors[i]; /* # of distinct values for this color */
- blksize = blkdist / nci;
- for (j = 0; j < nci; j++) {
- /* Compute j'th output value (out of nci) for component */
- val = output_value(cinfo, i, j, nci - 1);
- /* Fill in all colormap entries that have this value of this component */
- for (ptr = j * blksize; ptr < total_colors; ptr += blkdist) {
- /* fill in blksize entries beginning at ptr */
- for (k = 0; k < blksize; k++)
- colormap[i][ptr + k] = (JSAMPLE)val;
- }
- }
- blkdist = blksize; /* blksize of this color is blkdist of next */
- }
-
- /* Save the colormap in private storage,
- * where it will survive color quantization mode changes.
- */
- cquantize->sv_colormap = colormap;
- cquantize->sv_actual = total_colors;
-}
-
-
-/*
- * Create the color index table.
- */
-
-LOCAL(void)
-create_colorindex(j_decompress_ptr cinfo)
-{
- my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
- JSAMPROW indexptr;
- int i, j, k, nci, blksize, val, pad;
-
- /* For ordered dither, we pad the color index tables by MAXJSAMPLE in
- * each direction (input index values can be -MAXJSAMPLE .. 2*MAXJSAMPLE).
- * This is not necessary in the other dithering modes. However, we
- * flag whether it was done in case user changes dithering mode.
- */
- if (cinfo->dither_mode == JDITHER_ORDERED) {
- pad = MAXJSAMPLE * 2;
- cquantize->is_padded = TRUE;
- } else {
- pad = 0;
- cquantize->is_padded = FALSE;
- }
-
- cquantize->colorindex = (*cinfo->mem->alloc_sarray)
- ((j_common_ptr)cinfo, JPOOL_IMAGE,
- (JDIMENSION)(MAXJSAMPLE + 1 + pad),
- (JDIMENSION)cinfo->out_color_components);
-
- /* blksize is number of adjacent repeated entries for a component */
- blksize = cquantize->sv_actual;
-
- for (i = 0; i < cinfo->out_color_components; i++) {
- /* fill in colorindex entries for i'th color component */
- nci = cquantize->Ncolors[i]; /* # of distinct values for this color */
- blksize = blksize / nci;
-
- /* adjust colorindex pointers to provide padding at negative indexes. */
- if (pad)
- cquantize->colorindex[i] += MAXJSAMPLE;
-
- /* in loop, val = index of current output value, */
- /* and k = largest j that maps to current val */
- indexptr = cquantize->colorindex[i];
- val = 0;
- k = largest_input_value(cinfo, i, 0, nci - 1);
- for (j = 0; j <= MAXJSAMPLE; j++) {
- while (j > k) /* advance val if past boundary */
- k = largest_input_value(cinfo, i, ++val, nci - 1);
- /* premultiply so that no multiplication needed in main processing */
- indexptr[j] = (JSAMPLE)(val * blksize);
- }
- /* Pad at both ends if necessary */
- if (pad)
- for (j = 1; j <= MAXJSAMPLE; j++) {
- indexptr[-j] = indexptr[0];
- indexptr[MAXJSAMPLE + j] = indexptr[MAXJSAMPLE];
- }
- }
-}
-
-
-/*
- * Create an ordered-dither array for a component having ncolors
- * distinct output values.
- */
-
-LOCAL(ODITHER_MATRIX_PTR)
-make_odither_array(j_decompress_ptr cinfo, int ncolors)
-{
- ODITHER_MATRIX_PTR odither;
- int j, k;
- JLONG num, den;
-
- odither = (ODITHER_MATRIX_PTR)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- sizeof(ODITHER_MATRIX));
- /* The inter-value distance for this color is MAXJSAMPLE/(ncolors-1).
- * Hence the dither value for the matrix cell with fill order f
- * (f=0..N-1) should be (N-1-2*f)/(2*N) * MAXJSAMPLE/(ncolors-1).
- * On 16-bit-int machine, be careful to avoid overflow.
- */
- den = 2 * ODITHER_CELLS * ((JLONG)(ncolors - 1));
- for (j = 0; j < ODITHER_SIZE; j++) {
- for (k = 0; k < ODITHER_SIZE; k++) {
- num = ((JLONG)(ODITHER_CELLS - 1 -
- 2 * ((int)base_dither_matrix[j][k]))) * MAXJSAMPLE;
- /* Ensure round towards zero despite C's lack of consistency
- * about rounding negative values in integer division...
- */
- odither[j][k] = (int)(num < 0 ? -((-num) / den) : num / den);
- }
- }
- return odither;
-}
-
-
-/*
- * Create the ordered-dither tables.
- * Components having the same number of representative colors may
- * share a dither table.
- */
-
-LOCAL(void)
-create_odither_tables(j_decompress_ptr cinfo)
-{
- my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
- ODITHER_MATRIX_PTR odither;
- int i, j, nci;
-
- for (i = 0; i < cinfo->out_color_components; i++) {
- nci = cquantize->Ncolors[i]; /* # of distinct values for this color */
- odither = NULL; /* search for matching prior component */
- for (j = 0; j < i; j++) {
- if (nci == cquantize->Ncolors[j]) {
- odither = cquantize->odither[j];
- break;
- }
- }
- if (odither == NULL) /* need a new table? */
- odither = make_odither_array(cinfo, nci);
- cquantize->odither[i] = odither;
- }
-}
-
-
-/*
- * Map some rows of pixels to the output colormapped representation.
- */
-
-METHODDEF(void)
-color_quantize(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPARRAY output_buf, int num_rows)
-/* General case, no dithering */
-{
- my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
- JSAMPARRAY colorindex = cquantize->colorindex;
- register int pixcode, ci;
- register JSAMPROW ptrin, ptrout;
- int row;
- JDIMENSION col;
- JDIMENSION width = cinfo->output_width;
- register int nc = cinfo->out_color_components;
-
- for (row = 0; row < num_rows; row++) {
- ptrin = input_buf[row];
- ptrout = output_buf[row];
- for (col = width; col > 0; col--) {
- pixcode = 0;
- for (ci = 0; ci < nc; ci++) {
- pixcode += colorindex[ci][*ptrin++];
- }
- *ptrout++ = (JSAMPLE)pixcode;
- }
- }
-}
-
-
-METHODDEF(void)
-color_quantize3(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPARRAY output_buf, int num_rows)
-/* Fast path for out_color_components==3, no dithering */
-{
- my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
- register int pixcode;
- register JSAMPROW ptrin, ptrout;
- JSAMPROW colorindex0 = cquantize->colorindex[0];
- JSAMPROW colorindex1 = cquantize->colorindex[1];
- JSAMPROW colorindex2 = cquantize->colorindex[2];
- int row;
- JDIMENSION col;
- JDIMENSION width = cinfo->output_width;
-
- for (row = 0; row < num_rows; row++) {
- ptrin = input_buf[row];
- ptrout = output_buf[row];
- for (col = width; col > 0; col--) {
- pixcode = colorindex0[*ptrin++];
- pixcode += colorindex1[*ptrin++];
- pixcode += colorindex2[*ptrin++];
- *ptrout++ = (JSAMPLE)pixcode;
- }
- }
-}
-
-
-METHODDEF(void)
-quantize_ord_dither(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPARRAY output_buf, int num_rows)
-/* General case, with ordered dithering */
-{
- my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
- register JSAMPROW input_ptr;
- register JSAMPROW output_ptr;
- JSAMPROW colorindex_ci;
- int *dither; /* points to active row of dither matrix */
- int row_index, col_index; /* current indexes into dither matrix */
- int nc = cinfo->out_color_components;
- int ci;
- int row;
- JDIMENSION col;
- JDIMENSION width = cinfo->output_width;
-
- for (row = 0; row < num_rows; row++) {
- /* Initialize output values to 0 so can process components separately */
- jzero_far((void *)output_buf[row], (size_t)(width * sizeof(JSAMPLE)));
- row_index = cquantize->row_index;
- for (ci = 0; ci < nc; ci++) {
- input_ptr = input_buf[row] + ci;
- output_ptr = output_buf[row];
- colorindex_ci = cquantize->colorindex[ci];
- dither = cquantize->odither[ci][row_index];
- col_index = 0;
-
- for (col = width; col > 0; col--) {
- /* Form pixel value + dither, range-limit to 0..MAXJSAMPLE,
- * select output value, accumulate into output code for this pixel.
- * Range-limiting need not be done explicitly, as we have extended
- * the colorindex table to produce the right answers for out-of-range
- * inputs. The maximum dither is +- MAXJSAMPLE; this sets the
- * required amount of padding.
- */
- *output_ptr +=
- colorindex_ci[*input_ptr + dither[col_index]];
- input_ptr += nc;
- output_ptr++;
- col_index = (col_index + 1) & ODITHER_MASK;
- }
- }
- /* Advance row index for next row */
- row_index = (row_index + 1) & ODITHER_MASK;
- cquantize->row_index = row_index;
- }
-}
-
-
-METHODDEF(void)
-quantize3_ord_dither(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPARRAY output_buf, int num_rows)
-/* Fast path for out_color_components==3, with ordered dithering */
-{
- my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
- register int pixcode;
- register JSAMPROW input_ptr;
- register JSAMPROW output_ptr;
- JSAMPROW colorindex0 = cquantize->colorindex[0];
- JSAMPROW colorindex1 = cquantize->colorindex[1];
- JSAMPROW colorindex2 = cquantize->colorindex[2];
- int *dither0; /* points to active row of dither matrix */
- int *dither1;
- int *dither2;
- int row_index, col_index; /* current indexes into dither matrix */
- int row;
- JDIMENSION col;
- JDIMENSION width = cinfo->output_width;
-
- for (row = 0; row < num_rows; row++) {
- row_index = cquantize->row_index;
- input_ptr = input_buf[row];
- output_ptr = output_buf[row];
- dither0 = cquantize->odither[0][row_index];
- dither1 = cquantize->odither[1][row_index];
- dither2 = cquantize->odither[2][row_index];
- col_index = 0;
-
- for (col = width; col > 0; col--) {
- pixcode = colorindex0[(*input_ptr++) + dither0[col_index]];
- pixcode += colorindex1[(*input_ptr++) + dither1[col_index]];
- pixcode += colorindex2[(*input_ptr++) + dither2[col_index]];
- *output_ptr++ = (JSAMPLE)pixcode;
- col_index = (col_index + 1) & ODITHER_MASK;
- }
- row_index = (row_index + 1) & ODITHER_MASK;
- cquantize->row_index = row_index;
- }
-}
-
-
-METHODDEF(void)
-quantize_fs_dither(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPARRAY output_buf, int num_rows)
-/* General case, with Floyd-Steinberg dithering */
-{
- my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
- register LOCFSERROR cur; /* current error or pixel value */
- LOCFSERROR belowerr; /* error for pixel below cur */
- LOCFSERROR bpreverr; /* error for below/prev col */
- LOCFSERROR bnexterr; /* error for below/next col */
- LOCFSERROR delta;
- register FSERRPTR errorptr; /* => fserrors[] at column before current */
- register JSAMPROW input_ptr;
- register JSAMPROW output_ptr;
- JSAMPROW colorindex_ci;
- JSAMPROW colormap_ci;
- int pixcode;
- int nc = cinfo->out_color_components;
- int dir; /* 1 for left-to-right, -1 for right-to-left */
- int dirnc; /* dir * nc */
- int ci;
- int row;
- JDIMENSION col;
- JDIMENSION width = cinfo->output_width;
- JSAMPLE *range_limit = cinfo->sample_range_limit;
- SHIFT_TEMPS
-
- for (row = 0; row < num_rows; row++) {
- /* Initialize output values to 0 so can process components separately */
- jzero_far((void *)output_buf[row], (size_t)(width * sizeof(JSAMPLE)));
- for (ci = 0; ci < nc; ci++) {
- input_ptr = input_buf[row] + ci;
- output_ptr = output_buf[row];
- if (cquantize->on_odd_row) {
- /* work right to left in this row */
- input_ptr += (width - 1) * nc; /* so point to rightmost pixel */
- output_ptr += width - 1;
- dir = -1;
- dirnc = -nc;
- errorptr = cquantize->fserrors[ci] + (width + 1); /* => entry after last column */
- } else {
- /* work left to right in this row */
- dir = 1;
- dirnc = nc;
- errorptr = cquantize->fserrors[ci]; /* => entry before first column */
- }
- colorindex_ci = cquantize->colorindex[ci];
- colormap_ci = cquantize->sv_colormap[ci];
- /* Preset error values: no error propagated to first pixel from left */
- cur = 0;
- /* and no error propagated to row below yet */
- belowerr = bpreverr = 0;
-
- for (col = width; col > 0; col--) {
- /* cur holds the error propagated from the previous pixel on the
- * current line. Add the error propagated from the previous line
- * to form the complete error correction term for this pixel, and
- * round the error term (which is expressed * 16) to an integer.
- * RIGHT_SHIFT rounds towards minus infinity, so adding 8 is correct
- * for either sign of the error value.
- * Note: errorptr points to *previous* column's array entry.
- */
- cur = RIGHT_SHIFT(cur + errorptr[dir] + 8, 4);
- /* Form pixel value + error, and range-limit to 0..MAXJSAMPLE.
- * The maximum error is +- MAXJSAMPLE; this sets the required size
- * of the range_limit array.
- */
- cur += *input_ptr;
- cur = range_limit[cur];
- /* Select output value, accumulate into output code for this pixel */
- pixcode = colorindex_ci[cur];
- *output_ptr += (JSAMPLE)pixcode;
- /* Compute actual representation error at this pixel */
- /* Note: we can do this even though we don't have the final */
- /* pixel code, because the colormap is orthogonal. */
- cur -= colormap_ci[pixcode];
- /* Compute error fractions to be propagated to adjacent pixels.
- * Add these into the running sums, and simultaneously shift the
- * next-line error sums left by 1 column.
- */
- bnexterr = cur;
- delta = cur * 2;
- cur += delta; /* form error * 3 */
- errorptr[0] = (FSERROR)(bpreverr + cur);
- cur += delta; /* form error * 5 */
- bpreverr = belowerr + cur;
- belowerr = bnexterr;
- cur += delta; /* form error * 7 */
- /* At this point cur contains the 7/16 error value to be propagated
- * to the next pixel on the current line, and all the errors for the
- * next line have been shifted over. We are therefore ready to move on.
- */
- input_ptr += dirnc; /* advance input ptr to next column */
- output_ptr += dir; /* advance output ptr to next column */
- errorptr += dir; /* advance errorptr to current column */
- }
- /* Post-loop cleanup: we must unload the final error value into the
- * final fserrors[] entry. Note we need not unload belowerr because
- * it is for the dummy column before or after the actual array.
- */
- errorptr[0] = (FSERROR)bpreverr; /* unload prev err into array */
- }
- cquantize->on_odd_row = (cquantize->on_odd_row ? FALSE : TRUE);
- }
-}
-
-
-/*
- * Allocate workspace for Floyd-Steinberg errors.
- */
-
-LOCAL(void)
-alloc_fs_workspace(j_decompress_ptr cinfo)
-{
- my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
- size_t arraysize;
- int i;
-
- arraysize = (size_t)((cinfo->output_width + 2) * sizeof(FSERROR));
- for (i = 0; i < cinfo->out_color_components; i++) {
- cquantize->fserrors[i] = (FSERRPTR)
- (*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE, arraysize);
- }
-}
-
-
-/*
- * Initialize for one-pass color quantization.
- */
-
-METHODDEF(void)
-start_pass_1_quant(j_decompress_ptr cinfo, boolean is_pre_scan)
-{
- my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
- size_t arraysize;
- int i;
-
- /* Install my colormap. */
- cinfo->colormap = cquantize->sv_colormap;
- cinfo->actual_number_of_colors = cquantize->sv_actual;
-
- /* Initialize for desired dithering mode. */
- switch (cinfo->dither_mode) {
- case JDITHER_NONE:
- if (cinfo->out_color_components == 3)
- cquantize->pub.color_quantize = color_quantize3;
- else
- cquantize->pub.color_quantize = color_quantize;
- break;
- case JDITHER_ORDERED:
- if (cinfo->out_color_components == 3)
- cquantize->pub.color_quantize = quantize3_ord_dither;
- else
- cquantize->pub.color_quantize = quantize_ord_dither;
- cquantize->row_index = 0; /* initialize state for ordered dither */
- /* If user changed to ordered dither from another mode,
- * we must recreate the color index table with padding.
- * This will cost extra space, but probably isn't very likely.
- */
- if (!cquantize->is_padded)
- create_colorindex(cinfo);
- /* Create ordered-dither tables if we didn't already. */
- if (cquantize->odither[0] == NULL)
- create_odither_tables(cinfo);
- break;
- case JDITHER_FS:
- cquantize->pub.color_quantize = quantize_fs_dither;
- cquantize->on_odd_row = FALSE; /* initialize state for F-S dither */
- /* Allocate Floyd-Steinberg workspace if didn't already. */
- if (cquantize->fserrors[0] == NULL)
- alloc_fs_workspace(cinfo);
- /* Initialize the propagated errors to zero. */
- arraysize = (size_t)((cinfo->output_width + 2) * sizeof(FSERROR));
- for (i = 0; i < cinfo->out_color_components; i++)
- jzero_far((void *)cquantize->fserrors[i], arraysize);
- break;
- default:
- ERREXIT(cinfo, JERR_NOT_COMPILED);
- break;
- }
-}
-
-
-/*
- * Finish up at the end of the pass.
- */
-
-METHODDEF(void)
-finish_pass_1_quant(j_decompress_ptr cinfo)
-{
- /* no work in 1-pass case */
-}
-
-
-/*
- * Switch to a new external colormap between output passes.
- * Shouldn't get to this module!
- */
-
-METHODDEF(void)
-new_color_map_1_quant(j_decompress_ptr cinfo)
-{
- ERREXIT(cinfo, JERR_MODE_CHANGE);
-}
-
-
-/*
- * Module initialization routine for 1-pass color quantization.
- */
-
-GLOBAL(void)
-jinit_1pass_quantizer(j_decompress_ptr cinfo)
-{
- my_cquantize_ptr cquantize;
-
- cquantize = (my_cquantize_ptr)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- sizeof(my_cquantizer));
- cinfo->cquantize = (struct jpeg_color_quantizer *)cquantize;
- cquantize->pub.start_pass = start_pass_1_quant;
- cquantize->pub.finish_pass = finish_pass_1_quant;
- cquantize->pub.new_color_map = new_color_map_1_quant;
- cquantize->fserrors[0] = NULL; /* Flag FS workspace not allocated */
- cquantize->odither[0] = NULL; /* Also flag odither arrays not allocated */
-
- /* Make sure my internal arrays won't overflow */
- if (cinfo->out_color_components > MAX_Q_COMPS)
- ERREXIT1(cinfo, JERR_QUANT_COMPONENTS, MAX_Q_COMPS);
- /* Make sure colormap indexes can be represented by JSAMPLEs */
- if (cinfo->desired_number_of_colors > (MAXJSAMPLE + 1))
- ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXJSAMPLE + 1);
-
- /* Create the colormap and color index table. */
- create_colormap(cinfo);
- create_colorindex(cinfo);
-
- /* Allocate Floyd-Steinberg workspace now if requested.
- * We do this now since it may affect the memory manager's space
- * calculations. If the user changes to FS dither mode in a later pass, we
- * will allocate the space then, and will possibly overrun the
- * max_memory_to_use setting.
- */
- if (cinfo->dither_mode == JDITHER_FS)
- alloc_fs_workspace(cinfo);
-}
-
-#endif /* QUANT_1PASS_SUPPORTED */
diff --git a/contrib/libs/libjpeg-turbo/jquant2.c b/contrib/libs/libjpeg-turbo/jquant2.c
deleted file mode 100644
index 44efb18cad..0000000000
--- a/contrib/libs/libjpeg-turbo/jquant2.c
+++ /dev/null
@@ -1,1285 +0,0 @@
-/*
- * jquant2.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1996, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2009, 2014-2015, 2020, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains 2-pass color quantization (color mapping) routines.
- * These routines provide selection of a custom color map for an image,
- * followed by mapping of the image to that color map, with optional
- * Floyd-Steinberg dithering.
- * It is also possible to use just the second pass to map to an arbitrary
- * externally-given color map.
- *
- * Note: ordered dithering is not supported, since there isn't any fast
- * way to compute intercolor distances; it's unclear that ordered dither's
- * fundamental assumptions even hold with an irregularly spaced color map.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-
-#ifdef QUANT_2PASS_SUPPORTED
-
-
-/*
- * This module implements the well-known Heckbert paradigm for color
- * quantization. Most of the ideas used here can be traced back to
- * Heckbert's seminal paper
- * Heckbert, Paul. "Color Image Quantization for Frame Buffer Display",
- * Proc. SIGGRAPH '82, Computer Graphics v.16 #3 (July 1982), pp 297-304.
- *
- * In the first pass over the image, we accumulate a histogram showing the
- * usage count of each possible color. To keep the histogram to a reasonable
- * size, we reduce the precision of the input; typical practice is to retain
- * 5 or 6 bits per color, so that 8 or 4 different input values are counted
- * in the same histogram cell.
- *
- * Next, the color-selection step begins with a box representing the whole
- * color space, and repeatedly splits the "largest" remaining box until we
- * have as many boxes as desired colors. Then the mean color in each
- * remaining box becomes one of the possible output colors.
- *
- * The second pass over the image maps each input pixel to the closest output
- * color (optionally after applying a Floyd-Steinberg dithering correction).
- * This mapping is logically trivial, but making it go fast enough requires
- * considerable care.
- *
- * Heckbert-style quantizers vary a good deal in their policies for choosing
- * the "largest" box and deciding where to cut it. The particular policies
- * used here have proved out well in experimental comparisons, but better ones
- * may yet be found.
- *
- * In earlier versions of the IJG code, this module quantized in YCbCr color
- * space, processing the raw upsampled data without a color conversion step.
- * This allowed the color conversion math to be done only once per colormap
- * entry, not once per pixel. However, that optimization precluded other
- * useful optimizations (such as merging color conversion with upsampling)
- * and it also interfered with desired capabilities such as quantizing to an
- * externally-supplied colormap. We have therefore abandoned that approach.
- * The present code works in the post-conversion color space, typically RGB.
- *
- * To improve the visual quality of the results, we actually work in scaled
- * RGB space, giving G distances more weight than R, and R in turn more than
- * B. To do everything in integer math, we must use integer scale factors.
- * The 2/3/1 scale factors used here correspond loosely to the relative
- * weights of the colors in the NTSC grayscale equation.
- * If you want to use this code to quantize a non-RGB color space, you'll
- * probably need to change these scale factors.
- */
-
-#define R_SCALE 2 /* scale R distances by this much */
-#define G_SCALE 3 /* scale G distances by this much */
-#define B_SCALE 1 /* and B by this much */
-
-static const int c_scales[3] = { R_SCALE, G_SCALE, B_SCALE };
-#define C0_SCALE c_scales[rgb_red[cinfo->out_color_space]]
-#define C1_SCALE c_scales[rgb_green[cinfo->out_color_space]]
-#define C2_SCALE c_scales[rgb_blue[cinfo->out_color_space]]
-
-/*
- * First we have the histogram data structure and routines for creating it.
- *
- * The number of bits of precision can be adjusted by changing these symbols.
- * We recommend keeping 6 bits for G and 5 each for R and B.
- * If you have plenty of memory and cycles, 6 bits all around gives marginally
- * better results; if you are short of memory, 5 bits all around will save
- * some space but degrade the results.
- * To maintain a fully accurate histogram, we'd need to allocate a "long"
- * (preferably unsigned long) for each cell. In practice this is overkill;
- * we can get by with 16 bits per cell. Few of the cell counts will overflow,
- * and clamping those that do overflow to the maximum value will give close-
- * enough results. This reduces the recommended histogram size from 256Kb
- * to 128Kb, which is a useful savings on PC-class machines.
- * (In the second pass the histogram space is re-used for pixel mapping data;
- * in that capacity, each cell must be able to store zero to the number of
- * desired colors. 16 bits/cell is plenty for that too.)
- * Since the JPEG code is intended to run in small memory model on 80x86
- * machines, we can't just allocate the histogram in one chunk. Instead
- * of a true 3-D array, we use a row of pointers to 2-D arrays. Each
- * pointer corresponds to a C0 value (typically 2^5 = 32 pointers) and
- * each 2-D array has 2^6*2^5 = 2048 or 2^6*2^6 = 4096 entries.
- */
-
-#define MAXNUMCOLORS (MAXJSAMPLE + 1) /* maximum size of colormap */
-
-/* These will do the right thing for either R,G,B or B,G,R color order,
- * but you may not like the results for other color orders.
- */
-#define HIST_C0_BITS 5 /* bits of precision in R/B histogram */
-#define HIST_C1_BITS 6 /* bits of precision in G histogram */
-#define HIST_C2_BITS 5 /* bits of precision in B/R histogram */
-
-/* Number of elements along histogram axes. */
-#define HIST_C0_ELEMS (1 << HIST_C0_BITS)
-#define HIST_C1_ELEMS (1 << HIST_C1_BITS)
-#define HIST_C2_ELEMS (1 << HIST_C2_BITS)
-
-/* These are the amounts to shift an input value to get a histogram index. */
-#define C0_SHIFT (BITS_IN_JSAMPLE - HIST_C0_BITS)
-#define C1_SHIFT (BITS_IN_JSAMPLE - HIST_C1_BITS)
-#define C2_SHIFT (BITS_IN_JSAMPLE - HIST_C2_BITS)
-
-
-typedef UINT16 histcell; /* histogram cell; prefer an unsigned type */
-
-typedef histcell *histptr; /* for pointers to histogram cells */
-
-typedef histcell hist1d[HIST_C2_ELEMS]; /* typedefs for the array */
-typedef hist1d *hist2d; /* type for the 2nd-level pointers */
-typedef hist2d *hist3d; /* type for top-level pointer */
-
-
-/* Declarations for Floyd-Steinberg dithering.
- *
- * Errors are accumulated into the array fserrors[], at a resolution of
- * 1/16th of a pixel count. The error at a given pixel is propagated
- * to its not-yet-processed neighbors using the standard F-S fractions,
- * ... (here) 7/16
- * 3/16 5/16 1/16
- * We work left-to-right on even rows, right-to-left on odd rows.
- *
- * We can get away with a single array (holding one row's worth of errors)
- * by using it to store the current row's errors at pixel columns not yet
- * processed, but the next row's errors at columns already processed. We
- * need only a few extra variables to hold the errors immediately around the
- * current column. (If we are lucky, those variables are in registers, but
- * even if not, they're probably cheaper to access than array elements are.)
- *
- * The fserrors[] array has (#columns + 2) entries; the extra entry at
- * each end saves us from special-casing the first and last pixels.
- * Each entry is three values long, one value for each color component.
- */
-
-#if BITS_IN_JSAMPLE == 8
-typedef INT16 FSERROR; /* 16 bits should be enough */
-typedef int LOCFSERROR; /* use 'int' for calculation temps */
-#else
-typedef JLONG FSERROR; /* may need more than 16 bits */
-typedef JLONG LOCFSERROR; /* be sure calculation temps are big enough */
-#endif
-
-typedef FSERROR *FSERRPTR; /* pointer to error array */
-
-
-/* Private subobject */
-
-typedef struct {
- struct jpeg_color_quantizer pub; /* public fields */
-
- /* Space for the eventually created colormap is stashed here */
- JSAMPARRAY sv_colormap; /* colormap allocated at init time */
- int desired; /* desired # of colors = size of colormap */
-
- /* Variables for accumulating image statistics */
- hist3d histogram; /* pointer to the histogram */
-
- boolean needs_zeroed; /* TRUE if next pass must zero histogram */
-
- /* Variables for Floyd-Steinberg dithering */
- FSERRPTR fserrors; /* accumulated errors */
- boolean on_odd_row; /* flag to remember which row we are on */
- int *error_limiter; /* table for clamping the applied error */
-} my_cquantizer;
-
-typedef my_cquantizer *my_cquantize_ptr;
-
-
-/*
- * Prescan some rows of pixels.
- * In this module the prescan simply updates the histogram, which has been
- * initialized to zeroes by start_pass.
- * An output_buf parameter is required by the method signature, but no data
- * is actually output (in fact the buffer controller is probably passing a
- * NULL pointer).
- */
-
-METHODDEF(void)
-prescan_quantize(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPARRAY output_buf, int num_rows)
-{
- my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
- register JSAMPROW ptr;
- register histptr histp;
- register hist3d histogram = cquantize->histogram;
- int row;
- JDIMENSION col;
- JDIMENSION width = cinfo->output_width;
-
- for (row = 0; row < num_rows; row++) {
- ptr = input_buf[row];
- for (col = width; col > 0; col--) {
- /* get pixel value and index into the histogram */
- histp = &histogram[ptr[0] >> C0_SHIFT]
- [ptr[1] >> C1_SHIFT]
- [ptr[2] >> C2_SHIFT];
- /* increment, check for overflow and undo increment if so. */
- if (++(*histp) <= 0)
- (*histp)--;
- ptr += 3;
- }
- }
-}
-
-
-/*
- * Next we have the really interesting routines: selection of a colormap
- * given the completed histogram.
- * These routines work with a list of "boxes", each representing a rectangular
- * subset of the input color space (to histogram precision).
- */
-
-typedef struct {
- /* The bounds of the box (inclusive); expressed as histogram indexes */
- int c0min, c0max;
- int c1min, c1max;
- int c2min, c2max;
- /* The volume (actually 2-norm) of the box */
- JLONG volume;
- /* The number of nonzero histogram cells within this box */
- long colorcount;
-} box;
-
-typedef box *boxptr;
-
-
-LOCAL(boxptr)
-find_biggest_color_pop(boxptr boxlist, int numboxes)
-/* Find the splittable box with the largest color population */
-/* Returns NULL if no splittable boxes remain */
-{
- register boxptr boxp;
- register int i;
- register long maxc = 0;
- boxptr which = NULL;
-
- for (i = 0, boxp = boxlist; i < numboxes; i++, boxp++) {
- if (boxp->colorcount > maxc && boxp->volume > 0) {
- which = boxp;
- maxc = boxp->colorcount;
- }
- }
- return which;
-}
-
-
-LOCAL(boxptr)
-find_biggest_volume(boxptr boxlist, int numboxes)
-/* Find the splittable box with the largest (scaled) volume */
-/* Returns NULL if no splittable boxes remain */
-{
- register boxptr boxp;
- register int i;
- register JLONG maxv = 0;
- boxptr which = NULL;
-
- for (i = 0, boxp = boxlist; i < numboxes; i++, boxp++) {
- if (boxp->volume > maxv) {
- which = boxp;
- maxv = boxp->volume;
- }
- }
- return which;
-}
-
-
-LOCAL(void)
-update_box(j_decompress_ptr cinfo, boxptr boxp)
-/* Shrink the min/max bounds of a box to enclose only nonzero elements, */
-/* and recompute its volume and population */
-{
- my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
- hist3d histogram = cquantize->histogram;
- histptr histp;
- int c0, c1, c2;
- int c0min, c0max, c1min, c1max, c2min, c2max;
- JLONG dist0, dist1, dist2;
- long ccount;
-
- c0min = boxp->c0min; c0max = boxp->c0max;
- c1min = boxp->c1min; c1max = boxp->c1max;
- c2min = boxp->c2min; c2max = boxp->c2max;
-
- if (c0max > c0min)
- for (c0 = c0min; c0 <= c0max; c0++)
- for (c1 = c1min; c1 <= c1max; c1++) {
- histp = &histogram[c0][c1][c2min];
- for (c2 = c2min; c2 <= c2max; c2++)
- if (*histp++ != 0) {
- boxp->c0min = c0min = c0;
- goto have_c0min;
- }
- }
-have_c0min:
- if (c0max > c0min)
- for (c0 = c0max; c0 >= c0min; c0--)
- for (c1 = c1min; c1 <= c1max; c1++) {
- histp = &histogram[c0][c1][c2min];
- for (c2 = c2min; c2 <= c2max; c2++)
- if (*histp++ != 0) {
- boxp->c0max = c0max = c0;
- goto have_c0max;
- }
- }
-have_c0max:
- if (c1max > c1min)
- for (c1 = c1min; c1 <= c1max; c1++)
- for (c0 = c0min; c0 <= c0max; c0++) {
- histp = &histogram[c0][c1][c2min];
- for (c2 = c2min; c2 <= c2max; c2++)
- if (*histp++ != 0) {
- boxp->c1min = c1min = c1;
- goto have_c1min;
- }
- }
-have_c1min:
- if (c1max > c1min)
- for (c1 = c1max; c1 >= c1min; c1--)
- for (c0 = c0min; c0 <= c0max; c0++) {
- histp = &histogram[c0][c1][c2min];
- for (c2 = c2min; c2 <= c2max; c2++)
- if (*histp++ != 0) {
- boxp->c1max = c1max = c1;
- goto have_c1max;
- }
- }
-have_c1max:
- if (c2max > c2min)
- for (c2 = c2min; c2 <= c2max; c2++)
- for (c0 = c0min; c0 <= c0max; c0++) {
- histp = &histogram[c0][c1min][c2];
- for (c1 = c1min; c1 <= c1max; c1++, histp += HIST_C2_ELEMS)
- if (*histp != 0) {
- boxp->c2min = c2min = c2;
- goto have_c2min;
- }
- }
-have_c2min:
- if (c2max > c2min)
- for (c2 = c2max; c2 >= c2min; c2--)
- for (c0 = c0min; c0 <= c0max; c0++) {
- histp = &histogram[c0][c1min][c2];
- for (c1 = c1min; c1 <= c1max; c1++, histp += HIST_C2_ELEMS)
- if (*histp != 0) {
- boxp->c2max = c2max = c2;
- goto have_c2max;
- }
- }
-have_c2max:
-
- /* Update box volume.
- * We use 2-norm rather than real volume here; this biases the method
- * against making long narrow boxes, and it has the side benefit that
- * a box is splittable iff norm > 0.
- * Since the differences are expressed in histogram-cell units,
- * we have to shift back to JSAMPLE units to get consistent distances;
- * after which, we scale according to the selected distance scale factors.
- */
- dist0 = ((c0max - c0min) << C0_SHIFT) * C0_SCALE;
- dist1 = ((c1max - c1min) << C1_SHIFT) * C1_SCALE;
- dist2 = ((c2max - c2min) << C2_SHIFT) * C2_SCALE;
- boxp->volume = dist0 * dist0 + dist1 * dist1 + dist2 * dist2;
-
- /* Now scan remaining volume of box and compute population */
- ccount = 0;
- for (c0 = c0min; c0 <= c0max; c0++)
- for (c1 = c1min; c1 <= c1max; c1++) {
- histp = &histogram[c0][c1][c2min];
- for (c2 = c2min; c2 <= c2max; c2++, histp++)
- if (*histp != 0) {
- ccount++;
- }
- }
- boxp->colorcount = ccount;
-}
-
-
-LOCAL(int)
-median_cut(j_decompress_ptr cinfo, boxptr boxlist, int numboxes,
- int desired_colors)
-/* Repeatedly select and split the largest box until we have enough boxes */
-{
- int n, lb;
- int c0, c1, c2, cmax;
- register boxptr b1, b2;
-
- while (numboxes < desired_colors) {
- /* Select box to split.
- * Current algorithm: by population for first half, then by volume.
- */
- if (numboxes * 2 <= desired_colors) {
- b1 = find_biggest_color_pop(boxlist, numboxes);
- } else {
- b1 = find_biggest_volume(boxlist, numboxes);
- }
- if (b1 == NULL) /* no splittable boxes left! */
- break;
- b2 = &boxlist[numboxes]; /* where new box will go */
- /* Copy the color bounds to the new box. */
- b2->c0max = b1->c0max; b2->c1max = b1->c1max; b2->c2max = b1->c2max;
- b2->c0min = b1->c0min; b2->c1min = b1->c1min; b2->c2min = b1->c2min;
- /* Choose which axis to split the box on.
- * Current algorithm: longest scaled axis.
- * See notes in update_box about scaling distances.
- */
- c0 = ((b1->c0max - b1->c0min) << C0_SHIFT) * C0_SCALE;
- c1 = ((b1->c1max - b1->c1min) << C1_SHIFT) * C1_SCALE;
- c2 = ((b1->c2max - b1->c2min) << C2_SHIFT) * C2_SCALE;
- /* We want to break any ties in favor of green, then red, blue last.
- * This code does the right thing for R,G,B or B,G,R color orders only.
- */
- if (rgb_red[cinfo->out_color_space] == 0) {
- cmax = c1; n = 1;
- if (c0 > cmax) { cmax = c0; n = 0; }
- if (c2 > cmax) { n = 2; }
- } else {
- cmax = c1; n = 1;
- if (c2 > cmax) { cmax = c2; n = 2; }
- if (c0 > cmax) { n = 0; }
- }
- /* Choose split point along selected axis, and update box bounds.
- * Current algorithm: split at halfway point.
- * (Since the box has been shrunk to minimum volume,
- * any split will produce two nonempty subboxes.)
- * Note that lb value is max for lower box, so must be < old max.
- */
- switch (n) {
- case 0:
- lb = (b1->c0max + b1->c0min) / 2;
- b1->c0max = lb;
- b2->c0min = lb + 1;
- break;
- case 1:
- lb = (b1->c1max + b1->c1min) / 2;
- b1->c1max = lb;
- b2->c1min = lb + 1;
- break;
- case 2:
- lb = (b1->c2max + b1->c2min) / 2;
- b1->c2max = lb;
- b2->c2min = lb + 1;
- break;
- }
- /* Update stats for boxes */
- update_box(cinfo, b1);
- update_box(cinfo, b2);
- numboxes++;
- }
- return numboxes;
-}
-
-
-LOCAL(void)
-compute_color(j_decompress_ptr cinfo, boxptr boxp, int icolor)
-/* Compute representative color for a box, put it in colormap[icolor] */
-{
- /* Current algorithm: mean weighted by pixels (not colors) */
- /* Note it is important to get the rounding correct! */
- my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
- hist3d histogram = cquantize->histogram;
- histptr histp;
- int c0, c1, c2;
- int c0min, c0max, c1min, c1max, c2min, c2max;
- long count;
- long total = 0;
- long c0total = 0;
- long c1total = 0;
- long c2total = 0;
-
- c0min = boxp->c0min; c0max = boxp->c0max;
- c1min = boxp->c1min; c1max = boxp->c1max;
- c2min = boxp->c2min; c2max = boxp->c2max;
-
- for (c0 = c0min; c0 <= c0max; c0++)
- for (c1 = c1min; c1 <= c1max; c1++) {
- histp = &histogram[c0][c1][c2min];
- for (c2 = c2min; c2 <= c2max; c2++) {
- if ((count = *histp++) != 0) {
- total += count;
- c0total += ((c0 << C0_SHIFT) + ((1 << C0_SHIFT) >> 1)) * count;
- c1total += ((c1 << C1_SHIFT) + ((1 << C1_SHIFT) >> 1)) * count;
- c2total += ((c2 << C2_SHIFT) + ((1 << C2_SHIFT) >> 1)) * count;
- }
- }
- }
-
- cinfo->colormap[0][icolor] = (JSAMPLE)((c0total + (total >> 1)) / total);
- cinfo->colormap[1][icolor] = (JSAMPLE)((c1total + (total >> 1)) / total);
- cinfo->colormap[2][icolor] = (JSAMPLE)((c2total + (total >> 1)) / total);
-}
-
-
-LOCAL(void)
-select_colors(j_decompress_ptr cinfo, int desired_colors)
-/* Master routine for color selection */
-{
- boxptr boxlist;
- int numboxes;
- int i;
-
- /* Allocate workspace for box list */
- boxlist = (boxptr)(*cinfo->mem->alloc_small)
- ((j_common_ptr)cinfo, JPOOL_IMAGE, desired_colors * sizeof(box));
- /* Initialize one box containing whole space */
- numboxes = 1;
- boxlist[0].c0min = 0;
- boxlist[0].c0max = MAXJSAMPLE >> C0_SHIFT;
- boxlist[0].c1min = 0;
- boxlist[0].c1max = MAXJSAMPLE >> C1_SHIFT;
- boxlist[0].c2min = 0;
- boxlist[0].c2max = MAXJSAMPLE >> C2_SHIFT;
- /* Shrink it to actually-used volume and set its statistics */
- update_box(cinfo, &boxlist[0]);
- /* Perform median-cut to produce final box list */
- numboxes = median_cut(cinfo, boxlist, numboxes, desired_colors);
- /* Compute the representative color for each box, fill colormap */
- for (i = 0; i < numboxes; i++)
- compute_color(cinfo, &boxlist[i], i);
- cinfo->actual_number_of_colors = numboxes;
- TRACEMS1(cinfo, 1, JTRC_QUANT_SELECTED, numboxes);
-}
-
-
-/*
- * These routines are concerned with the time-critical task of mapping input
- * colors to the nearest color in the selected colormap.
- *
- * We re-use the histogram space as an "inverse color map", essentially a
- * cache for the results of nearest-color searches. All colors within a
- * histogram cell will be mapped to the same colormap entry, namely the one
- * closest to the cell's center. This may not be quite the closest entry to
- * the actual input color, but it's almost as good. A zero in the cache
- * indicates we haven't found the nearest color for that cell yet; the array
- * is cleared to zeroes before starting the mapping pass. When we find the
- * nearest color for a cell, its colormap index plus one is recorded in the
- * cache for future use. The pass2 scanning routines call fill_inverse_cmap
- * when they need to use an unfilled entry in the cache.
- *
- * Our method of efficiently finding nearest colors is based on the "locally
- * sorted search" idea described by Heckbert and on the incremental distance
- * calculation described by Spencer W. Thomas in chapter III.1 of Graphics
- * Gems II (James Arvo, ed. Academic Press, 1991). Thomas points out that
- * the distances from a given colormap entry to each cell of the histogram can
- * be computed quickly using an incremental method: the differences between
- * distances to adjacent cells themselves differ by a constant. This allows a
- * fairly fast implementation of the "brute force" approach of computing the
- * distance from every colormap entry to every histogram cell. Unfortunately,
- * it needs a work array to hold the best-distance-so-far for each histogram
- * cell (because the inner loop has to be over cells, not colormap entries).
- * The work array elements have to be JLONGs, so the work array would need
- * 256Kb at our recommended precision. This is not feasible in DOS machines.
- *
- * To get around these problems, we apply Thomas' method to compute the
- * nearest colors for only the cells within a small subbox of the histogram.
- * The work array need be only as big as the subbox, so the memory usage
- * problem is solved. Furthermore, we need not fill subboxes that are never
- * referenced in pass2; many images use only part of the color gamut, so a
- * fair amount of work is saved. An additional advantage of this
- * approach is that we can apply Heckbert's locality criterion to quickly
- * eliminate colormap entries that are far away from the subbox; typically
- * three-fourths of the colormap entries are rejected by Heckbert's criterion,
- * and we need not compute their distances to individual cells in the subbox.
- * The speed of this approach is heavily influenced by the subbox size: too
- * small means too much overhead, too big loses because Heckbert's criterion
- * can't eliminate as many colormap entries. Empirically the best subbox
- * size seems to be about 1/512th of the histogram (1/8th in each direction).
- *
- * Thomas' article also describes a refined method which is asymptotically
- * faster than the brute-force method, but it is also far more complex and
- * cannot efficiently be applied to small subboxes. It is therefore not
- * useful for programs intended to be portable to DOS machines. On machines
- * with plenty of memory, filling the whole histogram in one shot with Thomas'
- * refined method might be faster than the present code --- but then again,
- * it might not be any faster, and it's certainly more complicated.
- */
-
-
-/* log2(histogram cells in update box) for each axis; this can be adjusted */
-#define BOX_C0_LOG (HIST_C0_BITS - 3)
-#define BOX_C1_LOG (HIST_C1_BITS - 3)
-#define BOX_C2_LOG (HIST_C2_BITS - 3)
-
-#define BOX_C0_ELEMS (1 << BOX_C0_LOG) /* # of hist cells in update box */
-#define BOX_C1_ELEMS (1 << BOX_C1_LOG)
-#define BOX_C2_ELEMS (1 << BOX_C2_LOG)
-
-#define BOX_C0_SHIFT (C0_SHIFT + BOX_C0_LOG)
-#define BOX_C1_SHIFT (C1_SHIFT + BOX_C1_LOG)
-#define BOX_C2_SHIFT (C2_SHIFT + BOX_C2_LOG)
-
-
-/*
- * The next three routines implement inverse colormap filling. They could
- * all be folded into one big routine, but splitting them up this way saves
- * some stack space (the mindist[] and bestdist[] arrays need not coexist)
- * and may allow some compilers to produce better code by registerizing more
- * inner-loop variables.
- */
-
-LOCAL(int)
-find_nearby_colors(j_decompress_ptr cinfo, int minc0, int minc1, int minc2,
- JSAMPLE colorlist[])
-/* Locate the colormap entries close enough to an update box to be candidates
- * for the nearest entry to some cell(s) in the update box. The update box
- * is specified by the center coordinates of its first cell. The number of
- * candidate colormap entries is returned, and their colormap indexes are
- * placed in colorlist[].
- * This routine uses Heckbert's "locally sorted search" criterion to select
- * the colors that need further consideration.
- */
-{
- int numcolors = cinfo->actual_number_of_colors;
- int maxc0, maxc1, maxc2;
- int centerc0, centerc1, centerc2;
- int i, x, ncolors;
- JLONG minmaxdist, min_dist, max_dist, tdist;
- JLONG mindist[MAXNUMCOLORS]; /* min distance to colormap entry i */
-
- /* Compute true coordinates of update box's upper corner and center.
- * Actually we compute the coordinates of the center of the upper-corner
- * histogram cell, which are the upper bounds of the volume we care about.
- * Note that since ">>" rounds down, the "center" values may be closer to
- * min than to max; hence comparisons to them must be "<=", not "<".
- */
- maxc0 = minc0 + ((1 << BOX_C0_SHIFT) - (1 << C0_SHIFT));
- centerc0 = (minc0 + maxc0) >> 1;
- maxc1 = minc1 + ((1 << BOX_C1_SHIFT) - (1 << C1_SHIFT));
- centerc1 = (minc1 + maxc1) >> 1;
- maxc2 = minc2 + ((1 << BOX_C2_SHIFT) - (1 << C2_SHIFT));
- centerc2 = (minc2 + maxc2) >> 1;
-
- /* For each color in colormap, find:
- * 1. its minimum squared-distance to any point in the update box
- * (zero if color is within update box);
- * 2. its maximum squared-distance to any point in the update box.
- * Both of these can be found by considering only the corners of the box.
- * We save the minimum distance for each color in mindist[];
- * only the smallest maximum distance is of interest.
- */
- minmaxdist = 0x7FFFFFFFL;
-
- for (i = 0; i < numcolors; i++) {
- /* We compute the squared-c0-distance term, then add in the other two. */
- x = cinfo->colormap[0][i];
- if (x < minc0) {
- tdist = (x - minc0) * C0_SCALE;
- min_dist = tdist * tdist;
- tdist = (x - maxc0) * C0_SCALE;
- max_dist = tdist * tdist;
- } else if (x > maxc0) {
- tdist = (x - maxc0) * C0_SCALE;
- min_dist = tdist * tdist;
- tdist = (x - minc0) * C0_SCALE;
- max_dist = tdist * tdist;
- } else {
- /* within cell range so no contribution to min_dist */
- min_dist = 0;
- if (x <= centerc0) {
- tdist = (x - maxc0) * C0_SCALE;
- max_dist = tdist * tdist;
- } else {
- tdist = (x - minc0) * C0_SCALE;
- max_dist = tdist * tdist;
- }
- }
-
- x = cinfo->colormap[1][i];
- if (x < minc1) {
- tdist = (x - minc1) * C1_SCALE;
- min_dist += tdist * tdist;
- tdist = (x - maxc1) * C1_SCALE;
- max_dist += tdist * tdist;
- } else if (x > maxc1) {
- tdist = (x - maxc1) * C1_SCALE;
- min_dist += tdist * tdist;
- tdist = (x - minc1) * C1_SCALE;
- max_dist += tdist * tdist;
- } else {
- /* within cell range so no contribution to min_dist */
- if (x <= centerc1) {
- tdist = (x - maxc1) * C1_SCALE;
- max_dist += tdist * tdist;
- } else {
- tdist = (x - minc1) * C1_SCALE;
- max_dist += tdist * tdist;
- }
- }
-
- x = cinfo->colormap[2][i];
- if (x < minc2) {
- tdist = (x - minc2) * C2_SCALE;
- min_dist += tdist * tdist;
- tdist = (x - maxc2) * C2_SCALE;
- max_dist += tdist * tdist;
- } else if (x > maxc2) {
- tdist = (x - maxc2) * C2_SCALE;
- min_dist += tdist * tdist;
- tdist = (x - minc2) * C2_SCALE;
- max_dist += tdist * tdist;
- } else {
- /* within cell range so no contribution to min_dist */
- if (x <= centerc2) {
- tdist = (x - maxc2) * C2_SCALE;
- max_dist += tdist * tdist;
- } else {
- tdist = (x - minc2) * C2_SCALE;
- max_dist += tdist * tdist;
- }
- }
-
- mindist[i] = min_dist; /* save away the results */
- if (max_dist < minmaxdist)
- minmaxdist = max_dist;
- }
-
- /* Now we know that no cell in the update box is more than minmaxdist
- * away from some colormap entry. Therefore, only colors that are
- * within minmaxdist of some part of the box need be considered.
- */
- ncolors = 0;
- for (i = 0; i < numcolors; i++) {
- if (mindist[i] <= minmaxdist)
- colorlist[ncolors++] = (JSAMPLE)i;
- }
- return ncolors;
-}
-
-
-LOCAL(void)
-find_best_colors(j_decompress_ptr cinfo, int minc0, int minc1, int minc2,
- int numcolors, JSAMPLE colorlist[], JSAMPLE bestcolor[])
-/* Find the closest colormap entry for each cell in the update box,
- * given the list of candidate colors prepared by find_nearby_colors.
- * Return the indexes of the closest entries in the bestcolor[] array.
- * This routine uses Thomas' incremental distance calculation method to
- * find the distance from a colormap entry to successive cells in the box.
- */
-{
- int ic0, ic1, ic2;
- int i, icolor;
- register JLONG *bptr; /* pointer into bestdist[] array */
- JSAMPLE *cptr; /* pointer into bestcolor[] array */
- JLONG dist0, dist1; /* initial distance values */
- register JLONG dist2; /* current distance in inner loop */
- JLONG xx0, xx1; /* distance increments */
- register JLONG xx2;
- JLONG inc0, inc1, inc2; /* initial values for increments */
- /* This array holds the distance to the nearest-so-far color for each cell */
- JLONG bestdist[BOX_C0_ELEMS * BOX_C1_ELEMS * BOX_C2_ELEMS];
-
- /* Initialize best-distance for each cell of the update box */
- bptr = bestdist;
- for (i = BOX_C0_ELEMS * BOX_C1_ELEMS * BOX_C2_ELEMS - 1; i >= 0; i--)
- *bptr++ = 0x7FFFFFFFL;
-
- /* For each color selected by find_nearby_colors,
- * compute its distance to the center of each cell in the box.
- * If that's less than best-so-far, update best distance and color number.
- */
-
- /* Nominal steps between cell centers ("x" in Thomas article) */
-#define STEP_C0 ((1 << C0_SHIFT) * C0_SCALE)
-#define STEP_C1 ((1 << C1_SHIFT) * C1_SCALE)
-#define STEP_C2 ((1 << C2_SHIFT) * C2_SCALE)
-
- for (i = 0; i < numcolors; i++) {
- icolor = colorlist[i];
- /* Compute (square of) distance from minc0/c1/c2 to this color */
- inc0 = (minc0 - cinfo->colormap[0][icolor]) * C0_SCALE;
- dist0 = inc0 * inc0;
- inc1 = (minc1 - cinfo->colormap[1][icolor]) * C1_SCALE;
- dist0 += inc1 * inc1;
- inc2 = (minc2 - cinfo->colormap[2][icolor]) * C2_SCALE;
- dist0 += inc2 * inc2;
- /* Form the initial difference increments */
- inc0 = inc0 * (2 * STEP_C0) + STEP_C0 * STEP_C0;
- inc1 = inc1 * (2 * STEP_C1) + STEP_C1 * STEP_C1;
- inc2 = inc2 * (2 * STEP_C2) + STEP_C2 * STEP_C2;
- /* Now loop over all cells in box, updating distance per Thomas method */
- bptr = bestdist;
- cptr = bestcolor;
- xx0 = inc0;
- for (ic0 = BOX_C0_ELEMS - 1; ic0 >= 0; ic0--) {
- dist1 = dist0;
- xx1 = inc1;
- for (ic1 = BOX_C1_ELEMS - 1; ic1 >= 0; ic1--) {
- dist2 = dist1;
- xx2 = inc2;
- for (ic2 = BOX_C2_ELEMS - 1; ic2 >= 0; ic2--) {
- if (dist2 < *bptr) {
- *bptr = dist2;
- *cptr = (JSAMPLE)icolor;
- }
- dist2 += xx2;
- xx2 += 2 * STEP_C2 * STEP_C2;
- bptr++;
- cptr++;
- }
- dist1 += xx1;
- xx1 += 2 * STEP_C1 * STEP_C1;
- }
- dist0 += xx0;
- xx0 += 2 * STEP_C0 * STEP_C0;
- }
- }
-}
-
-
-LOCAL(void)
-fill_inverse_cmap(j_decompress_ptr cinfo, int c0, int c1, int c2)
-/* Fill the inverse-colormap entries in the update box that contains */
-/* histogram cell c0/c1/c2. (Only that one cell MUST be filled, but */
-/* we can fill as many others as we wish.) */
-{
- my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
- hist3d histogram = cquantize->histogram;
- int minc0, minc1, minc2; /* lower left corner of update box */
- int ic0, ic1, ic2;
- register JSAMPLE *cptr; /* pointer into bestcolor[] array */
- register histptr cachep; /* pointer into main cache array */
- /* This array lists the candidate colormap indexes. */
- JSAMPLE colorlist[MAXNUMCOLORS];
- int numcolors; /* number of candidate colors */
- /* This array holds the actually closest colormap index for each cell. */
- JSAMPLE bestcolor[BOX_C0_ELEMS * BOX_C1_ELEMS * BOX_C2_ELEMS];
-
- /* Convert cell coordinates to update box ID */
- c0 >>= BOX_C0_LOG;
- c1 >>= BOX_C1_LOG;
- c2 >>= BOX_C2_LOG;
-
- /* Compute true coordinates of update box's origin corner.
- * Actually we compute the coordinates of the center of the corner
- * histogram cell, which are the lower bounds of the volume we care about.
- */
- minc0 = (c0 << BOX_C0_SHIFT) + ((1 << C0_SHIFT) >> 1);
- minc1 = (c1 << BOX_C1_SHIFT) + ((1 << C1_SHIFT) >> 1);
- minc2 = (c2 << BOX_C2_SHIFT) + ((1 << C2_SHIFT) >> 1);
-
- /* Determine which colormap entries are close enough to be candidates
- * for the nearest entry to some cell in the update box.
- */
- numcolors = find_nearby_colors(cinfo, minc0, minc1, minc2, colorlist);
-
- /* Determine the actually nearest colors. */
- find_best_colors(cinfo, minc0, minc1, minc2, numcolors, colorlist,
- bestcolor);
-
- /* Save the best color numbers (plus 1) in the main cache array */
- c0 <<= BOX_C0_LOG; /* convert ID back to base cell indexes */
- c1 <<= BOX_C1_LOG;
- c2 <<= BOX_C2_LOG;
- cptr = bestcolor;
- for (ic0 = 0; ic0 < BOX_C0_ELEMS; ic0++) {
- for (ic1 = 0; ic1 < BOX_C1_ELEMS; ic1++) {
- cachep = &histogram[c0 + ic0][c1 + ic1][c2];
- for (ic2 = 0; ic2 < BOX_C2_ELEMS; ic2++) {
- *cachep++ = (histcell)((*cptr++) + 1);
- }
- }
- }
-}
-
-
-/*
- * Map some rows of pixels to the output colormapped representation.
- */
-
-METHODDEF(void)
-pass2_no_dither(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPARRAY output_buf, int num_rows)
-/* This version performs no dithering */
-{
- my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
- hist3d histogram = cquantize->histogram;
- register JSAMPROW inptr, outptr;
- register histptr cachep;
- register int c0, c1, c2;
- int row;
- JDIMENSION col;
- JDIMENSION width = cinfo->output_width;
-
- for (row = 0; row < num_rows; row++) {
- inptr = input_buf[row];
- outptr = output_buf[row];
- for (col = width; col > 0; col--) {
- /* get pixel value and index into the cache */
- c0 = (*inptr++) >> C0_SHIFT;
- c1 = (*inptr++) >> C1_SHIFT;
- c2 = (*inptr++) >> C2_SHIFT;
- cachep = &histogram[c0][c1][c2];
- /* If we have not seen this color before, find nearest colormap entry */
- /* and update the cache */
- if (*cachep == 0)
- fill_inverse_cmap(cinfo, c0, c1, c2);
- /* Now emit the colormap index for this cell */
- *outptr++ = (JSAMPLE)(*cachep - 1);
- }
- }
-}
-
-
-METHODDEF(void)
-pass2_fs_dither(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPARRAY output_buf, int num_rows)
-/* This version performs Floyd-Steinberg dithering */
-{
- my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
- hist3d histogram = cquantize->histogram;
- register LOCFSERROR cur0, cur1, cur2; /* current error or pixel value */
- LOCFSERROR belowerr0, belowerr1, belowerr2; /* error for pixel below cur */
- LOCFSERROR bpreverr0, bpreverr1, bpreverr2; /* error for below/prev col */
- register FSERRPTR errorptr; /* => fserrors[] at column before current */
- JSAMPROW inptr; /* => current input pixel */
- JSAMPROW outptr; /* => current output pixel */
- histptr cachep;
- int dir; /* +1 or -1 depending on direction */
- int dir3; /* 3*dir, for advancing inptr & errorptr */
- int row;
- JDIMENSION col;
- JDIMENSION width = cinfo->output_width;
- JSAMPLE *range_limit = cinfo->sample_range_limit;
- int *error_limit = cquantize->error_limiter;
- JSAMPROW colormap0 = cinfo->colormap[0];
- JSAMPROW colormap1 = cinfo->colormap[1];
- JSAMPROW colormap2 = cinfo->colormap[2];
- SHIFT_TEMPS
-
- for (row = 0; row < num_rows; row++) {
- inptr = input_buf[row];
- outptr = output_buf[row];
- if (cquantize->on_odd_row) {
- /* work right to left in this row */
- inptr += (width - 1) * 3; /* so point to rightmost pixel */
- outptr += width - 1;
- dir = -1;
- dir3 = -3;
- errorptr = cquantize->fserrors + (width + 1) * 3; /* => entry after last column */
- cquantize->on_odd_row = FALSE; /* flip for next time */
- } else {
- /* work left to right in this row */
- dir = 1;
- dir3 = 3;
- errorptr = cquantize->fserrors; /* => entry before first real column */
- cquantize->on_odd_row = TRUE; /* flip for next time */
- }
- /* Preset error values: no error propagated to first pixel from left */
- cur0 = cur1 = cur2 = 0;
- /* and no error propagated to row below yet */
- belowerr0 = belowerr1 = belowerr2 = 0;
- bpreverr0 = bpreverr1 = bpreverr2 = 0;
-
- for (col = width; col > 0; col--) {
- /* curN holds the error propagated from the previous pixel on the
- * current line. Add the error propagated from the previous line
- * to form the complete error correction term for this pixel, and
- * round the error term (which is expressed * 16) to an integer.
- * RIGHT_SHIFT rounds towards minus infinity, so adding 8 is correct
- * for either sign of the error value.
- * Note: errorptr points to *previous* column's array entry.
- */
- cur0 = RIGHT_SHIFT(cur0 + errorptr[dir3 + 0] + 8, 4);
- cur1 = RIGHT_SHIFT(cur1 + errorptr[dir3 + 1] + 8, 4);
- cur2 = RIGHT_SHIFT(cur2 + errorptr[dir3 + 2] + 8, 4);
- /* Limit the error using transfer function set by init_error_limit.
- * See comments with init_error_limit for rationale.
- */
- cur0 = error_limit[cur0];
- cur1 = error_limit[cur1];
- cur2 = error_limit[cur2];
- /* Form pixel value + error, and range-limit to 0..MAXJSAMPLE.
- * The maximum error is +- MAXJSAMPLE (or less with error limiting);
- * this sets the required size of the range_limit array.
- */
- cur0 += inptr[0];
- cur1 += inptr[1];
- cur2 += inptr[2];
- cur0 = range_limit[cur0];
- cur1 = range_limit[cur1];
- cur2 = range_limit[cur2];
- /* Index into the cache with adjusted pixel value */
- cachep =
- &histogram[cur0 >> C0_SHIFT][cur1 >> C1_SHIFT][cur2 >> C2_SHIFT];
- /* If we have not seen this color before, find nearest colormap */
- /* entry and update the cache */
- if (*cachep == 0)
- fill_inverse_cmap(cinfo, cur0 >> C0_SHIFT, cur1 >> C1_SHIFT,
- cur2 >> C2_SHIFT);
- /* Now emit the colormap index for this cell */
- {
- register int pixcode = *cachep - 1;
- *outptr = (JSAMPLE)pixcode;
- /* Compute representation error for this pixel */
- cur0 -= colormap0[pixcode];
- cur1 -= colormap1[pixcode];
- cur2 -= colormap2[pixcode];
- }
- /* Compute error fractions to be propagated to adjacent pixels.
- * Add these into the running sums, and simultaneously shift the
- * next-line error sums left by 1 column.
- */
- {
- register LOCFSERROR bnexterr;
-
- bnexterr = cur0; /* Process component 0 */
- errorptr[0] = (FSERROR)(bpreverr0 + cur0 * 3);
- bpreverr0 = belowerr0 + cur0 * 5;
- belowerr0 = bnexterr;
- cur0 *= 7;
- bnexterr = cur1; /* Process component 1 */
- errorptr[1] = (FSERROR)(bpreverr1 + cur1 * 3);
- bpreverr1 = belowerr1 + cur1 * 5;
- belowerr1 = bnexterr;
- cur1 *= 7;
- bnexterr = cur2; /* Process component 2 */
- errorptr[2] = (FSERROR)(bpreverr2 + cur2 * 3);
- bpreverr2 = belowerr2 + cur2 * 5;
- belowerr2 = bnexterr;
- cur2 *= 7;
- }
- /* At this point curN contains the 7/16 error value to be propagated
- * to the next pixel on the current line, and all the errors for the
- * next line have been shifted over. We are therefore ready to move on.
- */
- inptr += dir3; /* Advance pixel pointers to next column */
- outptr += dir;
- errorptr += dir3; /* advance errorptr to current column */
- }
- /* Post-loop cleanup: we must unload the final error values into the
- * final fserrors[] entry. Note we need not unload belowerrN because
- * it is for the dummy column before or after the actual array.
- */
- errorptr[0] = (FSERROR)bpreverr0; /* unload prev errs into array */
- errorptr[1] = (FSERROR)bpreverr1;
- errorptr[2] = (FSERROR)bpreverr2;
- }
-}
-
-
-/*
- * Initialize the error-limiting transfer function (lookup table).
- * The raw F-S error computation can potentially compute error values of up to
- * +- MAXJSAMPLE. But we want the maximum correction applied to a pixel to be
- * much less, otherwise obviously wrong pixels will be created. (Typical
- * effects include weird fringes at color-area boundaries, isolated bright
- * pixels in a dark area, etc.) The standard advice for avoiding this problem
- * is to ensure that the "corners" of the color cube are allocated as output
- * colors; then repeated errors in the same direction cannot cause cascading
- * error buildup. However, that only prevents the error from getting
- * completely out of hand; Aaron Giles reports that error limiting improves
- * the results even with corner colors allocated.
- * A simple clamping of the error values to about +- MAXJSAMPLE/8 works pretty
- * well, but the smoother transfer function used below is even better. Thanks
- * to Aaron Giles for this idea.
- */
-
-LOCAL(void)
-init_error_limit(j_decompress_ptr cinfo)
-/* Allocate and fill in the error_limiter table */
-{
- my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
- int *table;
- int in, out;
-
- table = (int *)(*cinfo->mem->alloc_small)
- ((j_common_ptr)cinfo, JPOOL_IMAGE, (MAXJSAMPLE * 2 + 1) * sizeof(int));
- table += MAXJSAMPLE; /* so can index -MAXJSAMPLE .. +MAXJSAMPLE */
- cquantize->error_limiter = table;
-
-#define STEPSIZE ((MAXJSAMPLE + 1) / 16)
- /* Map errors 1:1 up to +- MAXJSAMPLE/16 */
- out = 0;
- for (in = 0; in < STEPSIZE; in++, out++) {
- table[in] = out; table[-in] = -out;
- }
- /* Map errors 1:2 up to +- 3*MAXJSAMPLE/16 */
- for (; in < STEPSIZE * 3; in++, out += (in & 1) ? 0 : 1) {
- table[in] = out; table[-in] = -out;
- }
- /* Clamp the rest to final out value (which is (MAXJSAMPLE+1)/8) */
- for (; in <= MAXJSAMPLE; in++) {
- table[in] = out; table[-in] = -out;
- }
-#undef STEPSIZE
-}
-
-
-/*
- * Finish up at the end of each pass.
- */
-
-METHODDEF(void)
-finish_pass1(j_decompress_ptr cinfo)
-{
- my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
-
- /* Select the representative colors and fill in cinfo->colormap */
- cinfo->colormap = cquantize->sv_colormap;
- select_colors(cinfo, cquantize->desired);
- /* Force next pass to zero the color index table */
- cquantize->needs_zeroed = TRUE;
-}
-
-
-METHODDEF(void)
-finish_pass2(j_decompress_ptr cinfo)
-{
- /* no work */
-}
-
-
-/*
- * Initialize for each processing pass.
- */
-
-METHODDEF(void)
-start_pass_2_quant(j_decompress_ptr cinfo, boolean is_pre_scan)
-{
- my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
- hist3d histogram = cquantize->histogram;
- int i;
-
- /* Only F-S dithering or no dithering is supported. */
- /* If user asks for ordered dither, give them F-S. */
- if (cinfo->dither_mode != JDITHER_NONE)
- cinfo->dither_mode = JDITHER_FS;
-
- if (is_pre_scan) {
- /* Set up method pointers */
- cquantize->pub.color_quantize = prescan_quantize;
- cquantize->pub.finish_pass = finish_pass1;
- cquantize->needs_zeroed = TRUE; /* Always zero histogram */
- } else {
- /* Set up method pointers */
- if (cinfo->dither_mode == JDITHER_FS)
- cquantize->pub.color_quantize = pass2_fs_dither;
- else
- cquantize->pub.color_quantize = pass2_no_dither;
- cquantize->pub.finish_pass = finish_pass2;
-
- /* Make sure color count is acceptable */
- i = cinfo->actual_number_of_colors;
- if (i < 1)
- ERREXIT1(cinfo, JERR_QUANT_FEW_COLORS, 1);
- if (i > MAXNUMCOLORS)
- ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXNUMCOLORS);
-
- if (cinfo->dither_mode == JDITHER_FS) {
- size_t arraysize =
- (size_t)((cinfo->output_width + 2) * (3 * sizeof(FSERROR)));
- /* Allocate Floyd-Steinberg workspace if we didn't already. */
- if (cquantize->fserrors == NULL)
- cquantize->fserrors = (FSERRPTR)(*cinfo->mem->alloc_large)
- ((j_common_ptr)cinfo, JPOOL_IMAGE, arraysize);
- /* Initialize the propagated errors to zero. */
- jzero_far((void *)cquantize->fserrors, arraysize);
- /* Make the error-limit table if we didn't already. */
- if (cquantize->error_limiter == NULL)
- init_error_limit(cinfo);
- cquantize->on_odd_row = FALSE;
- }
-
- }
- /* Zero the histogram or inverse color map, if necessary */
- if (cquantize->needs_zeroed) {
- for (i = 0; i < HIST_C0_ELEMS; i++) {
- jzero_far((void *)histogram[i],
- HIST_C1_ELEMS * HIST_C2_ELEMS * sizeof(histcell));
- }
- cquantize->needs_zeroed = FALSE;
- }
-}
-
-
-/*
- * Switch to a new external colormap between output passes.
- */
-
-METHODDEF(void)
-new_color_map_2_quant(j_decompress_ptr cinfo)
-{
- my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
-
- /* Reset the inverse color map */
- cquantize->needs_zeroed = TRUE;
-}
-
-
-/*
- * Module initialization routine for 2-pass color quantization.
- */
-
-GLOBAL(void)
-jinit_2pass_quantizer(j_decompress_ptr cinfo)
-{
- my_cquantize_ptr cquantize;
- int i;
-
- cquantize = (my_cquantize_ptr)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- sizeof(my_cquantizer));
- cinfo->cquantize = (struct jpeg_color_quantizer *)cquantize;
- cquantize->pub.start_pass = start_pass_2_quant;
- cquantize->pub.new_color_map = new_color_map_2_quant;
- cquantize->fserrors = NULL; /* flag optional arrays not allocated */
- cquantize->error_limiter = NULL;
-
- /* Make sure jdmaster didn't give me a case I can't handle */
- if (cinfo->out_color_components != 3)
- ERREXIT(cinfo, JERR_NOTIMPL);
-
- /* Allocate the histogram/inverse colormap storage */
- cquantize->histogram = (hist3d)(*cinfo->mem->alloc_small)
- ((j_common_ptr)cinfo, JPOOL_IMAGE, HIST_C0_ELEMS * sizeof(hist2d));
- for (i = 0; i < HIST_C0_ELEMS; i++) {
- cquantize->histogram[i] = (hist2d)(*cinfo->mem->alloc_large)
- ((j_common_ptr)cinfo, JPOOL_IMAGE,
- HIST_C1_ELEMS * HIST_C2_ELEMS * sizeof(histcell));
- }
- cquantize->needs_zeroed = TRUE; /* histogram is garbage now */
-
- /* Allocate storage for the completed colormap, if required.
- * We do this now since it may affect the memory manager's space
- * calculations.
- */
- if (cinfo->enable_2pass_quant) {
- /* Make sure color count is acceptable */
- int desired = cinfo->desired_number_of_colors;
- /* Lower bound on # of colors ... somewhat arbitrary as long as > 0 */
- if (desired < 8)
- ERREXIT1(cinfo, JERR_QUANT_FEW_COLORS, 8);
- /* Make sure colormap indexes can be represented by JSAMPLEs */
- if (desired > MAXNUMCOLORS)
- ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXNUMCOLORS);
- cquantize->sv_colormap = (*cinfo->mem->alloc_sarray)
- ((j_common_ptr)cinfo, JPOOL_IMAGE, (JDIMENSION)desired, (JDIMENSION)3);
- cquantize->desired = desired;
- } else
- cquantize->sv_colormap = NULL;
-
- /* Only F-S dithering or no dithering is supported. */
- /* If user asks for ordered dither, give them F-S. */
- if (cinfo->dither_mode != JDITHER_NONE)
- cinfo->dither_mode = JDITHER_FS;
-
- /* Allocate Floyd-Steinberg workspace if necessary.
- * This isn't really needed until pass 2, but again it may affect the memory
- * manager's space calculations. Although we will cope with a later change
- * in dither_mode, we do not promise to honor max_memory_to_use if
- * dither_mode changes.
- */
- if (cinfo->dither_mode == JDITHER_FS) {
- cquantize->fserrors = (FSERRPTR)(*cinfo->mem->alloc_large)
- ((j_common_ptr)cinfo, JPOOL_IMAGE,
- (size_t)((cinfo->output_width + 2) * (3 * sizeof(FSERROR))));
- /* Might as well create the error-limiting table too. */
- init_error_limit(cinfo);
- }
-}
-
-#endif /* QUANT_2PASS_SUPPORTED */
diff --git a/contrib/libs/libjpeg-turbo/jsimd.h b/contrib/libs/libjpeg-turbo/jsimd.h
deleted file mode 100644
index 6c203655ef..0000000000
--- a/contrib/libs/libjpeg-turbo/jsimd.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * jsimd.h
- *
- * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- * Copyright (C) 2011, 2014, D. R. Commander.
- * Copyright (C) 2015-2016, 2018, Matthieu Darbois.
- * Copyright (C) 2020, Arm Limited.
- *
- * Based on the x86 SIMD extension for IJG JPEG library,
- * Copyright (C) 1999-2006, MIYASAKA Masaru.
- * For conditions of distribution and use, see copyright notice in jsimdext.inc
- *
- */
-
-#include "jchuff.h" /* Declarations shared with jcphuff.c */
-
-EXTERN(int) jsimd_can_rgb_ycc(void);
-EXTERN(int) jsimd_can_rgb_gray(void);
-EXTERN(int) jsimd_can_ycc_rgb(void);
-EXTERN(int) jsimd_can_ycc_rgb565(void);
-EXTERN(int) jsimd_c_can_null_convert(void);
-
-EXTERN(void) jsimd_rgb_ycc_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_rgb_gray_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_ycc_rgb_convert(j_decompress_ptr cinfo,
- JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_rgb565_convert(j_decompress_ptr cinfo,
- JSAMPIMAGE input_buf,
- JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_c_null_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPIMAGE output_buf, JDIMENSION output_row,
- int num_rows);
-
-EXTERN(int) jsimd_can_h2v2_downsample(void);
-EXTERN(int) jsimd_can_h2v1_downsample(void);
-
-EXTERN(void) jsimd_h2v2_downsample(j_compress_ptr cinfo,
- jpeg_component_info *compptr,
- JSAMPARRAY input_data,
- JSAMPARRAY output_data);
-
-EXTERN(int) jsimd_can_h2v2_smooth_downsample(void);
-
-EXTERN(void) jsimd_h2v2_smooth_downsample(j_compress_ptr cinfo,
- jpeg_component_info *compptr,
- JSAMPARRAY input_data,
- JSAMPARRAY output_data);
-
-EXTERN(void) jsimd_h2v1_downsample(j_compress_ptr cinfo,
- jpeg_component_info *compptr,
- JSAMPARRAY input_data,
- JSAMPARRAY output_data);
-
-EXTERN(int) jsimd_can_h2v2_upsample(void);
-EXTERN(int) jsimd_can_h2v1_upsample(void);
-EXTERN(int) jsimd_can_int_upsample(void);
-
-EXTERN(void) jsimd_h2v2_upsample(j_decompress_ptr cinfo,
- jpeg_component_info *compptr,
- JSAMPARRAY input_data,
- JSAMPARRAY *output_data_ptr);
-EXTERN(void) jsimd_h2v1_upsample(j_decompress_ptr cinfo,
- jpeg_component_info *compptr,
- JSAMPARRAY input_data,
- JSAMPARRAY *output_data_ptr);
-EXTERN(void) jsimd_int_upsample(j_decompress_ptr cinfo,
- jpeg_component_info *compptr,
- JSAMPARRAY input_data,
- JSAMPARRAY *output_data_ptr);
-
-EXTERN(int) jsimd_can_h2v2_fancy_upsample(void);
-EXTERN(int) jsimd_can_h2v1_fancy_upsample(void);
-EXTERN(int) jsimd_can_h1v2_fancy_upsample(void);
-
-EXTERN(void) jsimd_h2v2_fancy_upsample(j_decompress_ptr cinfo,
- jpeg_component_info *compptr,
- JSAMPARRAY input_data,
- JSAMPARRAY *output_data_ptr);
-EXTERN(void) jsimd_h2v1_fancy_upsample(j_decompress_ptr cinfo,
- jpeg_component_info *compptr,
- JSAMPARRAY input_data,
- JSAMPARRAY *output_data_ptr);
-EXTERN(void) jsimd_h1v2_fancy_upsample(j_decompress_ptr cinfo,
- jpeg_component_info *compptr,
- JSAMPARRAY input_data,
- JSAMPARRAY *output_data_ptr);
-
-EXTERN(int) jsimd_can_h2v2_merged_upsample(void);
-EXTERN(int) jsimd_can_h2v1_merged_upsample(void);
-
-EXTERN(void) jsimd_h2v2_merged_upsample(j_decompress_ptr cinfo,
- JSAMPIMAGE input_buf,
- JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v1_merged_upsample(j_decompress_ptr cinfo,
- JSAMPIMAGE input_buf,
- JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-
-EXTERN(int) jsimd_can_huff_encode_one_block(void);
-
-EXTERN(JOCTET *) jsimd_huff_encode_one_block(void *state, JOCTET *buffer,
- JCOEFPTR block, int last_dc_val,
- c_derived_tbl *dctbl,
- c_derived_tbl *actbl);
-
-EXTERN(int) jsimd_can_encode_mcu_AC_first_prepare(void);
-
-EXTERN(void) jsimd_encode_mcu_AC_first_prepare
- (const JCOEF *block, const int *jpeg_natural_order_start, int Sl, int Al,
- JCOEF *values, size_t *zerobits);
-
-EXTERN(int) jsimd_can_encode_mcu_AC_refine_prepare(void);
-
-EXTERN(int) jsimd_encode_mcu_AC_refine_prepare
- (const JCOEF *block, const int *jpeg_natural_order_start, int Sl, int Al,
- JCOEF *absvalues, size_t *bits);
diff --git a/contrib/libs/libjpeg-turbo/jsimd_none.c b/contrib/libs/libjpeg-turbo/jsimd_none.c
deleted file mode 100644
index 5b38a9fb5c..0000000000
--- a/contrib/libs/libjpeg-turbo/jsimd_none.c
+++ /dev/null
@@ -1,431 +0,0 @@
-/*
- * jsimd_none.c
- *
- * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- * Copyright (C) 2009-2011, 2014, D. R. Commander.
- * Copyright (C) 2015-2016, 2018, Matthieu Darbois.
- * Copyright (C) 2020, Arm Limited.
- *
- * Based on the x86 SIMD extension for IJG JPEG library,
- * Copyright (C) 1999-2006, MIYASAKA Masaru.
- * For conditions of distribution and use, see copyright notice in jsimdext.inc
- *
- * This file contains stubs for when there is no SIMD support available.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-#include "jsimd.h"
-#include "jdct.h"
-#include "jsimddct.h"
-
-GLOBAL(int)
-jsimd_can_rgb_ycc(void)
-{
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_rgb_gray(void)
-{
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_ycc_rgb(void)
-{
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_ycc_rgb565(void)
-{
- return 0;
-}
-
-GLOBAL(int)
-jsimd_c_can_null_convert(void)
-{
- return 0;
-}
-
-GLOBAL(void)
-jsimd_rgb_ycc_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPIMAGE output_buf, JDIMENSION output_row,
- int num_rows)
-{
-}
-
-GLOBAL(void)
-jsimd_rgb_gray_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPIMAGE output_buf, JDIMENSION output_row,
- int num_rows)
-{
-}
-
-GLOBAL(void)
-jsimd_ycc_rgb_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf,
- int num_rows)
-{
-}
-
-GLOBAL(void)
-jsimd_ycc_rgb565_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf,
- int num_rows)
-{
-}
-
-GLOBAL(void)
-jsimd_c_null_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPIMAGE output_buf, JDIMENSION output_row,
- int num_rows)
-{
-}
-
-GLOBAL(int)
-jsimd_can_h2v2_downsample(void)
-{
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_h2v1_downsample(void)
-{
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_h2v2_smooth_downsample(void)
-{
- return 0;
-}
-
-GLOBAL(void)
-jsimd_h2v2_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY output_data)
-{
-}
-
-GLOBAL(void)
-jsimd_h2v2_smooth_downsample(j_compress_ptr cinfo,
- jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY output_data)
-{
-}
-
-GLOBAL(void)
-jsimd_h2v1_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY output_data)
-{
-}
-
-GLOBAL(int)
-jsimd_can_h2v2_upsample(void)
-{
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_h2v1_upsample(void)
-{
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_int_upsample(void)
-{
- return 0;
-}
-
-GLOBAL(void)
-jsimd_int_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
-{
-}
-
-GLOBAL(void)
-jsimd_h2v2_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
-{
-}
-
-GLOBAL(void)
-jsimd_h2v1_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
-{
-}
-
-GLOBAL(int)
-jsimd_can_h2v2_fancy_upsample(void)
-{
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_h2v1_fancy_upsample(void)
-{
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_h1v2_fancy_upsample(void)
-{
- return 0;
-}
-
-GLOBAL(void)
-jsimd_h2v2_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
-{
-}
-
-GLOBAL(void)
-jsimd_h2v1_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
-{
-}
-
-GLOBAL(void)
-jsimd_h1v2_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
-{
-}
-
-GLOBAL(int)
-jsimd_can_h2v2_merged_upsample(void)
-{
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_h2v1_merged_upsample(void)
-{
- return 0;
-}
-
-GLOBAL(void)
-jsimd_h2v2_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
-{
-}
-
-GLOBAL(void)
-jsimd_h2v1_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
-{
-}
-
-GLOBAL(int)
-jsimd_can_convsamp(void)
-{
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_convsamp_float(void)
-{
- return 0;
-}
-
-GLOBAL(void)
-jsimd_convsamp(JSAMPARRAY sample_data, JDIMENSION start_col,
- DCTELEM *workspace)
-{
-}
-
-GLOBAL(void)
-jsimd_convsamp_float(JSAMPARRAY sample_data, JDIMENSION start_col,
- FAST_FLOAT *workspace)
-{
-}
-
-GLOBAL(int)
-jsimd_can_fdct_islow(void)
-{
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_fdct_ifast(void)
-{
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_fdct_float(void)
-{
- return 0;
-}
-
-GLOBAL(void)
-jsimd_fdct_islow(DCTELEM *data)
-{
-}
-
-GLOBAL(void)
-jsimd_fdct_ifast(DCTELEM *data)
-{
-}
-
-GLOBAL(void)
-jsimd_fdct_float(FAST_FLOAT *data)
-{
-}
-
-GLOBAL(int)
-jsimd_can_quantize(void)
-{
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_quantize_float(void)
-{
- return 0;
-}
-
-GLOBAL(void)
-jsimd_quantize(JCOEFPTR coef_block, DCTELEM *divisors, DCTELEM *workspace)
-{
-}
-
-GLOBAL(void)
-jsimd_quantize_float(JCOEFPTR coef_block, FAST_FLOAT *divisors,
- FAST_FLOAT *workspace)
-{
-}
-
-GLOBAL(int)
-jsimd_can_idct_2x2(void)
-{
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_idct_4x4(void)
-{
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_idct_6x6(void)
-{
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_idct_12x12(void)
-{
- return 0;
-}
-
-GLOBAL(void)
-jsimd_idct_2x2(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
-}
-
-GLOBAL(void)
-jsimd_idct_4x4(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
-}
-
-GLOBAL(void)
-jsimd_idct_6x6(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
-}
-
-GLOBAL(void)
-jsimd_idct_12x12(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
-}
-
-GLOBAL(int)
-jsimd_can_idct_islow(void)
-{
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_idct_ifast(void)
-{
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_idct_float(void)
-{
- return 0;
-}
-
-GLOBAL(void)
-jsimd_idct_islow(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
-}
-
-GLOBAL(void)
-jsimd_idct_ifast(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
-}
-
-GLOBAL(void)
-jsimd_idct_float(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
-}
-
-GLOBAL(int)
-jsimd_can_huff_encode_one_block(void)
-{
- return 0;
-}
-
-GLOBAL(JOCTET *)
-jsimd_huff_encode_one_block(void *state, JOCTET *buffer, JCOEFPTR block,
- int last_dc_val, c_derived_tbl *dctbl,
- c_derived_tbl *actbl)
-{
- return NULL;
-}
-
-GLOBAL(int)
-jsimd_can_encode_mcu_AC_first_prepare(void)
-{
- return 0;
-}
-
-GLOBAL(void)
-jsimd_encode_mcu_AC_first_prepare(const JCOEF *block,
- const int *jpeg_natural_order_start, int Sl,
- int Al, JCOEF *values, size_t *zerobits)
-{
-}
-
-GLOBAL(int)
-jsimd_can_encode_mcu_AC_refine_prepare(void)
-{
- return 0;
-}
-
-GLOBAL(int)
-jsimd_encode_mcu_AC_refine_prepare(const JCOEF *block,
- const int *jpeg_natural_order_start, int Sl,
- int Al, JCOEF *absvalues, size_t *bits)
-{
- return 0;
-}
diff --git a/contrib/libs/libjpeg-turbo/jsimddct.h b/contrib/libs/libjpeg-turbo/jsimddct.h
deleted file mode 100644
index 55ee8cf67f..0000000000
--- a/contrib/libs/libjpeg-turbo/jsimddct.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * jsimddct.h
- *
- * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- *
- * Based on the x86 SIMD extension for IJG JPEG library,
- * Copyright (C) 1999-2006, MIYASAKA Masaru.
- * For conditions of distribution and use, see copyright notice in jsimdext.inc
- *
- */
-
-EXTERN(int) jsimd_can_convsamp(void);
-EXTERN(int) jsimd_can_convsamp_float(void);
-
-EXTERN(void) jsimd_convsamp(JSAMPARRAY sample_data, JDIMENSION start_col,
- DCTELEM *workspace);
-EXTERN(void) jsimd_convsamp_float(JSAMPARRAY sample_data, JDIMENSION start_col,
- FAST_FLOAT *workspace);
-
-EXTERN(int) jsimd_can_fdct_islow(void);
-EXTERN(int) jsimd_can_fdct_ifast(void);
-EXTERN(int) jsimd_can_fdct_float(void);
-
-EXTERN(void) jsimd_fdct_islow(DCTELEM *data);
-EXTERN(void) jsimd_fdct_ifast(DCTELEM *data);
-EXTERN(void) jsimd_fdct_float(FAST_FLOAT *data);
-
-EXTERN(int) jsimd_can_quantize(void);
-EXTERN(int) jsimd_can_quantize_float(void);
-
-EXTERN(void) jsimd_quantize(JCOEFPTR coef_block, DCTELEM *divisors,
- DCTELEM *workspace);
-EXTERN(void) jsimd_quantize_float(JCOEFPTR coef_block, FAST_FLOAT *divisors,
- FAST_FLOAT *workspace);
-
-EXTERN(int) jsimd_can_idct_2x2(void);
-EXTERN(int) jsimd_can_idct_4x4(void);
-EXTERN(int) jsimd_can_idct_6x6(void);
-EXTERN(int) jsimd_can_idct_12x12(void);
-
-EXTERN(void) jsimd_idct_2x2(j_decompress_ptr cinfo,
- jpeg_component_info *compptr, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col);
-EXTERN(void) jsimd_idct_4x4(j_decompress_ptr cinfo,
- jpeg_component_info *compptr, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col);
-EXTERN(void) jsimd_idct_6x6(j_decompress_ptr cinfo,
- jpeg_component_info *compptr, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col);
-EXTERN(void) jsimd_idct_12x12(j_decompress_ptr cinfo,
- jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col);
-
-EXTERN(int) jsimd_can_idct_islow(void);
-EXTERN(int) jsimd_can_idct_ifast(void);
-EXTERN(int) jsimd_can_idct_float(void);
-
-EXTERN(void) jsimd_idct_islow(j_decompress_ptr cinfo,
- jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col);
-EXTERN(void) jsimd_idct_ifast(j_decompress_ptr cinfo,
- jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col);
-EXTERN(void) jsimd_idct_float(j_decompress_ptr cinfo,
- jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col);
diff --git a/contrib/libs/libjpeg-turbo/jstdhuff.c b/contrib/libs/libjpeg-turbo/jstdhuff.c
deleted file mode 100644
index 345b513d4d..0000000000
--- a/contrib/libs/libjpeg-turbo/jstdhuff.c
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * jstdhuff.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1998, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2013, 2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains routines to set the default Huffman tables, if they are
- * not already set.
- */
-
-/*
- * Huffman table setup routines
- */
-
-LOCAL(void)
-add_huff_table(j_common_ptr cinfo, JHUFF_TBL **htblptr, const UINT8 *bits,
- const UINT8 *val)
-/* Define a Huffman table */
-{
- int nsymbols, len;
-
- if (*htblptr == NULL)
- *htblptr = jpeg_alloc_huff_table(cinfo);
- else
- return;
-
- /* Copy the number-of-symbols-of-each-code-length counts */
- memcpy((*htblptr)->bits, bits, sizeof((*htblptr)->bits));
-
- /* Validate the counts. We do this here mainly so we can copy the right
- * number of symbols from the val[] array, without risking marching off
- * the end of memory. jchuff.c will do a more thorough test later.
- */
- nsymbols = 0;
- for (len = 1; len <= 16; len++)
- nsymbols += bits[len];
- if (nsymbols < 1 || nsymbols > 256)
- ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
-
- memcpy((*htblptr)->huffval, val, nsymbols * sizeof(UINT8));
- memset(&((*htblptr)->huffval[nsymbols]), 0,
- (256 - nsymbols) * sizeof(UINT8));
-
- /* Initialize sent_table FALSE so table will be written to JPEG file. */
- (*htblptr)->sent_table = FALSE;
-}
-
-
-LOCAL(void)
-std_huff_tables(j_common_ptr cinfo)
-/* Set up the standard Huffman tables (cf. JPEG standard section K.3) */
-/* IMPORTANT: these are only valid for 8-bit data precision! */
-{
- JHUFF_TBL **dc_huff_tbl_ptrs, **ac_huff_tbl_ptrs;
-
- static const UINT8 bits_dc_luminance[17] = {
- /* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0
- };
- static const UINT8 val_dc_luminance[] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
- };
-
- static const UINT8 bits_dc_chrominance[17] = {
- /* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0
- };
- static const UINT8 val_dc_chrominance[] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
- };
-
- static const UINT8 bits_ac_luminance[17] = {
- /* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d
- };
- static const UINT8 val_ac_luminance[] = {
- 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12,
- 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07,
- 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08,
- 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0,
- 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16,
- 0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28,
- 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
- 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,
- 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59,
- 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
- 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79,
- 0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
- 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98,
- 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
- 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6,
- 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5,
- 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4,
- 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2,
- 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea,
- 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
- 0xf9, 0xfa
- };
-
- static const UINT8 bits_ac_chrominance[17] = {
- /* 0-base */ 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77
- };
- static const UINT8 val_ac_chrominance[] = {
- 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21,
- 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71,
- 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91,
- 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0,
- 0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34,
- 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26,
- 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38,
- 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
- 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
- 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
- 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
- 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
- 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96,
- 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5,
- 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4,
- 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3,
- 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2,
- 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda,
- 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9,
- 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
- 0xf9, 0xfa
- };
-
- if (cinfo->is_decompressor) {
- dc_huff_tbl_ptrs = ((j_decompress_ptr)cinfo)->dc_huff_tbl_ptrs;
- ac_huff_tbl_ptrs = ((j_decompress_ptr)cinfo)->ac_huff_tbl_ptrs;
- } else {
- dc_huff_tbl_ptrs = ((j_compress_ptr)cinfo)->dc_huff_tbl_ptrs;
- ac_huff_tbl_ptrs = ((j_compress_ptr)cinfo)->ac_huff_tbl_ptrs;
- }
-
- add_huff_table(cinfo, &dc_huff_tbl_ptrs[0], bits_dc_luminance,
- val_dc_luminance);
- add_huff_table(cinfo, &ac_huff_tbl_ptrs[0], bits_ac_luminance,
- val_ac_luminance);
- add_huff_table(cinfo, &dc_huff_tbl_ptrs[1], bits_dc_chrominance,
- val_dc_chrominance);
- add_huff_table(cinfo, &ac_huff_tbl_ptrs[1], bits_ac_chrominance,
- val_ac_chrominance);
-}
diff --git a/contrib/libs/libjpeg-turbo/jutils.c b/contrib/libs/libjpeg-turbo/jutils.c
deleted file mode 100644
index d86271624a..0000000000
--- a/contrib/libs/libjpeg-turbo/jutils.c
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * jutils.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1996, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains tables and miscellaneous utility routines needed
- * for both compression and decompression.
- * Note we prefix all global names with "j" to minimize conflicts with
- * a surrounding application.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-
-
-/*
- * jpeg_zigzag_order[i] is the zigzag-order position of the i'th element
- * of a DCT block read in natural order (left to right, top to bottom).
- */
-
-#if 0 /* This table is not actually needed in v6a */
-
-const int jpeg_zigzag_order[DCTSIZE2] = {
- 0, 1, 5, 6, 14, 15, 27, 28,
- 2, 4, 7, 13, 16, 26, 29, 42,
- 3, 8, 12, 17, 25, 30, 41, 43,
- 9, 11, 18, 24, 31, 40, 44, 53,
- 10, 19, 23, 32, 39, 45, 52, 54,
- 20, 22, 33, 38, 46, 51, 55, 60,
- 21, 34, 37, 47, 50, 56, 59, 61,
- 35, 36, 48, 49, 57, 58, 62, 63
-};
-
-#endif
-
-/*
- * jpeg_natural_order[i] is the natural-order position of the i'th element
- * of zigzag order.
- *
- * When reading corrupted data, the Huffman decoders could attempt
- * to reference an entry beyond the end of this array (if the decoded
- * zero run length reaches past the end of the block). To prevent
- * wild stores without adding an inner-loop test, we put some extra
- * "63"s after the real entries. This will cause the extra coefficient
- * to be stored in location 63 of the block, not somewhere random.
- * The worst case would be a run-length of 15, which means we need 16
- * fake entries.
- */
-
-const int jpeg_natural_order[DCTSIZE2 + 16] = {
- 0, 1, 8, 16, 9, 2, 3, 10,
- 17, 24, 32, 25, 18, 11, 4, 5,
- 12, 19, 26, 33, 40, 48, 41, 34,
- 27, 20, 13, 6, 7, 14, 21, 28,
- 35, 42, 49, 56, 57, 50, 43, 36,
- 29, 22, 15, 23, 30, 37, 44, 51,
- 58, 59, 52, 45, 38, 31, 39, 46,
- 53, 60, 61, 54, 47, 55, 62, 63,
- 63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */
- 63, 63, 63, 63, 63, 63, 63, 63
-};
-
-
-/*
- * Arithmetic utilities
- */
-
-GLOBAL(long)
-jdiv_round_up(long a, long b)
-/* Compute a/b rounded up to next integer, ie, ceil(a/b) */
-/* Assumes a >= 0, b > 0 */
-{
- return (a + b - 1L) / b;
-}
-
-
-GLOBAL(long)
-jround_up(long a, long b)
-/* Compute a rounded up to next multiple of b, ie, ceil(a/b)*b */
-/* Assumes a >= 0, b > 0 */
-{
- a += b - 1L;
- return a - (a % b);
-}
-
-
-GLOBAL(void)
-jcopy_sample_rows(JSAMPARRAY input_array, int source_row,
- JSAMPARRAY output_array, int dest_row, int num_rows,
- JDIMENSION num_cols)
-/* Copy some rows of samples from one place to another.
- * num_rows rows are copied from input_array[source_row++]
- * to output_array[dest_row++]; these areas may overlap for duplication.
- * The source and destination arrays must be at least as wide as num_cols.
- */
-{
- register JSAMPROW inptr, outptr;
- register size_t count = (size_t)(num_cols * sizeof(JSAMPLE));
- register int row;
-
- input_array += source_row;
- output_array += dest_row;
-
- for (row = num_rows; row > 0; row--) {
- inptr = *input_array++;
- outptr = *output_array++;
- memcpy(outptr, inptr, count);
- }
-}
-
-
-GLOBAL(void)
-jcopy_block_row(JBLOCKROW input_row, JBLOCKROW output_row,
- JDIMENSION num_blocks)
-/* Copy a row of coefficient blocks from one place to another. */
-{
- memcpy(output_row, input_row, num_blocks * (DCTSIZE2 * sizeof(JCOEF)));
-}
-
-
-GLOBAL(void)
-jzero_far(void *target, size_t bytestozero)
-/* Zero out a chunk of memory. */
-/* This might be sample-array data, block-array data, or alloc_large data. */
-{
- memset(target, 0, bytestozero);
-}
diff --git a/contrib/libs/libjpeg-turbo/jversion.h b/contrib/libs/libjpeg-turbo/jversion.h
deleted file mode 100644
index 63db95b99b..0000000000
--- a/contrib/libs/libjpeg-turbo/jversion.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * jversion.h
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-2020, Thomas G. Lane, Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2012-2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains software version identification.
- */
-
-
-#if JPEG_LIB_VERSION >= 80
-
-#define JVERSION "8d 15-Jan-2012"
-
-#elif JPEG_LIB_VERSION >= 70
-
-#define JVERSION "7 27-Jun-2009"
-
-#else
-
-#define JVERSION "6b 27-Mar-1998"
-
-#endif
-
-/*
- * NOTE: It is our convention to place the authors in the following order:
- * - libjpeg-turbo authors (2009-) in descending order of the date of their
- * most recent contribution to the project, then in ascending order of the
- * date of their first contribution to the project, then in alphabetical
- * order
- * - Upstream authors in descending order of the date of the first inclusion of
- * their code
- */
-
-#define JCOPYRIGHT \
- "Copyright (C) 2009-2022 D. R. Commander\n" \
- "Copyright (C) 2015, 2020 Google, Inc.\n" \
- "Copyright (C) 2019-2020 Arm Limited\n" \
- "Copyright (C) 2015-2016, 2018 Matthieu Darbois\n" \
- "Copyright (C) 2011-2016 Siarhei Siamashka\n" \
- "Copyright (C) 2015 Intel Corporation\n" \
- "Copyright (C) 2013-2014 Linaro Limited\n" \
- "Copyright (C) 2013-2014 MIPS Technologies, Inc.\n" \
- "Copyright (C) 2009, 2012 Pierre Ossman for Cendio AB\n" \
- "Copyright (C) 2009-2011 Nokia Corporation and/or its subsidiary(-ies)\n" \
- "Copyright (C) 1999-2006 MIYASAKA Masaru\n" \
- "Copyright (C) 1991-2020 Thomas G. Lane, Guido Vollbeding"
-
-#define JCOPYRIGHT_SHORT \
- "Copyright (C) 1991-2022 The libjpeg-turbo Project and many others"
diff --git a/contrib/libs/libjpeg-turbo/libjpeg.map b/contrib/libs/libjpeg-turbo/libjpeg.map
deleted file mode 100644
index 78cbd6d8f0..0000000000
--- a/contrib/libs/libjpeg-turbo/libjpeg.map
+++ /dev/null
@@ -1,11 +0,0 @@
-LIBJPEGTURBO_6.2 {
- global: jpeg_mem_dest; jpeg_mem_src;
- local:
- jsimd_*;
- jconst_*;
-};
-
-LIBJPEG_6.2 {
- global:
- *;
-};
diff --git a/contrib/libs/libjpeg-turbo/md5/md5.c b/contrib/libs/libjpeg-turbo/md5/md5.c
deleted file mode 100644
index 9ef5daafb4..0000000000
--- a/contrib/libs/libjpeg-turbo/md5/md5.c
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
- * This code implements the MD5 message-digest algorithm.
- * The algorithm is due to Ron Rivest. This code was
- * written by Colin Plumb in 1993, no copyright is claimed.
- * This code is in the public domain; do with it what you wish.
- *
- * Equivalent code is available from RSA Data Security, Inc.
- * This code has been tested against that, and is equivalent,
- * except that you don't need to include two pages of legalese
- * with every copy.
- *
- * To compute the message digest of a chunk of bytes, declare an
- * MD5Context structure, pass it to MD5Init, call MD5Update as
- * needed on buffers full of bytes, and then call MD5Final, which
- * will fill a supplied 16-byte array with the digest.
- * ----------------------------------------------------------------------------
- * libjpeg-turbo Modifications:
- * Copyright (C)2018, D. R. Commander. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * - Neither the name of the libjpeg-turbo Project nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS",
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- * ----------------------------------------------------------------------------
- */
-
-#include <string.h> /* for memcpy() */
-#include "md5.h"
-
-#if (BYTE_ORDER == LITTLE_ENDIAN)
-#define byteReverse(buf, len) /* Nothing */
-#else
-/*
- * Note: this code is harmless on little-endian machines.
- */
-static void byteReverse(unsigned char *buf, unsigned int longs)
-{
- uint32 t;
- do {
- t = (uint32)((unsigned int)buf[3] << 8 | buf[2]) << 16 |
- ((unsigned int)buf[1] << 8 | buf[0]);
- *(uint32 *)buf = t;
- buf += 4;
- } while (--longs);
-}
-#endif
-
-/*
- * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
- * initialization constants.
- */
-void MD5Init(struct MD5Context *ctx)
-{
- ctx->buf[0] = 0x67452301;
- ctx->buf[1] = 0xefcdab89;
- ctx->buf[2] = 0x98badcfe;
- ctx->buf[3] = 0x10325476;
-
- ctx->bits[0] = 0;
- ctx->bits[1] = 0;
-}
-
-/*
- * Update context to reflect the concatenation of another buffer full
- * of bytes.
- */
-void MD5Update(struct MD5Context *ctx, unsigned char *buf, unsigned int len)
-{
- uint32 t;
-
- /* Update bitcount */
-
- t = ctx->bits[0];
- if ((ctx->bits[0] = t + ((uint32)len << 3)) < t)
- ctx->bits[1]++; /* Carry from low to high */
- ctx->bits[1] += len >> 29;
-
- t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
-
- /* Handle any leading odd-sized chunks */
-
- if (t) {
- unsigned char *p = (unsigned char *)ctx->in + t;
-
- t = 64 - t;
- if (len < t) {
- memcpy(p, buf, len);
- return;
- }
- memcpy(p, buf, t);
- byteReverse(ctx->in, 16);
- MD5Transform(ctx->buf, (uint32 *)ctx->in);
- buf += t;
- len -= t;
- }
- /* Process data in 64-byte chunks */
-
- while (len >= 64) {
- memcpy(ctx->in, buf, 64);
- byteReverse(ctx->in, 16);
- MD5Transform(ctx->buf, (uint32 *)ctx->in);
- buf += 64;
- len -= 64;
- }
-
- /* Handle any remaining bytes of data. */
-
- memcpy(ctx->in, buf, len);
-}
-
-/*
- * Final wrapup - pad to 64-byte boundary with the bit pattern
- * 1 0* (64-bit count of bits processed, MSB-first)
- */
-void MD5Final(unsigned char digest[16], struct MD5Context *ctx)
-{
- unsigned int count;
- unsigned char *p;
- uint32 *in32 = (uint32 *)ctx->in;
-
- /* Compute number of bytes mod 64 */
- count = (ctx->bits[0] >> 3) & 0x3F;
-
- /* Set the first char of padding to 0x80. This is safe since there is
- always at least one byte free */
- p = ctx->in + count;
- *p++ = 0x80;
-
- /* Bytes of padding needed to make 64 bytes */
- count = 64 - 1 - count;
-
- /* Pad out to 56 mod 64 */
- if (count < 8) {
- /* Two lots of padding: Pad the first block to 64 bytes */
- memset(p, 0, count);
- byteReverse(ctx->in, 16);
- MD5Transform(ctx->buf, (uint32 *)ctx->in);
-
- /* Now fill the next block with 56 bytes */
- memset(ctx->in, 0, 56);
- } else {
- /* Pad block to 56 bytes */
- memset(p, 0, count - 8);
- }
- byteReverse(ctx->in, 14);
-
- /* Append length in bits and transform */
- in32[14] = ctx->bits[0];
- in32[15] = ctx->bits[1];
-
- MD5Transform(ctx->buf, (uint32 *)ctx->in);
- byteReverse((unsigned char *)ctx->buf, 4);
- memcpy(digest, ctx->buf, 16);
- memset(ctx, 0, sizeof(struct MD5Context)); /* In case it's sensitive */
-}
-
-
-/* The four core functions - F1 is optimized somewhat */
-
-/* #define F1(x, y, z) (x & y | ~x & z) */
-#define F1(x, y, z) (z ^ (x & (y ^ z)))
-#define F2(x, y, z) F1(z, x, y)
-#define F3(x, y, z) (x ^ y ^ z)
-#define F4(x, y, z) (y ^ (x | ~z))
-
-/* This is the central step in the MD5 algorithm. */
-#define MD5STEP(f, w, x, y, z, data, s) \
- ( w += f(x, y, z) + data, w = w << s | w >> (32 - s), w += x )
-
-/*
- * The core of the MD5 algorithm, this alters an existing MD5 hash to
- * reflect the addition of 16 longwords of new data. MD5Update blocks
- * the data and converts bytes into longwords for this routine.
- */
-void MD5Transform(uint32 buf[4], uint32 in[16])
-{
- register uint32 a, b, c, d;
-
- a = buf[0];
- b = buf[1];
- c = buf[2];
- d = buf[3];
-
- MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
- MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
- MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
- MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
- MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
- MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
- MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
- MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
- MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
- MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
- MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
- MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
- MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
- MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
- MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
- MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
-
- MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
- MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
- MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
- MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
- MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
- MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
- MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
- MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
- MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
- MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
- MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
- MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
- MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
- MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
- MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
- MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
-
- MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
- MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
- MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
- MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
- MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
- MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
- MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
- MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
- MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
- MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
- MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
- MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
- MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
- MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
- MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
- MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
-
- MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
- MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
- MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
- MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
- MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
- MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
- MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
- MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
- MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
- MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
- MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
- MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
- MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
- MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
- MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
- MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
-
- buf[0] += a;
- buf[1] += b;
- buf[2] += c;
- buf[3] += d;
-}
diff --git a/contrib/libs/libjpeg-turbo/md5/md5.h b/contrib/libs/libjpeg-turbo/md5/md5.h
deleted file mode 100644
index 6d745e9c4d..0000000000
--- a/contrib/libs/libjpeg-turbo/md5/md5.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * libjpeg-turbo Modifications:
- * Copyright (C)2018 D. R. Commander. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * - Neither the name of the libjpeg-turbo Project nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS",
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef MD5_H
-#define MD5_H
-
-#include <sys/types.h>
-#ifdef __amigaos4__
-#include <machine/endian.h>
-#endif
-
-/* On machines where "long" is 64 bits, we need to declare
- uint32 as something guaranteed to be 32 bits. */
-
-typedef unsigned int uint32;
-
-typedef struct MD5Context {
- uint32 buf[4];
- uint32 bits[2];
- unsigned char in[64];
-} MD5_CTX;
-
-extern void MD5Init(struct MD5Context *ctx);
-extern void MD5Update(struct MD5Context *ctx, unsigned char *buf,
- unsigned int len);
-extern void MD5Final(unsigned char digest[16], struct MD5Context *ctx);
-extern void MD5Transform(uint32 buf[4], uint32 in[16]);
-extern char *MD5File(const char *, char *);
-extern char *MD5FileChunk(const char *, char *, off_t, off_t);
-
-#endif /* !MD5_H */
diff --git a/contrib/libs/libjpeg-turbo/md5/md5hl.c b/contrib/libs/libjpeg-turbo/md5/md5hl.c
deleted file mode 100644
index 849a136677..0000000000
--- a/contrib/libs/libjpeg-turbo/md5/md5hl.c
+++ /dev/null
@@ -1,129 +0,0 @@
-/* mdXhl.c
- * ----------------------------------------------------------------------------
- * "THE BEER-WARE LICENSE" (Revision 42):
- * <phk@FreeBSD.org> wrote this file. As long as you retain this notice you
- * can do whatever you want with this stuff. If we meet some day, and you think
- * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
- * ----------------------------------------------------------------------------
- * libjpeg-turbo Modifications:
- * Copyright (C)2016, 2018-2019, 2022 D. R. Commander. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * - Neither the name of the libjpeg-turbo Project nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS",
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- * ----------------------------------------------------------------------------
- */
-
-#ifdef _MSC_VER
-#define _CRT_SECURE_NO_DEPRECATE
-#endif
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#ifdef _WIN32
-#include <io.h>
-#define close _close
-#define fstat _fstat
-#define lseek _lseek
-#define read _read
-#define stat _stat
-#else
-#include <unistd.h>
-#endif
-
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#define LENGTH 16
-
-#include "./md5.h"
-
-static char *MD5End(MD5_CTX *ctx, char *buf)
-{
- int i;
- unsigned char digest[LENGTH];
- static const char hex[] = "0123456789abcdef";
-
- if (!buf)
- buf = malloc(2 * LENGTH + 1);
- if (!buf)
- return 0;
- MD5Final(digest, ctx);
- for (i = 0; i < LENGTH; i++) {
- buf[i + i] = hex[digest[i] >> 4];
- buf[i + i + 1] = hex[digest[i] & 0x0f];
- }
- buf[i + i] = '\0';
- return buf;
-}
-
-char *MD5File(const char *filename, char *buf)
-{
- return (MD5FileChunk(filename, buf, 0, 0));
-}
-
-char *MD5FileChunk(const char *filename, char *buf, off_t ofs, off_t len)
-{
- unsigned char buffer[BUFSIZ];
- MD5_CTX ctx;
- struct stat stbuf;
- int f, i, e;
- off_t n;
-
- MD5Init(&ctx);
-#ifdef _WIN32
- f = _open(filename, O_RDONLY | O_BINARY);
-#else
- f = open(filename, O_RDONLY);
-#endif
- if (f < 0)
- return 0;
- if (fstat(f, &stbuf) < 0)
- return 0;
- if (ofs > stbuf.st_size)
- ofs = stbuf.st_size;
- if ((len == 0) || (len > stbuf.st_size - ofs))
- len = stbuf.st_size - ofs;
- if (lseek(f, ofs, SEEK_SET) < 0)
- return 0;
- n = len;
- i = 0;
- while (n > 0) {
- if (n > sizeof(buffer))
- i = read(f, buffer, sizeof(buffer));
- else
- i = read(f, buffer, n);
- if (i < 0)
- break;
- MD5Update(&ctx, buffer, i);
- n -= i;
- }
- e = errno;
- close(f);
- errno = e;
- if (i < 0)
- return 0;
- return (MD5End(&ctx, buf));
-}
diff --git a/contrib/libs/libjpeg-turbo/patches/02-sanitizer.patch b/contrib/libs/libjpeg-turbo/patches/02-sanitizer.patch
deleted file mode 100644
index b219fe93d2..0000000000
--- a/contrib/libs/libjpeg-turbo/patches/02-sanitizer.patch
+++ /dev/null
@@ -1,91 +0,0 @@
-Memory sanitizer does not handle assembly code well and may generate false
-positives. libjpeg-turbo readme suggests to disable SIMD extensions at all when
-running it with sanitizers. We do not do this, but disable only some SIMD
-routines that cause problems with our tests.
-For more info see:
-* https://st.yandex-team.ru/CV-219
-* https://st.yandex-team.ru/DEVTOOLSSUPPORT-728
-* https://github.com/google/sanitizers/issues/192
-* https://github.com/libjpeg-turbo/libjpeg-turbo#memory-debugger-pitfalls
-* http://clang.llvm.org/docs/MemorySanitizer.html#handling-external-code
-
---- b/jinclude.h
-+++ a/jinclude.h
-@@ -130,6 +130,10 @@
- #endif /* _WIN32 */
-
- #endif /* NO_PUTENV */
-+
-+#ifdef WITH_SANITIZER
-+# define malloc(sz) calloc((sz), 1)
-+#endif
-
-
- #endif /* JINCLUDE_H */
---- b/simd/x86_64/jsimd.c
-+++ a/simd/x86_64/jsimd.c
-@@ -116,6 +116,7 @@ jsimd_can_ycc_rgb(void)
- {
- init_simd();
-
-+#ifndef WITH_SANITIZER
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
-@@ -130,6 +131,7 @@ jsimd_can_ycc_rgb(void)
- if ((simd_support & JSIMD_SSE2) &&
- IS_ALIGNED_SSE(jconst_ycc_rgb_convert_sse2))
- return 1;
-+#endif
-
- return 0;
- }
-@@ -997,6 +999,7 @@ jsimd_can_huff_encode_one_block(void)
- {
- init_simd();
-
-+#ifndef WITH_SANITIZER
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JCOEF) != 2)
-@@ -1005,6 +1008,7 @@ jsimd_can_huff_encode_one_block(void)
- if ((simd_support & JSIMD_SSE2) && simd_huffman &&
- IS_ALIGNED_SSE(jconst_huff_encode_one_block))
- return 1;
-+#endif
-
- return 0;
- }
-@@ -1023,6 +1027,7 @@ jsimd_can_encode_mcu_AC_first_prepare(void)
- {
- init_simd();
-
-+#ifndef WITH_SANITIZER
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JCOEF) != 2)
-@@ -1029,6 +1034,7 @@ jsimd_can_encode_mcu_AC_first_prepare(void)
- return 0;
- if (simd_support & JSIMD_SSE2)
- return 1;
-+#endif
-
- return 0;
- }
-@@ -1047,6 +1053,7 @@ jsimd_can_encode_mcu_AC_refine_prepare(void)
- {
- init_simd();
-
-+#ifndef WITH_SANITIZER
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JCOEF) != 2)
-@@ -1053,6 +1060,7 @@ jsimd_can_encode_mcu_AC_refine_prepare(void)
- return 0;
- if (simd_support & JSIMD_SSE2)
- return 1;
-+#endif
-
- return 0;
- }
-
diff --git a/contrib/libs/libjpeg-turbo/patches/03-asm.patch b/contrib/libs/libjpeg-turbo/patches/03-asm.patch
deleted file mode 100644
index c9810571e3..0000000000
--- a/contrib/libs/libjpeg-turbo/patches/03-asm.patch
+++ /dev/null
@@ -1,80 +0,0 @@
-diff --git a/simd/arm/jsimd_neon.S b/simd/arm/jsimd_neon.S
-index cd26127..e5c978f 100644
---- a/simd/arm/aarch32/jsimd_neon.S
-+++ b/simd/arm/aarch32/jsimd_neon.S
-@@ -30,10 +30,16 @@
- .section .note.GNU-stack, "", %progbits /* mark stack as non-executable */
- #endif
-
-+#if defined(__clang__) && defined(__arm__)
-+#define LITE_ASM 1
-+#endif
-+
- .text
-+#ifndef LITE_ASM
- .fpu neon
- .arch armv7a
- .object_arch armv4
-+#endif
- .arm
- .syntax unified
-
-@@ -47,6 +53,9 @@
- .globl _\fname
- _\fname:
- #else
-+#ifndef LITE_ASM
-+ .func \fname
-+#endif
- .global \fname
- #ifdef __ELF__
- .hidden \fname
-diff --git a/simd/nasm/jsimdext.inc b/simd/nasm/jsimdext.inc
-index b40901f..71a2172 100644
---- a/simd/nasm/jsimdext.inc
-+++ b/simd/nasm/jsimdext.inc
-@@ -67,7 +67,7 @@
- %define SEG_TEXT _text align=32 public use32 class=CODE
- %define SEG_CONST _data align=32 public use32 class=DATA
-
--%elifdef ELF ; ----(nasm -felf[64] -DELF ...)------------
-+%elifdef UNIX ; ----(nasm -felf[64] -DUNIX ...)------------
- ; * Linux
- ; * *BSD family Unix using elf format
- ; * Unix System V, including Solaris x86, UnixWare and SCO Unix
-@@ -77,7 +77,7 @@ section .note.GNU-stack noalloc noexec nowrite progbits
-
- ; -- segment definition --
- ;
--%ifdef __x86_64__
-+%ifdef _x86_64_
- %define SEG_TEXT .text progbits align=32
- %define SEG_CONST .rodata progbits align=32
- %else
-@@ -130,7 +130,7 @@ section .note.GNU-stack noalloc noexec nowrite progbits
- ; --------------------------------------------------------------------------
- ; Common types
- ;
--%ifdef __x86_64__
-+%ifdef _x86_64_
- %ifnidn __OUTPUT_FORMAT__, elfx32
- %define POINTER qword ; general pointer type
- %define SIZEOF_POINTER SIZEOF_QWORD ; sizeof(POINTER)
-@@ -230,7 +230,7 @@ section .note.GNU-stack noalloc noexec nowrite progbits
- ; --------------------------------------------------------------------------
- ; Hidden symbols
- ;
--%ifdef ELF ; ----(nasm -felf[64] -DELF ...)--------
-+%ifdef UNIX ; ----(nasm -felf[64] -DUNIX ...)--------
- %define GLOBAL_FUNCTION(name) global EXTN(name):function hidden
- %define GLOBAL_DATA(name) global EXTN(name):data hidden
- %elifdef MACHO ; ----(nasm -fmacho -DMACHO ...)--------
-@@ -374,7 +374,7 @@ const_base:
- align %1, db 0 ; filling zeros
- %endmacro
-
--%ifdef __x86_64__
-+%ifdef _x86_64_
-
- %ifdef WIN64
-
diff --git a/contrib/libs/libjpeg-turbo/patches/no-INT32.patch b/contrib/libs/libjpeg-turbo/patches/no-INT32.patch
deleted file mode 100644
index 9571ed48e3..0000000000
--- a/contrib/libs/libjpeg-turbo/patches/no-INT32.patch
+++ /dev/null
@@ -1,5 +0,0 @@
---- a/jmorecfg.h
-+++ b/jmorecfg.h
-@@ -140 +140 @@ typedef short INT16;
--typedef long INT32;
-+//typedef long INT32;
diff --git a/contrib/libs/libjpeg-turbo/rdbmp.c b/contrib/libs/libjpeg-turbo/rdbmp.c
deleted file mode 100644
index 433ebe2e51..0000000000
--- a/contrib/libs/libjpeg-turbo/rdbmp.c
+++ /dev/null
@@ -1,690 +0,0 @@
-/*
- * rdbmp.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * Modified 2009-2017 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Modified 2011 by Siarhei Siamashka.
- * Copyright (C) 2015, 2017-2018, 2021-2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains routines to read input images in Microsoft "BMP"
- * format (MS Windows 3.x, OS/2 1.x, and OS/2 2.x flavors).
- * Currently, only 8-, 24-, and 32-bit images are supported, not 1-bit or
- * 4-bit (feeding such low-depth images into JPEG would be silly anyway).
- * Also, we don't support RLE-compressed files.
- *
- * These routines may need modification for non-Unix environments or
- * specialized applications. As they stand, they assume input from
- * an ordinary stdio stream. They further assume that reading begins
- * at the start of the file; start_input may need work if the
- * user interface has already read some data (e.g., to determine that
- * the file is indeed BMP format).
- *
- * This code contributed by James Arthur Boucher.
- */
-
-#include "cmyk.h"
-#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
-
-#ifdef BMP_SUPPORTED
-
-
-/* Macros to deal with unsigned chars as efficiently as compiler allows */
-
-typedef unsigned char U_CHAR;
-#define UCH(x) ((int)(x))
-
-
-#define ReadOK(file, buffer, len) \
- (fread(buffer, 1, len, file) == ((size_t)(len)))
-
-static int alpha_index[JPEG_NUMCS] = {
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, 3, 0, 0, -1
-};
-
-
-/* Private version of data source object */
-
-typedef struct _bmp_source_struct *bmp_source_ptr;
-
-typedef struct _bmp_source_struct {
- struct cjpeg_source_struct pub; /* public fields */
-
- j_compress_ptr cinfo; /* back link saves passing separate parm */
-
- JSAMPARRAY colormap; /* BMP colormap (converted to my format) */
-
- jvirt_sarray_ptr whole_image; /* Needed to reverse row order */
- JDIMENSION source_row; /* Current source row number */
- JDIMENSION row_width; /* Physical width of scanlines in file */
-
- int bits_per_pixel; /* remembers 8-, 24-, or 32-bit format */
- int cmap_length; /* colormap length */
-
- boolean use_inversion_array; /* TRUE = preload the whole image, which is
- stored in bottom-up order, and feed it to
- the calling program in top-down order
-
- FALSE = the calling program will maintain
- its own image buffer and read the rows in
- bottom-up order */
-
- U_CHAR *iobuffer; /* I/O buffer (used to buffer a single row from
- disk if use_inversion_array == FALSE) */
-} bmp_source_struct;
-
-
-LOCAL(int)
-read_byte(bmp_source_ptr sinfo)
-/* Read next byte from BMP file */
-{
- register FILE *infile = sinfo->pub.input_file;
- register int c;
-
- if ((c = getc(infile)) == EOF)
- ERREXIT(sinfo->cinfo, JERR_INPUT_EOF);
- return c;
-}
-
-
-LOCAL(void)
-read_colormap(bmp_source_ptr sinfo, int cmaplen, int mapentrysize)
-/* Read the colormap from a BMP file */
-{
- int i, gray = 1;
-
- switch (mapentrysize) {
- case 3:
- /* BGR format (occurs in OS/2 files) */
- for (i = 0; i < cmaplen; i++) {
- sinfo->colormap[2][i] = (JSAMPLE)read_byte(sinfo);
- sinfo->colormap[1][i] = (JSAMPLE)read_byte(sinfo);
- sinfo->colormap[0][i] = (JSAMPLE)read_byte(sinfo);
- if (sinfo->colormap[2][i] != sinfo->colormap[1][i] ||
- sinfo->colormap[1][i] != sinfo->colormap[0][i])
- gray = 0;
- }
- break;
- case 4:
- /* BGR0 format (occurs in MS Windows files) */
- for (i = 0; i < cmaplen; i++) {
- sinfo->colormap[2][i] = (JSAMPLE)read_byte(sinfo);
- sinfo->colormap[1][i] = (JSAMPLE)read_byte(sinfo);
- sinfo->colormap[0][i] = (JSAMPLE)read_byte(sinfo);
- (void)read_byte(sinfo);
- if (sinfo->colormap[2][i] != sinfo->colormap[1][i] ||
- sinfo->colormap[1][i] != sinfo->colormap[0][i])
- gray = 0;
- }
- break;
- default:
- ERREXIT(sinfo->cinfo, JERR_BMP_BADCMAP);
- break;
- }
-
- if ((sinfo->cinfo->in_color_space == JCS_UNKNOWN ||
- sinfo->cinfo->in_color_space == JCS_RGB) && gray)
- sinfo->cinfo->in_color_space = JCS_GRAYSCALE;
-
- if (sinfo->cinfo->in_color_space == JCS_GRAYSCALE && !gray)
- ERREXIT(sinfo->cinfo, JERR_BAD_IN_COLORSPACE);
-}
-
-
-/*
- * Read one row of pixels.
- * The image has been read into the whole_image array, but is otherwise
- * unprocessed. We must read it out in top-to-bottom row order, and if
- * it is an 8-bit image, we must expand colormapped pixels to 24bit format.
- */
-
-METHODDEF(JDIMENSION)
-get_8bit_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
-/* This version is for reading 8-bit colormap indexes */
-{
- bmp_source_ptr source = (bmp_source_ptr)sinfo;
- register JSAMPARRAY colormap = source->colormap;
- int cmaplen = source->cmap_length;
- JSAMPARRAY image_ptr;
- register int t;
- register JSAMPROW inptr, outptr;
- register JDIMENSION col;
-
- if (source->use_inversion_array) {
- /* Fetch next row from virtual array */
- source->source_row--;
- image_ptr = (*cinfo->mem->access_virt_sarray)
- ((j_common_ptr)cinfo, source->whole_image,
- source->source_row, (JDIMENSION)1, FALSE);
- inptr = image_ptr[0];
- } else {
- if (!ReadOK(source->pub.input_file, source->iobuffer, source->row_width))
- ERREXIT(cinfo, JERR_INPUT_EOF);
- inptr = source->iobuffer;
- }
-
- /* Expand the colormap indexes to real data */
- outptr = source->pub.buffer[0];
- if (cinfo->in_color_space == JCS_GRAYSCALE) {
- for (col = cinfo->image_width; col > 0; col--) {
- t = *inptr++;
- if (t >= cmaplen)
- ERREXIT(cinfo, JERR_BMP_OUTOFRANGE);
- *outptr++ = colormap[0][t];
- }
- } else if (cinfo->in_color_space == JCS_CMYK) {
- for (col = cinfo->image_width; col > 0; col--) {
- t = *inptr++;
- if (t >= cmaplen)
- ERREXIT(cinfo, JERR_BMP_OUTOFRANGE);
- rgb_to_cmyk(colormap[0][t], colormap[1][t], colormap[2][t], outptr,
- outptr + 1, outptr + 2, outptr + 3);
- outptr += 4;
- }
- } else {
- register int rindex = rgb_red[cinfo->in_color_space];
- register int gindex = rgb_green[cinfo->in_color_space];
- register int bindex = rgb_blue[cinfo->in_color_space];
- register int aindex = alpha_index[cinfo->in_color_space];
- register int ps = rgb_pixelsize[cinfo->in_color_space];
-
- if (aindex >= 0) {
- for (col = cinfo->image_width; col > 0; col--) {
- t = *inptr++;
- if (t >= cmaplen)
- ERREXIT(cinfo, JERR_BMP_OUTOFRANGE);
- outptr[rindex] = colormap[0][t];
- outptr[gindex] = colormap[1][t];
- outptr[bindex] = colormap[2][t];
- outptr[aindex] = 0xFF;
- outptr += ps;
- }
- } else {
- for (col = cinfo->image_width; col > 0; col--) {
- t = *inptr++;
- if (t >= cmaplen)
- ERREXIT(cinfo, JERR_BMP_OUTOFRANGE);
- outptr[rindex] = colormap[0][t];
- outptr[gindex] = colormap[1][t];
- outptr[bindex] = colormap[2][t];
- outptr += ps;
- }
- }
- }
-
- return 1;
-}
-
-
-METHODDEF(JDIMENSION)
-get_24bit_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
-/* This version is for reading 24-bit pixels */
-{
- bmp_source_ptr source = (bmp_source_ptr)sinfo;
- JSAMPARRAY image_ptr;
- register JSAMPROW inptr, outptr;
- register JDIMENSION col;
-
- if (source->use_inversion_array) {
- /* Fetch next row from virtual array */
- source->source_row--;
- image_ptr = (*cinfo->mem->access_virt_sarray)
- ((j_common_ptr)cinfo, source->whole_image,
- source->source_row, (JDIMENSION)1, FALSE);
- inptr = image_ptr[0];
- } else {
- if (!ReadOK(source->pub.input_file, source->iobuffer, source->row_width))
- ERREXIT(cinfo, JERR_INPUT_EOF);
- inptr = source->iobuffer;
- }
-
- /* Transfer data. Note source values are in BGR order
- * (even though Microsoft's own documents say the opposite).
- */
- outptr = source->pub.buffer[0];
- if (cinfo->in_color_space == JCS_EXT_BGR) {
- memcpy(outptr, inptr, source->row_width);
- } else if (cinfo->in_color_space == JCS_CMYK) {
- for (col = cinfo->image_width; col > 0; col--) {
- JSAMPLE b = *inptr++, g = *inptr++, r = *inptr++;
- rgb_to_cmyk(r, g, b, outptr, outptr + 1, outptr + 2, outptr + 3);
- outptr += 4;
- }
- } else {
- register int rindex = rgb_red[cinfo->in_color_space];
- register int gindex = rgb_green[cinfo->in_color_space];
- register int bindex = rgb_blue[cinfo->in_color_space];
- register int aindex = alpha_index[cinfo->in_color_space];
- register int ps = rgb_pixelsize[cinfo->in_color_space];
-
- if (aindex >= 0) {
- for (col = cinfo->image_width; col > 0; col--) {
- outptr[bindex] = *inptr++;
- outptr[gindex] = *inptr++;
- outptr[rindex] = *inptr++;
- outptr[aindex] = 0xFF;
- outptr += ps;
- }
- } else {
- for (col = cinfo->image_width; col > 0; col--) {
- outptr[bindex] = *inptr++;
- outptr[gindex] = *inptr++;
- outptr[rindex] = *inptr++;
- outptr += ps;
- }
- }
- }
-
- return 1;
-}
-
-
-METHODDEF(JDIMENSION)
-get_32bit_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
-/* This version is for reading 32-bit pixels */
-{
- bmp_source_ptr source = (bmp_source_ptr)sinfo;
- JSAMPARRAY image_ptr;
- register JSAMPROW inptr, outptr;
- register JDIMENSION col;
-
- if (source->use_inversion_array) {
- /* Fetch next row from virtual array */
- source->source_row--;
- image_ptr = (*cinfo->mem->access_virt_sarray)
- ((j_common_ptr)cinfo, source->whole_image,
- source->source_row, (JDIMENSION)1, FALSE);
- inptr = image_ptr[0];
- } else {
- if (!ReadOK(source->pub.input_file, source->iobuffer, source->row_width))
- ERREXIT(cinfo, JERR_INPUT_EOF);
- inptr = source->iobuffer;
- }
-
- /* Transfer data. Note source values are in BGR order
- * (even though Microsoft's own documents say the opposite).
- */
- outptr = source->pub.buffer[0];
- if (cinfo->in_color_space == JCS_EXT_BGRX ||
- cinfo->in_color_space == JCS_EXT_BGRA) {
- memcpy(outptr, inptr, source->row_width);
- } else if (cinfo->in_color_space == JCS_CMYK) {
- for (col = cinfo->image_width; col > 0; col--) {
- JSAMPLE b = *inptr++, g = *inptr++, r = *inptr++;
- rgb_to_cmyk(r, g, b, outptr, outptr + 1, outptr + 2, outptr + 3);
- inptr++; /* skip the 4th byte (Alpha channel) */
- outptr += 4;
- }
- } else {
- register int rindex = rgb_red[cinfo->in_color_space];
- register int gindex = rgb_green[cinfo->in_color_space];
- register int bindex = rgb_blue[cinfo->in_color_space];
- register int aindex = alpha_index[cinfo->in_color_space];
- register int ps = rgb_pixelsize[cinfo->in_color_space];
-
- if (aindex >= 0) {
- for (col = cinfo->image_width; col > 0; col--) {
- outptr[bindex] = *inptr++;
- outptr[gindex] = *inptr++;
- outptr[rindex] = *inptr++;
- outptr[aindex] = *inptr++;
- outptr += ps;
- }
- } else {
- for (col = cinfo->image_width; col > 0; col--) {
- outptr[bindex] = *inptr++;
- outptr[gindex] = *inptr++;
- outptr[rindex] = *inptr++;
- inptr++; /* skip the 4th byte (Alpha channel) */
- outptr += ps;
- }
- }
- }
-
- return 1;
-}
-
-
-/*
- * This method loads the image into whole_image during the first call on
- * get_pixel_rows. The get_pixel_rows pointer is then adjusted to call
- * get_8bit_row, get_24bit_row, or get_32bit_row on subsequent calls.
- */
-
-METHODDEF(JDIMENSION)
-preload_image(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
-{
- bmp_source_ptr source = (bmp_source_ptr)sinfo;
- register FILE *infile = source->pub.input_file;
- register JSAMPROW out_ptr;
- JSAMPARRAY image_ptr;
- JDIMENSION row;
- cd_progress_ptr progress = (cd_progress_ptr)cinfo->progress;
-
- /* Read the data into a virtual array in input-file row order. */
- for (row = 0; row < cinfo->image_height; row++) {
- if (progress != NULL) {
- progress->pub.pass_counter = (long)row;
- progress->pub.pass_limit = (long)cinfo->image_height;
- (*progress->pub.progress_monitor) ((j_common_ptr)cinfo);
- }
- image_ptr = (*cinfo->mem->access_virt_sarray)
- ((j_common_ptr)cinfo, source->whole_image, row, (JDIMENSION)1, TRUE);
- out_ptr = image_ptr[0];
- if (fread(out_ptr, 1, source->row_width, infile) != source->row_width) {
- if (feof(infile))
- ERREXIT(cinfo, JERR_INPUT_EOF);
- else
- ERREXIT(cinfo, JERR_FILE_READ);
- }
- }
- if (progress != NULL)
- progress->completed_extra_passes++;
-
- /* Set up to read from the virtual array in top-to-bottom order */
- switch (source->bits_per_pixel) {
- case 8:
- source->pub.get_pixel_rows = get_8bit_row;
- break;
- case 24:
- source->pub.get_pixel_rows = get_24bit_row;
- break;
- case 32:
- source->pub.get_pixel_rows = get_32bit_row;
- break;
- default:
- ERREXIT(cinfo, JERR_BMP_BADDEPTH);
- }
- source->source_row = cinfo->image_height;
-
- /* And read the first row */
- return (*source->pub.get_pixel_rows) (cinfo, sinfo);
-}
-
-
-/*
- * Read the file header; return image size and component count.
- */
-
-METHODDEF(void)
-start_input_bmp(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
-{
- bmp_source_ptr source = (bmp_source_ptr)sinfo;
- U_CHAR bmpfileheader[14];
- U_CHAR bmpinfoheader[64];
-
-#define GET_2B(array, offset) \
- ((unsigned short)UCH(array[offset]) + \
- (((unsigned short)UCH(array[offset + 1])) << 8))
-#define GET_4B(array, offset) \
- ((unsigned int)UCH(array[offset]) + \
- (((unsigned int)UCH(array[offset + 1])) << 8) + \
- (((unsigned int)UCH(array[offset + 2])) << 16) + \
- (((unsigned int)UCH(array[offset + 3])) << 24))
-
- int bfOffBits;
- int headerSize;
- int biWidth;
- int biHeight;
- unsigned short biPlanes;
- unsigned int biCompression;
- int biXPelsPerMeter, biYPelsPerMeter;
- int biClrUsed = 0;
- int mapentrysize = 0; /* 0 indicates no colormap */
- int bPad;
- JDIMENSION row_width = 0;
-
- /* Read and verify the bitmap file header */
- if (!ReadOK(source->pub.input_file, bmpfileheader, 14))
- ERREXIT(cinfo, JERR_INPUT_EOF);
- if (GET_2B(bmpfileheader, 0) != 0x4D42) /* 'BM' */
- ERREXIT(cinfo, JERR_BMP_NOT);
- bfOffBits = GET_4B(bmpfileheader, 10);
- /* We ignore the remaining fileheader fields */
-
- /* The infoheader might be 12 bytes (OS/2 1.x), 40 bytes (Windows),
- * or 64 bytes (OS/2 2.x). Check the first 4 bytes to find out which.
- */
- if (!ReadOK(source->pub.input_file, bmpinfoheader, 4))
- ERREXIT(cinfo, JERR_INPUT_EOF);
- headerSize = GET_4B(bmpinfoheader, 0);
- if (headerSize < 12 || headerSize > 64 || (headerSize + 14) > bfOffBits)
- ERREXIT(cinfo, JERR_BMP_BADHEADER);
- if (!ReadOK(source->pub.input_file, bmpinfoheader + 4, headerSize - 4))
- ERREXIT(cinfo, JERR_INPUT_EOF);
-
- switch (headerSize) {
- case 12:
- /* Decode OS/2 1.x header (Microsoft calls this a BITMAPCOREHEADER) */
- biWidth = (int)GET_2B(bmpinfoheader, 4);
- biHeight = (int)GET_2B(bmpinfoheader, 6);
- biPlanes = GET_2B(bmpinfoheader, 8);
- source->bits_per_pixel = (int)GET_2B(bmpinfoheader, 10);
-
- switch (source->bits_per_pixel) {
- case 8: /* colormapped image */
- mapentrysize = 3; /* OS/2 uses RGBTRIPLE colormap */
- TRACEMS2(cinfo, 1, JTRC_BMP_OS2_MAPPED, biWidth, biHeight);
- break;
- case 24: /* RGB image */
- case 32: /* RGB image + Alpha channel */
- TRACEMS3(cinfo, 1, JTRC_BMP_OS2, biWidth, biHeight,
- source->bits_per_pixel);
- break;
- default:
- ERREXIT(cinfo, JERR_BMP_BADDEPTH);
- break;
- }
- break;
- case 40:
- case 64:
- /* Decode Windows 3.x header (Microsoft calls this a BITMAPINFOHEADER) */
- /* or OS/2 2.x header, which has additional fields that we ignore */
- biWidth = (int)GET_4B(bmpinfoheader, 4);
- biHeight = (int)GET_4B(bmpinfoheader, 8);
- biPlanes = GET_2B(bmpinfoheader, 12);
- source->bits_per_pixel = (int)GET_2B(bmpinfoheader, 14);
- biCompression = GET_4B(bmpinfoheader, 16);
- biXPelsPerMeter = (int)GET_4B(bmpinfoheader, 24);
- biYPelsPerMeter = (int)GET_4B(bmpinfoheader, 28);
- biClrUsed = GET_4B(bmpinfoheader, 32);
- /* biSizeImage, biClrImportant fields are ignored */
-
- switch (source->bits_per_pixel) {
- case 8: /* colormapped image */
- mapentrysize = 4; /* Windows uses RGBQUAD colormap */
- TRACEMS2(cinfo, 1, JTRC_BMP_MAPPED, biWidth, biHeight);
- break;
- case 24: /* RGB image */
- case 32: /* RGB image + Alpha channel */
- TRACEMS3(cinfo, 1, JTRC_BMP, biWidth, biHeight, source->bits_per_pixel);
- break;
- default:
- ERREXIT(cinfo, JERR_BMP_BADDEPTH);
- break;
- }
- if (biCompression != 0)
- ERREXIT(cinfo, JERR_BMP_COMPRESSED);
-
- if (biXPelsPerMeter > 0 && biYPelsPerMeter > 0) {
- /* Set JFIF density parameters from the BMP data */
- cinfo->X_density = (UINT16)(biXPelsPerMeter / 100); /* 100 cm per meter */
- cinfo->Y_density = (UINT16)(biYPelsPerMeter / 100);
- cinfo->density_unit = 2; /* dots/cm */
- }
- break;
- default:
- ERREXIT(cinfo, JERR_BMP_BADHEADER);
- return;
- }
-
- if (biWidth <= 0 || biHeight <= 0)
- ERREXIT(cinfo, JERR_BMP_EMPTY);
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
- if (sinfo->max_pixels &&
- (unsigned long long)biWidth * biHeight > sinfo->max_pixels)
- ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
-#endif
- if (biPlanes != 1)
- ERREXIT(cinfo, JERR_BMP_BADPLANES);
-
- /* Compute distance to bitmap data --- will adjust for colormap below */
- bPad = bfOffBits - (headerSize + 14);
-
- /* Read the colormap, if any */
- if (mapentrysize > 0) {
- if (biClrUsed <= 0)
- biClrUsed = 256; /* assume it's 256 */
- else if (biClrUsed > 256)
- ERREXIT(cinfo, JERR_BMP_BADCMAP);
- /* Allocate space to store the colormap */
- source->colormap = (*cinfo->mem->alloc_sarray)
- ((j_common_ptr)cinfo, JPOOL_IMAGE, (JDIMENSION)biClrUsed, (JDIMENSION)3);
- source->cmap_length = (int)biClrUsed;
- /* and read it from the file */
- read_colormap(source, (int)biClrUsed, mapentrysize);
- /* account for size of colormap */
- bPad -= biClrUsed * mapentrysize;
- }
-
- /* Skip any remaining pad bytes */
- if (bPad < 0) /* incorrect bfOffBits value? */
- ERREXIT(cinfo, JERR_BMP_BADHEADER);
- while (--bPad >= 0) {
- (void)read_byte(source);
- }
-
- /* Compute row width in file, including padding to 4-byte boundary */
- switch (source->bits_per_pixel) {
- case 8:
- if (cinfo->in_color_space == JCS_UNKNOWN)
- cinfo->in_color_space = JCS_EXT_RGB;
- if (IsExtRGB(cinfo->in_color_space))
- cinfo->input_components = rgb_pixelsize[cinfo->in_color_space];
- else if (cinfo->in_color_space == JCS_GRAYSCALE)
- cinfo->input_components = 1;
- else if (cinfo->in_color_space == JCS_CMYK)
- cinfo->input_components = 4;
- else
- ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
- row_width = (JDIMENSION)biWidth;
- break;
- case 24:
- if (cinfo->in_color_space == JCS_UNKNOWN)
- cinfo->in_color_space = JCS_EXT_BGR;
- if (IsExtRGB(cinfo->in_color_space))
- cinfo->input_components = rgb_pixelsize[cinfo->in_color_space];
- else if (cinfo->in_color_space == JCS_CMYK)
- cinfo->input_components = 4;
- else
- ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
- if ((unsigned long long)biWidth * 3ULL > 0xFFFFFFFFULL)
- ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
- row_width = (JDIMENSION)biWidth * 3;
- break;
- case 32:
- if (cinfo->in_color_space == JCS_UNKNOWN)
- cinfo->in_color_space = JCS_EXT_BGRA;
- if (IsExtRGB(cinfo->in_color_space))
- cinfo->input_components = rgb_pixelsize[cinfo->in_color_space];
- else if (cinfo->in_color_space == JCS_CMYK)
- cinfo->input_components = 4;
- else
- ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
- if ((unsigned long long)biWidth * 4ULL > 0xFFFFFFFFULL)
- ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
- row_width = (JDIMENSION)biWidth * 4;
- break;
- default:
- ERREXIT(cinfo, JERR_BMP_BADDEPTH);
- }
- while ((row_width & 3) != 0) row_width++;
- source->row_width = row_width;
-
- if (source->use_inversion_array) {
- /* Allocate space for inversion array, prepare for preload pass */
- source->whole_image = (*cinfo->mem->request_virt_sarray)
- ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE,
- row_width, (JDIMENSION)biHeight, (JDIMENSION)1);
- source->pub.get_pixel_rows = preload_image;
- if (cinfo->progress != NULL) {
- cd_progress_ptr progress = (cd_progress_ptr)cinfo->progress;
- progress->total_extra_passes++; /* count file input as separate pass */
- }
- } else {
- source->iobuffer = (U_CHAR *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, row_width);
- switch (source->bits_per_pixel) {
- case 8:
- source->pub.get_pixel_rows = get_8bit_row;
- break;
- case 24:
- source->pub.get_pixel_rows = get_24bit_row;
- break;
- case 32:
- source->pub.get_pixel_rows = get_32bit_row;
- break;
- default:
- ERREXIT(cinfo, JERR_BMP_BADDEPTH);
- }
- }
-
- /* Ensure that biWidth * cinfo->input_components doesn't exceed the maximum
- value of the JDIMENSION type. This is only a danger with BMP files, since
- their width and height fields are 32-bit integers. */
- if ((unsigned long long)biWidth *
- (unsigned long long)cinfo->input_components > 0xFFFFFFFFULL)
- ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
- /* Allocate one-row buffer for returned data */
- source->pub.buffer = (*cinfo->mem->alloc_sarray)
- ((j_common_ptr)cinfo, JPOOL_IMAGE,
- (JDIMENSION)biWidth * (JDIMENSION)cinfo->input_components, (JDIMENSION)1);
- source->pub.buffer_height = 1;
-
- cinfo->data_precision = 8;
- cinfo->image_width = (JDIMENSION)biWidth;
- cinfo->image_height = (JDIMENSION)biHeight;
-}
-
-
-/*
- * Finish up at the end of the file.
- */
-
-METHODDEF(void)
-finish_input_bmp(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
-{
- /* no work */
-}
-
-
-/*
- * The module selection routine for BMP format input.
- */
-
-GLOBAL(cjpeg_source_ptr)
-jinit_read_bmp(j_compress_ptr cinfo, boolean use_inversion_array)
-{
- bmp_source_ptr source;
-
- /* Create module interface object */
- source = (bmp_source_ptr)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- sizeof(bmp_source_struct));
- source->cinfo = cinfo; /* make back link for subroutines */
- /* Fill in method ptrs, except get_pixel_rows which start_input sets */
- source->pub.start_input = start_input_bmp;
- source->pub.finish_input = finish_input_bmp;
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
- source->pub.max_pixels = 0;
-#endif
-
- source->use_inversion_array = use_inversion_array;
-
- return (cjpeg_source_ptr)source;
-}
-
-#endif /* BMP_SUPPORTED */
diff --git a/contrib/libs/libjpeg-turbo/rdcolmap.c b/contrib/libs/libjpeg-turbo/rdcolmap.c
deleted file mode 100644
index d2ed95cf80..0000000000
--- a/contrib/libs/libjpeg-turbo/rdcolmap.c
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- * rdcolmap.c
- *
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * This file is part of the Independent JPEG Group's software.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file implements djpeg's "-map file" switch. It reads a source image
- * and constructs a colormap to be supplied to the JPEG decompressor.
- *
- * Currently, these file formats are supported for the map file:
- * GIF: the contents of the GIF's global colormap are used.
- * PPM (either text or raw flavor): the entire file is read and
- * each unique pixel value is entered in the map.
- * Note that reading a large PPM file will be horrendously slow.
- * Typically, a PPM-format map file should contain just one pixel
- * of each desired color. Such a file can be extracted from an
- * ordinary image PPM file with ppmtomap(1).
- *
- * Rescaling a PPM that has a maxval unequal to MAXJSAMPLE is not
- * currently implemented.
- */
-
-#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
-
-#ifdef QUANT_2PASS_SUPPORTED /* otherwise can't quantize to supplied map */
-
-/* Portions of this code are based on the PBMPLUS library, which is:
-**
-** Copyright (C) 1988 by Jef Poskanzer.
-**
-** Permission to use, copy, modify, and distribute this software and its
-** documentation for any purpose and without fee is hereby granted, provided
-** that the above copyright notice appear in all copies and that both that
-** copyright notice and this permission notice appear in supporting
-** documentation. This software is provided "as is" without express or
-** implied warranty.
-*/
-
-
-/*
- * Add a (potentially) new color to the color map.
- */
-
-LOCAL(void)
-add_map_entry(j_decompress_ptr cinfo, int R, int G, int B)
-{
- JSAMPROW colormap0 = cinfo->colormap[0];
- JSAMPROW colormap1 = cinfo->colormap[1];
- JSAMPROW colormap2 = cinfo->colormap[2];
- int ncolors = cinfo->actual_number_of_colors;
- int index;
-
- /* Check for duplicate color. */
- for (index = 0; index < ncolors; index++) {
- if (colormap0[index] == R && colormap1[index] == G &&
- colormap2[index] == B)
- return; /* color is already in map */
- }
-
- /* Check for map overflow. */
- if (ncolors >= (MAXJSAMPLE + 1))
- ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, (MAXJSAMPLE + 1));
-
- /* OK, add color to map. */
- colormap0[ncolors] = (JSAMPLE)R;
- colormap1[ncolors] = (JSAMPLE)G;
- colormap2[ncolors] = (JSAMPLE)B;
- cinfo->actual_number_of_colors++;
-}
-
-
-/*
- * Extract color map from a GIF file.
- */
-
-LOCAL(void)
-read_gif_map(j_decompress_ptr cinfo, FILE *infile)
-{
- int header[13];
- int i, colormaplen;
- int R, G, B;
-
- /* Initial 'G' has already been read by read_color_map */
- /* Read the rest of the GIF header and logical screen descriptor */
- for (i = 1; i < 13; i++) {
- if ((header[i] = getc(infile)) == EOF)
- ERREXIT(cinfo, JERR_BAD_CMAP_FILE);
- }
-
- /* Verify GIF Header */
- if (header[1] != 'I' || header[2] != 'F')
- ERREXIT(cinfo, JERR_BAD_CMAP_FILE);
-
- /* There must be a global color map. */
- if ((header[10] & 0x80) == 0)
- ERREXIT(cinfo, JERR_BAD_CMAP_FILE);
-
- /* OK, fetch it. */
- colormaplen = 2 << (header[10] & 0x07);
-
- for (i = 0; i < colormaplen; i++) {
- R = getc(infile);
- G = getc(infile);
- B = getc(infile);
- if (R == EOF || G == EOF || B == EOF)
- ERREXIT(cinfo, JERR_BAD_CMAP_FILE);
- add_map_entry(cinfo,
- R << (BITS_IN_JSAMPLE - 8),
- G << (BITS_IN_JSAMPLE - 8),
- B << (BITS_IN_JSAMPLE - 8));
- }
-}
-
-
-/* Support routines for reading PPM */
-
-
-LOCAL(int)
-pbm_getc(FILE *infile)
-/* Read next char, skipping over any comments */
-/* A comment/newline sequence is returned as a newline */
-{
- register int ch;
-
- ch = getc(infile);
- if (ch == '#') {
- do {
- ch = getc(infile);
- } while (ch != '\n' && ch != EOF);
- }
- return ch;
-}
-
-
-LOCAL(unsigned int)
-read_pbm_integer(j_decompress_ptr cinfo, FILE *infile)
-/* Read an unsigned decimal integer from the PPM file */
-/* Swallows one trailing character after the integer */
-/* Note that on a 16-bit-int machine, only values up to 64k can be read. */
-/* This should not be a problem in practice. */
-{
- register int ch;
- register unsigned int val;
-
- /* Skip any leading whitespace */
- do {
- ch = pbm_getc(infile);
- if (ch == EOF)
- ERREXIT(cinfo, JERR_BAD_CMAP_FILE);
- } while (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r');
-
- if (ch < '0' || ch > '9')
- ERREXIT(cinfo, JERR_BAD_CMAP_FILE);
-
- val = ch - '0';
- while ((ch = pbm_getc(infile)) >= '0' && ch <= '9') {
- val *= 10;
- val += ch - '0';
- }
- return val;
-}
-
-
-/*
- * Extract color map from a PPM file.
- */
-
-LOCAL(void)
-read_ppm_map(j_decompress_ptr cinfo, FILE *infile)
-{
- int c;
- unsigned int w, h, maxval, row, col;
- int R, G, B;
-
- /* Initial 'P' has already been read by read_color_map */
- c = getc(infile); /* save format discriminator for a sec */
-
- /* while we fetch the remaining header info */
- w = read_pbm_integer(cinfo, infile);
- h = read_pbm_integer(cinfo, infile);
- maxval = read_pbm_integer(cinfo, infile);
-
- if (w <= 0 || h <= 0 || maxval <= 0) /* error check */
- ERREXIT(cinfo, JERR_BAD_CMAP_FILE);
-
- /* For now, we don't support rescaling from an unusual maxval. */
- if (maxval != (unsigned int)MAXJSAMPLE)
- ERREXIT(cinfo, JERR_BAD_CMAP_FILE);
-
- switch (c) {
- case '3': /* it's a text-format PPM file */
- for (row = 0; row < h; row++) {
- for (col = 0; col < w; col++) {
- R = read_pbm_integer(cinfo, infile);
- G = read_pbm_integer(cinfo, infile);
- B = read_pbm_integer(cinfo, infile);
- add_map_entry(cinfo, R, G, B);
- }
- }
- break;
-
- case '6': /* it's a raw-format PPM file */
- for (row = 0; row < h; row++) {
- for (col = 0; col < w; col++) {
- R = getc(infile);
- G = getc(infile);
- B = getc(infile);
- if (R == EOF || G == EOF || B == EOF)
- ERREXIT(cinfo, JERR_BAD_CMAP_FILE);
- add_map_entry(cinfo, R, G, B);
- }
- }
- break;
-
- default:
- ERREXIT(cinfo, JERR_BAD_CMAP_FILE);
- break;
- }
-}
-
-
-/*
- * Main entry point from djpeg.c.
- * Input: opened input file (from file name argument on command line).
- * Output: colormap and actual_number_of_colors fields are set in cinfo.
- */
-
-GLOBAL(void)
-read_color_map(j_decompress_ptr cinfo, FILE *infile)
-{
- /* Allocate space for a color map of maximum supported size. */
- cinfo->colormap = (*cinfo->mem->alloc_sarray)
- ((j_common_ptr)cinfo, JPOOL_IMAGE,
- (JDIMENSION)(MAXJSAMPLE + 1), (JDIMENSION)3);
- cinfo->actual_number_of_colors = 0; /* initialize map to empty */
-
- /* Read first byte to determine file format */
- switch (getc(infile)) {
- case 'G':
- read_gif_map(cinfo, infile);
- break;
- case 'P':
- read_ppm_map(cinfo, infile);
- break;
- default:
- ERREXIT(cinfo, JERR_BAD_CMAP_FILE);
- break;
- }
-}
-
-#endif /* QUANT_2PASS_SUPPORTED */
diff --git a/contrib/libs/libjpeg-turbo/rdgif.c b/contrib/libs/libjpeg-turbo/rdgif.c
deleted file mode 100644
index bdf7401241..0000000000
--- a/contrib/libs/libjpeg-turbo/rdgif.c
+++ /dev/null
@@ -1,720 +0,0 @@
-/*
- * rdgif.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * Modified 2019 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2021-2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains routines to read input images in GIF format.
- *
- * These routines may need modification for non-Unix environments or
- * specialized applications. As they stand, they assume input from
- * an ordinary stdio stream. They further assume that reading begins
- * at the start of the file; start_input may need work if the
- * user interface has already read some data (e.g., to determine that
- * the file is indeed GIF format).
- */
-
-/*
- * This code is loosely based on giftoppm from the PBMPLUS distribution
- * of Feb. 1991. That file contains the following copyright notice:
- * +-------------------------------------------------------------------+
- * | Copyright 1990, David Koblas. |
- * | Permission to use, copy, modify, and distribute this software |
- * | and its documentation for any purpose and without fee is hereby |
- * | granted, provided that the above copyright notice appear in all |
- * | copies and that both that copyright notice and this permission |
- * | notice appear in supporting documentation. This software is |
- * | provided "as is" without express or implied warranty. |
- * +-------------------------------------------------------------------+
- */
-
-#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
-
-#ifdef GIF_SUPPORTED
-
-
-/* Macros to deal with unsigned chars as efficiently as compiler allows */
-
-typedef unsigned char U_CHAR;
-#define UCH(x) ((int)(x))
-
-
-#define ReadOK(file, buffer, len) \
- (fread(buffer, 1, len, file) == ((size_t)(len)))
-
-
-#define MAXCOLORMAPSIZE 256 /* max # of colors in a GIF colormap */
-#define NUMCOLORS 3 /* # of colors */
-#define CM_RED 0 /* color component numbers */
-#define CM_GREEN 1
-#define CM_BLUE 2
-
-#define MAX_LZW_BITS 12 /* maximum LZW code size */
-#define LZW_TABLE_SIZE (1 << MAX_LZW_BITS) /* # of possible LZW symbols */
-
-/* Macros for extracting header data --- note we assume chars may be signed */
-
-#define LM_to_uint(array, offset) \
- ((unsigned int)UCH(array[offset]) + \
- (((unsigned int)UCH(array[offset + 1])) << 8))
-
-#define BitSet(byte, bit) ((byte) & (bit))
-#define INTERLACE 0x40 /* mask for bit signifying interlaced image */
-#define COLORMAPFLAG 0x80 /* mask for bit signifying colormap presence */
-
-
-/*
- * LZW decompression tables look like this:
- * symbol_head[K] = prefix symbol of any LZW symbol K (0..LZW_TABLE_SIZE-1)
- * symbol_tail[K] = suffix byte of any LZW symbol K (0..LZW_TABLE_SIZE-1)
- * Note that entries 0..end_code of the above tables are not used,
- * since those symbols represent raw bytes or special codes.
- *
- * The stack represents the not-yet-used expansion of the last LZW symbol.
- * In the worst case, a symbol could expand to as many bytes as there are
- * LZW symbols, so we allocate LZW_TABLE_SIZE bytes for the stack.
- * (This is conservative since that number includes the raw-byte symbols.)
- */
-
-
-/* Private version of data source object */
-
-typedef struct {
- struct cjpeg_source_struct pub; /* public fields */
-
- j_compress_ptr cinfo; /* back link saves passing separate parm */
-
- JSAMPARRAY colormap; /* GIF colormap (converted to my format) */
-
- /* State for GetCode and LZWReadByte */
- U_CHAR code_buf[256 + 4]; /* current input data block */
- int last_byte; /* # of bytes in code_buf */
- int last_bit; /* # of bits in code_buf */
- int cur_bit; /* next bit index to read */
- boolean first_time; /* flags first call to GetCode */
- boolean out_of_blocks; /* TRUE if hit terminator data block */
-
- int input_code_size; /* codesize given in GIF file */
- int clear_code, end_code; /* values for Clear and End codes */
-
- int code_size; /* current actual code size */
- int limit_code; /* 2^code_size */
- int max_code; /* first unused code value */
-
- /* Private state for LZWReadByte */
- int oldcode; /* previous LZW symbol */
- int firstcode; /* first byte of oldcode's expansion */
-
- /* LZW symbol table and expansion stack */
- UINT16 *symbol_head; /* => table of prefix symbols */
- UINT8 *symbol_tail; /* => table of suffix bytes */
- UINT8 *symbol_stack; /* => stack for symbol expansions */
- UINT8 *sp; /* stack pointer */
-
- /* State for interlaced image processing */
- boolean is_interlaced; /* TRUE if have interlaced image */
- jvirt_sarray_ptr interlaced_image; /* full image in interlaced order */
- JDIMENSION cur_row_number; /* need to know actual row number */
- JDIMENSION pass2_offset; /* # of pixel rows in pass 1 */
- JDIMENSION pass3_offset; /* # of pixel rows in passes 1&2 */
- JDIMENSION pass4_offset; /* # of pixel rows in passes 1,2,3 */
-} gif_source_struct;
-
-typedef gif_source_struct *gif_source_ptr;
-
-
-/* Forward declarations */
-METHODDEF(JDIMENSION) get_pixel_rows(j_compress_ptr cinfo,
- cjpeg_source_ptr sinfo);
-METHODDEF(JDIMENSION) load_interlaced_image(j_compress_ptr cinfo,
- cjpeg_source_ptr sinfo);
-METHODDEF(JDIMENSION) get_interlaced_row(j_compress_ptr cinfo,
- cjpeg_source_ptr sinfo);
-
-
-LOCAL(int)
-ReadByte(gif_source_ptr sinfo)
-/* Read next byte from GIF file */
-{
- register FILE *infile = sinfo->pub.input_file;
- register int c;
-
- if ((c = getc(infile)) == EOF)
- ERREXIT(sinfo->cinfo, JERR_INPUT_EOF);
- return c;
-}
-
-
-LOCAL(int)
-GetDataBlock(gif_source_ptr sinfo, U_CHAR *buf)
-/* Read a GIF data block, which has a leading count byte */
-/* A zero-length block marks the end of a data block sequence */
-{
- int count;
-
- count = ReadByte(sinfo);
- if (count > 0) {
- if (!ReadOK(sinfo->pub.input_file, buf, count))
- ERREXIT(sinfo->cinfo, JERR_INPUT_EOF);
- }
- return count;
-}
-
-
-LOCAL(void)
-SkipDataBlocks(gif_source_ptr sinfo)
-/* Skip a series of data blocks, until a block terminator is found */
-{
- U_CHAR buf[256];
-
- while (GetDataBlock(sinfo, buf) > 0)
- /* skip */;
-}
-
-
-LOCAL(void)
-ReInitLZW(gif_source_ptr sinfo)
-/* (Re)initialize LZW state; shared code for startup and Clear processing */
-{
- sinfo->code_size = sinfo->input_code_size + 1;
- sinfo->limit_code = sinfo->clear_code << 1; /* 2^code_size */
- sinfo->max_code = sinfo->clear_code + 2; /* first unused code value */
- sinfo->sp = sinfo->symbol_stack; /* init stack to empty */
-}
-
-
-LOCAL(void)
-InitLZWCode(gif_source_ptr sinfo)
-/* Initialize for a series of LZWReadByte (and hence GetCode) calls */
-{
- /* GetCode initialization */
- sinfo->last_byte = 2; /* make safe to "recopy last two bytes" */
- sinfo->code_buf[0] = 0;
- sinfo->code_buf[1] = 0;
- sinfo->last_bit = 0; /* nothing in the buffer */
- sinfo->cur_bit = 0; /* force buffer load on first call */
- sinfo->first_time = TRUE;
- sinfo->out_of_blocks = FALSE;
-
- /* LZWReadByte initialization: */
- /* compute special code values (note that these do not change later) */
- sinfo->clear_code = 1 << sinfo->input_code_size;
- sinfo->end_code = sinfo->clear_code + 1;
- ReInitLZW(sinfo);
-}
-
-
-LOCAL(int)
-GetCode(gif_source_ptr sinfo)
-/* Fetch the next code_size bits from the GIF data */
-/* We assume code_size is less than 16 */
-{
- register int accum;
- int offs, count;
-
- while (sinfo->cur_bit + sinfo->code_size > sinfo->last_bit) {
- /* Time to reload the buffer */
- /* First time, share code with Clear case */
- if (sinfo->first_time) {
- sinfo->first_time = FALSE;
- return sinfo->clear_code;
- }
- if (sinfo->out_of_blocks) {
- WARNMS(sinfo->cinfo, JWRN_GIF_NOMOREDATA);
- return sinfo->end_code; /* fake something useful */
- }
- /* preserve last two bytes of what we have -- assume code_size <= 16 */
- sinfo->code_buf[0] = sinfo->code_buf[sinfo->last_byte-2];
- sinfo->code_buf[1] = sinfo->code_buf[sinfo->last_byte-1];
- /* Load more bytes; set flag if we reach the terminator block */
- if ((count = GetDataBlock(sinfo, &sinfo->code_buf[2])) == 0) {
- sinfo->out_of_blocks = TRUE;
- WARNMS(sinfo->cinfo, JWRN_GIF_NOMOREDATA);
- return sinfo->end_code; /* fake something useful */
- }
- /* Reset counters */
- sinfo->cur_bit = (sinfo->cur_bit - sinfo->last_bit) + 16;
- sinfo->last_byte = 2 + count;
- sinfo->last_bit = sinfo->last_byte * 8;
- }
-
- /* Form up next 24 bits in accum */
- offs = sinfo->cur_bit >> 3; /* byte containing cur_bit */
- accum = UCH(sinfo->code_buf[offs + 2]);
- accum <<= 8;
- accum |= UCH(sinfo->code_buf[offs + 1]);
- accum <<= 8;
- accum |= UCH(sinfo->code_buf[offs]);
-
- /* Right-align cur_bit in accum, then mask off desired number of bits */
- accum >>= (sinfo->cur_bit & 7);
- sinfo->cur_bit += sinfo->code_size;
- return accum & ((1 << sinfo->code_size) - 1);
-}
-
-
-LOCAL(int)
-LZWReadByte(gif_source_ptr sinfo)
-/* Read an LZW-compressed byte */
-{
- register int code; /* current working code */
- int incode; /* saves actual input code */
-
- /* If any codes are stacked from a previously read symbol, return them */
- if (sinfo->sp > sinfo->symbol_stack)
- return (int)(*(--sinfo->sp));
-
- /* Time to read a new symbol */
- code = GetCode(sinfo);
-
- if (code == sinfo->clear_code) {
- /* Reinit state, swallow any extra Clear codes, and */
- /* return next code, which is expected to be a raw byte. */
- ReInitLZW(sinfo);
- do {
- code = GetCode(sinfo);
- } while (code == sinfo->clear_code);
- if (code > sinfo->clear_code) { /* make sure it is a raw byte */
- WARNMS(sinfo->cinfo, JWRN_GIF_BADDATA);
- code = 0; /* use something valid */
- }
- /* make firstcode, oldcode valid! */
- sinfo->firstcode = sinfo->oldcode = code;
- return code;
- }
-
- if (code == sinfo->end_code) {
- /* Skip the rest of the image, unless GetCode already read terminator */
- if (!sinfo->out_of_blocks) {
- SkipDataBlocks(sinfo);
- sinfo->out_of_blocks = TRUE;
- }
- /* Complain that there's not enough data */
- WARNMS(sinfo->cinfo, JWRN_GIF_ENDCODE);
- /* Pad data with 0's */
- return 0; /* fake something usable */
- }
-
- /* Got normal raw byte or LZW symbol */
- incode = code; /* save for a moment */
-
- if (code >= sinfo->max_code) { /* special case for not-yet-defined symbol */
- /* code == max_code is OK; anything bigger is bad data */
- if (code > sinfo->max_code) {
- WARNMS(sinfo->cinfo, JWRN_GIF_BADDATA);
- incode = 0; /* prevent creation of loops in symbol table */
- }
- /* this symbol will be defined as oldcode/firstcode */
- *(sinfo->sp++) = (UINT8)sinfo->firstcode;
- code = sinfo->oldcode;
- }
-
- /* If it's a symbol, expand it into the stack */
- while (code >= sinfo->clear_code) {
- *(sinfo->sp++) = sinfo->symbol_tail[code]; /* tail is a byte value */
- code = sinfo->symbol_head[code]; /* head is another LZW symbol */
- }
- /* At this point code just represents a raw byte */
- sinfo->firstcode = code; /* save for possible future use */
-
- /* If there's room in table... */
- if ((code = sinfo->max_code) < LZW_TABLE_SIZE) {
- /* Define a new symbol = prev sym + head of this sym's expansion */
- sinfo->symbol_head[code] = (UINT16)sinfo->oldcode;
- sinfo->symbol_tail[code] = (UINT8)sinfo->firstcode;
- sinfo->max_code++;
- /* Is it time to increase code_size? */
- if (sinfo->max_code >= sinfo->limit_code &&
- sinfo->code_size < MAX_LZW_BITS) {
- sinfo->code_size++;
- sinfo->limit_code <<= 1; /* keep equal to 2^code_size */
- }
- }
-
- sinfo->oldcode = incode; /* save last input symbol for future use */
- return sinfo->firstcode; /* return first byte of symbol's expansion */
-}
-
-
-LOCAL(void)
-ReadColorMap(gif_source_ptr sinfo, int cmaplen, JSAMPARRAY cmap)
-/* Read a GIF colormap */
-{
- int i, gray = 1;
-
- for (i = 0; i < cmaplen; i++) {
-#if BITS_IN_JSAMPLE == 8
-#define UPSCALE(x) (x)
-#else
-#define UPSCALE(x) ((x) << (BITS_IN_JSAMPLE - 8))
-#endif
- cmap[CM_RED][i] = (JSAMPLE)UPSCALE(ReadByte(sinfo));
- cmap[CM_GREEN][i] = (JSAMPLE)UPSCALE(ReadByte(sinfo));
- cmap[CM_BLUE][i] = (JSAMPLE)UPSCALE(ReadByte(sinfo));
- if (cmap[CM_RED][i] != cmap[CM_GREEN][i] ||
- cmap[CM_GREEN][i] != cmap[CM_BLUE][i])
- gray = 0;
- }
-
- if (sinfo->cinfo->in_color_space == JCS_RGB && gray) {
- sinfo->cinfo->in_color_space = JCS_GRAYSCALE;
- sinfo->cinfo->input_components = 1;
- }
-}
-
-
-LOCAL(void)
-DoExtension(gif_source_ptr sinfo)
-/* Process an extension block */
-/* Currently we ignore 'em all */
-{
- int extlabel;
-
- /* Read extension label byte */
- extlabel = ReadByte(sinfo);
- TRACEMS1(sinfo->cinfo, 1, JTRC_GIF_EXTENSION, extlabel);
- /* Skip the data block(s) associated with the extension */
- SkipDataBlocks(sinfo);
-}
-
-
-/*
- * Read the file header; return image size and component count.
- */
-
-METHODDEF(void)
-start_input_gif(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
-{
- gif_source_ptr source = (gif_source_ptr)sinfo;
- U_CHAR hdrbuf[10]; /* workspace for reading control blocks */
- unsigned int width, height; /* image dimensions */
- int colormaplen, aspectRatio;
- int c;
-
- /* Read and verify GIF Header */
- if (!ReadOK(source->pub.input_file, hdrbuf, 6))
- ERREXIT(cinfo, JERR_GIF_NOT);
- if (hdrbuf[0] != 'G' || hdrbuf[1] != 'I' || hdrbuf[2] != 'F')
- ERREXIT(cinfo, JERR_GIF_NOT);
- /* Check for expected version numbers.
- * If unknown version, give warning and try to process anyway;
- * this is per recommendation in GIF89a standard.
- */
- if ((hdrbuf[3] != '8' || hdrbuf[4] != '7' || hdrbuf[5] != 'a') &&
- (hdrbuf[3] != '8' || hdrbuf[4] != '9' || hdrbuf[5] != 'a'))
- TRACEMS3(cinfo, 1, JTRC_GIF_BADVERSION, hdrbuf[3], hdrbuf[4], hdrbuf[5]);
-
- /* Read and decipher Logical Screen Descriptor */
- if (!ReadOK(source->pub.input_file, hdrbuf, 7))
- ERREXIT(cinfo, JERR_INPUT_EOF);
- width = LM_to_uint(hdrbuf, 0);
- height = LM_to_uint(hdrbuf, 2);
- if (width == 0 || height == 0)
- ERREXIT(cinfo, JERR_GIF_EMPTY);
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
- if (sinfo->max_pixels &&
- (unsigned long long)width * height > sinfo->max_pixels)
- ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
-#endif
- /* we ignore the color resolution, sort flag, and background color index */
- aspectRatio = UCH(hdrbuf[6]);
- if (aspectRatio != 0 && aspectRatio != 49)
- TRACEMS(cinfo, 1, JTRC_GIF_NONSQUARE);
-
- /* Allocate space to store the colormap */
- source->colormap = (*cinfo->mem->alloc_sarray)
- ((j_common_ptr)cinfo, JPOOL_IMAGE, (JDIMENSION)MAXCOLORMAPSIZE,
- (JDIMENSION)NUMCOLORS);
- colormaplen = 0; /* indicate initialization */
-
- /* Read global colormap if header indicates it is present */
- if (BitSet(hdrbuf[4], COLORMAPFLAG)) {
- colormaplen = 2 << (hdrbuf[4] & 0x07);
- ReadColorMap(source, colormaplen, source->colormap);
- }
-
- /* Scan until we reach start of desired image.
- * We don't currently support skipping images, but could add it easily.
- */
- for (;;) {
- c = ReadByte(source);
-
- if (c == ';') /* GIF terminator?? */
- ERREXIT(cinfo, JERR_GIF_IMAGENOTFOUND);
-
- if (c == '!') { /* Extension */
- DoExtension(source);
- continue;
- }
-
- if (c != ',') { /* Not an image separator? */
- WARNMS1(cinfo, JWRN_GIF_CHAR, c);
- continue;
- }
-
- /* Read and decipher Local Image Descriptor */
- if (!ReadOK(source->pub.input_file, hdrbuf, 9))
- ERREXIT(cinfo, JERR_INPUT_EOF);
- /* we ignore top/left position info, also sort flag */
- width = LM_to_uint(hdrbuf, 4);
- height = LM_to_uint(hdrbuf, 6);
- if (width == 0 || height == 0)
- ERREXIT(cinfo, JERR_GIF_EMPTY);
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
- if (sinfo->max_pixels &&
- (unsigned long long)width * height > sinfo->max_pixels)
- ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
-#endif
- source->is_interlaced = (BitSet(hdrbuf[8], INTERLACE) != 0);
-
- /* Read local colormap if header indicates it is present */
- /* Note: if we wanted to support skipping images, */
- /* we'd need to skip rather than read colormap for ignored images */
- if (BitSet(hdrbuf[8], COLORMAPFLAG)) {
- colormaplen = 2 << (hdrbuf[8] & 0x07);
- ReadColorMap(source, colormaplen, source->colormap);
- }
-
- source->input_code_size = ReadByte(source); /* get min-code-size byte */
- if (source->input_code_size < 2 || source->input_code_size > 8)
- ERREXIT1(cinfo, JERR_GIF_CODESIZE, source->input_code_size);
-
- /* Reached desired image, so break out of loop */
- /* If we wanted to skip this image, */
- /* we'd call SkipDataBlocks and then continue the loop */
- break;
- }
-
- /* Prepare to read selected image: first initialize LZW decompressor */
- source->symbol_head = (UINT16 *)
- (*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- LZW_TABLE_SIZE * sizeof(UINT16));
- source->symbol_tail = (UINT8 *)
- (*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- LZW_TABLE_SIZE * sizeof(UINT8));
- source->symbol_stack = (UINT8 *)
- (*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- LZW_TABLE_SIZE * sizeof(UINT8));
- InitLZWCode(source);
-
- /*
- * If image is interlaced, we read it into a full-size sample array,
- * decompressing as we go; then get_interlaced_row selects rows from the
- * sample array in the proper order.
- */
- if (source->is_interlaced) {
- /* We request the virtual array now, but can't access it until virtual
- * arrays have been allocated. Hence, the actual work of reading the
- * image is postponed until the first call to get_pixel_rows.
- */
- source->interlaced_image = (*cinfo->mem->request_virt_sarray)
- ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE,
- (JDIMENSION)width, (JDIMENSION)height, (JDIMENSION)1);
- if (cinfo->progress != NULL) {
- cd_progress_ptr progress = (cd_progress_ptr)cinfo->progress;
- progress->total_extra_passes++; /* count file input as separate pass */
- }
- source->pub.get_pixel_rows = load_interlaced_image;
- } else {
- source->pub.get_pixel_rows = get_pixel_rows;
- }
-
- if (cinfo->in_color_space != JCS_GRAYSCALE) {
- cinfo->in_color_space = JCS_RGB;
- cinfo->input_components = NUMCOLORS;
- }
-
- /* Create compressor input buffer. */
- source->pub.buffer = (*cinfo->mem->alloc_sarray)
- ((j_common_ptr)cinfo, JPOOL_IMAGE,
- (JDIMENSION)width * cinfo->input_components, (JDIMENSION)1);
- source->pub.buffer_height = 1;
-
- /* Pad colormap for safety. */
- for (c = colormaplen; c < source->clear_code; c++) {
- source->colormap[CM_RED][c] =
- source->colormap[CM_GREEN][c] =
- source->colormap[CM_BLUE][c] = CENTERJSAMPLE;
- }
-
- /* Return info about the image. */
- cinfo->data_precision = BITS_IN_JSAMPLE; /* we always rescale data to this */
- cinfo->image_width = width;
- cinfo->image_height = height;
-
- TRACEMS3(cinfo, 1, JTRC_GIF, width, height, colormaplen);
-}
-
-
-/*
- * Read one row of pixels.
- * This version is used for noninterlaced GIF images:
- * we read directly from the GIF file.
- */
-
-METHODDEF(JDIMENSION)
-get_pixel_rows(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
-{
- gif_source_ptr source = (gif_source_ptr)sinfo;
- register int c;
- register JSAMPROW ptr;
- register JDIMENSION col;
- register JSAMPARRAY colormap = source->colormap;
-
- ptr = source->pub.buffer[0];
- if (cinfo->in_color_space == JCS_GRAYSCALE) {
- for (col = cinfo->image_width; col > 0; col--) {
- c = LZWReadByte(source);
- *ptr++ = colormap[CM_RED][c];
- }
- } else {
- for (col = cinfo->image_width; col > 0; col--) {
- c = LZWReadByte(source);
- *ptr++ = colormap[CM_RED][c];
- *ptr++ = colormap[CM_GREEN][c];
- *ptr++ = colormap[CM_BLUE][c];
- }
- }
- return 1;
-}
-
-
-/*
- * Read one row of pixels.
- * This version is used for the first call on get_pixel_rows when
- * reading an interlaced GIF file: we read the whole image into memory.
- */
-
-METHODDEF(JDIMENSION)
-load_interlaced_image(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
-{
- gif_source_ptr source = (gif_source_ptr)sinfo;
- register JSAMPROW sptr;
- register JDIMENSION col;
- JDIMENSION row;
- cd_progress_ptr progress = (cd_progress_ptr)cinfo->progress;
-
- /* Read the interlaced image into the virtual array we've created. */
- for (row = 0; row < cinfo->image_height; row++) {
- if (progress != NULL) {
- progress->pub.pass_counter = (long)row;
- progress->pub.pass_limit = (long)cinfo->image_height;
- (*progress->pub.progress_monitor) ((j_common_ptr)cinfo);
- }
- sptr = *(*cinfo->mem->access_virt_sarray)
- ((j_common_ptr)cinfo, source->interlaced_image, row, (JDIMENSION)1,
- TRUE);
- for (col = cinfo->image_width; col > 0; col--) {
- *sptr++ = (JSAMPLE)LZWReadByte(source);
- }
- }
- if (progress != NULL)
- progress->completed_extra_passes++;
-
- /* Replace method pointer so subsequent calls don't come here. */
- source->pub.get_pixel_rows = get_interlaced_row;
- /* Initialize for get_interlaced_row, and perform first call on it. */
- source->cur_row_number = 0;
- source->pass2_offset = (cinfo->image_height + 7) / 8;
- source->pass3_offset = source->pass2_offset + (cinfo->image_height + 3) / 8;
- source->pass4_offset = source->pass3_offset + (cinfo->image_height + 1) / 4;
-
- return get_interlaced_row(cinfo, sinfo);
-}
-
-
-/*
- * Read one row of pixels.
- * This version is used for interlaced GIF images:
- * we read from the virtual array.
- */
-
-METHODDEF(JDIMENSION)
-get_interlaced_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
-{
- gif_source_ptr source = (gif_source_ptr)sinfo;
- register int c;
- register JSAMPROW sptr, ptr;
- register JDIMENSION col;
- register JSAMPARRAY colormap = source->colormap;
- JDIMENSION irow;
-
- /* Figure out which row of interlaced image is needed, and access it. */
- switch ((int)(source->cur_row_number & 7)) {
- case 0: /* first-pass row */
- irow = source->cur_row_number >> 3;
- break;
- case 4: /* second-pass row */
- irow = (source->cur_row_number >> 3) + source->pass2_offset;
- break;
- case 2: /* third-pass row */
- case 6:
- irow = (source->cur_row_number >> 2) + source->pass3_offset;
- break;
- default: /* fourth-pass row */
- irow = (source->cur_row_number >> 1) + source->pass4_offset;
- }
- sptr = *(*cinfo->mem->access_virt_sarray)
- ((j_common_ptr)cinfo, source->interlaced_image, irow, (JDIMENSION)1,
- FALSE);
- /* Scan the row, expand colormap, and output */
- ptr = source->pub.buffer[0];
- if (cinfo->in_color_space == JCS_GRAYSCALE) {
- for (col = cinfo->image_width; col > 0; col--) {
- c = *sptr++;
- *ptr++ = colormap[CM_RED][c];
- }
- } else {
- for (col = cinfo->image_width; col > 0; col--) {
- c = *sptr++;
- *ptr++ = colormap[CM_RED][c];
- *ptr++ = colormap[CM_GREEN][c];
- *ptr++ = colormap[CM_BLUE][c];
- }
- }
- source->cur_row_number++; /* for next time */
- return 1;
-}
-
-
-/*
- * Finish up at the end of the file.
- */
-
-METHODDEF(void)
-finish_input_gif(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
-{
- /* no work */
-}
-
-
-/*
- * The module selection routine for GIF format input.
- */
-
-GLOBAL(cjpeg_source_ptr)
-jinit_read_gif(j_compress_ptr cinfo)
-{
- gif_source_ptr source;
-
- /* Create module interface object */
- source = (gif_source_ptr)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- sizeof(gif_source_struct));
- source->cinfo = cinfo; /* make back link for subroutines */
- /* Fill in method ptrs, except get_pixel_rows which start_input sets */
- source->pub.start_input = start_input_gif;
- source->pub.finish_input = finish_input_gif;
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
- source->pub.max_pixels = 0;
-#endif
-
- return (cjpeg_source_ptr)source;
-}
-
-#endif /* GIF_SUPPORTED */
diff --git a/contrib/libs/libjpeg-turbo/rdppm.c b/contrib/libs/libjpeg-turbo/rdppm.c
deleted file mode 100644
index 294749a41c..0000000000
--- a/contrib/libs/libjpeg-turbo/rdppm.c
+++ /dev/null
@@ -1,781 +0,0 @@
-/*
- * rdppm.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * Modified 2009 by Bill Allombert, Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2015-2017, 2020-2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains routines to read input images in PPM/PGM format.
- * The extended 2-byte-per-sample raw PPM/PGM formats are supported.
- * The PBMPLUS library is NOT required to compile this software
- * (but it is highly useful as a set of PPM image manipulation programs).
- *
- * These routines may need modification for non-Unix environments or
- * specialized applications. As they stand, they assume input from
- * an ordinary stdio stream. They further assume that reading begins
- * at the start of the file; start_input may need work if the
- * user interface has already read some data (e.g., to determine that
- * the file is indeed PPM format).
- */
-
-#include "cmyk.h"
-#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
-
-#ifdef PPM_SUPPORTED
-
-
-/* Portions of this code are based on the PBMPLUS library, which is:
-**
-** Copyright (C) 1988 by Jef Poskanzer.
-**
-** Permission to use, copy, modify, and distribute this software and its
-** documentation for any purpose and without fee is hereby granted, provided
-** that the above copyright notice appear in all copies and that both that
-** copyright notice and this permission notice appear in supporting
-** documentation. This software is provided "as is" without express or
-** implied warranty.
-*/
-
-
-/* Macros to deal with unsigned chars as efficiently as compiler allows */
-
-typedef unsigned char U_CHAR;
-#define UCH(x) ((int)(x))
-
-
-#define ReadOK(file, buffer, len) \
- (fread(buffer, 1, len, file) == ((size_t)(len)))
-
-static int alpha_index[JPEG_NUMCS] = {
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, 3, 0, 0, -1
-};
-
-
-/* Private version of data source object */
-
-typedef struct {
- struct cjpeg_source_struct pub; /* public fields */
-
- /* Usually these two pointers point to the same place: */
- U_CHAR *iobuffer; /* fread's I/O buffer */
- JSAMPROW pixrow; /* compressor input buffer */
- size_t buffer_width; /* width of I/O buffer */
- JSAMPLE *rescale; /* => maxval-remapping array, or NULL */
- unsigned int maxval;
-} ppm_source_struct;
-
-typedef ppm_source_struct *ppm_source_ptr;
-
-
-LOCAL(int)
-pbm_getc(FILE *infile)
-/* Read next char, skipping over any comments */
-/* A comment/newline sequence is returned as a newline */
-{
- register int ch;
-
- ch = getc(infile);
- if (ch == '#') {
- do {
- ch = getc(infile);
- } while (ch != '\n' && ch != EOF);
- }
- return ch;
-}
-
-
-LOCAL(unsigned int)
-read_pbm_integer(j_compress_ptr cinfo, FILE *infile, unsigned int maxval)
-/* Read an unsigned decimal integer from the PPM file */
-/* Swallows one trailing character after the integer */
-/* Note that on a 16-bit-int machine, only values up to 64k can be read. */
-/* This should not be a problem in practice. */
-{
- register int ch;
- register unsigned int val;
-
- /* Skip any leading whitespace */
- do {
- ch = pbm_getc(infile);
- if (ch == EOF)
- ERREXIT(cinfo, JERR_INPUT_EOF);
- } while (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r');
-
- if (ch < '0' || ch > '9')
- ERREXIT(cinfo, JERR_PPM_NONNUMERIC);
-
- val = ch - '0';
- while ((ch = pbm_getc(infile)) >= '0' && ch <= '9') {
- val *= 10;
- val += ch - '0';
- if (val > maxval)
- ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
- }
-
- return val;
-}
-
-
-/*
- * Read one row of pixels.
- *
- * We provide several different versions depending on input file format.
- * In all cases, input is scaled to the size of JSAMPLE.
- *
- * A really fast path is provided for reading byte/sample raw files with
- * maxval = MAXJSAMPLE, which is the normal case for 8-bit data.
- */
-
-
-METHODDEF(JDIMENSION)
-get_text_gray_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
-/* This version is for reading text-format PGM files with any maxval */
-{
- ppm_source_ptr source = (ppm_source_ptr)sinfo;
- FILE *infile = source->pub.input_file;
- register JSAMPROW ptr;
- register JSAMPLE *rescale = source->rescale;
- JDIMENSION col;
- unsigned int maxval = source->maxval;
-
- ptr = source->pub.buffer[0];
- for (col = cinfo->image_width; col > 0; col--) {
- *ptr++ = rescale[read_pbm_integer(cinfo, infile, maxval)];
- }
- return 1;
-}
-
-
-#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op) { \
- for (col = cinfo->image_width; col > 0; col--) { \
- ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
- alpha_set_op \
- ptr += ps; \
- } \
-}
-
-METHODDEF(JDIMENSION)
-get_text_gray_rgb_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
-/* This version is for reading text-format PGM files with any maxval and
- converting to extended RGB */
-{
- ppm_source_ptr source = (ppm_source_ptr)sinfo;
- FILE *infile = source->pub.input_file;
- register JSAMPROW ptr;
- register JSAMPLE *rescale = source->rescale;
- JDIMENSION col;
- unsigned int maxval = source->maxval;
- register int rindex = rgb_red[cinfo->in_color_space];
- register int gindex = rgb_green[cinfo->in_color_space];
- register int bindex = rgb_blue[cinfo->in_color_space];
- register int aindex = alpha_index[cinfo->in_color_space];
- register int ps = rgb_pixelsize[cinfo->in_color_space];
-
- ptr = source->pub.buffer[0];
- if (maxval == MAXJSAMPLE) {
- if (aindex >= 0)
- GRAY_RGB_READ_LOOP((JSAMPLE)read_pbm_integer(cinfo, infile, maxval),
- ptr[aindex] = 0xFF;)
- else
- GRAY_RGB_READ_LOOP((JSAMPLE)read_pbm_integer(cinfo, infile, maxval), {})
- } else {
- if (aindex >= 0)
- GRAY_RGB_READ_LOOP(rescale[read_pbm_integer(cinfo, infile, maxval)],
- ptr[aindex] = 0xFF;)
- else
- GRAY_RGB_READ_LOOP(rescale[read_pbm_integer(cinfo, infile, maxval)], {})
- }
- return 1;
-}
-
-
-METHODDEF(JDIMENSION)
-get_text_gray_cmyk_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
-/* This version is for reading text-format PGM files with any maxval and
- converting to CMYK */
-{
- ppm_source_ptr source = (ppm_source_ptr)sinfo;
- FILE *infile = source->pub.input_file;
- register JSAMPROW ptr;
- register JSAMPLE *rescale = source->rescale;
- JDIMENSION col;
- unsigned int maxval = source->maxval;
-
- ptr = source->pub.buffer[0];
- if (maxval == MAXJSAMPLE) {
- for (col = cinfo->image_width; col > 0; col--) {
- JSAMPLE gray = (JSAMPLE)read_pbm_integer(cinfo, infile, maxval);
- rgb_to_cmyk(gray, gray, gray, ptr, ptr + 1, ptr + 2, ptr + 3);
- ptr += 4;
- }
- } else {
- for (col = cinfo->image_width; col > 0; col--) {
- JSAMPLE gray = rescale[read_pbm_integer(cinfo, infile, maxval)];
- rgb_to_cmyk(gray, gray, gray, ptr, ptr + 1, ptr + 2, ptr + 3);
- ptr += 4;
- }
- }
- return 1;
-}
-
-
-#define RGB_READ_LOOP(read_op, alpha_set_op) { \
- for (col = cinfo->image_width; col > 0; col--) { \
- ptr[rindex] = read_op; \
- ptr[gindex] = read_op; \
- ptr[bindex] = read_op; \
- alpha_set_op \
- ptr += ps; \
- } \
-}
-
-METHODDEF(JDIMENSION)
-get_text_rgb_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
-/* This version is for reading text-format PPM files with any maxval */
-{
- ppm_source_ptr source = (ppm_source_ptr)sinfo;
- FILE *infile = source->pub.input_file;
- register JSAMPROW ptr;
- register JSAMPLE *rescale = source->rescale;
- JDIMENSION col;
- unsigned int maxval = source->maxval;
- register int rindex = rgb_red[cinfo->in_color_space];
- register int gindex = rgb_green[cinfo->in_color_space];
- register int bindex = rgb_blue[cinfo->in_color_space];
- register int aindex = alpha_index[cinfo->in_color_space];
- register int ps = rgb_pixelsize[cinfo->in_color_space];
-
- ptr = source->pub.buffer[0];
- if (maxval == MAXJSAMPLE) {
- if (aindex >= 0)
- RGB_READ_LOOP((JSAMPLE)read_pbm_integer(cinfo, infile, maxval),
- ptr[aindex] = 0xFF;)
- else
- RGB_READ_LOOP((JSAMPLE)read_pbm_integer(cinfo, infile, maxval), {})
- } else {
- if (aindex >= 0)
- RGB_READ_LOOP(rescale[read_pbm_integer(cinfo, infile, maxval)],
- ptr[aindex] = 0xFF;)
- else
- RGB_READ_LOOP(rescale[read_pbm_integer(cinfo, infile, maxval)], {})
- }
- return 1;
-}
-
-
-METHODDEF(JDIMENSION)
-get_text_rgb_cmyk_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
-/* This version is for reading text-format PPM files with any maxval and
- converting to CMYK */
-{
- ppm_source_ptr source = (ppm_source_ptr)sinfo;
- FILE *infile = source->pub.input_file;
- register JSAMPROW ptr;
- register JSAMPLE *rescale = source->rescale;
- JDIMENSION col;
- unsigned int maxval = source->maxval;
-
- ptr = source->pub.buffer[0];
- if (maxval == MAXJSAMPLE) {
- for (col = cinfo->image_width; col > 0; col--) {
- JSAMPLE r = (JSAMPLE)read_pbm_integer(cinfo, infile, maxval);
- JSAMPLE g = (JSAMPLE)read_pbm_integer(cinfo, infile, maxval);
- JSAMPLE b = (JSAMPLE)read_pbm_integer(cinfo, infile, maxval);
- rgb_to_cmyk(r, g, b, ptr, ptr + 1, ptr + 2, ptr + 3);
- ptr += 4;
- }
- } else {
- for (col = cinfo->image_width; col > 0; col--) {
- JSAMPLE r = rescale[read_pbm_integer(cinfo, infile, maxval)];
- JSAMPLE g = rescale[read_pbm_integer(cinfo, infile, maxval)];
- JSAMPLE b = rescale[read_pbm_integer(cinfo, infile, maxval)];
- rgb_to_cmyk(r, g, b, ptr, ptr + 1, ptr + 2, ptr + 3);
- ptr += 4;
- }
- }
- return 1;
-}
-
-
-METHODDEF(JDIMENSION)
-get_scaled_gray_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
-/* This version is for reading raw-byte-format PGM files with any maxval */
-{
- ppm_source_ptr source = (ppm_source_ptr)sinfo;
- register JSAMPROW ptr;
- register U_CHAR *bufferptr;
- register JSAMPLE *rescale = source->rescale;
- JDIMENSION col;
-
- if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
- ERREXIT(cinfo, JERR_INPUT_EOF);
- ptr = source->pub.buffer[0];
- bufferptr = source->iobuffer;
- for (col = cinfo->image_width; col > 0; col--) {
- *ptr++ = rescale[UCH(*bufferptr++)];
- }
- return 1;
-}
-
-
-METHODDEF(JDIMENSION)
-get_gray_rgb_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
-/* This version is for reading raw-byte-format PGM files with any maxval
- and converting to extended RGB */
-{
- ppm_source_ptr source = (ppm_source_ptr)sinfo;
- register JSAMPROW ptr;
- register U_CHAR *bufferptr;
- register JSAMPLE *rescale = source->rescale;
- JDIMENSION col;
- unsigned int maxval = source->maxval;
- register int rindex = rgb_red[cinfo->in_color_space];
- register int gindex = rgb_green[cinfo->in_color_space];
- register int bindex = rgb_blue[cinfo->in_color_space];
- register int aindex = alpha_index[cinfo->in_color_space];
- register int ps = rgb_pixelsize[cinfo->in_color_space];
-
- if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
- ERREXIT(cinfo, JERR_INPUT_EOF);
- ptr = source->pub.buffer[0];
- bufferptr = source->iobuffer;
- if (maxval == MAXJSAMPLE) {
- if (aindex >= 0)
- GRAY_RGB_READ_LOOP(*bufferptr++, ptr[aindex] = 0xFF;)
- else
- GRAY_RGB_READ_LOOP(*bufferptr++, {})
- } else {
- if (aindex >= 0)
- GRAY_RGB_READ_LOOP(rescale[UCH(*bufferptr++)], ptr[aindex] = 0xFF;)
- else
- GRAY_RGB_READ_LOOP(rescale[UCH(*bufferptr++)], {})
- }
- return 1;
-}
-
-
-METHODDEF(JDIMENSION)
-get_gray_cmyk_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
-/* This version is for reading raw-byte-format PGM files with any maxval
- and converting to CMYK */
-{
- ppm_source_ptr source = (ppm_source_ptr)sinfo;
- register JSAMPROW ptr;
- register U_CHAR *bufferptr;
- register JSAMPLE *rescale = source->rescale;
- JDIMENSION col;
- unsigned int maxval = source->maxval;
-
- if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
- ERREXIT(cinfo, JERR_INPUT_EOF);
- ptr = source->pub.buffer[0];
- bufferptr = source->iobuffer;
- if (maxval == MAXJSAMPLE) {
- for (col = cinfo->image_width; col > 0; col--) {
- JSAMPLE gray = *bufferptr++;
- rgb_to_cmyk(gray, gray, gray, ptr, ptr + 1, ptr + 2, ptr + 3);
- ptr += 4;
- }
- } else {
- for (col = cinfo->image_width; col > 0; col--) {
- JSAMPLE gray = rescale[UCH(*bufferptr++)];
- rgb_to_cmyk(gray, gray, gray, ptr, ptr + 1, ptr + 2, ptr + 3);
- ptr += 4;
- }
- }
- return 1;
-}
-
-
-METHODDEF(JDIMENSION)
-get_rgb_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
-/* This version is for reading raw-byte-format PPM files with any maxval */
-{
- ppm_source_ptr source = (ppm_source_ptr)sinfo;
- register JSAMPROW ptr;
- register U_CHAR *bufferptr;
- register JSAMPLE *rescale = source->rescale;
- JDIMENSION col;
- unsigned int maxval = source->maxval;
- register int rindex = rgb_red[cinfo->in_color_space];
- register int gindex = rgb_green[cinfo->in_color_space];
- register int bindex = rgb_blue[cinfo->in_color_space];
- register int aindex = alpha_index[cinfo->in_color_space];
- register int ps = rgb_pixelsize[cinfo->in_color_space];
-
- if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
- ERREXIT(cinfo, JERR_INPUT_EOF);
- ptr = source->pub.buffer[0];
- bufferptr = source->iobuffer;
- if (maxval == MAXJSAMPLE) {
- if (aindex >= 0)
- RGB_READ_LOOP(*bufferptr++, ptr[aindex] = 0xFF;)
- else
- RGB_READ_LOOP(*bufferptr++, {})
- } else {
- if (aindex >= 0)
- RGB_READ_LOOP(rescale[UCH(*bufferptr++)], ptr[aindex] = 0xFF;)
- else
- RGB_READ_LOOP(rescale[UCH(*bufferptr++)], {})
- }
- return 1;
-}
-
-
-METHODDEF(JDIMENSION)
-get_rgb_cmyk_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
-/* This version is for reading raw-byte-format PPM files with any maxval and
- converting to CMYK */
-{
- ppm_source_ptr source = (ppm_source_ptr)sinfo;
- register JSAMPROW ptr;
- register U_CHAR *bufferptr;
- register JSAMPLE *rescale = source->rescale;
- JDIMENSION col;
- unsigned int maxval = source->maxval;
-
- if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
- ERREXIT(cinfo, JERR_INPUT_EOF);
- ptr = source->pub.buffer[0];
- bufferptr = source->iobuffer;
- if (maxval == MAXJSAMPLE) {
- for (col = cinfo->image_width; col > 0; col--) {
- JSAMPLE r = *bufferptr++;
- JSAMPLE g = *bufferptr++;
- JSAMPLE b = *bufferptr++;
- rgb_to_cmyk(r, g, b, ptr, ptr + 1, ptr + 2, ptr + 3);
- ptr += 4;
- }
- } else {
- for (col = cinfo->image_width; col > 0; col--) {
- JSAMPLE r = rescale[UCH(*bufferptr++)];
- JSAMPLE g = rescale[UCH(*bufferptr++)];
- JSAMPLE b = rescale[UCH(*bufferptr++)];
- rgb_to_cmyk(r, g, b, ptr, ptr + 1, ptr + 2, ptr + 3);
- ptr += 4;
- }
- }
- return 1;
-}
-
-
-METHODDEF(JDIMENSION)
-get_raw_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
-/* This version is for reading raw-byte-format files with maxval = MAXJSAMPLE.
- * In this case we just read right into the JSAMPLE buffer!
- * Note that same code works for PPM and PGM files.
- */
-{
- ppm_source_ptr source = (ppm_source_ptr)sinfo;
-
- if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
- ERREXIT(cinfo, JERR_INPUT_EOF);
- return 1;
-}
-
-
-METHODDEF(JDIMENSION)
-get_word_gray_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
-/* This version is for reading raw-word-format PGM files with any maxval */
-{
- ppm_source_ptr source = (ppm_source_ptr)sinfo;
- register JSAMPROW ptr;
- register U_CHAR *bufferptr;
- register JSAMPLE *rescale = source->rescale;
- JDIMENSION col;
- unsigned int maxval = source->maxval;
-
- if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
- ERREXIT(cinfo, JERR_INPUT_EOF);
- ptr = source->pub.buffer[0];
- bufferptr = source->iobuffer;
- for (col = cinfo->image_width; col > 0; col--) {
- register unsigned int temp;
- temp = UCH(*bufferptr++) << 8;
- temp |= UCH(*bufferptr++);
- if (temp > maxval)
- ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
- *ptr++ = rescale[temp];
- }
- return 1;
-}
-
-
-METHODDEF(JDIMENSION)
-get_word_rgb_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
-/* This version is for reading raw-word-format PPM files with any maxval */
-{
- ppm_source_ptr source = (ppm_source_ptr)sinfo;
- register JSAMPROW ptr;
- register U_CHAR *bufferptr;
- register JSAMPLE *rescale = source->rescale;
- JDIMENSION col;
- unsigned int maxval = source->maxval;
- register int rindex = rgb_red[cinfo->in_color_space];
- register int gindex = rgb_green[cinfo->in_color_space];
- register int bindex = rgb_blue[cinfo->in_color_space];
- register int aindex = alpha_index[cinfo->in_color_space];
- register int ps = rgb_pixelsize[cinfo->in_color_space];
-
- if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
- ERREXIT(cinfo, JERR_INPUT_EOF);
- ptr = source->pub.buffer[0];
- bufferptr = source->iobuffer;
- for (col = cinfo->image_width; col > 0; col--) {
- register unsigned int temp;
- temp = UCH(*bufferptr++) << 8;
- temp |= UCH(*bufferptr++);
- if (temp > maxval)
- ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
- ptr[rindex] = rescale[temp];
- temp = UCH(*bufferptr++) << 8;
- temp |= UCH(*bufferptr++);
- if (temp > maxval)
- ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
- ptr[gindex] = rescale[temp];
- temp = UCH(*bufferptr++) << 8;
- temp |= UCH(*bufferptr++);
- if (temp > maxval)
- ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
- ptr[bindex] = rescale[temp];
- if (aindex >= 0)
- ptr[aindex] = 0xFF;
- ptr += ps;
- }
- return 1;
-}
-
-
-/*
- * Read the file header; return image size and component count.
- */
-
-METHODDEF(void)
-start_input_ppm(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
-{
- ppm_source_ptr source = (ppm_source_ptr)sinfo;
- int c;
- unsigned int w, h, maxval;
- boolean need_iobuffer, use_raw_buffer, need_rescale;
-
- if (getc(source->pub.input_file) != 'P')
- ERREXIT(cinfo, JERR_PPM_NOT);
-
- c = getc(source->pub.input_file); /* subformat discriminator character */
-
- /* detect unsupported variants (ie, PBM) before trying to read header */
- switch (c) {
- case '2': /* it's a text-format PGM file */
- case '3': /* it's a text-format PPM file */
- case '5': /* it's a raw-format PGM file */
- case '6': /* it's a raw-format PPM file */
- break;
- default:
- ERREXIT(cinfo, JERR_PPM_NOT);
- break;
- }
-
- /* fetch the remaining header info */
- w = read_pbm_integer(cinfo, source->pub.input_file, 65535);
- h = read_pbm_integer(cinfo, source->pub.input_file, 65535);
- maxval = read_pbm_integer(cinfo, source->pub.input_file, 65535);
-
- if (w <= 0 || h <= 0 || maxval <= 0) /* error check */
- ERREXIT(cinfo, JERR_PPM_NOT);
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
- if (sinfo->max_pixels && (unsigned long long)w * h > sinfo->max_pixels)
- ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
-#endif
-
- cinfo->data_precision = BITS_IN_JSAMPLE; /* we always rescale data to this */
- cinfo->image_width = (JDIMENSION)w;
- cinfo->image_height = (JDIMENSION)h;
- source->maxval = maxval;
-
- /* initialize flags to most common settings */
- need_iobuffer = TRUE; /* do we need an I/O buffer? */
- use_raw_buffer = FALSE; /* do we map input buffer onto I/O buffer? */
- need_rescale = TRUE; /* do we need a rescale array? */
-
- switch (c) {
- case '2': /* it's a text-format PGM file */
- if (cinfo->in_color_space == JCS_UNKNOWN ||
- cinfo->in_color_space == JCS_RGB)
- cinfo->in_color_space = JCS_GRAYSCALE;
- TRACEMS2(cinfo, 1, JTRC_PGM_TEXT, w, h);
- if (cinfo->in_color_space == JCS_GRAYSCALE)
- source->pub.get_pixel_rows = get_text_gray_row;
- else if (IsExtRGB(cinfo->in_color_space))
- source->pub.get_pixel_rows = get_text_gray_rgb_row;
- else if (cinfo->in_color_space == JCS_CMYK)
- source->pub.get_pixel_rows = get_text_gray_cmyk_row;
- else
- ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
- need_iobuffer = FALSE;
- break;
-
- case '3': /* it's a text-format PPM file */
- if (cinfo->in_color_space == JCS_UNKNOWN)
- cinfo->in_color_space = JCS_EXT_RGB;
- TRACEMS2(cinfo, 1, JTRC_PPM_TEXT, w, h);
- if (IsExtRGB(cinfo->in_color_space))
- source->pub.get_pixel_rows = get_text_rgb_row;
- else if (cinfo->in_color_space == JCS_CMYK)
- source->pub.get_pixel_rows = get_text_rgb_cmyk_row;
- else
- ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
- need_iobuffer = FALSE;
- break;
-
- case '5': /* it's a raw-format PGM file */
- if (cinfo->in_color_space == JCS_UNKNOWN ||
- cinfo->in_color_space == JCS_RGB)
- cinfo->in_color_space = JCS_GRAYSCALE;
- TRACEMS2(cinfo, 1, JTRC_PGM, w, h);
- if (maxval > 255) {
- if (cinfo->in_color_space == JCS_GRAYSCALE)
- source->pub.get_pixel_rows = get_word_gray_row;
- else
- ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
- } else if (maxval == MAXJSAMPLE && sizeof(JSAMPLE) == sizeof(U_CHAR) &&
- cinfo->in_color_space == JCS_GRAYSCALE) {
- source->pub.get_pixel_rows = get_raw_row;
- use_raw_buffer = TRUE;
- need_rescale = FALSE;
- } else {
- if (cinfo->in_color_space == JCS_GRAYSCALE)
- source->pub.get_pixel_rows = get_scaled_gray_row;
- else if (IsExtRGB(cinfo->in_color_space))
- source->pub.get_pixel_rows = get_gray_rgb_row;
- else if (cinfo->in_color_space == JCS_CMYK)
- source->pub.get_pixel_rows = get_gray_cmyk_row;
- else
- ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
- }
- break;
-
- case '6': /* it's a raw-format PPM file */
- if (cinfo->in_color_space == JCS_UNKNOWN)
- cinfo->in_color_space = JCS_EXT_RGB;
- TRACEMS2(cinfo, 1, JTRC_PPM, w, h);
- if (maxval > 255) {
- if (IsExtRGB(cinfo->in_color_space))
- source->pub.get_pixel_rows = get_word_rgb_row;
- else
- ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
- } else if (maxval == MAXJSAMPLE && sizeof(JSAMPLE) == sizeof(U_CHAR) &&
-#if RGB_RED == 0 && RGB_GREEN == 1 && RGB_BLUE == 2 && RGB_PIXELSIZE == 3
- (cinfo->in_color_space == JCS_EXT_RGB ||
- cinfo->in_color_space == JCS_RGB)) {
-#else
- cinfo->in_color_space == JCS_EXT_RGB) {
-#endif
- source->pub.get_pixel_rows = get_raw_row;
- use_raw_buffer = TRUE;
- need_rescale = FALSE;
- } else {
- if (IsExtRGB(cinfo->in_color_space))
- source->pub.get_pixel_rows = get_rgb_row;
- else if (cinfo->in_color_space == JCS_CMYK)
- source->pub.get_pixel_rows = get_rgb_cmyk_row;
- else
- ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
- }
- break;
- }
-
- if (IsExtRGB(cinfo->in_color_space))
- cinfo->input_components = rgb_pixelsize[cinfo->in_color_space];
- else if (cinfo->in_color_space == JCS_GRAYSCALE)
- cinfo->input_components = 1;
- else if (cinfo->in_color_space == JCS_CMYK)
- cinfo->input_components = 4;
-
- /* Allocate space for I/O buffer: 1 or 3 bytes or words/pixel. */
- if (need_iobuffer) {
- if (c == '6')
- source->buffer_width = (size_t)w * 3 *
- ((maxval <= 255) ? sizeof(U_CHAR) : (2 * sizeof(U_CHAR)));
- else
- source->buffer_width = (size_t)w *
- ((maxval <= 255) ? sizeof(U_CHAR) : (2 * sizeof(U_CHAR)));
- source->iobuffer = (U_CHAR *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- source->buffer_width);
- }
-
- /* Create compressor input buffer. */
- if (use_raw_buffer) {
- /* For unscaled raw-input case, we can just map it onto the I/O buffer. */
- /* Synthesize a JSAMPARRAY pointer structure */
- source->pixrow = (JSAMPROW)source->iobuffer;
- source->pub.buffer = &source->pixrow;
- source->pub.buffer_height = 1;
- } else {
- /* Need to translate anyway, so make a separate sample buffer. */
- source->pub.buffer = (*cinfo->mem->alloc_sarray)
- ((j_common_ptr)cinfo, JPOOL_IMAGE,
- (JDIMENSION)w * cinfo->input_components, (JDIMENSION)1);
- source->pub.buffer_height = 1;
- }
-
- /* Compute the rescaling array if required. */
- if (need_rescale) {
- long val, half_maxval;
-
- /* On 16-bit-int machines we have to be careful of maxval = 65535 */
- source->rescale = (JSAMPLE *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- (size_t)(((long)MAX(maxval, 255) + 1L) *
- sizeof(JSAMPLE)));
- memset(source->rescale, 0, (size_t)(((long)MAX(maxval, 255) + 1L) *
- sizeof(JSAMPLE)));
- half_maxval = maxval / 2;
- for (val = 0; val <= (long)maxval; val++) {
- /* The multiplication here must be done in 32 bits to avoid overflow */
- source->rescale[val] = (JSAMPLE)((val * MAXJSAMPLE + half_maxval) /
- maxval);
- }
- }
-}
-
-
-/*
- * Finish up at the end of the file.
- */
-
-METHODDEF(void)
-finish_input_ppm(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
-{
- /* no work */
-}
-
-
-/*
- * The module selection routine for PPM format input.
- */
-
-GLOBAL(cjpeg_source_ptr)
-jinit_read_ppm(j_compress_ptr cinfo)
-{
- ppm_source_ptr source;
-
- /* Create module interface object */
- source = (ppm_source_ptr)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- sizeof(ppm_source_struct));
- /* Fill in method ptrs, except get_pixel_rows which start_input sets */
- source->pub.start_input = start_input_ppm;
- source->pub.finish_input = finish_input_ppm;
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
- source->pub.max_pixels = 0;
-#endif
-
- return (cjpeg_source_ptr)source;
-}
-
-#endif /* PPM_SUPPORTED */
diff --git a/contrib/libs/libjpeg-turbo/rdswitch.c b/contrib/libs/libjpeg-turbo/rdswitch.c
deleted file mode 100644
index 33449c86ba..0000000000
--- a/contrib/libs/libjpeg-turbo/rdswitch.c
+++ /dev/null
@@ -1,428 +0,0 @@
-/*
- * rdswitch.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1996, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2018, 2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains routines to process some of cjpeg's more complicated
- * command-line switches. Switches processed here are:
- * -qtables file Read quantization tables from text file
- * -scans file Read scan script from text file
- * -quality N[,N,...] Set quality ratings
- * -qslots N[,N,...] Set component quantization table selectors
- * -sample HxV[,HxV,...] Set component sampling factors
- */
-
-#ifdef _MSC_VER
-#define _CRT_SECURE_NO_DEPRECATE
-#endif
-
-#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
-#include <ctype.h> /* to declare isdigit(), isspace() */
-
-
-LOCAL(int)
-text_getc(FILE *file)
-/* Read next char, skipping over any comments (# to end of line) */
-/* A comment/newline sequence is returned as a newline */
-{
- register int ch;
-
- ch = getc(file);
- if (ch == '#') {
- do {
- ch = getc(file);
- } while (ch != '\n' && ch != EOF);
- }
- return ch;
-}
-
-
-LOCAL(boolean)
-read_text_integer(FILE *file, long *result, int *termchar)
-/* Read an unsigned decimal integer from a file, store it in result */
-/* Reads one trailing character after the integer; returns it in termchar */
-{
- register int ch;
- register long val;
-
- /* Skip any leading whitespace, detect EOF */
- do {
- ch = text_getc(file);
- if (ch == EOF) {
- *termchar = ch;
- return FALSE;
- }
- } while (isspace(ch));
-
- if (!isdigit(ch)) {
- *termchar = ch;
- return FALSE;
- }
-
- val = ch - '0';
- while ((ch = text_getc(file)) != EOF) {
- if (!isdigit(ch))
- break;
- val *= 10;
- val += ch - '0';
- }
- *result = val;
- *termchar = ch;
- return TRUE;
-}
-
-
-#if JPEG_LIB_VERSION < 70
-static int q_scale_factor[NUM_QUANT_TBLS] = { 100, 100, 100, 100 };
-#endif
-
-GLOBAL(boolean)
-read_quant_tables(j_compress_ptr cinfo, char *filename, boolean force_baseline)
-/* Read a set of quantization tables from the specified file.
- * The file is plain ASCII text: decimal numbers with whitespace between.
- * Comments preceded by '#' may be included in the file.
- * There may be one to NUM_QUANT_TBLS tables in the file, each of 64 values.
- * The tables are implicitly numbered 0,1,etc.
- * NOTE: does not affect the qslots mapping, which will default to selecting
- * table 0 for luminance (or primary) components, 1 for chrominance components.
- * You must use -qslots if you want a different component->table mapping.
- */
-{
- FILE *fp;
- int tblno, i, termchar;
- long val;
- unsigned int table[DCTSIZE2];
-
- if ((fp = fopen(filename, "r")) == NULL) {
- fprintf(stderr, "Can't open table file %s\n", filename);
- return FALSE;
- }
- tblno = 0;
-
- while (read_text_integer(fp, &val, &termchar)) { /* read 1st element of table */
- if (tblno >= NUM_QUANT_TBLS) {
- fprintf(stderr, "Too many tables in file %s\n", filename);
- fclose(fp);
- return FALSE;
- }
- table[0] = (unsigned int)val;
- for (i = 1; i < DCTSIZE2; i++) {
- if (!read_text_integer(fp, &val, &termchar)) {
- fprintf(stderr, "Invalid table data in file %s\n", filename);
- fclose(fp);
- return FALSE;
- }
- table[i] = (unsigned int)val;
- }
-#if JPEG_LIB_VERSION >= 70
- jpeg_add_quant_table(cinfo, tblno, table, cinfo->q_scale_factor[tblno],
- force_baseline);
-#else
- jpeg_add_quant_table(cinfo, tblno, table, q_scale_factor[tblno],
- force_baseline);
-#endif
- tblno++;
- }
-
- if (termchar != EOF) {
- fprintf(stderr, "Non-numeric data in file %s\n", filename);
- fclose(fp);
- return FALSE;
- }
-
- fclose(fp);
- return TRUE;
-}
-
-
-#ifdef C_MULTISCAN_FILES_SUPPORTED
-
-LOCAL(boolean)
-read_scan_integer(FILE *file, long *result, int *termchar)
-/* Variant of read_text_integer that always looks for a non-space termchar;
- * this simplifies parsing of punctuation in scan scripts.
- */
-{
- register int ch;
-
- if (!read_text_integer(file, result, termchar))
- return FALSE;
- ch = *termchar;
- while (ch != EOF && isspace(ch))
- ch = text_getc(file);
- if (isdigit(ch)) { /* oops, put it back */
- if (ungetc(ch, file) == EOF)
- return FALSE;
- ch = ' ';
- } else {
- /* Any separators other than ';' and ':' are ignored;
- * this allows user to insert commas, etc, if desired.
- */
- if (ch != EOF && ch != ';' && ch != ':')
- ch = ' ';
- }
- *termchar = ch;
- return TRUE;
-}
-
-
-GLOBAL(boolean)
-read_scan_script(j_compress_ptr cinfo, char *filename)
-/* Read a scan script from the specified text file.
- * Each entry in the file defines one scan to be emitted.
- * Entries are separated by semicolons ';'.
- * An entry contains one to four component indexes,
- * optionally followed by a colon ':' and four progressive-JPEG parameters.
- * The component indexes denote which component(s) are to be transmitted
- * in the current scan. The first component has index 0.
- * Sequential JPEG is used if the progressive-JPEG parameters are omitted.
- * The file is free format text: any whitespace may appear between numbers
- * and the ':' and ';' punctuation marks. Also, other punctuation (such
- * as commas or dashes) can be placed between numbers if desired.
- * Comments preceded by '#' may be included in the file.
- * Note: we do very little validity checking here;
- * jcmaster.c will validate the script parameters.
- */
-{
- FILE *fp;
- int scanno, ncomps, termchar;
- long val;
- jpeg_scan_info *scanptr;
-#define MAX_SCANS 100 /* quite arbitrary limit */
- jpeg_scan_info scans[MAX_SCANS];
-
- if ((fp = fopen(filename, "r")) == NULL) {
- fprintf(stderr, "Can't open scan definition file %s\n", filename);
- return FALSE;
- }
- scanptr = scans;
- scanno = 0;
-
- while (read_scan_integer(fp, &val, &termchar)) {
- if (scanno >= MAX_SCANS) {
- fprintf(stderr, "Too many scans defined in file %s\n", filename);
- fclose(fp);
- return FALSE;
- }
- scanptr->component_index[0] = (int)val;
- ncomps = 1;
- while (termchar == ' ') {
- if (ncomps >= MAX_COMPS_IN_SCAN) {
- fprintf(stderr, "Too many components in one scan in file %s\n",
- filename);
- fclose(fp);
- return FALSE;
- }
- if (!read_scan_integer(fp, &val, &termchar))
- goto bogus;
- scanptr->component_index[ncomps] = (int)val;
- ncomps++;
- }
- scanptr->comps_in_scan = ncomps;
- if (termchar == ':') {
- if (!read_scan_integer(fp, &val, &termchar) || termchar != ' ')
- goto bogus;
- scanptr->Ss = (int)val;
- if (!read_scan_integer(fp, &val, &termchar) || termchar != ' ')
- goto bogus;
- scanptr->Se = (int)val;
- if (!read_scan_integer(fp, &val, &termchar) || termchar != ' ')
- goto bogus;
- scanptr->Ah = (int)val;
- if (!read_scan_integer(fp, &val, &termchar))
- goto bogus;
- scanptr->Al = (int)val;
- } else {
- /* set non-progressive parameters */
- scanptr->Ss = 0;
- scanptr->Se = DCTSIZE2 - 1;
- scanptr->Ah = 0;
- scanptr->Al = 0;
- }
- if (termchar != ';' && termchar != EOF) {
-bogus:
- fprintf(stderr, "Invalid scan entry format in file %s\n", filename);
- fclose(fp);
- return FALSE;
- }
- scanptr++, scanno++;
- }
-
- if (termchar != EOF) {
- fprintf(stderr, "Non-numeric data in file %s\n", filename);
- fclose(fp);
- return FALSE;
- }
-
- if (scanno > 0) {
- /* Stash completed scan list in cinfo structure.
- * NOTE: for cjpeg's use, JPOOL_IMAGE is the right lifetime for this data,
- * but if you want to compress multiple images you'd want JPOOL_PERMANENT.
- */
- scanptr = (jpeg_scan_info *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- scanno * sizeof(jpeg_scan_info));
- memcpy(scanptr, scans, scanno * sizeof(jpeg_scan_info));
- cinfo->scan_info = scanptr;
- cinfo->num_scans = scanno;
- }
-
- fclose(fp);
- return TRUE;
-}
-
-#endif /* C_MULTISCAN_FILES_SUPPORTED */
-
-
-#if JPEG_LIB_VERSION < 70
-/* These are the sample quantization tables given in Annex K (Clause K.1) of
- * Recommendation ITU-T T.81 (1992) | ISO/IEC 10918-1:1994.
- * The spec says that the values given produce "good" quality, and
- * when divided by 2, "very good" quality.
- */
-static const unsigned int std_luminance_quant_tbl[DCTSIZE2] = {
- 16, 11, 10, 16, 24, 40, 51, 61,
- 12, 12, 14, 19, 26, 58, 60, 55,
- 14, 13, 16, 24, 40, 57, 69, 56,
- 14, 17, 22, 29, 51, 87, 80, 62,
- 18, 22, 37, 56, 68, 109, 103, 77,
- 24, 35, 55, 64, 81, 104, 113, 92,
- 49, 64, 78, 87, 103, 121, 120, 101,
- 72, 92, 95, 98, 112, 100, 103, 99
-};
-static const unsigned int std_chrominance_quant_tbl[DCTSIZE2] = {
- 17, 18, 24, 47, 99, 99, 99, 99,
- 18, 21, 26, 66, 99, 99, 99, 99,
- 24, 26, 56, 99, 99, 99, 99, 99,
- 47, 66, 99, 99, 99, 99, 99, 99,
- 99, 99, 99, 99, 99, 99, 99, 99,
- 99, 99, 99, 99, 99, 99, 99, 99,
- 99, 99, 99, 99, 99, 99, 99, 99,
- 99, 99, 99, 99, 99, 99, 99, 99
-};
-
-
-LOCAL(void)
-jpeg_default_qtables(j_compress_ptr cinfo, boolean force_baseline)
-{
- jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl, q_scale_factor[0],
- force_baseline);
- jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl, q_scale_factor[1],
- force_baseline);
-}
-#endif
-
-
-GLOBAL(boolean)
-set_quality_ratings(j_compress_ptr cinfo, char *arg, boolean force_baseline)
-/* Process a quality-ratings parameter string, of the form
- * N[,N,...]
- * If there are more q-table slots than parameters, the last value is replicated.
- */
-{
- int val = 75; /* default value */
- int tblno;
- char ch;
-
- for (tblno = 0; tblno < NUM_QUANT_TBLS; tblno++) {
- if (*arg) {
- ch = ','; /* if not set by sscanf, will be ',' */
- if (sscanf(arg, "%d%c", &val, &ch) < 1)
- return FALSE;
- if (ch != ',') /* syntax check */
- return FALSE;
- /* Convert user 0-100 rating to percentage scaling */
-#if JPEG_LIB_VERSION >= 70
- cinfo->q_scale_factor[tblno] = jpeg_quality_scaling(val);
-#else
- q_scale_factor[tblno] = jpeg_quality_scaling(val);
-#endif
- while (*arg && *arg++ != ','); /* advance to next segment of arg
- string */
- } else {
- /* reached end of parameter, set remaining factors to last value */
-#if JPEG_LIB_VERSION >= 70
- cinfo->q_scale_factor[tblno] = jpeg_quality_scaling(val);
-#else
- q_scale_factor[tblno] = jpeg_quality_scaling(val);
-#endif
- }
- }
- jpeg_default_qtables(cinfo, force_baseline);
- return TRUE;
-}
-
-
-GLOBAL(boolean)
-set_quant_slots(j_compress_ptr cinfo, char *arg)
-/* Process a quantization-table-selectors parameter string, of the form
- * N[,N,...]
- * If there are more components than parameters, the last value is replicated.
- */
-{
- int val = 0; /* default table # */
- int ci;
- char ch;
-
- for (ci = 0; ci < MAX_COMPONENTS; ci++) {
- if (*arg) {
- ch = ','; /* if not set by sscanf, will be ',' */
- if (sscanf(arg, "%d%c", &val, &ch) < 1)
- return FALSE;
- if (ch != ',') /* syntax check */
- return FALSE;
- if (val < 0 || val >= NUM_QUANT_TBLS) {
- fprintf(stderr, "JPEG quantization tables are numbered 0..%d\n",
- NUM_QUANT_TBLS - 1);
- return FALSE;
- }
- cinfo->comp_info[ci].quant_tbl_no = val;
- while (*arg && *arg++ != ','); /* advance to next segment of arg
- string */
- } else {
- /* reached end of parameter, set remaining components to last table */
- cinfo->comp_info[ci].quant_tbl_no = val;
- }
- }
- return TRUE;
-}
-
-
-GLOBAL(boolean)
-set_sample_factors(j_compress_ptr cinfo, char *arg)
-/* Process a sample-factors parameter string, of the form
- * HxV[,HxV,...]
- * If there are more components than parameters, "1x1" is assumed for the rest.
- */
-{
- int ci, val1, val2;
- char ch1, ch2;
-
- for (ci = 0; ci < MAX_COMPONENTS; ci++) {
- if (*arg) {
- ch2 = ','; /* if not set by sscanf, will be ',' */
- if (sscanf(arg, "%d%c%d%c", &val1, &ch1, &val2, &ch2) < 3)
- return FALSE;
- if ((ch1 != 'x' && ch1 != 'X') || ch2 != ',') /* syntax check */
- return FALSE;
- if (val1 <= 0 || val1 > 4 || val2 <= 0 || val2 > 4) {
- fprintf(stderr, "JPEG sampling factors must be 1..4\n");
- return FALSE;
- }
- cinfo->comp_info[ci].h_samp_factor = val1;
- cinfo->comp_info[ci].v_samp_factor = val2;
- while (*arg && *arg++ != ','); /* advance to next segment of arg
- string */
- } else {
- /* reached end of parameter, set remaining components to 1x1 sampling */
- cinfo->comp_info[ci].h_samp_factor = 1;
- cinfo->comp_info[ci].v_samp_factor = 1;
- }
- }
- return TRUE;
-}
diff --git a/contrib/libs/libjpeg-turbo/rdtarga.c b/contrib/libs/libjpeg-turbo/rdtarga.c
deleted file mode 100644
index 3ed7eb34d8..0000000000
--- a/contrib/libs/libjpeg-turbo/rdtarga.c
+++ /dev/null
@@ -1,508 +0,0 @@
-/*
- * rdtarga.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1996, Thomas G. Lane.
- * Modified 2017 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2018, 2021-2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains routines to read input images in Targa format.
- *
- * These routines may need modification for non-Unix environments or
- * specialized applications. As they stand, they assume input from
- * an ordinary stdio stream. They further assume that reading begins
- * at the start of the file; start_input may need work if the
- * user interface has already read some data (e.g., to determine that
- * the file is indeed Targa format).
- *
- * Based on code contributed by Lee Daniel Crocker.
- */
-
-#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
-
-#ifdef TARGA_SUPPORTED
-
-
-/* Macros to deal with unsigned chars as efficiently as compiler allows */
-
-typedef unsigned char U_CHAR;
-#define UCH(x) ((int)(x))
-
-
-#define ReadOK(file, buffer, len) \
- (fread(buffer, 1, len, file) == ((size_t)(len)))
-
-
-/* Private version of data source object */
-
-typedef struct _tga_source_struct *tga_source_ptr;
-
-typedef struct _tga_source_struct {
- struct cjpeg_source_struct pub; /* public fields */
-
- j_compress_ptr cinfo; /* back link saves passing separate parm */
-
- JSAMPARRAY colormap; /* Targa colormap (converted to my format) */
-
- jvirt_sarray_ptr whole_image; /* Needed if funny input row order */
- JDIMENSION current_row; /* Current logical row number to read */
-
- /* Pointer to routine to extract next Targa pixel from input file */
- void (*read_pixel) (tga_source_ptr sinfo);
-
- /* Result of read_pixel is delivered here: */
- U_CHAR tga_pixel[4];
-
- int pixel_size; /* Bytes per Targa pixel (1 to 4) */
- int cmap_length; /* colormap length */
-
- /* State info for reading RLE-coded pixels; both counts must be init to 0 */
- int block_count; /* # of pixels remaining in RLE block */
- int dup_pixel_count; /* # of times to duplicate previous pixel */
-
- /* This saves the correct pixel-row-expansion method for preload_image */
- JDIMENSION (*get_pixel_rows) (j_compress_ptr cinfo, cjpeg_source_ptr sinfo);
-} tga_source_struct;
-
-
-/* For expanding 5-bit pixel values to 8-bit with best rounding */
-
-static const UINT8 c5to8bits[32] = {
- 0, 8, 16, 25, 33, 41, 49, 58,
- 66, 74, 82, 90, 99, 107, 115, 123,
- 132, 140, 148, 156, 165, 173, 181, 189,
- 197, 206, 214, 222, 230, 239, 247, 255
-};
-
-
-
-LOCAL(int)
-read_byte(tga_source_ptr sinfo)
-/* Read next byte from Targa file */
-{
- register FILE *infile = sinfo->pub.input_file;
- register int c;
-
- if ((c = getc(infile)) == EOF)
- ERREXIT(sinfo->cinfo, JERR_INPUT_EOF);
- return c;
-}
-
-
-LOCAL(void)
-read_colormap(tga_source_ptr sinfo, int cmaplen, int mapentrysize)
-/* Read the colormap from a Targa file */
-{
- int i;
-
- /* Presently only handles 24-bit BGR format */
- if (mapentrysize != 24)
- ERREXIT(sinfo->cinfo, JERR_TGA_BADCMAP);
-
- for (i = 0; i < cmaplen; i++) {
- sinfo->colormap[2][i] = (JSAMPLE)read_byte(sinfo);
- sinfo->colormap[1][i] = (JSAMPLE)read_byte(sinfo);
- sinfo->colormap[0][i] = (JSAMPLE)read_byte(sinfo);
- }
-}
-
-
-/*
- * read_pixel methods: get a single pixel from Targa file into tga_pixel[]
- */
-
-METHODDEF(void)
-read_non_rle_pixel(tga_source_ptr sinfo)
-/* Read one Targa pixel from the input file; no RLE expansion */
-{
- register int i;
-
- for (i = 0; i < sinfo->pixel_size; i++) {
- sinfo->tga_pixel[i] = (U_CHAR)read_byte(sinfo);
- }
-}
-
-
-METHODDEF(void)
-read_rle_pixel(tga_source_ptr sinfo)
-/* Read one Targa pixel from the input file, expanding RLE data as needed */
-{
- register int i;
-
- /* Duplicate previously read pixel? */
- if (sinfo->dup_pixel_count > 0) {
- sinfo->dup_pixel_count--;
- return;
- }
-
- /* Time to read RLE block header? */
- if (--sinfo->block_count < 0) { /* decrement pixels remaining in block */
- i = read_byte(sinfo);
- if (i & 0x80) { /* Start of duplicate-pixel block? */
- sinfo->dup_pixel_count = i & 0x7F; /* number of dups after this one */
- sinfo->block_count = 0; /* then read new block header */
- } else {
- sinfo->block_count = i & 0x7F; /* number of pixels after this one */
- }
- }
-
- /* Read next pixel */
- for (i = 0; i < sinfo->pixel_size; i++) {
- sinfo->tga_pixel[i] = (U_CHAR)read_byte(sinfo);
- }
-}
-
-
-/*
- * Read one row of pixels.
- *
- * We provide several different versions depending on input file format.
- */
-
-
-METHODDEF(JDIMENSION)
-get_8bit_gray_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
-/* This version is for reading 8-bit grayscale pixels */
-{
- tga_source_ptr source = (tga_source_ptr)sinfo;
- register JSAMPROW ptr;
- register JDIMENSION col;
-
- ptr = source->pub.buffer[0];
- for (col = cinfo->image_width; col > 0; col--) {
- (*source->read_pixel) (source); /* Load next pixel into tga_pixel */
- *ptr++ = (JSAMPLE)UCH(source->tga_pixel[0]);
- }
- return 1;
-}
-
-METHODDEF(JDIMENSION)
-get_8bit_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
-/* This version is for reading 8-bit colormap indexes */
-{
- tga_source_ptr source = (tga_source_ptr)sinfo;
- register int t;
- register JSAMPROW ptr;
- register JDIMENSION col;
- register JSAMPARRAY colormap = source->colormap;
- int cmaplen = source->cmap_length;
-
- ptr = source->pub.buffer[0];
- for (col = cinfo->image_width; col > 0; col--) {
- (*source->read_pixel) (source); /* Load next pixel into tga_pixel */
- t = UCH(source->tga_pixel[0]);
- if (t >= cmaplen)
- ERREXIT(cinfo, JERR_TGA_BADPARMS);
- *ptr++ = colormap[0][t];
- *ptr++ = colormap[1][t];
- *ptr++ = colormap[2][t];
- }
- return 1;
-}
-
-METHODDEF(JDIMENSION)
-get_16bit_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
-/* This version is for reading 16-bit pixels */
-{
- tga_source_ptr source = (tga_source_ptr)sinfo;
- register int t;
- register JSAMPROW ptr;
- register JDIMENSION col;
-
- ptr = source->pub.buffer[0];
- for (col = cinfo->image_width; col > 0; col--) {
- (*source->read_pixel) (source); /* Load next pixel into tga_pixel */
- t = UCH(source->tga_pixel[0]);
- t += UCH(source->tga_pixel[1]) << 8;
- /* We expand 5 bit data to 8 bit sample width.
- * The format of the 16-bit (LSB first) input word is
- * xRRRRRGGGGGBBBBB
- */
- ptr[2] = (JSAMPLE)c5to8bits[t & 0x1F];
- t >>= 5;
- ptr[1] = (JSAMPLE)c5to8bits[t & 0x1F];
- t >>= 5;
- ptr[0] = (JSAMPLE)c5to8bits[t & 0x1F];
- ptr += 3;
- }
- return 1;
-}
-
-METHODDEF(JDIMENSION)
-get_24bit_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
-/* This version is for reading 24-bit pixels */
-{
- tga_source_ptr source = (tga_source_ptr)sinfo;
- register JSAMPROW ptr;
- register JDIMENSION col;
-
- ptr = source->pub.buffer[0];
- for (col = cinfo->image_width; col > 0; col--) {
- (*source->read_pixel) (source); /* Load next pixel into tga_pixel */
- *ptr++ = (JSAMPLE)UCH(source->tga_pixel[2]); /* change BGR to RGB order */
- *ptr++ = (JSAMPLE)UCH(source->tga_pixel[1]);
- *ptr++ = (JSAMPLE)UCH(source->tga_pixel[0]);
- }
- return 1;
-}
-
-/*
- * Targa also defines a 32-bit pixel format with order B,G,R,A.
- * We presently ignore the attribute byte, so the code for reading
- * these pixels is identical to the 24-bit routine above.
- * This works because the actual pixel length is only known to read_pixel.
- */
-
-#define get_32bit_row get_24bit_row
-
-
-/*
- * This method is for re-reading the input data in standard top-down
- * row order. The entire image has already been read into whole_image
- * with proper conversion of pixel format, but it's in a funny row order.
- */
-
-METHODDEF(JDIMENSION)
-get_memory_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
-{
- tga_source_ptr source = (tga_source_ptr)sinfo;
- JDIMENSION source_row;
-
- /* Compute row of source that maps to current_row of normal order */
- /* For now, assume image is bottom-up and not interlaced. */
- /* NEEDS WORK to support interlaced images! */
- source_row = cinfo->image_height - source->current_row - 1;
-
- /* Fetch that row from virtual array */
- source->pub.buffer = (*cinfo->mem->access_virt_sarray)
- ((j_common_ptr)cinfo, source->whole_image,
- source_row, (JDIMENSION)1, FALSE);
-
- source->current_row++;
- return 1;
-}
-
-
-/*
- * This method loads the image into whole_image during the first call on
- * get_pixel_rows. The get_pixel_rows pointer is then adjusted to call
- * get_memory_row on subsequent calls.
- */
-
-METHODDEF(JDIMENSION)
-preload_image(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
-{
- tga_source_ptr source = (tga_source_ptr)sinfo;
- JDIMENSION row;
- cd_progress_ptr progress = (cd_progress_ptr)cinfo->progress;
-
- /* Read the data into a virtual array in input-file row order. */
- for (row = 0; row < cinfo->image_height; row++) {
- if (progress != NULL) {
- progress->pub.pass_counter = (long)row;
- progress->pub.pass_limit = (long)cinfo->image_height;
- (*progress->pub.progress_monitor) ((j_common_ptr)cinfo);
- }
- source->pub.buffer = (*cinfo->mem->access_virt_sarray)
- ((j_common_ptr)cinfo, source->whole_image, row, (JDIMENSION)1, TRUE);
- (*source->get_pixel_rows) (cinfo, sinfo);
- }
- if (progress != NULL)
- progress->completed_extra_passes++;
-
- /* Set up to read from the virtual array in unscrambled order */
- source->pub.get_pixel_rows = get_memory_row;
- source->current_row = 0;
- /* And read the first row */
- return get_memory_row(cinfo, sinfo);
-}
-
-
-/*
- * Read the file header; return image size and component count.
- */
-
-METHODDEF(void)
-start_input_tga(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
-{
- tga_source_ptr source = (tga_source_ptr)sinfo;
- U_CHAR targaheader[18];
- int idlen, cmaptype, subtype, flags, interlace_type, components;
- unsigned int width, height, maplen;
- boolean is_bottom_up;
-
-#define GET_2B(offset) \
- ((unsigned int)UCH(targaheader[offset]) + \
- (((unsigned int)UCH(targaheader[offset + 1])) << 8))
-
- if (!ReadOK(source->pub.input_file, targaheader, 18))
- ERREXIT(cinfo, JERR_INPUT_EOF);
-
- /* Pretend "15-bit" pixels are 16-bit --- we ignore attribute bit anyway */
- if (targaheader[16] == 15)
- targaheader[16] = 16;
-
- idlen = UCH(targaheader[0]);
- cmaptype = UCH(targaheader[1]);
- subtype = UCH(targaheader[2]);
- maplen = GET_2B(5);
- width = GET_2B(12);
- height = GET_2B(14);
- source->pixel_size = UCH(targaheader[16]) >> 3;
- flags = UCH(targaheader[17]); /* Image Descriptor byte */
-
- is_bottom_up = ((flags & 0x20) == 0); /* bit 5 set => top-down */
- interlace_type = flags >> 6; /* bits 6/7 are interlace code */
-
- if (cmaptype > 1 || /* cmaptype must be 0 or 1 */
- source->pixel_size < 1 || source->pixel_size > 4 ||
- (UCH(targaheader[16]) & 7) != 0 || /* bits/pixel must be multiple of 8 */
- interlace_type != 0 || /* currently don't allow interlaced image */
- width == 0 || height == 0) /* image width/height must be non-zero */
- ERREXIT(cinfo, JERR_TGA_BADPARMS);
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
- if (sinfo->max_pixels &&
- (unsigned long long)width * height > sinfo->max_pixels)
- ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
-#endif
-
- if (subtype > 8) {
- /* It's an RLE-coded file */
- source->read_pixel = read_rle_pixel;
- source->block_count = source->dup_pixel_count = 0;
- subtype -= 8;
- } else {
- /* Non-RLE file */
- source->read_pixel = read_non_rle_pixel;
- }
-
- /* Now should have subtype 1, 2, or 3 */
- components = 3; /* until proven different */
- cinfo->in_color_space = JCS_RGB;
-
- switch (subtype) {
- case 1: /* Colormapped image */
- if (source->pixel_size == 1 && cmaptype == 1)
- source->get_pixel_rows = get_8bit_row;
- else
- ERREXIT(cinfo, JERR_TGA_BADPARMS);
- TRACEMS2(cinfo, 1, JTRC_TGA_MAPPED, width, height);
- break;
- case 2: /* RGB image */
- switch (source->pixel_size) {
- case 2:
- source->get_pixel_rows = get_16bit_row;
- break;
- case 3:
- source->get_pixel_rows = get_24bit_row;
- break;
- case 4:
- source->get_pixel_rows = get_32bit_row;
- break;
- default:
- ERREXIT(cinfo, JERR_TGA_BADPARMS);
- break;
- }
- TRACEMS2(cinfo, 1, JTRC_TGA, width, height);
- break;
- case 3: /* Grayscale image */
- components = 1;
- cinfo->in_color_space = JCS_GRAYSCALE;
- if (source->pixel_size == 1)
- source->get_pixel_rows = get_8bit_gray_row;
- else
- ERREXIT(cinfo, JERR_TGA_BADPARMS);
- TRACEMS2(cinfo, 1, JTRC_TGA_GRAY, width, height);
- break;
- default:
- ERREXIT(cinfo, JERR_TGA_BADPARMS);
- break;
- }
-
- if (is_bottom_up) {
- /* Create a virtual array to buffer the upside-down image. */
- source->whole_image = (*cinfo->mem->request_virt_sarray)
- ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE,
- (JDIMENSION)width * components, (JDIMENSION)height, (JDIMENSION)1);
- if (cinfo->progress != NULL) {
- cd_progress_ptr progress = (cd_progress_ptr)cinfo->progress;
- progress->total_extra_passes++; /* count file input as separate pass */
- }
- /* source->pub.buffer will point to the virtual array. */
- source->pub.buffer_height = 1; /* in case anyone looks at it */
- source->pub.get_pixel_rows = preload_image;
- } else {
- /* Don't need a virtual array, but do need a one-row input buffer. */
- source->whole_image = NULL;
- source->pub.buffer = (*cinfo->mem->alloc_sarray)
- ((j_common_ptr)cinfo, JPOOL_IMAGE,
- (JDIMENSION)width * components, (JDIMENSION)1);
- source->pub.buffer_height = 1;
- source->pub.get_pixel_rows = source->get_pixel_rows;
- }
-
- while (idlen--) /* Throw away ID field */
- (void)read_byte(source);
-
- if (maplen > 0) {
- if (maplen > 256 || GET_2B(3) != 0)
- ERREXIT(cinfo, JERR_TGA_BADCMAP);
- /* Allocate space to store the colormap */
- source->colormap = (*cinfo->mem->alloc_sarray)
- ((j_common_ptr)cinfo, JPOOL_IMAGE, (JDIMENSION)maplen, (JDIMENSION)3);
- source->cmap_length = (int)maplen;
- /* and read it from the file */
- read_colormap(source, (int)maplen, UCH(targaheader[7]));
- } else {
- if (cmaptype) /* but you promised a cmap! */
- ERREXIT(cinfo, JERR_TGA_BADPARMS);
- source->colormap = NULL;
- source->cmap_length = 0;
- }
-
- cinfo->input_components = components;
- cinfo->data_precision = 8;
- cinfo->image_width = width;
- cinfo->image_height = height;
-}
-
-
-/*
- * Finish up at the end of the file.
- */
-
-METHODDEF(void)
-finish_input_tga(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
-{
- /* no work */
-}
-
-
-/*
- * The module selection routine for Targa format input.
- */
-
-GLOBAL(cjpeg_source_ptr)
-jinit_read_targa(j_compress_ptr cinfo)
-{
- tga_source_ptr source;
-
- /* Create module interface object */
- source = (tga_source_ptr)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- sizeof(tga_source_struct));
- source->cinfo = cinfo; /* make back link for subroutines */
- /* Fill in method ptrs, except get_pixel_rows which start_input sets */
- source->pub.start_input = start_input_tga;
- source->pub.finish_input = finish_input_tga;
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
- source->pub.max_pixels = 0;
-#endif
-
- return (cjpeg_source_ptr)source;
-}
-
-#endif /* TARGA_SUPPORTED */
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/aarch32/jccolext-neon.c b/contrib/libs/libjpeg-turbo/simd/arm/aarch32/jccolext-neon.c
deleted file mode 100644
index 362102d2b2..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/arm/aarch32/jccolext-neon.c
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * jccolext-neon.c - colorspace conversion (32-bit Arm Neon)
- *
- * Copyright (C) 2020, Arm Limited. All Rights Reserved.
- * Copyright (C) 2020, D. R. Commander. All Rights Reserved.
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- * claim that you wrote the original software. If you use this software
- * in a product, an acknowledgment in the product documentation would be
- * appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must not be
- * misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source distribution.
- */
-
-/* This file is included by jccolor-neon.c */
-
-
-/* RGB -> YCbCr conversion is defined by the following equations:
- * Y = 0.29900 * R + 0.58700 * G + 0.11400 * B
- * Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + 128
- * Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + 128
- *
- * Avoid floating point arithmetic by using shifted integer constants:
- * 0.29899597 = 19595 * 2^-16
- * 0.58700561 = 38470 * 2^-16
- * 0.11399841 = 7471 * 2^-16
- * 0.16874695 = 11059 * 2^-16
- * 0.33125305 = 21709 * 2^-16
- * 0.50000000 = 32768 * 2^-16
- * 0.41868592 = 27439 * 2^-16
- * 0.08131409 = 5329 * 2^-16
- * These constants are defined in jccolor-neon.c
- *
- * We add the fixed-point equivalent of 0.5 to Cb and Cr, which effectively
- * rounds up or down the result via integer truncation.
- */
-
-void jsimd_rgb_ycc_convert_neon(JDIMENSION image_width, JSAMPARRAY input_buf,
- JSAMPIMAGE output_buf, JDIMENSION output_row,
- int num_rows)
-{
- /* Pointer to RGB(X/A) input data */
- JSAMPROW inptr;
- /* Pointers to Y, Cb, and Cr output data */
- JSAMPROW outptr0, outptr1, outptr2;
- /* Allocate temporary buffer for final (image_width % 8) pixels in row. */
- ALIGN(16) uint8_t tmp_buf[8 * RGB_PIXELSIZE];
-
- /* Set up conversion constants. */
-#ifdef HAVE_VLD1_U16_X2
- const uint16x4x2_t consts = vld1_u16_x2(jsimd_rgb_ycc_neon_consts);
-#else
- /* GCC does not currently support the intrinsic vld1_<type>_x2(). */
- const uint16x4_t consts1 = vld1_u16(jsimd_rgb_ycc_neon_consts);
- const uint16x4_t consts2 = vld1_u16(jsimd_rgb_ycc_neon_consts + 4);
- const uint16x4x2_t consts = { { consts1, consts2 } };
-#endif
- const uint32x4_t scaled_128_5 = vdupq_n_u32((128 << 16) + 32767);
-
- while (--num_rows >= 0) {
- inptr = *input_buf++;
- outptr0 = output_buf[0][output_row];
- outptr1 = output_buf[1][output_row];
- outptr2 = output_buf[2][output_row];
- output_row++;
-
- int cols_remaining = image_width;
- for (; cols_remaining > 0; cols_remaining -= 8) {
-
- /* To prevent buffer overread by the vector load instructions, the last
- * (image_width % 8) columns of data are first memcopied to a temporary
- * buffer large enough to accommodate the vector load.
- */
- if (cols_remaining < 8) {
- memcpy(tmp_buf, inptr, cols_remaining * RGB_PIXELSIZE);
- inptr = tmp_buf;
- }
-
-#if RGB_PIXELSIZE == 4
- uint8x8x4_t input_pixels = vld4_u8(inptr);
-#else
- uint8x8x3_t input_pixels = vld3_u8(inptr);
-#endif
- uint16x8_t r = vmovl_u8(input_pixels.val[RGB_RED]);
- uint16x8_t g = vmovl_u8(input_pixels.val[RGB_GREEN]);
- uint16x8_t b = vmovl_u8(input_pixels.val[RGB_BLUE]);
-
- /* Compute Y = 0.29900 * R + 0.58700 * G + 0.11400 * B */
- uint32x4_t y_low = vmull_lane_u16(vget_low_u16(r), consts.val[0], 0);
- y_low = vmlal_lane_u16(y_low, vget_low_u16(g), consts.val[0], 1);
- y_low = vmlal_lane_u16(y_low, vget_low_u16(b), consts.val[0], 2);
- uint32x4_t y_high = vmull_lane_u16(vget_high_u16(r), consts.val[0], 0);
- y_high = vmlal_lane_u16(y_high, vget_high_u16(g), consts.val[0], 1);
- y_high = vmlal_lane_u16(y_high, vget_high_u16(b), consts.val[0], 2);
-
- /* Compute Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + 128 */
- uint32x4_t cb_low = scaled_128_5;
- cb_low = vmlsl_lane_u16(cb_low, vget_low_u16(r), consts.val[0], 3);
- cb_low = vmlsl_lane_u16(cb_low, vget_low_u16(g), consts.val[1], 0);
- cb_low = vmlal_lane_u16(cb_low, vget_low_u16(b), consts.val[1], 1);
- uint32x4_t cb_high = scaled_128_5;
- cb_high = vmlsl_lane_u16(cb_high, vget_high_u16(r), consts.val[0], 3);
- cb_high = vmlsl_lane_u16(cb_high, vget_high_u16(g), consts.val[1], 0);
- cb_high = vmlal_lane_u16(cb_high, vget_high_u16(b), consts.val[1], 1);
-
- /* Compute Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + 128 */
- uint32x4_t cr_low = scaled_128_5;
- cr_low = vmlal_lane_u16(cr_low, vget_low_u16(r), consts.val[1], 1);
- cr_low = vmlsl_lane_u16(cr_low, vget_low_u16(g), consts.val[1], 2);
- cr_low = vmlsl_lane_u16(cr_low, vget_low_u16(b), consts.val[1], 3);
- uint32x4_t cr_high = scaled_128_5;
- cr_high = vmlal_lane_u16(cr_high, vget_high_u16(r), consts.val[1], 1);
- cr_high = vmlsl_lane_u16(cr_high, vget_high_u16(g), consts.val[1], 2);
- cr_high = vmlsl_lane_u16(cr_high, vget_high_u16(b), consts.val[1], 3);
-
- /* Descale Y values (rounding right shift) and narrow to 16-bit. */
- uint16x8_t y_u16 = vcombine_u16(vrshrn_n_u32(y_low, 16),
- vrshrn_n_u32(y_high, 16));
- /* Descale Cb values (right shift) and narrow to 16-bit. */
- uint16x8_t cb_u16 = vcombine_u16(vshrn_n_u32(cb_low, 16),
- vshrn_n_u32(cb_high, 16));
- /* Descale Cr values (right shift) and narrow to 16-bit. */
- uint16x8_t cr_u16 = vcombine_u16(vshrn_n_u32(cr_low, 16),
- vshrn_n_u32(cr_high, 16));
- /* Narrow Y, Cb, and Cr values to 8-bit and store to memory. Buffer
- * overwrite is permitted up to the next multiple of ALIGN_SIZE bytes.
- */
- vst1_u8(outptr0, vmovn_u16(y_u16));
- vst1_u8(outptr1, vmovn_u16(cb_u16));
- vst1_u8(outptr2, vmovn_u16(cr_u16));
-
- /* Increment pointers. */
- inptr += (8 * RGB_PIXELSIZE);
- outptr0 += 8;
- outptr1 += 8;
- outptr2 += 8;
- }
- }
-}
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/aarch32/jchuff-neon.c b/contrib/libs/libjpeg-turbo/simd/arm/aarch32/jchuff-neon.c
deleted file mode 100644
index 19d94f720d..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/arm/aarch32/jchuff-neon.c
+++ /dev/null
@@ -1,334 +0,0 @@
-/*
- * jchuff-neon.c - Huffman entropy encoding (32-bit Arm Neon)
- *
- * Copyright (C) 2020, Arm Limited. All Rights Reserved.
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- * claim that you wrote the original software. If you use this software
- * in a product, an acknowledgment in the product documentation would be
- * appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must not be
- * misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source distribution.
- *
- * NOTE: All referenced figures are from
- * Recommendation ITU-T T.81 (1992) | ISO/IEC 10918-1:1994.
- */
-
-#define JPEG_INTERNALS
-#include "../../../jinclude.h"
-#include "../../../jpeglib.h"
-#include "../../../jsimd.h"
-#include "../../../jdct.h"
-#include "../../../jsimddct.h"
-#include "../../jsimd.h"
-#include "../jchuff.h"
-#include "neon-compat.h"
-
-#include <limits.h>
-
-#include <arm_neon.h>
-
-
-JOCTET *jsimd_huff_encode_one_block_neon(void *state, JOCTET *buffer,
- JCOEFPTR block, int last_dc_val,
- c_derived_tbl *dctbl,
- c_derived_tbl *actbl)
-{
- uint8_t block_nbits[DCTSIZE2];
- uint16_t block_diff[DCTSIZE2];
-
- /* Load rows of coefficients from DCT block in zig-zag order. */
-
- /* Compute DC coefficient difference value. (F.1.1.5.1) */
- int16x8_t row0 = vdupq_n_s16(block[0] - last_dc_val);
- row0 = vld1q_lane_s16(block + 1, row0, 1);
- row0 = vld1q_lane_s16(block + 8, row0, 2);
- row0 = vld1q_lane_s16(block + 16, row0, 3);
- row0 = vld1q_lane_s16(block + 9, row0, 4);
- row0 = vld1q_lane_s16(block + 2, row0, 5);
- row0 = vld1q_lane_s16(block + 3, row0, 6);
- row0 = vld1q_lane_s16(block + 10, row0, 7);
-
- int16x8_t row1 = vld1q_dup_s16(block + 17);
- row1 = vld1q_lane_s16(block + 24, row1, 1);
- row1 = vld1q_lane_s16(block + 32, row1, 2);
- row1 = vld1q_lane_s16(block + 25, row1, 3);
- row1 = vld1q_lane_s16(block + 18, row1, 4);
- row1 = vld1q_lane_s16(block + 11, row1, 5);
- row1 = vld1q_lane_s16(block + 4, row1, 6);
- row1 = vld1q_lane_s16(block + 5, row1, 7);
-
- int16x8_t row2 = vld1q_dup_s16(block + 12);
- row2 = vld1q_lane_s16(block + 19, row2, 1);
- row2 = vld1q_lane_s16(block + 26, row2, 2);
- row2 = vld1q_lane_s16(block + 33, row2, 3);
- row2 = vld1q_lane_s16(block + 40, row2, 4);
- row2 = vld1q_lane_s16(block + 48, row2, 5);
- row2 = vld1q_lane_s16(block + 41, row2, 6);
- row2 = vld1q_lane_s16(block + 34, row2, 7);
-
- int16x8_t row3 = vld1q_dup_s16(block + 27);
- row3 = vld1q_lane_s16(block + 20, row3, 1);
- row3 = vld1q_lane_s16(block + 13, row3, 2);
- row3 = vld1q_lane_s16(block + 6, row3, 3);
- row3 = vld1q_lane_s16(block + 7, row3, 4);
- row3 = vld1q_lane_s16(block + 14, row3, 5);
- row3 = vld1q_lane_s16(block + 21, row3, 6);
- row3 = vld1q_lane_s16(block + 28, row3, 7);
-
- int16x8_t abs_row0 = vabsq_s16(row0);
- int16x8_t abs_row1 = vabsq_s16(row1);
- int16x8_t abs_row2 = vabsq_s16(row2);
- int16x8_t abs_row3 = vabsq_s16(row3);
-
- int16x8_t row0_lz = vclzq_s16(abs_row0);
- int16x8_t row1_lz = vclzq_s16(abs_row1);
- int16x8_t row2_lz = vclzq_s16(abs_row2);
- int16x8_t row3_lz = vclzq_s16(abs_row3);
-
- /* Compute number of bits required to represent each coefficient. */
- uint8x8_t row0_nbits = vsub_u8(vdup_n_u8(16),
- vmovn_u16(vreinterpretq_u16_s16(row0_lz)));
- uint8x8_t row1_nbits = vsub_u8(vdup_n_u8(16),
- vmovn_u16(vreinterpretq_u16_s16(row1_lz)));
- uint8x8_t row2_nbits = vsub_u8(vdup_n_u8(16),
- vmovn_u16(vreinterpretq_u16_s16(row2_lz)));
- uint8x8_t row3_nbits = vsub_u8(vdup_n_u8(16),
- vmovn_u16(vreinterpretq_u16_s16(row3_lz)));
-
- vst1_u8(block_nbits + 0 * DCTSIZE, row0_nbits);
- vst1_u8(block_nbits + 1 * DCTSIZE, row1_nbits);
- vst1_u8(block_nbits + 2 * DCTSIZE, row2_nbits);
- vst1_u8(block_nbits + 3 * DCTSIZE, row3_nbits);
-
- uint16x8_t row0_mask =
- vshlq_u16(vreinterpretq_u16_s16(vshrq_n_s16(row0, 15)),
- vnegq_s16(row0_lz));
- uint16x8_t row1_mask =
- vshlq_u16(vreinterpretq_u16_s16(vshrq_n_s16(row1, 15)),
- vnegq_s16(row1_lz));
- uint16x8_t row2_mask =
- vshlq_u16(vreinterpretq_u16_s16(vshrq_n_s16(row2, 15)),
- vnegq_s16(row2_lz));
- uint16x8_t row3_mask =
- vshlq_u16(vreinterpretq_u16_s16(vshrq_n_s16(row3, 15)),
- vnegq_s16(row3_lz));
-
- uint16x8_t row0_diff = veorq_u16(vreinterpretq_u16_s16(abs_row0), row0_mask);
- uint16x8_t row1_diff = veorq_u16(vreinterpretq_u16_s16(abs_row1), row1_mask);
- uint16x8_t row2_diff = veorq_u16(vreinterpretq_u16_s16(abs_row2), row2_mask);
- uint16x8_t row3_diff = veorq_u16(vreinterpretq_u16_s16(abs_row3), row3_mask);
-
- /* Store diff values for rows 0, 1, 2, and 3. */
- vst1q_u16(block_diff + 0 * DCTSIZE, row0_diff);
- vst1q_u16(block_diff + 1 * DCTSIZE, row1_diff);
- vst1q_u16(block_diff + 2 * DCTSIZE, row2_diff);
- vst1q_u16(block_diff + 3 * DCTSIZE, row3_diff);
-
- /* Load last four rows of coefficients from DCT block in zig-zag order. */
- int16x8_t row4 = vld1q_dup_s16(block + 35);
- row4 = vld1q_lane_s16(block + 42, row4, 1);
- row4 = vld1q_lane_s16(block + 49, row4, 2);
- row4 = vld1q_lane_s16(block + 56, row4, 3);
- row4 = vld1q_lane_s16(block + 57, row4, 4);
- row4 = vld1q_lane_s16(block + 50, row4, 5);
- row4 = vld1q_lane_s16(block + 43, row4, 6);
- row4 = vld1q_lane_s16(block + 36, row4, 7);
-
- int16x8_t row5 = vld1q_dup_s16(block + 29);
- row5 = vld1q_lane_s16(block + 22, row5, 1);
- row5 = vld1q_lane_s16(block + 15, row5, 2);
- row5 = vld1q_lane_s16(block + 23, row5, 3);
- row5 = vld1q_lane_s16(block + 30, row5, 4);
- row5 = vld1q_lane_s16(block + 37, row5, 5);
- row5 = vld1q_lane_s16(block + 44, row5, 6);
- row5 = vld1q_lane_s16(block + 51, row5, 7);
-
- int16x8_t row6 = vld1q_dup_s16(block + 58);
- row6 = vld1q_lane_s16(block + 59, row6, 1);
- row6 = vld1q_lane_s16(block + 52, row6, 2);
- row6 = vld1q_lane_s16(block + 45, row6, 3);
- row6 = vld1q_lane_s16(block + 38, row6, 4);
- row6 = vld1q_lane_s16(block + 31, row6, 5);
- row6 = vld1q_lane_s16(block + 39, row6, 6);
- row6 = vld1q_lane_s16(block + 46, row6, 7);
-
- int16x8_t row7 = vld1q_dup_s16(block + 53);
- row7 = vld1q_lane_s16(block + 60, row7, 1);
- row7 = vld1q_lane_s16(block + 61, row7, 2);
- row7 = vld1q_lane_s16(block + 54, row7, 3);
- row7 = vld1q_lane_s16(block + 47, row7, 4);
- row7 = vld1q_lane_s16(block + 55, row7, 5);
- row7 = vld1q_lane_s16(block + 62, row7, 6);
- row7 = vld1q_lane_s16(block + 63, row7, 7);
-
- int16x8_t abs_row4 = vabsq_s16(row4);
- int16x8_t abs_row5 = vabsq_s16(row5);
- int16x8_t abs_row6 = vabsq_s16(row6);
- int16x8_t abs_row7 = vabsq_s16(row7);
-
- int16x8_t row4_lz = vclzq_s16(abs_row4);
- int16x8_t row5_lz = vclzq_s16(abs_row5);
- int16x8_t row6_lz = vclzq_s16(abs_row6);
- int16x8_t row7_lz = vclzq_s16(abs_row7);
-
- /* Compute number of bits required to represent each coefficient. */
- uint8x8_t row4_nbits = vsub_u8(vdup_n_u8(16),
- vmovn_u16(vreinterpretq_u16_s16(row4_lz)));
- uint8x8_t row5_nbits = vsub_u8(vdup_n_u8(16),
- vmovn_u16(vreinterpretq_u16_s16(row5_lz)));
- uint8x8_t row6_nbits = vsub_u8(vdup_n_u8(16),
- vmovn_u16(vreinterpretq_u16_s16(row6_lz)));
- uint8x8_t row7_nbits = vsub_u8(vdup_n_u8(16),
- vmovn_u16(vreinterpretq_u16_s16(row7_lz)));
-
- vst1_u8(block_nbits + 4 * DCTSIZE, row4_nbits);
- vst1_u8(block_nbits + 5 * DCTSIZE, row5_nbits);
- vst1_u8(block_nbits + 6 * DCTSIZE, row6_nbits);
- vst1_u8(block_nbits + 7 * DCTSIZE, row7_nbits);
-
- uint16x8_t row4_mask =
- vshlq_u16(vreinterpretq_u16_s16(vshrq_n_s16(row4, 15)),
- vnegq_s16(row4_lz));
- uint16x8_t row5_mask =
- vshlq_u16(vreinterpretq_u16_s16(vshrq_n_s16(row5, 15)),
- vnegq_s16(row5_lz));
- uint16x8_t row6_mask =
- vshlq_u16(vreinterpretq_u16_s16(vshrq_n_s16(row6, 15)),
- vnegq_s16(row6_lz));
- uint16x8_t row7_mask =
- vshlq_u16(vreinterpretq_u16_s16(vshrq_n_s16(row7, 15)),
- vnegq_s16(row7_lz));
-
- uint16x8_t row4_diff = veorq_u16(vreinterpretq_u16_s16(abs_row4), row4_mask);
- uint16x8_t row5_diff = veorq_u16(vreinterpretq_u16_s16(abs_row5), row5_mask);
- uint16x8_t row6_diff = veorq_u16(vreinterpretq_u16_s16(abs_row6), row6_mask);
- uint16x8_t row7_diff = veorq_u16(vreinterpretq_u16_s16(abs_row7), row7_mask);
-
- /* Store diff values for rows 4, 5, 6, and 7. */
- vst1q_u16(block_diff + 4 * DCTSIZE, row4_diff);
- vst1q_u16(block_diff + 5 * DCTSIZE, row5_diff);
- vst1q_u16(block_diff + 6 * DCTSIZE, row6_diff);
- vst1q_u16(block_diff + 7 * DCTSIZE, row7_diff);
-
- /* Construct bitmap to accelerate encoding of AC coefficients. A set bit
- * means that the corresponding coefficient != 0.
- */
- uint8x8_t row0_nbits_gt0 = vcgt_u8(row0_nbits, vdup_n_u8(0));
- uint8x8_t row1_nbits_gt0 = vcgt_u8(row1_nbits, vdup_n_u8(0));
- uint8x8_t row2_nbits_gt0 = vcgt_u8(row2_nbits, vdup_n_u8(0));
- uint8x8_t row3_nbits_gt0 = vcgt_u8(row3_nbits, vdup_n_u8(0));
- uint8x8_t row4_nbits_gt0 = vcgt_u8(row4_nbits, vdup_n_u8(0));
- uint8x8_t row5_nbits_gt0 = vcgt_u8(row5_nbits, vdup_n_u8(0));
- uint8x8_t row6_nbits_gt0 = vcgt_u8(row6_nbits, vdup_n_u8(0));
- uint8x8_t row7_nbits_gt0 = vcgt_u8(row7_nbits, vdup_n_u8(0));
-
- /* { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 } */
- const uint8x8_t bitmap_mask =
- vreinterpret_u8_u64(vmov_n_u64(0x0102040810204080));
-
- row0_nbits_gt0 = vand_u8(row0_nbits_gt0, bitmap_mask);
- row1_nbits_gt0 = vand_u8(row1_nbits_gt0, bitmap_mask);
- row2_nbits_gt0 = vand_u8(row2_nbits_gt0, bitmap_mask);
- row3_nbits_gt0 = vand_u8(row3_nbits_gt0, bitmap_mask);
- row4_nbits_gt0 = vand_u8(row4_nbits_gt0, bitmap_mask);
- row5_nbits_gt0 = vand_u8(row5_nbits_gt0, bitmap_mask);
- row6_nbits_gt0 = vand_u8(row6_nbits_gt0, bitmap_mask);
- row7_nbits_gt0 = vand_u8(row7_nbits_gt0, bitmap_mask);
-
- uint8x8_t bitmap_rows_10 = vpadd_u8(row1_nbits_gt0, row0_nbits_gt0);
- uint8x8_t bitmap_rows_32 = vpadd_u8(row3_nbits_gt0, row2_nbits_gt0);
- uint8x8_t bitmap_rows_54 = vpadd_u8(row5_nbits_gt0, row4_nbits_gt0);
- uint8x8_t bitmap_rows_76 = vpadd_u8(row7_nbits_gt0, row6_nbits_gt0);
- uint8x8_t bitmap_rows_3210 = vpadd_u8(bitmap_rows_32, bitmap_rows_10);
- uint8x8_t bitmap_rows_7654 = vpadd_u8(bitmap_rows_76, bitmap_rows_54);
- uint8x8_t bitmap = vpadd_u8(bitmap_rows_7654, bitmap_rows_3210);
-
- /* Shift left to remove DC bit. */
- bitmap = vreinterpret_u8_u64(vshl_n_u64(vreinterpret_u64_u8(bitmap), 1));
- /* Move bitmap to 32-bit scalar registers. */
- uint32_t bitmap_1_32 = vget_lane_u32(vreinterpret_u32_u8(bitmap), 1);
- uint32_t bitmap_33_63 = vget_lane_u32(vreinterpret_u32_u8(bitmap), 0);
-
- /* Set up state and bit buffer for output bitstream. */
- working_state *state_ptr = (working_state *)state;
- int free_bits = state_ptr->cur.free_bits;
- size_t put_buffer = state_ptr->cur.put_buffer;
-
- /* Encode DC coefficient. */
-
- unsigned int nbits = block_nbits[0];
- /* Emit Huffman-coded symbol and additional diff bits. */
- unsigned int diff = block_diff[0];
- PUT_CODE(dctbl->ehufco[nbits], dctbl->ehufsi[nbits], diff)
-
- /* Encode AC coefficients. */
-
- unsigned int r = 0; /* r = run length of zeros */
- unsigned int i = 1; /* i = number of coefficients encoded */
- /* Code and size information for a run length of 16 zero coefficients */
- const unsigned int code_0xf0 = actbl->ehufco[0xf0];
- const unsigned int size_0xf0 = actbl->ehufsi[0xf0];
-
- while (bitmap_1_32 != 0) {
- r = BUILTIN_CLZ(bitmap_1_32);
- i += r;
- bitmap_1_32 <<= r;
- nbits = block_nbits[i];
- diff = block_diff[i];
- while (r > 15) {
- /* If run length > 15, emit special run-length-16 codes. */
- PUT_BITS(code_0xf0, size_0xf0)
- r -= 16;
- }
- /* Emit Huffman symbol for run length / number of bits. (F.1.2.2.1) */
- unsigned int rs = (r << 4) + nbits;
- PUT_CODE(actbl->ehufco[rs], actbl->ehufsi[rs], diff)
- i++;
- bitmap_1_32 <<= 1;
- }
-
- r = 33 - i;
- i = 33;
-
- while (bitmap_33_63 != 0) {
- unsigned int leading_zeros = BUILTIN_CLZ(bitmap_33_63);
- r += leading_zeros;
- i += leading_zeros;
- bitmap_33_63 <<= leading_zeros;
- nbits = block_nbits[i];
- diff = block_diff[i];
- while (r > 15) {
- /* If run length > 15, emit special run-length-16 codes. */
- PUT_BITS(code_0xf0, size_0xf0)
- r -= 16;
- }
- /* Emit Huffman symbol for run length / number of bits. (F.1.2.2.1) */
- unsigned int rs = (r << 4) + nbits;
- PUT_CODE(actbl->ehufco[rs], actbl->ehufsi[rs], diff)
- r = 0;
- i++;
- bitmap_33_63 <<= 1;
- }
-
- /* If the last coefficient(s) were zero, emit an end-of-block (EOB) code.
- * The value of RS for the EOB code is 0.
- */
- if (i != 64) {
- PUT_BITS(actbl->ehufco[0], actbl->ehufsi[0])
- }
-
- state_ptr->cur.put_buffer = put_buffer;
- state_ptr->cur.free_bits = free_bits;
-
- return buffer;
-}
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/aarch32/jsimd.c b/contrib/libs/libjpeg-turbo/simd/arm/aarch32/jsimd.c
deleted file mode 100644
index 920f7656eb..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/arm/aarch32/jsimd.c
+++ /dev/null
@@ -1,978 +0,0 @@
-/*
- * jsimd_arm.c
- *
- * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- * Copyright (C) 2011, Nokia Corporation and/or its subsidiary(-ies).
- * Copyright (C) 2009-2011, 2013-2014, 2016, 2018, 2022, D. R. Commander.
- * Copyright (C) 2015-2016, 2018, Matthieu Darbois.
- * Copyright (C) 2019, Google LLC.
- * Copyright (C) 2020, Arm Limited.
- *
- * Based on the x86 SIMD extension for IJG JPEG library,
- * Copyright (C) 1999-2006, MIYASAKA Masaru.
- * For conditions of distribution and use, see copyright notice in jsimdext.inc
- *
- * This file contains the interface between the "normal" portions
- * of the library and the SIMD implementations when running on a
- * 32-bit Arm architecture.
- */
-
-#define JPEG_INTERNALS
-#include "../../../jinclude.h"
-#include "../../../jpeglib.h"
-#include "../../../jsimd.h"
-#include "../../../jdct.h"
-#include "../../../jsimddct.h"
-#include "../../jsimd.h"
-
-#include <ctype.h>
-
-static unsigned int simd_support = ~0;
-static unsigned int simd_huffman = 1;
-
-#if !defined(__ARM_NEON__) && (defined(__linux__) || defined(ANDROID) || defined(__ANDROID__))
-
-#define SOMEWHAT_SANE_PROC_CPUINFO_SIZE_LIMIT (1024 * 1024)
-
-LOCAL(int)
-check_feature(char *buffer, char *feature)
-{
- char *p;
-
- if (*feature == 0)
- return 0;
- if (strncmp(buffer, "Features", 8) != 0)
- return 0;
- buffer += 8;
- while (isspace(*buffer))
- buffer++;
-
- /* Check if 'feature' is present in the buffer as a separate word */
- while ((p = strstr(buffer, feature))) {
- if (p > buffer && !isspace(*(p - 1))) {
- buffer++;
- continue;
- }
- p += strlen(feature);
- if (*p != 0 && !isspace(*p)) {
- buffer++;
- continue;
- }
- return 1;
- }
- return 0;
-}
-
-LOCAL(int)
-parse_proc_cpuinfo(int bufsize)
-{
- char *buffer = (char *)malloc(bufsize);
- FILE *fd;
-
- simd_support = 0;
-
- if (!buffer)
- return 0;
-
- fd = fopen("/proc/cpuinfo", "r");
- if (fd) {
- while (fgets(buffer, bufsize, fd)) {
- if (!strchr(buffer, '\n') && !feof(fd)) {
- /* "impossible" happened - insufficient size of the buffer! */
- fclose(fd);
- free(buffer);
- return 0;
- }
- if (check_feature(buffer, "neon"))
- simd_support |= JSIMD_NEON;
- }
- fclose(fd);
- }
- free(buffer);
- return 1;
-}
-
-#endif
-
-/*
- * Check what SIMD accelerations are supported.
- *
- * FIXME: This code is racy under a multi-threaded environment.
- */
-LOCAL(void)
-init_simd(void)
-{
-#ifndef NO_GETENV
- char env[2] = { 0 };
-#endif
-#if !defined(__ARM_NEON__) && (defined(__linux__) || defined(ANDROID) || defined(__ANDROID__))
- int bufsize = 1024; /* an initial guess for the line buffer size limit */
-#endif
-
- if (simd_support != ~0U)
- return;
-
- simd_support = 0;
-
-#if defined(__ARM_NEON__)
- simd_support |= JSIMD_NEON;
-#elif defined(__linux__) || defined(ANDROID) || defined(__ANDROID__)
- /* We still have a chance to use Neon regardless of globally used
- * -mcpu/-mfpu options passed to gcc by performing runtime detection via
- * /proc/cpuinfo parsing on linux/android */
- while (!parse_proc_cpuinfo(bufsize)) {
- bufsize *= 2;
- if (bufsize > SOMEWHAT_SANE_PROC_CPUINFO_SIZE_LIMIT)
- break;
- }
-#endif
-
-#ifndef NO_GETENV
- /* Force different settings through environment variables */
- if (!GETENV_S(env, 2, "JSIMD_FORCENEON") && !strcmp(env, "1"))
- simd_support = JSIMD_NEON;
- if (!GETENV_S(env, 2, "JSIMD_FORCENONE") && !strcmp(env, "1"))
- simd_support = 0;
- if (!GETENV_S(env, 2, "JSIMD_NOHUFFENC") && !strcmp(env, "1"))
- simd_huffman = 0;
-#endif
-}
-
-GLOBAL(int)
-jsimd_can_rgb_ycc(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
- if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_rgb_gray(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
- if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_ycc_rgb(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
- if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_ycc_rgb565(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(void)
-jsimd_rgb_ycc_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPIMAGE output_buf, JDIMENSION output_row,
- int num_rows)
-{
- void (*neonfct) (JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int);
-
- switch (cinfo->in_color_space) {
- case JCS_EXT_RGB:
- neonfct = jsimd_extrgb_ycc_convert_neon;
- break;
- case JCS_EXT_RGBX:
- case JCS_EXT_RGBA:
- neonfct = jsimd_extrgbx_ycc_convert_neon;
- break;
- case JCS_EXT_BGR:
- neonfct = jsimd_extbgr_ycc_convert_neon;
- break;
- case JCS_EXT_BGRX:
- case JCS_EXT_BGRA:
- neonfct = jsimd_extbgrx_ycc_convert_neon;
- break;
- case JCS_EXT_XBGR:
- case JCS_EXT_ABGR:
- neonfct = jsimd_extxbgr_ycc_convert_neon;
- break;
- case JCS_EXT_XRGB:
- case JCS_EXT_ARGB:
- neonfct = jsimd_extxrgb_ycc_convert_neon;
- break;
- default:
- neonfct = jsimd_extrgb_ycc_convert_neon;
- break;
- }
-
- neonfct(cinfo->image_width, input_buf, output_buf, output_row, num_rows);
-}
-
-GLOBAL(void)
-jsimd_rgb_gray_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPIMAGE output_buf, JDIMENSION output_row,
- int num_rows)
-{
- void (*neonfct) (JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int);
-
- switch (cinfo->in_color_space) {
- case JCS_EXT_RGB:
- neonfct = jsimd_extrgb_gray_convert_neon;
- break;
- case JCS_EXT_RGBX:
- case JCS_EXT_RGBA:
- neonfct = jsimd_extrgbx_gray_convert_neon;
- break;
- case JCS_EXT_BGR:
- neonfct = jsimd_extbgr_gray_convert_neon;
- break;
- case JCS_EXT_BGRX:
- case JCS_EXT_BGRA:
- neonfct = jsimd_extbgrx_gray_convert_neon;
- break;
- case JCS_EXT_XBGR:
- case JCS_EXT_ABGR:
- neonfct = jsimd_extxbgr_gray_convert_neon;
- break;
- case JCS_EXT_XRGB:
- case JCS_EXT_ARGB:
- neonfct = jsimd_extxrgb_gray_convert_neon;
- break;
- default:
- neonfct = jsimd_extrgb_gray_convert_neon;
- break;
- }
-
- neonfct(cinfo->image_width, input_buf, output_buf, output_row, num_rows);
-}
-
-GLOBAL(void)
-jsimd_ycc_rgb_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf,
- int num_rows)
-{
- void (*neonfct) (JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY, int);
-
- switch (cinfo->out_color_space) {
- case JCS_EXT_RGB:
- neonfct = jsimd_ycc_extrgb_convert_neon;
- break;
- case JCS_EXT_RGBX:
- case JCS_EXT_RGBA:
- neonfct = jsimd_ycc_extrgbx_convert_neon;
- break;
- case JCS_EXT_BGR:
- neonfct = jsimd_ycc_extbgr_convert_neon;
- break;
- case JCS_EXT_BGRX:
- case JCS_EXT_BGRA:
- neonfct = jsimd_ycc_extbgrx_convert_neon;
- break;
- case JCS_EXT_XBGR:
- case JCS_EXT_ABGR:
- neonfct = jsimd_ycc_extxbgr_convert_neon;
- break;
- case JCS_EXT_XRGB:
- case JCS_EXT_ARGB:
- neonfct = jsimd_ycc_extxrgb_convert_neon;
- break;
- default:
- neonfct = jsimd_ycc_extrgb_convert_neon;
- break;
- }
-
- neonfct(cinfo->output_width, input_buf, input_row, output_buf, num_rows);
-}
-
-GLOBAL(void)
-jsimd_ycc_rgb565_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf,
- int num_rows)
-{
- jsimd_ycc_rgb565_convert_neon(cinfo->output_width, input_buf, input_row,
- output_buf, num_rows);
-}
-
-GLOBAL(int)
-jsimd_can_h2v2_downsample(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_h2v1_downsample(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(void)
-jsimd_h2v2_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY output_data)
-{
- jsimd_h2v2_downsample_neon(cinfo->image_width, cinfo->max_v_samp_factor,
- compptr->v_samp_factor, compptr->width_in_blocks,
- input_data, output_data);
-}
-
-GLOBAL(void)
-jsimd_h2v1_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY output_data)
-{
- jsimd_h2v1_downsample_neon(cinfo->image_width, cinfo->max_v_samp_factor,
- compptr->v_samp_factor, compptr->width_in_blocks,
- input_data, output_data);
-}
-
-GLOBAL(int)
-jsimd_can_h2v2_upsample(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_h2v1_upsample(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(void)
-jsimd_h2v2_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
-{
- jsimd_h2v2_upsample_neon(cinfo->max_v_samp_factor, cinfo->output_width,
- input_data, output_data_ptr);
-}
-
-GLOBAL(void)
-jsimd_h2v1_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
-{
- jsimd_h2v1_upsample_neon(cinfo->max_v_samp_factor, cinfo->output_width,
- input_data, output_data_ptr);
-}
-
-GLOBAL(int)
-jsimd_can_h2v2_fancy_upsample(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_h2v1_fancy_upsample(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_h1v2_fancy_upsample(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(void)
-jsimd_h2v2_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
-{
- jsimd_h2v2_fancy_upsample_neon(cinfo->max_v_samp_factor,
- compptr->downsampled_width, input_data,
- output_data_ptr);
-}
-
-GLOBAL(void)
-jsimd_h2v1_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
-{
- jsimd_h2v1_fancy_upsample_neon(cinfo->max_v_samp_factor,
- compptr->downsampled_width, input_data,
- output_data_ptr);
-}
-
-GLOBAL(void)
-jsimd_h1v2_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
-{
- jsimd_h1v2_fancy_upsample_neon(cinfo->max_v_samp_factor,
- compptr->downsampled_width, input_data,
- output_data_ptr);
-}
-
-GLOBAL(int)
-jsimd_can_h2v2_merged_upsample(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_h2v1_merged_upsample(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(void)
-jsimd_h2v2_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
-{
- void (*neonfct) (JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY);
-
- switch (cinfo->out_color_space) {
- case JCS_EXT_RGB:
- neonfct = jsimd_h2v2_extrgb_merged_upsample_neon;
- break;
- case JCS_EXT_RGBX:
- case JCS_EXT_RGBA:
- neonfct = jsimd_h2v2_extrgbx_merged_upsample_neon;
- break;
- case JCS_EXT_BGR:
- neonfct = jsimd_h2v2_extbgr_merged_upsample_neon;
- break;
- case JCS_EXT_BGRX:
- case JCS_EXT_BGRA:
- neonfct = jsimd_h2v2_extbgrx_merged_upsample_neon;
- break;
- case JCS_EXT_XBGR:
- case JCS_EXT_ABGR:
- neonfct = jsimd_h2v2_extxbgr_merged_upsample_neon;
- break;
- case JCS_EXT_XRGB:
- case JCS_EXT_ARGB:
- neonfct = jsimd_h2v2_extxrgb_merged_upsample_neon;
- break;
- default:
- neonfct = jsimd_h2v2_extrgb_merged_upsample_neon;
- break;
- }
-
- neonfct(cinfo->output_width, input_buf, in_row_group_ctr, output_buf);
-}
-
-GLOBAL(void)
-jsimd_h2v1_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
-{
- void (*neonfct) (JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY);
-
- switch (cinfo->out_color_space) {
- case JCS_EXT_RGB:
- neonfct = jsimd_h2v1_extrgb_merged_upsample_neon;
- break;
- case JCS_EXT_RGBX:
- case JCS_EXT_RGBA:
- neonfct = jsimd_h2v1_extrgbx_merged_upsample_neon;
- break;
- case JCS_EXT_BGR:
- neonfct = jsimd_h2v1_extbgr_merged_upsample_neon;
- break;
- case JCS_EXT_BGRX:
- case JCS_EXT_BGRA:
- neonfct = jsimd_h2v1_extbgrx_merged_upsample_neon;
- break;
- case JCS_EXT_XBGR:
- case JCS_EXT_ABGR:
- neonfct = jsimd_h2v1_extxbgr_merged_upsample_neon;
- break;
- case JCS_EXT_XRGB:
- case JCS_EXT_ARGB:
- neonfct = jsimd_h2v1_extxrgb_merged_upsample_neon;
- break;
- default:
- neonfct = jsimd_h2v1_extrgb_merged_upsample_neon;
- break;
- }
-
- neonfct(cinfo->output_width, input_buf, in_row_group_ctr, output_buf);
-}
-
-GLOBAL(int)
-jsimd_can_convsamp(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (DCTSIZE != 8)
- return 0;
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
- if (sizeof(DCTELEM) != 2)
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_convsamp_float(void)
-{
- return 0;
-}
-
-GLOBAL(void)
-jsimd_convsamp(JSAMPARRAY sample_data, JDIMENSION start_col,
- DCTELEM *workspace)
-{
- jsimd_convsamp_neon(sample_data, start_col, workspace);
-}
-
-GLOBAL(void)
-jsimd_convsamp_float(JSAMPARRAY sample_data, JDIMENSION start_col,
- FAST_FLOAT *workspace)
-{
-}
-
-GLOBAL(int)
-jsimd_can_fdct_islow(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(DCTELEM) != 2)
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_fdct_ifast(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(DCTELEM) != 2)
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_fdct_float(void)
-{
- return 0;
-}
-
-GLOBAL(void)
-jsimd_fdct_islow(DCTELEM *data)
-{
- jsimd_fdct_islow_neon(data);
-}
-
-GLOBAL(void)
-jsimd_fdct_ifast(DCTELEM *data)
-{
- jsimd_fdct_ifast_neon(data);
-}
-
-GLOBAL(void)
-jsimd_fdct_float(FAST_FLOAT *data)
-{
-}
-
-GLOBAL(int)
-jsimd_can_quantize(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JCOEF) != 2)
- return 0;
- if (sizeof(DCTELEM) != 2)
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_quantize_float(void)
-{
- return 0;
-}
-
-GLOBAL(void)
-jsimd_quantize(JCOEFPTR coef_block, DCTELEM *divisors, DCTELEM *workspace)
-{
- jsimd_quantize_neon(coef_block, divisors, workspace);
-}
-
-GLOBAL(void)
-jsimd_quantize_float(JCOEFPTR coef_block, FAST_FLOAT *divisors,
- FAST_FLOAT *workspace)
-{
-}
-
-GLOBAL(int)
-jsimd_can_idct_2x2(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JCOEF) != 2)
- return 0;
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
- if (sizeof(ISLOW_MULT_TYPE) != 2)
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_idct_4x4(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JCOEF) != 2)
- return 0;
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
- if (sizeof(ISLOW_MULT_TYPE) != 2)
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(void)
-jsimd_idct_2x2(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
- jsimd_idct_2x2_neon(compptr->dct_table, coef_block, output_buf, output_col);
-}
-
-GLOBAL(void)
-jsimd_idct_4x4(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
- jsimd_idct_4x4_neon(compptr->dct_table, coef_block, output_buf, output_col);
-}
-
-GLOBAL(int)
-jsimd_can_idct_islow(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JCOEF) != 2)
- return 0;
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
- if (sizeof(ISLOW_MULT_TYPE) != 2)
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_idct_ifast(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JCOEF) != 2)
- return 0;
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
- if (sizeof(IFAST_MULT_TYPE) != 2)
- return 0;
- if (IFAST_SCALE_BITS != 2)
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_idct_float(void)
-{
- return 0;
-}
-
-GLOBAL(void)
-jsimd_idct_islow(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
- jsimd_idct_islow_neon(compptr->dct_table, coef_block, output_buf,
- output_col);
-}
-
-GLOBAL(void)
-jsimd_idct_ifast(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
- jsimd_idct_ifast_neon(compptr->dct_table, coef_block, output_buf,
- output_col);
-}
-
-GLOBAL(void)
-jsimd_idct_float(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
-}
-
-GLOBAL(int)
-jsimd_can_huff_encode_one_block(void)
-{
- init_simd();
-
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JCOEF) != 2)
- return 0;
-
- if (simd_support & JSIMD_NEON && simd_huffman)
- return 1;
-
- return 0;
-}
-
-GLOBAL(JOCTET *)
-jsimd_huff_encode_one_block(void *state, JOCTET *buffer, JCOEFPTR block,
- int last_dc_val, c_derived_tbl *dctbl,
- c_derived_tbl *actbl)
-{
- return jsimd_huff_encode_one_block_neon(state, buffer, block, last_dc_val,
- dctbl, actbl);
-}
-
-GLOBAL(int)
-jsimd_can_encode_mcu_AC_first_prepare(void)
-{
- init_simd();
-
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JCOEF) != 2)
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(void)
-jsimd_encode_mcu_AC_first_prepare(const JCOEF *block,
- const int *jpeg_natural_order_start, int Sl,
- int Al, JCOEF *values, size_t *zerobits)
-{
- jsimd_encode_mcu_AC_first_prepare_neon(block, jpeg_natural_order_start,
- Sl, Al, values, zerobits);
-}
-
-GLOBAL(int)
-jsimd_can_encode_mcu_AC_refine_prepare(void)
-{
- init_simd();
-
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JCOEF) != 2)
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_encode_mcu_AC_refine_prepare(const JCOEF *block,
- const int *jpeg_natural_order_start, int Sl,
- int Al, JCOEF *absvalues, size_t *bits)
-{
- return jsimd_encode_mcu_AC_refine_prepare_neon(block,
- jpeg_natural_order_start, Sl,
- Al, absvalues, bits);
-}
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/aarch32/jsimd_neon.S b/contrib/libs/libjpeg-turbo/simd/arm/aarch32/jsimd_neon.S
deleted file mode 100644
index 794f0f0a93..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/arm/aarch32/jsimd_neon.S
+++ /dev/null
@@ -1,1209 +0,0 @@
-/*
- * Armv7 Neon optimizations for libjpeg-turbo
- *
- * Copyright (C) 2009-2011, Nokia Corporation and/or its subsidiary(-ies).
- * All Rights Reserved.
- * Author: Siarhei Siamashka <siarhei.siamashka@nokia.com>
- * Copyright (C) 2014, Siarhei Siamashka. All Rights Reserved.
- * Copyright (C) 2014, Linaro Limited. All Rights Reserved.
- * Copyright (C) 2015, D. R. Commander. All Rights Reserved.
- * Copyright (C) 2015-2016, 2018, Matthieu Darbois. All Rights Reserved.
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- * claim that you wrote the original software. If you use this software
- * in a product, an acknowledgment in the product documentation would be
- * appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must not be
- * misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source distribution.
- */
-
-#if defined(__linux__) && defined(__ELF__)
-.section .note.GNU-stack, "", %progbits /* mark stack as non-executable */
-#endif
-
-#if defined(__clang__) && defined(__arm__)
-#define LITE_ASM 1
-#endif
-
-.text
-#ifndef LITE_ASM
-.fpu neon
-.arch armv7a
-.object_arch armv4
-#endif
-.arm
-.syntax unified
-
-
-/*****************************************************************************/
-
-/* Supplementary macro for setting function attributes */
-.macro asm_function fname
-#ifdef __APPLE__
- .private_extern _\fname
- .globl _\fname
-_\fname:
-#else
-#ifndef LITE_ASM
- .func \fname
-#endif
- .global \fname
-#ifdef __ELF__
- .hidden \fname
- .type \fname, %function
-#endif
-\fname:
-#endif
-.endm
-
-
-#define CENTERJSAMPLE 128
-
-/*****************************************************************************/
-
-/*
- * Perform dequantization and inverse DCT on one block of coefficients.
- *
- * GLOBAL(void)
- * jsimd_idct_islow_neon(void *dct_table, JCOEFPTR coef_block,
- * JSAMPARRAY output_buf, JDIMENSION output_col)
- */
-
-#define FIX_0_298631336 (2446)
-#define FIX_0_390180644 (3196)
-#define FIX_0_541196100 (4433)
-#define FIX_0_765366865 (6270)
-#define FIX_0_899976223 (7373)
-#define FIX_1_175875602 (9633)
-#define FIX_1_501321110 (12299)
-#define FIX_1_847759065 (15137)
-#define FIX_1_961570560 (16069)
-#define FIX_2_053119869 (16819)
-#define FIX_2_562915447 (20995)
-#define FIX_3_072711026 (25172)
-
-#define FIX_1_175875602_MINUS_1_961570560 (FIX_1_175875602 - FIX_1_961570560)
-#define FIX_1_175875602_MINUS_0_390180644 (FIX_1_175875602 - FIX_0_390180644)
-#define FIX_0_541196100_MINUS_1_847759065 (FIX_0_541196100 - FIX_1_847759065)
-#define FIX_3_072711026_MINUS_2_562915447 (FIX_3_072711026 - FIX_2_562915447)
-#define FIX_0_298631336_MINUS_0_899976223 (FIX_0_298631336 - FIX_0_899976223)
-#define FIX_1_501321110_MINUS_0_899976223 (FIX_1_501321110 - FIX_0_899976223)
-#define FIX_2_053119869_MINUS_2_562915447 (FIX_2_053119869 - FIX_2_562915447)
-#define FIX_0_541196100_PLUS_0_765366865 (FIX_0_541196100 + FIX_0_765366865)
-
-/*
- * Reference SIMD-friendly 1-D ISLOW iDCT C implementation.
- * Uses some ideas from the comments in 'simd/jiss2int-64.asm'
- */
-#define REF_1D_IDCT(xrow0, xrow1, xrow2, xrow3, xrow4, xrow5, xrow6, xrow7) { \
- DCTELEM row0, row1, row2, row3, row4, row5, row6, row7; \
- JLONG q1, q2, q3, q4, q5, q6, q7; \
- JLONG tmp11_plus_tmp2, tmp11_minus_tmp2; \
- \
- /* 1-D iDCT input data */ \
- row0 = xrow0; \
- row1 = xrow1; \
- row2 = xrow2; \
- row3 = xrow3; \
- row4 = xrow4; \
- row5 = xrow5; \
- row6 = xrow6; \
- row7 = xrow7; \
- \
- q5 = row7 + row3; \
- q4 = row5 + row1; \
- q6 = MULTIPLY(q5, FIX_1_175875602_MINUS_1_961570560) + \
- MULTIPLY(q4, FIX_1_175875602); \
- q7 = MULTIPLY(q5, FIX_1_175875602) + \
- MULTIPLY(q4, FIX_1_175875602_MINUS_0_390180644); \
- q2 = MULTIPLY(row2, FIX_0_541196100) + \
- MULTIPLY(row6, FIX_0_541196100_MINUS_1_847759065); \
- q4 = q6; \
- q3 = ((JLONG)row0 - (JLONG)row4) << 13; \
- q6 += MULTIPLY(row5, -FIX_2_562915447) + \
- MULTIPLY(row3, FIX_3_072711026_MINUS_2_562915447); \
- /* now we can use q1 (reloadable constants have been used up) */ \
- q1 = q3 + q2; \
- q4 += MULTIPLY(row7, FIX_0_298631336_MINUS_0_899976223) + \
- MULTIPLY(row1, -FIX_0_899976223); \
- q5 = q7; \
- q1 = q1 + q6; \
- q7 += MULTIPLY(row7, -FIX_0_899976223) + \
- MULTIPLY(row1, FIX_1_501321110_MINUS_0_899976223); \
- \
- /* (tmp11 + tmp2) has been calculated (out_row1 before descale) */ \
- tmp11_plus_tmp2 = q1; \
- row1 = 0; \
- \
- q1 = q1 - q6; \
- q5 += MULTIPLY(row5, FIX_2_053119869_MINUS_2_562915447) + \
- MULTIPLY(row3, -FIX_2_562915447); \
- q1 = q1 - q6; \
- q6 = MULTIPLY(row2, FIX_0_541196100_PLUS_0_765366865) + \
- MULTIPLY(row6, FIX_0_541196100); \
- q3 = q3 - q2; \
- \
- /* (tmp11 - tmp2) has been calculated (out_row6 before descale) */ \
- tmp11_minus_tmp2 = q1; \
- \
- q1 = ((JLONG)row0 + (JLONG)row4) << 13; \
- q2 = q1 + q6; \
- q1 = q1 - q6; \
- \
- /* pick up the results */ \
- tmp0 = q4; \
- tmp1 = q5; \
- tmp2 = (tmp11_plus_tmp2 - tmp11_minus_tmp2) / 2; \
- tmp3 = q7; \
- tmp10 = q2; \
- tmp11 = (tmp11_plus_tmp2 + tmp11_minus_tmp2) / 2; \
- tmp12 = q3; \
- tmp13 = q1; \
-}
-
-#define XFIX_0_899976223 d0[0]
-#define XFIX_0_541196100 d0[1]
-#define XFIX_2_562915447 d0[2]
-#define XFIX_0_298631336_MINUS_0_899976223 d0[3]
-#define XFIX_1_501321110_MINUS_0_899976223 d1[0]
-#define XFIX_2_053119869_MINUS_2_562915447 d1[1]
-#define XFIX_0_541196100_PLUS_0_765366865 d1[2]
-#define XFIX_1_175875602 d1[3]
-#define XFIX_1_175875602_MINUS_0_390180644 d2[0]
-#define XFIX_0_541196100_MINUS_1_847759065 d2[1]
-#define XFIX_3_072711026_MINUS_2_562915447 d2[2]
-#define XFIX_1_175875602_MINUS_1_961570560 d2[3]
-
-.balign 16
-jsimd_idct_islow_neon_consts:
- .short FIX_0_899976223 /* d0[0] */
- .short FIX_0_541196100 /* d0[1] */
- .short FIX_2_562915447 /* d0[2] */
- .short FIX_0_298631336_MINUS_0_899976223 /* d0[3] */
- .short FIX_1_501321110_MINUS_0_899976223 /* d1[0] */
- .short FIX_2_053119869_MINUS_2_562915447 /* d1[1] */
- .short FIX_0_541196100_PLUS_0_765366865 /* d1[2] */
- .short FIX_1_175875602 /* d1[3] */
- /* reloadable constants */
- .short FIX_1_175875602_MINUS_0_390180644 /* d2[0] */
- .short FIX_0_541196100_MINUS_1_847759065 /* d2[1] */
- .short FIX_3_072711026_MINUS_2_562915447 /* d2[2] */
- .short FIX_1_175875602_MINUS_1_961570560 /* d2[3] */
-
-asm_function jsimd_idct_islow_neon
-
- DCT_TABLE .req r0
- COEF_BLOCK .req r1
- OUTPUT_BUF .req r2
- OUTPUT_COL .req r3
- TMP1 .req r0
- TMP2 .req r1
- TMP3 .req r2
- TMP4 .req ip
-
- ROW0L .req d16
- ROW0R .req d17
- ROW1L .req d18
- ROW1R .req d19
- ROW2L .req d20
- ROW2R .req d21
- ROW3L .req d22
- ROW3R .req d23
- ROW4L .req d24
- ROW4R .req d25
- ROW5L .req d26
- ROW5R .req d27
- ROW6L .req d28
- ROW6R .req d29
- ROW7L .req d30
- ROW7R .req d31
-
- /* Load and dequantize coefficients into Neon registers
- * with the following allocation:
- * 0 1 2 3 | 4 5 6 7
- * ---------+--------
- * 0 | d16 | d17 ( q8 )
- * 1 | d18 | d19 ( q9 )
- * 2 | d20 | d21 ( q10 )
- * 3 | d22 | d23 ( q11 )
- * 4 | d24 | d25 ( q12 )
- * 5 | d26 | d27 ( q13 )
- * 6 | d28 | d29 ( q14 )
- * 7 | d30 | d31 ( q15 )
- */
- adr ip, jsimd_idct_islow_neon_consts
- vld1.16 {d16, d17, d18, d19}, [COEF_BLOCK, :128]!
- vld1.16 {d0, d1, d2, d3}, [DCT_TABLE, :128]!
- vld1.16 {d20, d21, d22, d23}, [COEF_BLOCK, :128]!
- vmul.s16 q8, q8, q0
- vld1.16 {d4, d5, d6, d7}, [DCT_TABLE, :128]!
- vmul.s16 q9, q9, q1
- vld1.16 {d24, d25, d26, d27}, [COEF_BLOCK, :128]!
- vmul.s16 q10, q10, q2
- vld1.16 {d0, d1, d2, d3}, [DCT_TABLE, :128]!
- vmul.s16 q11, q11, q3
- vld1.16 {d28, d29, d30, d31}, [COEF_BLOCK, :128]
- vmul.s16 q12, q12, q0
- vld1.16 {d4, d5, d6, d7}, [DCT_TABLE, :128]!
- vmul.s16 q14, q14, q2
- vmul.s16 q13, q13, q1
- vld1.16 {d0, d1, d2, d3}, [ip, :128] /* load constants */
- add ip, ip, #16
- vmul.s16 q15, q15, q3
- vpush {d8 - d15} /* save Neon registers */
- /* 1-D IDCT, pass 1, left 4x8 half */
- vadd.s16 d4, ROW7L, ROW3L
- vadd.s16 d5, ROW5L, ROW1L
- vmull.s16 q6, d4, XFIX_1_175875602_MINUS_1_961570560
- vmlal.s16 q6, d5, XFIX_1_175875602
- vmull.s16 q7, d4, XFIX_1_175875602
- /* Check for the zero coefficients in the right 4x8 half */
- push {r4, r5}
- vmlal.s16 q7, d5, XFIX_1_175875602_MINUS_0_390180644
- vsubl.s16 q3, ROW0L, ROW4L
- ldrd r4, [COEF_BLOCK, #(-96 + 2 * (4 + 1 * 8))]
- vmull.s16 q2, ROW2L, XFIX_0_541196100
- vmlal.s16 q2, ROW6L, XFIX_0_541196100_MINUS_1_847759065
- orr r0, r4, r5
- vmov q4, q6
- vmlsl.s16 q6, ROW5L, XFIX_2_562915447
- ldrd r4, [COEF_BLOCK, #(-96 + 2 * (4 + 2 * 8))]
- vmlal.s16 q6, ROW3L, XFIX_3_072711026_MINUS_2_562915447
- vshl.s32 q3, q3, #13
- orr r0, r0, r4
- vmlsl.s16 q4, ROW1L, XFIX_0_899976223
- orr r0, r0, r5
- vadd.s32 q1, q3, q2
- ldrd r4, [COEF_BLOCK, #(-96 + 2 * (4 + 3 * 8))]
- vmov q5, q7
- vadd.s32 q1, q1, q6
- orr r0, r0, r4
- vmlsl.s16 q7, ROW7L, XFIX_0_899976223
- orr r0, r0, r5
- vmlal.s16 q7, ROW1L, XFIX_1_501321110_MINUS_0_899976223
- vrshrn.s32 ROW1L, q1, #11
- ldrd r4, [COEF_BLOCK, #(-96 + 2 * (4 + 4 * 8))]
- vsub.s32 q1, q1, q6
- vmlal.s16 q5, ROW5L, XFIX_2_053119869_MINUS_2_562915447
- orr r0, r0, r4
- vmlsl.s16 q5, ROW3L, XFIX_2_562915447
- orr r0, r0, r5
- vsub.s32 q1, q1, q6
- vmull.s16 q6, ROW2L, XFIX_0_541196100_PLUS_0_765366865
- ldrd r4, [COEF_BLOCK, #(-96 + 2 * (4 + 5 * 8))]
- vmlal.s16 q6, ROW6L, XFIX_0_541196100
- vsub.s32 q3, q3, q2
- orr r0, r0, r4
- vrshrn.s32 ROW6L, q1, #11
- orr r0, r0, r5
- vadd.s32 q1, q3, q5
- ldrd r4, [COEF_BLOCK, #(-96 + 2 * (4 + 6 * 8))]
- vsub.s32 q3, q3, q5
- vaddl.s16 q5, ROW0L, ROW4L
- orr r0, r0, r4
- vrshrn.s32 ROW2L, q1, #11
- orr r0, r0, r5
- vrshrn.s32 ROW5L, q3, #11
- ldrd r4, [COEF_BLOCK, #(-96 + 2 * (4 + 7 * 8))]
- vshl.s32 q5, q5, #13
- vmlal.s16 q4, ROW7L, XFIX_0_298631336_MINUS_0_899976223
- orr r0, r0, r4
- vadd.s32 q2, q5, q6
- orrs r0, r0, r5
- vsub.s32 q1, q5, q6
- vadd.s32 q6, q2, q7
- ldrd r4, [COEF_BLOCK, #(-96 + 2 * (4 + 0 * 8))]
- vsub.s32 q2, q2, q7
- vadd.s32 q5, q1, q4
- orr r0, r4, r5
- vsub.s32 q3, q1, q4
- pop {r4, r5}
- vrshrn.s32 ROW7L, q2, #11
- vrshrn.s32 ROW3L, q5, #11
- vrshrn.s32 ROW0L, q6, #11
- vrshrn.s32 ROW4L, q3, #11
-
- beq 3f /* Go to do some special handling for the sparse
- right 4x8 half */
-
- /* 1-D IDCT, pass 1, right 4x8 half */
- vld1.s16 {d2}, [ip, :64] /* reload constants */
- vadd.s16 d10, ROW7R, ROW3R
- vadd.s16 d8, ROW5R, ROW1R
- /* Transpose left 4x8 half */
- vtrn.16 ROW6L, ROW7L
- vmull.s16 q6, d10, XFIX_1_175875602_MINUS_1_961570560
- vmlal.s16 q6, d8, XFIX_1_175875602
- vtrn.16 ROW2L, ROW3L
- vmull.s16 q7, d10, XFIX_1_175875602
- vmlal.s16 q7, d8, XFIX_1_175875602_MINUS_0_390180644
- vtrn.16 ROW0L, ROW1L
- vsubl.s16 q3, ROW0R, ROW4R
- vmull.s16 q2, ROW2R, XFIX_0_541196100
- vmlal.s16 q2, ROW6R, XFIX_0_541196100_MINUS_1_847759065
- vtrn.16 ROW4L, ROW5L
- vmov q4, q6
- vmlsl.s16 q6, ROW5R, XFIX_2_562915447
- vmlal.s16 q6, ROW3R, XFIX_3_072711026_MINUS_2_562915447
- vtrn.32 ROW1L, ROW3L
- vshl.s32 q3, q3, #13
- vmlsl.s16 q4, ROW1R, XFIX_0_899976223
- vtrn.32 ROW4L, ROW6L
- vadd.s32 q1, q3, q2
- vmov q5, q7
- vadd.s32 q1, q1, q6
- vtrn.32 ROW0L, ROW2L
- vmlsl.s16 q7, ROW7R, XFIX_0_899976223
- vmlal.s16 q7, ROW1R, XFIX_1_501321110_MINUS_0_899976223
- vrshrn.s32 ROW1R, q1, #11
- vtrn.32 ROW5L, ROW7L
- vsub.s32 q1, q1, q6
- vmlal.s16 q5, ROW5R, XFIX_2_053119869_MINUS_2_562915447
- vmlsl.s16 q5, ROW3R, XFIX_2_562915447
- vsub.s32 q1, q1, q6
- vmull.s16 q6, ROW2R, XFIX_0_541196100_PLUS_0_765366865
- vmlal.s16 q6, ROW6R, XFIX_0_541196100
- vsub.s32 q3, q3, q2
- vrshrn.s32 ROW6R, q1, #11
- vadd.s32 q1, q3, q5
- vsub.s32 q3, q3, q5
- vaddl.s16 q5, ROW0R, ROW4R
- vrshrn.s32 ROW2R, q1, #11
- vrshrn.s32 ROW5R, q3, #11
- vshl.s32 q5, q5, #13
- vmlal.s16 q4, ROW7R, XFIX_0_298631336_MINUS_0_899976223
- vadd.s32 q2, q5, q6
- vsub.s32 q1, q5, q6
- vadd.s32 q6, q2, q7
- vsub.s32 q2, q2, q7
- vadd.s32 q5, q1, q4
- vsub.s32 q3, q1, q4
- vrshrn.s32 ROW7R, q2, #11
- vrshrn.s32 ROW3R, q5, #11
- vrshrn.s32 ROW0R, q6, #11
- vrshrn.s32 ROW4R, q3, #11
- /* Transpose right 4x8 half */
- vtrn.16 ROW6R, ROW7R
- vtrn.16 ROW2R, ROW3R
- vtrn.16 ROW0R, ROW1R
- vtrn.16 ROW4R, ROW5R
- vtrn.32 ROW1R, ROW3R
- vtrn.32 ROW4R, ROW6R
- vtrn.32 ROW0R, ROW2R
- vtrn.32 ROW5R, ROW7R
-
-1: /* 1-D IDCT, pass 2 (normal variant), left 4x8 half */
- vld1.s16 {d2}, [ip, :64] /* reload constants */
- vmull.s16 q6, ROW1R, XFIX_1_175875602 /* ROW5L <-> ROW1R */
- vmlal.s16 q6, ROW1L, XFIX_1_175875602
- vmlal.s16 q6, ROW3R, XFIX_1_175875602_MINUS_1_961570560 /* ROW7L <-> ROW3R */
- vmlal.s16 q6, ROW3L, XFIX_1_175875602_MINUS_1_961570560
- vmull.s16 q7, ROW3R, XFIX_1_175875602 /* ROW7L <-> ROW3R */
- vmlal.s16 q7, ROW3L, XFIX_1_175875602
- vmlal.s16 q7, ROW1R, XFIX_1_175875602_MINUS_0_390180644 /* ROW5L <-> ROW1R */
- vmlal.s16 q7, ROW1L, XFIX_1_175875602_MINUS_0_390180644
- vsubl.s16 q3, ROW0L, ROW0R /* ROW4L <-> ROW0R */
- vmull.s16 q2, ROW2L, XFIX_0_541196100
- vmlal.s16 q2, ROW2R, XFIX_0_541196100_MINUS_1_847759065 /* ROW6L <-> ROW2R */
- vmov q4, q6
- vmlsl.s16 q6, ROW1R, XFIX_2_562915447 /* ROW5L <-> ROW1R */
- vmlal.s16 q6, ROW3L, XFIX_3_072711026_MINUS_2_562915447
- vshl.s32 q3, q3, #13
- vmlsl.s16 q4, ROW1L, XFIX_0_899976223
- vadd.s32 q1, q3, q2
- vmov q5, q7
- vadd.s32 q1, q1, q6
- vmlsl.s16 q7, ROW3R, XFIX_0_899976223 /* ROW7L <-> ROW3R */
- vmlal.s16 q7, ROW1L, XFIX_1_501321110_MINUS_0_899976223
- vshrn.s32 ROW1L, q1, #16
- vsub.s32 q1, q1, q6
- vmlal.s16 q5, ROW1R, XFIX_2_053119869_MINUS_2_562915447 /* ROW5L <-> ROW1R */
- vmlsl.s16 q5, ROW3L, XFIX_2_562915447
- vsub.s32 q1, q1, q6
- vmull.s16 q6, ROW2L, XFIX_0_541196100_PLUS_0_765366865
- vmlal.s16 q6, ROW2R, XFIX_0_541196100 /* ROW6L <-> ROW2R */
- vsub.s32 q3, q3, q2
- vshrn.s32 ROW2R, q1, #16 /* ROW6L <-> ROW2R */
- vadd.s32 q1, q3, q5
- vsub.s32 q3, q3, q5
- vaddl.s16 q5, ROW0L, ROW0R /* ROW4L <-> ROW0R */
- vshrn.s32 ROW2L, q1, #16
- vshrn.s32 ROW1R, q3, #16 /* ROW5L <-> ROW1R */
- vshl.s32 q5, q5, #13
- vmlal.s16 q4, ROW3R, XFIX_0_298631336_MINUS_0_899976223 /* ROW7L <-> ROW3R */
- vadd.s32 q2, q5, q6
- vsub.s32 q1, q5, q6
- vadd.s32 q6, q2, q7
- vsub.s32 q2, q2, q7
- vadd.s32 q5, q1, q4
- vsub.s32 q3, q1, q4
- vshrn.s32 ROW3R, q2, #16 /* ROW7L <-> ROW3R */
- vshrn.s32 ROW3L, q5, #16
- vshrn.s32 ROW0L, q6, #16
- vshrn.s32 ROW0R, q3, #16 /* ROW4L <-> ROW0R */
- /* 1-D IDCT, pass 2, right 4x8 half */
- vld1.s16 {d2}, [ip, :64] /* reload constants */
- vmull.s16 q6, ROW5R, XFIX_1_175875602
- vmlal.s16 q6, ROW5L, XFIX_1_175875602 /* ROW5L <-> ROW1R */
- vmlal.s16 q6, ROW7R, XFIX_1_175875602_MINUS_1_961570560
- vmlal.s16 q6, ROW7L, XFIX_1_175875602_MINUS_1_961570560 /* ROW7L <-> ROW3R */
- vmull.s16 q7, ROW7R, XFIX_1_175875602
- vmlal.s16 q7, ROW7L, XFIX_1_175875602 /* ROW7L <-> ROW3R */
- vmlal.s16 q7, ROW5R, XFIX_1_175875602_MINUS_0_390180644
- vmlal.s16 q7, ROW5L, XFIX_1_175875602_MINUS_0_390180644 /* ROW5L <-> ROW1R */
- vsubl.s16 q3, ROW4L, ROW4R /* ROW4L <-> ROW0R */
- vmull.s16 q2, ROW6L, XFIX_0_541196100 /* ROW6L <-> ROW2R */
- vmlal.s16 q2, ROW6R, XFIX_0_541196100_MINUS_1_847759065
- vmov q4, q6
- vmlsl.s16 q6, ROW5R, XFIX_2_562915447
- vmlal.s16 q6, ROW7L, XFIX_3_072711026_MINUS_2_562915447 /* ROW7L <-> ROW3R */
- vshl.s32 q3, q3, #13
- vmlsl.s16 q4, ROW5L, XFIX_0_899976223 /* ROW5L <-> ROW1R */
- vadd.s32 q1, q3, q2
- vmov q5, q7
- vadd.s32 q1, q1, q6
- vmlsl.s16 q7, ROW7R, XFIX_0_899976223
- vmlal.s16 q7, ROW5L, XFIX_1_501321110_MINUS_0_899976223 /* ROW5L <-> ROW1R */
- vshrn.s32 ROW5L, q1, #16 /* ROW5L <-> ROW1R */
- vsub.s32 q1, q1, q6
- vmlal.s16 q5, ROW5R, XFIX_2_053119869_MINUS_2_562915447
- vmlsl.s16 q5, ROW7L, XFIX_2_562915447 /* ROW7L <-> ROW3R */
- vsub.s32 q1, q1, q6
- vmull.s16 q6, ROW6L, XFIX_0_541196100_PLUS_0_765366865 /* ROW6L <-> ROW2R */
- vmlal.s16 q6, ROW6R, XFIX_0_541196100
- vsub.s32 q3, q3, q2
- vshrn.s32 ROW6R, q1, #16
- vadd.s32 q1, q3, q5
- vsub.s32 q3, q3, q5
- vaddl.s16 q5, ROW4L, ROW4R /* ROW4L <-> ROW0R */
- vshrn.s32 ROW6L, q1, #16 /* ROW6L <-> ROW2R */
- vshrn.s32 ROW5R, q3, #16
- vshl.s32 q5, q5, #13
- vmlal.s16 q4, ROW7R, XFIX_0_298631336_MINUS_0_899976223
- vadd.s32 q2, q5, q6
- vsub.s32 q1, q5, q6
- vadd.s32 q6, q2, q7
- vsub.s32 q2, q2, q7
- vadd.s32 q5, q1, q4
- vsub.s32 q3, q1, q4
- vshrn.s32 ROW7R, q2, #16
- vshrn.s32 ROW7L, q5, #16 /* ROW7L <-> ROW3R */
- vshrn.s32 ROW4L, q6, #16 /* ROW4L <-> ROW0R */
- vshrn.s32 ROW4R, q3, #16
-
-2: /* Descale to 8-bit and range limit */
- vqrshrn.s16 d16, q8, #2
- vqrshrn.s16 d17, q9, #2
- vqrshrn.s16 d18, q10, #2
- vqrshrn.s16 d19, q11, #2
- vpop {d8 - d15} /* restore Neon registers */
- vqrshrn.s16 d20, q12, #2
- /* Transpose the final 8-bit samples and do signed->unsigned conversion */
- vtrn.16 q8, q9
- vqrshrn.s16 d21, q13, #2
- vqrshrn.s16 d22, q14, #2
- vmov.u8 q0, #(CENTERJSAMPLE)
- vqrshrn.s16 d23, q15, #2
- vtrn.8 d16, d17
- vtrn.8 d18, d19
- vadd.u8 q8, q8, q0
- vadd.u8 q9, q9, q0
- vtrn.16 q10, q11
- /* Store results to the output buffer */
- ldmia OUTPUT_BUF!, {TMP1, TMP2}
- add TMP1, TMP1, OUTPUT_COL
- add TMP2, TMP2, OUTPUT_COL
- vst1.8 {d16}, [TMP1]
- vtrn.8 d20, d21
- vst1.8 {d17}, [TMP2]
- ldmia OUTPUT_BUF!, {TMP1, TMP2}
- add TMP1, TMP1, OUTPUT_COL
- add TMP2, TMP2, OUTPUT_COL
- vst1.8 {d18}, [TMP1]
- vadd.u8 q10, q10, q0
- vst1.8 {d19}, [TMP2]
- ldmia OUTPUT_BUF, {TMP1, TMP2, TMP3, TMP4}
- add TMP1, TMP1, OUTPUT_COL
- add TMP2, TMP2, OUTPUT_COL
- add TMP3, TMP3, OUTPUT_COL
- add TMP4, TMP4, OUTPUT_COL
- vtrn.8 d22, d23
- vst1.8 {d20}, [TMP1]
- vadd.u8 q11, q11, q0
- vst1.8 {d21}, [TMP2]
- vst1.8 {d22}, [TMP3]
- vst1.8 {d23}, [TMP4]
- bx lr
-
-3: /* Left 4x8 half is done, right 4x8 half contains mostly zeros */
-
- /* Transpose left 4x8 half */
- vtrn.16 ROW6L, ROW7L
- vtrn.16 ROW2L, ROW3L
- vtrn.16 ROW0L, ROW1L
- vtrn.16 ROW4L, ROW5L
- vshl.s16 ROW0R, ROW0R, #2 /* PASS1_BITS */
- vtrn.32 ROW1L, ROW3L
- vtrn.32 ROW4L, ROW6L
- vtrn.32 ROW0L, ROW2L
- vtrn.32 ROW5L, ROW7L
-
- cmp r0, #0
- beq 4f /* Right 4x8 half has all zeros, go to 'sparse' second
- pass */
-
- /* Only row 0 is non-zero for the right 4x8 half */
- vdup.s16 ROW1R, ROW0R[1]
- vdup.s16 ROW2R, ROW0R[2]
- vdup.s16 ROW3R, ROW0R[3]
- vdup.s16 ROW4R, ROW0R[0]
- vdup.s16 ROW5R, ROW0R[1]
- vdup.s16 ROW6R, ROW0R[2]
- vdup.s16 ROW7R, ROW0R[3]
- vdup.s16 ROW0R, ROW0R[0]
- b 1b /* Go to 'normal' second pass */
-
-4: /* 1-D IDCT, pass 2 (sparse variant with zero rows 4-7), left 4x8 half */
- vld1.s16 {d2}, [ip, :64] /* reload constants */
- vmull.s16 q6, ROW1L, XFIX_1_175875602
- vmlal.s16 q6, ROW3L, XFIX_1_175875602_MINUS_1_961570560
- vmull.s16 q7, ROW3L, XFIX_1_175875602
- vmlal.s16 q7, ROW1L, XFIX_1_175875602_MINUS_0_390180644
- vmull.s16 q2, ROW2L, XFIX_0_541196100
- vshll.s16 q3, ROW0L, #13
- vmov q4, q6
- vmlal.s16 q6, ROW3L, XFIX_3_072711026_MINUS_2_562915447
- vmlsl.s16 q4, ROW1L, XFIX_0_899976223
- vadd.s32 q1, q3, q2
- vmov q5, q7
- vmlal.s16 q7, ROW1L, XFIX_1_501321110_MINUS_0_899976223
- vadd.s32 q1, q1, q6
- vadd.s32 q6, q6, q6
- vmlsl.s16 q5, ROW3L, XFIX_2_562915447
- vshrn.s32 ROW1L, q1, #16
- vsub.s32 q1, q1, q6
- vmull.s16 q6, ROW2L, XFIX_0_541196100_PLUS_0_765366865
- vsub.s32 q3, q3, q2
- vshrn.s32 ROW2R, q1, #16 /* ROW6L <-> ROW2R */
- vadd.s32 q1, q3, q5
- vsub.s32 q3, q3, q5
- vshll.s16 q5, ROW0L, #13
- vshrn.s32 ROW2L, q1, #16
- vshrn.s32 ROW1R, q3, #16 /* ROW5L <-> ROW1R */
- vadd.s32 q2, q5, q6
- vsub.s32 q1, q5, q6
- vadd.s32 q6, q2, q7
- vsub.s32 q2, q2, q7
- vadd.s32 q5, q1, q4
- vsub.s32 q3, q1, q4
- vshrn.s32 ROW3R, q2, #16 /* ROW7L <-> ROW3R */
- vshrn.s32 ROW3L, q5, #16
- vshrn.s32 ROW0L, q6, #16
- vshrn.s32 ROW0R, q3, #16 /* ROW4L <-> ROW0R */
- /* 1-D IDCT, pass 2 (sparse variant with zero rows 4-7), right 4x8 half */
- vld1.s16 {d2}, [ip, :64] /* reload constants */
- vmull.s16 q6, ROW5L, XFIX_1_175875602
- vmlal.s16 q6, ROW7L, XFIX_1_175875602_MINUS_1_961570560
- vmull.s16 q7, ROW7L, XFIX_1_175875602
- vmlal.s16 q7, ROW5L, XFIX_1_175875602_MINUS_0_390180644
- vmull.s16 q2, ROW6L, XFIX_0_541196100
- vshll.s16 q3, ROW4L, #13
- vmov q4, q6
- vmlal.s16 q6, ROW7L, XFIX_3_072711026_MINUS_2_562915447
- vmlsl.s16 q4, ROW5L, XFIX_0_899976223
- vadd.s32 q1, q3, q2
- vmov q5, q7
- vmlal.s16 q7, ROW5L, XFIX_1_501321110_MINUS_0_899976223
- vadd.s32 q1, q1, q6
- vadd.s32 q6, q6, q6
- vmlsl.s16 q5, ROW7L, XFIX_2_562915447
- vshrn.s32 ROW5L, q1, #16 /* ROW5L <-> ROW1R */
- vsub.s32 q1, q1, q6
- vmull.s16 q6, ROW6L, XFIX_0_541196100_PLUS_0_765366865
- vsub.s32 q3, q3, q2
- vshrn.s32 ROW6R, q1, #16
- vadd.s32 q1, q3, q5
- vsub.s32 q3, q3, q5
- vshll.s16 q5, ROW4L, #13
- vshrn.s32 ROW6L, q1, #16 /* ROW6L <-> ROW2R */
- vshrn.s32 ROW5R, q3, #16
- vadd.s32 q2, q5, q6
- vsub.s32 q1, q5, q6
- vadd.s32 q6, q2, q7
- vsub.s32 q2, q2, q7
- vadd.s32 q5, q1, q4
- vsub.s32 q3, q1, q4
- vshrn.s32 ROW7R, q2, #16
- vshrn.s32 ROW7L, q5, #16 /* ROW7L <-> ROW3R */
- vshrn.s32 ROW4L, q6, #16 /* ROW4L <-> ROW0R */
- vshrn.s32 ROW4R, q3, #16
- b 2b /* Go to epilogue */
-
- .unreq DCT_TABLE
- .unreq COEF_BLOCK
- .unreq OUTPUT_BUF
- .unreq OUTPUT_COL
- .unreq TMP1
- .unreq TMP2
- .unreq TMP3
- .unreq TMP4
-
- .unreq ROW0L
- .unreq ROW0R
- .unreq ROW1L
- .unreq ROW1R
- .unreq ROW2L
- .unreq ROW2R
- .unreq ROW3L
- .unreq ROW3R
- .unreq ROW4L
- .unreq ROW4R
- .unreq ROW5L
- .unreq ROW5R
- .unreq ROW6L
- .unreq ROW6R
- .unreq ROW7L
- .unreq ROW7R
-
-
-/*****************************************************************************/
-
-/*
- * jsimd_idct_ifast_neon
- *
- * This function contains a fast, not so accurate integer implementation of
- * the inverse DCT (Discrete Cosine Transform). It uses the same calculations
- * and produces exactly the same output as IJG's original 'jpeg_idct_ifast'
- * function from jidctfst.c
- *
- * Normally 1-D AAN DCT needs 5 multiplications and 29 additions.
- * But in Arm Neon case some extra additions are required because VQDMULH
- * instruction can't handle the constants larger than 1. So the expressions
- * like "x * 1.082392200" have to be converted to "x * 0.082392200 + x",
- * which introduces an extra addition. Overall, there are 6 extra additions
- * per 1-D IDCT pass, totalling to 5 VQDMULH and 35 VADD/VSUB instructions.
- */
-
-#define XFIX_1_082392200 d0[0]
-#define XFIX_1_414213562 d0[1]
-#define XFIX_1_847759065 d0[2]
-#define XFIX_2_613125930 d0[3]
-
-.balign 16
-jsimd_idct_ifast_neon_consts:
- .short (277 * 128 - 256 * 128) /* XFIX_1_082392200 */
- .short (362 * 128 - 256 * 128) /* XFIX_1_414213562 */
- .short (473 * 128 - 256 * 128) /* XFIX_1_847759065 */
- .short (669 * 128 - 512 * 128) /* XFIX_2_613125930 */
-
-asm_function jsimd_idct_ifast_neon
-
- DCT_TABLE .req r0
- COEF_BLOCK .req r1
- OUTPUT_BUF .req r2
- OUTPUT_COL .req r3
- TMP1 .req r0
- TMP2 .req r1
- TMP3 .req r2
- TMP4 .req ip
-
- /* Load and dequantize coefficients into Neon registers
- * with the following allocation:
- * 0 1 2 3 | 4 5 6 7
- * ---------+--------
- * 0 | d16 | d17 ( q8 )
- * 1 | d18 | d19 ( q9 )
- * 2 | d20 | d21 ( q10 )
- * 3 | d22 | d23 ( q11 )
- * 4 | d24 | d25 ( q12 )
- * 5 | d26 | d27 ( q13 )
- * 6 | d28 | d29 ( q14 )
- * 7 | d30 | d31 ( q15 )
- */
- adr ip, jsimd_idct_ifast_neon_consts
- vld1.16 {d16, d17, d18, d19}, [COEF_BLOCK, :128]!
- vld1.16 {d0, d1, d2, d3}, [DCT_TABLE, :128]!
- vld1.16 {d20, d21, d22, d23}, [COEF_BLOCK, :128]!
- vmul.s16 q8, q8, q0
- vld1.16 {d4, d5, d6, d7}, [DCT_TABLE, :128]!
- vmul.s16 q9, q9, q1
- vld1.16 {d24, d25, d26, d27}, [COEF_BLOCK, :128]!
- vmul.s16 q10, q10, q2
- vld1.16 {d0, d1, d2, d3}, [DCT_TABLE, :128]!
- vmul.s16 q11, q11, q3
- vld1.16 {d28, d29, d30, d31}, [COEF_BLOCK, :128]
- vmul.s16 q12, q12, q0
- vld1.16 {d4, d5, d6, d7}, [DCT_TABLE, :128]!
- vmul.s16 q14, q14, q2
- vmul.s16 q13, q13, q1
- vld1.16 {d0}, [ip, :64] /* load constants */
- vmul.s16 q15, q15, q3
- vpush {d8 - d13} /* save Neon registers */
- /* 1-D IDCT, pass 1 */
- vsub.s16 q2, q10, q14
- vadd.s16 q14, q10, q14
- vsub.s16 q1, q11, q13
- vadd.s16 q13, q11, q13
- vsub.s16 q5, q9, q15
- vadd.s16 q15, q9, q15
- vqdmulh.s16 q4, q2, XFIX_1_414213562
- vqdmulh.s16 q6, q1, XFIX_2_613125930
- vadd.s16 q3, q1, q1
- vsub.s16 q1, q5, q1
- vadd.s16 q10, q2, q4
- vqdmulh.s16 q4, q1, XFIX_1_847759065
- vsub.s16 q2, q15, q13
- vadd.s16 q3, q3, q6
- vqdmulh.s16 q6, q2, XFIX_1_414213562
- vadd.s16 q1, q1, q4
- vqdmulh.s16 q4, q5, XFIX_1_082392200
- vsub.s16 q10, q10, q14
- vadd.s16 q2, q2, q6
- vsub.s16 q6, q8, q12
- vadd.s16 q12, q8, q12
- vadd.s16 q9, q5, q4
- vadd.s16 q5, q6, q10
- vsub.s16 q10, q6, q10
- vadd.s16 q6, q15, q13
- vadd.s16 q8, q12, q14
- vsub.s16 q3, q6, q3
- vsub.s16 q12, q12, q14
- vsub.s16 q3, q3, q1
- vsub.s16 q1, q9, q1
- vadd.s16 q2, q3, q2
- vsub.s16 q15, q8, q6
- vadd.s16 q1, q1, q2
- vadd.s16 q8, q8, q6
- vadd.s16 q14, q5, q3
- vsub.s16 q9, q5, q3
- vsub.s16 q13, q10, q2
- vadd.s16 q10, q10, q2
- /* Transpose */
- vtrn.16 q8, q9
- vsub.s16 q11, q12, q1
- vtrn.16 q14, q15
- vadd.s16 q12, q12, q1
- vtrn.16 q10, q11
- vtrn.16 q12, q13
- vtrn.32 q9, q11
- vtrn.32 q12, q14
- vtrn.32 q8, q10
- vtrn.32 q13, q15
- vswp d28, d21
- vswp d26, d19
- /* 1-D IDCT, pass 2 */
- vsub.s16 q2, q10, q14
- vswp d30, d23
- vadd.s16 q14, q10, q14
- vswp d24, d17
- vsub.s16 q1, q11, q13
- vadd.s16 q13, q11, q13
- vsub.s16 q5, q9, q15
- vadd.s16 q15, q9, q15
- vqdmulh.s16 q4, q2, XFIX_1_414213562
- vqdmulh.s16 q6, q1, XFIX_2_613125930
- vadd.s16 q3, q1, q1
- vsub.s16 q1, q5, q1
- vadd.s16 q10, q2, q4
- vqdmulh.s16 q4, q1, XFIX_1_847759065
- vsub.s16 q2, q15, q13
- vadd.s16 q3, q3, q6
- vqdmulh.s16 q6, q2, XFIX_1_414213562
- vadd.s16 q1, q1, q4
- vqdmulh.s16 q4, q5, XFIX_1_082392200
- vsub.s16 q10, q10, q14
- vadd.s16 q2, q2, q6
- vsub.s16 q6, q8, q12
- vadd.s16 q12, q8, q12
- vadd.s16 q9, q5, q4
- vadd.s16 q5, q6, q10
- vsub.s16 q10, q6, q10
- vadd.s16 q6, q15, q13
- vadd.s16 q8, q12, q14
- vsub.s16 q3, q6, q3
- vsub.s16 q12, q12, q14
- vsub.s16 q3, q3, q1
- vsub.s16 q1, q9, q1
- vadd.s16 q2, q3, q2
- vsub.s16 q15, q8, q6
- vadd.s16 q1, q1, q2
- vadd.s16 q8, q8, q6
- vadd.s16 q14, q5, q3
- vsub.s16 q9, q5, q3
- vsub.s16 q13, q10, q2
- vpop {d8 - d13} /* restore Neon registers */
- vadd.s16 q10, q10, q2
- vsub.s16 q11, q12, q1
- vadd.s16 q12, q12, q1
- /* Descale to 8-bit and range limit */
- vmov.u8 q0, #0x80
- vqshrn.s16 d16, q8, #5
- vqshrn.s16 d17, q9, #5
- vqshrn.s16 d18, q10, #5
- vqshrn.s16 d19, q11, #5
- vqshrn.s16 d20, q12, #5
- vqshrn.s16 d21, q13, #5
- vqshrn.s16 d22, q14, #5
- vqshrn.s16 d23, q15, #5
- vadd.u8 q8, q8, q0
- vadd.u8 q9, q9, q0
- vadd.u8 q10, q10, q0
- vadd.u8 q11, q11, q0
- /* Transpose the final 8-bit samples */
- vtrn.16 q8, q9
- vtrn.16 q10, q11
- vtrn.32 q8, q10
- vtrn.32 q9, q11
- vtrn.8 d16, d17
- vtrn.8 d18, d19
- /* Store results to the output buffer */
- ldmia OUTPUT_BUF!, {TMP1, TMP2}
- add TMP1, TMP1, OUTPUT_COL
- add TMP2, TMP2, OUTPUT_COL
- vst1.8 {d16}, [TMP1]
- vst1.8 {d17}, [TMP2]
- ldmia OUTPUT_BUF!, {TMP1, TMP2}
- add TMP1, TMP1, OUTPUT_COL
- add TMP2, TMP2, OUTPUT_COL
- vst1.8 {d18}, [TMP1]
- vtrn.8 d20, d21
- vst1.8 {d19}, [TMP2]
- ldmia OUTPUT_BUF, {TMP1, TMP2, TMP3, TMP4}
- add TMP1, TMP1, OUTPUT_COL
- add TMP2, TMP2, OUTPUT_COL
- add TMP3, TMP3, OUTPUT_COL
- add TMP4, TMP4, OUTPUT_COL
- vst1.8 {d20}, [TMP1]
- vtrn.8 d22, d23
- vst1.8 {d21}, [TMP2]
- vst1.8 {d22}, [TMP3]
- vst1.8 {d23}, [TMP4]
- bx lr
-
- .unreq DCT_TABLE
- .unreq COEF_BLOCK
- .unreq OUTPUT_BUF
- .unreq OUTPUT_COL
- .unreq TMP1
- .unreq TMP2
- .unreq TMP3
- .unreq TMP4
-
-
-/*****************************************************************************/
-
-/*
- * jsimd_extrgb_ycc_convert_neon
- * jsimd_extbgr_ycc_convert_neon
- * jsimd_extrgbx_ycc_convert_neon
- * jsimd_extbgrx_ycc_convert_neon
- * jsimd_extxbgr_ycc_convert_neon
- * jsimd_extxrgb_ycc_convert_neon
- *
- * Colorspace conversion RGB -> YCbCr
- */
-
-.macro do_store size
- .if \size == 8
- vst1.8 {d20}, [Y]!
- vst1.8 {d21}, [U]!
- vst1.8 {d22}, [V]!
- .elseif \size == 4
- vst1.8 {d20[0]}, [Y]!
- vst1.8 {d20[1]}, [Y]!
- vst1.8 {d20[2]}, [Y]!
- vst1.8 {d20[3]}, [Y]!
- vst1.8 {d21[0]}, [U]!
- vst1.8 {d21[1]}, [U]!
- vst1.8 {d21[2]}, [U]!
- vst1.8 {d21[3]}, [U]!
- vst1.8 {d22[0]}, [V]!
- vst1.8 {d22[1]}, [V]!
- vst1.8 {d22[2]}, [V]!
- vst1.8 {d22[3]}, [V]!
- .elseif \size == 2
- vst1.8 {d20[4]}, [Y]!
- vst1.8 {d20[5]}, [Y]!
- vst1.8 {d21[4]}, [U]!
- vst1.8 {d21[5]}, [U]!
- vst1.8 {d22[4]}, [V]!
- vst1.8 {d22[5]}, [V]!
- .elseif \size == 1
- vst1.8 {d20[6]}, [Y]!
- vst1.8 {d21[6]}, [U]!
- vst1.8 {d22[6]}, [V]!
- .else
- .error unsupported macroblock size
- .endif
-.endm
-
-.macro do_load bpp, size
- .if \bpp == 24
- .if \size == 8
- vld3.8 {d10, d11, d12}, [RGB]!
- pld [RGB, #128]
- .elseif \size == 4
- vld3.8 {d10[0], d11[0], d12[0]}, [RGB]!
- vld3.8 {d10[1], d11[1], d12[1]}, [RGB]!
- vld3.8 {d10[2], d11[2], d12[2]}, [RGB]!
- vld3.8 {d10[3], d11[3], d12[3]}, [RGB]!
- .elseif \size == 2
- vld3.8 {d10[4], d11[4], d12[4]}, [RGB]!
- vld3.8 {d10[5], d11[5], d12[5]}, [RGB]!
- .elseif \size == 1
- vld3.8 {d10[6], d11[6], d12[6]}, [RGB]!
- .else
- .error unsupported macroblock size
- .endif
- .elseif \bpp == 32
- .if \size == 8
- vld4.8 {d10, d11, d12, d13}, [RGB]!
- pld [RGB, #128]
- .elseif \size == 4
- vld4.8 {d10[0], d11[0], d12[0], d13[0]}, [RGB]!
- vld4.8 {d10[1], d11[1], d12[1], d13[1]}, [RGB]!
- vld4.8 {d10[2], d11[2], d12[2], d13[2]}, [RGB]!
- vld4.8 {d10[3], d11[3], d12[3], d13[3]}, [RGB]!
- .elseif \size == 2
- vld4.8 {d10[4], d11[4], d12[4], d13[4]}, [RGB]!
- vld4.8 {d10[5], d11[5], d12[5], d13[5]}, [RGB]!
- .elseif \size == 1
- vld4.8 {d10[6], d11[6], d12[6], d13[6]}, [RGB]!
- .else
- .error unsupported macroblock size
- .endif
- .else
- .error unsupported bpp
- .endif
-.endm
-
-.macro generate_jsimd_rgb_ycc_convert_neon colorid, bpp, r_offs, g_offs, b_offs
-
-/*
- * 2-stage pipelined RGB->YCbCr conversion
- */
-
-.macro do_rgb_to_yuv_stage1
- vmovl.u8 q2, d1\r_offs /* r = { d4, d5 } */
- vmovl.u8 q3, d1\g_offs /* g = { d6, d7 } */
- vmovl.u8 q4, d1\b_offs /* b = { d8, d9 } */
- vmull.u16 q7, d4, d0[0]
- vmlal.u16 q7, d6, d0[1]
- vmlal.u16 q7, d8, d0[2]
- vmull.u16 q8, d5, d0[0]
- vmlal.u16 q8, d7, d0[1]
- vmlal.u16 q8, d9, d0[2]
- vrev64.32 q9, q1
- vrev64.32 q13, q1
- vmlsl.u16 q9, d4, d0[3]
- vmlsl.u16 q9, d6, d1[0]
- vmlal.u16 q9, d8, d1[1]
- vmlsl.u16 q13, d5, d0[3]
- vmlsl.u16 q13, d7, d1[0]
- vmlal.u16 q13, d9, d1[1]
- vrev64.32 q14, q1
- vrev64.32 q15, q1
- vmlal.u16 q14, d4, d1[1]
- vmlsl.u16 q14, d6, d1[2]
- vmlsl.u16 q14, d8, d1[3]
- vmlal.u16 q15, d5, d1[1]
- vmlsl.u16 q15, d7, d1[2]
- vmlsl.u16 q15, d9, d1[3]
-.endm
-
-.macro do_rgb_to_yuv_stage2
- vrshrn.u32 d20, q7, #16
- vrshrn.u32 d21, q8, #16
- vshrn.u32 d22, q9, #16
- vshrn.u32 d23, q13, #16
- vshrn.u32 d24, q14, #16
- vshrn.u32 d25, q15, #16
- vmovn.u16 d20, q10 /* d20 = y */
- vmovn.u16 d21, q11 /* d21 = u */
- vmovn.u16 d22, q12 /* d22 = v */
-.endm
-
-.macro do_rgb_to_yuv
- do_rgb_to_yuv_stage1
- do_rgb_to_yuv_stage2
-.endm
-
-.macro do_rgb_to_yuv_stage2_store_load_stage1
- vrshrn.u32 d20, q7, #16
- vrshrn.u32 d21, q8, #16
- vshrn.u32 d22, q9, #16
- vrev64.32 q9, q1
- vshrn.u32 d23, q13, #16
- vrev64.32 q13, q1
- vshrn.u32 d24, q14, #16
- vshrn.u32 d25, q15, #16
- do_load \bpp, 8
- vmovn.u16 d20, q10 /* d20 = y */
- vmovl.u8 q2, d1\r_offs /* r = { d4, d5 } */
- vmovn.u16 d21, q11 /* d21 = u */
- vmovl.u8 q3, d1\g_offs /* g = { d6, d7 } */
- vmovn.u16 d22, q12 /* d22 = v */
- vmovl.u8 q4, d1\b_offs /* b = { d8, d9 } */
- vmull.u16 q7, d4, d0[0]
- vmlal.u16 q7, d6, d0[1]
- vmlal.u16 q7, d8, d0[2]
- vst1.8 {d20}, [Y]!
- vmull.u16 q8, d5, d0[0]
- vmlal.u16 q8, d7, d0[1]
- vmlal.u16 q8, d9, d0[2]
- vmlsl.u16 q9, d4, d0[3]
- vmlsl.u16 q9, d6, d1[0]
- vmlal.u16 q9, d8, d1[1]
- vst1.8 {d21}, [U]!
- vmlsl.u16 q13, d5, d0[3]
- vmlsl.u16 q13, d7, d1[0]
- vmlal.u16 q13, d9, d1[1]
- vrev64.32 q14, q1
- vrev64.32 q15, q1
- vmlal.u16 q14, d4, d1[1]
- vmlsl.u16 q14, d6, d1[2]
- vmlsl.u16 q14, d8, d1[3]
- vst1.8 {d22}, [V]!
- vmlal.u16 q15, d5, d1[1]
- vmlsl.u16 q15, d7, d1[2]
- vmlsl.u16 q15, d9, d1[3]
-.endm
-
-.balign 16
-jsimd_\colorid\()_ycc_neon_consts:
- .short 19595, 38470, 7471, 11059
- .short 21709, 32768, 27439, 5329
- .short 32767, 128, 32767, 128
- .short 32767, 128, 32767, 128
-
-asm_function jsimd_\colorid\()_ycc_convert_neon
- OUTPUT_WIDTH .req r0
- INPUT_BUF .req r1
- OUTPUT_BUF .req r2
- OUTPUT_ROW .req r3
- NUM_ROWS .req r4
-
- OUTPUT_BUF0 .req r5
- OUTPUT_BUF1 .req r6
- OUTPUT_BUF2 .req OUTPUT_BUF
-
- RGB .req r7
- Y .req r8
- U .req r9
- V .req r10
- N .req ip
-
- /* Load constants to d0, d1, d2, d3 */
- adr ip, jsimd_\colorid\()_ycc_neon_consts
- vld1.16 {d0, d1, d2, d3}, [ip, :128]
-
- /* Save Arm registers and handle input arguments */
- push {r4, r5, r6, r7, r8, r9, r10, lr}
- ldr NUM_ROWS, [sp, #(4 * 8)]
- ldr OUTPUT_BUF0, [OUTPUT_BUF]
- ldr OUTPUT_BUF1, [OUTPUT_BUF, #4]
- ldr OUTPUT_BUF2, [OUTPUT_BUF, #8]
- .unreq OUTPUT_BUF
-
- /* Save Neon registers */
- vpush {d8 - d15}
-
- /* Outer loop over scanlines */
- cmp NUM_ROWS, #1
- blt 9f
-0:
- ldr Y, [OUTPUT_BUF0, OUTPUT_ROW, lsl #2]
- ldr U, [OUTPUT_BUF1, OUTPUT_ROW, lsl #2]
- mov N, OUTPUT_WIDTH
- ldr V, [OUTPUT_BUF2, OUTPUT_ROW, lsl #2]
- add OUTPUT_ROW, OUTPUT_ROW, #1
- ldr RGB, [INPUT_BUF], #4
-
- /* Inner loop over pixels */
- subs N, N, #8
- blt 3f
- do_load \bpp, 8
- do_rgb_to_yuv_stage1
- subs N, N, #8
- blt 2f
-1:
- do_rgb_to_yuv_stage2_store_load_stage1
- subs N, N, #8
- bge 1b
-2:
- do_rgb_to_yuv_stage2
- do_store 8
- tst N, #7
- beq 8f
-3:
- tst N, #4
- beq 3f
- do_load \bpp, 4
-3:
- tst N, #2
- beq 4f
- do_load \bpp, 2
-4:
- tst N, #1
- beq 5f
- do_load \bpp, 1
-5:
- do_rgb_to_yuv
- tst N, #4
- beq 6f
- do_store 4
-6:
- tst N, #2
- beq 7f
- do_store 2
-7:
- tst N, #1
- beq 8f
- do_store 1
-8:
- subs NUM_ROWS, NUM_ROWS, #1
- bgt 0b
-9:
- /* Restore all registers and return */
- vpop {d8 - d15}
- pop {r4, r5, r6, r7, r8, r9, r10, pc}
-
- .unreq OUTPUT_WIDTH
- .unreq OUTPUT_ROW
- .unreq INPUT_BUF
- .unreq NUM_ROWS
- .unreq OUTPUT_BUF0
- .unreq OUTPUT_BUF1
- .unreq OUTPUT_BUF2
- .unreq RGB
- .unreq Y
- .unreq U
- .unreq V
- .unreq N
-
-.purgem do_rgb_to_yuv
-.purgem do_rgb_to_yuv_stage1
-.purgem do_rgb_to_yuv_stage2
-.purgem do_rgb_to_yuv_stage2_store_load_stage1
-
-.endm
-
-/*--------------------------------- id ----- bpp R G B */
-generate_jsimd_rgb_ycc_convert_neon extrgb, 24, 0, 1, 2
-generate_jsimd_rgb_ycc_convert_neon extbgr, 24, 2, 1, 0
-generate_jsimd_rgb_ycc_convert_neon extrgbx, 32, 0, 1, 2
-generate_jsimd_rgb_ycc_convert_neon extbgrx, 32, 2, 1, 0
-generate_jsimd_rgb_ycc_convert_neon extxbgr, 32, 3, 2, 1
-generate_jsimd_rgb_ycc_convert_neon extxrgb, 32, 1, 2, 3
-
-.purgem do_load
-.purgem do_store
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/aarch64/jccolext-neon.c b/contrib/libs/libjpeg-turbo/simd/arm/aarch64/jccolext-neon.c
deleted file mode 100644
index 37130c225e..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/arm/aarch64/jccolext-neon.c
+++ /dev/null
@@ -1,316 +0,0 @@
-/*
- * jccolext-neon.c - colorspace conversion (64-bit Arm Neon)
- *
- * Copyright (C) 2020, Arm Limited. All Rights Reserved.
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- * claim that you wrote the original software. If you use this software
- * in a product, an acknowledgment in the product documentation would be
- * appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must not be
- * misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source distribution.
- */
-
-/* This file is included by jccolor-neon.c */
-
-
-/* RGB -> YCbCr conversion is defined by the following equations:
- * Y = 0.29900 * R + 0.58700 * G + 0.11400 * B
- * Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + 128
- * Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + 128
- *
- * Avoid floating point arithmetic by using shifted integer constants:
- * 0.29899597 = 19595 * 2^-16
- * 0.58700561 = 38470 * 2^-16
- * 0.11399841 = 7471 * 2^-16
- * 0.16874695 = 11059 * 2^-16
- * 0.33125305 = 21709 * 2^-16
- * 0.50000000 = 32768 * 2^-16
- * 0.41868592 = 27439 * 2^-16
- * 0.08131409 = 5329 * 2^-16
- * These constants are defined in jccolor-neon.c
- *
- * We add the fixed-point equivalent of 0.5 to Cb and Cr, which effectively
- * rounds up or down the result via integer truncation.
- */
-
-void jsimd_rgb_ycc_convert_neon(JDIMENSION image_width, JSAMPARRAY input_buf,
- JSAMPIMAGE output_buf, JDIMENSION output_row,
- int num_rows)
-{
- /* Pointer to RGB(X/A) input data */
- JSAMPROW inptr;
- /* Pointers to Y, Cb, and Cr output data */
- JSAMPROW outptr0, outptr1, outptr2;
- /* Allocate temporary buffer for final (image_width % 16) pixels in row. */
- ALIGN(16) uint8_t tmp_buf[16 * RGB_PIXELSIZE];
-
- /* Set up conversion constants. */
- const uint16x8_t consts = vld1q_u16(jsimd_rgb_ycc_neon_consts);
- const uint32x4_t scaled_128_5 = vdupq_n_u32((128 << 16) + 32767);
-
- while (--num_rows >= 0) {
- inptr = *input_buf++;
- outptr0 = output_buf[0][output_row];
- outptr1 = output_buf[1][output_row];
- outptr2 = output_buf[2][output_row];
- output_row++;
-
- int cols_remaining = image_width;
- for (; cols_remaining >= 16; cols_remaining -= 16) {
-
-#if RGB_PIXELSIZE == 4
- uint8x16x4_t input_pixels = vld4q_u8(inptr);
-#else
- uint8x16x3_t input_pixels = vld3q_u8(inptr);
-#endif
- uint16x8_t r_l = vmovl_u8(vget_low_u8(input_pixels.val[RGB_RED]));
- uint16x8_t g_l = vmovl_u8(vget_low_u8(input_pixels.val[RGB_GREEN]));
- uint16x8_t b_l = vmovl_u8(vget_low_u8(input_pixels.val[RGB_BLUE]));
- uint16x8_t r_h = vmovl_u8(vget_high_u8(input_pixels.val[RGB_RED]));
- uint16x8_t g_h = vmovl_u8(vget_high_u8(input_pixels.val[RGB_GREEN]));
- uint16x8_t b_h = vmovl_u8(vget_high_u8(input_pixels.val[RGB_BLUE]));
-
- /* Compute Y = 0.29900 * R + 0.58700 * G + 0.11400 * B */
- uint32x4_t y_ll = vmull_laneq_u16(vget_low_u16(r_l), consts, 0);
- y_ll = vmlal_laneq_u16(y_ll, vget_low_u16(g_l), consts, 1);
- y_ll = vmlal_laneq_u16(y_ll, vget_low_u16(b_l), consts, 2);
- uint32x4_t y_lh = vmull_laneq_u16(vget_high_u16(r_l), consts, 0);
- y_lh = vmlal_laneq_u16(y_lh, vget_high_u16(g_l), consts, 1);
- y_lh = vmlal_laneq_u16(y_lh, vget_high_u16(b_l), consts, 2);
- uint32x4_t y_hl = vmull_laneq_u16(vget_low_u16(r_h), consts, 0);
- y_hl = vmlal_laneq_u16(y_hl, vget_low_u16(g_h), consts, 1);
- y_hl = vmlal_laneq_u16(y_hl, vget_low_u16(b_h), consts, 2);
- uint32x4_t y_hh = vmull_laneq_u16(vget_high_u16(r_h), consts, 0);
- y_hh = vmlal_laneq_u16(y_hh, vget_high_u16(g_h), consts, 1);
- y_hh = vmlal_laneq_u16(y_hh, vget_high_u16(b_h), consts, 2);
-
- /* Compute Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + 128 */
- uint32x4_t cb_ll = scaled_128_5;
- cb_ll = vmlsl_laneq_u16(cb_ll, vget_low_u16(r_l), consts, 3);
- cb_ll = vmlsl_laneq_u16(cb_ll, vget_low_u16(g_l), consts, 4);
- cb_ll = vmlal_laneq_u16(cb_ll, vget_low_u16(b_l), consts, 5);
- uint32x4_t cb_lh = scaled_128_5;
- cb_lh = vmlsl_laneq_u16(cb_lh, vget_high_u16(r_l), consts, 3);
- cb_lh = vmlsl_laneq_u16(cb_lh, vget_high_u16(g_l), consts, 4);
- cb_lh = vmlal_laneq_u16(cb_lh, vget_high_u16(b_l), consts, 5);
- uint32x4_t cb_hl = scaled_128_5;
- cb_hl = vmlsl_laneq_u16(cb_hl, vget_low_u16(r_h), consts, 3);
- cb_hl = vmlsl_laneq_u16(cb_hl, vget_low_u16(g_h), consts, 4);
- cb_hl = vmlal_laneq_u16(cb_hl, vget_low_u16(b_h), consts, 5);
- uint32x4_t cb_hh = scaled_128_5;
- cb_hh = vmlsl_laneq_u16(cb_hh, vget_high_u16(r_h), consts, 3);
- cb_hh = vmlsl_laneq_u16(cb_hh, vget_high_u16(g_h), consts, 4);
- cb_hh = vmlal_laneq_u16(cb_hh, vget_high_u16(b_h), consts, 5);
-
- /* Compute Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + 128 */
- uint32x4_t cr_ll = scaled_128_5;
- cr_ll = vmlal_laneq_u16(cr_ll, vget_low_u16(r_l), consts, 5);
- cr_ll = vmlsl_laneq_u16(cr_ll, vget_low_u16(g_l), consts, 6);
- cr_ll = vmlsl_laneq_u16(cr_ll, vget_low_u16(b_l), consts, 7);
- uint32x4_t cr_lh = scaled_128_5;
- cr_lh = vmlal_laneq_u16(cr_lh, vget_high_u16(r_l), consts, 5);
- cr_lh = vmlsl_laneq_u16(cr_lh, vget_high_u16(g_l), consts, 6);
- cr_lh = vmlsl_laneq_u16(cr_lh, vget_high_u16(b_l), consts, 7);
- uint32x4_t cr_hl = scaled_128_5;
- cr_hl = vmlal_laneq_u16(cr_hl, vget_low_u16(r_h), consts, 5);
- cr_hl = vmlsl_laneq_u16(cr_hl, vget_low_u16(g_h), consts, 6);
- cr_hl = vmlsl_laneq_u16(cr_hl, vget_low_u16(b_h), consts, 7);
- uint32x4_t cr_hh = scaled_128_5;
- cr_hh = vmlal_laneq_u16(cr_hh, vget_high_u16(r_h), consts, 5);
- cr_hh = vmlsl_laneq_u16(cr_hh, vget_high_u16(g_h), consts, 6);
- cr_hh = vmlsl_laneq_u16(cr_hh, vget_high_u16(b_h), consts, 7);
-
- /* Descale Y values (rounding right shift) and narrow to 16-bit. */
- uint16x8_t y_l = vcombine_u16(vrshrn_n_u32(y_ll, 16),
- vrshrn_n_u32(y_lh, 16));
- uint16x8_t y_h = vcombine_u16(vrshrn_n_u32(y_hl, 16),
- vrshrn_n_u32(y_hh, 16));
- /* Descale Cb values (right shift) and narrow to 16-bit. */
- uint16x8_t cb_l = vcombine_u16(vshrn_n_u32(cb_ll, 16),
- vshrn_n_u32(cb_lh, 16));
- uint16x8_t cb_h = vcombine_u16(vshrn_n_u32(cb_hl, 16),
- vshrn_n_u32(cb_hh, 16));
- /* Descale Cr values (right shift) and narrow to 16-bit. */
- uint16x8_t cr_l = vcombine_u16(vshrn_n_u32(cr_ll, 16),
- vshrn_n_u32(cr_lh, 16));
- uint16x8_t cr_h = vcombine_u16(vshrn_n_u32(cr_hl, 16),
- vshrn_n_u32(cr_hh, 16));
- /* Narrow Y, Cb, and Cr values to 8-bit and store to memory. Buffer
- * overwrite is permitted up to the next multiple of ALIGN_SIZE bytes.
- */
- vst1q_u8(outptr0, vcombine_u8(vmovn_u16(y_l), vmovn_u16(y_h)));
- vst1q_u8(outptr1, vcombine_u8(vmovn_u16(cb_l), vmovn_u16(cb_h)));
- vst1q_u8(outptr2, vcombine_u8(vmovn_u16(cr_l), vmovn_u16(cr_h)));
-
- /* Increment pointers. */
- inptr += (16 * RGB_PIXELSIZE);
- outptr0 += 16;
- outptr1 += 16;
- outptr2 += 16;
- }
-
- if (cols_remaining > 8) {
- /* To prevent buffer overread by the vector load instructions, the last
- * (image_width % 16) columns of data are first memcopied to a temporary
- * buffer large enough to accommodate the vector load.
- */
- memcpy(tmp_buf, inptr, cols_remaining * RGB_PIXELSIZE);
- inptr = tmp_buf;
-
-#if RGB_PIXELSIZE == 4
- uint8x16x4_t input_pixels = vld4q_u8(inptr);
-#else
- uint8x16x3_t input_pixels = vld3q_u8(inptr);
-#endif
- uint16x8_t r_l = vmovl_u8(vget_low_u8(input_pixels.val[RGB_RED]));
- uint16x8_t g_l = vmovl_u8(vget_low_u8(input_pixels.val[RGB_GREEN]));
- uint16x8_t b_l = vmovl_u8(vget_low_u8(input_pixels.val[RGB_BLUE]));
- uint16x8_t r_h = vmovl_u8(vget_high_u8(input_pixels.val[RGB_RED]));
- uint16x8_t g_h = vmovl_u8(vget_high_u8(input_pixels.val[RGB_GREEN]));
- uint16x8_t b_h = vmovl_u8(vget_high_u8(input_pixels.val[RGB_BLUE]));
-
- /* Compute Y = 0.29900 * R + 0.58700 * G + 0.11400 * B */
- uint32x4_t y_ll = vmull_laneq_u16(vget_low_u16(r_l), consts, 0);
- y_ll = vmlal_laneq_u16(y_ll, vget_low_u16(g_l), consts, 1);
- y_ll = vmlal_laneq_u16(y_ll, vget_low_u16(b_l), consts, 2);
- uint32x4_t y_lh = vmull_laneq_u16(vget_high_u16(r_l), consts, 0);
- y_lh = vmlal_laneq_u16(y_lh, vget_high_u16(g_l), consts, 1);
- y_lh = vmlal_laneq_u16(y_lh, vget_high_u16(b_l), consts, 2);
- uint32x4_t y_hl = vmull_laneq_u16(vget_low_u16(r_h), consts, 0);
- y_hl = vmlal_laneq_u16(y_hl, vget_low_u16(g_h), consts, 1);
- y_hl = vmlal_laneq_u16(y_hl, vget_low_u16(b_h), consts, 2);
- uint32x4_t y_hh = vmull_laneq_u16(vget_high_u16(r_h), consts, 0);
- y_hh = vmlal_laneq_u16(y_hh, vget_high_u16(g_h), consts, 1);
- y_hh = vmlal_laneq_u16(y_hh, vget_high_u16(b_h), consts, 2);
-
- /* Compute Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + 128 */
- uint32x4_t cb_ll = scaled_128_5;
- cb_ll = vmlsl_laneq_u16(cb_ll, vget_low_u16(r_l), consts, 3);
- cb_ll = vmlsl_laneq_u16(cb_ll, vget_low_u16(g_l), consts, 4);
- cb_ll = vmlal_laneq_u16(cb_ll, vget_low_u16(b_l), consts, 5);
- uint32x4_t cb_lh = scaled_128_5;
- cb_lh = vmlsl_laneq_u16(cb_lh, vget_high_u16(r_l), consts, 3);
- cb_lh = vmlsl_laneq_u16(cb_lh, vget_high_u16(g_l), consts, 4);
- cb_lh = vmlal_laneq_u16(cb_lh, vget_high_u16(b_l), consts, 5);
- uint32x4_t cb_hl = scaled_128_5;
- cb_hl = vmlsl_laneq_u16(cb_hl, vget_low_u16(r_h), consts, 3);
- cb_hl = vmlsl_laneq_u16(cb_hl, vget_low_u16(g_h), consts, 4);
- cb_hl = vmlal_laneq_u16(cb_hl, vget_low_u16(b_h), consts, 5);
- uint32x4_t cb_hh = scaled_128_5;
- cb_hh = vmlsl_laneq_u16(cb_hh, vget_high_u16(r_h), consts, 3);
- cb_hh = vmlsl_laneq_u16(cb_hh, vget_high_u16(g_h), consts, 4);
- cb_hh = vmlal_laneq_u16(cb_hh, vget_high_u16(b_h), consts, 5);
-
- /* Compute Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + 128 */
- uint32x4_t cr_ll = scaled_128_5;
- cr_ll = vmlal_laneq_u16(cr_ll, vget_low_u16(r_l), consts, 5);
- cr_ll = vmlsl_laneq_u16(cr_ll, vget_low_u16(g_l), consts, 6);
- cr_ll = vmlsl_laneq_u16(cr_ll, vget_low_u16(b_l), consts, 7);
- uint32x4_t cr_lh = scaled_128_5;
- cr_lh = vmlal_laneq_u16(cr_lh, vget_high_u16(r_l), consts, 5);
- cr_lh = vmlsl_laneq_u16(cr_lh, vget_high_u16(g_l), consts, 6);
- cr_lh = vmlsl_laneq_u16(cr_lh, vget_high_u16(b_l), consts, 7);
- uint32x4_t cr_hl = scaled_128_5;
- cr_hl = vmlal_laneq_u16(cr_hl, vget_low_u16(r_h), consts, 5);
- cr_hl = vmlsl_laneq_u16(cr_hl, vget_low_u16(g_h), consts, 6);
- cr_hl = vmlsl_laneq_u16(cr_hl, vget_low_u16(b_h), consts, 7);
- uint32x4_t cr_hh = scaled_128_5;
- cr_hh = vmlal_laneq_u16(cr_hh, vget_high_u16(r_h), consts, 5);
- cr_hh = vmlsl_laneq_u16(cr_hh, vget_high_u16(g_h), consts, 6);
- cr_hh = vmlsl_laneq_u16(cr_hh, vget_high_u16(b_h), consts, 7);
-
- /* Descale Y values (rounding right shift) and narrow to 16-bit. */
- uint16x8_t y_l = vcombine_u16(vrshrn_n_u32(y_ll, 16),
- vrshrn_n_u32(y_lh, 16));
- uint16x8_t y_h = vcombine_u16(vrshrn_n_u32(y_hl, 16),
- vrshrn_n_u32(y_hh, 16));
- /* Descale Cb values (right shift) and narrow to 16-bit. */
- uint16x8_t cb_l = vcombine_u16(vshrn_n_u32(cb_ll, 16),
- vshrn_n_u32(cb_lh, 16));
- uint16x8_t cb_h = vcombine_u16(vshrn_n_u32(cb_hl, 16),
- vshrn_n_u32(cb_hh, 16));
- /* Descale Cr values (right shift) and narrow to 16-bit. */
- uint16x8_t cr_l = vcombine_u16(vshrn_n_u32(cr_ll, 16),
- vshrn_n_u32(cr_lh, 16));
- uint16x8_t cr_h = vcombine_u16(vshrn_n_u32(cr_hl, 16),
- vshrn_n_u32(cr_hh, 16));
- /* Narrow Y, Cb, and Cr values to 8-bit and store to memory. Buffer
- * overwrite is permitted up to the next multiple of ALIGN_SIZE bytes.
- */
- vst1q_u8(outptr0, vcombine_u8(vmovn_u16(y_l), vmovn_u16(y_h)));
- vst1q_u8(outptr1, vcombine_u8(vmovn_u16(cb_l), vmovn_u16(cb_h)));
- vst1q_u8(outptr2, vcombine_u8(vmovn_u16(cr_l), vmovn_u16(cr_h)));
-
- } else if (cols_remaining > 0) {
- /* To prevent buffer overread by the vector load instructions, the last
- * (image_width % 8) columns of data are first memcopied to a temporary
- * buffer large enough to accommodate the vector load.
- */
- memcpy(tmp_buf, inptr, cols_remaining * RGB_PIXELSIZE);
- inptr = tmp_buf;
-
-#if RGB_PIXELSIZE == 4
- uint8x8x4_t input_pixels = vld4_u8(inptr);
-#else
- uint8x8x3_t input_pixels = vld3_u8(inptr);
-#endif
- uint16x8_t r = vmovl_u8(input_pixels.val[RGB_RED]);
- uint16x8_t g = vmovl_u8(input_pixels.val[RGB_GREEN]);
- uint16x8_t b = vmovl_u8(input_pixels.val[RGB_BLUE]);
-
- /* Compute Y = 0.29900 * R + 0.58700 * G + 0.11400 * B */
- uint32x4_t y_l = vmull_laneq_u16(vget_low_u16(r), consts, 0);
- y_l = vmlal_laneq_u16(y_l, vget_low_u16(g), consts, 1);
- y_l = vmlal_laneq_u16(y_l, vget_low_u16(b), consts, 2);
- uint32x4_t y_h = vmull_laneq_u16(vget_high_u16(r), consts, 0);
- y_h = vmlal_laneq_u16(y_h, vget_high_u16(g), consts, 1);
- y_h = vmlal_laneq_u16(y_h, vget_high_u16(b), consts, 2);
-
- /* Compute Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + 128 */
- uint32x4_t cb_l = scaled_128_5;
- cb_l = vmlsl_laneq_u16(cb_l, vget_low_u16(r), consts, 3);
- cb_l = vmlsl_laneq_u16(cb_l, vget_low_u16(g), consts, 4);
- cb_l = vmlal_laneq_u16(cb_l, vget_low_u16(b), consts, 5);
- uint32x4_t cb_h = scaled_128_5;
- cb_h = vmlsl_laneq_u16(cb_h, vget_high_u16(r), consts, 3);
- cb_h = vmlsl_laneq_u16(cb_h, vget_high_u16(g), consts, 4);
- cb_h = vmlal_laneq_u16(cb_h, vget_high_u16(b), consts, 5);
-
- /* Compute Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + 128 */
- uint32x4_t cr_l = scaled_128_5;
- cr_l = vmlal_laneq_u16(cr_l, vget_low_u16(r), consts, 5);
- cr_l = vmlsl_laneq_u16(cr_l, vget_low_u16(g), consts, 6);
- cr_l = vmlsl_laneq_u16(cr_l, vget_low_u16(b), consts, 7);
- uint32x4_t cr_h = scaled_128_5;
- cr_h = vmlal_laneq_u16(cr_h, vget_high_u16(r), consts, 5);
- cr_h = vmlsl_laneq_u16(cr_h, vget_high_u16(g), consts, 6);
- cr_h = vmlsl_laneq_u16(cr_h, vget_high_u16(b), consts, 7);
-
- /* Descale Y values (rounding right shift) and narrow to 16-bit. */
- uint16x8_t y_u16 = vcombine_u16(vrshrn_n_u32(y_l, 16),
- vrshrn_n_u32(y_h, 16));
- /* Descale Cb values (right shift) and narrow to 16-bit. */
- uint16x8_t cb_u16 = vcombine_u16(vshrn_n_u32(cb_l, 16),
- vshrn_n_u32(cb_h, 16));
- /* Descale Cr values (right shift) and narrow to 16-bit. */
- uint16x8_t cr_u16 = vcombine_u16(vshrn_n_u32(cr_l, 16),
- vshrn_n_u32(cr_h, 16));
- /* Narrow Y, Cb, and Cr values to 8-bit and store to memory. Buffer
- * overwrite is permitted up to the next multiple of ALIGN_SIZE bytes.
- */
- vst1_u8(outptr0, vmovn_u16(y_u16));
- vst1_u8(outptr1, vmovn_u16(cb_u16));
- vst1_u8(outptr2, vmovn_u16(cr_u16));
- }
- }
-}
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/aarch64/jchuff-neon.c b/contrib/libs/libjpeg-turbo/simd/arm/aarch64/jchuff-neon.c
deleted file mode 100644
index 607a116070..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/arm/aarch64/jchuff-neon.c
+++ /dev/null
@@ -1,411 +0,0 @@
-/*
- * jchuff-neon.c - Huffman entropy encoding (64-bit Arm Neon)
- *
- * Copyright (C) 2020-2021, Arm Limited. All Rights Reserved.
- * Copyright (C) 2020, 2022, D. R. Commander. All Rights Reserved.
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- * claim that you wrote the original software. If you use this software
- * in a product, an acknowledgment in the product documentation would be
- * appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must not be
- * misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source distribution.
- *
- * NOTE: All referenced figures are from
- * Recommendation ITU-T T.81 (1992) | ISO/IEC 10918-1:1994.
- */
-
-#define JPEG_INTERNALS
-#include "../../../jinclude.h"
-#include "../../../jpeglib.h"
-#include "../../../jsimd.h"
-#include "../../../jdct.h"
-#include "../../../jsimddct.h"
-#include "../../jsimd.h"
-#include "../align.h"
-#include "../jchuff.h"
-#include "neon-compat.h"
-
-#include <limits.h>
-
-#include <arm_neon.h>
-
-
-ALIGN(16) static const uint8_t jsimd_huff_encode_one_block_consts[] = {
- 0, 1, 2, 3, 16, 17, 32, 33,
- 18, 19, 4, 5, 6, 7, 20, 21,
- 34, 35, 48, 49, 255, 255, 50, 51,
- 36, 37, 22, 23, 8, 9, 10, 11,
- 255, 255, 6, 7, 20, 21, 34, 35,
- 48, 49, 255, 255, 50, 51, 36, 37,
- 54, 55, 40, 41, 26, 27, 12, 13,
- 14, 15, 28, 29, 42, 43, 56, 57,
- 6, 7, 20, 21, 34, 35, 48, 49,
- 50, 51, 36, 37, 22, 23, 8, 9,
- 26, 27, 12, 13, 255, 255, 14, 15,
- 28, 29, 42, 43, 56, 57, 255, 255,
- 52, 53, 54, 55, 40, 41, 26, 27,
- 12, 13, 255, 255, 14, 15, 28, 29,
- 26, 27, 40, 41, 42, 43, 28, 29,
- 14, 15, 30, 31, 44, 45, 46, 47
-};
-
-/* The AArch64 implementation of the FLUSH() macro triggers a UBSan misaligned
- * address warning because the macro sometimes writes a 64-bit value to a
- * non-64-bit-aligned address. That behavior is technically undefined per
- * the C specification, but it is supported by the AArch64 architecture and
- * compilers.
- */
-#if defined(__has_feature)
-#if __has_feature(undefined_behavior_sanitizer)
-__attribute__((no_sanitize("alignment")))
-#endif
-#endif
-JOCTET *jsimd_huff_encode_one_block_neon(void *state, JOCTET *buffer,
- JCOEFPTR block, int last_dc_val,
- c_derived_tbl *dctbl,
- c_derived_tbl *actbl)
-{
- uint16_t block_diff[DCTSIZE2];
-
- /* Load lookup table indices for rows of zig-zag ordering. */
-#ifdef HAVE_VLD1Q_U8_X4
- const uint8x16x4_t idx_rows_0123 =
- vld1q_u8_x4(jsimd_huff_encode_one_block_consts + 0 * DCTSIZE);
- const uint8x16x4_t idx_rows_4567 =
- vld1q_u8_x4(jsimd_huff_encode_one_block_consts + 8 * DCTSIZE);
-#else
- /* GCC does not currently support intrinsics vl1dq_<type>_x4(). */
- const uint8x16x4_t idx_rows_0123 = { {
- vld1q_u8(jsimd_huff_encode_one_block_consts + 0 * DCTSIZE),
- vld1q_u8(jsimd_huff_encode_one_block_consts + 2 * DCTSIZE),
- vld1q_u8(jsimd_huff_encode_one_block_consts + 4 * DCTSIZE),
- vld1q_u8(jsimd_huff_encode_one_block_consts + 6 * DCTSIZE)
- } };
- const uint8x16x4_t idx_rows_4567 = { {
- vld1q_u8(jsimd_huff_encode_one_block_consts + 8 * DCTSIZE),
- vld1q_u8(jsimd_huff_encode_one_block_consts + 10 * DCTSIZE),
- vld1q_u8(jsimd_huff_encode_one_block_consts + 12 * DCTSIZE),
- vld1q_u8(jsimd_huff_encode_one_block_consts + 14 * DCTSIZE)
- } };
-#endif
-
- /* Load 8x8 block of DCT coefficients. */
-#ifdef HAVE_VLD1Q_U8_X4
- const int8x16x4_t tbl_rows_0123 =
- vld1q_s8_x4((int8_t *)(block + 0 * DCTSIZE));
- const int8x16x4_t tbl_rows_4567 =
- vld1q_s8_x4((int8_t *)(block + 4 * DCTSIZE));
-#else
- const int8x16x4_t tbl_rows_0123 = { {
- vld1q_s8((int8_t *)(block + 0 * DCTSIZE)),
- vld1q_s8((int8_t *)(block + 1 * DCTSIZE)),
- vld1q_s8((int8_t *)(block + 2 * DCTSIZE)),
- vld1q_s8((int8_t *)(block + 3 * DCTSIZE))
- } };
- const int8x16x4_t tbl_rows_4567 = { {
- vld1q_s8((int8_t *)(block + 4 * DCTSIZE)),
- vld1q_s8((int8_t *)(block + 5 * DCTSIZE)),
- vld1q_s8((int8_t *)(block + 6 * DCTSIZE)),
- vld1q_s8((int8_t *)(block + 7 * DCTSIZE))
- } };
-#endif
-
- /* Initialise extra lookup tables. */
- const int8x16x4_t tbl_rows_2345 = { {
- tbl_rows_0123.val[2], tbl_rows_0123.val[3],
- tbl_rows_4567.val[0], tbl_rows_4567.val[1]
- } };
- const int8x16x3_t tbl_rows_567 =
- { { tbl_rows_4567.val[1], tbl_rows_4567.val[2], tbl_rows_4567.val[3] } };
-
- /* Shuffle coefficients into zig-zag order. */
- int16x8_t row0 =
- vreinterpretq_s16_s8(vqtbl4q_s8(tbl_rows_0123, idx_rows_0123.val[0]));
- int16x8_t row1 =
- vreinterpretq_s16_s8(vqtbl4q_s8(tbl_rows_0123, idx_rows_0123.val[1]));
- int16x8_t row2 =
- vreinterpretq_s16_s8(vqtbl4q_s8(tbl_rows_2345, idx_rows_0123.val[2]));
- int16x8_t row3 =
- vreinterpretq_s16_s8(vqtbl4q_s8(tbl_rows_0123, idx_rows_0123.val[3]));
- int16x8_t row4 =
- vreinterpretq_s16_s8(vqtbl4q_s8(tbl_rows_4567, idx_rows_4567.val[0]));
- int16x8_t row5 =
- vreinterpretq_s16_s8(vqtbl4q_s8(tbl_rows_2345, idx_rows_4567.val[1]));
- int16x8_t row6 =
- vreinterpretq_s16_s8(vqtbl4q_s8(tbl_rows_4567, idx_rows_4567.val[2]));
- int16x8_t row7 =
- vreinterpretq_s16_s8(vqtbl3q_s8(tbl_rows_567, idx_rows_4567.val[3]));
-
- /* Compute DC coefficient difference value (F.1.1.5.1). */
- row0 = vsetq_lane_s16(block[0] - last_dc_val, row0, 0);
- /* Initialize AC coefficient lanes not reachable by lookup tables. */
- row1 =
- vsetq_lane_s16(vgetq_lane_s16(vreinterpretq_s16_s8(tbl_rows_4567.val[0]),
- 0), row1, 2);
- row2 =
- vsetq_lane_s16(vgetq_lane_s16(vreinterpretq_s16_s8(tbl_rows_0123.val[1]),
- 4), row2, 0);
- row2 =
- vsetq_lane_s16(vgetq_lane_s16(vreinterpretq_s16_s8(tbl_rows_4567.val[2]),
- 0), row2, 5);
- row5 =
- vsetq_lane_s16(vgetq_lane_s16(vreinterpretq_s16_s8(tbl_rows_0123.val[1]),
- 7), row5, 2);
- row5 =
- vsetq_lane_s16(vgetq_lane_s16(vreinterpretq_s16_s8(tbl_rows_4567.val[2]),
- 3), row5, 7);
- row6 =
- vsetq_lane_s16(vgetq_lane_s16(vreinterpretq_s16_s8(tbl_rows_0123.val[3]),
- 7), row6, 5);
-
- /* DCT block is now in zig-zag order; start Huffman encoding process. */
-
- /* Construct bitmap to accelerate encoding of AC coefficients. A set bit
- * means that the corresponding coefficient != 0.
- */
- uint16x8_t row0_ne_0 = vtstq_s16(row0, row0);
- uint16x8_t row1_ne_0 = vtstq_s16(row1, row1);
- uint16x8_t row2_ne_0 = vtstq_s16(row2, row2);
- uint16x8_t row3_ne_0 = vtstq_s16(row3, row3);
- uint16x8_t row4_ne_0 = vtstq_s16(row4, row4);
- uint16x8_t row5_ne_0 = vtstq_s16(row5, row5);
- uint16x8_t row6_ne_0 = vtstq_s16(row6, row6);
- uint16x8_t row7_ne_0 = vtstq_s16(row7, row7);
-
- uint8x16_t row10_ne_0 = vuzp1q_u8(vreinterpretq_u8_u16(row1_ne_0),
- vreinterpretq_u8_u16(row0_ne_0));
- uint8x16_t row32_ne_0 = vuzp1q_u8(vreinterpretq_u8_u16(row3_ne_0),
- vreinterpretq_u8_u16(row2_ne_0));
- uint8x16_t row54_ne_0 = vuzp1q_u8(vreinterpretq_u8_u16(row5_ne_0),
- vreinterpretq_u8_u16(row4_ne_0));
- uint8x16_t row76_ne_0 = vuzp1q_u8(vreinterpretq_u8_u16(row7_ne_0),
- vreinterpretq_u8_u16(row6_ne_0));
-
- /* { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 } */
- const uint8x16_t bitmap_mask =
- vreinterpretq_u8_u64(vdupq_n_u64(0x0102040810204080));
-
- uint8x16_t bitmap_rows_10 = vandq_u8(row10_ne_0, bitmap_mask);
- uint8x16_t bitmap_rows_32 = vandq_u8(row32_ne_0, bitmap_mask);
- uint8x16_t bitmap_rows_54 = vandq_u8(row54_ne_0, bitmap_mask);
- uint8x16_t bitmap_rows_76 = vandq_u8(row76_ne_0, bitmap_mask);
-
- uint8x16_t bitmap_rows_3210 = vpaddq_u8(bitmap_rows_32, bitmap_rows_10);
- uint8x16_t bitmap_rows_7654 = vpaddq_u8(bitmap_rows_76, bitmap_rows_54);
- uint8x16_t bitmap_rows_76543210 = vpaddq_u8(bitmap_rows_7654,
- bitmap_rows_3210);
- uint8x8_t bitmap_all = vpadd_u8(vget_low_u8(bitmap_rows_76543210),
- vget_high_u8(bitmap_rows_76543210));
-
- /* Shift left to remove DC bit. */
- bitmap_all =
- vreinterpret_u8_u64(vshl_n_u64(vreinterpret_u64_u8(bitmap_all), 1));
- /* Count bits set (number of non-zero coefficients) in bitmap. */
- unsigned int non_zero_coefficients = vaddv_u8(vcnt_u8(bitmap_all));
- /* Move bitmap to 64-bit scalar register. */
- uint64_t bitmap = vget_lane_u64(vreinterpret_u64_u8(bitmap_all), 0);
-
- /* Set up state and bit buffer for output bitstream. */
- working_state *state_ptr = (working_state *)state;
- int free_bits = state_ptr->cur.free_bits;
- size_t put_buffer = state_ptr->cur.put_buffer;
-
- /* Encode DC coefficient. */
-
- /* For negative coeffs: diff = abs(coeff) -1 = ~abs(coeff) */
- int16x8_t abs_row0 = vabsq_s16(row0);
- int16x8_t row0_lz = vclzq_s16(abs_row0);
- uint16x8_t row0_mask = vshlq_u16(vcltzq_s16(row0), vnegq_s16(row0_lz));
- uint16x8_t row0_diff = veorq_u16(vreinterpretq_u16_s16(abs_row0), row0_mask);
- /* Find nbits required to specify sign and amplitude of coefficient. */
- unsigned int lz = vgetq_lane_u16(vreinterpretq_u16_s16(row0_lz), 0);
- unsigned int nbits = 16 - lz;
- /* Emit Huffman-coded symbol and additional diff bits. */
- unsigned int diff = vgetq_lane_u16(row0_diff, 0);
- PUT_CODE(dctbl->ehufco[nbits], dctbl->ehufsi[nbits], diff)
-
- /* Encode AC coefficients. */
-
- unsigned int r = 0; /* r = run length of zeros */
- unsigned int i = 1; /* i = number of coefficients encoded */
- /* Code and size information for a run length of 16 zero coefficients */
- const unsigned int code_0xf0 = actbl->ehufco[0xf0];
- const unsigned int size_0xf0 = actbl->ehufsi[0xf0];
-
- /* The most efficient method of computing nbits and diff depends on the
- * number of non-zero coefficients. If the bitmap is not too sparse (> 8
- * non-zero AC coefficients), it is beneficial to do all of the work using
- * Neon; else we do some of the work using Neon and the rest on demand using
- * scalar code.
- */
- if (non_zero_coefficients > 8) {
- uint8_t block_nbits[DCTSIZE2];
-
- int16x8_t abs_row1 = vabsq_s16(row1);
- int16x8_t abs_row2 = vabsq_s16(row2);
- int16x8_t abs_row3 = vabsq_s16(row3);
- int16x8_t abs_row4 = vabsq_s16(row4);
- int16x8_t abs_row5 = vabsq_s16(row5);
- int16x8_t abs_row6 = vabsq_s16(row6);
- int16x8_t abs_row7 = vabsq_s16(row7);
- int16x8_t row1_lz = vclzq_s16(abs_row1);
- int16x8_t row2_lz = vclzq_s16(abs_row2);
- int16x8_t row3_lz = vclzq_s16(abs_row3);
- int16x8_t row4_lz = vclzq_s16(abs_row4);
- int16x8_t row5_lz = vclzq_s16(abs_row5);
- int16x8_t row6_lz = vclzq_s16(abs_row6);
- int16x8_t row7_lz = vclzq_s16(abs_row7);
- /* Narrow leading zero count to 8 bits. */
- uint8x16_t row01_lz = vuzp1q_u8(vreinterpretq_u8_s16(row0_lz),
- vreinterpretq_u8_s16(row1_lz));
- uint8x16_t row23_lz = vuzp1q_u8(vreinterpretq_u8_s16(row2_lz),
- vreinterpretq_u8_s16(row3_lz));
- uint8x16_t row45_lz = vuzp1q_u8(vreinterpretq_u8_s16(row4_lz),
- vreinterpretq_u8_s16(row5_lz));
- uint8x16_t row67_lz = vuzp1q_u8(vreinterpretq_u8_s16(row6_lz),
- vreinterpretq_u8_s16(row7_lz));
- /* Compute nbits needed to specify magnitude of each coefficient. */
- uint8x16_t row01_nbits = vsubq_u8(vdupq_n_u8(16), row01_lz);
- uint8x16_t row23_nbits = vsubq_u8(vdupq_n_u8(16), row23_lz);
- uint8x16_t row45_nbits = vsubq_u8(vdupq_n_u8(16), row45_lz);
- uint8x16_t row67_nbits = vsubq_u8(vdupq_n_u8(16), row67_lz);
- /* Store nbits. */
- vst1q_u8(block_nbits + 0 * DCTSIZE, row01_nbits);
- vst1q_u8(block_nbits + 2 * DCTSIZE, row23_nbits);
- vst1q_u8(block_nbits + 4 * DCTSIZE, row45_nbits);
- vst1q_u8(block_nbits + 6 * DCTSIZE, row67_nbits);
- /* Mask bits not required to specify sign and amplitude of diff. */
- uint16x8_t row1_mask = vshlq_u16(vcltzq_s16(row1), vnegq_s16(row1_lz));
- uint16x8_t row2_mask = vshlq_u16(vcltzq_s16(row2), vnegq_s16(row2_lz));
- uint16x8_t row3_mask = vshlq_u16(vcltzq_s16(row3), vnegq_s16(row3_lz));
- uint16x8_t row4_mask = vshlq_u16(vcltzq_s16(row4), vnegq_s16(row4_lz));
- uint16x8_t row5_mask = vshlq_u16(vcltzq_s16(row5), vnegq_s16(row5_lz));
- uint16x8_t row6_mask = vshlq_u16(vcltzq_s16(row6), vnegq_s16(row6_lz));
- uint16x8_t row7_mask = vshlq_u16(vcltzq_s16(row7), vnegq_s16(row7_lz));
- /* diff = abs(coeff) ^ sign(coeff) [no-op for positive coefficients] */
- uint16x8_t row1_diff = veorq_u16(vreinterpretq_u16_s16(abs_row1),
- row1_mask);
- uint16x8_t row2_diff = veorq_u16(vreinterpretq_u16_s16(abs_row2),
- row2_mask);
- uint16x8_t row3_diff = veorq_u16(vreinterpretq_u16_s16(abs_row3),
- row3_mask);
- uint16x8_t row4_diff = veorq_u16(vreinterpretq_u16_s16(abs_row4),
- row4_mask);
- uint16x8_t row5_diff = veorq_u16(vreinterpretq_u16_s16(abs_row5),
- row5_mask);
- uint16x8_t row6_diff = veorq_u16(vreinterpretq_u16_s16(abs_row6),
- row6_mask);
- uint16x8_t row7_diff = veorq_u16(vreinterpretq_u16_s16(abs_row7),
- row7_mask);
- /* Store diff bits. */
- vst1q_u16(block_diff + 0 * DCTSIZE, row0_diff);
- vst1q_u16(block_diff + 1 * DCTSIZE, row1_diff);
- vst1q_u16(block_diff + 2 * DCTSIZE, row2_diff);
- vst1q_u16(block_diff + 3 * DCTSIZE, row3_diff);
- vst1q_u16(block_diff + 4 * DCTSIZE, row4_diff);
- vst1q_u16(block_diff + 5 * DCTSIZE, row5_diff);
- vst1q_u16(block_diff + 6 * DCTSIZE, row6_diff);
- vst1q_u16(block_diff + 7 * DCTSIZE, row7_diff);
-
- while (bitmap != 0) {
- r = BUILTIN_CLZLL(bitmap);
- i += r;
- bitmap <<= r;
- nbits = block_nbits[i];
- diff = block_diff[i];
- while (r > 15) {
- /* If run length > 15, emit special run-length-16 codes. */
- PUT_BITS(code_0xf0, size_0xf0)
- r -= 16;
- }
- /* Emit Huffman symbol for run length / number of bits. (F.1.2.2.1) */
- unsigned int rs = (r << 4) + nbits;
- PUT_CODE(actbl->ehufco[rs], actbl->ehufsi[rs], diff)
- i++;
- bitmap <<= 1;
- }
- } else if (bitmap != 0) {
- uint16_t block_abs[DCTSIZE2];
- /* Compute and store absolute value of coefficients. */
- int16x8_t abs_row1 = vabsq_s16(row1);
- int16x8_t abs_row2 = vabsq_s16(row2);
- int16x8_t abs_row3 = vabsq_s16(row3);
- int16x8_t abs_row4 = vabsq_s16(row4);
- int16x8_t abs_row5 = vabsq_s16(row5);
- int16x8_t abs_row6 = vabsq_s16(row6);
- int16x8_t abs_row7 = vabsq_s16(row7);
- vst1q_u16(block_abs + 0 * DCTSIZE, vreinterpretq_u16_s16(abs_row0));
- vst1q_u16(block_abs + 1 * DCTSIZE, vreinterpretq_u16_s16(abs_row1));
- vst1q_u16(block_abs + 2 * DCTSIZE, vreinterpretq_u16_s16(abs_row2));
- vst1q_u16(block_abs + 3 * DCTSIZE, vreinterpretq_u16_s16(abs_row3));
- vst1q_u16(block_abs + 4 * DCTSIZE, vreinterpretq_u16_s16(abs_row4));
- vst1q_u16(block_abs + 5 * DCTSIZE, vreinterpretq_u16_s16(abs_row5));
- vst1q_u16(block_abs + 6 * DCTSIZE, vreinterpretq_u16_s16(abs_row6));
- vst1q_u16(block_abs + 7 * DCTSIZE, vreinterpretq_u16_s16(abs_row7));
- /* Compute diff bits (without nbits mask) and store. */
- uint16x8_t row1_diff = veorq_u16(vreinterpretq_u16_s16(abs_row1),
- vcltzq_s16(row1));
- uint16x8_t row2_diff = veorq_u16(vreinterpretq_u16_s16(abs_row2),
- vcltzq_s16(row2));
- uint16x8_t row3_diff = veorq_u16(vreinterpretq_u16_s16(abs_row3),
- vcltzq_s16(row3));
- uint16x8_t row4_diff = veorq_u16(vreinterpretq_u16_s16(abs_row4),
- vcltzq_s16(row4));
- uint16x8_t row5_diff = veorq_u16(vreinterpretq_u16_s16(abs_row5),
- vcltzq_s16(row5));
- uint16x8_t row6_diff = veorq_u16(vreinterpretq_u16_s16(abs_row6),
- vcltzq_s16(row6));
- uint16x8_t row7_diff = veorq_u16(vreinterpretq_u16_s16(abs_row7),
- vcltzq_s16(row7));
- vst1q_u16(block_diff + 0 * DCTSIZE, row0_diff);
- vst1q_u16(block_diff + 1 * DCTSIZE, row1_diff);
- vst1q_u16(block_diff + 2 * DCTSIZE, row2_diff);
- vst1q_u16(block_diff + 3 * DCTSIZE, row3_diff);
- vst1q_u16(block_diff + 4 * DCTSIZE, row4_diff);
- vst1q_u16(block_diff + 5 * DCTSIZE, row5_diff);
- vst1q_u16(block_diff + 6 * DCTSIZE, row6_diff);
- vst1q_u16(block_diff + 7 * DCTSIZE, row7_diff);
-
- /* Same as above but must mask diff bits and compute nbits on demand. */
- while (bitmap != 0) {
- r = BUILTIN_CLZLL(bitmap);
- i += r;
- bitmap <<= r;
- lz = BUILTIN_CLZ(block_abs[i]);
- nbits = 32 - lz;
- diff = ((unsigned int)block_diff[i] << lz) >> lz;
- while (r > 15) {
- /* If run length > 15, emit special run-length-16 codes. */
- PUT_BITS(code_0xf0, size_0xf0)
- r -= 16;
- }
- /* Emit Huffman symbol for run length / number of bits. (F.1.2.2.1) */
- unsigned int rs = (r << 4) + nbits;
- PUT_CODE(actbl->ehufco[rs], actbl->ehufsi[rs], diff)
- i++;
- bitmap <<= 1;
- }
- }
-
- /* If the last coefficient(s) were zero, emit an end-of-block (EOB) code.
- * The value of RS for the EOB code is 0.
- */
- if (i != 64) {
- PUT_BITS(actbl->ehufco[0], actbl->ehufsi[0])
- }
-
- state_ptr->cur.put_buffer = put_buffer;
- state_ptr->cur.free_bits = free_bits;
-
- return buffer;
-}
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/aarch64/jsimd.c b/contrib/libs/libjpeg-turbo/simd/arm/aarch64/jsimd.c
deleted file mode 100644
index 41c06d3180..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/arm/aarch64/jsimd.c
+++ /dev/null
@@ -1,1056 +0,0 @@
-/*
- * jsimd_arm64.c
- *
- * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- * Copyright (C) 2011, Nokia Corporation and/or its subsidiary(-ies).
- * Copyright (C) 2009-2011, 2013-2014, 2016, 2018, 2020, 2022, D. R. Commander.
- * Copyright (C) 2015-2016, 2018, Matthieu Darbois.
- * Copyright (C) 2020, Arm Limited.
- *
- * Based on the x86 SIMD extension for IJG JPEG library,
- * Copyright (C) 1999-2006, MIYASAKA Masaru.
- * For conditions of distribution and use, see copyright notice in jsimdext.inc
- *
- * This file contains the interface between the "normal" portions
- * of the library and the SIMD implementations when running on a
- * 64-bit Arm architecture.
- */
-
-#define JPEG_INTERNALS
-#include "../../../jinclude.h"
-#include "../../../jpeglib.h"
-#include "../../../jsimd.h"
-#include "../../../jdct.h"
-#include "../../../jsimddct.h"
-#include "../../jsimd.h"
-#include "jconfigint.h"
-
-#include <ctype.h>
-
-#define JSIMD_FASTLD3 1
-#define JSIMD_FASTST3 2
-#define JSIMD_FASTTBL 4
-
-static unsigned int simd_support = ~0;
-static unsigned int simd_huffman = 1;
-static unsigned int simd_features = JSIMD_FASTLD3 | JSIMD_FASTST3 |
- JSIMD_FASTTBL;
-
-#if defined(__linux__) || defined(ANDROID) || defined(__ANDROID__)
-
-#define SOMEWHAT_SANE_PROC_CPUINFO_SIZE_LIMIT (1024 * 1024)
-
-LOCAL(int)
-check_cpuinfo(char *buffer, const char *field, char *value)
-{
- char *p;
-
- if (*value == 0)
- return 0;
- if (strncmp(buffer, field, strlen(field)) != 0)
- return 0;
- buffer += strlen(field);
- while (isspace(*buffer))
- buffer++;
-
- /* Check if 'value' is present in the buffer as a separate word */
- while ((p = strstr(buffer, value))) {
- if (p > buffer && !isspace(*(p - 1))) {
- buffer++;
- continue;
- }
- p += strlen(value);
- if (*p != 0 && !isspace(*p)) {
- buffer++;
- continue;
- }
- return 1;
- }
- return 0;
-}
-
-LOCAL(int)
-parse_proc_cpuinfo(int bufsize)
-{
- char *buffer = (char *)malloc(bufsize);
- FILE *fd;
-
- if (!buffer)
- return 0;
-
- fd = fopen("/proc/cpuinfo", "r");
- if (fd) {
- while (fgets(buffer, bufsize, fd)) {
- if (!strchr(buffer, '\n') && !feof(fd)) {
- /* "impossible" happened - insufficient size of the buffer! */
- fclose(fd);
- free(buffer);
- return 0;
- }
- if (check_cpuinfo(buffer, "CPU part", "0xd03") ||
- check_cpuinfo(buffer, "CPU part", "0xd07"))
- /* The Cortex-A53 has a slow tbl implementation. We can gain a few
- percent speedup by disabling the use of that instruction. The
- speedup on Cortex-A57 is more subtle but still measurable. */
- simd_features &= ~JSIMD_FASTTBL;
- else if (check_cpuinfo(buffer, "CPU part", "0x0a1"))
- /* The SIMD version of Huffman encoding is slower than the C version on
- Cavium ThunderX. Also, ld3 and st3 are abyssmally slow on that
- CPU. */
- simd_huffman = simd_features = 0;
- }
- fclose(fd);
- }
- free(buffer);
- return 1;
-}
-
-#endif
-
-/*
- * Check what SIMD accelerations are supported.
- *
- * FIXME: This code is racy under a multi-threaded environment.
- */
-
-/*
- * Armv8 architectures support Neon extensions by default.
- * It is no longer optional as it was with Armv7.
- */
-
-
-LOCAL(void)
-init_simd(void)
-{
-#ifndef NO_GETENV
- char env[2] = { 0 };
-#endif
-#if defined(__linux__) || defined(ANDROID) || defined(__ANDROID__)
- int bufsize = 1024; /* an initial guess for the line buffer size limit */
-#endif
-
- if (simd_support != ~0U)
- return;
-
- simd_support = 0;
-
- simd_support |= JSIMD_NEON;
-#if defined(__linux__) || defined(ANDROID) || defined(__ANDROID__)
- while (!parse_proc_cpuinfo(bufsize)) {
- bufsize *= 2;
- if (bufsize > SOMEWHAT_SANE_PROC_CPUINFO_SIZE_LIMIT)
- break;
- }
-#endif
-
-#ifndef NO_GETENV
- /* Force different settings through environment variables */
- if (!GETENV_S(env, 2, "JSIMD_FORCENEON") && !strcmp(env, "1"))
- simd_support = JSIMD_NEON;
- if (!GETENV_S(env, 2, "JSIMD_FORCENONE") && !strcmp(env, "1"))
- simd_support = 0;
- if (!GETENV_S(env, 2, "JSIMD_NOHUFFENC") && !strcmp(env, "1"))
- simd_huffman = 0;
- if (!GETENV_S(env, 2, "JSIMD_FASTLD3") && !strcmp(env, "1"))
- simd_features |= JSIMD_FASTLD3;
- if (!GETENV_S(env, 2, "JSIMD_FASTLD3") && !strcmp(env, "0"))
- simd_features &= ~JSIMD_FASTLD3;
- if (!GETENV_S(env, 2, "JSIMD_FASTST3") && !strcmp(env, "1"))
- simd_features |= JSIMD_FASTST3;
- if (!GETENV_S(env, 2, "JSIMD_FASTST3") && !strcmp(env, "0"))
- simd_features &= ~JSIMD_FASTST3;
-#endif
-}
-
-GLOBAL(int)
-jsimd_can_rgb_ycc(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
- if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_rgb_gray(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
- if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_ycc_rgb(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
- if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_ycc_rgb565(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(void)
-jsimd_rgb_ycc_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPIMAGE output_buf, JDIMENSION output_row,
- int num_rows)
-{
- void (*neonfct) (JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int);
-
- switch (cinfo->in_color_space) {
- case JCS_EXT_RGB:
-#ifndef NEON_INTRINSICS
- if (simd_features & JSIMD_FASTLD3)
-#endif
- neonfct = jsimd_extrgb_ycc_convert_neon;
-#ifndef NEON_INTRINSICS
- else
- neonfct = jsimd_extrgb_ycc_convert_neon_slowld3;
-#endif
- break;
- case JCS_EXT_RGBX:
- case JCS_EXT_RGBA:
- neonfct = jsimd_extrgbx_ycc_convert_neon;
- break;
- case JCS_EXT_BGR:
-#ifndef NEON_INTRINSICS
- if (simd_features & JSIMD_FASTLD3)
-#endif
- neonfct = jsimd_extbgr_ycc_convert_neon;
-#ifndef NEON_INTRINSICS
- else
- neonfct = jsimd_extbgr_ycc_convert_neon_slowld3;
-#endif
- break;
- case JCS_EXT_BGRX:
- case JCS_EXT_BGRA:
- neonfct = jsimd_extbgrx_ycc_convert_neon;
- break;
- case JCS_EXT_XBGR:
- case JCS_EXT_ABGR:
- neonfct = jsimd_extxbgr_ycc_convert_neon;
- break;
- case JCS_EXT_XRGB:
- case JCS_EXT_ARGB:
- neonfct = jsimd_extxrgb_ycc_convert_neon;
- break;
- default:
-#ifndef NEON_INTRINSICS
- if (simd_features & JSIMD_FASTLD3)
-#endif
- neonfct = jsimd_extrgb_ycc_convert_neon;
-#ifndef NEON_INTRINSICS
- else
- neonfct = jsimd_extrgb_ycc_convert_neon_slowld3;
-#endif
- break;
- }
-
- neonfct(cinfo->image_width, input_buf, output_buf, output_row, num_rows);
-}
-
-GLOBAL(void)
-jsimd_rgb_gray_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPIMAGE output_buf, JDIMENSION output_row,
- int num_rows)
-{
- void (*neonfct) (JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int);
-
- switch (cinfo->in_color_space) {
- case JCS_EXT_RGB:
- neonfct = jsimd_extrgb_gray_convert_neon;
- break;
- case JCS_EXT_RGBX:
- case JCS_EXT_RGBA:
- neonfct = jsimd_extrgbx_gray_convert_neon;
- break;
- case JCS_EXT_BGR:
- neonfct = jsimd_extbgr_gray_convert_neon;
- break;
- case JCS_EXT_BGRX:
- case JCS_EXT_BGRA:
- neonfct = jsimd_extbgrx_gray_convert_neon;
- break;
- case JCS_EXT_XBGR:
- case JCS_EXT_ABGR:
- neonfct = jsimd_extxbgr_gray_convert_neon;
- break;
- case JCS_EXT_XRGB:
- case JCS_EXT_ARGB:
- neonfct = jsimd_extxrgb_gray_convert_neon;
- break;
- default:
- neonfct = jsimd_extrgb_gray_convert_neon;
- break;
- }
-
- neonfct(cinfo->image_width, input_buf, output_buf, output_row, num_rows);
-}
-
-GLOBAL(void)
-jsimd_ycc_rgb_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf,
- int num_rows)
-{
- void (*neonfct) (JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY, int);
-
- switch (cinfo->out_color_space) {
- case JCS_EXT_RGB:
-#ifndef NEON_INTRINSICS
- if (simd_features & JSIMD_FASTST3)
-#endif
- neonfct = jsimd_ycc_extrgb_convert_neon;
-#ifndef NEON_INTRINSICS
- else
- neonfct = jsimd_ycc_extrgb_convert_neon_slowst3;
-#endif
- break;
- case JCS_EXT_RGBX:
- case JCS_EXT_RGBA:
- neonfct = jsimd_ycc_extrgbx_convert_neon;
- break;
- case JCS_EXT_BGR:
-#ifndef NEON_INTRINSICS
- if (simd_features & JSIMD_FASTST3)
-#endif
- neonfct = jsimd_ycc_extbgr_convert_neon;
-#ifndef NEON_INTRINSICS
- else
- neonfct = jsimd_ycc_extbgr_convert_neon_slowst3;
-#endif
- break;
- case JCS_EXT_BGRX:
- case JCS_EXT_BGRA:
- neonfct = jsimd_ycc_extbgrx_convert_neon;
- break;
- case JCS_EXT_XBGR:
- case JCS_EXT_ABGR:
- neonfct = jsimd_ycc_extxbgr_convert_neon;
- break;
- case JCS_EXT_XRGB:
- case JCS_EXT_ARGB:
- neonfct = jsimd_ycc_extxrgb_convert_neon;
- break;
- default:
-#ifndef NEON_INTRINSICS
- if (simd_features & JSIMD_FASTST3)
-#endif
- neonfct = jsimd_ycc_extrgb_convert_neon;
-#ifndef NEON_INTRINSICS
- else
- neonfct = jsimd_ycc_extrgb_convert_neon_slowst3;
-#endif
- break;
- }
-
- neonfct(cinfo->output_width, input_buf, input_row, output_buf, num_rows);
-}
-
-GLOBAL(void)
-jsimd_ycc_rgb565_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf,
- int num_rows)
-{
- jsimd_ycc_rgb565_convert_neon(cinfo->output_width, input_buf, input_row,
- output_buf, num_rows);
-}
-
-GLOBAL(int)
-jsimd_can_h2v2_downsample(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_h2v1_downsample(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(void)
-jsimd_h2v2_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY output_data)
-{
- jsimd_h2v2_downsample_neon(cinfo->image_width, cinfo->max_v_samp_factor,
- compptr->v_samp_factor, compptr->width_in_blocks,
- input_data, output_data);
-}
-
-GLOBAL(void)
-jsimd_h2v1_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY output_data)
-{
- jsimd_h2v1_downsample_neon(cinfo->image_width, cinfo->max_v_samp_factor,
- compptr->v_samp_factor, compptr->width_in_blocks,
- input_data, output_data);
-}
-
-GLOBAL(int)
-jsimd_can_h2v2_upsample(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_h2v1_upsample(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(void)
-jsimd_h2v2_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
-{
- jsimd_h2v2_upsample_neon(cinfo->max_v_samp_factor, cinfo->output_width,
- input_data, output_data_ptr);
-}
-
-GLOBAL(void)
-jsimd_h2v1_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
-{
- jsimd_h2v1_upsample_neon(cinfo->max_v_samp_factor, cinfo->output_width,
- input_data, output_data_ptr);
-}
-
-GLOBAL(int)
-jsimd_can_h2v2_fancy_upsample(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_h2v1_fancy_upsample(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_h1v2_fancy_upsample(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(void)
-jsimd_h2v2_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
-{
- jsimd_h2v2_fancy_upsample_neon(cinfo->max_v_samp_factor,
- compptr->downsampled_width, input_data,
- output_data_ptr);
-}
-
-GLOBAL(void)
-jsimd_h2v1_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
-{
- jsimd_h2v1_fancy_upsample_neon(cinfo->max_v_samp_factor,
- compptr->downsampled_width, input_data,
- output_data_ptr);
-}
-
-GLOBAL(void)
-jsimd_h1v2_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
-{
- jsimd_h1v2_fancy_upsample_neon(cinfo->max_v_samp_factor,
- compptr->downsampled_width, input_data,
- output_data_ptr);
-}
-
-GLOBAL(int)
-jsimd_can_h2v2_merged_upsample(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_h2v1_merged_upsample(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(void)
-jsimd_h2v2_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
-{
- void (*neonfct) (JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY);
-
- switch (cinfo->out_color_space) {
- case JCS_EXT_RGB:
- neonfct = jsimd_h2v2_extrgb_merged_upsample_neon;
- break;
- case JCS_EXT_RGBX:
- case JCS_EXT_RGBA:
- neonfct = jsimd_h2v2_extrgbx_merged_upsample_neon;
- break;
- case JCS_EXT_BGR:
- neonfct = jsimd_h2v2_extbgr_merged_upsample_neon;
- break;
- case JCS_EXT_BGRX:
- case JCS_EXT_BGRA:
- neonfct = jsimd_h2v2_extbgrx_merged_upsample_neon;
- break;
- case JCS_EXT_XBGR:
- case JCS_EXT_ABGR:
- neonfct = jsimd_h2v2_extxbgr_merged_upsample_neon;
- break;
- case JCS_EXT_XRGB:
- case JCS_EXT_ARGB:
- neonfct = jsimd_h2v2_extxrgb_merged_upsample_neon;
- break;
- default:
- neonfct = jsimd_h2v2_extrgb_merged_upsample_neon;
- break;
- }
-
- neonfct(cinfo->output_width, input_buf, in_row_group_ctr, output_buf);
-}
-
-GLOBAL(void)
-jsimd_h2v1_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
-{
- void (*neonfct) (JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY);
-
- switch (cinfo->out_color_space) {
- case JCS_EXT_RGB:
- neonfct = jsimd_h2v1_extrgb_merged_upsample_neon;
- break;
- case JCS_EXT_RGBX:
- case JCS_EXT_RGBA:
- neonfct = jsimd_h2v1_extrgbx_merged_upsample_neon;
- break;
- case JCS_EXT_BGR:
- neonfct = jsimd_h2v1_extbgr_merged_upsample_neon;
- break;
- case JCS_EXT_BGRX:
- case JCS_EXT_BGRA:
- neonfct = jsimd_h2v1_extbgrx_merged_upsample_neon;
- break;
- case JCS_EXT_XBGR:
- case JCS_EXT_ABGR:
- neonfct = jsimd_h2v1_extxbgr_merged_upsample_neon;
- break;
- case JCS_EXT_XRGB:
- case JCS_EXT_ARGB:
- neonfct = jsimd_h2v1_extxrgb_merged_upsample_neon;
- break;
- default:
- neonfct = jsimd_h2v1_extrgb_merged_upsample_neon;
- break;
- }
-
- neonfct(cinfo->output_width, input_buf, in_row_group_ctr, output_buf);
-}
-
-GLOBAL(int)
-jsimd_can_convsamp(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (DCTSIZE != 8)
- return 0;
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
- if (sizeof(DCTELEM) != 2)
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_convsamp_float(void)
-{
- return 0;
-}
-
-GLOBAL(void)
-jsimd_convsamp(JSAMPARRAY sample_data, JDIMENSION start_col,
- DCTELEM *workspace)
-{
- jsimd_convsamp_neon(sample_data, start_col, workspace);
-}
-
-GLOBAL(void)
-jsimd_convsamp_float(JSAMPARRAY sample_data, JDIMENSION start_col,
- FAST_FLOAT *workspace)
-{
-}
-
-GLOBAL(int)
-jsimd_can_fdct_islow(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(DCTELEM) != 2)
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_fdct_ifast(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(DCTELEM) != 2)
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_fdct_float(void)
-{
- return 0;
-}
-
-GLOBAL(void)
-jsimd_fdct_islow(DCTELEM *data)
-{
- jsimd_fdct_islow_neon(data);
-}
-
-GLOBAL(void)
-jsimd_fdct_ifast(DCTELEM *data)
-{
- jsimd_fdct_ifast_neon(data);
-}
-
-GLOBAL(void)
-jsimd_fdct_float(FAST_FLOAT *data)
-{
-}
-
-GLOBAL(int)
-jsimd_can_quantize(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JCOEF) != 2)
- return 0;
- if (sizeof(DCTELEM) != 2)
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_quantize_float(void)
-{
- return 0;
-}
-
-GLOBAL(void)
-jsimd_quantize(JCOEFPTR coef_block, DCTELEM *divisors, DCTELEM *workspace)
-{
- jsimd_quantize_neon(coef_block, divisors, workspace);
-}
-
-GLOBAL(void)
-jsimd_quantize_float(JCOEFPTR coef_block, FAST_FLOAT *divisors,
- FAST_FLOAT *workspace)
-{
-}
-
-GLOBAL(int)
-jsimd_can_idct_2x2(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JCOEF) != 2)
- return 0;
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
- if (sizeof(ISLOW_MULT_TYPE) != 2)
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_idct_4x4(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JCOEF) != 2)
- return 0;
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
- if (sizeof(ISLOW_MULT_TYPE) != 2)
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(void)
-jsimd_idct_2x2(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
- jsimd_idct_2x2_neon(compptr->dct_table, coef_block, output_buf, output_col);
-}
-
-GLOBAL(void)
-jsimd_idct_4x4(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
- jsimd_idct_4x4_neon(compptr->dct_table, coef_block, output_buf, output_col);
-}
-
-GLOBAL(int)
-jsimd_can_idct_islow(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JCOEF) != 2)
- return 0;
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
- if (sizeof(ISLOW_MULT_TYPE) != 2)
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_idct_ifast(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JCOEF) != 2)
- return 0;
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
- if (sizeof(IFAST_MULT_TYPE) != 2)
- return 0;
- if (IFAST_SCALE_BITS != 2)
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_idct_float(void)
-{
- return 0;
-}
-
-GLOBAL(void)
-jsimd_idct_islow(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
- jsimd_idct_islow_neon(compptr->dct_table, coef_block, output_buf,
- output_col);
-}
-
-GLOBAL(void)
-jsimd_idct_ifast(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
- jsimd_idct_ifast_neon(compptr->dct_table, coef_block, output_buf,
- output_col);
-}
-
-GLOBAL(void)
-jsimd_idct_float(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
-}
-
-GLOBAL(int)
-jsimd_can_huff_encode_one_block(void)
-{
- init_simd();
-
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JCOEF) != 2)
- return 0;
-
- if (simd_support & JSIMD_NEON && simd_huffman)
- return 1;
-
- return 0;
-}
-
-GLOBAL(JOCTET *)
-jsimd_huff_encode_one_block(void *state, JOCTET *buffer, JCOEFPTR block,
- int last_dc_val, c_derived_tbl *dctbl,
- c_derived_tbl *actbl)
-{
-#ifndef NEON_INTRINSICS
- if (simd_features & JSIMD_FASTTBL)
-#endif
- return jsimd_huff_encode_one_block_neon(state, buffer, block, last_dc_val,
- dctbl, actbl);
-#ifndef NEON_INTRINSICS
- else
- return jsimd_huff_encode_one_block_neon_slowtbl(state, buffer, block,
- last_dc_val, dctbl, actbl);
-#endif
-}
-
-GLOBAL(int)
-jsimd_can_encode_mcu_AC_first_prepare(void)
-{
- init_simd();
-
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JCOEF) != 2)
- return 0;
- if (SIZEOF_SIZE_T != 8)
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(void)
-jsimd_encode_mcu_AC_first_prepare(const JCOEF *block,
- const int *jpeg_natural_order_start, int Sl,
- int Al, JCOEF *values, size_t *zerobits)
-{
- jsimd_encode_mcu_AC_first_prepare_neon(block, jpeg_natural_order_start,
- Sl, Al, values, zerobits);
-}
-
-GLOBAL(int)
-jsimd_can_encode_mcu_AC_refine_prepare(void)
-{
- init_simd();
-
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JCOEF) != 2)
- return 0;
- if (SIZEOF_SIZE_T != 8)
- return 0;
-
- if (simd_support & JSIMD_NEON)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_encode_mcu_AC_refine_prepare(const JCOEF *block,
- const int *jpeg_natural_order_start, int Sl,
- int Al, JCOEF *absvalues, size_t *bits)
-{
- return jsimd_encode_mcu_AC_refine_prepare_neon(block,
- jpeg_natural_order_start,
- Sl, Al, absvalues, bits);
-}
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/aarch64/jsimd_neon.S b/contrib/libs/libjpeg-turbo/simd/arm/aarch64/jsimd_neon.S
deleted file mode 100644
index 738a4f0658..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/arm/aarch64/jsimd_neon.S
+++ /dev/null
@@ -1,2254 +0,0 @@
-/*
- * Armv8 Neon optimizations for libjpeg-turbo
- *
- * Copyright (C) 2009-2011, Nokia Corporation and/or its subsidiary(-ies).
- * All Rights Reserved.
- * Author: Siarhei Siamashka <siarhei.siamashka@nokia.com>
- * Copyright (C) 2013-2014, Linaro Limited. All Rights Reserved.
- * Author: Ragesh Radhakrishnan <ragesh.r@linaro.org>
- * Copyright (C) 2014-2016, 2020, D. R. Commander. All Rights Reserved.
- * Copyright (C) 2015-2016, 2018, Matthieu Darbois. All Rights Reserved.
- * Copyright (C) 2016, Siarhei Siamashka. All Rights Reserved.
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- * claim that you wrote the original software. If you use this software
- * in a product, an acknowledgment in the product documentation would be
- * appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must not be
- * misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source distribution.
- */
-
-#if defined(__linux__) && defined(__ELF__)
-.section .note.GNU-stack, "", %progbits /* mark stack as non-executable */
-#endif
-
-#if defined(__APPLE__)
-.section __DATA, __const
-#elif defined(_WIN32)
-.section .rdata
-#else
-.section .rodata, "a", %progbits
-#endif
-
-/* Constants for jsimd_idct_islow_neon() */
-
-#define F_0_298 2446 /* FIX(0.298631336) */
-#define F_0_390 3196 /* FIX(0.390180644) */
-#define F_0_541 4433 /* FIX(0.541196100) */
-#define F_0_765 6270 /* FIX(0.765366865) */
-#define F_0_899 7373 /* FIX(0.899976223) */
-#define F_1_175 9633 /* FIX(1.175875602) */
-#define F_1_501 12299 /* FIX(1.501321110) */
-#define F_1_847 15137 /* FIX(1.847759065) */
-#define F_1_961 16069 /* FIX(1.961570560) */
-#define F_2_053 16819 /* FIX(2.053119869) */
-#define F_2_562 20995 /* FIX(2.562915447) */
-#define F_3_072 25172 /* FIX(3.072711026) */
-
-.balign 16
-Ljsimd_idct_islow_neon_consts:
- .short F_0_298
- .short -F_0_390
- .short F_0_541
- .short F_0_765
- .short - F_0_899
- .short F_1_175
- .short F_1_501
- .short - F_1_847
- .short - F_1_961
- .short F_2_053
- .short - F_2_562
- .short F_3_072
- .short 0 /* padding */
- .short 0
- .short 0
- .short 0
-
-#undef F_0_298
-#undef F_0_390
-#undef F_0_541
-#undef F_0_765
-#undef F_0_899
-#undef F_1_175
-#undef F_1_501
-#undef F_1_847
-#undef F_1_961
-#undef F_2_053
-#undef F_2_562
-#undef F_3_072
-
-/* Constants for jsimd_ycc_*_neon() */
-
-.balign 16
-Ljsimd_ycc_rgb_neon_consts:
- .short 0, 0, 0, 0
- .short 22971, -11277, -23401, 29033
- .short -128, -128, -128, -128
- .short -128, -128, -128, -128
-
-/* Constants for jsimd_*_ycc_neon() */
-
-.balign 16
-Ljsimd_rgb_ycc_neon_consts:
- .short 19595, 38470, 7471, 11059
- .short 21709, 32768, 27439, 5329
- .short 32767, 128, 32767, 128
- .short 32767, 128, 32767, 128
-
-/* Constants for jsimd_fdct_islow_neon() */
-
-#define F_0_298 2446 /* FIX(0.298631336) */
-#define F_0_390 3196 /* FIX(0.390180644) */
-#define F_0_541 4433 /* FIX(0.541196100) */
-#define F_0_765 6270 /* FIX(0.765366865) */
-#define F_0_899 7373 /* FIX(0.899976223) */
-#define F_1_175 9633 /* FIX(1.175875602) */
-#define F_1_501 12299 /* FIX(1.501321110) */
-#define F_1_847 15137 /* FIX(1.847759065) */
-#define F_1_961 16069 /* FIX(1.961570560) */
-#define F_2_053 16819 /* FIX(2.053119869) */
-#define F_2_562 20995 /* FIX(2.562915447) */
-#define F_3_072 25172 /* FIX(3.072711026) */
-
-.balign 16
-Ljsimd_fdct_islow_neon_consts:
- .short F_0_298
- .short -F_0_390
- .short F_0_541
- .short F_0_765
- .short - F_0_899
- .short F_1_175
- .short F_1_501
- .short - F_1_847
- .short - F_1_961
- .short F_2_053
- .short - F_2_562
- .short F_3_072
- .short 0 /* padding */
- .short 0
- .short 0
- .short 0
-
-#undef F_0_298
-#undef F_0_390
-#undef F_0_541
-#undef F_0_765
-#undef F_0_899
-#undef F_1_175
-#undef F_1_501
-#undef F_1_847
-#undef F_1_961
-#undef F_2_053
-#undef F_2_562
-#undef F_3_072
-
-/* Constants for jsimd_huff_encode_one_block_neon() */
-
-.balign 16
-Ljsimd_huff_encode_one_block_neon_consts:
- .byte 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, \
- 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80
- .byte 0, 1, 2, 3, 16, 17, 32, 33, \
- 18, 19, 4, 5, 6, 7, 20, 21 /* L0 => L3 : 4 lines OK */
- .byte 34, 35, 48, 49, 255, 255, 50, 51, \
- 36, 37, 22, 23, 8, 9, 10, 11 /* L0 => L3 : 4 lines OK */
- .byte 8, 9, 22, 23, 36, 37, 50, 51, \
- 255, 255, 255, 255, 255, 255, 52, 53 /* L1 => L4 : 4 lines OK */
- .byte 54, 55, 40, 41, 26, 27, 12, 13, \
- 14, 15, 28, 29, 42, 43, 56, 57 /* L0 => L3 : 4 lines OK */
- .byte 6, 7, 20, 21, 34, 35, 48, 49, \
- 50, 51, 36, 37, 22, 23, 8, 9 /* L4 => L7 : 4 lines OK */
- .byte 42, 43, 28, 29, 14, 15, 30, 31, \
- 44, 45, 58, 59, 255, 255, 255, 255 /* L1 => L4 : 4 lines OK */
- .byte 255, 255, 255, 255, 56, 57, 42, 43, \
- 28, 29, 14, 15, 30, 31, 44, 45 /* L3 => L6 : 4 lines OK */
- .byte 26, 27, 40, 41, 42, 43, 28, 29, \
- 14, 15, 30, 31, 44, 45, 46, 47 /* L5 => L7 : 3 lines OK */
- .byte 255, 255, 255, 255, 0, 1, 255, 255, \
- 255, 255, 255, 255, 255, 255, 255, 255 /* L4 : 1 lines OK */
- .byte 255, 255, 255, 255, 255, 255, 255, 255, \
- 0, 1, 16, 17, 2, 3, 255, 255 /* L5 => L6 : 2 lines OK */
- .byte 255, 255, 255, 255, 255, 255, 255, 255, \
- 255, 255, 255, 255, 8, 9, 22, 23 /* L5 => L6 : 2 lines OK */
- .byte 4, 5, 6, 7, 255, 255, 255, 255, \
- 255, 255, 255, 255, 255, 255, 255, 255 /* L7 : 1 line OK */
-
-.text
-
-
-/*****************************************************************************/
-
-/* Supplementary macro for setting function attributes */
-.macro asm_function fname
-#ifdef __APPLE__
- .private_extern _\fname
- .globl _\fname
-_\fname:
-#else
- .global \fname
-#ifdef __ELF__
- .hidden \fname
- .type \fname, %function
-#endif
-\fname:
-#endif
-.endm
-
-/* Get symbol location */
-.macro get_symbol_loc reg, symbol
-#ifdef __APPLE__
- adrp \reg, \symbol@PAGE
- add \reg, \reg, \symbol@PAGEOFF
-#else
- adrp \reg, \symbol
- add \reg, \reg, :lo12:\symbol
-#endif
-.endm
-
-.macro transpose_8x8 l0, l1, l2, l3, l4, l5, l6, l7, t0, t1, t2, t3
- trn1 \t0\().8h, \l0\().8h, \l1\().8h
- trn1 \t1\().8h, \l2\().8h, \l3\().8h
- trn1 \t2\().8h, \l4\().8h, \l5\().8h
- trn1 \t3\().8h, \l6\().8h, \l7\().8h
- trn2 \l1\().8h, \l0\().8h, \l1\().8h
- trn2 \l3\().8h, \l2\().8h, \l3\().8h
- trn2 \l5\().8h, \l4\().8h, \l5\().8h
- trn2 \l7\().8h, \l6\().8h, \l7\().8h
-
- trn1 \l4\().4s, \t2\().4s, \t3\().4s
- trn2 \t3\().4s, \t2\().4s, \t3\().4s
- trn1 \t2\().4s, \t0\().4s, \t1\().4s
- trn2 \l2\().4s, \t0\().4s, \t1\().4s
- trn1 \t0\().4s, \l1\().4s, \l3\().4s
- trn2 \l3\().4s, \l1\().4s, \l3\().4s
- trn2 \t1\().4s, \l5\().4s, \l7\().4s
- trn1 \l5\().4s, \l5\().4s, \l7\().4s
-
- trn2 \l6\().2d, \l2\().2d, \t3\().2d
- trn1 \l0\().2d, \t2\().2d, \l4\().2d
- trn1 \l1\().2d, \t0\().2d, \l5\().2d
- trn2 \l7\().2d, \l3\().2d, \t1\().2d
- trn1 \l2\().2d, \l2\().2d, \t3\().2d
- trn2 \l4\().2d, \t2\().2d, \l4\().2d
- trn1 \l3\().2d, \l3\().2d, \t1\().2d
- trn2 \l5\().2d, \t0\().2d, \l5\().2d
-.endm
-
-
-#define CENTERJSAMPLE 128
-
-/*****************************************************************************/
-
-/*
- * Perform dequantization and inverse DCT on one block of coefficients.
- *
- * GLOBAL(void)
- * jsimd_idct_islow_neon(void *dct_table, JCOEFPTR coef_block,
- * JSAMPARRAY output_buf, JDIMENSION output_col)
- */
-
-#define CONST_BITS 13
-#define PASS1_BITS 2
-
-#define XFIX_P_0_298 v0.h[0]
-#define XFIX_N_0_390 v0.h[1]
-#define XFIX_P_0_541 v0.h[2]
-#define XFIX_P_0_765 v0.h[3]
-#define XFIX_N_0_899 v0.h[4]
-#define XFIX_P_1_175 v0.h[5]
-#define XFIX_P_1_501 v0.h[6]
-#define XFIX_N_1_847 v0.h[7]
-#define XFIX_N_1_961 v1.h[0]
-#define XFIX_P_2_053 v1.h[1]
-#define XFIX_N_2_562 v1.h[2]
-#define XFIX_P_3_072 v1.h[3]
-
-asm_function jsimd_idct_islow_neon
- DCT_TABLE .req x0
- COEF_BLOCK .req x1
- OUTPUT_BUF .req x2
- OUTPUT_COL .req x3
- TMP1 .req x0
- TMP2 .req x1
- TMP3 .req x9
- TMP4 .req x10
- TMP5 .req x11
- TMP6 .req x12
- TMP7 .req x13
- TMP8 .req x14
-
- /* OUTPUT_COL is a JDIMENSION (unsigned int) argument, so the ABI doesn't
- guarantee that the upper (unused) 32 bits of x3 are valid. This
- instruction ensures that those bits are set to zero. */
- uxtw x3, w3
-
- sub sp, sp, #64
- get_symbol_loc x15, Ljsimd_idct_islow_neon_consts
- mov x10, sp
- st1 {v8.8b, v9.8b, v10.8b, v11.8b}, [x10], #32
- st1 {v12.8b, v13.8b, v14.8b, v15.8b}, [x10], #32
- ld1 {v0.8h, v1.8h}, [x15]
- ld1 {v2.8h, v3.8h, v4.8h, v5.8h}, [COEF_BLOCK], #64
- ld1 {v18.8h, v19.8h, v20.8h, v21.8h}, [DCT_TABLE], #64
- ld1 {v6.8h, v7.8h, v8.8h, v9.8h}, [COEF_BLOCK], #64
- ld1 {v22.8h, v23.8h, v24.8h, v25.8h}, [DCT_TABLE], #64
-
- cmeq v16.8h, v3.8h, #0
- cmeq v26.8h, v4.8h, #0
- cmeq v27.8h, v5.8h, #0
- cmeq v28.8h, v6.8h, #0
- cmeq v29.8h, v7.8h, #0
- cmeq v30.8h, v8.8h, #0
- cmeq v31.8h, v9.8h, #0
-
- and v10.16b, v16.16b, v26.16b
- and v11.16b, v27.16b, v28.16b
- and v12.16b, v29.16b, v30.16b
- and v13.16b, v31.16b, v10.16b
- and v14.16b, v11.16b, v12.16b
- mul v2.8h, v2.8h, v18.8h
- and v15.16b, v13.16b, v14.16b
- shl v10.8h, v2.8h, #(PASS1_BITS)
- sqxtn v16.8b, v15.8h
- mov TMP1, v16.d[0]
- mvn TMP2, TMP1
-
- cbnz TMP2, 2f
- /* case all AC coeffs are zeros */
- dup v2.2d, v10.d[0]
- dup v6.2d, v10.d[1]
- mov v3.16b, v2.16b
- mov v7.16b, v6.16b
- mov v4.16b, v2.16b
- mov v8.16b, v6.16b
- mov v5.16b, v2.16b
- mov v9.16b, v6.16b
-1:
- /* for this transpose, we should organise data like this:
- * 00, 01, 02, 03, 40, 41, 42, 43
- * 10, 11, 12, 13, 50, 51, 52, 53
- * 20, 21, 22, 23, 60, 61, 62, 63
- * 30, 31, 32, 33, 70, 71, 72, 73
- * 04, 05, 06, 07, 44, 45, 46, 47
- * 14, 15, 16, 17, 54, 55, 56, 57
- * 24, 25, 26, 27, 64, 65, 66, 67
- * 34, 35, 36, 37, 74, 75, 76, 77
- */
- trn1 v28.8h, v2.8h, v3.8h
- trn1 v29.8h, v4.8h, v5.8h
- trn1 v30.8h, v6.8h, v7.8h
- trn1 v31.8h, v8.8h, v9.8h
- trn2 v16.8h, v2.8h, v3.8h
- trn2 v17.8h, v4.8h, v5.8h
- trn2 v18.8h, v6.8h, v7.8h
- trn2 v19.8h, v8.8h, v9.8h
- trn1 v2.4s, v28.4s, v29.4s
- trn1 v6.4s, v30.4s, v31.4s
- trn1 v3.4s, v16.4s, v17.4s
- trn1 v7.4s, v18.4s, v19.4s
- trn2 v4.4s, v28.4s, v29.4s
- trn2 v8.4s, v30.4s, v31.4s
- trn2 v5.4s, v16.4s, v17.4s
- trn2 v9.4s, v18.4s, v19.4s
- /* Even part: reverse the even part of the forward DCT. */
- add v18.8h, v4.8h, v8.8h /* z2 + z3 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]) + DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]) */
- add v22.8h, v2.8h, v6.8h /* z2 + z3 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) + DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]) */
- smull2 v19.4s, v18.8h, XFIX_P_0_541 /* z1h z1 = MULTIPLY(z2 + z3, FIX_0_541196100); */
- sub v26.8h, v2.8h, v6.8h /* z2 - z3 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) - DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]) */
- smull v18.4s, v18.4h, XFIX_P_0_541 /* z1l z1 = MULTIPLY(z2 + z3, FIX_0_541196100); */
- sshll2 v23.4s, v22.8h, #(CONST_BITS) /* tmp0h tmp0 = LEFT_SHIFT(z2 + z3, CONST_BITS); */
- mov v21.16b, v19.16b /* tmp3 = z1 */
- mov v20.16b, v18.16b /* tmp3 = z1 */
- smlal2 v19.4s, v8.8h, XFIX_N_1_847 /* tmp2h tmp2 = z1 + MULTIPLY(z3, -FIX_1_847759065); */
- smlal v18.4s, v8.4h, XFIX_N_1_847 /* tmp2l tmp2 = z1 + MULTIPLY(z3, -FIX_1_847759065); */
- sshll2 v27.4s, v26.8h, #(CONST_BITS) /* tmp1h tmp1 = LEFT_SHIFT(z2 - z3, CONST_BITS); */
- smlal2 v21.4s, v4.8h, XFIX_P_0_765 /* tmp3h tmp3 = z1 + MULTIPLY(z2, FIX_0_765366865); */
- smlal v20.4s, v4.4h, XFIX_P_0_765 /* tmp3l tmp3 = z1 + MULTIPLY(z2, FIX_0_765366865); */
- sshll v22.4s, v22.4h, #(CONST_BITS) /* tmp0l tmp0 = LEFT_SHIFT(z2 + z3, CONST_BITS); */
- sshll v26.4s, v26.4h, #(CONST_BITS) /* tmp1l tmp1 = LEFT_SHIFT(z2 - z3, CONST_BITS); */
- add v2.4s, v22.4s, v20.4s /* tmp10l tmp10 = tmp0 + tmp3; */
- sub v6.4s, v22.4s, v20.4s /* tmp13l tmp13 = tmp0 - tmp3; */
- add v8.4s, v26.4s, v18.4s /* tmp11l tmp11 = tmp1 + tmp2; */
- sub v4.4s, v26.4s, v18.4s /* tmp12l tmp12 = tmp1 - tmp2; */
- add v28.4s, v23.4s, v21.4s /* tmp10h tmp10 = tmp0 + tmp3; */
- sub v31.4s, v23.4s, v21.4s /* tmp13h tmp13 = tmp0 - tmp3; */
- add v29.4s, v27.4s, v19.4s /* tmp11h tmp11 = tmp1 + tmp2; */
- sub v30.4s, v27.4s, v19.4s /* tmp12h tmp12 = tmp1 - tmp2; */
-
- /* Odd part per figure 8; the matrix is unitary and hence its
- * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively.
- */
-
- add v22.8h, v9.8h, v5.8h /* z3 = tmp0 + tmp2 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]) + DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]) */
- add v24.8h, v7.8h, v3.8h /* z4 = tmp1 + tmp3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]) + DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]) */
- add v18.8h, v9.8h, v3.8h /* z1 = tmp0 + tmp3 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]) + DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]) */
- add v20.8h, v7.8h, v5.8h /* z2 = tmp1 + tmp2 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]) + DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]) */
- add v26.8h, v22.8h, v24.8h /* z5 = z3 + z4 */
-
- smull2 v11.4s, v9.8h, XFIX_P_0_298 /* tmp0 = MULTIPLY(tmp0, FIX_0_298631336) */
- smull2 v13.4s, v7.8h, XFIX_P_2_053 /* tmp1 = MULTIPLY(tmp1, FIX_2_053119869) */
- smull2 v15.4s, v5.8h, XFIX_P_3_072 /* tmp2 = MULTIPLY(tmp2, FIX_3_072711026) */
- smull2 v17.4s, v3.8h, XFIX_P_1_501 /* tmp3 = MULTIPLY(tmp3, FIX_1_501321110) */
- smull2 v27.4s, v26.8h, XFIX_P_1_175 /* z5h z5 = MULTIPLY(z3 + z4, FIX_1_175875602) */
- smull2 v23.4s, v22.8h, XFIX_N_1_961 /* z3 = MULTIPLY(z3, -FIX_1_961570560) */
- smull2 v25.4s, v24.8h, XFIX_N_0_390 /* z4 = MULTIPLY(z4, -FIX_0_390180644) */
- smull2 v19.4s, v18.8h, XFIX_N_0_899 /* z1 = MULTIPLY(z1, -FIX_0_899976223) */
- smull2 v21.4s, v20.8h, XFIX_N_2_562 /* z2 = MULTIPLY(z2, -FIX_2_562915447) */
-
- smull v10.4s, v9.4h, XFIX_P_0_298 /* tmp0 = MULTIPLY(tmp0, FIX_0_298631336) */
- smull v12.4s, v7.4h, XFIX_P_2_053 /* tmp1 = MULTIPLY(tmp1, FIX_2_053119869) */
- smull v14.4s, v5.4h, XFIX_P_3_072 /* tmp2 = MULTIPLY(tmp2, FIX_3_072711026) */
- smull v16.4s, v3.4h, XFIX_P_1_501 /* tmp3 = MULTIPLY(tmp3, FIX_1_501321110) */
- smull v26.4s, v26.4h, XFIX_P_1_175 /* z5l z5 = MULTIPLY(z3 + z4, FIX_1_175875602) */
- smull v22.4s, v22.4h, XFIX_N_1_961 /* z3 = MULTIPLY(z3, -FIX_1_961570560) */
- smull v24.4s, v24.4h, XFIX_N_0_390 /* z4 = MULTIPLY(z4, -FIX_0_390180644) */
- smull v18.4s, v18.4h, XFIX_N_0_899 /* z1 = MULTIPLY(z1, -FIX_0_899976223) */
- smull v20.4s, v20.4h, XFIX_N_2_562 /* z2 = MULTIPLY(z2, -FIX_2_562915447) */
-
- add v23.4s, v23.4s, v27.4s /* z3 += z5 */
- add v22.4s, v22.4s, v26.4s /* z3 += z5 */
- add v25.4s, v25.4s, v27.4s /* z4 += z5 */
- add v24.4s, v24.4s, v26.4s /* z4 += z5 */
-
- add v11.4s, v11.4s, v19.4s /* tmp0 += z1 */
- add v10.4s, v10.4s, v18.4s /* tmp0 += z1 */
- add v13.4s, v13.4s, v21.4s /* tmp1 += z2 */
- add v12.4s, v12.4s, v20.4s /* tmp1 += z2 */
- add v15.4s, v15.4s, v21.4s /* tmp2 += z2 */
- add v14.4s, v14.4s, v20.4s /* tmp2 += z2 */
- add v17.4s, v17.4s, v19.4s /* tmp3 += z1 */
- add v16.4s, v16.4s, v18.4s /* tmp3 += z1 */
-
- add v11.4s, v11.4s, v23.4s /* tmp0 += z3 */
- add v10.4s, v10.4s, v22.4s /* tmp0 += z3 */
- add v13.4s, v13.4s, v25.4s /* tmp1 += z4 */
- add v12.4s, v12.4s, v24.4s /* tmp1 += z4 */
- add v17.4s, v17.4s, v25.4s /* tmp3 += z4 */
- add v16.4s, v16.4s, v24.4s /* tmp3 += z4 */
- add v15.4s, v15.4s, v23.4s /* tmp2 += z3 */
- add v14.4s, v14.4s, v22.4s /* tmp2 += z3 */
-
- /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
-
- add v18.4s, v2.4s, v16.4s /* tmp10 + tmp3 */
- add v19.4s, v28.4s, v17.4s /* tmp10 + tmp3 */
- sub v20.4s, v2.4s, v16.4s /* tmp10 - tmp3 */
- sub v21.4s, v28.4s, v17.4s /* tmp10 - tmp3 */
- add v22.4s, v8.4s, v14.4s /* tmp11 + tmp2 */
- add v23.4s, v29.4s, v15.4s /* tmp11 + tmp2 */
- sub v24.4s, v8.4s, v14.4s /* tmp11 - tmp2 */
- sub v25.4s, v29.4s, v15.4s /* tmp11 - tmp2 */
- add v26.4s, v4.4s, v12.4s /* tmp12 + tmp1 */
- add v27.4s, v30.4s, v13.4s /* tmp12 + tmp1 */
- sub v28.4s, v4.4s, v12.4s /* tmp12 - tmp1 */
- sub v29.4s, v30.4s, v13.4s /* tmp12 - tmp1 */
- add v14.4s, v6.4s, v10.4s /* tmp13 + tmp0 */
- add v15.4s, v31.4s, v11.4s /* tmp13 + tmp0 */
- sub v16.4s, v6.4s, v10.4s /* tmp13 - tmp0 */
- sub v17.4s, v31.4s, v11.4s /* tmp13 - tmp0 */
-
- shrn v2.4h, v18.4s, #16 /* wsptr[DCTSIZE*0] = (int)DESCALE(tmp10 + tmp3, CONST_BITS+PASS1_BITS+3) */
- shrn v9.4h, v20.4s, #16 /* wsptr[DCTSIZE*7] = (int)DESCALE(tmp10 - tmp3, CONST_BITS+PASS1_BITS+3) */
- shrn v3.4h, v22.4s, #16 /* wsptr[DCTSIZE*1] = (int)DESCALE(tmp11 + tmp2, CONST_BITS+PASS1_BITS+3) */
- shrn v8.4h, v24.4s, #16 /* wsptr[DCTSIZE*6] = (int)DESCALE(tmp11 - tmp2, CONST_BITS+PASS1_BITS+3) */
- shrn v4.4h, v26.4s, #16 /* wsptr[DCTSIZE*2] = (int)DESCALE(tmp12 + tmp1, CONST_BITS+PASS1_BITS+3) */
- shrn v7.4h, v28.4s, #16 /* wsptr[DCTSIZE*5] = (int)DESCALE(tmp12 - tmp1, CONST_BITS+PASS1_BITS+3) */
- shrn v5.4h, v14.4s, #16 /* wsptr[DCTSIZE*3] = (int)DESCALE(tmp13 + tmp0, CONST_BITS+PASS1_BITS+3) */
- shrn v6.4h, v16.4s, #16 /* wsptr[DCTSIZE*4] = (int)DESCALE(tmp13 - tmp0, CONST_BITS+PASS1_BITS+3) */
- shrn2 v2.8h, v19.4s, #16 /* wsptr[DCTSIZE*0] = (int)DESCALE(tmp10 + tmp3, CONST_BITS+PASS1_BITS+3) */
- shrn2 v9.8h, v21.4s, #16 /* wsptr[DCTSIZE*7] = (int)DESCALE(tmp10 - tmp3, CONST_BITS+PASS1_BITS+3) */
- shrn2 v3.8h, v23.4s, #16 /* wsptr[DCTSIZE*1] = (int)DESCALE(tmp11 + tmp2, CONST_BITS+PASS1_BITS+3) */
- shrn2 v8.8h, v25.4s, #16 /* wsptr[DCTSIZE*6] = (int)DESCALE(tmp11 - tmp2, CONST_BITS+PASS1_BITS+3) */
- shrn2 v4.8h, v27.4s, #16 /* wsptr[DCTSIZE*2] = (int)DESCALE(tmp12 + tmp1, CONST_BITS+PASS1_BITS+3) */
- shrn2 v7.8h, v29.4s, #16 /* wsptr[DCTSIZE*5] = (int)DESCALE(tmp12 - tmp1, CONST_BITS+PASS1_BITS+3) */
- shrn2 v5.8h, v15.4s, #16 /* wsptr[DCTSIZE*3] = (int)DESCALE(tmp13 + tmp0, CONST_BITS+PASS1_BITS+3) */
- shrn2 v6.8h, v17.4s, #16 /* wsptr[DCTSIZE*4] = (int)DESCALE(tmp13 - tmp0, CONST_BITS+PASS1_BITS+3) */
- movi v0.16b, #(CENTERJSAMPLE)
- /* Prepare pointers (dual-issue with Neon instructions) */
- ldp TMP1, TMP2, [OUTPUT_BUF], 16
- sqrshrn v28.8b, v2.8h, #(CONST_BITS + PASS1_BITS + 3 - 16)
- ldp TMP3, TMP4, [OUTPUT_BUF], 16
- sqrshrn v29.8b, v3.8h, #(CONST_BITS + PASS1_BITS + 3 - 16)
- add TMP1, TMP1, OUTPUT_COL
- sqrshrn v30.8b, v4.8h, #(CONST_BITS + PASS1_BITS + 3 - 16)
- add TMP2, TMP2, OUTPUT_COL
- sqrshrn v31.8b, v5.8h, #(CONST_BITS + PASS1_BITS + 3 - 16)
- add TMP3, TMP3, OUTPUT_COL
- sqrshrn2 v28.16b, v6.8h, #(CONST_BITS + PASS1_BITS + 3 - 16)
- add TMP4, TMP4, OUTPUT_COL
- sqrshrn2 v29.16b, v7.8h, #(CONST_BITS + PASS1_BITS + 3 - 16)
- ldp TMP5, TMP6, [OUTPUT_BUF], 16
- sqrshrn2 v30.16b, v8.8h, #(CONST_BITS + PASS1_BITS + 3 - 16)
- ldp TMP7, TMP8, [OUTPUT_BUF], 16
- sqrshrn2 v31.16b, v9.8h, #(CONST_BITS + PASS1_BITS + 3 - 16)
- add TMP5, TMP5, OUTPUT_COL
- add v16.16b, v28.16b, v0.16b
- add TMP6, TMP6, OUTPUT_COL
- add v18.16b, v29.16b, v0.16b
- add TMP7, TMP7, OUTPUT_COL
- add v20.16b, v30.16b, v0.16b
- add TMP8, TMP8, OUTPUT_COL
- add v22.16b, v31.16b, v0.16b
-
- /* Transpose the final 8-bit samples */
- trn1 v28.16b, v16.16b, v18.16b
- trn1 v30.16b, v20.16b, v22.16b
- trn2 v29.16b, v16.16b, v18.16b
- trn2 v31.16b, v20.16b, v22.16b
-
- trn1 v16.8h, v28.8h, v30.8h
- trn2 v18.8h, v28.8h, v30.8h
- trn1 v20.8h, v29.8h, v31.8h
- trn2 v22.8h, v29.8h, v31.8h
-
- uzp1 v28.4s, v16.4s, v18.4s
- uzp2 v30.4s, v16.4s, v18.4s
- uzp1 v29.4s, v20.4s, v22.4s
- uzp2 v31.4s, v20.4s, v22.4s
-
- /* Store results to the output buffer */
- st1 {v28.d}[0], [TMP1]
- st1 {v29.d}[0], [TMP2]
- st1 {v28.d}[1], [TMP3]
- st1 {v29.d}[1], [TMP4]
- st1 {v30.d}[0], [TMP5]
- st1 {v31.d}[0], [TMP6]
- st1 {v30.d}[1], [TMP7]
- st1 {v31.d}[1], [TMP8]
- ld1 {v8.8b, v9.8b, v10.8b, v11.8b}, [sp], #32
- ld1 {v12.8b, v13.8b, v14.8b, v15.8b}, [sp], #32
- blr x30
-
-.balign 16
-2:
- mul v3.8h, v3.8h, v19.8h
- mul v4.8h, v4.8h, v20.8h
- mul v5.8h, v5.8h, v21.8h
- add TMP4, xzr, TMP2, LSL #32
- mul v6.8h, v6.8h, v22.8h
- mul v7.8h, v7.8h, v23.8h
- adds TMP3, xzr, TMP2, LSR #32
- mul v8.8h, v8.8h, v24.8h
- mul v9.8h, v9.8h, v25.8h
- b.ne 3f
- /* Right AC coef is zero */
- dup v15.2d, v10.d[1]
- /* Even part: reverse the even part of the forward DCT. */
- add v18.4h, v4.4h, v8.4h /* z2 + z3 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]) + DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]) */
- add v22.4h, v2.4h, v6.4h /* z2 + z3 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) + DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]) */
- sub v26.4h, v2.4h, v6.4h /* z2 - z3 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) - DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]) */
- smull v18.4s, v18.4h, XFIX_P_0_541 /* z1l z1 = MULTIPLY(z2 + z3, FIX_0_541196100); */
- sshll v22.4s, v22.4h, #(CONST_BITS) /* tmp0l tmp0 = LEFT_SHIFT(z2 + z3, CONST_BITS); */
- mov v20.16b, v18.16b /* tmp3 = z1 */
- sshll v26.4s, v26.4h, #(CONST_BITS) /* tmp1l tmp1 = LEFT_SHIFT(z2 - z3, CONST_BITS); */
- smlal v18.4s, v8.4h, XFIX_N_1_847 /* tmp2l tmp2 = z1 + MULTIPLY(z3, -FIX_1_847759065); */
- smlal v20.4s, v4.4h, XFIX_P_0_765 /* tmp3l tmp3 = z1 + MULTIPLY(z2, FIX_0_765366865); */
- add v2.4s, v22.4s, v20.4s /* tmp10l tmp10 = tmp0 + tmp3; */
- sub v6.4s, v22.4s, v20.4s /* tmp13l tmp13 = tmp0 - tmp3; */
- add v8.4s, v26.4s, v18.4s /* tmp11l tmp11 = tmp1 + tmp2; */
- sub v4.4s, v26.4s, v18.4s /* tmp12l tmp12 = tmp1 - tmp2; */
-
- /* Odd part per figure 8; the matrix is unitary and hence its
- * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively.
- */
-
- add v22.4h, v9.4h, v5.4h /* z3 = tmp0 + tmp2 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]) + DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]) */
- add v24.4h, v7.4h, v3.4h /* z4 = tmp1 + tmp3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]) + DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]) */
- add v18.4h, v9.4h, v3.4h /* z1 = tmp0 + tmp3 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]) + DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]) */
- add v20.4h, v7.4h, v5.4h /* z2 = tmp1 + tmp2 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]) + DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]) */
- add v26.4h, v22.4h, v24.4h /* z5 = z3 + z4 */
-
- smull v10.4s, v9.4h, XFIX_P_0_298 /* tmp0 = MULTIPLY(tmp0, FIX_0_298631336) */
- smull v12.4s, v7.4h, XFIX_P_2_053 /* tmp1 = MULTIPLY(tmp1, FIX_2_053119869) */
- smull v14.4s, v5.4h, XFIX_P_3_072 /* tmp2 = MULTIPLY(tmp2, FIX_3_072711026) */
- smull v16.4s, v3.4h, XFIX_P_1_501 /* tmp3 = MULTIPLY(tmp3, FIX_1_501321110) */
- smull v26.4s, v26.4h, XFIX_P_1_175 /* z5l z5 = MULTIPLY(z3 + z4, FIX_1_175875602) */
- smull v22.4s, v22.4h, XFIX_N_1_961 /* z3 = MULTIPLY(z3, -FIX_1_961570560) */
- smull v24.4s, v24.4h, XFIX_N_0_390 /* z4 = MULTIPLY(z4, -FIX_0_390180644) */
- smull v18.4s, v18.4h, XFIX_N_0_899 /* z1 = MULTIPLY(z1, -FIX_0_899976223) */
- smull v20.4s, v20.4h, XFIX_N_2_562 /* z2 = MULTIPLY(z2, -FIX_2_562915447) */
-
- add v22.4s, v22.4s, v26.4s /* z3 += z5 */
- add v24.4s, v24.4s, v26.4s /* z4 += z5 */
-
- add v10.4s, v10.4s, v18.4s /* tmp0 += z1 */
- add v12.4s, v12.4s, v20.4s /* tmp1 += z2 */
- add v14.4s, v14.4s, v20.4s /* tmp2 += z2 */
- add v16.4s, v16.4s, v18.4s /* tmp3 += z1 */
-
- add v10.4s, v10.4s, v22.4s /* tmp0 += z3 */
- add v12.4s, v12.4s, v24.4s /* tmp1 += z4 */
- add v16.4s, v16.4s, v24.4s /* tmp3 += z4 */
- add v14.4s, v14.4s, v22.4s /* tmp2 += z3 */
-
- /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
-
- add v18.4s, v2.4s, v16.4s /* tmp10 + tmp3 */
- sub v20.4s, v2.4s, v16.4s /* tmp10 - tmp3 */
- add v22.4s, v8.4s, v14.4s /* tmp11 + tmp2 */
- sub v24.4s, v8.4s, v14.4s /* tmp11 - tmp2 */
- add v26.4s, v4.4s, v12.4s /* tmp12 + tmp1 */
- sub v28.4s, v4.4s, v12.4s /* tmp12 - tmp1 */
- add v14.4s, v6.4s, v10.4s /* tmp13 + tmp0 */
- sub v16.4s, v6.4s, v10.4s /* tmp13 - tmp0 */
-
- rshrn v2.4h, v18.4s, #(CONST_BITS - PASS1_BITS) /* wsptr[DCTSIZE*0] = (int)DESCALE(tmp10 + tmp3, CONST_BITS-PASS1_BITS) */
- rshrn v3.4h, v22.4s, #(CONST_BITS - PASS1_BITS) /* wsptr[DCTSIZE*1] = (int)DESCALE(tmp11 + tmp2, CONST_BITS-PASS1_BITS) */
- rshrn v4.4h, v26.4s, #(CONST_BITS - PASS1_BITS) /* wsptr[DCTSIZE*2] = (int)DESCALE(tmp12 + tmp1, CONST_BITS-PASS1_BITS) */
- rshrn v5.4h, v14.4s, #(CONST_BITS - PASS1_BITS) /* wsptr[DCTSIZE*3] = (int)DESCALE(tmp13 + tmp0, CONST_BITS-PASS1_BITS) */
- rshrn2 v2.8h, v16.4s, #(CONST_BITS - PASS1_BITS) /* wsptr[DCTSIZE*4] = (int)DESCALE(tmp13 - tmp0, CONST_BITS-PASS1_BITS) */
- rshrn2 v3.8h, v28.4s, #(CONST_BITS - PASS1_BITS) /* wsptr[DCTSIZE*5] = (int)DESCALE(tmp12 - tmp1, CONST_BITS-PASS1_BITS) */
- rshrn2 v4.8h, v24.4s, #(CONST_BITS - PASS1_BITS) /* wsptr[DCTSIZE*6] = (int)DESCALE(tmp11 - tmp2, CONST_BITS-PASS1_BITS) */
- rshrn2 v5.8h, v20.4s, #(CONST_BITS - PASS1_BITS) /* wsptr[DCTSIZE*7] = (int)DESCALE(tmp10 - tmp3, CONST_BITS-PASS1_BITS) */
- mov v6.16b, v15.16b
- mov v7.16b, v15.16b
- mov v8.16b, v15.16b
- mov v9.16b, v15.16b
- b 1b
-
-.balign 16
-3:
- cbnz TMP4, 4f
- /* Left AC coef is zero */
- dup v14.2d, v10.d[0]
- /* Even part: reverse the even part of the forward DCT. */
- add v18.8h, v4.8h, v8.8h /* z2 + z3 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]) + DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]) */
- add v22.8h, v2.8h, v6.8h /* z2 + z3 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) + DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]) */
- smull2 v19.4s, v18.8h, XFIX_P_0_541 /* z1h z1 = MULTIPLY(z2 + z3, FIX_0_541196100); */
- sub v26.8h, v2.8h, v6.8h /* z2 - z3 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) - DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]) */
- sshll2 v23.4s, v22.8h, #(CONST_BITS) /* tmp0h tmp0 = LEFT_SHIFT(z2 + z3, CONST_BITS); */
- mov v21.16b, v19.16b /* tmp3 = z1 */
- smlal2 v19.4s, v8.8h, XFIX_N_1_847 /* tmp2h tmp2 = z1 + MULTIPLY(z3, -FIX_1_847759065); */
- sshll2 v27.4s, v26.8h, #(CONST_BITS) /* tmp1h tmp1 = LEFT_SHIFT(z2 - z3, CONST_BITS); */
- smlal2 v21.4s, v4.8h, XFIX_P_0_765 /* tmp3h tmp3 = z1 + MULTIPLY(z2, FIX_0_765366865); */
- add v28.4s, v23.4s, v21.4s /* tmp10h tmp10 = tmp0 + tmp3; */
- sub v31.4s, v23.4s, v21.4s /* tmp13h tmp13 = tmp0 - tmp3; */
- add v29.4s, v27.4s, v19.4s /* tmp11h tmp11 = tmp1 + tmp2; */
- sub v30.4s, v27.4s, v19.4s /* tmp12h tmp12 = tmp1 - tmp2; */
-
- /* Odd part per figure 8; the matrix is unitary and hence its
- * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively.
- */
-
- add v22.8h, v9.8h, v5.8h /* z3 = tmp0 + tmp2 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]) + DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]) */
- add v24.8h, v7.8h, v3.8h /* z4 = tmp1 + tmp3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]) + DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]) */
- add v18.8h, v9.8h, v3.8h /* z1 = tmp0 + tmp3 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]) + DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]) */
- add v20.8h, v7.8h, v5.8h /* z2 = tmp1 + tmp2 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]) + DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]) */
- add v26.8h, v22.8h, v24.8h /* z5 = z3 + z4 */
-
- smull2 v11.4s, v9.8h, XFIX_P_0_298 /* tmp0 = MULTIPLY(tmp0, FIX_0_298631336) */
- smull2 v13.4s, v7.8h, XFIX_P_2_053 /* tmp1 = MULTIPLY(tmp1, FIX_2_053119869) */
- smull2 v15.4s, v5.8h, XFIX_P_3_072 /* tmp2 = MULTIPLY(tmp2, FIX_3_072711026) */
- smull2 v17.4s, v3.8h, XFIX_P_1_501 /* tmp3 = MULTIPLY(tmp3, FIX_1_501321110) */
- smull2 v27.4s, v26.8h, XFIX_P_1_175 /* z5h z5 = MULTIPLY(z3 + z4, FIX_1_175875602) */
- smull2 v23.4s, v22.8h, XFIX_N_1_961 /* z3 = MULTIPLY(z3, -FIX_1_961570560) */
- smull2 v25.4s, v24.8h, XFIX_N_0_390 /* z4 = MULTIPLY(z4, -FIX_0_390180644) */
- smull2 v19.4s, v18.8h, XFIX_N_0_899 /* z1 = MULTIPLY(z1, -FIX_0_899976223) */
- smull2 v21.4s, v20.8h, XFIX_N_2_562 /* z2 = MULTIPLY(z2, -FIX_2_562915447) */
-
- add v23.4s, v23.4s, v27.4s /* z3 += z5 */
- add v22.4s, v22.4s, v26.4s /* z3 += z5 */
- add v25.4s, v25.4s, v27.4s /* z4 += z5 */
- add v24.4s, v24.4s, v26.4s /* z4 += z5 */
-
- add v11.4s, v11.4s, v19.4s /* tmp0 += z1 */
- add v13.4s, v13.4s, v21.4s /* tmp1 += z2 */
- add v15.4s, v15.4s, v21.4s /* tmp2 += z2 */
- add v17.4s, v17.4s, v19.4s /* tmp3 += z1 */
-
- add v11.4s, v11.4s, v23.4s /* tmp0 += z3 */
- add v13.4s, v13.4s, v25.4s /* tmp1 += z4 */
- add v17.4s, v17.4s, v25.4s /* tmp3 += z4 */
- add v15.4s, v15.4s, v23.4s /* tmp2 += z3 */
-
- /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
-
- add v19.4s, v28.4s, v17.4s /* tmp10 + tmp3 */
- sub v21.4s, v28.4s, v17.4s /* tmp10 - tmp3 */
- add v23.4s, v29.4s, v15.4s /* tmp11 + tmp2 */
- sub v25.4s, v29.4s, v15.4s /* tmp11 - tmp2 */
- add v27.4s, v30.4s, v13.4s /* tmp12 + tmp1 */
- sub v29.4s, v30.4s, v13.4s /* tmp12 - tmp1 */
- add v15.4s, v31.4s, v11.4s /* tmp13 + tmp0 */
- sub v17.4s, v31.4s, v11.4s /* tmp13 - tmp0 */
-
- mov v2.16b, v14.16b
- mov v3.16b, v14.16b
- mov v4.16b, v14.16b
- mov v5.16b, v14.16b
- rshrn v6.4h, v19.4s, #(CONST_BITS - PASS1_BITS) /* wsptr[DCTSIZE*0] = (int)DESCALE(tmp10 + tmp3, CONST_BITS-PASS1_BITS) */
- rshrn v7.4h, v23.4s, #(CONST_BITS - PASS1_BITS) /* wsptr[DCTSIZE*1] = (int)DESCALE(tmp11 + tmp2, CONST_BITS-PASS1_BITS) */
- rshrn v8.4h, v27.4s, #(CONST_BITS - PASS1_BITS) /* wsptr[DCTSIZE*2] = (int)DESCALE(tmp12 + tmp1, CONST_BITS-PASS1_BITS) */
- rshrn v9.4h, v15.4s, #(CONST_BITS - PASS1_BITS) /* wsptr[DCTSIZE*3] = (int)DESCALE(tmp13 + tmp0, CONST_BITS-PASS1_BITS) */
- rshrn2 v6.8h, v17.4s, #(CONST_BITS - PASS1_BITS) /* wsptr[DCTSIZE*4] = (int)DESCALE(tmp13 - tmp0, CONST_BITS-PASS1_BITS) */
- rshrn2 v7.8h, v29.4s, #(CONST_BITS - PASS1_BITS) /* wsptr[DCTSIZE*5] = (int)DESCALE(tmp12 - tmp1, CONST_BITS-PASS1_BITS) */
- rshrn2 v8.8h, v25.4s, #(CONST_BITS - PASS1_BITS) /* wsptr[DCTSIZE*6] = (int)DESCALE(tmp11 - tmp2, CONST_BITS-PASS1_BITS) */
- rshrn2 v9.8h, v21.4s, #(CONST_BITS - PASS1_BITS) /* wsptr[DCTSIZE*7] = (int)DESCALE(tmp10 - tmp3, CONST_BITS-PASS1_BITS) */
- b 1b
-
-.balign 16
-4:
- /* "No" AC coef is zero */
- /* Even part: reverse the even part of the forward DCT. */
- add v18.8h, v4.8h, v8.8h /* z2 + z3 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]) + DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]) */
- add v22.8h, v2.8h, v6.8h /* z2 + z3 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) + DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]) */
- smull2 v19.4s, v18.8h, XFIX_P_0_541 /* z1h z1 = MULTIPLY(z2 + z3, FIX_0_541196100); */
- sub v26.8h, v2.8h, v6.8h /* z2 - z3 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) - DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]) */
- smull v18.4s, v18.4h, XFIX_P_0_541 /* z1l z1 = MULTIPLY(z2 + z3, FIX_0_541196100); */
- sshll2 v23.4s, v22.8h, #(CONST_BITS) /* tmp0h tmp0 = LEFT_SHIFT(z2 + z3, CONST_BITS); */
- mov v21.16b, v19.16b /* tmp3 = z1 */
- mov v20.16b, v18.16b /* tmp3 = z1 */
- smlal2 v19.4s, v8.8h, XFIX_N_1_847 /* tmp2h tmp2 = z1 + MULTIPLY(z3, -FIX_1_847759065); */
- smlal v18.4s, v8.4h, XFIX_N_1_847 /* tmp2l tmp2 = z1 + MULTIPLY(z3, -FIX_1_847759065); */
- sshll2 v27.4s, v26.8h, #(CONST_BITS) /* tmp1h tmp1 = LEFT_SHIFT(z2 - z3, CONST_BITS); */
- smlal2 v21.4s, v4.8h, XFIX_P_0_765 /* tmp3h tmp3 = z1 + MULTIPLY(z2, FIX_0_765366865); */
- smlal v20.4s, v4.4h, XFIX_P_0_765 /* tmp3l tmp3 = z1 + MULTIPLY(z2, FIX_0_765366865); */
- sshll v22.4s, v22.4h, #(CONST_BITS) /* tmp0l tmp0 = LEFT_SHIFT(z2 + z3, CONST_BITS); */
- sshll v26.4s, v26.4h, #(CONST_BITS) /* tmp1l tmp1 = LEFT_SHIFT(z2 - z3, CONST_BITS); */
- add v2.4s, v22.4s, v20.4s /* tmp10l tmp10 = tmp0 + tmp3; */
- sub v6.4s, v22.4s, v20.4s /* tmp13l tmp13 = tmp0 - tmp3; */
- add v8.4s, v26.4s, v18.4s /* tmp11l tmp11 = tmp1 + tmp2; */
- sub v4.4s, v26.4s, v18.4s /* tmp12l tmp12 = tmp1 - tmp2; */
- add v28.4s, v23.4s, v21.4s /* tmp10h tmp10 = tmp0 + tmp3; */
- sub v31.4s, v23.4s, v21.4s /* tmp13h tmp13 = tmp0 - tmp3; */
- add v29.4s, v27.4s, v19.4s /* tmp11h tmp11 = tmp1 + tmp2; */
- sub v30.4s, v27.4s, v19.4s /* tmp12h tmp12 = tmp1 - tmp2; */
-
- /* Odd part per figure 8; the matrix is unitary and hence its
- * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively.
- */
-
- add v22.8h, v9.8h, v5.8h /* z3 = tmp0 + tmp2 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]) + DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]) */
- add v24.8h, v7.8h, v3.8h /* z4 = tmp1 + tmp3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]) + DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]) */
- add v18.8h, v9.8h, v3.8h /* z1 = tmp0 + tmp3 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]) + DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]) */
- add v20.8h, v7.8h, v5.8h /* z2 = tmp1 + tmp2 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]) + DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]) */
- add v26.8h, v22.8h, v24.8h /* z5 = z3 + z4 */
-
- smull2 v11.4s, v9.8h, XFIX_P_0_298 /* tmp0 = MULTIPLY(tmp0, FIX_0_298631336) */
- smull2 v13.4s, v7.8h, XFIX_P_2_053 /* tmp1 = MULTIPLY(tmp1, FIX_2_053119869) */
- smull2 v15.4s, v5.8h, XFIX_P_3_072 /* tmp2 = MULTIPLY(tmp2, FIX_3_072711026) */
- smull2 v17.4s, v3.8h, XFIX_P_1_501 /* tmp3 = MULTIPLY(tmp3, FIX_1_501321110) */
- smull2 v27.4s, v26.8h, XFIX_P_1_175 /* z5h z5 = MULTIPLY(z3 + z4, FIX_1_175875602) */
- smull2 v23.4s, v22.8h, XFIX_N_1_961 /* z3 = MULTIPLY(z3, -FIX_1_961570560) */
- smull2 v25.4s, v24.8h, XFIX_N_0_390 /* z4 = MULTIPLY(z4, -FIX_0_390180644) */
- smull2 v19.4s, v18.8h, XFIX_N_0_899 /* z1 = MULTIPLY(z1, -FIX_0_899976223) */
- smull2 v21.4s, v20.8h, XFIX_N_2_562 /* z2 = MULTIPLY(z2, -FIX_2_562915447) */
-
- smull v10.4s, v9.4h, XFIX_P_0_298 /* tmp0 = MULTIPLY(tmp0, FIX_0_298631336) */
- smull v12.4s, v7.4h, XFIX_P_2_053 /* tmp1 = MULTIPLY(tmp1, FIX_2_053119869) */
- smull v14.4s, v5.4h, XFIX_P_3_072 /* tmp2 = MULTIPLY(tmp2, FIX_3_072711026) */
- smull v16.4s, v3.4h, XFIX_P_1_501 /* tmp3 = MULTIPLY(tmp3, FIX_1_501321110) */
- smull v26.4s, v26.4h, XFIX_P_1_175 /* z5l z5 = MULTIPLY(z3 + z4, FIX_1_175875602) */
- smull v22.4s, v22.4h, XFIX_N_1_961 /* z3 = MULTIPLY(z3, -FIX_1_961570560) */
- smull v24.4s, v24.4h, XFIX_N_0_390 /* z4 = MULTIPLY(z4, -FIX_0_390180644) */
- smull v18.4s, v18.4h, XFIX_N_0_899 /* z1 = MULTIPLY(z1, -FIX_0_899976223) */
- smull v20.4s, v20.4h, XFIX_N_2_562 /* z2 = MULTIPLY(z2, -FIX_2_562915447) */
-
- add v23.4s, v23.4s, v27.4s /* z3 += z5 */
- add v22.4s, v22.4s, v26.4s /* z3 += z5 */
- add v25.4s, v25.4s, v27.4s /* z4 += z5 */
- add v24.4s, v24.4s, v26.4s /* z4 += z5 */
-
- add v11.4s, v11.4s, v19.4s /* tmp0 += z1 */
- add v10.4s, v10.4s, v18.4s /* tmp0 += z1 */
- add v13.4s, v13.4s, v21.4s /* tmp1 += z2 */
- add v12.4s, v12.4s, v20.4s /* tmp1 += z2 */
- add v15.4s, v15.4s, v21.4s /* tmp2 += z2 */
- add v14.4s, v14.4s, v20.4s /* tmp2 += z2 */
- add v17.4s, v17.4s, v19.4s /* tmp3 += z1 */
- add v16.4s, v16.4s, v18.4s /* tmp3 += z1 */
-
- add v11.4s, v11.4s, v23.4s /* tmp0 += z3 */
- add v10.4s, v10.4s, v22.4s /* tmp0 += z3 */
- add v13.4s, v13.4s, v25.4s /* tmp1 += z4 */
- add v12.4s, v12.4s, v24.4s /* tmp1 += z4 */
- add v17.4s, v17.4s, v25.4s /* tmp3 += z4 */
- add v16.4s, v16.4s, v24.4s /* tmp3 += z4 */
- add v15.4s, v15.4s, v23.4s /* tmp2 += z3 */
- add v14.4s, v14.4s, v22.4s /* tmp2 += z3 */
-
- /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
-
- add v18.4s, v2.4s, v16.4s /* tmp10 + tmp3 */
- add v19.4s, v28.4s, v17.4s /* tmp10 + tmp3 */
- sub v20.4s, v2.4s, v16.4s /* tmp10 - tmp3 */
- sub v21.4s, v28.4s, v17.4s /* tmp10 - tmp3 */
- add v22.4s, v8.4s, v14.4s /* tmp11 + tmp2 */
- add v23.4s, v29.4s, v15.4s /* tmp11 + tmp2 */
- sub v24.4s, v8.4s, v14.4s /* tmp11 - tmp2 */
- sub v25.4s, v29.4s, v15.4s /* tmp11 - tmp2 */
- add v26.4s, v4.4s, v12.4s /* tmp12 + tmp1 */
- add v27.4s, v30.4s, v13.4s /* tmp12 + tmp1 */
- sub v28.4s, v4.4s, v12.4s /* tmp12 - tmp1 */
- sub v29.4s, v30.4s, v13.4s /* tmp12 - tmp1 */
- add v14.4s, v6.4s, v10.4s /* tmp13 + tmp0 */
- add v15.4s, v31.4s, v11.4s /* tmp13 + tmp0 */
- sub v16.4s, v6.4s, v10.4s /* tmp13 - tmp0 */
- sub v17.4s, v31.4s, v11.4s /* tmp13 - tmp0 */
-
- rshrn v2.4h, v18.4s, #(CONST_BITS - PASS1_BITS) /* wsptr[DCTSIZE*0] = (int)DESCALE(tmp10 + tmp3, CONST_BITS-PASS1_BITS) */
- rshrn v3.4h, v22.4s, #(CONST_BITS - PASS1_BITS) /* wsptr[DCTSIZE*1] = (int)DESCALE(tmp11 + tmp2, CONST_BITS-PASS1_BITS) */
- rshrn v4.4h, v26.4s, #(CONST_BITS - PASS1_BITS) /* wsptr[DCTSIZE*2] = (int)DESCALE(tmp12 + tmp1, CONST_BITS-PASS1_BITS) */
- rshrn v5.4h, v14.4s, #(CONST_BITS - PASS1_BITS) /* wsptr[DCTSIZE*3] = (int)DESCALE(tmp13 + tmp0, CONST_BITS-PASS1_BITS) */
- rshrn v6.4h, v19.4s, #(CONST_BITS - PASS1_BITS) /* wsptr[DCTSIZE*0] = (int)DESCALE(tmp10 + tmp3, CONST_BITS-PASS1_BITS) */
- rshrn v7.4h, v23.4s, #(CONST_BITS - PASS1_BITS) /* wsptr[DCTSIZE*1] = (int)DESCALE(tmp11 + tmp2, CONST_BITS-PASS1_BITS) */
- rshrn v8.4h, v27.4s, #(CONST_BITS - PASS1_BITS) /* wsptr[DCTSIZE*2] = (int)DESCALE(tmp12 + tmp1, CONST_BITS-PASS1_BITS) */
- rshrn v9.4h, v15.4s, #(CONST_BITS - PASS1_BITS) /* wsptr[DCTSIZE*3] = (int)DESCALE(tmp13 + tmp0, CONST_BITS-PASS1_BITS) */
- rshrn2 v2.8h, v16.4s, #(CONST_BITS - PASS1_BITS) /* wsptr[DCTSIZE*4] = (int)DESCALE(tmp13 - tmp0, CONST_BITS-PASS1_BITS) */
- rshrn2 v3.8h, v28.4s, #(CONST_BITS - PASS1_BITS) /* wsptr[DCTSIZE*5] = (int)DESCALE(tmp12 - tmp1, CONST_BITS-PASS1_BITS) */
- rshrn2 v4.8h, v24.4s, #(CONST_BITS - PASS1_BITS) /* wsptr[DCTSIZE*6] = (int)DESCALE(tmp11 - tmp2, CONST_BITS-PASS1_BITS) */
- rshrn2 v5.8h, v20.4s, #(CONST_BITS - PASS1_BITS) /* wsptr[DCTSIZE*7] = (int)DESCALE(tmp10 - tmp3, CONST_BITS-PASS1_BITS) */
- rshrn2 v6.8h, v17.4s, #(CONST_BITS - PASS1_BITS) /* wsptr[DCTSIZE*4] = (int)DESCALE(tmp13 - tmp0, CONST_BITS-PASS1_BITS) */
- rshrn2 v7.8h, v29.4s, #(CONST_BITS - PASS1_BITS) /* wsptr[DCTSIZE*5] = (int)DESCALE(tmp12 - tmp1, CONST_BITS-PASS1_BITS) */
- rshrn2 v8.8h, v25.4s, #(CONST_BITS - PASS1_BITS) /* wsptr[DCTSIZE*6] = (int)DESCALE(tmp11 - tmp2, CONST_BITS-PASS1_BITS) */
- rshrn2 v9.8h, v21.4s, #(CONST_BITS - PASS1_BITS) /* wsptr[DCTSIZE*7] = (int)DESCALE(tmp10 - tmp3, CONST_BITS-PASS1_BITS) */
- b 1b
-
- .unreq DCT_TABLE
- .unreq COEF_BLOCK
- .unreq OUTPUT_BUF
- .unreq OUTPUT_COL
- .unreq TMP1
- .unreq TMP2
- .unreq TMP3
- .unreq TMP4
- .unreq TMP5
- .unreq TMP6
- .unreq TMP7
- .unreq TMP8
-
-#undef CENTERJSAMPLE
-#undef CONST_BITS
-#undef PASS1_BITS
-#undef XFIX_P_0_298
-#undef XFIX_N_0_390
-#undef XFIX_P_0_541
-#undef XFIX_P_0_765
-#undef XFIX_N_0_899
-#undef XFIX_P_1_175
-#undef XFIX_P_1_501
-#undef XFIX_N_1_847
-#undef XFIX_N_1_961
-#undef XFIX_P_2_053
-#undef XFIX_N_2_562
-#undef XFIX_P_3_072
-
-
-/*****************************************************************************/
-
-/*
- * jsimd_ycc_extrgb_convert_neon
- * jsimd_ycc_extbgr_convert_neon
- * jsimd_ycc_extrgbx_convert_neon
- * jsimd_ycc_extbgrx_convert_neon
- * jsimd_ycc_extxbgr_convert_neon
- * jsimd_ycc_extxrgb_convert_neon
- *
- * Colorspace conversion YCbCr -> RGB
- */
-
-.macro do_load size
- .if \size == 8
- ld1 {v4.8b}, [U], 8
- ld1 {v5.8b}, [V], 8
- ld1 {v0.8b}, [Y], 8
- prfm pldl1keep, [U, #64]
- prfm pldl1keep, [V, #64]
- prfm pldl1keep, [Y, #64]
- .elseif \size == 4
- ld1 {v4.b}[0], [U], 1
- ld1 {v4.b}[1], [U], 1
- ld1 {v4.b}[2], [U], 1
- ld1 {v4.b}[3], [U], 1
- ld1 {v5.b}[0], [V], 1
- ld1 {v5.b}[1], [V], 1
- ld1 {v5.b}[2], [V], 1
- ld1 {v5.b}[3], [V], 1
- ld1 {v0.b}[0], [Y], 1
- ld1 {v0.b}[1], [Y], 1
- ld1 {v0.b}[2], [Y], 1
- ld1 {v0.b}[3], [Y], 1
- .elseif \size == 2
- ld1 {v4.b}[4], [U], 1
- ld1 {v4.b}[5], [U], 1
- ld1 {v5.b}[4], [V], 1
- ld1 {v5.b}[5], [V], 1
- ld1 {v0.b}[4], [Y], 1
- ld1 {v0.b}[5], [Y], 1
- .elseif \size == 1
- ld1 {v4.b}[6], [U], 1
- ld1 {v5.b}[6], [V], 1
- ld1 {v0.b}[6], [Y], 1
- .else
- .error unsupported macroblock size
- .endif
-.endm
-
-.macro do_store bpp, size, fast_st3
- .if \bpp == 24
- .if \size == 8
- .if \fast_st3 == 1
- st3 {v10.8b, v11.8b, v12.8b}, [RGB], 24
- .else
- st1 {v10.b}[0], [RGB], #1
- st1 {v11.b}[0], [RGB], #1
- st1 {v12.b}[0], [RGB], #1
-
- st1 {v10.b}[1], [RGB], #1
- st1 {v11.b}[1], [RGB], #1
- st1 {v12.b}[1], [RGB], #1
-
- st1 {v10.b}[2], [RGB], #1
- st1 {v11.b}[2], [RGB], #1
- st1 {v12.b}[2], [RGB], #1
-
- st1 {v10.b}[3], [RGB], #1
- st1 {v11.b}[3], [RGB], #1
- st1 {v12.b}[3], [RGB], #1
-
- st1 {v10.b}[4], [RGB], #1
- st1 {v11.b}[4], [RGB], #1
- st1 {v12.b}[4], [RGB], #1
-
- st1 {v10.b}[5], [RGB], #1
- st1 {v11.b}[5], [RGB], #1
- st1 {v12.b}[5], [RGB], #1
-
- st1 {v10.b}[6], [RGB], #1
- st1 {v11.b}[6], [RGB], #1
- st1 {v12.b}[6], [RGB], #1
-
- st1 {v10.b}[7], [RGB], #1
- st1 {v11.b}[7], [RGB], #1
- st1 {v12.b}[7], [RGB], #1
- .endif
- .elseif \size == 4
- st3 {v10.b, v11.b, v12.b}[0], [RGB], 3
- st3 {v10.b, v11.b, v12.b}[1], [RGB], 3
- st3 {v10.b, v11.b, v12.b}[2], [RGB], 3
- st3 {v10.b, v11.b, v12.b}[3], [RGB], 3
- .elseif \size == 2
- st3 {v10.b, v11.b, v12.b}[4], [RGB], 3
- st3 {v10.b, v11.b, v12.b}[5], [RGB], 3
- .elseif \size == 1
- st3 {v10.b, v11.b, v12.b}[6], [RGB], 3
- .else
- .error unsupported macroblock size
- .endif
- .elseif \bpp == 32
- .if \size == 8
- st4 {v10.8b, v11.8b, v12.8b, v13.8b}, [RGB], 32
- .elseif \size == 4
- st4 {v10.b, v11.b, v12.b, v13.b}[0], [RGB], 4
- st4 {v10.b, v11.b, v12.b, v13.b}[1], [RGB], 4
- st4 {v10.b, v11.b, v12.b, v13.b}[2], [RGB], 4
- st4 {v10.b, v11.b, v12.b, v13.b}[3], [RGB], 4
- .elseif \size == 2
- st4 {v10.b, v11.b, v12.b, v13.b}[4], [RGB], 4
- st4 {v10.b, v11.b, v12.b, v13.b}[5], [RGB], 4
- .elseif \size == 1
- st4 {v10.b, v11.b, v12.b, v13.b}[6], [RGB], 4
- .else
- .error unsupported macroblock size
- .endif
- .elseif \bpp == 16
- .if \size == 8
- st1 {v25.8h}, [RGB], 16
- .elseif \size == 4
- st1 {v25.4h}, [RGB], 8
- .elseif \size == 2
- st1 {v25.h}[4], [RGB], 2
- st1 {v25.h}[5], [RGB], 2
- .elseif \size == 1
- st1 {v25.h}[6], [RGB], 2
- .else
- .error unsupported macroblock size
- .endif
- .else
- .error unsupported bpp
- .endif
-.endm
-
-.macro generate_jsimd_ycc_rgb_convert_neon colorid, bpp, r_offs, rsize, \
- g_offs, gsize, b_offs, bsize, \
- defsize, fast_st3
-
-/*
- * 2-stage pipelined YCbCr->RGB conversion
- */
-
-.macro do_yuv_to_rgb_stage1
- uaddw v6.8h, v2.8h, v4.8b /* q3 = u - 128 */
- uaddw v8.8h, v2.8h, v5.8b /* q2 = v - 128 */
- smull v20.4s, v6.4h, v1.h[1] /* multiply by -11277 */
- smlal v20.4s, v8.4h, v1.h[2] /* multiply by -23401 */
- smull2 v22.4s, v6.8h, v1.h[1] /* multiply by -11277 */
- smlal2 v22.4s, v8.8h, v1.h[2] /* multiply by -23401 */
- smull v24.4s, v8.4h, v1.h[0] /* multiply by 22971 */
- smull2 v26.4s, v8.8h, v1.h[0] /* multiply by 22971 */
- smull v28.4s, v6.4h, v1.h[3] /* multiply by 29033 */
- smull2 v30.4s, v6.8h, v1.h[3] /* multiply by 29033 */
-.endm
-
-.macro do_yuv_to_rgb_stage2
- rshrn v20.4h, v20.4s, #15
- rshrn2 v20.8h, v22.4s, #15
- rshrn v24.4h, v24.4s, #14
- rshrn2 v24.8h, v26.4s, #14
- rshrn v28.4h, v28.4s, #14
- rshrn2 v28.8h, v30.4s, #14
- uaddw v20.8h, v20.8h, v0.8b
- uaddw v24.8h, v24.8h, v0.8b
- uaddw v28.8h, v28.8h, v0.8b
- .if \bpp != 16
- sqxtun v1\g_offs\defsize, v20.8h
- sqxtun v1\r_offs\defsize, v24.8h
- sqxtun v1\b_offs\defsize, v28.8h
- .else
- sqshlu v21.8h, v20.8h, #8
- sqshlu v25.8h, v24.8h, #8
- sqshlu v29.8h, v28.8h, #8
- sri v25.8h, v21.8h, #5
- sri v25.8h, v29.8h, #11
- .endif
-.endm
-
-.macro do_yuv_to_rgb_stage2_store_load_stage1 fast_st3
- rshrn v20.4h, v20.4s, #15
- rshrn v24.4h, v24.4s, #14
- rshrn v28.4h, v28.4s, #14
- ld1 {v4.8b}, [U], 8
- rshrn2 v20.8h, v22.4s, #15
- rshrn2 v24.8h, v26.4s, #14
- rshrn2 v28.8h, v30.4s, #14
- ld1 {v5.8b}, [V], 8
- uaddw v20.8h, v20.8h, v0.8b
- uaddw v24.8h, v24.8h, v0.8b
- uaddw v28.8h, v28.8h, v0.8b
- .if \bpp != 16 /**************** rgb24/rgb32 ******************************/
- sqxtun v1\g_offs\defsize, v20.8h
- ld1 {v0.8b}, [Y], 8
- sqxtun v1\r_offs\defsize, v24.8h
- prfm pldl1keep, [U, #64]
- prfm pldl1keep, [V, #64]
- prfm pldl1keep, [Y, #64]
- sqxtun v1\b_offs\defsize, v28.8h
- uaddw v6.8h, v2.8h, v4.8b /* v6.16b = u - 128 */
- uaddw v8.8h, v2.8h, v5.8b /* q2 = v - 128 */
- smull v20.4s, v6.4h, v1.h[1] /* multiply by -11277 */
- smlal v20.4s, v8.4h, v1.h[2] /* multiply by -23401 */
- smull2 v22.4s, v6.8h, v1.h[1] /* multiply by -11277 */
- smlal2 v22.4s, v8.8h, v1.h[2] /* multiply by -23401 */
- smull v24.4s, v8.4h, v1.h[0] /* multiply by 22971 */
- smull2 v26.4s, v8.8h, v1.h[0] /* multiply by 22971 */
- .else /**************************** rgb565 ********************************/
- sqshlu v21.8h, v20.8h, #8
- sqshlu v25.8h, v24.8h, #8
- sqshlu v29.8h, v28.8h, #8
- uaddw v6.8h, v2.8h, v4.8b /* v6.16b = u - 128 */
- uaddw v8.8h, v2.8h, v5.8b /* q2 = v - 128 */
- ld1 {v0.8b}, [Y], 8
- smull v20.4s, v6.4h, v1.h[1] /* multiply by -11277 */
- smlal v20.4s, v8.4h, v1.h[2] /* multiply by -23401 */
- smull2 v22.4s, v6.8h, v1.h[1] /* multiply by -11277 */
- smlal2 v22.4s, v8.8h, v1.h[2] /* multiply by -23401 */
- sri v25.8h, v21.8h, #5
- smull v24.4s, v8.4h, v1.h[0] /* multiply by 22971 */
- smull2 v26.4s, v8.8h, v1.h[0] /* multiply by 22971 */
- prfm pldl1keep, [U, #64]
- prfm pldl1keep, [V, #64]
- prfm pldl1keep, [Y, #64]
- sri v25.8h, v29.8h, #11
- .endif
- do_store \bpp, 8, \fast_st3
- smull v28.4s, v6.4h, v1.h[3] /* multiply by 29033 */
- smull2 v30.4s, v6.8h, v1.h[3] /* multiply by 29033 */
-.endm
-
-.macro do_yuv_to_rgb
- do_yuv_to_rgb_stage1
- do_yuv_to_rgb_stage2
-.endm
-
-.if \fast_st3 == 1
-asm_function jsimd_ycc_\colorid\()_convert_neon
-.else
-asm_function jsimd_ycc_\colorid\()_convert_neon_slowst3
-.endif
- OUTPUT_WIDTH .req w0
- INPUT_BUF .req x1
- INPUT_ROW .req w2
- OUTPUT_BUF .req x3
- NUM_ROWS .req w4
-
- INPUT_BUF0 .req x5
- INPUT_BUF1 .req x6
- INPUT_BUF2 .req x1
-
- RGB .req x7
- Y .req x9
- U .req x10
- V .req x11
- N .req w15
-
- sub sp, sp, 64
- mov x9, sp
-
- /* Load constants to d1, d2, d3 (v0.4h is just used for padding) */
- get_symbol_loc x15, Ljsimd_ycc_rgb_neon_consts
-
- /* Save Neon registers */
- st1 {v8.8b, v9.8b, v10.8b, v11.8b}, [x9], 32
- st1 {v12.8b, v13.8b, v14.8b, v15.8b}, [x9], 32
- ld1 {v0.4h, v1.4h}, [x15], 16
- ld1 {v2.8h}, [x15]
-
- ldr INPUT_BUF0, [INPUT_BUF]
- ldr INPUT_BUF1, [INPUT_BUF, #8]
- ldr INPUT_BUF2, [INPUT_BUF, #16]
- .unreq INPUT_BUF
-
- /* Initially set v10, v11.4h, v12.8b, d13 to 0xFF */
- movi v10.16b, #255
- movi v13.16b, #255
-
- /* Outer loop over scanlines */
- cmp NUM_ROWS, #1
- b.lt 9f
-0:
- ldr Y, [INPUT_BUF0, INPUT_ROW, uxtw #3]
- ldr U, [INPUT_BUF1, INPUT_ROW, uxtw #3]
- mov N, OUTPUT_WIDTH
- ldr V, [INPUT_BUF2, INPUT_ROW, uxtw #3]
- add INPUT_ROW, INPUT_ROW, #1
- ldr RGB, [OUTPUT_BUF], #8
-
- /* Inner loop over pixels */
- subs N, N, #8
- b.lt 3f
- do_load 8
- do_yuv_to_rgb_stage1
- subs N, N, #8
- b.lt 2f
-1:
- do_yuv_to_rgb_stage2_store_load_stage1 \fast_st3
- subs N, N, #8
- b.ge 1b
-2:
- do_yuv_to_rgb_stage2
- do_store \bpp, 8, \fast_st3
- tst N, #7
- b.eq 8f
-3:
- tst N, #4
- b.eq 3f
- do_load 4
-3:
- tst N, #2
- b.eq 4f
- do_load 2
-4:
- tst N, #1
- b.eq 5f
- do_load 1
-5:
- do_yuv_to_rgb
- tst N, #4
- b.eq 6f
- do_store \bpp, 4, \fast_st3
-6:
- tst N, #2
- b.eq 7f
- do_store \bpp, 2, \fast_st3
-7:
- tst N, #1
- b.eq 8f
- do_store \bpp, 1, \fast_st3
-8:
- subs NUM_ROWS, NUM_ROWS, #1
- b.gt 0b
-9:
- /* Restore all registers and return */
- ld1 {v8.8b, v9.8b, v10.8b, v11.8b}, [sp], 32
- ld1 {v12.8b, v13.8b, v14.8b, v15.8b}, [sp], 32
- br x30
- .unreq OUTPUT_WIDTH
- .unreq INPUT_ROW
- .unreq OUTPUT_BUF
- .unreq NUM_ROWS
- .unreq INPUT_BUF0
- .unreq INPUT_BUF1
- .unreq INPUT_BUF2
- .unreq RGB
- .unreq Y
- .unreq U
- .unreq V
- .unreq N
-
-.purgem do_yuv_to_rgb
-.purgem do_yuv_to_rgb_stage1
-.purgem do_yuv_to_rgb_stage2
-.purgem do_yuv_to_rgb_stage2_store_load_stage1
-
-.endm
-
-/*--------------------------------- id ----- bpp R rsize G gsize B bsize defsize fast_st3*/
-generate_jsimd_ycc_rgb_convert_neon extrgb, 24, 0, .4h, 1, .4h, 2, .4h, .8b, 1
-generate_jsimd_ycc_rgb_convert_neon extbgr, 24, 2, .4h, 1, .4h, 0, .4h, .8b, 1
-generate_jsimd_ycc_rgb_convert_neon extrgbx, 32, 0, .4h, 1, .4h, 2, .4h, .8b, 1
-generate_jsimd_ycc_rgb_convert_neon extbgrx, 32, 2, .4h, 1, .4h, 0, .4h, .8b, 1
-generate_jsimd_ycc_rgb_convert_neon extxbgr, 32, 3, .4h, 2, .4h, 1, .4h, .8b, 1
-generate_jsimd_ycc_rgb_convert_neon extxrgb, 32, 1, .4h, 2, .4h, 3, .4h, .8b, 1
-generate_jsimd_ycc_rgb_convert_neon rgb565, 16, 0, .4h, 0, .4h, 0, .4h, .8b, 1
-
-generate_jsimd_ycc_rgb_convert_neon extrgb, 24, 0, .4h, 1, .4h, 2, .4h, .8b, 0
-generate_jsimd_ycc_rgb_convert_neon extbgr, 24, 2, .4h, 1, .4h, 0, .4h, .8b, 0
-
-.purgem do_load
-.purgem do_store
-
-
-/*****************************************************************************/
-
-/*
- * jsimd_extrgb_ycc_convert_neon
- * jsimd_extbgr_ycc_convert_neon
- * jsimd_extrgbx_ycc_convert_neon
- * jsimd_extbgrx_ycc_convert_neon
- * jsimd_extxbgr_ycc_convert_neon
- * jsimd_extxrgb_ycc_convert_neon
- *
- * Colorspace conversion RGB -> YCbCr
- */
-
-.macro do_store size
- .if \size == 8
- st1 {v20.8b}, [Y], #8
- st1 {v21.8b}, [U], #8
- st1 {v22.8b}, [V], #8
- .elseif \size == 4
- st1 {v20.b}[0], [Y], #1
- st1 {v20.b}[1], [Y], #1
- st1 {v20.b}[2], [Y], #1
- st1 {v20.b}[3], [Y], #1
- st1 {v21.b}[0], [U], #1
- st1 {v21.b}[1], [U], #1
- st1 {v21.b}[2], [U], #1
- st1 {v21.b}[3], [U], #1
- st1 {v22.b}[0], [V], #1
- st1 {v22.b}[1], [V], #1
- st1 {v22.b}[2], [V], #1
- st1 {v22.b}[3], [V], #1
- .elseif \size == 2
- st1 {v20.b}[4], [Y], #1
- st1 {v20.b}[5], [Y], #1
- st1 {v21.b}[4], [U], #1
- st1 {v21.b}[5], [U], #1
- st1 {v22.b}[4], [V], #1
- st1 {v22.b}[5], [V], #1
- .elseif \size == 1
- st1 {v20.b}[6], [Y], #1
- st1 {v21.b}[6], [U], #1
- st1 {v22.b}[6], [V], #1
- .else
- .error unsupported macroblock size
- .endif
-.endm
-
-.macro do_load bpp, size, fast_ld3
- .if \bpp == 24
- .if \size == 8
- .if \fast_ld3 == 1
- ld3 {v10.8b, v11.8b, v12.8b}, [RGB], #24
- .else
- ld1 {v10.b}[0], [RGB], #1
- ld1 {v11.b}[0], [RGB], #1
- ld1 {v12.b}[0], [RGB], #1
-
- ld1 {v10.b}[1], [RGB], #1
- ld1 {v11.b}[1], [RGB], #1
- ld1 {v12.b}[1], [RGB], #1
-
- ld1 {v10.b}[2], [RGB], #1
- ld1 {v11.b}[2], [RGB], #1
- ld1 {v12.b}[2], [RGB], #1
-
- ld1 {v10.b}[3], [RGB], #1
- ld1 {v11.b}[3], [RGB], #1
- ld1 {v12.b}[3], [RGB], #1
-
- ld1 {v10.b}[4], [RGB], #1
- ld1 {v11.b}[4], [RGB], #1
- ld1 {v12.b}[4], [RGB], #1
-
- ld1 {v10.b}[5], [RGB], #1
- ld1 {v11.b}[5], [RGB], #1
- ld1 {v12.b}[5], [RGB], #1
-
- ld1 {v10.b}[6], [RGB], #1
- ld1 {v11.b}[6], [RGB], #1
- ld1 {v12.b}[6], [RGB], #1
-
- ld1 {v10.b}[7], [RGB], #1
- ld1 {v11.b}[7], [RGB], #1
- ld1 {v12.b}[7], [RGB], #1
- .endif
- prfm pldl1keep, [RGB, #128]
- .elseif \size == 4
- ld3 {v10.b, v11.b, v12.b}[0], [RGB], #3
- ld3 {v10.b, v11.b, v12.b}[1], [RGB], #3
- ld3 {v10.b, v11.b, v12.b}[2], [RGB], #3
- ld3 {v10.b, v11.b, v12.b}[3], [RGB], #3
- .elseif \size == 2
- ld3 {v10.b, v11.b, v12.b}[4], [RGB], #3
- ld3 {v10.b, v11.b, v12.b}[5], [RGB], #3
- .elseif \size == 1
- ld3 {v10.b, v11.b, v12.b}[6], [RGB], #3
- .else
- .error unsupported macroblock size
- .endif
- .elseif \bpp == 32
- .if \size == 8
- ld4 {v10.8b, v11.8b, v12.8b, v13.8b}, [RGB], #32
- prfm pldl1keep, [RGB, #128]
- .elseif \size == 4
- ld4 {v10.b, v11.b, v12.b, v13.b}[0], [RGB], #4
- ld4 {v10.b, v11.b, v12.b, v13.b}[1], [RGB], #4
- ld4 {v10.b, v11.b, v12.b, v13.b}[2], [RGB], #4
- ld4 {v10.b, v11.b, v12.b, v13.b}[3], [RGB], #4
- .elseif \size == 2
- ld4 {v10.b, v11.b, v12.b, v13.b}[4], [RGB], #4
- ld4 {v10.b, v11.b, v12.b, v13.b}[5], [RGB], #4
- .elseif \size == 1
- ld4 {v10.b, v11.b, v12.b, v13.b}[6], [RGB], #4
- .else
- .error unsupported macroblock size
- .endif
- .else
- .error unsupported bpp
- .endif
-.endm
-
-.macro generate_jsimd_rgb_ycc_convert_neon colorid, bpp, r_offs, g_offs, \
- b_offs, fast_ld3
-
-/*
- * 2-stage pipelined RGB->YCbCr conversion
- */
-
-.macro do_rgb_to_yuv_stage1
- ushll v4.8h, v1\r_offs\().8b, #0 /* r = v4 */
- ushll v6.8h, v1\g_offs\().8b, #0 /* g = v6 */
- ushll v8.8h, v1\b_offs\().8b, #0 /* b = v8 */
- rev64 v18.4s, v1.4s
- rev64 v26.4s, v1.4s
- rev64 v28.4s, v1.4s
- rev64 v30.4s, v1.4s
- umull v14.4s, v4.4h, v0.h[0]
- umull2 v16.4s, v4.8h, v0.h[0]
- umlsl v18.4s, v4.4h, v0.h[3]
- umlsl2 v26.4s, v4.8h, v0.h[3]
- umlal v28.4s, v4.4h, v0.h[5]
- umlal2 v30.4s, v4.8h, v0.h[5]
- umlal v14.4s, v6.4h, v0.h[1]
- umlal2 v16.4s, v6.8h, v0.h[1]
- umlsl v18.4s, v6.4h, v0.h[4]
- umlsl2 v26.4s, v6.8h, v0.h[4]
- umlsl v28.4s, v6.4h, v0.h[6]
- umlsl2 v30.4s, v6.8h, v0.h[6]
- umlal v14.4s, v8.4h, v0.h[2]
- umlal2 v16.4s, v8.8h, v0.h[2]
- umlal v18.4s, v8.4h, v0.h[5]
- umlal2 v26.4s, v8.8h, v0.h[5]
- umlsl v28.4s, v8.4h, v0.h[7]
- umlsl2 v30.4s, v8.8h, v0.h[7]
-.endm
-
-.macro do_rgb_to_yuv_stage2
- rshrn v20.4h, v14.4s, #16
- shrn v22.4h, v18.4s, #16
- shrn v24.4h, v28.4s, #16
- rshrn2 v20.8h, v16.4s, #16
- shrn2 v22.8h, v26.4s, #16
- shrn2 v24.8h, v30.4s, #16
- xtn v20.8b, v20.8h /* v20 = y */
- xtn v21.8b, v22.8h /* v21 = u */
- xtn v22.8b, v24.8h /* v22 = v */
-.endm
-
-.macro do_rgb_to_yuv
- do_rgb_to_yuv_stage1
- do_rgb_to_yuv_stage2
-.endm
-
-/* TODO: expand macros and interleave instructions if some in-order
- * AArch64 processor actually can dual-issue LOAD/STORE with ALU */
-.macro do_rgb_to_yuv_stage2_store_load_stage1 fast_ld3
- do_rgb_to_yuv_stage2
- do_load \bpp, 8, \fast_ld3
- st1 {v20.8b}, [Y], #8
- st1 {v21.8b}, [U], #8
- st1 {v22.8b}, [V], #8
- do_rgb_to_yuv_stage1
-.endm
-
-.if \fast_ld3 == 1
-asm_function jsimd_\colorid\()_ycc_convert_neon
-.else
-asm_function jsimd_\colorid\()_ycc_convert_neon_slowld3
-.endif
- OUTPUT_WIDTH .req w0
- INPUT_BUF .req x1
- OUTPUT_BUF .req x2
- OUTPUT_ROW .req w3
- NUM_ROWS .req w4
-
- OUTPUT_BUF0 .req x5
- OUTPUT_BUF1 .req x6
- OUTPUT_BUF2 .req x2 /* OUTPUT_BUF */
-
- RGB .req x7
- Y .req x9
- U .req x10
- V .req x11
- N .req w12
-
- /* Load constants to d0, d1, d2, d3 */
- get_symbol_loc x13, Ljsimd_rgb_ycc_neon_consts
- ld1 {v0.8h, v1.8h}, [x13]
-
- ldr OUTPUT_BUF0, [OUTPUT_BUF]
- ldr OUTPUT_BUF1, [OUTPUT_BUF, #8]
- ldr OUTPUT_BUF2, [OUTPUT_BUF, #16]
- .unreq OUTPUT_BUF
-
- /* Save Neon registers */
- sub sp, sp, #64
- mov x9, sp
- st1 {v8.8b, v9.8b, v10.8b, v11.8b}, [x9], 32
- st1 {v12.8b, v13.8b, v14.8b, v15.8b}, [x9], 32
-
- /* Outer loop over scanlines */
- cmp NUM_ROWS, #1
- b.lt 9f
-0:
- ldr Y, [OUTPUT_BUF0, OUTPUT_ROW, uxtw #3]
- ldr U, [OUTPUT_BUF1, OUTPUT_ROW, uxtw #3]
- mov N, OUTPUT_WIDTH
- ldr V, [OUTPUT_BUF2, OUTPUT_ROW, uxtw #3]
- add OUTPUT_ROW, OUTPUT_ROW, #1
- ldr RGB, [INPUT_BUF], #8
-
- /* Inner loop over pixels */
- subs N, N, #8
- b.lt 3f
- do_load \bpp, 8, \fast_ld3
- do_rgb_to_yuv_stage1
- subs N, N, #8
- b.lt 2f
-1:
- do_rgb_to_yuv_stage2_store_load_stage1 \fast_ld3
- subs N, N, #8
- b.ge 1b
-2:
- do_rgb_to_yuv_stage2
- do_store 8
- tst N, #7
- b.eq 8f
-3:
- tbz N, #2, 3f
- do_load \bpp, 4, \fast_ld3
-3:
- tbz N, #1, 4f
- do_load \bpp, 2, \fast_ld3
-4:
- tbz N, #0, 5f
- do_load \bpp, 1, \fast_ld3
-5:
- do_rgb_to_yuv
- tbz N, #2, 6f
- do_store 4
-6:
- tbz N, #1, 7f
- do_store 2
-7:
- tbz N, #0, 8f
- do_store 1
-8:
- subs NUM_ROWS, NUM_ROWS, #1
- b.gt 0b
-9:
- /* Restore all registers and return */
- ld1 {v8.8b, v9.8b, v10.8b, v11.8b}, [sp], 32
- ld1 {v12.8b, v13.8b, v14.8b, v15.8b}, [sp], 32
- br x30
-
- .unreq OUTPUT_WIDTH
- .unreq OUTPUT_ROW
- .unreq INPUT_BUF
- .unreq NUM_ROWS
- .unreq OUTPUT_BUF0
- .unreq OUTPUT_BUF1
- .unreq OUTPUT_BUF2
- .unreq RGB
- .unreq Y
- .unreq U
- .unreq V
- .unreq N
-
-.purgem do_rgb_to_yuv
-.purgem do_rgb_to_yuv_stage1
-.purgem do_rgb_to_yuv_stage2
-.purgem do_rgb_to_yuv_stage2_store_load_stage1
-
-.endm
-
-/*--------------------------------- id ----- bpp R G B Fast LD3 */
-generate_jsimd_rgb_ycc_convert_neon extrgb, 24, 0, 1, 2, 1
-generate_jsimd_rgb_ycc_convert_neon extbgr, 24, 2, 1, 0, 1
-generate_jsimd_rgb_ycc_convert_neon extrgbx, 32, 0, 1, 2, 1
-generate_jsimd_rgb_ycc_convert_neon extbgrx, 32, 2, 1, 0, 1
-generate_jsimd_rgb_ycc_convert_neon extxbgr, 32, 3, 2, 1, 1
-generate_jsimd_rgb_ycc_convert_neon extxrgb, 32, 1, 2, 3, 1
-
-generate_jsimd_rgb_ycc_convert_neon extrgb, 24, 0, 1, 2, 0
-generate_jsimd_rgb_ycc_convert_neon extbgr, 24, 2, 1, 0, 0
-
-.purgem do_load
-.purgem do_store
-
-
-/*****************************************************************************/
-
-/*
- * jsimd_fdct_islow_neon
- *
- * This file contains a slower but more accurate integer implementation of the
- * forward DCT (Discrete Cosine Transform). The following code is based
- * directly on the IJG''s original jfdctint.c; see the jfdctint.c for
- * more details.
- *
- * TODO: can be combined with 'jsimd_convsamp_neon' to get
- * rid of a bunch of VLD1.16 instructions
- */
-
-#define CONST_BITS 13
-#define PASS1_BITS 2
-
-#define DESCALE_P1 (CONST_BITS - PASS1_BITS)
-#define DESCALE_P2 (CONST_BITS + PASS1_BITS)
-
-#define XFIX_P_0_298 v0.h[0]
-#define XFIX_N_0_390 v0.h[1]
-#define XFIX_P_0_541 v0.h[2]
-#define XFIX_P_0_765 v0.h[3]
-#define XFIX_N_0_899 v0.h[4]
-#define XFIX_P_1_175 v0.h[5]
-#define XFIX_P_1_501 v0.h[6]
-#define XFIX_N_1_847 v0.h[7]
-#define XFIX_N_1_961 v1.h[0]
-#define XFIX_P_2_053 v1.h[1]
-#define XFIX_N_2_562 v1.h[2]
-#define XFIX_P_3_072 v1.h[3]
-
-asm_function jsimd_fdct_islow_neon
-
- DATA .req x0
- TMP .req x9
-
- /* Load constants */
- get_symbol_loc TMP, Ljsimd_fdct_islow_neon_consts
- ld1 {v0.8h, v1.8h}, [TMP]
-
- /* Save Neon registers */
- sub sp, sp, #64
- mov x10, sp
- st1 {v8.8b, v9.8b, v10.8b, v11.8b}, [x10], 32
- st1 {v12.8b, v13.8b, v14.8b, v15.8b}, [x10], 32
-
- /* Load all DATA into Neon registers with the following allocation:
- * 0 1 2 3 | 4 5 6 7
- * ---------+--------
- * 0 | d16 | d17 | v16.8h
- * 1 | d18 | d19 | v17.8h
- * 2 | d20 | d21 | v18.8h
- * 3 | d22 | d23 | v19.8h
- * 4 | d24 | d25 | v20.8h
- * 5 | d26 | d27 | v21.8h
- * 6 | d28 | d29 | v22.8h
- * 7 | d30 | d31 | v23.8h
- */
-
- ld1 {v16.8h, v17.8h, v18.8h, v19.8h}, [DATA], 64
- ld1 {v20.8h, v21.8h, v22.8h, v23.8h}, [DATA]
- sub DATA, DATA, #64
-
- /* Transpose */
- transpose_8x8 v16, v17, v18, v19, v20, v21, v22, v23, v31, v2, v3, v4
- /* 1-D FDCT */
- add v24.8h, v16.8h, v23.8h /* tmp0 = dataptr[0] + dataptr[7]; */
- sub v31.8h, v16.8h, v23.8h /* tmp7 = dataptr[0] - dataptr[7]; */
- add v25.8h, v17.8h, v22.8h /* tmp1 = dataptr[1] + dataptr[6]; */
- sub v30.8h, v17.8h, v22.8h /* tmp6 = dataptr[1] - dataptr[6]; */
- add v26.8h, v18.8h, v21.8h /* tmp2 = dataptr[2] + dataptr[5]; */
- sub v29.8h, v18.8h, v21.8h /* tmp5 = dataptr[2] - dataptr[5]; */
- add v27.8h, v19.8h, v20.8h /* tmp3 = dataptr[3] + dataptr[4]; */
- sub v28.8h, v19.8h, v20.8h /* tmp4 = dataptr[3] - dataptr[4]; */
-
- /* even part */
-
- add v8.8h, v24.8h, v27.8h /* tmp10 = tmp0 + tmp3; */
- sub v9.8h, v24.8h, v27.8h /* tmp13 = tmp0 - tmp3; */
- add v10.8h, v25.8h, v26.8h /* tmp11 = tmp1 + tmp2; */
- sub v11.8h, v25.8h, v26.8h /* tmp12 = tmp1 - tmp2; */
-
- add v16.8h, v8.8h, v10.8h /* tmp10 + tmp11 */
- sub v20.8h, v8.8h, v10.8h /* tmp10 - tmp11 */
-
- add v18.8h, v11.8h, v9.8h /* tmp12 + tmp13 */
-
- shl v16.8h, v16.8h, #PASS1_BITS /* dataptr[0] = (DCTELEM)LEFT_SHIFT(tmp10 + tmp11, PASS1_BITS); */
- shl v20.8h, v20.8h, #PASS1_BITS /* dataptr[4] = (DCTELEM)LEFT_SHIFT(tmp10 - tmp11, PASS1_BITS); */
-
- smull2 v24.4s, v18.8h, XFIX_P_0_541 /* z1 hi = MULTIPLY(tmp12 + tmp13, XFIX_P_0_541); */
- smull v18.4s, v18.4h, XFIX_P_0_541 /* z1 lo = MULTIPLY(tmp12 + tmp13, XFIX_P_0_541); */
- mov v22.16b, v18.16b
- mov v25.16b, v24.16b
-
- smlal v18.4s, v9.4h, XFIX_P_0_765 /* lo z1 + MULTIPLY(tmp13, XFIX_P_0_765) */
- smlal2 v24.4s, v9.8h, XFIX_P_0_765 /* hi z1 + MULTIPLY(tmp13, XFIX_P_0_765) */
- smlal v22.4s, v11.4h, XFIX_N_1_847 /* lo z1 + MULTIPLY(tmp12, XFIX_N_1_847) */
- smlal2 v25.4s, v11.8h, XFIX_N_1_847 /* hi z1 + MULTIPLY(tmp12, XFIX_N_1_847) */
-
- rshrn v18.4h, v18.4s, #DESCALE_P1
- rshrn v22.4h, v22.4s, #DESCALE_P1
- rshrn2 v18.8h, v24.4s, #DESCALE_P1 /* dataptr[2] = (DCTELEM)DESCALE(z1 + MULTIPLY(tmp13, XFIX_P_0_765), CONST_BITS-PASS1_BITS); */
- rshrn2 v22.8h, v25.4s, #DESCALE_P1 /* dataptr[6] = (DCTELEM)DESCALE(z1 + MULTIPLY(tmp12, XFIX_N_1_847), CONST_BITS-PASS1_BITS); */
-
- /* Odd part */
-
- add v8.8h, v28.8h, v31.8h /* z1 = tmp4 + tmp7; */
- add v9.8h, v29.8h, v30.8h /* z2 = tmp5 + tmp6; */
- add v10.8h, v28.8h, v30.8h /* z3 = tmp4 + tmp6; */
- add v11.8h, v29.8h, v31.8h /* z4 = tmp5 + tmp7; */
- smull v4.4s, v10.4h, XFIX_P_1_175 /* z5 lo = z3 lo * XFIX_P_1_175 */
- smull2 v5.4s, v10.8h, XFIX_P_1_175
- smlal v4.4s, v11.4h, XFIX_P_1_175 /* z5 = MULTIPLY(z3 + z4, FIX_1_175875602); */
- smlal2 v5.4s, v11.8h, XFIX_P_1_175
-
- smull2 v24.4s, v28.8h, XFIX_P_0_298
- smull2 v25.4s, v29.8h, XFIX_P_2_053
- smull2 v26.4s, v30.8h, XFIX_P_3_072
- smull2 v27.4s, v31.8h, XFIX_P_1_501
- smull v28.4s, v28.4h, XFIX_P_0_298 /* tmp4 = MULTIPLY(tmp4, FIX_0_298631336); */
- smull v29.4s, v29.4h, XFIX_P_2_053 /* tmp5 = MULTIPLY(tmp5, FIX_2_053119869); */
- smull v30.4s, v30.4h, XFIX_P_3_072 /* tmp6 = MULTIPLY(tmp6, FIX_3_072711026); */
- smull v31.4s, v31.4h, XFIX_P_1_501 /* tmp7 = MULTIPLY(tmp7, FIX_1_501321110); */
-
- smull2 v12.4s, v8.8h, XFIX_N_0_899
- smull2 v13.4s, v9.8h, XFIX_N_2_562
- smull2 v14.4s, v10.8h, XFIX_N_1_961
- smull2 v15.4s, v11.8h, XFIX_N_0_390
- smull v8.4s, v8.4h, XFIX_N_0_899 /* z1 = MULTIPLY(z1, -FIX_0_899976223); */
- smull v9.4s, v9.4h, XFIX_N_2_562 /* z2 = MULTIPLY(z2, -FIX_2_562915447); */
- smull v10.4s, v10.4h, XFIX_N_1_961 /* z3 = MULTIPLY(z3, -FIX_1_961570560); */
- smull v11.4s, v11.4h, XFIX_N_0_390 /* z4 = MULTIPLY(z4, -FIX_0_390180644); */
-
- add v10.4s, v10.4s, v4.4s /* z3 += z5 */
- add v14.4s, v14.4s, v5.4s
- add v11.4s, v11.4s, v4.4s /* z4 += z5 */
- add v15.4s, v15.4s, v5.4s
-
- add v28.4s, v28.4s, v8.4s /* tmp4 += z1 */
- add v24.4s, v24.4s, v12.4s
- add v29.4s, v29.4s, v9.4s /* tmp5 += z2 */
- add v25.4s, v25.4s, v13.4s
- add v30.4s, v30.4s, v10.4s /* tmp6 += z3 */
- add v26.4s, v26.4s, v14.4s
- add v31.4s, v31.4s, v11.4s /* tmp7 += z4 */
- add v27.4s, v27.4s, v15.4s
-
- add v28.4s, v28.4s, v10.4s /* tmp4 += z3 */
- add v24.4s, v24.4s, v14.4s
- add v29.4s, v29.4s, v11.4s /* tmp5 += z4 */
- add v25.4s, v25.4s, v15.4s
- add v30.4s, v30.4s, v9.4s /* tmp6 += z2 */
- add v26.4s, v26.4s, v13.4s
- add v31.4s, v31.4s, v8.4s /* tmp7 += z1 */
- add v27.4s, v27.4s, v12.4s
-
- rshrn v23.4h, v28.4s, #DESCALE_P1
- rshrn v21.4h, v29.4s, #DESCALE_P1
- rshrn v19.4h, v30.4s, #DESCALE_P1
- rshrn v17.4h, v31.4s, #DESCALE_P1
- rshrn2 v23.8h, v24.4s, #DESCALE_P1 /* dataptr[7] = (DCTELEM)DESCALE(tmp4 + z1 + z3, CONST_BITS-PASS1_BITS); */
- rshrn2 v21.8h, v25.4s, #DESCALE_P1 /* dataptr[5] = (DCTELEM)DESCALE(tmp5 + z2 + z4, CONST_BITS-PASS1_BITS); */
- rshrn2 v19.8h, v26.4s, #DESCALE_P1 /* dataptr[3] = (DCTELEM)DESCALE(tmp6 + z2 + z3, CONST_BITS-PASS1_BITS); */
- rshrn2 v17.8h, v27.4s, #DESCALE_P1 /* dataptr[1] = (DCTELEM)DESCALE(tmp7 + z1 + z4, CONST_BITS-PASS1_BITS); */
-
- /* Transpose */
- transpose_8x8 v16, v17, v18, v19, v20, v21, v22, v23, v31, v2, v3, v4
-
- /* 1-D FDCT */
- add v24.8h, v16.8h, v23.8h /* tmp0 = dataptr[0] + dataptr[7]; */
- sub v31.8h, v16.8h, v23.8h /* tmp7 = dataptr[0] - dataptr[7]; */
- add v25.8h, v17.8h, v22.8h /* tmp1 = dataptr[1] + dataptr[6]; */
- sub v30.8h, v17.8h, v22.8h /* tmp6 = dataptr[1] - dataptr[6]; */
- add v26.8h, v18.8h, v21.8h /* tmp2 = dataptr[2] + dataptr[5]; */
- sub v29.8h, v18.8h, v21.8h /* tmp5 = dataptr[2] - dataptr[5]; */
- add v27.8h, v19.8h, v20.8h /* tmp3 = dataptr[3] + dataptr[4]; */
- sub v28.8h, v19.8h, v20.8h /* tmp4 = dataptr[3] - dataptr[4]; */
-
- /* even part */
- add v8.8h, v24.8h, v27.8h /* tmp10 = tmp0 + tmp3; */
- sub v9.8h, v24.8h, v27.8h /* tmp13 = tmp0 - tmp3; */
- add v10.8h, v25.8h, v26.8h /* tmp11 = tmp1 + tmp2; */
- sub v11.8h, v25.8h, v26.8h /* tmp12 = tmp1 - tmp2; */
-
- add v16.8h, v8.8h, v10.8h /* tmp10 + tmp11 */
- sub v20.8h, v8.8h, v10.8h /* tmp10 - tmp11 */
-
- add v18.8h, v11.8h, v9.8h /* tmp12 + tmp13 */
-
- srshr v16.8h, v16.8h, #PASS1_BITS /* dataptr[0] = (DCTELEM)DESCALE(tmp10 + tmp11, PASS1_BITS); */
- srshr v20.8h, v20.8h, #PASS1_BITS /* dataptr[4] = (DCTELEM)DESCALE(tmp10 - tmp11, PASS1_BITS); */
-
- smull2 v24.4s, v18.8h, XFIX_P_0_541 /* z1 hi = MULTIPLY(tmp12 + tmp13, XFIX_P_0_541); */
- smull v18.4s, v18.4h, XFIX_P_0_541 /* z1 lo = MULTIPLY(tmp12 + tmp13, XFIX_P_0_541); */
- mov v22.16b, v18.16b
- mov v25.16b, v24.16b
-
- smlal v18.4s, v9.4h, XFIX_P_0_765 /* lo z1 + MULTIPLY(tmp13, XFIX_P_0_765) */
- smlal2 v24.4s, v9.8h, XFIX_P_0_765 /* hi z1 + MULTIPLY(tmp13, XFIX_P_0_765) */
- smlal v22.4s, v11.4h, XFIX_N_1_847 /* lo z1 + MULTIPLY(tmp12, XFIX_N_1_847) */
- smlal2 v25.4s, v11.8h, XFIX_N_1_847 /* hi z1 + MULTIPLY(tmp12, XFIX_N_1_847) */
-
- rshrn v18.4h, v18.4s, #DESCALE_P2
- rshrn v22.4h, v22.4s, #DESCALE_P2
- rshrn2 v18.8h, v24.4s, #DESCALE_P2 /* dataptr[2] = (DCTELEM)DESCALE(z1 + MULTIPLY(tmp13, XFIX_P_0_765), CONST_BITS-PASS1_BITS); */
- rshrn2 v22.8h, v25.4s, #DESCALE_P2 /* dataptr[6] = (DCTELEM)DESCALE(z1 + MULTIPLY(tmp12, XFIX_N_1_847), CONST_BITS-PASS1_BITS); */
-
- /* Odd part */
- add v8.8h, v28.8h, v31.8h /* z1 = tmp4 + tmp7; */
- add v9.8h, v29.8h, v30.8h /* z2 = tmp5 + tmp6; */
- add v10.8h, v28.8h, v30.8h /* z3 = tmp4 + tmp6; */
- add v11.8h, v29.8h, v31.8h /* z4 = tmp5 + tmp7; */
-
- smull v4.4s, v10.4h, XFIX_P_1_175 /* z5 lo = z3 lo * XFIX_P_1_175 */
- smull2 v5.4s, v10.8h, XFIX_P_1_175
- smlal v4.4s, v11.4h, XFIX_P_1_175 /* z5 = MULTIPLY(z3 + z4, FIX_1_175875602); */
- smlal2 v5.4s, v11.8h, XFIX_P_1_175
-
- smull2 v24.4s, v28.8h, XFIX_P_0_298
- smull2 v25.4s, v29.8h, XFIX_P_2_053
- smull2 v26.4s, v30.8h, XFIX_P_3_072
- smull2 v27.4s, v31.8h, XFIX_P_1_501
- smull v28.4s, v28.4h, XFIX_P_0_298 /* tmp4 = MULTIPLY(tmp4, FIX_0_298631336); */
- smull v29.4s, v29.4h, XFIX_P_2_053 /* tmp5 = MULTIPLY(tmp5, FIX_2_053119869); */
- smull v30.4s, v30.4h, XFIX_P_3_072 /* tmp6 = MULTIPLY(tmp6, FIX_3_072711026); */
- smull v31.4s, v31.4h, XFIX_P_1_501 /* tmp7 = MULTIPLY(tmp7, FIX_1_501321110); */
-
- smull2 v12.4s, v8.8h, XFIX_N_0_899
- smull2 v13.4s, v9.8h, XFIX_N_2_562
- smull2 v14.4s, v10.8h, XFIX_N_1_961
- smull2 v15.4s, v11.8h, XFIX_N_0_390
- smull v8.4s, v8.4h, XFIX_N_0_899 /* z1 = MULTIPLY(z1, -FIX_0_899976223); */
- smull v9.4s, v9.4h, XFIX_N_2_562 /* z2 = MULTIPLY(z2, -FIX_2_562915447); */
- smull v10.4s, v10.4h, XFIX_N_1_961 /* z3 = MULTIPLY(z3, -FIX_1_961570560); */
- smull v11.4s, v11.4h, XFIX_N_0_390 /* z4 = MULTIPLY(z4, -FIX_0_390180644); */
-
- add v10.4s, v10.4s, v4.4s
- add v14.4s, v14.4s, v5.4s
- add v11.4s, v11.4s, v4.4s
- add v15.4s, v15.4s, v5.4s
-
- add v28.4s, v28.4s, v8.4s /* tmp4 += z1 */
- add v24.4s, v24.4s, v12.4s
- add v29.4s, v29.4s, v9.4s /* tmp5 += z2 */
- add v25.4s, v25.4s, v13.4s
- add v30.4s, v30.4s, v10.4s /* tmp6 += z3 */
- add v26.4s, v26.4s, v14.4s
- add v31.4s, v31.4s, v11.4s /* tmp7 += z4 */
- add v27.4s, v27.4s, v15.4s
-
- add v28.4s, v28.4s, v10.4s /* tmp4 += z3 */
- add v24.4s, v24.4s, v14.4s
- add v29.4s, v29.4s, v11.4s /* tmp5 += z4 */
- add v25.4s, v25.4s, v15.4s
- add v30.4s, v30.4s, v9.4s /* tmp6 += z2 */
- add v26.4s, v26.4s, v13.4s
- add v31.4s, v31.4s, v8.4s /* tmp7 += z1 */
- add v27.4s, v27.4s, v12.4s
-
- rshrn v23.4h, v28.4s, #DESCALE_P2
- rshrn v21.4h, v29.4s, #DESCALE_P2
- rshrn v19.4h, v30.4s, #DESCALE_P2
- rshrn v17.4h, v31.4s, #DESCALE_P2
- rshrn2 v23.8h, v24.4s, #DESCALE_P2 /* dataptr[7] = (DCTELEM)DESCALE(tmp4 + z1 + z3, CONST_BITS-PASS1_BITS); */
- rshrn2 v21.8h, v25.4s, #DESCALE_P2 /* dataptr[5] = (DCTELEM)DESCALE(tmp5 + z2 + z4, CONST_BITS-PASS1_BITS); */
- rshrn2 v19.8h, v26.4s, #DESCALE_P2 /* dataptr[3] = (DCTELEM)DESCALE(tmp6 + z2 + z3, CONST_BITS-PASS1_BITS); */
- rshrn2 v17.8h, v27.4s, #DESCALE_P2 /* dataptr[1] = (DCTELEM)DESCALE(tmp7 + z1 + z4, CONST_BITS-PASS1_BITS); */
-
- /* store results */
- st1 {v16.8h, v17.8h, v18.8h, v19.8h}, [DATA], 64
- st1 {v20.8h, v21.8h, v22.8h, v23.8h}, [DATA]
-
- /* Restore Neon registers */
- ld1 {v8.8b, v9.8b, v10.8b, v11.8b}, [sp], 32
- ld1 {v12.8b, v13.8b, v14.8b, v15.8b}, [sp], 32
-
- br x30
-
- .unreq DATA
- .unreq TMP
-
-#undef XFIX_P_0_298
-#undef XFIX_N_0_390
-#undef XFIX_P_0_541
-#undef XFIX_P_0_765
-#undef XFIX_N_0_899
-#undef XFIX_P_1_175
-#undef XFIX_P_1_501
-#undef XFIX_N_1_847
-#undef XFIX_N_1_961
-#undef XFIX_P_2_053
-#undef XFIX_N_2_562
-#undef XFIX_P_3_072
-
-
-/*****************************************************************************/
-
-/*
- * GLOBAL(JOCTET *)
- * jsimd_huff_encode_one_block(working_state *state, JOCTET *buffer,
- * JCOEFPTR block, int last_dc_val,
- * c_derived_tbl *dctbl, c_derived_tbl *actbl)
- *
- */
-
- BUFFER .req x1
- PUT_BUFFER .req x6
- PUT_BITS .req x7
- PUT_BITSw .req w7
-
-.macro emit_byte
- sub PUT_BITS, PUT_BITS, #0x8
- lsr x19, PUT_BUFFER, PUT_BITS
- uxtb w19, w19
- strb w19, [BUFFER, #1]!
- cmp w19, #0xff
- b.ne 14f
- strb wzr, [BUFFER, #1]!
-14:
-.endm
-.macro put_bits CODE, SIZE
- lsl PUT_BUFFER, PUT_BUFFER, \SIZE
- add PUT_BITS, PUT_BITS, \SIZE
- orr PUT_BUFFER, PUT_BUFFER, \CODE
-.endm
-.macro checkbuf31
- cmp PUT_BITS, #0x20
- b.lt 31f
- emit_byte
- emit_byte
- emit_byte
- emit_byte
-31:
-.endm
-.macro checkbuf47
- cmp PUT_BITS, #0x30
- b.lt 47f
- emit_byte
- emit_byte
- emit_byte
- emit_byte
- emit_byte
- emit_byte
-47:
-.endm
-
-.macro generate_jsimd_huff_encode_one_block fast_tbl
-
-.if \fast_tbl == 1
-asm_function jsimd_huff_encode_one_block_neon
-.else
-asm_function jsimd_huff_encode_one_block_neon_slowtbl
-.endif
- sub sp, sp, 272
- sub BUFFER, BUFFER, #0x1 /* BUFFER=buffer-- */
- /* Save Arm registers */
- stp x19, x20, [sp]
- get_symbol_loc x15, Ljsimd_huff_encode_one_block_neon_consts
- ldr PUT_BUFFER, [x0, #0x10]
- ldr PUT_BITSw, [x0, #0x18]
- ldrsh w12, [x2] /* load DC coeff in w12 */
- /* prepare data */
-.if \fast_tbl == 1
- ld1 {v23.16b}, [x15], #16
- ld1 {v0.16b, v1.16b, v2.16b, v3.16b}, [x15], #64
- ld1 {v4.16b, v5.16b, v6.16b, v7.16b}, [x15], #64
- ld1 {v16.16b, v17.16b, v18.16b, v19.16b}, [x15], #64
- ld1 {v24.16b, v25.16b, v26.16b, v27.16b}, [x2], #64
- ld1 {v28.16b, v29.16b, v30.16b, v31.16b}, [x2], #64
- sub w12, w12, w3 /* last_dc_val, not used afterwards */
- /* ZigZag 8x8 */
- tbl v0.16b, {v24.16b, v25.16b, v26.16b, v27.16b}, v0.16b
- tbl v1.16b, {v24.16b, v25.16b, v26.16b, v27.16b}, v1.16b
- tbl v2.16b, {v25.16b, v26.16b, v27.16b, v28.16b}, v2.16b
- tbl v3.16b, {v24.16b, v25.16b, v26.16b, v27.16b}, v3.16b
- tbl v4.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v4.16b
- tbl v5.16b, {v25.16b, v26.16b, v27.16b, v28.16b}, v5.16b
- tbl v6.16b, {v27.16b, v28.16b, v29.16b, v30.16b}, v6.16b
- tbl v7.16b, {v29.16b, v30.16b, v31.16b}, v7.16b
- ins v0.h[0], w12
- tbx v1.16b, {v28.16b}, v16.16b
- tbx v2.16b, {v29.16b, v30.16b}, v17.16b
- tbx v5.16b, {v29.16b, v30.16b}, v18.16b
- tbx v6.16b, {v31.16b}, v19.16b
-.else
- add x13, x2, #0x22
- sub w12, w12, w3 /* last_dc_val, not used afterwards */
- ld1 {v23.16b}, [x15]
- add x14, x2, #0x18
- add x3, x2, #0x36
- ins v0.h[0], w12
- add x9, x2, #0x2
- ld1 {v1.h}[0], [x13]
- add x15, x2, #0x30
- ld1 {v2.h}[0], [x14]
- add x19, x2, #0x26
- ld1 {v3.h}[0], [x3]
- add x20, x2, #0x28
- ld1 {v0.h}[1], [x9]
- add x12, x2, #0x10
- ld1 {v1.h}[1], [x15]
- add x13, x2, #0x40
- ld1 {v2.h}[1], [x19]
- add x14, x2, #0x34
- ld1 {v3.h}[1], [x20]
- add x3, x2, #0x1a
- ld1 {v0.h}[2], [x12]
- add x9, x2, #0x20
- ld1 {v1.h}[2], [x13]
- add x15, x2, #0x32
- ld1 {v2.h}[2], [x14]
- add x19, x2, #0x42
- ld1 {v3.h}[2], [x3]
- add x20, x2, #0xc
- ld1 {v0.h}[3], [x9]
- add x12, x2, #0x12
- ld1 {v1.h}[3], [x15]
- add x13, x2, #0x24
- ld1 {v2.h}[3], [x19]
- add x14, x2, #0x50
- ld1 {v3.h}[3], [x20]
- add x3, x2, #0xe
- ld1 {v0.h}[4], [x12]
- add x9, x2, #0x4
- ld1 {v1.h}[4], [x13]
- add x15, x2, #0x16
- ld1 {v2.h}[4], [x14]
- add x19, x2, #0x60
- ld1 {v3.h}[4], [x3]
- add x20, x2, #0x1c
- ld1 {v0.h}[5], [x9]
- add x12, x2, #0x6
- ld1 {v1.h}[5], [x15]
- add x13, x2, #0x8
- ld1 {v2.h}[5], [x19]
- add x14, x2, #0x52
- ld1 {v3.h}[5], [x20]
- add x3, x2, #0x2a
- ld1 {v0.h}[6], [x12]
- add x9, x2, #0x14
- ld1 {v1.h}[6], [x13]
- add x15, x2, #0xa
- ld1 {v2.h}[6], [x14]
- add x19, x2, #0x44
- ld1 {v3.h}[6], [x3]
- add x20, x2, #0x38
- ld1 {v0.h}[7], [x9]
- add x12, x2, #0x46
- ld1 {v1.h}[7], [x15]
- add x13, x2, #0x3a
- ld1 {v2.h}[7], [x19]
- add x14, x2, #0x74
- ld1 {v3.h}[7], [x20]
- add x3, x2, #0x6a
- ld1 {v4.h}[0], [x12]
- add x9, x2, #0x54
- ld1 {v5.h}[0], [x13]
- add x15, x2, #0x2c
- ld1 {v6.h}[0], [x14]
- add x19, x2, #0x76
- ld1 {v7.h}[0], [x3]
- add x20, x2, #0x78
- ld1 {v4.h}[1], [x9]
- add x12, x2, #0x62
- ld1 {v5.h}[1], [x15]
- add x13, x2, #0x1e
- ld1 {v6.h}[1], [x19]
- add x14, x2, #0x68
- ld1 {v7.h}[1], [x20]
- add x3, x2, #0x7a
- ld1 {v4.h}[2], [x12]
- add x9, x2, #0x70
- ld1 {v5.h}[2], [x13]
- add x15, x2, #0x2e
- ld1 {v6.h}[2], [x14]
- add x19, x2, #0x5a
- ld1 {v7.h}[2], [x3]
- add x20, x2, #0x6c
- ld1 {v4.h}[3], [x9]
- add x12, x2, #0x72
- ld1 {v5.h}[3], [x15]
- add x13, x2, #0x3c
- ld1 {v6.h}[3], [x19]
- add x14, x2, #0x4c
- ld1 {v7.h}[3], [x20]
- add x3, x2, #0x5e
- ld1 {v4.h}[4], [x12]
- add x9, x2, #0x64
- ld1 {v5.h}[4], [x13]
- add x15, x2, #0x4a
- ld1 {v6.h}[4], [x14]
- add x19, x2, #0x3e
- ld1 {v7.h}[4], [x3]
- add x20, x2, #0x6e
- ld1 {v4.h}[5], [x9]
- add x12, x2, #0x56
- ld1 {v5.h}[5], [x15]
- add x13, x2, #0x58
- ld1 {v6.h}[5], [x19]
- add x14, x2, #0x4e
- ld1 {v7.h}[5], [x20]
- add x3, x2, #0x7c
- ld1 {v4.h}[6], [x12]
- add x9, x2, #0x48
- ld1 {v5.h}[6], [x13]
- add x15, x2, #0x66
- ld1 {v6.h}[6], [x14]
- add x19, x2, #0x5c
- ld1 {v7.h}[6], [x3]
- add x20, x2, #0x7e
- ld1 {v4.h}[7], [x9]
- ld1 {v5.h}[7], [x15]
- ld1 {v6.h}[7], [x19]
- ld1 {v7.h}[7], [x20]
-.endif
- cmlt v24.8h, v0.8h, #0
- cmlt v25.8h, v1.8h, #0
- cmlt v26.8h, v2.8h, #0
- cmlt v27.8h, v3.8h, #0
- cmlt v28.8h, v4.8h, #0
- cmlt v29.8h, v5.8h, #0
- cmlt v30.8h, v6.8h, #0
- cmlt v31.8h, v7.8h, #0
- abs v0.8h, v0.8h
- abs v1.8h, v1.8h
- abs v2.8h, v2.8h
- abs v3.8h, v3.8h
- abs v4.8h, v4.8h
- abs v5.8h, v5.8h
- abs v6.8h, v6.8h
- abs v7.8h, v7.8h
- eor v24.16b, v24.16b, v0.16b
- eor v25.16b, v25.16b, v1.16b
- eor v26.16b, v26.16b, v2.16b
- eor v27.16b, v27.16b, v3.16b
- eor v28.16b, v28.16b, v4.16b
- eor v29.16b, v29.16b, v5.16b
- eor v30.16b, v30.16b, v6.16b
- eor v31.16b, v31.16b, v7.16b
- cmeq v16.8h, v0.8h, #0
- cmeq v17.8h, v1.8h, #0
- cmeq v18.8h, v2.8h, #0
- cmeq v19.8h, v3.8h, #0
- cmeq v20.8h, v4.8h, #0
- cmeq v21.8h, v5.8h, #0
- cmeq v22.8h, v6.8h, #0
- xtn v16.8b, v16.8h
- xtn v18.8b, v18.8h
- xtn v20.8b, v20.8h
- xtn v22.8b, v22.8h
- umov w14, v0.h[0]
- xtn2 v16.16b, v17.8h
- umov w13, v24.h[0]
- xtn2 v18.16b, v19.8h
- clz w14, w14
- xtn2 v20.16b, v21.8h
- lsl w13, w13, w14
- cmeq v17.8h, v7.8h, #0
- sub w12, w14, #32
- xtn2 v22.16b, v17.8h
- lsr w13, w13, w14
- and v16.16b, v16.16b, v23.16b
- neg w12, w12
- and v18.16b, v18.16b, v23.16b
- add x3, x4, #0x400 /* r1 = dctbl->ehufsi */
- and v20.16b, v20.16b, v23.16b
- add x15, sp, #0x90 /* x15 = t2 */
- and v22.16b, v22.16b, v23.16b
- ldr w10, [x4, x12, lsl #2]
- addp v16.16b, v16.16b, v18.16b
- ldrb w11, [x3, x12]
- addp v20.16b, v20.16b, v22.16b
- checkbuf47
- addp v16.16b, v16.16b, v20.16b
- put_bits x10, x11
- addp v16.16b, v16.16b, v18.16b
- checkbuf47
- umov x9, v16.D[0]
- put_bits x13, x12
- cnt v17.8b, v16.8b
- mvn x9, x9
- addv B18, v17.8b
- add x4, x5, #0x400 /* x4 = actbl->ehufsi */
- umov w12, v18.b[0]
- lsr x9, x9, #0x1 /* clear AC coeff */
- ldr w13, [x5, #0x3c0] /* x13 = actbl->ehufco[0xf0] */
- rbit x9, x9 /* x9 = index0 */
- ldrb w14, [x4, #0xf0] /* x14 = actbl->ehufsi[0xf0] */
- cmp w12, #(64-8)
- add x11, sp, #16
- b.lt 4f
- cbz x9, 6f
- st1 {v0.8h, v1.8h, v2.8h, v3.8h}, [x11], #64
- st1 {v4.8h, v5.8h, v6.8h, v7.8h}, [x11], #64
- st1 {v24.8h, v25.8h, v26.8h, v27.8h}, [x11], #64
- st1 {v28.8h, v29.8h, v30.8h, v31.8h}, [x11], #64
-1:
- clz x2, x9
- add x15, x15, x2, lsl #1
- lsl x9, x9, x2
- ldrh w20, [x15, #-126]
-2:
- cmp x2, #0x10
- b.lt 3f
- sub x2, x2, #0x10
- checkbuf47
- put_bits x13, x14
- b 2b
-3:
- clz w20, w20
- ldrh w3, [x15, #2]!
- sub w11, w20, #32
- lsl w3, w3, w20
- neg w11, w11
- lsr w3, w3, w20
- add x2, x11, x2, lsl #4
- lsl x9, x9, #0x1
- ldr w12, [x5, x2, lsl #2]
- ldrb w10, [x4, x2]
- checkbuf31
- put_bits x12, x10
- put_bits x3, x11
- cbnz x9, 1b
- b 6f
-4:
- movi v21.8h, #0x0010
- clz v0.8h, v0.8h
- clz v1.8h, v1.8h
- clz v2.8h, v2.8h
- clz v3.8h, v3.8h
- clz v4.8h, v4.8h
- clz v5.8h, v5.8h
- clz v6.8h, v6.8h
- clz v7.8h, v7.8h
- ushl v24.8h, v24.8h, v0.8h
- ushl v25.8h, v25.8h, v1.8h
- ushl v26.8h, v26.8h, v2.8h
- ushl v27.8h, v27.8h, v3.8h
- ushl v28.8h, v28.8h, v4.8h
- ushl v29.8h, v29.8h, v5.8h
- ushl v30.8h, v30.8h, v6.8h
- ushl v31.8h, v31.8h, v7.8h
- neg v0.8h, v0.8h
- neg v1.8h, v1.8h
- neg v2.8h, v2.8h
- neg v3.8h, v3.8h
- neg v4.8h, v4.8h
- neg v5.8h, v5.8h
- neg v6.8h, v6.8h
- neg v7.8h, v7.8h
- ushl v24.8h, v24.8h, v0.8h
- ushl v25.8h, v25.8h, v1.8h
- ushl v26.8h, v26.8h, v2.8h
- ushl v27.8h, v27.8h, v3.8h
- ushl v28.8h, v28.8h, v4.8h
- ushl v29.8h, v29.8h, v5.8h
- ushl v30.8h, v30.8h, v6.8h
- ushl v31.8h, v31.8h, v7.8h
- add v0.8h, v21.8h, v0.8h
- add v1.8h, v21.8h, v1.8h
- add v2.8h, v21.8h, v2.8h
- add v3.8h, v21.8h, v3.8h
- add v4.8h, v21.8h, v4.8h
- add v5.8h, v21.8h, v5.8h
- add v6.8h, v21.8h, v6.8h
- add v7.8h, v21.8h, v7.8h
- st1 {v0.8h, v1.8h, v2.8h, v3.8h}, [x11], #64
- st1 {v4.8h, v5.8h, v6.8h, v7.8h}, [x11], #64
- st1 {v24.8h, v25.8h, v26.8h, v27.8h}, [x11], #64
- st1 {v28.8h, v29.8h, v30.8h, v31.8h}, [x11], #64
-1:
- clz x2, x9
- add x15, x15, x2, lsl #1
- lsl x9, x9, x2
- ldrh w11, [x15, #-126]
-2:
- cmp x2, #0x10
- b.lt 3f
- sub x2, x2, #0x10
- checkbuf47
- put_bits x13, x14
- b 2b
-3:
- ldrh w3, [x15, #2]!
- add x2, x11, x2, lsl #4
- lsl x9, x9, #0x1
- ldr w12, [x5, x2, lsl #2]
- ldrb w10, [x4, x2]
- checkbuf31
- put_bits x12, x10
- put_bits x3, x11
- cbnz x9, 1b
-6:
- add x13, sp, #0x10e
- cmp x15, x13
- b.hs 1f
- ldr w12, [x5]
- ldrb w14, [x4]
- checkbuf47
- put_bits x12, x14
-1:
- str PUT_BUFFER, [x0, #0x10]
- str PUT_BITSw, [x0, #0x18]
- ldp x19, x20, [sp], 16
- add x0, BUFFER, #0x1
- add sp, sp, 256
- br x30
-
-.endm
-
-generate_jsimd_huff_encode_one_block 1
-generate_jsimd_huff_encode_one_block 0
-
- .unreq BUFFER
- .unreq PUT_BUFFER
- .unreq PUT_BITS
- .unreq PUT_BITSw
-
-.purgem emit_byte
-.purgem put_bits
-.purgem checkbuf31
-.purgem checkbuf47
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/align.h b/contrib/libs/libjpeg-turbo/simd/arm/align.h
deleted file mode 100644
index cff4241e84..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/arm/align.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2020, Arm Limited. All Rights Reserved.
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- * claim that you wrote the original software. If you use this software
- * in a product, an acknowledgment in the product documentation would be
- * appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must not be
- * misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source distribution.
- */
-
-/* How to obtain memory alignment for structures and variables */
-#if defined(_MSC_VER)
-#define ALIGN(alignment) __declspec(align(alignment))
-#elif defined(__clang__) || defined(__GNUC__)
-#define ALIGN(alignment) __attribute__((aligned(alignment)))
-#else
-#error "Unknown compiler"
-#endif
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/jccolor-neon.c b/contrib/libs/libjpeg-turbo/simd/arm/jccolor-neon.c
deleted file mode 100644
index 9fcc62dd25..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/arm/jccolor-neon.c
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * jccolor-neon.c - colorspace conversion (Arm Neon)
- *
- * Copyright (C) 2020, Arm Limited. All Rights Reserved.
- * Copyright (C) 2020, D. R. Commander. All Rights Reserved.
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- * claim that you wrote the original software. If you use this software
- * in a product, an acknowledgment in the product documentation would be
- * appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must not be
- * misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source distribution.
- */
-
-#define JPEG_INTERNALS
-#include "../../jinclude.h"
-#include "../../jpeglib.h"
-#include "../../jsimd.h"
-#include "../../jdct.h"
-#include "../../jsimddct.h"
-#include "../jsimd.h"
-#include "align.h"
-#include "neon-compat.h"
-
-#include <arm_neon.h>
-
-
-/* RGB -> YCbCr conversion constants */
-
-#define F_0_298 19595
-#define F_0_587 38470
-#define F_0_113 7471
-#define F_0_168 11059
-#define F_0_331 21709
-#define F_0_500 32768
-#define F_0_418 27439
-#define F_0_081 5329
-
-ALIGN(16) static const uint16_t jsimd_rgb_ycc_neon_consts[] = {
- F_0_298, F_0_587, F_0_113, F_0_168,
- F_0_331, F_0_500, F_0_418, F_0_081
-};
-
-
-/* Include inline routines for colorspace extensions. */
-
-#if defined(__aarch64__) || defined(_M_ARM64)
-#include "aarch64/jccolext-neon.c"
-#else
-#include "aarch32/jccolext-neon.c"
-#endif
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_PIXELSIZE
-
-#define RGB_RED EXT_RGB_RED
-#define RGB_GREEN EXT_RGB_GREEN
-#define RGB_BLUE EXT_RGB_BLUE
-#define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
-#define jsimd_rgb_ycc_convert_neon jsimd_extrgb_ycc_convert_neon
-#if defined(__aarch64__) || defined(_M_ARM64)
-#include "aarch64/jccolext-neon.c"
-#else
-#include "aarch32/jccolext-neon.c"
-#endif
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_PIXELSIZE
-#undef jsimd_rgb_ycc_convert_neon
-
-#define RGB_RED EXT_RGBX_RED
-#define RGB_GREEN EXT_RGBX_GREEN
-#define RGB_BLUE EXT_RGBX_BLUE
-#define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
-#define jsimd_rgb_ycc_convert_neon jsimd_extrgbx_ycc_convert_neon
-#if defined(__aarch64__) || defined(_M_ARM64)
-#include "aarch64/jccolext-neon.c"
-#else
-#include "aarch32/jccolext-neon.c"
-#endif
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_PIXELSIZE
-#undef jsimd_rgb_ycc_convert_neon
-
-#define RGB_RED EXT_BGR_RED
-#define RGB_GREEN EXT_BGR_GREEN
-#define RGB_BLUE EXT_BGR_BLUE
-#define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
-#define jsimd_rgb_ycc_convert_neon jsimd_extbgr_ycc_convert_neon
-#if defined(__aarch64__) || defined(_M_ARM64)
-#include "aarch64/jccolext-neon.c"
-#else
-#include "aarch32/jccolext-neon.c"
-#endif
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_PIXELSIZE
-#undef jsimd_rgb_ycc_convert_neon
-
-#define RGB_RED EXT_BGRX_RED
-#define RGB_GREEN EXT_BGRX_GREEN
-#define RGB_BLUE EXT_BGRX_BLUE
-#define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
-#define jsimd_rgb_ycc_convert_neon jsimd_extbgrx_ycc_convert_neon
-#if defined(__aarch64__) || defined(_M_ARM64)
-#include "aarch64/jccolext-neon.c"
-#else
-#include "aarch32/jccolext-neon.c"
-#endif
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_PIXELSIZE
-#undef jsimd_rgb_ycc_convert_neon
-
-#define RGB_RED EXT_XBGR_RED
-#define RGB_GREEN EXT_XBGR_GREEN
-#define RGB_BLUE EXT_XBGR_BLUE
-#define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
-#define jsimd_rgb_ycc_convert_neon jsimd_extxbgr_ycc_convert_neon
-#if defined(__aarch64__) || defined(_M_ARM64)
-#include "aarch64/jccolext-neon.c"
-#else
-#include "aarch32/jccolext-neon.c"
-#endif
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_PIXELSIZE
-#undef jsimd_rgb_ycc_convert_neon
-
-#define RGB_RED EXT_XRGB_RED
-#define RGB_GREEN EXT_XRGB_GREEN
-#define RGB_BLUE EXT_XRGB_BLUE
-#define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
-#define jsimd_rgb_ycc_convert_neon jsimd_extxrgb_ycc_convert_neon
-#if defined(__aarch64__) || defined(_M_ARM64)
-#include "aarch64/jccolext-neon.c"
-#else
-#include "aarch32/jccolext-neon.c"
-#endif
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_PIXELSIZE
-#undef jsimd_rgb_ycc_convert_neon
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/jcgray-neon.c b/contrib/libs/libjpeg-turbo/simd/arm/jcgray-neon.c
deleted file mode 100644
index 71c7b2de21..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/arm/jcgray-neon.c
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * jcgray-neon.c - grayscale colorspace conversion (Arm Neon)
- *
- * Copyright (C) 2020, Arm Limited. All Rights Reserved.
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- * claim that you wrote the original software. If you use this software
- * in a product, an acknowledgment in the product documentation would be
- * appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must not be
- * misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source distribution.
- */
-
-#define JPEG_INTERNALS
-#include "../../jinclude.h"
-#include "../../jpeglib.h"
-#include "../../jsimd.h"
-#include "../../jdct.h"
-#include "../../jsimddct.h"
-#include "../jsimd.h"
-#include "align.h"
-
-#include <arm_neon.h>
-
-
-/* RGB -> Grayscale conversion constants */
-
-#define F_0_298 19595
-#define F_0_587 38470
-#define F_0_113 7471
-
-
-/* Include inline routines for colorspace extensions. */
-
-#include "jcgryext-neon.c"
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_PIXELSIZE
-
-#define RGB_RED EXT_RGB_RED
-#define RGB_GREEN EXT_RGB_GREEN
-#define RGB_BLUE EXT_RGB_BLUE
-#define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
-#define jsimd_rgb_gray_convert_neon jsimd_extrgb_gray_convert_neon
-#include "jcgryext-neon.c"
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_PIXELSIZE
-#undef jsimd_rgb_gray_convert_neon
-
-#define RGB_RED EXT_RGBX_RED
-#define RGB_GREEN EXT_RGBX_GREEN
-#define RGB_BLUE EXT_RGBX_BLUE
-#define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
-#define jsimd_rgb_gray_convert_neon jsimd_extrgbx_gray_convert_neon
-#include "jcgryext-neon.c"
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_PIXELSIZE
-#undef jsimd_rgb_gray_convert_neon
-
-#define RGB_RED EXT_BGR_RED
-#define RGB_GREEN EXT_BGR_GREEN
-#define RGB_BLUE EXT_BGR_BLUE
-#define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
-#define jsimd_rgb_gray_convert_neon jsimd_extbgr_gray_convert_neon
-#include "jcgryext-neon.c"
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_PIXELSIZE
-#undef jsimd_rgb_gray_convert_neon
-
-#define RGB_RED EXT_BGRX_RED
-#define RGB_GREEN EXT_BGRX_GREEN
-#define RGB_BLUE EXT_BGRX_BLUE
-#define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
-#define jsimd_rgb_gray_convert_neon jsimd_extbgrx_gray_convert_neon
-#include "jcgryext-neon.c"
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_PIXELSIZE
-#undef jsimd_rgb_gray_convert_neon
-
-#define RGB_RED EXT_XBGR_RED
-#define RGB_GREEN EXT_XBGR_GREEN
-#define RGB_BLUE EXT_XBGR_BLUE
-#define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
-#define jsimd_rgb_gray_convert_neon jsimd_extxbgr_gray_convert_neon
-#include "jcgryext-neon.c"
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_PIXELSIZE
-#undef jsimd_rgb_gray_convert_neon
-
-#define RGB_RED EXT_XRGB_RED
-#define RGB_GREEN EXT_XRGB_GREEN
-#define RGB_BLUE EXT_XRGB_BLUE
-#define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
-#define jsimd_rgb_gray_convert_neon jsimd_extxrgb_gray_convert_neon
-#include "jcgryext-neon.c"
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_PIXELSIZE
-#undef jsimd_rgb_gray_convert_neon
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/jcgryext-neon.c b/contrib/libs/libjpeg-turbo/simd/arm/jcgryext-neon.c
deleted file mode 100644
index 416a7385df..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/arm/jcgryext-neon.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * jcgryext-neon.c - grayscale colorspace conversion (Arm Neon)
- *
- * Copyright (C) 2020, Arm Limited. All Rights Reserved.
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- * claim that you wrote the original software. If you use this software
- * in a product, an acknowledgment in the product documentation would be
- * appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must not be
- * misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source distribution.
- */
-
-/* This file is included by jcgray-neon.c */
-
-
-/* RGB -> Grayscale conversion is defined by the following equation:
- * Y = 0.29900 * R + 0.58700 * G + 0.11400 * B
- *
- * Avoid floating point arithmetic by using shifted integer constants:
- * 0.29899597 = 19595 * 2^-16
- * 0.58700561 = 38470 * 2^-16
- * 0.11399841 = 7471 * 2^-16
- * These constants are defined in jcgray-neon.c
- *
- * This is the same computation as the RGB -> Y portion of RGB -> YCbCr.
- */
-
-void jsimd_rgb_gray_convert_neon(JDIMENSION image_width, JSAMPARRAY input_buf,
- JSAMPIMAGE output_buf, JDIMENSION output_row,
- int num_rows)
-{
- JSAMPROW inptr;
- JSAMPROW outptr;
- /* Allocate temporary buffer for final (image_width % 16) pixels in row. */
- ALIGN(16) uint8_t tmp_buf[16 * RGB_PIXELSIZE];
-
- while (--num_rows >= 0) {
- inptr = *input_buf++;
- outptr = output_buf[0][output_row];
- output_row++;
-
- int cols_remaining = image_width;
- for (; cols_remaining > 0; cols_remaining -= 16) {
-
- /* To prevent buffer overread by the vector load instructions, the last
- * (image_width % 16) columns of data are first memcopied to a temporary
- * buffer large enough to accommodate the vector load.
- */
- if (cols_remaining < 16) {
- memcpy(tmp_buf, inptr, cols_remaining * RGB_PIXELSIZE);
- inptr = tmp_buf;
- }
-
-#if RGB_PIXELSIZE == 4
- uint8x16x4_t input_pixels = vld4q_u8(inptr);
-#else
- uint8x16x3_t input_pixels = vld3q_u8(inptr);
-#endif
- uint16x8_t r_l = vmovl_u8(vget_low_u8(input_pixels.val[RGB_RED]));
- uint16x8_t r_h = vmovl_u8(vget_high_u8(input_pixels.val[RGB_RED]));
- uint16x8_t g_l = vmovl_u8(vget_low_u8(input_pixels.val[RGB_GREEN]));
- uint16x8_t g_h = vmovl_u8(vget_high_u8(input_pixels.val[RGB_GREEN]));
- uint16x8_t b_l = vmovl_u8(vget_low_u8(input_pixels.val[RGB_BLUE]));
- uint16x8_t b_h = vmovl_u8(vget_high_u8(input_pixels.val[RGB_BLUE]));
-
- /* Compute Y = 0.29900 * R + 0.58700 * G + 0.11400 * B */
- uint32x4_t y_ll = vmull_n_u16(vget_low_u16(r_l), F_0_298);
- uint32x4_t y_lh = vmull_n_u16(vget_high_u16(r_l), F_0_298);
- uint32x4_t y_hl = vmull_n_u16(vget_low_u16(r_h), F_0_298);
- uint32x4_t y_hh = vmull_n_u16(vget_high_u16(r_h), F_0_298);
- y_ll = vmlal_n_u16(y_ll, vget_low_u16(g_l), F_0_587);
- y_lh = vmlal_n_u16(y_lh, vget_high_u16(g_l), F_0_587);
- y_hl = vmlal_n_u16(y_hl, vget_low_u16(g_h), F_0_587);
- y_hh = vmlal_n_u16(y_hh, vget_high_u16(g_h), F_0_587);
- y_ll = vmlal_n_u16(y_ll, vget_low_u16(b_l), F_0_113);
- y_lh = vmlal_n_u16(y_lh, vget_high_u16(b_l), F_0_113);
- y_hl = vmlal_n_u16(y_hl, vget_low_u16(b_h), F_0_113);
- y_hh = vmlal_n_u16(y_hh, vget_high_u16(b_h), F_0_113);
-
- /* Descale Y values (rounding right shift) and narrow to 16-bit. */
- uint16x8_t y_l = vcombine_u16(vrshrn_n_u32(y_ll, 16),
- vrshrn_n_u32(y_lh, 16));
- uint16x8_t y_h = vcombine_u16(vrshrn_n_u32(y_hl, 16),
- vrshrn_n_u32(y_hh, 16));
-
- /* Narrow Y values to 8-bit and store to memory. Buffer overwrite is
- * permitted up to the next multiple of ALIGN_SIZE bytes.
- */
- vst1q_u8(outptr, vcombine_u8(vmovn_u16(y_l), vmovn_u16(y_h)));
-
- /* Increment pointers. */
- inptr += (16 * RGB_PIXELSIZE);
- outptr += 16;
- }
- }
-}
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/jchuff.h b/contrib/libs/libjpeg-turbo/simd/arm/jchuff.h
deleted file mode 100644
index 2fbd252b9b..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/arm/jchuff.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * jchuff.h
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2009, 2018, 2021, D. R. Commander.
- * Copyright (C) 2018, Matthias Räncker.
- * Copyright (C) 2020-2021, Arm Limited.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- */
-
-/* Expanded entropy encoder object for Huffman encoding.
- *
- * The savable_state subrecord contains fields that change within an MCU,
- * but must not be updated permanently until we complete the MCU.
- */
-
-#if defined(__aarch64__) || defined(_M_ARM64)
-#define BIT_BUF_SIZE 64
-#else
-#define BIT_BUF_SIZE 32
-#endif
-
-typedef struct {
- size_t put_buffer; /* current bit accumulation buffer */
- int free_bits; /* # of bits available in it */
- int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */
-} savable_state;
-
-typedef struct {
- JOCTET *next_output_byte; /* => next byte to write in buffer */
- size_t free_in_buffer; /* # of byte spaces remaining in buffer */
- savable_state cur; /* Current bit buffer & DC state */
- j_compress_ptr cinfo; /* dump_buffer needs access to this */
- int simd;
-} working_state;
-
-/* Outputting bits to the file */
-
-/* Output byte b and, speculatively, an additional 0 byte. 0xFF must be encoded
- * as 0xFF 0x00, so the output buffer pointer is advanced by 2 if the byte is
- * 0xFF. Otherwise, the output buffer pointer is advanced by 1, and the
- * speculative 0 byte will be overwritten by the next byte.
- */
-#define EMIT_BYTE(b) { \
- buffer[0] = (JOCTET)(b); \
- buffer[1] = 0; \
- buffer -= -2 + ((JOCTET)(b) < 0xFF); \
-}
-
-/* Output the entire bit buffer. If there are no 0xFF bytes in it, then write
- * directly to the output buffer. Otherwise, use the EMIT_BYTE() macro to
- * encode 0xFF as 0xFF 0x00.
- */
-#if defined(__aarch64__) || defined(_M_ARM64)
-
-#define FLUSH() { \
- if (put_buffer & 0x8080808080808080 & ~(put_buffer + 0x0101010101010101)) { \
- EMIT_BYTE(put_buffer >> 56) \
- EMIT_BYTE(put_buffer >> 48) \
- EMIT_BYTE(put_buffer >> 40) \
- EMIT_BYTE(put_buffer >> 32) \
- EMIT_BYTE(put_buffer >> 24) \
- EMIT_BYTE(put_buffer >> 16) \
- EMIT_BYTE(put_buffer >> 8) \
- EMIT_BYTE(put_buffer ) \
- } else { \
- *((uint64_t *)buffer) = BUILTIN_BSWAP64(put_buffer); \
- buffer += 8; \
- } \
-}
-
-#else
-
-#if defined(_MSC_VER) && !defined(__clang__)
-#define SPLAT() { \
- buffer[0] = (JOCTET)(put_buffer >> 24); \
- buffer[1] = (JOCTET)(put_buffer >> 16); \
- buffer[2] = (JOCTET)(put_buffer >> 8); \
- buffer[3] = (JOCTET)(put_buffer ); \
- buffer += 4; \
-}
-#else
-#define SPLAT() { \
- put_buffer = __builtin_bswap32(put_buffer); \
- __asm__("str %1, [%0], #4" : "+r" (buffer) : "r" (put_buffer)); \
-}
-#endif
-
-#define FLUSH() { \
- if (put_buffer & 0x80808080 & ~(put_buffer + 0x01010101)) { \
- EMIT_BYTE(put_buffer >> 24) \
- EMIT_BYTE(put_buffer >> 16) \
- EMIT_BYTE(put_buffer >> 8) \
- EMIT_BYTE(put_buffer ) \
- } else { \
- SPLAT(); \
- } \
-}
-
-#endif
-
-/* Fill the bit buffer to capacity with the leading bits from code, then output
- * the bit buffer and put the remaining bits from code into the bit buffer.
- */
-#define PUT_AND_FLUSH(code, size) { \
- put_buffer = (put_buffer << (size + free_bits)) | (code >> -free_bits); \
- FLUSH() \
- free_bits += BIT_BUF_SIZE; \
- put_buffer = code; \
-}
-
-/* Insert code into the bit buffer and output the bit buffer if needed.
- * NOTE: We can't flush with free_bits == 0, since the left shift in
- * PUT_AND_FLUSH() would have undefined behavior.
- */
-#define PUT_BITS(code, size) { \
- free_bits -= size; \
- if (free_bits < 0) \
- PUT_AND_FLUSH(code, size) \
- else \
- put_buffer = (put_buffer << size) | code; \
-}
-
-#define PUT_CODE(code, size, diff) { \
- diff |= code << nbits; \
- nbits += size; \
- PUT_BITS(diff, nbits) \
-}
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/jcphuff-neon.c b/contrib/libs/libjpeg-turbo/simd/arm/jcphuff-neon.c
deleted file mode 100644
index b91c5db478..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/arm/jcphuff-neon.c
+++ /dev/null
@@ -1,622 +0,0 @@
-/*
- * jcphuff-neon.c - prepare data for progressive Huffman encoding (Arm Neon)
- *
- * Copyright (C) 2020-2021, Arm Limited. All Rights Reserved.
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- * claim that you wrote the original software. If you use this software
- * in a product, an acknowledgment in the product documentation would be
- * appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must not be
- * misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source distribution.
- */
-
-#define JPEG_INTERNALS
-#include "jconfigint.h"
-#include "../../jinclude.h"
-#include "../../jpeglib.h"
-#include "../../jsimd.h"
-#include "../../jdct.h"
-#include "../../jsimddct.h"
-#include "../jsimd.h"
-#include "neon-compat.h"
-
-#include <arm_neon.h>
-
-
-/* Data preparation for encode_mcu_AC_first().
- *
- * The equivalent scalar C function (encode_mcu_AC_first_prepare()) can be
- * found in jcphuff.c.
- */
-
-void jsimd_encode_mcu_AC_first_prepare_neon
- (const JCOEF *block, const int *jpeg_natural_order_start, int Sl, int Al,
- JCOEF *values, size_t *zerobits)
-{
- JCOEF *values_ptr = values;
- JCOEF *diff_values_ptr = values + DCTSIZE2;
-
- /* Rows of coefficients to zero (since they haven't been processed) */
- int i, rows_to_zero = 8;
-
- for (i = 0; i < Sl / 16; i++) {
- int16x8_t coefs1 = vld1q_dup_s16(block + jpeg_natural_order_start[0]);
- coefs1 = vld1q_lane_s16(block + jpeg_natural_order_start[1], coefs1, 1);
- coefs1 = vld1q_lane_s16(block + jpeg_natural_order_start[2], coefs1, 2);
- coefs1 = vld1q_lane_s16(block + jpeg_natural_order_start[3], coefs1, 3);
- coefs1 = vld1q_lane_s16(block + jpeg_natural_order_start[4], coefs1, 4);
- coefs1 = vld1q_lane_s16(block + jpeg_natural_order_start[5], coefs1, 5);
- coefs1 = vld1q_lane_s16(block + jpeg_natural_order_start[6], coefs1, 6);
- coefs1 = vld1q_lane_s16(block + jpeg_natural_order_start[7], coefs1, 7);
- int16x8_t coefs2 = vld1q_dup_s16(block + jpeg_natural_order_start[8]);
- coefs2 = vld1q_lane_s16(block + jpeg_natural_order_start[9], coefs2, 1);
- coefs2 = vld1q_lane_s16(block + jpeg_natural_order_start[10], coefs2, 2);
- coefs2 = vld1q_lane_s16(block + jpeg_natural_order_start[11], coefs2, 3);
- coefs2 = vld1q_lane_s16(block + jpeg_natural_order_start[12], coefs2, 4);
- coefs2 = vld1q_lane_s16(block + jpeg_natural_order_start[13], coefs2, 5);
- coefs2 = vld1q_lane_s16(block + jpeg_natural_order_start[14], coefs2, 6);
- coefs2 = vld1q_lane_s16(block + jpeg_natural_order_start[15], coefs2, 7);
-
- /* Isolate sign of coefficients. */
- int16x8_t sign_coefs1 = vshrq_n_s16(coefs1, 15);
- int16x8_t sign_coefs2 = vshrq_n_s16(coefs2, 15);
- /* Compute absolute value of coefficients and apply point transform Al. */
- int16x8_t abs_coefs1 = vabsq_s16(coefs1);
- int16x8_t abs_coefs2 = vabsq_s16(coefs2);
- coefs1 = vshlq_s16(abs_coefs1, vdupq_n_s16(-Al));
- coefs2 = vshlq_s16(abs_coefs2, vdupq_n_s16(-Al));
-
- /* Compute diff values. */
- int16x8_t diff1 = veorq_s16(coefs1, sign_coefs1);
- int16x8_t diff2 = veorq_s16(coefs2, sign_coefs2);
-
- /* Store transformed coefficients and diff values. */
- vst1q_s16(values_ptr, coefs1);
- vst1q_s16(values_ptr + DCTSIZE, coefs2);
- vst1q_s16(diff_values_ptr, diff1);
- vst1q_s16(diff_values_ptr + DCTSIZE, diff2);
- values_ptr += 16;
- diff_values_ptr += 16;
- jpeg_natural_order_start += 16;
- rows_to_zero -= 2;
- }
-
- /* Same operation but for remaining partial vector */
- int remaining_coefs = Sl % 16;
- if (remaining_coefs > 8) {
- int16x8_t coefs1 = vld1q_dup_s16(block + jpeg_natural_order_start[0]);
- coefs1 = vld1q_lane_s16(block + jpeg_natural_order_start[1], coefs1, 1);
- coefs1 = vld1q_lane_s16(block + jpeg_natural_order_start[2], coefs1, 2);
- coefs1 = vld1q_lane_s16(block + jpeg_natural_order_start[3], coefs1, 3);
- coefs1 = vld1q_lane_s16(block + jpeg_natural_order_start[4], coefs1, 4);
- coefs1 = vld1q_lane_s16(block + jpeg_natural_order_start[5], coefs1, 5);
- coefs1 = vld1q_lane_s16(block + jpeg_natural_order_start[6], coefs1, 6);
- coefs1 = vld1q_lane_s16(block + jpeg_natural_order_start[7], coefs1, 7);
- int16x8_t coefs2 = vdupq_n_s16(0);
- switch (remaining_coefs) {
- case 15:
- coefs2 = vld1q_lane_s16(block + jpeg_natural_order_start[14], coefs2, 6);
- FALLTHROUGH /*FALLTHROUGH*/
- case 14:
- coefs2 = vld1q_lane_s16(block + jpeg_natural_order_start[13], coefs2, 5);
- FALLTHROUGH /*FALLTHROUGH*/
- case 13:
- coefs2 = vld1q_lane_s16(block + jpeg_natural_order_start[12], coefs2, 4);
- FALLTHROUGH /*FALLTHROUGH*/
- case 12:
- coefs2 = vld1q_lane_s16(block + jpeg_natural_order_start[11], coefs2, 3);
- FALLTHROUGH /*FALLTHROUGH*/
- case 11:
- coefs2 = vld1q_lane_s16(block + jpeg_natural_order_start[10], coefs2, 2);
- FALLTHROUGH /*FALLTHROUGH*/
- case 10:
- coefs2 = vld1q_lane_s16(block + jpeg_natural_order_start[9], coefs2, 1);
- FALLTHROUGH /*FALLTHROUGH*/
- case 9:
- coefs2 = vld1q_lane_s16(block + jpeg_natural_order_start[8], coefs2, 0);
- FALLTHROUGH /*FALLTHROUGH*/
- default:
- break;
- }
-
- /* Isolate sign of coefficients. */
- int16x8_t sign_coefs1 = vshrq_n_s16(coefs1, 15);
- int16x8_t sign_coefs2 = vshrq_n_s16(coefs2, 15);
- /* Compute absolute value of coefficients and apply point transform Al. */
- int16x8_t abs_coefs1 = vabsq_s16(coefs1);
- int16x8_t abs_coefs2 = vabsq_s16(coefs2);
- coefs1 = vshlq_s16(abs_coefs1, vdupq_n_s16(-Al));
- coefs2 = vshlq_s16(abs_coefs2, vdupq_n_s16(-Al));
-
- /* Compute diff values. */
- int16x8_t diff1 = veorq_s16(coefs1, sign_coefs1);
- int16x8_t diff2 = veorq_s16(coefs2, sign_coefs2);
-
- /* Store transformed coefficients and diff values. */
- vst1q_s16(values_ptr, coefs1);
- vst1q_s16(values_ptr + DCTSIZE, coefs2);
- vst1q_s16(diff_values_ptr, diff1);
- vst1q_s16(diff_values_ptr + DCTSIZE, diff2);
- values_ptr += 16;
- diff_values_ptr += 16;
- rows_to_zero -= 2;
-
- } else if (remaining_coefs > 0) {
- int16x8_t coefs = vdupq_n_s16(0);
-
- switch (remaining_coefs) {
- case 8:
- coefs = vld1q_lane_s16(block + jpeg_natural_order_start[7], coefs, 7);
- FALLTHROUGH /*FALLTHROUGH*/
- case 7:
- coefs = vld1q_lane_s16(block + jpeg_natural_order_start[6], coefs, 6);
- FALLTHROUGH /*FALLTHROUGH*/
- case 6:
- coefs = vld1q_lane_s16(block + jpeg_natural_order_start[5], coefs, 5);
- FALLTHROUGH /*FALLTHROUGH*/
- case 5:
- coefs = vld1q_lane_s16(block + jpeg_natural_order_start[4], coefs, 4);
- FALLTHROUGH /*FALLTHROUGH*/
- case 4:
- coefs = vld1q_lane_s16(block + jpeg_natural_order_start[3], coefs, 3);
- FALLTHROUGH /*FALLTHROUGH*/
- case 3:
- coefs = vld1q_lane_s16(block + jpeg_natural_order_start[2], coefs, 2);
- FALLTHROUGH /*FALLTHROUGH*/
- case 2:
- coefs = vld1q_lane_s16(block + jpeg_natural_order_start[1], coefs, 1);
- FALLTHROUGH /*FALLTHROUGH*/
- case 1:
- coefs = vld1q_lane_s16(block + jpeg_natural_order_start[0], coefs, 0);
- FALLTHROUGH /*FALLTHROUGH*/
- default:
- break;
- }
-
- /* Isolate sign of coefficients. */
- int16x8_t sign_coefs = vshrq_n_s16(coefs, 15);
- /* Compute absolute value of coefficients and apply point transform Al. */
- int16x8_t abs_coefs = vabsq_s16(coefs);
- coefs = vshlq_s16(abs_coefs, vdupq_n_s16(-Al));
-
- /* Compute diff values. */
- int16x8_t diff = veorq_s16(coefs, sign_coefs);
-
- /* Store transformed coefficients and diff values. */
- vst1q_s16(values_ptr, coefs);
- vst1q_s16(diff_values_ptr, diff);
- values_ptr += 8;
- diff_values_ptr += 8;
- rows_to_zero--;
- }
-
- /* Zero remaining memory in the values and diff_values blocks. */
- for (i = 0; i < rows_to_zero; i++) {
- vst1q_s16(values_ptr, vdupq_n_s16(0));
- vst1q_s16(diff_values_ptr, vdupq_n_s16(0));
- values_ptr += 8;
- diff_values_ptr += 8;
- }
-
- /* Construct zerobits bitmap. A set bit means that the corresponding
- * coefficient != 0.
- */
- int16x8_t row0 = vld1q_s16(values + 0 * DCTSIZE);
- int16x8_t row1 = vld1q_s16(values + 1 * DCTSIZE);
- int16x8_t row2 = vld1q_s16(values + 2 * DCTSIZE);
- int16x8_t row3 = vld1q_s16(values + 3 * DCTSIZE);
- int16x8_t row4 = vld1q_s16(values + 4 * DCTSIZE);
- int16x8_t row5 = vld1q_s16(values + 5 * DCTSIZE);
- int16x8_t row6 = vld1q_s16(values + 6 * DCTSIZE);
- int16x8_t row7 = vld1q_s16(values + 7 * DCTSIZE);
-
- uint8x8_t row0_eq0 = vmovn_u16(vceqq_s16(row0, vdupq_n_s16(0)));
- uint8x8_t row1_eq0 = vmovn_u16(vceqq_s16(row1, vdupq_n_s16(0)));
- uint8x8_t row2_eq0 = vmovn_u16(vceqq_s16(row2, vdupq_n_s16(0)));
- uint8x8_t row3_eq0 = vmovn_u16(vceqq_s16(row3, vdupq_n_s16(0)));
- uint8x8_t row4_eq0 = vmovn_u16(vceqq_s16(row4, vdupq_n_s16(0)));
- uint8x8_t row5_eq0 = vmovn_u16(vceqq_s16(row5, vdupq_n_s16(0)));
- uint8x8_t row6_eq0 = vmovn_u16(vceqq_s16(row6, vdupq_n_s16(0)));
- uint8x8_t row7_eq0 = vmovn_u16(vceqq_s16(row7, vdupq_n_s16(0)));
-
- /* { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 } */
- const uint8x8_t bitmap_mask =
- vreinterpret_u8_u64(vmov_n_u64(0x8040201008040201));
-
- row0_eq0 = vand_u8(row0_eq0, bitmap_mask);
- row1_eq0 = vand_u8(row1_eq0, bitmap_mask);
- row2_eq0 = vand_u8(row2_eq0, bitmap_mask);
- row3_eq0 = vand_u8(row3_eq0, bitmap_mask);
- row4_eq0 = vand_u8(row4_eq0, bitmap_mask);
- row5_eq0 = vand_u8(row5_eq0, bitmap_mask);
- row6_eq0 = vand_u8(row6_eq0, bitmap_mask);
- row7_eq0 = vand_u8(row7_eq0, bitmap_mask);
-
- uint8x8_t bitmap_rows_01 = vpadd_u8(row0_eq0, row1_eq0);
- uint8x8_t bitmap_rows_23 = vpadd_u8(row2_eq0, row3_eq0);
- uint8x8_t bitmap_rows_45 = vpadd_u8(row4_eq0, row5_eq0);
- uint8x8_t bitmap_rows_67 = vpadd_u8(row6_eq0, row7_eq0);
- uint8x8_t bitmap_rows_0123 = vpadd_u8(bitmap_rows_01, bitmap_rows_23);
- uint8x8_t bitmap_rows_4567 = vpadd_u8(bitmap_rows_45, bitmap_rows_67);
- uint8x8_t bitmap_all = vpadd_u8(bitmap_rows_0123, bitmap_rows_4567);
-
-#if defined(__aarch64__) || defined(_M_ARM64)
- /* Move bitmap to a 64-bit scalar register. */
- uint64_t bitmap = vget_lane_u64(vreinterpret_u64_u8(bitmap_all), 0);
- /* Store zerobits bitmap. */
- *zerobits = ~bitmap;
-#else
- /* Move bitmap to two 32-bit scalar registers. */
- uint32_t bitmap0 = vget_lane_u32(vreinterpret_u32_u8(bitmap_all), 0);
- uint32_t bitmap1 = vget_lane_u32(vreinterpret_u32_u8(bitmap_all), 1);
- /* Store zerobits bitmap. */
- zerobits[0] = ~bitmap0;
- zerobits[1] = ~bitmap1;
-#endif
-}
-
-
-/* Data preparation for encode_mcu_AC_refine().
- *
- * The equivalent scalar C function (encode_mcu_AC_refine_prepare()) can be
- * found in jcphuff.c.
- */
-
-int jsimd_encode_mcu_AC_refine_prepare_neon
- (const JCOEF *block, const int *jpeg_natural_order_start, int Sl, int Al,
- JCOEF *absvalues, size_t *bits)
-{
- /* Temporary storage buffers for data used to compute the signbits bitmap and
- * the end-of-block (EOB) position
- */
- uint8_t coef_sign_bits[64];
- uint8_t coef_eq1_bits[64];
-
- JCOEF *absvalues_ptr = absvalues;
- uint8_t *coef_sign_bits_ptr = coef_sign_bits;
- uint8_t *eq1_bits_ptr = coef_eq1_bits;
-
- /* Rows of coefficients to zero (since they haven't been processed) */
- int i, rows_to_zero = 8;
-
- for (i = 0; i < Sl / 16; i++) {
- int16x8_t coefs1 = vld1q_dup_s16(block + jpeg_natural_order_start[0]);
- coefs1 = vld1q_lane_s16(block + jpeg_natural_order_start[1], coefs1, 1);
- coefs1 = vld1q_lane_s16(block + jpeg_natural_order_start[2], coefs1, 2);
- coefs1 = vld1q_lane_s16(block + jpeg_natural_order_start[3], coefs1, 3);
- coefs1 = vld1q_lane_s16(block + jpeg_natural_order_start[4], coefs1, 4);
- coefs1 = vld1q_lane_s16(block + jpeg_natural_order_start[5], coefs1, 5);
- coefs1 = vld1q_lane_s16(block + jpeg_natural_order_start[6], coefs1, 6);
- coefs1 = vld1q_lane_s16(block + jpeg_natural_order_start[7], coefs1, 7);
- int16x8_t coefs2 = vld1q_dup_s16(block + jpeg_natural_order_start[8]);
- coefs2 = vld1q_lane_s16(block + jpeg_natural_order_start[9], coefs2, 1);
- coefs2 = vld1q_lane_s16(block + jpeg_natural_order_start[10], coefs2, 2);
- coefs2 = vld1q_lane_s16(block + jpeg_natural_order_start[11], coefs2, 3);
- coefs2 = vld1q_lane_s16(block + jpeg_natural_order_start[12], coefs2, 4);
- coefs2 = vld1q_lane_s16(block + jpeg_natural_order_start[13], coefs2, 5);
- coefs2 = vld1q_lane_s16(block + jpeg_natural_order_start[14], coefs2, 6);
- coefs2 = vld1q_lane_s16(block + jpeg_natural_order_start[15], coefs2, 7);
-
- /* Compute and store data for signbits bitmap. */
- uint8x8_t sign_coefs1 =
- vmovn_u16(vreinterpretq_u16_s16(vshrq_n_s16(coefs1, 15)));
- uint8x8_t sign_coefs2 =
- vmovn_u16(vreinterpretq_u16_s16(vshrq_n_s16(coefs2, 15)));
- vst1_u8(coef_sign_bits_ptr, sign_coefs1);
- vst1_u8(coef_sign_bits_ptr + DCTSIZE, sign_coefs2);
-
- /* Compute absolute value of coefficients and apply point transform Al. */
- int16x8_t abs_coefs1 = vabsq_s16(coefs1);
- int16x8_t abs_coefs2 = vabsq_s16(coefs2);
- coefs1 = vshlq_s16(abs_coefs1, vdupq_n_s16(-Al));
- coefs2 = vshlq_s16(abs_coefs2, vdupq_n_s16(-Al));
- vst1q_s16(absvalues_ptr, coefs1);
- vst1q_s16(absvalues_ptr + DCTSIZE, coefs2);
-
- /* Test whether transformed coefficient values == 1 (used to find EOB
- * position.)
- */
- uint8x8_t coefs_eq11 = vmovn_u16(vceqq_s16(coefs1, vdupq_n_s16(1)));
- uint8x8_t coefs_eq12 = vmovn_u16(vceqq_s16(coefs2, vdupq_n_s16(1)));
- vst1_u8(eq1_bits_ptr, coefs_eq11);
- vst1_u8(eq1_bits_ptr + DCTSIZE, coefs_eq12);
-
- absvalues_ptr += 16;
- coef_sign_bits_ptr += 16;
- eq1_bits_ptr += 16;
- jpeg_natural_order_start += 16;
- rows_to_zero -= 2;
- }
-
- /* Same operation but for remaining partial vector */
- int remaining_coefs = Sl % 16;
- if (remaining_coefs > 8) {
- int16x8_t coefs1 = vld1q_dup_s16(block + jpeg_natural_order_start[0]);
- coefs1 = vld1q_lane_s16(block + jpeg_natural_order_start[1], coefs1, 1);
- coefs1 = vld1q_lane_s16(block + jpeg_natural_order_start[2], coefs1, 2);
- coefs1 = vld1q_lane_s16(block + jpeg_natural_order_start[3], coefs1, 3);
- coefs1 = vld1q_lane_s16(block + jpeg_natural_order_start[4], coefs1, 4);
- coefs1 = vld1q_lane_s16(block + jpeg_natural_order_start[5], coefs1, 5);
- coefs1 = vld1q_lane_s16(block + jpeg_natural_order_start[6], coefs1, 6);
- coefs1 = vld1q_lane_s16(block + jpeg_natural_order_start[7], coefs1, 7);
- int16x8_t coefs2 = vdupq_n_s16(0);
- switch (remaining_coefs) {
- case 15:
- coefs2 = vld1q_lane_s16(block + jpeg_natural_order_start[14], coefs2, 6);
- FALLTHROUGH /*FALLTHROUGH*/
- case 14:
- coefs2 = vld1q_lane_s16(block + jpeg_natural_order_start[13], coefs2, 5);
- FALLTHROUGH /*FALLTHROUGH*/
- case 13:
- coefs2 = vld1q_lane_s16(block + jpeg_natural_order_start[12], coefs2, 4);
- FALLTHROUGH /*FALLTHROUGH*/
- case 12:
- coefs2 = vld1q_lane_s16(block + jpeg_natural_order_start[11], coefs2, 3);
- FALLTHROUGH /*FALLTHROUGH*/
- case 11:
- coefs2 = vld1q_lane_s16(block + jpeg_natural_order_start[10], coefs2, 2);
- FALLTHROUGH /*FALLTHROUGH*/
- case 10:
- coefs2 = vld1q_lane_s16(block + jpeg_natural_order_start[9], coefs2, 1);
- FALLTHROUGH /*FALLTHROUGH*/
- case 9:
- coefs2 = vld1q_lane_s16(block + jpeg_natural_order_start[8], coefs2, 0);
- FALLTHROUGH /*FALLTHROUGH*/
- default:
- break;
- }
-
- /* Compute and store data for signbits bitmap. */
- uint8x8_t sign_coefs1 =
- vmovn_u16(vreinterpretq_u16_s16(vshrq_n_s16(coefs1, 15)));
- uint8x8_t sign_coefs2 =
- vmovn_u16(vreinterpretq_u16_s16(vshrq_n_s16(coefs2, 15)));
- vst1_u8(coef_sign_bits_ptr, sign_coefs1);
- vst1_u8(coef_sign_bits_ptr + DCTSIZE, sign_coefs2);
-
- /* Compute absolute value of coefficients and apply point transform Al. */
- int16x8_t abs_coefs1 = vabsq_s16(coefs1);
- int16x8_t abs_coefs2 = vabsq_s16(coefs2);
- coefs1 = vshlq_s16(abs_coefs1, vdupq_n_s16(-Al));
- coefs2 = vshlq_s16(abs_coefs2, vdupq_n_s16(-Al));
- vst1q_s16(absvalues_ptr, coefs1);
- vst1q_s16(absvalues_ptr + DCTSIZE, coefs2);
-
- /* Test whether transformed coefficient values == 1 (used to find EOB
- * position.)
- */
- uint8x8_t coefs_eq11 = vmovn_u16(vceqq_s16(coefs1, vdupq_n_s16(1)));
- uint8x8_t coefs_eq12 = vmovn_u16(vceqq_s16(coefs2, vdupq_n_s16(1)));
- vst1_u8(eq1_bits_ptr, coefs_eq11);
- vst1_u8(eq1_bits_ptr + DCTSIZE, coefs_eq12);
-
- absvalues_ptr += 16;
- coef_sign_bits_ptr += 16;
- eq1_bits_ptr += 16;
- jpeg_natural_order_start += 16;
- rows_to_zero -= 2;
-
- } else if (remaining_coefs > 0) {
- int16x8_t coefs = vdupq_n_s16(0);
-
- switch (remaining_coefs) {
- case 8:
- coefs = vld1q_lane_s16(block + jpeg_natural_order_start[7], coefs, 7);
- FALLTHROUGH /*FALLTHROUGH*/
- case 7:
- coefs = vld1q_lane_s16(block + jpeg_natural_order_start[6], coefs, 6);
- FALLTHROUGH /*FALLTHROUGH*/
- case 6:
- coefs = vld1q_lane_s16(block + jpeg_natural_order_start[5], coefs, 5);
- FALLTHROUGH /*FALLTHROUGH*/
- case 5:
- coefs = vld1q_lane_s16(block + jpeg_natural_order_start[4], coefs, 4);
- FALLTHROUGH /*FALLTHROUGH*/
- case 4:
- coefs = vld1q_lane_s16(block + jpeg_natural_order_start[3], coefs, 3);
- FALLTHROUGH /*FALLTHROUGH*/
- case 3:
- coefs = vld1q_lane_s16(block + jpeg_natural_order_start[2], coefs, 2);
- FALLTHROUGH /*FALLTHROUGH*/
- case 2:
- coefs = vld1q_lane_s16(block + jpeg_natural_order_start[1], coefs, 1);
- FALLTHROUGH /*FALLTHROUGH*/
- case 1:
- coefs = vld1q_lane_s16(block + jpeg_natural_order_start[0], coefs, 0);
- FALLTHROUGH /*FALLTHROUGH*/
- default:
- break;
- }
-
- /* Compute and store data for signbits bitmap. */
- uint8x8_t sign_coefs =
- vmovn_u16(vreinterpretq_u16_s16(vshrq_n_s16(coefs, 15)));
- vst1_u8(coef_sign_bits_ptr, sign_coefs);
-
- /* Compute absolute value of coefficients and apply point transform Al. */
- int16x8_t abs_coefs = vabsq_s16(coefs);
- coefs = vshlq_s16(abs_coefs, vdupq_n_s16(-Al));
- vst1q_s16(absvalues_ptr, coefs);
-
- /* Test whether transformed coefficient values == 1 (used to find EOB
- * position.)
- */
- uint8x8_t coefs_eq1 = vmovn_u16(vceqq_s16(coefs, vdupq_n_s16(1)));
- vst1_u8(eq1_bits_ptr, coefs_eq1);
-
- absvalues_ptr += 8;
- coef_sign_bits_ptr += 8;
- eq1_bits_ptr += 8;
- rows_to_zero--;
- }
-
- /* Zero remaining memory in blocks. */
- for (i = 0; i < rows_to_zero; i++) {
- vst1q_s16(absvalues_ptr, vdupq_n_s16(0));
- vst1_u8(coef_sign_bits_ptr, vdup_n_u8(0));
- vst1_u8(eq1_bits_ptr, vdup_n_u8(0));
- absvalues_ptr += 8;
- coef_sign_bits_ptr += 8;
- eq1_bits_ptr += 8;
- }
-
- /* Construct zerobits bitmap. */
- int16x8_t abs_row0 = vld1q_s16(absvalues + 0 * DCTSIZE);
- int16x8_t abs_row1 = vld1q_s16(absvalues + 1 * DCTSIZE);
- int16x8_t abs_row2 = vld1q_s16(absvalues + 2 * DCTSIZE);
- int16x8_t abs_row3 = vld1q_s16(absvalues + 3 * DCTSIZE);
- int16x8_t abs_row4 = vld1q_s16(absvalues + 4 * DCTSIZE);
- int16x8_t abs_row5 = vld1q_s16(absvalues + 5 * DCTSIZE);
- int16x8_t abs_row6 = vld1q_s16(absvalues + 6 * DCTSIZE);
- int16x8_t abs_row7 = vld1q_s16(absvalues + 7 * DCTSIZE);
-
- uint8x8_t abs_row0_eq0 = vmovn_u16(vceqq_s16(abs_row0, vdupq_n_s16(0)));
- uint8x8_t abs_row1_eq0 = vmovn_u16(vceqq_s16(abs_row1, vdupq_n_s16(0)));
- uint8x8_t abs_row2_eq0 = vmovn_u16(vceqq_s16(abs_row2, vdupq_n_s16(0)));
- uint8x8_t abs_row3_eq0 = vmovn_u16(vceqq_s16(abs_row3, vdupq_n_s16(0)));
- uint8x8_t abs_row4_eq0 = vmovn_u16(vceqq_s16(abs_row4, vdupq_n_s16(0)));
- uint8x8_t abs_row5_eq0 = vmovn_u16(vceqq_s16(abs_row5, vdupq_n_s16(0)));
- uint8x8_t abs_row6_eq0 = vmovn_u16(vceqq_s16(abs_row6, vdupq_n_s16(0)));
- uint8x8_t abs_row7_eq0 = vmovn_u16(vceqq_s16(abs_row7, vdupq_n_s16(0)));
-
- /* { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 } */
- const uint8x8_t bitmap_mask =
- vreinterpret_u8_u64(vmov_n_u64(0x8040201008040201));
-
- abs_row0_eq0 = vand_u8(abs_row0_eq0, bitmap_mask);
- abs_row1_eq0 = vand_u8(abs_row1_eq0, bitmap_mask);
- abs_row2_eq0 = vand_u8(abs_row2_eq0, bitmap_mask);
- abs_row3_eq0 = vand_u8(abs_row3_eq0, bitmap_mask);
- abs_row4_eq0 = vand_u8(abs_row4_eq0, bitmap_mask);
- abs_row5_eq0 = vand_u8(abs_row5_eq0, bitmap_mask);
- abs_row6_eq0 = vand_u8(abs_row6_eq0, bitmap_mask);
- abs_row7_eq0 = vand_u8(abs_row7_eq0, bitmap_mask);
-
- uint8x8_t bitmap_rows_01 = vpadd_u8(abs_row0_eq0, abs_row1_eq0);
- uint8x8_t bitmap_rows_23 = vpadd_u8(abs_row2_eq0, abs_row3_eq0);
- uint8x8_t bitmap_rows_45 = vpadd_u8(abs_row4_eq0, abs_row5_eq0);
- uint8x8_t bitmap_rows_67 = vpadd_u8(abs_row6_eq0, abs_row7_eq0);
- uint8x8_t bitmap_rows_0123 = vpadd_u8(bitmap_rows_01, bitmap_rows_23);
- uint8x8_t bitmap_rows_4567 = vpadd_u8(bitmap_rows_45, bitmap_rows_67);
- uint8x8_t bitmap_all = vpadd_u8(bitmap_rows_0123, bitmap_rows_4567);
-
-#if defined(__aarch64__) || defined(_M_ARM64)
- /* Move bitmap to a 64-bit scalar register. */
- uint64_t bitmap = vget_lane_u64(vreinterpret_u64_u8(bitmap_all), 0);
- /* Store zerobits bitmap. */
- bits[0] = ~bitmap;
-#else
- /* Move bitmap to two 32-bit scalar registers. */
- uint32_t bitmap0 = vget_lane_u32(vreinterpret_u32_u8(bitmap_all), 0);
- uint32_t bitmap1 = vget_lane_u32(vreinterpret_u32_u8(bitmap_all), 1);
- /* Store zerobits bitmap. */
- bits[0] = ~bitmap0;
- bits[1] = ~bitmap1;
-#endif
-
- /* Construct signbits bitmap. */
- uint8x8_t signbits_row0 = vld1_u8(coef_sign_bits + 0 * DCTSIZE);
- uint8x8_t signbits_row1 = vld1_u8(coef_sign_bits + 1 * DCTSIZE);
- uint8x8_t signbits_row2 = vld1_u8(coef_sign_bits + 2 * DCTSIZE);
- uint8x8_t signbits_row3 = vld1_u8(coef_sign_bits + 3 * DCTSIZE);
- uint8x8_t signbits_row4 = vld1_u8(coef_sign_bits + 4 * DCTSIZE);
- uint8x8_t signbits_row5 = vld1_u8(coef_sign_bits + 5 * DCTSIZE);
- uint8x8_t signbits_row6 = vld1_u8(coef_sign_bits + 6 * DCTSIZE);
- uint8x8_t signbits_row7 = vld1_u8(coef_sign_bits + 7 * DCTSIZE);
-
- signbits_row0 = vand_u8(signbits_row0, bitmap_mask);
- signbits_row1 = vand_u8(signbits_row1, bitmap_mask);
- signbits_row2 = vand_u8(signbits_row2, bitmap_mask);
- signbits_row3 = vand_u8(signbits_row3, bitmap_mask);
- signbits_row4 = vand_u8(signbits_row4, bitmap_mask);
- signbits_row5 = vand_u8(signbits_row5, bitmap_mask);
- signbits_row6 = vand_u8(signbits_row6, bitmap_mask);
- signbits_row7 = vand_u8(signbits_row7, bitmap_mask);
-
- bitmap_rows_01 = vpadd_u8(signbits_row0, signbits_row1);
- bitmap_rows_23 = vpadd_u8(signbits_row2, signbits_row3);
- bitmap_rows_45 = vpadd_u8(signbits_row4, signbits_row5);
- bitmap_rows_67 = vpadd_u8(signbits_row6, signbits_row7);
- bitmap_rows_0123 = vpadd_u8(bitmap_rows_01, bitmap_rows_23);
- bitmap_rows_4567 = vpadd_u8(bitmap_rows_45, bitmap_rows_67);
- bitmap_all = vpadd_u8(bitmap_rows_0123, bitmap_rows_4567);
-
-#if defined(__aarch64__) || defined(_M_ARM64)
- /* Move bitmap to a 64-bit scalar register. */
- bitmap = vget_lane_u64(vreinterpret_u64_u8(bitmap_all), 0);
- /* Store signbits bitmap. */
- bits[1] = ~bitmap;
-#else
- /* Move bitmap to two 32-bit scalar registers. */
- bitmap0 = vget_lane_u32(vreinterpret_u32_u8(bitmap_all), 0);
- bitmap1 = vget_lane_u32(vreinterpret_u32_u8(bitmap_all), 1);
- /* Store signbits bitmap. */
- bits[2] = ~bitmap0;
- bits[3] = ~bitmap1;
-#endif
-
- /* Construct bitmap to find EOB position (the index of the last coefficient
- * equal to 1.)
- */
- uint8x8_t row0_eq1 = vld1_u8(coef_eq1_bits + 0 * DCTSIZE);
- uint8x8_t row1_eq1 = vld1_u8(coef_eq1_bits + 1 * DCTSIZE);
- uint8x8_t row2_eq1 = vld1_u8(coef_eq1_bits + 2 * DCTSIZE);
- uint8x8_t row3_eq1 = vld1_u8(coef_eq1_bits + 3 * DCTSIZE);
- uint8x8_t row4_eq1 = vld1_u8(coef_eq1_bits + 4 * DCTSIZE);
- uint8x8_t row5_eq1 = vld1_u8(coef_eq1_bits + 5 * DCTSIZE);
- uint8x8_t row6_eq1 = vld1_u8(coef_eq1_bits + 6 * DCTSIZE);
- uint8x8_t row7_eq1 = vld1_u8(coef_eq1_bits + 7 * DCTSIZE);
-
- row0_eq1 = vand_u8(row0_eq1, bitmap_mask);
- row1_eq1 = vand_u8(row1_eq1, bitmap_mask);
- row2_eq1 = vand_u8(row2_eq1, bitmap_mask);
- row3_eq1 = vand_u8(row3_eq1, bitmap_mask);
- row4_eq1 = vand_u8(row4_eq1, bitmap_mask);
- row5_eq1 = vand_u8(row5_eq1, bitmap_mask);
- row6_eq1 = vand_u8(row6_eq1, bitmap_mask);
- row7_eq1 = vand_u8(row7_eq1, bitmap_mask);
-
- bitmap_rows_01 = vpadd_u8(row0_eq1, row1_eq1);
- bitmap_rows_23 = vpadd_u8(row2_eq1, row3_eq1);
- bitmap_rows_45 = vpadd_u8(row4_eq1, row5_eq1);
- bitmap_rows_67 = vpadd_u8(row6_eq1, row7_eq1);
- bitmap_rows_0123 = vpadd_u8(bitmap_rows_01, bitmap_rows_23);
- bitmap_rows_4567 = vpadd_u8(bitmap_rows_45, bitmap_rows_67);
- bitmap_all = vpadd_u8(bitmap_rows_0123, bitmap_rows_4567);
-
-#if defined(__aarch64__) || defined(_M_ARM64)
- /* Move bitmap to a 64-bit scalar register. */
- bitmap = vget_lane_u64(vreinterpret_u64_u8(bitmap_all), 0);
-
- /* Return EOB position. */
- if (bitmap == 0) {
- /* EOB position is defined to be 0 if all coefficients != 1. */
- return 0;
- } else {
- return 63 - BUILTIN_CLZLL(bitmap);
- }
-#else
- /* Move bitmap to two 32-bit scalar registers. */
- bitmap0 = vget_lane_u32(vreinterpret_u32_u8(bitmap_all), 0);
- bitmap1 = vget_lane_u32(vreinterpret_u32_u8(bitmap_all), 1);
-
- /* Return EOB position. */
- if (bitmap0 == 0 && bitmap1 == 0) {
- return 0;
- } else if (bitmap1 != 0) {
- return 63 - BUILTIN_CLZ(bitmap1);
- } else {
- return 31 - BUILTIN_CLZ(bitmap0);
- }
-#endif
-}
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/jcsample-neon.c b/contrib/libs/libjpeg-turbo/simd/arm/jcsample-neon.c
deleted file mode 100644
index 8a3e237838..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/arm/jcsample-neon.c
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * jcsample-neon.c - downsampling (Arm Neon)
- *
- * Copyright (C) 2020, Arm Limited. All Rights Reserved.
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- * claim that you wrote the original software. If you use this software
- * in a product, an acknowledgment in the product documentation would be
- * appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must not be
- * misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source distribution.
- */
-
-#define JPEG_INTERNALS
-#include "../../jinclude.h"
-#include "../../jpeglib.h"
-#include "../../jsimd.h"
-#include "../../jdct.h"
-#include "../../jsimddct.h"
-#include "../jsimd.h"
-#include "align.h"
-
-#include <arm_neon.h>
-
-
-ALIGN(16) static const uint8_t jsimd_h2_downsample_consts[] = {
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* Pad 0 */
- 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* Pad 1 */
- 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0E,
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* Pad 2 */
- 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0D, 0x0D,
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* Pad 3 */
- 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0C, 0x0C, 0x0C,
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* Pad 4 */
- 0x08, 0x09, 0x0A, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B,
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* Pad 5 */
- 0x08, 0x09, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A,
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* Pad 6 */
- 0x08, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* Pad 7 */
- 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* Pad 8 */
- 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x06, /* Pad 9 */
- 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x05, 0x05, /* Pad 10 */
- 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x04, 0x04, 0x04, /* Pad 11 */
- 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
- 0x00, 0x01, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, /* Pad 12 */
- 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
- 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, /* Pad 13 */
- 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
- 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, /* Pad 14 */
- 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* Pad 15 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-};
-
-
-/* Downsample pixel values of a single component.
- * This version handles the common case of 2:1 horizontal and 1:1 vertical,
- * without smoothing.
- */
-
-void jsimd_h2v1_downsample_neon(JDIMENSION image_width, int max_v_samp_factor,
- JDIMENSION v_samp_factor,
- JDIMENSION width_in_blocks,
- JSAMPARRAY input_data, JSAMPARRAY output_data)
-{
- JSAMPROW inptr, outptr;
- /* Load expansion mask to pad remaining elements of last DCT block. */
- const int mask_offset = 16 * ((width_in_blocks * 2 * DCTSIZE) - image_width);
- const uint8x16_t expand_mask =
- vld1q_u8(&jsimd_h2_downsample_consts[mask_offset]);
- /* Load bias pattern (alternating every pixel.) */
- /* { 0, 1, 0, 1, 0, 1, 0, 1 } */
- const uint16x8_t bias = vreinterpretq_u16_u32(vdupq_n_u32(0x00010000));
- unsigned i, outrow;
-
- for (outrow = 0; outrow < v_samp_factor; outrow++) {
- outptr = output_data[outrow];
- inptr = input_data[outrow];
-
- /* Downsample all but the last DCT block of pixels. */
- for (i = 0; i < width_in_blocks - 1; i++) {
- uint8x16_t pixels = vld1q_u8(inptr + i * 2 * DCTSIZE);
- /* Add adjacent pixel values, widen to 16-bit, and add bias. */
- uint16x8_t samples_u16 = vpadalq_u8(bias, pixels);
- /* Divide total by 2 and narrow to 8-bit. */
- uint8x8_t samples_u8 = vshrn_n_u16(samples_u16, 1);
- /* Store samples to memory. */
- vst1_u8(outptr + i * DCTSIZE, samples_u8);
- }
-
- /* Load pixels in last DCT block into a table. */
- uint8x16_t pixels = vld1q_u8(inptr + (width_in_blocks - 1) * 2 * DCTSIZE);
-#if defined(__aarch64__) || defined(_M_ARM64)
- /* Pad the empty elements with the value of the last pixel. */
- pixels = vqtbl1q_u8(pixels, expand_mask);
-#else
- uint8x8x2_t table = { { vget_low_u8(pixels), vget_high_u8(pixels) } };
- pixels = vcombine_u8(vtbl2_u8(table, vget_low_u8(expand_mask)),
- vtbl2_u8(table, vget_high_u8(expand_mask)));
-#endif
- /* Add adjacent pixel values, widen to 16-bit, and add bias. */
- uint16x8_t samples_u16 = vpadalq_u8(bias, pixels);
- /* Divide total by 2, narrow to 8-bit, and store. */
- uint8x8_t samples_u8 = vshrn_n_u16(samples_u16, 1);
- vst1_u8(outptr + (width_in_blocks - 1) * DCTSIZE, samples_u8);
- }
-}
-
-
-/* Downsample pixel values of a single component.
- * This version handles the standard case of 2:1 horizontal and 2:1 vertical,
- * without smoothing.
- */
-
-void jsimd_h2v2_downsample_neon(JDIMENSION image_width, int max_v_samp_factor,
- JDIMENSION v_samp_factor,
- JDIMENSION width_in_blocks,
- JSAMPARRAY input_data, JSAMPARRAY output_data)
-{
- JSAMPROW inptr0, inptr1, outptr;
- /* Load expansion mask to pad remaining elements of last DCT block. */
- const int mask_offset = 16 * ((width_in_blocks * 2 * DCTSIZE) - image_width);
- const uint8x16_t expand_mask =
- vld1q_u8(&jsimd_h2_downsample_consts[mask_offset]);
- /* Load bias pattern (alternating every pixel.) */
- /* { 1, 2, 1, 2, 1, 2, 1, 2 } */
- const uint16x8_t bias = vreinterpretq_u16_u32(vdupq_n_u32(0x00020001));
- unsigned i, outrow;
-
- for (outrow = 0; outrow < v_samp_factor; outrow++) {
- outptr = output_data[outrow];
- inptr0 = input_data[outrow];
- inptr1 = input_data[outrow + 1];
-
- /* Downsample all but the last DCT block of pixels. */
- for (i = 0; i < width_in_blocks - 1; i++) {
- uint8x16_t pixels_r0 = vld1q_u8(inptr0 + i * 2 * DCTSIZE);
- uint8x16_t pixels_r1 = vld1q_u8(inptr1 + i * 2 * DCTSIZE);
- /* Add adjacent pixel values in row 0, widen to 16-bit, and add bias. */
- uint16x8_t samples_u16 = vpadalq_u8(bias, pixels_r0);
- /* Add adjacent pixel values in row 1, widen to 16-bit, and accumulate.
- */
- samples_u16 = vpadalq_u8(samples_u16, pixels_r1);
- /* Divide total by 4 and narrow to 8-bit. */
- uint8x8_t samples_u8 = vshrn_n_u16(samples_u16, 2);
- /* Store samples to memory and increment pointers. */
- vst1_u8(outptr + i * DCTSIZE, samples_u8);
- }
-
- /* Load pixels in last DCT block into a table. */
- uint8x16_t pixels_r0 =
- vld1q_u8(inptr0 + (width_in_blocks - 1) * 2 * DCTSIZE);
- uint8x16_t pixels_r1 =
- vld1q_u8(inptr1 + (width_in_blocks - 1) * 2 * DCTSIZE);
-#if defined(__aarch64__) || defined(_M_ARM64)
- /* Pad the empty elements with the value of the last pixel. */
- pixels_r0 = vqtbl1q_u8(pixels_r0, expand_mask);
- pixels_r1 = vqtbl1q_u8(pixels_r1, expand_mask);
-#else
- uint8x8x2_t table_r0 =
- { { vget_low_u8(pixels_r0), vget_high_u8(pixels_r0) } };
- uint8x8x2_t table_r1 =
- { { vget_low_u8(pixels_r1), vget_high_u8(pixels_r1) } };
- pixels_r0 = vcombine_u8(vtbl2_u8(table_r0, vget_low_u8(expand_mask)),
- vtbl2_u8(table_r0, vget_high_u8(expand_mask)));
- pixels_r1 = vcombine_u8(vtbl2_u8(table_r1, vget_low_u8(expand_mask)),
- vtbl2_u8(table_r1, vget_high_u8(expand_mask)));
-#endif
- /* Add adjacent pixel values in row 0, widen to 16-bit, and add bias. */
- uint16x8_t samples_u16 = vpadalq_u8(bias, pixels_r0);
- /* Add adjacent pixel values in row 1, widen to 16-bit, and accumulate. */
- samples_u16 = vpadalq_u8(samples_u16, pixels_r1);
- /* Divide total by 4, narrow to 8-bit, and store. */
- uint8x8_t samples_u8 = vshrn_n_u16(samples_u16, 2);
- vst1_u8(outptr + (width_in_blocks - 1) * DCTSIZE, samples_u8);
- }
-}
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/jdcolext-neon.c b/contrib/libs/libjpeg-turbo/simd/arm/jdcolext-neon.c
deleted file mode 100644
index c3c07a1964..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/arm/jdcolext-neon.c
+++ /dev/null
@@ -1,374 +0,0 @@
-/*
- * jdcolext-neon.c - colorspace conversion (Arm Neon)
- *
- * Copyright (C) 2020, Arm Limited. All Rights Reserved.
- * Copyright (C) 2020, D. R. Commander. All Rights Reserved.
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- * claim that you wrote the original software. If you use this software
- * in a product, an acknowledgment in the product documentation would be
- * appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must not be
- * misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source distribution.
- */
-
-/* This file is included by jdcolor-neon.c. */
-
-
-/* YCbCr -> RGB conversion is defined by the following equations:
- * R = Y + 1.40200 * (Cr - 128)
- * G = Y - 0.34414 * (Cb - 128) - 0.71414 * (Cr - 128)
- * B = Y + 1.77200 * (Cb - 128)
- *
- * Scaled integer constants are used to avoid floating-point arithmetic:
- * 0.3441467 = 11277 * 2^-15
- * 0.7141418 = 23401 * 2^-15
- * 1.4020386 = 22971 * 2^-14
- * 1.7720337 = 29033 * 2^-14
- * These constants are defined in jdcolor-neon.c.
- *
- * To ensure correct results, rounding is used when descaling.
- */
-
-/* Notes on safe memory access for YCbCr -> RGB conversion routines:
- *
- * Input memory buffers can be safely overread up to the next multiple of
- * ALIGN_SIZE bytes, since they are always allocated by alloc_sarray() in
- * jmemmgr.c.
- *
- * The output buffer cannot safely be written beyond output_width, since
- * output_buf points to a possibly unpadded row in the decompressed image
- * buffer allocated by the calling program.
- */
-
-void jsimd_ycc_rgb_convert_neon(JDIMENSION output_width, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf,
- int num_rows)
-{
- JSAMPROW outptr;
- /* Pointers to Y, Cb, and Cr data */
- JSAMPROW inptr0, inptr1, inptr2;
-
- const int16x4_t consts = vld1_s16(jsimd_ycc_rgb_convert_neon_consts);
- const int16x8_t neg_128 = vdupq_n_s16(-128);
-
- while (--num_rows >= 0) {
- inptr0 = input_buf[0][input_row];
- inptr1 = input_buf[1][input_row];
- inptr2 = input_buf[2][input_row];
- input_row++;
- outptr = *output_buf++;
- int cols_remaining = output_width;
- for (; cols_remaining >= 16; cols_remaining -= 16) {
- uint8x16_t y = vld1q_u8(inptr0);
- uint8x16_t cb = vld1q_u8(inptr1);
- uint8x16_t cr = vld1q_u8(inptr2);
- /* Subtract 128 from Cb and Cr. */
- int16x8_t cr_128_l =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(neg_128),
- vget_low_u8(cr)));
- int16x8_t cr_128_h =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(neg_128),
- vget_high_u8(cr)));
- int16x8_t cb_128_l =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(neg_128),
- vget_low_u8(cb)));
- int16x8_t cb_128_h =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(neg_128),
- vget_high_u8(cb)));
- /* Compute G-Y: - 0.34414 * (Cb - 128) - 0.71414 * (Cr - 128) */
- int32x4_t g_sub_y_ll = vmull_lane_s16(vget_low_s16(cb_128_l), consts, 0);
- int32x4_t g_sub_y_lh = vmull_lane_s16(vget_high_s16(cb_128_l),
- consts, 0);
- int32x4_t g_sub_y_hl = vmull_lane_s16(vget_low_s16(cb_128_h), consts, 0);
- int32x4_t g_sub_y_hh = vmull_lane_s16(vget_high_s16(cb_128_h),
- consts, 0);
- g_sub_y_ll = vmlsl_lane_s16(g_sub_y_ll, vget_low_s16(cr_128_l),
- consts, 1);
- g_sub_y_lh = vmlsl_lane_s16(g_sub_y_lh, vget_high_s16(cr_128_l),
- consts, 1);
- g_sub_y_hl = vmlsl_lane_s16(g_sub_y_hl, vget_low_s16(cr_128_h),
- consts, 1);
- g_sub_y_hh = vmlsl_lane_s16(g_sub_y_hh, vget_high_s16(cr_128_h),
- consts, 1);
- /* Descale G components: shift right 15, round, and narrow to 16-bit. */
- int16x8_t g_sub_y_l = vcombine_s16(vrshrn_n_s32(g_sub_y_ll, 15),
- vrshrn_n_s32(g_sub_y_lh, 15));
- int16x8_t g_sub_y_h = vcombine_s16(vrshrn_n_s32(g_sub_y_hl, 15),
- vrshrn_n_s32(g_sub_y_hh, 15));
- /* Compute R-Y: 1.40200 * (Cr - 128) */
- int16x8_t r_sub_y_l = vqrdmulhq_lane_s16(vshlq_n_s16(cr_128_l, 1),
- consts, 2);
- int16x8_t r_sub_y_h = vqrdmulhq_lane_s16(vshlq_n_s16(cr_128_h, 1),
- consts, 2);
- /* Compute B-Y: 1.77200 * (Cb - 128) */
- int16x8_t b_sub_y_l = vqrdmulhq_lane_s16(vshlq_n_s16(cb_128_l, 1),
- consts, 3);
- int16x8_t b_sub_y_h = vqrdmulhq_lane_s16(vshlq_n_s16(cb_128_h, 1),
- consts, 3);
- /* Add Y. */
- int16x8_t r_l =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(r_sub_y_l),
- vget_low_u8(y)));
- int16x8_t r_h =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(r_sub_y_h),
- vget_high_u8(y)));
- int16x8_t b_l =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(b_sub_y_l),
- vget_low_u8(y)));
- int16x8_t b_h =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(b_sub_y_h),
- vget_high_u8(y)));
- int16x8_t g_l =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(g_sub_y_l),
- vget_low_u8(y)));
- int16x8_t g_h =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(g_sub_y_h),
- vget_high_u8(y)));
-
-#if RGB_PIXELSIZE == 4
- uint8x16x4_t rgba;
- /* Convert each component to unsigned and narrow, clamping to [0-255]. */
- rgba.val[RGB_RED] = vcombine_u8(vqmovun_s16(r_l), vqmovun_s16(r_h));
- rgba.val[RGB_GREEN] = vcombine_u8(vqmovun_s16(g_l), vqmovun_s16(g_h));
- rgba.val[RGB_BLUE] = vcombine_u8(vqmovun_s16(b_l), vqmovun_s16(b_h));
- /* Set alpha channel to opaque (0xFF). */
- rgba.val[RGB_ALPHA] = vdupq_n_u8(0xFF);
- /* Store RGBA pixel data to memory. */
- vst4q_u8(outptr, rgba);
-#elif RGB_PIXELSIZE == 3
- uint8x16x3_t rgb;
- /* Convert each component to unsigned and narrow, clamping to [0-255]. */
- rgb.val[RGB_RED] = vcombine_u8(vqmovun_s16(r_l), vqmovun_s16(r_h));
- rgb.val[RGB_GREEN] = vcombine_u8(vqmovun_s16(g_l), vqmovun_s16(g_h));
- rgb.val[RGB_BLUE] = vcombine_u8(vqmovun_s16(b_l), vqmovun_s16(b_h));
- /* Store RGB pixel data to memory. */
- vst3q_u8(outptr, rgb);
-#else
- /* Pack R, G, and B values in ratio 5:6:5. */
- uint16x8_t rgb565_l = vqshluq_n_s16(r_l, 8);
- rgb565_l = vsriq_n_u16(rgb565_l, vqshluq_n_s16(g_l, 8), 5);
- rgb565_l = vsriq_n_u16(rgb565_l, vqshluq_n_s16(b_l, 8), 11);
- uint16x8_t rgb565_h = vqshluq_n_s16(r_h, 8);
- rgb565_h = vsriq_n_u16(rgb565_h, vqshluq_n_s16(g_h, 8), 5);
- rgb565_h = vsriq_n_u16(rgb565_h, vqshluq_n_s16(b_h, 8), 11);
- /* Store RGB pixel data to memory. */
- vst1q_u16((uint16_t *)outptr, rgb565_l);
- vst1q_u16(((uint16_t *)outptr) + 8, rgb565_h);
-#endif
-
- /* Increment pointers. */
- inptr0 += 16;
- inptr1 += 16;
- inptr2 += 16;
- outptr += (RGB_PIXELSIZE * 16);
- }
-
- if (cols_remaining >= 8) {
- uint8x8_t y = vld1_u8(inptr0);
- uint8x8_t cb = vld1_u8(inptr1);
- uint8x8_t cr = vld1_u8(inptr2);
- /* Subtract 128 from Cb and Cr. */
- int16x8_t cr_128 =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(neg_128), cr));
- int16x8_t cb_128 =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(neg_128), cb));
- /* Compute G-Y: - 0.34414 * (Cb - 128) - 0.71414 * (Cr - 128) */
- int32x4_t g_sub_y_l = vmull_lane_s16(vget_low_s16(cb_128), consts, 0);
- int32x4_t g_sub_y_h = vmull_lane_s16(vget_high_s16(cb_128), consts, 0);
- g_sub_y_l = vmlsl_lane_s16(g_sub_y_l, vget_low_s16(cr_128), consts, 1);
- g_sub_y_h = vmlsl_lane_s16(g_sub_y_h, vget_high_s16(cr_128), consts, 1);
- /* Descale G components: shift right 15, round, and narrow to 16-bit. */
- int16x8_t g_sub_y = vcombine_s16(vrshrn_n_s32(g_sub_y_l, 15),
- vrshrn_n_s32(g_sub_y_h, 15));
- /* Compute R-Y: 1.40200 * (Cr - 128) */
- int16x8_t r_sub_y = vqrdmulhq_lane_s16(vshlq_n_s16(cr_128, 1),
- consts, 2);
- /* Compute B-Y: 1.77200 * (Cb - 128) */
- int16x8_t b_sub_y = vqrdmulhq_lane_s16(vshlq_n_s16(cb_128, 1),
- consts, 3);
- /* Add Y. */
- int16x8_t r =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(r_sub_y), y));
- int16x8_t b =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(b_sub_y), y));
- int16x8_t g =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(g_sub_y), y));
-
-#if RGB_PIXELSIZE == 4
- uint8x8x4_t rgba;
- /* Convert each component to unsigned and narrow, clamping to [0-255]. */
- rgba.val[RGB_RED] = vqmovun_s16(r);
- rgba.val[RGB_GREEN] = vqmovun_s16(g);
- rgba.val[RGB_BLUE] = vqmovun_s16(b);
- /* Set alpha channel to opaque (0xFF). */
- rgba.val[RGB_ALPHA] = vdup_n_u8(0xFF);
- /* Store RGBA pixel data to memory. */
- vst4_u8(outptr, rgba);
-#elif RGB_PIXELSIZE == 3
- uint8x8x3_t rgb;
- /* Convert each component to unsigned and narrow, clamping to [0-255]. */
- rgb.val[RGB_RED] = vqmovun_s16(r);
- rgb.val[RGB_GREEN] = vqmovun_s16(g);
- rgb.val[RGB_BLUE] = vqmovun_s16(b);
- /* Store RGB pixel data to memory. */
- vst3_u8(outptr, rgb);
-#else
- /* Pack R, G, and B values in ratio 5:6:5. */
- uint16x8_t rgb565 = vqshluq_n_s16(r, 8);
- rgb565 = vsriq_n_u16(rgb565, vqshluq_n_s16(g, 8), 5);
- rgb565 = vsriq_n_u16(rgb565, vqshluq_n_s16(b, 8), 11);
- /* Store RGB pixel data to memory. */
- vst1q_u16((uint16_t *)outptr, rgb565);
-#endif
-
- /* Increment pointers. */
- inptr0 += 8;
- inptr1 += 8;
- inptr2 += 8;
- outptr += (RGB_PIXELSIZE * 8);
- cols_remaining -= 8;
- }
-
- /* Handle the tail elements. */
- if (cols_remaining > 0) {
- uint8x8_t y = vld1_u8(inptr0);
- uint8x8_t cb = vld1_u8(inptr1);
- uint8x8_t cr = vld1_u8(inptr2);
- /* Subtract 128 from Cb and Cr. */
- int16x8_t cr_128 =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(neg_128), cr));
- int16x8_t cb_128 =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(neg_128), cb));
- /* Compute G-Y: - 0.34414 * (Cb - 128) - 0.71414 * (Cr - 128) */
- int32x4_t g_sub_y_l = vmull_lane_s16(vget_low_s16(cb_128), consts, 0);
- int32x4_t g_sub_y_h = vmull_lane_s16(vget_high_s16(cb_128), consts, 0);
- g_sub_y_l = vmlsl_lane_s16(g_sub_y_l, vget_low_s16(cr_128), consts, 1);
- g_sub_y_h = vmlsl_lane_s16(g_sub_y_h, vget_high_s16(cr_128), consts, 1);
- /* Descale G components: shift right 15, round, and narrow to 16-bit. */
- int16x8_t g_sub_y = vcombine_s16(vrshrn_n_s32(g_sub_y_l, 15),
- vrshrn_n_s32(g_sub_y_h, 15));
- /* Compute R-Y: 1.40200 * (Cr - 128) */
- int16x8_t r_sub_y = vqrdmulhq_lane_s16(vshlq_n_s16(cr_128, 1),
- consts, 2);
- /* Compute B-Y: 1.77200 * (Cb - 128) */
- int16x8_t b_sub_y = vqrdmulhq_lane_s16(vshlq_n_s16(cb_128, 1),
- consts, 3);
- /* Add Y. */
- int16x8_t r =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(r_sub_y), y));
- int16x8_t b =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(b_sub_y), y));
- int16x8_t g =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(g_sub_y), y));
-
-#if RGB_PIXELSIZE == 4
- uint8x8x4_t rgba;
- /* Convert each component to unsigned and narrow, clamping to [0-255]. */
- rgba.val[RGB_RED] = vqmovun_s16(r);
- rgba.val[RGB_GREEN] = vqmovun_s16(g);
- rgba.val[RGB_BLUE] = vqmovun_s16(b);
- /* Set alpha channel to opaque (0xFF). */
- rgba.val[RGB_ALPHA] = vdup_n_u8(0xFF);
- /* Store RGBA pixel data to memory. */
- switch (cols_remaining) {
- case 7:
- vst4_lane_u8(outptr + 6 * RGB_PIXELSIZE, rgba, 6);
- FALLTHROUGH /*FALLTHROUGH*/
- case 6:
- vst4_lane_u8(outptr + 5 * RGB_PIXELSIZE, rgba, 5);
- FALLTHROUGH /*FALLTHROUGH*/
- case 5:
- vst4_lane_u8(outptr + 4 * RGB_PIXELSIZE, rgba, 4);
- FALLTHROUGH /*FALLTHROUGH*/
- case 4:
- vst4_lane_u8(outptr + 3 * RGB_PIXELSIZE, rgba, 3);
- FALLTHROUGH /*FALLTHROUGH*/
- case 3:
- vst4_lane_u8(outptr + 2 * RGB_PIXELSIZE, rgba, 2);
- FALLTHROUGH /*FALLTHROUGH*/
- case 2:
- vst4_lane_u8(outptr + RGB_PIXELSIZE, rgba, 1);
- FALLTHROUGH /*FALLTHROUGH*/
- case 1:
- vst4_lane_u8(outptr, rgba, 0);
- FALLTHROUGH /*FALLTHROUGH*/
- default:
- break;
- }
-#elif RGB_PIXELSIZE == 3
- uint8x8x3_t rgb;
- /* Convert each component to unsigned and narrow, clamping to [0-255]. */
- rgb.val[RGB_RED] = vqmovun_s16(r);
- rgb.val[RGB_GREEN] = vqmovun_s16(g);
- rgb.val[RGB_BLUE] = vqmovun_s16(b);
- /* Store RGB pixel data to memory. */
- switch (cols_remaining) {
- case 7:
- vst3_lane_u8(outptr + 6 * RGB_PIXELSIZE, rgb, 6);
- FALLTHROUGH /*FALLTHROUGH*/
- case 6:
- vst3_lane_u8(outptr + 5 * RGB_PIXELSIZE, rgb, 5);
- FALLTHROUGH /*FALLTHROUGH*/
- case 5:
- vst3_lane_u8(outptr + 4 * RGB_PIXELSIZE, rgb, 4);
- FALLTHROUGH /*FALLTHROUGH*/
- case 4:
- vst3_lane_u8(outptr + 3 * RGB_PIXELSIZE, rgb, 3);
- FALLTHROUGH /*FALLTHROUGH*/
- case 3:
- vst3_lane_u8(outptr + 2 * RGB_PIXELSIZE, rgb, 2);
- FALLTHROUGH /*FALLTHROUGH*/
- case 2:
- vst3_lane_u8(outptr + RGB_PIXELSIZE, rgb, 1);
- FALLTHROUGH /*FALLTHROUGH*/
- case 1:
- vst3_lane_u8(outptr, rgb, 0);
- FALLTHROUGH /*FALLTHROUGH*/
- default:
- break;
- }
-#else
- /* Pack R, G, and B values in ratio 5:6:5. */
- uint16x8_t rgb565 = vqshluq_n_s16(r, 8);
- rgb565 = vsriq_n_u16(rgb565, vqshluq_n_s16(g, 8), 5);
- rgb565 = vsriq_n_u16(rgb565, vqshluq_n_s16(b, 8), 11);
- /* Store RGB565 pixel data to memory. */
- switch (cols_remaining) {
- case 7:
- vst1q_lane_u16((uint16_t *)(outptr + 6 * RGB_PIXELSIZE), rgb565, 6);
- FALLTHROUGH /*FALLTHROUGH*/
- case 6:
- vst1q_lane_u16((uint16_t *)(outptr + 5 * RGB_PIXELSIZE), rgb565, 5);
- FALLTHROUGH /*FALLTHROUGH*/
- case 5:
- vst1q_lane_u16((uint16_t *)(outptr + 4 * RGB_PIXELSIZE), rgb565, 4);
- FALLTHROUGH /*FALLTHROUGH*/
- case 4:
- vst1q_lane_u16((uint16_t *)(outptr + 3 * RGB_PIXELSIZE), rgb565, 3);
- FALLTHROUGH /*FALLTHROUGH*/
- case 3:
- vst1q_lane_u16((uint16_t *)(outptr + 2 * RGB_PIXELSIZE), rgb565, 2);
- FALLTHROUGH /*FALLTHROUGH*/
- case 2:
- vst1q_lane_u16((uint16_t *)(outptr + RGB_PIXELSIZE), rgb565, 1);
- FALLTHROUGH /*FALLTHROUGH*/
- case 1:
- vst1q_lane_u16((uint16_t *)outptr, rgb565, 0);
- FALLTHROUGH /*FALLTHROUGH*/
- default:
- break;
- }
-#endif
- }
- }
-}
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/jdcolor-neon.c b/contrib/libs/libjpeg-turbo/simd/arm/jdcolor-neon.c
deleted file mode 100644
index ea4668f1d3..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/arm/jdcolor-neon.c
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * jdcolor-neon.c - colorspace conversion (Arm Neon)
- *
- * Copyright (C) 2020, Arm Limited. All Rights Reserved.
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- * claim that you wrote the original software. If you use this software
- * in a product, an acknowledgment in the product documentation would be
- * appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must not be
- * misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source distribution.
- */
-
-#define JPEG_INTERNALS
-#include "jconfigint.h"
-#include "../../jinclude.h"
-#include "../../jpeglib.h"
-#include "../../jsimd.h"
-#include "../../jdct.h"
-#include "../../jsimddct.h"
-#include "../jsimd.h"
-#include "align.h"
-
-#include <arm_neon.h>
-
-
-/* YCbCr -> RGB conversion constants */
-
-#define F_0_344 11277 /* 0.3441467 = 11277 * 2^-15 */
-#define F_0_714 23401 /* 0.7141418 = 23401 * 2^-15 */
-#define F_1_402 22971 /* 1.4020386 = 22971 * 2^-14 */
-#define F_1_772 29033 /* 1.7720337 = 29033 * 2^-14 */
-
-ALIGN(16) static const int16_t jsimd_ycc_rgb_convert_neon_consts[] = {
- -F_0_344, F_0_714, F_1_402, F_1_772
-};
-
-
-/* Include inline routines for colorspace extensions. */
-
-#include "jdcolext-neon.c"
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_PIXELSIZE
-
-#define RGB_RED EXT_RGB_RED
-#define RGB_GREEN EXT_RGB_GREEN
-#define RGB_BLUE EXT_RGB_BLUE
-#define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
-#define jsimd_ycc_rgb_convert_neon jsimd_ycc_extrgb_convert_neon
-#include "jdcolext-neon.c"
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_PIXELSIZE
-#undef jsimd_ycc_rgb_convert_neon
-
-#define RGB_RED EXT_RGBX_RED
-#define RGB_GREEN EXT_RGBX_GREEN
-#define RGB_BLUE EXT_RGBX_BLUE
-#define RGB_ALPHA 3
-#define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
-#define jsimd_ycc_rgb_convert_neon jsimd_ycc_extrgbx_convert_neon
-#include "jdcolext-neon.c"
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_ALPHA
-#undef RGB_PIXELSIZE
-#undef jsimd_ycc_rgb_convert_neon
-
-#define RGB_RED EXT_BGR_RED
-#define RGB_GREEN EXT_BGR_GREEN
-#define RGB_BLUE EXT_BGR_BLUE
-#define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
-#define jsimd_ycc_rgb_convert_neon jsimd_ycc_extbgr_convert_neon
-#include "jdcolext-neon.c"
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_PIXELSIZE
-#undef jsimd_ycc_rgb_convert_neon
-
-#define RGB_RED EXT_BGRX_RED
-#define RGB_GREEN EXT_BGRX_GREEN
-#define RGB_BLUE EXT_BGRX_BLUE
-#define RGB_ALPHA 3
-#define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
-#define jsimd_ycc_rgb_convert_neon jsimd_ycc_extbgrx_convert_neon
-#include "jdcolext-neon.c"
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_ALPHA
-#undef RGB_PIXELSIZE
-#undef jsimd_ycc_rgb_convert_neon
-
-#define RGB_RED EXT_XBGR_RED
-#define RGB_GREEN EXT_XBGR_GREEN
-#define RGB_BLUE EXT_XBGR_BLUE
-#define RGB_ALPHA 0
-#define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
-#define jsimd_ycc_rgb_convert_neon jsimd_ycc_extxbgr_convert_neon
-#include "jdcolext-neon.c"
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_ALPHA
-#undef RGB_PIXELSIZE
-#undef jsimd_ycc_rgb_convert_neon
-
-#define RGB_RED EXT_XRGB_RED
-#define RGB_GREEN EXT_XRGB_GREEN
-#define RGB_BLUE EXT_XRGB_BLUE
-#define RGB_ALPHA 0
-#define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
-#define jsimd_ycc_rgb_convert_neon jsimd_ycc_extxrgb_convert_neon
-#include "jdcolext-neon.c"
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_ALPHA
-#undef RGB_PIXELSIZE
-#undef jsimd_ycc_rgb_convert_neon
-
-/* YCbCr -> RGB565 Conversion */
-
-#define RGB_PIXELSIZE 2
-#define jsimd_ycc_rgb_convert_neon jsimd_ycc_rgb565_convert_neon
-#include "jdcolext-neon.c"
-#undef RGB_PIXELSIZE
-#undef jsimd_ycc_rgb_convert_neon
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/jdmerge-neon.c b/contrib/libs/libjpeg-turbo/simd/arm/jdmerge-neon.c
deleted file mode 100644
index e4f91fdc0e..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/arm/jdmerge-neon.c
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * jdmerge-neon.c - merged upsampling/color conversion (Arm Neon)
- *
- * Copyright (C) 2020, Arm Limited. All Rights Reserved.
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- * claim that you wrote the original software. If you use this software
- * in a product, an acknowledgment in the product documentation would be
- * appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must not be
- * misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source distribution.
- */
-
-#define JPEG_INTERNALS
-#include "jconfigint.h"
-#include "../../jinclude.h"
-#include "../../jpeglib.h"
-#include "../../jsimd.h"
-#include "../../jdct.h"
-#include "../../jsimddct.h"
-#include "../jsimd.h"
-#include "align.h"
-
-#include <arm_neon.h>
-
-
-/* YCbCr -> RGB conversion constants */
-
-#define F_0_344 11277 /* 0.3441467 = 11277 * 2^-15 */
-#define F_0_714 23401 /* 0.7141418 = 23401 * 2^-15 */
-#define F_1_402 22971 /* 1.4020386 = 22971 * 2^-14 */
-#define F_1_772 29033 /* 1.7720337 = 29033 * 2^-14 */
-
-ALIGN(16) static const int16_t jsimd_ycc_rgb_convert_neon_consts[] = {
- -F_0_344, F_0_714, F_1_402, F_1_772
-};
-
-
-/* Include inline routines for colorspace extensions. */
-
-#include "jdmrgext-neon.c"
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_PIXELSIZE
-
-#define RGB_RED EXT_RGB_RED
-#define RGB_GREEN EXT_RGB_GREEN
-#define RGB_BLUE EXT_RGB_BLUE
-#define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
-#define jsimd_h2v1_merged_upsample_neon jsimd_h2v1_extrgb_merged_upsample_neon
-#define jsimd_h2v2_merged_upsample_neon jsimd_h2v2_extrgb_merged_upsample_neon
-#include "jdmrgext-neon.c"
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_PIXELSIZE
-#undef jsimd_h2v1_merged_upsample_neon
-#undef jsimd_h2v2_merged_upsample_neon
-
-#define RGB_RED EXT_RGBX_RED
-#define RGB_GREEN EXT_RGBX_GREEN
-#define RGB_BLUE EXT_RGBX_BLUE
-#define RGB_ALPHA 3
-#define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
-#define jsimd_h2v1_merged_upsample_neon jsimd_h2v1_extrgbx_merged_upsample_neon
-#define jsimd_h2v2_merged_upsample_neon jsimd_h2v2_extrgbx_merged_upsample_neon
-#include "jdmrgext-neon.c"
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_ALPHA
-#undef RGB_PIXELSIZE
-#undef jsimd_h2v1_merged_upsample_neon
-#undef jsimd_h2v2_merged_upsample_neon
-
-#define RGB_RED EXT_BGR_RED
-#define RGB_GREEN EXT_BGR_GREEN
-#define RGB_BLUE EXT_BGR_BLUE
-#define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
-#define jsimd_h2v1_merged_upsample_neon jsimd_h2v1_extbgr_merged_upsample_neon
-#define jsimd_h2v2_merged_upsample_neon jsimd_h2v2_extbgr_merged_upsample_neon
-#include "jdmrgext-neon.c"
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_PIXELSIZE
-#undef jsimd_h2v1_merged_upsample_neon
-#undef jsimd_h2v2_merged_upsample_neon
-
-#define RGB_RED EXT_BGRX_RED
-#define RGB_GREEN EXT_BGRX_GREEN
-#define RGB_BLUE EXT_BGRX_BLUE
-#define RGB_ALPHA 3
-#define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
-#define jsimd_h2v1_merged_upsample_neon jsimd_h2v1_extbgrx_merged_upsample_neon
-#define jsimd_h2v2_merged_upsample_neon jsimd_h2v2_extbgrx_merged_upsample_neon
-#include "jdmrgext-neon.c"
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_ALPHA
-#undef RGB_PIXELSIZE
-#undef jsimd_h2v1_merged_upsample_neon
-#undef jsimd_h2v2_merged_upsample_neon
-
-#define RGB_RED EXT_XBGR_RED
-#define RGB_GREEN EXT_XBGR_GREEN
-#define RGB_BLUE EXT_XBGR_BLUE
-#define RGB_ALPHA 0
-#define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
-#define jsimd_h2v1_merged_upsample_neon jsimd_h2v1_extxbgr_merged_upsample_neon
-#define jsimd_h2v2_merged_upsample_neon jsimd_h2v2_extxbgr_merged_upsample_neon
-#include "jdmrgext-neon.c"
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_ALPHA
-#undef RGB_PIXELSIZE
-#undef jsimd_h2v1_merged_upsample_neon
-#undef jsimd_h2v2_merged_upsample_neon
-
-#define RGB_RED EXT_XRGB_RED
-#define RGB_GREEN EXT_XRGB_GREEN
-#define RGB_BLUE EXT_XRGB_BLUE
-#define RGB_ALPHA 0
-#define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
-#define jsimd_h2v1_merged_upsample_neon jsimd_h2v1_extxrgb_merged_upsample_neon
-#define jsimd_h2v2_merged_upsample_neon jsimd_h2v2_extxrgb_merged_upsample_neon
-#include "jdmrgext-neon.c"
-#undef RGB_RED
-#undef RGB_GREEN
-#undef RGB_BLUE
-#undef RGB_ALPHA
-#undef RGB_PIXELSIZE
-#undef jsimd_h2v1_merged_upsample_neon
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/jdmrgext-neon.c b/contrib/libs/libjpeg-turbo/simd/arm/jdmrgext-neon.c
deleted file mode 100644
index 5b89bdb339..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/arm/jdmrgext-neon.c
+++ /dev/null
@@ -1,723 +0,0 @@
-/*
- * jdmrgext-neon.c - merged upsampling/color conversion (Arm Neon)
- *
- * Copyright (C) 2020, Arm Limited. All Rights Reserved.
- * Copyright (C) 2020, D. R. Commander. All Rights Reserved.
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- * claim that you wrote the original software. If you use this software
- * in a product, an acknowledgment in the product documentation would be
- * appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must not be
- * misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source distribution.
- */
-
-/* This file is included by jdmerge-neon.c. */
-
-
-/* These routines combine simple (non-fancy, i.e. non-smooth) h2v1 or h2v2
- * chroma upsampling and YCbCr -> RGB color conversion into a single function.
- *
- * As with the standalone functions, YCbCr -> RGB conversion is defined by the
- * following equations:
- * R = Y + 1.40200 * (Cr - 128)
- * G = Y - 0.34414 * (Cb - 128) - 0.71414 * (Cr - 128)
- * B = Y + 1.77200 * (Cb - 128)
- *
- * Scaled integer constants are used to avoid floating-point arithmetic:
- * 0.3441467 = 11277 * 2^-15
- * 0.7141418 = 23401 * 2^-15
- * 1.4020386 = 22971 * 2^-14
- * 1.7720337 = 29033 * 2^-14
- * These constants are defined in jdmerge-neon.c.
- *
- * To ensure correct results, rounding is used when descaling.
- */
-
-/* Notes on safe memory access for merged upsampling/YCbCr -> RGB conversion
- * routines:
- *
- * Input memory buffers can be safely overread up to the next multiple of
- * ALIGN_SIZE bytes, since they are always allocated by alloc_sarray() in
- * jmemmgr.c.
- *
- * The output buffer cannot safely be written beyond output_width, since
- * output_buf points to a possibly unpadded row in the decompressed image
- * buffer allocated by the calling program.
- */
-
-/* Upsample and color convert for the case of 2:1 horizontal and 1:1 vertical.
- */
-
-void jsimd_h2v1_merged_upsample_neon(JDIMENSION output_width,
- JSAMPIMAGE input_buf,
- JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf)
-{
- JSAMPROW outptr;
- /* Pointers to Y, Cb, and Cr data */
- JSAMPROW inptr0, inptr1, inptr2;
-
- const int16x4_t consts = vld1_s16(jsimd_ycc_rgb_convert_neon_consts);
- const int16x8_t neg_128 = vdupq_n_s16(-128);
-
- inptr0 = input_buf[0][in_row_group_ctr];
- inptr1 = input_buf[1][in_row_group_ctr];
- inptr2 = input_buf[2][in_row_group_ctr];
- outptr = output_buf[0];
-
- int cols_remaining = output_width;
- for (; cols_remaining >= 16; cols_remaining -= 16) {
- /* De-interleave Y component values into two separate vectors, one
- * containing the component values with even-numbered indices and one
- * containing the component values with odd-numbered indices.
- */
- uint8x8x2_t y = vld2_u8(inptr0);
- uint8x8_t cb = vld1_u8(inptr1);
- uint8x8_t cr = vld1_u8(inptr2);
- /* Subtract 128 from Cb and Cr. */
- int16x8_t cr_128 =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(neg_128), cr));
- int16x8_t cb_128 =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(neg_128), cb));
- /* Compute G-Y: - 0.34414 * (Cb - 128) - 0.71414 * (Cr - 128) */
- int32x4_t g_sub_y_l = vmull_lane_s16(vget_low_s16(cb_128), consts, 0);
- int32x4_t g_sub_y_h = vmull_lane_s16(vget_high_s16(cb_128), consts, 0);
- g_sub_y_l = vmlsl_lane_s16(g_sub_y_l, vget_low_s16(cr_128), consts, 1);
- g_sub_y_h = vmlsl_lane_s16(g_sub_y_h, vget_high_s16(cr_128), consts, 1);
- /* Descale G components: shift right 15, round, and narrow to 16-bit. */
- int16x8_t g_sub_y = vcombine_s16(vrshrn_n_s32(g_sub_y_l, 15),
- vrshrn_n_s32(g_sub_y_h, 15));
- /* Compute R-Y: 1.40200 * (Cr - 128) */
- int16x8_t r_sub_y = vqrdmulhq_lane_s16(vshlq_n_s16(cr_128, 1), consts, 2);
- /* Compute B-Y: 1.77200 * (Cb - 128) */
- int16x8_t b_sub_y = vqrdmulhq_lane_s16(vshlq_n_s16(cb_128, 1), consts, 3);
- /* Add the chroma-derived values (G-Y, R-Y, and B-Y) to both the "even" and
- * "odd" Y component values. This effectively upsamples the chroma
- * components horizontally.
- */
- int16x8_t g_even =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(g_sub_y),
- y.val[0]));
- int16x8_t r_even =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(r_sub_y),
- y.val[0]));
- int16x8_t b_even =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(b_sub_y),
- y.val[0]));
- int16x8_t g_odd =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(g_sub_y),
- y.val[1]));
- int16x8_t r_odd =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(r_sub_y),
- y.val[1]));
- int16x8_t b_odd =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(b_sub_y),
- y.val[1]));
- /* Convert each component to unsigned and narrow, clamping to [0-255].
- * Re-interleave the "even" and "odd" component values.
- */
- uint8x8x2_t r = vzip_u8(vqmovun_s16(r_even), vqmovun_s16(r_odd));
- uint8x8x2_t g = vzip_u8(vqmovun_s16(g_even), vqmovun_s16(g_odd));
- uint8x8x2_t b = vzip_u8(vqmovun_s16(b_even), vqmovun_s16(b_odd));
-
-#ifdef RGB_ALPHA
- uint8x16x4_t rgba;
- rgba.val[RGB_RED] = vcombine_u8(r.val[0], r.val[1]);
- rgba.val[RGB_GREEN] = vcombine_u8(g.val[0], g.val[1]);
- rgba.val[RGB_BLUE] = vcombine_u8(b.val[0], b.val[1]);
- /* Set alpha channel to opaque (0xFF). */
- rgba.val[RGB_ALPHA] = vdupq_n_u8(0xFF);
- /* Store RGBA pixel data to memory. */
- vst4q_u8(outptr, rgba);
-#else
- uint8x16x3_t rgb;
- rgb.val[RGB_RED] = vcombine_u8(r.val[0], r.val[1]);
- rgb.val[RGB_GREEN] = vcombine_u8(g.val[0], g.val[1]);
- rgb.val[RGB_BLUE] = vcombine_u8(b.val[0], b.val[1]);
- /* Store RGB pixel data to memory. */
- vst3q_u8(outptr, rgb);
-#endif
-
- /* Increment pointers. */
- inptr0 += 16;
- inptr1 += 8;
- inptr2 += 8;
- outptr += (RGB_PIXELSIZE * 16);
- }
-
- if (cols_remaining > 0) {
- /* De-interleave Y component values into two separate vectors, one
- * containing the component values with even-numbered indices and one
- * containing the component values with odd-numbered indices.
- */
- uint8x8x2_t y = vld2_u8(inptr0);
- uint8x8_t cb = vld1_u8(inptr1);
- uint8x8_t cr = vld1_u8(inptr2);
- /* Subtract 128 from Cb and Cr. */
- int16x8_t cr_128 =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(neg_128), cr));
- int16x8_t cb_128 =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(neg_128), cb));
- /* Compute G-Y: - 0.34414 * (Cb - 128) - 0.71414 * (Cr - 128) */
- int32x4_t g_sub_y_l = vmull_lane_s16(vget_low_s16(cb_128), consts, 0);
- int32x4_t g_sub_y_h = vmull_lane_s16(vget_high_s16(cb_128), consts, 0);
- g_sub_y_l = vmlsl_lane_s16(g_sub_y_l, vget_low_s16(cr_128), consts, 1);
- g_sub_y_h = vmlsl_lane_s16(g_sub_y_h, vget_high_s16(cr_128), consts, 1);
- /* Descale G components: shift right 15, round, and narrow to 16-bit. */
- int16x8_t g_sub_y = vcombine_s16(vrshrn_n_s32(g_sub_y_l, 15),
- vrshrn_n_s32(g_sub_y_h, 15));
- /* Compute R-Y: 1.40200 * (Cr - 128) */
- int16x8_t r_sub_y = vqrdmulhq_lane_s16(vshlq_n_s16(cr_128, 1), consts, 2);
- /* Compute B-Y: 1.77200 * (Cb - 128) */
- int16x8_t b_sub_y = vqrdmulhq_lane_s16(vshlq_n_s16(cb_128, 1), consts, 3);
- /* Add the chroma-derived values (G-Y, R-Y, and B-Y) to both the "even" and
- * "odd" Y component values. This effectively upsamples the chroma
- * components horizontally.
- */
- int16x8_t g_even =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(g_sub_y),
- y.val[0]));
- int16x8_t r_even =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(r_sub_y),
- y.val[0]));
- int16x8_t b_even =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(b_sub_y),
- y.val[0]));
- int16x8_t g_odd =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(g_sub_y),
- y.val[1]));
- int16x8_t r_odd =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(r_sub_y),
- y.val[1]));
- int16x8_t b_odd =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(b_sub_y),
- y.val[1]));
- /* Convert each component to unsigned and narrow, clamping to [0-255].
- * Re-interleave the "even" and "odd" component values.
- */
- uint8x8x2_t r = vzip_u8(vqmovun_s16(r_even), vqmovun_s16(r_odd));
- uint8x8x2_t g = vzip_u8(vqmovun_s16(g_even), vqmovun_s16(g_odd));
- uint8x8x2_t b = vzip_u8(vqmovun_s16(b_even), vqmovun_s16(b_odd));
-
-#ifdef RGB_ALPHA
- uint8x8x4_t rgba_h;
- rgba_h.val[RGB_RED] = r.val[1];
- rgba_h.val[RGB_GREEN] = g.val[1];
- rgba_h.val[RGB_BLUE] = b.val[1];
- /* Set alpha channel to opaque (0xFF). */
- rgba_h.val[RGB_ALPHA] = vdup_n_u8(0xFF);
- uint8x8x4_t rgba_l;
- rgba_l.val[RGB_RED] = r.val[0];
- rgba_l.val[RGB_GREEN] = g.val[0];
- rgba_l.val[RGB_BLUE] = b.val[0];
- /* Set alpha channel to opaque (0xFF). */
- rgba_l.val[RGB_ALPHA] = vdup_n_u8(0xFF);
- /* Store RGBA pixel data to memory. */
- switch (cols_remaining) {
- case 15:
- vst4_lane_u8(outptr + 14 * RGB_PIXELSIZE, rgba_h, 6);
- FALLTHROUGH /*FALLTHROUGH*/
- case 14:
- vst4_lane_u8(outptr + 13 * RGB_PIXELSIZE, rgba_h, 5);
- FALLTHROUGH /*FALLTHROUGH*/
- case 13:
- vst4_lane_u8(outptr + 12 * RGB_PIXELSIZE, rgba_h, 4);
- FALLTHROUGH /*FALLTHROUGH*/
- case 12:
- vst4_lane_u8(outptr + 11 * RGB_PIXELSIZE, rgba_h, 3);
- FALLTHROUGH /*FALLTHROUGH*/
- case 11:
- vst4_lane_u8(outptr + 10 * RGB_PIXELSIZE, rgba_h, 2);
- FALLTHROUGH /*FALLTHROUGH*/
- case 10:
- vst4_lane_u8(outptr + 9 * RGB_PIXELSIZE, rgba_h, 1);
- FALLTHROUGH /*FALLTHROUGH*/
- case 9:
- vst4_lane_u8(outptr + 8 * RGB_PIXELSIZE, rgba_h, 0);
- FALLTHROUGH /*FALLTHROUGH*/
- case 8:
- vst4_u8(outptr, rgba_l);
- break;
- case 7:
- vst4_lane_u8(outptr + 6 * RGB_PIXELSIZE, rgba_l, 6);
- FALLTHROUGH /*FALLTHROUGH*/
- case 6:
- vst4_lane_u8(outptr + 5 * RGB_PIXELSIZE, rgba_l, 5);
- FALLTHROUGH /*FALLTHROUGH*/
- case 5:
- vst4_lane_u8(outptr + 4 * RGB_PIXELSIZE, rgba_l, 4);
- FALLTHROUGH /*FALLTHROUGH*/
- case 4:
- vst4_lane_u8(outptr + 3 * RGB_PIXELSIZE, rgba_l, 3);
- FALLTHROUGH /*FALLTHROUGH*/
- case 3:
- vst4_lane_u8(outptr + 2 * RGB_PIXELSIZE, rgba_l, 2);
- FALLTHROUGH /*FALLTHROUGH*/
- case 2:
- vst4_lane_u8(outptr + RGB_PIXELSIZE, rgba_l, 1);
- FALLTHROUGH /*FALLTHROUGH*/
- case 1:
- vst4_lane_u8(outptr, rgba_l, 0);
- FALLTHROUGH /*FALLTHROUGH*/
- default:
- break;
- }
-#else
- uint8x8x3_t rgb_h;
- rgb_h.val[RGB_RED] = r.val[1];
- rgb_h.val[RGB_GREEN] = g.val[1];
- rgb_h.val[RGB_BLUE] = b.val[1];
- uint8x8x3_t rgb_l;
- rgb_l.val[RGB_RED] = r.val[0];
- rgb_l.val[RGB_GREEN] = g.val[0];
- rgb_l.val[RGB_BLUE] = b.val[0];
- /* Store RGB pixel data to memory. */
- switch (cols_remaining) {
- case 15:
- vst3_lane_u8(outptr + 14 * RGB_PIXELSIZE, rgb_h, 6);
- FALLTHROUGH /*FALLTHROUGH*/
- case 14:
- vst3_lane_u8(outptr + 13 * RGB_PIXELSIZE, rgb_h, 5);
- FALLTHROUGH /*FALLTHROUGH*/
- case 13:
- vst3_lane_u8(outptr + 12 * RGB_PIXELSIZE, rgb_h, 4);
- FALLTHROUGH /*FALLTHROUGH*/
- case 12:
- vst3_lane_u8(outptr + 11 * RGB_PIXELSIZE, rgb_h, 3);
- FALLTHROUGH /*FALLTHROUGH*/
- case 11:
- vst3_lane_u8(outptr + 10 * RGB_PIXELSIZE, rgb_h, 2);
- FALLTHROUGH /*FALLTHROUGH*/
- case 10:
- vst3_lane_u8(outptr + 9 * RGB_PIXELSIZE, rgb_h, 1);
- FALLTHROUGH /*FALLTHROUGH*/
- case 9:
- vst3_lane_u8(outptr + 8 * RGB_PIXELSIZE, rgb_h, 0);
- FALLTHROUGH /*FALLTHROUGH*/
- case 8:
- vst3_u8(outptr, rgb_l);
- break;
- case 7:
- vst3_lane_u8(outptr + 6 * RGB_PIXELSIZE, rgb_l, 6);
- FALLTHROUGH /*FALLTHROUGH*/
- case 6:
- vst3_lane_u8(outptr + 5 * RGB_PIXELSIZE, rgb_l, 5);
- FALLTHROUGH /*FALLTHROUGH*/
- case 5:
- vst3_lane_u8(outptr + 4 * RGB_PIXELSIZE, rgb_l, 4);
- FALLTHROUGH /*FALLTHROUGH*/
- case 4:
- vst3_lane_u8(outptr + 3 * RGB_PIXELSIZE, rgb_l, 3);
- FALLTHROUGH /*FALLTHROUGH*/
- case 3:
- vst3_lane_u8(outptr + 2 * RGB_PIXELSIZE, rgb_l, 2);
- FALLTHROUGH /*FALLTHROUGH*/
- case 2:
- vst3_lane_u8(outptr + RGB_PIXELSIZE, rgb_l, 1);
- FALLTHROUGH /*FALLTHROUGH*/
- case 1:
- vst3_lane_u8(outptr, rgb_l, 0);
- FALLTHROUGH /*FALLTHROUGH*/
- default:
- break;
- }
-#endif
- }
-}
-
-
-/* Upsample and color convert for the case of 2:1 horizontal and 2:1 vertical.
- *
- * See comments above for details regarding color conversion and safe memory
- * access.
- */
-
-void jsimd_h2v2_merged_upsample_neon(JDIMENSION output_width,
- JSAMPIMAGE input_buf,
- JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf)
-{
- JSAMPROW outptr0, outptr1;
- /* Pointers to Y (both rows), Cb, and Cr data */
- JSAMPROW inptr0_0, inptr0_1, inptr1, inptr2;
-
- const int16x4_t consts = vld1_s16(jsimd_ycc_rgb_convert_neon_consts);
- const int16x8_t neg_128 = vdupq_n_s16(-128);
-
- inptr0_0 = input_buf[0][in_row_group_ctr * 2];
- inptr0_1 = input_buf[0][in_row_group_ctr * 2 + 1];
- inptr1 = input_buf[1][in_row_group_ctr];
- inptr2 = input_buf[2][in_row_group_ctr];
- outptr0 = output_buf[0];
- outptr1 = output_buf[1];
-
- int cols_remaining = output_width;
- for (; cols_remaining >= 16; cols_remaining -= 16) {
- /* For each row, de-interleave Y component values into two separate
- * vectors, one containing the component values with even-numbered indices
- * and one containing the component values with odd-numbered indices.
- */
- uint8x8x2_t y0 = vld2_u8(inptr0_0);
- uint8x8x2_t y1 = vld2_u8(inptr0_1);
- uint8x8_t cb = vld1_u8(inptr1);
- uint8x8_t cr = vld1_u8(inptr2);
- /* Subtract 128 from Cb and Cr. */
- int16x8_t cr_128 =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(neg_128), cr));
- int16x8_t cb_128 =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(neg_128), cb));
- /* Compute G-Y: - 0.34414 * (Cb - 128) - 0.71414 * (Cr - 128) */
- int32x4_t g_sub_y_l = vmull_lane_s16(vget_low_s16(cb_128), consts, 0);
- int32x4_t g_sub_y_h = vmull_lane_s16(vget_high_s16(cb_128), consts, 0);
- g_sub_y_l = vmlsl_lane_s16(g_sub_y_l, vget_low_s16(cr_128), consts, 1);
- g_sub_y_h = vmlsl_lane_s16(g_sub_y_h, vget_high_s16(cr_128), consts, 1);
- /* Descale G components: shift right 15, round, and narrow to 16-bit. */
- int16x8_t g_sub_y = vcombine_s16(vrshrn_n_s32(g_sub_y_l, 15),
- vrshrn_n_s32(g_sub_y_h, 15));
- /* Compute R-Y: 1.40200 * (Cr - 128) */
- int16x8_t r_sub_y = vqrdmulhq_lane_s16(vshlq_n_s16(cr_128, 1), consts, 2);
- /* Compute B-Y: 1.77200 * (Cb - 128) */
- int16x8_t b_sub_y = vqrdmulhq_lane_s16(vshlq_n_s16(cb_128, 1), consts, 3);
- /* For each row, add the chroma-derived values (G-Y, R-Y, and B-Y) to both
- * the "even" and "odd" Y component values. This effectively upsamples the
- * chroma components both horizontally and vertically.
- */
- int16x8_t g0_even =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(g_sub_y),
- y0.val[0]));
- int16x8_t r0_even =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(r_sub_y),
- y0.val[0]));
- int16x8_t b0_even =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(b_sub_y),
- y0.val[0]));
- int16x8_t g0_odd =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(g_sub_y),
- y0.val[1]));
- int16x8_t r0_odd =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(r_sub_y),
- y0.val[1]));
- int16x8_t b0_odd =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(b_sub_y),
- y0.val[1]));
- int16x8_t g1_even =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(g_sub_y),
- y1.val[0]));
- int16x8_t r1_even =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(r_sub_y),
- y1.val[0]));
- int16x8_t b1_even =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(b_sub_y),
- y1.val[0]));
- int16x8_t g1_odd =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(g_sub_y),
- y1.val[1]));
- int16x8_t r1_odd =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(r_sub_y),
- y1.val[1]));
- int16x8_t b1_odd =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(b_sub_y),
- y1.val[1]));
- /* Convert each component to unsigned and narrow, clamping to [0-255].
- * Re-interleave the "even" and "odd" component values.
- */
- uint8x8x2_t r0 = vzip_u8(vqmovun_s16(r0_even), vqmovun_s16(r0_odd));
- uint8x8x2_t r1 = vzip_u8(vqmovun_s16(r1_even), vqmovun_s16(r1_odd));
- uint8x8x2_t g0 = vzip_u8(vqmovun_s16(g0_even), vqmovun_s16(g0_odd));
- uint8x8x2_t g1 = vzip_u8(vqmovun_s16(g1_even), vqmovun_s16(g1_odd));
- uint8x8x2_t b0 = vzip_u8(vqmovun_s16(b0_even), vqmovun_s16(b0_odd));
- uint8x8x2_t b1 = vzip_u8(vqmovun_s16(b1_even), vqmovun_s16(b1_odd));
-
-#ifdef RGB_ALPHA
- uint8x16x4_t rgba0, rgba1;
- rgba0.val[RGB_RED] = vcombine_u8(r0.val[0], r0.val[1]);
- rgba1.val[RGB_RED] = vcombine_u8(r1.val[0], r1.val[1]);
- rgba0.val[RGB_GREEN] = vcombine_u8(g0.val[0], g0.val[1]);
- rgba1.val[RGB_GREEN] = vcombine_u8(g1.val[0], g1.val[1]);
- rgba0.val[RGB_BLUE] = vcombine_u8(b0.val[0], b0.val[1]);
- rgba1.val[RGB_BLUE] = vcombine_u8(b1.val[0], b1.val[1]);
- /* Set alpha channel to opaque (0xFF). */
- rgba0.val[RGB_ALPHA] = vdupq_n_u8(0xFF);
- rgba1.val[RGB_ALPHA] = vdupq_n_u8(0xFF);
- /* Store RGBA pixel data to memory. */
- vst4q_u8(outptr0, rgba0);
- vst4q_u8(outptr1, rgba1);
-#else
- uint8x16x3_t rgb0, rgb1;
- rgb0.val[RGB_RED] = vcombine_u8(r0.val[0], r0.val[1]);
- rgb1.val[RGB_RED] = vcombine_u8(r1.val[0], r1.val[1]);
- rgb0.val[RGB_GREEN] = vcombine_u8(g0.val[0], g0.val[1]);
- rgb1.val[RGB_GREEN] = vcombine_u8(g1.val[0], g1.val[1]);
- rgb0.val[RGB_BLUE] = vcombine_u8(b0.val[0], b0.val[1]);
- rgb1.val[RGB_BLUE] = vcombine_u8(b1.val[0], b1.val[1]);
- /* Store RGB pixel data to memory. */
- vst3q_u8(outptr0, rgb0);
- vst3q_u8(outptr1, rgb1);
-#endif
-
- /* Increment pointers. */
- inptr0_0 += 16;
- inptr0_1 += 16;
- inptr1 += 8;
- inptr2 += 8;
- outptr0 += (RGB_PIXELSIZE * 16);
- outptr1 += (RGB_PIXELSIZE * 16);
- }
-
- if (cols_remaining > 0) {
- /* For each row, de-interleave Y component values into two separate
- * vectors, one containing the component values with even-numbered indices
- * and one containing the component values with odd-numbered indices.
- */
- uint8x8x2_t y0 = vld2_u8(inptr0_0);
- uint8x8x2_t y1 = vld2_u8(inptr0_1);
- uint8x8_t cb = vld1_u8(inptr1);
- uint8x8_t cr = vld1_u8(inptr2);
- /* Subtract 128 from Cb and Cr. */
- int16x8_t cr_128 =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(neg_128), cr));
- int16x8_t cb_128 =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(neg_128), cb));
- /* Compute G-Y: - 0.34414 * (Cb - 128) - 0.71414 * (Cr - 128) */
- int32x4_t g_sub_y_l = vmull_lane_s16(vget_low_s16(cb_128), consts, 0);
- int32x4_t g_sub_y_h = vmull_lane_s16(vget_high_s16(cb_128), consts, 0);
- g_sub_y_l = vmlsl_lane_s16(g_sub_y_l, vget_low_s16(cr_128), consts, 1);
- g_sub_y_h = vmlsl_lane_s16(g_sub_y_h, vget_high_s16(cr_128), consts, 1);
- /* Descale G components: shift right 15, round, and narrow to 16-bit. */
- int16x8_t g_sub_y = vcombine_s16(vrshrn_n_s32(g_sub_y_l, 15),
- vrshrn_n_s32(g_sub_y_h, 15));
- /* Compute R-Y: 1.40200 * (Cr - 128) */
- int16x8_t r_sub_y = vqrdmulhq_lane_s16(vshlq_n_s16(cr_128, 1), consts, 2);
- /* Compute B-Y: 1.77200 * (Cb - 128) */
- int16x8_t b_sub_y = vqrdmulhq_lane_s16(vshlq_n_s16(cb_128, 1), consts, 3);
- /* For each row, add the chroma-derived values (G-Y, R-Y, and B-Y) to both
- * the "even" and "odd" Y component values. This effectively upsamples the
- * chroma components both horizontally and vertically.
- */
- int16x8_t g0_even =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(g_sub_y),
- y0.val[0]));
- int16x8_t r0_even =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(r_sub_y),
- y0.val[0]));
- int16x8_t b0_even =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(b_sub_y),
- y0.val[0]));
- int16x8_t g0_odd =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(g_sub_y),
- y0.val[1]));
- int16x8_t r0_odd =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(r_sub_y),
- y0.val[1]));
- int16x8_t b0_odd =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(b_sub_y),
- y0.val[1]));
- int16x8_t g1_even =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(g_sub_y),
- y1.val[0]));
- int16x8_t r1_even =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(r_sub_y),
- y1.val[0]));
- int16x8_t b1_even =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(b_sub_y),
- y1.val[0]));
- int16x8_t g1_odd =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(g_sub_y),
- y1.val[1]));
- int16x8_t r1_odd =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(r_sub_y),
- y1.val[1]));
- int16x8_t b1_odd =
- vreinterpretq_s16_u16(vaddw_u8(vreinterpretq_u16_s16(b_sub_y),
- y1.val[1]));
- /* Convert each component to unsigned and narrow, clamping to [0-255].
- * Re-interleave the "even" and "odd" component values.
- */
- uint8x8x2_t r0 = vzip_u8(vqmovun_s16(r0_even), vqmovun_s16(r0_odd));
- uint8x8x2_t r1 = vzip_u8(vqmovun_s16(r1_even), vqmovun_s16(r1_odd));
- uint8x8x2_t g0 = vzip_u8(vqmovun_s16(g0_even), vqmovun_s16(g0_odd));
- uint8x8x2_t g1 = vzip_u8(vqmovun_s16(g1_even), vqmovun_s16(g1_odd));
- uint8x8x2_t b0 = vzip_u8(vqmovun_s16(b0_even), vqmovun_s16(b0_odd));
- uint8x8x2_t b1 = vzip_u8(vqmovun_s16(b1_even), vqmovun_s16(b1_odd));
-
-#ifdef RGB_ALPHA
- uint8x8x4_t rgba0_h, rgba1_h;
- rgba0_h.val[RGB_RED] = r0.val[1];
- rgba1_h.val[RGB_RED] = r1.val[1];
- rgba0_h.val[RGB_GREEN] = g0.val[1];
- rgba1_h.val[RGB_GREEN] = g1.val[1];
- rgba0_h.val[RGB_BLUE] = b0.val[1];
- rgba1_h.val[RGB_BLUE] = b1.val[1];
- /* Set alpha channel to opaque (0xFF). */
- rgba0_h.val[RGB_ALPHA] = vdup_n_u8(0xFF);
- rgba1_h.val[RGB_ALPHA] = vdup_n_u8(0xFF);
-
- uint8x8x4_t rgba0_l, rgba1_l;
- rgba0_l.val[RGB_RED] = r0.val[0];
- rgba1_l.val[RGB_RED] = r1.val[0];
- rgba0_l.val[RGB_GREEN] = g0.val[0];
- rgba1_l.val[RGB_GREEN] = g1.val[0];
- rgba0_l.val[RGB_BLUE] = b0.val[0];
- rgba1_l.val[RGB_BLUE] = b1.val[0];
- /* Set alpha channel to opaque (0xFF). */
- rgba0_l.val[RGB_ALPHA] = vdup_n_u8(0xFF);
- rgba1_l.val[RGB_ALPHA] = vdup_n_u8(0xFF);
- /* Store RGBA pixel data to memory. */
- switch (cols_remaining) {
- case 15:
- vst4_lane_u8(outptr0 + 14 * RGB_PIXELSIZE, rgba0_h, 6);
- vst4_lane_u8(outptr1 + 14 * RGB_PIXELSIZE, rgba1_h, 6);
- FALLTHROUGH /*FALLTHROUGH*/
- case 14:
- vst4_lane_u8(outptr0 + 13 * RGB_PIXELSIZE, rgba0_h, 5);
- vst4_lane_u8(outptr1 + 13 * RGB_PIXELSIZE, rgba1_h, 5);
- FALLTHROUGH /*FALLTHROUGH*/
- case 13:
- vst4_lane_u8(outptr0 + 12 * RGB_PIXELSIZE, rgba0_h, 4);
- vst4_lane_u8(outptr1 + 12 * RGB_PIXELSIZE, rgba1_h, 4);
- FALLTHROUGH /*FALLTHROUGH*/
- case 12:
- vst4_lane_u8(outptr0 + 11 * RGB_PIXELSIZE, rgba0_h, 3);
- vst4_lane_u8(outptr1 + 11 * RGB_PIXELSIZE, rgba1_h, 3);
- FALLTHROUGH /*FALLTHROUGH*/
- case 11:
- vst4_lane_u8(outptr0 + 10 * RGB_PIXELSIZE, rgba0_h, 2);
- vst4_lane_u8(outptr1 + 10 * RGB_PIXELSIZE, rgba1_h, 2);
- FALLTHROUGH /*FALLTHROUGH*/
- case 10:
- vst4_lane_u8(outptr0 + 9 * RGB_PIXELSIZE, rgba0_h, 1);
- vst4_lane_u8(outptr1 + 9 * RGB_PIXELSIZE, rgba1_h, 1);
- FALLTHROUGH /*FALLTHROUGH*/
- case 9:
- vst4_lane_u8(outptr0 + 8 * RGB_PIXELSIZE, rgba0_h, 0);
- vst4_lane_u8(outptr1 + 8 * RGB_PIXELSIZE, rgba1_h, 0);
- FALLTHROUGH /*FALLTHROUGH*/
- case 8:
- vst4_u8(outptr0, rgba0_l);
- vst4_u8(outptr1, rgba1_l);
- break;
- case 7:
- vst4_lane_u8(outptr0 + 6 * RGB_PIXELSIZE, rgba0_l, 6);
- vst4_lane_u8(outptr1 + 6 * RGB_PIXELSIZE, rgba1_l, 6);
- FALLTHROUGH /*FALLTHROUGH*/
- case 6:
- vst4_lane_u8(outptr0 + 5 * RGB_PIXELSIZE, rgba0_l, 5);
- vst4_lane_u8(outptr1 + 5 * RGB_PIXELSIZE, rgba1_l, 5);
- FALLTHROUGH /*FALLTHROUGH*/
- case 5:
- vst4_lane_u8(outptr0 + 4 * RGB_PIXELSIZE, rgba0_l, 4);
- vst4_lane_u8(outptr1 + 4 * RGB_PIXELSIZE, rgba1_l, 4);
- FALLTHROUGH /*FALLTHROUGH*/
- case 4:
- vst4_lane_u8(outptr0 + 3 * RGB_PIXELSIZE, rgba0_l, 3);
- vst4_lane_u8(outptr1 + 3 * RGB_PIXELSIZE, rgba1_l, 3);
- FALLTHROUGH /*FALLTHROUGH*/
- case 3:
- vst4_lane_u8(outptr0 + 2 * RGB_PIXELSIZE, rgba0_l, 2);
- vst4_lane_u8(outptr1 + 2 * RGB_PIXELSIZE, rgba1_l, 2);
- FALLTHROUGH /*FALLTHROUGH*/
- case 2:
- vst4_lane_u8(outptr0 + 1 * RGB_PIXELSIZE, rgba0_l, 1);
- vst4_lane_u8(outptr1 + 1 * RGB_PIXELSIZE, rgba1_l, 1);
- FALLTHROUGH /*FALLTHROUGH*/
- case 1:
- vst4_lane_u8(outptr0, rgba0_l, 0);
- vst4_lane_u8(outptr1, rgba1_l, 0);
- FALLTHROUGH /*FALLTHROUGH*/
- default:
- break;
- }
-#else
- uint8x8x3_t rgb0_h, rgb1_h;
- rgb0_h.val[RGB_RED] = r0.val[1];
- rgb1_h.val[RGB_RED] = r1.val[1];
- rgb0_h.val[RGB_GREEN] = g0.val[1];
- rgb1_h.val[RGB_GREEN] = g1.val[1];
- rgb0_h.val[RGB_BLUE] = b0.val[1];
- rgb1_h.val[RGB_BLUE] = b1.val[1];
-
- uint8x8x3_t rgb0_l, rgb1_l;
- rgb0_l.val[RGB_RED] = r0.val[0];
- rgb1_l.val[RGB_RED] = r1.val[0];
- rgb0_l.val[RGB_GREEN] = g0.val[0];
- rgb1_l.val[RGB_GREEN] = g1.val[0];
- rgb0_l.val[RGB_BLUE] = b0.val[0];
- rgb1_l.val[RGB_BLUE] = b1.val[0];
- /* Store RGB pixel data to memory. */
- switch (cols_remaining) {
- case 15:
- vst3_lane_u8(outptr0 + 14 * RGB_PIXELSIZE, rgb0_h, 6);
- vst3_lane_u8(outptr1 + 14 * RGB_PIXELSIZE, rgb1_h, 6);
- FALLTHROUGH /*FALLTHROUGH*/
- case 14:
- vst3_lane_u8(outptr0 + 13 * RGB_PIXELSIZE, rgb0_h, 5);
- vst3_lane_u8(outptr1 + 13 * RGB_PIXELSIZE, rgb1_h, 5);
- FALLTHROUGH /*FALLTHROUGH*/
- case 13:
- vst3_lane_u8(outptr0 + 12 * RGB_PIXELSIZE, rgb0_h, 4);
- vst3_lane_u8(outptr1 + 12 * RGB_PIXELSIZE, rgb1_h, 4);
- FALLTHROUGH /*FALLTHROUGH*/
- case 12:
- vst3_lane_u8(outptr0 + 11 * RGB_PIXELSIZE, rgb0_h, 3);
- vst3_lane_u8(outptr1 + 11 * RGB_PIXELSIZE, rgb1_h, 3);
- FALLTHROUGH /*FALLTHROUGH*/
- case 11:
- vst3_lane_u8(outptr0 + 10 * RGB_PIXELSIZE, rgb0_h, 2);
- vst3_lane_u8(outptr1 + 10 * RGB_PIXELSIZE, rgb1_h, 2);
- FALLTHROUGH /*FALLTHROUGH*/
- case 10:
- vst3_lane_u8(outptr0 + 9 * RGB_PIXELSIZE, rgb0_h, 1);
- vst3_lane_u8(outptr1 + 9 * RGB_PIXELSIZE, rgb1_h, 1);
- FALLTHROUGH /*FALLTHROUGH*/
- case 9:
- vst3_lane_u8(outptr0 + 8 * RGB_PIXELSIZE, rgb0_h, 0);
- vst3_lane_u8(outptr1 + 8 * RGB_PIXELSIZE, rgb1_h, 0);
- FALLTHROUGH /*FALLTHROUGH*/
- case 8:
- vst3_u8(outptr0, rgb0_l);
- vst3_u8(outptr1, rgb1_l);
- break;
- case 7:
- vst3_lane_u8(outptr0 + 6 * RGB_PIXELSIZE, rgb0_l, 6);
- vst3_lane_u8(outptr1 + 6 * RGB_PIXELSIZE, rgb1_l, 6);
- FALLTHROUGH /*FALLTHROUGH*/
- case 6:
- vst3_lane_u8(outptr0 + 5 * RGB_PIXELSIZE, rgb0_l, 5);
- vst3_lane_u8(outptr1 + 5 * RGB_PIXELSIZE, rgb1_l, 5);
- FALLTHROUGH /*FALLTHROUGH*/
- case 5:
- vst3_lane_u8(outptr0 + 4 * RGB_PIXELSIZE, rgb0_l, 4);
- vst3_lane_u8(outptr1 + 4 * RGB_PIXELSIZE, rgb1_l, 4);
- FALLTHROUGH /*FALLTHROUGH*/
- case 4:
- vst3_lane_u8(outptr0 + 3 * RGB_PIXELSIZE, rgb0_l, 3);
- vst3_lane_u8(outptr1 + 3 * RGB_PIXELSIZE, rgb1_l, 3);
- FALLTHROUGH /*FALLTHROUGH*/
- case 3:
- vst3_lane_u8(outptr0 + 2 * RGB_PIXELSIZE, rgb0_l, 2);
- vst3_lane_u8(outptr1 + 2 * RGB_PIXELSIZE, rgb1_l, 2);
- FALLTHROUGH /*FALLTHROUGH*/
- case 2:
- vst3_lane_u8(outptr0 + 1 * RGB_PIXELSIZE, rgb0_l, 1);
- vst3_lane_u8(outptr1 + 1 * RGB_PIXELSIZE, rgb1_l, 1);
- FALLTHROUGH /*FALLTHROUGH*/
- case 1:
- vst3_lane_u8(outptr0, rgb0_l, 0);
- vst3_lane_u8(outptr1, rgb1_l, 0);
- FALLTHROUGH /*FALLTHROUGH*/
- default:
- break;
- }
-#endif
- }
-}
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/jdsample-neon.c b/contrib/libs/libjpeg-turbo/simd/arm/jdsample-neon.c
deleted file mode 100644
index 90ec6782c4..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/arm/jdsample-neon.c
+++ /dev/null
@@ -1,569 +0,0 @@
-/*
- * jdsample-neon.c - upsampling (Arm Neon)
- *
- * Copyright (C) 2020, Arm Limited. All Rights Reserved.
- * Copyright (C) 2020, D. R. Commander. All Rights Reserved.
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- * claim that you wrote the original software. If you use this software
- * in a product, an acknowledgment in the product documentation would be
- * appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must not be
- * misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source distribution.
- */
-
-#define JPEG_INTERNALS
-#include "../../jinclude.h"
-#include "../../jpeglib.h"
-#include "../../jsimd.h"
-#include "../../jdct.h"
-#include "../../jsimddct.h"
-#include "../jsimd.h"
-
-#include <arm_neon.h>
-
-
-/* The diagram below shows a row of samples produced by h2v1 downsampling.
- *
- * s0 s1 s2
- * +---------+---------+---------+
- * | | | |
- * | p0 p1 | p2 p3 | p4 p5 |
- * | | | |
- * +---------+---------+---------+
- *
- * Samples s0-s2 were created by averaging the original pixel component values
- * centered at positions p0-p5 above. To approximate those original pixel
- * component values, we proportionally blend the adjacent samples in each row.
- *
- * An upsampled pixel component value is computed by blending the sample
- * containing the pixel center with the nearest neighboring sample, in the
- * ratio 3:1. For example:
- * p1(upsampled) = 3/4 * s0 + 1/4 * s1
- * p2(upsampled) = 3/4 * s1 + 1/4 * s0
- * When computing the first and last pixel component values in the row, there
- * is no adjacent sample to blend, so:
- * p0(upsampled) = s0
- * p5(upsampled) = s2
- */
-
-void jsimd_h2v1_fancy_upsample_neon(int max_v_samp_factor,
- JDIMENSION downsampled_width,
- JSAMPARRAY input_data,
- JSAMPARRAY *output_data_ptr)
-{
- JSAMPARRAY output_data = *output_data_ptr;
- JSAMPROW inptr, outptr;
- int inrow;
- unsigned colctr;
- /* Set up constants. */
- const uint16x8_t one_u16 = vdupq_n_u16(1);
- const uint8x8_t three_u8 = vdup_n_u8(3);
-
- for (inrow = 0; inrow < max_v_samp_factor; inrow++) {
- inptr = input_data[inrow];
- outptr = output_data[inrow];
- /* First pixel component value in this row of the original image */
- *outptr = (JSAMPLE)GETJSAMPLE(*inptr);
-
- /* 3/4 * containing sample + 1/4 * nearest neighboring sample
- * For p1: containing sample = s0, nearest neighboring sample = s1
- * For p2: containing sample = s1, nearest neighboring sample = s0
- */
- uint8x16_t s0 = vld1q_u8(inptr);
- uint8x16_t s1 = vld1q_u8(inptr + 1);
- /* Multiplication makes vectors twice as wide. '_l' and '_h' suffixes
- * denote low half and high half respectively.
- */
- uint16x8_t s1_add_3s0_l =
- vmlal_u8(vmovl_u8(vget_low_u8(s1)), vget_low_u8(s0), three_u8);
- uint16x8_t s1_add_3s0_h =
- vmlal_u8(vmovl_u8(vget_high_u8(s1)), vget_high_u8(s0), three_u8);
- uint16x8_t s0_add_3s1_l =
- vmlal_u8(vmovl_u8(vget_low_u8(s0)), vget_low_u8(s1), three_u8);
- uint16x8_t s0_add_3s1_h =
- vmlal_u8(vmovl_u8(vget_high_u8(s0)), vget_high_u8(s1), three_u8);
- /* Add ordered dithering bias to odd pixel values. */
- s0_add_3s1_l = vaddq_u16(s0_add_3s1_l, one_u16);
- s0_add_3s1_h = vaddq_u16(s0_add_3s1_h, one_u16);
-
- /* The offset is initially 1, because the first pixel component has already
- * been stored. However, in subsequent iterations of the SIMD loop, this
- * offset is (2 * colctr - 1) to stay within the bounds of the sample
- * buffers without having to resort to a slow scalar tail case for the last
- * (downsampled_width % 16) samples. See "Creation of 2-D sample arrays"
- * in jmemmgr.c for more details.
- */
- unsigned outptr_offset = 1;
- uint8x16x2_t output_pixels;
-
- /* We use software pipelining to maximise performance. The code indented
- * an extra two spaces begins the next iteration of the loop.
- */
- for (colctr = 16; colctr < downsampled_width; colctr += 16) {
-
- s0 = vld1q_u8(inptr + colctr - 1);
- s1 = vld1q_u8(inptr + colctr);
-
- /* Right-shift by 2 (divide by 4), narrow to 8-bit, and combine. */
- output_pixels.val[0] = vcombine_u8(vrshrn_n_u16(s1_add_3s0_l, 2),
- vrshrn_n_u16(s1_add_3s0_h, 2));
- output_pixels.val[1] = vcombine_u8(vshrn_n_u16(s0_add_3s1_l, 2),
- vshrn_n_u16(s0_add_3s1_h, 2));
-
- /* Multiplication makes vectors twice as wide. '_l' and '_h' suffixes
- * denote low half and high half respectively.
- */
- s1_add_3s0_l =
- vmlal_u8(vmovl_u8(vget_low_u8(s1)), vget_low_u8(s0), three_u8);
- s1_add_3s0_h =
- vmlal_u8(vmovl_u8(vget_high_u8(s1)), vget_high_u8(s0), three_u8);
- s0_add_3s1_l =
- vmlal_u8(vmovl_u8(vget_low_u8(s0)), vget_low_u8(s1), three_u8);
- s0_add_3s1_h =
- vmlal_u8(vmovl_u8(vget_high_u8(s0)), vget_high_u8(s1), three_u8);
- /* Add ordered dithering bias to odd pixel values. */
- s0_add_3s1_l = vaddq_u16(s0_add_3s1_l, one_u16);
- s0_add_3s1_h = vaddq_u16(s0_add_3s1_h, one_u16);
-
- /* Store pixel component values to memory. */
- vst2q_u8(outptr + outptr_offset, output_pixels);
- outptr_offset = 2 * colctr - 1;
- }
-
- /* Complete the last iteration of the loop. */
-
- /* Right-shift by 2 (divide by 4), narrow to 8-bit, and combine. */
- output_pixels.val[0] = vcombine_u8(vrshrn_n_u16(s1_add_3s0_l, 2),
- vrshrn_n_u16(s1_add_3s0_h, 2));
- output_pixels.val[1] = vcombine_u8(vshrn_n_u16(s0_add_3s1_l, 2),
- vshrn_n_u16(s0_add_3s1_h, 2));
- /* Store pixel component values to memory. */
- vst2q_u8(outptr + outptr_offset, output_pixels);
-
- /* Last pixel component value in this row of the original image */
- outptr[2 * downsampled_width - 1] =
- GETJSAMPLE(inptr[downsampled_width - 1]);
- }
-}
-
-
-/* The diagram below shows an array of samples produced by h2v2 downsampling.
- *
- * s0 s1 s2
- * +---------+---------+---------+
- * | p0 p1 | p2 p3 | p4 p5 |
- * sA | | | |
- * | p6 p7 | p8 p9 | p10 p11|
- * +---------+---------+---------+
- * | p12 p13| p14 p15| p16 p17|
- * sB | | | |
- * | p18 p19| p20 p21| p22 p23|
- * +---------+---------+---------+
- * | p24 p25| p26 p27| p28 p29|
- * sC | | | |
- * | p30 p31| p32 p33| p34 p35|
- * +---------+---------+---------+
- *
- * Samples s0A-s2C were created by averaging the original pixel component
- * values centered at positions p0-p35 above. To approximate one of those
- * original pixel component values, we proportionally blend the sample
- * containing the pixel center with the nearest neighboring samples in each
- * row, column, and diagonal.
- *
- * An upsampled pixel component value is computed by first blending the sample
- * containing the pixel center with the nearest neighboring samples in the
- * same column, in the ratio 3:1, and then blending each column sum with the
- * nearest neighboring column sum, in the ratio 3:1. For example:
- * p14(upsampled) = 3/4 * (3/4 * s1B + 1/4 * s1A) +
- * 1/4 * (3/4 * s0B + 1/4 * s0A)
- * = 9/16 * s1B + 3/16 * s1A + 3/16 * s0B + 1/16 * s0A
- * When computing the first and last pixel component values in the row, there
- * is no horizontally adjacent sample to blend, so:
- * p12(upsampled) = 3/4 * s0B + 1/4 * s0A
- * p23(upsampled) = 3/4 * s2B + 1/4 * s2C
- * When computing the first and last pixel component values in the column,
- * there is no vertically adjacent sample to blend, so:
- * p2(upsampled) = 3/4 * s1A + 1/4 * s0A
- * p33(upsampled) = 3/4 * s1C + 1/4 * s2C
- * When computing the corner pixel component values, there is no adjacent
- * sample to blend, so:
- * p0(upsampled) = s0A
- * p35(upsampled) = s2C
- */
-
-void jsimd_h2v2_fancy_upsample_neon(int max_v_samp_factor,
- JDIMENSION downsampled_width,
- JSAMPARRAY input_data,
- JSAMPARRAY *output_data_ptr)
-{
- JSAMPARRAY output_data = *output_data_ptr;
- JSAMPROW inptr0, inptr1, inptr2, outptr0, outptr1;
- int inrow, outrow;
- unsigned colctr;
- /* Set up constants. */
- const uint16x8_t seven_u16 = vdupq_n_u16(7);
- const uint8x8_t three_u8 = vdup_n_u8(3);
- const uint16x8_t three_u16 = vdupq_n_u16(3);
-
- inrow = outrow = 0;
- while (outrow < max_v_samp_factor) {
- inptr0 = input_data[inrow - 1];
- inptr1 = input_data[inrow];
- inptr2 = input_data[inrow + 1];
- /* Suffixes 0 and 1 denote the upper and lower rows of output pixels,
- * respectively.
- */
- outptr0 = output_data[outrow++];
- outptr1 = output_data[outrow++];
-
- /* First pixel component value in this row of the original image */
- int s0colsum0 = GETJSAMPLE(*inptr1) * 3 + GETJSAMPLE(*inptr0);
- *outptr0 = (JSAMPLE)((s0colsum0 * 4 + 8) >> 4);
- int s0colsum1 = GETJSAMPLE(*inptr1) * 3 + GETJSAMPLE(*inptr2);
- *outptr1 = (JSAMPLE)((s0colsum1 * 4 + 8) >> 4);
-
- /* Step 1: Blend samples vertically in columns s0 and s1.
- * Leave the divide by 4 until the end, when it can be done for both
- * dimensions at once, right-shifting by 4.
- */
-
- /* Load and compute s0colsum0 and s0colsum1. */
- uint8x16_t s0A = vld1q_u8(inptr0);
- uint8x16_t s0B = vld1q_u8(inptr1);
- uint8x16_t s0C = vld1q_u8(inptr2);
- /* Multiplication makes vectors twice as wide. '_l' and '_h' suffixes
- * denote low half and high half respectively.
- */
- uint16x8_t s0colsum0_l = vmlal_u8(vmovl_u8(vget_low_u8(s0A)),
- vget_low_u8(s0B), three_u8);
- uint16x8_t s0colsum0_h = vmlal_u8(vmovl_u8(vget_high_u8(s0A)),
- vget_high_u8(s0B), three_u8);
- uint16x8_t s0colsum1_l = vmlal_u8(vmovl_u8(vget_low_u8(s0C)),
- vget_low_u8(s0B), three_u8);
- uint16x8_t s0colsum1_h = vmlal_u8(vmovl_u8(vget_high_u8(s0C)),
- vget_high_u8(s0B), three_u8);
- /* Load and compute s1colsum0 and s1colsum1. */
- uint8x16_t s1A = vld1q_u8(inptr0 + 1);
- uint8x16_t s1B = vld1q_u8(inptr1 + 1);
- uint8x16_t s1C = vld1q_u8(inptr2 + 1);
- uint16x8_t s1colsum0_l = vmlal_u8(vmovl_u8(vget_low_u8(s1A)),
- vget_low_u8(s1B), three_u8);
- uint16x8_t s1colsum0_h = vmlal_u8(vmovl_u8(vget_high_u8(s1A)),
- vget_high_u8(s1B), three_u8);
- uint16x8_t s1colsum1_l = vmlal_u8(vmovl_u8(vget_low_u8(s1C)),
- vget_low_u8(s1B), three_u8);
- uint16x8_t s1colsum1_h = vmlal_u8(vmovl_u8(vget_high_u8(s1C)),
- vget_high_u8(s1B), three_u8);
-
- /* Step 2: Blend the already-blended columns. */
-
- uint16x8_t output0_p1_l = vmlaq_u16(s1colsum0_l, s0colsum0_l, three_u16);
- uint16x8_t output0_p1_h = vmlaq_u16(s1colsum0_h, s0colsum0_h, three_u16);
- uint16x8_t output0_p2_l = vmlaq_u16(s0colsum0_l, s1colsum0_l, three_u16);
- uint16x8_t output0_p2_h = vmlaq_u16(s0colsum0_h, s1colsum0_h, three_u16);
- uint16x8_t output1_p1_l = vmlaq_u16(s1colsum1_l, s0colsum1_l, three_u16);
- uint16x8_t output1_p1_h = vmlaq_u16(s1colsum1_h, s0colsum1_h, three_u16);
- uint16x8_t output1_p2_l = vmlaq_u16(s0colsum1_l, s1colsum1_l, three_u16);
- uint16x8_t output1_p2_h = vmlaq_u16(s0colsum1_h, s1colsum1_h, three_u16);
- /* Add ordered dithering bias to odd pixel values. */
- output0_p1_l = vaddq_u16(output0_p1_l, seven_u16);
- output0_p1_h = vaddq_u16(output0_p1_h, seven_u16);
- output1_p1_l = vaddq_u16(output1_p1_l, seven_u16);
- output1_p1_h = vaddq_u16(output1_p1_h, seven_u16);
- /* Right-shift by 4 (divide by 16), narrow to 8-bit, and combine. */
- uint8x16x2_t output_pixels0 = { {
- vcombine_u8(vshrn_n_u16(output0_p1_l, 4), vshrn_n_u16(output0_p1_h, 4)),
- vcombine_u8(vrshrn_n_u16(output0_p2_l, 4), vrshrn_n_u16(output0_p2_h, 4))
- } };
- uint8x16x2_t output_pixels1 = { {
- vcombine_u8(vshrn_n_u16(output1_p1_l, 4), vshrn_n_u16(output1_p1_h, 4)),
- vcombine_u8(vrshrn_n_u16(output1_p2_l, 4), vrshrn_n_u16(output1_p2_h, 4))
- } };
-
- /* Store pixel component values to memory.
- * The minimum size of the output buffer for each row is 64 bytes => no
- * need to worry about buffer overflow here. See "Creation of 2-D sample
- * arrays" in jmemmgr.c for more details.
- */
- vst2q_u8(outptr0 + 1, output_pixels0);
- vst2q_u8(outptr1 + 1, output_pixels1);
-
- /* The first pixel of the image shifted our loads and stores by one byte.
- * We have to re-align on a 32-byte boundary at some point before the end
- * of the row (we do it now on the 32/33 pixel boundary) to stay within the
- * bounds of the sample buffers without having to resort to a slow scalar
- * tail case for the last (downsampled_width % 16) samples. See "Creation
- * of 2-D sample arrays" in jmemmgr.c for more details.
- */
- for (colctr = 16; colctr < downsampled_width; colctr += 16) {
- /* Step 1: Blend samples vertically in columns s0 and s1. */
-
- /* Load and compute s0colsum0 and s0colsum1. */
- s0A = vld1q_u8(inptr0 + colctr - 1);
- s0B = vld1q_u8(inptr1 + colctr - 1);
- s0C = vld1q_u8(inptr2 + colctr - 1);
- s0colsum0_l = vmlal_u8(vmovl_u8(vget_low_u8(s0A)), vget_low_u8(s0B),
- three_u8);
- s0colsum0_h = vmlal_u8(vmovl_u8(vget_high_u8(s0A)), vget_high_u8(s0B),
- three_u8);
- s0colsum1_l = vmlal_u8(vmovl_u8(vget_low_u8(s0C)), vget_low_u8(s0B),
- three_u8);
- s0colsum1_h = vmlal_u8(vmovl_u8(vget_high_u8(s0C)), vget_high_u8(s0B),
- three_u8);
- /* Load and compute s1colsum0 and s1colsum1. */
- s1A = vld1q_u8(inptr0 + colctr);
- s1B = vld1q_u8(inptr1 + colctr);
- s1C = vld1q_u8(inptr2 + colctr);
- s1colsum0_l = vmlal_u8(vmovl_u8(vget_low_u8(s1A)), vget_low_u8(s1B),
- three_u8);
- s1colsum0_h = vmlal_u8(vmovl_u8(vget_high_u8(s1A)), vget_high_u8(s1B),
- three_u8);
- s1colsum1_l = vmlal_u8(vmovl_u8(vget_low_u8(s1C)), vget_low_u8(s1B),
- three_u8);
- s1colsum1_h = vmlal_u8(vmovl_u8(vget_high_u8(s1C)), vget_high_u8(s1B),
- three_u8);
-
- /* Step 2: Blend the already-blended columns. */
-
- output0_p1_l = vmlaq_u16(s1colsum0_l, s0colsum0_l, three_u16);
- output0_p1_h = vmlaq_u16(s1colsum0_h, s0colsum0_h, three_u16);
- output0_p2_l = vmlaq_u16(s0colsum0_l, s1colsum0_l, three_u16);
- output0_p2_h = vmlaq_u16(s0colsum0_h, s1colsum0_h, three_u16);
- output1_p1_l = vmlaq_u16(s1colsum1_l, s0colsum1_l, three_u16);
- output1_p1_h = vmlaq_u16(s1colsum1_h, s0colsum1_h, three_u16);
- output1_p2_l = vmlaq_u16(s0colsum1_l, s1colsum1_l, three_u16);
- output1_p2_h = vmlaq_u16(s0colsum1_h, s1colsum1_h, three_u16);
- /* Add ordered dithering bias to odd pixel values. */
- output0_p1_l = vaddq_u16(output0_p1_l, seven_u16);
- output0_p1_h = vaddq_u16(output0_p1_h, seven_u16);
- output1_p1_l = vaddq_u16(output1_p1_l, seven_u16);
- output1_p1_h = vaddq_u16(output1_p1_h, seven_u16);
- /* Right-shift by 4 (divide by 16), narrow to 8-bit, and combine. */
- output_pixels0.val[0] = vcombine_u8(vshrn_n_u16(output0_p1_l, 4),
- vshrn_n_u16(output0_p1_h, 4));
- output_pixels0.val[1] = vcombine_u8(vrshrn_n_u16(output0_p2_l, 4),
- vrshrn_n_u16(output0_p2_h, 4));
- output_pixels1.val[0] = vcombine_u8(vshrn_n_u16(output1_p1_l, 4),
- vshrn_n_u16(output1_p1_h, 4));
- output_pixels1.val[1] = vcombine_u8(vrshrn_n_u16(output1_p2_l, 4),
- vrshrn_n_u16(output1_p2_h, 4));
- /* Store pixel component values to memory. */
- vst2q_u8(outptr0 + 2 * colctr - 1, output_pixels0);
- vst2q_u8(outptr1 + 2 * colctr - 1, output_pixels1);
- }
-
- /* Last pixel component value in this row of the original image */
- int s1colsum0 = GETJSAMPLE(inptr1[downsampled_width - 1]) * 3 +
- GETJSAMPLE(inptr0[downsampled_width - 1]);
- outptr0[2 * downsampled_width - 1] = (JSAMPLE)((s1colsum0 * 4 + 7) >> 4);
- int s1colsum1 = GETJSAMPLE(inptr1[downsampled_width - 1]) * 3 +
- GETJSAMPLE(inptr2[downsampled_width - 1]);
- outptr1[2 * downsampled_width - 1] = (JSAMPLE)((s1colsum1 * 4 + 7) >> 4);
- inrow++;
- }
-}
-
-
-/* The diagram below shows a column of samples produced by h1v2 downsampling
- * (or by losslessly rotating or transposing an h2v1-downsampled image.)
- *
- * +---------+
- * | p0 |
- * sA | |
- * | p1 |
- * +---------+
- * | p2 |
- * sB | |
- * | p3 |
- * +---------+
- * | p4 |
- * sC | |
- * | p5 |
- * +---------+
- *
- * Samples sA-sC were created by averaging the original pixel component values
- * centered at positions p0-p5 above. To approximate those original pixel
- * component values, we proportionally blend the adjacent samples in each
- * column.
- *
- * An upsampled pixel component value is computed by blending the sample
- * containing the pixel center with the nearest neighboring sample, in the
- * ratio 3:1. For example:
- * p1(upsampled) = 3/4 * sA + 1/4 * sB
- * p2(upsampled) = 3/4 * sB + 1/4 * sA
- * When computing the first and last pixel component values in the column,
- * there is no adjacent sample to blend, so:
- * p0(upsampled) = sA
- * p5(upsampled) = sC
- */
-
-void jsimd_h1v2_fancy_upsample_neon(int max_v_samp_factor,
- JDIMENSION downsampled_width,
- JSAMPARRAY input_data,
- JSAMPARRAY *output_data_ptr)
-{
- JSAMPARRAY output_data = *output_data_ptr;
- JSAMPROW inptr0, inptr1, inptr2, outptr0, outptr1;
- int inrow, outrow;
- unsigned colctr;
- /* Set up constants. */
- const uint16x8_t one_u16 = vdupq_n_u16(1);
- const uint8x8_t three_u8 = vdup_n_u8(3);
-
- inrow = outrow = 0;
- while (outrow < max_v_samp_factor) {
- inptr0 = input_data[inrow - 1];
- inptr1 = input_data[inrow];
- inptr2 = input_data[inrow + 1];
- /* Suffixes 0 and 1 denote the upper and lower rows of output pixels,
- * respectively.
- */
- outptr0 = output_data[outrow++];
- outptr1 = output_data[outrow++];
- inrow++;
-
- /* The size of the input and output buffers is always a multiple of 32
- * bytes => no need to worry about buffer overflow when reading/writing
- * memory. See "Creation of 2-D sample arrays" in jmemmgr.c for more
- * details.
- */
- for (colctr = 0; colctr < downsampled_width; colctr += 16) {
- /* Load samples. */
- uint8x16_t sA = vld1q_u8(inptr0 + colctr);
- uint8x16_t sB = vld1q_u8(inptr1 + colctr);
- uint8x16_t sC = vld1q_u8(inptr2 + colctr);
- /* Blend samples vertically. */
- uint16x8_t colsum0_l = vmlal_u8(vmovl_u8(vget_low_u8(sA)),
- vget_low_u8(sB), three_u8);
- uint16x8_t colsum0_h = vmlal_u8(vmovl_u8(vget_high_u8(sA)),
- vget_high_u8(sB), three_u8);
- uint16x8_t colsum1_l = vmlal_u8(vmovl_u8(vget_low_u8(sC)),
- vget_low_u8(sB), three_u8);
- uint16x8_t colsum1_h = vmlal_u8(vmovl_u8(vget_high_u8(sC)),
- vget_high_u8(sB), three_u8);
- /* Add ordered dithering bias to pixel values in even output rows. */
- colsum0_l = vaddq_u16(colsum0_l, one_u16);
- colsum0_h = vaddq_u16(colsum0_h, one_u16);
- /* Right-shift by 2 (divide by 4), narrow to 8-bit, and combine. */
- uint8x16_t output_pixels0 = vcombine_u8(vshrn_n_u16(colsum0_l, 2),
- vshrn_n_u16(colsum0_h, 2));
- uint8x16_t output_pixels1 = vcombine_u8(vrshrn_n_u16(colsum1_l, 2),
- vrshrn_n_u16(colsum1_h, 2));
- /* Store pixel component values to memory. */
- vst1q_u8(outptr0 + colctr, output_pixels0);
- vst1q_u8(outptr1 + colctr, output_pixels1);
- }
- }
-}
-
-
-/* The diagram below shows a row of samples produced by h2v1 downsampling.
- *
- * s0 s1
- * +---------+---------+
- * | | |
- * | p0 p1 | p2 p3 |
- * | | |
- * +---------+---------+
- *
- * Samples s0 and s1 were created by averaging the original pixel component
- * values centered at positions p0-p3 above. To approximate those original
- * pixel component values, we duplicate the samples horizontally:
- * p0(upsampled) = p1(upsampled) = s0
- * p2(upsampled) = p3(upsampled) = s1
- */
-
-void jsimd_h2v1_upsample_neon(int max_v_samp_factor, JDIMENSION output_width,
- JSAMPARRAY input_data,
- JSAMPARRAY *output_data_ptr)
-{
- JSAMPARRAY output_data = *output_data_ptr;
- JSAMPROW inptr, outptr;
- int inrow;
- unsigned colctr;
-
- for (inrow = 0; inrow < max_v_samp_factor; inrow++) {
- inptr = input_data[inrow];
- outptr = output_data[inrow];
- for (colctr = 0; 2 * colctr < output_width; colctr += 16) {
- uint8x16_t samples = vld1q_u8(inptr + colctr);
- /* Duplicate the samples. The store operation below interleaves them so
- * that adjacent pixel component values take on the same sample value,
- * per above.
- */
- uint8x16x2_t output_pixels = { { samples, samples } };
- /* Store pixel component values to memory.
- * Due to the way sample buffers are allocated, we don't need to worry
- * about tail cases when output_width is not a multiple of 32. See
- * "Creation of 2-D sample arrays" in jmemmgr.c for details.
- */
- vst2q_u8(outptr + 2 * colctr, output_pixels);
- }
- }
-}
-
-
-/* The diagram below shows an array of samples produced by h2v2 downsampling.
- *
- * s0 s1
- * +---------+---------+
- * | p0 p1 | p2 p3 |
- * sA | | |
- * | p4 p5 | p6 p7 |
- * +---------+---------+
- * | p8 p9 | p10 p11|
- * sB | | |
- * | p12 p13| p14 p15|
- * +---------+---------+
- *
- * Samples s0A-s1B were created by averaging the original pixel component
- * values centered at positions p0-p15 above. To approximate those original
- * pixel component values, we duplicate the samples both horizontally and
- * vertically:
- * p0(upsampled) = p1(upsampled) = p4(upsampled) = p5(upsampled) = s0A
- * p2(upsampled) = p3(upsampled) = p6(upsampled) = p7(upsampled) = s1A
- * p8(upsampled) = p9(upsampled) = p12(upsampled) = p13(upsampled) = s0B
- * p10(upsampled) = p11(upsampled) = p14(upsampled) = p15(upsampled) = s1B
- */
-
-void jsimd_h2v2_upsample_neon(int max_v_samp_factor, JDIMENSION output_width,
- JSAMPARRAY input_data,
- JSAMPARRAY *output_data_ptr)
-{
- JSAMPARRAY output_data = *output_data_ptr;
- JSAMPROW inptr, outptr0, outptr1;
- int inrow, outrow;
- unsigned colctr;
-
- for (inrow = 0, outrow = 0; outrow < max_v_samp_factor; inrow++) {
- inptr = input_data[inrow];
- outptr0 = output_data[outrow++];
- outptr1 = output_data[outrow++];
-
- for (colctr = 0; 2 * colctr < output_width; colctr += 16) {
- uint8x16_t samples = vld1q_u8(inptr + colctr);
- /* Duplicate the samples. The store operation below interleaves them so
- * that adjacent pixel component values take on the same sample value,
- * per above.
- */
- uint8x16x2_t output_pixels = { { samples, samples } };
- /* Store pixel component values for both output rows to memory.
- * Due to the way sample buffers are allocated, we don't need to worry
- * about tail cases when output_width is not a multiple of 32. See
- * "Creation of 2-D sample arrays" in jmemmgr.c for details.
- */
- vst2q_u8(outptr0 + 2 * colctr, output_pixels);
- vst2q_u8(outptr1 + 2 * colctr, output_pixels);
- }
- }
-}
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/jfdctfst-neon.c b/contrib/libs/libjpeg-turbo/simd/arm/jfdctfst-neon.c
deleted file mode 100644
index bb371be399..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/arm/jfdctfst-neon.c
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * jfdctfst-neon.c - fast integer FDCT (Arm Neon)
- *
- * Copyright (C) 2020, Arm Limited. All Rights Reserved.
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- * claim that you wrote the original software. If you use this software
- * in a product, an acknowledgment in the product documentation would be
- * appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must not be
- * misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source distribution.
- */
-
-#define JPEG_INTERNALS
-#include "../../jinclude.h"
-#include "../../jpeglib.h"
-#include "../../jsimd.h"
-#include "../../jdct.h"
-#include "../../jsimddct.h"
-#include "../jsimd.h"
-#include "align.h"
-
-#include <arm_neon.h>
-
-
-/* jsimd_fdct_ifast_neon() performs a fast, not so accurate forward DCT
- * (Discrete Cosine Transform) on one block of samples. It uses the same
- * calculations and produces exactly the same output as IJG's original
- * jpeg_fdct_ifast() function, which can be found in jfdctfst.c.
- *
- * Scaled integer constants are used to avoid floating-point arithmetic:
- * 0.382683433 = 12544 * 2^-15
- * 0.541196100 = 17795 * 2^-15
- * 0.707106781 = 23168 * 2^-15
- * 0.306562965 = 9984 * 2^-15
- *
- * See jfdctfst.c for further details of the DCT algorithm. Where possible,
- * the variable names and comments here in jsimd_fdct_ifast_neon() match up
- * with those in jpeg_fdct_ifast().
- */
-
-#define F_0_382 12544
-#define F_0_541 17792
-#define F_0_707 23168
-#define F_0_306 9984
-
-
-ALIGN(16) static const int16_t jsimd_fdct_ifast_neon_consts[] = {
- F_0_382, F_0_541, F_0_707, F_0_306
-};
-
-void jsimd_fdct_ifast_neon(DCTELEM *data)
-{
- /* Load an 8x8 block of samples into Neon registers. De-interleaving loads
- * are used, followed by vuzp to transpose the block such that we have a
- * column of samples per vector - allowing all rows to be processed at once.
- */
- int16x8x4_t data1 = vld4q_s16(data);
- int16x8x4_t data2 = vld4q_s16(data + 4 * DCTSIZE);
-
- int16x8x2_t cols_04 = vuzpq_s16(data1.val[0], data2.val[0]);
- int16x8x2_t cols_15 = vuzpq_s16(data1.val[1], data2.val[1]);
- int16x8x2_t cols_26 = vuzpq_s16(data1.val[2], data2.val[2]);
- int16x8x2_t cols_37 = vuzpq_s16(data1.val[3], data2.val[3]);
-
- int16x8_t col0 = cols_04.val[0];
- int16x8_t col1 = cols_15.val[0];
- int16x8_t col2 = cols_26.val[0];
- int16x8_t col3 = cols_37.val[0];
- int16x8_t col4 = cols_04.val[1];
- int16x8_t col5 = cols_15.val[1];
- int16x8_t col6 = cols_26.val[1];
- int16x8_t col7 = cols_37.val[1];
-
- /* Pass 1: process rows. */
-
- /* Load DCT conversion constants. */
- const int16x4_t consts = vld1_s16(jsimd_fdct_ifast_neon_consts);
-
- int16x8_t tmp0 = vaddq_s16(col0, col7);
- int16x8_t tmp7 = vsubq_s16(col0, col7);
- int16x8_t tmp1 = vaddq_s16(col1, col6);
- int16x8_t tmp6 = vsubq_s16(col1, col6);
- int16x8_t tmp2 = vaddq_s16(col2, col5);
- int16x8_t tmp5 = vsubq_s16(col2, col5);
- int16x8_t tmp3 = vaddq_s16(col3, col4);
- int16x8_t tmp4 = vsubq_s16(col3, col4);
-
- /* Even part */
- int16x8_t tmp10 = vaddq_s16(tmp0, tmp3); /* phase 2 */
- int16x8_t tmp13 = vsubq_s16(tmp0, tmp3);
- int16x8_t tmp11 = vaddq_s16(tmp1, tmp2);
- int16x8_t tmp12 = vsubq_s16(tmp1, tmp2);
-
- col0 = vaddq_s16(tmp10, tmp11); /* phase 3 */
- col4 = vsubq_s16(tmp10, tmp11);
-
- int16x8_t z1 = vqdmulhq_lane_s16(vaddq_s16(tmp12, tmp13), consts, 2);
- col2 = vaddq_s16(tmp13, z1); /* phase 5 */
- col6 = vsubq_s16(tmp13, z1);
-
- /* Odd part */
- tmp10 = vaddq_s16(tmp4, tmp5); /* phase 2 */
- tmp11 = vaddq_s16(tmp5, tmp6);
- tmp12 = vaddq_s16(tmp6, tmp7);
-
- int16x8_t z5 = vqdmulhq_lane_s16(vsubq_s16(tmp10, tmp12), consts, 0);
- int16x8_t z2 = vqdmulhq_lane_s16(tmp10, consts, 1);
- z2 = vaddq_s16(z2, z5);
- int16x8_t z4 = vqdmulhq_lane_s16(tmp12, consts, 3);
- z5 = vaddq_s16(tmp12, z5);
- z4 = vaddq_s16(z4, z5);
- int16x8_t z3 = vqdmulhq_lane_s16(tmp11, consts, 2);
-
- int16x8_t z11 = vaddq_s16(tmp7, z3); /* phase 5 */
- int16x8_t z13 = vsubq_s16(tmp7, z3);
-
- col5 = vaddq_s16(z13, z2); /* phase 6 */
- col3 = vsubq_s16(z13, z2);
- col1 = vaddq_s16(z11, z4);
- col7 = vsubq_s16(z11, z4);
-
- /* Transpose to work on columns in pass 2. */
- int16x8x2_t cols_01 = vtrnq_s16(col0, col1);
- int16x8x2_t cols_23 = vtrnq_s16(col2, col3);
- int16x8x2_t cols_45 = vtrnq_s16(col4, col5);
- int16x8x2_t cols_67 = vtrnq_s16(col6, col7);
-
- int32x4x2_t cols_0145_l = vtrnq_s32(vreinterpretq_s32_s16(cols_01.val[0]),
- vreinterpretq_s32_s16(cols_45.val[0]));
- int32x4x2_t cols_0145_h = vtrnq_s32(vreinterpretq_s32_s16(cols_01.val[1]),
- vreinterpretq_s32_s16(cols_45.val[1]));
- int32x4x2_t cols_2367_l = vtrnq_s32(vreinterpretq_s32_s16(cols_23.val[0]),
- vreinterpretq_s32_s16(cols_67.val[0]));
- int32x4x2_t cols_2367_h = vtrnq_s32(vreinterpretq_s32_s16(cols_23.val[1]),
- vreinterpretq_s32_s16(cols_67.val[1]));
-
- int32x4x2_t rows_04 = vzipq_s32(cols_0145_l.val[0], cols_2367_l.val[0]);
- int32x4x2_t rows_15 = vzipq_s32(cols_0145_h.val[0], cols_2367_h.val[0]);
- int32x4x2_t rows_26 = vzipq_s32(cols_0145_l.val[1], cols_2367_l.val[1]);
- int32x4x2_t rows_37 = vzipq_s32(cols_0145_h.val[1], cols_2367_h.val[1]);
-
- int16x8_t row0 = vreinterpretq_s16_s32(rows_04.val[0]);
- int16x8_t row1 = vreinterpretq_s16_s32(rows_15.val[0]);
- int16x8_t row2 = vreinterpretq_s16_s32(rows_26.val[0]);
- int16x8_t row3 = vreinterpretq_s16_s32(rows_37.val[0]);
- int16x8_t row4 = vreinterpretq_s16_s32(rows_04.val[1]);
- int16x8_t row5 = vreinterpretq_s16_s32(rows_15.val[1]);
- int16x8_t row6 = vreinterpretq_s16_s32(rows_26.val[1]);
- int16x8_t row7 = vreinterpretq_s16_s32(rows_37.val[1]);
-
- /* Pass 2: process columns. */
-
- tmp0 = vaddq_s16(row0, row7);
- tmp7 = vsubq_s16(row0, row7);
- tmp1 = vaddq_s16(row1, row6);
- tmp6 = vsubq_s16(row1, row6);
- tmp2 = vaddq_s16(row2, row5);
- tmp5 = vsubq_s16(row2, row5);
- tmp3 = vaddq_s16(row3, row4);
- tmp4 = vsubq_s16(row3, row4);
-
- /* Even part */
- tmp10 = vaddq_s16(tmp0, tmp3); /* phase 2 */
- tmp13 = vsubq_s16(tmp0, tmp3);
- tmp11 = vaddq_s16(tmp1, tmp2);
- tmp12 = vsubq_s16(tmp1, tmp2);
-
- row0 = vaddq_s16(tmp10, tmp11); /* phase 3 */
- row4 = vsubq_s16(tmp10, tmp11);
-
- z1 = vqdmulhq_lane_s16(vaddq_s16(tmp12, tmp13), consts, 2);
- row2 = vaddq_s16(tmp13, z1); /* phase 5 */
- row6 = vsubq_s16(tmp13, z1);
-
- /* Odd part */
- tmp10 = vaddq_s16(tmp4, tmp5); /* phase 2 */
- tmp11 = vaddq_s16(tmp5, tmp6);
- tmp12 = vaddq_s16(tmp6, tmp7);
-
- z5 = vqdmulhq_lane_s16(vsubq_s16(tmp10, tmp12), consts, 0);
- z2 = vqdmulhq_lane_s16(tmp10, consts, 1);
- z2 = vaddq_s16(z2, z5);
- z4 = vqdmulhq_lane_s16(tmp12, consts, 3);
- z5 = vaddq_s16(tmp12, z5);
- z4 = vaddq_s16(z4, z5);
- z3 = vqdmulhq_lane_s16(tmp11, consts, 2);
-
- z11 = vaddq_s16(tmp7, z3); /* phase 5 */
- z13 = vsubq_s16(tmp7, z3);
-
- row5 = vaddq_s16(z13, z2); /* phase 6 */
- row3 = vsubq_s16(z13, z2);
- row1 = vaddq_s16(z11, z4);
- row7 = vsubq_s16(z11, z4);
-
- vst1q_s16(data + 0 * DCTSIZE, row0);
- vst1q_s16(data + 1 * DCTSIZE, row1);
- vst1q_s16(data + 2 * DCTSIZE, row2);
- vst1q_s16(data + 3 * DCTSIZE, row3);
- vst1q_s16(data + 4 * DCTSIZE, row4);
- vst1q_s16(data + 5 * DCTSIZE, row5);
- vst1q_s16(data + 6 * DCTSIZE, row6);
- vst1q_s16(data + 7 * DCTSIZE, row7);
-}
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/jfdctint-neon.c b/contrib/libs/libjpeg-turbo/simd/arm/jfdctint-neon.c
deleted file mode 100644
index ccfc07b15d..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/arm/jfdctint-neon.c
+++ /dev/null
@@ -1,376 +0,0 @@
-/*
- * jfdctint-neon.c - accurate integer FDCT (Arm Neon)
- *
- * Copyright (C) 2020, Arm Limited. All Rights Reserved.
- * Copyright (C) 2020, D. R. Commander. All Rights Reserved.
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- * claim that you wrote the original software. If you use this software
- * in a product, an acknowledgment in the product documentation would be
- * appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must not be
- * misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source distribution.
- */
-
-#define JPEG_INTERNALS
-#include "../../jinclude.h"
-#include "../../jpeglib.h"
-#include "../../jsimd.h"
-#include "../../jdct.h"
-#include "../../jsimddct.h"
-#include "../jsimd.h"
-#include "align.h"
-#include "neon-compat.h"
-
-#include <arm_neon.h>
-
-
-/* jsimd_fdct_islow_neon() performs a slower but more accurate forward DCT
- * (Discrete Cosine Transform) on one block of samples. It uses the same
- * calculations and produces exactly the same output as IJG's original
- * jpeg_fdct_islow() function, which can be found in jfdctint.c.
- *
- * Scaled integer constants are used to avoid floating-point arithmetic:
- * 0.298631336 = 2446 * 2^-13
- * 0.390180644 = 3196 * 2^-13
- * 0.541196100 = 4433 * 2^-13
- * 0.765366865 = 6270 * 2^-13
- * 0.899976223 = 7373 * 2^-13
- * 1.175875602 = 9633 * 2^-13
- * 1.501321110 = 12299 * 2^-13
- * 1.847759065 = 15137 * 2^-13
- * 1.961570560 = 16069 * 2^-13
- * 2.053119869 = 16819 * 2^-13
- * 2.562915447 = 20995 * 2^-13
- * 3.072711026 = 25172 * 2^-13
- *
- * See jfdctint.c for further details of the DCT algorithm. Where possible,
- * the variable names and comments here in jsimd_fdct_islow_neon() match up
- * with those in jpeg_fdct_islow().
- */
-
-#define CONST_BITS 13
-#define PASS1_BITS 2
-
-#define DESCALE_P1 (CONST_BITS - PASS1_BITS)
-#define DESCALE_P2 (CONST_BITS + PASS1_BITS)
-
-#define F_0_298 2446
-#define F_0_390 3196
-#define F_0_541 4433
-#define F_0_765 6270
-#define F_0_899 7373
-#define F_1_175 9633
-#define F_1_501 12299
-#define F_1_847 15137
-#define F_1_961 16069
-#define F_2_053 16819
-#define F_2_562 20995
-#define F_3_072 25172
-
-
-ALIGN(16) static const int16_t jsimd_fdct_islow_neon_consts[] = {
- F_0_298, -F_0_390, F_0_541, F_0_765,
- -F_0_899, F_1_175, F_1_501, -F_1_847,
- -F_1_961, F_2_053, -F_2_562, F_3_072
-};
-
-void jsimd_fdct_islow_neon(DCTELEM *data)
-{
- /* Load DCT constants. */
-#ifdef HAVE_VLD1_S16_X3
- const int16x4x3_t consts = vld1_s16_x3(jsimd_fdct_islow_neon_consts);
-#else
- /* GCC does not currently support the intrinsic vld1_<type>_x3(). */
- const int16x4_t consts1 = vld1_s16(jsimd_fdct_islow_neon_consts);
- const int16x4_t consts2 = vld1_s16(jsimd_fdct_islow_neon_consts + 4);
- const int16x4_t consts3 = vld1_s16(jsimd_fdct_islow_neon_consts + 8);
- const int16x4x3_t consts = { { consts1, consts2, consts3 } };
-#endif
-
- /* Load an 8x8 block of samples into Neon registers. De-interleaving loads
- * are used, followed by vuzp to transpose the block such that we have a
- * column of samples per vector - allowing all rows to be processed at once.
- */
- int16x8x4_t s_rows_0123 = vld4q_s16(data);
- int16x8x4_t s_rows_4567 = vld4q_s16(data + 4 * DCTSIZE);
-
- int16x8x2_t cols_04 = vuzpq_s16(s_rows_0123.val[0], s_rows_4567.val[0]);
- int16x8x2_t cols_15 = vuzpq_s16(s_rows_0123.val[1], s_rows_4567.val[1]);
- int16x8x2_t cols_26 = vuzpq_s16(s_rows_0123.val[2], s_rows_4567.val[2]);
- int16x8x2_t cols_37 = vuzpq_s16(s_rows_0123.val[3], s_rows_4567.val[3]);
-
- int16x8_t col0 = cols_04.val[0];
- int16x8_t col1 = cols_15.val[0];
- int16x8_t col2 = cols_26.val[0];
- int16x8_t col3 = cols_37.val[0];
- int16x8_t col4 = cols_04.val[1];
- int16x8_t col5 = cols_15.val[1];
- int16x8_t col6 = cols_26.val[1];
- int16x8_t col7 = cols_37.val[1];
-
- /* Pass 1: process rows. */
-
- int16x8_t tmp0 = vaddq_s16(col0, col7);
- int16x8_t tmp7 = vsubq_s16(col0, col7);
- int16x8_t tmp1 = vaddq_s16(col1, col6);
- int16x8_t tmp6 = vsubq_s16(col1, col6);
- int16x8_t tmp2 = vaddq_s16(col2, col5);
- int16x8_t tmp5 = vsubq_s16(col2, col5);
- int16x8_t tmp3 = vaddq_s16(col3, col4);
- int16x8_t tmp4 = vsubq_s16(col3, col4);
-
- /* Even part */
- int16x8_t tmp10 = vaddq_s16(tmp0, tmp3);
- int16x8_t tmp13 = vsubq_s16(tmp0, tmp3);
- int16x8_t tmp11 = vaddq_s16(tmp1, tmp2);
- int16x8_t tmp12 = vsubq_s16(tmp1, tmp2);
-
- col0 = vshlq_n_s16(vaddq_s16(tmp10, tmp11), PASS1_BITS);
- col4 = vshlq_n_s16(vsubq_s16(tmp10, tmp11), PASS1_BITS);
-
- int16x8_t tmp12_add_tmp13 = vaddq_s16(tmp12, tmp13);
- int32x4_t z1_l =
- vmull_lane_s16(vget_low_s16(tmp12_add_tmp13), consts.val[0], 2);
- int32x4_t z1_h =
- vmull_lane_s16(vget_high_s16(tmp12_add_tmp13), consts.val[0], 2);
-
- int32x4_t col2_scaled_l =
- vmlal_lane_s16(z1_l, vget_low_s16(tmp13), consts.val[0], 3);
- int32x4_t col2_scaled_h =
- vmlal_lane_s16(z1_h, vget_high_s16(tmp13), consts.val[0], 3);
- col2 = vcombine_s16(vrshrn_n_s32(col2_scaled_l, DESCALE_P1),
- vrshrn_n_s32(col2_scaled_h, DESCALE_P1));
-
- int32x4_t col6_scaled_l =
- vmlal_lane_s16(z1_l, vget_low_s16(tmp12), consts.val[1], 3);
- int32x4_t col6_scaled_h =
- vmlal_lane_s16(z1_h, vget_high_s16(tmp12), consts.val[1], 3);
- col6 = vcombine_s16(vrshrn_n_s32(col6_scaled_l, DESCALE_P1),
- vrshrn_n_s32(col6_scaled_h, DESCALE_P1));
-
- /* Odd part */
- int16x8_t z1 = vaddq_s16(tmp4, tmp7);
- int16x8_t z2 = vaddq_s16(tmp5, tmp6);
- int16x8_t z3 = vaddq_s16(tmp4, tmp6);
- int16x8_t z4 = vaddq_s16(tmp5, tmp7);
- /* sqrt(2) * c3 */
- int32x4_t z5_l = vmull_lane_s16(vget_low_s16(z3), consts.val[1], 1);
- int32x4_t z5_h = vmull_lane_s16(vget_high_s16(z3), consts.val[1], 1);
- z5_l = vmlal_lane_s16(z5_l, vget_low_s16(z4), consts.val[1], 1);
- z5_h = vmlal_lane_s16(z5_h, vget_high_s16(z4), consts.val[1], 1);
-
- /* sqrt(2) * (-c1+c3+c5-c7) */
- int32x4_t tmp4_l = vmull_lane_s16(vget_low_s16(tmp4), consts.val[0], 0);
- int32x4_t tmp4_h = vmull_lane_s16(vget_high_s16(tmp4), consts.val[0], 0);
- /* sqrt(2) * ( c1+c3-c5+c7) */
- int32x4_t tmp5_l = vmull_lane_s16(vget_low_s16(tmp5), consts.val[2], 1);
- int32x4_t tmp5_h = vmull_lane_s16(vget_high_s16(tmp5), consts.val[2], 1);
- /* sqrt(2) * ( c1+c3+c5-c7) */
- int32x4_t tmp6_l = vmull_lane_s16(vget_low_s16(tmp6), consts.val[2], 3);
- int32x4_t tmp6_h = vmull_lane_s16(vget_high_s16(tmp6), consts.val[2], 3);
- /* sqrt(2) * ( c1+c3-c5-c7) */
- int32x4_t tmp7_l = vmull_lane_s16(vget_low_s16(tmp7), consts.val[1], 2);
- int32x4_t tmp7_h = vmull_lane_s16(vget_high_s16(tmp7), consts.val[1], 2);
-
- /* sqrt(2) * (c7-c3) */
- z1_l = vmull_lane_s16(vget_low_s16(z1), consts.val[1], 0);
- z1_h = vmull_lane_s16(vget_high_s16(z1), consts.val[1], 0);
- /* sqrt(2) * (-c1-c3) */
- int32x4_t z2_l = vmull_lane_s16(vget_low_s16(z2), consts.val[2], 2);
- int32x4_t z2_h = vmull_lane_s16(vget_high_s16(z2), consts.val[2], 2);
- /* sqrt(2) * (-c3-c5) */
- int32x4_t z3_l = vmull_lane_s16(vget_low_s16(z3), consts.val[2], 0);
- int32x4_t z3_h = vmull_lane_s16(vget_high_s16(z3), consts.val[2], 0);
- /* sqrt(2) * (c5-c3) */
- int32x4_t z4_l = vmull_lane_s16(vget_low_s16(z4), consts.val[0], 1);
- int32x4_t z4_h = vmull_lane_s16(vget_high_s16(z4), consts.val[0], 1);
-
- z3_l = vaddq_s32(z3_l, z5_l);
- z3_h = vaddq_s32(z3_h, z5_h);
- z4_l = vaddq_s32(z4_l, z5_l);
- z4_h = vaddq_s32(z4_h, z5_h);
-
- tmp4_l = vaddq_s32(tmp4_l, z1_l);
- tmp4_h = vaddq_s32(tmp4_h, z1_h);
- tmp4_l = vaddq_s32(tmp4_l, z3_l);
- tmp4_h = vaddq_s32(tmp4_h, z3_h);
- col7 = vcombine_s16(vrshrn_n_s32(tmp4_l, DESCALE_P1),
- vrshrn_n_s32(tmp4_h, DESCALE_P1));
-
- tmp5_l = vaddq_s32(tmp5_l, z2_l);
- tmp5_h = vaddq_s32(tmp5_h, z2_h);
- tmp5_l = vaddq_s32(tmp5_l, z4_l);
- tmp5_h = vaddq_s32(tmp5_h, z4_h);
- col5 = vcombine_s16(vrshrn_n_s32(tmp5_l, DESCALE_P1),
- vrshrn_n_s32(tmp5_h, DESCALE_P1));
-
- tmp6_l = vaddq_s32(tmp6_l, z2_l);
- tmp6_h = vaddq_s32(tmp6_h, z2_h);
- tmp6_l = vaddq_s32(tmp6_l, z3_l);
- tmp6_h = vaddq_s32(tmp6_h, z3_h);
- col3 = vcombine_s16(vrshrn_n_s32(tmp6_l, DESCALE_P1),
- vrshrn_n_s32(tmp6_h, DESCALE_P1));
-
- tmp7_l = vaddq_s32(tmp7_l, z1_l);
- tmp7_h = vaddq_s32(tmp7_h, z1_h);
- tmp7_l = vaddq_s32(tmp7_l, z4_l);
- tmp7_h = vaddq_s32(tmp7_h, z4_h);
- col1 = vcombine_s16(vrshrn_n_s32(tmp7_l, DESCALE_P1),
- vrshrn_n_s32(tmp7_h, DESCALE_P1));
-
- /* Transpose to work on columns in pass 2. */
- int16x8x2_t cols_01 = vtrnq_s16(col0, col1);
- int16x8x2_t cols_23 = vtrnq_s16(col2, col3);
- int16x8x2_t cols_45 = vtrnq_s16(col4, col5);
- int16x8x2_t cols_67 = vtrnq_s16(col6, col7);
-
- int32x4x2_t cols_0145_l = vtrnq_s32(vreinterpretq_s32_s16(cols_01.val[0]),
- vreinterpretq_s32_s16(cols_45.val[0]));
- int32x4x2_t cols_0145_h = vtrnq_s32(vreinterpretq_s32_s16(cols_01.val[1]),
- vreinterpretq_s32_s16(cols_45.val[1]));
- int32x4x2_t cols_2367_l = vtrnq_s32(vreinterpretq_s32_s16(cols_23.val[0]),
- vreinterpretq_s32_s16(cols_67.val[0]));
- int32x4x2_t cols_2367_h = vtrnq_s32(vreinterpretq_s32_s16(cols_23.val[1]),
- vreinterpretq_s32_s16(cols_67.val[1]));
-
- int32x4x2_t rows_04 = vzipq_s32(cols_0145_l.val[0], cols_2367_l.val[0]);
- int32x4x2_t rows_15 = vzipq_s32(cols_0145_h.val[0], cols_2367_h.val[0]);
- int32x4x2_t rows_26 = vzipq_s32(cols_0145_l.val[1], cols_2367_l.val[1]);
- int32x4x2_t rows_37 = vzipq_s32(cols_0145_h.val[1], cols_2367_h.val[1]);
-
- int16x8_t row0 = vreinterpretq_s16_s32(rows_04.val[0]);
- int16x8_t row1 = vreinterpretq_s16_s32(rows_15.val[0]);
- int16x8_t row2 = vreinterpretq_s16_s32(rows_26.val[0]);
- int16x8_t row3 = vreinterpretq_s16_s32(rows_37.val[0]);
- int16x8_t row4 = vreinterpretq_s16_s32(rows_04.val[1]);
- int16x8_t row5 = vreinterpretq_s16_s32(rows_15.val[1]);
- int16x8_t row6 = vreinterpretq_s16_s32(rows_26.val[1]);
- int16x8_t row7 = vreinterpretq_s16_s32(rows_37.val[1]);
-
- /* Pass 2: process columns. */
-
- tmp0 = vaddq_s16(row0, row7);
- tmp7 = vsubq_s16(row0, row7);
- tmp1 = vaddq_s16(row1, row6);
- tmp6 = vsubq_s16(row1, row6);
- tmp2 = vaddq_s16(row2, row5);
- tmp5 = vsubq_s16(row2, row5);
- tmp3 = vaddq_s16(row3, row4);
- tmp4 = vsubq_s16(row3, row4);
-
- /* Even part */
- tmp10 = vaddq_s16(tmp0, tmp3);
- tmp13 = vsubq_s16(tmp0, tmp3);
- tmp11 = vaddq_s16(tmp1, tmp2);
- tmp12 = vsubq_s16(tmp1, tmp2);
-
- row0 = vrshrq_n_s16(vaddq_s16(tmp10, tmp11), PASS1_BITS);
- row4 = vrshrq_n_s16(vsubq_s16(tmp10, tmp11), PASS1_BITS);
-
- tmp12_add_tmp13 = vaddq_s16(tmp12, tmp13);
- z1_l = vmull_lane_s16(vget_low_s16(tmp12_add_tmp13), consts.val[0], 2);
- z1_h = vmull_lane_s16(vget_high_s16(tmp12_add_tmp13), consts.val[0], 2);
-
- int32x4_t row2_scaled_l =
- vmlal_lane_s16(z1_l, vget_low_s16(tmp13), consts.val[0], 3);
- int32x4_t row2_scaled_h =
- vmlal_lane_s16(z1_h, vget_high_s16(tmp13), consts.val[0], 3);
- row2 = vcombine_s16(vrshrn_n_s32(row2_scaled_l, DESCALE_P2),
- vrshrn_n_s32(row2_scaled_h, DESCALE_P2));
-
- int32x4_t row6_scaled_l =
- vmlal_lane_s16(z1_l, vget_low_s16(tmp12), consts.val[1], 3);
- int32x4_t row6_scaled_h =
- vmlal_lane_s16(z1_h, vget_high_s16(tmp12), consts.val[1], 3);
- row6 = vcombine_s16(vrshrn_n_s32(row6_scaled_l, DESCALE_P2),
- vrshrn_n_s32(row6_scaled_h, DESCALE_P2));
-
- /* Odd part */
- z1 = vaddq_s16(tmp4, tmp7);
- z2 = vaddq_s16(tmp5, tmp6);
- z3 = vaddq_s16(tmp4, tmp6);
- z4 = vaddq_s16(tmp5, tmp7);
- /* sqrt(2) * c3 */
- z5_l = vmull_lane_s16(vget_low_s16(z3), consts.val[1], 1);
- z5_h = vmull_lane_s16(vget_high_s16(z3), consts.val[1], 1);
- z5_l = vmlal_lane_s16(z5_l, vget_low_s16(z4), consts.val[1], 1);
- z5_h = vmlal_lane_s16(z5_h, vget_high_s16(z4), consts.val[1], 1);
-
- /* sqrt(2) * (-c1+c3+c5-c7) */
- tmp4_l = vmull_lane_s16(vget_low_s16(tmp4), consts.val[0], 0);
- tmp4_h = vmull_lane_s16(vget_high_s16(tmp4), consts.val[0], 0);
- /* sqrt(2) * ( c1+c3-c5+c7) */
- tmp5_l = vmull_lane_s16(vget_low_s16(tmp5), consts.val[2], 1);
- tmp5_h = vmull_lane_s16(vget_high_s16(tmp5), consts.val[2], 1);
- /* sqrt(2) * ( c1+c3+c5-c7) */
- tmp6_l = vmull_lane_s16(vget_low_s16(tmp6), consts.val[2], 3);
- tmp6_h = vmull_lane_s16(vget_high_s16(tmp6), consts.val[2], 3);
- /* sqrt(2) * ( c1+c3-c5-c7) */
- tmp7_l = vmull_lane_s16(vget_low_s16(tmp7), consts.val[1], 2);
- tmp7_h = vmull_lane_s16(vget_high_s16(tmp7), consts.val[1], 2);
-
- /* sqrt(2) * (c7-c3) */
- z1_l = vmull_lane_s16(vget_low_s16(z1), consts.val[1], 0);
- z1_h = vmull_lane_s16(vget_high_s16(z1), consts.val[1], 0);
- /* sqrt(2) * (-c1-c3) */
- z2_l = vmull_lane_s16(vget_low_s16(z2), consts.val[2], 2);
- z2_h = vmull_lane_s16(vget_high_s16(z2), consts.val[2], 2);
- /* sqrt(2) * (-c3-c5) */
- z3_l = vmull_lane_s16(vget_low_s16(z3), consts.val[2], 0);
- z3_h = vmull_lane_s16(vget_high_s16(z3), consts.val[2], 0);
- /* sqrt(2) * (c5-c3) */
- z4_l = vmull_lane_s16(vget_low_s16(z4), consts.val[0], 1);
- z4_h = vmull_lane_s16(vget_high_s16(z4), consts.val[0], 1);
-
- z3_l = vaddq_s32(z3_l, z5_l);
- z3_h = vaddq_s32(z3_h, z5_h);
- z4_l = vaddq_s32(z4_l, z5_l);
- z4_h = vaddq_s32(z4_h, z5_h);
-
- tmp4_l = vaddq_s32(tmp4_l, z1_l);
- tmp4_h = vaddq_s32(tmp4_h, z1_h);
- tmp4_l = vaddq_s32(tmp4_l, z3_l);
- tmp4_h = vaddq_s32(tmp4_h, z3_h);
- row7 = vcombine_s16(vrshrn_n_s32(tmp4_l, DESCALE_P2),
- vrshrn_n_s32(tmp4_h, DESCALE_P2));
-
- tmp5_l = vaddq_s32(tmp5_l, z2_l);
- tmp5_h = vaddq_s32(tmp5_h, z2_h);
- tmp5_l = vaddq_s32(tmp5_l, z4_l);
- tmp5_h = vaddq_s32(tmp5_h, z4_h);
- row5 = vcombine_s16(vrshrn_n_s32(tmp5_l, DESCALE_P2),
- vrshrn_n_s32(tmp5_h, DESCALE_P2));
-
- tmp6_l = vaddq_s32(tmp6_l, z2_l);
- tmp6_h = vaddq_s32(tmp6_h, z2_h);
- tmp6_l = vaddq_s32(tmp6_l, z3_l);
- tmp6_h = vaddq_s32(tmp6_h, z3_h);
- row3 = vcombine_s16(vrshrn_n_s32(tmp6_l, DESCALE_P2),
- vrshrn_n_s32(tmp6_h, DESCALE_P2));
-
- tmp7_l = vaddq_s32(tmp7_l, z1_l);
- tmp7_h = vaddq_s32(tmp7_h, z1_h);
- tmp7_l = vaddq_s32(tmp7_l, z4_l);
- tmp7_h = vaddq_s32(tmp7_h, z4_h);
- row1 = vcombine_s16(vrshrn_n_s32(tmp7_l, DESCALE_P2),
- vrshrn_n_s32(tmp7_h, DESCALE_P2));
-
- vst1q_s16(data + 0 * DCTSIZE, row0);
- vst1q_s16(data + 1 * DCTSIZE, row1);
- vst1q_s16(data + 2 * DCTSIZE, row2);
- vst1q_s16(data + 3 * DCTSIZE, row3);
- vst1q_s16(data + 4 * DCTSIZE, row4);
- vst1q_s16(data + 5 * DCTSIZE, row5);
- vst1q_s16(data + 6 * DCTSIZE, row6);
- vst1q_s16(data + 7 * DCTSIZE, row7);
-}
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/jidctfst-neon.c b/contrib/libs/libjpeg-turbo/simd/arm/jidctfst-neon.c
deleted file mode 100644
index a91be5362e..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/arm/jidctfst-neon.c
+++ /dev/null
@@ -1,472 +0,0 @@
-/*
- * jidctfst-neon.c - fast integer IDCT (Arm Neon)
- *
- * Copyright (C) 2020, Arm Limited. All Rights Reserved.
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- * claim that you wrote the original software. If you use this software
- * in a product, an acknowledgment in the product documentation would be
- * appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must not be
- * misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source distribution.
- */
-
-#define JPEG_INTERNALS
-#include "../../jinclude.h"
-#include "../../jpeglib.h"
-#include "../../jsimd.h"
-#include "../../jdct.h"
-#include "../../jsimddct.h"
-#include "../jsimd.h"
-#include "align.h"
-
-#include <arm_neon.h>
-
-
-/* jsimd_idct_ifast_neon() performs dequantization and a fast, not so accurate
- * inverse DCT (Discrete Cosine Transform) on one block of coefficients. It
- * uses the same calculations and produces exactly the same output as IJG's
- * original jpeg_idct_ifast() function, which can be found in jidctfst.c.
- *
- * Scaled integer constants are used to avoid floating-point arithmetic:
- * 0.082392200 = 2688 * 2^-15
- * 0.414213562 = 13568 * 2^-15
- * 0.847759065 = 27776 * 2^-15
- * 0.613125930 = 20096 * 2^-15
- *
- * See jidctfst.c for further details of the IDCT algorithm. Where possible,
- * the variable names and comments here in jsimd_idct_ifast_neon() match up
- * with those in jpeg_idct_ifast().
- */
-
-#define PASS1_BITS 2
-
-#define F_0_082 2688
-#define F_0_414 13568
-#define F_0_847 27776
-#define F_0_613 20096
-
-
-ALIGN(16) static const int16_t jsimd_idct_ifast_neon_consts[] = {
- F_0_082, F_0_414, F_0_847, F_0_613
-};
-
-void jsimd_idct_ifast_neon(void *dct_table, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col)
-{
- IFAST_MULT_TYPE *quantptr = dct_table;
-
- /* Load DCT coefficients. */
- int16x8_t row0 = vld1q_s16(coef_block + 0 * DCTSIZE);
- int16x8_t row1 = vld1q_s16(coef_block + 1 * DCTSIZE);
- int16x8_t row2 = vld1q_s16(coef_block + 2 * DCTSIZE);
- int16x8_t row3 = vld1q_s16(coef_block + 3 * DCTSIZE);
- int16x8_t row4 = vld1q_s16(coef_block + 4 * DCTSIZE);
- int16x8_t row5 = vld1q_s16(coef_block + 5 * DCTSIZE);
- int16x8_t row6 = vld1q_s16(coef_block + 6 * DCTSIZE);
- int16x8_t row7 = vld1q_s16(coef_block + 7 * DCTSIZE);
-
- /* Load quantization table values for DC coefficients. */
- int16x8_t quant_row0 = vld1q_s16(quantptr + 0 * DCTSIZE);
- /* Dequantize DC coefficients. */
- row0 = vmulq_s16(row0, quant_row0);
-
- /* Construct bitmap to test if all AC coefficients are 0. */
- int16x8_t bitmap = vorrq_s16(row1, row2);
- bitmap = vorrq_s16(bitmap, row3);
- bitmap = vorrq_s16(bitmap, row4);
- bitmap = vorrq_s16(bitmap, row5);
- bitmap = vorrq_s16(bitmap, row6);
- bitmap = vorrq_s16(bitmap, row7);
-
- int64_t left_ac_bitmap = vgetq_lane_s64(vreinterpretq_s64_s16(bitmap), 0);
- int64_t right_ac_bitmap = vgetq_lane_s64(vreinterpretq_s64_s16(bitmap), 1);
-
- /* Load IDCT conversion constants. */
- const int16x4_t consts = vld1_s16(jsimd_idct_ifast_neon_consts);
-
- if (left_ac_bitmap == 0 && right_ac_bitmap == 0) {
- /* All AC coefficients are zero.
- * Compute DC values and duplicate into vectors.
- */
- int16x8_t dcval = row0;
- row1 = dcval;
- row2 = dcval;
- row3 = dcval;
- row4 = dcval;
- row5 = dcval;
- row6 = dcval;
- row7 = dcval;
- } else if (left_ac_bitmap == 0) {
- /* AC coefficients are zero for columns 0, 1, 2, and 3.
- * Use DC values for these columns.
- */
- int16x4_t dcval = vget_low_s16(row0);
-
- /* Commence regular fast IDCT computation for columns 4, 5, 6, and 7. */
-
- /* Load quantization table. */
- int16x4_t quant_row1 = vld1_s16(quantptr + 1 * DCTSIZE + 4);
- int16x4_t quant_row2 = vld1_s16(quantptr + 2 * DCTSIZE + 4);
- int16x4_t quant_row3 = vld1_s16(quantptr + 3 * DCTSIZE + 4);
- int16x4_t quant_row4 = vld1_s16(quantptr + 4 * DCTSIZE + 4);
- int16x4_t quant_row5 = vld1_s16(quantptr + 5 * DCTSIZE + 4);
- int16x4_t quant_row6 = vld1_s16(quantptr + 6 * DCTSIZE + 4);
- int16x4_t quant_row7 = vld1_s16(quantptr + 7 * DCTSIZE + 4);
-
- /* Even part: dequantize DCT coefficients. */
- int16x4_t tmp0 = vget_high_s16(row0);
- int16x4_t tmp1 = vmul_s16(vget_high_s16(row2), quant_row2);
- int16x4_t tmp2 = vmul_s16(vget_high_s16(row4), quant_row4);
- int16x4_t tmp3 = vmul_s16(vget_high_s16(row6), quant_row6);
-
- int16x4_t tmp10 = vadd_s16(tmp0, tmp2); /* phase 3 */
- int16x4_t tmp11 = vsub_s16(tmp0, tmp2);
-
- int16x4_t tmp13 = vadd_s16(tmp1, tmp3); /* phases 5-3 */
- int16x4_t tmp1_sub_tmp3 = vsub_s16(tmp1, tmp3);
- int16x4_t tmp12 = vqdmulh_lane_s16(tmp1_sub_tmp3, consts, 1);
- tmp12 = vadd_s16(tmp12, tmp1_sub_tmp3);
- tmp12 = vsub_s16(tmp12, tmp13);
-
- tmp0 = vadd_s16(tmp10, tmp13); /* phase 2 */
- tmp3 = vsub_s16(tmp10, tmp13);
- tmp1 = vadd_s16(tmp11, tmp12);
- tmp2 = vsub_s16(tmp11, tmp12);
-
- /* Odd part: dequantize DCT coefficients. */
- int16x4_t tmp4 = vmul_s16(vget_high_s16(row1), quant_row1);
- int16x4_t tmp5 = vmul_s16(vget_high_s16(row3), quant_row3);
- int16x4_t tmp6 = vmul_s16(vget_high_s16(row5), quant_row5);
- int16x4_t tmp7 = vmul_s16(vget_high_s16(row7), quant_row7);
-
- int16x4_t z13 = vadd_s16(tmp6, tmp5); /* phase 6 */
- int16x4_t neg_z10 = vsub_s16(tmp5, tmp6);
- int16x4_t z11 = vadd_s16(tmp4, tmp7);
- int16x4_t z12 = vsub_s16(tmp4, tmp7);
-
- tmp7 = vadd_s16(z11, z13); /* phase 5 */
- int16x4_t z11_sub_z13 = vsub_s16(z11, z13);
- tmp11 = vqdmulh_lane_s16(z11_sub_z13, consts, 1);
- tmp11 = vadd_s16(tmp11, z11_sub_z13);
-
- int16x4_t z10_add_z12 = vsub_s16(z12, neg_z10);
- int16x4_t z5 = vqdmulh_lane_s16(z10_add_z12, consts, 2);
- z5 = vadd_s16(z5, z10_add_z12);
- tmp10 = vqdmulh_lane_s16(z12, consts, 0);
- tmp10 = vadd_s16(tmp10, z12);
- tmp10 = vsub_s16(tmp10, z5);
- tmp12 = vqdmulh_lane_s16(neg_z10, consts, 3);
- tmp12 = vadd_s16(tmp12, vadd_s16(neg_z10, neg_z10));
- tmp12 = vadd_s16(tmp12, z5);
-
- tmp6 = vsub_s16(tmp12, tmp7); /* phase 2 */
- tmp5 = vsub_s16(tmp11, tmp6);
- tmp4 = vadd_s16(tmp10, tmp5);
-
- row0 = vcombine_s16(dcval, vadd_s16(tmp0, tmp7));
- row7 = vcombine_s16(dcval, vsub_s16(tmp0, tmp7));
- row1 = vcombine_s16(dcval, vadd_s16(tmp1, tmp6));
- row6 = vcombine_s16(dcval, vsub_s16(tmp1, tmp6));
- row2 = vcombine_s16(dcval, vadd_s16(tmp2, tmp5));
- row5 = vcombine_s16(dcval, vsub_s16(tmp2, tmp5));
- row4 = vcombine_s16(dcval, vadd_s16(tmp3, tmp4));
- row3 = vcombine_s16(dcval, vsub_s16(tmp3, tmp4));
- } else if (right_ac_bitmap == 0) {
- /* AC coefficients are zero for columns 4, 5, 6, and 7.
- * Use DC values for these columns.
- */
- int16x4_t dcval = vget_high_s16(row0);
-
- /* Commence regular fast IDCT computation for columns 0, 1, 2, and 3. */
-
- /* Load quantization table. */
- int16x4_t quant_row1 = vld1_s16(quantptr + 1 * DCTSIZE);
- int16x4_t quant_row2 = vld1_s16(quantptr + 2 * DCTSIZE);
- int16x4_t quant_row3 = vld1_s16(quantptr + 3 * DCTSIZE);
- int16x4_t quant_row4 = vld1_s16(quantptr + 4 * DCTSIZE);
- int16x4_t quant_row5 = vld1_s16(quantptr + 5 * DCTSIZE);
- int16x4_t quant_row6 = vld1_s16(quantptr + 6 * DCTSIZE);
- int16x4_t quant_row7 = vld1_s16(quantptr + 7 * DCTSIZE);
-
- /* Even part: dequantize DCT coefficients. */
- int16x4_t tmp0 = vget_low_s16(row0);
- int16x4_t tmp1 = vmul_s16(vget_low_s16(row2), quant_row2);
- int16x4_t tmp2 = vmul_s16(vget_low_s16(row4), quant_row4);
- int16x4_t tmp3 = vmul_s16(vget_low_s16(row6), quant_row6);
-
- int16x4_t tmp10 = vadd_s16(tmp0, tmp2); /* phase 3 */
- int16x4_t tmp11 = vsub_s16(tmp0, tmp2);
-
- int16x4_t tmp13 = vadd_s16(tmp1, tmp3); /* phases 5-3 */
- int16x4_t tmp1_sub_tmp3 = vsub_s16(tmp1, tmp3);
- int16x4_t tmp12 = vqdmulh_lane_s16(tmp1_sub_tmp3, consts, 1);
- tmp12 = vadd_s16(tmp12, tmp1_sub_tmp3);
- tmp12 = vsub_s16(tmp12, tmp13);
-
- tmp0 = vadd_s16(tmp10, tmp13); /* phase 2 */
- tmp3 = vsub_s16(tmp10, tmp13);
- tmp1 = vadd_s16(tmp11, tmp12);
- tmp2 = vsub_s16(tmp11, tmp12);
-
- /* Odd part: dequantize DCT coefficients. */
- int16x4_t tmp4 = vmul_s16(vget_low_s16(row1), quant_row1);
- int16x4_t tmp5 = vmul_s16(vget_low_s16(row3), quant_row3);
- int16x4_t tmp6 = vmul_s16(vget_low_s16(row5), quant_row5);
- int16x4_t tmp7 = vmul_s16(vget_low_s16(row7), quant_row7);
-
- int16x4_t z13 = vadd_s16(tmp6, tmp5); /* phase 6 */
- int16x4_t neg_z10 = vsub_s16(tmp5, tmp6);
- int16x4_t z11 = vadd_s16(tmp4, tmp7);
- int16x4_t z12 = vsub_s16(tmp4, tmp7);
-
- tmp7 = vadd_s16(z11, z13); /* phase 5 */
- int16x4_t z11_sub_z13 = vsub_s16(z11, z13);
- tmp11 = vqdmulh_lane_s16(z11_sub_z13, consts, 1);
- tmp11 = vadd_s16(tmp11, z11_sub_z13);
-
- int16x4_t z10_add_z12 = vsub_s16(z12, neg_z10);
- int16x4_t z5 = vqdmulh_lane_s16(z10_add_z12, consts, 2);
- z5 = vadd_s16(z5, z10_add_z12);
- tmp10 = vqdmulh_lane_s16(z12, consts, 0);
- tmp10 = vadd_s16(tmp10, z12);
- tmp10 = vsub_s16(tmp10, z5);
- tmp12 = vqdmulh_lane_s16(neg_z10, consts, 3);
- tmp12 = vadd_s16(tmp12, vadd_s16(neg_z10, neg_z10));
- tmp12 = vadd_s16(tmp12, z5);
-
- tmp6 = vsub_s16(tmp12, tmp7); /* phase 2 */
- tmp5 = vsub_s16(tmp11, tmp6);
- tmp4 = vadd_s16(tmp10, tmp5);
-
- row0 = vcombine_s16(vadd_s16(tmp0, tmp7), dcval);
- row7 = vcombine_s16(vsub_s16(tmp0, tmp7), dcval);
- row1 = vcombine_s16(vadd_s16(tmp1, tmp6), dcval);
- row6 = vcombine_s16(vsub_s16(tmp1, tmp6), dcval);
- row2 = vcombine_s16(vadd_s16(tmp2, tmp5), dcval);
- row5 = vcombine_s16(vsub_s16(tmp2, tmp5), dcval);
- row4 = vcombine_s16(vadd_s16(tmp3, tmp4), dcval);
- row3 = vcombine_s16(vsub_s16(tmp3, tmp4), dcval);
- } else {
- /* Some AC coefficients are non-zero; full IDCT calculation required. */
-
- /* Load quantization table. */
- int16x8_t quant_row1 = vld1q_s16(quantptr + 1 * DCTSIZE);
- int16x8_t quant_row2 = vld1q_s16(quantptr + 2 * DCTSIZE);
- int16x8_t quant_row3 = vld1q_s16(quantptr + 3 * DCTSIZE);
- int16x8_t quant_row4 = vld1q_s16(quantptr + 4 * DCTSIZE);
- int16x8_t quant_row5 = vld1q_s16(quantptr + 5 * DCTSIZE);
- int16x8_t quant_row6 = vld1q_s16(quantptr + 6 * DCTSIZE);
- int16x8_t quant_row7 = vld1q_s16(quantptr + 7 * DCTSIZE);
-
- /* Even part: dequantize DCT coefficients. */
- int16x8_t tmp0 = row0;
- int16x8_t tmp1 = vmulq_s16(row2, quant_row2);
- int16x8_t tmp2 = vmulq_s16(row4, quant_row4);
- int16x8_t tmp3 = vmulq_s16(row6, quant_row6);
-
- int16x8_t tmp10 = vaddq_s16(tmp0, tmp2); /* phase 3 */
- int16x8_t tmp11 = vsubq_s16(tmp0, tmp2);
-
- int16x8_t tmp13 = vaddq_s16(tmp1, tmp3); /* phases 5-3 */
- int16x8_t tmp1_sub_tmp3 = vsubq_s16(tmp1, tmp3);
- int16x8_t tmp12 = vqdmulhq_lane_s16(tmp1_sub_tmp3, consts, 1);
- tmp12 = vaddq_s16(tmp12, tmp1_sub_tmp3);
- tmp12 = vsubq_s16(tmp12, tmp13);
-
- tmp0 = vaddq_s16(tmp10, tmp13); /* phase 2 */
- tmp3 = vsubq_s16(tmp10, tmp13);
- tmp1 = vaddq_s16(tmp11, tmp12);
- tmp2 = vsubq_s16(tmp11, tmp12);
-
- /* Odd part: dequantize DCT coefficients. */
- int16x8_t tmp4 = vmulq_s16(row1, quant_row1);
- int16x8_t tmp5 = vmulq_s16(row3, quant_row3);
- int16x8_t tmp6 = vmulq_s16(row5, quant_row5);
- int16x8_t tmp7 = vmulq_s16(row7, quant_row7);
-
- int16x8_t z13 = vaddq_s16(tmp6, tmp5); /* phase 6 */
- int16x8_t neg_z10 = vsubq_s16(tmp5, tmp6);
- int16x8_t z11 = vaddq_s16(tmp4, tmp7);
- int16x8_t z12 = vsubq_s16(tmp4, tmp7);
-
- tmp7 = vaddq_s16(z11, z13); /* phase 5 */
- int16x8_t z11_sub_z13 = vsubq_s16(z11, z13);
- tmp11 = vqdmulhq_lane_s16(z11_sub_z13, consts, 1);
- tmp11 = vaddq_s16(tmp11, z11_sub_z13);
-
- int16x8_t z10_add_z12 = vsubq_s16(z12, neg_z10);
- int16x8_t z5 = vqdmulhq_lane_s16(z10_add_z12, consts, 2);
- z5 = vaddq_s16(z5, z10_add_z12);
- tmp10 = vqdmulhq_lane_s16(z12, consts, 0);
- tmp10 = vaddq_s16(tmp10, z12);
- tmp10 = vsubq_s16(tmp10, z5);
- tmp12 = vqdmulhq_lane_s16(neg_z10, consts, 3);
- tmp12 = vaddq_s16(tmp12, vaddq_s16(neg_z10, neg_z10));
- tmp12 = vaddq_s16(tmp12, z5);
-
- tmp6 = vsubq_s16(tmp12, tmp7); /* phase 2 */
- tmp5 = vsubq_s16(tmp11, tmp6);
- tmp4 = vaddq_s16(tmp10, tmp5);
-
- row0 = vaddq_s16(tmp0, tmp7);
- row7 = vsubq_s16(tmp0, tmp7);
- row1 = vaddq_s16(tmp1, tmp6);
- row6 = vsubq_s16(tmp1, tmp6);
- row2 = vaddq_s16(tmp2, tmp5);
- row5 = vsubq_s16(tmp2, tmp5);
- row4 = vaddq_s16(tmp3, tmp4);
- row3 = vsubq_s16(tmp3, tmp4);
- }
-
- /* Transpose rows to work on columns in pass 2. */
- int16x8x2_t rows_01 = vtrnq_s16(row0, row1);
- int16x8x2_t rows_23 = vtrnq_s16(row2, row3);
- int16x8x2_t rows_45 = vtrnq_s16(row4, row5);
- int16x8x2_t rows_67 = vtrnq_s16(row6, row7);
-
- int32x4x2_t rows_0145_l = vtrnq_s32(vreinterpretq_s32_s16(rows_01.val[0]),
- vreinterpretq_s32_s16(rows_45.val[0]));
- int32x4x2_t rows_0145_h = vtrnq_s32(vreinterpretq_s32_s16(rows_01.val[1]),
- vreinterpretq_s32_s16(rows_45.val[1]));
- int32x4x2_t rows_2367_l = vtrnq_s32(vreinterpretq_s32_s16(rows_23.val[0]),
- vreinterpretq_s32_s16(rows_67.val[0]));
- int32x4x2_t rows_2367_h = vtrnq_s32(vreinterpretq_s32_s16(rows_23.val[1]),
- vreinterpretq_s32_s16(rows_67.val[1]));
-
- int32x4x2_t cols_04 = vzipq_s32(rows_0145_l.val[0], rows_2367_l.val[0]);
- int32x4x2_t cols_15 = vzipq_s32(rows_0145_h.val[0], rows_2367_h.val[0]);
- int32x4x2_t cols_26 = vzipq_s32(rows_0145_l.val[1], rows_2367_l.val[1]);
- int32x4x2_t cols_37 = vzipq_s32(rows_0145_h.val[1], rows_2367_h.val[1]);
-
- int16x8_t col0 = vreinterpretq_s16_s32(cols_04.val[0]);
- int16x8_t col1 = vreinterpretq_s16_s32(cols_15.val[0]);
- int16x8_t col2 = vreinterpretq_s16_s32(cols_26.val[0]);
- int16x8_t col3 = vreinterpretq_s16_s32(cols_37.val[0]);
- int16x8_t col4 = vreinterpretq_s16_s32(cols_04.val[1]);
- int16x8_t col5 = vreinterpretq_s16_s32(cols_15.val[1]);
- int16x8_t col6 = vreinterpretq_s16_s32(cols_26.val[1]);
- int16x8_t col7 = vreinterpretq_s16_s32(cols_37.val[1]);
-
- /* 1-D IDCT, pass 2 */
-
- /* Even part */
- int16x8_t tmp10 = vaddq_s16(col0, col4);
- int16x8_t tmp11 = vsubq_s16(col0, col4);
-
- int16x8_t tmp13 = vaddq_s16(col2, col6);
- int16x8_t col2_sub_col6 = vsubq_s16(col2, col6);
- int16x8_t tmp12 = vqdmulhq_lane_s16(col2_sub_col6, consts, 1);
- tmp12 = vaddq_s16(tmp12, col2_sub_col6);
- tmp12 = vsubq_s16(tmp12, tmp13);
-
- int16x8_t tmp0 = vaddq_s16(tmp10, tmp13);
- int16x8_t tmp3 = vsubq_s16(tmp10, tmp13);
- int16x8_t tmp1 = vaddq_s16(tmp11, tmp12);
- int16x8_t tmp2 = vsubq_s16(tmp11, tmp12);
-
- /* Odd part */
- int16x8_t z13 = vaddq_s16(col5, col3);
- int16x8_t neg_z10 = vsubq_s16(col3, col5);
- int16x8_t z11 = vaddq_s16(col1, col7);
- int16x8_t z12 = vsubq_s16(col1, col7);
-
- int16x8_t tmp7 = vaddq_s16(z11, z13); /* phase 5 */
- int16x8_t z11_sub_z13 = vsubq_s16(z11, z13);
- tmp11 = vqdmulhq_lane_s16(z11_sub_z13, consts, 1);
- tmp11 = vaddq_s16(tmp11, z11_sub_z13);
-
- int16x8_t z10_add_z12 = vsubq_s16(z12, neg_z10);
- int16x8_t z5 = vqdmulhq_lane_s16(z10_add_z12, consts, 2);
- z5 = vaddq_s16(z5, z10_add_z12);
- tmp10 = vqdmulhq_lane_s16(z12, consts, 0);
- tmp10 = vaddq_s16(tmp10, z12);
- tmp10 = vsubq_s16(tmp10, z5);
- tmp12 = vqdmulhq_lane_s16(neg_z10, consts, 3);
- tmp12 = vaddq_s16(tmp12, vaddq_s16(neg_z10, neg_z10));
- tmp12 = vaddq_s16(tmp12, z5);
-
- int16x8_t tmp6 = vsubq_s16(tmp12, tmp7); /* phase 2 */
- int16x8_t tmp5 = vsubq_s16(tmp11, tmp6);
- int16x8_t tmp4 = vaddq_s16(tmp10, tmp5);
-
- col0 = vaddq_s16(tmp0, tmp7);
- col7 = vsubq_s16(tmp0, tmp7);
- col1 = vaddq_s16(tmp1, tmp6);
- col6 = vsubq_s16(tmp1, tmp6);
- col2 = vaddq_s16(tmp2, tmp5);
- col5 = vsubq_s16(tmp2, tmp5);
- col4 = vaddq_s16(tmp3, tmp4);
- col3 = vsubq_s16(tmp3, tmp4);
-
- /* Scale down by a factor of 8, narrowing to 8-bit. */
- int8x16_t cols_01_s8 = vcombine_s8(vqshrn_n_s16(col0, PASS1_BITS + 3),
- vqshrn_n_s16(col1, PASS1_BITS + 3));
- int8x16_t cols_45_s8 = vcombine_s8(vqshrn_n_s16(col4, PASS1_BITS + 3),
- vqshrn_n_s16(col5, PASS1_BITS + 3));
- int8x16_t cols_23_s8 = vcombine_s8(vqshrn_n_s16(col2, PASS1_BITS + 3),
- vqshrn_n_s16(col3, PASS1_BITS + 3));
- int8x16_t cols_67_s8 = vcombine_s8(vqshrn_n_s16(col6, PASS1_BITS + 3),
- vqshrn_n_s16(col7, PASS1_BITS + 3));
- /* Clamp to range [0-255]. */
- uint8x16_t cols_01 =
- vreinterpretq_u8_s8
- (vaddq_s8(cols_01_s8, vreinterpretq_s8_u8(vdupq_n_u8(CENTERJSAMPLE))));
- uint8x16_t cols_45 =
- vreinterpretq_u8_s8
- (vaddq_s8(cols_45_s8, vreinterpretq_s8_u8(vdupq_n_u8(CENTERJSAMPLE))));
- uint8x16_t cols_23 =
- vreinterpretq_u8_s8
- (vaddq_s8(cols_23_s8, vreinterpretq_s8_u8(vdupq_n_u8(CENTERJSAMPLE))));
- uint8x16_t cols_67 =
- vreinterpretq_u8_s8
- (vaddq_s8(cols_67_s8, vreinterpretq_s8_u8(vdupq_n_u8(CENTERJSAMPLE))));
-
- /* Transpose block to prepare for store. */
- uint32x4x2_t cols_0415 = vzipq_u32(vreinterpretq_u32_u8(cols_01),
- vreinterpretq_u32_u8(cols_45));
- uint32x4x2_t cols_2637 = vzipq_u32(vreinterpretq_u32_u8(cols_23),
- vreinterpretq_u32_u8(cols_67));
-
- uint8x16x2_t cols_0145 = vtrnq_u8(vreinterpretq_u8_u32(cols_0415.val[0]),
- vreinterpretq_u8_u32(cols_0415.val[1]));
- uint8x16x2_t cols_2367 = vtrnq_u8(vreinterpretq_u8_u32(cols_2637.val[0]),
- vreinterpretq_u8_u32(cols_2637.val[1]));
- uint16x8x2_t rows_0426 = vtrnq_u16(vreinterpretq_u16_u8(cols_0145.val[0]),
- vreinterpretq_u16_u8(cols_2367.val[0]));
- uint16x8x2_t rows_1537 = vtrnq_u16(vreinterpretq_u16_u8(cols_0145.val[1]),
- vreinterpretq_u16_u8(cols_2367.val[1]));
-
- uint8x16_t rows_04 = vreinterpretq_u8_u16(rows_0426.val[0]);
- uint8x16_t rows_15 = vreinterpretq_u8_u16(rows_1537.val[0]);
- uint8x16_t rows_26 = vreinterpretq_u8_u16(rows_0426.val[1]);
- uint8x16_t rows_37 = vreinterpretq_u8_u16(rows_1537.val[1]);
-
- JSAMPROW outptr0 = output_buf[0] + output_col;
- JSAMPROW outptr1 = output_buf[1] + output_col;
- JSAMPROW outptr2 = output_buf[2] + output_col;
- JSAMPROW outptr3 = output_buf[3] + output_col;
- JSAMPROW outptr4 = output_buf[4] + output_col;
- JSAMPROW outptr5 = output_buf[5] + output_col;
- JSAMPROW outptr6 = output_buf[6] + output_col;
- JSAMPROW outptr7 = output_buf[7] + output_col;
-
- /* Store DCT block to memory. */
- vst1q_lane_u64((uint64_t *)outptr0, vreinterpretq_u64_u8(rows_04), 0);
- vst1q_lane_u64((uint64_t *)outptr1, vreinterpretq_u64_u8(rows_15), 0);
- vst1q_lane_u64((uint64_t *)outptr2, vreinterpretq_u64_u8(rows_26), 0);
- vst1q_lane_u64((uint64_t *)outptr3, vreinterpretq_u64_u8(rows_37), 0);
- vst1q_lane_u64((uint64_t *)outptr4, vreinterpretq_u64_u8(rows_04), 1);
- vst1q_lane_u64((uint64_t *)outptr5, vreinterpretq_u64_u8(rows_15), 1);
- vst1q_lane_u64((uint64_t *)outptr6, vreinterpretq_u64_u8(rows_26), 1);
- vst1q_lane_u64((uint64_t *)outptr7, vreinterpretq_u64_u8(rows_37), 1);
-}
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/jidctint-neon.c b/contrib/libs/libjpeg-turbo/simd/arm/jidctint-neon.c
deleted file mode 100644
index 043b652e6c..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/arm/jidctint-neon.c
+++ /dev/null
@@ -1,802 +0,0 @@
-/*
- * jidctint-neon.c - accurate integer IDCT (Arm Neon)
- *
- * Copyright (C) 2020, Arm Limited. All Rights Reserved.
- * Copyright (C) 2020, D. R. Commander. All Rights Reserved.
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- * claim that you wrote the original software. If you use this software
- * in a product, an acknowledgment in the product documentation would be
- * appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must not be
- * misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source distribution.
- */
-
-#define JPEG_INTERNALS
-#include "jconfigint.h"
-#include "../../jinclude.h"
-#include "../../jpeglib.h"
-#include "../../jsimd.h"
-#include "../../jdct.h"
-#include "../../jsimddct.h"
-#include "../jsimd.h"
-#include "align.h"
-#include "neon-compat.h"
-
-#include <arm_neon.h>
-
-
-#define CONST_BITS 13
-#define PASS1_BITS 2
-
-#define DESCALE_P1 (CONST_BITS - PASS1_BITS)
-#define DESCALE_P2 (CONST_BITS + PASS1_BITS + 3)
-
-/* The computation of the inverse DCT requires the use of constants known at
- * compile time. Scaled integer constants are used to avoid floating-point
- * arithmetic:
- * 0.298631336 = 2446 * 2^-13
- * 0.390180644 = 3196 * 2^-13
- * 0.541196100 = 4433 * 2^-13
- * 0.765366865 = 6270 * 2^-13
- * 0.899976223 = 7373 * 2^-13
- * 1.175875602 = 9633 * 2^-13
- * 1.501321110 = 12299 * 2^-13
- * 1.847759065 = 15137 * 2^-13
- * 1.961570560 = 16069 * 2^-13
- * 2.053119869 = 16819 * 2^-13
- * 2.562915447 = 20995 * 2^-13
- * 3.072711026 = 25172 * 2^-13
- */
-
-#define F_0_298 2446
-#define F_0_390 3196
-#define F_0_541 4433
-#define F_0_765 6270
-#define F_0_899 7373
-#define F_1_175 9633
-#define F_1_501 12299
-#define F_1_847 15137
-#define F_1_961 16069
-#define F_2_053 16819
-#define F_2_562 20995
-#define F_3_072 25172
-
-#define F_1_175_MINUS_1_961 (F_1_175 - F_1_961)
-#define F_1_175_MINUS_0_390 (F_1_175 - F_0_390)
-#define F_0_541_MINUS_1_847 (F_0_541 - F_1_847)
-#define F_3_072_MINUS_2_562 (F_3_072 - F_2_562)
-#define F_0_298_MINUS_0_899 (F_0_298 - F_0_899)
-#define F_1_501_MINUS_0_899 (F_1_501 - F_0_899)
-#define F_2_053_MINUS_2_562 (F_2_053 - F_2_562)
-#define F_0_541_PLUS_0_765 (F_0_541 + F_0_765)
-
-
-ALIGN(16) static const int16_t jsimd_idct_islow_neon_consts[] = {
- F_0_899, F_0_541,
- F_2_562, F_0_298_MINUS_0_899,
- F_1_501_MINUS_0_899, F_2_053_MINUS_2_562,
- F_0_541_PLUS_0_765, F_1_175,
- F_1_175_MINUS_0_390, F_0_541_MINUS_1_847,
- F_3_072_MINUS_2_562, F_1_175_MINUS_1_961,
- 0, 0, 0, 0
-};
-
-
-/* Forward declaration of regular and sparse IDCT helper functions */
-
-static INLINE void jsimd_idct_islow_pass1_regular(int16x4_t row0,
- int16x4_t row1,
- int16x4_t row2,
- int16x4_t row3,
- int16x4_t row4,
- int16x4_t row5,
- int16x4_t row6,
- int16x4_t row7,
- int16x4_t quant_row0,
- int16x4_t quant_row1,
- int16x4_t quant_row2,
- int16x4_t quant_row3,
- int16x4_t quant_row4,
- int16x4_t quant_row5,
- int16x4_t quant_row6,
- int16x4_t quant_row7,
- int16_t *workspace_1,
- int16_t *workspace_2);
-
-static INLINE void jsimd_idct_islow_pass1_sparse(int16x4_t row0,
- int16x4_t row1,
- int16x4_t row2,
- int16x4_t row3,
- int16x4_t quant_row0,
- int16x4_t quant_row1,
- int16x4_t quant_row2,
- int16x4_t quant_row3,
- int16_t *workspace_1,
- int16_t *workspace_2);
-
-static INLINE void jsimd_idct_islow_pass2_regular(int16_t *workspace,
- JSAMPARRAY output_buf,
- JDIMENSION output_col,
- unsigned buf_offset);
-
-static INLINE void jsimd_idct_islow_pass2_sparse(int16_t *workspace,
- JSAMPARRAY output_buf,
- JDIMENSION output_col,
- unsigned buf_offset);
-
-
-/* Perform dequantization and inverse DCT on one block of coefficients. For
- * reference, the C implementation (jpeg_idct_slow()) can be found in
- * jidctint.c.
- *
- * Optimization techniques used for fast data access:
- *
- * In each pass, the inverse DCT is computed for the left and right 4x8 halves
- * of the DCT block. This avoids spilling due to register pressure, and the
- * increased granularity allows for an optimized calculation depending on the
- * values of the DCT coefficients. Between passes, intermediate data is stored
- * in 4x8 workspace buffers.
- *
- * Transposing the 8x8 DCT block after each pass can be achieved by transposing
- * each of the four 4x4 quadrants and swapping quadrants 1 and 2 (refer to the
- * diagram below.) Swapping quadrants is cheap, since the second pass can just
- * swap the workspace buffer pointers.
- *
- * +-------+-------+ +-------+-------+
- * | | | | | |
- * | 0 | 1 | | 0 | 2 |
- * | | | transpose | | |
- * +-------+-------+ ------> +-------+-------+
- * | | | | | |
- * | 2 | 3 | | 1 | 3 |
- * | | | | | |
- * +-------+-------+ +-------+-------+
- *
- * Optimization techniques used to accelerate the inverse DCT calculation:
- *
- * In a DCT coefficient block, the coefficients are increasingly likely to be 0
- * as you move diagonally from top left to bottom right. If whole rows of
- * coefficients are 0, then the inverse DCT calculation can be simplified. On
- * the first pass of the inverse DCT, we test for three special cases before
- * defaulting to a full "regular" inverse DCT:
- *
- * 1) Coefficients in rows 4-7 are all zero. In this case, we perform a
- * "sparse" simplified inverse DCT on rows 0-3.
- * 2) AC coefficients (rows 1-7) are all zero. In this case, the inverse DCT
- * result is equal to the dequantized DC coefficients.
- * 3) AC and DC coefficients are all zero. In this case, the inverse DCT
- * result is all zero. For the left 4x8 half, this is handled identically
- * to Case 2 above. For the right 4x8 half, we do no work and signal that
- * the "sparse" algorithm is required for the second pass.
- *
- * In the second pass, only a single special case is tested: whether the AC and
- * DC coefficients were all zero in the right 4x8 block during the first pass
- * (refer to Case 3 above.) If this is the case, then a "sparse" variant of
- * the second pass is performed for both the left and right halves of the DCT
- * block. (The transposition after the first pass means that the right 4x8
- * block during the first pass becomes rows 4-7 during the second pass.)
- */
-
-void jsimd_idct_islow_neon(void *dct_table, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col)
-{
- ISLOW_MULT_TYPE *quantptr = dct_table;
-
- int16_t workspace_l[8 * DCTSIZE / 2];
- int16_t workspace_r[8 * DCTSIZE / 2];
-
- /* Compute IDCT first pass on left 4x8 coefficient block. */
-
- /* Load DCT coefficients in left 4x8 block. */
- int16x4_t row0 = vld1_s16(coef_block + 0 * DCTSIZE);
- int16x4_t row1 = vld1_s16(coef_block + 1 * DCTSIZE);
- int16x4_t row2 = vld1_s16(coef_block + 2 * DCTSIZE);
- int16x4_t row3 = vld1_s16(coef_block + 3 * DCTSIZE);
- int16x4_t row4 = vld1_s16(coef_block + 4 * DCTSIZE);
- int16x4_t row5 = vld1_s16(coef_block + 5 * DCTSIZE);
- int16x4_t row6 = vld1_s16(coef_block + 6 * DCTSIZE);
- int16x4_t row7 = vld1_s16(coef_block + 7 * DCTSIZE);
-
- /* Load quantization table for left 4x8 block. */
- int16x4_t quant_row0 = vld1_s16(quantptr + 0 * DCTSIZE);
- int16x4_t quant_row1 = vld1_s16(quantptr + 1 * DCTSIZE);
- int16x4_t quant_row2 = vld1_s16(quantptr + 2 * DCTSIZE);
- int16x4_t quant_row3 = vld1_s16(quantptr + 3 * DCTSIZE);
- int16x4_t quant_row4 = vld1_s16(quantptr + 4 * DCTSIZE);
- int16x4_t quant_row5 = vld1_s16(quantptr + 5 * DCTSIZE);
- int16x4_t quant_row6 = vld1_s16(quantptr + 6 * DCTSIZE);
- int16x4_t quant_row7 = vld1_s16(quantptr + 7 * DCTSIZE);
-
- /* Construct bitmap to test if DCT coefficients in left 4x8 block are 0. */
- int16x4_t bitmap = vorr_s16(row7, row6);
- bitmap = vorr_s16(bitmap, row5);
- bitmap = vorr_s16(bitmap, row4);
- int64_t bitmap_rows_4567 = vget_lane_s64(vreinterpret_s64_s16(bitmap), 0);
-
- if (bitmap_rows_4567 == 0) {
- bitmap = vorr_s16(bitmap, row3);
- bitmap = vorr_s16(bitmap, row2);
- bitmap = vorr_s16(bitmap, row1);
- int64_t left_ac_bitmap = vget_lane_s64(vreinterpret_s64_s16(bitmap), 0);
-
- if (left_ac_bitmap == 0) {
- int16x4_t dcval = vshl_n_s16(vmul_s16(row0, quant_row0), PASS1_BITS);
- int16x4x4_t quadrant = { { dcval, dcval, dcval, dcval } };
- /* Store 4x4 blocks to workspace, transposing in the process. */
- vst4_s16(workspace_l, quadrant);
- vst4_s16(workspace_r, quadrant);
- } else {
- jsimd_idct_islow_pass1_sparse(row0, row1, row2, row3, quant_row0,
- quant_row1, quant_row2, quant_row3,
- workspace_l, workspace_r);
- }
- } else {
- jsimd_idct_islow_pass1_regular(row0, row1, row2, row3, row4, row5,
- row6, row7, quant_row0, quant_row1,
- quant_row2, quant_row3, quant_row4,
- quant_row5, quant_row6, quant_row7,
- workspace_l, workspace_r);
- }
-
- /* Compute IDCT first pass on right 4x8 coefficient block. */
-
- /* Load DCT coefficients in right 4x8 block. */
- row0 = vld1_s16(coef_block + 0 * DCTSIZE + 4);
- row1 = vld1_s16(coef_block + 1 * DCTSIZE + 4);
- row2 = vld1_s16(coef_block + 2 * DCTSIZE + 4);
- row3 = vld1_s16(coef_block + 3 * DCTSIZE + 4);
- row4 = vld1_s16(coef_block + 4 * DCTSIZE + 4);
- row5 = vld1_s16(coef_block + 5 * DCTSIZE + 4);
- row6 = vld1_s16(coef_block + 6 * DCTSIZE + 4);
- row7 = vld1_s16(coef_block + 7 * DCTSIZE + 4);
-
- /* Load quantization table for right 4x8 block. */
- quant_row0 = vld1_s16(quantptr + 0 * DCTSIZE + 4);
- quant_row1 = vld1_s16(quantptr + 1 * DCTSIZE + 4);
- quant_row2 = vld1_s16(quantptr + 2 * DCTSIZE + 4);
- quant_row3 = vld1_s16(quantptr + 3 * DCTSIZE + 4);
- quant_row4 = vld1_s16(quantptr + 4 * DCTSIZE + 4);
- quant_row5 = vld1_s16(quantptr + 5 * DCTSIZE + 4);
- quant_row6 = vld1_s16(quantptr + 6 * DCTSIZE + 4);
- quant_row7 = vld1_s16(quantptr + 7 * DCTSIZE + 4);
-
- /* Construct bitmap to test if DCT coefficients in right 4x8 block are 0. */
- bitmap = vorr_s16(row7, row6);
- bitmap = vorr_s16(bitmap, row5);
- bitmap = vorr_s16(bitmap, row4);
- bitmap_rows_4567 = vget_lane_s64(vreinterpret_s64_s16(bitmap), 0);
- bitmap = vorr_s16(bitmap, row3);
- bitmap = vorr_s16(bitmap, row2);
- bitmap = vorr_s16(bitmap, row1);
- int64_t right_ac_bitmap = vget_lane_s64(vreinterpret_s64_s16(bitmap), 0);
-
- /* If this remains non-zero, a "regular" second pass will be performed. */
- int64_t right_ac_dc_bitmap = 1;
-
- if (right_ac_bitmap == 0) {
- bitmap = vorr_s16(bitmap, row0);
- right_ac_dc_bitmap = vget_lane_s64(vreinterpret_s64_s16(bitmap), 0);
-
- if (right_ac_dc_bitmap != 0) {
- int16x4_t dcval = vshl_n_s16(vmul_s16(row0, quant_row0), PASS1_BITS);
- int16x4x4_t quadrant = { { dcval, dcval, dcval, dcval } };
- /* Store 4x4 blocks to workspace, transposing in the process. */
- vst4_s16(workspace_l + 4 * DCTSIZE / 2, quadrant);
- vst4_s16(workspace_r + 4 * DCTSIZE / 2, quadrant);
- }
- } else {
- if (bitmap_rows_4567 == 0) {
- jsimd_idct_islow_pass1_sparse(row0, row1, row2, row3, quant_row0,
- quant_row1, quant_row2, quant_row3,
- workspace_l + 4 * DCTSIZE / 2,
- workspace_r + 4 * DCTSIZE / 2);
- } else {
- jsimd_idct_islow_pass1_regular(row0, row1, row2, row3, row4, row5,
- row6, row7, quant_row0, quant_row1,
- quant_row2, quant_row3, quant_row4,
- quant_row5, quant_row6, quant_row7,
- workspace_l + 4 * DCTSIZE / 2,
- workspace_r + 4 * DCTSIZE / 2);
- }
- }
-
- /* Second pass: compute IDCT on rows in workspace. */
-
- /* If all coefficients in right 4x8 block are 0, use "sparse" second pass. */
- if (right_ac_dc_bitmap == 0) {
- jsimd_idct_islow_pass2_sparse(workspace_l, output_buf, output_col, 0);
- jsimd_idct_islow_pass2_sparse(workspace_r, output_buf, output_col, 4);
- } else {
- jsimd_idct_islow_pass2_regular(workspace_l, output_buf, output_col, 0);
- jsimd_idct_islow_pass2_regular(workspace_r, output_buf, output_col, 4);
- }
-}
-
-
-/* Perform dequantization and the first pass of the accurate inverse DCT on a
- * 4x8 block of coefficients. (To process the full 8x8 DCT block, this
- * function-- or some other optimized variant-- needs to be called for both the
- * left and right 4x8 blocks.)
- *
- * This "regular" version assumes that no optimization can be made to the IDCT
- * calculation, since no useful set of AC coefficients is all 0.
- *
- * The original C implementation of the accurate IDCT (jpeg_idct_slow()) can be
- * found in jidctint.c. Algorithmic changes made here are documented inline.
- */
-
-static INLINE void jsimd_idct_islow_pass1_regular(int16x4_t row0,
- int16x4_t row1,
- int16x4_t row2,
- int16x4_t row3,
- int16x4_t row4,
- int16x4_t row5,
- int16x4_t row6,
- int16x4_t row7,
- int16x4_t quant_row0,
- int16x4_t quant_row1,
- int16x4_t quant_row2,
- int16x4_t quant_row3,
- int16x4_t quant_row4,
- int16x4_t quant_row5,
- int16x4_t quant_row6,
- int16x4_t quant_row7,
- int16_t *workspace_1,
- int16_t *workspace_2)
-{
- /* Load constants for IDCT computation. */
-#ifdef HAVE_VLD1_S16_X3
- const int16x4x3_t consts = vld1_s16_x3(jsimd_idct_islow_neon_consts);
-#else
- const int16x4_t consts1 = vld1_s16(jsimd_idct_islow_neon_consts);
- const int16x4_t consts2 = vld1_s16(jsimd_idct_islow_neon_consts + 4);
- const int16x4_t consts3 = vld1_s16(jsimd_idct_islow_neon_consts + 8);
- const int16x4x3_t consts = { { consts1, consts2, consts3 } };
-#endif
-
- /* Even part */
- int16x4_t z2_s16 = vmul_s16(row2, quant_row2);
- int16x4_t z3_s16 = vmul_s16(row6, quant_row6);
-
- int32x4_t tmp2 = vmull_lane_s16(z2_s16, consts.val[0], 1);
- int32x4_t tmp3 = vmull_lane_s16(z2_s16, consts.val[1], 2);
- tmp2 = vmlal_lane_s16(tmp2, z3_s16, consts.val[2], 1);
- tmp3 = vmlal_lane_s16(tmp3, z3_s16, consts.val[0], 1);
-
- z2_s16 = vmul_s16(row0, quant_row0);
- z3_s16 = vmul_s16(row4, quant_row4);
-
- int32x4_t tmp0 = vshll_n_s16(vadd_s16(z2_s16, z3_s16), CONST_BITS);
- int32x4_t tmp1 = vshll_n_s16(vsub_s16(z2_s16, z3_s16), CONST_BITS);
-
- int32x4_t tmp10 = vaddq_s32(tmp0, tmp3);
- int32x4_t tmp13 = vsubq_s32(tmp0, tmp3);
- int32x4_t tmp11 = vaddq_s32(tmp1, tmp2);
- int32x4_t tmp12 = vsubq_s32(tmp1, tmp2);
-
- /* Odd part */
- int16x4_t tmp0_s16 = vmul_s16(row7, quant_row7);
- int16x4_t tmp1_s16 = vmul_s16(row5, quant_row5);
- int16x4_t tmp2_s16 = vmul_s16(row3, quant_row3);
- int16x4_t tmp3_s16 = vmul_s16(row1, quant_row1);
-
- z3_s16 = vadd_s16(tmp0_s16, tmp2_s16);
- int16x4_t z4_s16 = vadd_s16(tmp1_s16, tmp3_s16);
-
- /* Implementation as per jpeg_idct_islow() in jidctint.c:
- * z5 = (z3 + z4) * 1.175875602;
- * z3 = z3 * -1.961570560; z4 = z4 * -0.390180644;
- * z3 += z5; z4 += z5;
- *
- * This implementation:
- * z3 = z3 * (1.175875602 - 1.961570560) + z4 * 1.175875602;
- * z4 = z3 * 1.175875602 + z4 * (1.175875602 - 0.390180644);
- */
-
- int32x4_t z3 = vmull_lane_s16(z3_s16, consts.val[2], 3);
- int32x4_t z4 = vmull_lane_s16(z3_s16, consts.val[1], 3);
- z3 = vmlal_lane_s16(z3, z4_s16, consts.val[1], 3);
- z4 = vmlal_lane_s16(z4, z4_s16, consts.val[2], 0);
-
- /* Implementation as per jpeg_idct_islow() in jidctint.c:
- * z1 = tmp0 + tmp3; z2 = tmp1 + tmp2;
- * tmp0 = tmp0 * 0.298631336; tmp1 = tmp1 * 2.053119869;
- * tmp2 = tmp2 * 3.072711026; tmp3 = tmp3 * 1.501321110;
- * z1 = z1 * -0.899976223; z2 = z2 * -2.562915447;
- * tmp0 += z1 + z3; tmp1 += z2 + z4;
- * tmp2 += z2 + z3; tmp3 += z1 + z4;
- *
- * This implementation:
- * tmp0 = tmp0 * (0.298631336 - 0.899976223) + tmp3 * -0.899976223;
- * tmp1 = tmp1 * (2.053119869 - 2.562915447) + tmp2 * -2.562915447;
- * tmp2 = tmp1 * -2.562915447 + tmp2 * (3.072711026 - 2.562915447);
- * tmp3 = tmp0 * -0.899976223 + tmp3 * (1.501321110 - 0.899976223);
- * tmp0 += z3; tmp1 += z4;
- * tmp2 += z3; tmp3 += z4;
- */
-
- tmp0 = vmull_lane_s16(tmp0_s16, consts.val[0], 3);
- tmp1 = vmull_lane_s16(tmp1_s16, consts.val[1], 1);
- tmp2 = vmull_lane_s16(tmp2_s16, consts.val[2], 2);
- tmp3 = vmull_lane_s16(tmp3_s16, consts.val[1], 0);
-
- tmp0 = vmlsl_lane_s16(tmp0, tmp3_s16, consts.val[0], 0);
- tmp1 = vmlsl_lane_s16(tmp1, tmp2_s16, consts.val[0], 2);
- tmp2 = vmlsl_lane_s16(tmp2, tmp1_s16, consts.val[0], 2);
- tmp3 = vmlsl_lane_s16(tmp3, tmp0_s16, consts.val[0], 0);
-
- tmp0 = vaddq_s32(tmp0, z3);
- tmp1 = vaddq_s32(tmp1, z4);
- tmp2 = vaddq_s32(tmp2, z3);
- tmp3 = vaddq_s32(tmp3, z4);
-
- /* Final output stage: descale and narrow to 16-bit. */
- int16x4x4_t rows_0123 = { {
- vrshrn_n_s32(vaddq_s32(tmp10, tmp3), DESCALE_P1),
- vrshrn_n_s32(vaddq_s32(tmp11, tmp2), DESCALE_P1),
- vrshrn_n_s32(vaddq_s32(tmp12, tmp1), DESCALE_P1),
- vrshrn_n_s32(vaddq_s32(tmp13, tmp0), DESCALE_P1)
- } };
- int16x4x4_t rows_4567 = { {
- vrshrn_n_s32(vsubq_s32(tmp13, tmp0), DESCALE_P1),
- vrshrn_n_s32(vsubq_s32(tmp12, tmp1), DESCALE_P1),
- vrshrn_n_s32(vsubq_s32(tmp11, tmp2), DESCALE_P1),
- vrshrn_n_s32(vsubq_s32(tmp10, tmp3), DESCALE_P1)
- } };
-
- /* Store 4x4 blocks to the intermediate workspace, ready for the second pass.
- * (VST4 transposes the blocks. We need to operate on rows in the next
- * pass.)
- */
- vst4_s16(workspace_1, rows_0123);
- vst4_s16(workspace_2, rows_4567);
-}
-
-
-/* Perform dequantization and the first pass of the accurate inverse DCT on a
- * 4x8 block of coefficients.
- *
- * This "sparse" version assumes that the AC coefficients in rows 4-7 are all
- * 0. This simplifies the IDCT calculation, accelerating overall performance.
- */
-
-static INLINE void jsimd_idct_islow_pass1_sparse(int16x4_t row0,
- int16x4_t row1,
- int16x4_t row2,
- int16x4_t row3,
- int16x4_t quant_row0,
- int16x4_t quant_row1,
- int16x4_t quant_row2,
- int16x4_t quant_row3,
- int16_t *workspace_1,
- int16_t *workspace_2)
-{
- /* Load constants for IDCT computation. */
-#ifdef HAVE_VLD1_S16_X3
- const int16x4x3_t consts = vld1_s16_x3(jsimd_idct_islow_neon_consts);
-#else
- const int16x4_t consts1 = vld1_s16(jsimd_idct_islow_neon_consts);
- const int16x4_t consts2 = vld1_s16(jsimd_idct_islow_neon_consts + 4);
- const int16x4_t consts3 = vld1_s16(jsimd_idct_islow_neon_consts + 8);
- const int16x4x3_t consts = { { consts1, consts2, consts3 } };
-#endif
-
- /* Even part (z3 is all 0) */
- int16x4_t z2_s16 = vmul_s16(row2, quant_row2);
-
- int32x4_t tmp2 = vmull_lane_s16(z2_s16, consts.val[0], 1);
- int32x4_t tmp3 = vmull_lane_s16(z2_s16, consts.val[1], 2);
-
- z2_s16 = vmul_s16(row0, quant_row0);
- int32x4_t tmp0 = vshll_n_s16(z2_s16, CONST_BITS);
- int32x4_t tmp1 = vshll_n_s16(z2_s16, CONST_BITS);
-
- int32x4_t tmp10 = vaddq_s32(tmp0, tmp3);
- int32x4_t tmp13 = vsubq_s32(tmp0, tmp3);
- int32x4_t tmp11 = vaddq_s32(tmp1, tmp2);
- int32x4_t tmp12 = vsubq_s32(tmp1, tmp2);
-
- /* Odd part (tmp0 and tmp1 are both all 0) */
- int16x4_t tmp2_s16 = vmul_s16(row3, quant_row3);
- int16x4_t tmp3_s16 = vmul_s16(row1, quant_row1);
-
- int16x4_t z3_s16 = tmp2_s16;
- int16x4_t z4_s16 = tmp3_s16;
-
- int32x4_t z3 = vmull_lane_s16(z3_s16, consts.val[2], 3);
- int32x4_t z4 = vmull_lane_s16(z3_s16, consts.val[1], 3);
- z3 = vmlal_lane_s16(z3, z4_s16, consts.val[1], 3);
- z4 = vmlal_lane_s16(z4, z4_s16, consts.val[2], 0);
-
- tmp0 = vmlsl_lane_s16(z3, tmp3_s16, consts.val[0], 0);
- tmp1 = vmlsl_lane_s16(z4, tmp2_s16, consts.val[0], 2);
- tmp2 = vmlal_lane_s16(z3, tmp2_s16, consts.val[2], 2);
- tmp3 = vmlal_lane_s16(z4, tmp3_s16, consts.val[1], 0);
-
- /* Final output stage: descale and narrow to 16-bit. */
- int16x4x4_t rows_0123 = { {
- vrshrn_n_s32(vaddq_s32(tmp10, tmp3), DESCALE_P1),
- vrshrn_n_s32(vaddq_s32(tmp11, tmp2), DESCALE_P1),
- vrshrn_n_s32(vaddq_s32(tmp12, tmp1), DESCALE_P1),
- vrshrn_n_s32(vaddq_s32(tmp13, tmp0), DESCALE_P1)
- } };
- int16x4x4_t rows_4567 = { {
- vrshrn_n_s32(vsubq_s32(tmp13, tmp0), DESCALE_P1),
- vrshrn_n_s32(vsubq_s32(tmp12, tmp1), DESCALE_P1),
- vrshrn_n_s32(vsubq_s32(tmp11, tmp2), DESCALE_P1),
- vrshrn_n_s32(vsubq_s32(tmp10, tmp3), DESCALE_P1)
- } };
-
- /* Store 4x4 blocks to the intermediate workspace, ready for the second pass.
- * (VST4 transposes the blocks. We need to operate on rows in the next
- * pass.)
- */
- vst4_s16(workspace_1, rows_0123);
- vst4_s16(workspace_2, rows_4567);
-}
-
-
-/* Perform the second pass of the accurate inverse DCT on a 4x8 block of
- * coefficients. (To process the full 8x8 DCT block, this function-- or some
- * other optimized variant-- needs to be called for both the right and left 4x8
- * blocks.)
- *
- * This "regular" version assumes that no optimization can be made to the IDCT
- * calculation, since no useful set of coefficient values are all 0 after the
- * first pass.
- *
- * Again, the original C implementation of the accurate IDCT (jpeg_idct_slow())
- * can be found in jidctint.c. Algorithmic changes made here are documented
- * inline.
- */
-
-static INLINE void jsimd_idct_islow_pass2_regular(int16_t *workspace,
- JSAMPARRAY output_buf,
- JDIMENSION output_col,
- unsigned buf_offset)
-{
- /* Load constants for IDCT computation. */
-#ifdef HAVE_VLD1_S16_X3
- const int16x4x3_t consts = vld1_s16_x3(jsimd_idct_islow_neon_consts);
-#else
- const int16x4_t consts1 = vld1_s16(jsimd_idct_islow_neon_consts);
- const int16x4_t consts2 = vld1_s16(jsimd_idct_islow_neon_consts + 4);
- const int16x4_t consts3 = vld1_s16(jsimd_idct_islow_neon_consts + 8);
- const int16x4x3_t consts = { { consts1, consts2, consts3 } };
-#endif
-
- /* Even part */
- int16x4_t z2_s16 = vld1_s16(workspace + 2 * DCTSIZE / 2);
- int16x4_t z3_s16 = vld1_s16(workspace + 6 * DCTSIZE / 2);
-
- int32x4_t tmp2 = vmull_lane_s16(z2_s16, consts.val[0], 1);
- int32x4_t tmp3 = vmull_lane_s16(z2_s16, consts.val[1], 2);
- tmp2 = vmlal_lane_s16(tmp2, z3_s16, consts.val[2], 1);
- tmp3 = vmlal_lane_s16(tmp3, z3_s16, consts.val[0], 1);
-
- z2_s16 = vld1_s16(workspace + 0 * DCTSIZE / 2);
- z3_s16 = vld1_s16(workspace + 4 * DCTSIZE / 2);
-
- int32x4_t tmp0 = vshll_n_s16(vadd_s16(z2_s16, z3_s16), CONST_BITS);
- int32x4_t tmp1 = vshll_n_s16(vsub_s16(z2_s16, z3_s16), CONST_BITS);
-
- int32x4_t tmp10 = vaddq_s32(tmp0, tmp3);
- int32x4_t tmp13 = vsubq_s32(tmp0, tmp3);
- int32x4_t tmp11 = vaddq_s32(tmp1, tmp2);
- int32x4_t tmp12 = vsubq_s32(tmp1, tmp2);
-
- /* Odd part */
- int16x4_t tmp0_s16 = vld1_s16(workspace + 7 * DCTSIZE / 2);
- int16x4_t tmp1_s16 = vld1_s16(workspace + 5 * DCTSIZE / 2);
- int16x4_t tmp2_s16 = vld1_s16(workspace + 3 * DCTSIZE / 2);
- int16x4_t tmp3_s16 = vld1_s16(workspace + 1 * DCTSIZE / 2);
-
- z3_s16 = vadd_s16(tmp0_s16, tmp2_s16);
- int16x4_t z4_s16 = vadd_s16(tmp1_s16, tmp3_s16);
-
- /* Implementation as per jpeg_idct_islow() in jidctint.c:
- * z5 = (z3 + z4) * 1.175875602;
- * z3 = z3 * -1.961570560; z4 = z4 * -0.390180644;
- * z3 += z5; z4 += z5;
- *
- * This implementation:
- * z3 = z3 * (1.175875602 - 1.961570560) + z4 * 1.175875602;
- * z4 = z3 * 1.175875602 + z4 * (1.175875602 - 0.390180644);
- */
-
- int32x4_t z3 = vmull_lane_s16(z3_s16, consts.val[2], 3);
- int32x4_t z4 = vmull_lane_s16(z3_s16, consts.val[1], 3);
- z3 = vmlal_lane_s16(z3, z4_s16, consts.val[1], 3);
- z4 = vmlal_lane_s16(z4, z4_s16, consts.val[2], 0);
-
- /* Implementation as per jpeg_idct_islow() in jidctint.c:
- * z1 = tmp0 + tmp3; z2 = tmp1 + tmp2;
- * tmp0 = tmp0 * 0.298631336; tmp1 = tmp1 * 2.053119869;
- * tmp2 = tmp2 * 3.072711026; tmp3 = tmp3 * 1.501321110;
- * z1 = z1 * -0.899976223; z2 = z2 * -2.562915447;
- * tmp0 += z1 + z3; tmp1 += z2 + z4;
- * tmp2 += z2 + z3; tmp3 += z1 + z4;
- *
- * This implementation:
- * tmp0 = tmp0 * (0.298631336 - 0.899976223) + tmp3 * -0.899976223;
- * tmp1 = tmp1 * (2.053119869 - 2.562915447) + tmp2 * -2.562915447;
- * tmp2 = tmp1 * -2.562915447 + tmp2 * (3.072711026 - 2.562915447);
- * tmp3 = tmp0 * -0.899976223 + tmp3 * (1.501321110 - 0.899976223);
- * tmp0 += z3; tmp1 += z4;
- * tmp2 += z3; tmp3 += z4;
- */
-
- tmp0 = vmull_lane_s16(tmp0_s16, consts.val[0], 3);
- tmp1 = vmull_lane_s16(tmp1_s16, consts.val[1], 1);
- tmp2 = vmull_lane_s16(tmp2_s16, consts.val[2], 2);
- tmp3 = vmull_lane_s16(tmp3_s16, consts.val[1], 0);
-
- tmp0 = vmlsl_lane_s16(tmp0, tmp3_s16, consts.val[0], 0);
- tmp1 = vmlsl_lane_s16(tmp1, tmp2_s16, consts.val[0], 2);
- tmp2 = vmlsl_lane_s16(tmp2, tmp1_s16, consts.val[0], 2);
- tmp3 = vmlsl_lane_s16(tmp3, tmp0_s16, consts.val[0], 0);
-
- tmp0 = vaddq_s32(tmp0, z3);
- tmp1 = vaddq_s32(tmp1, z4);
- tmp2 = vaddq_s32(tmp2, z3);
- tmp3 = vaddq_s32(tmp3, z4);
-
- /* Final output stage: descale and narrow to 16-bit. */
- int16x8_t cols_02_s16 = vcombine_s16(vaddhn_s32(tmp10, tmp3),
- vaddhn_s32(tmp12, tmp1));
- int16x8_t cols_13_s16 = vcombine_s16(vaddhn_s32(tmp11, tmp2),
- vaddhn_s32(tmp13, tmp0));
- int16x8_t cols_46_s16 = vcombine_s16(vsubhn_s32(tmp13, tmp0),
- vsubhn_s32(tmp11, tmp2));
- int16x8_t cols_57_s16 = vcombine_s16(vsubhn_s32(tmp12, tmp1),
- vsubhn_s32(tmp10, tmp3));
- /* Descale and narrow to 8-bit. */
- int8x8_t cols_02_s8 = vqrshrn_n_s16(cols_02_s16, DESCALE_P2 - 16);
- int8x8_t cols_13_s8 = vqrshrn_n_s16(cols_13_s16, DESCALE_P2 - 16);
- int8x8_t cols_46_s8 = vqrshrn_n_s16(cols_46_s16, DESCALE_P2 - 16);
- int8x8_t cols_57_s8 = vqrshrn_n_s16(cols_57_s16, DESCALE_P2 - 16);
- /* Clamp to range [0-255]. */
- uint8x8_t cols_02_u8 = vadd_u8(vreinterpret_u8_s8(cols_02_s8),
- vdup_n_u8(CENTERJSAMPLE));
- uint8x8_t cols_13_u8 = vadd_u8(vreinterpret_u8_s8(cols_13_s8),
- vdup_n_u8(CENTERJSAMPLE));
- uint8x8_t cols_46_u8 = vadd_u8(vreinterpret_u8_s8(cols_46_s8),
- vdup_n_u8(CENTERJSAMPLE));
- uint8x8_t cols_57_u8 = vadd_u8(vreinterpret_u8_s8(cols_57_s8),
- vdup_n_u8(CENTERJSAMPLE));
-
- /* Transpose 4x8 block and store to memory. (Zipping adjacent columns
- * together allows us to store 16-bit elements.)
- */
- uint8x8x2_t cols_01_23 = vzip_u8(cols_02_u8, cols_13_u8);
- uint8x8x2_t cols_45_67 = vzip_u8(cols_46_u8, cols_57_u8);
- uint16x4x4_t cols_01_23_45_67 = { {
- vreinterpret_u16_u8(cols_01_23.val[0]),
- vreinterpret_u16_u8(cols_01_23.val[1]),
- vreinterpret_u16_u8(cols_45_67.val[0]),
- vreinterpret_u16_u8(cols_45_67.val[1])
- } };
-
- JSAMPROW outptr0 = output_buf[buf_offset + 0] + output_col;
- JSAMPROW outptr1 = output_buf[buf_offset + 1] + output_col;
- JSAMPROW outptr2 = output_buf[buf_offset + 2] + output_col;
- JSAMPROW outptr3 = output_buf[buf_offset + 3] + output_col;
- /* VST4 of 16-bit elements completes the transpose. */
- vst4_lane_u16((uint16_t *)outptr0, cols_01_23_45_67, 0);
- vst4_lane_u16((uint16_t *)outptr1, cols_01_23_45_67, 1);
- vst4_lane_u16((uint16_t *)outptr2, cols_01_23_45_67, 2);
- vst4_lane_u16((uint16_t *)outptr3, cols_01_23_45_67, 3);
-}
-
-
-/* Performs the second pass of the accurate inverse DCT on a 4x8 block
- * of coefficients.
- *
- * This "sparse" version assumes that the coefficient values (after the first
- * pass) in rows 4-7 are all 0. This simplifies the IDCT calculation,
- * accelerating overall performance.
- */
-
-static INLINE void jsimd_idct_islow_pass2_sparse(int16_t *workspace,
- JSAMPARRAY output_buf,
- JDIMENSION output_col,
- unsigned buf_offset)
-{
- /* Load constants for IDCT computation. */
-#ifdef HAVE_VLD1_S16_X3
- const int16x4x3_t consts = vld1_s16_x3(jsimd_idct_islow_neon_consts);
-#else
- const int16x4_t consts1 = vld1_s16(jsimd_idct_islow_neon_consts);
- const int16x4_t consts2 = vld1_s16(jsimd_idct_islow_neon_consts + 4);
- const int16x4_t consts3 = vld1_s16(jsimd_idct_islow_neon_consts + 8);
- const int16x4x3_t consts = { { consts1, consts2, consts3 } };
-#endif
-
- /* Even part (z3 is all 0) */
- int16x4_t z2_s16 = vld1_s16(workspace + 2 * DCTSIZE / 2);
-
- int32x4_t tmp2 = vmull_lane_s16(z2_s16, consts.val[0], 1);
- int32x4_t tmp3 = vmull_lane_s16(z2_s16, consts.val[1], 2);
-
- z2_s16 = vld1_s16(workspace + 0 * DCTSIZE / 2);
- int32x4_t tmp0 = vshll_n_s16(z2_s16, CONST_BITS);
- int32x4_t tmp1 = vshll_n_s16(z2_s16, CONST_BITS);
-
- int32x4_t tmp10 = vaddq_s32(tmp0, tmp3);
- int32x4_t tmp13 = vsubq_s32(tmp0, tmp3);
- int32x4_t tmp11 = vaddq_s32(tmp1, tmp2);
- int32x4_t tmp12 = vsubq_s32(tmp1, tmp2);
-
- /* Odd part (tmp0 and tmp1 are both all 0) */
- int16x4_t tmp2_s16 = vld1_s16(workspace + 3 * DCTSIZE / 2);
- int16x4_t tmp3_s16 = vld1_s16(workspace + 1 * DCTSIZE / 2);
-
- int16x4_t z3_s16 = tmp2_s16;
- int16x4_t z4_s16 = tmp3_s16;
-
- int32x4_t z3 = vmull_lane_s16(z3_s16, consts.val[2], 3);
- z3 = vmlal_lane_s16(z3, z4_s16, consts.val[1], 3);
- int32x4_t z4 = vmull_lane_s16(z3_s16, consts.val[1], 3);
- z4 = vmlal_lane_s16(z4, z4_s16, consts.val[2], 0);
-
- tmp0 = vmlsl_lane_s16(z3, tmp3_s16, consts.val[0], 0);
- tmp1 = vmlsl_lane_s16(z4, tmp2_s16, consts.val[0], 2);
- tmp2 = vmlal_lane_s16(z3, tmp2_s16, consts.val[2], 2);
- tmp3 = vmlal_lane_s16(z4, tmp3_s16, consts.val[1], 0);
-
- /* Final output stage: descale and narrow to 16-bit. */
- int16x8_t cols_02_s16 = vcombine_s16(vaddhn_s32(tmp10, tmp3),
- vaddhn_s32(tmp12, tmp1));
- int16x8_t cols_13_s16 = vcombine_s16(vaddhn_s32(tmp11, tmp2),
- vaddhn_s32(tmp13, tmp0));
- int16x8_t cols_46_s16 = vcombine_s16(vsubhn_s32(tmp13, tmp0),
- vsubhn_s32(tmp11, tmp2));
- int16x8_t cols_57_s16 = vcombine_s16(vsubhn_s32(tmp12, tmp1),
- vsubhn_s32(tmp10, tmp3));
- /* Descale and narrow to 8-bit. */
- int8x8_t cols_02_s8 = vqrshrn_n_s16(cols_02_s16, DESCALE_P2 - 16);
- int8x8_t cols_13_s8 = vqrshrn_n_s16(cols_13_s16, DESCALE_P2 - 16);
- int8x8_t cols_46_s8 = vqrshrn_n_s16(cols_46_s16, DESCALE_P2 - 16);
- int8x8_t cols_57_s8 = vqrshrn_n_s16(cols_57_s16, DESCALE_P2 - 16);
- /* Clamp to range [0-255]. */
- uint8x8_t cols_02_u8 = vadd_u8(vreinterpret_u8_s8(cols_02_s8),
- vdup_n_u8(CENTERJSAMPLE));
- uint8x8_t cols_13_u8 = vadd_u8(vreinterpret_u8_s8(cols_13_s8),
- vdup_n_u8(CENTERJSAMPLE));
- uint8x8_t cols_46_u8 = vadd_u8(vreinterpret_u8_s8(cols_46_s8),
- vdup_n_u8(CENTERJSAMPLE));
- uint8x8_t cols_57_u8 = vadd_u8(vreinterpret_u8_s8(cols_57_s8),
- vdup_n_u8(CENTERJSAMPLE));
-
- /* Transpose 4x8 block and store to memory. (Zipping adjacent columns
- * together allows us to store 16-bit elements.)
- */
- uint8x8x2_t cols_01_23 = vzip_u8(cols_02_u8, cols_13_u8);
- uint8x8x2_t cols_45_67 = vzip_u8(cols_46_u8, cols_57_u8);
- uint16x4x4_t cols_01_23_45_67 = { {
- vreinterpret_u16_u8(cols_01_23.val[0]),
- vreinterpret_u16_u8(cols_01_23.val[1]),
- vreinterpret_u16_u8(cols_45_67.val[0]),
- vreinterpret_u16_u8(cols_45_67.val[1])
- } };
-
- JSAMPROW outptr0 = output_buf[buf_offset + 0] + output_col;
- JSAMPROW outptr1 = output_buf[buf_offset + 1] + output_col;
- JSAMPROW outptr2 = output_buf[buf_offset + 2] + output_col;
- JSAMPROW outptr3 = output_buf[buf_offset + 3] + output_col;
- /* VST4 of 16-bit elements completes the transpose. */
- vst4_lane_u16((uint16_t *)outptr0, cols_01_23_45_67, 0);
- vst4_lane_u16((uint16_t *)outptr1, cols_01_23_45_67, 1);
- vst4_lane_u16((uint16_t *)outptr2, cols_01_23_45_67, 2);
- vst4_lane_u16((uint16_t *)outptr3, cols_01_23_45_67, 3);
-}
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/jidctred-neon.c b/contrib/libs/libjpeg-turbo/simd/arm/jidctred-neon.c
deleted file mode 100644
index be9627e61d..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/arm/jidctred-neon.c
+++ /dev/null
@@ -1,486 +0,0 @@
-/*
- * jidctred-neon.c - reduced-size IDCT (Arm Neon)
- *
- * Copyright (C) 2020, Arm Limited. All Rights Reserved.
- * Copyright (C) 2020, D. R. Commander. All Rights Reserved.
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- * claim that you wrote the original software. If you use this software
- * in a product, an acknowledgment in the product documentation would be
- * appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must not be
- * misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source distribution.
- */
-
-#define JPEG_INTERNALS
-#include "../../jinclude.h"
-#include "../../jpeglib.h"
-#include "../../jsimd.h"
-#include "../../jdct.h"
-#include "../../jsimddct.h"
-#include "../jsimd.h"
-#include "align.h"
-#include "neon-compat.h"
-
-#include <arm_neon.h>
-
-
-#define CONST_BITS 13
-#define PASS1_BITS 2
-
-#define F_0_211 1730
-#define F_0_509 4176
-#define F_0_601 4926
-#define F_0_720 5906
-#define F_0_765 6270
-#define F_0_850 6967
-#define F_0_899 7373
-#define F_1_061 8697
-#define F_1_272 10426
-#define F_1_451 11893
-#define F_1_847 15137
-#define F_2_172 17799
-#define F_2_562 20995
-#define F_3_624 29692
-
-
-/* jsimd_idct_2x2_neon() is an inverse DCT function that produces reduced-size
- * 2x2 output from an 8x8 DCT block. It uses the same calculations and
- * produces exactly the same output as IJG's original jpeg_idct_2x2() function
- * from jpeg-6b, which can be found in jidctred.c.
- *
- * Scaled integer constants are used to avoid floating-point arithmetic:
- * 0.720959822 = 5906 * 2^-13
- * 0.850430095 = 6967 * 2^-13
- * 1.272758580 = 10426 * 2^-13
- * 3.624509785 = 29692 * 2^-13
- *
- * See jidctred.c for further details of the 2x2 IDCT algorithm. Where
- * possible, the variable names and comments here in jsimd_idct_2x2_neon()
- * match up with those in jpeg_idct_2x2().
- */
-
-ALIGN(16) static const int16_t jsimd_idct_2x2_neon_consts[] = {
- -F_0_720, F_0_850, -F_1_272, F_3_624
-};
-
-void jsimd_idct_2x2_neon(void *dct_table, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col)
-{
- ISLOW_MULT_TYPE *quantptr = dct_table;
-
- /* Load DCT coefficients. */
- int16x8_t row0 = vld1q_s16(coef_block + 0 * DCTSIZE);
- int16x8_t row1 = vld1q_s16(coef_block + 1 * DCTSIZE);
- int16x8_t row3 = vld1q_s16(coef_block + 3 * DCTSIZE);
- int16x8_t row5 = vld1q_s16(coef_block + 5 * DCTSIZE);
- int16x8_t row7 = vld1q_s16(coef_block + 7 * DCTSIZE);
-
- /* Load quantization table values. */
- int16x8_t quant_row0 = vld1q_s16(quantptr + 0 * DCTSIZE);
- int16x8_t quant_row1 = vld1q_s16(quantptr + 1 * DCTSIZE);
- int16x8_t quant_row3 = vld1q_s16(quantptr + 3 * DCTSIZE);
- int16x8_t quant_row5 = vld1q_s16(quantptr + 5 * DCTSIZE);
- int16x8_t quant_row7 = vld1q_s16(quantptr + 7 * DCTSIZE);
-
- /* Dequantize DCT coefficients. */
- row0 = vmulq_s16(row0, quant_row0);
- row1 = vmulq_s16(row1, quant_row1);
- row3 = vmulq_s16(row3, quant_row3);
- row5 = vmulq_s16(row5, quant_row5);
- row7 = vmulq_s16(row7, quant_row7);
-
- /* Load IDCT conversion constants. */
- const int16x4_t consts = vld1_s16(jsimd_idct_2x2_neon_consts);
-
- /* Pass 1: process columns from input, put results in vectors row0 and
- * row1.
- */
-
- /* Even part */
- int32x4_t tmp10_l = vshll_n_s16(vget_low_s16(row0), CONST_BITS + 2);
- int32x4_t tmp10_h = vshll_n_s16(vget_high_s16(row0), CONST_BITS + 2);
-
- /* Odd part */
- int32x4_t tmp0_l = vmull_lane_s16(vget_low_s16(row1), consts, 3);
- tmp0_l = vmlal_lane_s16(tmp0_l, vget_low_s16(row3), consts, 2);
- tmp0_l = vmlal_lane_s16(tmp0_l, vget_low_s16(row5), consts, 1);
- tmp0_l = vmlal_lane_s16(tmp0_l, vget_low_s16(row7), consts, 0);
- int32x4_t tmp0_h = vmull_lane_s16(vget_high_s16(row1), consts, 3);
- tmp0_h = vmlal_lane_s16(tmp0_h, vget_high_s16(row3), consts, 2);
- tmp0_h = vmlal_lane_s16(tmp0_h, vget_high_s16(row5), consts, 1);
- tmp0_h = vmlal_lane_s16(tmp0_h, vget_high_s16(row7), consts, 0);
-
- /* Final output stage: descale and narrow to 16-bit. */
- row0 = vcombine_s16(vrshrn_n_s32(vaddq_s32(tmp10_l, tmp0_l), CONST_BITS),
- vrshrn_n_s32(vaddq_s32(tmp10_h, tmp0_h), CONST_BITS));
- row1 = vcombine_s16(vrshrn_n_s32(vsubq_s32(tmp10_l, tmp0_l), CONST_BITS),
- vrshrn_n_s32(vsubq_s32(tmp10_h, tmp0_h), CONST_BITS));
-
- /* Transpose two rows, ready for second pass. */
- int16x8x2_t cols_0246_1357 = vtrnq_s16(row0, row1);
- int16x8_t cols_0246 = cols_0246_1357.val[0];
- int16x8_t cols_1357 = cols_0246_1357.val[1];
- /* Duplicate columns such that each is accessible in its own vector. */
- int32x4x2_t cols_1155_3377 = vtrnq_s32(vreinterpretq_s32_s16(cols_1357),
- vreinterpretq_s32_s16(cols_1357));
- int16x8_t cols_1155 = vreinterpretq_s16_s32(cols_1155_3377.val[0]);
- int16x8_t cols_3377 = vreinterpretq_s16_s32(cols_1155_3377.val[1]);
-
- /* Pass 2: process two rows, store to output array. */
-
- /* Even part: we're only interested in col0; the top half of tmp10 is "don't
- * care."
- */
- int32x4_t tmp10 = vshll_n_s16(vget_low_s16(cols_0246), CONST_BITS + 2);
-
- /* Odd part: we're only interested in the bottom half of tmp0. */
- int32x4_t tmp0 = vmull_lane_s16(vget_low_s16(cols_1155), consts, 3);
- tmp0 = vmlal_lane_s16(tmp0, vget_low_s16(cols_3377), consts, 2);
- tmp0 = vmlal_lane_s16(tmp0, vget_high_s16(cols_1155), consts, 1);
- tmp0 = vmlal_lane_s16(tmp0, vget_high_s16(cols_3377), consts, 0);
-
- /* Final output stage: descale and clamp to range [0-255]. */
- int16x8_t output_s16 = vcombine_s16(vaddhn_s32(tmp10, tmp0),
- vsubhn_s32(tmp10, tmp0));
- output_s16 = vrsraq_n_s16(vdupq_n_s16(CENTERJSAMPLE), output_s16,
- CONST_BITS + PASS1_BITS + 3 + 2 - 16);
- /* Narrow to 8-bit and convert to unsigned. */
- uint8x8_t output_u8 = vqmovun_s16(output_s16);
-
- /* Store 2x2 block to memory. */
- vst1_lane_u8(output_buf[0] + output_col, output_u8, 0);
- vst1_lane_u8(output_buf[1] + output_col, output_u8, 1);
- vst1_lane_u8(output_buf[0] + output_col + 1, output_u8, 4);
- vst1_lane_u8(output_buf[1] + output_col + 1, output_u8, 5);
-}
-
-
-/* jsimd_idct_4x4_neon() is an inverse DCT function that produces reduced-size
- * 4x4 output from an 8x8 DCT block. It uses the same calculations and
- * produces exactly the same output as IJG's original jpeg_idct_4x4() function
- * from jpeg-6b, which can be found in jidctred.c.
- *
- * Scaled integer constants are used to avoid floating-point arithmetic:
- * 0.211164243 = 1730 * 2^-13
- * 0.509795579 = 4176 * 2^-13
- * 0.601344887 = 4926 * 2^-13
- * 0.765366865 = 6270 * 2^-13
- * 0.899976223 = 7373 * 2^-13
- * 1.061594337 = 8697 * 2^-13
- * 1.451774981 = 11893 * 2^-13
- * 1.847759065 = 15137 * 2^-13
- * 2.172734803 = 17799 * 2^-13
- * 2.562915447 = 20995 * 2^-13
- *
- * See jidctred.c for further details of the 4x4 IDCT algorithm. Where
- * possible, the variable names and comments here in jsimd_idct_4x4_neon()
- * match up with those in jpeg_idct_4x4().
- */
-
-ALIGN(16) static const int16_t jsimd_idct_4x4_neon_consts[] = {
- F_1_847, -F_0_765, -F_0_211, F_1_451,
- -F_2_172, F_1_061, -F_0_509, -F_0_601,
- F_0_899, F_2_562, 0, 0
-};
-
-void jsimd_idct_4x4_neon(void *dct_table, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col)
-{
- ISLOW_MULT_TYPE *quantptr = dct_table;
-
- /* Load DCT coefficients. */
- int16x8_t row0 = vld1q_s16(coef_block + 0 * DCTSIZE);
- int16x8_t row1 = vld1q_s16(coef_block + 1 * DCTSIZE);
- int16x8_t row2 = vld1q_s16(coef_block + 2 * DCTSIZE);
- int16x8_t row3 = vld1q_s16(coef_block + 3 * DCTSIZE);
- int16x8_t row5 = vld1q_s16(coef_block + 5 * DCTSIZE);
- int16x8_t row6 = vld1q_s16(coef_block + 6 * DCTSIZE);
- int16x8_t row7 = vld1q_s16(coef_block + 7 * DCTSIZE);
-
- /* Load quantization table values for DC coefficients. */
- int16x8_t quant_row0 = vld1q_s16(quantptr + 0 * DCTSIZE);
- /* Dequantize DC coefficients. */
- row0 = vmulq_s16(row0, quant_row0);
-
- /* Construct bitmap to test if all AC coefficients are 0. */
- int16x8_t bitmap = vorrq_s16(row1, row2);
- bitmap = vorrq_s16(bitmap, row3);
- bitmap = vorrq_s16(bitmap, row5);
- bitmap = vorrq_s16(bitmap, row6);
- bitmap = vorrq_s16(bitmap, row7);
-
- int64_t left_ac_bitmap = vgetq_lane_s64(vreinterpretq_s64_s16(bitmap), 0);
- int64_t right_ac_bitmap = vgetq_lane_s64(vreinterpretq_s64_s16(bitmap), 1);
-
- /* Load constants for IDCT computation. */
-#ifdef HAVE_VLD1_S16_X3
- const int16x4x3_t consts = vld1_s16_x3(jsimd_idct_4x4_neon_consts);
-#else
- /* GCC does not currently support the intrinsic vld1_<type>_x3(). */
- const int16x4_t consts1 = vld1_s16(jsimd_idct_4x4_neon_consts);
- const int16x4_t consts2 = vld1_s16(jsimd_idct_4x4_neon_consts + 4);
- const int16x4_t consts3 = vld1_s16(jsimd_idct_4x4_neon_consts + 8);
- const int16x4x3_t consts = { { consts1, consts2, consts3 } };
-#endif
-
- if (left_ac_bitmap == 0 && right_ac_bitmap == 0) {
- /* All AC coefficients are zero.
- * Compute DC values and duplicate into row vectors 0, 1, 2, and 3.
- */
- int16x8_t dcval = vshlq_n_s16(row0, PASS1_BITS);
- row0 = dcval;
- row1 = dcval;
- row2 = dcval;
- row3 = dcval;
- } else if (left_ac_bitmap == 0) {
- /* AC coefficients are zero for columns 0, 1, 2, and 3.
- * Compute DC values for these columns.
- */
- int16x4_t dcval = vshl_n_s16(vget_low_s16(row0), PASS1_BITS);
-
- /* Commence regular IDCT computation for columns 4, 5, 6, and 7. */
-
- /* Load quantization table. */
- int16x4_t quant_row1 = vld1_s16(quantptr + 1 * DCTSIZE + 4);
- int16x4_t quant_row2 = vld1_s16(quantptr + 2 * DCTSIZE + 4);
- int16x4_t quant_row3 = vld1_s16(quantptr + 3 * DCTSIZE + 4);
- int16x4_t quant_row5 = vld1_s16(quantptr + 5 * DCTSIZE + 4);
- int16x4_t quant_row6 = vld1_s16(quantptr + 6 * DCTSIZE + 4);
- int16x4_t quant_row7 = vld1_s16(quantptr + 7 * DCTSIZE + 4);
-
- /* Even part */
- int32x4_t tmp0 = vshll_n_s16(vget_high_s16(row0), CONST_BITS + 1);
-
- int16x4_t z2 = vmul_s16(vget_high_s16(row2), quant_row2);
- int16x4_t z3 = vmul_s16(vget_high_s16(row6), quant_row6);
-
- int32x4_t tmp2 = vmull_lane_s16(z2, consts.val[0], 0);
- tmp2 = vmlal_lane_s16(tmp2, z3, consts.val[0], 1);
-
- int32x4_t tmp10 = vaddq_s32(tmp0, tmp2);
- int32x4_t tmp12 = vsubq_s32(tmp0, tmp2);
-
- /* Odd part */
- int16x4_t z1 = vmul_s16(vget_high_s16(row7), quant_row7);
- z2 = vmul_s16(vget_high_s16(row5), quant_row5);
- z3 = vmul_s16(vget_high_s16(row3), quant_row3);
- int16x4_t z4 = vmul_s16(vget_high_s16(row1), quant_row1);
-
- tmp0 = vmull_lane_s16(z1, consts.val[0], 2);
- tmp0 = vmlal_lane_s16(tmp0, z2, consts.val[0], 3);
- tmp0 = vmlal_lane_s16(tmp0, z3, consts.val[1], 0);
- tmp0 = vmlal_lane_s16(tmp0, z4, consts.val[1], 1);
-
- tmp2 = vmull_lane_s16(z1, consts.val[1], 2);
- tmp2 = vmlal_lane_s16(tmp2, z2, consts.val[1], 3);
- tmp2 = vmlal_lane_s16(tmp2, z3, consts.val[2], 0);
- tmp2 = vmlal_lane_s16(tmp2, z4, consts.val[2], 1);
-
- /* Final output stage: descale and narrow to 16-bit. */
- row0 = vcombine_s16(dcval, vrshrn_n_s32(vaddq_s32(tmp10, tmp2),
- CONST_BITS - PASS1_BITS + 1));
- row3 = vcombine_s16(dcval, vrshrn_n_s32(vsubq_s32(tmp10, tmp2),
- CONST_BITS - PASS1_BITS + 1));
- row1 = vcombine_s16(dcval, vrshrn_n_s32(vaddq_s32(tmp12, tmp0),
- CONST_BITS - PASS1_BITS + 1));
- row2 = vcombine_s16(dcval, vrshrn_n_s32(vsubq_s32(tmp12, tmp0),
- CONST_BITS - PASS1_BITS + 1));
- } else if (right_ac_bitmap == 0) {
- /* AC coefficients are zero for columns 4, 5, 6, and 7.
- * Compute DC values for these columns.
- */
- int16x4_t dcval = vshl_n_s16(vget_high_s16(row0), PASS1_BITS);
-
- /* Commence regular IDCT computation for columns 0, 1, 2, and 3. */
-
- /* Load quantization table. */
- int16x4_t quant_row1 = vld1_s16(quantptr + 1 * DCTSIZE);
- int16x4_t quant_row2 = vld1_s16(quantptr + 2 * DCTSIZE);
- int16x4_t quant_row3 = vld1_s16(quantptr + 3 * DCTSIZE);
- int16x4_t quant_row5 = vld1_s16(quantptr + 5 * DCTSIZE);
- int16x4_t quant_row6 = vld1_s16(quantptr + 6 * DCTSIZE);
- int16x4_t quant_row7 = vld1_s16(quantptr + 7 * DCTSIZE);
-
- /* Even part */
- int32x4_t tmp0 = vshll_n_s16(vget_low_s16(row0), CONST_BITS + 1);
-
- int16x4_t z2 = vmul_s16(vget_low_s16(row2), quant_row2);
- int16x4_t z3 = vmul_s16(vget_low_s16(row6), quant_row6);
-
- int32x4_t tmp2 = vmull_lane_s16(z2, consts.val[0], 0);
- tmp2 = vmlal_lane_s16(tmp2, z3, consts.val[0], 1);
-
- int32x4_t tmp10 = vaddq_s32(tmp0, tmp2);
- int32x4_t tmp12 = vsubq_s32(tmp0, tmp2);
-
- /* Odd part */
- int16x4_t z1 = vmul_s16(vget_low_s16(row7), quant_row7);
- z2 = vmul_s16(vget_low_s16(row5), quant_row5);
- z3 = vmul_s16(vget_low_s16(row3), quant_row3);
- int16x4_t z4 = vmul_s16(vget_low_s16(row1), quant_row1);
-
- tmp0 = vmull_lane_s16(z1, consts.val[0], 2);
- tmp0 = vmlal_lane_s16(tmp0, z2, consts.val[0], 3);
- tmp0 = vmlal_lane_s16(tmp0, z3, consts.val[1], 0);
- tmp0 = vmlal_lane_s16(tmp0, z4, consts.val[1], 1);
-
- tmp2 = vmull_lane_s16(z1, consts.val[1], 2);
- tmp2 = vmlal_lane_s16(tmp2, z2, consts.val[1], 3);
- tmp2 = vmlal_lane_s16(tmp2, z3, consts.val[2], 0);
- tmp2 = vmlal_lane_s16(tmp2, z4, consts.val[2], 1);
-
- /* Final output stage: descale and narrow to 16-bit. */
- row0 = vcombine_s16(vrshrn_n_s32(vaddq_s32(tmp10, tmp2),
- CONST_BITS - PASS1_BITS + 1), dcval);
- row3 = vcombine_s16(vrshrn_n_s32(vsubq_s32(tmp10, tmp2),
- CONST_BITS - PASS1_BITS + 1), dcval);
- row1 = vcombine_s16(vrshrn_n_s32(vaddq_s32(tmp12, tmp0),
- CONST_BITS - PASS1_BITS + 1), dcval);
- row2 = vcombine_s16(vrshrn_n_s32(vsubq_s32(tmp12, tmp0),
- CONST_BITS - PASS1_BITS + 1), dcval);
- } else {
- /* All AC coefficients are non-zero; full IDCT calculation required. */
- int16x8_t quant_row1 = vld1q_s16(quantptr + 1 * DCTSIZE);
- int16x8_t quant_row2 = vld1q_s16(quantptr + 2 * DCTSIZE);
- int16x8_t quant_row3 = vld1q_s16(quantptr + 3 * DCTSIZE);
- int16x8_t quant_row5 = vld1q_s16(quantptr + 5 * DCTSIZE);
- int16x8_t quant_row6 = vld1q_s16(quantptr + 6 * DCTSIZE);
- int16x8_t quant_row7 = vld1q_s16(quantptr + 7 * DCTSIZE);
-
- /* Even part */
- int32x4_t tmp0_l = vshll_n_s16(vget_low_s16(row0), CONST_BITS + 1);
- int32x4_t tmp0_h = vshll_n_s16(vget_high_s16(row0), CONST_BITS + 1);
-
- int16x8_t z2 = vmulq_s16(row2, quant_row2);
- int16x8_t z3 = vmulq_s16(row6, quant_row6);
-
- int32x4_t tmp2_l = vmull_lane_s16(vget_low_s16(z2), consts.val[0], 0);
- int32x4_t tmp2_h = vmull_lane_s16(vget_high_s16(z2), consts.val[0], 0);
- tmp2_l = vmlal_lane_s16(tmp2_l, vget_low_s16(z3), consts.val[0], 1);
- tmp2_h = vmlal_lane_s16(tmp2_h, vget_high_s16(z3), consts.val[0], 1);
-
- int32x4_t tmp10_l = vaddq_s32(tmp0_l, tmp2_l);
- int32x4_t tmp10_h = vaddq_s32(tmp0_h, tmp2_h);
- int32x4_t tmp12_l = vsubq_s32(tmp0_l, tmp2_l);
- int32x4_t tmp12_h = vsubq_s32(tmp0_h, tmp2_h);
-
- /* Odd part */
- int16x8_t z1 = vmulq_s16(row7, quant_row7);
- z2 = vmulq_s16(row5, quant_row5);
- z3 = vmulq_s16(row3, quant_row3);
- int16x8_t z4 = vmulq_s16(row1, quant_row1);
-
- tmp0_l = vmull_lane_s16(vget_low_s16(z1), consts.val[0], 2);
- tmp0_l = vmlal_lane_s16(tmp0_l, vget_low_s16(z2), consts.val[0], 3);
- tmp0_l = vmlal_lane_s16(tmp0_l, vget_low_s16(z3), consts.val[1], 0);
- tmp0_l = vmlal_lane_s16(tmp0_l, vget_low_s16(z4), consts.val[1], 1);
- tmp0_h = vmull_lane_s16(vget_high_s16(z1), consts.val[0], 2);
- tmp0_h = vmlal_lane_s16(tmp0_h, vget_high_s16(z2), consts.val[0], 3);
- tmp0_h = vmlal_lane_s16(tmp0_h, vget_high_s16(z3), consts.val[1], 0);
- tmp0_h = vmlal_lane_s16(tmp0_h, vget_high_s16(z4), consts.val[1], 1);
-
- tmp2_l = vmull_lane_s16(vget_low_s16(z1), consts.val[1], 2);
- tmp2_l = vmlal_lane_s16(tmp2_l, vget_low_s16(z2), consts.val[1], 3);
- tmp2_l = vmlal_lane_s16(tmp2_l, vget_low_s16(z3), consts.val[2], 0);
- tmp2_l = vmlal_lane_s16(tmp2_l, vget_low_s16(z4), consts.val[2], 1);
- tmp2_h = vmull_lane_s16(vget_high_s16(z1), consts.val[1], 2);
- tmp2_h = vmlal_lane_s16(tmp2_h, vget_high_s16(z2), consts.val[1], 3);
- tmp2_h = vmlal_lane_s16(tmp2_h, vget_high_s16(z3), consts.val[2], 0);
- tmp2_h = vmlal_lane_s16(tmp2_h, vget_high_s16(z4), consts.val[2], 1);
-
- /* Final output stage: descale and narrow to 16-bit. */
- row0 = vcombine_s16(vrshrn_n_s32(vaddq_s32(tmp10_l, tmp2_l),
- CONST_BITS - PASS1_BITS + 1),
- vrshrn_n_s32(vaddq_s32(tmp10_h, tmp2_h),
- CONST_BITS - PASS1_BITS + 1));
- row3 = vcombine_s16(vrshrn_n_s32(vsubq_s32(tmp10_l, tmp2_l),
- CONST_BITS - PASS1_BITS + 1),
- vrshrn_n_s32(vsubq_s32(tmp10_h, tmp2_h),
- CONST_BITS - PASS1_BITS + 1));
- row1 = vcombine_s16(vrshrn_n_s32(vaddq_s32(tmp12_l, tmp0_l),
- CONST_BITS - PASS1_BITS + 1),
- vrshrn_n_s32(vaddq_s32(tmp12_h, tmp0_h),
- CONST_BITS - PASS1_BITS + 1));
- row2 = vcombine_s16(vrshrn_n_s32(vsubq_s32(tmp12_l, tmp0_l),
- CONST_BITS - PASS1_BITS + 1),
- vrshrn_n_s32(vsubq_s32(tmp12_h, tmp0_h),
- CONST_BITS - PASS1_BITS + 1));
- }
-
- /* Transpose 8x4 block to perform IDCT on rows in second pass. */
- int16x8x2_t row_01 = vtrnq_s16(row0, row1);
- int16x8x2_t row_23 = vtrnq_s16(row2, row3);
-
- int32x4x2_t cols_0426 = vtrnq_s32(vreinterpretq_s32_s16(row_01.val[0]),
- vreinterpretq_s32_s16(row_23.val[0]));
- int32x4x2_t cols_1537 = vtrnq_s32(vreinterpretq_s32_s16(row_01.val[1]),
- vreinterpretq_s32_s16(row_23.val[1]));
-
- int16x4_t col0 = vreinterpret_s16_s32(vget_low_s32(cols_0426.val[0]));
- int16x4_t col1 = vreinterpret_s16_s32(vget_low_s32(cols_1537.val[0]));
- int16x4_t col2 = vreinterpret_s16_s32(vget_low_s32(cols_0426.val[1]));
- int16x4_t col3 = vreinterpret_s16_s32(vget_low_s32(cols_1537.val[1]));
- int16x4_t col5 = vreinterpret_s16_s32(vget_high_s32(cols_1537.val[0]));
- int16x4_t col6 = vreinterpret_s16_s32(vget_high_s32(cols_0426.val[1]));
- int16x4_t col7 = vreinterpret_s16_s32(vget_high_s32(cols_1537.val[1]));
-
- /* Commence second pass of IDCT. */
-
- /* Even part */
- int32x4_t tmp0 = vshll_n_s16(col0, CONST_BITS + 1);
- int32x4_t tmp2 = vmull_lane_s16(col2, consts.val[0], 0);
- tmp2 = vmlal_lane_s16(tmp2, col6, consts.val[0], 1);
-
- int32x4_t tmp10 = vaddq_s32(tmp0, tmp2);
- int32x4_t tmp12 = vsubq_s32(tmp0, tmp2);
-
- /* Odd part */
- tmp0 = vmull_lane_s16(col7, consts.val[0], 2);
- tmp0 = vmlal_lane_s16(tmp0, col5, consts.val[0], 3);
- tmp0 = vmlal_lane_s16(tmp0, col3, consts.val[1], 0);
- tmp0 = vmlal_lane_s16(tmp0, col1, consts.val[1], 1);
-
- tmp2 = vmull_lane_s16(col7, consts.val[1], 2);
- tmp2 = vmlal_lane_s16(tmp2, col5, consts.val[1], 3);
- tmp2 = vmlal_lane_s16(tmp2, col3, consts.val[2], 0);
- tmp2 = vmlal_lane_s16(tmp2, col1, consts.val[2], 1);
-
- /* Final output stage: descale and clamp to range [0-255]. */
- int16x8_t output_cols_02 = vcombine_s16(vaddhn_s32(tmp10, tmp2),
- vsubhn_s32(tmp12, tmp0));
- int16x8_t output_cols_13 = vcombine_s16(vaddhn_s32(tmp12, tmp0),
- vsubhn_s32(tmp10, tmp2));
- output_cols_02 = vrsraq_n_s16(vdupq_n_s16(CENTERJSAMPLE), output_cols_02,
- CONST_BITS + PASS1_BITS + 3 + 1 - 16);
- output_cols_13 = vrsraq_n_s16(vdupq_n_s16(CENTERJSAMPLE), output_cols_13,
- CONST_BITS + PASS1_BITS + 3 + 1 - 16);
- /* Narrow to 8-bit and convert to unsigned while zipping 8-bit elements.
- * An interleaving store completes the transpose.
- */
- uint8x8x2_t output_0123 = vzip_u8(vqmovun_s16(output_cols_02),
- vqmovun_s16(output_cols_13));
- uint16x4x2_t output_01_23 = { {
- vreinterpret_u16_u8(output_0123.val[0]),
- vreinterpret_u16_u8(output_0123.val[1])
- } };
-
- /* Store 4x4 block to memory. */
- JSAMPROW outptr0 = output_buf[0] + output_col;
- JSAMPROW outptr1 = output_buf[1] + output_col;
- JSAMPROW outptr2 = output_buf[2] + output_col;
- JSAMPROW outptr3 = output_buf[3] + output_col;
- vst2_lane_u16((uint16_t *)outptr0, output_01_23, 0);
- vst2_lane_u16((uint16_t *)outptr1, output_01_23, 1);
- vst2_lane_u16((uint16_t *)outptr2, output_01_23, 2);
- vst2_lane_u16((uint16_t *)outptr3, output_01_23, 3);
-}
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/jquanti-neon.c b/contrib/libs/libjpeg-turbo/simd/arm/jquanti-neon.c
deleted file mode 100644
index d5d95d89f6..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/arm/jquanti-neon.c
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * jquanti-neon.c - sample data conversion and quantization (Arm Neon)
- *
- * Copyright (C) 2020-2021, Arm Limited. All Rights Reserved.
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- * claim that you wrote the original software. If you use this software
- * in a product, an acknowledgment in the product documentation would be
- * appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must not be
- * misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source distribution.
- */
-
-#define JPEG_INTERNALS
-#include "../../jinclude.h"
-#include "../../jpeglib.h"
-#include "../../jsimd.h"
-#include "../../jdct.h"
-#include "../../jsimddct.h"
-#include "../jsimd.h"
-
-#include <arm_neon.h>
-
-
-/* After downsampling, the resulting sample values are in the range [0, 255],
- * but the Discrete Cosine Transform (DCT) operates on values centered around
- * 0.
- *
- * To prepare sample values for the DCT, load samples into a DCT workspace,
- * subtracting CENTERJSAMPLE (128). The samples, now in the range [-128, 127],
- * are also widened from 8- to 16-bit.
- *
- * The equivalent scalar C function convsamp() can be found in jcdctmgr.c.
- */
-
-void jsimd_convsamp_neon(JSAMPARRAY sample_data, JDIMENSION start_col,
- DCTELEM *workspace)
-{
- uint8x8_t samp_row0 = vld1_u8(sample_data[0] + start_col);
- uint8x8_t samp_row1 = vld1_u8(sample_data[1] + start_col);
- uint8x8_t samp_row2 = vld1_u8(sample_data[2] + start_col);
- uint8x8_t samp_row3 = vld1_u8(sample_data[3] + start_col);
- uint8x8_t samp_row4 = vld1_u8(sample_data[4] + start_col);
- uint8x8_t samp_row5 = vld1_u8(sample_data[5] + start_col);
- uint8x8_t samp_row6 = vld1_u8(sample_data[6] + start_col);
- uint8x8_t samp_row7 = vld1_u8(sample_data[7] + start_col);
-
- int16x8_t row0 =
- vreinterpretq_s16_u16(vsubl_u8(samp_row0, vdup_n_u8(CENTERJSAMPLE)));
- int16x8_t row1 =
- vreinterpretq_s16_u16(vsubl_u8(samp_row1, vdup_n_u8(CENTERJSAMPLE)));
- int16x8_t row2 =
- vreinterpretq_s16_u16(vsubl_u8(samp_row2, vdup_n_u8(CENTERJSAMPLE)));
- int16x8_t row3 =
- vreinterpretq_s16_u16(vsubl_u8(samp_row3, vdup_n_u8(CENTERJSAMPLE)));
- int16x8_t row4 =
- vreinterpretq_s16_u16(vsubl_u8(samp_row4, vdup_n_u8(CENTERJSAMPLE)));
- int16x8_t row5 =
- vreinterpretq_s16_u16(vsubl_u8(samp_row5, vdup_n_u8(CENTERJSAMPLE)));
- int16x8_t row6 =
- vreinterpretq_s16_u16(vsubl_u8(samp_row6, vdup_n_u8(CENTERJSAMPLE)));
- int16x8_t row7 =
- vreinterpretq_s16_u16(vsubl_u8(samp_row7, vdup_n_u8(CENTERJSAMPLE)));
-
- vst1q_s16(workspace + 0 * DCTSIZE, row0);
- vst1q_s16(workspace + 1 * DCTSIZE, row1);
- vst1q_s16(workspace + 2 * DCTSIZE, row2);
- vst1q_s16(workspace + 3 * DCTSIZE, row3);
- vst1q_s16(workspace + 4 * DCTSIZE, row4);
- vst1q_s16(workspace + 5 * DCTSIZE, row5);
- vst1q_s16(workspace + 6 * DCTSIZE, row6);
- vst1q_s16(workspace + 7 * DCTSIZE, row7);
-}
-
-
-/* After the DCT, the resulting array of coefficient values needs to be divided
- * by an array of quantization values.
- *
- * To avoid a slow division operation, the DCT coefficients are multiplied by
- * the (scaled) reciprocals of the quantization values and then right-shifted.
- *
- * The equivalent scalar C function quantize() can be found in jcdctmgr.c.
- */
-
-void jsimd_quantize_neon(JCOEFPTR coef_block, DCTELEM *divisors,
- DCTELEM *workspace)
-{
- JCOEFPTR out_ptr = coef_block;
- UDCTELEM *recip_ptr = (UDCTELEM *)divisors;
- UDCTELEM *corr_ptr = (UDCTELEM *)divisors + DCTSIZE2;
- DCTELEM *shift_ptr = divisors + 3 * DCTSIZE2;
- int i;
-
-#if defined(__clang__) && (defined(__aarch64__) || defined(_M_ARM64))
-#pragma unroll
-#endif
- for (i = 0; i < DCTSIZE; i += DCTSIZE / 2) {
- /* Load DCT coefficients. */
- int16x8_t row0 = vld1q_s16(workspace + (i + 0) * DCTSIZE);
- int16x8_t row1 = vld1q_s16(workspace + (i + 1) * DCTSIZE);
- int16x8_t row2 = vld1q_s16(workspace + (i + 2) * DCTSIZE);
- int16x8_t row3 = vld1q_s16(workspace + (i + 3) * DCTSIZE);
- /* Load reciprocals of quantization values. */
- uint16x8_t recip0 = vld1q_u16(recip_ptr + (i + 0) * DCTSIZE);
- uint16x8_t recip1 = vld1q_u16(recip_ptr + (i + 1) * DCTSIZE);
- uint16x8_t recip2 = vld1q_u16(recip_ptr + (i + 2) * DCTSIZE);
- uint16x8_t recip3 = vld1q_u16(recip_ptr + (i + 3) * DCTSIZE);
- uint16x8_t corr0 = vld1q_u16(corr_ptr + (i + 0) * DCTSIZE);
- uint16x8_t corr1 = vld1q_u16(corr_ptr + (i + 1) * DCTSIZE);
- uint16x8_t corr2 = vld1q_u16(corr_ptr + (i + 2) * DCTSIZE);
- uint16x8_t corr3 = vld1q_u16(corr_ptr + (i + 3) * DCTSIZE);
- int16x8_t shift0 = vld1q_s16(shift_ptr + (i + 0) * DCTSIZE);
- int16x8_t shift1 = vld1q_s16(shift_ptr + (i + 1) * DCTSIZE);
- int16x8_t shift2 = vld1q_s16(shift_ptr + (i + 2) * DCTSIZE);
- int16x8_t shift3 = vld1q_s16(shift_ptr + (i + 3) * DCTSIZE);
-
- /* Extract sign from coefficients. */
- int16x8_t sign_row0 = vshrq_n_s16(row0, 15);
- int16x8_t sign_row1 = vshrq_n_s16(row1, 15);
- int16x8_t sign_row2 = vshrq_n_s16(row2, 15);
- int16x8_t sign_row3 = vshrq_n_s16(row3, 15);
- /* Get absolute value of DCT coefficients. */
- uint16x8_t abs_row0 = vreinterpretq_u16_s16(vabsq_s16(row0));
- uint16x8_t abs_row1 = vreinterpretq_u16_s16(vabsq_s16(row1));
- uint16x8_t abs_row2 = vreinterpretq_u16_s16(vabsq_s16(row2));
- uint16x8_t abs_row3 = vreinterpretq_u16_s16(vabsq_s16(row3));
- /* Add correction. */
- abs_row0 = vaddq_u16(abs_row0, corr0);
- abs_row1 = vaddq_u16(abs_row1, corr1);
- abs_row2 = vaddq_u16(abs_row2, corr2);
- abs_row3 = vaddq_u16(abs_row3, corr3);
-
- /* Multiply DCT coefficients by quantization reciprocals. */
- int32x4_t row0_l = vreinterpretq_s32_u32(vmull_u16(vget_low_u16(abs_row0),
- vget_low_u16(recip0)));
- int32x4_t row0_h = vreinterpretq_s32_u32(vmull_u16(vget_high_u16(abs_row0),
- vget_high_u16(recip0)));
- int32x4_t row1_l = vreinterpretq_s32_u32(vmull_u16(vget_low_u16(abs_row1),
- vget_low_u16(recip1)));
- int32x4_t row1_h = vreinterpretq_s32_u32(vmull_u16(vget_high_u16(abs_row1),
- vget_high_u16(recip1)));
- int32x4_t row2_l = vreinterpretq_s32_u32(vmull_u16(vget_low_u16(abs_row2),
- vget_low_u16(recip2)));
- int32x4_t row2_h = vreinterpretq_s32_u32(vmull_u16(vget_high_u16(abs_row2),
- vget_high_u16(recip2)));
- int32x4_t row3_l = vreinterpretq_s32_u32(vmull_u16(vget_low_u16(abs_row3),
- vget_low_u16(recip3)));
- int32x4_t row3_h = vreinterpretq_s32_u32(vmull_u16(vget_high_u16(abs_row3),
- vget_high_u16(recip3)));
- /* Narrow back to 16-bit. */
- row0 = vcombine_s16(vshrn_n_s32(row0_l, 16), vshrn_n_s32(row0_h, 16));
- row1 = vcombine_s16(vshrn_n_s32(row1_l, 16), vshrn_n_s32(row1_h, 16));
- row2 = vcombine_s16(vshrn_n_s32(row2_l, 16), vshrn_n_s32(row2_h, 16));
- row3 = vcombine_s16(vshrn_n_s32(row3_l, 16), vshrn_n_s32(row3_h, 16));
-
- /* Since VSHR only supports an immediate as its second argument, negate the
- * shift value and shift left.
- */
- row0 = vreinterpretq_s16_u16(vshlq_u16(vreinterpretq_u16_s16(row0),
- vnegq_s16(shift0)));
- row1 = vreinterpretq_s16_u16(vshlq_u16(vreinterpretq_u16_s16(row1),
- vnegq_s16(shift1)));
- row2 = vreinterpretq_s16_u16(vshlq_u16(vreinterpretq_u16_s16(row2),
- vnegq_s16(shift2)));
- row3 = vreinterpretq_s16_u16(vshlq_u16(vreinterpretq_u16_s16(row3),
- vnegq_s16(shift3)));
-
- /* Restore sign to original product. */
- row0 = veorq_s16(row0, sign_row0);
- row0 = vsubq_s16(row0, sign_row0);
- row1 = veorq_s16(row1, sign_row1);
- row1 = vsubq_s16(row1, sign_row1);
- row2 = veorq_s16(row2, sign_row2);
- row2 = vsubq_s16(row2, sign_row2);
- row3 = veorq_s16(row3, sign_row3);
- row3 = vsubq_s16(row3, sign_row3);
-
- /* Store quantized coefficients to memory. */
- vst1q_s16(out_ptr + (i + 0) * DCTSIZE, row0);
- vst1q_s16(out_ptr + (i + 1) * DCTSIZE, row1);
- vst1q_s16(out_ptr + (i + 2) * DCTSIZE, row2);
- vst1q_s16(out_ptr + (i + 3) * DCTSIZE, row3);
- }
-}
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/neon-compat.h b/contrib/libs/libjpeg-turbo/simd/arm/neon-compat.h
deleted file mode 100644
index 069c62d829..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/arm/neon-compat.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2020, D. R. Commander. All Rights Reserved.
- * Copyright (C) 2020-2021, Arm Limited. All Rights Reserved.
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- * claim that you wrote the original software. If you use this software
- * in a product, an acknowledgment in the product documentation would be
- * appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must not be
- * misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source distribution.
- */
-
-// #cmakedefine HAVE_VLD1_S16_X3
-// #cmakedefine HAVE_VLD1_U16_X2
-// #cmakedefine HAVE_VLD1Q_U8_X4
-
-/* Define compiler-independent count-leading-zeros and byte-swap macros */
-#if defined(_MSC_VER) && !defined(__clang__)
-#define BUILTIN_CLZ(x) _CountLeadingZeros(x)
-#define BUILTIN_CLZLL(x) _CountLeadingZeros64(x)
-#define BUILTIN_BSWAP64(x) _byteswap_uint64(x)
-#elif defined(__clang__) || defined(__GNUC__)
-#define BUILTIN_CLZ(x) __builtin_clz(x)
-#define BUILTIN_CLZLL(x) __builtin_clzll(x)
-#define BUILTIN_BSWAP64(x) __builtin_bswap64(x)
-#else
-#error "Unknown compiler"
-#endif
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jccolext-avx2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jccolext-avx2.asm
deleted file mode 100644
index c46d684436..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jccolext-avx2.asm
+++ /dev/null
@@ -1,578 +0,0 @@
-;
-; jccolext.asm - colorspace conversion (AVX2)
-;
-; Copyright (C) 2015, Intel Corporation.
-; Copyright (C) 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jcolsamp.inc"
-
-; --------------------------------------------------------------------------
-;
-; Convert some rows of samples to the output colorspace.
-;
-; GLOBAL(void)
-; jsimd_rgb_ycc_convert_avx2(JDIMENSION img_width, JSAMPARRAY input_buf,
-; JSAMPIMAGE output_buf, JDIMENSION output_row,
-; int num_rows);
-;
-
-%define img_width(b) (b) + 8 ; JDIMENSION img_width
-%define input_buf(b) (b) + 12 ; JSAMPARRAY input_buf
-%define output_buf(b) (b) + 16 ; JSAMPIMAGE output_buf
-%define output_row(b) (b) + 20 ; JDIMENSION output_row
-%define num_rows(b) (b) + 24 ; int num_rows
-
-%define original_ebp ebp + 0
-%define wk(i) ebp - (WK_NUM - (i)) * SIZEOF_YMMWORD
- ; ymmword wk[WK_NUM]
-%define WK_NUM 8
-%define gotptr wk(0) - SIZEOF_POINTER ; void * gotptr
-
- align 32
- GLOBAL_FUNCTION(jsimd_rgb_ycc_convert_avx2)
-
-EXTN(jsimd_rgb_ycc_convert_avx2):
- push ebp
- mov eax, esp ; eax = original ebp
- sub esp, byte 4
- and esp, byte (-SIZEOF_YMMWORD) ; align to 256 bits
- mov [esp], eax
- mov ebp, esp ; ebp = aligned ebp
- lea esp, [wk(0)]
- pushpic eax ; make a room for GOT address
- push ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- get_GOT ebx ; get GOT address
- movpic POINTER [gotptr], ebx ; save GOT address
-
- mov ecx, JDIMENSION [img_width(eax)]
- test ecx, ecx
- jz near .return
-
- push ecx
-
- mov esi, JSAMPIMAGE [output_buf(eax)]
- mov ecx, JDIMENSION [output_row(eax)]
- mov edi, JSAMPARRAY [esi+0*SIZEOF_JSAMPARRAY]
- mov ebx, JSAMPARRAY [esi+1*SIZEOF_JSAMPARRAY]
- mov edx, JSAMPARRAY [esi+2*SIZEOF_JSAMPARRAY]
- lea edi, [edi+ecx*SIZEOF_JSAMPROW]
- lea ebx, [ebx+ecx*SIZEOF_JSAMPROW]
- lea edx, [edx+ecx*SIZEOF_JSAMPROW]
-
- pop ecx
-
- mov esi, JSAMPARRAY [input_buf(eax)]
- mov eax, INT [num_rows(eax)]
- test eax, eax
- jle near .return
- alignx 16, 7
-.rowloop:
- pushpic eax
- push edx
- push ebx
- push edi
- push esi
- push ecx ; col
-
- mov esi, JSAMPROW [esi] ; inptr
- mov edi, JSAMPROW [edi] ; outptr0
- mov ebx, JSAMPROW [ebx] ; outptr1
- mov edx, JSAMPROW [edx] ; outptr2
- movpic eax, POINTER [gotptr] ; load GOT address (eax)
-
- cmp ecx, byte SIZEOF_YMMWORD
- jae near .columnloop
- alignx 16, 7
-
-%if RGB_PIXELSIZE == 3 ; ---------------
-
-.column_ld1:
- push eax
- push edx
- lea ecx, [ecx+ecx*2] ; imul ecx,RGB_PIXELSIZE
- test cl, SIZEOF_BYTE
- jz short .column_ld2
- sub ecx, byte SIZEOF_BYTE
- movzx eax, byte [esi+ecx]
-.column_ld2:
- test cl, SIZEOF_WORD
- jz short .column_ld4
- sub ecx, byte SIZEOF_WORD
- movzx edx, word [esi+ecx]
- shl eax, WORD_BIT
- or eax, edx
-.column_ld4:
- vmovd xmmA, eax
- pop edx
- pop eax
- test cl, SIZEOF_DWORD
- jz short .column_ld8
- sub ecx, byte SIZEOF_DWORD
- vmovd xmmF, XMM_DWORD [esi+ecx]
- vpslldq xmmA, xmmA, SIZEOF_DWORD
- vpor xmmA, xmmA, xmmF
-.column_ld8:
- test cl, SIZEOF_MMWORD
- jz short .column_ld16
- sub ecx, byte SIZEOF_MMWORD
- vmovq xmmB, XMM_MMWORD [esi+ecx]
- vpslldq xmmA, xmmA, SIZEOF_MMWORD
- vpor xmmA, xmmA, xmmB
-.column_ld16:
- test cl, SIZEOF_XMMWORD
- jz short .column_ld32
- sub ecx, byte SIZEOF_XMMWORD
- vmovdqu xmmB, XMM_MMWORD [esi+ecx]
- vperm2i128 ymmA, ymmA, ymmA, 1
- vpor ymmA, ymmB
-.column_ld32:
- test cl, SIZEOF_YMMWORD
- jz short .column_ld64
- sub ecx, byte SIZEOF_YMMWORD
- vmovdqa ymmF, ymmA
- vmovdqu ymmA, YMMWORD [esi+0*SIZEOF_YMMWORD]
-.column_ld64:
- test cl, 2*SIZEOF_YMMWORD
- mov ecx, SIZEOF_YMMWORD
- jz short .rgb_ycc_cnv
- vmovdqa ymmB, ymmA
- vmovdqu ymmA, YMMWORD [esi+0*SIZEOF_YMMWORD]
- vmovdqu ymmF, YMMWORD [esi+1*SIZEOF_YMMWORD]
- jmp short .rgb_ycc_cnv
- alignx 16, 7
-
-.columnloop:
- vmovdqu ymmA, YMMWORD [esi+0*SIZEOF_YMMWORD]
- vmovdqu ymmF, YMMWORD [esi+1*SIZEOF_YMMWORD]
- vmovdqu ymmB, YMMWORD [esi+2*SIZEOF_YMMWORD]
-
-.rgb_ycc_cnv:
- ; ymmA=(00 10 20 01 11 21 02 12 22 03 13 23 04 14 24 05
- ; 15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A)
- ; ymmF=(2A 0B 1B 2B 0C 1C 2C 0D 1D 2D 0E 1E 2E 0F 1F 2F
- ; 0G 1G 2G 0H 1H 2H 0I 1I 2I 0J 1J 2J 0K 1K 2K 0L)
- ; ymmB=(1L 2L 0M 1M 2M 0N 1N 2N 0O 1O 2O 0P 1P 2P 0Q 1Q
- ; 2Q 0R 1R 2R 0S 1S 2S 0T 1T 2T 0U 1U 2U 0V 1V 2V)
-
- vmovdqu ymmC, ymmA
- vinserti128 ymmA, ymmF, xmmA, 0 ; ymmA=(00 10 20 01 11 21 02 12 22 03 13 23 04 14 24 05
- ; 0G 1G 2G 0H 1H 2H 0I 1I 2I 0J 1J 2J 0K 1K 2K 0L)
- vinserti128 ymmC, ymmC, xmmB, 0 ; ymmC=(1L 2L 0M 1M 2M 0N 1N 2N 0O 1O 2O 0P 1P 2P 0Q 1Q
- ; 15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A)
- vinserti128 ymmB, ymmB, xmmF, 0 ; ymmB=(2A 0B 1B 2B 0C 1C 2C 0D 1D 2D 0E 1E 2E 0F 1F 2F
- ; 2Q 0R 1R 2R 0S 1S 2S 0T 1T 2T 0U 1U 2U 0V 1V 2V)
- vperm2i128 ymmF, ymmC, ymmC, 1 ; ymmF=(15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A
- ; 1L 2L 0M 1M 2M 0N 1N 2N 0O 1O 2O 0P 1P 2P 0Q 1Q)
-
- vmovdqa ymmG, ymmA
- vpslldq ymmA, ymmA, 8 ; ymmA=(-- -- -- -- -- -- -- -- 00 10 20 01 11 21 02 12
- ; 22 03 13 23 04 14 24 05 0G 1G 2G 0H 1H 2H 0I 1I)
- vpsrldq ymmG, ymmG, 8 ; ymmG=(22 03 13 23 04 14 24 05 0G 1G 2G 0H 1H 2H 0I 1I
- ; 2I 0J 1J 2J 0K 1K 2K 0L -- -- -- -- -- -- -- --)
-
- vpunpckhbw ymmA, ymmA, ymmF ; ymmA=(00 08 10 18 20 28 01 09 11 19 21 29 02 0A 12 1A
- ; 0G 0O 1G 1O 2G 2O 0H 0P 1H 1P 2H 2P 0I 0Q 1I 1Q)
- vpslldq ymmF, ymmF, 8 ; ymmF=(-- -- -- -- -- -- -- -- 15 25 06 16 26 07 17 27
- ; 08 18 28 09 19 29 0A 1A 1L 2L 0M 1M 2M 0N 1N 2N)
-
- vpunpcklbw ymmG, ymmG, ymmB ; ymmG=(22 2A 03 0B 13 1B 23 2B 04 0C 14 1C 24 2C 05 0D
- ; 2I 2Q 0J 0R 1J 1R 2J 2R 0K 0S 1K 1S 2K 2S 0L 0T)
- vpunpckhbw ymmF, ymmF, ymmB ; ymmF=(15 1D 25 2D 06 0E 16 1E 26 2E 07 0F 17 1F 27 2F
- ; 1L 1T 2L 2T 0M 0U 1M 1U 2M 2U 0N 0V 1N 1V 2N 2V)
-
- vmovdqa ymmD, ymmA
- vpslldq ymmA, ymmA, 8 ; ymmA=(-- -- -- -- -- -- -- -- 00 08 10 18 20 28 01 09
- ; 11 19 21 29 02 0A 12 1A 0G 0O 1G 1O 2G 2O 0H 0P)
- vpsrldq ymmD, ymmD, 8 ; ymmD=(11 19 21 29 02 0A 12 1A 0G 0O 1G 1O 2G 2O 0H 0P
- ; 1H 1P 2H 2P 0I 0Q 1I 1Q -- -- -- -- -- -- -- --)
-
- vpunpckhbw ymmA, ymmA, ymmG ; ymmA=(00 04 08 0C 10 14 18 1C 20 24 28 2C 01 05 09 0D
- ; 0G 0K 0O 0S 1G 1K 1O 1S 2G 2K 2O 2S 0H 0L 0P 0T)
- vpslldq ymmG, ymmG, 8 ; ymmG=(-- -- -- -- -- -- -- -- 22 2A 03 0B 13 1B 23 2B
- ; 04 0C 14 1C 24 2C 05 0D 2I 2Q 0J 0R 1J 1R 2J 2R)
-
- vpunpcklbw ymmD, ymmD, ymmF ; ymmD=(11 15 19 1D 21 25 29 2D 02 06 0A 0E 12 16 1A 1E
- ; 1H 1L 1P 1T 2H 2L 2P 2T 0I 0M 0Q 0U 1I 1M 1Q 1U)
- vpunpckhbw ymmG, ymmG, ymmF ; ymmG=(22 26 2A 2E 03 07 0B 0F 13 17 1B 1F 23 27 2B 2F
- ; 2I 2M 2Q 2U 0J 0N 0R 0V 1J 1N 1R 1V 2J 2N 2R 2V)
-
- vmovdqa ymmE, ymmA
- vpslldq ymmA, ymmA, 8 ; ymmA=(-- -- -- -- -- -- -- -- 00 04 08 0C 10 14 18 1C
- ; 20 24 28 2C 01 05 09 0D 0G 0K 0O 0S 1G 1K 1O 1S)
- vpsrldq ymmE, ymmE, 8 ; ymmE=(20 24 28 2C 01 05 09 0D 0G 0K 0O 0S 1G 1K 1O 1S
- ; 2G 2K 2O 2S 0H 0L 0P 0T -- -- -- -- -- -- -- --)
-
- vpunpckhbw ymmA, ymmA, ymmD ; ymmA=(00 02 04 06 08 0A 0C 0E 10 12 14 16 18 1A 1C 1E
- ; 0G 0I 0K 0M 0O 0Q 0S 0U 1G 1I 1K 1M 1O 1Q 1S 1U)
- vpslldq ymmD, ymmD, 8 ; ymmD=(-- -- -- -- -- -- -- -- 11 15 19 1D 21 25 29 2D
- ; 02 06 0A 0E 12 16 1A 1E 1H 1L 1P 1T 2H 2L 2P 2T)
-
- vpunpcklbw ymmE, ymmE, ymmG ; ymmE=(20 22 24 26 28 2A 2C 2E 01 03 05 07 09 0B 0D 0F
- ; 2G 2I 2K 2M 2O 2Q 2S 2U 0H 0J 0L 0N 0P 0R 0T 0V)
- vpunpckhbw ymmD, ymmD, ymmG ; ymmD=(11 13 15 17 19 1B 1D 1F 21 23 25 27 29 2B 2D 2F
- ; 1H 1J 1L 1N 1P 1R 1T 1V 2H 2J 2L 2N 2P 2R 2T 2V)
-
- vpxor ymmH, ymmH, ymmH
-
- vmovdqa ymmC, ymmA
- vpunpcklbw ymmA, ymmA, ymmH ; ymmA=(00 02 04 06 08 0A 0C 0E 0G 0I 0K 0M 0O 0Q 0S 0U)
- vpunpckhbw ymmC, ymmC, ymmH ; ymmC=(10 12 14 16 18 1A 1C 1E 1G 1I 1K 1M 1O 1Q 1S 1U)
-
- vmovdqa ymmB, ymmE
- vpunpcklbw ymmE, ymmE, ymmH ; ymmE=(20 22 24 26 28 2A 2C 2E 2G 2I 2K 2M 2O 2Q 2S 2U)
- vpunpckhbw ymmB, ymmB, ymmH ; ymmB=(01 03 05 07 09 0B 0D 0F 0H 0J 0L 0N 0P 0R 0T 0V)
-
- vmovdqa ymmF, ymmD
- vpunpcklbw ymmD, ymmD, ymmH ; ymmD=(11 13 15 17 19 1B 1D 1F 1H 1J 1L 1N 1P 1R 1T 1V)
- vpunpckhbw ymmF, ymmF, ymmH ; ymmF=(21 23 25 27 29 2B 2D 2F 2H 2J 2L 2N 2P 2R 2T 2V)
-
-%else ; RGB_PIXELSIZE == 4 ; -----------
-
-.column_ld1:
- test cl, SIZEOF_XMMWORD/16
- jz short .column_ld2
- sub ecx, byte SIZEOF_XMMWORD/16
- vmovd xmmA, XMM_DWORD [esi+ecx*RGB_PIXELSIZE]
-.column_ld2:
- test cl, SIZEOF_XMMWORD/8
- jz short .column_ld4
- sub ecx, byte SIZEOF_XMMWORD/8
- vmovq xmmF, XMM_MMWORD [esi+ecx*RGB_PIXELSIZE]
- vpslldq xmmA, xmmA, SIZEOF_MMWORD
- vpor xmmA, xmmA, xmmF
-.column_ld4:
- test cl, SIZEOF_XMMWORD/4
- jz short .column_ld8
- sub ecx, byte SIZEOF_XMMWORD/4
- vmovdqa xmmF, xmmA
- vperm2i128 ymmF, ymmF, ymmF, 1
- vmovdqu xmmA, XMMWORD [esi+ecx*RGB_PIXELSIZE]
- vpor ymmA, ymmA, ymmF
-.column_ld8:
- test cl, SIZEOF_XMMWORD/2
- jz short .column_ld16
- sub ecx, byte SIZEOF_XMMWORD/2
- vmovdqa ymmF, ymmA
- vmovdqu ymmA, YMMWORD [esi+ecx*RGB_PIXELSIZE]
-.column_ld16:
- test cl, SIZEOF_XMMWORD
- mov ecx, SIZEOF_YMMWORD
- jz short .rgb_ycc_cnv
- vmovdqa ymmE, ymmA
- vmovdqa ymmH, ymmF
- vmovdqu ymmA, YMMWORD [esi+0*SIZEOF_YMMWORD]
- vmovdqu ymmF, YMMWORD [esi+1*SIZEOF_YMMWORD]
- jmp short .rgb_ycc_cnv
- alignx 16, 7
-
-.columnloop:
- vmovdqu ymmA, YMMWORD [esi+0*SIZEOF_YMMWORD]
- vmovdqu ymmF, YMMWORD [esi+1*SIZEOF_YMMWORD]
- vmovdqu ymmE, YMMWORD [esi+2*SIZEOF_YMMWORD]
- vmovdqu ymmH, YMMWORD [esi+3*SIZEOF_YMMWORD]
-
-.rgb_ycc_cnv:
- ; ymmA=(00 10 20 30 01 11 21 31 02 12 22 32 03 13 23 33
- ; 04 14 24 34 05 15 25 35 06 16 26 36 07 17 27 37)
- ; ymmF=(08 18 28 38 09 19 29 39 0A 1A 2A 3A 0B 1B 2B 3B
- ; 0C 1C 2C 3C 0D 1D 2D 3D 0E 1E 2E 3E 0F 1F 2F 3F)
- ; ymmE=(0G 1G 2G 3G 0H 1H 2H 3H 0I 1I 2I 3I 0J 1J 2J 3J
- ; 0K 1K 2K 3K 0L 1L 2L 3L 0M 1M 2M 3M 0N 1N 2N 3N)
- ; ymmH=(0O 1O 2O 3O 0P 1P 2P 3P 0Q 1Q 2Q 3Q 0R 1R 2R 3R
- ; 0S 1S 2S 3S 0T 1T 2T 3T 0U 1U 2U 3U 0V 1V 2V 3V)
-
- vmovdqa ymmB, ymmA
- vinserti128 ymmA, ymmA, xmmE, 1 ; ymmA=(00 10 20 30 01 11 21 31 02 12 22 32 03 13 23 33
- ; 0G 1G 2G 3G 0H 1H 2H 3H 0I 1I 2I 3I 0J 1J 2J 3J)
- vperm2i128 ymmE, ymmB, ymmE, 0x31 ; ymmE=(04 14 24 34 05 15 25 35 06 16 26 36 07 17 27 37
- ; 0K 1K 2K 3K 0L 1L 2L 3L 0M 1M 2M 3M 0N 1N 2N 3N)
-
- vmovdqa ymmB, ymmF
- vinserti128 ymmF, ymmF, xmmH, 1 ; ymmF=(08 18 28 38 09 19 29 39 0A 1A 2A 3A 0B 1B 2B 3B
- ; 0O 1O 2O 3O 0P 1P 2P 3P 0Q 1Q 2Q 3Q 0R 1R 2R 3R)
- vperm2i128 ymmH, ymmB, ymmH, 0x31 ; ymmH=(0C 1C 2C 3C 0D 1D 2D 3D 0E 1E 2E 3E 0F 1F 2F 3F
- ; 0S 1S 2S 3S 0T 1T 2T 3T 0U 1U 2U 3U 0V 1V 2V 3V)
-
- vmovdqa ymmD, ymmA
- vpunpcklbw ymmA, ymmA, ymmE ; ymmA=(00 04 10 14 20 24 30 34 01 05 11 15 21 25 31 35
- ; 0G 0K 1G 1K 2G 2K 3G 3K 0H 0L 1H 1L 2H 2L 3H 3L)
- vpunpckhbw ymmD, ymmD, ymmE ; ymmD=(02 06 12 16 22 26 32 36 03 07 13 17 23 27 33 37
- ; 0I 0M 1I 1M 2I 2M 3I 3M 0J 0N 1J 1N 2J 2N 3J 3N)
-
- vmovdqa ymmC, ymmF
- vpunpcklbw ymmF, ymmF, ymmH ; ymmF=(08 0C 18 1C 28 2C 38 3C 09 0D 19 1D 29 2D 39 3D
- ; 0O 0S 1O 1S 2O 2S 3O 3S 0P 0T 1P 1T 2P 2T 3P 3T)
- vpunpckhbw ymmC, ymmC, ymmH ; ymmC=(0A 0E 1A 1E 2A 2E 3A 3E 0B 0F 1B 1F 2B 2F 3B 3F
- ; 0Q 0U 1Q 1U 2Q 2U 3Q 3U 0R 0V 1R 1V 2R 2V 3R 3V)
-
- vmovdqa ymmB, ymmA
- vpunpcklwd ymmA, ymmA, ymmF ; ymmA=(00 04 08 0C 10 14 18 1C 20 24 28 2C 30 34 38 3C
- ; 0G 0K 0O 0S 1G 1K 1O 1S 2G 2K 2O 2S 3G 3K 3O 3S)
- vpunpckhwd ymmB, ymmB, ymmF ; ymmB=(01 05 09 0D 11 15 19 1D 21 25 29 2D 31 35 39 3D
- ; 0H 0L 0P 0T 1H 1L 1P 1T 2H 2L 2P 2T 3H 3L 3P 3T)
-
- vmovdqa ymmG, ymmD
- vpunpcklwd ymmD, ymmD, ymmC ; ymmD=(02 06 0A 0E 12 16 1A 1E 22 26 2A 2E 32 36 3A 3E
- ; 0I 0M 0Q 0U 1I 1M 1Q 1U 2I 2M 2Q 2U 3I 3M 3Q 3U)
- vpunpckhwd ymmG, ymmG, ymmC ; ymmG=(03 07 0B 0F 13 17 1B 1F 23 27 2B 2F 33 37 3B 3F
- ; 0J 0N 0R 0V 1J 1N 1R 1V 2J 2N 2R 2V 3J 3N 3R 3V)
-
- vmovdqa ymmE, ymmA
- vpunpcklbw ymmA, ymmA, ymmD ; ymmA=(00 02 04 06 08 0A 0C 0E 10 12 14 16 18 1A 1C 1E
- ; 0G 0I 0K 0M 0O 0Q 0S 0U 1G 1I 1K 1M 1O 1Q 1S 1U)
- vpunpckhbw ymmE, ymmE, ymmD ; ymmE=(20 22 24 26 28 2A 2C 2E 30 32 34 36 38 3A 3C 3E
- ; 2G 2I 2K 2M 2O 2Q 2S 2U 3G 3I 3K 3M 3O 3Q 3S 3U)
-
- vmovdqa ymmH, ymmB
- vpunpcklbw ymmB, ymmB, ymmG ; ymmB=(01 03 05 07 09 0B 0D 0F 11 13 15 17 19 1B 1D 1F
- ; 0H 0J 0L 0N 0P 0R 0T 0V 1H 1J 1L 1N 1P 1R 1T 1V)
- vpunpckhbw ymmH, ymmH, ymmG ; ymmH=(21 23 25 27 29 2B 2D 2F 31 33 35 37 39 3B 3D 3F
- ; 2H 2J 2L 2N 2P 2R 2T 2V 3H 3J 3L 3N 3P 3R 3T 3V)
-
- vpxor ymmF, ymmF, ymmF
-
- vmovdqa ymmC, ymmA
- vpunpcklbw ymmA, ymmA, ymmF ; ymmA=(00 02 04 06 08 0A 0C 0E 0G 0I 0K 0M 0O 0Q 0S 0U)
- vpunpckhbw ymmC, ymmC, ymmF ; ymmC=(10 12 14 16 18 1A 1C 1E 1G 1I 1K 1M 1O 1Q 1S 1U)
-
- vmovdqa ymmD, ymmB
- vpunpcklbw ymmB, ymmB, ymmF ; ymmB=(01 03 05 07 09 0B 0D 0F 0H 0J 0L 0N 0P 0R 0T 0V)
- vpunpckhbw ymmD, ymmD, ymmF ; ymmD=(11 13 15 17 19 1B 1D 1F 1H 1J 1L 1N 1P 1R 1T 1V)
-
- vmovdqa ymmG, ymmE
- vpunpcklbw ymmE, ymmE, ymmF ; ymmE=(20 22 24 26 28 2A 2C 2E 2G 2I 2K 2M 2O 2Q 2S 2U)
- vpunpckhbw ymmG, ymmG, ymmF ; ymmG=(30 32 34 36 38 3A 3C 3E 3G 3I 3K 3M 3O 3Q 3S 3U)
-
- vpunpcklbw ymmF, ymmF, ymmH
- vpunpckhbw ymmH, ymmH, ymmH
- vpsrlw ymmF, ymmF, BYTE_BIT ; ymmF=(21 23 25 27 29 2B 2D 2F 2H 2J 2L 2N 2P 2R 2T 2V)
- vpsrlw ymmH, ymmH, BYTE_BIT ; ymmH=(31 33 35 37 39 3B 3D 3F 3H 3J 3L 3N 3P 3R 3T 3V)
-
-%endif ; RGB_PIXELSIZE ; ---------------
-
- ; ymm0=R(02468ACEGIKMOQSU)=RE, ymm2=G(02468ACEGIKMOQSU)=GE, ymm4=B(02468ACEGIKMOQSU)=BE
- ; ymm1=R(13579BDFHJLNPRTV)=RO, ymm3=G(13579BDFHJLNPRTV)=GO, ymm5=B(13579BDFHJLNPRTV)=BO
-
- ; (Original)
- ; Y = 0.29900 * R + 0.58700 * G + 0.11400 * B
- ; Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + CENTERJSAMPLE
- ; Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + CENTERJSAMPLE
- ;
- ; (This implementation)
- ; Y = 0.29900 * R + 0.33700 * G + 0.11400 * B + 0.25000 * G
- ; Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + CENTERJSAMPLE
- ; Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + CENTERJSAMPLE
-
- vmovdqa YMMWORD [wk(0)], ymm0 ; wk(0)=RE
- vmovdqa YMMWORD [wk(1)], ymm1 ; wk(1)=RO
- vmovdqa YMMWORD [wk(2)], ymm4 ; wk(2)=BE
- vmovdqa YMMWORD [wk(3)], ymm5 ; wk(3)=BO
-
- vmovdqa ymm6, ymm1
- vpunpcklwd ymm1, ymm1, ymm3
- vpunpckhwd ymm6, ymm6, ymm3
- vmovdqa ymm7, ymm1
- vmovdqa ymm4, ymm6
- vpmaddwd ymm1, ymm1, [GOTOFF(eax,PW_F0299_F0337)] ; ymm1=ROL*FIX(0.299)+GOL*FIX(0.337)
- vpmaddwd ymm6, ymm6, [GOTOFF(eax,PW_F0299_F0337)] ; ymm6=ROH*FIX(0.299)+GOH*FIX(0.337)
- vpmaddwd ymm7, ymm7, [GOTOFF(eax,PW_MF016_MF033)] ; ymm7=ROL*-FIX(0.168)+GOL*-FIX(0.331)
- vpmaddwd ymm4, ymm4, [GOTOFF(eax,PW_MF016_MF033)] ; ymm4=ROH*-FIX(0.168)+GOH*-FIX(0.331)
-
- vmovdqa YMMWORD [wk(4)], ymm1 ; wk(4)=ROL*FIX(0.299)+GOL*FIX(0.337)
- vmovdqa YMMWORD [wk(5)], ymm6 ; wk(5)=ROH*FIX(0.299)+GOH*FIX(0.337)
-
- vpxor ymm1, ymm1, ymm1
- vpxor ymm6, ymm6, ymm6
- vpunpcklwd ymm1, ymm1, ymm5 ; ymm1=BOL
- vpunpckhwd ymm6, ymm6, ymm5 ; ymm6=BOH
- vpsrld ymm1, ymm1, 1 ; ymm1=BOL*FIX(0.500)
- vpsrld ymm6, ymm6, 1 ; ymm6=BOH*FIX(0.500)
-
- vmovdqa ymm5, [GOTOFF(eax,PD_ONEHALFM1_CJ)] ; ymm5=[PD_ONEHALFM1_CJ]
-
- vpaddd ymm7, ymm7, ymm1
- vpaddd ymm4, ymm4, ymm6
- vpaddd ymm7, ymm7, ymm5
- vpaddd ymm4, ymm4, ymm5
- vpsrld ymm7, ymm7, SCALEBITS ; ymm7=CbOL
- vpsrld ymm4, ymm4, SCALEBITS ; ymm4=CbOH
- vpackssdw ymm7, ymm7, ymm4 ; ymm7=CbO
-
- vmovdqa ymm1, YMMWORD [wk(2)] ; ymm1=BE
-
- vmovdqa ymm6, ymm0
- vpunpcklwd ymm0, ymm0, ymm2
- vpunpckhwd ymm6, ymm6, ymm2
- vmovdqa ymm5, ymm0
- vmovdqa ymm4, ymm6
- vpmaddwd ymm0, ymm0, [GOTOFF(eax,PW_F0299_F0337)] ; ymm0=REL*FIX(0.299)+GEL*FIX(0.337)
- vpmaddwd ymm6, ymm6, [GOTOFF(eax,PW_F0299_F0337)] ; ymm6=REH*FIX(0.299)+GEH*FIX(0.337)
- vpmaddwd ymm5, ymm5, [GOTOFF(eax,PW_MF016_MF033)] ; ymm5=REL*-FIX(0.168)+GEL*-FIX(0.331)
- vpmaddwd ymm4, ymm4, [GOTOFF(eax,PW_MF016_MF033)] ; ymm4=REH*-FIX(0.168)+GEH*-FIX(0.331)
-
- vmovdqa YMMWORD [wk(6)], ymm0 ; wk(6)=REL*FIX(0.299)+GEL*FIX(0.337)
- vmovdqa YMMWORD [wk(7)], ymm6 ; wk(7)=REH*FIX(0.299)+GEH*FIX(0.337)
-
- vpxor ymm0, ymm0, ymm0
- vpxor ymm6, ymm6, ymm6
- vpunpcklwd ymm0, ymm0, ymm1 ; ymm0=BEL
- vpunpckhwd ymm6, ymm6, ymm1 ; ymm6=BEH
- vpsrld ymm0, ymm0, 1 ; ymm0=BEL*FIX(0.500)
- vpsrld ymm6, ymm6, 1 ; ymm6=BEH*FIX(0.500)
-
- vmovdqa ymm1, [GOTOFF(eax,PD_ONEHALFM1_CJ)] ; ymm1=[PD_ONEHALFM1_CJ]
-
- vpaddd ymm5, ymm5, ymm0
- vpaddd ymm4, ymm4, ymm6
- vpaddd ymm5, ymm5, ymm1
- vpaddd ymm4, ymm4, ymm1
- vpsrld ymm5, ymm5, SCALEBITS ; ymm5=CbEL
- vpsrld ymm4, ymm4, SCALEBITS ; ymm4=CbEH
- vpackssdw ymm5, ymm5, ymm4 ; ymm5=CbE
-
- vpsllw ymm7, ymm7, BYTE_BIT
- vpor ymm5, ymm5, ymm7 ; ymm5=Cb
- vmovdqu YMMWORD [ebx], ymm5 ; Save Cb
-
- vmovdqa ymm0, YMMWORD [wk(3)] ; ymm0=BO
- vmovdqa ymm6, YMMWORD [wk(2)] ; ymm6=BE
- vmovdqa ymm1, YMMWORD [wk(1)] ; ymm1=RO
-
- vmovdqa ymm4, ymm0
- vpunpcklwd ymm0, ymm0, ymm3
- vpunpckhwd ymm4, ymm4, ymm3
- vmovdqa ymm7, ymm0
- vmovdqa ymm5, ymm4
- vpmaddwd ymm0, ymm0, [GOTOFF(eax,PW_F0114_F0250)] ; ymm0=BOL*FIX(0.114)+GOL*FIX(0.250)
- vpmaddwd ymm4, ymm4, [GOTOFF(eax,PW_F0114_F0250)] ; ymm4=BOH*FIX(0.114)+GOH*FIX(0.250)
- vpmaddwd ymm7, ymm7, [GOTOFF(eax,PW_MF008_MF041)] ; ymm7=BOL*-FIX(0.081)+GOL*-FIX(0.418)
- vpmaddwd ymm5, ymm5, [GOTOFF(eax,PW_MF008_MF041)] ; ymm5=BOH*-FIX(0.081)+GOH*-FIX(0.418)
-
- vmovdqa ymm3, [GOTOFF(eax,PD_ONEHALF)] ; ymm3=[PD_ONEHALF]
-
- vpaddd ymm0, ymm0, YMMWORD [wk(4)]
- vpaddd ymm4, ymm4, YMMWORD [wk(5)]
- vpaddd ymm0, ymm0, ymm3
- vpaddd ymm4, ymm4, ymm3
- vpsrld ymm0, ymm0, SCALEBITS ; ymm0=YOL
- vpsrld ymm4, ymm4, SCALEBITS ; ymm4=YOH
- vpackssdw ymm0, ymm0, ymm4 ; ymm0=YO
-
- vpxor ymm3, ymm3, ymm3
- vpxor ymm4, ymm4, ymm4
- vpunpcklwd ymm3, ymm3, ymm1 ; ymm3=ROL
- vpunpckhwd ymm4, ymm4, ymm1 ; ymm4=ROH
- vpsrld ymm3, ymm3, 1 ; ymm3=ROL*FIX(0.500)
- vpsrld ymm4, ymm4, 1 ; ymm4=ROH*FIX(0.500)
-
- vmovdqa ymm1, [GOTOFF(eax,PD_ONEHALFM1_CJ)] ; ymm1=[PD_ONEHALFM1_CJ]
-
- vpaddd ymm7, ymm7, ymm3
- vpaddd ymm5, ymm5, ymm4
- vpaddd ymm7, ymm7, ymm1
- vpaddd ymm5, ymm5, ymm1
- vpsrld ymm7, ymm7, SCALEBITS ; ymm7=CrOL
- vpsrld ymm5, ymm5, SCALEBITS ; ymm5=CrOH
- vpackssdw ymm7, ymm7, ymm5 ; ymm7=CrO
-
- vmovdqa ymm3, YMMWORD [wk(0)] ; ymm3=RE
-
- vmovdqa ymm4, ymm6
- vpunpcklwd ymm6, ymm6, ymm2
- vpunpckhwd ymm4, ymm4, ymm2
- vmovdqa ymm1, ymm6
- vmovdqa ymm5, ymm4
- vpmaddwd ymm6, ymm6, [GOTOFF(eax,PW_F0114_F0250)] ; ymm6=BEL*FIX(0.114)+GEL*FIX(0.250)
- vpmaddwd ymm4, ymm4, [GOTOFF(eax,PW_F0114_F0250)] ; ymm4=BEH*FIX(0.114)+GEH*FIX(0.250)
- vpmaddwd ymm1, ymm1, [GOTOFF(eax,PW_MF008_MF041)] ; ymm1=BEL*-FIX(0.081)+GEL*-FIX(0.418)
- vpmaddwd ymm5, ymm5, [GOTOFF(eax,PW_MF008_MF041)] ; ymm5=BEH*-FIX(0.081)+GEH*-FIX(0.418)
-
- vmovdqa ymm2, [GOTOFF(eax,PD_ONEHALF)] ; ymm2=[PD_ONEHALF]
-
- vpaddd ymm6, ymm6, YMMWORD [wk(6)]
- vpaddd ymm4, ymm4, YMMWORD [wk(7)]
- vpaddd ymm6, ymm6, ymm2
- vpaddd ymm4, ymm4, ymm2
- vpsrld ymm6, ymm6, SCALEBITS ; ymm6=YEL
- vpsrld ymm4, ymm4, SCALEBITS ; ymm4=YEH
- vpackssdw ymm6, ymm6, ymm4 ; ymm6=YE
-
- vpsllw ymm0, ymm0, BYTE_BIT
- vpor ymm6, ymm6, ymm0 ; ymm6=Y
- vmovdqu YMMWORD [edi], ymm6 ; Save Y
-
- vpxor ymm2, ymm2, ymm2
- vpxor ymm4, ymm4, ymm4
- vpunpcklwd ymm2, ymm2, ymm3 ; ymm2=REL
- vpunpckhwd ymm4, ymm4, ymm3 ; ymm4=REH
- vpsrld ymm2, ymm2, 1 ; ymm2=REL*FIX(0.500)
- vpsrld ymm4, ymm4, 1 ; ymm4=REH*FIX(0.500)
-
- vmovdqa ymm0, [GOTOFF(eax,PD_ONEHALFM1_CJ)] ; ymm0=[PD_ONEHALFM1_CJ]
-
- vpaddd ymm1, ymm1, ymm2
- vpaddd ymm5, ymm5, ymm4
- vpaddd ymm1, ymm1, ymm0
- vpaddd ymm5, ymm5, ymm0
- vpsrld ymm1, ymm1, SCALEBITS ; ymm1=CrEL
- vpsrld ymm5, ymm5, SCALEBITS ; ymm5=CrEH
- vpackssdw ymm1, ymm1, ymm5 ; ymm1=CrE
-
- vpsllw ymm7, ymm7, BYTE_BIT
- vpor ymm1, ymm1, ymm7 ; ymm1=Cr
- vmovdqu YMMWORD [edx], ymm1 ; Save Cr
-
- sub ecx, byte SIZEOF_YMMWORD
- add esi, RGB_PIXELSIZE*SIZEOF_YMMWORD ; inptr
- add edi, byte SIZEOF_YMMWORD ; outptr0
- add ebx, byte SIZEOF_YMMWORD ; outptr1
- add edx, byte SIZEOF_YMMWORD ; outptr2
- cmp ecx, byte SIZEOF_YMMWORD
- jae near .columnloop
- test ecx, ecx
- jnz near .column_ld1
-
- pop ecx ; col
- pop esi
- pop edi
- pop ebx
- pop edx
- poppic eax
-
- add esi, byte SIZEOF_JSAMPROW ; input_buf
- add edi, byte SIZEOF_JSAMPROW
- add ebx, byte SIZEOF_JSAMPROW
- add edx, byte SIZEOF_JSAMPROW
- dec eax ; num_rows
- jg near .rowloop
-
-.return:
- vzeroupper
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- pop ebx
- mov esp, ebp ; esp <- aligned ebp
- pop esp ; esp <- original ebp
- pop ebp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jccolext-mmx.asm b/contrib/libs/libjpeg-turbo/simd/i386/jccolext-mmx.asm
deleted file mode 100644
index 6357a42b2c..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jccolext-mmx.asm
+++ /dev/null
@@ -1,476 +0,0 @@
-;
-; jccolext.asm - colorspace conversion (MMX)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jcolsamp.inc"
-
-; --------------------------------------------------------------------------
-;
-; Convert some rows of samples to the output colorspace.
-;
-; GLOBAL(void)
-; jsimd_rgb_ycc_convert_mmx(JDIMENSION img_width, JSAMPARRAY input_buf,
-; JSAMPIMAGE output_buf, JDIMENSION output_row,
-; int num_rows);
-;
-
-%define img_width(b) (b) + 8 ; JDIMENSION img_width
-%define input_buf(b) (b) + 12 ; JSAMPARRAY input_buf
-%define output_buf(b) (b) + 16 ; JSAMPIMAGE output_buf
-%define output_row(b) (b) + 20 ; JDIMENSION output_row
-%define num_rows(b) (b) + 24 ; int num_rows
-
-%define original_ebp ebp + 0
-%define wk(i) ebp - (WK_NUM - (i)) * SIZEOF_MMWORD
- ; mmword wk[WK_NUM]
-%define WK_NUM 8
-%define gotptr wk(0) - SIZEOF_POINTER ; void * gotptr
-
- align 32
- GLOBAL_FUNCTION(jsimd_rgb_ycc_convert_mmx)
-
-EXTN(jsimd_rgb_ycc_convert_mmx):
- push ebp
- mov eax, esp ; eax = original ebp
- sub esp, byte 4
- and esp, byte (-SIZEOF_MMWORD) ; align to 64 bits
- mov [esp], eax
- mov ebp, esp ; ebp = aligned ebp
- lea esp, [wk(0)]
- pushpic eax ; make a room for GOT address
- push ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- get_GOT ebx ; get GOT address
- movpic POINTER [gotptr], ebx ; save GOT address
-
- mov ecx, JDIMENSION [img_width(eax)] ; num_cols
- test ecx, ecx
- jz near .return
-
- push ecx
-
- mov esi, JSAMPIMAGE [output_buf(eax)]
- mov ecx, JDIMENSION [output_row(eax)]
- mov edi, JSAMPARRAY [esi+0*SIZEOF_JSAMPARRAY]
- mov ebx, JSAMPARRAY [esi+1*SIZEOF_JSAMPARRAY]
- mov edx, JSAMPARRAY [esi+2*SIZEOF_JSAMPARRAY]
- lea edi, [edi+ecx*SIZEOF_JSAMPROW]
- lea ebx, [ebx+ecx*SIZEOF_JSAMPROW]
- lea edx, [edx+ecx*SIZEOF_JSAMPROW]
-
- pop ecx
-
- mov esi, JSAMPARRAY [input_buf(eax)]
- mov eax, INT [num_rows(eax)]
- test eax, eax
- jle near .return
- alignx 16, 7
-.rowloop:
- pushpic eax
- push edx
- push ebx
- push edi
- push esi
- push ecx ; col
-
- mov esi, JSAMPROW [esi] ; inptr
- mov edi, JSAMPROW [edi] ; outptr0
- mov ebx, JSAMPROW [ebx] ; outptr1
- mov edx, JSAMPROW [edx] ; outptr2
- movpic eax, POINTER [gotptr] ; load GOT address (eax)
-
- cmp ecx, byte SIZEOF_MMWORD
- jae short .columnloop
- alignx 16, 7
-
-%if RGB_PIXELSIZE == 3 ; ---------------
-
-.column_ld1:
- push eax
- push edx
- lea ecx, [ecx+ecx*2] ; imul ecx,RGB_PIXELSIZE
- test cl, SIZEOF_BYTE
- jz short .column_ld2
- sub ecx, byte SIZEOF_BYTE
- xor eax, eax
- mov al, byte [esi+ecx]
-.column_ld2:
- test cl, SIZEOF_WORD
- jz short .column_ld4
- sub ecx, byte SIZEOF_WORD
- xor edx, edx
- mov dx, word [esi+ecx]
- shl eax, WORD_BIT
- or eax, edx
-.column_ld4:
- movd mmA, eax
- pop edx
- pop eax
- test cl, SIZEOF_DWORD
- jz short .column_ld8
- sub ecx, byte SIZEOF_DWORD
- movd mmG, dword [esi+ecx]
- psllq mmA, DWORD_BIT
- por mmA, mmG
-.column_ld8:
- test cl, SIZEOF_MMWORD
- jz short .column_ld16
- movq mmG, mmA
- movq mmA, MMWORD [esi+0*SIZEOF_MMWORD]
- mov ecx, SIZEOF_MMWORD
- jmp short .rgb_ycc_cnv
-.column_ld16:
- test cl, 2*SIZEOF_MMWORD
- mov ecx, SIZEOF_MMWORD
- jz short .rgb_ycc_cnv
- movq mmF, mmA
- movq mmA, MMWORD [esi+0*SIZEOF_MMWORD]
- movq mmG, MMWORD [esi+1*SIZEOF_MMWORD]
- jmp short .rgb_ycc_cnv
- alignx 16, 7
-
-.columnloop:
- movq mmA, MMWORD [esi+0*SIZEOF_MMWORD]
- movq mmG, MMWORD [esi+1*SIZEOF_MMWORD]
- movq mmF, MMWORD [esi+2*SIZEOF_MMWORD]
-
-.rgb_ycc_cnv:
- ; mmA=(00 10 20 01 11 21 02 12)
- ; mmG=(22 03 13 23 04 14 24 05)
- ; mmF=(15 25 06 16 26 07 17 27)
-
- movq mmD, mmA
- psllq mmA, 4*BYTE_BIT ; mmA=(-- -- -- -- 00 10 20 01)
- psrlq mmD, 4*BYTE_BIT ; mmD=(11 21 02 12 -- -- -- --)
-
- punpckhbw mmA, mmG ; mmA=(00 04 10 14 20 24 01 05)
- psllq mmG, 4*BYTE_BIT ; mmG=(-- -- -- -- 22 03 13 23)
-
- punpcklbw mmD, mmF ; mmD=(11 15 21 25 02 06 12 16)
- punpckhbw mmG, mmF ; mmG=(22 26 03 07 13 17 23 27)
-
- movq mmE, mmA
- psllq mmA, 4*BYTE_BIT ; mmA=(-- -- -- -- 00 04 10 14)
- psrlq mmE, 4*BYTE_BIT ; mmE=(20 24 01 05 -- -- -- --)
-
- punpckhbw mmA, mmD ; mmA=(00 02 04 06 10 12 14 16)
- psllq mmD, 4*BYTE_BIT ; mmD=(-- -- -- -- 11 15 21 25)
-
- punpcklbw mmE, mmG ; mmE=(20 22 24 26 01 03 05 07)
- punpckhbw mmD, mmG ; mmD=(11 13 15 17 21 23 25 27)
-
- pxor mmH, mmH
-
- movq mmC, mmA
- punpcklbw mmA, mmH ; mmA=(00 02 04 06)
- punpckhbw mmC, mmH ; mmC=(10 12 14 16)
-
- movq mmB, mmE
- punpcklbw mmE, mmH ; mmE=(20 22 24 26)
- punpckhbw mmB, mmH ; mmB=(01 03 05 07)
-
- movq mmF, mmD
- punpcklbw mmD, mmH ; mmD=(11 13 15 17)
- punpckhbw mmF, mmH ; mmF=(21 23 25 27)
-
-%else ; RGB_PIXELSIZE == 4 ; -----------
-
-.column_ld1:
- test cl, SIZEOF_MMWORD/8
- jz short .column_ld2
- sub ecx, byte SIZEOF_MMWORD/8
- movd mmA, dword [esi+ecx*RGB_PIXELSIZE]
-.column_ld2:
- test cl, SIZEOF_MMWORD/4
- jz short .column_ld4
- sub ecx, byte SIZEOF_MMWORD/4
- movq mmF, mmA
- movq mmA, MMWORD [esi+ecx*RGB_PIXELSIZE]
-.column_ld4:
- test cl, SIZEOF_MMWORD/2
- mov ecx, SIZEOF_MMWORD
- jz short .rgb_ycc_cnv
- movq mmD, mmA
- movq mmC, mmF
- movq mmA, MMWORD [esi+0*SIZEOF_MMWORD]
- movq mmF, MMWORD [esi+1*SIZEOF_MMWORD]
- jmp short .rgb_ycc_cnv
- alignx 16, 7
-
-.columnloop:
- movq mmA, MMWORD [esi+0*SIZEOF_MMWORD]
- movq mmF, MMWORD [esi+1*SIZEOF_MMWORD]
- movq mmD, MMWORD [esi+2*SIZEOF_MMWORD]
- movq mmC, MMWORD [esi+3*SIZEOF_MMWORD]
-
-.rgb_ycc_cnv:
- ; mmA=(00 10 20 30 01 11 21 31)
- ; mmF=(02 12 22 32 03 13 23 33)
- ; mmD=(04 14 24 34 05 15 25 35)
- ; mmC=(06 16 26 36 07 17 27 37)
-
- movq mmB, mmA
- punpcklbw mmA, mmF ; mmA=(00 02 10 12 20 22 30 32)
- punpckhbw mmB, mmF ; mmB=(01 03 11 13 21 23 31 33)
-
- movq mmG, mmD
- punpcklbw mmD, mmC ; mmD=(04 06 14 16 24 26 34 36)
- punpckhbw mmG, mmC ; mmG=(05 07 15 17 25 27 35 37)
-
- movq mmE, mmA
- punpcklwd mmA, mmD ; mmA=(00 02 04 06 10 12 14 16)
- punpckhwd mmE, mmD ; mmE=(20 22 24 26 30 32 34 36)
-
- movq mmH, mmB
- punpcklwd mmB, mmG ; mmB=(01 03 05 07 11 13 15 17)
- punpckhwd mmH, mmG ; mmH=(21 23 25 27 31 33 35 37)
-
- pxor mmF, mmF
-
- movq mmC, mmA
- punpcklbw mmA, mmF ; mmA=(00 02 04 06)
- punpckhbw mmC, mmF ; mmC=(10 12 14 16)
-
- movq mmD, mmB
- punpcklbw mmB, mmF ; mmB=(01 03 05 07)
- punpckhbw mmD, mmF ; mmD=(11 13 15 17)
-
- movq mmG, mmE
- punpcklbw mmE, mmF ; mmE=(20 22 24 26)
- punpckhbw mmG, mmF ; mmG=(30 32 34 36)
-
- punpcklbw mmF, mmH
- punpckhbw mmH, mmH
- psrlw mmF, BYTE_BIT ; mmF=(21 23 25 27)
- psrlw mmH, BYTE_BIT ; mmH=(31 33 35 37)
-
-%endif ; RGB_PIXELSIZE ; ---------------
-
- ; mm0=(R0 R2 R4 R6)=RE, mm2=(G0 G2 G4 G6)=GE, mm4=(B0 B2 B4 B6)=BE
- ; mm1=(R1 R3 R5 R7)=RO, mm3=(G1 G3 G5 G7)=GO, mm5=(B1 B3 B5 B7)=BO
-
- ; (Original)
- ; Y = 0.29900 * R + 0.58700 * G + 0.11400 * B
- ; Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + CENTERJSAMPLE
- ; Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + CENTERJSAMPLE
- ;
- ; (This implementation)
- ; Y = 0.29900 * R + 0.33700 * G + 0.11400 * B + 0.25000 * G
- ; Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + CENTERJSAMPLE
- ; Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + CENTERJSAMPLE
-
- movq MMWORD [wk(0)], mm0 ; wk(0)=RE
- movq MMWORD [wk(1)], mm1 ; wk(1)=RO
- movq MMWORD [wk(2)], mm4 ; wk(2)=BE
- movq MMWORD [wk(3)], mm5 ; wk(3)=BO
-
- movq mm6, mm1
- punpcklwd mm1, mm3
- punpckhwd mm6, mm3
- movq mm7, mm1
- movq mm4, mm6
- pmaddwd mm1, [GOTOFF(eax,PW_F0299_F0337)] ; mm1=ROL*FIX(0.299)+GOL*FIX(0.337)
- pmaddwd mm6, [GOTOFF(eax,PW_F0299_F0337)] ; mm6=ROH*FIX(0.299)+GOH*FIX(0.337)
- pmaddwd mm7, [GOTOFF(eax,PW_MF016_MF033)] ; mm7=ROL*-FIX(0.168)+GOL*-FIX(0.331)
- pmaddwd mm4, [GOTOFF(eax,PW_MF016_MF033)] ; mm4=ROH*-FIX(0.168)+GOH*-FIX(0.331)
-
- movq MMWORD [wk(4)], mm1 ; wk(4)=ROL*FIX(0.299)+GOL*FIX(0.337)
- movq MMWORD [wk(5)], mm6 ; wk(5)=ROH*FIX(0.299)+GOH*FIX(0.337)
-
- pxor mm1, mm1
- pxor mm6, mm6
- punpcklwd mm1, mm5 ; mm1=BOL
- punpckhwd mm6, mm5 ; mm6=BOH
- psrld mm1, 1 ; mm1=BOL*FIX(0.500)
- psrld mm6, 1 ; mm6=BOH*FIX(0.500)
-
- movq mm5, [GOTOFF(eax,PD_ONEHALFM1_CJ)] ; mm5=[PD_ONEHALFM1_CJ]
-
- paddd mm7, mm1
- paddd mm4, mm6
- paddd mm7, mm5
- paddd mm4, mm5
- psrld mm7, SCALEBITS ; mm7=CbOL
- psrld mm4, SCALEBITS ; mm4=CbOH
- packssdw mm7, mm4 ; mm7=CbO
-
- movq mm1, MMWORD [wk(2)] ; mm1=BE
-
- movq mm6, mm0
- punpcklwd mm0, mm2
- punpckhwd mm6, mm2
- movq mm5, mm0
- movq mm4, mm6
- pmaddwd mm0, [GOTOFF(eax,PW_F0299_F0337)] ; mm0=REL*FIX(0.299)+GEL*FIX(0.337)
- pmaddwd mm6, [GOTOFF(eax,PW_F0299_F0337)] ; mm6=REH*FIX(0.299)+GEH*FIX(0.337)
- pmaddwd mm5, [GOTOFF(eax,PW_MF016_MF033)] ; mm5=REL*-FIX(0.168)+GEL*-FIX(0.331)
- pmaddwd mm4, [GOTOFF(eax,PW_MF016_MF033)] ; mm4=REH*-FIX(0.168)+GEH*-FIX(0.331)
-
- movq MMWORD [wk(6)], mm0 ; wk(6)=REL*FIX(0.299)+GEL*FIX(0.337)
- movq MMWORD [wk(7)], mm6 ; wk(7)=REH*FIX(0.299)+GEH*FIX(0.337)
-
- pxor mm0, mm0
- pxor mm6, mm6
- punpcklwd mm0, mm1 ; mm0=BEL
- punpckhwd mm6, mm1 ; mm6=BEH
- psrld mm0, 1 ; mm0=BEL*FIX(0.500)
- psrld mm6, 1 ; mm6=BEH*FIX(0.500)
-
- movq mm1, [GOTOFF(eax,PD_ONEHALFM1_CJ)] ; mm1=[PD_ONEHALFM1_CJ]
-
- paddd mm5, mm0
- paddd mm4, mm6
- paddd mm5, mm1
- paddd mm4, mm1
- psrld mm5, SCALEBITS ; mm5=CbEL
- psrld mm4, SCALEBITS ; mm4=CbEH
- packssdw mm5, mm4 ; mm5=CbE
-
- psllw mm7, BYTE_BIT
- por mm5, mm7 ; mm5=Cb
- movq MMWORD [ebx], mm5 ; Save Cb
-
- movq mm0, MMWORD [wk(3)] ; mm0=BO
- movq mm6, MMWORD [wk(2)] ; mm6=BE
- movq mm1, MMWORD [wk(1)] ; mm1=RO
-
- movq mm4, mm0
- punpcklwd mm0, mm3
- punpckhwd mm4, mm3
- movq mm7, mm0
- movq mm5, mm4
- pmaddwd mm0, [GOTOFF(eax,PW_F0114_F0250)] ; mm0=BOL*FIX(0.114)+GOL*FIX(0.250)
- pmaddwd mm4, [GOTOFF(eax,PW_F0114_F0250)] ; mm4=BOH*FIX(0.114)+GOH*FIX(0.250)
- pmaddwd mm7, [GOTOFF(eax,PW_MF008_MF041)] ; mm7=BOL*-FIX(0.081)+GOL*-FIX(0.418)
- pmaddwd mm5, [GOTOFF(eax,PW_MF008_MF041)] ; mm5=BOH*-FIX(0.081)+GOH*-FIX(0.418)
-
- movq mm3, [GOTOFF(eax,PD_ONEHALF)] ; mm3=[PD_ONEHALF]
-
- paddd mm0, MMWORD [wk(4)]
- paddd mm4, MMWORD [wk(5)]
- paddd mm0, mm3
- paddd mm4, mm3
- psrld mm0, SCALEBITS ; mm0=YOL
- psrld mm4, SCALEBITS ; mm4=YOH
- packssdw mm0, mm4 ; mm0=YO
-
- pxor mm3, mm3
- pxor mm4, mm4
- punpcklwd mm3, mm1 ; mm3=ROL
- punpckhwd mm4, mm1 ; mm4=ROH
- psrld mm3, 1 ; mm3=ROL*FIX(0.500)
- psrld mm4, 1 ; mm4=ROH*FIX(0.500)
-
- movq mm1, [GOTOFF(eax,PD_ONEHALFM1_CJ)] ; mm1=[PD_ONEHALFM1_CJ]
-
- paddd mm7, mm3
- paddd mm5, mm4
- paddd mm7, mm1
- paddd mm5, mm1
- psrld mm7, SCALEBITS ; mm7=CrOL
- psrld mm5, SCALEBITS ; mm5=CrOH
- packssdw mm7, mm5 ; mm7=CrO
-
- movq mm3, MMWORD [wk(0)] ; mm3=RE
-
- movq mm4, mm6
- punpcklwd mm6, mm2
- punpckhwd mm4, mm2
- movq mm1, mm6
- movq mm5, mm4
- pmaddwd mm6, [GOTOFF(eax,PW_F0114_F0250)] ; mm6=BEL*FIX(0.114)+GEL*FIX(0.250)
- pmaddwd mm4, [GOTOFF(eax,PW_F0114_F0250)] ; mm4=BEH*FIX(0.114)+GEH*FIX(0.250)
- pmaddwd mm1, [GOTOFF(eax,PW_MF008_MF041)] ; mm1=BEL*-FIX(0.081)+GEL*-FIX(0.418)
- pmaddwd mm5, [GOTOFF(eax,PW_MF008_MF041)] ; mm5=BEH*-FIX(0.081)+GEH*-FIX(0.418)
-
- movq mm2, [GOTOFF(eax,PD_ONEHALF)] ; mm2=[PD_ONEHALF]
-
- paddd mm6, MMWORD [wk(6)]
- paddd mm4, MMWORD [wk(7)]
- paddd mm6, mm2
- paddd mm4, mm2
- psrld mm6, SCALEBITS ; mm6=YEL
- psrld mm4, SCALEBITS ; mm4=YEH
- packssdw mm6, mm4 ; mm6=YE
-
- psllw mm0, BYTE_BIT
- por mm6, mm0 ; mm6=Y
- movq MMWORD [edi], mm6 ; Save Y
-
- pxor mm2, mm2
- pxor mm4, mm4
- punpcklwd mm2, mm3 ; mm2=REL
- punpckhwd mm4, mm3 ; mm4=REH
- psrld mm2, 1 ; mm2=REL*FIX(0.500)
- psrld mm4, 1 ; mm4=REH*FIX(0.500)
-
- movq mm0, [GOTOFF(eax,PD_ONEHALFM1_CJ)] ; mm0=[PD_ONEHALFM1_CJ]
-
- paddd mm1, mm2
- paddd mm5, mm4
- paddd mm1, mm0
- paddd mm5, mm0
- psrld mm1, SCALEBITS ; mm1=CrEL
- psrld mm5, SCALEBITS ; mm5=CrEH
- packssdw mm1, mm5 ; mm1=CrE
-
- psllw mm7, BYTE_BIT
- por mm1, mm7 ; mm1=Cr
- movq MMWORD [edx], mm1 ; Save Cr
-
- sub ecx, byte SIZEOF_MMWORD
- add esi, byte RGB_PIXELSIZE*SIZEOF_MMWORD ; inptr
- add edi, byte SIZEOF_MMWORD ; outptr0
- add ebx, byte SIZEOF_MMWORD ; outptr1
- add edx, byte SIZEOF_MMWORD ; outptr2
- cmp ecx, byte SIZEOF_MMWORD
- jae near .columnloop
- test ecx, ecx
- jnz near .column_ld1
-
- pop ecx ; col
- pop esi
- pop edi
- pop ebx
- pop edx
- poppic eax
-
- add esi, byte SIZEOF_JSAMPROW ; input_buf
- add edi, byte SIZEOF_JSAMPROW
- add ebx, byte SIZEOF_JSAMPROW
- add edx, byte SIZEOF_JSAMPROW
- dec eax ; num_rows
- jg near .rowloop
-
- emms ; empty MMX state
-
-.return:
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- pop ebx
- mov esp, ebp ; esp <- aligned ebp
- pop esp ; esp <- original ebp
- pop ebp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jccolext-sse2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jccolext-sse2.asm
deleted file mode 100644
index c6c80852ac..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jccolext-sse2.asm
+++ /dev/null
@@ -1,503 +0,0 @@
-;
-; jccolext.asm - colorspace conversion (SSE2)
-;
-; Copyright (C) 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jcolsamp.inc"
-
-; --------------------------------------------------------------------------
-;
-; Convert some rows of samples to the output colorspace.
-;
-; GLOBAL(void)
-; jsimd_rgb_ycc_convert_sse2(JDIMENSION img_width, JSAMPARRAY input_buf,
-; JSAMPIMAGE output_buf, JDIMENSION output_row,
-; int num_rows);
-;
-
-%define img_width(b) (b) + 8 ; JDIMENSION img_width
-%define input_buf(b) (b) + 12 ; JSAMPARRAY input_buf
-%define output_buf(b) (b) + 16 ; JSAMPIMAGE output_buf
-%define output_row(b) (b) + 20 ; JDIMENSION output_row
-%define num_rows(b) (b) + 24 ; int num_rows
-
-%define original_ebp ebp + 0
-%define wk(i) ebp - (WK_NUM - (i)) * SIZEOF_XMMWORD
- ; xmmword wk[WK_NUM]
-%define WK_NUM 8
-%define gotptr wk(0) - SIZEOF_POINTER ; void * gotptr
-
- align 32
- GLOBAL_FUNCTION(jsimd_rgb_ycc_convert_sse2)
-
-EXTN(jsimd_rgb_ycc_convert_sse2):
- push ebp
- mov eax, esp ; eax = original ebp
- sub esp, byte 4
- and esp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [esp], eax
- mov ebp, esp ; ebp = aligned ebp
- lea esp, [wk(0)]
- pushpic eax ; make a room for GOT address
- push ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- get_GOT ebx ; get GOT address
- movpic POINTER [gotptr], ebx ; save GOT address
-
- mov ecx, JDIMENSION [img_width(eax)]
- test ecx, ecx
- jz near .return
-
- push ecx
-
- mov esi, JSAMPIMAGE [output_buf(eax)]
- mov ecx, JDIMENSION [output_row(eax)]
- mov edi, JSAMPARRAY [esi+0*SIZEOF_JSAMPARRAY]
- mov ebx, JSAMPARRAY [esi+1*SIZEOF_JSAMPARRAY]
- mov edx, JSAMPARRAY [esi+2*SIZEOF_JSAMPARRAY]
- lea edi, [edi+ecx*SIZEOF_JSAMPROW]
- lea ebx, [ebx+ecx*SIZEOF_JSAMPROW]
- lea edx, [edx+ecx*SIZEOF_JSAMPROW]
-
- pop ecx
-
- mov esi, JSAMPARRAY [input_buf(eax)]
- mov eax, INT [num_rows(eax)]
- test eax, eax
- jle near .return
- alignx 16, 7
-.rowloop:
- pushpic eax
- push edx
- push ebx
- push edi
- push esi
- push ecx ; col
-
- mov esi, JSAMPROW [esi] ; inptr
- mov edi, JSAMPROW [edi] ; outptr0
- mov ebx, JSAMPROW [ebx] ; outptr1
- mov edx, JSAMPROW [edx] ; outptr2
- movpic eax, POINTER [gotptr] ; load GOT address (eax)
-
- cmp ecx, byte SIZEOF_XMMWORD
- jae near .columnloop
- alignx 16, 7
-
-%if RGB_PIXELSIZE == 3 ; ---------------
-
-.column_ld1:
- push eax
- push edx
- lea ecx, [ecx+ecx*2] ; imul ecx,RGB_PIXELSIZE
- test cl, SIZEOF_BYTE
- jz short .column_ld2
- sub ecx, byte SIZEOF_BYTE
- movzx eax, byte [esi+ecx]
-.column_ld2:
- test cl, SIZEOF_WORD
- jz short .column_ld4
- sub ecx, byte SIZEOF_WORD
- movzx edx, word [esi+ecx]
- shl eax, WORD_BIT
- or eax, edx
-.column_ld4:
- movd xmmA, eax
- pop edx
- pop eax
- test cl, SIZEOF_DWORD
- jz short .column_ld8
- sub ecx, byte SIZEOF_DWORD
- movd xmmF, XMM_DWORD [esi+ecx]
- pslldq xmmA, SIZEOF_DWORD
- por xmmA, xmmF
-.column_ld8:
- test cl, SIZEOF_MMWORD
- jz short .column_ld16
- sub ecx, byte SIZEOF_MMWORD
- movq xmmB, XMM_MMWORD [esi+ecx]
- pslldq xmmA, SIZEOF_MMWORD
- por xmmA, xmmB
-.column_ld16:
- test cl, SIZEOF_XMMWORD
- jz short .column_ld32
- movdqa xmmF, xmmA
- movdqu xmmA, XMMWORD [esi+0*SIZEOF_XMMWORD]
- mov ecx, SIZEOF_XMMWORD
- jmp short .rgb_ycc_cnv
-.column_ld32:
- test cl, 2*SIZEOF_XMMWORD
- mov ecx, SIZEOF_XMMWORD
- jz short .rgb_ycc_cnv
- movdqa xmmB, xmmA
- movdqu xmmA, XMMWORD [esi+0*SIZEOF_XMMWORD]
- movdqu xmmF, XMMWORD [esi+1*SIZEOF_XMMWORD]
- jmp short .rgb_ycc_cnv
- alignx 16, 7
-
-.columnloop:
- movdqu xmmA, XMMWORD [esi+0*SIZEOF_XMMWORD]
- movdqu xmmF, XMMWORD [esi+1*SIZEOF_XMMWORD]
- movdqu xmmB, XMMWORD [esi+2*SIZEOF_XMMWORD]
-
-.rgb_ycc_cnv:
- ; xmmA=(00 10 20 01 11 21 02 12 22 03 13 23 04 14 24 05)
- ; xmmF=(15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A)
- ; xmmB=(2A 0B 1B 2B 0C 1C 2C 0D 1D 2D 0E 1E 2E 0F 1F 2F)
-
- movdqa xmmG, xmmA
- pslldq xmmA, 8 ; xmmA=(-- -- -- -- -- -- -- -- 00 10 20 01 11 21 02 12)
- psrldq xmmG, 8 ; xmmG=(22 03 13 23 04 14 24 05 -- -- -- -- -- -- -- --)
-
- punpckhbw xmmA, xmmF ; xmmA=(00 08 10 18 20 28 01 09 11 19 21 29 02 0A 12 1A)
- pslldq xmmF, 8 ; xmmF=(-- -- -- -- -- -- -- -- 15 25 06 16 26 07 17 27)
-
- punpcklbw xmmG, xmmB ; xmmG=(22 2A 03 0B 13 1B 23 2B 04 0C 14 1C 24 2C 05 0D)
- punpckhbw xmmF, xmmB ; xmmF=(15 1D 25 2D 06 0E 16 1E 26 2E 07 0F 17 1F 27 2F)
-
- movdqa xmmD, xmmA
- pslldq xmmA, 8 ; xmmA=(-- -- -- -- -- -- -- -- 00 08 10 18 20 28 01 09)
- psrldq xmmD, 8 ; xmmD=(11 19 21 29 02 0A 12 1A -- -- -- -- -- -- -- --)
-
- punpckhbw xmmA, xmmG ; xmmA=(00 04 08 0C 10 14 18 1C 20 24 28 2C 01 05 09 0D)
- pslldq xmmG, 8 ; xmmG=(-- -- -- -- -- -- -- -- 22 2A 03 0B 13 1B 23 2B)
-
- punpcklbw xmmD, xmmF ; xmmD=(11 15 19 1D 21 25 29 2D 02 06 0A 0E 12 16 1A 1E)
- punpckhbw xmmG, xmmF ; xmmG=(22 26 2A 2E 03 07 0B 0F 13 17 1B 1F 23 27 2B 2F)
-
- movdqa xmmE, xmmA
- pslldq xmmA, 8 ; xmmA=(-- -- -- -- -- -- -- -- 00 04 08 0C 10 14 18 1C)
- psrldq xmmE, 8 ; xmmE=(20 24 28 2C 01 05 09 0D -- -- -- -- -- -- -- --)
-
- punpckhbw xmmA, xmmD ; xmmA=(00 02 04 06 08 0A 0C 0E 10 12 14 16 18 1A 1C 1E)
- pslldq xmmD, 8 ; xmmD=(-- -- -- -- -- -- -- -- 11 15 19 1D 21 25 29 2D)
-
- punpcklbw xmmE, xmmG ; xmmE=(20 22 24 26 28 2A 2C 2E 01 03 05 07 09 0B 0D 0F)
- punpckhbw xmmD, xmmG ; xmmD=(11 13 15 17 19 1B 1D 1F 21 23 25 27 29 2B 2D 2F)
-
- pxor xmmH, xmmH
-
- movdqa xmmC, xmmA
- punpcklbw xmmA, xmmH ; xmmA=(00 02 04 06 08 0A 0C 0E)
- punpckhbw xmmC, xmmH ; xmmC=(10 12 14 16 18 1A 1C 1E)
-
- movdqa xmmB, xmmE
- punpcklbw xmmE, xmmH ; xmmE=(20 22 24 26 28 2A 2C 2E)
- punpckhbw xmmB, xmmH ; xmmB=(01 03 05 07 09 0B 0D 0F)
-
- movdqa xmmF, xmmD
- punpcklbw xmmD, xmmH ; xmmD=(11 13 15 17 19 1B 1D 1F)
- punpckhbw xmmF, xmmH ; xmmF=(21 23 25 27 29 2B 2D 2F)
-
-%else ; RGB_PIXELSIZE == 4 ; -----------
-
-.column_ld1:
- test cl, SIZEOF_XMMWORD/16
- jz short .column_ld2
- sub ecx, byte SIZEOF_XMMWORD/16
- movd xmmA, XMM_DWORD [esi+ecx*RGB_PIXELSIZE]
-.column_ld2:
- test cl, SIZEOF_XMMWORD/8
- jz short .column_ld4
- sub ecx, byte SIZEOF_XMMWORD/8
- movq xmmE, XMM_MMWORD [esi+ecx*RGB_PIXELSIZE]
- pslldq xmmA, SIZEOF_MMWORD
- por xmmA, xmmE
-.column_ld4:
- test cl, SIZEOF_XMMWORD/4
- jz short .column_ld8
- sub ecx, byte SIZEOF_XMMWORD/4
- movdqa xmmE, xmmA
- movdqu xmmA, XMMWORD [esi+ecx*RGB_PIXELSIZE]
-.column_ld8:
- test cl, SIZEOF_XMMWORD/2
- mov ecx, SIZEOF_XMMWORD
- jz short .rgb_ycc_cnv
- movdqa xmmF, xmmA
- movdqa xmmH, xmmE
- movdqu xmmA, XMMWORD [esi+0*SIZEOF_XMMWORD]
- movdqu xmmE, XMMWORD [esi+1*SIZEOF_XMMWORD]
- jmp short .rgb_ycc_cnv
- alignx 16, 7
-
-.columnloop:
- movdqu xmmA, XMMWORD [esi+0*SIZEOF_XMMWORD]
- movdqu xmmE, XMMWORD [esi+1*SIZEOF_XMMWORD]
- movdqu xmmF, XMMWORD [esi+2*SIZEOF_XMMWORD]
- movdqu xmmH, XMMWORD [esi+3*SIZEOF_XMMWORD]
-
-.rgb_ycc_cnv:
- ; xmmA=(00 10 20 30 01 11 21 31 02 12 22 32 03 13 23 33)
- ; xmmE=(04 14 24 34 05 15 25 35 06 16 26 36 07 17 27 37)
- ; xmmF=(08 18 28 38 09 19 29 39 0A 1A 2A 3A 0B 1B 2B 3B)
- ; xmmH=(0C 1C 2C 3C 0D 1D 2D 3D 0E 1E 2E 3E 0F 1F 2F 3F)
-
- movdqa xmmD, xmmA
- punpcklbw xmmA, xmmE ; xmmA=(00 04 10 14 20 24 30 34 01 05 11 15 21 25 31 35)
- punpckhbw xmmD, xmmE ; xmmD=(02 06 12 16 22 26 32 36 03 07 13 17 23 27 33 37)
-
- movdqa xmmC, xmmF
- punpcklbw xmmF, xmmH ; xmmF=(08 0C 18 1C 28 2C 38 3C 09 0D 19 1D 29 2D 39 3D)
- punpckhbw xmmC, xmmH ; xmmC=(0A 0E 1A 1E 2A 2E 3A 3E 0B 0F 1B 1F 2B 2F 3B 3F)
-
- movdqa xmmB, xmmA
- punpcklwd xmmA, xmmF ; xmmA=(00 04 08 0C 10 14 18 1C 20 24 28 2C 30 34 38 3C)
- punpckhwd xmmB, xmmF ; xmmB=(01 05 09 0D 11 15 19 1D 21 25 29 2D 31 35 39 3D)
-
- movdqa xmmG, xmmD
- punpcklwd xmmD, xmmC ; xmmD=(02 06 0A 0E 12 16 1A 1E 22 26 2A 2E 32 36 3A 3E)
- punpckhwd xmmG, xmmC ; xmmG=(03 07 0B 0F 13 17 1B 1F 23 27 2B 2F 33 37 3B 3F)
-
- movdqa xmmE, xmmA
- punpcklbw xmmA, xmmD ; xmmA=(00 02 04 06 08 0A 0C 0E 10 12 14 16 18 1A 1C 1E)
- punpckhbw xmmE, xmmD ; xmmE=(20 22 24 26 28 2A 2C 2E 30 32 34 36 38 3A 3C 3E)
-
- movdqa xmmH, xmmB
- punpcklbw xmmB, xmmG ; xmmB=(01 03 05 07 09 0B 0D 0F 11 13 15 17 19 1B 1D 1F)
- punpckhbw xmmH, xmmG ; xmmH=(21 23 25 27 29 2B 2D 2F 31 33 35 37 39 3B 3D 3F)
-
- pxor xmmF, xmmF
-
- movdqa xmmC, xmmA
- punpcklbw xmmA, xmmF ; xmmA=(00 02 04 06 08 0A 0C 0E)
- punpckhbw xmmC, xmmF ; xmmC=(10 12 14 16 18 1A 1C 1E)
-
- movdqa xmmD, xmmB
- punpcklbw xmmB, xmmF ; xmmB=(01 03 05 07 09 0B 0D 0F)
- punpckhbw xmmD, xmmF ; xmmD=(11 13 15 17 19 1B 1D 1F)
-
- movdqa xmmG, xmmE
- punpcklbw xmmE, xmmF ; xmmE=(20 22 24 26 28 2A 2C 2E)
- punpckhbw xmmG, xmmF ; xmmG=(30 32 34 36 38 3A 3C 3E)
-
- punpcklbw xmmF, xmmH
- punpckhbw xmmH, xmmH
- psrlw xmmF, BYTE_BIT ; xmmF=(21 23 25 27 29 2B 2D 2F)
- psrlw xmmH, BYTE_BIT ; xmmH=(31 33 35 37 39 3B 3D 3F)
-
-%endif ; RGB_PIXELSIZE ; ---------------
-
- ; xmm0=R(02468ACE)=RE, xmm2=G(02468ACE)=GE, xmm4=B(02468ACE)=BE
- ; xmm1=R(13579BDF)=RO, xmm3=G(13579BDF)=GO, xmm5=B(13579BDF)=BO
-
- ; (Original)
- ; Y = 0.29900 * R + 0.58700 * G + 0.11400 * B
- ; Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + CENTERJSAMPLE
- ; Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + CENTERJSAMPLE
- ;
- ; (This implementation)
- ; Y = 0.29900 * R + 0.33700 * G + 0.11400 * B + 0.25000 * G
- ; Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + CENTERJSAMPLE
- ; Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + CENTERJSAMPLE
-
- movdqa XMMWORD [wk(0)], xmm0 ; wk(0)=RE
- movdqa XMMWORD [wk(1)], xmm1 ; wk(1)=RO
- movdqa XMMWORD [wk(2)], xmm4 ; wk(2)=BE
- movdqa XMMWORD [wk(3)], xmm5 ; wk(3)=BO
-
- movdqa xmm6, xmm1
- punpcklwd xmm1, xmm3
- punpckhwd xmm6, xmm3
- movdqa xmm7, xmm1
- movdqa xmm4, xmm6
- pmaddwd xmm1, [GOTOFF(eax,PW_F0299_F0337)] ; xmm1=ROL*FIX(0.299)+GOL*FIX(0.337)
- pmaddwd xmm6, [GOTOFF(eax,PW_F0299_F0337)] ; xmm6=ROH*FIX(0.299)+GOH*FIX(0.337)
- pmaddwd xmm7, [GOTOFF(eax,PW_MF016_MF033)] ; xmm7=ROL*-FIX(0.168)+GOL*-FIX(0.331)
- pmaddwd xmm4, [GOTOFF(eax,PW_MF016_MF033)] ; xmm4=ROH*-FIX(0.168)+GOH*-FIX(0.331)
-
- movdqa XMMWORD [wk(4)], xmm1 ; wk(4)=ROL*FIX(0.299)+GOL*FIX(0.337)
- movdqa XMMWORD [wk(5)], xmm6 ; wk(5)=ROH*FIX(0.299)+GOH*FIX(0.337)
-
- pxor xmm1, xmm1
- pxor xmm6, xmm6
- punpcklwd xmm1, xmm5 ; xmm1=BOL
- punpckhwd xmm6, xmm5 ; xmm6=BOH
- psrld xmm1, 1 ; xmm1=BOL*FIX(0.500)
- psrld xmm6, 1 ; xmm6=BOH*FIX(0.500)
-
- movdqa xmm5, [GOTOFF(eax,PD_ONEHALFM1_CJ)] ; xmm5=[PD_ONEHALFM1_CJ]
-
- paddd xmm7, xmm1
- paddd xmm4, xmm6
- paddd xmm7, xmm5
- paddd xmm4, xmm5
- psrld xmm7, SCALEBITS ; xmm7=CbOL
- psrld xmm4, SCALEBITS ; xmm4=CbOH
- packssdw xmm7, xmm4 ; xmm7=CbO
-
- movdqa xmm1, XMMWORD [wk(2)] ; xmm1=BE
-
- movdqa xmm6, xmm0
- punpcklwd xmm0, xmm2
- punpckhwd xmm6, xmm2
- movdqa xmm5, xmm0
- movdqa xmm4, xmm6
- pmaddwd xmm0, [GOTOFF(eax,PW_F0299_F0337)] ; xmm0=REL*FIX(0.299)+GEL*FIX(0.337)
- pmaddwd xmm6, [GOTOFF(eax,PW_F0299_F0337)] ; xmm6=REH*FIX(0.299)+GEH*FIX(0.337)
- pmaddwd xmm5, [GOTOFF(eax,PW_MF016_MF033)] ; xmm5=REL*-FIX(0.168)+GEL*-FIX(0.331)
- pmaddwd xmm4, [GOTOFF(eax,PW_MF016_MF033)] ; xmm4=REH*-FIX(0.168)+GEH*-FIX(0.331)
-
- movdqa XMMWORD [wk(6)], xmm0 ; wk(6)=REL*FIX(0.299)+GEL*FIX(0.337)
- movdqa XMMWORD [wk(7)], xmm6 ; wk(7)=REH*FIX(0.299)+GEH*FIX(0.337)
-
- pxor xmm0, xmm0
- pxor xmm6, xmm6
- punpcklwd xmm0, xmm1 ; xmm0=BEL
- punpckhwd xmm6, xmm1 ; xmm6=BEH
- psrld xmm0, 1 ; xmm0=BEL*FIX(0.500)
- psrld xmm6, 1 ; xmm6=BEH*FIX(0.500)
-
- movdqa xmm1, [GOTOFF(eax,PD_ONEHALFM1_CJ)] ; xmm1=[PD_ONEHALFM1_CJ]
-
- paddd xmm5, xmm0
- paddd xmm4, xmm6
- paddd xmm5, xmm1
- paddd xmm4, xmm1
- psrld xmm5, SCALEBITS ; xmm5=CbEL
- psrld xmm4, SCALEBITS ; xmm4=CbEH
- packssdw xmm5, xmm4 ; xmm5=CbE
-
- psllw xmm7, BYTE_BIT
- por xmm5, xmm7 ; xmm5=Cb
- movdqa XMMWORD [ebx], xmm5 ; Save Cb
-
- movdqa xmm0, XMMWORD [wk(3)] ; xmm0=BO
- movdqa xmm6, XMMWORD [wk(2)] ; xmm6=BE
- movdqa xmm1, XMMWORD [wk(1)] ; xmm1=RO
-
- movdqa xmm4, xmm0
- punpcklwd xmm0, xmm3
- punpckhwd xmm4, xmm3
- movdqa xmm7, xmm0
- movdqa xmm5, xmm4
- pmaddwd xmm0, [GOTOFF(eax,PW_F0114_F0250)] ; xmm0=BOL*FIX(0.114)+GOL*FIX(0.250)
- pmaddwd xmm4, [GOTOFF(eax,PW_F0114_F0250)] ; xmm4=BOH*FIX(0.114)+GOH*FIX(0.250)
- pmaddwd xmm7, [GOTOFF(eax,PW_MF008_MF041)] ; xmm7=BOL*-FIX(0.081)+GOL*-FIX(0.418)
- pmaddwd xmm5, [GOTOFF(eax,PW_MF008_MF041)] ; xmm5=BOH*-FIX(0.081)+GOH*-FIX(0.418)
-
- movdqa xmm3, [GOTOFF(eax,PD_ONEHALF)] ; xmm3=[PD_ONEHALF]
-
- paddd xmm0, XMMWORD [wk(4)]
- paddd xmm4, XMMWORD [wk(5)]
- paddd xmm0, xmm3
- paddd xmm4, xmm3
- psrld xmm0, SCALEBITS ; xmm0=YOL
- psrld xmm4, SCALEBITS ; xmm4=YOH
- packssdw xmm0, xmm4 ; xmm0=YO
-
- pxor xmm3, xmm3
- pxor xmm4, xmm4
- punpcklwd xmm3, xmm1 ; xmm3=ROL
- punpckhwd xmm4, xmm1 ; xmm4=ROH
- psrld xmm3, 1 ; xmm3=ROL*FIX(0.500)
- psrld xmm4, 1 ; xmm4=ROH*FIX(0.500)
-
- movdqa xmm1, [GOTOFF(eax,PD_ONEHALFM1_CJ)] ; xmm1=[PD_ONEHALFM1_CJ]
-
- paddd xmm7, xmm3
- paddd xmm5, xmm4
- paddd xmm7, xmm1
- paddd xmm5, xmm1
- psrld xmm7, SCALEBITS ; xmm7=CrOL
- psrld xmm5, SCALEBITS ; xmm5=CrOH
- packssdw xmm7, xmm5 ; xmm7=CrO
-
- movdqa xmm3, XMMWORD [wk(0)] ; xmm3=RE
-
- movdqa xmm4, xmm6
- punpcklwd xmm6, xmm2
- punpckhwd xmm4, xmm2
- movdqa xmm1, xmm6
- movdqa xmm5, xmm4
- pmaddwd xmm6, [GOTOFF(eax,PW_F0114_F0250)] ; xmm6=BEL*FIX(0.114)+GEL*FIX(0.250)
- pmaddwd xmm4, [GOTOFF(eax,PW_F0114_F0250)] ; xmm4=BEH*FIX(0.114)+GEH*FIX(0.250)
- pmaddwd xmm1, [GOTOFF(eax,PW_MF008_MF041)] ; xmm1=BEL*-FIX(0.081)+GEL*-FIX(0.418)
- pmaddwd xmm5, [GOTOFF(eax,PW_MF008_MF041)] ; xmm5=BEH*-FIX(0.081)+GEH*-FIX(0.418)
-
- movdqa xmm2, [GOTOFF(eax,PD_ONEHALF)] ; xmm2=[PD_ONEHALF]
-
- paddd xmm6, XMMWORD [wk(6)]
- paddd xmm4, XMMWORD [wk(7)]
- paddd xmm6, xmm2
- paddd xmm4, xmm2
- psrld xmm6, SCALEBITS ; xmm6=YEL
- psrld xmm4, SCALEBITS ; xmm4=YEH
- packssdw xmm6, xmm4 ; xmm6=YE
-
- psllw xmm0, BYTE_BIT
- por xmm6, xmm0 ; xmm6=Y
- movdqa XMMWORD [edi], xmm6 ; Save Y
-
- pxor xmm2, xmm2
- pxor xmm4, xmm4
- punpcklwd xmm2, xmm3 ; xmm2=REL
- punpckhwd xmm4, xmm3 ; xmm4=REH
- psrld xmm2, 1 ; xmm2=REL*FIX(0.500)
- psrld xmm4, 1 ; xmm4=REH*FIX(0.500)
-
- movdqa xmm0, [GOTOFF(eax,PD_ONEHALFM1_CJ)] ; xmm0=[PD_ONEHALFM1_CJ]
-
- paddd xmm1, xmm2
- paddd xmm5, xmm4
- paddd xmm1, xmm0
- paddd xmm5, xmm0
- psrld xmm1, SCALEBITS ; xmm1=CrEL
- psrld xmm5, SCALEBITS ; xmm5=CrEH
- packssdw xmm1, xmm5 ; xmm1=CrE
-
- psllw xmm7, BYTE_BIT
- por xmm1, xmm7 ; xmm1=Cr
- movdqa XMMWORD [edx], xmm1 ; Save Cr
-
- sub ecx, byte SIZEOF_XMMWORD
- add esi, byte RGB_PIXELSIZE*SIZEOF_XMMWORD ; inptr
- add edi, byte SIZEOF_XMMWORD ; outptr0
- add ebx, byte SIZEOF_XMMWORD ; outptr1
- add edx, byte SIZEOF_XMMWORD ; outptr2
- cmp ecx, byte SIZEOF_XMMWORD
- jae near .columnloop
- test ecx, ecx
- jnz near .column_ld1
-
- pop ecx ; col
- pop esi
- pop edi
- pop ebx
- pop edx
- poppic eax
-
- add esi, byte SIZEOF_JSAMPROW ; input_buf
- add edi, byte SIZEOF_JSAMPROW
- add ebx, byte SIZEOF_JSAMPROW
- add edx, byte SIZEOF_JSAMPROW
- dec eax ; num_rows
- jg near .rowloop
-
-.return:
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- pop ebx
- mov esp, ebp ; esp <- aligned ebp
- pop esp ; esp <- original ebp
- pop ebp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jccolor-avx2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jccolor-avx2.asm
deleted file mode 100644
index 14944e952f..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jccolor-avx2.asm
+++ /dev/null
@@ -1,121 +0,0 @@
-;
-; jccolor.asm - colorspace conversion (AVX2)
-;
-; Copyright (C) 2009, 2016, D. R. Commander.
-; Copyright (C) 2015, Intel Corporation.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jsimdext.inc"
-
-; --------------------------------------------------------------------------
-
-%define SCALEBITS 16
-
-F_0_081 equ 5329 ; FIX(0.08131)
-F_0_114 equ 7471 ; FIX(0.11400)
-F_0_168 equ 11059 ; FIX(0.16874)
-F_0_250 equ 16384 ; FIX(0.25000)
-F_0_299 equ 19595 ; FIX(0.29900)
-F_0_331 equ 21709 ; FIX(0.33126)
-F_0_418 equ 27439 ; FIX(0.41869)
-F_0_587 equ 38470 ; FIX(0.58700)
-F_0_337 equ (F_0_587 - F_0_250) ; FIX(0.58700) - FIX(0.25000)
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_rgb_ycc_convert_avx2)
-
-EXTN(jconst_rgb_ycc_convert_avx2):
-
-PW_F0299_F0337 times 8 dw F_0_299, F_0_337
-PW_F0114_F0250 times 8 dw F_0_114, F_0_250
-PW_MF016_MF033 times 8 dw -F_0_168, -F_0_331
-PW_MF008_MF041 times 8 dw -F_0_081, -F_0_418
-PD_ONEHALFM1_CJ times 8 dd (1 << (SCALEBITS - 1)) - 1 + \
- (CENTERJSAMPLE << SCALEBITS)
-PD_ONEHALF times 8 dd (1 << (SCALEBITS - 1))
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-
-%include "jccolext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_RGB_RED
-%define RGB_GREEN EXT_RGB_GREEN
-%define RGB_BLUE EXT_RGB_BLUE
-%define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
-%define jsimd_rgb_ycc_convert_avx2 jsimd_extrgb_ycc_convert_avx2
-%include "jccolext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_RGBX_RED
-%define RGB_GREEN EXT_RGBX_GREEN
-%define RGB_BLUE EXT_RGBX_BLUE
-%define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
-%define jsimd_rgb_ycc_convert_avx2 jsimd_extrgbx_ycc_convert_avx2
-%include "jccolext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_BGR_RED
-%define RGB_GREEN EXT_BGR_GREEN
-%define RGB_BLUE EXT_BGR_BLUE
-%define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
-%define jsimd_rgb_ycc_convert_avx2 jsimd_extbgr_ycc_convert_avx2
-%include "jccolext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_BGRX_RED
-%define RGB_GREEN EXT_BGRX_GREEN
-%define RGB_BLUE EXT_BGRX_BLUE
-%define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
-%define jsimd_rgb_ycc_convert_avx2 jsimd_extbgrx_ycc_convert_avx2
-%include "jccolext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_XBGR_RED
-%define RGB_GREEN EXT_XBGR_GREEN
-%define RGB_BLUE EXT_XBGR_BLUE
-%define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
-%define jsimd_rgb_ycc_convert_avx2 jsimd_extxbgr_ycc_convert_avx2
-%include "jccolext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_XRGB_RED
-%define RGB_GREEN EXT_XRGB_GREEN
-%define RGB_BLUE EXT_XRGB_BLUE
-%define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
-%define jsimd_rgb_ycc_convert_avx2 jsimd_extxrgb_ycc_convert_avx2
-%include "jccolext-avx2.asm"
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jccolor-mmx.asm b/contrib/libs/libjpeg-turbo/simd/i386/jccolor-mmx.asm
deleted file mode 100644
index 8cb399bdc4..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jccolor-mmx.asm
+++ /dev/null
@@ -1,121 +0,0 @@
-;
-; jccolor.asm - colorspace conversion (MMX)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jsimdext.inc"
-
-; --------------------------------------------------------------------------
-
-%define SCALEBITS 16
-
-F_0_081 equ 5329 ; FIX(0.08131)
-F_0_114 equ 7471 ; FIX(0.11400)
-F_0_168 equ 11059 ; FIX(0.16874)
-F_0_250 equ 16384 ; FIX(0.25000)
-F_0_299 equ 19595 ; FIX(0.29900)
-F_0_331 equ 21709 ; FIX(0.33126)
-F_0_418 equ 27439 ; FIX(0.41869)
-F_0_587 equ 38470 ; FIX(0.58700)
-F_0_337 equ (F_0_587 - F_0_250) ; FIX(0.58700) - FIX(0.25000)
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_rgb_ycc_convert_mmx)
-
-EXTN(jconst_rgb_ycc_convert_mmx):
-
-PW_F0299_F0337 times 2 dw F_0_299, F_0_337
-PW_F0114_F0250 times 2 dw F_0_114, F_0_250
-PW_MF016_MF033 times 2 dw -F_0_168, -F_0_331
-PW_MF008_MF041 times 2 dw -F_0_081, -F_0_418
-PD_ONEHALFM1_CJ times 2 dd (1 << (SCALEBITS - 1)) - 1 + \
- (CENTERJSAMPLE << SCALEBITS)
-PD_ONEHALF times 2 dd (1 << (SCALEBITS - 1))
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-
-%include "jccolext-mmx.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_RGB_RED
-%define RGB_GREEN EXT_RGB_GREEN
-%define RGB_BLUE EXT_RGB_BLUE
-%define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
-%define jsimd_rgb_ycc_convert_mmx jsimd_extrgb_ycc_convert_mmx
-%include "jccolext-mmx.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_RGBX_RED
-%define RGB_GREEN EXT_RGBX_GREEN
-%define RGB_BLUE EXT_RGBX_BLUE
-%define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
-%define jsimd_rgb_ycc_convert_mmx jsimd_extrgbx_ycc_convert_mmx
-%include "jccolext-mmx.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_BGR_RED
-%define RGB_GREEN EXT_BGR_GREEN
-%define RGB_BLUE EXT_BGR_BLUE
-%define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
-%define jsimd_rgb_ycc_convert_mmx jsimd_extbgr_ycc_convert_mmx
-%include "jccolext-mmx.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_BGRX_RED
-%define RGB_GREEN EXT_BGRX_GREEN
-%define RGB_BLUE EXT_BGRX_BLUE
-%define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
-%define jsimd_rgb_ycc_convert_mmx jsimd_extbgrx_ycc_convert_mmx
-%include "jccolext-mmx.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_XBGR_RED
-%define RGB_GREEN EXT_XBGR_GREEN
-%define RGB_BLUE EXT_XBGR_BLUE
-%define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
-%define jsimd_rgb_ycc_convert_mmx jsimd_extxbgr_ycc_convert_mmx
-%include "jccolext-mmx.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_XRGB_RED
-%define RGB_GREEN EXT_XRGB_GREEN
-%define RGB_BLUE EXT_XRGB_BLUE
-%define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
-%define jsimd_rgb_ycc_convert_mmx jsimd_extxrgb_ycc_convert_mmx
-%include "jccolext-mmx.asm"
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jccolor-sse2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jccolor-sse2.asm
deleted file mode 100644
index 686d222ff7..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jccolor-sse2.asm
+++ /dev/null
@@ -1,120 +0,0 @@
-;
-; jccolor.asm - colorspace conversion (SSE2)
-;
-; Copyright (C) 2009, 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jsimdext.inc"
-
-; --------------------------------------------------------------------------
-
-%define SCALEBITS 16
-
-F_0_081 equ 5329 ; FIX(0.08131)
-F_0_114 equ 7471 ; FIX(0.11400)
-F_0_168 equ 11059 ; FIX(0.16874)
-F_0_250 equ 16384 ; FIX(0.25000)
-F_0_299 equ 19595 ; FIX(0.29900)
-F_0_331 equ 21709 ; FIX(0.33126)
-F_0_418 equ 27439 ; FIX(0.41869)
-F_0_587 equ 38470 ; FIX(0.58700)
-F_0_337 equ (F_0_587 - F_0_250) ; FIX(0.58700) - FIX(0.25000)
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_rgb_ycc_convert_sse2)
-
-EXTN(jconst_rgb_ycc_convert_sse2):
-
-PW_F0299_F0337 times 4 dw F_0_299, F_0_337
-PW_F0114_F0250 times 4 dw F_0_114, F_0_250
-PW_MF016_MF033 times 4 dw -F_0_168, -F_0_331
-PW_MF008_MF041 times 4 dw -F_0_081, -F_0_418
-PD_ONEHALFM1_CJ times 4 dd (1 << (SCALEBITS - 1)) - 1 + \
- (CENTERJSAMPLE << SCALEBITS)
-PD_ONEHALF times 4 dd (1 << (SCALEBITS - 1))
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-
-%include "jccolext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_RGB_RED
-%define RGB_GREEN EXT_RGB_GREEN
-%define RGB_BLUE EXT_RGB_BLUE
-%define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
-%define jsimd_rgb_ycc_convert_sse2 jsimd_extrgb_ycc_convert_sse2
-%include "jccolext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_RGBX_RED
-%define RGB_GREEN EXT_RGBX_GREEN
-%define RGB_BLUE EXT_RGBX_BLUE
-%define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
-%define jsimd_rgb_ycc_convert_sse2 jsimd_extrgbx_ycc_convert_sse2
-%include "jccolext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_BGR_RED
-%define RGB_GREEN EXT_BGR_GREEN
-%define RGB_BLUE EXT_BGR_BLUE
-%define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
-%define jsimd_rgb_ycc_convert_sse2 jsimd_extbgr_ycc_convert_sse2
-%include "jccolext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_BGRX_RED
-%define RGB_GREEN EXT_BGRX_GREEN
-%define RGB_BLUE EXT_BGRX_BLUE
-%define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
-%define jsimd_rgb_ycc_convert_sse2 jsimd_extbgrx_ycc_convert_sse2
-%include "jccolext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_XBGR_RED
-%define RGB_GREEN EXT_XBGR_GREEN
-%define RGB_BLUE EXT_XBGR_BLUE
-%define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
-%define jsimd_rgb_ycc_convert_sse2 jsimd_extxbgr_ycc_convert_sse2
-%include "jccolext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_XRGB_RED
-%define RGB_GREEN EXT_XRGB_GREEN
-%define RGB_BLUE EXT_XRGB_BLUE
-%define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
-%define jsimd_rgb_ycc_convert_sse2 jsimd_extxrgb_ycc_convert_sse2
-%include "jccolext-sse2.asm"
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jcgray-avx2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jcgray-avx2.asm
deleted file mode 100644
index 560ee0c71e..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jcgray-avx2.asm
+++ /dev/null
@@ -1,113 +0,0 @@
-;
-; jcgray.asm - grayscale colorspace conversion (AVX2)
-;
-; Copyright (C) 2011, 2016, D. R. Commander.
-; Copyright (C) 2015, Intel Corporation.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jsimdext.inc"
-
-; --------------------------------------------------------------------------
-
-%define SCALEBITS 16
-
-F_0_114 equ 7471 ; FIX(0.11400)
-F_0_250 equ 16384 ; FIX(0.25000)
-F_0_299 equ 19595 ; FIX(0.29900)
-F_0_587 equ 38470 ; FIX(0.58700)
-F_0_337 equ (F_0_587 - F_0_250) ; FIX(0.58700) - FIX(0.25000)
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_rgb_gray_convert_avx2)
-
-EXTN(jconst_rgb_gray_convert_avx2):
-
-PW_F0299_F0337 times 8 dw F_0_299, F_0_337
-PW_F0114_F0250 times 8 dw F_0_114, F_0_250
-PD_ONEHALF times 8 dd (1 << (SCALEBITS - 1))
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-
-%include "jcgryext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_RGB_RED
-%define RGB_GREEN EXT_RGB_GREEN
-%define RGB_BLUE EXT_RGB_BLUE
-%define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
-%define jsimd_rgb_gray_convert_avx2 jsimd_extrgb_gray_convert_avx2
-%include "jcgryext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_RGBX_RED
-%define RGB_GREEN EXT_RGBX_GREEN
-%define RGB_BLUE EXT_RGBX_BLUE
-%define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
-%define jsimd_rgb_gray_convert_avx2 jsimd_extrgbx_gray_convert_avx2
-%include "jcgryext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_BGR_RED
-%define RGB_GREEN EXT_BGR_GREEN
-%define RGB_BLUE EXT_BGR_BLUE
-%define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
-%define jsimd_rgb_gray_convert_avx2 jsimd_extbgr_gray_convert_avx2
-%include "jcgryext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_BGRX_RED
-%define RGB_GREEN EXT_BGRX_GREEN
-%define RGB_BLUE EXT_BGRX_BLUE
-%define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
-%define jsimd_rgb_gray_convert_avx2 jsimd_extbgrx_gray_convert_avx2
-%include "jcgryext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_XBGR_RED
-%define RGB_GREEN EXT_XBGR_GREEN
-%define RGB_BLUE EXT_XBGR_BLUE
-%define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
-%define jsimd_rgb_gray_convert_avx2 jsimd_extxbgr_gray_convert_avx2
-%include "jcgryext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_XRGB_RED
-%define RGB_GREEN EXT_XRGB_GREEN
-%define RGB_BLUE EXT_XRGB_BLUE
-%define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
-%define jsimd_rgb_gray_convert_avx2 jsimd_extxrgb_gray_convert_avx2
-%include "jcgryext-avx2.asm"
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jcgray-mmx.asm b/contrib/libs/libjpeg-turbo/simd/i386/jcgray-mmx.asm
deleted file mode 100644
index 79fdf082a8..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jcgray-mmx.asm
+++ /dev/null
@@ -1,113 +0,0 @@
-;
-; jcgray.asm - grayscale colorspace conversion (MMX)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2011, 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jsimdext.inc"
-
-; --------------------------------------------------------------------------
-
-%define SCALEBITS 16
-
-F_0_114 equ 7471 ; FIX(0.11400)
-F_0_250 equ 16384 ; FIX(0.25000)
-F_0_299 equ 19595 ; FIX(0.29900)
-F_0_587 equ 38470 ; FIX(0.58700)
-F_0_337 equ (F_0_587 - F_0_250) ; FIX(0.58700) - FIX(0.25000)
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_rgb_gray_convert_mmx)
-
-EXTN(jconst_rgb_gray_convert_mmx):
-
-PW_F0299_F0337 times 2 dw F_0_299, F_0_337
-PW_F0114_F0250 times 2 dw F_0_114, F_0_250
-PD_ONEHALF times 2 dd (1 << (SCALEBITS - 1))
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-
-%include "jcgryext-mmx.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_RGB_RED
-%define RGB_GREEN EXT_RGB_GREEN
-%define RGB_BLUE EXT_RGB_BLUE
-%define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
-%define jsimd_rgb_gray_convert_mmx jsimd_extrgb_gray_convert_mmx
-%include "jcgryext-mmx.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_RGBX_RED
-%define RGB_GREEN EXT_RGBX_GREEN
-%define RGB_BLUE EXT_RGBX_BLUE
-%define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
-%define jsimd_rgb_gray_convert_mmx jsimd_extrgbx_gray_convert_mmx
-%include "jcgryext-mmx.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_BGR_RED
-%define RGB_GREEN EXT_BGR_GREEN
-%define RGB_BLUE EXT_BGR_BLUE
-%define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
-%define jsimd_rgb_gray_convert_mmx jsimd_extbgr_gray_convert_mmx
-%include "jcgryext-mmx.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_BGRX_RED
-%define RGB_GREEN EXT_BGRX_GREEN
-%define RGB_BLUE EXT_BGRX_BLUE
-%define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
-%define jsimd_rgb_gray_convert_mmx jsimd_extbgrx_gray_convert_mmx
-%include "jcgryext-mmx.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_XBGR_RED
-%define RGB_GREEN EXT_XBGR_GREEN
-%define RGB_BLUE EXT_XBGR_BLUE
-%define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
-%define jsimd_rgb_gray_convert_mmx jsimd_extxbgr_gray_convert_mmx
-%include "jcgryext-mmx.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_XRGB_RED
-%define RGB_GREEN EXT_XRGB_GREEN
-%define RGB_BLUE EXT_XRGB_BLUE
-%define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
-%define jsimd_rgb_gray_convert_mmx jsimd_extxrgb_gray_convert_mmx
-%include "jcgryext-mmx.asm"
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jcgray-sse2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jcgray-sse2.asm
deleted file mode 100644
index cb4b28e8f4..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jcgray-sse2.asm
+++ /dev/null
@@ -1,112 +0,0 @@
-;
-; jcgray.asm - grayscale colorspace conversion (SSE2)
-;
-; Copyright (C) 2011, 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jsimdext.inc"
-
-; --------------------------------------------------------------------------
-
-%define SCALEBITS 16
-
-F_0_114 equ 7471 ; FIX(0.11400)
-F_0_250 equ 16384 ; FIX(0.25000)
-F_0_299 equ 19595 ; FIX(0.29900)
-F_0_587 equ 38470 ; FIX(0.58700)
-F_0_337 equ (F_0_587 - F_0_250) ; FIX(0.58700) - FIX(0.25000)
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_rgb_gray_convert_sse2)
-
-EXTN(jconst_rgb_gray_convert_sse2):
-
-PW_F0299_F0337 times 4 dw F_0_299, F_0_337
-PW_F0114_F0250 times 4 dw F_0_114, F_0_250
-PD_ONEHALF times 4 dd (1 << (SCALEBITS - 1))
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-
-%include "jcgryext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_RGB_RED
-%define RGB_GREEN EXT_RGB_GREEN
-%define RGB_BLUE EXT_RGB_BLUE
-%define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
-%define jsimd_rgb_gray_convert_sse2 jsimd_extrgb_gray_convert_sse2
-%include "jcgryext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_RGBX_RED
-%define RGB_GREEN EXT_RGBX_GREEN
-%define RGB_BLUE EXT_RGBX_BLUE
-%define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
-%define jsimd_rgb_gray_convert_sse2 jsimd_extrgbx_gray_convert_sse2
-%include "jcgryext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_BGR_RED
-%define RGB_GREEN EXT_BGR_GREEN
-%define RGB_BLUE EXT_BGR_BLUE
-%define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
-%define jsimd_rgb_gray_convert_sse2 jsimd_extbgr_gray_convert_sse2
-%include "jcgryext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_BGRX_RED
-%define RGB_GREEN EXT_BGRX_GREEN
-%define RGB_BLUE EXT_BGRX_BLUE
-%define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
-%define jsimd_rgb_gray_convert_sse2 jsimd_extbgrx_gray_convert_sse2
-%include "jcgryext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_XBGR_RED
-%define RGB_GREEN EXT_XBGR_GREEN
-%define RGB_BLUE EXT_XBGR_BLUE
-%define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
-%define jsimd_rgb_gray_convert_sse2 jsimd_extxbgr_gray_convert_sse2
-%include "jcgryext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_XRGB_RED
-%define RGB_GREEN EXT_XRGB_GREEN
-%define RGB_BLUE EXT_XRGB_BLUE
-%define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
-%define jsimd_rgb_gray_convert_sse2 jsimd_extxrgb_gray_convert_sse2
-%include "jcgryext-sse2.asm"
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jcgryext-avx2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jcgryext-avx2.asm
deleted file mode 100644
index 3fa7973d72..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jcgryext-avx2.asm
+++ /dev/null
@@ -1,457 +0,0 @@
-;
-; jcgryext.asm - grayscale colorspace conversion (AVX2)
-;
-; Copyright (C) 2011, 2016, D. R. Commander.
-; Copyright (C) 2015, Intel Corporation.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jcolsamp.inc"
-
-; --------------------------------------------------------------------------
-;
-; Convert some rows of samples to the output colorspace.
-;
-; GLOBAL(void)
-; jsimd_rgb_gray_convert_avx2(JDIMENSION img_width, JSAMPARRAY input_buf,
-; JSAMPIMAGE output_buf, JDIMENSION output_row,
-; int num_rows);
-;
-
-%define img_width(b) (b) + 8 ; JDIMENSION img_width
-%define input_buf(b) (b) + 12 ; JSAMPARRAY input_buf
-%define output_buf(b) (b) + 16 ; JSAMPIMAGE output_buf
-%define output_row(b) (b) + 20 ; JDIMENSION output_row
-%define num_rows(b) (b) + 24 ; int num_rows
-
-%define original_ebp ebp + 0
-%define wk(i) ebp - (WK_NUM - (i)) * SIZEOF_YMMWORD
- ; ymmword wk[WK_NUM]
-%define WK_NUM 2
-%define gotptr wk(0) - SIZEOF_POINTER ; void * gotptr
-
- align 32
- GLOBAL_FUNCTION(jsimd_rgb_gray_convert_avx2)
-
-EXTN(jsimd_rgb_gray_convert_avx2):
- push ebp
- mov eax, esp ; eax = original ebp
- sub esp, byte 4
- and esp, byte (-SIZEOF_YMMWORD) ; align to 256 bits
- mov [esp], eax
- mov ebp, esp ; ebp = aligned ebp
- lea esp, [wk(0)]
- pushpic eax ; make a room for GOT address
- push ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- get_GOT ebx ; get GOT address
- movpic POINTER [gotptr], ebx ; save GOT address
-
- mov ecx, JDIMENSION [img_width(eax)]
- test ecx, ecx
- jz near .return
-
- push ecx
-
- mov esi, JSAMPIMAGE [output_buf(eax)]
- mov ecx, JDIMENSION [output_row(eax)]
- mov edi, JSAMPARRAY [esi+0*SIZEOF_JSAMPARRAY]
- lea edi, [edi+ecx*SIZEOF_JSAMPROW]
-
- pop ecx
-
- mov esi, JSAMPARRAY [input_buf(eax)]
- mov eax, INT [num_rows(eax)]
- test eax, eax
- jle near .return
- alignx 16, 7
-.rowloop:
- pushpic eax
- push edi
- push esi
- push ecx ; col
-
- mov esi, JSAMPROW [esi] ; inptr
- mov edi, JSAMPROW [edi] ; outptr0
- movpic eax, POINTER [gotptr] ; load GOT address (eax)
-
- cmp ecx, byte SIZEOF_YMMWORD
- jae near .columnloop
- alignx 16, 7
-
-%if RGB_PIXELSIZE == 3 ; ---------------
-
-.column_ld1:
- push eax
- push edx
- lea ecx, [ecx+ecx*2] ; imul ecx,RGB_PIXELSIZE
- test cl, SIZEOF_BYTE
- jz short .column_ld2
- sub ecx, byte SIZEOF_BYTE
- movzx eax, byte [esi+ecx]
-.column_ld2:
- test cl, SIZEOF_WORD
- jz short .column_ld4
- sub ecx, byte SIZEOF_WORD
- movzx edx, word [esi+ecx]
- shl eax, WORD_BIT
- or eax, edx
-.column_ld4:
- vmovd xmmA, eax
- pop edx
- pop eax
- test cl, SIZEOF_DWORD
- jz short .column_ld8
- sub ecx, byte SIZEOF_DWORD
- vmovd xmmF, XMM_DWORD [esi+ecx]
- vpslldq xmmA, xmmA, SIZEOF_DWORD
- vpor xmmA, xmmA, xmmF
-.column_ld8:
- test cl, SIZEOF_MMWORD
- jz short .column_ld16
- sub ecx, byte SIZEOF_MMWORD
- vmovq xmmB, XMM_MMWORD [esi+ecx]
- vpslldq xmmA, xmmA, SIZEOF_MMWORD
- vpor xmmA, xmmA, xmmB
-.column_ld16:
- test cl, SIZEOF_XMMWORD
- jz short .column_ld32
- sub ecx, byte SIZEOF_XMMWORD
- vmovdqu xmmB, XMM_MMWORD [esi+ecx]
- vperm2i128 ymmA, ymmA, ymmA, 1
- vpor ymmA, ymmB
-.column_ld32:
- test cl, SIZEOF_YMMWORD
- jz short .column_ld64
- sub ecx, byte SIZEOF_YMMWORD
- vmovdqa ymmF, ymmA
- vmovdqu ymmA, YMMWORD [esi+0*SIZEOF_YMMWORD]
-.column_ld64:
- test cl, 2*SIZEOF_YMMWORD
- mov ecx, SIZEOF_YMMWORD
- jz short .rgb_gray_cnv
- vmovdqa ymmB, ymmA
- vmovdqu ymmA, YMMWORD [esi+0*SIZEOF_YMMWORD]
- vmovdqu ymmF, YMMWORD [esi+1*SIZEOF_YMMWORD]
- jmp short .rgb_gray_cnv
- alignx 16, 7
-
-.columnloop:
- vmovdqu ymmA, YMMWORD [esi+0*SIZEOF_YMMWORD]
- vmovdqu ymmF, YMMWORD [esi+1*SIZEOF_YMMWORD]
- vmovdqu ymmB, YMMWORD [esi+2*SIZEOF_YMMWORD]
-
-.rgb_gray_cnv:
- ; ymmA=(00 10 20 01 11 21 02 12 22 03 13 23 04 14 24 05
- ; 15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A)
- ; ymmF=(2A 0B 1B 2B 0C 1C 2C 0D 1D 2D 0E 1E 2E 0F 1F 2F
- ; 0G 1G 2G 0H 1H 2H 0I 1I 2I 0J 1J 2J 0K 1K 2K 0L)
- ; ymmB=(1L 2L 0M 1M 2M 0N 1N 2N 0O 1O 2O 0P 1P 2P 0Q 1Q
- ; 2Q 0R 1R 2R 0S 1S 2S 0T 1T 2T 0U 1U 2U 0V 1V 2V)
-
- vmovdqu ymmC, ymmA
- vinserti128 ymmA, ymmF, xmmA, 0 ; ymmA=(00 10 20 01 11 21 02 12 22 03 13 23 04 14 24 05
- ; 0G 1G 2G 0H 1H 2H 0I 1I 2I 0J 1J 2J 0K 1K 2K 0L)
- vinserti128 ymmC, ymmC, xmmB, 0 ; ymmC=(1L 2L 0M 1M 2M 0N 1N 2N 0O 1O 2O 0P 1P 2P 0Q 1Q
- ; 15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A)
- vinserti128 ymmB, ymmB, xmmF, 0 ; ymmB=(2A 0B 1B 2B 0C 1C 2C 0D 1D 2D 0E 1E 2E 0F 1F 2F
- ; 2Q 0R 1R 2R 0S 1S 2S 0T 1T 2T 0U 1U 2U 0V 1V 2V)
- vperm2i128 ymmF, ymmC, ymmC, 1 ; ymmF=(15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A
- ; 1L 2L 0M 1M 2M 0N 1N 2N 0O 1O 2O 0P 1P 2P 0Q 1Q)
-
- vmovdqa ymmG, ymmA
- vpslldq ymmA, ymmA, 8 ; ymmA=(-- -- -- -- -- -- -- -- 00 10 20 01 11 21 02 12
- ; 22 03 13 23 04 14 24 05 0G 1G 2G 0H 1H 2H 0I 1I)
- vpsrldq ymmG, ymmG, 8 ; ymmG=(22 03 13 23 04 14 24 05 0G 1G 2G 0H 1H 2H 0I 1I
- ; 2I 0J 1J 2J 0K 1K 2K 0L -- -- -- -- -- -- -- --)
-
- vpunpckhbw ymmA, ymmA, ymmF ; ymmA=(00 08 10 18 20 28 01 09 11 19 21 29 02 0A 12 1A
- ; 0G 0O 1G 1O 2G 2O 0H 0P 1H 1P 2H 2P 0I 0Q 1I 1Q)
- vpslldq ymmF, ymmF, 8 ; ymmF=(-- -- -- -- -- -- -- -- 15 25 06 16 26 07 17 27
- ; 08 18 28 09 19 29 0A 1A 1L 2L 0M 1M 2M 0N 1N 2N)
-
- vpunpcklbw ymmG, ymmG, ymmB ; ymmG=(22 2A 03 0B 13 1B 23 2B 04 0C 14 1C 24 2C 05 0D
- ; 2I 2Q 0J 0R 1J 1R 2J 2R 0K 0S 1K 1S 2K 2S 0L 0T)
- vpunpckhbw ymmF, ymmF, ymmB ; ymmF=(15 1D 25 2D 06 0E 16 1E 26 2E 07 0F 17 1F 27 2F
- ; 1L 1T 2L 2T 0M 0U 1M 1U 2M 2U 0N 0V 1N 1V 2N 2V)
-
- vmovdqa ymmD, ymmA
- vpslldq ymmA, ymmA, 8 ; ymmA=(-- -- -- -- -- -- -- -- 00 08 10 18 20 28 01 09
- ; 11 19 21 29 02 0A 12 1A 0G 0O 1G 1O 2G 2O 0H 0P)
- vpsrldq ymmD, ymmD, 8 ; ymmD=(11 19 21 29 02 0A 12 1A 0G 0O 1G 1O 2G 2O 0H 0P
- ; 1H 1P 2H 2P 0I 0Q 1I 1Q -- -- -- -- -- -- -- --)
-
- vpunpckhbw ymmA, ymmA, ymmG ; ymmA=(00 04 08 0C 10 14 18 1C 20 24 28 2C 01 05 09 0D
- ; 0G 0K 0O 0S 1G 1K 1O 1S 2G 2K 2O 2S 0H 0L 0P 0T)
- vpslldq ymmG, ymmG, 8 ; ymmG=(-- -- -- -- -- -- -- -- 22 2A 03 0B 13 1B 23 2B
- ; 04 0C 14 1C 24 2C 05 0D 2I 2Q 0J 0R 1J 1R 2J 2R)
-
- vpunpcklbw ymmD, ymmD, ymmF ; ymmD=(11 15 19 1D 21 25 29 2D 02 06 0A 0E 12 16 1A 1E
- ; 1H 1L 1P 1T 2H 2L 2P 2T 0I 0M 0Q 0U 1I 1M 1Q 1U)
- vpunpckhbw ymmG, ymmG, ymmF ; ymmG=(22 26 2A 2E 03 07 0B 0F 13 17 1B 1F 23 27 2B 2F
- ; 2I 2M 2Q 2U 0J 0N 0R 0V 1J 1N 1R 1V 2J 2N 2R 2V)
-
- vmovdqa ymmE, ymmA
- vpslldq ymmA, ymmA, 8 ; ymmA=(-- -- -- -- -- -- -- -- 00 04 08 0C 10 14 18 1C
- ; 20 24 28 2C 01 05 09 0D 0G 0K 0O 0S 1G 1K 1O 1S)
- vpsrldq ymmE, ymmE, 8 ; ymmE=(20 24 28 2C 01 05 09 0D 0G 0K 0O 0S 1G 1K 1O 1S
- ; 2G 2K 2O 2S 0H 0L 0P 0T -- -- -- -- -- -- -- --)
-
- vpunpckhbw ymmA, ymmA, ymmD ; ymmA=(00 02 04 06 08 0A 0C 0E 10 12 14 16 18 1A 1C 1E
- ; 0G 0I 0K 0M 0O 0Q 0S 0U 1G 1I 1K 1M 1O 1Q 1S 1U)
- vpslldq ymmD, ymmD, 8 ; ymmD=(-- -- -- -- -- -- -- -- 11 15 19 1D 21 25 29 2D
- ; 02 06 0A 0E 12 16 1A 1E 1H 1L 1P 1T 2H 2L 2P 2T)
-
- vpunpcklbw ymmE, ymmE, ymmG ; ymmE=(20 22 24 26 28 2A 2C 2E 01 03 05 07 09 0B 0D 0F
- ; 2G 2I 2K 2M 2O 2Q 2S 2U 0H 0J 0L 0N 0P 0R 0T 0V)
- vpunpckhbw ymmD, ymmD, ymmG ; ymmD=(11 13 15 17 19 1B 1D 1F 21 23 25 27 29 2B 2D 2F
- ; 1H 1J 1L 1N 1P 1R 1T 1V 2H 2J 2L 2N 2P 2R 2T 2V)
-
- vpxor ymmH, ymmH, ymmH
-
- vmovdqa ymmC, ymmA
- vpunpcklbw ymmA, ymmA, ymmH ; ymmA=(00 02 04 06 08 0A 0C 0E 0G 0I 0K 0M 0O 0Q 0S 0U)
- vpunpckhbw ymmC, ymmC, ymmH ; ymmC=(10 12 14 16 18 1A 1C 1E 1G 1I 1K 1M 1O 1Q 1S 1U)
-
- vmovdqa ymmB, ymmE
- vpunpcklbw ymmE, ymmE, ymmH ; ymmE=(20 22 24 26 28 2A 2C 2E 2G 2I 2K 2M 2O 2Q 2S 2U)
- vpunpckhbw ymmB, ymmB, ymmH ; ymmB=(01 03 05 07 09 0B 0D 0F 0H 0J 0L 0N 0P 0R 0T 0V)
-
- vmovdqa ymmF, ymmD
- vpunpcklbw ymmD, ymmD, ymmH ; ymmD=(11 13 15 17 19 1B 1D 1F 1H 1J 1L 1N 1P 1R 1T 1V)
- vpunpckhbw ymmF, ymmF, ymmH ; ymmF=(21 23 25 27 29 2B 2D 2F 2H 2J 2L 2N 2P 2R 2T 2V)
-
-%else ; RGB_PIXELSIZE == 4 ; -----------
-
-.column_ld1:
- test cl, SIZEOF_XMMWORD/16
- jz short .column_ld2
- sub ecx, byte SIZEOF_XMMWORD/16
- vmovd xmmA, XMM_DWORD [esi+ecx*RGB_PIXELSIZE]
-.column_ld2:
- test cl, SIZEOF_XMMWORD/8
- jz short .column_ld4
- sub ecx, byte SIZEOF_XMMWORD/8
- vmovq xmmF, XMM_MMWORD [esi+ecx*RGB_PIXELSIZE]
- vpslldq xmmA, xmmA, SIZEOF_MMWORD
- vpor xmmA, xmmA, xmmF
-.column_ld4:
- test cl, SIZEOF_XMMWORD/4
- jz short .column_ld8
- sub ecx, byte SIZEOF_XMMWORD/4
- vmovdqa xmmF, xmmA
- vperm2i128 ymmF, ymmF, ymmF, 1
- vmovdqu xmmA, XMMWORD [esi+ecx*RGB_PIXELSIZE]
- vpor ymmA, ymmA, ymmF
-.column_ld8:
- test cl, SIZEOF_XMMWORD/2
- jz short .column_ld16
- sub ecx, byte SIZEOF_XMMWORD/2
- vmovdqa ymmF, ymmA
- vmovdqu ymmA, YMMWORD [esi+ecx*RGB_PIXELSIZE]
-.column_ld16:
- test cl, SIZEOF_XMMWORD
- mov ecx, SIZEOF_YMMWORD
- jz short .rgb_gray_cnv
- vmovdqa ymmE, ymmA
- vmovdqa ymmH, ymmF
- vmovdqu ymmA, YMMWORD [esi+0*SIZEOF_YMMWORD]
- vmovdqu ymmF, YMMWORD [esi+1*SIZEOF_YMMWORD]
- jmp short .rgb_gray_cnv
- alignx 16, 7
-
-.columnloop:
- vmovdqu ymmA, YMMWORD [esi+0*SIZEOF_YMMWORD]
- vmovdqu ymmF, YMMWORD [esi+1*SIZEOF_YMMWORD]
- vmovdqu ymmE, YMMWORD [esi+2*SIZEOF_YMMWORD]
- vmovdqu ymmH, YMMWORD [esi+3*SIZEOF_YMMWORD]
-
-.rgb_gray_cnv:
- ; ymmA=(00 10 20 30 01 11 21 31 02 12 22 32 03 13 23 33
- ; 04 14 24 34 05 15 25 35 06 16 26 36 07 17 27 37)
- ; ymmF=(08 18 28 38 09 19 29 39 0A 1A 2A 3A 0B 1B 2B 3B
- ; 0C 1C 2C 3C 0D 1D 2D 3D 0E 1E 2E 3E 0F 1F 2F 3F)
- ; ymmE=(0G 1G 2G 3G 0H 1H 2H 3H 0I 1I 2I 3I 0J 1J 2J 3J
- ; 0K 1K 2K 3K 0L 1L 2L 3L 0M 1M 2M 3M 0N 1N 2N 3N)
- ; ymmH=(0O 1O 2O 3O 0P 1P 2P 3P 0Q 1Q 2Q 3Q 0R 1R 2R 3R
- ; 0S 1S 2S 3S 0T 1T 2T 3T 0U 1U 2U 3U 0V 1V 2V 3V)
-
- vmovdqa ymmB, ymmA
- vinserti128 ymmA, ymmA, xmmE, 1 ; ymmA=(00 10 20 30 01 11 21 31 02 12 22 32 03 13 23 33
- ; 0G 1G 2G 3G 0H 1H 2H 3H 0I 1I 2I 3I 0J 1J 2J 3J)
- vperm2i128 ymmE, ymmB, ymmE, 0x31 ; ymmE=(04 14 24 34 05 15 25 35 06 16 26 36 07 17 27 37
- ; 0K 1K 2K 3K 0L 1L 2L 3L 0M 1M 2M 3M 0N 1N 2N 3N)
-
- vmovdqa ymmB, ymmF
- vinserti128 ymmF, ymmF, xmmH, 1 ; ymmF=(08 18 28 38 09 19 29 39 0A 1A 2A 3A 0B 1B 2B 3B
- ; 0O 1O 2O 3O 0P 1P 2P 3P 0Q 1Q 2Q 3Q 0R 1R 2R 3R)
- vperm2i128 ymmH, ymmB, ymmH, 0x31 ; ymmH=(0C 1C 2C 3C 0D 1D 2D 3D 0E 1E 2E 3E 0F 1F 2F 3F
- ; 0S 1S 2S 3S 0T 1T 2T 3T 0U 1U 2U 3U 0V 1V 2V 3V)
-
- vmovdqa ymmD, ymmA
- vpunpcklbw ymmA, ymmA, ymmE ; ymmA=(00 04 10 14 20 24 30 34 01 05 11 15 21 25 31 35
- ; 0G 0K 1G 1K 2G 2K 3G 3K 0H 0L 1H 1L 2H 2L 3H 3L)
- vpunpckhbw ymmD, ymmD, ymmE ; ymmD=(02 06 12 16 22 26 32 36 03 07 13 17 23 27 33 37
- ; 0I 0M 1I 1M 2I 2M 3I 3M 0J 0N 1J 1N 2J 2N 3J 3N)
-
- vmovdqa ymmC, ymmF
- vpunpcklbw ymmF, ymmF, ymmH ; ymmF=(08 0C 18 1C 28 2C 38 3C 09 0D 19 1D 29 2D 39 3D
- ; 0O 0S 1O 1S 2O 2S 3O 3S 0P 0T 1P 1T 2P 2T 3P 3T)
- vpunpckhbw ymmC, ymmC, ymmH ; ymmC=(0A 0E 1A 1E 2A 2E 3A 3E 0B 0F 1B 1F 2B 2F 3B 3F
- ; 0Q 0U 1Q 1U 2Q 2U 3Q 3U 0R 0V 1R 1V 2R 2V 3R 3V)
-
- vmovdqa ymmB, ymmA
- vpunpcklwd ymmA, ymmA, ymmF ; ymmA=(00 04 08 0C 10 14 18 1C 20 24 28 2C 30 34 38 3C
- ; 0G 0K 0O 0S 1G 1K 1O 1S 2G 2K 2O 2S 3G 3K 3O 3S)
- vpunpckhwd ymmB, ymmB, ymmF ; ymmB=(01 05 09 0D 11 15 19 1D 21 25 29 2D 31 35 39 3D
- ; 0H 0L 0P 0T 1H 1L 1P 1T 2H 2L 2P 2T 3H 3L 3P 3T)
-
- vmovdqa ymmG, ymmD
- vpunpcklwd ymmD, ymmD, ymmC ; ymmD=(02 06 0A 0E 12 16 1A 1E 22 26 2A 2E 32 36 3A 3E
- ; 0I 0M 0Q 0U 1I 1M 1Q 1U 2I 2M 2Q 2U 3I 3M 3Q 3U)
- vpunpckhwd ymmG, ymmG, ymmC ; ymmG=(03 07 0B 0F 13 17 1B 1F 23 27 2B 2F 33 37 3B 3F
- ; 0J 0N 0R 0V 1J 1N 1R 1V 2J 2N 2R 2V 3J 3N 3R 3V)
-
- vmovdqa ymmE, ymmA
- vpunpcklbw ymmA, ymmA, ymmD ; ymmA=(00 02 04 06 08 0A 0C 0E 10 12 14 16 18 1A 1C 1E
- ; 0G 0I 0K 0M 0O 0Q 0S 0U 1G 1I 1K 1M 1O 1Q 1S 1U)
- vpunpckhbw ymmE, ymmE, ymmD ; ymmE=(20 22 24 26 28 2A 2C 2E 30 32 34 36 38 3A 3C 3E
- ; 2G 2I 2K 2M 2O 2Q 2S 2U 3G 3I 3K 3M 3O 3Q 3S 3U)
-
- vmovdqa ymmH, ymmB
- vpunpcklbw ymmB, ymmB, ymmG ; ymmB=(01 03 05 07 09 0B 0D 0F 11 13 15 17 19 1B 1D 1F
- ; 0H 0J 0L 0N 0P 0R 0T 0V 1H 1J 1L 1N 1P 1R 1T 1V)
- vpunpckhbw ymmH, ymmH, ymmG ; ymmH=(21 23 25 27 29 2B 2D 2F 31 33 35 37 39 3B 3D 3F
- ; 2H 2J 2L 2N 2P 2R 2T 2V 3H 3J 3L 3N 3P 3R 3T 3V)
-
- vpxor ymmF, ymmF, ymmF
-
- vmovdqa ymmC, ymmA
- vpunpcklbw ymmA, ymmA, ymmF ; ymmA=(00 02 04 06 08 0A 0C 0E 0G 0I 0K 0M 0O 0Q 0S 0U)
- vpunpckhbw ymmC, ymmC, ymmF ; ymmC=(10 12 14 16 18 1A 1C 1E 1G 1I 1K 1M 1O 1Q 1S 1U)
-
- vmovdqa ymmD, ymmB
- vpunpcklbw ymmB, ymmB, ymmF ; ymmB=(01 03 05 07 09 0B 0D 0F 0H 0J 0L 0N 0P 0R 0T 0V)
- vpunpckhbw ymmD, ymmD, ymmF ; ymmD=(11 13 15 17 19 1B 1D 1F 1H 1J 1L 1N 1P 1R 1T 1V)
-
- vmovdqa ymmG, ymmE
- vpunpcklbw ymmE, ymmE, ymmF ; ymmE=(20 22 24 26 28 2A 2C 2E 2G 2I 2K 2M 2O 2Q 2S 2U)
- vpunpckhbw ymmG, ymmG, ymmF ; ymmG=(30 32 34 36 38 3A 3C 3E 3G 3I 3K 3M 3O 3Q 3S 3U)
-
- vpunpcklbw ymmF, ymmF, ymmH
- vpunpckhbw ymmH, ymmH, ymmH
- vpsrlw ymmF, ymmF, BYTE_BIT ; ymmF=(21 23 25 27 29 2B 2D 2F 2H 2J 2L 2N 2P 2R 2T 2V)
- vpsrlw ymmH, ymmH, BYTE_BIT ; ymmH=(31 33 35 37 39 3B 3D 3F 3H 3J 3L 3N 3P 3R 3T 3V)
-
-%endif ; RGB_PIXELSIZE ; ---------------
-
- ; ymm0=R(02468ACEGIKMOQSU)=RE, ymm2=G(02468ACEGIKMOQSU)=GE, ymm4=B(02468ACEGIKMOQSU)=BE
- ; ymm1=R(13579BDFHJLNPRTV)=RO, ymm3=G(13579BDFHJLNPRTV)=GO, ymm5=B(13579BDFHJLNPRTV)=BO
-
- ; (Original)
- ; Y = 0.29900 * R + 0.58700 * G + 0.11400 * B
- ;
- ; (This implementation)
- ; Y = 0.29900 * R + 0.33700 * G + 0.11400 * B + 0.25000 * G
-
- vmovdqa ymm6, ymm1
- vpunpcklwd ymm1, ymm1, ymm3
- vpunpckhwd ymm6, ymm6, ymm3
- vpmaddwd ymm1, ymm1, [GOTOFF(eax,PW_F0299_F0337)] ; ymm1=ROL*FIX(0.299)+GOL*FIX(0.337)
- vpmaddwd ymm6, ymm6, [GOTOFF(eax,PW_F0299_F0337)] ; ymm6=ROH*FIX(0.299)+GOH*FIX(0.337)
-
- vmovdqa ymm7, ymm6 ; ymm7=ROH*FIX(0.299)+GOH*FIX(0.337)
-
- vmovdqa ymm6, ymm0
- vpunpcklwd ymm0, ymm0, ymm2
- vpunpckhwd ymm6, ymm6, ymm2
- vpmaddwd ymm0, ymm0, [GOTOFF(eax,PW_F0299_F0337)] ; ymm0=REL*FIX(0.299)+GEL*FIX(0.337)
- vpmaddwd ymm6, ymm6, [GOTOFF(eax,PW_F0299_F0337)] ; ymm6=REH*FIX(0.299)+GEH*FIX(0.337)
-
- vmovdqa YMMWORD [wk(0)], ymm0 ; wk(0)=REL*FIX(0.299)+GEL*FIX(0.337)
- vmovdqa YMMWORD [wk(1)], ymm6 ; wk(1)=REH*FIX(0.299)+GEH*FIX(0.337)
-
- vmovdqa ymm0, ymm5 ; ymm0=BO
- vmovdqa ymm6, ymm4 ; ymm6=BE
-
- vmovdqa ymm4, ymm0
- vpunpcklwd ymm0, ymm0, ymm3
- vpunpckhwd ymm4, ymm4, ymm3
- vpmaddwd ymm0, ymm0, [GOTOFF(eax,PW_F0114_F0250)] ; ymm0=BOL*FIX(0.114)+GOL*FIX(0.250)
- vpmaddwd ymm4, ymm4, [GOTOFF(eax,PW_F0114_F0250)] ; ymm4=BOH*FIX(0.114)+GOH*FIX(0.250)
-
- vmovdqa ymm3, [GOTOFF(eax,PD_ONEHALF)] ; ymm3=[PD_ONEHALF]
-
- vpaddd ymm0, ymm0, ymm1
- vpaddd ymm4, ymm4, ymm7
- vpaddd ymm0, ymm0, ymm3
- vpaddd ymm4, ymm4, ymm3
- vpsrld ymm0, ymm0, SCALEBITS ; ymm0=YOL
- vpsrld ymm4, ymm4, SCALEBITS ; ymm4=YOH
- vpackssdw ymm0, ymm0, ymm4 ; ymm0=YO
-
- vmovdqa ymm4, ymm6
- vpunpcklwd ymm6, ymm6, ymm2
- vpunpckhwd ymm4, ymm4, ymm2
- vpmaddwd ymm6, ymm6, [GOTOFF(eax,PW_F0114_F0250)] ; ymm6=BEL*FIX(0.114)+GEL*FIX(0.250)
- vpmaddwd ymm4, ymm4, [GOTOFF(eax,PW_F0114_F0250)] ; ymm4=BEH*FIX(0.114)+GEH*FIX(0.250)
-
- vmovdqa ymm2, [GOTOFF(eax,PD_ONEHALF)] ; ymm2=[PD_ONEHALF]
-
- vpaddd ymm6, ymm6, YMMWORD [wk(0)]
- vpaddd ymm4, ymm4, YMMWORD [wk(1)]
- vpaddd ymm6, ymm6, ymm2
- vpaddd ymm4, ymm4, ymm2
- vpsrld ymm6, ymm6, SCALEBITS ; ymm6=YEL
- vpsrld ymm4, ymm4, SCALEBITS ; ymm4=YEH
- vpackssdw ymm6, ymm6, ymm4 ; ymm6=YE
-
- vpsllw ymm0, ymm0, BYTE_BIT
- vpor ymm6, ymm6, ymm0 ; ymm6=Y
- vmovdqu YMMWORD [edi], ymm6 ; Save Y
-
- sub ecx, byte SIZEOF_YMMWORD
- add esi, RGB_PIXELSIZE*SIZEOF_YMMWORD ; inptr
- add edi, byte SIZEOF_YMMWORD ; outptr0
- cmp ecx, byte SIZEOF_YMMWORD
- jae near .columnloop
- test ecx, ecx
- jnz near .column_ld1
-
- pop ecx ; col
- pop esi
- pop edi
- poppic eax
-
- add esi, byte SIZEOF_JSAMPROW ; input_buf
- add edi, byte SIZEOF_JSAMPROW
- dec eax ; num_rows
- jg near .rowloop
-
-.return:
- vzeroupper
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- pop ebx
- mov esp, ebp ; esp <- aligned ebp
- pop esp ; esp <- original ebp
- pop ebp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jcgryext-mmx.asm b/contrib/libs/libjpeg-turbo/simd/i386/jcgryext-mmx.asm
deleted file mode 100644
index 8af42e5a33..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jcgryext-mmx.asm
+++ /dev/null
@@ -1,355 +0,0 @@
-;
-; jcgryext.asm - grayscale colorspace conversion (MMX)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2011, 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jcolsamp.inc"
-
-; --------------------------------------------------------------------------
-;
-; Convert some rows of samples to the output colorspace.
-;
-; GLOBAL(void)
-; jsimd_rgb_gray_convert_mmx(JDIMENSION img_width, JSAMPARRAY input_buf,
-; JSAMPIMAGE output_buf, JDIMENSION output_row,
-; int num_rows);
-;
-
-%define img_width(b) (b) + 8 ; JDIMENSION img_width
-%define input_buf(b) (b) + 12 ; JSAMPARRAY input_buf
-%define output_buf(b) (b) + 16 ; JSAMPIMAGE output_buf
-%define output_row(b) (b) + 20 ; JDIMENSION output_row
-%define num_rows(b) (b) + 24 ; int num_rows
-
-%define original_ebp ebp + 0
-%define wk(i) ebp - (WK_NUM - (i)) * SIZEOF_MMWORD
- ; mmword wk[WK_NUM]
-%define WK_NUM 2
-%define gotptr wk(0) - SIZEOF_POINTER ; void * gotptr
-
- align 32
- GLOBAL_FUNCTION(jsimd_rgb_gray_convert_mmx)
-
-EXTN(jsimd_rgb_gray_convert_mmx):
- push ebp
- mov eax, esp ; eax = original ebp
- sub esp, byte 4
- and esp, byte (-SIZEOF_MMWORD) ; align to 64 bits
- mov [esp], eax
- mov ebp, esp ; ebp = aligned ebp
- lea esp, [wk(0)]
- pushpic eax ; make a room for GOT address
- push ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- get_GOT ebx ; get GOT address
- movpic POINTER [gotptr], ebx ; save GOT address
-
- mov ecx, JDIMENSION [img_width(eax)] ; num_cols
- test ecx, ecx
- jz near .return
-
- push ecx
-
- mov esi, JSAMPIMAGE [output_buf(eax)]
- mov ecx, JDIMENSION [output_row(eax)]
- mov edi, JSAMPARRAY [esi+0*SIZEOF_JSAMPARRAY]
- lea edi, [edi+ecx*SIZEOF_JSAMPROW]
-
- pop ecx
-
- mov esi, JSAMPARRAY [input_buf(eax)]
- mov eax, INT [num_rows(eax)]
- test eax, eax
- jle near .return
- alignx 16, 7
-.rowloop:
- pushpic eax
- push edi
- push esi
- push ecx ; col
-
- mov esi, JSAMPROW [esi] ; inptr
- mov edi, JSAMPROW [edi] ; outptr0
- movpic eax, POINTER [gotptr] ; load GOT address (eax)
-
- cmp ecx, byte SIZEOF_MMWORD
- jae short .columnloop
- alignx 16, 7
-
-%if RGB_PIXELSIZE == 3 ; ---------------
-
-.column_ld1:
- push eax
- push edx
- lea ecx, [ecx+ecx*2] ; imul ecx,RGB_PIXELSIZE
- test cl, SIZEOF_BYTE
- jz short .column_ld2
- sub ecx, byte SIZEOF_BYTE
- xor eax, eax
- mov al, byte [esi+ecx]
-.column_ld2:
- test cl, SIZEOF_WORD
- jz short .column_ld4
- sub ecx, byte SIZEOF_WORD
- xor edx, edx
- mov dx, word [esi+ecx]
- shl eax, WORD_BIT
- or eax, edx
-.column_ld4:
- movd mmA, eax
- pop edx
- pop eax
- test cl, SIZEOF_DWORD
- jz short .column_ld8
- sub ecx, byte SIZEOF_DWORD
- movd mmG, dword [esi+ecx]
- psllq mmA, DWORD_BIT
- por mmA, mmG
-.column_ld8:
- test cl, SIZEOF_MMWORD
- jz short .column_ld16
- movq mmG, mmA
- movq mmA, MMWORD [esi+0*SIZEOF_MMWORD]
- mov ecx, SIZEOF_MMWORD
- jmp short .rgb_gray_cnv
-.column_ld16:
- test cl, 2*SIZEOF_MMWORD
- mov ecx, SIZEOF_MMWORD
- jz short .rgb_gray_cnv
- movq mmF, mmA
- movq mmA, MMWORD [esi+0*SIZEOF_MMWORD]
- movq mmG, MMWORD [esi+1*SIZEOF_MMWORD]
- jmp short .rgb_gray_cnv
- alignx 16, 7
-
-.columnloop:
- movq mmA, MMWORD [esi+0*SIZEOF_MMWORD]
- movq mmG, MMWORD [esi+1*SIZEOF_MMWORD]
- movq mmF, MMWORD [esi+2*SIZEOF_MMWORD]
-
-.rgb_gray_cnv:
- ; mmA=(00 10 20 01 11 21 02 12)
- ; mmG=(22 03 13 23 04 14 24 05)
- ; mmF=(15 25 06 16 26 07 17 27)
-
- movq mmD, mmA
- psllq mmA, 4*BYTE_BIT ; mmA=(-- -- -- -- 00 10 20 01)
- psrlq mmD, 4*BYTE_BIT ; mmD=(11 21 02 12 -- -- -- --)
-
- punpckhbw mmA, mmG ; mmA=(00 04 10 14 20 24 01 05)
- psllq mmG, 4*BYTE_BIT ; mmG=(-- -- -- -- 22 03 13 23)
-
- punpcklbw mmD, mmF ; mmD=(11 15 21 25 02 06 12 16)
- punpckhbw mmG, mmF ; mmG=(22 26 03 07 13 17 23 27)
-
- movq mmE, mmA
- psllq mmA, 4*BYTE_BIT ; mmA=(-- -- -- -- 00 04 10 14)
- psrlq mmE, 4*BYTE_BIT ; mmE=(20 24 01 05 -- -- -- --)
-
- punpckhbw mmA, mmD ; mmA=(00 02 04 06 10 12 14 16)
- psllq mmD, 4*BYTE_BIT ; mmD=(-- -- -- -- 11 15 21 25)
-
- punpcklbw mmE, mmG ; mmE=(20 22 24 26 01 03 05 07)
- punpckhbw mmD, mmG ; mmD=(11 13 15 17 21 23 25 27)
-
- pxor mmH, mmH
-
- movq mmC, mmA
- punpcklbw mmA, mmH ; mmA=(00 02 04 06)
- punpckhbw mmC, mmH ; mmC=(10 12 14 16)
-
- movq mmB, mmE
- punpcklbw mmE, mmH ; mmE=(20 22 24 26)
- punpckhbw mmB, mmH ; mmB=(01 03 05 07)
-
- movq mmF, mmD
- punpcklbw mmD, mmH ; mmD=(11 13 15 17)
- punpckhbw mmF, mmH ; mmF=(21 23 25 27)
-
-%else ; RGB_PIXELSIZE == 4 ; -----------
-
-.column_ld1:
- test cl, SIZEOF_MMWORD/8
- jz short .column_ld2
- sub ecx, byte SIZEOF_MMWORD/8
- movd mmA, dword [esi+ecx*RGB_PIXELSIZE]
-.column_ld2:
- test cl, SIZEOF_MMWORD/4
- jz short .column_ld4
- sub ecx, byte SIZEOF_MMWORD/4
- movq mmF, mmA
- movq mmA, MMWORD [esi+ecx*RGB_PIXELSIZE]
-.column_ld4:
- test cl, SIZEOF_MMWORD/2
- mov ecx, SIZEOF_MMWORD
- jz short .rgb_gray_cnv
- movq mmD, mmA
- movq mmC, mmF
- movq mmA, MMWORD [esi+0*SIZEOF_MMWORD]
- movq mmF, MMWORD [esi+1*SIZEOF_MMWORD]
- jmp short .rgb_gray_cnv
- alignx 16, 7
-
-.columnloop:
- movq mmA, MMWORD [esi+0*SIZEOF_MMWORD]
- movq mmF, MMWORD [esi+1*SIZEOF_MMWORD]
- movq mmD, MMWORD [esi+2*SIZEOF_MMWORD]
- movq mmC, MMWORD [esi+3*SIZEOF_MMWORD]
-
-.rgb_gray_cnv:
- ; mmA=(00 10 20 30 01 11 21 31)
- ; mmF=(02 12 22 32 03 13 23 33)
- ; mmD=(04 14 24 34 05 15 25 35)
- ; mmC=(06 16 26 36 07 17 27 37)
-
- movq mmB, mmA
- punpcklbw mmA, mmF ; mmA=(00 02 10 12 20 22 30 32)
- punpckhbw mmB, mmF ; mmB=(01 03 11 13 21 23 31 33)
-
- movq mmG, mmD
- punpcklbw mmD, mmC ; mmD=(04 06 14 16 24 26 34 36)
- punpckhbw mmG, mmC ; mmG=(05 07 15 17 25 27 35 37)
-
- movq mmE, mmA
- punpcklwd mmA, mmD ; mmA=(00 02 04 06 10 12 14 16)
- punpckhwd mmE, mmD ; mmE=(20 22 24 26 30 32 34 36)
-
- movq mmH, mmB
- punpcklwd mmB, mmG ; mmB=(01 03 05 07 11 13 15 17)
- punpckhwd mmH, mmG ; mmH=(21 23 25 27 31 33 35 37)
-
- pxor mmF, mmF
-
- movq mmC, mmA
- punpcklbw mmA, mmF ; mmA=(00 02 04 06)
- punpckhbw mmC, mmF ; mmC=(10 12 14 16)
-
- movq mmD, mmB
- punpcklbw mmB, mmF ; mmB=(01 03 05 07)
- punpckhbw mmD, mmF ; mmD=(11 13 15 17)
-
- movq mmG, mmE
- punpcklbw mmE, mmF ; mmE=(20 22 24 26)
- punpckhbw mmG, mmF ; mmG=(30 32 34 36)
-
- punpcklbw mmF, mmH
- punpckhbw mmH, mmH
- psrlw mmF, BYTE_BIT ; mmF=(21 23 25 27)
- psrlw mmH, BYTE_BIT ; mmH=(31 33 35 37)
-
-%endif ; RGB_PIXELSIZE ; ---------------
-
- ; mm0=(R0 R2 R4 R6)=RE, mm2=(G0 G2 G4 G6)=GE, mm4=(B0 B2 B4 B6)=BE
- ; mm1=(R1 R3 R5 R7)=RO, mm3=(G1 G3 G5 G7)=GO, mm5=(B1 B3 B5 B7)=BO
-
- ; (Original)
- ; Y = 0.29900 * R + 0.58700 * G + 0.11400 * B
- ;
- ; (This implementation)
- ; Y = 0.29900 * R + 0.33700 * G + 0.11400 * B + 0.25000 * G
-
- movq mm6, mm1
- punpcklwd mm1, mm3
- punpckhwd mm6, mm3
- pmaddwd mm1, [GOTOFF(eax,PW_F0299_F0337)] ; mm1=ROL*FIX(0.299)+GOL*FIX(0.337)
- pmaddwd mm6, [GOTOFF(eax,PW_F0299_F0337)] ; mm6=ROH*FIX(0.299)+GOH*FIX(0.337)
-
- movq mm7, mm6 ; mm7=ROH*FIX(0.299)+GOH*FIX(0.337)
-
- movq mm6, mm0
- punpcklwd mm0, mm2
- punpckhwd mm6, mm2
- pmaddwd mm0, [GOTOFF(eax,PW_F0299_F0337)] ; mm0=REL*FIX(0.299)+GEL*FIX(0.337)
- pmaddwd mm6, [GOTOFF(eax,PW_F0299_F0337)] ; mm6=REH*FIX(0.299)+GEH*FIX(0.337)
-
- movq MMWORD [wk(0)], mm0 ; wk(0)=REL*FIX(0.299)+GEL*FIX(0.337)
- movq MMWORD [wk(1)], mm6 ; wk(1)=REH*FIX(0.299)+GEH*FIX(0.337)
-
- movq mm0, mm5 ; mm0=BO
- movq mm6, mm4 ; mm6=BE
-
- movq mm4, mm0
- punpcklwd mm0, mm3
- punpckhwd mm4, mm3
- pmaddwd mm0, [GOTOFF(eax,PW_F0114_F0250)] ; mm0=BOL*FIX(0.114)+GOL*FIX(0.250)
- pmaddwd mm4, [GOTOFF(eax,PW_F0114_F0250)] ; mm4=BOH*FIX(0.114)+GOH*FIX(0.250)
-
- movq mm3, [GOTOFF(eax,PD_ONEHALF)] ; mm3=[PD_ONEHALF]
-
- paddd mm0, mm1
- paddd mm4, mm7
- paddd mm0, mm3
- paddd mm4, mm3
- psrld mm0, SCALEBITS ; mm0=YOL
- psrld mm4, SCALEBITS ; mm4=YOH
- packssdw mm0, mm4 ; mm0=YO
-
- movq mm4, mm6
- punpcklwd mm6, mm2
- punpckhwd mm4, mm2
- pmaddwd mm6, [GOTOFF(eax,PW_F0114_F0250)] ; mm6=BEL*FIX(0.114)+GEL*FIX(0.250)
- pmaddwd mm4, [GOTOFF(eax,PW_F0114_F0250)] ; mm4=BEH*FIX(0.114)+GEH*FIX(0.250)
-
- movq mm2, [GOTOFF(eax,PD_ONEHALF)] ; mm2=[PD_ONEHALF]
-
- paddd mm6, MMWORD [wk(0)]
- paddd mm4, MMWORD [wk(1)]
- paddd mm6, mm2
- paddd mm4, mm2
- psrld mm6, SCALEBITS ; mm6=YEL
- psrld mm4, SCALEBITS ; mm4=YEH
- packssdw mm6, mm4 ; mm6=YE
-
- psllw mm0, BYTE_BIT
- por mm6, mm0 ; mm6=Y
- movq MMWORD [edi], mm6 ; Save Y
-
- sub ecx, byte SIZEOF_MMWORD
- add esi, byte RGB_PIXELSIZE*SIZEOF_MMWORD ; inptr
- add edi, byte SIZEOF_MMWORD ; outptr0
- cmp ecx, byte SIZEOF_MMWORD
- jae near .columnloop
- test ecx, ecx
- jnz near .column_ld1
-
- pop ecx ; col
- pop esi
- pop edi
- poppic eax
-
- add esi, byte SIZEOF_JSAMPROW ; input_buf
- add edi, byte SIZEOF_JSAMPROW
- dec eax ; num_rows
- jg near .rowloop
-
- emms ; empty MMX state
-
-.return:
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- pop ebx
- mov esp, ebp ; esp <- aligned ebp
- pop esp ; esp <- original ebp
- pop ebp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jcgryext-sse2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jcgryext-sse2.asm
deleted file mode 100644
index c9d6ff1e35..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jcgryext-sse2.asm
+++ /dev/null
@@ -1,382 +0,0 @@
-;
-; jcgryext.asm - grayscale colorspace conversion (SSE2)
-;
-; Copyright (C) 2011, 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jcolsamp.inc"
-
-; --------------------------------------------------------------------------
-;
-; Convert some rows of samples to the output colorspace.
-;
-; GLOBAL(void)
-; jsimd_rgb_gray_convert_sse2(JDIMENSION img_width, JSAMPARRAY input_buf,
-; JSAMPIMAGE output_buf, JDIMENSION output_row,
-; int num_rows);
-;
-
-%define img_width(b) (b) + 8 ; JDIMENSION img_width
-%define input_buf(b) (b) + 12 ; JSAMPARRAY input_buf
-%define output_buf(b) (b) + 16 ; JSAMPIMAGE output_buf
-%define output_row(b) (b) + 20 ; JDIMENSION output_row
-%define num_rows(b) (b) + 24 ; int num_rows
-
-%define original_ebp ebp + 0
-%define wk(i) ebp - (WK_NUM - (i)) * SIZEOF_XMMWORD
- ; xmmword wk[WK_NUM]
-%define WK_NUM 2
-%define gotptr wk(0) - SIZEOF_POINTER ; void * gotptr
-
- align 32
- GLOBAL_FUNCTION(jsimd_rgb_gray_convert_sse2)
-
-EXTN(jsimd_rgb_gray_convert_sse2):
- push ebp
- mov eax, esp ; eax = original ebp
- sub esp, byte 4
- and esp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [esp], eax
- mov ebp, esp ; ebp = aligned ebp
- lea esp, [wk(0)]
- pushpic eax ; make a room for GOT address
- push ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- get_GOT ebx ; get GOT address
- movpic POINTER [gotptr], ebx ; save GOT address
-
- mov ecx, JDIMENSION [img_width(eax)]
- test ecx, ecx
- jz near .return
-
- push ecx
-
- mov esi, JSAMPIMAGE [output_buf(eax)]
- mov ecx, JDIMENSION [output_row(eax)]
- mov edi, JSAMPARRAY [esi+0*SIZEOF_JSAMPARRAY]
- lea edi, [edi+ecx*SIZEOF_JSAMPROW]
-
- pop ecx
-
- mov esi, JSAMPARRAY [input_buf(eax)]
- mov eax, INT [num_rows(eax)]
- test eax, eax
- jle near .return
- alignx 16, 7
-.rowloop:
- pushpic eax
- push edi
- push esi
- push ecx ; col
-
- mov esi, JSAMPROW [esi] ; inptr
- mov edi, JSAMPROW [edi] ; outptr0
- movpic eax, POINTER [gotptr] ; load GOT address (eax)
-
- cmp ecx, byte SIZEOF_XMMWORD
- jae near .columnloop
- alignx 16, 7
-
-%if RGB_PIXELSIZE == 3 ; ---------------
-
-.column_ld1:
- push eax
- push edx
- lea ecx, [ecx+ecx*2] ; imul ecx,RGB_PIXELSIZE
- test cl, SIZEOF_BYTE
- jz short .column_ld2
- sub ecx, byte SIZEOF_BYTE
- movzx eax, byte [esi+ecx]
-.column_ld2:
- test cl, SIZEOF_WORD
- jz short .column_ld4
- sub ecx, byte SIZEOF_WORD
- movzx edx, word [esi+ecx]
- shl eax, WORD_BIT
- or eax, edx
-.column_ld4:
- movd xmmA, eax
- pop edx
- pop eax
- test cl, SIZEOF_DWORD
- jz short .column_ld8
- sub ecx, byte SIZEOF_DWORD
- movd xmmF, XMM_DWORD [esi+ecx]
- pslldq xmmA, SIZEOF_DWORD
- por xmmA, xmmF
-.column_ld8:
- test cl, SIZEOF_MMWORD
- jz short .column_ld16
- sub ecx, byte SIZEOF_MMWORD
- movq xmmB, XMM_MMWORD [esi+ecx]
- pslldq xmmA, SIZEOF_MMWORD
- por xmmA, xmmB
-.column_ld16:
- test cl, SIZEOF_XMMWORD
- jz short .column_ld32
- movdqa xmmF, xmmA
- movdqu xmmA, XMMWORD [esi+0*SIZEOF_XMMWORD]
- mov ecx, SIZEOF_XMMWORD
- jmp short .rgb_gray_cnv
-.column_ld32:
- test cl, 2*SIZEOF_XMMWORD
- mov ecx, SIZEOF_XMMWORD
- jz short .rgb_gray_cnv
- movdqa xmmB, xmmA
- movdqu xmmA, XMMWORD [esi+0*SIZEOF_XMMWORD]
- movdqu xmmF, XMMWORD [esi+1*SIZEOF_XMMWORD]
- jmp short .rgb_gray_cnv
- alignx 16, 7
-
-.columnloop:
- movdqu xmmA, XMMWORD [esi+0*SIZEOF_XMMWORD]
- movdqu xmmF, XMMWORD [esi+1*SIZEOF_XMMWORD]
- movdqu xmmB, XMMWORD [esi+2*SIZEOF_XMMWORD]
-
-.rgb_gray_cnv:
- ; xmmA=(00 10 20 01 11 21 02 12 22 03 13 23 04 14 24 05)
- ; xmmF=(15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A)
- ; xmmB=(2A 0B 1B 2B 0C 1C 2C 0D 1D 2D 0E 1E 2E 0F 1F 2F)
-
- movdqa xmmG, xmmA
- pslldq xmmA, 8 ; xmmA=(-- -- -- -- -- -- -- -- 00 10 20 01 11 21 02 12)
- psrldq xmmG, 8 ; xmmG=(22 03 13 23 04 14 24 05 -- -- -- -- -- -- -- --)
-
- punpckhbw xmmA, xmmF ; xmmA=(00 08 10 18 20 28 01 09 11 19 21 29 02 0A 12 1A)
- pslldq xmmF, 8 ; xmmF=(-- -- -- -- -- -- -- -- 15 25 06 16 26 07 17 27)
-
- punpcklbw xmmG, xmmB ; xmmG=(22 2A 03 0B 13 1B 23 2B 04 0C 14 1C 24 2C 05 0D)
- punpckhbw xmmF, xmmB ; xmmF=(15 1D 25 2D 06 0E 16 1E 26 2E 07 0F 17 1F 27 2F)
-
- movdqa xmmD, xmmA
- pslldq xmmA, 8 ; xmmA=(-- -- -- -- -- -- -- -- 00 08 10 18 20 28 01 09)
- psrldq xmmD, 8 ; xmmD=(11 19 21 29 02 0A 12 1A -- -- -- -- -- -- -- --)
-
- punpckhbw xmmA, xmmG ; xmmA=(00 04 08 0C 10 14 18 1C 20 24 28 2C 01 05 09 0D)
- pslldq xmmG, 8 ; xmmG=(-- -- -- -- -- -- -- -- 22 2A 03 0B 13 1B 23 2B)
-
- punpcklbw xmmD, xmmF ; xmmD=(11 15 19 1D 21 25 29 2D 02 06 0A 0E 12 16 1A 1E)
- punpckhbw xmmG, xmmF ; xmmG=(22 26 2A 2E 03 07 0B 0F 13 17 1B 1F 23 27 2B 2F)
-
- movdqa xmmE, xmmA
- pslldq xmmA, 8 ; xmmA=(-- -- -- -- -- -- -- -- 00 04 08 0C 10 14 18 1C)
- psrldq xmmE, 8 ; xmmE=(20 24 28 2C 01 05 09 0D -- -- -- -- -- -- -- --)
-
- punpckhbw xmmA, xmmD ; xmmA=(00 02 04 06 08 0A 0C 0E 10 12 14 16 18 1A 1C 1E)
- pslldq xmmD, 8 ; xmmD=(-- -- -- -- -- -- -- -- 11 15 19 1D 21 25 29 2D)
-
- punpcklbw xmmE, xmmG ; xmmE=(20 22 24 26 28 2A 2C 2E 01 03 05 07 09 0B 0D 0F)
- punpckhbw xmmD, xmmG ; xmmD=(11 13 15 17 19 1B 1D 1F 21 23 25 27 29 2B 2D 2F)
-
- pxor xmmH, xmmH
-
- movdqa xmmC, xmmA
- punpcklbw xmmA, xmmH ; xmmA=(00 02 04 06 08 0A 0C 0E)
- punpckhbw xmmC, xmmH ; xmmC=(10 12 14 16 18 1A 1C 1E)
-
- movdqa xmmB, xmmE
- punpcklbw xmmE, xmmH ; xmmE=(20 22 24 26 28 2A 2C 2E)
- punpckhbw xmmB, xmmH ; xmmB=(01 03 05 07 09 0B 0D 0F)
-
- movdqa xmmF, xmmD
- punpcklbw xmmD, xmmH ; xmmD=(11 13 15 17 19 1B 1D 1F)
- punpckhbw xmmF, xmmH ; xmmF=(21 23 25 27 29 2B 2D 2F)
-
-%else ; RGB_PIXELSIZE == 4 ; -----------
-
-.column_ld1:
- test cl, SIZEOF_XMMWORD/16
- jz short .column_ld2
- sub ecx, byte SIZEOF_XMMWORD/16
- movd xmmA, XMM_DWORD [esi+ecx*RGB_PIXELSIZE]
-.column_ld2:
- test cl, SIZEOF_XMMWORD/8
- jz short .column_ld4
- sub ecx, byte SIZEOF_XMMWORD/8
- movq xmmE, XMM_MMWORD [esi+ecx*RGB_PIXELSIZE]
- pslldq xmmA, SIZEOF_MMWORD
- por xmmA, xmmE
-.column_ld4:
- test cl, SIZEOF_XMMWORD/4
- jz short .column_ld8
- sub ecx, byte SIZEOF_XMMWORD/4
- movdqa xmmE, xmmA
- movdqu xmmA, XMMWORD [esi+ecx*RGB_PIXELSIZE]
-.column_ld8:
- test cl, SIZEOF_XMMWORD/2
- mov ecx, SIZEOF_XMMWORD
- jz short .rgb_gray_cnv
- movdqa xmmF, xmmA
- movdqa xmmH, xmmE
- movdqu xmmA, XMMWORD [esi+0*SIZEOF_XMMWORD]
- movdqu xmmE, XMMWORD [esi+1*SIZEOF_XMMWORD]
- jmp short .rgb_gray_cnv
- alignx 16, 7
-
-.columnloop:
- movdqu xmmA, XMMWORD [esi+0*SIZEOF_XMMWORD]
- movdqu xmmE, XMMWORD [esi+1*SIZEOF_XMMWORD]
- movdqu xmmF, XMMWORD [esi+2*SIZEOF_XMMWORD]
- movdqu xmmH, XMMWORD [esi+3*SIZEOF_XMMWORD]
-
-.rgb_gray_cnv:
- ; xmmA=(00 10 20 30 01 11 21 31 02 12 22 32 03 13 23 33)
- ; xmmE=(04 14 24 34 05 15 25 35 06 16 26 36 07 17 27 37)
- ; xmmF=(08 18 28 38 09 19 29 39 0A 1A 2A 3A 0B 1B 2B 3B)
- ; xmmH=(0C 1C 2C 3C 0D 1D 2D 3D 0E 1E 2E 3E 0F 1F 2F 3F)
-
- movdqa xmmD, xmmA
- punpcklbw xmmA, xmmE ; xmmA=(00 04 10 14 20 24 30 34 01 05 11 15 21 25 31 35)
- punpckhbw xmmD, xmmE ; xmmD=(02 06 12 16 22 26 32 36 03 07 13 17 23 27 33 37)
-
- movdqa xmmC, xmmF
- punpcklbw xmmF, xmmH ; xmmF=(08 0C 18 1C 28 2C 38 3C 09 0D 19 1D 29 2D 39 3D)
- punpckhbw xmmC, xmmH ; xmmC=(0A 0E 1A 1E 2A 2E 3A 3E 0B 0F 1B 1F 2B 2F 3B 3F)
-
- movdqa xmmB, xmmA
- punpcklwd xmmA, xmmF ; xmmA=(00 04 08 0C 10 14 18 1C 20 24 28 2C 30 34 38 3C)
- punpckhwd xmmB, xmmF ; xmmB=(01 05 09 0D 11 15 19 1D 21 25 29 2D 31 35 39 3D)
-
- movdqa xmmG, xmmD
- punpcklwd xmmD, xmmC ; xmmD=(02 06 0A 0E 12 16 1A 1E 22 26 2A 2E 32 36 3A 3E)
- punpckhwd xmmG, xmmC ; xmmG=(03 07 0B 0F 13 17 1B 1F 23 27 2B 2F 33 37 3B 3F)
-
- movdqa xmmE, xmmA
- punpcklbw xmmA, xmmD ; xmmA=(00 02 04 06 08 0A 0C 0E 10 12 14 16 18 1A 1C 1E)
- punpckhbw xmmE, xmmD ; xmmE=(20 22 24 26 28 2A 2C 2E 30 32 34 36 38 3A 3C 3E)
-
- movdqa xmmH, xmmB
- punpcklbw xmmB, xmmG ; xmmB=(01 03 05 07 09 0B 0D 0F 11 13 15 17 19 1B 1D 1F)
- punpckhbw xmmH, xmmG ; xmmH=(21 23 25 27 29 2B 2D 2F 31 33 35 37 39 3B 3D 3F)
-
- pxor xmmF, xmmF
-
- movdqa xmmC, xmmA
- punpcklbw xmmA, xmmF ; xmmA=(00 02 04 06 08 0A 0C 0E)
- punpckhbw xmmC, xmmF ; xmmC=(10 12 14 16 18 1A 1C 1E)
-
- movdqa xmmD, xmmB
- punpcklbw xmmB, xmmF ; xmmB=(01 03 05 07 09 0B 0D 0F)
- punpckhbw xmmD, xmmF ; xmmD=(11 13 15 17 19 1B 1D 1F)
-
- movdqa xmmG, xmmE
- punpcklbw xmmE, xmmF ; xmmE=(20 22 24 26 28 2A 2C 2E)
- punpckhbw xmmG, xmmF ; xmmG=(30 32 34 36 38 3A 3C 3E)
-
- punpcklbw xmmF, xmmH
- punpckhbw xmmH, xmmH
- psrlw xmmF, BYTE_BIT ; xmmF=(21 23 25 27 29 2B 2D 2F)
- psrlw xmmH, BYTE_BIT ; xmmH=(31 33 35 37 39 3B 3D 3F)
-
-%endif ; RGB_PIXELSIZE ; ---------------
-
- ; xmm0=R(02468ACE)=RE, xmm2=G(02468ACE)=GE, xmm4=B(02468ACE)=BE
- ; xmm1=R(13579BDF)=RO, xmm3=G(13579BDF)=GO, xmm5=B(13579BDF)=BO
-
- ; (Original)
- ; Y = 0.29900 * R + 0.58700 * G + 0.11400 * B
- ;
- ; (This implementation)
- ; Y = 0.29900 * R + 0.33700 * G + 0.11400 * B + 0.25000 * G
-
- movdqa xmm6, xmm1
- punpcklwd xmm1, xmm3
- punpckhwd xmm6, xmm3
- pmaddwd xmm1, [GOTOFF(eax,PW_F0299_F0337)] ; xmm1=ROL*FIX(0.299)+GOL*FIX(0.337)
- pmaddwd xmm6, [GOTOFF(eax,PW_F0299_F0337)] ; xmm6=ROH*FIX(0.299)+GOH*FIX(0.337)
-
- movdqa xmm7, xmm6 ; xmm7=ROH*FIX(0.299)+GOH*FIX(0.337)
-
- movdqa xmm6, xmm0
- punpcklwd xmm0, xmm2
- punpckhwd xmm6, xmm2
- pmaddwd xmm0, [GOTOFF(eax,PW_F0299_F0337)] ; xmm0=REL*FIX(0.299)+GEL*FIX(0.337)
- pmaddwd xmm6, [GOTOFF(eax,PW_F0299_F0337)] ; xmm6=REH*FIX(0.299)+GEH*FIX(0.337)
-
- movdqa XMMWORD [wk(0)], xmm0 ; wk(0)=REL*FIX(0.299)+GEL*FIX(0.337)
- movdqa XMMWORD [wk(1)], xmm6 ; wk(1)=REH*FIX(0.299)+GEH*FIX(0.337)
-
- movdqa xmm0, xmm5 ; xmm0=BO
- movdqa xmm6, xmm4 ; xmm6=BE
-
- movdqa xmm4, xmm0
- punpcklwd xmm0, xmm3
- punpckhwd xmm4, xmm3
- pmaddwd xmm0, [GOTOFF(eax,PW_F0114_F0250)] ; xmm0=BOL*FIX(0.114)+GOL*FIX(0.250)
- pmaddwd xmm4, [GOTOFF(eax,PW_F0114_F0250)] ; xmm4=BOH*FIX(0.114)+GOH*FIX(0.250)
-
- movdqa xmm3, [GOTOFF(eax,PD_ONEHALF)] ; xmm3=[PD_ONEHALF]
-
- paddd xmm0, xmm1
- paddd xmm4, xmm7
- paddd xmm0, xmm3
- paddd xmm4, xmm3
- psrld xmm0, SCALEBITS ; xmm0=YOL
- psrld xmm4, SCALEBITS ; xmm4=YOH
- packssdw xmm0, xmm4 ; xmm0=YO
-
- movdqa xmm4, xmm6
- punpcklwd xmm6, xmm2
- punpckhwd xmm4, xmm2
- pmaddwd xmm6, [GOTOFF(eax,PW_F0114_F0250)] ; xmm6=BEL*FIX(0.114)+GEL*FIX(0.250)
- pmaddwd xmm4, [GOTOFF(eax,PW_F0114_F0250)] ; xmm4=BEH*FIX(0.114)+GEH*FIX(0.250)
-
- movdqa xmm2, [GOTOFF(eax,PD_ONEHALF)] ; xmm2=[PD_ONEHALF]
-
- paddd xmm6, XMMWORD [wk(0)]
- paddd xmm4, XMMWORD [wk(1)]
- paddd xmm6, xmm2
- paddd xmm4, xmm2
- psrld xmm6, SCALEBITS ; xmm6=YEL
- psrld xmm4, SCALEBITS ; xmm4=YEH
- packssdw xmm6, xmm4 ; xmm6=YE
-
- psllw xmm0, BYTE_BIT
- por xmm6, xmm0 ; xmm6=Y
- movdqa XMMWORD [edi], xmm6 ; Save Y
-
- sub ecx, byte SIZEOF_XMMWORD
- add esi, byte RGB_PIXELSIZE*SIZEOF_XMMWORD ; inptr
- add edi, byte SIZEOF_XMMWORD ; outptr0
- cmp ecx, byte SIZEOF_XMMWORD
- jae near .columnloop
- test ecx, ecx
- jnz near .column_ld1
-
- pop ecx ; col
- pop esi
- pop edi
- poppic eax
-
- add esi, byte SIZEOF_JSAMPROW ; input_buf
- add edi, byte SIZEOF_JSAMPROW
- dec eax ; num_rows
- jg near .rowloop
-
-.return:
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- pop ebx
- mov esp, ebp ; esp <- aligned ebp
- pop esp ; esp <- original ebp
- pop ebp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jchuff-sse2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jchuff-sse2.asm
deleted file mode 100644
index 278cf5e83a..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jchuff-sse2.asm
+++ /dev/null
@@ -1,761 +0,0 @@
-;
-; jchuff-sse2.asm - Huffman entropy encoding (SSE2)
-;
-; Copyright (C) 2009-2011, 2014-2017, 2019, D. R. Commander.
-; Copyright (C) 2015, Matthieu Darbois.
-; Copyright (C) 2018, Matthias Räncker.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-;
-; This file contains an SSE2 implementation for Huffman coding of one block.
-; The following code is based on jchuff.c; see jchuff.c for more details.
-
-%include "jsimdext.inc"
-
-struc working_state
-.next_output_byte: resp 1 ; => next byte to write in buffer
-.free_in_buffer: resp 1 ; # of byte spaces remaining in buffer
-.cur.put_buffer.simd resq 1 ; current bit accumulation buffer
-.cur.free_bits resd 1 ; # of bits available in it
-.cur.last_dc_val resd 4 ; last DC coef for each component
-.cinfo: resp 1 ; dump_buffer needs access to this
-endstruc
-
-struc c_derived_tbl
-.ehufco: resd 256 ; code for each symbol
-.ehufsi: resb 256 ; length of code for each symbol
-; If no code has been allocated for a symbol S, ehufsi[S] contains 0
-endstruc
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- GLOBAL_DATA(jconst_huff_encode_one_block)
-
-EXTN(jconst_huff_encode_one_block):
-
- alignz 32
-
-jpeg_mask_bits dq 0x0000, 0x0001, 0x0003, 0x0007
- dq 0x000f, 0x001f, 0x003f, 0x007f
- dq 0x00ff, 0x01ff, 0x03ff, 0x07ff
- dq 0x0fff, 0x1fff, 0x3fff, 0x7fff
-
-times 1 << 14 db 15
-times 1 << 13 db 14
-times 1 << 12 db 13
-times 1 << 11 db 12
-times 1 << 10 db 11
-times 1 << 9 db 10
-times 1 << 8 db 9
-times 1 << 7 db 8
-times 1 << 6 db 7
-times 1 << 5 db 6
-times 1 << 4 db 5
-times 1 << 3 db 4
-times 1 << 2 db 3
-times 1 << 1 db 2
-times 1 << 0 db 1
-times 1 db 0
-jpeg_nbits_table:
-times 1 db 0
-times 1 << 0 db 1
-times 1 << 1 db 2
-times 1 << 2 db 3
-times 1 << 3 db 4
-times 1 << 4 db 5
-times 1 << 5 db 6
-times 1 << 6 db 7
-times 1 << 7 db 8
-times 1 << 8 db 9
-times 1 << 9 db 10
-times 1 << 10 db 11
-times 1 << 11 db 12
-times 1 << 12 db 13
-times 1 << 13 db 14
-times 1 << 14 db 15
-
- alignz 32
-
-%ifdef PIC
-%define NBITS(x) nbits_base + x
-%else
-%define NBITS(x) jpeg_nbits_table + x
-%endif
-%define MASK_BITS(x) NBITS((x) * 8) + (jpeg_mask_bits - jpeg_nbits_table)
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-
-%define mm_put_buffer mm0
-%define mm_all_0xff mm1
-%define mm_temp mm2
-%define mm_nbits mm3
-%define mm_code_bits mm3
-%define mm_code mm4
-%define mm_overflow_bits mm5
-%define mm_save_nbits mm6
-
-; Shorthand used to describe SIMD operations:
-; wN: xmmN treated as eight signed 16-bit values
-; wN[i]: perform the same operation on all eight signed 16-bit values, i=0..7
-; bN: xmmN treated as 16 unsigned 8-bit values, or
-; mmN treated as eight unsigned 8-bit values
-; bN[i]: perform the same operation on all unsigned 8-bit values,
-; i=0..15 (SSE register) or i=0..7 (MMX register)
-; Contents of SIMD registers are shown in memory order.
-
-; Fill the bit buffer to capacity with the leading bits from code, then output
-; the bit buffer and put the remaining bits from code into the bit buffer.
-;
-; Usage:
-; code - contains the bits to shift into the bit buffer (LSB-aligned)
-; %1 - temp register
-; %2 - low byte of temp register
-; %3 - second byte of temp register
-; %4-%8 (optional) - extra instructions to execute before the macro completes
-; %9 - the label to which to jump when the macro completes
-;
-; Upon completion, free_bits will be set to the number of remaining bits from
-; code, and put_buffer will contain those remaining bits. temp and code will
-; be clobbered.
-;
-; This macro encodes any 0xFF bytes as 0xFF 0x00, as does the EMIT_BYTE()
-; macro in jchuff.c.
-
-%macro EMIT_QWORD 9
-%define %%temp %1
-%define %%tempb %2
-%define %%temph %3
- add nbits, free_bits ; nbits += free_bits;
- neg free_bits ; free_bits = -free_bits;
- movq mm_temp, mm_code ; temp = code;
- movd mm_nbits, nbits ; nbits --> MMX register
- movd mm_overflow_bits, free_bits ; overflow_bits (temp register) = free_bits;
- neg free_bits ; free_bits = -free_bits;
- psllq mm_put_buffer, mm_nbits ; put_buffer <<= nbits;
- psrlq mm_temp, mm_overflow_bits ; temp >>= overflow_bits;
- add free_bits, 64 ; free_bits += 64;
- por mm_temp, mm_put_buffer ; temp |= put_buffer;
-%ifidn %%temp, nbits_base
- movd mm_save_nbits, nbits_base ; save nbits_base
-%endif
- movq mm_code_bits, mm_temp ; code_bits (temp register) = temp;
- movq mm_put_buffer, mm_code ; put_buffer = code;
- pcmpeqb mm_temp, mm_all_0xff ; b_temp[i] = (b_temp[i] == 0xFF ? 0xFF : 0);
- movq mm_code, mm_code_bits ; code = code_bits;
- psrlq mm_code_bits, 32 ; code_bits >>= 32;
- pmovmskb nbits, mm_temp ; nbits = 0; nbits |= ((b_temp[i] >> 7) << i);
- movd %%temp, mm_code_bits ; temp = code_bits;
- bswap %%temp ; temp = htonl(temp);
- test nbits, nbits ; if (nbits != 0) /* Some 0xFF bytes */
- jnz %%.SLOW ; goto %%.SLOW
- mov dword [buffer], %%temp ; *(uint32_t)buffer = temp;
-%ifidn %%temp, nbits_base
- movd nbits_base, mm_save_nbits ; restore nbits_base
-%endif
- %4
- movd nbits, mm_code ; nbits = (uint32_t)(code);
- %5
- bswap nbits ; nbits = htonl(nbits);
- mov dword [buffer + 4], nbits ; *(uint32_t)(buffer + 4) = nbits;
- lea buffer, [buffer + 8] ; buffer += 8;
- %6
- %7
- %8
- jmp %9 ; return
-%%.SLOW:
- ; Execute the equivalent of the EMIT_BYTE() macro in jchuff.c for all 8
- ; bytes in the qword.
- mov byte [buffer], %%tempb ; buffer[0] = temp[0];
- cmp %%tempb, 0xFF ; Set CF if temp[0] < 0xFF
- mov byte [buffer+1], 0 ; buffer[1] = 0;
- sbb buffer, -2 ; buffer -= (-2 + (temp[0] < 0xFF ? 1 : 0));
- mov byte [buffer], %%temph ; buffer[0] = temp[1];
- cmp %%temph, 0xFF ; Set CF if temp[1] < 0xFF
- mov byte [buffer+1], 0 ; buffer[1] = 0;
- sbb buffer, -2 ; buffer -= (-2 + (temp[1] < 0xFF ? 1 : 0));
- shr %%temp, 16 ; temp >>= 16;
- mov byte [buffer], %%tempb ; buffer[0] = temp[0];
- cmp %%tempb, 0xFF ; Set CF if temp[0] < 0xFF
- mov byte [buffer+1], 0 ; buffer[1] = 0;
- sbb buffer, -2 ; buffer -= (-2 + (temp[0] < 0xFF ? 1 : 0));
- mov byte [buffer], %%temph ; buffer[0] = temp[1];
- cmp %%temph, 0xFF ; Set CF if temp[1] < 0xFF
- mov byte [buffer+1], 0 ; buffer[1] = 0;
- sbb buffer, -2 ; buffer -= (-2 + (temp[1] < 0xFF ? 1 : 0));
- movd nbits, mm_code ; nbits (temp register) = (uint32_t)(code)
-%ifidn %%temp, nbits_base
- movd nbits_base, mm_save_nbits ; restore nbits_base
-%endif
- bswap nbits ; nbits = htonl(nbits)
- mov byte [buffer], nbitsb ; buffer[0] = nbits[0];
- cmp nbitsb, 0xFF ; Set CF if nbits[0] < 0xFF
- mov byte [buffer+1], 0 ; buffer[1] = 0;
- sbb buffer, -2 ; buffer -= (-2 + (nbits[0] < 0xFF ? 1 : 0));
- mov byte [buffer], nbitsh ; buffer[0] = nbits[1];
- cmp nbitsh, 0xFF ; Set CF if nbits[1] < 0xFF
- mov byte [buffer+1], 0 ; buffer[1] = 0;
- sbb buffer, -2 ; buffer -= (-2 + (nbits[1] < 0xFF ? 1 : 0));
- shr nbits, 16 ; nbits >>= 16;
- mov byte [buffer], nbitsb ; buffer[0] = nbits[0];
- cmp nbitsb, 0xFF ; Set CF if nbits[0] < 0xFF
- mov byte [buffer+1], 0 ; buffer[1] = 0;
- sbb buffer, -2 ; buffer -= (-2 + (nbits[0] < 0xFF ? 1 : 0));
- mov byte [buffer], nbitsh ; buffer[0] = nbits[1];
- %4
- cmp nbitsh, 0xFF ; Set CF if nbits[1] < 0xFF
- mov byte [buffer+1], 0 ; buffer[1] = 0;
- sbb buffer, -2 ; buffer -= (-2 + (nbits[1] < 0xFF ? 1 : 0));
- %5
- %6
- %7
- %8
- jmp %9 ; return;
-%endmacro
-
-%macro PUSH 1
- push %1
-%assign stack_offset stack_offset + 4
-%endmacro
-
-%macro POP 1
- pop %1
-%assign stack_offset stack_offset - 4
-%endmacro
-
-; If PIC is defined, load the address of a symbol defined in this file into a
-; register. Equivalent to
-; get_GOT %1
-; lea %1, [GOTOFF(%1, %2)]
-; without using the GOT.
-;
-; Usage:
-; %1 - register into which to load the address of the symbol
-; %2 - symbol whose address should be loaded
-; %3 - optional multi-line macro to execute before the symbol address is loaded
-; %4 - optional multi-line macro to execute after the symbol address is loaded
-;
-; If PIC is not defined, then %3 and %4 are executed in order.
-
-%macro GET_SYM 2-4
-%ifdef PIC
- call %%.geteip
-%%.ref:
- %4
- add %1, %2 - %%.ref
- jmp short %%.done
- align 32
-%%.geteip:
- %3 4 ; must adjust stack pointer because of call
- mov %1, POINTER [esp]
- ret
- align 32
-%%.done:
-%else
- %3 0
- %4
-%endif
-%endmacro
-
-;
-; Encode a single block's worth of coefficients.
-;
-; GLOBAL(JOCTET *)
-; jsimd_huff_encode_one_block_sse2(working_state *state, JOCTET *buffer,
-; JCOEFPTR block, int last_dc_val,
-; c_derived_tbl *dctbl, c_derived_tbl *actbl)
-;
-; Stack layout:
-; Function args
-; Return address
-; Saved ebx
-; Saved ebp
-; Saved esi
-; Saved edi <-- esp_save
-; ...
-; esp_save
-; t_ 64*2 bytes (aligned to 128 bytes)
-;
-; esp is used (as t) to point into t_ (data in lower indices is not used once
-; esp passes over them, so this is signal-safe.) Aligning to 128 bytes allows
-; us to find the rest of the data again.
-;
-; NOTES:
-; When shuffling data, we try to avoid pinsrw as much as possible, since it is
-; slow on many CPUs. Its reciprocal throughput (issue latency) is 1 even on
-; modern CPUs, so chains of pinsrw instructions (even with different outputs)
-; can limit performance. pinsrw is a VectorPath instruction on AMD K8 and
-; requires 2 µops (with memory operand) on Intel. In either case, only one
-; pinsrw instruction can be decoded per cycle (and nothing else if they are
-; back-to-back), so out-of-order execution cannot be used to work around long
-; pinsrw chains (though for Sandy Bridge and later, this may be less of a
-; problem if the code runs from the µop cache.)
-;
-; We use tzcnt instead of bsf without checking for support. The instruction is
-; executed as bsf on CPUs that don't support tzcnt (encoding is equivalent to
-; rep bsf.) The destination (first) operand of bsf (and tzcnt on some CPUs) is
-; an input dependency (although the behavior is not formally defined, Intel
-; CPUs usually leave the destination unmodified if the source is zero.) This
-; can prevent out-of-order execution, so we clear the destination before
-; invoking tzcnt.
-;
-; Initial register allocation
-; eax - frame --> buffer
-; ebx - nbits_base (PIC) / emit_temp
-; ecx - dctbl --> size --> state
-; edx - block --> nbits
-; esi - code_temp --> state --> actbl
-; edi - index_temp --> free_bits
-; esp - t
-; ebp - index
-
-%define frame eax
-%ifdef PIC
-%define nbits_base ebx
-%endif
-%define emit_temp ebx
-%define emit_tempb bl
-%define emit_temph bh
-%define dctbl ecx
-%define block edx
-%define code_temp esi
-%define index_temp edi
-%define t esp
-%define index ebp
-
-%assign save_frame DCTSIZE2 * SIZEOF_WORD
-
-; Step 1: Re-arrange input data according to jpeg_natural_order
-; xx 01 02 03 04 05 06 07 xx 01 08 16 09 02 03 10
-; 08 09 10 11 12 13 14 15 17 24 32 25 18 11 04 05
-; 16 17 18 19 20 21 22 23 12 19 26 33 40 48 41 34
-; 24 25 26 27 28 29 30 31 ==> 27 20 13 06 07 14 21 28
-; 32 33 34 35 36 37 38 39 35 42 49 56 57 50 43 36
-; 40 41 42 43 44 45 46 47 29 22 15 23 30 37 44 51
-; 48 49 50 51 52 53 54 55 58 59 52 45 38 31 39 46
-; 56 57 58 59 60 61 62 63 53 60 61 54 47 55 62 63
-
- align 32
- GLOBAL_FUNCTION(jsimd_huff_encode_one_block_sse2)
-
-EXTN(jsimd_huff_encode_one_block_sse2):
-
-%assign stack_offset 0
-%define arg_state 4 + stack_offset
-%define arg_buffer 8 + stack_offset
-%define arg_block 12 + stack_offset
-%define arg_last_dc_val 16 + stack_offset
-%define arg_dctbl 20 + stack_offset
-%define arg_actbl 24 + stack_offset
-
- ;X: X = code stream
- mov block, [esp + arg_block]
- PUSH ebx
- PUSH ebp
- movups xmm3, XMMWORD [block + 0 * SIZEOF_WORD] ;D: w3 = xx 01 02 03 04 05 06 07
- PUSH esi
- PUSH edi
- movdqa xmm0, xmm3 ;A: w0 = xx 01 02 03 04 05 06 07
- mov frame, esp
- lea t, [frame - (save_frame + 4)]
- movups xmm1, XMMWORD [block + 8 * SIZEOF_WORD] ;B: w1 = 08 09 10 11 12 13 14 15
- and t, -DCTSIZE2 * SIZEOF_WORD ; t = &t_[0]
- mov [t + save_frame], frame
- pxor xmm4, xmm4 ;A: w4[i] = 0;
- punpckldq xmm0, xmm1 ;A: w0 = xx 01 08 09 02 03 10 11
- pshuflw xmm0, xmm0, 11001001b ;A: w0 = 01 08 xx 09 02 03 10 11
- pinsrw xmm0, word [block + 16 * SIZEOF_WORD], 2 ;A: w0 = 01 08 16 09 02 03 10 11
- punpckhdq xmm3, xmm1 ;D: w3 = 04 05 12 13 06 07 14 15
- punpcklqdq xmm1, xmm3 ;B: w1 = 08 09 10 11 04 05 12 13
- pinsrw xmm0, word [block + 17 * SIZEOF_WORD], 7 ;A: w0 = 01 08 16 09 02 03 10 17
- ;A: (Row 0, offset 1)
- pcmpgtw xmm4, xmm0 ;A: w4[i] = (w0[i] < 0 ? -1 : 0);
- paddw xmm0, xmm4 ;A: w0[i] += w4[i];
- movaps XMMWORD [t + 0 * SIZEOF_WORD], xmm0 ;A: t[i] = w0[i];
-
- movq xmm2, qword [block + 24 * SIZEOF_WORD] ;B: w2 = 24 25 26 27 -- -- -- --
- pshuflw xmm2, xmm2, 11011000b ;B: w2 = 24 26 25 27 -- -- -- --
- pslldq xmm1, 1 * SIZEOF_WORD ;B: w1 = -- 08 09 10 11 04 05 12
- movups xmm5, XMMWORD [block + 48 * SIZEOF_WORD] ;H: w5 = 48 49 50 51 52 53 54 55
- movsd xmm1, xmm2 ;B: w1 = 24 26 25 27 11 04 05 12
- punpcklqdq xmm2, xmm5 ;C: w2 = 24 26 25 27 48 49 50 51
- pinsrw xmm1, word [block + 32 * SIZEOF_WORD], 1 ;B: w1 = 24 32 25 27 11 04 05 12
- pxor xmm4, xmm4 ;A: w4[i] = 0;
- psrldq xmm3, 2 * SIZEOF_WORD ;D: w3 = 12 13 06 07 14 15 -- --
- pcmpeqw xmm0, xmm4 ;A: w0[i] = (w0[i] == 0 ? -1 : 0);
- pinsrw xmm1, word [block + 18 * SIZEOF_WORD], 3 ;B: w1 = 24 32 25 18 11 04 05 12
- ; (Row 1, offset 1)
- pcmpgtw xmm4, xmm1 ;B: w4[i] = (w1[i] < 0 ? -1 : 0);
- paddw xmm1, xmm4 ;B: w1[i] += w4[i];
- movaps XMMWORD [t + 8 * SIZEOF_WORD], xmm1 ;B: t[i+8] = w1[i];
- pxor xmm4, xmm4 ;B: w4[i] = 0;
- pcmpeqw xmm1, xmm4 ;B: w1[i] = (w1[i] == 0 ? -1 : 0);
-
- packsswb xmm0, xmm1 ;AB: b0[i] = w0[i], b0[i+8] = w1[i]
- ; w/ signed saturation
-
- pinsrw xmm3, word [block + 20 * SIZEOF_WORD], 0 ;D: w3 = 20 13 06 07 14 15 -- --
- pinsrw xmm3, word [block + 21 * SIZEOF_WORD], 5 ;D: w3 = 20 13 06 07 14 21 -- --
- pinsrw xmm3, word [block + 28 * SIZEOF_WORD], 6 ;D: w3 = 20 13 06 07 14 21 28 --
- pinsrw xmm3, word [block + 35 * SIZEOF_WORD], 7 ;D: w3 = 20 13 06 07 14 21 28 35
- ; (Row 3, offset 1)
- pcmpgtw xmm4, xmm3 ;D: w4[i] = (w3[i] < 0 ? -1 : 0);
- paddw xmm3, xmm4 ;D: w3[i] += w4[i];
- movaps XMMWORD [t + 24 * SIZEOF_WORD], xmm3 ;D: t[i+24] = w3[i];
- pxor xmm4, xmm4 ;D: w4[i] = 0;
- pcmpeqw xmm3, xmm4 ;D: w3[i] = (w3[i] == 0 ? -1 : 0);
-
- pinsrw xmm2, word [block + 19 * SIZEOF_WORD], 0 ;C: w2 = 19 26 25 27 48 49 50 51
- pinsrw xmm2, word [block + 33 * SIZEOF_WORD], 2 ;C: w2 = 19 26 33 27 48 49 50 51
- pinsrw xmm2, word [block + 40 * SIZEOF_WORD], 3 ;C: w2 = 19 26 33 40 48 49 50 51
- pinsrw xmm2, word [block + 41 * SIZEOF_WORD], 5 ;C: w2 = 19 26 33 40 48 41 50 51
- pinsrw xmm2, word [block + 34 * SIZEOF_WORD], 6 ;C: w2 = 19 26 33 40 48 41 34 51
- pinsrw xmm2, word [block + 27 * SIZEOF_WORD], 7 ;C: w2 = 19 26 33 40 48 41 34 27
- ; (Row 2, offset 1)
- pcmpgtw xmm4, xmm2 ;C: w4[i] = (w2[i] < 0 ? -1 : 0);
- paddw xmm2, xmm4 ;C: w2[i] += w4[i];
- movsx code_temp, word [block] ;Z: code_temp = block[0];
-
-; %1 - stack pointer adjustment
-%macro GET_SYM_BEFORE 1
- movaps XMMWORD [t + 16 * SIZEOF_WORD + %1], xmm2
- ;C: t[i+16] = w2[i];
- pxor xmm4, xmm4 ;C: w4[i] = 0;
- pcmpeqw xmm2, xmm4 ;C: w2[i] = (w2[i] == 0 ? -1 : 0);
- sub code_temp, [frame + arg_last_dc_val] ;Z: code_temp -= last_dc_val;
-
- packsswb xmm2, xmm3 ;CD: b2[i] = w2[i], b2[i+8] = w3[i]
- ; w/ signed saturation
-
- movdqa xmm3, xmm5 ;H: w3 = 48 49 50 51 52 53 54 55
- pmovmskb index_temp, xmm2 ;Z: index_temp = 0; index_temp |= ((b2[i] >> 7) << i);
- pmovmskb index, xmm0 ;Z: index = 0; index |= ((b0[i] >> 7) << i);
- movups xmm0, XMMWORD [block + 56 * SIZEOF_WORD] ;H: w0 = 56 57 58 59 60 61 62 63
- punpckhdq xmm3, xmm0 ;H: w3 = 52 53 60 61 54 55 62 63
- shl index_temp, 16 ;Z: index_temp <<= 16;
- psrldq xmm3, 1 * SIZEOF_WORD ;H: w3 = 53 60 61 54 55 62 63 --
- pxor xmm2, xmm2 ;H: w2[i] = 0;
- pshuflw xmm3, xmm3, 00111001b ;H: w3 = 60 61 54 53 55 62 63 --
- or index, index_temp ;Z: index |= index_temp;
-%undef index_temp
-%define free_bits edi
-%endmacro
-
-%macro GET_SYM_AFTER 0
- movq xmm1, qword [block + 44 * SIZEOF_WORD] ;G: w1 = 44 45 46 47 -- -- -- --
- unpcklps xmm5, xmm0 ;E: w5 = 48 49 56 57 50 51 58 59
- pxor xmm0, xmm0 ;H: w0[i] = 0;
- not index ;Z: index = ~index;
- pinsrw xmm3, word [block + 47 * SIZEOF_WORD], 3 ;H: w3 = 60 61 54 47 55 62 63 --
- ; (Row 7, offset 1)
- pcmpgtw xmm2, xmm3 ;H: w2[i] = (w3[i] < 0 ? -1 : 0);
- mov dctbl, [frame + arg_dctbl]
- paddw xmm3, xmm2 ;H: w3[i] += w2[i];
- movaps XMMWORD [t + 56 * SIZEOF_WORD], xmm3 ;H: t[i+56] = w3[i];
- movq xmm4, qword [block + 36 * SIZEOF_WORD] ;G: w4 = 36 37 38 39 -- -- -- --
- pcmpeqw xmm3, xmm0 ;H: w3[i] = (w3[i] == 0 ? -1 : 0);
- punpckldq xmm4, xmm1 ;G: w4 = 36 37 44 45 38 39 46 47
- movdqa xmm1, xmm4 ;F: w1 = 36 37 44 45 38 39 46 47
- pcmpeqw mm_all_0xff, mm_all_0xff ;Z: all_0xff[i] = 0xFF;
-%endmacro
-
- GET_SYM nbits_base, jpeg_nbits_table, GET_SYM_BEFORE, GET_SYM_AFTER
-
- psrldq xmm4, 1 * SIZEOF_WORD ;G: w4 = 37 44 45 38 39 46 47 --
- shufpd xmm1, xmm5, 10b ;F: w1 = 36 37 44 45 50 51 58 59
- pshufhw xmm4, xmm4, 11010011b ;G: w4 = 37 44 45 38 -- 39 46 --
- pslldq xmm1, 1 * SIZEOF_WORD ;F: w1 = -- 36 37 44 45 50 51 58
- pinsrw xmm4, word [block + 59 * SIZEOF_WORD], 0 ;G: w4 = 59 44 45 38 -- 39 46 --
- pshufd xmm1, xmm1, 11011000b ;F: w1 = -- 36 45 50 37 44 51 58
- cmp code_temp, 1 << 31 ;Z: Set CF if code_temp < 0x80000000,
- ;Z: i.e. if code_temp is positive
- pinsrw xmm4, word [block + 52 * SIZEOF_WORD], 1 ;G: w4 = 59 52 45 38 -- 39 46 --
- movlps xmm1, qword [block + 20 * SIZEOF_WORD] ;F: w1 = 20 21 22 23 37 44 51 58
- pinsrw xmm4, word [block + 31 * SIZEOF_WORD], 4 ;G: w4 = 59 52 45 38 31 39 46 --
- pshuflw xmm1, xmm1, 01110010b ;F: w1 = 22 20 23 21 37 44 51 58
- pinsrw xmm4, word [block + 53 * SIZEOF_WORD], 7 ;G: w4 = 59 52 45 38 31 39 46 53
- ; (Row 6, offset 1)
- adc code_temp, -1 ;Z: code_temp += -1 + (code_temp >= 0 ? 1 : 0);
- pxor xmm2, xmm2 ;G: w2[i] = 0;
- pcmpgtw xmm0, xmm4 ;G: w0[i] = (w4[i] < 0 ? -1 : 0);
- pinsrw xmm1, word [block + 15 * SIZEOF_WORD], 1 ;F: w1 = 22 15 23 21 37 44 51 58
- paddw xmm4, xmm0 ;G: w4[i] += w0[i];
- movaps XMMWORD [t + 48 * SIZEOF_WORD], xmm4 ;G: t[48+i] = w4[i];
- movd mm_temp, code_temp ;Z: temp = code_temp
- pinsrw xmm1, word [block + 30 * SIZEOF_WORD], 3 ;F: w1 = 22 15 23 30 37 44 51 58
- ; (Row 5, offset 1)
- pcmpeqw xmm4, xmm2 ;G: w4[i] = (w4[i] == 0 ? -1 : 0);
-
- packsswb xmm4, xmm3 ;GH: b4[i] = w4[i], b4[i+8] = w3[i]
- ; w/ signed saturation
-
- lea t, [t - SIZEOF_WORD] ;Z: t = &t[-1]
- pxor xmm0, xmm0 ;F: w0[i] = 0;
- pcmpgtw xmm2, xmm1 ;F: w2[i] = (w1[i] < 0 ? -1 : 0);
- paddw xmm1, xmm2 ;F: w1[i] += w2[i];
- movaps XMMWORD [t + (40+1) * SIZEOF_WORD], xmm1 ;F: t[40+i] = w1[i];
- pcmpeqw xmm1, xmm0 ;F: w1[i] = (w1[i] == 0 ? -1 : 0);
- pinsrw xmm5, word [block + 42 * SIZEOF_WORD], 0 ;E: w5 = 42 49 56 57 50 51 58 59
- pinsrw xmm5, word [block + 43 * SIZEOF_WORD], 5 ;E: w5 = 42 49 56 57 50 43 58 59
- pinsrw xmm5, word [block + 36 * SIZEOF_WORD], 6 ;E: w5 = 42 49 56 57 50 43 36 59
- pinsrw xmm5, word [block + 29 * SIZEOF_WORD], 7 ;E: w5 = 42 49 56 57 50 43 36 29
- ; (Row 4, offset 1)
-%undef block
-%define nbits edx
-%define nbitsb dl
-%define nbitsh dh
- movzx nbits, byte [NBITS(code_temp)] ;Z: nbits = JPEG_NBITS(code_temp);
-%undef code_temp
-%define state esi
- pxor xmm2, xmm2 ;E: w2[i] = 0;
- mov state, [frame + arg_state]
- movd mm_nbits, nbits ;Z: nbits --> MMX register
- pcmpgtw xmm0, xmm5 ;E: w0[i] = (w5[i] < 0 ? -1 : 0);
- movd mm_code, dword [dctbl + c_derived_tbl.ehufco + nbits * 4]
- ;Z: code = dctbl->ehufco[nbits];
-%define size ecx
-%define sizeb cl
-%define sizeh ch
- paddw xmm5, xmm0 ;E: w5[i] += w0[i];
- movaps XMMWORD [t + (32+1) * SIZEOF_WORD], xmm5 ;E: t[32+i] = w5[i];
- movzx size, byte [dctbl + c_derived_tbl.ehufsi + nbits]
- ;Z: size = dctbl->ehufsi[nbits];
-%undef dctbl
- pcmpeqw xmm5, xmm2 ;E: w5[i] = (w5[i] == 0 ? -1 : 0);
-
- packsswb xmm5, xmm1 ;EF: b5[i] = w5[i], b5[i+8] = w1[i]
- ; w/ signed saturation
-
- movq mm_put_buffer, [state + working_state.cur.put_buffer.simd]
- ;Z: put_buffer = state->cur.put_buffer.simd;
- mov free_bits, [state + working_state.cur.free_bits]
- ;Z: free_bits = state->cur.free_bits;
-%undef state
-%define actbl esi
- mov actbl, [frame + arg_actbl]
-%define buffer eax
- mov buffer, [frame + arg_buffer]
-%undef frame
- jmp .BEGIN
-
-; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- align 16
-; size <= 32, so this is not really a loop
-.BRLOOP1: ; .BRLOOP1:
- movzx nbits, byte [actbl + c_derived_tbl.ehufsi + 0xf0]
- ; nbits = actbl->ehufsi[0xf0];
- movd mm_code, dword [actbl + c_derived_tbl.ehufco + 0xf0 * 4]
- ; code = actbl->ehufco[0xf0];
- and index, 0x7ffffff ; clear index if size == 32
- sub size, 16 ; size -= 16;
- sub free_bits, nbits ; if ((free_bits -= nbits) <= 0)
- jle .EMIT_BRLOOP1 ; goto .EMIT_BRLOOP1;
- movd mm_nbits, nbits ; nbits --> MMX register
- psllq mm_put_buffer, mm_nbits ; put_buffer <<= nbits;
- por mm_put_buffer, mm_code ; put_buffer |= code;
- jmp .ERLOOP1 ; goto .ERLOOP1;
-
-; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- align 16
-%ifdef PIC
- times 6 nop
-%else
- times 2 nop
-%endif
-.BLOOP1: ; do { /* size = # of zero bits/elements to skip */
-; if size == 32, index remains unchanged. Correct in .BRLOOP.
- shr index, sizeb ; index >>= size;
- lea t, [t + size * SIZEOF_WORD] ; t += size;
- cmp size, 16 ; if (size > 16)
- jg .BRLOOP1 ; goto .BRLOOP1;
-.ERLOOP1: ; .ERLOOP1:
- movsx nbits, word [t] ; nbits = *t;
-%ifdef PIC
- add size, size ; size += size;
-%else
- lea size, [size * 2] ; size += size;
-%endif
- movd mm_temp, nbits ; temp = nbits;
- movzx nbits, byte [NBITS(nbits)] ; nbits = JPEG_NBITS(nbits);
- lea size, [size * 8 + nbits] ; size = size * 8 + nbits;
- movd mm_nbits, nbits ; nbits --> MMX register
- movd mm_code, dword [actbl + c_derived_tbl.ehufco + (size - 16) * 4]
- ; code = actbl->ehufco[size-16];
- movzx size, byte [actbl + c_derived_tbl.ehufsi + (size - 16)]
- ; size = actbl->ehufsi[size-16];
-.BEGIN: ; .BEGIN:
- pand mm_temp, [MASK_BITS(nbits)] ; temp &= (1 << nbits) - 1;
- psllq mm_code, mm_nbits ; code <<= nbits;
- add nbits, size ; nbits += size;
- por mm_code, mm_temp ; code |= temp;
- sub free_bits, nbits ; if ((free_bits -= nbits) <= 0)
- jle .EMIT_ERLOOP1 ; insert code, flush buffer, init size, goto .BLOOP1
- xor size, size ; size = 0; /* kill tzcnt input dependency */
- tzcnt size, index ; size = # of trailing 0 bits in index
- movd mm_nbits, nbits ; nbits --> MMX register
- psllq mm_put_buffer, mm_nbits ; put_buffer <<= nbits;
- inc size ; ++size;
- por mm_put_buffer, mm_code ; put_buffer |= code;
- test index, index
- jnz .BLOOP1 ; } while (index != 0);
-; Round 2
-; t points to the last used word, possibly below t_ if the previous index had 32 zero bits.
-.ELOOP1: ; .ELOOP1:
- pmovmskb size, xmm4 ; size = 0; size |= ((b4[i] >> 7) << i);
- pmovmskb index, xmm5 ; index = 0; index |= ((b5[i] >> 7) << i);
- shl size, 16 ; size <<= 16;
- or index, size ; index |= size;
- not index ; index = ~index;
- lea nbits, [t + (1 + DCTSIZE2) * SIZEOF_WORD]
- ; nbits = t + 1 + 64;
- and nbits, -DCTSIZE2 * SIZEOF_WORD ; nbits &= -128; /* now points to &t_[64] */
- sub nbits, t ; nbits -= t;
- shr nbits, 1 ; nbits >>= 1; /* # of leading 0 bits in old index + 33 */
- tzcnt size, index ; size = # of trailing 0 bits in index
- inc size ; ++size;
- test index, index ; if (index == 0)
- jz .ELOOP2 ; goto .ELOOP2;
-; NOTE: size == 32 cannot happen, since the last element is always 0.
- shr index, sizeb ; index >>= size;
- lea size, [size + nbits - 33] ; size = size + nbits - 33;
- lea t, [t + size * SIZEOF_WORD] ; t += size;
- cmp size, 16 ; if (size <= 16)
- jle .ERLOOP2 ; goto .ERLOOP2;
-.BRLOOP2: ; do {
- movzx nbits, byte [actbl + c_derived_tbl.ehufsi + 0xf0]
- ; nbits = actbl->ehufsi[0xf0];
- sub size, 16 ; size -= 16;
- movd mm_code, dword [actbl + c_derived_tbl.ehufco + 0xf0 * 4]
- ; code = actbl->ehufco[0xf0];
- sub free_bits, nbits ; if ((free_bits -= nbits) <= 0)
- jle .EMIT_BRLOOP2 ; insert code and flush put_buffer
- movd mm_nbits, nbits ; else { nbits --> MMX register
- psllq mm_put_buffer, mm_nbits ; put_buffer <<= nbits;
- por mm_put_buffer, mm_code ; put_buffer |= code;
- cmp size, 16 ; if (size <= 16)
- jle .ERLOOP2 ; goto .ERLOOP2;
- jmp .BRLOOP2 ; } while (1);
-
-; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- align 16
-.BLOOP2: ; do { /* size = # of zero bits/elements to skip */
- shr index, sizeb ; index >>= size;
- lea t, [t + size * SIZEOF_WORD] ; t += size;
- cmp size, 16 ; if (size > 16)
- jg .BRLOOP2 ; goto .BRLOOP2;
-.ERLOOP2: ; .ERLOOP2:
- movsx nbits, word [t] ; nbits = *t;
- add size, size ; size += size;
- movd mm_temp, nbits ; temp = nbits;
- movzx nbits, byte [NBITS(nbits)] ; nbits = JPEG_NBITS(nbits);
- movd mm_nbits, nbits ; nbits --> MMX register
- lea size, [size * 8 + nbits] ; size = size * 8 + nbits;
- movd mm_code, dword [actbl + c_derived_tbl.ehufco + (size - 16) * 4]
- ; code = actbl->ehufco[size-16];
- movzx size, byte [actbl + c_derived_tbl.ehufsi + (size - 16)]
- ; size = actbl->ehufsi[size-16];
- psllq mm_code, mm_nbits ; code <<= nbits;
- pand mm_temp, [MASK_BITS(nbits)] ; temp &= (1 << nbits) - 1;
- lea nbits, [nbits + size] ; nbits += size;
- por mm_code, mm_temp ; code |= temp;
- xor size, size ; size = 0; /* kill tzcnt input dependency */
- sub free_bits, nbits ; if ((free_bits -= nbits) <= 0)
- jle .EMIT_ERLOOP2 ; insert code, flush buffer, init size, goto .BLOOP2
- tzcnt size, index ; size = # of trailing 0 bits in index
- movd mm_nbits, nbits ; nbits --> MMX register
- psllq mm_put_buffer, mm_nbits ; put_buffer <<= nbits;
- inc size ; ++size;
- por mm_put_buffer, mm_code ; put_buffer |= code;
- test index, index
- jnz .BLOOP2 ; } while (index != 0);
-.ELOOP2: ; .ELOOP2:
- mov nbits, t ; nbits = t;
- lea t, [t + SIZEOF_WORD] ; t = &t[1];
- and nbits, DCTSIZE2 * SIZEOF_WORD - 1 ; nbits &= 127;
- and t, -DCTSIZE2 * SIZEOF_WORD ; t &= -128; /* t = &t_[0]; */
- cmp nbits, (DCTSIZE2 - 2) * SIZEOF_WORD ; if (nbits != 62 * 2)
- je .EFN ; {
- movd mm_code, dword [actbl + c_derived_tbl.ehufco + 0]
- ; code = actbl->ehufco[0];
- movzx nbits, byte [actbl + c_derived_tbl.ehufsi + 0]
- ; nbits = actbl->ehufsi[0];
- sub free_bits, nbits ; if ((free_bits -= nbits) <= 0)
- jg .EFN_SKIP_EMIT_CODE ; {
- EMIT_QWORD size, sizeb, sizeh, , , , , , .EFN ; insert code, flush put_buffer
- align 16
-.EFN_SKIP_EMIT_CODE: ; } else {
- movd mm_nbits, nbits ; nbits --> MMX register
- psllq mm_put_buffer, mm_nbits ; put_buffer <<= nbits;
- por mm_put_buffer, mm_code ; put_buffer |= code;
-.EFN: ; } }
-%define frame esp
- mov frame, [t + save_frame]
-%define state ecx
- mov state, [frame + arg_state]
- movq [state + working_state.cur.put_buffer.simd], mm_put_buffer
- ; state->cur.put_buffer.simd = put_buffer;
- emms
- mov [state + working_state.cur.free_bits], free_bits
- ; state->cur.free_bits = free_bits;
- POP edi
- POP esi
- POP ebp
- POP ebx
- ret
-
-; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- align 16
-.EMIT_BRLOOP1:
- EMIT_QWORD emit_temp, emit_tempb, emit_temph, , , , , , \
- .ERLOOP1
-
-; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- align 16
-.EMIT_ERLOOP1:
- EMIT_QWORD size, sizeb, sizeh, \
- { xor size, size }, \
- { tzcnt size, index }, \
- { inc size }, \
- { test index, index }, \
- { jnz .BLOOP1 }, \
- .ELOOP1
-
-; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- align 16
-.EMIT_BRLOOP2:
- EMIT_QWORD emit_temp, emit_tempb, emit_temph, , , , \
- { cmp size, 16 }, \
- { jle .ERLOOP2 }, \
- .BRLOOP2
-
-; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- align 16
-.EMIT_ERLOOP2:
- EMIT_QWORD size, sizeb, sizeh, \
- { xor size, size }, \
- { tzcnt size, index }, \
- { inc size }, \
- { test index, index }, \
- { jnz .BLOOP2 }, \
- .ELOOP2
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jcphuff-sse2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jcphuff-sse2.asm
deleted file mode 100644
index c26b48a47d..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jcphuff-sse2.asm
+++ /dev/null
@@ -1,662 +0,0 @@
-;
-; jcphuff-sse2.asm - prepare data for progressive Huffman encoding (SSE2)
-;
-; Copyright (C) 2016, 2018, Matthieu Darbois
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-;
-; This file contains an SSE2 implementation of data preparation for progressive
-; Huffman encoding. See jcphuff.c for more details.
-
-%include "jsimdext.inc"
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-
-; --------------------------------------------------------------------------
-; Macros to load data for jsimd_encode_mcu_AC_first_prepare_sse2() and
-; jsimd_encode_mcu_AC_refine_prepare_sse2()
-
-%macro LOAD16 0
- pxor N0, N0
- pxor N1, N1
-
- mov T0, INT [LUT + 0*SIZEOF_INT]
- mov T1, INT [LUT + 8*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 0
- pinsrw X1, word [BLOCK + T1 * 2], 0
-
- mov T0, INT [LUT + 1*SIZEOF_INT]
- mov T1, INT [LUT + 9*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 1
- pinsrw X1, word [BLOCK + T1 * 2], 1
-
- mov T0, INT [LUT + 2*SIZEOF_INT]
- mov T1, INT [LUT + 10*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 2
- pinsrw X1, word [BLOCK + T1 * 2], 2
-
- mov T0, INT [LUT + 3*SIZEOF_INT]
- mov T1, INT [LUT + 11*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 3
- pinsrw X1, word [BLOCK + T1 * 2], 3
-
- mov T0, INT [LUT + 4*SIZEOF_INT]
- mov T1, INT [LUT + 12*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 4
- pinsrw X1, word [BLOCK + T1 * 2], 4
-
- mov T0, INT [LUT + 5*SIZEOF_INT]
- mov T1, INT [LUT + 13*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 5
- pinsrw X1, word [BLOCK + T1 * 2], 5
-
- mov T0, INT [LUT + 6*SIZEOF_INT]
- mov T1, INT [LUT + 14*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 6
- pinsrw X1, word [BLOCK + T1 * 2], 6
-
- mov T0, INT [LUT + 7*SIZEOF_INT]
- mov T1, INT [LUT + 15*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 7
- pinsrw X1, word [BLOCK + T1 * 2], 7
-%endmacro
-
-%macro LOAD15 0
- pxor N0, N0
- pxor N1, N1
- pxor X1, X1
-
- mov T0, INT [LUT + 0*SIZEOF_INT]
- mov T1, INT [LUT + 8*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 0
- pinsrw X1, word [BLOCK + T1 * 2], 0
-
- mov T0, INT [LUT + 1*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 1
-
- mov T0, INT [LUT + 2*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 2
-
- mov T0, INT [LUT + 3*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 3
-
- mov T0, INT [LUT + 4*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 4
-
- mov T0, INT [LUT + 5*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 5
-
- mov T0, INT [LUT + 6*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 6
-
- mov T0, INT [LUT + 7*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 7
-
- cmp LENEND, 2
- jl %%.ELOAD15
- mov T1, INT [LUT + 9*SIZEOF_INT]
- pinsrw X1, word [BLOCK + T1 * 2], 1
-
- cmp LENEND, 3
- jl %%.ELOAD15
- mov T1, INT [LUT + 10*SIZEOF_INT]
- pinsrw X1, word [BLOCK + T1 * 2], 2
-
- cmp LENEND, 4
- jl %%.ELOAD15
- mov T1, INT [LUT + 11*SIZEOF_INT]
- pinsrw X1, word [BLOCK + T1 * 2], 3
-
- cmp LENEND, 5
- jl %%.ELOAD15
- mov T1, INT [LUT + 12*SIZEOF_INT]
- pinsrw X1, word [BLOCK + T1 * 2], 4
-
- cmp LENEND, 6
- jl %%.ELOAD15
- mov T1, INT [LUT + 13*SIZEOF_INT]
- pinsrw X1, word [BLOCK + T1 * 2], 5
-
- cmp LENEND, 7
- jl %%.ELOAD15
- mov T1, INT [LUT + 14*SIZEOF_INT]
- pinsrw X1, word [BLOCK + T1 * 2], 6
-%%.ELOAD15:
-%endmacro
-
-%macro LOAD8 0
- pxor N0, N0
-
- mov T0, INT [LUT + 0*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 0
-
- mov T0, INT [LUT + 1*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 1
-
- mov T0, INT [LUT + 2*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 2
-
- mov T0, INT [LUT + 3*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 3
-
- mov T0, INT [LUT + 4*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 4
-
- mov T0, INT [LUT + 5*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 5
-
- mov T0, INT [LUT + 6*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 6
-
- mov T0, INT [LUT + 7*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 7
-%endmacro
-
-%macro LOAD7 0
- pxor N0, N0
- pxor X0, X0
-
- mov T1, INT [LUT + 0*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T1 * 2], 0
-
- cmp LENEND, 2
- jl %%.ELOAD7
- mov T1, INT [LUT + 1*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T1 * 2], 1
-
- cmp LENEND, 3
- jl %%.ELOAD7
- mov T1, INT [LUT + 2*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T1 * 2], 2
-
- cmp LENEND, 4
- jl %%.ELOAD7
- mov T1, INT [LUT + 3*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T1 * 2], 3
-
- cmp LENEND, 5
- jl %%.ELOAD7
- mov T1, INT [LUT + 4*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T1 * 2], 4
-
- cmp LENEND, 6
- jl %%.ELOAD7
- mov T1, INT [LUT + 5*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T1 * 2], 5
-
- cmp LENEND, 7
- jl %%.ELOAD7
- mov T1, INT [LUT + 6*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T1 * 2], 6
-%%.ELOAD7:
-%endmacro
-
-%macro REDUCE0 0
- movdqa xmm0, XMMWORD [VALUES + ( 0*2)]
- movdqa xmm1, XMMWORD [VALUES + ( 8*2)]
- movdqa xmm2, XMMWORD [VALUES + (16*2)]
- movdqa xmm3, XMMWORD [VALUES + (24*2)]
- movdqa xmm4, XMMWORD [VALUES + (32*2)]
- movdqa xmm5, XMMWORD [VALUES + (40*2)]
- movdqa xmm6, XMMWORD [VALUES + (48*2)]
-
- pcmpeqw xmm0, ZERO
- pcmpeqw xmm1, ZERO
- pcmpeqw xmm2, ZERO
- pcmpeqw xmm3, ZERO
- pcmpeqw xmm4, ZERO
- pcmpeqw xmm5, ZERO
- pcmpeqw xmm6, ZERO
- pcmpeqw xmm7, XMMWORD [VALUES + (56*2)]
-
- packsswb xmm0, xmm1
- packsswb xmm2, xmm3
- packsswb xmm4, xmm5
- packsswb xmm6, xmm7
-
- pmovmskb eax, xmm0
- pmovmskb ecx, xmm2
- pmovmskb edx, xmm4
- pmovmskb esi, xmm6
-
- shl ecx, 16
- shl esi, 16
-
- or eax, ecx
- or edx, esi
-
- not eax
- not edx
-
- mov edi, ZEROBITS
-
- mov INT [edi], eax
- mov INT [edi+SIZEOF_INT], edx
-%endmacro
-
-;
-; Prepare data for jsimd_encode_mcu_AC_first().
-;
-; GLOBAL(void)
-; jsimd_encode_mcu_AC_first_prepare_sse2(const JCOEF *block,
-; const int *jpeg_natural_order_start,
-; int Sl, int Al, JCOEF *values,
-; size_t *zerobits)
-;
-; eax + 8 = const JCOEF *block
-; eax + 12 = const int *jpeg_natural_order_start
-; eax + 16 = int Sl
-; eax + 20 = int Al
-; eax + 24 = JCOEF *values
-; eax + 28 = size_t *zerobits
-
-%define ZERO xmm7
-%define X0 xmm0
-%define X1 xmm1
-%define N0 xmm2
-%define N1 xmm3
-%define AL xmm4
-%define K eax
-%define LENEND eax
-%define LUT ebx
-%define T0 ecx
-%define T1 edx
-%define BLOCK esi
-%define VALUES edi
-%define LEN ebp
-
-%define ZEROBITS INT [esp + 5 * 4]
-
- align 32
- GLOBAL_FUNCTION(jsimd_encode_mcu_AC_first_prepare_sse2)
-
-EXTN(jsimd_encode_mcu_AC_first_prepare_sse2):
- push ebp
- mov eax, esp ; eax = original ebp
- sub esp, byte 4
- and esp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [esp], eax
- mov ebp, esp ; ebp = aligned ebp
- sub esp, 4
- push ebx
- push ecx
-; push edx ; need not be preserved
- push esi
- push edi
- push ebp
-
- mov BLOCK, INT [eax + 8]
- mov LUT, INT [eax + 12]
- mov VALUES, INT [eax + 24]
- movd AL, INT [eax + 20]
- mov T0, INT [eax + 28]
- mov ZEROBITS, T0
- mov LEN, INT [eax + 16]
- pxor ZERO, ZERO
- mov K, LEN
- and K, -16
- shr K, 4
- jz .ELOOP16
-.BLOOP16:
- LOAD16
- pcmpgtw N0, X0
- pcmpgtw N1, X1
- paddw X0, N0
- paddw X1, N1
- pxor X0, N0
- pxor X1, N1
- psrlw X0, AL
- psrlw X1, AL
- pxor N0, X0
- pxor N1, X1
- movdqa XMMWORD [VALUES + (0) * 2], X0
- movdqa XMMWORD [VALUES + (8) * 2], X1
- movdqa XMMWORD [VALUES + (0 + DCTSIZE2) * 2], N0
- movdqa XMMWORD [VALUES + (8 + DCTSIZE2) * 2], N1
- add VALUES, 16*2
- add LUT, 16*SIZEOF_INT
- dec K
- jnz .BLOOP16
- test LEN, 15
- je .PADDING
-.ELOOP16:
- mov LENEND, LEN
- and LENEND, 7
-
- test LEN, 8
- jz .TRY7
- test LEN, 7
- jz .TRY8
-
- LOAD15
- pcmpgtw N0, X0
- pcmpgtw N1, X1
- paddw X0, N0
- paddw X1, N1
- pxor X0, N0
- pxor X1, N1
- psrlw X0, AL
- psrlw X1, AL
- pxor N0, X0
- pxor N1, X1
- movdqa XMMWORD [VALUES + (0) * 2], X0
- movdqa XMMWORD [VALUES + (8) * 2], X1
- movdqa XMMWORD [VALUES + (0 + DCTSIZE2) * 2], N0
- movdqa XMMWORD [VALUES + (8 + DCTSIZE2) * 2], N1
- add VALUES, 16*2
- jmp .PADDING
-.TRY8:
- LOAD8
- pcmpgtw N0, X0
- paddw X0, N0
- pxor X0, N0
- psrlw X0, AL
- pxor N0, X0
- movdqa XMMWORD [VALUES + (0) * 2], X0
- movdqa XMMWORD [VALUES + (0 + DCTSIZE2) * 2], N0
- add VALUES, 8*2
- jmp .PADDING
-.TRY7:
- LOAD7
- pcmpgtw N0, X0
- paddw X0, N0
- pxor X0, N0
- psrlw X0, AL
- pxor N0, X0
- movdqa XMMWORD [VALUES + (0) * 2], X0
- movdqa XMMWORD [VALUES + (0 + DCTSIZE2) * 2], N0
- add VALUES, 8*2
-.PADDING:
- mov K, LEN
- add K, 7
- and K, -8
- shr K, 3
- sub K, DCTSIZE2/8
- jz .EPADDING
- align 16
-.ZEROLOOP:
- movdqa XMMWORD [VALUES + 0], ZERO
- add VALUES, 8*2
- inc K
- jnz .ZEROLOOP
-.EPADDING:
- sub VALUES, DCTSIZE2*2
-
- REDUCE0
-
- pop ebp
- pop edi
- pop esi
-; pop edx ; need not be preserved
- pop ecx
- pop ebx
- mov esp, ebp ; esp <- aligned ebp
- pop esp ; esp <- original ebp
- pop ebp
- ret
-
-%undef ZERO
-%undef X0
-%undef X1
-%undef N0
-%undef N1
-%undef AL
-%undef K
-%undef LUT
-%undef T0
-%undef T1
-%undef BLOCK
-%undef VALUES
-%undef LEN
-
-;
-; Prepare data for jsimd_encode_mcu_AC_refine().
-;
-; GLOBAL(int)
-; jsimd_encode_mcu_AC_refine_prepare_sse2(const JCOEF *block,
-; const int *jpeg_natural_order_start,
-; int Sl, int Al, JCOEF *absvalues,
-; size_t *bits)
-;
-; eax + 8 = const JCOEF *block
-; eax + 12 = const int *jpeg_natural_order_start
-; eax + 16 = int Sl
-; eax + 20 = int Al
-; eax + 24 = JCOEF *values
-; eax + 28 = size_t *bits
-
-%define ZERO xmm7
-%define ONE xmm5
-%define X0 xmm0
-%define X1 xmm1
-%define N0 xmm2
-%define N1 xmm3
-%define AL xmm4
-%define K eax
-%define LENEND eax
-%define LUT ebx
-%define T0 ecx
-%define T0w cx
-%define T1 edx
-%define BLOCK esi
-%define VALUES edi
-%define KK ebp
-
-%define ZEROBITS INT [esp + 5 * 4]
-%define EOB INT [esp + 5 * 4 + 4]
-%define LEN INT [esp + 5 * 4 + 8]
-
- align 32
- GLOBAL_FUNCTION(jsimd_encode_mcu_AC_refine_prepare_sse2)
-
-EXTN(jsimd_encode_mcu_AC_refine_prepare_sse2):
- push ebp
- mov eax, esp ; eax = original ebp
- sub esp, byte 4
- and esp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [esp], eax
- mov ebp, esp ; ebp = aligned ebp
- sub esp, 16
- push ebx
- push ecx
-; push edx ; need not be preserved
- push esi
- push edi
- push ebp
-
- pcmpeqw ONE, ONE
- psrlw ONE, 15
- mov BLOCK, INT [eax + 8]
- mov LUT, INT [eax + 12]
- mov VALUES, INT [eax + 24]
- movd AL, INT [eax + 20]
- mov T0, INT [eax + 28]
- mov K, INT [eax + 16]
- mov INT [T0 + 2 * SIZEOF_INT], -1
- mov INT [T0 + 3 * SIZEOF_INT], -1
- mov ZEROBITS, T0
- mov LEN, K
- pxor ZERO, ZERO
- and K, -16
- mov EOB, 0
- xor KK, KK
- shr K, 4
- jz .ELOOPR16
-.BLOOPR16:
- LOAD16
- pcmpgtw N0, X0
- pcmpgtw N1, X1
- paddw X0, N0
- paddw X1, N1
- pxor X0, N0
- pxor X1, N1
- psrlw X0, AL
- psrlw X1, AL
- movdqa XMMWORD [VALUES + (0) * 2], X0
- movdqa XMMWORD [VALUES + (8) * 2], X1
- pcmpeqw X0, ONE
- pcmpeqw X1, ONE
- packsswb N0, N1
- packsswb X0, X1
- pmovmskb T0, N0 ; lsignbits.val16u[k>>4] = _mm_movemask_epi8(neg);
- mov T1, ZEROBITS
- not T0
- mov word [T1 + 2 * SIZEOF_INT + KK], T0w
- pmovmskb T1, X0 ; idx = _mm_movemask_epi8(x1);
- bsr T1, T1 ; idx = 16 - (__builtin_clz(idx)>>1);
- jz .CONTINUER16 ; if (idx) {
- lea T1, [T1+KK*8]
- mov EOB, T1 ; EOB = k + idx;
-.CONTINUER16:
- add VALUES, 16*2
- add LUT, 16*SIZEOF_INT
- add KK, 2
- dec K
- jnz .BLOOPR16
- test LEN, 15
- je .PADDINGR
-.ELOOPR16:
- mov LENEND, LEN
-
- test LENEND, 8
- jz .TRYR7
- test LENEND, 7
- jz .TRYR8
-
- and LENEND, 7
- LOAD15
- pcmpgtw N0, X0
- pcmpgtw N1, X1
- paddw X0, N0
- paddw X1, N1
- pxor X0, N0
- pxor X1, N1
- psrlw X0, AL
- psrlw X1, AL
- movdqa XMMWORD [VALUES + (0) * 2], X0
- movdqa XMMWORD [VALUES + (8) * 2], X1
- pcmpeqw X0, ONE
- pcmpeqw X1, ONE
- packsswb N0, N1
- packsswb X0, X1
- pmovmskb T0, N0 ; lsignbits.val16u[k>>4] = _mm_movemask_epi8(neg);
- mov T1, ZEROBITS
- not T0
- mov word [T1 + 2 * SIZEOF_INT + KK], T0w
- pmovmskb T1, X0 ; idx = _mm_movemask_epi8(x1);
- bsr T1, T1 ; idx = 16 - (__builtin_clz(idx)>>1);
- jz .CONTINUER15 ; if (idx) {
- lea T1, [T1+KK*8]
- mov EOB, T1 ; EOB = k + idx;
-.CONTINUER15:
- add VALUES, 16*2
- jmp .PADDINGR
-.TRYR8:
- LOAD8
-
- pcmpgtw N0, X0
- paddw X0, N0
- pxor X0, N0
- psrlw X0, AL
- movdqa XMMWORD [VALUES + (0) * 2], X0
- pcmpeqw X0, ONE
- packsswb N0, ZERO
- packsswb X0, ZERO
- pmovmskb T0, N0 ; lsignbits.val16u[k>>4] = _mm_movemask_epi8(neg);
- mov T1, ZEROBITS
- not T0
- mov word [T1 + 2 * SIZEOF_INT + KK], T0w
- pmovmskb T1, X0 ; idx = _mm_movemask_epi8(x1);
- bsr T1, T1 ; idx = 16 - (__builtin_clz(idx)>>1);
- jz .CONTINUER8 ; if (idx) {
- lea T1, [T1+KK*8]
- mov EOB, T1 ; EOB = k + idx;
-.CONTINUER8:
- add VALUES, 8*2
- jmp .PADDINGR
-.TRYR7:
- and LENEND, 7
- LOAD7
-
- pcmpgtw N0, X0
- paddw X0, N0
- pxor X0, N0
- psrlw X0, AL
- movdqa XMMWORD [VALUES + (0) * 2], X0
- pcmpeqw X0, ONE
- packsswb N0, ZERO
- packsswb X0, ZERO
- pmovmskb T0, N0 ; lsignbits.val16u[k>>4] = _mm_movemask_epi8(neg);
- mov T1, ZEROBITS
- not T0
- mov word [T1 + 2 * SIZEOF_INT + KK], T0w
- pmovmskb T1, X0 ; idx = _mm_movemask_epi8(x1);
- bsr T1, T1 ; idx = 16 - (__builtin_clz(idx)>>1);
- jz .CONTINUER7 ; if (idx) {
- lea T1, [T1+KK*8]
- mov EOB, T1 ; EOB = k + idx;
-.CONTINUER7:
- add VALUES, 8*2
-.PADDINGR:
- mov K, LEN
- add K, 7
- and K, -8
- shr K, 3
- sub K, DCTSIZE2/8
- jz .EPADDINGR
- align 16
-.ZEROLOOPR:
- movdqa XMMWORD [VALUES + 0], ZERO
- add VALUES, 8*2
- inc K
- jnz .ZEROLOOPR
-.EPADDINGR:
- sub VALUES, DCTSIZE2*2
-
- REDUCE0
-
- mov eax, EOB
-
- pop ebp
- pop edi
- pop esi
-; pop edx ; need not be preserved
- pop ecx
- pop ebx
- mov esp, ebp ; esp <- aligned ebp
- pop esp ; esp <- original ebp
- pop ebp
- ret
-
-%undef ZERO
-%undef ONE
-%undef X0
-%undef X1
-%undef N0
-%undef N1
-%undef AL
-%undef K
-%undef KK
-%undef EOB
-%undef SIGN
-%undef LUT
-%undef T0
-%undef T1
-%undef BLOCK
-%undef VALUES
-%undef LEN
-%undef LENEND
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jcsample-avx2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jcsample-avx2.asm
deleted file mode 100644
index 0a20802dd8..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jcsample-avx2.asm
+++ /dev/null
@@ -1,388 +0,0 @@
-;
-; jcsample.asm - downsampling (AVX2)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2015, Intel Corporation.
-; Copyright (C) 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jsimdext.inc"
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-;
-; Downsample pixel values of a single component.
-; This version handles the common case of 2:1 horizontal and 1:1 vertical,
-; without smoothing.
-;
-; GLOBAL(void)
-; jsimd_h2v1_downsample_avx2(JDIMENSION image_width, int max_v_samp_factor,
-; JDIMENSION v_samp_factor,
-; JDIMENSION width_in_blocks, JSAMPARRAY input_data,
-; JSAMPARRAY output_data);
-;
-
-%define img_width(b) (b) + 8 ; JDIMENSION image_width
-%define max_v_samp(b) (b) + 12 ; int max_v_samp_factor
-%define v_samp(b) (b) + 16 ; JDIMENSION v_samp_factor
-%define width_blks(b) (b) + 20 ; JDIMENSION width_in_blocks
-%define input_data(b) (b) + 24 ; JSAMPARRAY input_data
-%define output_data(b) (b) + 28 ; JSAMPARRAY output_data
-
- align 32
- GLOBAL_FUNCTION(jsimd_h2v1_downsample_avx2)
-
-EXTN(jsimd_h2v1_downsample_avx2):
- push ebp
- mov ebp, esp
-; push ebx ; unused
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- mov ecx, JDIMENSION [width_blks(ebp)]
- shl ecx, 3 ; imul ecx,DCTSIZE (ecx = output_cols)
- jz near .return
-
- mov edx, JDIMENSION [img_width(ebp)]
-
- ; -- expand_right_edge
-
- push ecx
- shl ecx, 1 ; output_cols * 2
- sub ecx, edx
- jle short .expand_end
-
- mov eax, INT [max_v_samp(ebp)]
- test eax, eax
- jle short .expand_end
-
- cld
- mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
- alignx 16, 7
-.expandloop:
- push eax
- push ecx
-
- mov edi, JSAMPROW [esi]
- add edi, edx
- mov al, JSAMPLE [edi-1]
-
- rep stosb
-
- pop ecx
- pop eax
-
- add esi, byte SIZEOF_JSAMPROW
- dec eax
- jg short .expandloop
-
-.expand_end:
- pop ecx ; output_cols
-
- ; -- h2v1_downsample
-
- mov eax, JDIMENSION [v_samp(ebp)] ; rowctr
- test eax, eax
- jle near .return
-
- mov edx, 0x00010000 ; bias pattern
- vmovd xmm7, edx
- vpshufd xmm7, xmm7, 0x00 ; xmm7={0, 1, 0, 1, 0, 1, 0, 1}
- vperm2i128 ymm7, ymm7, ymm7, 0 ; ymm7={xmm7, xmm7}
- vpcmpeqw ymm6, ymm6, ymm6
- vpsrlw ymm6, ymm6, BYTE_BIT ; ymm6={0xFF 0x00 0xFF 0x00 ..}
-
- mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
- mov edi, JSAMPARRAY [output_data(ebp)] ; output_data
- alignx 16, 7
-.rowloop:
- push ecx
- push edi
- push esi
-
- mov esi, JSAMPROW [esi] ; inptr
- mov edi, JSAMPROW [edi] ; outptr
-
- cmp ecx, byte SIZEOF_YMMWORD
- jae short .columnloop
- alignx 16, 7
-
-.columnloop_r24:
- ; ecx can possibly be 8, 16, 24
- cmp ecx, 24
- jne .columnloop_r16
- vmovdqu ymm0, YMMWORD [esi+0*SIZEOF_YMMWORD]
- vmovdqu xmm1, XMMWORD [esi+1*SIZEOF_YMMWORD]
- mov ecx, SIZEOF_YMMWORD
- jmp short .downsample
-
-.columnloop_r16:
- cmp ecx, 16
- jne .columnloop_r8
- vmovdqu ymm0, YMMWORD [esi+0*SIZEOF_YMMWORD]
- vpxor ymm1, ymm1, ymm1
- mov ecx, SIZEOF_YMMWORD
- jmp short .downsample
-
-.columnloop_r8:
- vmovdqu xmm0, XMMWORD[esi+0*SIZEOF_YMMWORD]
- vpxor ymm1, ymm1, ymm1
- mov ecx, SIZEOF_YMMWORD
- jmp short .downsample
- alignx 16, 7
-
-.columnloop:
- vmovdqu ymm0, YMMWORD [esi+0*SIZEOF_YMMWORD]
- vmovdqu ymm1, YMMWORD [esi+1*SIZEOF_YMMWORD]
-
-.downsample:
- vpsrlw ymm2, ymm0, BYTE_BIT
- vpand ymm0, ymm0, ymm6
- vpsrlw ymm3, ymm1, BYTE_BIT
- vpand ymm1, ymm1, ymm6
-
- vpaddw ymm0, ymm0, ymm2
- vpaddw ymm1, ymm1, ymm3
- vpaddw ymm0, ymm0, ymm7
- vpaddw ymm1, ymm1, ymm7
- vpsrlw ymm0, ymm0, 1
- vpsrlw ymm1, ymm1, 1
-
- vpackuswb ymm0, ymm0, ymm1
- vpermq ymm0, ymm0, 0xd8
-
- vmovdqu YMMWORD [edi+0*SIZEOF_YMMWORD], ymm0
-
- sub ecx, byte SIZEOF_YMMWORD ; outcol
- add esi, byte 2*SIZEOF_YMMWORD ; inptr
- add edi, byte 1*SIZEOF_YMMWORD ; outptr
- cmp ecx, byte SIZEOF_YMMWORD
- jae short .columnloop
- test ecx, ecx
- jnz near .columnloop_r24
-
- pop esi
- pop edi
- pop ecx
-
- add esi, byte SIZEOF_JSAMPROW ; input_data
- add edi, byte SIZEOF_JSAMPROW ; output_data
- dec eax ; rowctr
- jg near .rowloop
-
-.return:
- vzeroupper
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
-; pop ebx ; unused
- pop ebp
- ret
-
-; --------------------------------------------------------------------------
-;
-; Downsample pixel values of a single component.
-; This version handles the standard case of 2:1 horizontal and 2:1 vertical,
-; without smoothing.
-;
-; GLOBAL(void)
-; jsimd_h2v2_downsample_avx2(JDIMENSION image_width, int max_v_samp_factor,
-; JDIMENSION v_samp_factor,
-; JDIMENSION width_in_blocks, JSAMPARRAY input_data,
-; JSAMPARRAY output_data);
-;
-
-%define img_width(b) (b) + 8 ; JDIMENSION image_width
-%define max_v_samp(b) (b) + 12 ; int max_v_samp_factor
-%define v_samp(b) (b) + 16 ; JDIMENSION v_samp_factor
-%define width_blks(b) (b) + 20 ; JDIMENSION width_in_blocks
-%define input_data(b) (b) + 24 ; JSAMPARRAY input_data
-%define output_data(b) (b) + 28 ; JSAMPARRAY output_data
-
- align 32
- GLOBAL_FUNCTION(jsimd_h2v2_downsample_avx2)
-
-EXTN(jsimd_h2v2_downsample_avx2):
- push ebp
- mov ebp, esp
-; push ebx ; unused
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- mov ecx, JDIMENSION [width_blks(ebp)]
- shl ecx, 3 ; imul ecx,DCTSIZE (ecx = output_cols)
- jz near .return
-
- mov edx, JDIMENSION [img_width(ebp)]
-
- ; -- expand_right_edge
-
- push ecx
- shl ecx, 1 ; output_cols * 2
- sub ecx, edx
- jle short .expand_end
-
- mov eax, INT [max_v_samp(ebp)]
- test eax, eax
- jle short .expand_end
-
- cld
- mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
- alignx 16, 7
-.expandloop:
- push eax
- push ecx
-
- mov edi, JSAMPROW [esi]
- add edi, edx
- mov al, JSAMPLE [edi-1]
-
- rep stosb
-
- pop ecx
- pop eax
-
- add esi, byte SIZEOF_JSAMPROW
- dec eax
- jg short .expandloop
-
-.expand_end:
- pop ecx ; output_cols
-
- ; -- h2v2_downsample
-
- mov eax, JDIMENSION [v_samp(ebp)] ; rowctr
- test eax, eax
- jle near .return
-
- mov edx, 0x00020001 ; bias pattern
- vmovd xmm7, edx
- vpcmpeqw ymm6, ymm6, ymm6
- vpshufd xmm7, xmm7, 0x00 ; ymm7={1, 2, 1, 2, 1, 2, 1, 2}
- vperm2i128 ymm7, ymm7, ymm7, 0
- vpsrlw ymm6, ymm6, BYTE_BIT ; ymm6={0xFF 0x00 0xFF 0x00 ..}
-
- mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
- mov edi, JSAMPARRAY [output_data(ebp)] ; output_data
- alignx 16, 7
-.rowloop:
- push ecx
- push edi
- push esi
-
- mov edx, JSAMPROW [esi+0*SIZEOF_JSAMPROW] ; inptr0
- mov esi, JSAMPROW [esi+1*SIZEOF_JSAMPROW] ; inptr1
- mov edi, JSAMPROW [edi] ; outptr
-
- cmp ecx, byte SIZEOF_YMMWORD
- jae short .columnloop
- alignx 16, 7
-
-.columnloop_r24:
- cmp ecx, 24
- jne .columnloop_r16
- vmovdqu ymm0, YMMWORD [edx+0*SIZEOF_YMMWORD]
- vmovdqu ymm1, YMMWORD [esi+0*SIZEOF_YMMWORD]
- vmovdqu xmm2, XMMWORD [edx+1*SIZEOF_YMMWORD]
- vmovdqu xmm3, XMMWORD [esi+1*SIZEOF_YMMWORD]
- mov ecx, SIZEOF_YMMWORD
- jmp short .downsample
-
-.columnloop_r16:
- cmp ecx, 16
- jne .columnloop_r8
- vmovdqu ymm0, YMMWORD [edx+0*SIZEOF_YMMWORD]
- vmovdqu ymm1, YMMWORD [esi+0*SIZEOF_YMMWORD]
- vpxor ymm2, ymm2, ymm2
- vpxor ymm3, ymm3, ymm3
- mov ecx, SIZEOF_YMMWORD
- jmp short .downsample
-
-.columnloop_r8:
- vmovdqu xmm0, XMMWORD [edx+0*SIZEOF_XMMWORD]
- vmovdqu xmm1, XMMWORD [esi+0*SIZEOF_XMMWORD]
- vpxor ymm2, ymm2, ymm2
- vpxor ymm3, ymm3, ymm3
- mov ecx, SIZEOF_YMMWORD
- jmp short .downsample
- alignx 16, 7
-
-.columnloop:
- vmovdqu ymm0, YMMWORD [edx+0*SIZEOF_YMMWORD]
- vmovdqu ymm1, YMMWORD [esi+0*SIZEOF_YMMWORD]
- vmovdqu ymm2, YMMWORD [edx+1*SIZEOF_YMMWORD]
- vmovdqu ymm3, YMMWORD [esi+1*SIZEOF_YMMWORD]
-
-.downsample:
- vpand ymm4, ymm0, ymm6
- vpsrlw ymm0, ymm0, BYTE_BIT
- vpand ymm5, ymm1, ymm6
- vpsrlw ymm1, ymm1, BYTE_BIT
- vpaddw ymm0, ymm0, ymm4
- vpaddw ymm1, ymm1, ymm5
-
- vpand ymm4, ymm2, ymm6
- vpsrlw ymm2, ymm2, BYTE_BIT
- vpand ymm5, ymm3, ymm6
- vpsrlw ymm3, ymm3, BYTE_BIT
- vpaddw ymm2, ymm2, ymm4
- vpaddw ymm3, ymm3, ymm5
-
- vpaddw ymm0, ymm0, ymm1
- vpaddw ymm2, ymm2, ymm3
- vpaddw ymm0, ymm0, ymm7
- vpaddw ymm2, ymm2, ymm7
- vpsrlw ymm0, ymm0, 2
- vpsrlw ymm2, ymm2, 2
-
- vpackuswb ymm0, ymm0, ymm2
- vpermq ymm0, ymm0, 0xd8
-
- vmovdqu YMMWORD [edi+0*SIZEOF_YMMWORD], ymm0
-
- sub ecx, byte SIZEOF_YMMWORD ; outcol
- add edx, byte 2*SIZEOF_YMMWORD ; inptr0
- add esi, byte 2*SIZEOF_YMMWORD ; inptr1
- add edi, byte 1*SIZEOF_YMMWORD ; outptr
- cmp ecx, byte SIZEOF_YMMWORD
- jae near .columnloop
- test ecx, ecx
- jnz near .columnloop_r24
-
- pop esi
- pop edi
- pop ecx
-
- add esi, byte 2*SIZEOF_JSAMPROW ; input_data
- add edi, byte 1*SIZEOF_JSAMPROW ; output_data
- dec eax ; rowctr
- jg near .rowloop
-
-.return:
- vzeroupper
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
-; pop ebx ; unused
- pop ebp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jcsample-mmx.asm b/contrib/libs/libjpeg-turbo/simd/i386/jcsample-mmx.asm
deleted file mode 100644
index 2c223eebe8..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jcsample-mmx.asm
+++ /dev/null
@@ -1,324 +0,0 @@
-;
-; jcsample.asm - downsampling (MMX)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jsimdext.inc"
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-;
-; Downsample pixel values of a single component.
-; This version handles the common case of 2:1 horizontal and 1:1 vertical,
-; without smoothing.
-;
-; GLOBAL(void)
-; jsimd_h2v1_downsample_mmx(JDIMENSION image_width, int max_v_samp_factor,
-; JDIMENSION v_samp_factor,
-; JDIMENSION width_in_blocks, JSAMPARRAY input_data,
-; JSAMPARRAY output_data);
-;
-
-%define img_width(b) (b) + 8 ; JDIMENSION image_width
-%define max_v_samp(b) (b) + 12 ; int max_v_samp_factor
-%define v_samp(b) (b) + 16 ; JDIMENSION v_samp_factor
-%define width_blks(b) (b) + 20 ; JDIMENSION width_in_blocks
-%define input_data(b) (b) + 24 ; JSAMPARRAY input_data
-%define output_data(b) (b) + 28 ; JSAMPARRAY output_data
-
- align 32
- GLOBAL_FUNCTION(jsimd_h2v1_downsample_mmx)
-
-EXTN(jsimd_h2v1_downsample_mmx):
- push ebp
- mov ebp, esp
-; push ebx ; unused
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- mov ecx, JDIMENSION [width_blks(ebp)]
- shl ecx, 3 ; imul ecx,DCTSIZE (ecx = output_cols)
- jz near .return
-
- mov edx, JDIMENSION [img_width(ebp)]
-
- ; -- expand_right_edge
-
- push ecx
- shl ecx, 1 ; output_cols * 2
- sub ecx, edx
- jle short .expand_end
-
- mov eax, INT [max_v_samp(ebp)]
- test eax, eax
- jle short .expand_end
-
- cld
- mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
- alignx 16, 7
-.expandloop:
- push eax
- push ecx
-
- mov edi, JSAMPROW [esi]
- add edi, edx
- mov al, JSAMPLE [edi-1]
-
- rep stosb
-
- pop ecx
- pop eax
-
- add esi, byte SIZEOF_JSAMPROW
- dec eax
- jg short .expandloop
-
-.expand_end:
- pop ecx ; output_cols
-
- ; -- h2v1_downsample
-
- mov eax, JDIMENSION [v_samp(ebp)] ; rowctr
- test eax, eax
- jle near .return
-
- mov edx, 0x00010000 ; bias pattern
- movd mm7, edx
- pcmpeqw mm6, mm6
- punpckldq mm7, mm7 ; mm7={0, 1, 0, 1}
- psrlw mm6, BYTE_BIT ; mm6={0xFF 0x00 0xFF 0x00 ..}
-
- mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
- mov edi, JSAMPARRAY [output_data(ebp)] ; output_data
- alignx 16, 7
-.rowloop:
- push ecx
- push edi
- push esi
-
- mov esi, JSAMPROW [esi] ; inptr
- mov edi, JSAMPROW [edi] ; outptr
- alignx 16, 7
-.columnloop:
-
- movq mm0, MMWORD [esi+0*SIZEOF_MMWORD]
- movq mm1, MMWORD [esi+1*SIZEOF_MMWORD]
- movq mm2, mm0
- movq mm3, mm1
-
- pand mm0, mm6
- psrlw mm2, BYTE_BIT
- pand mm1, mm6
- psrlw mm3, BYTE_BIT
-
- paddw mm0, mm2
- paddw mm1, mm3
- paddw mm0, mm7
- paddw mm1, mm7
- psrlw mm0, 1
- psrlw mm1, 1
-
- packuswb mm0, mm1
-
- movq MMWORD [edi+0*SIZEOF_MMWORD], mm0
-
- add esi, byte 2*SIZEOF_MMWORD ; inptr
- add edi, byte 1*SIZEOF_MMWORD ; outptr
- sub ecx, byte SIZEOF_MMWORD ; outcol
- jnz short .columnloop
-
- pop esi
- pop edi
- pop ecx
-
- add esi, byte SIZEOF_JSAMPROW ; input_data
- add edi, byte SIZEOF_JSAMPROW ; output_data
- dec eax ; rowctr
- jg short .rowloop
-
- emms ; empty MMX state
-
-.return:
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
-; pop ebx ; unused
- pop ebp
- ret
-
-; --------------------------------------------------------------------------
-;
-; Downsample pixel values of a single component.
-; This version handles the standard case of 2:1 horizontal and 2:1 vertical,
-; without smoothing.
-;
-; GLOBAL(void)
-; jsimd_h2v2_downsample_mmx(JDIMENSION image_width, int max_v_samp_factor,
-; JDIMENSION v_samp_factor,
-; JDIMENSION width_in_blocks, JSAMPARRAY input_data,
-; JSAMPARRAY output_data);
-;
-
-%define img_width(b) (b) + 8 ; JDIMENSION image_width
-%define max_v_samp(b) (b) + 12 ; int max_v_samp_factor
-%define v_samp(b) (b) + 16 ; JDIMENSION v_samp_factor
-%define width_blks(b) (b) + 20 ; JDIMENSION width_in_blocks
-%define input_data(b) (b) + 24 ; JSAMPARRAY input_data
-%define output_data(b) (b) + 28 ; JSAMPARRAY output_data
-
- align 32
- GLOBAL_FUNCTION(jsimd_h2v2_downsample_mmx)
-
-EXTN(jsimd_h2v2_downsample_mmx):
- push ebp
- mov ebp, esp
-; push ebx ; unused
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- mov ecx, JDIMENSION [width_blks(ebp)]
- shl ecx, 3 ; imul ecx,DCTSIZE (ecx = output_cols)
- jz near .return
-
- mov edx, JDIMENSION [img_width(ebp)]
-
- ; -- expand_right_edge
-
- push ecx
- shl ecx, 1 ; output_cols * 2
- sub ecx, edx
- jle short .expand_end
-
- mov eax, INT [max_v_samp(ebp)]
- test eax, eax
- jle short .expand_end
-
- cld
- mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
- alignx 16, 7
-.expandloop:
- push eax
- push ecx
-
- mov edi, JSAMPROW [esi]
- add edi, edx
- mov al, JSAMPLE [edi-1]
-
- rep stosb
-
- pop ecx
- pop eax
-
- add esi, byte SIZEOF_JSAMPROW
- dec eax
- jg short .expandloop
-
-.expand_end:
- pop ecx ; output_cols
-
- ; -- h2v2_downsample
-
- mov eax, JDIMENSION [v_samp(ebp)] ; rowctr
- test eax, eax
- jle near .return
-
- mov edx, 0x00020001 ; bias pattern
- movd mm7, edx
- pcmpeqw mm6, mm6
- punpckldq mm7, mm7 ; mm7={1, 2, 1, 2}
- psrlw mm6, BYTE_BIT ; mm6={0xFF 0x00 0xFF 0x00 ..}
-
- mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
- mov edi, JSAMPARRAY [output_data(ebp)] ; output_data
- alignx 16, 7
-.rowloop:
- push ecx
- push edi
- push esi
-
- mov edx, JSAMPROW [esi+0*SIZEOF_JSAMPROW] ; inptr0
- mov esi, JSAMPROW [esi+1*SIZEOF_JSAMPROW] ; inptr1
- mov edi, JSAMPROW [edi] ; outptr
- alignx 16, 7
-.columnloop:
-
- movq mm0, MMWORD [edx+0*SIZEOF_MMWORD]
- movq mm1, MMWORD [esi+0*SIZEOF_MMWORD]
- movq mm2, MMWORD [edx+1*SIZEOF_MMWORD]
- movq mm3, MMWORD [esi+1*SIZEOF_MMWORD]
-
- movq mm4, mm0
- movq mm5, mm1
- pand mm0, mm6
- psrlw mm4, BYTE_BIT
- pand mm1, mm6
- psrlw mm5, BYTE_BIT
- paddw mm0, mm4
- paddw mm1, mm5
-
- movq mm4, mm2
- movq mm5, mm3
- pand mm2, mm6
- psrlw mm4, BYTE_BIT
- pand mm3, mm6
- psrlw mm5, BYTE_BIT
- paddw mm2, mm4
- paddw mm3, mm5
-
- paddw mm0, mm1
- paddw mm2, mm3
- paddw mm0, mm7
- paddw mm2, mm7
- psrlw mm0, 2
- psrlw mm2, 2
-
- packuswb mm0, mm2
-
- movq MMWORD [edi+0*SIZEOF_MMWORD], mm0
-
- add edx, byte 2*SIZEOF_MMWORD ; inptr0
- add esi, byte 2*SIZEOF_MMWORD ; inptr1
- add edi, byte 1*SIZEOF_MMWORD ; outptr
- sub ecx, byte SIZEOF_MMWORD ; outcol
- jnz near .columnloop
-
- pop esi
- pop edi
- pop ecx
-
- add esi, byte 2*SIZEOF_JSAMPROW ; input_data
- add edi, byte 1*SIZEOF_JSAMPROW ; output_data
- dec eax ; rowctr
- jg near .rowloop
-
- emms ; empty MMX state
-
-.return:
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
-; pop ebx ; unused
- pop ebp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jcsample-sse2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jcsample-sse2.asm
deleted file mode 100644
index 4fea60d2e2..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jcsample-sse2.asm
+++ /dev/null
@@ -1,351 +0,0 @@
-;
-; jcsample.asm - downsampling (SSE2)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jsimdext.inc"
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-;
-; Downsample pixel values of a single component.
-; This version handles the common case of 2:1 horizontal and 1:1 vertical,
-; without smoothing.
-;
-; GLOBAL(void)
-; jsimd_h2v1_downsample_sse2(JDIMENSION image_width, int max_v_samp_factor,
-; JDIMENSION v_samp_factor,
-; JDIMENSION width_in_blocks, JSAMPARRAY input_data,
-; JSAMPARRAY output_data);
-;
-
-%define img_width(b) (b) + 8 ; JDIMENSION image_width
-%define max_v_samp(b) (b) + 12 ; int max_v_samp_factor
-%define v_samp(b) (b) + 16 ; JDIMENSION v_samp_factor
-%define width_blks(b) (b) + 20 ; JDIMENSION width_in_blocks
-%define input_data(b) (b) + 24 ; JSAMPARRAY input_data
-%define output_data(b) (b) + 28 ; JSAMPARRAY output_data
-
- align 32
- GLOBAL_FUNCTION(jsimd_h2v1_downsample_sse2)
-
-EXTN(jsimd_h2v1_downsample_sse2):
- push ebp
- mov ebp, esp
-; push ebx ; unused
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- mov ecx, JDIMENSION [width_blks(ebp)]
- shl ecx, 3 ; imul ecx,DCTSIZE (ecx = output_cols)
- jz near .return
-
- mov edx, JDIMENSION [img_width(ebp)]
-
- ; -- expand_right_edge
-
- push ecx
- shl ecx, 1 ; output_cols * 2
- sub ecx, edx
- jle short .expand_end
-
- mov eax, INT [max_v_samp(ebp)]
- test eax, eax
- jle short .expand_end
-
- cld
- mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
- alignx 16, 7
-.expandloop:
- push eax
- push ecx
-
- mov edi, JSAMPROW [esi]
- add edi, edx
- mov al, JSAMPLE [edi-1]
-
- rep stosb
-
- pop ecx
- pop eax
-
- add esi, byte SIZEOF_JSAMPROW
- dec eax
- jg short .expandloop
-
-.expand_end:
- pop ecx ; output_cols
-
- ; -- h2v1_downsample
-
- mov eax, JDIMENSION [v_samp(ebp)] ; rowctr
- test eax, eax
- jle near .return
-
- mov edx, 0x00010000 ; bias pattern
- movd xmm7, edx
- pcmpeqw xmm6, xmm6
- pshufd xmm7, xmm7, 0x00 ; xmm7={0, 1, 0, 1, 0, 1, 0, 1}
- psrlw xmm6, BYTE_BIT ; xmm6={0xFF 0x00 0xFF 0x00 ..}
-
- mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
- mov edi, JSAMPARRAY [output_data(ebp)] ; output_data
- alignx 16, 7
-.rowloop:
- push ecx
- push edi
- push esi
-
- mov esi, JSAMPROW [esi] ; inptr
- mov edi, JSAMPROW [edi] ; outptr
-
- cmp ecx, byte SIZEOF_XMMWORD
- jae short .columnloop
- alignx 16, 7
-
-.columnloop_r8:
- movdqa xmm0, XMMWORD [esi+0*SIZEOF_XMMWORD]
- pxor xmm1, xmm1
- mov ecx, SIZEOF_XMMWORD
- jmp short .downsample
- alignx 16, 7
-
-.columnloop:
- movdqa xmm0, XMMWORD [esi+0*SIZEOF_XMMWORD]
- movdqa xmm1, XMMWORD [esi+1*SIZEOF_XMMWORD]
-
-.downsample:
- movdqa xmm2, xmm0
- movdqa xmm3, xmm1
-
- pand xmm0, xmm6
- psrlw xmm2, BYTE_BIT
- pand xmm1, xmm6
- psrlw xmm3, BYTE_BIT
-
- paddw xmm0, xmm2
- paddw xmm1, xmm3
- paddw xmm0, xmm7
- paddw xmm1, xmm7
- psrlw xmm0, 1
- psrlw xmm1, 1
-
- packuswb xmm0, xmm1
-
- movdqa XMMWORD [edi+0*SIZEOF_XMMWORD], xmm0
-
- sub ecx, byte SIZEOF_XMMWORD ; outcol
- add esi, byte 2*SIZEOF_XMMWORD ; inptr
- add edi, byte 1*SIZEOF_XMMWORD ; outptr
- cmp ecx, byte SIZEOF_XMMWORD
- jae short .columnloop
- test ecx, ecx
- jnz short .columnloop_r8
-
- pop esi
- pop edi
- pop ecx
-
- add esi, byte SIZEOF_JSAMPROW ; input_data
- add edi, byte SIZEOF_JSAMPROW ; output_data
- dec eax ; rowctr
- jg near .rowloop
-
-.return:
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
-; pop ebx ; unused
- pop ebp
- ret
-
-; --------------------------------------------------------------------------
-;
-; Downsample pixel values of a single component.
-; This version handles the standard case of 2:1 horizontal and 2:1 vertical,
-; without smoothing.
-;
-; GLOBAL(void)
-; jsimd_h2v2_downsample_sse2(JDIMENSION image_width, int max_v_samp_factor,
-; JDIMENSION v_samp_factor,
-; JDIMENSION width_in_blocks, JSAMPARRAY input_data,
-; JSAMPARRAY output_data);
-;
-
-%define img_width(b) (b) + 8 ; JDIMENSION image_width
-%define max_v_samp(b) (b) + 12 ; int max_v_samp_factor
-%define v_samp(b) (b) + 16 ; JDIMENSION v_samp_factor
-%define width_blks(b) (b) + 20 ; JDIMENSION width_in_blocks
-%define input_data(b) (b) + 24 ; JSAMPARRAY input_data
-%define output_data(b) (b) + 28 ; JSAMPARRAY output_data
-
- align 32
- GLOBAL_FUNCTION(jsimd_h2v2_downsample_sse2)
-
-EXTN(jsimd_h2v2_downsample_sse2):
- push ebp
- mov ebp, esp
-; push ebx ; unused
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- mov ecx, JDIMENSION [width_blks(ebp)]
- shl ecx, 3 ; imul ecx,DCTSIZE (ecx = output_cols)
- jz near .return
-
- mov edx, JDIMENSION [img_width(ebp)]
-
- ; -- expand_right_edge
-
- push ecx
- shl ecx, 1 ; output_cols * 2
- sub ecx, edx
- jle short .expand_end
-
- mov eax, INT [max_v_samp(ebp)]
- test eax, eax
- jle short .expand_end
-
- cld
- mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
- alignx 16, 7
-.expandloop:
- push eax
- push ecx
-
- mov edi, JSAMPROW [esi]
- add edi, edx
- mov al, JSAMPLE [edi-1]
-
- rep stosb
-
- pop ecx
- pop eax
-
- add esi, byte SIZEOF_JSAMPROW
- dec eax
- jg short .expandloop
-
-.expand_end:
- pop ecx ; output_cols
-
- ; -- h2v2_downsample
-
- mov eax, JDIMENSION [v_samp(ebp)] ; rowctr
- test eax, eax
- jle near .return
-
- mov edx, 0x00020001 ; bias pattern
- movd xmm7, edx
- pcmpeqw xmm6, xmm6
- pshufd xmm7, xmm7, 0x00 ; xmm7={1, 2, 1, 2, 1, 2, 1, 2}
- psrlw xmm6, BYTE_BIT ; xmm6={0xFF 0x00 0xFF 0x00 ..}
-
- mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
- mov edi, JSAMPARRAY [output_data(ebp)] ; output_data
- alignx 16, 7
-.rowloop:
- push ecx
- push edi
- push esi
-
- mov edx, JSAMPROW [esi+0*SIZEOF_JSAMPROW] ; inptr0
- mov esi, JSAMPROW [esi+1*SIZEOF_JSAMPROW] ; inptr1
- mov edi, JSAMPROW [edi] ; outptr
-
- cmp ecx, byte SIZEOF_XMMWORD
- jae short .columnloop
- alignx 16, 7
-
-.columnloop_r8:
- movdqa xmm0, XMMWORD [edx+0*SIZEOF_XMMWORD]
- movdqa xmm1, XMMWORD [esi+0*SIZEOF_XMMWORD]
- pxor xmm2, xmm2
- pxor xmm3, xmm3
- mov ecx, SIZEOF_XMMWORD
- jmp short .downsample
- alignx 16, 7
-
-.columnloop:
- movdqa xmm0, XMMWORD [edx+0*SIZEOF_XMMWORD]
- movdqa xmm1, XMMWORD [esi+0*SIZEOF_XMMWORD]
- movdqa xmm2, XMMWORD [edx+1*SIZEOF_XMMWORD]
- movdqa xmm3, XMMWORD [esi+1*SIZEOF_XMMWORD]
-
-.downsample:
- movdqa xmm4, xmm0
- movdqa xmm5, xmm1
- pand xmm0, xmm6
- psrlw xmm4, BYTE_BIT
- pand xmm1, xmm6
- psrlw xmm5, BYTE_BIT
- paddw xmm0, xmm4
- paddw xmm1, xmm5
-
- movdqa xmm4, xmm2
- movdqa xmm5, xmm3
- pand xmm2, xmm6
- psrlw xmm4, BYTE_BIT
- pand xmm3, xmm6
- psrlw xmm5, BYTE_BIT
- paddw xmm2, xmm4
- paddw xmm3, xmm5
-
- paddw xmm0, xmm1
- paddw xmm2, xmm3
- paddw xmm0, xmm7
- paddw xmm2, xmm7
- psrlw xmm0, 2
- psrlw xmm2, 2
-
- packuswb xmm0, xmm2
-
- movdqa XMMWORD [edi+0*SIZEOF_XMMWORD], xmm0
-
- sub ecx, byte SIZEOF_XMMWORD ; outcol
- add edx, byte 2*SIZEOF_XMMWORD ; inptr0
- add esi, byte 2*SIZEOF_XMMWORD ; inptr1
- add edi, byte 1*SIZEOF_XMMWORD ; outptr
- cmp ecx, byte SIZEOF_XMMWORD
- jae near .columnloop
- test ecx, ecx
- jnz near .columnloop_r8
-
- pop esi
- pop edi
- pop ecx
-
- add esi, byte 2*SIZEOF_JSAMPROW ; input_data
- add edi, byte 1*SIZEOF_JSAMPROW ; output_data
- dec eax ; rowctr
- jg near .rowloop
-
-.return:
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
-; pop ebx ; unused
- pop ebp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jdcolext-avx2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jdcolext-avx2.asm
deleted file mode 100644
index 015be0416c..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jdcolext-avx2.asm
+++ /dev/null
@@ -1,515 +0,0 @@
-;
-; jdcolext.asm - colorspace conversion (AVX2)
-;
-; Copyright 2009, 2012 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2012, 2016, D. R. Commander.
-; Copyright (C) 2015, Intel Corporation.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jcolsamp.inc"
-
-; --------------------------------------------------------------------------
-;
-; Convert some rows of samples to the output colorspace.
-;
-; GLOBAL(void)
-; jsimd_ycc_rgb_convert_avx2(JDIMENSION out_width, JSAMPIMAGE input_buf,
-; JDIMENSION input_row, JSAMPARRAY output_buf,
-; int num_rows)
-;
-
-%define out_width(b) (b) + 8 ; JDIMENSION out_width
-%define input_buf(b) (b) + 12 ; JSAMPIMAGE input_buf
-%define input_row(b) (b) + 16 ; JDIMENSION input_row
-%define output_buf(b) (b) + 20 ; JSAMPARRAY output_buf
-%define num_rows(b) (b) + 24 ; int num_rows
-
-%define original_ebp ebp + 0
-%define wk(i) ebp - (WK_NUM - (i)) * SIZEOF_YMMWORD
- ; ymmword wk[WK_NUM]
-%define WK_NUM 2
-%define gotptr wk(0) - SIZEOF_POINTER ; void * gotptr
-
- align 32
- GLOBAL_FUNCTION(jsimd_ycc_rgb_convert_avx2)
-
-EXTN(jsimd_ycc_rgb_convert_avx2):
- push ebp
- mov eax, esp ; eax = original ebp
- sub esp, byte 4
- and esp, byte (-SIZEOF_YMMWORD) ; align to 256 bits
- mov [esp], eax
- mov ebp, esp ; ebp = aligned ebp
- lea esp, [wk(0)]
- pushpic eax ; make a room for GOT address
- push ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- get_GOT ebx ; get GOT address
- movpic POINTER [gotptr], ebx ; save GOT address
-
- mov ecx, JDIMENSION [out_width(eax)] ; num_cols
- test ecx, ecx
- jz near .return
-
- push ecx
-
- mov edi, JSAMPIMAGE [input_buf(eax)]
- mov ecx, JDIMENSION [input_row(eax)]
- mov esi, JSAMPARRAY [edi+0*SIZEOF_JSAMPARRAY]
- mov ebx, JSAMPARRAY [edi+1*SIZEOF_JSAMPARRAY]
- mov edx, JSAMPARRAY [edi+2*SIZEOF_JSAMPARRAY]
- lea esi, [esi+ecx*SIZEOF_JSAMPROW]
- lea ebx, [ebx+ecx*SIZEOF_JSAMPROW]
- lea edx, [edx+ecx*SIZEOF_JSAMPROW]
-
- pop ecx
-
- mov edi, JSAMPARRAY [output_buf(eax)]
- mov eax, INT [num_rows(eax)]
- test eax, eax
- jle near .return
- alignx 16, 7
-.rowloop:
- push eax
- push edi
- push edx
- push ebx
- push esi
- push ecx ; col
-
- mov esi, JSAMPROW [esi] ; inptr0
- mov ebx, JSAMPROW [ebx] ; inptr1
- mov edx, JSAMPROW [edx] ; inptr2
- mov edi, JSAMPROW [edi] ; outptr
- movpic eax, POINTER [gotptr] ; load GOT address (eax)
- alignx 16, 7
-.columnloop:
-
- vmovdqu ymm5, YMMWORD [ebx] ; ymm5=Cb(0123456789ABCDEFGHIJKLMNOPQRSTUV)
- vmovdqu ymm1, YMMWORD [edx] ; ymm1=Cr(0123456789ABCDEFGHIJKLMNOPQRSTUV)
-
- vpcmpeqw ymm0, ymm0, ymm0
- vpcmpeqw ymm7, ymm7, ymm7
- vpsrlw ymm0, ymm0, BYTE_BIT ; ymm0={0xFF 0x00 0xFF 0x00 ..}
- vpsllw ymm7, ymm7, 7 ; ymm7={0xFF80 0xFF80 0xFF80 0xFF80 ..}
-
- vpand ymm4, ymm0, ymm5 ; ymm4=Cb(02468ACEGIKMOQSU)=CbE
- vpsrlw ymm5, ymm5, BYTE_BIT ; ymm5=Cb(13579BDFHJLNPRTV)=CbO
- vpand ymm0, ymm0, ymm1 ; ymm0=Cr(02468ACEGIKMOQSU)=CrE
- vpsrlw ymm1, ymm1, BYTE_BIT ; ymm1=Cr(13579BDFHJLNPRTV)=CrO
-
- vpaddw ymm2, ymm4, ymm7
- vpaddw ymm3, ymm5, ymm7
- vpaddw ymm6, ymm0, ymm7
- vpaddw ymm7, ymm1, ymm7
-
- ; (Original)
- ; R = Y + 1.40200 * Cr
- ; G = Y - 0.34414 * Cb - 0.71414 * Cr
- ; B = Y + 1.77200 * Cb
- ;
- ; (This implementation)
- ; R = Y + 0.40200 * Cr + Cr
- ; G = Y - 0.34414 * Cb + 0.28586 * Cr - Cr
- ; B = Y - 0.22800 * Cb + Cb + Cb
-
- vpaddw ymm4, ymm2, ymm2 ; ymm4=2*CbE
- vpaddw ymm5, ymm3, ymm3 ; ymm5=2*CbO
- vpaddw ymm0, ymm6, ymm6 ; ymm0=2*CrE
- vpaddw ymm1, ymm7, ymm7 ; ymm1=2*CrO
-
- vpmulhw ymm4, ymm4, [GOTOFF(eax,PW_MF0228)] ; ymm4=(2*CbE * -FIX(0.22800))
- vpmulhw ymm5, ymm5, [GOTOFF(eax,PW_MF0228)] ; ymm5=(2*CbO * -FIX(0.22800))
- vpmulhw ymm0, ymm0, [GOTOFF(eax,PW_F0402)] ; ymm0=(2*CrE * FIX(0.40200))
- vpmulhw ymm1, ymm1, [GOTOFF(eax,PW_F0402)] ; ymm1=(2*CrO * FIX(0.40200))
-
- vpaddw ymm4, ymm4, [GOTOFF(eax,PW_ONE)]
- vpaddw ymm5, ymm5, [GOTOFF(eax,PW_ONE)]
- vpsraw ymm4, ymm4, 1 ; ymm4=(CbE * -FIX(0.22800))
- vpsraw ymm5, ymm5, 1 ; ymm5=(CbO * -FIX(0.22800))
- vpaddw ymm0, ymm0, [GOTOFF(eax,PW_ONE)]
- vpaddw ymm1, ymm1, [GOTOFF(eax,PW_ONE)]
- vpsraw ymm0, ymm0, 1 ; ymm0=(CrE * FIX(0.40200))
- vpsraw ymm1, ymm1, 1 ; ymm1=(CrO * FIX(0.40200))
-
- vpaddw ymm4, ymm4, ymm2
- vpaddw ymm5, ymm5, ymm3
- vpaddw ymm4, ymm4, ymm2 ; ymm4=(CbE * FIX(1.77200))=(B-Y)E
- vpaddw ymm5, ymm5, ymm3 ; ymm5=(CbO * FIX(1.77200))=(B-Y)O
- vpaddw ymm0, ymm0, ymm6 ; ymm0=(CrE * FIX(1.40200))=(R-Y)E
- vpaddw ymm1, ymm1, ymm7 ; ymm1=(CrO * FIX(1.40200))=(R-Y)O
-
- vmovdqa YMMWORD [wk(0)], ymm4 ; wk(0)=(B-Y)E
- vmovdqa YMMWORD [wk(1)], ymm5 ; wk(1)=(B-Y)O
-
- vpunpckhwd ymm4, ymm2, ymm6
- vpunpcklwd ymm2, ymm2, ymm6
- vpmaddwd ymm2, ymm2, [GOTOFF(eax,PW_MF0344_F0285)]
- vpmaddwd ymm4, ymm4, [GOTOFF(eax,PW_MF0344_F0285)]
- vpunpckhwd ymm5, ymm3, ymm7
- vpunpcklwd ymm3, ymm3, ymm7
- vpmaddwd ymm3, ymm3, [GOTOFF(eax,PW_MF0344_F0285)]
- vpmaddwd ymm5, ymm5, [GOTOFF(eax,PW_MF0344_F0285)]
-
- vpaddd ymm2, ymm2, [GOTOFF(eax,PD_ONEHALF)]
- vpaddd ymm4, ymm4, [GOTOFF(eax,PD_ONEHALF)]
- vpsrad ymm2, ymm2, SCALEBITS
- vpsrad ymm4, ymm4, SCALEBITS
- vpaddd ymm3, ymm3, [GOTOFF(eax,PD_ONEHALF)]
- vpaddd ymm5, ymm5, [GOTOFF(eax,PD_ONEHALF)]
- vpsrad ymm3, ymm3, SCALEBITS
- vpsrad ymm5, ymm5, SCALEBITS
-
- vpackssdw ymm2, ymm2, ymm4 ; ymm2=CbE*-FIX(0.344)+CrE*FIX(0.285)
- vpackssdw ymm3, ymm3, ymm5 ; ymm3=CbO*-FIX(0.344)+CrO*FIX(0.285)
- vpsubw ymm2, ymm2, ymm6 ; ymm2=CbE*-FIX(0.344)+CrE*-FIX(0.714)=(G-Y)E
- vpsubw ymm3, ymm3, ymm7 ; ymm3=CbO*-FIX(0.344)+CrO*-FIX(0.714)=(G-Y)O
-
- vmovdqu ymm5, YMMWORD [esi] ; ymm5=Y(0123456789ABCDEFGHIJKLMNOPQRSTUV)
-
- vpcmpeqw ymm4, ymm4, ymm4
- vpsrlw ymm4, ymm4, BYTE_BIT ; ymm4={0xFF 0x00 0xFF 0x00 ..}
- vpand ymm4, ymm4, ymm5 ; ymm4=Y(02468ACEGIKMOQSU)=YE
- vpsrlw ymm5, ymm5, BYTE_BIT ; ymm5=Y(13579BDFHJLNPRTV)=YO
-
- vpaddw ymm0, ymm0, ymm4 ; ymm0=((R-Y)E+YE)=RE=R(02468ACEGIKMOQSU)
- vpaddw ymm1, ymm1, ymm5 ; ymm1=((R-Y)O+YO)=RO=R(13579BDFHJLNPRTV)
- vpackuswb ymm0, ymm0, ymm0 ; ymm0=R(02468ACE********GIKMOQSU********)
- vpackuswb ymm1, ymm1, ymm1 ; ymm1=R(13579BDF********HJLNPRTV********)
-
- vpaddw ymm2, ymm2, ymm4 ; ymm2=((G-Y)E+YE)=GE=G(02468ACEGIKMOQSU)
- vpaddw ymm3, ymm3, ymm5 ; ymm3=((G-Y)O+YO)=GO=G(13579BDFHJLNPRTV)
- vpackuswb ymm2, ymm2, ymm2 ; ymm2=G(02468ACE********GIKMOQSU********)
- vpackuswb ymm3, ymm3, ymm3 ; ymm3=G(13579BDF********HJLNPRTV********)
-
- vpaddw ymm4, ymm4, YMMWORD [wk(0)] ; ymm4=(YE+(B-Y)E)=BE=B(02468ACEGIKMOQSU)
- vpaddw ymm5, ymm5, YMMWORD [wk(1)] ; ymm5=(YO+(B-Y)O)=BO=B(13579BDFHJLNPRTV)
- vpackuswb ymm4, ymm4, ymm4 ; ymm4=B(02468ACE********GIKMOQSU********)
- vpackuswb ymm5, ymm5, ymm5 ; ymm5=B(13579BDF********HJLNPRTV********)
-
-%if RGB_PIXELSIZE == 3 ; ---------------
-
- ; ymmA=(00 02 04 06 08 0A 0C 0E ** 0G 0I 0K 0M 0O 0Q 0S 0U **)
- ; ymmB=(01 03 05 07 09 0B 0D 0F ** 0H 0J 0L 0N 0P 0R 0T 0V **)
- ; ymmC=(10 12 14 16 18 1A 1C 1E ** 1G 1I 1K 1M 1O 1Q 1S 1U **)
- ; ymmD=(11 13 15 17 19 1B 1D 1F ** 1H 1J 1L 1N 1P 1R 1T 1V **)
- ; ymmE=(20 22 24 26 28 2A 2C 2E ** 2G 2I 2K 2M 2O 2Q 2S 2U **)
- ; ymmF=(21 23 25 27 29 2B 2D 2F ** 2H 2J 2L 2N 2P 2R 2T 2V **)
- ; ymmG=(** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **)
- ; ymmH=(** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **)
-
- vpunpcklbw ymmA, ymmA, ymmC ; ymmA=(00 10 02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E
- ; 0G 1G 0I 1I 0K 1K 0M 1M 0O 1O 0Q 1Q 0S 1S 0U 1U)
- vpunpcklbw ymmE, ymmE, ymmB ; ymmE=(20 01 22 03 24 05 26 07 28 09 2A 0B 2C 0D 2E 0F
- ; 2G 0H 2I 0J 2K 0L 2M 0N 2O 0P 2Q 0R 2S 0T 2U 0V)
- vpunpcklbw ymmD, ymmD, ymmF ; ymmD=(11 21 13 23 15 25 17 27 19 29 1B 2B 1D 2D 1F 2F
- ; 1H 2H 1J 2J 1L 2L 1N 2N 1P 2P 1R 2R 1T 2T 1V 2V)
-
- vpsrldq ymmH, ymmA, 2 ; ymmH=(02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E 0G 1G
- ; 0I 1I 0K 1K 0M 1M 0O 1O 0Q 1Q 0S 1S 0U 1U -- --)
- vpunpckhwd ymmG, ymmA, ymmE ; ymmG=(08 18 28 09 0A 1A 2A 0B 0C 1C 2C 0D 0E 1E 2E 0F
- ; 0O 1O 2O 0P 0Q 1Q 2Q 0R 0S 1S 2S 0T 0U 1U 2U 0V)
- vpunpcklwd ymmA, ymmA, ymmE ; ymmA=(00 10 20 01 02 12 22 03 04 14 24 05 06 16 26 07
- ; 0G 1G 2G 0H 0I 1I 2I 0J 0K 1K 2K 0L 0M 1M 2M 0N)
-
- vpsrldq ymmE, ymmE, 2 ; ymmE=(22 03 24 05 26 07 28 09 2A 0B 2C 0D 2E 0F 2G 0H
- ; 2I 0J 2K 0L 2M 0N 2O 0P 2Q 0R 2S 0T 2U 0V -- --)
-
- vpsrldq ymmB, ymmD, 2 ; ymmB=(13 23 15 25 17 27 19 29 1B 2B 1D 2D 1F 2F 1H 2H
- ; 1J 2J 1L 2L 1N 2N 1P 2P 1R 2R 1T 2T 1V 2V -- --)
- vpunpckhwd ymmC, ymmD, ymmH ; ymmC=(19 29 0A 1A 1B 2B 0C 1C 1D 2D 0E 1E 1F 2F 0G 1G
- ; 1P 2P 0Q 1Q 1R 2R 0S 1S 1T 2T 0U 1U 1V 2V -- --)
- vpunpcklwd ymmD, ymmD, ymmH ; ymmD=(11 21 02 12 13 23 04 14 15 25 06 16 17 27 08 18
- ; 1H 2H 0I 1I 1J 2J 0K 1K 1L 2L 0M 1M 1N 2N 0O 1O)
-
- vpunpckhwd ymmF, ymmE, ymmB ; ymmF=(2A 0B 1B 2B 2C 0D 1D 2D 2E 0F 1F 2F 2G 0H 1H 2H
- ; 2Q 0R 1R 2R 2S 0T 1T 2T 2U 0V 1V 2V -- -- -- --)
- vpunpcklwd ymmE, ymmE, ymmB ; ymmE=(22 03 13 23 24 05 15 25 26 07 17 27 28 09 19 29
- ; 2I 0J 1J 2J 2K 0L 1L 2L 2M 0N 1N 2N 2O 0P 1P 2P)
-
- vpshufd ymmH, ymmA, 0x4E ; ymmH=(04 14 24 05 06 16 26 07 00 10 20 01 02 12 22 03
- ; 0K 1K 2K 0L 0M 1M 2M 0N 0G 1G 2G 0H 0I 1I 2I 0J)
- vpunpckldq ymmA, ymmA, ymmD ; ymmA=(00 10 20 01 11 21 02 12 02 12 22 03 13 23 04 14
- ; 0G 1G 2G 0H 1H 2H 0I 1I 0I 1I 2I 0J 1J 2J 0K 1K)
- vpunpckhdq ymmD, ymmD, ymmE ; ymmD=(15 25 06 16 26 07 17 27 17 27 08 18 28 09 19 29
- ; 1L 2L 0M 1M 2M 0N 1N 2N 1N 2N 0O 1O 2O 0P 1P 2P)
- vpunpckldq ymmE, ymmE, ymmH ; ymmE=(22 03 13 23 04 14 24 05 24 05 15 25 06 16 26 07
- ; 2I 0J 1J 2J 0K 1K 2K 0L 2K 0L 1L 2L 0M 1M 2M 0N)
-
- vpshufd ymmH, ymmG, 0x4E ; ymmH=(0C 1C 2C 0D 0E 1E 2E 0F 08 18 28 09 0A 1A 2A 0B
- ; 0S 1S 2S 0T 0U 1U 2U 0V 0O 1O 2O 0P 0Q 1Q 2Q 0R)
- vpunpckldq ymmG, ymmG, ymmC ; ymmG=(08 18 28 09 19 29 0A 1A 0A 1A 2A 0B 1B 2B 0C 1C
- ; 0O 1O 2O 0P 1P 2P 0Q 1Q 0Q 1Q 2Q 0R 1R 2R 0S 1S)
- vpunpckhdq ymmC, ymmC, ymmF ; ymmC=(1D 2D 0E 1E 2E 0F 1F 2F 1F 2F 0G 1G 2G 0H 1H 2H
- ; 1T 2T 0U 1U 2U 0V 1V 2V 1V 2V -- -- -- -- -- --)
- vpunpckldq ymmF, ymmF, ymmH ; ymmF=(2A 0B 1B 2B 0C 1C 2C 0D 2C 0D 1D 2D 0E 1E 2E 0F
- ; 2Q 0R 1R 2R 0S 1S 2S 0T 2S 0T 1T 2T 0U 1U 2U 0V)
-
- vpunpcklqdq ymmH, ymmA, ymmE ; ymmH=(00 10 20 01 11 21 02 12 22 03 13 23 04 14 24 05
- ; 0G 1G 2G 0H 1H 2H 0I 1I 2I 0J 1J 2J 0K 1K 2K 0L)
- vpunpcklqdq ymmG, ymmD, ymmG ; ymmG=(15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A
- ; 1L 2L 0M 1M 2M 0N 1N 2N 0O 1O 2O 0P 1P 2P 0Q 1Q)
- vpunpcklqdq ymmC, ymmF, ymmC ; ymmC=(2A 0B 1B 2B 0C 1C 2C 0D 1D 2D 0E 1E 2E 0F 1F 2F
- ; 2Q 0R 1R 2R 0S 1S 2S 0T 1T 2T 0U 1U 2U 0V 1V 2V)
-
- vperm2i128 ymmA, ymmH, ymmG, 0x20 ; ymmA=(00 10 20 01 11 21 02 12 22 03 13 23 04 14 24 05
- ; 15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A)
- vperm2i128 ymmD, ymmC, ymmH, 0x30 ; ymmD=(2A 0B 1B 2B 0C 1C 2C 0D 1D 2D 0E 1E 2E 0F 1F 2F
- ; 0G 1G 2G 0H 1H 2H 0I 1I 2I 0J 1J 2J 0K 1K 2K 0L)
- vperm2i128 ymmF, ymmG, ymmC, 0x31 ; ymmF=(1L 2L 0M 1M 2M 0N 1N 2N 0O 1O 2O 0P 1P 2P 0Q 1Q
- ; 2Q 0R 1R 2R 0S 1S 2S 0T 1T 2T 0U 1U 2U 0V 1V 2V)
-
- cmp ecx, byte SIZEOF_YMMWORD
- jb short .column_st64
-
- test edi, SIZEOF_YMMWORD-1
- jnz short .out1
- ; --(aligned)-------------------
- vmovntdq YMMWORD [edi+0*SIZEOF_YMMWORD], ymmA
- vmovntdq YMMWORD [edi+1*SIZEOF_YMMWORD], ymmD
- vmovntdq YMMWORD [edi+2*SIZEOF_YMMWORD], ymmF
- jmp short .out0
-.out1: ; --(unaligned)-----------------
- vmovdqu YMMWORD [edi+0*SIZEOF_YMMWORD], ymmA
- vmovdqu YMMWORD [edi+1*SIZEOF_YMMWORD], ymmD
- vmovdqu YMMWORD [edi+2*SIZEOF_YMMWORD], ymmF
-.out0:
- add edi, byte RGB_PIXELSIZE*SIZEOF_YMMWORD ; outptr
- sub ecx, byte SIZEOF_YMMWORD
- jz near .nextrow
-
- add esi, byte SIZEOF_YMMWORD ; inptr0
- add ebx, byte SIZEOF_YMMWORD ; inptr1
- add edx, byte SIZEOF_YMMWORD ; inptr2
- jmp near .columnloop
- alignx 16, 7
-
-.column_st64:
- lea ecx, [ecx+ecx*2] ; imul ecx, RGB_PIXELSIZE
- cmp ecx, byte 2*SIZEOF_YMMWORD
- jb short .column_st32
- vmovdqu YMMWORD [edi+0*SIZEOF_YMMWORD], ymmA
- vmovdqu YMMWORD [edi+1*SIZEOF_YMMWORD], ymmD
- add edi, byte 2*SIZEOF_YMMWORD ; outptr
- vmovdqa ymmA, ymmF
- sub ecx, byte 2*SIZEOF_YMMWORD
- jmp short .column_st31
-.column_st32:
- cmp ecx, byte SIZEOF_YMMWORD
- jb short .column_st31
- vmovdqu YMMWORD [edi+0*SIZEOF_YMMWORD], ymmA
- add edi, byte SIZEOF_YMMWORD ; outptr
- vmovdqa ymmA, ymmD
- sub ecx, byte SIZEOF_YMMWORD
- jmp short .column_st31
-.column_st31:
- cmp ecx, byte SIZEOF_XMMWORD
- jb short .column_st15
- vmovdqu XMMWORD [edi+0*SIZEOF_XMMWORD], xmmA
- add edi, byte SIZEOF_XMMWORD ; outptr
- vperm2i128 ymmA, ymmA, ymmA, 1
- sub ecx, byte SIZEOF_XMMWORD
-.column_st15:
- ; Store the lower 8 bytes of xmmA to the output when it has enough
- ; space.
- cmp ecx, byte SIZEOF_MMWORD
- jb short .column_st7
- vmovq XMM_MMWORD [edi], xmmA
- add edi, byte SIZEOF_MMWORD
- sub ecx, byte SIZEOF_MMWORD
- vpsrldq xmmA, xmmA, SIZEOF_MMWORD
-.column_st7:
- ; Store the lower 4 bytes of xmmA to the output when it has enough
- ; space.
- cmp ecx, byte SIZEOF_DWORD
- jb short .column_st3
- vmovd XMM_DWORD [edi], xmmA
- add edi, byte SIZEOF_DWORD
- sub ecx, byte SIZEOF_DWORD
- vpsrldq xmmA, xmmA, SIZEOF_DWORD
-.column_st3:
- ; Store the lower 2 bytes of eax to the output when it has enough
- ; space.
- vmovd eax, xmmA
- cmp ecx, byte SIZEOF_WORD
- jb short .column_st1
- mov word [edi], ax
- add edi, byte SIZEOF_WORD
- sub ecx, byte SIZEOF_WORD
- shr eax, 16
-.column_st1:
- ; Store the lower 1 byte of eax to the output when it has enough
- ; space.
- test ecx, ecx
- jz short .nextrow
- mov byte [edi], al
-
-%else ; RGB_PIXELSIZE == 4 ; -----------
-
-%ifdef RGBX_FILLER_0XFF
- vpcmpeqb ymm6, ymm6, ymm6 ; ymm6=XE=X(02468ACE********GIKMOQSU********)
- vpcmpeqb ymm7, ymm7, ymm7 ; ymm7=XO=X(13579BDF********HJLNPRTV********)
-%else
- vpxor ymm6, ymm6, ymm6 ; ymm6=XE=X(02468ACE********GIKMOQSU********)
- vpxor ymm7, ymm7, ymm7 ; ymm7=XO=X(13579BDF********HJLNPRTV********)
-%endif
- ; ymmA=(00 02 04 06 08 0A 0C 0E ** 0G 0I 0K 0M 0O 0Q 0S 0U **)
- ; ymmB=(01 03 05 07 09 0B 0D 0F ** 0H 0J 0L 0N 0P 0R 0T 0V **)
- ; ymmC=(10 12 14 16 18 1A 1C 1E ** 1G 1I 1K 1M 1O 1Q 1S 1U **)
- ; ymmD=(11 13 15 17 19 1B 1D 1F ** 1H 1J 1L 1N 1P 1R 1T 1V **)
- ; ymmE=(20 22 24 26 28 2A 2C 2E ** 2G 2I 2K 2M 2O 2Q 2S 2U **)
- ; ymmF=(21 23 25 27 29 2B 2D 2F ** 2H 2J 2L 2N 2P 2R 2T 2V **)
- ; ymmG=(30 32 34 36 38 3A 3C 3E ** 3G 3I 3K 3M 3O 3Q 3S 3U **)
- ; ymmH=(31 33 35 37 39 3B 3D 3F ** 3H 3J 3L 3N 3P 3R 3T 3V **)
-
- vpunpcklbw ymmA, ymmA, ymmC ; ymmA=(00 10 02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E
- ; 0G 1G 0I 1I 0K 1K 0M 1M 0O 1O 0Q 1Q 0S 1S 0U 1U)
- vpunpcklbw ymmE, ymmE, ymmG ; ymmE=(20 30 22 32 24 34 26 36 28 38 2A 3A 2C 3C 2E 3E
- ; 2G 3G 2I 3I 2K 3K 2M 3M 2O 3O 2Q 3Q 2S 3S 2U 3U)
- vpunpcklbw ymmB, ymmB, ymmD ; ymmB=(01 11 03 13 05 15 07 17 09 19 0B 1B 0D 1D 0F 1F
- ; 0H 1H 0J 1J 0L 1L 0N 1N 0P 1P 0R 1R 0T 1T 0V 1V)
- vpunpcklbw ymmF, ymmF, ymmH ; ymmF=(21 31 23 33 25 35 27 37 29 39 2B 3B 2D 3D 2F 3F
- ; 2H 3H 2J 3J 2L 3L 2N 3N 2P 3P 2R 3R 2T 3T 2V 3V)
-
- vpunpckhwd ymmC, ymmA, ymmE ; ymmC=(08 18 28 38 0A 1A 2A 3A 0C 1C 2C 3C 0E 1E 2E 3E
- ; 0O 1O 2O 3O 0Q 1Q 2Q 3Q 0S 1S 2S 3S 0U 1U 2U 3U)
- vpunpcklwd ymmA, ymmA, ymmE ; ymmA=(00 10 20 30 02 12 22 32 04 14 24 34 06 16 26 36
- ; 0G 1G 2G 3G 0I 1I 2I 3I 0K 1K 2K 3K 0M 1M 2M 3M)
- vpunpckhwd ymmG, ymmB, ymmF ; ymmG=(09 19 29 39 0B 1B 2B 3B 0D 1D 2D 3D 0F 1F 2F 3F
- ; 0P 1P 2P 3P 0R 1R 2R 3R 0T 1T 2T 3T 0V 1V 2V 3V)
- vpunpcklwd ymmB, ymmB, ymmF ; ymmB=(01 11 21 31 03 13 23 33 05 15 25 35 07 17 27 37
- ; 0H 1H 2H 3H 0J 1J 2J 3J 0L 1L 2L 3L 0N 1N 2N 3N)
-
- vpunpckhdq ymmE, ymmA, ymmB ; ymmE=(04 14 24 34 05 15 25 35 06 16 26 36 07 17 27 37
- ; 0K 1K 2K 3K 0L 1L 2L 3L 0M 1M 2M 3M 0N 1N 2N 3N)
- vpunpckldq ymmB, ymmA, ymmB ; ymmB=(00 10 20 30 01 11 21 31 02 12 22 32 03 13 23 33
- ; 0G 1G 2G 3G 0H 1H 2H 3H 0I 1I 2I 3I 0J 1J 2J 3J)
- vpunpckhdq ymmF, ymmC, ymmG ; ymmF=(0C 1C 2C 3C 0D 1D 2D 3D 0E 1E 2E 3E 0F 1F 2F 3F
- ; 0S 1S 2S 3S 0T 1T 2T 3T 0U 1U 2U 3U 0V 1V 2V 3V)
- vpunpckldq ymmG, ymmC, ymmG ; ymmG=(08 18 28 38 09 19 29 39 0A 1A 2A 3A 0B 1B 2B 3B
- ; 0O 1O 2O 3O 0P 1P 2P 3P 0Q 1Q 2Q 3Q 0R 1R 2R 3R)
-
- vperm2i128 ymmA, ymmB, ymmE, 0x20 ; ymmA=(00 10 20 30 01 11 21 31 02 12 22 32 03 13 23 33
- ; 04 14 24 34 05 15 25 35 06 16 26 36 07 17 27 37)
- vperm2i128 ymmD, ymmG, ymmF, 0x20 ; ymmD=(08 18 28 38 09 19 29 39 0A 1A 2A 3A 0B 1B 2B 3B
- ; 0C 1C 2C 3C 0D 1D 2D 3D 0E 1E 2E 3E 0F 1F 2F 3F)
- vperm2i128 ymmC, ymmB, ymmE, 0x31 ; ymmC=(0G 1G 2G 3G 0H 1H 2H 3H 0I 1I 2I 3I 0J 1J 2J 3J
- ; 0K 1K 2K 3K 0L 1L 2L 3L 0M 1M 2M 3M 0N 1N 2N 3N)
- vperm2i128 ymmH, ymmG, ymmF, 0x31 ; ymmH=(0O 1O 2O 3O 0P 1P 2P 3P 0Q 1Q 2Q 3Q 0R 1R 2R 3R
- ; 0S 1S 2S 3S 0T 1T 2T 3T 0U 1U 2U 3U 0V 1V 2V 3V)
-
- cmp ecx, byte SIZEOF_YMMWORD
- jb short .column_st64
-
- test edi, SIZEOF_YMMWORD-1
- jnz short .out1
- ; --(aligned)-------------------
- vmovntdq YMMWORD [edi+0*SIZEOF_YMMWORD], ymmA
- vmovntdq YMMWORD [edi+1*SIZEOF_YMMWORD], ymmD
- vmovntdq YMMWORD [edi+2*SIZEOF_YMMWORD], ymmC
- vmovntdq YMMWORD [edi+3*SIZEOF_YMMWORD], ymmH
- jmp short .out0
-.out1: ; --(unaligned)-----------------
- vmovdqu YMMWORD [edi+0*SIZEOF_YMMWORD], ymmA
- vmovdqu YMMWORD [edi+1*SIZEOF_YMMWORD], ymmD
- vmovdqu YMMWORD [edi+2*SIZEOF_YMMWORD], ymmC
- vmovdqu YMMWORD [edi+3*SIZEOF_YMMWORD], ymmH
-.out0:
- add edi, RGB_PIXELSIZE*SIZEOF_YMMWORD ; outptr
- sub ecx, byte SIZEOF_YMMWORD
- jz near .nextrow
-
- add esi, byte SIZEOF_YMMWORD ; inptr0
- add ebx, byte SIZEOF_YMMWORD ; inptr1
- add edx, byte SIZEOF_YMMWORD ; inptr2
- jmp near .columnloop
- alignx 16, 7
-
-.column_st64:
- cmp ecx, byte SIZEOF_YMMWORD/2
- jb short .column_st32
- vmovdqu YMMWORD [edi+0*SIZEOF_YMMWORD], ymmA
- vmovdqu YMMWORD [edi+1*SIZEOF_YMMWORD], ymmD
- add edi, byte 2*SIZEOF_YMMWORD ; outptr
- vmovdqa ymmA, ymmC
- vmovdqa ymmD, ymmH
- sub ecx, byte SIZEOF_YMMWORD/2
-.column_st32:
- cmp ecx, byte SIZEOF_YMMWORD/4
- jb short .column_st16
- vmovdqu YMMWORD [edi+0*SIZEOF_YMMWORD], ymmA
- add edi, byte SIZEOF_YMMWORD ; outptr
- vmovdqa ymmA, ymmD
- sub ecx, byte SIZEOF_YMMWORD/4
-.column_st16:
- cmp ecx, byte SIZEOF_YMMWORD/8
- jb short .column_st15
- vmovdqu XMMWORD [edi+0*SIZEOF_XMMWORD], xmmA
- vperm2i128 ymmA, ymmA, ymmA, 1
- add edi, byte SIZEOF_XMMWORD ; outptr
- sub ecx, byte SIZEOF_YMMWORD/8
-.column_st15:
- ; Store two pixels (8 bytes) of ymmA to the output when it has enough
- ; space.
- cmp ecx, byte SIZEOF_YMMWORD/16
- jb short .column_st7
- vmovq MMWORD [edi], xmmA
- add edi, byte SIZEOF_YMMWORD/16*4
- sub ecx, byte SIZEOF_YMMWORD/16
- vpsrldq xmmA, SIZEOF_YMMWORD/16*4
-.column_st7:
- ; Store one pixel (4 bytes) of ymmA to the output when it has enough
- ; space.
- test ecx, ecx
- jz short .nextrow
- vmovd XMM_DWORD [edi], xmmA
-
-%endif ; RGB_PIXELSIZE ; ---------------
-
- alignx 16, 7
-
-.nextrow:
- pop ecx
- pop esi
- pop ebx
- pop edx
- pop edi
- pop eax
-
- add esi, byte SIZEOF_JSAMPROW
- add ebx, byte SIZEOF_JSAMPROW
- add edx, byte SIZEOF_JSAMPROW
- add edi, byte SIZEOF_JSAMPROW ; output_buf
- dec eax ; num_rows
- jg near .rowloop
-
- sfence ; flush the write buffer
-
-.return:
- vzeroupper
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- pop ebx
- mov esp, ebp ; esp <- aligned ebp
- pop esp ; esp <- original ebp
- pop ebp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jdcolext-mmx.asm b/contrib/libs/libjpeg-turbo/simd/i386/jdcolext-mmx.asm
deleted file mode 100644
index 5813cfcb66..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jdcolext-mmx.asm
+++ /dev/null
@@ -1,404 +0,0 @@
-;
-; jdcolext.asm - colorspace conversion (MMX)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jcolsamp.inc"
-
-; --------------------------------------------------------------------------
-;
-; Convert some rows of samples to the output colorspace.
-;
-; GLOBAL(void)
-; jsimd_ycc_rgb_convert_mmx(JDIMENSION out_width, JSAMPIMAGE input_buf,
-; JDIMENSION input_row, JSAMPARRAY output_buf,
-; int num_rows)
-;
-
-%define out_width(b) (b) + 8 ; JDIMENSION out_width
-%define input_buf(b) (b) + 12 ; JSAMPIMAGE input_buf
-%define input_row(b) (b) + 16 ; JDIMENSION input_row
-%define output_buf(b) (b) + 20 ; JSAMPARRAY output_buf
-%define num_rows(b) (b) + 24 ; int num_rows
-
-%define original_ebp ebp + 0
-%define wk(i) ebp - (WK_NUM - (i)) * SIZEOF_MMWORD
- ; mmword wk[WK_NUM]
-%define WK_NUM 2
-%define gotptr wk(0) - SIZEOF_POINTER ; void * gotptr
-
- align 32
- GLOBAL_FUNCTION(jsimd_ycc_rgb_convert_mmx)
-
-EXTN(jsimd_ycc_rgb_convert_mmx):
- push ebp
- mov eax, esp ; eax = original ebp
- sub esp, byte 4
- and esp, byte (-SIZEOF_MMWORD) ; align to 64 bits
- mov [esp], eax
- mov ebp, esp ; ebp = aligned ebp
- lea esp, [wk(0)]
- pushpic eax ; make a room for GOT address
- push ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- get_GOT ebx ; get GOT address
- movpic POINTER [gotptr], ebx ; save GOT address
-
- mov ecx, JDIMENSION [out_width(eax)] ; num_cols
- test ecx, ecx
- jz near .return
-
- push ecx
-
- mov edi, JSAMPIMAGE [input_buf(eax)]
- mov ecx, JDIMENSION [input_row(eax)]
- mov esi, JSAMPARRAY [edi+0*SIZEOF_JSAMPARRAY]
- mov ebx, JSAMPARRAY [edi+1*SIZEOF_JSAMPARRAY]
- mov edx, JSAMPARRAY [edi+2*SIZEOF_JSAMPARRAY]
- lea esi, [esi+ecx*SIZEOF_JSAMPROW]
- lea ebx, [ebx+ecx*SIZEOF_JSAMPROW]
- lea edx, [edx+ecx*SIZEOF_JSAMPROW]
-
- pop ecx
-
- mov edi, JSAMPARRAY [output_buf(eax)]
- mov eax, INT [num_rows(eax)]
- test eax, eax
- jle near .return
- alignx 16, 7
-.rowloop:
- push eax
- push edi
- push edx
- push ebx
- push esi
- push ecx ; col
-
- mov esi, JSAMPROW [esi] ; inptr0
- mov ebx, JSAMPROW [ebx] ; inptr1
- mov edx, JSAMPROW [edx] ; inptr2
- mov edi, JSAMPROW [edi] ; outptr
- movpic eax, POINTER [gotptr] ; load GOT address (eax)
- alignx 16, 7
-.columnloop:
-
- movq mm5, MMWORD [ebx] ; mm5=Cb(01234567)
- movq mm1, MMWORD [edx] ; mm1=Cr(01234567)
-
- pcmpeqw mm4, mm4
- pcmpeqw mm7, mm7
- psrlw mm4, BYTE_BIT
- psllw mm7, 7 ; mm7={0xFF80 0xFF80 0xFF80 0xFF80}
- movq mm0, mm4 ; mm0=mm4={0xFF 0x00 0xFF 0x00 ..}
-
- pand mm4, mm5 ; mm4=Cb(0246)=CbE
- psrlw mm5, BYTE_BIT ; mm5=Cb(1357)=CbO
- pand mm0, mm1 ; mm0=Cr(0246)=CrE
- psrlw mm1, BYTE_BIT ; mm1=Cr(1357)=CrO
-
- paddw mm4, mm7
- paddw mm5, mm7
- paddw mm0, mm7
- paddw mm1, mm7
-
- ; (Original)
- ; R = Y + 1.40200 * Cr
- ; G = Y - 0.34414 * Cb - 0.71414 * Cr
- ; B = Y + 1.77200 * Cb
- ;
- ; (This implementation)
- ; R = Y + 0.40200 * Cr + Cr
- ; G = Y - 0.34414 * Cb + 0.28586 * Cr - Cr
- ; B = Y - 0.22800 * Cb + Cb + Cb
-
- movq mm2, mm4 ; mm2=CbE
- movq mm3, mm5 ; mm3=CbO
- paddw mm4, mm4 ; mm4=2*CbE
- paddw mm5, mm5 ; mm5=2*CbO
- movq mm6, mm0 ; mm6=CrE
- movq mm7, mm1 ; mm7=CrO
- paddw mm0, mm0 ; mm0=2*CrE
- paddw mm1, mm1 ; mm1=2*CrO
-
- pmulhw mm4, [GOTOFF(eax,PW_MF0228)] ; mm4=(2*CbE * -FIX(0.22800))
- pmulhw mm5, [GOTOFF(eax,PW_MF0228)] ; mm5=(2*CbO * -FIX(0.22800))
- pmulhw mm0, [GOTOFF(eax,PW_F0402)] ; mm0=(2*CrE * FIX(0.40200))
- pmulhw mm1, [GOTOFF(eax,PW_F0402)] ; mm1=(2*CrO * FIX(0.40200))
-
- paddw mm4, [GOTOFF(eax,PW_ONE)]
- paddw mm5, [GOTOFF(eax,PW_ONE)]
- psraw mm4, 1 ; mm4=(CbE * -FIX(0.22800))
- psraw mm5, 1 ; mm5=(CbO * -FIX(0.22800))
- paddw mm0, [GOTOFF(eax,PW_ONE)]
- paddw mm1, [GOTOFF(eax,PW_ONE)]
- psraw mm0, 1 ; mm0=(CrE * FIX(0.40200))
- psraw mm1, 1 ; mm1=(CrO * FIX(0.40200))
-
- paddw mm4, mm2
- paddw mm5, mm3
- paddw mm4, mm2 ; mm4=(CbE * FIX(1.77200))=(B-Y)E
- paddw mm5, mm3 ; mm5=(CbO * FIX(1.77200))=(B-Y)O
- paddw mm0, mm6 ; mm0=(CrE * FIX(1.40200))=(R-Y)E
- paddw mm1, mm7 ; mm1=(CrO * FIX(1.40200))=(R-Y)O
-
- movq MMWORD [wk(0)], mm4 ; wk(0)=(B-Y)E
- movq MMWORD [wk(1)], mm5 ; wk(1)=(B-Y)O
-
- movq mm4, mm2
- movq mm5, mm3
- punpcklwd mm2, mm6
- punpckhwd mm4, mm6
- pmaddwd mm2, [GOTOFF(eax,PW_MF0344_F0285)]
- pmaddwd mm4, [GOTOFF(eax,PW_MF0344_F0285)]
- punpcklwd mm3, mm7
- punpckhwd mm5, mm7
- pmaddwd mm3, [GOTOFF(eax,PW_MF0344_F0285)]
- pmaddwd mm5, [GOTOFF(eax,PW_MF0344_F0285)]
-
- paddd mm2, [GOTOFF(eax,PD_ONEHALF)]
- paddd mm4, [GOTOFF(eax,PD_ONEHALF)]
- psrad mm2, SCALEBITS
- psrad mm4, SCALEBITS
- paddd mm3, [GOTOFF(eax,PD_ONEHALF)]
- paddd mm5, [GOTOFF(eax,PD_ONEHALF)]
- psrad mm3, SCALEBITS
- psrad mm5, SCALEBITS
-
- packssdw mm2, mm4 ; mm2=CbE*-FIX(0.344)+CrE*FIX(0.285)
- packssdw mm3, mm5 ; mm3=CbO*-FIX(0.344)+CrO*FIX(0.285)
- psubw mm2, mm6 ; mm2=CbE*-FIX(0.344)+CrE*-FIX(0.714)=(G-Y)E
- psubw mm3, mm7 ; mm3=CbO*-FIX(0.344)+CrO*-FIX(0.714)=(G-Y)O
-
- movq mm5, MMWORD [esi] ; mm5=Y(01234567)
-
- pcmpeqw mm4, mm4
- psrlw mm4, BYTE_BIT ; mm4={0xFF 0x00 0xFF 0x00 ..}
- pand mm4, mm5 ; mm4=Y(0246)=YE
- psrlw mm5, BYTE_BIT ; mm5=Y(1357)=YO
-
- paddw mm0, mm4 ; mm0=((R-Y)E+YE)=RE=(R0 R2 R4 R6)
- paddw mm1, mm5 ; mm1=((R-Y)O+YO)=RO=(R1 R3 R5 R7)
- packuswb mm0, mm0 ; mm0=(R0 R2 R4 R6 ** ** ** **)
- packuswb mm1, mm1 ; mm1=(R1 R3 R5 R7 ** ** ** **)
-
- paddw mm2, mm4 ; mm2=((G-Y)E+YE)=GE=(G0 G2 G4 G6)
- paddw mm3, mm5 ; mm3=((G-Y)O+YO)=GO=(G1 G3 G5 G7)
- packuswb mm2, mm2 ; mm2=(G0 G2 G4 G6 ** ** ** **)
- packuswb mm3, mm3 ; mm3=(G1 G3 G5 G7 ** ** ** **)
-
- paddw mm4, MMWORD [wk(0)] ; mm4=(YE+(B-Y)E)=BE=(B0 B2 B4 B6)
- paddw mm5, MMWORD [wk(1)] ; mm5=(YO+(B-Y)O)=BO=(B1 B3 B5 B7)
- packuswb mm4, mm4 ; mm4=(B0 B2 B4 B6 ** ** ** **)
- packuswb mm5, mm5 ; mm5=(B1 B3 B5 B7 ** ** ** **)
-
-%if RGB_PIXELSIZE == 3 ; ---------------
-
- ; mmA=(00 02 04 06 ** ** ** **), mmB=(01 03 05 07 ** ** ** **)
- ; mmC=(10 12 14 16 ** ** ** **), mmD=(11 13 15 17 ** ** ** **)
- ; mmE=(20 22 24 26 ** ** ** **), mmF=(21 23 25 27 ** ** ** **)
- ; mmG=(** ** ** ** ** ** ** **), mmH=(** ** ** ** ** ** ** **)
-
- punpcklbw mmA, mmC ; mmA=(00 10 02 12 04 14 06 16)
- punpcklbw mmE, mmB ; mmE=(20 01 22 03 24 05 26 07)
- punpcklbw mmD, mmF ; mmD=(11 21 13 23 15 25 17 27)
-
- movq mmG, mmA
- movq mmH, mmA
- punpcklwd mmA, mmE ; mmA=(00 10 20 01 02 12 22 03)
- punpckhwd mmG, mmE ; mmG=(04 14 24 05 06 16 26 07)
-
- psrlq mmH, 2*BYTE_BIT ; mmH=(02 12 04 14 06 16 -- --)
- psrlq mmE, 2*BYTE_BIT ; mmE=(22 03 24 05 26 07 -- --)
-
- movq mmC, mmD
- movq mmB, mmD
- punpcklwd mmD, mmH ; mmD=(11 21 02 12 13 23 04 14)
- punpckhwd mmC, mmH ; mmC=(15 25 06 16 17 27 -- --)
-
- psrlq mmB, 2*BYTE_BIT ; mmB=(13 23 15 25 17 27 -- --)
-
- movq mmF, mmE
- punpcklwd mmE, mmB ; mmE=(22 03 13 23 24 05 15 25)
- punpckhwd mmF, mmB ; mmF=(26 07 17 27 -- -- -- --)
-
- punpckldq mmA, mmD ; mmA=(00 10 20 01 11 21 02 12)
- punpckldq mmE, mmG ; mmE=(22 03 13 23 04 14 24 05)
- punpckldq mmC, mmF ; mmC=(15 25 06 16 26 07 17 27)
-
- cmp ecx, byte SIZEOF_MMWORD
- jb short .column_st16
-
- movq MMWORD [edi+0*SIZEOF_MMWORD], mmA
- movq MMWORD [edi+1*SIZEOF_MMWORD], mmE
- movq MMWORD [edi+2*SIZEOF_MMWORD], mmC
-
- sub ecx, byte SIZEOF_MMWORD
- jz short .nextrow
-
- add esi, byte SIZEOF_MMWORD ; inptr0
- add ebx, byte SIZEOF_MMWORD ; inptr1
- add edx, byte SIZEOF_MMWORD ; inptr2
- add edi, byte RGB_PIXELSIZE*SIZEOF_MMWORD ; outptr
- jmp near .columnloop
- alignx 16, 7
-
-.column_st16:
- lea ecx, [ecx+ecx*2] ; imul ecx, RGB_PIXELSIZE
- cmp ecx, byte 2*SIZEOF_MMWORD
- jb short .column_st8
- movq MMWORD [edi+0*SIZEOF_MMWORD], mmA
- movq MMWORD [edi+1*SIZEOF_MMWORD], mmE
- movq mmA, mmC
- sub ecx, byte 2*SIZEOF_MMWORD
- add edi, byte 2*SIZEOF_MMWORD
- jmp short .column_st4
-.column_st8:
- cmp ecx, byte SIZEOF_MMWORD
- jb short .column_st4
- movq MMWORD [edi+0*SIZEOF_MMWORD], mmA
- movq mmA, mmE
- sub ecx, byte SIZEOF_MMWORD
- add edi, byte SIZEOF_MMWORD
-.column_st4:
- movd eax, mmA
- cmp ecx, byte SIZEOF_DWORD
- jb short .column_st2
- mov dword [edi+0*SIZEOF_DWORD], eax
- psrlq mmA, DWORD_BIT
- movd eax, mmA
- sub ecx, byte SIZEOF_DWORD
- add edi, byte SIZEOF_DWORD
-.column_st2:
- cmp ecx, byte SIZEOF_WORD
- jb short .column_st1
- mov word [edi+0*SIZEOF_WORD], ax
- shr eax, WORD_BIT
- sub ecx, byte SIZEOF_WORD
- add edi, byte SIZEOF_WORD
-.column_st1:
- cmp ecx, byte SIZEOF_BYTE
- jb short .nextrow
- mov byte [edi+0*SIZEOF_BYTE], al
-
-%else ; RGB_PIXELSIZE == 4 ; -----------
-
-%ifdef RGBX_FILLER_0XFF
- pcmpeqb mm6, mm6 ; mm6=(X0 X2 X4 X6 ** ** ** **)
- pcmpeqb mm7, mm7 ; mm7=(X1 X3 X5 X7 ** ** ** **)
-%else
- pxor mm6, mm6 ; mm6=(X0 X2 X4 X6 ** ** ** **)
- pxor mm7, mm7 ; mm7=(X1 X3 X5 X7 ** ** ** **)
-%endif
- ; mmA=(00 02 04 06 ** ** ** **), mmB=(01 03 05 07 ** ** ** **)
- ; mmC=(10 12 14 16 ** ** ** **), mmD=(11 13 15 17 ** ** ** **)
- ; mmE=(20 22 24 26 ** ** ** **), mmF=(21 23 25 27 ** ** ** **)
- ; mmG=(30 32 34 36 ** ** ** **), mmH=(31 33 35 37 ** ** ** **)
-
- punpcklbw mmA, mmC ; mmA=(00 10 02 12 04 14 06 16)
- punpcklbw mmE, mmG ; mmE=(20 30 22 32 24 34 26 36)
- punpcklbw mmB, mmD ; mmB=(01 11 03 13 05 15 07 17)
- punpcklbw mmF, mmH ; mmF=(21 31 23 33 25 35 27 37)
-
- movq mmC, mmA
- punpcklwd mmA, mmE ; mmA=(00 10 20 30 02 12 22 32)
- punpckhwd mmC, mmE ; mmC=(04 14 24 34 06 16 26 36)
- movq mmG, mmB
- punpcklwd mmB, mmF ; mmB=(01 11 21 31 03 13 23 33)
- punpckhwd mmG, mmF ; mmG=(05 15 25 35 07 17 27 37)
-
- movq mmD, mmA
- punpckldq mmA, mmB ; mmA=(00 10 20 30 01 11 21 31)
- punpckhdq mmD, mmB ; mmD=(02 12 22 32 03 13 23 33)
- movq mmH, mmC
- punpckldq mmC, mmG ; mmC=(04 14 24 34 05 15 25 35)
- punpckhdq mmH, mmG ; mmH=(06 16 26 36 07 17 27 37)
-
- cmp ecx, byte SIZEOF_MMWORD
- jb short .column_st16
-
- movq MMWORD [edi+0*SIZEOF_MMWORD], mmA
- movq MMWORD [edi+1*SIZEOF_MMWORD], mmD
- movq MMWORD [edi+2*SIZEOF_MMWORD], mmC
- movq MMWORD [edi+3*SIZEOF_MMWORD], mmH
-
- sub ecx, byte SIZEOF_MMWORD
- jz short .nextrow
-
- add esi, byte SIZEOF_MMWORD ; inptr0
- add ebx, byte SIZEOF_MMWORD ; inptr1
- add edx, byte SIZEOF_MMWORD ; inptr2
- add edi, byte RGB_PIXELSIZE*SIZEOF_MMWORD ; outptr
- jmp near .columnloop
- alignx 16, 7
-
-.column_st16:
- cmp ecx, byte SIZEOF_MMWORD/2
- jb short .column_st8
- movq MMWORD [edi+0*SIZEOF_MMWORD], mmA
- movq MMWORD [edi+1*SIZEOF_MMWORD], mmD
- movq mmA, mmC
- movq mmD, mmH
- sub ecx, byte SIZEOF_MMWORD/2
- add edi, byte 2*SIZEOF_MMWORD
-.column_st8:
- cmp ecx, byte SIZEOF_MMWORD/4
- jb short .column_st4
- movq MMWORD [edi+0*SIZEOF_MMWORD], mmA
- movq mmA, mmD
- sub ecx, byte SIZEOF_MMWORD/4
- add edi, byte 1*SIZEOF_MMWORD
-.column_st4:
- cmp ecx, byte SIZEOF_MMWORD/8
- jb short .nextrow
- movd dword [edi+0*SIZEOF_DWORD], mmA
-
-%endif ; RGB_PIXELSIZE ; ---------------
-
- alignx 16, 7
-
-.nextrow:
- pop ecx
- pop esi
- pop ebx
- pop edx
- pop edi
- pop eax
-
- add esi, byte SIZEOF_JSAMPROW
- add ebx, byte SIZEOF_JSAMPROW
- add edx, byte SIZEOF_JSAMPROW
- add edi, byte SIZEOF_JSAMPROW ; output_buf
- dec eax ; num_rows
- jg near .rowloop
-
- emms ; empty MMX state
-
-.return:
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- pop ebx
- mov esp, ebp ; esp <- aligned ebp
- pop esp ; esp <- original ebp
- pop ebp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jdcolext-sse2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jdcolext-sse2.asm
deleted file mode 100644
index d5572b3294..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jdcolext-sse2.asm
+++ /dev/null
@@ -1,458 +0,0 @@
-;
-; jdcolext.asm - colorspace conversion (SSE2)
-;
-; Copyright 2009, 2012 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2012, 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jcolsamp.inc"
-
-; --------------------------------------------------------------------------
-;
-; Convert some rows of samples to the output colorspace.
-;
-; GLOBAL(void)
-; jsimd_ycc_rgb_convert_sse2(JDIMENSION out_width, JSAMPIMAGE input_buf,
-; JDIMENSION input_row, JSAMPARRAY output_buf,
-; int num_rows)
-;
-
-%define out_width(b) (b) + 8 ; JDIMENSION out_width
-%define input_buf(b) (b) + 12 ; JSAMPIMAGE input_buf
-%define input_row(b) (b) + 16 ; JDIMENSION input_row
-%define output_buf(b) (b) + 20 ; JSAMPARRAY output_buf
-%define num_rows(b) (b) + 24 ; int num_rows
-
-%define original_ebp ebp + 0
-%define wk(i) ebp - (WK_NUM - (i)) * SIZEOF_XMMWORD
- ; xmmword wk[WK_NUM]
-%define WK_NUM 2
-%define gotptr wk(0) - SIZEOF_POINTER ; void * gotptr
-
- align 32
- GLOBAL_FUNCTION(jsimd_ycc_rgb_convert_sse2)
-
-EXTN(jsimd_ycc_rgb_convert_sse2):
- push ebp
- mov eax, esp ; eax = original ebp
- sub esp, byte 4
- and esp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [esp], eax
- mov ebp, esp ; ebp = aligned ebp
- lea esp, [wk(0)]
- pushpic eax ; make a room for GOT address
- push ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- get_GOT ebx ; get GOT address
- movpic POINTER [gotptr], ebx ; save GOT address
-
- mov ecx, JDIMENSION [out_width(eax)] ; num_cols
- test ecx, ecx
- jz near .return
-
- push ecx
-
- mov edi, JSAMPIMAGE [input_buf(eax)]
- mov ecx, JDIMENSION [input_row(eax)]
- mov esi, JSAMPARRAY [edi+0*SIZEOF_JSAMPARRAY]
- mov ebx, JSAMPARRAY [edi+1*SIZEOF_JSAMPARRAY]
- mov edx, JSAMPARRAY [edi+2*SIZEOF_JSAMPARRAY]
- lea esi, [esi+ecx*SIZEOF_JSAMPROW]
- lea ebx, [ebx+ecx*SIZEOF_JSAMPROW]
- lea edx, [edx+ecx*SIZEOF_JSAMPROW]
-
- pop ecx
-
- mov edi, JSAMPARRAY [output_buf(eax)]
- mov eax, INT [num_rows(eax)]
- test eax, eax
- jle near .return
- alignx 16, 7
-.rowloop:
- push eax
- push edi
- push edx
- push ebx
- push esi
- push ecx ; col
-
- mov esi, JSAMPROW [esi] ; inptr0
- mov ebx, JSAMPROW [ebx] ; inptr1
- mov edx, JSAMPROW [edx] ; inptr2
- mov edi, JSAMPROW [edi] ; outptr
- movpic eax, POINTER [gotptr] ; load GOT address (eax)
- alignx 16, 7
-.columnloop:
-
- movdqa xmm5, XMMWORD [ebx] ; xmm5=Cb(0123456789ABCDEF)
- movdqa xmm1, XMMWORD [edx] ; xmm1=Cr(0123456789ABCDEF)
-
- pcmpeqw xmm4, xmm4
- pcmpeqw xmm7, xmm7
- psrlw xmm4, BYTE_BIT
- psllw xmm7, 7 ; xmm7={0xFF80 0xFF80 0xFF80 0xFF80 ..}
- movdqa xmm0, xmm4 ; xmm0=xmm4={0xFF 0x00 0xFF 0x00 ..}
-
- pand xmm4, xmm5 ; xmm4=Cb(02468ACE)=CbE
- psrlw xmm5, BYTE_BIT ; xmm5=Cb(13579BDF)=CbO
- pand xmm0, xmm1 ; xmm0=Cr(02468ACE)=CrE
- psrlw xmm1, BYTE_BIT ; xmm1=Cr(13579BDF)=CrO
-
- paddw xmm4, xmm7
- paddw xmm5, xmm7
- paddw xmm0, xmm7
- paddw xmm1, xmm7
-
- ; (Original)
- ; R = Y + 1.40200 * Cr
- ; G = Y - 0.34414 * Cb - 0.71414 * Cr
- ; B = Y + 1.77200 * Cb
- ;
- ; (This implementation)
- ; R = Y + 0.40200 * Cr + Cr
- ; G = Y - 0.34414 * Cb + 0.28586 * Cr - Cr
- ; B = Y - 0.22800 * Cb + Cb + Cb
-
- movdqa xmm2, xmm4 ; xmm2=CbE
- movdqa xmm3, xmm5 ; xmm3=CbO
- paddw xmm4, xmm4 ; xmm4=2*CbE
- paddw xmm5, xmm5 ; xmm5=2*CbO
- movdqa xmm6, xmm0 ; xmm6=CrE
- movdqa xmm7, xmm1 ; xmm7=CrO
- paddw xmm0, xmm0 ; xmm0=2*CrE
- paddw xmm1, xmm1 ; xmm1=2*CrO
-
- pmulhw xmm4, [GOTOFF(eax,PW_MF0228)] ; xmm4=(2*CbE * -FIX(0.22800))
- pmulhw xmm5, [GOTOFF(eax,PW_MF0228)] ; xmm5=(2*CbO * -FIX(0.22800))
- pmulhw xmm0, [GOTOFF(eax,PW_F0402)] ; xmm0=(2*CrE * FIX(0.40200))
- pmulhw xmm1, [GOTOFF(eax,PW_F0402)] ; xmm1=(2*CrO * FIX(0.40200))
-
- paddw xmm4, [GOTOFF(eax,PW_ONE)]
- paddw xmm5, [GOTOFF(eax,PW_ONE)]
- psraw xmm4, 1 ; xmm4=(CbE * -FIX(0.22800))
- psraw xmm5, 1 ; xmm5=(CbO * -FIX(0.22800))
- paddw xmm0, [GOTOFF(eax,PW_ONE)]
- paddw xmm1, [GOTOFF(eax,PW_ONE)]
- psraw xmm0, 1 ; xmm0=(CrE * FIX(0.40200))
- psraw xmm1, 1 ; xmm1=(CrO * FIX(0.40200))
-
- paddw xmm4, xmm2
- paddw xmm5, xmm3
- paddw xmm4, xmm2 ; xmm4=(CbE * FIX(1.77200))=(B-Y)E
- paddw xmm5, xmm3 ; xmm5=(CbO * FIX(1.77200))=(B-Y)O
- paddw xmm0, xmm6 ; xmm0=(CrE * FIX(1.40200))=(R-Y)E
- paddw xmm1, xmm7 ; xmm1=(CrO * FIX(1.40200))=(R-Y)O
-
- movdqa XMMWORD [wk(0)], xmm4 ; wk(0)=(B-Y)E
- movdqa XMMWORD [wk(1)], xmm5 ; wk(1)=(B-Y)O
-
- movdqa xmm4, xmm2
- movdqa xmm5, xmm3
- punpcklwd xmm2, xmm6
- punpckhwd xmm4, xmm6
- pmaddwd xmm2, [GOTOFF(eax,PW_MF0344_F0285)]
- pmaddwd xmm4, [GOTOFF(eax,PW_MF0344_F0285)]
- punpcklwd xmm3, xmm7
- punpckhwd xmm5, xmm7
- pmaddwd xmm3, [GOTOFF(eax,PW_MF0344_F0285)]
- pmaddwd xmm5, [GOTOFF(eax,PW_MF0344_F0285)]
-
- paddd xmm2, [GOTOFF(eax,PD_ONEHALF)]
- paddd xmm4, [GOTOFF(eax,PD_ONEHALF)]
- psrad xmm2, SCALEBITS
- psrad xmm4, SCALEBITS
- paddd xmm3, [GOTOFF(eax,PD_ONEHALF)]
- paddd xmm5, [GOTOFF(eax,PD_ONEHALF)]
- psrad xmm3, SCALEBITS
- psrad xmm5, SCALEBITS
-
- packssdw xmm2, xmm4 ; xmm2=CbE*-FIX(0.344)+CrE*FIX(0.285)
- packssdw xmm3, xmm5 ; xmm3=CbO*-FIX(0.344)+CrO*FIX(0.285)
- psubw xmm2, xmm6 ; xmm2=CbE*-FIX(0.344)+CrE*-FIX(0.714)=(G-Y)E
- psubw xmm3, xmm7 ; xmm3=CbO*-FIX(0.344)+CrO*-FIX(0.714)=(G-Y)O
-
- movdqa xmm5, XMMWORD [esi] ; xmm5=Y(0123456789ABCDEF)
-
- pcmpeqw xmm4, xmm4
- psrlw xmm4, BYTE_BIT ; xmm4={0xFF 0x00 0xFF 0x00 ..}
- pand xmm4, xmm5 ; xmm4=Y(02468ACE)=YE
- psrlw xmm5, BYTE_BIT ; xmm5=Y(13579BDF)=YO
-
- paddw xmm0, xmm4 ; xmm0=((R-Y)E+YE)=RE=R(02468ACE)
- paddw xmm1, xmm5 ; xmm1=((R-Y)O+YO)=RO=R(13579BDF)
- packuswb xmm0, xmm0 ; xmm0=R(02468ACE********)
- packuswb xmm1, xmm1 ; xmm1=R(13579BDF********)
-
- paddw xmm2, xmm4 ; xmm2=((G-Y)E+YE)=GE=G(02468ACE)
- paddw xmm3, xmm5 ; xmm3=((G-Y)O+YO)=GO=G(13579BDF)
- packuswb xmm2, xmm2 ; xmm2=G(02468ACE********)
- packuswb xmm3, xmm3 ; xmm3=G(13579BDF********)
-
- paddw xmm4, XMMWORD [wk(0)] ; xmm4=(YE+(B-Y)E)=BE=B(02468ACE)
- paddw xmm5, XMMWORD [wk(1)] ; xmm5=(YO+(B-Y)O)=BO=B(13579BDF)
- packuswb xmm4, xmm4 ; xmm4=B(02468ACE********)
- packuswb xmm5, xmm5 ; xmm5=B(13579BDF********)
-
-%if RGB_PIXELSIZE == 3 ; ---------------
-
- ; xmmA=(00 02 04 06 08 0A 0C 0E **), xmmB=(01 03 05 07 09 0B 0D 0F **)
- ; xmmC=(10 12 14 16 18 1A 1C 1E **), xmmD=(11 13 15 17 19 1B 1D 1F **)
- ; xmmE=(20 22 24 26 28 2A 2C 2E **), xmmF=(21 23 25 27 29 2B 2D 2F **)
- ; xmmG=(** ** ** ** ** ** ** ** **), xmmH=(** ** ** ** ** ** ** ** **)
-
- punpcklbw xmmA, xmmC ; xmmA=(00 10 02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E)
- punpcklbw xmmE, xmmB ; xmmE=(20 01 22 03 24 05 26 07 28 09 2A 0B 2C 0D 2E 0F)
- punpcklbw xmmD, xmmF ; xmmD=(11 21 13 23 15 25 17 27 19 29 1B 2B 1D 2D 1F 2F)
-
- movdqa xmmG, xmmA
- movdqa xmmH, xmmA
- punpcklwd xmmA, xmmE ; xmmA=(00 10 20 01 02 12 22 03 04 14 24 05 06 16 26 07)
- punpckhwd xmmG, xmmE ; xmmG=(08 18 28 09 0A 1A 2A 0B 0C 1C 2C 0D 0E 1E 2E 0F)
-
- psrldq xmmH, 2 ; xmmH=(02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E -- --)
- psrldq xmmE, 2 ; xmmE=(22 03 24 05 26 07 28 09 2A 0B 2C 0D 2E 0F -- --)
-
- movdqa xmmC, xmmD
- movdqa xmmB, xmmD
- punpcklwd xmmD, xmmH ; xmmD=(11 21 02 12 13 23 04 14 15 25 06 16 17 27 08 18)
- punpckhwd xmmC, xmmH ; xmmC=(19 29 0A 1A 1B 2B 0C 1C 1D 2D 0E 1E 1F 2F -- --)
-
- psrldq xmmB, 2 ; xmmB=(13 23 15 25 17 27 19 29 1B 2B 1D 2D 1F 2F -- --)
-
- movdqa xmmF, xmmE
- punpcklwd xmmE, xmmB ; xmmE=(22 03 13 23 24 05 15 25 26 07 17 27 28 09 19 29)
- punpckhwd xmmF, xmmB ; xmmF=(2A 0B 1B 2B 2C 0D 1D 2D 2E 0F 1F 2F -- -- -- --)
-
- pshufd xmmH, xmmA, 0x4E ; xmmH=(04 14 24 05 06 16 26 07 00 10 20 01 02 12 22 03)
- movdqa xmmB, xmmE
- punpckldq xmmA, xmmD ; xmmA=(00 10 20 01 11 21 02 12 02 12 22 03 13 23 04 14)
- punpckldq xmmE, xmmH ; xmmE=(22 03 13 23 04 14 24 05 24 05 15 25 06 16 26 07)
- punpckhdq xmmD, xmmB ; xmmD=(15 25 06 16 26 07 17 27 17 27 08 18 28 09 19 29)
-
- pshufd xmmH, xmmG, 0x4E ; xmmH=(0C 1C 2C 0D 0E 1E 2E 0F 08 18 28 09 0A 1A 2A 0B)
- movdqa xmmB, xmmF
- punpckldq xmmG, xmmC ; xmmG=(08 18 28 09 19 29 0A 1A 0A 1A 2A 0B 1B 2B 0C 1C)
- punpckldq xmmF, xmmH ; xmmF=(2A 0B 1B 2B 0C 1C 2C 0D 2C 0D 1D 2D 0E 1E 2E 0F)
- punpckhdq xmmC, xmmB ; xmmC=(1D 2D 0E 1E 2E 0F 1F 2F 1F 2F -- -- -- -- -- --)
-
- punpcklqdq xmmA, xmmE ; xmmA=(00 10 20 01 11 21 02 12 22 03 13 23 04 14 24 05)
- punpcklqdq xmmD, xmmG ; xmmD=(15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A)
- punpcklqdq xmmF, xmmC ; xmmF=(2A 0B 1B 2B 0C 1C 2C 0D 1D 2D 0E 1E 2E 0F 1F 2F)
-
- cmp ecx, byte SIZEOF_XMMWORD
- jb short .column_st32
-
- test edi, SIZEOF_XMMWORD-1
- jnz short .out1
- ; --(aligned)-------------------
- movntdq XMMWORD [edi+0*SIZEOF_XMMWORD], xmmA
- movntdq XMMWORD [edi+1*SIZEOF_XMMWORD], xmmD
- movntdq XMMWORD [edi+2*SIZEOF_XMMWORD], xmmF
- jmp short .out0
-.out1: ; --(unaligned)-----------------
- movdqu XMMWORD [edi+0*SIZEOF_XMMWORD], xmmA
- movdqu XMMWORD [edi+1*SIZEOF_XMMWORD], xmmD
- movdqu XMMWORD [edi+2*SIZEOF_XMMWORD], xmmF
-.out0:
- add edi, byte RGB_PIXELSIZE*SIZEOF_XMMWORD ; outptr
- sub ecx, byte SIZEOF_XMMWORD
- jz near .nextrow
-
- add esi, byte SIZEOF_XMMWORD ; inptr0
- add ebx, byte SIZEOF_XMMWORD ; inptr1
- add edx, byte SIZEOF_XMMWORD ; inptr2
- jmp near .columnloop
- alignx 16, 7
-
-.column_st32:
- lea ecx, [ecx+ecx*2] ; imul ecx, RGB_PIXELSIZE
- cmp ecx, byte 2*SIZEOF_XMMWORD
- jb short .column_st16
- movdqu XMMWORD [edi+0*SIZEOF_XMMWORD], xmmA
- movdqu XMMWORD [edi+1*SIZEOF_XMMWORD], xmmD
- add edi, byte 2*SIZEOF_XMMWORD ; outptr
- movdqa xmmA, xmmF
- sub ecx, byte 2*SIZEOF_XMMWORD
- jmp short .column_st15
-.column_st16:
- cmp ecx, byte SIZEOF_XMMWORD
- jb short .column_st15
- movdqu XMMWORD [edi+0*SIZEOF_XMMWORD], xmmA
- add edi, byte SIZEOF_XMMWORD ; outptr
- movdqa xmmA, xmmD
- sub ecx, byte SIZEOF_XMMWORD
-.column_st15:
- ; Store the lower 8 bytes of xmmA to the output when it has enough
- ; space.
- cmp ecx, byte SIZEOF_MMWORD
- jb short .column_st7
- movq XMM_MMWORD [edi], xmmA
- add edi, byte SIZEOF_MMWORD
- sub ecx, byte SIZEOF_MMWORD
- psrldq xmmA, SIZEOF_MMWORD
-.column_st7:
- ; Store the lower 4 bytes of xmmA to the output when it has enough
- ; space.
- cmp ecx, byte SIZEOF_DWORD
- jb short .column_st3
- movd XMM_DWORD [edi], xmmA
- add edi, byte SIZEOF_DWORD
- sub ecx, byte SIZEOF_DWORD
- psrldq xmmA, SIZEOF_DWORD
-.column_st3:
- ; Store the lower 2 bytes of eax to the output when it has enough
- ; space.
- movd eax, xmmA
- cmp ecx, byte SIZEOF_WORD
- jb short .column_st1
- mov word [edi], ax
- add edi, byte SIZEOF_WORD
- sub ecx, byte SIZEOF_WORD
- shr eax, 16
-.column_st1:
- ; Store the lower 1 byte of eax to the output when it has enough
- ; space.
- test ecx, ecx
- jz short .nextrow
- mov byte [edi], al
-
-%else ; RGB_PIXELSIZE == 4 ; -----------
-
-%ifdef RGBX_FILLER_0XFF
- pcmpeqb xmm6, xmm6 ; xmm6=XE=X(02468ACE********)
- pcmpeqb xmm7, xmm7 ; xmm7=XO=X(13579BDF********)
-%else
- pxor xmm6, xmm6 ; xmm6=XE=X(02468ACE********)
- pxor xmm7, xmm7 ; xmm7=XO=X(13579BDF********)
-%endif
- ; xmmA=(00 02 04 06 08 0A 0C 0E **), xmmB=(01 03 05 07 09 0B 0D 0F **)
- ; xmmC=(10 12 14 16 18 1A 1C 1E **), xmmD=(11 13 15 17 19 1B 1D 1F **)
- ; xmmE=(20 22 24 26 28 2A 2C 2E **), xmmF=(21 23 25 27 29 2B 2D 2F **)
- ; xmmG=(30 32 34 36 38 3A 3C 3E **), xmmH=(31 33 35 37 39 3B 3D 3F **)
-
- punpcklbw xmmA, xmmC ; xmmA=(00 10 02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E)
- punpcklbw xmmE, xmmG ; xmmE=(20 30 22 32 24 34 26 36 28 38 2A 3A 2C 3C 2E 3E)
- punpcklbw xmmB, xmmD ; xmmB=(01 11 03 13 05 15 07 17 09 19 0B 1B 0D 1D 0F 1F)
- punpcklbw xmmF, xmmH ; xmmF=(21 31 23 33 25 35 27 37 29 39 2B 3B 2D 3D 2F 3F)
-
- movdqa xmmC, xmmA
- punpcklwd xmmA, xmmE ; xmmA=(00 10 20 30 02 12 22 32 04 14 24 34 06 16 26 36)
- punpckhwd xmmC, xmmE ; xmmC=(08 18 28 38 0A 1A 2A 3A 0C 1C 2C 3C 0E 1E 2E 3E)
- movdqa xmmG, xmmB
- punpcklwd xmmB, xmmF ; xmmB=(01 11 21 31 03 13 23 33 05 15 25 35 07 17 27 37)
- punpckhwd xmmG, xmmF ; xmmG=(09 19 29 39 0B 1B 2B 3B 0D 1D 2D 3D 0F 1F 2F 3F)
-
- movdqa xmmD, xmmA
- punpckldq xmmA, xmmB ; xmmA=(00 10 20 30 01 11 21 31 02 12 22 32 03 13 23 33)
- punpckhdq xmmD, xmmB ; xmmD=(04 14 24 34 05 15 25 35 06 16 26 36 07 17 27 37)
- movdqa xmmH, xmmC
- punpckldq xmmC, xmmG ; xmmC=(08 18 28 38 09 19 29 39 0A 1A 2A 3A 0B 1B 2B 3B)
- punpckhdq xmmH, xmmG ; xmmH=(0C 1C 2C 3C 0D 1D 2D 3D 0E 1E 2E 3E 0F 1F 2F 3F)
-
- cmp ecx, byte SIZEOF_XMMWORD
- jb short .column_st32
-
- test edi, SIZEOF_XMMWORD-1
- jnz short .out1
- ; --(aligned)-------------------
- movntdq XMMWORD [edi+0*SIZEOF_XMMWORD], xmmA
- movntdq XMMWORD [edi+1*SIZEOF_XMMWORD], xmmD
- movntdq XMMWORD [edi+2*SIZEOF_XMMWORD], xmmC
- movntdq XMMWORD [edi+3*SIZEOF_XMMWORD], xmmH
- jmp short .out0
-.out1: ; --(unaligned)-----------------
- movdqu XMMWORD [edi+0*SIZEOF_XMMWORD], xmmA
- movdqu XMMWORD [edi+1*SIZEOF_XMMWORD], xmmD
- movdqu XMMWORD [edi+2*SIZEOF_XMMWORD], xmmC
- movdqu XMMWORD [edi+3*SIZEOF_XMMWORD], xmmH
-.out0:
- add edi, byte RGB_PIXELSIZE*SIZEOF_XMMWORD ; outptr
- sub ecx, byte SIZEOF_XMMWORD
- jz near .nextrow
-
- add esi, byte SIZEOF_XMMWORD ; inptr0
- add ebx, byte SIZEOF_XMMWORD ; inptr1
- add edx, byte SIZEOF_XMMWORD ; inptr2
- jmp near .columnloop
- alignx 16, 7
-
-.column_st32:
- cmp ecx, byte SIZEOF_XMMWORD/2
- jb short .column_st16
- movdqu XMMWORD [edi+0*SIZEOF_XMMWORD], xmmA
- movdqu XMMWORD [edi+1*SIZEOF_XMMWORD], xmmD
- add edi, byte 2*SIZEOF_XMMWORD ; outptr
- movdqa xmmA, xmmC
- movdqa xmmD, xmmH
- sub ecx, byte SIZEOF_XMMWORD/2
-.column_st16:
- cmp ecx, byte SIZEOF_XMMWORD/4
- jb short .column_st15
- movdqu XMMWORD [edi+0*SIZEOF_XMMWORD], xmmA
- add edi, byte SIZEOF_XMMWORD ; outptr
- movdqa xmmA, xmmD
- sub ecx, byte SIZEOF_XMMWORD/4
-.column_st15:
- ; Store two pixels (8 bytes) of xmmA to the output when it has enough
- ; space.
- cmp ecx, byte SIZEOF_XMMWORD/8
- jb short .column_st7
- movq XMM_MMWORD [edi], xmmA
- add edi, byte SIZEOF_XMMWORD/8*4
- sub ecx, byte SIZEOF_XMMWORD/8
- psrldq xmmA, SIZEOF_XMMWORD/8*4
-.column_st7:
- ; Store one pixel (4 bytes) of xmmA to the output when it has enough
- ; space.
- test ecx, ecx
- jz short .nextrow
- movd XMM_DWORD [edi], xmmA
-
-%endif ; RGB_PIXELSIZE ; ---------------
-
- alignx 16, 7
-
-.nextrow:
- pop ecx
- pop esi
- pop ebx
- pop edx
- pop edi
- pop eax
-
- add esi, byte SIZEOF_JSAMPROW
- add ebx, byte SIZEOF_JSAMPROW
- add edx, byte SIZEOF_JSAMPROW
- add edi, byte SIZEOF_JSAMPROW ; output_buf
- dec eax ; num_rows
- jg near .rowloop
-
- sfence ; flush the write buffer
-
-.return:
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- pop ebx
- mov esp, ebp ; esp <- aligned ebp
- pop esp ; esp <- original ebp
- pop ebp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jdcolor-avx2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jdcolor-avx2.asm
deleted file mode 100644
index e05b60d001..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jdcolor-avx2.asm
+++ /dev/null
@@ -1,118 +0,0 @@
-;
-; jdcolor.asm - colorspace conversion (AVX2)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2015, Intel Corporation.
-; Copyright (C) 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jsimdext.inc"
-
-; --------------------------------------------------------------------------
-
-%define SCALEBITS 16
-
-F_0_344 equ 22554 ; FIX(0.34414)
-F_0_714 equ 46802 ; FIX(0.71414)
-F_1_402 equ 91881 ; FIX(1.40200)
-F_1_772 equ 116130 ; FIX(1.77200)
-F_0_402 equ (F_1_402 - 65536) ; FIX(1.40200) - FIX(1)
-F_0_285 equ ( 65536 - F_0_714) ; FIX(1) - FIX(0.71414)
-F_0_228 equ (131072 - F_1_772) ; FIX(2) - FIX(1.77200)
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_ycc_rgb_convert_avx2)
-
-EXTN(jconst_ycc_rgb_convert_avx2):
-
-PW_F0402 times 16 dw F_0_402
-PW_MF0228 times 16 dw -F_0_228
-PW_MF0344_F0285 times 8 dw -F_0_344, F_0_285
-PW_ONE times 16 dw 1
-PD_ONEHALF times 8 dd 1 << (SCALEBITS - 1)
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-
-%include "jdcolext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_RGB_RED
-%define RGB_GREEN EXT_RGB_GREEN
-%define RGB_BLUE EXT_RGB_BLUE
-%define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
-%define jsimd_ycc_rgb_convert_avx2 jsimd_ycc_extrgb_convert_avx2
-%include "jdcolext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_RGBX_RED
-%define RGB_GREEN EXT_RGBX_GREEN
-%define RGB_BLUE EXT_RGBX_BLUE
-%define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
-%define jsimd_ycc_rgb_convert_avx2 jsimd_ycc_extrgbx_convert_avx2
-%include "jdcolext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_BGR_RED
-%define RGB_GREEN EXT_BGR_GREEN
-%define RGB_BLUE EXT_BGR_BLUE
-%define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
-%define jsimd_ycc_rgb_convert_avx2 jsimd_ycc_extbgr_convert_avx2
-%include "jdcolext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_BGRX_RED
-%define RGB_GREEN EXT_BGRX_GREEN
-%define RGB_BLUE EXT_BGRX_BLUE
-%define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
-%define jsimd_ycc_rgb_convert_avx2 jsimd_ycc_extbgrx_convert_avx2
-%include "jdcolext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_XBGR_RED
-%define RGB_GREEN EXT_XBGR_GREEN
-%define RGB_BLUE EXT_XBGR_BLUE
-%define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
-%define jsimd_ycc_rgb_convert_avx2 jsimd_ycc_extxbgr_convert_avx2
-%include "jdcolext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_XRGB_RED
-%define RGB_GREEN EXT_XRGB_GREEN
-%define RGB_BLUE EXT_XRGB_BLUE
-%define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
-%define jsimd_ycc_rgb_convert_avx2 jsimd_ycc_extxrgb_convert_avx2
-%include "jdcolext-avx2.asm"
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jdcolor-mmx.asm b/contrib/libs/libjpeg-turbo/simd/i386/jdcolor-mmx.asm
deleted file mode 100644
index fb7e7bcce4..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jdcolor-mmx.asm
+++ /dev/null
@@ -1,117 +0,0 @@
-;
-; jdcolor.asm - colorspace conversion (MMX)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jsimdext.inc"
-
-; --------------------------------------------------------------------------
-
-%define SCALEBITS 16
-
-F_0_344 equ 22554 ; FIX(0.34414)
-F_0_714 equ 46802 ; FIX(0.71414)
-F_1_402 equ 91881 ; FIX(1.40200)
-F_1_772 equ 116130 ; FIX(1.77200)
-F_0_402 equ (F_1_402 - 65536) ; FIX(1.40200) - FIX(1)
-F_0_285 equ ( 65536 - F_0_714) ; FIX(1) - FIX(0.71414)
-F_0_228 equ (131072 - F_1_772) ; FIX(2) - FIX(1.77200)
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_ycc_rgb_convert_mmx)
-
-EXTN(jconst_ycc_rgb_convert_mmx):
-
-PW_F0402 times 4 dw F_0_402
-PW_MF0228 times 4 dw -F_0_228
-PW_MF0344_F0285 times 2 dw -F_0_344, F_0_285
-PW_ONE times 4 dw 1
-PD_ONEHALF times 2 dd 1 << (SCALEBITS - 1)
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-
-%include "jdcolext-mmx.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_RGB_RED
-%define RGB_GREEN EXT_RGB_GREEN
-%define RGB_BLUE EXT_RGB_BLUE
-%define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
-%define jsimd_ycc_rgb_convert_mmx jsimd_ycc_extrgb_convert_mmx
-%include "jdcolext-mmx.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_RGBX_RED
-%define RGB_GREEN EXT_RGBX_GREEN
-%define RGB_BLUE EXT_RGBX_BLUE
-%define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
-%define jsimd_ycc_rgb_convert_mmx jsimd_ycc_extrgbx_convert_mmx
-%include "jdcolext-mmx.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_BGR_RED
-%define RGB_GREEN EXT_BGR_GREEN
-%define RGB_BLUE EXT_BGR_BLUE
-%define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
-%define jsimd_ycc_rgb_convert_mmx jsimd_ycc_extbgr_convert_mmx
-%include "jdcolext-mmx.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_BGRX_RED
-%define RGB_GREEN EXT_BGRX_GREEN
-%define RGB_BLUE EXT_BGRX_BLUE
-%define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
-%define jsimd_ycc_rgb_convert_mmx jsimd_ycc_extbgrx_convert_mmx
-%include "jdcolext-mmx.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_XBGR_RED
-%define RGB_GREEN EXT_XBGR_GREEN
-%define RGB_BLUE EXT_XBGR_BLUE
-%define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
-%define jsimd_ycc_rgb_convert_mmx jsimd_ycc_extxbgr_convert_mmx
-%include "jdcolext-mmx.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_XRGB_RED
-%define RGB_GREEN EXT_XRGB_GREEN
-%define RGB_BLUE EXT_XRGB_BLUE
-%define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
-%define jsimd_ycc_rgb_convert_mmx jsimd_ycc_extxrgb_convert_mmx
-%include "jdcolext-mmx.asm"
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jdcolor-sse2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jdcolor-sse2.asm
deleted file mode 100644
index b736255317..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jdcolor-sse2.asm
+++ /dev/null
@@ -1,117 +0,0 @@
-;
-; jdcolor.asm - colorspace conversion (SSE2)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jsimdext.inc"
-
-; --------------------------------------------------------------------------
-
-%define SCALEBITS 16
-
-F_0_344 equ 22554 ; FIX(0.34414)
-F_0_714 equ 46802 ; FIX(0.71414)
-F_1_402 equ 91881 ; FIX(1.40200)
-F_1_772 equ 116130 ; FIX(1.77200)
-F_0_402 equ (F_1_402 - 65536) ; FIX(1.40200) - FIX(1)
-F_0_285 equ ( 65536 - F_0_714) ; FIX(1) - FIX(0.71414)
-F_0_228 equ (131072 - F_1_772) ; FIX(2) - FIX(1.77200)
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_ycc_rgb_convert_sse2)
-
-EXTN(jconst_ycc_rgb_convert_sse2):
-
-PW_F0402 times 8 dw F_0_402
-PW_MF0228 times 8 dw -F_0_228
-PW_MF0344_F0285 times 4 dw -F_0_344, F_0_285
-PW_ONE times 8 dw 1
-PD_ONEHALF times 4 dd 1 << (SCALEBITS - 1)
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-
-%include "jdcolext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_RGB_RED
-%define RGB_GREEN EXT_RGB_GREEN
-%define RGB_BLUE EXT_RGB_BLUE
-%define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
-%define jsimd_ycc_rgb_convert_sse2 jsimd_ycc_extrgb_convert_sse2
-%include "jdcolext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_RGBX_RED
-%define RGB_GREEN EXT_RGBX_GREEN
-%define RGB_BLUE EXT_RGBX_BLUE
-%define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
-%define jsimd_ycc_rgb_convert_sse2 jsimd_ycc_extrgbx_convert_sse2
-%include "jdcolext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_BGR_RED
-%define RGB_GREEN EXT_BGR_GREEN
-%define RGB_BLUE EXT_BGR_BLUE
-%define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
-%define jsimd_ycc_rgb_convert_sse2 jsimd_ycc_extbgr_convert_sse2
-%include "jdcolext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_BGRX_RED
-%define RGB_GREEN EXT_BGRX_GREEN
-%define RGB_BLUE EXT_BGRX_BLUE
-%define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
-%define jsimd_ycc_rgb_convert_sse2 jsimd_ycc_extbgrx_convert_sse2
-%include "jdcolext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_XBGR_RED
-%define RGB_GREEN EXT_XBGR_GREEN
-%define RGB_BLUE EXT_XBGR_BLUE
-%define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
-%define jsimd_ycc_rgb_convert_sse2 jsimd_ycc_extxbgr_convert_sse2
-%include "jdcolext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_XRGB_RED
-%define RGB_GREEN EXT_XRGB_GREEN
-%define RGB_BLUE EXT_XRGB_BLUE
-%define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
-%define jsimd_ycc_rgb_convert_sse2 jsimd_ycc_extxrgb_convert_sse2
-%include "jdcolext-sse2.asm"
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jdmerge-avx2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jdmerge-avx2.asm
deleted file mode 100644
index 711e6792d0..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jdmerge-avx2.asm
+++ /dev/null
@@ -1,136 +0,0 @@
-;
-; jdmerge.asm - merged upsampling/color conversion (AVX2)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
-; Copyright (C) 2015, Intel Corporation.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jsimdext.inc"
-
-; --------------------------------------------------------------------------
-
-%define SCALEBITS 16
-
-F_0_344 equ 22554 ; FIX(0.34414)
-F_0_714 equ 46802 ; FIX(0.71414)
-F_1_402 equ 91881 ; FIX(1.40200)
-F_1_772 equ 116130 ; FIX(1.77200)
-F_0_402 equ (F_1_402 - 65536) ; FIX(1.40200) - FIX(1)
-F_0_285 equ ( 65536 - F_0_714) ; FIX(1) - FIX(0.71414)
-F_0_228 equ (131072 - F_1_772) ; FIX(2) - FIX(1.77200)
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_merged_upsample_avx2)
-
-EXTN(jconst_merged_upsample_avx2):
-
-PW_F0402 times 16 dw F_0_402
-PW_MF0228 times 16 dw -F_0_228
-PW_MF0344_F0285 times 8 dw -F_0_344, F_0_285
-PW_ONE times 16 dw 1
-PD_ONEHALF times 8 dd 1 << (SCALEBITS - 1)
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-
-%include "jdmrgext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_RGB_RED
-%define RGB_GREEN EXT_RGB_GREEN
-%define RGB_BLUE EXT_RGB_BLUE
-%define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
-%define jsimd_h2v1_merged_upsample_avx2 \
- jsimd_h2v1_extrgb_merged_upsample_avx2
-%define jsimd_h2v2_merged_upsample_avx2 \
- jsimd_h2v2_extrgb_merged_upsample_avx2
-%include "jdmrgext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_RGBX_RED
-%define RGB_GREEN EXT_RGBX_GREEN
-%define RGB_BLUE EXT_RGBX_BLUE
-%define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
-%define jsimd_h2v1_merged_upsample_avx2 \
- jsimd_h2v1_extrgbx_merged_upsample_avx2
-%define jsimd_h2v2_merged_upsample_avx2 \
- jsimd_h2v2_extrgbx_merged_upsample_avx2
-%include "jdmrgext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_BGR_RED
-%define RGB_GREEN EXT_BGR_GREEN
-%define RGB_BLUE EXT_BGR_BLUE
-%define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
-%define jsimd_h2v1_merged_upsample_avx2 \
- jsimd_h2v1_extbgr_merged_upsample_avx2
-%define jsimd_h2v2_merged_upsample_avx2 \
- jsimd_h2v2_extbgr_merged_upsample_avx2
-%include "jdmrgext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_BGRX_RED
-%define RGB_GREEN EXT_BGRX_GREEN
-%define RGB_BLUE EXT_BGRX_BLUE
-%define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
-%define jsimd_h2v1_merged_upsample_avx2 \
- jsimd_h2v1_extbgrx_merged_upsample_avx2
-%define jsimd_h2v2_merged_upsample_avx2 \
- jsimd_h2v2_extbgrx_merged_upsample_avx2
-%include "jdmrgext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_XBGR_RED
-%define RGB_GREEN EXT_XBGR_GREEN
-%define RGB_BLUE EXT_XBGR_BLUE
-%define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
-%define jsimd_h2v1_merged_upsample_avx2 \
- jsimd_h2v1_extxbgr_merged_upsample_avx2
-%define jsimd_h2v2_merged_upsample_avx2 \
- jsimd_h2v2_extxbgr_merged_upsample_avx2
-%include "jdmrgext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_XRGB_RED
-%define RGB_GREEN EXT_XRGB_GREEN
-%define RGB_BLUE EXT_XRGB_BLUE
-%define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
-%define jsimd_h2v1_merged_upsample_avx2 \
- jsimd_h2v1_extxrgb_merged_upsample_avx2
-%define jsimd_h2v2_merged_upsample_avx2 \
- jsimd_h2v2_extxrgb_merged_upsample_avx2
-%include "jdmrgext-avx2.asm"
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jdmerge-mmx.asm b/contrib/libs/libjpeg-turbo/simd/i386/jdmerge-mmx.asm
deleted file mode 100644
index 6e8311d408..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jdmerge-mmx.asm
+++ /dev/null
@@ -1,123 +0,0 @@
-;
-; jdmerge.asm - merged upsampling/color conversion (MMX)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jsimdext.inc"
-
-; --------------------------------------------------------------------------
-
-%define SCALEBITS 16
-
-F_0_344 equ 22554 ; FIX(0.34414)
-F_0_714 equ 46802 ; FIX(0.71414)
-F_1_402 equ 91881 ; FIX(1.40200)
-F_1_772 equ 116130 ; FIX(1.77200)
-F_0_402 equ (F_1_402 - 65536) ; FIX(1.40200) - FIX(1)
-F_0_285 equ ( 65536 - F_0_714) ; FIX(1) - FIX(0.71414)
-F_0_228 equ (131072 - F_1_772) ; FIX(2) - FIX(1.77200)
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_merged_upsample_mmx)
-
-EXTN(jconst_merged_upsample_mmx):
-
-PW_F0402 times 4 dw F_0_402
-PW_MF0228 times 4 dw -F_0_228
-PW_MF0344_F0285 times 2 dw -F_0_344, F_0_285
-PW_ONE times 4 dw 1
-PD_ONEHALF times 2 dd 1 << (SCALEBITS - 1)
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-
-%include "jdmrgext-mmx.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_RGB_RED
-%define RGB_GREEN EXT_RGB_GREEN
-%define RGB_BLUE EXT_RGB_BLUE
-%define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
-%define jsimd_h2v1_merged_upsample_mmx jsimd_h2v1_extrgb_merged_upsample_mmx
-%define jsimd_h2v2_merged_upsample_mmx jsimd_h2v2_extrgb_merged_upsample_mmx
-%include "jdmrgext-mmx.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_RGBX_RED
-%define RGB_GREEN EXT_RGBX_GREEN
-%define RGB_BLUE EXT_RGBX_BLUE
-%define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
-%define jsimd_h2v1_merged_upsample_mmx jsimd_h2v1_extrgbx_merged_upsample_mmx
-%define jsimd_h2v2_merged_upsample_mmx jsimd_h2v2_extrgbx_merged_upsample_mmx
-%include "jdmrgext-mmx.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_BGR_RED
-%define RGB_GREEN EXT_BGR_GREEN
-%define RGB_BLUE EXT_BGR_BLUE
-%define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
-%define jsimd_h2v1_merged_upsample_mmx jsimd_h2v1_extbgr_merged_upsample_mmx
-%define jsimd_h2v2_merged_upsample_mmx jsimd_h2v2_extbgr_merged_upsample_mmx
-%include "jdmrgext-mmx.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_BGRX_RED
-%define RGB_GREEN EXT_BGRX_GREEN
-%define RGB_BLUE EXT_BGRX_BLUE
-%define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
-%define jsimd_h2v1_merged_upsample_mmx jsimd_h2v1_extbgrx_merged_upsample_mmx
-%define jsimd_h2v2_merged_upsample_mmx jsimd_h2v2_extbgrx_merged_upsample_mmx
-%include "jdmrgext-mmx.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_XBGR_RED
-%define RGB_GREEN EXT_XBGR_GREEN
-%define RGB_BLUE EXT_XBGR_BLUE
-%define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
-%define jsimd_h2v1_merged_upsample_mmx jsimd_h2v1_extxbgr_merged_upsample_mmx
-%define jsimd_h2v2_merged_upsample_mmx jsimd_h2v2_extxbgr_merged_upsample_mmx
-%include "jdmrgext-mmx.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_XRGB_RED
-%define RGB_GREEN EXT_XRGB_GREEN
-%define RGB_BLUE EXT_XRGB_BLUE
-%define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
-%define jsimd_h2v1_merged_upsample_mmx jsimd_h2v1_extxrgb_merged_upsample_mmx
-%define jsimd_h2v2_merged_upsample_mmx jsimd_h2v2_extxrgb_merged_upsample_mmx
-%include "jdmrgext-mmx.asm"
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jdmerge-sse2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jdmerge-sse2.asm
deleted file mode 100644
index e32f90aa17..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jdmerge-sse2.asm
+++ /dev/null
@@ -1,135 +0,0 @@
-;
-; jdmerge.asm - merged upsampling/color conversion (SSE2)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jsimdext.inc"
-
-; --------------------------------------------------------------------------
-
-%define SCALEBITS 16
-
-F_0_344 equ 22554 ; FIX(0.34414)
-F_0_714 equ 46802 ; FIX(0.71414)
-F_1_402 equ 91881 ; FIX(1.40200)
-F_1_772 equ 116130 ; FIX(1.77200)
-F_0_402 equ (F_1_402 - 65536) ; FIX(1.40200) - FIX(1)
-F_0_285 equ ( 65536 - F_0_714) ; FIX(1) - FIX(0.71414)
-F_0_228 equ (131072 - F_1_772) ; FIX(2) - FIX(1.77200)
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_merged_upsample_sse2)
-
-EXTN(jconst_merged_upsample_sse2):
-
-PW_F0402 times 8 dw F_0_402
-PW_MF0228 times 8 dw -F_0_228
-PW_MF0344_F0285 times 4 dw -F_0_344, F_0_285
-PW_ONE times 8 dw 1
-PD_ONEHALF times 4 dd 1 << (SCALEBITS - 1)
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-
-%include "jdmrgext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_RGB_RED
-%define RGB_GREEN EXT_RGB_GREEN
-%define RGB_BLUE EXT_RGB_BLUE
-%define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
-%define jsimd_h2v1_merged_upsample_sse2 \
- jsimd_h2v1_extrgb_merged_upsample_sse2
-%define jsimd_h2v2_merged_upsample_sse2 \
- jsimd_h2v2_extrgb_merged_upsample_sse2
-%include "jdmrgext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_RGBX_RED
-%define RGB_GREEN EXT_RGBX_GREEN
-%define RGB_BLUE EXT_RGBX_BLUE
-%define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
-%define jsimd_h2v1_merged_upsample_sse2 \
- jsimd_h2v1_extrgbx_merged_upsample_sse2
-%define jsimd_h2v2_merged_upsample_sse2 \
- jsimd_h2v2_extrgbx_merged_upsample_sse2
-%include "jdmrgext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_BGR_RED
-%define RGB_GREEN EXT_BGR_GREEN
-%define RGB_BLUE EXT_BGR_BLUE
-%define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
-%define jsimd_h2v1_merged_upsample_sse2 \
- jsimd_h2v1_extbgr_merged_upsample_sse2
-%define jsimd_h2v2_merged_upsample_sse2 \
- jsimd_h2v2_extbgr_merged_upsample_sse2
-%include "jdmrgext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_BGRX_RED
-%define RGB_GREEN EXT_BGRX_GREEN
-%define RGB_BLUE EXT_BGRX_BLUE
-%define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
-%define jsimd_h2v1_merged_upsample_sse2 \
- jsimd_h2v1_extbgrx_merged_upsample_sse2
-%define jsimd_h2v2_merged_upsample_sse2 \
- jsimd_h2v2_extbgrx_merged_upsample_sse2
-%include "jdmrgext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_XBGR_RED
-%define RGB_GREEN EXT_XBGR_GREEN
-%define RGB_BLUE EXT_XBGR_BLUE
-%define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
-%define jsimd_h2v1_merged_upsample_sse2 \
- jsimd_h2v1_extxbgr_merged_upsample_sse2
-%define jsimd_h2v2_merged_upsample_sse2 \
- jsimd_h2v2_extxbgr_merged_upsample_sse2
-%include "jdmrgext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_XRGB_RED
-%define RGB_GREEN EXT_XRGB_GREEN
-%define RGB_BLUE EXT_XRGB_BLUE
-%define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
-%define jsimd_h2v1_merged_upsample_sse2 \
- jsimd_h2v1_extxrgb_merged_upsample_sse2
-%define jsimd_h2v2_merged_upsample_sse2 \
- jsimd_h2v2_extxrgb_merged_upsample_sse2
-%include "jdmrgext-sse2.asm"
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jdmrgext-avx2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jdmrgext-avx2.asm
deleted file mode 100644
index e35f7282bc..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jdmrgext-avx2.asm
+++ /dev/null
@@ -1,575 +0,0 @@
-;
-; jdmrgext.asm - merged upsampling/color conversion (AVX2)
-;
-; Copyright 2009, 2012 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2012, 2016, D. R. Commander.
-; Copyright (C) 2015, Intel Corporation.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jcolsamp.inc"
-
-; --------------------------------------------------------------------------
-;
-; Upsample and color convert for the case of 2:1 horizontal and 1:1 vertical.
-;
-; GLOBAL(void)
-; jsimd_h2v1_merged_upsample_avx2(JDIMENSION output_width,
-; JSAMPIMAGE input_buf,
-; JDIMENSION in_row_group_ctr,
-; JSAMPARRAY output_buf);
-;
-
-%define output_width(b) (b) + 8 ; JDIMENSION output_width
-%define input_buf(b) (b) + 12 ; JSAMPIMAGE input_buf
-%define in_row_group_ctr(b) (b) + 16 ; JDIMENSION in_row_group_ctr
-%define output_buf(b) (b) + 20 ; JSAMPARRAY output_buf
-
-%define original_ebp ebp + 0
-%define wk(i) ebp - (WK_NUM - (i)) * SIZEOF_YMMWORD
- ; ymmword wk[WK_NUM]
-%define WK_NUM 3
-%define gotptr wk(0) - SIZEOF_POINTER ; void * gotptr
-
- align 32
- GLOBAL_FUNCTION(jsimd_h2v1_merged_upsample_avx2)
-
-EXTN(jsimd_h2v1_merged_upsample_avx2):
- push ebp
- mov eax, esp ; eax = original ebp
- sub esp, byte 4
- and esp, byte (-SIZEOF_YMMWORD) ; align to 256 bits
- mov [esp], eax
- mov ebp, esp ; ebp = aligned ebp
- lea esp, [wk(0)]
- pushpic eax ; make a room for GOT address
- push ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- get_GOT ebx ; get GOT address
- movpic POINTER [gotptr], ebx ; save GOT address
-
- mov ecx, JDIMENSION [output_width(eax)] ; col
- test ecx, ecx
- jz near .return
-
- push ecx
-
- mov edi, JSAMPIMAGE [input_buf(eax)]
- mov ecx, JDIMENSION [in_row_group_ctr(eax)]
- mov esi, JSAMPARRAY [edi+0*SIZEOF_JSAMPARRAY]
- mov ebx, JSAMPARRAY [edi+1*SIZEOF_JSAMPARRAY]
- mov edx, JSAMPARRAY [edi+2*SIZEOF_JSAMPARRAY]
- mov edi, JSAMPARRAY [output_buf(eax)]
- mov esi, JSAMPROW [esi+ecx*SIZEOF_JSAMPROW] ; inptr0
- mov ebx, JSAMPROW [ebx+ecx*SIZEOF_JSAMPROW] ; inptr1
- mov edx, JSAMPROW [edx+ecx*SIZEOF_JSAMPROW] ; inptr2
- mov edi, JSAMPROW [edi] ; outptr
-
- pop ecx ; col
-
- alignx 16, 7
-.columnloop:
- movpic eax, POINTER [gotptr] ; load GOT address (eax)
-
- vmovdqu ymm6, YMMWORD [ebx] ; ymm6=Cb(0123456789ABCDEFGHIJKLMNOPQRSTUV)
- vmovdqu ymm7, YMMWORD [edx] ; ymm7=Cr(0123456789ABCDEFGHIJKLMNOPQRSTUV)
-
- vpxor ymm1, ymm1, ymm1 ; ymm1=(all 0's)
- vpcmpeqw ymm3, ymm3, ymm3
- vpsllw ymm3, ymm3, 7 ; ymm3={0xFF80 0xFF80 0xFF80 0xFF80 ..}
-
- vpermq ymm6, ymm6, 0xd8 ; ymm6=Cb(01234567GHIJKLMN89ABCDEFOPQRSTUV)
- vpermq ymm7, ymm7, 0xd8 ; ymm7=Cr(01234567GHIJKLMN89ABCDEFOPQRSTUV)
- vpunpcklbw ymm4, ymm6, ymm1 ; ymm4=Cb(0123456789ABCDEF)=CbL
- vpunpckhbw ymm6, ymm6, ymm1 ; ymm6=Cb(GHIJKLMNOPQRSTUV)=CbH
- vpunpcklbw ymm0, ymm7, ymm1 ; ymm0=Cr(0123456789ABCDEF)=CrL
- vpunpckhbw ymm7, ymm7, ymm1 ; ymm7=Cr(GHIJKLMNOPQRSTUV)=CrH
-
- vpaddw ymm5, ymm6, ymm3
- vpaddw ymm2, ymm4, ymm3
- vpaddw ymm1, ymm7, ymm3
- vpaddw ymm3, ymm0, ymm3
-
- ; (Original)
- ; R = Y + 1.40200 * Cr
- ; G = Y - 0.34414 * Cb - 0.71414 * Cr
- ; B = Y + 1.77200 * Cb
- ;
- ; (This implementation)
- ; R = Y + 0.40200 * Cr + Cr
- ; G = Y - 0.34414 * Cb + 0.28586 * Cr - Cr
- ; B = Y - 0.22800 * Cb + Cb + Cb
-
- vpaddw ymm6, ymm5, ymm5 ; ymm6=2*CbH
- vpaddw ymm4, ymm2, ymm2 ; ymm4=2*CbL
- vpaddw ymm7, ymm1, ymm1 ; ymm7=2*CrH
- vpaddw ymm0, ymm3, ymm3 ; ymm0=2*CrL
-
- vpmulhw ymm6, ymm6, [GOTOFF(eax,PW_MF0228)] ; ymm6=(2*CbH * -FIX(0.22800))
- vpmulhw ymm4, ymm4, [GOTOFF(eax,PW_MF0228)] ; ymm4=(2*CbL * -FIX(0.22800))
- vpmulhw ymm7, ymm7, [GOTOFF(eax,PW_F0402)] ; ymm7=(2*CrH * FIX(0.40200))
- vpmulhw ymm0, ymm0, [GOTOFF(eax,PW_F0402)] ; ymm0=(2*CrL * FIX(0.40200))
-
- vpaddw ymm6, ymm6, [GOTOFF(eax,PW_ONE)]
- vpaddw ymm4, ymm4, [GOTOFF(eax,PW_ONE)]
- vpsraw ymm6, ymm6, 1 ; ymm6=(CbH * -FIX(0.22800))
- vpsraw ymm4, ymm4, 1 ; ymm4=(CbL * -FIX(0.22800))
- vpaddw ymm7, ymm7, [GOTOFF(eax,PW_ONE)]
- vpaddw ymm0, ymm0, [GOTOFF(eax,PW_ONE)]
- vpsraw ymm7, ymm7, 1 ; ymm7=(CrH * FIX(0.40200))
- vpsraw ymm0, ymm0, 1 ; ymm0=(CrL * FIX(0.40200))
-
- vpaddw ymm6, ymm6, ymm5
- vpaddw ymm4, ymm4, ymm2
- vpaddw ymm6, ymm6, ymm5 ; ymm6=(CbH * FIX(1.77200))=(B-Y)H
- vpaddw ymm4, ymm4, ymm2 ; ymm4=(CbL * FIX(1.77200))=(B-Y)L
- vpaddw ymm7, ymm7, ymm1 ; ymm7=(CrH * FIX(1.40200))=(R-Y)H
- vpaddw ymm0, ymm0, ymm3 ; ymm0=(CrL * FIX(1.40200))=(R-Y)L
-
- vmovdqa YMMWORD [wk(0)], ymm6 ; wk(0)=(B-Y)H
- vmovdqa YMMWORD [wk(1)], ymm7 ; wk(1)=(R-Y)H
-
- vpunpckhwd ymm6, ymm5, ymm1
- vpunpcklwd ymm5, ymm5, ymm1
- vpmaddwd ymm5, ymm5, [GOTOFF(eax,PW_MF0344_F0285)]
- vpmaddwd ymm6, ymm6, [GOTOFF(eax,PW_MF0344_F0285)]
- vpunpckhwd ymm7, ymm2, ymm3
- vpunpcklwd ymm2, ymm2, ymm3
- vpmaddwd ymm2, ymm2, [GOTOFF(eax,PW_MF0344_F0285)]
- vpmaddwd ymm7, ymm7, [GOTOFF(eax,PW_MF0344_F0285)]
-
- vpaddd ymm5, ymm5, [GOTOFF(eax,PD_ONEHALF)]
- vpaddd ymm6, ymm6, [GOTOFF(eax,PD_ONEHALF)]
- vpsrad ymm5, ymm5, SCALEBITS
- vpsrad ymm6, ymm6, SCALEBITS
- vpaddd ymm2, ymm2, [GOTOFF(eax,PD_ONEHALF)]
- vpaddd ymm7, ymm7, [GOTOFF(eax,PD_ONEHALF)]
- vpsrad ymm2, ymm2, SCALEBITS
- vpsrad ymm7, ymm7, SCALEBITS
-
- vpackssdw ymm5, ymm5, ymm6 ; ymm5=CbH*-FIX(0.344)+CrH*FIX(0.285)
- vpackssdw ymm2, ymm2, ymm7 ; ymm2=CbL*-FIX(0.344)+CrL*FIX(0.285)
- vpsubw ymm5, ymm5, ymm1 ; ymm5=CbH*-FIX(0.344)+CrH*-FIX(0.714)=(G-Y)H
- vpsubw ymm2, ymm2, ymm3 ; ymm2=CbL*-FIX(0.344)+CrL*-FIX(0.714)=(G-Y)L
-
- vmovdqa YMMWORD [wk(2)], ymm5 ; wk(2)=(G-Y)H
-
- mov al, 2 ; Yctr
- jmp short .Yloop_1st
- alignx 16, 7
-
-.Yloop_2nd:
- vmovdqa ymm0, YMMWORD [wk(1)] ; ymm0=(R-Y)H
- vmovdqa ymm2, YMMWORD [wk(2)] ; ymm2=(G-Y)H
- vmovdqa ymm4, YMMWORD [wk(0)] ; ymm4=(B-Y)H
- alignx 16, 7
-
-.Yloop_1st:
- vmovdqu ymm7, YMMWORD [esi] ; ymm7=Y(0123456789ABCDEFGHIJKLMNOPQRSTUV)
-
- vpcmpeqw ymm6, ymm6, ymm6
- vpsrlw ymm6, ymm6, BYTE_BIT ; ymm6={0xFF 0x00 0xFF 0x00 ..}
- vpand ymm6, ymm6, ymm7 ; ymm6=Y(02468ACEGIKMOQSU)=YE
- vpsrlw ymm7, ymm7, BYTE_BIT ; ymm7=Y(13579BDFHJLNPRTV)=YO
-
- vmovdqa ymm1, ymm0 ; ymm1=ymm0=(R-Y)(L/H)
- vmovdqa ymm3, ymm2 ; ymm3=ymm2=(G-Y)(L/H)
- vmovdqa ymm5, ymm4 ; ymm5=ymm4=(B-Y)(L/H)
-
- vpaddw ymm0, ymm0, ymm6 ; ymm0=((R-Y)+YE)=RE=R(02468ACEGIKMOQSU)
- vpaddw ymm1, ymm1, ymm7 ; ymm1=((R-Y)+YO)=RO=R(13579BDFHJLNPRTV)
- vpackuswb ymm0, ymm0, ymm0 ; ymm0=R(02468ACE********GIKMOQSU********)
- vpackuswb ymm1, ymm1, ymm1 ; ymm1=R(13579BDF********HJLNPRTV********)
-
- vpaddw ymm2, ymm2, ymm6 ; ymm2=((G-Y)+YE)=GE=G(02468ACEGIKMOQSU)
- vpaddw ymm3, ymm3, ymm7 ; ymm3=((G-Y)+YO)=GO=G(13579BDFHJLNPRTV)
- vpackuswb ymm2, ymm2, ymm2 ; ymm2=G(02468ACE********GIKMOQSU********)
- vpackuswb ymm3, ymm3, ymm3 ; ymm3=G(13579BDF********HJLNPRTV********)
-
- vpaddw ymm4, ymm4, ymm6 ; ymm4=((B-Y)+YE)=BE=B(02468ACEGIKMOQSU)
- vpaddw ymm5, ymm5, ymm7 ; ymm5=((B-Y)+YO)=BO=B(13579BDFHJLNPRTV)
- vpackuswb ymm4, ymm4, ymm4 ; ymm4=B(02468ACE********GIKMOQSU********)
- vpackuswb ymm5, ymm5, ymm5 ; ymm5=B(13579BDF********HJLNPRTV********)
-
-%if RGB_PIXELSIZE == 3 ; ---------------
-
- ; ymmA=(00 02 04 06 08 0A 0C 0E ** 0G 0I 0K 0M 0O 0Q 0S 0U **)
- ; ymmB=(01 03 05 07 09 0B 0D 0F ** 0H 0J 0L 0N 0P 0R 0T 0V **)
- ; ymmC=(10 12 14 16 18 1A 1C 1E ** 1G 1I 1K 1M 1O 1Q 1S 1U **)
- ; ymmD=(11 13 15 17 19 1B 1D 1F ** 1H 1J 1L 1N 1P 1R 1T 1V **)
- ; ymmE=(20 22 24 26 28 2A 2C 2E ** 2G 2I 2K 2M 2O 2Q 2S 2U **)
- ; ymmF=(21 23 25 27 29 2B 2D 2F ** 2H 2J 2L 2N 2P 2R 2T 2V **)
- ; ymmG=(** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **)
- ; ymmH=(** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **)
-
- vpunpcklbw ymmA, ymmA, ymmC ; ymmA=(00 10 02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E
- ; 0G 1G 0I 1I 0K 1K 0M 1M 0O 1O 0Q 1Q 0S 1S 0U 1U)
- vpunpcklbw ymmE, ymmE, ymmB ; ymmE=(20 01 22 03 24 05 26 07 28 09 2A 0B 2C 0D 2E 0F
- ; 2G 0H 2I 0J 2K 0L 2M 0N 2O 0P 2Q 0R 2S 0T 2U 0V)
- vpunpcklbw ymmD, ymmD, ymmF ; ymmD=(11 21 13 23 15 25 17 27 19 29 1B 2B 1D 2D 1F 2F
- ; 1H 2H 1J 2J 1L 2L 1N 2N 1P 2P 1R 2R 1T 2T 1V 2V)
-
- vpsrldq ymmH, ymmA, 2 ; ymmH=(02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E 0G 1G
- ; 0I 1I 0K 1K 0M 1M 0O 1O 0Q 1Q 0S 1S 0U 1U -- --)
- vpunpckhwd ymmG, ymmA, ymmE ; ymmG=(08 18 28 09 0A 1A 2A 0B 0C 1C 2C 0D 0E 1E 2E 0F
- ; 0O 1O 2O 0P 0Q 1Q 2Q 0R 0S 1S 2S 0T 0U 1U 2U 0V)
- vpunpcklwd ymmA, ymmA, ymmE ; ymmA=(00 10 20 01 02 12 22 03 04 14 24 05 06 16 26 07
- ; 0G 1G 2G 0H 0I 1I 2I 0J 0K 1K 2K 0L 0M 1M 2M 0N)
-
- vpsrldq ymmE, ymmE, 2 ; ymmE=(22 03 24 05 26 07 28 09 2A 0B 2C 0D 2E 0F 2G 0H
- ; 2I 0J 2K 0L 2M 0N 2O 0P 2Q 0R 2S 0T 2U 0V -- --)
-
- vpsrldq ymmB, ymmD, 2 ; ymmB=(13 23 15 25 17 27 19 29 1B 2B 1D 2D 1F 2F 1H 2H
- ; 1J 2J 1L 2L 1N 2N 1P 2P 1R 2R 1T 2T 1V 2V -- --)
- vpunpckhwd ymmC, ymmD, ymmH ; ymmC=(19 29 0A 1A 1B 2B 0C 1C 1D 2D 0E 1E 1F 2F 0G 1G
- ; 1P 2P 0Q 1Q 1R 2R 0S 1S 1T 2T 0U 1U 1V 2V -- --)
- vpunpcklwd ymmD, ymmD, ymmH ; ymmD=(11 21 02 12 13 23 04 14 15 25 06 16 17 27 08 18
- ; 1H 2H 0I 1I 1J 2J 0K 1K 1L 2L 0M 1M 1N 2N 0O 1O)
-
- vpunpckhwd ymmF, ymmE, ymmB ; ymmF=(2A 0B 1B 2B 2C 0D 1D 2D 2E 0F 1F 2F 2G 0H 1H 2H
- ; 2Q 0R 1R 2R 2S 0T 1T 2T 2U 0V 1V 2V -- -- -- --)
- vpunpcklwd ymmE, ymmE, ymmB ; ymmE=(22 03 13 23 24 05 15 25 26 07 17 27 28 09 19 29
- ; 2I 0J 1J 2J 2K 0L 1L 2L 2M 0N 1N 2N 2O 0P 1P 2P)
-
- vpshufd ymmH, ymmA, 0x4E ; ymmH=(04 14 24 05 06 16 26 07 00 10 20 01 02 12 22 03
- ; 0K 1K 2K 0L 0M 1M 2M 0N 0G 1G 2G 0H 0I 1I 2I 0J)
- vpunpckldq ymmA, ymmA, ymmD ; ymmA=(00 10 20 01 11 21 02 12 02 12 22 03 13 23 04 14
- ; 0G 1G 2G 0H 1H 2H 0I 1I 0I 1I 2I 0J 1J 2J 0K 1K)
- vpunpckhdq ymmD, ymmD, ymmE ; ymmD=(15 25 06 16 26 07 17 27 17 27 08 18 28 09 19 29
- ; 1L 2L 0M 1M 2M 0N 1N 2N 1N 2N 0O 1O 2O 0P 1P 2P)
- vpunpckldq ymmE, ymmE, ymmH ; ymmE=(22 03 13 23 04 14 24 05 24 05 15 25 06 16 26 07
- ; 2I 0J 1J 2J 0K 1K 2K 0L 2K 0L 1L 2L 0M 1M 2M 0N)
-
- vpshufd ymmH, ymmG, 0x4E ; ymmH=(0C 1C 2C 0D 0E 1E 2E 0F 08 18 28 09 0A 1A 2A 0B
- ; 0S 1S 2S 0T 0U 1U 2U 0V 0O 1O 2O 0P 0Q 1Q 2Q 0R)
- vpunpckldq ymmG, ymmG, ymmC ; ymmG=(08 18 28 09 19 29 0A 1A 0A 1A 2A 0B 1B 2B 0C 1C
- ; 0O 1O 2O 0P 1P 2P 0Q 1Q 0Q 1Q 2Q 0R 1R 2R 0S 1S)
- vpunpckhdq ymmC, ymmC, ymmF ; ymmC=(1D 2D 0E 1E 2E 0F 1F 2F 1F 2F 0G 1G 2G 0H 1H 2H
- ; 1T 2T 0U 1U 2U 0V 1V 2V 1V 2V -- -- -- -- -- --)
- vpunpckldq ymmF, ymmF, ymmH ; ymmF=(2A 0B 1B 2B 0C 1C 2C 0D 2C 0D 1D 2D 0E 1E 2E 0F
- ; 2Q 0R 1R 2R 0S 1S 2S 0T 2S 0T 1T 2T 0U 1U 2U 0V)
-
- vpunpcklqdq ymmH, ymmA, ymmE ; ymmH=(00 10 20 01 11 21 02 12 22 03 13 23 04 14 24 05
- ; 0G 1G 2G 0H 1H 2H 0I 1I 2I 0J 1J 2J 0K 1K 2K 0L)
- vpunpcklqdq ymmG, ymmD, ymmG ; ymmG=(15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A
- ; 1L 2L 0M 1M 2M 0N 1N 2N 0O 1O 2O 0P 1P 2P 0Q 1Q)
- vpunpcklqdq ymmC, ymmF, ymmC ; ymmC=(2A 0B 1B 2B 0C 1C 2C 0D 1D 2D 0E 1E 2E 0F 1F 2F
- ; 2Q 0R 1R 2R 0S 1S 2S 0T 1T 2T 0U 1U 2U 0V 1V 2V)
-
- vperm2i128 ymmA, ymmH, ymmG, 0x20 ; ymmA=(00 10 20 01 11 21 02 12 22 03 13 23 04 14 24 05
- ; 15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A)
- vperm2i128 ymmD, ymmC, ymmH, 0x30 ; ymmD=(2A 0B 1B 2B 0C 1C 2C 0D 1D 2D 0E 1E 2E 0F 1F 2F
- ; 0G 1G 2G 0H 1H 2H 0I 1I 2I 0J 1J 2J 0K 1K 2K 0L)
- vperm2i128 ymmF, ymmG, ymmC, 0x31 ; ymmF=(1L 2L 0M 1M 2M 0N 1N 2N 0O 1O 2O 0P 1P 2P 0Q 1Q
- ; 2Q 0R 1R 2R 0S 1S 2S 0T 1T 2T 0U 1U 2U 0V 1V 2V)
-
- cmp ecx, byte SIZEOF_YMMWORD
- jb short .column_st64
-
- test edi, SIZEOF_YMMWORD-1
- jnz short .out1
- ; --(aligned)-------------------
- vmovntdq YMMWORD [edi+0*SIZEOF_YMMWORD], ymmA
- vmovntdq YMMWORD [edi+1*SIZEOF_YMMWORD], ymmD
- vmovntdq YMMWORD [edi+2*SIZEOF_YMMWORD], ymmF
- jmp short .out0
-.out1: ; --(unaligned)-----------------
- vmovdqu YMMWORD [edi+0*SIZEOF_YMMWORD], ymmA
- vmovdqu YMMWORD [edi+1*SIZEOF_YMMWORD], ymmD
- vmovdqu YMMWORD [edi+2*SIZEOF_YMMWORD], ymmF
-.out0:
- add edi, byte RGB_PIXELSIZE*SIZEOF_YMMWORD ; outptr
- sub ecx, byte SIZEOF_YMMWORD
- jz near .endcolumn
-
- add esi, byte SIZEOF_YMMWORD ; inptr0
- dec al ; Yctr
- jnz near .Yloop_2nd
-
- add ebx, byte SIZEOF_YMMWORD ; inptr1
- add edx, byte SIZEOF_YMMWORD ; inptr2
- jmp near .columnloop
- alignx 16, 7
-
-.column_st64:
- lea ecx, [ecx+ecx*2] ; imul ecx, RGB_PIXELSIZE
- cmp ecx, byte 2*SIZEOF_YMMWORD
- jb short .column_st32
- vmovdqu YMMWORD [edi+0*SIZEOF_YMMWORD], ymmA
- vmovdqu YMMWORD [edi+1*SIZEOF_YMMWORD], ymmD
- add edi, byte 2*SIZEOF_YMMWORD ; outptr
- vmovdqa ymmA, ymmF
- sub ecx, byte 2*SIZEOF_YMMWORD
- jmp short .column_st31
-.column_st32:
- cmp ecx, byte SIZEOF_YMMWORD
- jb short .column_st31
- vmovdqu YMMWORD [edi+0*SIZEOF_YMMWORD], ymmA
- add edi, byte SIZEOF_YMMWORD ; outptr
- vmovdqa ymmA, ymmD
- sub ecx, byte SIZEOF_YMMWORD
- jmp short .column_st31
-.column_st31:
- cmp ecx, byte SIZEOF_XMMWORD
- jb short .column_st15
- vmovdqu XMMWORD [edi+0*SIZEOF_XMMWORD], xmmA
- add edi, byte SIZEOF_XMMWORD ; outptr
- vperm2i128 ymmA, ymmA, ymmA, 1
- sub ecx, byte SIZEOF_XMMWORD
-.column_st15:
- ; Store the lower 8 bytes of xmmA to the output when it has enough
- ; space.
- cmp ecx, byte SIZEOF_MMWORD
- jb short .column_st7
- vmovq XMM_MMWORD [edi], xmmA
- add edi, byte SIZEOF_MMWORD
- sub ecx, byte SIZEOF_MMWORD
- vpsrldq xmmA, xmmA, SIZEOF_MMWORD
-.column_st7:
- ; Store the lower 4 bytes of xmmA to the output when it has enough
- ; space.
- cmp ecx, byte SIZEOF_DWORD
- jb short .column_st3
- vmovd XMM_DWORD [edi], xmmA
- add edi, byte SIZEOF_DWORD
- sub ecx, byte SIZEOF_DWORD
- vpsrldq xmmA, xmmA, SIZEOF_DWORD
-.column_st3:
- ; Store the lower 2 bytes of eax to the output when it has enough
- ; space.
- vmovd eax, xmmA
- cmp ecx, byte SIZEOF_WORD
- jb short .column_st1
- mov word [edi], ax
- add edi, byte SIZEOF_WORD
- sub ecx, byte SIZEOF_WORD
- shr eax, 16
-.column_st1:
- ; Store the lower 1 byte of eax to the output when it has enough
- ; space.
- test ecx, ecx
- jz short .endcolumn
- mov byte [edi], al
-
-%else ; RGB_PIXELSIZE == 4 ; -----------
-
-%ifdef RGBX_FILLER_0XFF
- vpcmpeqb ymm6, ymm6, ymm6 ; ymm6=XE=X(02468ACE********GIKMOQSU********)
- vpcmpeqb ymm7, ymm7, ymm7 ; ymm7=XO=X(13579BDF********HJLNPRTV********)
-%else
- vpxor ymm6, ymm6, ymm6 ; ymm6=XE=X(02468ACE********GIKMOQSU********)
- vpxor ymm7, ymm7, ymm7 ; ymm7=XO=X(13579BDF********HJLNPRTV********)
-%endif
- ; ymmA=(00 02 04 06 08 0A 0C 0E ** 0G 0I 0K 0M 0O 0Q 0S 0U **)
- ; ymmB=(01 03 05 07 09 0B 0D 0F ** 0H 0J 0L 0N 0P 0R 0T 0V **)
- ; ymmC=(10 12 14 16 18 1A 1C 1E ** 1G 1I 1K 1M 1O 1Q 1S 1U **)
- ; ymmD=(11 13 15 17 19 1B 1D 1F ** 1H 1J 1L 1N 1P 1R 1T 1V **)
- ; ymmE=(20 22 24 26 28 2A 2C 2E ** 2G 2I 2K 2M 2O 2Q 2S 2U **)
- ; ymmF=(21 23 25 27 29 2B 2D 2F ** 2H 2J 2L 2N 2P 2R 2T 2V **)
- ; ymmG=(30 32 34 36 38 3A 3C 3E ** 3G 3I 3K 3M 3O 3Q 3S 3U **)
- ; ymmH=(31 33 35 37 39 3B 3D 3F ** 3H 3J 3L 3N 3P 3R 3T 3V **)
-
- vpunpcklbw ymmA, ymmA, ymmC ; ymmA=(00 10 02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E
- ; 0G 1G 0I 1I 0K 1K 0M 1M 0O 1O 0Q 1Q 0S 1S 0U 1U)
- vpunpcklbw ymmE, ymmE, ymmG ; ymmE=(20 30 22 32 24 34 26 36 28 38 2A 3A 2C 3C 2E 3E
- ; 2G 3G 2I 3I 2K 3K 2M 3M 2O 3O 2Q 3Q 2S 3S 2U 3U)
- vpunpcklbw ymmB, ymmB, ymmD ; ymmB=(01 11 03 13 05 15 07 17 09 19 0B 1B 0D 1D 0F 1F
- ; 0H 1H 0J 1J 0L 1L 0N 1N 0P 1P 0R 1R 0T 1T 0V 1V)
- vpunpcklbw ymmF, ymmF, ymmH ; ymmF=(21 31 23 33 25 35 27 37 29 39 2B 3B 2D 3D 2F 3F
- ; 2H 3H 2J 3J 2L 3L 2N 3N 2P 3P 2R 3R 2T 3T 2V 3V)
-
- vpunpckhwd ymmC, ymmA, ymmE ; ymmC=(08 18 28 38 0A 1A 2A 3A 0C 1C 2C 3C 0E 1E 2E 3E
- ; 0O 1O 2O 3O 0Q 1Q 2Q 3Q 0S 1S 2S 3S 0U 1U 2U 3U)
- vpunpcklwd ymmA, ymmA, ymmE ; ymmA=(00 10 20 30 02 12 22 32 04 14 24 34 06 16 26 36
- ; 0G 1G 2G 3G 0I 1I 2I 3I 0K 1K 2K 3K 0M 1M 2M 3M)
- vpunpckhwd ymmG, ymmB, ymmF ; ymmG=(09 19 29 39 0B 1B 2B 3B 0D 1D 2D 3D 0F 1F 2F 3F
- ; 0P 1P 2P 3P 0R 1R 2R 3R 0T 1T 2T 3T 0V 1V 2V 3V)
- vpunpcklwd ymmB, ymmB, ymmF ; ymmB=(01 11 21 31 03 13 23 33 05 15 25 35 07 17 27 37
- ; 0H 1H 2H 3H 0J 1J 2J 3J 0L 1L 2L 3L 0N 1N 2N 3N)
-
- vpunpckhdq ymmE, ymmA, ymmB ; ymmE=(04 14 24 34 05 15 25 35 06 16 26 36 07 17 27 37
- ; 0K 1K 2K 3K 0L 1L 2L 3L 0M 1M 2M 3M 0N 1N 2N 3N)
- vpunpckldq ymmB, ymmA, ymmB ; ymmB=(00 10 20 30 01 11 21 31 02 12 22 32 03 13 23 33
- ; 0G 1G 2G 3G 0H 1H 2H 3H 0I 1I 2I 3I 0J 1J 2J 3J)
- vpunpckhdq ymmF, ymmC, ymmG ; ymmF=(0C 1C 2C 3C 0D 1D 2D 3D 0E 1E 2E 3E 0F 1F 2F 3F
- ; 0S 1S 2S 3S 0T 1T 2T 3T 0U 1U 2U 3U 0V 1V 2V 3V)
- vpunpckldq ymmG, ymmC, ymmG ; ymmG=(08 18 28 38 09 19 29 39 0A 1A 2A 3A 0B 1B 2B 3B
- ; 0O 1O 2O 3O 0P 1P 2P 3P 0Q 1Q 2Q 3Q 0R 1R 2R 3R)
-
- vperm2i128 ymmA, ymmB, ymmE, 0x20 ; ymmA=(00 10 20 30 01 11 21 31 02 12 22 32 03 13 23 33
- ; 04 14 24 34 05 15 25 35 06 16 26 36 07 17 27 37)
- vperm2i128 ymmD, ymmG, ymmF, 0x20 ; ymmD=(08 18 28 38 09 19 29 39 0A 1A 2A 3A 0B 1B 2B 3B
- ; 0C 1C 2C 3C 0D 1D 2D 3D 0E 1E 2E 3E 0F 1F 2F 3F)
- vperm2i128 ymmC, ymmB, ymmE, 0x31 ; ymmC=(0G 1G 2G 3G 0H 1H 2H 3H 0I 1I 2I 3I 0J 1J 2J 3J
- ; 0K 1K 2K 3K 0L 1L 2L 3L 0M 1M 2M 3M 0N 1N 2N 3N)
- vperm2i128 ymmH, ymmG, ymmF, 0x31 ; ymmH=(0O 1O 2O 3O 0P 1P 2P 3P 0Q 1Q 2Q 3Q 0R 1R 2R 3R
- ; 0S 1S 2S 3S 0T 1T 2T 3T 0U 1U 2U 3U 0V 1V 2V 3V)
-
- cmp ecx, byte SIZEOF_YMMWORD
- jb short .column_st64
-
- test edi, SIZEOF_YMMWORD-1
- jnz short .out1
- ; --(aligned)-------------------
- vmovntdq YMMWORD [edi+0*SIZEOF_YMMWORD], ymmA
- vmovntdq YMMWORD [edi+1*SIZEOF_YMMWORD], ymmD
- vmovntdq YMMWORD [edi+2*SIZEOF_YMMWORD], ymmC
- vmovntdq YMMWORD [edi+3*SIZEOF_YMMWORD], ymmH
- jmp short .out0
-.out1: ; --(unaligned)-----------------
- vmovdqu YMMWORD [edi+0*SIZEOF_YMMWORD], ymmA
- vmovdqu YMMWORD [edi+1*SIZEOF_YMMWORD], ymmD
- vmovdqu YMMWORD [edi+2*SIZEOF_YMMWORD], ymmC
- vmovdqu YMMWORD [edi+3*SIZEOF_YMMWORD], ymmH
-.out0:
- add edi, RGB_PIXELSIZE*SIZEOF_YMMWORD ; outptr
- sub ecx, byte SIZEOF_YMMWORD
- jz near .endcolumn
-
- add esi, byte SIZEOF_YMMWORD ; inptr0
- dec al
- jnz near .Yloop_2nd
-
- add ebx, byte SIZEOF_YMMWORD ; inptr1
- add edx, byte SIZEOF_YMMWORD ; inptr2
- jmp near .columnloop
- alignx 16, 7
-
-.column_st64:
- cmp ecx, byte SIZEOF_YMMWORD/2
- jb short .column_st32
- vmovdqu YMMWORD [edi+0*SIZEOF_YMMWORD], ymmA
- vmovdqu YMMWORD [edi+1*SIZEOF_YMMWORD], ymmD
- add edi, byte 2*SIZEOF_YMMWORD ; outptr
- vmovdqa ymmA, ymmC
- vmovdqa ymmD, ymmH
- sub ecx, byte SIZEOF_YMMWORD/2
-.column_st32:
- cmp ecx, byte SIZEOF_YMMWORD/4
- jb short .column_st16
- vmovdqu YMMWORD [edi+0*SIZEOF_YMMWORD], ymmA
- add edi, byte SIZEOF_YMMWORD ; outptr
- vmovdqa ymmA, ymmD
- sub ecx, byte SIZEOF_YMMWORD/4
-.column_st16:
- cmp ecx, byte SIZEOF_YMMWORD/8
- jb short .column_st15
- vmovdqu XMMWORD [edi+0*SIZEOF_XMMWORD], xmmA
- add edi, byte SIZEOF_XMMWORD ; outptr
- vperm2i128 ymmA, ymmA, ymmA, 1
- sub ecx, byte SIZEOF_YMMWORD/8
-.column_st15:
- ; Store two pixels (8 bytes) of ymmA to the output when it has enough
- ; space.
- cmp ecx, byte SIZEOF_YMMWORD/16
- jb short .column_st7
- vmovq MMWORD [edi], xmmA
- add edi, byte SIZEOF_YMMWORD/16*4
- sub ecx, byte SIZEOF_YMMWORD/16
- vpsrldq xmmA, SIZEOF_YMMWORD/16*4
-.column_st7:
- ; Store one pixel (4 bytes) of ymmA to the output when it has enough
- ; space.
- test ecx, ecx
- jz short .endcolumn
- vmovd XMM_DWORD [edi], xmmA
-
-%endif ; RGB_PIXELSIZE ; ---------------
-
-.endcolumn:
- sfence ; flush the write buffer
-
-.return:
- vzeroupper
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- pop ebx
- mov esp, ebp ; esp <- aligned ebp
- pop esp ; esp <- original ebp
- pop ebp
- ret
-
-; --------------------------------------------------------------------------
-;
-; Upsample and color convert for the case of 2:1 horizontal and 2:1 vertical.
-;
-; GLOBAL(void)
-; jsimd_h2v2_merged_upsample_avx2(JDIMENSION output_width,
-; JSAMPIMAGE input_buf,
-; JDIMENSION in_row_group_ctr,
-; JSAMPARRAY output_buf);
-;
-
-%define output_width(b) (b) + 8 ; JDIMENSION output_width
-%define input_buf(b) (b) + 12 ; JSAMPIMAGE input_buf
-%define in_row_group_ctr(b) (b) + 16 ; JDIMENSION in_row_group_ctr
-%define output_buf(b) (b) + 20 ; JSAMPARRAY output_buf
-
- align 32
- GLOBAL_FUNCTION(jsimd_h2v2_merged_upsample_avx2)
-
-EXTN(jsimd_h2v2_merged_upsample_avx2):
- push ebp
- mov ebp, esp
- push ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- mov eax, POINTER [output_width(ebp)]
-
- mov edi, JSAMPIMAGE [input_buf(ebp)]
- mov ecx, JDIMENSION [in_row_group_ctr(ebp)]
- mov esi, JSAMPARRAY [edi+0*SIZEOF_JSAMPARRAY]
- mov ebx, JSAMPARRAY [edi+1*SIZEOF_JSAMPARRAY]
- mov edx, JSAMPARRAY [edi+2*SIZEOF_JSAMPARRAY]
- mov edi, JSAMPARRAY [output_buf(ebp)]
- lea esi, [esi+ecx*SIZEOF_JSAMPROW]
-
- push edx ; inptr2
- push ebx ; inptr1
- push esi ; inptr00
- mov ebx, esp
-
- push edi ; output_buf (outptr0)
- push ecx ; in_row_group_ctr
- push ebx ; input_buf
- push eax ; output_width
-
- call near EXTN(jsimd_h2v1_merged_upsample_avx2)
-
- add esi, byte SIZEOF_JSAMPROW ; inptr01
- add edi, byte SIZEOF_JSAMPROW ; outptr1
- mov POINTER [ebx+0*SIZEOF_POINTER], esi
- mov POINTER [ebx-1*SIZEOF_POINTER], edi
-
- call near EXTN(jsimd_h2v1_merged_upsample_avx2)
-
- add esp, byte 7*SIZEOF_DWORD
-
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- pop ebx
- pop ebp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jdmrgext-mmx.asm b/contrib/libs/libjpeg-turbo/simd/i386/jdmrgext-mmx.asm
deleted file mode 100644
index eb3e36b475..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jdmrgext-mmx.asm
+++ /dev/null
@@ -1,460 +0,0 @@
-;
-; jdmrgext.asm - merged upsampling/color conversion (MMX)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jcolsamp.inc"
-
-; --------------------------------------------------------------------------
-;
-; Upsample and color convert for the case of 2:1 horizontal and 1:1 vertical.
-;
-; GLOBAL(void)
-; jsimd_h2v1_merged_upsample_mmx(JDIMENSION output_width, JSAMPIMAGE input_buf,
-; JDIMENSION in_row_group_ctr,
-; JSAMPARRAY output_buf);
-;
-
-%define output_width(b) (b) + 8 ; JDIMENSION output_width
-%define input_buf(b) (b) + 12 ; JSAMPIMAGE input_buf
-%define in_row_group_ctr(b) (b) + 16 ; JDIMENSION in_row_group_ctr
-%define output_buf(b) (b) + 20 ; JSAMPARRAY output_buf
-
-%define original_ebp ebp + 0
-%define wk(i) ebp - (WK_NUM - (i)) * SIZEOF_MMWORD ; mmword wk[WK_NUM]
-%define WK_NUM 3
-%define gotptr wk(0) - SIZEOF_POINTER ; void * gotptr
-
- align 32
- GLOBAL_FUNCTION(jsimd_h2v1_merged_upsample_mmx)
-
-EXTN(jsimd_h2v1_merged_upsample_mmx):
- push ebp
- mov eax, esp ; eax = original ebp
- sub esp, byte 4
- and esp, byte (-SIZEOF_MMWORD) ; align to 64 bits
- mov [esp], eax
- mov ebp, esp ; ebp = aligned ebp
- lea esp, [wk(0)]
- pushpic eax ; make a room for GOT address
- push ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- get_GOT ebx ; get GOT address
- movpic POINTER [gotptr], ebx ; save GOT address
-
- mov ecx, JDIMENSION [output_width(eax)] ; col
- test ecx, ecx
- jz near .return
-
- push ecx
-
- mov edi, JSAMPIMAGE [input_buf(eax)]
- mov ecx, JDIMENSION [in_row_group_ctr(eax)]
- mov esi, JSAMPARRAY [edi+0*SIZEOF_JSAMPARRAY]
- mov ebx, JSAMPARRAY [edi+1*SIZEOF_JSAMPARRAY]
- mov edx, JSAMPARRAY [edi+2*SIZEOF_JSAMPARRAY]
- mov edi, JSAMPARRAY [output_buf(eax)]
- mov esi, JSAMPROW [esi+ecx*SIZEOF_JSAMPROW] ; inptr0
- mov ebx, JSAMPROW [ebx+ecx*SIZEOF_JSAMPROW] ; inptr1
- mov edx, JSAMPROW [edx+ecx*SIZEOF_JSAMPROW] ; inptr2
- mov edi, JSAMPROW [edi] ; outptr
-
- pop ecx ; col
-
- alignx 16, 7
-.columnloop:
- movpic eax, POINTER [gotptr] ; load GOT address (eax)
-
- movq mm6, MMWORD [ebx] ; mm6=Cb(01234567)
- movq mm7, MMWORD [edx] ; mm7=Cr(01234567)
-
- pxor mm1, mm1 ; mm1=(all 0's)
- pcmpeqw mm3, mm3
- psllw mm3, 7 ; mm3={0xFF80 0xFF80 0xFF80 0xFF80}
-
- movq mm4, mm6
- punpckhbw mm6, mm1 ; mm6=Cb(4567)=CbH
- punpcklbw mm4, mm1 ; mm4=Cb(0123)=CbL
- movq mm0, mm7
- punpckhbw mm7, mm1 ; mm7=Cr(4567)=CrH
- punpcklbw mm0, mm1 ; mm0=Cr(0123)=CrL
-
- paddw mm6, mm3
- paddw mm4, mm3
- paddw mm7, mm3
- paddw mm0, mm3
-
- ; (Original)
- ; R = Y + 1.40200 * Cr
- ; G = Y - 0.34414 * Cb - 0.71414 * Cr
- ; B = Y + 1.77200 * Cb
- ;
- ; (This implementation)
- ; R = Y + 0.40200 * Cr + Cr
- ; G = Y - 0.34414 * Cb + 0.28586 * Cr - Cr
- ; B = Y - 0.22800 * Cb + Cb + Cb
-
- movq mm5, mm6 ; mm5=CbH
- movq mm2, mm4 ; mm2=CbL
- paddw mm6, mm6 ; mm6=2*CbH
- paddw mm4, mm4 ; mm4=2*CbL
- movq mm1, mm7 ; mm1=CrH
- movq mm3, mm0 ; mm3=CrL
- paddw mm7, mm7 ; mm7=2*CrH
- paddw mm0, mm0 ; mm0=2*CrL
-
- pmulhw mm6, [GOTOFF(eax,PW_MF0228)] ; mm6=(2*CbH * -FIX(0.22800))
- pmulhw mm4, [GOTOFF(eax,PW_MF0228)] ; mm4=(2*CbL * -FIX(0.22800))
- pmulhw mm7, [GOTOFF(eax,PW_F0402)] ; mm7=(2*CrH * FIX(0.40200))
- pmulhw mm0, [GOTOFF(eax,PW_F0402)] ; mm0=(2*CrL * FIX(0.40200))
-
- paddw mm6, [GOTOFF(eax,PW_ONE)]
- paddw mm4, [GOTOFF(eax,PW_ONE)]
- psraw mm6, 1 ; mm6=(CbH * -FIX(0.22800))
- psraw mm4, 1 ; mm4=(CbL * -FIX(0.22800))
- paddw mm7, [GOTOFF(eax,PW_ONE)]
- paddw mm0, [GOTOFF(eax,PW_ONE)]
- psraw mm7, 1 ; mm7=(CrH * FIX(0.40200))
- psraw mm0, 1 ; mm0=(CrL * FIX(0.40200))
-
- paddw mm6, mm5
- paddw mm4, mm2
- paddw mm6, mm5 ; mm6=(CbH * FIX(1.77200))=(B-Y)H
- paddw mm4, mm2 ; mm4=(CbL * FIX(1.77200))=(B-Y)L
- paddw mm7, mm1 ; mm7=(CrH * FIX(1.40200))=(R-Y)H
- paddw mm0, mm3 ; mm0=(CrL * FIX(1.40200))=(R-Y)L
-
- movq MMWORD [wk(0)], mm6 ; wk(0)=(B-Y)H
- movq MMWORD [wk(1)], mm7 ; wk(1)=(R-Y)H
-
- movq mm6, mm5
- movq mm7, mm2
- punpcklwd mm5, mm1
- punpckhwd mm6, mm1
- pmaddwd mm5, [GOTOFF(eax,PW_MF0344_F0285)]
- pmaddwd mm6, [GOTOFF(eax,PW_MF0344_F0285)]
- punpcklwd mm2, mm3
- punpckhwd mm7, mm3
- pmaddwd mm2, [GOTOFF(eax,PW_MF0344_F0285)]
- pmaddwd mm7, [GOTOFF(eax,PW_MF0344_F0285)]
-
- paddd mm5, [GOTOFF(eax,PD_ONEHALF)]
- paddd mm6, [GOTOFF(eax,PD_ONEHALF)]
- psrad mm5, SCALEBITS
- psrad mm6, SCALEBITS
- paddd mm2, [GOTOFF(eax,PD_ONEHALF)]
- paddd mm7, [GOTOFF(eax,PD_ONEHALF)]
- psrad mm2, SCALEBITS
- psrad mm7, SCALEBITS
-
- packssdw mm5, mm6 ; mm5=CbH*-FIX(0.344)+CrH*FIX(0.285)
- packssdw mm2, mm7 ; mm2=CbL*-FIX(0.344)+CrL*FIX(0.285)
- psubw mm5, mm1 ; mm5=CbH*-FIX(0.344)+CrH*-FIX(0.714)=(G-Y)H
- psubw mm2, mm3 ; mm2=CbL*-FIX(0.344)+CrL*-FIX(0.714)=(G-Y)L
-
- movq MMWORD [wk(2)], mm5 ; wk(2)=(G-Y)H
-
- mov al, 2 ; Yctr
- jmp short .Yloop_1st
- alignx 16, 7
-
-.Yloop_2nd:
- movq mm0, MMWORD [wk(1)] ; mm0=(R-Y)H
- movq mm2, MMWORD [wk(2)] ; mm2=(G-Y)H
- movq mm4, MMWORD [wk(0)] ; mm4=(B-Y)H
- alignx 16, 7
-
-.Yloop_1st:
- movq mm7, MMWORD [esi] ; mm7=Y(01234567)
-
- pcmpeqw mm6, mm6
- psrlw mm6, BYTE_BIT ; mm6={0xFF 0x00 0xFF 0x00 ..}
- pand mm6, mm7 ; mm6=Y(0246)=YE
- psrlw mm7, BYTE_BIT ; mm7=Y(1357)=YO
-
- movq mm1, mm0 ; mm1=mm0=(R-Y)(L/H)
- movq mm3, mm2 ; mm3=mm2=(G-Y)(L/H)
- movq mm5, mm4 ; mm5=mm4=(B-Y)(L/H)
-
- paddw mm0, mm6 ; mm0=((R-Y)+YE)=RE=(R0 R2 R4 R6)
- paddw mm1, mm7 ; mm1=((R-Y)+YO)=RO=(R1 R3 R5 R7)
- packuswb mm0, mm0 ; mm0=(R0 R2 R4 R6 ** ** ** **)
- packuswb mm1, mm1 ; mm1=(R1 R3 R5 R7 ** ** ** **)
-
- paddw mm2, mm6 ; mm2=((G-Y)+YE)=GE=(G0 G2 G4 G6)
- paddw mm3, mm7 ; mm3=((G-Y)+YO)=GO=(G1 G3 G5 G7)
- packuswb mm2, mm2 ; mm2=(G0 G2 G4 G6 ** ** ** **)
- packuswb mm3, mm3 ; mm3=(G1 G3 G5 G7 ** ** ** **)
-
- paddw mm4, mm6 ; mm4=((B-Y)+YE)=BE=(B0 B2 B4 B6)
- paddw mm5, mm7 ; mm5=((B-Y)+YO)=BO=(B1 B3 B5 B7)
- packuswb mm4, mm4 ; mm4=(B0 B2 B4 B6 ** ** ** **)
- packuswb mm5, mm5 ; mm5=(B1 B3 B5 B7 ** ** ** **)
-
-%if RGB_PIXELSIZE == 3 ; ---------------
-
- ; mmA=(00 02 04 06 ** ** ** **), mmB=(01 03 05 07 ** ** ** **)
- ; mmC=(10 12 14 16 ** ** ** **), mmD=(11 13 15 17 ** ** ** **)
- ; mmE=(20 22 24 26 ** ** ** **), mmF=(21 23 25 27 ** ** ** **)
- ; mmG=(** ** ** ** ** ** ** **), mmH=(** ** ** ** ** ** ** **)
-
- punpcklbw mmA, mmC ; mmA=(00 10 02 12 04 14 06 16)
- punpcklbw mmE, mmB ; mmE=(20 01 22 03 24 05 26 07)
- punpcklbw mmD, mmF ; mmD=(11 21 13 23 15 25 17 27)
-
- movq mmG, mmA
- movq mmH, mmA
- punpcklwd mmA, mmE ; mmA=(00 10 20 01 02 12 22 03)
- punpckhwd mmG, mmE ; mmG=(04 14 24 05 06 16 26 07)
-
- psrlq mmH, 2*BYTE_BIT ; mmH=(02 12 04 14 06 16 -- --)
- psrlq mmE, 2*BYTE_BIT ; mmE=(22 03 24 05 26 07 -- --)
-
- movq mmC, mmD
- movq mmB, mmD
- punpcklwd mmD, mmH ; mmD=(11 21 02 12 13 23 04 14)
- punpckhwd mmC, mmH ; mmC=(15 25 06 16 17 27 -- --)
-
- psrlq mmB, 2*BYTE_BIT ; mmB=(13 23 15 25 17 27 -- --)
-
- movq mmF, mmE
- punpcklwd mmE, mmB ; mmE=(22 03 13 23 24 05 15 25)
- punpckhwd mmF, mmB ; mmF=(26 07 17 27 -- -- -- --)
-
- punpckldq mmA, mmD ; mmA=(00 10 20 01 11 21 02 12)
- punpckldq mmE, mmG ; mmE=(22 03 13 23 04 14 24 05)
- punpckldq mmC, mmF ; mmC=(15 25 06 16 26 07 17 27)
-
- cmp ecx, byte SIZEOF_MMWORD
- jb short .column_st16
-
- movq MMWORD [edi+0*SIZEOF_MMWORD], mmA
- movq MMWORD [edi+1*SIZEOF_MMWORD], mmE
- movq MMWORD [edi+2*SIZEOF_MMWORD], mmC
-
- sub ecx, byte SIZEOF_MMWORD
- jz near .endcolumn
-
- add edi, byte RGB_PIXELSIZE*SIZEOF_MMWORD ; outptr
- add esi, byte SIZEOF_MMWORD ; inptr0
- dec al ; Yctr
- jnz near .Yloop_2nd
-
- add ebx, byte SIZEOF_MMWORD ; inptr1
- add edx, byte SIZEOF_MMWORD ; inptr2
- jmp near .columnloop
- alignx 16, 7
-
-.column_st16:
- lea ecx, [ecx+ecx*2] ; imul ecx, RGB_PIXELSIZE
- cmp ecx, byte 2*SIZEOF_MMWORD
- jb short .column_st8
- movq MMWORD [edi+0*SIZEOF_MMWORD], mmA
- movq MMWORD [edi+1*SIZEOF_MMWORD], mmE
- movq mmA, mmC
- sub ecx, byte 2*SIZEOF_MMWORD
- add edi, byte 2*SIZEOF_MMWORD
- jmp short .column_st4
-.column_st8:
- cmp ecx, byte SIZEOF_MMWORD
- jb short .column_st4
- movq MMWORD [edi+0*SIZEOF_MMWORD], mmA
- movq mmA, mmE
- sub ecx, byte SIZEOF_MMWORD
- add edi, byte SIZEOF_MMWORD
-.column_st4:
- movd eax, mmA
- cmp ecx, byte SIZEOF_DWORD
- jb short .column_st2
- mov dword [edi+0*SIZEOF_DWORD], eax
- psrlq mmA, DWORD_BIT
- movd eax, mmA
- sub ecx, byte SIZEOF_DWORD
- add edi, byte SIZEOF_DWORD
-.column_st2:
- cmp ecx, byte SIZEOF_WORD
- jb short .column_st1
- mov word [edi+0*SIZEOF_WORD], ax
- shr eax, WORD_BIT
- sub ecx, byte SIZEOF_WORD
- add edi, byte SIZEOF_WORD
-.column_st1:
- cmp ecx, byte SIZEOF_BYTE
- jb short .endcolumn
- mov byte [edi+0*SIZEOF_BYTE], al
-
-%else ; RGB_PIXELSIZE == 4 ; -----------
-
-%ifdef RGBX_FILLER_0XFF
- pcmpeqb mm6, mm6 ; mm6=(X0 X2 X4 X6 ** ** ** **)
- pcmpeqb mm7, mm7 ; mm7=(X1 X3 X5 X7 ** ** ** **)
-%else
- pxor mm6, mm6 ; mm6=(X0 X2 X4 X6 ** ** ** **)
- pxor mm7, mm7 ; mm7=(X1 X3 X5 X7 ** ** ** **)
-%endif
- ; mmA=(00 02 04 06 ** ** ** **), mmB=(01 03 05 07 ** ** ** **)
- ; mmC=(10 12 14 16 ** ** ** **), mmD=(11 13 15 17 ** ** ** **)
- ; mmE=(20 22 24 26 ** ** ** **), mmF=(21 23 25 27 ** ** ** **)
- ; mmG=(30 32 34 36 ** ** ** **), mmH=(31 33 35 37 ** ** ** **)
-
- punpcklbw mmA, mmC ; mmA=(00 10 02 12 04 14 06 16)
- punpcklbw mmE, mmG ; mmE=(20 30 22 32 24 34 26 36)
- punpcklbw mmB, mmD ; mmB=(01 11 03 13 05 15 07 17)
- punpcklbw mmF, mmH ; mmF=(21 31 23 33 25 35 27 37)
-
- movq mmC, mmA
- punpcklwd mmA, mmE ; mmA=(00 10 20 30 02 12 22 32)
- punpckhwd mmC, mmE ; mmC=(04 14 24 34 06 16 26 36)
- movq mmG, mmB
- punpcklwd mmB, mmF ; mmB=(01 11 21 31 03 13 23 33)
- punpckhwd mmG, mmF ; mmG=(05 15 25 35 07 17 27 37)
-
- movq mmD, mmA
- punpckldq mmA, mmB ; mmA=(00 10 20 30 01 11 21 31)
- punpckhdq mmD, mmB ; mmD=(02 12 22 32 03 13 23 33)
- movq mmH, mmC
- punpckldq mmC, mmG ; mmC=(04 14 24 34 05 15 25 35)
- punpckhdq mmH, mmG ; mmH=(06 16 26 36 07 17 27 37)
-
- cmp ecx, byte SIZEOF_MMWORD
- jb short .column_st16
-
- movq MMWORD [edi+0*SIZEOF_MMWORD], mmA
- movq MMWORD [edi+1*SIZEOF_MMWORD], mmD
- movq MMWORD [edi+2*SIZEOF_MMWORD], mmC
- movq MMWORD [edi+3*SIZEOF_MMWORD], mmH
-
- sub ecx, byte SIZEOF_MMWORD
- jz short .endcolumn
-
- add edi, byte RGB_PIXELSIZE*SIZEOF_MMWORD ; outptr
- add esi, byte SIZEOF_MMWORD ; inptr0
- dec al ; Yctr
- jnz near .Yloop_2nd
-
- add ebx, byte SIZEOF_MMWORD ; inptr1
- add edx, byte SIZEOF_MMWORD ; inptr2
- jmp near .columnloop
- alignx 16, 7
-
-.column_st16:
- cmp ecx, byte SIZEOF_MMWORD/2
- jb short .column_st8
- movq MMWORD [edi+0*SIZEOF_MMWORD], mmA
- movq MMWORD [edi+1*SIZEOF_MMWORD], mmD
- movq mmA, mmC
- movq mmD, mmH
- sub ecx, byte SIZEOF_MMWORD/2
- add edi, byte 2*SIZEOF_MMWORD
-.column_st8:
- cmp ecx, byte SIZEOF_MMWORD/4
- jb short .column_st4
- movq MMWORD [edi+0*SIZEOF_MMWORD], mmA
- movq mmA, mmD
- sub ecx, byte SIZEOF_MMWORD/4
- add edi, byte 1*SIZEOF_MMWORD
-.column_st4:
- cmp ecx, byte SIZEOF_MMWORD/8
- jb short .endcolumn
- movd dword [edi+0*SIZEOF_DWORD], mmA
-
-%endif ; RGB_PIXELSIZE ; ---------------
-
-.endcolumn:
- emms ; empty MMX state
-
-.return:
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- pop ebx
- mov esp, ebp ; esp <- aligned ebp
- pop esp ; esp <- original ebp
- pop ebp
- ret
-
-; --------------------------------------------------------------------------
-;
-; Upsample and color convert for the case of 2:1 horizontal and 2:1 vertical.
-;
-; GLOBAL(void)
-; jsimd_h2v2_merged_upsample_mmx(JDIMENSION output_width, JSAMPIMAGE input_buf,
-; JDIMENSION in_row_group_ctr,
-; JSAMPARRAY output_buf);
-;
-
-%define output_width(b) (b) + 8 ; JDIMENSION output_width
-%define input_buf(b) (b) + 12 ; JSAMPIMAGE input_buf
-%define in_row_group_ctr(b) (b) + 16 ; JDIMENSION in_row_group_ctr
-%define output_buf(b) (b) + 20 ; JSAMPARRAY output_buf
-
- align 32
- GLOBAL_FUNCTION(jsimd_h2v2_merged_upsample_mmx)
-
-EXTN(jsimd_h2v2_merged_upsample_mmx):
- push ebp
- mov ebp, esp
- push ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- mov eax, JDIMENSION [output_width(ebp)]
-
- mov edi, JSAMPIMAGE [input_buf(ebp)]
- mov ecx, JDIMENSION [in_row_group_ctr(ebp)]
- mov esi, JSAMPARRAY [edi+0*SIZEOF_JSAMPARRAY]
- mov ebx, JSAMPARRAY [edi+1*SIZEOF_JSAMPARRAY]
- mov edx, JSAMPARRAY [edi+2*SIZEOF_JSAMPARRAY]
- mov edi, JSAMPARRAY [output_buf(ebp)]
- lea esi, [esi+ecx*SIZEOF_JSAMPROW]
-
- push edx ; inptr2
- push ebx ; inptr1
- push esi ; inptr00
- mov ebx, esp
-
- push edi ; output_buf (outptr0)
- push ecx ; in_row_group_ctr
- push ebx ; input_buf
- push eax ; output_width
-
- call near EXTN(jsimd_h2v1_merged_upsample_mmx)
-
- add esi, byte SIZEOF_JSAMPROW ; inptr01
- add edi, byte SIZEOF_JSAMPROW ; outptr1
- mov POINTER [ebx+0*SIZEOF_POINTER], esi
- mov POINTER [ebx-1*SIZEOF_POINTER], edi
-
- call near EXTN(jsimd_h2v1_merged_upsample_mmx)
-
- add esp, byte 7*SIZEOF_DWORD
-
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- pop ebx
- pop ebp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jdmrgext-sse2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jdmrgext-sse2.asm
deleted file mode 100644
index c113dc4d27..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jdmrgext-sse2.asm
+++ /dev/null
@@ -1,517 +0,0 @@
-;
-; jdmrgext.asm - merged upsampling/color conversion (SSE2)
-;
-; Copyright 2009, 2012 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2012, 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jcolsamp.inc"
-
-; --------------------------------------------------------------------------
-;
-; Upsample and color convert for the case of 2:1 horizontal and 1:1 vertical.
-;
-; GLOBAL(void)
-; jsimd_h2v1_merged_upsample_sse2(JDIMENSION output_width,
-; JSAMPIMAGE input_buf,
-; JDIMENSION in_row_group_ctr,
-; JSAMPARRAY output_buf);
-;
-
-%define output_width(b) (b) + 8 ; JDIMENSION output_width
-%define input_buf(b) (b) + 12 ; JSAMPIMAGE input_buf
-%define in_row_group_ctr(b) (b) + 16 ; JDIMENSION in_row_group_ctr
-%define output_buf(b) (b) + 20 ; JSAMPARRAY output_buf
-
-%define original_ebp ebp + 0
-%define wk(i) ebp - (WK_NUM - (i)) * SIZEOF_XMMWORD
- ; xmmword wk[WK_NUM]
-%define WK_NUM 3
-%define gotptr wk(0) - SIZEOF_POINTER ; void * gotptr
-
- align 32
- GLOBAL_FUNCTION(jsimd_h2v1_merged_upsample_sse2)
-
-EXTN(jsimd_h2v1_merged_upsample_sse2):
- push ebp
- mov eax, esp ; eax = original ebp
- sub esp, byte 4
- and esp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [esp], eax
- mov ebp, esp ; ebp = aligned ebp
- lea esp, [wk(0)]
- pushpic eax ; make a room for GOT address
- push ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- get_GOT ebx ; get GOT address
- movpic POINTER [gotptr], ebx ; save GOT address
-
- mov ecx, JDIMENSION [output_width(eax)] ; col
- test ecx, ecx
- jz near .return
-
- push ecx
-
- mov edi, JSAMPIMAGE [input_buf(eax)]
- mov ecx, JDIMENSION [in_row_group_ctr(eax)]
- mov esi, JSAMPARRAY [edi+0*SIZEOF_JSAMPARRAY]
- mov ebx, JSAMPARRAY [edi+1*SIZEOF_JSAMPARRAY]
- mov edx, JSAMPARRAY [edi+2*SIZEOF_JSAMPARRAY]
- mov edi, JSAMPARRAY [output_buf(eax)]
- mov esi, JSAMPROW [esi+ecx*SIZEOF_JSAMPROW] ; inptr0
- mov ebx, JSAMPROW [ebx+ecx*SIZEOF_JSAMPROW] ; inptr1
- mov edx, JSAMPROW [edx+ecx*SIZEOF_JSAMPROW] ; inptr2
- mov edi, JSAMPROW [edi] ; outptr
-
- pop ecx ; col
-
- alignx 16, 7
-.columnloop:
- movpic eax, POINTER [gotptr] ; load GOT address (eax)
-
- movdqa xmm6, XMMWORD [ebx] ; xmm6=Cb(0123456789ABCDEF)
- movdqa xmm7, XMMWORD [edx] ; xmm7=Cr(0123456789ABCDEF)
-
- pxor xmm1, xmm1 ; xmm1=(all 0's)
- pcmpeqw xmm3, xmm3
- psllw xmm3, 7 ; xmm3={0xFF80 0xFF80 0xFF80 0xFF80 ..}
-
- movdqa xmm4, xmm6
- punpckhbw xmm6, xmm1 ; xmm6=Cb(89ABCDEF)=CbH
- punpcklbw xmm4, xmm1 ; xmm4=Cb(01234567)=CbL
- movdqa xmm0, xmm7
- punpckhbw xmm7, xmm1 ; xmm7=Cr(89ABCDEF)=CrH
- punpcklbw xmm0, xmm1 ; xmm0=Cr(01234567)=CrL
-
- paddw xmm6, xmm3
- paddw xmm4, xmm3
- paddw xmm7, xmm3
- paddw xmm0, xmm3
-
- ; (Original)
- ; R = Y + 1.40200 * Cr
- ; G = Y - 0.34414 * Cb - 0.71414 * Cr
- ; B = Y + 1.77200 * Cb
- ;
- ; (This implementation)
- ; R = Y + 0.40200 * Cr + Cr
- ; G = Y - 0.34414 * Cb + 0.28586 * Cr - Cr
- ; B = Y - 0.22800 * Cb + Cb + Cb
-
- movdqa xmm5, xmm6 ; xmm5=CbH
- movdqa xmm2, xmm4 ; xmm2=CbL
- paddw xmm6, xmm6 ; xmm6=2*CbH
- paddw xmm4, xmm4 ; xmm4=2*CbL
- movdqa xmm1, xmm7 ; xmm1=CrH
- movdqa xmm3, xmm0 ; xmm3=CrL
- paddw xmm7, xmm7 ; xmm7=2*CrH
- paddw xmm0, xmm0 ; xmm0=2*CrL
-
- pmulhw xmm6, [GOTOFF(eax,PW_MF0228)] ; xmm6=(2*CbH * -FIX(0.22800))
- pmulhw xmm4, [GOTOFF(eax,PW_MF0228)] ; xmm4=(2*CbL * -FIX(0.22800))
- pmulhw xmm7, [GOTOFF(eax,PW_F0402)] ; xmm7=(2*CrH * FIX(0.40200))
- pmulhw xmm0, [GOTOFF(eax,PW_F0402)] ; xmm0=(2*CrL * FIX(0.40200))
-
- paddw xmm6, [GOTOFF(eax,PW_ONE)]
- paddw xmm4, [GOTOFF(eax,PW_ONE)]
- psraw xmm6, 1 ; xmm6=(CbH * -FIX(0.22800))
- psraw xmm4, 1 ; xmm4=(CbL * -FIX(0.22800))
- paddw xmm7, [GOTOFF(eax,PW_ONE)]
- paddw xmm0, [GOTOFF(eax,PW_ONE)]
- psraw xmm7, 1 ; xmm7=(CrH * FIX(0.40200))
- psraw xmm0, 1 ; xmm0=(CrL * FIX(0.40200))
-
- paddw xmm6, xmm5
- paddw xmm4, xmm2
- paddw xmm6, xmm5 ; xmm6=(CbH * FIX(1.77200))=(B-Y)H
- paddw xmm4, xmm2 ; xmm4=(CbL * FIX(1.77200))=(B-Y)L
- paddw xmm7, xmm1 ; xmm7=(CrH * FIX(1.40200))=(R-Y)H
- paddw xmm0, xmm3 ; xmm0=(CrL * FIX(1.40200))=(R-Y)L
-
- movdqa XMMWORD [wk(0)], xmm6 ; wk(0)=(B-Y)H
- movdqa XMMWORD [wk(1)], xmm7 ; wk(1)=(R-Y)H
-
- movdqa xmm6, xmm5
- movdqa xmm7, xmm2
- punpcklwd xmm5, xmm1
- punpckhwd xmm6, xmm1
- pmaddwd xmm5, [GOTOFF(eax,PW_MF0344_F0285)]
- pmaddwd xmm6, [GOTOFF(eax,PW_MF0344_F0285)]
- punpcklwd xmm2, xmm3
- punpckhwd xmm7, xmm3
- pmaddwd xmm2, [GOTOFF(eax,PW_MF0344_F0285)]
- pmaddwd xmm7, [GOTOFF(eax,PW_MF0344_F0285)]
-
- paddd xmm5, [GOTOFF(eax,PD_ONEHALF)]
- paddd xmm6, [GOTOFF(eax,PD_ONEHALF)]
- psrad xmm5, SCALEBITS
- psrad xmm6, SCALEBITS
- paddd xmm2, [GOTOFF(eax,PD_ONEHALF)]
- paddd xmm7, [GOTOFF(eax,PD_ONEHALF)]
- psrad xmm2, SCALEBITS
- psrad xmm7, SCALEBITS
-
- packssdw xmm5, xmm6 ; xmm5=CbH*-FIX(0.344)+CrH*FIX(0.285)
- packssdw xmm2, xmm7 ; xmm2=CbL*-FIX(0.344)+CrL*FIX(0.285)
- psubw xmm5, xmm1 ; xmm5=CbH*-FIX(0.344)+CrH*-FIX(0.714)=(G-Y)H
- psubw xmm2, xmm3 ; xmm2=CbL*-FIX(0.344)+CrL*-FIX(0.714)=(G-Y)L
-
- movdqa XMMWORD [wk(2)], xmm5 ; wk(2)=(G-Y)H
-
- mov al, 2 ; Yctr
- jmp short .Yloop_1st
- alignx 16, 7
-
-.Yloop_2nd:
- movdqa xmm0, XMMWORD [wk(1)] ; xmm0=(R-Y)H
- movdqa xmm2, XMMWORD [wk(2)] ; xmm2=(G-Y)H
- movdqa xmm4, XMMWORD [wk(0)] ; xmm4=(B-Y)H
- alignx 16, 7
-
-.Yloop_1st:
- movdqa xmm7, XMMWORD [esi] ; xmm7=Y(0123456789ABCDEF)
-
- pcmpeqw xmm6, xmm6
- psrlw xmm6, BYTE_BIT ; xmm6={0xFF 0x00 0xFF 0x00 ..}
- pand xmm6, xmm7 ; xmm6=Y(02468ACE)=YE
- psrlw xmm7, BYTE_BIT ; xmm7=Y(13579BDF)=YO
-
- movdqa xmm1, xmm0 ; xmm1=xmm0=(R-Y)(L/H)
- movdqa xmm3, xmm2 ; xmm3=xmm2=(G-Y)(L/H)
- movdqa xmm5, xmm4 ; xmm5=xmm4=(B-Y)(L/H)
-
- paddw xmm0, xmm6 ; xmm0=((R-Y)+YE)=RE=R(02468ACE)
- paddw xmm1, xmm7 ; xmm1=((R-Y)+YO)=RO=R(13579BDF)
- packuswb xmm0, xmm0 ; xmm0=R(02468ACE********)
- packuswb xmm1, xmm1 ; xmm1=R(13579BDF********)
-
- paddw xmm2, xmm6 ; xmm2=((G-Y)+YE)=GE=G(02468ACE)
- paddw xmm3, xmm7 ; xmm3=((G-Y)+YO)=GO=G(13579BDF)
- packuswb xmm2, xmm2 ; xmm2=G(02468ACE********)
- packuswb xmm3, xmm3 ; xmm3=G(13579BDF********)
-
- paddw xmm4, xmm6 ; xmm4=((B-Y)+YE)=BE=B(02468ACE)
- paddw xmm5, xmm7 ; xmm5=((B-Y)+YO)=BO=B(13579BDF)
- packuswb xmm4, xmm4 ; xmm4=B(02468ACE********)
- packuswb xmm5, xmm5 ; xmm5=B(13579BDF********)
-
-%if RGB_PIXELSIZE == 3 ; ---------------
-
- ; xmmA=(00 02 04 06 08 0A 0C 0E **), xmmB=(01 03 05 07 09 0B 0D 0F **)
- ; xmmC=(10 12 14 16 18 1A 1C 1E **), xmmD=(11 13 15 17 19 1B 1D 1F **)
- ; xmmE=(20 22 24 26 28 2A 2C 2E **), xmmF=(21 23 25 27 29 2B 2D 2F **)
- ; xmmG=(** ** ** ** ** ** ** ** **), xmmH=(** ** ** ** ** ** ** ** **)
-
- punpcklbw xmmA, xmmC ; xmmA=(00 10 02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E)
- punpcklbw xmmE, xmmB ; xmmE=(20 01 22 03 24 05 26 07 28 09 2A 0B 2C 0D 2E 0F)
- punpcklbw xmmD, xmmF ; xmmD=(11 21 13 23 15 25 17 27 19 29 1B 2B 1D 2D 1F 2F)
-
- movdqa xmmG, xmmA
- movdqa xmmH, xmmA
- punpcklwd xmmA, xmmE ; xmmA=(00 10 20 01 02 12 22 03 04 14 24 05 06 16 26 07)
- punpckhwd xmmG, xmmE ; xmmG=(08 18 28 09 0A 1A 2A 0B 0C 1C 2C 0D 0E 1E 2E 0F)
-
- psrldq xmmH, 2 ; xmmH=(02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E -- --)
- psrldq xmmE, 2 ; xmmE=(22 03 24 05 26 07 28 09 2A 0B 2C 0D 2E 0F -- --)
-
- movdqa xmmC, xmmD
- movdqa xmmB, xmmD
- punpcklwd xmmD, xmmH ; xmmD=(11 21 02 12 13 23 04 14 15 25 06 16 17 27 08 18)
- punpckhwd xmmC, xmmH ; xmmC=(19 29 0A 1A 1B 2B 0C 1C 1D 2D 0E 1E 1F 2F -- --)
-
- psrldq xmmB, 2 ; xmmB=(13 23 15 25 17 27 19 29 1B 2B 1D 2D 1F 2F -- --)
-
- movdqa xmmF, xmmE
- punpcklwd xmmE, xmmB ; xmmE=(22 03 13 23 24 05 15 25 26 07 17 27 28 09 19 29)
- punpckhwd xmmF, xmmB ; xmmF=(2A 0B 1B 2B 2C 0D 1D 2D 2E 0F 1F 2F -- -- -- --)
-
- pshufd xmmH, xmmA, 0x4E ; xmmH=(04 14 24 05 06 16 26 07 00 10 20 01 02 12 22 03)
- movdqa xmmB, xmmE
- punpckldq xmmA, xmmD ; xmmA=(00 10 20 01 11 21 02 12 02 12 22 03 13 23 04 14)
- punpckldq xmmE, xmmH ; xmmE=(22 03 13 23 04 14 24 05 24 05 15 25 06 16 26 07)
- punpckhdq xmmD, xmmB ; xmmD=(15 25 06 16 26 07 17 27 17 27 08 18 28 09 19 29)
-
- pshufd xmmH, xmmG, 0x4E ; xmmH=(0C 1C 2C 0D 0E 1E 2E 0F 08 18 28 09 0A 1A 2A 0B)
- movdqa xmmB, xmmF
- punpckldq xmmG, xmmC ; xmmG=(08 18 28 09 19 29 0A 1A 0A 1A 2A 0B 1B 2B 0C 1C)
- punpckldq xmmF, xmmH ; xmmF=(2A 0B 1B 2B 0C 1C 2C 0D 2C 0D 1D 2D 0E 1E 2E 0F)
- punpckhdq xmmC, xmmB ; xmmC=(1D 2D 0E 1E 2E 0F 1F 2F 1F 2F -- -- -- -- -- --)
-
- punpcklqdq xmmA, xmmE ; xmmA=(00 10 20 01 11 21 02 12 22 03 13 23 04 14 24 05)
- punpcklqdq xmmD, xmmG ; xmmD=(15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A)
- punpcklqdq xmmF, xmmC ; xmmF=(2A 0B 1B 2B 0C 1C 2C 0D 1D 2D 0E 1E 2E 0F 1F 2F)
-
- cmp ecx, byte SIZEOF_XMMWORD
- jb short .column_st32
-
- test edi, SIZEOF_XMMWORD-1
- jnz short .out1
- ; --(aligned)-------------------
- movntdq XMMWORD [edi+0*SIZEOF_XMMWORD], xmmA
- movntdq XMMWORD [edi+1*SIZEOF_XMMWORD], xmmD
- movntdq XMMWORD [edi+2*SIZEOF_XMMWORD], xmmF
- jmp short .out0
-.out1: ; --(unaligned)-----------------
- movdqu XMMWORD [edi+0*SIZEOF_XMMWORD], xmmA
- movdqu XMMWORD [edi+1*SIZEOF_XMMWORD], xmmD
- movdqu XMMWORD [edi+2*SIZEOF_XMMWORD], xmmF
-.out0:
- add edi, byte RGB_PIXELSIZE*SIZEOF_XMMWORD ; outptr
- sub ecx, byte SIZEOF_XMMWORD
- jz near .endcolumn
-
- add esi, byte SIZEOF_XMMWORD ; inptr0
- dec al ; Yctr
- jnz near .Yloop_2nd
-
- add ebx, byte SIZEOF_XMMWORD ; inptr1
- add edx, byte SIZEOF_XMMWORD ; inptr2
- jmp near .columnloop
- alignx 16, 7
-
-.column_st32:
- lea ecx, [ecx+ecx*2] ; imul ecx, RGB_PIXELSIZE
- cmp ecx, byte 2*SIZEOF_XMMWORD
- jb short .column_st16
- movdqu XMMWORD [edi+0*SIZEOF_XMMWORD], xmmA
- movdqu XMMWORD [edi+1*SIZEOF_XMMWORD], xmmD
- add edi, byte 2*SIZEOF_XMMWORD ; outptr
- movdqa xmmA, xmmF
- sub ecx, byte 2*SIZEOF_XMMWORD
- jmp short .column_st15
-.column_st16:
- cmp ecx, byte SIZEOF_XMMWORD
- jb short .column_st15
- movdqu XMMWORD [edi+0*SIZEOF_XMMWORD], xmmA
- add edi, byte SIZEOF_XMMWORD ; outptr
- movdqa xmmA, xmmD
- sub ecx, byte SIZEOF_XMMWORD
-.column_st15:
- ; Store the lower 8 bytes of xmmA to the output when it has enough
- ; space.
- cmp ecx, byte SIZEOF_MMWORD
- jb short .column_st7
- movq XMM_MMWORD [edi], xmmA
- add edi, byte SIZEOF_MMWORD
- sub ecx, byte SIZEOF_MMWORD
- psrldq xmmA, SIZEOF_MMWORD
-.column_st7:
- ; Store the lower 4 bytes of xmmA to the output when it has enough
- ; space.
- cmp ecx, byte SIZEOF_DWORD
- jb short .column_st3
- movd XMM_DWORD [edi], xmmA
- add edi, byte SIZEOF_DWORD
- sub ecx, byte SIZEOF_DWORD
- psrldq xmmA, SIZEOF_DWORD
-.column_st3:
- ; Store the lower 2 bytes of eax to the output when it has enough
- ; space.
- movd eax, xmmA
- cmp ecx, byte SIZEOF_WORD
- jb short .column_st1
- mov word [edi], ax
- add edi, byte SIZEOF_WORD
- sub ecx, byte SIZEOF_WORD
- shr eax, 16
-.column_st1:
- ; Store the lower 1 byte of eax to the output when it has enough
- ; space.
- test ecx, ecx
- jz short .endcolumn
- mov byte [edi], al
-
-%else ; RGB_PIXELSIZE == 4 ; -----------
-
-%ifdef RGBX_FILLER_0XFF
- pcmpeqb xmm6, xmm6 ; xmm6=XE=X(02468ACE********)
- pcmpeqb xmm7, xmm7 ; xmm7=XO=X(13579BDF********)
-%else
- pxor xmm6, xmm6 ; xmm6=XE=X(02468ACE********)
- pxor xmm7, xmm7 ; xmm7=XO=X(13579BDF********)
-%endif
- ; xmmA=(00 02 04 06 08 0A 0C 0E **), xmmB=(01 03 05 07 09 0B 0D 0F **)
- ; xmmC=(10 12 14 16 18 1A 1C 1E **), xmmD=(11 13 15 17 19 1B 1D 1F **)
- ; xmmE=(20 22 24 26 28 2A 2C 2E **), xmmF=(21 23 25 27 29 2B 2D 2F **)
- ; xmmG=(30 32 34 36 38 3A 3C 3E **), xmmH=(31 33 35 37 39 3B 3D 3F **)
-
- punpcklbw xmmA, xmmC ; xmmA=(00 10 02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E)
- punpcklbw xmmE, xmmG ; xmmE=(20 30 22 32 24 34 26 36 28 38 2A 3A 2C 3C 2E 3E)
- punpcklbw xmmB, xmmD ; xmmB=(01 11 03 13 05 15 07 17 09 19 0B 1B 0D 1D 0F 1F)
- punpcklbw xmmF, xmmH ; xmmF=(21 31 23 33 25 35 27 37 29 39 2B 3B 2D 3D 2F 3F)
-
- movdqa xmmC, xmmA
- punpcklwd xmmA, xmmE ; xmmA=(00 10 20 30 02 12 22 32 04 14 24 34 06 16 26 36)
- punpckhwd xmmC, xmmE ; xmmC=(08 18 28 38 0A 1A 2A 3A 0C 1C 2C 3C 0E 1E 2E 3E)
- movdqa xmmG, xmmB
- punpcklwd xmmB, xmmF ; xmmB=(01 11 21 31 03 13 23 33 05 15 25 35 07 17 27 37)
- punpckhwd xmmG, xmmF ; xmmG=(09 19 29 39 0B 1B 2B 3B 0D 1D 2D 3D 0F 1F 2F 3F)
-
- movdqa xmmD, xmmA
- punpckldq xmmA, xmmB ; xmmA=(00 10 20 30 01 11 21 31 02 12 22 32 03 13 23 33)
- punpckhdq xmmD, xmmB ; xmmD=(04 14 24 34 05 15 25 35 06 16 26 36 07 17 27 37)
- movdqa xmmH, xmmC
- punpckldq xmmC, xmmG ; xmmC=(08 18 28 38 09 19 29 39 0A 1A 2A 3A 0B 1B 2B 3B)
- punpckhdq xmmH, xmmG ; xmmH=(0C 1C 2C 3C 0D 1D 2D 3D 0E 1E 2E 3E 0F 1F 2F 3F)
-
- cmp ecx, byte SIZEOF_XMMWORD
- jb short .column_st32
-
- test edi, SIZEOF_XMMWORD-1
- jnz short .out1
- ; --(aligned)-------------------
- movntdq XMMWORD [edi+0*SIZEOF_XMMWORD], xmmA
- movntdq XMMWORD [edi+1*SIZEOF_XMMWORD], xmmD
- movntdq XMMWORD [edi+2*SIZEOF_XMMWORD], xmmC
- movntdq XMMWORD [edi+3*SIZEOF_XMMWORD], xmmH
- jmp short .out0
-.out1: ; --(unaligned)-----------------
- movdqu XMMWORD [edi+0*SIZEOF_XMMWORD], xmmA
- movdqu XMMWORD [edi+1*SIZEOF_XMMWORD], xmmD
- movdqu XMMWORD [edi+2*SIZEOF_XMMWORD], xmmC
- movdqu XMMWORD [edi+3*SIZEOF_XMMWORD], xmmH
-.out0:
- add edi, byte RGB_PIXELSIZE*SIZEOF_XMMWORD ; outptr
- sub ecx, byte SIZEOF_XMMWORD
- jz near .endcolumn
-
- add esi, byte SIZEOF_XMMWORD ; inptr0
- dec al ; Yctr
- jnz near .Yloop_2nd
-
- add ebx, byte SIZEOF_XMMWORD ; inptr1
- add edx, byte SIZEOF_XMMWORD ; inptr2
- jmp near .columnloop
- alignx 16, 7
-
-.column_st32:
- cmp ecx, byte SIZEOF_XMMWORD/2
- jb short .column_st16
- movdqu XMMWORD [edi+0*SIZEOF_XMMWORD], xmmA
- movdqu XMMWORD [edi+1*SIZEOF_XMMWORD], xmmD
- add edi, byte 2*SIZEOF_XMMWORD ; outptr
- movdqa xmmA, xmmC
- movdqa xmmD, xmmH
- sub ecx, byte SIZEOF_XMMWORD/2
-.column_st16:
- cmp ecx, byte SIZEOF_XMMWORD/4
- jb short .column_st15
- movdqu XMMWORD [edi+0*SIZEOF_XMMWORD], xmmA
- add edi, byte SIZEOF_XMMWORD ; outptr
- movdqa xmmA, xmmD
- sub ecx, byte SIZEOF_XMMWORD/4
-.column_st15:
- ; Store two pixels (8 bytes) of xmmA to the output when it has enough
- ; space.
- cmp ecx, byte SIZEOF_XMMWORD/8
- jb short .column_st7
- movq XMM_MMWORD [edi], xmmA
- add edi, byte SIZEOF_XMMWORD/8*4
- sub ecx, byte SIZEOF_XMMWORD/8
- psrldq xmmA, SIZEOF_XMMWORD/8*4
-.column_st7:
- ; Store one pixel (4 bytes) of xmmA to the output when it has enough
- ; space.
- test ecx, ecx
- jz short .endcolumn
- movd XMM_DWORD [edi], xmmA
-
-%endif ; RGB_PIXELSIZE ; ---------------
-
-.endcolumn:
- sfence ; flush the write buffer
-
-.return:
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- pop ebx
- mov esp, ebp ; esp <- aligned ebp
- pop esp ; esp <- original ebp
- pop ebp
- ret
-
-; --------------------------------------------------------------------------
-;
-; Upsample and color convert for the case of 2:1 horizontal and 2:1 vertical.
-;
-; GLOBAL(void)
-; jsimd_h2v2_merged_upsample_sse2(JDIMENSION output_width,
-; JSAMPIMAGE input_buf,
-; JDIMENSION in_row_group_ctr,
-; JSAMPARRAY output_buf);
-;
-
-%define output_width(b) (b) + 8 ; JDIMENSION output_width
-%define input_buf(b) (b) + 12 ; JSAMPIMAGE input_buf
-%define in_row_group_ctr(b) (b) + 16 ; JDIMENSION in_row_group_ctr
-%define output_buf(b) (b) + 20 ; JSAMPARRAY output_buf
-
- align 32
- GLOBAL_FUNCTION(jsimd_h2v2_merged_upsample_sse2)
-
-EXTN(jsimd_h2v2_merged_upsample_sse2):
- push ebp
- mov ebp, esp
- push ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- mov eax, POINTER [output_width(ebp)]
-
- mov edi, JSAMPIMAGE [input_buf(ebp)]
- mov ecx, JDIMENSION [in_row_group_ctr(ebp)]
- mov esi, JSAMPARRAY [edi+0*SIZEOF_JSAMPARRAY]
- mov ebx, JSAMPARRAY [edi+1*SIZEOF_JSAMPARRAY]
- mov edx, JSAMPARRAY [edi+2*SIZEOF_JSAMPARRAY]
- mov edi, JSAMPARRAY [output_buf(ebp)]
- lea esi, [esi+ecx*SIZEOF_JSAMPROW]
-
- push edx ; inptr2
- push ebx ; inptr1
- push esi ; inptr00
- mov ebx, esp
-
- push edi ; output_buf (outptr0)
- push ecx ; in_row_group_ctr
- push ebx ; input_buf
- push eax ; output_width
-
- call near EXTN(jsimd_h2v1_merged_upsample_sse2)
-
- add esi, byte SIZEOF_JSAMPROW ; inptr01
- add edi, byte SIZEOF_JSAMPROW ; outptr1
- mov POINTER [ebx+0*SIZEOF_POINTER], esi
- mov POINTER [ebx-1*SIZEOF_POINTER], edi
-
- call near EXTN(jsimd_h2v1_merged_upsample_sse2)
-
- add esp, byte 7*SIZEOF_DWORD
-
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- pop ebx
- pop ebp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jdsample-avx2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jdsample-avx2.asm
deleted file mode 100644
index a800c35e08..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jdsample-avx2.asm
+++ /dev/null
@@ -1,760 +0,0 @@
-;
-; jdsample.asm - upsampling (AVX2)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2015, Intel Corporation.
-; Copyright (C) 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jsimdext.inc"
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_fancy_upsample_avx2)
-
-EXTN(jconst_fancy_upsample_avx2):
-
-PW_ONE times 16 dw 1
-PW_TWO times 16 dw 2
-PW_THREE times 16 dw 3
-PW_SEVEN times 16 dw 7
-PW_EIGHT times 16 dw 8
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-;
-; Fancy processing for the common case of 2:1 horizontal and 1:1 vertical.
-;
-; The upsampling algorithm is linear interpolation between pixel centers,
-; also known as a "triangle filter". This is a good compromise between
-; speed and visual quality. The centers of the output pixels are 1/4 and 3/4
-; of the way between input pixel centers.
-;
-; GLOBAL(void)
-; jsimd_h2v1_fancy_upsample_avx2(int max_v_samp_factor,
-; JDIMENSION downsampled_width,
-; JSAMPARRAY input_data,
-; JSAMPARRAY *output_data_ptr);
-;
-
-%define max_v_samp(b) (b) + 8 ; int max_v_samp_factor
-%define downsamp_width(b) (b) + 12 ; JDIMENSION downsampled_width
-%define input_data(b) (b) + 16 ; JSAMPARRAY input_data
-%define output_data_ptr(b) (b) + 20 ; JSAMPARRAY *output_data_ptr
-
- align 32
- GLOBAL_FUNCTION(jsimd_h2v1_fancy_upsample_avx2)
-
-EXTN(jsimd_h2v1_fancy_upsample_avx2):
- push ebp
- mov ebp, esp
- pushpic ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- get_GOT ebx ; get GOT address
-
- mov eax, JDIMENSION [downsamp_width(ebp)] ; colctr
- test eax, eax
- jz near .return
-
- mov ecx, INT [max_v_samp(ebp)] ; rowctr
- test ecx, ecx
- jz near .return
-
- mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
- mov edi, POINTER [output_data_ptr(ebp)]
- mov edi, JSAMPARRAY [edi] ; output_data
- alignx 16, 7
-.rowloop:
- push eax ; colctr
- push edi
- push esi
-
- mov esi, JSAMPROW [esi] ; inptr
- mov edi, JSAMPROW [edi] ; outptr
-
- test eax, SIZEOF_YMMWORD-1
- jz short .skip
- mov dl, JSAMPLE [esi+(eax-1)*SIZEOF_JSAMPLE]
- mov JSAMPLE [esi+eax*SIZEOF_JSAMPLE], dl ; insert a dummy sample
-.skip:
- vpxor ymm0, ymm0, ymm0 ; ymm0=(all 0's)
- vpcmpeqb xmm7, xmm7, xmm7
- vpsrldq xmm7, xmm7, (SIZEOF_XMMWORD-1) ; (ff -- -- -- ... -- --) LSB is ff
- vpand ymm7, ymm7, YMMWORD [esi+0*SIZEOF_YMMWORD]
-
- add eax, byte SIZEOF_YMMWORD-1
- and eax, byte -SIZEOF_YMMWORD
- cmp eax, byte SIZEOF_YMMWORD
- ja short .columnloop
- alignx 16, 7
-
-.columnloop_last:
- vpcmpeqb xmm6, xmm6, xmm6
- vpslldq xmm6, xmm6, (SIZEOF_XMMWORD-1)
- vperm2i128 ymm6, ymm6, ymm6, 1 ; (---- ---- ... ---- ---- ff) MSB is ff
- vpand ymm6, ymm6, YMMWORD [esi+0*SIZEOF_YMMWORD]
- jmp short .upsample
- alignx 16, 7
-
-.columnloop:
- vmovdqu ymm6, YMMWORD [esi+1*SIZEOF_YMMWORD]
- vperm2i128 ymm6, ymm0, ymm6, 0x20
- vpslldq ymm6, ymm6, 15
-
-.upsample:
- vmovdqu ymm1, YMMWORD [esi+0*SIZEOF_YMMWORD] ; ymm1=( 0 1 2 ... 29 30 31)
-
- vperm2i128 ymm2, ymm0, ymm1, 0x20
- vpalignr ymm2, ymm1, ymm2, 15 ; ymm2=(-- 0 1 ... 28 29 30)
- vperm2i128 ymm4, ymm0, ymm1, 0x03
- vpalignr ymm3, ymm4, ymm1, 1 ; ymm3=( 1 2 3 ... 30 31 --)
-
- vpor ymm2, ymm2, ymm7 ; ymm2=(-1 0 1 ... 28 29 30)
- vpor ymm3, ymm3, ymm6 ; ymm3=( 1 2 3 ... 30 31 32)
-
- vpsrldq ymm7, ymm4, (SIZEOF_XMMWORD-1) ; ymm7=(31 -- -- ... -- -- --)
-
- vpunpckhbw ymm4, ymm1, ymm0 ; ymm4=( 8 9 10 11 12 13 14 15 24 25 26 27 28 29 30 31)
- vpunpcklbw ymm5, ymm1, ymm0 ; ymm5=( 0 1 2 3 4 5 6 7 16 17 18 19 20 21 22 23)
- vperm2i128 ymm1, ymm5, ymm4, 0x20 ; ymm1=( 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)
- vperm2i128 ymm4, ymm5, ymm4, 0x31 ; ymm4=(16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31)
-
- vpunpckhbw ymm5, ymm2, ymm0 ; ymm5=( 7 8 9 10 11 12 13 14 23 24 25 26 27 28 29 30)
- vpunpcklbw ymm6, ymm2, ymm0 ; ymm6=(-1 0 1 2 3 4 5 6 15 16 17 18 19 20 21 22)
- vperm2i128 ymm2, ymm6, ymm5, 0x20 ; ymm2=(-1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14)
- vperm2i128 ymm5, ymm6, ymm5, 0x31 ; ymm5=(15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30)
-
- vpunpckhbw ymm6, ymm3, ymm0 ; ymm6=( 1 2 3 4 5 6 7 8 17 18 19 20 21 22 23 24)
- vpunpcklbw ymm0, ymm3, ymm0 ; ymm0=( 9 10 11 12 13 14 15 16 25 26 27 28 29 30 31 32)
- vperm2i128 ymm3, ymm0, ymm6, 0x20 ; ymm3=( 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16)
- vperm2i128 ymm6, ymm0, ymm6, 0x31 ; ymm6=(17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32)
-
- vpxor ymm0, ymm0, ymm0 ; ymm0=(all 0's)
-
- vpmullw ymm1, ymm1, [GOTOFF(ebx,PW_THREE)]
- vpmullw ymm4, ymm4, [GOTOFF(ebx,PW_THREE)]
- vpaddw ymm2, ymm2, [GOTOFF(ebx,PW_ONE)]
- vpaddw ymm5, ymm5, [GOTOFF(ebx,PW_ONE)]
- vpaddw ymm3, ymm3, [GOTOFF(ebx,PW_TWO)]
- vpaddw ymm6, ymm6, [GOTOFF(ebx,PW_TWO)]
-
- vpaddw ymm2, ymm2, ymm1
- vpaddw ymm5, ymm5, ymm4
- vpsrlw ymm2, ymm2, 2 ; ymm2=OutLE=( 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30)
- vpsrlw ymm5, ymm5, 2 ; ymm5=OutHE=(32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62)
- vpaddw ymm3, ymm3, ymm1
- vpaddw ymm6, ymm6, ymm4
- vpsrlw ymm3, ymm3, 2 ; ymm3=OutLO=( 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31)
- vpsrlw ymm6, ymm6, 2 ; ymm6=OutHO=(33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63)
-
- vpsllw ymm3, ymm3, BYTE_BIT
- vpsllw ymm6, ymm6, BYTE_BIT
- vpor ymm2, ymm2, ymm3 ; ymm2=OutL=( 0 1 2 ... 29 30 31)
- vpor ymm5, ymm5, ymm6 ; ymm5=OutH=(32 33 34 ... 61 62 63)
-
- vmovdqu YMMWORD [edi+0*SIZEOF_YMMWORD], ymm2
- vmovdqu YMMWORD [edi+1*SIZEOF_YMMWORD], ymm5
-
- sub eax, byte SIZEOF_YMMWORD
- add esi, byte 1*SIZEOF_YMMWORD ; inptr
- add edi, byte 2*SIZEOF_YMMWORD ; outptr
- cmp eax, byte SIZEOF_YMMWORD
- ja near .columnloop
- test eax, eax
- jnz near .columnloop_last
-
- pop esi
- pop edi
- pop eax
-
- add esi, byte SIZEOF_JSAMPROW ; input_data
- add edi, byte SIZEOF_JSAMPROW ; output_data
- dec ecx ; rowctr
- jg near .rowloop
-
-.return:
- vzeroupper
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- poppic ebx
- pop ebp
- ret
-
-; --------------------------------------------------------------------------
-;
-; Fancy processing for the common case of 2:1 horizontal and 2:1 vertical.
-; Again a triangle filter; see comments for h2v1 case, above.
-;
-; GLOBAL(void)
-; jsimd_h2v2_fancy_upsample_avx2(int max_v_samp_factor,
-; JDIMENSION downsampled_width,
-; JSAMPARRAY input_data,
-; JSAMPARRAY *output_data_ptr);
-;
-
-%define max_v_samp(b) (b) + 8 ; int max_v_samp_factor
-%define downsamp_width(b) (b) + 12 ; JDIMENSION downsampled_width
-%define input_data(b) (b) + 16 ; JSAMPARRAY input_data
-%define output_data_ptr(b) (b) + 20 ; JSAMPARRAY *output_data_ptr
-
-%define original_ebp ebp + 0
-%define wk(i) ebp - (WK_NUM - (i)) * SIZEOF_YMMWORD
- ; ymmword wk[WK_NUM]
-%define WK_NUM 4
-%define gotptr wk(0) - SIZEOF_POINTER ; void *gotptr
-
- align 32
- GLOBAL_FUNCTION(jsimd_h2v2_fancy_upsample_avx2)
-
-EXTN(jsimd_h2v2_fancy_upsample_avx2):
- push ebp
- mov eax, esp ; eax = original ebp
- sub esp, byte 4
- and esp, byte (-SIZEOF_YMMWORD) ; align to 256 bits
- mov [esp], eax
- mov ebp, esp ; ebp = aligned ebp
- lea esp, [wk(0)]
- pushpic eax ; make a room for GOT address
- push ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- get_GOT ebx ; get GOT address
- movpic POINTER [gotptr], ebx ; save GOT address
-
- mov edx, eax ; edx = original ebp
- mov eax, JDIMENSION [downsamp_width(edx)] ; colctr
- test eax, eax
- jz near .return
-
- mov ecx, INT [max_v_samp(edx)] ; rowctr
- test ecx, ecx
- jz near .return
-
- mov esi, JSAMPARRAY [input_data(edx)] ; input_data
- mov edi, POINTER [output_data_ptr(edx)]
- mov edi, JSAMPARRAY [edi] ; output_data
- alignx 16, 7
-.rowloop:
- push eax ; colctr
- push ecx
- push edi
- push esi
-
- mov ecx, JSAMPROW [esi-1*SIZEOF_JSAMPROW] ; inptr1(above)
- mov ebx, JSAMPROW [esi+0*SIZEOF_JSAMPROW] ; inptr0
- mov esi, JSAMPROW [esi+1*SIZEOF_JSAMPROW] ; inptr1(below)
- mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW] ; outptr0
- mov edi, JSAMPROW [edi+1*SIZEOF_JSAMPROW] ; outptr1
-
- test eax, SIZEOF_YMMWORD-1
- jz short .skip
- push edx
- mov dl, JSAMPLE [ecx+(eax-1)*SIZEOF_JSAMPLE]
- mov JSAMPLE [ecx+eax*SIZEOF_JSAMPLE], dl
- mov dl, JSAMPLE [ebx+(eax-1)*SIZEOF_JSAMPLE]
- mov JSAMPLE [ebx+eax*SIZEOF_JSAMPLE], dl
- mov dl, JSAMPLE [esi+(eax-1)*SIZEOF_JSAMPLE]
- mov JSAMPLE [esi+eax*SIZEOF_JSAMPLE], dl ; insert a dummy sample
- pop edx
-.skip:
- ; -- process the first column block
-
- vmovdqu ymm0, YMMWORD [ebx+0*SIZEOF_YMMWORD] ; ymm0=row[ 0][0]
- vmovdqu ymm1, YMMWORD [ecx+0*SIZEOF_YMMWORD] ; ymm1=row[-1][0]
- vmovdqu ymm2, YMMWORD [esi+0*SIZEOF_YMMWORD] ; ymm2=row[+1][0]
-
- pushpic ebx
- movpic ebx, POINTER [gotptr] ; load GOT address
-
- vpxor ymm3, ymm3, ymm3 ; ymm3=(all 0's)
-
- vpunpckhbw ymm4, ymm0, ymm3 ; ymm4=row[ 0]( 8 9 10 11 12 13 14 15 24 25 26 27 28 29 30 31)
- vpunpcklbw ymm5, ymm0, ymm3 ; ymm5=row[ 0]( 0 1 2 3 4 5 6 7 16 17 18 19 20 21 22 23)
- vperm2i128 ymm0, ymm5, ymm4, 0x20 ; ymm0=row[ 0]( 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)
- vperm2i128 ymm4, ymm5, ymm4, 0x31 ; ymm4=row[ 0](16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31)
-
- vpunpckhbw ymm5, ymm1, ymm3 ; ymm5=row[-1]( 8 9 10 11 12 13 14 15 24 25 26 27 28 29 30 31)
- vpunpcklbw ymm6, ymm1, ymm3 ; ymm6=row[-1]( 0 1 2 3 4 5 6 7 16 17 18 19 20 21 22 23)
- vperm2i128 ymm1, ymm6, ymm5, 0x20 ; ymm1=row[-1]( 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)
- vperm2i128 ymm5, ymm6, ymm5, 0x31 ; ymm5=row[-1](16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31)
-
- vpunpckhbw ymm6, ymm2, ymm3 ; ymm6=row[+1]( 8 9 10 11 12 13 14 15 24 25 26 27 28 29 30 31)
- vpunpcklbw ymm3, ymm2, ymm3 ; ymm3=row[+1]( 0 1 2 3 4 5 6 7 16 17 18 19 20 21 22 23)
- vperm2i128 ymm2, ymm3, ymm6, 0x20 ; ymm2=row[+1]( 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)
- vperm2i128 ymm6, ymm3, ymm6, 0x31 ; ymm6=row[+1](16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31)
-
- vpmullw ymm0, ymm0, [GOTOFF(ebx,PW_THREE)]
- vpmullw ymm4, ymm4, [GOTOFF(ebx,PW_THREE)]
-
- vpcmpeqb xmm7, xmm7, xmm7
- vpsrldq xmm7, xmm7, (SIZEOF_XMMWORD-2) ; (ffff ---- ---- ... ---- ----) LSB is ffff
-
- vpaddw ymm1, ymm1, ymm0 ; ymm1=Int0L=( 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)
- vpaddw ymm5, ymm5, ymm4 ; ymm5=Int0H=(16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31)
- vpaddw ymm2, ymm2, ymm0 ; ymm2=Int1L=( 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)
- vpaddw ymm6, ymm6, ymm4 ; ymm6=Int1H=(16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31)
-
- vmovdqu YMMWORD [edx+0*SIZEOF_YMMWORD], ymm1 ; temporarily save
- vmovdqu YMMWORD [edx+1*SIZEOF_YMMWORD], ymm5 ; the intermediate data
- vmovdqu YMMWORD [edi+0*SIZEOF_YMMWORD], ymm2
- vmovdqu YMMWORD [edi+1*SIZEOF_YMMWORD], ymm6
-
- vpand ymm1, ymm1, ymm7 ; ymm1=( 0 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --)
- vpand ymm2, ymm2, ymm7 ; ymm2=( 0 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --)
-
- vmovdqa YMMWORD [wk(0)], ymm1
- vmovdqa YMMWORD [wk(1)], ymm2
-
- poppic ebx
-
- add eax, byte SIZEOF_YMMWORD-1
- and eax, byte -SIZEOF_YMMWORD
- cmp eax, byte SIZEOF_YMMWORD
- ja short .columnloop
- alignx 16, 7
-
-.columnloop_last:
- ; -- process the last column block
-
- pushpic ebx
- movpic ebx, POINTER [gotptr] ; load GOT address
-
- vpcmpeqb xmm1, xmm1, xmm1
- vpslldq xmm1, xmm1, (SIZEOF_XMMWORD-2)
- vperm2i128 ymm1, ymm1, ymm1, 1 ; (---- ---- ... ---- ---- ffff) MSB is ffff
-
- vpand ymm2, ymm1, YMMWORD [edi+1*SIZEOF_YMMWORD]
- vpand ymm1, ymm1, YMMWORD [edx+1*SIZEOF_YMMWORD]
-
- vmovdqa YMMWORD [wk(2)], ymm1 ; ymm1=(-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 31)
- vmovdqa YMMWORD [wk(3)], ymm2 ; ymm2=(-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 31)
-
- jmp near .upsample
- alignx 16, 7
-
-.columnloop:
- ; -- process the next column block
-
- vmovdqu ymm0, YMMWORD [ebx+1*SIZEOF_YMMWORD] ; ymm0=row[ 0][1]
- vmovdqu ymm1, YMMWORD [ecx+1*SIZEOF_YMMWORD] ; ymm1=row[-1][1]
- vmovdqu ymm2, YMMWORD [esi+1*SIZEOF_YMMWORD] ; ymm2=row[+1][1]
-
- pushpic ebx
- movpic ebx, POINTER [gotptr] ; load GOT address
-
- vpxor ymm3, ymm3, ymm3 ; ymm3=(all 0's)
-
- vpunpckhbw ymm4, ymm0, ymm3 ; ymm4=row[ 0]( 8 9 10 11 12 13 14 15 24 25 26 27 28 29 30 31)
- vpunpcklbw ymm5, ymm0, ymm3 ; ymm5=row[ 0]( 0 1 2 3 4 5 6 7 16 17 18 19 20 21 22 23)
- vperm2i128 ymm0, ymm5, ymm4, 0x20 ; ymm0=row[ 0]( 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)
- vperm2i128 ymm4, ymm5, ymm4, 0x31 ; ymm4=row[ 0](16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31)
-
- vpunpckhbw ymm5, ymm1, ymm3 ; ymm5=row[-1]( 8 9 10 11 12 13 14 15 24 25 26 27 28 29 30 31)
- vpunpcklbw ymm6, ymm1, ymm3 ; ymm6=row[-1]( 0 1 2 3 4 5 6 7 16 17 18 19 20 21 22 23)
- vperm2i128 ymm1, ymm6, ymm5, 0x20 ; ymm1=row[-1]( 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)
- vperm2i128 ymm5, ymm6, ymm5, 0x31 ; ymm5=row[-1](16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31)
-
- vpunpckhbw ymm6, ymm2, ymm3 ; ymm6=row[+1]( 8 9 10 11 12 13 14 15 24 25 26 27 28 29 30 31)
- vpunpcklbw ymm7, ymm2, ymm3 ; ymm7=row[+1]( 0 1 2 3 4 5 6 7 16 17 18 19 20 21 22 23)
- vperm2i128 ymm2, ymm7, ymm6, 0x20 ; ymm2=row[+1]( 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)
- vperm2i128 ymm6, ymm7, ymm6, 0x31 ; ymm6=row[+1](16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31)
-
- vpmullw ymm0, ymm0, [GOTOFF(ebx,PW_THREE)]
- vpmullw ymm4, ymm4, [GOTOFF(ebx,PW_THREE)]
-
- vpaddw ymm1, ymm1, ymm0 ; ymm1=Int0L=( 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)
- vpaddw ymm5, ymm5, ymm4 ; ymm5=Int0H=(16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31)
- vpaddw ymm2, ymm2, ymm0 ; ymm2=Int1L=( 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)
- vpaddw ymm6, ymm6, ymm4 ; ymm6=Int1H=(16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31)
-
- vmovdqu YMMWORD [edx+2*SIZEOF_YMMWORD], ymm1 ; temporarily save
- vmovdqu YMMWORD [edx+3*SIZEOF_YMMWORD], ymm5 ; the intermediate data
- vmovdqu YMMWORD [edi+2*SIZEOF_YMMWORD], ymm2
- vmovdqu YMMWORD [edi+3*SIZEOF_YMMWORD], ymm6
-
- vperm2i128 ymm1, ymm3, ymm1, 0x20
- vpslldq ymm1, ymm1, 14 ; ymm1=(-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 0)
- vperm2i128 ymm2, ymm3, ymm2, 0x20
- vpslldq ymm2, ymm2, 14 ; ymm2=(-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 0)
-
- vmovdqa YMMWORD [wk(2)], ymm1
- vmovdqa YMMWORD [wk(3)], ymm2
-
-.upsample:
- ; -- process the upper row
-
- vmovdqu ymm7, YMMWORD [edx+0*SIZEOF_YMMWORD] ; ymm7=Int0L=( 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)
- vmovdqu ymm3, YMMWORD [edx+1*SIZEOF_YMMWORD] ; ymm3=Int0H=(16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31)
-
- vpxor ymm1, ymm1, ymm1 ; ymm1=(all 0's)
-
- vperm2i128 ymm0, ymm1, ymm7, 0x03
- vpalignr ymm0, ymm0, ymm7, 2 ; ymm0=( 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 --)
- vperm2i128 ymm4, ymm1, ymm3, 0x20
- vpslldq ymm4, ymm4, 14 ; ymm4=(-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 16)
-
- vperm2i128 ymm5, ymm1, ymm7, 0x03
- vpsrldq ymm5, ymm5, 14 ; ymm5=(15 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --)
- vperm2i128 ymm6, ymm1, ymm3, 0x20
- vpalignr ymm6, ymm3, ymm6, 14 ; ymm6=(-- 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30)
-
- vpor ymm0, ymm0, ymm4 ; ymm0=( 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16)
- vpor ymm5, ymm5, ymm6 ; ymm5=(15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30)
-
- vperm2i128 ymm2, ymm1, ymm3, 0x03
- vpalignr ymm2, ymm2, ymm3, 2 ; ymm2=(17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 --)
- vperm2i128 ymm4, ymm1, ymm3, 0x03
- vpsrldq ymm4, ymm4, 14 ; ymm4=(31 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --)
- vperm2i128 ymm1, ymm1, ymm7, 0x20
- vpalignr ymm1, ymm7, ymm1, 14 ; ymm1=(-- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14)
-
- vpor ymm1, ymm1, YMMWORD [wk(0)] ; ymm1=(-1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14)
- vpor ymm2, ymm2, YMMWORD [wk(2)] ; ymm2=(17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32)
-
- vmovdqa YMMWORD [wk(0)], ymm4
-
- vpmullw ymm7, ymm7, [GOTOFF(ebx,PW_THREE)]
- vpmullw ymm3, ymm3, [GOTOFF(ebx,PW_THREE)]
- vpaddw ymm1, ymm1, [GOTOFF(ebx,PW_EIGHT)]
- vpaddw ymm5, ymm5, [GOTOFF(ebx,PW_EIGHT)]
- vpaddw ymm0, ymm0, [GOTOFF(ebx,PW_SEVEN)]
- vpaddw ymm2, [GOTOFF(ebx,PW_SEVEN)]
-
- vpaddw ymm1, ymm1, ymm7
- vpaddw ymm5, ymm5, ymm3
- vpsrlw ymm1, ymm1, 4 ; ymm1=Out0LE=( 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30)
- vpsrlw ymm5, ymm5, 4 ; ymm5=Out0HE=(32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62)
- vpaddw ymm0, ymm0, ymm7
- vpaddw ymm2, ymm2, ymm3
- vpsrlw ymm0, ymm0, 4 ; ymm0=Out0LO=( 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31)
- vpsrlw ymm2, ymm2, 4 ; ymm2=Out0HO=(33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63)
-
- vpsllw ymm0, ymm0, BYTE_BIT
- vpsllw ymm2, ymm2, BYTE_BIT
- vpor ymm1, ymm1, ymm0 ; ymm1=Out0L=( 0 1 2 ... 29 30 31)
- vpor ymm5, ymm5, ymm2 ; ymm5=Out0H=(32 33 34 ... 61 62 63)
-
- vmovdqu YMMWORD [edx+0*SIZEOF_YMMWORD], ymm1
- vmovdqu YMMWORD [edx+1*SIZEOF_YMMWORD], ymm5
-
- ; -- process the lower row
-
- vmovdqu ymm6, YMMWORD [edi+0*SIZEOF_YMMWORD] ; ymm6=Int1L=( 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)
- vmovdqu ymm4, YMMWORD [edi+1*SIZEOF_YMMWORD] ; ymm4=Int1H=(16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31)
-
- vpxor ymm1, ymm1, ymm1 ; ymm1=(all 0's)
-
- vperm2i128 ymm7, ymm1, ymm6, 0x03
- vpalignr ymm7, ymm7, ymm6, 2 ; ymm7=( 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 --)
- vperm2i128 ymm3, ymm1, ymm4, 0x20
- vpslldq ymm3, ymm3, 14 ; ymm3=(-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 16)
-
- vperm2i128 ymm0, ymm1, ymm6, 0x03
- vpsrldq ymm0, ymm0, 14 ; ymm0=(15 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --)
- vperm2i128 ymm2, ymm1, ymm4, 0x20
- vpalignr ymm2, ymm4, ymm2, 14 ; ymm2=(-- 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30)
-
- vpor ymm7, ymm7, ymm3 ; ymm7=( 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16)
- vpor ymm0, ymm0, ymm2 ; ymm0=(15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30)
-
- vperm2i128 ymm5, ymm1, ymm4, 0x03
- vpalignr ymm5, ymm5, ymm4, 2 ; ymm5=(17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 --)
- vperm2i128 ymm3, ymm1, ymm4, 0x03
- vpsrldq ymm3, ymm3, 14 ; ymm3=(31 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --)
- vperm2i128 ymm1, ymm1, ymm6, 0x20
- vpalignr ymm1, ymm6, ymm1, 14 ; ymm1=(-- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14)
-
- vpor ymm1, ymm1, YMMWORD [wk(1)] ; ymm1=(-1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14)
- vpor ymm5, ymm5, YMMWORD [wk(3)] ; ymm5=(17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32)
-
- vmovdqa YMMWORD [wk(1)], ymm3
-
- vpmullw ymm6, ymm6, [GOTOFF(ebx,PW_THREE)]
- vpmullw ymm4, ymm4, [GOTOFF(ebx,PW_THREE)]
- vpaddw ymm1, ymm1, [GOTOFF(ebx,PW_EIGHT)]
- vpaddw ymm0, ymm0, [GOTOFF(ebx,PW_EIGHT)]
- vpaddw ymm7, ymm7, [GOTOFF(ebx,PW_SEVEN)]
- vpaddw ymm5, ymm5, [GOTOFF(ebx,PW_SEVEN)]
-
- vpaddw ymm1, ymm1, ymm6
- vpaddw ymm0, ymm0, ymm4
- vpsrlw ymm1, ymm1, 4 ; ymm1=Out1LE=( 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30)
- vpsrlw ymm0, ymm0, 4 ; ymm0=Out1HE=(32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62)
- vpaddw ymm7, ymm7, ymm6
- vpaddw ymm5, ymm5, ymm4
- vpsrlw ymm7, ymm7, 4 ; ymm7=Out1LO=( 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31)
- vpsrlw ymm5, ymm5, 4 ; ymm5=Out1HO=(33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63)
-
- vpsllw ymm7, ymm7, BYTE_BIT
- vpsllw ymm5, ymm5, BYTE_BIT
- vpor ymm1, ymm1, ymm7 ; ymm1=Out1L=( 0 1 2 ... 29 30 31)
- vpor ymm0, ymm0, ymm5 ; ymm0=Out1H=(32 33 34 ... 61 62 63)
-
- vmovdqu YMMWORD [edi+0*SIZEOF_YMMWORD], ymm1
- vmovdqu YMMWORD [edi+1*SIZEOF_YMMWORD], ymm0
-
- poppic ebx
-
- sub eax, byte SIZEOF_YMMWORD
- add ecx, byte 1*SIZEOF_YMMWORD ; inptr1(above)
- add ebx, byte 1*SIZEOF_YMMWORD ; inptr0
- add esi, byte 1*SIZEOF_YMMWORD ; inptr1(below)
- add edx, byte 2*SIZEOF_YMMWORD ; outptr0
- add edi, byte 2*SIZEOF_YMMWORD ; outptr1
- cmp eax, byte SIZEOF_YMMWORD
- ja near .columnloop
- test eax, eax
- jnz near .columnloop_last
-
- pop esi
- pop edi
- pop ecx
- pop eax
-
- add esi, byte 1*SIZEOF_JSAMPROW ; input_data
- add edi, byte 2*SIZEOF_JSAMPROW ; output_data
- sub ecx, byte 2 ; rowctr
- jg near .rowloop
-
-.return:
- vzeroupper
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- pop ebx
- mov esp, ebp ; esp <- aligned ebp
- pop esp ; esp <- original ebp
- pop ebp
- ret
-
-; --------------------------------------------------------------------------
-;
-; Fast processing for the common case of 2:1 horizontal and 1:1 vertical.
-; It's still a box filter.
-;
-; GLOBAL(void)
-; jsimd_h2v1_upsample_avx2(int max_v_samp_factor, JDIMENSION output_width,
-; JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr);
-;
-
-%define max_v_samp(b) (b) + 8 ; int max_v_samp_factor
-%define output_width(b) (b) + 12 ; JDIMENSION output_width
-%define input_data(b) (b) + 16 ; JSAMPARRAY input_data
-%define output_data_ptr(b) (b) + 20 ; JSAMPARRAY *output_data_ptr
-
- align 32
- GLOBAL_FUNCTION(jsimd_h2v1_upsample_avx2)
-
-EXTN(jsimd_h2v1_upsample_avx2):
- push ebp
- mov ebp, esp
-; push ebx ; unused
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- mov edx, JDIMENSION [output_width(ebp)]
- add edx, byte (SIZEOF_YMMWORD-1)
- and edx, -SIZEOF_YMMWORD
- jz short .return
-
- mov ecx, INT [max_v_samp(ebp)] ; rowctr
- test ecx, ecx
- jz short .return
-
- mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
- mov edi, POINTER [output_data_ptr(ebp)]
- mov edi, JSAMPARRAY [edi] ; output_data
- alignx 16, 7
-.rowloop:
- push edi
- push esi
-
- mov esi, JSAMPROW [esi] ; inptr
- mov edi, JSAMPROW [edi] ; outptr
- mov eax, edx ; colctr
- alignx 16, 7
-.columnloop:
-
- cmp eax, byte SIZEOF_YMMWORD
- ja near .above_16
-
- vmovdqu xmm0, XMMWORD [esi+0*SIZEOF_YMMWORD]
- vpunpckhbw xmm1, xmm0, xmm0
- vpunpcklbw xmm0, xmm0, xmm0
-
- vmovdqu XMMWORD [edi+0*SIZEOF_XMMWORD], xmm0
- vmovdqu XMMWORD [edi+1*SIZEOF_XMMWORD], xmm1
-
- jmp short .nextrow
-
-.above_16:
- vmovdqu ymm0, YMMWORD [esi+0*SIZEOF_YMMWORD]
-
- vpermq ymm0, ymm0, 0xd8
- vpunpckhbw ymm1, ymm0, ymm0
- vpunpcklbw ymm0, ymm0, ymm0
-
- vmovdqu YMMWORD [edi+0*SIZEOF_YMMWORD], ymm0
- vmovdqu YMMWORD [edi+1*SIZEOF_YMMWORD], ymm1
-
- sub eax, byte 2*SIZEOF_YMMWORD
- jz short .nextrow
-
- add esi, byte SIZEOF_YMMWORD ; inptr
- add edi, byte 2*SIZEOF_YMMWORD ; outptr
- jmp short .columnloop
- alignx 16, 7
-
-.nextrow:
- pop esi
- pop edi
-
- add esi, byte SIZEOF_JSAMPROW ; input_data
- add edi, byte SIZEOF_JSAMPROW ; output_data
- dec ecx ; rowctr
- jg short .rowloop
-
-.return:
- vzeroupper
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
-; pop ebx ; unused
- pop ebp
- ret
-
-; --------------------------------------------------------------------------
-;
-; Fast processing for the common case of 2:1 horizontal and 2:1 vertical.
-; It's still a box filter.
-;
-; GLOBAL(void)
-; jsimd_h2v2_upsample_avx2(int max_v_samp_factor, JDIMENSION output_width,
-; JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr);
-;
-
-%define max_v_samp(b) (b) + 8 ; int max_v_samp_factor
-%define output_width(b) (b) + 12 ; JDIMENSION output_width
-%define input_data(b) (b) + 16 ; JSAMPARRAY input_data
-%define output_data_ptr(b) (b) + 20 ; JSAMPARRAY *output_data_ptr
-
- align 32
- GLOBAL_FUNCTION(jsimd_h2v2_upsample_avx2)
-
-EXTN(jsimd_h2v2_upsample_avx2):
- push ebp
- mov ebp, esp
- push ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- mov edx, JDIMENSION [output_width(ebp)]
- add edx, byte (SIZEOF_YMMWORD-1)
- and edx, -SIZEOF_YMMWORD
- jz near .return
-
- mov ecx, INT [max_v_samp(ebp)] ; rowctr
- test ecx, ecx
- jz near .return
-
- mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
- mov edi, POINTER [output_data_ptr(ebp)]
- mov edi, JSAMPARRAY [edi] ; output_data
- alignx 16, 7
-.rowloop:
- push edi
- push esi
-
- mov esi, JSAMPROW [esi] ; inptr
- mov ebx, JSAMPROW [edi+0*SIZEOF_JSAMPROW] ; outptr0
- mov edi, JSAMPROW [edi+1*SIZEOF_JSAMPROW] ; outptr1
- mov eax, edx ; colctr
- alignx 16, 7
-.columnloop:
-
- cmp eax, byte SIZEOF_YMMWORD
- ja short .above_16
-
- vmovdqu xmm0, XMMWORD [esi+0*SIZEOF_XMMWORD]
- vpunpckhbw xmm1, xmm0, xmm0
- vpunpcklbw xmm0, xmm0, xmm0
-
- vmovdqu XMMWORD [ebx+0*SIZEOF_XMMWORD], xmm0
- vmovdqu XMMWORD [ebx+1*SIZEOF_XMMWORD], xmm1
- vmovdqu XMMWORD [edi+0*SIZEOF_XMMWORD], xmm0
- vmovdqu XMMWORD [edi+1*SIZEOF_XMMWORD], xmm1
-
- jmp near .nextrow
-
-.above_16:
- vmovdqu ymm0, YMMWORD [esi+0*SIZEOF_YMMWORD]
-
- vpermq ymm0, ymm0, 0xd8
- vpunpckhbw ymm1, ymm0, ymm0
- vpunpcklbw ymm0, ymm0, ymm0
-
- vmovdqu YMMWORD [ebx+0*SIZEOF_YMMWORD], ymm0
- vmovdqu YMMWORD [ebx+1*SIZEOF_YMMWORD], ymm1
- vmovdqu YMMWORD [edi+0*SIZEOF_YMMWORD], ymm0
- vmovdqu YMMWORD [edi+1*SIZEOF_YMMWORD], ymm1
-
- sub eax, byte 2*SIZEOF_YMMWORD
- jz short .nextrow
-
- add esi, byte SIZEOF_YMMWORD ; inptr
- add ebx, 2*SIZEOF_YMMWORD ; outptr0
- add edi, 2*SIZEOF_YMMWORD ; outptr1
- jmp short .columnloop
- alignx 16, 7
-
-.nextrow:
- pop esi
- pop edi
-
- add esi, byte 1*SIZEOF_JSAMPROW ; input_data
- add edi, byte 2*SIZEOF_JSAMPROW ; output_data
- sub ecx, byte 2 ; rowctr
- jg near .rowloop
-
-.return:
- vzeroupper
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- pop ebx
- pop ebp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jdsample-mmx.asm b/contrib/libs/libjpeg-turbo/simd/i386/jdsample-mmx.asm
deleted file mode 100644
index 12c49f0eab..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jdsample-mmx.asm
+++ /dev/null
@@ -1,731 +0,0 @@
-;
-; jdsample.asm - upsampling (MMX)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jsimdext.inc"
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_fancy_upsample_mmx)
-
-EXTN(jconst_fancy_upsample_mmx):
-
-PW_ONE times 4 dw 1
-PW_TWO times 4 dw 2
-PW_THREE times 4 dw 3
-PW_SEVEN times 4 dw 7
-PW_EIGHT times 4 dw 8
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-;
-; Fancy processing for the common case of 2:1 horizontal and 1:1 vertical.
-;
-; The upsampling algorithm is linear interpolation between pixel centers,
-; also known as a "triangle filter". This is a good compromise between
-; speed and visual quality. The centers of the output pixels are 1/4 and 3/4
-; of the way between input pixel centers.
-;
-; GLOBAL(void)
-; jsimd_h2v1_fancy_upsample_mmx(int max_v_samp_factor,
-; JDIMENSION downsampled_width,
-; JSAMPARRAY input_data,
-; JSAMPARRAY *output_data_ptr);
-;
-
-%define max_v_samp(b) (b) + 8 ; int max_v_samp_factor
-%define downsamp_width(b) (b) + 12 ; JDIMENSION downsampled_width
-%define input_data(b) (b) + 16 ; JSAMPARRAY input_data
-%define output_data_ptr(b) (b) + 20 ; JSAMPARRAY *output_data_ptr
-
- align 32
- GLOBAL_FUNCTION(jsimd_h2v1_fancy_upsample_mmx)
-
-EXTN(jsimd_h2v1_fancy_upsample_mmx):
- push ebp
- mov ebp, esp
- pushpic ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- get_GOT ebx ; get GOT address
-
- mov eax, JDIMENSION [downsamp_width(ebp)] ; colctr
- test eax, eax
- jz near .return
-
- mov ecx, INT [max_v_samp(ebp)] ; rowctr
- test ecx, ecx
- jz near .return
-
- mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
- mov edi, POINTER [output_data_ptr(ebp)]
- mov edi, JSAMPARRAY [edi] ; output_data
- alignx 16, 7
-.rowloop:
- push eax ; colctr
- push edi
- push esi
-
- mov esi, JSAMPROW [esi] ; inptr
- mov edi, JSAMPROW [edi] ; outptr
-
- test eax, SIZEOF_MMWORD-1
- jz short .skip
- mov dl, JSAMPLE [esi+(eax-1)*SIZEOF_JSAMPLE]
- mov JSAMPLE [esi+eax*SIZEOF_JSAMPLE], dl ; insert a dummy sample
-.skip:
- pxor mm0, mm0 ; mm0=(all 0's)
- pcmpeqb mm7, mm7
- psrlq mm7, (SIZEOF_MMWORD-1)*BYTE_BIT
- pand mm7, MMWORD [esi+0*SIZEOF_MMWORD]
-
- add eax, byte SIZEOF_MMWORD-1
- and eax, byte -SIZEOF_MMWORD
- cmp eax, byte SIZEOF_MMWORD
- ja short .columnloop
- alignx 16, 7
-
-.columnloop_last:
- pcmpeqb mm6, mm6
- psllq mm6, (SIZEOF_MMWORD-1)*BYTE_BIT
- pand mm6, MMWORD [esi+0*SIZEOF_MMWORD]
- jmp short .upsample
- alignx 16, 7
-
-.columnloop:
- movq mm6, MMWORD [esi+1*SIZEOF_MMWORD]
- psllq mm6, (SIZEOF_MMWORD-1)*BYTE_BIT
-
-.upsample:
- movq mm1, MMWORD [esi+0*SIZEOF_MMWORD]
- movq mm2, mm1
- movq mm3, mm1 ; mm1=( 0 1 2 3 4 5 6 7)
- psllq mm2, BYTE_BIT ; mm2=( - 0 1 2 3 4 5 6)
- psrlq mm3, BYTE_BIT ; mm3=( 1 2 3 4 5 6 7 -)
-
- por mm2, mm7 ; mm2=(-1 0 1 2 3 4 5 6)
- por mm3, mm6 ; mm3=( 1 2 3 4 5 6 7 8)
-
- movq mm7, mm1
- psrlq mm7, (SIZEOF_MMWORD-1)*BYTE_BIT ; mm7=( 7 - - - - - - -)
-
- movq mm4, mm1
- punpcklbw mm1, mm0 ; mm1=( 0 1 2 3)
- punpckhbw mm4, mm0 ; mm4=( 4 5 6 7)
- movq mm5, mm2
- punpcklbw mm2, mm0 ; mm2=(-1 0 1 2)
- punpckhbw mm5, mm0 ; mm5=( 3 4 5 6)
- movq mm6, mm3
- punpcklbw mm3, mm0 ; mm3=( 1 2 3 4)
- punpckhbw mm6, mm0 ; mm6=( 5 6 7 8)
-
- pmullw mm1, [GOTOFF(ebx,PW_THREE)]
- pmullw mm4, [GOTOFF(ebx,PW_THREE)]
- paddw mm2, [GOTOFF(ebx,PW_ONE)]
- paddw mm5, [GOTOFF(ebx,PW_ONE)]
- paddw mm3, [GOTOFF(ebx,PW_TWO)]
- paddw mm6, [GOTOFF(ebx,PW_TWO)]
-
- paddw mm2, mm1
- paddw mm5, mm4
- psrlw mm2, 2 ; mm2=OutLE=( 0 2 4 6)
- psrlw mm5, 2 ; mm5=OutHE=( 8 10 12 14)
- paddw mm3, mm1
- paddw mm6, mm4
- psrlw mm3, 2 ; mm3=OutLO=( 1 3 5 7)
- psrlw mm6, 2 ; mm6=OutHO=( 9 11 13 15)
-
- psllw mm3, BYTE_BIT
- psllw mm6, BYTE_BIT
- por mm2, mm3 ; mm2=OutL=( 0 1 2 3 4 5 6 7)
- por mm5, mm6 ; mm5=OutH=( 8 9 10 11 12 13 14 15)
-
- movq MMWORD [edi+0*SIZEOF_MMWORD], mm2
- movq MMWORD [edi+1*SIZEOF_MMWORD], mm5
-
- sub eax, byte SIZEOF_MMWORD
- add esi, byte 1*SIZEOF_MMWORD ; inptr
- add edi, byte 2*SIZEOF_MMWORD ; outptr
- cmp eax, byte SIZEOF_MMWORD
- ja near .columnloop
- test eax, eax
- jnz near .columnloop_last
-
- pop esi
- pop edi
- pop eax
-
- add esi, byte SIZEOF_JSAMPROW ; input_data
- add edi, byte SIZEOF_JSAMPROW ; output_data
- dec ecx ; rowctr
- jg near .rowloop
-
- emms ; empty MMX state
-
-.return:
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- poppic ebx
- pop ebp
- ret
-
-; --------------------------------------------------------------------------
-;
-; Fancy processing for the common case of 2:1 horizontal and 2:1 vertical.
-; Again a triangle filter; see comments for h2v1 case, above.
-;
-; GLOBAL(void)
-; jsimd_h2v2_fancy_upsample_mmx(int max_v_samp_factor,
-; JDIMENSION downsampled_width,
-; JSAMPARRAY input_data,
-; JSAMPARRAY *output_data_ptr);
-;
-
-%define max_v_samp(b) (b) + 8 ; int max_v_samp_factor
-%define downsamp_width(b) (b) + 12 ; JDIMENSION downsampled_width
-%define input_data(b) (b) + 16 ; JSAMPARRAY input_data
-%define output_data_ptr(b) (b) + 20 ; JSAMPARRAY *output_data_ptr
-
-%define original_ebp ebp + 0
-%define wk(i) ebp - (WK_NUM - (i)) * SIZEOF_MMWORD ; mmword wk[WK_NUM]
-%define WK_NUM 4
-%define gotptr wk(0) - SIZEOF_POINTER ; void *gotptr
-
- align 32
- GLOBAL_FUNCTION(jsimd_h2v2_fancy_upsample_mmx)
-
-EXTN(jsimd_h2v2_fancy_upsample_mmx):
- push ebp
- mov eax, esp ; eax = original ebp
- sub esp, byte 4
- and esp, byte (-SIZEOF_MMWORD) ; align to 64 bits
- mov [esp], eax
- mov ebp, esp ; ebp = aligned ebp
- lea esp, [wk(0)]
- pushpic eax ; make a room for GOT address
- push ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- get_GOT ebx ; get GOT address
- movpic POINTER [gotptr], ebx ; save GOT address
-
- mov edx, eax ; edx = original ebp
- mov eax, JDIMENSION [downsamp_width(edx)] ; colctr
- test eax, eax
- jz near .return
-
- mov ecx, INT [max_v_samp(edx)] ; rowctr
- test ecx, ecx
- jz near .return
-
- mov esi, JSAMPARRAY [input_data(edx)] ; input_data
- mov edi, POINTER [output_data_ptr(edx)]
- mov edi, JSAMPARRAY [edi] ; output_data
- alignx 16, 7
-.rowloop:
- push eax ; colctr
- push ecx
- push edi
- push esi
-
- mov ecx, JSAMPROW [esi-1*SIZEOF_JSAMPROW] ; inptr1(above)
- mov ebx, JSAMPROW [esi+0*SIZEOF_JSAMPROW] ; inptr0
- mov esi, JSAMPROW [esi+1*SIZEOF_JSAMPROW] ; inptr1(below)
- mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW] ; outptr0
- mov edi, JSAMPROW [edi+1*SIZEOF_JSAMPROW] ; outptr1
-
- test eax, SIZEOF_MMWORD-1
- jz short .skip
- push edx
- mov dl, JSAMPLE [ecx+(eax-1)*SIZEOF_JSAMPLE]
- mov JSAMPLE [ecx+eax*SIZEOF_JSAMPLE], dl
- mov dl, JSAMPLE [ebx+(eax-1)*SIZEOF_JSAMPLE]
- mov JSAMPLE [ebx+eax*SIZEOF_JSAMPLE], dl
- mov dl, JSAMPLE [esi+(eax-1)*SIZEOF_JSAMPLE]
- mov JSAMPLE [esi+eax*SIZEOF_JSAMPLE], dl ; insert a dummy sample
- pop edx
-.skip:
- ; -- process the first column block
-
- movq mm0, MMWORD [ebx+0*SIZEOF_MMWORD] ; mm0=row[ 0][0]
- movq mm1, MMWORD [ecx+0*SIZEOF_MMWORD] ; mm1=row[-1][0]
- movq mm2, MMWORD [esi+0*SIZEOF_MMWORD] ; mm2=row[+1][0]
-
- pushpic ebx
- movpic ebx, POINTER [gotptr] ; load GOT address
-
- pxor mm3, mm3 ; mm3=(all 0's)
- movq mm4, mm0
- punpcklbw mm0, mm3 ; mm0=row[ 0][0]( 0 1 2 3)
- punpckhbw mm4, mm3 ; mm4=row[ 0][0]( 4 5 6 7)
- movq mm5, mm1
- punpcklbw mm1, mm3 ; mm1=row[-1][0]( 0 1 2 3)
- punpckhbw mm5, mm3 ; mm5=row[-1][0]( 4 5 6 7)
- movq mm6, mm2
- punpcklbw mm2, mm3 ; mm2=row[+1][0]( 0 1 2 3)
- punpckhbw mm6, mm3 ; mm6=row[+1][0]( 4 5 6 7)
-
- pmullw mm0, [GOTOFF(ebx,PW_THREE)]
- pmullw mm4, [GOTOFF(ebx,PW_THREE)]
-
- pcmpeqb mm7, mm7
- psrlq mm7, (SIZEOF_MMWORD-2)*BYTE_BIT
-
- paddw mm1, mm0 ; mm1=Int0L=( 0 1 2 3)
- paddw mm5, mm4 ; mm5=Int0H=( 4 5 6 7)
- paddw mm2, mm0 ; mm2=Int1L=( 0 1 2 3)
- paddw mm6, mm4 ; mm6=Int1H=( 4 5 6 7)
-
- movq MMWORD [edx+0*SIZEOF_MMWORD], mm1 ; temporarily save
- movq MMWORD [edx+1*SIZEOF_MMWORD], mm5 ; the intermediate data
- movq MMWORD [edi+0*SIZEOF_MMWORD], mm2
- movq MMWORD [edi+1*SIZEOF_MMWORD], mm6
-
- pand mm1, mm7 ; mm1=( 0 - - -)
- pand mm2, mm7 ; mm2=( 0 - - -)
-
- movq MMWORD [wk(0)], mm1
- movq MMWORD [wk(1)], mm2
-
- poppic ebx
-
- add eax, byte SIZEOF_MMWORD-1
- and eax, byte -SIZEOF_MMWORD
- cmp eax, byte SIZEOF_MMWORD
- ja short .columnloop
- alignx 16, 7
-
-.columnloop_last:
- ; -- process the last column block
-
- pushpic ebx
- movpic ebx, POINTER [gotptr] ; load GOT address
-
- pcmpeqb mm1, mm1
- psllq mm1, (SIZEOF_MMWORD-2)*BYTE_BIT
- movq mm2, mm1
-
- pand mm1, MMWORD [edx+1*SIZEOF_MMWORD] ; mm1=( - - - 7)
- pand mm2, MMWORD [edi+1*SIZEOF_MMWORD] ; mm2=( - - - 7)
-
- movq MMWORD [wk(2)], mm1
- movq MMWORD [wk(3)], mm2
-
- jmp short .upsample
- alignx 16, 7
-
-.columnloop:
- ; -- process the next column block
-
- movq mm0, MMWORD [ebx+1*SIZEOF_MMWORD] ; mm0=row[ 0][1]
- movq mm1, MMWORD [ecx+1*SIZEOF_MMWORD] ; mm1=row[-1][1]
- movq mm2, MMWORD [esi+1*SIZEOF_MMWORD] ; mm2=row[+1][1]
-
- pushpic ebx
- movpic ebx, POINTER [gotptr] ; load GOT address
-
- pxor mm3, mm3 ; mm3=(all 0's)
- movq mm4, mm0
- punpcklbw mm0, mm3 ; mm0=row[ 0][1]( 0 1 2 3)
- punpckhbw mm4, mm3 ; mm4=row[ 0][1]( 4 5 6 7)
- movq mm5, mm1
- punpcklbw mm1, mm3 ; mm1=row[-1][1]( 0 1 2 3)
- punpckhbw mm5, mm3 ; mm5=row[-1][1]( 4 5 6 7)
- movq mm6, mm2
- punpcklbw mm2, mm3 ; mm2=row[+1][1]( 0 1 2 3)
- punpckhbw mm6, mm3 ; mm6=row[+1][1]( 4 5 6 7)
-
- pmullw mm0, [GOTOFF(ebx,PW_THREE)]
- pmullw mm4, [GOTOFF(ebx,PW_THREE)]
-
- paddw mm1, mm0 ; mm1=Int0L=( 0 1 2 3)
- paddw mm5, mm4 ; mm5=Int0H=( 4 5 6 7)
- paddw mm2, mm0 ; mm2=Int1L=( 0 1 2 3)
- paddw mm6, mm4 ; mm6=Int1H=( 4 5 6 7)
-
- movq MMWORD [edx+2*SIZEOF_MMWORD], mm1 ; temporarily save
- movq MMWORD [edx+3*SIZEOF_MMWORD], mm5 ; the intermediate data
- movq MMWORD [edi+2*SIZEOF_MMWORD], mm2
- movq MMWORD [edi+3*SIZEOF_MMWORD], mm6
-
- psllq mm1, (SIZEOF_MMWORD-2)*BYTE_BIT ; mm1=( - - - 0)
- psllq mm2, (SIZEOF_MMWORD-2)*BYTE_BIT ; mm2=( - - - 0)
-
- movq MMWORD [wk(2)], mm1
- movq MMWORD [wk(3)], mm2
-
-.upsample:
- ; -- process the upper row
-
- movq mm7, MMWORD [edx+0*SIZEOF_MMWORD] ; mm7=Int0L=( 0 1 2 3)
- movq mm3, MMWORD [edx+1*SIZEOF_MMWORD] ; mm3=Int0H=( 4 5 6 7)
-
- movq mm0, mm7
- movq mm4, mm3
- psrlq mm0, 2*BYTE_BIT ; mm0=( 1 2 3 -)
- psllq mm4, (SIZEOF_MMWORD-2)*BYTE_BIT ; mm4=( - - - 4)
- movq mm5, mm7
- movq mm6, mm3
- psrlq mm5, (SIZEOF_MMWORD-2)*BYTE_BIT ; mm5=( 3 - - -)
- psllq mm6, 2*BYTE_BIT ; mm6=( - 4 5 6)
-
- por mm0, mm4 ; mm0=( 1 2 3 4)
- por mm5, mm6 ; mm5=( 3 4 5 6)
-
- movq mm1, mm7
- movq mm2, mm3
- psllq mm1, 2*BYTE_BIT ; mm1=( - 0 1 2)
- psrlq mm2, 2*BYTE_BIT ; mm2=( 5 6 7 -)
- movq mm4, mm3
- psrlq mm4, (SIZEOF_MMWORD-2)*BYTE_BIT ; mm4=( 7 - - -)
-
- por mm1, MMWORD [wk(0)] ; mm1=(-1 0 1 2)
- por mm2, MMWORD [wk(2)] ; mm2=( 5 6 7 8)
-
- movq MMWORD [wk(0)], mm4
-
- pmullw mm7, [GOTOFF(ebx,PW_THREE)]
- pmullw mm3, [GOTOFF(ebx,PW_THREE)]
- paddw mm1, [GOTOFF(ebx,PW_EIGHT)]
- paddw mm5, [GOTOFF(ebx,PW_EIGHT)]
- paddw mm0, [GOTOFF(ebx,PW_SEVEN)]
- paddw mm2, [GOTOFF(ebx,PW_SEVEN)]
-
- paddw mm1, mm7
- paddw mm5, mm3
- psrlw mm1, 4 ; mm1=Out0LE=( 0 2 4 6)
- psrlw mm5, 4 ; mm5=Out0HE=( 8 10 12 14)
- paddw mm0, mm7
- paddw mm2, mm3
- psrlw mm0, 4 ; mm0=Out0LO=( 1 3 5 7)
- psrlw mm2, 4 ; mm2=Out0HO=( 9 11 13 15)
-
- psllw mm0, BYTE_BIT
- psllw mm2, BYTE_BIT
- por mm1, mm0 ; mm1=Out0L=( 0 1 2 3 4 5 6 7)
- por mm5, mm2 ; mm5=Out0H=( 8 9 10 11 12 13 14 15)
-
- movq MMWORD [edx+0*SIZEOF_MMWORD], mm1
- movq MMWORD [edx+1*SIZEOF_MMWORD], mm5
-
- ; -- process the lower row
-
- movq mm6, MMWORD [edi+0*SIZEOF_MMWORD] ; mm6=Int1L=( 0 1 2 3)
- movq mm4, MMWORD [edi+1*SIZEOF_MMWORD] ; mm4=Int1H=( 4 5 6 7)
-
- movq mm7, mm6
- movq mm3, mm4
- psrlq mm7, 2*BYTE_BIT ; mm7=( 1 2 3 -)
- psllq mm3, (SIZEOF_MMWORD-2)*BYTE_BIT ; mm3=( - - - 4)
- movq mm0, mm6
- movq mm2, mm4
- psrlq mm0, (SIZEOF_MMWORD-2)*BYTE_BIT ; mm0=( 3 - - -)
- psllq mm2, 2*BYTE_BIT ; mm2=( - 4 5 6)
-
- por mm7, mm3 ; mm7=( 1 2 3 4)
- por mm0, mm2 ; mm0=( 3 4 5 6)
-
- movq mm1, mm6
- movq mm5, mm4
- psllq mm1, 2*BYTE_BIT ; mm1=( - 0 1 2)
- psrlq mm5, 2*BYTE_BIT ; mm5=( 5 6 7 -)
- movq mm3, mm4
- psrlq mm3, (SIZEOF_MMWORD-2)*BYTE_BIT ; mm3=( 7 - - -)
-
- por mm1, MMWORD [wk(1)] ; mm1=(-1 0 1 2)
- por mm5, MMWORD [wk(3)] ; mm5=( 5 6 7 8)
-
- movq MMWORD [wk(1)], mm3
-
- pmullw mm6, [GOTOFF(ebx,PW_THREE)]
- pmullw mm4, [GOTOFF(ebx,PW_THREE)]
- paddw mm1, [GOTOFF(ebx,PW_EIGHT)]
- paddw mm0, [GOTOFF(ebx,PW_EIGHT)]
- paddw mm7, [GOTOFF(ebx,PW_SEVEN)]
- paddw mm5, [GOTOFF(ebx,PW_SEVEN)]
-
- paddw mm1, mm6
- paddw mm0, mm4
- psrlw mm1, 4 ; mm1=Out1LE=( 0 2 4 6)
- psrlw mm0, 4 ; mm0=Out1HE=( 8 10 12 14)
- paddw mm7, mm6
- paddw mm5, mm4
- psrlw mm7, 4 ; mm7=Out1LO=( 1 3 5 7)
- psrlw mm5, 4 ; mm5=Out1HO=( 9 11 13 15)
-
- psllw mm7, BYTE_BIT
- psllw mm5, BYTE_BIT
- por mm1, mm7 ; mm1=Out1L=( 0 1 2 3 4 5 6 7)
- por mm0, mm5 ; mm0=Out1H=( 8 9 10 11 12 13 14 15)
-
- movq MMWORD [edi+0*SIZEOF_MMWORD], mm1
- movq MMWORD [edi+1*SIZEOF_MMWORD], mm0
-
- poppic ebx
-
- sub eax, byte SIZEOF_MMWORD
- add ecx, byte 1*SIZEOF_MMWORD ; inptr1(above)
- add ebx, byte 1*SIZEOF_MMWORD ; inptr0
- add esi, byte 1*SIZEOF_MMWORD ; inptr1(below)
- add edx, byte 2*SIZEOF_MMWORD ; outptr0
- add edi, byte 2*SIZEOF_MMWORD ; outptr1
- cmp eax, byte SIZEOF_MMWORD
- ja near .columnloop
- test eax, eax
- jnz near .columnloop_last
-
- pop esi
- pop edi
- pop ecx
- pop eax
-
- add esi, byte 1*SIZEOF_JSAMPROW ; input_data
- add edi, byte 2*SIZEOF_JSAMPROW ; output_data
- sub ecx, byte 2 ; rowctr
- jg near .rowloop
-
- emms ; empty MMX state
-
-.return:
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- pop ebx
- mov esp, ebp ; esp <- aligned ebp
- pop esp ; esp <- original ebp
- pop ebp
- ret
-
-; --------------------------------------------------------------------------
-;
-; Fast processing for the common case of 2:1 horizontal and 1:1 vertical.
-; It's still a box filter.
-;
-; GLOBAL(void)
-; jsimd_h2v1_upsample_mmx(int max_v_samp_factor, JDIMENSION output_width,
-; JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr);
-;
-
-%define max_v_samp(b) (b) + 8 ; int max_v_samp_factor
-%define output_width(b) (b) + 12 ; JDIMENSION output_width
-%define input_data(b) (b) + 16 ; JSAMPARRAY input_data
-%define output_data_ptr(b) (b) + 20 ; JSAMPARRAY *output_data_ptr
-
- align 32
- GLOBAL_FUNCTION(jsimd_h2v1_upsample_mmx)
-
-EXTN(jsimd_h2v1_upsample_mmx):
- push ebp
- mov ebp, esp
-; push ebx ; unused
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- mov edx, JDIMENSION [output_width(ebp)]
- add edx, byte (2*SIZEOF_MMWORD)-1
- and edx, byte -(2*SIZEOF_MMWORD)
- jz short .return
-
- mov ecx, INT [max_v_samp(ebp)] ; rowctr
- test ecx, ecx
- jz short .return
-
- mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
- mov edi, POINTER [output_data_ptr(ebp)]
- mov edi, JSAMPARRAY [edi] ; output_data
- alignx 16, 7
-.rowloop:
- push edi
- push esi
-
- mov esi, JSAMPROW [esi] ; inptr
- mov edi, JSAMPROW [edi] ; outptr
- mov eax, edx ; colctr
- alignx 16, 7
-.columnloop:
-
- movq mm0, MMWORD [esi+0*SIZEOF_MMWORD]
-
- movq mm1, mm0
- punpcklbw mm0, mm0
- punpckhbw mm1, mm1
-
- movq MMWORD [edi+0*SIZEOF_MMWORD], mm0
- movq MMWORD [edi+1*SIZEOF_MMWORD], mm1
-
- sub eax, byte 2*SIZEOF_MMWORD
- jz short .nextrow
-
- movq mm2, MMWORD [esi+1*SIZEOF_MMWORD]
-
- movq mm3, mm2
- punpcklbw mm2, mm2
- punpckhbw mm3, mm3
-
- movq MMWORD [edi+2*SIZEOF_MMWORD], mm2
- movq MMWORD [edi+3*SIZEOF_MMWORD], mm3
-
- sub eax, byte 2*SIZEOF_MMWORD
- jz short .nextrow
-
- add esi, byte 2*SIZEOF_MMWORD ; inptr
- add edi, byte 4*SIZEOF_MMWORD ; outptr
- jmp short .columnloop
- alignx 16, 7
-
-.nextrow:
- pop esi
- pop edi
-
- add esi, byte SIZEOF_JSAMPROW ; input_data
- add edi, byte SIZEOF_JSAMPROW ; output_data
- dec ecx ; rowctr
- jg short .rowloop
-
- emms ; empty MMX state
-
-.return:
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
-; pop ebx ; unused
- pop ebp
- ret
-
-; --------------------------------------------------------------------------
-;
-; Fast processing for the common case of 2:1 horizontal and 2:1 vertical.
-; It's still a box filter.
-;
-; GLOBAL(void)
-; jsimd_h2v2_upsample_mmx(int max_v_samp_factor, JDIMENSION output_width,
-; JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr);
-;
-
-%define max_v_samp(b) (b) + 8 ; int max_v_samp_factor
-%define output_width(b) (b) + 12 ; JDIMENSION output_width
-%define input_data(b) (b) + 16 ; JSAMPARRAY input_data
-%define output_data_ptr(b) (b) + 20 ; JSAMPARRAY *output_data_ptr
-
- align 32
- GLOBAL_FUNCTION(jsimd_h2v2_upsample_mmx)
-
-EXTN(jsimd_h2v2_upsample_mmx):
- push ebp
- mov ebp, esp
- push ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- mov edx, JDIMENSION [output_width(ebp)]
- add edx, byte (2*SIZEOF_MMWORD)-1
- and edx, byte -(2*SIZEOF_MMWORD)
- jz near .return
-
- mov ecx, INT [max_v_samp(ebp)] ; rowctr
- test ecx, ecx
- jz short .return
-
- mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
- mov edi, POINTER [output_data_ptr(ebp)]
- mov edi, JSAMPARRAY [edi] ; output_data
- alignx 16, 7
-.rowloop:
- push edi
- push esi
-
- mov esi, JSAMPROW [esi] ; inptr
- mov ebx, JSAMPROW [edi+0*SIZEOF_JSAMPROW] ; outptr0
- mov edi, JSAMPROW [edi+1*SIZEOF_JSAMPROW] ; outptr1
- mov eax, edx ; colctr
- alignx 16, 7
-.columnloop:
-
- movq mm0, MMWORD [esi+0*SIZEOF_MMWORD]
-
- movq mm1, mm0
- punpcklbw mm0, mm0
- punpckhbw mm1, mm1
-
- movq MMWORD [ebx+0*SIZEOF_MMWORD], mm0
- movq MMWORD [ebx+1*SIZEOF_MMWORD], mm1
- movq MMWORD [edi+0*SIZEOF_MMWORD], mm0
- movq MMWORD [edi+1*SIZEOF_MMWORD], mm1
-
- sub eax, byte 2*SIZEOF_MMWORD
- jz short .nextrow
-
- movq mm2, MMWORD [esi+1*SIZEOF_MMWORD]
-
- movq mm3, mm2
- punpcklbw mm2, mm2
- punpckhbw mm3, mm3
-
- movq MMWORD [ebx+2*SIZEOF_MMWORD], mm2
- movq MMWORD [ebx+3*SIZEOF_MMWORD], mm3
- movq MMWORD [edi+2*SIZEOF_MMWORD], mm2
- movq MMWORD [edi+3*SIZEOF_MMWORD], mm3
-
- sub eax, byte 2*SIZEOF_MMWORD
- jz short .nextrow
-
- add esi, byte 2*SIZEOF_MMWORD ; inptr
- add ebx, byte 4*SIZEOF_MMWORD ; outptr0
- add edi, byte 4*SIZEOF_MMWORD ; outptr1
- jmp short .columnloop
- alignx 16, 7
-
-.nextrow:
- pop esi
- pop edi
-
- add esi, byte 1*SIZEOF_JSAMPROW ; input_data
- add edi, byte 2*SIZEOF_JSAMPROW ; output_data
- sub ecx, byte 2 ; rowctr
- jg short .rowloop
-
- emms ; empty MMX state
-
-.return:
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- pop ebx
- pop ebp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jdsample-sse2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jdsample-sse2.asm
deleted file mode 100644
index 4e28d2f4b8..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jdsample-sse2.asm
+++ /dev/null
@@ -1,724 +0,0 @@
-;
-; jdsample.asm - upsampling (SSE2)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jsimdext.inc"
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_fancy_upsample_sse2)
-
-EXTN(jconst_fancy_upsample_sse2):
-
-PW_ONE times 8 dw 1
-PW_TWO times 8 dw 2
-PW_THREE times 8 dw 3
-PW_SEVEN times 8 dw 7
-PW_EIGHT times 8 dw 8
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-;
-; Fancy processing for the common case of 2:1 horizontal and 1:1 vertical.
-;
-; The upsampling algorithm is linear interpolation between pixel centers,
-; also known as a "triangle filter". This is a good compromise between
-; speed and visual quality. The centers of the output pixels are 1/4 and 3/4
-; of the way between input pixel centers.
-;
-; GLOBAL(void)
-; jsimd_h2v1_fancy_upsample_sse2(int max_v_samp_factor,
-; JDIMENSION downsampled_width,
-; JSAMPARRAY input_data,
-; JSAMPARRAY *output_data_ptr);
-;
-
-%define max_v_samp(b) (b) + 8 ; int max_v_samp_factor
-%define downsamp_width(b) (b) + 12 ; JDIMENSION downsampled_width
-%define input_data(b) (b) + 16 ; JSAMPARRAY input_data
-%define output_data_ptr(b) (b) + 20 ; JSAMPARRAY *output_data_ptr
-
- align 32
- GLOBAL_FUNCTION(jsimd_h2v1_fancy_upsample_sse2)
-
-EXTN(jsimd_h2v1_fancy_upsample_sse2):
- push ebp
- mov ebp, esp
- pushpic ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- get_GOT ebx ; get GOT address
-
- mov eax, JDIMENSION [downsamp_width(ebp)] ; colctr
- test eax, eax
- jz near .return
-
- mov ecx, INT [max_v_samp(ebp)] ; rowctr
- test ecx, ecx
- jz near .return
-
- mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
- mov edi, POINTER [output_data_ptr(ebp)]
- mov edi, JSAMPARRAY [edi] ; output_data
- alignx 16, 7
-.rowloop:
- push eax ; colctr
- push edi
- push esi
-
- mov esi, JSAMPROW [esi] ; inptr
- mov edi, JSAMPROW [edi] ; outptr
-
- test eax, SIZEOF_XMMWORD-1
- jz short .skip
- mov dl, JSAMPLE [esi+(eax-1)*SIZEOF_JSAMPLE]
- mov JSAMPLE [esi+eax*SIZEOF_JSAMPLE], dl ; insert a dummy sample
-.skip:
- pxor xmm0, xmm0 ; xmm0=(all 0's)
- pcmpeqb xmm7, xmm7
- psrldq xmm7, (SIZEOF_XMMWORD-1)
- pand xmm7, XMMWORD [esi+0*SIZEOF_XMMWORD]
-
- add eax, byte SIZEOF_XMMWORD-1
- and eax, byte -SIZEOF_XMMWORD
- cmp eax, byte SIZEOF_XMMWORD
- ja short .columnloop
- alignx 16, 7
-
-.columnloop_last:
- pcmpeqb xmm6, xmm6
- pslldq xmm6, (SIZEOF_XMMWORD-1)
- pand xmm6, XMMWORD [esi+0*SIZEOF_XMMWORD]
- jmp short .upsample
- alignx 16, 7
-
-.columnloop:
- movdqa xmm6, XMMWORD [esi+1*SIZEOF_XMMWORD]
- pslldq xmm6, (SIZEOF_XMMWORD-1)
-
-.upsample:
- movdqa xmm1, XMMWORD [esi+0*SIZEOF_XMMWORD]
- movdqa xmm2, xmm1
- movdqa xmm3, xmm1 ; xmm1=( 0 1 2 ... 13 14 15)
- pslldq xmm2, 1 ; xmm2=(-- 0 1 ... 12 13 14)
- psrldq xmm3, 1 ; xmm3=( 1 2 3 ... 14 15 --)
-
- por xmm2, xmm7 ; xmm2=(-1 0 1 ... 12 13 14)
- por xmm3, xmm6 ; xmm3=( 1 2 3 ... 14 15 16)
-
- movdqa xmm7, xmm1
- psrldq xmm7, (SIZEOF_XMMWORD-1) ; xmm7=(15 -- -- ... -- -- --)
-
- movdqa xmm4, xmm1
- punpcklbw xmm1, xmm0 ; xmm1=( 0 1 2 3 4 5 6 7)
- punpckhbw xmm4, xmm0 ; xmm4=( 8 9 10 11 12 13 14 15)
- movdqa xmm5, xmm2
- punpcklbw xmm2, xmm0 ; xmm2=(-1 0 1 2 3 4 5 6)
- punpckhbw xmm5, xmm0 ; xmm5=( 7 8 9 10 11 12 13 14)
- movdqa xmm6, xmm3
- punpcklbw xmm3, xmm0 ; xmm3=( 1 2 3 4 5 6 7 8)
- punpckhbw xmm6, xmm0 ; xmm6=( 9 10 11 12 13 14 15 16)
-
- pmullw xmm1, [GOTOFF(ebx,PW_THREE)]
- pmullw xmm4, [GOTOFF(ebx,PW_THREE)]
- paddw xmm2, [GOTOFF(ebx,PW_ONE)]
- paddw xmm5, [GOTOFF(ebx,PW_ONE)]
- paddw xmm3, [GOTOFF(ebx,PW_TWO)]
- paddw xmm6, [GOTOFF(ebx,PW_TWO)]
-
- paddw xmm2, xmm1
- paddw xmm5, xmm4
- psrlw xmm2, 2 ; xmm2=OutLE=( 0 2 4 6 8 10 12 14)
- psrlw xmm5, 2 ; xmm5=OutHE=(16 18 20 22 24 26 28 30)
- paddw xmm3, xmm1
- paddw xmm6, xmm4
- psrlw xmm3, 2 ; xmm3=OutLO=( 1 3 5 7 9 11 13 15)
- psrlw xmm6, 2 ; xmm6=OutHO=(17 19 21 23 25 27 29 31)
-
- psllw xmm3, BYTE_BIT
- psllw xmm6, BYTE_BIT
- por xmm2, xmm3 ; xmm2=OutL=( 0 1 2 ... 13 14 15)
- por xmm5, xmm6 ; xmm5=OutH=(16 17 18 ... 29 30 31)
-
- movdqa XMMWORD [edi+0*SIZEOF_XMMWORD], xmm2
- movdqa XMMWORD [edi+1*SIZEOF_XMMWORD], xmm5
-
- sub eax, byte SIZEOF_XMMWORD
- add esi, byte 1*SIZEOF_XMMWORD ; inptr
- add edi, byte 2*SIZEOF_XMMWORD ; outptr
- cmp eax, byte SIZEOF_XMMWORD
- ja near .columnloop
- test eax, eax
- jnz near .columnloop_last
-
- pop esi
- pop edi
- pop eax
-
- add esi, byte SIZEOF_JSAMPROW ; input_data
- add edi, byte SIZEOF_JSAMPROW ; output_data
- dec ecx ; rowctr
- jg near .rowloop
-
-.return:
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- poppic ebx
- pop ebp
- ret
-
-; --------------------------------------------------------------------------
-;
-; Fancy processing for the common case of 2:1 horizontal and 2:1 vertical.
-; Again a triangle filter; see comments for h2v1 case, above.
-;
-; GLOBAL(void)
-; jsimd_h2v2_fancy_upsample_sse2(int max_v_samp_factor,
-; JDIMENSION downsampled_width,
-; JSAMPARRAY input_data,
-; JSAMPARRAY *output_data_ptr);
-;
-
-%define max_v_samp(b) (b) + 8 ; int max_v_samp_factor
-%define downsamp_width(b) (b) + 12 ; JDIMENSION downsampled_width
-%define input_data(b) (b) + 16 ; JSAMPARRAY input_data
-%define output_data_ptr(b) (b) + 20 ; JSAMPARRAY *output_data_ptr
-
-%define original_ebp ebp + 0
-%define wk(i) ebp - (WK_NUM - (i)) * SIZEOF_XMMWORD
- ; xmmword wk[WK_NUM]
-%define WK_NUM 4
-%define gotptr wk(0) - SIZEOF_POINTER ; void *gotptr
-
- align 32
- GLOBAL_FUNCTION(jsimd_h2v2_fancy_upsample_sse2)
-
-EXTN(jsimd_h2v2_fancy_upsample_sse2):
- push ebp
- mov eax, esp ; eax = original ebp
- sub esp, byte 4
- and esp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [esp], eax
- mov ebp, esp ; ebp = aligned ebp
- lea esp, [wk(0)]
- pushpic eax ; make a room for GOT address
- push ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- get_GOT ebx ; get GOT address
- movpic POINTER [gotptr], ebx ; save GOT address
-
- mov edx, eax ; edx = original ebp
- mov eax, JDIMENSION [downsamp_width(edx)] ; colctr
- test eax, eax
- jz near .return
-
- mov ecx, INT [max_v_samp(edx)] ; rowctr
- test ecx, ecx
- jz near .return
-
- mov esi, JSAMPARRAY [input_data(edx)] ; input_data
- mov edi, POINTER [output_data_ptr(edx)]
- mov edi, JSAMPARRAY [edi] ; output_data
- alignx 16, 7
-.rowloop:
- push eax ; colctr
- push ecx
- push edi
- push esi
-
- mov ecx, JSAMPROW [esi-1*SIZEOF_JSAMPROW] ; inptr1(above)
- mov ebx, JSAMPROW [esi+0*SIZEOF_JSAMPROW] ; inptr0
- mov esi, JSAMPROW [esi+1*SIZEOF_JSAMPROW] ; inptr1(below)
- mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW] ; outptr0
- mov edi, JSAMPROW [edi+1*SIZEOF_JSAMPROW] ; outptr1
-
- test eax, SIZEOF_XMMWORD-1
- jz short .skip
- push edx
- mov dl, JSAMPLE [ecx+(eax-1)*SIZEOF_JSAMPLE]
- mov JSAMPLE [ecx+eax*SIZEOF_JSAMPLE], dl
- mov dl, JSAMPLE [ebx+(eax-1)*SIZEOF_JSAMPLE]
- mov JSAMPLE [ebx+eax*SIZEOF_JSAMPLE], dl
- mov dl, JSAMPLE [esi+(eax-1)*SIZEOF_JSAMPLE]
- mov JSAMPLE [esi+eax*SIZEOF_JSAMPLE], dl ; insert a dummy sample
- pop edx
-.skip:
- ; -- process the first column block
-
- movdqa xmm0, XMMWORD [ebx+0*SIZEOF_XMMWORD] ; xmm0=row[ 0][0]
- movdqa xmm1, XMMWORD [ecx+0*SIZEOF_XMMWORD] ; xmm1=row[-1][0]
- movdqa xmm2, XMMWORD [esi+0*SIZEOF_XMMWORD] ; xmm2=row[+1][0]
-
- pushpic ebx
- movpic ebx, POINTER [gotptr] ; load GOT address
-
- pxor xmm3, xmm3 ; xmm3=(all 0's)
- movdqa xmm4, xmm0
- punpcklbw xmm0, xmm3 ; xmm0=row[ 0]( 0 1 2 3 4 5 6 7)
- punpckhbw xmm4, xmm3 ; xmm4=row[ 0]( 8 9 10 11 12 13 14 15)
- movdqa xmm5, xmm1
- punpcklbw xmm1, xmm3 ; xmm1=row[-1]( 0 1 2 3 4 5 6 7)
- punpckhbw xmm5, xmm3 ; xmm5=row[-1]( 8 9 10 11 12 13 14 15)
- movdqa xmm6, xmm2
- punpcklbw xmm2, xmm3 ; xmm2=row[+1]( 0 1 2 3 4 5 6 7)
- punpckhbw xmm6, xmm3 ; xmm6=row[+1]( 8 9 10 11 12 13 14 15)
-
- pmullw xmm0, [GOTOFF(ebx,PW_THREE)]
- pmullw xmm4, [GOTOFF(ebx,PW_THREE)]
-
- pcmpeqb xmm7, xmm7
- psrldq xmm7, (SIZEOF_XMMWORD-2)
-
- paddw xmm1, xmm0 ; xmm1=Int0L=( 0 1 2 3 4 5 6 7)
- paddw xmm5, xmm4 ; xmm5=Int0H=( 8 9 10 11 12 13 14 15)
- paddw xmm2, xmm0 ; xmm2=Int1L=( 0 1 2 3 4 5 6 7)
- paddw xmm6, xmm4 ; xmm6=Int1H=( 8 9 10 11 12 13 14 15)
-
- movdqa XMMWORD [edx+0*SIZEOF_XMMWORD], xmm1 ; temporarily save
- movdqa XMMWORD [edx+1*SIZEOF_XMMWORD], xmm5 ; the intermediate data
- movdqa XMMWORD [edi+0*SIZEOF_XMMWORD], xmm2
- movdqa XMMWORD [edi+1*SIZEOF_XMMWORD], xmm6
-
- pand xmm1, xmm7 ; xmm1=( 0 -- -- -- -- -- -- --)
- pand xmm2, xmm7 ; xmm2=( 0 -- -- -- -- -- -- --)
-
- movdqa XMMWORD [wk(0)], xmm1
- movdqa XMMWORD [wk(1)], xmm2
-
- poppic ebx
-
- add eax, byte SIZEOF_XMMWORD-1
- and eax, byte -SIZEOF_XMMWORD
- cmp eax, byte SIZEOF_XMMWORD
- ja short .columnloop
- alignx 16, 7
-
-.columnloop_last:
- ; -- process the last column block
-
- pushpic ebx
- movpic ebx, POINTER [gotptr] ; load GOT address
-
- pcmpeqb xmm1, xmm1
- pslldq xmm1, (SIZEOF_XMMWORD-2)
- movdqa xmm2, xmm1
-
- pand xmm1, XMMWORD [edx+1*SIZEOF_XMMWORD]
- pand xmm2, XMMWORD [edi+1*SIZEOF_XMMWORD]
-
- movdqa XMMWORD [wk(2)], xmm1 ; xmm1=(-- -- -- -- -- -- -- 15)
- movdqa XMMWORD [wk(3)], xmm2 ; xmm2=(-- -- -- -- -- -- -- 15)
-
- jmp near .upsample
- alignx 16, 7
-
-.columnloop:
- ; -- process the next column block
-
- movdqa xmm0, XMMWORD [ebx+1*SIZEOF_XMMWORD] ; xmm0=row[ 0][1]
- movdqa xmm1, XMMWORD [ecx+1*SIZEOF_XMMWORD] ; xmm1=row[-1][1]
- movdqa xmm2, XMMWORD [esi+1*SIZEOF_XMMWORD] ; xmm2=row[+1][1]
-
- pushpic ebx
- movpic ebx, POINTER [gotptr] ; load GOT address
-
- pxor xmm3, xmm3 ; xmm3=(all 0's)
- movdqa xmm4, xmm0
- punpcklbw xmm0, xmm3 ; xmm0=row[ 0]( 0 1 2 3 4 5 6 7)
- punpckhbw xmm4, xmm3 ; xmm4=row[ 0]( 8 9 10 11 12 13 14 15)
- movdqa xmm5, xmm1
- punpcklbw xmm1, xmm3 ; xmm1=row[-1]( 0 1 2 3 4 5 6 7)
- punpckhbw xmm5, xmm3 ; xmm5=row[-1]( 8 9 10 11 12 13 14 15)
- movdqa xmm6, xmm2
- punpcklbw xmm2, xmm3 ; xmm2=row[+1]( 0 1 2 3 4 5 6 7)
- punpckhbw xmm6, xmm3 ; xmm6=row[+1]( 8 9 10 11 12 13 14 15)
-
- pmullw xmm0, [GOTOFF(ebx,PW_THREE)]
- pmullw xmm4, [GOTOFF(ebx,PW_THREE)]
-
- paddw xmm1, xmm0 ; xmm1=Int0L=( 0 1 2 3 4 5 6 7)
- paddw xmm5, xmm4 ; xmm5=Int0H=( 8 9 10 11 12 13 14 15)
- paddw xmm2, xmm0 ; xmm2=Int1L=( 0 1 2 3 4 5 6 7)
- paddw xmm6, xmm4 ; xmm6=Int1H=( 8 9 10 11 12 13 14 15)
-
- movdqa XMMWORD [edx+2*SIZEOF_XMMWORD], xmm1 ; temporarily save
- movdqa XMMWORD [edx+3*SIZEOF_XMMWORD], xmm5 ; the intermediate data
- movdqa XMMWORD [edi+2*SIZEOF_XMMWORD], xmm2
- movdqa XMMWORD [edi+3*SIZEOF_XMMWORD], xmm6
-
- pslldq xmm1, (SIZEOF_XMMWORD-2) ; xmm1=(-- -- -- -- -- -- -- 0)
- pslldq xmm2, (SIZEOF_XMMWORD-2) ; xmm2=(-- -- -- -- -- -- -- 0)
-
- movdqa XMMWORD [wk(2)], xmm1
- movdqa XMMWORD [wk(3)], xmm2
-
-.upsample:
- ; -- process the upper row
-
- movdqa xmm7, XMMWORD [edx+0*SIZEOF_XMMWORD]
- movdqa xmm3, XMMWORD [edx+1*SIZEOF_XMMWORD]
-
- movdqa xmm0, xmm7 ; xmm7=Int0L=( 0 1 2 3 4 5 6 7)
- movdqa xmm4, xmm3 ; xmm3=Int0H=( 8 9 10 11 12 13 14 15)
- psrldq xmm0, 2 ; xmm0=( 1 2 3 4 5 6 7 --)
- pslldq xmm4, (SIZEOF_XMMWORD-2) ; xmm4=(-- -- -- -- -- -- -- 8)
- movdqa xmm5, xmm7
- movdqa xmm6, xmm3
- psrldq xmm5, (SIZEOF_XMMWORD-2) ; xmm5=( 7 -- -- -- -- -- -- --)
- pslldq xmm6, 2 ; xmm6=(-- 8 9 10 11 12 13 14)
-
- por xmm0, xmm4 ; xmm0=( 1 2 3 4 5 6 7 8)
- por xmm5, xmm6 ; xmm5=( 7 8 9 10 11 12 13 14)
-
- movdqa xmm1, xmm7
- movdqa xmm2, xmm3
- pslldq xmm1, 2 ; xmm1=(-- 0 1 2 3 4 5 6)
- psrldq xmm2, 2 ; xmm2=( 9 10 11 12 13 14 15 --)
- movdqa xmm4, xmm3
- psrldq xmm4, (SIZEOF_XMMWORD-2) ; xmm4=(15 -- -- -- -- -- -- --)
-
- por xmm1, XMMWORD [wk(0)] ; xmm1=(-1 0 1 2 3 4 5 6)
- por xmm2, XMMWORD [wk(2)] ; xmm2=( 9 10 11 12 13 14 15 16)
-
- movdqa XMMWORD [wk(0)], xmm4
-
- pmullw xmm7, [GOTOFF(ebx,PW_THREE)]
- pmullw xmm3, [GOTOFF(ebx,PW_THREE)]
- paddw xmm1, [GOTOFF(ebx,PW_EIGHT)]
- paddw xmm5, [GOTOFF(ebx,PW_EIGHT)]
- paddw xmm0, [GOTOFF(ebx,PW_SEVEN)]
- paddw xmm2, [GOTOFF(ebx,PW_SEVEN)]
-
- paddw xmm1, xmm7
- paddw xmm5, xmm3
- psrlw xmm1, 4 ; xmm1=Out0LE=( 0 2 4 6 8 10 12 14)
- psrlw xmm5, 4 ; xmm5=Out0HE=(16 18 20 22 24 26 28 30)
- paddw xmm0, xmm7
- paddw xmm2, xmm3
- psrlw xmm0, 4 ; xmm0=Out0LO=( 1 3 5 7 9 11 13 15)
- psrlw xmm2, 4 ; xmm2=Out0HO=(17 19 21 23 25 27 29 31)
-
- psllw xmm0, BYTE_BIT
- psllw xmm2, BYTE_BIT
- por xmm1, xmm0 ; xmm1=Out0L=( 0 1 2 ... 13 14 15)
- por xmm5, xmm2 ; xmm5=Out0H=(16 17 18 ... 29 30 31)
-
- movdqa XMMWORD [edx+0*SIZEOF_XMMWORD], xmm1
- movdqa XMMWORD [edx+1*SIZEOF_XMMWORD], xmm5
-
- ; -- process the lower row
-
- movdqa xmm6, XMMWORD [edi+0*SIZEOF_XMMWORD]
- movdqa xmm4, XMMWORD [edi+1*SIZEOF_XMMWORD]
-
- movdqa xmm7, xmm6 ; xmm6=Int1L=( 0 1 2 3 4 5 6 7)
- movdqa xmm3, xmm4 ; xmm4=Int1H=( 8 9 10 11 12 13 14 15)
- psrldq xmm7, 2 ; xmm7=( 1 2 3 4 5 6 7 --)
- pslldq xmm3, (SIZEOF_XMMWORD-2) ; xmm3=(-- -- -- -- -- -- -- 8)
- movdqa xmm0, xmm6
- movdqa xmm2, xmm4
- psrldq xmm0, (SIZEOF_XMMWORD-2) ; xmm0=( 7 -- -- -- -- -- -- --)
- pslldq xmm2, 2 ; xmm2=(-- 8 9 10 11 12 13 14)
-
- por xmm7, xmm3 ; xmm7=( 1 2 3 4 5 6 7 8)
- por xmm0, xmm2 ; xmm0=( 7 8 9 10 11 12 13 14)
-
- movdqa xmm1, xmm6
- movdqa xmm5, xmm4
- pslldq xmm1, 2 ; xmm1=(-- 0 1 2 3 4 5 6)
- psrldq xmm5, 2 ; xmm5=( 9 10 11 12 13 14 15 --)
- movdqa xmm3, xmm4
- psrldq xmm3, (SIZEOF_XMMWORD-2) ; xmm3=(15 -- -- -- -- -- -- --)
-
- por xmm1, XMMWORD [wk(1)] ; xmm1=(-1 0 1 2 3 4 5 6)
- por xmm5, XMMWORD [wk(3)] ; xmm5=( 9 10 11 12 13 14 15 16)
-
- movdqa XMMWORD [wk(1)], xmm3
-
- pmullw xmm6, [GOTOFF(ebx,PW_THREE)]
- pmullw xmm4, [GOTOFF(ebx,PW_THREE)]
- paddw xmm1, [GOTOFF(ebx,PW_EIGHT)]
- paddw xmm0, [GOTOFF(ebx,PW_EIGHT)]
- paddw xmm7, [GOTOFF(ebx,PW_SEVEN)]
- paddw xmm5, [GOTOFF(ebx,PW_SEVEN)]
-
- paddw xmm1, xmm6
- paddw xmm0, xmm4
- psrlw xmm1, 4 ; xmm1=Out1LE=( 0 2 4 6 8 10 12 14)
- psrlw xmm0, 4 ; xmm0=Out1HE=(16 18 20 22 24 26 28 30)
- paddw xmm7, xmm6
- paddw xmm5, xmm4
- psrlw xmm7, 4 ; xmm7=Out1LO=( 1 3 5 7 9 11 13 15)
- psrlw xmm5, 4 ; xmm5=Out1HO=(17 19 21 23 25 27 29 31)
-
- psllw xmm7, BYTE_BIT
- psllw xmm5, BYTE_BIT
- por xmm1, xmm7 ; xmm1=Out1L=( 0 1 2 ... 13 14 15)
- por xmm0, xmm5 ; xmm0=Out1H=(16 17 18 ... 29 30 31)
-
- movdqa XMMWORD [edi+0*SIZEOF_XMMWORD], xmm1
- movdqa XMMWORD [edi+1*SIZEOF_XMMWORD], xmm0
-
- poppic ebx
-
- sub eax, byte SIZEOF_XMMWORD
- add ecx, byte 1*SIZEOF_XMMWORD ; inptr1(above)
- add ebx, byte 1*SIZEOF_XMMWORD ; inptr0
- add esi, byte 1*SIZEOF_XMMWORD ; inptr1(below)
- add edx, byte 2*SIZEOF_XMMWORD ; outptr0
- add edi, byte 2*SIZEOF_XMMWORD ; outptr1
- cmp eax, byte SIZEOF_XMMWORD
- ja near .columnloop
- test eax, eax
- jnz near .columnloop_last
-
- pop esi
- pop edi
- pop ecx
- pop eax
-
- add esi, byte 1*SIZEOF_JSAMPROW ; input_data
- add edi, byte 2*SIZEOF_JSAMPROW ; output_data
- sub ecx, byte 2 ; rowctr
- jg near .rowloop
-
-.return:
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- pop ebx
- mov esp, ebp ; esp <- aligned ebp
- pop esp ; esp <- original ebp
- pop ebp
- ret
-
-; --------------------------------------------------------------------------
-;
-; Fast processing for the common case of 2:1 horizontal and 1:1 vertical.
-; It's still a box filter.
-;
-; GLOBAL(void)
-; jsimd_h2v1_upsample_sse2(int max_v_samp_factor, JDIMENSION output_width,
-; JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr);
-;
-
-%define max_v_samp(b) (b) + 8 ; int max_v_samp_factor
-%define output_width(b) (b) + 12 ; JDIMENSION output_width
-%define input_data(b) (b) + 16 ; JSAMPARRAY input_data
-%define output_data_ptr(b) (b) + 20 ; JSAMPARRAY *output_data_ptr
-
- align 32
- GLOBAL_FUNCTION(jsimd_h2v1_upsample_sse2)
-
-EXTN(jsimd_h2v1_upsample_sse2):
- push ebp
- mov ebp, esp
-; push ebx ; unused
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- mov edx, JDIMENSION [output_width(ebp)]
- add edx, byte (2*SIZEOF_XMMWORD)-1
- and edx, byte -(2*SIZEOF_XMMWORD)
- jz short .return
-
- mov ecx, INT [max_v_samp(ebp)] ; rowctr
- test ecx, ecx
- jz short .return
-
- mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
- mov edi, POINTER [output_data_ptr(ebp)]
- mov edi, JSAMPARRAY [edi] ; output_data
- alignx 16, 7
-.rowloop:
- push edi
- push esi
-
- mov esi, JSAMPROW [esi] ; inptr
- mov edi, JSAMPROW [edi] ; outptr
- mov eax, edx ; colctr
- alignx 16, 7
-.columnloop:
-
- movdqa xmm0, XMMWORD [esi+0*SIZEOF_XMMWORD]
-
- movdqa xmm1, xmm0
- punpcklbw xmm0, xmm0
- punpckhbw xmm1, xmm1
-
- movdqa XMMWORD [edi+0*SIZEOF_XMMWORD], xmm0
- movdqa XMMWORD [edi+1*SIZEOF_XMMWORD], xmm1
-
- sub eax, byte 2*SIZEOF_XMMWORD
- jz short .nextrow
-
- movdqa xmm2, XMMWORD [esi+1*SIZEOF_XMMWORD]
-
- movdqa xmm3, xmm2
- punpcklbw xmm2, xmm2
- punpckhbw xmm3, xmm3
-
- movdqa XMMWORD [edi+2*SIZEOF_XMMWORD], xmm2
- movdqa XMMWORD [edi+3*SIZEOF_XMMWORD], xmm3
-
- sub eax, byte 2*SIZEOF_XMMWORD
- jz short .nextrow
-
- add esi, byte 2*SIZEOF_XMMWORD ; inptr
- add edi, byte 4*SIZEOF_XMMWORD ; outptr
- jmp short .columnloop
- alignx 16, 7
-
-.nextrow:
- pop esi
- pop edi
-
- add esi, byte SIZEOF_JSAMPROW ; input_data
- add edi, byte SIZEOF_JSAMPROW ; output_data
- dec ecx ; rowctr
- jg short .rowloop
-
-.return:
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
-; pop ebx ; unused
- pop ebp
- ret
-
-; --------------------------------------------------------------------------
-;
-; Fast processing for the common case of 2:1 horizontal and 2:1 vertical.
-; It's still a box filter.
-;
-; GLOBAL(void)
-; jsimd_h2v2_upsample_sse2(int max_v_samp_factor, JDIMENSION output_width,
-; JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr);
-;
-
-%define max_v_samp(b) (b) + 8 ; int max_v_samp_factor
-%define output_width(b) (b) + 12 ; JDIMENSION output_width
-%define input_data(b) (b) + 16 ; JSAMPARRAY input_data
-%define output_data_ptr(b) (b) + 20 ; JSAMPARRAY *output_data_ptr
-
- align 32
- GLOBAL_FUNCTION(jsimd_h2v2_upsample_sse2)
-
-EXTN(jsimd_h2v2_upsample_sse2):
- push ebp
- mov ebp, esp
- push ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- mov edx, JDIMENSION [output_width(ebp)]
- add edx, byte (2*SIZEOF_XMMWORD)-1
- and edx, byte -(2*SIZEOF_XMMWORD)
- jz near .return
-
- mov ecx, INT [max_v_samp(ebp)] ; rowctr
- test ecx, ecx
- jz near .return
-
- mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
- mov edi, POINTER [output_data_ptr(ebp)]
- mov edi, JSAMPARRAY [edi] ; output_data
- alignx 16, 7
-.rowloop:
- push edi
- push esi
-
- mov esi, JSAMPROW [esi] ; inptr
- mov ebx, JSAMPROW [edi+0*SIZEOF_JSAMPROW] ; outptr0
- mov edi, JSAMPROW [edi+1*SIZEOF_JSAMPROW] ; outptr1
- mov eax, edx ; colctr
- alignx 16, 7
-.columnloop:
-
- movdqa xmm0, XMMWORD [esi+0*SIZEOF_XMMWORD]
-
- movdqa xmm1, xmm0
- punpcklbw xmm0, xmm0
- punpckhbw xmm1, xmm1
-
- movdqa XMMWORD [ebx+0*SIZEOF_XMMWORD], xmm0
- movdqa XMMWORD [ebx+1*SIZEOF_XMMWORD], xmm1
- movdqa XMMWORD [edi+0*SIZEOF_XMMWORD], xmm0
- movdqa XMMWORD [edi+1*SIZEOF_XMMWORD], xmm1
-
- sub eax, byte 2*SIZEOF_XMMWORD
- jz short .nextrow
-
- movdqa xmm2, XMMWORD [esi+1*SIZEOF_XMMWORD]
-
- movdqa xmm3, xmm2
- punpcklbw xmm2, xmm2
- punpckhbw xmm3, xmm3
-
- movdqa XMMWORD [ebx+2*SIZEOF_XMMWORD], xmm2
- movdqa XMMWORD [ebx+3*SIZEOF_XMMWORD], xmm3
- movdqa XMMWORD [edi+2*SIZEOF_XMMWORD], xmm2
- movdqa XMMWORD [edi+3*SIZEOF_XMMWORD], xmm3
-
- sub eax, byte 2*SIZEOF_XMMWORD
- jz short .nextrow
-
- add esi, byte 2*SIZEOF_XMMWORD ; inptr
- add ebx, byte 4*SIZEOF_XMMWORD ; outptr0
- add edi, byte 4*SIZEOF_XMMWORD ; outptr1
- jmp short .columnloop
- alignx 16, 7
-
-.nextrow:
- pop esi
- pop edi
-
- add esi, byte 1*SIZEOF_JSAMPROW ; input_data
- add edi, byte 2*SIZEOF_JSAMPROW ; output_data
- sub ecx, byte 2 ; rowctr
- jg short .rowloop
-
-.return:
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- pop ebx
- pop ebp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jfdctflt-3dn.asm b/contrib/libs/libjpeg-turbo/simd/i386/jfdctflt-3dn.asm
deleted file mode 100644
index 322ab16325..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jfdctflt-3dn.asm
+++ /dev/null
@@ -1,318 +0,0 @@
-;
-; jfdctflt.asm - floating-point FDCT (3DNow!)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-;
-; This file contains a floating-point implementation of the forward DCT
-; (Discrete Cosine Transform). The following code is based directly on
-; the IJG's original jfdctflt.c; see the jfdctflt.c for more details.
-
-%include "jsimdext.inc"
-%include "jdct.inc"
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_fdct_float_3dnow)
-
-EXTN(jconst_fdct_float_3dnow):
-
-PD_0_382 times 2 dd 0.382683432365089771728460
-PD_0_707 times 2 dd 0.707106781186547524400844
-PD_0_541 times 2 dd 0.541196100146196984399723
-PD_1_306 times 2 dd 1.306562964876376527856643
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-;
-; Perform the forward DCT on one block of samples.
-;
-; GLOBAL(void)
-; jsimd_fdct_float_3dnow(FAST_FLOAT *data)
-;
-
-%define data(b) (b) + 8 ; FAST_FLOAT *data
-
-%define original_ebp ebp + 0
-%define wk(i) ebp - (WK_NUM - (i)) * SIZEOF_MMWORD ; mmword wk[WK_NUM]
-%define WK_NUM 2
-
- align 32
- GLOBAL_FUNCTION(jsimd_fdct_float_3dnow)
-
-EXTN(jsimd_fdct_float_3dnow):
- push ebp
- mov eax, esp ; eax = original ebp
- sub esp, byte 4
- and esp, byte (-SIZEOF_MMWORD) ; align to 64 bits
- mov [esp], eax
- mov ebp, esp ; ebp = aligned ebp
- lea esp, [wk(0)]
- pushpic ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
-; push esi ; unused
-; push edi ; unused
-
- get_GOT ebx ; get GOT address
-
- ; ---- Pass 1: process rows.
-
- mov edx, POINTER [data(eax)] ; (FAST_FLOAT *)
- mov ecx, DCTSIZE/2
- alignx 16, 7
-.rowloop:
-
- movq mm0, MMWORD [MMBLOCK(0,0,edx,SIZEOF_FAST_FLOAT)]
- movq mm1, MMWORD [MMBLOCK(1,0,edx,SIZEOF_FAST_FLOAT)]
- movq mm2, MMWORD [MMBLOCK(0,3,edx,SIZEOF_FAST_FLOAT)]
- movq mm3, MMWORD [MMBLOCK(1,3,edx,SIZEOF_FAST_FLOAT)]
-
- ; mm0=(00 01), mm1=(10 11), mm2=(06 07), mm3=(16 17)
-
- movq mm4, mm0 ; transpose coefficients
- punpckldq mm0, mm1 ; mm0=(00 10)=data0
- punpckhdq mm4, mm1 ; mm4=(01 11)=data1
- movq mm5, mm2 ; transpose coefficients
- punpckldq mm2, mm3 ; mm2=(06 16)=data6
- punpckhdq mm5, mm3 ; mm5=(07 17)=data7
-
- movq mm6, mm4
- movq mm7, mm0
- pfsub mm4, mm2 ; mm4=data1-data6=tmp6
- pfsub mm0, mm5 ; mm0=data0-data7=tmp7
- pfadd mm6, mm2 ; mm6=data1+data6=tmp1
- pfadd mm7, mm5 ; mm7=data0+data7=tmp0
-
- movq mm1, MMWORD [MMBLOCK(0,1,edx,SIZEOF_FAST_FLOAT)]
- movq mm3, MMWORD [MMBLOCK(1,1,edx,SIZEOF_FAST_FLOAT)]
- movq mm2, MMWORD [MMBLOCK(0,2,edx,SIZEOF_FAST_FLOAT)]
- movq mm5, MMWORD [MMBLOCK(1,2,edx,SIZEOF_FAST_FLOAT)]
-
- ; mm1=(02 03), mm3=(12 13), mm2=(04 05), mm5=(14 15)
-
- movq MMWORD [wk(0)], mm4 ; wk(0)=tmp6
- movq MMWORD [wk(1)], mm0 ; wk(1)=tmp7
-
- movq mm4, mm1 ; transpose coefficients
- punpckldq mm1, mm3 ; mm1=(02 12)=data2
- punpckhdq mm4, mm3 ; mm4=(03 13)=data3
- movq mm0, mm2 ; transpose coefficients
- punpckldq mm2, mm5 ; mm2=(04 14)=data4
- punpckhdq mm0, mm5 ; mm0=(05 15)=data5
-
- movq mm3, mm4
- movq mm5, mm1
- pfadd mm4, mm2 ; mm4=data3+data4=tmp3
- pfadd mm1, mm0 ; mm1=data2+data5=tmp2
- pfsub mm3, mm2 ; mm3=data3-data4=tmp4
- pfsub mm5, mm0 ; mm5=data2-data5=tmp5
-
- ; -- Even part
-
- movq mm2, mm7
- movq mm0, mm6
- pfsub mm7, mm4 ; mm7=tmp13
- pfsub mm6, mm1 ; mm6=tmp12
- pfadd mm2, mm4 ; mm2=tmp10
- pfadd mm0, mm1 ; mm0=tmp11
-
- pfadd mm6, mm7
- pfmul mm6, [GOTOFF(ebx,PD_0_707)] ; mm6=z1
-
- movq mm4, mm2
- movq mm1, mm7
- pfsub mm2, mm0 ; mm2=data4
- pfsub mm7, mm6 ; mm7=data6
- pfadd mm4, mm0 ; mm4=data0
- pfadd mm1, mm6 ; mm1=data2
-
- movq MMWORD [MMBLOCK(0,2,edx,SIZEOF_FAST_FLOAT)], mm2
- movq MMWORD [MMBLOCK(0,3,edx,SIZEOF_FAST_FLOAT)], mm7
- movq MMWORD [MMBLOCK(0,0,edx,SIZEOF_FAST_FLOAT)], mm4
- movq MMWORD [MMBLOCK(0,1,edx,SIZEOF_FAST_FLOAT)], mm1
-
- ; -- Odd part
-
- movq mm0, MMWORD [wk(0)] ; mm0=tmp6
- movq mm6, MMWORD [wk(1)] ; mm6=tmp7
-
- pfadd mm3, mm5 ; mm3=tmp10
- pfadd mm5, mm0 ; mm5=tmp11
- pfadd mm0, mm6 ; mm0=tmp12, mm6=tmp7
-
- pfmul mm5, [GOTOFF(ebx,PD_0_707)] ; mm5=z3
-
- movq mm2, mm3 ; mm2=tmp10
- pfsub mm3, mm0
- pfmul mm3, [GOTOFF(ebx,PD_0_382)] ; mm3=z5
- pfmul mm2, [GOTOFF(ebx,PD_0_541)] ; mm2=MULTIPLY(tmp10,FIX_0_54119610)
- pfmul mm0, [GOTOFF(ebx,PD_1_306)] ; mm0=MULTIPLY(tmp12,FIX_1_30656296)
- pfadd mm2, mm3 ; mm2=z2
- pfadd mm0, mm3 ; mm0=z4
-
- movq mm7, mm6
- pfsub mm6, mm5 ; mm6=z13
- pfadd mm7, mm5 ; mm7=z11
-
- movq mm4, mm6
- movq mm1, mm7
- pfsub mm6, mm2 ; mm6=data3
- pfsub mm7, mm0 ; mm7=data7
- pfadd mm4, mm2 ; mm4=data5
- pfadd mm1, mm0 ; mm1=data1
-
- movq MMWORD [MMBLOCK(1,1,edx,SIZEOF_FAST_FLOAT)], mm6
- movq MMWORD [MMBLOCK(1,3,edx,SIZEOF_FAST_FLOAT)], mm7
- movq MMWORD [MMBLOCK(1,2,edx,SIZEOF_FAST_FLOAT)], mm4
- movq MMWORD [MMBLOCK(1,0,edx,SIZEOF_FAST_FLOAT)], mm1
-
- add edx, byte 2*DCTSIZE*SIZEOF_FAST_FLOAT
- dec ecx
- jnz near .rowloop
-
- ; ---- Pass 2: process columns.
-
- mov edx, POINTER [data(eax)] ; (FAST_FLOAT *)
- mov ecx, DCTSIZE/2
- alignx 16, 7
-.columnloop:
-
- movq mm0, MMWORD [MMBLOCK(0,0,edx,SIZEOF_FAST_FLOAT)]
- movq mm1, MMWORD [MMBLOCK(1,0,edx,SIZEOF_FAST_FLOAT)]
- movq mm2, MMWORD [MMBLOCK(6,0,edx,SIZEOF_FAST_FLOAT)]
- movq mm3, MMWORD [MMBLOCK(7,0,edx,SIZEOF_FAST_FLOAT)]
-
- ; mm0=(00 10), mm1=(01 11), mm2=(60 70), mm3=(61 71)
-
- movq mm4, mm0 ; transpose coefficients
- punpckldq mm0, mm1 ; mm0=(00 01)=data0
- punpckhdq mm4, mm1 ; mm4=(10 11)=data1
- movq mm5, mm2 ; transpose coefficients
- punpckldq mm2, mm3 ; mm2=(60 61)=data6
- punpckhdq mm5, mm3 ; mm5=(70 71)=data7
-
- movq mm6, mm4
- movq mm7, mm0
- pfsub mm4, mm2 ; mm4=data1-data6=tmp6
- pfsub mm0, mm5 ; mm0=data0-data7=tmp7
- pfadd mm6, mm2 ; mm6=data1+data6=tmp1
- pfadd mm7, mm5 ; mm7=data0+data7=tmp0
-
- movq mm1, MMWORD [MMBLOCK(2,0,edx,SIZEOF_FAST_FLOAT)]
- movq mm3, MMWORD [MMBLOCK(3,0,edx,SIZEOF_FAST_FLOAT)]
- movq mm2, MMWORD [MMBLOCK(4,0,edx,SIZEOF_FAST_FLOAT)]
- movq mm5, MMWORD [MMBLOCK(5,0,edx,SIZEOF_FAST_FLOAT)]
-
- ; mm1=(20 30), mm3=(21 31), mm2=(40 50), mm5=(41 51)
-
- movq MMWORD [wk(0)], mm4 ; wk(0)=tmp6
- movq MMWORD [wk(1)], mm0 ; wk(1)=tmp7
-
- movq mm4, mm1 ; transpose coefficients
- punpckldq mm1, mm3 ; mm1=(20 21)=data2
- punpckhdq mm4, mm3 ; mm4=(30 31)=data3
- movq mm0, mm2 ; transpose coefficients
- punpckldq mm2, mm5 ; mm2=(40 41)=data4
- punpckhdq mm0, mm5 ; mm0=(50 51)=data5
-
- movq mm3, mm4
- movq mm5, mm1
- pfadd mm4, mm2 ; mm4=data3+data4=tmp3
- pfadd mm1, mm0 ; mm1=data2+data5=tmp2
- pfsub mm3, mm2 ; mm3=data3-data4=tmp4
- pfsub mm5, mm0 ; mm5=data2-data5=tmp5
-
- ; -- Even part
-
- movq mm2, mm7
- movq mm0, mm6
- pfsub mm7, mm4 ; mm7=tmp13
- pfsub mm6, mm1 ; mm6=tmp12
- pfadd mm2, mm4 ; mm2=tmp10
- pfadd mm0, mm1 ; mm0=tmp11
-
- pfadd mm6, mm7
- pfmul mm6, [GOTOFF(ebx,PD_0_707)] ; mm6=z1
-
- movq mm4, mm2
- movq mm1, mm7
- pfsub mm2, mm0 ; mm2=data4
- pfsub mm7, mm6 ; mm7=data6
- pfadd mm4, mm0 ; mm4=data0
- pfadd mm1, mm6 ; mm1=data2
-
- movq MMWORD [MMBLOCK(4,0,edx,SIZEOF_FAST_FLOAT)], mm2
- movq MMWORD [MMBLOCK(6,0,edx,SIZEOF_FAST_FLOAT)], mm7
- movq MMWORD [MMBLOCK(0,0,edx,SIZEOF_FAST_FLOAT)], mm4
- movq MMWORD [MMBLOCK(2,0,edx,SIZEOF_FAST_FLOAT)], mm1
-
- ; -- Odd part
-
- movq mm0, MMWORD [wk(0)] ; mm0=tmp6
- movq mm6, MMWORD [wk(1)] ; mm6=tmp7
-
- pfadd mm3, mm5 ; mm3=tmp10
- pfadd mm5, mm0 ; mm5=tmp11
- pfadd mm0, mm6 ; mm0=tmp12, mm6=tmp7
-
- pfmul mm5, [GOTOFF(ebx,PD_0_707)] ; mm5=z3
-
- movq mm2, mm3 ; mm2=tmp10
- pfsub mm3, mm0
- pfmul mm3, [GOTOFF(ebx,PD_0_382)] ; mm3=z5
- pfmul mm2, [GOTOFF(ebx,PD_0_541)] ; mm2=MULTIPLY(tmp10,FIX_0_54119610)
- pfmul mm0, [GOTOFF(ebx,PD_1_306)] ; mm0=MULTIPLY(tmp12,FIX_1_30656296)
- pfadd mm2, mm3 ; mm2=z2
- pfadd mm0, mm3 ; mm0=z4
-
- movq mm7, mm6
- pfsub mm6, mm5 ; mm6=z13
- pfadd mm7, mm5 ; mm7=z11
-
- movq mm4, mm6
- movq mm1, mm7
- pfsub mm6, mm2 ; mm6=data3
- pfsub mm7, mm0 ; mm7=data7
- pfadd mm4, mm2 ; mm4=data5
- pfadd mm1, mm0 ; mm1=data1
-
- movq MMWORD [MMBLOCK(3,0,edx,SIZEOF_FAST_FLOAT)], mm6
- movq MMWORD [MMBLOCK(7,0,edx,SIZEOF_FAST_FLOAT)], mm7
- movq MMWORD [MMBLOCK(5,0,edx,SIZEOF_FAST_FLOAT)], mm4
- movq MMWORD [MMBLOCK(1,0,edx,SIZEOF_FAST_FLOAT)], mm1
-
- add edx, byte 2*SIZEOF_FAST_FLOAT
- dec ecx
- jnz near .columnloop
-
- femms ; empty MMX/3DNow! state
-
-; pop edi ; unused
-; pop esi ; unused
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- poppic ebx
- mov esp, ebp ; esp <- aligned ebp
- pop esp ; esp <- original ebp
- pop ebp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jfdctflt-sse.asm b/contrib/libs/libjpeg-turbo/simd/i386/jfdctflt-sse.asm
deleted file mode 100644
index 86952c6499..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jfdctflt-sse.asm
+++ /dev/null
@@ -1,369 +0,0 @@
-;
-; jfdctflt.asm - floating-point FDCT (SSE)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-;
-; This file contains a floating-point implementation of the forward DCT
-; (Discrete Cosine Transform). The following code is based directly on
-; the IJG's original jfdctflt.c; see the jfdctflt.c for more details.
-
-%include "jsimdext.inc"
-%include "jdct.inc"
-
-; --------------------------------------------------------------------------
-
-%macro unpcklps2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(0 1 4 5)
- shufps %1, %2, 0x44
-%endmacro
-
-%macro unpckhps2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(2 3 6 7)
- shufps %1, %2, 0xEE
-%endmacro
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_fdct_float_sse)
-
-EXTN(jconst_fdct_float_sse):
-
-PD_0_382 times 4 dd 0.382683432365089771728460
-PD_0_707 times 4 dd 0.707106781186547524400844
-PD_0_541 times 4 dd 0.541196100146196984399723
-PD_1_306 times 4 dd 1.306562964876376527856643
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-;
-; Perform the forward DCT on one block of samples.
-;
-; GLOBAL(void)
-; jsimd_fdct_float_sse(FAST_FLOAT *data)
-;
-
-%define data(b) (b) + 8 ; FAST_FLOAT *data
-
-%define original_ebp ebp + 0
-%define wk(i) ebp - (WK_NUM - (i)) * SIZEOF_XMMWORD
- ; xmmword wk[WK_NUM]
-%define WK_NUM 2
-
- align 32
- GLOBAL_FUNCTION(jsimd_fdct_float_sse)
-
-EXTN(jsimd_fdct_float_sse):
- push ebp
- mov eax, esp ; eax = original ebp
- sub esp, byte 4
- and esp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [esp], eax
- mov ebp, esp ; ebp = aligned ebp
- lea esp, [wk(0)]
- pushpic ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
-; push esi ; unused
-; push edi ; unused
-
- get_GOT ebx ; get GOT address
-
- ; ---- Pass 1: process rows.
-
- mov edx, POINTER [data(eax)] ; (FAST_FLOAT *)
- mov ecx, DCTSIZE/4
- alignx 16, 7
-.rowloop:
-
- movaps xmm0, XMMWORD [XMMBLOCK(2,0,edx,SIZEOF_FAST_FLOAT)]
- movaps xmm1, XMMWORD [XMMBLOCK(3,0,edx,SIZEOF_FAST_FLOAT)]
- movaps xmm2, XMMWORD [XMMBLOCK(2,1,edx,SIZEOF_FAST_FLOAT)]
- movaps xmm3, XMMWORD [XMMBLOCK(3,1,edx,SIZEOF_FAST_FLOAT)]
-
- ; xmm0=(20 21 22 23), xmm2=(24 25 26 27)
- ; xmm1=(30 31 32 33), xmm3=(34 35 36 37)
-
- movaps xmm4, xmm0 ; transpose coefficients(phase 1)
- unpcklps xmm0, xmm1 ; xmm0=(20 30 21 31)
- unpckhps xmm4, xmm1 ; xmm4=(22 32 23 33)
- movaps xmm5, xmm2 ; transpose coefficients(phase 1)
- unpcklps xmm2, xmm3 ; xmm2=(24 34 25 35)
- unpckhps xmm5, xmm3 ; xmm5=(26 36 27 37)
-
- movaps xmm6, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_FAST_FLOAT)]
- movaps xmm7, XMMWORD [XMMBLOCK(1,0,edx,SIZEOF_FAST_FLOAT)]
- movaps xmm1, XMMWORD [XMMBLOCK(0,1,edx,SIZEOF_FAST_FLOAT)]
- movaps xmm3, XMMWORD [XMMBLOCK(1,1,edx,SIZEOF_FAST_FLOAT)]
-
- ; xmm6=(00 01 02 03), xmm1=(04 05 06 07)
- ; xmm7=(10 11 12 13), xmm3=(14 15 16 17)
-
- movaps XMMWORD [wk(0)], xmm4 ; wk(0)=(22 32 23 33)
- movaps XMMWORD [wk(1)], xmm2 ; wk(1)=(24 34 25 35)
-
- movaps xmm4, xmm6 ; transpose coefficients(phase 1)
- unpcklps xmm6, xmm7 ; xmm6=(00 10 01 11)
- unpckhps xmm4, xmm7 ; xmm4=(02 12 03 13)
- movaps xmm2, xmm1 ; transpose coefficients(phase 1)
- unpcklps xmm1, xmm3 ; xmm1=(04 14 05 15)
- unpckhps xmm2, xmm3 ; xmm2=(06 16 07 17)
-
- movaps xmm7, xmm6 ; transpose coefficients(phase 2)
- unpcklps2 xmm6, xmm0 ; xmm6=(00 10 20 30)=data0
- unpckhps2 xmm7, xmm0 ; xmm7=(01 11 21 31)=data1
- movaps xmm3, xmm2 ; transpose coefficients(phase 2)
- unpcklps2 xmm2, xmm5 ; xmm2=(06 16 26 36)=data6
- unpckhps2 xmm3, xmm5 ; xmm3=(07 17 27 37)=data7
-
- movaps xmm0, xmm7
- movaps xmm5, xmm6
- subps xmm7, xmm2 ; xmm7=data1-data6=tmp6
- subps xmm6, xmm3 ; xmm6=data0-data7=tmp7
- addps xmm0, xmm2 ; xmm0=data1+data6=tmp1
- addps xmm5, xmm3 ; xmm5=data0+data7=tmp0
-
- movaps xmm2, XMMWORD [wk(0)] ; xmm2=(22 32 23 33)
- movaps xmm3, XMMWORD [wk(1)] ; xmm3=(24 34 25 35)
- movaps XMMWORD [wk(0)], xmm7 ; wk(0)=tmp6
- movaps XMMWORD [wk(1)], xmm6 ; wk(1)=tmp7
-
- movaps xmm7, xmm4 ; transpose coefficients(phase 2)
- unpcklps2 xmm4, xmm2 ; xmm4=(02 12 22 32)=data2
- unpckhps2 xmm7, xmm2 ; xmm7=(03 13 23 33)=data3
- movaps xmm6, xmm1 ; transpose coefficients(phase 2)
- unpcklps2 xmm1, xmm3 ; xmm1=(04 14 24 34)=data4
- unpckhps2 xmm6, xmm3 ; xmm6=(05 15 25 35)=data5
-
- movaps xmm2, xmm7
- movaps xmm3, xmm4
- addps xmm7, xmm1 ; xmm7=data3+data4=tmp3
- addps xmm4, xmm6 ; xmm4=data2+data5=tmp2
- subps xmm2, xmm1 ; xmm2=data3-data4=tmp4
- subps xmm3, xmm6 ; xmm3=data2-data5=tmp5
-
- ; -- Even part
-
- movaps xmm1, xmm5
- movaps xmm6, xmm0
- subps xmm5, xmm7 ; xmm5=tmp13
- subps xmm0, xmm4 ; xmm0=tmp12
- addps xmm1, xmm7 ; xmm1=tmp10
- addps xmm6, xmm4 ; xmm6=tmp11
-
- addps xmm0, xmm5
- mulps xmm0, [GOTOFF(ebx,PD_0_707)] ; xmm0=z1
-
- movaps xmm7, xmm1
- movaps xmm4, xmm5
- subps xmm1, xmm6 ; xmm1=data4
- subps xmm5, xmm0 ; xmm5=data6
- addps xmm7, xmm6 ; xmm7=data0
- addps xmm4, xmm0 ; xmm4=data2
-
- movaps XMMWORD [XMMBLOCK(0,1,edx,SIZEOF_FAST_FLOAT)], xmm1
- movaps XMMWORD [XMMBLOCK(2,1,edx,SIZEOF_FAST_FLOAT)], xmm5
- movaps XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_FAST_FLOAT)], xmm7
- movaps XMMWORD [XMMBLOCK(2,0,edx,SIZEOF_FAST_FLOAT)], xmm4
-
- ; -- Odd part
-
- movaps xmm6, XMMWORD [wk(0)] ; xmm6=tmp6
- movaps xmm0, XMMWORD [wk(1)] ; xmm0=tmp7
-
- addps xmm2, xmm3 ; xmm2=tmp10
- addps xmm3, xmm6 ; xmm3=tmp11
- addps xmm6, xmm0 ; xmm6=tmp12, xmm0=tmp7
-
- mulps xmm3, [GOTOFF(ebx,PD_0_707)] ; xmm3=z3
-
- movaps xmm1, xmm2 ; xmm1=tmp10
- subps xmm2, xmm6
- mulps xmm2, [GOTOFF(ebx,PD_0_382)] ; xmm2=z5
- mulps xmm1, [GOTOFF(ebx,PD_0_541)] ; xmm1=MULTIPLY(tmp10,FIX_0_541196)
- mulps xmm6, [GOTOFF(ebx,PD_1_306)] ; xmm6=MULTIPLY(tmp12,FIX_1_306562)
- addps xmm1, xmm2 ; xmm1=z2
- addps xmm6, xmm2 ; xmm6=z4
-
- movaps xmm5, xmm0
- subps xmm0, xmm3 ; xmm0=z13
- addps xmm5, xmm3 ; xmm5=z11
-
- movaps xmm7, xmm0
- movaps xmm4, xmm5
- subps xmm0, xmm1 ; xmm0=data3
- subps xmm5, xmm6 ; xmm5=data7
- addps xmm7, xmm1 ; xmm7=data5
- addps xmm4, xmm6 ; xmm4=data1
-
- movaps XMMWORD [XMMBLOCK(3,0,edx,SIZEOF_FAST_FLOAT)], xmm0
- movaps XMMWORD [XMMBLOCK(3,1,edx,SIZEOF_FAST_FLOAT)], xmm5
- movaps XMMWORD [XMMBLOCK(1,1,edx,SIZEOF_FAST_FLOAT)], xmm7
- movaps XMMWORD [XMMBLOCK(1,0,edx,SIZEOF_FAST_FLOAT)], xmm4
-
- add edx, 4*DCTSIZE*SIZEOF_FAST_FLOAT
- dec ecx
- jnz near .rowloop
-
- ; ---- Pass 2: process columns.
-
- mov edx, POINTER [data(eax)] ; (FAST_FLOAT *)
- mov ecx, DCTSIZE/4
- alignx 16, 7
-.columnloop:
-
- movaps xmm0, XMMWORD [XMMBLOCK(2,0,edx,SIZEOF_FAST_FLOAT)]
- movaps xmm1, XMMWORD [XMMBLOCK(3,0,edx,SIZEOF_FAST_FLOAT)]
- movaps xmm2, XMMWORD [XMMBLOCK(6,0,edx,SIZEOF_FAST_FLOAT)]
- movaps xmm3, XMMWORD [XMMBLOCK(7,0,edx,SIZEOF_FAST_FLOAT)]
-
- ; xmm0=(02 12 22 32), xmm2=(42 52 62 72)
- ; xmm1=(03 13 23 33), xmm3=(43 53 63 73)
-
- movaps xmm4, xmm0 ; transpose coefficients(phase 1)
- unpcklps xmm0, xmm1 ; xmm0=(02 03 12 13)
- unpckhps xmm4, xmm1 ; xmm4=(22 23 32 33)
- movaps xmm5, xmm2 ; transpose coefficients(phase 1)
- unpcklps xmm2, xmm3 ; xmm2=(42 43 52 53)
- unpckhps xmm5, xmm3 ; xmm5=(62 63 72 73)
-
- movaps xmm6, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_FAST_FLOAT)]
- movaps xmm7, XMMWORD [XMMBLOCK(1,0,edx,SIZEOF_FAST_FLOAT)]
- movaps xmm1, XMMWORD [XMMBLOCK(4,0,edx,SIZEOF_FAST_FLOAT)]
- movaps xmm3, XMMWORD [XMMBLOCK(5,0,edx,SIZEOF_FAST_FLOAT)]
-
- ; xmm6=(00 10 20 30), xmm1=(40 50 60 70)
- ; xmm7=(01 11 21 31), xmm3=(41 51 61 71)
-
- movaps XMMWORD [wk(0)], xmm4 ; wk(0)=(22 23 32 33)
- movaps XMMWORD [wk(1)], xmm2 ; wk(1)=(42 43 52 53)
-
- movaps xmm4, xmm6 ; transpose coefficients(phase 1)
- unpcklps xmm6, xmm7 ; xmm6=(00 01 10 11)
- unpckhps xmm4, xmm7 ; xmm4=(20 21 30 31)
- movaps xmm2, xmm1 ; transpose coefficients(phase 1)
- unpcklps xmm1, xmm3 ; xmm1=(40 41 50 51)
- unpckhps xmm2, xmm3 ; xmm2=(60 61 70 71)
-
- movaps xmm7, xmm6 ; transpose coefficients(phase 2)
- unpcklps2 xmm6, xmm0 ; xmm6=(00 01 02 03)=data0
- unpckhps2 xmm7, xmm0 ; xmm7=(10 11 12 13)=data1
- movaps xmm3, xmm2 ; transpose coefficients(phase 2)
- unpcklps2 xmm2, xmm5 ; xmm2=(60 61 62 63)=data6
- unpckhps2 xmm3, xmm5 ; xmm3=(70 71 72 73)=data7
-
- movaps xmm0, xmm7
- movaps xmm5, xmm6
- subps xmm7, xmm2 ; xmm7=data1-data6=tmp6
- subps xmm6, xmm3 ; xmm6=data0-data7=tmp7
- addps xmm0, xmm2 ; xmm0=data1+data6=tmp1
- addps xmm5, xmm3 ; xmm5=data0+data7=tmp0
-
- movaps xmm2, XMMWORD [wk(0)] ; xmm2=(22 23 32 33)
- movaps xmm3, XMMWORD [wk(1)] ; xmm3=(42 43 52 53)
- movaps XMMWORD [wk(0)], xmm7 ; wk(0)=tmp6
- movaps XMMWORD [wk(1)], xmm6 ; wk(1)=tmp7
-
- movaps xmm7, xmm4 ; transpose coefficients(phase 2)
- unpcklps2 xmm4, xmm2 ; xmm4=(20 21 22 23)=data2
- unpckhps2 xmm7, xmm2 ; xmm7=(30 31 32 33)=data3
- movaps xmm6, xmm1 ; transpose coefficients(phase 2)
- unpcklps2 xmm1, xmm3 ; xmm1=(40 41 42 43)=data4
- unpckhps2 xmm6, xmm3 ; xmm6=(50 51 52 53)=data5
-
- movaps xmm2, xmm7
- movaps xmm3, xmm4
- addps xmm7, xmm1 ; xmm7=data3+data4=tmp3
- addps xmm4, xmm6 ; xmm4=data2+data5=tmp2
- subps xmm2, xmm1 ; xmm2=data3-data4=tmp4
- subps xmm3, xmm6 ; xmm3=data2-data5=tmp5
-
- ; -- Even part
-
- movaps xmm1, xmm5
- movaps xmm6, xmm0
- subps xmm5, xmm7 ; xmm5=tmp13
- subps xmm0, xmm4 ; xmm0=tmp12
- addps xmm1, xmm7 ; xmm1=tmp10
- addps xmm6, xmm4 ; xmm6=tmp11
-
- addps xmm0, xmm5
- mulps xmm0, [GOTOFF(ebx,PD_0_707)] ; xmm0=z1
-
- movaps xmm7, xmm1
- movaps xmm4, xmm5
- subps xmm1, xmm6 ; xmm1=data4
- subps xmm5, xmm0 ; xmm5=data6
- addps xmm7, xmm6 ; xmm7=data0
- addps xmm4, xmm0 ; xmm4=data2
-
- movaps XMMWORD [XMMBLOCK(4,0,edx,SIZEOF_FAST_FLOAT)], xmm1
- movaps XMMWORD [XMMBLOCK(6,0,edx,SIZEOF_FAST_FLOAT)], xmm5
- movaps XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_FAST_FLOAT)], xmm7
- movaps XMMWORD [XMMBLOCK(2,0,edx,SIZEOF_FAST_FLOAT)], xmm4
-
- ; -- Odd part
-
- movaps xmm6, XMMWORD [wk(0)] ; xmm6=tmp6
- movaps xmm0, XMMWORD [wk(1)] ; xmm0=tmp7
-
- addps xmm2, xmm3 ; xmm2=tmp10
- addps xmm3, xmm6 ; xmm3=tmp11
- addps xmm6, xmm0 ; xmm6=tmp12, xmm0=tmp7
-
- mulps xmm3, [GOTOFF(ebx,PD_0_707)] ; xmm3=z3
-
- movaps xmm1, xmm2 ; xmm1=tmp10
- subps xmm2, xmm6
- mulps xmm2, [GOTOFF(ebx,PD_0_382)] ; xmm2=z5
- mulps xmm1, [GOTOFF(ebx,PD_0_541)] ; xmm1=MULTIPLY(tmp10,FIX_0_541196)
- mulps xmm6, [GOTOFF(ebx,PD_1_306)] ; xmm6=MULTIPLY(tmp12,FIX_1_306562)
- addps xmm1, xmm2 ; xmm1=z2
- addps xmm6, xmm2 ; xmm6=z4
-
- movaps xmm5, xmm0
- subps xmm0, xmm3 ; xmm0=z13
- addps xmm5, xmm3 ; xmm5=z11
-
- movaps xmm7, xmm0
- movaps xmm4, xmm5
- subps xmm0, xmm1 ; xmm0=data3
- subps xmm5, xmm6 ; xmm5=data7
- addps xmm7, xmm1 ; xmm7=data5
- addps xmm4, xmm6 ; xmm4=data1
-
- movaps XMMWORD [XMMBLOCK(3,0,edx,SIZEOF_FAST_FLOAT)], xmm0
- movaps XMMWORD [XMMBLOCK(7,0,edx,SIZEOF_FAST_FLOAT)], xmm5
- movaps XMMWORD [XMMBLOCK(5,0,edx,SIZEOF_FAST_FLOAT)], xmm7
- movaps XMMWORD [XMMBLOCK(1,0,edx,SIZEOF_FAST_FLOAT)], xmm4
-
- add edx, byte 4*SIZEOF_FAST_FLOAT
- dec ecx
- jnz near .columnloop
-
-; pop edi ; unused
-; pop esi ; unused
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- poppic ebx
- mov esp, ebp ; esp <- aligned ebp
- pop esp ; esp <- original ebp
- pop ebp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jfdctfst-mmx.asm b/contrib/libs/libjpeg-turbo/simd/i386/jfdctfst-mmx.asm
deleted file mode 100644
index 80645a50d7..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jfdctfst-mmx.asm
+++ /dev/null
@@ -1,395 +0,0 @@
-;
-; jfdctfst.asm - fast integer FDCT (MMX)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-;
-; This file contains a fast, not so accurate integer implementation of
-; the forward DCT (Discrete Cosine Transform). The following code is
-; based directly on the IJG's original jfdctfst.c; see the jfdctfst.c
-; for more details.
-
-%include "jsimdext.inc"
-%include "jdct.inc"
-
-; --------------------------------------------------------------------------
-
-%define CONST_BITS 8 ; 14 is also OK.
-
-%if CONST_BITS == 8
-F_0_382 equ 98 ; FIX(0.382683433)
-F_0_541 equ 139 ; FIX(0.541196100)
-F_0_707 equ 181 ; FIX(0.707106781)
-F_1_306 equ 334 ; FIX(1.306562965)
-%else
-; NASM cannot do compile-time arithmetic on floating-point constants.
-%define DESCALE(x, n) (((x) + (1 << ((n) - 1))) >> (n))
-F_0_382 equ DESCALE( 410903207, 30 - CONST_BITS) ; FIX(0.382683433)
-F_0_541 equ DESCALE( 581104887, 30 - CONST_BITS) ; FIX(0.541196100)
-F_0_707 equ DESCALE( 759250124, 30 - CONST_BITS) ; FIX(0.707106781)
-F_1_306 equ DESCALE(1402911301, 30 - CONST_BITS) ; FIX(1.306562965)
-%endif
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
-; PRE_MULTIPLY_SCALE_BITS <= 2 (to avoid overflow)
-; CONST_BITS + CONST_SHIFT + PRE_MULTIPLY_SCALE_BITS == 16 (for pmulhw)
-
-%define PRE_MULTIPLY_SCALE_BITS 2
-%define CONST_SHIFT (16 - PRE_MULTIPLY_SCALE_BITS - CONST_BITS)
-
- alignz 32
- GLOBAL_DATA(jconst_fdct_ifast_mmx)
-
-EXTN(jconst_fdct_ifast_mmx):
-
-PW_F0707 times 4 dw F_0_707 << CONST_SHIFT
-PW_F0382 times 4 dw F_0_382 << CONST_SHIFT
-PW_F0541 times 4 dw F_0_541 << CONST_SHIFT
-PW_F1306 times 4 dw F_1_306 << CONST_SHIFT
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-;
-; Perform the forward DCT on one block of samples.
-;
-; GLOBAL(void)
-; jsimd_fdct_ifast_mmx(DCTELEM *data)
-;
-
-%define data(b) (b) + 8 ; DCTELEM *data
-
-%define original_ebp ebp + 0
-%define wk(i) ebp - (WK_NUM - (i)) * SIZEOF_MMWORD ; mmword wk[WK_NUM]
-%define WK_NUM 2
-
- align 32
- GLOBAL_FUNCTION(jsimd_fdct_ifast_mmx)
-
-EXTN(jsimd_fdct_ifast_mmx):
- push ebp
- mov eax, esp ; eax = original ebp
- sub esp, byte 4
- and esp, byte (-SIZEOF_MMWORD) ; align to 64 bits
- mov [esp], eax
- mov ebp, esp ; ebp = aligned ebp
- lea esp, [wk(0)]
- pushpic ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
-; push esi ; unused
-; push edi ; unused
-
- get_GOT ebx ; get GOT address
-
- ; ---- Pass 1: process rows.
-
- mov edx, POINTER [data(eax)] ; (DCTELEM *)
- mov ecx, DCTSIZE/4
- alignx 16, 7
-.rowloop:
-
- movq mm0, MMWORD [MMBLOCK(2,0,edx,SIZEOF_DCTELEM)]
- movq mm1, MMWORD [MMBLOCK(3,0,edx,SIZEOF_DCTELEM)]
- movq mm2, MMWORD [MMBLOCK(2,1,edx,SIZEOF_DCTELEM)]
- movq mm3, MMWORD [MMBLOCK(3,1,edx,SIZEOF_DCTELEM)]
-
- ; mm0=(20 21 22 23), mm2=(24 25 26 27)
- ; mm1=(30 31 32 33), mm3=(34 35 36 37)
-
- movq mm4, mm0 ; transpose coefficients(phase 1)
- punpcklwd mm0, mm1 ; mm0=(20 30 21 31)
- punpckhwd mm4, mm1 ; mm4=(22 32 23 33)
- movq mm5, mm2 ; transpose coefficients(phase 1)
- punpcklwd mm2, mm3 ; mm2=(24 34 25 35)
- punpckhwd mm5, mm3 ; mm5=(26 36 27 37)
-
- movq mm6, MMWORD [MMBLOCK(0,0,edx,SIZEOF_DCTELEM)]
- movq mm7, MMWORD [MMBLOCK(1,0,edx,SIZEOF_DCTELEM)]
- movq mm1, MMWORD [MMBLOCK(0,1,edx,SIZEOF_DCTELEM)]
- movq mm3, MMWORD [MMBLOCK(1,1,edx,SIZEOF_DCTELEM)]
-
- ; mm6=(00 01 02 03), mm1=(04 05 06 07)
- ; mm7=(10 11 12 13), mm3=(14 15 16 17)
-
- movq MMWORD [wk(0)], mm4 ; wk(0)=(22 32 23 33)
- movq MMWORD [wk(1)], mm2 ; wk(1)=(24 34 25 35)
-
- movq mm4, mm6 ; transpose coefficients(phase 1)
- punpcklwd mm6, mm7 ; mm6=(00 10 01 11)
- punpckhwd mm4, mm7 ; mm4=(02 12 03 13)
- movq mm2, mm1 ; transpose coefficients(phase 1)
- punpcklwd mm1, mm3 ; mm1=(04 14 05 15)
- punpckhwd mm2, mm3 ; mm2=(06 16 07 17)
-
- movq mm7, mm6 ; transpose coefficients(phase 2)
- punpckldq mm6, mm0 ; mm6=(00 10 20 30)=data0
- punpckhdq mm7, mm0 ; mm7=(01 11 21 31)=data1
- movq mm3, mm2 ; transpose coefficients(phase 2)
- punpckldq mm2, mm5 ; mm2=(06 16 26 36)=data6
- punpckhdq mm3, mm5 ; mm3=(07 17 27 37)=data7
-
- movq mm0, mm7
- movq mm5, mm6
- psubw mm7, mm2 ; mm7=data1-data6=tmp6
- psubw mm6, mm3 ; mm6=data0-data7=tmp7
- paddw mm0, mm2 ; mm0=data1+data6=tmp1
- paddw mm5, mm3 ; mm5=data0+data7=tmp0
-
- movq mm2, MMWORD [wk(0)] ; mm2=(22 32 23 33)
- movq mm3, MMWORD [wk(1)] ; mm3=(24 34 25 35)
- movq MMWORD [wk(0)], mm7 ; wk(0)=tmp6
- movq MMWORD [wk(1)], mm6 ; wk(1)=tmp7
-
- movq mm7, mm4 ; transpose coefficients(phase 2)
- punpckldq mm4, mm2 ; mm4=(02 12 22 32)=data2
- punpckhdq mm7, mm2 ; mm7=(03 13 23 33)=data3
- movq mm6, mm1 ; transpose coefficients(phase 2)
- punpckldq mm1, mm3 ; mm1=(04 14 24 34)=data4
- punpckhdq mm6, mm3 ; mm6=(05 15 25 35)=data5
-
- movq mm2, mm7
- movq mm3, mm4
- paddw mm7, mm1 ; mm7=data3+data4=tmp3
- paddw mm4, mm6 ; mm4=data2+data5=tmp2
- psubw mm2, mm1 ; mm2=data3-data4=tmp4
- psubw mm3, mm6 ; mm3=data2-data5=tmp5
-
- ; -- Even part
-
- movq mm1, mm5
- movq mm6, mm0
- psubw mm5, mm7 ; mm5=tmp13
- psubw mm0, mm4 ; mm0=tmp12
- paddw mm1, mm7 ; mm1=tmp10
- paddw mm6, mm4 ; mm6=tmp11
-
- paddw mm0, mm5
- psllw mm0, PRE_MULTIPLY_SCALE_BITS
- pmulhw mm0, [GOTOFF(ebx,PW_F0707)] ; mm0=z1
-
- movq mm7, mm1
- movq mm4, mm5
- psubw mm1, mm6 ; mm1=data4
- psubw mm5, mm0 ; mm5=data6
- paddw mm7, mm6 ; mm7=data0
- paddw mm4, mm0 ; mm4=data2
-
- movq MMWORD [MMBLOCK(0,1,edx,SIZEOF_DCTELEM)], mm1
- movq MMWORD [MMBLOCK(2,1,edx,SIZEOF_DCTELEM)], mm5
- movq MMWORD [MMBLOCK(0,0,edx,SIZEOF_DCTELEM)], mm7
- movq MMWORD [MMBLOCK(2,0,edx,SIZEOF_DCTELEM)], mm4
-
- ; -- Odd part
-
- movq mm6, MMWORD [wk(0)] ; mm6=tmp6
- movq mm0, MMWORD [wk(1)] ; mm0=tmp7
-
- paddw mm2, mm3 ; mm2=tmp10
- paddw mm3, mm6 ; mm3=tmp11
- paddw mm6, mm0 ; mm6=tmp12, mm0=tmp7
-
- psllw mm2, PRE_MULTIPLY_SCALE_BITS
- psllw mm6, PRE_MULTIPLY_SCALE_BITS
-
- psllw mm3, PRE_MULTIPLY_SCALE_BITS
- pmulhw mm3, [GOTOFF(ebx,PW_F0707)] ; mm3=z3
-
- movq mm1, mm2 ; mm1=tmp10
- psubw mm2, mm6
- pmulhw mm2, [GOTOFF(ebx,PW_F0382)] ; mm2=z5
- pmulhw mm1, [GOTOFF(ebx,PW_F0541)] ; mm1=MULTIPLY(tmp10,FIX_0_54119610)
- pmulhw mm6, [GOTOFF(ebx,PW_F1306)] ; mm6=MULTIPLY(tmp12,FIX_1_30656296)
- paddw mm1, mm2 ; mm1=z2
- paddw mm6, mm2 ; mm6=z4
-
- movq mm5, mm0
- psubw mm0, mm3 ; mm0=z13
- paddw mm5, mm3 ; mm5=z11
-
- movq mm7, mm0
- movq mm4, mm5
- psubw mm0, mm1 ; mm0=data3
- psubw mm5, mm6 ; mm5=data7
- paddw mm7, mm1 ; mm7=data5
- paddw mm4, mm6 ; mm4=data1
-
- movq MMWORD [MMBLOCK(3,0,edx,SIZEOF_DCTELEM)], mm0
- movq MMWORD [MMBLOCK(3,1,edx,SIZEOF_DCTELEM)], mm5
- movq MMWORD [MMBLOCK(1,1,edx,SIZEOF_DCTELEM)], mm7
- movq MMWORD [MMBLOCK(1,0,edx,SIZEOF_DCTELEM)], mm4
-
- add edx, byte 4*DCTSIZE*SIZEOF_DCTELEM
- dec ecx
- jnz near .rowloop
-
- ; ---- Pass 2: process columns.
-
- mov edx, POINTER [data(eax)] ; (DCTELEM *)
- mov ecx, DCTSIZE/4
- alignx 16, 7
-.columnloop:
-
- movq mm0, MMWORD [MMBLOCK(2,0,edx,SIZEOF_DCTELEM)]
- movq mm1, MMWORD [MMBLOCK(3,0,edx,SIZEOF_DCTELEM)]
- movq mm2, MMWORD [MMBLOCK(6,0,edx,SIZEOF_DCTELEM)]
- movq mm3, MMWORD [MMBLOCK(7,0,edx,SIZEOF_DCTELEM)]
-
- ; mm0=(02 12 22 32), mm2=(42 52 62 72)
- ; mm1=(03 13 23 33), mm3=(43 53 63 73)
-
- movq mm4, mm0 ; transpose coefficients(phase 1)
- punpcklwd mm0, mm1 ; mm0=(02 03 12 13)
- punpckhwd mm4, mm1 ; mm4=(22 23 32 33)
- movq mm5, mm2 ; transpose coefficients(phase 1)
- punpcklwd mm2, mm3 ; mm2=(42 43 52 53)
- punpckhwd mm5, mm3 ; mm5=(62 63 72 73)
-
- movq mm6, MMWORD [MMBLOCK(0,0,edx,SIZEOF_DCTELEM)]
- movq mm7, MMWORD [MMBLOCK(1,0,edx,SIZEOF_DCTELEM)]
- movq mm1, MMWORD [MMBLOCK(4,0,edx,SIZEOF_DCTELEM)]
- movq mm3, MMWORD [MMBLOCK(5,0,edx,SIZEOF_DCTELEM)]
-
- ; mm6=(00 10 20 30), mm1=(40 50 60 70)
- ; mm7=(01 11 21 31), mm3=(41 51 61 71)
-
- movq MMWORD [wk(0)], mm4 ; wk(0)=(22 23 32 33)
- movq MMWORD [wk(1)], mm2 ; wk(1)=(42 43 52 53)
-
- movq mm4, mm6 ; transpose coefficients(phase 1)
- punpcklwd mm6, mm7 ; mm6=(00 01 10 11)
- punpckhwd mm4, mm7 ; mm4=(20 21 30 31)
- movq mm2, mm1 ; transpose coefficients(phase 1)
- punpcklwd mm1, mm3 ; mm1=(40 41 50 51)
- punpckhwd mm2, mm3 ; mm2=(60 61 70 71)
-
- movq mm7, mm6 ; transpose coefficients(phase 2)
- punpckldq mm6, mm0 ; mm6=(00 01 02 03)=data0
- punpckhdq mm7, mm0 ; mm7=(10 11 12 13)=data1
- movq mm3, mm2 ; transpose coefficients(phase 2)
- punpckldq mm2, mm5 ; mm2=(60 61 62 63)=data6
- punpckhdq mm3, mm5 ; mm3=(70 71 72 73)=data7
-
- movq mm0, mm7
- movq mm5, mm6
- psubw mm7, mm2 ; mm7=data1-data6=tmp6
- psubw mm6, mm3 ; mm6=data0-data7=tmp7
- paddw mm0, mm2 ; mm0=data1+data6=tmp1
- paddw mm5, mm3 ; mm5=data0+data7=tmp0
-
- movq mm2, MMWORD [wk(0)] ; mm2=(22 23 32 33)
- movq mm3, MMWORD [wk(1)] ; mm3=(42 43 52 53)
- movq MMWORD [wk(0)], mm7 ; wk(0)=tmp6
- movq MMWORD [wk(1)], mm6 ; wk(1)=tmp7
-
- movq mm7, mm4 ; transpose coefficients(phase 2)
- punpckldq mm4, mm2 ; mm4=(20 21 22 23)=data2
- punpckhdq mm7, mm2 ; mm7=(30 31 32 33)=data3
- movq mm6, mm1 ; transpose coefficients(phase 2)
- punpckldq mm1, mm3 ; mm1=(40 41 42 43)=data4
- punpckhdq mm6, mm3 ; mm6=(50 51 52 53)=data5
-
- movq mm2, mm7
- movq mm3, mm4
- paddw mm7, mm1 ; mm7=data3+data4=tmp3
- paddw mm4, mm6 ; mm4=data2+data5=tmp2
- psubw mm2, mm1 ; mm2=data3-data4=tmp4
- psubw mm3, mm6 ; mm3=data2-data5=tmp5
-
- ; -- Even part
-
- movq mm1, mm5
- movq mm6, mm0
- psubw mm5, mm7 ; mm5=tmp13
- psubw mm0, mm4 ; mm0=tmp12
- paddw mm1, mm7 ; mm1=tmp10
- paddw mm6, mm4 ; mm6=tmp11
-
- paddw mm0, mm5
- psllw mm0, PRE_MULTIPLY_SCALE_BITS
- pmulhw mm0, [GOTOFF(ebx,PW_F0707)] ; mm0=z1
-
- movq mm7, mm1
- movq mm4, mm5
- psubw mm1, mm6 ; mm1=data4
- psubw mm5, mm0 ; mm5=data6
- paddw mm7, mm6 ; mm7=data0
- paddw mm4, mm0 ; mm4=data2
-
- movq MMWORD [MMBLOCK(4,0,edx,SIZEOF_DCTELEM)], mm1
- movq MMWORD [MMBLOCK(6,0,edx,SIZEOF_DCTELEM)], mm5
- movq MMWORD [MMBLOCK(0,0,edx,SIZEOF_DCTELEM)], mm7
- movq MMWORD [MMBLOCK(2,0,edx,SIZEOF_DCTELEM)], mm4
-
- ; -- Odd part
-
- movq mm6, MMWORD [wk(0)] ; mm6=tmp6
- movq mm0, MMWORD [wk(1)] ; mm0=tmp7
-
- paddw mm2, mm3 ; mm2=tmp10
- paddw mm3, mm6 ; mm3=tmp11
- paddw mm6, mm0 ; mm6=tmp12, mm0=tmp7
-
- psllw mm2, PRE_MULTIPLY_SCALE_BITS
- psllw mm6, PRE_MULTIPLY_SCALE_BITS
-
- psllw mm3, PRE_MULTIPLY_SCALE_BITS
- pmulhw mm3, [GOTOFF(ebx,PW_F0707)] ; mm3=z3
-
- movq mm1, mm2 ; mm1=tmp10
- psubw mm2, mm6
- pmulhw mm2, [GOTOFF(ebx,PW_F0382)] ; mm2=z5
- pmulhw mm1, [GOTOFF(ebx,PW_F0541)] ; mm1=MULTIPLY(tmp10,FIX_0_54119610)
- pmulhw mm6, [GOTOFF(ebx,PW_F1306)] ; mm6=MULTIPLY(tmp12,FIX_1_30656296)
- paddw mm1, mm2 ; mm1=z2
- paddw mm6, mm2 ; mm6=z4
-
- movq mm5, mm0
- psubw mm0, mm3 ; mm0=z13
- paddw mm5, mm3 ; mm5=z11
-
- movq mm7, mm0
- movq mm4, mm5
- psubw mm0, mm1 ; mm0=data3
- psubw mm5, mm6 ; mm5=data7
- paddw mm7, mm1 ; mm7=data5
- paddw mm4, mm6 ; mm4=data1
-
- movq MMWORD [MMBLOCK(3,0,edx,SIZEOF_DCTELEM)], mm0
- movq MMWORD [MMBLOCK(7,0,edx,SIZEOF_DCTELEM)], mm5
- movq MMWORD [MMBLOCK(5,0,edx,SIZEOF_DCTELEM)], mm7
- movq MMWORD [MMBLOCK(1,0,edx,SIZEOF_DCTELEM)], mm4
-
- add edx, byte 4*SIZEOF_DCTELEM
- dec ecx
- jnz near .columnloop
-
- emms ; empty MMX state
-
-; pop edi ; unused
-; pop esi ; unused
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- poppic ebx
- mov esp, ebp ; esp <- aligned ebp
- pop esp ; esp <- original ebp
- pop ebp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jfdctfst-sse2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jfdctfst-sse2.asm
deleted file mode 100644
index 446fa7a68f..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jfdctfst-sse2.asm
+++ /dev/null
@@ -1,403 +0,0 @@
-;
-; jfdctfst.asm - fast integer FDCT (SSE2)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-;
-; This file contains a fast, not so accurate integer implementation of
-; the forward DCT (Discrete Cosine Transform). The following code is
-; based directly on the IJG's original jfdctfst.c; see the jfdctfst.c
-; for more details.
-
-%include "jsimdext.inc"
-%include "jdct.inc"
-
-; --------------------------------------------------------------------------
-
-%define CONST_BITS 8 ; 14 is also OK.
-
-%if CONST_BITS == 8
-F_0_382 equ 98 ; FIX(0.382683433)
-F_0_541 equ 139 ; FIX(0.541196100)
-F_0_707 equ 181 ; FIX(0.707106781)
-F_1_306 equ 334 ; FIX(1.306562965)
-%else
-; NASM cannot do compile-time arithmetic on floating-point constants.
-%define DESCALE(x, n) (((x) + (1 << ((n) - 1))) >> (n))
-F_0_382 equ DESCALE( 410903207, 30 - CONST_BITS) ; FIX(0.382683433)
-F_0_541 equ DESCALE( 581104887, 30 - CONST_BITS) ; FIX(0.541196100)
-F_0_707 equ DESCALE( 759250124, 30 - CONST_BITS) ; FIX(0.707106781)
-F_1_306 equ DESCALE(1402911301, 30 - CONST_BITS) ; FIX(1.306562965)
-%endif
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
-; PRE_MULTIPLY_SCALE_BITS <= 2 (to avoid overflow)
-; CONST_BITS + CONST_SHIFT + PRE_MULTIPLY_SCALE_BITS == 16 (for pmulhw)
-
-%define PRE_MULTIPLY_SCALE_BITS 2
-%define CONST_SHIFT (16 - PRE_MULTIPLY_SCALE_BITS - CONST_BITS)
-
- alignz 32
- GLOBAL_DATA(jconst_fdct_ifast_sse2)
-
-EXTN(jconst_fdct_ifast_sse2):
-
-PW_F0707 times 8 dw F_0_707 << CONST_SHIFT
-PW_F0382 times 8 dw F_0_382 << CONST_SHIFT
-PW_F0541 times 8 dw F_0_541 << CONST_SHIFT
-PW_F1306 times 8 dw F_1_306 << CONST_SHIFT
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-;
-; Perform the forward DCT on one block of samples.
-;
-; GLOBAL(void)
-; jsimd_fdct_ifast_sse2(DCTELEM *data)
-;
-
-%define data(b) (b) + 8 ; DCTELEM *data
-
-%define original_ebp ebp + 0
-%define wk(i) ebp - (WK_NUM - (i)) * SIZEOF_XMMWORD
- ; xmmword wk[WK_NUM]
-%define WK_NUM 2
-
- align 32
- GLOBAL_FUNCTION(jsimd_fdct_ifast_sse2)
-
-EXTN(jsimd_fdct_ifast_sse2):
- push ebp
- mov eax, esp ; eax = original ebp
- sub esp, byte 4
- and esp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [esp], eax
- mov ebp, esp ; ebp = aligned ebp
- lea esp, [wk(0)]
- pushpic ebx
-; push ecx ; unused
-; push edx ; need not be preserved
-; push esi ; unused
-; push edi ; unused
-
- get_GOT ebx ; get GOT address
-
- ; ---- Pass 1: process rows.
-
- mov edx, POINTER [data(eax)] ; (DCTELEM *)
-
- movdqa xmm0, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_DCTELEM)]
- movdqa xmm1, XMMWORD [XMMBLOCK(1,0,edx,SIZEOF_DCTELEM)]
- movdqa xmm2, XMMWORD [XMMBLOCK(2,0,edx,SIZEOF_DCTELEM)]
- movdqa xmm3, XMMWORD [XMMBLOCK(3,0,edx,SIZEOF_DCTELEM)]
-
- ; xmm0=(00 01 02 03 04 05 06 07), xmm2=(20 21 22 23 24 25 26 27)
- ; xmm1=(10 11 12 13 14 15 16 17), xmm3=(30 31 32 33 34 35 36 37)
-
- movdqa xmm4, xmm0 ; transpose coefficients(phase 1)
- punpcklwd xmm0, xmm1 ; xmm0=(00 10 01 11 02 12 03 13)
- punpckhwd xmm4, xmm1 ; xmm4=(04 14 05 15 06 16 07 17)
- movdqa xmm5, xmm2 ; transpose coefficients(phase 1)
- punpcklwd xmm2, xmm3 ; xmm2=(20 30 21 31 22 32 23 33)
- punpckhwd xmm5, xmm3 ; xmm5=(24 34 25 35 26 36 27 37)
-
- movdqa xmm6, XMMWORD [XMMBLOCK(4,0,edx,SIZEOF_DCTELEM)]
- movdqa xmm7, XMMWORD [XMMBLOCK(5,0,edx,SIZEOF_DCTELEM)]
- movdqa xmm1, XMMWORD [XMMBLOCK(6,0,edx,SIZEOF_DCTELEM)]
- movdqa xmm3, XMMWORD [XMMBLOCK(7,0,edx,SIZEOF_DCTELEM)]
-
- ; xmm6=( 4 12 20 28 36 44 52 60), xmm1=( 6 14 22 30 38 46 54 62)
- ; xmm7=( 5 13 21 29 37 45 53 61), xmm3=( 7 15 23 31 39 47 55 63)
-
- movdqa XMMWORD [wk(0)], xmm2 ; wk(0)=(20 30 21 31 22 32 23 33)
- movdqa XMMWORD [wk(1)], xmm5 ; wk(1)=(24 34 25 35 26 36 27 37)
-
- movdqa xmm2, xmm6 ; transpose coefficients(phase 1)
- punpcklwd xmm6, xmm7 ; xmm6=(40 50 41 51 42 52 43 53)
- punpckhwd xmm2, xmm7 ; xmm2=(44 54 45 55 46 56 47 57)
- movdqa xmm5, xmm1 ; transpose coefficients(phase 1)
- punpcklwd xmm1, xmm3 ; xmm1=(60 70 61 71 62 72 63 73)
- punpckhwd xmm5, xmm3 ; xmm5=(64 74 65 75 66 76 67 77)
-
- movdqa xmm7, xmm6 ; transpose coefficients(phase 2)
- punpckldq xmm6, xmm1 ; xmm6=(40 50 60 70 41 51 61 71)
- punpckhdq xmm7, xmm1 ; xmm7=(42 52 62 72 43 53 63 73)
- movdqa xmm3, xmm2 ; transpose coefficients(phase 2)
- punpckldq xmm2, xmm5 ; xmm2=(44 54 64 74 45 55 65 75)
- punpckhdq xmm3, xmm5 ; xmm3=(46 56 66 76 47 57 67 77)
-
- movdqa xmm1, XMMWORD [wk(0)] ; xmm1=(20 30 21 31 22 32 23 33)
- movdqa xmm5, XMMWORD [wk(1)] ; xmm5=(24 34 25 35 26 36 27 37)
- movdqa XMMWORD [wk(0)], xmm7 ; wk(0)=(42 52 62 72 43 53 63 73)
- movdqa XMMWORD [wk(1)], xmm2 ; wk(1)=(44 54 64 74 45 55 65 75)
-
- movdqa xmm7, xmm0 ; transpose coefficients(phase 2)
- punpckldq xmm0, xmm1 ; xmm0=(00 10 20 30 01 11 21 31)
- punpckhdq xmm7, xmm1 ; xmm7=(02 12 22 32 03 13 23 33)
- movdqa xmm2, xmm4 ; transpose coefficients(phase 2)
- punpckldq xmm4, xmm5 ; xmm4=(04 14 24 34 05 15 25 35)
- punpckhdq xmm2, xmm5 ; xmm2=(06 16 26 36 07 17 27 37)
-
- movdqa xmm1, xmm0 ; transpose coefficients(phase 3)
- punpcklqdq xmm0, xmm6 ; xmm0=(00 10 20 30 40 50 60 70)=data0
- punpckhqdq xmm1, xmm6 ; xmm1=(01 11 21 31 41 51 61 71)=data1
- movdqa xmm5, xmm2 ; transpose coefficients(phase 3)
- punpcklqdq xmm2, xmm3 ; xmm2=(06 16 26 36 46 56 66 76)=data6
- punpckhqdq xmm5, xmm3 ; xmm5=(07 17 27 37 47 57 67 77)=data7
-
- movdqa xmm6, xmm1
- movdqa xmm3, xmm0
- psubw xmm1, xmm2 ; xmm1=data1-data6=tmp6
- psubw xmm0, xmm5 ; xmm0=data0-data7=tmp7
- paddw xmm6, xmm2 ; xmm6=data1+data6=tmp1
- paddw xmm3, xmm5 ; xmm3=data0+data7=tmp0
-
- movdqa xmm2, XMMWORD [wk(0)] ; xmm2=(42 52 62 72 43 53 63 73)
- movdqa xmm5, XMMWORD [wk(1)] ; xmm5=(44 54 64 74 45 55 65 75)
- movdqa XMMWORD [wk(0)], xmm1 ; wk(0)=tmp6
- movdqa XMMWORD [wk(1)], xmm0 ; wk(1)=tmp7
-
- movdqa xmm1, xmm7 ; transpose coefficients(phase 3)
- punpcklqdq xmm7, xmm2 ; xmm7=(02 12 22 32 42 52 62 72)=data2
- punpckhqdq xmm1, xmm2 ; xmm1=(03 13 23 33 43 53 63 73)=data3
- movdqa xmm0, xmm4 ; transpose coefficients(phase 3)
- punpcklqdq xmm4, xmm5 ; xmm4=(04 14 24 34 44 54 64 74)=data4
- punpckhqdq xmm0, xmm5 ; xmm0=(05 15 25 35 45 55 65 75)=data5
-
- movdqa xmm2, xmm1
- movdqa xmm5, xmm7
- paddw xmm1, xmm4 ; xmm1=data3+data4=tmp3
- paddw xmm7, xmm0 ; xmm7=data2+data5=tmp2
- psubw xmm2, xmm4 ; xmm2=data3-data4=tmp4
- psubw xmm5, xmm0 ; xmm5=data2-data5=tmp5
-
- ; -- Even part
-
- movdqa xmm4, xmm3
- movdqa xmm0, xmm6
- psubw xmm3, xmm1 ; xmm3=tmp13
- psubw xmm6, xmm7 ; xmm6=tmp12
- paddw xmm4, xmm1 ; xmm4=tmp10
- paddw xmm0, xmm7 ; xmm0=tmp11
-
- paddw xmm6, xmm3
- psllw xmm6, PRE_MULTIPLY_SCALE_BITS
- pmulhw xmm6, [GOTOFF(ebx,PW_F0707)] ; xmm6=z1
-
- movdqa xmm1, xmm4
- movdqa xmm7, xmm3
- psubw xmm4, xmm0 ; xmm4=data4
- psubw xmm3, xmm6 ; xmm3=data6
- paddw xmm1, xmm0 ; xmm1=data0
- paddw xmm7, xmm6 ; xmm7=data2
-
- movdqa xmm0, XMMWORD [wk(0)] ; xmm0=tmp6
- movdqa xmm6, XMMWORD [wk(1)] ; xmm6=tmp7
- movdqa XMMWORD [wk(0)], xmm4 ; wk(0)=data4
- movdqa XMMWORD [wk(1)], xmm3 ; wk(1)=data6
-
- ; -- Odd part
-
- paddw xmm2, xmm5 ; xmm2=tmp10
- paddw xmm5, xmm0 ; xmm5=tmp11
- paddw xmm0, xmm6 ; xmm0=tmp12, xmm6=tmp7
-
- psllw xmm2, PRE_MULTIPLY_SCALE_BITS
- psllw xmm0, PRE_MULTIPLY_SCALE_BITS
-
- psllw xmm5, PRE_MULTIPLY_SCALE_BITS
- pmulhw xmm5, [GOTOFF(ebx,PW_F0707)] ; xmm5=z3
-
- movdqa xmm4, xmm2 ; xmm4=tmp10
- psubw xmm2, xmm0
- pmulhw xmm2, [GOTOFF(ebx,PW_F0382)] ; xmm2=z5
- pmulhw xmm4, [GOTOFF(ebx,PW_F0541)] ; xmm4=MULTIPLY(tmp10,FIX_0_541196)
- pmulhw xmm0, [GOTOFF(ebx,PW_F1306)] ; xmm0=MULTIPLY(tmp12,FIX_1_306562)
- paddw xmm4, xmm2 ; xmm4=z2
- paddw xmm0, xmm2 ; xmm0=z4
-
- movdqa xmm3, xmm6
- psubw xmm6, xmm5 ; xmm6=z13
- paddw xmm3, xmm5 ; xmm3=z11
-
- movdqa xmm2, xmm6
- movdqa xmm5, xmm3
- psubw xmm6, xmm4 ; xmm6=data3
- psubw xmm3, xmm0 ; xmm3=data7
- paddw xmm2, xmm4 ; xmm2=data5
- paddw xmm5, xmm0 ; xmm5=data1
-
- ; ---- Pass 2: process columns.
-
-; mov edx, POINTER [data(eax)] ; (DCTELEM *)
-
- ; xmm1=(00 10 20 30 40 50 60 70), xmm7=(02 12 22 32 42 52 62 72)
- ; xmm5=(01 11 21 31 41 51 61 71), xmm6=(03 13 23 33 43 53 63 73)
-
- movdqa xmm4, xmm1 ; transpose coefficients(phase 1)
- punpcklwd xmm1, xmm5 ; xmm1=(00 01 10 11 20 21 30 31)
- punpckhwd xmm4, xmm5 ; xmm4=(40 41 50 51 60 61 70 71)
- movdqa xmm0, xmm7 ; transpose coefficients(phase 1)
- punpcklwd xmm7, xmm6 ; xmm7=(02 03 12 13 22 23 32 33)
- punpckhwd xmm0, xmm6 ; xmm0=(42 43 52 53 62 63 72 73)
-
- movdqa xmm5, XMMWORD [wk(0)] ; xmm5=col4
- movdqa xmm6, XMMWORD [wk(1)] ; xmm6=col6
-
- ; xmm5=(04 14 24 34 44 54 64 74), xmm6=(06 16 26 36 46 56 66 76)
- ; xmm2=(05 15 25 35 45 55 65 75), xmm3=(07 17 27 37 47 57 67 77)
-
- movdqa XMMWORD [wk(0)], xmm7 ; wk(0)=(02 03 12 13 22 23 32 33)
- movdqa XMMWORD [wk(1)], xmm0 ; wk(1)=(42 43 52 53 62 63 72 73)
-
- movdqa xmm7, xmm5 ; transpose coefficients(phase 1)
- punpcklwd xmm5, xmm2 ; xmm5=(04 05 14 15 24 25 34 35)
- punpckhwd xmm7, xmm2 ; xmm7=(44 45 54 55 64 65 74 75)
- movdqa xmm0, xmm6 ; transpose coefficients(phase 1)
- punpcklwd xmm6, xmm3 ; xmm6=(06 07 16 17 26 27 36 37)
- punpckhwd xmm0, xmm3 ; xmm0=(46 47 56 57 66 67 76 77)
-
- movdqa xmm2, xmm5 ; transpose coefficients(phase 2)
- punpckldq xmm5, xmm6 ; xmm5=(04 05 06 07 14 15 16 17)
- punpckhdq xmm2, xmm6 ; xmm2=(24 25 26 27 34 35 36 37)
- movdqa xmm3, xmm7 ; transpose coefficients(phase 2)
- punpckldq xmm7, xmm0 ; xmm7=(44 45 46 47 54 55 56 57)
- punpckhdq xmm3, xmm0 ; xmm3=(64 65 66 67 74 75 76 77)
-
- movdqa xmm6, XMMWORD [wk(0)] ; xmm6=(02 03 12 13 22 23 32 33)
- movdqa xmm0, XMMWORD [wk(1)] ; xmm0=(42 43 52 53 62 63 72 73)
- movdqa XMMWORD [wk(0)], xmm2 ; wk(0)=(24 25 26 27 34 35 36 37)
- movdqa XMMWORD [wk(1)], xmm7 ; wk(1)=(44 45 46 47 54 55 56 57)
-
- movdqa xmm2, xmm1 ; transpose coefficients(phase 2)
- punpckldq xmm1, xmm6 ; xmm1=(00 01 02 03 10 11 12 13)
- punpckhdq xmm2, xmm6 ; xmm2=(20 21 22 23 30 31 32 33)
- movdqa xmm7, xmm4 ; transpose coefficients(phase 2)
- punpckldq xmm4, xmm0 ; xmm4=(40 41 42 43 50 51 52 53)
- punpckhdq xmm7, xmm0 ; xmm7=(60 61 62 63 70 71 72 73)
-
- movdqa xmm6, xmm1 ; transpose coefficients(phase 3)
- punpcklqdq xmm1, xmm5 ; xmm1=(00 01 02 03 04 05 06 07)=data0
- punpckhqdq xmm6, xmm5 ; xmm6=(10 11 12 13 14 15 16 17)=data1
- movdqa xmm0, xmm7 ; transpose coefficients(phase 3)
- punpcklqdq xmm7, xmm3 ; xmm7=(60 61 62 63 64 65 66 67)=data6
- punpckhqdq xmm0, xmm3 ; xmm0=(70 71 72 73 74 75 76 77)=data7
-
- movdqa xmm5, xmm6
- movdqa xmm3, xmm1
- psubw xmm6, xmm7 ; xmm6=data1-data6=tmp6
- psubw xmm1, xmm0 ; xmm1=data0-data7=tmp7
- paddw xmm5, xmm7 ; xmm5=data1+data6=tmp1
- paddw xmm3, xmm0 ; xmm3=data0+data7=tmp0
-
- movdqa xmm7, XMMWORD [wk(0)] ; xmm7=(24 25 26 27 34 35 36 37)
- movdqa xmm0, XMMWORD [wk(1)] ; xmm0=(44 45 46 47 54 55 56 57)
- movdqa XMMWORD [wk(0)], xmm6 ; wk(0)=tmp6
- movdqa XMMWORD [wk(1)], xmm1 ; wk(1)=tmp7
-
- movdqa xmm6, xmm2 ; transpose coefficients(phase 3)
- punpcklqdq xmm2, xmm7 ; xmm2=(20 21 22 23 24 25 26 27)=data2
- punpckhqdq xmm6, xmm7 ; xmm6=(30 31 32 33 34 35 36 37)=data3
- movdqa xmm1, xmm4 ; transpose coefficients(phase 3)
- punpcklqdq xmm4, xmm0 ; xmm4=(40 41 42 43 44 45 46 47)=data4
- punpckhqdq xmm1, xmm0 ; xmm1=(50 51 52 53 54 55 56 57)=data5
-
- movdqa xmm7, xmm6
- movdqa xmm0, xmm2
- paddw xmm6, xmm4 ; xmm6=data3+data4=tmp3
- paddw xmm2, xmm1 ; xmm2=data2+data5=tmp2
- psubw xmm7, xmm4 ; xmm7=data3-data4=tmp4
- psubw xmm0, xmm1 ; xmm0=data2-data5=tmp5
-
- ; -- Even part
-
- movdqa xmm4, xmm3
- movdqa xmm1, xmm5
- psubw xmm3, xmm6 ; xmm3=tmp13
- psubw xmm5, xmm2 ; xmm5=tmp12
- paddw xmm4, xmm6 ; xmm4=tmp10
- paddw xmm1, xmm2 ; xmm1=tmp11
-
- paddw xmm5, xmm3
- psllw xmm5, PRE_MULTIPLY_SCALE_BITS
- pmulhw xmm5, [GOTOFF(ebx,PW_F0707)] ; xmm5=z1
-
- movdqa xmm6, xmm4
- movdqa xmm2, xmm3
- psubw xmm4, xmm1 ; xmm4=data4
- psubw xmm3, xmm5 ; xmm3=data6
- paddw xmm6, xmm1 ; xmm6=data0
- paddw xmm2, xmm5 ; xmm2=data2
-
- movdqa XMMWORD [XMMBLOCK(4,0,edx,SIZEOF_DCTELEM)], xmm4
- movdqa XMMWORD [XMMBLOCK(6,0,edx,SIZEOF_DCTELEM)], xmm3
- movdqa XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_DCTELEM)], xmm6
- movdqa XMMWORD [XMMBLOCK(2,0,edx,SIZEOF_DCTELEM)], xmm2
-
- ; -- Odd part
-
- movdqa xmm1, XMMWORD [wk(0)] ; xmm1=tmp6
- movdqa xmm5, XMMWORD [wk(1)] ; xmm5=tmp7
-
- paddw xmm7, xmm0 ; xmm7=tmp10
- paddw xmm0, xmm1 ; xmm0=tmp11
- paddw xmm1, xmm5 ; xmm1=tmp12, xmm5=tmp7
-
- psllw xmm7, PRE_MULTIPLY_SCALE_BITS
- psllw xmm1, PRE_MULTIPLY_SCALE_BITS
-
- psllw xmm0, PRE_MULTIPLY_SCALE_BITS
- pmulhw xmm0, [GOTOFF(ebx,PW_F0707)] ; xmm0=z3
-
- movdqa xmm4, xmm7 ; xmm4=tmp10
- psubw xmm7, xmm1
- pmulhw xmm7, [GOTOFF(ebx,PW_F0382)] ; xmm7=z5
- pmulhw xmm4, [GOTOFF(ebx,PW_F0541)] ; xmm4=MULTIPLY(tmp10,FIX_0_541196)
- pmulhw xmm1, [GOTOFF(ebx,PW_F1306)] ; xmm1=MULTIPLY(tmp12,FIX_1_306562)
- paddw xmm4, xmm7 ; xmm4=z2
- paddw xmm1, xmm7 ; xmm1=z4
-
- movdqa xmm3, xmm5
- psubw xmm5, xmm0 ; xmm5=z13
- paddw xmm3, xmm0 ; xmm3=z11
-
- movdqa xmm6, xmm5
- movdqa xmm2, xmm3
- psubw xmm5, xmm4 ; xmm5=data3
- psubw xmm3, xmm1 ; xmm3=data7
- paddw xmm6, xmm4 ; xmm6=data5
- paddw xmm2, xmm1 ; xmm2=data1
-
- movdqa XMMWORD [XMMBLOCK(3,0,edx,SIZEOF_DCTELEM)], xmm5
- movdqa XMMWORD [XMMBLOCK(7,0,edx,SIZEOF_DCTELEM)], xmm3
- movdqa XMMWORD [XMMBLOCK(5,0,edx,SIZEOF_DCTELEM)], xmm6
- movdqa XMMWORD [XMMBLOCK(1,0,edx,SIZEOF_DCTELEM)], xmm2
-
-; pop edi ; unused
-; pop esi ; unused
-; pop edx ; need not be preserved
-; pop ecx ; unused
- poppic ebx
- mov esp, ebp ; esp <- aligned ebp
- pop esp ; esp <- original ebp
- pop ebp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jfdctint-avx2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jfdctint-avx2.asm
deleted file mode 100644
index 23cf733135..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jfdctint-avx2.asm
+++ /dev/null
@@ -1,331 +0,0 @@
-;
-; jfdctint.asm - accurate integer FDCT (AVX2)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, 2016, 2018, 2020, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-;
-; This file contains a slower but more accurate integer implementation of the
-; forward DCT (Discrete Cosine Transform). The following code is based
-; directly on the IJG's original jfdctint.c; see the jfdctint.c for
-; more details.
-
-%include "jsimdext.inc"
-%include "jdct.inc"
-
-; --------------------------------------------------------------------------
-
-%define CONST_BITS 13
-%define PASS1_BITS 2
-
-%define DESCALE_P1 (CONST_BITS - PASS1_BITS)
-%define DESCALE_P2 (CONST_BITS + PASS1_BITS)
-
-%if CONST_BITS == 13
-F_0_298 equ 2446 ; FIX(0.298631336)
-F_0_390 equ 3196 ; FIX(0.390180644)
-F_0_541 equ 4433 ; FIX(0.541196100)
-F_0_765 equ 6270 ; FIX(0.765366865)
-F_0_899 equ 7373 ; FIX(0.899976223)
-F_1_175 equ 9633 ; FIX(1.175875602)
-F_1_501 equ 12299 ; FIX(1.501321110)
-F_1_847 equ 15137 ; FIX(1.847759065)
-F_1_961 equ 16069 ; FIX(1.961570560)
-F_2_053 equ 16819 ; FIX(2.053119869)
-F_2_562 equ 20995 ; FIX(2.562915447)
-F_3_072 equ 25172 ; FIX(3.072711026)
-%else
-; NASM cannot do compile-time arithmetic on floating-point constants.
-%define DESCALE(x, n) (((x) + (1 << ((n) - 1))) >> (n))
-F_0_298 equ DESCALE( 320652955, 30 - CONST_BITS) ; FIX(0.298631336)
-F_0_390 equ DESCALE( 418953276, 30 - CONST_BITS) ; FIX(0.390180644)
-F_0_541 equ DESCALE( 581104887, 30 - CONST_BITS) ; FIX(0.541196100)
-F_0_765 equ DESCALE( 821806413, 30 - CONST_BITS) ; FIX(0.765366865)
-F_0_899 equ DESCALE( 966342111, 30 - CONST_BITS) ; FIX(0.899976223)
-F_1_175 equ DESCALE(1262586813, 30 - CONST_BITS) ; FIX(1.175875602)
-F_1_501 equ DESCALE(1612031267, 30 - CONST_BITS) ; FIX(1.501321110)
-F_1_847 equ DESCALE(1984016188, 30 - CONST_BITS) ; FIX(1.847759065)
-F_1_961 equ DESCALE(2106220350, 30 - CONST_BITS) ; FIX(1.961570560)
-F_2_053 equ DESCALE(2204520673, 30 - CONST_BITS) ; FIX(2.053119869)
-F_2_562 equ DESCALE(2751909506, 30 - CONST_BITS) ; FIX(2.562915447)
-F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
-%endif
-
-; --------------------------------------------------------------------------
-; In-place 8x8x16-bit matrix transpose using AVX2 instructions
-; %1-%4: Input/output registers
-; %5-%8: Temp registers
-
-%macro dotranspose 8
- ; %1=(00 01 02 03 04 05 06 07 40 41 42 43 44 45 46 47)
- ; %2=(10 11 12 13 14 15 16 17 50 51 52 53 54 55 56 57)
- ; %3=(20 21 22 23 24 25 26 27 60 61 62 63 64 65 66 67)
- ; %4=(30 31 32 33 34 35 36 37 70 71 72 73 74 75 76 77)
-
- vpunpcklwd %5, %1, %2
- vpunpckhwd %6, %1, %2
- vpunpcklwd %7, %3, %4
- vpunpckhwd %8, %3, %4
- ; transpose coefficients(phase 1)
- ; %5=(00 10 01 11 02 12 03 13 40 50 41 51 42 52 43 53)
- ; %6=(04 14 05 15 06 16 07 17 44 54 45 55 46 56 47 57)
- ; %7=(20 30 21 31 22 32 23 33 60 70 61 71 62 72 63 73)
- ; %8=(24 34 25 35 26 36 27 37 64 74 65 75 66 76 67 77)
-
- vpunpckldq %1, %5, %7
- vpunpckhdq %2, %5, %7
- vpunpckldq %3, %6, %8
- vpunpckhdq %4, %6, %8
- ; transpose coefficients(phase 2)
- ; %1=(00 10 20 30 01 11 21 31 40 50 60 70 41 51 61 71)
- ; %2=(02 12 22 32 03 13 23 33 42 52 62 72 43 53 63 73)
- ; %3=(04 14 24 34 05 15 25 35 44 54 64 74 45 55 65 75)
- ; %4=(06 16 26 36 07 17 27 37 46 56 66 76 47 57 67 77)
-
- vpermq %1, %1, 0x8D
- vpermq %2, %2, 0x8D
- vpermq %3, %3, 0xD8
- vpermq %4, %4, 0xD8
- ; transpose coefficients(phase 3)
- ; %1=(01 11 21 31 41 51 61 71 00 10 20 30 40 50 60 70)
- ; %2=(03 13 23 33 43 53 63 73 02 12 22 32 42 52 62 72)
- ; %3=(04 14 24 34 44 54 64 74 05 15 25 35 45 55 65 75)
- ; %4=(06 16 26 36 46 56 66 76 07 17 27 37 47 57 67 77)
-%endmacro
-
-; --------------------------------------------------------------------------
-; In-place 8x8x16-bit accurate integer forward DCT using AVX2 instructions
-; %1-%4: Input/output registers
-; %5-%8: Temp registers
-; %9: Pass (1 or 2)
-
-%macro dodct 9
- vpsubw %5, %1, %4 ; %5=data1_0-data6_7=tmp6_7
- vpaddw %6, %1, %4 ; %6=data1_0+data6_7=tmp1_0
- vpaddw %7, %2, %3 ; %7=data3_2+data4_5=tmp3_2
- vpsubw %8, %2, %3 ; %8=data3_2-data4_5=tmp4_5
-
- ; -- Even part
-
- vperm2i128 %6, %6, %6, 0x01 ; %6=tmp0_1
- vpaddw %1, %6, %7 ; %1=tmp0_1+tmp3_2=tmp10_11
- vpsubw %6, %6, %7 ; %6=tmp0_1-tmp3_2=tmp13_12
-
- vperm2i128 %7, %1, %1, 0x01 ; %7=tmp11_10
- vpsignw %1, %1, [GOTOFF(ebx, PW_1_NEG1)] ; %1=tmp10_neg11
- vpaddw %7, %7, %1 ; %7=(tmp10+tmp11)_(tmp10-tmp11)
-%if %9 == 1
- vpsllw %1, %7, PASS1_BITS ; %1=data0_4
-%else
- vpaddw %7, %7, [GOTOFF(ebx, PW_DESCALE_P2X)]
- vpsraw %1, %7, PASS1_BITS ; %1=data0_4
-%endif
-
- ; (Original)
- ; z1 = (tmp12 + tmp13) * 0.541196100;
- ; data2 = z1 + tmp13 * 0.765366865;
- ; data6 = z1 + tmp12 * -1.847759065;
- ;
- ; (This implementation)
- ; data2 = tmp13 * (0.541196100 + 0.765366865) + tmp12 * 0.541196100;
- ; data6 = tmp13 * 0.541196100 + tmp12 * (0.541196100 - 1.847759065);
-
- vperm2i128 %7, %6, %6, 0x01 ; %7=tmp12_13
- vpunpcklwd %2, %6, %7
- vpunpckhwd %6, %6, %7
- vpmaddwd %2, %2, [GOTOFF(ebx, PW_F130_F054_MF130_F054)] ; %2=data2_6L
- vpmaddwd %6, %6, [GOTOFF(ebx, PW_F130_F054_MF130_F054)] ; %6=data2_6H
-
- vpaddd %2, %2, [GOTOFF(ebx, PD_DESCALE_P %+ %9)]
- vpaddd %6, %6, [GOTOFF(ebx, PD_DESCALE_P %+ %9)]
- vpsrad %2, %2, DESCALE_P %+ %9
- vpsrad %6, %6, DESCALE_P %+ %9
-
- vpackssdw %3, %2, %6 ; %6=data2_6
-
- ; -- Odd part
-
- vpaddw %7, %8, %5 ; %7=tmp4_5+tmp6_7=z3_4
-
- ; (Original)
- ; z5 = (z3 + z4) * 1.175875602;
- ; z3 = z3 * -1.961570560; z4 = z4 * -0.390180644;
- ; z3 += z5; z4 += z5;
- ;
- ; (This implementation)
- ; z3 = z3 * (1.175875602 - 1.961570560) + z4 * 1.175875602;
- ; z4 = z3 * 1.175875602 + z4 * (1.175875602 - 0.390180644);
-
- vperm2i128 %2, %7, %7, 0x01 ; %2=z4_3
- vpunpcklwd %6, %7, %2
- vpunpckhwd %7, %7, %2
- vpmaddwd %6, %6, [GOTOFF(ebx, PW_MF078_F117_F078_F117)] ; %6=z3_4L
- vpmaddwd %7, %7, [GOTOFF(ebx, PW_MF078_F117_F078_F117)] ; %7=z3_4H
-
- ; (Original)
- ; z1 = tmp4 + tmp7; z2 = tmp5 + tmp6;
- ; tmp4 = tmp4 * 0.298631336; tmp5 = tmp5 * 2.053119869;
- ; tmp6 = tmp6 * 3.072711026; tmp7 = tmp7 * 1.501321110;
- ; z1 = z1 * -0.899976223; z2 = z2 * -2.562915447;
- ; data7 = tmp4 + z1 + z3; data5 = tmp5 + z2 + z4;
- ; data3 = tmp6 + z2 + z3; data1 = tmp7 + z1 + z4;
- ;
- ; (This implementation)
- ; tmp4 = tmp4 * (0.298631336 - 0.899976223) + tmp7 * -0.899976223;
- ; tmp5 = tmp5 * (2.053119869 - 2.562915447) + tmp6 * -2.562915447;
- ; tmp6 = tmp5 * -2.562915447 + tmp6 * (3.072711026 - 2.562915447);
- ; tmp7 = tmp4 * -0.899976223 + tmp7 * (1.501321110 - 0.899976223);
- ; data7 = tmp4 + z3; data5 = tmp5 + z4;
- ; data3 = tmp6 + z3; data1 = tmp7 + z4;
-
- vperm2i128 %4, %5, %5, 0x01 ; %4=tmp7_6
- vpunpcklwd %2, %8, %4
- vpunpckhwd %4, %8, %4
- vpmaddwd %2, %2, [GOTOFF(ebx, PW_MF060_MF089_MF050_MF256)] ; %2=tmp4_5L
- vpmaddwd %4, %4, [GOTOFF(ebx, PW_MF060_MF089_MF050_MF256)] ; %4=tmp4_5H
-
- vpaddd %2, %2, %6 ; %2=data7_5L
- vpaddd %4, %4, %7 ; %4=data7_5H
-
- vpaddd %2, %2, [GOTOFF(ebx, PD_DESCALE_P %+ %9)]
- vpaddd %4, %4, [GOTOFF(ebx, PD_DESCALE_P %+ %9)]
- vpsrad %2, %2, DESCALE_P %+ %9
- vpsrad %4, %4, DESCALE_P %+ %9
-
- vpackssdw %4, %2, %4 ; %4=data7_5
-
- vperm2i128 %2, %8, %8, 0x01 ; %2=tmp5_4
- vpunpcklwd %8, %5, %2
- vpunpckhwd %5, %5, %2
- vpmaddwd %8, %8, [GOTOFF(ebx, PW_F050_MF256_F060_MF089)] ; %8=tmp6_7L
- vpmaddwd %5, %5, [GOTOFF(ebx, PW_F050_MF256_F060_MF089)] ; %5=tmp6_7H
-
- vpaddd %8, %8, %6 ; %8=data3_1L
- vpaddd %5, %5, %7 ; %5=data3_1H
-
- vpaddd %8, %8, [GOTOFF(ebx, PD_DESCALE_P %+ %9)]
- vpaddd %5, %5, [GOTOFF(ebx, PD_DESCALE_P %+ %9)]
- vpsrad %8, %8, DESCALE_P %+ %9
- vpsrad %5, %5, DESCALE_P %+ %9
-
- vpackssdw %2, %8, %5 ; %2=data3_1
-%endmacro
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_fdct_islow_avx2)
-
-EXTN(jconst_fdct_islow_avx2):
-
-PW_F130_F054_MF130_F054 times 4 dw (F_0_541 + F_0_765), F_0_541
- times 4 dw (F_0_541 - F_1_847), F_0_541
-PW_MF078_F117_F078_F117 times 4 dw (F_1_175 - F_1_961), F_1_175
- times 4 dw (F_1_175 - F_0_390), F_1_175
-PW_MF060_MF089_MF050_MF256 times 4 dw (F_0_298 - F_0_899), -F_0_899
- times 4 dw (F_2_053 - F_2_562), -F_2_562
-PW_F050_MF256_F060_MF089 times 4 dw (F_3_072 - F_2_562), -F_2_562
- times 4 dw (F_1_501 - F_0_899), -F_0_899
-PD_DESCALE_P1 times 8 dd 1 << (DESCALE_P1 - 1)
-PD_DESCALE_P2 times 8 dd 1 << (DESCALE_P2 - 1)
-PW_DESCALE_P2X times 16 dw 1 << (PASS1_BITS - 1)
-PW_1_NEG1 times 8 dw 1
- times 8 dw -1
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-;
-; Perform the forward DCT on one block of samples.
-;
-; GLOBAL(void)
-; jsimd_fdct_islow_avx2(DCTELEM *data)
-;
-
-%define data(b) (b) + 8 ; DCTELEM *data
-
- align 32
- GLOBAL_FUNCTION(jsimd_fdct_islow_avx2)
-
-EXTN(jsimd_fdct_islow_avx2):
- push ebp
- mov ebp, esp
- pushpic ebx
-; push ecx ; unused
-; push edx ; need not be preserved
-; push esi ; unused
-; push edi ; unused
-
- get_GOT ebx ; get GOT address
-
- ; ---- Pass 1: process rows.
-
- mov edx, POINTER [data(ebp)] ; (DCTELEM *)
-
- vmovdqu ymm4, YMMWORD [YMMBLOCK(0,0,edx,SIZEOF_DCTELEM)]
- vmovdqu ymm5, YMMWORD [YMMBLOCK(2,0,edx,SIZEOF_DCTELEM)]
- vmovdqu ymm6, YMMWORD [YMMBLOCK(4,0,edx,SIZEOF_DCTELEM)]
- vmovdqu ymm7, YMMWORD [YMMBLOCK(6,0,edx,SIZEOF_DCTELEM)]
- ; ymm4=(00 01 02 03 04 05 06 07 10 11 12 13 14 15 16 17)
- ; ymm5=(20 21 22 23 24 25 26 27 30 31 32 33 34 35 36 37)
- ; ymm6=(40 41 42 43 44 45 46 47 50 51 52 53 54 55 56 57)
- ; ymm7=(60 61 62 63 64 65 66 67 70 71 72 73 74 75 76 77)
-
- vperm2i128 ymm0, ymm4, ymm6, 0x20
- vperm2i128 ymm1, ymm4, ymm6, 0x31
- vperm2i128 ymm2, ymm5, ymm7, 0x20
- vperm2i128 ymm3, ymm5, ymm7, 0x31
- ; ymm0=(00 01 02 03 04 05 06 07 40 41 42 43 44 45 46 47)
- ; ymm1=(10 11 12 13 14 15 16 17 50 51 52 53 54 55 56 57)
- ; ymm2=(20 21 22 23 24 25 26 27 60 61 62 63 64 65 66 67)
- ; ymm3=(30 31 32 33 34 35 36 37 70 71 72 73 74 75 76 77)
-
- dotranspose ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7
-
- dodct ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7, 1
- ; ymm0=data0_4, ymm1=data3_1, ymm2=data2_6, ymm3=data7_5
-
- ; ---- Pass 2: process columns.
-
- vperm2i128 ymm4, ymm1, ymm3, 0x20 ; ymm4=data3_7
- vperm2i128 ymm1, ymm1, ymm3, 0x31 ; ymm1=data1_5
-
- dotranspose ymm0, ymm1, ymm2, ymm4, ymm3, ymm5, ymm6, ymm7
-
- dodct ymm0, ymm1, ymm2, ymm4, ymm3, ymm5, ymm6, ymm7, 2
- ; ymm0=data0_4, ymm1=data3_1, ymm2=data2_6, ymm4=data7_5
-
- vperm2i128 ymm3, ymm0, ymm1, 0x30 ; ymm3=data0_1
- vperm2i128 ymm5, ymm2, ymm1, 0x20 ; ymm5=data2_3
- vperm2i128 ymm6, ymm0, ymm4, 0x31 ; ymm6=data4_5
- vperm2i128 ymm7, ymm2, ymm4, 0x21 ; ymm7=data6_7
-
- vmovdqu YMMWORD [YMMBLOCK(0,0,edx,SIZEOF_DCTELEM)], ymm3
- vmovdqu YMMWORD [YMMBLOCK(2,0,edx,SIZEOF_DCTELEM)], ymm5
- vmovdqu YMMWORD [YMMBLOCK(4,0,edx,SIZEOF_DCTELEM)], ymm6
- vmovdqu YMMWORD [YMMBLOCK(6,0,edx,SIZEOF_DCTELEM)], ymm7
-
- vzeroupper
-; pop edi ; unused
-; pop esi ; unused
-; pop edx ; need not be preserved
-; pop ecx ; unused
- poppic ebx
- pop ebp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jfdctint-mmx.asm b/contrib/libs/libjpeg-turbo/simd/i386/jfdctint-mmx.asm
deleted file mode 100644
index 34a43b9e5e..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jfdctint-mmx.asm
+++ /dev/null
@@ -1,620 +0,0 @@
-;
-; jfdctint.asm - accurate integer FDCT (MMX)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2016, 2020, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-;
-; This file contains a slower but more accurate integer implementation of the
-; forward DCT (Discrete Cosine Transform). The following code is based
-; directly on the IJG's original jfdctint.c; see the jfdctint.c for
-; more details.
-
-%include "jsimdext.inc"
-%include "jdct.inc"
-
-; --------------------------------------------------------------------------
-
-%define CONST_BITS 13
-%define PASS1_BITS 2
-
-%define DESCALE_P1 (CONST_BITS - PASS1_BITS)
-%define DESCALE_P2 (CONST_BITS + PASS1_BITS)
-
-%if CONST_BITS == 13
-F_0_298 equ 2446 ; FIX(0.298631336)
-F_0_390 equ 3196 ; FIX(0.390180644)
-F_0_541 equ 4433 ; FIX(0.541196100)
-F_0_765 equ 6270 ; FIX(0.765366865)
-F_0_899 equ 7373 ; FIX(0.899976223)
-F_1_175 equ 9633 ; FIX(1.175875602)
-F_1_501 equ 12299 ; FIX(1.501321110)
-F_1_847 equ 15137 ; FIX(1.847759065)
-F_1_961 equ 16069 ; FIX(1.961570560)
-F_2_053 equ 16819 ; FIX(2.053119869)
-F_2_562 equ 20995 ; FIX(2.562915447)
-F_3_072 equ 25172 ; FIX(3.072711026)
-%else
-; NASM cannot do compile-time arithmetic on floating-point constants.
-%define DESCALE(x, n) (((x) + (1 << ((n) - 1))) >> (n))
-F_0_298 equ DESCALE( 320652955, 30 - CONST_BITS) ; FIX(0.298631336)
-F_0_390 equ DESCALE( 418953276, 30 - CONST_BITS) ; FIX(0.390180644)
-F_0_541 equ DESCALE( 581104887, 30 - CONST_BITS) ; FIX(0.541196100)
-F_0_765 equ DESCALE( 821806413, 30 - CONST_BITS) ; FIX(0.765366865)
-F_0_899 equ DESCALE( 966342111, 30 - CONST_BITS) ; FIX(0.899976223)
-F_1_175 equ DESCALE(1262586813, 30 - CONST_BITS) ; FIX(1.175875602)
-F_1_501 equ DESCALE(1612031267, 30 - CONST_BITS) ; FIX(1.501321110)
-F_1_847 equ DESCALE(1984016188, 30 - CONST_BITS) ; FIX(1.847759065)
-F_1_961 equ DESCALE(2106220350, 30 - CONST_BITS) ; FIX(1.961570560)
-F_2_053 equ DESCALE(2204520673, 30 - CONST_BITS) ; FIX(2.053119869)
-F_2_562 equ DESCALE(2751909506, 30 - CONST_BITS) ; FIX(2.562915447)
-F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
-%endif
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_fdct_islow_mmx)
-
-EXTN(jconst_fdct_islow_mmx):
-
-PW_F130_F054 times 2 dw (F_0_541 + F_0_765), F_0_541
-PW_F054_MF130 times 2 dw F_0_541, (F_0_541 - F_1_847)
-PW_MF078_F117 times 2 dw (F_1_175 - F_1_961), F_1_175
-PW_F117_F078 times 2 dw F_1_175, (F_1_175 - F_0_390)
-PW_MF060_MF089 times 2 dw (F_0_298 - F_0_899), -F_0_899
-PW_MF089_F060 times 2 dw -F_0_899, (F_1_501 - F_0_899)
-PW_MF050_MF256 times 2 dw (F_2_053 - F_2_562), -F_2_562
-PW_MF256_F050 times 2 dw -F_2_562, (F_3_072 - F_2_562)
-PD_DESCALE_P1 times 2 dd 1 << (DESCALE_P1 - 1)
-PD_DESCALE_P2 times 2 dd 1 << (DESCALE_P2 - 1)
-PW_DESCALE_P2X times 4 dw 1 << (PASS1_BITS - 1)
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-;
-; Perform the forward DCT on one block of samples.
-;
-; GLOBAL(void)
-; jsimd_fdct_islow_mmx(DCTELEM *data)
-;
-
-%define data(b) (b) + 8 ; DCTELEM *data
-
-%define original_ebp ebp + 0
-%define wk(i) ebp - (WK_NUM - (i)) * SIZEOF_MMWORD ; mmword wk[WK_NUM]
-%define WK_NUM 2
-
- align 32
- GLOBAL_FUNCTION(jsimd_fdct_islow_mmx)
-
-EXTN(jsimd_fdct_islow_mmx):
- push ebp
- mov eax, esp ; eax = original ebp
- sub esp, byte 4
- and esp, byte (-SIZEOF_MMWORD) ; align to 64 bits
- mov [esp], eax
- mov ebp, esp ; ebp = aligned ebp
- lea esp, [wk(0)]
- pushpic ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
-; push esi ; unused
-; push edi ; unused
-
- get_GOT ebx ; get GOT address
-
- ; ---- Pass 1: process rows.
-
- mov edx, POINTER [data(eax)] ; (DCTELEM *)
- mov ecx, DCTSIZE/4
- alignx 16, 7
-.rowloop:
-
- movq mm0, MMWORD [MMBLOCK(2,0,edx,SIZEOF_DCTELEM)]
- movq mm1, MMWORD [MMBLOCK(3,0,edx,SIZEOF_DCTELEM)]
- movq mm2, MMWORD [MMBLOCK(2,1,edx,SIZEOF_DCTELEM)]
- movq mm3, MMWORD [MMBLOCK(3,1,edx,SIZEOF_DCTELEM)]
-
- ; mm0=(20 21 22 23), mm2=(24 25 26 27)
- ; mm1=(30 31 32 33), mm3=(34 35 36 37)
-
- movq mm4, mm0 ; transpose coefficients(phase 1)
- punpcklwd mm0, mm1 ; mm0=(20 30 21 31)
- punpckhwd mm4, mm1 ; mm4=(22 32 23 33)
- movq mm5, mm2 ; transpose coefficients(phase 1)
- punpcklwd mm2, mm3 ; mm2=(24 34 25 35)
- punpckhwd mm5, mm3 ; mm5=(26 36 27 37)
-
- movq mm6, MMWORD [MMBLOCK(0,0,edx,SIZEOF_DCTELEM)]
- movq mm7, MMWORD [MMBLOCK(1,0,edx,SIZEOF_DCTELEM)]
- movq mm1, MMWORD [MMBLOCK(0,1,edx,SIZEOF_DCTELEM)]
- movq mm3, MMWORD [MMBLOCK(1,1,edx,SIZEOF_DCTELEM)]
-
- ; mm6=(00 01 02 03), mm1=(04 05 06 07)
- ; mm7=(10 11 12 13), mm3=(14 15 16 17)
-
- movq MMWORD [wk(0)], mm4 ; wk(0)=(22 32 23 33)
- movq MMWORD [wk(1)], mm2 ; wk(1)=(24 34 25 35)
-
- movq mm4, mm6 ; transpose coefficients(phase 1)
- punpcklwd mm6, mm7 ; mm6=(00 10 01 11)
- punpckhwd mm4, mm7 ; mm4=(02 12 03 13)
- movq mm2, mm1 ; transpose coefficients(phase 1)
- punpcklwd mm1, mm3 ; mm1=(04 14 05 15)
- punpckhwd mm2, mm3 ; mm2=(06 16 07 17)
-
- movq mm7, mm6 ; transpose coefficients(phase 2)
- punpckldq mm6, mm0 ; mm6=(00 10 20 30)=data0
- punpckhdq mm7, mm0 ; mm7=(01 11 21 31)=data1
- movq mm3, mm2 ; transpose coefficients(phase 2)
- punpckldq mm2, mm5 ; mm2=(06 16 26 36)=data6
- punpckhdq mm3, mm5 ; mm3=(07 17 27 37)=data7
-
- movq mm0, mm7
- movq mm5, mm6
- psubw mm7, mm2 ; mm7=data1-data6=tmp6
- psubw mm6, mm3 ; mm6=data0-data7=tmp7
- paddw mm0, mm2 ; mm0=data1+data6=tmp1
- paddw mm5, mm3 ; mm5=data0+data7=tmp0
-
- movq mm2, MMWORD [wk(0)] ; mm2=(22 32 23 33)
- movq mm3, MMWORD [wk(1)] ; mm3=(24 34 25 35)
- movq MMWORD [wk(0)], mm7 ; wk(0)=tmp6
- movq MMWORD [wk(1)], mm6 ; wk(1)=tmp7
-
- movq mm7, mm4 ; transpose coefficients(phase 2)
- punpckldq mm4, mm2 ; mm4=(02 12 22 32)=data2
- punpckhdq mm7, mm2 ; mm7=(03 13 23 33)=data3
- movq mm6, mm1 ; transpose coefficients(phase 2)
- punpckldq mm1, mm3 ; mm1=(04 14 24 34)=data4
- punpckhdq mm6, mm3 ; mm6=(05 15 25 35)=data5
-
- movq mm2, mm7
- movq mm3, mm4
- paddw mm7, mm1 ; mm7=data3+data4=tmp3
- paddw mm4, mm6 ; mm4=data2+data5=tmp2
- psubw mm2, mm1 ; mm2=data3-data4=tmp4
- psubw mm3, mm6 ; mm3=data2-data5=tmp5
-
- ; -- Even part
-
- movq mm1, mm5
- movq mm6, mm0
- paddw mm5, mm7 ; mm5=tmp10
- paddw mm0, mm4 ; mm0=tmp11
- psubw mm1, mm7 ; mm1=tmp13
- psubw mm6, mm4 ; mm6=tmp12
-
- movq mm7, mm5
- paddw mm5, mm0 ; mm5=tmp10+tmp11
- psubw mm7, mm0 ; mm7=tmp10-tmp11
-
- psllw mm5, PASS1_BITS ; mm5=data0
- psllw mm7, PASS1_BITS ; mm7=data4
-
- movq MMWORD [MMBLOCK(0,0,edx,SIZEOF_DCTELEM)], mm5
- movq MMWORD [MMBLOCK(0,1,edx,SIZEOF_DCTELEM)], mm7
-
- ; (Original)
- ; z1 = (tmp12 + tmp13) * 0.541196100;
- ; data2 = z1 + tmp13 * 0.765366865;
- ; data6 = z1 + tmp12 * -1.847759065;
- ;
- ; (This implementation)
- ; data2 = tmp13 * (0.541196100 + 0.765366865) + tmp12 * 0.541196100;
- ; data6 = tmp13 * 0.541196100 + tmp12 * (0.541196100 - 1.847759065);
-
- movq mm4, mm1 ; mm1=tmp13
- movq mm0, mm1
- punpcklwd mm4, mm6 ; mm6=tmp12
- punpckhwd mm0, mm6
- movq mm1, mm4
- movq mm6, mm0
- pmaddwd mm4, [GOTOFF(ebx,PW_F130_F054)] ; mm4=data2L
- pmaddwd mm0, [GOTOFF(ebx,PW_F130_F054)] ; mm0=data2H
- pmaddwd mm1, [GOTOFF(ebx,PW_F054_MF130)] ; mm1=data6L
- pmaddwd mm6, [GOTOFF(ebx,PW_F054_MF130)] ; mm6=data6H
-
- paddd mm4, [GOTOFF(ebx,PD_DESCALE_P1)]
- paddd mm0, [GOTOFF(ebx,PD_DESCALE_P1)]
- psrad mm4, DESCALE_P1
- psrad mm0, DESCALE_P1
- paddd mm1, [GOTOFF(ebx,PD_DESCALE_P1)]
- paddd mm6, [GOTOFF(ebx,PD_DESCALE_P1)]
- psrad mm1, DESCALE_P1
- psrad mm6, DESCALE_P1
-
- packssdw mm4, mm0 ; mm4=data2
- packssdw mm1, mm6 ; mm1=data6
-
- movq MMWORD [MMBLOCK(2,0,edx,SIZEOF_DCTELEM)], mm4
- movq MMWORD [MMBLOCK(2,1,edx,SIZEOF_DCTELEM)], mm1
-
- ; -- Odd part
-
- movq mm5, MMWORD [wk(0)] ; mm5=tmp6
- movq mm7, MMWORD [wk(1)] ; mm7=tmp7
-
- movq mm0, mm2 ; mm2=tmp4
- movq mm6, mm3 ; mm3=tmp5
- paddw mm0, mm5 ; mm0=z3
- paddw mm6, mm7 ; mm6=z4
-
- ; (Original)
- ; z5 = (z3 + z4) * 1.175875602;
- ; z3 = z3 * -1.961570560; z4 = z4 * -0.390180644;
- ; z3 += z5; z4 += z5;
- ;
- ; (This implementation)
- ; z3 = z3 * (1.175875602 - 1.961570560) + z4 * 1.175875602;
- ; z4 = z3 * 1.175875602 + z4 * (1.175875602 - 0.390180644);
-
- movq mm4, mm0
- movq mm1, mm0
- punpcklwd mm4, mm6
- punpckhwd mm1, mm6
- movq mm0, mm4
- movq mm6, mm1
- pmaddwd mm4, [GOTOFF(ebx,PW_MF078_F117)] ; mm4=z3L
- pmaddwd mm1, [GOTOFF(ebx,PW_MF078_F117)] ; mm1=z3H
- pmaddwd mm0, [GOTOFF(ebx,PW_F117_F078)] ; mm0=z4L
- pmaddwd mm6, [GOTOFF(ebx,PW_F117_F078)] ; mm6=z4H
-
- movq MMWORD [wk(0)], mm4 ; wk(0)=z3L
- movq MMWORD [wk(1)], mm1 ; wk(1)=z3H
-
- ; (Original)
- ; z1 = tmp4 + tmp7; z2 = tmp5 + tmp6;
- ; tmp4 = tmp4 * 0.298631336; tmp5 = tmp5 * 2.053119869;
- ; tmp6 = tmp6 * 3.072711026; tmp7 = tmp7 * 1.501321110;
- ; z1 = z1 * -0.899976223; z2 = z2 * -2.562915447;
- ; data7 = tmp4 + z1 + z3; data5 = tmp5 + z2 + z4;
- ; data3 = tmp6 + z2 + z3; data1 = tmp7 + z1 + z4;
- ;
- ; (This implementation)
- ; tmp4 = tmp4 * (0.298631336 - 0.899976223) + tmp7 * -0.899976223;
- ; tmp5 = tmp5 * (2.053119869 - 2.562915447) + tmp6 * -2.562915447;
- ; tmp6 = tmp5 * -2.562915447 + tmp6 * (3.072711026 - 2.562915447);
- ; tmp7 = tmp4 * -0.899976223 + tmp7 * (1.501321110 - 0.899976223);
- ; data7 = tmp4 + z3; data5 = tmp5 + z4;
- ; data3 = tmp6 + z3; data1 = tmp7 + z4;
-
- movq mm4, mm2
- movq mm1, mm2
- punpcklwd mm4, mm7
- punpckhwd mm1, mm7
- movq mm2, mm4
- movq mm7, mm1
- pmaddwd mm4, [GOTOFF(ebx,PW_MF060_MF089)] ; mm4=tmp4L
- pmaddwd mm1, [GOTOFF(ebx,PW_MF060_MF089)] ; mm1=tmp4H
- pmaddwd mm2, [GOTOFF(ebx,PW_MF089_F060)] ; mm2=tmp7L
- pmaddwd mm7, [GOTOFF(ebx,PW_MF089_F060)] ; mm7=tmp7H
-
- paddd mm4, MMWORD [wk(0)] ; mm4=data7L
- paddd mm1, MMWORD [wk(1)] ; mm1=data7H
- paddd mm2, mm0 ; mm2=data1L
- paddd mm7, mm6 ; mm7=data1H
-
- paddd mm4, [GOTOFF(ebx,PD_DESCALE_P1)]
- paddd mm1, [GOTOFF(ebx,PD_DESCALE_P1)]
- psrad mm4, DESCALE_P1
- psrad mm1, DESCALE_P1
- paddd mm2, [GOTOFF(ebx,PD_DESCALE_P1)]
- paddd mm7, [GOTOFF(ebx,PD_DESCALE_P1)]
- psrad mm2, DESCALE_P1
- psrad mm7, DESCALE_P1
-
- packssdw mm4, mm1 ; mm4=data7
- packssdw mm2, mm7 ; mm2=data1
-
- movq MMWORD [MMBLOCK(3,1,edx,SIZEOF_DCTELEM)], mm4
- movq MMWORD [MMBLOCK(1,0,edx,SIZEOF_DCTELEM)], mm2
-
- movq mm1, mm3
- movq mm7, mm3
- punpcklwd mm1, mm5
- punpckhwd mm7, mm5
- movq mm3, mm1
- movq mm5, mm7
- pmaddwd mm1, [GOTOFF(ebx,PW_MF050_MF256)] ; mm1=tmp5L
- pmaddwd mm7, [GOTOFF(ebx,PW_MF050_MF256)] ; mm7=tmp5H
- pmaddwd mm3, [GOTOFF(ebx,PW_MF256_F050)] ; mm3=tmp6L
- pmaddwd mm5, [GOTOFF(ebx,PW_MF256_F050)] ; mm5=tmp6H
-
- paddd mm1, mm0 ; mm1=data5L
- paddd mm7, mm6 ; mm7=data5H
- paddd mm3, MMWORD [wk(0)] ; mm3=data3L
- paddd mm5, MMWORD [wk(1)] ; mm5=data3H
-
- paddd mm1, [GOTOFF(ebx,PD_DESCALE_P1)]
- paddd mm7, [GOTOFF(ebx,PD_DESCALE_P1)]
- psrad mm1, DESCALE_P1
- psrad mm7, DESCALE_P1
- paddd mm3, [GOTOFF(ebx,PD_DESCALE_P1)]
- paddd mm5, [GOTOFF(ebx,PD_DESCALE_P1)]
- psrad mm3, DESCALE_P1
- psrad mm5, DESCALE_P1
-
- packssdw mm1, mm7 ; mm1=data5
- packssdw mm3, mm5 ; mm3=data3
-
- movq MMWORD [MMBLOCK(1,1,edx,SIZEOF_DCTELEM)], mm1
- movq MMWORD [MMBLOCK(3,0,edx,SIZEOF_DCTELEM)], mm3
-
- add edx, byte 4*DCTSIZE*SIZEOF_DCTELEM
- dec ecx
- jnz near .rowloop
-
- ; ---- Pass 2: process columns.
-
- mov edx, POINTER [data(eax)] ; (DCTELEM *)
- mov ecx, DCTSIZE/4
- alignx 16, 7
-.columnloop:
-
- movq mm0, MMWORD [MMBLOCK(2,0,edx,SIZEOF_DCTELEM)]
- movq mm1, MMWORD [MMBLOCK(3,0,edx,SIZEOF_DCTELEM)]
- movq mm2, MMWORD [MMBLOCK(6,0,edx,SIZEOF_DCTELEM)]
- movq mm3, MMWORD [MMBLOCK(7,0,edx,SIZEOF_DCTELEM)]
-
- ; mm0=(02 12 22 32), mm2=(42 52 62 72)
- ; mm1=(03 13 23 33), mm3=(43 53 63 73)
-
- movq mm4, mm0 ; transpose coefficients(phase 1)
- punpcklwd mm0, mm1 ; mm0=(02 03 12 13)
- punpckhwd mm4, mm1 ; mm4=(22 23 32 33)
- movq mm5, mm2 ; transpose coefficients(phase 1)
- punpcklwd mm2, mm3 ; mm2=(42 43 52 53)
- punpckhwd mm5, mm3 ; mm5=(62 63 72 73)
-
- movq mm6, MMWORD [MMBLOCK(0,0,edx,SIZEOF_DCTELEM)]
- movq mm7, MMWORD [MMBLOCK(1,0,edx,SIZEOF_DCTELEM)]
- movq mm1, MMWORD [MMBLOCK(4,0,edx,SIZEOF_DCTELEM)]
- movq mm3, MMWORD [MMBLOCK(5,0,edx,SIZEOF_DCTELEM)]
-
- ; mm6=(00 10 20 30), mm1=(40 50 60 70)
- ; mm7=(01 11 21 31), mm3=(41 51 61 71)
-
- movq MMWORD [wk(0)], mm4 ; wk(0)=(22 23 32 33)
- movq MMWORD [wk(1)], mm2 ; wk(1)=(42 43 52 53)
-
- movq mm4, mm6 ; transpose coefficients(phase 1)
- punpcklwd mm6, mm7 ; mm6=(00 01 10 11)
- punpckhwd mm4, mm7 ; mm4=(20 21 30 31)
- movq mm2, mm1 ; transpose coefficients(phase 1)
- punpcklwd mm1, mm3 ; mm1=(40 41 50 51)
- punpckhwd mm2, mm3 ; mm2=(60 61 70 71)
-
- movq mm7, mm6 ; transpose coefficients(phase 2)
- punpckldq mm6, mm0 ; mm6=(00 01 02 03)=data0
- punpckhdq mm7, mm0 ; mm7=(10 11 12 13)=data1
- movq mm3, mm2 ; transpose coefficients(phase 2)
- punpckldq mm2, mm5 ; mm2=(60 61 62 63)=data6
- punpckhdq mm3, mm5 ; mm3=(70 71 72 73)=data7
-
- movq mm0, mm7
- movq mm5, mm6
- psubw mm7, mm2 ; mm7=data1-data6=tmp6
- psubw mm6, mm3 ; mm6=data0-data7=tmp7
- paddw mm0, mm2 ; mm0=data1+data6=tmp1
- paddw mm5, mm3 ; mm5=data0+data7=tmp0
-
- movq mm2, MMWORD [wk(0)] ; mm2=(22 23 32 33)
- movq mm3, MMWORD [wk(1)] ; mm3=(42 43 52 53)
- movq MMWORD [wk(0)], mm7 ; wk(0)=tmp6
- movq MMWORD [wk(1)], mm6 ; wk(1)=tmp7
-
- movq mm7, mm4 ; transpose coefficients(phase 2)
- punpckldq mm4, mm2 ; mm4=(20 21 22 23)=data2
- punpckhdq mm7, mm2 ; mm7=(30 31 32 33)=data3
- movq mm6, mm1 ; transpose coefficients(phase 2)
- punpckldq mm1, mm3 ; mm1=(40 41 42 43)=data4
- punpckhdq mm6, mm3 ; mm6=(50 51 52 53)=data5
-
- movq mm2, mm7
- movq mm3, mm4
- paddw mm7, mm1 ; mm7=data3+data4=tmp3
- paddw mm4, mm6 ; mm4=data2+data5=tmp2
- psubw mm2, mm1 ; mm2=data3-data4=tmp4
- psubw mm3, mm6 ; mm3=data2-data5=tmp5
-
- ; -- Even part
-
- movq mm1, mm5
- movq mm6, mm0
- paddw mm5, mm7 ; mm5=tmp10
- paddw mm0, mm4 ; mm0=tmp11
- psubw mm1, mm7 ; mm1=tmp13
- psubw mm6, mm4 ; mm6=tmp12
-
- movq mm7, mm5
- paddw mm5, mm0 ; mm5=tmp10+tmp11
- psubw mm7, mm0 ; mm7=tmp10-tmp11
-
- paddw mm5, [GOTOFF(ebx,PW_DESCALE_P2X)]
- paddw mm7, [GOTOFF(ebx,PW_DESCALE_P2X)]
- psraw mm5, PASS1_BITS ; mm5=data0
- psraw mm7, PASS1_BITS ; mm7=data4
-
- movq MMWORD [MMBLOCK(0,0,edx,SIZEOF_DCTELEM)], mm5
- movq MMWORD [MMBLOCK(4,0,edx,SIZEOF_DCTELEM)], mm7
-
- ; (Original)
- ; z1 = (tmp12 + tmp13) * 0.541196100;
- ; data2 = z1 + tmp13 * 0.765366865;
- ; data6 = z1 + tmp12 * -1.847759065;
- ;
- ; (This implementation)
- ; data2 = tmp13 * (0.541196100 + 0.765366865) + tmp12 * 0.541196100;
- ; data6 = tmp13 * 0.541196100 + tmp12 * (0.541196100 - 1.847759065);
-
- movq mm4, mm1 ; mm1=tmp13
- movq mm0, mm1
- punpcklwd mm4, mm6 ; mm6=tmp12
- punpckhwd mm0, mm6
- movq mm1, mm4
- movq mm6, mm0
- pmaddwd mm4, [GOTOFF(ebx,PW_F130_F054)] ; mm4=data2L
- pmaddwd mm0, [GOTOFF(ebx,PW_F130_F054)] ; mm0=data2H
- pmaddwd mm1, [GOTOFF(ebx,PW_F054_MF130)] ; mm1=data6L
- pmaddwd mm6, [GOTOFF(ebx,PW_F054_MF130)] ; mm6=data6H
-
- paddd mm4, [GOTOFF(ebx,PD_DESCALE_P2)]
- paddd mm0, [GOTOFF(ebx,PD_DESCALE_P2)]
- psrad mm4, DESCALE_P2
- psrad mm0, DESCALE_P2
- paddd mm1, [GOTOFF(ebx,PD_DESCALE_P2)]
- paddd mm6, [GOTOFF(ebx,PD_DESCALE_P2)]
- psrad mm1, DESCALE_P2
- psrad mm6, DESCALE_P2
-
- packssdw mm4, mm0 ; mm4=data2
- packssdw mm1, mm6 ; mm1=data6
-
- movq MMWORD [MMBLOCK(2,0,edx,SIZEOF_DCTELEM)], mm4
- movq MMWORD [MMBLOCK(6,0,edx,SIZEOF_DCTELEM)], mm1
-
- ; -- Odd part
-
- movq mm5, MMWORD [wk(0)] ; mm5=tmp6
- movq mm7, MMWORD [wk(1)] ; mm7=tmp7
-
- movq mm0, mm2 ; mm2=tmp4
- movq mm6, mm3 ; mm3=tmp5
- paddw mm0, mm5 ; mm0=z3
- paddw mm6, mm7 ; mm6=z4
-
- ; (Original)
- ; z5 = (z3 + z4) * 1.175875602;
- ; z3 = z3 * -1.961570560; z4 = z4 * -0.390180644;
- ; z3 += z5; z4 += z5;
- ;
- ; (This implementation)
- ; z3 = z3 * (1.175875602 - 1.961570560) + z4 * 1.175875602;
- ; z4 = z3 * 1.175875602 + z4 * (1.175875602 - 0.390180644);
-
- movq mm4, mm0
- movq mm1, mm0
- punpcklwd mm4, mm6
- punpckhwd mm1, mm6
- movq mm0, mm4
- movq mm6, mm1
- pmaddwd mm4, [GOTOFF(ebx,PW_MF078_F117)] ; mm4=z3L
- pmaddwd mm1, [GOTOFF(ebx,PW_MF078_F117)] ; mm1=z3H
- pmaddwd mm0, [GOTOFF(ebx,PW_F117_F078)] ; mm0=z4L
- pmaddwd mm6, [GOTOFF(ebx,PW_F117_F078)] ; mm6=z4H
-
- movq MMWORD [wk(0)], mm4 ; wk(0)=z3L
- movq MMWORD [wk(1)], mm1 ; wk(1)=z3H
-
- ; (Original)
- ; z1 = tmp4 + tmp7; z2 = tmp5 + tmp6;
- ; tmp4 = tmp4 * 0.298631336; tmp5 = tmp5 * 2.053119869;
- ; tmp6 = tmp6 * 3.072711026; tmp7 = tmp7 * 1.501321110;
- ; z1 = z1 * -0.899976223; z2 = z2 * -2.562915447;
- ; data7 = tmp4 + z1 + z3; data5 = tmp5 + z2 + z4;
- ; data3 = tmp6 + z2 + z3; data1 = tmp7 + z1 + z4;
- ;
- ; (This implementation)
- ; tmp4 = tmp4 * (0.298631336 - 0.899976223) + tmp7 * -0.899976223;
- ; tmp5 = tmp5 * (2.053119869 - 2.562915447) + tmp6 * -2.562915447;
- ; tmp6 = tmp5 * -2.562915447 + tmp6 * (3.072711026 - 2.562915447);
- ; tmp7 = tmp4 * -0.899976223 + tmp7 * (1.501321110 - 0.899976223);
- ; data7 = tmp4 + z3; data5 = tmp5 + z4;
- ; data3 = tmp6 + z3; data1 = tmp7 + z4;
-
- movq mm4, mm2
- movq mm1, mm2
- punpcklwd mm4, mm7
- punpckhwd mm1, mm7
- movq mm2, mm4
- movq mm7, mm1
- pmaddwd mm4, [GOTOFF(ebx,PW_MF060_MF089)] ; mm4=tmp4L
- pmaddwd mm1, [GOTOFF(ebx,PW_MF060_MF089)] ; mm1=tmp4H
- pmaddwd mm2, [GOTOFF(ebx,PW_MF089_F060)] ; mm2=tmp7L
- pmaddwd mm7, [GOTOFF(ebx,PW_MF089_F060)] ; mm7=tmp7H
-
- paddd mm4, MMWORD [wk(0)] ; mm4=data7L
- paddd mm1, MMWORD [wk(1)] ; mm1=data7H
- paddd mm2, mm0 ; mm2=data1L
- paddd mm7, mm6 ; mm7=data1H
-
- paddd mm4, [GOTOFF(ebx,PD_DESCALE_P2)]
- paddd mm1, [GOTOFF(ebx,PD_DESCALE_P2)]
- psrad mm4, DESCALE_P2
- psrad mm1, DESCALE_P2
- paddd mm2, [GOTOFF(ebx,PD_DESCALE_P2)]
- paddd mm7, [GOTOFF(ebx,PD_DESCALE_P2)]
- psrad mm2, DESCALE_P2
- psrad mm7, DESCALE_P2
-
- packssdw mm4, mm1 ; mm4=data7
- packssdw mm2, mm7 ; mm2=data1
-
- movq MMWORD [MMBLOCK(7,0,edx,SIZEOF_DCTELEM)], mm4
- movq MMWORD [MMBLOCK(1,0,edx,SIZEOF_DCTELEM)], mm2
-
- movq mm1, mm3
- movq mm7, mm3
- punpcklwd mm1, mm5
- punpckhwd mm7, mm5
- movq mm3, mm1
- movq mm5, mm7
- pmaddwd mm1, [GOTOFF(ebx,PW_MF050_MF256)] ; mm1=tmp5L
- pmaddwd mm7, [GOTOFF(ebx,PW_MF050_MF256)] ; mm7=tmp5H
- pmaddwd mm3, [GOTOFF(ebx,PW_MF256_F050)] ; mm3=tmp6L
- pmaddwd mm5, [GOTOFF(ebx,PW_MF256_F050)] ; mm5=tmp6H
-
- paddd mm1, mm0 ; mm1=data5L
- paddd mm7, mm6 ; mm7=data5H
- paddd mm3, MMWORD [wk(0)] ; mm3=data3L
- paddd mm5, MMWORD [wk(1)] ; mm5=data3H
-
- paddd mm1, [GOTOFF(ebx,PD_DESCALE_P2)]
- paddd mm7, [GOTOFF(ebx,PD_DESCALE_P2)]
- psrad mm1, DESCALE_P2
- psrad mm7, DESCALE_P2
- paddd mm3, [GOTOFF(ebx,PD_DESCALE_P2)]
- paddd mm5, [GOTOFF(ebx,PD_DESCALE_P2)]
- psrad mm3, DESCALE_P2
- psrad mm5, DESCALE_P2
-
- packssdw mm1, mm7 ; mm1=data5
- packssdw mm3, mm5 ; mm3=data3
-
- movq MMWORD [MMBLOCK(5,0,edx,SIZEOF_DCTELEM)], mm1
- movq MMWORD [MMBLOCK(3,0,edx,SIZEOF_DCTELEM)], mm3
-
- add edx, byte 4*SIZEOF_DCTELEM
- dec ecx
- jnz near .columnloop
-
- emms ; empty MMX state
-
-; pop edi ; unused
-; pop esi ; unused
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- poppic ebx
- mov esp, ebp ; esp <- aligned ebp
- pop esp ; esp <- original ebp
- pop ebp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jfdctint-sse2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jfdctint-sse2.asm
deleted file mode 100644
index 6f8e18cb9d..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jfdctint-sse2.asm
+++ /dev/null
@@ -1,633 +0,0 @@
-;
-; jfdctint.asm - accurate integer FDCT (SSE2)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2016, 2020, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-;
-; This file contains a slower but more accurate integer implementation of the
-; forward DCT (Discrete Cosine Transform). The following code is based
-; directly on the IJG's original jfdctint.c; see the jfdctint.c for
-; more details.
-
-%include "jsimdext.inc"
-%include "jdct.inc"
-
-; --------------------------------------------------------------------------
-
-%define CONST_BITS 13
-%define PASS1_BITS 2
-
-%define DESCALE_P1 (CONST_BITS - PASS1_BITS)
-%define DESCALE_P2 (CONST_BITS + PASS1_BITS)
-
-%if CONST_BITS == 13
-F_0_298 equ 2446 ; FIX(0.298631336)
-F_0_390 equ 3196 ; FIX(0.390180644)
-F_0_541 equ 4433 ; FIX(0.541196100)
-F_0_765 equ 6270 ; FIX(0.765366865)
-F_0_899 equ 7373 ; FIX(0.899976223)
-F_1_175 equ 9633 ; FIX(1.175875602)
-F_1_501 equ 12299 ; FIX(1.501321110)
-F_1_847 equ 15137 ; FIX(1.847759065)
-F_1_961 equ 16069 ; FIX(1.961570560)
-F_2_053 equ 16819 ; FIX(2.053119869)
-F_2_562 equ 20995 ; FIX(2.562915447)
-F_3_072 equ 25172 ; FIX(3.072711026)
-%else
-; NASM cannot do compile-time arithmetic on floating-point constants.
-%define DESCALE(x, n) (((x) + (1 << ((n) - 1))) >> (n))
-F_0_298 equ DESCALE( 320652955, 30 - CONST_BITS) ; FIX(0.298631336)
-F_0_390 equ DESCALE( 418953276, 30 - CONST_BITS) ; FIX(0.390180644)
-F_0_541 equ DESCALE( 581104887, 30 - CONST_BITS) ; FIX(0.541196100)
-F_0_765 equ DESCALE( 821806413, 30 - CONST_BITS) ; FIX(0.765366865)
-F_0_899 equ DESCALE( 966342111, 30 - CONST_BITS) ; FIX(0.899976223)
-F_1_175 equ DESCALE(1262586813, 30 - CONST_BITS) ; FIX(1.175875602)
-F_1_501 equ DESCALE(1612031267, 30 - CONST_BITS) ; FIX(1.501321110)
-F_1_847 equ DESCALE(1984016188, 30 - CONST_BITS) ; FIX(1.847759065)
-F_1_961 equ DESCALE(2106220350, 30 - CONST_BITS) ; FIX(1.961570560)
-F_2_053 equ DESCALE(2204520673, 30 - CONST_BITS) ; FIX(2.053119869)
-F_2_562 equ DESCALE(2751909506, 30 - CONST_BITS) ; FIX(2.562915447)
-F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
-%endif
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_fdct_islow_sse2)
-
-EXTN(jconst_fdct_islow_sse2):
-
-PW_F130_F054 times 4 dw (F_0_541 + F_0_765), F_0_541
-PW_F054_MF130 times 4 dw F_0_541, (F_0_541 - F_1_847)
-PW_MF078_F117 times 4 dw (F_1_175 - F_1_961), F_1_175
-PW_F117_F078 times 4 dw F_1_175, (F_1_175 - F_0_390)
-PW_MF060_MF089 times 4 dw (F_0_298 - F_0_899), -F_0_899
-PW_MF089_F060 times 4 dw -F_0_899, (F_1_501 - F_0_899)
-PW_MF050_MF256 times 4 dw (F_2_053 - F_2_562), -F_2_562
-PW_MF256_F050 times 4 dw -F_2_562, (F_3_072 - F_2_562)
-PD_DESCALE_P1 times 4 dd 1 << (DESCALE_P1 - 1)
-PD_DESCALE_P2 times 4 dd 1 << (DESCALE_P2 - 1)
-PW_DESCALE_P2X times 8 dw 1 << (PASS1_BITS - 1)
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-;
-; Perform the forward DCT on one block of samples.
-;
-; GLOBAL(void)
-; jsimd_fdct_islow_sse2(DCTELEM *data)
-;
-
-%define data(b) (b) + 8 ; DCTELEM *data
-
-%define original_ebp ebp + 0
-%define wk(i) ebp - (WK_NUM - (i)) * SIZEOF_XMMWORD
- ; xmmword wk[WK_NUM]
-%define WK_NUM 6
-
- align 32
- GLOBAL_FUNCTION(jsimd_fdct_islow_sse2)
-
-EXTN(jsimd_fdct_islow_sse2):
- push ebp
- mov eax, esp ; eax = original ebp
- sub esp, byte 4
- and esp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [esp], eax
- mov ebp, esp ; ebp = aligned ebp
- lea esp, [wk(0)]
- pushpic ebx
-; push ecx ; unused
-; push edx ; need not be preserved
-; push esi ; unused
-; push edi ; unused
-
- get_GOT ebx ; get GOT address
-
- ; ---- Pass 1: process rows.
-
- mov edx, POINTER [data(eax)] ; (DCTELEM *)
-
- movdqa xmm0, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_DCTELEM)]
- movdqa xmm1, XMMWORD [XMMBLOCK(1,0,edx,SIZEOF_DCTELEM)]
- movdqa xmm2, XMMWORD [XMMBLOCK(2,0,edx,SIZEOF_DCTELEM)]
- movdqa xmm3, XMMWORD [XMMBLOCK(3,0,edx,SIZEOF_DCTELEM)]
-
- ; xmm0=(00 01 02 03 04 05 06 07), xmm2=(20 21 22 23 24 25 26 27)
- ; xmm1=(10 11 12 13 14 15 16 17), xmm3=(30 31 32 33 34 35 36 37)
-
- movdqa xmm4, xmm0 ; transpose coefficients(phase 1)
- punpcklwd xmm0, xmm1 ; xmm0=(00 10 01 11 02 12 03 13)
- punpckhwd xmm4, xmm1 ; xmm4=(04 14 05 15 06 16 07 17)
- movdqa xmm5, xmm2 ; transpose coefficients(phase 1)
- punpcklwd xmm2, xmm3 ; xmm2=(20 30 21 31 22 32 23 33)
- punpckhwd xmm5, xmm3 ; xmm5=(24 34 25 35 26 36 27 37)
-
- movdqa xmm6, XMMWORD [XMMBLOCK(4,0,edx,SIZEOF_DCTELEM)]
- movdqa xmm7, XMMWORD [XMMBLOCK(5,0,edx,SIZEOF_DCTELEM)]
- movdqa xmm1, XMMWORD [XMMBLOCK(6,0,edx,SIZEOF_DCTELEM)]
- movdqa xmm3, XMMWORD [XMMBLOCK(7,0,edx,SIZEOF_DCTELEM)]
-
- ; xmm6=( 4 12 20 28 36 44 52 60), xmm1=( 6 14 22 30 38 46 54 62)
- ; xmm7=( 5 13 21 29 37 45 53 61), xmm3=( 7 15 23 31 39 47 55 63)
-
- movdqa XMMWORD [wk(0)], xmm2 ; wk(0)=(20 30 21 31 22 32 23 33)
- movdqa XMMWORD [wk(1)], xmm5 ; wk(1)=(24 34 25 35 26 36 27 37)
-
- movdqa xmm2, xmm6 ; transpose coefficients(phase 1)
- punpcklwd xmm6, xmm7 ; xmm6=(40 50 41 51 42 52 43 53)
- punpckhwd xmm2, xmm7 ; xmm2=(44 54 45 55 46 56 47 57)
- movdqa xmm5, xmm1 ; transpose coefficients(phase 1)
- punpcklwd xmm1, xmm3 ; xmm1=(60 70 61 71 62 72 63 73)
- punpckhwd xmm5, xmm3 ; xmm5=(64 74 65 75 66 76 67 77)
-
- movdqa xmm7, xmm6 ; transpose coefficients(phase 2)
- punpckldq xmm6, xmm1 ; xmm6=(40 50 60 70 41 51 61 71)
- punpckhdq xmm7, xmm1 ; xmm7=(42 52 62 72 43 53 63 73)
- movdqa xmm3, xmm2 ; transpose coefficients(phase 2)
- punpckldq xmm2, xmm5 ; xmm2=(44 54 64 74 45 55 65 75)
- punpckhdq xmm3, xmm5 ; xmm3=(46 56 66 76 47 57 67 77)
-
- movdqa xmm1, XMMWORD [wk(0)] ; xmm1=(20 30 21 31 22 32 23 33)
- movdqa xmm5, XMMWORD [wk(1)] ; xmm5=(24 34 25 35 26 36 27 37)
- movdqa XMMWORD [wk(2)], xmm7 ; wk(2)=(42 52 62 72 43 53 63 73)
- movdqa XMMWORD [wk(3)], xmm2 ; wk(3)=(44 54 64 74 45 55 65 75)
-
- movdqa xmm7, xmm0 ; transpose coefficients(phase 2)
- punpckldq xmm0, xmm1 ; xmm0=(00 10 20 30 01 11 21 31)
- punpckhdq xmm7, xmm1 ; xmm7=(02 12 22 32 03 13 23 33)
- movdqa xmm2, xmm4 ; transpose coefficients(phase 2)
- punpckldq xmm4, xmm5 ; xmm4=(04 14 24 34 05 15 25 35)
- punpckhdq xmm2, xmm5 ; xmm2=(06 16 26 36 07 17 27 37)
-
- movdqa xmm1, xmm0 ; transpose coefficients(phase 3)
- punpcklqdq xmm0, xmm6 ; xmm0=(00 10 20 30 40 50 60 70)=data0
- punpckhqdq xmm1, xmm6 ; xmm1=(01 11 21 31 41 51 61 71)=data1
- movdqa xmm5, xmm2 ; transpose coefficients(phase 3)
- punpcklqdq xmm2, xmm3 ; xmm2=(06 16 26 36 46 56 66 76)=data6
- punpckhqdq xmm5, xmm3 ; xmm5=(07 17 27 37 47 57 67 77)=data7
-
- movdqa xmm6, xmm1
- movdqa xmm3, xmm0
- psubw xmm1, xmm2 ; xmm1=data1-data6=tmp6
- psubw xmm0, xmm5 ; xmm0=data0-data7=tmp7
- paddw xmm6, xmm2 ; xmm6=data1+data6=tmp1
- paddw xmm3, xmm5 ; xmm3=data0+data7=tmp0
-
- movdqa xmm2, XMMWORD [wk(2)] ; xmm2=(42 52 62 72 43 53 63 73)
- movdqa xmm5, XMMWORD [wk(3)] ; xmm5=(44 54 64 74 45 55 65 75)
- movdqa XMMWORD [wk(0)], xmm1 ; wk(0)=tmp6
- movdqa XMMWORD [wk(1)], xmm0 ; wk(1)=tmp7
-
- movdqa xmm1, xmm7 ; transpose coefficients(phase 3)
- punpcklqdq xmm7, xmm2 ; xmm7=(02 12 22 32 42 52 62 72)=data2
- punpckhqdq xmm1, xmm2 ; xmm1=(03 13 23 33 43 53 63 73)=data3
- movdqa xmm0, xmm4 ; transpose coefficients(phase 3)
- punpcklqdq xmm4, xmm5 ; xmm4=(04 14 24 34 44 54 64 74)=data4
- punpckhqdq xmm0, xmm5 ; xmm0=(05 15 25 35 45 55 65 75)=data5
-
- movdqa xmm2, xmm1
- movdqa xmm5, xmm7
- paddw xmm1, xmm4 ; xmm1=data3+data4=tmp3
- paddw xmm7, xmm0 ; xmm7=data2+data5=tmp2
- psubw xmm2, xmm4 ; xmm2=data3-data4=tmp4
- psubw xmm5, xmm0 ; xmm5=data2-data5=tmp5
-
- ; -- Even part
-
- movdqa xmm4, xmm3
- movdqa xmm0, xmm6
- paddw xmm3, xmm1 ; xmm3=tmp10
- paddw xmm6, xmm7 ; xmm6=tmp11
- psubw xmm4, xmm1 ; xmm4=tmp13
- psubw xmm0, xmm7 ; xmm0=tmp12
-
- movdqa xmm1, xmm3
- paddw xmm3, xmm6 ; xmm3=tmp10+tmp11
- psubw xmm1, xmm6 ; xmm1=tmp10-tmp11
-
- psllw xmm3, PASS1_BITS ; xmm3=data0
- psllw xmm1, PASS1_BITS ; xmm1=data4
-
- movdqa XMMWORD [wk(2)], xmm3 ; wk(2)=data0
- movdqa XMMWORD [wk(3)], xmm1 ; wk(3)=data4
-
- ; (Original)
- ; z1 = (tmp12 + tmp13) * 0.541196100;
- ; data2 = z1 + tmp13 * 0.765366865;
- ; data6 = z1 + tmp12 * -1.847759065;
- ;
- ; (This implementation)
- ; data2 = tmp13 * (0.541196100 + 0.765366865) + tmp12 * 0.541196100;
- ; data6 = tmp13 * 0.541196100 + tmp12 * (0.541196100 - 1.847759065);
-
- movdqa xmm7, xmm4 ; xmm4=tmp13
- movdqa xmm6, xmm4
- punpcklwd xmm7, xmm0 ; xmm0=tmp12
- punpckhwd xmm6, xmm0
- movdqa xmm4, xmm7
- movdqa xmm0, xmm6
- pmaddwd xmm7, [GOTOFF(ebx,PW_F130_F054)] ; xmm7=data2L
- pmaddwd xmm6, [GOTOFF(ebx,PW_F130_F054)] ; xmm6=data2H
- pmaddwd xmm4, [GOTOFF(ebx,PW_F054_MF130)] ; xmm4=data6L
- pmaddwd xmm0, [GOTOFF(ebx,PW_F054_MF130)] ; xmm0=data6H
-
- paddd xmm7, [GOTOFF(ebx,PD_DESCALE_P1)]
- paddd xmm6, [GOTOFF(ebx,PD_DESCALE_P1)]
- psrad xmm7, DESCALE_P1
- psrad xmm6, DESCALE_P1
- paddd xmm4, [GOTOFF(ebx,PD_DESCALE_P1)]
- paddd xmm0, [GOTOFF(ebx,PD_DESCALE_P1)]
- psrad xmm4, DESCALE_P1
- psrad xmm0, DESCALE_P1
-
- packssdw xmm7, xmm6 ; xmm7=data2
- packssdw xmm4, xmm0 ; xmm4=data6
-
- movdqa XMMWORD [wk(4)], xmm7 ; wk(4)=data2
- movdqa XMMWORD [wk(5)], xmm4 ; wk(5)=data6
-
- ; -- Odd part
-
- movdqa xmm3, XMMWORD [wk(0)] ; xmm3=tmp6
- movdqa xmm1, XMMWORD [wk(1)] ; xmm1=tmp7
-
- movdqa xmm6, xmm2 ; xmm2=tmp4
- movdqa xmm0, xmm5 ; xmm5=tmp5
- paddw xmm6, xmm3 ; xmm6=z3
- paddw xmm0, xmm1 ; xmm0=z4
-
- ; (Original)
- ; z5 = (z3 + z4) * 1.175875602;
- ; z3 = z3 * -1.961570560; z4 = z4 * -0.390180644;
- ; z3 += z5; z4 += z5;
- ;
- ; (This implementation)
- ; z3 = z3 * (1.175875602 - 1.961570560) + z4 * 1.175875602;
- ; z4 = z3 * 1.175875602 + z4 * (1.175875602 - 0.390180644);
-
- movdqa xmm7, xmm6
- movdqa xmm4, xmm6
- punpcklwd xmm7, xmm0
- punpckhwd xmm4, xmm0
- movdqa xmm6, xmm7
- movdqa xmm0, xmm4
- pmaddwd xmm7, [GOTOFF(ebx,PW_MF078_F117)] ; xmm7=z3L
- pmaddwd xmm4, [GOTOFF(ebx,PW_MF078_F117)] ; xmm4=z3H
- pmaddwd xmm6, [GOTOFF(ebx,PW_F117_F078)] ; xmm6=z4L
- pmaddwd xmm0, [GOTOFF(ebx,PW_F117_F078)] ; xmm0=z4H
-
- movdqa XMMWORD [wk(0)], xmm7 ; wk(0)=z3L
- movdqa XMMWORD [wk(1)], xmm4 ; wk(1)=z3H
-
- ; (Original)
- ; z1 = tmp4 + tmp7; z2 = tmp5 + tmp6;
- ; tmp4 = tmp4 * 0.298631336; tmp5 = tmp5 * 2.053119869;
- ; tmp6 = tmp6 * 3.072711026; tmp7 = tmp7 * 1.501321110;
- ; z1 = z1 * -0.899976223; z2 = z2 * -2.562915447;
- ; data7 = tmp4 + z1 + z3; data5 = tmp5 + z2 + z4;
- ; data3 = tmp6 + z2 + z3; data1 = tmp7 + z1 + z4;
- ;
- ; (This implementation)
- ; tmp4 = tmp4 * (0.298631336 - 0.899976223) + tmp7 * -0.899976223;
- ; tmp5 = tmp5 * (2.053119869 - 2.562915447) + tmp6 * -2.562915447;
- ; tmp6 = tmp5 * -2.562915447 + tmp6 * (3.072711026 - 2.562915447);
- ; tmp7 = tmp4 * -0.899976223 + tmp7 * (1.501321110 - 0.899976223);
- ; data7 = tmp4 + z3; data5 = tmp5 + z4;
- ; data3 = tmp6 + z3; data1 = tmp7 + z4;
-
- movdqa xmm7, xmm2
- movdqa xmm4, xmm2
- punpcklwd xmm7, xmm1
- punpckhwd xmm4, xmm1
- movdqa xmm2, xmm7
- movdqa xmm1, xmm4
- pmaddwd xmm7, [GOTOFF(ebx,PW_MF060_MF089)] ; xmm7=tmp4L
- pmaddwd xmm4, [GOTOFF(ebx,PW_MF060_MF089)] ; xmm4=tmp4H
- pmaddwd xmm2, [GOTOFF(ebx,PW_MF089_F060)] ; xmm2=tmp7L
- pmaddwd xmm1, [GOTOFF(ebx,PW_MF089_F060)] ; xmm1=tmp7H
-
- paddd xmm7, XMMWORD [wk(0)] ; xmm7=data7L
- paddd xmm4, XMMWORD [wk(1)] ; xmm4=data7H
- paddd xmm2, xmm6 ; xmm2=data1L
- paddd xmm1, xmm0 ; xmm1=data1H
-
- paddd xmm7, [GOTOFF(ebx,PD_DESCALE_P1)]
- paddd xmm4, [GOTOFF(ebx,PD_DESCALE_P1)]
- psrad xmm7, DESCALE_P1
- psrad xmm4, DESCALE_P1
- paddd xmm2, [GOTOFF(ebx,PD_DESCALE_P1)]
- paddd xmm1, [GOTOFF(ebx,PD_DESCALE_P1)]
- psrad xmm2, DESCALE_P1
- psrad xmm1, DESCALE_P1
-
- packssdw xmm7, xmm4 ; xmm7=data7
- packssdw xmm2, xmm1 ; xmm2=data1
-
- movdqa xmm4, xmm5
- movdqa xmm1, xmm5
- punpcklwd xmm4, xmm3
- punpckhwd xmm1, xmm3
- movdqa xmm5, xmm4
- movdqa xmm3, xmm1
- pmaddwd xmm4, [GOTOFF(ebx,PW_MF050_MF256)] ; xmm4=tmp5L
- pmaddwd xmm1, [GOTOFF(ebx,PW_MF050_MF256)] ; xmm1=tmp5H
- pmaddwd xmm5, [GOTOFF(ebx,PW_MF256_F050)] ; xmm5=tmp6L
- pmaddwd xmm3, [GOTOFF(ebx,PW_MF256_F050)] ; xmm3=tmp6H
-
- paddd xmm4, xmm6 ; xmm4=data5L
- paddd xmm1, xmm0 ; xmm1=data5H
- paddd xmm5, XMMWORD [wk(0)] ; xmm5=data3L
- paddd xmm3, XMMWORD [wk(1)] ; xmm3=data3H
-
- paddd xmm4, [GOTOFF(ebx,PD_DESCALE_P1)]
- paddd xmm1, [GOTOFF(ebx,PD_DESCALE_P1)]
- psrad xmm4, DESCALE_P1
- psrad xmm1, DESCALE_P1
- paddd xmm5, [GOTOFF(ebx,PD_DESCALE_P1)]
- paddd xmm3, [GOTOFF(ebx,PD_DESCALE_P1)]
- psrad xmm5, DESCALE_P1
- psrad xmm3, DESCALE_P1
-
- packssdw xmm4, xmm1 ; xmm4=data5
- packssdw xmm5, xmm3 ; xmm5=data3
-
- ; ---- Pass 2: process columns.
-
-; mov edx, POINTER [data(eax)] ; (DCTELEM *)
-
- movdqa xmm6, XMMWORD [wk(2)] ; xmm6=col0
- movdqa xmm0, XMMWORD [wk(4)] ; xmm0=col2
-
- ; xmm6=(00 10 20 30 40 50 60 70), xmm0=(02 12 22 32 42 52 62 72)
- ; xmm2=(01 11 21 31 41 51 61 71), xmm5=(03 13 23 33 43 53 63 73)
-
- movdqa xmm1, xmm6 ; transpose coefficients(phase 1)
- punpcklwd xmm6, xmm2 ; xmm6=(00 01 10 11 20 21 30 31)
- punpckhwd xmm1, xmm2 ; xmm1=(40 41 50 51 60 61 70 71)
- movdqa xmm3, xmm0 ; transpose coefficients(phase 1)
- punpcklwd xmm0, xmm5 ; xmm0=(02 03 12 13 22 23 32 33)
- punpckhwd xmm3, xmm5 ; xmm3=(42 43 52 53 62 63 72 73)
-
- movdqa xmm2, XMMWORD [wk(3)] ; xmm2=col4
- movdqa xmm5, XMMWORD [wk(5)] ; xmm5=col6
-
- ; xmm2=(04 14 24 34 44 54 64 74), xmm5=(06 16 26 36 46 56 66 76)
- ; xmm4=(05 15 25 35 45 55 65 75), xmm7=(07 17 27 37 47 57 67 77)
-
- movdqa XMMWORD [wk(0)], xmm0 ; wk(0)=(02 03 12 13 22 23 32 33)
- movdqa XMMWORD [wk(1)], xmm3 ; wk(1)=(42 43 52 53 62 63 72 73)
-
- movdqa xmm0, xmm2 ; transpose coefficients(phase 1)
- punpcklwd xmm2, xmm4 ; xmm2=(04 05 14 15 24 25 34 35)
- punpckhwd xmm0, xmm4 ; xmm0=(44 45 54 55 64 65 74 75)
- movdqa xmm3, xmm5 ; transpose coefficients(phase 1)
- punpcklwd xmm5, xmm7 ; xmm5=(06 07 16 17 26 27 36 37)
- punpckhwd xmm3, xmm7 ; xmm3=(46 47 56 57 66 67 76 77)
-
- movdqa xmm4, xmm2 ; transpose coefficients(phase 2)
- punpckldq xmm2, xmm5 ; xmm2=(04 05 06 07 14 15 16 17)
- punpckhdq xmm4, xmm5 ; xmm4=(24 25 26 27 34 35 36 37)
- movdqa xmm7, xmm0 ; transpose coefficients(phase 2)
- punpckldq xmm0, xmm3 ; xmm0=(44 45 46 47 54 55 56 57)
- punpckhdq xmm7, xmm3 ; xmm7=(64 65 66 67 74 75 76 77)
-
- movdqa xmm5, XMMWORD [wk(0)] ; xmm5=(02 03 12 13 22 23 32 33)
- movdqa xmm3, XMMWORD [wk(1)] ; xmm3=(42 43 52 53 62 63 72 73)
- movdqa XMMWORD [wk(2)], xmm4 ; wk(2)=(24 25 26 27 34 35 36 37)
- movdqa XMMWORD [wk(3)], xmm0 ; wk(3)=(44 45 46 47 54 55 56 57)
-
- movdqa xmm4, xmm6 ; transpose coefficients(phase 2)
- punpckldq xmm6, xmm5 ; xmm6=(00 01 02 03 10 11 12 13)
- punpckhdq xmm4, xmm5 ; xmm4=(20 21 22 23 30 31 32 33)
- movdqa xmm0, xmm1 ; transpose coefficients(phase 2)
- punpckldq xmm1, xmm3 ; xmm1=(40 41 42 43 50 51 52 53)
- punpckhdq xmm0, xmm3 ; xmm0=(60 61 62 63 70 71 72 73)
-
- movdqa xmm5, xmm6 ; transpose coefficients(phase 3)
- punpcklqdq xmm6, xmm2 ; xmm6=(00 01 02 03 04 05 06 07)=data0
- punpckhqdq xmm5, xmm2 ; xmm5=(10 11 12 13 14 15 16 17)=data1
- movdqa xmm3, xmm0 ; transpose coefficients(phase 3)
- punpcklqdq xmm0, xmm7 ; xmm0=(60 61 62 63 64 65 66 67)=data6
- punpckhqdq xmm3, xmm7 ; xmm3=(70 71 72 73 74 75 76 77)=data7
-
- movdqa xmm2, xmm5
- movdqa xmm7, xmm6
- psubw xmm5, xmm0 ; xmm5=data1-data6=tmp6
- psubw xmm6, xmm3 ; xmm6=data0-data7=tmp7
- paddw xmm2, xmm0 ; xmm2=data1+data6=tmp1
- paddw xmm7, xmm3 ; xmm7=data0+data7=tmp0
-
- movdqa xmm0, XMMWORD [wk(2)] ; xmm0=(24 25 26 27 34 35 36 37)
- movdqa xmm3, XMMWORD [wk(3)] ; xmm3=(44 45 46 47 54 55 56 57)
- movdqa XMMWORD [wk(0)], xmm5 ; wk(0)=tmp6
- movdqa XMMWORD [wk(1)], xmm6 ; wk(1)=tmp7
-
- movdqa xmm5, xmm4 ; transpose coefficients(phase 3)
- punpcklqdq xmm4, xmm0 ; xmm4=(20 21 22 23 24 25 26 27)=data2
- punpckhqdq xmm5, xmm0 ; xmm5=(30 31 32 33 34 35 36 37)=data3
- movdqa xmm6, xmm1 ; transpose coefficients(phase 3)
- punpcklqdq xmm1, xmm3 ; xmm1=(40 41 42 43 44 45 46 47)=data4
- punpckhqdq xmm6, xmm3 ; xmm6=(50 51 52 53 54 55 56 57)=data5
-
- movdqa xmm0, xmm5
- movdqa xmm3, xmm4
- paddw xmm5, xmm1 ; xmm5=data3+data4=tmp3
- paddw xmm4, xmm6 ; xmm4=data2+data5=tmp2
- psubw xmm0, xmm1 ; xmm0=data3-data4=tmp4
- psubw xmm3, xmm6 ; xmm3=data2-data5=tmp5
-
- ; -- Even part
-
- movdqa xmm1, xmm7
- movdqa xmm6, xmm2
- paddw xmm7, xmm5 ; xmm7=tmp10
- paddw xmm2, xmm4 ; xmm2=tmp11
- psubw xmm1, xmm5 ; xmm1=tmp13
- psubw xmm6, xmm4 ; xmm6=tmp12
-
- movdqa xmm5, xmm7
- paddw xmm7, xmm2 ; xmm7=tmp10+tmp11
- psubw xmm5, xmm2 ; xmm5=tmp10-tmp11
-
- paddw xmm7, [GOTOFF(ebx,PW_DESCALE_P2X)]
- paddw xmm5, [GOTOFF(ebx,PW_DESCALE_P2X)]
- psraw xmm7, PASS1_BITS ; xmm7=data0
- psraw xmm5, PASS1_BITS ; xmm5=data4
-
- movdqa XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_DCTELEM)], xmm7
- movdqa XMMWORD [XMMBLOCK(4,0,edx,SIZEOF_DCTELEM)], xmm5
-
- ; (Original)
- ; z1 = (tmp12 + tmp13) * 0.541196100;
- ; data2 = z1 + tmp13 * 0.765366865;
- ; data6 = z1 + tmp12 * -1.847759065;
- ;
- ; (This implementation)
- ; data2 = tmp13 * (0.541196100 + 0.765366865) + tmp12 * 0.541196100;
- ; data6 = tmp13 * 0.541196100 + tmp12 * (0.541196100 - 1.847759065);
-
- movdqa xmm4, xmm1 ; xmm1=tmp13
- movdqa xmm2, xmm1
- punpcklwd xmm4, xmm6 ; xmm6=tmp12
- punpckhwd xmm2, xmm6
- movdqa xmm1, xmm4
- movdqa xmm6, xmm2
- pmaddwd xmm4, [GOTOFF(ebx,PW_F130_F054)] ; xmm4=data2L
- pmaddwd xmm2, [GOTOFF(ebx,PW_F130_F054)] ; xmm2=data2H
- pmaddwd xmm1, [GOTOFF(ebx,PW_F054_MF130)] ; xmm1=data6L
- pmaddwd xmm6, [GOTOFF(ebx,PW_F054_MF130)] ; xmm6=data6H
-
- paddd xmm4, [GOTOFF(ebx,PD_DESCALE_P2)]
- paddd xmm2, [GOTOFF(ebx,PD_DESCALE_P2)]
- psrad xmm4, DESCALE_P2
- psrad xmm2, DESCALE_P2
- paddd xmm1, [GOTOFF(ebx,PD_DESCALE_P2)]
- paddd xmm6, [GOTOFF(ebx,PD_DESCALE_P2)]
- psrad xmm1, DESCALE_P2
- psrad xmm6, DESCALE_P2
-
- packssdw xmm4, xmm2 ; xmm4=data2
- packssdw xmm1, xmm6 ; xmm1=data6
-
- movdqa XMMWORD [XMMBLOCK(2,0,edx,SIZEOF_DCTELEM)], xmm4
- movdqa XMMWORD [XMMBLOCK(6,0,edx,SIZEOF_DCTELEM)], xmm1
-
- ; -- Odd part
-
- movdqa xmm7, XMMWORD [wk(0)] ; xmm7=tmp6
- movdqa xmm5, XMMWORD [wk(1)] ; xmm5=tmp7
-
- movdqa xmm2, xmm0 ; xmm0=tmp4
- movdqa xmm6, xmm3 ; xmm3=tmp5
- paddw xmm2, xmm7 ; xmm2=z3
- paddw xmm6, xmm5 ; xmm6=z4
-
- ; (Original)
- ; z5 = (z3 + z4) * 1.175875602;
- ; z3 = z3 * -1.961570560; z4 = z4 * -0.390180644;
- ; z3 += z5; z4 += z5;
- ;
- ; (This implementation)
- ; z3 = z3 * (1.175875602 - 1.961570560) + z4 * 1.175875602;
- ; z4 = z3 * 1.175875602 + z4 * (1.175875602 - 0.390180644);
-
- movdqa xmm4, xmm2
- movdqa xmm1, xmm2
- punpcklwd xmm4, xmm6
- punpckhwd xmm1, xmm6
- movdqa xmm2, xmm4
- movdqa xmm6, xmm1
- pmaddwd xmm4, [GOTOFF(ebx,PW_MF078_F117)] ; xmm4=z3L
- pmaddwd xmm1, [GOTOFF(ebx,PW_MF078_F117)] ; xmm1=z3H
- pmaddwd xmm2, [GOTOFF(ebx,PW_F117_F078)] ; xmm2=z4L
- pmaddwd xmm6, [GOTOFF(ebx,PW_F117_F078)] ; xmm6=z4H
-
- movdqa XMMWORD [wk(0)], xmm4 ; wk(0)=z3L
- movdqa XMMWORD [wk(1)], xmm1 ; wk(1)=z3H
-
- ; (Original)
- ; z1 = tmp4 + tmp7; z2 = tmp5 + tmp6;
- ; tmp4 = tmp4 * 0.298631336; tmp5 = tmp5 * 2.053119869;
- ; tmp6 = tmp6 * 3.072711026; tmp7 = tmp7 * 1.501321110;
- ; z1 = z1 * -0.899976223; z2 = z2 * -2.562915447;
- ; data7 = tmp4 + z1 + z3; data5 = tmp5 + z2 + z4;
- ; data3 = tmp6 + z2 + z3; data1 = tmp7 + z1 + z4;
- ;
- ; (This implementation)
- ; tmp4 = tmp4 * (0.298631336 - 0.899976223) + tmp7 * -0.899976223;
- ; tmp5 = tmp5 * (2.053119869 - 2.562915447) + tmp6 * -2.562915447;
- ; tmp6 = tmp5 * -2.562915447 + tmp6 * (3.072711026 - 2.562915447);
- ; tmp7 = tmp4 * -0.899976223 + tmp7 * (1.501321110 - 0.899976223);
- ; data7 = tmp4 + z3; data5 = tmp5 + z4;
- ; data3 = tmp6 + z3; data1 = tmp7 + z4;
-
- movdqa xmm4, xmm0
- movdqa xmm1, xmm0
- punpcklwd xmm4, xmm5
- punpckhwd xmm1, xmm5
- movdqa xmm0, xmm4
- movdqa xmm5, xmm1
- pmaddwd xmm4, [GOTOFF(ebx,PW_MF060_MF089)] ; xmm4=tmp4L
- pmaddwd xmm1, [GOTOFF(ebx,PW_MF060_MF089)] ; xmm1=tmp4H
- pmaddwd xmm0, [GOTOFF(ebx,PW_MF089_F060)] ; xmm0=tmp7L
- pmaddwd xmm5, [GOTOFF(ebx,PW_MF089_F060)] ; xmm5=tmp7H
-
- paddd xmm4, XMMWORD [wk(0)] ; xmm4=data7L
- paddd xmm1, XMMWORD [wk(1)] ; xmm1=data7H
- paddd xmm0, xmm2 ; xmm0=data1L
- paddd xmm5, xmm6 ; xmm5=data1H
-
- paddd xmm4, [GOTOFF(ebx,PD_DESCALE_P2)]
- paddd xmm1, [GOTOFF(ebx,PD_DESCALE_P2)]
- psrad xmm4, DESCALE_P2
- psrad xmm1, DESCALE_P2
- paddd xmm0, [GOTOFF(ebx,PD_DESCALE_P2)]
- paddd xmm5, [GOTOFF(ebx,PD_DESCALE_P2)]
- psrad xmm0, DESCALE_P2
- psrad xmm5, DESCALE_P2
-
- packssdw xmm4, xmm1 ; xmm4=data7
- packssdw xmm0, xmm5 ; xmm0=data1
-
- movdqa XMMWORD [XMMBLOCK(7,0,edx,SIZEOF_DCTELEM)], xmm4
- movdqa XMMWORD [XMMBLOCK(1,0,edx,SIZEOF_DCTELEM)], xmm0
-
- movdqa xmm1, xmm3
- movdqa xmm5, xmm3
- punpcklwd xmm1, xmm7
- punpckhwd xmm5, xmm7
- movdqa xmm3, xmm1
- movdqa xmm7, xmm5
- pmaddwd xmm1, [GOTOFF(ebx,PW_MF050_MF256)] ; xmm1=tmp5L
- pmaddwd xmm5, [GOTOFF(ebx,PW_MF050_MF256)] ; xmm5=tmp5H
- pmaddwd xmm3, [GOTOFF(ebx,PW_MF256_F050)] ; xmm3=tmp6L
- pmaddwd xmm7, [GOTOFF(ebx,PW_MF256_F050)] ; xmm7=tmp6H
-
- paddd xmm1, xmm2 ; xmm1=data5L
- paddd xmm5, xmm6 ; xmm5=data5H
- paddd xmm3, XMMWORD [wk(0)] ; xmm3=data3L
- paddd xmm7, XMMWORD [wk(1)] ; xmm7=data3H
-
- paddd xmm1, [GOTOFF(ebx,PD_DESCALE_P2)]
- paddd xmm5, [GOTOFF(ebx,PD_DESCALE_P2)]
- psrad xmm1, DESCALE_P2
- psrad xmm5, DESCALE_P2
- paddd xmm3, [GOTOFF(ebx,PD_DESCALE_P2)]
- paddd xmm7, [GOTOFF(ebx,PD_DESCALE_P2)]
- psrad xmm3, DESCALE_P2
- psrad xmm7, DESCALE_P2
-
- packssdw xmm1, xmm5 ; xmm1=data5
- packssdw xmm3, xmm7 ; xmm3=data3
-
- movdqa XMMWORD [XMMBLOCK(5,0,edx,SIZEOF_DCTELEM)], xmm1
- movdqa XMMWORD [XMMBLOCK(3,0,edx,SIZEOF_DCTELEM)], xmm3
-
-; pop edi ; unused
-; pop esi ; unused
-; pop edx ; need not be preserved
-; pop ecx ; unused
- poppic ebx
- mov esp, ebp ; esp <- aligned ebp
- pop esp ; esp <- original ebp
- pop ebp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jidctflt-3dn.asm b/contrib/libs/libjpeg-turbo/simd/i386/jidctflt-3dn.asm
deleted file mode 100644
index 87951910d8..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jidctflt-3dn.asm
+++ /dev/null
@@ -1,451 +0,0 @@
-;
-; jidctflt.asm - floating-point IDCT (3DNow! & MMX)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-;
-; This file contains a floating-point implementation of the inverse DCT
-; (Discrete Cosine Transform). The following code is based directly on
-; the IJG's original jidctflt.c; see the jidctflt.c for more details.
-
-%include "jsimdext.inc"
-%include "jdct.inc"
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_idct_float_3dnow)
-
-EXTN(jconst_idct_float_3dnow):
-
-PD_1_414 times 2 dd 1.414213562373095048801689
-PD_1_847 times 2 dd 1.847759065022573512256366
-PD_1_082 times 2 dd 1.082392200292393968799446
-PD_2_613 times 2 dd 2.613125929752753055713286
-PD_RNDINT_MAGIC times 2 dd 100663296.0 ; (float)(0x00C00000 << 3)
-PB_CENTERJSAMP times 8 db CENTERJSAMPLE
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-;
-; Perform dequantization and inverse DCT on one block of coefficients.
-;
-; GLOBAL(void)
-; jsimd_idct_float_3dnow(void *dct_table, JCOEFPTR coef_block,
-; JSAMPARRAY output_buf, JDIMENSION output_col)
-;
-
-%define dct_table(b) (b) + 8 ; void *dct_table
-%define coef_block(b) (b) + 12 ; JCOEFPTR coef_block
-%define output_buf(b) (b) + 16 ; JSAMPARRAY output_buf
-%define output_col(b) (b) + 20 ; JDIMENSION output_col
-
-%define original_ebp ebp + 0
-%define wk(i) ebp - (WK_NUM - (i)) * SIZEOF_MMWORD
- ; mmword wk[WK_NUM]
-%define WK_NUM 2
-%define workspace wk(0) - DCTSIZE2 * SIZEOF_FAST_FLOAT
- ; FAST_FLOAT workspace[DCTSIZE2]
-
- align 32
- GLOBAL_FUNCTION(jsimd_idct_float_3dnow)
-
-EXTN(jsimd_idct_float_3dnow):
- push ebp
- mov eax, esp ; eax = original ebp
- sub esp, byte 4
- and esp, byte (-SIZEOF_MMWORD) ; align to 64 bits
- mov [esp], eax
- mov ebp, esp ; ebp = aligned ebp
- lea esp, [workspace]
- push ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- get_GOT ebx ; get GOT address
-
- ; ---- Pass 1: process columns from input, store into work array.
-
-; mov eax, [original_ebp]
- mov edx, POINTER [dct_table(eax)] ; quantptr
- mov esi, JCOEFPTR [coef_block(eax)] ; inptr
- lea edi, [workspace] ; FAST_FLOAT *wsptr
- mov ecx, DCTSIZE/2 ; ctr
- alignx 16, 7
-.columnloop:
-%ifndef NO_ZERO_COLUMN_TEST_FLOAT_3DNOW
- mov eax, dword [DWBLOCK(1,0,esi,SIZEOF_JCOEF)]
- or eax, dword [DWBLOCK(2,0,esi,SIZEOF_JCOEF)]
- jnz short .columnDCT
-
- pushpic ebx ; save GOT address
- mov ebx, dword [DWBLOCK(3,0,esi,SIZEOF_JCOEF)]
- mov eax, dword [DWBLOCK(4,0,esi,SIZEOF_JCOEF)]
- or ebx, dword [DWBLOCK(5,0,esi,SIZEOF_JCOEF)]
- or eax, dword [DWBLOCK(6,0,esi,SIZEOF_JCOEF)]
- or ebx, dword [DWBLOCK(7,0,esi,SIZEOF_JCOEF)]
- or eax, ebx
- poppic ebx ; restore GOT address
- jnz short .columnDCT
-
- ; -- AC terms all zero
-
- movd mm0, dword [DWBLOCK(0,0,esi,SIZEOF_JCOEF)]
-
- punpcklwd mm0, mm0
- psrad mm0, (DWORD_BIT-WORD_BIT)
- pi2fd mm0, mm0
-
- pfmul mm0, MMWORD [MMBLOCK(0,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
-
- movq mm1, mm0
- punpckldq mm0, mm0
- punpckhdq mm1, mm1
-
- movq MMWORD [MMBLOCK(0,0,edi,SIZEOF_FAST_FLOAT)], mm0
- movq MMWORD [MMBLOCK(0,1,edi,SIZEOF_FAST_FLOAT)], mm0
- movq MMWORD [MMBLOCK(0,2,edi,SIZEOF_FAST_FLOAT)], mm0
- movq MMWORD [MMBLOCK(0,3,edi,SIZEOF_FAST_FLOAT)], mm0
- movq MMWORD [MMBLOCK(1,0,edi,SIZEOF_FAST_FLOAT)], mm1
- movq MMWORD [MMBLOCK(1,1,edi,SIZEOF_FAST_FLOAT)], mm1
- movq MMWORD [MMBLOCK(1,2,edi,SIZEOF_FAST_FLOAT)], mm1
- movq MMWORD [MMBLOCK(1,3,edi,SIZEOF_FAST_FLOAT)], mm1
- jmp near .nextcolumn
- alignx 16, 7
-%endif
-.columnDCT:
-
- ; -- Even part
-
- movd mm0, dword [DWBLOCK(0,0,esi,SIZEOF_JCOEF)]
- movd mm1, dword [DWBLOCK(2,0,esi,SIZEOF_JCOEF)]
- movd mm2, dword [DWBLOCK(4,0,esi,SIZEOF_JCOEF)]
- movd mm3, dword [DWBLOCK(6,0,esi,SIZEOF_JCOEF)]
-
- punpcklwd mm0, mm0
- punpcklwd mm1, mm1
- psrad mm0, (DWORD_BIT-WORD_BIT)
- psrad mm1, (DWORD_BIT-WORD_BIT)
- pi2fd mm0, mm0
- pi2fd mm1, mm1
-
- pfmul mm0, MMWORD [MMBLOCK(0,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
- pfmul mm1, MMWORD [MMBLOCK(2,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
-
- punpcklwd mm2, mm2
- punpcklwd mm3, mm3
- psrad mm2, (DWORD_BIT-WORD_BIT)
- psrad mm3, (DWORD_BIT-WORD_BIT)
- pi2fd mm2, mm2
- pi2fd mm3, mm3
-
- pfmul mm2, MMWORD [MMBLOCK(4,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
- pfmul mm3, MMWORD [MMBLOCK(6,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
-
- movq mm4, mm0
- movq mm5, mm1
- pfsub mm0, mm2 ; mm0=tmp11
- pfsub mm1, mm3
- pfadd mm4, mm2 ; mm4=tmp10
- pfadd mm5, mm3 ; mm5=tmp13
-
- pfmul mm1, [GOTOFF(ebx,PD_1_414)]
- pfsub mm1, mm5 ; mm1=tmp12
-
- movq mm6, mm4
- movq mm7, mm0
- pfsub mm4, mm5 ; mm4=tmp3
- pfsub mm0, mm1 ; mm0=tmp2
- pfadd mm6, mm5 ; mm6=tmp0
- pfadd mm7, mm1 ; mm7=tmp1
-
- movq MMWORD [wk(1)], mm4 ; tmp3
- movq MMWORD [wk(0)], mm0 ; tmp2
-
- ; -- Odd part
-
- movd mm2, dword [DWBLOCK(1,0,esi,SIZEOF_JCOEF)]
- movd mm3, dword [DWBLOCK(3,0,esi,SIZEOF_JCOEF)]
- movd mm5, dword [DWBLOCK(5,0,esi,SIZEOF_JCOEF)]
- movd mm1, dword [DWBLOCK(7,0,esi,SIZEOF_JCOEF)]
-
- punpcklwd mm2, mm2
- punpcklwd mm3, mm3
- psrad mm2, (DWORD_BIT-WORD_BIT)
- psrad mm3, (DWORD_BIT-WORD_BIT)
- pi2fd mm2, mm2
- pi2fd mm3, mm3
-
- pfmul mm2, MMWORD [MMBLOCK(1,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
- pfmul mm3, MMWORD [MMBLOCK(3,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
-
- punpcklwd mm5, mm5
- punpcklwd mm1, mm1
- psrad mm5, (DWORD_BIT-WORD_BIT)
- psrad mm1, (DWORD_BIT-WORD_BIT)
- pi2fd mm5, mm5
- pi2fd mm1, mm1
-
- pfmul mm5, MMWORD [MMBLOCK(5,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
- pfmul mm1, MMWORD [MMBLOCK(7,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
-
- movq mm4, mm2
- movq mm0, mm5
- pfadd mm2, mm1 ; mm2=z11
- pfadd mm5, mm3 ; mm5=z13
- pfsub mm4, mm1 ; mm4=z12
- pfsub mm0, mm3 ; mm0=z10
-
- movq mm1, mm2
- pfsub mm2, mm5
- pfadd mm1, mm5 ; mm1=tmp7
-
- pfmul mm2, [GOTOFF(ebx,PD_1_414)] ; mm2=tmp11
-
- movq mm3, mm0
- pfadd mm0, mm4
- pfmul mm0, [GOTOFF(ebx,PD_1_847)] ; mm0=z5
- pfmul mm3, [GOTOFF(ebx,PD_2_613)] ; mm3=(z10 * 2.613125930)
- pfmul mm4, [GOTOFF(ebx,PD_1_082)] ; mm4=(z12 * 1.082392200)
- pfsubr mm3, mm0 ; mm3=tmp12
- pfsub mm4, mm0 ; mm4=tmp10
-
- ; -- Final output stage
-
- pfsub mm3, mm1 ; mm3=tmp6
- movq mm5, mm6
- movq mm0, mm7
- pfadd mm6, mm1 ; mm6=data0=(00 01)
- pfadd mm7, mm3 ; mm7=data1=(10 11)
- pfsub mm5, mm1 ; mm5=data7=(70 71)
- pfsub mm0, mm3 ; mm0=data6=(60 61)
- pfsub mm2, mm3 ; mm2=tmp5
-
- movq mm1, mm6 ; transpose coefficients
- punpckldq mm6, mm7 ; mm6=(00 10)
- punpckhdq mm1, mm7 ; mm1=(01 11)
- movq mm3, mm0 ; transpose coefficients
- punpckldq mm0, mm5 ; mm0=(60 70)
- punpckhdq mm3, mm5 ; mm3=(61 71)
-
- movq MMWORD [MMBLOCK(0,0,edi,SIZEOF_FAST_FLOAT)], mm6
- movq MMWORD [MMBLOCK(1,0,edi,SIZEOF_FAST_FLOAT)], mm1
- movq MMWORD [MMBLOCK(0,3,edi,SIZEOF_FAST_FLOAT)], mm0
- movq MMWORD [MMBLOCK(1,3,edi,SIZEOF_FAST_FLOAT)], mm3
-
- movq mm7, MMWORD [wk(0)] ; mm7=tmp2
- movq mm5, MMWORD [wk(1)] ; mm5=tmp3
-
- pfadd mm4, mm2 ; mm4=tmp4
- movq mm6, mm7
- movq mm1, mm5
- pfadd mm7, mm2 ; mm7=data2=(20 21)
- pfadd mm5, mm4 ; mm5=data4=(40 41)
- pfsub mm6, mm2 ; mm6=data5=(50 51)
- pfsub mm1, mm4 ; mm1=data3=(30 31)
-
- movq mm0, mm7 ; transpose coefficients
- punpckldq mm7, mm1 ; mm7=(20 30)
- punpckhdq mm0, mm1 ; mm0=(21 31)
- movq mm3, mm5 ; transpose coefficients
- punpckldq mm5, mm6 ; mm5=(40 50)
- punpckhdq mm3, mm6 ; mm3=(41 51)
-
- movq MMWORD [MMBLOCK(0,1,edi,SIZEOF_FAST_FLOAT)], mm7
- movq MMWORD [MMBLOCK(1,1,edi,SIZEOF_FAST_FLOAT)], mm0
- movq MMWORD [MMBLOCK(0,2,edi,SIZEOF_FAST_FLOAT)], mm5
- movq MMWORD [MMBLOCK(1,2,edi,SIZEOF_FAST_FLOAT)], mm3
-
-.nextcolumn:
- add esi, byte 2*SIZEOF_JCOEF ; coef_block
- add edx, byte 2*SIZEOF_FLOAT_MULT_TYPE ; quantptr
- add edi, byte 2*DCTSIZE*SIZEOF_FAST_FLOAT ; wsptr
- dec ecx ; ctr
- jnz near .columnloop
-
- ; -- Prefetch the next coefficient block
-
- prefetch [esi + (DCTSIZE2-8)*SIZEOF_JCOEF + 0*32]
- prefetch [esi + (DCTSIZE2-8)*SIZEOF_JCOEF + 1*32]
- prefetch [esi + (DCTSIZE2-8)*SIZEOF_JCOEF + 2*32]
- prefetch [esi + (DCTSIZE2-8)*SIZEOF_JCOEF + 3*32]
-
- ; ---- Pass 2: process rows from work array, store into output array.
-
- mov eax, [original_ebp]
- lea esi, [workspace] ; FAST_FLOAT *wsptr
- mov edi, JSAMPARRAY [output_buf(eax)] ; (JSAMPROW *)
- mov eax, JDIMENSION [output_col(eax)]
- mov ecx, DCTSIZE/2 ; ctr
- alignx 16, 7
-.rowloop:
-
- ; -- Even part
-
- movq mm0, MMWORD [MMBLOCK(0,0,esi,SIZEOF_FAST_FLOAT)]
- movq mm1, MMWORD [MMBLOCK(2,0,esi,SIZEOF_FAST_FLOAT)]
- movq mm2, MMWORD [MMBLOCK(4,0,esi,SIZEOF_FAST_FLOAT)]
- movq mm3, MMWORD [MMBLOCK(6,0,esi,SIZEOF_FAST_FLOAT)]
-
- movq mm4, mm0
- movq mm5, mm1
- pfsub mm0, mm2 ; mm0=tmp11
- pfsub mm1, mm3
- pfadd mm4, mm2 ; mm4=tmp10
- pfadd mm5, mm3 ; mm5=tmp13
-
- pfmul mm1, [GOTOFF(ebx,PD_1_414)]
- pfsub mm1, mm5 ; mm1=tmp12
-
- movq mm6, mm4
- movq mm7, mm0
- pfsub mm4, mm5 ; mm4=tmp3
- pfsub mm0, mm1 ; mm0=tmp2
- pfadd mm6, mm5 ; mm6=tmp0
- pfadd mm7, mm1 ; mm7=tmp1
-
- movq MMWORD [wk(1)], mm4 ; tmp3
- movq MMWORD [wk(0)], mm0 ; tmp2
-
- ; -- Odd part
-
- movq mm2, MMWORD [MMBLOCK(1,0,esi,SIZEOF_FAST_FLOAT)]
- movq mm3, MMWORD [MMBLOCK(3,0,esi,SIZEOF_FAST_FLOAT)]
- movq mm5, MMWORD [MMBLOCK(5,0,esi,SIZEOF_FAST_FLOAT)]
- movq mm1, MMWORD [MMBLOCK(7,0,esi,SIZEOF_FAST_FLOAT)]
-
- movq mm4, mm2
- movq mm0, mm5
- pfadd mm2, mm1 ; mm2=z11
- pfadd mm5, mm3 ; mm5=z13
- pfsub mm4, mm1 ; mm4=z12
- pfsub mm0, mm3 ; mm0=z10
-
- movq mm1, mm2
- pfsub mm2, mm5
- pfadd mm1, mm5 ; mm1=tmp7
-
- pfmul mm2, [GOTOFF(ebx,PD_1_414)] ; mm2=tmp11
-
- movq mm3, mm0
- pfadd mm0, mm4
- pfmul mm0, [GOTOFF(ebx,PD_1_847)] ; mm0=z5
- pfmul mm3, [GOTOFF(ebx,PD_2_613)] ; mm3=(z10 * 2.613125930)
- pfmul mm4, [GOTOFF(ebx,PD_1_082)] ; mm4=(z12 * 1.082392200)
- pfsubr mm3, mm0 ; mm3=tmp12
- pfsub mm4, mm0 ; mm4=tmp10
-
- ; -- Final output stage
-
- pfsub mm3, mm1 ; mm3=tmp6
- movq mm5, mm6
- movq mm0, mm7
- pfadd mm6, mm1 ; mm6=data0=(00 10)
- pfadd mm7, mm3 ; mm7=data1=(01 11)
- pfsub mm5, mm1 ; mm5=data7=(07 17)
- pfsub mm0, mm3 ; mm0=data6=(06 16)
- pfsub mm2, mm3 ; mm2=tmp5
-
- movq mm1, [GOTOFF(ebx,PD_RNDINT_MAGIC)] ; mm1=[PD_RNDINT_MAGIC]
- pcmpeqd mm3, mm3
- psrld mm3, WORD_BIT ; mm3={0xFFFF 0x0000 0xFFFF 0x0000}
-
- pfadd mm6, mm1 ; mm6=roundint(data0/8)=(00 ** 10 **)
- pfadd mm7, mm1 ; mm7=roundint(data1/8)=(01 ** 11 **)
- pfadd mm0, mm1 ; mm0=roundint(data6/8)=(06 ** 16 **)
- pfadd mm5, mm1 ; mm5=roundint(data7/8)=(07 ** 17 **)
-
- pand mm6, mm3 ; mm6=(00 -- 10 --)
- pslld mm7, WORD_BIT ; mm7=(-- 01 -- 11)
- pand mm0, mm3 ; mm0=(06 -- 16 --)
- pslld mm5, WORD_BIT ; mm5=(-- 07 -- 17)
- por mm6, mm7 ; mm6=(00 01 10 11)
- por mm0, mm5 ; mm0=(06 07 16 17)
-
- movq mm1, MMWORD [wk(0)] ; mm1=tmp2
- movq mm3, MMWORD [wk(1)] ; mm3=tmp3
-
- pfadd mm4, mm2 ; mm4=tmp4
- movq mm7, mm1
- movq mm5, mm3
- pfadd mm1, mm2 ; mm1=data2=(02 12)
- pfadd mm3, mm4 ; mm3=data4=(04 14)
- pfsub mm7, mm2 ; mm7=data5=(05 15)
- pfsub mm5, mm4 ; mm5=data3=(03 13)
-
- movq mm2, [GOTOFF(ebx,PD_RNDINT_MAGIC)] ; mm2=[PD_RNDINT_MAGIC]
- pcmpeqd mm4, mm4
- psrld mm4, WORD_BIT ; mm4={0xFFFF 0x0000 0xFFFF 0x0000}
-
- pfadd mm3, mm2 ; mm3=roundint(data4/8)=(04 ** 14 **)
- pfadd mm7, mm2 ; mm7=roundint(data5/8)=(05 ** 15 **)
- pfadd mm1, mm2 ; mm1=roundint(data2/8)=(02 ** 12 **)
- pfadd mm5, mm2 ; mm5=roundint(data3/8)=(03 ** 13 **)
-
- pand mm3, mm4 ; mm3=(04 -- 14 --)
- pslld mm7, WORD_BIT ; mm7=(-- 05 -- 15)
- pand mm1, mm4 ; mm1=(02 -- 12 --)
- pslld mm5, WORD_BIT ; mm5=(-- 03 -- 13)
- por mm3, mm7 ; mm3=(04 05 14 15)
- por mm1, mm5 ; mm1=(02 03 12 13)
-
- movq mm2, [GOTOFF(ebx,PB_CENTERJSAMP)] ; mm2=[PB_CENTERJSAMP]
-
- packsswb mm6, mm3 ; mm6=(00 01 10 11 04 05 14 15)
- packsswb mm1, mm0 ; mm1=(02 03 12 13 06 07 16 17)
- paddb mm6, mm2
- paddb mm1, mm2
-
- movq mm4, mm6 ; transpose coefficients(phase 2)
- punpcklwd mm6, mm1 ; mm6=(00 01 02 03 10 11 12 13)
- punpckhwd mm4, mm1 ; mm4=(04 05 06 07 14 15 16 17)
-
- movq mm7, mm6 ; transpose coefficients(phase 3)
- punpckldq mm6, mm4 ; mm6=(00 01 02 03 04 05 06 07)
- punpckhdq mm7, mm4 ; mm7=(10 11 12 13 14 15 16 17)
-
- pushpic ebx ; save GOT address
-
- mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW]
- mov ebx, JSAMPROW [edi+1*SIZEOF_JSAMPROW]
- movq MMWORD [edx+eax*SIZEOF_JSAMPLE], mm6
- movq MMWORD [ebx+eax*SIZEOF_JSAMPLE], mm7
-
- poppic ebx ; restore GOT address
-
- add esi, byte 2*SIZEOF_FAST_FLOAT ; wsptr
- add edi, byte 2*SIZEOF_JSAMPROW
- dec ecx ; ctr
- jnz near .rowloop
-
- femms ; empty MMX/3DNow! state
-
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- pop ebx
- mov esp, ebp ; esp <- aligned ebp
- pop esp ; esp <- original ebp
- pop ebp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jidctflt-sse.asm b/contrib/libs/libjpeg-turbo/simd/i386/jidctflt-sse.asm
deleted file mode 100644
index b27ecfdf46..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jidctflt-sse.asm
+++ /dev/null
@@ -1,571 +0,0 @@
-;
-; jidctflt.asm - floating-point IDCT (SSE & MMX)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-;
-; This file contains a floating-point implementation of the inverse DCT
-; (Discrete Cosine Transform). The following code is based directly on
-; the IJG's original jidctflt.c; see the jidctflt.c for more details.
-
-%include "jsimdext.inc"
-%include "jdct.inc"
-
-; --------------------------------------------------------------------------
-
-%macro unpcklps2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(0 1 4 5)
- shufps %1, %2, 0x44
-%endmacro
-
-%macro unpckhps2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(2 3 6 7)
- shufps %1, %2, 0xEE
-%endmacro
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_idct_float_sse)
-
-EXTN(jconst_idct_float_sse):
-
-PD_1_414 times 4 dd 1.414213562373095048801689
-PD_1_847 times 4 dd 1.847759065022573512256366
-PD_1_082 times 4 dd 1.082392200292393968799446
-PD_M2_613 times 4 dd -2.613125929752753055713286
-PD_0_125 times 4 dd 0.125 ; 1/8
-PB_CENTERJSAMP times 8 db CENTERJSAMPLE
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-;
-; Perform dequantization and inverse DCT on one block of coefficients.
-;
-; GLOBAL(void)
-; jsimd_idct_float_sse(void *dct_table, JCOEFPTR coef_block,
-; JSAMPARRAY output_buf, JDIMENSION output_col)
-;
-
-%define dct_table(b) (b) + 8 ; void *dct_table
-%define coef_block(b) (b) + 12 ; JCOEFPTR coef_block
-%define output_buf(b) (b) + 16 ; JSAMPARRAY output_buf
-%define output_col(b) (b) + 20 ; JDIMENSION output_col
-
-%define original_ebp ebp + 0
-%define wk(i) ebp - (WK_NUM - (i)) * SIZEOF_XMMWORD
- ; xmmword wk[WK_NUM]
-%define WK_NUM 2
-%define workspace wk(0) - DCTSIZE2 * SIZEOF_FAST_FLOAT
- ; FAST_FLOAT workspace[DCTSIZE2]
-
- align 32
- GLOBAL_FUNCTION(jsimd_idct_float_sse)
-
-EXTN(jsimd_idct_float_sse):
- push ebp
- mov eax, esp ; eax = original ebp
- sub esp, byte 4
- and esp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [esp], eax
- mov ebp, esp ; ebp = aligned ebp
- lea esp, [workspace]
- push ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- get_GOT ebx ; get GOT address
-
- ; ---- Pass 1: process columns from input, store into work array.
-
-; mov eax, [original_ebp]
- mov edx, POINTER [dct_table(eax)] ; quantptr
- mov esi, JCOEFPTR [coef_block(eax)] ; inptr
- lea edi, [workspace] ; FAST_FLOAT *wsptr
- mov ecx, DCTSIZE/4 ; ctr
- alignx 16, 7
-.columnloop:
-%ifndef NO_ZERO_COLUMN_TEST_FLOAT_SSE
- mov eax, dword [DWBLOCK(1,0,esi,SIZEOF_JCOEF)]
- or eax, dword [DWBLOCK(2,0,esi,SIZEOF_JCOEF)]
- jnz near .columnDCT
-
- movq mm0, MMWORD [MMBLOCK(1,0,esi,SIZEOF_JCOEF)]
- movq mm1, MMWORD [MMBLOCK(2,0,esi,SIZEOF_JCOEF)]
- por mm0, MMWORD [MMBLOCK(3,0,esi,SIZEOF_JCOEF)]
- por mm1, MMWORD [MMBLOCK(4,0,esi,SIZEOF_JCOEF)]
- por mm0, MMWORD [MMBLOCK(5,0,esi,SIZEOF_JCOEF)]
- por mm1, MMWORD [MMBLOCK(6,0,esi,SIZEOF_JCOEF)]
- por mm0, MMWORD [MMBLOCK(7,0,esi,SIZEOF_JCOEF)]
- por mm1, mm0
- packsswb mm1, mm1
- movd eax, mm1
- test eax, eax
- jnz short .columnDCT
-
- ; -- AC terms all zero
-
- movq mm0, MMWORD [MMBLOCK(0,0,esi,SIZEOF_JCOEF)]
-
- punpckhwd mm1, mm0 ; mm1=(** 02 ** 03)
- punpcklwd mm0, mm0 ; mm0=(00 00 01 01)
- psrad mm1, (DWORD_BIT-WORD_BIT) ; mm1=in0H=(02 03)
- psrad mm0, (DWORD_BIT-WORD_BIT) ; mm0=in0L=(00 01)
- cvtpi2ps xmm3, mm1 ; xmm3=(02 03 ** **)
- cvtpi2ps xmm0, mm0 ; xmm0=(00 01 ** **)
- movlhps xmm0, xmm3 ; xmm0=in0=(00 01 02 03)
-
- mulps xmm0, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
-
- movaps xmm1, xmm0
- movaps xmm2, xmm0
- movaps xmm3, xmm0
-
- shufps xmm0, xmm0, 0x00 ; xmm0=(00 00 00 00)
- shufps xmm1, xmm1, 0x55 ; xmm1=(01 01 01 01)
- shufps xmm2, xmm2, 0xAA ; xmm2=(02 02 02 02)
- shufps xmm3, xmm3, 0xFF ; xmm3=(03 03 03 03)
-
- movaps XMMWORD [XMMBLOCK(0,0,edi,SIZEOF_FAST_FLOAT)], xmm0
- movaps XMMWORD [XMMBLOCK(0,1,edi,SIZEOF_FAST_FLOAT)], xmm0
- movaps XMMWORD [XMMBLOCK(1,0,edi,SIZEOF_FAST_FLOAT)], xmm1
- movaps XMMWORD [XMMBLOCK(1,1,edi,SIZEOF_FAST_FLOAT)], xmm1
- movaps XMMWORD [XMMBLOCK(2,0,edi,SIZEOF_FAST_FLOAT)], xmm2
- movaps XMMWORD [XMMBLOCK(2,1,edi,SIZEOF_FAST_FLOAT)], xmm2
- movaps XMMWORD [XMMBLOCK(3,0,edi,SIZEOF_FAST_FLOAT)], xmm3
- movaps XMMWORD [XMMBLOCK(3,1,edi,SIZEOF_FAST_FLOAT)], xmm3
- jmp near .nextcolumn
- alignx 16, 7
-%endif
-.columnDCT:
-
- ; -- Even part
-
- movq mm0, MMWORD [MMBLOCK(0,0,esi,SIZEOF_JCOEF)]
- movq mm1, MMWORD [MMBLOCK(2,0,esi,SIZEOF_JCOEF)]
- movq mm2, MMWORD [MMBLOCK(4,0,esi,SIZEOF_JCOEF)]
- movq mm3, MMWORD [MMBLOCK(6,0,esi,SIZEOF_JCOEF)]
-
- punpckhwd mm4, mm0 ; mm4=(** 02 ** 03)
- punpcklwd mm0, mm0 ; mm0=(00 00 01 01)
- punpckhwd mm5, mm1 ; mm5=(** 22 ** 23)
- punpcklwd mm1, mm1 ; mm1=(20 20 21 21)
-
- psrad mm4, (DWORD_BIT-WORD_BIT) ; mm4=in0H=(02 03)
- psrad mm0, (DWORD_BIT-WORD_BIT) ; mm0=in0L=(00 01)
- cvtpi2ps xmm4, mm4 ; xmm4=(02 03 ** **)
- cvtpi2ps xmm0, mm0 ; xmm0=(00 01 ** **)
- psrad mm5, (DWORD_BIT-WORD_BIT) ; mm5=in2H=(22 23)
- psrad mm1, (DWORD_BIT-WORD_BIT) ; mm1=in2L=(20 21)
- cvtpi2ps xmm5, mm5 ; xmm5=(22 23 ** **)
- cvtpi2ps xmm1, mm1 ; xmm1=(20 21 ** **)
-
- punpckhwd mm6, mm2 ; mm6=(** 42 ** 43)
- punpcklwd mm2, mm2 ; mm2=(40 40 41 41)
- punpckhwd mm7, mm3 ; mm7=(** 62 ** 63)
- punpcklwd mm3, mm3 ; mm3=(60 60 61 61)
-
- psrad mm6, (DWORD_BIT-WORD_BIT) ; mm6=in4H=(42 43)
- psrad mm2, (DWORD_BIT-WORD_BIT) ; mm2=in4L=(40 41)
- cvtpi2ps xmm6, mm6 ; xmm6=(42 43 ** **)
- cvtpi2ps xmm2, mm2 ; xmm2=(40 41 ** **)
- psrad mm7, (DWORD_BIT-WORD_BIT) ; mm7=in6H=(62 63)
- psrad mm3, (DWORD_BIT-WORD_BIT) ; mm3=in6L=(60 61)
- cvtpi2ps xmm7, mm7 ; xmm7=(62 63 ** **)
- cvtpi2ps xmm3, mm3 ; xmm3=(60 61 ** **)
-
- movlhps xmm0, xmm4 ; xmm0=in0=(00 01 02 03)
- movlhps xmm1, xmm5 ; xmm1=in2=(20 21 22 23)
- mulps xmm0, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
- mulps xmm1, XMMWORD [XMMBLOCK(2,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
-
- movlhps xmm2, xmm6 ; xmm2=in4=(40 41 42 43)
- movlhps xmm3, xmm7 ; xmm3=in6=(60 61 62 63)
- mulps xmm2, XMMWORD [XMMBLOCK(4,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
- mulps xmm3, XMMWORD [XMMBLOCK(6,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
-
- movaps xmm4, xmm0
- movaps xmm5, xmm1
- subps xmm0, xmm2 ; xmm0=tmp11
- subps xmm1, xmm3
- addps xmm4, xmm2 ; xmm4=tmp10
- addps xmm5, xmm3 ; xmm5=tmp13
-
- mulps xmm1, [GOTOFF(ebx,PD_1_414)]
- subps xmm1, xmm5 ; xmm1=tmp12
-
- movaps xmm6, xmm4
- movaps xmm7, xmm0
- subps xmm4, xmm5 ; xmm4=tmp3
- subps xmm0, xmm1 ; xmm0=tmp2
- addps xmm6, xmm5 ; xmm6=tmp0
- addps xmm7, xmm1 ; xmm7=tmp1
-
- movaps XMMWORD [wk(1)], xmm4 ; tmp3
- movaps XMMWORD [wk(0)], xmm0 ; tmp2
-
- ; -- Odd part
-
- movq mm4, MMWORD [MMBLOCK(1,0,esi,SIZEOF_JCOEF)]
- movq mm0, MMWORD [MMBLOCK(3,0,esi,SIZEOF_JCOEF)]
- movq mm5, MMWORD [MMBLOCK(5,0,esi,SIZEOF_JCOEF)]
- movq mm1, MMWORD [MMBLOCK(7,0,esi,SIZEOF_JCOEF)]
-
- punpckhwd mm6, mm4 ; mm6=(** 12 ** 13)
- punpcklwd mm4, mm4 ; mm4=(10 10 11 11)
- punpckhwd mm2, mm0 ; mm2=(** 32 ** 33)
- punpcklwd mm0, mm0 ; mm0=(30 30 31 31)
-
- psrad mm6, (DWORD_BIT-WORD_BIT) ; mm6=in1H=(12 13)
- psrad mm4, (DWORD_BIT-WORD_BIT) ; mm4=in1L=(10 11)
- cvtpi2ps xmm4, mm6 ; xmm4=(12 13 ** **)
- cvtpi2ps xmm2, mm4 ; xmm2=(10 11 ** **)
- psrad mm2, (DWORD_BIT-WORD_BIT) ; mm2=in3H=(32 33)
- psrad mm0, (DWORD_BIT-WORD_BIT) ; mm0=in3L=(30 31)
- cvtpi2ps xmm0, mm2 ; xmm0=(32 33 ** **)
- cvtpi2ps xmm3, mm0 ; xmm3=(30 31 ** **)
-
- punpckhwd mm7, mm5 ; mm7=(** 52 ** 53)
- punpcklwd mm5, mm5 ; mm5=(50 50 51 51)
- punpckhwd mm3, mm1 ; mm3=(** 72 ** 73)
- punpcklwd mm1, mm1 ; mm1=(70 70 71 71)
-
- movlhps xmm2, xmm4 ; xmm2=in1=(10 11 12 13)
- movlhps xmm3, xmm0 ; xmm3=in3=(30 31 32 33)
-
- psrad mm7, (DWORD_BIT-WORD_BIT) ; mm7=in5H=(52 53)
- psrad mm5, (DWORD_BIT-WORD_BIT) ; mm5=in5L=(50 51)
- cvtpi2ps xmm4, mm7 ; xmm4=(52 53 ** **)
- cvtpi2ps xmm5, mm5 ; xmm5=(50 51 ** **)
- psrad mm3, (DWORD_BIT-WORD_BIT) ; mm3=in7H=(72 73)
- psrad mm1, (DWORD_BIT-WORD_BIT) ; mm1=in7L=(70 71)
- cvtpi2ps xmm0, mm3 ; xmm0=(72 73 ** **)
- cvtpi2ps xmm1, mm1 ; xmm1=(70 71 ** **)
-
- mulps xmm2, XMMWORD [XMMBLOCK(1,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
- mulps xmm3, XMMWORD [XMMBLOCK(3,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
-
- movlhps xmm5, xmm4 ; xmm5=in5=(50 51 52 53)
- movlhps xmm1, xmm0 ; xmm1=in7=(70 71 72 73)
- mulps xmm5, XMMWORD [XMMBLOCK(5,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
- mulps xmm1, XMMWORD [XMMBLOCK(7,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
-
- movaps xmm4, xmm2
- movaps xmm0, xmm5
- addps xmm2, xmm1 ; xmm2=z11
- addps xmm5, xmm3 ; xmm5=z13
- subps xmm4, xmm1 ; xmm4=z12
- subps xmm0, xmm3 ; xmm0=z10
-
- movaps xmm1, xmm2
- subps xmm2, xmm5
- addps xmm1, xmm5 ; xmm1=tmp7
-
- mulps xmm2, [GOTOFF(ebx,PD_1_414)] ; xmm2=tmp11
-
- movaps xmm3, xmm0
- addps xmm0, xmm4
- mulps xmm0, [GOTOFF(ebx,PD_1_847)] ; xmm0=z5
- mulps xmm3, [GOTOFF(ebx,PD_M2_613)] ; xmm3=(z10 * -2.613125930)
- mulps xmm4, [GOTOFF(ebx,PD_1_082)] ; xmm4=(z12 * 1.082392200)
- addps xmm3, xmm0 ; xmm3=tmp12
- subps xmm4, xmm0 ; xmm4=tmp10
-
- ; -- Final output stage
-
- subps xmm3, xmm1 ; xmm3=tmp6
- movaps xmm5, xmm6
- movaps xmm0, xmm7
- addps xmm6, xmm1 ; xmm6=data0=(00 01 02 03)
- addps xmm7, xmm3 ; xmm7=data1=(10 11 12 13)
- subps xmm5, xmm1 ; xmm5=data7=(70 71 72 73)
- subps xmm0, xmm3 ; xmm0=data6=(60 61 62 63)
- subps xmm2, xmm3 ; xmm2=tmp5
-
- movaps xmm1, xmm6 ; transpose coefficients(phase 1)
- unpcklps xmm6, xmm7 ; xmm6=(00 10 01 11)
- unpckhps xmm1, xmm7 ; xmm1=(02 12 03 13)
- movaps xmm3, xmm0 ; transpose coefficients(phase 1)
- unpcklps xmm0, xmm5 ; xmm0=(60 70 61 71)
- unpckhps xmm3, xmm5 ; xmm3=(62 72 63 73)
-
- movaps xmm7, XMMWORD [wk(0)] ; xmm7=tmp2
- movaps xmm5, XMMWORD [wk(1)] ; xmm5=tmp3
-
- movaps XMMWORD [wk(0)], xmm0 ; wk(0)=(60 70 61 71)
- movaps XMMWORD [wk(1)], xmm3 ; wk(1)=(62 72 63 73)
-
- addps xmm4, xmm2 ; xmm4=tmp4
- movaps xmm0, xmm7
- movaps xmm3, xmm5
- addps xmm7, xmm2 ; xmm7=data2=(20 21 22 23)
- addps xmm5, xmm4 ; xmm5=data4=(40 41 42 43)
- subps xmm0, xmm2 ; xmm0=data5=(50 51 52 53)
- subps xmm3, xmm4 ; xmm3=data3=(30 31 32 33)
-
- movaps xmm2, xmm7 ; transpose coefficients(phase 1)
- unpcklps xmm7, xmm3 ; xmm7=(20 30 21 31)
- unpckhps xmm2, xmm3 ; xmm2=(22 32 23 33)
- movaps xmm4, xmm5 ; transpose coefficients(phase 1)
- unpcklps xmm5, xmm0 ; xmm5=(40 50 41 51)
- unpckhps xmm4, xmm0 ; xmm4=(42 52 43 53)
-
- movaps xmm3, xmm6 ; transpose coefficients(phase 2)
- unpcklps2 xmm6, xmm7 ; xmm6=(00 10 20 30)
- unpckhps2 xmm3, xmm7 ; xmm3=(01 11 21 31)
- movaps xmm0, xmm1 ; transpose coefficients(phase 2)
- unpcklps2 xmm1, xmm2 ; xmm1=(02 12 22 32)
- unpckhps2 xmm0, xmm2 ; xmm0=(03 13 23 33)
-
- movaps xmm7, XMMWORD [wk(0)] ; xmm7=(60 70 61 71)
- movaps xmm2, XMMWORD [wk(1)] ; xmm2=(62 72 63 73)
-
- movaps XMMWORD [XMMBLOCK(0,0,edi,SIZEOF_FAST_FLOAT)], xmm6
- movaps XMMWORD [XMMBLOCK(1,0,edi,SIZEOF_FAST_FLOAT)], xmm3
- movaps XMMWORD [XMMBLOCK(2,0,edi,SIZEOF_FAST_FLOAT)], xmm1
- movaps XMMWORD [XMMBLOCK(3,0,edi,SIZEOF_FAST_FLOAT)], xmm0
-
- movaps xmm6, xmm5 ; transpose coefficients(phase 2)
- unpcklps2 xmm5, xmm7 ; xmm5=(40 50 60 70)
- unpckhps2 xmm6, xmm7 ; xmm6=(41 51 61 71)
- movaps xmm3, xmm4 ; transpose coefficients(phase 2)
- unpcklps2 xmm4, xmm2 ; xmm4=(42 52 62 72)
- unpckhps2 xmm3, xmm2 ; xmm3=(43 53 63 73)
-
- movaps XMMWORD [XMMBLOCK(0,1,edi,SIZEOF_FAST_FLOAT)], xmm5
- movaps XMMWORD [XMMBLOCK(1,1,edi,SIZEOF_FAST_FLOAT)], xmm6
- movaps XMMWORD [XMMBLOCK(2,1,edi,SIZEOF_FAST_FLOAT)], xmm4
- movaps XMMWORD [XMMBLOCK(3,1,edi,SIZEOF_FAST_FLOAT)], xmm3
-
-.nextcolumn:
- add esi, byte 4*SIZEOF_JCOEF ; coef_block
- add edx, byte 4*SIZEOF_FLOAT_MULT_TYPE ; quantptr
- add edi, 4*DCTSIZE*SIZEOF_FAST_FLOAT ; wsptr
- dec ecx ; ctr
- jnz near .columnloop
-
- ; -- Prefetch the next coefficient block
-
- prefetchnta [esi + (DCTSIZE2-8)*SIZEOF_JCOEF + 0*32]
- prefetchnta [esi + (DCTSIZE2-8)*SIZEOF_JCOEF + 1*32]
- prefetchnta [esi + (DCTSIZE2-8)*SIZEOF_JCOEF + 2*32]
- prefetchnta [esi + (DCTSIZE2-8)*SIZEOF_JCOEF + 3*32]
-
- ; ---- Pass 2: process rows from work array, store into output array.
-
- mov eax, [original_ebp]
- lea esi, [workspace] ; FAST_FLOAT *wsptr
- mov edi, JSAMPARRAY [output_buf(eax)] ; (JSAMPROW *)
- mov eax, JDIMENSION [output_col(eax)]
- mov ecx, DCTSIZE/4 ; ctr
- alignx 16, 7
-.rowloop:
-
- ; -- Even part
-
- movaps xmm0, XMMWORD [XMMBLOCK(0,0,esi,SIZEOF_FAST_FLOAT)]
- movaps xmm1, XMMWORD [XMMBLOCK(2,0,esi,SIZEOF_FAST_FLOAT)]
- movaps xmm2, XMMWORD [XMMBLOCK(4,0,esi,SIZEOF_FAST_FLOAT)]
- movaps xmm3, XMMWORD [XMMBLOCK(6,0,esi,SIZEOF_FAST_FLOAT)]
-
- movaps xmm4, xmm0
- movaps xmm5, xmm1
- subps xmm0, xmm2 ; xmm0=tmp11
- subps xmm1, xmm3
- addps xmm4, xmm2 ; xmm4=tmp10
- addps xmm5, xmm3 ; xmm5=tmp13
-
- mulps xmm1, [GOTOFF(ebx,PD_1_414)]
- subps xmm1, xmm5 ; xmm1=tmp12
-
- movaps xmm6, xmm4
- movaps xmm7, xmm0
- subps xmm4, xmm5 ; xmm4=tmp3
- subps xmm0, xmm1 ; xmm0=tmp2
- addps xmm6, xmm5 ; xmm6=tmp0
- addps xmm7, xmm1 ; xmm7=tmp1
-
- movaps XMMWORD [wk(1)], xmm4 ; tmp3
- movaps XMMWORD [wk(0)], xmm0 ; tmp2
-
- ; -- Odd part
-
- movaps xmm2, XMMWORD [XMMBLOCK(1,0,esi,SIZEOF_FAST_FLOAT)]
- movaps xmm3, XMMWORD [XMMBLOCK(3,0,esi,SIZEOF_FAST_FLOAT)]
- movaps xmm5, XMMWORD [XMMBLOCK(5,0,esi,SIZEOF_FAST_FLOAT)]
- movaps xmm1, XMMWORD [XMMBLOCK(7,0,esi,SIZEOF_FAST_FLOAT)]
-
- movaps xmm4, xmm2
- movaps xmm0, xmm5
- addps xmm2, xmm1 ; xmm2=z11
- addps xmm5, xmm3 ; xmm5=z13
- subps xmm4, xmm1 ; xmm4=z12
- subps xmm0, xmm3 ; xmm0=z10
-
- movaps xmm1, xmm2
- subps xmm2, xmm5
- addps xmm1, xmm5 ; xmm1=tmp7
-
- mulps xmm2, [GOTOFF(ebx,PD_1_414)] ; xmm2=tmp11
-
- movaps xmm3, xmm0
- addps xmm0, xmm4
- mulps xmm0, [GOTOFF(ebx,PD_1_847)] ; xmm0=z5
- mulps xmm3, [GOTOFF(ebx,PD_M2_613)] ; xmm3=(z10 * -2.613125930)
- mulps xmm4, [GOTOFF(ebx,PD_1_082)] ; xmm4=(z12 * 1.082392200)
- addps xmm3, xmm0 ; xmm3=tmp12
- subps xmm4, xmm0 ; xmm4=tmp10
-
- ; -- Final output stage
-
- subps xmm3, xmm1 ; xmm3=tmp6
- movaps xmm5, xmm6
- movaps xmm0, xmm7
- addps xmm6, xmm1 ; xmm6=data0=(00 10 20 30)
- addps xmm7, xmm3 ; xmm7=data1=(01 11 21 31)
- subps xmm5, xmm1 ; xmm5=data7=(07 17 27 37)
- subps xmm0, xmm3 ; xmm0=data6=(06 16 26 36)
- subps xmm2, xmm3 ; xmm2=tmp5
-
- movaps xmm1, [GOTOFF(ebx,PD_0_125)] ; xmm1=[PD_0_125]
-
- mulps xmm6, xmm1 ; descale(1/8)
- mulps xmm7, xmm1 ; descale(1/8)
- mulps xmm5, xmm1 ; descale(1/8)
- mulps xmm0, xmm1 ; descale(1/8)
-
- movhlps xmm3, xmm6
- movhlps xmm1, xmm7
- cvtps2pi mm0, xmm6 ; round to int32, mm0=data0L=(00 10)
- cvtps2pi mm1, xmm7 ; round to int32, mm1=data1L=(01 11)
- cvtps2pi mm2, xmm3 ; round to int32, mm2=data0H=(20 30)
- cvtps2pi mm3, xmm1 ; round to int32, mm3=data1H=(21 31)
- packssdw mm0, mm2 ; mm0=data0=(00 10 20 30)
- packssdw mm1, mm3 ; mm1=data1=(01 11 21 31)
-
- movhlps xmm6, xmm5
- movhlps xmm7, xmm0
- cvtps2pi mm4, xmm5 ; round to int32, mm4=data7L=(07 17)
- cvtps2pi mm5, xmm0 ; round to int32, mm5=data6L=(06 16)
- cvtps2pi mm6, xmm6 ; round to int32, mm6=data7H=(27 37)
- cvtps2pi mm7, xmm7 ; round to int32, mm7=data6H=(26 36)
- packssdw mm4, mm6 ; mm4=data7=(07 17 27 37)
- packssdw mm5, mm7 ; mm5=data6=(06 16 26 36)
-
- packsswb mm0, mm5 ; mm0=(00 10 20 30 06 16 26 36)
- packsswb mm1, mm4 ; mm1=(01 11 21 31 07 17 27 37)
-
- movaps xmm3, XMMWORD [wk(0)] ; xmm3=tmp2
- movaps xmm1, XMMWORD [wk(1)] ; xmm1=tmp3
-
- movaps xmm6, [GOTOFF(ebx,PD_0_125)] ; xmm6=[PD_0_125]
-
- addps xmm4, xmm2 ; xmm4=tmp4
- movaps xmm5, xmm3
- movaps xmm0, xmm1
- addps xmm3, xmm2 ; xmm3=data2=(02 12 22 32)
- addps xmm1, xmm4 ; xmm1=data4=(04 14 24 34)
- subps xmm5, xmm2 ; xmm5=data5=(05 15 25 35)
- subps xmm0, xmm4 ; xmm0=data3=(03 13 23 33)
-
- mulps xmm3, xmm6 ; descale(1/8)
- mulps xmm1, xmm6 ; descale(1/8)
- mulps xmm5, xmm6 ; descale(1/8)
- mulps xmm0, xmm6 ; descale(1/8)
-
- movhlps xmm7, xmm3
- movhlps xmm2, xmm1
- cvtps2pi mm2, xmm3 ; round to int32, mm2=data2L=(02 12)
- cvtps2pi mm3, xmm1 ; round to int32, mm3=data4L=(04 14)
- cvtps2pi mm6, xmm7 ; round to int32, mm6=data2H=(22 32)
- cvtps2pi mm7, xmm2 ; round to int32, mm7=data4H=(24 34)
- packssdw mm2, mm6 ; mm2=data2=(02 12 22 32)
- packssdw mm3, mm7 ; mm3=data4=(04 14 24 34)
-
- movhlps xmm4, xmm5
- movhlps xmm6, xmm0
- cvtps2pi mm5, xmm5 ; round to int32, mm5=data5L=(05 15)
- cvtps2pi mm4, xmm0 ; round to int32, mm4=data3L=(03 13)
- cvtps2pi mm6, xmm4 ; round to int32, mm6=data5H=(25 35)
- cvtps2pi mm7, xmm6 ; round to int32, mm7=data3H=(23 33)
- packssdw mm5, mm6 ; mm5=data5=(05 15 25 35)
- packssdw mm4, mm7 ; mm4=data3=(03 13 23 33)
-
- movq mm6, [GOTOFF(ebx,PB_CENTERJSAMP)] ; mm6=[PB_CENTERJSAMP]
-
- packsswb mm2, mm3 ; mm2=(02 12 22 32 04 14 24 34)
- packsswb mm4, mm5 ; mm4=(03 13 23 33 05 15 25 35)
-
- paddb mm0, mm6
- paddb mm1, mm6
- paddb mm2, mm6
- paddb mm4, mm6
-
- movq mm7, mm0 ; transpose coefficients(phase 1)
- punpcklbw mm0, mm1 ; mm0=(00 01 10 11 20 21 30 31)
- punpckhbw mm7, mm1 ; mm7=(06 07 16 17 26 27 36 37)
- movq mm3, mm2 ; transpose coefficients(phase 1)
- punpcklbw mm2, mm4 ; mm2=(02 03 12 13 22 23 32 33)
- punpckhbw mm3, mm4 ; mm3=(04 05 14 15 24 25 34 35)
-
- movq mm5, mm0 ; transpose coefficients(phase 2)
- punpcklwd mm0, mm2 ; mm0=(00 01 02 03 10 11 12 13)
- punpckhwd mm5, mm2 ; mm5=(20 21 22 23 30 31 32 33)
- movq mm6, mm3 ; transpose coefficients(phase 2)
- punpcklwd mm3, mm7 ; mm3=(04 05 06 07 14 15 16 17)
- punpckhwd mm6, mm7 ; mm6=(24 25 26 27 34 35 36 37)
-
- movq mm1, mm0 ; transpose coefficients(phase 3)
- punpckldq mm0, mm3 ; mm0=(00 01 02 03 04 05 06 07)
- punpckhdq mm1, mm3 ; mm1=(10 11 12 13 14 15 16 17)
- movq mm4, mm5 ; transpose coefficients(phase 3)
- punpckldq mm5, mm6 ; mm5=(20 21 22 23 24 25 26 27)
- punpckhdq mm4, mm6 ; mm4=(30 31 32 33 34 35 36 37)
-
- pushpic ebx ; save GOT address
-
- mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW]
- mov ebx, JSAMPROW [edi+1*SIZEOF_JSAMPROW]
- movq MMWORD [edx+eax*SIZEOF_JSAMPLE], mm0
- movq MMWORD [ebx+eax*SIZEOF_JSAMPLE], mm1
- mov edx, JSAMPROW [edi+2*SIZEOF_JSAMPROW]
- mov ebx, JSAMPROW [edi+3*SIZEOF_JSAMPROW]
- movq MMWORD [edx+eax*SIZEOF_JSAMPLE], mm5
- movq MMWORD [ebx+eax*SIZEOF_JSAMPLE], mm4
-
- poppic ebx ; restore GOT address
-
- add esi, byte 4*SIZEOF_FAST_FLOAT ; wsptr
- add edi, byte 4*SIZEOF_JSAMPROW
- dec ecx ; ctr
- jnz near .rowloop
-
- emms ; empty MMX state
-
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- pop ebx
- mov esp, ebp ; esp <- aligned ebp
- pop esp ; esp <- original ebp
- pop ebp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jidctflt-sse2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jidctflt-sse2.asm
deleted file mode 100644
index c646eaef76..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jidctflt-sse2.asm
+++ /dev/null
@@ -1,497 +0,0 @@
-;
-; jidctflt.asm - floating-point IDCT (SSE & SSE2)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-;
-; This file contains a floating-point implementation of the inverse DCT
-; (Discrete Cosine Transform). The following code is based directly on
-; the IJG's original jidctflt.c; see the jidctflt.c for more details.
-
-%include "jsimdext.inc"
-%include "jdct.inc"
-
-; --------------------------------------------------------------------------
-
-%macro unpcklps2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(0 1 4 5)
- shufps %1, %2, 0x44
-%endmacro
-
-%macro unpckhps2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(2 3 6 7)
- shufps %1, %2, 0xEE
-%endmacro
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_idct_float_sse2)
-
-EXTN(jconst_idct_float_sse2):
-
-PD_1_414 times 4 dd 1.414213562373095048801689
-PD_1_847 times 4 dd 1.847759065022573512256366
-PD_1_082 times 4 dd 1.082392200292393968799446
-PD_M2_613 times 4 dd -2.613125929752753055713286
-PD_RNDINT_MAGIC times 4 dd 100663296.0 ; (float)(0x00C00000 << 3)
-PB_CENTERJSAMP times 16 db CENTERJSAMPLE
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-;
-; Perform dequantization and inverse DCT on one block of coefficients.
-;
-; GLOBAL(void)
-; jsimd_idct_float_sse2(void *dct_table, JCOEFPTR coef_block,
-; JSAMPARRAY output_buf, JDIMENSION output_col)
-;
-
-%define dct_table(b) (b) + 8 ; void *dct_table
-%define coef_block(b) (b) + 12 ; JCOEFPTR coef_block
-%define output_buf(b) (b) + 16 ; JSAMPARRAY output_buf
-%define output_col(b) (b) + 20 ; JDIMENSION output_col
-
-%define original_ebp ebp + 0
-%define wk(i) ebp - (WK_NUM - (i)) * SIZEOF_XMMWORD
- ; xmmword wk[WK_NUM]
-%define WK_NUM 2
-%define workspace wk(0) - DCTSIZE2 * SIZEOF_FAST_FLOAT
- ; FAST_FLOAT workspace[DCTSIZE2]
-
- align 32
- GLOBAL_FUNCTION(jsimd_idct_float_sse2)
-
-EXTN(jsimd_idct_float_sse2):
- push ebp
- mov eax, esp ; eax = original ebp
- sub esp, byte 4
- and esp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [esp], eax
- mov ebp, esp ; ebp = aligned ebp
- lea esp, [workspace]
- push ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- get_GOT ebx ; get GOT address
-
- ; ---- Pass 1: process columns from input, store into work array.
-
-; mov eax, [original_ebp]
- mov edx, POINTER [dct_table(eax)] ; quantptr
- mov esi, JCOEFPTR [coef_block(eax)] ; inptr
- lea edi, [workspace] ; FAST_FLOAT *wsptr
- mov ecx, DCTSIZE/4 ; ctr
- alignx 16, 7
-.columnloop:
-%ifndef NO_ZERO_COLUMN_TEST_FLOAT_SSE
- mov eax, dword [DWBLOCK(1,0,esi,SIZEOF_JCOEF)]
- or eax, dword [DWBLOCK(2,0,esi,SIZEOF_JCOEF)]
- jnz near .columnDCT
-
- movq xmm1, XMM_MMWORD [MMBLOCK(1,0,esi,SIZEOF_JCOEF)]
- movq xmm2, XMM_MMWORD [MMBLOCK(2,0,esi,SIZEOF_JCOEF)]
- movq xmm3, XMM_MMWORD [MMBLOCK(3,0,esi,SIZEOF_JCOEF)]
- movq xmm4, XMM_MMWORD [MMBLOCK(4,0,esi,SIZEOF_JCOEF)]
- movq xmm5, XMM_MMWORD [MMBLOCK(5,0,esi,SIZEOF_JCOEF)]
- movq xmm6, XMM_MMWORD [MMBLOCK(6,0,esi,SIZEOF_JCOEF)]
- movq xmm7, XMM_MMWORD [MMBLOCK(7,0,esi,SIZEOF_JCOEF)]
- por xmm1, xmm2
- por xmm3, xmm4
- por xmm5, xmm6
- por xmm1, xmm3
- por xmm5, xmm7
- por xmm1, xmm5
- packsswb xmm1, xmm1
- movd eax, xmm1
- test eax, eax
- jnz short .columnDCT
-
- ; -- AC terms all zero
-
- movq xmm0, XMM_MMWORD [MMBLOCK(0,0,esi,SIZEOF_JCOEF)]
-
- punpcklwd xmm0, xmm0 ; xmm0=(00 00 01 01 02 02 03 03)
- psrad xmm0, (DWORD_BIT-WORD_BIT) ; xmm0=in0=(00 01 02 03)
- cvtdq2ps xmm0, xmm0 ; xmm0=in0=(00 01 02 03)
-
- mulps xmm0, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
-
- movaps xmm1, xmm0
- movaps xmm2, xmm0
- movaps xmm3, xmm0
-
- shufps xmm0, xmm0, 0x00 ; xmm0=(00 00 00 00)
- shufps xmm1, xmm1, 0x55 ; xmm1=(01 01 01 01)
- shufps xmm2, xmm2, 0xAA ; xmm2=(02 02 02 02)
- shufps xmm3, xmm3, 0xFF ; xmm3=(03 03 03 03)
-
- movaps XMMWORD [XMMBLOCK(0,0,edi,SIZEOF_FAST_FLOAT)], xmm0
- movaps XMMWORD [XMMBLOCK(0,1,edi,SIZEOF_FAST_FLOAT)], xmm0
- movaps XMMWORD [XMMBLOCK(1,0,edi,SIZEOF_FAST_FLOAT)], xmm1
- movaps XMMWORD [XMMBLOCK(1,1,edi,SIZEOF_FAST_FLOAT)], xmm1
- movaps XMMWORD [XMMBLOCK(2,0,edi,SIZEOF_FAST_FLOAT)], xmm2
- movaps XMMWORD [XMMBLOCK(2,1,edi,SIZEOF_FAST_FLOAT)], xmm2
- movaps XMMWORD [XMMBLOCK(3,0,edi,SIZEOF_FAST_FLOAT)], xmm3
- movaps XMMWORD [XMMBLOCK(3,1,edi,SIZEOF_FAST_FLOAT)], xmm3
- jmp near .nextcolumn
- alignx 16, 7
-%endif
-.columnDCT:
-
- ; -- Even part
-
- movq xmm0, XMM_MMWORD [MMBLOCK(0,0,esi,SIZEOF_JCOEF)]
- movq xmm1, XMM_MMWORD [MMBLOCK(2,0,esi,SIZEOF_JCOEF)]
- movq xmm2, XMM_MMWORD [MMBLOCK(4,0,esi,SIZEOF_JCOEF)]
- movq xmm3, XMM_MMWORD [MMBLOCK(6,0,esi,SIZEOF_JCOEF)]
-
- punpcklwd xmm0, xmm0 ; xmm0=(00 00 01 01 02 02 03 03)
- punpcklwd xmm1, xmm1 ; xmm1=(20 20 21 21 22 22 23 23)
- psrad xmm0, (DWORD_BIT-WORD_BIT) ; xmm0=in0=(00 01 02 03)
- psrad xmm1, (DWORD_BIT-WORD_BIT) ; xmm1=in2=(20 21 22 23)
- cvtdq2ps xmm0, xmm0 ; xmm0=in0=(00 01 02 03)
- cvtdq2ps xmm1, xmm1 ; xmm1=in2=(20 21 22 23)
-
- punpcklwd xmm2, xmm2 ; xmm2=(40 40 41 41 42 42 43 43)
- punpcklwd xmm3, xmm3 ; xmm3=(60 60 61 61 62 62 63 63)
- psrad xmm2, (DWORD_BIT-WORD_BIT) ; xmm2=in4=(40 41 42 43)
- psrad xmm3, (DWORD_BIT-WORD_BIT) ; xmm3=in6=(60 61 62 63)
- cvtdq2ps xmm2, xmm2 ; xmm2=in4=(40 41 42 43)
- cvtdq2ps xmm3, xmm3 ; xmm3=in6=(60 61 62 63)
-
- mulps xmm0, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
- mulps xmm1, XMMWORD [XMMBLOCK(2,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
- mulps xmm2, XMMWORD [XMMBLOCK(4,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
- mulps xmm3, XMMWORD [XMMBLOCK(6,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
-
- movaps xmm4, xmm0
- movaps xmm5, xmm1
- subps xmm0, xmm2 ; xmm0=tmp11
- subps xmm1, xmm3
- addps xmm4, xmm2 ; xmm4=tmp10
- addps xmm5, xmm3 ; xmm5=tmp13
-
- mulps xmm1, [GOTOFF(ebx,PD_1_414)]
- subps xmm1, xmm5 ; xmm1=tmp12
-
- movaps xmm6, xmm4
- movaps xmm7, xmm0
- subps xmm4, xmm5 ; xmm4=tmp3
- subps xmm0, xmm1 ; xmm0=tmp2
- addps xmm6, xmm5 ; xmm6=tmp0
- addps xmm7, xmm1 ; xmm7=tmp1
-
- movaps XMMWORD [wk(1)], xmm4 ; tmp3
- movaps XMMWORD [wk(0)], xmm0 ; tmp2
-
- ; -- Odd part
-
- movq xmm2, XMM_MMWORD [MMBLOCK(1,0,esi,SIZEOF_JCOEF)]
- movq xmm3, XMM_MMWORD [MMBLOCK(3,0,esi,SIZEOF_JCOEF)]
- movq xmm5, XMM_MMWORD [MMBLOCK(5,0,esi,SIZEOF_JCOEF)]
- movq xmm1, XMM_MMWORD [MMBLOCK(7,0,esi,SIZEOF_JCOEF)]
-
- punpcklwd xmm2, xmm2 ; xmm2=(10 10 11 11 12 12 13 13)
- punpcklwd xmm3, xmm3 ; xmm3=(30 30 31 31 32 32 33 33)
- psrad xmm2, (DWORD_BIT-WORD_BIT) ; xmm2=in1=(10 11 12 13)
- psrad xmm3, (DWORD_BIT-WORD_BIT) ; xmm3=in3=(30 31 32 33)
- cvtdq2ps xmm2, xmm2 ; xmm2=in1=(10 11 12 13)
- cvtdq2ps xmm3, xmm3 ; xmm3=in3=(30 31 32 33)
-
- punpcklwd xmm5, xmm5 ; xmm5=(50 50 51 51 52 52 53 53)
- punpcklwd xmm1, xmm1 ; xmm1=(70 70 71 71 72 72 73 73)
- psrad xmm5, (DWORD_BIT-WORD_BIT) ; xmm5=in5=(50 51 52 53)
- psrad xmm1, (DWORD_BIT-WORD_BIT) ; xmm1=in7=(70 71 72 73)
- cvtdq2ps xmm5, xmm5 ; xmm5=in5=(50 51 52 53)
- cvtdq2ps xmm1, xmm1 ; xmm1=in7=(70 71 72 73)
-
- mulps xmm2, XMMWORD [XMMBLOCK(1,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
- mulps xmm3, XMMWORD [XMMBLOCK(3,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
- mulps xmm5, XMMWORD [XMMBLOCK(5,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
- mulps xmm1, XMMWORD [XMMBLOCK(7,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
-
- movaps xmm4, xmm2
- movaps xmm0, xmm5
- addps xmm2, xmm1 ; xmm2=z11
- addps xmm5, xmm3 ; xmm5=z13
- subps xmm4, xmm1 ; xmm4=z12
- subps xmm0, xmm3 ; xmm0=z10
-
- movaps xmm1, xmm2
- subps xmm2, xmm5
- addps xmm1, xmm5 ; xmm1=tmp7
-
- mulps xmm2, [GOTOFF(ebx,PD_1_414)] ; xmm2=tmp11
-
- movaps xmm3, xmm0
- addps xmm0, xmm4
- mulps xmm0, [GOTOFF(ebx,PD_1_847)] ; xmm0=z5
- mulps xmm3, [GOTOFF(ebx,PD_M2_613)] ; xmm3=(z10 * -2.613125930)
- mulps xmm4, [GOTOFF(ebx,PD_1_082)] ; xmm4=(z12 * 1.082392200)
- addps xmm3, xmm0 ; xmm3=tmp12
- subps xmm4, xmm0 ; xmm4=tmp10
-
- ; -- Final output stage
-
- subps xmm3, xmm1 ; xmm3=tmp6
- movaps xmm5, xmm6
- movaps xmm0, xmm7
- addps xmm6, xmm1 ; xmm6=data0=(00 01 02 03)
- addps xmm7, xmm3 ; xmm7=data1=(10 11 12 13)
- subps xmm5, xmm1 ; xmm5=data7=(70 71 72 73)
- subps xmm0, xmm3 ; xmm0=data6=(60 61 62 63)
- subps xmm2, xmm3 ; xmm2=tmp5
-
- movaps xmm1, xmm6 ; transpose coefficients(phase 1)
- unpcklps xmm6, xmm7 ; xmm6=(00 10 01 11)
- unpckhps xmm1, xmm7 ; xmm1=(02 12 03 13)
- movaps xmm3, xmm0 ; transpose coefficients(phase 1)
- unpcklps xmm0, xmm5 ; xmm0=(60 70 61 71)
- unpckhps xmm3, xmm5 ; xmm3=(62 72 63 73)
-
- movaps xmm7, XMMWORD [wk(0)] ; xmm7=tmp2
- movaps xmm5, XMMWORD [wk(1)] ; xmm5=tmp3
-
- movaps XMMWORD [wk(0)], xmm0 ; wk(0)=(60 70 61 71)
- movaps XMMWORD [wk(1)], xmm3 ; wk(1)=(62 72 63 73)
-
- addps xmm4, xmm2 ; xmm4=tmp4
- movaps xmm0, xmm7
- movaps xmm3, xmm5
- addps xmm7, xmm2 ; xmm7=data2=(20 21 22 23)
- addps xmm5, xmm4 ; xmm5=data4=(40 41 42 43)
- subps xmm0, xmm2 ; xmm0=data5=(50 51 52 53)
- subps xmm3, xmm4 ; xmm3=data3=(30 31 32 33)
-
- movaps xmm2, xmm7 ; transpose coefficients(phase 1)
- unpcklps xmm7, xmm3 ; xmm7=(20 30 21 31)
- unpckhps xmm2, xmm3 ; xmm2=(22 32 23 33)
- movaps xmm4, xmm5 ; transpose coefficients(phase 1)
- unpcklps xmm5, xmm0 ; xmm5=(40 50 41 51)
- unpckhps xmm4, xmm0 ; xmm4=(42 52 43 53)
-
- movaps xmm3, xmm6 ; transpose coefficients(phase 2)
- unpcklps2 xmm6, xmm7 ; xmm6=(00 10 20 30)
- unpckhps2 xmm3, xmm7 ; xmm3=(01 11 21 31)
- movaps xmm0, xmm1 ; transpose coefficients(phase 2)
- unpcklps2 xmm1, xmm2 ; xmm1=(02 12 22 32)
- unpckhps2 xmm0, xmm2 ; xmm0=(03 13 23 33)
-
- movaps xmm7, XMMWORD [wk(0)] ; xmm7=(60 70 61 71)
- movaps xmm2, XMMWORD [wk(1)] ; xmm2=(62 72 63 73)
-
- movaps XMMWORD [XMMBLOCK(0,0,edi,SIZEOF_FAST_FLOAT)], xmm6
- movaps XMMWORD [XMMBLOCK(1,0,edi,SIZEOF_FAST_FLOAT)], xmm3
- movaps XMMWORD [XMMBLOCK(2,0,edi,SIZEOF_FAST_FLOAT)], xmm1
- movaps XMMWORD [XMMBLOCK(3,0,edi,SIZEOF_FAST_FLOAT)], xmm0
-
- movaps xmm6, xmm5 ; transpose coefficients(phase 2)
- unpcklps2 xmm5, xmm7 ; xmm5=(40 50 60 70)
- unpckhps2 xmm6, xmm7 ; xmm6=(41 51 61 71)
- movaps xmm3, xmm4 ; transpose coefficients(phase 2)
- unpcklps2 xmm4, xmm2 ; xmm4=(42 52 62 72)
- unpckhps2 xmm3, xmm2 ; xmm3=(43 53 63 73)
-
- movaps XMMWORD [XMMBLOCK(0,1,edi,SIZEOF_FAST_FLOAT)], xmm5
- movaps XMMWORD [XMMBLOCK(1,1,edi,SIZEOF_FAST_FLOAT)], xmm6
- movaps XMMWORD [XMMBLOCK(2,1,edi,SIZEOF_FAST_FLOAT)], xmm4
- movaps XMMWORD [XMMBLOCK(3,1,edi,SIZEOF_FAST_FLOAT)], xmm3
-
-.nextcolumn:
- add esi, byte 4*SIZEOF_JCOEF ; coef_block
- add edx, byte 4*SIZEOF_FLOAT_MULT_TYPE ; quantptr
- add edi, 4*DCTSIZE*SIZEOF_FAST_FLOAT ; wsptr
- dec ecx ; ctr
- jnz near .columnloop
-
- ; -- Prefetch the next coefficient block
-
- prefetchnta [esi + (DCTSIZE2-8)*SIZEOF_JCOEF + 0*32]
- prefetchnta [esi + (DCTSIZE2-8)*SIZEOF_JCOEF + 1*32]
- prefetchnta [esi + (DCTSIZE2-8)*SIZEOF_JCOEF + 2*32]
- prefetchnta [esi + (DCTSIZE2-8)*SIZEOF_JCOEF + 3*32]
-
- ; ---- Pass 2: process rows from work array, store into output array.
-
- mov eax, [original_ebp]
- lea esi, [workspace] ; FAST_FLOAT *wsptr
- mov edi, JSAMPARRAY [output_buf(eax)] ; (JSAMPROW *)
- mov eax, JDIMENSION [output_col(eax)]
- mov ecx, DCTSIZE/4 ; ctr
- alignx 16, 7
-.rowloop:
-
- ; -- Even part
-
- movaps xmm0, XMMWORD [XMMBLOCK(0,0,esi,SIZEOF_FAST_FLOAT)]
- movaps xmm1, XMMWORD [XMMBLOCK(2,0,esi,SIZEOF_FAST_FLOAT)]
- movaps xmm2, XMMWORD [XMMBLOCK(4,0,esi,SIZEOF_FAST_FLOAT)]
- movaps xmm3, XMMWORD [XMMBLOCK(6,0,esi,SIZEOF_FAST_FLOAT)]
-
- movaps xmm4, xmm0
- movaps xmm5, xmm1
- subps xmm0, xmm2 ; xmm0=tmp11
- subps xmm1, xmm3
- addps xmm4, xmm2 ; xmm4=tmp10
- addps xmm5, xmm3 ; xmm5=tmp13
-
- mulps xmm1, [GOTOFF(ebx,PD_1_414)]
- subps xmm1, xmm5 ; xmm1=tmp12
-
- movaps xmm6, xmm4
- movaps xmm7, xmm0
- subps xmm4, xmm5 ; xmm4=tmp3
- subps xmm0, xmm1 ; xmm0=tmp2
- addps xmm6, xmm5 ; xmm6=tmp0
- addps xmm7, xmm1 ; xmm7=tmp1
-
- movaps XMMWORD [wk(1)], xmm4 ; tmp3
- movaps XMMWORD [wk(0)], xmm0 ; tmp2
-
- ; -- Odd part
-
- movaps xmm2, XMMWORD [XMMBLOCK(1,0,esi,SIZEOF_FAST_FLOAT)]
- movaps xmm3, XMMWORD [XMMBLOCK(3,0,esi,SIZEOF_FAST_FLOAT)]
- movaps xmm5, XMMWORD [XMMBLOCK(5,0,esi,SIZEOF_FAST_FLOAT)]
- movaps xmm1, XMMWORD [XMMBLOCK(7,0,esi,SIZEOF_FAST_FLOAT)]
-
- movaps xmm4, xmm2
- movaps xmm0, xmm5
- addps xmm2, xmm1 ; xmm2=z11
- addps xmm5, xmm3 ; xmm5=z13
- subps xmm4, xmm1 ; xmm4=z12
- subps xmm0, xmm3 ; xmm0=z10
-
- movaps xmm1, xmm2
- subps xmm2, xmm5
- addps xmm1, xmm5 ; xmm1=tmp7
-
- mulps xmm2, [GOTOFF(ebx,PD_1_414)] ; xmm2=tmp11
-
- movaps xmm3, xmm0
- addps xmm0, xmm4
- mulps xmm0, [GOTOFF(ebx,PD_1_847)] ; xmm0=z5
- mulps xmm3, [GOTOFF(ebx,PD_M2_613)] ; xmm3=(z10 * -2.613125930)
- mulps xmm4, [GOTOFF(ebx,PD_1_082)] ; xmm4=(z12 * 1.082392200)
- addps xmm3, xmm0 ; xmm3=tmp12
- subps xmm4, xmm0 ; xmm4=tmp10
-
- ; -- Final output stage
-
- subps xmm3, xmm1 ; xmm3=tmp6
- movaps xmm5, xmm6
- movaps xmm0, xmm7
- addps xmm6, xmm1 ; xmm6=data0=(00 10 20 30)
- addps xmm7, xmm3 ; xmm7=data1=(01 11 21 31)
- subps xmm5, xmm1 ; xmm5=data7=(07 17 27 37)
- subps xmm0, xmm3 ; xmm0=data6=(06 16 26 36)
- subps xmm2, xmm3 ; xmm2=tmp5
-
- movaps xmm1, [GOTOFF(ebx,PD_RNDINT_MAGIC)] ; xmm1=[PD_RNDINT_MAGIC]
- pcmpeqd xmm3, xmm3
- psrld xmm3, WORD_BIT ; xmm3={0xFFFF 0x0000 0xFFFF 0x0000 ..}
-
- addps xmm6, xmm1 ; xmm6=roundint(data0/8)=(00 ** 10 ** 20 ** 30 **)
- addps xmm7, xmm1 ; xmm7=roundint(data1/8)=(01 ** 11 ** 21 ** 31 **)
- addps xmm0, xmm1 ; xmm0=roundint(data6/8)=(06 ** 16 ** 26 ** 36 **)
- addps xmm5, xmm1 ; xmm5=roundint(data7/8)=(07 ** 17 ** 27 ** 37 **)
-
- pand xmm6, xmm3 ; xmm6=(00 -- 10 -- 20 -- 30 --)
- pslld xmm7, WORD_BIT ; xmm7=(-- 01 -- 11 -- 21 -- 31)
- pand xmm0, xmm3 ; xmm0=(06 -- 16 -- 26 -- 36 --)
- pslld xmm5, WORD_BIT ; xmm5=(-- 07 -- 17 -- 27 -- 37)
- por xmm6, xmm7 ; xmm6=(00 01 10 11 20 21 30 31)
- por xmm0, xmm5 ; xmm0=(06 07 16 17 26 27 36 37)
-
- movaps xmm1, XMMWORD [wk(0)] ; xmm1=tmp2
- movaps xmm3, XMMWORD [wk(1)] ; xmm3=tmp3
-
- addps xmm4, xmm2 ; xmm4=tmp4
- movaps xmm7, xmm1
- movaps xmm5, xmm3
- addps xmm1, xmm2 ; xmm1=data2=(02 12 22 32)
- addps xmm3, xmm4 ; xmm3=data4=(04 14 24 34)
- subps xmm7, xmm2 ; xmm7=data5=(05 15 25 35)
- subps xmm5, xmm4 ; xmm5=data3=(03 13 23 33)
-
- movaps xmm2, [GOTOFF(ebx,PD_RNDINT_MAGIC)] ; xmm2=[PD_RNDINT_MAGIC]
- pcmpeqd xmm4, xmm4
- psrld xmm4, WORD_BIT ; xmm4={0xFFFF 0x0000 0xFFFF 0x0000 ..}
-
- addps xmm3, xmm2 ; xmm3=roundint(data4/8)=(04 ** 14 ** 24 ** 34 **)
- addps xmm7, xmm2 ; xmm7=roundint(data5/8)=(05 ** 15 ** 25 ** 35 **)
- addps xmm1, xmm2 ; xmm1=roundint(data2/8)=(02 ** 12 ** 22 ** 32 **)
- addps xmm5, xmm2 ; xmm5=roundint(data3/8)=(03 ** 13 ** 23 ** 33 **)
-
- pand xmm3, xmm4 ; xmm3=(04 -- 14 -- 24 -- 34 --)
- pslld xmm7, WORD_BIT ; xmm7=(-- 05 -- 15 -- 25 -- 35)
- pand xmm1, xmm4 ; xmm1=(02 -- 12 -- 22 -- 32 --)
- pslld xmm5, WORD_BIT ; xmm5=(-- 03 -- 13 -- 23 -- 33)
- por xmm3, xmm7 ; xmm3=(04 05 14 15 24 25 34 35)
- por xmm1, xmm5 ; xmm1=(02 03 12 13 22 23 32 33)
-
- movdqa xmm2, [GOTOFF(ebx,PB_CENTERJSAMP)] ; xmm2=[PB_CENTERJSAMP]
-
- packsswb xmm6, xmm3 ; xmm6=(00 01 10 11 20 21 30 31 04 05 14 15 24 25 34 35)
- packsswb xmm1, xmm0 ; xmm1=(02 03 12 13 22 23 32 33 06 07 16 17 26 27 36 37)
- paddb xmm6, xmm2
- paddb xmm1, xmm2
-
- movdqa xmm4, xmm6 ; transpose coefficients(phase 2)
- punpcklwd xmm6, xmm1 ; xmm6=(00 01 02 03 10 11 12 13 20 21 22 23 30 31 32 33)
- punpckhwd xmm4, xmm1 ; xmm4=(04 05 06 07 14 15 16 17 24 25 26 27 34 35 36 37)
-
- movdqa xmm7, xmm6 ; transpose coefficients(phase 3)
- punpckldq xmm6, xmm4 ; xmm6=(00 01 02 03 04 05 06 07 10 11 12 13 14 15 16 17)
- punpckhdq xmm7, xmm4 ; xmm7=(20 21 22 23 24 25 26 27 30 31 32 33 34 35 36 37)
-
- pshufd xmm5, xmm6, 0x4E ; xmm5=(10 11 12 13 14 15 16 17 00 01 02 03 04 05 06 07)
- pshufd xmm3, xmm7, 0x4E ; xmm3=(30 31 32 33 34 35 36 37 20 21 22 23 24 25 26 27)
-
- pushpic ebx ; save GOT address
-
- mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW]
- mov ebx, JSAMPROW [edi+2*SIZEOF_JSAMPROW]
- movq XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE], xmm6
- movq XMM_MMWORD [ebx+eax*SIZEOF_JSAMPLE], xmm7
- mov edx, JSAMPROW [edi+1*SIZEOF_JSAMPROW]
- mov ebx, JSAMPROW [edi+3*SIZEOF_JSAMPROW]
- movq XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE], xmm5
- movq XMM_MMWORD [ebx+eax*SIZEOF_JSAMPLE], xmm3
-
- poppic ebx ; restore GOT address
-
- add esi, byte 4*SIZEOF_FAST_FLOAT ; wsptr
- add edi, byte 4*SIZEOF_JSAMPROW
- dec ecx ; ctr
- jnz near .rowloop
-
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- pop ebx
- mov esp, ebp ; esp <- aligned ebp
- pop esp ; esp <- original ebp
- pop ebp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jidctfst-mmx.asm b/contrib/libs/libjpeg-turbo/simd/i386/jidctfst-mmx.asm
deleted file mode 100644
index 24622d4369..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jidctfst-mmx.asm
+++ /dev/null
@@ -1,499 +0,0 @@
-;
-; jidctfst.asm - fast integer IDCT (MMX)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-;
-; This file contains a fast, not so accurate integer implementation of
-; the inverse DCT (Discrete Cosine Transform). The following code is
-; based directly on the IJG's original jidctfst.c; see the jidctfst.c
-; for more details.
-
-%include "jsimdext.inc"
-%include "jdct.inc"
-
-; --------------------------------------------------------------------------
-
-%define CONST_BITS 8 ; 14 is also OK.
-%define PASS1_BITS 2
-
-%if IFAST_SCALE_BITS != PASS1_BITS
-%error "'IFAST_SCALE_BITS' must be equal to 'PASS1_BITS'."
-%endif
-
-%if CONST_BITS == 8
-F_1_082 equ 277 ; FIX(1.082392200)
-F_1_414 equ 362 ; FIX(1.414213562)
-F_1_847 equ 473 ; FIX(1.847759065)
-F_2_613 equ 669 ; FIX(2.613125930)
-F_1_613 equ (F_2_613 - 256) ; FIX(2.613125930) - FIX(1)
-%else
-; NASM cannot do compile-time arithmetic on floating-point constants.
-%define DESCALE(x, n) (((x) + (1 << ((n) - 1))) >> (n))
-F_1_082 equ DESCALE(1162209775, 30 - CONST_BITS) ; FIX(1.082392200)
-F_1_414 equ DESCALE(1518500249, 30 - CONST_BITS) ; FIX(1.414213562)
-F_1_847 equ DESCALE(1984016188, 30 - CONST_BITS) ; FIX(1.847759065)
-F_2_613 equ DESCALE(2805822602, 30 - CONST_BITS) ; FIX(2.613125930)
-F_1_613 equ (F_2_613 - (1 << CONST_BITS)) ; FIX(2.613125930) - FIX(1)
-%endif
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
-; PRE_MULTIPLY_SCALE_BITS <= 2 (to avoid overflow)
-; CONST_BITS + CONST_SHIFT + PRE_MULTIPLY_SCALE_BITS == 16 (for pmulhw)
-
-%define PRE_MULTIPLY_SCALE_BITS 2
-%define CONST_SHIFT (16 - PRE_MULTIPLY_SCALE_BITS - CONST_BITS)
-
- alignz 32
- GLOBAL_DATA(jconst_idct_ifast_mmx)
-
-EXTN(jconst_idct_ifast_mmx):
-
-PW_F1414 times 4 dw F_1_414 << CONST_SHIFT
-PW_F1847 times 4 dw F_1_847 << CONST_SHIFT
-PW_MF1613 times 4 dw -F_1_613 << CONST_SHIFT
-PW_F1082 times 4 dw F_1_082 << CONST_SHIFT
-PB_CENTERJSAMP times 8 db CENTERJSAMPLE
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-;
-; Perform dequantization and inverse DCT on one block of coefficients.
-;
-; GLOBAL(void)
-; jsimd_idct_ifast_mmx(void *dct_table, JCOEFPTR coef_block,
-; JSAMPARRAY output_buf, JDIMENSION output_col)
-;
-
-%define dct_table(b) (b) + 8 ; jpeg_component_info *compptr
-%define coef_block(b) (b) + 12 ; JCOEFPTR coef_block
-%define output_buf(b) (b) + 16 ; JSAMPARRAY output_buf
-%define output_col(b) (b) + 20 ; JDIMENSION output_col
-
-%define original_ebp ebp + 0
-%define wk(i) ebp - (WK_NUM - (i)) * SIZEOF_MMWORD
- ; mmword wk[WK_NUM]
-%define WK_NUM 2
-%define workspace wk(0) - DCTSIZE2 * SIZEOF_JCOEF
- ; JCOEF workspace[DCTSIZE2]
-
- align 32
- GLOBAL_FUNCTION(jsimd_idct_ifast_mmx)
-
-EXTN(jsimd_idct_ifast_mmx):
- push ebp
- mov eax, esp ; eax = original ebp
- sub esp, byte 4
- and esp, byte (-SIZEOF_MMWORD) ; align to 64 bits
- mov [esp], eax
- mov ebp, esp ; ebp = aligned ebp
- lea esp, [workspace]
- push ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- get_GOT ebx ; get GOT address
-
- ; ---- Pass 1: process columns from input, store into work array.
-
-; mov eax, [original_ebp]
- mov edx, POINTER [dct_table(eax)] ; quantptr
- mov esi, JCOEFPTR [coef_block(eax)] ; inptr
- lea edi, [workspace] ; JCOEF *wsptr
- mov ecx, DCTSIZE/4 ; ctr
- alignx 16, 7
-.columnloop:
-%ifndef NO_ZERO_COLUMN_TEST_IFAST_MMX
- mov eax, dword [DWBLOCK(1,0,esi,SIZEOF_JCOEF)]
- or eax, dword [DWBLOCK(2,0,esi,SIZEOF_JCOEF)]
- jnz short .columnDCT
-
- movq mm0, MMWORD [MMBLOCK(1,0,esi,SIZEOF_JCOEF)]
- movq mm1, MMWORD [MMBLOCK(2,0,esi,SIZEOF_JCOEF)]
- por mm0, MMWORD [MMBLOCK(3,0,esi,SIZEOF_JCOEF)]
- por mm1, MMWORD [MMBLOCK(4,0,esi,SIZEOF_JCOEF)]
- por mm0, MMWORD [MMBLOCK(5,0,esi,SIZEOF_JCOEF)]
- por mm1, MMWORD [MMBLOCK(6,0,esi,SIZEOF_JCOEF)]
- por mm0, MMWORD [MMBLOCK(7,0,esi,SIZEOF_JCOEF)]
- por mm1, mm0
- packsswb mm1, mm1
- movd eax, mm1
- test eax, eax
- jnz short .columnDCT
-
- ; -- AC terms all zero
-
- movq mm0, MMWORD [MMBLOCK(0,0,esi,SIZEOF_JCOEF)]
- pmullw mm0, MMWORD [MMBLOCK(0,0,edx,SIZEOF_IFAST_MULT_TYPE)]
-
- movq mm2, mm0 ; mm0=in0=(00 01 02 03)
- punpcklwd mm0, mm0 ; mm0=(00 00 01 01)
- punpckhwd mm2, mm2 ; mm2=(02 02 03 03)
-
- movq mm1, mm0
- punpckldq mm0, mm0 ; mm0=(00 00 00 00)
- punpckhdq mm1, mm1 ; mm1=(01 01 01 01)
- movq mm3, mm2
- punpckldq mm2, mm2 ; mm2=(02 02 02 02)
- punpckhdq mm3, mm3 ; mm3=(03 03 03 03)
-
- movq MMWORD [MMBLOCK(0,0,edi,SIZEOF_JCOEF)], mm0
- movq MMWORD [MMBLOCK(0,1,edi,SIZEOF_JCOEF)], mm0
- movq MMWORD [MMBLOCK(1,0,edi,SIZEOF_JCOEF)], mm1
- movq MMWORD [MMBLOCK(1,1,edi,SIZEOF_JCOEF)], mm1
- movq MMWORD [MMBLOCK(2,0,edi,SIZEOF_JCOEF)], mm2
- movq MMWORD [MMBLOCK(2,1,edi,SIZEOF_JCOEF)], mm2
- movq MMWORD [MMBLOCK(3,0,edi,SIZEOF_JCOEF)], mm3
- movq MMWORD [MMBLOCK(3,1,edi,SIZEOF_JCOEF)], mm3
- jmp near .nextcolumn
- alignx 16, 7
-%endif
-.columnDCT:
-
- ; -- Even part
-
- movq mm0, MMWORD [MMBLOCK(0,0,esi,SIZEOF_JCOEF)]
- movq mm1, MMWORD [MMBLOCK(2,0,esi,SIZEOF_JCOEF)]
- pmullw mm0, MMWORD [MMBLOCK(0,0,edx,SIZEOF_IFAST_MULT_TYPE)]
- pmullw mm1, MMWORD [MMBLOCK(2,0,edx,SIZEOF_IFAST_MULT_TYPE)]
- movq mm2, MMWORD [MMBLOCK(4,0,esi,SIZEOF_JCOEF)]
- movq mm3, MMWORD [MMBLOCK(6,0,esi,SIZEOF_JCOEF)]
- pmullw mm2, MMWORD [MMBLOCK(4,0,edx,SIZEOF_IFAST_MULT_TYPE)]
- pmullw mm3, MMWORD [MMBLOCK(6,0,edx,SIZEOF_IFAST_MULT_TYPE)]
-
- movq mm4, mm0
- movq mm5, mm1
- psubw mm0, mm2 ; mm0=tmp11
- psubw mm1, mm3
- paddw mm4, mm2 ; mm4=tmp10
- paddw mm5, mm3 ; mm5=tmp13
-
- psllw mm1, PRE_MULTIPLY_SCALE_BITS
- pmulhw mm1, [GOTOFF(ebx,PW_F1414)]
- psubw mm1, mm5 ; mm1=tmp12
-
- movq mm6, mm4
- movq mm7, mm0
- psubw mm4, mm5 ; mm4=tmp3
- psubw mm0, mm1 ; mm0=tmp2
- paddw mm6, mm5 ; mm6=tmp0
- paddw mm7, mm1 ; mm7=tmp1
-
- movq MMWORD [wk(1)], mm4 ; wk(1)=tmp3
- movq MMWORD [wk(0)], mm0 ; wk(0)=tmp2
-
- ; -- Odd part
-
- movq mm2, MMWORD [MMBLOCK(1,0,esi,SIZEOF_JCOEF)]
- movq mm3, MMWORD [MMBLOCK(3,0,esi,SIZEOF_JCOEF)]
- pmullw mm2, MMWORD [MMBLOCK(1,0,edx,SIZEOF_IFAST_MULT_TYPE)]
- pmullw mm3, MMWORD [MMBLOCK(3,0,edx,SIZEOF_IFAST_MULT_TYPE)]
- movq mm5, MMWORD [MMBLOCK(5,0,esi,SIZEOF_JCOEF)]
- movq mm1, MMWORD [MMBLOCK(7,0,esi,SIZEOF_JCOEF)]
- pmullw mm5, MMWORD [MMBLOCK(5,0,edx,SIZEOF_IFAST_MULT_TYPE)]
- pmullw mm1, MMWORD [MMBLOCK(7,0,edx,SIZEOF_IFAST_MULT_TYPE)]
-
- movq mm4, mm2
- movq mm0, mm5
- psubw mm2, mm1 ; mm2=z12
- psubw mm5, mm3 ; mm5=z10
- paddw mm4, mm1 ; mm4=z11
- paddw mm0, mm3 ; mm0=z13
-
- movq mm1, mm5 ; mm1=z10(unscaled)
- psllw mm2, PRE_MULTIPLY_SCALE_BITS
- psllw mm5, PRE_MULTIPLY_SCALE_BITS
-
- movq mm3, mm4
- psubw mm4, mm0
- paddw mm3, mm0 ; mm3=tmp7
-
- psllw mm4, PRE_MULTIPLY_SCALE_BITS
- pmulhw mm4, [GOTOFF(ebx,PW_F1414)] ; mm4=tmp11
-
- ; To avoid overflow...
- ;
- ; (Original)
- ; tmp12 = -2.613125930 * z10 + z5;
- ;
- ; (This implementation)
- ; tmp12 = (-1.613125930 - 1) * z10 + z5;
- ; = -1.613125930 * z10 - z10 + z5;
-
- movq mm0, mm5
- paddw mm5, mm2
- pmulhw mm5, [GOTOFF(ebx,PW_F1847)] ; mm5=z5
- pmulhw mm0, [GOTOFF(ebx,PW_MF1613)]
- pmulhw mm2, [GOTOFF(ebx,PW_F1082)]
- psubw mm0, mm1
- psubw mm2, mm5 ; mm2=tmp10
- paddw mm0, mm5 ; mm0=tmp12
-
- ; -- Final output stage
-
- psubw mm0, mm3 ; mm0=tmp6
- movq mm1, mm6
- movq mm5, mm7
- paddw mm6, mm3 ; mm6=data0=(00 01 02 03)
- paddw mm7, mm0 ; mm7=data1=(10 11 12 13)
- psubw mm1, mm3 ; mm1=data7=(70 71 72 73)
- psubw mm5, mm0 ; mm5=data6=(60 61 62 63)
- psubw mm4, mm0 ; mm4=tmp5
-
- movq mm3, mm6 ; transpose coefficients(phase 1)
- punpcklwd mm6, mm7 ; mm6=(00 10 01 11)
- punpckhwd mm3, mm7 ; mm3=(02 12 03 13)
- movq mm0, mm5 ; transpose coefficients(phase 1)
- punpcklwd mm5, mm1 ; mm5=(60 70 61 71)
- punpckhwd mm0, mm1 ; mm0=(62 72 63 73)
-
- movq mm7, MMWORD [wk(0)] ; mm7=tmp2
- movq mm1, MMWORD [wk(1)] ; mm1=tmp3
-
- movq MMWORD [wk(0)], mm5 ; wk(0)=(60 70 61 71)
- movq MMWORD [wk(1)], mm0 ; wk(1)=(62 72 63 73)
-
- paddw mm2, mm4 ; mm2=tmp4
- movq mm5, mm7
- movq mm0, mm1
- paddw mm7, mm4 ; mm7=data2=(20 21 22 23)
- paddw mm1, mm2 ; mm1=data4=(40 41 42 43)
- psubw mm5, mm4 ; mm5=data5=(50 51 52 53)
- psubw mm0, mm2 ; mm0=data3=(30 31 32 33)
-
- movq mm4, mm7 ; transpose coefficients(phase 1)
- punpcklwd mm7, mm0 ; mm7=(20 30 21 31)
- punpckhwd mm4, mm0 ; mm4=(22 32 23 33)
- movq mm2, mm1 ; transpose coefficients(phase 1)
- punpcklwd mm1, mm5 ; mm1=(40 50 41 51)
- punpckhwd mm2, mm5 ; mm2=(42 52 43 53)
-
- movq mm0, mm6 ; transpose coefficients(phase 2)
- punpckldq mm6, mm7 ; mm6=(00 10 20 30)
- punpckhdq mm0, mm7 ; mm0=(01 11 21 31)
- movq mm5, mm3 ; transpose coefficients(phase 2)
- punpckldq mm3, mm4 ; mm3=(02 12 22 32)
- punpckhdq mm5, mm4 ; mm5=(03 13 23 33)
-
- movq mm7, MMWORD [wk(0)] ; mm7=(60 70 61 71)
- movq mm4, MMWORD [wk(1)] ; mm4=(62 72 63 73)
-
- movq MMWORD [MMBLOCK(0,0,edi,SIZEOF_JCOEF)], mm6
- movq MMWORD [MMBLOCK(1,0,edi,SIZEOF_JCOEF)], mm0
- movq MMWORD [MMBLOCK(2,0,edi,SIZEOF_JCOEF)], mm3
- movq MMWORD [MMBLOCK(3,0,edi,SIZEOF_JCOEF)], mm5
-
- movq mm6, mm1 ; transpose coefficients(phase 2)
- punpckldq mm1, mm7 ; mm1=(40 50 60 70)
- punpckhdq mm6, mm7 ; mm6=(41 51 61 71)
- movq mm0, mm2 ; transpose coefficients(phase 2)
- punpckldq mm2, mm4 ; mm2=(42 52 62 72)
- punpckhdq mm0, mm4 ; mm0=(43 53 63 73)
-
- movq MMWORD [MMBLOCK(0,1,edi,SIZEOF_JCOEF)], mm1
- movq MMWORD [MMBLOCK(1,1,edi,SIZEOF_JCOEF)], mm6
- movq MMWORD [MMBLOCK(2,1,edi,SIZEOF_JCOEF)], mm2
- movq MMWORD [MMBLOCK(3,1,edi,SIZEOF_JCOEF)], mm0
-
-.nextcolumn:
- add esi, byte 4*SIZEOF_JCOEF ; coef_block
- add edx, byte 4*SIZEOF_IFAST_MULT_TYPE ; quantptr
- add edi, byte 4*DCTSIZE*SIZEOF_JCOEF ; wsptr
- dec ecx ; ctr
- jnz near .columnloop
-
- ; ---- Pass 2: process rows from work array, store into output array.
-
- mov eax, [original_ebp]
- lea esi, [workspace] ; JCOEF *wsptr
- mov edi, JSAMPARRAY [output_buf(eax)] ; (JSAMPROW *)
- mov eax, JDIMENSION [output_col(eax)]
- mov ecx, DCTSIZE/4 ; ctr
- alignx 16, 7
-.rowloop:
-
- ; -- Even part
-
- movq mm0, MMWORD [MMBLOCK(0,0,esi,SIZEOF_JCOEF)]
- movq mm1, MMWORD [MMBLOCK(2,0,esi,SIZEOF_JCOEF)]
- movq mm2, MMWORD [MMBLOCK(4,0,esi,SIZEOF_JCOEF)]
- movq mm3, MMWORD [MMBLOCK(6,0,esi,SIZEOF_JCOEF)]
-
- movq mm4, mm0
- movq mm5, mm1
- psubw mm0, mm2 ; mm0=tmp11
- psubw mm1, mm3
- paddw mm4, mm2 ; mm4=tmp10
- paddw mm5, mm3 ; mm5=tmp13
-
- psllw mm1, PRE_MULTIPLY_SCALE_BITS
- pmulhw mm1, [GOTOFF(ebx,PW_F1414)]
- psubw mm1, mm5 ; mm1=tmp12
-
- movq mm6, mm4
- movq mm7, mm0
- psubw mm4, mm5 ; mm4=tmp3
- psubw mm0, mm1 ; mm0=tmp2
- paddw mm6, mm5 ; mm6=tmp0
- paddw mm7, mm1 ; mm7=tmp1
-
- movq MMWORD [wk(1)], mm4 ; wk(1)=tmp3
- movq MMWORD [wk(0)], mm0 ; wk(0)=tmp2
-
- ; -- Odd part
-
- movq mm2, MMWORD [MMBLOCK(1,0,esi,SIZEOF_JCOEF)]
- movq mm3, MMWORD [MMBLOCK(3,0,esi,SIZEOF_JCOEF)]
- movq mm5, MMWORD [MMBLOCK(5,0,esi,SIZEOF_JCOEF)]
- movq mm1, MMWORD [MMBLOCK(7,0,esi,SIZEOF_JCOEF)]
-
- movq mm4, mm2
- movq mm0, mm5
- psubw mm2, mm1 ; mm2=z12
- psubw mm5, mm3 ; mm5=z10
- paddw mm4, mm1 ; mm4=z11
- paddw mm0, mm3 ; mm0=z13
-
- movq mm1, mm5 ; mm1=z10(unscaled)
- psllw mm2, PRE_MULTIPLY_SCALE_BITS
- psllw mm5, PRE_MULTIPLY_SCALE_BITS
-
- movq mm3, mm4
- psubw mm4, mm0
- paddw mm3, mm0 ; mm3=tmp7
-
- psllw mm4, PRE_MULTIPLY_SCALE_BITS
- pmulhw mm4, [GOTOFF(ebx,PW_F1414)] ; mm4=tmp11
-
- ; To avoid overflow...
- ;
- ; (Original)
- ; tmp12 = -2.613125930 * z10 + z5;
- ;
- ; (This implementation)
- ; tmp12 = (-1.613125930 - 1) * z10 + z5;
- ; = -1.613125930 * z10 - z10 + z5;
-
- movq mm0, mm5
- paddw mm5, mm2
- pmulhw mm5, [GOTOFF(ebx,PW_F1847)] ; mm5=z5
- pmulhw mm0, [GOTOFF(ebx,PW_MF1613)]
- pmulhw mm2, [GOTOFF(ebx,PW_F1082)]
- psubw mm0, mm1
- psubw mm2, mm5 ; mm2=tmp10
- paddw mm0, mm5 ; mm0=tmp12
-
- ; -- Final output stage
-
- psubw mm0, mm3 ; mm0=tmp6
- movq mm1, mm6
- movq mm5, mm7
- paddw mm6, mm3 ; mm6=data0=(00 10 20 30)
- paddw mm7, mm0 ; mm7=data1=(01 11 21 31)
- psraw mm6, (PASS1_BITS+3) ; descale
- psraw mm7, (PASS1_BITS+3) ; descale
- psubw mm1, mm3 ; mm1=data7=(07 17 27 37)
- psubw mm5, mm0 ; mm5=data6=(06 16 26 36)
- psraw mm1, (PASS1_BITS+3) ; descale
- psraw mm5, (PASS1_BITS+3) ; descale
- psubw mm4, mm0 ; mm4=tmp5
-
- packsswb mm6, mm5 ; mm6=(00 10 20 30 06 16 26 36)
- packsswb mm7, mm1 ; mm7=(01 11 21 31 07 17 27 37)
-
- movq mm3, MMWORD [wk(0)] ; mm3=tmp2
- movq mm0, MMWORD [wk(1)] ; mm0=tmp3
-
- paddw mm2, mm4 ; mm2=tmp4
- movq mm5, mm3
- movq mm1, mm0
- paddw mm3, mm4 ; mm3=data2=(02 12 22 32)
- paddw mm0, mm2 ; mm0=data4=(04 14 24 34)
- psraw mm3, (PASS1_BITS+3) ; descale
- psraw mm0, (PASS1_BITS+3) ; descale
- psubw mm5, mm4 ; mm5=data5=(05 15 25 35)
- psubw mm1, mm2 ; mm1=data3=(03 13 23 33)
- psraw mm5, (PASS1_BITS+3) ; descale
- psraw mm1, (PASS1_BITS+3) ; descale
-
- movq mm4, [GOTOFF(ebx,PB_CENTERJSAMP)] ; mm4=[PB_CENTERJSAMP]
-
- packsswb mm3, mm0 ; mm3=(02 12 22 32 04 14 24 34)
- packsswb mm1, mm5 ; mm1=(03 13 23 33 05 15 25 35)
-
- paddb mm6, mm4
- paddb mm7, mm4
- paddb mm3, mm4
- paddb mm1, mm4
-
- movq mm2, mm6 ; transpose coefficients(phase 1)
- punpcklbw mm6, mm7 ; mm6=(00 01 10 11 20 21 30 31)
- punpckhbw mm2, mm7 ; mm2=(06 07 16 17 26 27 36 37)
- movq mm0, mm3 ; transpose coefficients(phase 1)
- punpcklbw mm3, mm1 ; mm3=(02 03 12 13 22 23 32 33)
- punpckhbw mm0, mm1 ; mm0=(04 05 14 15 24 25 34 35)
-
- movq mm5, mm6 ; transpose coefficients(phase 2)
- punpcklwd mm6, mm3 ; mm6=(00 01 02 03 10 11 12 13)
- punpckhwd mm5, mm3 ; mm5=(20 21 22 23 30 31 32 33)
- movq mm4, mm0 ; transpose coefficients(phase 2)
- punpcklwd mm0, mm2 ; mm0=(04 05 06 07 14 15 16 17)
- punpckhwd mm4, mm2 ; mm4=(24 25 26 27 34 35 36 37)
-
- movq mm7, mm6 ; transpose coefficients(phase 3)
- punpckldq mm6, mm0 ; mm6=(00 01 02 03 04 05 06 07)
- punpckhdq mm7, mm0 ; mm7=(10 11 12 13 14 15 16 17)
- movq mm1, mm5 ; transpose coefficients(phase 3)
- punpckldq mm5, mm4 ; mm5=(20 21 22 23 24 25 26 27)
- punpckhdq mm1, mm4 ; mm1=(30 31 32 33 34 35 36 37)
-
- pushpic ebx ; save GOT address
-
- mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW]
- mov ebx, JSAMPROW [edi+1*SIZEOF_JSAMPROW]
- movq MMWORD [edx+eax*SIZEOF_JSAMPLE], mm6
- movq MMWORD [ebx+eax*SIZEOF_JSAMPLE], mm7
- mov edx, JSAMPROW [edi+2*SIZEOF_JSAMPROW]
- mov ebx, JSAMPROW [edi+3*SIZEOF_JSAMPROW]
- movq MMWORD [edx+eax*SIZEOF_JSAMPLE], mm5
- movq MMWORD [ebx+eax*SIZEOF_JSAMPLE], mm1
-
- poppic ebx ; restore GOT address
-
- add esi, byte 4*SIZEOF_JCOEF ; wsptr
- add edi, byte 4*SIZEOF_JSAMPROW
- dec ecx ; ctr
- jnz near .rowloop
-
- emms ; empty MMX state
-
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- pop ebx
- mov esp, ebp ; esp <- aligned ebp
- pop esp ; esp <- original ebp
- pop ebp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jidctfst-sse2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jidctfst-sse2.asm
deleted file mode 100644
index 19704ffa48..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jidctfst-sse2.asm
+++ /dev/null
@@ -1,501 +0,0 @@
-;
-; jidctfst.asm - fast integer IDCT (SSE2)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-;
-; This file contains a fast, not so accurate integer implementation of
-; the inverse DCT (Discrete Cosine Transform). The following code is
-; based directly on the IJG's original jidctfst.c; see the jidctfst.c
-; for more details.
-
-%include "jsimdext.inc"
-%include "jdct.inc"
-
-; --------------------------------------------------------------------------
-
-%define CONST_BITS 8 ; 14 is also OK.
-%define PASS1_BITS 2
-
-%if IFAST_SCALE_BITS != PASS1_BITS
-%error "'IFAST_SCALE_BITS' must be equal to 'PASS1_BITS'."
-%endif
-
-%if CONST_BITS == 8
-F_1_082 equ 277 ; FIX(1.082392200)
-F_1_414 equ 362 ; FIX(1.414213562)
-F_1_847 equ 473 ; FIX(1.847759065)
-F_2_613 equ 669 ; FIX(2.613125930)
-F_1_613 equ (F_2_613 - 256) ; FIX(2.613125930) - FIX(1)
-%else
-; NASM cannot do compile-time arithmetic on floating-point constants.
-%define DESCALE(x, n) (((x) + (1 << ((n) - 1))) >> (n))
-F_1_082 equ DESCALE(1162209775, 30 - CONST_BITS) ; FIX(1.082392200)
-F_1_414 equ DESCALE(1518500249, 30 - CONST_BITS) ; FIX(1.414213562)
-F_1_847 equ DESCALE(1984016188, 30 - CONST_BITS) ; FIX(1.847759065)
-F_2_613 equ DESCALE(2805822602, 30 - CONST_BITS) ; FIX(2.613125930)
-F_1_613 equ (F_2_613 - (1 << CONST_BITS)) ; FIX(2.613125930) - FIX(1)
-%endif
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
-; PRE_MULTIPLY_SCALE_BITS <= 2 (to avoid overflow)
-; CONST_BITS + CONST_SHIFT + PRE_MULTIPLY_SCALE_BITS == 16 (for pmulhw)
-
-%define PRE_MULTIPLY_SCALE_BITS 2
-%define CONST_SHIFT (16 - PRE_MULTIPLY_SCALE_BITS - CONST_BITS)
-
- alignz 32
- GLOBAL_DATA(jconst_idct_ifast_sse2)
-
-EXTN(jconst_idct_ifast_sse2):
-
-PW_F1414 times 8 dw F_1_414 << CONST_SHIFT
-PW_F1847 times 8 dw F_1_847 << CONST_SHIFT
-PW_MF1613 times 8 dw -F_1_613 << CONST_SHIFT
-PW_F1082 times 8 dw F_1_082 << CONST_SHIFT
-PB_CENTERJSAMP times 16 db CENTERJSAMPLE
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-;
-; Perform dequantization and inverse DCT on one block of coefficients.
-;
-; GLOBAL(void)
-; jsimd_idct_ifast_sse2(void *dct_table, JCOEFPTR coef_block,
-; JSAMPARRAY output_buf, JDIMENSION output_col)
-;
-
-%define dct_table(b) (b) + 8 ; jpeg_component_info *compptr
-%define coef_block(b) (b) + 12 ; JCOEFPTR coef_block
-%define output_buf(b) (b) + 16 ; JSAMPARRAY output_buf
-%define output_col(b) (b) + 20 ; JDIMENSION output_col
-
-%define original_ebp ebp + 0
-%define wk(i) ebp - (WK_NUM - (i)) * SIZEOF_XMMWORD
- ; xmmword wk[WK_NUM]
-%define WK_NUM 2
-
- align 32
- GLOBAL_FUNCTION(jsimd_idct_ifast_sse2)
-
-EXTN(jsimd_idct_ifast_sse2):
- push ebp
- mov eax, esp ; eax = original ebp
- sub esp, byte 4
- and esp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [esp], eax
- mov ebp, esp ; ebp = aligned ebp
- lea esp, [wk(0)]
- pushpic ebx
-; push ecx ; unused
-; push edx ; need not be preserved
- push esi
- push edi
-
- get_GOT ebx ; get GOT address
-
- ; ---- Pass 1: process columns from input.
-
-; mov eax, [original_ebp]
- mov edx, POINTER [dct_table(eax)] ; quantptr
- mov esi, JCOEFPTR [coef_block(eax)] ; inptr
-
-%ifndef NO_ZERO_COLUMN_TEST_IFAST_SSE2
- mov eax, dword [DWBLOCK(1,0,esi,SIZEOF_JCOEF)]
- or eax, dword [DWBLOCK(2,0,esi,SIZEOF_JCOEF)]
- jnz near .columnDCT
-
- movdqa xmm0, XMMWORD [XMMBLOCK(1,0,esi,SIZEOF_JCOEF)]
- movdqa xmm1, XMMWORD [XMMBLOCK(2,0,esi,SIZEOF_JCOEF)]
- por xmm0, XMMWORD [XMMBLOCK(3,0,esi,SIZEOF_JCOEF)]
- por xmm1, XMMWORD [XMMBLOCK(4,0,esi,SIZEOF_JCOEF)]
- por xmm0, XMMWORD [XMMBLOCK(5,0,esi,SIZEOF_JCOEF)]
- por xmm1, XMMWORD [XMMBLOCK(6,0,esi,SIZEOF_JCOEF)]
- por xmm0, XMMWORD [XMMBLOCK(7,0,esi,SIZEOF_JCOEF)]
- por xmm1, xmm0
- packsswb xmm1, xmm1
- packsswb xmm1, xmm1
- movd eax, xmm1
- test eax, eax
- jnz short .columnDCT
-
- ; -- AC terms all zero
-
- movdqa xmm0, XMMWORD [XMMBLOCK(0,0,esi,SIZEOF_JCOEF)]
- pmullw xmm0, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
-
- movdqa xmm7, xmm0 ; xmm0=in0=(00 01 02 03 04 05 06 07)
- punpcklwd xmm0, xmm0 ; xmm0=(00 00 01 01 02 02 03 03)
- punpckhwd xmm7, xmm7 ; xmm7=(04 04 05 05 06 06 07 07)
-
- pshufd xmm6, xmm0, 0x00 ; xmm6=col0=(00 00 00 00 00 00 00 00)
- pshufd xmm2, xmm0, 0x55 ; xmm2=col1=(01 01 01 01 01 01 01 01)
- pshufd xmm5, xmm0, 0xAA ; xmm5=col2=(02 02 02 02 02 02 02 02)
- pshufd xmm0, xmm0, 0xFF ; xmm0=col3=(03 03 03 03 03 03 03 03)
- pshufd xmm1, xmm7, 0x00 ; xmm1=col4=(04 04 04 04 04 04 04 04)
- pshufd xmm4, xmm7, 0x55 ; xmm4=col5=(05 05 05 05 05 05 05 05)
- pshufd xmm3, xmm7, 0xAA ; xmm3=col6=(06 06 06 06 06 06 06 06)
- pshufd xmm7, xmm7, 0xFF ; xmm7=col7=(07 07 07 07 07 07 07 07)
-
- movdqa XMMWORD [wk(0)], xmm2 ; wk(0)=col1
- movdqa XMMWORD [wk(1)], xmm0 ; wk(1)=col3
- jmp near .column_end
- alignx 16, 7
-%endif
-.columnDCT:
-
- ; -- Even part
-
- movdqa xmm0, XMMWORD [XMMBLOCK(0,0,esi,SIZEOF_JCOEF)]
- movdqa xmm1, XMMWORD [XMMBLOCK(2,0,esi,SIZEOF_JCOEF)]
- pmullw xmm0, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_IFAST_MULT_TYPE)]
- pmullw xmm1, XMMWORD [XMMBLOCK(2,0,edx,SIZEOF_IFAST_MULT_TYPE)]
- movdqa xmm2, XMMWORD [XMMBLOCK(4,0,esi,SIZEOF_JCOEF)]
- movdqa xmm3, XMMWORD [XMMBLOCK(6,0,esi,SIZEOF_JCOEF)]
- pmullw xmm2, XMMWORD [XMMBLOCK(4,0,edx,SIZEOF_IFAST_MULT_TYPE)]
- pmullw xmm3, XMMWORD [XMMBLOCK(6,0,edx,SIZEOF_IFAST_MULT_TYPE)]
-
- movdqa xmm4, xmm0
- movdqa xmm5, xmm1
- psubw xmm0, xmm2 ; xmm0=tmp11
- psubw xmm1, xmm3
- paddw xmm4, xmm2 ; xmm4=tmp10
- paddw xmm5, xmm3 ; xmm5=tmp13
-
- psllw xmm1, PRE_MULTIPLY_SCALE_BITS
- pmulhw xmm1, [GOTOFF(ebx,PW_F1414)]
- psubw xmm1, xmm5 ; xmm1=tmp12
-
- movdqa xmm6, xmm4
- movdqa xmm7, xmm0
- psubw xmm4, xmm5 ; xmm4=tmp3
- psubw xmm0, xmm1 ; xmm0=tmp2
- paddw xmm6, xmm5 ; xmm6=tmp0
- paddw xmm7, xmm1 ; xmm7=tmp1
-
- movdqa XMMWORD [wk(1)], xmm4 ; wk(1)=tmp3
- movdqa XMMWORD [wk(0)], xmm0 ; wk(0)=tmp2
-
- ; -- Odd part
-
- movdqa xmm2, XMMWORD [XMMBLOCK(1,0,esi,SIZEOF_JCOEF)]
- movdqa xmm3, XMMWORD [XMMBLOCK(3,0,esi,SIZEOF_JCOEF)]
- pmullw xmm2, XMMWORD [XMMBLOCK(1,0,edx,SIZEOF_IFAST_MULT_TYPE)]
- pmullw xmm3, XMMWORD [XMMBLOCK(3,0,edx,SIZEOF_IFAST_MULT_TYPE)]
- movdqa xmm5, XMMWORD [XMMBLOCK(5,0,esi,SIZEOF_JCOEF)]
- movdqa xmm1, XMMWORD [XMMBLOCK(7,0,esi,SIZEOF_JCOEF)]
- pmullw xmm5, XMMWORD [XMMBLOCK(5,0,edx,SIZEOF_IFAST_MULT_TYPE)]
- pmullw xmm1, XMMWORD [XMMBLOCK(7,0,edx,SIZEOF_IFAST_MULT_TYPE)]
-
- movdqa xmm4, xmm2
- movdqa xmm0, xmm5
- psubw xmm2, xmm1 ; xmm2=z12
- psubw xmm5, xmm3 ; xmm5=z10
- paddw xmm4, xmm1 ; xmm4=z11
- paddw xmm0, xmm3 ; xmm0=z13
-
- movdqa xmm1, xmm5 ; xmm1=z10(unscaled)
- psllw xmm2, PRE_MULTIPLY_SCALE_BITS
- psllw xmm5, PRE_MULTIPLY_SCALE_BITS
-
- movdqa xmm3, xmm4
- psubw xmm4, xmm0
- paddw xmm3, xmm0 ; xmm3=tmp7
-
- psllw xmm4, PRE_MULTIPLY_SCALE_BITS
- pmulhw xmm4, [GOTOFF(ebx,PW_F1414)] ; xmm4=tmp11
-
- ; To avoid overflow...
- ;
- ; (Original)
- ; tmp12 = -2.613125930 * z10 + z5;
- ;
- ; (This implementation)
- ; tmp12 = (-1.613125930 - 1) * z10 + z5;
- ; = -1.613125930 * z10 - z10 + z5;
-
- movdqa xmm0, xmm5
- paddw xmm5, xmm2
- pmulhw xmm5, [GOTOFF(ebx,PW_F1847)] ; xmm5=z5
- pmulhw xmm0, [GOTOFF(ebx,PW_MF1613)]
- pmulhw xmm2, [GOTOFF(ebx,PW_F1082)]
- psubw xmm0, xmm1
- psubw xmm2, xmm5 ; xmm2=tmp10
- paddw xmm0, xmm5 ; xmm0=tmp12
-
- ; -- Final output stage
-
- psubw xmm0, xmm3 ; xmm0=tmp6
- movdqa xmm1, xmm6
- movdqa xmm5, xmm7
- paddw xmm6, xmm3 ; xmm6=data0=(00 01 02 03 04 05 06 07)
- paddw xmm7, xmm0 ; xmm7=data1=(10 11 12 13 14 15 16 17)
- psubw xmm1, xmm3 ; xmm1=data7=(70 71 72 73 74 75 76 77)
- psubw xmm5, xmm0 ; xmm5=data6=(60 61 62 63 64 65 66 67)
- psubw xmm4, xmm0 ; xmm4=tmp5
-
- movdqa xmm3, xmm6 ; transpose coefficients(phase 1)
- punpcklwd xmm6, xmm7 ; xmm6=(00 10 01 11 02 12 03 13)
- punpckhwd xmm3, xmm7 ; xmm3=(04 14 05 15 06 16 07 17)
- movdqa xmm0, xmm5 ; transpose coefficients(phase 1)
- punpcklwd xmm5, xmm1 ; xmm5=(60 70 61 71 62 72 63 73)
- punpckhwd xmm0, xmm1 ; xmm0=(64 74 65 75 66 76 67 77)
-
- movdqa xmm7, XMMWORD [wk(0)] ; xmm7=tmp2
- movdqa xmm1, XMMWORD [wk(1)] ; xmm1=tmp3
-
- movdqa XMMWORD [wk(0)], xmm5 ; wk(0)=(60 70 61 71 62 72 63 73)
- movdqa XMMWORD [wk(1)], xmm0 ; wk(1)=(64 74 65 75 66 76 67 77)
-
- paddw xmm2, xmm4 ; xmm2=tmp4
- movdqa xmm5, xmm7
- movdqa xmm0, xmm1
- paddw xmm7, xmm4 ; xmm7=data2=(20 21 22 23 24 25 26 27)
- paddw xmm1, xmm2 ; xmm1=data4=(40 41 42 43 44 45 46 47)
- psubw xmm5, xmm4 ; xmm5=data5=(50 51 52 53 54 55 56 57)
- psubw xmm0, xmm2 ; xmm0=data3=(30 31 32 33 34 35 36 37)
-
- movdqa xmm4, xmm7 ; transpose coefficients(phase 1)
- punpcklwd xmm7, xmm0 ; xmm7=(20 30 21 31 22 32 23 33)
- punpckhwd xmm4, xmm0 ; xmm4=(24 34 25 35 26 36 27 37)
- movdqa xmm2, xmm1 ; transpose coefficients(phase 1)
- punpcklwd xmm1, xmm5 ; xmm1=(40 50 41 51 42 52 43 53)
- punpckhwd xmm2, xmm5 ; xmm2=(44 54 45 55 46 56 47 57)
-
- movdqa xmm0, xmm3 ; transpose coefficients(phase 2)
- punpckldq xmm3, xmm4 ; xmm3=(04 14 24 34 05 15 25 35)
- punpckhdq xmm0, xmm4 ; xmm0=(06 16 26 36 07 17 27 37)
- movdqa xmm5, xmm6 ; transpose coefficients(phase 2)
- punpckldq xmm6, xmm7 ; xmm6=(00 10 20 30 01 11 21 31)
- punpckhdq xmm5, xmm7 ; xmm5=(02 12 22 32 03 13 23 33)
-
- movdqa xmm4, XMMWORD [wk(0)] ; xmm4=(60 70 61 71 62 72 63 73)
- movdqa xmm7, XMMWORD [wk(1)] ; xmm7=(64 74 65 75 66 76 67 77)
-
- movdqa XMMWORD [wk(0)], xmm3 ; wk(0)=(04 14 24 34 05 15 25 35)
- movdqa XMMWORD [wk(1)], xmm0 ; wk(1)=(06 16 26 36 07 17 27 37)
-
- movdqa xmm3, xmm1 ; transpose coefficients(phase 2)
- punpckldq xmm1, xmm4 ; xmm1=(40 50 60 70 41 51 61 71)
- punpckhdq xmm3, xmm4 ; xmm3=(42 52 62 72 43 53 63 73)
- movdqa xmm0, xmm2 ; transpose coefficients(phase 2)
- punpckldq xmm2, xmm7 ; xmm2=(44 54 64 74 45 55 65 75)
- punpckhdq xmm0, xmm7 ; xmm0=(46 56 66 76 47 57 67 77)
-
- movdqa xmm4, xmm6 ; transpose coefficients(phase 3)
- punpcklqdq xmm6, xmm1 ; xmm6=col0=(00 10 20 30 40 50 60 70)
- punpckhqdq xmm4, xmm1 ; xmm4=col1=(01 11 21 31 41 51 61 71)
- movdqa xmm7, xmm5 ; transpose coefficients(phase 3)
- punpcklqdq xmm5, xmm3 ; xmm5=col2=(02 12 22 32 42 52 62 72)
- punpckhqdq xmm7, xmm3 ; xmm7=col3=(03 13 23 33 43 53 63 73)
-
- movdqa xmm1, XMMWORD [wk(0)] ; xmm1=(04 14 24 34 05 15 25 35)
- movdqa xmm3, XMMWORD [wk(1)] ; xmm3=(06 16 26 36 07 17 27 37)
-
- movdqa XMMWORD [wk(0)], xmm4 ; wk(0)=col1
- movdqa XMMWORD [wk(1)], xmm7 ; wk(1)=col3
-
- movdqa xmm4, xmm1 ; transpose coefficients(phase 3)
- punpcklqdq xmm1, xmm2 ; xmm1=col4=(04 14 24 34 44 54 64 74)
- punpckhqdq xmm4, xmm2 ; xmm4=col5=(05 15 25 35 45 55 65 75)
- movdqa xmm7, xmm3 ; transpose coefficients(phase 3)
- punpcklqdq xmm3, xmm0 ; xmm3=col6=(06 16 26 36 46 56 66 76)
- punpckhqdq xmm7, xmm0 ; xmm7=col7=(07 17 27 37 47 57 67 77)
-.column_end:
-
- ; -- Prefetch the next coefficient block
-
- prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 0*32]
- prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 1*32]
- prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 2*32]
- prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 3*32]
-
- ; ---- Pass 2: process rows from work array, store into output array.
-
- mov eax, [original_ebp]
- mov edi, JSAMPARRAY [output_buf(eax)] ; (JSAMPROW *)
- mov eax, JDIMENSION [output_col(eax)]
-
- ; -- Even part
-
- ; xmm6=col0, xmm5=col2, xmm1=col4, xmm3=col6
-
- movdqa xmm2, xmm6
- movdqa xmm0, xmm5
- psubw xmm6, xmm1 ; xmm6=tmp11
- psubw xmm5, xmm3
- paddw xmm2, xmm1 ; xmm2=tmp10
- paddw xmm0, xmm3 ; xmm0=tmp13
-
- psllw xmm5, PRE_MULTIPLY_SCALE_BITS
- pmulhw xmm5, [GOTOFF(ebx,PW_F1414)]
- psubw xmm5, xmm0 ; xmm5=tmp12
-
- movdqa xmm1, xmm2
- movdqa xmm3, xmm6
- psubw xmm2, xmm0 ; xmm2=tmp3
- psubw xmm6, xmm5 ; xmm6=tmp2
- paddw xmm1, xmm0 ; xmm1=tmp0
- paddw xmm3, xmm5 ; xmm3=tmp1
-
- movdqa xmm0, XMMWORD [wk(0)] ; xmm0=col1
- movdqa xmm5, XMMWORD [wk(1)] ; xmm5=col3
-
- movdqa XMMWORD [wk(0)], xmm2 ; wk(0)=tmp3
- movdqa XMMWORD [wk(1)], xmm6 ; wk(1)=tmp2
-
- ; -- Odd part
-
- ; xmm0=col1, xmm5=col3, xmm4=col5, xmm7=col7
-
- movdqa xmm2, xmm0
- movdqa xmm6, xmm4
- psubw xmm0, xmm7 ; xmm0=z12
- psubw xmm4, xmm5 ; xmm4=z10
- paddw xmm2, xmm7 ; xmm2=z11
- paddw xmm6, xmm5 ; xmm6=z13
-
- movdqa xmm7, xmm4 ; xmm7=z10(unscaled)
- psllw xmm0, PRE_MULTIPLY_SCALE_BITS
- psllw xmm4, PRE_MULTIPLY_SCALE_BITS
-
- movdqa xmm5, xmm2
- psubw xmm2, xmm6
- paddw xmm5, xmm6 ; xmm5=tmp7
-
- psllw xmm2, PRE_MULTIPLY_SCALE_BITS
- pmulhw xmm2, [GOTOFF(ebx,PW_F1414)] ; xmm2=tmp11
-
- ; To avoid overflow...
- ;
- ; (Original)
- ; tmp12 = -2.613125930 * z10 + z5;
- ;
- ; (This implementation)
- ; tmp12 = (-1.613125930 - 1) * z10 + z5;
- ; = -1.613125930 * z10 - z10 + z5;
-
- movdqa xmm6, xmm4
- paddw xmm4, xmm0
- pmulhw xmm4, [GOTOFF(ebx,PW_F1847)] ; xmm4=z5
- pmulhw xmm6, [GOTOFF(ebx,PW_MF1613)]
- pmulhw xmm0, [GOTOFF(ebx,PW_F1082)]
- psubw xmm6, xmm7
- psubw xmm0, xmm4 ; xmm0=tmp10
- paddw xmm6, xmm4 ; xmm6=tmp12
-
- ; -- Final output stage
-
- psubw xmm6, xmm5 ; xmm6=tmp6
- movdqa xmm7, xmm1
- movdqa xmm4, xmm3
- paddw xmm1, xmm5 ; xmm1=data0=(00 10 20 30 40 50 60 70)
- paddw xmm3, xmm6 ; xmm3=data1=(01 11 21 31 41 51 61 71)
- psraw xmm1, (PASS1_BITS+3) ; descale
- psraw xmm3, (PASS1_BITS+3) ; descale
- psubw xmm7, xmm5 ; xmm7=data7=(07 17 27 37 47 57 67 77)
- psubw xmm4, xmm6 ; xmm4=data6=(06 16 26 36 46 56 66 76)
- psraw xmm7, (PASS1_BITS+3) ; descale
- psraw xmm4, (PASS1_BITS+3) ; descale
- psubw xmm2, xmm6 ; xmm2=tmp5
-
- packsswb xmm1, xmm4 ; xmm1=(00 10 20 30 40 50 60 70 06 16 26 36 46 56 66 76)
- packsswb xmm3, xmm7 ; xmm3=(01 11 21 31 41 51 61 71 07 17 27 37 47 57 67 77)
-
- movdqa xmm5, XMMWORD [wk(1)] ; xmm5=tmp2
- movdqa xmm6, XMMWORD [wk(0)] ; xmm6=tmp3
-
- paddw xmm0, xmm2 ; xmm0=tmp4
- movdqa xmm4, xmm5
- movdqa xmm7, xmm6
- paddw xmm5, xmm2 ; xmm5=data2=(02 12 22 32 42 52 62 72)
- paddw xmm6, xmm0 ; xmm6=data4=(04 14 24 34 44 54 64 74)
- psraw xmm5, (PASS1_BITS+3) ; descale
- psraw xmm6, (PASS1_BITS+3) ; descale
- psubw xmm4, xmm2 ; xmm4=data5=(05 15 25 35 45 55 65 75)
- psubw xmm7, xmm0 ; xmm7=data3=(03 13 23 33 43 53 63 73)
- psraw xmm4, (PASS1_BITS+3) ; descale
- psraw xmm7, (PASS1_BITS+3) ; descale
-
- movdqa xmm2, [GOTOFF(ebx,PB_CENTERJSAMP)] ; xmm2=[PB_CENTERJSAMP]
-
- packsswb xmm5, xmm6 ; xmm5=(02 12 22 32 42 52 62 72 04 14 24 34 44 54 64 74)
- packsswb xmm7, xmm4 ; xmm7=(03 13 23 33 43 53 63 73 05 15 25 35 45 55 65 75)
-
- paddb xmm1, xmm2
- paddb xmm3, xmm2
- paddb xmm5, xmm2
- paddb xmm7, xmm2
-
- movdqa xmm0, xmm1 ; transpose coefficients(phase 1)
- punpcklbw xmm1, xmm3 ; xmm1=(00 01 10 11 20 21 30 31 40 41 50 51 60 61 70 71)
- punpckhbw xmm0, xmm3 ; xmm0=(06 07 16 17 26 27 36 37 46 47 56 57 66 67 76 77)
- movdqa xmm6, xmm5 ; transpose coefficients(phase 1)
- punpcklbw xmm5, xmm7 ; xmm5=(02 03 12 13 22 23 32 33 42 43 52 53 62 63 72 73)
- punpckhbw xmm6, xmm7 ; xmm6=(04 05 14 15 24 25 34 35 44 45 54 55 64 65 74 75)
-
- movdqa xmm4, xmm1 ; transpose coefficients(phase 2)
- punpcklwd xmm1, xmm5 ; xmm1=(00 01 02 03 10 11 12 13 20 21 22 23 30 31 32 33)
- punpckhwd xmm4, xmm5 ; xmm4=(40 41 42 43 50 51 52 53 60 61 62 63 70 71 72 73)
- movdqa xmm2, xmm6 ; transpose coefficients(phase 2)
- punpcklwd xmm6, xmm0 ; xmm6=(04 05 06 07 14 15 16 17 24 25 26 27 34 35 36 37)
- punpckhwd xmm2, xmm0 ; xmm2=(44 45 46 47 54 55 56 57 64 65 66 67 74 75 76 77)
-
- movdqa xmm3, xmm1 ; transpose coefficients(phase 3)
- punpckldq xmm1, xmm6 ; xmm1=(00 01 02 03 04 05 06 07 10 11 12 13 14 15 16 17)
- punpckhdq xmm3, xmm6 ; xmm3=(20 21 22 23 24 25 26 27 30 31 32 33 34 35 36 37)
- movdqa xmm7, xmm4 ; transpose coefficients(phase 3)
- punpckldq xmm4, xmm2 ; xmm4=(40 41 42 43 44 45 46 47 50 51 52 53 54 55 56 57)
- punpckhdq xmm7, xmm2 ; xmm7=(60 61 62 63 64 65 66 67 70 71 72 73 74 75 76 77)
-
- pshufd xmm5, xmm1, 0x4E ; xmm5=(10 11 12 13 14 15 16 17 00 01 02 03 04 05 06 07)
- pshufd xmm0, xmm3, 0x4E ; xmm0=(30 31 32 33 34 35 36 37 20 21 22 23 24 25 26 27)
- pshufd xmm6, xmm4, 0x4E ; xmm6=(50 51 52 53 54 55 56 57 40 41 42 43 44 45 46 47)
- pshufd xmm2, xmm7, 0x4E ; xmm2=(70 71 72 73 74 75 76 77 60 61 62 63 64 65 66 67)
-
- mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW]
- mov esi, JSAMPROW [edi+2*SIZEOF_JSAMPROW]
- movq XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE], xmm1
- movq XMM_MMWORD [esi+eax*SIZEOF_JSAMPLE], xmm3
- mov edx, JSAMPROW [edi+4*SIZEOF_JSAMPROW]
- mov esi, JSAMPROW [edi+6*SIZEOF_JSAMPROW]
- movq XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE], xmm4
- movq XMM_MMWORD [esi+eax*SIZEOF_JSAMPLE], xmm7
-
- mov edx, JSAMPROW [edi+1*SIZEOF_JSAMPROW]
- mov esi, JSAMPROW [edi+3*SIZEOF_JSAMPROW]
- movq XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE], xmm5
- movq XMM_MMWORD [esi+eax*SIZEOF_JSAMPLE], xmm0
- mov edx, JSAMPROW [edi+5*SIZEOF_JSAMPROW]
- mov esi, JSAMPROW [edi+7*SIZEOF_JSAMPROW]
- movq XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE], xmm6
- movq XMM_MMWORD [esi+eax*SIZEOF_JSAMPLE], xmm2
-
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; unused
- poppic ebx
- mov esp, ebp ; esp <- aligned ebp
- pop esp ; esp <- original ebp
- pop ebp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jidctint-avx2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jidctint-avx2.asm
deleted file mode 100644
index 199c7df3b6..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jidctint-avx2.asm
+++ /dev/null
@@ -1,453 +0,0 @@
-;
-; jidctint.asm - accurate integer IDCT (AVX2)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, 2016, 2018, 2020, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-;
-; This file contains a slower but more accurate integer implementation of the
-; inverse DCT (Discrete Cosine Transform). The following code is based
-; directly on the IJG's original jidctint.c; see the jidctint.c for
-; more details.
-
-%include "jsimdext.inc"
-%include "jdct.inc"
-
-; --------------------------------------------------------------------------
-
-%define CONST_BITS 13
-%define PASS1_BITS 2
-
-%define DESCALE_P1 (CONST_BITS - PASS1_BITS)
-%define DESCALE_P2 (CONST_BITS + PASS1_BITS + 3)
-
-%if CONST_BITS == 13
-F_0_298 equ 2446 ; FIX(0.298631336)
-F_0_390 equ 3196 ; FIX(0.390180644)
-F_0_541 equ 4433 ; FIX(0.541196100)
-F_0_765 equ 6270 ; FIX(0.765366865)
-F_0_899 equ 7373 ; FIX(0.899976223)
-F_1_175 equ 9633 ; FIX(1.175875602)
-F_1_501 equ 12299 ; FIX(1.501321110)
-F_1_847 equ 15137 ; FIX(1.847759065)
-F_1_961 equ 16069 ; FIX(1.961570560)
-F_2_053 equ 16819 ; FIX(2.053119869)
-F_2_562 equ 20995 ; FIX(2.562915447)
-F_3_072 equ 25172 ; FIX(3.072711026)
-%else
-; NASM cannot do compile-time arithmetic on floating-point constants.
-%define DESCALE(x, n) (((x) + (1 << ((n) - 1))) >> (n))
-F_0_298 equ DESCALE( 320652955, 30 - CONST_BITS) ; FIX(0.298631336)
-F_0_390 equ DESCALE( 418953276, 30 - CONST_BITS) ; FIX(0.390180644)
-F_0_541 equ DESCALE( 581104887, 30 - CONST_BITS) ; FIX(0.541196100)
-F_0_765 equ DESCALE( 821806413, 30 - CONST_BITS) ; FIX(0.765366865)
-F_0_899 equ DESCALE( 966342111, 30 - CONST_BITS) ; FIX(0.899976223)
-F_1_175 equ DESCALE(1262586813, 30 - CONST_BITS) ; FIX(1.175875602)
-F_1_501 equ DESCALE(1612031267, 30 - CONST_BITS) ; FIX(1.501321110)
-F_1_847 equ DESCALE(1984016188, 30 - CONST_BITS) ; FIX(1.847759065)
-F_1_961 equ DESCALE(2106220350, 30 - CONST_BITS) ; FIX(1.961570560)
-F_2_053 equ DESCALE(2204520673, 30 - CONST_BITS) ; FIX(2.053119869)
-F_2_562 equ DESCALE(2751909506, 30 - CONST_BITS) ; FIX(2.562915447)
-F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
-%endif
-
-; --------------------------------------------------------------------------
-; In-place 8x8x16-bit inverse matrix transpose using AVX2 instructions
-; %1-%4: Input/output registers
-; %5-%8: Temp registers
-
-%macro dotranspose 8
- ; %5=(00 10 20 30 40 50 60 70 01 11 21 31 41 51 61 71)
- ; %6=(03 13 23 33 43 53 63 73 02 12 22 32 42 52 62 72)
- ; %7=(04 14 24 34 44 54 64 74 05 15 25 35 45 55 65 75)
- ; %8=(07 17 27 37 47 57 67 77 06 16 26 36 46 56 66 76)
-
- vpermq %5, %1, 0xD8
- vpermq %6, %2, 0x72
- vpermq %7, %3, 0xD8
- vpermq %8, %4, 0x72
- ; transpose coefficients(phase 1)
- ; %5=(00 10 20 30 01 11 21 31 40 50 60 70 41 51 61 71)
- ; %6=(02 12 22 32 03 13 23 33 42 52 62 72 43 53 63 73)
- ; %7=(04 14 24 34 05 15 25 35 44 54 64 74 45 55 65 75)
- ; %8=(06 16 26 36 07 17 27 37 46 56 66 76 47 57 67 77)
-
- vpunpcklwd %1, %5, %6
- vpunpckhwd %2, %5, %6
- vpunpcklwd %3, %7, %8
- vpunpckhwd %4, %7, %8
- ; transpose coefficients(phase 2)
- ; %1=(00 02 10 12 20 22 30 32 40 42 50 52 60 62 70 72)
- ; %2=(01 03 11 13 21 23 31 33 41 43 51 53 61 63 71 73)
- ; %3=(04 06 14 16 24 26 34 36 44 46 54 56 64 66 74 76)
- ; %4=(05 07 15 17 25 27 35 37 45 47 55 57 65 67 75 77)
-
- vpunpcklwd %5, %1, %2
- vpunpcklwd %6, %3, %4
- vpunpckhwd %7, %1, %2
- vpunpckhwd %8, %3, %4
- ; transpose coefficients(phase 3)
- ; %5=(00 01 02 03 10 11 12 13 40 41 42 43 50 51 52 53)
- ; %6=(04 05 06 07 14 15 16 17 44 45 46 47 54 55 56 57)
- ; %7=(20 21 22 23 30 31 32 33 60 61 62 63 70 71 72 73)
- ; %8=(24 25 26 27 34 35 36 37 64 65 66 67 74 75 76 77)
-
- vpunpcklqdq %1, %5, %6
- vpunpckhqdq %2, %5, %6
- vpunpcklqdq %3, %7, %8
- vpunpckhqdq %4, %7, %8
- ; transpose coefficients(phase 4)
- ; %1=(00 01 02 03 04 05 06 07 40 41 42 43 44 45 46 47)
- ; %2=(10 11 12 13 14 15 16 17 50 51 52 53 54 55 56 57)
- ; %3=(20 21 22 23 24 25 26 27 60 61 62 63 64 65 66 67)
- ; %4=(30 31 32 33 34 35 36 37 70 71 72 73 74 75 76 77)
-%endmacro
-
-; --------------------------------------------------------------------------
-; In-place 8x8x16-bit accurate integer inverse DCT using AVX2 instructions
-; %1-%4: Input/output registers
-; %5-%12: Temp registers
-; %9: Pass (1 or 2)
-
-%macro dodct 13
- ; -- Even part
-
- ; (Original)
- ; z1 = (z2 + z3) * 0.541196100;
- ; tmp2 = z1 + z3 * -1.847759065;
- ; tmp3 = z1 + z2 * 0.765366865;
- ;
- ; (This implementation)
- ; tmp2 = z2 * 0.541196100 + z3 * (0.541196100 - 1.847759065);
- ; tmp3 = z2 * (0.541196100 + 0.765366865) + z3 * 0.541196100;
-
- vperm2i128 %6, %3, %3, 0x01 ; %6=in6_2
- vpunpcklwd %5, %3, %6 ; %5=in26_62L
- vpunpckhwd %6, %3, %6 ; %6=in26_62H
- vpmaddwd %5, %5, [GOTOFF(ebx,PW_F130_F054_MF130_F054)] ; %5=tmp3_2L
- vpmaddwd %6, %6, [GOTOFF(ebx,PW_F130_F054_MF130_F054)] ; %6=tmp3_2H
-
- vperm2i128 %7, %1, %1, 0x01 ; %7=in4_0
- vpsignw %1, %1, [GOTOFF(ebx,PW_1_NEG1)]
- vpaddw %7, %7, %1 ; %7=(in0+in4)_(in0-in4)
-
- vpxor %1, %1, %1
- vpunpcklwd %8, %1, %7 ; %8=tmp0_1L
- vpunpckhwd %1, %1, %7 ; %1=tmp0_1H
- vpsrad %8, %8, (16-CONST_BITS) ; vpsrad %8,16 & vpslld %8,CONST_BITS
- vpsrad %1, %1, (16-CONST_BITS) ; vpsrad %1,16 & vpslld %1,CONST_BITS
-
- vpsubd %3, %8, %5
- vmovdqu %11, %3 ; %11=tmp0_1L-tmp3_2L=tmp13_12L
- vpaddd %3, %8, %5
- vmovdqu %9, %3 ; %9=tmp0_1L+tmp3_2L=tmp10_11L
- vpsubd %3, %1, %6
- vmovdqu %12, %3 ; %12=tmp0_1H-tmp3_2H=tmp13_12H
- vpaddd %3, %1, %6
- vmovdqu %10, %3 ; %10=tmp0_1H+tmp3_2H=tmp10_11H
-
- ; -- Odd part
-
- vpaddw %1, %4, %2 ; %1=in7_5+in3_1=z3_4
-
- ; (Original)
- ; z5 = (z3 + z4) * 1.175875602;
- ; z3 = z3 * -1.961570560; z4 = z4 * -0.390180644;
- ; z3 += z5; z4 += z5;
- ;
- ; (This implementation)
- ; z3 = z3 * (1.175875602 - 1.961570560) + z4 * 1.175875602;
- ; z4 = z3 * 1.175875602 + z4 * (1.175875602 - 0.390180644);
-
- vperm2i128 %8, %1, %1, 0x01 ; %8=z4_3
- vpunpcklwd %7, %1, %8 ; %7=z34_43L
- vpunpckhwd %8, %1, %8 ; %8=z34_43H
- vpmaddwd %7, %7, [GOTOFF(ebx,PW_MF078_F117_F078_F117)] ; %7=z3_4L
- vpmaddwd %8, %8, [GOTOFF(ebx,PW_MF078_F117_F078_F117)] ; %8=z3_4H
-
- ; (Original)
- ; z1 = tmp0 + tmp3; z2 = tmp1 + tmp2;
- ; tmp0 = tmp0 * 0.298631336; tmp1 = tmp1 * 2.053119869;
- ; tmp2 = tmp2 * 3.072711026; tmp3 = tmp3 * 1.501321110;
- ; z1 = z1 * -0.899976223; z2 = z2 * -2.562915447;
- ; tmp0 += z1 + z3; tmp1 += z2 + z4;
- ; tmp2 += z2 + z3; tmp3 += z1 + z4;
- ;
- ; (This implementation)
- ; tmp0 = tmp0 * (0.298631336 - 0.899976223) + tmp3 * -0.899976223;
- ; tmp1 = tmp1 * (2.053119869 - 2.562915447) + tmp2 * -2.562915447;
- ; tmp2 = tmp1 * -2.562915447 + tmp2 * (3.072711026 - 2.562915447);
- ; tmp3 = tmp0 * -0.899976223 + tmp3 * (1.501321110 - 0.899976223);
- ; tmp0 += z3; tmp1 += z4;
- ; tmp2 += z3; tmp3 += z4;
-
- vperm2i128 %2, %2, %2, 0x01 ; %2=in1_3
- vpunpcklwd %3, %4, %2 ; %3=in71_53L
- vpunpckhwd %4, %4, %2 ; %4=in71_53H
-
- vpmaddwd %5, %3, [GOTOFF(ebx,PW_MF060_MF089_MF050_MF256)] ; %5=tmp0_1L
- vpmaddwd %6, %4, [GOTOFF(ebx,PW_MF060_MF089_MF050_MF256)] ; %6=tmp0_1H
- vpaddd %5, %5, %7 ; %5=tmp0_1L+z3_4L=tmp0_1L
- vpaddd %6, %6, %8 ; %6=tmp0_1H+z3_4H=tmp0_1H
-
- vpmaddwd %3, %3, [GOTOFF(ebx,PW_MF089_F060_MF256_F050)] ; %3=tmp3_2L
- vpmaddwd %4, %4, [GOTOFF(ebx,PW_MF089_F060_MF256_F050)] ; %4=tmp3_2H
- vperm2i128 %7, %7, %7, 0x01 ; %7=z4_3L
- vperm2i128 %8, %8, %8, 0x01 ; %8=z4_3H
- vpaddd %7, %3, %7 ; %7=tmp3_2L+z4_3L=tmp3_2L
- vpaddd %8, %4, %8 ; %8=tmp3_2H+z4_3H=tmp3_2H
-
- ; -- Final output stage
-
- vmovdqu %3, %9
- vmovdqu %4, %10
-
- vpaddd %1, %3, %7 ; %1=tmp10_11L+tmp3_2L=data0_1L
- vpaddd %2, %4, %8 ; %2=tmp10_11H+tmp3_2H=data0_1H
- vpaddd %1, %1, [GOTOFF(ebx,PD_DESCALE_P %+ %13)]
- vpaddd %2, %2, [GOTOFF(ebx,PD_DESCALE_P %+ %13)]
- vpsrad %1, %1, DESCALE_P %+ %13
- vpsrad %2, %2, DESCALE_P %+ %13
- vpackssdw %1, %1, %2 ; %1=data0_1
-
- vpsubd %3, %3, %7 ; %3=tmp10_11L-tmp3_2L=data7_6L
- vpsubd %4, %4, %8 ; %4=tmp10_11H-tmp3_2H=data7_6H
- vpaddd %3, %3, [GOTOFF(ebx,PD_DESCALE_P %+ %13)]
- vpaddd %4, %4, [GOTOFF(ebx,PD_DESCALE_P %+ %13)]
- vpsrad %3, %3, DESCALE_P %+ %13
- vpsrad %4, %4, DESCALE_P %+ %13
- vpackssdw %4, %3, %4 ; %4=data7_6
-
- vmovdqu %7, %11
- vmovdqu %8, %12
-
- vpaddd %2, %7, %5 ; %7=tmp13_12L+tmp0_1L=data3_2L
- vpaddd %3, %8, %6 ; %8=tmp13_12H+tmp0_1H=data3_2H
- vpaddd %2, %2, [GOTOFF(ebx,PD_DESCALE_P %+ %13)]
- vpaddd %3, %3, [GOTOFF(ebx,PD_DESCALE_P %+ %13)]
- vpsrad %2, %2, DESCALE_P %+ %13
- vpsrad %3, %3, DESCALE_P %+ %13
- vpackssdw %2, %2, %3 ; %2=data3_2
-
- vpsubd %3, %7, %5 ; %7=tmp13_12L-tmp0_1L=data4_5L
- vpsubd %6, %8, %6 ; %8=tmp13_12H-tmp0_1H=data4_5H
- vpaddd %3, %3, [GOTOFF(ebx,PD_DESCALE_P %+ %13)]
- vpaddd %6, %6, [GOTOFF(ebx,PD_DESCALE_P %+ %13)]
- vpsrad %3, %3, DESCALE_P %+ %13
- vpsrad %6, %6, DESCALE_P %+ %13
- vpackssdw %3, %3, %6 ; %3=data4_5
-%endmacro
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_idct_islow_avx2)
-
-EXTN(jconst_idct_islow_avx2):
-
-PW_F130_F054_MF130_F054 times 4 dw (F_0_541 + F_0_765), F_0_541
- times 4 dw (F_0_541 - F_1_847), F_0_541
-PW_MF078_F117_F078_F117 times 4 dw (F_1_175 - F_1_961), F_1_175
- times 4 dw (F_1_175 - F_0_390), F_1_175
-PW_MF060_MF089_MF050_MF256 times 4 dw (F_0_298 - F_0_899), -F_0_899
- times 4 dw (F_2_053 - F_2_562), -F_2_562
-PW_MF089_F060_MF256_F050 times 4 dw -F_0_899, (F_1_501 - F_0_899)
- times 4 dw -F_2_562, (F_3_072 - F_2_562)
-PD_DESCALE_P1 times 8 dd 1 << (DESCALE_P1 - 1)
-PD_DESCALE_P2 times 8 dd 1 << (DESCALE_P2 - 1)
-PB_CENTERJSAMP times 32 db CENTERJSAMPLE
-PW_1_NEG1 times 8 dw 1
- times 8 dw -1
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-;
-; Perform dequantization and inverse DCT on one block of coefficients.
-;
-; GLOBAL(void)
-; jsimd_idct_islow_avx2(void *dct_table, JCOEFPTR coef_block,
-; JSAMPARRAY output_buf, JDIMENSION output_col)
-;
-
-%define dct_table(b) (b) + 8 ; jpeg_component_info *compptr
-%define coef_block(b) (b) + 12 ; JCOEFPTR coef_block
-%define output_buf(b) (b) + 16 ; JSAMPARRAY output_buf
-%define output_col(b) (b) + 20 ; JDIMENSION output_col
-
-%define original_ebp ebp + 0
-%define wk(i) ebp - (WK_NUM - (i)) * SIZEOF_YMMWORD
- ; ymmword wk[WK_NUM]
-%define WK_NUM 4
-
- align 32
- GLOBAL_FUNCTION(jsimd_idct_islow_avx2)
-
-EXTN(jsimd_idct_islow_avx2):
- push ebp
- mov eax, esp ; eax = original ebp
- sub esp, byte 4
- and esp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [esp], eax
- mov ebp, esp ; ebp = aligned ebp
- lea esp, [wk(0)]
- pushpic ebx
-; push ecx ; unused
-; push edx ; need not be preserved
- push esi
- push edi
-
- get_GOT ebx ; get GOT address
-
- ; ---- Pass 1: process columns.
-
-; mov eax, [original_ebp]
- mov edx, POINTER [dct_table(eax)] ; quantptr
- mov esi, JCOEFPTR [coef_block(eax)] ; inptr
-
-%ifndef NO_ZERO_COLUMN_TEST_ISLOW_AVX2
- mov eax, dword [DWBLOCK(1,0,esi,SIZEOF_JCOEF)]
- or eax, dword [DWBLOCK(2,0,esi,SIZEOF_JCOEF)]
- jnz near .columnDCT
-
- movdqa xmm0, XMMWORD [XMMBLOCK(1,0,esi,SIZEOF_JCOEF)]
- movdqa xmm1, XMMWORD [XMMBLOCK(2,0,esi,SIZEOF_JCOEF)]
- vpor xmm0, xmm0, XMMWORD [XMMBLOCK(3,0,esi,SIZEOF_JCOEF)]
- vpor xmm1, xmm1, XMMWORD [XMMBLOCK(4,0,esi,SIZEOF_JCOEF)]
- vpor xmm0, xmm0, XMMWORD [XMMBLOCK(5,0,esi,SIZEOF_JCOEF)]
- vpor xmm1, xmm1, XMMWORD [XMMBLOCK(6,0,esi,SIZEOF_JCOEF)]
- vpor xmm0, xmm0, XMMWORD [XMMBLOCK(7,0,esi,SIZEOF_JCOEF)]
- vpor xmm1, xmm1, xmm0
- vpacksswb xmm1, xmm1, xmm1
- vpacksswb xmm1, xmm1, xmm1
- movd eax, xmm1
- test eax, eax
- jnz short .columnDCT
-
- ; -- AC terms all zero
-
- movdqa xmm5, XMMWORD [XMMBLOCK(0,0,esi,SIZEOF_JCOEF)]
- vpmullw xmm5, xmm5, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
-
- vpsllw xmm5, xmm5, PASS1_BITS
-
- vpunpcklwd xmm4, xmm5, xmm5 ; xmm4=(00 00 01 01 02 02 03 03)
- vpunpckhwd xmm5, xmm5, xmm5 ; xmm5=(04 04 05 05 06 06 07 07)
- vinserti128 ymm4, ymm4, xmm5, 1
-
- vpshufd ymm0, ymm4, 0x00 ; ymm0=col0_4=(00 00 00 00 00 00 00 00 04 04 04 04 04 04 04 04)
- vpshufd ymm1, ymm4, 0x55 ; ymm1=col1_5=(01 01 01 01 01 01 01 01 05 05 05 05 05 05 05 05)
- vpshufd ymm2, ymm4, 0xAA ; ymm2=col2_6=(02 02 02 02 02 02 02 02 06 06 06 06 06 06 06 06)
- vpshufd ymm3, ymm4, 0xFF ; ymm3=col3_7=(03 03 03 03 03 03 03 03 07 07 07 07 07 07 07 07)
-
- jmp near .column_end
- alignx 16, 7
-%endif
-.columnDCT:
-
- vmovdqu ymm4, YMMWORD [YMMBLOCK(0,0,esi,SIZEOF_JCOEF)] ; ymm4=in0_1
- vmovdqu ymm5, YMMWORD [YMMBLOCK(2,0,esi,SIZEOF_JCOEF)] ; ymm5=in2_3
- vmovdqu ymm6, YMMWORD [YMMBLOCK(4,0,esi,SIZEOF_JCOEF)] ; ymm6=in4_5
- vmovdqu ymm7, YMMWORD [YMMBLOCK(6,0,esi,SIZEOF_JCOEF)] ; ymm7=in6_7
- vpmullw ymm4, ymm4, YMMWORD [YMMBLOCK(0,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
- vpmullw ymm5, ymm5, YMMWORD [YMMBLOCK(2,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
- vpmullw ymm6, ymm6, YMMWORD [YMMBLOCK(4,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
- vpmullw ymm7, ymm7, YMMWORD [YMMBLOCK(6,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
-
- vperm2i128 ymm0, ymm4, ymm6, 0x20 ; ymm0=in0_4
- vperm2i128 ymm1, ymm5, ymm4, 0x31 ; ymm1=in3_1
- vperm2i128 ymm2, ymm5, ymm7, 0x20 ; ymm2=in2_6
- vperm2i128 ymm3, ymm7, ymm6, 0x31 ; ymm3=in7_5
-
- dodct ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7, XMMWORD [wk(0)], XMMWORD [wk(1)], XMMWORD [wk(2)], XMMWORD [wk(3)], 1
- ; ymm0=data0_1, ymm1=data3_2, ymm2=data4_5, ymm3=data7_6
-
- dotranspose ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7
- ; ymm0=data0_4, ymm1=data1_5, ymm2=data2_6, ymm3=data3_7
-
-.column_end:
-
- ; -- Prefetch the next coefficient block
-
- prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 0*32]
- prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 1*32]
- prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 2*32]
- prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 3*32]
-
- ; ---- Pass 2: process rows.
-
- mov eax, [original_ebp]
- mov edi, JSAMPARRAY [output_buf(eax)] ; (JSAMPROW *)
- mov eax, JDIMENSION [output_col(eax)]
-
- vperm2i128 ymm4, ymm3, ymm1, 0x31 ; ymm3=in7_5
- vperm2i128 ymm1, ymm3, ymm1, 0x20 ; ymm1=in3_1
-
- dodct ymm0, ymm1, ymm2, ymm4, ymm3, ymm5, ymm6, ymm7, XMMWORD [wk(0)], XMMWORD [wk(1)], XMMWORD [wk(2)], XMMWORD [wk(3)], 2
- ; ymm0=data0_1, ymm1=data3_2, ymm2=data4_5, ymm4=data7_6
-
- dotranspose ymm0, ymm1, ymm2, ymm4, ymm3, ymm5, ymm6, ymm7
- ; ymm0=data0_4, ymm1=data1_5, ymm2=data2_6, ymm4=data3_7
-
- vpacksswb ymm0, ymm0, ymm1 ; ymm0=data01_45
- vpacksswb ymm1, ymm2, ymm4 ; ymm1=data23_67
- vpaddb ymm0, ymm0, [GOTOFF(ebx,PB_CENTERJSAMP)]
- vpaddb ymm1, ymm1, [GOTOFF(ebx,PB_CENTERJSAMP)]
-
- vextracti128 xmm6, ymm1, 1 ; xmm3=data67
- vextracti128 xmm4, ymm0, 1 ; xmm2=data45
- vextracti128 xmm2, ymm1, 0 ; xmm1=data23
- vextracti128 xmm0, ymm0, 0 ; xmm0=data01
-
- vpshufd xmm1, xmm0, 0x4E ; xmm1=(10 11 12 13 14 15 16 17 00 01 02 03 04 05 06 07)
- vpshufd xmm3, xmm2, 0x4E ; xmm3=(30 31 32 33 34 35 36 37 20 21 22 23 24 25 26 27)
- vpshufd xmm5, xmm4, 0x4E ; xmm5=(50 51 52 53 54 55 56 57 40 41 42 43 44 45 46 47)
- vpshufd xmm7, xmm6, 0x4E ; xmm7=(70 71 72 73 74 75 76 77 60 61 62 63 64 65 66 67)
-
- vzeroupper
-
- mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW] ; (JSAMPLE *)
- mov esi, JSAMPROW [edi+1*SIZEOF_JSAMPROW] ; (JSAMPLE *)
- movq XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE], xmm0
- movq XMM_MMWORD [esi+eax*SIZEOF_JSAMPLE], xmm1
-
- mov edx, JSAMPROW [edi+2*SIZEOF_JSAMPROW] ; (JSAMPLE *)
- mov esi, JSAMPROW [edi+3*SIZEOF_JSAMPROW] ; (JSAMPLE *)
- movq XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE], xmm2
- movq XMM_MMWORD [esi+eax*SIZEOF_JSAMPLE], xmm3
-
- mov edx, JSAMPROW [edi+4*SIZEOF_JSAMPROW] ; (JSAMPLE *)
- mov esi, JSAMPROW [edi+5*SIZEOF_JSAMPROW] ; (JSAMPLE *)
- movq XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE], xmm4
- movq XMM_MMWORD [esi+eax*SIZEOF_JSAMPLE], xmm5
-
- mov edx, JSAMPROW [edi+6*SIZEOF_JSAMPROW] ; (JSAMPLE *)
- mov esi, JSAMPROW [edi+7*SIZEOF_JSAMPROW] ; (JSAMPLE *)
- movq XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE], xmm6
- movq XMM_MMWORD [esi+eax*SIZEOF_JSAMPLE], xmm7
-
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; unused
- poppic ebx
- mov esp, ebp ; esp <- aligned ebp
- pop esp ; esp <- original ebp
- pop ebp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jidctint-mmx.asm b/contrib/libs/libjpeg-turbo/simd/i386/jidctint-mmx.asm
deleted file mode 100644
index f15c8d34bc..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jidctint-mmx.asm
+++ /dev/null
@@ -1,851 +0,0 @@
-;
-; jidctint.asm - accurate integer IDCT (MMX)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2016, 2020, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-;
-; This file contains a slower but more accurate integer implementation of the
-; inverse DCT (Discrete Cosine Transform). The following code is based
-; directly on the IJG's original jidctint.c; see the jidctint.c for
-; more details.
-
-%include "jsimdext.inc"
-%include "jdct.inc"
-
-; --------------------------------------------------------------------------
-
-%define CONST_BITS 13
-%define PASS1_BITS 2
-
-%define DESCALE_P1 (CONST_BITS - PASS1_BITS)
-%define DESCALE_P2 (CONST_BITS + PASS1_BITS + 3)
-
-%if CONST_BITS == 13
-F_0_298 equ 2446 ; FIX(0.298631336)
-F_0_390 equ 3196 ; FIX(0.390180644)
-F_0_541 equ 4433 ; FIX(0.541196100)
-F_0_765 equ 6270 ; FIX(0.765366865)
-F_0_899 equ 7373 ; FIX(0.899976223)
-F_1_175 equ 9633 ; FIX(1.175875602)
-F_1_501 equ 12299 ; FIX(1.501321110)
-F_1_847 equ 15137 ; FIX(1.847759065)
-F_1_961 equ 16069 ; FIX(1.961570560)
-F_2_053 equ 16819 ; FIX(2.053119869)
-F_2_562 equ 20995 ; FIX(2.562915447)
-F_3_072 equ 25172 ; FIX(3.072711026)
-%else
-; NASM cannot do compile-time arithmetic on floating-point constants.
-%define DESCALE(x, n) (((x) + (1 << ((n) - 1))) >> (n))
-F_0_298 equ DESCALE( 320652955, 30 - CONST_BITS) ; FIX(0.298631336)
-F_0_390 equ DESCALE( 418953276, 30 - CONST_BITS) ; FIX(0.390180644)
-F_0_541 equ DESCALE( 581104887, 30 - CONST_BITS) ; FIX(0.541196100)
-F_0_765 equ DESCALE( 821806413, 30 - CONST_BITS) ; FIX(0.765366865)
-F_0_899 equ DESCALE( 966342111, 30 - CONST_BITS) ; FIX(0.899976223)
-F_1_175 equ DESCALE(1262586813, 30 - CONST_BITS) ; FIX(1.175875602)
-F_1_501 equ DESCALE(1612031267, 30 - CONST_BITS) ; FIX(1.501321110)
-F_1_847 equ DESCALE(1984016188, 30 - CONST_BITS) ; FIX(1.847759065)
-F_1_961 equ DESCALE(2106220350, 30 - CONST_BITS) ; FIX(1.961570560)
-F_2_053 equ DESCALE(2204520673, 30 - CONST_BITS) ; FIX(2.053119869)
-F_2_562 equ DESCALE(2751909506, 30 - CONST_BITS) ; FIX(2.562915447)
-F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
-%endif
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_idct_islow_mmx)
-
-EXTN(jconst_idct_islow_mmx):
-
-PW_F130_F054 times 2 dw (F_0_541 + F_0_765), F_0_541
-PW_F054_MF130 times 2 dw F_0_541, (F_0_541 - F_1_847)
-PW_MF078_F117 times 2 dw (F_1_175 - F_1_961), F_1_175
-PW_F117_F078 times 2 dw F_1_175, (F_1_175 - F_0_390)
-PW_MF060_MF089 times 2 dw (F_0_298 - F_0_899), -F_0_899
-PW_MF089_F060 times 2 dw -F_0_899, (F_1_501 - F_0_899)
-PW_MF050_MF256 times 2 dw (F_2_053 - F_2_562), -F_2_562
-PW_MF256_F050 times 2 dw -F_2_562, (F_3_072 - F_2_562)
-PD_DESCALE_P1 times 2 dd 1 << (DESCALE_P1 - 1)
-PD_DESCALE_P2 times 2 dd 1 << (DESCALE_P2 - 1)
-PB_CENTERJSAMP times 8 db CENTERJSAMPLE
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-;
-; Perform dequantization and inverse DCT on one block of coefficients.
-;
-; GLOBAL(void)
-; jsimd_idct_islow_mmx(void *dct_table, JCOEFPTR coef_block,
-; JSAMPARRAY output_buf, JDIMENSION output_col)
-;
-
-%define dct_table(b) (b) + 8 ; jpeg_component_info *compptr
-%define coef_block(b) (b) + 12 ; JCOEFPTR coef_block
-%define output_buf(b) (b) + 16 ; JSAMPARRAY output_buf
-%define output_col(b) (b) + 20 ; JDIMENSION output_col
-
-%define original_ebp ebp + 0
-%define wk(i) ebp - (WK_NUM - (i)) * SIZEOF_MMWORD
- ; mmword wk[WK_NUM]
-%define WK_NUM 12
-%define workspace wk(0) - DCTSIZE2 * SIZEOF_JCOEF
- ; JCOEF workspace[DCTSIZE2]
-
- align 32
- GLOBAL_FUNCTION(jsimd_idct_islow_mmx)
-
-EXTN(jsimd_idct_islow_mmx):
- push ebp
- mov eax, esp ; eax = original ebp
- sub esp, byte 4
- and esp, byte (-SIZEOF_MMWORD) ; align to 64 bits
- mov [esp], eax
- mov ebp, esp ; ebp = aligned ebp
- lea esp, [workspace]
- push ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- get_GOT ebx ; get GOT address
-
- ; ---- Pass 1: process columns from input, store into work array.
-
-; mov eax, [original_ebp]
- mov edx, POINTER [dct_table(eax)] ; quantptr
- mov esi, JCOEFPTR [coef_block(eax)] ; inptr
- lea edi, [workspace] ; JCOEF *wsptr
- mov ecx, DCTSIZE/4 ; ctr
- alignx 16, 7
-.columnloop:
-%ifndef NO_ZERO_COLUMN_TEST_ISLOW_MMX
- mov eax, dword [DWBLOCK(1,0,esi,SIZEOF_JCOEF)]
- or eax, dword [DWBLOCK(2,0,esi,SIZEOF_JCOEF)]
- jnz short .columnDCT
-
- movq mm0, MMWORD [MMBLOCK(1,0,esi,SIZEOF_JCOEF)]
- movq mm1, MMWORD [MMBLOCK(2,0,esi,SIZEOF_JCOEF)]
- por mm0, MMWORD [MMBLOCK(3,0,esi,SIZEOF_JCOEF)]
- por mm1, MMWORD [MMBLOCK(4,0,esi,SIZEOF_JCOEF)]
- por mm0, MMWORD [MMBLOCK(5,0,esi,SIZEOF_JCOEF)]
- por mm1, MMWORD [MMBLOCK(6,0,esi,SIZEOF_JCOEF)]
- por mm0, MMWORD [MMBLOCK(7,0,esi,SIZEOF_JCOEF)]
- por mm1, mm0
- packsswb mm1, mm1
- movd eax, mm1
- test eax, eax
- jnz short .columnDCT
-
- ; -- AC terms all zero
-
- movq mm0, MMWORD [MMBLOCK(0,0,esi,SIZEOF_JCOEF)]
- pmullw mm0, MMWORD [MMBLOCK(0,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
-
- psllw mm0, PASS1_BITS
-
- movq mm2, mm0 ; mm0=in0=(00 01 02 03)
- punpcklwd mm0, mm0 ; mm0=(00 00 01 01)
- punpckhwd mm2, mm2 ; mm2=(02 02 03 03)
-
- movq mm1, mm0
- punpckldq mm0, mm0 ; mm0=(00 00 00 00)
- punpckhdq mm1, mm1 ; mm1=(01 01 01 01)
- movq mm3, mm2
- punpckldq mm2, mm2 ; mm2=(02 02 02 02)
- punpckhdq mm3, mm3 ; mm3=(03 03 03 03)
-
- movq MMWORD [MMBLOCK(0,0,edi,SIZEOF_JCOEF)], mm0
- movq MMWORD [MMBLOCK(0,1,edi,SIZEOF_JCOEF)], mm0
- movq MMWORD [MMBLOCK(1,0,edi,SIZEOF_JCOEF)], mm1
- movq MMWORD [MMBLOCK(1,1,edi,SIZEOF_JCOEF)], mm1
- movq MMWORD [MMBLOCK(2,0,edi,SIZEOF_JCOEF)], mm2
- movq MMWORD [MMBLOCK(2,1,edi,SIZEOF_JCOEF)], mm2
- movq MMWORD [MMBLOCK(3,0,edi,SIZEOF_JCOEF)], mm3
- movq MMWORD [MMBLOCK(3,1,edi,SIZEOF_JCOEF)], mm3
- jmp near .nextcolumn
- alignx 16, 7
-%endif
-.columnDCT:
-
- ; -- Even part
-
- movq mm0, MMWORD [MMBLOCK(0,0,esi,SIZEOF_JCOEF)]
- movq mm1, MMWORD [MMBLOCK(2,0,esi,SIZEOF_JCOEF)]
- pmullw mm0, MMWORD [MMBLOCK(0,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
- pmullw mm1, MMWORD [MMBLOCK(2,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
- movq mm2, MMWORD [MMBLOCK(4,0,esi,SIZEOF_JCOEF)]
- movq mm3, MMWORD [MMBLOCK(6,0,esi,SIZEOF_JCOEF)]
- pmullw mm2, MMWORD [MMBLOCK(4,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
- pmullw mm3, MMWORD [MMBLOCK(6,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
-
- ; (Original)
- ; z1 = (z2 + z3) * 0.541196100;
- ; tmp2 = z1 + z3 * -1.847759065;
- ; tmp3 = z1 + z2 * 0.765366865;
- ;
- ; (This implementation)
- ; tmp2 = z2 * 0.541196100 + z3 * (0.541196100 - 1.847759065);
- ; tmp3 = z2 * (0.541196100 + 0.765366865) + z3 * 0.541196100;
-
- movq mm4, mm1 ; mm1=in2=z2
- movq mm5, mm1
- punpcklwd mm4, mm3 ; mm3=in6=z3
- punpckhwd mm5, mm3
- movq mm1, mm4
- movq mm3, mm5
- pmaddwd mm4, [GOTOFF(ebx,PW_F130_F054)] ; mm4=tmp3L
- pmaddwd mm5, [GOTOFF(ebx,PW_F130_F054)] ; mm5=tmp3H
- pmaddwd mm1, [GOTOFF(ebx,PW_F054_MF130)] ; mm1=tmp2L
- pmaddwd mm3, [GOTOFF(ebx,PW_F054_MF130)] ; mm3=tmp2H
-
- movq mm6, mm0
- paddw mm0, mm2 ; mm0=in0+in4
- psubw mm6, mm2 ; mm6=in0-in4
-
- pxor mm7, mm7
- pxor mm2, mm2
- punpcklwd mm7, mm0 ; mm7=tmp0L
- punpckhwd mm2, mm0 ; mm2=tmp0H
- psrad mm7, (16-CONST_BITS) ; psrad mm7,16 & pslld mm7,CONST_BITS
- psrad mm2, (16-CONST_BITS) ; psrad mm2,16 & pslld mm2,CONST_BITS
-
- movq mm0, mm7
- paddd mm7, mm4 ; mm7=tmp10L
- psubd mm0, mm4 ; mm0=tmp13L
- movq mm4, mm2
- paddd mm2, mm5 ; mm2=tmp10H
- psubd mm4, mm5 ; mm4=tmp13H
-
- movq MMWORD [wk(0)], mm7 ; wk(0)=tmp10L
- movq MMWORD [wk(1)], mm2 ; wk(1)=tmp10H
- movq MMWORD [wk(2)], mm0 ; wk(2)=tmp13L
- movq MMWORD [wk(3)], mm4 ; wk(3)=tmp13H
-
- pxor mm5, mm5
- pxor mm7, mm7
- punpcklwd mm5, mm6 ; mm5=tmp1L
- punpckhwd mm7, mm6 ; mm7=tmp1H
- psrad mm5, (16-CONST_BITS) ; psrad mm5,16 & pslld mm5,CONST_BITS
- psrad mm7, (16-CONST_BITS) ; psrad mm7,16 & pslld mm7,CONST_BITS
-
- movq mm2, mm5
- paddd mm5, mm1 ; mm5=tmp11L
- psubd mm2, mm1 ; mm2=tmp12L
- movq mm0, mm7
- paddd mm7, mm3 ; mm7=tmp11H
- psubd mm0, mm3 ; mm0=tmp12H
-
- movq MMWORD [wk(4)], mm5 ; wk(4)=tmp11L
- movq MMWORD [wk(5)], mm7 ; wk(5)=tmp11H
- movq MMWORD [wk(6)], mm2 ; wk(6)=tmp12L
- movq MMWORD [wk(7)], mm0 ; wk(7)=tmp12H
-
- ; -- Odd part
-
- movq mm4, MMWORD [MMBLOCK(1,0,esi,SIZEOF_JCOEF)]
- movq mm6, MMWORD [MMBLOCK(3,0,esi,SIZEOF_JCOEF)]
- pmullw mm4, MMWORD [MMBLOCK(1,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
- pmullw mm6, MMWORD [MMBLOCK(3,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
- movq mm1, MMWORD [MMBLOCK(5,0,esi,SIZEOF_JCOEF)]
- movq mm3, MMWORD [MMBLOCK(7,0,esi,SIZEOF_JCOEF)]
- pmullw mm1, MMWORD [MMBLOCK(5,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
- pmullw mm3, MMWORD [MMBLOCK(7,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
-
- movq mm5, mm6
- movq mm7, mm4
- paddw mm5, mm3 ; mm5=z3
- paddw mm7, mm1 ; mm7=z4
-
- ; (Original)
- ; z5 = (z3 + z4) * 1.175875602;
- ; z3 = z3 * -1.961570560; z4 = z4 * -0.390180644;
- ; z3 += z5; z4 += z5;
- ;
- ; (This implementation)
- ; z3 = z3 * (1.175875602 - 1.961570560) + z4 * 1.175875602;
- ; z4 = z3 * 1.175875602 + z4 * (1.175875602 - 0.390180644);
-
- movq mm2, mm5
- movq mm0, mm5
- punpcklwd mm2, mm7
- punpckhwd mm0, mm7
- movq mm5, mm2
- movq mm7, mm0
- pmaddwd mm2, [GOTOFF(ebx,PW_MF078_F117)] ; mm2=z3L
- pmaddwd mm0, [GOTOFF(ebx,PW_MF078_F117)] ; mm0=z3H
- pmaddwd mm5, [GOTOFF(ebx,PW_F117_F078)] ; mm5=z4L
- pmaddwd mm7, [GOTOFF(ebx,PW_F117_F078)] ; mm7=z4H
-
- movq MMWORD [wk(10)], mm2 ; wk(10)=z3L
- movq MMWORD [wk(11)], mm0 ; wk(11)=z3H
-
- ; (Original)
- ; z1 = tmp0 + tmp3; z2 = tmp1 + tmp2;
- ; tmp0 = tmp0 * 0.298631336; tmp1 = tmp1 * 2.053119869;
- ; tmp2 = tmp2 * 3.072711026; tmp3 = tmp3 * 1.501321110;
- ; z1 = z1 * -0.899976223; z2 = z2 * -2.562915447;
- ; tmp0 += z1 + z3; tmp1 += z2 + z4;
- ; tmp2 += z2 + z3; tmp3 += z1 + z4;
- ;
- ; (This implementation)
- ; tmp0 = tmp0 * (0.298631336 - 0.899976223) + tmp3 * -0.899976223;
- ; tmp1 = tmp1 * (2.053119869 - 2.562915447) + tmp2 * -2.562915447;
- ; tmp2 = tmp1 * -2.562915447 + tmp2 * (3.072711026 - 2.562915447);
- ; tmp3 = tmp0 * -0.899976223 + tmp3 * (1.501321110 - 0.899976223);
- ; tmp0 += z3; tmp1 += z4;
- ; tmp2 += z3; tmp3 += z4;
-
- movq mm2, mm3
- movq mm0, mm3
- punpcklwd mm2, mm4
- punpckhwd mm0, mm4
- movq mm3, mm2
- movq mm4, mm0
- pmaddwd mm2, [GOTOFF(ebx,PW_MF060_MF089)] ; mm2=tmp0L
- pmaddwd mm0, [GOTOFF(ebx,PW_MF060_MF089)] ; mm0=tmp0H
- pmaddwd mm3, [GOTOFF(ebx,PW_MF089_F060)] ; mm3=tmp3L
- pmaddwd mm4, [GOTOFF(ebx,PW_MF089_F060)] ; mm4=tmp3H
-
- paddd mm2, MMWORD [wk(10)] ; mm2=tmp0L
- paddd mm0, MMWORD [wk(11)] ; mm0=tmp0H
- paddd mm3, mm5 ; mm3=tmp3L
- paddd mm4, mm7 ; mm4=tmp3H
-
- movq MMWORD [wk(8)], mm2 ; wk(8)=tmp0L
- movq MMWORD [wk(9)], mm0 ; wk(9)=tmp0H
-
- movq mm2, mm1
- movq mm0, mm1
- punpcklwd mm2, mm6
- punpckhwd mm0, mm6
- movq mm1, mm2
- movq mm6, mm0
- pmaddwd mm2, [GOTOFF(ebx,PW_MF050_MF256)] ; mm2=tmp1L
- pmaddwd mm0, [GOTOFF(ebx,PW_MF050_MF256)] ; mm0=tmp1H
- pmaddwd mm1, [GOTOFF(ebx,PW_MF256_F050)] ; mm1=tmp2L
- pmaddwd mm6, [GOTOFF(ebx,PW_MF256_F050)] ; mm6=tmp2H
-
- paddd mm2, mm5 ; mm2=tmp1L
- paddd mm0, mm7 ; mm0=tmp1H
- paddd mm1, MMWORD [wk(10)] ; mm1=tmp2L
- paddd mm6, MMWORD [wk(11)] ; mm6=tmp2H
-
- movq MMWORD [wk(10)], mm2 ; wk(10)=tmp1L
- movq MMWORD [wk(11)], mm0 ; wk(11)=tmp1H
-
- ; -- Final output stage
-
- movq mm5, MMWORD [wk(0)] ; mm5=tmp10L
- movq mm7, MMWORD [wk(1)] ; mm7=tmp10H
-
- movq mm2, mm5
- movq mm0, mm7
- paddd mm5, mm3 ; mm5=data0L
- paddd mm7, mm4 ; mm7=data0H
- psubd mm2, mm3 ; mm2=data7L
- psubd mm0, mm4 ; mm0=data7H
-
- movq mm3, [GOTOFF(ebx,PD_DESCALE_P1)] ; mm3=[PD_DESCALE_P1]
-
- paddd mm5, mm3
- paddd mm7, mm3
- psrad mm5, DESCALE_P1
- psrad mm7, DESCALE_P1
- paddd mm2, mm3
- paddd mm0, mm3
- psrad mm2, DESCALE_P1
- psrad mm0, DESCALE_P1
-
- packssdw mm5, mm7 ; mm5=data0=(00 01 02 03)
- packssdw mm2, mm0 ; mm2=data7=(70 71 72 73)
-
- movq mm4, MMWORD [wk(4)] ; mm4=tmp11L
- movq mm3, MMWORD [wk(5)] ; mm3=tmp11H
-
- movq mm7, mm4
- movq mm0, mm3
- paddd mm4, mm1 ; mm4=data1L
- paddd mm3, mm6 ; mm3=data1H
- psubd mm7, mm1 ; mm7=data6L
- psubd mm0, mm6 ; mm0=data6H
-
- movq mm1, [GOTOFF(ebx,PD_DESCALE_P1)] ; mm1=[PD_DESCALE_P1]
-
- paddd mm4, mm1
- paddd mm3, mm1
- psrad mm4, DESCALE_P1
- psrad mm3, DESCALE_P1
- paddd mm7, mm1
- paddd mm0, mm1
- psrad mm7, DESCALE_P1
- psrad mm0, DESCALE_P1
-
- packssdw mm4, mm3 ; mm4=data1=(10 11 12 13)
- packssdw mm7, mm0 ; mm7=data6=(60 61 62 63)
-
- movq mm6, mm5 ; transpose coefficients(phase 1)
- punpcklwd mm5, mm4 ; mm5=(00 10 01 11)
- punpckhwd mm6, mm4 ; mm6=(02 12 03 13)
- movq mm1, mm7 ; transpose coefficients(phase 1)
- punpcklwd mm7, mm2 ; mm7=(60 70 61 71)
- punpckhwd mm1, mm2 ; mm1=(62 72 63 73)
-
- movq mm3, MMWORD [wk(6)] ; mm3=tmp12L
- movq mm0, MMWORD [wk(7)] ; mm0=tmp12H
- movq mm4, MMWORD [wk(10)] ; mm4=tmp1L
- movq mm2, MMWORD [wk(11)] ; mm2=tmp1H
-
- movq MMWORD [wk(0)], mm5 ; wk(0)=(00 10 01 11)
- movq MMWORD [wk(1)], mm6 ; wk(1)=(02 12 03 13)
- movq MMWORD [wk(4)], mm7 ; wk(4)=(60 70 61 71)
- movq MMWORD [wk(5)], mm1 ; wk(5)=(62 72 63 73)
-
- movq mm5, mm3
- movq mm6, mm0
- paddd mm3, mm4 ; mm3=data2L
- paddd mm0, mm2 ; mm0=data2H
- psubd mm5, mm4 ; mm5=data5L
- psubd mm6, mm2 ; mm6=data5H
-
- movq mm7, [GOTOFF(ebx,PD_DESCALE_P1)] ; mm7=[PD_DESCALE_P1]
-
- paddd mm3, mm7
- paddd mm0, mm7
- psrad mm3, DESCALE_P1
- psrad mm0, DESCALE_P1
- paddd mm5, mm7
- paddd mm6, mm7
- psrad mm5, DESCALE_P1
- psrad mm6, DESCALE_P1
-
- packssdw mm3, mm0 ; mm3=data2=(20 21 22 23)
- packssdw mm5, mm6 ; mm5=data5=(50 51 52 53)
-
- movq mm1, MMWORD [wk(2)] ; mm1=tmp13L
- movq mm4, MMWORD [wk(3)] ; mm4=tmp13H
- movq mm2, MMWORD [wk(8)] ; mm2=tmp0L
- movq mm7, MMWORD [wk(9)] ; mm7=tmp0H
-
- movq mm0, mm1
- movq mm6, mm4
- paddd mm1, mm2 ; mm1=data3L
- paddd mm4, mm7 ; mm4=data3H
- psubd mm0, mm2 ; mm0=data4L
- psubd mm6, mm7 ; mm6=data4H
-
- movq mm2, [GOTOFF(ebx,PD_DESCALE_P1)] ; mm2=[PD_DESCALE_P1]
-
- paddd mm1, mm2
- paddd mm4, mm2
- psrad mm1, DESCALE_P1
- psrad mm4, DESCALE_P1
- paddd mm0, mm2
- paddd mm6, mm2
- psrad mm0, DESCALE_P1
- psrad mm6, DESCALE_P1
-
- packssdw mm1, mm4 ; mm1=data3=(30 31 32 33)
- packssdw mm0, mm6 ; mm0=data4=(40 41 42 43)
-
- movq mm7, MMWORD [wk(0)] ; mm7=(00 10 01 11)
- movq mm2, MMWORD [wk(1)] ; mm2=(02 12 03 13)
-
- movq mm4, mm3 ; transpose coefficients(phase 1)
- punpcklwd mm3, mm1 ; mm3=(20 30 21 31)
- punpckhwd mm4, mm1 ; mm4=(22 32 23 33)
- movq mm6, mm0 ; transpose coefficients(phase 1)
- punpcklwd mm0, mm5 ; mm0=(40 50 41 51)
- punpckhwd mm6, mm5 ; mm6=(42 52 43 53)
-
- movq mm1, mm7 ; transpose coefficients(phase 2)
- punpckldq mm7, mm3 ; mm7=(00 10 20 30)
- punpckhdq mm1, mm3 ; mm1=(01 11 21 31)
- movq mm5, mm2 ; transpose coefficients(phase 2)
- punpckldq mm2, mm4 ; mm2=(02 12 22 32)
- punpckhdq mm5, mm4 ; mm5=(03 13 23 33)
-
- movq mm3, MMWORD [wk(4)] ; mm3=(60 70 61 71)
- movq mm4, MMWORD [wk(5)] ; mm4=(62 72 63 73)
-
- movq MMWORD [MMBLOCK(0,0,edi,SIZEOF_JCOEF)], mm7
- movq MMWORD [MMBLOCK(1,0,edi,SIZEOF_JCOEF)], mm1
- movq MMWORD [MMBLOCK(2,0,edi,SIZEOF_JCOEF)], mm2
- movq MMWORD [MMBLOCK(3,0,edi,SIZEOF_JCOEF)], mm5
-
- movq mm7, mm0 ; transpose coefficients(phase 2)
- punpckldq mm0, mm3 ; mm0=(40 50 60 70)
- punpckhdq mm7, mm3 ; mm7=(41 51 61 71)
- movq mm1, mm6 ; transpose coefficients(phase 2)
- punpckldq mm6, mm4 ; mm6=(42 52 62 72)
- punpckhdq mm1, mm4 ; mm1=(43 53 63 73)
-
- movq MMWORD [MMBLOCK(0,1,edi,SIZEOF_JCOEF)], mm0
- movq MMWORD [MMBLOCK(1,1,edi,SIZEOF_JCOEF)], mm7
- movq MMWORD [MMBLOCK(2,1,edi,SIZEOF_JCOEF)], mm6
- movq MMWORD [MMBLOCK(3,1,edi,SIZEOF_JCOEF)], mm1
-
-.nextcolumn:
- add esi, byte 4*SIZEOF_JCOEF ; coef_block
- add edx, byte 4*SIZEOF_ISLOW_MULT_TYPE ; quantptr
- add edi, byte 4*DCTSIZE*SIZEOF_JCOEF ; wsptr
- dec ecx ; ctr
- jnz near .columnloop
-
- ; ---- Pass 2: process rows from work array, store into output array.
-
- mov eax, [original_ebp]
- lea esi, [workspace] ; JCOEF *wsptr
- mov edi, JSAMPARRAY [output_buf(eax)] ; (JSAMPROW *)
- mov eax, JDIMENSION [output_col(eax)]
- mov ecx, DCTSIZE/4 ; ctr
- alignx 16, 7
-.rowloop:
-
- ; -- Even part
-
- movq mm0, MMWORD [MMBLOCK(0,0,esi,SIZEOF_JCOEF)]
- movq mm1, MMWORD [MMBLOCK(2,0,esi,SIZEOF_JCOEF)]
- movq mm2, MMWORD [MMBLOCK(4,0,esi,SIZEOF_JCOEF)]
- movq mm3, MMWORD [MMBLOCK(6,0,esi,SIZEOF_JCOEF)]
-
- ; (Original)
- ; z1 = (z2 + z3) * 0.541196100;
- ; tmp2 = z1 + z3 * -1.847759065;
- ; tmp3 = z1 + z2 * 0.765366865;
- ;
- ; (This implementation)
- ; tmp2 = z2 * 0.541196100 + z3 * (0.541196100 - 1.847759065);
- ; tmp3 = z2 * (0.541196100 + 0.765366865) + z3 * 0.541196100;
-
- movq mm4, mm1 ; mm1=in2=z2
- movq mm5, mm1
- punpcklwd mm4, mm3 ; mm3=in6=z3
- punpckhwd mm5, mm3
- movq mm1, mm4
- movq mm3, mm5
- pmaddwd mm4, [GOTOFF(ebx,PW_F130_F054)] ; mm4=tmp3L
- pmaddwd mm5, [GOTOFF(ebx,PW_F130_F054)] ; mm5=tmp3H
- pmaddwd mm1, [GOTOFF(ebx,PW_F054_MF130)] ; mm1=tmp2L
- pmaddwd mm3, [GOTOFF(ebx,PW_F054_MF130)] ; mm3=tmp2H
-
- movq mm6, mm0
- paddw mm0, mm2 ; mm0=in0+in4
- psubw mm6, mm2 ; mm6=in0-in4
-
- pxor mm7, mm7
- pxor mm2, mm2
- punpcklwd mm7, mm0 ; mm7=tmp0L
- punpckhwd mm2, mm0 ; mm2=tmp0H
- psrad mm7, (16-CONST_BITS) ; psrad mm7,16 & pslld mm7,CONST_BITS
- psrad mm2, (16-CONST_BITS) ; psrad mm2,16 & pslld mm2,CONST_BITS
-
- movq mm0, mm7
- paddd mm7, mm4 ; mm7=tmp10L
- psubd mm0, mm4 ; mm0=tmp13L
- movq mm4, mm2
- paddd mm2, mm5 ; mm2=tmp10H
- psubd mm4, mm5 ; mm4=tmp13H
-
- movq MMWORD [wk(0)], mm7 ; wk(0)=tmp10L
- movq MMWORD [wk(1)], mm2 ; wk(1)=tmp10H
- movq MMWORD [wk(2)], mm0 ; wk(2)=tmp13L
- movq MMWORD [wk(3)], mm4 ; wk(3)=tmp13H
-
- pxor mm5, mm5
- pxor mm7, mm7
- punpcklwd mm5, mm6 ; mm5=tmp1L
- punpckhwd mm7, mm6 ; mm7=tmp1H
- psrad mm5, (16-CONST_BITS) ; psrad mm5,16 & pslld mm5,CONST_BITS
- psrad mm7, (16-CONST_BITS) ; psrad mm7,16 & pslld mm7,CONST_BITS
-
- movq mm2, mm5
- paddd mm5, mm1 ; mm5=tmp11L
- psubd mm2, mm1 ; mm2=tmp12L
- movq mm0, mm7
- paddd mm7, mm3 ; mm7=tmp11H
- psubd mm0, mm3 ; mm0=tmp12H
-
- movq MMWORD [wk(4)], mm5 ; wk(4)=tmp11L
- movq MMWORD [wk(5)], mm7 ; wk(5)=tmp11H
- movq MMWORD [wk(6)], mm2 ; wk(6)=tmp12L
- movq MMWORD [wk(7)], mm0 ; wk(7)=tmp12H
-
- ; -- Odd part
-
- movq mm4, MMWORD [MMBLOCK(1,0,esi,SIZEOF_JCOEF)]
- movq mm6, MMWORD [MMBLOCK(3,0,esi,SIZEOF_JCOEF)]
- movq mm1, MMWORD [MMBLOCK(5,0,esi,SIZEOF_JCOEF)]
- movq mm3, MMWORD [MMBLOCK(7,0,esi,SIZEOF_JCOEF)]
-
- movq mm5, mm6
- movq mm7, mm4
- paddw mm5, mm3 ; mm5=z3
- paddw mm7, mm1 ; mm7=z4
-
- ; (Original)
- ; z5 = (z3 + z4) * 1.175875602;
- ; z3 = z3 * -1.961570560; z4 = z4 * -0.390180644;
- ; z3 += z5; z4 += z5;
- ;
- ; (This implementation)
- ; z3 = z3 * (1.175875602 - 1.961570560) + z4 * 1.175875602;
- ; z4 = z3 * 1.175875602 + z4 * (1.175875602 - 0.390180644);
-
- movq mm2, mm5
- movq mm0, mm5
- punpcklwd mm2, mm7
- punpckhwd mm0, mm7
- movq mm5, mm2
- movq mm7, mm0
- pmaddwd mm2, [GOTOFF(ebx,PW_MF078_F117)] ; mm2=z3L
- pmaddwd mm0, [GOTOFF(ebx,PW_MF078_F117)] ; mm0=z3H
- pmaddwd mm5, [GOTOFF(ebx,PW_F117_F078)] ; mm5=z4L
- pmaddwd mm7, [GOTOFF(ebx,PW_F117_F078)] ; mm7=z4H
-
- movq MMWORD [wk(10)], mm2 ; wk(10)=z3L
- movq MMWORD [wk(11)], mm0 ; wk(11)=z3H
-
- ; (Original)
- ; z1 = tmp0 + tmp3; z2 = tmp1 + tmp2;
- ; tmp0 = tmp0 * 0.298631336; tmp1 = tmp1 * 2.053119869;
- ; tmp2 = tmp2 * 3.072711026; tmp3 = tmp3 * 1.501321110;
- ; z1 = z1 * -0.899976223; z2 = z2 * -2.562915447;
- ; tmp0 += z1 + z3; tmp1 += z2 + z4;
- ; tmp2 += z2 + z3; tmp3 += z1 + z4;
- ;
- ; (This implementation)
- ; tmp0 = tmp0 * (0.298631336 - 0.899976223) + tmp3 * -0.899976223;
- ; tmp1 = tmp1 * (2.053119869 - 2.562915447) + tmp2 * -2.562915447;
- ; tmp2 = tmp1 * -2.562915447 + tmp2 * (3.072711026 - 2.562915447);
- ; tmp3 = tmp0 * -0.899976223 + tmp3 * (1.501321110 - 0.899976223);
- ; tmp0 += z3; tmp1 += z4;
- ; tmp2 += z3; tmp3 += z4;
-
- movq mm2, mm3
- movq mm0, mm3
- punpcklwd mm2, mm4
- punpckhwd mm0, mm4
- movq mm3, mm2
- movq mm4, mm0
- pmaddwd mm2, [GOTOFF(ebx,PW_MF060_MF089)] ; mm2=tmp0L
- pmaddwd mm0, [GOTOFF(ebx,PW_MF060_MF089)] ; mm0=tmp0H
- pmaddwd mm3, [GOTOFF(ebx,PW_MF089_F060)] ; mm3=tmp3L
- pmaddwd mm4, [GOTOFF(ebx,PW_MF089_F060)] ; mm4=tmp3H
-
- paddd mm2, MMWORD [wk(10)] ; mm2=tmp0L
- paddd mm0, MMWORD [wk(11)] ; mm0=tmp0H
- paddd mm3, mm5 ; mm3=tmp3L
- paddd mm4, mm7 ; mm4=tmp3H
-
- movq MMWORD [wk(8)], mm2 ; wk(8)=tmp0L
- movq MMWORD [wk(9)], mm0 ; wk(9)=tmp0H
-
- movq mm2, mm1
- movq mm0, mm1
- punpcklwd mm2, mm6
- punpckhwd mm0, mm6
- movq mm1, mm2
- movq mm6, mm0
- pmaddwd mm2, [GOTOFF(ebx,PW_MF050_MF256)] ; mm2=tmp1L
- pmaddwd mm0, [GOTOFF(ebx,PW_MF050_MF256)] ; mm0=tmp1H
- pmaddwd mm1, [GOTOFF(ebx,PW_MF256_F050)] ; mm1=tmp2L
- pmaddwd mm6, [GOTOFF(ebx,PW_MF256_F050)] ; mm6=tmp2H
-
- paddd mm2, mm5 ; mm2=tmp1L
- paddd mm0, mm7 ; mm0=tmp1H
- paddd mm1, MMWORD [wk(10)] ; mm1=tmp2L
- paddd mm6, MMWORD [wk(11)] ; mm6=tmp2H
-
- movq MMWORD [wk(10)], mm2 ; wk(10)=tmp1L
- movq MMWORD [wk(11)], mm0 ; wk(11)=tmp1H
-
- ; -- Final output stage
-
- movq mm5, MMWORD [wk(0)] ; mm5=tmp10L
- movq mm7, MMWORD [wk(1)] ; mm7=tmp10H
-
- movq mm2, mm5
- movq mm0, mm7
- paddd mm5, mm3 ; mm5=data0L
- paddd mm7, mm4 ; mm7=data0H
- psubd mm2, mm3 ; mm2=data7L
- psubd mm0, mm4 ; mm0=data7H
-
- movq mm3, [GOTOFF(ebx,PD_DESCALE_P2)] ; mm3=[PD_DESCALE_P2]
-
- paddd mm5, mm3
- paddd mm7, mm3
- psrad mm5, DESCALE_P2
- psrad mm7, DESCALE_P2
- paddd mm2, mm3
- paddd mm0, mm3
- psrad mm2, DESCALE_P2
- psrad mm0, DESCALE_P2
-
- packssdw mm5, mm7 ; mm5=data0=(00 10 20 30)
- packssdw mm2, mm0 ; mm2=data7=(07 17 27 37)
-
- movq mm4, MMWORD [wk(4)] ; mm4=tmp11L
- movq mm3, MMWORD [wk(5)] ; mm3=tmp11H
-
- movq mm7, mm4
- movq mm0, mm3
- paddd mm4, mm1 ; mm4=data1L
- paddd mm3, mm6 ; mm3=data1H
- psubd mm7, mm1 ; mm7=data6L
- psubd mm0, mm6 ; mm0=data6H
-
- movq mm1, [GOTOFF(ebx,PD_DESCALE_P2)] ; mm1=[PD_DESCALE_P2]
-
- paddd mm4, mm1
- paddd mm3, mm1
- psrad mm4, DESCALE_P2
- psrad mm3, DESCALE_P2
- paddd mm7, mm1
- paddd mm0, mm1
- psrad mm7, DESCALE_P2
- psrad mm0, DESCALE_P2
-
- packssdw mm4, mm3 ; mm4=data1=(01 11 21 31)
- packssdw mm7, mm0 ; mm7=data6=(06 16 26 36)
-
- packsswb mm5, mm7 ; mm5=(00 10 20 30 06 16 26 36)
- packsswb mm4, mm2 ; mm4=(01 11 21 31 07 17 27 37)
-
- movq mm6, MMWORD [wk(6)] ; mm6=tmp12L
- movq mm1, MMWORD [wk(7)] ; mm1=tmp12H
- movq mm3, MMWORD [wk(10)] ; mm3=tmp1L
- movq mm0, MMWORD [wk(11)] ; mm0=tmp1H
-
- movq MMWORD [wk(0)], mm5 ; wk(0)=(00 10 20 30 06 16 26 36)
- movq MMWORD [wk(1)], mm4 ; wk(1)=(01 11 21 31 07 17 27 37)
-
- movq mm7, mm6
- movq mm2, mm1
- paddd mm6, mm3 ; mm6=data2L
- paddd mm1, mm0 ; mm1=data2H
- psubd mm7, mm3 ; mm7=data5L
- psubd mm2, mm0 ; mm2=data5H
-
- movq mm5, [GOTOFF(ebx,PD_DESCALE_P2)] ; mm5=[PD_DESCALE_P2]
-
- paddd mm6, mm5
- paddd mm1, mm5
- psrad mm6, DESCALE_P2
- psrad mm1, DESCALE_P2
- paddd mm7, mm5
- paddd mm2, mm5
- psrad mm7, DESCALE_P2
- psrad mm2, DESCALE_P2
-
- packssdw mm6, mm1 ; mm6=data2=(02 12 22 32)
- packssdw mm7, mm2 ; mm7=data5=(05 15 25 35)
-
- movq mm4, MMWORD [wk(2)] ; mm4=tmp13L
- movq mm3, MMWORD [wk(3)] ; mm3=tmp13H
- movq mm0, MMWORD [wk(8)] ; mm0=tmp0L
- movq mm5, MMWORD [wk(9)] ; mm5=tmp0H
-
- movq mm1, mm4
- movq mm2, mm3
- paddd mm4, mm0 ; mm4=data3L
- paddd mm3, mm5 ; mm3=data3H
- psubd mm1, mm0 ; mm1=data4L
- psubd mm2, mm5 ; mm2=data4H
-
- movq mm0, [GOTOFF(ebx,PD_DESCALE_P2)] ; mm0=[PD_DESCALE_P2]
-
- paddd mm4, mm0
- paddd mm3, mm0
- psrad mm4, DESCALE_P2
- psrad mm3, DESCALE_P2
- paddd mm1, mm0
- paddd mm2, mm0
- psrad mm1, DESCALE_P2
- psrad mm2, DESCALE_P2
-
- movq mm5, [GOTOFF(ebx,PB_CENTERJSAMP)] ; mm5=[PB_CENTERJSAMP]
-
- packssdw mm4, mm3 ; mm4=data3=(03 13 23 33)
- packssdw mm1, mm2 ; mm1=data4=(04 14 24 34)
-
- movq mm0, MMWORD [wk(0)] ; mm0=(00 10 20 30 06 16 26 36)
- movq mm3, MMWORD [wk(1)] ; mm3=(01 11 21 31 07 17 27 37)
-
- packsswb mm6, mm1 ; mm6=(02 12 22 32 04 14 24 34)
- packsswb mm4, mm7 ; mm4=(03 13 23 33 05 15 25 35)
-
- paddb mm0, mm5
- paddb mm3, mm5
- paddb mm6, mm5
- paddb mm4, mm5
-
- movq mm2, mm0 ; transpose coefficients(phase 1)
- punpcklbw mm0, mm3 ; mm0=(00 01 10 11 20 21 30 31)
- punpckhbw mm2, mm3 ; mm2=(06 07 16 17 26 27 36 37)
- movq mm1, mm6 ; transpose coefficients(phase 1)
- punpcklbw mm6, mm4 ; mm6=(02 03 12 13 22 23 32 33)
- punpckhbw mm1, mm4 ; mm1=(04 05 14 15 24 25 34 35)
-
- movq mm7, mm0 ; transpose coefficients(phase 2)
- punpcklwd mm0, mm6 ; mm0=(00 01 02 03 10 11 12 13)
- punpckhwd mm7, mm6 ; mm7=(20 21 22 23 30 31 32 33)
- movq mm5, mm1 ; transpose coefficients(phase 2)
- punpcklwd mm1, mm2 ; mm1=(04 05 06 07 14 15 16 17)
- punpckhwd mm5, mm2 ; mm5=(24 25 26 27 34 35 36 37)
-
- movq mm3, mm0 ; transpose coefficients(phase 3)
- punpckldq mm0, mm1 ; mm0=(00 01 02 03 04 05 06 07)
- punpckhdq mm3, mm1 ; mm3=(10 11 12 13 14 15 16 17)
- movq mm4, mm7 ; transpose coefficients(phase 3)
- punpckldq mm7, mm5 ; mm7=(20 21 22 23 24 25 26 27)
- punpckhdq mm4, mm5 ; mm4=(30 31 32 33 34 35 36 37)
-
- pushpic ebx ; save GOT address
-
- mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW]
- mov ebx, JSAMPROW [edi+1*SIZEOF_JSAMPROW]
- movq MMWORD [edx+eax*SIZEOF_JSAMPLE], mm0
- movq MMWORD [ebx+eax*SIZEOF_JSAMPLE], mm3
- mov edx, JSAMPROW [edi+2*SIZEOF_JSAMPROW]
- mov ebx, JSAMPROW [edi+3*SIZEOF_JSAMPROW]
- movq MMWORD [edx+eax*SIZEOF_JSAMPLE], mm7
- movq MMWORD [ebx+eax*SIZEOF_JSAMPLE], mm4
-
- poppic ebx ; restore GOT address
-
- add esi, byte 4*SIZEOF_JCOEF ; wsptr
- add edi, byte 4*SIZEOF_JSAMPROW
- dec ecx ; ctr
- jnz near .rowloop
-
- emms ; empty MMX state
-
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- pop ebx
- mov esp, ebp ; esp <- aligned ebp
- pop esp ; esp <- original ebp
- pop ebp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jidctint-sse2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jidctint-sse2.asm
deleted file mode 100644
index 43e320189b..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jidctint-sse2.asm
+++ /dev/null
@@ -1,858 +0,0 @@
-;
-; jidctint.asm - accurate integer IDCT (SSE2)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2016, 2020, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-;
-; This file contains a slower but more accurate integer implementation of the
-; inverse DCT (Discrete Cosine Transform). The following code is based
-; directly on the IJG's original jidctint.c; see the jidctint.c for
-; more details.
-
-%include "jsimdext.inc"
-%include "jdct.inc"
-
-; --------------------------------------------------------------------------
-
-%define CONST_BITS 13
-%define PASS1_BITS 2
-
-%define DESCALE_P1 (CONST_BITS - PASS1_BITS)
-%define DESCALE_P2 (CONST_BITS + PASS1_BITS + 3)
-
-%if CONST_BITS == 13
-F_0_298 equ 2446 ; FIX(0.298631336)
-F_0_390 equ 3196 ; FIX(0.390180644)
-F_0_541 equ 4433 ; FIX(0.541196100)
-F_0_765 equ 6270 ; FIX(0.765366865)
-F_0_899 equ 7373 ; FIX(0.899976223)
-F_1_175 equ 9633 ; FIX(1.175875602)
-F_1_501 equ 12299 ; FIX(1.501321110)
-F_1_847 equ 15137 ; FIX(1.847759065)
-F_1_961 equ 16069 ; FIX(1.961570560)
-F_2_053 equ 16819 ; FIX(2.053119869)
-F_2_562 equ 20995 ; FIX(2.562915447)
-F_3_072 equ 25172 ; FIX(3.072711026)
-%else
-; NASM cannot do compile-time arithmetic on floating-point constants.
-%define DESCALE(x, n) (((x) + (1 << ((n) - 1))) >> (n))
-F_0_298 equ DESCALE( 320652955, 30 - CONST_BITS) ; FIX(0.298631336)
-F_0_390 equ DESCALE( 418953276, 30 - CONST_BITS) ; FIX(0.390180644)
-F_0_541 equ DESCALE( 581104887, 30 - CONST_BITS) ; FIX(0.541196100)
-F_0_765 equ DESCALE( 821806413, 30 - CONST_BITS) ; FIX(0.765366865)
-F_0_899 equ DESCALE( 966342111, 30 - CONST_BITS) ; FIX(0.899976223)
-F_1_175 equ DESCALE(1262586813, 30 - CONST_BITS) ; FIX(1.175875602)
-F_1_501 equ DESCALE(1612031267, 30 - CONST_BITS) ; FIX(1.501321110)
-F_1_847 equ DESCALE(1984016188, 30 - CONST_BITS) ; FIX(1.847759065)
-F_1_961 equ DESCALE(2106220350, 30 - CONST_BITS) ; FIX(1.961570560)
-F_2_053 equ DESCALE(2204520673, 30 - CONST_BITS) ; FIX(2.053119869)
-F_2_562 equ DESCALE(2751909506, 30 - CONST_BITS) ; FIX(2.562915447)
-F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
-%endif
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_idct_islow_sse2)
-
-EXTN(jconst_idct_islow_sse2):
-
-PW_F130_F054 times 4 dw (F_0_541 + F_0_765), F_0_541
-PW_F054_MF130 times 4 dw F_0_541, (F_0_541 - F_1_847)
-PW_MF078_F117 times 4 dw (F_1_175 - F_1_961), F_1_175
-PW_F117_F078 times 4 dw F_1_175, (F_1_175 - F_0_390)
-PW_MF060_MF089 times 4 dw (F_0_298 - F_0_899), -F_0_899
-PW_MF089_F060 times 4 dw -F_0_899, (F_1_501 - F_0_899)
-PW_MF050_MF256 times 4 dw (F_2_053 - F_2_562), -F_2_562
-PW_MF256_F050 times 4 dw -F_2_562, (F_3_072 - F_2_562)
-PD_DESCALE_P1 times 4 dd 1 << (DESCALE_P1 - 1)
-PD_DESCALE_P2 times 4 dd 1 << (DESCALE_P2 - 1)
-PB_CENTERJSAMP times 16 db CENTERJSAMPLE
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-;
-; Perform dequantization and inverse DCT on one block of coefficients.
-;
-; GLOBAL(void)
-; jsimd_idct_islow_sse2(void *dct_table, JCOEFPTR coef_block,
-; JSAMPARRAY output_buf, JDIMENSION output_col)
-;
-
-%define dct_table(b) (b) + 8 ; jpeg_component_info *compptr
-%define coef_block(b) (b) + 12 ; JCOEFPTR coef_block
-%define output_buf(b) (b) + 16 ; JSAMPARRAY output_buf
-%define output_col(b) (b) + 20 ; JDIMENSION output_col
-
-%define original_ebp ebp + 0
-%define wk(i) ebp - (WK_NUM - (i)) * SIZEOF_XMMWORD
- ; xmmword wk[WK_NUM]
-%define WK_NUM 12
-
- align 32
- GLOBAL_FUNCTION(jsimd_idct_islow_sse2)
-
-EXTN(jsimd_idct_islow_sse2):
- push ebp
- mov eax, esp ; eax = original ebp
- sub esp, byte 4
- and esp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [esp], eax
- mov ebp, esp ; ebp = aligned ebp
- lea esp, [wk(0)]
- pushpic ebx
-; push ecx ; unused
-; push edx ; need not be preserved
- push esi
- push edi
-
- get_GOT ebx ; get GOT address
-
- ; ---- Pass 1: process columns from input.
-
-; mov eax, [original_ebp]
- mov edx, POINTER [dct_table(eax)] ; quantptr
- mov esi, JCOEFPTR [coef_block(eax)] ; inptr
-
-%ifndef NO_ZERO_COLUMN_TEST_ISLOW_SSE2
- mov eax, dword [DWBLOCK(1,0,esi,SIZEOF_JCOEF)]
- or eax, dword [DWBLOCK(2,0,esi,SIZEOF_JCOEF)]
- jnz near .columnDCT
-
- movdqa xmm0, XMMWORD [XMMBLOCK(1,0,esi,SIZEOF_JCOEF)]
- movdqa xmm1, XMMWORD [XMMBLOCK(2,0,esi,SIZEOF_JCOEF)]
- por xmm0, XMMWORD [XMMBLOCK(3,0,esi,SIZEOF_JCOEF)]
- por xmm1, XMMWORD [XMMBLOCK(4,0,esi,SIZEOF_JCOEF)]
- por xmm0, XMMWORD [XMMBLOCK(5,0,esi,SIZEOF_JCOEF)]
- por xmm1, XMMWORD [XMMBLOCK(6,0,esi,SIZEOF_JCOEF)]
- por xmm0, XMMWORD [XMMBLOCK(7,0,esi,SIZEOF_JCOEF)]
- por xmm1, xmm0
- packsswb xmm1, xmm1
- packsswb xmm1, xmm1
- movd eax, xmm1
- test eax, eax
- jnz short .columnDCT
-
- ; -- AC terms all zero
-
- movdqa xmm5, XMMWORD [XMMBLOCK(0,0,esi,SIZEOF_JCOEF)]
- pmullw xmm5, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
-
- psllw xmm5, PASS1_BITS
-
- movdqa xmm4, xmm5 ; xmm5=in0=(00 01 02 03 04 05 06 07)
- punpcklwd xmm5, xmm5 ; xmm5=(00 00 01 01 02 02 03 03)
- punpckhwd xmm4, xmm4 ; xmm4=(04 04 05 05 06 06 07 07)
-
- pshufd xmm7, xmm5, 0x00 ; xmm7=col0=(00 00 00 00 00 00 00 00)
- pshufd xmm6, xmm5, 0x55 ; xmm6=col1=(01 01 01 01 01 01 01 01)
- pshufd xmm1, xmm5, 0xAA ; xmm1=col2=(02 02 02 02 02 02 02 02)
- pshufd xmm5, xmm5, 0xFF ; xmm5=col3=(03 03 03 03 03 03 03 03)
- pshufd xmm0, xmm4, 0x00 ; xmm0=col4=(04 04 04 04 04 04 04 04)
- pshufd xmm3, xmm4, 0x55 ; xmm3=col5=(05 05 05 05 05 05 05 05)
- pshufd xmm2, xmm4, 0xAA ; xmm2=col6=(06 06 06 06 06 06 06 06)
- pshufd xmm4, xmm4, 0xFF ; xmm4=col7=(07 07 07 07 07 07 07 07)
-
- movdqa XMMWORD [wk(8)], xmm6 ; wk(8)=col1
- movdqa XMMWORD [wk(9)], xmm5 ; wk(9)=col3
- movdqa XMMWORD [wk(10)], xmm3 ; wk(10)=col5
- movdqa XMMWORD [wk(11)], xmm4 ; wk(11)=col7
- jmp near .column_end
- alignx 16, 7
-%endif
-.columnDCT:
-
- ; -- Even part
-
- movdqa xmm0, XMMWORD [XMMBLOCK(0,0,esi,SIZEOF_JCOEF)]
- movdqa xmm1, XMMWORD [XMMBLOCK(2,0,esi,SIZEOF_JCOEF)]
- pmullw xmm0, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
- pmullw xmm1, XMMWORD [XMMBLOCK(2,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
- movdqa xmm2, XMMWORD [XMMBLOCK(4,0,esi,SIZEOF_JCOEF)]
- movdqa xmm3, XMMWORD [XMMBLOCK(6,0,esi,SIZEOF_JCOEF)]
- pmullw xmm2, XMMWORD [XMMBLOCK(4,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
- pmullw xmm3, XMMWORD [XMMBLOCK(6,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
-
- ; (Original)
- ; z1 = (z2 + z3) * 0.541196100;
- ; tmp2 = z1 + z3 * -1.847759065;
- ; tmp3 = z1 + z2 * 0.765366865;
- ;
- ; (This implementation)
- ; tmp2 = z2 * 0.541196100 + z3 * (0.541196100 - 1.847759065);
- ; tmp3 = z2 * (0.541196100 + 0.765366865) + z3 * 0.541196100;
-
- movdqa xmm4, xmm1 ; xmm1=in2=z2
- movdqa xmm5, xmm1
- punpcklwd xmm4, xmm3 ; xmm3=in6=z3
- punpckhwd xmm5, xmm3
- movdqa xmm1, xmm4
- movdqa xmm3, xmm5
- pmaddwd xmm4, [GOTOFF(ebx,PW_F130_F054)] ; xmm4=tmp3L
- pmaddwd xmm5, [GOTOFF(ebx,PW_F130_F054)] ; xmm5=tmp3H
- pmaddwd xmm1, [GOTOFF(ebx,PW_F054_MF130)] ; xmm1=tmp2L
- pmaddwd xmm3, [GOTOFF(ebx,PW_F054_MF130)] ; xmm3=tmp2H
-
- movdqa xmm6, xmm0
- paddw xmm0, xmm2 ; xmm0=in0+in4
- psubw xmm6, xmm2 ; xmm6=in0-in4
-
- pxor xmm7, xmm7
- pxor xmm2, xmm2
- punpcklwd xmm7, xmm0 ; xmm7=tmp0L
- punpckhwd xmm2, xmm0 ; xmm2=tmp0H
- psrad xmm7, (16-CONST_BITS) ; psrad xmm7,16 & pslld xmm7,CONST_BITS
- psrad xmm2, (16-CONST_BITS) ; psrad xmm2,16 & pslld xmm2,CONST_BITS
-
- movdqa xmm0, xmm7
- paddd xmm7, xmm4 ; xmm7=tmp10L
- psubd xmm0, xmm4 ; xmm0=tmp13L
- movdqa xmm4, xmm2
- paddd xmm2, xmm5 ; xmm2=tmp10H
- psubd xmm4, xmm5 ; xmm4=tmp13H
-
- movdqa XMMWORD [wk(0)], xmm7 ; wk(0)=tmp10L
- movdqa XMMWORD [wk(1)], xmm2 ; wk(1)=tmp10H
- movdqa XMMWORD [wk(2)], xmm0 ; wk(2)=tmp13L
- movdqa XMMWORD [wk(3)], xmm4 ; wk(3)=tmp13H
-
- pxor xmm5, xmm5
- pxor xmm7, xmm7
- punpcklwd xmm5, xmm6 ; xmm5=tmp1L
- punpckhwd xmm7, xmm6 ; xmm7=tmp1H
- psrad xmm5, (16-CONST_BITS) ; psrad xmm5,16 & pslld xmm5,CONST_BITS
- psrad xmm7, (16-CONST_BITS) ; psrad xmm7,16 & pslld xmm7,CONST_BITS
-
- movdqa xmm2, xmm5
- paddd xmm5, xmm1 ; xmm5=tmp11L
- psubd xmm2, xmm1 ; xmm2=tmp12L
- movdqa xmm0, xmm7
- paddd xmm7, xmm3 ; xmm7=tmp11H
- psubd xmm0, xmm3 ; xmm0=tmp12H
-
- movdqa XMMWORD [wk(4)], xmm5 ; wk(4)=tmp11L
- movdqa XMMWORD [wk(5)], xmm7 ; wk(5)=tmp11H
- movdqa XMMWORD [wk(6)], xmm2 ; wk(6)=tmp12L
- movdqa XMMWORD [wk(7)], xmm0 ; wk(7)=tmp12H
-
- ; -- Odd part
-
- movdqa xmm4, XMMWORD [XMMBLOCK(1,0,esi,SIZEOF_JCOEF)]
- movdqa xmm6, XMMWORD [XMMBLOCK(3,0,esi,SIZEOF_JCOEF)]
- pmullw xmm4, XMMWORD [XMMBLOCK(1,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
- pmullw xmm6, XMMWORD [XMMBLOCK(3,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
- movdqa xmm1, XMMWORD [XMMBLOCK(5,0,esi,SIZEOF_JCOEF)]
- movdqa xmm3, XMMWORD [XMMBLOCK(7,0,esi,SIZEOF_JCOEF)]
- pmullw xmm1, XMMWORD [XMMBLOCK(5,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
- pmullw xmm3, XMMWORD [XMMBLOCK(7,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
-
- movdqa xmm5, xmm6
- movdqa xmm7, xmm4
- paddw xmm5, xmm3 ; xmm5=z3
- paddw xmm7, xmm1 ; xmm7=z4
-
- ; (Original)
- ; z5 = (z3 + z4) * 1.175875602;
- ; z3 = z3 * -1.961570560; z4 = z4 * -0.390180644;
- ; z3 += z5; z4 += z5;
- ;
- ; (This implementation)
- ; z3 = z3 * (1.175875602 - 1.961570560) + z4 * 1.175875602;
- ; z4 = z3 * 1.175875602 + z4 * (1.175875602 - 0.390180644);
-
- movdqa xmm2, xmm5
- movdqa xmm0, xmm5
- punpcklwd xmm2, xmm7
- punpckhwd xmm0, xmm7
- movdqa xmm5, xmm2
- movdqa xmm7, xmm0
- pmaddwd xmm2, [GOTOFF(ebx,PW_MF078_F117)] ; xmm2=z3L
- pmaddwd xmm0, [GOTOFF(ebx,PW_MF078_F117)] ; xmm0=z3H
- pmaddwd xmm5, [GOTOFF(ebx,PW_F117_F078)] ; xmm5=z4L
- pmaddwd xmm7, [GOTOFF(ebx,PW_F117_F078)] ; xmm7=z4H
-
- movdqa XMMWORD [wk(10)], xmm2 ; wk(10)=z3L
- movdqa XMMWORD [wk(11)], xmm0 ; wk(11)=z3H
-
- ; (Original)
- ; z1 = tmp0 + tmp3; z2 = tmp1 + tmp2;
- ; tmp0 = tmp0 * 0.298631336; tmp1 = tmp1 * 2.053119869;
- ; tmp2 = tmp2 * 3.072711026; tmp3 = tmp3 * 1.501321110;
- ; z1 = z1 * -0.899976223; z2 = z2 * -2.562915447;
- ; tmp0 += z1 + z3; tmp1 += z2 + z4;
- ; tmp2 += z2 + z3; tmp3 += z1 + z4;
- ;
- ; (This implementation)
- ; tmp0 = tmp0 * (0.298631336 - 0.899976223) + tmp3 * -0.899976223;
- ; tmp1 = tmp1 * (2.053119869 - 2.562915447) + tmp2 * -2.562915447;
- ; tmp2 = tmp1 * -2.562915447 + tmp2 * (3.072711026 - 2.562915447);
- ; tmp3 = tmp0 * -0.899976223 + tmp3 * (1.501321110 - 0.899976223);
- ; tmp0 += z3; tmp1 += z4;
- ; tmp2 += z3; tmp3 += z4;
-
- movdqa xmm2, xmm3
- movdqa xmm0, xmm3
- punpcklwd xmm2, xmm4
- punpckhwd xmm0, xmm4
- movdqa xmm3, xmm2
- movdqa xmm4, xmm0
- pmaddwd xmm2, [GOTOFF(ebx,PW_MF060_MF089)] ; xmm2=tmp0L
- pmaddwd xmm0, [GOTOFF(ebx,PW_MF060_MF089)] ; xmm0=tmp0H
- pmaddwd xmm3, [GOTOFF(ebx,PW_MF089_F060)] ; xmm3=tmp3L
- pmaddwd xmm4, [GOTOFF(ebx,PW_MF089_F060)] ; xmm4=tmp3H
-
- paddd xmm2, XMMWORD [wk(10)] ; xmm2=tmp0L
- paddd xmm0, XMMWORD [wk(11)] ; xmm0=tmp0H
- paddd xmm3, xmm5 ; xmm3=tmp3L
- paddd xmm4, xmm7 ; xmm4=tmp3H
-
- movdqa XMMWORD [wk(8)], xmm2 ; wk(8)=tmp0L
- movdqa XMMWORD [wk(9)], xmm0 ; wk(9)=tmp0H
-
- movdqa xmm2, xmm1
- movdqa xmm0, xmm1
- punpcklwd xmm2, xmm6
- punpckhwd xmm0, xmm6
- movdqa xmm1, xmm2
- movdqa xmm6, xmm0
- pmaddwd xmm2, [GOTOFF(ebx,PW_MF050_MF256)] ; xmm2=tmp1L
- pmaddwd xmm0, [GOTOFF(ebx,PW_MF050_MF256)] ; xmm0=tmp1H
- pmaddwd xmm1, [GOTOFF(ebx,PW_MF256_F050)] ; xmm1=tmp2L
- pmaddwd xmm6, [GOTOFF(ebx,PW_MF256_F050)] ; xmm6=tmp2H
-
- paddd xmm2, xmm5 ; xmm2=tmp1L
- paddd xmm0, xmm7 ; xmm0=tmp1H
- paddd xmm1, XMMWORD [wk(10)] ; xmm1=tmp2L
- paddd xmm6, XMMWORD [wk(11)] ; xmm6=tmp2H
-
- movdqa XMMWORD [wk(10)], xmm2 ; wk(10)=tmp1L
- movdqa XMMWORD [wk(11)], xmm0 ; wk(11)=tmp1H
-
- ; -- Final output stage
-
- movdqa xmm5, XMMWORD [wk(0)] ; xmm5=tmp10L
- movdqa xmm7, XMMWORD [wk(1)] ; xmm7=tmp10H
-
- movdqa xmm2, xmm5
- movdqa xmm0, xmm7
- paddd xmm5, xmm3 ; xmm5=data0L
- paddd xmm7, xmm4 ; xmm7=data0H
- psubd xmm2, xmm3 ; xmm2=data7L
- psubd xmm0, xmm4 ; xmm0=data7H
-
- movdqa xmm3, [GOTOFF(ebx,PD_DESCALE_P1)] ; xmm3=[PD_DESCALE_P1]
-
- paddd xmm5, xmm3
- paddd xmm7, xmm3
- psrad xmm5, DESCALE_P1
- psrad xmm7, DESCALE_P1
- paddd xmm2, xmm3
- paddd xmm0, xmm3
- psrad xmm2, DESCALE_P1
- psrad xmm0, DESCALE_P1
-
- packssdw xmm5, xmm7 ; xmm5=data0=(00 01 02 03 04 05 06 07)
- packssdw xmm2, xmm0 ; xmm2=data7=(70 71 72 73 74 75 76 77)
-
- movdqa xmm4, XMMWORD [wk(4)] ; xmm4=tmp11L
- movdqa xmm3, XMMWORD [wk(5)] ; xmm3=tmp11H
-
- movdqa xmm7, xmm4
- movdqa xmm0, xmm3
- paddd xmm4, xmm1 ; xmm4=data1L
- paddd xmm3, xmm6 ; xmm3=data1H
- psubd xmm7, xmm1 ; xmm7=data6L
- psubd xmm0, xmm6 ; xmm0=data6H
-
- movdqa xmm1, [GOTOFF(ebx,PD_DESCALE_P1)] ; xmm1=[PD_DESCALE_P1]
-
- paddd xmm4, xmm1
- paddd xmm3, xmm1
- psrad xmm4, DESCALE_P1
- psrad xmm3, DESCALE_P1
- paddd xmm7, xmm1
- paddd xmm0, xmm1
- psrad xmm7, DESCALE_P1
- psrad xmm0, DESCALE_P1
-
- packssdw xmm4, xmm3 ; xmm4=data1=(10 11 12 13 14 15 16 17)
- packssdw xmm7, xmm0 ; xmm7=data6=(60 61 62 63 64 65 66 67)
-
- movdqa xmm6, xmm5 ; transpose coefficients(phase 1)
- punpcklwd xmm5, xmm4 ; xmm5=(00 10 01 11 02 12 03 13)
- punpckhwd xmm6, xmm4 ; xmm6=(04 14 05 15 06 16 07 17)
- movdqa xmm1, xmm7 ; transpose coefficients(phase 1)
- punpcklwd xmm7, xmm2 ; xmm7=(60 70 61 71 62 72 63 73)
- punpckhwd xmm1, xmm2 ; xmm1=(64 74 65 75 66 76 67 77)
-
- movdqa xmm3, XMMWORD [wk(6)] ; xmm3=tmp12L
- movdqa xmm0, XMMWORD [wk(7)] ; xmm0=tmp12H
- movdqa xmm4, XMMWORD [wk(10)] ; xmm4=tmp1L
- movdqa xmm2, XMMWORD [wk(11)] ; xmm2=tmp1H
-
- movdqa XMMWORD [wk(0)], xmm5 ; wk(0)=(00 10 01 11 02 12 03 13)
- movdqa XMMWORD [wk(1)], xmm6 ; wk(1)=(04 14 05 15 06 16 07 17)
- movdqa XMMWORD [wk(4)], xmm7 ; wk(4)=(60 70 61 71 62 72 63 73)
- movdqa XMMWORD [wk(5)], xmm1 ; wk(5)=(64 74 65 75 66 76 67 77)
-
- movdqa xmm5, xmm3
- movdqa xmm6, xmm0
- paddd xmm3, xmm4 ; xmm3=data2L
- paddd xmm0, xmm2 ; xmm0=data2H
- psubd xmm5, xmm4 ; xmm5=data5L
- psubd xmm6, xmm2 ; xmm6=data5H
-
- movdqa xmm7, [GOTOFF(ebx,PD_DESCALE_P1)] ; xmm7=[PD_DESCALE_P1]
-
- paddd xmm3, xmm7
- paddd xmm0, xmm7
- psrad xmm3, DESCALE_P1
- psrad xmm0, DESCALE_P1
- paddd xmm5, xmm7
- paddd xmm6, xmm7
- psrad xmm5, DESCALE_P1
- psrad xmm6, DESCALE_P1
-
- packssdw xmm3, xmm0 ; xmm3=data2=(20 21 22 23 24 25 26 27)
- packssdw xmm5, xmm6 ; xmm5=data5=(50 51 52 53 54 55 56 57)
-
- movdqa xmm1, XMMWORD [wk(2)] ; xmm1=tmp13L
- movdqa xmm4, XMMWORD [wk(3)] ; xmm4=tmp13H
- movdqa xmm2, XMMWORD [wk(8)] ; xmm2=tmp0L
- movdqa xmm7, XMMWORD [wk(9)] ; xmm7=tmp0H
-
- movdqa xmm0, xmm1
- movdqa xmm6, xmm4
- paddd xmm1, xmm2 ; xmm1=data3L
- paddd xmm4, xmm7 ; xmm4=data3H
- psubd xmm0, xmm2 ; xmm0=data4L
- psubd xmm6, xmm7 ; xmm6=data4H
-
- movdqa xmm2, [GOTOFF(ebx,PD_DESCALE_P1)] ; xmm2=[PD_DESCALE_P1]
-
- paddd xmm1, xmm2
- paddd xmm4, xmm2
- psrad xmm1, DESCALE_P1
- psrad xmm4, DESCALE_P1
- paddd xmm0, xmm2
- paddd xmm6, xmm2
- psrad xmm0, DESCALE_P1
- psrad xmm6, DESCALE_P1
-
- packssdw xmm1, xmm4 ; xmm1=data3=(30 31 32 33 34 35 36 37)
- packssdw xmm0, xmm6 ; xmm0=data4=(40 41 42 43 44 45 46 47)
-
- movdqa xmm7, XMMWORD [wk(0)] ; xmm7=(00 10 01 11 02 12 03 13)
- movdqa xmm2, XMMWORD [wk(1)] ; xmm2=(04 14 05 15 06 16 07 17)
-
- movdqa xmm4, xmm3 ; transpose coefficients(phase 1)
- punpcklwd xmm3, xmm1 ; xmm3=(20 30 21 31 22 32 23 33)
- punpckhwd xmm4, xmm1 ; xmm4=(24 34 25 35 26 36 27 37)
- movdqa xmm6, xmm0 ; transpose coefficients(phase 1)
- punpcklwd xmm0, xmm5 ; xmm0=(40 50 41 51 42 52 43 53)
- punpckhwd xmm6, xmm5 ; xmm6=(44 54 45 55 46 56 47 57)
-
- movdqa xmm1, xmm7 ; transpose coefficients(phase 2)
- punpckldq xmm7, xmm3 ; xmm7=(00 10 20 30 01 11 21 31)
- punpckhdq xmm1, xmm3 ; xmm1=(02 12 22 32 03 13 23 33)
- movdqa xmm5, xmm2 ; transpose coefficients(phase 2)
- punpckldq xmm2, xmm4 ; xmm2=(04 14 24 34 05 15 25 35)
- punpckhdq xmm5, xmm4 ; xmm5=(06 16 26 36 07 17 27 37)
-
- movdqa xmm3, XMMWORD [wk(4)] ; xmm3=(60 70 61 71 62 72 63 73)
- movdqa xmm4, XMMWORD [wk(5)] ; xmm4=(64 74 65 75 66 76 67 77)
-
- movdqa XMMWORD [wk(6)], xmm2 ; wk(6)=(04 14 24 34 05 15 25 35)
- movdqa XMMWORD [wk(7)], xmm5 ; wk(7)=(06 16 26 36 07 17 27 37)
-
- movdqa xmm2, xmm0 ; transpose coefficients(phase 2)
- punpckldq xmm0, xmm3 ; xmm0=(40 50 60 70 41 51 61 71)
- punpckhdq xmm2, xmm3 ; xmm2=(42 52 62 72 43 53 63 73)
- movdqa xmm5, xmm6 ; transpose coefficients(phase 2)
- punpckldq xmm6, xmm4 ; xmm6=(44 54 64 74 45 55 65 75)
- punpckhdq xmm5, xmm4 ; xmm5=(46 56 66 76 47 57 67 77)
-
- movdqa xmm3, xmm7 ; transpose coefficients(phase 3)
- punpcklqdq xmm7, xmm0 ; xmm7=col0=(00 10 20 30 40 50 60 70)
- punpckhqdq xmm3, xmm0 ; xmm3=col1=(01 11 21 31 41 51 61 71)
- movdqa xmm4, xmm1 ; transpose coefficients(phase 3)
- punpcklqdq xmm1, xmm2 ; xmm1=col2=(02 12 22 32 42 52 62 72)
- punpckhqdq xmm4, xmm2 ; xmm4=col3=(03 13 23 33 43 53 63 73)
-
- movdqa xmm0, XMMWORD [wk(6)] ; xmm0=(04 14 24 34 05 15 25 35)
- movdqa xmm2, XMMWORD [wk(7)] ; xmm2=(06 16 26 36 07 17 27 37)
-
- movdqa XMMWORD [wk(8)], xmm3 ; wk(8)=col1
- movdqa XMMWORD [wk(9)], xmm4 ; wk(9)=col3
-
- movdqa xmm3, xmm0 ; transpose coefficients(phase 3)
- punpcklqdq xmm0, xmm6 ; xmm0=col4=(04 14 24 34 44 54 64 74)
- punpckhqdq xmm3, xmm6 ; xmm3=col5=(05 15 25 35 45 55 65 75)
- movdqa xmm4, xmm2 ; transpose coefficients(phase 3)
- punpcklqdq xmm2, xmm5 ; xmm2=col6=(06 16 26 36 46 56 66 76)
- punpckhqdq xmm4, xmm5 ; xmm4=col7=(07 17 27 37 47 57 67 77)
-
- movdqa XMMWORD [wk(10)], xmm3 ; wk(10)=col5
- movdqa XMMWORD [wk(11)], xmm4 ; wk(11)=col7
-.column_end:
-
- ; -- Prefetch the next coefficient block
-
- prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 0*32]
- prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 1*32]
- prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 2*32]
- prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 3*32]
-
- ; ---- Pass 2: process rows from work array, store into output array.
-
- mov eax, [original_ebp]
- mov edi, JSAMPARRAY [output_buf(eax)] ; (JSAMPROW *)
- mov eax, JDIMENSION [output_col(eax)]
-
- ; -- Even part
-
- ; xmm7=col0, xmm1=col2, xmm0=col4, xmm2=col6
-
- ; (Original)
- ; z1 = (z2 + z3) * 0.541196100;
- ; tmp2 = z1 + z3 * -1.847759065;
- ; tmp3 = z1 + z2 * 0.765366865;
- ;
- ; (This implementation)
- ; tmp2 = z2 * 0.541196100 + z3 * (0.541196100 - 1.847759065);
- ; tmp3 = z2 * (0.541196100 + 0.765366865) + z3 * 0.541196100;
-
- movdqa xmm6, xmm1 ; xmm1=in2=z2
- movdqa xmm5, xmm1
- punpcklwd xmm6, xmm2 ; xmm2=in6=z3
- punpckhwd xmm5, xmm2
- movdqa xmm1, xmm6
- movdqa xmm2, xmm5
- pmaddwd xmm6, [GOTOFF(ebx,PW_F130_F054)] ; xmm6=tmp3L
- pmaddwd xmm5, [GOTOFF(ebx,PW_F130_F054)] ; xmm5=tmp3H
- pmaddwd xmm1, [GOTOFF(ebx,PW_F054_MF130)] ; xmm1=tmp2L
- pmaddwd xmm2, [GOTOFF(ebx,PW_F054_MF130)] ; xmm2=tmp2H
-
- movdqa xmm3, xmm7
- paddw xmm7, xmm0 ; xmm7=in0+in4
- psubw xmm3, xmm0 ; xmm3=in0-in4
-
- pxor xmm4, xmm4
- pxor xmm0, xmm0
- punpcklwd xmm4, xmm7 ; xmm4=tmp0L
- punpckhwd xmm0, xmm7 ; xmm0=tmp0H
- psrad xmm4, (16-CONST_BITS) ; psrad xmm4,16 & pslld xmm4,CONST_BITS
- psrad xmm0, (16-CONST_BITS) ; psrad xmm0,16 & pslld xmm0,CONST_BITS
-
- movdqa xmm7, xmm4
- paddd xmm4, xmm6 ; xmm4=tmp10L
- psubd xmm7, xmm6 ; xmm7=tmp13L
- movdqa xmm6, xmm0
- paddd xmm0, xmm5 ; xmm0=tmp10H
- psubd xmm6, xmm5 ; xmm6=tmp13H
-
- movdqa XMMWORD [wk(0)], xmm4 ; wk(0)=tmp10L
- movdqa XMMWORD [wk(1)], xmm0 ; wk(1)=tmp10H
- movdqa XMMWORD [wk(2)], xmm7 ; wk(2)=tmp13L
- movdqa XMMWORD [wk(3)], xmm6 ; wk(3)=tmp13H
-
- pxor xmm5, xmm5
- pxor xmm4, xmm4
- punpcklwd xmm5, xmm3 ; xmm5=tmp1L
- punpckhwd xmm4, xmm3 ; xmm4=tmp1H
- psrad xmm5, (16-CONST_BITS) ; psrad xmm5,16 & pslld xmm5,CONST_BITS
- psrad xmm4, (16-CONST_BITS) ; psrad xmm4,16 & pslld xmm4,CONST_BITS
-
- movdqa xmm0, xmm5
- paddd xmm5, xmm1 ; xmm5=tmp11L
- psubd xmm0, xmm1 ; xmm0=tmp12L
- movdqa xmm7, xmm4
- paddd xmm4, xmm2 ; xmm4=tmp11H
- psubd xmm7, xmm2 ; xmm7=tmp12H
-
- movdqa XMMWORD [wk(4)], xmm5 ; wk(4)=tmp11L
- movdqa XMMWORD [wk(5)], xmm4 ; wk(5)=tmp11H
- movdqa XMMWORD [wk(6)], xmm0 ; wk(6)=tmp12L
- movdqa XMMWORD [wk(7)], xmm7 ; wk(7)=tmp12H
-
- ; -- Odd part
-
- movdqa xmm6, XMMWORD [wk(9)] ; xmm6=col3
- movdqa xmm3, XMMWORD [wk(8)] ; xmm3=col1
- movdqa xmm1, XMMWORD [wk(11)] ; xmm1=col7
- movdqa xmm2, XMMWORD [wk(10)] ; xmm2=col5
-
- movdqa xmm5, xmm6
- movdqa xmm4, xmm3
- paddw xmm5, xmm1 ; xmm5=z3
- paddw xmm4, xmm2 ; xmm4=z4
-
- ; (Original)
- ; z5 = (z3 + z4) * 1.175875602;
- ; z3 = z3 * -1.961570560; z4 = z4 * -0.390180644;
- ; z3 += z5; z4 += z5;
- ;
- ; (This implementation)
- ; z3 = z3 * (1.175875602 - 1.961570560) + z4 * 1.175875602;
- ; z4 = z3 * 1.175875602 + z4 * (1.175875602 - 0.390180644);
-
- movdqa xmm0, xmm5
- movdqa xmm7, xmm5
- punpcklwd xmm0, xmm4
- punpckhwd xmm7, xmm4
- movdqa xmm5, xmm0
- movdqa xmm4, xmm7
- pmaddwd xmm0, [GOTOFF(ebx,PW_MF078_F117)] ; xmm0=z3L
- pmaddwd xmm7, [GOTOFF(ebx,PW_MF078_F117)] ; xmm7=z3H
- pmaddwd xmm5, [GOTOFF(ebx,PW_F117_F078)] ; xmm5=z4L
- pmaddwd xmm4, [GOTOFF(ebx,PW_F117_F078)] ; xmm4=z4H
-
- movdqa XMMWORD [wk(10)], xmm0 ; wk(10)=z3L
- movdqa XMMWORD [wk(11)], xmm7 ; wk(11)=z3H
-
- ; (Original)
- ; z1 = tmp0 + tmp3; z2 = tmp1 + tmp2;
- ; tmp0 = tmp0 * 0.298631336; tmp1 = tmp1 * 2.053119869;
- ; tmp2 = tmp2 * 3.072711026; tmp3 = tmp3 * 1.501321110;
- ; z1 = z1 * -0.899976223; z2 = z2 * -2.562915447;
- ; tmp0 += z1 + z3; tmp1 += z2 + z4;
- ; tmp2 += z2 + z3; tmp3 += z1 + z4;
- ;
- ; (This implementation)
- ; tmp0 = tmp0 * (0.298631336 - 0.899976223) + tmp3 * -0.899976223;
- ; tmp1 = tmp1 * (2.053119869 - 2.562915447) + tmp2 * -2.562915447;
- ; tmp2 = tmp1 * -2.562915447 + tmp2 * (3.072711026 - 2.562915447);
- ; tmp3 = tmp0 * -0.899976223 + tmp3 * (1.501321110 - 0.899976223);
- ; tmp0 += z3; tmp1 += z4;
- ; tmp2 += z3; tmp3 += z4;
-
- movdqa xmm0, xmm1
- movdqa xmm7, xmm1
- punpcklwd xmm0, xmm3
- punpckhwd xmm7, xmm3
- movdqa xmm1, xmm0
- movdqa xmm3, xmm7
- pmaddwd xmm0, [GOTOFF(ebx,PW_MF060_MF089)] ; xmm0=tmp0L
- pmaddwd xmm7, [GOTOFF(ebx,PW_MF060_MF089)] ; xmm7=tmp0H
- pmaddwd xmm1, [GOTOFF(ebx,PW_MF089_F060)] ; xmm1=tmp3L
- pmaddwd xmm3, [GOTOFF(ebx,PW_MF089_F060)] ; xmm3=tmp3H
-
- paddd xmm0, XMMWORD [wk(10)] ; xmm0=tmp0L
- paddd xmm7, XMMWORD [wk(11)] ; xmm7=tmp0H
- paddd xmm1, xmm5 ; xmm1=tmp3L
- paddd xmm3, xmm4 ; xmm3=tmp3H
-
- movdqa XMMWORD [wk(8)], xmm0 ; wk(8)=tmp0L
- movdqa XMMWORD [wk(9)], xmm7 ; wk(9)=tmp0H
-
- movdqa xmm0, xmm2
- movdqa xmm7, xmm2
- punpcklwd xmm0, xmm6
- punpckhwd xmm7, xmm6
- movdqa xmm2, xmm0
- movdqa xmm6, xmm7
- pmaddwd xmm0, [GOTOFF(ebx,PW_MF050_MF256)] ; xmm0=tmp1L
- pmaddwd xmm7, [GOTOFF(ebx,PW_MF050_MF256)] ; xmm7=tmp1H
- pmaddwd xmm2, [GOTOFF(ebx,PW_MF256_F050)] ; xmm2=tmp2L
- pmaddwd xmm6, [GOTOFF(ebx,PW_MF256_F050)] ; xmm6=tmp2H
-
- paddd xmm0, xmm5 ; xmm0=tmp1L
- paddd xmm7, xmm4 ; xmm7=tmp1H
- paddd xmm2, XMMWORD [wk(10)] ; xmm2=tmp2L
- paddd xmm6, XMMWORD [wk(11)] ; xmm6=tmp2H
-
- movdqa XMMWORD [wk(10)], xmm0 ; wk(10)=tmp1L
- movdqa XMMWORD [wk(11)], xmm7 ; wk(11)=tmp1H
-
- ; -- Final output stage
-
- movdqa xmm5, XMMWORD [wk(0)] ; xmm5=tmp10L
- movdqa xmm4, XMMWORD [wk(1)] ; xmm4=tmp10H
-
- movdqa xmm0, xmm5
- movdqa xmm7, xmm4
- paddd xmm5, xmm1 ; xmm5=data0L
- paddd xmm4, xmm3 ; xmm4=data0H
- psubd xmm0, xmm1 ; xmm0=data7L
- psubd xmm7, xmm3 ; xmm7=data7H
-
- movdqa xmm1, [GOTOFF(ebx,PD_DESCALE_P2)] ; xmm1=[PD_DESCALE_P2]
-
- paddd xmm5, xmm1
- paddd xmm4, xmm1
- psrad xmm5, DESCALE_P2
- psrad xmm4, DESCALE_P2
- paddd xmm0, xmm1
- paddd xmm7, xmm1
- psrad xmm0, DESCALE_P2
- psrad xmm7, DESCALE_P2
-
- packssdw xmm5, xmm4 ; xmm5=data0=(00 10 20 30 40 50 60 70)
- packssdw xmm0, xmm7 ; xmm0=data7=(07 17 27 37 47 57 67 77)
-
- movdqa xmm3, XMMWORD [wk(4)] ; xmm3=tmp11L
- movdqa xmm1, XMMWORD [wk(5)] ; xmm1=tmp11H
-
- movdqa xmm4, xmm3
- movdqa xmm7, xmm1
- paddd xmm3, xmm2 ; xmm3=data1L
- paddd xmm1, xmm6 ; xmm1=data1H
- psubd xmm4, xmm2 ; xmm4=data6L
- psubd xmm7, xmm6 ; xmm7=data6H
-
- movdqa xmm2, [GOTOFF(ebx,PD_DESCALE_P2)] ; xmm2=[PD_DESCALE_P2]
-
- paddd xmm3, xmm2
- paddd xmm1, xmm2
- psrad xmm3, DESCALE_P2
- psrad xmm1, DESCALE_P2
- paddd xmm4, xmm2
- paddd xmm7, xmm2
- psrad xmm4, DESCALE_P2
- psrad xmm7, DESCALE_P2
-
- packssdw xmm3, xmm1 ; xmm3=data1=(01 11 21 31 41 51 61 71)
- packssdw xmm4, xmm7 ; xmm4=data6=(06 16 26 36 46 56 66 76)
-
- packsswb xmm5, xmm4 ; xmm5=(00 10 20 30 40 50 60 70 06 16 26 36 46 56 66 76)
- packsswb xmm3, xmm0 ; xmm3=(01 11 21 31 41 51 61 71 07 17 27 37 47 57 67 77)
-
- movdqa xmm6, XMMWORD [wk(6)] ; xmm6=tmp12L
- movdqa xmm2, XMMWORD [wk(7)] ; xmm2=tmp12H
- movdqa xmm1, XMMWORD [wk(10)] ; xmm1=tmp1L
- movdqa xmm7, XMMWORD [wk(11)] ; xmm7=tmp1H
-
- movdqa XMMWORD [wk(0)], xmm5 ; wk(0)=(00 10 20 30 40 50 60 70 06 16 26 36 46 56 66 76)
- movdqa XMMWORD [wk(1)], xmm3 ; wk(1)=(01 11 21 31 41 51 61 71 07 17 27 37 47 57 67 77)
-
- movdqa xmm4, xmm6
- movdqa xmm0, xmm2
- paddd xmm6, xmm1 ; xmm6=data2L
- paddd xmm2, xmm7 ; xmm2=data2H
- psubd xmm4, xmm1 ; xmm4=data5L
- psubd xmm0, xmm7 ; xmm0=data5H
-
- movdqa xmm5, [GOTOFF(ebx,PD_DESCALE_P2)] ; xmm5=[PD_DESCALE_P2]
-
- paddd xmm6, xmm5
- paddd xmm2, xmm5
- psrad xmm6, DESCALE_P2
- psrad xmm2, DESCALE_P2
- paddd xmm4, xmm5
- paddd xmm0, xmm5
- psrad xmm4, DESCALE_P2
- psrad xmm0, DESCALE_P2
-
- packssdw xmm6, xmm2 ; xmm6=data2=(02 12 22 32 42 52 62 72)
- packssdw xmm4, xmm0 ; xmm4=data5=(05 15 25 35 45 55 65 75)
-
- movdqa xmm3, XMMWORD [wk(2)] ; xmm3=tmp13L
- movdqa xmm1, XMMWORD [wk(3)] ; xmm1=tmp13H
- movdqa xmm7, XMMWORD [wk(8)] ; xmm7=tmp0L
- movdqa xmm5, XMMWORD [wk(9)] ; xmm5=tmp0H
-
- movdqa xmm2, xmm3
- movdqa xmm0, xmm1
- paddd xmm3, xmm7 ; xmm3=data3L
- paddd xmm1, xmm5 ; xmm1=data3H
- psubd xmm2, xmm7 ; xmm2=data4L
- psubd xmm0, xmm5 ; xmm0=data4H
-
- movdqa xmm7, [GOTOFF(ebx,PD_DESCALE_P2)] ; xmm7=[PD_DESCALE_P2]
-
- paddd xmm3, xmm7
- paddd xmm1, xmm7
- psrad xmm3, DESCALE_P2
- psrad xmm1, DESCALE_P2
- paddd xmm2, xmm7
- paddd xmm0, xmm7
- psrad xmm2, DESCALE_P2
- psrad xmm0, DESCALE_P2
-
- movdqa xmm5, [GOTOFF(ebx,PB_CENTERJSAMP)] ; xmm5=[PB_CENTERJSAMP]
-
- packssdw xmm3, xmm1 ; xmm3=data3=(03 13 23 33 43 53 63 73)
- packssdw xmm2, xmm0 ; xmm2=data4=(04 14 24 34 44 54 64 74)
-
- movdqa xmm7, XMMWORD [wk(0)] ; xmm7=(00 10 20 30 40 50 60 70 06 16 26 36 46 56 66 76)
- movdqa xmm1, XMMWORD [wk(1)] ; xmm1=(01 11 21 31 41 51 61 71 07 17 27 37 47 57 67 77)
-
- packsswb xmm6, xmm2 ; xmm6=(02 12 22 32 42 52 62 72 04 14 24 34 44 54 64 74)
- packsswb xmm3, xmm4 ; xmm3=(03 13 23 33 43 53 63 73 05 15 25 35 45 55 65 75)
-
- paddb xmm7, xmm5
- paddb xmm1, xmm5
- paddb xmm6, xmm5
- paddb xmm3, xmm5
-
- movdqa xmm0, xmm7 ; transpose coefficients(phase 1)
- punpcklbw xmm7, xmm1 ; xmm7=(00 01 10 11 20 21 30 31 40 41 50 51 60 61 70 71)
- punpckhbw xmm0, xmm1 ; xmm0=(06 07 16 17 26 27 36 37 46 47 56 57 66 67 76 77)
- movdqa xmm2, xmm6 ; transpose coefficients(phase 1)
- punpcklbw xmm6, xmm3 ; xmm6=(02 03 12 13 22 23 32 33 42 43 52 53 62 63 72 73)
- punpckhbw xmm2, xmm3 ; xmm2=(04 05 14 15 24 25 34 35 44 45 54 55 64 65 74 75)
-
- movdqa xmm4, xmm7 ; transpose coefficients(phase 2)
- punpcklwd xmm7, xmm6 ; xmm7=(00 01 02 03 10 11 12 13 20 21 22 23 30 31 32 33)
- punpckhwd xmm4, xmm6 ; xmm4=(40 41 42 43 50 51 52 53 60 61 62 63 70 71 72 73)
- movdqa xmm5, xmm2 ; transpose coefficients(phase 2)
- punpcklwd xmm2, xmm0 ; xmm2=(04 05 06 07 14 15 16 17 24 25 26 27 34 35 36 37)
- punpckhwd xmm5, xmm0 ; xmm5=(44 45 46 47 54 55 56 57 64 65 66 67 74 75 76 77)
-
- movdqa xmm1, xmm7 ; transpose coefficients(phase 3)
- punpckldq xmm7, xmm2 ; xmm7=(00 01 02 03 04 05 06 07 10 11 12 13 14 15 16 17)
- punpckhdq xmm1, xmm2 ; xmm1=(20 21 22 23 24 25 26 27 30 31 32 33 34 35 36 37)
- movdqa xmm3, xmm4 ; transpose coefficients(phase 3)
- punpckldq xmm4, xmm5 ; xmm4=(40 41 42 43 44 45 46 47 50 51 52 53 54 55 56 57)
- punpckhdq xmm3, xmm5 ; xmm3=(60 61 62 63 64 65 66 67 70 71 72 73 74 75 76 77)
-
- pshufd xmm6, xmm7, 0x4E ; xmm6=(10 11 12 13 14 15 16 17 00 01 02 03 04 05 06 07)
- pshufd xmm0, xmm1, 0x4E ; xmm0=(30 31 32 33 34 35 36 37 20 21 22 23 24 25 26 27)
- pshufd xmm2, xmm4, 0x4E ; xmm2=(50 51 52 53 54 55 56 57 40 41 42 43 44 45 46 47)
- pshufd xmm5, xmm3, 0x4E ; xmm5=(70 71 72 73 74 75 76 77 60 61 62 63 64 65 66 67)
-
- mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW]
- mov esi, JSAMPROW [edi+2*SIZEOF_JSAMPROW]
- movq XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE], xmm7
- movq XMM_MMWORD [esi+eax*SIZEOF_JSAMPLE], xmm1
- mov edx, JSAMPROW [edi+4*SIZEOF_JSAMPROW]
- mov esi, JSAMPROW [edi+6*SIZEOF_JSAMPROW]
- movq XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE], xmm4
- movq XMM_MMWORD [esi+eax*SIZEOF_JSAMPLE], xmm3
-
- mov edx, JSAMPROW [edi+1*SIZEOF_JSAMPROW]
- mov esi, JSAMPROW [edi+3*SIZEOF_JSAMPROW]
- movq XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE], xmm6
- movq XMM_MMWORD [esi+eax*SIZEOF_JSAMPLE], xmm0
- mov edx, JSAMPROW [edi+5*SIZEOF_JSAMPROW]
- mov esi, JSAMPROW [edi+7*SIZEOF_JSAMPROW]
- movq XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE], xmm2
- movq XMM_MMWORD [esi+eax*SIZEOF_JSAMPLE], xmm5
-
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; unused
- poppic ebx
- mov esp, ebp ; esp <- aligned ebp
- pop esp ; esp <- original ebp
- pop ebp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jidctred-mmx.asm b/contrib/libs/libjpeg-turbo/simd/i386/jidctred-mmx.asm
deleted file mode 100644
index e2307e1cb6..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jidctred-mmx.asm
+++ /dev/null
@@ -1,704 +0,0 @@
-;
-; jidctred.asm - reduced-size IDCT (MMX)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-;
-; This file contains inverse-DCT routines that produce reduced-size
-; output: either 4x4 or 2x2 pixels from an 8x8 DCT block.
-; The following code is based directly on the IJG's original jidctred.c;
-; see the jidctred.c for more details.
-
-%include "jsimdext.inc"
-%include "jdct.inc"
-
-; --------------------------------------------------------------------------
-
-%define CONST_BITS 13
-%define PASS1_BITS 2
-
-%define DESCALE_P1_4 (CONST_BITS - PASS1_BITS + 1)
-%define DESCALE_P2_4 (CONST_BITS + PASS1_BITS + 3 + 1)
-%define DESCALE_P1_2 (CONST_BITS - PASS1_BITS + 2)
-%define DESCALE_P2_2 (CONST_BITS + PASS1_BITS + 3 + 2)
-
-%if CONST_BITS == 13
-F_0_211 equ 1730 ; FIX(0.211164243)
-F_0_509 equ 4176 ; FIX(0.509795579)
-F_0_601 equ 4926 ; FIX(0.601344887)
-F_0_720 equ 5906 ; FIX(0.720959822)
-F_0_765 equ 6270 ; FIX(0.765366865)
-F_0_850 equ 6967 ; FIX(0.850430095)
-F_0_899 equ 7373 ; FIX(0.899976223)
-F_1_061 equ 8697 ; FIX(1.061594337)
-F_1_272 equ 10426 ; FIX(1.272758580)
-F_1_451 equ 11893 ; FIX(1.451774981)
-F_1_847 equ 15137 ; FIX(1.847759065)
-F_2_172 equ 17799 ; FIX(2.172734803)
-F_2_562 equ 20995 ; FIX(2.562915447)
-F_3_624 equ 29692 ; FIX(3.624509785)
-%else
-; NASM cannot do compile-time arithmetic on floating-point constants.
-%define DESCALE(x, n) (((x) + (1 << ((n) - 1))) >> (n))
-F_0_211 equ DESCALE( 226735879, 30 - CONST_BITS) ; FIX(0.211164243)
-F_0_509 equ DESCALE( 547388834, 30 - CONST_BITS) ; FIX(0.509795579)
-F_0_601 equ DESCALE( 645689155, 30 - CONST_BITS) ; FIX(0.601344887)
-F_0_720 equ DESCALE( 774124714, 30 - CONST_BITS) ; FIX(0.720959822)
-F_0_765 equ DESCALE( 821806413, 30 - CONST_BITS) ; FIX(0.765366865)
-F_0_850 equ DESCALE( 913142361, 30 - CONST_BITS) ; FIX(0.850430095)
-F_0_899 equ DESCALE( 966342111, 30 - CONST_BITS) ; FIX(0.899976223)
-F_1_061 equ DESCALE(1139878239, 30 - CONST_BITS) ; FIX(1.061594337)
-F_1_272 equ DESCALE(1366614119, 30 - CONST_BITS) ; FIX(1.272758580)
-F_1_451 equ DESCALE(1558831516, 30 - CONST_BITS) ; FIX(1.451774981)
-F_1_847 equ DESCALE(1984016188, 30 - CONST_BITS) ; FIX(1.847759065)
-F_2_172 equ DESCALE(2332956230, 30 - CONST_BITS) ; FIX(2.172734803)
-F_2_562 equ DESCALE(2751909506, 30 - CONST_BITS) ; FIX(2.562915447)
-F_3_624 equ DESCALE(3891787747, 30 - CONST_BITS) ; FIX(3.624509785)
-%endif
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_idct_red_mmx)
-
-EXTN(jconst_idct_red_mmx):
-
-PW_F184_MF076 times 2 dw F_1_847, -F_0_765
-PW_F256_F089 times 2 dw F_2_562, F_0_899
-PW_F106_MF217 times 2 dw F_1_061, -F_2_172
-PW_MF060_MF050 times 2 dw -F_0_601, -F_0_509
-PW_F145_MF021 times 2 dw F_1_451, -F_0_211
-PW_F362_MF127 times 2 dw F_3_624, -F_1_272
-PW_F085_MF072 times 2 dw F_0_850, -F_0_720
-PD_DESCALE_P1_4 times 2 dd 1 << (DESCALE_P1_4 - 1)
-PD_DESCALE_P2_4 times 2 dd 1 << (DESCALE_P2_4 - 1)
-PD_DESCALE_P1_2 times 2 dd 1 << (DESCALE_P1_2 - 1)
-PD_DESCALE_P2_2 times 2 dd 1 << (DESCALE_P2_2 - 1)
-PB_CENTERJSAMP times 8 db CENTERJSAMPLE
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-;
-; Perform dequantization and inverse DCT on one block of coefficients,
-; producing a reduced-size 4x4 output block.
-;
-; GLOBAL(void)
-; jsimd_idct_4x4_mmx(void *dct_table, JCOEFPTR coef_block,
-; JSAMPARRAY output_buf, JDIMENSION output_col)
-;
-
-%define dct_table(b) (b) + 8 ; void *dct_table
-%define coef_block(b) (b) + 12 ; JCOEFPTR coef_block
-%define output_buf(b) (b) + 16 ; JSAMPARRAY output_buf
-%define output_col(b) (b) + 20 ; JDIMENSION output_col
-
-%define original_ebp ebp + 0
-%define wk(i) ebp - (WK_NUM - (i)) * SIZEOF_MMWORD
- ; mmword wk[WK_NUM]
-%define WK_NUM 2
-%define workspace wk(0) - DCTSIZE2 * SIZEOF_JCOEF
- ; JCOEF workspace[DCTSIZE2]
-
- align 32
- GLOBAL_FUNCTION(jsimd_idct_4x4_mmx)
-
-EXTN(jsimd_idct_4x4_mmx):
- push ebp
- mov eax, esp ; eax = original ebp
- sub esp, byte 4
- and esp, byte (-SIZEOF_MMWORD) ; align to 64 bits
- mov [esp], eax
- mov ebp, esp ; ebp = aligned ebp
- lea esp, [workspace]
- pushpic ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- get_GOT ebx ; get GOT address
-
- ; ---- Pass 1: process columns from input, store into work array.
-
-; mov eax, [original_ebp]
- mov edx, POINTER [dct_table(eax)] ; quantptr
- mov esi, JCOEFPTR [coef_block(eax)] ; inptr
- lea edi, [workspace] ; JCOEF *wsptr
- mov ecx, DCTSIZE/4 ; ctr
- alignx 16, 7
-.columnloop:
-%ifndef NO_ZERO_COLUMN_TEST_4X4_MMX
- mov eax, dword [DWBLOCK(1,0,esi,SIZEOF_JCOEF)]
- or eax, dword [DWBLOCK(2,0,esi,SIZEOF_JCOEF)]
- jnz short .columnDCT
-
- movq mm0, MMWORD [MMBLOCK(1,0,esi,SIZEOF_JCOEF)]
- movq mm1, MMWORD [MMBLOCK(2,0,esi,SIZEOF_JCOEF)]
- por mm0, MMWORD [MMBLOCK(3,0,esi,SIZEOF_JCOEF)]
- por mm1, MMWORD [MMBLOCK(5,0,esi,SIZEOF_JCOEF)]
- por mm0, MMWORD [MMBLOCK(6,0,esi,SIZEOF_JCOEF)]
- por mm1, MMWORD [MMBLOCK(7,0,esi,SIZEOF_JCOEF)]
- por mm0, mm1
- packsswb mm0, mm0
- movd eax, mm0
- test eax, eax
- jnz short .columnDCT
-
- ; -- AC terms all zero
-
- movq mm0, MMWORD [MMBLOCK(0,0,esi,SIZEOF_JCOEF)]
- pmullw mm0, MMWORD [MMBLOCK(0,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
-
- psllw mm0, PASS1_BITS
-
- movq mm2, mm0 ; mm0=in0=(00 01 02 03)
- punpcklwd mm0, mm0 ; mm0=(00 00 01 01)
- punpckhwd mm2, mm2 ; mm2=(02 02 03 03)
-
- movq mm1, mm0
- punpckldq mm0, mm0 ; mm0=(00 00 00 00)
- punpckhdq mm1, mm1 ; mm1=(01 01 01 01)
- movq mm3, mm2
- punpckldq mm2, mm2 ; mm2=(02 02 02 02)
- punpckhdq mm3, mm3 ; mm3=(03 03 03 03)
-
- movq MMWORD [MMBLOCK(0,0,edi,SIZEOF_JCOEF)], mm0
- movq MMWORD [MMBLOCK(1,0,edi,SIZEOF_JCOEF)], mm1
- movq MMWORD [MMBLOCK(2,0,edi,SIZEOF_JCOEF)], mm2
- movq MMWORD [MMBLOCK(3,0,edi,SIZEOF_JCOEF)], mm3
- jmp near .nextcolumn
- alignx 16, 7
-%endif
-.columnDCT:
-
- ; -- Odd part
-
- movq mm0, MMWORD [MMBLOCK(1,0,esi,SIZEOF_JCOEF)]
- movq mm1, MMWORD [MMBLOCK(3,0,esi,SIZEOF_JCOEF)]
- pmullw mm0, MMWORD [MMBLOCK(1,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
- pmullw mm1, MMWORD [MMBLOCK(3,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
- movq mm2, MMWORD [MMBLOCK(5,0,esi,SIZEOF_JCOEF)]
- movq mm3, MMWORD [MMBLOCK(7,0,esi,SIZEOF_JCOEF)]
- pmullw mm2, MMWORD [MMBLOCK(5,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
- pmullw mm3, MMWORD [MMBLOCK(7,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
-
- movq mm4, mm0
- movq mm5, mm0
- punpcklwd mm4, mm1
- punpckhwd mm5, mm1
- movq mm0, mm4
- movq mm1, mm5
- pmaddwd mm4, [GOTOFF(ebx,PW_F256_F089)] ; mm4=(tmp2L)
- pmaddwd mm5, [GOTOFF(ebx,PW_F256_F089)] ; mm5=(tmp2H)
- pmaddwd mm0, [GOTOFF(ebx,PW_F106_MF217)] ; mm0=(tmp0L)
- pmaddwd mm1, [GOTOFF(ebx,PW_F106_MF217)] ; mm1=(tmp0H)
-
- movq mm6, mm2
- movq mm7, mm2
- punpcklwd mm6, mm3
- punpckhwd mm7, mm3
- movq mm2, mm6
- movq mm3, mm7
- pmaddwd mm6, [GOTOFF(ebx,PW_MF060_MF050)] ; mm6=(tmp2L)
- pmaddwd mm7, [GOTOFF(ebx,PW_MF060_MF050)] ; mm7=(tmp2H)
- pmaddwd mm2, [GOTOFF(ebx,PW_F145_MF021)] ; mm2=(tmp0L)
- pmaddwd mm3, [GOTOFF(ebx,PW_F145_MF021)] ; mm3=(tmp0H)
-
- paddd mm6, mm4 ; mm6=tmp2L
- paddd mm7, mm5 ; mm7=tmp2H
- paddd mm2, mm0 ; mm2=tmp0L
- paddd mm3, mm1 ; mm3=tmp0H
-
- movq MMWORD [wk(0)], mm2 ; wk(0)=tmp0L
- movq MMWORD [wk(1)], mm3 ; wk(1)=tmp0H
-
- ; -- Even part
-
- movq mm4, MMWORD [MMBLOCK(0,0,esi,SIZEOF_JCOEF)]
- movq mm5, MMWORD [MMBLOCK(2,0,esi,SIZEOF_JCOEF)]
- movq mm0, MMWORD [MMBLOCK(6,0,esi,SIZEOF_JCOEF)]
- pmullw mm4, MMWORD [MMBLOCK(0,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
- pmullw mm5, MMWORD [MMBLOCK(2,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
- pmullw mm0, MMWORD [MMBLOCK(6,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
-
- pxor mm1, mm1
- pxor mm2, mm2
- punpcklwd mm1, mm4 ; mm1=tmp0L
- punpckhwd mm2, mm4 ; mm2=tmp0H
- psrad mm1, (16-CONST_BITS-1) ; psrad mm1,16 & pslld mm1,CONST_BITS+1
- psrad mm2, (16-CONST_BITS-1) ; psrad mm2,16 & pslld mm2,CONST_BITS+1
-
- movq mm3, mm5 ; mm5=in2=z2
- punpcklwd mm5, mm0 ; mm0=in6=z3
- punpckhwd mm3, mm0
- pmaddwd mm5, [GOTOFF(ebx,PW_F184_MF076)] ; mm5=tmp2L
- pmaddwd mm3, [GOTOFF(ebx,PW_F184_MF076)] ; mm3=tmp2H
-
- movq mm4, mm1
- movq mm0, mm2
- paddd mm1, mm5 ; mm1=tmp10L
- paddd mm2, mm3 ; mm2=tmp10H
- psubd mm4, mm5 ; mm4=tmp12L
- psubd mm0, mm3 ; mm0=tmp12H
-
- ; -- Final output stage
-
- movq mm5, mm1
- movq mm3, mm2
- paddd mm1, mm6 ; mm1=data0L
- paddd mm2, mm7 ; mm2=data0H
- psubd mm5, mm6 ; mm5=data3L
- psubd mm3, mm7 ; mm3=data3H
-
- movq mm6, [GOTOFF(ebx,PD_DESCALE_P1_4)] ; mm6=[PD_DESCALE_P1_4]
-
- paddd mm1, mm6
- paddd mm2, mm6
- psrad mm1, DESCALE_P1_4
- psrad mm2, DESCALE_P1_4
- paddd mm5, mm6
- paddd mm3, mm6
- psrad mm5, DESCALE_P1_4
- psrad mm3, DESCALE_P1_4
-
- packssdw mm1, mm2 ; mm1=data0=(00 01 02 03)
- packssdw mm5, mm3 ; mm5=data3=(30 31 32 33)
-
- movq mm7, MMWORD [wk(0)] ; mm7=tmp0L
- movq mm6, MMWORD [wk(1)] ; mm6=tmp0H
-
- movq mm2, mm4
- movq mm3, mm0
- paddd mm4, mm7 ; mm4=data1L
- paddd mm0, mm6 ; mm0=data1H
- psubd mm2, mm7 ; mm2=data2L
- psubd mm3, mm6 ; mm3=data2H
-
- movq mm7, [GOTOFF(ebx,PD_DESCALE_P1_4)] ; mm7=[PD_DESCALE_P1_4]
-
- paddd mm4, mm7
- paddd mm0, mm7
- psrad mm4, DESCALE_P1_4
- psrad mm0, DESCALE_P1_4
- paddd mm2, mm7
- paddd mm3, mm7
- psrad mm2, DESCALE_P1_4
- psrad mm3, DESCALE_P1_4
-
- packssdw mm4, mm0 ; mm4=data1=(10 11 12 13)
- packssdw mm2, mm3 ; mm2=data2=(20 21 22 23)
-
- movq mm6, mm1 ; transpose coefficients(phase 1)
- punpcklwd mm1, mm4 ; mm1=(00 10 01 11)
- punpckhwd mm6, mm4 ; mm6=(02 12 03 13)
- movq mm7, mm2 ; transpose coefficients(phase 1)
- punpcklwd mm2, mm5 ; mm2=(20 30 21 31)
- punpckhwd mm7, mm5 ; mm7=(22 32 23 33)
-
- movq mm0, mm1 ; transpose coefficients(phase 2)
- punpckldq mm1, mm2 ; mm1=(00 10 20 30)
- punpckhdq mm0, mm2 ; mm0=(01 11 21 31)
- movq mm3, mm6 ; transpose coefficients(phase 2)
- punpckldq mm6, mm7 ; mm6=(02 12 22 32)
- punpckhdq mm3, mm7 ; mm3=(03 13 23 33)
-
- movq MMWORD [MMBLOCK(0,0,edi,SIZEOF_JCOEF)], mm1
- movq MMWORD [MMBLOCK(1,0,edi,SIZEOF_JCOEF)], mm0
- movq MMWORD [MMBLOCK(2,0,edi,SIZEOF_JCOEF)], mm6
- movq MMWORD [MMBLOCK(3,0,edi,SIZEOF_JCOEF)], mm3
-
-.nextcolumn:
- add esi, byte 4*SIZEOF_JCOEF ; coef_block
- add edx, byte 4*SIZEOF_ISLOW_MULT_TYPE ; quantptr
- add edi, byte 4*DCTSIZE*SIZEOF_JCOEF ; wsptr
- dec ecx ; ctr
- jnz near .columnloop
-
- ; ---- Pass 2: process rows from work array, store into output array.
-
- mov eax, [original_ebp]
- lea esi, [workspace] ; JCOEF *wsptr
- mov edi, JSAMPARRAY [output_buf(eax)] ; (JSAMPROW *)
- mov eax, JDIMENSION [output_col(eax)]
-
- ; -- Odd part
-
- movq mm0, MMWORD [MMBLOCK(1,0,esi,SIZEOF_JCOEF)]
- movq mm1, MMWORD [MMBLOCK(3,0,esi,SIZEOF_JCOEF)]
- movq mm2, MMWORD [MMBLOCK(5,0,esi,SIZEOF_JCOEF)]
- movq mm3, MMWORD [MMBLOCK(7,0,esi,SIZEOF_JCOEF)]
-
- movq mm4, mm0
- movq mm5, mm0
- punpcklwd mm4, mm1
- punpckhwd mm5, mm1
- movq mm0, mm4
- movq mm1, mm5
- pmaddwd mm4, [GOTOFF(ebx,PW_F256_F089)] ; mm4=(tmp2L)
- pmaddwd mm5, [GOTOFF(ebx,PW_F256_F089)] ; mm5=(tmp2H)
- pmaddwd mm0, [GOTOFF(ebx,PW_F106_MF217)] ; mm0=(tmp0L)
- pmaddwd mm1, [GOTOFF(ebx,PW_F106_MF217)] ; mm1=(tmp0H)
-
- movq mm6, mm2
- movq mm7, mm2
- punpcklwd mm6, mm3
- punpckhwd mm7, mm3
- movq mm2, mm6
- movq mm3, mm7
- pmaddwd mm6, [GOTOFF(ebx,PW_MF060_MF050)] ; mm6=(tmp2L)
- pmaddwd mm7, [GOTOFF(ebx,PW_MF060_MF050)] ; mm7=(tmp2H)
- pmaddwd mm2, [GOTOFF(ebx,PW_F145_MF021)] ; mm2=(tmp0L)
- pmaddwd mm3, [GOTOFF(ebx,PW_F145_MF021)] ; mm3=(tmp0H)
-
- paddd mm6, mm4 ; mm6=tmp2L
- paddd mm7, mm5 ; mm7=tmp2H
- paddd mm2, mm0 ; mm2=tmp0L
- paddd mm3, mm1 ; mm3=tmp0H
-
- movq MMWORD [wk(0)], mm2 ; wk(0)=tmp0L
- movq MMWORD [wk(1)], mm3 ; wk(1)=tmp0H
-
- ; -- Even part
-
- movq mm4, MMWORD [MMBLOCK(0,0,esi,SIZEOF_JCOEF)]
- movq mm5, MMWORD [MMBLOCK(2,0,esi,SIZEOF_JCOEF)]
- movq mm0, MMWORD [MMBLOCK(6,0,esi,SIZEOF_JCOEF)]
-
- pxor mm1, mm1
- pxor mm2, mm2
- punpcklwd mm1, mm4 ; mm1=tmp0L
- punpckhwd mm2, mm4 ; mm2=tmp0H
- psrad mm1, (16-CONST_BITS-1) ; psrad mm1,16 & pslld mm1,CONST_BITS+1
- psrad mm2, (16-CONST_BITS-1) ; psrad mm2,16 & pslld mm2,CONST_BITS+1
-
- movq mm3, mm5 ; mm5=in2=z2
- punpcklwd mm5, mm0 ; mm0=in6=z3
- punpckhwd mm3, mm0
- pmaddwd mm5, [GOTOFF(ebx,PW_F184_MF076)] ; mm5=tmp2L
- pmaddwd mm3, [GOTOFF(ebx,PW_F184_MF076)] ; mm3=tmp2H
-
- movq mm4, mm1
- movq mm0, mm2
- paddd mm1, mm5 ; mm1=tmp10L
- paddd mm2, mm3 ; mm2=tmp10H
- psubd mm4, mm5 ; mm4=tmp12L
- psubd mm0, mm3 ; mm0=tmp12H
-
- ; -- Final output stage
-
- movq mm5, mm1
- movq mm3, mm2
- paddd mm1, mm6 ; mm1=data0L
- paddd mm2, mm7 ; mm2=data0H
- psubd mm5, mm6 ; mm5=data3L
- psubd mm3, mm7 ; mm3=data3H
-
- movq mm6, [GOTOFF(ebx,PD_DESCALE_P2_4)] ; mm6=[PD_DESCALE_P2_4]
-
- paddd mm1, mm6
- paddd mm2, mm6
- psrad mm1, DESCALE_P2_4
- psrad mm2, DESCALE_P2_4
- paddd mm5, mm6
- paddd mm3, mm6
- psrad mm5, DESCALE_P2_4
- psrad mm3, DESCALE_P2_4
-
- packssdw mm1, mm2 ; mm1=data0=(00 10 20 30)
- packssdw mm5, mm3 ; mm5=data3=(03 13 23 33)
-
- movq mm7, MMWORD [wk(0)] ; mm7=tmp0L
- movq mm6, MMWORD [wk(1)] ; mm6=tmp0H
-
- movq mm2, mm4
- movq mm3, mm0
- paddd mm4, mm7 ; mm4=data1L
- paddd mm0, mm6 ; mm0=data1H
- psubd mm2, mm7 ; mm2=data2L
- psubd mm3, mm6 ; mm3=data2H
-
- movq mm7, [GOTOFF(ebx,PD_DESCALE_P2_4)] ; mm7=[PD_DESCALE_P2_4]
-
- paddd mm4, mm7
- paddd mm0, mm7
- psrad mm4, DESCALE_P2_4
- psrad mm0, DESCALE_P2_4
- paddd mm2, mm7
- paddd mm3, mm7
- psrad mm2, DESCALE_P2_4
- psrad mm3, DESCALE_P2_4
-
- packssdw mm4, mm0 ; mm4=data1=(01 11 21 31)
- packssdw mm2, mm3 ; mm2=data2=(02 12 22 32)
-
- movq mm6, [GOTOFF(ebx,PB_CENTERJSAMP)] ; mm6=[PB_CENTERJSAMP]
-
- packsswb mm1, mm2 ; mm1=(00 10 20 30 02 12 22 32)
- packsswb mm4, mm5 ; mm4=(01 11 21 31 03 13 23 33)
- paddb mm1, mm6
- paddb mm4, mm6
-
- movq mm7, mm1 ; transpose coefficients(phase 1)
- punpcklbw mm1, mm4 ; mm1=(00 01 10 11 20 21 30 31)
- punpckhbw mm7, mm4 ; mm7=(02 03 12 13 22 23 32 33)
-
- movq mm0, mm1 ; transpose coefficients(phase 2)
- punpcklwd mm1, mm7 ; mm1=(00 01 02 03 10 11 12 13)
- punpckhwd mm0, mm7 ; mm0=(20 21 22 23 30 31 32 33)
-
- mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW]
- mov esi, JSAMPROW [edi+2*SIZEOF_JSAMPROW]
- movd dword [edx+eax*SIZEOF_JSAMPLE], mm1
- movd dword [esi+eax*SIZEOF_JSAMPLE], mm0
-
- psrlq mm1, 4*BYTE_BIT
- psrlq mm0, 4*BYTE_BIT
-
- mov edx, JSAMPROW [edi+1*SIZEOF_JSAMPROW]
- mov esi, JSAMPROW [edi+3*SIZEOF_JSAMPROW]
- movd dword [edx+eax*SIZEOF_JSAMPLE], mm1
- movd dword [esi+eax*SIZEOF_JSAMPLE], mm0
-
- emms ; empty MMX state
-
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- poppic ebx
- mov esp, ebp ; esp <- aligned ebp
- pop esp ; esp <- original ebp
- pop ebp
- ret
-
-; --------------------------------------------------------------------------
-;
-; Perform dequantization and inverse DCT on one block of coefficients,
-; producing a reduced-size 2x2 output block.
-;
-; GLOBAL(void)
-; jsimd_idct_2x2_mmx(void *dct_table, JCOEFPTR coef_block,
-; JSAMPARRAY output_buf, JDIMENSION output_col)
-;
-
-%define dct_table(b) (b) + 8 ; void *dct_table
-%define coef_block(b) (b) + 12 ; JCOEFPTR coef_block
-%define output_buf(b) (b) + 16 ; JSAMPARRAY output_buf
-%define output_col(b) (b) + 20 ; JDIMENSION output_col
-
- align 32
- GLOBAL_FUNCTION(jsimd_idct_2x2_mmx)
-
-EXTN(jsimd_idct_2x2_mmx):
- push ebp
- mov ebp, esp
- push ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- get_GOT ebx ; get GOT address
-
- ; ---- Pass 1: process columns from input.
-
- mov edx, POINTER [dct_table(ebp)] ; quantptr
- mov esi, JCOEFPTR [coef_block(ebp)] ; inptr
-
- ; | input: | result: |
- ; | 00 01 ** 03 ** 05 ** 07 | |
- ; | 10 11 ** 13 ** 15 ** 17 | |
- ; | ** ** ** ** ** ** ** ** | |
- ; | 30 31 ** 33 ** 35 ** 37 | A0 A1 A3 A5 A7 |
- ; | ** ** ** ** ** ** ** ** | B0 B1 B3 B5 B7 |
- ; | 50 51 ** 53 ** 55 ** 57 | |
- ; | ** ** ** ** ** ** ** ** | |
- ; | 70 71 ** 73 ** 75 ** 77 | |
-
- ; -- Odd part
-
- movq mm0, MMWORD [MMBLOCK(1,0,esi,SIZEOF_JCOEF)]
- movq mm1, MMWORD [MMBLOCK(3,0,esi,SIZEOF_JCOEF)]
- pmullw mm0, MMWORD [MMBLOCK(1,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
- pmullw mm1, MMWORD [MMBLOCK(3,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
- movq mm2, MMWORD [MMBLOCK(5,0,esi,SIZEOF_JCOEF)]
- movq mm3, MMWORD [MMBLOCK(7,0,esi,SIZEOF_JCOEF)]
- pmullw mm2, MMWORD [MMBLOCK(5,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
- pmullw mm3, MMWORD [MMBLOCK(7,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
-
- ; mm0=(10 11 ** 13), mm1=(30 31 ** 33)
- ; mm2=(50 51 ** 53), mm3=(70 71 ** 73)
-
- pcmpeqd mm7, mm7
- pslld mm7, WORD_BIT ; mm7={0x0000 0xFFFF 0x0000 0xFFFF}
-
- movq mm4, mm0 ; mm4=(10 11 ** 13)
- movq mm5, mm2 ; mm5=(50 51 ** 53)
- punpcklwd mm4, mm1 ; mm4=(10 30 11 31)
- punpcklwd mm5, mm3 ; mm5=(50 70 51 71)
- pmaddwd mm4, [GOTOFF(ebx,PW_F362_MF127)]
- pmaddwd mm5, [GOTOFF(ebx,PW_F085_MF072)]
-
- psrld mm0, WORD_BIT ; mm0=(11 -- 13 --)
- pand mm1, mm7 ; mm1=(-- 31 -- 33)
- psrld mm2, WORD_BIT ; mm2=(51 -- 53 --)
- pand mm3, mm7 ; mm3=(-- 71 -- 73)
- por mm0, mm1 ; mm0=(11 31 13 33)
- por mm2, mm3 ; mm2=(51 71 53 73)
- pmaddwd mm0, [GOTOFF(ebx,PW_F362_MF127)]
- pmaddwd mm2, [GOTOFF(ebx,PW_F085_MF072)]
-
- paddd mm4, mm5 ; mm4=tmp0[col0 col1]
-
- movq mm6, MMWORD [MMBLOCK(1,1,esi,SIZEOF_JCOEF)]
- movq mm1, MMWORD [MMBLOCK(3,1,esi,SIZEOF_JCOEF)]
- pmullw mm6, MMWORD [MMBLOCK(1,1,edx,SIZEOF_ISLOW_MULT_TYPE)]
- pmullw mm1, MMWORD [MMBLOCK(3,1,edx,SIZEOF_ISLOW_MULT_TYPE)]
- movq mm3, MMWORD [MMBLOCK(5,1,esi,SIZEOF_JCOEF)]
- movq mm5, MMWORD [MMBLOCK(7,1,esi,SIZEOF_JCOEF)]
- pmullw mm3, MMWORD [MMBLOCK(5,1,edx,SIZEOF_ISLOW_MULT_TYPE)]
- pmullw mm5, MMWORD [MMBLOCK(7,1,edx,SIZEOF_ISLOW_MULT_TYPE)]
-
- ; mm6=(** 15 ** 17), mm1=(** 35 ** 37)
- ; mm3=(** 55 ** 57), mm5=(** 75 ** 77)
-
- psrld mm6, WORD_BIT ; mm6=(15 -- 17 --)
- pand mm1, mm7 ; mm1=(-- 35 -- 37)
- psrld mm3, WORD_BIT ; mm3=(55 -- 57 --)
- pand mm5, mm7 ; mm5=(-- 75 -- 77)
- por mm6, mm1 ; mm6=(15 35 17 37)
- por mm3, mm5 ; mm3=(55 75 57 77)
- pmaddwd mm6, [GOTOFF(ebx,PW_F362_MF127)]
- pmaddwd mm3, [GOTOFF(ebx,PW_F085_MF072)]
-
- paddd mm0, mm2 ; mm0=tmp0[col1 col3]
- paddd mm6, mm3 ; mm6=tmp0[col5 col7]
-
- ; -- Even part
-
- movq mm1, MMWORD [MMBLOCK(0,0,esi,SIZEOF_JCOEF)]
- movq mm5, MMWORD [MMBLOCK(0,1,esi,SIZEOF_JCOEF)]
- pmullw mm1, MMWORD [MMBLOCK(0,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
- pmullw mm5, MMWORD [MMBLOCK(0,1,edx,SIZEOF_ISLOW_MULT_TYPE)]
-
- ; mm1=(00 01 ** 03), mm5=(** 05 ** 07)
-
- movq mm2, mm1 ; mm2=(00 01 ** 03)
- pslld mm1, WORD_BIT ; mm1=(-- 00 -- **)
- psrad mm1, (WORD_BIT-CONST_BITS-2) ; mm1=tmp10[col0 ****]
-
- pand mm2, mm7 ; mm2=(-- 01 -- 03)
- pand mm5, mm7 ; mm5=(-- 05 -- 07)
- psrad mm2, (WORD_BIT-CONST_BITS-2) ; mm2=tmp10[col1 col3]
- psrad mm5, (WORD_BIT-CONST_BITS-2) ; mm5=tmp10[col5 col7]
-
- ; -- Final output stage
-
- movq mm3, mm1
- paddd mm1, mm4 ; mm1=data0[col0 ****]=(A0 **)
- psubd mm3, mm4 ; mm3=data1[col0 ****]=(B0 **)
- punpckldq mm1, mm3 ; mm1=(A0 B0)
-
- movq mm7, [GOTOFF(ebx,PD_DESCALE_P1_2)] ; mm7=[PD_DESCALE_P1_2]
-
- movq mm4, mm2
- movq mm3, mm5
- paddd mm2, mm0 ; mm2=data0[col1 col3]=(A1 A3)
- paddd mm5, mm6 ; mm5=data0[col5 col7]=(A5 A7)
- psubd mm4, mm0 ; mm4=data1[col1 col3]=(B1 B3)
- psubd mm3, mm6 ; mm3=data1[col5 col7]=(B5 B7)
-
- paddd mm1, mm7
- psrad mm1, DESCALE_P1_2
-
- paddd mm2, mm7
- paddd mm5, mm7
- psrad mm2, DESCALE_P1_2
- psrad mm5, DESCALE_P1_2
- paddd mm4, mm7
- paddd mm3, mm7
- psrad mm4, DESCALE_P1_2
- psrad mm3, DESCALE_P1_2
-
- ; ---- Pass 2: process rows, store into output array.
-
- mov edi, JSAMPARRAY [output_buf(ebp)] ; (JSAMPROW *)
- mov eax, JDIMENSION [output_col(ebp)]
-
- ; | input:| result:|
- ; | A0 B0 | |
- ; | A1 B1 | C0 C1 |
- ; | A3 B3 | D0 D1 |
- ; | A5 B5 | |
- ; | A7 B7 | |
-
- ; -- Odd part
-
- packssdw mm2, mm4 ; mm2=(A1 A3 B1 B3)
- packssdw mm5, mm3 ; mm5=(A5 A7 B5 B7)
- pmaddwd mm2, [GOTOFF(ebx,PW_F362_MF127)]
- pmaddwd mm5, [GOTOFF(ebx,PW_F085_MF072)]
-
- paddd mm2, mm5 ; mm2=tmp0[row0 row1]
-
- ; -- Even part
-
- pslld mm1, (CONST_BITS+2) ; mm1=tmp10[row0 row1]
-
- ; -- Final output stage
-
- movq mm0, [GOTOFF(ebx,PD_DESCALE_P2_2)] ; mm0=[PD_DESCALE_P2_2]
-
- movq mm6, mm1
- paddd mm1, mm2 ; mm1=data0[row0 row1]=(C0 C1)
- psubd mm6, mm2 ; mm6=data1[row0 row1]=(D0 D1)
-
- paddd mm1, mm0
- paddd mm6, mm0
- psrad mm1, DESCALE_P2_2
- psrad mm6, DESCALE_P2_2
-
- movq mm7, mm1 ; transpose coefficients
- punpckldq mm1, mm6 ; mm1=(C0 D0)
- punpckhdq mm7, mm6 ; mm7=(C1 D1)
-
- packssdw mm1, mm7 ; mm1=(C0 D0 C1 D1)
- packsswb mm1, mm1 ; mm1=(C0 D0 C1 D1 C0 D0 C1 D1)
- paddb mm1, [GOTOFF(ebx,PB_CENTERJSAMP)]
-
- movd ecx, mm1
- movd ebx, mm1 ; ebx=(C0 D0 C1 D1)
- shr ecx, 2*BYTE_BIT ; ecx=(C1 D1 -- --)
-
- mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW]
- mov esi, JSAMPROW [edi+1*SIZEOF_JSAMPROW]
- mov word [edx+eax*SIZEOF_JSAMPLE], bx
- mov word [esi+eax*SIZEOF_JSAMPLE], cx
-
- emms ; empty MMX state
-
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- pop ebx
- pop ebp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jidctred-sse2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jidctred-sse2.asm
deleted file mode 100644
index 6e56494e97..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jidctred-sse2.asm
+++ /dev/null
@@ -1,592 +0,0 @@
-;
-; jidctred.asm - reduced-size IDCT (SSE2)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-;
-; This file contains inverse-DCT routines that produce reduced-size
-; output: either 4x4 or 2x2 pixels from an 8x8 DCT block.
-; The following code is based directly on the IJG's original jidctred.c;
-; see the jidctred.c for more details.
-
-%include "jsimdext.inc"
-%include "jdct.inc"
-
-; --------------------------------------------------------------------------
-
-%define CONST_BITS 13
-%define PASS1_BITS 2
-
-%define DESCALE_P1_4 (CONST_BITS - PASS1_BITS + 1)
-%define DESCALE_P2_4 (CONST_BITS + PASS1_BITS + 3 + 1)
-%define DESCALE_P1_2 (CONST_BITS - PASS1_BITS + 2)
-%define DESCALE_P2_2 (CONST_BITS + PASS1_BITS + 3 + 2)
-
-%if CONST_BITS == 13
-F_0_211 equ 1730 ; FIX(0.211164243)
-F_0_509 equ 4176 ; FIX(0.509795579)
-F_0_601 equ 4926 ; FIX(0.601344887)
-F_0_720 equ 5906 ; FIX(0.720959822)
-F_0_765 equ 6270 ; FIX(0.765366865)
-F_0_850 equ 6967 ; FIX(0.850430095)
-F_0_899 equ 7373 ; FIX(0.899976223)
-F_1_061 equ 8697 ; FIX(1.061594337)
-F_1_272 equ 10426 ; FIX(1.272758580)
-F_1_451 equ 11893 ; FIX(1.451774981)
-F_1_847 equ 15137 ; FIX(1.847759065)
-F_2_172 equ 17799 ; FIX(2.172734803)
-F_2_562 equ 20995 ; FIX(2.562915447)
-F_3_624 equ 29692 ; FIX(3.624509785)
-%else
-; NASM cannot do compile-time arithmetic on floating-point constants.
-%define DESCALE(x, n) (((x) + (1 << ((n) - 1))) >> (n))
-F_0_211 equ DESCALE( 226735879, 30 - CONST_BITS) ; FIX(0.211164243)
-F_0_509 equ DESCALE( 547388834, 30 - CONST_BITS) ; FIX(0.509795579)
-F_0_601 equ DESCALE( 645689155, 30 - CONST_BITS) ; FIX(0.601344887)
-F_0_720 equ DESCALE( 774124714, 30 - CONST_BITS) ; FIX(0.720959822)
-F_0_765 equ DESCALE( 821806413, 30 - CONST_BITS) ; FIX(0.765366865)
-F_0_850 equ DESCALE( 913142361, 30 - CONST_BITS) ; FIX(0.850430095)
-F_0_899 equ DESCALE( 966342111, 30 - CONST_BITS) ; FIX(0.899976223)
-F_1_061 equ DESCALE(1139878239, 30 - CONST_BITS) ; FIX(1.061594337)
-F_1_272 equ DESCALE(1366614119, 30 - CONST_BITS) ; FIX(1.272758580)
-F_1_451 equ DESCALE(1558831516, 30 - CONST_BITS) ; FIX(1.451774981)
-F_1_847 equ DESCALE(1984016188, 30 - CONST_BITS) ; FIX(1.847759065)
-F_2_172 equ DESCALE(2332956230, 30 - CONST_BITS) ; FIX(2.172734803)
-F_2_562 equ DESCALE(2751909506, 30 - CONST_BITS) ; FIX(2.562915447)
-F_3_624 equ DESCALE(3891787747, 30 - CONST_BITS) ; FIX(3.624509785)
-%endif
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_idct_red_sse2)
-
-EXTN(jconst_idct_red_sse2):
-
-PW_F184_MF076 times 4 dw F_1_847, -F_0_765
-PW_F256_F089 times 4 dw F_2_562, F_0_899
-PW_F106_MF217 times 4 dw F_1_061, -F_2_172
-PW_MF060_MF050 times 4 dw -F_0_601, -F_0_509
-PW_F145_MF021 times 4 dw F_1_451, -F_0_211
-PW_F362_MF127 times 4 dw F_3_624, -F_1_272
-PW_F085_MF072 times 4 dw F_0_850, -F_0_720
-PD_DESCALE_P1_4 times 4 dd 1 << (DESCALE_P1_4 - 1)
-PD_DESCALE_P2_4 times 4 dd 1 << (DESCALE_P2_4 - 1)
-PD_DESCALE_P1_2 times 4 dd 1 << (DESCALE_P1_2 - 1)
-PD_DESCALE_P2_2 times 4 dd 1 << (DESCALE_P2_2 - 1)
-PB_CENTERJSAMP times 16 db CENTERJSAMPLE
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-;
-; Perform dequantization and inverse DCT on one block of coefficients,
-; producing a reduced-size 4x4 output block.
-;
-; GLOBAL(void)
-; jsimd_idct_4x4_sse2(void *dct_table, JCOEFPTR coef_block,
-; JSAMPARRAY output_buf, JDIMENSION output_col)
-;
-
-%define dct_table(b) (b) + 8 ; void *dct_table
-%define coef_block(b) (b) + 12 ; JCOEFPTR coef_block
-%define output_buf(b) (b) + 16 ; JSAMPARRAY output_buf
-%define output_col(b) (b) + 20 ; JDIMENSION output_col
-
-%define original_ebp ebp + 0
-%define wk(i) ebp - (WK_NUM - (i)) * SIZEOF_XMMWORD
- ; xmmword wk[WK_NUM]
-%define WK_NUM 2
-
- align 32
- GLOBAL_FUNCTION(jsimd_idct_4x4_sse2)
-
-EXTN(jsimd_idct_4x4_sse2):
- push ebp
- mov eax, esp ; eax = original ebp
- sub esp, byte 4
- and esp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [esp], eax
- mov ebp, esp ; ebp = aligned ebp
- lea esp, [wk(0)]
- pushpic ebx
-; push ecx ; unused
-; push edx ; need not be preserved
- push esi
- push edi
-
- get_GOT ebx ; get GOT address
-
- ; ---- Pass 1: process columns from input.
-
-; mov eax, [original_ebp]
- mov edx, POINTER [dct_table(eax)] ; quantptr
- mov esi, JCOEFPTR [coef_block(eax)] ; inptr
-
-%ifndef NO_ZERO_COLUMN_TEST_4X4_SSE2
- mov eax, dword [DWBLOCK(1,0,esi,SIZEOF_JCOEF)]
- or eax, dword [DWBLOCK(2,0,esi,SIZEOF_JCOEF)]
- jnz short .columnDCT
-
- movdqa xmm0, XMMWORD [XMMBLOCK(1,0,esi,SIZEOF_JCOEF)]
- movdqa xmm1, XMMWORD [XMMBLOCK(2,0,esi,SIZEOF_JCOEF)]
- por xmm0, XMMWORD [XMMBLOCK(3,0,esi,SIZEOF_JCOEF)]
- por xmm1, XMMWORD [XMMBLOCK(5,0,esi,SIZEOF_JCOEF)]
- por xmm0, XMMWORD [XMMBLOCK(6,0,esi,SIZEOF_JCOEF)]
- por xmm1, XMMWORD [XMMBLOCK(7,0,esi,SIZEOF_JCOEF)]
- por xmm0, xmm1
- packsswb xmm0, xmm0
- packsswb xmm0, xmm0
- movd eax, xmm0
- test eax, eax
- jnz short .columnDCT
-
- ; -- AC terms all zero
-
- movdqa xmm0, XMMWORD [XMMBLOCK(0,0,esi,SIZEOF_JCOEF)]
- pmullw xmm0, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
-
- psllw xmm0, PASS1_BITS
-
- movdqa xmm3, xmm0 ; xmm0=in0=(00 01 02 03 04 05 06 07)
- punpcklwd xmm0, xmm0 ; xmm0=(00 00 01 01 02 02 03 03)
- punpckhwd xmm3, xmm3 ; xmm3=(04 04 05 05 06 06 07 07)
-
- pshufd xmm1, xmm0, 0x50 ; xmm1=[col0 col1]=(00 00 00 00 01 01 01 01)
- pshufd xmm0, xmm0, 0xFA ; xmm0=[col2 col3]=(02 02 02 02 03 03 03 03)
- pshufd xmm6, xmm3, 0x50 ; xmm6=[col4 col5]=(04 04 04 04 05 05 05 05)
- pshufd xmm3, xmm3, 0xFA ; xmm3=[col6 col7]=(06 06 06 06 07 07 07 07)
-
- jmp near .column_end
- alignx 16, 7
-%endif
-.columnDCT:
-
- ; -- Odd part
-
- movdqa xmm0, XMMWORD [XMMBLOCK(1,0,esi,SIZEOF_JCOEF)]
- movdqa xmm1, XMMWORD [XMMBLOCK(3,0,esi,SIZEOF_JCOEF)]
- pmullw xmm0, XMMWORD [XMMBLOCK(1,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
- pmullw xmm1, XMMWORD [XMMBLOCK(3,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
- movdqa xmm2, XMMWORD [XMMBLOCK(5,0,esi,SIZEOF_JCOEF)]
- movdqa xmm3, XMMWORD [XMMBLOCK(7,0,esi,SIZEOF_JCOEF)]
- pmullw xmm2, XMMWORD [XMMBLOCK(5,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
- pmullw xmm3, XMMWORD [XMMBLOCK(7,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
-
- movdqa xmm4, xmm0
- movdqa xmm5, xmm0
- punpcklwd xmm4, xmm1
- punpckhwd xmm5, xmm1
- movdqa xmm0, xmm4
- movdqa xmm1, xmm5
- pmaddwd xmm4, [GOTOFF(ebx,PW_F256_F089)] ; xmm4=(tmp2L)
- pmaddwd xmm5, [GOTOFF(ebx,PW_F256_F089)] ; xmm5=(tmp2H)
- pmaddwd xmm0, [GOTOFF(ebx,PW_F106_MF217)] ; xmm0=(tmp0L)
- pmaddwd xmm1, [GOTOFF(ebx,PW_F106_MF217)] ; xmm1=(tmp0H)
-
- movdqa xmm6, xmm2
- movdqa xmm7, xmm2
- punpcklwd xmm6, xmm3
- punpckhwd xmm7, xmm3
- movdqa xmm2, xmm6
- movdqa xmm3, xmm7
- pmaddwd xmm6, [GOTOFF(ebx,PW_MF060_MF050)] ; xmm6=(tmp2L)
- pmaddwd xmm7, [GOTOFF(ebx,PW_MF060_MF050)] ; xmm7=(tmp2H)
- pmaddwd xmm2, [GOTOFF(ebx,PW_F145_MF021)] ; xmm2=(tmp0L)
- pmaddwd xmm3, [GOTOFF(ebx,PW_F145_MF021)] ; xmm3=(tmp0H)
-
- paddd xmm6, xmm4 ; xmm6=tmp2L
- paddd xmm7, xmm5 ; xmm7=tmp2H
- paddd xmm2, xmm0 ; xmm2=tmp0L
- paddd xmm3, xmm1 ; xmm3=tmp0H
-
- movdqa XMMWORD [wk(0)], xmm2 ; wk(0)=tmp0L
- movdqa XMMWORD [wk(1)], xmm3 ; wk(1)=tmp0H
-
- ; -- Even part
-
- movdqa xmm4, XMMWORD [XMMBLOCK(0,0,esi,SIZEOF_JCOEF)]
- movdqa xmm5, XMMWORD [XMMBLOCK(2,0,esi,SIZEOF_JCOEF)]
- movdqa xmm0, XMMWORD [XMMBLOCK(6,0,esi,SIZEOF_JCOEF)]
- pmullw xmm4, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
- pmullw xmm5, XMMWORD [XMMBLOCK(2,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
- pmullw xmm0, XMMWORD [XMMBLOCK(6,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
-
- pxor xmm1, xmm1
- pxor xmm2, xmm2
- punpcklwd xmm1, xmm4 ; xmm1=tmp0L
- punpckhwd xmm2, xmm4 ; xmm2=tmp0H
- psrad xmm1, (16-CONST_BITS-1) ; psrad xmm1,16 & pslld xmm1,CONST_BITS+1
- psrad xmm2, (16-CONST_BITS-1) ; psrad xmm2,16 & pslld xmm2,CONST_BITS+1
-
- movdqa xmm3, xmm5 ; xmm5=in2=z2
- punpcklwd xmm5, xmm0 ; xmm0=in6=z3
- punpckhwd xmm3, xmm0
- pmaddwd xmm5, [GOTOFF(ebx,PW_F184_MF076)] ; xmm5=tmp2L
- pmaddwd xmm3, [GOTOFF(ebx,PW_F184_MF076)] ; xmm3=tmp2H
-
- movdqa xmm4, xmm1
- movdqa xmm0, xmm2
- paddd xmm1, xmm5 ; xmm1=tmp10L
- paddd xmm2, xmm3 ; xmm2=tmp10H
- psubd xmm4, xmm5 ; xmm4=tmp12L
- psubd xmm0, xmm3 ; xmm0=tmp12H
-
- ; -- Final output stage
-
- movdqa xmm5, xmm1
- movdqa xmm3, xmm2
- paddd xmm1, xmm6 ; xmm1=data0L
- paddd xmm2, xmm7 ; xmm2=data0H
- psubd xmm5, xmm6 ; xmm5=data3L
- psubd xmm3, xmm7 ; xmm3=data3H
-
- movdqa xmm6, [GOTOFF(ebx,PD_DESCALE_P1_4)] ; xmm6=[PD_DESCALE_P1_4]
-
- paddd xmm1, xmm6
- paddd xmm2, xmm6
- psrad xmm1, DESCALE_P1_4
- psrad xmm2, DESCALE_P1_4
- paddd xmm5, xmm6
- paddd xmm3, xmm6
- psrad xmm5, DESCALE_P1_4
- psrad xmm3, DESCALE_P1_4
-
- packssdw xmm1, xmm2 ; xmm1=data0=(00 01 02 03 04 05 06 07)
- packssdw xmm5, xmm3 ; xmm5=data3=(30 31 32 33 34 35 36 37)
-
- movdqa xmm7, XMMWORD [wk(0)] ; xmm7=tmp0L
- movdqa xmm6, XMMWORD [wk(1)] ; xmm6=tmp0H
-
- movdqa xmm2, xmm4
- movdqa xmm3, xmm0
- paddd xmm4, xmm7 ; xmm4=data1L
- paddd xmm0, xmm6 ; xmm0=data1H
- psubd xmm2, xmm7 ; xmm2=data2L
- psubd xmm3, xmm6 ; xmm3=data2H
-
- movdqa xmm7, [GOTOFF(ebx,PD_DESCALE_P1_4)] ; xmm7=[PD_DESCALE_P1_4]
-
- paddd xmm4, xmm7
- paddd xmm0, xmm7
- psrad xmm4, DESCALE_P1_4
- psrad xmm0, DESCALE_P1_4
- paddd xmm2, xmm7
- paddd xmm3, xmm7
- psrad xmm2, DESCALE_P1_4
- psrad xmm3, DESCALE_P1_4
-
- packssdw xmm4, xmm0 ; xmm4=data1=(10 11 12 13 14 15 16 17)
- packssdw xmm2, xmm3 ; xmm2=data2=(20 21 22 23 24 25 26 27)
-
- movdqa xmm6, xmm1 ; transpose coefficients(phase 1)
- punpcklwd xmm1, xmm4 ; xmm1=(00 10 01 11 02 12 03 13)
- punpckhwd xmm6, xmm4 ; xmm6=(04 14 05 15 06 16 07 17)
- movdqa xmm7, xmm2 ; transpose coefficients(phase 1)
- punpcklwd xmm2, xmm5 ; xmm2=(20 30 21 31 22 32 23 33)
- punpckhwd xmm7, xmm5 ; xmm7=(24 34 25 35 26 36 27 37)
-
- movdqa xmm0, xmm1 ; transpose coefficients(phase 2)
- punpckldq xmm1, xmm2 ; xmm1=[col0 col1]=(00 10 20 30 01 11 21 31)
- punpckhdq xmm0, xmm2 ; xmm0=[col2 col3]=(02 12 22 32 03 13 23 33)
- movdqa xmm3, xmm6 ; transpose coefficients(phase 2)
- punpckldq xmm6, xmm7 ; xmm6=[col4 col5]=(04 14 24 34 05 15 25 35)
- punpckhdq xmm3, xmm7 ; xmm3=[col6 col7]=(06 16 26 36 07 17 27 37)
-.column_end:
-
- ; -- Prefetch the next coefficient block
-
- prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 0*32]
- prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 1*32]
- prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 2*32]
- prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 3*32]
-
- ; ---- Pass 2: process rows, store into output array.
-
- mov eax, [original_ebp]
- mov edi, JSAMPARRAY [output_buf(eax)] ; (JSAMPROW *)
- mov eax, JDIMENSION [output_col(eax)]
-
- ; -- Even part
-
- pxor xmm4, xmm4
- punpcklwd xmm4, xmm1 ; xmm4=tmp0
- psrad xmm4, (16-CONST_BITS-1) ; psrad xmm4,16 & pslld xmm4,CONST_BITS+1
-
- ; -- Odd part
-
- punpckhwd xmm1, xmm0
- punpckhwd xmm6, xmm3
- movdqa xmm5, xmm1
- movdqa xmm2, xmm6
- pmaddwd xmm1, [GOTOFF(ebx,PW_F256_F089)] ; xmm1=(tmp2)
- pmaddwd xmm6, [GOTOFF(ebx,PW_MF060_MF050)] ; xmm6=(tmp2)
- pmaddwd xmm5, [GOTOFF(ebx,PW_F106_MF217)] ; xmm5=(tmp0)
- pmaddwd xmm2, [GOTOFF(ebx,PW_F145_MF021)] ; xmm2=(tmp0)
-
- paddd xmm6, xmm1 ; xmm6=tmp2
- paddd xmm2, xmm5 ; xmm2=tmp0
-
- ; -- Even part
-
- punpcklwd xmm0, xmm3
- pmaddwd xmm0, [GOTOFF(ebx,PW_F184_MF076)] ; xmm0=tmp2
-
- movdqa xmm7, xmm4
- paddd xmm4, xmm0 ; xmm4=tmp10
- psubd xmm7, xmm0 ; xmm7=tmp12
-
- ; -- Final output stage
-
- movdqa xmm1, [GOTOFF(ebx,PD_DESCALE_P2_4)] ; xmm1=[PD_DESCALE_P2_4]
-
- movdqa xmm5, xmm4
- movdqa xmm3, xmm7
- paddd xmm4, xmm6 ; xmm4=data0=(00 10 20 30)
- paddd xmm7, xmm2 ; xmm7=data1=(01 11 21 31)
- psubd xmm5, xmm6 ; xmm5=data3=(03 13 23 33)
- psubd xmm3, xmm2 ; xmm3=data2=(02 12 22 32)
-
- paddd xmm4, xmm1
- paddd xmm7, xmm1
- psrad xmm4, DESCALE_P2_4
- psrad xmm7, DESCALE_P2_4
- paddd xmm5, xmm1
- paddd xmm3, xmm1
- psrad xmm5, DESCALE_P2_4
- psrad xmm3, DESCALE_P2_4
-
- packssdw xmm4, xmm3 ; xmm4=(00 10 20 30 02 12 22 32)
- packssdw xmm7, xmm5 ; xmm7=(01 11 21 31 03 13 23 33)
-
- movdqa xmm0, xmm4 ; transpose coefficients(phase 1)
- punpcklwd xmm4, xmm7 ; xmm4=(00 01 10 11 20 21 30 31)
- punpckhwd xmm0, xmm7 ; xmm0=(02 03 12 13 22 23 32 33)
-
- movdqa xmm6, xmm4 ; transpose coefficients(phase 2)
- punpckldq xmm4, xmm0 ; xmm4=(00 01 02 03 10 11 12 13)
- punpckhdq xmm6, xmm0 ; xmm6=(20 21 22 23 30 31 32 33)
-
- packsswb xmm4, xmm6 ; xmm4=(00 01 02 03 10 11 12 13 20 ..)
- paddb xmm4, [GOTOFF(ebx,PB_CENTERJSAMP)]
-
- pshufd xmm2, xmm4, 0x39 ; xmm2=(10 11 12 13 20 21 22 23 30 ..)
- pshufd xmm1, xmm4, 0x4E ; xmm1=(20 21 22 23 30 31 32 33 00 ..)
- pshufd xmm3, xmm4, 0x93 ; xmm3=(30 31 32 33 00 01 02 03 10 ..)
-
- mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW]
- mov esi, JSAMPROW [edi+1*SIZEOF_JSAMPROW]
- movd XMM_DWORD [edx+eax*SIZEOF_JSAMPLE], xmm4
- movd XMM_DWORD [esi+eax*SIZEOF_JSAMPLE], xmm2
- mov edx, JSAMPROW [edi+2*SIZEOF_JSAMPROW]
- mov esi, JSAMPROW [edi+3*SIZEOF_JSAMPROW]
- movd XMM_DWORD [edx+eax*SIZEOF_JSAMPLE], xmm1
- movd XMM_DWORD [esi+eax*SIZEOF_JSAMPLE], xmm3
-
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; unused
- poppic ebx
- mov esp, ebp ; esp <- aligned ebp
- pop esp ; esp <- original ebp
- pop ebp
- ret
-
-; --------------------------------------------------------------------------
-;
-; Perform dequantization and inverse DCT on one block of coefficients,
-; producing a reduced-size 2x2 output block.
-;
-; GLOBAL(void)
-; jsimd_idct_2x2_sse2(void *dct_table, JCOEFPTR coef_block,
-; JSAMPARRAY output_buf, JDIMENSION output_col)
-;
-
-%define dct_table(b) (b) + 8 ; void *dct_table
-%define coef_block(b) (b) + 12 ; JCOEFPTR coef_block
-%define output_buf(b) (b) + 16 ; JSAMPARRAY output_buf
-%define output_col(b) (b) + 20 ; JDIMENSION output_col
-
- align 32
- GLOBAL_FUNCTION(jsimd_idct_2x2_sse2)
-
-EXTN(jsimd_idct_2x2_sse2):
- push ebp
- mov ebp, esp
- push ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- get_GOT ebx ; get GOT address
-
- ; ---- Pass 1: process columns from input.
-
- mov edx, POINTER [dct_table(ebp)] ; quantptr
- mov esi, JCOEFPTR [coef_block(ebp)] ; inptr
-
- ; | input: | result: |
- ; | 00 01 ** 03 ** 05 ** 07 | |
- ; | 10 11 ** 13 ** 15 ** 17 | |
- ; | ** ** ** ** ** ** ** ** | |
- ; | 30 31 ** 33 ** 35 ** 37 | A0 A1 A3 A5 A7 |
- ; | ** ** ** ** ** ** ** ** | B0 B1 B3 B5 B7 |
- ; | 50 51 ** 53 ** 55 ** 57 | |
- ; | ** ** ** ** ** ** ** ** | |
- ; | 70 71 ** 73 ** 75 ** 77 | |
-
- ; -- Odd part
-
- movdqa xmm0, XMMWORD [XMMBLOCK(1,0,esi,SIZEOF_JCOEF)]
- movdqa xmm1, XMMWORD [XMMBLOCK(3,0,esi,SIZEOF_JCOEF)]
- pmullw xmm0, XMMWORD [XMMBLOCK(1,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
- pmullw xmm1, XMMWORD [XMMBLOCK(3,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
- movdqa xmm2, XMMWORD [XMMBLOCK(5,0,esi,SIZEOF_JCOEF)]
- movdqa xmm3, XMMWORD [XMMBLOCK(7,0,esi,SIZEOF_JCOEF)]
- pmullw xmm2, XMMWORD [XMMBLOCK(5,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
- pmullw xmm3, XMMWORD [XMMBLOCK(7,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
-
- ; xmm0=(10 11 ** 13 ** 15 ** 17), xmm1=(30 31 ** 33 ** 35 ** 37)
- ; xmm2=(50 51 ** 53 ** 55 ** 57), xmm3=(70 71 ** 73 ** 75 ** 77)
-
- pcmpeqd xmm7, xmm7
- pslld xmm7, WORD_BIT ; xmm7={0x0000 0xFFFF 0x0000 0xFFFF ..}
-
- movdqa xmm4, xmm0 ; xmm4=(10 11 ** 13 ** 15 ** 17)
- movdqa xmm5, xmm2 ; xmm5=(50 51 ** 53 ** 55 ** 57)
- punpcklwd xmm4, xmm1 ; xmm4=(10 30 11 31 ** ** 13 33)
- punpcklwd xmm5, xmm3 ; xmm5=(50 70 51 71 ** ** 53 73)
- pmaddwd xmm4, [GOTOFF(ebx,PW_F362_MF127)]
- pmaddwd xmm5, [GOTOFF(ebx,PW_F085_MF072)]
-
- psrld xmm0, WORD_BIT ; xmm0=(11 -- 13 -- 15 -- 17 --)
- pand xmm1, xmm7 ; xmm1=(-- 31 -- 33 -- 35 -- 37)
- psrld xmm2, WORD_BIT ; xmm2=(51 -- 53 -- 55 -- 57 --)
- pand xmm3, xmm7 ; xmm3=(-- 71 -- 73 -- 75 -- 77)
- por xmm0, xmm1 ; xmm0=(11 31 13 33 15 35 17 37)
- por xmm2, xmm3 ; xmm2=(51 71 53 73 55 75 57 77)
- pmaddwd xmm0, [GOTOFF(ebx,PW_F362_MF127)]
- pmaddwd xmm2, [GOTOFF(ebx,PW_F085_MF072)]
-
- paddd xmm4, xmm5 ; xmm4=tmp0[col0 col1 **** col3]
- paddd xmm0, xmm2 ; xmm0=tmp0[col1 col3 col5 col7]
-
- ; -- Even part
-
- movdqa xmm6, XMMWORD [XMMBLOCK(0,0,esi,SIZEOF_JCOEF)]
- pmullw xmm6, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
-
- ; xmm6=(00 01 ** 03 ** 05 ** 07)
-
- movdqa xmm1, xmm6 ; xmm1=(00 01 ** 03 ** 05 ** 07)
- pslld xmm6, WORD_BIT ; xmm6=(-- 00 -- ** -- ** -- **)
- pand xmm1, xmm7 ; xmm1=(-- 01 -- 03 -- 05 -- 07)
- psrad xmm6, (WORD_BIT-CONST_BITS-2) ; xmm6=tmp10[col0 **** **** ****]
- psrad xmm1, (WORD_BIT-CONST_BITS-2) ; xmm1=tmp10[col1 col3 col5 col7]
-
- ; -- Final output stage
-
- movdqa xmm3, xmm6
- movdqa xmm5, xmm1
- paddd xmm6, xmm4 ; xmm6=data0[col0 **** **** ****]=(A0 ** ** **)
- paddd xmm1, xmm0 ; xmm1=data0[col1 col3 col5 col7]=(A1 A3 A5 A7)
- psubd xmm3, xmm4 ; xmm3=data1[col0 **** **** ****]=(B0 ** ** **)
- psubd xmm5, xmm0 ; xmm5=data1[col1 col3 col5 col7]=(B1 B3 B5 B7)
-
- movdqa xmm2, [GOTOFF(ebx,PD_DESCALE_P1_2)] ; xmm2=[PD_DESCALE_P1_2]
-
- punpckldq xmm6, xmm3 ; xmm6=(A0 B0 ** **)
-
- movdqa xmm7, xmm1
- punpcklqdq xmm1, xmm5 ; xmm1=(A1 A3 B1 B3)
- punpckhqdq xmm7, xmm5 ; xmm7=(A5 A7 B5 B7)
-
- paddd xmm6, xmm2
- psrad xmm6, DESCALE_P1_2
-
- paddd xmm1, xmm2
- paddd xmm7, xmm2
- psrad xmm1, DESCALE_P1_2
- psrad xmm7, DESCALE_P1_2
-
- ; -- Prefetch the next coefficient block
-
- prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 0*32]
- prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 1*32]
- prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 2*32]
- prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 3*32]
-
- ; ---- Pass 2: process rows, store into output array.
-
- mov edi, JSAMPARRAY [output_buf(ebp)] ; (JSAMPROW *)
- mov eax, JDIMENSION [output_col(ebp)]
-
- ; | input:| result:|
- ; | A0 B0 | |
- ; | A1 B1 | C0 C1 |
- ; | A3 B3 | D0 D1 |
- ; | A5 B5 | |
- ; | A7 B7 | |
-
- ; -- Odd part
-
- packssdw xmm1, xmm1 ; xmm1=(A1 A3 B1 B3 A1 A3 B1 B3)
- packssdw xmm7, xmm7 ; xmm7=(A5 A7 B5 B7 A5 A7 B5 B7)
- pmaddwd xmm1, [GOTOFF(ebx,PW_F362_MF127)]
- pmaddwd xmm7, [GOTOFF(ebx,PW_F085_MF072)]
-
- paddd xmm1, xmm7 ; xmm1=tmp0[row0 row1 row0 row1]
-
- ; -- Even part
-
- pslld xmm6, (CONST_BITS+2) ; xmm6=tmp10[row0 row1 **** ****]
-
- ; -- Final output stage
-
- movdqa xmm4, xmm6
- paddd xmm6, xmm1 ; xmm6=data0[row0 row1 **** ****]=(C0 C1 ** **)
- psubd xmm4, xmm1 ; xmm4=data1[row0 row1 **** ****]=(D0 D1 ** **)
-
- punpckldq xmm6, xmm4 ; xmm6=(C0 D0 C1 D1)
-
- paddd xmm6, [GOTOFF(ebx,PD_DESCALE_P2_2)]
- psrad xmm6, DESCALE_P2_2
-
- packssdw xmm6, xmm6 ; xmm6=(C0 D0 C1 D1 C0 D0 C1 D1)
- packsswb xmm6, xmm6 ; xmm6=(C0 D0 C1 D1 C0 D0 C1 D1 ..)
- paddb xmm6, [GOTOFF(ebx,PB_CENTERJSAMP)]
-
- pextrw ebx, xmm6, 0x00 ; ebx=(C0 D0 -- --)
- pextrw ecx, xmm6, 0x01 ; ecx=(C1 D1 -- --)
-
- mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW]
- mov esi, JSAMPROW [edi+1*SIZEOF_JSAMPROW]
- mov word [edx+eax*SIZEOF_JSAMPLE], bx
- mov word [esi+eax*SIZEOF_JSAMPLE], cx
-
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- pop ebx
- pop ebp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jquant-3dn.asm b/contrib/libs/libjpeg-turbo/simd/i386/jquant-3dn.asm
deleted file mode 100644
index 5cb60caa94..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jquant-3dn.asm
+++ /dev/null
@@ -1,230 +0,0 @@
-;
-; jquant.asm - sample data conversion and quantization (3DNow! & MMX)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jsimdext.inc"
-%include "jdct.inc"
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-;
-; Load data into workspace, applying unsigned->signed conversion
-;
-; GLOBAL(void)
-; jsimd_convsamp_float_3dnow(JSAMPARRAY sample_data, JDIMENSION start_col,
-; FAST_FLOAT *workspace);
-;
-
-%define sample_data ebp + 8 ; JSAMPARRAY sample_data
-%define start_col ebp + 12 ; JDIMENSION start_col
-%define workspace ebp + 16 ; FAST_FLOAT *workspace
-
- align 32
- GLOBAL_FUNCTION(jsimd_convsamp_float_3dnow)
-
-EXTN(jsimd_convsamp_float_3dnow):
- push ebp
- mov ebp, esp
- push ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- pcmpeqw mm7, mm7
- psllw mm7, 7
- packsswb mm7, mm7 ; mm7 = PB_CENTERJSAMPLE (0x808080..)
-
- mov esi, JSAMPARRAY [sample_data] ; (JSAMPROW *)
- mov eax, JDIMENSION [start_col]
- mov edi, POINTER [workspace] ; (DCTELEM *)
- mov ecx, DCTSIZE/2
- alignx 16, 7
-.convloop:
- mov ebx, JSAMPROW [esi+0*SIZEOF_JSAMPROW] ; (JSAMPLE *)
- mov edx, JSAMPROW [esi+1*SIZEOF_JSAMPROW] ; (JSAMPLE *)
-
- movq mm0, MMWORD [ebx+eax*SIZEOF_JSAMPLE]
- movq mm1, MMWORD [edx+eax*SIZEOF_JSAMPLE]
-
- psubb mm0, mm7 ; mm0=(01234567)
- psubb mm1, mm7 ; mm1=(89ABCDEF)
-
- punpcklbw mm2, mm0 ; mm2=(*0*1*2*3)
- punpckhbw mm0, mm0 ; mm0=(*4*5*6*7)
- punpcklbw mm3, mm1 ; mm3=(*8*9*A*B)
- punpckhbw mm1, mm1 ; mm1=(*C*D*E*F)
-
- punpcklwd mm4, mm2 ; mm4=(***0***1)
- punpckhwd mm2, mm2 ; mm2=(***2***3)
- punpcklwd mm5, mm0 ; mm5=(***4***5)
- punpckhwd mm0, mm0 ; mm0=(***6***7)
-
- psrad mm4, (DWORD_BIT-BYTE_BIT) ; mm4=(01)
- psrad mm2, (DWORD_BIT-BYTE_BIT) ; mm2=(23)
- pi2fd mm4, mm4
- pi2fd mm2, mm2
- psrad mm5, (DWORD_BIT-BYTE_BIT) ; mm5=(45)
- psrad mm0, (DWORD_BIT-BYTE_BIT) ; mm0=(67)
- pi2fd mm5, mm5
- pi2fd mm0, mm0
-
- movq MMWORD [MMBLOCK(0,0,edi,SIZEOF_FAST_FLOAT)], mm4
- movq MMWORD [MMBLOCK(0,1,edi,SIZEOF_FAST_FLOAT)], mm2
- movq MMWORD [MMBLOCK(0,2,edi,SIZEOF_FAST_FLOAT)], mm5
- movq MMWORD [MMBLOCK(0,3,edi,SIZEOF_FAST_FLOAT)], mm0
-
- punpcklwd mm6, mm3 ; mm6=(***8***9)
- punpckhwd mm3, mm3 ; mm3=(***A***B)
- punpcklwd mm4, mm1 ; mm4=(***C***D)
- punpckhwd mm1, mm1 ; mm1=(***E***F)
-
- psrad mm6, (DWORD_BIT-BYTE_BIT) ; mm6=(89)
- psrad mm3, (DWORD_BIT-BYTE_BIT) ; mm3=(AB)
- pi2fd mm6, mm6
- pi2fd mm3, mm3
- psrad mm4, (DWORD_BIT-BYTE_BIT) ; mm4=(CD)
- psrad mm1, (DWORD_BIT-BYTE_BIT) ; mm1=(EF)
- pi2fd mm4, mm4
- pi2fd mm1, mm1
-
- movq MMWORD [MMBLOCK(1,0,edi,SIZEOF_FAST_FLOAT)], mm6
- movq MMWORD [MMBLOCK(1,1,edi,SIZEOF_FAST_FLOAT)], mm3
- movq MMWORD [MMBLOCK(1,2,edi,SIZEOF_FAST_FLOAT)], mm4
- movq MMWORD [MMBLOCK(1,3,edi,SIZEOF_FAST_FLOAT)], mm1
-
- add esi, byte 2*SIZEOF_JSAMPROW
- add edi, byte 2*DCTSIZE*SIZEOF_FAST_FLOAT
- dec ecx
- jnz near .convloop
-
- femms ; empty MMX/3DNow! state
-
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- pop ebx
- pop ebp
- ret
-
-; --------------------------------------------------------------------------
-;
-; Quantize/descale the coefficients, and store into coef_block
-;
-; GLOBAL(void)
-; jsimd_quantize_float_3dnow(JCOEFPTR coef_block, FAST_FLOAT *divisors,
-; FAST_FLOAT *workspace);
-;
-
-%define coef_block ebp + 8 ; JCOEFPTR coef_block
-%define divisors ebp + 12 ; FAST_FLOAT *divisors
-%define workspace ebp + 16 ; FAST_FLOAT *workspace
-
- align 32
- GLOBAL_FUNCTION(jsimd_quantize_float_3dnow)
-
-EXTN(jsimd_quantize_float_3dnow):
- push ebp
- mov ebp, esp
-; push ebx ; unused
-; push ecx ; unused
-; push edx ; need not be preserved
- push esi
- push edi
-
- mov eax, 0x4B400000 ; (float)0x00C00000 (rndint_magic)
- movd mm7, eax
- punpckldq mm7, mm7 ; mm7={12582912.0F 12582912.0F}
-
- mov esi, POINTER [workspace]
- mov edx, POINTER [divisors]
- mov edi, JCOEFPTR [coef_block]
- mov eax, DCTSIZE2/16
- alignx 16, 7
-.quantloop:
- movq mm0, MMWORD [MMBLOCK(0,0,esi,SIZEOF_FAST_FLOAT)]
- movq mm1, MMWORD [MMBLOCK(0,1,esi,SIZEOF_FAST_FLOAT)]
- pfmul mm0, MMWORD [MMBLOCK(0,0,edx,SIZEOF_FAST_FLOAT)]
- pfmul mm1, MMWORD [MMBLOCK(0,1,edx,SIZEOF_FAST_FLOAT)]
- movq mm2, MMWORD [MMBLOCK(0,2,esi,SIZEOF_FAST_FLOAT)]
- movq mm3, MMWORD [MMBLOCK(0,3,esi,SIZEOF_FAST_FLOAT)]
- pfmul mm2, MMWORD [MMBLOCK(0,2,edx,SIZEOF_FAST_FLOAT)]
- pfmul mm3, MMWORD [MMBLOCK(0,3,edx,SIZEOF_FAST_FLOAT)]
-
- pfadd mm0, mm7 ; mm0=(00 ** 01 **)
- pfadd mm1, mm7 ; mm1=(02 ** 03 **)
- pfadd mm2, mm7 ; mm0=(04 ** 05 **)
- pfadd mm3, mm7 ; mm1=(06 ** 07 **)
-
- movq mm4, mm0
- punpcklwd mm0, mm1 ; mm0=(00 02 ** **)
- punpckhwd mm4, mm1 ; mm4=(01 03 ** **)
- movq mm5, mm2
- punpcklwd mm2, mm3 ; mm2=(04 06 ** **)
- punpckhwd mm5, mm3 ; mm5=(05 07 ** **)
-
- punpcklwd mm0, mm4 ; mm0=(00 01 02 03)
- punpcklwd mm2, mm5 ; mm2=(04 05 06 07)
-
- movq mm6, MMWORD [MMBLOCK(1,0,esi,SIZEOF_FAST_FLOAT)]
- movq mm1, MMWORD [MMBLOCK(1,1,esi,SIZEOF_FAST_FLOAT)]
- pfmul mm6, MMWORD [MMBLOCK(1,0,edx,SIZEOF_FAST_FLOAT)]
- pfmul mm1, MMWORD [MMBLOCK(1,1,edx,SIZEOF_FAST_FLOAT)]
- movq mm3, MMWORD [MMBLOCK(1,2,esi,SIZEOF_FAST_FLOAT)]
- movq mm4, MMWORD [MMBLOCK(1,3,esi,SIZEOF_FAST_FLOAT)]
- pfmul mm3, MMWORD [MMBLOCK(1,2,edx,SIZEOF_FAST_FLOAT)]
- pfmul mm4, MMWORD [MMBLOCK(1,3,edx,SIZEOF_FAST_FLOAT)]
-
- pfadd mm6, mm7 ; mm0=(10 ** 11 **)
- pfadd mm1, mm7 ; mm4=(12 ** 13 **)
- pfadd mm3, mm7 ; mm0=(14 ** 15 **)
- pfadd mm4, mm7 ; mm4=(16 ** 17 **)
-
- movq mm5, mm6
- punpcklwd mm6, mm1 ; mm6=(10 12 ** **)
- punpckhwd mm5, mm1 ; mm5=(11 13 ** **)
- movq mm1, mm3
- punpcklwd mm3, mm4 ; mm3=(14 16 ** **)
- punpckhwd mm1, mm4 ; mm1=(15 17 ** **)
-
- punpcklwd mm6, mm5 ; mm6=(10 11 12 13)
- punpcklwd mm3, mm1 ; mm3=(14 15 16 17)
-
- movq MMWORD [MMBLOCK(0,0,edi,SIZEOF_JCOEF)], mm0
- movq MMWORD [MMBLOCK(0,1,edi,SIZEOF_JCOEF)], mm2
- movq MMWORD [MMBLOCK(1,0,edi,SIZEOF_JCOEF)], mm6
- movq MMWORD [MMBLOCK(1,1,edi,SIZEOF_JCOEF)], mm3
-
- add esi, byte 16*SIZEOF_FAST_FLOAT
- add edx, byte 16*SIZEOF_FAST_FLOAT
- add edi, byte 16*SIZEOF_JCOEF
- dec eax
- jnz near .quantloop
-
- femms ; empty MMX/3DNow! state
-
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; unused
-; pop ebx ; unused
- pop ebp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jquant-mmx.asm b/contrib/libs/libjpeg-turbo/simd/i386/jquant-mmx.asm
deleted file mode 100644
index 61305c625d..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jquant-mmx.asm
+++ /dev/null
@@ -1,276 +0,0 @@
-;
-; jquant.asm - sample data conversion and quantization (MMX)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jsimdext.inc"
-%include "jdct.inc"
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-;
-; Load data into workspace, applying unsigned->signed conversion
-;
-; GLOBAL(void)
-; jsimd_convsamp_mmx(JSAMPARRAY sample_data, JDIMENSION start_col,
-; DCTELEM *workspace);
-;
-
-%define sample_data ebp + 8 ; JSAMPARRAY sample_data
-%define start_col ebp + 12 ; JDIMENSION start_col
-%define workspace ebp + 16 ; DCTELEM *workspace
-
- align 32
- GLOBAL_FUNCTION(jsimd_convsamp_mmx)
-
-EXTN(jsimd_convsamp_mmx):
- push ebp
- mov ebp, esp
- push ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- pxor mm6, mm6 ; mm6=(all 0's)
- pcmpeqw mm7, mm7
- psllw mm7, 7 ; mm7={0xFF80 0xFF80 0xFF80 0xFF80}
-
- mov esi, JSAMPARRAY [sample_data] ; (JSAMPROW *)
- mov eax, JDIMENSION [start_col]
- mov edi, POINTER [workspace] ; (DCTELEM *)
- mov ecx, DCTSIZE/4
- alignx 16, 7
-.convloop:
- mov ebx, JSAMPROW [esi+0*SIZEOF_JSAMPROW] ; (JSAMPLE *)
- mov edx, JSAMPROW [esi+1*SIZEOF_JSAMPROW] ; (JSAMPLE *)
-
- movq mm0, MMWORD [ebx+eax*SIZEOF_JSAMPLE] ; mm0=(01234567)
- movq mm1, MMWORD [edx+eax*SIZEOF_JSAMPLE] ; mm1=(89ABCDEF)
-
- mov ebx, JSAMPROW [esi+2*SIZEOF_JSAMPROW] ; (JSAMPLE *)
- mov edx, JSAMPROW [esi+3*SIZEOF_JSAMPROW] ; (JSAMPLE *)
-
- movq mm2, MMWORD [ebx+eax*SIZEOF_JSAMPLE] ; mm2=(GHIJKLMN)
- movq mm3, MMWORD [edx+eax*SIZEOF_JSAMPLE] ; mm3=(OPQRSTUV)
-
- movq mm4, mm0
- punpcklbw mm0, mm6 ; mm0=(0123)
- punpckhbw mm4, mm6 ; mm4=(4567)
- movq mm5, mm1
- punpcklbw mm1, mm6 ; mm1=(89AB)
- punpckhbw mm5, mm6 ; mm5=(CDEF)
-
- paddw mm0, mm7
- paddw mm4, mm7
- paddw mm1, mm7
- paddw mm5, mm7
-
- movq MMWORD [MMBLOCK(0,0,edi,SIZEOF_DCTELEM)], mm0
- movq MMWORD [MMBLOCK(0,1,edi,SIZEOF_DCTELEM)], mm4
- movq MMWORD [MMBLOCK(1,0,edi,SIZEOF_DCTELEM)], mm1
- movq MMWORD [MMBLOCK(1,1,edi,SIZEOF_DCTELEM)], mm5
-
- movq mm0, mm2
- punpcklbw mm2, mm6 ; mm2=(GHIJ)
- punpckhbw mm0, mm6 ; mm0=(KLMN)
- movq mm4, mm3
- punpcklbw mm3, mm6 ; mm3=(OPQR)
- punpckhbw mm4, mm6 ; mm4=(STUV)
-
- paddw mm2, mm7
- paddw mm0, mm7
- paddw mm3, mm7
- paddw mm4, mm7
-
- movq MMWORD [MMBLOCK(2,0,edi,SIZEOF_DCTELEM)], mm2
- movq MMWORD [MMBLOCK(2,1,edi,SIZEOF_DCTELEM)], mm0
- movq MMWORD [MMBLOCK(3,0,edi,SIZEOF_DCTELEM)], mm3
- movq MMWORD [MMBLOCK(3,1,edi,SIZEOF_DCTELEM)], mm4
-
- add esi, byte 4*SIZEOF_JSAMPROW
- add edi, byte 4*DCTSIZE*SIZEOF_DCTELEM
- dec ecx
- jnz short .convloop
-
- emms ; empty MMX state
-
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- pop ebx
- pop ebp
- ret
-
-; --------------------------------------------------------------------------
-;
-; Quantize/descale the coefficients, and store into coef_block
-;
-; This implementation is based on an algorithm described in
-; "How to optimize for the Pentium family of microprocessors"
-; (http://www.agner.org/assem/).
-;
-; GLOBAL(void)
-; jsimd_quantize_mmx(JCOEFPTR coef_block, DCTELEM *divisors,
-; DCTELEM *workspace);
-;
-
-%define RECIPROCAL(m, n, b) \
- MMBLOCK(DCTSIZE * 0 + (m), (n), (b), SIZEOF_DCTELEM)
-%define CORRECTION(m, n, b) \
- MMBLOCK(DCTSIZE * 1 + (m), (n), (b), SIZEOF_DCTELEM)
-%define SCALE(m, n, b) \
- MMBLOCK(DCTSIZE * 2 + (m), (n), (b), SIZEOF_DCTELEM)
-%define SHIFT(m, n, b) \
- MMBLOCK(DCTSIZE * 3 + (m), (n), (b), SIZEOF_DCTELEM)
-
-%define coef_block ebp + 8 ; JCOEFPTR coef_block
-%define divisors ebp + 12 ; DCTELEM *divisors
-%define workspace ebp + 16 ; DCTELEM *workspace
-
- align 32
- GLOBAL_FUNCTION(jsimd_quantize_mmx)
-
-EXTN(jsimd_quantize_mmx):
- push ebp
- mov ebp, esp
-; push ebx ; unused
-; push ecx ; unused
-; push edx ; need not be preserved
- push esi
- push edi
-
- mov esi, POINTER [workspace]
- mov edx, POINTER [divisors]
- mov edi, JCOEFPTR [coef_block]
- mov ah, 2
- alignx 16, 7
-.quantloop1:
- mov al, DCTSIZE2/8/2
- alignx 16, 7
-.quantloop2:
- movq mm2, MMWORD [MMBLOCK(0,0,esi,SIZEOF_DCTELEM)]
- movq mm3, MMWORD [MMBLOCK(0,1,esi,SIZEOF_DCTELEM)]
-
- movq mm0, mm2
- movq mm1, mm3
-
- psraw mm2, (WORD_BIT-1) ; -1 if value < 0, 0 otherwise
- psraw mm3, (WORD_BIT-1)
-
- pxor mm0, mm2 ; val = -val
- pxor mm1, mm3
- psubw mm0, mm2
- psubw mm1, mm3
-
- ;
- ; MMX is an annoyingly crappy instruction set. It has two
- ; misfeatures that are causing problems here:
- ;
- ; - All multiplications are signed.
- ;
- ; - The second operand for the shifts is not treated as packed.
- ;
- ;
- ; We work around the first problem by implementing this algorithm:
- ;
- ; unsigned long unsigned_multiply(unsigned short x, unsigned short y)
- ; {
- ; enum { SHORT_BIT = 16 };
- ; signed short sx = (signed short)x;
- ; signed short sy = (signed short)y;
- ; signed long sz;
- ;
- ; sz = (long)sx * (long)sy; /* signed multiply */
- ;
- ; if (sx < 0) sz += (long)sy << SHORT_BIT;
- ; if (sy < 0) sz += (long)sx << SHORT_BIT;
- ;
- ; return (unsigned long)sz;
- ; }
- ;
- ; (note that a negative sx adds _sy_ and vice versa)
- ;
- ; For the second problem, we replace the shift by a multiplication.
- ; Unfortunately that means we have to deal with the signed issue again.
- ;
-
- paddw mm0, MMWORD [CORRECTION(0,0,edx)] ; correction + roundfactor
- paddw mm1, MMWORD [CORRECTION(0,1,edx)]
-
- movq mm4, mm0 ; store current value for later
- movq mm5, mm1
- pmulhw mm0, MMWORD [RECIPROCAL(0,0,edx)] ; reciprocal
- pmulhw mm1, MMWORD [RECIPROCAL(0,1,edx)]
- paddw mm0, mm4 ; reciprocal is always negative (MSB=1),
- paddw mm1, mm5 ; so we always need to add the initial value
- ; (input value is never negative as we
- ; inverted it at the start of this routine)
-
- ; here it gets a bit tricky as both scale
- ; and mm0/mm1 can be negative
- movq mm6, MMWORD [SCALE(0,0,edx)] ; scale
- movq mm7, MMWORD [SCALE(0,1,edx)]
- movq mm4, mm0
- movq mm5, mm1
- pmulhw mm0, mm6
- pmulhw mm1, mm7
-
- psraw mm6, (WORD_BIT-1) ; determine if scale is negative
- psraw mm7, (WORD_BIT-1)
-
- pand mm6, mm4 ; and add input if it is
- pand mm7, mm5
- paddw mm0, mm6
- paddw mm1, mm7
-
- psraw mm4, (WORD_BIT-1) ; then check if negative input
- psraw mm5, (WORD_BIT-1)
-
- pand mm4, MMWORD [SCALE(0,0,edx)] ; and add scale if it is
- pand mm5, MMWORD [SCALE(0,1,edx)]
- paddw mm0, mm4
- paddw mm1, mm5
-
- pxor mm0, mm2 ; val = -val
- pxor mm1, mm3
- psubw mm0, mm2
- psubw mm1, mm3
-
- movq MMWORD [MMBLOCK(0,0,edi,SIZEOF_DCTELEM)], mm0
- movq MMWORD [MMBLOCK(0,1,edi,SIZEOF_DCTELEM)], mm1
-
- add esi, byte 8*SIZEOF_DCTELEM
- add edx, byte 8*SIZEOF_DCTELEM
- add edi, byte 8*SIZEOF_JCOEF
- dec al
- jnz near .quantloop2
- dec ah
- jnz near .quantloop1 ; to avoid branch misprediction
-
- emms ; empty MMX state
-
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; unused
-; pop ebx ; unused
- pop ebp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jquant-sse.asm b/contrib/libs/libjpeg-turbo/simd/i386/jquant-sse.asm
deleted file mode 100644
index 218adc976f..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jquant-sse.asm
+++ /dev/null
@@ -1,208 +0,0 @@
-;
-; jquant.asm - sample data conversion and quantization (SSE & MMX)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jsimdext.inc"
-%include "jdct.inc"
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-;
-; Load data into workspace, applying unsigned->signed conversion
-;
-; GLOBAL(void)
-; jsimd_convsamp_float_sse(JSAMPARRAY sample_data, JDIMENSION start_col,
-; FAST_FLOAT *workspace);
-;
-
-%define sample_data ebp + 8 ; JSAMPARRAY sample_data
-%define start_col ebp + 12 ; JDIMENSION start_col
-%define workspace ebp + 16 ; FAST_FLOAT *workspace
-
- align 32
- GLOBAL_FUNCTION(jsimd_convsamp_float_sse)
-
-EXTN(jsimd_convsamp_float_sse):
- push ebp
- mov ebp, esp
- push ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- pcmpeqw mm7, mm7
- psllw mm7, 7
- packsswb mm7, mm7 ; mm7 = PB_CENTERJSAMPLE (0x808080..)
-
- mov esi, JSAMPARRAY [sample_data] ; (JSAMPROW *)
- mov eax, JDIMENSION [start_col]
- mov edi, POINTER [workspace] ; (DCTELEM *)
- mov ecx, DCTSIZE/2
- alignx 16, 7
-.convloop:
- mov ebx, JSAMPROW [esi+0*SIZEOF_JSAMPROW] ; (JSAMPLE *)
- mov edx, JSAMPROW [esi+1*SIZEOF_JSAMPROW] ; (JSAMPLE *)
-
- movq mm0, MMWORD [ebx+eax*SIZEOF_JSAMPLE]
- movq mm1, MMWORD [edx+eax*SIZEOF_JSAMPLE]
-
- psubb mm0, mm7 ; mm0=(01234567)
- psubb mm1, mm7 ; mm1=(89ABCDEF)
-
- punpcklbw mm2, mm0 ; mm2=(*0*1*2*3)
- punpckhbw mm0, mm0 ; mm0=(*4*5*6*7)
- punpcklbw mm3, mm1 ; mm3=(*8*9*A*B)
- punpckhbw mm1, mm1 ; mm1=(*C*D*E*F)
-
- punpcklwd mm4, mm2 ; mm4=(***0***1)
- punpckhwd mm2, mm2 ; mm2=(***2***3)
- punpcklwd mm5, mm0 ; mm5=(***4***5)
- punpckhwd mm0, mm0 ; mm0=(***6***7)
-
- psrad mm4, (DWORD_BIT-BYTE_BIT) ; mm4=(01)
- psrad mm2, (DWORD_BIT-BYTE_BIT) ; mm2=(23)
- cvtpi2ps xmm0, mm4 ; xmm0=(01**)
- cvtpi2ps xmm1, mm2 ; xmm1=(23**)
- psrad mm5, (DWORD_BIT-BYTE_BIT) ; mm5=(45)
- psrad mm0, (DWORD_BIT-BYTE_BIT) ; mm0=(67)
- cvtpi2ps xmm2, mm5 ; xmm2=(45**)
- cvtpi2ps xmm3, mm0 ; xmm3=(67**)
-
- punpcklwd mm6, mm3 ; mm6=(***8***9)
- punpckhwd mm3, mm3 ; mm3=(***A***B)
- punpcklwd mm4, mm1 ; mm4=(***C***D)
- punpckhwd mm1, mm1 ; mm1=(***E***F)
-
- psrad mm6, (DWORD_BIT-BYTE_BIT) ; mm6=(89)
- psrad mm3, (DWORD_BIT-BYTE_BIT) ; mm3=(AB)
- cvtpi2ps xmm4, mm6 ; xmm4=(89**)
- cvtpi2ps xmm5, mm3 ; xmm5=(AB**)
- psrad mm4, (DWORD_BIT-BYTE_BIT) ; mm4=(CD)
- psrad mm1, (DWORD_BIT-BYTE_BIT) ; mm1=(EF)
- cvtpi2ps xmm6, mm4 ; xmm6=(CD**)
- cvtpi2ps xmm7, mm1 ; xmm7=(EF**)
-
- movlhps xmm0, xmm1 ; xmm0=(0123)
- movlhps xmm2, xmm3 ; xmm2=(4567)
- movlhps xmm4, xmm5 ; xmm4=(89AB)
- movlhps xmm6, xmm7 ; xmm6=(CDEF)
-
- movaps XMMWORD [XMMBLOCK(0,0,edi,SIZEOF_FAST_FLOAT)], xmm0
- movaps XMMWORD [XMMBLOCK(0,1,edi,SIZEOF_FAST_FLOAT)], xmm2
- movaps XMMWORD [XMMBLOCK(1,0,edi,SIZEOF_FAST_FLOAT)], xmm4
- movaps XMMWORD [XMMBLOCK(1,1,edi,SIZEOF_FAST_FLOAT)], xmm6
-
- add esi, byte 2*SIZEOF_JSAMPROW
- add edi, byte 2*DCTSIZE*SIZEOF_FAST_FLOAT
- dec ecx
- jnz near .convloop
-
- emms ; empty MMX state
-
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- pop ebx
- pop ebp
- ret
-
-; --------------------------------------------------------------------------
-;
-; Quantize/descale the coefficients, and store into coef_block
-;
-; GLOBAL(void)
-; jsimd_quantize_float_sse(JCOEFPTR coef_block, FAST_FLOAT *divisors,
-; FAST_FLOAT *workspace);
-;
-
-%define coef_block ebp + 8 ; JCOEFPTR coef_block
-%define divisors ebp + 12 ; FAST_FLOAT *divisors
-%define workspace ebp + 16 ; FAST_FLOAT *workspace
-
- align 32
- GLOBAL_FUNCTION(jsimd_quantize_float_sse)
-
-EXTN(jsimd_quantize_float_sse):
- push ebp
- mov ebp, esp
-; push ebx ; unused
-; push ecx ; unused
-; push edx ; need not be preserved
- push esi
- push edi
-
- mov esi, POINTER [workspace]
- mov edx, POINTER [divisors]
- mov edi, JCOEFPTR [coef_block]
- mov eax, DCTSIZE2/16
- alignx 16, 7
-.quantloop:
- movaps xmm0, XMMWORD [XMMBLOCK(0,0,esi,SIZEOF_FAST_FLOAT)]
- movaps xmm1, XMMWORD [XMMBLOCK(0,1,esi,SIZEOF_FAST_FLOAT)]
- mulps xmm0, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_FAST_FLOAT)]
- mulps xmm1, XMMWORD [XMMBLOCK(0,1,edx,SIZEOF_FAST_FLOAT)]
- movaps xmm2, XMMWORD [XMMBLOCK(1,0,esi,SIZEOF_FAST_FLOAT)]
- movaps xmm3, XMMWORD [XMMBLOCK(1,1,esi,SIZEOF_FAST_FLOAT)]
- mulps xmm2, XMMWORD [XMMBLOCK(1,0,edx,SIZEOF_FAST_FLOAT)]
- mulps xmm3, XMMWORD [XMMBLOCK(1,1,edx,SIZEOF_FAST_FLOAT)]
-
- movhlps xmm4, xmm0
- movhlps xmm5, xmm1
-
- cvtps2pi mm0, xmm0
- cvtps2pi mm1, xmm1
- cvtps2pi mm4, xmm4
- cvtps2pi mm5, xmm5
-
- movhlps xmm6, xmm2
- movhlps xmm7, xmm3
-
- cvtps2pi mm2, xmm2
- cvtps2pi mm3, xmm3
- cvtps2pi mm6, xmm6
- cvtps2pi mm7, xmm7
-
- packssdw mm0, mm4
- packssdw mm1, mm5
- packssdw mm2, mm6
- packssdw mm3, mm7
-
- movq MMWORD [MMBLOCK(0,0,edi,SIZEOF_JCOEF)], mm0
- movq MMWORD [MMBLOCK(0,1,edi,SIZEOF_JCOEF)], mm1
- movq MMWORD [MMBLOCK(1,0,edi,SIZEOF_JCOEF)], mm2
- movq MMWORD [MMBLOCK(1,1,edi,SIZEOF_JCOEF)], mm3
-
- add esi, byte 16*SIZEOF_FAST_FLOAT
- add edx, byte 16*SIZEOF_FAST_FLOAT
- add edi, byte 16*SIZEOF_JCOEF
- dec eax
- jnz short .quantloop
-
- emms ; empty MMX state
-
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; unused
-; pop ebx ; unused
- pop ebp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jquantf-sse2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jquantf-sse2.asm
deleted file mode 100644
index a881ab50f9..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jquantf-sse2.asm
+++ /dev/null
@@ -1,168 +0,0 @@
-;
-; jquantf.asm - sample data conversion and quantization (SSE & SSE2)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jsimdext.inc"
-%include "jdct.inc"
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-;
-; Load data into workspace, applying unsigned->signed conversion
-;
-; GLOBAL(void)
-; jsimd_convsamp_float_sse2(JSAMPARRAY sample_data, JDIMENSION start_col,
-; FAST_FLOAT *workspace);
-;
-
-%define sample_data ebp + 8 ; JSAMPARRAY sample_data
-%define start_col ebp + 12 ; JDIMENSION start_col
-%define workspace ebp + 16 ; FAST_FLOAT *workspace
-
- align 32
- GLOBAL_FUNCTION(jsimd_convsamp_float_sse2)
-
-EXTN(jsimd_convsamp_float_sse2):
- push ebp
- mov ebp, esp
- push ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- pcmpeqw xmm7, xmm7
- psllw xmm7, 7
- packsswb xmm7, xmm7 ; xmm7 = PB_CENTERJSAMPLE (0x808080..)
-
- mov esi, JSAMPARRAY [sample_data] ; (JSAMPROW *)
- mov eax, JDIMENSION [start_col]
- mov edi, POINTER [workspace] ; (DCTELEM *)
- mov ecx, DCTSIZE/2
- alignx 16, 7
-.convloop:
- mov ebx, JSAMPROW [esi+0*SIZEOF_JSAMPROW] ; (JSAMPLE *)
- mov edx, JSAMPROW [esi+1*SIZEOF_JSAMPROW] ; (JSAMPLE *)
-
- movq xmm0, XMM_MMWORD [ebx+eax*SIZEOF_JSAMPLE]
- movq xmm1, XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE]
-
- psubb xmm0, xmm7 ; xmm0=(01234567)
- psubb xmm1, xmm7 ; xmm1=(89ABCDEF)
-
- punpcklbw xmm0, xmm0 ; xmm0=(*0*1*2*3*4*5*6*7)
- punpcklbw xmm1, xmm1 ; xmm1=(*8*9*A*B*C*D*E*F)
-
- punpcklwd xmm2, xmm0 ; xmm2=(***0***1***2***3)
- punpckhwd xmm0, xmm0 ; xmm0=(***4***5***6***7)
- punpcklwd xmm3, xmm1 ; xmm3=(***8***9***A***B)
- punpckhwd xmm1, xmm1 ; xmm1=(***C***D***E***F)
-
- psrad xmm2, (DWORD_BIT-BYTE_BIT) ; xmm2=(0123)
- psrad xmm0, (DWORD_BIT-BYTE_BIT) ; xmm0=(4567)
- cvtdq2ps xmm2, xmm2 ; xmm2=(0123)
- cvtdq2ps xmm0, xmm0 ; xmm0=(4567)
- psrad xmm3, (DWORD_BIT-BYTE_BIT) ; xmm3=(89AB)
- psrad xmm1, (DWORD_BIT-BYTE_BIT) ; xmm1=(CDEF)
- cvtdq2ps xmm3, xmm3 ; xmm3=(89AB)
- cvtdq2ps xmm1, xmm1 ; xmm1=(CDEF)
-
- movaps XMMWORD [XMMBLOCK(0,0,edi,SIZEOF_FAST_FLOAT)], xmm2
- movaps XMMWORD [XMMBLOCK(0,1,edi,SIZEOF_FAST_FLOAT)], xmm0
- movaps XMMWORD [XMMBLOCK(1,0,edi,SIZEOF_FAST_FLOAT)], xmm3
- movaps XMMWORD [XMMBLOCK(1,1,edi,SIZEOF_FAST_FLOAT)], xmm1
-
- add esi, byte 2*SIZEOF_JSAMPROW
- add edi, byte 2*DCTSIZE*SIZEOF_FAST_FLOAT
- dec ecx
- jnz short .convloop
-
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- pop ebx
- pop ebp
- ret
-
-; --------------------------------------------------------------------------
-;
-; Quantize/descale the coefficients, and store into coef_block
-;
-; GLOBAL(void)
-; jsimd_quantize_float_sse2(JCOEFPTR coef_block, FAST_FLOAT *divisors,
-; FAST_FLOAT *workspace);
-;
-
-%define coef_block ebp + 8 ; JCOEFPTR coef_block
-%define divisors ebp + 12 ; FAST_FLOAT *divisors
-%define workspace ebp + 16 ; FAST_FLOAT *workspace
-
- align 32
- GLOBAL_FUNCTION(jsimd_quantize_float_sse2)
-
-EXTN(jsimd_quantize_float_sse2):
- push ebp
- mov ebp, esp
-; push ebx ; unused
-; push ecx ; unused
-; push edx ; need not be preserved
- push esi
- push edi
-
- mov esi, POINTER [workspace]
- mov edx, POINTER [divisors]
- mov edi, JCOEFPTR [coef_block]
- mov eax, DCTSIZE2/16
- alignx 16, 7
-.quantloop:
- movaps xmm0, XMMWORD [XMMBLOCK(0,0,esi,SIZEOF_FAST_FLOAT)]
- movaps xmm1, XMMWORD [XMMBLOCK(0,1,esi,SIZEOF_FAST_FLOAT)]
- mulps xmm0, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_FAST_FLOAT)]
- mulps xmm1, XMMWORD [XMMBLOCK(0,1,edx,SIZEOF_FAST_FLOAT)]
- movaps xmm2, XMMWORD [XMMBLOCK(1,0,esi,SIZEOF_FAST_FLOAT)]
- movaps xmm3, XMMWORD [XMMBLOCK(1,1,esi,SIZEOF_FAST_FLOAT)]
- mulps xmm2, XMMWORD [XMMBLOCK(1,0,edx,SIZEOF_FAST_FLOAT)]
- mulps xmm3, XMMWORD [XMMBLOCK(1,1,edx,SIZEOF_FAST_FLOAT)]
-
- cvtps2dq xmm0, xmm0
- cvtps2dq xmm1, xmm1
- cvtps2dq xmm2, xmm2
- cvtps2dq xmm3, xmm3
-
- packssdw xmm0, xmm1
- packssdw xmm2, xmm3
-
- movdqa XMMWORD [XMMBLOCK(0,0,edi,SIZEOF_JCOEF)], xmm0
- movdqa XMMWORD [XMMBLOCK(1,0,edi,SIZEOF_JCOEF)], xmm2
-
- add esi, byte 16*SIZEOF_FAST_FLOAT
- add edx, byte 16*SIZEOF_FAST_FLOAT
- add edi, byte 16*SIZEOF_JCOEF
- dec eax
- jnz short .quantloop
-
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; unused
-; pop ebx ; unused
- pop ebp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jquanti-avx2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jquanti-avx2.asm
deleted file mode 100644
index 5ed6bec246..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jquanti-avx2.asm
+++ /dev/null
@@ -1,188 +0,0 @@
-;
-; jquanti.asm - sample data conversion and quantization (AVX2)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2016, 2018, D. R. Commander.
-; Copyright (C) 2016, Matthieu Darbois.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jsimdext.inc"
-%include "jdct.inc"
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-;
-; Load data into workspace, applying unsigned->signed conversion
-;
-; GLOBAL(void)
-; jsimd_convsamp_avx2(JSAMPARRAY sample_data, JDIMENSION start_col,
-; DCTELEM *workspace);
-;
-
-%define sample_data ebp + 8 ; JSAMPARRAY sample_data
-%define start_col ebp + 12 ; JDIMENSION start_col
-%define workspace ebp + 16 ; DCTELEM *workspace
-
- align 32
- GLOBAL_FUNCTION(jsimd_convsamp_avx2)
-
-EXTN(jsimd_convsamp_avx2):
- push ebp
- mov ebp, esp
- push ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- mov esi, JSAMPARRAY [sample_data] ; (JSAMPROW *)
- mov eax, JDIMENSION [start_col]
- mov edi, POINTER [workspace] ; (DCTELEM *)
-
- mov ebx, JSAMPROW [esi+0*SIZEOF_JSAMPROW] ; (JSAMPLE *)
- mov edx, JSAMPROW [esi+1*SIZEOF_JSAMPROW] ; (JSAMPLE *)
- movq xmm0, XMM_MMWORD [ebx+eax*SIZEOF_JSAMPLE]
- movq xmm1, XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE]
-
- mov ebx, JSAMPROW [esi+2*SIZEOF_JSAMPROW] ; (JSAMPLE *)
- mov edx, JSAMPROW [esi+3*SIZEOF_JSAMPROW] ; (JSAMPLE *)
- movq xmm2, XMM_MMWORD [ebx+eax*SIZEOF_JSAMPLE]
- movq xmm3, XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE]
-
- mov ebx, JSAMPROW [esi+4*SIZEOF_JSAMPROW] ; (JSAMPLE *)
- mov edx, JSAMPROW [esi+5*SIZEOF_JSAMPROW] ; (JSAMPLE *)
- movq xmm4, XMM_MMWORD [ebx+eax*SIZEOF_JSAMPLE]
- movq xmm5, XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE]
-
- mov ebx, JSAMPROW [esi+6*SIZEOF_JSAMPROW] ; (JSAMPLE *)
- mov edx, JSAMPROW [esi+7*SIZEOF_JSAMPROW] ; (JSAMPLE *)
- movq xmm6, XMM_MMWORD [ebx+eax*SIZEOF_JSAMPLE]
- movq xmm7, XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE]
-
- vinserti128 ymm0, ymm0, xmm1, 1
- vinserti128 ymm2, ymm2, xmm3, 1
- vinserti128 ymm4, ymm4, xmm5, 1
- vinserti128 ymm6, ymm6, xmm7, 1
-
- vpxor ymm1, ymm1, ymm1 ; ymm1=(all 0's)
- vpunpcklbw ymm0, ymm0, ymm1
- vpunpcklbw ymm2, ymm2, ymm1
- vpunpcklbw ymm4, ymm4, ymm1
- vpunpcklbw ymm6, ymm6, ymm1
-
- vpcmpeqw ymm7, ymm7, ymm7
- vpsllw ymm7, ymm7, 7 ; ymm7={0xFF80 0xFF80 0xFF80 0xFF80 ..}
-
- vpaddw ymm0, ymm0, ymm7
- vpaddw ymm2, ymm2, ymm7
- vpaddw ymm4, ymm4, ymm7
- vpaddw ymm6, ymm6, ymm7
-
- vmovdqu YMMWORD [YMMBLOCK(0,0,edi,SIZEOF_DCTELEM)], ymm0
- vmovdqu YMMWORD [YMMBLOCK(2,0,edi,SIZEOF_DCTELEM)], ymm2
- vmovdqu YMMWORD [YMMBLOCK(4,0,edi,SIZEOF_DCTELEM)], ymm4
- vmovdqu YMMWORD [YMMBLOCK(6,0,edi,SIZEOF_DCTELEM)], ymm6
-
- vzeroupper
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- pop ebx
- pop ebp
- ret
-
-; --------------------------------------------------------------------------
-;
-; Quantize/descale the coefficients, and store into coef_block
-;
-; This implementation is based on an algorithm described in
-; "How to optimize for the Pentium family of microprocessors"
-; (http://www.agner.org/assem/).
-;
-; GLOBAL(void)
-; jsimd_quantize_avx2(JCOEFPTR coef_block, DCTELEM *divisors,
-; DCTELEM *workspace);
-;
-
-%define RECIPROCAL(m, n, b) \
- YMMBLOCK(DCTSIZE * 0 + (m), (n), (b), SIZEOF_DCTELEM)
-%define CORRECTION(m, n, b) \
- YMMBLOCK(DCTSIZE * 1 + (m), (n), (b), SIZEOF_DCTELEM)
-%define SCALE(m, n, b) \
- YMMBLOCK(DCTSIZE * 2 + (m), (n), (b), SIZEOF_DCTELEM)
-
-%define coef_block ebp + 8 ; JCOEFPTR coef_block
-%define divisors ebp + 12 ; DCTELEM *divisors
-%define workspace ebp + 16 ; DCTELEM *workspace
-
- align 32
- GLOBAL_FUNCTION(jsimd_quantize_avx2)
-
-EXTN(jsimd_quantize_avx2):
- push ebp
- mov ebp, esp
-; push ebx ; unused
-; push ecx ; unused
-; push edx ; need not be preserved
- push esi
- push edi
-
- mov esi, POINTER [workspace]
- mov edx, POINTER [divisors]
- mov edi, JCOEFPTR [coef_block]
-
- vmovdqu ymm4, [YMMBLOCK(0,0,esi,SIZEOF_DCTELEM)]
- vmovdqu ymm5, [YMMBLOCK(2,0,esi,SIZEOF_DCTELEM)]
- vmovdqu ymm6, [YMMBLOCK(4,0,esi,SIZEOF_DCTELEM)]
- vmovdqu ymm7, [YMMBLOCK(6,0,esi,SIZEOF_DCTELEM)]
- vpabsw ymm0, ymm4
- vpabsw ymm1, ymm5
- vpabsw ymm2, ymm6
- vpabsw ymm3, ymm7
-
- vpaddw ymm0, YMMWORD [CORRECTION(0,0,edx)] ; correction + roundfactor
- vpaddw ymm1, YMMWORD [CORRECTION(2,0,edx)]
- vpaddw ymm2, YMMWORD [CORRECTION(4,0,edx)]
- vpaddw ymm3, YMMWORD [CORRECTION(6,0,edx)]
- vpmulhuw ymm0, YMMWORD [RECIPROCAL(0,0,edx)] ; reciprocal
- vpmulhuw ymm1, YMMWORD [RECIPROCAL(2,0,edx)]
- vpmulhuw ymm2, YMMWORD [RECIPROCAL(4,0,edx)]
- vpmulhuw ymm3, YMMWORD [RECIPROCAL(6,0,edx)]
- vpmulhuw ymm0, YMMWORD [SCALE(0,0,edx)] ; scale
- vpmulhuw ymm1, YMMWORD [SCALE(2,0,edx)]
- vpmulhuw ymm2, YMMWORD [SCALE(4,0,edx)]
- vpmulhuw ymm3, YMMWORD [SCALE(6,0,edx)]
-
- vpsignw ymm0, ymm0, ymm4
- vpsignw ymm1, ymm1, ymm5
- vpsignw ymm2, ymm2, ymm6
- vpsignw ymm3, ymm3, ymm7
-
- vmovdqu [YMMBLOCK(0,0,edi,SIZEOF_DCTELEM)], ymm0
- vmovdqu [YMMBLOCK(2,0,edi,SIZEOF_DCTELEM)], ymm1
- vmovdqu [YMMBLOCK(4,0,edi,SIZEOF_DCTELEM)], ymm2
- vmovdqu [YMMBLOCK(6,0,edi,SIZEOF_DCTELEM)], ymm3
-
- vzeroupper
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; unused
-; pop ebx ; unused
- pop ebp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jquanti-sse2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jquanti-sse2.asm
deleted file mode 100644
index 0a509408aa..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jquanti-sse2.asm
+++ /dev/null
@@ -1,201 +0,0 @@
-;
-; jquanti.asm - sample data conversion and quantization (SSE2)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jsimdext.inc"
-%include "jdct.inc"
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-;
-; Load data into workspace, applying unsigned->signed conversion
-;
-; GLOBAL(void)
-; jsimd_convsamp_sse2(JSAMPARRAY sample_data, JDIMENSION start_col,
-; DCTELEM *workspace);
-;
-
-%define sample_data ebp + 8 ; JSAMPARRAY sample_data
-%define start_col ebp + 12 ; JDIMENSION start_col
-%define workspace ebp + 16 ; DCTELEM *workspace
-
- align 32
- GLOBAL_FUNCTION(jsimd_convsamp_sse2)
-
-EXTN(jsimd_convsamp_sse2):
- push ebp
- mov ebp, esp
- push ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
- push esi
- push edi
-
- pxor xmm6, xmm6 ; xmm6=(all 0's)
- pcmpeqw xmm7, xmm7
- psllw xmm7, 7 ; xmm7={0xFF80 0xFF80 0xFF80 0xFF80 ..}
-
- mov esi, JSAMPARRAY [sample_data] ; (JSAMPROW *)
- mov eax, JDIMENSION [start_col]
- mov edi, POINTER [workspace] ; (DCTELEM *)
- mov ecx, DCTSIZE/4
- alignx 16, 7
-.convloop:
- mov ebx, JSAMPROW [esi+0*SIZEOF_JSAMPROW] ; (JSAMPLE *)
- mov edx, JSAMPROW [esi+1*SIZEOF_JSAMPROW] ; (JSAMPLE *)
-
- movq xmm0, XMM_MMWORD [ebx+eax*SIZEOF_JSAMPLE] ; xmm0=(01234567)
- movq xmm1, XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE] ; xmm1=(89ABCDEF)
-
- mov ebx, JSAMPROW [esi+2*SIZEOF_JSAMPROW] ; (JSAMPLE *)
- mov edx, JSAMPROW [esi+3*SIZEOF_JSAMPROW] ; (JSAMPLE *)
-
- movq xmm2, XMM_MMWORD [ebx+eax*SIZEOF_JSAMPLE] ; xmm2=(GHIJKLMN)
- movq xmm3, XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE] ; xmm3=(OPQRSTUV)
-
- punpcklbw xmm0, xmm6 ; xmm0=(01234567)
- punpcklbw xmm1, xmm6 ; xmm1=(89ABCDEF)
- paddw xmm0, xmm7
- paddw xmm1, xmm7
- punpcklbw xmm2, xmm6 ; xmm2=(GHIJKLMN)
- punpcklbw xmm3, xmm6 ; xmm3=(OPQRSTUV)
- paddw xmm2, xmm7
- paddw xmm3, xmm7
-
- movdqa XMMWORD [XMMBLOCK(0,0,edi,SIZEOF_DCTELEM)], xmm0
- movdqa XMMWORD [XMMBLOCK(1,0,edi,SIZEOF_DCTELEM)], xmm1
- movdqa XMMWORD [XMMBLOCK(2,0,edi,SIZEOF_DCTELEM)], xmm2
- movdqa XMMWORD [XMMBLOCK(3,0,edi,SIZEOF_DCTELEM)], xmm3
-
- add esi, byte 4*SIZEOF_JSAMPROW
- add edi, byte 4*DCTSIZE*SIZEOF_DCTELEM
- dec ecx
- jnz short .convloop
-
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- pop ebx
- pop ebp
- ret
-
-; --------------------------------------------------------------------------
-;
-; Quantize/descale the coefficients, and store into coef_block
-;
-; This implementation is based on an algorithm described in
-; "How to optimize for the Pentium family of microprocessors"
-; (http://www.agner.org/assem/).
-;
-; GLOBAL(void)
-; jsimd_quantize_sse2(JCOEFPTR coef_block, DCTELEM *divisors,
-; DCTELEM *workspace);
-;
-
-%define RECIPROCAL(m, n, b) \
- XMMBLOCK(DCTSIZE * 0 + (m), (n), (b), SIZEOF_DCTELEM)
-%define CORRECTION(m, n, b) \
- XMMBLOCK(DCTSIZE * 1 + (m), (n), (b), SIZEOF_DCTELEM)
-%define SCALE(m, n, b) \
- XMMBLOCK(DCTSIZE * 2 + (m), (n), (b), SIZEOF_DCTELEM)
-
-%define coef_block ebp + 8 ; JCOEFPTR coef_block
-%define divisors ebp + 12 ; DCTELEM *divisors
-%define workspace ebp + 16 ; DCTELEM *workspace
-
- align 32
- GLOBAL_FUNCTION(jsimd_quantize_sse2)
-
-EXTN(jsimd_quantize_sse2):
- push ebp
- mov ebp, esp
-; push ebx ; unused
-; push ecx ; unused
-; push edx ; need not be preserved
- push esi
- push edi
-
- mov esi, POINTER [workspace]
- mov edx, POINTER [divisors]
- mov edi, JCOEFPTR [coef_block]
- mov eax, DCTSIZE2/32
- alignx 16, 7
-.quantloop:
- movdqa xmm4, XMMWORD [XMMBLOCK(0,0,esi,SIZEOF_DCTELEM)]
- movdqa xmm5, XMMWORD [XMMBLOCK(1,0,esi,SIZEOF_DCTELEM)]
- movdqa xmm6, XMMWORD [XMMBLOCK(2,0,esi,SIZEOF_DCTELEM)]
- movdqa xmm7, XMMWORD [XMMBLOCK(3,0,esi,SIZEOF_DCTELEM)]
- movdqa xmm0, xmm4
- movdqa xmm1, xmm5
- movdqa xmm2, xmm6
- movdqa xmm3, xmm7
- psraw xmm4, (WORD_BIT-1)
- psraw xmm5, (WORD_BIT-1)
- psraw xmm6, (WORD_BIT-1)
- psraw xmm7, (WORD_BIT-1)
- pxor xmm0, xmm4
- pxor xmm1, xmm5
- pxor xmm2, xmm6
- pxor xmm3, xmm7
- psubw xmm0, xmm4 ; if (xmm0 < 0) xmm0 = -xmm0;
- psubw xmm1, xmm5 ; if (xmm1 < 0) xmm1 = -xmm1;
- psubw xmm2, xmm6 ; if (xmm2 < 0) xmm2 = -xmm2;
- psubw xmm3, xmm7 ; if (xmm3 < 0) xmm3 = -xmm3;
-
- paddw xmm0, XMMWORD [CORRECTION(0,0,edx)] ; correction + roundfactor
- paddw xmm1, XMMWORD [CORRECTION(1,0,edx)]
- paddw xmm2, XMMWORD [CORRECTION(2,0,edx)]
- paddw xmm3, XMMWORD [CORRECTION(3,0,edx)]
- pmulhuw xmm0, XMMWORD [RECIPROCAL(0,0,edx)] ; reciprocal
- pmulhuw xmm1, XMMWORD [RECIPROCAL(1,0,edx)]
- pmulhuw xmm2, XMMWORD [RECIPROCAL(2,0,edx)]
- pmulhuw xmm3, XMMWORD [RECIPROCAL(3,0,edx)]
- pmulhuw xmm0, XMMWORD [SCALE(0,0,edx)] ; scale
- pmulhuw xmm1, XMMWORD [SCALE(1,0,edx)]
- pmulhuw xmm2, XMMWORD [SCALE(2,0,edx)]
- pmulhuw xmm3, XMMWORD [SCALE(3,0,edx)]
-
- pxor xmm0, xmm4
- pxor xmm1, xmm5
- pxor xmm2, xmm6
- pxor xmm3, xmm7
- psubw xmm0, xmm4
- psubw xmm1, xmm5
- psubw xmm2, xmm6
- psubw xmm3, xmm7
- movdqa XMMWORD [XMMBLOCK(0,0,edi,SIZEOF_DCTELEM)], xmm0
- movdqa XMMWORD [XMMBLOCK(1,0,edi,SIZEOF_DCTELEM)], xmm1
- movdqa XMMWORD [XMMBLOCK(2,0,edi,SIZEOF_DCTELEM)], xmm2
- movdqa XMMWORD [XMMBLOCK(3,0,edi,SIZEOF_DCTELEM)], xmm3
-
- add esi, byte 32*SIZEOF_DCTELEM
- add edx, byte 32*SIZEOF_DCTELEM
- add edi, byte 32*SIZEOF_JCOEF
- dec eax
- jnz near .quantloop
-
- pop edi
- pop esi
-; pop edx ; need not be preserved
-; pop ecx ; unused
-; pop ebx ; unused
- pop ebp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jsimd.c b/contrib/libs/libjpeg-turbo/simd/i386/jsimd.c
deleted file mode 100644
index 80bc821ff4..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jsimd.c
+++ /dev/null
@@ -1,1246 +0,0 @@
-/*
- * jsimd_i386.c
- *
- * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- * Copyright (C) 2009-2011, 2013-2014, 2016, 2018, 2022, D. R. Commander.
- * Copyright (C) 2015-2016, 2018, Matthieu Darbois.
- *
- * Based on the x86 SIMD extension for IJG JPEG library,
- * Copyright (C) 1999-2006, MIYASAKA Masaru.
- * For conditions of distribution and use, see copyright notice in jsimdext.inc
- *
- * This file contains the interface between the "normal" portions
- * of the library and the SIMD implementations when running on a
- * 32-bit x86 architecture.
- */
-
-#define JPEG_INTERNALS
-#include "../../jinclude.h"
-#include "../../jpeglib.h"
-#include "../../jsimd.h"
-#include "../../jdct.h"
-#include "../../jsimddct.h"
-#include "../jsimd.h"
-#include "jconfigint.h"
-
-/*
- * In the PIC cases, we have no guarantee that constants will keep
- * their alignment. This macro allows us to verify it at runtime.
- */
-#define IS_ALIGNED(ptr, order) (((unsigned)ptr & ((1 << order) - 1)) == 0)
-
-#define IS_ALIGNED_SSE(ptr) (IS_ALIGNED(ptr, 4)) /* 16 byte alignment */
-#define IS_ALIGNED_AVX(ptr) (IS_ALIGNED(ptr, 5)) /* 32 byte alignment */
-
-static unsigned int simd_support = (unsigned int)(~0);
-static unsigned int simd_huffman = 1;
-
-/*
- * Check what SIMD accelerations are supported.
- *
- * FIXME: This code is racy under a multi-threaded environment.
- */
-LOCAL(void)
-init_simd(void)
-{
-#ifndef NO_GETENV
- char env[2] = { 0 };
-#endif
-
- if (simd_support != ~0U)
- return;
-
- simd_support = jpeg_simd_cpu_support();
-
-#ifndef NO_GETENV
- /* Force different settings through environment variables */
- if (!GETENV_S(env, 2, "JSIMD_FORCEMMX") && !strcmp(env, "1"))
- simd_support &= JSIMD_MMX;
- if (!GETENV_S(env, 2, "JSIMD_FORCE3DNOW") && !strcmp(env, "1"))
- simd_support &= JSIMD_3DNOW | JSIMD_MMX;
- if (!GETENV_S(env, 2, "JSIMD_FORCESSE") && !strcmp(env, "1"))
- simd_support &= JSIMD_SSE | JSIMD_MMX;
- if (!GETENV_S(env, 2, "JSIMD_FORCESSE2") && !strcmp(env, "1"))
- simd_support &= JSIMD_SSE2;
- if (!GETENV_S(env, 2, "JSIMD_FORCEAVX2") && !strcmp(env, "1"))
- simd_support &= JSIMD_AVX2;
- if (!GETENV_S(env, 2, "JSIMD_FORCENONE") && !strcmp(env, "1"))
- simd_support = 0;
- if (!GETENV_S(env, 2, "JSIMD_NOHUFFENC") && !strcmp(env, "1"))
- simd_huffman = 0;
-#endif
-}
-
-GLOBAL(int)
-jsimd_can_rgb_ycc(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
- if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
- return 0;
-
- if ((simd_support & JSIMD_AVX2) &&
- IS_ALIGNED_AVX(jconst_rgb_ycc_convert_avx2))
- return 1;
- if ((simd_support & JSIMD_SSE2) &&
- IS_ALIGNED_SSE(jconst_rgb_ycc_convert_sse2))
- return 1;
- if (simd_support & JSIMD_MMX)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_rgb_gray(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
- if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
- return 0;
-
- if ((simd_support & JSIMD_AVX2) &&
- IS_ALIGNED_AVX(jconst_rgb_gray_convert_avx2))
- return 1;
- if ((simd_support & JSIMD_SSE2) &&
- IS_ALIGNED_SSE(jconst_rgb_gray_convert_sse2))
- return 1;
- if (simd_support & JSIMD_MMX)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_ycc_rgb(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
- if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
- return 0;
-
- if ((simd_support & JSIMD_AVX2) &&
- IS_ALIGNED_AVX(jconst_ycc_rgb_convert_avx2))
- return 1;
- if ((simd_support & JSIMD_SSE2) &&
- IS_ALIGNED_SSE(jconst_ycc_rgb_convert_sse2))
- return 1;
- if (simd_support & JSIMD_MMX)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_ycc_rgb565(void)
-{
- return 0;
-}
-
-GLOBAL(void)
-jsimd_rgb_ycc_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPIMAGE output_buf, JDIMENSION output_row,
- int num_rows)
-{
- void (*avx2fct) (JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int);
- void (*sse2fct) (JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int);
- void (*mmxfct) (JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int);
-
- switch (cinfo->in_color_space) {
- case JCS_EXT_RGB:
- avx2fct = jsimd_extrgb_ycc_convert_avx2;
- sse2fct = jsimd_extrgb_ycc_convert_sse2;
- mmxfct = jsimd_extrgb_ycc_convert_mmx;
- break;
- case JCS_EXT_RGBX:
- case JCS_EXT_RGBA:
- avx2fct = jsimd_extrgbx_ycc_convert_avx2;
- sse2fct = jsimd_extrgbx_ycc_convert_sse2;
- mmxfct = jsimd_extrgbx_ycc_convert_mmx;
- break;
- case JCS_EXT_BGR:
- avx2fct = jsimd_extbgr_ycc_convert_avx2;
- sse2fct = jsimd_extbgr_ycc_convert_sse2;
- mmxfct = jsimd_extbgr_ycc_convert_mmx;
- break;
- case JCS_EXT_BGRX:
- case JCS_EXT_BGRA:
- avx2fct = jsimd_extbgrx_ycc_convert_avx2;
- sse2fct = jsimd_extbgrx_ycc_convert_sse2;
- mmxfct = jsimd_extbgrx_ycc_convert_mmx;
- break;
- case JCS_EXT_XBGR:
- case JCS_EXT_ABGR:
- avx2fct = jsimd_extxbgr_ycc_convert_avx2;
- sse2fct = jsimd_extxbgr_ycc_convert_sse2;
- mmxfct = jsimd_extxbgr_ycc_convert_mmx;
- break;
- case JCS_EXT_XRGB:
- case JCS_EXT_ARGB:
- avx2fct = jsimd_extxrgb_ycc_convert_avx2;
- sse2fct = jsimd_extxrgb_ycc_convert_sse2;
- mmxfct = jsimd_extxrgb_ycc_convert_mmx;
- break;
- default:
- avx2fct = jsimd_rgb_ycc_convert_avx2;
- sse2fct = jsimd_rgb_ycc_convert_sse2;
- mmxfct = jsimd_rgb_ycc_convert_mmx;
- break;
- }
-
- if (simd_support & JSIMD_AVX2)
- avx2fct(cinfo->image_width, input_buf, output_buf, output_row, num_rows);
- else if (simd_support & JSIMD_SSE2)
- sse2fct(cinfo->image_width, input_buf, output_buf, output_row, num_rows);
- else
- mmxfct(cinfo->image_width, input_buf, output_buf, output_row, num_rows);
-}
-
-GLOBAL(void)
-jsimd_rgb_gray_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPIMAGE output_buf, JDIMENSION output_row,
- int num_rows)
-{
- void (*avx2fct) (JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int);
- void (*sse2fct) (JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int);
- void (*mmxfct) (JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int);
-
- switch (cinfo->in_color_space) {
- case JCS_EXT_RGB:
- avx2fct = jsimd_extrgb_gray_convert_avx2;
- sse2fct = jsimd_extrgb_gray_convert_sse2;
- mmxfct = jsimd_extrgb_gray_convert_mmx;
- break;
- case JCS_EXT_RGBX:
- case JCS_EXT_RGBA:
- avx2fct = jsimd_extrgbx_gray_convert_avx2;
- sse2fct = jsimd_extrgbx_gray_convert_sse2;
- mmxfct = jsimd_extrgbx_gray_convert_mmx;
- break;
- case JCS_EXT_BGR:
- avx2fct = jsimd_extbgr_gray_convert_avx2;
- sse2fct = jsimd_extbgr_gray_convert_sse2;
- mmxfct = jsimd_extbgr_gray_convert_mmx;
- break;
- case JCS_EXT_BGRX:
- case JCS_EXT_BGRA:
- avx2fct = jsimd_extbgrx_gray_convert_avx2;
- sse2fct = jsimd_extbgrx_gray_convert_sse2;
- mmxfct = jsimd_extbgrx_gray_convert_mmx;
- break;
- case JCS_EXT_XBGR:
- case JCS_EXT_ABGR:
- avx2fct = jsimd_extxbgr_gray_convert_avx2;
- sse2fct = jsimd_extxbgr_gray_convert_sse2;
- mmxfct = jsimd_extxbgr_gray_convert_mmx;
- break;
- case JCS_EXT_XRGB:
- case JCS_EXT_ARGB:
- avx2fct = jsimd_extxrgb_gray_convert_avx2;
- sse2fct = jsimd_extxrgb_gray_convert_sse2;
- mmxfct = jsimd_extxrgb_gray_convert_mmx;
- break;
- default:
- avx2fct = jsimd_rgb_gray_convert_avx2;
- sse2fct = jsimd_rgb_gray_convert_sse2;
- mmxfct = jsimd_rgb_gray_convert_mmx;
- break;
- }
-
- if (simd_support & JSIMD_AVX2)
- avx2fct(cinfo->image_width, input_buf, output_buf, output_row, num_rows);
- else if (simd_support & JSIMD_SSE2)
- sse2fct(cinfo->image_width, input_buf, output_buf, output_row, num_rows);
- else
- mmxfct(cinfo->image_width, input_buf, output_buf, output_row, num_rows);
-}
-
-GLOBAL(void)
-jsimd_ycc_rgb_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf,
- int num_rows)
-{
- void (*avx2fct) (JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY, int);
- void (*sse2fct) (JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY, int);
- void (*mmxfct) (JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY, int);
-
- switch (cinfo->out_color_space) {
- case JCS_EXT_RGB:
- avx2fct = jsimd_ycc_extrgb_convert_avx2;
- sse2fct = jsimd_ycc_extrgb_convert_sse2;
- mmxfct = jsimd_ycc_extrgb_convert_mmx;
- break;
- case JCS_EXT_RGBX:
- case JCS_EXT_RGBA:
- avx2fct = jsimd_ycc_extrgbx_convert_avx2;
- sse2fct = jsimd_ycc_extrgbx_convert_sse2;
- mmxfct = jsimd_ycc_extrgbx_convert_mmx;
- break;
- case JCS_EXT_BGR:
- avx2fct = jsimd_ycc_extbgr_convert_avx2;
- sse2fct = jsimd_ycc_extbgr_convert_sse2;
- mmxfct = jsimd_ycc_extbgr_convert_mmx;
- break;
- case JCS_EXT_BGRX:
- case JCS_EXT_BGRA:
- avx2fct = jsimd_ycc_extbgrx_convert_avx2;
- sse2fct = jsimd_ycc_extbgrx_convert_sse2;
- mmxfct = jsimd_ycc_extbgrx_convert_mmx;
- break;
- case JCS_EXT_XBGR:
- case JCS_EXT_ABGR:
- avx2fct = jsimd_ycc_extxbgr_convert_avx2;
- sse2fct = jsimd_ycc_extxbgr_convert_sse2;
- mmxfct = jsimd_ycc_extxbgr_convert_mmx;
- break;
- case JCS_EXT_XRGB:
- case JCS_EXT_ARGB:
- avx2fct = jsimd_ycc_extxrgb_convert_avx2;
- sse2fct = jsimd_ycc_extxrgb_convert_sse2;
- mmxfct = jsimd_ycc_extxrgb_convert_mmx;
- break;
- default:
- avx2fct = jsimd_ycc_rgb_convert_avx2;
- sse2fct = jsimd_ycc_rgb_convert_sse2;
- mmxfct = jsimd_ycc_rgb_convert_mmx;
- break;
- }
-
- if (simd_support & JSIMD_AVX2)
- avx2fct(cinfo->output_width, input_buf, input_row, output_buf, num_rows);
- else if (simd_support & JSIMD_SSE2)
- sse2fct(cinfo->output_width, input_buf, input_row, output_buf, num_rows);
- else
- mmxfct(cinfo->output_width, input_buf, input_row, output_buf, num_rows);
-}
-
-GLOBAL(void)
-jsimd_ycc_rgb565_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf,
- int num_rows)
-{
-}
-
-GLOBAL(int)
-jsimd_can_h2v2_downsample(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
-
- if (simd_support & JSIMD_AVX2)
- return 1;
- if (simd_support & JSIMD_SSE2)
- return 1;
- if (simd_support & JSIMD_MMX)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_h2v1_downsample(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
-
- if (simd_support & JSIMD_AVX2)
- return 1;
- if (simd_support & JSIMD_SSE2)
- return 1;
- if (simd_support & JSIMD_MMX)
- return 1;
-
- return 0;
-}
-
-GLOBAL(void)
-jsimd_h2v2_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY output_data)
-{
- if (simd_support & JSIMD_AVX2)
- jsimd_h2v2_downsample_avx2(cinfo->image_width, cinfo->max_v_samp_factor,
- compptr->v_samp_factor,
- compptr->width_in_blocks, input_data,
- output_data);
- else if (simd_support & JSIMD_SSE2)
- jsimd_h2v2_downsample_sse2(cinfo->image_width, cinfo->max_v_samp_factor,
- compptr->v_samp_factor,
- compptr->width_in_blocks, input_data,
- output_data);
- else
- jsimd_h2v2_downsample_mmx(cinfo->image_width, cinfo->max_v_samp_factor,
- compptr->v_samp_factor, compptr->width_in_blocks,
- input_data, output_data);
-}
-
-GLOBAL(void)
-jsimd_h2v1_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY output_data)
-{
- if (simd_support & JSIMD_AVX2)
- jsimd_h2v1_downsample_avx2(cinfo->image_width, cinfo->max_v_samp_factor,
- compptr->v_samp_factor,
- compptr->width_in_blocks, input_data,
- output_data);
- else if (simd_support & JSIMD_SSE2)
- jsimd_h2v1_downsample_sse2(cinfo->image_width, cinfo->max_v_samp_factor,
- compptr->v_samp_factor,
- compptr->width_in_blocks, input_data,
- output_data);
- else
- jsimd_h2v1_downsample_mmx(cinfo->image_width, cinfo->max_v_samp_factor,
- compptr->v_samp_factor, compptr->width_in_blocks,
- input_data, output_data);
-}
-
-GLOBAL(int)
-jsimd_can_h2v2_upsample(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
-
- if (simd_support & JSIMD_AVX2)
- return 1;
- if (simd_support & JSIMD_SSE2)
- return 1;
- if (simd_support & JSIMD_MMX)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_h2v1_upsample(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
-
- if (simd_support & JSIMD_AVX2)
- return 1;
- if (simd_support & JSIMD_SSE2)
- return 1;
- if (simd_support & JSIMD_MMX)
- return 1;
-
- return 0;
-}
-
-GLOBAL(void)
-jsimd_h2v2_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
-{
- if (simd_support & JSIMD_AVX2)
- jsimd_h2v2_upsample_avx2(cinfo->max_v_samp_factor, cinfo->output_width,
- input_data, output_data_ptr);
- else if (simd_support & JSIMD_SSE2)
- jsimd_h2v2_upsample_sse2(cinfo->max_v_samp_factor, cinfo->output_width,
- input_data, output_data_ptr);
- else
- jsimd_h2v2_upsample_mmx(cinfo->max_v_samp_factor, cinfo->output_width,
- input_data, output_data_ptr);
-}
-
-GLOBAL(void)
-jsimd_h2v1_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
-{
- if (simd_support & JSIMD_AVX2)
- jsimd_h2v1_upsample_avx2(cinfo->max_v_samp_factor, cinfo->output_width,
- input_data, output_data_ptr);
- else if (simd_support & JSIMD_SSE2)
- jsimd_h2v1_upsample_sse2(cinfo->max_v_samp_factor, cinfo->output_width,
- input_data, output_data_ptr);
- else
- jsimd_h2v1_upsample_mmx(cinfo->max_v_samp_factor, cinfo->output_width,
- input_data, output_data_ptr);
-}
-
-GLOBAL(int)
-jsimd_can_h2v2_fancy_upsample(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
-
- if ((simd_support & JSIMD_AVX2) &&
- IS_ALIGNED_AVX(jconst_fancy_upsample_avx2))
- return 1;
- if ((simd_support & JSIMD_SSE2) &&
- IS_ALIGNED_SSE(jconst_fancy_upsample_sse2))
- return 1;
- if (simd_support & JSIMD_MMX)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_h2v1_fancy_upsample(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
-
- if ((simd_support & JSIMD_AVX2) &&
- IS_ALIGNED_AVX(jconst_fancy_upsample_avx2))
- return 1;
- if ((simd_support & JSIMD_SSE2) &&
- IS_ALIGNED_SSE(jconst_fancy_upsample_sse2))
- return 1;
- if (simd_support & JSIMD_MMX)
- return 1;
-
- return 0;
-}
-
-GLOBAL(void)
-jsimd_h2v2_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
-{
- if (simd_support & JSIMD_AVX2)
- jsimd_h2v2_fancy_upsample_avx2(cinfo->max_v_samp_factor,
- compptr->downsampled_width, input_data,
- output_data_ptr);
- else if (simd_support & JSIMD_SSE2)
- jsimd_h2v2_fancy_upsample_sse2(cinfo->max_v_samp_factor,
- compptr->downsampled_width, input_data,
- output_data_ptr);
- else
- jsimd_h2v2_fancy_upsample_mmx(cinfo->max_v_samp_factor,
- compptr->downsampled_width, input_data,
- output_data_ptr);
-}
-
-GLOBAL(void)
-jsimd_h2v1_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
-{
- if (simd_support & JSIMD_AVX2)
- jsimd_h2v1_fancy_upsample_avx2(cinfo->max_v_samp_factor,
- compptr->downsampled_width, input_data,
- output_data_ptr);
- else if (simd_support & JSIMD_SSE2)
- jsimd_h2v1_fancy_upsample_sse2(cinfo->max_v_samp_factor,
- compptr->downsampled_width, input_data,
- output_data_ptr);
- else
- jsimd_h2v1_fancy_upsample_mmx(cinfo->max_v_samp_factor,
- compptr->downsampled_width, input_data,
- output_data_ptr);
-}
-
-GLOBAL(int)
-jsimd_can_h2v2_merged_upsample(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
-
- if ((simd_support & JSIMD_AVX2) &&
- IS_ALIGNED_AVX(jconst_merged_upsample_avx2))
- return 1;
- if ((simd_support & JSIMD_SSE2) &&
- IS_ALIGNED_SSE(jconst_merged_upsample_sse2))
- return 1;
- if (simd_support & JSIMD_MMX)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_h2v1_merged_upsample(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
-
- if ((simd_support & JSIMD_AVX2) &&
- IS_ALIGNED_AVX(jconst_merged_upsample_avx2))
- return 1;
- if ((simd_support & JSIMD_SSE2) &&
- IS_ALIGNED_SSE(jconst_merged_upsample_sse2))
- return 1;
- if (simd_support & JSIMD_MMX)
- return 1;
-
- return 0;
-}
-
-GLOBAL(void)
-jsimd_h2v2_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
-{
- void (*avx2fct) (JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY);
- void (*sse2fct) (JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY);
- void (*mmxfct) (JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY);
-
- switch (cinfo->out_color_space) {
- case JCS_EXT_RGB:
- avx2fct = jsimd_h2v2_extrgb_merged_upsample_avx2;
- sse2fct = jsimd_h2v2_extrgb_merged_upsample_sse2;
- mmxfct = jsimd_h2v2_extrgb_merged_upsample_mmx;
- break;
- case JCS_EXT_RGBX:
- case JCS_EXT_RGBA:
- avx2fct = jsimd_h2v2_extrgbx_merged_upsample_avx2;
- sse2fct = jsimd_h2v2_extrgbx_merged_upsample_sse2;
- mmxfct = jsimd_h2v2_extrgbx_merged_upsample_mmx;
- break;
- case JCS_EXT_BGR:
- avx2fct = jsimd_h2v2_extbgr_merged_upsample_avx2;
- sse2fct = jsimd_h2v2_extbgr_merged_upsample_sse2;
- mmxfct = jsimd_h2v2_extbgr_merged_upsample_mmx;
- break;
- case JCS_EXT_BGRX:
- case JCS_EXT_BGRA:
- avx2fct = jsimd_h2v2_extbgrx_merged_upsample_avx2;
- sse2fct = jsimd_h2v2_extbgrx_merged_upsample_sse2;
- mmxfct = jsimd_h2v2_extbgrx_merged_upsample_mmx;
- break;
- case JCS_EXT_XBGR:
- case JCS_EXT_ABGR:
- avx2fct = jsimd_h2v2_extxbgr_merged_upsample_avx2;
- sse2fct = jsimd_h2v2_extxbgr_merged_upsample_sse2;
- mmxfct = jsimd_h2v2_extxbgr_merged_upsample_mmx;
- break;
- case JCS_EXT_XRGB:
- case JCS_EXT_ARGB:
- avx2fct = jsimd_h2v2_extxrgb_merged_upsample_avx2;
- sse2fct = jsimd_h2v2_extxrgb_merged_upsample_sse2;
- mmxfct = jsimd_h2v2_extxrgb_merged_upsample_mmx;
- break;
- default:
- avx2fct = jsimd_h2v2_merged_upsample_avx2;
- sse2fct = jsimd_h2v2_merged_upsample_sse2;
- mmxfct = jsimd_h2v2_merged_upsample_mmx;
- break;
- }
-
- if (simd_support & JSIMD_AVX2)
- avx2fct(cinfo->output_width, input_buf, in_row_group_ctr, output_buf);
- else if (simd_support & JSIMD_SSE2)
- sse2fct(cinfo->output_width, input_buf, in_row_group_ctr, output_buf);
- else
- mmxfct(cinfo->output_width, input_buf, in_row_group_ctr, output_buf);
-}
-
-GLOBAL(void)
-jsimd_h2v1_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
-{
- void (*avx2fct) (JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY);
- void (*sse2fct) (JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY);
- void (*mmxfct) (JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY);
-
- switch (cinfo->out_color_space) {
- case JCS_EXT_RGB:
- avx2fct = jsimd_h2v1_extrgb_merged_upsample_avx2;
- sse2fct = jsimd_h2v1_extrgb_merged_upsample_sse2;
- mmxfct = jsimd_h2v1_extrgb_merged_upsample_mmx;
- break;
- case JCS_EXT_RGBX:
- case JCS_EXT_RGBA:
- avx2fct = jsimd_h2v1_extrgbx_merged_upsample_avx2;
- sse2fct = jsimd_h2v1_extrgbx_merged_upsample_sse2;
- mmxfct = jsimd_h2v1_extrgbx_merged_upsample_mmx;
- break;
- case JCS_EXT_BGR:
- avx2fct = jsimd_h2v1_extbgr_merged_upsample_avx2;
- sse2fct = jsimd_h2v1_extbgr_merged_upsample_sse2;
- mmxfct = jsimd_h2v1_extbgr_merged_upsample_mmx;
- break;
- case JCS_EXT_BGRX:
- case JCS_EXT_BGRA:
- avx2fct = jsimd_h2v1_extbgrx_merged_upsample_avx2;
- sse2fct = jsimd_h2v1_extbgrx_merged_upsample_sse2;
- mmxfct = jsimd_h2v1_extbgrx_merged_upsample_mmx;
- break;
- case JCS_EXT_XBGR:
- case JCS_EXT_ABGR:
- avx2fct = jsimd_h2v1_extxbgr_merged_upsample_avx2;
- sse2fct = jsimd_h2v1_extxbgr_merged_upsample_sse2;
- mmxfct = jsimd_h2v1_extxbgr_merged_upsample_mmx;
- break;
- case JCS_EXT_XRGB:
- case JCS_EXT_ARGB:
- avx2fct = jsimd_h2v1_extxrgb_merged_upsample_avx2;
- sse2fct = jsimd_h2v1_extxrgb_merged_upsample_sse2;
- mmxfct = jsimd_h2v1_extxrgb_merged_upsample_mmx;
- break;
- default:
- avx2fct = jsimd_h2v1_merged_upsample_avx2;
- sse2fct = jsimd_h2v1_merged_upsample_sse2;
- mmxfct = jsimd_h2v1_merged_upsample_mmx;
- break;
- }
-
- if (simd_support & JSIMD_AVX2)
- avx2fct(cinfo->output_width, input_buf, in_row_group_ctr, output_buf);
- else if (simd_support & JSIMD_SSE2)
- sse2fct(cinfo->output_width, input_buf, in_row_group_ctr, output_buf);
- else
- mmxfct(cinfo->output_width, input_buf, in_row_group_ctr, output_buf);
-}
-
-GLOBAL(int)
-jsimd_can_convsamp(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (DCTSIZE != 8)
- return 0;
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
- if (sizeof(DCTELEM) != 2)
- return 0;
-
- if (simd_support & JSIMD_AVX2)
- return 1;
- if (simd_support & JSIMD_SSE2)
- return 1;
- if (simd_support & JSIMD_MMX)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_convsamp_float(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (DCTSIZE != 8)
- return 0;
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
- if (sizeof(FAST_FLOAT) != 4)
- return 0;
-
- if (simd_support & JSIMD_SSE2)
- return 1;
- if (simd_support & JSIMD_SSE)
- return 1;
- if (simd_support & JSIMD_3DNOW)
- return 1;
-
- return 0;
-}
-
-GLOBAL(void)
-jsimd_convsamp(JSAMPARRAY sample_data, JDIMENSION start_col,
- DCTELEM *workspace)
-{
- if (simd_support & JSIMD_AVX2)
- jsimd_convsamp_avx2(sample_data, start_col, workspace);
- else if (simd_support & JSIMD_SSE2)
- jsimd_convsamp_sse2(sample_data, start_col, workspace);
- else
- jsimd_convsamp_mmx(sample_data, start_col, workspace);
-}
-
-GLOBAL(void)
-jsimd_convsamp_float(JSAMPARRAY sample_data, JDIMENSION start_col,
- FAST_FLOAT *workspace)
-{
- if (simd_support & JSIMD_SSE2)
- jsimd_convsamp_float_sse2(sample_data, start_col, workspace);
- else if (simd_support & JSIMD_SSE)
- jsimd_convsamp_float_sse(sample_data, start_col, workspace);
- else
- jsimd_convsamp_float_3dnow(sample_data, start_col, workspace);
-}
-
-GLOBAL(int)
-jsimd_can_fdct_islow(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(DCTELEM) != 2)
- return 0;
-
- if ((simd_support & JSIMD_AVX2) && IS_ALIGNED_AVX(jconst_fdct_islow_avx2))
- return 1;
- if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_fdct_islow_sse2))
- return 1;
- if (simd_support & JSIMD_MMX)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_fdct_ifast(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(DCTELEM) != 2)
- return 0;
-
- if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_fdct_ifast_sse2))
- return 1;
- if (simd_support & JSIMD_MMX)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_fdct_float(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(FAST_FLOAT) != 4)
- return 0;
-
- if ((simd_support & JSIMD_SSE) && IS_ALIGNED_SSE(jconst_fdct_float_sse))
- return 1;
- if (simd_support & JSIMD_3DNOW)
- return 1;
-
- return 0;
-}
-
-GLOBAL(void)
-jsimd_fdct_islow(DCTELEM *data)
-{
- if (simd_support & JSIMD_AVX2)
- jsimd_fdct_islow_avx2(data);
- else if (simd_support & JSIMD_SSE2)
- jsimd_fdct_islow_sse2(data);
- else
- jsimd_fdct_islow_mmx(data);
-}
-
-GLOBAL(void)
-jsimd_fdct_ifast(DCTELEM *data)
-{
- if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_fdct_islow_sse2))
- jsimd_fdct_ifast_sse2(data);
- else
- jsimd_fdct_ifast_mmx(data);
-}
-
-GLOBAL(void)
-jsimd_fdct_float(FAST_FLOAT *data)
-{
- if ((simd_support & JSIMD_SSE) && IS_ALIGNED_SSE(jconst_fdct_float_sse))
- jsimd_fdct_float_sse(data);
- else if (simd_support & JSIMD_3DNOW)
- jsimd_fdct_float_3dnow(data);
-}
-
-GLOBAL(int)
-jsimd_can_quantize(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JCOEF) != 2)
- return 0;
- if (sizeof(DCTELEM) != 2)
- return 0;
-
- if (simd_support & JSIMD_AVX2)
- return 1;
- if (simd_support & JSIMD_SSE2)
- return 1;
- if (simd_support & JSIMD_MMX)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_quantize_float(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JCOEF) != 2)
- return 0;
- if (sizeof(FAST_FLOAT) != 4)
- return 0;
-
- if (simd_support & JSIMD_SSE2)
- return 1;
- if (simd_support & JSIMD_SSE)
- return 1;
- if (simd_support & JSIMD_3DNOW)
- return 1;
-
- return 0;
-}
-
-GLOBAL(void)
-jsimd_quantize(JCOEFPTR coef_block, DCTELEM *divisors, DCTELEM *workspace)
-{
- if (simd_support & JSIMD_AVX2)
- jsimd_quantize_avx2(coef_block, divisors, workspace);
- else if (simd_support & JSIMD_SSE2)
- jsimd_quantize_sse2(coef_block, divisors, workspace);
- else
- jsimd_quantize_mmx(coef_block, divisors, workspace);
-}
-
-GLOBAL(void)
-jsimd_quantize_float(JCOEFPTR coef_block, FAST_FLOAT *divisors,
- FAST_FLOAT *workspace)
-{
- if (simd_support & JSIMD_SSE2)
- jsimd_quantize_float_sse2(coef_block, divisors, workspace);
- else if (simd_support & JSIMD_SSE)
- jsimd_quantize_float_sse(coef_block, divisors, workspace);
- else
- jsimd_quantize_float_3dnow(coef_block, divisors, workspace);
-}
-
-GLOBAL(int)
-jsimd_can_idct_2x2(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JCOEF) != 2)
- return 0;
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
- if (sizeof(ISLOW_MULT_TYPE) != 2)
- return 0;
-
- if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_red_sse2))
- return 1;
- if (simd_support & JSIMD_MMX)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_idct_4x4(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JCOEF) != 2)
- return 0;
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
- if (sizeof(ISLOW_MULT_TYPE) != 2)
- return 0;
-
- if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_red_sse2))
- return 1;
- if (simd_support & JSIMD_MMX)
- return 1;
-
- return 0;
-}
-
-GLOBAL(void)
-jsimd_idct_2x2(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
- if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_red_sse2))
- jsimd_idct_2x2_sse2(compptr->dct_table, coef_block, output_buf,
- output_col);
- else
- jsimd_idct_2x2_mmx(compptr->dct_table, coef_block, output_buf, output_col);
-}
-
-GLOBAL(void)
-jsimd_idct_4x4(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
- if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_red_sse2))
- jsimd_idct_4x4_sse2(compptr->dct_table, coef_block, output_buf,
- output_col);
- else
- jsimd_idct_4x4_mmx(compptr->dct_table, coef_block, output_buf, output_col);
-}
-
-GLOBAL(int)
-jsimd_can_idct_islow(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JCOEF) != 2)
- return 0;
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
- if (sizeof(ISLOW_MULT_TYPE) != 2)
- return 0;
-
- if ((simd_support & JSIMD_AVX2) && IS_ALIGNED_AVX(jconst_idct_islow_avx2))
- return 1;
- if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_islow_sse2))
- return 1;
- if (simd_support & JSIMD_MMX)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_idct_ifast(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JCOEF) != 2)
- return 0;
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
- if (sizeof(IFAST_MULT_TYPE) != 2)
- return 0;
- if (IFAST_SCALE_BITS != 2)
- return 0;
-
- if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_ifast_sse2))
- return 1;
- if (simd_support & JSIMD_MMX)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_idct_float(void)
-{
- init_simd();
-
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JCOEF) != 2)
- return 0;
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
- if (sizeof(FAST_FLOAT) != 4)
- return 0;
- if (sizeof(FLOAT_MULT_TYPE) != 4)
- return 0;
-
- if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_float_sse2))
- return 1;
- if ((simd_support & JSIMD_SSE) && IS_ALIGNED_SSE(jconst_idct_float_sse))
- return 1;
- if (simd_support & JSIMD_3DNOW)
- return 1;
-
- return 0;
-}
-
-GLOBAL(void)
-jsimd_idct_islow(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
- if (simd_support & JSIMD_AVX2)
- jsimd_idct_islow_avx2(compptr->dct_table, coef_block, output_buf,
- output_col);
- else if (simd_support & JSIMD_SSE2)
- jsimd_idct_islow_sse2(compptr->dct_table, coef_block, output_buf,
- output_col);
- else
- jsimd_idct_islow_mmx(compptr->dct_table, coef_block, output_buf,
- output_col);
-}
-
-GLOBAL(void)
-jsimd_idct_ifast(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
- if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_ifast_sse2))
- jsimd_idct_ifast_sse2(compptr->dct_table, coef_block, output_buf,
- output_col);
- else
- jsimd_idct_ifast_mmx(compptr->dct_table, coef_block, output_buf,
- output_col);
-}
-
-GLOBAL(void)
-jsimd_idct_float(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
- if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_float_sse2))
- jsimd_idct_float_sse2(compptr->dct_table, coef_block, output_buf,
- output_col);
- else if ((simd_support & JSIMD_SSE) && IS_ALIGNED_SSE(jconst_idct_float_sse))
- jsimd_idct_float_sse(compptr->dct_table, coef_block, output_buf,
- output_col);
- else
- jsimd_idct_float_3dnow(compptr->dct_table, coef_block, output_buf,
- output_col);
-}
-
-GLOBAL(int)
-jsimd_can_huff_encode_one_block(void)
-{
- init_simd();
-
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JCOEF) != 2)
- return 0;
-
- if ((simd_support & JSIMD_SSE2) && simd_huffman &&
- IS_ALIGNED_SSE(jconst_huff_encode_one_block))
- return 1;
-
- return 0;
-}
-
-GLOBAL(JOCTET *)
-jsimd_huff_encode_one_block(void *state, JOCTET *buffer, JCOEFPTR block,
- int last_dc_val, c_derived_tbl *dctbl,
- c_derived_tbl *actbl)
-{
- return jsimd_huff_encode_one_block_sse2(state, buffer, block, last_dc_val,
- dctbl, actbl);
-}
-
-GLOBAL(int)
-jsimd_can_encode_mcu_AC_first_prepare(void)
-{
- init_simd();
-
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JCOEF) != 2)
- return 0;
- if (SIZEOF_SIZE_T != 4)
- return 0;
- if (simd_support & JSIMD_SSE2)
- return 1;
-
- return 0;
-}
-
-GLOBAL(void)
-jsimd_encode_mcu_AC_first_prepare(const JCOEF *block,
- const int *jpeg_natural_order_start, int Sl,
- int Al, JCOEF *values, size_t *zerobits)
-{
- jsimd_encode_mcu_AC_first_prepare_sse2(block, jpeg_natural_order_start,
- Sl, Al, values, zerobits);
-}
-
-GLOBAL(int)
-jsimd_can_encode_mcu_AC_refine_prepare(void)
-{
- init_simd();
-
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JCOEF) != 2)
- return 0;
- if (SIZEOF_SIZE_T != 4)
- return 0;
- if (simd_support & JSIMD_SSE2)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_encode_mcu_AC_refine_prepare(const JCOEF *block,
- const int *jpeg_natural_order_start, int Sl,
- int Al, JCOEF *absvalues, size_t *bits)
-{
- return jsimd_encode_mcu_AC_refine_prepare_sse2(block,
- jpeg_natural_order_start,
- Sl, Al, absvalues, bits);
-}
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jsimdcpu.asm b/contrib/libs/libjpeg-turbo/simd/i386/jsimdcpu.asm
deleted file mode 100644
index ddcafa9e21..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/i386/jsimdcpu.asm
+++ /dev/null
@@ -1,135 +0,0 @@
-;
-; jsimdcpu.asm - SIMD instruction support check
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jsimdext.inc"
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 32
-;
-; Check if the CPU supports SIMD instructions
-;
-; GLOBAL(unsigned int)
-; jpeg_simd_cpu_support(void)
-;
-
- align 32
- GLOBAL_FUNCTION(jpeg_simd_cpu_support)
-
-EXTN(jpeg_simd_cpu_support):
- push ebx
-; push ecx ; need not be preserved
-; push edx ; need not be preserved
-; push esi ; unused
- push edi
-
- xor edi, edi ; simd support flag
-
- pushfd
- pop eax
- mov edx, eax
- xor eax, 1<<21 ; flip ID bit in EFLAGS
- push eax
- popfd
- pushfd
- pop eax
- xor eax, edx
- jz near .return ; CPUID is not supported
-
- ; Check whether CPUID leaf 07H is supported
- ; (leaf 07H is used to check for AVX2 instruction support)
- xor eax, eax
- cpuid
- test eax, eax
- jz near .return
- cmp eax, 7
- jl short .no_avx2 ; Maximum leaf < 07H
-
- ; Check for AVX2 instruction support
- mov eax, 7
- xor ecx, ecx
- cpuid
- mov eax, ebx
- test eax, 1<<5 ; bit5:AVX2
- jz short .no_avx2
-
- ; Check for AVX2 O/S support
- mov eax, 1
- xor ecx, ecx
- cpuid
- test ecx, 1<<27
- jz short .no_avx2 ; O/S does not support XSAVE
- test ecx, 1<<28
- jz short .no_avx2 ; CPU does not support AVX2
-
- xor ecx, ecx
- xgetbv
- and eax, 6
- cmp eax, 6 ; O/S does not manage XMM/YMM state
- ; using XSAVE
- jnz short .no_avx2
-
- or edi, JSIMD_AVX2
-.no_avx2:
-
- ; Check CPUID leaf 01H for MMX, SSE, and SSE2 support
- xor eax, eax
- inc eax
- cpuid
- mov eax, edx ; eax = Standard feature flags
-
- ; Check for MMX instruction support
- test eax, 1<<23 ; bit23:MMX
- jz short .no_mmx
- or edi, byte JSIMD_MMX
-.no_mmx:
- test eax, 1<<25 ; bit25:SSE
- jz short .no_sse
- or edi, byte JSIMD_SSE
-.no_sse:
- test eax, 1<<26 ; bit26:SSE2
- jz short .no_sse2
- or edi, byte JSIMD_SSE2
-.no_sse2:
-
- ; Check for 3DNow! instruction support
- mov eax, 0x80000000
- cpuid
- cmp eax, 0x80000000
- jbe short .return
-
- mov eax, 0x80000001
- cpuid
- mov eax, edx ; eax = Extended feature flags
-
- test eax, 1<<31 ; bit31:3DNow!(vendor independent)
- jz short .no_3dnow
- or edi, byte JSIMD_3DNOW
-.no_3dnow:
-
-.return:
- mov eax, edi
-
- pop edi
-; pop esi ; unused
-; pop edx ; need not be preserved
-; pop ecx ; need not be preserved
- pop ebx
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/jsimd.h b/contrib/libs/libjpeg-turbo/simd/jsimd.h
deleted file mode 100644
index 64747c6360..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/jsimd.h
+++ /dev/null
@@ -1,1258 +0,0 @@
-/*
- * simd/jsimd.h
- *
- * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- * Copyright (C) 2011, 2014-2016, 2018, 2020, D. R. Commander.
- * Copyright (C) 2013-2014, MIPS Technologies, Inc., California.
- * Copyright (C) 2014, Linaro Limited.
- * Copyright (C) 2015-2016, 2018, Matthieu Darbois.
- * Copyright (C) 2016-2018, Loongson Technology Corporation Limited, BeiJing.
- * Copyright (C) 2020, Arm Limited.
- *
- * Based on the x86 SIMD extension for IJG JPEG library,
- * Copyright (C) 1999-2006, MIYASAKA Masaru.
- * For conditions of distribution and use, see copyright notice in jsimdext.inc
- *
- */
-
-/* Bitmask for supported acceleration methods */
-
-#define JSIMD_NONE 0x00
-#define JSIMD_MMX 0x01
-#define JSIMD_3DNOW 0x02
-#define JSIMD_SSE 0x04
-#define JSIMD_SSE2 0x08
-#define JSIMD_NEON 0x10
-#define JSIMD_DSPR2 0x20
-#define JSIMD_ALTIVEC 0x40
-#define JSIMD_AVX2 0x80
-#define JSIMD_MMI 0x100
-
-/* SIMD Ext: retrieve SIMD/CPU information */
-EXTERN(unsigned int) jpeg_simd_cpu_support(void);
-
-/* RGB & extended RGB --> YCC Colorspace Conversion */
-EXTERN(void) jsimd_rgb_ycc_convert_mmx
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extrgb_ycc_convert_mmx
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extrgbx_ycc_convert_mmx
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extbgr_ycc_convert_mmx
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extbgrx_ycc_convert_mmx
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extxbgr_ycc_convert_mmx
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extxrgb_ycc_convert_mmx
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-
-extern const int jconst_rgb_ycc_convert_sse2[];
-EXTERN(void) jsimd_rgb_ycc_convert_sse2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extrgb_ycc_convert_sse2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extrgbx_ycc_convert_sse2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extbgr_ycc_convert_sse2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extbgrx_ycc_convert_sse2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extxbgr_ycc_convert_sse2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extxrgb_ycc_convert_sse2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-
-extern const int jconst_rgb_ycc_convert_avx2[];
-EXTERN(void) jsimd_rgb_ycc_convert_avx2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extrgb_ycc_convert_avx2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extrgbx_ycc_convert_avx2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extbgr_ycc_convert_avx2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extbgrx_ycc_convert_avx2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extxbgr_ycc_convert_avx2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extxrgb_ycc_convert_avx2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-
-EXTERN(void) jsimd_rgb_ycc_convert_neon
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extrgb_ycc_convert_neon
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extrgbx_ycc_convert_neon
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extbgr_ycc_convert_neon
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extbgrx_ycc_convert_neon
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extxbgr_ycc_convert_neon
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extxrgb_ycc_convert_neon
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-
-#ifndef NEON_INTRINSICS
-
-EXTERN(void) jsimd_extrgb_ycc_convert_neon_slowld3
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extbgr_ycc_convert_neon_slowld3
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-
-#endif
-
-EXTERN(void) jsimd_rgb_ycc_convert_dspr2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extrgb_ycc_convert_dspr2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extrgbx_ycc_convert_dspr2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extbgr_ycc_convert_dspr2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extbgrx_ycc_convert_dspr2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extxbgr_ycc_convert_dspr2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extxrgb_ycc_convert_dspr2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-
-EXTERN(void) jsimd_rgb_ycc_convert_mmi
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extrgb_ycc_convert_mmi
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extrgbx_ycc_convert_mmi
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extbgr_ycc_convert_mmi
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extbgrx_ycc_convert_mmi
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extxbgr_ycc_convert_mmi
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extxrgb_ycc_convert_mmi
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-
-EXTERN(void) jsimd_rgb_ycc_convert_altivec
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extrgb_ycc_convert_altivec
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extrgbx_ycc_convert_altivec
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extbgr_ycc_convert_altivec
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extbgrx_ycc_convert_altivec
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extxbgr_ycc_convert_altivec
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extxrgb_ycc_convert_altivec
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-
-/* RGB & extended RGB --> Grayscale Colorspace Conversion */
-EXTERN(void) jsimd_rgb_gray_convert_mmx
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extrgb_gray_convert_mmx
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extrgbx_gray_convert_mmx
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extbgr_gray_convert_mmx
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extbgrx_gray_convert_mmx
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extxbgr_gray_convert_mmx
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extxrgb_gray_convert_mmx
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-
-extern const int jconst_rgb_gray_convert_sse2[];
-EXTERN(void) jsimd_rgb_gray_convert_sse2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extrgb_gray_convert_sse2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extrgbx_gray_convert_sse2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extbgr_gray_convert_sse2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extbgrx_gray_convert_sse2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extxbgr_gray_convert_sse2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extxrgb_gray_convert_sse2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-
-extern const int jconst_rgb_gray_convert_avx2[];
-EXTERN(void) jsimd_rgb_gray_convert_avx2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extrgb_gray_convert_avx2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extrgbx_gray_convert_avx2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extbgr_gray_convert_avx2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extbgrx_gray_convert_avx2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extxbgr_gray_convert_avx2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extxrgb_gray_convert_avx2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-
-EXTERN(void) jsimd_rgb_gray_convert_neon
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extrgb_gray_convert_neon
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extrgbx_gray_convert_neon
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extbgr_gray_convert_neon
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extbgrx_gray_convert_neon
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extxbgr_gray_convert_neon
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extxrgb_gray_convert_neon
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-
-EXTERN(void) jsimd_rgb_gray_convert_dspr2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extrgb_gray_convert_dspr2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extrgbx_gray_convert_dspr2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extbgr_gray_convert_dspr2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extbgrx_gray_convert_dspr2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extxbgr_gray_convert_dspr2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extxrgb_gray_convert_dspr2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-
-EXTERN(void) jsimd_rgb_gray_convert_mmi
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extrgb_gray_convert_mmi
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extrgbx_gray_convert_mmi
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extbgr_gray_convert_mmi
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extbgrx_gray_convert_mmi
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extxbgr_gray_convert_mmi
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extxrgb_gray_convert_mmi
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-
-EXTERN(void) jsimd_rgb_gray_convert_altivec
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extrgb_gray_convert_altivec
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extrgbx_gray_convert_altivec
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extbgr_gray_convert_altivec
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extbgrx_gray_convert_altivec
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extxbgr_gray_convert_altivec
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-EXTERN(void) jsimd_extxrgb_gray_convert_altivec
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows);
-
-/* YCC --> RGB & extended RGB Colorspace Conversion */
-EXTERN(void) jsimd_ycc_rgb_convert_mmx
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extrgb_convert_mmx
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extrgbx_convert_mmx
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extbgr_convert_mmx
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extbgrx_convert_mmx
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extxbgr_convert_mmx
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extxrgb_convert_mmx
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-
-extern const int jconst_ycc_rgb_convert_sse2[];
-EXTERN(void) jsimd_ycc_rgb_convert_sse2
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extrgb_convert_sse2
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extrgbx_convert_sse2
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extbgr_convert_sse2
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extbgrx_convert_sse2
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extxbgr_convert_sse2
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extxrgb_convert_sse2
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-
-extern const int jconst_ycc_rgb_convert_avx2[];
-EXTERN(void) jsimd_ycc_rgb_convert_avx2
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extrgb_convert_avx2
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extrgbx_convert_avx2
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extbgr_convert_avx2
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extbgrx_convert_avx2
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extxbgr_convert_avx2
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extxrgb_convert_avx2
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-
-EXTERN(void) jsimd_ycc_rgb_convert_neon
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extrgb_convert_neon
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extrgbx_convert_neon
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extbgr_convert_neon
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extbgrx_convert_neon
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extxbgr_convert_neon
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extxrgb_convert_neon
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_rgb565_convert_neon
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-
-#ifndef NEON_INTRINSICS
-
-EXTERN(void) jsimd_ycc_extrgb_convert_neon_slowst3
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extbgr_convert_neon_slowst3
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-
-#endif
-
-EXTERN(void) jsimd_ycc_rgb_convert_dspr2
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extrgb_convert_dspr2
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extrgbx_convert_dspr2
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extbgr_convert_dspr2
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extbgrx_convert_dspr2
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extxbgr_convert_dspr2
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extxrgb_convert_dspr2
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-
-EXTERN(void) jsimd_ycc_rgb_convert_mmi
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extrgb_convert_mmi
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extrgbx_convert_mmi
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extbgr_convert_mmi
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extbgrx_convert_mmi
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extxbgr_convert_mmi
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extxrgb_convert_mmi
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-
-EXTERN(void) jsimd_ycc_rgb_convert_altivec
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extrgb_convert_altivec
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extrgbx_convert_altivec
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extbgr_convert_altivec
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extbgrx_convert_altivec
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extxbgr_convert_altivec
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-EXTERN(void) jsimd_ycc_extxrgb_convert_altivec
- (JDIMENSION out_width, JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows);
-
-/* NULL Colorspace Conversion */
-EXTERN(void) jsimd_c_null_convert_dspr2
- (JDIMENSION img_width, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows, int num_components);
-
-/* h2v1 Downsampling */
-EXTERN(void) jsimd_h2v1_downsample_mmx
- (JDIMENSION image_width, int max_v_samp_factor, JDIMENSION v_samp_factor,
- JDIMENSION width_in_blocks, JSAMPARRAY input_data, JSAMPARRAY output_data);
-
-EXTERN(void) jsimd_h2v1_downsample_sse2
- (JDIMENSION image_width, int max_v_samp_factor, JDIMENSION v_samp_factor,
- JDIMENSION width_in_blocks, JSAMPARRAY input_data, JSAMPARRAY output_data);
-
-EXTERN(void) jsimd_h2v1_downsample_avx2
- (JDIMENSION image_width, int max_v_samp_factor, JDIMENSION v_samp_factor,
- JDIMENSION width_in_blocks, JSAMPARRAY input_data, JSAMPARRAY output_data);
-
-EXTERN(void) jsimd_h2v1_downsample_neon
- (JDIMENSION image_width, int max_v_samp_factor, JDIMENSION v_samp_factor,
- JDIMENSION width_in_blocks, JSAMPARRAY input_data, JSAMPARRAY output_data);
-
-EXTERN(void) jsimd_h2v1_downsample_dspr2
- (JDIMENSION image_width, int max_v_samp_factor, JDIMENSION v_samp_factor,
- JDIMENSION width_in_blocks, JSAMPARRAY input_data, JSAMPARRAY output_data);
-
-EXTERN(void) jsimd_h2v1_downsample_altivec
- (JDIMENSION image_width, int max_v_samp_factor, JDIMENSION v_samp_factor,
- JDIMENSION width_in_blocks, JSAMPARRAY input_data, JSAMPARRAY output_data);
-
-/* h2v2 Downsampling */
-EXTERN(void) jsimd_h2v2_downsample_mmx
- (JDIMENSION image_width, int max_v_samp_factor, JDIMENSION v_samp_factor,
- JDIMENSION width_in_blocks, JSAMPARRAY input_data, JSAMPARRAY output_data);
-
-EXTERN(void) jsimd_h2v2_downsample_sse2
- (JDIMENSION image_width, int max_v_samp_factor, JDIMENSION v_samp_factor,
- JDIMENSION width_in_blocks, JSAMPARRAY input_data, JSAMPARRAY output_data);
-
-EXTERN(void) jsimd_h2v2_downsample_avx2
- (JDIMENSION image_width, int max_v_samp_factor, JDIMENSION v_samp_factor,
- JDIMENSION width_in_blocks, JSAMPARRAY input_data, JSAMPARRAY output_data);
-
-EXTERN(void) jsimd_h2v2_downsample_neon
- (JDIMENSION image_width, int max_v_samp_factor, JDIMENSION v_samp_factor,
- JDIMENSION width_in_blocks, JSAMPARRAY input_data, JSAMPARRAY output_data);
-
-EXTERN(void) jsimd_h2v2_downsample_dspr2
- (JDIMENSION image_width, int max_v_samp_factor, JDIMENSION v_samp_factor,
- JDIMENSION width_in_blocks, JSAMPARRAY input_data, JSAMPARRAY output_data);
-
-EXTERN(void) jsimd_h2v2_downsample_mmi
- (JDIMENSION image_width, int max_v_samp_factor, JDIMENSION v_samp_factor,
- JDIMENSION width_in_blocks, JSAMPARRAY input_data, JSAMPARRAY output_data);
-
-EXTERN(void) jsimd_h2v2_downsample_altivec
- (JDIMENSION image_width, int max_v_samp_factor, JDIMENSION v_samp_factor,
- JDIMENSION width_in_blocks, JSAMPARRAY input_data, JSAMPARRAY output_data);
-
-/* h2v2 Smooth Downsampling */
-EXTERN(void) jsimd_h2v2_smooth_downsample_dspr2
- (JSAMPARRAY input_data, JSAMPARRAY output_data, JDIMENSION v_samp_factor,
- int max_v_samp_factor, int smoothing_factor, JDIMENSION width_in_blocks,
- JDIMENSION image_width);
-
-
-/* Upsampling */
-EXTERN(void) jsimd_h2v1_upsample_mmx
- (int max_v_samp_factor, JDIMENSION output_width, JSAMPARRAY input_data,
- JSAMPARRAY *output_data_ptr);
-EXTERN(void) jsimd_h2v2_upsample_mmx
- (int max_v_samp_factor, JDIMENSION output_width, JSAMPARRAY input_data,
- JSAMPARRAY *output_data_ptr);
-
-EXTERN(void) jsimd_h2v1_upsample_sse2
- (int max_v_samp_factor, JDIMENSION output_width, JSAMPARRAY input_data,
- JSAMPARRAY *output_data_ptr);
-EXTERN(void) jsimd_h2v2_upsample_sse2
- (int max_v_samp_factor, JDIMENSION output_width, JSAMPARRAY input_data,
- JSAMPARRAY *output_data_ptr);
-
-EXTERN(void) jsimd_h2v1_upsample_avx2
- (int max_v_samp_factor, JDIMENSION output_width, JSAMPARRAY input_data,
- JSAMPARRAY *output_data_ptr);
-EXTERN(void) jsimd_h2v2_upsample_avx2
- (int max_v_samp_factor, JDIMENSION output_width, JSAMPARRAY input_data,
- JSAMPARRAY *output_data_ptr);
-
-EXTERN(void) jsimd_h2v1_upsample_neon
- (int max_v_samp_factor, JDIMENSION output_width, JSAMPARRAY input_data,
- JSAMPARRAY *output_data_ptr);
-EXTERN(void) jsimd_h2v2_upsample_neon
- (int max_v_samp_factor, JDIMENSION output_width, JSAMPARRAY input_data,
- JSAMPARRAY *output_data_ptr);
-
-EXTERN(void) jsimd_h2v1_upsample_dspr2
- (int max_v_samp_factor, JDIMENSION output_width, JSAMPARRAY input_data,
- JSAMPARRAY *output_data_ptr);
-EXTERN(void) jsimd_h2v2_upsample_dspr2
- (int max_v_samp_factor, JDIMENSION output_width, JSAMPARRAY input_data,
- JSAMPARRAY *output_data_ptr);
-
-EXTERN(void) jsimd_int_upsample_dspr2
- (UINT8 h_expand, UINT8 v_expand, JSAMPARRAY input_data,
- JSAMPARRAY *output_data_ptr, JDIMENSION output_width,
- int max_v_samp_factor);
-
-EXTERN(void) jsimd_h2v1_upsample_altivec
- (int max_v_samp_factor, JDIMENSION output_width, JSAMPARRAY input_data,
- JSAMPARRAY *output_data_ptr);
-EXTERN(void) jsimd_h2v2_upsample_altivec
- (int max_v_samp_factor, JDIMENSION output_width, JSAMPARRAY input_data,
- JSAMPARRAY *output_data_ptr);
-
-/* Fancy Upsampling */
-EXTERN(void) jsimd_h2v1_fancy_upsample_mmx
- (int max_v_samp_factor, JDIMENSION downsampled_width, JSAMPARRAY input_data,
- JSAMPARRAY *output_data_ptr);
-EXTERN(void) jsimd_h2v2_fancy_upsample_mmx
- (int max_v_samp_factor, JDIMENSION downsampled_width, JSAMPARRAY input_data,
- JSAMPARRAY *output_data_ptr);
-
-extern const int jconst_fancy_upsample_sse2[];
-EXTERN(void) jsimd_h2v1_fancy_upsample_sse2
- (int max_v_samp_factor, JDIMENSION downsampled_width, JSAMPARRAY input_data,
- JSAMPARRAY *output_data_ptr);
-EXTERN(void) jsimd_h2v2_fancy_upsample_sse2
- (int max_v_samp_factor, JDIMENSION downsampled_width, JSAMPARRAY input_data,
- JSAMPARRAY *output_data_ptr);
-
-extern const int jconst_fancy_upsample_avx2[];
-EXTERN(void) jsimd_h2v1_fancy_upsample_avx2
- (int max_v_samp_factor, JDIMENSION downsampled_width, JSAMPARRAY input_data,
- JSAMPARRAY *output_data_ptr);
-EXTERN(void) jsimd_h2v2_fancy_upsample_avx2
- (int max_v_samp_factor, JDIMENSION downsampled_width, JSAMPARRAY input_data,
- JSAMPARRAY *output_data_ptr);
-
-EXTERN(void) jsimd_h2v1_fancy_upsample_neon
- (int max_v_samp_factor, JDIMENSION downsampled_width, JSAMPARRAY input_data,
- JSAMPARRAY *output_data_ptr);
-EXTERN(void) jsimd_h2v2_fancy_upsample_neon
- (int max_v_samp_factor, JDIMENSION downsampled_width, JSAMPARRAY input_data,
- JSAMPARRAY *output_data_ptr);
-EXTERN(void) jsimd_h1v2_fancy_upsample_neon
- (int max_v_samp_factor, JDIMENSION downsampled_width, JSAMPARRAY input_data,
- JSAMPARRAY *output_data_ptr);
-
-EXTERN(void) jsimd_h2v1_fancy_upsample_dspr2
- (int max_v_samp_factor, JDIMENSION downsampled_width, JSAMPARRAY input_data,
- JSAMPARRAY *output_data_ptr);
-EXTERN(void) jsimd_h2v2_fancy_upsample_dspr2
- (int max_v_samp_factor, JDIMENSION downsampled_width, JSAMPARRAY input_data,
- JSAMPARRAY *output_data_ptr);
-
-EXTERN(void) jsimd_h2v1_fancy_upsample_mmi
- (int max_v_samp_factor, JDIMENSION downsampled_width, JSAMPARRAY input_data,
- JSAMPARRAY *output_data_ptr);
-EXTERN(void) jsimd_h2v2_fancy_upsample_mmi
- (int max_v_samp_factor, JDIMENSION downsampled_width, JSAMPARRAY input_data,
- JSAMPARRAY *output_data_ptr);
-
-EXTERN(void) jsimd_h2v1_fancy_upsample_altivec
- (int max_v_samp_factor, JDIMENSION downsampled_width, JSAMPARRAY input_data,
- JSAMPARRAY *output_data_ptr);
-EXTERN(void) jsimd_h2v2_fancy_upsample_altivec
- (int max_v_samp_factor, JDIMENSION downsampled_width, JSAMPARRAY input_data,
- JSAMPARRAY *output_data_ptr);
-
-/* Merged Upsampling */
-EXTERN(void) jsimd_h2v1_merged_upsample_mmx
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v1_extrgb_merged_upsample_mmx
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v1_extrgbx_merged_upsample_mmx
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v1_extbgr_merged_upsample_mmx
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v1_extbgrx_merged_upsample_mmx
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v1_extxbgr_merged_upsample_mmx
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v1_extxrgb_merged_upsample_mmx
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-
-EXTERN(void) jsimd_h2v2_merged_upsample_mmx
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v2_extrgb_merged_upsample_mmx
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v2_extrgbx_merged_upsample_mmx
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v2_extbgr_merged_upsample_mmx
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v2_extbgrx_merged_upsample_mmx
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v2_extxbgr_merged_upsample_mmx
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v2_extxrgb_merged_upsample_mmx
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-
-extern const int jconst_merged_upsample_sse2[];
-EXTERN(void) jsimd_h2v1_merged_upsample_sse2
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v1_extrgb_merged_upsample_sse2
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v1_extrgbx_merged_upsample_sse2
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v1_extbgr_merged_upsample_sse2
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v1_extbgrx_merged_upsample_sse2
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v1_extxbgr_merged_upsample_sse2
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v1_extxrgb_merged_upsample_sse2
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-
-EXTERN(void) jsimd_h2v2_merged_upsample_sse2
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v2_extrgb_merged_upsample_sse2
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v2_extrgbx_merged_upsample_sse2
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v2_extbgr_merged_upsample_sse2
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v2_extbgrx_merged_upsample_sse2
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v2_extxbgr_merged_upsample_sse2
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v2_extxrgb_merged_upsample_sse2
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-
-extern const int jconst_merged_upsample_avx2[];
-EXTERN(void) jsimd_h2v1_merged_upsample_avx2
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v1_extrgb_merged_upsample_avx2
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v1_extrgbx_merged_upsample_avx2
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v1_extbgr_merged_upsample_avx2
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v1_extbgrx_merged_upsample_avx2
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v1_extxbgr_merged_upsample_avx2
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v1_extxrgb_merged_upsample_avx2
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-
-EXTERN(void) jsimd_h2v2_merged_upsample_avx2
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v2_extrgb_merged_upsample_avx2
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v2_extrgbx_merged_upsample_avx2
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v2_extbgr_merged_upsample_avx2
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v2_extbgrx_merged_upsample_avx2
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v2_extxbgr_merged_upsample_avx2
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v2_extxrgb_merged_upsample_avx2
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-
-EXTERN(void) jsimd_h2v1_merged_upsample_neon
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v1_extrgb_merged_upsample_neon
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v1_extrgbx_merged_upsample_neon
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v1_extbgr_merged_upsample_neon
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v1_extbgrx_merged_upsample_neon
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v1_extxbgr_merged_upsample_neon
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v1_extxrgb_merged_upsample_neon
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-
-EXTERN(void) jsimd_h2v2_merged_upsample_neon
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v2_extrgb_merged_upsample_neon
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v2_extrgbx_merged_upsample_neon
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v2_extbgr_merged_upsample_neon
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v2_extbgrx_merged_upsample_neon
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v2_extxbgr_merged_upsample_neon
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v2_extxrgb_merged_upsample_neon
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-
-EXTERN(void) jsimd_h2v1_merged_upsample_dspr2
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf, JSAMPLE *range);
-EXTERN(void) jsimd_h2v1_extrgb_merged_upsample_dspr2
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf, JSAMPLE *range);
-EXTERN(void) jsimd_h2v1_extrgbx_merged_upsample_dspr2
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf, JSAMPLE *range);
-EXTERN(void) jsimd_h2v1_extbgr_merged_upsample_dspr2
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf, JSAMPLE *range);
-EXTERN(void) jsimd_h2v1_extbgrx_merged_upsample_dspr2
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf, JSAMPLE *range);
-EXTERN(void) jsimd_h2v1_extxbgr_merged_upsample_dspr2
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf, JSAMPLE *range);
-EXTERN(void) jsimd_h2v1_extxrgb_merged_upsample_dspr2
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf, JSAMPLE *range);
-
-EXTERN(void) jsimd_h2v2_merged_upsample_dspr2
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf, JSAMPLE *range);
-EXTERN(void) jsimd_h2v2_extrgb_merged_upsample_dspr2
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf, JSAMPLE *range);
-EXTERN(void) jsimd_h2v2_extrgbx_merged_upsample_dspr2
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf, JSAMPLE *range);
-EXTERN(void) jsimd_h2v2_extbgr_merged_upsample_dspr2
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf, JSAMPLE *range);
-EXTERN(void) jsimd_h2v2_extbgrx_merged_upsample_dspr2
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf, JSAMPLE *range);
-EXTERN(void) jsimd_h2v2_extxbgr_merged_upsample_dspr2
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf, JSAMPLE *range);
-EXTERN(void) jsimd_h2v2_extxrgb_merged_upsample_dspr2
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf, JSAMPLE *range);
-
-EXTERN(void) jsimd_h2v1_merged_upsample_mmi
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v1_extrgb_merged_upsample_mmi
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v1_extrgbx_merged_upsample_mmi
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v1_extbgr_merged_upsample_mmi
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v1_extbgrx_merged_upsample_mmi
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v1_extxbgr_merged_upsample_mmi
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v1_extxrgb_merged_upsample_mmi
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-
-EXTERN(void) jsimd_h2v2_merged_upsample_mmi
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v2_extrgb_merged_upsample_mmi
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v2_extrgbx_merged_upsample_mmi
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v2_extbgr_merged_upsample_mmi
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v2_extbgrx_merged_upsample_mmi
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v2_extxbgr_merged_upsample_mmi
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v2_extxrgb_merged_upsample_mmi
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-
-EXTERN(void) jsimd_h2v1_merged_upsample_altivec
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v1_extrgb_merged_upsample_altivec
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v1_extrgbx_merged_upsample_altivec
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v1_extbgr_merged_upsample_altivec
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v1_extbgrx_merged_upsample_altivec
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v1_extxbgr_merged_upsample_altivec
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v1_extxrgb_merged_upsample_altivec
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-
-EXTERN(void) jsimd_h2v2_merged_upsample_altivec
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v2_extrgb_merged_upsample_altivec
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v2_extrgbx_merged_upsample_altivec
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v2_extbgr_merged_upsample_altivec
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v2_extbgrx_merged_upsample_altivec
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v2_extxbgr_merged_upsample_altivec
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-EXTERN(void) jsimd_h2v2_extxrgb_merged_upsample_altivec
- (JDIMENSION output_width, JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf);
-
-/* Sample Conversion */
-EXTERN(void) jsimd_convsamp_mmx
- (JSAMPARRAY sample_data, JDIMENSION start_col, DCTELEM *workspace);
-
-EXTERN(void) jsimd_convsamp_sse2
- (JSAMPARRAY sample_data, JDIMENSION start_col, DCTELEM *workspace);
-
-EXTERN(void) jsimd_convsamp_avx2
- (JSAMPARRAY sample_data, JDIMENSION start_col, DCTELEM *workspace);
-
-EXTERN(void) jsimd_convsamp_neon
- (JSAMPARRAY sample_data, JDIMENSION start_col, DCTELEM *workspace);
-
-EXTERN(void) jsimd_convsamp_dspr2
- (JSAMPARRAY sample_data, JDIMENSION start_col, DCTELEM *workspace);
-
-EXTERN(void) jsimd_convsamp_altivec
- (JSAMPARRAY sample_data, JDIMENSION start_col, DCTELEM *workspace);
-
-/* Floating Point Sample Conversion */
-EXTERN(void) jsimd_convsamp_float_3dnow
- (JSAMPARRAY sample_data, JDIMENSION start_col, FAST_FLOAT *workspace);
-
-EXTERN(void) jsimd_convsamp_float_sse
- (JSAMPARRAY sample_data, JDIMENSION start_col, FAST_FLOAT *workspace);
-
-EXTERN(void) jsimd_convsamp_float_sse2
- (JSAMPARRAY sample_data, JDIMENSION start_col, FAST_FLOAT *workspace);
-
-EXTERN(void) jsimd_convsamp_float_dspr2
- (JSAMPARRAY sample_data, JDIMENSION start_col, FAST_FLOAT *workspace);
-
-/* Accurate Integer Forward DCT */
-EXTERN(void) jsimd_fdct_islow_mmx(DCTELEM *data);
-
-extern const int jconst_fdct_islow_sse2[];
-EXTERN(void) jsimd_fdct_islow_sse2(DCTELEM *data);
-
-extern const int jconst_fdct_islow_avx2[];
-EXTERN(void) jsimd_fdct_islow_avx2(DCTELEM *data);
-
-EXTERN(void) jsimd_fdct_islow_neon(DCTELEM *data);
-
-EXTERN(void) jsimd_fdct_islow_dspr2(DCTELEM *data);
-
-EXTERN(void) jsimd_fdct_islow_mmi(DCTELEM *data);
-
-EXTERN(void) jsimd_fdct_islow_altivec(DCTELEM *data);
-
-/* Fast Integer Forward DCT */
-EXTERN(void) jsimd_fdct_ifast_mmx(DCTELEM *data);
-
-extern const int jconst_fdct_ifast_sse2[];
-EXTERN(void) jsimd_fdct_ifast_sse2(DCTELEM *data);
-
-EXTERN(void) jsimd_fdct_ifast_neon(DCTELEM *data);
-
-EXTERN(void) jsimd_fdct_ifast_dspr2(DCTELEM *data);
-
-EXTERN(void) jsimd_fdct_ifast_mmi(DCTELEM *data);
-
-EXTERN(void) jsimd_fdct_ifast_altivec(DCTELEM *data);
-
-/* Floating Point Forward DCT */
-EXTERN(void) jsimd_fdct_float_3dnow(FAST_FLOAT *data);
-
-extern const int jconst_fdct_float_sse[];
-EXTERN(void) jsimd_fdct_float_sse(FAST_FLOAT *data);
-
-/* Quantization */
-EXTERN(void) jsimd_quantize_mmx
- (JCOEFPTR coef_block, DCTELEM *divisors, DCTELEM *workspace);
-
-EXTERN(void) jsimd_quantize_sse2
- (JCOEFPTR coef_block, DCTELEM *divisors, DCTELEM *workspace);
-
-EXTERN(void) jsimd_quantize_avx2
- (JCOEFPTR coef_block, DCTELEM *divisors, DCTELEM *workspace);
-
-EXTERN(void) jsimd_quantize_neon
- (JCOEFPTR coef_block, DCTELEM *divisors, DCTELEM *workspace);
-
-EXTERN(void) jsimd_quantize_dspr2
- (JCOEFPTR coef_block, DCTELEM *divisors, DCTELEM *workspace);
-
-EXTERN(void) jsimd_quantize_mmi
- (JCOEFPTR coef_block, DCTELEM *divisors, DCTELEM *workspace);
-
-EXTERN(void) jsimd_quantize_altivec
- (JCOEFPTR coef_block, DCTELEM *divisors, DCTELEM *workspace);
-
-/* Floating Point Quantization */
-EXTERN(void) jsimd_quantize_float_3dnow
- (JCOEFPTR coef_block, FAST_FLOAT *divisors, FAST_FLOAT *workspace);
-
-EXTERN(void) jsimd_quantize_float_sse
- (JCOEFPTR coef_block, FAST_FLOAT *divisors, FAST_FLOAT *workspace);
-
-EXTERN(void) jsimd_quantize_float_sse2
- (JCOEFPTR coef_block, FAST_FLOAT *divisors, FAST_FLOAT *workspace);
-
-EXTERN(void) jsimd_quantize_float_dspr2
- (JCOEFPTR coef_block, FAST_FLOAT *divisors, FAST_FLOAT *workspace);
-
-/* Scaled Inverse DCT */
-EXTERN(void) jsimd_idct_2x2_mmx
- (void *dct_table, JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col);
-EXTERN(void) jsimd_idct_4x4_mmx
- (void *dct_table, JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col);
-
-extern const int jconst_idct_red_sse2[];
-EXTERN(void) jsimd_idct_2x2_sse2
- (void *dct_table, JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col);
-EXTERN(void) jsimd_idct_4x4_sse2
- (void *dct_table, JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col);
-
-EXTERN(void) jsimd_idct_2x2_neon
- (void *dct_table, JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col);
-EXTERN(void) jsimd_idct_4x4_neon
- (void *dct_table, JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col);
-
-EXTERN(void) jsimd_idct_2x2_dspr2
- (void *dct_table, JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col);
-EXTERN(void) jsimd_idct_4x4_dspr2
- (void *dct_table, JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col, int *workspace);
-EXTERN(void) jsimd_idct_6x6_dspr2
- (void *dct_table, JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col);
-EXTERN(void) jsimd_idct_12x12_pass1_dspr2
- (JCOEFPTR coef_block, void *dct_table, int *workspace);
-EXTERN(void) jsimd_idct_12x12_pass2_dspr2
- (int *workspace, int *output);
-
-/* Accurate Integer Inverse DCT */
-EXTERN(void) jsimd_idct_islow_mmx
- (void *dct_table, JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col);
-
-extern const int jconst_idct_islow_sse2[];
-EXTERN(void) jsimd_idct_islow_sse2
- (void *dct_table, JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col);
-
-extern const int jconst_idct_islow_avx2[];
-EXTERN(void) jsimd_idct_islow_avx2
- (void *dct_table, JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col);
-
-EXTERN(void) jsimd_idct_islow_neon
- (void *dct_table, JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col);
-
-EXTERN(void) jsimd_idct_islow_dspr2
- (void *dct_table, JCOEFPTR coef_block, int *output_buf, JSAMPLE *output_col);
-
-EXTERN(void) jsimd_idct_islow_mmi
- (void *dct_table, JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col);
-
-EXTERN(void) jsimd_idct_islow_altivec
- (void *dct_table, JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col);
-
-/* Fast Integer Inverse DCT */
-EXTERN(void) jsimd_idct_ifast_mmx
- (void *dct_table, JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col);
-
-extern const int jconst_idct_ifast_sse2[];
-EXTERN(void) jsimd_idct_ifast_sse2
- (void *dct_table, JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col);
-
-EXTERN(void) jsimd_idct_ifast_neon
- (void *dct_table, JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col);
-
-EXTERN(void) jsimd_idct_ifast_cols_dspr2
- (JCOEF *inptr, IFAST_MULT_TYPE *quantptr, DCTELEM *wsptr,
- const int *idct_coefs);
-EXTERN(void) jsimd_idct_ifast_rows_dspr2
- (DCTELEM *wsptr, JSAMPARRAY output_buf, JDIMENSION output_col,
- const int *idct_coefs);
-
-EXTERN(void) jsimd_idct_ifast_mmi
- (void *dct_table, JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col);
-
-EXTERN(void) jsimd_idct_ifast_altivec
- (void *dct_table, JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col);
-
-/* Floating Point Inverse DCT */
-EXTERN(void) jsimd_idct_float_3dnow
- (void *dct_table, JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col);
-
-extern const int jconst_idct_float_sse[];
-EXTERN(void) jsimd_idct_float_sse
- (void *dct_table, JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col);
-
-extern const int jconst_idct_float_sse2[];
-EXTERN(void) jsimd_idct_float_sse2
- (void *dct_table, JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col);
-
-/* Huffman coding */
-extern const int jconst_huff_encode_one_block[];
-EXTERN(JOCTET *) jsimd_huff_encode_one_block_sse2
- (void *state, JOCTET *buffer, JCOEFPTR block, int last_dc_val,
- c_derived_tbl *dctbl, c_derived_tbl *actbl);
-
-EXTERN(JOCTET *) jsimd_huff_encode_one_block_neon
- (void *state, JOCTET *buffer, JCOEFPTR block, int last_dc_val,
- c_derived_tbl *dctbl, c_derived_tbl *actbl);
-
-#ifndef NEON_INTRINSICS
-
-EXTERN(JOCTET *) jsimd_huff_encode_one_block_neon_slowtbl
- (void *state, JOCTET *buffer, JCOEFPTR block, int last_dc_val,
- c_derived_tbl *dctbl, c_derived_tbl *actbl);
-
-#endif
-
-/* Progressive Huffman encoding */
-EXTERN(void) jsimd_encode_mcu_AC_first_prepare_sse2
- (const JCOEF *block, const int *jpeg_natural_order_start, int Sl, int Al,
- JCOEF *values, size_t *zerobits);
-
-EXTERN(void) jsimd_encode_mcu_AC_first_prepare_neon
- (const JCOEF *block, const int *jpeg_natural_order_start, int Sl, int Al,
- JCOEF *values, size_t *zerobits);
-
-EXTERN(int) jsimd_encode_mcu_AC_refine_prepare_sse2
- (const JCOEF *block, const int *jpeg_natural_order_start, int Sl, int Al,
- JCOEF *absvalues, size_t *bits);
-
-EXTERN(int) jsimd_encode_mcu_AC_refine_prepare_neon
- (const JCOEF *block, const int *jpeg_natural_order_start, int Sl, int Al,
- JCOEF *absvalues, size_t *bits);
diff --git a/contrib/libs/libjpeg-turbo/simd/nasm/jcolsamp.inc b/contrib/libs/libjpeg-turbo/simd/nasm/jcolsamp.inc
deleted file mode 100644
index 6f6d7f29d1..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/nasm/jcolsamp.inc
+++ /dev/null
@@ -1,135 +0,0 @@
-;
-; jcolsamp.inc - private declarations for color conversion & up/downsampling
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2015, Intel Corporation.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-
-; --------------------------------------------------------------------------
-
-; pseudo-resisters to make ordering of RGB configurable
-;
-%if RGB_RED == 0
-%define mmA mm0
-%define mmB mm1
-%define xmmA xmm0
-%define xmmB xmm1
-%define ymmA ymm0
-%define ymmB ymm1
-%elif RGB_GREEN == 0
-%define mmA mm2
-%define mmB mm3
-%define xmmA xmm2
-%define xmmB xmm3
-%define ymmA ymm2
-%define ymmB ymm3
-%elif RGB_BLUE == 0
-%define mmA mm4
-%define mmB mm5
-%define xmmA xmm4
-%define xmmB xmm5
-%define ymmA ymm4
-%define ymmB ymm5
-%else
-%define mmA mm6
-%define mmB mm7
-%define xmmA xmm6
-%define xmmB xmm7
-%define ymmA ymm6
-%define ymmB ymm7
-%endif
-
-%if RGB_RED == 1
-%define mmC mm0
-%define mmD mm1
-%define xmmC xmm0
-%define xmmD xmm1
-%define ymmC ymm0
-%define ymmD ymm1
-%elif RGB_GREEN == 1
-%define mmC mm2
-%define mmD mm3
-%define xmmC xmm2
-%define xmmD xmm3
-%define ymmC ymm2
-%define ymmD ymm3
-%elif RGB_BLUE == 1
-%define mmC mm4
-%define mmD mm5
-%define xmmC xmm4
-%define xmmD xmm5
-%define ymmC ymm4
-%define ymmD ymm5
-%else
-%define mmC mm6
-%define mmD mm7
-%define xmmC xmm6
-%define xmmD xmm7
-%define ymmC ymm6
-%define ymmD ymm7
-%endif
-
-%if RGB_RED == 2
-%define mmE mm0
-%define mmF mm1
-%define xmmE xmm0
-%define xmmF xmm1
-%define ymmE ymm0
-%define ymmF ymm1
-%elif RGB_GREEN == 2
-%define mmE mm2
-%define mmF mm3
-%define xmmE xmm2
-%define xmmF xmm3
-%define ymmE ymm2
-%define ymmF ymm3
-%elif RGB_BLUE == 2
-%define mmE mm4
-%define mmF mm5
-%define xmmE xmm4
-%define xmmF xmm5
-%define ymmE ymm4
-%define ymmF ymm5
-%else
-%define mmE mm6
-%define mmF mm7
-%define xmmE xmm6
-%define xmmF xmm7
-%define ymmE ymm6
-%define ymmF ymm7
-%endif
-
-%if RGB_RED == 3
-%define mmG mm0
-%define mmH mm1
-%define xmmG xmm0
-%define xmmH xmm1
-%define ymmG ymm0
-%define ymmH ymm1
-%elif RGB_GREEN == 3
-%define mmG mm2
-%define mmH mm3
-%define xmmG xmm2
-%define xmmH xmm3
-%define ymmG ymm2
-%define ymmH ymm3
-%elif RGB_BLUE == 3
-%define mmG mm4
-%define mmH mm5
-%define xmmG xmm4
-%define xmmH xmm5
-%define ymmG ymm4
-%define ymmH ymm5
-%else
-%define mmG mm6
-%define mmH mm7
-%define xmmG xmm6
-%define xmmH xmm7
-%define ymmG ymm6
-%define ymmH ymm7
-%endif
-
-; --------------------------------------------------------------------------
diff --git a/contrib/libs/libjpeg-turbo/simd/nasm/jdct.inc b/contrib/libs/libjpeg-turbo/simd/nasm/jdct.inc
deleted file mode 100644
index 9192f66f0c..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/nasm/jdct.inc
+++ /dev/null
@@ -1,31 +0,0 @@
-;
-; jdct.inc - private declarations for forward & reverse DCT subsystems
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2018, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-
-; Each IDCT routine is responsible for range-limiting its results and
-; converting them to unsigned form (0..MAXJSAMPLE). The raw outputs could
-; be quite far out of range if the input data is corrupt, so a bulletproof
-; range-limiting step is required. We use a mask-and-table-lookup method
-; to do the combined operations quickly.
-;
-%define RANGE_MASK (MAXJSAMPLE * 4 + 3) ; 2 bits wider than legal samples
-
-%define ROW(n, b, s) ((b) + (n) * (s))
-%define COL(n, b, s) ((b) + (n) * (s) * DCTSIZE)
-
-%define DWBLOCK(m, n, b, s) \
- ((b) + (m) * DCTSIZE * (s) + (n) * SIZEOF_DWORD)
-%define MMBLOCK(m, n, b, s) \
- ((b) + (m) * DCTSIZE * (s) + (n) * SIZEOF_MMWORD)
-%define XMMBLOCK(m, n, b, s) \
- ((b) + (m) * DCTSIZE * (s) + (n) * SIZEOF_XMMWORD)
-%define YMMBLOCK(m, n, b, s) \
- ((b) + (m) * DCTSIZE * (s) + (n) * SIZEOF_YMMWORD)
-
-; --------------------------------------------------------------------------
diff --git a/contrib/libs/libjpeg-turbo/simd/nasm/jsimdcfg.inc b/contrib/libs/libjpeg-turbo/simd/nasm/jsimdcfg.inc
deleted file mode 100644
index 667024a5f9..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/nasm/jsimdcfg.inc
+++ /dev/null
@@ -1,93 +0,0 @@
-;
-; Automatically generated include file from jsimdcfg.inc.h
-;
-;
-; -- jpeglib.h
-;
-%define DCTSIZE 8
-%define DCTSIZE2 64
-;
-; -- jmorecfg.h
-;
-%define RGB_RED 0
-%define RGB_GREEN 1
-%define RGB_BLUE 2
-%define RGB_PIXELSIZE 3
-%define EXT_RGB_RED 0
-%define EXT_RGB_GREEN 1
-%define EXT_RGB_BLUE 2
-%define EXT_RGB_PIXELSIZE 3
-%define EXT_RGBX_RED 0
-%define EXT_RGBX_GREEN 1
-%define EXT_RGBX_BLUE 2
-%define EXT_RGBX_PIXELSIZE 4
-%define EXT_BGR_RED 2
-%define EXT_BGR_GREEN 1
-%define EXT_BGR_BLUE 0
-%define EXT_BGR_PIXELSIZE 3
-%define EXT_BGRX_RED 2
-%define EXT_BGRX_GREEN 1
-%define EXT_BGRX_BLUE 0
-%define EXT_BGRX_PIXELSIZE 4
-%define EXT_XBGR_RED 3
-%define EXT_XBGR_GREEN 2
-%define EXT_XBGR_BLUE 1
-%define EXT_XBGR_PIXELSIZE 4
-%define EXT_XRGB_RED 1
-%define EXT_XRGB_GREEN 2
-%define EXT_XRGB_BLUE 3
-%define EXT_XRGB_PIXELSIZE 4
-%define RGBX_FILLER_0XFF 1
-; Representation of a single sample (pixel element value).
-; On this SIMD implementation, this must be 'unsigned char'.
-;
-%define JSAMPLE byte ; unsigned char
-%define SIZEOF_JSAMPLE SIZEOF_BYTE ; sizeof(JSAMPLE)
-%define CENTERJSAMPLE 128
-; Representation of a DCT frequency coefficient.
-; On this SIMD implementation, this must be 'short'.
-;
-%define JCOEF word ; short
-%define SIZEOF_JCOEF SIZEOF_WORD ; sizeof(JCOEF)
-; Datatype used for image dimensions.
-; On this SIMD implementation, this must be 'unsigned int'.
-;
-%define JDIMENSION dword ; unsigned int
-%define SIZEOF_JDIMENSION SIZEOF_DWORD ; sizeof(JDIMENSION)
-%define JSAMPROW POINTER ; JSAMPLE * (jpeglib.h)
-%define JSAMPARRAY POINTER ; JSAMPROW * (jpeglib.h)
-%define JSAMPIMAGE POINTER ; JSAMPARRAY * (jpeglib.h)
-%define JCOEFPTR POINTER ; JCOEF * (jpeglib.h)
-%define SIZEOF_JSAMPROW SIZEOF_POINTER ; sizeof(JSAMPROW)
-%define SIZEOF_JSAMPARRAY SIZEOF_POINTER ; sizeof(JSAMPARRAY)
-%define SIZEOF_JSAMPIMAGE SIZEOF_POINTER ; sizeof(JSAMPIMAGE)
-%define SIZEOF_JCOEFPTR SIZEOF_POINTER ; sizeof(JCOEFPTR)
-;
-; -- jdct.h
-;
-; A forward DCT routine is given a pointer to a work area of type DCTELEM[];
-; the DCT is to be performed in-place in that buffer.
-; To maximize parallelism, Type DCTELEM is changed to short (originally, int).
-;
-%define DCTELEM word ; short
-%define SIZEOF_DCTELEM SIZEOF_WORD ; sizeof(DCTELEM)
-%define float FP32 ; float
-%define SIZEOF_FAST_FLOAT SIZEOF_FP32 ; sizeof(float)
-; To maximize parallelism, Type short is changed to short.
-;
-%define ISLOW_MULT_TYPE word ; must be short
-%define SIZEOF_ISLOW_MULT_TYPE SIZEOF_WORD ; sizeof(ISLOW_MULT_TYPE)
-%define IFAST_MULT_TYPE word ; must be short
-%define SIZEOF_IFAST_MULT_TYPE SIZEOF_WORD ; sizeof(IFAST_MULT_TYPE)
-%define IFAST_SCALE_BITS 2 ; fractional bits in scale factors
-%define FLOAT_MULT_TYPE FP32 ; must be float
-%define SIZEOF_FLOAT_MULT_TYPE SIZEOF_FP32 ; sizeof(FLOAT_MULT_TYPE)
-;
-; -- jsimd.h
-;
-%define JSIMD_NONE 0x00
-%define JSIMD_MMX 0x01
-%define JSIMD_3DNOW 0x02
-%define JSIMD_SSE 0x04
-%define JSIMD_SSE2 0x08
-%define JSIMD_AVX2 0x80
diff --git a/contrib/libs/libjpeg-turbo/simd/nasm/jsimdcfg.inc.h b/contrib/libs/libjpeg-turbo/simd/nasm/jsimdcfg.inc.h
deleted file mode 100644
index bf2a45ad50..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/nasm/jsimdcfg.inc.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * This file generates the include file for the assembly
- * implementations by abusing the C preprocessor.
- *
- * Note: Some things are manually defined as they need to
- * be mapped to NASM types.
- */
-
-;
-; Automatically generated include file from jsimdcfg.inc.h
-;
-
-#define JPEG_INTERNALS
-
-#include "../jpeglib.h"
-#include "../jconfig.h"
-#include "../jmorecfg.h"
-#include "jsimd.h"
-
-;
-; -- jpeglib.h
-;
-
-%define _cpp_protection_DCTSIZE DCTSIZE
-%define _cpp_protection_DCTSIZE2 DCTSIZE2
-
-;
-; -- jmorecfg.h
-;
-
-%define _cpp_protection_RGB_RED RGB_RED
-%define _cpp_protection_RGB_GREEN RGB_GREEN
-%define _cpp_protection_RGB_BLUE RGB_BLUE
-%define _cpp_protection_RGB_PIXELSIZE RGB_PIXELSIZE
-
-%define _cpp_protection_EXT_RGB_RED EXT_RGB_RED
-%define _cpp_protection_EXT_RGB_GREEN EXT_RGB_GREEN
-%define _cpp_protection_EXT_RGB_BLUE EXT_RGB_BLUE
-%define _cpp_protection_EXT_RGB_PIXELSIZE EXT_RGB_PIXELSIZE
-
-%define _cpp_protection_EXT_RGBX_RED EXT_RGBX_RED
-%define _cpp_protection_EXT_RGBX_GREEN EXT_RGBX_GREEN
-%define _cpp_protection_EXT_RGBX_BLUE EXT_RGBX_BLUE
-%define _cpp_protection_EXT_RGBX_PIXELSIZE EXT_RGBX_PIXELSIZE
-
-%define _cpp_protection_EXT_BGR_RED EXT_BGR_RED
-%define _cpp_protection_EXT_BGR_GREEN EXT_BGR_GREEN
-%define _cpp_protection_EXT_BGR_BLUE EXT_BGR_BLUE
-%define _cpp_protection_EXT_BGR_PIXELSIZE EXT_BGR_PIXELSIZE
-
-%define _cpp_protection_EXT_BGRX_RED EXT_BGRX_RED
-%define _cpp_protection_EXT_BGRX_GREEN EXT_BGRX_GREEN
-%define _cpp_protection_EXT_BGRX_BLUE EXT_BGRX_BLUE
-%define _cpp_protection_EXT_BGRX_PIXELSIZE EXT_BGRX_PIXELSIZE
-
-%define _cpp_protection_EXT_XBGR_RED EXT_XBGR_RED
-%define _cpp_protection_EXT_XBGR_GREEN EXT_XBGR_GREEN
-%define _cpp_protection_EXT_XBGR_BLUE EXT_XBGR_BLUE
-%define _cpp_protection_EXT_XBGR_PIXELSIZE EXT_XBGR_PIXELSIZE
-
-%define _cpp_protection_EXT_XRGB_RED EXT_XRGB_RED
-%define _cpp_protection_EXT_XRGB_GREEN EXT_XRGB_GREEN
-%define _cpp_protection_EXT_XRGB_BLUE EXT_XRGB_BLUE
-%define _cpp_protection_EXT_XRGB_PIXELSIZE EXT_XRGB_PIXELSIZE
-
-%define RGBX_FILLER_0XFF 1
-
-; Representation of a single sample (pixel element value).
-; On this SIMD implementation, this must be 'unsigned char'.
-;
-
-%define JSAMPLE byte ; unsigned char
-%define SIZEOF_JSAMPLE SIZEOF_BYTE ; sizeof(JSAMPLE)
-
-%define _cpp_protection_CENTERJSAMPLE CENTERJSAMPLE
-
-; Representation of a DCT frequency coefficient.
-; On this SIMD implementation, this must be 'short'.
-;
-%define JCOEF word ; short
-%define SIZEOF_JCOEF SIZEOF_WORD ; sizeof(JCOEF)
-
-; Datatype used for image dimensions.
-; On this SIMD implementation, this must be 'unsigned int'.
-;
-%define JDIMENSION dword ; unsigned int
-%define SIZEOF_JDIMENSION SIZEOF_DWORD ; sizeof(JDIMENSION)
-
-%define JSAMPROW POINTER ; JSAMPLE * (jpeglib.h)
-%define JSAMPARRAY POINTER ; JSAMPROW * (jpeglib.h)
-%define JSAMPIMAGE POINTER ; JSAMPARRAY * (jpeglib.h)
-%define JCOEFPTR POINTER ; JCOEF * (jpeglib.h)
-%define SIZEOF_JSAMPROW SIZEOF_POINTER ; sizeof(JSAMPROW)
-%define SIZEOF_JSAMPARRAY SIZEOF_POINTER ; sizeof(JSAMPARRAY)
-%define SIZEOF_JSAMPIMAGE SIZEOF_POINTER ; sizeof(JSAMPIMAGE)
-%define SIZEOF_JCOEFPTR SIZEOF_POINTER ; sizeof(JCOEFPTR)
-
-;
-; -- jdct.h
-;
-
-; A forward DCT routine is given a pointer to a work area of type DCTELEM[];
-; the DCT is to be performed in-place in that buffer.
-; To maximize parallelism, Type DCTELEM is changed to short (originally, int).
-;
-%define DCTELEM word ; short
-%define SIZEOF_DCTELEM SIZEOF_WORD ; sizeof(DCTELEM)
-
-%define FAST_FLOAT FP32 ; float
-%define SIZEOF_FAST_FLOAT SIZEOF_FP32 ; sizeof(FAST_FLOAT)
-
-; To maximize parallelism, Type MULTIPLIER is changed to short.
-;
-%define ISLOW_MULT_TYPE word ; must be short
-%define SIZEOF_ISLOW_MULT_TYPE SIZEOF_WORD ; sizeof(ISLOW_MULT_TYPE)
-
-%define IFAST_MULT_TYPE word ; must be short
-%define SIZEOF_IFAST_MULT_TYPE SIZEOF_WORD ; sizeof(IFAST_MULT_TYPE)
-%define IFAST_SCALE_BITS 2 ; fractional bits in scale factors
-
-%define FLOAT_MULT_TYPE FP32 ; must be float
-%define SIZEOF_FLOAT_MULT_TYPE SIZEOF_FP32 ; sizeof(FLOAT_MULT_TYPE)
-
-;
-; -- jsimd.h
-;
-
-%define _cpp_protection_JSIMD_NONE JSIMD_NONE
-%define _cpp_protection_JSIMD_MMX JSIMD_MMX
-%define _cpp_protection_JSIMD_3DNOW JSIMD_3DNOW
-%define _cpp_protection_JSIMD_SSE JSIMD_SSE
-%define _cpp_protection_JSIMD_SSE2 JSIMD_SSE2
-%define _cpp_protection_JSIMD_AVX2 JSIMD_AVX2
diff --git a/contrib/libs/libjpeg-turbo/simd/nasm/jsimdext.inc b/contrib/libs/libjpeg-turbo/simd/nasm/jsimdext.inc
deleted file mode 100644
index d8a50ed8e2..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/nasm/jsimdext.inc
+++ /dev/null
@@ -1,520 +0,0 @@
-;
-; jsimdext.inc - common declarations
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2010, 2016, 2018-2019, D. R. Commander.
-; Copyright (C) 2018, Matthieu Darbois.
-; Copyright (C) 2018, Matthias Räncker.
-;
-; Based on the x86 SIMD extension for IJG JPEG library - version 1.02
-;
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-;
-; This software is provided 'as-is', without any express or implied
-; warranty. In no event will the authors be held liable for any damages
-; arising from the use of this software.
-;
-; Permission is granted to anyone to use this software for any purpose,
-; including commercial applications, and to alter it and redistribute it
-; freely, subject to the following restrictions:
-;
-; 1. The origin of this software must not be misrepresented; you must not
-; claim that you wrote the original software. If you use this software
-; in a product, an acknowledgment in the product documentation would be
-; appreciated but is not required.
-; 2. Altered source versions must be plainly marked as such, and must not be
-; misrepresented as being the original software.
-; 3. This notice may not be removed or altered from any source distribution.
-
-; ==========================================================================
-; System-dependent configurations
-
-%ifdef WIN32 ; ----(nasm -fwin32 -DWIN32 ...)--------
-; * Microsoft Visual C++
-; * MinGW (Minimalist GNU for Windows)
-; * CygWin
-; * LCC-Win32
-
-; -- segment definition --
-;
-%ifdef __YASM_VER__
-%define SEG_TEXT .text align=32
-%define SEG_CONST .rdata align=32
-%else
-%define SEG_TEXT .text align=32 public use32 class=CODE
-%define SEG_CONST .rdata align=32 public use32 class=CONST
-%endif
-
-%elifdef WIN64 ; ----(nasm -fwin64 -DWIN64 ...)--------
-; * Microsoft Visual C++
-
-; -- segment definition --
-;
-%ifdef __YASM_VER__
-%define SEG_TEXT .text align=32
-%define SEG_CONST .rdata align=32
-%else
-%define SEG_TEXT .text align=32 public use64 class=CODE
-%define SEG_CONST .rdata align=32 public use64 class=CONST
-%endif
-%define EXTN(name) name ; foo() -> foo
-
-%elifdef OBJ32 ; ----(nasm -fobj -DOBJ32 ...)----------
-; * Borland C++ (Win32)
-
-; -- segment definition --
-;
-%define SEG_TEXT _text align=32 public use32 class=CODE
-%define SEG_CONST _data align=32 public use32 class=DATA
-
-%elifdef UNIX ; ----(nasm -felf[64] -DUNIX ...)------------
-; * Linux
-; * *BSD family Unix using elf format
-; * Unix System V, including Solaris x86, UnixWare and SCO Unix
-
-; mark stack as non-executable
-section .note.GNU-stack noalloc noexec nowrite progbits
-
-; -- segment definition --
-;
-%ifdef _x86_64_
-%define SEG_TEXT .text progbits align=32
-%define SEG_CONST .rodata progbits align=32
-%else
-%define SEG_TEXT .text progbits alloc exec nowrite align=32
-%define SEG_CONST .rodata progbits alloc noexec nowrite align=32
-%endif
-
-; To make the code position-independent, append -DPIC to the commandline
-;
-%define GOT_SYMBOL _GLOBAL_OFFSET_TABLE_ ; ELF supports PIC
-%define EXTN(name) name ; foo() -> foo
-
-%elifdef AOUT ; ----(nasm -faoutb/aout -DAOUT ...)----
-; * Older Linux using a.out format (nasm -f aout -DAOUT ...)
-; * *BSD family Unix using a.out format (nasm -f aoutb -DAOUT ...)
-
-; -- segment definition --
-;
-%define SEG_TEXT .text
-%define SEG_CONST .data
-
-; To make the code position-independent, append -DPIC to the commandline
-;
-%define GOT_SYMBOL __GLOBAL_OFFSET_TABLE_ ; BSD-style a.out supports PIC
-
-%elifdef MACHO ; ----(nasm -fmacho -DMACHO ...)--------
-; * NeXTstep/OpenStep/Rhapsody/Darwin/MacOS X (Mach-O format)
-
-; -- segment definition --
-;
-%define SEG_TEXT .text ;align=32 ; nasm doesn't accept align=32. why?
-%define SEG_CONST .rodata align=32
-
-; The generation of position-independent code (PIC) is the default on Darwin.
-;
-%define PIC
-%define GOT_SYMBOL _MACHO_PIC_ ; Mach-O style code-relative addressing
-
-%else ; ----(Other case)----------------------
-
-; -- segment definition --
-;
-%define SEG_TEXT .text
-%define SEG_CONST .data
-
-%endif ; ----------------------------------------------
-
-; ==========================================================================
-
-; --------------------------------------------------------------------------
-; Common types
-;
-%ifdef _x86_64_
-%ifnidn __OUTPUT_FORMAT__, elfx32
-%define POINTER qword ; general pointer type
-%define SIZEOF_POINTER SIZEOF_QWORD ; sizeof(POINTER)
-%define POINTER_BIT QWORD_BIT ; sizeof(POINTER)*BYTE_BIT
-%define resp resq
-%define dp dq
-%define raxp rax
-%define rbxp rbx
-%define rcxp rcx
-%define rdxp rdx
-%define rsip rsi
-%define rdip rdi
-%define rbpp rbp
-%define rspp rsp
-%define r8p r8
-%define r9p r9
-%define r10p r10
-%define r11p r11
-%define r12p r12
-%define r13p r13
-%define r14p r14
-%define r15p r15
-%endif
-%endif
-%ifndef raxp
-%define POINTER dword ; general pointer type
-%define SIZEOF_POINTER SIZEOF_DWORD ; sizeof(POINTER)
-%define POINTER_BIT DWORD_BIT ; sizeof(POINTER)*BYTE_BIT
-%define resp resd
-%define dp dd
-; x86_64 ILP32 ABI (x32)
-%define raxp eax
-%define rbxp ebx
-%define rcxp ecx
-%define rdxp edx
-%define rsip esi
-%define rdip edi
-%define rbpp ebp
-%define rspp esp
-%define r8p r8d
-%define r9p r9d
-%define r10p r10d
-%define r11p r11d
-%define r12p r12d
-%define r13p r13d
-%define r14p r14d
-%define r15p r15d
-%endif
-
-%define INT dword ; signed integer type
-%define SIZEOF_INT SIZEOF_DWORD ; sizeof(INT)
-%define INT_BIT DWORD_BIT ; sizeof(INT)*BYTE_BIT
-
-%define FP32 dword ; IEEE754 single
-%define SIZEOF_FP32 SIZEOF_DWORD ; sizeof(FP32)
-%define FP32_BIT DWORD_BIT ; sizeof(FP32)*BYTE_BIT
-
-%define MMWORD qword ; int64 (MMX register)
-%define SIZEOF_MMWORD SIZEOF_QWORD ; sizeof(MMWORD)
-%define MMWORD_BIT QWORD_BIT ; sizeof(MMWORD)*BYTE_BIT
-
-; NASM is buggy and doesn't properly handle operand sizes for SSE
-; instructions, so for now we have to define XMMWORD as blank.
-%define XMMWORD ; int128 (SSE register)
-%define SIZEOF_XMMWORD SIZEOF_OWORD ; sizeof(XMMWORD)
-%define XMMWORD_BIT OWORD_BIT ; sizeof(XMMWORD)*BYTE_BIT
-
-%define YMMWORD ; int256 (AVX register)
-%define SIZEOF_YMMWORD SIZEOF_YWORD ; sizeof(YMMWORD)
-%define YMMWORD_BIT YWORD_BIT ; sizeof(YMMWORD)*BYTE_BIT
-
-; Similar hacks for when we load a dword or MMWORD into an xmm# register
-%define XMM_DWORD
-%define XMM_MMWORD
-
-%define SIZEOF_BYTE 1 ; sizeof(byte)
-%define SIZEOF_WORD 2 ; sizeof(word)
-%define SIZEOF_DWORD 4 ; sizeof(dword)
-%define SIZEOF_QWORD 8 ; sizeof(qword)
-%define SIZEOF_OWORD 16 ; sizeof(oword)
-%define SIZEOF_YWORD 32 ; sizeof(yword)
-
-%define BYTE_BIT 8 ; CHAR_BIT in C
-%define WORD_BIT 16 ; sizeof(word)*BYTE_BIT
-%define DWORD_BIT 32 ; sizeof(dword)*BYTE_BIT
-%define QWORD_BIT 64 ; sizeof(qword)*BYTE_BIT
-%define OWORD_BIT 128 ; sizeof(oword)*BYTE_BIT
-%define YWORD_BIT 256 ; sizeof(yword)*BYTE_BIT
-
-; --------------------------------------------------------------------------
-; External Symbol Name
-;
-%ifndef EXTN
-%define EXTN(name) _ %+ name ; foo() -> _foo
-%endif
-
-; --------------------------------------------------------------------------
-; Hidden symbols
-;
-%ifdef UNIX ; ----(nasm -felf[64] -DUNIX ...)--------
-%define GLOBAL_FUNCTION(name) global EXTN(name):function hidden
-%define GLOBAL_DATA(name) global EXTN(name):data hidden
-%elifdef MACHO ; ----(nasm -fmacho -DMACHO ...)--------
-%ifdef __YASM_VER__
-%define GLOBAL_FUNCTION(name) global EXTN(name):private_extern
-%define GLOBAL_DATA(name) global EXTN(name):private_extern
-%else
-%if __NASM_VERSION_ID__ >= 0x020E0000
-%define GLOBAL_FUNCTION(name) global EXTN(name):private_extern
-%define GLOBAL_DATA(name) global EXTN(name):private_extern
-%endif
-%endif
-%endif
-
-%ifndef GLOBAL_FUNCTION
-%define GLOBAL_FUNCTION(name) global EXTN(name)
-%endif
-%ifndef GLOBAL_DATA
-%define GLOBAL_DATA(name) global EXTN(name)
-%endif
-
-; --------------------------------------------------------------------------
-; Macros for position-independent code (PIC) support
-;
-%ifndef GOT_SYMBOL
-%undef PIC
-%endif
-
-%ifdef PIC ; -------------------------------------------
-
-%ifidn GOT_SYMBOL, _MACHO_PIC_ ; --------------------
-
-; At present, nasm doesn't seem to support PIC generation for Mach-O.
-; The PIC support code below is a little tricky.
-
- SECTION SEG_CONST
-const_base:
-
-%define GOTOFF(got, sym) (got) + (sym) - const_base
-
-%imacro get_GOT 1
- ; NOTE: this macro destroys ecx resister.
- call %%geteip
- add ecx, byte (%%ref - $)
- jmp short %%adjust
-%%geteip:
- mov ecx, POINTER [esp]
- ret
-%%adjust:
- push ebp
- xor ebp, ebp ; ebp = 0
-%ifidni %1, ebx ; (%1 == ebx)
- ; db 0x8D,0x9C + jmp near const_base =
- ; lea ebx, [ecx+ebp*8+(const_base-%%ref)] ; 8D,9C,E9,(offset32)
- db 0x8D, 0x9C ; 8D,9C
- jmp near const_base ; E9,(const_base-%%ref)
-%%ref:
-%else ; (%1 != ebx)
- ; db 0x8D,0x8C + jmp near const_base =
- ; lea ecx, [ecx+ebp*8+(const_base-%%ref)] ; 8D,8C,E9,(offset32)
- db 0x8D, 0x8C ; 8D,8C
- jmp near const_base ; E9,(const_base-%%ref)
-%%ref:
- mov %1, ecx
-%endif ; (%1 == ebx)
- pop ebp
-%endmacro
-
-%else ; GOT_SYMBOL != _MACHO_PIC_ ----------------
-
-%define GOTOFF(got, sym) (got) + (sym) wrt ..gotoff
-
-%imacro get_GOT 1
- extern GOT_SYMBOL
- call %%geteip
- add %1, GOT_SYMBOL + $$ - $ wrt ..gotpc
- jmp short %%done
-%%geteip:
- mov %1, POINTER [esp]
- ret
-%%done:
-%endmacro
-
-%endif ; GOT_SYMBOL == _MACHO_PIC_ ----------------
-
-%imacro pushpic 1.nolist
- push %1
-%endmacro
-%imacro poppic 1.nolist
- pop %1
-%endmacro
-%imacro movpic 2.nolist
- mov %1, %2
-%endmacro
-
-%else ; !PIC -----------------------------------------
-
-%define GOTOFF(got, sym) (sym)
-
-%imacro get_GOT 1.nolist
-%endmacro
-%imacro pushpic 1.nolist
-%endmacro
-%imacro poppic 1.nolist
-%endmacro
-%imacro movpic 2.nolist
-%endmacro
-
-%endif ; PIC -----------------------------------------
-
-; --------------------------------------------------------------------------
-; Align the next instruction on {2,4,8,16,..}-byte boundary.
-; ".balign n,,m" in GNU as
-;
-%define MSKLE(x, y) (~(((y) & 0xFFFF) - ((x) & 0xFFFF)) >> 16)
-%define FILLB(b, n) (($$-(b)) & ((n)-1))
-
-%imacro alignx 1-2.nolist 0xFFFF
-%%bs: \
- times MSKLE(FILLB(%%bs, %1), %2) & MSKLE(16, FILLB($, %1)) & FILLB($, %1) \
- db 0x90 ; nop
- times MSKLE(FILLB(%%bs, %1), %2) & FILLB($, %1) / 9 \
- db 0x8D, 0x9C, 0x23, 0x00, 0x00, 0x00, 0x00 ; lea ebx,[ebx+0x00000000]
- times MSKLE(FILLB(%%bs, %1), %2) & FILLB($, %1) / 7 \
- db 0x8D, 0xAC, 0x25, 0x00, 0x00, 0x00, 0x00 ; lea ebp,[ebp+0x00000000]
- times MSKLE(FILLB(%%bs, %1), %2) & FILLB($, %1) / 6 \
- db 0x8D, 0xAD, 0x00, 0x00, 0x00, 0x00 ; lea ebp,[ebp+0x00000000]
- times MSKLE(FILLB(%%bs, %1), %2) & FILLB($, %1) / 4 \
- db 0x8D, 0x6C, 0x25, 0x00 ; lea ebp,[ebp+0x00]
- times MSKLE(FILLB(%%bs, %1), %2) & FILLB($, %1) / 3 \
- db 0x8D, 0x6D, 0x00 ; lea ebp,[ebp+0x00]
- times MSKLE(FILLB(%%bs, %1), %2) & FILLB($, %1) / 2 \
- db 0x8B, 0xED ; mov ebp,ebp
- times MSKLE(FILLB(%%bs, %1), %2) & FILLB($, %1) / 1 \
- db 0x90 ; nop
-%endmacro
-
-; Align the next data on {2,4,8,16,..}-byte boundary.
-;
-%imacro alignz 1.nolist
- align %1, db 0 ; filling zeros
-%endmacro
-
-%ifdef _x86_64_
-
-%ifdef WIN64
-
-%imacro collect_args 1
- sub rsp, SIZEOF_XMMWORD
- movaps XMMWORD [rsp], xmm6
- sub rsp, SIZEOF_XMMWORD
- movaps XMMWORD [rsp], xmm7
- mov r10, rcx
-%if %1 > 1
- mov r11, rdx
-%endif
-%if %1 > 2
- push r12
- mov r12, r8
-%endif
-%if %1 > 3
- push r13
- mov r13, r9
-%endif
-%if %1 > 4
- push r14
- mov r14, [rax+48]
-%endif
-%if %1 > 5
- push r15
- mov r15, [rax+56]
-%endif
- push rsi
- push rdi
-%endmacro
-
-%imacro uncollect_args 1
- pop rdi
- pop rsi
-%if %1 > 5
- pop r15
-%endif
-%if %1 > 4
- pop r14
-%endif
-%if %1 > 3
- pop r13
-%endif
-%if %1 > 2
- pop r12
-%endif
- movaps xmm7, XMMWORD [rsp]
- add rsp, SIZEOF_XMMWORD
- movaps xmm6, XMMWORD [rsp]
- add rsp, SIZEOF_XMMWORD
-%endmacro
-
-%imacro push_xmm 1
- sub rsp, %1 * SIZEOF_XMMWORD
- movaps XMMWORD [rsp+0*SIZEOF_XMMWORD], xmm8
-%if %1 > 1
- movaps XMMWORD [rsp+1*SIZEOF_XMMWORD], xmm9
-%endif
-%if %1 > 2
- movaps XMMWORD [rsp+2*SIZEOF_XMMWORD], xmm10
-%endif
-%if %1 > 3
- movaps XMMWORD [rsp+3*SIZEOF_XMMWORD], xmm11
-%endif
-%endmacro
-
-%imacro pop_xmm 1
- movaps xmm8, XMMWORD [rsp+0*SIZEOF_XMMWORD]
-%if %1 > 1
- movaps xmm9, XMMWORD [rsp+1*SIZEOF_XMMWORD]
-%endif
-%if %1 > 2
- movaps xmm10, XMMWORD [rsp+2*SIZEOF_XMMWORD]
-%endif
-%if %1 > 3
- movaps xmm11, XMMWORD [rsp+3*SIZEOF_XMMWORD]
-%endif
- add rsp, %1 * SIZEOF_XMMWORD
-%endmacro
-
-%else
-
-%imacro collect_args 1
- push r10
- mov r10, rdi
-%if %1 > 1
- push r11
- mov r11, rsi
-%endif
-%if %1 > 2
- push r12
- mov r12, rdx
-%endif
-%if %1 > 3
- push r13
- mov r13, rcx
-%endif
-%if %1 > 4
- push r14
- mov r14, r8
-%endif
-%if %1 > 5
- push r15
- mov r15, r9
-%endif
-%endmacro
-
-%imacro uncollect_args 1
-%if %1 > 5
- pop r15
-%endif
-%if %1 > 4
- pop r14
-%endif
-%if %1 > 3
- pop r13
-%endif
-%if %1 > 2
- pop r12
-%endif
-%if %1 > 1
- pop r11
-%endif
- pop r10
-%endmacro
-
-%imacro push_xmm 1
-%endmacro
-
-%imacro pop_xmm 1
-%endmacro
-
-%endif
-
-%endif
-
-; --------------------------------------------------------------------------
-; Defines picked up from the C headers
-;
-%include "jsimdcfg.inc"
-
-; --------------------------------------------------------------------------
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jccolext-avx2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jccolext-avx2.asm
deleted file mode 100644
index ffb527db00..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jccolext-avx2.asm
+++ /dev/null
@@ -1,559 +0,0 @@
-;
-; jccolext.asm - colorspace conversion (64-bit AVX2)
-;
-; Copyright (C) 2009, 2016, D. R. Commander.
-; Copyright (C) 2015, Intel Corporation.
-; Copyright (C) 2018, Matthias Räncker.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jcolsamp.inc"
-
-; --------------------------------------------------------------------------
-;
-; Convert some rows of samples to the output colorspace.
-;
-; GLOBAL(void)
-; jsimd_rgb_ycc_convert_avx2(JDIMENSION img_width, JSAMPARRAY input_buf,
-; JSAMPIMAGE output_buf, JDIMENSION output_row,
-; int num_rows);
-;
-
-; r10d = JDIMENSION img_width
-; r11 = JSAMPARRAY input_buf
-; r12 = JSAMPIMAGE output_buf
-; r13d = JDIMENSION output_row
-; r14d = int num_rows
-
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_YMMWORD ; ymmword wk[WK_NUM]
-%define WK_NUM 8
-
- align 32
- GLOBAL_FUNCTION(jsimd_rgb_ycc_convert_avx2)
-
-EXTN(jsimd_rgb_ycc_convert_avx2):
- push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
- and rsp, byte (-SIZEOF_YMMWORD) ; align to 256 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
- collect_args 5
- push rbx
-
- mov ecx, r10d
- test rcx, rcx
- jz near .return
-
- push rcx
-
- mov rsi, r12
- mov ecx, r13d
- mov rdip, JSAMPARRAY [rsi+0*SIZEOF_JSAMPARRAY]
- mov rbxp, JSAMPARRAY [rsi+1*SIZEOF_JSAMPARRAY]
- mov rdxp, JSAMPARRAY [rsi+2*SIZEOF_JSAMPARRAY]
- lea rdi, [rdi+rcx*SIZEOF_JSAMPROW]
- lea rbx, [rbx+rcx*SIZEOF_JSAMPROW]
- lea rdx, [rdx+rcx*SIZEOF_JSAMPROW]
-
- pop rcx
-
- mov rsi, r11
- mov eax, r14d
- test rax, rax
- jle near .return
-.rowloop:
- push rdx
- push rbx
- push rdi
- push rsi
- push rcx ; col
-
- mov rsip, JSAMPROW [rsi] ; inptr
- mov rdip, JSAMPROW [rdi] ; outptr0
- mov rbxp, JSAMPROW [rbx] ; outptr1
- mov rdxp, JSAMPROW [rdx] ; outptr2
-
- cmp rcx, byte SIZEOF_YMMWORD
- jae near .columnloop
-
-%if RGB_PIXELSIZE == 3 ; ---------------
-
-.column_ld1:
- push rax
- push rdx
- lea rcx, [rcx+rcx*2] ; imul ecx,RGB_PIXELSIZE
- test cl, SIZEOF_BYTE
- jz short .column_ld2
- sub rcx, byte SIZEOF_BYTE
- movzx rax, byte [rsi+rcx]
-.column_ld2:
- test cl, SIZEOF_WORD
- jz short .column_ld4
- sub rcx, byte SIZEOF_WORD
- movzx rdx, word [rsi+rcx]
- shl rax, WORD_BIT
- or rax, rdx
-.column_ld4:
- vmovd xmmA, eax
- pop rdx
- pop rax
- test cl, SIZEOF_DWORD
- jz short .column_ld8
- sub rcx, byte SIZEOF_DWORD
- vmovd xmmF, XMM_DWORD [rsi+rcx]
- vpslldq xmmA, xmmA, SIZEOF_DWORD
- vpor xmmA, xmmA, xmmF
-.column_ld8:
- test cl, SIZEOF_MMWORD
- jz short .column_ld16
- sub rcx, byte SIZEOF_MMWORD
- vmovq xmmB, XMM_MMWORD [rsi+rcx]
- vpslldq xmmA, xmmA, SIZEOF_MMWORD
- vpor xmmA, xmmA, xmmB
-.column_ld16:
- test cl, SIZEOF_XMMWORD
- jz short .column_ld32
- sub rcx, byte SIZEOF_XMMWORD
- vmovdqu xmmB, XMM_MMWORD [rsi+rcx]
- vperm2i128 ymmA, ymmA, ymmA, 1
- vpor ymmA, ymmB
-.column_ld32:
- test cl, SIZEOF_YMMWORD
- jz short .column_ld64
- sub rcx, byte SIZEOF_YMMWORD
- vmovdqa ymmF, ymmA
- vmovdqu ymmA, YMMWORD [rsi+0*SIZEOF_YMMWORD]
-.column_ld64:
- test cl, 2*SIZEOF_YMMWORD
- mov rcx, SIZEOF_YMMWORD
- jz short .rgb_ycc_cnv
- vmovdqa ymmB, ymmA
- vmovdqu ymmA, YMMWORD [rsi+0*SIZEOF_YMMWORD]
- vmovdqu ymmF, YMMWORD [rsi+1*SIZEOF_YMMWORD]
- jmp short .rgb_ycc_cnv
-
-.columnloop:
- vmovdqu ymmA, YMMWORD [rsi+0*SIZEOF_YMMWORD]
- vmovdqu ymmF, YMMWORD [rsi+1*SIZEOF_YMMWORD]
- vmovdqu ymmB, YMMWORD [rsi+2*SIZEOF_YMMWORD]
-
-.rgb_ycc_cnv:
- ; ymmA=(00 10 20 01 11 21 02 12 22 03 13 23 04 14 24 05
- ; 15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A)
- ; ymmF=(2A 0B 1B 2B 0C 1C 2C 0D 1D 2D 0E 1E 2E 0F 1F 2F
- ; 0G 1G 2G 0H 1H 2H 0I 1I 2I 0J 1J 2J 0K 1K 2K 0L)
- ; ymmB=(1L 2L 0M 1M 2M 0N 1N 2N 0O 1O 2O 0P 1P 2P 0Q 1Q
- ; 2Q 0R 1R 2R 0S 1S 2S 0T 1T 2T 0U 1U 2U 0V 1V 2V)
-
- vmovdqu ymmC, ymmA
- vinserti128 ymmA, ymmF, xmmA, 0 ; ymmA=(00 10 20 01 11 21 02 12 22 03 13 23 04 14 24 05
- ; 0G 1G 2G 0H 1H 2H 0I 1I 2I 0J 1J 2J 0K 1K 2K 0L)
- vinserti128 ymmC, ymmC, xmmB, 0 ; ymmC=(1L 2L 0M 1M 2M 0N 1N 2N 0O 1O 2O 0P 1P 2P 0Q 1Q
- ; 15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A)
- vinserti128 ymmB, ymmB, xmmF, 0 ; ymmB=(2A 0B 1B 2B 0C 1C 2C 0D 1D 2D 0E 1E 2E 0F 1F 2F
- ; 2Q 0R 1R 2R 0S 1S 2S 0T 1T 2T 0U 1U 2U 0V 1V 2V)
- vperm2i128 ymmF, ymmC, ymmC, 1 ; ymmF=(15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A
- ; 1L 2L 0M 1M 2M 0N 1N 2N 0O 1O 2O 0P 1P 2P 0Q 1Q)
-
- vmovdqa ymmG, ymmA
- vpslldq ymmA, ymmA, 8 ; ymmA=(-- -- -- -- -- -- -- -- 00 10 20 01 11 21 02 12
- ; 22 03 13 23 04 14 24 05 0G 1G 2G 0H 1H 2H 0I 1I)
- vpsrldq ymmG, ymmG, 8 ; ymmG=(22 03 13 23 04 14 24 05 0G 1G 2G 0H 1H 2H 0I 1I
- ; 2I 0J 1J 2J 0K 1K 2K 0L -- -- -- -- -- -- -- --)
-
- vpunpckhbw ymmA, ymmA, ymmF ; ymmA=(00 08 10 18 20 28 01 09 11 19 21 29 02 0A 12 1A
- ; 0G 0O 1G 1O 2G 2O 0H 0P 1H 1P 2H 2P 0I 0Q 1I 1Q)
- vpslldq ymmF, ymmF, 8 ; ymmF=(-- -- -- -- -- -- -- -- 15 25 06 16 26 07 17 27
- ; 08 18 28 09 19 29 0A 1A 1L 2L 0M 1M 2M 0N 1N 2N)
-
- vpunpcklbw ymmG, ymmG, ymmB ; ymmG=(22 2A 03 0B 13 1B 23 2B 04 0C 14 1C 24 2C 05 0D
- ; 2I 2Q 0J 0R 1J 1R 2J 2R 0K 0S 1K 1S 2K 2S 0L 0T)
- vpunpckhbw ymmF, ymmF, ymmB ; ymmF=(15 1D 25 2D 06 0E 16 1E 26 2E 07 0F 17 1F 27 2F
- ; 1L 1T 2L 2T 0M 0U 1M 1U 2M 2U 0N 0V 1N 1V 2N 2V)
-
- vmovdqa ymmD, ymmA
- vpslldq ymmA, ymmA, 8 ; ymmA=(-- -- -- -- -- -- -- -- 00 08 10 18 20 28 01 09
- ; 11 19 21 29 02 0A 12 1A 0G 0O 1G 1O 2G 2O 0H 0P)
- vpsrldq ymmD, ymmD, 8 ; ymmD=(11 19 21 29 02 0A 12 1A 0G 0O 1G 1O 2G 2O 0H 0P
- ; 1H 1P 2H 2P 0I 0Q 1I 1Q -- -- -- -- -- -- -- --)
-
- vpunpckhbw ymmA, ymmA, ymmG ; ymmA=(00 04 08 0C 10 14 18 1C 20 24 28 2C 01 05 09 0D
- ; 0G 0K 0O 0S 1G 1K 1O 1S 2G 2K 2O 2S 0H 0L 0P 0T)
- vpslldq ymmG, ymmG, 8 ; ymmG=(-- -- -- -- -- -- -- -- 22 2A 03 0B 13 1B 23 2B
- ; 04 0C 14 1C 24 2C 05 0D 2I 2Q 0J 0R 1J 1R 2J 2R)
-
- vpunpcklbw ymmD, ymmD, ymmF ; ymmD=(11 15 19 1D 21 25 29 2D 02 06 0A 0E 12 16 1A 1E
- ; 1H 1L 1P 1T 2H 2L 2P 2T 0I 0M 0Q 0U 1I 1M 1Q 1U)
- vpunpckhbw ymmG, ymmG, ymmF ; ymmG=(22 26 2A 2E 03 07 0B 0F 13 17 1B 1F 23 27 2B 2F
- ; 2I 2M 2Q 2U 0J 0N 0R 0V 1J 1N 1R 1V 2J 2N 2R 2V)
-
- vmovdqa ymmE, ymmA
- vpslldq ymmA, ymmA, 8 ; ymmA=(-- -- -- -- -- -- -- -- 00 04 08 0C 10 14 18 1C
- ; 20 24 28 2C 01 05 09 0D 0G 0K 0O 0S 1G 1K 1O 1S)
- vpsrldq ymmE, ymmE, 8 ; ymmE=(20 24 28 2C 01 05 09 0D 0G 0K 0O 0S 1G 1K 1O 1S
- ; 2G 2K 2O 2S 0H 0L 0P 0T -- -- -- -- -- -- -- --)
-
- vpunpckhbw ymmA, ymmA, ymmD ; ymmA=(00 02 04 06 08 0A 0C 0E 10 12 14 16 18 1A 1C 1E
- ; 0G 0I 0K 0M 0O 0Q 0S 0U 1G 1I 1K 1M 1O 1Q 1S 1U)
- vpslldq ymmD, ymmD, 8 ; ymmD=(-- -- -- -- -- -- -- -- 11 15 19 1D 21 25 29 2D
- ; 02 06 0A 0E 12 16 1A 1E 1H 1L 1P 1T 2H 2L 2P 2T)
-
- vpunpcklbw ymmE, ymmE, ymmG ; ymmE=(20 22 24 26 28 2A 2C 2E 01 03 05 07 09 0B 0D 0F
- ; 2G 2I 2K 2M 2O 2Q 2S 2U 0H 0J 0L 0N 0P 0R 0T 0V)
- vpunpckhbw ymmD, ymmD, ymmG ; ymmD=(11 13 15 17 19 1B 1D 1F 21 23 25 27 29 2B 2D 2F
- ; 1H 1J 1L 1N 1P 1R 1T 1V 2H 2J 2L 2N 2P 2R 2T 2V)
-
- vpxor ymmH, ymmH, ymmH
-
- vmovdqa ymmC, ymmA
- vpunpcklbw ymmA, ymmA, ymmH ; ymmA=(00 02 04 06 08 0A 0C 0E 0G 0I 0K 0M 0O 0Q 0S 0U)
- vpunpckhbw ymmC, ymmC, ymmH ; ymmC=(10 12 14 16 18 1A 1C 1E 1G 1I 1K 1M 1O 1Q 1S 1U)
-
- vmovdqa ymmB, ymmE
- vpunpcklbw ymmE, ymmE, ymmH ; ymmE=(20 22 24 26 28 2A 2C 2E 2G 2I 2K 2M 2O 2Q 2S 2U)
- vpunpckhbw ymmB, ymmB, ymmH ; ymmB=(01 03 05 07 09 0B 0D 0F 0H 0J 0L 0N 0P 0R 0T 0V)
-
- vmovdqa ymmF, ymmD
- vpunpcklbw ymmD, ymmD, ymmH ; ymmD=(11 13 15 17 19 1B 1D 1F 1H 1J 1L 1N 1P 1R 1T 1V)
- vpunpckhbw ymmF, ymmF, ymmH ; ymmF=(21 23 25 27 29 2B 2D 2F 2H 2J 2L 2N 2P 2R 2T 2V)
-
-%else ; RGB_PIXELSIZE == 4 ; -----------
-
-.column_ld1:
- test cl, SIZEOF_XMMWORD/16
- jz short .column_ld2
- sub rcx, byte SIZEOF_XMMWORD/16
- vmovd xmmA, XMM_DWORD [rsi+rcx*RGB_PIXELSIZE]
-.column_ld2:
- test cl, SIZEOF_XMMWORD/8
- jz short .column_ld4
- sub rcx, byte SIZEOF_XMMWORD/8
- vmovq xmmF, XMM_MMWORD [rsi+rcx*RGB_PIXELSIZE]
- vpslldq xmmA, xmmA, SIZEOF_MMWORD
- vpor xmmA, xmmA, xmmF
-.column_ld4:
- test cl, SIZEOF_XMMWORD/4
- jz short .column_ld8
- sub rcx, byte SIZEOF_XMMWORD/4
- vmovdqa xmmF, xmmA
- vperm2i128 ymmF, ymmF, ymmF, 1
- vmovdqu xmmA, XMMWORD [rsi+rcx*RGB_PIXELSIZE]
- vpor ymmA, ymmA, ymmF
-.column_ld8:
- test cl, SIZEOF_XMMWORD/2
- jz short .column_ld16
- sub rcx, byte SIZEOF_XMMWORD/2
- vmovdqa ymmF, ymmA
- vmovdqu ymmA, YMMWORD [rsi+rcx*RGB_PIXELSIZE]
-.column_ld16:
- test cl, SIZEOF_XMMWORD
- mov rcx, SIZEOF_YMMWORD
- jz short .rgb_ycc_cnv
- vmovdqa ymmE, ymmA
- vmovdqa ymmH, ymmF
- vmovdqu ymmA, YMMWORD [rsi+0*SIZEOF_YMMWORD]
- vmovdqu ymmF, YMMWORD [rsi+1*SIZEOF_YMMWORD]
- jmp short .rgb_ycc_cnv
-
-.columnloop:
- vmovdqu ymmA, YMMWORD [rsi+0*SIZEOF_YMMWORD]
- vmovdqu ymmF, YMMWORD [rsi+1*SIZEOF_YMMWORD]
- vmovdqu ymmE, YMMWORD [rsi+2*SIZEOF_YMMWORD]
- vmovdqu ymmH, YMMWORD [rsi+3*SIZEOF_YMMWORD]
-
-.rgb_ycc_cnv:
- ; ymmA=(00 10 20 30 01 11 21 31 02 12 22 32 03 13 23 33
- ; 04 14 24 34 05 15 25 35 06 16 26 36 07 17 27 37)
- ; ymmF=(08 18 28 38 09 19 29 39 0A 1A 2A 3A 0B 1B 2B 3B
- ; 0C 1C 2C 3C 0D 1D 2D 3D 0E 1E 2E 3E 0F 1F 2F 3F)
- ; ymmE=(0G 1G 2G 3G 0H 1H 2H 3H 0I 1I 2I 3I 0J 1J 2J 3J
- ; 0K 1K 2K 3K 0L 1L 2L 3L 0M 1M 2M 3M 0N 1N 2N 3N)
- ; ymmH=(0O 1O 2O 3O 0P 1P 2P 3P 0Q 1Q 2Q 3Q 0R 1R 2R 3R
- ; 0S 1S 2S 3S 0T 1T 2T 3T 0U 1U 2U 3U 0V 1V 2V 3V)
-
- vmovdqa ymmB, ymmA
- vinserti128 ymmA, ymmA, xmmE, 1 ; ymmA=(00 10 20 30 01 11 21 31 02 12 22 32 03 13 23 33
- ; 0G 1G 2G 3G 0H 1H 2H 3H 0I 1I 2I 3I 0J 1J 2J 3J)
- vperm2i128 ymmE, ymmB, ymmE, 0x31 ; ymmE=(04 14 24 34 05 15 25 35 06 16 26 36 07 17 27 37
- ; 0K 1K 2K 3K 0L 1L 2L 3L 0M 1M 2M 3M 0N 1N 2N 3N)
-
- vmovdqa ymmB, ymmF
- vinserti128 ymmF, ymmF, xmmH, 1 ; ymmF=(08 18 28 38 09 19 29 39 0A 1A 2A 3A 0B 1B 2B 3B
- ; 0O 1O 2O 3O 0P 1P 2P 3P 0Q 1Q 2Q 3Q 0R 1R 2R 3R)
- vperm2i128 ymmH, ymmB, ymmH, 0x31 ; ymmH=(0C 1C 2C 3C 0D 1D 2D 3D 0E 1E 2E 3E 0F 1F 2F 3F
- ; 0S 1S 2S 3S 0T 1T 2T 3T 0U 1U 2U 3U 0V 1V 2V 3V)
-
- vmovdqa ymmD, ymmA
- vpunpcklbw ymmA, ymmA, ymmE ; ymmA=(00 04 10 14 20 24 30 34 01 05 11 15 21 25 31 35
- ; 0G 0K 1G 1K 2G 2K 3G 3K 0H 0L 1H 1L 2H 2L 3H 3L)
- vpunpckhbw ymmD, ymmD, ymmE ; ymmD=(02 06 12 16 22 26 32 36 03 07 13 17 23 27 33 37
- ; 0I 0M 1I 1M 2I 2M 3I 3M 0J 0N 1J 1N 2J 2N 3J 3N)
-
- vmovdqa ymmC, ymmF
- vpunpcklbw ymmF, ymmF, ymmH ; ymmF=(08 0C 18 1C 28 2C 38 3C 09 0D 19 1D 29 2D 39 3D
- ; 0O 0S 1O 1S 2O 2S 3O 3S 0P 0T 1P 1T 2P 2T 3P 3T)
- vpunpckhbw ymmC, ymmC, ymmH ; ymmC=(0A 0E 1A 1E 2A 2E 3A 3E 0B 0F 1B 1F 2B 2F 3B 3F
- ; 0Q 0U 1Q 1U 2Q 2U 3Q 3U 0R 0V 1R 1V 2R 2V 3R 3V)
-
- vmovdqa ymmB, ymmA
- vpunpcklwd ymmA, ymmA, ymmF ; ymmA=(00 04 08 0C 10 14 18 1C 20 24 28 2C 30 34 38 3C
- ; 0G 0K 0O 0S 1G 1K 1O 1S 2G 2K 2O 2S 3G 3K 3O 3S)
- vpunpckhwd ymmB, ymmB, ymmF ; ymmB=(01 05 09 0D 11 15 19 1D 21 25 29 2D 31 35 39 3D
- ; 0H 0L 0P 0T 1H 1L 1P 1T 2H 2L 2P 2T 3H 3L 3P 3T)
-
- vmovdqa ymmG, ymmD
- vpunpcklwd ymmD, ymmD, ymmC ; ymmD=(02 06 0A 0E 12 16 1A 1E 22 26 2A 2E 32 36 3A 3E
- ; 0I 0M 0Q 0U 1I 1M 1Q 1U 2I 2M 2Q 2U 3I 3M 3Q 3U)
- vpunpckhwd ymmG, ymmG, ymmC ; ymmG=(03 07 0B 0F 13 17 1B 1F 23 27 2B 2F 33 37 3B 3F
- ; 0J 0N 0R 0V 1J 1N 1R 1V 2J 2N 2R 2V 3J 3N 3R 3V)
-
- vmovdqa ymmE, ymmA
- vpunpcklbw ymmA, ymmA, ymmD ; ymmA=(00 02 04 06 08 0A 0C 0E 10 12 14 16 18 1A 1C 1E
- ; 0G 0I 0K 0M 0O 0Q 0S 0U 1G 1I 1K 1M 1O 1Q 1S 1U)
- vpunpckhbw ymmE, ymmE, ymmD ; ymmE=(20 22 24 26 28 2A 2C 2E 30 32 34 36 38 3A 3C 3E
- ; 2G 2I 2K 2M 2O 2Q 2S 2U 3G 3I 3K 3M 3O 3Q 3S 3U)
-
- vmovdqa ymmH, ymmB
- vpunpcklbw ymmB, ymmB, ymmG ; ymmB=(01 03 05 07 09 0B 0D 0F 11 13 15 17 19 1B 1D 1F
- ; 0H 0J 0L 0N 0P 0R 0T 0V 1H 1J 1L 1N 1P 1R 1T 1V)
- vpunpckhbw ymmH, ymmH, ymmG ; ymmH=(21 23 25 27 29 2B 2D 2F 31 33 35 37 39 3B 3D 3F
- ; 2H 2J 2L 2N 2P 2R 2T 2V 3H 3J 3L 3N 3P 3R 3T 3V)
-
- vpxor ymmF, ymmF, ymmF
-
- vmovdqa ymmC, ymmA
- vpunpcklbw ymmA, ymmA, ymmF ; ymmA=(00 02 04 06 08 0A 0C 0E 0G 0I 0K 0M 0O 0Q 0S 0U)
- vpunpckhbw ymmC, ymmC, ymmF ; ymmC=(10 12 14 16 18 1A 1C 1E 1G 1I 1K 1M 1O 1Q 1S 1U)
-
- vmovdqa ymmD, ymmB
- vpunpcklbw ymmB, ymmB, ymmF ; ymmB=(01 03 05 07 09 0B 0D 0F 0H 0J 0L 0N 0P 0R 0T 0V)
- vpunpckhbw ymmD, ymmD, ymmF ; ymmD=(11 13 15 17 19 1B 1D 1F 1H 1J 1L 1N 1P 1R 1T 1V)
-
- vmovdqa ymmG, ymmE
- vpunpcklbw ymmE, ymmE, ymmF ; ymmE=(20 22 24 26 28 2A 2C 2E 2G 2I 2K 2M 2O 2Q 2S 2U)
- vpunpckhbw ymmG, ymmG, ymmF ; ymmG=(30 32 34 36 38 3A 3C 3E 3G 3I 3K 3M 3O 3Q 3S 3U)
-
- vpunpcklbw ymmF, ymmF, ymmH
- vpunpckhbw ymmH, ymmH, ymmH
- vpsrlw ymmF, ymmF, BYTE_BIT ; ymmF=(21 23 25 27 29 2B 2D 2F 2H 2J 2L 2N 2P 2R 2T 2V)
- vpsrlw ymmH, ymmH, BYTE_BIT ; ymmH=(31 33 35 37 39 3B 3D 3F 3H 3J 3L 3N 3P 3R 3T 3V)
-
-%endif ; RGB_PIXELSIZE ; ---------------
-
- ; ymm0=R(02468ACEGIKMOQSU)=RE, ymm2=G(02468ACEGIKMOQSU)=GE, ymm4=B(02468ACEGIKMOQSU)=BE
- ; ymm1=R(13579BDFHJLNPRTV)=RO, ymm3=G(13579BDFHJLNPRTV)=GO, ymm5=B(13579BDFHJLNPRTV)=BO
-
- ; (Original)
- ; Y = 0.29900 * R + 0.58700 * G + 0.11400 * B
- ; Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + CENTERJSAMPLE
- ; Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + CENTERJSAMPLE
- ;
- ; (This implementation)
- ; Y = 0.29900 * R + 0.33700 * G + 0.11400 * B + 0.25000 * G
- ; Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + CENTERJSAMPLE
- ; Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + CENTERJSAMPLE
-
- vmovdqa YMMWORD [wk(0)], ymm0 ; wk(0)=RE
- vmovdqa YMMWORD [wk(1)], ymm1 ; wk(1)=RO
- vmovdqa YMMWORD [wk(2)], ymm4 ; wk(2)=BE
- vmovdqa YMMWORD [wk(3)], ymm5 ; wk(3)=BO
-
- vmovdqa ymm6, ymm1
- vpunpcklwd ymm1, ymm1, ymm3
- vpunpckhwd ymm6, ymm6, ymm3
- vmovdqa ymm7, ymm1
- vmovdqa ymm4, ymm6
- vpmaddwd ymm1, ymm1, [rel PW_F0299_F0337] ; ymm1=ROL*FIX(0.299)+GOL*FIX(0.337)
- vpmaddwd ymm6, ymm6, [rel PW_F0299_F0337] ; ymm6=ROH*FIX(0.299)+GOH*FIX(0.337)
- vpmaddwd ymm7, ymm7, [rel PW_MF016_MF033] ; ymm7=ROL*-FIX(0.168)+GOL*-FIX(0.331)
- vpmaddwd ymm4, ymm4, [rel PW_MF016_MF033] ; ymm4=ROH*-FIX(0.168)+GOH*-FIX(0.331)
-
- vmovdqa YMMWORD [wk(4)], ymm1 ; wk(4)=ROL*FIX(0.299)+GOL*FIX(0.337)
- vmovdqa YMMWORD [wk(5)], ymm6 ; wk(5)=ROH*FIX(0.299)+GOH*FIX(0.337)
-
- vpxor ymm1, ymm1, ymm1
- vpxor ymm6, ymm6, ymm6
- vpunpcklwd ymm1, ymm1, ymm5 ; ymm1=BOL
- vpunpckhwd ymm6, ymm6, ymm5 ; ymm6=BOH
- vpsrld ymm1, ymm1, 1 ; ymm1=BOL*FIX(0.500)
- vpsrld ymm6, ymm6, 1 ; ymm6=BOH*FIX(0.500)
-
- vmovdqa ymm5, [rel PD_ONEHALFM1_CJ] ; ymm5=[PD_ONEHALFM1_CJ]
-
- vpaddd ymm7, ymm7, ymm1
- vpaddd ymm4, ymm4, ymm6
- vpaddd ymm7, ymm7, ymm5
- vpaddd ymm4, ymm4, ymm5
- vpsrld ymm7, ymm7, SCALEBITS ; ymm7=CbOL
- vpsrld ymm4, ymm4, SCALEBITS ; ymm4=CbOH
- vpackssdw ymm7, ymm7, ymm4 ; ymm7=CbO
-
- vmovdqa ymm1, YMMWORD [wk(2)] ; ymm1=BE
-
- vmovdqa ymm6, ymm0
- vpunpcklwd ymm0, ymm0, ymm2
- vpunpckhwd ymm6, ymm6, ymm2
- vmovdqa ymm5, ymm0
- vmovdqa ymm4, ymm6
- vpmaddwd ymm0, ymm0, [rel PW_F0299_F0337] ; ymm0=REL*FIX(0.299)+GEL*FIX(0.337)
- vpmaddwd ymm6, ymm6, [rel PW_F0299_F0337] ; ymm6=REH*FIX(0.299)+GEH*FIX(0.337)
- vpmaddwd ymm5, ymm5, [rel PW_MF016_MF033] ; ymm5=REL*-FIX(0.168)+GEL*-FIX(0.331)
- vpmaddwd ymm4, ymm4, [rel PW_MF016_MF033] ; ymm4=REH*-FIX(0.168)+GEH*-FIX(0.331)
-
- vmovdqa YMMWORD [wk(6)], ymm0 ; wk(6)=REL*FIX(0.299)+GEL*FIX(0.337)
- vmovdqa YMMWORD [wk(7)], ymm6 ; wk(7)=REH*FIX(0.299)+GEH*FIX(0.337)
-
- vpxor ymm0, ymm0, ymm0
- vpxor ymm6, ymm6, ymm6
- vpunpcklwd ymm0, ymm0, ymm1 ; ymm0=BEL
- vpunpckhwd ymm6, ymm6, ymm1 ; ymm6=BEH
- vpsrld ymm0, ymm0, 1 ; ymm0=BEL*FIX(0.500)
- vpsrld ymm6, ymm6, 1 ; ymm6=BEH*FIX(0.500)
-
- vmovdqa ymm1, [rel PD_ONEHALFM1_CJ] ; ymm1=[PD_ONEHALFM1_CJ]
-
- vpaddd ymm5, ymm5, ymm0
- vpaddd ymm4, ymm4, ymm6
- vpaddd ymm5, ymm5, ymm1
- vpaddd ymm4, ymm4, ymm1
- vpsrld ymm5, ymm5, SCALEBITS ; ymm5=CbEL
- vpsrld ymm4, ymm4, SCALEBITS ; ymm4=CbEH
- vpackssdw ymm5, ymm5, ymm4 ; ymm5=CbE
-
- vpsllw ymm7, ymm7, BYTE_BIT
- vpor ymm5, ymm5, ymm7 ; ymm5=Cb
- vmovdqu YMMWORD [rbx], ymm5 ; Save Cb
-
- vmovdqa ymm0, YMMWORD [wk(3)] ; ymm0=BO
- vmovdqa ymm6, YMMWORD [wk(2)] ; ymm6=BE
- vmovdqa ymm1, YMMWORD [wk(1)] ; ymm1=RO
-
- vmovdqa ymm4, ymm0
- vpunpcklwd ymm0, ymm0, ymm3
- vpunpckhwd ymm4, ymm4, ymm3
- vmovdqa ymm7, ymm0
- vmovdqa ymm5, ymm4
- vpmaddwd ymm0, ymm0, [rel PW_F0114_F0250] ; ymm0=BOL*FIX(0.114)+GOL*FIX(0.250)
- vpmaddwd ymm4, ymm4, [rel PW_F0114_F0250] ; ymm4=BOH*FIX(0.114)+GOH*FIX(0.250)
- vpmaddwd ymm7, ymm7, [rel PW_MF008_MF041] ; ymm7=BOL*-FIX(0.081)+GOL*-FIX(0.418)
- vpmaddwd ymm5, ymm5, [rel PW_MF008_MF041] ; ymm5=BOH*-FIX(0.081)+GOH*-FIX(0.418)
-
- vmovdqa ymm3, [rel PD_ONEHALF] ; ymm3=[PD_ONEHALF]
-
- vpaddd ymm0, ymm0, YMMWORD [wk(4)]
- vpaddd ymm4, ymm4, YMMWORD [wk(5)]
- vpaddd ymm0, ymm0, ymm3
- vpaddd ymm4, ymm4, ymm3
- vpsrld ymm0, ymm0, SCALEBITS ; ymm0=YOL
- vpsrld ymm4, ymm4, SCALEBITS ; ymm4=YOH
- vpackssdw ymm0, ymm0, ymm4 ; ymm0=YO
-
- vpxor ymm3, ymm3, ymm3
- vpxor ymm4, ymm4, ymm4
- vpunpcklwd ymm3, ymm3, ymm1 ; ymm3=ROL
- vpunpckhwd ymm4, ymm4, ymm1 ; ymm4=ROH
- vpsrld ymm3, ymm3, 1 ; ymm3=ROL*FIX(0.500)
- vpsrld ymm4, ymm4, 1 ; ymm4=ROH*FIX(0.500)
-
- vmovdqa ymm1, [rel PD_ONEHALFM1_CJ] ; ymm1=[PD_ONEHALFM1_CJ]
-
- vpaddd ymm7, ymm7, ymm3
- vpaddd ymm5, ymm5, ymm4
- vpaddd ymm7, ymm7, ymm1
- vpaddd ymm5, ymm5, ymm1
- vpsrld ymm7, ymm7, SCALEBITS ; ymm7=CrOL
- vpsrld ymm5, ymm5, SCALEBITS ; ymm5=CrOH
- vpackssdw ymm7, ymm7, ymm5 ; ymm7=CrO
-
- vmovdqa ymm3, YMMWORD [wk(0)] ; ymm3=RE
-
- vmovdqa ymm4, ymm6
- vpunpcklwd ymm6, ymm6, ymm2
- vpunpckhwd ymm4, ymm4, ymm2
- vmovdqa ymm1, ymm6
- vmovdqa ymm5, ymm4
- vpmaddwd ymm6, ymm6, [rel PW_F0114_F0250] ; ymm6=BEL*FIX(0.114)+GEL*FIX(0.250)
- vpmaddwd ymm4, ymm4, [rel PW_F0114_F0250] ; ymm4=BEH*FIX(0.114)+GEH*FIX(0.250)
- vpmaddwd ymm1, ymm1, [rel PW_MF008_MF041] ; ymm1=BEL*-FIX(0.081)+GEL*-FIX(0.418)
- vpmaddwd ymm5, ymm5, [rel PW_MF008_MF041] ; ymm5=BEH*-FIX(0.081)+GEH*-FIX(0.418)
-
- vmovdqa ymm2, [rel PD_ONEHALF] ; ymm2=[PD_ONEHALF]
-
- vpaddd ymm6, ymm6, YMMWORD [wk(6)]
- vpaddd ymm4, ymm4, YMMWORD [wk(7)]
- vpaddd ymm6, ymm6, ymm2
- vpaddd ymm4, ymm4, ymm2
- vpsrld ymm6, ymm6, SCALEBITS ; ymm6=YEL
- vpsrld ymm4, ymm4, SCALEBITS ; ymm4=YEH
- vpackssdw ymm6, ymm6, ymm4 ; ymm6=YE
-
- vpsllw ymm0, ymm0, BYTE_BIT
- vpor ymm6, ymm6, ymm0 ; ymm6=Y
- vmovdqu YMMWORD [rdi], ymm6 ; Save Y
-
- vpxor ymm2, ymm2, ymm2
- vpxor ymm4, ymm4, ymm4
- vpunpcklwd ymm2, ymm2, ymm3 ; ymm2=REL
- vpunpckhwd ymm4, ymm4, ymm3 ; ymm4=REH
- vpsrld ymm2, ymm2, 1 ; ymm2=REL*FIX(0.500)
- vpsrld ymm4, ymm4, 1 ; ymm4=REH*FIX(0.500)
-
- vmovdqa ymm0, [rel PD_ONEHALFM1_CJ] ; ymm0=[PD_ONEHALFM1_CJ]
-
- vpaddd ymm1, ymm1, ymm2
- vpaddd ymm5, ymm5, ymm4
- vpaddd ymm1, ymm1, ymm0
- vpaddd ymm5, ymm5, ymm0
- vpsrld ymm1, ymm1, SCALEBITS ; ymm1=CrEL
- vpsrld ymm5, ymm5, SCALEBITS ; ymm5=CrEH
- vpackssdw ymm1, ymm1, ymm5 ; ymm1=CrE
-
- vpsllw ymm7, ymm7, BYTE_BIT
- vpor ymm1, ymm1, ymm7 ; ymm1=Cr
- vmovdqu YMMWORD [rdx], ymm1 ; Save Cr
-
- sub rcx, byte SIZEOF_YMMWORD
- add rsi, RGB_PIXELSIZE*SIZEOF_YMMWORD ; inptr
- add rdi, byte SIZEOF_YMMWORD ; outptr0
- add rbx, byte SIZEOF_YMMWORD ; outptr1
- add rdx, byte SIZEOF_YMMWORD ; outptr2
- cmp rcx, byte SIZEOF_YMMWORD
- jae near .columnloop
- test rcx, rcx
- jnz near .column_ld1
-
- pop rcx ; col
- pop rsi
- pop rdi
- pop rbx
- pop rdx
-
- add rsi, byte SIZEOF_JSAMPROW ; input_buf
- add rdi, byte SIZEOF_JSAMPROW
- add rbx, byte SIZEOF_JSAMPROW
- add rdx, byte SIZEOF_JSAMPROW
- dec rax ; num_rows
- jg near .rowloop
-
-.return:
- pop rbx
- vzeroupper
- uncollect_args 5
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
- pop rbp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jccolext-sse2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jccolext-sse2.asm
deleted file mode 100644
index af70ed6010..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jccolext-sse2.asm
+++ /dev/null
@@ -1,484 +0,0 @@
-;
-; jccolext.asm - colorspace conversion (64-bit SSE2)
-;
-; Copyright (C) 2009, 2016, D. R. Commander.
-; Copyright (C) 2018, Matthias Räncker.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jcolsamp.inc"
-
-; --------------------------------------------------------------------------
-;
-; Convert some rows of samples to the output colorspace.
-;
-; GLOBAL(void)
-; jsimd_rgb_ycc_convert_sse2(JDIMENSION img_width, JSAMPARRAY input_buf,
-; JSAMPIMAGE output_buf, JDIMENSION output_row,
-; int num_rows);
-;
-
-; r10d = JDIMENSION img_width
-; r11 = JSAMPARRAY input_buf
-; r12 = JSAMPIMAGE output_buf
-; r13d = JDIMENSION output_row
-; r14d = int num_rows
-
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
-%define WK_NUM 8
-
- align 32
- GLOBAL_FUNCTION(jsimd_rgb_ycc_convert_sse2)
-
-EXTN(jsimd_rgb_ycc_convert_sse2):
- push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
- and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
- collect_args 5
- push rbx
-
- mov ecx, r10d
- test rcx, rcx
- jz near .return
-
- push rcx
-
- mov rsi, r12
- mov ecx, r13d
- mov rdip, JSAMPARRAY [rsi+0*SIZEOF_JSAMPARRAY]
- mov rbxp, JSAMPARRAY [rsi+1*SIZEOF_JSAMPARRAY]
- mov rdxp, JSAMPARRAY [rsi+2*SIZEOF_JSAMPARRAY]
- lea rdi, [rdi+rcx*SIZEOF_JSAMPROW]
- lea rbx, [rbx+rcx*SIZEOF_JSAMPROW]
- lea rdx, [rdx+rcx*SIZEOF_JSAMPROW]
-
- pop rcx
-
- mov rsi, r11
- mov eax, r14d
- test rax, rax
- jle near .return
-.rowloop:
- push rdx
- push rbx
- push rdi
- push rsi
- push rcx ; col
-
- mov rsip, JSAMPROW [rsi] ; inptr
- mov rdip, JSAMPROW [rdi] ; outptr0
- mov rbxp, JSAMPROW [rbx] ; outptr1
- mov rdxp, JSAMPROW [rdx] ; outptr2
-
- cmp rcx, byte SIZEOF_XMMWORD
- jae near .columnloop
-
-%if RGB_PIXELSIZE == 3 ; ---------------
-
-.column_ld1:
- push rax
- push rdx
- lea rcx, [rcx+rcx*2] ; imul ecx,RGB_PIXELSIZE
- test cl, SIZEOF_BYTE
- jz short .column_ld2
- sub rcx, byte SIZEOF_BYTE
- movzx rax, byte [rsi+rcx]
-.column_ld2:
- test cl, SIZEOF_WORD
- jz short .column_ld4
- sub rcx, byte SIZEOF_WORD
- movzx rdx, word [rsi+rcx]
- shl rax, WORD_BIT
- or rax, rdx
-.column_ld4:
- movd xmmA, eax
- pop rdx
- pop rax
- test cl, SIZEOF_DWORD
- jz short .column_ld8
- sub rcx, byte SIZEOF_DWORD
- movd xmmF, XMM_DWORD [rsi+rcx]
- pslldq xmmA, SIZEOF_DWORD
- por xmmA, xmmF
-.column_ld8:
- test cl, SIZEOF_MMWORD
- jz short .column_ld16
- sub rcx, byte SIZEOF_MMWORD
- movq xmmB, XMM_MMWORD [rsi+rcx]
- pslldq xmmA, SIZEOF_MMWORD
- por xmmA, xmmB
-.column_ld16:
- test cl, SIZEOF_XMMWORD
- jz short .column_ld32
- movdqa xmmF, xmmA
- movdqu xmmA, XMMWORD [rsi+0*SIZEOF_XMMWORD]
- mov rcx, SIZEOF_XMMWORD
- jmp short .rgb_ycc_cnv
-.column_ld32:
- test cl, 2*SIZEOF_XMMWORD
- mov rcx, SIZEOF_XMMWORD
- jz short .rgb_ycc_cnv
- movdqa xmmB, xmmA
- movdqu xmmA, XMMWORD [rsi+0*SIZEOF_XMMWORD]
- movdqu xmmF, XMMWORD [rsi+1*SIZEOF_XMMWORD]
- jmp short .rgb_ycc_cnv
-
-.columnloop:
- movdqu xmmA, XMMWORD [rsi+0*SIZEOF_XMMWORD]
- movdqu xmmF, XMMWORD [rsi+1*SIZEOF_XMMWORD]
- movdqu xmmB, XMMWORD [rsi+2*SIZEOF_XMMWORD]
-
-.rgb_ycc_cnv:
- ; xmmA=(00 10 20 01 11 21 02 12 22 03 13 23 04 14 24 05)
- ; xmmF=(15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A)
- ; xmmB=(2A 0B 1B 2B 0C 1C 2C 0D 1D 2D 0E 1E 2E 0F 1F 2F)
-
- movdqa xmmG, xmmA
- pslldq xmmA, 8 ; xmmA=(-- -- -- -- -- -- -- -- 00 10 20 01 11 21 02 12)
- psrldq xmmG, 8 ; xmmG=(22 03 13 23 04 14 24 05 -- -- -- -- -- -- -- --)
-
- punpckhbw xmmA, xmmF ; xmmA=(00 08 10 18 20 28 01 09 11 19 21 29 02 0A 12 1A)
- pslldq xmmF, 8 ; xmmF=(-- -- -- -- -- -- -- -- 15 25 06 16 26 07 17 27)
-
- punpcklbw xmmG, xmmB ; xmmG=(22 2A 03 0B 13 1B 23 2B 04 0C 14 1C 24 2C 05 0D)
- punpckhbw xmmF, xmmB ; xmmF=(15 1D 25 2D 06 0E 16 1E 26 2E 07 0F 17 1F 27 2F)
-
- movdqa xmmD, xmmA
- pslldq xmmA, 8 ; xmmA=(-- -- -- -- -- -- -- -- 00 08 10 18 20 28 01 09)
- psrldq xmmD, 8 ; xmmD=(11 19 21 29 02 0A 12 1A -- -- -- -- -- -- -- --)
-
- punpckhbw xmmA, xmmG ; xmmA=(00 04 08 0C 10 14 18 1C 20 24 28 2C 01 05 09 0D)
- pslldq xmmG, 8 ; xmmG=(-- -- -- -- -- -- -- -- 22 2A 03 0B 13 1B 23 2B)
-
- punpcklbw xmmD, xmmF ; xmmD=(11 15 19 1D 21 25 29 2D 02 06 0A 0E 12 16 1A 1E)
- punpckhbw xmmG, xmmF ; xmmG=(22 26 2A 2E 03 07 0B 0F 13 17 1B 1F 23 27 2B 2F)
-
- movdqa xmmE, xmmA
- pslldq xmmA, 8 ; xmmA=(-- -- -- -- -- -- -- -- 00 04 08 0C 10 14 18 1C)
- psrldq xmmE, 8 ; xmmE=(20 24 28 2C 01 05 09 0D -- -- -- -- -- -- -- --)
-
- punpckhbw xmmA, xmmD ; xmmA=(00 02 04 06 08 0A 0C 0E 10 12 14 16 18 1A 1C 1E)
- pslldq xmmD, 8 ; xmmD=(-- -- -- -- -- -- -- -- 11 15 19 1D 21 25 29 2D)
-
- punpcklbw xmmE, xmmG ; xmmE=(20 22 24 26 28 2A 2C 2E 01 03 05 07 09 0B 0D 0F)
- punpckhbw xmmD, xmmG ; xmmD=(11 13 15 17 19 1B 1D 1F 21 23 25 27 29 2B 2D 2F)
-
- pxor xmmH, xmmH
-
- movdqa xmmC, xmmA
- punpcklbw xmmA, xmmH ; xmmA=(00 02 04 06 08 0A 0C 0E)
- punpckhbw xmmC, xmmH ; xmmC=(10 12 14 16 18 1A 1C 1E)
-
- movdqa xmmB, xmmE
- punpcklbw xmmE, xmmH ; xmmE=(20 22 24 26 28 2A 2C 2E)
- punpckhbw xmmB, xmmH ; xmmB=(01 03 05 07 09 0B 0D 0F)
-
- movdqa xmmF, xmmD
- punpcklbw xmmD, xmmH ; xmmD=(11 13 15 17 19 1B 1D 1F)
- punpckhbw xmmF, xmmH ; xmmF=(21 23 25 27 29 2B 2D 2F)
-
-%else ; RGB_PIXELSIZE == 4 ; -----------
-
-.column_ld1:
- test cl, SIZEOF_XMMWORD/16
- jz short .column_ld2
- sub rcx, byte SIZEOF_XMMWORD/16
- movd xmmA, XMM_DWORD [rsi+rcx*RGB_PIXELSIZE]
-.column_ld2:
- test cl, SIZEOF_XMMWORD/8
- jz short .column_ld4
- sub rcx, byte SIZEOF_XMMWORD/8
- movq xmmE, XMM_MMWORD [rsi+rcx*RGB_PIXELSIZE]
- pslldq xmmA, SIZEOF_MMWORD
- por xmmA, xmmE
-.column_ld4:
- test cl, SIZEOF_XMMWORD/4
- jz short .column_ld8
- sub rcx, byte SIZEOF_XMMWORD/4
- movdqa xmmE, xmmA
- movdqu xmmA, XMMWORD [rsi+rcx*RGB_PIXELSIZE]
-.column_ld8:
- test cl, SIZEOF_XMMWORD/2
- mov rcx, SIZEOF_XMMWORD
- jz short .rgb_ycc_cnv
- movdqa xmmF, xmmA
- movdqa xmmH, xmmE
- movdqu xmmA, XMMWORD [rsi+0*SIZEOF_XMMWORD]
- movdqu xmmE, XMMWORD [rsi+1*SIZEOF_XMMWORD]
- jmp short .rgb_ycc_cnv
-
-.columnloop:
- movdqu xmmA, XMMWORD [rsi+0*SIZEOF_XMMWORD]
- movdqu xmmE, XMMWORD [rsi+1*SIZEOF_XMMWORD]
- movdqu xmmF, XMMWORD [rsi+2*SIZEOF_XMMWORD]
- movdqu xmmH, XMMWORD [rsi+3*SIZEOF_XMMWORD]
-
-.rgb_ycc_cnv:
- ; xmmA=(00 10 20 30 01 11 21 31 02 12 22 32 03 13 23 33)
- ; xmmE=(04 14 24 34 05 15 25 35 06 16 26 36 07 17 27 37)
- ; xmmF=(08 18 28 38 09 19 29 39 0A 1A 2A 3A 0B 1B 2B 3B)
- ; xmmH=(0C 1C 2C 3C 0D 1D 2D 3D 0E 1E 2E 3E 0F 1F 2F 3F)
-
- movdqa xmmD, xmmA
- punpcklbw xmmA, xmmE ; xmmA=(00 04 10 14 20 24 30 34 01 05 11 15 21 25 31 35)
- punpckhbw xmmD, xmmE ; xmmD=(02 06 12 16 22 26 32 36 03 07 13 17 23 27 33 37)
-
- movdqa xmmC, xmmF
- punpcklbw xmmF, xmmH ; xmmF=(08 0C 18 1C 28 2C 38 3C 09 0D 19 1D 29 2D 39 3D)
- punpckhbw xmmC, xmmH ; xmmC=(0A 0E 1A 1E 2A 2E 3A 3E 0B 0F 1B 1F 2B 2F 3B 3F)
-
- movdqa xmmB, xmmA
- punpcklwd xmmA, xmmF ; xmmA=(00 04 08 0C 10 14 18 1C 20 24 28 2C 30 34 38 3C)
- punpckhwd xmmB, xmmF ; xmmB=(01 05 09 0D 11 15 19 1D 21 25 29 2D 31 35 39 3D)
-
- movdqa xmmG, xmmD
- punpcklwd xmmD, xmmC ; xmmD=(02 06 0A 0E 12 16 1A 1E 22 26 2A 2E 32 36 3A 3E)
- punpckhwd xmmG, xmmC ; xmmG=(03 07 0B 0F 13 17 1B 1F 23 27 2B 2F 33 37 3B 3F)
-
- movdqa xmmE, xmmA
- punpcklbw xmmA, xmmD ; xmmA=(00 02 04 06 08 0A 0C 0E 10 12 14 16 18 1A 1C 1E)
- punpckhbw xmmE, xmmD ; xmmE=(20 22 24 26 28 2A 2C 2E 30 32 34 36 38 3A 3C 3E)
-
- movdqa xmmH, xmmB
- punpcklbw xmmB, xmmG ; xmmB=(01 03 05 07 09 0B 0D 0F 11 13 15 17 19 1B 1D 1F)
- punpckhbw xmmH, xmmG ; xmmH=(21 23 25 27 29 2B 2D 2F 31 33 35 37 39 3B 3D 3F)
-
- pxor xmmF, xmmF
-
- movdqa xmmC, xmmA
- punpcklbw xmmA, xmmF ; xmmA=(00 02 04 06 08 0A 0C 0E)
- punpckhbw xmmC, xmmF ; xmmC=(10 12 14 16 18 1A 1C 1E)
-
- movdqa xmmD, xmmB
- punpcklbw xmmB, xmmF ; xmmB=(01 03 05 07 09 0B 0D 0F)
- punpckhbw xmmD, xmmF ; xmmD=(11 13 15 17 19 1B 1D 1F)
-
- movdqa xmmG, xmmE
- punpcklbw xmmE, xmmF ; xmmE=(20 22 24 26 28 2A 2C 2E)
- punpckhbw xmmG, xmmF ; xmmG=(30 32 34 36 38 3A 3C 3E)
-
- punpcklbw xmmF, xmmH
- punpckhbw xmmH, xmmH
- psrlw xmmF, BYTE_BIT ; xmmF=(21 23 25 27 29 2B 2D 2F)
- psrlw xmmH, BYTE_BIT ; xmmH=(31 33 35 37 39 3B 3D 3F)
-
-%endif ; RGB_PIXELSIZE ; ---------------
-
- ; xmm0=R(02468ACE)=RE, xmm2=G(02468ACE)=GE, xmm4=B(02468ACE)=BE
- ; xmm1=R(13579BDF)=RO, xmm3=G(13579BDF)=GO, xmm5=B(13579BDF)=BO
-
- ; (Original)
- ; Y = 0.29900 * R + 0.58700 * G + 0.11400 * B
- ; Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + CENTERJSAMPLE
- ; Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + CENTERJSAMPLE
- ;
- ; (This implementation)
- ; Y = 0.29900 * R + 0.33700 * G + 0.11400 * B + 0.25000 * G
- ; Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + CENTERJSAMPLE
- ; Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + CENTERJSAMPLE
-
- movdqa XMMWORD [wk(0)], xmm0 ; wk(0)=RE
- movdqa XMMWORD [wk(1)], xmm1 ; wk(1)=RO
- movdqa XMMWORD [wk(2)], xmm4 ; wk(2)=BE
- movdqa XMMWORD [wk(3)], xmm5 ; wk(3)=BO
-
- movdqa xmm6, xmm1
- punpcklwd xmm1, xmm3
- punpckhwd xmm6, xmm3
- movdqa xmm7, xmm1
- movdqa xmm4, xmm6
- pmaddwd xmm1, [rel PW_F0299_F0337] ; xmm1=ROL*FIX(0.299)+GOL*FIX(0.337)
- pmaddwd xmm6, [rel PW_F0299_F0337] ; xmm6=ROH*FIX(0.299)+GOH*FIX(0.337)
- pmaddwd xmm7, [rel PW_MF016_MF033] ; xmm7=ROL*-FIX(0.168)+GOL*-FIX(0.331)
- pmaddwd xmm4, [rel PW_MF016_MF033] ; xmm4=ROH*-FIX(0.168)+GOH*-FIX(0.331)
-
- movdqa XMMWORD [wk(4)], xmm1 ; wk(4)=ROL*FIX(0.299)+GOL*FIX(0.337)
- movdqa XMMWORD [wk(5)], xmm6 ; wk(5)=ROH*FIX(0.299)+GOH*FIX(0.337)
-
- pxor xmm1, xmm1
- pxor xmm6, xmm6
- punpcklwd xmm1, xmm5 ; xmm1=BOL
- punpckhwd xmm6, xmm5 ; xmm6=BOH
- psrld xmm1, 1 ; xmm1=BOL*FIX(0.500)
- psrld xmm6, 1 ; xmm6=BOH*FIX(0.500)
-
- movdqa xmm5, [rel PD_ONEHALFM1_CJ] ; xmm5=[PD_ONEHALFM1_CJ]
-
- paddd xmm7, xmm1
- paddd xmm4, xmm6
- paddd xmm7, xmm5
- paddd xmm4, xmm5
- psrld xmm7, SCALEBITS ; xmm7=CbOL
- psrld xmm4, SCALEBITS ; xmm4=CbOH
- packssdw xmm7, xmm4 ; xmm7=CbO
-
- movdqa xmm1, XMMWORD [wk(2)] ; xmm1=BE
-
- movdqa xmm6, xmm0
- punpcklwd xmm0, xmm2
- punpckhwd xmm6, xmm2
- movdqa xmm5, xmm0
- movdqa xmm4, xmm6
- pmaddwd xmm0, [rel PW_F0299_F0337] ; xmm0=REL*FIX(0.299)+GEL*FIX(0.337)
- pmaddwd xmm6, [rel PW_F0299_F0337] ; xmm6=REH*FIX(0.299)+GEH*FIX(0.337)
- pmaddwd xmm5, [rel PW_MF016_MF033] ; xmm5=REL*-FIX(0.168)+GEL*-FIX(0.331)
- pmaddwd xmm4, [rel PW_MF016_MF033] ; xmm4=REH*-FIX(0.168)+GEH*-FIX(0.331)
-
- movdqa XMMWORD [wk(6)], xmm0 ; wk(6)=REL*FIX(0.299)+GEL*FIX(0.337)
- movdqa XMMWORD [wk(7)], xmm6 ; wk(7)=REH*FIX(0.299)+GEH*FIX(0.337)
-
- pxor xmm0, xmm0
- pxor xmm6, xmm6
- punpcklwd xmm0, xmm1 ; xmm0=BEL
- punpckhwd xmm6, xmm1 ; xmm6=BEH
- psrld xmm0, 1 ; xmm0=BEL*FIX(0.500)
- psrld xmm6, 1 ; xmm6=BEH*FIX(0.500)
-
- movdqa xmm1, [rel PD_ONEHALFM1_CJ] ; xmm1=[PD_ONEHALFM1_CJ]
-
- paddd xmm5, xmm0
- paddd xmm4, xmm6
- paddd xmm5, xmm1
- paddd xmm4, xmm1
- psrld xmm5, SCALEBITS ; xmm5=CbEL
- psrld xmm4, SCALEBITS ; xmm4=CbEH
- packssdw xmm5, xmm4 ; xmm5=CbE
-
- psllw xmm7, BYTE_BIT
- por xmm5, xmm7 ; xmm5=Cb
- movdqa XMMWORD [rbx], xmm5 ; Save Cb
-
- movdqa xmm0, XMMWORD [wk(3)] ; xmm0=BO
- movdqa xmm6, XMMWORD [wk(2)] ; xmm6=BE
- movdqa xmm1, XMMWORD [wk(1)] ; xmm1=RO
-
- movdqa xmm4, xmm0
- punpcklwd xmm0, xmm3
- punpckhwd xmm4, xmm3
- movdqa xmm7, xmm0
- movdqa xmm5, xmm4
- pmaddwd xmm0, [rel PW_F0114_F0250] ; xmm0=BOL*FIX(0.114)+GOL*FIX(0.250)
- pmaddwd xmm4, [rel PW_F0114_F0250] ; xmm4=BOH*FIX(0.114)+GOH*FIX(0.250)
- pmaddwd xmm7, [rel PW_MF008_MF041] ; xmm7=BOL*-FIX(0.081)+GOL*-FIX(0.418)
- pmaddwd xmm5, [rel PW_MF008_MF041] ; xmm5=BOH*-FIX(0.081)+GOH*-FIX(0.418)
-
- movdqa xmm3, [rel PD_ONEHALF] ; xmm3=[PD_ONEHALF]
-
- paddd xmm0, XMMWORD [wk(4)]
- paddd xmm4, XMMWORD [wk(5)]
- paddd xmm0, xmm3
- paddd xmm4, xmm3
- psrld xmm0, SCALEBITS ; xmm0=YOL
- psrld xmm4, SCALEBITS ; xmm4=YOH
- packssdw xmm0, xmm4 ; xmm0=YO
-
- pxor xmm3, xmm3
- pxor xmm4, xmm4
- punpcklwd xmm3, xmm1 ; xmm3=ROL
- punpckhwd xmm4, xmm1 ; xmm4=ROH
- psrld xmm3, 1 ; xmm3=ROL*FIX(0.500)
- psrld xmm4, 1 ; xmm4=ROH*FIX(0.500)
-
- movdqa xmm1, [rel PD_ONEHALFM1_CJ] ; xmm1=[PD_ONEHALFM1_CJ]
-
- paddd xmm7, xmm3
- paddd xmm5, xmm4
- paddd xmm7, xmm1
- paddd xmm5, xmm1
- psrld xmm7, SCALEBITS ; xmm7=CrOL
- psrld xmm5, SCALEBITS ; xmm5=CrOH
- packssdw xmm7, xmm5 ; xmm7=CrO
-
- movdqa xmm3, XMMWORD [wk(0)] ; xmm3=RE
-
- movdqa xmm4, xmm6
- punpcklwd xmm6, xmm2
- punpckhwd xmm4, xmm2
- movdqa xmm1, xmm6
- movdqa xmm5, xmm4
- pmaddwd xmm6, [rel PW_F0114_F0250] ; xmm6=BEL*FIX(0.114)+GEL*FIX(0.250)
- pmaddwd xmm4, [rel PW_F0114_F0250] ; xmm4=BEH*FIX(0.114)+GEH*FIX(0.250)
- pmaddwd xmm1, [rel PW_MF008_MF041] ; xmm1=BEL*-FIX(0.081)+GEL*-FIX(0.418)
- pmaddwd xmm5, [rel PW_MF008_MF041] ; xmm5=BEH*-FIX(0.081)+GEH*-FIX(0.418)
-
- movdqa xmm2, [rel PD_ONEHALF] ; xmm2=[PD_ONEHALF]
-
- paddd xmm6, XMMWORD [wk(6)]
- paddd xmm4, XMMWORD [wk(7)]
- paddd xmm6, xmm2
- paddd xmm4, xmm2
- psrld xmm6, SCALEBITS ; xmm6=YEL
- psrld xmm4, SCALEBITS ; xmm4=YEH
- packssdw xmm6, xmm4 ; xmm6=YE
-
- psllw xmm0, BYTE_BIT
- por xmm6, xmm0 ; xmm6=Y
- movdqa XMMWORD [rdi], xmm6 ; Save Y
-
- pxor xmm2, xmm2
- pxor xmm4, xmm4
- punpcklwd xmm2, xmm3 ; xmm2=REL
- punpckhwd xmm4, xmm3 ; xmm4=REH
- psrld xmm2, 1 ; xmm2=REL*FIX(0.500)
- psrld xmm4, 1 ; xmm4=REH*FIX(0.500)
-
- movdqa xmm0, [rel PD_ONEHALFM1_CJ] ; xmm0=[PD_ONEHALFM1_CJ]
-
- paddd xmm1, xmm2
- paddd xmm5, xmm4
- paddd xmm1, xmm0
- paddd xmm5, xmm0
- psrld xmm1, SCALEBITS ; xmm1=CrEL
- psrld xmm5, SCALEBITS ; xmm5=CrEH
- packssdw xmm1, xmm5 ; xmm1=CrE
-
- psllw xmm7, BYTE_BIT
- por xmm1, xmm7 ; xmm1=Cr
- movdqa XMMWORD [rdx], xmm1 ; Save Cr
-
- sub rcx, byte SIZEOF_XMMWORD
- add rsi, byte RGB_PIXELSIZE*SIZEOF_XMMWORD ; inptr
- add rdi, byte SIZEOF_XMMWORD ; outptr0
- add rbx, byte SIZEOF_XMMWORD ; outptr1
- add rdx, byte SIZEOF_XMMWORD ; outptr2
- cmp rcx, byte SIZEOF_XMMWORD
- jae near .columnloop
- test rcx, rcx
- jnz near .column_ld1
-
- pop rcx ; col
- pop rsi
- pop rdi
- pop rbx
- pop rdx
-
- add rsi, byte SIZEOF_JSAMPROW ; input_buf
- add rdi, byte SIZEOF_JSAMPROW
- add rbx, byte SIZEOF_JSAMPROW
- add rdx, byte SIZEOF_JSAMPROW
- dec rax ; num_rows
- jg near .rowloop
-
-.return:
- pop rbx
- uncollect_args 5
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
- pop rbp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jccolor-avx2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jccolor-avx2.asm
deleted file mode 100644
index 16b78298dc..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jccolor-avx2.asm
+++ /dev/null
@@ -1,121 +0,0 @@
-;
-; jccolor.asm - colorspace conversion (64-bit AVX2)
-;
-; Copyright (C) 2009, 2016, D. R. Commander.
-; Copyright (C) 2015, Intel Corporation.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jsimdext.inc"
-
-; --------------------------------------------------------------------------
-
-%define SCALEBITS 16
-
-F_0_081 equ 5329 ; FIX(0.08131)
-F_0_114 equ 7471 ; FIX(0.11400)
-F_0_168 equ 11059 ; FIX(0.16874)
-F_0_250 equ 16384 ; FIX(0.25000)
-F_0_299 equ 19595 ; FIX(0.29900)
-F_0_331 equ 21709 ; FIX(0.33126)
-F_0_418 equ 27439 ; FIX(0.41869)
-F_0_587 equ 38470 ; FIX(0.58700)
-F_0_337 equ (F_0_587 - F_0_250) ; FIX(0.58700) - FIX(0.25000)
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_rgb_ycc_convert_avx2)
-
-EXTN(jconst_rgb_ycc_convert_avx2):
-
-PW_F0299_F0337 times 8 dw F_0_299, F_0_337
-PW_F0114_F0250 times 8 dw F_0_114, F_0_250
-PW_MF016_MF033 times 8 dw -F_0_168, -F_0_331
-PW_MF008_MF041 times 8 dw -F_0_081, -F_0_418
-PD_ONEHALFM1_CJ times 8 dd (1 << (SCALEBITS - 1)) - 1 + \
- (CENTERJSAMPLE << SCALEBITS)
-PD_ONEHALF times 8 dd (1 << (SCALEBITS - 1))
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 64
-
-%include "jccolext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_RGB_RED
-%define RGB_GREEN EXT_RGB_GREEN
-%define RGB_BLUE EXT_RGB_BLUE
-%define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
-%define jsimd_rgb_ycc_convert_avx2 jsimd_extrgb_ycc_convert_avx2
-%include "jccolext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_RGBX_RED
-%define RGB_GREEN EXT_RGBX_GREEN
-%define RGB_BLUE EXT_RGBX_BLUE
-%define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
-%define jsimd_rgb_ycc_convert_avx2 jsimd_extrgbx_ycc_convert_avx2
-%include "jccolext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_BGR_RED
-%define RGB_GREEN EXT_BGR_GREEN
-%define RGB_BLUE EXT_BGR_BLUE
-%define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
-%define jsimd_rgb_ycc_convert_avx2 jsimd_extbgr_ycc_convert_avx2
-%include "jccolext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_BGRX_RED
-%define RGB_GREEN EXT_BGRX_GREEN
-%define RGB_BLUE EXT_BGRX_BLUE
-%define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
-%define jsimd_rgb_ycc_convert_avx2 jsimd_extbgrx_ycc_convert_avx2
-%include "jccolext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_XBGR_RED
-%define RGB_GREEN EXT_XBGR_GREEN
-%define RGB_BLUE EXT_XBGR_BLUE
-%define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
-%define jsimd_rgb_ycc_convert_avx2 jsimd_extxbgr_ycc_convert_avx2
-%include "jccolext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_XRGB_RED
-%define RGB_GREEN EXT_XRGB_GREEN
-%define RGB_BLUE EXT_XRGB_BLUE
-%define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
-%define jsimd_rgb_ycc_convert_avx2 jsimd_extxrgb_ycc_convert_avx2
-%include "jccolext-avx2.asm"
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jccolor-sse2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jccolor-sse2.asm
deleted file mode 100644
index e2955c2134..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jccolor-sse2.asm
+++ /dev/null
@@ -1,120 +0,0 @@
-;
-; jccolor.asm - colorspace conversion (64-bit SSE2)
-;
-; Copyright (C) 2009, 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jsimdext.inc"
-
-; --------------------------------------------------------------------------
-
-%define SCALEBITS 16
-
-F_0_081 equ 5329 ; FIX(0.08131)
-F_0_114 equ 7471 ; FIX(0.11400)
-F_0_168 equ 11059 ; FIX(0.16874)
-F_0_250 equ 16384 ; FIX(0.25000)
-F_0_299 equ 19595 ; FIX(0.29900)
-F_0_331 equ 21709 ; FIX(0.33126)
-F_0_418 equ 27439 ; FIX(0.41869)
-F_0_587 equ 38470 ; FIX(0.58700)
-F_0_337 equ (F_0_587 - F_0_250) ; FIX(0.58700) - FIX(0.25000)
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_rgb_ycc_convert_sse2)
-
-EXTN(jconst_rgb_ycc_convert_sse2):
-
-PW_F0299_F0337 times 4 dw F_0_299, F_0_337
-PW_F0114_F0250 times 4 dw F_0_114, F_0_250
-PW_MF016_MF033 times 4 dw -F_0_168, -F_0_331
-PW_MF008_MF041 times 4 dw -F_0_081, -F_0_418
-PD_ONEHALFM1_CJ times 4 dd (1 << (SCALEBITS - 1)) - 1 + \
- (CENTERJSAMPLE << SCALEBITS)
-PD_ONEHALF times 4 dd (1 << (SCALEBITS - 1))
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 64
-
-%include "jccolext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_RGB_RED
-%define RGB_GREEN EXT_RGB_GREEN
-%define RGB_BLUE EXT_RGB_BLUE
-%define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
-%define jsimd_rgb_ycc_convert_sse2 jsimd_extrgb_ycc_convert_sse2
-%include "jccolext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_RGBX_RED
-%define RGB_GREEN EXT_RGBX_GREEN
-%define RGB_BLUE EXT_RGBX_BLUE
-%define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
-%define jsimd_rgb_ycc_convert_sse2 jsimd_extrgbx_ycc_convert_sse2
-%include "jccolext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_BGR_RED
-%define RGB_GREEN EXT_BGR_GREEN
-%define RGB_BLUE EXT_BGR_BLUE
-%define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
-%define jsimd_rgb_ycc_convert_sse2 jsimd_extbgr_ycc_convert_sse2
-%include "jccolext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_BGRX_RED
-%define RGB_GREEN EXT_BGRX_GREEN
-%define RGB_BLUE EXT_BGRX_BLUE
-%define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
-%define jsimd_rgb_ycc_convert_sse2 jsimd_extbgrx_ycc_convert_sse2
-%include "jccolext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_XBGR_RED
-%define RGB_GREEN EXT_XBGR_GREEN
-%define RGB_BLUE EXT_XBGR_BLUE
-%define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
-%define jsimd_rgb_ycc_convert_sse2 jsimd_extxbgr_ycc_convert_sse2
-%include "jccolext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_XRGB_RED
-%define RGB_GREEN EXT_XRGB_GREEN
-%define RGB_BLUE EXT_XRGB_BLUE
-%define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
-%define jsimd_rgb_ycc_convert_sse2 jsimd_extxrgb_ycc_convert_sse2
-%include "jccolext-sse2.asm"
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jcgray-avx2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jcgray-avx2.asm
deleted file mode 100644
index 591255bb11..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jcgray-avx2.asm
+++ /dev/null
@@ -1,113 +0,0 @@
-;
-; jcgray.asm - grayscale colorspace conversion (64-bit AVX2)
-;
-; Copyright (C) 2011, 2016, D. R. Commander.
-; Copyright (C) 2015, Intel Corporation.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jsimdext.inc"
-
-; --------------------------------------------------------------------------
-
-%define SCALEBITS 16
-
-F_0_114 equ 7471 ; FIX(0.11400)
-F_0_250 equ 16384 ; FIX(0.25000)
-F_0_299 equ 19595 ; FIX(0.29900)
-F_0_587 equ 38470 ; FIX(0.58700)
-F_0_337 equ (F_0_587 - F_0_250) ; FIX(0.58700) - FIX(0.25000)
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_rgb_gray_convert_avx2)
-
-EXTN(jconst_rgb_gray_convert_avx2):
-
-PW_F0299_F0337 times 8 dw F_0_299, F_0_337
-PW_F0114_F0250 times 8 dw F_0_114, F_0_250
-PD_ONEHALF times 8 dd (1 << (SCALEBITS - 1))
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 64
-
-%include "jcgryext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_RGB_RED
-%define RGB_GREEN EXT_RGB_GREEN
-%define RGB_BLUE EXT_RGB_BLUE
-%define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
-%define jsimd_rgb_gray_convert_avx2 jsimd_extrgb_gray_convert_avx2
-%include "jcgryext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_RGBX_RED
-%define RGB_GREEN EXT_RGBX_GREEN
-%define RGB_BLUE EXT_RGBX_BLUE
-%define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
-%define jsimd_rgb_gray_convert_avx2 jsimd_extrgbx_gray_convert_avx2
-%include "jcgryext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_BGR_RED
-%define RGB_GREEN EXT_BGR_GREEN
-%define RGB_BLUE EXT_BGR_BLUE
-%define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
-%define jsimd_rgb_gray_convert_avx2 jsimd_extbgr_gray_convert_avx2
-%include "jcgryext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_BGRX_RED
-%define RGB_GREEN EXT_BGRX_GREEN
-%define RGB_BLUE EXT_BGRX_BLUE
-%define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
-%define jsimd_rgb_gray_convert_avx2 jsimd_extbgrx_gray_convert_avx2
-%include "jcgryext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_XBGR_RED
-%define RGB_GREEN EXT_XBGR_GREEN
-%define RGB_BLUE EXT_XBGR_BLUE
-%define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
-%define jsimd_rgb_gray_convert_avx2 jsimd_extxbgr_gray_convert_avx2
-%include "jcgryext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_XRGB_RED
-%define RGB_GREEN EXT_XRGB_GREEN
-%define RGB_BLUE EXT_XRGB_BLUE
-%define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
-%define jsimd_rgb_gray_convert_avx2 jsimd_extxrgb_gray_convert_avx2
-%include "jcgryext-avx2.asm"
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jcgray-sse2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jcgray-sse2.asm
deleted file mode 100644
index e389904f2f..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jcgray-sse2.asm
+++ /dev/null
@@ -1,112 +0,0 @@
-;
-; jcgray.asm - grayscale colorspace conversion (64-bit SSE2)
-;
-; Copyright (C) 2011, 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jsimdext.inc"
-
-; --------------------------------------------------------------------------
-
-%define SCALEBITS 16
-
-F_0_114 equ 7471 ; FIX(0.11400)
-F_0_250 equ 16384 ; FIX(0.25000)
-F_0_299 equ 19595 ; FIX(0.29900)
-F_0_587 equ 38470 ; FIX(0.58700)
-F_0_337 equ (F_0_587 - F_0_250) ; FIX(0.58700) - FIX(0.25000)
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_rgb_gray_convert_sse2)
-
-EXTN(jconst_rgb_gray_convert_sse2):
-
-PW_F0299_F0337 times 4 dw F_0_299, F_0_337
-PW_F0114_F0250 times 4 dw F_0_114, F_0_250
-PD_ONEHALF times 4 dd (1 << (SCALEBITS - 1))
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 64
-
-%include "jcgryext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_RGB_RED
-%define RGB_GREEN EXT_RGB_GREEN
-%define RGB_BLUE EXT_RGB_BLUE
-%define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
-%define jsimd_rgb_gray_convert_sse2 jsimd_extrgb_gray_convert_sse2
-%include "jcgryext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_RGBX_RED
-%define RGB_GREEN EXT_RGBX_GREEN
-%define RGB_BLUE EXT_RGBX_BLUE
-%define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
-%define jsimd_rgb_gray_convert_sse2 jsimd_extrgbx_gray_convert_sse2
-%include "jcgryext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_BGR_RED
-%define RGB_GREEN EXT_BGR_GREEN
-%define RGB_BLUE EXT_BGR_BLUE
-%define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
-%define jsimd_rgb_gray_convert_sse2 jsimd_extbgr_gray_convert_sse2
-%include "jcgryext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_BGRX_RED
-%define RGB_GREEN EXT_BGRX_GREEN
-%define RGB_BLUE EXT_BGRX_BLUE
-%define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
-%define jsimd_rgb_gray_convert_sse2 jsimd_extbgrx_gray_convert_sse2
-%include "jcgryext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_XBGR_RED
-%define RGB_GREEN EXT_XBGR_GREEN
-%define RGB_BLUE EXT_XBGR_BLUE
-%define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
-%define jsimd_rgb_gray_convert_sse2 jsimd_extxbgr_gray_convert_sse2
-%include "jcgryext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_XRGB_RED
-%define RGB_GREEN EXT_XRGB_GREEN
-%define RGB_BLUE EXT_XRGB_BLUE
-%define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
-%define jsimd_rgb_gray_convert_sse2 jsimd_extxrgb_gray_convert_sse2
-%include "jcgryext-sse2.asm"
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jcgryext-avx2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jcgryext-avx2.asm
deleted file mode 100644
index ddcc2c0a2f..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jcgryext-avx2.asm
+++ /dev/null
@@ -1,438 +0,0 @@
-;
-; jcgryext.asm - grayscale colorspace conversion (64-bit AVX2)
-;
-; Copyright (C) 2011, 2016, D. R. Commander.
-; Copyright (C) 2015, Intel Corporation.
-; Copyright (C) 2018, Matthias Räncker.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jcolsamp.inc"
-
-; --------------------------------------------------------------------------
-;
-; Convert some rows of samples to the output colorspace.
-;
-; GLOBAL(void)
-; jsimd_rgb_gray_convert_avx2(JDIMENSION img_width, JSAMPARRAY input_buf,
-; JSAMPIMAGE output_buf, JDIMENSION output_row,
-; int num_rows);
-;
-
-; r10d = JDIMENSION img_width
-; r11 = JSAMPARRAY input_buf
-; r12 = JSAMPIMAGE output_buf
-; r13d = JDIMENSION output_row
-; r14d = int num_rows
-
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_YMMWORD ; ymmword wk[WK_NUM]
-%define WK_NUM 2
-
- align 32
- GLOBAL_FUNCTION(jsimd_rgb_gray_convert_avx2)
-
-EXTN(jsimd_rgb_gray_convert_avx2):
- push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
- and rsp, byte (-SIZEOF_YMMWORD) ; align to 256 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
- collect_args 5
- push rbx
-
- mov ecx, r10d
- test rcx, rcx
- jz near .return
-
- push rcx
-
- mov rsi, r12
- mov ecx, r13d
- mov rdip, JSAMPARRAY [rsi+0*SIZEOF_JSAMPARRAY]
- lea rdi, [rdi+rcx*SIZEOF_JSAMPROW]
-
- pop rcx
-
- mov rsi, r11
- mov eax, r14d
- test rax, rax
- jle near .return
-.rowloop:
- push rdi
- push rsi
- push rcx ; col
-
- mov rsip, JSAMPROW [rsi] ; inptr
- mov rdip, JSAMPROW [rdi] ; outptr0
-
- cmp rcx, byte SIZEOF_YMMWORD
- jae near .columnloop
-
-%if RGB_PIXELSIZE == 3 ; ---------------
-
-.column_ld1:
- push rax
- push rdx
- lea rcx, [rcx+rcx*2] ; imul ecx,RGB_PIXELSIZE
- test cl, SIZEOF_BYTE
- jz short .column_ld2
- sub rcx, byte SIZEOF_BYTE
- movzx rax, byte [rsi+rcx]
-.column_ld2:
- test cl, SIZEOF_WORD
- jz short .column_ld4
- sub rcx, byte SIZEOF_WORD
- movzx rdx, word [rsi+rcx]
- shl rax, WORD_BIT
- or rax, rdx
-.column_ld4:
- vmovd xmmA, eax
- pop rdx
- pop rax
- test cl, SIZEOF_DWORD
- jz short .column_ld8
- sub rcx, byte SIZEOF_DWORD
- vmovd xmmF, XMM_DWORD [rsi+rcx]
- vpslldq xmmA, xmmA, SIZEOF_DWORD
- vpor xmmA, xmmA, xmmF
-.column_ld8:
- test cl, SIZEOF_MMWORD
- jz short .column_ld16
- sub rcx, byte SIZEOF_MMWORD
- vmovq xmmB, XMM_MMWORD [rsi+rcx]
- vpslldq xmmA, xmmA, SIZEOF_MMWORD
- vpor xmmA, xmmA, xmmB
-.column_ld16:
- test cl, SIZEOF_XMMWORD
- jz short .column_ld32
- sub rcx, byte SIZEOF_XMMWORD
- vmovdqu xmmB, XMM_MMWORD [rsi+rcx]
- vperm2i128 ymmA, ymmA, ymmA, 1
- vpor ymmA, ymmB
-.column_ld32:
- test cl, SIZEOF_YMMWORD
- jz short .column_ld64
- sub rcx, byte SIZEOF_YMMWORD
- vmovdqa ymmF, ymmA
- vmovdqu ymmA, YMMWORD [rsi+0*SIZEOF_YMMWORD]
-.column_ld64:
- test cl, 2*SIZEOF_YMMWORD
- mov rcx, SIZEOF_YMMWORD
- jz short .rgb_gray_cnv
- vmovdqa ymmB, ymmA
- vmovdqu ymmA, YMMWORD [rsi+0*SIZEOF_YMMWORD]
- vmovdqu ymmF, YMMWORD [rsi+1*SIZEOF_YMMWORD]
- jmp short .rgb_gray_cnv
-
-.columnloop:
- vmovdqu ymmA, YMMWORD [rsi+0*SIZEOF_YMMWORD]
- vmovdqu ymmF, YMMWORD [rsi+1*SIZEOF_YMMWORD]
- vmovdqu ymmB, YMMWORD [rsi+2*SIZEOF_YMMWORD]
-
-.rgb_gray_cnv:
- ; ymmA=(00 10 20 01 11 21 02 12 22 03 13 23 04 14 24 05
- ; 15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A)
- ; ymmF=(2A 0B 1B 2B 0C 1C 2C 0D 1D 2D 0E 1E 2E 0F 1F 2F
- ; 0G 1G 2G 0H 1H 2H 0I 1I 2I 0J 1J 2J 0K 1K 2K 0L)
- ; ymmB=(1L 2L 0M 1M 2M 0N 1N 2N 0O 1O 2O 0P 1P 2P 0Q 1Q
- ; 2Q 0R 1R 2R 0S 1S 2S 0T 1T 2T 0U 1U 2U 0V 1V 2V)
-
- vmovdqu ymmC, ymmA
- vinserti128 ymmA, ymmF, xmmA, 0 ; ymmA=(00 10 20 01 11 21 02 12 22 03 13 23 04 14 24 05
- ; 0G 1G 2G 0H 1H 2H 0I 1I 2I 0J 1J 2J 0K 1K 2K 0L)
- vinserti128 ymmC, ymmC, xmmB, 0 ; ymmC=(1L 2L 0M 1M 2M 0N 1N 2N 0O 1O 2O 0P 1P 2P 0Q 1Q
- ; 15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A)
- vinserti128 ymmB, ymmB, xmmF, 0 ; ymmB=(2A 0B 1B 2B 0C 1C 2C 0D 1D 2D 0E 1E 2E 0F 1F 2F
- ; 2Q 0R 1R 2R 0S 1S 2S 0T 1T 2T 0U 1U 2U 0V 1V 2V)
- vperm2i128 ymmF, ymmC, ymmC, 1 ; ymmF=(15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A
- ; 1L 2L 0M 1M 2M 0N 1N 2N 0O 1O 2O 0P 1P 2P 0Q 1Q)
-
- vmovdqa ymmG, ymmA
- vpslldq ymmA, ymmA, 8 ; ymmA=(-- -- -- -- -- -- -- -- 00 10 20 01 11 21 02 12
- ; 22 03 13 23 04 14 24 05 0G 1G 2G 0H 1H 2H 0I 1I)
- vpsrldq ymmG, ymmG, 8 ; ymmG=(22 03 13 23 04 14 24 05 0G 1G 2G 0H 1H 2H 0I 1I
- ; 2I 0J 1J 2J 0K 1K 2K 0L -- -- -- -- -- -- -- --)
-
- vpunpckhbw ymmA, ymmA, ymmF ; ymmA=(00 08 10 18 20 28 01 09 11 19 21 29 02 0A 12 1A
- ; 0G 0O 1G 1O 2G 2O 0H 0P 1H 1P 2H 2P 0I 0Q 1I 1Q)
- vpslldq ymmF, ymmF, 8 ; ymmF=(-- -- -- -- -- -- -- -- 15 25 06 16 26 07 17 27
- ; 08 18 28 09 19 29 0A 1A 1L 2L 0M 1M 2M 0N 1N 2N)
-
- vpunpcklbw ymmG, ymmG, ymmB ; ymmG=(22 2A 03 0B 13 1B 23 2B 04 0C 14 1C 24 2C 05 0D
- ; 2I 2Q 0J 0R 1J 1R 2J 2R 0K 0S 1K 1S 2K 2S 0L 0T)
- vpunpckhbw ymmF, ymmF, ymmB ; ymmF=(15 1D 25 2D 06 0E 16 1E 26 2E 07 0F 17 1F 27 2F
- ; 1L 1T 2L 2T 0M 0U 1M 1U 2M 2U 0N 0V 1N 1V 2N 2V)
-
- vmovdqa ymmD, ymmA
- vpslldq ymmA, ymmA, 8 ; ymmA=(-- -- -- -- -- -- -- -- 00 08 10 18 20 28 01 09
- ; 11 19 21 29 02 0A 12 1A 0G 0O 1G 1O 2G 2O 0H 0P)
- vpsrldq ymmD, ymmD, 8 ; ymmD=(11 19 21 29 02 0A 12 1A 0G 0O 1G 1O 2G 2O 0H 0P
- ; 1H 1P 2H 2P 0I 0Q 1I 1Q -- -- -- -- -- -- -- --)
-
- vpunpckhbw ymmA, ymmA, ymmG ; ymmA=(00 04 08 0C 10 14 18 1C 20 24 28 2C 01 05 09 0D
- ; 0G 0K 0O 0S 1G 1K 1O 1S 2G 2K 2O 2S 0H 0L 0P 0T)
- vpslldq ymmG, ymmG, 8 ; ymmG=(-- -- -- -- -- -- -- -- 22 2A 03 0B 13 1B 23 2B
- ; 04 0C 14 1C 24 2C 05 0D 2I 2Q 0J 0R 1J 1R 2J 2R)
-
- vpunpcklbw ymmD, ymmD, ymmF ; ymmD=(11 15 19 1D 21 25 29 2D 02 06 0A 0E 12 16 1A 1E
- ; 1H 1L 1P 1T 2H 2L 2P 2T 0I 0M 0Q 0U 1I 1M 1Q 1U)
- vpunpckhbw ymmG, ymmG, ymmF ; ymmG=(22 26 2A 2E 03 07 0B 0F 13 17 1B 1F 23 27 2B 2F
- ; 2I 2M 2Q 2U 0J 0N 0R 0V 1J 1N 1R 1V 2J 2N 2R 2V)
-
- vmovdqa ymmE, ymmA
- vpslldq ymmA, ymmA, 8 ; ymmA=(-- -- -- -- -- -- -- -- 00 04 08 0C 10 14 18 1C
- ; 20 24 28 2C 01 05 09 0D 0G 0K 0O 0S 1G 1K 1O 1S)
- vpsrldq ymmE, ymmE, 8 ; ymmE=(20 24 28 2C 01 05 09 0D 0G 0K 0O 0S 1G 1K 1O 1S
- ; 2G 2K 2O 2S 0H 0L 0P 0T -- -- -- -- -- -- -- --)
-
- vpunpckhbw ymmA, ymmA, ymmD ; ymmA=(00 02 04 06 08 0A 0C 0E 10 12 14 16 18 1A 1C 1E
- ; 0G 0I 0K 0M 0O 0Q 0S 0U 1G 1I 1K 1M 1O 1Q 1S 1U)
- vpslldq ymmD, ymmD, 8 ; ymmD=(-- -- -- -- -- -- -- -- 11 15 19 1D 21 25 29 2D
- ; 02 06 0A 0E 12 16 1A 1E 1H 1L 1P 1T 2H 2L 2P 2T)
-
- vpunpcklbw ymmE, ymmE, ymmG ; ymmE=(20 22 24 26 28 2A 2C 2E 01 03 05 07 09 0B 0D 0F
- ; 2G 2I 2K 2M 2O 2Q 2S 2U 0H 0J 0L 0N 0P 0R 0T 0V)
- vpunpckhbw ymmD, ymmD, ymmG ; ymmD=(11 13 15 17 19 1B 1D 1F 21 23 25 27 29 2B 2D 2F
- ; 1H 1J 1L 1N 1P 1R 1T 1V 2H 2J 2L 2N 2P 2R 2T 2V)
-
- vpxor ymmH, ymmH, ymmH
-
- vmovdqa ymmC, ymmA
- vpunpcklbw ymmA, ymmA, ymmH ; ymmA=(00 02 04 06 08 0A 0C 0E 0G 0I 0K 0M 0O 0Q 0S 0U)
- vpunpckhbw ymmC, ymmC, ymmH ; ymmC=(10 12 14 16 18 1A 1C 1E 1G 1I 1K 1M 1O 1Q 1S 1U)
-
- vmovdqa ymmB, ymmE
- vpunpcklbw ymmE, ymmE, ymmH ; ymmE=(20 22 24 26 28 2A 2C 2E 2G 2I 2K 2M 2O 2Q 2S 2U)
- vpunpckhbw ymmB, ymmB, ymmH ; ymmB=(01 03 05 07 09 0B 0D 0F 0H 0J 0L 0N 0P 0R 0T 0V)
-
- vmovdqa ymmF, ymmD
- vpunpcklbw ymmD, ymmD, ymmH ; ymmD=(11 13 15 17 19 1B 1D 1F 1H 1J 1L 1N 1P 1R 1T 1V)
- vpunpckhbw ymmF, ymmF, ymmH ; ymmF=(21 23 25 27 29 2B 2D 2F 2H 2J 2L 2N 2P 2R 2T 2V)
-
-%else ; RGB_PIXELSIZE == 4 ; -----------
-
-.column_ld1:
- test cl, SIZEOF_XMMWORD/16
- jz short .column_ld2
- sub rcx, byte SIZEOF_XMMWORD/16
- vmovd xmmA, XMM_DWORD [rsi+rcx*RGB_PIXELSIZE]
-.column_ld2:
- test cl, SIZEOF_XMMWORD/8
- jz short .column_ld4
- sub rcx, byte SIZEOF_XMMWORD/8
- vmovq xmmF, XMM_MMWORD [rsi+rcx*RGB_PIXELSIZE]
- vpslldq xmmA, xmmA, SIZEOF_MMWORD
- vpor xmmA, xmmA, xmmF
-.column_ld4:
- test cl, SIZEOF_XMMWORD/4
- jz short .column_ld8
- sub rcx, byte SIZEOF_XMMWORD/4
- vmovdqa xmmF, xmmA
- vperm2i128 ymmF, ymmF, ymmF, 1
- vmovdqu xmmA, XMMWORD [rsi+rcx*RGB_PIXELSIZE]
- vpor ymmA, ymmA, ymmF
-.column_ld8:
- test cl, SIZEOF_XMMWORD/2
- jz short .column_ld16
- sub rcx, byte SIZEOF_XMMWORD/2
- vmovdqa ymmF, ymmA
- vmovdqu ymmA, YMMWORD [rsi+rcx*RGB_PIXELSIZE]
-.column_ld16:
- test cl, SIZEOF_XMMWORD
- mov rcx, SIZEOF_YMMWORD
- jz short .rgb_gray_cnv
- vmovdqa ymmE, ymmA
- vmovdqa ymmH, ymmF
- vmovdqu ymmA, YMMWORD [rsi+0*SIZEOF_YMMWORD]
- vmovdqu ymmF, YMMWORD [rsi+1*SIZEOF_YMMWORD]
- jmp short .rgb_gray_cnv
-
-.columnloop:
- vmovdqu ymmA, YMMWORD [rsi+0*SIZEOF_YMMWORD]
- vmovdqu ymmF, YMMWORD [rsi+1*SIZEOF_YMMWORD]
- vmovdqu ymmE, YMMWORD [rsi+2*SIZEOF_YMMWORD]
- vmovdqu ymmH, YMMWORD [rsi+3*SIZEOF_YMMWORD]
-
-.rgb_gray_cnv:
- ; ymmA=(00 10 20 30 01 11 21 31 02 12 22 32 03 13 23 33
- ; 04 14 24 34 05 15 25 35 06 16 26 36 07 17 27 37)
- ; ymmF=(08 18 28 38 09 19 29 39 0A 1A 2A 3A 0B 1B 2B 3B
- ; 0C 1C 2C 3C 0D 1D 2D 3D 0E 1E 2E 3E 0F 1F 2F 3F)
- ; ymmE=(0G 1G 2G 3G 0H 1H 2H 3H 0I 1I 2I 3I 0J 1J 2J 3J
- ; 0K 1K 2K 3K 0L 1L 2L 3L 0M 1M 2M 3M 0N 1N 2N 3N)
- ; ymmH=(0O 1O 2O 3O 0P 1P 2P 3P 0Q 1Q 2Q 3Q 0R 1R 2R 3R
- ; 0S 1S 2S 3S 0T 1T 2T 3T 0U 1U 2U 3U 0V 1V 2V 3V)
-
- vmovdqa ymmB, ymmA
- vinserti128 ymmA, ymmA, xmmE, 1 ; ymmA=(00 10 20 30 01 11 21 31 02 12 22 32 03 13 23 33
- ; 0G 1G 2G 3G 0H 1H 2H 3H 0I 1I 2I 3I 0J 1J 2J 3J)
- vperm2i128 ymmE, ymmB, ymmE, 0x31 ; ymmE=(04 14 24 34 05 15 25 35 06 16 26 36 07 17 27 37
- ; 0K 1K 2K 3K 0L 1L 2L 3L 0M 1M 2M 3M 0N 1N 2N 3N)
-
- vmovdqa ymmB, ymmF
- vinserti128 ymmF, ymmF, xmmH, 1 ; ymmF=(08 18 28 38 09 19 29 39 0A 1A 2A 3A 0B 1B 2B 3B
- ; 0O 1O 2O 3O 0P 1P 2P 3P 0Q 1Q 2Q 3Q 0R 1R 2R 3R)
- vperm2i128 ymmH, ymmB, ymmH, 0x31 ; ymmH=(0C 1C 2C 3C 0D 1D 2D 3D 0E 1E 2E 3E 0F 1F 2F 3F
- ; 0S 1S 2S 3S 0T 1T 2T 3T 0U 1U 2U 3U 0V 1V 2V 3V)
-
- vmovdqa ymmD, ymmA
- vpunpcklbw ymmA, ymmA, ymmE ; ymmA=(00 04 10 14 20 24 30 34 01 05 11 15 21 25 31 35
- ; 0G 0K 1G 1K 2G 2K 3G 3K 0H 0L 1H 1L 2H 2L 3H 3L)
- vpunpckhbw ymmD, ymmD, ymmE ; ymmD=(02 06 12 16 22 26 32 36 03 07 13 17 23 27 33 37
- ; 0I 0M 1I 1M 2I 2M 3I 3M 0J 0N 1J 1N 2J 2N 3J 3N)
-
- vmovdqa ymmC, ymmF
- vpunpcklbw ymmF, ymmF, ymmH ; ymmF=(08 0C 18 1C 28 2C 38 3C 09 0D 19 1D 29 2D 39 3D
- ; 0O 0S 1O 1S 2O 2S 3O 3S 0P 0T 1P 1T 2P 2T 3P 3T)
- vpunpckhbw ymmC, ymmC, ymmH ; ymmC=(0A 0E 1A 1E 2A 2E 3A 3E 0B 0F 1B 1F 2B 2F 3B 3F
- ; 0Q 0U 1Q 1U 2Q 2U 3Q 3U 0R 0V 1R 1V 2R 2V 3R 3V)
-
- vmovdqa ymmB, ymmA
- vpunpcklwd ymmA, ymmA, ymmF ; ymmA=(00 04 08 0C 10 14 18 1C 20 24 28 2C 30 34 38 3C
- ; 0G 0K 0O 0S 1G 1K 1O 1S 2G 2K 2O 2S 3G 3K 3O 3S)
- vpunpckhwd ymmB, ymmB, ymmF ; ymmB=(01 05 09 0D 11 15 19 1D 21 25 29 2D 31 35 39 3D
- ; 0H 0L 0P 0T 1H 1L 1P 1T 2H 2L 2P 2T 3H 3L 3P 3T)
-
- vmovdqa ymmG, ymmD
- vpunpcklwd ymmD, ymmD, ymmC ; ymmD=(02 06 0A 0E 12 16 1A 1E 22 26 2A 2E 32 36 3A 3E
- ; 0I 0M 0Q 0U 1I 1M 1Q 1U 2I 2M 2Q 2U 3I 3M 3Q 3U)
- vpunpckhwd ymmG, ymmG, ymmC ; ymmG=(03 07 0B 0F 13 17 1B 1F 23 27 2B 2F 33 37 3B 3F
- ; 0J 0N 0R 0V 1J 1N 1R 1V 2J 2N 2R 2V 3J 3N 3R 3V)
-
- vmovdqa ymmE, ymmA
- vpunpcklbw ymmA, ymmA, ymmD ; ymmA=(00 02 04 06 08 0A 0C 0E 10 12 14 16 18 1A 1C 1E
- ; 0G 0I 0K 0M 0O 0Q 0S 0U 1G 1I 1K 1M 1O 1Q 1S 1U)
- vpunpckhbw ymmE, ymmE, ymmD ; ymmE=(20 22 24 26 28 2A 2C 2E 30 32 34 36 38 3A 3C 3E
- ; 2G 2I 2K 2M 2O 2Q 2S 2U 3G 3I 3K 3M 3O 3Q 3S 3U)
-
- vmovdqa ymmH, ymmB
- vpunpcklbw ymmB, ymmB, ymmG ; ymmB=(01 03 05 07 09 0B 0D 0F 11 13 15 17 19 1B 1D 1F
- ; 0H 0J 0L 0N 0P 0R 0T 0V 1H 1J 1L 1N 1P 1R 1T 1V)
- vpunpckhbw ymmH, ymmH, ymmG ; ymmH=(21 23 25 27 29 2B 2D 2F 31 33 35 37 39 3B 3D 3F
- ; 2H 2J 2L 2N 2P 2R 2T 2V 3H 3J 3L 3N 3P 3R 3T 3V)
-
- vpxor ymmF, ymmF, ymmF
-
- vmovdqa ymmC, ymmA
- vpunpcklbw ymmA, ymmA, ymmF ; ymmA=(00 02 04 06 08 0A 0C 0E 0G 0I 0K 0M 0O 0Q 0S 0U)
- vpunpckhbw ymmC, ymmC, ymmF ; ymmC=(10 12 14 16 18 1A 1C 1E 1G 1I 1K 1M 1O 1Q 1S 1U)
-
- vmovdqa ymmD, ymmB
- vpunpcklbw ymmB, ymmB, ymmF ; ymmB=(01 03 05 07 09 0B 0D 0F 0H 0J 0L 0N 0P 0R 0T 0V)
- vpunpckhbw ymmD, ymmD, ymmF ; ymmD=(11 13 15 17 19 1B 1D 1F 1H 1J 1L 1N 1P 1R 1T 1V)
-
- vmovdqa ymmG, ymmE
- vpunpcklbw ymmE, ymmE, ymmF ; ymmE=(20 22 24 26 28 2A 2C 2E 2G 2I 2K 2M 2O 2Q 2S 2U)
- vpunpckhbw ymmG, ymmG, ymmF ; ymmG=(30 32 34 36 38 3A 3C 3E 3G 3I 3K 3M 3O 3Q 3S 3U)
-
- vpunpcklbw ymmF, ymmF, ymmH
- vpunpckhbw ymmH, ymmH, ymmH
- vpsrlw ymmF, ymmF, BYTE_BIT ; ymmF=(21 23 25 27 29 2B 2D 2F 2H 2J 2L 2N 2P 2R 2T 2V)
- vpsrlw ymmH, ymmH, BYTE_BIT ; ymmH=(31 33 35 37 39 3B 3D 3F 3H 3J 3L 3N 3P 3R 3T 3V)
-
-%endif ; RGB_PIXELSIZE ; ---------------
-
- ; ymm0=R(02468ACEGIKMOQSU)=RE, ymm2=G(02468ACEGIKMOQSU)=GE, ymm4=B(02468ACEGIKMOQSU)=BE
- ; ymm1=R(13579BDFHJLNPRTV)=RO, ymm3=G(13579BDFHJLNPRTV)=GO, ymm5=B(13579BDFHJLNPRTV)=BO
-
- ; (Original)
- ; Y = 0.29900 * R + 0.58700 * G + 0.11400 * B
- ;
- ; (This implementation)
- ; Y = 0.29900 * R + 0.33700 * G + 0.11400 * B + 0.25000 * G
-
- vmovdqa ymm6, ymm1
- vpunpcklwd ymm1, ymm1, ymm3
- vpunpckhwd ymm6, ymm6, ymm3
- vpmaddwd ymm1, ymm1, [rel PW_F0299_F0337] ; ymm1=ROL*FIX(0.299)+GOL*FIX(0.337)
- vpmaddwd ymm6, ymm6, [rel PW_F0299_F0337] ; ymm6=ROH*FIX(0.299)+GOH*FIX(0.337)
-
- vmovdqa ymm7, ymm6 ; ymm7=ROH*FIX(0.299)+GOH*FIX(0.337)
-
- vmovdqa ymm6, ymm0
- vpunpcklwd ymm0, ymm0, ymm2
- vpunpckhwd ymm6, ymm6, ymm2
- vpmaddwd ymm0, ymm0, [rel PW_F0299_F0337] ; ymm0=REL*FIX(0.299)+GEL*FIX(0.337)
- vpmaddwd ymm6, ymm6, [rel PW_F0299_F0337] ; ymm6=REH*FIX(0.299)+GEH*FIX(0.337)
-
- vmovdqa YMMWORD [wk(0)], ymm0 ; wk(0)=REL*FIX(0.299)+GEL*FIX(0.337)
- vmovdqa YMMWORD [wk(1)], ymm6 ; wk(1)=REH*FIX(0.299)+GEH*FIX(0.337)
-
- vmovdqa ymm0, ymm5 ; ymm0=BO
- vmovdqa ymm6, ymm4 ; ymm6=BE
-
- vmovdqa ymm4, ymm0
- vpunpcklwd ymm0, ymm0, ymm3
- vpunpckhwd ymm4, ymm4, ymm3
- vpmaddwd ymm0, ymm0, [rel PW_F0114_F0250] ; ymm0=BOL*FIX(0.114)+GOL*FIX(0.250)
- vpmaddwd ymm4, ymm4, [rel PW_F0114_F0250] ; ymm4=BOH*FIX(0.114)+GOH*FIX(0.250)
-
- vmovdqa ymm3, [rel PD_ONEHALF] ; ymm3=[PD_ONEHALF]
-
- vpaddd ymm0, ymm0, ymm1
- vpaddd ymm4, ymm4, ymm7
- vpaddd ymm0, ymm0, ymm3
- vpaddd ymm4, ymm4, ymm3
- vpsrld ymm0, ymm0, SCALEBITS ; ymm0=YOL
- vpsrld ymm4, ymm4, SCALEBITS ; ymm4=YOH
- vpackssdw ymm0, ymm0, ymm4 ; ymm0=YO
-
- vmovdqa ymm4, ymm6
- vpunpcklwd ymm6, ymm6, ymm2
- vpunpckhwd ymm4, ymm4, ymm2
- vpmaddwd ymm6, ymm6, [rel PW_F0114_F0250] ; ymm6=BEL*FIX(0.114)+GEL*FIX(0.250)
- vpmaddwd ymm4, ymm4, [rel PW_F0114_F0250] ; ymm4=BEH*FIX(0.114)+GEH*FIX(0.250)
-
- vmovdqa ymm2, [rel PD_ONEHALF] ; ymm2=[PD_ONEHALF]
-
- vpaddd ymm6, ymm6, YMMWORD [wk(0)]
- vpaddd ymm4, ymm4, YMMWORD [wk(1)]
- vpaddd ymm6, ymm6, ymm2
- vpaddd ymm4, ymm4, ymm2
- vpsrld ymm6, ymm6, SCALEBITS ; ymm6=YEL
- vpsrld ymm4, ymm4, SCALEBITS ; ymm4=YEH
- vpackssdw ymm6, ymm6, ymm4 ; ymm6=YE
-
- vpsllw ymm0, ymm0, BYTE_BIT
- vpor ymm6, ymm6, ymm0 ; ymm6=Y
- vmovdqu YMMWORD [rdi], ymm6 ; Save Y
-
- sub rcx, byte SIZEOF_YMMWORD
- add rsi, RGB_PIXELSIZE*SIZEOF_YMMWORD ; inptr
- add rdi, byte SIZEOF_YMMWORD ; outptr0
- cmp rcx, byte SIZEOF_YMMWORD
- jae near .columnloop
- test rcx, rcx
- jnz near .column_ld1
-
- pop rcx ; col
- pop rsi
- pop rdi
-
- add rsi, byte SIZEOF_JSAMPROW ; input_buf
- add rdi, byte SIZEOF_JSAMPROW
- dec rax ; num_rows
- jg near .rowloop
-
-.return:
- pop rbx
- vzeroupper
- uncollect_args 5
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
- pop rbp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jcgryext-sse2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jcgryext-sse2.asm
deleted file mode 100644
index f1d399a63b..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jcgryext-sse2.asm
+++ /dev/null
@@ -1,363 +0,0 @@
-;
-; jcgryext.asm - grayscale colorspace conversion (64-bit SSE2)
-;
-; Copyright (C) 2011, 2016, D. R. Commander.
-; Copyright (C) 2018, Matthias Räncker.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jcolsamp.inc"
-
-; --------------------------------------------------------------------------
-;
-; Convert some rows of samples to the output colorspace.
-;
-; GLOBAL(void)
-; jsimd_rgb_gray_convert_sse2(JDIMENSION img_width, JSAMPARRAY input_buf,
-; JSAMPIMAGE output_buf, JDIMENSION output_row,
-; int num_rows);
-;
-
-; r10d = JDIMENSION img_width
-; r11 = JSAMPARRAY input_buf
-; r12 = JSAMPIMAGE output_buf
-; r13d = JDIMENSION output_row
-; r14d = int num_rows
-
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
-%define WK_NUM 2
-
- align 32
- GLOBAL_FUNCTION(jsimd_rgb_gray_convert_sse2)
-
-EXTN(jsimd_rgb_gray_convert_sse2):
- push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
- and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
- collect_args 5
- push rbx
-
- mov ecx, r10d
- test rcx, rcx
- jz near .return
-
- push rcx
-
- mov rsi, r12
- mov ecx, r13d
- mov rdip, JSAMPARRAY [rsi+0*SIZEOF_JSAMPARRAY]
- lea rdi, [rdi+rcx*SIZEOF_JSAMPROW]
-
- pop rcx
-
- mov rsi, r11
- mov eax, r14d
- test rax, rax
- jle near .return
-.rowloop:
- push rdi
- push rsi
- push rcx ; col
-
- mov rsip, JSAMPROW [rsi] ; inptr
- mov rdip, JSAMPROW [rdi] ; outptr0
-
- cmp rcx, byte SIZEOF_XMMWORD
- jae near .columnloop
-
-%if RGB_PIXELSIZE == 3 ; ---------------
-
-.column_ld1:
- push rax
- push rdx
- lea rcx, [rcx+rcx*2] ; imul ecx,RGB_PIXELSIZE
- test cl, SIZEOF_BYTE
- jz short .column_ld2
- sub rcx, byte SIZEOF_BYTE
- movzx rax, byte [rsi+rcx]
-.column_ld2:
- test cl, SIZEOF_WORD
- jz short .column_ld4
- sub rcx, byte SIZEOF_WORD
- movzx rdx, word [rsi+rcx]
- shl rax, WORD_BIT
- or rax, rdx
-.column_ld4:
- movd xmmA, eax
- pop rdx
- pop rax
- test cl, SIZEOF_DWORD
- jz short .column_ld8
- sub rcx, byte SIZEOF_DWORD
- movd xmmF, XMM_DWORD [rsi+rcx]
- pslldq xmmA, SIZEOF_DWORD
- por xmmA, xmmF
-.column_ld8:
- test cl, SIZEOF_MMWORD
- jz short .column_ld16
- sub rcx, byte SIZEOF_MMWORD
- movq xmmB, XMM_MMWORD [rsi+rcx]
- pslldq xmmA, SIZEOF_MMWORD
- por xmmA, xmmB
-.column_ld16:
- test cl, SIZEOF_XMMWORD
- jz short .column_ld32
- movdqa xmmF, xmmA
- movdqu xmmA, XMMWORD [rsi+0*SIZEOF_XMMWORD]
- mov rcx, SIZEOF_XMMWORD
- jmp short .rgb_gray_cnv
-.column_ld32:
- test cl, 2*SIZEOF_XMMWORD
- mov rcx, SIZEOF_XMMWORD
- jz short .rgb_gray_cnv
- movdqa xmmB, xmmA
- movdqu xmmA, XMMWORD [rsi+0*SIZEOF_XMMWORD]
- movdqu xmmF, XMMWORD [rsi+1*SIZEOF_XMMWORD]
- jmp short .rgb_gray_cnv
-
-.columnloop:
- movdqu xmmA, XMMWORD [rsi+0*SIZEOF_XMMWORD]
- movdqu xmmF, XMMWORD [rsi+1*SIZEOF_XMMWORD]
- movdqu xmmB, XMMWORD [rsi+2*SIZEOF_XMMWORD]
-
-.rgb_gray_cnv:
- ; xmmA=(00 10 20 01 11 21 02 12 22 03 13 23 04 14 24 05)
- ; xmmF=(15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A)
- ; xmmB=(2A 0B 1B 2B 0C 1C 2C 0D 1D 2D 0E 1E 2E 0F 1F 2F)
-
- movdqa xmmG, xmmA
- pslldq xmmA, 8 ; xmmA=(-- -- -- -- -- -- -- -- 00 10 20 01 11 21 02 12)
- psrldq xmmG, 8 ; xmmG=(22 03 13 23 04 14 24 05 -- -- -- -- -- -- -- --)
-
- punpckhbw xmmA, xmmF ; xmmA=(00 08 10 18 20 28 01 09 11 19 21 29 02 0A 12 1A)
- pslldq xmmF, 8 ; xmmF=(-- -- -- -- -- -- -- -- 15 25 06 16 26 07 17 27)
-
- punpcklbw xmmG, xmmB ; xmmG=(22 2A 03 0B 13 1B 23 2B 04 0C 14 1C 24 2C 05 0D)
- punpckhbw xmmF, xmmB ; xmmF=(15 1D 25 2D 06 0E 16 1E 26 2E 07 0F 17 1F 27 2F)
-
- movdqa xmmD, xmmA
- pslldq xmmA, 8 ; xmmA=(-- -- -- -- -- -- -- -- 00 08 10 18 20 28 01 09)
- psrldq xmmD, 8 ; xmmD=(11 19 21 29 02 0A 12 1A -- -- -- -- -- -- -- --)
-
- punpckhbw xmmA, xmmG ; xmmA=(00 04 08 0C 10 14 18 1C 20 24 28 2C 01 05 09 0D)
- pslldq xmmG, 8 ; xmmG=(-- -- -- -- -- -- -- -- 22 2A 03 0B 13 1B 23 2B)
-
- punpcklbw xmmD, xmmF ; xmmD=(11 15 19 1D 21 25 29 2D 02 06 0A 0E 12 16 1A 1E)
- punpckhbw xmmG, xmmF ; xmmG=(22 26 2A 2E 03 07 0B 0F 13 17 1B 1F 23 27 2B 2F)
-
- movdqa xmmE, xmmA
- pslldq xmmA, 8 ; xmmA=(-- -- -- -- -- -- -- -- 00 04 08 0C 10 14 18 1C)
- psrldq xmmE, 8 ; xmmE=(20 24 28 2C 01 05 09 0D -- -- -- -- -- -- -- --)
-
- punpckhbw xmmA, xmmD ; xmmA=(00 02 04 06 08 0A 0C 0E 10 12 14 16 18 1A 1C 1E)
- pslldq xmmD, 8 ; xmmD=(-- -- -- -- -- -- -- -- 11 15 19 1D 21 25 29 2D)
-
- punpcklbw xmmE, xmmG ; xmmE=(20 22 24 26 28 2A 2C 2E 01 03 05 07 09 0B 0D 0F)
- punpckhbw xmmD, xmmG ; xmmD=(11 13 15 17 19 1B 1D 1F 21 23 25 27 29 2B 2D 2F)
-
- pxor xmmH, xmmH
-
- movdqa xmmC, xmmA
- punpcklbw xmmA, xmmH ; xmmA=(00 02 04 06 08 0A 0C 0E)
- punpckhbw xmmC, xmmH ; xmmC=(10 12 14 16 18 1A 1C 1E)
-
- movdqa xmmB, xmmE
- punpcklbw xmmE, xmmH ; xmmE=(20 22 24 26 28 2A 2C 2E)
- punpckhbw xmmB, xmmH ; xmmB=(01 03 05 07 09 0B 0D 0F)
-
- movdqa xmmF, xmmD
- punpcklbw xmmD, xmmH ; xmmD=(11 13 15 17 19 1B 1D 1F)
- punpckhbw xmmF, xmmH ; xmmF=(21 23 25 27 29 2B 2D 2F)
-
-%else ; RGB_PIXELSIZE == 4 ; -----------
-
-.column_ld1:
- test cl, SIZEOF_XMMWORD/16
- jz short .column_ld2
- sub rcx, byte SIZEOF_XMMWORD/16
- movd xmmA, XMM_DWORD [rsi+rcx*RGB_PIXELSIZE]
-.column_ld2:
- test cl, SIZEOF_XMMWORD/8
- jz short .column_ld4
- sub rcx, byte SIZEOF_XMMWORD/8
- movq xmmE, XMM_MMWORD [rsi+rcx*RGB_PIXELSIZE]
- pslldq xmmA, SIZEOF_MMWORD
- por xmmA, xmmE
-.column_ld4:
- test cl, SIZEOF_XMMWORD/4
- jz short .column_ld8
- sub rcx, byte SIZEOF_XMMWORD/4
- movdqa xmmE, xmmA
- movdqu xmmA, XMMWORD [rsi+rcx*RGB_PIXELSIZE]
-.column_ld8:
- test cl, SIZEOF_XMMWORD/2
- mov rcx, SIZEOF_XMMWORD
- jz short .rgb_gray_cnv
- movdqa xmmF, xmmA
- movdqa xmmH, xmmE
- movdqu xmmA, XMMWORD [rsi+0*SIZEOF_XMMWORD]
- movdqu xmmE, XMMWORD [rsi+1*SIZEOF_XMMWORD]
- jmp short .rgb_gray_cnv
-
-.columnloop:
- movdqu xmmA, XMMWORD [rsi+0*SIZEOF_XMMWORD]
- movdqu xmmE, XMMWORD [rsi+1*SIZEOF_XMMWORD]
- movdqu xmmF, XMMWORD [rsi+2*SIZEOF_XMMWORD]
- movdqu xmmH, XMMWORD [rsi+3*SIZEOF_XMMWORD]
-
-.rgb_gray_cnv:
- ; xmmA=(00 10 20 30 01 11 21 31 02 12 22 32 03 13 23 33)
- ; xmmE=(04 14 24 34 05 15 25 35 06 16 26 36 07 17 27 37)
- ; xmmF=(08 18 28 38 09 19 29 39 0A 1A 2A 3A 0B 1B 2B 3B)
- ; xmmH=(0C 1C 2C 3C 0D 1D 2D 3D 0E 1E 2E 3E 0F 1F 2F 3F)
-
- movdqa xmmD, xmmA
- punpcklbw xmmA, xmmE ; xmmA=(00 04 10 14 20 24 30 34 01 05 11 15 21 25 31 35)
- punpckhbw xmmD, xmmE ; xmmD=(02 06 12 16 22 26 32 36 03 07 13 17 23 27 33 37)
-
- movdqa xmmC, xmmF
- punpcklbw xmmF, xmmH ; xmmF=(08 0C 18 1C 28 2C 38 3C 09 0D 19 1D 29 2D 39 3D)
- punpckhbw xmmC, xmmH ; xmmC=(0A 0E 1A 1E 2A 2E 3A 3E 0B 0F 1B 1F 2B 2F 3B 3F)
-
- movdqa xmmB, xmmA
- punpcklwd xmmA, xmmF ; xmmA=(00 04 08 0C 10 14 18 1C 20 24 28 2C 30 34 38 3C)
- punpckhwd xmmB, xmmF ; xmmB=(01 05 09 0D 11 15 19 1D 21 25 29 2D 31 35 39 3D)
-
- movdqa xmmG, xmmD
- punpcklwd xmmD, xmmC ; xmmD=(02 06 0A 0E 12 16 1A 1E 22 26 2A 2E 32 36 3A 3E)
- punpckhwd xmmG, xmmC ; xmmG=(03 07 0B 0F 13 17 1B 1F 23 27 2B 2F 33 37 3B 3F)
-
- movdqa xmmE, xmmA
- punpcklbw xmmA, xmmD ; xmmA=(00 02 04 06 08 0A 0C 0E 10 12 14 16 18 1A 1C 1E)
- punpckhbw xmmE, xmmD ; xmmE=(20 22 24 26 28 2A 2C 2E 30 32 34 36 38 3A 3C 3E)
-
- movdqa xmmH, xmmB
- punpcklbw xmmB, xmmG ; xmmB=(01 03 05 07 09 0B 0D 0F 11 13 15 17 19 1B 1D 1F)
- punpckhbw xmmH, xmmG ; xmmH=(21 23 25 27 29 2B 2D 2F 31 33 35 37 39 3B 3D 3F)
-
- pxor xmmF, xmmF
-
- movdqa xmmC, xmmA
- punpcklbw xmmA, xmmF ; xmmA=(00 02 04 06 08 0A 0C 0E)
- punpckhbw xmmC, xmmF ; xmmC=(10 12 14 16 18 1A 1C 1E)
-
- movdqa xmmD, xmmB
- punpcklbw xmmB, xmmF ; xmmB=(01 03 05 07 09 0B 0D 0F)
- punpckhbw xmmD, xmmF ; xmmD=(11 13 15 17 19 1B 1D 1F)
-
- movdqa xmmG, xmmE
- punpcklbw xmmE, xmmF ; xmmE=(20 22 24 26 28 2A 2C 2E)
- punpckhbw xmmG, xmmF ; xmmG=(30 32 34 36 38 3A 3C 3E)
-
- punpcklbw xmmF, xmmH
- punpckhbw xmmH, xmmH
- psrlw xmmF, BYTE_BIT ; xmmF=(21 23 25 27 29 2B 2D 2F)
- psrlw xmmH, BYTE_BIT ; xmmH=(31 33 35 37 39 3B 3D 3F)
-
-%endif ; RGB_PIXELSIZE ; ---------------
-
- ; xmm0=R(02468ACE)=RE, xmm2=G(02468ACE)=GE, xmm4=B(02468ACE)=BE
- ; xmm1=R(13579BDF)=RO, xmm3=G(13579BDF)=GO, xmm5=B(13579BDF)=BO
-
- ; (Original)
- ; Y = 0.29900 * R + 0.58700 * G + 0.11400 * B
- ;
- ; (This implementation)
- ; Y = 0.29900 * R + 0.33700 * G + 0.11400 * B + 0.25000 * G
-
- movdqa xmm6, xmm1
- punpcklwd xmm1, xmm3
- punpckhwd xmm6, xmm3
- pmaddwd xmm1, [rel PW_F0299_F0337] ; xmm1=ROL*FIX(0.299)+GOL*FIX(0.337)
- pmaddwd xmm6, [rel PW_F0299_F0337] ; xmm6=ROH*FIX(0.299)+GOH*FIX(0.337)
-
- movdqa xmm7, xmm6 ; xmm7=ROH*FIX(0.299)+GOH*FIX(0.337)
-
- movdqa xmm6, xmm0
- punpcklwd xmm0, xmm2
- punpckhwd xmm6, xmm2
- pmaddwd xmm0, [rel PW_F0299_F0337] ; xmm0=REL*FIX(0.299)+GEL*FIX(0.337)
- pmaddwd xmm6, [rel PW_F0299_F0337] ; xmm6=REH*FIX(0.299)+GEH*FIX(0.337)
-
- movdqa XMMWORD [wk(0)], xmm0 ; wk(0)=REL*FIX(0.299)+GEL*FIX(0.337)
- movdqa XMMWORD [wk(1)], xmm6 ; wk(1)=REH*FIX(0.299)+GEH*FIX(0.337)
-
- movdqa xmm0, xmm5 ; xmm0=BO
- movdqa xmm6, xmm4 ; xmm6=BE
-
- movdqa xmm4, xmm0
- punpcklwd xmm0, xmm3
- punpckhwd xmm4, xmm3
- pmaddwd xmm0, [rel PW_F0114_F0250] ; xmm0=BOL*FIX(0.114)+GOL*FIX(0.250)
- pmaddwd xmm4, [rel PW_F0114_F0250] ; xmm4=BOH*FIX(0.114)+GOH*FIX(0.250)
-
- movdqa xmm3, [rel PD_ONEHALF] ; xmm3=[PD_ONEHALF]
-
- paddd xmm0, xmm1
- paddd xmm4, xmm7
- paddd xmm0, xmm3
- paddd xmm4, xmm3
- psrld xmm0, SCALEBITS ; xmm0=YOL
- psrld xmm4, SCALEBITS ; xmm4=YOH
- packssdw xmm0, xmm4 ; xmm0=YO
-
- movdqa xmm4, xmm6
- punpcklwd xmm6, xmm2
- punpckhwd xmm4, xmm2
- pmaddwd xmm6, [rel PW_F0114_F0250] ; xmm6=BEL*FIX(0.114)+GEL*FIX(0.250)
- pmaddwd xmm4, [rel PW_F0114_F0250] ; xmm4=BEH*FIX(0.114)+GEH*FIX(0.250)
-
- movdqa xmm2, [rel PD_ONEHALF] ; xmm2=[PD_ONEHALF]
-
- paddd xmm6, XMMWORD [wk(0)]
- paddd xmm4, XMMWORD [wk(1)]
- paddd xmm6, xmm2
- paddd xmm4, xmm2
- psrld xmm6, SCALEBITS ; xmm6=YEL
- psrld xmm4, SCALEBITS ; xmm4=YEH
- packssdw xmm6, xmm4 ; xmm6=YE
-
- psllw xmm0, BYTE_BIT
- por xmm6, xmm0 ; xmm6=Y
- movdqa XMMWORD [rdi], xmm6 ; Save Y
-
- sub rcx, byte SIZEOF_XMMWORD
- add rsi, byte RGB_PIXELSIZE*SIZEOF_XMMWORD ; inptr
- add rdi, byte SIZEOF_XMMWORD ; outptr0
- cmp rcx, byte SIZEOF_XMMWORD
- jae near .columnloop
- test rcx, rcx
- jnz near .column_ld1
-
- pop rcx ; col
- pop rsi
- pop rdi
-
- add rsi, byte SIZEOF_JSAMPROW ; input_buf
- add rdi, byte SIZEOF_JSAMPROW
- dec rax ; num_rows
- jg near .rowloop
-
-.return:
- pop rbx
- uncollect_args 5
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
- pop rbp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jchuff-sse2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jchuff-sse2.asm
deleted file mode 100644
index 9ea6df946e..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jchuff-sse2.asm
+++ /dev/null
@@ -1,583 +0,0 @@
-;
-; jchuff-sse2.asm - Huffman entropy encoding (64-bit SSE2)
-;
-; Copyright (C) 2009-2011, 2014-2016, 2019, 2021, D. R. Commander.
-; Copyright (C) 2015, Matthieu Darbois.
-; Copyright (C) 2018, Matthias Räncker.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-;
-; This file contains an SSE2 implementation for Huffman coding of one block.
-; The following code is based on jchuff.c; see jchuff.c for more details.
-
-%include "jsimdext.inc"
-
-struc working_state
-.next_output_byte: resp 1 ; => next byte to write in buffer
-.free_in_buffer: resp 1 ; # of byte spaces remaining in buffer
-.cur.put_buffer.simd resq 1 ; current bit accumulation buffer
-.cur.free_bits resd 1 ; # of bits available in it
-.cur.last_dc_val resd 4 ; last DC coef for each component
-.cinfo: resp 1 ; dump_buffer needs access to this
-endstruc
-
-struc c_derived_tbl
-.ehufco: resd 256 ; code for each symbol
-.ehufsi: resb 256 ; length of code for each symbol
-; If no code has been allocated for a symbol S, ehufsi[S] contains 0
-endstruc
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_huff_encode_one_block)
-
-EXTN(jconst_huff_encode_one_block):
-
-jpeg_mask_bits dd 0x0000, 0x0001, 0x0003, 0x0007
- dd 0x000f, 0x001f, 0x003f, 0x007f
- dd 0x00ff, 0x01ff, 0x03ff, 0x07ff
- dd 0x0fff, 0x1fff, 0x3fff, 0x7fff
-
- alignz 32
-
-times 1 << 14 db 15
-times 1 << 13 db 14
-times 1 << 12 db 13
-times 1 << 11 db 12
-times 1 << 10 db 11
-times 1 << 9 db 10
-times 1 << 8 db 9
-times 1 << 7 db 8
-times 1 << 6 db 7
-times 1 << 5 db 6
-times 1 << 4 db 5
-times 1 << 3 db 4
-times 1 << 2 db 3
-times 1 << 1 db 2
-times 1 << 0 db 1
-times 1 db 0
-jpeg_nbits_table:
-times 1 db 0
-times 1 << 0 db 1
-times 1 << 1 db 2
-times 1 << 2 db 3
-times 1 << 3 db 4
-times 1 << 4 db 5
-times 1 << 5 db 6
-times 1 << 6 db 7
-times 1 << 7 db 8
-times 1 << 8 db 9
-times 1 << 9 db 10
-times 1 << 10 db 11
-times 1 << 11 db 12
-times 1 << 12 db 13
-times 1 << 13 db 14
-times 1 << 14 db 15
-times 1 << 15 db 16
-
- alignz 32
-
-%define NBITS(x) nbits_base + x
-%define MASK_BITS(x) NBITS((x) * 4) + (jpeg_mask_bits - jpeg_nbits_table)
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 64
-
-; Shorthand used to describe SIMD operations:
-; wN: xmmN treated as eight signed 16-bit values
-; wN[i]: perform the same operation on all eight signed 16-bit values, i=0..7
-; bN: xmmN treated as 16 unsigned 8-bit values
-; bN[i]: perform the same operation on all 16 unsigned 8-bit values, i=0..15
-; Contents of SIMD registers are shown in memory order.
-
-; Fill the bit buffer to capacity with the leading bits from code, then output
-; the bit buffer and put the remaining bits from code into the bit buffer.
-;
-; Usage:
-; code - contains the bits to shift into the bit buffer (LSB-aligned)
-; %1 - the label to which to jump when the macro completes
-; %2 (optional) - extra instructions to execute after nbits has been set
-;
-; Upon completion, free_bits will be set to the number of remaining bits from
-; code, and put_buffer will contain those remaining bits. temp and code will
-; be clobbered.
-;
-; This macro encodes any 0xFF bytes as 0xFF 0x00, as does the EMIT_BYTE()
-; macro in jchuff.c.
-
-%macro EMIT_QWORD 1-2
- add nbitsb, free_bitsb ; nbits += free_bits;
- neg free_bitsb ; free_bits = -free_bits;
- mov tempd, code ; temp = code;
- shl put_buffer, nbitsb ; put_buffer <<= nbits;
- mov nbitsb, free_bitsb ; nbits = free_bits;
- neg free_bitsb ; free_bits = -free_bits;
- shr tempd, nbitsb ; temp >>= nbits;
- or tempq, put_buffer ; temp |= put_buffer;
- movq xmm0, tempq ; xmm0.u64 = { temp, 0 };
- bswap tempq ; temp = htonl(temp);
- mov put_buffer, codeq ; put_buffer = code;
- pcmpeqb xmm0, xmm1 ; b0[i] = (b0[i] == 0xFF ? 0xFF : 0);
- %2
- pmovmskb code, xmm0 ; code = 0; code |= ((b0[i] >> 7) << i);
- mov qword [buffer], tempq ; memcpy(buffer, &temp, 8);
- ; (speculative; will be overwritten if
- ; code contains any 0xFF bytes)
- add free_bitsb, 64 ; free_bits += 64;
- add bufferp, 8 ; buffer += 8;
- test code, code ; if (code == 0) /* No 0xFF bytes */
- jz %1 ; return;
- ; Execute the equivalent of the EMIT_BYTE() macro in jchuff.c for all 8
- ; bytes in the qword.
- cmp tempb, 0xFF ; Set CF if temp[0] < 0xFF
- mov byte [buffer-7], 0 ; buffer[-7] = 0;
- sbb bufferp, 6 ; buffer -= (6 + (temp[0] < 0xFF ? 1 : 0));
- mov byte [buffer], temph ; buffer[0] = temp[1];
- cmp temph, 0xFF ; Set CF if temp[1] < 0xFF
- mov byte [buffer+1], 0 ; buffer[1] = 0;
- sbb bufferp, -2 ; buffer -= (-2 + (temp[1] < 0xFF ? 1 : 0));
- shr tempq, 16 ; temp >>= 16;
- mov byte [buffer], tempb ; buffer[0] = temp[0];
- cmp tempb, 0xFF ; Set CF if temp[0] < 0xFF
- mov byte [buffer+1], 0 ; buffer[1] = 0;
- sbb bufferp, -2 ; buffer -= (-2 + (temp[0] < 0xFF ? 1 : 0));
- mov byte [buffer], temph ; buffer[0] = temp[1];
- cmp temph, 0xFF ; Set CF if temp[1] < 0xFF
- mov byte [buffer+1], 0 ; buffer[1] = 0;
- sbb bufferp, -2 ; buffer -= (-2 + (temp[1] < 0xFF ? 1 : 0));
- shr tempq, 16 ; temp >>= 16;
- mov byte [buffer], tempb ; buffer[0] = temp[0];
- cmp tempb, 0xFF ; Set CF if temp[0] < 0xFF
- mov byte [buffer+1], 0 ; buffer[1] = 0;
- sbb bufferp, -2 ; buffer -= (-2 + (temp[0] < 0xFF ? 1 : 0));
- mov byte [buffer], temph ; buffer[0] = temp[1];
- cmp temph, 0xFF ; Set CF if temp[1] < 0xFF
- mov byte [buffer+1], 0 ; buffer[1] = 0;
- sbb bufferp, -2 ; buffer -= (-2 + (temp[1] < 0xFF ? 1 : 0));
- shr tempd, 16 ; temp >>= 16;
- mov byte [buffer], tempb ; buffer[0] = temp[0];
- cmp tempb, 0xFF ; Set CF if temp[0] < 0xFF
- mov byte [buffer+1], 0 ; buffer[1] = 0;
- sbb bufferp, -2 ; buffer -= (-2 + (temp[0] < 0xFF ? 1 : 0));
- mov byte [buffer], temph ; buffer[0] = temp[1];
- cmp temph, 0xFF ; Set CF if temp[1] < 0xFF
- mov byte [buffer+1], 0 ; buffer[1] = 0;
- sbb bufferp, -2 ; buffer -= (-2 + (temp[1] < 0xFF ? 1 : 0));
- jmp %1 ; return;
-%endmacro
-
-;
-; Encode a single block's worth of coefficients.
-;
-; GLOBAL(JOCTET *)
-; jsimd_huff_encode_one_block_sse2(working_state *state, JOCTET *buffer,
-; JCOEFPTR block, int last_dc_val,
-; c_derived_tbl *dctbl, c_derived_tbl *actbl)
-;
-; NOTES:
-; When shuffling data, we try to avoid pinsrw as much as possible, since it is
-; slow on many CPUs. Its reciprocal throughput (issue latency) is 1 even on
-; modern CPUs, so chains of pinsrw instructions (even with different outputs)
-; can limit performance. pinsrw is a VectorPath instruction on AMD K8 and
-; requires 2 µops (with memory operand) on Intel. In either case, only one
-; pinsrw instruction can be decoded per cycle (and nothing else if they are
-; back-to-back), so out-of-order execution cannot be used to work around long
-; pinsrw chains (though for Sandy Bridge and later, this may be less of a
-; problem if the code runs from the µop cache.)
-;
-; We use tzcnt instead of bsf without checking for support. The instruction is
-; executed as bsf on CPUs that don't support tzcnt (encoding is equivalent to
-; rep bsf.) The destination (first) operand of bsf (and tzcnt on some CPUs) is
-; an input dependency (although the behavior is not formally defined, Intel
-; CPUs usually leave the destination unmodified if the source is zero.) This
-; can prevent out-of-order execution, so we clear the destination before
-; invoking tzcnt.
-;
-; Initial register allocation
-; rax - buffer
-; rbx - temp
-; rcx - nbits
-; rdx - block --> free_bits
-; rsi - nbits_base
-; rdi - t
-; rbp - code
-; r8 - dctbl --> code_temp
-; r9 - actbl
-; r10 - state
-; r11 - index
-; r12 - put_buffer
-
-%define buffer rax
-%ifdef WIN64
-%define bufferp rax
-%else
-%define bufferp raxp
-%endif
-%define tempq rbx
-%define tempd ebx
-%define tempb bl
-%define temph bh
-%define nbitsq rcx
-%define nbits ecx
-%define nbitsb cl
-%define block rdx
-%define nbits_base rsi
-%define t rdi
-%define td edi
-%define codeq rbp
-%define code ebp
-%define dctbl r8
-%define actbl r9
-%define state r10
-%define index r11
-%define indexd r11d
-%define put_buffer r12
-%define put_bufferd r12d
-
-; Step 1: Re-arrange input data according to jpeg_natural_order
-; xx 01 02 03 04 05 06 07 xx 01 08 16 09 02 03 10
-; 08 09 10 11 12 13 14 15 17 24 32 25 18 11 04 05
-; 16 17 18 19 20 21 22 23 12 19 26 33 40 48 41 34
-; 24 25 26 27 28 29 30 31 ==> 27 20 13 06 07 14 21 28
-; 32 33 34 35 36 37 38 39 35 42 49 56 57 50 43 36
-; 40 41 42 43 44 45 46 47 29 22 15 23 30 37 44 51
-; 48 49 50 51 52 53 54 55 58 59 52 45 38 31 39 46
-; 56 57 58 59 60 61 62 63 53 60 61 54 47 55 62 63
-
- align 32
- GLOBAL_FUNCTION(jsimd_huff_encode_one_block_sse2)
-
-EXTN(jsimd_huff_encode_one_block_sse2):
-
-%ifdef WIN64
-
-; rcx = working_state *state
-; rdx = JOCTET *buffer
-; r8 = JCOEFPTR block
-; r9 = int last_dc_val
-; [rax+48] = c_derived_tbl *dctbl
-; [rax+56] = c_derived_tbl *actbl
-
- ;X: X = code stream
- mov buffer, rdx
- mov block, r8
- movups xmm3, XMMWORD [block + 0 * SIZEOF_WORD] ;D: w3 = xx 01 02 03 04 05 06 07
- push rbx
- push rbp
- movdqa xmm0, xmm3 ;A: w0 = xx 01 02 03 04 05 06 07
- push rsi
- push rdi
- push r12
- movups xmm1, XMMWORD [block + 8 * SIZEOF_WORD] ;B: w1 = 08 09 10 11 12 13 14 15
- mov state, rcx
- movsx code, word [block] ;Z: code = block[0];
- pxor xmm4, xmm4 ;A: w4[i] = 0;
- sub code, r9d ;Z: code -= last_dc_val;
- mov dctbl, POINTER [rsp+6*8+4*8]
- mov actbl, POINTER [rsp+6*8+5*8]
- punpckldq xmm0, xmm1 ;A: w0 = xx 01 08 09 02 03 10 11
- lea nbits_base, [rel jpeg_nbits_table]
- add rsp, -DCTSIZE2 * SIZEOF_WORD
- mov t, rsp
-
-%else
-
-; rdi = working_state *state
-; rsi = JOCTET *buffer
-; rdx = JCOEFPTR block
-; rcx = int last_dc_val
-; r8 = c_derived_tbl *dctbl
-; r9 = c_derived_tbl *actbl
-
- ;X: X = code stream
- movups xmm3, XMMWORD [block + 0 * SIZEOF_WORD] ;D: w3 = xx 01 02 03 04 05 06 07
- push rbx
- push rbp
- movdqa xmm0, xmm3 ;A: w0 = xx 01 02 03 04 05 06 07
- push r12
- mov state, rdi
- mov buffer, rsi
- movups xmm1, XMMWORD [block + 8 * SIZEOF_WORD] ;B: w1 = 08 09 10 11 12 13 14 15
- movsx codeq, word [block] ;Z: code = block[0];
- lea nbits_base, [rel jpeg_nbits_table]
- pxor xmm4, xmm4 ;A: w4[i] = 0;
- sub codeq, rcx ;Z: code -= last_dc_val;
- punpckldq xmm0, xmm1 ;A: w0 = xx 01 08 09 02 03 10 11
- lea t, [rsp - DCTSIZE2 * SIZEOF_WORD] ; use red zone for t_
-
-%endif
-
- pshuflw xmm0, xmm0, 11001001b ;A: w0 = 01 08 xx 09 02 03 10 11
- pinsrw xmm0, word [block + 16 * SIZEOF_WORD], 2 ;A: w0 = 01 08 16 09 02 03 10 11
- punpckhdq xmm3, xmm1 ;D: w3 = 04 05 12 13 06 07 14 15
- punpcklqdq xmm1, xmm3 ;B: w1 = 08 09 10 11 04 05 12 13
- pinsrw xmm0, word [block + 17 * SIZEOF_WORD], 7 ;A: w0 = 01 08 16 09 02 03 10 17
- ;A: (Row 0, offset 1)
- pcmpgtw xmm4, xmm0 ;A: w4[i] = (w0[i] < 0 ? -1 : 0);
- paddw xmm0, xmm4 ;A: w0[i] += w4[i];
- movaps XMMWORD [t + 0 * SIZEOF_WORD], xmm0 ;A: t[i] = w0[i];
-
- movq xmm2, qword [block + 24 * SIZEOF_WORD] ;B: w2 = 24 25 26 27 -- -- -- --
- pshuflw xmm2, xmm2, 11011000b ;B: w2 = 24 26 25 27 -- -- -- --
- pslldq xmm1, 1 * SIZEOF_WORD ;B: w1 = -- 08 09 10 11 04 05 12
- movups xmm5, XMMWORD [block + 48 * SIZEOF_WORD] ;H: w5 = 48 49 50 51 52 53 54 55
- movsd xmm1, xmm2 ;B: w1 = 24 26 25 27 11 04 05 12
- punpcklqdq xmm2, xmm5 ;C: w2 = 24 26 25 27 48 49 50 51
- pinsrw xmm1, word [block + 32 * SIZEOF_WORD], 1 ;B: w1 = 24 32 25 27 11 04 05 12
- pxor xmm4, xmm4 ;A: w4[i] = 0;
- psrldq xmm3, 2 * SIZEOF_WORD ;D: w3 = 12 13 06 07 14 15 -- --
- pcmpeqw xmm0, xmm4 ;A: w0[i] = (w0[i] == 0 ? -1 : 0);
- pinsrw xmm1, word [block + 18 * SIZEOF_WORD], 3 ;B: w1 = 24 32 25 18 11 04 05 12
- ; (Row 1, offset 1)
- pcmpgtw xmm4, xmm1 ;B: w4[i] = (w1[i] < 0 ? -1 : 0);
- paddw xmm1, xmm4 ;B: w1[i] += w4[i];
- movaps XMMWORD [t + 8 * SIZEOF_WORD], xmm1 ;B: t[i+8] = w1[i];
- pxor xmm4, xmm4 ;B: w4[i] = 0;
- pcmpeqw xmm1, xmm4 ;B: w1[i] = (w1[i] == 0 ? -1 : 0);
-
- packsswb xmm0, xmm1 ;AB: b0[i] = w0[i], b0[i+8] = w1[i]
- ; w/ signed saturation
-
- pinsrw xmm3, word [block + 20 * SIZEOF_WORD], 0 ;D: w3 = 20 13 06 07 14 15 -- --
- pinsrw xmm3, word [block + 21 * SIZEOF_WORD], 5 ;D: w3 = 20 13 06 07 14 21 -- --
- pinsrw xmm3, word [block + 28 * SIZEOF_WORD], 6 ;D: w3 = 20 13 06 07 14 21 28 --
- pinsrw xmm3, word [block + 35 * SIZEOF_WORD], 7 ;D: w3 = 20 13 06 07 14 21 28 35
- ; (Row 3, offset 1)
- pcmpgtw xmm4, xmm3 ;D: w4[i] = (w3[i] < 0 ? -1 : 0);
- paddw xmm3, xmm4 ;D: w3[i] += w4[i];
- movaps XMMWORD [t + 24 * SIZEOF_WORD], xmm3 ;D: t[i+24] = w3[i];
- pxor xmm4, xmm4 ;D: w4[i] = 0;
- pcmpeqw xmm3, xmm4 ;D: w3[i] = (w3[i] == 0 ? -1 : 0);
-
- pinsrw xmm2, word [block + 19 * SIZEOF_WORD], 0 ;C: w2 = 19 26 25 27 48 49 50 51
- cmp code, 1 << 31 ;Z: Set CF if code < 0x80000000,
- ;Z: i.e. if code is positive
- pinsrw xmm2, word [block + 33 * SIZEOF_WORD], 2 ;C: w2 = 19 26 33 27 48 49 50 51
- pinsrw xmm2, word [block + 40 * SIZEOF_WORD], 3 ;C: w2 = 19 26 33 40 48 49 50 51
- adc code, -1 ;Z: code += -1 + (code >= 0 ? 1 : 0);
- pinsrw xmm2, word [block + 41 * SIZEOF_WORD], 5 ;C: w2 = 19 26 33 40 48 41 50 51
- pinsrw xmm2, word [block + 34 * SIZEOF_WORD], 6 ;C: w2 = 19 26 33 40 48 41 34 51
- movsxd codeq, code ;Z: sign extend code
- pinsrw xmm2, word [block + 27 * SIZEOF_WORD], 7 ;C: w2 = 19 26 33 40 48 41 34 27
- ; (Row 2, offset 1)
- pcmpgtw xmm4, xmm2 ;C: w4[i] = (w2[i] < 0 ? -1 : 0);
- paddw xmm2, xmm4 ;C: w2[i] += w4[i];
- movaps XMMWORD [t + 16 * SIZEOF_WORD], xmm2 ;C: t[i+16] = w2[i];
- pxor xmm4, xmm4 ;C: w4[i] = 0;
- pcmpeqw xmm2, xmm4 ;C: w2[i] = (w2[i] == 0 ? -1 : 0);
-
- packsswb xmm2, xmm3 ;CD: b2[i] = w2[i], b2[i+8] = w3[i]
- ; w/ signed saturation
-
- movzx nbitsq, byte [NBITS(codeq)] ;Z: nbits = JPEG_NBITS(code);
- movdqa xmm3, xmm5 ;H: w3 = 48 49 50 51 52 53 54 55
- pmovmskb tempd, xmm2 ;Z: temp = 0; temp |= ((b2[i] >> 7) << i);
- pmovmskb put_bufferd, xmm0 ;Z: put_buffer = 0; put_buffer |= ((b0[i] >> 7) << i);
- movups xmm0, XMMWORD [block + 56 * SIZEOF_WORD] ;H: w0 = 56 57 58 59 60 61 62 63
- punpckhdq xmm3, xmm0 ;H: w3 = 52 53 60 61 54 55 62 63
- shl tempd, 16 ;Z: temp <<= 16;
- psrldq xmm3, 1 * SIZEOF_WORD ;H: w3 = 53 60 61 54 55 62 63 --
- pxor xmm2, xmm2 ;H: w2[i] = 0;
- or put_bufferd, tempd ;Z: put_buffer |= temp;
- pshuflw xmm3, xmm3, 00111001b ;H: w3 = 60 61 54 53 55 62 63 --
- movq xmm1, qword [block + 44 * SIZEOF_WORD] ;G: w1 = 44 45 46 47 -- -- -- --
- unpcklps xmm5, xmm0 ;E: w5 = 48 49 56 57 50 51 58 59
- pxor xmm0, xmm0 ;H: w0[i] = 0;
- pinsrw xmm3, word [block + 47 * SIZEOF_WORD], 3 ;H: w3 = 60 61 54 47 55 62 63 --
- ; (Row 7, offset 1)
- pcmpgtw xmm2, xmm3 ;H: w2[i] = (w3[i] < 0 ? -1 : 0);
- paddw xmm3, xmm2 ;H: w3[i] += w2[i];
- movaps XMMWORD [t + 56 * SIZEOF_WORD], xmm3 ;H: t[i+56] = w3[i];
- movq xmm4, qword [block + 36 * SIZEOF_WORD] ;G: w4 = 36 37 38 39 -- -- -- --
- pcmpeqw xmm3, xmm0 ;H: w3[i] = (w3[i] == 0 ? -1 : 0);
- punpckldq xmm4, xmm1 ;G: w4 = 36 37 44 45 38 39 46 47
- mov tempd, [dctbl + c_derived_tbl.ehufco + nbitsq * 4]
- ;Z: temp = dctbl->ehufco[nbits];
- movdqa xmm1, xmm4 ;F: w1 = 36 37 44 45 38 39 46 47
- psrldq xmm4, 1 * SIZEOF_WORD ;G: w4 = 37 44 45 38 39 46 47 --
- shufpd xmm1, xmm5, 10b ;F: w1 = 36 37 44 45 50 51 58 59
- and code, dword [MASK_BITS(nbitsq)] ;Z: code &= (1 << nbits) - 1;
- pshufhw xmm4, xmm4, 11010011b ;G: w4 = 37 44 45 38 -- 39 46 --
- pslldq xmm1, 1 * SIZEOF_WORD ;F: w1 = -- 36 37 44 45 50 51 58
- shl tempq, nbitsb ;Z: temp <<= nbits;
- pinsrw xmm4, word [block + 59 * SIZEOF_WORD], 0 ;G: w4 = 59 44 45 38 -- 39 46 --
- pshufd xmm1, xmm1, 11011000b ;F: w1 = -- 36 45 50 37 44 51 58
- pinsrw xmm4, word [block + 52 * SIZEOF_WORD], 1 ;G: w4 = 59 52 45 38 -- 39 46 --
- or code, tempd ;Z: code |= temp;
- movlps xmm1, qword [block + 20 * SIZEOF_WORD] ;F: w1 = 20 21 22 23 37 44 51 58
- pinsrw xmm4, word [block + 31 * SIZEOF_WORD], 4 ;G: w4 = 59 52 45 38 31 39 46 --
- pshuflw xmm1, xmm1, 01110010b ;F: w1 = 22 20 23 21 37 44 51 58
- pinsrw xmm4, word [block + 53 * SIZEOF_WORD], 7 ;G: w4 = 59 52 45 38 31 39 46 53
- ; (Row 6, offset 1)
- pxor xmm2, xmm2 ;G: w2[i] = 0;
- pcmpgtw xmm0, xmm4 ;G: w0[i] = (w4[i] < 0 ? -1 : 0);
- pinsrw xmm1, word [block + 15 * SIZEOF_WORD], 1 ;F: w1 = 22 15 23 21 37 44 51 58
- paddw xmm4, xmm0 ;G: w4[i] += w0[i];
- movaps XMMWORD [t + 48 * SIZEOF_WORD], xmm4 ;G: t[48+i] = w4[i];
- pinsrw xmm1, word [block + 30 * SIZEOF_WORD], 3 ;F: w1 = 22 15 23 30 37 44 51 58
- ; (Row 5, offset 1)
- pcmpeqw xmm4, xmm2 ;G: w4[i] = (w4[i] == 0 ? -1 : 0);
- pinsrw xmm5, word [block + 42 * SIZEOF_WORD], 0 ;E: w5 = 42 49 56 57 50 51 58 59
-
- packsswb xmm4, xmm3 ;GH: b4[i] = w4[i], b4[i+8] = w3[i]
- ; w/ signed saturation
-
- pxor xmm0, xmm0 ;F: w0[i] = 0;
- pinsrw xmm5, word [block + 43 * SIZEOF_WORD], 5 ;E: w5 = 42 49 56 57 50 43 58 59
- pcmpgtw xmm2, xmm1 ;F: w2[i] = (w1[i] < 0 ? -1 : 0);
- pmovmskb tempd, xmm4 ;Z: temp = 0; temp |= ((b4[i] >> 7) << i);
- pinsrw xmm5, word [block + 36 * SIZEOF_WORD], 6 ;E: w5 = 42 49 56 57 50 43 36 59
- paddw xmm1, xmm2 ;F: w1[i] += w2[i];
- movaps XMMWORD [t + 40 * SIZEOF_WORD], xmm1 ;F: t[40+i] = w1[i];
- pinsrw xmm5, word [block + 29 * SIZEOF_WORD], 7 ;E: w5 = 42 49 56 57 50 43 36 29
- ; (Row 4, offset 1)
-%undef block
-%define free_bitsq rdx
-%define free_bitsd edx
-%define free_bitsb dl
- pcmpeqw xmm1, xmm0 ;F: w1[i] = (w1[i] == 0 ? -1 : 0);
- shl tempq, 48 ;Z: temp <<= 48;
- pxor xmm2, xmm2 ;E: w2[i] = 0;
- pcmpgtw xmm0, xmm5 ;E: w0[i] = (w5[i] < 0 ? -1 : 0);
- paddw xmm5, xmm0 ;E: w5[i] += w0[i];
- or tempq, put_buffer ;Z: temp |= put_buffer;
- movaps XMMWORD [t + 32 * SIZEOF_WORD], xmm5 ;E: t[32+i] = w5[i];
- lea t, [dword t - 2] ;Z: t = &t[-1];
- pcmpeqw xmm5, xmm2 ;E: w5[i] = (w5[i] == 0 ? -1 : 0);
-
- packsswb xmm5, xmm1 ;EF: b5[i] = w5[i], b5[i+8] = w1[i]
- ; w/ signed saturation
-
- add nbitsb, byte [dctbl + c_derived_tbl.ehufsi + nbitsq]
- ;Z: nbits += dctbl->ehufsi[nbits];
-%undef dctbl
-%define code_temp r8d
- pmovmskb indexd, xmm5 ;Z: index = 0; index |= ((b5[i] >> 7) << i);
- mov free_bitsd, [state+working_state.cur.free_bits]
- ;Z: free_bits = state->cur.free_bits;
- pcmpeqw xmm1, xmm1 ;Z: b1[i] = 0xFF;
- shl index, 32 ;Z: index <<= 32;
- mov put_buffer, [state+working_state.cur.put_buffer.simd]
- ;Z: put_buffer = state->cur.put_buffer.simd;
- or index, tempq ;Z: index |= temp;
- not index ;Z: index = ~index;
- sub free_bitsb, nbitsb ;Z: if ((free_bits -= nbits) >= 0)
- jnl .ENTRY_SKIP_EMIT_CODE ;Z: goto .ENTRY_SKIP_EMIT_CODE;
- align 16
-.EMIT_CODE: ;Z: .EMIT_CODE:
- EMIT_QWORD .BLOOP_COND ;Z: insert code, flush buffer, goto .BLOOP_COND
-
-; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- align 16
-.BRLOOP: ; do {
- lea code_temp, [nbitsq - 16] ; code_temp = nbits - 16;
- movzx nbits, byte [actbl + c_derived_tbl.ehufsi + 0xf0]
- ; nbits = actbl->ehufsi[0xf0];
- mov code, [actbl + c_derived_tbl.ehufco + 0xf0 * 4]
- ; code = actbl->ehufco[0xf0];
- sub free_bitsb, nbitsb ; if ((free_bits -= nbits) <= 0)
- jle .EMIT_BRLOOP_CODE ; goto .EMIT_BRLOOP_CODE;
- shl put_buffer, nbitsb ; put_buffer <<= nbits;
- mov nbits, code_temp ; nbits = code_temp;
- or put_buffer, codeq ; put_buffer |= code;
- cmp nbits, 16 ; if (nbits <= 16)
- jle .ERLOOP ; break;
- jmp .BRLOOP ; } while (1);
-
-; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- align 16
- times 5 nop
-.ENTRY_SKIP_EMIT_CODE: ; .ENTRY_SKIP_EMIT_CODE:
- shl put_buffer, nbitsb ; put_buffer <<= nbits;
- or put_buffer, codeq ; put_buffer |= code;
-.BLOOP_COND: ; .BLOOP_COND:
- test index, index ; if (index != 0)
- jz .ELOOP ; {
-.BLOOP: ; do {
- xor nbits, nbits ; nbits = 0; /* kill tzcnt input dependency */
- tzcnt nbitsq, index ; nbits = # of trailing 0 bits in index
- inc nbits ; ++nbits;
- lea t, [t + nbitsq * 2] ; t = &t[nbits];
- shr index, nbitsb ; index >>= nbits;
-.EMIT_BRLOOP_CODE_END: ; .EMIT_BRLOOP_CODE_END:
- cmp nbits, 16 ; if (nbits > 16)
- jg .BRLOOP ; goto .BRLOOP;
-.ERLOOP: ; .ERLOOP:
- movsx codeq, word [t] ; code = *t;
- lea tempd, [nbitsq * 2] ; temp = nbits * 2;
- movzx nbits, byte [NBITS(codeq)] ; nbits = JPEG_NBITS(code);
- lea tempd, [nbitsq + tempq * 8] ; temp = temp * 8 + nbits;
- mov code_temp, [actbl + c_derived_tbl.ehufco + (tempq - 16) * 4]
- ; code_temp = actbl->ehufco[temp-16];
- shl code_temp, nbitsb ; code_temp <<= nbits;
- and code, dword [MASK_BITS(nbitsq)] ; code &= (1 << nbits) - 1;
- add nbitsb, [actbl + c_derived_tbl.ehufsi + (tempq - 16)]
- ; free_bits -= actbl->ehufsi[temp-16];
- or code, code_temp ; code |= code_temp;
- sub free_bitsb, nbitsb ; if ((free_bits -= nbits) <= 0)
- jle .EMIT_CODE ; goto .EMIT_CODE;
- shl put_buffer, nbitsb ; put_buffer <<= nbits;
- or put_buffer, codeq ; put_buffer |= code;
- test index, index
- jnz .BLOOP ; } while (index != 0);
-.ELOOP: ; } /* index != 0 */
- sub td, esp ; t -= (WIN64: &t_[0], UNIX: &t_[64]);
-%ifdef WIN64
- cmp td, (DCTSIZE2 - 2) * SIZEOF_WORD ; if (t != 62)
-%else
- cmp td, -2 * SIZEOF_WORD ; if (t != -2)
-%endif
- je .EFN ; {
- movzx nbits, byte [actbl + c_derived_tbl.ehufsi + 0]
- ; nbits = actbl->ehufsi[0];
- mov code, [actbl + c_derived_tbl.ehufco + 0] ; code = actbl->ehufco[0];
- sub free_bitsb, nbitsb ; if ((free_bits -= nbits) <= 0)
- jg .EFN_SKIP_EMIT_CODE ; {
- EMIT_QWORD .EFN ; insert code, flush buffer
- align 16
-.EFN_SKIP_EMIT_CODE: ; } else {
- shl put_buffer, nbitsb ; put_buffer <<= nbits;
- or put_buffer, codeq ; put_buffer |= code;
-.EFN: ; } }
- mov [state + working_state.cur.put_buffer.simd], put_buffer
- ; state->cur.put_buffer.simd = put_buffer;
- mov byte [state + working_state.cur.free_bits], free_bitsb
- ; state->cur.free_bits = free_bits;
-%ifdef WIN64
- sub rsp, -DCTSIZE2 * SIZEOF_WORD
- pop r12
- pop rdi
- pop rsi
- pop rbp
- pop rbx
-%else
- pop r12
- pop rbp
- pop rbx
-%endif
- ret
-
-; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- align 16
-.EMIT_BRLOOP_CODE:
- EMIT_QWORD .EMIT_BRLOOP_CODE_END, { mov nbits, code_temp }
- ; insert code, flush buffer,
- ; nbits = code_temp, goto .EMIT_BRLOOP_CODE_END
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jcphuff-sse2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jcphuff-sse2.asm
deleted file mode 100644
index 01b5c0235f..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jcphuff-sse2.asm
+++ /dev/null
@@ -1,639 +0,0 @@
-;
-; jcphuff-sse2.asm - prepare data for progressive Huffman encoding
-; (64-bit SSE2)
-;
-; Copyright (C) 2016, 2018, Matthieu Darbois
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-;
-; This file contains an SSE2 implementation of data preparation for progressive
-; Huffman encoding. See jcphuff.c for more details.
-
-%include "jsimdext.inc"
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 64
-
-; --------------------------------------------------------------------------
-; Macros to load data for jsimd_encode_mcu_AC_first_prepare_sse2() and
-; jsimd_encode_mcu_AC_refine_prepare_sse2()
-
-%macro LOAD16 0
- pxor N0, N0
- pxor N1, N1
-
- mov T0d, INT [LUT + 0*SIZEOF_INT]
- mov T1d, INT [LUT + 8*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 0
- pinsrw X1, word [BLOCK + T1 * 2], 0
-
- mov T0d, INT [LUT + 1*SIZEOF_INT]
- mov T1d, INT [LUT + 9*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 1
- pinsrw X1, word [BLOCK + T1 * 2], 1
-
- mov T0d, INT [LUT + 2*SIZEOF_INT]
- mov T1d, INT [LUT + 10*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 2
- pinsrw X1, word [BLOCK + T1 * 2], 2
-
- mov T0d, INT [LUT + 3*SIZEOF_INT]
- mov T1d, INT [LUT + 11*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 3
- pinsrw X1, word [BLOCK + T1 * 2], 3
-
- mov T0d, INT [LUT + 4*SIZEOF_INT]
- mov T1d, INT [LUT + 12*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 4
- pinsrw X1, word [BLOCK + T1 * 2], 4
-
- mov T0d, INT [LUT + 5*SIZEOF_INT]
- mov T1d, INT [LUT + 13*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 5
- pinsrw X1, word [BLOCK + T1 * 2], 5
-
- mov T0d, INT [LUT + 6*SIZEOF_INT]
- mov T1d, INT [LUT + 14*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 6
- pinsrw X1, word [BLOCK + T1 * 2], 6
-
- mov T0d, INT [LUT + 7*SIZEOF_INT]
- mov T1d, INT [LUT + 15*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 7
- pinsrw X1, word [BLOCK + T1 * 2], 7
-%endmacro
-
-%macro LOAD15 0
- pxor N0, N0
- pxor N1, N1
- pxor X1, X1
-
- mov T0d, INT [LUT + 0*SIZEOF_INT]
- mov T1d, INT [LUT + 8*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 0
- pinsrw X1, word [BLOCK + T1 * 2], 0
-
- mov T0d, INT [LUT + 1*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 1
-
- mov T0d, INT [LUT + 2*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 2
-
- mov T0d, INT [LUT + 3*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 3
-
- mov T0d, INT [LUT + 4*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 4
-
- mov T0d, INT [LUT + 5*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 5
-
- mov T0d, INT [LUT + 6*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 6
-
- mov T0d, INT [LUT + 7*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 7
-
- cmp LENEND, 2
- jl %%.ELOAD15
- mov T1d, INT [LUT + 9*SIZEOF_INT]
- pinsrw X1, word [BLOCK + T1 * 2], 1
-
- cmp LENEND, 3
- jl %%.ELOAD15
- mov T1d, INT [LUT + 10*SIZEOF_INT]
- pinsrw X1, word [BLOCK + T1 * 2], 2
-
- cmp LENEND, 4
- jl %%.ELOAD15
- mov T1d, INT [LUT + 11*SIZEOF_INT]
- pinsrw X1, word [BLOCK + T1 * 2], 3
-
- cmp LENEND, 5
- jl %%.ELOAD15
- mov T1d, INT [LUT + 12*SIZEOF_INT]
- pinsrw X1, word [BLOCK + T1 * 2], 4
-
- cmp LENEND, 6
- jl %%.ELOAD15
- mov T1d, INT [LUT + 13*SIZEOF_INT]
- pinsrw X1, word [BLOCK + T1 * 2], 5
-
- cmp LENEND, 7
- jl %%.ELOAD15
- mov T1d, INT [LUT + 14*SIZEOF_INT]
- pinsrw X1, word [BLOCK + T1 * 2], 6
-%%.ELOAD15:
-%endmacro
-
-%macro LOAD8 0
- pxor N0, N0
-
- mov T0d, INT [LUT + 0*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 0
-
- mov T0d, INT [LUT + 1*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 1
-
- mov T0d, INT [LUT + 2*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 2
-
- mov T0d, INT [LUT + 3*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 3
-
- mov T0d, INT [LUT + 4*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 4
-
- mov T0d, INT [LUT + 5*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 5
-
- mov T0d, INT [LUT + 6*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 6
-
- mov T0d, INT [LUT + 7*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T0 * 2], 7
-%endmacro
-
-%macro LOAD7 0
- pxor N0, N0
- pxor X0, X0
-
- mov T1d, INT [LUT + 0*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T1 * 2], 0
-
- cmp LENEND, 2
- jl %%.ELOAD7
- mov T1d, INT [LUT + 1*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T1 * 2], 1
-
- cmp LENEND, 3
- jl %%.ELOAD7
- mov T1d, INT [LUT + 2*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T1 * 2], 2
-
- cmp LENEND, 4
- jl %%.ELOAD7
- mov T1d, INT [LUT + 3*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T1 * 2], 3
-
- cmp LENEND, 5
- jl %%.ELOAD7
- mov T1d, INT [LUT + 4*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T1 * 2], 4
-
- cmp LENEND, 6
- jl %%.ELOAD7
- mov T1d, INT [LUT + 5*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T1 * 2], 5
-
- cmp LENEND, 7
- jl %%.ELOAD7
- mov T1d, INT [LUT + 6*SIZEOF_INT]
- pinsrw X0, word [BLOCK + T1 * 2], 6
-%%.ELOAD7:
-%endmacro
-
-%macro REDUCE0 0
- movdqa xmm0, XMMWORD [VALUES + ( 0*2)]
- movdqa xmm1, XMMWORD [VALUES + ( 8*2)]
- movdqa xmm2, XMMWORD [VALUES + (16*2)]
- movdqa xmm3, XMMWORD [VALUES + (24*2)]
- movdqa xmm4, XMMWORD [VALUES + (32*2)]
- movdqa xmm5, XMMWORD [VALUES + (40*2)]
- movdqa xmm6, XMMWORD [VALUES + (48*2)]
- movdqa xmm7, XMMWORD [VALUES + (56*2)]
-
- pcmpeqw xmm0, ZERO
- pcmpeqw xmm1, ZERO
- pcmpeqw xmm2, ZERO
- pcmpeqw xmm3, ZERO
- pcmpeqw xmm4, ZERO
- pcmpeqw xmm5, ZERO
- pcmpeqw xmm6, ZERO
- pcmpeqw xmm7, ZERO
-
- packsswb xmm0, xmm1
- packsswb xmm2, xmm3
- packsswb xmm4, xmm5
- packsswb xmm6, xmm7
-
- pmovmskb eax, xmm0
- pmovmskb ecx, xmm2
- pmovmskb edx, xmm4
- pmovmskb esi, xmm6
-
- shl rcx, 16
- shl rdx, 32
- shl rsi, 48
-
- or rax, rcx
- or rdx, rsi
- or rax, rdx
-
- not rax
-
- mov MMWORD [r15], rax
-%endmacro
-
-;
-; Prepare data for jsimd_encode_mcu_AC_first().
-;
-; GLOBAL(void)
-; jsimd_encode_mcu_AC_first_prepare_sse2(const JCOEF *block,
-; const int *jpeg_natural_order_start,
-; int Sl, int Al, JCOEF *values,
-; size_t *zerobits)
-;
-; r10 = const JCOEF *block
-; r11 = const int *jpeg_natural_order_start
-; r12 = int Sl
-; r13 = int Al
-; r14 = JCOEF *values
-; r15 = size_t *zerobits
-
-%define ZERO xmm9
-%define X0 xmm0
-%define X1 xmm1
-%define N0 xmm2
-%define N1 xmm3
-%define AL xmm4
-%define K eax
-%define LUT r11
-%define T0 rcx
-%define T0d ecx
-%define T1 rdx
-%define T1d edx
-%define BLOCK r10
-%define VALUES r14
-%define LEN r12d
-%define LENEND r13d
-
- align 32
- GLOBAL_FUNCTION(jsimd_encode_mcu_AC_first_prepare_sse2)
-
-EXTN(jsimd_encode_mcu_AC_first_prepare_sse2):
- push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
- and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [rbp - 16]
- collect_args 6
-
- movdqa XMMWORD [rbp - 16], ZERO
-
- movd AL, r13d
- pxor ZERO, ZERO
- mov K, LEN
- mov LENEND, LEN
- and K, -16
- and LENEND, 7
- shr K, 4
- jz .ELOOP16
-.BLOOP16:
- LOAD16
- pcmpgtw N0, X0
- pcmpgtw N1, X1
- paddw X0, N0
- paddw X1, N1
- pxor X0, N0
- pxor X1, N1
- psrlw X0, AL
- psrlw X1, AL
- pxor N0, X0
- pxor N1, X1
- movdqa XMMWORD [VALUES + (0) * 2], X0
- movdqa XMMWORD [VALUES + (8) * 2], X1
- movdqa XMMWORD [VALUES + (0 + DCTSIZE2) * 2], N0
- movdqa XMMWORD [VALUES + (8 + DCTSIZE2) * 2], N1
- add VALUES, 16*2
- add LUT, 16*SIZEOF_INT
- dec K
- jnz .BLOOP16
- test LEN, 15
- je .PADDING
-.ELOOP16:
- test LEN, 8
- jz .TRY7
- test LEN, 7
- jz .TRY8
-
- LOAD15
- pcmpgtw N0, X0
- pcmpgtw N1, X1
- paddw X0, N0
- paddw X1, N1
- pxor X0, N0
- pxor X1, N1
- psrlw X0, AL
- psrlw X1, AL
- pxor N0, X0
- pxor N1, X1
- movdqa XMMWORD [VALUES + (0) * 2], X0
- movdqa XMMWORD [VALUES + (8) * 2], X1
- movdqa XMMWORD [VALUES + (0 + DCTSIZE2) * 2], N0
- movdqa XMMWORD [VALUES + (8 + DCTSIZE2) * 2], N1
- add VALUES, 16*2
- jmp .PADDING
-.TRY8:
- LOAD8
- pcmpgtw N0, X0
- paddw X0, N0
- pxor X0, N0
- psrlw X0, AL
- pxor N0, X0
- movdqa XMMWORD [VALUES + (0) * 2], X0
- movdqa XMMWORD [VALUES + (0 + DCTSIZE2) * 2], N0
- add VALUES, 8*2
- jmp .PADDING
-.TRY7:
- LOAD7
- pcmpgtw N0, X0
- paddw X0, N0
- pxor X0, N0
- psrlw X0, AL
- pxor N0, X0
- movdqa XMMWORD [VALUES + (0) * 2], X0
- movdqa XMMWORD [VALUES + (0 + DCTSIZE2) * 2], N0
- add VALUES, 8*2
-.PADDING:
- mov K, LEN
- add K, 7
- and K, -8
- shr K, 3
- sub K, DCTSIZE2/8
- jz .EPADDING
- align 16
-.ZEROLOOP:
- movdqa XMMWORD [VALUES + 0], ZERO
- add VALUES, 8*2
- inc K
- jnz .ZEROLOOP
-.EPADDING:
- sub VALUES, DCTSIZE2*2
-
- REDUCE0
-
- movdqa ZERO, XMMWORD [rbp - 16]
- uncollect_args 6
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
- pop rbp
- ret
-
-%undef ZERO
-%undef X0
-%undef X1
-%undef N0
-%undef N1
-%undef AL
-%undef K
-%undef LUT
-%undef T0
-%undef T0d
-%undef T1
-%undef T1d
-%undef BLOCK
-%undef VALUES
-%undef LEN
-%undef LENEND
-
-;
-; Prepare data for jsimd_encode_mcu_AC_refine().
-;
-; GLOBAL(int)
-; jsimd_encode_mcu_AC_refine_prepare_sse2(const JCOEF *block,
-; const int *jpeg_natural_order_start,
-; int Sl, int Al, JCOEF *absvalues,
-; size_t *bits)
-;
-; r10 = const JCOEF *block
-; r11 = const int *jpeg_natural_order_start
-; r12 = int Sl
-; r13 = int Al
-; r14 = JCOEF *values
-; r15 = size_t *bits
-
-%define ZERO xmm9
-%define ONE xmm5
-%define X0 xmm0
-%define X1 xmm1
-%define N0 xmm2
-%define N1 xmm3
-%define AL xmm4
-%define K eax
-%define KK r9d
-%define EOB r8d
-%define SIGN rdi
-%define LUT r11
-%define T0 rcx
-%define T0d ecx
-%define T1 rdx
-%define T1d edx
-%define BLOCK r10
-%define VALUES r14
-%define LEN r12d
-%define LENEND r13d
-
- align 32
- GLOBAL_FUNCTION(jsimd_encode_mcu_AC_refine_prepare_sse2)
-
-EXTN(jsimd_encode_mcu_AC_refine_prepare_sse2):
- push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
- and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [rbp - 16]
- collect_args 6
-
- movdqa XMMWORD [rbp - 16], ZERO
-
- xor SIGN, SIGN
- xor EOB, EOB
- xor KK, KK
- movd AL, r13d
- pxor ZERO, ZERO
- pcmpeqw ONE, ONE
- psrlw ONE, 15
- mov K, LEN
- mov LENEND, LEN
- and K, -16
- and LENEND, 7
- shr K, 4
- jz .ELOOPR16
-.BLOOPR16:
- LOAD16
- pcmpgtw N0, X0
- pcmpgtw N1, X1
- paddw X0, N0
- paddw X1, N1
- pxor X0, N0
- pxor X1, N1
- psrlw X0, AL
- psrlw X1, AL
- movdqa XMMWORD [VALUES + (0) * 2], X0
- movdqa XMMWORD [VALUES + (8) * 2], X1
- pcmpeqw X0, ONE
- pcmpeqw X1, ONE
- packsswb N0, N1
- packsswb X0, X1
- pmovmskb T0d, N0 ; lsignbits.val16u[k>>4] = _mm_movemask_epi8(neg);
- pmovmskb T1d, X0 ; idx = _mm_movemask_epi8(x1);
- shr SIGN, 16 ; make room for sizebits
- shl T0, 48
- or SIGN, T0
- bsr T1d, T1d ; idx = 16 - (__builtin_clz(idx)>>1);
- jz .CONTINUER16 ; if (idx) {
- mov EOB, KK
- add EOB, T1d ; EOB = k + idx;
-.CONTINUER16:
- add VALUES, 16*2
- add LUT, 16*SIZEOF_INT
- add KK, 16
- dec K
- jnz .BLOOPR16
- test LEN, 15
- je .PADDINGR
-.ELOOPR16:
- test LEN, 8
- jz .TRYR7
- test LEN, 7
- jz .TRYR8
-
- LOAD15
- pcmpgtw N0, X0
- pcmpgtw N1, X1
- paddw X0, N0
- paddw X1, N1
- pxor X0, N0
- pxor X1, N1
- psrlw X0, AL
- psrlw X1, AL
- movdqa XMMWORD [VALUES + (0) * 2], X0
- movdqa XMMWORD [VALUES + (8) * 2], X1
- pcmpeqw X0, ONE
- pcmpeqw X1, ONE
- packsswb N0, N1
- packsswb X0, X1
- pmovmskb T0d, N0 ; lsignbits.val16u[k>>4] = _mm_movemask_epi8(neg);
- pmovmskb T1d, X0 ; idx = _mm_movemask_epi8(x1);
- shr SIGN, 16 ; make room for sizebits
- shl T0, 48
- or SIGN, T0
- bsr T1d, T1d ; idx = 16 - (__builtin_clz(idx)>>1);
- jz .CONTINUER15 ; if (idx) {
- mov EOB, KK
- add EOB, T1d ; EOB = k + idx;
-.CONTINUER15:
- add VALUES, 16*2
- jmp .PADDINGR
-.TRYR8:
- LOAD8
-
- pcmpgtw N0, X0
- paddw X0, N0
- pxor X0, N0
- psrlw X0, AL
- movdqa XMMWORD [VALUES + (0) * 2], X0
- pcmpeqw X0, ONE
- packsswb N0, ZERO
- packsswb X0, ZERO
- pmovmskb T0d, N0 ; lsignbits.val16u[k>>4] = _mm_movemask_epi8(neg);
- pmovmskb T1d, X0 ; idx = _mm_movemask_epi8(x1);
- shr SIGN, 8 ; make room for sizebits
- shl T0, 56
- or SIGN, T0
- bsr T1d, T1d ; idx = 16 - (__builtin_clz(idx)>>1);
- jz .CONTINUER8 ; if (idx) {
- mov EOB, KK
- add EOB, T1d ; EOB = k + idx;
-.CONTINUER8:
- add VALUES, 8*2
- jmp .PADDINGR
-.TRYR7:
- LOAD7
-
- pcmpgtw N0, X0
- paddw X0, N0
- pxor X0, N0
- psrlw X0, AL
- movdqa XMMWORD [VALUES + (0) * 2], X0
- pcmpeqw X0, ONE
- packsswb N0, ZERO
- packsswb X0, ZERO
- pmovmskb T0d, N0 ; lsignbits.val16u[k>>4] = _mm_movemask_epi8(neg);
- pmovmskb T1d, X0 ; idx = _mm_movemask_epi8(x1);
- shr SIGN, 8 ; make room for sizebits
- shl T0, 56
- or SIGN, T0
- bsr T1d, T1d ; idx = 16 - (__builtin_clz(idx)>>1);
- jz .CONTINUER7 ; if (idx) {
- mov EOB, KK
- add EOB, T1d ; EOB = k + idx;
-.CONTINUER7:
- add VALUES, 8*2
-.PADDINGR:
- mov K, LEN
- add K, 7
- and K, -8
- shr K, 3
- sub K, DCTSIZE2/8
- jz .EPADDINGR
- align 16
-.ZEROLOOPR:
- movdqa XMMWORD [VALUES + 0], ZERO
- shr SIGN, 8
- add VALUES, 8*2
- inc K
- jnz .ZEROLOOPR
-.EPADDINGR:
- not SIGN
- sub VALUES, DCTSIZE2*2
- mov MMWORD [r15+SIZEOF_MMWORD], SIGN
-
- REDUCE0
-
- mov eax, EOB
- movdqa ZERO, XMMWORD [rbp - 16]
- uncollect_args 6
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
- pop rbp
- ret
-
-%undef ZERO
-%undef ONE
-%undef X0
-%undef X1
-%undef N0
-%undef N1
-%undef AL
-%undef K
-%undef KK
-%undef EOB
-%undef SIGN
-%undef LUT
-%undef T0
-%undef T0d
-%undef T1
-%undef T1d
-%undef BLOCK
-%undef VALUES
-%undef LEN
-%undef LENEND
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jcsample-avx2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jcsample-avx2.asm
deleted file mode 100644
index b32527aebe..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jcsample-avx2.asm
+++ /dev/null
@@ -1,367 +0,0 @@
-;
-; jcsample.asm - downsampling (64-bit AVX2)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
-; Copyright (C) 2015, Intel Corporation.
-; Copyright (C) 2018, Matthias Räncker.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jsimdext.inc"
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 64
-;
-; Downsample pixel values of a single component.
-; This version handles the common case of 2:1 horizontal and 1:1 vertical,
-; without smoothing.
-;
-; GLOBAL(void)
-; jsimd_h2v1_downsample_avx2(JDIMENSION image_width, int max_v_samp_factor,
-; JDIMENSION v_samp_factor,
-; JDIMENSION width_in_blocks, JSAMPARRAY input_data,
-; JSAMPARRAY output_data);
-;
-
-; r10d = JDIMENSION image_width
-; r11 = int max_v_samp_factor
-; r12d = JDIMENSION v_samp_factor
-; r13d = JDIMENSION width_in_blocks
-; r14 = JSAMPARRAY input_data
-; r15 = JSAMPARRAY output_data
-
- align 32
- GLOBAL_FUNCTION(jsimd_h2v1_downsample_avx2)
-
-EXTN(jsimd_h2v1_downsample_avx2):
- push rbp
- mov rax, rsp
- mov rbp, rsp
- collect_args 6
-
- mov ecx, r13d
- shl rcx, 3 ; imul rcx,DCTSIZE (rcx = output_cols)
- jz near .return
-
- mov edx, r10d
-
- ; -- expand_right_edge
-
- push rcx
- shl rcx, 1 ; output_cols * 2
- sub rcx, rdx
- jle short .expand_end
-
- mov rax, r11
- test rax, rax
- jle short .expand_end
-
- cld
- mov rsi, r14 ; input_data
-.expandloop:
- push rax
- push rcx
-
- mov rdip, JSAMPROW [rsi]
- add rdi, rdx
- mov al, JSAMPLE [rdi-1]
-
- rep stosb
-
- pop rcx
- pop rax
-
- add rsi, byte SIZEOF_JSAMPROW
- dec rax
- jg short .expandloop
-
-.expand_end:
- pop rcx ; output_cols
-
- ; -- h2v1_downsample
-
- mov eax, r12d ; rowctr
- test eax, eax
- jle near .return
-
- mov rdx, 0x00010000 ; bias pattern
- vmovd xmm7, edx
- vpshufd xmm7, xmm7, 0x00 ; xmm7={0, 1, 0, 1, 0, 1, 0, 1}
- vperm2i128 ymm7, ymm7, ymm7, 0 ; ymm7={xmm7, xmm7}
- vpcmpeqw ymm6, ymm6, ymm6
- vpsrlw ymm6, ymm6, BYTE_BIT ; ymm6={0xFF 0x00 0xFF 0x00 ..}
-
- mov rsi, r14 ; input_data
- mov rdi, r15 ; output_data
-.rowloop:
- push rcx
- push rdi
- push rsi
-
- mov rsip, JSAMPROW [rsi] ; inptr
- mov rdip, JSAMPROW [rdi] ; outptr
-
- cmp rcx, byte SIZEOF_YMMWORD
- jae short .columnloop
-
-.columnloop_r24:
- ; rcx can possibly be 8, 16, 24
- cmp rcx, 24
- jne .columnloop_r16
- vmovdqu ymm0, YMMWORD [rsi+0*SIZEOF_YMMWORD]
- vmovdqu xmm1, XMMWORD [rsi+1*SIZEOF_YMMWORD]
- mov rcx, SIZEOF_YMMWORD
- jmp short .downsample
-
-.columnloop_r16:
- cmp rcx, 16
- jne .columnloop_r8
- vmovdqu ymm0, YMMWORD [rsi+0*SIZEOF_YMMWORD]
- vpxor ymm1, ymm1, ymm1
- mov rcx, SIZEOF_YMMWORD
- jmp short .downsample
-
-.columnloop_r8:
- vmovdqu xmm0, XMMWORD[rsi+0*SIZEOF_YMMWORD]
- vpxor ymm1, ymm1, ymm1
- mov rcx, SIZEOF_YMMWORD
- jmp short .downsample
-
-.columnloop:
- vmovdqu ymm0, YMMWORD [rsi+0*SIZEOF_YMMWORD]
- vmovdqu ymm1, YMMWORD [rsi+1*SIZEOF_YMMWORD]
-
-.downsample:
- vpsrlw ymm2, ymm0, BYTE_BIT
- vpand ymm0, ymm0, ymm6
- vpsrlw ymm3, ymm1, BYTE_BIT
- vpand ymm1, ymm1, ymm6
-
- vpaddw ymm0, ymm0, ymm2
- vpaddw ymm1, ymm1, ymm3
- vpaddw ymm0, ymm0, ymm7
- vpaddw ymm1, ymm1, ymm7
- vpsrlw ymm0, ymm0, 1
- vpsrlw ymm1, ymm1, 1
-
- vpackuswb ymm0, ymm0, ymm1
- vpermq ymm0, ymm0, 0xd8
-
- vmovdqu YMMWORD [rdi+0*SIZEOF_YMMWORD], ymm0
-
- sub rcx, byte SIZEOF_YMMWORD ; outcol
- add rsi, byte 2*SIZEOF_YMMWORD ; inptr
- add rdi, byte 1*SIZEOF_YMMWORD ; outptr
- cmp rcx, byte SIZEOF_YMMWORD
- jae short .columnloop
- test rcx, rcx
- jnz near .columnloop_r24
-
- pop rsi
- pop rdi
- pop rcx
-
- add rsi, byte SIZEOF_JSAMPROW ; input_data
- add rdi, byte SIZEOF_JSAMPROW ; output_data
- dec rax ; rowctr
- jg near .rowloop
-
-.return:
- vzeroupper
- uncollect_args 6
- pop rbp
- ret
-
-; --------------------------------------------------------------------------
-;
-; Downsample pixel values of a single component.
-; This version handles the standard case of 2:1 horizontal and 2:1 vertical,
-; without smoothing.
-;
-; GLOBAL(void)
-; jsimd_h2v2_downsample_avx2(JDIMENSION image_width, int max_v_samp_factor,
-; JDIMENSION v_samp_factor,
-; JDIMENSION width_in_blocks, JSAMPARRAY input_data,
-; JSAMPARRAY output_data);
-;
-
-; r10d = JDIMENSION image_width
-; r11 = int max_v_samp_factor
-; r12d = JDIMENSION v_samp_factor
-; r13d = JDIMENSION width_in_blocks
-; r14 = JSAMPARRAY input_data
-; r15 = JSAMPARRAY output_data
-
- align 32
- GLOBAL_FUNCTION(jsimd_h2v2_downsample_avx2)
-
-EXTN(jsimd_h2v2_downsample_avx2):
- push rbp
- mov rax, rsp
- mov rbp, rsp
- collect_args 6
-
- mov ecx, r13d
- shl rcx, 3 ; imul rcx,DCTSIZE (rcx = output_cols)
- jz near .return
-
- mov edx, r10d
-
- ; -- expand_right_edge
-
- push rcx
- shl rcx, 1 ; output_cols * 2
- sub rcx, rdx
- jle short .expand_end
-
- mov rax, r11
- test rax, rax
- jle short .expand_end
-
- cld
- mov rsi, r14 ; input_data
-.expandloop:
- push rax
- push rcx
-
- mov rdip, JSAMPROW [rsi]
- add rdi, rdx
- mov al, JSAMPLE [rdi-1]
-
- rep stosb
-
- pop rcx
- pop rax
-
- add rsi, byte SIZEOF_JSAMPROW
- dec rax
- jg short .expandloop
-
-.expand_end:
- pop rcx ; output_cols
-
- ; -- h2v2_downsample
-
- mov eax, r12d ; rowctr
- test rax, rax
- jle near .return
-
- mov rdx, 0x00020001 ; bias pattern
- vmovd xmm7, edx
- vpcmpeqw ymm6, ymm6, ymm6
- vpshufd xmm7, xmm7, 0x00 ; ymm7={1, 2, 1, 2, 1, 2, 1, 2}
- vperm2i128 ymm7, ymm7, ymm7, 0
- vpsrlw ymm6, ymm6, BYTE_BIT ; ymm6={0xFF 0x00 0xFF 0x00 ..}
-
- mov rsi, r14 ; input_data
- mov rdi, r15 ; output_data
-.rowloop:
- push rcx
- push rdi
- push rsi
-
- mov rdxp, JSAMPROW [rsi+0*SIZEOF_JSAMPROW] ; inptr0
- mov rsip, JSAMPROW [rsi+1*SIZEOF_JSAMPROW] ; inptr1
- mov rdip, JSAMPROW [rdi] ; outptr
-
- cmp rcx, byte SIZEOF_YMMWORD
- jae short .columnloop
-
-.columnloop_r24:
- cmp rcx, 24
- jne .columnloop_r16
- vmovdqu ymm0, YMMWORD [rdx+0*SIZEOF_YMMWORD]
- vmovdqu ymm1, YMMWORD [rsi+0*SIZEOF_YMMWORD]
- vmovdqu xmm2, XMMWORD [rdx+1*SIZEOF_YMMWORD]
- vmovdqu xmm3, XMMWORD [rsi+1*SIZEOF_YMMWORD]
- mov rcx, SIZEOF_YMMWORD
- jmp short .downsample
-
-.columnloop_r16:
- cmp rcx, 16
- jne .columnloop_r8
- vmovdqu ymm0, YMMWORD [rdx+0*SIZEOF_YMMWORD]
- vmovdqu ymm1, YMMWORD [rsi+0*SIZEOF_YMMWORD]
- vpxor ymm2, ymm2, ymm2
- vpxor ymm3, ymm3, ymm3
- mov rcx, SIZEOF_YMMWORD
- jmp short .downsample
-
-.columnloop_r8:
- vmovdqu xmm0, XMMWORD [rdx+0*SIZEOF_XMMWORD]
- vmovdqu xmm1, XMMWORD [rsi+0*SIZEOF_XMMWORD]
- vpxor ymm2, ymm2, ymm2
- vpxor ymm3, ymm3, ymm3
- mov rcx, SIZEOF_YMMWORD
- jmp short .downsample
-
-.columnloop:
- vmovdqu ymm0, YMMWORD [rdx+0*SIZEOF_YMMWORD]
- vmovdqu ymm1, YMMWORD [rsi+0*SIZEOF_YMMWORD]
- vmovdqu ymm2, YMMWORD [rdx+1*SIZEOF_YMMWORD]
- vmovdqu ymm3, YMMWORD [rsi+1*SIZEOF_YMMWORD]
-
-.downsample:
- vpand ymm4, ymm0, ymm6
- vpsrlw ymm0, ymm0, BYTE_BIT
- vpand ymm5, ymm1, ymm6
- vpsrlw ymm1, ymm1, BYTE_BIT
- vpaddw ymm0, ymm0, ymm4
- vpaddw ymm1, ymm1, ymm5
-
- vpand ymm4, ymm2, ymm6
- vpsrlw ymm2, ymm2, BYTE_BIT
- vpand ymm5, ymm3, ymm6
- vpsrlw ymm3, ymm3, BYTE_BIT
- vpaddw ymm2, ymm2, ymm4
- vpaddw ymm3, ymm3, ymm5
-
- vpaddw ymm0, ymm0, ymm1
- vpaddw ymm2, ymm2, ymm3
- vpaddw ymm0, ymm0, ymm7
- vpaddw ymm2, ymm2, ymm7
- vpsrlw ymm0, ymm0, 2
- vpsrlw ymm2, ymm2, 2
-
- vpackuswb ymm0, ymm0, ymm2
- vpermq ymm0, ymm0, 0xd8
-
- vmovdqu YMMWORD [rdi+0*SIZEOF_YMMWORD], ymm0
-
- sub rcx, byte SIZEOF_YMMWORD ; outcol
- add rdx, byte 2*SIZEOF_YMMWORD ; inptr0
- add rsi, byte 2*SIZEOF_YMMWORD ; inptr1
- add rdi, byte 1*SIZEOF_YMMWORD ; outptr
- cmp rcx, byte SIZEOF_YMMWORD
- jae near .columnloop
- test rcx, rcx
- jnz near .columnloop_r24
-
- pop rsi
- pop rdi
- pop rcx
-
- add rsi, byte 2*SIZEOF_JSAMPROW ; input_data
- add rdi, byte 1*SIZEOF_JSAMPROW ; output_data
- dec rax ; rowctr
- jg near .rowloop
-
-.return:
- vzeroupper
- uncollect_args 6
- pop rbp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jcsample-sse2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jcsample-sse2.asm
deleted file mode 100644
index 2fcfe4567a..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jcsample-sse2.asm
+++ /dev/null
@@ -1,330 +0,0 @@
-;
-; jcsample.asm - downsampling (64-bit SSE2)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
-; Copyright (C) 2018, Matthias Räncker.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jsimdext.inc"
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 64
-;
-; Downsample pixel values of a single component.
-; This version handles the common case of 2:1 horizontal and 1:1 vertical,
-; without smoothing.
-;
-; GLOBAL(void)
-; jsimd_h2v1_downsample_sse2(JDIMENSION image_width, int max_v_samp_factor,
-; JDIMENSION v_samp_factor,
-; JDIMENSION width_in_blocks, JSAMPARRAY input_data,
-; JSAMPARRAY output_data);
-;
-
-; r10d = JDIMENSION image_width
-; r11 = int max_v_samp_factor
-; r12d = JDIMENSION v_samp_factor
-; r13d = JDIMENSION width_in_blocks
-; r14 = JSAMPARRAY input_data
-; r15 = JSAMPARRAY output_data
-
- align 32
- GLOBAL_FUNCTION(jsimd_h2v1_downsample_sse2)
-
-EXTN(jsimd_h2v1_downsample_sse2):
- push rbp
- mov rax, rsp
- mov rbp, rsp
- collect_args 6
-
- mov ecx, r13d
- shl rcx, 3 ; imul rcx,DCTSIZE (rcx = output_cols)
- jz near .return
-
- mov edx, r10d
-
- ; -- expand_right_edge
-
- push rcx
- shl rcx, 1 ; output_cols * 2
- sub rcx, rdx
- jle short .expand_end
-
- mov rax, r11
- test rax, rax
- jle short .expand_end
-
- cld
- mov rsi, r14 ; input_data
-.expandloop:
- push rax
- push rcx
-
- mov rdip, JSAMPROW [rsi]
- add rdi, rdx
- mov al, JSAMPLE [rdi-1]
-
- rep stosb
-
- pop rcx
- pop rax
-
- add rsi, byte SIZEOF_JSAMPROW
- dec rax
- jg short .expandloop
-
-.expand_end:
- pop rcx ; output_cols
-
- ; -- h2v1_downsample
-
- mov eax, r12d ; rowctr
- test eax, eax
- jle near .return
-
- mov rdx, 0x00010000 ; bias pattern
- movd xmm7, edx
- pcmpeqw xmm6, xmm6
- pshufd xmm7, xmm7, 0x00 ; xmm7={0, 1, 0, 1, 0, 1, 0, 1}
- psrlw xmm6, BYTE_BIT ; xmm6={0xFF 0x00 0xFF 0x00 ..}
-
- mov rsi, r14 ; input_data
- mov rdi, r15 ; output_data
-.rowloop:
- push rcx
- push rdi
- push rsi
-
- mov rsip, JSAMPROW [rsi] ; inptr
- mov rdip, JSAMPROW [rdi] ; outptr
-
- cmp rcx, byte SIZEOF_XMMWORD
- jae short .columnloop
-
-.columnloop_r8:
- movdqa xmm0, XMMWORD [rsi+0*SIZEOF_XMMWORD]
- pxor xmm1, xmm1
- mov rcx, SIZEOF_XMMWORD
- jmp short .downsample
-
-.columnloop:
- movdqa xmm0, XMMWORD [rsi+0*SIZEOF_XMMWORD]
- movdqa xmm1, XMMWORD [rsi+1*SIZEOF_XMMWORD]
-
-.downsample:
- movdqa xmm2, xmm0
- movdqa xmm3, xmm1
-
- pand xmm0, xmm6
- psrlw xmm2, BYTE_BIT
- pand xmm1, xmm6
- psrlw xmm3, BYTE_BIT
-
- paddw xmm0, xmm2
- paddw xmm1, xmm3
- paddw xmm0, xmm7
- paddw xmm1, xmm7
- psrlw xmm0, 1
- psrlw xmm1, 1
-
- packuswb xmm0, xmm1
-
- movdqa XMMWORD [rdi+0*SIZEOF_XMMWORD], xmm0
-
- sub rcx, byte SIZEOF_XMMWORD ; outcol
- add rsi, byte 2*SIZEOF_XMMWORD ; inptr
- add rdi, byte 1*SIZEOF_XMMWORD ; outptr
- cmp rcx, byte SIZEOF_XMMWORD
- jae short .columnloop
- test rcx, rcx
- jnz short .columnloop_r8
-
- pop rsi
- pop rdi
- pop rcx
-
- add rsi, byte SIZEOF_JSAMPROW ; input_data
- add rdi, byte SIZEOF_JSAMPROW ; output_data
- dec rax ; rowctr
- jg near .rowloop
-
-.return:
- uncollect_args 6
- pop rbp
- ret
-
-; --------------------------------------------------------------------------
-;
-; Downsample pixel values of a single component.
-; This version handles the standard case of 2:1 horizontal and 2:1 vertical,
-; without smoothing.
-;
-; GLOBAL(void)
-; jsimd_h2v2_downsample_sse2(JDIMENSION image_width, int max_v_samp_factor,
-; JDIMENSION v_samp_factor,
-; JDIMENSION width_in_blocks, JSAMPARRAY input_data,
-; JSAMPARRAY output_data);
-;
-
-; r10d = JDIMENSION image_width
-; r11 = int max_v_samp_factor
-; r12d = JDIMENSION v_samp_factor
-; r13d = JDIMENSION width_in_blocks
-; r14 = JSAMPARRAY input_data
-; r15 = JSAMPARRAY output_data
-
- align 32
- GLOBAL_FUNCTION(jsimd_h2v2_downsample_sse2)
-
-EXTN(jsimd_h2v2_downsample_sse2):
- push rbp
- mov rax, rsp
- mov rbp, rsp
- collect_args 6
-
- mov ecx, r13d
- shl rcx, 3 ; imul rcx,DCTSIZE (rcx = output_cols)
- jz near .return
-
- mov edx, r10d
-
- ; -- expand_right_edge
-
- push rcx
- shl rcx, 1 ; output_cols * 2
- sub rcx, rdx
- jle short .expand_end
-
- mov rax, r11
- test rax, rax
- jle short .expand_end
-
- cld
- mov rsi, r14 ; input_data
-.expandloop:
- push rax
- push rcx
-
- mov rdip, JSAMPROW [rsi]
- add rdi, rdx
- mov al, JSAMPLE [rdi-1]
-
- rep stosb
-
- pop rcx
- pop rax
-
- add rsi, byte SIZEOF_JSAMPROW
- dec rax
- jg short .expandloop
-
-.expand_end:
- pop rcx ; output_cols
-
- ; -- h2v2_downsample
-
- mov eax, r12d ; rowctr
- test rax, rax
- jle near .return
-
- mov rdx, 0x00020001 ; bias pattern
- movd xmm7, edx
- pcmpeqw xmm6, xmm6
- pshufd xmm7, xmm7, 0x00 ; xmm7={1, 2, 1, 2, 1, 2, 1, 2}
- psrlw xmm6, BYTE_BIT ; xmm6={0xFF 0x00 0xFF 0x00 ..}
-
- mov rsi, r14 ; input_data
- mov rdi, r15 ; output_data
-.rowloop:
- push rcx
- push rdi
- push rsi
-
- mov rdxp, JSAMPROW [rsi+0*SIZEOF_JSAMPROW] ; inptr0
- mov rsip, JSAMPROW [rsi+1*SIZEOF_JSAMPROW] ; inptr1
- mov rdip, JSAMPROW [rdi] ; outptr
-
- cmp rcx, byte SIZEOF_XMMWORD
- jae short .columnloop
-
-.columnloop_r8:
- movdqa xmm0, XMMWORD [rdx+0*SIZEOF_XMMWORD]
- movdqa xmm1, XMMWORD [rsi+0*SIZEOF_XMMWORD]
- pxor xmm2, xmm2
- pxor xmm3, xmm3
- mov rcx, SIZEOF_XMMWORD
- jmp short .downsample
-
-.columnloop:
- movdqa xmm0, XMMWORD [rdx+0*SIZEOF_XMMWORD]
- movdqa xmm1, XMMWORD [rsi+0*SIZEOF_XMMWORD]
- movdqa xmm2, XMMWORD [rdx+1*SIZEOF_XMMWORD]
- movdqa xmm3, XMMWORD [rsi+1*SIZEOF_XMMWORD]
-
-.downsample:
- movdqa xmm4, xmm0
- movdqa xmm5, xmm1
- pand xmm0, xmm6
- psrlw xmm4, BYTE_BIT
- pand xmm1, xmm6
- psrlw xmm5, BYTE_BIT
- paddw xmm0, xmm4
- paddw xmm1, xmm5
-
- movdqa xmm4, xmm2
- movdqa xmm5, xmm3
- pand xmm2, xmm6
- psrlw xmm4, BYTE_BIT
- pand xmm3, xmm6
- psrlw xmm5, BYTE_BIT
- paddw xmm2, xmm4
- paddw xmm3, xmm5
-
- paddw xmm0, xmm1
- paddw xmm2, xmm3
- paddw xmm0, xmm7
- paddw xmm2, xmm7
- psrlw xmm0, 2
- psrlw xmm2, 2
-
- packuswb xmm0, xmm2
-
- movdqa XMMWORD [rdi+0*SIZEOF_XMMWORD], xmm0
-
- sub rcx, byte SIZEOF_XMMWORD ; outcol
- add rdx, byte 2*SIZEOF_XMMWORD ; inptr0
- add rsi, byte 2*SIZEOF_XMMWORD ; inptr1
- add rdi, byte 1*SIZEOF_XMMWORD ; outptr
- cmp rcx, byte SIZEOF_XMMWORD
- jae near .columnloop
- test rcx, rcx
- jnz near .columnloop_r8
-
- pop rsi
- pop rdi
- pop rcx
-
- add rsi, byte 2*SIZEOF_JSAMPROW ; input_data
- add rdi, byte 1*SIZEOF_JSAMPROW ; output_data
- dec rax ; rowctr
- jg near .rowloop
-
-.return:
- uncollect_args 6
- pop rbp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jdcolext-avx2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jdcolext-avx2.asm
deleted file mode 100644
index 2370fda642..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jdcolext-avx2.asm
+++ /dev/null
@@ -1,496 +0,0 @@
-;
-; jdcolext.asm - colorspace conversion (64-bit AVX2)
-;
-; Copyright 2009, 2012 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, 2012, 2016, D. R. Commander.
-; Copyright (C) 2015, Intel Corporation.
-; Copyright (C) 2018, Matthias Räncker.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jcolsamp.inc"
-
-; --------------------------------------------------------------------------
-;
-; Convert some rows of samples to the output colorspace.
-;
-; GLOBAL(void)
-; jsimd_ycc_rgb_convert_avx2(JDIMENSION out_width, JSAMPIMAGE input_buf,
-; JDIMENSION input_row, JSAMPARRAY output_buf,
-; int num_rows)
-;
-
-; r10d = JDIMENSION out_width
-; r11 = JSAMPIMAGE input_buf
-; r12d = JDIMENSION input_row
-; r13 = JSAMPARRAY output_buf
-; r14d = int num_rows
-
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_YMMWORD ; ymmword wk[WK_NUM]
-%define WK_NUM 2
-
- align 32
- GLOBAL_FUNCTION(jsimd_ycc_rgb_convert_avx2)
-
-EXTN(jsimd_ycc_rgb_convert_avx2):
- push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
- and rsp, byte (-SIZEOF_YMMWORD) ; align to 256 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
- collect_args 5
- push rbx
-
- mov ecx, r10d ; num_cols
- test rcx, rcx
- jz near .return
-
- push rcx
-
- mov rdi, r11
- mov ecx, r12d
- mov rsip, JSAMPARRAY [rdi+0*SIZEOF_JSAMPARRAY]
- mov rbxp, JSAMPARRAY [rdi+1*SIZEOF_JSAMPARRAY]
- mov rdxp, JSAMPARRAY [rdi+2*SIZEOF_JSAMPARRAY]
- lea rsi, [rsi+rcx*SIZEOF_JSAMPROW]
- lea rbx, [rbx+rcx*SIZEOF_JSAMPROW]
- lea rdx, [rdx+rcx*SIZEOF_JSAMPROW]
-
- pop rcx
-
- mov rdi, r13
- mov eax, r14d
- test rax, rax
- jle near .return
-.rowloop:
- push rax
- push rdi
- push rdx
- push rbx
- push rsi
- push rcx ; col
-
- mov rsip, JSAMPROW [rsi] ; inptr0
- mov rbxp, JSAMPROW [rbx] ; inptr1
- mov rdxp, JSAMPROW [rdx] ; inptr2
- mov rdip, JSAMPROW [rdi] ; outptr
-.columnloop:
-
- vmovdqu ymm5, YMMWORD [rbx] ; ymm5=Cb(0123456789ABCDEFGHIJKLMNOPQRSTUV)
- vmovdqu ymm1, YMMWORD [rdx] ; ymm1=Cr(0123456789ABCDEFGHIJKLMNOPQRSTUV)
-
- vpcmpeqw ymm0, ymm0, ymm0
- vpcmpeqw ymm7, ymm7, ymm7
- vpsrlw ymm0, ymm0, BYTE_BIT ; ymm0={0xFF 0x00 0xFF 0x00 ..}
- vpsllw ymm7, ymm7, 7 ; ymm7={0xFF80 0xFF80 0xFF80 0xFF80 ..}
-
- vpand ymm4, ymm0, ymm5 ; ymm4=Cb(02468ACEGIKMOQSU)=CbE
- vpsrlw ymm5, ymm5, BYTE_BIT ; ymm5=Cb(13579BDFHJLNPRTV)=CbO
- vpand ymm0, ymm0, ymm1 ; ymm0=Cr(02468ACEGIKMOQSU)=CrE
- vpsrlw ymm1, ymm1, BYTE_BIT ; ymm1=Cr(13579BDFHJLNPRTV)=CrO
-
- vpaddw ymm2, ymm4, ymm7
- vpaddw ymm3, ymm5, ymm7
- vpaddw ymm6, ymm0, ymm7
- vpaddw ymm7, ymm1, ymm7
-
- ; (Original)
- ; R = Y + 1.40200 * Cr
- ; G = Y - 0.34414 * Cb - 0.71414 * Cr
- ; B = Y + 1.77200 * Cb
- ;
- ; (This implementation)
- ; R = Y + 0.40200 * Cr + Cr
- ; G = Y - 0.34414 * Cb + 0.28586 * Cr - Cr
- ; B = Y - 0.22800 * Cb + Cb + Cb
-
- vpaddw ymm4, ymm2, ymm2 ; ymm4=2*CbE
- vpaddw ymm5, ymm3, ymm3 ; ymm5=2*CbO
- vpaddw ymm0, ymm6, ymm6 ; ymm0=2*CrE
- vpaddw ymm1, ymm7, ymm7 ; ymm1=2*CrO
-
- vpmulhw ymm4, ymm4, [rel PW_MF0228] ; ymm4=(2*CbE * -FIX(0.22800))
- vpmulhw ymm5, ymm5, [rel PW_MF0228] ; ymm5=(2*CbO * -FIX(0.22800))
- vpmulhw ymm0, ymm0, [rel PW_F0402] ; ymm0=(2*CrE * FIX(0.40200))
- vpmulhw ymm1, ymm1, [rel PW_F0402] ; ymm1=(2*CrO * FIX(0.40200))
-
- vpaddw ymm4, ymm4, [rel PW_ONE]
- vpaddw ymm5, ymm5, [rel PW_ONE]
- vpsraw ymm4, ymm4, 1 ; ymm4=(CbE * -FIX(0.22800))
- vpsraw ymm5, ymm5, 1 ; ymm5=(CbO * -FIX(0.22800))
- vpaddw ymm0, ymm0, [rel PW_ONE]
- vpaddw ymm1, ymm1, [rel PW_ONE]
- vpsraw ymm0, ymm0, 1 ; ymm0=(CrE * FIX(0.40200))
- vpsraw ymm1, ymm1, 1 ; ymm1=(CrO * FIX(0.40200))
-
- vpaddw ymm4, ymm4, ymm2
- vpaddw ymm5, ymm5, ymm3
- vpaddw ymm4, ymm4, ymm2 ; ymm4=(CbE * FIX(1.77200))=(B-Y)E
- vpaddw ymm5, ymm5, ymm3 ; ymm5=(CbO * FIX(1.77200))=(B-Y)O
- vpaddw ymm0, ymm0, ymm6 ; ymm0=(CrE * FIX(1.40200))=(R-Y)E
- vpaddw ymm1, ymm1, ymm7 ; ymm1=(CrO * FIX(1.40200))=(R-Y)O
-
- vmovdqa YMMWORD [wk(0)], ymm4 ; wk(0)=(B-Y)E
- vmovdqa YMMWORD [wk(1)], ymm5 ; wk(1)=(B-Y)O
-
- vpunpckhwd ymm4, ymm2, ymm6
- vpunpcklwd ymm2, ymm2, ymm6
- vpmaddwd ymm2, ymm2, [rel PW_MF0344_F0285]
- vpmaddwd ymm4, ymm4, [rel PW_MF0344_F0285]
- vpunpckhwd ymm5, ymm3, ymm7
- vpunpcklwd ymm3, ymm3, ymm7
- vpmaddwd ymm3, ymm3, [rel PW_MF0344_F0285]
- vpmaddwd ymm5, ymm5, [rel PW_MF0344_F0285]
-
- vpaddd ymm2, ymm2, [rel PD_ONEHALF]
- vpaddd ymm4, ymm4, [rel PD_ONEHALF]
- vpsrad ymm2, ymm2, SCALEBITS
- vpsrad ymm4, ymm4, SCALEBITS
- vpaddd ymm3, ymm3, [rel PD_ONEHALF]
- vpaddd ymm5, ymm5, [rel PD_ONEHALF]
- vpsrad ymm3, ymm3, SCALEBITS
- vpsrad ymm5, ymm5, SCALEBITS
-
- vpackssdw ymm2, ymm2, ymm4 ; ymm2=CbE*-FIX(0.344)+CrE*FIX(0.285)
- vpackssdw ymm3, ymm3, ymm5 ; ymm3=CbO*-FIX(0.344)+CrO*FIX(0.285)
- vpsubw ymm2, ymm2, ymm6 ; ymm2=CbE*-FIX(0.344)+CrE*-FIX(0.714)=(G-Y)E
- vpsubw ymm3, ymm3, ymm7 ; ymm3=CbO*-FIX(0.344)+CrO*-FIX(0.714)=(G-Y)O
-
- vmovdqu ymm5, YMMWORD [rsi] ; ymm5=Y(0123456789ABCDEFGHIJKLMNOPQRSTUV)
-
- vpcmpeqw ymm4, ymm4, ymm4
- vpsrlw ymm4, ymm4, BYTE_BIT ; ymm4={0xFF 0x00 0xFF 0x00 ..}
- vpand ymm4, ymm4, ymm5 ; ymm4=Y(02468ACEGIKMOQSU)=YE
- vpsrlw ymm5, ymm5, BYTE_BIT ; ymm5=Y(13579BDFHJLNPRTV)=YO
-
- vpaddw ymm0, ymm0, ymm4 ; ymm0=((R-Y)E+YE)=RE=R(02468ACEGIKMOQSU)
- vpaddw ymm1, ymm1, ymm5 ; ymm1=((R-Y)O+YO)=RO=R(13579BDFHJLNPRTV)
- vpackuswb ymm0, ymm0, ymm0 ; ymm0=R(02468ACE********GIKMOQSU********)
- vpackuswb ymm1, ymm1, ymm1 ; ymm1=R(13579BDF********HJLNPRTV********)
-
- vpaddw ymm2, ymm2, ymm4 ; ymm2=((G-Y)E+YE)=GE=G(02468ACEGIKMOQSU)
- vpaddw ymm3, ymm3, ymm5 ; ymm3=((G-Y)O+YO)=GO=G(13579BDFHJLNPRTV)
- vpackuswb ymm2, ymm2, ymm2 ; ymm2=G(02468ACE********GIKMOQSU********)
- vpackuswb ymm3, ymm3, ymm3 ; ymm3=G(13579BDF********HJLNPRTV********)
-
- vpaddw ymm4, ymm4, YMMWORD [wk(0)] ; ymm4=(YE+(B-Y)E)=BE=B(02468ACEGIKMOQSU)
- vpaddw ymm5, ymm5, YMMWORD [wk(1)] ; ymm5=(YO+(B-Y)O)=BO=B(13579BDFHJLNPRTV)
- vpackuswb ymm4, ymm4, ymm4 ; ymm4=B(02468ACE********GIKMOQSU********)
- vpackuswb ymm5, ymm5, ymm5 ; ymm5=B(13579BDF********HJLNPRTV********)
-
-%if RGB_PIXELSIZE == 3 ; ---------------
-
- ; ymmA=(00 02 04 06 08 0A 0C 0E ** 0G 0I 0K 0M 0O 0Q 0S 0U **)
- ; ymmB=(01 03 05 07 09 0B 0D 0F ** 0H 0J 0L 0N 0P 0R 0T 0V **)
- ; ymmC=(10 12 14 16 18 1A 1C 1E ** 1G 1I 1K 1M 1O 1Q 1S 1U **)
- ; ymmD=(11 13 15 17 19 1B 1D 1F ** 1H 1J 1L 1N 1P 1R 1T 1V **)
- ; ymmE=(20 22 24 26 28 2A 2C 2E ** 2G 2I 2K 2M 2O 2Q 2S 2U **)
- ; ymmF=(21 23 25 27 29 2B 2D 2F ** 2H 2J 2L 2N 2P 2R 2T 2V **)
- ; ymmG=(** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **)
- ; ymmH=(** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **)
-
- vpunpcklbw ymmA, ymmA, ymmC ; ymmA=(00 10 02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E
- ; 0G 1G 0I 1I 0K 1K 0M 1M 0O 1O 0Q 1Q 0S 1S 0U 1U)
- vpunpcklbw ymmE, ymmE, ymmB ; ymmE=(20 01 22 03 24 05 26 07 28 09 2A 0B 2C 0D 2E 0F
- ; 2G 0H 2I 0J 2K 0L 2M 0N 2O 0P 2Q 0R 2S 0T 2U 0V)
- vpunpcklbw ymmD, ymmD, ymmF ; ymmD=(11 21 13 23 15 25 17 27 19 29 1B 2B 1D 2D 1F 2F
- ; 1H 2H 1J 2J 1L 2L 1N 2N 1P 2P 1R 2R 1T 2T 1V 2V)
-
- vpsrldq ymmH, ymmA, 2 ; ymmH=(02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E 0G 1G
- ; 0I 1I 0K 1K 0M 1M 0O 1O 0Q 1Q 0S 1S 0U 1U -- --)
- vpunpckhwd ymmG, ymmA, ymmE ; ymmG=(08 18 28 09 0A 1A 2A 0B 0C 1C 2C 0D 0E 1E 2E 0F
- ; 0O 1O 2O 0P 0Q 1Q 2Q 0R 0S 1S 2S 0T 0U 1U 2U 0V)
- vpunpcklwd ymmA, ymmA, ymmE ; ymmA=(00 10 20 01 02 12 22 03 04 14 24 05 06 16 26 07
- ; 0G 1G 2G 0H 0I 1I 2I 0J 0K 1K 2K 0L 0M 1M 2M 0N)
-
- vpsrldq ymmE, ymmE, 2 ; ymmE=(22 03 24 05 26 07 28 09 2A 0B 2C 0D 2E 0F 2G 0H
- ; 2I 0J 2K 0L 2M 0N 2O 0P 2Q 0R 2S 0T 2U 0V -- --)
-
- vpsrldq ymmB, ymmD, 2 ; ymmB=(13 23 15 25 17 27 19 29 1B 2B 1D 2D 1F 2F 1H 2H
- ; 1J 2J 1L 2L 1N 2N 1P 2P 1R 2R 1T 2T 1V 2V -- --)
- vpunpckhwd ymmC, ymmD, ymmH ; ymmC=(19 29 0A 1A 1B 2B 0C 1C 1D 2D 0E 1E 1F 2F 0G 1G
- ; 1P 2P 0Q 1Q 1R 2R 0S 1S 1T 2T 0U 1U 1V 2V -- --)
- vpunpcklwd ymmD, ymmD, ymmH ; ymmD=(11 21 02 12 13 23 04 14 15 25 06 16 17 27 08 18
- ; 1H 2H 0I 1I 1J 2J 0K 1K 1L 2L 0M 1M 1N 2N 0O 1O)
-
- vpunpckhwd ymmF, ymmE, ymmB ; ymmF=(2A 0B 1B 2B 2C 0D 1D 2D 2E 0F 1F 2F 2G 0H 1H 2H
- ; 2Q 0R 1R 2R 2S 0T 1T 2T 2U 0V 1V 2V -- -- -- --)
- vpunpcklwd ymmE, ymmE, ymmB ; ymmE=(22 03 13 23 24 05 15 25 26 07 17 27 28 09 19 29
- ; 2I 0J 1J 2J 2K 0L 1L 2L 2M 0N 1N 2N 2O 0P 1P 2P)
-
- vpshufd ymmH, ymmA, 0x4E ; ymmH=(04 14 24 05 06 16 26 07 00 10 20 01 02 12 22 03
- ; 0K 1K 2K 0L 0M 1M 2M 0N 0G 1G 2G 0H 0I 1I 2I 0J)
- vpunpckldq ymmA, ymmA, ymmD ; ymmA=(00 10 20 01 11 21 02 12 02 12 22 03 13 23 04 14
- ; 0G 1G 2G 0H 1H 2H 0I 1I 0I 1I 2I 0J 1J 2J 0K 1K)
- vpunpckhdq ymmD, ymmD, ymmE ; ymmD=(15 25 06 16 26 07 17 27 17 27 08 18 28 09 19 29
- ; 1L 2L 0M 1M 2M 0N 1N 2N 1N 2N 0O 1O 2O 0P 1P 2P)
- vpunpckldq ymmE, ymmE, ymmH ; ymmE=(22 03 13 23 04 14 24 05 24 05 15 25 06 16 26 07
- ; 2I 0J 1J 2J 0K 1K 2K 0L 2K 0L 1L 2L 0M 1M 2M 0N)
-
- vpshufd ymmH, ymmG, 0x4E ; ymmH=(0C 1C 2C 0D 0E 1E 2E 0F 08 18 28 09 0A 1A 2A 0B
- ; 0S 1S 2S 0T 0U 1U 2U 0V 0O 1O 2O 0P 0Q 1Q 2Q 0R)
- vpunpckldq ymmG, ymmG, ymmC ; ymmG=(08 18 28 09 19 29 0A 1A 0A 1A 2A 0B 1B 2B 0C 1C
- ; 0O 1O 2O 0P 1P 2P 0Q 1Q 0Q 1Q 2Q 0R 1R 2R 0S 1S)
- vpunpckhdq ymmC, ymmC, ymmF ; ymmC=(1D 2D 0E 1E 2E 0F 1F 2F 1F 2F 0G 1G 2G 0H 1H 2H
- ; 1T 2T 0U 1U 2U 0V 1V 2V 1V 2V -- -- -- -- -- --)
- vpunpckldq ymmF, ymmF, ymmH ; ymmF=(2A 0B 1B 2B 0C 1C 2C 0D 2C 0D 1D 2D 0E 1E 2E 0F
- ; 2Q 0R 1R 2R 0S 1S 2S 0T 2S 0T 1T 2T 0U 1U 2U 0V)
-
- vpunpcklqdq ymmH, ymmA, ymmE ; ymmH=(00 10 20 01 11 21 02 12 22 03 13 23 04 14 24 05
- ; 0G 1G 2G 0H 1H 2H 0I 1I 2I 0J 1J 2J 0K 1K 2K 0L)
- vpunpcklqdq ymmG, ymmD, ymmG ; ymmG=(15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A
- ; 1L 2L 0M 1M 2M 0N 1N 2N 0O 1O 2O 0P 1P 2P 0Q 1Q)
- vpunpcklqdq ymmC, ymmF, ymmC ; ymmC=(2A 0B 1B 2B 0C 1C 2C 0D 1D 2D 0E 1E 2E 0F 1F 2F
- ; 2Q 0R 1R 2R 0S 1S 2S 0T 1T 2T 0U 1U 2U 0V 1V 2V)
-
- vperm2i128 ymmA, ymmH, ymmG, 0x20 ; ymmA=(00 10 20 01 11 21 02 12 22 03 13 23 04 14 24 05
- ; 15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A)
- vperm2i128 ymmD, ymmC, ymmH, 0x30 ; ymmD=(2A 0B 1B 2B 0C 1C 2C 0D 1D 2D 0E 1E 2E 0F 1F 2F
- ; 0G 1G 2G 0H 1H 2H 0I 1I 2I 0J 1J 2J 0K 1K 2K 0L)
- vperm2i128 ymmF, ymmG, ymmC, 0x31 ; ymmF=(1L 2L 0M 1M 2M 0N 1N 2N 0O 1O 2O 0P 1P 2P 0Q 1Q
- ; 2Q 0R 1R 2R 0S 1S 2S 0T 1T 2T 0U 1U 2U 0V 1V 2V)
-
- cmp rcx, byte SIZEOF_YMMWORD
- jb short .column_st64
-
- test rdi, SIZEOF_YMMWORD-1
- jnz short .out1
- ; --(aligned)-------------------
- vmovntdq YMMWORD [rdi+0*SIZEOF_YMMWORD], ymmA
- vmovntdq YMMWORD [rdi+1*SIZEOF_YMMWORD], ymmD
- vmovntdq YMMWORD [rdi+2*SIZEOF_YMMWORD], ymmF
- jmp short .out0
-.out1: ; --(unaligned)-----------------
- vmovdqu YMMWORD [rdi+0*SIZEOF_YMMWORD], ymmA
- vmovdqu YMMWORD [rdi+1*SIZEOF_YMMWORD], ymmD
- vmovdqu YMMWORD [rdi+2*SIZEOF_YMMWORD], ymmF
-.out0:
- add rdi, byte RGB_PIXELSIZE*SIZEOF_YMMWORD ; outptr
- sub rcx, byte SIZEOF_YMMWORD
- jz near .nextrow
-
- add rsi, byte SIZEOF_YMMWORD ; inptr0
- add rbx, byte SIZEOF_YMMWORD ; inptr1
- add rdx, byte SIZEOF_YMMWORD ; inptr2
- jmp near .columnloop
-
-.column_st64:
- lea rcx, [rcx+rcx*2] ; imul ecx, RGB_PIXELSIZE
- cmp rcx, byte 2*SIZEOF_YMMWORD
- jb short .column_st32
- vmovdqu YMMWORD [rdi+0*SIZEOF_YMMWORD], ymmA
- vmovdqu YMMWORD [rdi+1*SIZEOF_YMMWORD], ymmD
- add rdi, byte 2*SIZEOF_YMMWORD ; outptr
- vmovdqa ymmA, ymmF
- sub rcx, byte 2*SIZEOF_YMMWORD
- jmp short .column_st31
-.column_st32:
- cmp rcx, byte SIZEOF_YMMWORD
- jb short .column_st31
- vmovdqu YMMWORD [rdi+0*SIZEOF_YMMWORD], ymmA
- add rdi, byte SIZEOF_YMMWORD ; outptr
- vmovdqa ymmA, ymmD
- sub rcx, byte SIZEOF_YMMWORD
- jmp short .column_st31
-.column_st31:
- cmp rcx, byte SIZEOF_XMMWORD
- jb short .column_st15
- vmovdqu XMMWORD [rdi+0*SIZEOF_XMMWORD], xmmA
- add rdi, byte SIZEOF_XMMWORD ; outptr
- vperm2i128 ymmA, ymmA, ymmA, 1
- sub rcx, byte SIZEOF_XMMWORD
-.column_st15:
- ; Store the lower 8 bytes of xmmA to the output when it has enough
- ; space.
- cmp rcx, byte SIZEOF_MMWORD
- jb short .column_st7
- vmovq XMM_MMWORD [rdi], xmmA
- add rdi, byte SIZEOF_MMWORD
- sub rcx, byte SIZEOF_MMWORD
- vpsrldq xmmA, xmmA, SIZEOF_MMWORD
-.column_st7:
- ; Store the lower 4 bytes of xmmA to the output when it has enough
- ; space.
- cmp rcx, byte SIZEOF_DWORD
- jb short .column_st3
- vmovd XMM_DWORD [rdi], xmmA
- add rdi, byte SIZEOF_DWORD
- sub rcx, byte SIZEOF_DWORD
- vpsrldq xmmA, xmmA, SIZEOF_DWORD
-.column_st3:
- ; Store the lower 2 bytes of rax to the output when it has enough
- ; space.
- vmovd eax, xmmA
- cmp rcx, byte SIZEOF_WORD
- jb short .column_st1
- mov word [rdi], ax
- add rdi, byte SIZEOF_WORD
- sub rcx, byte SIZEOF_WORD
- shr rax, 16
-.column_st1:
- ; Store the lower 1 byte of rax to the output when it has enough
- ; space.
- test rcx, rcx
- jz short .nextrow
- mov byte [rdi], al
-
-%else ; RGB_PIXELSIZE == 4 ; -----------
-
-%ifdef RGBX_FILLER_0XFF
- vpcmpeqb ymm6, ymm6, ymm6 ; ymm6=XE=X(02468ACE********GIKMOQSU********)
- vpcmpeqb ymm7, ymm7, ymm7 ; ymm7=XO=X(13579BDF********HJLNPRTV********)
-%else
- vpxor ymm6, ymm6, ymm6 ; ymm6=XE=X(02468ACE********GIKMOQSU********)
- vpxor ymm7, ymm7, ymm7 ; ymm7=XO=X(13579BDF********HJLNPRTV********)
-%endif
- ; ymmA=(00 02 04 06 08 0A 0C 0E ** 0G 0I 0K 0M 0O 0Q 0S 0U **)
- ; ymmB=(01 03 05 07 09 0B 0D 0F ** 0H 0J 0L 0N 0P 0R 0T 0V **)
- ; ymmC=(10 12 14 16 18 1A 1C 1E ** 1G 1I 1K 1M 1O 1Q 1S 1U **)
- ; ymmD=(11 13 15 17 19 1B 1D 1F ** 1H 1J 1L 1N 1P 1R 1T 1V **)
- ; ymmE=(20 22 24 26 28 2A 2C 2E ** 2G 2I 2K 2M 2O 2Q 2S 2U **)
- ; ymmF=(21 23 25 27 29 2B 2D 2F ** 2H 2J 2L 2N 2P 2R 2T 2V **)
- ; ymmG=(30 32 34 36 38 3A 3C 3E ** 3G 3I 3K 3M 3O 3Q 3S 3U **)
- ; ymmH=(31 33 35 37 39 3B 3D 3F ** 3H 3J 3L 3N 3P 3R 3T 3V **)
-
- vpunpcklbw ymmA, ymmA, ymmC ; ymmA=(00 10 02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E
- ; 0G 1G 0I 1I 0K 1K 0M 1M 0O 1O 0Q 1Q 0S 1S 0U 1U)
- vpunpcklbw ymmE, ymmE, ymmG ; ymmE=(20 30 22 32 24 34 26 36 28 38 2A 3A 2C 3C 2E 3E
- ; 2G 3G 2I 3I 2K 3K 2M 3M 2O 3O 2Q 3Q 2S 3S 2U 3U)
- vpunpcklbw ymmB, ymmB, ymmD ; ymmB=(01 11 03 13 05 15 07 17 09 19 0B 1B 0D 1D 0F 1F
- ; 0H 1H 0J 1J 0L 1L 0N 1N 0P 1P 0R 1R 0T 1T 0V 1V)
- vpunpcklbw ymmF, ymmF, ymmH ; ymmF=(21 31 23 33 25 35 27 37 29 39 2B 3B 2D 3D 2F 3F
- ; 2H 3H 2J 3J 2L 3L 2N 3N 2P 3P 2R 3R 2T 3T 2V 3V)
-
- vpunpckhwd ymmC, ymmA, ymmE ; ymmC=(08 18 28 38 0A 1A 2A 3A 0C 1C 2C 3C 0E 1E 2E 3E
- ; 0O 1O 2O 3O 0Q 1Q 2Q 3Q 0S 1S 2S 3S 0U 1U 2U 3U)
- vpunpcklwd ymmA, ymmA, ymmE ; ymmA=(00 10 20 30 02 12 22 32 04 14 24 34 06 16 26 36
- ; 0G 1G 2G 3G 0I 1I 2I 3I 0K 1K 2K 3K 0M 1M 2M 3M)
- vpunpckhwd ymmG, ymmB, ymmF ; ymmG=(09 19 29 39 0B 1B 2B 3B 0D 1D 2D 3D 0F 1F 2F 3F
- ; 0P 1P 2P 3P 0R 1R 2R 3R 0T 1T 2T 3T 0V 1V 2V 3V)
- vpunpcklwd ymmB, ymmB, ymmF ; ymmB=(01 11 21 31 03 13 23 33 05 15 25 35 07 17 27 37
- ; 0H 1H 2H 3H 0J 1J 2J 3J 0L 1L 2L 3L 0N 1N 2N 3N)
-
- vpunpckhdq ymmE, ymmA, ymmB ; ymmE=(04 14 24 34 05 15 25 35 06 16 26 36 07 17 27 37
- ; 0K 1K 2K 3K 0L 1L 2L 3L 0M 1M 2M 3M 0N 1N 2N 3N)
- vpunpckldq ymmB, ymmA, ymmB ; ymmB=(00 10 20 30 01 11 21 31 02 12 22 32 03 13 23 33
- ; 0G 1G 2G 3G 0H 1H 2H 3H 0I 1I 2I 3I 0J 1J 2J 3J)
- vpunpckhdq ymmF, ymmC, ymmG ; ymmF=(0C 1C 2C 3C 0D 1D 2D 3D 0E 1E 2E 3E 0F 1F 2F 3F
- ; 0S 1S 2S 3S 0T 1T 2T 3T 0U 1U 2U 3U 0V 1V 2V 3V)
- vpunpckldq ymmG, ymmC, ymmG ; ymmG=(08 18 28 38 09 19 29 39 0A 1A 2A 3A 0B 1B 2B 3B
- ; 0O 1O 2O 3O 0P 1P 2P 3P 0Q 1Q 2Q 3Q 0R 1R 2R 3R)
-
- vperm2i128 ymmA, ymmB, ymmE, 0x20 ; ymmA=(00 10 20 30 01 11 21 31 02 12 22 32 03 13 23 33
- ; 04 14 24 34 05 15 25 35 06 16 26 36 07 17 27 37)
- vperm2i128 ymmD, ymmG, ymmF, 0x20 ; ymmD=(08 18 28 38 09 19 29 39 0A 1A 2A 3A 0B 1B 2B 3B
- ; 0C 1C 2C 3C 0D 1D 2D 3D 0E 1E 2E 3E 0F 1F 2F 3F)
- vperm2i128 ymmC, ymmB, ymmE, 0x31 ; ymmC=(0G 1G 2G 3G 0H 1H 2H 3H 0I 1I 2I 3I 0J 1J 2J 3J
- ; 0K 1K 2K 3K 0L 1L 2L 3L 0M 1M 2M 3M 0N 1N 2N 3N)
- vperm2i128 ymmH, ymmG, ymmF, 0x31 ; ymmH=(0O 1O 2O 3O 0P 1P 2P 3P 0Q 1Q 2Q 3Q 0R 1R 2R 3R
- ; 0S 1S 2S 3S 0T 1T 2T 3T 0U 1U 2U 3U 0V 1V 2V 3V)
-
- cmp rcx, byte SIZEOF_YMMWORD
- jb short .column_st64
-
- test rdi, SIZEOF_YMMWORD-1
- jnz short .out1
- ; --(aligned)-------------------
- vmovntdq YMMWORD [rdi+0*SIZEOF_YMMWORD], ymmA
- vmovntdq YMMWORD [rdi+1*SIZEOF_YMMWORD], ymmD
- vmovntdq YMMWORD [rdi+2*SIZEOF_YMMWORD], ymmC
- vmovntdq YMMWORD [rdi+3*SIZEOF_YMMWORD], ymmH
- jmp short .out0
-.out1: ; --(unaligned)-----------------
- vmovdqu YMMWORD [rdi+0*SIZEOF_YMMWORD], ymmA
- vmovdqu YMMWORD [rdi+1*SIZEOF_YMMWORD], ymmD
- vmovdqu YMMWORD [rdi+2*SIZEOF_YMMWORD], ymmC
- vmovdqu YMMWORD [rdi+3*SIZEOF_YMMWORD], ymmH
-.out0:
- add rdi, RGB_PIXELSIZE*SIZEOF_YMMWORD ; outptr
- sub rcx, byte SIZEOF_YMMWORD
- jz near .nextrow
-
- add rsi, byte SIZEOF_YMMWORD ; inptr0
- add rbx, byte SIZEOF_YMMWORD ; inptr1
- add rdx, byte SIZEOF_YMMWORD ; inptr2
- jmp near .columnloop
-
-.column_st64:
- cmp rcx, byte SIZEOF_YMMWORD/2
- jb short .column_st32
- vmovdqu YMMWORD [rdi+0*SIZEOF_YMMWORD], ymmA
- vmovdqu YMMWORD [rdi+1*SIZEOF_YMMWORD], ymmD
- add rdi, byte 2*SIZEOF_YMMWORD ; outptr
- vmovdqa ymmA, ymmC
- vmovdqa ymmD, ymmH
- sub rcx, byte SIZEOF_YMMWORD/2
-.column_st32:
- cmp rcx, byte SIZEOF_YMMWORD/4
- jb short .column_st16
- vmovdqu YMMWORD [rdi+0*SIZEOF_YMMWORD], ymmA
- add rdi, byte SIZEOF_YMMWORD ; outptr
- vmovdqa ymmA, ymmD
- sub rcx, byte SIZEOF_YMMWORD/4
-.column_st16:
- cmp rcx, byte SIZEOF_YMMWORD/8
- jb short .column_st15
- vmovdqu XMMWORD [rdi+0*SIZEOF_XMMWORD], xmmA
- vperm2i128 ymmA, ymmA, ymmA, 1
- add rdi, byte SIZEOF_XMMWORD ; outptr
- sub rcx, byte SIZEOF_YMMWORD/8
-.column_st15:
- ; Store two pixels (8 bytes) of ymmA to the output when it has enough
- ; space.
- cmp rcx, byte SIZEOF_YMMWORD/16
- jb short .column_st7
- vmovq MMWORD [rdi], xmmA
- add rdi, byte SIZEOF_YMMWORD/16*4
- sub rcx, byte SIZEOF_YMMWORD/16
- vpsrldq xmmA, SIZEOF_YMMWORD/16*4
-.column_st7:
- ; Store one pixel (4 bytes) of ymmA to the output when it has enough
- ; space.
- test rcx, rcx
- jz short .nextrow
- vmovd XMM_DWORD [rdi], xmmA
-
-%endif ; RGB_PIXELSIZE ; ---------------
-
-.nextrow:
- pop rcx
- pop rsi
- pop rbx
- pop rdx
- pop rdi
- pop rax
-
- add rsi, byte SIZEOF_JSAMPROW
- add rbx, byte SIZEOF_JSAMPROW
- add rdx, byte SIZEOF_JSAMPROW
- add rdi, byte SIZEOF_JSAMPROW ; output_buf
- dec rax ; num_rows
- jg near .rowloop
-
- sfence ; flush the write buffer
-
-.return:
- pop rbx
- vzeroupper
- uncollect_args 5
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
- pop rbp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jdcolext-sse2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jdcolext-sse2.asm
deleted file mode 100644
index e07c8d7518..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jdcolext-sse2.asm
+++ /dev/null
@@ -1,439 +0,0 @@
-;
-; jdcolext.asm - colorspace conversion (64-bit SSE2)
-;
-; Copyright 2009, 2012 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, 2012, 2016, D. R. Commander.
-; Copyright (C) 2018, Matthias Räncker.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jcolsamp.inc"
-
-; --------------------------------------------------------------------------
-;
-; Convert some rows of samples to the output colorspace.
-;
-; GLOBAL(void)
-; jsimd_ycc_rgb_convert_sse2(JDIMENSION out_width, JSAMPIMAGE input_buf,
-; JDIMENSION input_row, JSAMPARRAY output_buf,
-; int num_rows)
-;
-
-; r10d = JDIMENSION out_width
-; r11 = JSAMPIMAGE input_buf
-; r12d = JDIMENSION input_row
-; r13 = JSAMPARRAY output_buf
-; r14d = int num_rows
-
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
-%define WK_NUM 2
-
- align 32
- GLOBAL_FUNCTION(jsimd_ycc_rgb_convert_sse2)
-
-EXTN(jsimd_ycc_rgb_convert_sse2):
- push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
- and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
- collect_args 5
- push rbx
-
- mov ecx, r10d ; num_cols
- test rcx, rcx
- jz near .return
-
- push rcx
-
- mov rdi, r11
- mov ecx, r12d
- mov rsip, JSAMPARRAY [rdi+0*SIZEOF_JSAMPARRAY]
- mov rbxp, JSAMPARRAY [rdi+1*SIZEOF_JSAMPARRAY]
- mov rdxp, JSAMPARRAY [rdi+2*SIZEOF_JSAMPARRAY]
- lea rsi, [rsi+rcx*SIZEOF_JSAMPROW]
- lea rbx, [rbx+rcx*SIZEOF_JSAMPROW]
- lea rdx, [rdx+rcx*SIZEOF_JSAMPROW]
-
- pop rcx
-
- mov rdi, r13
- mov eax, r14d
- test rax, rax
- jle near .return
-.rowloop:
- push rax
- push rdi
- push rdx
- push rbx
- push rsi
- push rcx ; col
-
- mov rsip, JSAMPROW [rsi] ; inptr0
- mov rbxp, JSAMPROW [rbx] ; inptr1
- mov rdxp, JSAMPROW [rdx] ; inptr2
- mov rdip, JSAMPROW [rdi] ; outptr
-.columnloop:
-
- movdqa xmm5, XMMWORD [rbx] ; xmm5=Cb(0123456789ABCDEF)
- movdqa xmm1, XMMWORD [rdx] ; xmm1=Cr(0123456789ABCDEF)
-
- pcmpeqw xmm4, xmm4
- pcmpeqw xmm7, xmm7
- psrlw xmm4, BYTE_BIT
- psllw xmm7, 7 ; xmm7={0xFF80 0xFF80 0xFF80 0xFF80 ..}
- movdqa xmm0, xmm4 ; xmm0=xmm4={0xFF 0x00 0xFF 0x00 ..}
-
- pand xmm4, xmm5 ; xmm4=Cb(02468ACE)=CbE
- psrlw xmm5, BYTE_BIT ; xmm5=Cb(13579BDF)=CbO
- pand xmm0, xmm1 ; xmm0=Cr(02468ACE)=CrE
- psrlw xmm1, BYTE_BIT ; xmm1=Cr(13579BDF)=CrO
-
- paddw xmm4, xmm7
- paddw xmm5, xmm7
- paddw xmm0, xmm7
- paddw xmm1, xmm7
-
- ; (Original)
- ; R = Y + 1.40200 * Cr
- ; G = Y - 0.34414 * Cb - 0.71414 * Cr
- ; B = Y + 1.77200 * Cb
- ;
- ; (This implementation)
- ; R = Y + 0.40200 * Cr + Cr
- ; G = Y - 0.34414 * Cb + 0.28586 * Cr - Cr
- ; B = Y - 0.22800 * Cb + Cb + Cb
-
- movdqa xmm2, xmm4 ; xmm2=CbE
- movdqa xmm3, xmm5 ; xmm3=CbO
- paddw xmm4, xmm4 ; xmm4=2*CbE
- paddw xmm5, xmm5 ; xmm5=2*CbO
- movdqa xmm6, xmm0 ; xmm6=CrE
- movdqa xmm7, xmm1 ; xmm7=CrO
- paddw xmm0, xmm0 ; xmm0=2*CrE
- paddw xmm1, xmm1 ; xmm1=2*CrO
-
- pmulhw xmm4, [rel PW_MF0228] ; xmm4=(2*CbE * -FIX(0.22800))
- pmulhw xmm5, [rel PW_MF0228] ; xmm5=(2*CbO * -FIX(0.22800))
- pmulhw xmm0, [rel PW_F0402] ; xmm0=(2*CrE * FIX(0.40200))
- pmulhw xmm1, [rel PW_F0402] ; xmm1=(2*CrO * FIX(0.40200))
-
- paddw xmm4, [rel PW_ONE]
- paddw xmm5, [rel PW_ONE]
- psraw xmm4, 1 ; xmm4=(CbE * -FIX(0.22800))
- psraw xmm5, 1 ; xmm5=(CbO * -FIX(0.22800))
- paddw xmm0, [rel PW_ONE]
- paddw xmm1, [rel PW_ONE]
- psraw xmm0, 1 ; xmm0=(CrE * FIX(0.40200))
- psraw xmm1, 1 ; xmm1=(CrO * FIX(0.40200))
-
- paddw xmm4, xmm2
- paddw xmm5, xmm3
- paddw xmm4, xmm2 ; xmm4=(CbE * FIX(1.77200))=(B-Y)E
- paddw xmm5, xmm3 ; xmm5=(CbO * FIX(1.77200))=(B-Y)O
- paddw xmm0, xmm6 ; xmm0=(CrE * FIX(1.40200))=(R-Y)E
- paddw xmm1, xmm7 ; xmm1=(CrO * FIX(1.40200))=(R-Y)O
-
- movdqa XMMWORD [wk(0)], xmm4 ; wk(0)=(B-Y)E
- movdqa XMMWORD [wk(1)], xmm5 ; wk(1)=(B-Y)O
-
- movdqa xmm4, xmm2
- movdqa xmm5, xmm3
- punpcklwd xmm2, xmm6
- punpckhwd xmm4, xmm6
- pmaddwd xmm2, [rel PW_MF0344_F0285]
- pmaddwd xmm4, [rel PW_MF0344_F0285]
- punpcklwd xmm3, xmm7
- punpckhwd xmm5, xmm7
- pmaddwd xmm3, [rel PW_MF0344_F0285]
- pmaddwd xmm5, [rel PW_MF0344_F0285]
-
- paddd xmm2, [rel PD_ONEHALF]
- paddd xmm4, [rel PD_ONEHALF]
- psrad xmm2, SCALEBITS
- psrad xmm4, SCALEBITS
- paddd xmm3, [rel PD_ONEHALF]
- paddd xmm5, [rel PD_ONEHALF]
- psrad xmm3, SCALEBITS
- psrad xmm5, SCALEBITS
-
- packssdw xmm2, xmm4 ; xmm2=CbE*-FIX(0.344)+CrE*FIX(0.285)
- packssdw xmm3, xmm5 ; xmm3=CbO*-FIX(0.344)+CrO*FIX(0.285)
- psubw xmm2, xmm6 ; xmm2=CbE*-FIX(0.344)+CrE*-FIX(0.714)=(G-Y)E
- psubw xmm3, xmm7 ; xmm3=CbO*-FIX(0.344)+CrO*-FIX(0.714)=(G-Y)O
-
- movdqa xmm5, XMMWORD [rsi] ; xmm5=Y(0123456789ABCDEF)
-
- pcmpeqw xmm4, xmm4
- psrlw xmm4, BYTE_BIT ; xmm4={0xFF 0x00 0xFF 0x00 ..}
- pand xmm4, xmm5 ; xmm4=Y(02468ACE)=YE
- psrlw xmm5, BYTE_BIT ; xmm5=Y(13579BDF)=YO
-
- paddw xmm0, xmm4 ; xmm0=((R-Y)E+YE)=RE=R(02468ACE)
- paddw xmm1, xmm5 ; xmm1=((R-Y)O+YO)=RO=R(13579BDF)
- packuswb xmm0, xmm0 ; xmm0=R(02468ACE********)
- packuswb xmm1, xmm1 ; xmm1=R(13579BDF********)
-
- paddw xmm2, xmm4 ; xmm2=((G-Y)E+YE)=GE=G(02468ACE)
- paddw xmm3, xmm5 ; xmm3=((G-Y)O+YO)=GO=G(13579BDF)
- packuswb xmm2, xmm2 ; xmm2=G(02468ACE********)
- packuswb xmm3, xmm3 ; xmm3=G(13579BDF********)
-
- paddw xmm4, XMMWORD [wk(0)] ; xmm4=(YE+(B-Y)E)=BE=B(02468ACE)
- paddw xmm5, XMMWORD [wk(1)] ; xmm5=(YO+(B-Y)O)=BO=B(13579BDF)
- packuswb xmm4, xmm4 ; xmm4=B(02468ACE********)
- packuswb xmm5, xmm5 ; xmm5=B(13579BDF********)
-
-%if RGB_PIXELSIZE == 3 ; ---------------
-
- ; xmmA=(00 02 04 06 08 0A 0C 0E **), xmmB=(01 03 05 07 09 0B 0D 0F **)
- ; xmmC=(10 12 14 16 18 1A 1C 1E **), xmmD=(11 13 15 17 19 1B 1D 1F **)
- ; xmmE=(20 22 24 26 28 2A 2C 2E **), xmmF=(21 23 25 27 29 2B 2D 2F **)
- ; xmmG=(** ** ** ** ** ** ** ** **), xmmH=(** ** ** ** ** ** ** ** **)
-
- punpcklbw xmmA, xmmC ; xmmA=(00 10 02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E)
- punpcklbw xmmE, xmmB ; xmmE=(20 01 22 03 24 05 26 07 28 09 2A 0B 2C 0D 2E 0F)
- punpcklbw xmmD, xmmF ; xmmD=(11 21 13 23 15 25 17 27 19 29 1B 2B 1D 2D 1F 2F)
-
- movdqa xmmG, xmmA
- movdqa xmmH, xmmA
- punpcklwd xmmA, xmmE ; xmmA=(00 10 20 01 02 12 22 03 04 14 24 05 06 16 26 07)
- punpckhwd xmmG, xmmE ; xmmG=(08 18 28 09 0A 1A 2A 0B 0C 1C 2C 0D 0E 1E 2E 0F)
-
- psrldq xmmH, 2 ; xmmH=(02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E -- --)
- psrldq xmmE, 2 ; xmmE=(22 03 24 05 26 07 28 09 2A 0B 2C 0D 2E 0F -- --)
-
- movdqa xmmC, xmmD
- movdqa xmmB, xmmD
- punpcklwd xmmD, xmmH ; xmmD=(11 21 02 12 13 23 04 14 15 25 06 16 17 27 08 18)
- punpckhwd xmmC, xmmH ; xmmC=(19 29 0A 1A 1B 2B 0C 1C 1D 2D 0E 1E 1F 2F -- --)
-
- psrldq xmmB, 2 ; xmmB=(13 23 15 25 17 27 19 29 1B 2B 1D 2D 1F 2F -- --)
-
- movdqa xmmF, xmmE
- punpcklwd xmmE, xmmB ; xmmE=(22 03 13 23 24 05 15 25 26 07 17 27 28 09 19 29)
- punpckhwd xmmF, xmmB ; xmmF=(2A 0B 1B 2B 2C 0D 1D 2D 2E 0F 1F 2F -- -- -- --)
-
- pshufd xmmH, xmmA, 0x4E ; xmmH=(04 14 24 05 06 16 26 07 00 10 20 01 02 12 22 03)
- movdqa xmmB, xmmE
- punpckldq xmmA, xmmD ; xmmA=(00 10 20 01 11 21 02 12 02 12 22 03 13 23 04 14)
- punpckldq xmmE, xmmH ; xmmE=(22 03 13 23 04 14 24 05 24 05 15 25 06 16 26 07)
- punpckhdq xmmD, xmmB ; xmmD=(15 25 06 16 26 07 17 27 17 27 08 18 28 09 19 29)
-
- pshufd xmmH, xmmG, 0x4E ; xmmH=(0C 1C 2C 0D 0E 1E 2E 0F 08 18 28 09 0A 1A 2A 0B)
- movdqa xmmB, xmmF
- punpckldq xmmG, xmmC ; xmmG=(08 18 28 09 19 29 0A 1A 0A 1A 2A 0B 1B 2B 0C 1C)
- punpckldq xmmF, xmmH ; xmmF=(2A 0B 1B 2B 0C 1C 2C 0D 2C 0D 1D 2D 0E 1E 2E 0F)
- punpckhdq xmmC, xmmB ; xmmC=(1D 2D 0E 1E 2E 0F 1F 2F 1F 2F -- -- -- -- -- --)
-
- punpcklqdq xmmA, xmmE ; xmmA=(00 10 20 01 11 21 02 12 22 03 13 23 04 14 24 05)
- punpcklqdq xmmD, xmmG ; xmmD=(15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A)
- punpcklqdq xmmF, xmmC ; xmmF=(2A 0B 1B 2B 0C 1C 2C 0D 1D 2D 0E 1E 2E 0F 1F 2F)
-
- cmp rcx, byte SIZEOF_XMMWORD
- jb short .column_st32
-
- test rdi, SIZEOF_XMMWORD-1
- jnz short .out1
- ; --(aligned)-------------------
- movntdq XMMWORD [rdi+0*SIZEOF_XMMWORD], xmmA
- movntdq XMMWORD [rdi+1*SIZEOF_XMMWORD], xmmD
- movntdq XMMWORD [rdi+2*SIZEOF_XMMWORD], xmmF
- jmp short .out0
-.out1: ; --(unaligned)-----------------
- movdqu XMMWORD [rdi+0*SIZEOF_XMMWORD], xmmA
- movdqu XMMWORD [rdi+1*SIZEOF_XMMWORD], xmmD
- movdqu XMMWORD [rdi+2*SIZEOF_XMMWORD], xmmF
-.out0:
- add rdi, byte RGB_PIXELSIZE*SIZEOF_XMMWORD ; outptr
- sub rcx, byte SIZEOF_XMMWORD
- jz near .nextrow
-
- add rsi, byte SIZEOF_XMMWORD ; inptr0
- add rbx, byte SIZEOF_XMMWORD ; inptr1
- add rdx, byte SIZEOF_XMMWORD ; inptr2
- jmp near .columnloop
-
-.column_st32:
- lea rcx, [rcx+rcx*2] ; imul ecx, RGB_PIXELSIZE
- cmp rcx, byte 2*SIZEOF_XMMWORD
- jb short .column_st16
- movdqu XMMWORD [rdi+0*SIZEOF_XMMWORD], xmmA
- movdqu XMMWORD [rdi+1*SIZEOF_XMMWORD], xmmD
- add rdi, byte 2*SIZEOF_XMMWORD ; outptr
- movdqa xmmA, xmmF
- sub rcx, byte 2*SIZEOF_XMMWORD
- jmp short .column_st15
-.column_st16:
- cmp rcx, byte SIZEOF_XMMWORD
- jb short .column_st15
- movdqu XMMWORD [rdi+0*SIZEOF_XMMWORD], xmmA
- add rdi, byte SIZEOF_XMMWORD ; outptr
- movdqa xmmA, xmmD
- sub rcx, byte SIZEOF_XMMWORD
-.column_st15:
- ; Store the lower 8 bytes of xmmA to the output when it has enough
- ; space.
- cmp rcx, byte SIZEOF_MMWORD
- jb short .column_st7
- movq XMM_MMWORD [rdi], xmmA
- add rdi, byte SIZEOF_MMWORD
- sub rcx, byte SIZEOF_MMWORD
- psrldq xmmA, SIZEOF_MMWORD
-.column_st7:
- ; Store the lower 4 bytes of xmmA to the output when it has enough
- ; space.
- cmp rcx, byte SIZEOF_DWORD
- jb short .column_st3
- movd XMM_DWORD [rdi], xmmA
- add rdi, byte SIZEOF_DWORD
- sub rcx, byte SIZEOF_DWORD
- psrldq xmmA, SIZEOF_DWORD
-.column_st3:
- ; Store the lower 2 bytes of rax to the output when it has enough
- ; space.
- movd eax, xmmA
- cmp rcx, byte SIZEOF_WORD
- jb short .column_st1
- mov word [rdi], ax
- add rdi, byte SIZEOF_WORD
- sub rcx, byte SIZEOF_WORD
- shr rax, 16
-.column_st1:
- ; Store the lower 1 byte of rax to the output when it has enough
- ; space.
- test rcx, rcx
- jz short .nextrow
- mov byte [rdi], al
-
-%else ; RGB_PIXELSIZE == 4 ; -----------
-
-%ifdef RGBX_FILLER_0XFF
- pcmpeqb xmm6, xmm6 ; xmm6=XE=X(02468ACE********)
- pcmpeqb xmm7, xmm7 ; xmm7=XO=X(13579BDF********)
-%else
- pxor xmm6, xmm6 ; xmm6=XE=X(02468ACE********)
- pxor xmm7, xmm7 ; xmm7=XO=X(13579BDF********)
-%endif
- ; xmmA=(00 02 04 06 08 0A 0C 0E **), xmmB=(01 03 05 07 09 0B 0D 0F **)
- ; xmmC=(10 12 14 16 18 1A 1C 1E **), xmmD=(11 13 15 17 19 1B 1D 1F **)
- ; xmmE=(20 22 24 26 28 2A 2C 2E **), xmmF=(21 23 25 27 29 2B 2D 2F **)
- ; xmmG=(30 32 34 36 38 3A 3C 3E **), xmmH=(31 33 35 37 39 3B 3D 3F **)
-
- punpcklbw xmmA, xmmC ; xmmA=(00 10 02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E)
- punpcklbw xmmE, xmmG ; xmmE=(20 30 22 32 24 34 26 36 28 38 2A 3A 2C 3C 2E 3E)
- punpcklbw xmmB, xmmD ; xmmB=(01 11 03 13 05 15 07 17 09 19 0B 1B 0D 1D 0F 1F)
- punpcklbw xmmF, xmmH ; xmmF=(21 31 23 33 25 35 27 37 29 39 2B 3B 2D 3D 2F 3F)
-
- movdqa xmmC, xmmA
- punpcklwd xmmA, xmmE ; xmmA=(00 10 20 30 02 12 22 32 04 14 24 34 06 16 26 36)
- punpckhwd xmmC, xmmE ; xmmC=(08 18 28 38 0A 1A 2A 3A 0C 1C 2C 3C 0E 1E 2E 3E)
- movdqa xmmG, xmmB
- punpcklwd xmmB, xmmF ; xmmB=(01 11 21 31 03 13 23 33 05 15 25 35 07 17 27 37)
- punpckhwd xmmG, xmmF ; xmmG=(09 19 29 39 0B 1B 2B 3B 0D 1D 2D 3D 0F 1F 2F 3F)
-
- movdqa xmmD, xmmA
- punpckldq xmmA, xmmB ; xmmA=(00 10 20 30 01 11 21 31 02 12 22 32 03 13 23 33)
- punpckhdq xmmD, xmmB ; xmmD=(04 14 24 34 05 15 25 35 06 16 26 36 07 17 27 37)
- movdqa xmmH, xmmC
- punpckldq xmmC, xmmG ; xmmC=(08 18 28 38 09 19 29 39 0A 1A 2A 3A 0B 1B 2B 3B)
- punpckhdq xmmH, xmmG ; xmmH=(0C 1C 2C 3C 0D 1D 2D 3D 0E 1E 2E 3E 0F 1F 2F 3F)
-
- cmp rcx, byte SIZEOF_XMMWORD
- jb short .column_st32
-
- test rdi, SIZEOF_XMMWORD-1
- jnz short .out1
- ; --(aligned)-------------------
- movntdq XMMWORD [rdi+0*SIZEOF_XMMWORD], xmmA
- movntdq XMMWORD [rdi+1*SIZEOF_XMMWORD], xmmD
- movntdq XMMWORD [rdi+2*SIZEOF_XMMWORD], xmmC
- movntdq XMMWORD [rdi+3*SIZEOF_XMMWORD], xmmH
- jmp short .out0
-.out1: ; --(unaligned)-----------------
- movdqu XMMWORD [rdi+0*SIZEOF_XMMWORD], xmmA
- movdqu XMMWORD [rdi+1*SIZEOF_XMMWORD], xmmD
- movdqu XMMWORD [rdi+2*SIZEOF_XMMWORD], xmmC
- movdqu XMMWORD [rdi+3*SIZEOF_XMMWORD], xmmH
-.out0:
- add rdi, byte RGB_PIXELSIZE*SIZEOF_XMMWORD ; outptr
- sub rcx, byte SIZEOF_XMMWORD
- jz near .nextrow
-
- add rsi, byte SIZEOF_XMMWORD ; inptr0
- add rbx, byte SIZEOF_XMMWORD ; inptr1
- add rdx, byte SIZEOF_XMMWORD ; inptr2
- jmp near .columnloop
-
-.column_st32:
- cmp rcx, byte SIZEOF_XMMWORD/2
- jb short .column_st16
- movdqu XMMWORD [rdi+0*SIZEOF_XMMWORD], xmmA
- movdqu XMMWORD [rdi+1*SIZEOF_XMMWORD], xmmD
- add rdi, byte 2*SIZEOF_XMMWORD ; outptr
- movdqa xmmA, xmmC
- movdqa xmmD, xmmH
- sub rcx, byte SIZEOF_XMMWORD/2
-.column_st16:
- cmp rcx, byte SIZEOF_XMMWORD/4
- jb short .column_st15
- movdqu XMMWORD [rdi+0*SIZEOF_XMMWORD], xmmA
- add rdi, byte SIZEOF_XMMWORD ; outptr
- movdqa xmmA, xmmD
- sub rcx, byte SIZEOF_XMMWORD/4
-.column_st15:
- ; Store two pixels (8 bytes) of xmmA to the output when it has enough
- ; space.
- cmp rcx, byte SIZEOF_XMMWORD/8
- jb short .column_st7
- movq MMWORD [rdi], xmmA
- add rdi, byte SIZEOF_XMMWORD/8*4
- sub rcx, byte SIZEOF_XMMWORD/8
- psrldq xmmA, SIZEOF_XMMWORD/8*4
-.column_st7:
- ; Store one pixel (4 bytes) of xmmA to the output when it has enough
- ; space.
- test rcx, rcx
- jz short .nextrow
- movd XMM_DWORD [rdi], xmmA
-
-%endif ; RGB_PIXELSIZE ; ---------------
-
-.nextrow:
- pop rcx
- pop rsi
- pop rbx
- pop rdx
- pop rdi
- pop rax
-
- add rsi, byte SIZEOF_JSAMPROW
- add rbx, byte SIZEOF_JSAMPROW
- add rdx, byte SIZEOF_JSAMPROW
- add rdi, byte SIZEOF_JSAMPROW ; output_buf
- dec rax ; num_rows
- jg near .rowloop
-
- sfence ; flush the write buffer
-
-.return:
- pop rbx
- uncollect_args 5
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
- pop rbp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jdcolor-avx2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jdcolor-avx2.asm
deleted file mode 100644
index 43de9db04d..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jdcolor-avx2.asm
+++ /dev/null
@@ -1,118 +0,0 @@
-;
-; jdcolor.asm - colorspace conversion (64-bit AVX2)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
-; Copyright (C) 2015, Intel Corporation.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jsimdext.inc"
-
-; --------------------------------------------------------------------------
-
-%define SCALEBITS 16
-
-F_0_344 equ 22554 ; FIX(0.34414)
-F_0_714 equ 46802 ; FIX(0.71414)
-F_1_402 equ 91881 ; FIX(1.40200)
-F_1_772 equ 116130 ; FIX(1.77200)
-F_0_402 equ (F_1_402 - 65536) ; FIX(1.40200) - FIX(1)
-F_0_285 equ ( 65536 - F_0_714) ; FIX(1) - FIX(0.71414)
-F_0_228 equ (131072 - F_1_772) ; FIX(2) - FIX(1.77200)
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_ycc_rgb_convert_avx2)
-
-EXTN(jconst_ycc_rgb_convert_avx2):
-
-PW_F0402 times 16 dw F_0_402
-PW_MF0228 times 16 dw -F_0_228
-PW_MF0344_F0285 times 8 dw -F_0_344, F_0_285
-PW_ONE times 16 dw 1
-PD_ONEHALF times 8 dd 1 << (SCALEBITS - 1)
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 64
-
-%include "jdcolext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_RGB_RED
-%define RGB_GREEN EXT_RGB_GREEN
-%define RGB_BLUE EXT_RGB_BLUE
-%define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
-%define jsimd_ycc_rgb_convert_avx2 jsimd_ycc_extrgb_convert_avx2
-%include "jdcolext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_RGBX_RED
-%define RGB_GREEN EXT_RGBX_GREEN
-%define RGB_BLUE EXT_RGBX_BLUE
-%define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
-%define jsimd_ycc_rgb_convert_avx2 jsimd_ycc_extrgbx_convert_avx2
-%include "jdcolext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_BGR_RED
-%define RGB_GREEN EXT_BGR_GREEN
-%define RGB_BLUE EXT_BGR_BLUE
-%define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
-%define jsimd_ycc_rgb_convert_avx2 jsimd_ycc_extbgr_convert_avx2
-%include "jdcolext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_BGRX_RED
-%define RGB_GREEN EXT_BGRX_GREEN
-%define RGB_BLUE EXT_BGRX_BLUE
-%define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
-%define jsimd_ycc_rgb_convert_avx2 jsimd_ycc_extbgrx_convert_avx2
-%include "jdcolext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_XBGR_RED
-%define RGB_GREEN EXT_XBGR_GREEN
-%define RGB_BLUE EXT_XBGR_BLUE
-%define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
-%define jsimd_ycc_rgb_convert_avx2 jsimd_ycc_extxbgr_convert_avx2
-%include "jdcolext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_XRGB_RED
-%define RGB_GREEN EXT_XRGB_GREEN
-%define RGB_BLUE EXT_XRGB_BLUE
-%define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
-%define jsimd_ycc_rgb_convert_avx2 jsimd_ycc_extxrgb_convert_avx2
-%include "jdcolext-avx2.asm"
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jdcolor-sse2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jdcolor-sse2.asm
deleted file mode 100644
index b3f1fec07e..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jdcolor-sse2.asm
+++ /dev/null
@@ -1,117 +0,0 @@
-;
-; jdcolor.asm - colorspace conversion (64-bit SSE2)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jsimdext.inc"
-
-; --------------------------------------------------------------------------
-
-%define SCALEBITS 16
-
-F_0_344 equ 22554 ; FIX(0.34414)
-F_0_714 equ 46802 ; FIX(0.71414)
-F_1_402 equ 91881 ; FIX(1.40200)
-F_1_772 equ 116130 ; FIX(1.77200)
-F_0_402 equ (F_1_402 - 65536) ; FIX(1.40200) - FIX(1)
-F_0_285 equ ( 65536 - F_0_714) ; FIX(1) - FIX(0.71414)
-F_0_228 equ (131072 - F_1_772) ; FIX(2) - FIX(1.77200)
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_ycc_rgb_convert_sse2)
-
-EXTN(jconst_ycc_rgb_convert_sse2):
-
-PW_F0402 times 8 dw F_0_402
-PW_MF0228 times 8 dw -F_0_228
-PW_MF0344_F0285 times 4 dw -F_0_344, F_0_285
-PW_ONE times 8 dw 1
-PD_ONEHALF times 4 dd 1 << (SCALEBITS - 1)
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 64
-
-%include "jdcolext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_RGB_RED
-%define RGB_GREEN EXT_RGB_GREEN
-%define RGB_BLUE EXT_RGB_BLUE
-%define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
-%define jsimd_ycc_rgb_convert_sse2 jsimd_ycc_extrgb_convert_sse2
-%include "jdcolext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_RGBX_RED
-%define RGB_GREEN EXT_RGBX_GREEN
-%define RGB_BLUE EXT_RGBX_BLUE
-%define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
-%define jsimd_ycc_rgb_convert_sse2 jsimd_ycc_extrgbx_convert_sse2
-%include "jdcolext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_BGR_RED
-%define RGB_GREEN EXT_BGR_GREEN
-%define RGB_BLUE EXT_BGR_BLUE
-%define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
-%define jsimd_ycc_rgb_convert_sse2 jsimd_ycc_extbgr_convert_sse2
-%include "jdcolext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_BGRX_RED
-%define RGB_GREEN EXT_BGRX_GREEN
-%define RGB_BLUE EXT_BGRX_BLUE
-%define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
-%define jsimd_ycc_rgb_convert_sse2 jsimd_ycc_extbgrx_convert_sse2
-%include "jdcolext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_XBGR_RED
-%define RGB_GREEN EXT_XBGR_GREEN
-%define RGB_BLUE EXT_XBGR_BLUE
-%define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
-%define jsimd_ycc_rgb_convert_sse2 jsimd_ycc_extxbgr_convert_sse2
-%include "jdcolext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_XRGB_RED
-%define RGB_GREEN EXT_XRGB_GREEN
-%define RGB_BLUE EXT_XRGB_BLUE
-%define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
-%define jsimd_ycc_rgb_convert_sse2 jsimd_ycc_extxrgb_convert_sse2
-%include "jdcolext-sse2.asm"
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jdmerge-avx2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jdmerge-avx2.asm
deleted file mode 100644
index 9515a17013..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jdmerge-avx2.asm
+++ /dev/null
@@ -1,136 +0,0 @@
-;
-; jdmerge.asm - merged upsampling/color conversion (64-bit AVX2)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
-; Copyright (C) 2015, Intel Corporation.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jsimdext.inc"
-
-; --------------------------------------------------------------------------
-
-%define SCALEBITS 16
-
-F_0_344 equ 22554 ; FIX(0.34414)
-F_0_714 equ 46802 ; FIX(0.71414)
-F_1_402 equ 91881 ; FIX(1.40200)
-F_1_772 equ 116130 ; FIX(1.77200)
-F_0_402 equ (F_1_402 - 65536) ; FIX(1.40200) - FIX(1)
-F_0_285 equ ( 65536 - F_0_714) ; FIX(1) - FIX(0.71414)
-F_0_228 equ (131072 - F_1_772) ; FIX(2) - FIX(1.77200)
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_merged_upsample_avx2)
-
-EXTN(jconst_merged_upsample_avx2):
-
-PW_F0402 times 16 dw F_0_402
-PW_MF0228 times 16 dw -F_0_228
-PW_MF0344_F0285 times 8 dw -F_0_344, F_0_285
-PW_ONE times 16 dw 1
-PD_ONEHALF times 8 dd 1 << (SCALEBITS - 1)
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 64
-
-%include "jdmrgext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_RGB_RED
-%define RGB_GREEN EXT_RGB_GREEN
-%define RGB_BLUE EXT_RGB_BLUE
-%define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
-%define jsimd_h2v1_merged_upsample_avx2 \
- jsimd_h2v1_extrgb_merged_upsample_avx2
-%define jsimd_h2v2_merged_upsample_avx2 \
- jsimd_h2v2_extrgb_merged_upsample_avx2
-%include "jdmrgext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_RGBX_RED
-%define RGB_GREEN EXT_RGBX_GREEN
-%define RGB_BLUE EXT_RGBX_BLUE
-%define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
-%define jsimd_h2v1_merged_upsample_avx2 \
- jsimd_h2v1_extrgbx_merged_upsample_avx2
-%define jsimd_h2v2_merged_upsample_avx2 \
- jsimd_h2v2_extrgbx_merged_upsample_avx2
-%include "jdmrgext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_BGR_RED
-%define RGB_GREEN EXT_BGR_GREEN
-%define RGB_BLUE EXT_BGR_BLUE
-%define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
-%define jsimd_h2v1_merged_upsample_avx2 \
- jsimd_h2v1_extbgr_merged_upsample_avx2
-%define jsimd_h2v2_merged_upsample_avx2 \
- jsimd_h2v2_extbgr_merged_upsample_avx2
-%include "jdmrgext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_BGRX_RED
-%define RGB_GREEN EXT_BGRX_GREEN
-%define RGB_BLUE EXT_BGRX_BLUE
-%define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
-%define jsimd_h2v1_merged_upsample_avx2 \
- jsimd_h2v1_extbgrx_merged_upsample_avx2
-%define jsimd_h2v2_merged_upsample_avx2 \
- jsimd_h2v2_extbgrx_merged_upsample_avx2
-%include "jdmrgext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_XBGR_RED
-%define RGB_GREEN EXT_XBGR_GREEN
-%define RGB_BLUE EXT_XBGR_BLUE
-%define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
-%define jsimd_h2v1_merged_upsample_avx2 \
- jsimd_h2v1_extxbgr_merged_upsample_avx2
-%define jsimd_h2v2_merged_upsample_avx2 \
- jsimd_h2v2_extxbgr_merged_upsample_avx2
-%include "jdmrgext-avx2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_XRGB_RED
-%define RGB_GREEN EXT_XRGB_GREEN
-%define RGB_BLUE EXT_XRGB_BLUE
-%define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
-%define jsimd_h2v1_merged_upsample_avx2 \
- jsimd_h2v1_extxrgb_merged_upsample_avx2
-%define jsimd_h2v2_merged_upsample_avx2 \
- jsimd_h2v2_extxrgb_merged_upsample_avx2
-%include "jdmrgext-avx2.asm"
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jdmerge-sse2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jdmerge-sse2.asm
deleted file mode 100644
index aedccc20f6..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jdmerge-sse2.asm
+++ /dev/null
@@ -1,135 +0,0 @@
-;
-; jdmerge.asm - merged upsampling/color conversion (64-bit SSE2)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jsimdext.inc"
-
-; --------------------------------------------------------------------------
-
-%define SCALEBITS 16
-
-F_0_344 equ 22554 ; FIX(0.34414)
-F_0_714 equ 46802 ; FIX(0.71414)
-F_1_402 equ 91881 ; FIX(1.40200)
-F_1_772 equ 116130 ; FIX(1.77200)
-F_0_402 equ (F_1_402 - 65536) ; FIX(1.40200) - FIX(1)
-F_0_285 equ ( 65536 - F_0_714) ; FIX(1) - FIX(0.71414)
-F_0_228 equ (131072 - F_1_772) ; FIX(2) - FIX(1.77200)
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_merged_upsample_sse2)
-
-EXTN(jconst_merged_upsample_sse2):
-
-PW_F0402 times 8 dw F_0_402
-PW_MF0228 times 8 dw -F_0_228
-PW_MF0344_F0285 times 4 dw -F_0_344, F_0_285
-PW_ONE times 8 dw 1
-PD_ONEHALF times 4 dd 1 << (SCALEBITS - 1)
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 64
-
-%include "jdmrgext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_RGB_RED
-%define RGB_GREEN EXT_RGB_GREEN
-%define RGB_BLUE EXT_RGB_BLUE
-%define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
-%define jsimd_h2v1_merged_upsample_sse2 \
- jsimd_h2v1_extrgb_merged_upsample_sse2
-%define jsimd_h2v2_merged_upsample_sse2 \
- jsimd_h2v2_extrgb_merged_upsample_sse2
-%include "jdmrgext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_RGBX_RED
-%define RGB_GREEN EXT_RGBX_GREEN
-%define RGB_BLUE EXT_RGBX_BLUE
-%define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
-%define jsimd_h2v1_merged_upsample_sse2 \
- jsimd_h2v1_extrgbx_merged_upsample_sse2
-%define jsimd_h2v2_merged_upsample_sse2 \
- jsimd_h2v2_extrgbx_merged_upsample_sse2
-%include "jdmrgext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_BGR_RED
-%define RGB_GREEN EXT_BGR_GREEN
-%define RGB_BLUE EXT_BGR_BLUE
-%define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
-%define jsimd_h2v1_merged_upsample_sse2 \
- jsimd_h2v1_extbgr_merged_upsample_sse2
-%define jsimd_h2v2_merged_upsample_sse2 \
- jsimd_h2v2_extbgr_merged_upsample_sse2
-%include "jdmrgext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_BGRX_RED
-%define RGB_GREEN EXT_BGRX_GREEN
-%define RGB_BLUE EXT_BGRX_BLUE
-%define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
-%define jsimd_h2v1_merged_upsample_sse2 \
- jsimd_h2v1_extbgrx_merged_upsample_sse2
-%define jsimd_h2v2_merged_upsample_sse2 \
- jsimd_h2v2_extbgrx_merged_upsample_sse2
-%include "jdmrgext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_XBGR_RED
-%define RGB_GREEN EXT_XBGR_GREEN
-%define RGB_BLUE EXT_XBGR_BLUE
-%define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
-%define jsimd_h2v1_merged_upsample_sse2 \
- jsimd_h2v1_extxbgr_merged_upsample_sse2
-%define jsimd_h2v2_merged_upsample_sse2 \
- jsimd_h2v2_extxbgr_merged_upsample_sse2
-%include "jdmrgext-sse2.asm"
-
-%undef RGB_RED
-%undef RGB_GREEN
-%undef RGB_BLUE
-%undef RGB_PIXELSIZE
-%define RGB_RED EXT_XRGB_RED
-%define RGB_GREEN EXT_XRGB_GREEN
-%define RGB_BLUE EXT_XRGB_BLUE
-%define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
-%define jsimd_h2v1_merged_upsample_sse2 \
- jsimd_h2v1_extxrgb_merged_upsample_sse2
-%define jsimd_h2v2_merged_upsample_sse2 \
- jsimd_h2v2_extxrgb_merged_upsample_sse2
-%include "jdmrgext-sse2.asm"
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jdmrgext-avx2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jdmrgext-avx2.asm
deleted file mode 100644
index 8b264b4f03..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jdmrgext-avx2.asm
+++ /dev/null
@@ -1,596 +0,0 @@
-;
-; jdmrgext.asm - merged upsampling/color conversion (64-bit AVX2)
-;
-; Copyright 2009, 2012 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, 2012, 2016, D. R. Commander.
-; Copyright (C) 2015, Intel Corporation.
-; Copyright (C) 2018, Matthias Räncker.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jcolsamp.inc"
-
-; --------------------------------------------------------------------------
-;
-; Upsample and color convert for the case of 2:1 horizontal and 1:1 vertical.
-;
-; GLOBAL(void)
-; jsimd_h2v1_merged_upsample_avx2(JDIMENSION output_width,
-; JSAMPIMAGE input_buf,
-; JDIMENSION in_row_group_ctr,
-; JSAMPARRAY output_buf);
-;
-
-; r10d = JDIMENSION output_width
-; r11 = JSAMPIMAGE input_buf
-; r12d = JDIMENSION in_row_group_ctr
-; r13 = JSAMPARRAY output_buf
-
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_YMMWORD ; ymmword wk[WK_NUM]
-%define WK_NUM 3
-
- align 32
- GLOBAL_FUNCTION(jsimd_h2v1_merged_upsample_avx2)
-
-EXTN(jsimd_h2v1_merged_upsample_avx2):
- push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
- and rsp, byte (-SIZEOF_YMMWORD) ; align to 256 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
- collect_args 4
- push rbx
-
- mov ecx, r10d ; col
- test rcx, rcx
- jz near .return
-
- push rcx
-
- mov rdi, r11
- mov ecx, r12d
- mov rsip, JSAMPARRAY [rdi+0*SIZEOF_JSAMPARRAY]
- mov rbxp, JSAMPARRAY [rdi+1*SIZEOF_JSAMPARRAY]
- mov rdxp, JSAMPARRAY [rdi+2*SIZEOF_JSAMPARRAY]
- mov rdi, r13
- mov rsip, JSAMPROW [rsi+rcx*SIZEOF_JSAMPROW] ; inptr0
- mov rbxp, JSAMPROW [rbx+rcx*SIZEOF_JSAMPROW] ; inptr1
- mov rdxp, JSAMPROW [rdx+rcx*SIZEOF_JSAMPROW] ; inptr2
- mov rdip, JSAMPROW [rdi] ; outptr
-
- pop rcx ; col
-
-.columnloop:
-
- vmovdqu ymm6, YMMWORD [rbx] ; ymm6=Cb(0123456789ABCDEFGHIJKLMNOPQRSTUV)
- vmovdqu ymm7, YMMWORD [rdx] ; ymm7=Cr(0123456789ABCDEFGHIJKLMNOPQRSTUV)
-
- vpxor ymm1, ymm1, ymm1 ; ymm1=(all 0's)
- vpcmpeqw ymm3, ymm3, ymm3
- vpsllw ymm3, ymm3, 7 ; ymm3={0xFF80 0xFF80 0xFF80 0xFF80 ..}
-
- vpermq ymm6, ymm6, 0xd8 ; ymm6=Cb(01234567GHIJKLMN89ABCDEFOPQRSTUV)
- vpermq ymm7, ymm7, 0xd8 ; ymm7=Cr(01234567GHIJKLMN89ABCDEFOPQRSTUV)
- vpunpcklbw ymm4, ymm6, ymm1 ; ymm4=Cb(0123456789ABCDEF)=CbL
- vpunpckhbw ymm6, ymm6, ymm1 ; ymm6=Cb(GHIJKLMNOPQRSTUV)=CbH
- vpunpcklbw ymm0, ymm7, ymm1 ; ymm0=Cr(0123456789ABCDEF)=CrL
- vpunpckhbw ymm7, ymm7, ymm1 ; ymm7=Cr(GHIJKLMNOPQRSTUV)=CrH
-
- vpaddw ymm5, ymm6, ymm3
- vpaddw ymm2, ymm4, ymm3
- vpaddw ymm1, ymm7, ymm3
- vpaddw ymm3, ymm0, ymm3
-
- ; (Original)
- ; R = Y + 1.40200 * Cr
- ; G = Y - 0.34414 * Cb - 0.71414 * Cr
- ; B = Y + 1.77200 * Cb
- ;
- ; (This implementation)
- ; R = Y + 0.40200 * Cr + Cr
- ; G = Y - 0.34414 * Cb + 0.28586 * Cr - Cr
- ; B = Y - 0.22800 * Cb + Cb + Cb
-
- vpaddw ymm6, ymm5, ymm5 ; ymm6=2*CbH
- vpaddw ymm4, ymm2, ymm2 ; ymm4=2*CbL
- vpaddw ymm7, ymm1, ymm1 ; ymm7=2*CrH
- vpaddw ymm0, ymm3, ymm3 ; ymm0=2*CrL
-
- vpmulhw ymm6, ymm6, [rel PW_MF0228] ; ymm6=(2*CbH * -FIX(0.22800))
- vpmulhw ymm4, ymm4, [rel PW_MF0228] ; ymm4=(2*CbL * -FIX(0.22800))
- vpmulhw ymm7, ymm7, [rel PW_F0402] ; ymm7=(2*CrH * FIX(0.40200))
- vpmulhw ymm0, ymm0, [rel PW_F0402] ; ymm0=(2*CrL * FIX(0.40200))
-
- vpaddw ymm6, ymm6, [rel PW_ONE]
- vpaddw ymm4, ymm4, [rel PW_ONE]
- vpsraw ymm6, ymm6, 1 ; ymm6=(CbH * -FIX(0.22800))
- vpsraw ymm4, ymm4, 1 ; ymm4=(CbL * -FIX(0.22800))
- vpaddw ymm7, ymm7, [rel PW_ONE]
- vpaddw ymm0, ymm0, [rel PW_ONE]
- vpsraw ymm7, ymm7, 1 ; ymm7=(CrH * FIX(0.40200))
- vpsraw ymm0, ymm0, 1 ; ymm0=(CrL * FIX(0.40200))
-
- vpaddw ymm6, ymm6, ymm5
- vpaddw ymm4, ymm4, ymm2
- vpaddw ymm6, ymm6, ymm5 ; ymm6=(CbH * FIX(1.77200))=(B-Y)H
- vpaddw ymm4, ymm4, ymm2 ; ymm4=(CbL * FIX(1.77200))=(B-Y)L
- vpaddw ymm7, ymm7, ymm1 ; ymm7=(CrH * FIX(1.40200))=(R-Y)H
- vpaddw ymm0, ymm0, ymm3 ; ymm0=(CrL * FIX(1.40200))=(R-Y)L
-
- vmovdqa YMMWORD [wk(0)], ymm6 ; wk(0)=(B-Y)H
- vmovdqa YMMWORD [wk(1)], ymm7 ; wk(1)=(R-Y)H
-
- vpunpckhwd ymm6, ymm5, ymm1
- vpunpcklwd ymm5, ymm5, ymm1
- vpmaddwd ymm5, ymm5, [rel PW_MF0344_F0285]
- vpmaddwd ymm6, ymm6, [rel PW_MF0344_F0285]
- vpunpckhwd ymm7, ymm2, ymm3
- vpunpcklwd ymm2, ymm2, ymm3
- vpmaddwd ymm2, ymm2, [rel PW_MF0344_F0285]
- vpmaddwd ymm7, ymm7, [rel PW_MF0344_F0285]
-
- vpaddd ymm5, ymm5, [rel PD_ONEHALF]
- vpaddd ymm6, ymm6, [rel PD_ONEHALF]
- vpsrad ymm5, ymm5, SCALEBITS
- vpsrad ymm6, ymm6, SCALEBITS
- vpaddd ymm2, ymm2, [rel PD_ONEHALF]
- vpaddd ymm7, ymm7, [rel PD_ONEHALF]
- vpsrad ymm2, ymm2, SCALEBITS
- vpsrad ymm7, ymm7, SCALEBITS
-
- vpackssdw ymm5, ymm5, ymm6 ; ymm5=CbH*-FIX(0.344)+CrH*FIX(0.285)
- vpackssdw ymm2, ymm2, ymm7 ; ymm2=CbL*-FIX(0.344)+CrL*FIX(0.285)
- vpsubw ymm5, ymm5, ymm1 ; ymm5=CbH*-FIX(0.344)+CrH*-FIX(0.714)=(G-Y)H
- vpsubw ymm2, ymm2, ymm3 ; ymm2=CbL*-FIX(0.344)+CrL*-FIX(0.714)=(G-Y)L
-
- vmovdqa YMMWORD [wk(2)], ymm5 ; wk(2)=(G-Y)H
-
- mov al, 2 ; Yctr
- jmp short .Yloop_1st
-
-.Yloop_2nd:
- vmovdqa ymm0, YMMWORD [wk(1)] ; ymm0=(R-Y)H
- vmovdqa ymm2, YMMWORD [wk(2)] ; ymm2=(G-Y)H
- vmovdqa ymm4, YMMWORD [wk(0)] ; ymm4=(B-Y)H
-
-.Yloop_1st:
- vmovdqu ymm7, YMMWORD [rsi] ; ymm7=Y(0123456789ABCDEFGHIJKLMNOPQRSTUV)
-
- vpcmpeqw ymm6, ymm6, ymm6
- vpsrlw ymm6, ymm6, BYTE_BIT ; ymm6={0xFF 0x00 0xFF 0x00 ..}
- vpand ymm6, ymm6, ymm7 ; ymm6=Y(02468ACEGIKMOQSU)=YE
- vpsrlw ymm7, ymm7, BYTE_BIT ; ymm7=Y(13579BDFHJLNPRTV)=YO
-
- vmovdqa ymm1, ymm0 ; ymm1=ymm0=(R-Y)(L/H)
- vmovdqa ymm3, ymm2 ; ymm3=ymm2=(G-Y)(L/H)
- vmovdqa ymm5, ymm4 ; ymm5=ymm4=(B-Y)(L/H)
-
- vpaddw ymm0, ymm0, ymm6 ; ymm0=((R-Y)+YE)=RE=R(02468ACEGIKMOQSU)
- vpaddw ymm1, ymm1, ymm7 ; ymm1=((R-Y)+YO)=RO=R(13579BDFHJLNPRTV)
- vpackuswb ymm0, ymm0, ymm0 ; ymm0=R(02468ACE********GIKMOQSU********)
- vpackuswb ymm1, ymm1, ymm1 ; ymm1=R(13579BDF********HJLNPRTV********)
-
- vpaddw ymm2, ymm2, ymm6 ; ymm2=((G-Y)+YE)=GE=G(02468ACEGIKMOQSU)
- vpaddw ymm3, ymm3, ymm7 ; ymm3=((G-Y)+YO)=GO=G(13579BDFHJLNPRTV)
- vpackuswb ymm2, ymm2, ymm2 ; ymm2=G(02468ACE********GIKMOQSU********)
- vpackuswb ymm3, ymm3, ymm3 ; ymm3=G(13579BDF********HJLNPRTV********)
-
- vpaddw ymm4, ymm4, ymm6 ; ymm4=((B-Y)+YE)=BE=B(02468ACEGIKMOQSU)
- vpaddw ymm5, ymm5, ymm7 ; ymm5=((B-Y)+YO)=BO=B(13579BDFHJLNPRTV)
- vpackuswb ymm4, ymm4, ymm4 ; ymm4=B(02468ACE********GIKMOQSU********)
- vpackuswb ymm5, ymm5, ymm5 ; ymm5=B(13579BDF********HJLNPRTV********)
-
-%if RGB_PIXELSIZE == 3 ; ---------------
-
- ; ymmA=(00 02 04 06 08 0A 0C 0E ** 0G 0I 0K 0M 0O 0Q 0S 0U **)
- ; ymmB=(01 03 05 07 09 0B 0D 0F ** 0H 0J 0L 0N 0P 0R 0T 0V **)
- ; ymmC=(10 12 14 16 18 1A 1C 1E ** 1G 1I 1K 1M 1O 1Q 1S 1U **)
- ; ymmD=(11 13 15 17 19 1B 1D 1F ** 1H 1J 1L 1N 1P 1R 1T 1V **)
- ; ymmE=(20 22 24 26 28 2A 2C 2E ** 2G 2I 2K 2M 2O 2Q 2S 2U **)
- ; ymmF=(21 23 25 27 29 2B 2D 2F ** 2H 2J 2L 2N 2P 2R 2T 2V **)
- ; ymmG=(** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **)
- ; ymmH=(** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **)
-
- vpunpcklbw ymmA, ymmA, ymmC ; ymmA=(00 10 02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E
- ; 0G 1G 0I 1I 0K 1K 0M 1M 0O 1O 0Q 1Q 0S 1S 0U 1U)
- vpunpcklbw ymmE, ymmE, ymmB ; ymmE=(20 01 22 03 24 05 26 07 28 09 2A 0B 2C 0D 2E 0F
- ; 2G 0H 2I 0J 2K 0L 2M 0N 2O 0P 2Q 0R 2S 0T 2U 0V)
- vpunpcklbw ymmD, ymmD, ymmF ; ymmD=(11 21 13 23 15 25 17 27 19 29 1B 2B 1D 2D 1F 2F
- ; 1H 2H 1J 2J 1L 2L 1N 2N 1P 2P 1R 2R 1T 2T 1V 2V)
-
- vpsrldq ymmH, ymmA, 2 ; ymmH=(02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E 0G 1G
- ; 0I 1I 0K 1K 0M 1M 0O 1O 0Q 1Q 0S 1S 0U 1U -- --)
- vpunpckhwd ymmG, ymmA, ymmE ; ymmG=(08 18 28 09 0A 1A 2A 0B 0C 1C 2C 0D 0E 1E 2E 0F
- ; 0O 1O 2O 0P 0Q 1Q 2Q 0R 0S 1S 2S 0T 0U 1U 2U 0V)
- vpunpcklwd ymmA, ymmA, ymmE ; ymmA=(00 10 20 01 02 12 22 03 04 14 24 05 06 16 26 07
- ; 0G 1G 2G 0H 0I 1I 2I 0J 0K 1K 2K 0L 0M 1M 2M 0N)
-
- vpsrldq ymmE, ymmE, 2 ; ymmE=(22 03 24 05 26 07 28 09 2A 0B 2C 0D 2E 0F 2G 0H
- ; 2I 0J 2K 0L 2M 0N 2O 0P 2Q 0R 2S 0T 2U 0V -- --)
-
- vpsrldq ymmB, ymmD, 2 ; ymmB=(13 23 15 25 17 27 19 29 1B 2B 1D 2D 1F 2F 1H 2H
- ; 1J 2J 1L 2L 1N 2N 1P 2P 1R 2R 1T 2T 1V 2V -- --)
- vpunpckhwd ymmC, ymmD, ymmH ; ymmC=(19 29 0A 1A 1B 2B 0C 1C 1D 2D 0E 1E 1F 2F 0G 1G
- ; 1P 2P 0Q 1Q 1R 2R 0S 1S 1T 2T 0U 1U 1V 2V -- --)
- vpunpcklwd ymmD, ymmD, ymmH ; ymmD=(11 21 02 12 13 23 04 14 15 25 06 16 17 27 08 18
- ; 1H 2H 0I 1I 1J 2J 0K 1K 1L 2L 0M 1M 1N 2N 0O 1O)
-
- vpunpckhwd ymmF, ymmE, ymmB ; ymmF=(2A 0B 1B 2B 2C 0D 1D 2D 2E 0F 1F 2F 2G 0H 1H 2H
- ; 2Q 0R 1R 2R 2S 0T 1T 2T 2U 0V 1V 2V -- -- -- --)
- vpunpcklwd ymmE, ymmE, ymmB ; ymmE=(22 03 13 23 24 05 15 25 26 07 17 27 28 09 19 29
- ; 2I 0J 1J 2J 2K 0L 1L 2L 2M 0N 1N 2N 2O 0P 1P 2P)
-
- vpshufd ymmH, ymmA, 0x4E ; ymmH=(04 14 24 05 06 16 26 07 00 10 20 01 02 12 22 03
- ; 0K 1K 2K 0L 0M 1M 2M 0N 0G 1G 2G 0H 0I 1I 2I 0J)
- vpunpckldq ymmA, ymmA, ymmD ; ymmA=(00 10 20 01 11 21 02 12 02 12 22 03 13 23 04 14
- ; 0G 1G 2G 0H 1H 2H 0I 1I 0I 1I 2I 0J 1J 2J 0K 1K)
- vpunpckhdq ymmD, ymmD, ymmE ; ymmD=(15 25 06 16 26 07 17 27 17 27 08 18 28 09 19 29
- ; 1L 2L 0M 1M 2M 0N 1N 2N 1N 2N 0O 1O 2O 0P 1P 2P)
- vpunpckldq ymmE, ymmE, ymmH ; ymmE=(22 03 13 23 04 14 24 05 24 05 15 25 06 16 26 07
- ; 2I 0J 1J 2J 0K 1K 2K 0L 2K 0L 1L 2L 0M 1M 2M 0N)
-
- vpshufd ymmH, ymmG, 0x4E ; ymmH=(0C 1C 2C 0D 0E 1E 2E 0F 08 18 28 09 0A 1A 2A 0B
- ; 0S 1S 2S 0T 0U 1U 2U 0V 0O 1O 2O 0P 0Q 1Q 2Q 0R)
- vpunpckldq ymmG, ymmG, ymmC ; ymmG=(08 18 28 09 19 29 0A 1A 0A 1A 2A 0B 1B 2B 0C 1C
- ; 0O 1O 2O 0P 1P 2P 0Q 1Q 0Q 1Q 2Q 0R 1R 2R 0S 1S)
- vpunpckhdq ymmC, ymmC, ymmF ; ymmC=(1D 2D 0E 1E 2E 0F 1F 2F 1F 2F 0G 1G 2G 0H 1H 2H
- ; 1T 2T 0U 1U 2U 0V 1V 2V 1V 2V -- -- -- -- -- --)
- vpunpckldq ymmF, ymmF, ymmH ; ymmF=(2A 0B 1B 2B 0C 1C 2C 0D 2C 0D 1D 2D 0E 1E 2E 0F
- ; 2Q 0R 1R 2R 0S 1S 2S 0T 2S 0T 1T 2T 0U 1U 2U 0V)
-
- vpunpcklqdq ymmH, ymmA, ymmE ; ymmH=(00 10 20 01 11 21 02 12 22 03 13 23 04 14 24 05
- ; 0G 1G 2G 0H 1H 2H 0I 1I 2I 0J 1J 2J 0K 1K 2K 0L)
- vpunpcklqdq ymmG, ymmD, ymmG ; ymmG=(15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A
- ; 1L 2L 0M 1M 2M 0N 1N 2N 0O 1O 2O 0P 1P 2P 0Q 1Q)
- vpunpcklqdq ymmC, ymmF, ymmC ; ymmC=(2A 0B 1B 2B 0C 1C 2C 0D 1D 2D 0E 1E 2E 0F 1F 2F
- ; 2Q 0R 1R 2R 0S 1S 2S 0T 1T 2T 0U 1U 2U 0V 1V 2V)
-
- vperm2i128 ymmA, ymmH, ymmG, 0x20 ; ymmA=(00 10 20 01 11 21 02 12 22 03 13 23 04 14 24 05
- ; 15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A)
- vperm2i128 ymmD, ymmC, ymmH, 0x30 ; ymmD=(2A 0B 1B 2B 0C 1C 2C 0D 1D 2D 0E 1E 2E 0F 1F 2F
- ; 0G 1G 2G 0H 1H 2H 0I 1I 2I 0J 1J 2J 0K 1K 2K 0L)
- vperm2i128 ymmF, ymmG, ymmC, 0x31 ; ymmF=(1L 2L 0M 1M 2M 0N 1N 2N 0O 1O 2O 0P 1P 2P 0Q 1Q
- ; 2Q 0R 1R 2R 0S 1S 2S 0T 1T 2T 0U 1U 2U 0V 1V 2V)
-
- cmp rcx, byte SIZEOF_YMMWORD
- jb short .column_st64
-
- test rdi, SIZEOF_YMMWORD-1
- jnz short .out1
- ; --(aligned)-------------------
- vmovntdq YMMWORD [rdi+0*SIZEOF_YMMWORD], ymmA
- vmovntdq YMMWORD [rdi+1*SIZEOF_YMMWORD], ymmD
- vmovntdq YMMWORD [rdi+2*SIZEOF_YMMWORD], ymmF
- jmp short .out0
-.out1: ; --(unaligned)-----------------
- vmovdqu YMMWORD [rdi+0*SIZEOF_YMMWORD], ymmA
- vmovdqu YMMWORD [rdi+1*SIZEOF_YMMWORD], ymmD
- vmovdqu YMMWORD [rdi+2*SIZEOF_YMMWORD], ymmF
-.out0:
- add rdi, byte RGB_PIXELSIZE*SIZEOF_YMMWORD ; outptr
- sub rcx, byte SIZEOF_YMMWORD
- jz near .endcolumn
-
- add rsi, byte SIZEOF_YMMWORD ; inptr0
- dec al ; Yctr
- jnz near .Yloop_2nd
-
- add rbx, byte SIZEOF_YMMWORD ; inptr1
- add rdx, byte SIZEOF_YMMWORD ; inptr2
- jmp near .columnloop
-
-.column_st64:
- lea rcx, [rcx+rcx*2] ; imul ecx, RGB_PIXELSIZE
- cmp rcx, byte 2*SIZEOF_YMMWORD
- jb short .column_st32
- vmovdqu YMMWORD [rdi+0*SIZEOF_YMMWORD], ymmA
- vmovdqu YMMWORD [rdi+1*SIZEOF_YMMWORD], ymmD
- add rdi, byte 2*SIZEOF_YMMWORD ; outptr
- vmovdqa ymmA, ymmF
- sub rcx, byte 2*SIZEOF_YMMWORD
- jmp short .column_st31
-.column_st32:
- cmp rcx, byte SIZEOF_YMMWORD
- jb short .column_st31
- vmovdqu YMMWORD [rdi+0*SIZEOF_YMMWORD], ymmA
- add rdi, byte SIZEOF_YMMWORD ; outptr
- vmovdqa ymmA, ymmD
- sub rcx, byte SIZEOF_YMMWORD
- jmp short .column_st31
-.column_st31:
- cmp rcx, byte SIZEOF_XMMWORD
- jb short .column_st15
- vmovdqu XMMWORD [rdi+0*SIZEOF_XMMWORD], xmmA
- add rdi, byte SIZEOF_XMMWORD ; outptr
- vperm2i128 ymmA, ymmA, ymmA, 1
- sub rcx, byte SIZEOF_XMMWORD
-.column_st15:
- ; Store the lower 8 bytes of xmmA to the output when it has enough
- ; space.
- cmp rcx, byte SIZEOF_MMWORD
- jb short .column_st7
- vmovq XMM_MMWORD [rdi], xmmA
- add rdi, byte SIZEOF_MMWORD
- sub rcx, byte SIZEOF_MMWORD
- vpsrldq xmmA, xmmA, SIZEOF_MMWORD
-.column_st7:
- ; Store the lower 4 bytes of xmmA to the output when it has enough
- ; space.
- cmp rcx, byte SIZEOF_DWORD
- jb short .column_st3
- vmovd XMM_DWORD [rdi], xmmA
- add rdi, byte SIZEOF_DWORD
- sub rcx, byte SIZEOF_DWORD
- vpsrldq xmmA, xmmA, SIZEOF_DWORD
-.column_st3:
- ; Store the lower 2 bytes of rax to the output when it has enough
- ; space.
- vmovd eax, xmmA
- cmp rcx, byte SIZEOF_WORD
- jb short .column_st1
- mov word [rdi], ax
- add rdi, byte SIZEOF_WORD
- sub rcx, byte SIZEOF_WORD
- shr rax, 16
-.column_st1:
- ; Store the lower 1 byte of rax to the output when it has enough
- ; space.
- test rcx, rcx
- jz short .endcolumn
- mov byte [rdi], al
-
-%else ; RGB_PIXELSIZE == 4 ; -----------
-
-%ifdef RGBX_FILLER_0XFF
- vpcmpeqb ymm6, ymm6, ymm6 ; ymm6=XE=X(02468ACE********GIKMOQSU********)
- vpcmpeqb ymm7, ymm7, ymm7 ; ymm7=XO=X(13579BDF********HJLNPRTV********)
-%else
- vpxor ymm6, ymm6, ymm6 ; ymm6=XE=X(02468ACE********GIKMOQSU********)
- vpxor ymm7, ymm7, ymm7 ; ymm7=XO=X(13579BDF********HJLNPRTV********)
-%endif
- ; ymmA=(00 02 04 06 08 0A 0C 0E ** 0G 0I 0K 0M 0O 0Q 0S 0U **)
- ; ymmB=(01 03 05 07 09 0B 0D 0F ** 0H 0J 0L 0N 0P 0R 0T 0V **)
- ; ymmC=(10 12 14 16 18 1A 1C 1E ** 1G 1I 1K 1M 1O 1Q 1S 1U **)
- ; ymmD=(11 13 15 17 19 1B 1D 1F ** 1H 1J 1L 1N 1P 1R 1T 1V **)
- ; ymmE=(20 22 24 26 28 2A 2C 2E ** 2G 2I 2K 2M 2O 2Q 2S 2U **)
- ; ymmF=(21 23 25 27 29 2B 2D 2F ** 2H 2J 2L 2N 2P 2R 2T 2V **)
- ; ymmG=(30 32 34 36 38 3A 3C 3E ** 3G 3I 3K 3M 3O 3Q 3S 3U **)
- ; ymmH=(31 33 35 37 39 3B 3D 3F ** 3H 3J 3L 3N 3P 3R 3T 3V **)
-
- vpunpcklbw ymmA, ymmA, ymmC ; ymmA=(00 10 02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E
- ; 0G 1G 0I 1I 0K 1K 0M 1M 0O 1O 0Q 1Q 0S 1S 0U 1U)
- vpunpcklbw ymmE, ymmE, ymmG ; ymmE=(20 30 22 32 24 34 26 36 28 38 2A 3A 2C 3C 2E 3E
- ; 2G 3G 2I 3I 2K 3K 2M 3M 2O 3O 2Q 3Q 2S 3S 2U 3U)
- vpunpcklbw ymmB, ymmB, ymmD ; ymmB=(01 11 03 13 05 15 07 17 09 19 0B 1B 0D 1D 0F 1F
- ; 0H 1H 0J 1J 0L 1L 0N 1N 0P 1P 0R 1R 0T 1T 0V 1V)
- vpunpcklbw ymmF, ymmF, ymmH ; ymmF=(21 31 23 33 25 35 27 37 29 39 2B 3B 2D 3D 2F 3F
- ; 2H 3H 2J 3J 2L 3L 2N 3N 2P 3P 2R 3R 2T 3T 2V 3V)
-
- vpunpckhwd ymmC, ymmA, ymmE ; ymmC=(08 18 28 38 0A 1A 2A 3A 0C 1C 2C 3C 0E 1E 2E 3E
- ; 0O 1O 2O 3O 0Q 1Q 2Q 3Q 0S 1S 2S 3S 0U 1U 2U 3U)
- vpunpcklwd ymmA, ymmA, ymmE ; ymmA=(00 10 20 30 02 12 22 32 04 14 24 34 06 16 26 36
- ; 0G 1G 2G 3G 0I 1I 2I 3I 0K 1K 2K 3K 0M 1M 2M 3M)
- vpunpckhwd ymmG, ymmB, ymmF ; ymmG=(09 19 29 39 0B 1B 2B 3B 0D 1D 2D 3D 0F 1F 2F 3F
- ; 0P 1P 2P 3P 0R 1R 2R 3R 0T 1T 2T 3T 0V 1V 2V 3V)
- vpunpcklwd ymmB, ymmB, ymmF ; ymmB=(01 11 21 31 03 13 23 33 05 15 25 35 07 17 27 37
- ; 0H 1H 2H 3H 0J 1J 2J 3J 0L 1L 2L 3L 0N 1N 2N 3N)
-
- vpunpckhdq ymmE, ymmA, ymmB ; ymmE=(04 14 24 34 05 15 25 35 06 16 26 36 07 17 27 37
- ; 0K 1K 2K 3K 0L 1L 2L 3L 0M 1M 2M 3M 0N 1N 2N 3N)
- vpunpckldq ymmB, ymmA, ymmB ; ymmB=(00 10 20 30 01 11 21 31 02 12 22 32 03 13 23 33
- ; 0G 1G 2G 3G 0H 1H 2H 3H 0I 1I 2I 3I 0J 1J 2J 3J)
- vpunpckhdq ymmF, ymmC, ymmG ; ymmF=(0C 1C 2C 3C 0D 1D 2D 3D 0E 1E 2E 3E 0F 1F 2F 3F
- ; 0S 1S 2S 3S 0T 1T 2T 3T 0U 1U 2U 3U 0V 1V 2V 3V)
- vpunpckldq ymmG, ymmC, ymmG ; ymmG=(08 18 28 38 09 19 29 39 0A 1A 2A 3A 0B 1B 2B 3B
- ; 0O 1O 2O 3O 0P 1P 2P 3P 0Q 1Q 2Q 3Q 0R 1R 2R 3R)
-
- vperm2i128 ymmA, ymmB, ymmE, 0x20 ; ymmA=(00 10 20 30 01 11 21 31 02 12 22 32 03 13 23 33
- ; 04 14 24 34 05 15 25 35 06 16 26 36 07 17 27 37)
- vperm2i128 ymmD, ymmG, ymmF, 0x20 ; ymmD=(08 18 28 38 09 19 29 39 0A 1A 2A 3A 0B 1B 2B 3B
- ; 0C 1C 2C 3C 0D 1D 2D 3D 0E 1E 2E 3E 0F 1F 2F 3F)
- vperm2i128 ymmC, ymmB, ymmE, 0x31 ; ymmC=(0G 1G 2G 3G 0H 1H 2H 3H 0I 1I 2I 3I 0J 1J 2J 3J
- ; 0K 1K 2K 3K 0L 1L 2L 3L 0M 1M 2M 3M 0N 1N 2N 3N)
- vperm2i128 ymmH, ymmG, ymmF, 0x31 ; ymmH=(0O 1O 2O 3O 0P 1P 2P 3P 0Q 1Q 2Q 3Q 0R 1R 2R 3R
- ; 0S 1S 2S 3S 0T 1T 2T 3T 0U 1U 2U 3U 0V 1V 2V 3V)
-
- cmp rcx, byte SIZEOF_YMMWORD
- jb short .column_st64
-
- test rdi, SIZEOF_YMMWORD-1
- jnz short .out1
- ; --(aligned)-------------------
- vmovntdq YMMWORD [rdi+0*SIZEOF_YMMWORD], ymmA
- vmovntdq YMMWORD [rdi+1*SIZEOF_YMMWORD], ymmD
- vmovntdq YMMWORD [rdi+2*SIZEOF_YMMWORD], ymmC
- vmovntdq YMMWORD [rdi+3*SIZEOF_YMMWORD], ymmH
- jmp short .out0
-.out1: ; --(unaligned)-----------------
- vmovdqu YMMWORD [rdi+0*SIZEOF_YMMWORD], ymmA
- vmovdqu YMMWORD [rdi+1*SIZEOF_YMMWORD], ymmD
- vmovdqu YMMWORD [rdi+2*SIZEOF_YMMWORD], ymmC
- vmovdqu YMMWORD [rdi+3*SIZEOF_YMMWORD], ymmH
-.out0:
- add rdi, RGB_PIXELSIZE*SIZEOF_YMMWORD ; outptr
- sub rcx, byte SIZEOF_YMMWORD
- jz near .endcolumn
-
- add rsi, byte SIZEOF_YMMWORD ; inptr0
- dec al
- jnz near .Yloop_2nd
-
- add rbx, byte SIZEOF_YMMWORD ; inptr1
- add rdx, byte SIZEOF_YMMWORD ; inptr2
- jmp near .columnloop
-
-.column_st64:
- cmp rcx, byte SIZEOF_YMMWORD/2
- jb short .column_st32
- vmovdqu YMMWORD [rdi+0*SIZEOF_YMMWORD], ymmA
- vmovdqu YMMWORD [rdi+1*SIZEOF_YMMWORD], ymmD
- add rdi, byte 2*SIZEOF_YMMWORD ; outptr
- vmovdqa ymmA, ymmC
- vmovdqa ymmD, ymmH
- sub rcx, byte SIZEOF_YMMWORD/2
-.column_st32:
- cmp rcx, byte SIZEOF_YMMWORD/4
- jb short .column_st16
- vmovdqu YMMWORD [rdi+0*SIZEOF_YMMWORD], ymmA
- add rdi, byte SIZEOF_YMMWORD ; outptr
- vmovdqa ymmA, ymmD
- sub rcx, byte SIZEOF_YMMWORD/4
-.column_st16:
- cmp rcx, byte SIZEOF_YMMWORD/8
- jb short .column_st15
- vmovdqu XMMWORD [rdi+0*SIZEOF_XMMWORD], xmmA
- add rdi, byte SIZEOF_XMMWORD ; outptr
- vperm2i128 ymmA, ymmA, ymmA, 1
- sub rcx, byte SIZEOF_YMMWORD/8
-.column_st15:
- ; Store two pixels (8 bytes) of ymmA to the output when it has enough
- ; space.
- cmp rcx, byte SIZEOF_YMMWORD/16
- jb short .column_st7
- vmovq MMWORD [rdi], xmmA
- add rdi, byte SIZEOF_YMMWORD/16*4
- sub rcx, byte SIZEOF_YMMWORD/16
- vpsrldq xmmA, SIZEOF_YMMWORD/16*4
-.column_st7:
- ; Store one pixel (4 bytes) of ymmA to the output when it has enough
- ; space.
- test rcx, rcx
- jz short .endcolumn
- vmovd XMM_DWORD [rdi], xmmA
-
-%endif ; RGB_PIXELSIZE ; ---------------
-
-.endcolumn:
- sfence ; flush the write buffer
-
-.return:
- pop rbx
- vzeroupper
- uncollect_args 4
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
- pop rbp
- ret
-
-; --------------------------------------------------------------------------
-;
-; Upsample and color convert for the case of 2:1 horizontal and 2:1 vertical.
-;
-; GLOBAL(void)
-; jsimd_h2v2_merged_upsample_avx2(JDIMENSION output_width,
-; JSAMPIMAGE input_buf,
-; JDIMENSION in_row_group_ctr,
-; JSAMPARRAY output_buf);
-;
-
-; r10d = JDIMENSION output_width
-; r11 = JSAMPIMAGE input_buf
-; r12d = JDIMENSION in_row_group_ctr
-; r13 = JSAMPARRAY output_buf
-
- align 32
- GLOBAL_FUNCTION(jsimd_h2v2_merged_upsample_avx2)
-
-EXTN(jsimd_h2v2_merged_upsample_avx2):
- push rbp
- mov rax, rsp
- mov rbp, rsp
- collect_args 4
- push rbx
-
- mov eax, r10d
-
- mov rdi, r11
- mov ecx, r12d
- mov rsip, JSAMPARRAY [rdi+0*SIZEOF_JSAMPARRAY]
- mov rbxp, JSAMPARRAY [rdi+1*SIZEOF_JSAMPARRAY]
- mov rdxp, JSAMPARRAY [rdi+2*SIZEOF_JSAMPARRAY]
- mov rdi, r13
- lea rsi, [rsi+rcx*SIZEOF_JSAMPROW]
-
- sub rsp, SIZEOF_JSAMPARRAY*4
- mov JSAMPARRAY [rsp+0*SIZEOF_JSAMPARRAY], rsip ; intpr00
- mov JSAMPARRAY [rsp+1*SIZEOF_JSAMPARRAY], rbxp ; intpr1
- mov JSAMPARRAY [rsp+2*SIZEOF_JSAMPARRAY], rdxp ; intpr2
- mov rbx, rsp
-
- push rdi
- push rcx
- push rax
-
- %ifdef WIN64
- mov r8, rcx
- mov r9, rdi
- mov rcx, rax
- mov rdx, rbx
- %else
- mov rdx, rcx
- mov rcx, rdi
- mov rdi, rax
- mov rsi, rbx
- %endif
-
- call EXTN(jsimd_h2v1_merged_upsample_avx2)
-
- pop rax
- pop rcx
- pop rdi
- mov rsip, JSAMPARRAY [rsp+0*SIZEOF_JSAMPARRAY]
- mov rbxp, JSAMPARRAY [rsp+1*SIZEOF_JSAMPARRAY]
- mov rdxp, JSAMPARRAY [rsp+2*SIZEOF_JSAMPARRAY]
-
- add rdi, byte SIZEOF_JSAMPROW ; outptr1
- add rsi, byte SIZEOF_JSAMPROW ; inptr01
-
- mov JSAMPARRAY [rsp+0*SIZEOF_JSAMPARRAY], rsip ; intpr00
- mov JSAMPARRAY [rsp+1*SIZEOF_JSAMPARRAY], rbxp ; intpr1
- mov JSAMPARRAY [rsp+2*SIZEOF_JSAMPARRAY], rdxp ; intpr2
- mov rbx, rsp
-
- push rdi
- push rcx
- push rax
-
- %ifdef WIN64
- mov r8, rcx
- mov r9, rdi
- mov rcx, rax
- mov rdx, rbx
- %else
- mov rdx, rcx
- mov rcx, rdi
- mov rdi, rax
- mov rsi, rbx
- %endif
-
- call EXTN(jsimd_h2v1_merged_upsample_avx2)
-
- pop rax
- pop rcx
- pop rdi
- mov rsip, JSAMPARRAY [rsp+0*SIZEOF_JSAMPARRAY]
- mov rbxp, JSAMPARRAY [rsp+1*SIZEOF_JSAMPARRAY]
- mov rdxp, JSAMPARRAY [rsp+2*SIZEOF_JSAMPARRAY]
- add rsp, SIZEOF_JSAMPARRAY*4
-
- pop rbx
- uncollect_args 4
- pop rbp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jdmrgext-sse2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jdmrgext-sse2.asm
deleted file mode 100644
index eb3ab9dbd9..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jdmrgext-sse2.asm
+++ /dev/null
@@ -1,538 +0,0 @@
-;
-; jdmrgext.asm - merged upsampling/color conversion (64-bit SSE2)
-;
-; Copyright 2009, 2012 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, 2012, 2016, D. R. Commander.
-; Copyright (C) 2018, Matthias Räncker.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jcolsamp.inc"
-
-; --------------------------------------------------------------------------
-;
-; Upsample and color convert for the case of 2:1 horizontal and 1:1 vertical.
-;
-; GLOBAL(void)
-; jsimd_h2v1_merged_upsample_sse2(JDIMENSION output_width,
-; JSAMPIMAGE input_buf,
-; JDIMENSION in_row_group_ctr,
-; JSAMPARRAY output_buf);
-;
-
-; r10d = JDIMENSION output_width
-; r11 = JSAMPIMAGE input_buf
-; r12d = JDIMENSION in_row_group_ctr
-; r13 = JSAMPARRAY output_buf
-
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
-%define WK_NUM 3
-
- align 32
- GLOBAL_FUNCTION(jsimd_h2v1_merged_upsample_sse2)
-
-EXTN(jsimd_h2v1_merged_upsample_sse2):
- push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
- and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
- collect_args 4
- push rbx
-
- mov ecx, r10d ; col
- test rcx, rcx
- jz near .return
-
- push rcx
-
- mov rdi, r11
- mov ecx, r12d
- mov rsip, JSAMPARRAY [rdi+0*SIZEOF_JSAMPARRAY]
- mov rbxp, JSAMPARRAY [rdi+1*SIZEOF_JSAMPARRAY]
- mov rdxp, JSAMPARRAY [rdi+2*SIZEOF_JSAMPARRAY]
- mov rdi, r13
- mov rsip, JSAMPROW [rsi+rcx*SIZEOF_JSAMPROW] ; inptr0
- mov rbxp, JSAMPROW [rbx+rcx*SIZEOF_JSAMPROW] ; inptr1
- mov rdxp, JSAMPROW [rdx+rcx*SIZEOF_JSAMPROW] ; inptr2
- mov rdip, JSAMPROW [rdi] ; outptr
-
- pop rcx ; col
-
-.columnloop:
-
- movdqa xmm6, XMMWORD [rbx] ; xmm6=Cb(0123456789ABCDEF)
- movdqa xmm7, XMMWORD [rdx] ; xmm7=Cr(0123456789ABCDEF)
-
- pxor xmm1, xmm1 ; xmm1=(all 0's)
- pcmpeqw xmm3, xmm3
- psllw xmm3, 7 ; xmm3={0xFF80 0xFF80 0xFF80 0xFF80 ..}
-
- movdqa xmm4, xmm6
- punpckhbw xmm6, xmm1 ; xmm6=Cb(89ABCDEF)=CbH
- punpcklbw xmm4, xmm1 ; xmm4=Cb(01234567)=CbL
- movdqa xmm0, xmm7
- punpckhbw xmm7, xmm1 ; xmm7=Cr(89ABCDEF)=CrH
- punpcklbw xmm0, xmm1 ; xmm0=Cr(01234567)=CrL
-
- paddw xmm6, xmm3
- paddw xmm4, xmm3
- paddw xmm7, xmm3
- paddw xmm0, xmm3
-
- ; (Original)
- ; R = Y + 1.40200 * Cr
- ; G = Y - 0.34414 * Cb - 0.71414 * Cr
- ; B = Y + 1.77200 * Cb
- ;
- ; (This implementation)
- ; R = Y + 0.40200 * Cr + Cr
- ; G = Y - 0.34414 * Cb + 0.28586 * Cr - Cr
- ; B = Y - 0.22800 * Cb + Cb + Cb
-
- movdqa xmm5, xmm6 ; xmm5=CbH
- movdqa xmm2, xmm4 ; xmm2=CbL
- paddw xmm6, xmm6 ; xmm6=2*CbH
- paddw xmm4, xmm4 ; xmm4=2*CbL
- movdqa xmm1, xmm7 ; xmm1=CrH
- movdqa xmm3, xmm0 ; xmm3=CrL
- paddw xmm7, xmm7 ; xmm7=2*CrH
- paddw xmm0, xmm0 ; xmm0=2*CrL
-
- pmulhw xmm6, [rel PW_MF0228] ; xmm6=(2*CbH * -FIX(0.22800))
- pmulhw xmm4, [rel PW_MF0228] ; xmm4=(2*CbL * -FIX(0.22800))
- pmulhw xmm7, [rel PW_F0402] ; xmm7=(2*CrH * FIX(0.40200))
- pmulhw xmm0, [rel PW_F0402] ; xmm0=(2*CrL * FIX(0.40200))
-
- paddw xmm6, [rel PW_ONE]
- paddw xmm4, [rel PW_ONE]
- psraw xmm6, 1 ; xmm6=(CbH * -FIX(0.22800))
- psraw xmm4, 1 ; xmm4=(CbL * -FIX(0.22800))
- paddw xmm7, [rel PW_ONE]
- paddw xmm0, [rel PW_ONE]
- psraw xmm7, 1 ; xmm7=(CrH * FIX(0.40200))
- psraw xmm0, 1 ; xmm0=(CrL * FIX(0.40200))
-
- paddw xmm6, xmm5
- paddw xmm4, xmm2
- paddw xmm6, xmm5 ; xmm6=(CbH * FIX(1.77200))=(B-Y)H
- paddw xmm4, xmm2 ; xmm4=(CbL * FIX(1.77200))=(B-Y)L
- paddw xmm7, xmm1 ; xmm7=(CrH * FIX(1.40200))=(R-Y)H
- paddw xmm0, xmm3 ; xmm0=(CrL * FIX(1.40200))=(R-Y)L
-
- movdqa XMMWORD [wk(0)], xmm6 ; wk(0)=(B-Y)H
- movdqa XMMWORD [wk(1)], xmm7 ; wk(1)=(R-Y)H
-
- movdqa xmm6, xmm5
- movdqa xmm7, xmm2
- punpcklwd xmm5, xmm1
- punpckhwd xmm6, xmm1
- pmaddwd xmm5, [rel PW_MF0344_F0285]
- pmaddwd xmm6, [rel PW_MF0344_F0285]
- punpcklwd xmm2, xmm3
- punpckhwd xmm7, xmm3
- pmaddwd xmm2, [rel PW_MF0344_F0285]
- pmaddwd xmm7, [rel PW_MF0344_F0285]
-
- paddd xmm5, [rel PD_ONEHALF]
- paddd xmm6, [rel PD_ONEHALF]
- psrad xmm5, SCALEBITS
- psrad xmm6, SCALEBITS
- paddd xmm2, [rel PD_ONEHALF]
- paddd xmm7, [rel PD_ONEHALF]
- psrad xmm2, SCALEBITS
- psrad xmm7, SCALEBITS
-
- packssdw xmm5, xmm6 ; xmm5=CbH*-FIX(0.344)+CrH*FIX(0.285)
- packssdw xmm2, xmm7 ; xmm2=CbL*-FIX(0.344)+CrL*FIX(0.285)
- psubw xmm5, xmm1 ; xmm5=CbH*-FIX(0.344)+CrH*-FIX(0.714)=(G-Y)H
- psubw xmm2, xmm3 ; xmm2=CbL*-FIX(0.344)+CrL*-FIX(0.714)=(G-Y)L
-
- movdqa XMMWORD [wk(2)], xmm5 ; wk(2)=(G-Y)H
-
- mov al, 2 ; Yctr
- jmp short .Yloop_1st
-
-.Yloop_2nd:
- movdqa xmm0, XMMWORD [wk(1)] ; xmm0=(R-Y)H
- movdqa xmm2, XMMWORD [wk(2)] ; xmm2=(G-Y)H
- movdqa xmm4, XMMWORD [wk(0)] ; xmm4=(B-Y)H
-
-.Yloop_1st:
- movdqa xmm7, XMMWORD [rsi] ; xmm7=Y(0123456789ABCDEF)
-
- pcmpeqw xmm6, xmm6
- psrlw xmm6, BYTE_BIT ; xmm6={0xFF 0x00 0xFF 0x00 ..}
- pand xmm6, xmm7 ; xmm6=Y(02468ACE)=YE
- psrlw xmm7, BYTE_BIT ; xmm7=Y(13579BDF)=YO
-
- movdqa xmm1, xmm0 ; xmm1=xmm0=(R-Y)(L/H)
- movdqa xmm3, xmm2 ; xmm3=xmm2=(G-Y)(L/H)
- movdqa xmm5, xmm4 ; xmm5=xmm4=(B-Y)(L/H)
-
- paddw xmm0, xmm6 ; xmm0=((R-Y)+YE)=RE=R(02468ACE)
- paddw xmm1, xmm7 ; xmm1=((R-Y)+YO)=RO=R(13579BDF)
- packuswb xmm0, xmm0 ; xmm0=R(02468ACE********)
- packuswb xmm1, xmm1 ; xmm1=R(13579BDF********)
-
- paddw xmm2, xmm6 ; xmm2=((G-Y)+YE)=GE=G(02468ACE)
- paddw xmm3, xmm7 ; xmm3=((G-Y)+YO)=GO=G(13579BDF)
- packuswb xmm2, xmm2 ; xmm2=G(02468ACE********)
- packuswb xmm3, xmm3 ; xmm3=G(13579BDF********)
-
- paddw xmm4, xmm6 ; xmm4=((B-Y)+YE)=BE=B(02468ACE)
- paddw xmm5, xmm7 ; xmm5=((B-Y)+YO)=BO=B(13579BDF)
- packuswb xmm4, xmm4 ; xmm4=B(02468ACE********)
- packuswb xmm5, xmm5 ; xmm5=B(13579BDF********)
-
-%if RGB_PIXELSIZE == 3 ; ---------------
-
- ; xmmA=(00 02 04 06 08 0A 0C 0E **), xmmB=(01 03 05 07 09 0B 0D 0F **)
- ; xmmC=(10 12 14 16 18 1A 1C 1E **), xmmD=(11 13 15 17 19 1B 1D 1F **)
- ; xmmE=(20 22 24 26 28 2A 2C 2E **), xmmF=(21 23 25 27 29 2B 2D 2F **)
- ; xmmG=(** ** ** ** ** ** ** ** **), xmmH=(** ** ** ** ** ** ** ** **)
-
- punpcklbw xmmA, xmmC ; xmmA=(00 10 02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E)
- punpcklbw xmmE, xmmB ; xmmE=(20 01 22 03 24 05 26 07 28 09 2A 0B 2C 0D 2E 0F)
- punpcklbw xmmD, xmmF ; xmmD=(11 21 13 23 15 25 17 27 19 29 1B 2B 1D 2D 1F 2F)
-
- movdqa xmmG, xmmA
- movdqa xmmH, xmmA
- punpcklwd xmmA, xmmE ; xmmA=(00 10 20 01 02 12 22 03 04 14 24 05 06 16 26 07)
- punpckhwd xmmG, xmmE ; xmmG=(08 18 28 09 0A 1A 2A 0B 0C 1C 2C 0D 0E 1E 2E 0F)
-
- psrldq xmmH, 2 ; xmmH=(02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E -- --)
- psrldq xmmE, 2 ; xmmE=(22 03 24 05 26 07 28 09 2A 0B 2C 0D 2E 0F -- --)
-
- movdqa xmmC, xmmD
- movdqa xmmB, xmmD
- punpcklwd xmmD, xmmH ; xmmD=(11 21 02 12 13 23 04 14 15 25 06 16 17 27 08 18)
- punpckhwd xmmC, xmmH ; xmmC=(19 29 0A 1A 1B 2B 0C 1C 1D 2D 0E 1E 1F 2F -- --)
-
- psrldq xmmB, 2 ; xmmB=(13 23 15 25 17 27 19 29 1B 2B 1D 2D 1F 2F -- --)
-
- movdqa xmmF, xmmE
- punpcklwd xmmE, xmmB ; xmmE=(22 03 13 23 24 05 15 25 26 07 17 27 28 09 19 29)
- punpckhwd xmmF, xmmB ; xmmF=(2A 0B 1B 2B 2C 0D 1D 2D 2E 0F 1F 2F -- -- -- --)
-
- pshufd xmmH, xmmA, 0x4E ; xmmH=(04 14 24 05 06 16 26 07 00 10 20 01 02 12 22 03)
- movdqa xmmB, xmmE
- punpckldq xmmA, xmmD ; xmmA=(00 10 20 01 11 21 02 12 02 12 22 03 13 23 04 14)
- punpckldq xmmE, xmmH ; xmmE=(22 03 13 23 04 14 24 05 24 05 15 25 06 16 26 07)
- punpckhdq xmmD, xmmB ; xmmD=(15 25 06 16 26 07 17 27 17 27 08 18 28 09 19 29)
-
- pshufd xmmH, xmmG, 0x4E ; xmmH=(0C 1C 2C 0D 0E 1E 2E 0F 08 18 28 09 0A 1A 2A 0B)
- movdqa xmmB, xmmF
- punpckldq xmmG, xmmC ; xmmG=(08 18 28 09 19 29 0A 1A 0A 1A 2A 0B 1B 2B 0C 1C)
- punpckldq xmmF, xmmH ; xmmF=(2A 0B 1B 2B 0C 1C 2C 0D 2C 0D 1D 2D 0E 1E 2E 0F)
- punpckhdq xmmC, xmmB ; xmmC=(1D 2D 0E 1E 2E 0F 1F 2F 1F 2F -- -- -- -- -- --)
-
- punpcklqdq xmmA, xmmE ; xmmA=(00 10 20 01 11 21 02 12 22 03 13 23 04 14 24 05)
- punpcklqdq xmmD, xmmG ; xmmD=(15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A)
- punpcklqdq xmmF, xmmC ; xmmF=(2A 0B 1B 2B 0C 1C 2C 0D 1D 2D 0E 1E 2E 0F 1F 2F)
-
- cmp rcx, byte SIZEOF_XMMWORD
- jb short .column_st32
-
- test rdi, SIZEOF_XMMWORD-1
- jnz short .out1
- ; --(aligned)-------------------
- movntdq XMMWORD [rdi+0*SIZEOF_XMMWORD], xmmA
- movntdq XMMWORD [rdi+1*SIZEOF_XMMWORD], xmmD
- movntdq XMMWORD [rdi+2*SIZEOF_XMMWORD], xmmF
- jmp short .out0
-.out1: ; --(unaligned)-----------------
- movdqu XMMWORD [rdi+0*SIZEOF_XMMWORD], xmmA
- movdqu XMMWORD [rdi+1*SIZEOF_XMMWORD], xmmD
- movdqu XMMWORD [rdi+2*SIZEOF_XMMWORD], xmmF
-.out0:
- add rdi, byte RGB_PIXELSIZE*SIZEOF_XMMWORD ; outptr
- sub rcx, byte SIZEOF_XMMWORD
- jz near .endcolumn
-
- add rsi, byte SIZEOF_XMMWORD ; inptr0
- dec al ; Yctr
- jnz near .Yloop_2nd
-
- add rbx, byte SIZEOF_XMMWORD ; inptr1
- add rdx, byte SIZEOF_XMMWORD ; inptr2
- jmp near .columnloop
-
-.column_st32:
- lea rcx, [rcx+rcx*2] ; imul ecx, RGB_PIXELSIZE
- cmp rcx, byte 2*SIZEOF_XMMWORD
- jb short .column_st16
- movdqu XMMWORD [rdi+0*SIZEOF_XMMWORD], xmmA
- movdqu XMMWORD [rdi+1*SIZEOF_XMMWORD], xmmD
- add rdi, byte 2*SIZEOF_XMMWORD ; outptr
- movdqa xmmA, xmmF
- sub rcx, byte 2*SIZEOF_XMMWORD
- jmp short .column_st15
-.column_st16:
- cmp rcx, byte SIZEOF_XMMWORD
- jb short .column_st15
- movdqu XMMWORD [rdi+0*SIZEOF_XMMWORD], xmmA
- add rdi, byte SIZEOF_XMMWORD ; outptr
- movdqa xmmA, xmmD
- sub rcx, byte SIZEOF_XMMWORD
-.column_st15:
- ; Store the lower 8 bytes of xmmA to the output when it has enough
- ; space.
- cmp rcx, byte SIZEOF_MMWORD
- jb short .column_st7
- movq XMM_MMWORD [rdi], xmmA
- add rdi, byte SIZEOF_MMWORD
- sub rcx, byte SIZEOF_MMWORD
- psrldq xmmA, SIZEOF_MMWORD
-.column_st7:
- ; Store the lower 4 bytes of xmmA to the output when it has enough
- ; space.
- cmp rcx, byte SIZEOF_DWORD
- jb short .column_st3
- movd XMM_DWORD [rdi], xmmA
- add rdi, byte SIZEOF_DWORD
- sub rcx, byte SIZEOF_DWORD
- psrldq xmmA, SIZEOF_DWORD
-.column_st3:
- ; Store the lower 2 bytes of rax to the output when it has enough
- ; space.
- movd eax, xmmA
- cmp rcx, byte SIZEOF_WORD
- jb short .column_st1
- mov word [rdi], ax
- add rdi, byte SIZEOF_WORD
- sub rcx, byte SIZEOF_WORD
- shr rax, 16
-.column_st1:
- ; Store the lower 1 byte of rax to the output when it has enough
- ; space.
- test rcx, rcx
- jz short .endcolumn
- mov byte [rdi], al
-
-%else ; RGB_PIXELSIZE == 4 ; -----------
-
-%ifdef RGBX_FILLER_0XFF
- pcmpeqb xmm6, xmm6 ; xmm6=XE=X(02468ACE********)
- pcmpeqb xmm7, xmm7 ; xmm7=XO=X(13579BDF********)
-%else
- pxor xmm6, xmm6 ; xmm6=XE=X(02468ACE********)
- pxor xmm7, xmm7 ; xmm7=XO=X(13579BDF********)
-%endif
- ; xmmA=(00 02 04 06 08 0A 0C 0E **), xmmB=(01 03 05 07 09 0B 0D 0F **)
- ; xmmC=(10 12 14 16 18 1A 1C 1E **), xmmD=(11 13 15 17 19 1B 1D 1F **)
- ; xmmE=(20 22 24 26 28 2A 2C 2E **), xmmF=(21 23 25 27 29 2B 2D 2F **)
- ; xmmG=(30 32 34 36 38 3A 3C 3E **), xmmH=(31 33 35 37 39 3B 3D 3F **)
-
- punpcklbw xmmA, xmmC ; xmmA=(00 10 02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E)
- punpcklbw xmmE, xmmG ; xmmE=(20 30 22 32 24 34 26 36 28 38 2A 3A 2C 3C 2E 3E)
- punpcklbw xmmB, xmmD ; xmmB=(01 11 03 13 05 15 07 17 09 19 0B 1B 0D 1D 0F 1F)
- punpcklbw xmmF, xmmH ; xmmF=(21 31 23 33 25 35 27 37 29 39 2B 3B 2D 3D 2F 3F)
-
- movdqa xmmC, xmmA
- punpcklwd xmmA, xmmE ; xmmA=(00 10 20 30 02 12 22 32 04 14 24 34 06 16 26 36)
- punpckhwd xmmC, xmmE ; xmmC=(08 18 28 38 0A 1A 2A 3A 0C 1C 2C 3C 0E 1E 2E 3E)
- movdqa xmmG, xmmB
- punpcklwd xmmB, xmmF ; xmmB=(01 11 21 31 03 13 23 33 05 15 25 35 07 17 27 37)
- punpckhwd xmmG, xmmF ; xmmG=(09 19 29 39 0B 1B 2B 3B 0D 1D 2D 3D 0F 1F 2F 3F)
-
- movdqa xmmD, xmmA
- punpckldq xmmA, xmmB ; xmmA=(00 10 20 30 01 11 21 31 02 12 22 32 03 13 23 33)
- punpckhdq xmmD, xmmB ; xmmD=(04 14 24 34 05 15 25 35 06 16 26 36 07 17 27 37)
- movdqa xmmH, xmmC
- punpckldq xmmC, xmmG ; xmmC=(08 18 28 38 09 19 29 39 0A 1A 2A 3A 0B 1B 2B 3B)
- punpckhdq xmmH, xmmG ; xmmH=(0C 1C 2C 3C 0D 1D 2D 3D 0E 1E 2E 3E 0F 1F 2F 3F)
-
- cmp rcx, byte SIZEOF_XMMWORD
- jb short .column_st32
-
- test rdi, SIZEOF_XMMWORD-1
- jnz short .out1
- ; --(aligned)-------------------
- movntdq XMMWORD [rdi+0*SIZEOF_XMMWORD], xmmA
- movntdq XMMWORD [rdi+1*SIZEOF_XMMWORD], xmmD
- movntdq XMMWORD [rdi+2*SIZEOF_XMMWORD], xmmC
- movntdq XMMWORD [rdi+3*SIZEOF_XMMWORD], xmmH
- jmp short .out0
-.out1: ; --(unaligned)-----------------
- movdqu XMMWORD [rdi+0*SIZEOF_XMMWORD], xmmA
- movdqu XMMWORD [rdi+1*SIZEOF_XMMWORD], xmmD
- movdqu XMMWORD [rdi+2*SIZEOF_XMMWORD], xmmC
- movdqu XMMWORD [rdi+3*SIZEOF_XMMWORD], xmmH
-.out0:
- add rdi, byte RGB_PIXELSIZE*SIZEOF_XMMWORD ; outptr
- sub rcx, byte SIZEOF_XMMWORD
- jz near .endcolumn
-
- add rsi, byte SIZEOF_XMMWORD ; inptr0
- dec al ; Yctr
- jnz near .Yloop_2nd
-
- add rbx, byte SIZEOF_XMMWORD ; inptr1
- add rdx, byte SIZEOF_XMMWORD ; inptr2
- jmp near .columnloop
-
-.column_st32:
- cmp rcx, byte SIZEOF_XMMWORD/2
- jb short .column_st16
- movdqu XMMWORD [rdi+0*SIZEOF_XMMWORD], xmmA
- movdqu XMMWORD [rdi+1*SIZEOF_XMMWORD], xmmD
- add rdi, byte 2*SIZEOF_XMMWORD ; outptr
- movdqa xmmA, xmmC
- movdqa xmmD, xmmH
- sub rcx, byte SIZEOF_XMMWORD/2
-.column_st16:
- cmp rcx, byte SIZEOF_XMMWORD/4
- jb short .column_st15
- movdqu XMMWORD [rdi+0*SIZEOF_XMMWORD], xmmA
- add rdi, byte SIZEOF_XMMWORD ; outptr
- movdqa xmmA, xmmD
- sub rcx, byte SIZEOF_XMMWORD/4
-.column_st15:
- ; Store two pixels (8 bytes) of xmmA to the output when it has enough
- ; space.
- cmp rcx, byte SIZEOF_XMMWORD/8
- jb short .column_st7
- movq XMM_MMWORD [rdi], xmmA
- add rdi, byte SIZEOF_XMMWORD/8*4
- sub rcx, byte SIZEOF_XMMWORD/8
- psrldq xmmA, SIZEOF_XMMWORD/8*4
-.column_st7:
- ; Store one pixel (4 bytes) of xmmA to the output when it has enough
- ; space.
- test rcx, rcx
- jz short .endcolumn
- movd XMM_DWORD [rdi], xmmA
-
-%endif ; RGB_PIXELSIZE ; ---------------
-
-.endcolumn:
- sfence ; flush the write buffer
-
-.return:
- pop rbx
- uncollect_args 4
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
- pop rbp
- ret
-
-; --------------------------------------------------------------------------
-;
-; Upsample and color convert for the case of 2:1 horizontal and 2:1 vertical.
-;
-; GLOBAL(void)
-; jsimd_h2v2_merged_upsample_sse2(JDIMENSION output_width,
-; JSAMPIMAGE input_buf,
-; JDIMENSION in_row_group_ctr,
-; JSAMPARRAY output_buf);
-;
-
-; r10d = JDIMENSION output_width
-; r11 = JSAMPIMAGE input_buf
-; r12d = JDIMENSION in_row_group_ctr
-; r13 = JSAMPARRAY output_buf
-
- align 32
- GLOBAL_FUNCTION(jsimd_h2v2_merged_upsample_sse2)
-
-EXTN(jsimd_h2v2_merged_upsample_sse2):
- push rbp
- mov rax, rsp
- mov rbp, rsp
- collect_args 4
- push rbx
-
- mov eax, r10d
-
- mov rdi, r11
- mov ecx, r12d
- mov rsip, JSAMPARRAY [rdi+0*SIZEOF_JSAMPARRAY]
- mov rbxp, JSAMPARRAY [rdi+1*SIZEOF_JSAMPARRAY]
- mov rdxp, JSAMPARRAY [rdi+2*SIZEOF_JSAMPARRAY]
- mov rdi, r13
- lea rsi, [rsi+rcx*SIZEOF_JSAMPROW]
-
- sub rsp, SIZEOF_JSAMPARRAY*4
- mov JSAMPARRAY [rsp+0*SIZEOF_JSAMPARRAY], rsip ; intpr00
- mov JSAMPARRAY [rsp+1*SIZEOF_JSAMPARRAY], rbxp ; intpr1
- mov JSAMPARRAY [rsp+2*SIZEOF_JSAMPARRAY], rdxp ; intpr2
- mov rbx, rsp
-
- push rdi
- push rcx
- push rax
-
- %ifdef WIN64
- mov r8, rcx
- mov r9, rdi
- mov rcx, rax
- mov rdx, rbx
- %else
- mov rdx, rcx
- mov rcx, rdi
- mov rdi, rax
- mov rsi, rbx
- %endif
-
- call EXTN(jsimd_h2v1_merged_upsample_sse2)
-
- pop rax
- pop rcx
- pop rdi
- mov rsip, JSAMPARRAY [rsp+0*SIZEOF_JSAMPARRAY]
- mov rbxp, JSAMPARRAY [rsp+1*SIZEOF_JSAMPARRAY]
- mov rdxp, JSAMPARRAY [rsp+2*SIZEOF_JSAMPARRAY]
-
- add rdi, byte SIZEOF_JSAMPROW ; outptr1
- add rsi, byte SIZEOF_JSAMPROW ; inptr01
-
- mov JSAMPARRAY [rsp+0*SIZEOF_JSAMPARRAY], rsip ; intpr00
- mov JSAMPARRAY [rsp+1*SIZEOF_JSAMPARRAY], rbxp ; intpr1
- mov JSAMPARRAY [rsp+2*SIZEOF_JSAMPARRAY], rdxp ; intpr2
- mov rbx, rsp
-
- push rdi
- push rcx
- push rax
-
- %ifdef WIN64
- mov r8, rcx
- mov r9, rdi
- mov rcx, rax
- mov rdx, rbx
- %else
- mov rdx, rcx
- mov rcx, rdi
- mov rdi, rax
- mov rsi, rbx
- %endif
-
- call EXTN(jsimd_h2v1_merged_upsample_sse2)
-
- pop rax
- pop rcx
- pop rdi
- mov rsip, JSAMPARRAY [rsp+0*SIZEOF_JSAMPARRAY]
- mov rbxp, JSAMPARRAY [rsp+1*SIZEOF_JSAMPARRAY]
- mov rdxp, JSAMPARRAY [rsp+2*SIZEOF_JSAMPARRAY]
- add rsp, SIZEOF_JSAMPARRAY*4
-
- pop rbx
- uncollect_args 4
- pop rbp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jdsample-avx2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jdsample-avx2.asm
deleted file mode 100644
index 1e4979f933..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jdsample-avx2.asm
+++ /dev/null
@@ -1,696 +0,0 @@
-;
-; jdsample.asm - upsampling (64-bit AVX2)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
-; Copyright (C) 2015, Intel Corporation.
-; Copyright (C) 2018, Matthias Räncker.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jsimdext.inc"
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_fancy_upsample_avx2)
-
-EXTN(jconst_fancy_upsample_avx2):
-
-PW_ONE times 16 dw 1
-PW_TWO times 16 dw 2
-PW_THREE times 16 dw 3
-PW_SEVEN times 16 dw 7
-PW_EIGHT times 16 dw 8
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 64
-;
-; Fancy processing for the common case of 2:1 horizontal and 1:1 vertical.
-;
-; The upsampling algorithm is linear interpolation between pixel centers,
-; also known as a "triangle filter". This is a good compromise between
-; speed and visual quality. The centers of the output pixels are 1/4 and 3/4
-; of the way between input pixel centers.
-;
-; GLOBAL(void)
-; jsimd_h2v1_fancy_upsample_avx2(int max_v_samp_factor,
-; JDIMENSION downsampled_width,
-; JSAMPARRAY input_data,
-; JSAMPARRAY *output_data_ptr);
-;
-
-; r10 = int max_v_samp_factor
-; r11d = JDIMENSION downsampled_width
-; r12 = JSAMPARRAY input_data
-; r13 = JSAMPARRAY *output_data_ptr
-
- align 32
- GLOBAL_FUNCTION(jsimd_h2v1_fancy_upsample_avx2)
-
-EXTN(jsimd_h2v1_fancy_upsample_avx2):
- push rbp
- mov rax, rsp
- mov rbp, rsp
- push_xmm 3
- collect_args 4
-
- mov eax, r11d ; colctr
- test rax, rax
- jz near .return
-
- mov rcx, r10 ; rowctr
- test rcx, rcx
- jz near .return
-
- mov rsi, r12 ; input_data
- mov rdi, r13
- mov rdip, JSAMPARRAY [rdi] ; output_data
-
- vpxor ymm0, ymm0, ymm0 ; ymm0=(all 0's)
- vpcmpeqb xmm9, xmm9, xmm9
- vpsrldq xmm10, xmm9, (SIZEOF_XMMWORD-1) ; (ff -- -- -- ... -- --) LSB is ff
-
- vpslldq xmm9, xmm9, (SIZEOF_XMMWORD-1)
- vperm2i128 ymm9, ymm9, ymm9, 1 ; (---- ---- ... ---- ---- ff) MSB is ff
-
-.rowloop:
- push rax ; colctr
- push rdi
- push rsi
-
- mov rsip, JSAMPROW [rsi] ; inptr
- mov rdip, JSAMPROW [rdi] ; outptr
-
- test rax, SIZEOF_YMMWORD-1
- jz short .skip
- mov dl, JSAMPLE [rsi+(rax-1)*SIZEOF_JSAMPLE]
- mov JSAMPLE [rsi+rax*SIZEOF_JSAMPLE], dl ; insert a dummy sample
-.skip:
- vpand ymm7, ymm10, YMMWORD [rsi+0*SIZEOF_YMMWORD]
-
- add rax, byte SIZEOF_YMMWORD-1
- and rax, byte -SIZEOF_YMMWORD
- cmp rax, byte SIZEOF_YMMWORD
- ja short .columnloop
-
-.columnloop_last:
- vpand ymm6, ymm9, YMMWORD [rsi+0*SIZEOF_YMMWORD]
- jmp short .upsample
-
-.columnloop:
- vmovdqu ymm6, YMMWORD [rsi+1*SIZEOF_YMMWORD]
- vperm2i128 ymm6, ymm0, ymm6, 0x20
- vpslldq ymm6, ymm6, 15
-
-.upsample:
- vmovdqu ymm1, YMMWORD [rsi+0*SIZEOF_YMMWORD] ; ymm1=( 0 1 2 ... 29 30 31)
-
- vperm2i128 ymm2, ymm0, ymm1, 0x20
- vpalignr ymm2, ymm1, ymm2, 15 ; ymm2=(-- 0 1 ... 28 29 30)
- vperm2i128 ymm4, ymm0, ymm1, 0x03
- vpalignr ymm3, ymm4, ymm1, 1 ; ymm3=( 1 2 3 ... 30 31 --)
-
- vpor ymm2, ymm2, ymm7 ; ymm2=(-1 0 1 ... 28 29 30)
- vpor ymm3, ymm3, ymm6 ; ymm3=( 1 2 3 ... 30 31 32)
-
- vpsrldq ymm7, ymm4, (SIZEOF_XMMWORD-1) ; ymm7=(31 -- -- ... -- -- --)
-
- vpunpckhbw ymm4, ymm1, ymm0 ; ymm4=( 8 9 10 11 12 13 14 15 24 25 26 27 28 29 30 31)
- vpunpcklbw ymm5, ymm1, ymm0 ; ymm5=( 0 1 2 3 4 5 6 7 16 17 18 19 20 21 22 23)
- vperm2i128 ymm1, ymm5, ymm4, 0x20 ; ymm1=( 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)
- vperm2i128 ymm4, ymm5, ymm4, 0x31 ; ymm4=(16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31)
-
- vpunpckhbw ymm5, ymm2, ymm0 ; ymm5=( 7 8 9 10 11 12 13 14 23 24 25 26 27 28 29 30)
- vpunpcklbw ymm6, ymm2, ymm0 ; ymm6=(-1 0 1 2 3 4 5 6 15 16 17 18 19 20 21 22)
- vperm2i128 ymm2, ymm6, ymm5, 0x20 ; ymm2=(-1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14)
- vperm2i128 ymm5, ymm6, ymm5, 0x31 ; ymm5=(15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30)
-
- vpunpckhbw ymm6, ymm3, ymm0 ; ymm6=( 1 2 3 4 5 6 7 8 17 18 19 20 21 22 23 24)
- vpunpcklbw ymm8, ymm3, ymm0 ; ymm8=( 9 10 11 12 13 14 15 16 25 26 27 28 29 30 31 32)
- vperm2i128 ymm3, ymm8, ymm6, 0x20 ; ymm3=( 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16)
- vperm2i128 ymm6, ymm8, ymm6, 0x31 ; ymm6=(17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32)
-
- vpmullw ymm1, ymm1, [rel PW_THREE]
- vpmullw ymm4, ymm4, [rel PW_THREE]
- vpaddw ymm2, ymm2, [rel PW_ONE]
- vpaddw ymm5, ymm5, [rel PW_ONE]
- vpaddw ymm3, ymm3, [rel PW_TWO]
- vpaddw ymm6, ymm6, [rel PW_TWO]
-
- vpaddw ymm2, ymm2, ymm1
- vpaddw ymm5, ymm5, ymm4
- vpsrlw ymm2, ymm2, 2 ; ymm2=OutLE=( 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30)
- vpsrlw ymm5, ymm5, 2 ; ymm5=OutHE=(32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62)
- vpaddw ymm3, ymm3, ymm1
- vpaddw ymm6, ymm6, ymm4
- vpsrlw ymm3, ymm3, 2 ; ymm3=OutLO=( 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31)
- vpsrlw ymm6, ymm6, 2 ; ymm6=OutHO=(33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63)
-
- vpsllw ymm3, ymm3, BYTE_BIT
- vpsllw ymm6, ymm6, BYTE_BIT
- vpor ymm2, ymm2, ymm3 ; ymm2=OutL=( 0 1 2 ... 29 30 31)
- vpor ymm5, ymm5, ymm6 ; ymm5=OutH=(32 33 34 ... 61 62 63)
-
- vmovdqu YMMWORD [rdi+0*SIZEOF_YMMWORD], ymm2
- vmovdqu YMMWORD [rdi+1*SIZEOF_YMMWORD], ymm5
-
- sub rax, byte SIZEOF_YMMWORD
- add rsi, byte 1*SIZEOF_YMMWORD ; inptr
- add rdi, byte 2*SIZEOF_YMMWORD ; outptr
- cmp rax, byte SIZEOF_YMMWORD
- ja near .columnloop
- test eax, eax
- jnz near .columnloop_last
-
- pop rsi
- pop rdi
- pop rax
-
- add rsi, byte SIZEOF_JSAMPROW ; input_data
- add rdi, byte SIZEOF_JSAMPROW ; output_data
- dec rcx ; rowctr
- jg near .rowloop
-
-.return:
- vzeroupper
- uncollect_args 4
- pop_xmm 3
- pop rbp
- ret
-
-; --------------------------------------------------------------------------
-;
-; Fancy processing for the common case of 2:1 horizontal and 2:1 vertical.
-; Again a triangle filter; see comments for h2v1 case, above.
-;
-; GLOBAL(void)
-; jsimd_h2v2_fancy_upsample_avx2(int max_v_samp_factor,
-; JDIMENSION downsampled_width,
-; JSAMPARRAY input_data,
-; JSAMPARRAY *output_data_ptr);
-;
-
-; r10 = int max_v_samp_factor
-; r11d = JDIMENSION downsampled_width
-; r12 = JSAMPARRAY input_data
-; r13 = JSAMPARRAY *output_data_ptr
-
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_YMMWORD ; ymmword wk[WK_NUM]
-%define WK_NUM 4
-
- align 32
- GLOBAL_FUNCTION(jsimd_h2v2_fancy_upsample_avx2)
-
-EXTN(jsimd_h2v2_fancy_upsample_avx2):
- push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
- and rsp, byte (-SIZEOF_YMMWORD) ; align to 256 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
- push_xmm 3
- collect_args 4
- push rbx
-
- mov eax, r11d ; colctr
- test rax, rax
- jz near .return
-
- mov rcx, r10 ; rowctr
- test rcx, rcx
- jz near .return
-
- mov rsi, r12 ; input_data
- mov rdi, r13
- mov rdip, JSAMPARRAY [rdi] ; output_data
-.rowloop:
- push rax ; colctr
- push rcx
- push rdi
- push rsi
-
- mov rcxp, JSAMPROW [rsi-1*SIZEOF_JSAMPROW] ; inptr1(above)
- mov rbxp, JSAMPROW [rsi+0*SIZEOF_JSAMPROW] ; inptr0
- mov rsip, JSAMPROW [rsi+1*SIZEOF_JSAMPROW] ; inptr1(below)
- mov rdxp, JSAMPROW [rdi+0*SIZEOF_JSAMPROW] ; outptr0
- mov rdip, JSAMPROW [rdi+1*SIZEOF_JSAMPROW] ; outptr1
-
- vpxor ymm8, ymm8, ymm8 ; ymm8=(all 0's)
- vpcmpeqb xmm9, xmm9, xmm9
- vpsrldq xmm10, xmm9, (SIZEOF_XMMWORD-2) ; (ffff ---- ---- ... ---- ----) LSB is ffff
- vpslldq xmm9, xmm9, (SIZEOF_XMMWORD-2)
- vperm2i128 ymm9, ymm9, ymm9, 1 ; (---- ---- ... ---- ---- ffff) MSB is ffff
-
- test rax, SIZEOF_YMMWORD-1
- jz short .skip
- push rdx
- mov dl, JSAMPLE [rcx+(rax-1)*SIZEOF_JSAMPLE]
- mov JSAMPLE [rcx+rax*SIZEOF_JSAMPLE], dl
- mov dl, JSAMPLE [rbx+(rax-1)*SIZEOF_JSAMPLE]
- mov JSAMPLE [rbx+rax*SIZEOF_JSAMPLE], dl
- mov dl, JSAMPLE [rsi+(rax-1)*SIZEOF_JSAMPLE]
- mov JSAMPLE [rsi+rax*SIZEOF_JSAMPLE], dl ; insert a dummy sample
- pop rdx
-.skip:
- ; -- process the first column block
-
- vmovdqu ymm0, YMMWORD [rbx+0*SIZEOF_YMMWORD] ; ymm0=row[ 0][0]
- vmovdqu ymm1, YMMWORD [rcx+0*SIZEOF_YMMWORD] ; ymm1=row[-1][0]
- vmovdqu ymm2, YMMWORD [rsi+0*SIZEOF_YMMWORD] ; ymm2=row[+1][0]
-
- vpunpckhbw ymm4, ymm0, ymm8 ; ymm4=row[ 0]( 8 9 10 11 12 13 14 15 24 25 26 27 28 29 30 31)
- vpunpcklbw ymm5, ymm0, ymm8 ; ymm5=row[ 0]( 0 1 2 3 4 5 6 7 16 17 18 19 20 21 22 23)
- vperm2i128 ymm0, ymm5, ymm4, 0x20 ; ymm0=row[ 0]( 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)
- vperm2i128 ymm4, ymm5, ymm4, 0x31 ; ymm4=row[ 0](16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31)
-
- vpunpckhbw ymm5, ymm1, ymm8 ; ymm5=row[-1]( 8 9 10 11 12 13 14 15 24 25 26 27 28 29 30 31)
- vpunpcklbw ymm6, ymm1, ymm8 ; ymm6=row[-1]( 0 1 2 3 4 5 6 7 16 17 18 19 20 21 22 23)
- vperm2i128 ymm1, ymm6, ymm5, 0x20 ; ymm1=row[-1]( 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)
- vperm2i128 ymm5, ymm6, ymm5, 0x31 ; ymm5=row[-1](16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31)
-
- vpunpckhbw ymm6, ymm2, ymm8 ; ymm6=row[+1]( 8 9 10 11 12 13 14 15 24 25 26 27 28 29 30 31)
- vpunpcklbw ymm3, ymm2, ymm8 ; ymm3=row[+1]( 0 1 2 3 4 5 6 7 16 17 18 19 20 21 22 23)
- vperm2i128 ymm2, ymm3, ymm6, 0x20 ; ymm2=row[+1]( 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)
- vperm2i128 ymm6, ymm3, ymm6, 0x31 ; ymm6=row[+1](16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31)
-
- vpmullw ymm0, ymm0, [rel PW_THREE]
- vpmullw ymm4, ymm4, [rel PW_THREE]
-
- vpaddw ymm1, ymm1, ymm0 ; ymm1=Int0L=( 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)
- vpaddw ymm5, ymm5, ymm4 ; ymm5=Int0H=(16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31)
- vpaddw ymm2, ymm2, ymm0 ; ymm2=Int1L=( 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)
- vpaddw ymm6, ymm6, ymm4 ; ymm6=Int1H=(16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31)
-
- vmovdqu YMMWORD [rdx+0*SIZEOF_YMMWORD], ymm1 ; temporarily save
- vmovdqu YMMWORD [rdx+1*SIZEOF_YMMWORD], ymm5 ; the intermediate data
- vmovdqu YMMWORD [rdi+0*SIZEOF_YMMWORD], ymm2
- vmovdqu YMMWORD [rdi+1*SIZEOF_YMMWORD], ymm6
-
- vpand ymm1, ymm1, ymm10 ; ymm1=( 0 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --)
- vpand ymm2, ymm2, ymm10 ; ymm2=( 0 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --)
-
- vmovdqa YMMWORD [wk(0)], ymm1
- vmovdqa YMMWORD [wk(1)], ymm2
-
- add rax, byte SIZEOF_YMMWORD-1
- and rax, byte -SIZEOF_YMMWORD
- cmp rax, byte SIZEOF_YMMWORD
- ja short .columnloop
-
-.columnloop_last:
- ; -- process the last column block
-
- vpand ymm1, ymm9, YMMWORD [rdx+1*SIZEOF_YMMWORD]
- vpand ymm2, ymm9, YMMWORD [rdi+1*SIZEOF_YMMWORD]
-
- vmovdqa YMMWORD [wk(2)], ymm1 ; ymm1=(-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 31)
- vmovdqa YMMWORD [wk(3)], ymm2 ; ymm2=(-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 31)
-
- jmp near .upsample
-
-.columnloop:
- ; -- process the next column block
-
- vmovdqu ymm0, YMMWORD [rbx+1*SIZEOF_YMMWORD] ; ymm0=row[ 0][1]
- vmovdqu ymm1, YMMWORD [rcx+1*SIZEOF_YMMWORD] ; ymm1=row[-1][1]
- vmovdqu ymm2, YMMWORD [rsi+1*SIZEOF_YMMWORD] ; ymm2=row[+1][1]
-
- vpunpckhbw ymm4, ymm0, ymm8 ; ymm4=row[ 0]( 8 9 10 11 12 13 14 15 24 25 26 27 28 29 30 31)
- vpunpcklbw ymm5, ymm0, ymm8 ; ymm5=row[ 0]( 0 1 2 3 4 5 6 7 16 17 18 19 20 21 22 23)
- vperm2i128 ymm0, ymm5, ymm4, 0x20 ; ymm0=row[ 0]( 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)
- vperm2i128 ymm4, ymm5, ymm4, 0x31 ; ymm4=row[ 0](16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31)
-
- vpunpckhbw ymm5, ymm1, ymm8 ; ymm5=row[-1]( 8 9 10 11 12 13 14 15 24 25 26 27 28 29 30 31)
- vpunpcklbw ymm6, ymm1, ymm8 ; ymm6=row[-1]( 0 1 2 3 4 5 6 7 16 17 18 19 20 21 22 23)
- vperm2i128 ymm1, ymm6, ymm5, 0x20 ; ymm1=row[-1]( 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)
- vperm2i128 ymm5, ymm6, ymm5, 0x31 ; ymm5=row[-1](16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31)
-
- vpunpckhbw ymm6, ymm2, ymm8 ; ymm6=row[+1]( 8 9 10 11 12 13 14 15 24 25 26 27 28 29 30 31)
- vpunpcklbw ymm7, ymm2, ymm8 ; ymm7=row[+1]( 0 1 2 3 4 5 6 7 16 17 18 19 20 21 22 23)
- vperm2i128 ymm2, ymm7, ymm6, 0x20 ; ymm2=row[+1]( 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)
- vperm2i128 ymm6, ymm7, ymm6, 0x31 ; ymm6=row[+1](16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31)
-
- vpmullw ymm0, ymm0, [rel PW_THREE]
- vpmullw ymm4, ymm4, [rel PW_THREE]
-
- vpaddw ymm1, ymm1, ymm0 ; ymm1=Int0L=( 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)
- vpaddw ymm5, ymm5, ymm4 ; ymm5=Int0H=(16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31)
- vpaddw ymm2, ymm2, ymm0 ; ymm2=Int1L=( 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)
- vpaddw ymm6, ymm6, ymm4 ; ymm6=Int1H=(16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31)
-
- vmovdqu YMMWORD [rdx+2*SIZEOF_YMMWORD], ymm1 ; temporarily save
- vmovdqu YMMWORD [rdx+3*SIZEOF_YMMWORD], ymm5 ; the intermediate data
- vmovdqu YMMWORD [rdi+2*SIZEOF_YMMWORD], ymm2
- vmovdqu YMMWORD [rdi+3*SIZEOF_YMMWORD], ymm6
-
- vperm2i128 ymm1, ymm8, ymm1, 0x20
- vpslldq ymm1, ymm1, 14 ; ymm1=(-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 0)
- vperm2i128 ymm2, ymm8, ymm2, 0x20
- vpslldq ymm2, ymm2, 14 ; ymm2=(-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 0)
-
- vmovdqa YMMWORD [wk(2)], ymm1
- vmovdqa YMMWORD [wk(3)], ymm2
-
-.upsample:
- ; -- process the upper row
-
- vmovdqu ymm7, YMMWORD [rdx+0*SIZEOF_YMMWORD] ; ymm7=Int0L=( 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)
- vmovdqu ymm3, YMMWORD [rdx+1*SIZEOF_YMMWORD] ; ymm3=Int0H=(16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31)
-
- vperm2i128 ymm0, ymm8, ymm7, 0x03
- vpalignr ymm0, ymm0, ymm7, 2 ; ymm0=( 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 --)
- vperm2i128 ymm4, ymm8, ymm3, 0x20
- vpslldq ymm4, ymm4, 14 ; ymm4=(-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 16)
-
- vperm2i128 ymm5, ymm8, ymm7, 0x03
- vpsrldq ymm5, ymm5, 14 ; ymm5=(15 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --)
- vperm2i128 ymm6, ymm8, ymm3, 0x20
- vpalignr ymm6, ymm3, ymm6, 14 ; ymm6=(-- 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30)
-
- vpor ymm0, ymm0, ymm4 ; ymm0=( 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16)
- vpor ymm5, ymm5, ymm6 ; ymm5=(15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30)
-
- vperm2i128 ymm2, ymm8, ymm3, 0x03
- vpalignr ymm2, ymm2, ymm3, 2 ; ymm2=(17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 --)
- vperm2i128 ymm4, ymm8, ymm3, 0x03
- vpsrldq ymm4, ymm4, 14 ; ymm4=(31 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --)
- vperm2i128 ymm1, ymm8, ymm7, 0x20
- vpalignr ymm1, ymm7, ymm1, 14 ; ymm1=(-- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14)
-
- vpor ymm1, ymm1, YMMWORD [wk(0)] ; ymm1=(-1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14)
- vpor ymm2, ymm2, YMMWORD [wk(2)] ; ymm2=(17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32)
-
- vmovdqa YMMWORD [wk(0)], ymm4
-
- vpmullw ymm7, ymm7, [rel PW_THREE]
- vpmullw ymm3, ymm3, [rel PW_THREE]
- vpaddw ymm1, ymm1, [rel PW_EIGHT]
- vpaddw ymm5, ymm5, [rel PW_EIGHT]
- vpaddw ymm0, ymm0, [rel PW_SEVEN]
- vpaddw ymm2, [rel PW_SEVEN]
-
- vpaddw ymm1, ymm1, ymm7
- vpaddw ymm5, ymm5, ymm3
- vpsrlw ymm1, ymm1, 4 ; ymm1=Out0LE=( 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30)
- vpsrlw ymm5, ymm5, 4 ; ymm5=Out0HE=(32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62)
- vpaddw ymm0, ymm0, ymm7
- vpaddw ymm2, ymm2, ymm3
- vpsrlw ymm0, ymm0, 4 ; ymm0=Out0LO=( 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31)
- vpsrlw ymm2, ymm2, 4 ; ymm2=Out0HO=(33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63)
-
- vpsllw ymm0, ymm0, BYTE_BIT
- vpsllw ymm2, ymm2, BYTE_BIT
- vpor ymm1, ymm1, ymm0 ; ymm1=Out0L=( 0 1 2 ... 29 30 31)
- vpor ymm5, ymm5, ymm2 ; ymm5=Out0H=(32 33 34 ... 61 62 63)
-
- vmovdqu YMMWORD [rdx+0*SIZEOF_YMMWORD], ymm1
- vmovdqu YMMWORD [rdx+1*SIZEOF_YMMWORD], ymm5
-
- ; -- process the lower row
-
- vmovdqu ymm6, YMMWORD [rdi+0*SIZEOF_YMMWORD] ; ymm6=Int1L=( 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)
- vmovdqu ymm4, YMMWORD [rdi+1*SIZEOF_YMMWORD] ; ymm4=Int1H=(16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31)
-
- vperm2i128 ymm7, ymm8, ymm6, 0x03
- vpalignr ymm7, ymm7, ymm6, 2 ; ymm7=( 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 --)
- vperm2i128 ymm3, ymm8, ymm4, 0x20
- vpslldq ymm3, ymm3, 14 ; ymm3=(-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 16)
-
- vperm2i128 ymm0, ymm8, ymm6, 0x03
- vpsrldq ymm0, ymm0, 14 ; ymm0=(15 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --)
- vperm2i128 ymm2, ymm8, ymm4, 0x20
- vpalignr ymm2, ymm4, ymm2, 14 ; ymm2=(-- 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30)
-
- vpor ymm7, ymm7, ymm3 ; ymm7=( 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16)
- vpor ymm0, ymm0, ymm2 ; ymm0=(15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30)
-
- vperm2i128 ymm5, ymm8, ymm4, 0x03
- vpalignr ymm5, ymm5, ymm4, 2 ; ymm5=(17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 --)
- vperm2i128 ymm3, ymm8, ymm4, 0x03
- vpsrldq ymm3, ymm3, 14 ; ymm3=(31 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --)
- vperm2i128 ymm1, ymm8, ymm6, 0x20
- vpalignr ymm1, ymm6, ymm1, 14 ; ymm1=(-- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14)
-
- vpor ymm1, ymm1, YMMWORD [wk(1)] ; ymm1=(-1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14)
- vpor ymm5, ymm5, YMMWORD [wk(3)] ; ymm5=(17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32)
-
- vmovdqa YMMWORD [wk(1)], ymm3
-
- vpmullw ymm6, ymm6, [rel PW_THREE]
- vpmullw ymm4, ymm4, [rel PW_THREE]
- vpaddw ymm1, ymm1, [rel PW_EIGHT]
- vpaddw ymm0, ymm0, [rel PW_EIGHT]
- vpaddw ymm7, ymm7, [rel PW_SEVEN]
- vpaddw ymm5, ymm5, [rel PW_SEVEN]
-
- vpaddw ymm1, ymm1, ymm6
- vpaddw ymm0, ymm0, ymm4
- vpsrlw ymm1, ymm1, 4 ; ymm1=Out1LE=( 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30)
- vpsrlw ymm0, ymm0, 4 ; ymm0=Out1HE=(32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62)
- vpaddw ymm7, ymm7, ymm6
- vpaddw ymm5, ymm5, ymm4
- vpsrlw ymm7, ymm7, 4 ; ymm7=Out1LO=( 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31)
- vpsrlw ymm5, ymm5, 4 ; ymm5=Out1HO=(33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63)
-
- vpsllw ymm7, ymm7, BYTE_BIT
- vpsllw ymm5, ymm5, BYTE_BIT
- vpor ymm1, ymm1, ymm7 ; ymm1=Out1L=( 0 1 2 ... 29 30 31)
- vpor ymm0, ymm0, ymm5 ; ymm0=Out1H=(32 33 34 ... 61 62 63)
-
- vmovdqu YMMWORD [rdi+0*SIZEOF_YMMWORD], ymm1
- vmovdqu YMMWORD [rdi+1*SIZEOF_YMMWORD], ymm0
-
- sub rax, byte SIZEOF_YMMWORD
- add rcx, byte 1*SIZEOF_YMMWORD ; inptr1(above)
- add rbx, byte 1*SIZEOF_YMMWORD ; inptr0
- add rsi, byte 1*SIZEOF_YMMWORD ; inptr1(below)
- add rdx, byte 2*SIZEOF_YMMWORD ; outptr0
- add rdi, byte 2*SIZEOF_YMMWORD ; outptr1
- cmp rax, byte SIZEOF_YMMWORD
- ja near .columnloop
- test rax, rax
- jnz near .columnloop_last
-
- pop rsi
- pop rdi
- pop rcx
- pop rax
-
- add rsi, byte 1*SIZEOF_JSAMPROW ; input_data
- add rdi, byte 2*SIZEOF_JSAMPROW ; output_data
- sub rcx, byte 2 ; rowctr
- jg near .rowloop
-
-.return:
- pop rbx
- vzeroupper
- uncollect_args 4
- pop_xmm 3
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
- pop rbp
- ret
-
-; --------------------------------------------------------------------------
-;
-; Fast processing for the common case of 2:1 horizontal and 1:1 vertical.
-; It's still a box filter.
-;
-; GLOBAL(void)
-; jsimd_h2v1_upsample_avx2(int max_v_samp_factor, JDIMENSION output_width,
-; JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr);
-;
-
-; r10 = int max_v_samp_factor
-; r11d = JDIMENSION output_width
-; r12 = JSAMPARRAY input_data
-; r13 = JSAMPARRAY *output_data_ptr
-
- align 32
- GLOBAL_FUNCTION(jsimd_h2v1_upsample_avx2)
-
-EXTN(jsimd_h2v1_upsample_avx2):
- push rbp
- mov rax, rsp
- mov rbp, rsp
- collect_args 4
-
- mov edx, r11d
- add rdx, byte (SIZEOF_YMMWORD-1)
- and rdx, -SIZEOF_YMMWORD
- jz near .return
-
- mov rcx, r10 ; rowctr
- test rcx, rcx
- jz short .return
-
- mov rsi, r12 ; input_data
- mov rdi, r13
- mov rdip, JSAMPARRAY [rdi] ; output_data
-.rowloop:
- push rdi
- push rsi
-
- mov rsip, JSAMPROW [rsi] ; inptr
- mov rdip, JSAMPROW [rdi] ; outptr
- mov rax, rdx ; colctr
-.columnloop:
-
- cmp rax, byte SIZEOF_YMMWORD
- ja near .above_16
-
- vmovdqu xmm0, XMMWORD [rsi+0*SIZEOF_YMMWORD]
- vpunpckhbw xmm1, xmm0, xmm0
- vpunpcklbw xmm0, xmm0, xmm0
-
- vmovdqu XMMWORD [rdi+0*SIZEOF_XMMWORD], xmm0
- vmovdqu XMMWORD [rdi+1*SIZEOF_XMMWORD], xmm1
-
- jmp short .nextrow
-
-.above_16:
- vmovdqu ymm0, YMMWORD [rsi+0*SIZEOF_YMMWORD]
-
- vpermq ymm0, ymm0, 0xd8
- vpunpckhbw ymm1, ymm0, ymm0
- vpunpcklbw ymm0, ymm0, ymm0
-
- vmovdqu YMMWORD [rdi+0*SIZEOF_YMMWORD], ymm0
- vmovdqu YMMWORD [rdi+1*SIZEOF_YMMWORD], ymm1
-
- sub rax, byte 2*SIZEOF_YMMWORD
- jz short .nextrow
-
- add rsi, byte SIZEOF_YMMWORD ; inptr
- add rdi, byte 2*SIZEOF_YMMWORD ; outptr
- jmp short .columnloop
-
-.nextrow:
- pop rsi
- pop rdi
-
- add rsi, byte SIZEOF_JSAMPROW ; input_data
- add rdi, byte SIZEOF_JSAMPROW ; output_data
- dec rcx ; rowctr
- jg short .rowloop
-
-.return:
- vzeroupper
- uncollect_args 4
- pop rbp
- ret
-
-; --------------------------------------------------------------------------
-;
-; Fast processing for the common case of 2:1 horizontal and 2:1 vertical.
-; It's still a box filter.
-;
-; GLOBAL(void)
-; jsimd_h2v2_upsample_avx2(int max_v_samp_factor, JDIMENSION output_width,
-; JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr);
-;
-
-; r10 = int max_v_samp_factor
-; r11d = JDIMENSION output_width
-; r12 = JSAMPARRAY input_data
-; r13 = JSAMPARRAY *output_data_ptr
-
- align 32
- GLOBAL_FUNCTION(jsimd_h2v2_upsample_avx2)
-
-EXTN(jsimd_h2v2_upsample_avx2):
- push rbp
- mov rax, rsp
- mov rbp, rsp
- collect_args 4
- push rbx
-
- mov edx, r11d
- add rdx, byte (SIZEOF_YMMWORD-1)
- and rdx, -SIZEOF_YMMWORD
- jz near .return
-
- mov rcx, r10 ; rowctr
- test rcx, rcx
- jz near .return
-
- mov rsi, r12 ; input_data
- mov rdi, r13
- mov rdip, JSAMPARRAY [rdi] ; output_data
-.rowloop:
- push rdi
- push rsi
-
- mov rsip, JSAMPROW [rsi] ; inptr
- mov rbxp, JSAMPROW [rdi+0*SIZEOF_JSAMPROW] ; outptr0
- mov rdip, JSAMPROW [rdi+1*SIZEOF_JSAMPROW] ; outptr1
- mov rax, rdx ; colctr
-.columnloop:
-
- cmp rax, byte SIZEOF_YMMWORD
- ja short .above_16
-
- vmovdqu xmm0, XMMWORD [rsi+0*SIZEOF_XMMWORD]
- vpunpckhbw xmm1, xmm0, xmm0
- vpunpcklbw xmm0, xmm0, xmm0
-
- vmovdqu XMMWORD [rbx+0*SIZEOF_XMMWORD], xmm0
- vmovdqu XMMWORD [rbx+1*SIZEOF_XMMWORD], xmm1
- vmovdqu XMMWORD [rdi+0*SIZEOF_XMMWORD], xmm0
- vmovdqu XMMWORD [rdi+1*SIZEOF_XMMWORD], xmm1
-
- jmp near .nextrow
-
-.above_16:
- vmovdqu ymm0, YMMWORD [rsi+0*SIZEOF_YMMWORD]
-
- vpermq ymm0, ymm0, 0xd8
- vpunpckhbw ymm1, ymm0, ymm0
- vpunpcklbw ymm0, ymm0, ymm0
-
- vmovdqu YMMWORD [rbx+0*SIZEOF_YMMWORD], ymm0
- vmovdqu YMMWORD [rbx+1*SIZEOF_YMMWORD], ymm1
- vmovdqu YMMWORD [rdi+0*SIZEOF_YMMWORD], ymm0
- vmovdqu YMMWORD [rdi+1*SIZEOF_YMMWORD], ymm1
-
- sub rax, byte 2*SIZEOF_YMMWORD
- jz short .nextrow
-
- add rsi, byte SIZEOF_YMMWORD ; inptr
- add rbx, 2*SIZEOF_YMMWORD ; outptr0
- add rdi, 2*SIZEOF_YMMWORD ; outptr1
- jmp short .columnloop
-
-.nextrow:
- pop rsi
- pop rdi
-
- add rsi, byte 1*SIZEOF_JSAMPROW ; input_data
- add rdi, byte 2*SIZEOF_JSAMPROW ; output_data
- sub rcx, byte 2 ; rowctr
- jg near .rowloop
-
-.return:
- pop rbx
- vzeroupper
- uncollect_args 4
- pop rbp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jdsample-sse2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jdsample-sse2.asm
deleted file mode 100644
index 38dbceec26..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jdsample-sse2.asm
+++ /dev/null
@@ -1,665 +0,0 @@
-;
-; jdsample.asm - upsampling (64-bit SSE2)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
-; Copyright (C) 2018, Matthias Räncker.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jsimdext.inc"
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_fancy_upsample_sse2)
-
-EXTN(jconst_fancy_upsample_sse2):
-
-PW_ONE times 8 dw 1
-PW_TWO times 8 dw 2
-PW_THREE times 8 dw 3
-PW_SEVEN times 8 dw 7
-PW_EIGHT times 8 dw 8
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 64
-;
-; Fancy processing for the common case of 2:1 horizontal and 1:1 vertical.
-;
-; The upsampling algorithm is linear interpolation between pixel centers,
-; also known as a "triangle filter". This is a good compromise between
-; speed and visual quality. The centers of the output pixels are 1/4 and 3/4
-; of the way between input pixel centers.
-;
-; GLOBAL(void)
-; jsimd_h2v1_fancy_upsample_sse2(int max_v_samp_factor,
-; JDIMENSION downsampled_width,
-; JSAMPARRAY input_data,
-; JSAMPARRAY *output_data_ptr);
-;
-
-; r10 = int max_v_samp_factor
-; r11d = JDIMENSION downsampled_width
-; r12 = JSAMPARRAY input_data
-; r13 = JSAMPARRAY *output_data_ptr
-
- align 32
- GLOBAL_FUNCTION(jsimd_h2v1_fancy_upsample_sse2)
-
-EXTN(jsimd_h2v1_fancy_upsample_sse2):
- push rbp
- mov rax, rsp
- mov rbp, rsp
- collect_args 4
-
- mov eax, r11d ; colctr
- test rax, rax
- jz near .return
-
- mov rcx, r10 ; rowctr
- test rcx, rcx
- jz near .return
-
- mov rsi, r12 ; input_data
- mov rdi, r13
- mov rdip, JSAMPARRAY [rdi] ; output_data
-.rowloop:
- push rax ; colctr
- push rdi
- push rsi
-
- mov rsip, JSAMPROW [rsi] ; inptr
- mov rdip, JSAMPROW [rdi] ; outptr
-
- test rax, SIZEOF_XMMWORD-1
- jz short .skip
- mov dl, JSAMPLE [rsi+(rax-1)*SIZEOF_JSAMPLE]
- mov JSAMPLE [rsi+rax*SIZEOF_JSAMPLE], dl ; insert a dummy sample
-.skip:
- pxor xmm0, xmm0 ; xmm0=(all 0's)
- pcmpeqb xmm7, xmm7
- psrldq xmm7, (SIZEOF_XMMWORD-1)
- pand xmm7, XMMWORD [rsi+0*SIZEOF_XMMWORD]
-
- add rax, byte SIZEOF_XMMWORD-1
- and rax, byte -SIZEOF_XMMWORD
- cmp rax, byte SIZEOF_XMMWORD
- ja short .columnloop
-
-.columnloop_last:
- pcmpeqb xmm6, xmm6
- pslldq xmm6, (SIZEOF_XMMWORD-1)
- pand xmm6, XMMWORD [rsi+0*SIZEOF_XMMWORD]
- jmp short .upsample
-
-.columnloop:
- movdqa xmm6, XMMWORD [rsi+1*SIZEOF_XMMWORD]
- pslldq xmm6, (SIZEOF_XMMWORD-1)
-
-.upsample:
- movdqa xmm1, XMMWORD [rsi+0*SIZEOF_XMMWORD]
- movdqa xmm2, xmm1
- movdqa xmm3, xmm1 ; xmm1=( 0 1 2 ... 13 14 15)
- pslldq xmm2, 1 ; xmm2=(-- 0 1 ... 12 13 14)
- psrldq xmm3, 1 ; xmm3=( 1 2 3 ... 14 15 --)
-
- por xmm2, xmm7 ; xmm2=(-1 0 1 ... 12 13 14)
- por xmm3, xmm6 ; xmm3=( 1 2 3 ... 14 15 16)
-
- movdqa xmm7, xmm1
- psrldq xmm7, (SIZEOF_XMMWORD-1) ; xmm7=(15 -- -- ... -- -- --)
-
- movdqa xmm4, xmm1
- punpcklbw xmm1, xmm0 ; xmm1=( 0 1 2 3 4 5 6 7)
- punpckhbw xmm4, xmm0 ; xmm4=( 8 9 10 11 12 13 14 15)
- movdqa xmm5, xmm2
- punpcklbw xmm2, xmm0 ; xmm2=(-1 0 1 2 3 4 5 6)
- punpckhbw xmm5, xmm0 ; xmm5=( 7 8 9 10 11 12 13 14)
- movdqa xmm6, xmm3
- punpcklbw xmm3, xmm0 ; xmm3=( 1 2 3 4 5 6 7 8)
- punpckhbw xmm6, xmm0 ; xmm6=( 9 10 11 12 13 14 15 16)
-
- pmullw xmm1, [rel PW_THREE]
- pmullw xmm4, [rel PW_THREE]
- paddw xmm2, [rel PW_ONE]
- paddw xmm5, [rel PW_ONE]
- paddw xmm3, [rel PW_TWO]
- paddw xmm6, [rel PW_TWO]
-
- paddw xmm2, xmm1
- paddw xmm5, xmm4
- psrlw xmm2, 2 ; xmm2=OutLE=( 0 2 4 6 8 10 12 14)
- psrlw xmm5, 2 ; xmm5=OutHE=(16 18 20 22 24 26 28 30)
- paddw xmm3, xmm1
- paddw xmm6, xmm4
- psrlw xmm3, 2 ; xmm3=OutLO=( 1 3 5 7 9 11 13 15)
- psrlw xmm6, 2 ; xmm6=OutHO=(17 19 21 23 25 27 29 31)
-
- psllw xmm3, BYTE_BIT
- psllw xmm6, BYTE_BIT
- por xmm2, xmm3 ; xmm2=OutL=( 0 1 2 ... 13 14 15)
- por xmm5, xmm6 ; xmm5=OutH=(16 17 18 ... 29 30 31)
-
- movdqa XMMWORD [rdi+0*SIZEOF_XMMWORD], xmm2
- movdqa XMMWORD [rdi+1*SIZEOF_XMMWORD], xmm5
-
- sub rax, byte SIZEOF_XMMWORD
- add rsi, byte 1*SIZEOF_XMMWORD ; inptr
- add rdi, byte 2*SIZEOF_XMMWORD ; outptr
- cmp rax, byte SIZEOF_XMMWORD
- ja near .columnloop
- test eax, eax
- jnz near .columnloop_last
-
- pop rsi
- pop rdi
- pop rax
-
- add rsi, byte SIZEOF_JSAMPROW ; input_data
- add rdi, byte SIZEOF_JSAMPROW ; output_data
- dec rcx ; rowctr
- jg near .rowloop
-
-.return:
- uncollect_args 4
- pop rbp
- ret
-
-; --------------------------------------------------------------------------
-;
-; Fancy processing for the common case of 2:1 horizontal and 2:1 vertical.
-; Again a triangle filter; see comments for h2v1 case, above.
-;
-; GLOBAL(void)
-; jsimd_h2v2_fancy_upsample_sse2(int max_v_samp_factor,
-; JDIMENSION downsampled_width,
-; JSAMPARRAY input_data,
-; JSAMPARRAY *output_data_ptr);
-;
-
-; r10 = int max_v_samp_factor
-; r11d = JDIMENSION downsampled_width
-; r12 = JSAMPARRAY input_data
-; r13 = JSAMPARRAY *output_data_ptr
-
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
-%define WK_NUM 4
-
- align 32
- GLOBAL_FUNCTION(jsimd_h2v2_fancy_upsample_sse2)
-
-EXTN(jsimd_h2v2_fancy_upsample_sse2):
- push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
- and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
- collect_args 4
- push rbx
-
- mov eax, r11d ; colctr
- test rax, rax
- jz near .return
-
- mov rcx, r10 ; rowctr
- test rcx, rcx
- jz near .return
-
- mov rsi, r12 ; input_data
- mov rdi, r13
- mov rdip, JSAMPARRAY [rdi] ; output_data
-.rowloop:
- push rax ; colctr
- push rcx
- push rdi
- push rsi
-
- mov rcxp, JSAMPROW [rsi-1*SIZEOF_JSAMPROW] ; inptr1(above)
- mov rbxp, JSAMPROW [rsi+0*SIZEOF_JSAMPROW] ; inptr0
- mov rsip, JSAMPROW [rsi+1*SIZEOF_JSAMPROW] ; inptr1(below)
- mov rdxp, JSAMPROW [rdi+0*SIZEOF_JSAMPROW] ; outptr0
- mov rdip, JSAMPROW [rdi+1*SIZEOF_JSAMPROW] ; outptr1
-
- test rax, SIZEOF_XMMWORD-1
- jz short .skip
- push rdx
- mov dl, JSAMPLE [rcx+(rax-1)*SIZEOF_JSAMPLE]
- mov JSAMPLE [rcx+rax*SIZEOF_JSAMPLE], dl
- mov dl, JSAMPLE [rbx+(rax-1)*SIZEOF_JSAMPLE]
- mov JSAMPLE [rbx+rax*SIZEOF_JSAMPLE], dl
- mov dl, JSAMPLE [rsi+(rax-1)*SIZEOF_JSAMPLE]
- mov JSAMPLE [rsi+rax*SIZEOF_JSAMPLE], dl ; insert a dummy sample
- pop rdx
-.skip:
- ; -- process the first column block
-
- movdqa xmm0, XMMWORD [rbx+0*SIZEOF_XMMWORD] ; xmm0=row[ 0][0]
- movdqa xmm1, XMMWORD [rcx+0*SIZEOF_XMMWORD] ; xmm1=row[-1][0]
- movdqa xmm2, XMMWORD [rsi+0*SIZEOF_XMMWORD] ; xmm2=row[+1][0]
-
- pxor xmm3, xmm3 ; xmm3=(all 0's)
- movdqa xmm4, xmm0
- punpcklbw xmm0, xmm3 ; xmm0=row[ 0]( 0 1 2 3 4 5 6 7)
- punpckhbw xmm4, xmm3 ; xmm4=row[ 0]( 8 9 10 11 12 13 14 15)
- movdqa xmm5, xmm1
- punpcklbw xmm1, xmm3 ; xmm1=row[-1]( 0 1 2 3 4 5 6 7)
- punpckhbw xmm5, xmm3 ; xmm5=row[-1]( 8 9 10 11 12 13 14 15)
- movdqa xmm6, xmm2
- punpcklbw xmm2, xmm3 ; xmm2=row[+1]( 0 1 2 3 4 5 6 7)
- punpckhbw xmm6, xmm3 ; xmm6=row[+1]( 8 9 10 11 12 13 14 15)
-
- pmullw xmm0, [rel PW_THREE]
- pmullw xmm4, [rel PW_THREE]
-
- pcmpeqb xmm7, xmm7
- psrldq xmm7, (SIZEOF_XMMWORD-2)
-
- paddw xmm1, xmm0 ; xmm1=Int0L=( 0 1 2 3 4 5 6 7)
- paddw xmm5, xmm4 ; xmm5=Int0H=( 8 9 10 11 12 13 14 15)
- paddw xmm2, xmm0 ; xmm2=Int1L=( 0 1 2 3 4 5 6 7)
- paddw xmm6, xmm4 ; xmm6=Int1H=( 8 9 10 11 12 13 14 15)
-
- movdqa XMMWORD [rdx+0*SIZEOF_XMMWORD], xmm1 ; temporarily save
- movdqa XMMWORD [rdx+1*SIZEOF_XMMWORD], xmm5 ; the intermediate data
- movdqa XMMWORD [rdi+0*SIZEOF_XMMWORD], xmm2
- movdqa XMMWORD [rdi+1*SIZEOF_XMMWORD], xmm6
-
- pand xmm1, xmm7 ; xmm1=( 0 -- -- -- -- -- -- --)
- pand xmm2, xmm7 ; xmm2=( 0 -- -- -- -- -- -- --)
-
- movdqa XMMWORD [wk(0)], xmm1
- movdqa XMMWORD [wk(1)], xmm2
-
- add rax, byte SIZEOF_XMMWORD-1
- and rax, byte -SIZEOF_XMMWORD
- cmp rax, byte SIZEOF_XMMWORD
- ja short .columnloop
-
-.columnloop_last:
- ; -- process the last column block
-
- pcmpeqb xmm1, xmm1
- pslldq xmm1, (SIZEOF_XMMWORD-2)
- movdqa xmm2, xmm1
-
- pand xmm1, XMMWORD [rdx+1*SIZEOF_XMMWORD]
- pand xmm2, XMMWORD [rdi+1*SIZEOF_XMMWORD]
-
- movdqa XMMWORD [wk(2)], xmm1 ; xmm1=(-- -- -- -- -- -- -- 15)
- movdqa XMMWORD [wk(3)], xmm2 ; xmm2=(-- -- -- -- -- -- -- 15)
-
- jmp near .upsample
-
-.columnloop:
- ; -- process the next column block
-
- movdqa xmm0, XMMWORD [rbx+1*SIZEOF_XMMWORD] ; xmm0=row[ 0][1]
- movdqa xmm1, XMMWORD [rcx+1*SIZEOF_XMMWORD] ; xmm1=row[-1][1]
- movdqa xmm2, XMMWORD [rsi+1*SIZEOF_XMMWORD] ; xmm2=row[+1][1]
-
- pxor xmm3, xmm3 ; xmm3=(all 0's)
- movdqa xmm4, xmm0
- punpcklbw xmm0, xmm3 ; xmm0=row[ 0]( 0 1 2 3 4 5 6 7)
- punpckhbw xmm4, xmm3 ; xmm4=row[ 0]( 8 9 10 11 12 13 14 15)
- movdqa xmm5, xmm1
- punpcklbw xmm1, xmm3 ; xmm1=row[-1]( 0 1 2 3 4 5 6 7)
- punpckhbw xmm5, xmm3 ; xmm5=row[-1]( 8 9 10 11 12 13 14 15)
- movdqa xmm6, xmm2
- punpcklbw xmm2, xmm3 ; xmm2=row[+1]( 0 1 2 3 4 5 6 7)
- punpckhbw xmm6, xmm3 ; xmm6=row[+1]( 8 9 10 11 12 13 14 15)
-
- pmullw xmm0, [rel PW_THREE]
- pmullw xmm4, [rel PW_THREE]
-
- paddw xmm1, xmm0 ; xmm1=Int0L=( 0 1 2 3 4 5 6 7)
- paddw xmm5, xmm4 ; xmm5=Int0H=( 8 9 10 11 12 13 14 15)
- paddw xmm2, xmm0 ; xmm2=Int1L=( 0 1 2 3 4 5 6 7)
- paddw xmm6, xmm4 ; xmm6=Int1H=( 8 9 10 11 12 13 14 15)
-
- movdqa XMMWORD [rdx+2*SIZEOF_XMMWORD], xmm1 ; temporarily save
- movdqa XMMWORD [rdx+3*SIZEOF_XMMWORD], xmm5 ; the intermediate data
- movdqa XMMWORD [rdi+2*SIZEOF_XMMWORD], xmm2
- movdqa XMMWORD [rdi+3*SIZEOF_XMMWORD], xmm6
-
- pslldq xmm1, (SIZEOF_XMMWORD-2) ; xmm1=(-- -- -- -- -- -- -- 0)
- pslldq xmm2, (SIZEOF_XMMWORD-2) ; xmm2=(-- -- -- -- -- -- -- 0)
-
- movdqa XMMWORD [wk(2)], xmm1
- movdqa XMMWORD [wk(3)], xmm2
-
-.upsample:
- ; -- process the upper row
-
- movdqa xmm7, XMMWORD [rdx+0*SIZEOF_XMMWORD]
- movdqa xmm3, XMMWORD [rdx+1*SIZEOF_XMMWORD]
-
- movdqa xmm0, xmm7 ; xmm7=Int0L=( 0 1 2 3 4 5 6 7)
- movdqa xmm4, xmm3 ; xmm3=Int0H=( 8 9 10 11 12 13 14 15)
- psrldq xmm0, 2 ; xmm0=( 1 2 3 4 5 6 7 --)
- pslldq xmm4, (SIZEOF_XMMWORD-2) ; xmm4=(-- -- -- -- -- -- -- 8)
- movdqa xmm5, xmm7
- movdqa xmm6, xmm3
- psrldq xmm5, (SIZEOF_XMMWORD-2) ; xmm5=( 7 -- -- -- -- -- -- --)
- pslldq xmm6, 2 ; xmm6=(-- 8 9 10 11 12 13 14)
-
- por xmm0, xmm4 ; xmm0=( 1 2 3 4 5 6 7 8)
- por xmm5, xmm6 ; xmm5=( 7 8 9 10 11 12 13 14)
-
- movdqa xmm1, xmm7
- movdqa xmm2, xmm3
- pslldq xmm1, 2 ; xmm1=(-- 0 1 2 3 4 5 6)
- psrldq xmm2, 2 ; xmm2=( 9 10 11 12 13 14 15 --)
- movdqa xmm4, xmm3
- psrldq xmm4, (SIZEOF_XMMWORD-2) ; xmm4=(15 -- -- -- -- -- -- --)
-
- por xmm1, XMMWORD [wk(0)] ; xmm1=(-1 0 1 2 3 4 5 6)
- por xmm2, XMMWORD [wk(2)] ; xmm2=( 9 10 11 12 13 14 15 16)
-
- movdqa XMMWORD [wk(0)], xmm4
-
- pmullw xmm7, [rel PW_THREE]
- pmullw xmm3, [rel PW_THREE]
- paddw xmm1, [rel PW_EIGHT]
- paddw xmm5, [rel PW_EIGHT]
- paddw xmm0, [rel PW_SEVEN]
- paddw xmm2, [rel PW_SEVEN]
-
- paddw xmm1, xmm7
- paddw xmm5, xmm3
- psrlw xmm1, 4 ; xmm1=Out0LE=( 0 2 4 6 8 10 12 14)
- psrlw xmm5, 4 ; xmm5=Out0HE=(16 18 20 22 24 26 28 30)
- paddw xmm0, xmm7
- paddw xmm2, xmm3
- psrlw xmm0, 4 ; xmm0=Out0LO=( 1 3 5 7 9 11 13 15)
- psrlw xmm2, 4 ; xmm2=Out0HO=(17 19 21 23 25 27 29 31)
-
- psllw xmm0, BYTE_BIT
- psllw xmm2, BYTE_BIT
- por xmm1, xmm0 ; xmm1=Out0L=( 0 1 2 ... 13 14 15)
- por xmm5, xmm2 ; xmm5=Out0H=(16 17 18 ... 29 30 31)
-
- movdqa XMMWORD [rdx+0*SIZEOF_XMMWORD], xmm1
- movdqa XMMWORD [rdx+1*SIZEOF_XMMWORD], xmm5
-
- ; -- process the lower row
-
- movdqa xmm6, XMMWORD [rdi+0*SIZEOF_XMMWORD]
- movdqa xmm4, XMMWORD [rdi+1*SIZEOF_XMMWORD]
-
- movdqa xmm7, xmm6 ; xmm6=Int1L=( 0 1 2 3 4 5 6 7)
- movdqa xmm3, xmm4 ; xmm4=Int1H=( 8 9 10 11 12 13 14 15)
- psrldq xmm7, 2 ; xmm7=( 1 2 3 4 5 6 7 --)
- pslldq xmm3, (SIZEOF_XMMWORD-2) ; xmm3=(-- -- -- -- -- -- -- 8)
- movdqa xmm0, xmm6
- movdqa xmm2, xmm4
- psrldq xmm0, (SIZEOF_XMMWORD-2) ; xmm0=( 7 -- -- -- -- -- -- --)
- pslldq xmm2, 2 ; xmm2=(-- 8 9 10 11 12 13 14)
-
- por xmm7, xmm3 ; xmm7=( 1 2 3 4 5 6 7 8)
- por xmm0, xmm2 ; xmm0=( 7 8 9 10 11 12 13 14)
-
- movdqa xmm1, xmm6
- movdqa xmm5, xmm4
- pslldq xmm1, 2 ; xmm1=(-- 0 1 2 3 4 5 6)
- psrldq xmm5, 2 ; xmm5=( 9 10 11 12 13 14 15 --)
- movdqa xmm3, xmm4
- psrldq xmm3, (SIZEOF_XMMWORD-2) ; xmm3=(15 -- -- -- -- -- -- --)
-
- por xmm1, XMMWORD [wk(1)] ; xmm1=(-1 0 1 2 3 4 5 6)
- por xmm5, XMMWORD [wk(3)] ; xmm5=( 9 10 11 12 13 14 15 16)
-
- movdqa XMMWORD [wk(1)], xmm3
-
- pmullw xmm6, [rel PW_THREE]
- pmullw xmm4, [rel PW_THREE]
- paddw xmm1, [rel PW_EIGHT]
- paddw xmm0, [rel PW_EIGHT]
- paddw xmm7, [rel PW_SEVEN]
- paddw xmm5, [rel PW_SEVEN]
-
- paddw xmm1, xmm6
- paddw xmm0, xmm4
- psrlw xmm1, 4 ; xmm1=Out1LE=( 0 2 4 6 8 10 12 14)
- psrlw xmm0, 4 ; xmm0=Out1HE=(16 18 20 22 24 26 28 30)
- paddw xmm7, xmm6
- paddw xmm5, xmm4
- psrlw xmm7, 4 ; xmm7=Out1LO=( 1 3 5 7 9 11 13 15)
- psrlw xmm5, 4 ; xmm5=Out1HO=(17 19 21 23 25 27 29 31)
-
- psllw xmm7, BYTE_BIT
- psllw xmm5, BYTE_BIT
- por xmm1, xmm7 ; xmm1=Out1L=( 0 1 2 ... 13 14 15)
- por xmm0, xmm5 ; xmm0=Out1H=(16 17 18 ... 29 30 31)
-
- movdqa XMMWORD [rdi+0*SIZEOF_XMMWORD], xmm1
- movdqa XMMWORD [rdi+1*SIZEOF_XMMWORD], xmm0
-
- sub rax, byte SIZEOF_XMMWORD
- add rcx, byte 1*SIZEOF_XMMWORD ; inptr1(above)
- add rbx, byte 1*SIZEOF_XMMWORD ; inptr0
- add rsi, byte 1*SIZEOF_XMMWORD ; inptr1(below)
- add rdx, byte 2*SIZEOF_XMMWORD ; outptr0
- add rdi, byte 2*SIZEOF_XMMWORD ; outptr1
- cmp rax, byte SIZEOF_XMMWORD
- ja near .columnloop
- test rax, rax
- jnz near .columnloop_last
-
- pop rsi
- pop rdi
- pop rcx
- pop rax
-
- add rsi, byte 1*SIZEOF_JSAMPROW ; input_data
- add rdi, byte 2*SIZEOF_JSAMPROW ; output_data
- sub rcx, byte 2 ; rowctr
- jg near .rowloop
-
-.return:
- pop rbx
- uncollect_args 4
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
- pop rbp
- ret
-
-; --------------------------------------------------------------------------
-;
-; Fast processing for the common case of 2:1 horizontal and 1:1 vertical.
-; It's still a box filter.
-;
-; GLOBAL(void)
-; jsimd_h2v1_upsample_sse2(int max_v_samp_factor, JDIMENSION output_width,
-; JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr);
-;
-
-; r10 = int max_v_samp_factor
-; r11d = JDIMENSION output_width
-; r12 = JSAMPARRAY input_data
-; r13 = JSAMPARRAY *output_data_ptr
-
- align 32
- GLOBAL_FUNCTION(jsimd_h2v1_upsample_sse2)
-
-EXTN(jsimd_h2v1_upsample_sse2):
- push rbp
- mov rax, rsp
- mov rbp, rsp
- collect_args 4
-
- mov edx, r11d
- add rdx, byte (2*SIZEOF_XMMWORD)-1
- and rdx, byte -(2*SIZEOF_XMMWORD)
- jz near .return
-
- mov rcx, r10 ; rowctr
- test rcx, rcx
- jz short .return
-
- mov rsi, r12 ; input_data
- mov rdi, r13
- mov rdip, JSAMPARRAY [rdi] ; output_data
-.rowloop:
- push rdi
- push rsi
-
- mov rsip, JSAMPROW [rsi] ; inptr
- mov rdip, JSAMPROW [rdi] ; outptr
- mov rax, rdx ; colctr
-.columnloop:
-
- movdqa xmm0, XMMWORD [rsi+0*SIZEOF_XMMWORD]
-
- movdqa xmm1, xmm0
- punpcklbw xmm0, xmm0
- punpckhbw xmm1, xmm1
-
- movdqa XMMWORD [rdi+0*SIZEOF_XMMWORD], xmm0
- movdqa XMMWORD [rdi+1*SIZEOF_XMMWORD], xmm1
-
- sub rax, byte 2*SIZEOF_XMMWORD
- jz short .nextrow
-
- movdqa xmm2, XMMWORD [rsi+1*SIZEOF_XMMWORD]
-
- movdqa xmm3, xmm2
- punpcklbw xmm2, xmm2
- punpckhbw xmm3, xmm3
-
- movdqa XMMWORD [rdi+2*SIZEOF_XMMWORD], xmm2
- movdqa XMMWORD [rdi+3*SIZEOF_XMMWORD], xmm3
-
- sub rax, byte 2*SIZEOF_XMMWORD
- jz short .nextrow
-
- add rsi, byte 2*SIZEOF_XMMWORD ; inptr
- add rdi, byte 4*SIZEOF_XMMWORD ; outptr
- jmp short .columnloop
-
-.nextrow:
- pop rsi
- pop rdi
-
- add rsi, byte SIZEOF_JSAMPROW ; input_data
- add rdi, byte SIZEOF_JSAMPROW ; output_data
- dec rcx ; rowctr
- jg short .rowloop
-
-.return:
- uncollect_args 4
- pop rbp
- ret
-
-; --------------------------------------------------------------------------
-;
-; Fast processing for the common case of 2:1 horizontal and 2:1 vertical.
-; It's still a box filter.
-;
-; GLOBAL(void)
-; jsimd_h2v2_upsample_sse2(int max_v_samp_factor, JDIMENSION output_width,
-; JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr);
-;
-
-; r10 = int max_v_samp_factor
-; r11d = JDIMENSION output_width
-; r12 = JSAMPARRAY input_data
-; r13 = JSAMPARRAY *output_data_ptr
-
- align 32
- GLOBAL_FUNCTION(jsimd_h2v2_upsample_sse2)
-
-EXTN(jsimd_h2v2_upsample_sse2):
- push rbp
- mov rax, rsp
- mov rbp, rsp
- collect_args 4
- push rbx
-
- mov edx, r11d
- add rdx, byte (2*SIZEOF_XMMWORD)-1
- and rdx, byte -(2*SIZEOF_XMMWORD)
- jz near .return
-
- mov rcx, r10 ; rowctr
- test rcx, rcx
- jz near .return
-
- mov rsi, r12 ; input_data
- mov rdi, r13
- mov rdip, JSAMPARRAY [rdi] ; output_data
-.rowloop:
- push rdi
- push rsi
-
- mov rsip, JSAMPROW [rsi] ; inptr
- mov rbxp, JSAMPROW [rdi+0*SIZEOF_JSAMPROW] ; outptr0
- mov rdip, JSAMPROW [rdi+1*SIZEOF_JSAMPROW] ; outptr1
- mov rax, rdx ; colctr
-.columnloop:
-
- movdqa xmm0, XMMWORD [rsi+0*SIZEOF_XMMWORD]
-
- movdqa xmm1, xmm0
- punpcklbw xmm0, xmm0
- punpckhbw xmm1, xmm1
-
- movdqa XMMWORD [rbx+0*SIZEOF_XMMWORD], xmm0
- movdqa XMMWORD [rbx+1*SIZEOF_XMMWORD], xmm1
- movdqa XMMWORD [rdi+0*SIZEOF_XMMWORD], xmm0
- movdqa XMMWORD [rdi+1*SIZEOF_XMMWORD], xmm1
-
- sub rax, byte 2*SIZEOF_XMMWORD
- jz short .nextrow
-
- movdqa xmm2, XMMWORD [rsi+1*SIZEOF_XMMWORD]
-
- movdqa xmm3, xmm2
- punpcklbw xmm2, xmm2
- punpckhbw xmm3, xmm3
-
- movdqa XMMWORD [rbx+2*SIZEOF_XMMWORD], xmm2
- movdqa XMMWORD [rbx+3*SIZEOF_XMMWORD], xmm3
- movdqa XMMWORD [rdi+2*SIZEOF_XMMWORD], xmm2
- movdqa XMMWORD [rdi+3*SIZEOF_XMMWORD], xmm3
-
- sub rax, byte 2*SIZEOF_XMMWORD
- jz short .nextrow
-
- add rsi, byte 2*SIZEOF_XMMWORD ; inptr
- add rbx, byte 4*SIZEOF_XMMWORD ; outptr0
- add rdi, byte 4*SIZEOF_XMMWORD ; outptr1
- jmp short .columnloop
-
-.nextrow:
- pop rsi
- pop rdi
-
- add rsi, byte 1*SIZEOF_JSAMPROW ; input_data
- add rdi, byte 2*SIZEOF_JSAMPROW ; output_data
- sub rcx, byte 2 ; rowctr
- jg near .rowloop
-
-.return:
- pop rbx
- uncollect_args 4
- pop rbp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jfdctflt-sse.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jfdctflt-sse.asm
deleted file mode 100644
index ef2796649b..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jfdctflt-sse.asm
+++ /dev/null
@@ -1,355 +0,0 @@
-;
-; jfdctflt.asm - floating-point FDCT (64-bit SSE)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-;
-; This file contains a floating-point implementation of the forward DCT
-; (Discrete Cosine Transform). The following code is based directly on
-; the IJG's original jfdctflt.c; see the jfdctflt.c for more details.
-
-%include "jsimdext.inc"
-%include "jdct.inc"
-
-; --------------------------------------------------------------------------
-
-%macro unpcklps2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(0 1 4 5)
- shufps %1, %2, 0x44
-%endmacro
-
-%macro unpckhps2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(2 3 6 7)
- shufps %1, %2, 0xEE
-%endmacro
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_fdct_float_sse)
-
-EXTN(jconst_fdct_float_sse):
-
-PD_0_382 times 4 dd 0.382683432365089771728460
-PD_0_707 times 4 dd 0.707106781186547524400844
-PD_0_541 times 4 dd 0.541196100146196984399723
-PD_1_306 times 4 dd 1.306562964876376527856643
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 64
-;
-; Perform the forward DCT on one block of samples.
-;
-; GLOBAL(void)
-; jsimd_fdct_float_sse(FAST_FLOAT *data)
-;
-
-; r10 = FAST_FLOAT *data
-
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
-%define WK_NUM 2
-
- align 32
- GLOBAL_FUNCTION(jsimd_fdct_float_sse)
-
-EXTN(jsimd_fdct_float_sse):
- push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
- and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
- collect_args 1
-
- ; ---- Pass 1: process rows.
-
- mov rdx, r10 ; (FAST_FLOAT *)
- mov rcx, DCTSIZE/4
-.rowloop:
-
- movaps xmm0, XMMWORD [XMMBLOCK(2,0,rdx,SIZEOF_FAST_FLOAT)]
- movaps xmm1, XMMWORD [XMMBLOCK(3,0,rdx,SIZEOF_FAST_FLOAT)]
- movaps xmm2, XMMWORD [XMMBLOCK(2,1,rdx,SIZEOF_FAST_FLOAT)]
- movaps xmm3, XMMWORD [XMMBLOCK(3,1,rdx,SIZEOF_FAST_FLOAT)]
-
- ; xmm0=(20 21 22 23), xmm2=(24 25 26 27)
- ; xmm1=(30 31 32 33), xmm3=(34 35 36 37)
-
- movaps xmm4, xmm0 ; transpose coefficients(phase 1)
- unpcklps xmm0, xmm1 ; xmm0=(20 30 21 31)
- unpckhps xmm4, xmm1 ; xmm4=(22 32 23 33)
- movaps xmm5, xmm2 ; transpose coefficients(phase 1)
- unpcklps xmm2, xmm3 ; xmm2=(24 34 25 35)
- unpckhps xmm5, xmm3 ; xmm5=(26 36 27 37)
-
- movaps xmm6, XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_FAST_FLOAT)]
- movaps xmm7, XMMWORD [XMMBLOCK(1,0,rdx,SIZEOF_FAST_FLOAT)]
- movaps xmm1, XMMWORD [XMMBLOCK(0,1,rdx,SIZEOF_FAST_FLOAT)]
- movaps xmm3, XMMWORD [XMMBLOCK(1,1,rdx,SIZEOF_FAST_FLOAT)]
-
- ; xmm6=(00 01 02 03), xmm1=(04 05 06 07)
- ; xmm7=(10 11 12 13), xmm3=(14 15 16 17)
-
- movaps XMMWORD [wk(0)], xmm4 ; wk(0)=(22 32 23 33)
- movaps XMMWORD [wk(1)], xmm2 ; wk(1)=(24 34 25 35)
-
- movaps xmm4, xmm6 ; transpose coefficients(phase 1)
- unpcklps xmm6, xmm7 ; xmm6=(00 10 01 11)
- unpckhps xmm4, xmm7 ; xmm4=(02 12 03 13)
- movaps xmm2, xmm1 ; transpose coefficients(phase 1)
- unpcklps xmm1, xmm3 ; xmm1=(04 14 05 15)
- unpckhps xmm2, xmm3 ; xmm2=(06 16 07 17)
-
- movaps xmm7, xmm6 ; transpose coefficients(phase 2)
- unpcklps2 xmm6, xmm0 ; xmm6=(00 10 20 30)=data0
- unpckhps2 xmm7, xmm0 ; xmm7=(01 11 21 31)=data1
- movaps xmm3, xmm2 ; transpose coefficients(phase 2)
- unpcklps2 xmm2, xmm5 ; xmm2=(06 16 26 36)=data6
- unpckhps2 xmm3, xmm5 ; xmm3=(07 17 27 37)=data7
-
- movaps xmm0, xmm7
- movaps xmm5, xmm6
- subps xmm7, xmm2 ; xmm7=data1-data6=tmp6
- subps xmm6, xmm3 ; xmm6=data0-data7=tmp7
- addps xmm0, xmm2 ; xmm0=data1+data6=tmp1
- addps xmm5, xmm3 ; xmm5=data0+data7=tmp0
-
- movaps xmm2, XMMWORD [wk(0)] ; xmm2=(22 32 23 33)
- movaps xmm3, XMMWORD [wk(1)] ; xmm3=(24 34 25 35)
- movaps XMMWORD [wk(0)], xmm7 ; wk(0)=tmp6
- movaps XMMWORD [wk(1)], xmm6 ; wk(1)=tmp7
-
- movaps xmm7, xmm4 ; transpose coefficients(phase 2)
- unpcklps2 xmm4, xmm2 ; xmm4=(02 12 22 32)=data2
- unpckhps2 xmm7, xmm2 ; xmm7=(03 13 23 33)=data3
- movaps xmm6, xmm1 ; transpose coefficients(phase 2)
- unpcklps2 xmm1, xmm3 ; xmm1=(04 14 24 34)=data4
- unpckhps2 xmm6, xmm3 ; xmm6=(05 15 25 35)=data5
-
- movaps xmm2, xmm7
- movaps xmm3, xmm4
- addps xmm7, xmm1 ; xmm7=data3+data4=tmp3
- addps xmm4, xmm6 ; xmm4=data2+data5=tmp2
- subps xmm2, xmm1 ; xmm2=data3-data4=tmp4
- subps xmm3, xmm6 ; xmm3=data2-data5=tmp5
-
- ; -- Even part
-
- movaps xmm1, xmm5
- movaps xmm6, xmm0
- subps xmm5, xmm7 ; xmm5=tmp13
- subps xmm0, xmm4 ; xmm0=tmp12
- addps xmm1, xmm7 ; xmm1=tmp10
- addps xmm6, xmm4 ; xmm6=tmp11
-
- addps xmm0, xmm5
- mulps xmm0, [rel PD_0_707] ; xmm0=z1
-
- movaps xmm7, xmm1
- movaps xmm4, xmm5
- subps xmm1, xmm6 ; xmm1=data4
- subps xmm5, xmm0 ; xmm5=data6
- addps xmm7, xmm6 ; xmm7=data0
- addps xmm4, xmm0 ; xmm4=data2
-
- movaps XMMWORD [XMMBLOCK(0,1,rdx,SIZEOF_FAST_FLOAT)], xmm1
- movaps XMMWORD [XMMBLOCK(2,1,rdx,SIZEOF_FAST_FLOAT)], xmm5
- movaps XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_FAST_FLOAT)], xmm7
- movaps XMMWORD [XMMBLOCK(2,0,rdx,SIZEOF_FAST_FLOAT)], xmm4
-
- ; -- Odd part
-
- movaps xmm6, XMMWORD [wk(0)] ; xmm6=tmp6
- movaps xmm0, XMMWORD [wk(1)] ; xmm0=tmp7
-
- addps xmm2, xmm3 ; xmm2=tmp10
- addps xmm3, xmm6 ; xmm3=tmp11
- addps xmm6, xmm0 ; xmm6=tmp12, xmm0=tmp7
-
- mulps xmm3, [rel PD_0_707] ; xmm3=z3
-
- movaps xmm1, xmm2 ; xmm1=tmp10
- subps xmm2, xmm6
- mulps xmm2, [rel PD_0_382] ; xmm2=z5
- mulps xmm1, [rel PD_0_541] ; xmm1=MULTIPLY(tmp10,FIX_0_541196)
- mulps xmm6, [rel PD_1_306] ; xmm6=MULTIPLY(tmp12,FIX_1_306562)
- addps xmm1, xmm2 ; xmm1=z2
- addps xmm6, xmm2 ; xmm6=z4
-
- movaps xmm5, xmm0
- subps xmm0, xmm3 ; xmm0=z13
- addps xmm5, xmm3 ; xmm5=z11
-
- movaps xmm7, xmm0
- movaps xmm4, xmm5
- subps xmm0, xmm1 ; xmm0=data3
- subps xmm5, xmm6 ; xmm5=data7
- addps xmm7, xmm1 ; xmm7=data5
- addps xmm4, xmm6 ; xmm4=data1
-
- movaps XMMWORD [XMMBLOCK(3,0,rdx,SIZEOF_FAST_FLOAT)], xmm0
- movaps XMMWORD [XMMBLOCK(3,1,rdx,SIZEOF_FAST_FLOAT)], xmm5
- movaps XMMWORD [XMMBLOCK(1,1,rdx,SIZEOF_FAST_FLOAT)], xmm7
- movaps XMMWORD [XMMBLOCK(1,0,rdx,SIZEOF_FAST_FLOAT)], xmm4
-
- add rdx, 4*DCTSIZE*SIZEOF_FAST_FLOAT
- dec rcx
- jnz near .rowloop
-
- ; ---- Pass 2: process columns.
-
- mov rdx, r10 ; (FAST_FLOAT *)
- mov rcx, DCTSIZE/4
-.columnloop:
-
- movaps xmm0, XMMWORD [XMMBLOCK(2,0,rdx,SIZEOF_FAST_FLOAT)]
- movaps xmm1, XMMWORD [XMMBLOCK(3,0,rdx,SIZEOF_FAST_FLOAT)]
- movaps xmm2, XMMWORD [XMMBLOCK(6,0,rdx,SIZEOF_FAST_FLOAT)]
- movaps xmm3, XMMWORD [XMMBLOCK(7,0,rdx,SIZEOF_FAST_FLOAT)]
-
- ; xmm0=(02 12 22 32), xmm2=(42 52 62 72)
- ; xmm1=(03 13 23 33), xmm3=(43 53 63 73)
-
- movaps xmm4, xmm0 ; transpose coefficients(phase 1)
- unpcklps xmm0, xmm1 ; xmm0=(02 03 12 13)
- unpckhps xmm4, xmm1 ; xmm4=(22 23 32 33)
- movaps xmm5, xmm2 ; transpose coefficients(phase 1)
- unpcklps xmm2, xmm3 ; xmm2=(42 43 52 53)
- unpckhps xmm5, xmm3 ; xmm5=(62 63 72 73)
-
- movaps xmm6, XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_FAST_FLOAT)]
- movaps xmm7, XMMWORD [XMMBLOCK(1,0,rdx,SIZEOF_FAST_FLOAT)]
- movaps xmm1, XMMWORD [XMMBLOCK(4,0,rdx,SIZEOF_FAST_FLOAT)]
- movaps xmm3, XMMWORD [XMMBLOCK(5,0,rdx,SIZEOF_FAST_FLOAT)]
-
- ; xmm6=(00 10 20 30), xmm1=(40 50 60 70)
- ; xmm7=(01 11 21 31), xmm3=(41 51 61 71)
-
- movaps XMMWORD [wk(0)], xmm4 ; wk(0)=(22 23 32 33)
- movaps XMMWORD [wk(1)], xmm2 ; wk(1)=(42 43 52 53)
-
- movaps xmm4, xmm6 ; transpose coefficients(phase 1)
- unpcklps xmm6, xmm7 ; xmm6=(00 01 10 11)
- unpckhps xmm4, xmm7 ; xmm4=(20 21 30 31)
- movaps xmm2, xmm1 ; transpose coefficients(phase 1)
- unpcklps xmm1, xmm3 ; xmm1=(40 41 50 51)
- unpckhps xmm2, xmm3 ; xmm2=(60 61 70 71)
-
- movaps xmm7, xmm6 ; transpose coefficients(phase 2)
- unpcklps2 xmm6, xmm0 ; xmm6=(00 01 02 03)=data0
- unpckhps2 xmm7, xmm0 ; xmm7=(10 11 12 13)=data1
- movaps xmm3, xmm2 ; transpose coefficients(phase 2)
- unpcklps2 xmm2, xmm5 ; xmm2=(60 61 62 63)=data6
- unpckhps2 xmm3, xmm5 ; xmm3=(70 71 72 73)=data7
-
- movaps xmm0, xmm7
- movaps xmm5, xmm6
- subps xmm7, xmm2 ; xmm7=data1-data6=tmp6
- subps xmm6, xmm3 ; xmm6=data0-data7=tmp7
- addps xmm0, xmm2 ; xmm0=data1+data6=tmp1
- addps xmm5, xmm3 ; xmm5=data0+data7=tmp0
-
- movaps xmm2, XMMWORD [wk(0)] ; xmm2=(22 23 32 33)
- movaps xmm3, XMMWORD [wk(1)] ; xmm3=(42 43 52 53)
- movaps XMMWORD [wk(0)], xmm7 ; wk(0)=tmp6
- movaps XMMWORD [wk(1)], xmm6 ; wk(1)=tmp7
-
- movaps xmm7, xmm4 ; transpose coefficients(phase 2)
- unpcklps2 xmm4, xmm2 ; xmm4=(20 21 22 23)=data2
- unpckhps2 xmm7, xmm2 ; xmm7=(30 31 32 33)=data3
- movaps xmm6, xmm1 ; transpose coefficients(phase 2)
- unpcklps2 xmm1, xmm3 ; xmm1=(40 41 42 43)=data4
- unpckhps2 xmm6, xmm3 ; xmm6=(50 51 52 53)=data5
-
- movaps xmm2, xmm7
- movaps xmm3, xmm4
- addps xmm7, xmm1 ; xmm7=data3+data4=tmp3
- addps xmm4, xmm6 ; xmm4=data2+data5=tmp2
- subps xmm2, xmm1 ; xmm2=data3-data4=tmp4
- subps xmm3, xmm6 ; xmm3=data2-data5=tmp5
-
- ; -- Even part
-
- movaps xmm1, xmm5
- movaps xmm6, xmm0
- subps xmm5, xmm7 ; xmm5=tmp13
- subps xmm0, xmm4 ; xmm0=tmp12
- addps xmm1, xmm7 ; xmm1=tmp10
- addps xmm6, xmm4 ; xmm6=tmp11
-
- addps xmm0, xmm5
- mulps xmm0, [rel PD_0_707] ; xmm0=z1
-
- movaps xmm7, xmm1
- movaps xmm4, xmm5
- subps xmm1, xmm6 ; xmm1=data4
- subps xmm5, xmm0 ; xmm5=data6
- addps xmm7, xmm6 ; xmm7=data0
- addps xmm4, xmm0 ; xmm4=data2
-
- movaps XMMWORD [XMMBLOCK(4,0,rdx,SIZEOF_FAST_FLOAT)], xmm1
- movaps XMMWORD [XMMBLOCK(6,0,rdx,SIZEOF_FAST_FLOAT)], xmm5
- movaps XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_FAST_FLOAT)], xmm7
- movaps XMMWORD [XMMBLOCK(2,0,rdx,SIZEOF_FAST_FLOAT)], xmm4
-
- ; -- Odd part
-
- movaps xmm6, XMMWORD [wk(0)] ; xmm6=tmp6
- movaps xmm0, XMMWORD [wk(1)] ; xmm0=tmp7
-
- addps xmm2, xmm3 ; xmm2=tmp10
- addps xmm3, xmm6 ; xmm3=tmp11
- addps xmm6, xmm0 ; xmm6=tmp12, xmm0=tmp7
-
- mulps xmm3, [rel PD_0_707] ; xmm3=z3
-
- movaps xmm1, xmm2 ; xmm1=tmp10
- subps xmm2, xmm6
- mulps xmm2, [rel PD_0_382] ; xmm2=z5
- mulps xmm1, [rel PD_0_541] ; xmm1=MULTIPLY(tmp10,FIX_0_541196)
- mulps xmm6, [rel PD_1_306] ; xmm6=MULTIPLY(tmp12,FIX_1_306562)
- addps xmm1, xmm2 ; xmm1=z2
- addps xmm6, xmm2 ; xmm6=z4
-
- movaps xmm5, xmm0
- subps xmm0, xmm3 ; xmm0=z13
- addps xmm5, xmm3 ; xmm5=z11
-
- movaps xmm7, xmm0
- movaps xmm4, xmm5
- subps xmm0, xmm1 ; xmm0=data3
- subps xmm5, xmm6 ; xmm5=data7
- addps xmm7, xmm1 ; xmm7=data5
- addps xmm4, xmm6 ; xmm4=data1
-
- movaps XMMWORD [XMMBLOCK(3,0,rdx,SIZEOF_FAST_FLOAT)], xmm0
- movaps XMMWORD [XMMBLOCK(7,0,rdx,SIZEOF_FAST_FLOAT)], xmm5
- movaps XMMWORD [XMMBLOCK(5,0,rdx,SIZEOF_FAST_FLOAT)], xmm7
- movaps XMMWORD [XMMBLOCK(1,0,rdx,SIZEOF_FAST_FLOAT)], xmm4
-
- add rdx, byte 4*SIZEOF_FAST_FLOAT
- dec rcx
- jnz near .columnloop
-
- uncollect_args 1
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
- pop rbp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jfdctfst-sse2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jfdctfst-sse2.asm
deleted file mode 100644
index 2e1bfe6e8c..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jfdctfst-sse2.asm
+++ /dev/null
@@ -1,389 +0,0 @@
-;
-; jfdctfst.asm - fast integer FDCT (64-bit SSE2)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-;
-; This file contains a fast, not so accurate integer implementation of
-; the forward DCT (Discrete Cosine Transform). The following code is
-; based directly on the IJG's original jfdctfst.c; see the jfdctfst.c
-; for more details.
-
-%include "jsimdext.inc"
-%include "jdct.inc"
-
-; --------------------------------------------------------------------------
-
-%define CONST_BITS 8 ; 14 is also OK.
-
-%if CONST_BITS == 8
-F_0_382 equ 98 ; FIX(0.382683433)
-F_0_541 equ 139 ; FIX(0.541196100)
-F_0_707 equ 181 ; FIX(0.707106781)
-F_1_306 equ 334 ; FIX(1.306562965)
-%else
-; NASM cannot do compile-time arithmetic on floating-point constants.
-%define DESCALE(x, n) (((x) + (1 << ((n) - 1))) >> (n))
-F_0_382 equ DESCALE( 410903207, 30 - CONST_BITS) ; FIX(0.382683433)
-F_0_541 equ DESCALE( 581104887, 30 - CONST_BITS) ; FIX(0.541196100)
-F_0_707 equ DESCALE( 759250124, 30 - CONST_BITS) ; FIX(0.707106781)
-F_1_306 equ DESCALE(1402911301, 30 - CONST_BITS) ; FIX(1.306562965)
-%endif
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
-; PRE_MULTIPLY_SCALE_BITS <= 2 (to avoid overflow)
-; CONST_BITS + CONST_SHIFT + PRE_MULTIPLY_SCALE_BITS == 16 (for pmulhw)
-
-%define PRE_MULTIPLY_SCALE_BITS 2
-%define CONST_SHIFT (16 - PRE_MULTIPLY_SCALE_BITS - CONST_BITS)
-
- alignz 32
- GLOBAL_DATA(jconst_fdct_ifast_sse2)
-
-EXTN(jconst_fdct_ifast_sse2):
-
-PW_F0707 times 8 dw F_0_707 << CONST_SHIFT
-PW_F0382 times 8 dw F_0_382 << CONST_SHIFT
-PW_F0541 times 8 dw F_0_541 << CONST_SHIFT
-PW_F1306 times 8 dw F_1_306 << CONST_SHIFT
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 64
-;
-; Perform the forward DCT on one block of samples.
-;
-; GLOBAL(void)
-; jsimd_fdct_ifast_sse2(DCTELEM *data)
-;
-
-; r10 = DCTELEM *data
-
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
-%define WK_NUM 2
-
- align 32
- GLOBAL_FUNCTION(jsimd_fdct_ifast_sse2)
-
-EXTN(jsimd_fdct_ifast_sse2):
- push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
- and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
- collect_args 1
-
- ; ---- Pass 1: process rows.
-
- mov rdx, r10 ; (DCTELEM *)
-
- movdqa xmm0, XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_DCTELEM)]
- movdqa xmm1, XMMWORD [XMMBLOCK(1,0,rdx,SIZEOF_DCTELEM)]
- movdqa xmm2, XMMWORD [XMMBLOCK(2,0,rdx,SIZEOF_DCTELEM)]
- movdqa xmm3, XMMWORD [XMMBLOCK(3,0,rdx,SIZEOF_DCTELEM)]
-
- ; xmm0=(00 01 02 03 04 05 06 07), xmm2=(20 21 22 23 24 25 26 27)
- ; xmm1=(10 11 12 13 14 15 16 17), xmm3=(30 31 32 33 34 35 36 37)
-
- movdqa xmm4, xmm0 ; transpose coefficients(phase 1)
- punpcklwd xmm0, xmm1 ; xmm0=(00 10 01 11 02 12 03 13)
- punpckhwd xmm4, xmm1 ; xmm4=(04 14 05 15 06 16 07 17)
- movdqa xmm5, xmm2 ; transpose coefficients(phase 1)
- punpcklwd xmm2, xmm3 ; xmm2=(20 30 21 31 22 32 23 33)
- punpckhwd xmm5, xmm3 ; xmm5=(24 34 25 35 26 36 27 37)
-
- movdqa xmm6, XMMWORD [XMMBLOCK(4,0,rdx,SIZEOF_DCTELEM)]
- movdqa xmm7, XMMWORD [XMMBLOCK(5,0,rdx,SIZEOF_DCTELEM)]
- movdqa xmm1, XMMWORD [XMMBLOCK(6,0,rdx,SIZEOF_DCTELEM)]
- movdqa xmm3, XMMWORD [XMMBLOCK(7,0,rdx,SIZEOF_DCTELEM)]
-
- ; xmm6=( 4 12 20 28 36 44 52 60), xmm1=( 6 14 22 30 38 46 54 62)
- ; xmm7=( 5 13 21 29 37 45 53 61), xmm3=( 7 15 23 31 39 47 55 63)
-
- movdqa XMMWORD [wk(0)], xmm2 ; wk(0)=(20 30 21 31 22 32 23 33)
- movdqa XMMWORD [wk(1)], xmm5 ; wk(1)=(24 34 25 35 26 36 27 37)
-
- movdqa xmm2, xmm6 ; transpose coefficients(phase 1)
- punpcklwd xmm6, xmm7 ; xmm6=(40 50 41 51 42 52 43 53)
- punpckhwd xmm2, xmm7 ; xmm2=(44 54 45 55 46 56 47 57)
- movdqa xmm5, xmm1 ; transpose coefficients(phase 1)
- punpcklwd xmm1, xmm3 ; xmm1=(60 70 61 71 62 72 63 73)
- punpckhwd xmm5, xmm3 ; xmm5=(64 74 65 75 66 76 67 77)
-
- movdqa xmm7, xmm6 ; transpose coefficients(phase 2)
- punpckldq xmm6, xmm1 ; xmm6=(40 50 60 70 41 51 61 71)
- punpckhdq xmm7, xmm1 ; xmm7=(42 52 62 72 43 53 63 73)
- movdqa xmm3, xmm2 ; transpose coefficients(phase 2)
- punpckldq xmm2, xmm5 ; xmm2=(44 54 64 74 45 55 65 75)
- punpckhdq xmm3, xmm5 ; xmm3=(46 56 66 76 47 57 67 77)
-
- movdqa xmm1, XMMWORD [wk(0)] ; xmm1=(20 30 21 31 22 32 23 33)
- movdqa xmm5, XMMWORD [wk(1)] ; xmm5=(24 34 25 35 26 36 27 37)
- movdqa XMMWORD [wk(0)], xmm7 ; wk(0)=(42 52 62 72 43 53 63 73)
- movdqa XMMWORD [wk(1)], xmm2 ; wk(1)=(44 54 64 74 45 55 65 75)
-
- movdqa xmm7, xmm0 ; transpose coefficients(phase 2)
- punpckldq xmm0, xmm1 ; xmm0=(00 10 20 30 01 11 21 31)
- punpckhdq xmm7, xmm1 ; xmm7=(02 12 22 32 03 13 23 33)
- movdqa xmm2, xmm4 ; transpose coefficients(phase 2)
- punpckldq xmm4, xmm5 ; xmm4=(04 14 24 34 05 15 25 35)
- punpckhdq xmm2, xmm5 ; xmm2=(06 16 26 36 07 17 27 37)
-
- movdqa xmm1, xmm0 ; transpose coefficients(phase 3)
- punpcklqdq xmm0, xmm6 ; xmm0=(00 10 20 30 40 50 60 70)=data0
- punpckhqdq xmm1, xmm6 ; xmm1=(01 11 21 31 41 51 61 71)=data1
- movdqa xmm5, xmm2 ; transpose coefficients(phase 3)
- punpcklqdq xmm2, xmm3 ; xmm2=(06 16 26 36 46 56 66 76)=data6
- punpckhqdq xmm5, xmm3 ; xmm5=(07 17 27 37 47 57 67 77)=data7
-
- movdqa xmm6, xmm1
- movdqa xmm3, xmm0
- psubw xmm1, xmm2 ; xmm1=data1-data6=tmp6
- psubw xmm0, xmm5 ; xmm0=data0-data7=tmp7
- paddw xmm6, xmm2 ; xmm6=data1+data6=tmp1
- paddw xmm3, xmm5 ; xmm3=data0+data7=tmp0
-
- movdqa xmm2, XMMWORD [wk(0)] ; xmm2=(42 52 62 72 43 53 63 73)
- movdqa xmm5, XMMWORD [wk(1)] ; xmm5=(44 54 64 74 45 55 65 75)
- movdqa XMMWORD [wk(0)], xmm1 ; wk(0)=tmp6
- movdqa XMMWORD [wk(1)], xmm0 ; wk(1)=tmp7
-
- movdqa xmm1, xmm7 ; transpose coefficients(phase 3)
- punpcklqdq xmm7, xmm2 ; xmm7=(02 12 22 32 42 52 62 72)=data2
- punpckhqdq xmm1, xmm2 ; xmm1=(03 13 23 33 43 53 63 73)=data3
- movdqa xmm0, xmm4 ; transpose coefficients(phase 3)
- punpcklqdq xmm4, xmm5 ; xmm4=(04 14 24 34 44 54 64 74)=data4
- punpckhqdq xmm0, xmm5 ; xmm0=(05 15 25 35 45 55 65 75)=data5
-
- movdqa xmm2, xmm1
- movdqa xmm5, xmm7
- paddw xmm1, xmm4 ; xmm1=data3+data4=tmp3
- paddw xmm7, xmm0 ; xmm7=data2+data5=tmp2
- psubw xmm2, xmm4 ; xmm2=data3-data4=tmp4
- psubw xmm5, xmm0 ; xmm5=data2-data5=tmp5
-
- ; -- Even part
-
- movdqa xmm4, xmm3
- movdqa xmm0, xmm6
- psubw xmm3, xmm1 ; xmm3=tmp13
- psubw xmm6, xmm7 ; xmm6=tmp12
- paddw xmm4, xmm1 ; xmm4=tmp10
- paddw xmm0, xmm7 ; xmm0=tmp11
-
- paddw xmm6, xmm3
- psllw xmm6, PRE_MULTIPLY_SCALE_BITS
- pmulhw xmm6, [rel PW_F0707] ; xmm6=z1
-
- movdqa xmm1, xmm4
- movdqa xmm7, xmm3
- psubw xmm4, xmm0 ; xmm4=data4
- psubw xmm3, xmm6 ; xmm3=data6
- paddw xmm1, xmm0 ; xmm1=data0
- paddw xmm7, xmm6 ; xmm7=data2
-
- movdqa xmm0, XMMWORD [wk(0)] ; xmm0=tmp6
- movdqa xmm6, XMMWORD [wk(1)] ; xmm6=tmp7
- movdqa XMMWORD [wk(0)], xmm4 ; wk(0)=data4
- movdqa XMMWORD [wk(1)], xmm3 ; wk(1)=data6
-
- ; -- Odd part
-
- paddw xmm2, xmm5 ; xmm2=tmp10
- paddw xmm5, xmm0 ; xmm5=tmp11
- paddw xmm0, xmm6 ; xmm0=tmp12, xmm6=tmp7
-
- psllw xmm2, PRE_MULTIPLY_SCALE_BITS
- psllw xmm0, PRE_MULTIPLY_SCALE_BITS
-
- psllw xmm5, PRE_MULTIPLY_SCALE_BITS
- pmulhw xmm5, [rel PW_F0707] ; xmm5=z3
-
- movdqa xmm4, xmm2 ; xmm4=tmp10
- psubw xmm2, xmm0
- pmulhw xmm2, [rel PW_F0382] ; xmm2=z5
- pmulhw xmm4, [rel PW_F0541] ; xmm4=MULTIPLY(tmp10,FIX_0_541196)
- pmulhw xmm0, [rel PW_F1306] ; xmm0=MULTIPLY(tmp12,FIX_1_306562)
- paddw xmm4, xmm2 ; xmm4=z2
- paddw xmm0, xmm2 ; xmm0=z4
-
- movdqa xmm3, xmm6
- psubw xmm6, xmm5 ; xmm6=z13
- paddw xmm3, xmm5 ; xmm3=z11
-
- movdqa xmm2, xmm6
- movdqa xmm5, xmm3
- psubw xmm6, xmm4 ; xmm6=data3
- psubw xmm3, xmm0 ; xmm3=data7
- paddw xmm2, xmm4 ; xmm2=data5
- paddw xmm5, xmm0 ; xmm5=data1
-
- ; ---- Pass 2: process columns.
-
- ; xmm1=(00 10 20 30 40 50 60 70), xmm7=(02 12 22 32 42 52 62 72)
- ; xmm5=(01 11 21 31 41 51 61 71), xmm6=(03 13 23 33 43 53 63 73)
-
- movdqa xmm4, xmm1 ; transpose coefficients(phase 1)
- punpcklwd xmm1, xmm5 ; xmm1=(00 01 10 11 20 21 30 31)
- punpckhwd xmm4, xmm5 ; xmm4=(40 41 50 51 60 61 70 71)
- movdqa xmm0, xmm7 ; transpose coefficients(phase 1)
- punpcklwd xmm7, xmm6 ; xmm7=(02 03 12 13 22 23 32 33)
- punpckhwd xmm0, xmm6 ; xmm0=(42 43 52 53 62 63 72 73)
-
- movdqa xmm5, XMMWORD [wk(0)] ; xmm5=col4
- movdqa xmm6, XMMWORD [wk(1)] ; xmm6=col6
-
- ; xmm5=(04 14 24 34 44 54 64 74), xmm6=(06 16 26 36 46 56 66 76)
- ; xmm2=(05 15 25 35 45 55 65 75), xmm3=(07 17 27 37 47 57 67 77)
-
- movdqa XMMWORD [wk(0)], xmm7 ; wk(0)=(02 03 12 13 22 23 32 33)
- movdqa XMMWORD [wk(1)], xmm0 ; wk(1)=(42 43 52 53 62 63 72 73)
-
- movdqa xmm7, xmm5 ; transpose coefficients(phase 1)
- punpcklwd xmm5, xmm2 ; xmm5=(04 05 14 15 24 25 34 35)
- punpckhwd xmm7, xmm2 ; xmm7=(44 45 54 55 64 65 74 75)
- movdqa xmm0, xmm6 ; transpose coefficients(phase 1)
- punpcklwd xmm6, xmm3 ; xmm6=(06 07 16 17 26 27 36 37)
- punpckhwd xmm0, xmm3 ; xmm0=(46 47 56 57 66 67 76 77)
-
- movdqa xmm2, xmm5 ; transpose coefficients(phase 2)
- punpckldq xmm5, xmm6 ; xmm5=(04 05 06 07 14 15 16 17)
- punpckhdq xmm2, xmm6 ; xmm2=(24 25 26 27 34 35 36 37)
- movdqa xmm3, xmm7 ; transpose coefficients(phase 2)
- punpckldq xmm7, xmm0 ; xmm7=(44 45 46 47 54 55 56 57)
- punpckhdq xmm3, xmm0 ; xmm3=(64 65 66 67 74 75 76 77)
-
- movdqa xmm6, XMMWORD [wk(0)] ; xmm6=(02 03 12 13 22 23 32 33)
- movdqa xmm0, XMMWORD [wk(1)] ; xmm0=(42 43 52 53 62 63 72 73)
- movdqa XMMWORD [wk(0)], xmm2 ; wk(0)=(24 25 26 27 34 35 36 37)
- movdqa XMMWORD [wk(1)], xmm7 ; wk(1)=(44 45 46 47 54 55 56 57)
-
- movdqa xmm2, xmm1 ; transpose coefficients(phase 2)
- punpckldq xmm1, xmm6 ; xmm1=(00 01 02 03 10 11 12 13)
- punpckhdq xmm2, xmm6 ; xmm2=(20 21 22 23 30 31 32 33)
- movdqa xmm7, xmm4 ; transpose coefficients(phase 2)
- punpckldq xmm4, xmm0 ; xmm4=(40 41 42 43 50 51 52 53)
- punpckhdq xmm7, xmm0 ; xmm7=(60 61 62 63 70 71 72 73)
-
- movdqa xmm6, xmm1 ; transpose coefficients(phase 3)
- punpcklqdq xmm1, xmm5 ; xmm1=(00 01 02 03 04 05 06 07)=data0
- punpckhqdq xmm6, xmm5 ; xmm6=(10 11 12 13 14 15 16 17)=data1
- movdqa xmm0, xmm7 ; transpose coefficients(phase 3)
- punpcklqdq xmm7, xmm3 ; xmm7=(60 61 62 63 64 65 66 67)=data6
- punpckhqdq xmm0, xmm3 ; xmm0=(70 71 72 73 74 75 76 77)=data7
-
- movdqa xmm5, xmm6
- movdqa xmm3, xmm1
- psubw xmm6, xmm7 ; xmm6=data1-data6=tmp6
- psubw xmm1, xmm0 ; xmm1=data0-data7=tmp7
- paddw xmm5, xmm7 ; xmm5=data1+data6=tmp1
- paddw xmm3, xmm0 ; xmm3=data0+data7=tmp0
-
- movdqa xmm7, XMMWORD [wk(0)] ; xmm7=(24 25 26 27 34 35 36 37)
- movdqa xmm0, XMMWORD [wk(1)] ; xmm0=(44 45 46 47 54 55 56 57)
- movdqa XMMWORD [wk(0)], xmm6 ; wk(0)=tmp6
- movdqa XMMWORD [wk(1)], xmm1 ; wk(1)=tmp7
-
- movdqa xmm6, xmm2 ; transpose coefficients(phase 3)
- punpcklqdq xmm2, xmm7 ; xmm2=(20 21 22 23 24 25 26 27)=data2
- punpckhqdq xmm6, xmm7 ; xmm6=(30 31 32 33 34 35 36 37)=data3
- movdqa xmm1, xmm4 ; transpose coefficients(phase 3)
- punpcklqdq xmm4, xmm0 ; xmm4=(40 41 42 43 44 45 46 47)=data4
- punpckhqdq xmm1, xmm0 ; xmm1=(50 51 52 53 54 55 56 57)=data5
-
- movdqa xmm7, xmm6
- movdqa xmm0, xmm2
- paddw xmm6, xmm4 ; xmm6=data3+data4=tmp3
- paddw xmm2, xmm1 ; xmm2=data2+data5=tmp2
- psubw xmm7, xmm4 ; xmm7=data3-data4=tmp4
- psubw xmm0, xmm1 ; xmm0=data2-data5=tmp5
-
- ; -- Even part
-
- movdqa xmm4, xmm3
- movdqa xmm1, xmm5
- psubw xmm3, xmm6 ; xmm3=tmp13
- psubw xmm5, xmm2 ; xmm5=tmp12
- paddw xmm4, xmm6 ; xmm4=tmp10
- paddw xmm1, xmm2 ; xmm1=tmp11
-
- paddw xmm5, xmm3
- psllw xmm5, PRE_MULTIPLY_SCALE_BITS
- pmulhw xmm5, [rel PW_F0707] ; xmm5=z1
-
- movdqa xmm6, xmm4
- movdqa xmm2, xmm3
- psubw xmm4, xmm1 ; xmm4=data4
- psubw xmm3, xmm5 ; xmm3=data6
- paddw xmm6, xmm1 ; xmm6=data0
- paddw xmm2, xmm5 ; xmm2=data2
-
- movdqa XMMWORD [XMMBLOCK(4,0,rdx,SIZEOF_DCTELEM)], xmm4
- movdqa XMMWORD [XMMBLOCK(6,0,rdx,SIZEOF_DCTELEM)], xmm3
- movdqa XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_DCTELEM)], xmm6
- movdqa XMMWORD [XMMBLOCK(2,0,rdx,SIZEOF_DCTELEM)], xmm2
-
- ; -- Odd part
-
- movdqa xmm1, XMMWORD [wk(0)] ; xmm1=tmp6
- movdqa xmm5, XMMWORD [wk(1)] ; xmm5=tmp7
-
- paddw xmm7, xmm0 ; xmm7=tmp10
- paddw xmm0, xmm1 ; xmm0=tmp11
- paddw xmm1, xmm5 ; xmm1=tmp12, xmm5=tmp7
-
- psllw xmm7, PRE_MULTIPLY_SCALE_BITS
- psllw xmm1, PRE_MULTIPLY_SCALE_BITS
-
- psllw xmm0, PRE_MULTIPLY_SCALE_BITS
- pmulhw xmm0, [rel PW_F0707] ; xmm0=z3
-
- movdqa xmm4, xmm7 ; xmm4=tmp10
- psubw xmm7, xmm1
- pmulhw xmm7, [rel PW_F0382] ; xmm7=z5
- pmulhw xmm4, [rel PW_F0541] ; xmm4=MULTIPLY(tmp10,FIX_0_541196)
- pmulhw xmm1, [rel PW_F1306] ; xmm1=MULTIPLY(tmp12,FIX_1_306562)
- paddw xmm4, xmm7 ; xmm4=z2
- paddw xmm1, xmm7 ; xmm1=z4
-
- movdqa xmm3, xmm5
- psubw xmm5, xmm0 ; xmm5=z13
- paddw xmm3, xmm0 ; xmm3=z11
-
- movdqa xmm6, xmm5
- movdqa xmm2, xmm3
- psubw xmm5, xmm4 ; xmm5=data3
- psubw xmm3, xmm1 ; xmm3=data7
- paddw xmm6, xmm4 ; xmm6=data5
- paddw xmm2, xmm1 ; xmm2=data1
-
- movdqa XMMWORD [XMMBLOCK(3,0,rdx,SIZEOF_DCTELEM)], xmm5
- movdqa XMMWORD [XMMBLOCK(7,0,rdx,SIZEOF_DCTELEM)], xmm3
- movdqa XMMWORD [XMMBLOCK(5,0,rdx,SIZEOF_DCTELEM)], xmm6
- movdqa XMMWORD [XMMBLOCK(1,0,rdx,SIZEOF_DCTELEM)], xmm2
-
- uncollect_args 1
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
- pop rbp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jfdctint-avx2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jfdctint-avx2.asm
deleted file mode 100644
index e56258b48a..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jfdctint-avx2.asm
+++ /dev/null
@@ -1,320 +0,0 @@
-;
-; jfdctint.asm - accurate integer FDCT (64-bit AVX2)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, 2016, 2018, 2020, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-;
-; This file contains a slower but more accurate integer implementation of the
-; forward DCT (Discrete Cosine Transform). The following code is based
-; directly on the IJG's original jfdctint.c; see the jfdctint.c for
-; more details.
-
-%include "jsimdext.inc"
-%include "jdct.inc"
-
-; --------------------------------------------------------------------------
-
-%define CONST_BITS 13
-%define PASS1_BITS 2
-
-%define DESCALE_P1 (CONST_BITS - PASS1_BITS)
-%define DESCALE_P2 (CONST_BITS + PASS1_BITS)
-
-%if CONST_BITS == 13
-F_0_298 equ 2446 ; FIX(0.298631336)
-F_0_390 equ 3196 ; FIX(0.390180644)
-F_0_541 equ 4433 ; FIX(0.541196100)
-F_0_765 equ 6270 ; FIX(0.765366865)
-F_0_899 equ 7373 ; FIX(0.899976223)
-F_1_175 equ 9633 ; FIX(1.175875602)
-F_1_501 equ 12299 ; FIX(1.501321110)
-F_1_847 equ 15137 ; FIX(1.847759065)
-F_1_961 equ 16069 ; FIX(1.961570560)
-F_2_053 equ 16819 ; FIX(2.053119869)
-F_2_562 equ 20995 ; FIX(2.562915447)
-F_3_072 equ 25172 ; FIX(3.072711026)
-%else
-; NASM cannot do compile-time arithmetic on floating-point constants.
-%define DESCALE(x, n) (((x) + (1 << ((n) - 1))) >> (n))
-F_0_298 equ DESCALE( 320652955, 30 - CONST_BITS) ; FIX(0.298631336)
-F_0_390 equ DESCALE( 418953276, 30 - CONST_BITS) ; FIX(0.390180644)
-F_0_541 equ DESCALE( 581104887, 30 - CONST_BITS) ; FIX(0.541196100)
-F_0_765 equ DESCALE( 821806413, 30 - CONST_BITS) ; FIX(0.765366865)
-F_0_899 equ DESCALE( 966342111, 30 - CONST_BITS) ; FIX(0.899976223)
-F_1_175 equ DESCALE(1262586813, 30 - CONST_BITS) ; FIX(1.175875602)
-F_1_501 equ DESCALE(1612031267, 30 - CONST_BITS) ; FIX(1.501321110)
-F_1_847 equ DESCALE(1984016188, 30 - CONST_BITS) ; FIX(1.847759065)
-F_1_961 equ DESCALE(2106220350, 30 - CONST_BITS) ; FIX(1.961570560)
-F_2_053 equ DESCALE(2204520673, 30 - CONST_BITS) ; FIX(2.053119869)
-F_2_562 equ DESCALE(2751909506, 30 - CONST_BITS) ; FIX(2.562915447)
-F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
-%endif
-
-; --------------------------------------------------------------------------
-; In-place 8x8x16-bit matrix transpose using AVX2 instructions
-; %1-%4: Input/output registers
-; %5-%8: Temp registers
-
-%macro dotranspose 8
- ; %1=(00 01 02 03 04 05 06 07 40 41 42 43 44 45 46 47)
- ; %2=(10 11 12 13 14 15 16 17 50 51 52 53 54 55 56 57)
- ; %3=(20 21 22 23 24 25 26 27 60 61 62 63 64 65 66 67)
- ; %4=(30 31 32 33 34 35 36 37 70 71 72 73 74 75 76 77)
-
- vpunpcklwd %5, %1, %2
- vpunpckhwd %6, %1, %2
- vpunpcklwd %7, %3, %4
- vpunpckhwd %8, %3, %4
- ; transpose coefficients(phase 1)
- ; %5=(00 10 01 11 02 12 03 13 40 50 41 51 42 52 43 53)
- ; %6=(04 14 05 15 06 16 07 17 44 54 45 55 46 56 47 57)
- ; %7=(20 30 21 31 22 32 23 33 60 70 61 71 62 72 63 73)
- ; %8=(24 34 25 35 26 36 27 37 64 74 65 75 66 76 67 77)
-
- vpunpckldq %1, %5, %7
- vpunpckhdq %2, %5, %7
- vpunpckldq %3, %6, %8
- vpunpckhdq %4, %6, %8
- ; transpose coefficients(phase 2)
- ; %1=(00 10 20 30 01 11 21 31 40 50 60 70 41 51 61 71)
- ; %2=(02 12 22 32 03 13 23 33 42 52 62 72 43 53 63 73)
- ; %3=(04 14 24 34 05 15 25 35 44 54 64 74 45 55 65 75)
- ; %4=(06 16 26 36 07 17 27 37 46 56 66 76 47 57 67 77)
-
- vpermq %1, %1, 0x8D
- vpermq %2, %2, 0x8D
- vpermq %3, %3, 0xD8
- vpermq %4, %4, 0xD8
- ; transpose coefficients(phase 3)
- ; %1=(01 11 21 31 41 51 61 71 00 10 20 30 40 50 60 70)
- ; %2=(03 13 23 33 43 53 63 73 02 12 22 32 42 52 62 72)
- ; %3=(04 14 24 34 44 54 64 74 05 15 25 35 45 55 65 75)
- ; %4=(06 16 26 36 46 56 66 76 07 17 27 37 47 57 67 77)
-%endmacro
-
-; --------------------------------------------------------------------------
-; In-place 8x8x16-bit accurate integer forward DCT using AVX2 instructions
-; %1-%4: Input/output registers
-; %5-%8: Temp registers
-; %9: Pass (1 or 2)
-
-%macro dodct 9
- vpsubw %5, %1, %4 ; %5=data1_0-data6_7=tmp6_7
- vpaddw %6, %1, %4 ; %6=data1_0+data6_7=tmp1_0
- vpaddw %7, %2, %3 ; %7=data3_2+data4_5=tmp3_2
- vpsubw %8, %2, %3 ; %8=data3_2-data4_5=tmp4_5
-
- ; -- Even part
-
- vperm2i128 %6, %6, %6, 0x01 ; %6=tmp0_1
- vpaddw %1, %6, %7 ; %1=tmp0_1+tmp3_2=tmp10_11
- vpsubw %6, %6, %7 ; %6=tmp0_1-tmp3_2=tmp13_12
-
- vperm2i128 %7, %1, %1, 0x01 ; %7=tmp11_10
- vpsignw %1, %1, [rel PW_1_NEG1] ; %1=tmp10_neg11
- vpaddw %7, %7, %1 ; %7=(tmp10+tmp11)_(tmp10-tmp11)
-%if %9 == 1
- vpsllw %1, %7, PASS1_BITS ; %1=data0_4
-%else
- vpaddw %7, %7, [rel PW_DESCALE_P2X]
- vpsraw %1, %7, PASS1_BITS ; %1=data0_4
-%endif
-
- ; (Original)
- ; z1 = (tmp12 + tmp13) * 0.541196100;
- ; data2 = z1 + tmp13 * 0.765366865;
- ; data6 = z1 + tmp12 * -1.847759065;
- ;
- ; (This implementation)
- ; data2 = tmp13 * (0.541196100 + 0.765366865) + tmp12 * 0.541196100;
- ; data6 = tmp13 * 0.541196100 + tmp12 * (0.541196100 - 1.847759065);
-
- vperm2i128 %7, %6, %6, 0x01 ; %7=tmp12_13
- vpunpcklwd %2, %6, %7
- vpunpckhwd %6, %6, %7
- vpmaddwd %2, %2, [rel PW_F130_F054_MF130_F054] ; %2=data2_6L
- vpmaddwd %6, %6, [rel PW_F130_F054_MF130_F054] ; %6=data2_6H
-
- vpaddd %2, %2, [rel PD_DESCALE_P %+ %9]
- vpaddd %6, %6, [rel PD_DESCALE_P %+ %9]
- vpsrad %2, %2, DESCALE_P %+ %9
- vpsrad %6, %6, DESCALE_P %+ %9
-
- vpackssdw %3, %2, %6 ; %6=data2_6
-
- ; -- Odd part
-
- vpaddw %7, %8, %5 ; %7=tmp4_5+tmp6_7=z3_4
-
- ; (Original)
- ; z5 = (z3 + z4) * 1.175875602;
- ; z3 = z3 * -1.961570560; z4 = z4 * -0.390180644;
- ; z3 += z5; z4 += z5;
- ;
- ; (This implementation)
- ; z3 = z3 * (1.175875602 - 1.961570560) + z4 * 1.175875602;
- ; z4 = z3 * 1.175875602 + z4 * (1.175875602 - 0.390180644);
-
- vperm2i128 %2, %7, %7, 0x01 ; %2=z4_3
- vpunpcklwd %6, %7, %2
- vpunpckhwd %7, %7, %2
- vpmaddwd %6, %6, [rel PW_MF078_F117_F078_F117] ; %6=z3_4L
- vpmaddwd %7, %7, [rel PW_MF078_F117_F078_F117] ; %7=z3_4H
-
- ; (Original)
- ; z1 = tmp4 + tmp7; z2 = tmp5 + tmp6;
- ; tmp4 = tmp4 * 0.298631336; tmp5 = tmp5 * 2.053119869;
- ; tmp6 = tmp6 * 3.072711026; tmp7 = tmp7 * 1.501321110;
- ; z1 = z1 * -0.899976223; z2 = z2 * -2.562915447;
- ; data7 = tmp4 + z1 + z3; data5 = tmp5 + z2 + z4;
- ; data3 = tmp6 + z2 + z3; data1 = tmp7 + z1 + z4;
- ;
- ; (This implementation)
- ; tmp4 = tmp4 * (0.298631336 - 0.899976223) + tmp7 * -0.899976223;
- ; tmp5 = tmp5 * (2.053119869 - 2.562915447) + tmp6 * -2.562915447;
- ; tmp6 = tmp5 * -2.562915447 + tmp6 * (3.072711026 - 2.562915447);
- ; tmp7 = tmp4 * -0.899976223 + tmp7 * (1.501321110 - 0.899976223);
- ; data7 = tmp4 + z3; data5 = tmp5 + z4;
- ; data3 = tmp6 + z3; data1 = tmp7 + z4;
-
- vperm2i128 %4, %5, %5, 0x01 ; %4=tmp7_6
- vpunpcklwd %2, %8, %4
- vpunpckhwd %4, %8, %4
- vpmaddwd %2, %2, [rel PW_MF060_MF089_MF050_MF256] ; %2=tmp4_5L
- vpmaddwd %4, %4, [rel PW_MF060_MF089_MF050_MF256] ; %4=tmp4_5H
-
- vpaddd %2, %2, %6 ; %2=data7_5L
- vpaddd %4, %4, %7 ; %4=data7_5H
-
- vpaddd %2, %2, [rel PD_DESCALE_P %+ %9]
- vpaddd %4, %4, [rel PD_DESCALE_P %+ %9]
- vpsrad %2, %2, DESCALE_P %+ %9
- vpsrad %4, %4, DESCALE_P %+ %9
-
- vpackssdw %4, %2, %4 ; %4=data7_5
-
- vperm2i128 %2, %8, %8, 0x01 ; %2=tmp5_4
- vpunpcklwd %8, %5, %2
- vpunpckhwd %5, %5, %2
- vpmaddwd %8, %8, [rel PW_F050_MF256_F060_MF089] ; %8=tmp6_7L
- vpmaddwd %5, %5, [rel PW_F050_MF256_F060_MF089] ; %5=tmp6_7H
-
- vpaddd %8, %8, %6 ; %8=data3_1L
- vpaddd %5, %5, %7 ; %5=data3_1H
-
- vpaddd %8, %8, [rel PD_DESCALE_P %+ %9]
- vpaddd %5, %5, [rel PD_DESCALE_P %+ %9]
- vpsrad %8, %8, DESCALE_P %+ %9
- vpsrad %5, %5, DESCALE_P %+ %9
-
- vpackssdw %2, %8, %5 ; %2=data3_1
-%endmacro
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_fdct_islow_avx2)
-
-EXTN(jconst_fdct_islow_avx2):
-
-PW_F130_F054_MF130_F054 times 4 dw (F_0_541 + F_0_765), F_0_541
- times 4 dw (F_0_541 - F_1_847), F_0_541
-PW_MF078_F117_F078_F117 times 4 dw (F_1_175 - F_1_961), F_1_175
- times 4 dw (F_1_175 - F_0_390), F_1_175
-PW_MF060_MF089_MF050_MF256 times 4 dw (F_0_298 - F_0_899), -F_0_899
- times 4 dw (F_2_053 - F_2_562), -F_2_562
-PW_F050_MF256_F060_MF089 times 4 dw (F_3_072 - F_2_562), -F_2_562
- times 4 dw (F_1_501 - F_0_899), -F_0_899
-PD_DESCALE_P1 times 8 dd 1 << (DESCALE_P1 - 1)
-PD_DESCALE_P2 times 8 dd 1 << (DESCALE_P2 - 1)
-PW_DESCALE_P2X times 16 dw 1 << (PASS1_BITS - 1)
-PW_1_NEG1 times 8 dw 1
- times 8 dw -1
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 64
-;
-; Perform the forward DCT on one block of samples.
-;
-; GLOBAL(void)
-; jsimd_fdct_islow_avx2(DCTELEM *data)
-;
-
-; r10 = DCTELEM *data
-
- align 32
- GLOBAL_FUNCTION(jsimd_fdct_islow_avx2)
-
-EXTN(jsimd_fdct_islow_avx2):
- push rbp
- mov rax, rsp
- mov rbp, rsp
- collect_args 1
-
- ; ---- Pass 1: process rows.
-
- vmovdqu ymm4, YMMWORD [YMMBLOCK(0,0,r10,SIZEOF_DCTELEM)]
- vmovdqu ymm5, YMMWORD [YMMBLOCK(2,0,r10,SIZEOF_DCTELEM)]
- vmovdqu ymm6, YMMWORD [YMMBLOCK(4,0,r10,SIZEOF_DCTELEM)]
- vmovdqu ymm7, YMMWORD [YMMBLOCK(6,0,r10,SIZEOF_DCTELEM)]
- ; ymm4=(00 01 02 03 04 05 06 07 10 11 12 13 14 15 16 17)
- ; ymm5=(20 21 22 23 24 25 26 27 30 31 32 33 34 35 36 37)
- ; ymm6=(40 41 42 43 44 45 46 47 50 51 52 53 54 55 56 57)
- ; ymm7=(60 61 62 63 64 65 66 67 70 71 72 73 74 75 76 77)
-
- vperm2i128 ymm0, ymm4, ymm6, 0x20
- vperm2i128 ymm1, ymm4, ymm6, 0x31
- vperm2i128 ymm2, ymm5, ymm7, 0x20
- vperm2i128 ymm3, ymm5, ymm7, 0x31
- ; ymm0=(00 01 02 03 04 05 06 07 40 41 42 43 44 45 46 47)
- ; ymm1=(10 11 12 13 14 15 16 17 50 51 52 53 54 55 56 57)
- ; ymm2=(20 21 22 23 24 25 26 27 60 61 62 63 64 65 66 67)
- ; ymm3=(30 31 32 33 34 35 36 37 70 71 72 73 74 75 76 77)
-
- dotranspose ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7
-
- dodct ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7, 1
- ; ymm0=data0_4, ymm1=data3_1, ymm2=data2_6, ymm3=data7_5
-
- ; ---- Pass 2: process columns.
-
- vperm2i128 ymm4, ymm1, ymm3, 0x20 ; ymm4=data3_7
- vperm2i128 ymm1, ymm1, ymm3, 0x31 ; ymm1=data1_5
-
- dotranspose ymm0, ymm1, ymm2, ymm4, ymm3, ymm5, ymm6, ymm7
-
- dodct ymm0, ymm1, ymm2, ymm4, ymm3, ymm5, ymm6, ymm7, 2
- ; ymm0=data0_4, ymm1=data3_1, ymm2=data2_6, ymm4=data7_5
-
- vperm2i128 ymm3, ymm0, ymm1, 0x30 ; ymm3=data0_1
- vperm2i128 ymm5, ymm2, ymm1, 0x20 ; ymm5=data2_3
- vperm2i128 ymm6, ymm0, ymm4, 0x31 ; ymm6=data4_5
- vperm2i128 ymm7, ymm2, ymm4, 0x21 ; ymm7=data6_7
-
- vmovdqu YMMWORD [YMMBLOCK(0,0,r10,SIZEOF_DCTELEM)], ymm3
- vmovdqu YMMWORD [YMMBLOCK(2,0,r10,SIZEOF_DCTELEM)], ymm5
- vmovdqu YMMWORD [YMMBLOCK(4,0,r10,SIZEOF_DCTELEM)], ymm6
- vmovdqu YMMWORD [YMMBLOCK(6,0,r10,SIZEOF_DCTELEM)], ymm7
-
- vzeroupper
- uncollect_args 1
- pop rbp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jfdctint-sse2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jfdctint-sse2.asm
deleted file mode 100644
index ec1f383ccb..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jfdctint-sse2.asm
+++ /dev/null
@@ -1,619 +0,0 @@
-;
-; jfdctint.asm - accurate integer FDCT (64-bit SSE2)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, 2016, 2020, D. R. Commander.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-;
-; This file contains a slower but more accurate integer implementation of the
-; forward DCT (Discrete Cosine Transform). The following code is based
-; directly on the IJG's original jfdctint.c; see the jfdctint.c for
-; more details.
-
-%include "jsimdext.inc"
-%include "jdct.inc"
-
-; --------------------------------------------------------------------------
-
-%define CONST_BITS 13
-%define PASS1_BITS 2
-
-%define DESCALE_P1 (CONST_BITS - PASS1_BITS)
-%define DESCALE_P2 (CONST_BITS + PASS1_BITS)
-
-%if CONST_BITS == 13
-F_0_298 equ 2446 ; FIX(0.298631336)
-F_0_390 equ 3196 ; FIX(0.390180644)
-F_0_541 equ 4433 ; FIX(0.541196100)
-F_0_765 equ 6270 ; FIX(0.765366865)
-F_0_899 equ 7373 ; FIX(0.899976223)
-F_1_175 equ 9633 ; FIX(1.175875602)
-F_1_501 equ 12299 ; FIX(1.501321110)
-F_1_847 equ 15137 ; FIX(1.847759065)
-F_1_961 equ 16069 ; FIX(1.961570560)
-F_2_053 equ 16819 ; FIX(2.053119869)
-F_2_562 equ 20995 ; FIX(2.562915447)
-F_3_072 equ 25172 ; FIX(3.072711026)
-%else
-; NASM cannot do compile-time arithmetic on floating-point constants.
-%define DESCALE(x, n) (((x) + (1 << ((n) - 1))) >> (n))
-F_0_298 equ DESCALE( 320652955, 30 - CONST_BITS) ; FIX(0.298631336)
-F_0_390 equ DESCALE( 418953276, 30 - CONST_BITS) ; FIX(0.390180644)
-F_0_541 equ DESCALE( 581104887, 30 - CONST_BITS) ; FIX(0.541196100)
-F_0_765 equ DESCALE( 821806413, 30 - CONST_BITS) ; FIX(0.765366865)
-F_0_899 equ DESCALE( 966342111, 30 - CONST_BITS) ; FIX(0.899976223)
-F_1_175 equ DESCALE(1262586813, 30 - CONST_BITS) ; FIX(1.175875602)
-F_1_501 equ DESCALE(1612031267, 30 - CONST_BITS) ; FIX(1.501321110)
-F_1_847 equ DESCALE(1984016188, 30 - CONST_BITS) ; FIX(1.847759065)
-F_1_961 equ DESCALE(2106220350, 30 - CONST_BITS) ; FIX(1.961570560)
-F_2_053 equ DESCALE(2204520673, 30 - CONST_BITS) ; FIX(2.053119869)
-F_2_562 equ DESCALE(2751909506, 30 - CONST_BITS) ; FIX(2.562915447)
-F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
-%endif
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_fdct_islow_sse2)
-
-EXTN(jconst_fdct_islow_sse2):
-
-PW_F130_F054 times 4 dw (F_0_541 + F_0_765), F_0_541
-PW_F054_MF130 times 4 dw F_0_541, (F_0_541 - F_1_847)
-PW_MF078_F117 times 4 dw (F_1_175 - F_1_961), F_1_175
-PW_F117_F078 times 4 dw F_1_175, (F_1_175 - F_0_390)
-PW_MF060_MF089 times 4 dw (F_0_298 - F_0_899), -F_0_899
-PW_MF089_F060 times 4 dw -F_0_899, (F_1_501 - F_0_899)
-PW_MF050_MF256 times 4 dw (F_2_053 - F_2_562), -F_2_562
-PW_MF256_F050 times 4 dw -F_2_562, (F_3_072 - F_2_562)
-PD_DESCALE_P1 times 4 dd 1 << (DESCALE_P1 - 1)
-PD_DESCALE_P2 times 4 dd 1 << (DESCALE_P2 - 1)
-PW_DESCALE_P2X times 8 dw 1 << (PASS1_BITS - 1)
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 64
-;
-; Perform the forward DCT on one block of samples.
-;
-; GLOBAL(void)
-; jsimd_fdct_islow_sse2(DCTELEM *data)
-;
-
-; r10 = DCTELEM *data
-
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
-%define WK_NUM 6
-
- align 32
- GLOBAL_FUNCTION(jsimd_fdct_islow_sse2)
-
-EXTN(jsimd_fdct_islow_sse2):
- push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
- and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
- collect_args 1
-
- ; ---- Pass 1: process rows.
-
- mov rdx, r10 ; (DCTELEM *)
-
- movdqa xmm0, XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_DCTELEM)]
- movdqa xmm1, XMMWORD [XMMBLOCK(1,0,rdx,SIZEOF_DCTELEM)]
- movdqa xmm2, XMMWORD [XMMBLOCK(2,0,rdx,SIZEOF_DCTELEM)]
- movdqa xmm3, XMMWORD [XMMBLOCK(3,0,rdx,SIZEOF_DCTELEM)]
-
- ; xmm0=(00 01 02 03 04 05 06 07), xmm2=(20 21 22 23 24 25 26 27)
- ; xmm1=(10 11 12 13 14 15 16 17), xmm3=(30 31 32 33 34 35 36 37)
-
- movdqa xmm4, xmm0 ; transpose coefficients(phase 1)
- punpcklwd xmm0, xmm1 ; xmm0=(00 10 01 11 02 12 03 13)
- punpckhwd xmm4, xmm1 ; xmm4=(04 14 05 15 06 16 07 17)
- movdqa xmm5, xmm2 ; transpose coefficients(phase 1)
- punpcklwd xmm2, xmm3 ; xmm2=(20 30 21 31 22 32 23 33)
- punpckhwd xmm5, xmm3 ; xmm5=(24 34 25 35 26 36 27 37)
-
- movdqa xmm6, XMMWORD [XMMBLOCK(4,0,rdx,SIZEOF_DCTELEM)]
- movdqa xmm7, XMMWORD [XMMBLOCK(5,0,rdx,SIZEOF_DCTELEM)]
- movdqa xmm1, XMMWORD [XMMBLOCK(6,0,rdx,SIZEOF_DCTELEM)]
- movdqa xmm3, XMMWORD [XMMBLOCK(7,0,rdx,SIZEOF_DCTELEM)]
-
- ; xmm6=( 4 12 20 28 36 44 52 60), xmm1=( 6 14 22 30 38 46 54 62)
- ; xmm7=( 5 13 21 29 37 45 53 61), xmm3=( 7 15 23 31 39 47 55 63)
-
- movdqa XMMWORD [wk(0)], xmm2 ; wk(0)=(20 30 21 31 22 32 23 33)
- movdqa XMMWORD [wk(1)], xmm5 ; wk(1)=(24 34 25 35 26 36 27 37)
-
- movdqa xmm2, xmm6 ; transpose coefficients(phase 1)
- punpcklwd xmm6, xmm7 ; xmm6=(40 50 41 51 42 52 43 53)
- punpckhwd xmm2, xmm7 ; xmm2=(44 54 45 55 46 56 47 57)
- movdqa xmm5, xmm1 ; transpose coefficients(phase 1)
- punpcklwd xmm1, xmm3 ; xmm1=(60 70 61 71 62 72 63 73)
- punpckhwd xmm5, xmm3 ; xmm5=(64 74 65 75 66 76 67 77)
-
- movdqa xmm7, xmm6 ; transpose coefficients(phase 2)
- punpckldq xmm6, xmm1 ; xmm6=(40 50 60 70 41 51 61 71)
- punpckhdq xmm7, xmm1 ; xmm7=(42 52 62 72 43 53 63 73)
- movdqa xmm3, xmm2 ; transpose coefficients(phase 2)
- punpckldq xmm2, xmm5 ; xmm2=(44 54 64 74 45 55 65 75)
- punpckhdq xmm3, xmm5 ; xmm3=(46 56 66 76 47 57 67 77)
-
- movdqa xmm1, XMMWORD [wk(0)] ; xmm1=(20 30 21 31 22 32 23 33)
- movdqa xmm5, XMMWORD [wk(1)] ; xmm5=(24 34 25 35 26 36 27 37)
- movdqa XMMWORD [wk(2)], xmm7 ; wk(2)=(42 52 62 72 43 53 63 73)
- movdqa XMMWORD [wk(3)], xmm2 ; wk(3)=(44 54 64 74 45 55 65 75)
-
- movdqa xmm7, xmm0 ; transpose coefficients(phase 2)
- punpckldq xmm0, xmm1 ; xmm0=(00 10 20 30 01 11 21 31)
- punpckhdq xmm7, xmm1 ; xmm7=(02 12 22 32 03 13 23 33)
- movdqa xmm2, xmm4 ; transpose coefficients(phase 2)
- punpckldq xmm4, xmm5 ; xmm4=(04 14 24 34 05 15 25 35)
- punpckhdq xmm2, xmm5 ; xmm2=(06 16 26 36 07 17 27 37)
-
- movdqa xmm1, xmm0 ; transpose coefficients(phase 3)
- punpcklqdq xmm0, xmm6 ; xmm0=(00 10 20 30 40 50 60 70)=data0
- punpckhqdq xmm1, xmm6 ; xmm1=(01 11 21 31 41 51 61 71)=data1
- movdqa xmm5, xmm2 ; transpose coefficients(phase 3)
- punpcklqdq xmm2, xmm3 ; xmm2=(06 16 26 36 46 56 66 76)=data6
- punpckhqdq xmm5, xmm3 ; xmm5=(07 17 27 37 47 57 67 77)=data7
-
- movdqa xmm6, xmm1
- movdqa xmm3, xmm0
- psubw xmm1, xmm2 ; xmm1=data1-data6=tmp6
- psubw xmm0, xmm5 ; xmm0=data0-data7=tmp7
- paddw xmm6, xmm2 ; xmm6=data1+data6=tmp1
- paddw xmm3, xmm5 ; xmm3=data0+data7=tmp0
-
- movdqa xmm2, XMMWORD [wk(2)] ; xmm2=(42 52 62 72 43 53 63 73)
- movdqa xmm5, XMMWORD [wk(3)] ; xmm5=(44 54 64 74 45 55 65 75)
- movdqa XMMWORD [wk(0)], xmm1 ; wk(0)=tmp6
- movdqa XMMWORD [wk(1)], xmm0 ; wk(1)=tmp7
-
- movdqa xmm1, xmm7 ; transpose coefficients(phase 3)
- punpcklqdq xmm7, xmm2 ; xmm7=(02 12 22 32 42 52 62 72)=data2
- punpckhqdq xmm1, xmm2 ; xmm1=(03 13 23 33 43 53 63 73)=data3
- movdqa xmm0, xmm4 ; transpose coefficients(phase 3)
- punpcklqdq xmm4, xmm5 ; xmm4=(04 14 24 34 44 54 64 74)=data4
- punpckhqdq xmm0, xmm5 ; xmm0=(05 15 25 35 45 55 65 75)=data5
-
- movdqa xmm2, xmm1
- movdqa xmm5, xmm7
- paddw xmm1, xmm4 ; xmm1=data3+data4=tmp3
- paddw xmm7, xmm0 ; xmm7=data2+data5=tmp2
- psubw xmm2, xmm4 ; xmm2=data3-data4=tmp4
- psubw xmm5, xmm0 ; xmm5=data2-data5=tmp5
-
- ; -- Even part
-
- movdqa xmm4, xmm3
- movdqa xmm0, xmm6
- paddw xmm3, xmm1 ; xmm3=tmp10
- paddw xmm6, xmm7 ; xmm6=tmp11
- psubw xmm4, xmm1 ; xmm4=tmp13
- psubw xmm0, xmm7 ; xmm0=tmp12
-
- movdqa xmm1, xmm3
- paddw xmm3, xmm6 ; xmm3=tmp10+tmp11
- psubw xmm1, xmm6 ; xmm1=tmp10-tmp11
-
- psllw xmm3, PASS1_BITS ; xmm3=data0
- psllw xmm1, PASS1_BITS ; xmm1=data4
-
- movdqa XMMWORD [wk(2)], xmm3 ; wk(2)=data0
- movdqa XMMWORD [wk(3)], xmm1 ; wk(3)=data4
-
- ; (Original)
- ; z1 = (tmp12 + tmp13) * 0.541196100;
- ; data2 = z1 + tmp13 * 0.765366865;
- ; data6 = z1 + tmp12 * -1.847759065;
- ;
- ; (This implementation)
- ; data2 = tmp13 * (0.541196100 + 0.765366865) + tmp12 * 0.541196100;
- ; data6 = tmp13 * 0.541196100 + tmp12 * (0.541196100 - 1.847759065);
-
- movdqa xmm7, xmm4 ; xmm4=tmp13
- movdqa xmm6, xmm4
- punpcklwd xmm7, xmm0 ; xmm0=tmp12
- punpckhwd xmm6, xmm0
- movdqa xmm4, xmm7
- movdqa xmm0, xmm6
- pmaddwd xmm7, [rel PW_F130_F054] ; xmm7=data2L
- pmaddwd xmm6, [rel PW_F130_F054] ; xmm6=data2H
- pmaddwd xmm4, [rel PW_F054_MF130] ; xmm4=data6L
- pmaddwd xmm0, [rel PW_F054_MF130] ; xmm0=data6H
-
- paddd xmm7, [rel PD_DESCALE_P1]
- paddd xmm6, [rel PD_DESCALE_P1]
- psrad xmm7, DESCALE_P1
- psrad xmm6, DESCALE_P1
- paddd xmm4, [rel PD_DESCALE_P1]
- paddd xmm0, [rel PD_DESCALE_P1]
- psrad xmm4, DESCALE_P1
- psrad xmm0, DESCALE_P1
-
- packssdw xmm7, xmm6 ; xmm7=data2
- packssdw xmm4, xmm0 ; xmm4=data6
-
- movdqa XMMWORD [wk(4)], xmm7 ; wk(4)=data2
- movdqa XMMWORD [wk(5)], xmm4 ; wk(5)=data6
-
- ; -- Odd part
-
- movdqa xmm3, XMMWORD [wk(0)] ; xmm3=tmp6
- movdqa xmm1, XMMWORD [wk(1)] ; xmm1=tmp7
-
- movdqa xmm6, xmm2 ; xmm2=tmp4
- movdqa xmm0, xmm5 ; xmm5=tmp5
- paddw xmm6, xmm3 ; xmm6=z3
- paddw xmm0, xmm1 ; xmm0=z4
-
- ; (Original)
- ; z5 = (z3 + z4) * 1.175875602;
- ; z3 = z3 * -1.961570560; z4 = z4 * -0.390180644;
- ; z3 += z5; z4 += z5;
- ;
- ; (This implementation)
- ; z3 = z3 * (1.175875602 - 1.961570560) + z4 * 1.175875602;
- ; z4 = z3 * 1.175875602 + z4 * (1.175875602 - 0.390180644);
-
- movdqa xmm7, xmm6
- movdqa xmm4, xmm6
- punpcklwd xmm7, xmm0
- punpckhwd xmm4, xmm0
- movdqa xmm6, xmm7
- movdqa xmm0, xmm4
- pmaddwd xmm7, [rel PW_MF078_F117] ; xmm7=z3L
- pmaddwd xmm4, [rel PW_MF078_F117] ; xmm4=z3H
- pmaddwd xmm6, [rel PW_F117_F078] ; xmm6=z4L
- pmaddwd xmm0, [rel PW_F117_F078] ; xmm0=z4H
-
- movdqa XMMWORD [wk(0)], xmm7 ; wk(0)=z3L
- movdqa XMMWORD [wk(1)], xmm4 ; wk(1)=z3H
-
- ; (Original)
- ; z1 = tmp4 + tmp7; z2 = tmp5 + tmp6;
- ; tmp4 = tmp4 * 0.298631336; tmp5 = tmp5 * 2.053119869;
- ; tmp6 = tmp6 * 3.072711026; tmp7 = tmp7 * 1.501321110;
- ; z1 = z1 * -0.899976223; z2 = z2 * -2.562915447;
- ; data7 = tmp4 + z1 + z3; data5 = tmp5 + z2 + z4;
- ; data3 = tmp6 + z2 + z3; data1 = tmp7 + z1 + z4;
- ;
- ; (This implementation)
- ; tmp4 = tmp4 * (0.298631336 - 0.899976223) + tmp7 * -0.899976223;
- ; tmp5 = tmp5 * (2.053119869 - 2.562915447) + tmp6 * -2.562915447;
- ; tmp6 = tmp5 * -2.562915447 + tmp6 * (3.072711026 - 2.562915447);
- ; tmp7 = tmp4 * -0.899976223 + tmp7 * (1.501321110 - 0.899976223);
- ; data7 = tmp4 + z3; data5 = tmp5 + z4;
- ; data3 = tmp6 + z3; data1 = tmp7 + z4;
-
- movdqa xmm7, xmm2
- movdqa xmm4, xmm2
- punpcklwd xmm7, xmm1
- punpckhwd xmm4, xmm1
- movdqa xmm2, xmm7
- movdqa xmm1, xmm4
- pmaddwd xmm7, [rel PW_MF060_MF089] ; xmm7=tmp4L
- pmaddwd xmm4, [rel PW_MF060_MF089] ; xmm4=tmp4H
- pmaddwd xmm2, [rel PW_MF089_F060] ; xmm2=tmp7L
- pmaddwd xmm1, [rel PW_MF089_F060] ; xmm1=tmp7H
-
- paddd xmm7, XMMWORD [wk(0)] ; xmm7=data7L
- paddd xmm4, XMMWORD [wk(1)] ; xmm4=data7H
- paddd xmm2, xmm6 ; xmm2=data1L
- paddd xmm1, xmm0 ; xmm1=data1H
-
- paddd xmm7, [rel PD_DESCALE_P1]
- paddd xmm4, [rel PD_DESCALE_P1]
- psrad xmm7, DESCALE_P1
- psrad xmm4, DESCALE_P1
- paddd xmm2, [rel PD_DESCALE_P1]
- paddd xmm1, [rel PD_DESCALE_P1]
- psrad xmm2, DESCALE_P1
- psrad xmm1, DESCALE_P1
-
- packssdw xmm7, xmm4 ; xmm7=data7
- packssdw xmm2, xmm1 ; xmm2=data1
-
- movdqa xmm4, xmm5
- movdqa xmm1, xmm5
- punpcklwd xmm4, xmm3
- punpckhwd xmm1, xmm3
- movdqa xmm5, xmm4
- movdqa xmm3, xmm1
- pmaddwd xmm4, [rel PW_MF050_MF256] ; xmm4=tmp5L
- pmaddwd xmm1, [rel PW_MF050_MF256] ; xmm1=tmp5H
- pmaddwd xmm5, [rel PW_MF256_F050] ; xmm5=tmp6L
- pmaddwd xmm3, [rel PW_MF256_F050] ; xmm3=tmp6H
-
- paddd xmm4, xmm6 ; xmm4=data5L
- paddd xmm1, xmm0 ; xmm1=data5H
- paddd xmm5, XMMWORD [wk(0)] ; xmm5=data3L
- paddd xmm3, XMMWORD [wk(1)] ; xmm3=data3H
-
- paddd xmm4, [rel PD_DESCALE_P1]
- paddd xmm1, [rel PD_DESCALE_P1]
- psrad xmm4, DESCALE_P1
- psrad xmm1, DESCALE_P1
- paddd xmm5, [rel PD_DESCALE_P1]
- paddd xmm3, [rel PD_DESCALE_P1]
- psrad xmm5, DESCALE_P1
- psrad xmm3, DESCALE_P1
-
- packssdw xmm4, xmm1 ; xmm4=data5
- packssdw xmm5, xmm3 ; xmm5=data3
-
- ; ---- Pass 2: process columns.
-
- movdqa xmm6, XMMWORD [wk(2)] ; xmm6=col0
- movdqa xmm0, XMMWORD [wk(4)] ; xmm0=col2
-
- ; xmm6=(00 10 20 30 40 50 60 70), xmm0=(02 12 22 32 42 52 62 72)
- ; xmm2=(01 11 21 31 41 51 61 71), xmm5=(03 13 23 33 43 53 63 73)
-
- movdqa xmm1, xmm6 ; transpose coefficients(phase 1)
- punpcklwd xmm6, xmm2 ; xmm6=(00 01 10 11 20 21 30 31)
- punpckhwd xmm1, xmm2 ; xmm1=(40 41 50 51 60 61 70 71)
- movdqa xmm3, xmm0 ; transpose coefficients(phase 1)
- punpcklwd xmm0, xmm5 ; xmm0=(02 03 12 13 22 23 32 33)
- punpckhwd xmm3, xmm5 ; xmm3=(42 43 52 53 62 63 72 73)
-
- movdqa xmm2, XMMWORD [wk(3)] ; xmm2=col4
- movdqa xmm5, XMMWORD [wk(5)] ; xmm5=col6
-
- ; xmm2=(04 14 24 34 44 54 64 74), xmm5=(06 16 26 36 46 56 66 76)
- ; xmm4=(05 15 25 35 45 55 65 75), xmm7=(07 17 27 37 47 57 67 77)
-
- movdqa XMMWORD [wk(0)], xmm0 ; wk(0)=(02 03 12 13 22 23 32 33)
- movdqa XMMWORD [wk(1)], xmm3 ; wk(1)=(42 43 52 53 62 63 72 73)
-
- movdqa xmm0, xmm2 ; transpose coefficients(phase 1)
- punpcklwd xmm2, xmm4 ; xmm2=(04 05 14 15 24 25 34 35)
- punpckhwd xmm0, xmm4 ; xmm0=(44 45 54 55 64 65 74 75)
- movdqa xmm3, xmm5 ; transpose coefficients(phase 1)
- punpcklwd xmm5, xmm7 ; xmm5=(06 07 16 17 26 27 36 37)
- punpckhwd xmm3, xmm7 ; xmm3=(46 47 56 57 66 67 76 77)
-
- movdqa xmm4, xmm2 ; transpose coefficients(phase 2)
- punpckldq xmm2, xmm5 ; xmm2=(04 05 06 07 14 15 16 17)
- punpckhdq xmm4, xmm5 ; xmm4=(24 25 26 27 34 35 36 37)
- movdqa xmm7, xmm0 ; transpose coefficients(phase 2)
- punpckldq xmm0, xmm3 ; xmm0=(44 45 46 47 54 55 56 57)
- punpckhdq xmm7, xmm3 ; xmm7=(64 65 66 67 74 75 76 77)
-
- movdqa xmm5, XMMWORD [wk(0)] ; xmm5=(02 03 12 13 22 23 32 33)
- movdqa xmm3, XMMWORD [wk(1)] ; xmm3=(42 43 52 53 62 63 72 73)
- movdqa XMMWORD [wk(2)], xmm4 ; wk(2)=(24 25 26 27 34 35 36 37)
- movdqa XMMWORD [wk(3)], xmm0 ; wk(3)=(44 45 46 47 54 55 56 57)
-
- movdqa xmm4, xmm6 ; transpose coefficients(phase 2)
- punpckldq xmm6, xmm5 ; xmm6=(00 01 02 03 10 11 12 13)
- punpckhdq xmm4, xmm5 ; xmm4=(20 21 22 23 30 31 32 33)
- movdqa xmm0, xmm1 ; transpose coefficients(phase 2)
- punpckldq xmm1, xmm3 ; xmm1=(40 41 42 43 50 51 52 53)
- punpckhdq xmm0, xmm3 ; xmm0=(60 61 62 63 70 71 72 73)
-
- movdqa xmm5, xmm6 ; transpose coefficients(phase 3)
- punpcklqdq xmm6, xmm2 ; xmm6=(00 01 02 03 04 05 06 07)=data0
- punpckhqdq xmm5, xmm2 ; xmm5=(10 11 12 13 14 15 16 17)=data1
- movdqa xmm3, xmm0 ; transpose coefficients(phase 3)
- punpcklqdq xmm0, xmm7 ; xmm0=(60 61 62 63 64 65 66 67)=data6
- punpckhqdq xmm3, xmm7 ; xmm3=(70 71 72 73 74 75 76 77)=data7
-
- movdqa xmm2, xmm5
- movdqa xmm7, xmm6
- psubw xmm5, xmm0 ; xmm5=data1-data6=tmp6
- psubw xmm6, xmm3 ; xmm6=data0-data7=tmp7
- paddw xmm2, xmm0 ; xmm2=data1+data6=tmp1
- paddw xmm7, xmm3 ; xmm7=data0+data7=tmp0
-
- movdqa xmm0, XMMWORD [wk(2)] ; xmm0=(24 25 26 27 34 35 36 37)
- movdqa xmm3, XMMWORD [wk(3)] ; xmm3=(44 45 46 47 54 55 56 57)
- movdqa XMMWORD [wk(0)], xmm5 ; wk(0)=tmp6
- movdqa XMMWORD [wk(1)], xmm6 ; wk(1)=tmp7
-
- movdqa xmm5, xmm4 ; transpose coefficients(phase 3)
- punpcklqdq xmm4, xmm0 ; xmm4=(20 21 22 23 24 25 26 27)=data2
- punpckhqdq xmm5, xmm0 ; xmm5=(30 31 32 33 34 35 36 37)=data3
- movdqa xmm6, xmm1 ; transpose coefficients(phase 3)
- punpcklqdq xmm1, xmm3 ; xmm1=(40 41 42 43 44 45 46 47)=data4
- punpckhqdq xmm6, xmm3 ; xmm6=(50 51 52 53 54 55 56 57)=data5
-
- movdqa xmm0, xmm5
- movdqa xmm3, xmm4
- paddw xmm5, xmm1 ; xmm5=data3+data4=tmp3
- paddw xmm4, xmm6 ; xmm4=data2+data5=tmp2
- psubw xmm0, xmm1 ; xmm0=data3-data4=tmp4
- psubw xmm3, xmm6 ; xmm3=data2-data5=tmp5
-
- ; -- Even part
-
- movdqa xmm1, xmm7
- movdqa xmm6, xmm2
- paddw xmm7, xmm5 ; xmm7=tmp10
- paddw xmm2, xmm4 ; xmm2=tmp11
- psubw xmm1, xmm5 ; xmm1=tmp13
- psubw xmm6, xmm4 ; xmm6=tmp12
-
- movdqa xmm5, xmm7
- paddw xmm7, xmm2 ; xmm7=tmp10+tmp11
- psubw xmm5, xmm2 ; xmm5=tmp10-tmp11
-
- paddw xmm7, [rel PW_DESCALE_P2X]
- paddw xmm5, [rel PW_DESCALE_P2X]
- psraw xmm7, PASS1_BITS ; xmm7=data0
- psraw xmm5, PASS1_BITS ; xmm5=data4
-
- movdqa XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_DCTELEM)], xmm7
- movdqa XMMWORD [XMMBLOCK(4,0,rdx,SIZEOF_DCTELEM)], xmm5
-
- ; (Original)
- ; z1 = (tmp12 + tmp13) * 0.541196100;
- ; data2 = z1 + tmp13 * 0.765366865;
- ; data6 = z1 + tmp12 * -1.847759065;
- ;
- ; (This implementation)
- ; data2 = tmp13 * (0.541196100 + 0.765366865) + tmp12 * 0.541196100;
- ; data6 = tmp13 * 0.541196100 + tmp12 * (0.541196100 - 1.847759065);
-
- movdqa xmm4, xmm1 ; xmm1=tmp13
- movdqa xmm2, xmm1
- punpcklwd xmm4, xmm6 ; xmm6=tmp12
- punpckhwd xmm2, xmm6
- movdqa xmm1, xmm4
- movdqa xmm6, xmm2
- pmaddwd xmm4, [rel PW_F130_F054] ; xmm4=data2L
- pmaddwd xmm2, [rel PW_F130_F054] ; xmm2=data2H
- pmaddwd xmm1, [rel PW_F054_MF130] ; xmm1=data6L
- pmaddwd xmm6, [rel PW_F054_MF130] ; xmm6=data6H
-
- paddd xmm4, [rel PD_DESCALE_P2]
- paddd xmm2, [rel PD_DESCALE_P2]
- psrad xmm4, DESCALE_P2
- psrad xmm2, DESCALE_P2
- paddd xmm1, [rel PD_DESCALE_P2]
- paddd xmm6, [rel PD_DESCALE_P2]
- psrad xmm1, DESCALE_P2
- psrad xmm6, DESCALE_P2
-
- packssdw xmm4, xmm2 ; xmm4=data2
- packssdw xmm1, xmm6 ; xmm1=data6
-
- movdqa XMMWORD [XMMBLOCK(2,0,rdx,SIZEOF_DCTELEM)], xmm4
- movdqa XMMWORD [XMMBLOCK(6,0,rdx,SIZEOF_DCTELEM)], xmm1
-
- ; -- Odd part
-
- movdqa xmm7, XMMWORD [wk(0)] ; xmm7=tmp6
- movdqa xmm5, XMMWORD [wk(1)] ; xmm5=tmp7
-
- movdqa xmm2, xmm0 ; xmm0=tmp4
- movdqa xmm6, xmm3 ; xmm3=tmp5
- paddw xmm2, xmm7 ; xmm2=z3
- paddw xmm6, xmm5 ; xmm6=z4
-
- ; (Original)
- ; z5 = (z3 + z4) * 1.175875602;
- ; z3 = z3 * -1.961570560; z4 = z4 * -0.390180644;
- ; z3 += z5; z4 += z5;
- ;
- ; (This implementation)
- ; z3 = z3 * (1.175875602 - 1.961570560) + z4 * 1.175875602;
- ; z4 = z3 * 1.175875602 + z4 * (1.175875602 - 0.390180644);
-
- movdqa xmm4, xmm2
- movdqa xmm1, xmm2
- punpcklwd xmm4, xmm6
- punpckhwd xmm1, xmm6
- movdqa xmm2, xmm4
- movdqa xmm6, xmm1
- pmaddwd xmm4, [rel PW_MF078_F117] ; xmm4=z3L
- pmaddwd xmm1, [rel PW_MF078_F117] ; xmm1=z3H
- pmaddwd xmm2, [rel PW_F117_F078] ; xmm2=z4L
- pmaddwd xmm6, [rel PW_F117_F078] ; xmm6=z4H
-
- movdqa XMMWORD [wk(0)], xmm4 ; wk(0)=z3L
- movdqa XMMWORD [wk(1)], xmm1 ; wk(1)=z3H
-
- ; (Original)
- ; z1 = tmp4 + tmp7; z2 = tmp5 + tmp6;
- ; tmp4 = tmp4 * 0.298631336; tmp5 = tmp5 * 2.053119869;
- ; tmp6 = tmp6 * 3.072711026; tmp7 = tmp7 * 1.501321110;
- ; z1 = z1 * -0.899976223; z2 = z2 * -2.562915447;
- ; data7 = tmp4 + z1 + z3; data5 = tmp5 + z2 + z4;
- ; data3 = tmp6 + z2 + z3; data1 = tmp7 + z1 + z4;
- ;
- ; (This implementation)
- ; tmp4 = tmp4 * (0.298631336 - 0.899976223) + tmp7 * -0.899976223;
- ; tmp5 = tmp5 * (2.053119869 - 2.562915447) + tmp6 * -2.562915447;
- ; tmp6 = tmp5 * -2.562915447 + tmp6 * (3.072711026 - 2.562915447);
- ; tmp7 = tmp4 * -0.899976223 + tmp7 * (1.501321110 - 0.899976223);
- ; data7 = tmp4 + z3; data5 = tmp5 + z4;
- ; data3 = tmp6 + z3; data1 = tmp7 + z4;
-
- movdqa xmm4, xmm0
- movdqa xmm1, xmm0
- punpcklwd xmm4, xmm5
- punpckhwd xmm1, xmm5
- movdqa xmm0, xmm4
- movdqa xmm5, xmm1
- pmaddwd xmm4, [rel PW_MF060_MF089] ; xmm4=tmp4L
- pmaddwd xmm1, [rel PW_MF060_MF089] ; xmm1=tmp4H
- pmaddwd xmm0, [rel PW_MF089_F060] ; xmm0=tmp7L
- pmaddwd xmm5, [rel PW_MF089_F060] ; xmm5=tmp7H
-
- paddd xmm4, XMMWORD [wk(0)] ; xmm4=data7L
- paddd xmm1, XMMWORD [wk(1)] ; xmm1=data7H
- paddd xmm0, xmm2 ; xmm0=data1L
- paddd xmm5, xmm6 ; xmm5=data1H
-
- paddd xmm4, [rel PD_DESCALE_P2]
- paddd xmm1, [rel PD_DESCALE_P2]
- psrad xmm4, DESCALE_P2
- psrad xmm1, DESCALE_P2
- paddd xmm0, [rel PD_DESCALE_P2]
- paddd xmm5, [rel PD_DESCALE_P2]
- psrad xmm0, DESCALE_P2
- psrad xmm5, DESCALE_P2
-
- packssdw xmm4, xmm1 ; xmm4=data7
- packssdw xmm0, xmm5 ; xmm0=data1
-
- movdqa XMMWORD [XMMBLOCK(7,0,rdx,SIZEOF_DCTELEM)], xmm4
- movdqa XMMWORD [XMMBLOCK(1,0,rdx,SIZEOF_DCTELEM)], xmm0
-
- movdqa xmm1, xmm3
- movdqa xmm5, xmm3
- punpcklwd xmm1, xmm7
- punpckhwd xmm5, xmm7
- movdqa xmm3, xmm1
- movdqa xmm7, xmm5
- pmaddwd xmm1, [rel PW_MF050_MF256] ; xmm1=tmp5L
- pmaddwd xmm5, [rel PW_MF050_MF256] ; xmm5=tmp5H
- pmaddwd xmm3, [rel PW_MF256_F050] ; xmm3=tmp6L
- pmaddwd xmm7, [rel PW_MF256_F050] ; xmm7=tmp6H
-
- paddd xmm1, xmm2 ; xmm1=data5L
- paddd xmm5, xmm6 ; xmm5=data5H
- paddd xmm3, XMMWORD [wk(0)] ; xmm3=data3L
- paddd xmm7, XMMWORD [wk(1)] ; xmm7=data3H
-
- paddd xmm1, [rel PD_DESCALE_P2]
- paddd xmm5, [rel PD_DESCALE_P2]
- psrad xmm1, DESCALE_P2
- psrad xmm5, DESCALE_P2
- paddd xmm3, [rel PD_DESCALE_P2]
- paddd xmm7, [rel PD_DESCALE_P2]
- psrad xmm3, DESCALE_P2
- psrad xmm7, DESCALE_P2
-
- packssdw xmm1, xmm5 ; xmm1=data5
- packssdw xmm3, xmm7 ; xmm3=data3
-
- movdqa XMMWORD [XMMBLOCK(5,0,rdx,SIZEOF_DCTELEM)], xmm1
- movdqa XMMWORD [XMMBLOCK(3,0,rdx,SIZEOF_DCTELEM)], xmm3
-
- uncollect_args 1
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
- pop rbp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jidctflt-sse2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jidctflt-sse2.asm
deleted file mode 100644
index 60bf961896..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jidctflt-sse2.asm
+++ /dev/null
@@ -1,482 +0,0 @@
-;
-; jidctflt.asm - floating-point IDCT (64-bit SSE & SSE2)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
-; Copyright (C) 2018, Matthias Räncker.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-;
-; This file contains a floating-point implementation of the inverse DCT
-; (Discrete Cosine Transform). The following code is based directly on
-; the IJG's original jidctflt.c; see the jidctflt.c for more details.
-
-%include "jsimdext.inc"
-%include "jdct.inc"
-
-; --------------------------------------------------------------------------
-
-%macro unpcklps2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(0 1 4 5)
- shufps %1, %2, 0x44
-%endmacro
-
-%macro unpckhps2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(2 3 6 7)
- shufps %1, %2, 0xEE
-%endmacro
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_idct_float_sse2)
-
-EXTN(jconst_idct_float_sse2):
-
-PD_1_414 times 4 dd 1.414213562373095048801689
-PD_1_847 times 4 dd 1.847759065022573512256366
-PD_1_082 times 4 dd 1.082392200292393968799446
-PD_M2_613 times 4 dd -2.613125929752753055713286
-PD_RNDINT_MAGIC times 4 dd 100663296.0 ; (float)(0x00C00000 << 3)
-PB_CENTERJSAMP times 16 db CENTERJSAMPLE
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 64
-;
-; Perform dequantization and inverse DCT on one block of coefficients.
-;
-; GLOBAL(void)
-; jsimd_idct_float_sse2(void *dct_table, JCOEFPTR coef_block,
-; JSAMPARRAY output_buf, JDIMENSION output_col)
-;
-
-; r10 = void *dct_table
-; r11 = JCOEFPTR coef_block
-; r12 = JSAMPARRAY output_buf
-; r13d = JDIMENSION output_col
-
-%define original_rbp rbp + 0
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_XMMWORD
- ; xmmword wk[WK_NUM]
-%define WK_NUM 2
-%define workspace wk(0) - DCTSIZE2 * SIZEOF_FAST_FLOAT
- ; FAST_FLOAT workspace[DCTSIZE2]
-
- align 32
- GLOBAL_FUNCTION(jsimd_idct_float_sse2)
-
-EXTN(jsimd_idct_float_sse2):
- push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
- and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [workspace]
- collect_args 4
- push rbx
-
- ; ---- Pass 1: process columns from input, store into work array.
-
- mov rdx, r10 ; quantptr
- mov rsi, r11 ; inptr
- lea rdi, [workspace] ; FAST_FLOAT *wsptr
- mov rcx, DCTSIZE/4 ; ctr
-.columnloop:
-%ifndef NO_ZERO_COLUMN_TEST_FLOAT_SSE
- mov eax, dword [DWBLOCK(1,0,rsi,SIZEOF_JCOEF)]
- or eax, dword [DWBLOCK(2,0,rsi,SIZEOF_JCOEF)]
- jnz near .columnDCT
-
- movq xmm1, XMM_MMWORD [MMBLOCK(1,0,rsi,SIZEOF_JCOEF)]
- movq xmm2, XMM_MMWORD [MMBLOCK(2,0,rsi,SIZEOF_JCOEF)]
- movq xmm3, XMM_MMWORD [MMBLOCK(3,0,rsi,SIZEOF_JCOEF)]
- movq xmm4, XMM_MMWORD [MMBLOCK(4,0,rsi,SIZEOF_JCOEF)]
- movq xmm5, XMM_MMWORD [MMBLOCK(5,0,rsi,SIZEOF_JCOEF)]
- movq xmm6, XMM_MMWORD [MMBLOCK(6,0,rsi,SIZEOF_JCOEF)]
- movq xmm7, XMM_MMWORD [MMBLOCK(7,0,rsi,SIZEOF_JCOEF)]
- por xmm1, xmm2
- por xmm3, xmm4
- por xmm5, xmm6
- por xmm1, xmm3
- por xmm5, xmm7
- por xmm1, xmm5
- packsswb xmm1, xmm1
- movd eax, xmm1
- test rax, rax
- jnz short .columnDCT
-
- ; -- AC terms all zero
-
- movq xmm0, XMM_MMWORD [MMBLOCK(0,0,rsi,SIZEOF_JCOEF)]
-
- punpcklwd xmm0, xmm0 ; xmm0=(00 00 01 01 02 02 03 03)
- psrad xmm0, (DWORD_BIT-WORD_BIT) ; xmm0=in0=(00 01 02 03)
- cvtdq2ps xmm0, xmm0 ; xmm0=in0=(00 01 02 03)
-
- mulps xmm0, XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_FLOAT_MULT_TYPE)]
-
- movaps xmm1, xmm0
- movaps xmm2, xmm0
- movaps xmm3, xmm0
-
- shufps xmm0, xmm0, 0x00 ; xmm0=(00 00 00 00)
- shufps xmm1, xmm1, 0x55 ; xmm1=(01 01 01 01)
- shufps xmm2, xmm2, 0xAA ; xmm2=(02 02 02 02)
- shufps xmm3, xmm3, 0xFF ; xmm3=(03 03 03 03)
-
- movaps XMMWORD [XMMBLOCK(0,0,rdi,SIZEOF_FAST_FLOAT)], xmm0
- movaps XMMWORD [XMMBLOCK(0,1,rdi,SIZEOF_FAST_FLOAT)], xmm0
- movaps XMMWORD [XMMBLOCK(1,0,rdi,SIZEOF_FAST_FLOAT)], xmm1
- movaps XMMWORD [XMMBLOCK(1,1,rdi,SIZEOF_FAST_FLOAT)], xmm1
- movaps XMMWORD [XMMBLOCK(2,0,rdi,SIZEOF_FAST_FLOAT)], xmm2
- movaps XMMWORD [XMMBLOCK(2,1,rdi,SIZEOF_FAST_FLOAT)], xmm2
- movaps XMMWORD [XMMBLOCK(3,0,rdi,SIZEOF_FAST_FLOAT)], xmm3
- movaps XMMWORD [XMMBLOCK(3,1,rdi,SIZEOF_FAST_FLOAT)], xmm3
- jmp near .nextcolumn
-%endif
-.columnDCT:
-
- ; -- Even part
-
- movq xmm0, XMM_MMWORD [MMBLOCK(0,0,rsi,SIZEOF_JCOEF)]
- movq xmm1, XMM_MMWORD [MMBLOCK(2,0,rsi,SIZEOF_JCOEF)]
- movq xmm2, XMM_MMWORD [MMBLOCK(4,0,rsi,SIZEOF_JCOEF)]
- movq xmm3, XMM_MMWORD [MMBLOCK(6,0,rsi,SIZEOF_JCOEF)]
-
- punpcklwd xmm0, xmm0 ; xmm0=(00 00 01 01 02 02 03 03)
- punpcklwd xmm1, xmm1 ; xmm1=(20 20 21 21 22 22 23 23)
- psrad xmm0, (DWORD_BIT-WORD_BIT) ; xmm0=in0=(00 01 02 03)
- psrad xmm1, (DWORD_BIT-WORD_BIT) ; xmm1=in2=(20 21 22 23)
- cvtdq2ps xmm0, xmm0 ; xmm0=in0=(00 01 02 03)
- cvtdq2ps xmm1, xmm1 ; xmm1=in2=(20 21 22 23)
-
- punpcklwd xmm2, xmm2 ; xmm2=(40 40 41 41 42 42 43 43)
- punpcklwd xmm3, xmm3 ; xmm3=(60 60 61 61 62 62 63 63)
- psrad xmm2, (DWORD_BIT-WORD_BIT) ; xmm2=in4=(40 41 42 43)
- psrad xmm3, (DWORD_BIT-WORD_BIT) ; xmm3=in6=(60 61 62 63)
- cvtdq2ps xmm2, xmm2 ; xmm2=in4=(40 41 42 43)
- cvtdq2ps xmm3, xmm3 ; xmm3=in6=(60 61 62 63)
-
- mulps xmm0, XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_FLOAT_MULT_TYPE)]
- mulps xmm1, XMMWORD [XMMBLOCK(2,0,rdx,SIZEOF_FLOAT_MULT_TYPE)]
- mulps xmm2, XMMWORD [XMMBLOCK(4,0,rdx,SIZEOF_FLOAT_MULT_TYPE)]
- mulps xmm3, XMMWORD [XMMBLOCK(6,0,rdx,SIZEOF_FLOAT_MULT_TYPE)]
-
- movaps xmm4, xmm0
- movaps xmm5, xmm1
- subps xmm0, xmm2 ; xmm0=tmp11
- subps xmm1, xmm3
- addps xmm4, xmm2 ; xmm4=tmp10
- addps xmm5, xmm3 ; xmm5=tmp13
-
- mulps xmm1, [rel PD_1_414]
- subps xmm1, xmm5 ; xmm1=tmp12
-
- movaps xmm6, xmm4
- movaps xmm7, xmm0
- subps xmm4, xmm5 ; xmm4=tmp3
- subps xmm0, xmm1 ; xmm0=tmp2
- addps xmm6, xmm5 ; xmm6=tmp0
- addps xmm7, xmm1 ; xmm7=tmp1
-
- movaps XMMWORD [wk(1)], xmm4 ; tmp3
- movaps XMMWORD [wk(0)], xmm0 ; tmp2
-
- ; -- Odd part
-
- movq xmm2, XMM_MMWORD [MMBLOCK(1,0,rsi,SIZEOF_JCOEF)]
- movq xmm3, XMM_MMWORD [MMBLOCK(3,0,rsi,SIZEOF_JCOEF)]
- movq xmm5, XMM_MMWORD [MMBLOCK(5,0,rsi,SIZEOF_JCOEF)]
- movq xmm1, XMM_MMWORD [MMBLOCK(7,0,rsi,SIZEOF_JCOEF)]
-
- punpcklwd xmm2, xmm2 ; xmm2=(10 10 11 11 12 12 13 13)
- punpcklwd xmm3, xmm3 ; xmm3=(30 30 31 31 32 32 33 33)
- psrad xmm2, (DWORD_BIT-WORD_BIT) ; xmm2=in1=(10 11 12 13)
- psrad xmm3, (DWORD_BIT-WORD_BIT) ; xmm3=in3=(30 31 32 33)
- cvtdq2ps xmm2, xmm2 ; xmm2=in1=(10 11 12 13)
- cvtdq2ps xmm3, xmm3 ; xmm3=in3=(30 31 32 33)
-
- punpcklwd xmm5, xmm5 ; xmm5=(50 50 51 51 52 52 53 53)
- punpcklwd xmm1, xmm1 ; xmm1=(70 70 71 71 72 72 73 73)
- psrad xmm5, (DWORD_BIT-WORD_BIT) ; xmm5=in5=(50 51 52 53)
- psrad xmm1, (DWORD_BIT-WORD_BIT) ; xmm1=in7=(70 71 72 73)
- cvtdq2ps xmm5, xmm5 ; xmm5=in5=(50 51 52 53)
- cvtdq2ps xmm1, xmm1 ; xmm1=in7=(70 71 72 73)
-
- mulps xmm2, XMMWORD [XMMBLOCK(1,0,rdx,SIZEOF_FLOAT_MULT_TYPE)]
- mulps xmm3, XMMWORD [XMMBLOCK(3,0,rdx,SIZEOF_FLOAT_MULT_TYPE)]
- mulps xmm5, XMMWORD [XMMBLOCK(5,0,rdx,SIZEOF_FLOAT_MULT_TYPE)]
- mulps xmm1, XMMWORD [XMMBLOCK(7,0,rdx,SIZEOF_FLOAT_MULT_TYPE)]
-
- movaps xmm4, xmm2
- movaps xmm0, xmm5
- addps xmm2, xmm1 ; xmm2=z11
- addps xmm5, xmm3 ; xmm5=z13
- subps xmm4, xmm1 ; xmm4=z12
- subps xmm0, xmm3 ; xmm0=z10
-
- movaps xmm1, xmm2
- subps xmm2, xmm5
- addps xmm1, xmm5 ; xmm1=tmp7
-
- mulps xmm2, [rel PD_1_414] ; xmm2=tmp11
-
- movaps xmm3, xmm0
- addps xmm0, xmm4
- mulps xmm0, [rel PD_1_847] ; xmm0=z5
- mulps xmm3, [rel PD_M2_613] ; xmm3=(z10 * -2.613125930)
- mulps xmm4, [rel PD_1_082] ; xmm4=(z12 * 1.082392200)
- addps xmm3, xmm0 ; xmm3=tmp12
- subps xmm4, xmm0 ; xmm4=tmp10
-
- ; -- Final output stage
-
- subps xmm3, xmm1 ; xmm3=tmp6
- movaps xmm5, xmm6
- movaps xmm0, xmm7
- addps xmm6, xmm1 ; xmm6=data0=(00 01 02 03)
- addps xmm7, xmm3 ; xmm7=data1=(10 11 12 13)
- subps xmm5, xmm1 ; xmm5=data7=(70 71 72 73)
- subps xmm0, xmm3 ; xmm0=data6=(60 61 62 63)
- subps xmm2, xmm3 ; xmm2=tmp5
-
- movaps xmm1, xmm6 ; transpose coefficients(phase 1)
- unpcklps xmm6, xmm7 ; xmm6=(00 10 01 11)
- unpckhps xmm1, xmm7 ; xmm1=(02 12 03 13)
- movaps xmm3, xmm0 ; transpose coefficients(phase 1)
- unpcklps xmm0, xmm5 ; xmm0=(60 70 61 71)
- unpckhps xmm3, xmm5 ; xmm3=(62 72 63 73)
-
- movaps xmm7, XMMWORD [wk(0)] ; xmm7=tmp2
- movaps xmm5, XMMWORD [wk(1)] ; xmm5=tmp3
-
- movaps XMMWORD [wk(0)], xmm0 ; wk(0)=(60 70 61 71)
- movaps XMMWORD [wk(1)], xmm3 ; wk(1)=(62 72 63 73)
-
- addps xmm4, xmm2 ; xmm4=tmp4
- movaps xmm0, xmm7
- movaps xmm3, xmm5
- addps xmm7, xmm2 ; xmm7=data2=(20 21 22 23)
- addps xmm5, xmm4 ; xmm5=data4=(40 41 42 43)
- subps xmm0, xmm2 ; xmm0=data5=(50 51 52 53)
- subps xmm3, xmm4 ; xmm3=data3=(30 31 32 33)
-
- movaps xmm2, xmm7 ; transpose coefficients(phase 1)
- unpcklps xmm7, xmm3 ; xmm7=(20 30 21 31)
- unpckhps xmm2, xmm3 ; xmm2=(22 32 23 33)
- movaps xmm4, xmm5 ; transpose coefficients(phase 1)
- unpcklps xmm5, xmm0 ; xmm5=(40 50 41 51)
- unpckhps xmm4, xmm0 ; xmm4=(42 52 43 53)
-
- movaps xmm3, xmm6 ; transpose coefficients(phase 2)
- unpcklps2 xmm6, xmm7 ; xmm6=(00 10 20 30)
- unpckhps2 xmm3, xmm7 ; xmm3=(01 11 21 31)
- movaps xmm0, xmm1 ; transpose coefficients(phase 2)
- unpcklps2 xmm1, xmm2 ; xmm1=(02 12 22 32)
- unpckhps2 xmm0, xmm2 ; xmm0=(03 13 23 33)
-
- movaps xmm7, XMMWORD [wk(0)] ; xmm7=(60 70 61 71)
- movaps xmm2, XMMWORD [wk(1)] ; xmm2=(62 72 63 73)
-
- movaps XMMWORD [XMMBLOCK(0,0,rdi,SIZEOF_FAST_FLOAT)], xmm6
- movaps XMMWORD [XMMBLOCK(1,0,rdi,SIZEOF_FAST_FLOAT)], xmm3
- movaps XMMWORD [XMMBLOCK(2,0,rdi,SIZEOF_FAST_FLOAT)], xmm1
- movaps XMMWORD [XMMBLOCK(3,0,rdi,SIZEOF_FAST_FLOAT)], xmm0
-
- movaps xmm6, xmm5 ; transpose coefficients(phase 2)
- unpcklps2 xmm5, xmm7 ; xmm5=(40 50 60 70)
- unpckhps2 xmm6, xmm7 ; xmm6=(41 51 61 71)
- movaps xmm3, xmm4 ; transpose coefficients(phase 2)
- unpcklps2 xmm4, xmm2 ; xmm4=(42 52 62 72)
- unpckhps2 xmm3, xmm2 ; xmm3=(43 53 63 73)
-
- movaps XMMWORD [XMMBLOCK(0,1,rdi,SIZEOF_FAST_FLOAT)], xmm5
- movaps XMMWORD [XMMBLOCK(1,1,rdi,SIZEOF_FAST_FLOAT)], xmm6
- movaps XMMWORD [XMMBLOCK(2,1,rdi,SIZEOF_FAST_FLOAT)], xmm4
- movaps XMMWORD [XMMBLOCK(3,1,rdi,SIZEOF_FAST_FLOAT)], xmm3
-
-.nextcolumn:
- add rsi, byte 4*SIZEOF_JCOEF ; coef_block
- add rdx, byte 4*SIZEOF_FLOAT_MULT_TYPE ; quantptr
- add rdi, 4*DCTSIZE*SIZEOF_FAST_FLOAT ; wsptr
- dec rcx ; ctr
- jnz near .columnloop
-
- ; -- Prefetch the next coefficient block
-
- prefetchnta [rsi + (DCTSIZE2-8)*SIZEOF_JCOEF + 0*32]
- prefetchnta [rsi + (DCTSIZE2-8)*SIZEOF_JCOEF + 1*32]
- prefetchnta [rsi + (DCTSIZE2-8)*SIZEOF_JCOEF + 2*32]
- prefetchnta [rsi + (DCTSIZE2-8)*SIZEOF_JCOEF + 3*32]
-
- ; ---- Pass 2: process rows from work array, store into output array.
-
- mov rax, [original_rbp]
- lea rsi, [workspace] ; FAST_FLOAT *wsptr
- mov rdi, r12 ; (JSAMPROW *)
- mov eax, r13d
- mov rcx, DCTSIZE/4 ; ctr
-.rowloop:
-
- ; -- Even part
-
- movaps xmm0, XMMWORD [XMMBLOCK(0,0,rsi,SIZEOF_FAST_FLOAT)]
- movaps xmm1, XMMWORD [XMMBLOCK(2,0,rsi,SIZEOF_FAST_FLOAT)]
- movaps xmm2, XMMWORD [XMMBLOCK(4,0,rsi,SIZEOF_FAST_FLOAT)]
- movaps xmm3, XMMWORD [XMMBLOCK(6,0,rsi,SIZEOF_FAST_FLOAT)]
-
- movaps xmm4, xmm0
- movaps xmm5, xmm1
- subps xmm0, xmm2 ; xmm0=tmp11
- subps xmm1, xmm3
- addps xmm4, xmm2 ; xmm4=tmp10
- addps xmm5, xmm3 ; xmm5=tmp13
-
- mulps xmm1, [rel PD_1_414]
- subps xmm1, xmm5 ; xmm1=tmp12
-
- movaps xmm6, xmm4
- movaps xmm7, xmm0
- subps xmm4, xmm5 ; xmm4=tmp3
- subps xmm0, xmm1 ; xmm0=tmp2
- addps xmm6, xmm5 ; xmm6=tmp0
- addps xmm7, xmm1 ; xmm7=tmp1
-
- movaps XMMWORD [wk(1)], xmm4 ; tmp3
- movaps XMMWORD [wk(0)], xmm0 ; tmp2
-
- ; -- Odd part
-
- movaps xmm2, XMMWORD [XMMBLOCK(1,0,rsi,SIZEOF_FAST_FLOAT)]
- movaps xmm3, XMMWORD [XMMBLOCK(3,0,rsi,SIZEOF_FAST_FLOAT)]
- movaps xmm5, XMMWORD [XMMBLOCK(5,0,rsi,SIZEOF_FAST_FLOAT)]
- movaps xmm1, XMMWORD [XMMBLOCK(7,0,rsi,SIZEOF_FAST_FLOAT)]
-
- movaps xmm4, xmm2
- movaps xmm0, xmm5
- addps xmm2, xmm1 ; xmm2=z11
- addps xmm5, xmm3 ; xmm5=z13
- subps xmm4, xmm1 ; xmm4=z12
- subps xmm0, xmm3 ; xmm0=z10
-
- movaps xmm1, xmm2
- subps xmm2, xmm5
- addps xmm1, xmm5 ; xmm1=tmp7
-
- mulps xmm2, [rel PD_1_414] ; xmm2=tmp11
-
- movaps xmm3, xmm0
- addps xmm0, xmm4
- mulps xmm0, [rel PD_1_847] ; xmm0=z5
- mulps xmm3, [rel PD_M2_613] ; xmm3=(z10 * -2.613125930)
- mulps xmm4, [rel PD_1_082] ; xmm4=(z12 * 1.082392200)
- addps xmm3, xmm0 ; xmm3=tmp12
- subps xmm4, xmm0 ; xmm4=tmp10
-
- ; -- Final output stage
-
- subps xmm3, xmm1 ; xmm3=tmp6
- movaps xmm5, xmm6
- movaps xmm0, xmm7
- addps xmm6, xmm1 ; xmm6=data0=(00 10 20 30)
- addps xmm7, xmm3 ; xmm7=data1=(01 11 21 31)
- subps xmm5, xmm1 ; xmm5=data7=(07 17 27 37)
- subps xmm0, xmm3 ; xmm0=data6=(06 16 26 36)
- subps xmm2, xmm3 ; xmm2=tmp5
-
- movaps xmm1, [rel PD_RNDINT_MAGIC] ; xmm1=[rel PD_RNDINT_MAGIC]
- pcmpeqd xmm3, xmm3
- psrld xmm3, WORD_BIT ; xmm3={0xFFFF 0x0000 0xFFFF 0x0000 ..}
-
- addps xmm6, xmm1 ; xmm6=roundint(data0/8)=(00 ** 10 ** 20 ** 30 **)
- addps xmm7, xmm1 ; xmm7=roundint(data1/8)=(01 ** 11 ** 21 ** 31 **)
- addps xmm0, xmm1 ; xmm0=roundint(data6/8)=(06 ** 16 ** 26 ** 36 **)
- addps xmm5, xmm1 ; xmm5=roundint(data7/8)=(07 ** 17 ** 27 ** 37 **)
-
- pand xmm6, xmm3 ; xmm6=(00 -- 10 -- 20 -- 30 --)
- pslld xmm7, WORD_BIT ; xmm7=(-- 01 -- 11 -- 21 -- 31)
- pand xmm0, xmm3 ; xmm0=(06 -- 16 -- 26 -- 36 --)
- pslld xmm5, WORD_BIT ; xmm5=(-- 07 -- 17 -- 27 -- 37)
- por xmm6, xmm7 ; xmm6=(00 01 10 11 20 21 30 31)
- por xmm0, xmm5 ; xmm0=(06 07 16 17 26 27 36 37)
-
- movaps xmm1, XMMWORD [wk(0)] ; xmm1=tmp2
- movaps xmm3, XMMWORD [wk(1)] ; xmm3=tmp3
-
- addps xmm4, xmm2 ; xmm4=tmp4
- movaps xmm7, xmm1
- movaps xmm5, xmm3
- addps xmm1, xmm2 ; xmm1=data2=(02 12 22 32)
- addps xmm3, xmm4 ; xmm3=data4=(04 14 24 34)
- subps xmm7, xmm2 ; xmm7=data5=(05 15 25 35)
- subps xmm5, xmm4 ; xmm5=data3=(03 13 23 33)
-
- movaps xmm2, [rel PD_RNDINT_MAGIC] ; xmm2=[rel PD_RNDINT_MAGIC]
- pcmpeqd xmm4, xmm4
- psrld xmm4, WORD_BIT ; xmm4={0xFFFF 0x0000 0xFFFF 0x0000 ..}
-
- addps xmm3, xmm2 ; xmm3=roundint(data4/8)=(04 ** 14 ** 24 ** 34 **)
- addps xmm7, xmm2 ; xmm7=roundint(data5/8)=(05 ** 15 ** 25 ** 35 **)
- addps xmm1, xmm2 ; xmm1=roundint(data2/8)=(02 ** 12 ** 22 ** 32 **)
- addps xmm5, xmm2 ; xmm5=roundint(data3/8)=(03 ** 13 ** 23 ** 33 **)
-
- pand xmm3, xmm4 ; xmm3=(04 -- 14 -- 24 -- 34 --)
- pslld xmm7, WORD_BIT ; xmm7=(-- 05 -- 15 -- 25 -- 35)
- pand xmm1, xmm4 ; xmm1=(02 -- 12 -- 22 -- 32 --)
- pslld xmm5, WORD_BIT ; xmm5=(-- 03 -- 13 -- 23 -- 33)
- por xmm3, xmm7 ; xmm3=(04 05 14 15 24 25 34 35)
- por xmm1, xmm5 ; xmm1=(02 03 12 13 22 23 32 33)
-
- movdqa xmm2, [rel PB_CENTERJSAMP] ; xmm2=[rel PB_CENTERJSAMP]
-
- packsswb xmm6, xmm3 ; xmm6=(00 01 10 11 20 21 30 31 04 05 14 15 24 25 34 35)
- packsswb xmm1, xmm0 ; xmm1=(02 03 12 13 22 23 32 33 06 07 16 17 26 27 36 37)
- paddb xmm6, xmm2
- paddb xmm1, xmm2
-
- movdqa xmm4, xmm6 ; transpose coefficients(phase 2)
- punpcklwd xmm6, xmm1 ; xmm6=(00 01 02 03 10 11 12 13 20 21 22 23 30 31 32 33)
- punpckhwd xmm4, xmm1 ; xmm4=(04 05 06 07 14 15 16 17 24 25 26 27 34 35 36 37)
-
- movdqa xmm7, xmm6 ; transpose coefficients(phase 3)
- punpckldq xmm6, xmm4 ; xmm6=(00 01 02 03 04 05 06 07 10 11 12 13 14 15 16 17)
- punpckhdq xmm7, xmm4 ; xmm7=(20 21 22 23 24 25 26 27 30 31 32 33 34 35 36 37)
-
- pshufd xmm5, xmm6, 0x4E ; xmm5=(10 11 12 13 14 15 16 17 00 01 02 03 04 05 06 07)
- pshufd xmm3, xmm7, 0x4E ; xmm3=(30 31 32 33 34 35 36 37 20 21 22 23 24 25 26 27)
-
- mov rdxp, JSAMPROW [rdi+0*SIZEOF_JSAMPROW]
- mov rbxp, JSAMPROW [rdi+2*SIZEOF_JSAMPROW]
- movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm6
- movq XMM_MMWORD [rbx+rax*SIZEOF_JSAMPLE], xmm7
- mov rdxp, JSAMPROW [rdi+1*SIZEOF_JSAMPROW]
- mov rbxp, JSAMPROW [rdi+3*SIZEOF_JSAMPROW]
- movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm5
- movq XMM_MMWORD [rbx+rax*SIZEOF_JSAMPLE], xmm3
-
- add rsi, byte 4*SIZEOF_FAST_FLOAT ; wsptr
- add rdi, byte 4*SIZEOF_JSAMPROW
- dec rcx ; ctr
- jnz near .rowloop
-
- pop rbx
- uncollect_args 4
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
- pop rbp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jidctfst-sse2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jidctfst-sse2.asm
deleted file mode 100644
index cb97fdfbb2..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jidctfst-sse2.asm
+++ /dev/null
@@ -1,491 +0,0 @@
-;
-; jidctfst.asm - fast integer IDCT (64-bit SSE2)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
-; Copyright (C) 2018, Matthias Räncker.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-;
-; This file contains a fast, not so accurate integer implementation of
-; the inverse DCT (Discrete Cosine Transform). The following code is
-; based directly on the IJG's original jidctfst.c; see the jidctfst.c
-; for more details.
-
-%include "jsimdext.inc"
-%include "jdct.inc"
-
-; --------------------------------------------------------------------------
-
-%define CONST_BITS 8 ; 14 is also OK.
-%define PASS1_BITS 2
-
-%if IFAST_SCALE_BITS != PASS1_BITS
-%error "'IFAST_SCALE_BITS' must be equal to 'PASS1_BITS'."
-%endif
-
-%if CONST_BITS == 8
-F_1_082 equ 277 ; FIX(1.082392200)
-F_1_414 equ 362 ; FIX(1.414213562)
-F_1_847 equ 473 ; FIX(1.847759065)
-F_2_613 equ 669 ; FIX(2.613125930)
-F_1_613 equ (F_2_613 - 256) ; FIX(2.613125930) - FIX(1)
-%else
-; NASM cannot do compile-time arithmetic on floating-point constants.
-%define DESCALE(x, n) (((x) + (1 << ((n) - 1))) >> (n))
-F_1_082 equ DESCALE(1162209775, 30 - CONST_BITS) ; FIX(1.082392200)
-F_1_414 equ DESCALE(1518500249, 30 - CONST_BITS) ; FIX(1.414213562)
-F_1_847 equ DESCALE(1984016188, 30 - CONST_BITS) ; FIX(1.847759065)
-F_2_613 equ DESCALE(2805822602, 30 - CONST_BITS) ; FIX(2.613125930)
-F_1_613 equ (F_2_613 - (1 << CONST_BITS)) ; FIX(2.613125930) - FIX(1)
-%endif
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
-; PRE_MULTIPLY_SCALE_BITS <= 2 (to avoid overflow)
-; CONST_BITS + CONST_SHIFT + PRE_MULTIPLY_SCALE_BITS == 16 (for pmulhw)
-
-%define PRE_MULTIPLY_SCALE_BITS 2
-%define CONST_SHIFT (16 - PRE_MULTIPLY_SCALE_BITS - CONST_BITS)
-
- alignz 32
- GLOBAL_DATA(jconst_idct_ifast_sse2)
-
-EXTN(jconst_idct_ifast_sse2):
-
-PW_F1414 times 8 dw F_1_414 << CONST_SHIFT
-PW_F1847 times 8 dw F_1_847 << CONST_SHIFT
-PW_MF1613 times 8 dw -F_1_613 << CONST_SHIFT
-PW_F1082 times 8 dw F_1_082 << CONST_SHIFT
-PB_CENTERJSAMP times 16 db CENTERJSAMPLE
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 64
-;
-; Perform dequantization and inverse DCT on one block of coefficients.
-;
-; GLOBAL(void)
-; jsimd_idct_ifast_sse2(void *dct_table, JCOEFPTR coef_block,
-; JSAMPARRAY output_buf, JDIMENSION output_col)
-;
-
-; r10 = jpeg_component_info *compptr
-; r11 = JCOEFPTR coef_block
-; r12 = JSAMPARRAY output_buf
-; r13d = JDIMENSION output_col
-
-%define original_rbp rbp + 0
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_XMMWORD
- ; xmmword wk[WK_NUM]
-%define WK_NUM 2
-
- align 32
- GLOBAL_FUNCTION(jsimd_idct_ifast_sse2)
-
-EXTN(jsimd_idct_ifast_sse2):
- push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
- and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
- collect_args 4
-
- ; ---- Pass 1: process columns from input.
-
- mov rdx, r10 ; quantptr
- mov rsi, r11 ; inptr
-
-%ifndef NO_ZERO_COLUMN_TEST_IFAST_SSE2
- mov eax, dword [DWBLOCK(1,0,rsi,SIZEOF_JCOEF)]
- or eax, dword [DWBLOCK(2,0,rsi,SIZEOF_JCOEF)]
- jnz near .columnDCT
-
- movdqa xmm0, XMMWORD [XMMBLOCK(1,0,rsi,SIZEOF_JCOEF)]
- movdqa xmm1, XMMWORD [XMMBLOCK(2,0,rsi,SIZEOF_JCOEF)]
- por xmm0, XMMWORD [XMMBLOCK(3,0,rsi,SIZEOF_JCOEF)]
- por xmm1, XMMWORD [XMMBLOCK(4,0,rsi,SIZEOF_JCOEF)]
- por xmm0, XMMWORD [XMMBLOCK(5,0,rsi,SIZEOF_JCOEF)]
- por xmm1, XMMWORD [XMMBLOCK(6,0,rsi,SIZEOF_JCOEF)]
- por xmm0, XMMWORD [XMMBLOCK(7,0,rsi,SIZEOF_JCOEF)]
- por xmm1, xmm0
- packsswb xmm1, xmm1
- packsswb xmm1, xmm1
- movd eax, xmm1
- test rax, rax
- jnz short .columnDCT
-
- ; -- AC terms all zero
-
- movdqa xmm0, XMMWORD [XMMBLOCK(0,0,rsi,SIZEOF_JCOEF)]
- pmullw xmm0, XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_ISLOW_MULT_TYPE)]
-
- movdqa xmm7, xmm0 ; xmm0=in0=(00 01 02 03 04 05 06 07)
- punpcklwd xmm0, xmm0 ; xmm0=(00 00 01 01 02 02 03 03)
- punpckhwd xmm7, xmm7 ; xmm7=(04 04 05 05 06 06 07 07)
-
- pshufd xmm6, xmm0, 0x00 ; xmm6=col0=(00 00 00 00 00 00 00 00)
- pshufd xmm2, xmm0, 0x55 ; xmm2=col1=(01 01 01 01 01 01 01 01)
- pshufd xmm5, xmm0, 0xAA ; xmm5=col2=(02 02 02 02 02 02 02 02)
- pshufd xmm0, xmm0, 0xFF ; xmm0=col3=(03 03 03 03 03 03 03 03)
- pshufd xmm1, xmm7, 0x00 ; xmm1=col4=(04 04 04 04 04 04 04 04)
- pshufd xmm4, xmm7, 0x55 ; xmm4=col5=(05 05 05 05 05 05 05 05)
- pshufd xmm3, xmm7, 0xAA ; xmm3=col6=(06 06 06 06 06 06 06 06)
- pshufd xmm7, xmm7, 0xFF ; xmm7=col7=(07 07 07 07 07 07 07 07)
-
- movdqa XMMWORD [wk(0)], xmm2 ; wk(0)=col1
- movdqa XMMWORD [wk(1)], xmm0 ; wk(1)=col3
- jmp near .column_end
-%endif
-.columnDCT:
-
- ; -- Even part
-
- movdqa xmm0, XMMWORD [XMMBLOCK(0,0,rsi,SIZEOF_JCOEF)]
- movdqa xmm1, XMMWORD [XMMBLOCK(2,0,rsi,SIZEOF_JCOEF)]
- pmullw xmm0, XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_IFAST_MULT_TYPE)]
- pmullw xmm1, XMMWORD [XMMBLOCK(2,0,rdx,SIZEOF_IFAST_MULT_TYPE)]
- movdqa xmm2, XMMWORD [XMMBLOCK(4,0,rsi,SIZEOF_JCOEF)]
- movdqa xmm3, XMMWORD [XMMBLOCK(6,0,rsi,SIZEOF_JCOEF)]
- pmullw xmm2, XMMWORD [XMMBLOCK(4,0,rdx,SIZEOF_IFAST_MULT_TYPE)]
- pmullw xmm3, XMMWORD [XMMBLOCK(6,0,rdx,SIZEOF_IFAST_MULT_TYPE)]
-
- movdqa xmm4, xmm0
- movdqa xmm5, xmm1
- psubw xmm0, xmm2 ; xmm0=tmp11
- psubw xmm1, xmm3
- paddw xmm4, xmm2 ; xmm4=tmp10
- paddw xmm5, xmm3 ; xmm5=tmp13
-
- psllw xmm1, PRE_MULTIPLY_SCALE_BITS
- pmulhw xmm1, [rel PW_F1414]
- psubw xmm1, xmm5 ; xmm1=tmp12
-
- movdqa xmm6, xmm4
- movdqa xmm7, xmm0
- psubw xmm4, xmm5 ; xmm4=tmp3
- psubw xmm0, xmm1 ; xmm0=tmp2
- paddw xmm6, xmm5 ; xmm6=tmp0
- paddw xmm7, xmm1 ; xmm7=tmp1
-
- movdqa XMMWORD [wk(1)], xmm4 ; wk(1)=tmp3
- movdqa XMMWORD [wk(0)], xmm0 ; wk(0)=tmp2
-
- ; -- Odd part
-
- movdqa xmm2, XMMWORD [XMMBLOCK(1,0,rsi,SIZEOF_JCOEF)]
- movdqa xmm3, XMMWORD [XMMBLOCK(3,0,rsi,SIZEOF_JCOEF)]
- pmullw xmm2, XMMWORD [XMMBLOCK(1,0,rdx,SIZEOF_IFAST_MULT_TYPE)]
- pmullw xmm3, XMMWORD [XMMBLOCK(3,0,rdx,SIZEOF_IFAST_MULT_TYPE)]
- movdqa xmm5, XMMWORD [XMMBLOCK(5,0,rsi,SIZEOF_JCOEF)]
- movdqa xmm1, XMMWORD [XMMBLOCK(7,0,rsi,SIZEOF_JCOEF)]
- pmullw xmm5, XMMWORD [XMMBLOCK(5,0,rdx,SIZEOF_IFAST_MULT_TYPE)]
- pmullw xmm1, XMMWORD [XMMBLOCK(7,0,rdx,SIZEOF_IFAST_MULT_TYPE)]
-
- movdqa xmm4, xmm2
- movdqa xmm0, xmm5
- psubw xmm2, xmm1 ; xmm2=z12
- psubw xmm5, xmm3 ; xmm5=z10
- paddw xmm4, xmm1 ; xmm4=z11
- paddw xmm0, xmm3 ; xmm0=z13
-
- movdqa xmm1, xmm5 ; xmm1=z10(unscaled)
- psllw xmm2, PRE_MULTIPLY_SCALE_BITS
- psllw xmm5, PRE_MULTIPLY_SCALE_BITS
-
- movdqa xmm3, xmm4
- psubw xmm4, xmm0
- paddw xmm3, xmm0 ; xmm3=tmp7
-
- psllw xmm4, PRE_MULTIPLY_SCALE_BITS
- pmulhw xmm4, [rel PW_F1414] ; xmm4=tmp11
-
- ; To avoid overflow...
- ;
- ; (Original)
- ; tmp12 = -2.613125930 * z10 + z5;
- ;
- ; (This implementation)
- ; tmp12 = (-1.613125930 - 1) * z10 + z5;
- ; = -1.613125930 * z10 - z10 + z5;
-
- movdqa xmm0, xmm5
- paddw xmm5, xmm2
- pmulhw xmm5, [rel PW_F1847] ; xmm5=z5
- pmulhw xmm0, [rel PW_MF1613]
- pmulhw xmm2, [rel PW_F1082]
- psubw xmm0, xmm1
- psubw xmm2, xmm5 ; xmm2=tmp10
- paddw xmm0, xmm5 ; xmm0=tmp12
-
- ; -- Final output stage
-
- psubw xmm0, xmm3 ; xmm0=tmp6
- movdqa xmm1, xmm6
- movdqa xmm5, xmm7
- paddw xmm6, xmm3 ; xmm6=data0=(00 01 02 03 04 05 06 07)
- paddw xmm7, xmm0 ; xmm7=data1=(10 11 12 13 14 15 16 17)
- psubw xmm1, xmm3 ; xmm1=data7=(70 71 72 73 74 75 76 77)
- psubw xmm5, xmm0 ; xmm5=data6=(60 61 62 63 64 65 66 67)
- psubw xmm4, xmm0 ; xmm4=tmp5
-
- movdqa xmm3, xmm6 ; transpose coefficients(phase 1)
- punpcklwd xmm6, xmm7 ; xmm6=(00 10 01 11 02 12 03 13)
- punpckhwd xmm3, xmm7 ; xmm3=(04 14 05 15 06 16 07 17)
- movdqa xmm0, xmm5 ; transpose coefficients(phase 1)
- punpcklwd xmm5, xmm1 ; xmm5=(60 70 61 71 62 72 63 73)
- punpckhwd xmm0, xmm1 ; xmm0=(64 74 65 75 66 76 67 77)
-
- movdqa xmm7, XMMWORD [wk(0)] ; xmm7=tmp2
- movdqa xmm1, XMMWORD [wk(1)] ; xmm1=tmp3
-
- movdqa XMMWORD [wk(0)], xmm5 ; wk(0)=(60 70 61 71 62 72 63 73)
- movdqa XMMWORD [wk(1)], xmm0 ; wk(1)=(64 74 65 75 66 76 67 77)
-
- paddw xmm2, xmm4 ; xmm2=tmp4
- movdqa xmm5, xmm7
- movdqa xmm0, xmm1
- paddw xmm7, xmm4 ; xmm7=data2=(20 21 22 23 24 25 26 27)
- paddw xmm1, xmm2 ; xmm1=data4=(40 41 42 43 44 45 46 47)
- psubw xmm5, xmm4 ; xmm5=data5=(50 51 52 53 54 55 56 57)
- psubw xmm0, xmm2 ; xmm0=data3=(30 31 32 33 34 35 36 37)
-
- movdqa xmm4, xmm7 ; transpose coefficients(phase 1)
- punpcklwd xmm7, xmm0 ; xmm7=(20 30 21 31 22 32 23 33)
- punpckhwd xmm4, xmm0 ; xmm4=(24 34 25 35 26 36 27 37)
- movdqa xmm2, xmm1 ; transpose coefficients(phase 1)
- punpcklwd xmm1, xmm5 ; xmm1=(40 50 41 51 42 52 43 53)
- punpckhwd xmm2, xmm5 ; xmm2=(44 54 45 55 46 56 47 57)
-
- movdqa xmm0, xmm3 ; transpose coefficients(phase 2)
- punpckldq xmm3, xmm4 ; xmm3=(04 14 24 34 05 15 25 35)
- punpckhdq xmm0, xmm4 ; xmm0=(06 16 26 36 07 17 27 37)
- movdqa xmm5, xmm6 ; transpose coefficients(phase 2)
- punpckldq xmm6, xmm7 ; xmm6=(00 10 20 30 01 11 21 31)
- punpckhdq xmm5, xmm7 ; xmm5=(02 12 22 32 03 13 23 33)
-
- movdqa xmm4, XMMWORD [wk(0)] ; xmm4=(60 70 61 71 62 72 63 73)
- movdqa xmm7, XMMWORD [wk(1)] ; xmm7=(64 74 65 75 66 76 67 77)
-
- movdqa XMMWORD [wk(0)], xmm3 ; wk(0)=(04 14 24 34 05 15 25 35)
- movdqa XMMWORD [wk(1)], xmm0 ; wk(1)=(06 16 26 36 07 17 27 37)
-
- movdqa xmm3, xmm1 ; transpose coefficients(phase 2)
- punpckldq xmm1, xmm4 ; xmm1=(40 50 60 70 41 51 61 71)
- punpckhdq xmm3, xmm4 ; xmm3=(42 52 62 72 43 53 63 73)
- movdqa xmm0, xmm2 ; transpose coefficients(phase 2)
- punpckldq xmm2, xmm7 ; xmm2=(44 54 64 74 45 55 65 75)
- punpckhdq xmm0, xmm7 ; xmm0=(46 56 66 76 47 57 67 77)
-
- movdqa xmm4, xmm6 ; transpose coefficients(phase 3)
- punpcklqdq xmm6, xmm1 ; xmm6=col0=(00 10 20 30 40 50 60 70)
- punpckhqdq xmm4, xmm1 ; xmm4=col1=(01 11 21 31 41 51 61 71)
- movdqa xmm7, xmm5 ; transpose coefficients(phase 3)
- punpcklqdq xmm5, xmm3 ; xmm5=col2=(02 12 22 32 42 52 62 72)
- punpckhqdq xmm7, xmm3 ; xmm7=col3=(03 13 23 33 43 53 63 73)
-
- movdqa xmm1, XMMWORD [wk(0)] ; xmm1=(04 14 24 34 05 15 25 35)
- movdqa xmm3, XMMWORD [wk(1)] ; xmm3=(06 16 26 36 07 17 27 37)
-
- movdqa XMMWORD [wk(0)], xmm4 ; wk(0)=col1
- movdqa XMMWORD [wk(1)], xmm7 ; wk(1)=col3
-
- movdqa xmm4, xmm1 ; transpose coefficients(phase 3)
- punpcklqdq xmm1, xmm2 ; xmm1=col4=(04 14 24 34 44 54 64 74)
- punpckhqdq xmm4, xmm2 ; xmm4=col5=(05 15 25 35 45 55 65 75)
- movdqa xmm7, xmm3 ; transpose coefficients(phase 3)
- punpcklqdq xmm3, xmm0 ; xmm3=col6=(06 16 26 36 46 56 66 76)
- punpckhqdq xmm7, xmm0 ; xmm7=col7=(07 17 27 37 47 57 67 77)
-.column_end:
-
- ; -- Prefetch the next coefficient block
-
- prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 0*32]
- prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 1*32]
- prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 2*32]
- prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 3*32]
-
- ; ---- Pass 2: process rows from work array, store into output array.
-
- mov rax, [original_rbp]
- mov rdi, r12 ; (JSAMPROW *)
- mov eax, r13d
-
- ; -- Even part
-
- ; xmm6=col0, xmm5=col2, xmm1=col4, xmm3=col6
-
- movdqa xmm2, xmm6
- movdqa xmm0, xmm5
- psubw xmm6, xmm1 ; xmm6=tmp11
- psubw xmm5, xmm3
- paddw xmm2, xmm1 ; xmm2=tmp10
- paddw xmm0, xmm3 ; xmm0=tmp13
-
- psllw xmm5, PRE_MULTIPLY_SCALE_BITS
- pmulhw xmm5, [rel PW_F1414]
- psubw xmm5, xmm0 ; xmm5=tmp12
-
- movdqa xmm1, xmm2
- movdqa xmm3, xmm6
- psubw xmm2, xmm0 ; xmm2=tmp3
- psubw xmm6, xmm5 ; xmm6=tmp2
- paddw xmm1, xmm0 ; xmm1=tmp0
- paddw xmm3, xmm5 ; xmm3=tmp1
-
- movdqa xmm0, XMMWORD [wk(0)] ; xmm0=col1
- movdqa xmm5, XMMWORD [wk(1)] ; xmm5=col3
-
- movdqa XMMWORD [wk(0)], xmm2 ; wk(0)=tmp3
- movdqa XMMWORD [wk(1)], xmm6 ; wk(1)=tmp2
-
- ; -- Odd part
-
- ; xmm0=col1, xmm5=col3, xmm4=col5, xmm7=col7
-
- movdqa xmm2, xmm0
- movdqa xmm6, xmm4
- psubw xmm0, xmm7 ; xmm0=z12
- psubw xmm4, xmm5 ; xmm4=z10
- paddw xmm2, xmm7 ; xmm2=z11
- paddw xmm6, xmm5 ; xmm6=z13
-
- movdqa xmm7, xmm4 ; xmm7=z10(unscaled)
- psllw xmm0, PRE_MULTIPLY_SCALE_BITS
- psllw xmm4, PRE_MULTIPLY_SCALE_BITS
-
- movdqa xmm5, xmm2
- psubw xmm2, xmm6
- paddw xmm5, xmm6 ; xmm5=tmp7
-
- psllw xmm2, PRE_MULTIPLY_SCALE_BITS
- pmulhw xmm2, [rel PW_F1414] ; xmm2=tmp11
-
- ; To avoid overflow...
- ;
- ; (Original)
- ; tmp12 = -2.613125930 * z10 + z5;
- ;
- ; (This implementation)
- ; tmp12 = (-1.613125930 - 1) * z10 + z5;
- ; = -1.613125930 * z10 - z10 + z5;
-
- movdqa xmm6, xmm4
- paddw xmm4, xmm0
- pmulhw xmm4, [rel PW_F1847] ; xmm4=z5
- pmulhw xmm6, [rel PW_MF1613]
- pmulhw xmm0, [rel PW_F1082]
- psubw xmm6, xmm7
- psubw xmm0, xmm4 ; xmm0=tmp10
- paddw xmm6, xmm4 ; xmm6=tmp12
-
- ; -- Final output stage
-
- psubw xmm6, xmm5 ; xmm6=tmp6
- movdqa xmm7, xmm1
- movdqa xmm4, xmm3
- paddw xmm1, xmm5 ; xmm1=data0=(00 10 20 30 40 50 60 70)
- paddw xmm3, xmm6 ; xmm3=data1=(01 11 21 31 41 51 61 71)
- psraw xmm1, (PASS1_BITS+3) ; descale
- psraw xmm3, (PASS1_BITS+3) ; descale
- psubw xmm7, xmm5 ; xmm7=data7=(07 17 27 37 47 57 67 77)
- psubw xmm4, xmm6 ; xmm4=data6=(06 16 26 36 46 56 66 76)
- psraw xmm7, (PASS1_BITS+3) ; descale
- psraw xmm4, (PASS1_BITS+3) ; descale
- psubw xmm2, xmm6 ; xmm2=tmp5
-
- packsswb xmm1, xmm4 ; xmm1=(00 10 20 30 40 50 60 70 06 16 26 36 46 56 66 76)
- packsswb xmm3, xmm7 ; xmm3=(01 11 21 31 41 51 61 71 07 17 27 37 47 57 67 77)
-
- movdqa xmm5, XMMWORD [wk(1)] ; xmm5=tmp2
- movdqa xmm6, XMMWORD [wk(0)] ; xmm6=tmp3
-
- paddw xmm0, xmm2 ; xmm0=tmp4
- movdqa xmm4, xmm5
- movdqa xmm7, xmm6
- paddw xmm5, xmm2 ; xmm5=data2=(02 12 22 32 42 52 62 72)
- paddw xmm6, xmm0 ; xmm6=data4=(04 14 24 34 44 54 64 74)
- psraw xmm5, (PASS1_BITS+3) ; descale
- psraw xmm6, (PASS1_BITS+3) ; descale
- psubw xmm4, xmm2 ; xmm4=data5=(05 15 25 35 45 55 65 75)
- psubw xmm7, xmm0 ; xmm7=data3=(03 13 23 33 43 53 63 73)
- psraw xmm4, (PASS1_BITS+3) ; descale
- psraw xmm7, (PASS1_BITS+3) ; descale
-
- movdqa xmm2, [rel PB_CENTERJSAMP] ; xmm2=[rel PB_CENTERJSAMP]
-
- packsswb xmm5, xmm6 ; xmm5=(02 12 22 32 42 52 62 72 04 14 24 34 44 54 64 74)
- packsswb xmm7, xmm4 ; xmm7=(03 13 23 33 43 53 63 73 05 15 25 35 45 55 65 75)
-
- paddb xmm1, xmm2
- paddb xmm3, xmm2
- paddb xmm5, xmm2
- paddb xmm7, xmm2
-
- movdqa xmm0, xmm1 ; transpose coefficients(phase 1)
- punpcklbw xmm1, xmm3 ; xmm1=(00 01 10 11 20 21 30 31 40 41 50 51 60 61 70 71)
- punpckhbw xmm0, xmm3 ; xmm0=(06 07 16 17 26 27 36 37 46 47 56 57 66 67 76 77)
- movdqa xmm6, xmm5 ; transpose coefficients(phase 1)
- punpcklbw xmm5, xmm7 ; xmm5=(02 03 12 13 22 23 32 33 42 43 52 53 62 63 72 73)
- punpckhbw xmm6, xmm7 ; xmm6=(04 05 14 15 24 25 34 35 44 45 54 55 64 65 74 75)
-
- movdqa xmm4, xmm1 ; transpose coefficients(phase 2)
- punpcklwd xmm1, xmm5 ; xmm1=(00 01 02 03 10 11 12 13 20 21 22 23 30 31 32 33)
- punpckhwd xmm4, xmm5 ; xmm4=(40 41 42 43 50 51 52 53 60 61 62 63 70 71 72 73)
- movdqa xmm2, xmm6 ; transpose coefficients(phase 2)
- punpcklwd xmm6, xmm0 ; xmm6=(04 05 06 07 14 15 16 17 24 25 26 27 34 35 36 37)
- punpckhwd xmm2, xmm0 ; xmm2=(44 45 46 47 54 55 56 57 64 65 66 67 74 75 76 77)
-
- movdqa xmm3, xmm1 ; transpose coefficients(phase 3)
- punpckldq xmm1, xmm6 ; xmm1=(00 01 02 03 04 05 06 07 10 11 12 13 14 15 16 17)
- punpckhdq xmm3, xmm6 ; xmm3=(20 21 22 23 24 25 26 27 30 31 32 33 34 35 36 37)
- movdqa xmm7, xmm4 ; transpose coefficients(phase 3)
- punpckldq xmm4, xmm2 ; xmm4=(40 41 42 43 44 45 46 47 50 51 52 53 54 55 56 57)
- punpckhdq xmm7, xmm2 ; xmm7=(60 61 62 63 64 65 66 67 70 71 72 73 74 75 76 77)
-
- pshufd xmm5, xmm1, 0x4E ; xmm5=(10 11 12 13 14 15 16 17 00 01 02 03 04 05 06 07)
- pshufd xmm0, xmm3, 0x4E ; xmm0=(30 31 32 33 34 35 36 37 20 21 22 23 24 25 26 27)
- pshufd xmm6, xmm4, 0x4E ; xmm6=(50 51 52 53 54 55 56 57 40 41 42 43 44 45 46 47)
- pshufd xmm2, xmm7, 0x4E ; xmm2=(70 71 72 73 74 75 76 77 60 61 62 63 64 65 66 67)
-
- mov rdxp, JSAMPROW [rdi+0*SIZEOF_JSAMPROW]
- mov rsip, JSAMPROW [rdi+2*SIZEOF_JSAMPROW]
- movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm1
- movq XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE], xmm3
- mov rdxp, JSAMPROW [rdi+4*SIZEOF_JSAMPROW]
- mov rsip, JSAMPROW [rdi+6*SIZEOF_JSAMPROW]
- movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm4
- movq XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE], xmm7
-
- mov rdxp, JSAMPROW [rdi+1*SIZEOF_JSAMPROW]
- mov rsip, JSAMPROW [rdi+3*SIZEOF_JSAMPROW]
- movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm5
- movq XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE], xmm0
- mov rdxp, JSAMPROW [rdi+5*SIZEOF_JSAMPROW]
- mov rsip, JSAMPROW [rdi+7*SIZEOF_JSAMPROW]
- movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm6
- movq XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE], xmm2
-
- uncollect_args 4
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
- pop rbp
- ret
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jidctint-avx2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jidctint-avx2.asm
deleted file mode 100644
index ca7e317f6e..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jidctint-avx2.asm
+++ /dev/null
@@ -1,418 +0,0 @@
-;
-; jidctint.asm - accurate integer IDCT (64-bit AVX2)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, 2016, 2018, 2020, D. R. Commander.
-; Copyright (C) 2018, Matthias Räncker.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-;
-; This file contains a slower but more accurate integer implementation of the
-; inverse DCT (Discrete Cosine Transform). The following code is based
-; directly on the IJG's original jidctint.c; see the jidctint.c for
-; more details.
-
-%include "jsimdext.inc"
-%include "jdct.inc"
-
-; --------------------------------------------------------------------------
-
-%define CONST_BITS 13
-%define PASS1_BITS 2
-
-%define DESCALE_P1 (CONST_BITS - PASS1_BITS)
-%define DESCALE_P2 (CONST_BITS + PASS1_BITS + 3)
-
-%if CONST_BITS == 13
-F_0_298 equ 2446 ; FIX(0.298631336)
-F_0_390 equ 3196 ; FIX(0.390180644)
-F_0_541 equ 4433 ; FIX(0.541196100)
-F_0_765 equ 6270 ; FIX(0.765366865)
-F_0_899 equ 7373 ; FIX(0.899976223)
-F_1_175 equ 9633 ; FIX(1.175875602)
-F_1_501 equ 12299 ; FIX(1.501321110)
-F_1_847 equ 15137 ; FIX(1.847759065)
-F_1_961 equ 16069 ; FIX(1.961570560)
-F_2_053 equ 16819 ; FIX(2.053119869)
-F_2_562 equ 20995 ; FIX(2.562915447)
-F_3_072 equ 25172 ; FIX(3.072711026)
-%else
-; NASM cannot do compile-time arithmetic on floating-point constants.
-%define DESCALE(x, n) (((x) + (1 << ((n) - 1))) >> (n))
-F_0_298 equ DESCALE( 320652955, 30 - CONST_BITS) ; FIX(0.298631336)
-F_0_390 equ DESCALE( 418953276, 30 - CONST_BITS) ; FIX(0.390180644)
-F_0_541 equ DESCALE( 581104887, 30 - CONST_BITS) ; FIX(0.541196100)
-F_0_765 equ DESCALE( 821806413, 30 - CONST_BITS) ; FIX(0.765366865)
-F_0_899 equ DESCALE( 966342111, 30 - CONST_BITS) ; FIX(0.899976223)
-F_1_175 equ DESCALE(1262586813, 30 - CONST_BITS) ; FIX(1.175875602)
-F_1_501 equ DESCALE(1612031267, 30 - CONST_BITS) ; FIX(1.501321110)
-F_1_847 equ DESCALE(1984016188, 30 - CONST_BITS) ; FIX(1.847759065)
-F_1_961 equ DESCALE(2106220350, 30 - CONST_BITS) ; FIX(1.961570560)
-F_2_053 equ DESCALE(2204520673, 30 - CONST_BITS) ; FIX(2.053119869)
-F_2_562 equ DESCALE(2751909506, 30 - CONST_BITS) ; FIX(2.562915447)
-F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
-%endif
-
-; --------------------------------------------------------------------------
-; In-place 8x8x16-bit inverse matrix transpose using AVX2 instructions
-; %1-%4: Input/output registers
-; %5-%8: Temp registers
-
-%macro dotranspose 8
- ; %5=(00 10 20 30 40 50 60 70 01 11 21 31 41 51 61 71)
- ; %6=(03 13 23 33 43 53 63 73 02 12 22 32 42 52 62 72)
- ; %7=(04 14 24 34 44 54 64 74 05 15 25 35 45 55 65 75)
- ; %8=(07 17 27 37 47 57 67 77 06 16 26 36 46 56 66 76)
-
- vpermq %5, %1, 0xD8
- vpermq %6, %2, 0x72
- vpermq %7, %3, 0xD8
- vpermq %8, %4, 0x72
- ; transpose coefficients(phase 1)
- ; %5=(00 10 20 30 01 11 21 31 40 50 60 70 41 51 61 71)
- ; %6=(02 12 22 32 03 13 23 33 42 52 62 72 43 53 63 73)
- ; %7=(04 14 24 34 05 15 25 35 44 54 64 74 45 55 65 75)
- ; %8=(06 16 26 36 07 17 27 37 46 56 66 76 47 57 67 77)
-
- vpunpcklwd %1, %5, %6
- vpunpckhwd %2, %5, %6
- vpunpcklwd %3, %7, %8
- vpunpckhwd %4, %7, %8
- ; transpose coefficients(phase 2)
- ; %1=(00 02 10 12 20 22 30 32 40 42 50 52 60 62 70 72)
- ; %2=(01 03 11 13 21 23 31 33 41 43 51 53 61 63 71 73)
- ; %3=(04 06 14 16 24 26 34 36 44 46 54 56 64 66 74 76)
- ; %4=(05 07 15 17 25 27 35 37 45 47 55 57 65 67 75 77)
-
- vpunpcklwd %5, %1, %2
- vpunpcklwd %6, %3, %4
- vpunpckhwd %7, %1, %2
- vpunpckhwd %8, %3, %4
- ; transpose coefficients(phase 3)
- ; %5=(00 01 02 03 10 11 12 13 40 41 42 43 50 51 52 53)
- ; %6=(04 05 06 07 14 15 16 17 44 45 46 47 54 55 56 57)
- ; %7=(20 21 22 23 30 31 32 33 60 61 62 63 70 71 72 73)
- ; %8=(24 25 26 27 34 35 36 37 64 65 66 67 74 75 76 77)
-
- vpunpcklqdq %1, %5, %6
- vpunpckhqdq %2, %5, %6
- vpunpcklqdq %3, %7, %8
- vpunpckhqdq %4, %7, %8
- ; transpose coefficients(phase 4)
- ; %1=(00 01 02 03 04 05 06 07 40 41 42 43 44 45 46 47)
- ; %2=(10 11 12 13 14 15 16 17 50 51 52 53 54 55 56 57)
- ; %3=(20 21 22 23 24 25 26 27 60 61 62 63 64 65 66 67)
- ; %4=(30 31 32 33 34 35 36 37 70 71 72 73 74 75 76 77)
-%endmacro
-
-; --------------------------------------------------------------------------
-; In-place 8x8x16-bit accurate integer inverse DCT using AVX2 instructions
-; %1-%4: Input/output registers
-; %5-%12: Temp registers
-; %9: Pass (1 or 2)
-
-%macro dodct 13
- ; -- Even part
-
- ; (Original)
- ; z1 = (z2 + z3) * 0.541196100;
- ; tmp2 = z1 + z3 * -1.847759065;
- ; tmp3 = z1 + z2 * 0.765366865;
- ;
- ; (This implementation)
- ; tmp2 = z2 * 0.541196100 + z3 * (0.541196100 - 1.847759065);
- ; tmp3 = z2 * (0.541196100 + 0.765366865) + z3 * 0.541196100;
-
- vperm2i128 %6, %3, %3, 0x01 ; %6=in6_2
- vpunpcklwd %5, %3, %6 ; %5=in26_62L
- vpunpckhwd %6, %3, %6 ; %6=in26_62H
- vpmaddwd %5, %5, [rel PW_F130_F054_MF130_F054] ; %5=tmp3_2L
- vpmaddwd %6, %6, [rel PW_F130_F054_MF130_F054] ; %6=tmp3_2H
-
- vperm2i128 %7, %1, %1, 0x01 ; %7=in4_0
- vpsignw %1, %1, [rel PW_1_NEG1]
- vpaddw %7, %7, %1 ; %7=(in0+in4)_(in0-in4)
-
- vpxor %1, %1, %1
- vpunpcklwd %8, %1, %7 ; %8=tmp0_1L
- vpunpckhwd %1, %1, %7 ; %1=tmp0_1H
- vpsrad %8, %8, (16-CONST_BITS) ; vpsrad %8,16 & vpslld %8,CONST_BITS
- vpsrad %1, %1, (16-CONST_BITS) ; vpsrad %1,16 & vpslld %1,CONST_BITS
-
- vpsubd %11, %8, %5 ; %11=tmp0_1L-tmp3_2L=tmp13_12L
- vpaddd %9, %8, %5 ; %9=tmp0_1L+tmp3_2L=tmp10_11L
- vpsubd %12, %1, %6 ; %12=tmp0_1H-tmp3_2H=tmp13_12H
- vpaddd %10, %1, %6 ; %10=tmp0_1H+tmp3_2H=tmp10_11H
-
- ; -- Odd part
-
- vpaddw %1, %4, %2 ; %1=in7_5+in3_1=z3_4
-
- ; (Original)
- ; z5 = (z3 + z4) * 1.175875602;
- ; z3 = z3 * -1.961570560; z4 = z4 * -0.390180644;
- ; z3 += z5; z4 += z5;
- ;
- ; (This implementation)
- ; z3 = z3 * (1.175875602 - 1.961570560) + z4 * 1.175875602;
- ; z4 = z3 * 1.175875602 + z4 * (1.175875602 - 0.390180644);
-
- vperm2i128 %8, %1, %1, 0x01 ; %8=z4_3
- vpunpcklwd %7, %1, %8 ; %7=z34_43L
- vpunpckhwd %8, %1, %8 ; %8=z34_43H
- vpmaddwd %7, %7, [rel PW_MF078_F117_F078_F117] ; %7=z3_4L
- vpmaddwd %8, %8, [rel PW_MF078_F117_F078_F117] ; %8=z3_4H
-
- ; (Original)
- ; z1 = tmp0 + tmp3; z2 = tmp1 + tmp2;
- ; tmp0 = tmp0 * 0.298631336; tmp1 = tmp1 * 2.053119869;
- ; tmp2 = tmp2 * 3.072711026; tmp3 = tmp3 * 1.501321110;
- ; z1 = z1 * -0.899976223; z2 = z2 * -2.562915447;
- ; tmp0 += z1 + z3; tmp1 += z2 + z4;
- ; tmp2 += z2 + z3; tmp3 += z1 + z4;
- ;
- ; (This implementation)
- ; tmp0 = tmp0 * (0.298631336 - 0.899976223) + tmp3 * -0.899976223;
- ; tmp1 = tmp1 * (2.053119869 - 2.562915447) + tmp2 * -2.562915447;
- ; tmp2 = tmp1 * -2.562915447 + tmp2 * (3.072711026 - 2.562915447);
- ; tmp3 = tmp0 * -0.899976223 + tmp3 * (1.501321110 - 0.899976223);
- ; tmp0 += z3; tmp1 += z4;
- ; tmp2 += z3; tmp3 += z4;
-
- vperm2i128 %2, %2, %2, 0x01 ; %2=in1_3
- vpunpcklwd %3, %4, %2 ; %3=in71_53L
- vpunpckhwd %4, %4, %2 ; %4=in71_53H
-
- vpmaddwd %5, %3, [rel PW_MF060_MF089_MF050_MF256] ; %5=tmp0_1L
- vpmaddwd %6, %4, [rel PW_MF060_MF089_MF050_MF256] ; %6=tmp0_1H
- vpaddd %5, %5, %7 ; %5=tmp0_1L+z3_4L=tmp0_1L
- vpaddd %6, %6, %8 ; %6=tmp0_1H+z3_4H=tmp0_1H
-
- vpmaddwd %3, %3, [rel PW_MF089_F060_MF256_F050] ; %3=tmp3_2L
- vpmaddwd %4, %4, [rel PW_MF089_F060_MF256_F050] ; %4=tmp3_2H
- vperm2i128 %7, %7, %7, 0x01 ; %7=z4_3L
- vperm2i128 %8, %8, %8, 0x01 ; %8=z4_3H
- vpaddd %7, %3, %7 ; %7=tmp3_2L+z4_3L=tmp3_2L
- vpaddd %8, %4, %8 ; %8=tmp3_2H+z4_3H=tmp3_2H
-
- ; -- Final output stage
-
- vpaddd %1, %9, %7 ; %1=tmp10_11L+tmp3_2L=data0_1L
- vpaddd %2, %10, %8 ; %2=tmp10_11H+tmp3_2H=data0_1H
- vpaddd %1, %1, [rel PD_DESCALE_P %+ %13]
- vpaddd %2, %2, [rel PD_DESCALE_P %+ %13]
- vpsrad %1, %1, DESCALE_P %+ %13
- vpsrad %2, %2, DESCALE_P %+ %13
- vpackssdw %1, %1, %2 ; %1=data0_1
-
- vpsubd %3, %9, %7 ; %3=tmp10_11L-tmp3_2L=data7_6L
- vpsubd %4, %10, %8 ; %4=tmp10_11H-tmp3_2H=data7_6H
- vpaddd %3, %3, [rel PD_DESCALE_P %+ %13]
- vpaddd %4, %4, [rel PD_DESCALE_P %+ %13]
- vpsrad %3, %3, DESCALE_P %+ %13
- vpsrad %4, %4, DESCALE_P %+ %13
- vpackssdw %4, %3, %4 ; %4=data7_6
-
- vpaddd %7, %11, %5 ; %7=tmp13_12L+tmp0_1L=data3_2L
- vpaddd %8, %12, %6 ; %8=tmp13_12H+tmp0_1H=data3_2H
- vpaddd %7, %7, [rel PD_DESCALE_P %+ %13]
- vpaddd %8, %8, [rel PD_DESCALE_P %+ %13]
- vpsrad %7, %7, DESCALE_P %+ %13
- vpsrad %8, %8, DESCALE_P %+ %13
- vpackssdw %2, %7, %8 ; %2=data3_2
-
- vpsubd %7, %11, %5 ; %7=tmp13_12L-tmp0_1L=data4_5L
- vpsubd %8, %12, %6 ; %8=tmp13_12H-tmp0_1H=data4_5H
- vpaddd %7, %7, [rel PD_DESCALE_P %+ %13]
- vpaddd %8, %8, [rel PD_DESCALE_P %+ %13]
- vpsrad %7, %7, DESCALE_P %+ %13
- vpsrad %8, %8, DESCALE_P %+ %13
- vpackssdw %3, %7, %8 ; %3=data4_5
-%endmacro
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_idct_islow_avx2)
-
-EXTN(jconst_idct_islow_avx2):
-
-PW_F130_F054_MF130_F054 times 4 dw (F_0_541 + F_0_765), F_0_541
- times 4 dw (F_0_541 - F_1_847), F_0_541
-PW_MF078_F117_F078_F117 times 4 dw (F_1_175 - F_1_961), F_1_175
- times 4 dw (F_1_175 - F_0_390), F_1_175
-PW_MF060_MF089_MF050_MF256 times 4 dw (F_0_298 - F_0_899), -F_0_899
- times 4 dw (F_2_053 - F_2_562), -F_2_562
-PW_MF089_F060_MF256_F050 times 4 dw -F_0_899, (F_1_501 - F_0_899)
- times 4 dw -F_2_562, (F_3_072 - F_2_562)
-PD_DESCALE_P1 times 8 dd 1 << (DESCALE_P1 - 1)
-PD_DESCALE_P2 times 8 dd 1 << (DESCALE_P2 - 1)
-PB_CENTERJSAMP times 32 db CENTERJSAMPLE
-PW_1_NEG1 times 8 dw 1
- times 8 dw -1
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 64
-;
-; Perform dequantization and inverse DCT on one block of coefficients.
-;
-; GLOBAL(void)
-; jsimd_idct_islow_avx2(void *dct_table, JCOEFPTR coef_block,
-; JSAMPARRAY output_buf, JDIMENSION output_col)
-;
-
-; r10 = jpeg_component_info *compptr
-; r11 = JCOEFPTR coef_block
-; r12 = JSAMPARRAY output_buf
-; r13d = JDIMENSION output_col
-
- align 32
- GLOBAL_FUNCTION(jsimd_idct_islow_avx2)
-
-EXTN(jsimd_idct_islow_avx2):
- push rbp
- mov rax, rsp ; rax = original rbp
- mov rbp, rsp ; rbp = aligned rbp
- push_xmm 4
- collect_args 4
-
- ; ---- Pass 1: process columns.
-
-%ifndef NO_ZERO_COLUMN_TEST_ISLOW_AVX2
- mov eax, dword [DWBLOCK(1,0,r11,SIZEOF_JCOEF)]
- or eax, dword [DWBLOCK(2,0,r11,SIZEOF_JCOEF)]
- jnz near .columnDCT
-
- movdqa xmm0, XMMWORD [XMMBLOCK(1,0,r11,SIZEOF_JCOEF)]
- movdqa xmm1, XMMWORD [XMMBLOCK(2,0,r11,SIZEOF_JCOEF)]
- vpor xmm0, xmm0, XMMWORD [XMMBLOCK(3,0,r11,SIZEOF_JCOEF)]
- vpor xmm1, xmm1, XMMWORD [XMMBLOCK(4,0,r11,SIZEOF_JCOEF)]
- vpor xmm0, xmm0, XMMWORD [XMMBLOCK(5,0,r11,SIZEOF_JCOEF)]
- vpor xmm1, xmm1, XMMWORD [XMMBLOCK(6,0,r11,SIZEOF_JCOEF)]
- vpor xmm0, xmm0, XMMWORD [XMMBLOCK(7,0,r11,SIZEOF_JCOEF)]
- vpor xmm1, xmm1, xmm0
- vpacksswb xmm1, xmm1, xmm1
- vpacksswb xmm1, xmm1, xmm1
- movd eax, xmm1
- test rax, rax
- jnz short .columnDCT
-
- ; -- AC terms all zero
-
- movdqa xmm5, XMMWORD [XMMBLOCK(0,0,r11,SIZEOF_JCOEF)]
- vpmullw xmm5, xmm5, XMMWORD [XMMBLOCK(0,0,r10,SIZEOF_ISLOW_MULT_TYPE)]
-
- vpsllw xmm5, xmm5, PASS1_BITS
-
- vpunpcklwd xmm4, xmm5, xmm5 ; xmm4=(00 00 01 01 02 02 03 03)
- vpunpckhwd xmm5, xmm5, xmm5 ; xmm5=(04 04 05 05 06 06 07 07)
- vinserti128 ymm4, ymm4, xmm5, 1
-
- vpshufd ymm0, ymm4, 0x00 ; ymm0=col0_4=(00 00 00 00 00 00 00 00 04 04 04 04 04 04 04 04)
- vpshufd ymm1, ymm4, 0x55 ; ymm1=col1_5=(01 01 01 01 01 01 01 01 05 05 05 05 05 05 05 05)
- vpshufd ymm2, ymm4, 0xAA ; ymm2=col2_6=(02 02 02 02 02 02 02 02 06 06 06 06 06 06 06 06)
- vpshufd ymm3, ymm4, 0xFF ; ymm3=col3_7=(03 03 03 03 03 03 03 03 07 07 07 07 07 07 07 07)
-
- jmp near .column_end
-%endif
-.columnDCT:
-
- vmovdqu ymm4, YMMWORD [YMMBLOCK(0,0,r11,SIZEOF_JCOEF)] ; ymm4=in0_1
- vmovdqu ymm5, YMMWORD [YMMBLOCK(2,0,r11,SIZEOF_JCOEF)] ; ymm5=in2_3
- vmovdqu ymm6, YMMWORD [YMMBLOCK(4,0,r11,SIZEOF_JCOEF)] ; ymm6=in4_5
- vmovdqu ymm7, YMMWORD [YMMBLOCK(6,0,r11,SIZEOF_JCOEF)] ; ymm7=in6_7
- vpmullw ymm4, ymm4, YMMWORD [YMMBLOCK(0,0,r10,SIZEOF_ISLOW_MULT_TYPE)]
- vpmullw ymm5, ymm5, YMMWORD [YMMBLOCK(2,0,r10,SIZEOF_ISLOW_MULT_TYPE)]
- vpmullw ymm6, ymm6, YMMWORD [YMMBLOCK(4,0,r10,SIZEOF_ISLOW_MULT_TYPE)]
- vpmullw ymm7, ymm7, YMMWORD [YMMBLOCK(6,0,r10,SIZEOF_ISLOW_MULT_TYPE)]
-
- vperm2i128 ymm0, ymm4, ymm6, 0x20 ; ymm0=in0_4
- vperm2i128 ymm1, ymm5, ymm4, 0x31 ; ymm1=in3_1
- vperm2i128 ymm2, ymm5, ymm7, 0x20 ; ymm2=in2_6
- vperm2i128 ymm3, ymm7, ymm6, 0x31 ; ymm3=in7_5
-
- dodct ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7, ymm8, ymm9, ymm10, ymm11, 1
- ; ymm0=data0_1, ymm1=data3_2, ymm2=data4_5, ymm3=data7_6
-
- dotranspose ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7
- ; ymm0=data0_4, ymm1=data1_5, ymm2=data2_6, ymm3=data3_7
-
-.column_end:
-
- ; -- Prefetch the next coefficient block
-
- prefetchnta [r11 + DCTSIZE2*SIZEOF_JCOEF + 0*32]
- prefetchnta [r11 + DCTSIZE2*SIZEOF_JCOEF + 1*32]
- prefetchnta [r11 + DCTSIZE2*SIZEOF_JCOEF + 2*32]
- prefetchnta [r11 + DCTSIZE2*SIZEOF_JCOEF + 3*32]
-
- ; ---- Pass 2: process rows.
-
- vperm2i128 ymm4, ymm3, ymm1, 0x31 ; ymm3=in7_5
- vperm2i128 ymm1, ymm3, ymm1, 0x20 ; ymm1=in3_1
-
- dodct ymm0, ymm1, ymm2, ymm4, ymm3, ymm5, ymm6, ymm7, ymm8, ymm9, ymm10, ymm11, 2
- ; ymm0=data0_1, ymm1=data3_2, ymm2=data4_5, ymm4=data7_6
-
- dotranspose ymm0, ymm1, ymm2, ymm4, ymm3, ymm5, ymm6, ymm7
- ; ymm0=data0_4, ymm1=data1_5, ymm2=data2_6, ymm4=data3_7
-
- vpacksswb ymm0, ymm0, ymm1 ; ymm0=data01_45
- vpacksswb ymm1, ymm2, ymm4 ; ymm1=data23_67
- vpaddb ymm0, ymm0, [rel PB_CENTERJSAMP]
- vpaddb ymm1, ymm1, [rel PB_CENTERJSAMP]
-
- vextracti128 xmm6, ymm1, 1 ; xmm3=data67
- vextracti128 xmm4, ymm0, 1 ; xmm2=data45
- vextracti128 xmm2, ymm1, 0 ; xmm1=data23
- vextracti128 xmm0, ymm0, 0 ; xmm0=data01
-
- vpshufd xmm1, xmm0, 0x4E ; xmm1=(10 11 12 13 14 15 16 17 00 01 02 03 04 05 06 07)
- vpshufd xmm3, xmm2, 0x4E ; xmm3=(30 31 32 33 34 35 36 37 20 21 22 23 24 25 26 27)
- vpshufd xmm5, xmm4, 0x4E ; xmm5=(50 51 52 53 54 55 56 57 40 41 42 43 44 45 46 47)
- vpshufd xmm7, xmm6, 0x4E ; xmm7=(70 71 72 73 74 75 76 77 60 61 62 63 64 65 66 67)
-
- vzeroupper
-
- mov eax, r13d
-
- mov rdxp, JSAMPROW [r12+0*SIZEOF_JSAMPROW] ; (JSAMPLE *)
- mov rsip, JSAMPROW [r12+1*SIZEOF_JSAMPROW] ; (JSAMPLE *)
- movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm0
- movq XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE], xmm1
-
- mov rdxp, JSAMPROW [r12+2*SIZEOF_JSAMPROW] ; (JSAMPLE *)
- mov rsip, JSAMPROW [r12+3*SIZEOF_JSAMPROW] ; (JSAMPLE *)
- movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm2
- movq XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE], xmm3
-
- mov rdxp, JSAMPROW [r12+4*SIZEOF_JSAMPROW] ; (JSAMPLE *)
- mov rsip, JSAMPROW [r12+5*SIZEOF_JSAMPROW] ; (JSAMPLE *)
- movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm4
- movq XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE], xmm5
-
- mov rdxp, JSAMPROW [r12+6*SIZEOF_JSAMPROW] ; (JSAMPLE *)
- mov rsip, JSAMPROW [r12+7*SIZEOF_JSAMPROW] ; (JSAMPLE *)
- movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm6
- movq XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE], xmm7
-
- uncollect_args 4
- pop_xmm 4
- pop rbp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jidctint-sse2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jidctint-sse2.asm
deleted file mode 100644
index 7aa869bc0b..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jidctint-sse2.asm
+++ /dev/null
@@ -1,847 +0,0 @@
-;
-; jidctint.asm - accurate integer IDCT (64-bit SSE2)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, 2016, 2020, D. R. Commander.
-; Copyright (C) 2018, Matthias Räncker.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-;
-; This file contains a slower but more accurate integer implementation of the
-; inverse DCT (Discrete Cosine Transform). The following code is based
-; directly on the IJG's original jidctint.c; see the jidctint.c for
-; more details.
-
-%include "jsimdext.inc"
-%include "jdct.inc"
-
-; --------------------------------------------------------------------------
-
-%define CONST_BITS 13
-%define PASS1_BITS 2
-
-%define DESCALE_P1 (CONST_BITS - PASS1_BITS)
-%define DESCALE_P2 (CONST_BITS + PASS1_BITS + 3)
-
-%if CONST_BITS == 13
-F_0_298 equ 2446 ; FIX(0.298631336)
-F_0_390 equ 3196 ; FIX(0.390180644)
-F_0_541 equ 4433 ; FIX(0.541196100)
-F_0_765 equ 6270 ; FIX(0.765366865)
-F_0_899 equ 7373 ; FIX(0.899976223)
-F_1_175 equ 9633 ; FIX(1.175875602)
-F_1_501 equ 12299 ; FIX(1.501321110)
-F_1_847 equ 15137 ; FIX(1.847759065)
-F_1_961 equ 16069 ; FIX(1.961570560)
-F_2_053 equ 16819 ; FIX(2.053119869)
-F_2_562 equ 20995 ; FIX(2.562915447)
-F_3_072 equ 25172 ; FIX(3.072711026)
-%else
-; NASM cannot do compile-time arithmetic on floating-point constants.
-%define DESCALE(x, n) (((x) + (1 << ((n) - 1))) >> (n))
-F_0_298 equ DESCALE( 320652955, 30 - CONST_BITS) ; FIX(0.298631336)
-F_0_390 equ DESCALE( 418953276, 30 - CONST_BITS) ; FIX(0.390180644)
-F_0_541 equ DESCALE( 581104887, 30 - CONST_BITS) ; FIX(0.541196100)
-F_0_765 equ DESCALE( 821806413, 30 - CONST_BITS) ; FIX(0.765366865)
-F_0_899 equ DESCALE( 966342111, 30 - CONST_BITS) ; FIX(0.899976223)
-F_1_175 equ DESCALE(1262586813, 30 - CONST_BITS) ; FIX(1.175875602)
-F_1_501 equ DESCALE(1612031267, 30 - CONST_BITS) ; FIX(1.501321110)
-F_1_847 equ DESCALE(1984016188, 30 - CONST_BITS) ; FIX(1.847759065)
-F_1_961 equ DESCALE(2106220350, 30 - CONST_BITS) ; FIX(1.961570560)
-F_2_053 equ DESCALE(2204520673, 30 - CONST_BITS) ; FIX(2.053119869)
-F_2_562 equ DESCALE(2751909506, 30 - CONST_BITS) ; FIX(2.562915447)
-F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
-%endif
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_idct_islow_sse2)
-
-EXTN(jconst_idct_islow_sse2):
-
-PW_F130_F054 times 4 dw (F_0_541 + F_0_765), F_0_541
-PW_F054_MF130 times 4 dw F_0_541, (F_0_541 - F_1_847)
-PW_MF078_F117 times 4 dw (F_1_175 - F_1_961), F_1_175
-PW_F117_F078 times 4 dw F_1_175, (F_1_175 - F_0_390)
-PW_MF060_MF089 times 4 dw (F_0_298 - F_0_899), -F_0_899
-PW_MF089_F060 times 4 dw -F_0_899, (F_1_501 - F_0_899)
-PW_MF050_MF256 times 4 dw (F_2_053 - F_2_562), -F_2_562
-PW_MF256_F050 times 4 dw -F_2_562, (F_3_072 - F_2_562)
-PD_DESCALE_P1 times 4 dd 1 << (DESCALE_P1 - 1)
-PD_DESCALE_P2 times 4 dd 1 << (DESCALE_P2 - 1)
-PB_CENTERJSAMP times 16 db CENTERJSAMPLE
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 64
-;
-; Perform dequantization and inverse DCT on one block of coefficients.
-;
-; GLOBAL(void)
-; jsimd_idct_islow_sse2(void *dct_table, JCOEFPTR coef_block,
-; JSAMPARRAY output_buf, JDIMENSION output_col)
-;
-
-; r10 = jpeg_component_info *compptr
-; r11 = JCOEFPTR coef_block
-; r12 = JSAMPARRAY output_buf
-; r13d = JDIMENSION output_col
-
-%define original_rbp rbp + 0
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_XMMWORD
- ; xmmword wk[WK_NUM]
-%define WK_NUM 12
-
- align 32
- GLOBAL_FUNCTION(jsimd_idct_islow_sse2)
-
-EXTN(jsimd_idct_islow_sse2):
- push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
- and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
- collect_args 4
-
- ; ---- Pass 1: process columns from input.
-
- mov rdx, r10 ; quantptr
- mov rsi, r11 ; inptr
-
-%ifndef NO_ZERO_COLUMN_TEST_ISLOW_SSE2
- mov eax, dword [DWBLOCK(1,0,rsi,SIZEOF_JCOEF)]
- or eax, dword [DWBLOCK(2,0,rsi,SIZEOF_JCOEF)]
- jnz near .columnDCT
-
- movdqa xmm0, XMMWORD [XMMBLOCK(1,0,rsi,SIZEOF_JCOEF)]
- movdqa xmm1, XMMWORD [XMMBLOCK(2,0,rsi,SIZEOF_JCOEF)]
- por xmm0, XMMWORD [XMMBLOCK(3,0,rsi,SIZEOF_JCOEF)]
- por xmm1, XMMWORD [XMMBLOCK(4,0,rsi,SIZEOF_JCOEF)]
- por xmm0, XMMWORD [XMMBLOCK(5,0,rsi,SIZEOF_JCOEF)]
- por xmm1, XMMWORD [XMMBLOCK(6,0,rsi,SIZEOF_JCOEF)]
- por xmm0, XMMWORD [XMMBLOCK(7,0,rsi,SIZEOF_JCOEF)]
- por xmm1, xmm0
- packsswb xmm1, xmm1
- packsswb xmm1, xmm1
- movd eax, xmm1
- test rax, rax
- jnz short .columnDCT
-
- ; -- AC terms all zero
-
- movdqa xmm5, XMMWORD [XMMBLOCK(0,0,rsi,SIZEOF_JCOEF)]
- pmullw xmm5, XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_ISLOW_MULT_TYPE)]
-
- psllw xmm5, PASS1_BITS
-
- movdqa xmm4, xmm5 ; xmm5=in0=(00 01 02 03 04 05 06 07)
- punpcklwd xmm5, xmm5 ; xmm5=(00 00 01 01 02 02 03 03)
- punpckhwd xmm4, xmm4 ; xmm4=(04 04 05 05 06 06 07 07)
-
- pshufd xmm7, xmm5, 0x00 ; xmm7=col0=(00 00 00 00 00 00 00 00)
- pshufd xmm6, xmm5, 0x55 ; xmm6=col1=(01 01 01 01 01 01 01 01)
- pshufd xmm1, xmm5, 0xAA ; xmm1=col2=(02 02 02 02 02 02 02 02)
- pshufd xmm5, xmm5, 0xFF ; xmm5=col3=(03 03 03 03 03 03 03 03)
- pshufd xmm0, xmm4, 0x00 ; xmm0=col4=(04 04 04 04 04 04 04 04)
- pshufd xmm3, xmm4, 0x55 ; xmm3=col5=(05 05 05 05 05 05 05 05)
- pshufd xmm2, xmm4, 0xAA ; xmm2=col6=(06 06 06 06 06 06 06 06)
- pshufd xmm4, xmm4, 0xFF ; xmm4=col7=(07 07 07 07 07 07 07 07)
-
- movdqa XMMWORD [wk(8)], xmm6 ; wk(8)=col1
- movdqa XMMWORD [wk(9)], xmm5 ; wk(9)=col3
- movdqa XMMWORD [wk(10)], xmm3 ; wk(10)=col5
- movdqa XMMWORD [wk(11)], xmm4 ; wk(11)=col7
- jmp near .column_end
-%endif
-.columnDCT:
-
- ; -- Even part
-
- movdqa xmm0, XMMWORD [XMMBLOCK(0,0,rsi,SIZEOF_JCOEF)]
- movdqa xmm1, XMMWORD [XMMBLOCK(2,0,rsi,SIZEOF_JCOEF)]
- pmullw xmm0, XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_ISLOW_MULT_TYPE)]
- pmullw xmm1, XMMWORD [XMMBLOCK(2,0,rdx,SIZEOF_ISLOW_MULT_TYPE)]
- movdqa xmm2, XMMWORD [XMMBLOCK(4,0,rsi,SIZEOF_JCOEF)]
- movdqa xmm3, XMMWORD [XMMBLOCK(6,0,rsi,SIZEOF_JCOEF)]
- pmullw xmm2, XMMWORD [XMMBLOCK(4,0,rdx,SIZEOF_ISLOW_MULT_TYPE)]
- pmullw xmm3, XMMWORD [XMMBLOCK(6,0,rdx,SIZEOF_ISLOW_MULT_TYPE)]
-
- ; (Original)
- ; z1 = (z2 + z3) * 0.541196100;
- ; tmp2 = z1 + z3 * -1.847759065;
- ; tmp3 = z1 + z2 * 0.765366865;
- ;
- ; (This implementation)
- ; tmp2 = z2 * 0.541196100 + z3 * (0.541196100 - 1.847759065);
- ; tmp3 = z2 * (0.541196100 + 0.765366865) + z3 * 0.541196100;
-
- movdqa xmm4, xmm1 ; xmm1=in2=z2
- movdqa xmm5, xmm1
- punpcklwd xmm4, xmm3 ; xmm3=in6=z3
- punpckhwd xmm5, xmm3
- movdqa xmm1, xmm4
- movdqa xmm3, xmm5
- pmaddwd xmm4, [rel PW_F130_F054] ; xmm4=tmp3L
- pmaddwd xmm5, [rel PW_F130_F054] ; xmm5=tmp3H
- pmaddwd xmm1, [rel PW_F054_MF130] ; xmm1=tmp2L
- pmaddwd xmm3, [rel PW_F054_MF130] ; xmm3=tmp2H
-
- movdqa xmm6, xmm0
- paddw xmm0, xmm2 ; xmm0=in0+in4
- psubw xmm6, xmm2 ; xmm6=in0-in4
-
- pxor xmm7, xmm7
- pxor xmm2, xmm2
- punpcklwd xmm7, xmm0 ; xmm7=tmp0L
- punpckhwd xmm2, xmm0 ; xmm2=tmp0H
- psrad xmm7, (16-CONST_BITS) ; psrad xmm7,16 & pslld xmm7,CONST_BITS
- psrad xmm2, (16-CONST_BITS) ; psrad xmm2,16 & pslld xmm2,CONST_BITS
-
- movdqa xmm0, xmm7
- paddd xmm7, xmm4 ; xmm7=tmp10L
- psubd xmm0, xmm4 ; xmm0=tmp13L
- movdqa xmm4, xmm2
- paddd xmm2, xmm5 ; xmm2=tmp10H
- psubd xmm4, xmm5 ; xmm4=tmp13H
-
- movdqa XMMWORD [wk(0)], xmm7 ; wk(0)=tmp10L
- movdqa XMMWORD [wk(1)], xmm2 ; wk(1)=tmp10H
- movdqa XMMWORD [wk(2)], xmm0 ; wk(2)=tmp13L
- movdqa XMMWORD [wk(3)], xmm4 ; wk(3)=tmp13H
-
- pxor xmm5, xmm5
- pxor xmm7, xmm7
- punpcklwd xmm5, xmm6 ; xmm5=tmp1L
- punpckhwd xmm7, xmm6 ; xmm7=tmp1H
- psrad xmm5, (16-CONST_BITS) ; psrad xmm5,16 & pslld xmm5,CONST_BITS
- psrad xmm7, (16-CONST_BITS) ; psrad xmm7,16 & pslld xmm7,CONST_BITS
-
- movdqa xmm2, xmm5
- paddd xmm5, xmm1 ; xmm5=tmp11L
- psubd xmm2, xmm1 ; xmm2=tmp12L
- movdqa xmm0, xmm7
- paddd xmm7, xmm3 ; xmm7=tmp11H
- psubd xmm0, xmm3 ; xmm0=tmp12H
-
- movdqa XMMWORD [wk(4)], xmm5 ; wk(4)=tmp11L
- movdqa XMMWORD [wk(5)], xmm7 ; wk(5)=tmp11H
- movdqa XMMWORD [wk(6)], xmm2 ; wk(6)=tmp12L
- movdqa XMMWORD [wk(7)], xmm0 ; wk(7)=tmp12H
-
- ; -- Odd part
-
- movdqa xmm4, XMMWORD [XMMBLOCK(1,0,rsi,SIZEOF_JCOEF)]
- movdqa xmm6, XMMWORD [XMMBLOCK(3,0,rsi,SIZEOF_JCOEF)]
- pmullw xmm4, XMMWORD [XMMBLOCK(1,0,rdx,SIZEOF_ISLOW_MULT_TYPE)]
- pmullw xmm6, XMMWORD [XMMBLOCK(3,0,rdx,SIZEOF_ISLOW_MULT_TYPE)]
- movdqa xmm1, XMMWORD [XMMBLOCK(5,0,rsi,SIZEOF_JCOEF)]
- movdqa xmm3, XMMWORD [XMMBLOCK(7,0,rsi,SIZEOF_JCOEF)]
- pmullw xmm1, XMMWORD [XMMBLOCK(5,0,rdx,SIZEOF_ISLOW_MULT_TYPE)]
- pmullw xmm3, XMMWORD [XMMBLOCK(7,0,rdx,SIZEOF_ISLOW_MULT_TYPE)]
-
- movdqa xmm5, xmm6
- movdqa xmm7, xmm4
- paddw xmm5, xmm3 ; xmm5=z3
- paddw xmm7, xmm1 ; xmm7=z4
-
- ; (Original)
- ; z5 = (z3 + z4) * 1.175875602;
- ; z3 = z3 * -1.961570560; z4 = z4 * -0.390180644;
- ; z3 += z5; z4 += z5;
- ;
- ; (This implementation)
- ; z3 = z3 * (1.175875602 - 1.961570560) + z4 * 1.175875602;
- ; z4 = z3 * 1.175875602 + z4 * (1.175875602 - 0.390180644);
-
- movdqa xmm2, xmm5
- movdqa xmm0, xmm5
- punpcklwd xmm2, xmm7
- punpckhwd xmm0, xmm7
- movdqa xmm5, xmm2
- movdqa xmm7, xmm0
- pmaddwd xmm2, [rel PW_MF078_F117] ; xmm2=z3L
- pmaddwd xmm0, [rel PW_MF078_F117] ; xmm0=z3H
- pmaddwd xmm5, [rel PW_F117_F078] ; xmm5=z4L
- pmaddwd xmm7, [rel PW_F117_F078] ; xmm7=z4H
-
- movdqa XMMWORD [wk(10)], xmm2 ; wk(10)=z3L
- movdqa XMMWORD [wk(11)], xmm0 ; wk(11)=z3H
-
- ; (Original)
- ; z1 = tmp0 + tmp3; z2 = tmp1 + tmp2;
- ; tmp0 = tmp0 * 0.298631336; tmp1 = tmp1 * 2.053119869;
- ; tmp2 = tmp2 * 3.072711026; tmp3 = tmp3 * 1.501321110;
- ; z1 = z1 * -0.899976223; z2 = z2 * -2.562915447;
- ; tmp0 += z1 + z3; tmp1 += z2 + z4;
- ; tmp2 += z2 + z3; tmp3 += z1 + z4;
- ;
- ; (This implementation)
- ; tmp0 = tmp0 * (0.298631336 - 0.899976223) + tmp3 * -0.899976223;
- ; tmp1 = tmp1 * (2.053119869 - 2.562915447) + tmp2 * -2.562915447;
- ; tmp2 = tmp1 * -2.562915447 + tmp2 * (3.072711026 - 2.562915447);
- ; tmp3 = tmp0 * -0.899976223 + tmp3 * (1.501321110 - 0.899976223);
- ; tmp0 += z3; tmp1 += z4;
- ; tmp2 += z3; tmp3 += z4;
-
- movdqa xmm2, xmm3
- movdqa xmm0, xmm3
- punpcklwd xmm2, xmm4
- punpckhwd xmm0, xmm4
- movdqa xmm3, xmm2
- movdqa xmm4, xmm0
- pmaddwd xmm2, [rel PW_MF060_MF089] ; xmm2=tmp0L
- pmaddwd xmm0, [rel PW_MF060_MF089] ; xmm0=tmp0H
- pmaddwd xmm3, [rel PW_MF089_F060] ; xmm3=tmp3L
- pmaddwd xmm4, [rel PW_MF089_F060] ; xmm4=tmp3H
-
- paddd xmm2, XMMWORD [wk(10)] ; xmm2=tmp0L
- paddd xmm0, XMMWORD [wk(11)] ; xmm0=tmp0H
- paddd xmm3, xmm5 ; xmm3=tmp3L
- paddd xmm4, xmm7 ; xmm4=tmp3H
-
- movdqa XMMWORD [wk(8)], xmm2 ; wk(8)=tmp0L
- movdqa XMMWORD [wk(9)], xmm0 ; wk(9)=tmp0H
-
- movdqa xmm2, xmm1
- movdqa xmm0, xmm1
- punpcklwd xmm2, xmm6
- punpckhwd xmm0, xmm6
- movdqa xmm1, xmm2
- movdqa xmm6, xmm0
- pmaddwd xmm2, [rel PW_MF050_MF256] ; xmm2=tmp1L
- pmaddwd xmm0, [rel PW_MF050_MF256] ; xmm0=tmp1H
- pmaddwd xmm1, [rel PW_MF256_F050] ; xmm1=tmp2L
- pmaddwd xmm6, [rel PW_MF256_F050] ; xmm6=tmp2H
-
- paddd xmm2, xmm5 ; xmm2=tmp1L
- paddd xmm0, xmm7 ; xmm0=tmp1H
- paddd xmm1, XMMWORD [wk(10)] ; xmm1=tmp2L
- paddd xmm6, XMMWORD [wk(11)] ; xmm6=tmp2H
-
- movdqa XMMWORD [wk(10)], xmm2 ; wk(10)=tmp1L
- movdqa XMMWORD [wk(11)], xmm0 ; wk(11)=tmp1H
-
- ; -- Final output stage
-
- movdqa xmm5, XMMWORD [wk(0)] ; xmm5=tmp10L
- movdqa xmm7, XMMWORD [wk(1)] ; xmm7=tmp10H
-
- movdqa xmm2, xmm5
- movdqa xmm0, xmm7
- paddd xmm5, xmm3 ; xmm5=data0L
- paddd xmm7, xmm4 ; xmm7=data0H
- psubd xmm2, xmm3 ; xmm2=data7L
- psubd xmm0, xmm4 ; xmm0=data7H
-
- movdqa xmm3, [rel PD_DESCALE_P1] ; xmm3=[rel PD_DESCALE_P1]
-
- paddd xmm5, xmm3
- paddd xmm7, xmm3
- psrad xmm5, DESCALE_P1
- psrad xmm7, DESCALE_P1
- paddd xmm2, xmm3
- paddd xmm0, xmm3
- psrad xmm2, DESCALE_P1
- psrad xmm0, DESCALE_P1
-
- packssdw xmm5, xmm7 ; xmm5=data0=(00 01 02 03 04 05 06 07)
- packssdw xmm2, xmm0 ; xmm2=data7=(70 71 72 73 74 75 76 77)
-
- movdqa xmm4, XMMWORD [wk(4)] ; xmm4=tmp11L
- movdqa xmm3, XMMWORD [wk(5)] ; xmm3=tmp11H
-
- movdqa xmm7, xmm4
- movdqa xmm0, xmm3
- paddd xmm4, xmm1 ; xmm4=data1L
- paddd xmm3, xmm6 ; xmm3=data1H
- psubd xmm7, xmm1 ; xmm7=data6L
- psubd xmm0, xmm6 ; xmm0=data6H
-
- movdqa xmm1, [rel PD_DESCALE_P1] ; xmm1=[rel PD_DESCALE_P1]
-
- paddd xmm4, xmm1
- paddd xmm3, xmm1
- psrad xmm4, DESCALE_P1
- psrad xmm3, DESCALE_P1
- paddd xmm7, xmm1
- paddd xmm0, xmm1
- psrad xmm7, DESCALE_P1
- psrad xmm0, DESCALE_P1
-
- packssdw xmm4, xmm3 ; xmm4=data1=(10 11 12 13 14 15 16 17)
- packssdw xmm7, xmm0 ; xmm7=data6=(60 61 62 63 64 65 66 67)
-
- movdqa xmm6, xmm5 ; transpose coefficients(phase 1)
- punpcklwd xmm5, xmm4 ; xmm5=(00 10 01 11 02 12 03 13)
- punpckhwd xmm6, xmm4 ; xmm6=(04 14 05 15 06 16 07 17)
- movdqa xmm1, xmm7 ; transpose coefficients(phase 1)
- punpcklwd xmm7, xmm2 ; xmm7=(60 70 61 71 62 72 63 73)
- punpckhwd xmm1, xmm2 ; xmm1=(64 74 65 75 66 76 67 77)
-
- movdqa xmm3, XMMWORD [wk(6)] ; xmm3=tmp12L
- movdqa xmm0, XMMWORD [wk(7)] ; xmm0=tmp12H
- movdqa xmm4, XMMWORD [wk(10)] ; xmm4=tmp1L
- movdqa xmm2, XMMWORD [wk(11)] ; xmm2=tmp1H
-
- movdqa XMMWORD [wk(0)], xmm5 ; wk(0)=(00 10 01 11 02 12 03 13)
- movdqa XMMWORD [wk(1)], xmm6 ; wk(1)=(04 14 05 15 06 16 07 17)
- movdqa XMMWORD [wk(4)], xmm7 ; wk(4)=(60 70 61 71 62 72 63 73)
- movdqa XMMWORD [wk(5)], xmm1 ; wk(5)=(64 74 65 75 66 76 67 77)
-
- movdqa xmm5, xmm3
- movdqa xmm6, xmm0
- paddd xmm3, xmm4 ; xmm3=data2L
- paddd xmm0, xmm2 ; xmm0=data2H
- psubd xmm5, xmm4 ; xmm5=data5L
- psubd xmm6, xmm2 ; xmm6=data5H
-
- movdqa xmm7, [rel PD_DESCALE_P1] ; xmm7=[rel PD_DESCALE_P1]
-
- paddd xmm3, xmm7
- paddd xmm0, xmm7
- psrad xmm3, DESCALE_P1
- psrad xmm0, DESCALE_P1
- paddd xmm5, xmm7
- paddd xmm6, xmm7
- psrad xmm5, DESCALE_P1
- psrad xmm6, DESCALE_P1
-
- packssdw xmm3, xmm0 ; xmm3=data2=(20 21 22 23 24 25 26 27)
- packssdw xmm5, xmm6 ; xmm5=data5=(50 51 52 53 54 55 56 57)
-
- movdqa xmm1, XMMWORD [wk(2)] ; xmm1=tmp13L
- movdqa xmm4, XMMWORD [wk(3)] ; xmm4=tmp13H
- movdqa xmm2, XMMWORD [wk(8)] ; xmm2=tmp0L
- movdqa xmm7, XMMWORD [wk(9)] ; xmm7=tmp0H
-
- movdqa xmm0, xmm1
- movdqa xmm6, xmm4
- paddd xmm1, xmm2 ; xmm1=data3L
- paddd xmm4, xmm7 ; xmm4=data3H
- psubd xmm0, xmm2 ; xmm0=data4L
- psubd xmm6, xmm7 ; xmm6=data4H
-
- movdqa xmm2, [rel PD_DESCALE_P1] ; xmm2=[rel PD_DESCALE_P1]
-
- paddd xmm1, xmm2
- paddd xmm4, xmm2
- psrad xmm1, DESCALE_P1
- psrad xmm4, DESCALE_P1
- paddd xmm0, xmm2
- paddd xmm6, xmm2
- psrad xmm0, DESCALE_P1
- psrad xmm6, DESCALE_P1
-
- packssdw xmm1, xmm4 ; xmm1=data3=(30 31 32 33 34 35 36 37)
- packssdw xmm0, xmm6 ; xmm0=data4=(40 41 42 43 44 45 46 47)
-
- movdqa xmm7, XMMWORD [wk(0)] ; xmm7=(00 10 01 11 02 12 03 13)
- movdqa xmm2, XMMWORD [wk(1)] ; xmm2=(04 14 05 15 06 16 07 17)
-
- movdqa xmm4, xmm3 ; transpose coefficients(phase 1)
- punpcklwd xmm3, xmm1 ; xmm3=(20 30 21 31 22 32 23 33)
- punpckhwd xmm4, xmm1 ; xmm4=(24 34 25 35 26 36 27 37)
- movdqa xmm6, xmm0 ; transpose coefficients(phase 1)
- punpcklwd xmm0, xmm5 ; xmm0=(40 50 41 51 42 52 43 53)
- punpckhwd xmm6, xmm5 ; xmm6=(44 54 45 55 46 56 47 57)
-
- movdqa xmm1, xmm7 ; transpose coefficients(phase 2)
- punpckldq xmm7, xmm3 ; xmm7=(00 10 20 30 01 11 21 31)
- punpckhdq xmm1, xmm3 ; xmm1=(02 12 22 32 03 13 23 33)
- movdqa xmm5, xmm2 ; transpose coefficients(phase 2)
- punpckldq xmm2, xmm4 ; xmm2=(04 14 24 34 05 15 25 35)
- punpckhdq xmm5, xmm4 ; xmm5=(06 16 26 36 07 17 27 37)
-
- movdqa xmm3, XMMWORD [wk(4)] ; xmm3=(60 70 61 71 62 72 63 73)
- movdqa xmm4, XMMWORD [wk(5)] ; xmm4=(64 74 65 75 66 76 67 77)
-
- movdqa XMMWORD [wk(6)], xmm2 ; wk(6)=(04 14 24 34 05 15 25 35)
- movdqa XMMWORD [wk(7)], xmm5 ; wk(7)=(06 16 26 36 07 17 27 37)
-
- movdqa xmm2, xmm0 ; transpose coefficients(phase 2)
- punpckldq xmm0, xmm3 ; xmm0=(40 50 60 70 41 51 61 71)
- punpckhdq xmm2, xmm3 ; xmm2=(42 52 62 72 43 53 63 73)
- movdqa xmm5, xmm6 ; transpose coefficients(phase 2)
- punpckldq xmm6, xmm4 ; xmm6=(44 54 64 74 45 55 65 75)
- punpckhdq xmm5, xmm4 ; xmm5=(46 56 66 76 47 57 67 77)
-
- movdqa xmm3, xmm7 ; transpose coefficients(phase 3)
- punpcklqdq xmm7, xmm0 ; xmm7=col0=(00 10 20 30 40 50 60 70)
- punpckhqdq xmm3, xmm0 ; xmm3=col1=(01 11 21 31 41 51 61 71)
- movdqa xmm4, xmm1 ; transpose coefficients(phase 3)
- punpcklqdq xmm1, xmm2 ; xmm1=col2=(02 12 22 32 42 52 62 72)
- punpckhqdq xmm4, xmm2 ; xmm4=col3=(03 13 23 33 43 53 63 73)
-
- movdqa xmm0, XMMWORD [wk(6)] ; xmm0=(04 14 24 34 05 15 25 35)
- movdqa xmm2, XMMWORD [wk(7)] ; xmm2=(06 16 26 36 07 17 27 37)
-
- movdqa XMMWORD [wk(8)], xmm3 ; wk(8)=col1
- movdqa XMMWORD [wk(9)], xmm4 ; wk(9)=col3
-
- movdqa xmm3, xmm0 ; transpose coefficients(phase 3)
- punpcklqdq xmm0, xmm6 ; xmm0=col4=(04 14 24 34 44 54 64 74)
- punpckhqdq xmm3, xmm6 ; xmm3=col5=(05 15 25 35 45 55 65 75)
- movdqa xmm4, xmm2 ; transpose coefficients(phase 3)
- punpcklqdq xmm2, xmm5 ; xmm2=col6=(06 16 26 36 46 56 66 76)
- punpckhqdq xmm4, xmm5 ; xmm4=col7=(07 17 27 37 47 57 67 77)
-
- movdqa XMMWORD [wk(10)], xmm3 ; wk(10)=col5
- movdqa XMMWORD [wk(11)], xmm4 ; wk(11)=col7
-.column_end:
-
- ; -- Prefetch the next coefficient block
-
- prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 0*32]
- prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 1*32]
- prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 2*32]
- prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 3*32]
-
- ; ---- Pass 2: process rows from work array, store into output array.
-
- mov rax, [original_rbp]
- mov rdi, r12 ; (JSAMPROW *)
- mov eax, r13d
-
- ; -- Even part
-
- ; xmm7=col0, xmm1=col2, xmm0=col4, xmm2=col6
-
- ; (Original)
- ; z1 = (z2 + z3) * 0.541196100;
- ; tmp2 = z1 + z3 * -1.847759065;
- ; tmp3 = z1 + z2 * 0.765366865;
- ;
- ; (This implementation)
- ; tmp2 = z2 * 0.541196100 + z3 * (0.541196100 - 1.847759065);
- ; tmp3 = z2 * (0.541196100 + 0.765366865) + z3 * 0.541196100;
-
- movdqa xmm6, xmm1 ; xmm1=in2=z2
- movdqa xmm5, xmm1
- punpcklwd xmm6, xmm2 ; xmm2=in6=z3
- punpckhwd xmm5, xmm2
- movdqa xmm1, xmm6
- movdqa xmm2, xmm5
- pmaddwd xmm6, [rel PW_F130_F054] ; xmm6=tmp3L
- pmaddwd xmm5, [rel PW_F130_F054] ; xmm5=tmp3H
- pmaddwd xmm1, [rel PW_F054_MF130] ; xmm1=tmp2L
- pmaddwd xmm2, [rel PW_F054_MF130] ; xmm2=tmp2H
-
- movdqa xmm3, xmm7
- paddw xmm7, xmm0 ; xmm7=in0+in4
- psubw xmm3, xmm0 ; xmm3=in0-in4
-
- pxor xmm4, xmm4
- pxor xmm0, xmm0
- punpcklwd xmm4, xmm7 ; xmm4=tmp0L
- punpckhwd xmm0, xmm7 ; xmm0=tmp0H
- psrad xmm4, (16-CONST_BITS) ; psrad xmm4,16 & pslld xmm4,CONST_BITS
- psrad xmm0, (16-CONST_BITS) ; psrad xmm0,16 & pslld xmm0,CONST_BITS
-
- movdqa xmm7, xmm4
- paddd xmm4, xmm6 ; xmm4=tmp10L
- psubd xmm7, xmm6 ; xmm7=tmp13L
- movdqa xmm6, xmm0
- paddd xmm0, xmm5 ; xmm0=tmp10H
- psubd xmm6, xmm5 ; xmm6=tmp13H
-
- movdqa XMMWORD [wk(0)], xmm4 ; wk(0)=tmp10L
- movdqa XMMWORD [wk(1)], xmm0 ; wk(1)=tmp10H
- movdqa XMMWORD [wk(2)], xmm7 ; wk(2)=tmp13L
- movdqa XMMWORD [wk(3)], xmm6 ; wk(3)=tmp13H
-
- pxor xmm5, xmm5
- pxor xmm4, xmm4
- punpcklwd xmm5, xmm3 ; xmm5=tmp1L
- punpckhwd xmm4, xmm3 ; xmm4=tmp1H
- psrad xmm5, (16-CONST_BITS) ; psrad xmm5,16 & pslld xmm5,CONST_BITS
- psrad xmm4, (16-CONST_BITS) ; psrad xmm4,16 & pslld xmm4,CONST_BITS
-
- movdqa xmm0, xmm5
- paddd xmm5, xmm1 ; xmm5=tmp11L
- psubd xmm0, xmm1 ; xmm0=tmp12L
- movdqa xmm7, xmm4
- paddd xmm4, xmm2 ; xmm4=tmp11H
- psubd xmm7, xmm2 ; xmm7=tmp12H
-
- movdqa XMMWORD [wk(4)], xmm5 ; wk(4)=tmp11L
- movdqa XMMWORD [wk(5)], xmm4 ; wk(5)=tmp11H
- movdqa XMMWORD [wk(6)], xmm0 ; wk(6)=tmp12L
- movdqa XMMWORD [wk(7)], xmm7 ; wk(7)=tmp12H
-
- ; -- Odd part
-
- movdqa xmm6, XMMWORD [wk(9)] ; xmm6=col3
- movdqa xmm3, XMMWORD [wk(8)] ; xmm3=col1
- movdqa xmm1, XMMWORD [wk(11)] ; xmm1=col7
- movdqa xmm2, XMMWORD [wk(10)] ; xmm2=col5
-
- movdqa xmm5, xmm6
- movdqa xmm4, xmm3
- paddw xmm5, xmm1 ; xmm5=z3
- paddw xmm4, xmm2 ; xmm4=z4
-
- ; (Original)
- ; z5 = (z3 + z4) * 1.175875602;
- ; z3 = z3 * -1.961570560; z4 = z4 * -0.390180644;
- ; z3 += z5; z4 += z5;
- ;
- ; (This implementation)
- ; z3 = z3 * (1.175875602 - 1.961570560) + z4 * 1.175875602;
- ; z4 = z3 * 1.175875602 + z4 * (1.175875602 - 0.390180644);
-
- movdqa xmm0, xmm5
- movdqa xmm7, xmm5
- punpcklwd xmm0, xmm4
- punpckhwd xmm7, xmm4
- movdqa xmm5, xmm0
- movdqa xmm4, xmm7
- pmaddwd xmm0, [rel PW_MF078_F117] ; xmm0=z3L
- pmaddwd xmm7, [rel PW_MF078_F117] ; xmm7=z3H
- pmaddwd xmm5, [rel PW_F117_F078] ; xmm5=z4L
- pmaddwd xmm4, [rel PW_F117_F078] ; xmm4=z4H
-
- movdqa XMMWORD [wk(10)], xmm0 ; wk(10)=z3L
- movdqa XMMWORD [wk(11)], xmm7 ; wk(11)=z3H
-
- ; (Original)
- ; z1 = tmp0 + tmp3; z2 = tmp1 + tmp2;
- ; tmp0 = tmp0 * 0.298631336; tmp1 = tmp1 * 2.053119869;
- ; tmp2 = tmp2 * 3.072711026; tmp3 = tmp3 * 1.501321110;
- ; z1 = z1 * -0.899976223; z2 = z2 * -2.562915447;
- ; tmp0 += z1 + z3; tmp1 += z2 + z4;
- ; tmp2 += z2 + z3; tmp3 += z1 + z4;
- ;
- ; (This implementation)
- ; tmp0 = tmp0 * (0.298631336 - 0.899976223) + tmp3 * -0.899976223;
- ; tmp1 = tmp1 * (2.053119869 - 2.562915447) + tmp2 * -2.562915447;
- ; tmp2 = tmp1 * -2.562915447 + tmp2 * (3.072711026 - 2.562915447);
- ; tmp3 = tmp0 * -0.899976223 + tmp3 * (1.501321110 - 0.899976223);
- ; tmp0 += z3; tmp1 += z4;
- ; tmp2 += z3; tmp3 += z4;
-
- movdqa xmm0, xmm1
- movdqa xmm7, xmm1
- punpcklwd xmm0, xmm3
- punpckhwd xmm7, xmm3
- movdqa xmm1, xmm0
- movdqa xmm3, xmm7
- pmaddwd xmm0, [rel PW_MF060_MF089] ; xmm0=tmp0L
- pmaddwd xmm7, [rel PW_MF060_MF089] ; xmm7=tmp0H
- pmaddwd xmm1, [rel PW_MF089_F060] ; xmm1=tmp3L
- pmaddwd xmm3, [rel PW_MF089_F060] ; xmm3=tmp3H
-
- paddd xmm0, XMMWORD [wk(10)] ; xmm0=tmp0L
- paddd xmm7, XMMWORD [wk(11)] ; xmm7=tmp0H
- paddd xmm1, xmm5 ; xmm1=tmp3L
- paddd xmm3, xmm4 ; xmm3=tmp3H
-
- movdqa XMMWORD [wk(8)], xmm0 ; wk(8)=tmp0L
- movdqa XMMWORD [wk(9)], xmm7 ; wk(9)=tmp0H
-
- movdqa xmm0, xmm2
- movdqa xmm7, xmm2
- punpcklwd xmm0, xmm6
- punpckhwd xmm7, xmm6
- movdqa xmm2, xmm0
- movdqa xmm6, xmm7
- pmaddwd xmm0, [rel PW_MF050_MF256] ; xmm0=tmp1L
- pmaddwd xmm7, [rel PW_MF050_MF256] ; xmm7=tmp1H
- pmaddwd xmm2, [rel PW_MF256_F050] ; xmm2=tmp2L
- pmaddwd xmm6, [rel PW_MF256_F050] ; xmm6=tmp2H
-
- paddd xmm0, xmm5 ; xmm0=tmp1L
- paddd xmm7, xmm4 ; xmm7=tmp1H
- paddd xmm2, XMMWORD [wk(10)] ; xmm2=tmp2L
- paddd xmm6, XMMWORD [wk(11)] ; xmm6=tmp2H
-
- movdqa XMMWORD [wk(10)], xmm0 ; wk(10)=tmp1L
- movdqa XMMWORD [wk(11)], xmm7 ; wk(11)=tmp1H
-
- ; -- Final output stage
-
- movdqa xmm5, XMMWORD [wk(0)] ; xmm5=tmp10L
- movdqa xmm4, XMMWORD [wk(1)] ; xmm4=tmp10H
-
- movdqa xmm0, xmm5
- movdqa xmm7, xmm4
- paddd xmm5, xmm1 ; xmm5=data0L
- paddd xmm4, xmm3 ; xmm4=data0H
- psubd xmm0, xmm1 ; xmm0=data7L
- psubd xmm7, xmm3 ; xmm7=data7H
-
- movdqa xmm1, [rel PD_DESCALE_P2] ; xmm1=[rel PD_DESCALE_P2]
-
- paddd xmm5, xmm1
- paddd xmm4, xmm1
- psrad xmm5, DESCALE_P2
- psrad xmm4, DESCALE_P2
- paddd xmm0, xmm1
- paddd xmm7, xmm1
- psrad xmm0, DESCALE_P2
- psrad xmm7, DESCALE_P2
-
- packssdw xmm5, xmm4 ; xmm5=data0=(00 10 20 30 40 50 60 70)
- packssdw xmm0, xmm7 ; xmm0=data7=(07 17 27 37 47 57 67 77)
-
- movdqa xmm3, XMMWORD [wk(4)] ; xmm3=tmp11L
- movdqa xmm1, XMMWORD [wk(5)] ; xmm1=tmp11H
-
- movdqa xmm4, xmm3
- movdqa xmm7, xmm1
- paddd xmm3, xmm2 ; xmm3=data1L
- paddd xmm1, xmm6 ; xmm1=data1H
- psubd xmm4, xmm2 ; xmm4=data6L
- psubd xmm7, xmm6 ; xmm7=data6H
-
- movdqa xmm2, [rel PD_DESCALE_P2] ; xmm2=[rel PD_DESCALE_P2]
-
- paddd xmm3, xmm2
- paddd xmm1, xmm2
- psrad xmm3, DESCALE_P2
- psrad xmm1, DESCALE_P2
- paddd xmm4, xmm2
- paddd xmm7, xmm2
- psrad xmm4, DESCALE_P2
- psrad xmm7, DESCALE_P2
-
- packssdw xmm3, xmm1 ; xmm3=data1=(01 11 21 31 41 51 61 71)
- packssdw xmm4, xmm7 ; xmm4=data6=(06 16 26 36 46 56 66 76)
-
- packsswb xmm5, xmm4 ; xmm5=(00 10 20 30 40 50 60 70 06 16 26 36 46 56 66 76)
- packsswb xmm3, xmm0 ; xmm3=(01 11 21 31 41 51 61 71 07 17 27 37 47 57 67 77)
-
- movdqa xmm6, XMMWORD [wk(6)] ; xmm6=tmp12L
- movdqa xmm2, XMMWORD [wk(7)] ; xmm2=tmp12H
- movdqa xmm1, XMMWORD [wk(10)] ; xmm1=tmp1L
- movdqa xmm7, XMMWORD [wk(11)] ; xmm7=tmp1H
-
- movdqa XMMWORD [wk(0)], xmm5 ; wk(0)=(00 10 20 30 40 50 60 70 06 16 26 36 46 56 66 76)
- movdqa XMMWORD [wk(1)], xmm3 ; wk(1)=(01 11 21 31 41 51 61 71 07 17 27 37 47 57 67 77)
-
- movdqa xmm4, xmm6
- movdqa xmm0, xmm2
- paddd xmm6, xmm1 ; xmm6=data2L
- paddd xmm2, xmm7 ; xmm2=data2H
- psubd xmm4, xmm1 ; xmm4=data5L
- psubd xmm0, xmm7 ; xmm0=data5H
-
- movdqa xmm5, [rel PD_DESCALE_P2] ; xmm5=[rel PD_DESCALE_P2]
-
- paddd xmm6, xmm5
- paddd xmm2, xmm5
- psrad xmm6, DESCALE_P2
- psrad xmm2, DESCALE_P2
- paddd xmm4, xmm5
- paddd xmm0, xmm5
- psrad xmm4, DESCALE_P2
- psrad xmm0, DESCALE_P2
-
- packssdw xmm6, xmm2 ; xmm6=data2=(02 12 22 32 42 52 62 72)
- packssdw xmm4, xmm0 ; xmm4=data5=(05 15 25 35 45 55 65 75)
-
- movdqa xmm3, XMMWORD [wk(2)] ; xmm3=tmp13L
- movdqa xmm1, XMMWORD [wk(3)] ; xmm1=tmp13H
- movdqa xmm7, XMMWORD [wk(8)] ; xmm7=tmp0L
- movdqa xmm5, XMMWORD [wk(9)] ; xmm5=tmp0H
-
- movdqa xmm2, xmm3
- movdqa xmm0, xmm1
- paddd xmm3, xmm7 ; xmm3=data3L
- paddd xmm1, xmm5 ; xmm1=data3H
- psubd xmm2, xmm7 ; xmm2=data4L
- psubd xmm0, xmm5 ; xmm0=data4H
-
- movdqa xmm7, [rel PD_DESCALE_P2] ; xmm7=[rel PD_DESCALE_P2]
-
- paddd xmm3, xmm7
- paddd xmm1, xmm7
- psrad xmm3, DESCALE_P2
- psrad xmm1, DESCALE_P2
- paddd xmm2, xmm7
- paddd xmm0, xmm7
- psrad xmm2, DESCALE_P2
- psrad xmm0, DESCALE_P2
-
- movdqa xmm5, [rel PB_CENTERJSAMP] ; xmm5=[rel PB_CENTERJSAMP]
-
- packssdw xmm3, xmm1 ; xmm3=data3=(03 13 23 33 43 53 63 73)
- packssdw xmm2, xmm0 ; xmm2=data4=(04 14 24 34 44 54 64 74)
-
- movdqa xmm7, XMMWORD [wk(0)] ; xmm7=(00 10 20 30 40 50 60 70 06 16 26 36 46 56 66 76)
- movdqa xmm1, XMMWORD [wk(1)] ; xmm1=(01 11 21 31 41 51 61 71 07 17 27 37 47 57 67 77)
-
- packsswb xmm6, xmm2 ; xmm6=(02 12 22 32 42 52 62 72 04 14 24 34 44 54 64 74)
- packsswb xmm3, xmm4 ; xmm3=(03 13 23 33 43 53 63 73 05 15 25 35 45 55 65 75)
-
- paddb xmm7, xmm5
- paddb xmm1, xmm5
- paddb xmm6, xmm5
- paddb xmm3, xmm5
-
- movdqa xmm0, xmm7 ; transpose coefficients(phase 1)
- punpcklbw xmm7, xmm1 ; xmm7=(00 01 10 11 20 21 30 31 40 41 50 51 60 61 70 71)
- punpckhbw xmm0, xmm1 ; xmm0=(06 07 16 17 26 27 36 37 46 47 56 57 66 67 76 77)
- movdqa xmm2, xmm6 ; transpose coefficients(phase 1)
- punpcklbw xmm6, xmm3 ; xmm6=(02 03 12 13 22 23 32 33 42 43 52 53 62 63 72 73)
- punpckhbw xmm2, xmm3 ; xmm2=(04 05 14 15 24 25 34 35 44 45 54 55 64 65 74 75)
-
- movdqa xmm4, xmm7 ; transpose coefficients(phase 2)
- punpcklwd xmm7, xmm6 ; xmm7=(00 01 02 03 10 11 12 13 20 21 22 23 30 31 32 33)
- punpckhwd xmm4, xmm6 ; xmm4=(40 41 42 43 50 51 52 53 60 61 62 63 70 71 72 73)
- movdqa xmm5, xmm2 ; transpose coefficients(phase 2)
- punpcklwd xmm2, xmm0 ; xmm2=(04 05 06 07 14 15 16 17 24 25 26 27 34 35 36 37)
- punpckhwd xmm5, xmm0 ; xmm5=(44 45 46 47 54 55 56 57 64 65 66 67 74 75 76 77)
-
- movdqa xmm1, xmm7 ; transpose coefficients(phase 3)
- punpckldq xmm7, xmm2 ; xmm7=(00 01 02 03 04 05 06 07 10 11 12 13 14 15 16 17)
- punpckhdq xmm1, xmm2 ; xmm1=(20 21 22 23 24 25 26 27 30 31 32 33 34 35 36 37)
- movdqa xmm3, xmm4 ; transpose coefficients(phase 3)
- punpckldq xmm4, xmm5 ; xmm4=(40 41 42 43 44 45 46 47 50 51 52 53 54 55 56 57)
- punpckhdq xmm3, xmm5 ; xmm3=(60 61 62 63 64 65 66 67 70 71 72 73 74 75 76 77)
-
- pshufd xmm6, xmm7, 0x4E ; xmm6=(10 11 12 13 14 15 16 17 00 01 02 03 04 05 06 07)
- pshufd xmm0, xmm1, 0x4E ; xmm0=(30 31 32 33 34 35 36 37 20 21 22 23 24 25 26 27)
- pshufd xmm2, xmm4, 0x4E ; xmm2=(50 51 52 53 54 55 56 57 40 41 42 43 44 45 46 47)
- pshufd xmm5, xmm3, 0x4E ; xmm5=(70 71 72 73 74 75 76 77 60 61 62 63 64 65 66 67)
-
- mov rdxp, JSAMPROW [rdi+0*SIZEOF_JSAMPROW]
- mov rsip, JSAMPROW [rdi+2*SIZEOF_JSAMPROW]
- movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm7
- movq XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE], xmm1
- mov rdxp, JSAMPROW [rdi+4*SIZEOF_JSAMPROW]
- mov rsip, JSAMPROW [rdi+6*SIZEOF_JSAMPROW]
- movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm4
- movq XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE], xmm3
-
- mov rdxp, JSAMPROW [rdi+1*SIZEOF_JSAMPROW]
- mov rsip, JSAMPROW [rdi+3*SIZEOF_JSAMPROW]
- movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm6
- movq XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE], xmm0
- mov rdxp, JSAMPROW [rdi+5*SIZEOF_JSAMPROW]
- mov rsip, JSAMPROW [rdi+7*SIZEOF_JSAMPROW]
- movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm2
- movq XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE], xmm5
-
- uncollect_args 4
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
- pop rbp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jidctred-sse2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jidctred-sse2.asm
deleted file mode 100644
index 4ece9d891c..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jidctred-sse2.asm
+++ /dev/null
@@ -1,574 +0,0 @@
-;
-; jidctred.asm - reduced-size IDCT (64-bit SSE2)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
-; Copyright (C) 2018, Matthias Räncker.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-;
-; This file contains inverse-DCT routines that produce reduced-size
-; output: either 4x4 or 2x2 pixels from an 8x8 DCT block.
-; The following code is based directly on the IJG's original jidctred.c;
-; see the jidctred.c for more details.
-
-%include "jsimdext.inc"
-%include "jdct.inc"
-
-; --------------------------------------------------------------------------
-
-%define CONST_BITS 13
-%define PASS1_BITS 2
-
-%define DESCALE_P1_4 (CONST_BITS - PASS1_BITS + 1)
-%define DESCALE_P2_4 (CONST_BITS + PASS1_BITS + 3 + 1)
-%define DESCALE_P1_2 (CONST_BITS - PASS1_BITS + 2)
-%define DESCALE_P2_2 (CONST_BITS + PASS1_BITS + 3 + 2)
-
-%if CONST_BITS == 13
-F_0_211 equ 1730 ; FIX(0.211164243)
-F_0_509 equ 4176 ; FIX(0.509795579)
-F_0_601 equ 4926 ; FIX(0.601344887)
-F_0_720 equ 5906 ; FIX(0.720959822)
-F_0_765 equ 6270 ; FIX(0.765366865)
-F_0_850 equ 6967 ; FIX(0.850430095)
-F_0_899 equ 7373 ; FIX(0.899976223)
-F_1_061 equ 8697 ; FIX(1.061594337)
-F_1_272 equ 10426 ; FIX(1.272758580)
-F_1_451 equ 11893 ; FIX(1.451774981)
-F_1_847 equ 15137 ; FIX(1.847759065)
-F_2_172 equ 17799 ; FIX(2.172734803)
-F_2_562 equ 20995 ; FIX(2.562915447)
-F_3_624 equ 29692 ; FIX(3.624509785)
-%else
-; NASM cannot do compile-time arithmetic on floating-point constants.
-%define DESCALE(x, n) (((x) + (1 << ((n) - 1))) >> (n))
-F_0_211 equ DESCALE( 226735879, 30 - CONST_BITS) ; FIX(0.211164243)
-F_0_509 equ DESCALE( 547388834, 30 - CONST_BITS) ; FIX(0.509795579)
-F_0_601 equ DESCALE( 645689155, 30 - CONST_BITS) ; FIX(0.601344887)
-F_0_720 equ DESCALE( 774124714, 30 - CONST_BITS) ; FIX(0.720959822)
-F_0_765 equ DESCALE( 821806413, 30 - CONST_BITS) ; FIX(0.765366865)
-F_0_850 equ DESCALE( 913142361, 30 - CONST_BITS) ; FIX(0.850430095)
-F_0_899 equ DESCALE( 966342111, 30 - CONST_BITS) ; FIX(0.899976223)
-F_1_061 equ DESCALE(1139878239, 30 - CONST_BITS) ; FIX(1.061594337)
-F_1_272 equ DESCALE(1366614119, 30 - CONST_BITS) ; FIX(1.272758580)
-F_1_451 equ DESCALE(1558831516, 30 - CONST_BITS) ; FIX(1.451774981)
-F_1_847 equ DESCALE(1984016188, 30 - CONST_BITS) ; FIX(1.847759065)
-F_2_172 equ DESCALE(2332956230, 30 - CONST_BITS) ; FIX(2.172734803)
-F_2_562 equ DESCALE(2751909506, 30 - CONST_BITS) ; FIX(2.562915447)
-F_3_624 equ DESCALE(3891787747, 30 - CONST_BITS) ; FIX(3.624509785)
-%endif
-
-; --------------------------------------------------------------------------
- SECTION SEG_CONST
-
- alignz 32
- GLOBAL_DATA(jconst_idct_red_sse2)
-
-EXTN(jconst_idct_red_sse2):
-
-PW_F184_MF076 times 4 dw F_1_847, -F_0_765
-PW_F256_F089 times 4 dw F_2_562, F_0_899
-PW_F106_MF217 times 4 dw F_1_061, -F_2_172
-PW_MF060_MF050 times 4 dw -F_0_601, -F_0_509
-PW_F145_MF021 times 4 dw F_1_451, -F_0_211
-PW_F362_MF127 times 4 dw F_3_624, -F_1_272
-PW_F085_MF072 times 4 dw F_0_850, -F_0_720
-PD_DESCALE_P1_4 times 4 dd 1 << (DESCALE_P1_4 - 1)
-PD_DESCALE_P2_4 times 4 dd 1 << (DESCALE_P2_4 - 1)
-PD_DESCALE_P1_2 times 4 dd 1 << (DESCALE_P1_2 - 1)
-PD_DESCALE_P2_2 times 4 dd 1 << (DESCALE_P2_2 - 1)
-PB_CENTERJSAMP times 16 db CENTERJSAMPLE
-
- alignz 32
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 64
-;
-; Perform dequantization and inverse DCT on one block of coefficients,
-; producing a reduced-size 4x4 output block.
-;
-; GLOBAL(void)
-; jsimd_idct_4x4_sse2(void *dct_table, JCOEFPTR coef_block,
-; JSAMPARRAY output_buf, JDIMENSION output_col)
-;
-
-; r10 = void *dct_table
-; r11 = JCOEFPTR coef_block
-; r12 = JSAMPARRAY output_buf
-; r13d = JDIMENSION output_col
-
-%define original_rbp rbp + 0
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_XMMWORD
- ; xmmword wk[WK_NUM]
-%define WK_NUM 2
-
- align 32
- GLOBAL_FUNCTION(jsimd_idct_4x4_sse2)
-
-EXTN(jsimd_idct_4x4_sse2):
- push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
- and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
- collect_args 4
-
- ; ---- Pass 1: process columns from input.
-
- mov rdx, r10 ; quantptr
- mov rsi, r11 ; inptr
-
-%ifndef NO_ZERO_COLUMN_TEST_4X4_SSE2
- mov eax, dword [DWBLOCK(1,0,rsi,SIZEOF_JCOEF)]
- or eax, dword [DWBLOCK(2,0,rsi,SIZEOF_JCOEF)]
- jnz short .columnDCT
-
- movdqa xmm0, XMMWORD [XMMBLOCK(1,0,rsi,SIZEOF_JCOEF)]
- movdqa xmm1, XMMWORD [XMMBLOCK(2,0,rsi,SIZEOF_JCOEF)]
- por xmm0, XMMWORD [XMMBLOCK(3,0,rsi,SIZEOF_JCOEF)]
- por xmm1, XMMWORD [XMMBLOCK(5,0,rsi,SIZEOF_JCOEF)]
- por xmm0, XMMWORD [XMMBLOCK(6,0,rsi,SIZEOF_JCOEF)]
- por xmm1, XMMWORD [XMMBLOCK(7,0,rsi,SIZEOF_JCOEF)]
- por xmm0, xmm1
- packsswb xmm0, xmm0
- packsswb xmm0, xmm0
- movd eax, xmm0
- test rax, rax
- jnz short .columnDCT
-
- ; -- AC terms all zero
-
- movdqa xmm0, XMMWORD [XMMBLOCK(0,0,rsi,SIZEOF_JCOEF)]
- pmullw xmm0, XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_ISLOW_MULT_TYPE)]
-
- psllw xmm0, PASS1_BITS
-
- movdqa xmm3, xmm0 ; xmm0=in0=(00 01 02 03 04 05 06 07)
- punpcklwd xmm0, xmm0 ; xmm0=(00 00 01 01 02 02 03 03)
- punpckhwd xmm3, xmm3 ; xmm3=(04 04 05 05 06 06 07 07)
-
- pshufd xmm1, xmm0, 0x50 ; xmm1=[col0 col1]=(00 00 00 00 01 01 01 01)
- pshufd xmm0, xmm0, 0xFA ; xmm0=[col2 col3]=(02 02 02 02 03 03 03 03)
- pshufd xmm6, xmm3, 0x50 ; xmm6=[col4 col5]=(04 04 04 04 05 05 05 05)
- pshufd xmm3, xmm3, 0xFA ; xmm3=[col6 col7]=(06 06 06 06 07 07 07 07)
-
- jmp near .column_end
-%endif
-.columnDCT:
-
- ; -- Odd part
-
- movdqa xmm0, XMMWORD [XMMBLOCK(1,0,rsi,SIZEOF_JCOEF)]
- movdqa xmm1, XMMWORD [XMMBLOCK(3,0,rsi,SIZEOF_JCOEF)]
- pmullw xmm0, XMMWORD [XMMBLOCK(1,0,rdx,SIZEOF_ISLOW_MULT_TYPE)]
- pmullw xmm1, XMMWORD [XMMBLOCK(3,0,rdx,SIZEOF_ISLOW_MULT_TYPE)]
- movdqa xmm2, XMMWORD [XMMBLOCK(5,0,rsi,SIZEOF_JCOEF)]
- movdqa xmm3, XMMWORD [XMMBLOCK(7,0,rsi,SIZEOF_JCOEF)]
- pmullw xmm2, XMMWORD [XMMBLOCK(5,0,rdx,SIZEOF_ISLOW_MULT_TYPE)]
- pmullw xmm3, XMMWORD [XMMBLOCK(7,0,rdx,SIZEOF_ISLOW_MULT_TYPE)]
-
- movdqa xmm4, xmm0
- movdqa xmm5, xmm0
- punpcklwd xmm4, xmm1
- punpckhwd xmm5, xmm1
- movdqa xmm0, xmm4
- movdqa xmm1, xmm5
- pmaddwd xmm4, [rel PW_F256_F089] ; xmm4=(tmp2L)
- pmaddwd xmm5, [rel PW_F256_F089] ; xmm5=(tmp2H)
- pmaddwd xmm0, [rel PW_F106_MF217] ; xmm0=(tmp0L)
- pmaddwd xmm1, [rel PW_F106_MF217] ; xmm1=(tmp0H)
-
- movdqa xmm6, xmm2
- movdqa xmm7, xmm2
- punpcklwd xmm6, xmm3
- punpckhwd xmm7, xmm3
- movdqa xmm2, xmm6
- movdqa xmm3, xmm7
- pmaddwd xmm6, [rel PW_MF060_MF050] ; xmm6=(tmp2L)
- pmaddwd xmm7, [rel PW_MF060_MF050] ; xmm7=(tmp2H)
- pmaddwd xmm2, [rel PW_F145_MF021] ; xmm2=(tmp0L)
- pmaddwd xmm3, [rel PW_F145_MF021] ; xmm3=(tmp0H)
-
- paddd xmm6, xmm4 ; xmm6=tmp2L
- paddd xmm7, xmm5 ; xmm7=tmp2H
- paddd xmm2, xmm0 ; xmm2=tmp0L
- paddd xmm3, xmm1 ; xmm3=tmp0H
-
- movdqa XMMWORD [wk(0)], xmm2 ; wk(0)=tmp0L
- movdqa XMMWORD [wk(1)], xmm3 ; wk(1)=tmp0H
-
- ; -- Even part
-
- movdqa xmm4, XMMWORD [XMMBLOCK(0,0,rsi,SIZEOF_JCOEF)]
- movdqa xmm5, XMMWORD [XMMBLOCK(2,0,rsi,SIZEOF_JCOEF)]
- movdqa xmm0, XMMWORD [XMMBLOCK(6,0,rsi,SIZEOF_JCOEF)]
- pmullw xmm4, XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_ISLOW_MULT_TYPE)]
- pmullw xmm5, XMMWORD [XMMBLOCK(2,0,rdx,SIZEOF_ISLOW_MULT_TYPE)]
- pmullw xmm0, XMMWORD [XMMBLOCK(6,0,rdx,SIZEOF_ISLOW_MULT_TYPE)]
-
- pxor xmm1, xmm1
- pxor xmm2, xmm2
- punpcklwd xmm1, xmm4 ; xmm1=tmp0L
- punpckhwd xmm2, xmm4 ; xmm2=tmp0H
- psrad xmm1, (16-CONST_BITS-1) ; psrad xmm1,16 & pslld xmm1,CONST_BITS+1
- psrad xmm2, (16-CONST_BITS-1) ; psrad xmm2,16 & pslld xmm2,CONST_BITS+1
-
- movdqa xmm3, xmm5 ; xmm5=in2=z2
- punpcklwd xmm5, xmm0 ; xmm0=in6=z3
- punpckhwd xmm3, xmm0
- pmaddwd xmm5, [rel PW_F184_MF076] ; xmm5=tmp2L
- pmaddwd xmm3, [rel PW_F184_MF076] ; xmm3=tmp2H
-
- movdqa xmm4, xmm1
- movdqa xmm0, xmm2
- paddd xmm1, xmm5 ; xmm1=tmp10L
- paddd xmm2, xmm3 ; xmm2=tmp10H
- psubd xmm4, xmm5 ; xmm4=tmp12L
- psubd xmm0, xmm3 ; xmm0=tmp12H
-
- ; -- Final output stage
-
- movdqa xmm5, xmm1
- movdqa xmm3, xmm2
- paddd xmm1, xmm6 ; xmm1=data0L
- paddd xmm2, xmm7 ; xmm2=data0H
- psubd xmm5, xmm6 ; xmm5=data3L
- psubd xmm3, xmm7 ; xmm3=data3H
-
- movdqa xmm6, [rel PD_DESCALE_P1_4] ; xmm6=[rel PD_DESCALE_P1_4]
-
- paddd xmm1, xmm6
- paddd xmm2, xmm6
- psrad xmm1, DESCALE_P1_4
- psrad xmm2, DESCALE_P1_4
- paddd xmm5, xmm6
- paddd xmm3, xmm6
- psrad xmm5, DESCALE_P1_4
- psrad xmm3, DESCALE_P1_4
-
- packssdw xmm1, xmm2 ; xmm1=data0=(00 01 02 03 04 05 06 07)
- packssdw xmm5, xmm3 ; xmm5=data3=(30 31 32 33 34 35 36 37)
-
- movdqa xmm7, XMMWORD [wk(0)] ; xmm7=tmp0L
- movdqa xmm6, XMMWORD [wk(1)] ; xmm6=tmp0H
-
- movdqa xmm2, xmm4
- movdqa xmm3, xmm0
- paddd xmm4, xmm7 ; xmm4=data1L
- paddd xmm0, xmm6 ; xmm0=data1H
- psubd xmm2, xmm7 ; xmm2=data2L
- psubd xmm3, xmm6 ; xmm3=data2H
-
- movdqa xmm7, [rel PD_DESCALE_P1_4] ; xmm7=[rel PD_DESCALE_P1_4]
-
- paddd xmm4, xmm7
- paddd xmm0, xmm7
- psrad xmm4, DESCALE_P1_4
- psrad xmm0, DESCALE_P1_4
- paddd xmm2, xmm7
- paddd xmm3, xmm7
- psrad xmm2, DESCALE_P1_4
- psrad xmm3, DESCALE_P1_4
-
- packssdw xmm4, xmm0 ; xmm4=data1=(10 11 12 13 14 15 16 17)
- packssdw xmm2, xmm3 ; xmm2=data2=(20 21 22 23 24 25 26 27)
-
- movdqa xmm6, xmm1 ; transpose coefficients(phase 1)
- punpcklwd xmm1, xmm4 ; xmm1=(00 10 01 11 02 12 03 13)
- punpckhwd xmm6, xmm4 ; xmm6=(04 14 05 15 06 16 07 17)
- movdqa xmm7, xmm2 ; transpose coefficients(phase 1)
- punpcklwd xmm2, xmm5 ; xmm2=(20 30 21 31 22 32 23 33)
- punpckhwd xmm7, xmm5 ; xmm7=(24 34 25 35 26 36 27 37)
-
- movdqa xmm0, xmm1 ; transpose coefficients(phase 2)
- punpckldq xmm1, xmm2 ; xmm1=[col0 col1]=(00 10 20 30 01 11 21 31)
- punpckhdq xmm0, xmm2 ; xmm0=[col2 col3]=(02 12 22 32 03 13 23 33)
- movdqa xmm3, xmm6 ; transpose coefficients(phase 2)
- punpckldq xmm6, xmm7 ; xmm6=[col4 col5]=(04 14 24 34 05 15 25 35)
- punpckhdq xmm3, xmm7 ; xmm3=[col6 col7]=(06 16 26 36 07 17 27 37)
-.column_end:
-
- ; -- Prefetch the next coefficient block
-
- prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 0*32]
- prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 1*32]
- prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 2*32]
- prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 3*32]
-
- ; ---- Pass 2: process rows, store into output array.
-
- mov rax, [original_rbp]
- mov rdi, r12 ; (JSAMPROW *)
- mov eax, r13d
-
- ; -- Even part
-
- pxor xmm4, xmm4
- punpcklwd xmm4, xmm1 ; xmm4=tmp0
- psrad xmm4, (16-CONST_BITS-1) ; psrad xmm4,16 & pslld xmm4,CONST_BITS+1
-
- ; -- Odd part
-
- punpckhwd xmm1, xmm0
- punpckhwd xmm6, xmm3
- movdqa xmm5, xmm1
- movdqa xmm2, xmm6
- pmaddwd xmm1, [rel PW_F256_F089] ; xmm1=(tmp2)
- pmaddwd xmm6, [rel PW_MF060_MF050] ; xmm6=(tmp2)
- pmaddwd xmm5, [rel PW_F106_MF217] ; xmm5=(tmp0)
- pmaddwd xmm2, [rel PW_F145_MF021] ; xmm2=(tmp0)
-
- paddd xmm6, xmm1 ; xmm6=tmp2
- paddd xmm2, xmm5 ; xmm2=tmp0
-
- ; -- Even part
-
- punpcklwd xmm0, xmm3
- pmaddwd xmm0, [rel PW_F184_MF076] ; xmm0=tmp2
-
- movdqa xmm7, xmm4
- paddd xmm4, xmm0 ; xmm4=tmp10
- psubd xmm7, xmm0 ; xmm7=tmp12
-
- ; -- Final output stage
-
- movdqa xmm1, [rel PD_DESCALE_P2_4] ; xmm1=[rel PD_DESCALE_P2_4]
-
- movdqa xmm5, xmm4
- movdqa xmm3, xmm7
- paddd xmm4, xmm6 ; xmm4=data0=(00 10 20 30)
- paddd xmm7, xmm2 ; xmm7=data1=(01 11 21 31)
- psubd xmm5, xmm6 ; xmm5=data3=(03 13 23 33)
- psubd xmm3, xmm2 ; xmm3=data2=(02 12 22 32)
-
- paddd xmm4, xmm1
- paddd xmm7, xmm1
- psrad xmm4, DESCALE_P2_4
- psrad xmm7, DESCALE_P2_4
- paddd xmm5, xmm1
- paddd xmm3, xmm1
- psrad xmm5, DESCALE_P2_4
- psrad xmm3, DESCALE_P2_4
-
- packssdw xmm4, xmm3 ; xmm4=(00 10 20 30 02 12 22 32)
- packssdw xmm7, xmm5 ; xmm7=(01 11 21 31 03 13 23 33)
-
- movdqa xmm0, xmm4 ; transpose coefficients(phase 1)
- punpcklwd xmm4, xmm7 ; xmm4=(00 01 10 11 20 21 30 31)
- punpckhwd xmm0, xmm7 ; xmm0=(02 03 12 13 22 23 32 33)
-
- movdqa xmm6, xmm4 ; transpose coefficients(phase 2)
- punpckldq xmm4, xmm0 ; xmm4=(00 01 02 03 10 11 12 13)
- punpckhdq xmm6, xmm0 ; xmm6=(20 21 22 23 30 31 32 33)
-
- packsswb xmm4, xmm6 ; xmm4=(00 01 02 03 10 11 12 13 20 ..)
- paddb xmm4, [rel PB_CENTERJSAMP]
-
- pshufd xmm2, xmm4, 0x39 ; xmm2=(10 11 12 13 20 21 22 23 30 ..)
- pshufd xmm1, xmm4, 0x4E ; xmm1=(20 21 22 23 30 31 32 33 00 ..)
- pshufd xmm3, xmm4, 0x93 ; xmm3=(30 31 32 33 00 01 02 03 10 ..)
-
- mov rdxp, JSAMPROW [rdi+0*SIZEOF_JSAMPROW]
- mov rsip, JSAMPROW [rdi+1*SIZEOF_JSAMPROW]
- movd XMM_DWORD [rdx+rax*SIZEOF_JSAMPLE], xmm4
- movd XMM_DWORD [rsi+rax*SIZEOF_JSAMPLE], xmm2
- mov rdxp, JSAMPROW [rdi+2*SIZEOF_JSAMPROW]
- mov rsip, JSAMPROW [rdi+3*SIZEOF_JSAMPROW]
- movd XMM_DWORD [rdx+rax*SIZEOF_JSAMPLE], xmm1
- movd XMM_DWORD [rsi+rax*SIZEOF_JSAMPLE], xmm3
-
- uncollect_args 4
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
- pop rbp
- ret
-
-; --------------------------------------------------------------------------
-;
-; Perform dequantization and inverse DCT on one block of coefficients,
-; producing a reduced-size 2x2 output block.
-;
-; GLOBAL(void)
-; jsimd_idct_2x2_sse2(void *dct_table, JCOEFPTR coef_block,
-; JSAMPARRAY output_buf, JDIMENSION output_col)
-;
-
-; r10 = void *dct_table
-; r11 = JCOEFPTR coef_block
-; r12 = JSAMPARRAY output_buf
-; r13d = JDIMENSION output_col
-
- align 32
- GLOBAL_FUNCTION(jsimd_idct_2x2_sse2)
-
-EXTN(jsimd_idct_2x2_sse2):
- push rbp
- mov rax, rsp
- mov rbp, rsp
- collect_args 4
- push rbx
-
- ; ---- Pass 1: process columns from input.
-
- mov rdx, r10 ; quantptr
- mov rsi, r11 ; inptr
-
- ; | input: | result: |
- ; | 00 01 ** 03 ** 05 ** 07 | |
- ; | 10 11 ** 13 ** 15 ** 17 | |
- ; | ** ** ** ** ** ** ** ** | |
- ; | 30 31 ** 33 ** 35 ** 37 | A0 A1 A3 A5 A7 |
- ; | ** ** ** ** ** ** ** ** | B0 B1 B3 B5 B7 |
- ; | 50 51 ** 53 ** 55 ** 57 | |
- ; | ** ** ** ** ** ** ** ** | |
- ; | 70 71 ** 73 ** 75 ** 77 | |
-
- ; -- Odd part
-
- movdqa xmm0, XMMWORD [XMMBLOCK(1,0,rsi,SIZEOF_JCOEF)]
- movdqa xmm1, XMMWORD [XMMBLOCK(3,0,rsi,SIZEOF_JCOEF)]
- pmullw xmm0, XMMWORD [XMMBLOCK(1,0,rdx,SIZEOF_ISLOW_MULT_TYPE)]
- pmullw xmm1, XMMWORD [XMMBLOCK(3,0,rdx,SIZEOF_ISLOW_MULT_TYPE)]
- movdqa xmm2, XMMWORD [XMMBLOCK(5,0,rsi,SIZEOF_JCOEF)]
- movdqa xmm3, XMMWORD [XMMBLOCK(7,0,rsi,SIZEOF_JCOEF)]
- pmullw xmm2, XMMWORD [XMMBLOCK(5,0,rdx,SIZEOF_ISLOW_MULT_TYPE)]
- pmullw xmm3, XMMWORD [XMMBLOCK(7,0,rdx,SIZEOF_ISLOW_MULT_TYPE)]
-
- ; xmm0=(10 11 ** 13 ** 15 ** 17), xmm1=(30 31 ** 33 ** 35 ** 37)
- ; xmm2=(50 51 ** 53 ** 55 ** 57), xmm3=(70 71 ** 73 ** 75 ** 77)
-
- pcmpeqd xmm7, xmm7
- pslld xmm7, WORD_BIT ; xmm7={0x0000 0xFFFF 0x0000 0xFFFF ..}
-
- movdqa xmm4, xmm0 ; xmm4=(10 11 ** 13 ** 15 ** 17)
- movdqa xmm5, xmm2 ; xmm5=(50 51 ** 53 ** 55 ** 57)
- punpcklwd xmm4, xmm1 ; xmm4=(10 30 11 31 ** ** 13 33)
- punpcklwd xmm5, xmm3 ; xmm5=(50 70 51 71 ** ** 53 73)
- pmaddwd xmm4, [rel PW_F362_MF127]
- pmaddwd xmm5, [rel PW_F085_MF072]
-
- psrld xmm0, WORD_BIT ; xmm0=(11 -- 13 -- 15 -- 17 --)
- pand xmm1, xmm7 ; xmm1=(-- 31 -- 33 -- 35 -- 37)
- psrld xmm2, WORD_BIT ; xmm2=(51 -- 53 -- 55 -- 57 --)
- pand xmm3, xmm7 ; xmm3=(-- 71 -- 73 -- 75 -- 77)
- por xmm0, xmm1 ; xmm0=(11 31 13 33 15 35 17 37)
- por xmm2, xmm3 ; xmm2=(51 71 53 73 55 75 57 77)
- pmaddwd xmm0, [rel PW_F362_MF127]
- pmaddwd xmm2, [rel PW_F085_MF072]
-
- paddd xmm4, xmm5 ; xmm4=tmp0[col0 col1 **** col3]
- paddd xmm0, xmm2 ; xmm0=tmp0[col1 col3 col5 col7]
-
- ; -- Even part
-
- movdqa xmm6, XMMWORD [XMMBLOCK(0,0,rsi,SIZEOF_JCOEF)]
- pmullw xmm6, XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_ISLOW_MULT_TYPE)]
-
- ; xmm6=(00 01 ** 03 ** 05 ** 07)
-
- movdqa xmm1, xmm6 ; xmm1=(00 01 ** 03 ** 05 ** 07)
- pslld xmm6, WORD_BIT ; xmm6=(-- 00 -- ** -- ** -- **)
- pand xmm1, xmm7 ; xmm1=(-- 01 -- 03 -- 05 -- 07)
- psrad xmm6, (WORD_BIT-CONST_BITS-2) ; xmm6=tmp10[col0 **** **** ****]
- psrad xmm1, (WORD_BIT-CONST_BITS-2) ; xmm1=tmp10[col1 col3 col5 col7]
-
- ; -- Final output stage
-
- movdqa xmm3, xmm6
- movdqa xmm5, xmm1
- paddd xmm6, xmm4 ; xmm6=data0[col0 **** **** ****]=(A0 ** ** **)
- paddd xmm1, xmm0 ; xmm1=data0[col1 col3 col5 col7]=(A1 A3 A5 A7)
- psubd xmm3, xmm4 ; xmm3=data1[col0 **** **** ****]=(B0 ** ** **)
- psubd xmm5, xmm0 ; xmm5=data1[col1 col3 col5 col7]=(B1 B3 B5 B7)
-
- movdqa xmm2, [rel PD_DESCALE_P1_2] ; xmm2=[rel PD_DESCALE_P1_2]
-
- punpckldq xmm6, xmm3 ; xmm6=(A0 B0 ** **)
-
- movdqa xmm7, xmm1
- punpcklqdq xmm1, xmm5 ; xmm1=(A1 A3 B1 B3)
- punpckhqdq xmm7, xmm5 ; xmm7=(A5 A7 B5 B7)
-
- paddd xmm6, xmm2
- psrad xmm6, DESCALE_P1_2
-
- paddd xmm1, xmm2
- paddd xmm7, xmm2
- psrad xmm1, DESCALE_P1_2
- psrad xmm7, DESCALE_P1_2
-
- ; -- Prefetch the next coefficient block
-
- prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 0*32]
- prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 1*32]
- prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 2*32]
- prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 3*32]
-
- ; ---- Pass 2: process rows, store into output array.
-
- mov rdi, r12 ; (JSAMPROW *)
- mov eax, r13d
-
- ; | input:| result:|
- ; | A0 B0 | |
- ; | A1 B1 | C0 C1 |
- ; | A3 B3 | D0 D1 |
- ; | A5 B5 | |
- ; | A7 B7 | |
-
- ; -- Odd part
-
- packssdw xmm1, xmm1 ; xmm1=(A1 A3 B1 B3 A1 A3 B1 B3)
- packssdw xmm7, xmm7 ; xmm7=(A5 A7 B5 B7 A5 A7 B5 B7)
- pmaddwd xmm1, [rel PW_F362_MF127]
- pmaddwd xmm7, [rel PW_F085_MF072]
-
- paddd xmm1, xmm7 ; xmm1=tmp0[row0 row1 row0 row1]
-
- ; -- Even part
-
- pslld xmm6, (CONST_BITS+2) ; xmm6=tmp10[row0 row1 **** ****]
-
- ; -- Final output stage
-
- movdqa xmm4, xmm6
- paddd xmm6, xmm1 ; xmm6=data0[row0 row1 **** ****]=(C0 C1 ** **)
- psubd xmm4, xmm1 ; xmm4=data1[row0 row1 **** ****]=(D0 D1 ** **)
-
- punpckldq xmm6, xmm4 ; xmm6=(C0 D0 C1 D1)
-
- paddd xmm6, [rel PD_DESCALE_P2_2]
- psrad xmm6, DESCALE_P2_2
-
- packssdw xmm6, xmm6 ; xmm6=(C0 D0 C1 D1 C0 D0 C1 D1)
- packsswb xmm6, xmm6 ; xmm6=(C0 D0 C1 D1 C0 D0 C1 D1 ..)
- paddb xmm6, [rel PB_CENTERJSAMP]
-
- pextrw ebx, xmm6, 0x00 ; ebx=(C0 D0 -- --)
- pextrw ecx, xmm6, 0x01 ; ecx=(C1 D1 -- --)
-
- mov rdxp, JSAMPROW [rdi+0*SIZEOF_JSAMPROW]
- mov rsip, JSAMPROW [rdi+1*SIZEOF_JSAMPROW]
- mov word [rdx+rax*SIZEOF_JSAMPLE], bx
- mov word [rsi+rax*SIZEOF_JSAMPLE], cx
-
- pop rbx
- uncollect_args 4
- pop rbp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jquantf-sse2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jquantf-sse2.asm
deleted file mode 100644
index ab2e3954f6..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jquantf-sse2.asm
+++ /dev/null
@@ -1,155 +0,0 @@
-;
-; jquantf.asm - sample data conversion and quantization (64-bit SSE & SSE2)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
-; Copyright (C) 2018, Matthias Räncker.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jsimdext.inc"
-%include "jdct.inc"
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 64
-;
-; Load data into workspace, applying unsigned->signed conversion
-;
-; GLOBAL(void)
-; jsimd_convsamp_float_sse2(JSAMPARRAY sample_data, JDIMENSION start_col,
-; FAST_FLOAT *workspace);
-;
-
-; r10 = JSAMPARRAY sample_data
-; r11d = JDIMENSION start_col
-; r12 = FAST_FLOAT *workspace
-
- align 32
- GLOBAL_FUNCTION(jsimd_convsamp_float_sse2)
-
-EXTN(jsimd_convsamp_float_sse2):
- push rbp
- mov rax, rsp
- mov rbp, rsp
- collect_args 3
- push rbx
-
- pcmpeqw xmm7, xmm7
- psllw xmm7, 7
- packsswb xmm7, xmm7 ; xmm7 = PB_CENTERJSAMPLE (0x808080..)
-
- mov rsi, r10
- mov eax, r11d
- mov rdi, r12
- mov rcx, DCTSIZE/2
-.convloop:
- mov rbxp, JSAMPROW [rsi+0*SIZEOF_JSAMPROW] ; (JSAMPLE *)
- mov rdxp, JSAMPROW [rsi+1*SIZEOF_JSAMPROW] ; (JSAMPLE *)
-
- movq xmm0, XMM_MMWORD [rbx+rax*SIZEOF_JSAMPLE]
- movq xmm1, XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE]
-
- psubb xmm0, xmm7 ; xmm0=(01234567)
- psubb xmm1, xmm7 ; xmm1=(89ABCDEF)
-
- punpcklbw xmm0, xmm0 ; xmm0=(*0*1*2*3*4*5*6*7)
- punpcklbw xmm1, xmm1 ; xmm1=(*8*9*A*B*C*D*E*F)
-
- punpcklwd xmm2, xmm0 ; xmm2=(***0***1***2***3)
- punpckhwd xmm0, xmm0 ; xmm0=(***4***5***6***7)
- punpcklwd xmm3, xmm1 ; xmm3=(***8***9***A***B)
- punpckhwd xmm1, xmm1 ; xmm1=(***C***D***E***F)
-
- psrad xmm2, (DWORD_BIT-BYTE_BIT) ; xmm2=(0123)
- psrad xmm0, (DWORD_BIT-BYTE_BIT) ; xmm0=(4567)
- cvtdq2ps xmm2, xmm2 ; xmm2=(0123)
- cvtdq2ps xmm0, xmm0 ; xmm0=(4567)
- psrad xmm3, (DWORD_BIT-BYTE_BIT) ; xmm3=(89AB)
- psrad xmm1, (DWORD_BIT-BYTE_BIT) ; xmm1=(CDEF)
- cvtdq2ps xmm3, xmm3 ; xmm3=(89AB)
- cvtdq2ps xmm1, xmm1 ; xmm1=(CDEF)
-
- movaps XMMWORD [XMMBLOCK(0,0,rdi,SIZEOF_FAST_FLOAT)], xmm2
- movaps XMMWORD [XMMBLOCK(0,1,rdi,SIZEOF_FAST_FLOAT)], xmm0
- movaps XMMWORD [XMMBLOCK(1,0,rdi,SIZEOF_FAST_FLOAT)], xmm3
- movaps XMMWORD [XMMBLOCK(1,1,rdi,SIZEOF_FAST_FLOAT)], xmm1
-
- add rsi, byte 2*SIZEOF_JSAMPROW
- add rdi, byte 2*DCTSIZE*SIZEOF_FAST_FLOAT
- dec rcx
- jnz short .convloop
-
- pop rbx
- uncollect_args 3
- pop rbp
- ret
-
-; --------------------------------------------------------------------------
-;
-; Quantize/descale the coefficients, and store into coef_block
-;
-; GLOBAL(void)
-; jsimd_quantize_float_sse2(JCOEFPTR coef_block, FAST_FLOAT *divisors,
-; FAST_FLOAT *workspace);
-;
-
-; r10 = JCOEFPTR coef_block
-; r11 = FAST_FLOAT *divisors
-; r12 = FAST_FLOAT *workspace
-
- align 32
- GLOBAL_FUNCTION(jsimd_quantize_float_sse2)
-
-EXTN(jsimd_quantize_float_sse2):
- push rbp
- mov rax, rsp
- mov rbp, rsp
- collect_args 3
-
- mov rsi, r12
- mov rdx, r11
- mov rdi, r10
- mov rax, DCTSIZE2/16
-.quantloop:
- movaps xmm0, XMMWORD [XMMBLOCK(0,0,rsi,SIZEOF_FAST_FLOAT)]
- movaps xmm1, XMMWORD [XMMBLOCK(0,1,rsi,SIZEOF_FAST_FLOAT)]
- mulps xmm0, XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_FAST_FLOAT)]
- mulps xmm1, XMMWORD [XMMBLOCK(0,1,rdx,SIZEOF_FAST_FLOAT)]
- movaps xmm2, XMMWORD [XMMBLOCK(1,0,rsi,SIZEOF_FAST_FLOAT)]
- movaps xmm3, XMMWORD [XMMBLOCK(1,1,rsi,SIZEOF_FAST_FLOAT)]
- mulps xmm2, XMMWORD [XMMBLOCK(1,0,rdx,SIZEOF_FAST_FLOAT)]
- mulps xmm3, XMMWORD [XMMBLOCK(1,1,rdx,SIZEOF_FAST_FLOAT)]
-
- cvtps2dq xmm0, xmm0
- cvtps2dq xmm1, xmm1
- cvtps2dq xmm2, xmm2
- cvtps2dq xmm3, xmm3
-
- packssdw xmm0, xmm1
- packssdw xmm2, xmm3
-
- movdqa XMMWORD [XMMBLOCK(0,0,rdi,SIZEOF_JCOEF)], xmm0
- movdqa XMMWORD [XMMBLOCK(1,0,rdi,SIZEOF_JCOEF)], xmm2
-
- add rsi, byte 16*SIZEOF_FAST_FLOAT
- add rdx, byte 16*SIZEOF_FAST_FLOAT
- add rdi, byte 16*SIZEOF_JCOEF
- dec rax
- jnz short .quantloop
-
- uncollect_args 3
- pop rbp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jquanti-avx2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jquanti-avx2.asm
deleted file mode 100644
index 70fe81139c..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jquanti-avx2.asm
+++ /dev/null
@@ -1,163 +0,0 @@
-;
-; jquanti.asm - sample data conversion and quantization (64-bit AVX2)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, 2016, 2018, D. R. Commander.
-; Copyright (C) 2016, Matthieu Darbois.
-; Copyright (C) 2018, Matthias Räncker.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jsimdext.inc"
-%include "jdct.inc"
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 64
-;
-; Load data into workspace, applying unsigned->signed conversion
-;
-; GLOBAL(void)
-; jsimd_convsamp_avx2(JSAMPARRAY sample_data, JDIMENSION start_col,
-; DCTELEM *workspace);
-;
-
-; r10 = JSAMPARRAY sample_data
-; r11d = JDIMENSION start_col
-; r12 = DCTELEM *workspace
-
- align 32
- GLOBAL_FUNCTION(jsimd_convsamp_avx2)
-
-EXTN(jsimd_convsamp_avx2):
- push rbp
- mov rax, rsp
- mov rbp, rsp
- collect_args 3
-
- mov eax, r11d
-
- mov rsip, JSAMPROW [r10+0*SIZEOF_JSAMPROW] ; (JSAMPLE *)
- mov rdip, JSAMPROW [r10+1*SIZEOF_JSAMPROW] ; (JSAMPLE *)
- movq xmm0, XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE]
- pinsrq xmm0, XMM_MMWORD [rdi+rax*SIZEOF_JSAMPLE], 1
-
- mov rsip, JSAMPROW [r10+2*SIZEOF_JSAMPROW] ; (JSAMPLE *)
- mov rdip, JSAMPROW [r10+3*SIZEOF_JSAMPROW] ; (JSAMPLE *)
- movq xmm1, XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE]
- pinsrq xmm1, XMM_MMWORD [rdi+rax*SIZEOF_JSAMPLE], 1
-
- mov rsip, JSAMPROW [r10+4*SIZEOF_JSAMPROW] ; (JSAMPLE *)
- mov rdip, JSAMPROW [r10+5*SIZEOF_JSAMPROW] ; (JSAMPLE *)
- movq xmm2, XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE]
- pinsrq xmm2, XMM_MMWORD [rdi+rax*SIZEOF_JSAMPLE], 1
-
- mov rsip, JSAMPROW [r10+6*SIZEOF_JSAMPROW] ; (JSAMPLE *)
- mov rdip, JSAMPROW [r10+7*SIZEOF_JSAMPROW] ; (JSAMPLE *)
- movq xmm3, XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE]
- pinsrq xmm3, XMM_MMWORD [rdi+rax*SIZEOF_JSAMPLE], 1
-
- vpmovzxbw ymm0, xmm0 ; ymm0=(00 01 02 03 04 05 06 07 10 11 12 13 14 15 16 17)
- vpmovzxbw ymm1, xmm1 ; ymm1=(20 21 22 23 24 25 26 27 30 31 32 33 34 35 36 37)
- vpmovzxbw ymm2, xmm2 ; ymm2=(40 41 42 43 44 45 46 47 50 51 52 53 54 55 56 57)
- vpmovzxbw ymm3, xmm3 ; ymm3=(60 61 62 63 64 65 66 67 70 71 72 73 74 75 76 77)
-
- vpcmpeqw ymm7, ymm7, ymm7
- vpsllw ymm7, ymm7, 7 ; ymm7={0xFF80 0xFF80 0xFF80 0xFF80 ..}
-
- vpaddw ymm0, ymm0, ymm7
- vpaddw ymm1, ymm1, ymm7
- vpaddw ymm2, ymm2, ymm7
- vpaddw ymm3, ymm3, ymm7
-
- vmovdqu YMMWORD [YMMBLOCK(0,0,r12,SIZEOF_DCTELEM)], ymm0
- vmovdqu YMMWORD [YMMBLOCK(2,0,r12,SIZEOF_DCTELEM)], ymm1
- vmovdqu YMMWORD [YMMBLOCK(4,0,r12,SIZEOF_DCTELEM)], ymm2
- vmovdqu YMMWORD [YMMBLOCK(6,0,r12,SIZEOF_DCTELEM)], ymm3
-
- vzeroupper
- uncollect_args 3
- pop rbp
- ret
-
-; --------------------------------------------------------------------------
-;
-; Quantize/descale the coefficients, and store into coef_block
-;
-; This implementation is based on an algorithm described in
-; "How to optimize for the Pentium family of microprocessors"
-; (http://www.agner.org/assem/).
-;
-; GLOBAL(void)
-; jsimd_quantize_avx2(JCOEFPTR coef_block, DCTELEM *divisors,
-; DCTELEM *workspace);
-;
-
-%define RECIPROCAL(m, n, b) \
- YMMBLOCK(DCTSIZE * 0 + (m), (n), (b), SIZEOF_DCTELEM)
-%define CORRECTION(m, n, b) \
- YMMBLOCK(DCTSIZE * 1 + (m), (n), (b), SIZEOF_DCTELEM)
-%define SCALE(m, n, b) \
- YMMBLOCK(DCTSIZE * 2 + (m), (n), (b), SIZEOF_DCTELEM)
-
-; r10 = JCOEFPTR coef_block
-; r11 = DCTELEM *divisors
-; r12 = DCTELEM *workspace
-
- align 32
- GLOBAL_FUNCTION(jsimd_quantize_avx2)
-
-EXTN(jsimd_quantize_avx2):
- push rbp
- mov rax, rsp
- mov rbp, rsp
- collect_args 3
-
- vmovdqu ymm4, [YMMBLOCK(0,0,r12,SIZEOF_DCTELEM)]
- vmovdqu ymm5, [YMMBLOCK(2,0,r12,SIZEOF_DCTELEM)]
- vmovdqu ymm6, [YMMBLOCK(4,0,r12,SIZEOF_DCTELEM)]
- vmovdqu ymm7, [YMMBLOCK(6,0,r12,SIZEOF_DCTELEM)]
- vpabsw ymm0, ymm4
- vpabsw ymm1, ymm5
- vpabsw ymm2, ymm6
- vpabsw ymm3, ymm7
-
- vpaddw ymm0, YMMWORD [CORRECTION(0,0,r11)] ; correction + roundfactor
- vpaddw ymm1, YMMWORD [CORRECTION(2,0,r11)]
- vpaddw ymm2, YMMWORD [CORRECTION(4,0,r11)]
- vpaddw ymm3, YMMWORD [CORRECTION(6,0,r11)]
- vpmulhuw ymm0, YMMWORD [RECIPROCAL(0,0,r11)] ; reciprocal
- vpmulhuw ymm1, YMMWORD [RECIPROCAL(2,0,r11)]
- vpmulhuw ymm2, YMMWORD [RECIPROCAL(4,0,r11)]
- vpmulhuw ymm3, YMMWORD [RECIPROCAL(6,0,r11)]
- vpmulhuw ymm0, YMMWORD [SCALE(0,0,r11)] ; scale
- vpmulhuw ymm1, YMMWORD [SCALE(2,0,r11)]
- vpmulhuw ymm2, YMMWORD [SCALE(4,0,r11)]
- vpmulhuw ymm3, YMMWORD [SCALE(6,0,r11)]
-
- vpsignw ymm0, ymm0, ymm4
- vpsignw ymm1, ymm1, ymm5
- vpsignw ymm2, ymm2, ymm6
- vpsignw ymm3, ymm3, ymm7
-
- vmovdqu [YMMBLOCK(0,0,r10,SIZEOF_DCTELEM)], ymm0
- vmovdqu [YMMBLOCK(2,0,r10,SIZEOF_DCTELEM)], ymm1
- vmovdqu [YMMBLOCK(4,0,r10,SIZEOF_DCTELEM)], ymm2
- vmovdqu [YMMBLOCK(6,0,r10,SIZEOF_DCTELEM)], ymm3
-
- vzeroupper
- uncollect_args 3
- pop rbp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jquanti-sse2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jquanti-sse2.asm
deleted file mode 100644
index 3ee442027a..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jquanti-sse2.asm
+++ /dev/null
@@ -1,188 +0,0 @@
-;
-; jquanti.asm - sample data conversion and quantization (64-bit SSE2)
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
-; Copyright (C) 2018, Matthias Räncker.
-;
-; Based on the x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jsimdext.inc"
-%include "jdct.inc"
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 64
-;
-; Load data into workspace, applying unsigned->signed conversion
-;
-; GLOBAL(void)
-; jsimd_convsamp_sse2(JSAMPARRAY sample_data, JDIMENSION start_col,
-; DCTELEM *workspace);
-;
-
-; r10 = JSAMPARRAY sample_data
-; r11d = JDIMENSION start_col
-; r12 = DCTELEM *workspace
-
- align 32
- GLOBAL_FUNCTION(jsimd_convsamp_sse2)
-
-EXTN(jsimd_convsamp_sse2):
- push rbp
- mov rax, rsp
- mov rbp, rsp
- collect_args 3
- push rbx
-
- pxor xmm6, xmm6 ; xmm6=(all 0's)
- pcmpeqw xmm7, xmm7
- psllw xmm7, 7 ; xmm7={0xFF80 0xFF80 0xFF80 0xFF80 ..}
-
- mov rsi, r10
- mov eax, r11d
- mov rdi, r12
- mov rcx, DCTSIZE/4
-.convloop:
- mov rbxp, JSAMPROW [rsi+0*SIZEOF_JSAMPROW] ; (JSAMPLE *)
- mov rdxp, JSAMPROW [rsi+1*SIZEOF_JSAMPROW] ; (JSAMPLE *)
-
- movq xmm0, XMM_MMWORD [rbx+rax*SIZEOF_JSAMPLE] ; xmm0=(01234567)
- movq xmm1, XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE] ; xmm1=(89ABCDEF)
-
- mov rbxp, JSAMPROW [rsi+2*SIZEOF_JSAMPROW] ; (JSAMPLE *)
- mov rdxp, JSAMPROW [rsi+3*SIZEOF_JSAMPROW] ; (JSAMPLE *)
-
- movq xmm2, XMM_MMWORD [rbx+rax*SIZEOF_JSAMPLE] ; xmm2=(GHIJKLMN)
- movq xmm3, XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE] ; xmm3=(OPQRSTUV)
-
- punpcklbw xmm0, xmm6 ; xmm0=(01234567)
- punpcklbw xmm1, xmm6 ; xmm1=(89ABCDEF)
- paddw xmm0, xmm7
- paddw xmm1, xmm7
- punpcklbw xmm2, xmm6 ; xmm2=(GHIJKLMN)
- punpcklbw xmm3, xmm6 ; xmm3=(OPQRSTUV)
- paddw xmm2, xmm7
- paddw xmm3, xmm7
-
- movdqa XMMWORD [XMMBLOCK(0,0,rdi,SIZEOF_DCTELEM)], xmm0
- movdqa XMMWORD [XMMBLOCK(1,0,rdi,SIZEOF_DCTELEM)], xmm1
- movdqa XMMWORD [XMMBLOCK(2,0,rdi,SIZEOF_DCTELEM)], xmm2
- movdqa XMMWORD [XMMBLOCK(3,0,rdi,SIZEOF_DCTELEM)], xmm3
-
- add rsi, byte 4*SIZEOF_JSAMPROW
- add rdi, byte 4*DCTSIZE*SIZEOF_DCTELEM
- dec rcx
- jnz short .convloop
-
- pop rbx
- uncollect_args 3
- pop rbp
- ret
-
-; --------------------------------------------------------------------------
-;
-; Quantize/descale the coefficients, and store into coef_block
-;
-; This implementation is based on an algorithm described in
-; "How to optimize for the Pentium family of microprocessors"
-; (http://www.agner.org/assem/).
-;
-; GLOBAL(void)
-; jsimd_quantize_sse2(JCOEFPTR coef_block, DCTELEM *divisors,
-; DCTELEM *workspace);
-;
-
-%define RECIPROCAL(m, n, b) \
- XMMBLOCK(DCTSIZE * 0 + (m), (n), (b), SIZEOF_DCTELEM)
-%define CORRECTION(m, n, b) \
- XMMBLOCK(DCTSIZE * 1 + (m), (n), (b), SIZEOF_DCTELEM)
-%define SCALE(m, n, b) \
- XMMBLOCK(DCTSIZE * 2 + (m), (n), (b), SIZEOF_DCTELEM)
-
-; r10 = JCOEFPTR coef_block
-; r11 = DCTELEM *divisors
-; r12 = DCTELEM *workspace
-
- align 32
- GLOBAL_FUNCTION(jsimd_quantize_sse2)
-
-EXTN(jsimd_quantize_sse2):
- push rbp
- mov rax, rsp
- mov rbp, rsp
- collect_args 3
-
- mov rsi, r12
- mov rdx, r11
- mov rdi, r10
- mov rax, DCTSIZE2/32
-.quantloop:
- movdqa xmm4, XMMWORD [XMMBLOCK(0,0,rsi,SIZEOF_DCTELEM)]
- movdqa xmm5, XMMWORD [XMMBLOCK(1,0,rsi,SIZEOF_DCTELEM)]
- movdqa xmm6, XMMWORD [XMMBLOCK(2,0,rsi,SIZEOF_DCTELEM)]
- movdqa xmm7, XMMWORD [XMMBLOCK(3,0,rsi,SIZEOF_DCTELEM)]
- movdqa xmm0, xmm4
- movdqa xmm1, xmm5
- movdqa xmm2, xmm6
- movdqa xmm3, xmm7
- psraw xmm4, (WORD_BIT-1)
- psraw xmm5, (WORD_BIT-1)
- psraw xmm6, (WORD_BIT-1)
- psraw xmm7, (WORD_BIT-1)
- pxor xmm0, xmm4
- pxor xmm1, xmm5
- pxor xmm2, xmm6
- pxor xmm3, xmm7
- psubw xmm0, xmm4 ; if (xmm0 < 0) xmm0 = -xmm0;
- psubw xmm1, xmm5 ; if (xmm1 < 0) xmm1 = -xmm1;
- psubw xmm2, xmm6 ; if (xmm2 < 0) xmm2 = -xmm2;
- psubw xmm3, xmm7 ; if (xmm3 < 0) xmm3 = -xmm3;
-
- paddw xmm0, XMMWORD [CORRECTION(0,0,rdx)] ; correction + roundfactor
- paddw xmm1, XMMWORD [CORRECTION(1,0,rdx)]
- paddw xmm2, XMMWORD [CORRECTION(2,0,rdx)]
- paddw xmm3, XMMWORD [CORRECTION(3,0,rdx)]
- pmulhuw xmm0, XMMWORD [RECIPROCAL(0,0,rdx)] ; reciprocal
- pmulhuw xmm1, XMMWORD [RECIPROCAL(1,0,rdx)]
- pmulhuw xmm2, XMMWORD [RECIPROCAL(2,0,rdx)]
- pmulhuw xmm3, XMMWORD [RECIPROCAL(3,0,rdx)]
- pmulhuw xmm0, XMMWORD [SCALE(0,0,rdx)] ; scale
- pmulhuw xmm1, XMMWORD [SCALE(1,0,rdx)]
- pmulhuw xmm2, XMMWORD [SCALE(2,0,rdx)]
- pmulhuw xmm3, XMMWORD [SCALE(3,0,rdx)]
-
- pxor xmm0, xmm4
- pxor xmm1, xmm5
- pxor xmm2, xmm6
- pxor xmm3, xmm7
- psubw xmm0, xmm4
- psubw xmm1, xmm5
- psubw xmm2, xmm6
- psubw xmm3, xmm7
- movdqa XMMWORD [XMMBLOCK(0,0,rdi,SIZEOF_DCTELEM)], xmm0
- movdqa XMMWORD [XMMBLOCK(1,0,rdi,SIZEOF_DCTELEM)], xmm1
- movdqa XMMWORD [XMMBLOCK(2,0,rdi,SIZEOF_DCTELEM)], xmm2
- movdqa XMMWORD [XMMBLOCK(3,0,rdi,SIZEOF_DCTELEM)], xmm3
-
- add rsi, byte 32*SIZEOF_DCTELEM
- add rdx, byte 32*SIZEOF_DCTELEM
- add rdi, byte 32*SIZEOF_JCOEF
- dec rax
- jnz near .quantloop
-
- uncollect_args 3
- pop rbp
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jsimd.c b/contrib/libs/libjpeg-turbo/simd/x86_64/jsimd.c
deleted file mode 100644
index d51962f398..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jsimd.c
+++ /dev/null
@@ -1,1076 +0,0 @@
-/*
- * jsimd_x86_64.c
- *
- * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- * Copyright (C) 2009-2011, 2014, 2016, 2018, 2022, D. R. Commander.
- * Copyright (C) 2015-2016, 2018, Matthieu Darbois.
- *
- * Based on the x86 SIMD extension for IJG JPEG library,
- * Copyright (C) 1999-2006, MIYASAKA Masaru.
- * For conditions of distribution and use, see copyright notice in jsimdext.inc
- *
- * This file contains the interface between the "normal" portions
- * of the library and the SIMD implementations when running on a
- * 64-bit x86 architecture.
- */
-
-#define JPEG_INTERNALS
-#include "../../jinclude.h"
-#include "../../jpeglib.h"
-#include "../../jsimd.h"
-#include "../../jdct.h"
-#include "../../jsimddct.h"
-#include "../jsimd.h"
-#include "jconfigint.h"
-
-/*
- * In the PIC cases, we have no guarantee that constants will keep
- * their alignment. This macro allows us to verify it at runtime.
- */
-#define IS_ALIGNED(ptr, order) (((size_t)ptr & ((1 << order) - 1)) == 0)
-
-#define IS_ALIGNED_SSE(ptr) (IS_ALIGNED(ptr, 4)) /* 16 byte alignment */
-#define IS_ALIGNED_AVX(ptr) (IS_ALIGNED(ptr, 5)) /* 32 byte alignment */
-
-static unsigned int simd_support = (unsigned int)(~0);
-static unsigned int simd_huffman = 1;
-
-/*
- * Check what SIMD accelerations are supported.
- *
- * FIXME: This code is racy under a multi-threaded environment.
- */
-LOCAL(void)
-init_simd(void)
-{
-#ifndef NO_GETENV
- char env[2] = { 0 };
-#endif
-
- if (simd_support != ~0U)
- return;
-
- simd_support = jpeg_simd_cpu_support();
-
-#ifndef NO_GETENV
- /* Force different settings through environment variables */
- if (!GETENV_S(env, 2, "JSIMD_FORCESSE2") && !strcmp(env, "1"))
- simd_support &= JSIMD_SSE2;
- if (!GETENV_S(env, 2, "JSIMD_FORCEAVX2") && !strcmp(env, "1"))
- simd_support &= JSIMD_AVX2;
- if (!GETENV_S(env, 2, "JSIMD_FORCENONE") && !strcmp(env, "1"))
- simd_support = 0;
- if (!GETENV_S(env, 2, "JSIMD_NOHUFFENC") && !strcmp(env, "1"))
- simd_huffman = 0;
-#endif
-}
-
-GLOBAL(int)
-jsimd_can_rgb_ycc(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
- if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
- return 0;
-
- if ((simd_support & JSIMD_AVX2) &&
- IS_ALIGNED_AVX(jconst_rgb_ycc_convert_avx2))
- return 1;
- if ((simd_support & JSIMD_SSE2) &&
- IS_ALIGNED_SSE(jconst_rgb_ycc_convert_sse2))
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_rgb_gray(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
- if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
- return 0;
-
- if ((simd_support & JSIMD_AVX2) &&
- IS_ALIGNED_AVX(jconst_rgb_gray_convert_avx2))
- return 1;
- if ((simd_support & JSIMD_SSE2) &&
- IS_ALIGNED_SSE(jconst_rgb_gray_convert_sse2))
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_ycc_rgb(void)
-{
- init_simd();
-
-#ifndef WITH_SANITIZER
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
- if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
- return 0;
-
- if ((simd_support & JSIMD_AVX2) &&
- IS_ALIGNED_AVX(jconst_ycc_rgb_convert_avx2))
- return 1;
- if ((simd_support & JSIMD_SSE2) &&
- IS_ALIGNED_SSE(jconst_ycc_rgb_convert_sse2))
- return 1;
-#endif
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_ycc_rgb565(void)
-{
- return 0;
-}
-
-GLOBAL(void)
-jsimd_rgb_ycc_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPIMAGE output_buf, JDIMENSION output_row,
- int num_rows)
-{
- void (*avx2fct) (JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int);
- void (*sse2fct) (JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int);
-
- switch (cinfo->in_color_space) {
- case JCS_EXT_RGB:
- avx2fct = jsimd_extrgb_ycc_convert_avx2;
- sse2fct = jsimd_extrgb_ycc_convert_sse2;
- break;
- case JCS_EXT_RGBX:
- case JCS_EXT_RGBA:
- avx2fct = jsimd_extrgbx_ycc_convert_avx2;
- sse2fct = jsimd_extrgbx_ycc_convert_sse2;
- break;
- case JCS_EXT_BGR:
- avx2fct = jsimd_extbgr_ycc_convert_avx2;
- sse2fct = jsimd_extbgr_ycc_convert_sse2;
- break;
- case JCS_EXT_BGRX:
- case JCS_EXT_BGRA:
- avx2fct = jsimd_extbgrx_ycc_convert_avx2;
- sse2fct = jsimd_extbgrx_ycc_convert_sse2;
- break;
- case JCS_EXT_XBGR:
- case JCS_EXT_ABGR:
- avx2fct = jsimd_extxbgr_ycc_convert_avx2;
- sse2fct = jsimd_extxbgr_ycc_convert_sse2;
- break;
- case JCS_EXT_XRGB:
- case JCS_EXT_ARGB:
- avx2fct = jsimd_extxrgb_ycc_convert_avx2;
- sse2fct = jsimd_extxrgb_ycc_convert_sse2;
- break;
- default:
- avx2fct = jsimd_rgb_ycc_convert_avx2;
- sse2fct = jsimd_rgb_ycc_convert_sse2;
- break;
- }
-
- if (simd_support & JSIMD_AVX2)
- avx2fct(cinfo->image_width, input_buf, output_buf, output_row, num_rows);
- else
- sse2fct(cinfo->image_width, input_buf, output_buf, output_row, num_rows);
-}
-
-GLOBAL(void)
-jsimd_rgb_gray_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPIMAGE output_buf, JDIMENSION output_row,
- int num_rows)
-{
- void (*avx2fct) (JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int);
- void (*sse2fct) (JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int);
-
- switch (cinfo->in_color_space) {
- case JCS_EXT_RGB:
- avx2fct = jsimd_extrgb_gray_convert_avx2;
- sse2fct = jsimd_extrgb_gray_convert_sse2;
- break;
- case JCS_EXT_RGBX:
- case JCS_EXT_RGBA:
- avx2fct = jsimd_extrgbx_gray_convert_avx2;
- sse2fct = jsimd_extrgbx_gray_convert_sse2;
- break;
- case JCS_EXT_BGR:
- avx2fct = jsimd_extbgr_gray_convert_avx2;
- sse2fct = jsimd_extbgr_gray_convert_sse2;
- break;
- case JCS_EXT_BGRX:
- case JCS_EXT_BGRA:
- avx2fct = jsimd_extbgrx_gray_convert_avx2;
- sse2fct = jsimd_extbgrx_gray_convert_sse2;
- break;
- case JCS_EXT_XBGR:
- case JCS_EXT_ABGR:
- avx2fct = jsimd_extxbgr_gray_convert_avx2;
- sse2fct = jsimd_extxbgr_gray_convert_sse2;
- break;
- case JCS_EXT_XRGB:
- case JCS_EXT_ARGB:
- avx2fct = jsimd_extxrgb_gray_convert_avx2;
- sse2fct = jsimd_extxrgb_gray_convert_sse2;
- break;
- default:
- avx2fct = jsimd_rgb_gray_convert_avx2;
- sse2fct = jsimd_rgb_gray_convert_sse2;
- break;
- }
-
- if (simd_support & JSIMD_AVX2)
- avx2fct(cinfo->image_width, input_buf, output_buf, output_row, num_rows);
- else
- sse2fct(cinfo->image_width, input_buf, output_buf, output_row, num_rows);
-}
-
-GLOBAL(void)
-jsimd_ycc_rgb_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf,
- int num_rows)
-{
- void (*avx2fct) (JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY, int);
- void (*sse2fct) (JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY, int);
-
- switch (cinfo->out_color_space) {
- case JCS_EXT_RGB:
- avx2fct = jsimd_ycc_extrgb_convert_avx2;
- sse2fct = jsimd_ycc_extrgb_convert_sse2;
- break;
- case JCS_EXT_RGBX:
- case JCS_EXT_RGBA:
- avx2fct = jsimd_ycc_extrgbx_convert_avx2;
- sse2fct = jsimd_ycc_extrgbx_convert_sse2;
- break;
- case JCS_EXT_BGR:
- avx2fct = jsimd_ycc_extbgr_convert_avx2;
- sse2fct = jsimd_ycc_extbgr_convert_sse2;
- break;
- case JCS_EXT_BGRX:
- case JCS_EXT_BGRA:
- avx2fct = jsimd_ycc_extbgrx_convert_avx2;
- sse2fct = jsimd_ycc_extbgrx_convert_sse2;
- break;
- case JCS_EXT_XBGR:
- case JCS_EXT_ABGR:
- avx2fct = jsimd_ycc_extxbgr_convert_avx2;
- sse2fct = jsimd_ycc_extxbgr_convert_sse2;
- break;
- case JCS_EXT_XRGB:
- case JCS_EXT_ARGB:
- avx2fct = jsimd_ycc_extxrgb_convert_avx2;
- sse2fct = jsimd_ycc_extxrgb_convert_sse2;
- break;
- default:
- avx2fct = jsimd_ycc_rgb_convert_avx2;
- sse2fct = jsimd_ycc_rgb_convert_sse2;
- break;
- }
-
- if (simd_support & JSIMD_AVX2)
- avx2fct(cinfo->output_width, input_buf, input_row, output_buf, num_rows);
- else
- sse2fct(cinfo->output_width, input_buf, input_row, output_buf, num_rows);
-}
-
-GLOBAL(void)
-jsimd_ycc_rgb565_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf,
- int num_rows)
-{
-}
-
-GLOBAL(int)
-jsimd_can_h2v2_downsample(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
-
- if (simd_support & JSIMD_AVX2)
- return 1;
- if (simd_support & JSIMD_SSE2)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_h2v1_downsample(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
-
- if (simd_support & JSIMD_AVX2)
- return 1;
- if (simd_support & JSIMD_SSE2)
- return 1;
-
- return 0;
-}
-
-GLOBAL(void)
-jsimd_h2v2_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY output_data)
-{
- if (simd_support & JSIMD_AVX2)
- jsimd_h2v2_downsample_avx2(cinfo->image_width, cinfo->max_v_samp_factor,
- compptr->v_samp_factor,
- compptr->width_in_blocks, input_data,
- output_data);
- else
- jsimd_h2v2_downsample_sse2(cinfo->image_width, cinfo->max_v_samp_factor,
- compptr->v_samp_factor,
- compptr->width_in_blocks, input_data,
- output_data);
-}
-
-GLOBAL(void)
-jsimd_h2v1_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY output_data)
-{
- if (simd_support & JSIMD_AVX2)
- jsimd_h2v1_downsample_avx2(cinfo->image_width, cinfo->max_v_samp_factor,
- compptr->v_samp_factor,
- compptr->width_in_blocks, input_data,
- output_data);
- else
- jsimd_h2v1_downsample_sse2(cinfo->image_width, cinfo->max_v_samp_factor,
- compptr->v_samp_factor,
- compptr->width_in_blocks, input_data,
- output_data);
-}
-
-GLOBAL(int)
-jsimd_can_h2v2_upsample(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
-
- if (simd_support & JSIMD_AVX2)
- return 1;
- if (simd_support & JSIMD_SSE2)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_h2v1_upsample(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
-
- if (simd_support & JSIMD_AVX2)
- return 1;
- if (simd_support & JSIMD_SSE2)
- return 1;
-
- return 0;
-}
-
-GLOBAL(void)
-jsimd_h2v2_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
-{
- if (simd_support & JSIMD_AVX2)
- jsimd_h2v2_upsample_avx2(cinfo->max_v_samp_factor, cinfo->output_width,
- input_data, output_data_ptr);
- else
- jsimd_h2v2_upsample_sse2(cinfo->max_v_samp_factor, cinfo->output_width,
- input_data, output_data_ptr);
-}
-
-GLOBAL(void)
-jsimd_h2v1_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
-{
- if (simd_support & JSIMD_AVX2)
- jsimd_h2v1_upsample_avx2(cinfo->max_v_samp_factor, cinfo->output_width,
- input_data, output_data_ptr);
- else
- jsimd_h2v1_upsample_sse2(cinfo->max_v_samp_factor, cinfo->output_width,
- input_data, output_data_ptr);
-}
-
-GLOBAL(int)
-jsimd_can_h2v2_fancy_upsample(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
-
- if ((simd_support & JSIMD_AVX2) &&
- IS_ALIGNED_AVX(jconst_fancy_upsample_avx2))
- return 1;
- if ((simd_support & JSIMD_SSE2) &&
- IS_ALIGNED_SSE(jconst_fancy_upsample_sse2))
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_h2v1_fancy_upsample(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
-
- if ((simd_support & JSIMD_AVX2) &&
- IS_ALIGNED_AVX(jconst_fancy_upsample_avx2))
- return 1;
- if ((simd_support & JSIMD_SSE2) &&
- IS_ALIGNED_SSE(jconst_fancy_upsample_sse2))
- return 1;
-
- return 0;
-}
-
-GLOBAL(void)
-jsimd_h2v2_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
-{
- if (simd_support & JSIMD_AVX2)
- jsimd_h2v2_fancy_upsample_avx2(cinfo->max_v_samp_factor,
- compptr->downsampled_width, input_data,
- output_data_ptr);
- else
- jsimd_h2v2_fancy_upsample_sse2(cinfo->max_v_samp_factor,
- compptr->downsampled_width, input_data,
- output_data_ptr);
-}
-
-GLOBAL(void)
-jsimd_h2v1_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
-{
- if (simd_support & JSIMD_AVX2)
- jsimd_h2v1_fancy_upsample_avx2(cinfo->max_v_samp_factor,
- compptr->downsampled_width, input_data,
- output_data_ptr);
- else
- jsimd_h2v1_fancy_upsample_sse2(cinfo->max_v_samp_factor,
- compptr->downsampled_width, input_data,
- output_data_ptr);
-}
-
-GLOBAL(int)
-jsimd_can_h2v2_merged_upsample(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
-
- if ((simd_support & JSIMD_AVX2) &&
- IS_ALIGNED_AVX(jconst_merged_upsample_avx2))
- return 1;
- if ((simd_support & JSIMD_SSE2) &&
- IS_ALIGNED_SSE(jconst_merged_upsample_sse2))
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_h2v1_merged_upsample(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
-
- if ((simd_support & JSIMD_AVX2) &&
- IS_ALIGNED_AVX(jconst_merged_upsample_avx2))
- return 1;
- if ((simd_support & JSIMD_SSE2) &&
- IS_ALIGNED_SSE(jconst_merged_upsample_sse2))
- return 1;
-
- return 0;
-}
-
-GLOBAL(void)
-jsimd_h2v2_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
-{
- void (*avx2fct) (JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY);
- void (*sse2fct) (JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY);
-
- switch (cinfo->out_color_space) {
- case JCS_EXT_RGB:
- avx2fct = jsimd_h2v2_extrgb_merged_upsample_avx2;
- sse2fct = jsimd_h2v2_extrgb_merged_upsample_sse2;
- break;
- case JCS_EXT_RGBX:
- case JCS_EXT_RGBA:
- avx2fct = jsimd_h2v2_extrgbx_merged_upsample_avx2;
- sse2fct = jsimd_h2v2_extrgbx_merged_upsample_sse2;
- break;
- case JCS_EXT_BGR:
- avx2fct = jsimd_h2v2_extbgr_merged_upsample_avx2;
- sse2fct = jsimd_h2v2_extbgr_merged_upsample_sse2;
- break;
- case JCS_EXT_BGRX:
- case JCS_EXT_BGRA:
- avx2fct = jsimd_h2v2_extbgrx_merged_upsample_avx2;
- sse2fct = jsimd_h2v2_extbgrx_merged_upsample_sse2;
- break;
- case JCS_EXT_XBGR:
- case JCS_EXT_ABGR:
- avx2fct = jsimd_h2v2_extxbgr_merged_upsample_avx2;
- sse2fct = jsimd_h2v2_extxbgr_merged_upsample_sse2;
- break;
- case JCS_EXT_XRGB:
- case JCS_EXT_ARGB:
- avx2fct = jsimd_h2v2_extxrgb_merged_upsample_avx2;
- sse2fct = jsimd_h2v2_extxrgb_merged_upsample_sse2;
- break;
- default:
- avx2fct = jsimd_h2v2_merged_upsample_avx2;
- sse2fct = jsimd_h2v2_merged_upsample_sse2;
- break;
- }
-
- if (simd_support & JSIMD_AVX2)
- avx2fct(cinfo->output_width, input_buf, in_row_group_ctr, output_buf);
- else
- sse2fct(cinfo->output_width, input_buf, in_row_group_ctr, output_buf);
-}
-
-GLOBAL(void)
-jsimd_h2v1_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
-{
- void (*avx2fct) (JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY);
- void (*sse2fct) (JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY);
-
- switch (cinfo->out_color_space) {
- case JCS_EXT_RGB:
- avx2fct = jsimd_h2v1_extrgb_merged_upsample_avx2;
- sse2fct = jsimd_h2v1_extrgb_merged_upsample_sse2;
- break;
- case JCS_EXT_RGBX:
- case JCS_EXT_RGBA:
- avx2fct = jsimd_h2v1_extrgbx_merged_upsample_avx2;
- sse2fct = jsimd_h2v1_extrgbx_merged_upsample_sse2;
- break;
- case JCS_EXT_BGR:
- avx2fct = jsimd_h2v1_extbgr_merged_upsample_avx2;
- sse2fct = jsimd_h2v1_extbgr_merged_upsample_sse2;
- break;
- case JCS_EXT_BGRX:
- case JCS_EXT_BGRA:
- avx2fct = jsimd_h2v1_extbgrx_merged_upsample_avx2;
- sse2fct = jsimd_h2v1_extbgrx_merged_upsample_sse2;
- break;
- case JCS_EXT_XBGR:
- case JCS_EXT_ABGR:
- avx2fct = jsimd_h2v1_extxbgr_merged_upsample_avx2;
- sse2fct = jsimd_h2v1_extxbgr_merged_upsample_sse2;
- break;
- case JCS_EXT_XRGB:
- case JCS_EXT_ARGB:
- avx2fct = jsimd_h2v1_extxrgb_merged_upsample_avx2;
- sse2fct = jsimd_h2v1_extxrgb_merged_upsample_sse2;
- break;
- default:
- avx2fct = jsimd_h2v1_merged_upsample_avx2;
- sse2fct = jsimd_h2v1_merged_upsample_sse2;
- break;
- }
-
- if (simd_support & JSIMD_AVX2)
- avx2fct(cinfo->output_width, input_buf, in_row_group_ctr, output_buf);
- else
- sse2fct(cinfo->output_width, input_buf, in_row_group_ctr, output_buf);
-}
-
-GLOBAL(int)
-jsimd_can_convsamp(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (DCTSIZE != 8)
- return 0;
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
- if (sizeof(DCTELEM) != 2)
- return 0;
-
- if (simd_support & JSIMD_AVX2)
- return 1;
- if (simd_support & JSIMD_SSE2)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_convsamp_float(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (DCTSIZE != 8)
- return 0;
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
- if (sizeof(FAST_FLOAT) != 4)
- return 0;
-
- if (simd_support & JSIMD_SSE2)
- return 1;
-
- return 0;
-}
-
-GLOBAL(void)
-jsimd_convsamp(JSAMPARRAY sample_data, JDIMENSION start_col,
- DCTELEM *workspace)
-{
- if (simd_support & JSIMD_AVX2)
- jsimd_convsamp_avx2(sample_data, start_col, workspace);
- else
- jsimd_convsamp_sse2(sample_data, start_col, workspace);
-}
-
-GLOBAL(void)
-jsimd_convsamp_float(JSAMPARRAY sample_data, JDIMENSION start_col,
- FAST_FLOAT *workspace)
-{
- jsimd_convsamp_float_sse2(sample_data, start_col, workspace);
-}
-
-GLOBAL(int)
-jsimd_can_fdct_islow(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(DCTELEM) != 2)
- return 0;
-
- if ((simd_support & JSIMD_AVX2) && IS_ALIGNED_AVX(jconst_fdct_islow_avx2))
- return 1;
- if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_fdct_islow_sse2))
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_fdct_ifast(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(DCTELEM) != 2)
- return 0;
-
- if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_fdct_ifast_sse2))
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_fdct_float(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(FAST_FLOAT) != 4)
- return 0;
-
- if ((simd_support & JSIMD_SSE) && IS_ALIGNED_SSE(jconst_fdct_float_sse))
- return 1;
-
- return 0;
-}
-
-GLOBAL(void)
-jsimd_fdct_islow(DCTELEM *data)
-{
- if (simd_support & JSIMD_AVX2)
- jsimd_fdct_islow_avx2(data);
- else
- jsimd_fdct_islow_sse2(data);
-}
-
-GLOBAL(void)
-jsimd_fdct_ifast(DCTELEM *data)
-{
- jsimd_fdct_ifast_sse2(data);
-}
-
-GLOBAL(void)
-jsimd_fdct_float(FAST_FLOAT *data)
-{
- jsimd_fdct_float_sse(data);
-}
-
-GLOBAL(int)
-jsimd_can_quantize(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JCOEF) != 2)
- return 0;
- if (sizeof(DCTELEM) != 2)
- return 0;
-
- if (simd_support & JSIMD_AVX2)
- return 1;
- if (simd_support & JSIMD_SSE2)
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_quantize_float(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JCOEF) != 2)
- return 0;
- if (sizeof(FAST_FLOAT) != 4)
- return 0;
-
- if (simd_support & JSIMD_SSE2)
- return 1;
-
- return 0;
-}
-
-GLOBAL(void)
-jsimd_quantize(JCOEFPTR coef_block, DCTELEM *divisors, DCTELEM *workspace)
-{
- if (simd_support & JSIMD_AVX2)
- jsimd_quantize_avx2(coef_block, divisors, workspace);
- else
- jsimd_quantize_sse2(coef_block, divisors, workspace);
-}
-
-GLOBAL(void)
-jsimd_quantize_float(JCOEFPTR coef_block, FAST_FLOAT *divisors,
- FAST_FLOAT *workspace)
-{
- jsimd_quantize_float_sse2(coef_block, divisors, workspace);
-}
-
-GLOBAL(int)
-jsimd_can_idct_2x2(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JCOEF) != 2)
- return 0;
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
- if (sizeof(ISLOW_MULT_TYPE) != 2)
- return 0;
-
- if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_red_sse2))
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_idct_4x4(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JCOEF) != 2)
- return 0;
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
- if (sizeof(ISLOW_MULT_TYPE) != 2)
- return 0;
-
- if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_red_sse2))
- return 1;
-
- return 0;
-}
-
-GLOBAL(void)
-jsimd_idct_2x2(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
- jsimd_idct_2x2_sse2(compptr->dct_table, coef_block, output_buf, output_col);
-}
-
-GLOBAL(void)
-jsimd_idct_4x4(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
- jsimd_idct_4x4_sse2(compptr->dct_table, coef_block, output_buf, output_col);
-}
-
-GLOBAL(int)
-jsimd_can_idct_islow(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JCOEF) != 2)
- return 0;
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
- if (sizeof(ISLOW_MULT_TYPE) != 2)
- return 0;
-
- if ((simd_support & JSIMD_AVX2) && IS_ALIGNED_AVX(jconst_idct_islow_avx2))
- return 1;
- if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_islow_sse2))
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_idct_ifast(void)
-{
- init_simd();
-
- /* The code is optimised for these values only */
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JCOEF) != 2)
- return 0;
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
- if (sizeof(IFAST_MULT_TYPE) != 2)
- return 0;
- if (IFAST_SCALE_BITS != 2)
- return 0;
-
- if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_ifast_sse2))
- return 1;
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_idct_float(void)
-{
- init_simd();
-
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JCOEF) != 2)
- return 0;
- if (BITS_IN_JSAMPLE != 8)
- return 0;
- if (sizeof(JDIMENSION) != 4)
- return 0;
- if (sizeof(FAST_FLOAT) != 4)
- return 0;
- if (sizeof(FLOAT_MULT_TYPE) != 4)
- return 0;
-
- if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_float_sse2))
- return 1;
-
- return 0;
-}
-
-GLOBAL(void)
-jsimd_idct_islow(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
- if (simd_support & JSIMD_AVX2)
- jsimd_idct_islow_avx2(compptr->dct_table, coef_block, output_buf,
- output_col);
- else
- jsimd_idct_islow_sse2(compptr->dct_table, coef_block, output_buf,
- output_col);
-}
-
-GLOBAL(void)
-jsimd_idct_ifast(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
- jsimd_idct_ifast_sse2(compptr->dct_table, coef_block, output_buf,
- output_col);
-}
-
-GLOBAL(void)
-jsimd_idct_float(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
- jsimd_idct_float_sse2(compptr->dct_table, coef_block, output_buf,
- output_col);
-}
-
-GLOBAL(int)
-jsimd_can_huff_encode_one_block(void)
-{
- init_simd();
-
-#ifndef WITH_SANITIZER
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JCOEF) != 2)
- return 0;
-
- if ((simd_support & JSIMD_SSE2) && simd_huffman &&
- IS_ALIGNED_SSE(jconst_huff_encode_one_block))
- return 1;
-#endif
-
- return 0;
-}
-
-GLOBAL(JOCTET *)
-jsimd_huff_encode_one_block(void *state, JOCTET *buffer, JCOEFPTR block,
- int last_dc_val, c_derived_tbl *dctbl,
- c_derived_tbl *actbl)
-{
- return jsimd_huff_encode_one_block_sse2(state, buffer, block, last_dc_val,
- dctbl, actbl);
-}
-
-GLOBAL(int)
-jsimd_can_encode_mcu_AC_first_prepare(void)
-{
- init_simd();
-
-#ifndef WITH_SANITIZER
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JCOEF) != 2)
- return 0;
- if (simd_support & JSIMD_SSE2)
- return 1;
-#endif
-
- return 0;
-}
-
-GLOBAL(void)
-jsimd_encode_mcu_AC_first_prepare(const JCOEF *block,
- const int *jpeg_natural_order_start, int Sl,
- int Al, JCOEF *values, size_t *zerobits)
-{
- jsimd_encode_mcu_AC_first_prepare_sse2(block, jpeg_natural_order_start,
- Sl, Al, values, zerobits);
-}
-
-GLOBAL(int)
-jsimd_can_encode_mcu_AC_refine_prepare(void)
-{
- init_simd();
-
-#ifndef WITH_SANITIZER
- if (DCTSIZE != 8)
- return 0;
- if (sizeof(JCOEF) != 2)
- return 0;
- if (simd_support & JSIMD_SSE2)
- return 1;
-#endif
-
- return 0;
-}
-
-GLOBAL(int)
-jsimd_encode_mcu_AC_refine_prepare(const JCOEF *block,
- const int *jpeg_natural_order_start, int Sl,
- int Al, JCOEF *absvalues, size_t *bits)
-{
- return jsimd_encode_mcu_AC_refine_prepare_sse2(block,
- jpeg_natural_order_start,
- Sl, Al, absvalues, bits);
-}
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jsimdcpu.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jsimdcpu.asm
deleted file mode 100644
index 705f813d7d..0000000000
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jsimdcpu.asm
+++ /dev/null
@@ -1,86 +0,0 @@
-;
-; jsimdcpu.asm - SIMD instruction support check
-;
-; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
-;
-; Based on
-; x86 SIMD extension for IJG JPEG library
-; Copyright (C) 1999-2006, MIYASAKA Masaru.
-; For conditions of distribution and use, see copyright notice in jsimdext.inc
-;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
-
-%include "jsimdext.inc"
-
-; --------------------------------------------------------------------------
- SECTION SEG_TEXT
- BITS 64
-;
-; Check if the CPU supports SIMD instructions
-;
-; GLOBAL(unsigned int)
-; jpeg_simd_cpu_support(void)
-;
-
- align 32
- GLOBAL_FUNCTION(jpeg_simd_cpu_support)
-
-EXTN(jpeg_simd_cpu_support):
- push rbx
- push rdi
-
- xor rdi, rdi ; simd support flag
-
- ; Assume that all x86-64 processors support SSE & SSE2 instructions
- or rdi, JSIMD_SSE2
- or rdi, JSIMD_SSE
-
- ; Check whether CPUID leaf 07H is supported
- ; (leaf 07H is used to check for AVX2 instruction support)
- mov rax, 0
- cpuid
- cmp rax, 7
- jl short .return ; Maximum leaf < 07H
-
- ; Check for AVX2 instruction support
- mov rax, 7
- xor rcx, rcx
- cpuid
- mov rax, rbx ; rax = Extended feature flags
-
- test rax, 1<<5 ; bit5:AVX2
- jz short .return
-
- ; Check for AVX2 O/S support
- mov rax, 1
- xor rcx, rcx
- cpuid
- test rcx, 1<<27
- jz short .return ; O/S does not support XSAVE
- test rcx, 1<<28
- jz short .return ; CPU does not support AVX2
-
- xor rcx, rcx
- xgetbv
- and rax, 6
- cmp rax, 6 ; O/S does not manage XMM/YMM state
- ; using XSAVE
- jnz short .return
-
- or rdi, JSIMD_AVX2
-
-.return:
- mov rax, rdi
-
- pop rdi
- pop rbx
- ret
-
-; For some reason, the OS X linker does not honor the request to align the
-; segment unless we do this.
- align 32
diff --git a/contrib/libs/libjpeg-turbo/testimages/nightshot_iso_100.bmp b/contrib/libs/libjpeg-turbo/testimages/nightshot_iso_100.bmp
deleted file mode 100644
index 5a2715165b..0000000000
--- a/contrib/libs/libjpeg-turbo/testimages/nightshot_iso_100.bmp
+++ /dev/null
Binary files differ
diff --git a/contrib/libs/libjpeg-turbo/testimages/nightshot_iso_100.txt b/contrib/libs/libjpeg-turbo/testimages/nightshot_iso_100.txt
deleted file mode 100644
index 93208865f8..0000000000
--- a/contrib/libs/libjpeg-turbo/testimages/nightshot_iso_100.txt
+++ /dev/null
@@ -1,25 +0,0 @@
-libjpeg-turbo note: This image was extracted from the 8-bit nightshot_iso_100
-image. The original can be downloaded at the link below.
-
-The New Image Compression Test Set - Jan 2008
-http://www.imagecompression.info/test_images
-
-The images historically used for compression research (lena, barbra, pepper etc...) have outlived their useful life and its about time they become a part of history only. They are too small, come from data sources too old and are available in only 8-bit precision.
-
-These images have been carefully selected to aid in image compression algorithm research and evaluation. These are photographic images chosen to come from a wide variety of sources and each one picked to stress different aspects of algorithms. Images are available in 8-bit, 16-bit and 16-bit linear variations, RGB and gray.
-
-Images are available without any prohibitive copyright restrictions.
-
-These images are (c) there respective owners. You are granted full redistribution and publication rights on these images provided:
-
-1. The origin of the pictures must not be misrepresented; you must not claim that you took the original pictures. If you use, publish or redistribute them, an acknowledgment would be appreciated but is not required.
-2. Altered versions must be plainly marked as such, and must not be misinterpreted as being the originals.
-3. No payment is required for distribution this material, it must be available freely under the conditions stated here. That is, it is prohibited to sell the material.
-4. This notice may not be removed or altered from any distribution.
-
-Acknowledgments: A lot of people contributed a lot of time and effort in making this test set possible. Thanks to everyone who voiced their opinion in any of the discussions online. Thanks to Axel Becker, Thomas Richter and Niels Fröhling for their extensive help in picking images, running all the various tests etc... Thanks to Pete Fraser, Tony Story, Wayne J. Cosshall, David Coffin, Bruce Lindbloom and raw.fotosite.pl for the images which make up this set.
-
-Sachin Garg [India]
-sachingarg@c10n.info
-
-www.sachingarg.com | www.c10n.info | www.imagecompression.info
diff --git a/contrib/libs/libjpeg-turbo/testimages/testimgari.jpg b/contrib/libs/libjpeg-turbo/testimages/testimgari.jpg
deleted file mode 100644
index 896648741b..0000000000
--- a/contrib/libs/libjpeg-turbo/testimages/testimgari.jpg
+++ /dev/null
Binary files differ
diff --git a/contrib/libs/libjpeg-turbo/testimages/testimgint.jpg b/contrib/libs/libjpeg-turbo/testimages/testimgint.jpg
deleted file mode 100644
index 2501c61598..0000000000
--- a/contrib/libs/libjpeg-turbo/testimages/testimgint.jpg
+++ /dev/null
Binary files differ
diff --git a/contrib/libs/libjpeg-turbo/testimages/testorig.jpg b/contrib/libs/libjpeg-turbo/testimages/testorig.jpg
deleted file mode 100644
index 9816a0c623..0000000000
--- a/contrib/libs/libjpeg-turbo/testimages/testorig.jpg
+++ /dev/null
Binary files differ
diff --git a/contrib/libs/libjpeg-turbo/testimages/testorig.ppm b/contrib/libs/libjpeg-turbo/testimages/testorig.ppm
deleted file mode 100644
index 2a5d1e958b..0000000000
--- a/contrib/libs/libjpeg-turbo/testimages/testorig.ppm
+++ /dev/null
@@ -1,4 +0,0 @@
-P6
-227 149
-255
-0/-0/-10.21/51.51.62/62/83/83/:2/:2/:3-:3-:3-:3-:2/:2/91.80-80-91.:2/:2/80-80-80-80-80-80-80-80-6.+6.+6.+5-*5-*5-*4,)4,)4,)4,)4,)4,)4,)4,)4,)2-)/*$/,%0-&0-&1.'2/(30)30)63,63,74-85.96/96/:70:7.A:0B<0D>2F@4IA4JB5KC6KC6NE6MD5OC3NB2OC3OC3PD4RE5R?1Y?2b@4nB5}E6‹H8™G9£F7°H;¸F;¿F;ÅF=ÇG>ËH@ËH@ÐEBçFLíCLìEMëEIîCIïBDò?Cô=Aø;A÷:@ô:?ð<?é?Bâ?@×?<ËA7»=/µ@.µ@.´?-´?-³@-²?-¯@-­?.ªA.¦A-¢B, A-›@+™A+–A,”>-’?/’?/‘>.‘>,‘>,’<+’<+”>-”>-”=*”=*•>+•>+–?,–@/–?6•>5—=4Ÿ?3©B3³D3¼D4¿D4¹?0¶B3¬F:žH;‡G;oA2U9+C3&=52:659548437116005//5//72/72/72/61.61-61-50,41,//-.0-//-//-0/-0/-2.-2.-5,-4+,4*+3)*7(+=.1E69P:<jAE|HJŽNO•OQŸW[ªdnªoƒŸt”{£‡®€†º~ˆ½tz®`a‘TKvQEiSJgPH_MH^TQbfdo|}‚‘™ž˜£©Ÿ¢¨šž “‘ƒ{|lfgWYXFQNEUR[UQbUQb0/-0/-10.10.40-51.62/62/83/83/:2/:2/:3-:3-:3-:3-:2/91.80-80-80-80-91.:2/80-80-80-80-80-80-80-80-6.+6.+6.+5-*5-*4,)4,)4,)5-*5-*5-*5-*5-*5-*5-*3.*1,(0-&0-&1.'2/(30)41*41*63,63,74-85.85.96/:70:7.@9/B<0C=1E?3H@3IA4JB5JB5LC4LC4MA3MA1MA1NB2OC3QD4P>0U?1^A3jC4xD6…F5’E5œC3§C4¯A4µ@6¼B7ÀD:ÄE<ÅF=ÍC@áEIçBIèCIêDHíDGðCEó@Cö?Cø;A÷:@ô:?ð<?é?@à@@Õ@<Ê@6¹>/µ@.´?-´?-´?-²?,°?-¯@-­?.ªA.¦A-¢B,Ÿ@,›@+˜@*–A,”>-’?/’?/‘>.‘>,=+’<+’<+”>-“=,”=*”=*”=*•>+–?,–@1•A6–?6˜>5¡?4«A3µD4½C4¿D5»A2·C6¬F:œH=…G:l@3S9*B4)>63:65:6584382271160060072/72/72/61.61-61-50,41,//-.0-//-//-0/-0/-2.-2.-4..5,-5+,3)*5)+<-0C47N8:d=>vDC†JIMNšTV¤aj¥l}rŽ‘{¢†€®…¹{„»ou©[[RIvOCiOFePH`PH_RN_[Yfnot…†ˆ”™•™ž—š ”™‘ƒ~qjk[][LVSJXSZVRaXQa/.,0/-0/-10.40/40/51.51.72.72.72.72.92,92,92,92,91.80.80.7/-7/-80.80.91/80.80.80.80.80.80.80.80.6.,6.,5-+5-+5-+4,*4,*4,*6.,6.,6.,6.,6.,6.,6.,4/+2-)1.)2/*30+30+41,52-52-63.63.74/74/850961961:70?8.@:.B<0D>2G?4H@5H@3H@3J@4I@1K?1K?1K?1L@2MA1NB2MA3QA2YB4dC4qC4|C2‡B2’A0˜<-¡;,§;.¯=2µ@6ºD:¿F=ÅD>ÙCEá@FãBGèCGêDFðCEôADø?Dú;@ù:?õ;@ð=@è@@ÝB>Ñ@;Æ@5·=.³@-³@-³@-²?-°?-¯>,­@,ª?-§@-¥@.¡@-A,›@+˜@*•@+”>-’?/‘>.‘>.‘>.=-=+=+‘>,‘>,’<+’<+“=,”>-•?.•?0•A6–?5š>3¤?3¯A4¹C5¿D5ÁC5ÀD8¹G<®I=™J=G;h@4Q:,B5,?74=77<66;5594183072/72/62/62/62/51.52-52-41,21,/1.-2./1./1.00.00.10.3/.5//4..5,-4*+4*+9-/>24I56[97l?:}FA†IDOM˜[`›fv•n‰Œwžƒ}­}‚¹u~·gl¤UU‰MEvLAkMAeOFcQHcNI_NK\[[esty‡‰ˆ‡Œ†Šˆ…†Š|xzlfhZZ[MVSLZU[ZT`[S`.-+/.,/.,0/-3/.40/40-51.61-61-61-61-81+81+81+80-80.7/-6.,6.,6.,6.,7/-80.80.80.80.80.80.80.80.80.5-+5-+5-+5-+4,*4,*3+)3+)6.,6.,6.,6.,6.,6.,6.,4/,30+30+30+41,41,52-52-52-52-63.63.74/85096196196/>7-?9-A;/B<0E=2E=2F>3F>1G=1G=1H<.I=/I=/J>0L@0JA0LE5NE4VE5^D3iD2sB1~A/†?-Œ9)”9'9*¤=.¬@3³E8¸H<ÁF>ÒDCÚACÞBEâDEèDEìBCó@C÷?Aú;@ù:?ö<Aî>@åA@ÚB=Í@9Â@3¶>.°@,°@,°@,¯>,®?,®?,¬?+©@-¦?,£@- ?,œ@+˜@*–@)”?*‘>,‘>.‘>.‘>.=-=-<*<*=+=+=+=+’<+‘>,”>-’?/•A6—@6œ>2¦@4²B6¼C8ÁC7ÂB7ÂF<ºJ?¬KB—J@|F:b@4L:.A7-@85>88=77<66:5294183083062/62/62/32.52-32-21,12--2.-2./1./1.00.00.10.10.5106005//5,-4+,6,-:01D22T71c;3rB8{E;ƒIE‰RU_l‹i‚ƒs˜}y«x}µowµae¢SRŒMDyL@pL@hPEgQFfLC^HCWNLZ^^fjnquyxy~xz€vwzokoa`bUWYLTTL]WY]V]]V^------/.,/.,0/-10.3/,40-40-40-50,50,50,50,7/,7/,4/,4/,3.+3.+3.+3.+4/,4/,50-50-50-50-50-50-50-50-3.+3.+3.+2-*2-*1,)1,)1,)4/,4/,4/,4/,4/,4/,4/,4/,41,41,41,41,52-52-52-52-52-52-63.74/74/85096196/<5-=6,?8.@9/B90C;0C;0C;0E;/D:.F:.G;/H<.I=/J>0I@1JG6MH5RG5YF5bE3jD1uB/|?,‚;)‹:)“:*š=,£B2¬F8²J=¼J@ÌGBÔDCØDDÝEDãCCéAAð=@ô<>ù:?ù;=ô<>í?>áB>ÓC:ÅA5¹?0²?-¯@-®?,®?,®?.¬>-¬>-ª?-¨>.¤?- ?,ž?+š?,—?+•>*”?+‘>,?.?.>->-Ž=,Ž=,Ž=,Ž=,Ž=,Ž=,Ž=,<,>-‘>.‘@/”B4—A4ž@4¨@3¶A7¿C9ÅB:ÄA9¾C;·H?¦LC‘KCtE;Z>2E9-=6,A96@86?75>64=53<4294183062/43/43/23.32.23.12-02--2.,2.-2.-2./1./1.00.10.3205105104..2,,5,-7./>0/N5.Y9.e=1oA4tC<yKK€Ze„hp—zxªu{·ltµ_d¦TT”OGƒLBwNAmNBhMAeJA`GBYHEXKKWMPU^bc`fbbia`f\Z`VWZOUXMXXP^YV`WX`WZ,,,,,,.-+/.,/.,0/-3/.3/,2.+2.+3.*3.*3.*3.*5-*5-*3.+3.+2-*2-*2-*2-*3.+3.+3.+3.+3.+3.+3.+3.+3.+3.+3.+2-*2-*2-*1,)1,)1,)0+(4/,4/,4/,4/,4/,4/,4/,4/,40-41,41,41,41,41,41,41,41,52-52-63.74/85085096/;4,<5+=6,?8.@7.A8/A8/A9.C9/C9-E9-F:.G;/I=/J>0HA1JG6JI7NG5VF6\E3dC2lA0t?-|=,ƒ<*Œ;*”=,œ@1£F5ªJ:´J=ÄH@ÌEAÑFAÖE@ÞCAåA?ì>?ò;=÷;<ô:;ð<=é@=ÜC=ÍC8¾@2²?-®?,«@,«@,ª?+ª?-©>,©>,¨?,¥>-£@- ?,œ?-—?+•>*“>)‘?*?,>->->-Ž=,Ž=,Ž=,<+Ž=,‹<+<+‹<+‹<-Œ=,>/Ž?0”B4˜B3¡A3¬B5¹C9ÂC:ÅB:ÃB<»B:±HB£NGNEpH>T@5A;/96-@85A75?75>63=5394194173043/43/34/23.23.13.02-.3--3/-3/.3/.3/02/02/11/11/21/32032040/2.-1-,4..8.,G4-O4)X8+`<0e?6mGFyYd‚k…€uŸ||²w|¼nu»dh¯[[¡SLLB~OArL@hI=cH>`HB^ECX@BO<AGCHKDMJJQJJQIIPHKQGOUKVWO^YS`YS`XU+++,,,,,,---/-.0/-0/-0/-1-*1-*1-*1-*2-)2-)2-)2-)2-*2,,1++1++1++1++2,,2,,1++1++1++1++1++1++1++1++2,,2,,2,,1++1++1++0**0**3--3--3--3--3--3--3--3.+40-40-40-40-3/,3/,3/,3/,40-40-51.62/730730841850:3-;4,<5-=6.?6/?6-?6-?6-C90C9/E8/F90G:1I=1J>2H@3HE6GE6KE5QD4YD3_B2g@/n=,v=,|:*…9+Œ:,“=.›B2¢F7¬F8¼G=ÂF>ÉF>ÐE>ÙD@âC?ê@@ð>>ò::ñ;:ì<<äA<ÖC;ÆD6µ@/ª=)ª?-©@-©@-©@-¨>.¨>.§=-¥>-£=. ?.ž?-š?-–?,”?+‘?*>)>+>->-Œ=,Œ=.Œ=.‹<-‹<-‹<-Š=-Š;,‰<,Š</‹>.Œ>1Œ?/’C4˜B3¡A3®B6¼C:ÃD=ÄC=ÀC=ºGB²QK¦YSXQsRIWI>CC7<?6>93@72>63=60:5194083/63.43.43.34/23.13.13.02-.3--3/-3/.3/.3/.3/.3/02/02/00.11/22021/10./.,2.-4/,?0+D0)K3)T8-Z<4eGGu]jƒs‰€«…„¾~ƒÇtzÆmp½ee¯VSšLC‚K?qJ=hG;cE>_FB]DBW?AN;?H:BE>HGDMHGQIGQHJRGNVKUXM^ZOaYNaXO++++++,,,---.,-/-.0/-0/-1-,1-*1-*1-*2-)2-)2-)2-*2,,1++1++0**0**1++1++2,,0**0**0**0**0**0**0**0**2,,2,,2,,1++1++0**0**0**2,,2,,2,,2,,2,,2,,2,,2,,3/,3/,3/,3/,3/,3/,3/,3/,40-40-51.62/62/73084185092,:3+;4,<5->5.>5.>5.>5,B8/B8/E80F90G:1I<3J=4I?5FB6FB6JB5OA4UB3\@2c?1j<-q<.w9*}8)…7*Œ:,–>0›B4¤B5²F:ºE;ÁF>ÊG?ÔG@ÞFAçCAîB@í;;ë;;ç>;ßB;ÑD:¿D4°A.¤>(¦A-¦A-¦A-¥@.¥@.¤?-¤?-¤>/¢>.Ÿ@.œ?.˜?-•>+‘?*>)>+>->->-Œ=,Œ=.‹<-‹<-Š=-Š=-‰=/ˆ<.ˆ<.ˆ</‡=0ˆ>1‹?1‘D4–C3¢B4­C6ºC;ÁD>ÁD@»EA¹PL²[T¦f]‘f]u_T[UIHNBCI?<92?82>71;6094.74-63.43.43.43.34/23.13.13..3-.3-.3/-3/.3/.3/.3/.3/02/02///-11/22022010.0/-0/-3/,8,,<-*C0*K70S<6^HJtbn‡z”Š¶ŒÆ„ˆÏz€ÌtwÆjl·YW ID„E=nG<dD<aC>^CAY@CV@DP>EKGQRKWUQ^WU`XT`VS]TT^SY_S^[LaZJaZJ,-/,-/--/--/------.,-.-+/.,/.,1-*0,)0,)0,)/+(/+(/+*/+*/+*/+*/+*/+*0,+0,+/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*0,+0,+1-,1-,2.-2.-2.-1-,1-,1-,1-,1-,1-,0,)1-*2.+3/,3/,3/,3/,3/,3/,3/,3/,3/,40-51.62/73080-92,:3-;4.=4/>5.>5.>5.@5/@6-B5-C6.D7/F91H;3G=4G>5H@5J@6P?5T>3X<1^90c7,m9.t8-|8-ƒ9.;/“=0˜?1ž>0§A3­A4µC8¾E:ÊG=ÔG>ÞE?åC@è@?êBAæDAÚE>ÈD8·B1ªA.¢B,¢A.¡@-¢?,¢>.¡=-¡=-¢>. ?/œ<,š=,˜<-•>-“=,=+Ž=*Œ=,‹<+‹<+Š=-‰<,‰<,‰<,ˆ:-‡;-‰=/‡=0‡=0‡=0ˆ>3ˆ@4‰A5‹A4‘E5—D4£E9±I>ºG@»D>»EA¸MGµ[S¯f_£qf‘sh~rdjj^V^SJRGLLBJF=B>5=90:6-74+63,33+54/34.34/23.02-/1,.0-,1--2.-2.-2.-2./1./1./1./1.02/02/11/11/11/11/11/40/4+0;/3A32C41J;8]NQym{‹…Ÿ“»”–Ï•Ùƒ‰ÓtzÆjn·`c¨Z[”LItHBdA>]>>X?BUAIVLU\U`bbqno~yv†|s€vlyohth_k_W_P^]Ib\Fc]G,-/,-/--/--/------.,-.,-/.,/.,0,+0,)0,)/+(/+(/+(.*).*).*)/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*0,+0,+1-,1-,1-,1-,1-,1-,1-,1-,1-,1-,1-,0,+1-*2.+2.+3/,3/,3/,2.+2.+2.+2.+2.+3/,40-62/62/80.91.:2/;4.=4/>50>50>5.?4.?4.B5/B5-D7/E80G:2H;3H>5H>5L=6O>6R>5V;2Z90_7/i81p7.x8.8/Š:/<1–<1›=1¢@3§A3­C6´D8¾E:ÉF<ÔE=ÛC>ßD@àEAßGBÔG>ÄF:³D3¥B/žB-ŸC.žA/Ÿ@.ž?-ž?-ž?-ž>.Ÿ?/š=,™>,–=-”=,=+>+Œ=,Œ=,‹<+Š=+‰<,‰<,‰<,‡;+‡;-…<-†</…=/…=1ƒ=1…?3†@6ˆB8ˆB6“G9˜F8£G<¯JB¸HD¸GC·KH³TN±d\ªqfŸ~oo|mmseZfZNXMLNCKI=EC7A>5=:188.44,11)23-23-12-01,/1,/1,.0-.0-/1.-2./1./1./1./1./1./1.02/02/11/11/11/11/11/2015+49-7<15?54I?=^UVys}Šˆž““¹”—Ê–Ô„‹ÏyÂqy¸kt­hnž]`XZqSUjRWjT^hZgmfvvr‚tˆ~’‡ƒ•‰~Žw‡zr€qftgZeT[ZE`ZBb\D-.0-.0-.0-.0-.0-.0.......,-.-+.-+-,*/+*.*).*'.*',+),*+,*+,*+,*+,*++)*+)*-+,-+,-+,-+,-+,-+,-+,-+,,*+-+,-+,-+,-+,.,-.,-.,-.,-/-./-./-./-./-./-./.,0,+0,+1-,2.-2.-2.-2.-1-,1-,1-,1-,1-,2.-3/.40/51.80.91/:20<41=31>42=31=4/?40?4.A4.A4.C60D71F93G:4H;5J;6K<7N=6P;6S:5W83[6.c60k6.t5,}7/‡9/;0”<2—=2ž@6 @4¢@3¨@3±C6ºD8ÅE<ÍD<ÕF@×HBÔIBÌI?¾E:®C3¡B0œA.B/œA/œ?.›>-›>-›>-›>/›?0˜<-–=-”<.“=.>-Œ=,Œ=.Š=-‰<,‰<,‰<,ˆ<,‡;-…<-„:-ƒ;-„<0‚<0‚<2‚>3ƒ?4…A8‡C:ˆD9”J=—H; H>¬KD²KF³LG²SM®`V­sg¦qŒz‘Ž{‚‰ws€ocqbXcUNRDMN@HI;DD8@@4:</46+/1&12*01+/0+/0+./*/0+//-//-//-.0-//-//-//-//-//-//-00.00.00.00.00.00.00.1/26+98,:8/4;63HE@_^Yzy~‹š”±’—¿•Ç„ŽÃ}‰»{‰¶|‹²}Œ«}ˆšyƒq~‡o~ƒn~~pƒyŽ…ƒ™‹¡”‘¨˜¥”ˆŒƒ•…|{j{k\hTXX@]Y>_[@-.0-.0-.0-.0-.0-.0.......,-.,--,*-,*/+*.*).*'.*),*+,*++)*+)*+)*+)**()*(),*+,*+,*+,*+,*+,*+,*+,*+,*+,*+,*+,*+-+,-+,-+,-+,.,-.,-.,-.,-.,-/-./-./-./+*0,+1-,1-,1-,1-,0,+0,+0,+0,+0,+0,+1-,2.-3/.40/91/:20;31<42=31=31=31=31>3/>3/@2/@3-A4.C60D71E82F93H94I:5J;6L:6N94Q83T50^72e60o6/x8/‚90‹;2<2”=3š@7›?4›?2Ÿ?1¥A2®B5¸C9¿E:ÈH?ËH@ÊJAÃH@¶F:ªB5žA0™@.šA/™@.˜?-—>,—>,™>,™=.˜?/–=-”=,“=.=-Ž=,Š=+Š=-‰<,‰<,ˆ;+‡;+‡;+„;,„;,ƒ;-€;,;/€<1=2>5ƒ@7ƒC:‡D<ˆE<”KB–H>žG@§JE®LI®QL­]Vªj^§€o¡yšš‚›ƒ†•€z‹xm{lbm_SZJQUFKO@EI:@D6;=057,13(01)/0(./*.-).-)/.*0/-0/-0/-0/-0/-0/-0/-//-0/-//-10.00.10.00.00.00.00.3.27,:6*83-1961HJ?bfX{€z‹““£–°Œ•¶ƒ²¯…™²¤¶’¨³”§«‘££Œ ž‡ž˜‚™}˜‰œ‹ˆ£”°š˜±›”­—‹£…›†~‘}k|iXfOSU=ZV;^Z?+/2+/2-.2-.2-.0-.0..0..0------.-+-,*-,*-,*,+),+),*+,*+,*++)*+)**()*()*(),*+,*+,*+,*+,*+,*+,*+,*+,*+,*+,*+,*+,*+,*++)*+)*-+,-+,-+,.,-.,-/-./-./-./+*0,+0,+1-,0,+0,+/+*/+*0,+/+*/+*0,+0,+2.-3/.40/:12:12;31<42=32=32<20<20>31=2.?1.?1.@2/A30B41C52D63C84D95E:6G96H94K84N50X72_60i70s80}:1†<1Œ>2>2—@6—?5—?5—?3œ@3£C5«C6³E8ºE;½G=¾H>¹G=°D8¦A5œ@1—@/—@-—@-–?.•>-”=,–=-–=/–=/•<.“;-’</Ž<.‹<-Š=-‰;.ˆ<.‡;+‡;+†:*†:*„;,ƒ:+‚:,€:.€:0€<1€=4?6‚B9ƒD=‡F@ˆH?‘KC’H?šGA£KG¨PL©YR©f]¦vh¢Œw›™€•¤‡Œ£‡†ƒ~‘}t‚qjue\eTV_LNUCEL:?F6<@27:/58-12*/0(.-)/+(/+*0,+1-,2.-1-,1-,1-,1-,1-,/.,1-,/.,2.-0/-2.-0/-0/-0/-0/-2-18,:5)51++66,GL8aiRzƒpˆ’‡—–š ™¥ˆ–£‡›¢ª©›¹±¡¿³š¶¨š¶§›·¨˜·¥‘±œ‰«’‰«±”’³–•´•­ˆ¢…„›{’xgzdTbIQT9VU9YX<,03,03./3./3./1./1//1//1....../.,.-+.-+.-+-,*-,*.,--+,-+,,*++)*+)**()*(),*+,*+,*+,*+,*+,*+,*+,*+,*+,*++)*+)*+)**()*()*(),*+,*+,*+-+,.,-/-./-./-./+*/+*0,+0,+0,+/+*.*)-)(0,+0,+0,+0,+1-,2.-3/.40/:12;23;31<42=32=32<21<20=20=20>0->0-?1.@2/A30?40@51@72@93A:4B94C84F74H5/Q51X5/a6/l8-v:/€</†>0‹=1“?5•>5“?5“?4•B4šB4 C4¥D4¬B5°D8´E:±E;ªB7¢@5š>1–>0•?.•@,”>-“=,“<+“<+”<.”<.“;-’<-<.;-‹<-‰<,‡;-‡;-†:*†:*†:*ƒ:)ƒ:+9+9-9-€<1<3?6€A8‚C<…F?ˆIBŠICŽIBG@—HD OK§VS§`Z©pe¤ƒrœ”}– …¨Šˆ§ˆƒ „~–~z‡uq|kdp\]iUR^JJS@BK:>E5<@29<134,22*1-*/+(/))0**1++2,,1++1++1++1++1++0,+0,+0,+1-,1-,1-,1-,/.,/.,/.,2,.8*75(13+(56&EK1\gGu‚d†“yŽ›Š‘ž”’žšž˜¥——´ž¢Å¥©Î­¥É­§É°§Ë±¤È¬—¾Ÿ‹³‘ˆ°²Ž²Ž²¬Š„¡‚€™{wŽrdx]R`FNR7QQ5SR6,03,03,03,03./1./1./1./1000//////////.,/.,/.,.-+/-./-..,--+,,*++)*+)**()+)*+)*+)*+)*+)*+)*+)*+)*,*++)*+)*+)**()*())'()'(+)*+)*,*+-+,.,-/-./-.0.//+*/+*/+*/+*/+*.*)-)(,('0,+0,+0,+0,+1-,3/.40/510:12;23<34<34=34<21<21;10<1/<1/>0/=/.>0-?1.@2/>3/=52;62;83<94=:5>93@72C60G4.O4-Y4,d5+n8,x:-;.…;.<4‘<5>3@3A2“B1—A2šA1 >1¦@4ªB7ªB9¦A7Ÿ>5˜>3•?2’?-’?-‘>,=+‘;,’<-’<-’<-‘;.‘;.<.;-Š;.ˆ:-‡;-„;,…9)…9)ƒ:)ƒ:)‚9*9+~8,~8,=2€=4€@7B9„E>…HCˆKFŒMFŒICŽGA˜JH¡SO¨]Z©hb©{n¤Žy™œ’§ˆ‰¬‹‚ªˆ€¡„€˜€~‹wxnjwcdr[ZgSQ]IKTCEL<@D6<?467/44,3/,1,)1()1()3*+4+,2)*2)*2)*2)*2)*0**0**0**1++1++0,+0,+0,+0,+0,+1+-6)25)-4-%46!BI'Wc;q€W‚’mœ} †’¡Œ Š¨‰•¸Ž È”¤Ð©Ó«¨Ò®§Ñ­¡Ë¥“½—…¯‡‚¬„‡°†ˆ®…Œ±ˆ‹«†Ÿ{{”tqˆk_sWM]BIO3JM0KK/./1,01./1./1.0/.0/.0////00.00.00.10.0/-0/+/.,1-,2.-1-,1-,0,+/+,,*++)*+)*+)*+)*+)*+)*+)*+)*+),+)*+),+)*-(,*(),())'()'()'(+)*+)*,*+-,*.,-.-+/.,0/--,*-,*/+*/+*/+*.*),(',('1-,2-*2-*2-*3.+4/,50-61.;31;31<42<42=32<21;10;1/<1/<1/=/.=/.=/,>0-?1.=2.=4/=60;81::29:49:4;81?61C2+J1,T1+^3,g7-o9-u=.{=0‡=4‹=3‹?2Œ@2Ž@3@1’?1•=/˜</œ>2¢B6¡C7žB7™?4–>2•?2”>/“=.=-<,Ž<.Œ=.Œ=.>/Ž<.Ž<.‹</Š;.‰;.ˆ:-†:,„;,‚:+‚:+€;+~;+~;+|:,}9,|:.€>2>5€@7‚C:ƒG?†KCˆOH‹OGŒHEŽHF“OL˜[Vžg`uiž‡už˜€”¡…ª‹‰¬‹ƒ¨‡€¡„~›|ytˆoj~ccz^]qXWfOO\HIRAAH8>@399/85.7/,3+)2()2()3)*4*+0*,/+*0*,0**0*,0*,2),2),3*-1+-1+-1+-0,-0,-0,-1+/5*05+,4-%46!?F%T`8n}Rg‰™tžz¡~ˆ¡zŠ§{‘¶‚›ÄˆŸËŸÉ™žÇÆš˜Á•Œ·Š‚­€…®‚Œµ‰„«‰®…‰©‚~œxvolƒfZnSJZ@GM3FJ1DF./0+.0+/0+01,01,12-12-21-43/43/43/62/51.41,3/,4/,50-50-4/,3.+3--1-,0,+0,+.,-.,-..0--/,,.++-*).))+.)/.)-/(/.)-/)-.)-.*+.*+/+*/+*-,*.-)--+./*./*./*------.,-/-./.,0/-2.+2.+2-*4,)5-*6.+90+:1,;2+;2+=4-=4->50>50>50=4/<3.<3.=2.<1-<1/;0.=/.>0/>0/@1.A0)@1*;4*77-39/39/560:3-?-+F*'L)'S*&Z/(`5,d<0k@0yA2€A0†A2‹B3@3“=0“;/’8-“;/”>/”A1•B2”C2’A0‘>.‘;.—:2—:2’;1>1ˆ?0„?/‚?.ƒ>.ˆ@1ˆ?0Š>1Š<0‰;/ˆ:.†:-ƒ;-{9+~@3w<.q7)w=/w=/v;-}?2{;/‚@4ˆE<ŠJAˆLB†MB„PE‡NE‘KI—SR”b[‘ocŒ}j‰‰q‰–|Šž‚¤‡¦‰Ž§Š§Œ‡¤ˆ~Ÿ‚uš{o—uiib„_[zXZsU[mSWeNPWEJK=C?6@93;0.6**4(*3'+3'+1&*,*-)+***,*(),'+.(,1(-2'-3(.3(.3(02(00)00)0/*1/*0/)-1++0-(//#<?,V\BpzX‹gœu‹sŒ¡vŒ¦wŠ¨v‰ªuŽ´{™¿†ŸÁ¾–ºŠ³ƒˆ®}…«|ƒª{…ª~ƒ¨}ƒ¦~€ž|y”ur‰mh|cYkUN[GIP>CH4?B/01+01+01+01+12,12,21,32-43.43.74/74/63.52-50,50,7/,7/,6.,6.,3.+2-*1-,0,+/-./-./-0..0-,1+*/)*.)(-.)//(//(//(//)-/)-.*+.*+/+*0,+.-).-)./*./*./)/0+.....0....../.,/.,2.+3.+5-*5-*7.)8/(:/)<1+<2)=3*>5,>5,>5.?6/>5.=4-=4/<3.=2.<1-<1/;0.=/.>0/>00@1.C0*C0)A2+>3-:5/94.:2/<1/?-+D*)I*(N+'T/)Z5-`;2e=1pA1x@/€A0ˆ@2?4’>4”;3“;19.‹</‹=0Œ@0A1A1B2’@2•;2•;2<2‹=0‡?1ƒ@/?/‚?.…@1†>/‰=0ˆ<.‡;.„;,ƒ;-€;,x8,x<1t:.n9+t?/s>.r8*u:,}=1ƒA5‰E<‹H?ŠKB†MB„PCˆOF‘JH—SR’f]wi„†p€“wž„¥†ˆ§ˆ§Š§§Š¤‰Ÿƒwœ}o˜ve’iaŒaZƒ[Y{X\wXZnSSaJNUCFH;C@7<737/-3*+2)*1(+.(*,*-**,+),+),-(,/)-2(02(04)13)13)21*20+2.+2.+4.+22-13/.0,)--%8:-SXDox]€‹i‡–o†™l†žnˆ£p†¤p„¥pŠ­w“¶€™¹‡–¶„“³¯|†«x‚¨w‚¨yƒ¨|ƒ¦|„¤{x’uqˆnh{eYjWN[IEL<@D5;=/12,12,12,23-23-23-43.43.54/65085085085074/72.72.80-80-7/,7/,4/,3.+1-,1-,1-.0./0.1/-0..0,,.+*/+)./(/1'//)-/)-/)-/)-.*+.*+0,+0,+/.*/.*0/*0/*/0*/0+//-///0./0./0/-/.,1-*2-*6.+7/,90+:1*<1+=3*>4+?5,?6-@7.@7.@7.?6/>5.=4/=4/=2.<1-<1/;0.;0.<1/<1/?1.C2+E0+H/+K--L,/K+.I*/E+.A-,@.*A.(F/)N/*X1*b3-g5.j:,o;-x<1=4‡<6Œ<5:4:4Š;4‡=2†>2…?3†@4ŠB6ŒB5C6Ž?2=/Œ>1Š>.‡>/†?-†=.ˆ<,‰;.‰<,ˆ:-‡;+ƒ;,<)~=+{<+}=1z<1v:/v<0x@1x@1v<.v;-?5ƒC9‰F=‹H?‰JAˆLB‡NEŠNF’KI˜TQ–f\‘wh‡…n‚‘t{¤ƒ…¨‡ˆª‰ªŒ©ŒŽ¥‰ˆŸƒš}y˜xi–ma’e\‹a\†`^ƒa[|]UrVQgPHYGBPA:D93:2.3,+0**,)**(1(+1&*1&*1&*0'*1(+2).1+//*.-+.,+0+,0)-0(-0(-1)-01/23/./+(**"57*QVBmu]|Ši€k~“j™lƒŸo€ o~ m‚¤q‰«x¯|‹­zˆªx„©v‚¦v€¦u€¦w€¥y€£y‚¢}}›yw‘tp‡mh{eYkUN[IDH9>@399-23-23-34.34.45/45/54/54/761761:72:72:72961:51940:2/:2/91.80-50-50-3/.3/.3/03/01/01/20.1..0--/-+.0)02).0*.0*.0*.0*,/+,/+*1-,2.-0/+0/+10+10+01+12-11/1111/010.10.2.+3.+3.*91.92,;2+<3,?5,@6-A7.A7.B8/A8/B90A8/A81@70>50>50=2.=2.<1/<1/<1/<1/=20=2.B3.E2.M//R+0W(0U&.P'/I).C/.<1+;2+?2)H1)S0*_.*d/)i9/k;/u<3}<6†<9‰;9Š;7ˆ:6‰>9†?9†B9…B9…B9†B9‡A7ŠB6ˆ@1ˆA/ˆA/‡@.‡>-ˆ<,‰<,‰:+‹9+ˆ9*‡:*ƒ:)<){=(x>(x>*‚>3{7.z7.z<1v;-w=/|A3{@2€B7ƒE:†H=ˆI@‡KA‡MBˆOFŠQHŽSK\QŽh[‹tb…g€‹m~–vž|ƒ§ƒ„©‡ˆª‰‹ªŠ‹¦‡‡ ‚ƒš~}˜yq•oj“ifgfŒeg‹gd†e_~_\v[PhRK^KBPA8D62:/.4*,/(+*%2&(5%(4%(2&(1&*/)+/+,.,-++-*+-*+-(,-(,/',/',/*+-/+,1++0+(/,%99-PTCiqYvƒe{Œhyh|•kœn}žoyžk{ m€¥r‚§t€¥q}£p}£p~¤s~¥v~¥x}¤x|¡x}Ÿzz™wuqn‡je|bXlSN[GDF9?=1:8,45/45/45/560560671761761872983;83<94<94<94<73<73<41<41;30;3083072/61.61.5106216213123121/00./1-.2,04+.4+.4+.2,.2,,2,,2,,3/.3/,3/,40-21,21,32-32.22022032032051051.61.61-;30<5/>5.?6-A7.B8/E8/C9/E;2E;2E;2D:1C90B8/A60@5/>3/>3/=2.=2.=20=20>31>31@51F42M02T,4X)3W(2R)1K,1B30:6-77-:6*B4)M2)X/)^/)f:1j;3s<7z=:‚<:†<;‡;;†::‚;7>8@:‚C<ƒC:ƒC:…@9„@7‚C2‚C1ƒB0„?/‡>/ˆ<.‰:-‹9-Š8,‡8+…9+‚:+~=+x>*v?*x=+9-|/'‚8/„>4w4+t6+}A6}C7E:€G<‚I>„KB„KB†MDˆRH…WJ}`N{iQ€pYu]‚|bƒ†i†“uˆ|„¢~‚¦‚‚ª…‚¬†©„¥€{ž}z™wz’p{lyŒlwŒkumsŠmm„gkd`rZ[hTR[JIM>@@4;7,70&5*$6('5''3''1'&.((,+)++)+-*(,+(,+*,+*,+++-,*-,*-.*+,#$3+(50*85,BC5UZFfpWn}^tˆeqŠbuex˜ivšjs™htšiwŸkz¢nx lwŸmx n{¢s{¥u{¥w|£wyžuzœww–tsŽom†hd{_WkPN[GCC7>:195,560671671671782782872983983:94=:5>;6>;6>;6>95>95?74?74>63>63;63:5294194184195495484384343151240/6-06-.6-06-.4..4..4..4/,40-40-40-51.32-32-43.43.43/442542540841850:51:5/>71>7/@7.A8/C90D:0G:1H;2G=4G=4F<3F<3E;2C90B71A60@51@51?40?40?42?42@53?53@72D63I35P16T/6S.5P05J22C52=90<:.=9-C7)I6(Q3)W2)]2+d3,l50v64}77‚87ƒ77ƒ77~75}:4}<6~?8€?9ƒ@8†?;…A8C4€C1B1ƒ@0…=/‡;.ˆ:.‡9-…9,ƒ9,‚:,<,|=,y>,x?,|=,‡4,‹2,¡LE¨XQ‹A8|90‚F;€K=yH:zJ<{M@|NA}OBQE‡UJ‚_LrkOptS|uX‡w]yb˜iŸ‹s ”z—–z‘œ|‹£ˆ¨ƒ…§‚€¤~{Ÿy~™vƒ‘p…Žo„pŽpr{ŽpwŒmtˆlj~cfv\_hSV[GOM>GA3A7+=0';,'9+(6+)3+(/,',-'+-().().(+-(-,*/+*3)*4(*7'*7'(3($<3,E>4IG:QR@^cMgqVjyZoƒ^k„\l‰]p‘bq•eo•do—eršfuŸmrœjq›itžnx¢rz¤vy¢vyŸvvštw™vu”rokk„fc|^UlON\ECC7@91;4,782782782782893893:94:94:94;:5>;6?<7@=8@=8@;7@;7B:7B:7A96@85=84=84<73<73<73<74<74<74;639529338308/09/.8/080.80.80.61.61-61-61-52-63.63.63.74/54/540651841952;74<94=84@93@70A8/C90D:0G:1H<0I=1J>2J=4J=4J=4I<3F<3D:1C90B8/A81A81@72?61?61@72A83A83?74@85B86E:8G96I:7H96H94E80E8/E9-E9+G9,I9*K9+Q7*Z/&d/'n3-z63ƒ98‰;9‹;:‹=;‹A>‡@:ƒ>7<4:3‚<4ˆ=8‰@9ƒA5B3‚@2ƒ?2ƒ=1„<0;/€</=/}>/|>/|>/|>/}>/=/†9/1+£;8ÎkfÛ~y­ZTD=ˆLAN@tJ<rN>pQ?qR@tSB{WG‚[J~eOmsOpzU„y[˜u_©oc¶mf¾qk½wo»‚w±Œz§—~žž‚–¡¡~…y…™vˆ‘r‹rˆ‘r…“r”t}•sx“pt’pm‹ii„edx]]kRV^GMP;ED0B;+@3+?2,;0,70*30)00(./)./)01+30+7-,;+,?),D',F%,D'+F5-LC4VP@[XE`bLgmSjxWj{Wl‚[g‚Wg†Zl^o“cn”an–bršfskpšjo™irœnvŸsy¢xxžwvšvs—su—vs’rn‹lk„db{[UmMN\CGH:E<5@707827828938938939:4:94:94;:5<;6?<7@=8@=8@=8A<8A<8D<9C;8C;8B:7?:6>95>95=84>95>95>95>95=85<73:52<41:0/:0.91/91.91/91.91.72.61-61-63.63.63.74/74/74/540651952;83<94?:4B;5C<4A8/B:/D:0E;/H<0I=1J>2J>2K>5K>5K>5J=4F<3E;2C90B8/B92B92A83A83A83A83B94A:4@85A96B;5D=7F=8G<6K<5N;4M6.O7-Q6+Q6+R8+P9+P9)W7(f6*r6,~;3‰@9•D@›HDŸJGŸLF QJ™LDŽD;†<1„7-†8.Œ91=6ˆ>5‡>7†=6…<5…<5=4}=3z>3x@3vA3x@3z>3<3ƒ:3‰84’42˜(&³=;í{zþ•’Åhc–G@‰K@xH:nM<jQ=fT>hV@lWBt[E`L€hP{rQ…vUžt\´l^É__ÓV\ÙQ[×T\äouÙzx̆~À€µ•€«•}£’xŸvœŠrœŠt™u•u‘‘u‹‘u†‘s‚‘r|‹ny†ju{anpZgbN_TBUE5R</O4-N2.I0,D/*>/(9/&7.'6/'92*;0*>/,B-,G*,I),L'.I)*TB6YQ<d^HgeLilOnuVm{Xl~Xn…[hƒVg‡Xm]p•bq–br™dvœit›lq˜ko–jr™mwvzžxxšyt–uu”uu”usroŠkjƒeb{[UmMM]BMN@KB;F=69:49:49:49:4:;5;<6=<7=<7=<7=<7@=8@=8A>9B?:D?;D?;E@<E@<E@<D?;D?9C>8E>8E>8B;5B;5B;5B;5B:7B;5B:7A:4A75A83A75@72@64>71>71>71<71<71;60:5/96185074/74/961961961:72<73>93A:2B;1C:1D<1F<2J>2L@4L@2N@3N@5N@7N@7L?6K>5J=4H;2F<3E;2B90B90@91?80?82?82@93@93<5/MD?M@:K:3T?:S73O0+a<6\3-`5.`4+^/'^/%f6,m=1q=0ŠJ>G;—I?ŸKAŸF>›>7›>7žD;¦ND¥QF©WK«YK¥OB™A5—;0›>6“98’:9Œ65†52†84„?8|@6r>1rB4oA2q=0w;1‚72Œ43’-1š',ÈHIèbaÅEDÍWUáyv«VO†F<„VFnS>i[AibFjeHj`En^D|dLjT’bL´l]ÑnhÛX]à;Lç-Eò+Hõ0Lö@YìI\ä[eånrâ{|Û€}Ûƒ؉‚Ã~w½wº„x¶†x²ˆx­‰y¨‹y¥Œxš€o™~m˜xi“ocbY„UM{IBxA>u:<i.2d04b14P&'G%#L0-M51G4.E2,D1-F1.F.,G+*K-/Q51YH6`V;f_CgdEkoNu|Zu„]oYlƒWl‡Zp_r’at”cu—dw™fxšhq•is˜ot–qr”ou”ty˜x{˜|y–zx•ysrm‡lk„gi‚dazZTmMO_DNOASJAQH?9:49:49:49:4:;5;<6>=8?>9>=8>=8A>9A>9B?:C@;D?;D?;FA=FA=E@<E@<D?9D?9E>8E>8E>8E>8E>8D=5D=7C<4D;4C:3B92B92B92B92B94A83@93@93>71<71<71;6096185085074/961961961:70<71>:1A:0B<0C;0E;/I=1J>0L@2L@2N@3N@3N@5N@7M?6K>5I<3H;2E;2E;2C:1B90A:2@91@93@93A:4B94E:4J71L.,V..j68u9;{;;…EC„E@…IA…IA‡H?ŽIB™NH¡PL¢OG“D7”B4šB6 D9 >3œ7-œ7-Ÿ=2£C5œ@1™@0 D5¤G6§F6®H:¶NE´LM¯HL¥@D™9;‘98>:ƒ@8x>3o>0zI;…LA„?8…-,’).³9DÒLWÜKNßMMÊ>=À@?Ð`\³YQ„@5ƒUEyaIe[@_^@ihIslOvgJ~dK–cN¼dXÖ_[æUZëANò,Eÿ&Eÿ&Hÿ'Iÿ.Nù3Nò<RðI[ëP^åQ]ãS]àXbÛbkÕflÔioÒmqÏqrÍutÉxwÇywÊ||ÉyzÈvxÇqtÆkrÅfnÅakÃ_kÅ`n³Sa¦LXšGQŽEL†EIm69HT1-M0*I2,J6/L92K:2O>7UE8[O7cZ;hbBifEnrO{ƒ^z‰bt†^r‰_p‰_p‹`r`u’dw”dw”dw”fs‘kx–t|—x{•x—}„œ„…‡ƒ›…™ƒz’|rˆqm„jhd`y[TmMP`ERSCVPDUOC8938938939:4;<6=>8?>9@?:@?:@?:C@;C@;C@;C@;E@<E@<FA;FA;FA;FA;E@:E@:G@8G@8JA:I@9I@9H?6F=6E<3F<3E;2D:1D:1D:1D:1D;4D;4D;4C<4?80?80<71;60;60:5/94.94.96/96/:5/;7.>7/@9/C:1C;0E;1F<0I=1K?1M?2NA1P@1P@3P?5M?4L>3K=2I<3H;2E;1E;1D;2C:1B;1A:0?;2@<3A=4D;4VE>U4/j25ŽAG­LWÃUbË]fÆ_c›B>—I?–LAœND¬QL¾URÌOSÄLM¥@6B0 @0¥?1¥;.£7+¤8+§=/«E6¡=-˜7$:'¥>-¬A1²C2·E;§02¯:B¹DL½LRºMR­KL–A>‚71{8/v6,x2*„1-œ37¹=GÕGWèM[âFIÏ53Ð:9½31ÈNKÆc]•K@Œ[J}cLk`DgdEtoOpSgLhN°hYäbbõQZôDQö7Iþ2Kÿ2Nÿ/Mÿ+Iÿ2Oü0K÷1Jõ5Nó5Nð2Kó3Lô8Qò@ZïC[îF_íIaëNcêQfèTjèVkåSjäRiäPjäNiçNlëPoòSsóVuþg†ñ`}å[uÕUlÎZmÉdr¨R]r-2^&'Y0,W:4Q?5C;.:8)>B3LN9VO3aV6e_?heDquT†e€‹ixˆdxŒiu‹etŠdr‹cvŒeyhzizj€•v„›Šž… Š’£—¨–˜©™–¦™‘¢’‡˜†zypƒmhc_vYTmMPcGTWDYVGYVG7827828939:4;<6=>8@?:A@;BA<BA<DA<DA<DA<DA<E@<E@<GB<GB<GB<GB<FA;FA;HA9HA9LC<KB9JA8I@7H>5G=3F<2E;1D:0D:0E;1E;2D;2E<3E<5E<5@91?80=82<71;60;60:5/:5/:70:70;7.;7.?8.@9/C;0D</F<0G>/J>0K?/M@0NA1P@1O?0O?2O>4L>3K=2J<3H;2E;1D:0D;2D;2B;1@<1@<3A=4B>5G=4S81[*&Š;@¾T`ÙTeæTgãUcËJO 41—;0’?1™A3®F=ÅIGÕBHÎ?C±B7§F5©B3¬@3¯?3°>3³B4µE7²G7©B1£<)¤;(©;*«:*®6&­3(¶97º9=½7>¼7<¿<BÆJLÄTS¾XS™?7Œ4*‰,%61ÃHKÜOWãBRÛ3@Þ:9Í.*Ó84È74ÆE@È]U©WK‘XGwW@veI~pS€qR„fLcL©o[ÕuiîSWüDP÷;Jù:Jþ=Nÿ@Qÿ;Où4Hÿ?Sÿ9Pû4Ký3Ký1Jÿ/Iÿ0Nÿ6Sÿ3Tý4Vý6Wú7Wù:[ø=\÷>`õ@aøCf÷Agõ?eõ?gø?hüCmÿErÿIsÿOwÿQuþUvòSqçTpåaxÖfv·Wb~17j0/Y2+P8,G>/>A.;D/?G/QL/_T8g`CokN||`ˆŽr‡‘v~‹q|Œq|Žt|szqzŠm}Œoƒ’uˆ–|•£Œœ©•£®¦±¡¬´©±¸°°·°«µ­¡«¢•¡•ƒ‘‚s„qh|c]tXSlNQdHRZCWYDYZH671671782893:;5<=7?>9@?:BA<BA<DA<DA<EB=EB=FA=FA=FC<GD=HC=HC=HD;HD;JC;JC;LC:KB9KA8J@6K>5I=1H<0H<0E;/E;/E;/E;1E;1E;1D;2D;2A:2@91@91?80<71;60;60:5/;7.;7.;7.<8/?8.A:0C;0D</G=1G>/K?1M@0NA1NA0P@0O?0O?2O>4N=3K=2I;0G;/D:0D:0D<1D<1B;1@<1A=2A?3B?6K=4\50w32­LSÛ]iæM_å?S×6E·&+¨1+7(“;'—<)¬@3ÃD=Ô>?Í;<±?5¨B4ª@3­>3²@5¸C9¼G=»I>¬>/ª?/¨=+¦;)ª9)°:,·;/¼<1ÊFAÏEBÐ>?Ð79Ö7<ÞBEâLNÞSPÄC>ÇLDÍTLÔSMÙKJÜ@Cà5>á27Û4.Ú7.Ð1+Ï:4¿84³@9µ[P–TD{N9‚bI†kP…aG’[F®gUËrdçmhêEKò:Dê9Cç<DçBHçFKèGMêFMõKTóAOó8Iö5Hù2Gþ0Gÿ3Mÿ8Rÿ9Vÿ9Xÿ:Xý:Zþ;]ÿ=_ÿ?dÿAeÿCiþDkþDmüCmüCoüCoýCrþCpÿGpÿ@hÿGmÿMpòIjéOkå[rÙcs½YeŽ?D`&$Q+"V@3VO=IL7@D-RJ3eYCvkW€{gŽy™œ‹•œŒˆ“ƒ‚Ž€Š–ˆ›Œ˜Š‡’‚Š“‚—žŽ¤¨™²¶¨¸¼®¿Á¶ÀÁ¹ÂþÅÅÃÃÃþ¾¾°µ±¢©¢—Œy‡vi{e\sYTmORfJQ[BUZCW\F560671671782893:;5=<7>=8@?:@?:C@;DA<EB=EB=GB>GB>GD=GD=HC=ID>IE<IE<LE=LE;LC:LD9LB8KA5L@4K?3J>2J>2G=1G=1F<0F<0E;1E;1D;2C:1A:2A:2@91@91=82<71<71;60;7.;7.<8/<8-@9/A;/D</E=0H?0J>0L?/M@0NA0NA0O?/O?/O?2N=3M<2L;1I;0G;/F90C9/C;0B<0B;1@<1@>2A?3B?6N;4n95—FEÄY_ÛWbßCQÞ8FÔ3;½++­1'¡8%˜:!—9 ¤;&¶>.Ã:2¾71§7,¢:-¥9/§7,¯:1¸A9ºE<·E:®>2­?0§<,¤6'ª6)¶>0ÃD;ÊG=¾8-Î@6âE@ìBBô=Aó9>ë27Þ.0Û75âGBèSLåNGÜ=9Ù10ã/2ê67Ù1(Þ</Í,"Ð71¾3,°7/Ég\¸l^ŽWC‡ZCƒV?‰R=©\LÎlaágbåUUðEKñ=Fä;@Ù=>ÒA>ÒGDÝOMëWWíNSïDMò9Gö5Fø1Fø.Dû1Gþ7Nþ8Sý8Tþ9Wÿ:Xÿ;\ÿ>aÿAeÿCkÿ<fý<hý>jý?mú>nø>oô=mö:jÿHrÿ;aÿ?dÿJpÿKn÷NmïUoãYpèr‚Ä`j˜INt:8\6-P9+PC2UM:^QAreUˆ|n•‚Ÿ‘¦§Ÿ¡¦Ÿ–œ˜•ž›ž§¤¦¯¬¦¬ª¢§£¦¨£µ´°ÂÁ½ÌÉÂÑÎÇÕÐÌÕÐÍÔÎÐÕÏÓÑËÏËÆÊ¿½À°²¯˜Ÿ˜€Œ~m~kau\XoSVjNS`FV`EX`H560560560671782893:94;:5>=8>=8A>9C@;DA<FC>HC?HC?HE>HE>ID>JE?JF=JF=MF<MF<MD;ME:MC9MC7NB6NB4N@3MA3JA2JA2I@1H?0G=1F<0D<1D<1C:1C:1A:2@91?82?82<71<71<8/<8-<8-=9.@9/A;/D</E=0H?0K?1M@0NA1P@0P@0O@-O?/O=1O=1M<2L;1I;0F:.F90C9/B:/A;/A:0?;0?=1@>2@@4Q:2r1/©KLÁRX»>D½06Â03Á//º1)ª2"£9#>"™;›< ¡=#¥;%¤6%ž6) 8-£6/¥4,®92·@:¸C<²@6±B7­A4¨</¦8+¯:0¼C8ÄE>Å@7Ã>-Ï>-Ù5+á*&í"%ú%+ÿ+2ÿ.4í)*ç.+á3,ß4,à3,ä3-é0-ç2+Ú2%Ö6&Ð2&Ï7,Å6.½>7È`UÒq¦eSVBŠM:£WIÈf[ßd_çRTèCIõFMîAEß??Ô@<É@8Æ?9ÑFAãMLïJPô@Kù9Hý7Hü5Hø3E÷6Gú;Mû9Qü7Rû6Rý6Uÿ6Xÿ9]ÿ;aÿ<gÿ>kÿ?mÿ@qÿBtÿBuþBuüBtùBpÿFmúAaþEeÿJlþKkÿVtÿ_zõ]vòj~æp~Ómx¯]aƒCAg6/hB7sUJye\Œ}v£–­£¡²®«¶¶¶²¶¹ª¯³°·½¶½Å¾ÁÊÂÂÊÄÃËÉÆÍÕÎÖÝ×ÛâÚØçÝÛéÝÝæÚÜåØßä×ààÔÞÙÏØÊÅ˺ºº¢§£ˆ’‡t‚qexb\sY[oS[jM\iK]gL561561561560561671983983<;6=<7@=8B?:DA<FC<GD?HE>HE>HE>HE<JF=KG<KG;KG;NH:MG;MG;NF;MD;MD;MD=NC?NC=MC7MD5LC4JA2H>2G=1E=2D;2C:1C:3A:2A:4@93?74<73<71>7/>7/<8/=90>:1B;3C<2D=3H@5I?3L@2MA1NA1P@0O@-O@-L?/L>1M<2L;1J91I81E80C90@9/>:/;;/<<0=>0>?1A?0S8-‡<7Ä\[ÊZY®86«.*²1+¯/&­2#¬9&¬B*ªF,¦D)£A&£A&£=$Ÿ9#¡:+£;0¦:0¦7.­<4¶C<·E;±A6«=0©=0©;.­=1»E9ÇMBÅE<¼8,¿6$Î;)Ý;.æ3,ñ+*ù(+ý&+û%'ø**õ.+ï2,ë4,è3*å3)ä2(à3%à:*Ñ2Ü?0Ï7*È8-Â?5³A6Ñl`¿gY¥RB¨NCËcZçhbæRRêAFôCKë>Dá;=Ö<<Í@9Á>4¶8,¹6.Ä94âHHé@Eð:F÷;Iú:Iø8G÷;Iû?NþAUÿ?Vþ<Tþ9Tÿ8Uÿ9Zÿ:^ÿ;cÿ>iÿ?mÿ>oÿ>pþ?rú@rø@t÷Aq÷CjÿMmÿSs÷JhìAaýTsÿg…ÿe‚÷]wï_xèg{ÜpÆqx§gg^X{ZQ—~wª™’¾°­Ä¼ºÆÂÃÈÇÌÇÇÏÃÃÏËÊØÍÉØÑÊÚ×ÎßßÔäæÛéêàëíãëïåæòèæôèèðäæîáèíàéêÝçäØâÑÊÑÁ¿Â««©‘–z†xlzibu_`rZcqWcpTcmT21/320542651875984984984;:5<;6==5??7AA9CC9EE=EE=HH@HH>HH<JH;KJ8LK7ML8OL9NK:JF:HE<JFCNIMNIPICOE>ENE>LC4J@4KA5MC9LB8F=4B90E<5C:5@93@85@85@86<74<42C97B94A96>95?:7>:7?;8@<9B?:D@7G@6J@4L@0O@-O@+L?,G@.G@0I;0K81M53L76J88F;9C@;6904</9D4:A/69$?=(bC1¼j^¹JA¦7,¥5)§7+¥5'¥7&¨=+£8$¥<&ª@*­@+¬=)­:'®6%«6%¤6'¡7)£9+¦<.ª@2¬B4¬B2¬A1©>.«=.­<,³=/¾D7ÅG;Á?2º2&Ç9+Ì8*Ð8+Ö8-Ü8.â5.é3/î1-ò/-ô.-ó0,ñ1,ê5,ä8,Ý:)Û:(Ü9&Ô3Ð3"Ï8'Æ7'¾6(ÂB5ÏSIÈMEÐTLá[Xî\\ðPRí>Cò9?÷?GêAFßCDÖBBÈ?9»<3±;/°</²<0ÊKBÔKCÜFEá>?ë<A÷?Gý?Iù;GþDQüCQþDRÿDUý@Vü<Uÿ<ZÿBdÿFkÿAjú;gõ:g÷=nùCtýH{ÿK{ÿMyÿMtøPsðOpçMiêMjüYxÿgˆÿ_ƒõGl÷Vxè_{Ã^n½z‡a^xp§‘„»§œÑÄ»ÝÖÐÝÜÚÜÛàÞÜçâÛëæ×ìëØîòØñöÝó÷âó÷çôõëôôîòùôñùôðùñïöíîóèìîãééÞäæÝâÖÐÔÍÉÊ»º¸£¥ ‹‰yƒxr}op{k}†sxlv}k0./1/0320542653873873984;:5;:5==5??7AA7CC9DD:EE;HH@HH>HH<JH9KJ6LK6ML7NM8LK9KI=KJEPPRWU`YXjVTjSO`QHKMD?H?:F=8G>9H?:F=8B;5D:8A96?74?74@85@85=85<73=31=31=52=85=96>:9>=;>=9B?:D?9G@6J@4M@0O@-P?+L@*B?,B?.F<0H:1J65I56F35@65A=::=6;>5@@4E<-J9)^B4€L>®QB«;- 2#¡6&£:'ž7$ž9%£>*¡;%§<(®?,³@.¶=,·9*¹7)¶8*ª9)¥:*¥:*¦<,©?/«A1«B/«@.®?.«:*²=,ÀF7ÆH:Á?2¼8+À6)Ë7+Ï7,Ð9.Ñ;-Ô</Ø:.à8/ç4-î1-ô.-õ/,ò1,ê3+á7*×:'Õ:&Þ;(Ù6#Õ8%Ô=,Ì;*Á5&Ä:/ÏF<ÑF?ÚIFéOOóPQôGKñ<Aõ:AøCHåBEÛEDÒBAÅ>8·;1®:-ª<-«=.¶E5ÆL?ÔNEÜGCä@Aï?Bû@Iþ@JùDM÷CLúDPÿFTþCTú?Tü>XÿBaÿGiÿCiü?iù@jùBpüFvþJzÿK|ÿJzÿHtõKpñQsõ\zù_{úWvüNqýEkúDlïEjÚKiÈ^r±nukLI~t°–‰Ì²¥äÓÉìãÜëçæêéîêçòíâóöãùûáúÿâýÿçÿÿìÿÿñýÿöþÿùûþú÷ýúõü÷ôúõòøïòôëîñèíïæëæÝàÜÖØÊÆÅ´³±ž ›Ž“Œ‰…‡‚•‡‰€†Œ~/.,0/-10.21/43/651762761:94:94<<4>>6@@6BB8CC9DD:IF=JH<JH;LI:MJ7NK8OL9OL9KI:NKBTRS_^fihxmm…lkŠkhƒ`YiYQ\OGRH@KH>GG=EE<AA;=D;<?:7=85<73=82>93>:1>:194.:5/;60<92>;4?<5?<5@<3E>4G?4I?3L@2O?0P?/P?-L?,<;&:=(?<+A;-B71A62>42;30=84B;5H94N2.Y,)l/.ˆ<>¢GF£;0¢2$Ÿ1"¤9)¥<)Ÿ8%ž7$¢;(¤;&«>*±A-¶A/¹>.¼=.¾:-¾</²<.¬<.ª:,©9+«<+­>-­>-­<,²?-°8(¹>/ËK>ËG:¼6*º2&É9.Ð6,Ô6+Ô8,Ö:.Ø:/Ý9/ã6/é4-ð0-ô.+ô.+ð0+ç2'Ý6&Ô7$Ò7#Ý8%Ü5#Ú9'Ú>/Ó=.È6)Å9,ËA7É<5Î?9ÙEAåKIêJJéCCí@BëCCÞCAÕD?ÍB=Â=4¶:.®8*«:*¬;+¬8)ÀD8ÕNHÞJHâ?Bê=A÷BKÿHRô@Iô@IùCOýGTþEUú@Uû?XþA_ÿEgÿCiÿCkÿFpÿIwÿK{ÿL|ÿJzÿFxÿHwÿKtûOuÿZ|ÿa€ýUvñCdûIkÿTvÜ?\ÍI`Ø{†¸||aC;{p®ŽÕ³§óÛÑûìåúòðù÷ú÷ôýôìûúëÿÿêÿÿìÿÿîÿÿóÿÿ÷ÿÿûÿÿýüÿþûÿýùÿúøÿøöÿôøýòöûðôùðóðçêåßáÓÏξ½»­®©¢¥ž£™£—£«žž¦—›£–/.,/.,0/-10,21-43/54/650983983;;3==5??5AA7BB8CC9IF=JF;LI:MJ9PK8OL9QL9OL=LJ>QPL^]bmlzzz’‚¡€‚¨€€¦{u—rkŠe_{YSmTLdMEZG@PB<HD?F@;?<87;63<71=90=90;8/:70991;;3>;2?=1@<1?;/A;-F?/H?0K?1M@0O?0O?/P>0L?/@=*?>,@=.?;/?;2>93=:5:94<94E:6M51V-+j)-†18ž8C¬=C§8/¥7(¥:*ª?/¨?, 9&¡8%¤;&¥:&«<)´?-¹@/¾?0Á=0Å=1Ä>2½?3¶=2²9.®8*¯9+°:,²:,³9*¶;,º<.ÄB5ËE9È>3¿2(À2(Í9/Ö5+Ù5+Ú6-Û7-Þ7.â7-ç4-ì1*ó0,õ/,ô.+ï0(ä2&Û4$Ò5"Ð5!×2Ú0Ú4&Ü<.Ö=/Ñ:/Í=2ÒD:Ä5-Å60Ê;5ÙEAãNJåKIÞC?Ö=8Ó@9ÎA8È?5¿=0µ9-±9+¯9+±;-¬4&½?3ÑHBÙHEßABæ@DôGMýNUð?Gð?GöBMþHUþHWüBWú@XüA^ÿAcÿCfÿFmÿIrÿMyÿO|ÿL{ÿIyÿDvÿN~ÿR}þKrøMoÿVuÿUu÷MjñGdðLgÒ>VádtþŸ§ÓŽd92lJ@¥ypÐ¥œõÔËÿéãÿôòÿýÿÿüÿùóÿüïÿÿïÿÿðÿÿòÿÿôÿÿ÷ÿÿûýÿüûÿýúÿüøÿúøÿù÷ÿö÷ÿôøÿôøþó÷öëïìãäÚÔÔÉź¹´³´¬±´©°¶ª¶¾³°¸­¬´©10,10,0/+0/+10,21,43.54/77/880::2;;3>>4??5AA7DA8IE:LF:NH:PJ:RK9RM:SL<RL@OJDVTUfdqwx‡‡©¹“ÃÆŽ‹À‡ƒ¶{w©pmšid_[~UPnNJaKGXFCN?=B<8995296/85,85.671783891;;1></@=,B=*C<)G?,J?-K@.L@0M@0M?2L@4K>5M@7K>5F<3B92=82:946;47<59<5>:1H4-Y2-x89”?D¦>E©8<ª;0«=,«@.¬A/©@-¥<)¦;'«>*§8%®;(¶=,¼=.Á<-Å;.Ê<0Ê=3Å?6¾>3º:/·7,¸8-¸8+º8+º8+»7+ÇA5ÍC8Æ9/Á1(Æ3)Ì8.Ï5+Û4+ß3)á4-â6,ä6-ç4-í2-ð/*õ/,ö/*ò/)í1(ã3&Ù4!Ð5Ï4×2Ù/Ø2$Ø6)×9-Õ;1Ö?6ØE=ÖF>Í@7É<5Ë@9ÖKDÙNGÒE>Å;1Å=1Ã=1À</º;,·9+´:+¶<-¹?0µ9-¿<2É@:ÒC?ÛBDãDHíJOöOVí@Fí>EòBLûIUÿJYýFXúCYûC]û@_ûBdÿElÿJsÿNzÿO|ÿLyþIvÿJwÿTÿT}ýJqùImÿStÿVtøNiëD^äF]êXkÿ–¢ÿµ¼óžŽHFk.)¦keÍ–óÈÁÿãÞÿñðÿüýÿýÿü÷þþöÿÿöÿÿøÿÿøÿÿúÿÿüÿÿýÿÿýüÿüùÿûøÿùøÿø÷ÿöøÿõ÷ÿôøÿôøýñóóéêäÜÚÖÑÍÍÊÃÉÉ¿ÊÊÀÊÍÂÉÐȾȿ¸Â¹65154/32.21,10+21,32-43.66.77/880::2<<2>>4@@6CA5JD8ME8OH8RK;TK:TM=SK>RKAQLIZW^li|~¸–™Ì™žØšžÞ™˜Ú”‘ÔŒŠÉ†…¿~µxv§nk–fe‡^[xWTiMKYDAJ><?;:8;76875557457664872<:.?<+C>*F@*G?*H@+IA.IB0IA4HB6HA9G@:K=<I;;C9:=77875384/83/917<574+C1']80~C=–GCž>?ž52¨<0ª<+ª?-ª?-ª?-©>*¬?+°?-«8%²9(¹:+¿9-Ã9,È:.Í:0Ï<4Ë>5Æ;4Â91Á8.Á8.Â9/Â8.Ã6,Æ8.ÑC9ÑA8Ã0&Ã,#Ð7/Ö<4Ó2*à3,ä1*ç2+è3,ê3-í2+ð/*ó-*ö/*ö/*ò/)ì1(á4$Ú5"Ñ6 Ð5Ø7#Ù3#Ö3$Õ3&Õ5)Ô8,Ô<1Ö?6ìYQáRJÔIBÌC;ËF=ÍJ@ÈE;À>1¼:*½;+¼:*¹:)·9*¹;,¼>0¿A3ÁA6Â=4Æ=7ÏA=×EEÝGHäIMìMQèBFê@CðBKùKTþN[üJZüF\üF_øA_ùBaýEiÿJpÿNwÿOzÿNxÿLvÿQ{ÿR{þOvýOtÿVyÿ]{ÿSoîD^úTlîQd÷dtÿ’žÿ‹•ôƒ‰Ç`d§MMµjgΊXÿÞÙÿïîÿúúÿüþýûÿýúÿþûÿÿûÿÿûÿÿüÿÿûýÿûûÿûøÿûøÿüùÿûúÿûúÿøúÿöøÿó÷ýñóùíïòææçÝÛßØÒÛ×ÎÝÛÏàÞÒßáÖÜãÛÏØÓÅÎÉ=:5;8185063,41*41*52+63,74-85.:70;81>;2?<3A>5C?4KC8MC7PG8SJ;WK;UL=UK?SJCSJK]Wcomƒ‚‚¦’”Å› ÚŸ¦ê¢©ñ¡¥ïž ë™›å•˜Ý”•Ö‘ʉ‰½‚ƒ±zy¡rq‘fc~ZWlPN\IGRFCNCAL??K==G;:@;9:=:5?;/C=-E@,F@*FA+EB/EC4CC7BC;AC>@ACB<FD>LD@NEEOCHNAIL?IJ?HECHAA=2L:.gF7ƒOAŽJ=?4”8+¥>/©>,«=,¬>-­@,¯@-°?-²=+±8'¶8)½9*Ã9,È8-Ì8.Ò91Ô;5Ï:4Í:3Ë81Ë81Ì92Í:2Ì70Ë6/Ô=6Õ>5Ò91Ì2(Î4*Ù<3Ú<3Ø4+ä1*é1)ì1*î1+ð0+ò/)ô-(ö,(ø.*ö/*ñ0)ê2(â5'Ù6%Ó6#Ï7"Ô9%Õ8%Ó6%Ò5&Ò4(Ó7+Ò8.Ð7/ãNGèXPçZSÚQIÌG>ÄD9¿@7¹>/¹<*¹<(¹<(¹:'¸9(º;*À>0ÃA4ÉD;Æ@7É@:ÑFCÕIHÖHGØGJßIKæFHèBDíDKõLSüP\ûO]ûL]ûK`öD^÷DaùFfýIlÿNuÿOxÿOxÿPy÷UzóUxôTvüYxÿ]{ÿZwûQkòI`ýWköUgêM^ö^mâKZæTaåTc×XcÁefȃ~嫧ÿÔÑÿëéÿóôÿøùÿþÿûüÿûüÿûüÿüûÿüúýýùúý÷÷ü÷ôÿú÷ÿûøÿüûÿûúÿøúÿóõýîñúëîðáäéÝÝäÙ×âÙÔæßÕëçÛñíáññåíòìÜåâÏØÕ@=6>;4:7074-52+52+52+63,74-85.96/;81=:1?<3@=4B>3JB7MC7SG9VJ<WK;XL>WK?TICSJM^Xfpmˆ„ƒ«“–Ëœ¤ã¤¬õ§°ý«°ÿ¦¬ú¡§ó ¤îŸ£ê¡á™›Ö•–Ì’’ĉˆ´zxŸji‹`]|XUpRPhOMeOKdKG^FBS@=H?:>?:6@<1A>/C@/CB0BC3BD7?D=>D@<ED;BJ>CVDHaMRhV[n\br`dobbje`dfXWaJDlG>„TF•XF“J7‘@-™>+¨A0®@/®@/¯@-°A.´A/²=+±8'µ7(¼8+Â8+È8-Í6-Ñ7/Õ81Ø;4Ò72Ñ83Ð72Ò93Ô94Ô94Ó83Ó6/ÞA:Õ8/Ñ3*Ö8/Ü>5Þ=5Ú91Ý6.ç2+ë0)ï/*ñ0+ô/)÷-)÷,(÷,(÷-)ô/)ð1)ê4)á5'Ú7&Ô7$Ð8#Î7"Ï8%Ï8'Ï6&Ð7)Ò9+Ñ7+Ï5+Ì5,ãNGód\ë`YÕOFÄA7º;2µ9-¸>)¸>'º='¹;%º9&½9*À</Ä>2ÊD;ÊA9ÎE?ÕKHÔMJÎGDÍEEÖHGãIIæCDéFIòMSøSZùR\÷O^úOaôH^õG`øGdûIiÿNrÿQxÿRyÿTzðUuïZxù^}ý^|ùTrõMgùOiÿYnÿ[mÿctðM^øUfôO`üUgõL_äR_À^_»vqל˜úÉÅÿåãÿííÿôôÿÿýüÿÿûÿÿûÿÿûÿÿýýýýûüþøøýøõÿøõÿùöÿúùÿúùÿöøüðòøéìôææëÝÝèÚÙäÙÕèÝ×ðèÝùóåÿúìþþòõúöãìëÔÝÜB>5A=4@<3>:1<8/:6-84+84+62)62)72,83-;60>93A<6E>6I@7MC7RF8UI;WJ:XK;ZLA[NHTIMXR`gd|~§’Ê— ã ©ö¥°ÿª³ÿ«²ÿ¬´ÿ¬²üª±ùª¯ó¨¬ì©«èŸ¡Ú™šÒÁ±ur¡he’]Z‡XR~XQ{YQxVOpNI`C?M?:@?;:B?8>>4AC6BE:?D=<B>:CB>FH?LUEWoSf„bqŽisŽtvx„o€_mŠ[c“XZžWU¦VM¦M?Ÿ@.:% :$¨=)¬=*®?,±@.³@.´?-¶=,¹;,º6'¿7)Ä6*Ë7-Ñ7-Ö8/Ú91Ú83×84Ø95Ù:6Ø93Ø61Ø61Ú83Þ;4çD=à=6Ú70ã@7þ[Rÿlcÿ]Tç?6å3)í2)ñ2*ô/)ô*&õ(%ø((ø**÷-+ó0,í2+ã1'Ú0#Ô1"Ô4$Ó:(Ì;&Ê<(Í<)Ï<*Ò:,Ò9+Ò8,Ñ7-Ú@8Ï81ÜGAôc^åXQËB<ÆA<·4*·:&¶<$¹<&º<&½:(¿:+Ä<0Æ>2Ç>6ÌC;ÙPJßXTÔNKÃ?;À?:ÏHDßIHâGEæJKïPTñRWïNVîLYñL\ùRføOf÷Jf÷JhüMnÿQuÿRvýRvôWvîXuõXwû[wÿ\xÿZsÿWnÿVkÿbuýVgÿ\mÿ[lñFXôDXÿQeîVeÆfgªieʋ網øÒÏÿêéýïîüø÷ùýüùÿÿùÿÿúÿþüþýÿýþÿúúþöôþùõÿû÷ÿùöÿöôÿööÿõõöèèæØØãÕÔÞÐÍáÖÐñçÞüôçþøèÿüéÿÿóúÿùèñðØáàC?6B>3A=4?;2=90;7.:6-95,73*73*72,83-:5/>93A<6D=5H?6LB8OE9TH8VI8WJ:YK@ZMGUJNXP_fay{¤ŠÉ”⛦õ£®þ«´ÿ¬µÿ®¶ÿ¯·ÿ°·ÿ¯¶ü¯´ø¯²õ©ªë¢£ã˜˜ØŒŠÉ€»uq®jf¡d_™`WŽ`VŠ]TVPtMIbFCTBAIAAC<<:AB=FEACD?A?@DBEOMRWVdch†quš}¢ˆ}Ÿ”|œ |˜¥pŠ¤`u¬Yi¶VaºQU¸HF°@4¬;)¬<&®>(¨8$¨7%¬9'®9(±9(²9(µ7(¸6(»3%Â4(Ê7-Ó:2Ù<3Þ=5ß<5ß<5á>9ß<7ß<7á>9åB=èC=èC=æA;å@:æB9ä@7Ü8/Ô1(Ø5,ëH?ÿZQñ@6î6,ë,$î)#ø-)ÿ//þ,-ö((ú0.õ4/ï61ç6.Þ3)Ö2&Ô2%Ï6&Ë:'È;'Ê<(Í:(Ï9*Ð7)Ñ5)Ñ5)Ô:0Ï5-Ô=6åPJåTQÛLHÍB?·1(¼;(»=&½<'¾;'¾9(Á9+Â:.Ä:/È>4ËB:ÕNHÝXQÓRLÃD=¿C;ÌHCÛLHßJFåMLëSRíTWëPVéNVìOZ÷VføUhùSkúRlþQoÿRsÿStÿRuòMmøUtÿ\|ÿ_}ÿ\vÿUoûRiûReüUg÷RbÿZjÿZjóN^øScþYißS^¶`_—^W¶}Ù©¥îÈÅýáÞùééýøõúüùùÿÿøÿÿ÷ÿýúþýÿÿÿÿûûÿö÷ýøõþùõþùõþöóÿ÷öÿõõöêêêÜÛäÖÓÝÐÊßÕÌïåÛüõåÿùçÿýéÿÿïúÿøèñîÛáßFB7EA5C?4A=2?;0=9.<8-;7,84+84+83-83-:5/=82?:4A=4F?5JB7ND8RF6TG6WG7WI<XKCWKKXP]b^ysuœ…ŠÂ™Ü˜¤ð «úª³þ­µþ¯·ÿ±¹ÿ³ºÿ´»ÿµ¹ÿµ¹ÿ¯²ù¬¬ô££ë™—àŽÓƒ€Çxu¼sm³k`¤i]›cZ‘]W…VRwNKhEDV@@L85<A<@KABL@BQ>B[FKpW]‚cu—s—¤{§®«²{£¸vœÀp“ÂcƒÀSpÂF^ÐK\ÑHRÄ<<º5.¸9*µ<'°<%°;)°;*²:)´;*·<,»<-À<-Ä<.Ä6*Ë8.Ó<1Ù?5ßA8á>7á=4ß:4Ý84Ù40Ù40Þ93çB<ìE?éB<ä=5ã<4Ü5-Ø4+Û7-Ô2'Ì, Ö6*éG:õK>ò@6ï4-ð-)ö,*û-/ü+.ø*,ð*)ì/+é3/ã5.Ü4+Ù2)Õ1'Ñ3'Í7(Ë:)Í:(Ð:)Ò;*Ó:*Ô8+Ô8,Ñ4+Ö<4Õ:5Õ<7åONíYWÙEEÂ3/Á<-¿<(À;*À;*Á9+Á9+À8,À8,Æ=3ÇA6ÏJAØUKÓSJÆG>ÀD:ÇG>ÖKDÙJDÝLIäSPåSTâPSâMSåNWòXdöZhý[pþZrýUoûQnýPnÿQrýGmÿPvÿZ}ÿ[{ÿVrýSmþVmÿ\mûXiøZhû`nö`lí]gïfnìfmÉ\_ ]W{OF˜mfÁ˜”ݺ¸ðÔÓôàßÿõôùù÷ùÿýùÿÿ÷ÿÿúþýÿÿÿÿýÿÿøùüøõüùôüùôýøôÿùöÿøöùîìïäâåÚÖÛÐÊÜÒÈîäØýöäÿûèÿýçÿÿíúýôêðìÞãßIE9HD8FB6EA5B>3A=2?;0>:/:6-:6-94.94.:5/<71?:4@;5C?6HA7LD7OF5SF5UE5UH8VJ>YNLXNW^Zqpp–€†ºŒ–Ô•¡é©õ¨°ù©±ù­³ý°·ÿ±·ÿ²¹ÿ´¸ÿ´¸ÿ¯±ü«­ø¥§òŸžê—–⌋׃€Í}yÅum¶pgªf`ž_ZYX„QQuGGcB?R=5DH8BT=C`@EnCJ€OU—^gªgx½kÉnšËo˜ÉiÈ`ƒÉWxÆIgÄ;UÆ2HÙAPàDOÑ;=Ç82Ä?0½@,±:$­5$­5%¯6%³5&¶7(½9,Ã;-È</Ó@6×@7Ú@6Ý@7Þ=5Þ93Ý6.Û4,Ó.(Ò-'Ó.(Ø3-á:4ã<4á81Ü5-Ü5-Ð,"Î* Ù7,âB6Ü>2Ñ5&Ë.éF7óI<ýH?ü<9ô,,ñ#%õ')û/2ñ-.ì0/ä2.Þ3,Ú1*×0*Ö/)Ó0'Ó7+Ò9+Ö:-Ø<-Ú>/Û?0Ü@3Ü@3Ò6*æLBåJEÎ50ßGFóZ\ßIKÕA?È</Ä;+Ã:*Ã:*Â:,Â:,Á9-¾8,Â<1Â>2ÈF9ÏOBÎPDÆH<¿C7ÁC7ÎH?ÑF?ÕJEÛPKÝROÙMLÚKMÝLQëX`ó[güaqÿauûWoõNhõMgÿMmÿOuÿRyÿUwÿTqüTmý[pÿcuÿizÿguúboõamídnãflÙhjÎghµfa^TeG<^U©ˆÍ«©æÈÈïÚÙÿóóùøöùýüøÿÿ÷ÿÿûÿÿÿþÿÿüÿÿùüþú÷ûúõûúõþûöÿýùÿûøþôòøíéêßÙÞÔËÝÓÉíæÖÿøæÿþèÿÿæÿÿëøúïêïèãæßNH:MG9LF8JD6HB6F@4D=3D=3?80>7/=60=60=60?82@85?:4C>8EA8LD9NE6RE4RE2VF6VH;ZMGVMR[Whlk‹~‚±Š“Δžãœ¦î§­÷©¯ù­°ý¯³ý°³ÿ°´þ°³ÿ¯³ý«®û¨«ø¤§ô ¢ïšœé“•âŒ‹Ù†…уÉ|v¼mk¬dež_a’Y[„RQsNHbWFY_CQmBL‚FP˜LV¬U^¼[dÊZhÙRpâRußTuÙPlÒJbÍBWÇ8JÅ.?Ô8EãCMæGLØ>>Í>8ÌF:ÃH6·@,·>-¸=-º<-½>/Ã?0ÊB4ÐD7ÕE:ÙE9ÚB7Û>5Ù;2Ù6-Ù5,Ú3+Ù2*Õ0*×4-Û60Ý90ß80Þ7/Ý6.Ý6-Ö/&Ú6,Ø8,Ï2#Î2#Ò9)Õ>-Ô;+Ø<-èD8øJAýDAù56õ*-ö*-÷/2÷67í55ã41Ú1,×0*×/,Ù0-Ú1.ã81ä91ã;2â;2á=1ß=0Ü?0Ú>1Ñ7+ïWLøaZÓ;6Ñ;:æPQÜFHæPQÏ<4Ê:/Æ8,Å9,Ä:-Ä<.Ä<0À:.¾:-¾<.ÃA3ÇH9ÇI;ÂD6¾@2¼>0ÉF<ÊE<ÎIBÕPI×RMÕNKÔLL×LOéZ`ð^hüetÿhzü]qóOgóMeýNkÿVzÿTxÿRrøTmö]qûhxûjw÷erüetó_mì`kêktßruÃjfªd\žla}fVYI:kXJ”{t½ œÞÂÁîÕØþîïûõõûûûûÿÿùÿÿýþÿÿþÿÿûÿÿúýÿþúûþõûüöÿþùÿÿúÿþúÿûõÿ÷òñèáäÜÑáÙÌðé×ÿùæÿþèÿþåÿÿê÷ùëíðçèéáQK=PJ<OI;MG9KE9IC7G@6G@6B;3A:2@93?82?82@93A96@;7B?8EB9KE9MF6PE3RE2VG4UH7YLDUKLZScii…|«‰“È“žÞš¤ë¦¬ø©¬û¬­ý­°ÿ®±ÿ®±þ­°ý­°ý©¬ù§ª÷¤¨ò¢¦ðŸ£í›Ÿé–˜ã’”Þ’’Ú‰‰Ï|€Àty³ou©mpigŽj_}y_x‚WjŽP_£O\»S^ÍT]ÖPWÛHRå@Qè?RäCRÜDPÖCKÏ@DÊ9<É46äJLçIJáAAÖ87Î95ÎA8ÈD8¾>1ÃE6ÃE6ÅF7ÉE8ÎF8ÑG:×G<ÚG=Ö>3Õ;1Ö8/Ö5-Ö3*Ø4+Û4,Û7.Û81Þ;4à=4à<3Ý90Ü5-Ü5,Û7-Ò.$Ý;0Ú=.Í1"Ç.Î7&Ò<+Í:(Î8'Ô8)â:1ó=9ÿ@@ÿ<>þ37ó,/ê,.á+*Ø*)Ô+(×/,Þ44ä88é9;ð88ð75î73è71ã7-Ü6*×5(Ñ5&Í5(çPEÿmcÛHAÈ42×CCÔ?CêVVÙA<Ò>4Ë80Ç7,Æ:-Æ</Ã=1Á=0¼:,»<-¾?0ÀA2¿A2½@.¼=.»<-ÄD7ÄD9ÈH?ÐPGÓRLÑPJÒNLÕONç_cîaiûitÿm|ÿdwõVjõQiÿUoÿWvÿVtúXpñ^pônyöw€íksÞXañ`mñ`mìboïs}숊Ì|ªth™yjskXON<_VG„rh¯–’ÜÀ¿ïÕØüéëþó÷ýûüýþÿúþÿþýÿÿýÿÿûÿÿùþÿÿûùÿõúýöÿÿúÿÿúÿÿúÿý÷ÿþöùðçíåÚéáÔôïÜÿûçÿþåÿÿãÿÿèùúêòôçîðåSM=SM=QK=OI;MG;KE9JC9IB8E>6D=5B;5A:4@93A:4B:7@;7A@;CC;IE:MG7OG4RF0VG2UH5WJASIHXR^jg‚}§‹“Ä’žÚ˜¢ç¤§ö¦§ú«©ü«¬þ¬­ÿ­®þ¬®û¬®û¨¬ö¦ªô¤¨ñ£§ð£§î §íŸ¤è¢æ™žâ”™Û‹“҆ʃ„ˆ·ƒ¨ˆyšmˆšcz©Xi»Q_ÐNZàIRèAIê=Aé=;ä?9ÝC9ÖH:ÎI8ÆG4ÂC0Å@1äTIàG?Ú;7Ø64Ø88Ù;<Ñ98È74À:/¾<.¿;.À:.Â8+Ã7*Æ3)Æ2(Ï5+Ð3*Ñ3(Ô3)Ö3*Ù5,Ý6.Ü8/ß>4Ý<2Ü;1Û8/Û7.Ú6-Ø4*×3)Õ3&Ó3%Ð4%Ð7'Ò=)Ñ>*Ê9$À2È:&Ê4%Õ1(ç51ú<<ÿ=@ÿ8>÷37ê-1á-.Ù--Ø0/Ü43ã9:é;=ð9=ö26ø03ô01í1/å2+Þ2(Õ1%Ï3$É1$Ñ=1új_äTLÈ95Ð@?Ë:=äRSäJHÜC=Ñ94É6.Ç9/Å;0Â<0¿=/º;*¼?-¾A/¼?-º;*º;(½;+¾<,¼>0¼>2ÀD:ÈLBÌPHÊNFÌLIÐNLç`dìahøhrÿo{ÿhx÷Zk÷UjþZrÿYsû]tîaræjtë}€ñ‡‰èwyÚ_dñgtþm|óeuëlwö‘•ì¢ŸÄ”Š¢|ikVHQ<WUFtg^¤ŒˆÛ¾ÀòÕÙùãæÿóøÿúüþþÿüýÿþûÿÿüÿÿúÿÿøýÿÿûùÿõ÷üõýÿùÿÿúÿýøÿý÷ÿÿöÿùïõïáòìÜúõáÿýçÿýäÿþâÿÿçýþìùúì÷÷ëVO?TN>SK>PJ<OG<MG;LD9JC9H?6F?5E<5B;3B92A:2C:5A<6C@9DD:JF;MG7OG2QF0TH2UH5UH?QGFWQ]jh€~‚¨Œ”Å“Ø™¢çŸ ò£ ÷¦£ú§§ý¨ªÿ©«þ©¬ý§­û¥«õ£ªò£§î¢§ë¤©í¦©î¥¨í£§î˜ è– å”Ÿß”Ÿ×•›Íš•¾ Œ¯ªƒ ¥e´]pÃRdÐIWÜBNå>Fë<Aì<<ë@9ãA4ÜE4ÔI4ÊI3ÂF.¿B,Â?-âSEÞD<Ý97æ>>êDFå@DÙ8=Î65ÍB;ÉE9ÉC8ÇA5Æ>2Ã9.Â5+Â2'Æ2(Ë3(Î4*Ó5,Ø5.Ù4.Û4.Û4,äA8Þ>2Ù7,Ú6,ß8/à:.Û5)Õ1%Ø8(Í2 Ê1!Ï9(Ï9(Ç4"Ê7%ÔC0È7&Î8*Ø7-Þ5.ç40î53ö:9û?>ÿLKúHFòBBì>?ê<=è8;å26æ+2ô+1ø)/ô,.ï/.è1+à4*Ù5)Ó7(Æ0!À.ôdYë]SÏ@:ÔDCË;;ßMMêRQàHEÔ<9É6/Æ8.Æ9/Ã;/¾:+¾<,Á@-ÀA.¼=*·8%¸9&½<)¾?.µ7)´8,¸>3ÁG<ÅK@ÅIAÆJBËJEåa_æ^`ñdjþnwþkuó]iðXeø]mú^sõbtèdqãlrì~ù‹ö†…éqsøryÿy†õaqàXföˆ‘ÿ´´Ð®¢ ›‡]jPDR9QTAjbUœ‰‚ÚÀ¿òØÛöàãÿô÷ÿúýÿþÿýüÿþüÿÿýÿÿûÿþùýûÿúôÿôòþòùÿöüÿöûüôÿýöÿÿöÿÿóûõç÷ñáþùåÿýçþüãþýáÿÿêÿÿñýýóüüòXNBWOBWMAUM@TJ>RJ=RH<PH=MC9KC8KA7H@5H>4G?4H>4F?5GC:GE9JF:NI6RJ5UJ4VK5VK9XNEULMZTbkhƒ{~§‰Ã‘™×˜Ÿç£¤ö¥¢ù¤¡ü¡¢ü¡¥ÿ¢¨ÿ£«ÿ¤­ü¡ªõ¡©ñ¡¨ì¥¨íª©ï­©ó±©ö¬©ø ©ø—§ò’¡â–ŸÖ¦£Î¶ž¾¹…œ¸gz¿L]ÑERß>Mç;Gç<Dæ=Bà@@à@@â>?ß<=ÝEBÉ:4ÊD;ÊE<º1)ÜKFèJIéCEë>Bé<@æ<?á=>Ú<=Ô<;ÏB;È?7ÊD;ÑMAÍK>¿=0¸6)½9,¿7+Ã6,È5-Ë2*Ñ/*Õ0,Û2/Þ50ç@7ß9-Ú2%Ý3&å9+ç;-ß8(Õ2Ï2Ì4Ê5!Ç4"Ç4"Ê4%Í5(Ï5)Ê0&Í3)Ñ5)Ò6*Ó5)Õ3&×3'Ü4)à2)æ3.ë52ë33é/2ç-2è-4í.5ö-3ö+/ï+,í0.ê5.ã9,Ù7(Ð4%Ã-Ä3"çXHéYNË;3ßNIÅ41ÚHHáOPÜJJÔBBÍ<7È80Æ8.È:.È<-Æ=+Â;(¾9&¼;(»<)»>,º=+·<,´8,µ;0¹=1»?3»?3¾@4À@5ÄA7ïjaõpiêc_ômjûqqìadôgmÿpyÿlzûhxðdoébiëdjîlnîqoîqoûy{ÿ}…ùZlücwßbpû¬¯¶ªš}‘u]rQJY:LR8snZ¥•ˆË·°íÕÓÿîðÿöùÿ÷ûýøüüüþÿÿÿÿþÿÿþÿûÿþðÿôåþëæûêïÿðøÿöüÿôþÿóÿþñÿýñÿûîÿúêÿùæÿùãÿùáÿùáüúåÿÿõÿÿûÿÿûYOCYOCXNBVL@UK?TJ>SI=RH<ND8ND8LB6KA5J@4J@4J@4IA6GC8HD9LF8OH6RJ5SK4VK7TK:XNEULMYUckhƒ{}¦†ŒÀ•Ó–šáŸžì žò ôžŸù¢ýŸ¦ÿ ªÿ¡¬û ¬ô «íŸ§è¢¥è¥¤ê©£í« î¤Ÿï §÷š¦ðœ¡á£œÐ±˜À¿ªÂq„ÄTbÑCOâ<Fì8Aï7?ê:=å<?Ü@AÛACà<CÛ:@ÚADÌ<<ÍCAÊ@>Á31åOPçDGé@Eê;Bç8?â8;Ü9:Õ:8Ï;7ÔE?Æ=5Æ=5ÌG>ÌLAÂD6¸:,·9+¹7*¿7+Æ6-Ì5.Ò3/Ø3/á55ä84å>5á;-Þ6)ß5&â6(á5'Û6#Ó4Ñ9$Ë9"Ç9%Ç:&É<+Ë<,Ì8.Î4,Ó4.Ö5-Ó6-Ï7)Ë5&È5#Ë4!Ï4"Ø2$Þ2(ã0+æ.,æ,-æ,/æ-2é/4ì+.í,-ì0/è2.á5+Û5'Õ8'Ò9'Õ?.»*ÖD5Ñ?2ÙF>ëVPÚB?ØBAçUVâRRÜJJÔC@Î>6Ê:/È8-Ç8*É<+Ä;(¿:'½<)½>-º?-¹@/¶>.²:,´;0·=0¸>1º>2½?1ÁA4ÅC5ëi\òmdçb[ðkfõolèbañklütxÿq~ÿo|öhtí]fêY`ñbf÷qpþzxûvwÿx~ùRdþ[pä]nö¦©©¦“jŒk[sOO_;SZ;us\©ÖĺöáÜÿôóÿúûÿúûÿûüüüüüþýûÿÿúþÿõÿúíÿóáÿéáýæéÿëóÿñøÿòýÿòÿÿñÿýïÿýíÿúéÿöåûóàúòÝüôßü÷äýúóüüúÿÿý\PB[OA[OAZN@XL>WK=WK=VJ<SG9RF8QE7PD6OC5OC5OC5MC7KD:JF;MG9PI7SK6VK5VK7TK:WMCVMNZWbkiz|¢…‰¹‹‘Ë‘–Ö˜˜Þ™™ãš™éšî› ô£÷Ÿ§ø ©ô ªïž§èœ¤ãœ¢àžŸàžáŸ™ãœ˜â–›ßššÚ¤•Ð±ŒÀ¿‚¬Çr“ÉYqÈCT×ALß>Dã=?å==å<?ã=?á>Cá=Dà<C×8=Ö@BÏA@ÊC?Ã<8Ä96éWWàBCä>Bè;Aã8>Ü68Ö66Ñ96Í<7ÕHAÄ;1¾5+ÅA5ÍK>ÆH:»=/·8)º6)¿7)Ç7,Ï6.×50Þ71æ87é=9×3*×5*Ú6,Ü6*Ý5*Ý7)Ú:*×>,Å4!¿4¹4!º7#¼8)¾9*¾4*À-%ã?=å>8ß>6Õ<.Î8)È7$È7"Í8$Ò7%Õ3&×/&Ù.'Ü/+Ý/.Û//Ü./Û,)ß0+à5.Ü5,Õ3&Ð4%Ð9&Ñ>*ÔA/Â1 çSEÒ;0ÚA;ÞC?éKJðTUíTVèTTãOMÝIEÖC<Ï<2Ê7-Å6(Å8'À7%¼7&¹:'º=+·>-µ=-²=,°:,±;/µ<1µ=/·=0¹?0¾C4ÃE7Ü\Qêg]äaYðlgöpoçabìfgójqàR^ï^kõgsòemñ`gõfjùqqþxwútuÿnuóJ]øRhä[mñœ¡£œŠb`VoHRd>W`Axx^­¥’áÑÄÿîæÿøñÿüøÿþúÿþúýÿüûÿýûÿÿùÿýóÿ÷èÿîÜþãÚøÞáùáéüæïüèöýëýþîýúëÿúêÿøçúñàôèØòçÕöëÙøñáþúñýüøÿþû\PB\PB[OA[OAZN@YM?XL>XL>UI;TH:SG9RF8RF8RF8RF8QG;LE;KG<OI;RK9TL7WL6WL8WK;VLBUMK\V`jh~yy›‚…²ŠÂ”Γ•Ò•”Ö••Û–˜ã˜›è˜žìš¢í›£ëœ¥è™¡ß–ŸÚ•›Õ”˜Õ•–Ö’“Ö‘Ò…„½‘ƒ¶¥}±·s¢ÈfÓW{ÕGaÔ<KÞAJàBCÞCAàB?áAAä?Cç=Fç=Fã?FÖ:>Ñ?@ÑEDÆA<º61Å>:êZYÝABã@Cæ=Bã:?Û89Ó97Ð<8ÎA8ÏE;Â:.»2(À</ÇE8ÄE6½>/¸9(½8)Â9)Ì9/Ò:/Ú91à91è;7ë>8Ù2,Ù2*Ü3,Ý5,à5-ß7.Ü:/Ö=/É7(Æ:)Á<+¾<,¿;/Á;0Å<6Î95ëCBîA=ä@7Ú<1Ï9*É8%È:&É;%Ð=)Ð7'Ï1%Ñ1%Ô1(Ö3,Ô1,Ñ/*Ó2*Ó5,Ó7+Ð6*Í5'Ê7%Ì;(Ì>*Ì;(Ï<,ô^PàF<Ò3/Ó/-æ@@ûWXÿtuÿrqÿjgö^YçPIÕA7Ç5(½. Ä8'À8(»8&¸;)·<,µ=-²=,°<-¯;.®=/°</°</±;-¶>0¼B3ÀF9ËMAß`Wâa[ôpløstæ_cä]aæ]dÖHTçYeógrôgoöelükpþsvþvvûpsûenñDXôKbåXkë’– •ƒ_zYRkCSh?\gEy|_°ª”çÜÊÿõèÿùðÿûñÿýôýÿ÷ûÿúùÿúöÿøòüôêúíÚøÞÎóÒÊëÌÏìÎ×îÔàïØéòÝò÷ãöõãûöãüõãõìÛíáÑéÝÍíáÑñèÙüõíü÷ñþùó\PB\PB[OA[OAZN@YM?YM?YM?WK=VJ<VJ<UI;UI;UI;UI;TJ>OG<OI=QI<SL:UM:XM9YL9XL<UKAVLJ\U]hexut“|~¥…‡·ŒÂŽÃÈ’Ï’“Ô’•Ü”–à”˜ß•šÞ—œÜ”šÖŽ”ΉDž‹Å‡Ã}ƒÁ~¸}tŸŽp”¨gÁ\„ÖNvâAcè:Uê9KæAGàECÜGAÛGCßEEæAGî<Jí=JæBI×>AÐ@?ÐIEÀ?9´3-ÈC<àUPÜDCáACä@Aá>?Ú?=Ô@<ÑD;ÏF<Ç=2À8*½5)½9*À>0¿=-½;+½<)Â:*Ç;*Ï;/Õ;/Û8/á90ç83é:5ç:6å63ä20æ21è43æ40Ý2+Ô0'Ì2(Ë7-É;1Å8/Á3/Ã40Í;<Ý?@ë8;í76ä71Ø5,Ì4&Æ5"Ä7#Å:%Ë=)Ë8&Ì4&Î5'Ô8,Õ;1Ó9/Ð8-Ð>1Ê;-Å8'Å8'Ç:(Ç<)Ç<)È;)Í>-Í:*Ø>2áC:Ô/-ä::à24à67×53Ö;7ÞC?æKFêQIëTIèTHäUGË?0Ä?.¾<,¸=-·=.´>0°?/®>0¬<.¬<0­=/¬<.­<,±=.·A3ºD6ÇMBÝbZàc]ïolôrrå`cå`eç`g÷kvûoz÷kví`hð_fýlqÿy|ÿy|úmsø^jóAWõD^èUh懤“ƒh€^[tJ_vJhwP‚ˆf³²–èâÌÿúéÿýíÿþïþÿòûÿôøÿôôÿñíûêåñãÚíÙÆèǻ伺޺¿Þ¼ÇàÀÍâÃØæÌãëÓìîØóðÝ÷òßóêÛìàÒèÚÍêÜÏïáÖòèßñèáòéâ[OA[OA[OAZN@ZN@YM?YM?YM?XL>XL>WK=VJ<VJ<WK=WK=XL>QI>RJ?SK>UL;XM;YN:ZM:YL;XL@ULGYSWe^nnjƒut–~}¥„…±†‰´‡‰¹Š‹Á‹ÈŽÏŽŽÔÕÓ”Ó‹Ê„‰Á|¸u|²ov­io«ljœ€kŠ”dz®YvËPoãBdð7Vö4Lø9Iï@EåFBÝJCÛJEáGGèCJò=Nð>NäCI×BDÌA>ÎID»<5°4,ÊJAÕLFØBAÚ>?Û;;Û=<ÙA>ÔE?ÍG<ËG:À8*Á7*À8*¾9(¼8)¼9'½:(À;(Ä;)Ê=,Ò<.×;.Ü8.á6.ä6/è50é32è./ê-1î02õ47õ79î45æ21Ú.,×4/Õ63Ñ32Ï/1Ò/4Ü7>ê:Dí06î02æ21Ü3,Ñ5)Ê7'È9(É<(Æ8$É6$Ï7)Ô;-Ú>2ÝA5Ý@7ÙB7ÓG8ÉA1Ã<)Á:'Ã<)Æ=*Å<*Å8&Ì:+Î8*Í0'æC<Û2/ï?Aã.3Ú*,Õ1/Ó6/Õ83Ö92Ò8.Ì5*Æ2&À1#ÎE5ÆA2¼=.µ:+±9+¯9+«:,ª:,¬<0«=0¬>/¬<.«<+®=-³?0µA4ÉSIàg_ßd_èkiînoæchðjqõoxúp}üs}ömwîbködnÿrzÿx~ÿquúipøWfùAYô@[êQfâ}ƒ­–†zŽkn‡]o‰ZyŠ`—r¶·˜ßÞÂùôÞüúåÿÿïûÿïõÿïïÿëçúäÜïÙÑãÍÅÞÁ±Õ¯¨Ó¦ªÐ§°Ó«¶Ô®¼Ö±ÉÚºÒßÁàæÌèêÔòíÚóêÛîâÖìÛÑêÙÑìÛÓéÚÓæÙÑä×Ï[N>[N>[N>[N>ZM=ZM=ZM=ZM=ZM=YL<YL<XK;XK;YL<YL<YM?SI?TJ>UL=XL<YN<ZM:ZM:ZM<ZN@VKEXOR_Wbd_sjfsozzž|~¤~€©‚²ƒ„¼‡…ƈ‡Ë‰ˆÌ‰ˆÊˆˆÈƒƒ¿|}µvw­qr¨kl¤fg l`Ž‚_s•V_³N^ÒJ^ì@Xø7Lþ3Fþ9Có?BéD@áHBÞICâFIéBJò=Nï>NÝAEÔFDÈA=ÉHB´:/±7,ÏPGÊC=Ï>9Ð64Ð21Ð53Ó>8ÒE<ÉG:ÃD5À8*Ã:*Â:*¿:'½8'¾9&¿:'Á:&Å:'Ë:)Ó:,Ù9+Ý7+á5+å4,ê3-ë*+ñ*-ø-3ü/4ÿ17ÿ39ÿ49ý58ù8;õ8<ò9?ò9Aô9Dø8Gû6Hþ5Gô+5ô-2í12ã4/Ù6-Ð8+Î:,Î=,Ë5&Ñ8*Ù;/à>3â>4ä=4å>6ßA6ÙJ<ÐH8ÉA1Ä<,Ã:*Â9'Æ8*È9)É2'Ó9/á@8ëD>Þ0/à..ì59è58Ø3/Õ7.×82×:1Õ;1Ò;0Í:0É;/ÖL?ÌF:¿@1´9*°6)¬6*«7*©8*¬;-­=/®>0­=/¬=,«<+­<.±=0ÁLBÚc[Þc^èkiðosêinõrzüvîfr÷oyùq{öjsþlvÿwÿu|ùhoùcn÷RbþB[÷<YêKaÝt{µš‰žz}˜k{—f‚•h‘u¬²ËÌ­ààÄéìÑîöÞåóÙÙíÑÏæÉÅÞÀ¼Õ·´Ë®¬Ç¤šÁ”–‘™Ã“¡È™§Ë¬Ë¡·Í§ÁÒ°ÎÙ»ÙÝÄåâÏìåÕïáÖëÚÒçÒÍãÐÊàÏÈÚÌÃÕǾ[N>[N>ZM=ZM=ZM=ZM=YL<YL<ZM=YL<YL<XK;XK;YL<ZM=ZL?VJ>VJ>XL>YN<ZM<[N;ZM:ZM<[OAWMDWML\RZ^Xfb]qjfspwv–xxœ|{§~µ„¿‡‚ň‚ȉ„Ç‚}¿y·zu­xq§vo¥tk¢pg za‹„P\™HG³EHÓHOîBNø:Fþ6Aÿ:Aõ==îA=æDAãEBäCHèAKî=Më?MØ?BÑGDÅA<ÄH@²9.³:/ÑUKÃ>7É83Ç/,Å*(È/*Î;4ÍC9ÃC6¼>/Á<-Ä;+Ã<)Á:'Â;(Ã<)Â;'Ã8%Ä5$Ê7%Ô8)Ù7*Þ6+á3*å3)ë3+õ33ÿ58ÿ8<ÿ4:ÿ-2ÿ(-ÿ(/þ+1ü-3ö)0ò&1÷)6ÿ,?ÿ*Aý!:ó/ö"1ó'0í,1æ0/Û2-Ô3+Ñ4+Ð6*Ô6+Ý90æ=6ë>7ë:4è71è51â92ßH=×K<ÓE7Ë=/Ä6(Â3%È5+Ï8-Î4,Ô6-æC<à93à21Ò ì89å55Õ0*Ò4+Ò4+Ï5+Î6+Ê6*È5+Å7+ãYNØRFÊH;¾@4·;/µ;0µ<1µ<1¯9-±;/²>1±=.¯;,­9*­9,®:-±<2ÐYQÜb]ìppôvyîmrõq|ör}ÿz…ÿ‰ÿx‚ôhq÷epÿq|ÿuÿkvø^jöOaÿA^÷8WéG^Ûntº‹™©…‚žn}™f€–gœq¡©„´º˜ÈÍ­ÕܽÌÙ»ÁÔ´²Ì©§ÂŸž¼˜š¶–²Œ°‡‰³†µ¹„•À‹œÂ¡Ã‘¨Å™²È¡¾ÎªËѵÚÙÄæßÍêÞÒéÖÏáÌÉÛÆÃÔÁ»Î½µÈ·°ZM=ZM=ZM=ZM=ZM=ZM=ZM=ZM=XK;XK;YL<YL<YL<ZM=ZM=ZL?ZLAZLA[M@[N=]M=^O<\O<\O>YM=YLCXMIXNO[QY]Ub`Yia\rjfokŽsp›vq§{u³„}ÁŠƒÉŒ‚LjÀŠ~¼ˆy²ƒr¨‡s¨t«‡l£†\„GN¤B9¶@<ÍC@Þ@?è:;õ=?ÿDE÷><ô>=í?@ê@CëBIêCMëANãALÑ??Å@9¾?6·>3°</²<0ÀD8ÒMDÈ72Ô:8Í2.Ì3.ÖC<É?4µ6'»>,»6%Á:'Ã<)Â;(À9%Â9&Æ;(Ç:(Ë:'Ð9(Ö6(Ø2$Ú."á0&ì7.õ=5õ82÷40÷0-ø**û&(û%'û%'û$)û&,÷!)ø".ÿ'7ÿ(>ÿ!;ÿ7ý1ÿ'8ï#.æ#+ã+-Ý--Ô+(Ó.*Ü41â64è64ï77ò65ó23ï./î,,å/,Ü92Ñ:1Ò91ìSK¼#Ä+#ßF@È.&Í.*Þ<7èE@â:7Ø/*Ú.*â51å<7ß>4Õ;/Ï5)Ë3&Ì5*Í;.Ë;0Å8.ìbXàZOÈC:¹6,º:/¸8-±3'´6*±1&°2&®2&°5&°6'²:*´<.³=1°:0ºC;Ö\Wìppñsvöx|ûyƒõq|ÿ|„ýw€út}üs{ÿr~ÿr~ÿmyÿgtü`nôI\ÿ>\ÿ>]ä@XÔelµ”’ |ƒm}™f~”c‡—j”Ÿwž¦ §…œ§…’£Š£|€Ÿvzšqyšo|r vƒ¤u‚­wƒ³y‹¸‘¼„•¾†—¾‡œ¾Œ¢½§¼“±¼š¾Â§Ï̹ßÓÇãÒÊÜÇÄÔ¿¼Ìº¶Á²«¹ª¥ZM=ZM=ZM=ZM=ZM=ZM=ZM=ZM=XK;XK;YL<YL<YL<ZM=ZM=ZM=ZL?ZL?]M>]M=]N;^O<\O<\O>]P@[OC[NFYNJZPQ\SX_U^_Wfd\tibƒng‘qjxp¬€y¼‰Ä‹€Ä¿~ºt«Œn¢—q¤¡u¨›kŸ™W}<Cª5+²6,Â<3Ó@8Ý>8è?:óA=õ=;õ;<ô;@ñ>Dî@IèAIâ@KÛBGÇ<9½=4¶<1±;/«:,®:-½A5ÐJAÚFBÜA=Ô63Ð51ÖA:ÍC8¼:,²5#½8'Â;(Ä=*Ä=*Ä;(Æ;(È;)Ë:)Ï9(Ï6&Ô2%Ú2%ã5*ê8.ð91ð91ç1&è0&ê.%ï,&ö+'û+)þ,+ÿ-.ü)/ú$,ú$0ÿ'7ÿ$;ÿ8ÿ3ü0õ0ö.9õ3<æ+2Û(,Ü.0Þ02Û+.ñ:>ô7=÷4:ö26÷05ø03ù25ô87Û2-Ú;5×82äE?äEAÎ/+Ñ2.Á"Ô51á?<èE@à=8Ø3-Ù2,Ý60Ý:1Ô:.Ï9*É5'Ç5(È9+Ê<0Ê<2Æ9/ícYáXNÉ@8º4+Â91Ã:0¿6,Â9/¿5+¿5+½4*»5)¸6)µ5(²7(°6)´;0¼C:ÓYTèljïqtöx|þ|„øv€þ|„üyùv~þuÿsÿp}ÿkwüdqý_nöI]ÿ>\ÿ>\êDZÓdj®Žy‹—qz”du’\xŽ]cŠ•k˜p‹•p…”mr‡`mˆ]iŠ]g^lbq•ey›izŸk¬t„±vŠ·|»}¼“¼‚—¼†›»‰›µˆ¢²­¶—¾½¨ÏÆ·ØÇ¿ÖÁ¼Ï¼¸Æ·´»­ª²¤£\L<\L<\L<\L<\L<\L<\L<\L<ZJ:ZJ:[K;[K;[K;\L<\L<\L=\L=\L=^L>]M=]N;^O<^O<\O<_RA]QA\PD[NFZOK[PN]QS]RZ_SgcXvh]…kb‘sk¤vµ‡|¾‰}»—…¿™€·›v©žpž®u¢ºv¥µi˜°Rv¸<D¾5/º4+À<0ËC7ÓE9ÛC8ä?9ñ=<÷:>ù:Aö=Eï@GæAHÙ@EÏ@BÀ;6¸90±8-­9,ª9)­9*»?3ÏF>ÙD>Ø:7Ù75Ú;7ÜC=ÞPFÎH<µ3#¾9(Á:'Ä;)Æ=+É=,È<+É:)Ì9)Ï7)Ð3$Ó/#à5+î=5õ@9ò:2é4+à4&ß5&â2%å/$ì-%î+%ñ+(ó,)ó+-ð(+ò&/ø(6þ%:ý7ü3ø3ô%7ò0;ó5Aò8Cñ<Eð<Eê6?ä,6ð2<ó/;ö.9ö-7õ.3õ.1ó/1í42Ü0,â=9Ú64ß;9ÿmkåCAÒ0.Î/,Ú;8ß@<àA;Û<6Õ7.Ö5-Ö5+Ò6*È6'Ä7&Â6'Ä8)Å;.Æ<1Æ<1Å;1ë`YáTMÉ<3¿0(Ë;3Ñ>6Î;3Ò=6Ø=8×<7Õ>7Ð=3Ê<2Â:.»7*¶6)¹;/¼@6ÏTMãgeíorøz~ÿˆû|ƒû|ƒûyûx€ÿwÿsÿn}ÿgvû`pü[mõG^ÿ<Zÿ>\ìFZÎ`cž~gy…]i„Qh…OmƒRt…X|‰^}ˆ`x„\q‚XazP_Pa…UfŽZn”auœg} j~£mƒ¬r„²tˆ¶x‹¹y‹¹y¹z‘º~”º“±•¬€›©†©­”ºµ¢Ç¹®Ë¸²È¶´¸¬¬ª¡¢ —š[K;[K;[K;[K;[K;[K;[K;[K;ZJ:ZJ:[K;[K;[K;\L<\L<\L<]K=]K=^M=^M=^M;^O<^O<^O<^Q@^Q@]OB[OC\NE\OG]PJ]OO^P_bTmdY{i^‰pgœ}u®…{·ˆ{³™…¸¥…´¯€ª¸z¡ÆxŸÑuœÊdŒÆMlÜFRßA@ÕA=ÏE;ÌH;ÍG;ÓE9ÞA:î@Aõ<Aú=Dø?GñBIãBGÒ@AÆ?<¿?6¶<1°:.¬;-ª9)¯9+¼>2ÎD:Õ<7Õ31à;9åA?áD?èSLßUJ¿:+Â:*¿8%À7%Ä;)É=,Ê=,Ë9*Î8)Î5'Ò2&Ù2)å9/ñ>7õ>8ð50ä/&à5+Þ6)à4*ã1'ç.)ê-)í+)í++ê),è',ë'1ò)9÷'=ø"<ü>û%Aû6Hä(6ç.<ÿP\ÿ`lÿP\ò<Ió9Gè)8í*8ò.:ô0:ñ27ê01á+*Ø)&Ø0-Ú72Ô2/åC@ÿspõVSÝ==åGFÛ=<Ú<9Õ:5Ò80Ñ7-Ð6*Í4&Æ3#¾5#¹6$»8&¿;,À</¿9.À:/Å<4åXQÜMGÊ70Ç0)×<7ÞA:Û<6ß<5ç>9é=9æ?9á@8Ù?5Ï<2È:.Á9-»9,»<3ÌOIàc_ìnoú|ÿ„ˆý~…øy€øy€üyÿx‚ÿt‚ÿn}ýetù^n÷VhóE\ý8Vÿ<ZîH\ÇYZ‹mScrG]uC\yCdzIm~QtVvƒXs‚YoWm‡ZlŽ\o•buh{£n¨q„ªq…«p…­q…±tˆ´u‰·v‰·v‰·v‹·x¸|‘´~«{’¤~›¤‡­«–¾²¤È·¯Ç¸µ´«°¡ž¥—’™[K;[K;[K;[K;[K;[K;[K;[K;ZJ:ZJ:[K;[K;[K;\L<\L<\L<]K=^K=_L=^M=^M;_N<^O<^O<^O<^N>^N>\O?_OB]OB^PE^OJbNYcRecTqdZ}le‘xr¢w¨ƒv¤”}§¬†«Â‰©Î‚žÚw”ál‰ÛXwÚD_ôCUûEQïJPáIHÑF?ËE<ÐE>ÚEAéCCð@Cõ@GõBHíDIßCDÏA?Ã@8¿@7µ=/®:+«:*ª9)®8*»;.Ì?6áFBâ=;îBBëAAÞ;6äKCæXLÕK>ÉA3À8(¼3#Á8(È<-É:*Ë7)Ð8+Î0%×3)à8/é;4í:5í62ë/-å,)ã0,ã1-ç10ì31ó25ö37÷48÷6;ì-5ê,6í.=ñ0Có-Fö)Hý+Nÿ3Rô9Lå3?ð@Mÿ_lÿkyÿWfõCSõ>Pî3Dí3Aí3@ê7=ã99Û83Î4*Ç/$Ë2*Ç.(Ð72òYTö\ZòXVÛAAâHFÜB@Ô<7Î70Í6-Ð9.Ï9+Ê7'Â5#¹8%³8&µ:(¹>.¹;-¶6+¼7.Ç>6ÛNGÙEAÎ50Ð1-á>9ç@:ã81ç51ë20î21ë52ç83á:2Ø:/Ð9.È:.¾5+º7-ÈIBÜ_Yënlû}€ÿ…‰ýƒõv}öw~üyÿx‚ÿsƒÿk}ýdvù^pôRgôF_ý8Vþ=ZïL]ÀTR{`CWh<Yq?[vCfyKn~QtVx…Zyˆ_wŒay•exšhz m|§qªr„«r…«p†©o‡­rˆ°t‰³tˆµt‡µt…·r‰·v‹¸w¶{Ž¬xŽ£x™¤‚­­•À¹§ÎÀµÒÄÁ¼¹À¨ª¶œœ¨[K;[K;[K;[K;[K;[K;[K;[K;ZJ:ZJ:[K;[K;[K;\L<\L<]L<^K=^K=_L=_L=^M;_N<^O<^O<]N;]N;^O<_O?`P@`P@aQAbPFbNPcN]_Pe`Usga…to—{t~r˜v–®ƒŸÌ‹¡Û‚–ær…ëduéPdé;Rù3Lÿ<QûERéDKÕ?@Î@>ÑCAÖEBãEFèBDîAEíCFçDGÚDCËB<À@5»?3±;-©8(©:)ª9)°8*¼:-Ê;3èIEê@@ë=>å78Ú2/ßB;îZPôh[ÛQDÉA3¾4'Â6'È:,È9+Ë7+Ò8,Ñ0&Ú6-æ;4é;4ê40è/,ê-+ë--ó49õ3;ø3=ü3=ÿ1>ÿ1>ý1=ù1>õ0Aò1Dô4Kõ5Nõ/Pö-Qÿ2Yÿ>_æ3HùO\ÿanÿ_nÿWfûP`ôDXé8JóAQê:GÝ2;Ò/2Ê2-Â8-½;+½;+Ä:/À2(ÙJBúkcÝLGáPKÏ;9Ï;9àLJÔ@<Ë81Ê7-Î</Î=,Ë:)Ä;(´;&®;&¯<)³>-±9+¯3'º:1ÊC=ÖGAÙD>Ô72×2.ç;7ì:6è2.í2-ò,-ô,,ó/0ï31è71â:1Ú<1Ò>2Ã6,º4)ÅB:ØYSçjhú|}ÿ†‰þ€„õv}÷xýz‚ÿx‚ÿqÿi{ûbtø]oòPe÷Ibÿ:Xþ@\ðO_ºQNqX:Sf8]uEa|InSv†Y{ˆ]~‹`g‚—l€œl}Ÿm|¤o}¨p€©o‚ªnƒ©l…©lˆ«qˆ®qˆ°r†³r„³oƒµp…·r‰¸t‹µv‰¬tŽ¥wš¨„°´™ÈïØÌÀÛÑÏÂÂÌ«±Á›¡±ZK8ZK8ZK8ZK8ZK8ZK8ZK8ZK8ZK8ZK8[L9[L9[L9\M:\M:]L:^K<`J<_L=_L=^M=_N>^O<^O<^O<_P=aP>aP>aP>aP>aP>bOAeMMdMW`O_aUmgb€uq’|v˜€s‘uŽ­€”Ά”ß~‡îqyùclúP[ú;Mÿ*Fÿ2Qÿ<Sñ<Mà<E×@EÕCDÔBCÜCEàBCäADãCEÞDBÔC>É@8¾>3¸>1¯9+¨7'©:)­<*´<,Á=1Ï?7à>;å99ã03â/2à42Û94çNFülaòh]ÙQCÆ</Æ:-È:.É7*Í6+Õ8/Õ4,Þ7/æ93é73é1/è/-î1/õ15ÿ2Cÿ0Eÿ-Fÿ*Bÿ&Aÿ#=ü :ö :÷&Cõ*Gõ.Mõ/Pó+Rô)Tÿ2`ÿAhóCXÿ`mÿhuøVeíKZñL\ëBUÚ2Cë@RÝ7CÉ,3º((±.$«8&¥?&¨@'¸?.¼:,ÝYMá]QÍG>ÍD>Á63É;7äUQÕF@É91È8-Ê;-É:)È9(Ä=)±>)¦<&¨;'¬=*«7(¬3(¼=4ÓLFÖGAÝE@Û96Ü30é73í62ë0+ô1-ý,/ÿ+-ú./ô1/í4/æ81ß;1Ø>2É9.½3(À;2ÏNHáa^÷yzÿˆŠÿƒ‡ùzû|ƒÿ{†ÿx„ÿn~þew÷^põZlëL`õIaü9Wû=YîM]³KHhQ1Qd6\tDf~Nv‡[Žc„h†’jˆ—n‰žsˆ¤t„¦t§r}¨p¨n©mƒ©l…©l…¨n‡«n…­o…¯o°l€²k‚¶n…·r‡³t‡­t§wœ¬…²¹šÈƯ×οÙÒÌ»¿Ê¤¬¿’š­[J8ZK8[J8ZK8[J8ZK8[J8ZK8[J8ZK8\K9[L9\K9\M:]L:]L:^K<^K<_L=^M=^M=^N>^N>\O<aR?aR?aR?bQ?bQ?aP>aN=bL?hOKgNRbP\cWkjfwv•}|œx—‘z–«•Æ„’Ú}…ðuzýklÿY[ýDLÿ0Jÿ5Tÿ<Uô=Qé?LãCMÝBHÖ=@ÛACÜ@CÞ@AÛA?ØC?ÐA9Ç>4½=0µ?1¬;+©8(­<,´?.»@1ÊA7ØC=Ù74á85ß//â30ç;7Ó0'Ñ5)ëUGÿvlë[PÑC7Ê<0Ë;0Ê8+Í6+Ô:0Ú70ß82å63ç32ê01í12ô36ý4<ÿ&7ÿ#9ÿ"9ÿ"9ÿ!8ÿ8þ6ø6ï4î9ð%Bð)Hî&Jñ'Mÿ3^ÿEhÿbuÿ`l÷WcñQ]òP]ïMZâ@MÔ2=Ú=FÌ7;»/.®/(¦5'¢;(œ@'œ>%ª9'²8+ÒVJ»;2Ä?8¾41½2/ÎC@åWSÕHAÈ91Ä6,Æ7)Ä5%Æ5$Ã:(±<(§:&¨7%­9*¬4&¯1%Â?5ÛRJÚIDáHCÞ;6Þ2.ê41í1/ï-+ü22þ,/ý+.ù+-ó++í-*æ1*ß4,Ö8,Ñ=1¿2(¼7.ÈIBÙ\Xówwÿ‰‹ÿ‡Šû€…þˆÿ}ˆÿv„ÿj|þ_s÷XlöTiëE]õD^õ6Uñ:VàLZ¥HC^K-Mc5Wo?b}Ju‹\‚•g‡˜lˆ›nŠ r‹¥vŒ¬z†«wªr~§m|¥i}¥g¥h‚¦i‚¥k‚¨mƒ«m‚¬l®h~°i³j„¶o‰¶s‰¯rŽ¬x™°„­»˜¿Å©ËʵËͶ½Åžªº‹—§]K7\K7]K7\K7]K7\K7]K7\K7^L8]L8^L8]L8^L8]L8^L8]L:]J<]K=^L>]M>\L=[N=]P?^SA`SB_RA`P@bQAcRBdQBdNAdLBjMIhKMdPYf[lnk†x{ž„­‰ˆ²ƒ©¥‡©¾ˆ Ð‚’ây~ðsqújbÿa^ùJWñ>Që:Lî?PïCQê@Mç=Hå>Fâ=Cß<AÚ<=Ö<:Ï>9Ê=4Á;0¹;-¨7'¯A0­<,¬6(¿A5ÌF=Í>6Ð72Ú85Ü71Þ5.Þ6-Þ8*Ý<*Ù:'Ó6%Ù;2ðSLòYQÙE9Ç8*Í>.ÔB3Ò:-Ô3+ðGBá//î5:ó6=î,7ÿBMñ'3ú&2ÿ)2ÿ(2ù'ý!+ÿ'0ÿ(0ñ'ð)ù+7ê .ì&7ñ-Cç#;ÿXsè.Eÿ]lÿ_iþZcùU\õPWëHMÝ?@Î95Ë>7ÄA7·?1¦7&š3"™6#š;'Ÿ<)§8-¯80ÂE?¿;7½31Å75Å54ÔDCÛLHÚKEÑD;È:0Ä4)Ç5(Ì5*Å5*¼</³9,­/#«(³-$Ã9/ÒC;ØH?äOHßE=Ú70Ý0*ç/-ò21ú24ý14÷/2ö/2ö01ó0.ò0.î3.æ5-Ý9/Õ=0¾2%À>1¹=3Ö_Yésqÿû„†û†ŒÿƒŽÿxˆÿh}ÿ_wÿ[uÿUoøLføEcñ:Yô;[æ?YÛ]i‹@;VF-L^6ZuBh‡Nw–]}œcg€¡jƒ¦p‚§q€§n¦m~¥l}¥i}£h£f£f£f~¤k¦mªn¬k~­g®f±gƒ³i‡µm‹´r°v®|š³‰¨¼™±Á¤²Á®¦²°˜žz…‹]K7]K7]K7]K7]K7]K7]K7]K7^L8^L8^L8^L8^L8^L8^L8^K:]K=^L>`N@^N?[N>[N>\P@^RB_SC]QC]OB_NDaOEbPFcOHeNHiMJgNQeS_h_tony~¨€‡»‡ŠÁž•Ê£‹»«£¹xÓyƒê|{ôvjöi`ø]aóOZìFRòHUùJYöFSï?Jë;Eä9Aà:>Ú::Õ=8Î?7È?5À</·<,«<+ª?-ª9)²:,ÁA6Æ=5È72Ô<7Ò50Ö5-×5*Ù5)Ú7&Û:&Û;%Ú9'Ý6.æA;ëMDâJ=Ñ?0Ç8(Ë9*Ô</Þ;4öJFå12ð6;ö6Añ.<ÿ@Nï'4ó$,÷%(û),ý+.ý+.ø((ö(*÷+,ï$'í%(ë&-þ<EÙ)ð4CüATØ&6ÿjuÿbjþZaüW]ôOSåBCØ=9Ñ>6¾8,¿D5¹H6©>,™/)(’(ž-%±;7ÑTRÎHGÃ54Ç56Ñ==ëWUØGBÖGAÐA9Ç9/Æ3)Ê6,Ð7/Ï81Ç=3Â91Â5.Ä3.É4.Ñ83Ø?9ßF@äJBÞA8Ú6-Ý0*ç/-ò12û03û03ô04ó12ô02ó/0ó0.ï2.ç4-ß9-×=1¿3$¾</·=2Ó^Wévsÿù…ˆø…ŠÿŒÿt…ÿf|ÿ\vÿXtÿQoþIhýAbó:Zñ?_âJaÁS\|@8SG1M_9[vCg†Ks•Yxœ_wb{¡f}¤k}¦l|¥i|¥i|¤h{£g{¡d}¡d~ c~¢e|£j}¦n}©l}ªi|«e}­c¯c‚°e…°h‡²kˆ¯pˆ«s‹«|¬„ª‡Œ¢‹x‡€dppR^^]L:]L:]L:]L:]L:]L:]L:]L:^M;^M;^M;^M;^M;^M;^M;^M;^K<_N>aP@`P@]P?\O?\P@[RC\RF[QG\OG\OI_PMcQOfTTgUUhVVhW]h]nmh†sv£|ƒº‚ŠËŠÔ˜‘× ŠÊª‚´¹}ŸÏ€“䄆îvósjüfh÷S\íGQðFQöGT÷EQò@Lî=Gå8>à7:Ù99Ô<7Í@7ÅA4¾?0¶>-­>-ª<+«:,¸B6ÇH?À;2¼1*Ê:2Í6/Ð6.Õ7,Ø8,Ù7(Ù8&Ü9&à:*Ý4-Û4.âA9éOCÞH:È5%É3$Ù@2â>5õHDè13ò5;ù7@ø4@ÿESø2?ð)0ë#&ì$'ù13õ-/ï''ì&'õ12ë)*ö8:è+1â)1ì4@ÿR^ï=Mÿ\iþ^fñV\îOTñNSêEIÝ:;Õ74Ô?9À6,Á?2¼B5³=1¬7-¥3)¡,%œ' š%ª0+ÇECÂ::½--È35×ABô^]Ñ@;ÒC=ÐA9Ë=3Ì9/Ô=4ÛA9Û@;Û@<Ø=;Ý==ã@Aä>>à::ã?=ìJGàA;Ý<4Ù5,Ý2+ç1-ð31õ12ø02ô04ô02ô02ó/0ó0.ï2.ç4-ß9-Ø>2À4%º8+µ;0Ð[Tízwÿ“’û‡Šúƒ‰ý~‰ÿr‚ÿdyÿ[tÿTqÿNmÿFgû=aô<^ïFcßTg¢AHp;3SH2Qa<^yFh‡Nr“Zu˜^tš_xžc{£g|¤hy¢fy¢fy¡cx byŸb{Ÿb}Ÿb| cz¡h{¤j{§h{¨e{©a{©`}«`­b‡²jŠµn‹²s‰¬t†¦w‚žuy“np‡mTdYCOM4@>^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^L8`N:aP<`Q>]P?ZN>YOCXPEXOH[QO_UTbXYeX_iYcl\fk^glaimerok‚ttšy~µ†Ê†ŒÚŽáŽ‡×Ÿ‹Ó­ŠÄ³€©½yŽÌ{Þzò‚wÿsrÿcgùU\ôMTõGQôCMò>Iï;Då6;à88Û97Ô<7Í@6ÆB5¼A1·?.«:*­>-±=0¼F:ÍSHÇH?º5.º1)È91Í81Ô<1Ù=1Û;-Ù6'Ü6&à8+à5-Û2+á>5ìNBäL>Ò:,Ñ8*àB6ß7.ð>:é/0ð16÷4<ü8BÿNZÿLUý>Eò38â$&í/1ê,,ð22è**ë/.ò::Òæ37Ý,2è8BðENÿXcòNWØ=CÛBEáBGá>Cß:>Ý8<Ø88Ó97É83Â91½:2ÀA:ÍNHÖVSÐNNÃCB²72¶95ÏKIÙMLäRSïYZëSRñYVÉ51Î>6ÒB9Ð@7Ó?5ÙB9àC<ãA>é?@ç8=ì9?ò?Cð;@è58ì>?öMJÞ93Û60Ú3+Þ3,å4.í41ò21ô01ô02ö/2ö/2õ/0õ/.ñ1.é4-à8-Ù?3Â6'·5(´:/ËVOï|yÿ“’üˆ‹ý‰þz‡ýoücwÿXqÿOlÿFhÿ@cù9^ô?`éKdØZh…35g;0WO8XhDa{Kj‰Ps’Yt•\u˜^wby¡ez¢fw dv awŸavž`xžaxža{Ÿa| cz¢fz£g|¦fz§dz¨`z¨]|«]~­_†²g‹´nŒ³tŠ­s†¦u€qtŽii€dRbUFSL:G@_N<_N<_N<_N<_N<_N<_N<_N<^M;^M;^M;^M;^M;^M;^M;^M9]K5_M5`P9_P;\O?ZNBXOFXQKYPQ`W\g`hnfsshysg{sg}ri~pm~pq†sv—x|«|Á€†Ò…‰àŒŒæ•ãŒÚ „¿žuŸ l‚¬nq¼vlÒviòsmÿllÿgiþ^`ûRYõFMï;Dê7=ç6<â89Ý98Ö=7ÎA7ÆB5½B0¸@/­7)µA4°;1°;1ÈRHÕ\SÉME»;2¾90Á7-Ì9/×?4Û=1Ú6*Ü4'â6*à3,â70ä=5åE9âF9ÞB3ÞA2â>2Û0&ê72ì0/ï.1ñ.4ú7?ÿPXÿ]dÿZ_ÿOSá.1ã03à,/÷DGè66Ü,,Û-.ë>@Ý36Ù37ÿbhà<CË*2Ê-4Á&*Õ;=á@EÛ6:Ù37ß9=Ü7;Í/0Ì43Í;;ÕGFÞRSì`cõhnôekê]cÄ@>ÆE@å^[øhgÿopÿjjåKK×=;É40Ñ>7ØE=ÖC;Õ>5Õ<4Ø93Ü43ï6<ñ-9ð,6ò.8ð,6ë,3ó9>þJKß3/Ü3.Ú3+Ü3,ã5.ê40ï4/ò21ô02ö/2÷/2ö.0õ/.ñ1.ê3-â7-Ù?3Æ8*´2%²8-ÃNGï|yÿ’‘ÿˆŒÿ‰ÿw…úl|øatûTnýHgÿ>bÿ:_ú6\ôBbàNeÂWaq0,_?0[W>^lIf~Nk‰St’\u–_v™_xžcy¡ex dvž`vž`u_vž_wž_xŸ`{Ÿa| bz¢d{¥e|¦d|§by§^y§\{ª\}¬^€¬a…¯g‡®m‡ªp…¥sƒ r{•nrŠjfwe[k^RbU_N<_N<_N<_N<_N<_N<_N<_N<_N<_N<_N<_N<_N<_N<_N<_N:^L4_N4`N8^O<[N>YOEZSMZTT_ZahbprmzuŒ}t‘{q“zp“vp’qt“rxšu|¨y€¶{ƒÄ…φ‰Ú‹Þ–Ü™ŠÍ›…¶¢ƒ£ª„‘«~yŸl[›R?¼MBÔQIâWRëWUñSTñKOí>Cæ5;é9<æ9;à;9Ù>9Ó@8ÊB6ÁB1º?/´:-ºA6«5+£.$¾I?Ùg\ÙdZËUK¹=3¸5+À3)Î:0Ù;0Ú6,Þ3)ä6-ß1*å82ã;2Ý9/Þ>0ãF7äB5ß9-ß1(ê5.ð31ð./í*.ô17ÿEJÿV[ÿ]bÿ\aâ9<ã9<Õ+.ôJMâ89Ø00Û57Ì()Ì'+øW\Ý>CÖ:>Ò7=º#Å),Ü<>çBFÝ49Ù,2Þ17Ú16Í(.Ò37äKNöaeûhnùcl÷_kú`løbkÖLLÕNJê\ZêVTçMMãHFÏ42Î3/ÙA<àKDäOHßJCÙ@8×:3×50Ü.-õ1;û,<ø*7õ'4õ)4ø0:ÿ>CÿJLà1.Þ3,Ü3,Ý5,á4-ç4/í4/ñ42ô02÷/2ù.2ø-0ö..ò0.ë2-â7-Ù=1É;-´2%±7,»D>ìyvÿÿˆÿ|ˆÿqöhxö_rùRlùDcÿ9^ÿ6]ú8]ñGdÑN`¢IMe5+VD0[Y@^lIe|NkˆRt‘[w•_x™`{ždz evž`s›]s›\s›\tœ]v^wž_{Ÿaz¡bz¡b{¤b|§b{¦_x¦[x§Yz©Y{ªZ~ª_ƒ­e…¬k‡©m‰§s‰¥u„u|”rvˆpnlfwe_O?_O?_O?_O?_O?_O?_O?_O?^N>^N>^N>^N>^N>^N>^N>_N:aO7aP6aO9^O<[OC[RK\VV_Zakgvso†}z—‚~¡|¥}w£{u¥xv§sy©s}°z¸}ƒ¿€†Ä…‰ÉŽÎ”“Íš“Ç •½«›µ¼¦²É­©Å¦”ªˆmœfJœE2¯A4·A5ÃC:×IEéOOîJKì?Cë=?é;=ä<;ß=:Ù@:Ð@7È>1Á=0½:2¼@8¯4,§1'¼J@ÑbWÖg\ÕeYÃOBº>2º4)Ç7.Ö90Ù5,ß2+ç60ã1-ä50â7/ß8/à>1æD7ä>0Þ4'æ4*é0+ð3/ð..ï-.ò14ó78öBEöMRüY^éFKöQWÙ48ëFJÝ8<æAEÚ7:Ï/1Ñ05äHKÓ8<Ð7:¹#%Õ:>Û8;å;>ë<Aè7=â-6Ý)2á1;ç<DðLSý]eÿksÿjsú`löZhùXh÷[hôddèZVèWTØ@=Ï10Ô44Ó33áC@ãJEéRKêSLáJAÙ?7Ø93Û81ã33ó.8ÿ0>ÿ0>ú*8ü.:ÿ;EÿCHûADã1/ß4-Ý4-Ý5,â4-æ3,í4/ò53ô02÷/2ù.2ø-0ö..ò0.ë2-ã7-Ø:/Í>0µ1%±7,²;5ésqÿŠŠÿ‡ÿv†þi}óató[p÷PjúCbÿ8`ÿ8aù;aìLh¿O[~86]=0NF1VX@ZeEcxMj…RrŽ[v”^yša{ždxžatš]p˜Zp˜Yq™ZqšXt›\uœ]y_xŸ`y _y¢^z¥^y¤\x¤Yx¤Wy¥V{§X©_‚¬d„«h†¨l‡¥o†¢q€™ox‘jr…il~ddv^_O?_O?_O?_O?_O?_O?_O?_O?^N>^N>^N>^N>^N>^N>^N>_N<cQ9cQ9aP<]P@ZPG\TR_Zaa_mtrŠzy™€¨ƒ°}¯{x¯zv±wwµw|¾x€Á}…Ä‚ˆÄ‡ŠÁ¿—–¾ ¼¬§»¶¬µ¾³±È¸«Ð¾¦ÖÁ¢Ñ»–Ьˆ¯oT¯]H¥H6¨>0ÂG?àWQïWVñNOé@Cê=?æ<=ã><ß=:Ø=8Ñ:1É90Á80À<7¹:3·>5ÂPFÇXMÇ]PÑeXÓcUÃM?¼9/Å8.Ò91×4-ß2,ç60æ40â3.à5.ã<3çC7æB6â:-ß3'ê5,æ.&ð0-ð0-ð31ñ54ç-.ã35çBF÷X]öW\ÿouåDJëHMá=Dþ[`ÿouß>Cÿ}‚ÿmqêQTÔ>@Æ02Ö:=óILî9@ñ8@ø=Fò7Bè-8ô>Jÿ]hÿmwÿjrÿcn÷]gú^kÿapÿ]nùYeò\]ãOKâJGÕ74Ó01Ù54Ò0.Ø95ßD?ãJDãJBÙ@8Ó6/Ö4/Ü71é77ê'/ü0<þ2>ø,7ù0:ÿ>Eý>Cì44â3.à5.Þ6-ß4,á3*è3,ï4/ô43ö/2÷/2ù.2ø-0ø..ó0.ë2-ã7-×9.Ñ?2¶0%²6,°61çonÿ‡ˆÿ†Žÿp‚ücxñ\pôXn÷OiûBbÿ9aÿ<döAdäRi°QWd/'WD3GG/RT<U^?cuMiQq‹[v’_z˜b|dxœ_r™Zn–Wn—Un—Uo˜Vr™Zt›\w›]wž]wž[x¡[y£[w£Xv¢Wv¢Uw£Ty¥Xz¤Z~¦_¦c¡d~œf{—frŒ_kZ`vR[nPSfH\L<^N>`P@`P@_O?_O?`P@aQAbRB_O?]M=^N>aQAcSCbRB`Q>dS?aP>]P@^QI[QPZSZeapsq‰yxšz|¥~€±€¹~~ºyy·sr´nn¶twÈv{Ì€ƒÊ‹Æ–—䤾²°»¼¹´ËƳÓÌ°ÙϬÛϧÜÏ£ÝУÙ˜٘Ѩˆ¸€g¡_IËzgÖtg½H?×QN÷ccéKLå?Aâ89ä:;â:9Ü75Ù53Ö;6Ë73À50ÇB;¹=3¿I?ÆXK¹OAÎdVÑcTÌXIÅG;Ä:/Í6-Ø7/á6/ã4/ß0-ß2,à70ä=4á=1Ý7+ß5(å7,å0'ê/(ì/+î1-î20ë40è51ã75×79æJNõY]îOT×8=×6<ùX`ÿ~„ÿ~†ÿouÿgoÿipÿflõ\añX[ûZ_ÿU\ÿDLü8Bû7C÷3Aï,:ì0>ñ=IÿS_ÿ`iÿgrÿepþbmÿbpÿ`oý]gíSSßFAÖ85Ö41×11×/.Ø31Û94áD=ÜB:Ù?7Ö<4×90Û81à93æ66ñ7<ô5<ö4<ö4<÷5=ò59ë35ã1/Þ3,Þ5.ß7.á6.ä3+é2,ï2,ö31÷03ø03ú/3ù.1ù//ô1/ì3.å7.à?5Ì8,¿6,¯/&¸;7ÒXWÿ˜šþ{ƒÿm€ÿe|ø\tðPjõHfüCeÿ;dù9`õNlÓRd‰=?R,!C;&CG.KM5Z`DZjEcxMqˆZx’bx–`t•\r–Yq˜Yl•Sm–Rn—So˜Tr™Xt›Zuœ]uœ[t›XtWv Xw¡Wv¢Wv¢Uu¡Tt S{¥[{£]zž^u—[m‹Ub~MXrCSj>AW0?U/<R,\L<^N>`P@aQA`P@_O?`P@aQAcSC`P@_O?`P@bRBcSCbRB`P@fVG_QF]PH^TSaZad`omkƒvw–xz£{}®}¸x|¹rv¶lo´mp·oq¾uvÐ|~Õ‰‰Ó˜˜Î¨§Ç¹¶ÁÉźÓαÛתâÛ¥çÞ¥æÝ¢äÛ¤âØ£ÛÑ ÔǛӼœ»œ€©|eÅ‹wÊ}m´VJÒa[örpìZ[çKLã?@è>?ë>@è<<â66Û55Ö=8É83Ê?8¹6.¸>3¾LA¶H;È]MÝo`Ô`QÆH:½5)Å1'Ô6-Ü5-Û0)â51å95ä=7à<3Ü8.Û5)ß4*ã5*ì7.í5-í2-ë0+ç0,ã2,á4.Ý52Ö87Ø>@åJNóW[ú]dü\dþ]eÿaiôS[ïNVñQ[ÿ_gÿjqÿflõZ`óNTí4:ñ,5ô*6÷-9ñ'5å!/æ'6í7DþO\ÿZdÿblÿdmÿenÿcmý[hõQZåEEÞ<7Û64Þ63ß55Ü30Ú2/Û62à>9Û>7Ù<5×:3Û81ß82å95ç:6ë8;ë7:í6:ï6;ï79ì57å31ß2,Ý4-Ý6-ß7.â6,å2+ê1,ò1,õ20÷03÷03ú/3ù.1÷//ô1/ì3.å7.ß<3Ô=2Â8.¶1*·74ØZ[ÿ“ûs}ÿfzÿ^vùVq÷NkúGgü@cü<cõAdåOhºLWy<9L2#<:#<B(EG/PT9VdA`rJnƒXu_v’_t“Zq“Wp”Tk’Ok”Pl•Qm–Rp—Vr™Xsš[sšYuœYuWuŸWuŸWtžTržQqRq›Qo—Pl”NiŒLbFXu?Ni6F]/@W+@W-AX.AX.YL<[N>^QA^QA^QA^QA_RB`SCaTD`SC_RB`SCbUEbUE`SC^PCbUM\QM[QRcYbkdtqm„vu•z|¥y{¬y~¶x|»ot¶ei°bf¯jn¸ruÆ}}ׇ„Ý—”Û©§Ø»¹ÏÍÉÈÜØ¿åá´éäªíè¦ðé¥íå¤çá§âÛ§×Ï¡ËÞ¸¯’©››‚l¨ƒp§o`œRGº]UÝmi÷uuï__äJLæAEëADì>@è8;ã68ß=;Ô;6ÔA:Ã81·7,·>3®=/·G9Ûj\ßi[Ú\NÊB6Æ3)Ñ4+Ù6-Ù2,Þ52éA>ìGCà=6Õ2)Õ1'Û3(Þ0'ç4-è1+ç.)æ/)ã2,ã80á=4àB9Æ-(Ê43ÜCEðVXú^b÷ZaóS[ñQ[éGRêHSïO[ü\fÿmvÿntôY_ã>Dé.5ô-4û2<ü2>õ+9í'6ö6EÿKW÷ISõPWøW_þ^fÿckÿ`i÷RYéBIÞ97Þ71ã75é<8ì<<æ95á51Ý60Ý:3Ù;2×90×90Ü71â94è;7é<8ã99ã99æ87è88è88æ66á40Û2+Ú6-Û7-Þ7.â6,ç2+ë0)ó0,÷10õ13õ13ø03÷/1÷//ó1/î3.ç6.Þ:1ÜD9È91»4.µ/.ä_bÿƒˆølwþbxþWsúPmþLlÿBh÷:`ô<`ìIfÔSgDJm<5O>,=<':?(ED/FH0Q\<YkEg|Qr‰[t\qWmRlPiMi‘Kj“Mk”Pn•To–Up—Xq˜YuœYuWtœVrœTpšRm—Mk•Mj”LfŽHaˆE\~AUt;Li3E`-AX*>U'D[/E_2Ic6WJ:ZM=]P@^QA^QA^QA_RBaTD`SC`SCaTDaTDaTDaTD_RB]QEZOM[RWbXcjcsqm†vu•xz£z|­w|´sy·mr´dh¯]d¬ag±lr¾x{ʉ‰ß•‘夡䷴áÇÄÙÕÑÎáÝÄçä¹ëæ¯îê­îè¬éâ«ãÛªÚÓ©Ë¡»¶™¥¥›˜…“ˆv˜q™rc›bW³i`Ïrmû‹‰õutê[]æLNéDHí@Dì;Aé;=ß:8Û<8ßF@ÓC;Ã:0º:/°6)§1#¿I;ÛaRêj]ÛSGÊ:/Ì4)Ô6+×4-Ù42ñMKþZXíKFÚ91×4+Û4+Þ2(ß.&â-&á,%Þ-%Ü1)Ú6,Ù;0×?4Â/'Ä4,Î:8ÙCBßFHàEIäGNêMVñQ]öVbøXdù\gÿgrÿmuôYaÞ;@ë28ñ.4ó.7ò*4ë%2í)5û<KÿS_í?IèAIêGLôQVÿY`ÿX]ôGMå79á53å84ë<9ò@>ô@?ï=;æ95à72Ý82Ú91Ù80Ù80Ü71ä84è96ê;8â:7à;9ã:7æ:8ç98å84à5.Ú3+Ú6,Ü8.Þ8,â6,ç2)ë0)ò/+ö0/ô23ô23÷03ö01ö0/ó1/î3.ç6.Ü8/àF<É91¿4/¶,,îfjÿy€øgtÿbyýTqþKkÿGjÿ=eó6\ë=^ãQhÄXeˆBBgC7[N;GF1AC-JH3EE-LU6Sc>btLlƒUp‹XoŒTmŒPiŽKiŽIhJh‘Kj“Ml“Rn•To•Xp—Xt›Xs›Uq™So—Qk”Nh‘KeŽHdG`‡D]AWy=Rq8Mi6Lf6Oe7Of8Ne7Oi9Sm>UH8XK;[N>\O?]P@]P@_RBaTD_RB`SCaTDaTD`SC`SC_RB^QIVMR_Xhnf{uqŠxt—xw¡xz«y{´tx·lq³bf­\c«`f°kq»v|Æ€„Γ•àŸžä®­ç½¼æËÉßÔÓØÝÛÎáßÆåá¾æâ¼äß¹à׶ÚеÎƱ¾µ¦­§›™™ŒŽ‹…yŠ|q‘vk›si¨meºoi扄î~ósrñedñWYðMNîDGì?Aã:7à;7äB=ÞE?Ì<3Æ=3ÄB5°2$®0"ÈJ<ÜXKÖN@Ì=/Î7,Ñ7+Ñ3*Ö42õUUÿkhú]XãD>Ü;3ß;2ã80â4-ã2,â1+Ý0)Ô0'Í/$Æ/$Â0#Å9,À4'Á2*Ì;6×CAÛEGÛBGÚ@HàDOìP[òVcòVaú^iÿgoóYaáBGê:<í57ï28ï28ò2=÷9CÿHUÿVaå7@Ý4;ß6;ëADùJOüIMõ<Bé13é54ë95ð=9ó=:ó;9ð:7é73ã81ß;2Ü;1Û:2Ü92ß82ä73è64é75æ:8ä;8æ:8è:9è;7æ95á6/Ü3,Û7-Ü8.ß9-á6,å3)é1)ñ0)ô1-ó23ñ33ô23ô01ô1/ó1/î3.ç6.Þ7/àC:Ê70À1-À13økqÿqzúftû]túPmÿBhÿ>gÿ9cõ8^æEdÙZm«V[wE>dJ=aYFTO;KI4PI7GE0GP3M]9ZlFf{Pm…SmŠRlŒMhJiŽIgHgJi’Lk”Rl•Sn”Wo–Wt˜Xs˜Un•Rk’OfKcŒHaŠF_ˆF[‚CY}@St;Pn8Ok:Rl=Xn@ZqCWo?Vq>WqARE5UH8XK;ZM=[N>\O?^QA`SC`SCaTDaTDaTD`SC`SCbUEbWQ^Vckf}yu~z›zy¡xy©vy°txµlq³cj°\c«^d®io¹w}LJшŒÓ™Ý£¥à°²ã¼¾åÆÇãÏÎÞÔÓØ×ÖÑÙ×ËÙÖÇØÐÅÒÉÀÌþŹ¹´¨¬£šŠ‹†yztyvquleleŽphŽa[`[ÀsmØyuð~}ü|yÿrqýccöSTðHHðDBê>:á<6áB<Ñ:3ÓC:ÞUKÂ>2¸6)½9,Â=.È?/ÐB4×C5Ö@1Ñ7-Ñ30êLMú_]òWSßD?Ù:4Û81á81æ93ç92ç92â:1Û:0Ñ9,Ê8+Å9*±)¸3"È@2ÓI>ÒD@Ë;:Ì7;Ï:@Ò8BâHRíUaðXdõ^g÷`iêU[ÜAEå@>ì?;ó@CûGJÿLTÿQYÿT]ÿV`á3<Ú/5Ý04è8;õ>Bø;?÷48ó04í42ï96ñ97î53ë20ê20ç40á4.ã<4à=4ß<5Þ;4á83ä73è43è43é99ç98è88ë99ë97é75â5/Þ3,Ü8.Ý9-Ý9-ß7*ä3)è1)ï0(ò1,ñ33ð43ó23ó11ó1/ò2/ì3.ç6.à91Ù<3Ì71Á0-Ñ@CÿnuýkuùbqðRiõHfÿ;cÿ5aÿ6bü?eäNiË]j‹GFjF:^M=^WDYR?RJ7OF5ID0DJ.GU2Sc>^sHgMj‡OjŠKgŒGgŒFfŽGfIh‘Ki’Nk”Rm“Vm”Uq•Up•Rk’OgŽKcŒH`‰E_ˆF_†G^‚E[~DYwAVr?Uo@YpB]rG^uG[sCYtAXs@NB2QE5UI9WK;XL<ZN>\P@^RBaUEbVFbVFaUE`TDaUEfZJi^ZngwupŽ|x™{y wx¦vw­pu¯jo¯ch¬`g¯`f°em¶qxÀ~…ؙ͉ؗ Ö¡¨Öª±Û´¹ßº¿ßÀÁÝÃÃÛÇÆØÆÃÔÅÁкɼ³Ä»°Áµ¨¼¦˜¯–‹œˆ…Œqqquqppfewhe†nj„_Y•d_›ZT¹f`Ùsoðzvÿ{yÿvuÿhhüZXþRNõHBæ=8èE>Ù<5ÛG=ê\RÅ;0Ä<0½7+¿7)Ç>.ÑC5ÔB3ÔA1ØB4Ò86Ø>>ÝCCÜB@Ö=7Õ81Ø7/Þ7/å:3æ93å:3â;3Û>5ÖB6ÑE8ÌG6®-¼;%ÍJ8ÑL=Æ=5»0+À00Ê9>×AJâLWëU`ðZeð]eìYaßLTÔ>@Ï4/Ø7/à;9ê@@òCHõDJñBIî?Fâ5;ß26ã36ï8<ö8:ø14û/2ü14ï20ð95ñ85ì0.è,*ç0,æ3/á4.ä=5á>5à=4à<3ã:5æ95ê65ì65ì57ì57í57î68î66ë54ä2.Þ1+Þ7.Ý9-Ý9-ß7*á3(æ1&í1(ñ1,ð43î53ñ33ò21ó1/ò2/ì3.ç6.â;3Ò4+Ò:5Æ20èVYÿpxùcnòZiçI`óEfÿ8bÿ0^ÿ5bÿBhÜLe±PYk60^G7XK:UN;[O?VI9M@0JC0@F,AO.L\7Xj@bxGfJhˆIf‹FeŠDc‹BdŽFeŽHgLh‘OjSk’Sn’Rm‘QhNeŒKb‰HaˆG`‡H`‡Ha…H_‚H_}I]yH]wH`wKcxOczN]uC[vA[vAJC3MF6RI:TK<WK=YM?\O?^QAdWFeXGdXHbVF_UIbXNg^Ulcfwr‰zv›zužtsŸss¥tu­lp¯bg©\`©ae¯fl¸ntÀx{ȃ†Ó“Ý—œÞ›¡Õ §Ó©­Ú®³Ý±´Ý²´Û´´Ú¶´Ûµ±Ö³­Ñ®§É«¡ÄªžÂ¥™½™‹¯ˆ~™|x†dbgiefdZ[j[X{c_yVP’c]ŠNF¢UM½`YÖkeñwrÿ{ÿzwÿnjþa\÷TOéGDîOKÝB=ÞG@êWOº,"¾1'¾4'È?/ÑE6Ë>-Á2"Ê7'ÛE7ÞE?Ó97Ì3.Î61Ô;5×=5Ý<4á=4ä;4ä92Þ5.×4+Ï5)Ê8+Å<,Â?-ÕT?ÈG2½<)¿;.Ã=2Ä;5Â74Â35ÜKPÞMRáPUåTYèY]åVXÜMQÓCBÉ5+Ñ7+Ù80Ý52â24å26æ18ç/9ì4>ì3;ó5?û9Bý4>ú+5ÿ(3ÿ0:ø-3ù59ù59ð./ë*+ê1/è43â51ã<6à=4à=4á=4ä;6ç:6ì87ï77ì46ë35ì25í34í55ê41ã1-Û0(Þ8,Ý:+Ý:+Þ8(à4&ã3$é3&ì4,î52î53ð42ð3/ò2/ð3-ì3.ç6.ä=4Í/&×>9Ì35ùbgÿoy÷[iðNcêC]ùEhÿ:eÿ0]ÿ6aöFjÉJ]“BHS-$WJ9SL:OH6[O?UI9F?/HF1>B'@J(IU1Sd:_rEe}Kg„JeˆHcˆCa‰Bc‹DcEeŽJgŽMhPiQlPkMfJcŠIaˆGb†Fb†Hc‡J_€G^H_}I`|Ka{Kd{Mf|Nf~N]xC]z@^{CDB6FD8KG<PG>RH>XJ?]M>`P@`Q>aR?`SB_VGcZSgb_ojnso~wq“zt ~x¨yw©pp¦gg£`a¢\_¤`b­fhµopÀyzÌ„‚ÖŽŠß–’眙栞ݡ¡×££Ù¤¤Ú¦£Ø¦¡×¥¡Ô¦ŸÓ¥žÑ¤œÍ¢šÉ¢™ÈŸ–Ù»Ž‚°ƒ|žrn}igld^`g[[kYUrWP}WNŒWO•RI©[QµXPÁZSØkdìyrù‚|ÿ‹†ùuqÿusí_]àQMÙECïZTÌ71Å2*Å7+Ã7(À7'Ã7&Æ9(Ê;+Ñ=/Õ?1Ò8.Ö<2Ø@5Ô<1Í5(Î4(Ø:/ãA6à90á90Þ7.×7+Ï7)É:*Æ?,ÄA/Â=.Æ@4ËE:ÍG<ÌC;Å<4¼3-¶+&Ç<9ÐEBÚPMàVSãYVáXRØNKÐC:Ì;*Ó:(Ü8,â5.è./ì*2ð(3ô'8ú->û,@û*?ý)?ÿ(?ÿ&?ÿ%=ÿ%=ÿ#:ÿ':ÿ+<þ,9ô,6í.5è45ç;9Ý84Ý:3Þ;4à;5ã:5æ95é73ë54ë35ì46ë54é54ç53â5/Ý5,Û5)Ü8,Û9*Ü9(Þ9&ß8&â7%ã6%æ4&ì5/í41ð50ñ4.ñ4.í5+ë6-å7,à90Ø7/Õ:6Û?BÿmwÿbsûSjõIcÿKjö6[ÿ6_ÿ<gø>cçNj¯IV^$#E-!?:'HE4PM<PI9EB1>B1?G/BH&EK%KS.S]8[kDavKd~NdƒJc†F`ˆBa‰@c‹BeFjJlPn’Rl‘LjIgŒGf‹HfŠJf‰Ic…HaƒGe„KdIbIdJgKg€Ie~Ga}C\|=\=_‚B=?4@B7FC<JE?PE?TG>[K>^N>aP>`Q<^SA^VIc[Xhcinlyso†uo•vpžtp¢pm¢gfŸaaŸ]^¡]]¥ed°kjºusÆ}{φ‚ÙŽˆà”Žæ˜“å›–Ùœ˜Õ™Öžš×ž˜Ö—Õž•Ô•Ñž–Ñœ”Íœ“Ê›’ǚē‰»ˆ®‚xtk|mdif]^f[YiZSoWM{UJŠVKšVK±]S»ZSÁXRÓfaàqjãvoí~wý‡…ÿ‡…÷uuîgdãUSëZUÇ2,Â/%Å7)Ã7&Á8&Á8&Ä8'È;*Ï;-Ó=/Õ9,Õ9,Ó:,Ò:,Ñ9+Ñ9+Ô8+Ø8,ß;1à90Ü8.Ö8,Ï9*È9(Á:&¾9&¾6*Á80Æ=5É@8ÊA9È?7Å<4Ã:2¿4-Ç>6ÒIAØOGÚQI×NFÌC;Ã7*Ë8&Ó8$Ý7)å4,í//ô+3ù)7þ);ÿ+Bÿ*Aÿ)Aÿ'Bÿ#@ÿ!<ÿ=ÿ;ÿ:ÿ ;ÿ%;ÿ);÷-9ð19ê7:å;;Ü94Ü:5Þ;4à;5ã:5æ95é73ë54ì46ì46ì65è64ä71ß6/Ü5,Ù5)Û9*Û9*Ü9(Ü9&Þ9&ß8%á8%ã6&ç5+ê3-ë4,ë4,ë5*ê5*ä7)â8+à<2Õ3.Ó54óTYÿesÿ[pöHcÿIhÿAdÿ;`þ4\ú<bòMmÍLb‰8?S*&A5)7:);<,B@1F@0@?-=B.?H-=CKP'\b<fpKhvRf{Rf}QeNaƒFa†Aa‰@cŒ@gŒFjJkMm’Om’LjGhHgŒGgŠJgŠJf…Je„IfƒKdIdHdHg€Gg€GfEb~A^?_„?b‡B7:/;=2@@8EB;KB=OE<VH=YL<^N>]P?\SD^WMc]]ifmom{sq‰so”qk™jf˜c`•\[”ZZ˜\] \_¦hjµno¿wxÊÒ‡ƒØ‹‡ÜŠà’Ý“Ó“‘ÑÑăŽÐ“ŒÏ’‹Î•ŒÍ“‹Ç”‹Ä”‹À“‹¾Œ„³ƒz¥€r•|ewu^fi[[e\Wd[RgYLrVH„TH£ZQ½`YÉ\YÐZXÛcbákißokãvqûŠ†ÿŠ†ÿ…ƒÿ}y÷nhîaXÅ5,À2&Å9*Á:'À9&À9%Â9'Æ:)Ì:+Ð:,Ö:-Ô6*Î5'Ð8*Ô>/Ô>/Ï7)Ë/"Ú:.Ú8-Ù7,Ö8,Ð:+É:)Â9&¾7$¾6*À6,Â8.Å;1Ç=3Ê@6ËA7ÌB8Ç:1ËA7ÏE;ÐF<ÒH>ÑG=Ê@6Å7+Ì6%Ö6&ß7,è50ñ03ö-7û+9ÿ*<ü'=ü'=û%=ù#;û!:ú7ü7þ6ÿ8ÿ6ÿ$8ý*;÷2<ñ6=ë8;ä::Ü94Ü:5Þ;6à;7å95ç85é75ë54í36î47í55ê65æ72á6/Ü5,Ù5)Ú8)Ù9)Ú9'Û8%Ý8%Þ7$à7$á6%á5)â4)ã5*ã6(ä7)á7(ß7*Û7+Ý<2Ð1+Ø88ÿkrÿ]nþPiñ<[ÿHlÿ7]ÿ>eù5[î>bæVqª?Qa#(L/+;7+18(37&:;)B=*A<(@>)BB&?FXa4s~T€Œdw‡`i€Tb|MaI`‚E`…@a‰@dAhGjJkMl‘Nn“Mk‘HiŽIgŒGh‹Kh‹Kh‡Lg†KfƒKe‚Jc€HdIf‚Hf‚HeFb€Bc†DeŠEhH25*69.;<4A>7G@:KB=SF>VJ>XL>YM?YQD^WOc^bigron€roŒrm•jg”a_WW‹TUŽWX˜\_¢ac­ln»rsÃ{|΂ƒÕˆ†Ù‹‡ÛŒˆÜŠ×ÒΌώ‹Î‰ÏŽˆÐŽ†Ï…Î…ÊŽ…Æ…Á‡¼‡¶‰‚¬€xoŒ€_p|Y`lXYd[T^_Q_\IjWF}SEžUL¾\YÑZ\ÙX\äcgçkkáplåxsì|xízuþƒ~ÿ†ÿ{õkaÉ<2Ä8)Â;(À;(¿;&¾:%Á:'Å9(È9)Î8*Ù;/Ô6*Î5'Ï9*Ñ>.Ñ>.Ë8(Ç/!Ò6)Ó5)Ó5)Ó7*Ñ9+Í<+È=*Ä;)Ä:-Ä:/Æ90Æ9/Ç:1È;1É<3Ë=3ÔE=ÓE;ÐA9Ë=3Ì=5ÏA7Ï@8Î;1Ï6(Ù5)ã6/ë31ò/5÷+6ú*:ü)<ù&9÷&;ø'<ø'<û&<ý%:ÿ$:ÿ#:ÿ#8þ#7û&8ù,;÷5>ò9?è8:à87Ü94Ü:5Þ;6à;7å95ç85é75ë54î47ï58î66ê65æ72á6/Ü5,×5*Ù9+Ù9)Ù9)Ú9'Û8'Ý8%Þ7%Þ7%Û5%Ü6(Ý7'Ü9(Ü9(Û:(Ù9)×:+×:1Ñ4/ìILÿoyÿVjùE`ø<_ÿAgÿ3\ÿ8bø>cèMlÅOe€0=J C1-11'/7(5<,>A.B@+B<$E>$IF%U\0p~MŸr—¨|ƒ˜mj„W_{J]~E_ƒCa†Ac‹BfCkJm’Mm’Om’Oo”Nl‘KiŽIhHiŒLiŒLj‰NiˆMg„Le‚JdIe‚HgƒIh„IgƒHd‚DgŠHiŽIl‘L.4(36+891<;6B=9H@=MD=QG=SI=SK>UNDZUQa^eigumklkŠki‘b`XVˆPP†QQXYš`cªfj´orÁuxÉ|Ѓ„Ö†‡Ù‰ˆØŠ‰Ù‹ŠÖŒ‹Ï‹ŠÌŠ‰Í‰‡Ð‰…ш„ÑŠƒÑ‰‚ÐŒ„Ï‹„È…Á†º†°‡¥~w–m…„Yj€SZnVTc\RZaOZ_HeZDxUB“ME¸TRÐSWÛRYå^dèejãklæuqäunâoh÷~vÿ‚{ÿ‡~ôl`É?2Á8(À;(¿<(¿='À<'Â;'Å:'È9)Í7)Ø:/Ù8.Ò8,Ï9+Ì:+É:*È9)É7(Ï9+Ñ7+Ò8,Ñ7+Ï7*Ì8*Ë<,Ë>-Ê<0É=0Ê<2É;/È:0Ç9-Å7-Å5*Ð@7Ð@5Í=4É9.Ë80Î;1Í:2Ì5,Ð/%Ù0)ä20ì25ô/8ù-9û+;ü+>ü-?ü/@ü/@ü/@þ/Aÿ/?ÿ.@ÿ.@ÿ)9ü)8ø,8õ0:ñ6=í8=ã77Ü43Ü86Ü:7Þ;6â:7å97ç77ê65ì44ñ48ñ48ð67í76æ74á6/Ú6,×5*Ø8*Ö9(Ö9(Ø9&Ø9&Ù8&Ú7&Ù8&Õ8%Õ:&Ö;'Õ=(Ô=(Ô=*Ô=,Ô<.Ñ7/Û<9ÿ^eÿaqÿPi÷<[ÿAiÿ4_ÿ5aû1YôKlÛYq•>NZ%-C),:20.1*08-8A0=B,<<"A<UH(`[5|†T¢nª¾¨¾Ž¥wo‹[aK^F`„DcˆBgDl’Go”Np•Po“So“So”Ol‘KiŽIgŒGiŒLiŒLi‹OhŠNg†Ke„IdƒHe„Ih†Jh†Hg…Ge…FiŽKi‘Kl”N+1%.4*470894>:7B=:HA;KD<NG=NG=PKEWSR_^ffeugggf†ba‰[YŠRR†NO‡RS“[^£ei³lo¾uwÊz|ÑÖƒ…؆‡Ù†‡×ˆ‡Õ‰‰Ó‡ˆË†‡È†…Ë…ƒÎ…€Ð…€Ò‡Ò‡€Ð…ÒŒ…Ë…ÁŒ…¸‹…«„{v}k{„VcPVnUQd^P[eMYcJb^EsXCOE´WRÐUZÛT[ç\cèagågjèpoìyræqh÷|tósjþxmæ\QÄ;+¾5#Ã<)Á=(Á=(Ã<(Ä;(È;)Ë9*Ï7*×6,Ø7-Ô:.Î:,Ç:)Ä8'Ç;*Ê=,Ï=.Ö@2ÙA4Ö>1Î8*É5'Ê8)Ë<,É:,È:,É;/Ê<.Ê:/È9+È5+Ç5(Ê6,Ï;/Ò>4Ó?3Ö?6Õ>3Î7.É,#Ò+%Ü-*ç02ð39ö1;ú0>ý0Aþ1Bú1A÷1@÷1@ö0=÷/<÷-9ú,9ú*7ü0<ù/;ô0:ñ4;í6;æ69ß55Ú53Ü86Ý97ß:6â:7å97ç77ê65ì44ò59ò59ð67í76æ74à72Ú6-Ö6*Õ7+Ô8)Ô8)Ô9'Õ8'Õ8%×7'Ô9%Ð9$Î<%Ï=&Ï?'Î@(Î@*Ð?.Ó<1Ñ61ëHIÿfrÿOdÿHfû7[ÿAmý/]ÿ7aò4XäQk¼Ufm19E(,E697325426926=-5:#38CCja:…TŸ®w©Á‡µÍ™¯Ç•’®}v”be†Q`‚F`…BcˆBiFo•Jr˜Or—Rq•Up”To”Ol‘KhHf‹Fh‹KiŒLjŒOi‹Og†Kf…Je„If…Ii‡IjˆJi‡Ig‡FjJk“Mn–P(0#+1'14-561764<87@<9C>8IE<HE<KHCRPQ\Zecbtbb|``‚_^ˆZXŠTTŠTT\] gi³psÄvxÍ{Ø~‚Ûƒ„Þ„†Ý„…؃„Ö…„Ô†…у†Ë‚…ȃƒË‚̓€Ñ…€Ôˆ€Õˆ€Ó…Ò‹„È‹ƒ¾‹ƒ²‰‚¤|“wp€wfp~U[|PQnUNf_O^fNZdIaaGq]E‰TF­]TÈZ[ÔVZâ[aæ]déaeîllõzsírj÷xoÞYPå[PÒD8Ã5'Ç:)Å9(Ä;(Å<)È=(Ê;*Î;+Ñ9,Ô6+Ó0'Õ4*Ò8,Í;,Ç;*Â;(À;(Ã<)È;*ÕC4áK=ÞH:Ó=/Ë5'Ê6(Í;,È9)È9)È9+È9)Ê8+Ë9*Ì8,Ë7)Í6+Ò<.×?4Ø@3ÛA7ÛA5×:1Ò1)Ü0.å14ï5:õ6>ù4>ú2?ú0@ù0@ò.<ï/<í/9í07ï-5ï,2ò+2ò+2ö3;ó4;ò5;í6:å57á55Þ65Ü75Ü86Ý97ß:8ã99æ87é77ê67ì46ô5:ô5:ñ7:î79ç85à72Ú6-Ô6+Ó7+Ñ8*Ð8*Ð9(Ð9(Ð9&Ñ8(Ð9&Ë9"È:"È=&Ç?'È@(È@*Ì=-Ï;1×96üU\ÿ^qÿGcÿ?aÿ;bÿ7gþ3bû8`íFdÅNa‰@IT15A55@:<:46?56>6389+6<"9CSZ.‚Q¢§q±ÅŠ¯ËŽ°Ë”¦Ã’®}{™eh‰R_E^ƒ@c‰@iDo•Js™Ps˜Sq•Uo“So’NlJh‹Gf‰EgŠJiŒLi‹Ni‹NfˆKd†Id†Ie‡Ji‰JjŠIi‰Hf‰Ej’Ll–No™Q&.!)/%-2+13.333764:97=<7GD=DD<HGCPPRZZd_ap``z\\~`_‰][YX‘]]›gg­rtÁz|р܄ႅ䅆ㄅჃۂՃ‚Òƒ‚΄‡Ìƒ†É„„̃‚Î…‚Ó‡‚ÖŠ‚׌ƒÔ…ÐŒƒÄ‹‚·Š‚«†€œxˆsnuqbewXVtSLjVKg`NbfO_eIcaHp^F{R@ž\N·ZSÆTS×VZâW\êY`òce÷qnðme÷qhÑD;ÔA7Å1%È4&ÔC2Ç8'Ç:(É;'Í<)Ñ;,Ó:,Ø7-Ù6-Ï,#Ï1&Î6)Ë<,Ç@-Â?+¾;'¼7$À4#ÑB2ãOAåOAØB4Ë7)Ë7)Ð>/Ê;+É:*Ç8(Æ7'È6'Ê6(Î8*Ð8+Ó;.Õ;/Õ9-Ò6*Õ7,Ú<1Ý<2Ü71è88ñ8=ø;Bû9Bú4Aö0=ò,;ï,:í/;ê19ê2:ë48í49ñ48ô36ó57ð37ï6;í9<é69â45Þ44ß76à;9Ý86Þ97á98ã99æ87é77ê67ì46ô5:ô5:ñ7:ì89æ95ß82Ø7/Ó7+Ð8+Í9+Í9+Ì;*Í:*Í:(Í:*Ì;(Å9"Ã;#Ã=$Â>'Ã?(Æ?,Ê<.Ð92ß<?ÿ\fÿQhÿIfÿ9]ÿ=hù.]ý<hé;\å\p¦LV^-0G85BC><89?48F37C41=:)>D(GV-bs?›a­½±ËŒ«É‹¦Ã‹º„Ž¬z{™ef‡PZ|@^?a‡>iDo•Jr˜Or—Rp”Tn’Ro’NlJgŠFeˆDf‰Ih‹Ki‹Ni‹NfˆKe‡Jd†IeˆHgŠHh‹GjŠGg‹Ek“Lm—OpšR)/#)/%(-&+-(///3317759:4==5?@8DE@KKKQQYVXe[[s^]}YX‚[Y‹^]–ee£nn¶wxÈØ„…⌌ðŠŠì†‡ä‚‚Ü€€Ö‚€Óƒ‚΂‚ȃ„ǃƒË„„ΆƒÐˆƒÓ‹„ÒŒ„ÏŠ€ÅŠ€¼‰€¯‡}Ÿ€xwozkegf]Xm[Qm[Mi\Lf^Kd_IeaHh`Io_FoP;…UA¦^PÀbZÑYXÝQTîS[ø\`ùggæYRÔD<Î70Ñ7/×:1Ö<0Ô;-Ï9*Í:(Ð:)Ñ:)Ô8+Ø8,Ü5,Ü5-Ð/%Í3)Ì8,Ê>/Å@/ÂA.¾=*½:(Â9)¾0"éWJàL@Ã/#Ñ=1Î</Ç8(Ê;+É:)È9(Ç8'È7&É6&Ë5&Ì4&Ð7)×;.Ü>2Ü<0Ù7,Ú8-â>4ìC<õBEò9?ñ3=ö4?ö2@ñ-;í-:í2=ì7@æ5;ä5:å78ë8;ð9;ò89ï77ò;=î<<ê::æ87á77ß76Ü75Ü75Þ97á98ã99æ::é9;ì9<í9<ï8<ô7;ó6:ð8:í9:ç;9à;5×90Ï7,Ê8+È9+Ç9+Æ:)Ç:)È;)È;*Ç<)Á9#Ä='¾:#¶4¼9%ÉD3Ï?6Ê0.ÿ^eÿVgÿIbÿ<\ø1X÷0Yû6cõBiçYo¬FQo33N3,B?6>C<A89@-1L/3K2.B9(DI)Zm?~š_ž¸w¨Å‚«É‹Ÿ¾‚˜¶€”²~‚ nf„RYwCY{?^?c‡AiFn”Im•Ll”Nk’QlPjIfŠDc†Bc†Bf‰Ih‹Kg‰LfˆKhŒNhŒNg‹Kf‹HeŠGgŒGkIm’Lq›SrUtŸW*0$)/#).',.)//-220561782;<4>?7CD>IIGOPTSUaXYk[[u\Z^]‰db”kj¤utº~·‡ß‹Œéð‰‰ë…„ ؀~Ò€ÏË…†É†‡È‡ˆË‰ˆÎ‹ˆÏŒ†Î†ÌŽ…ÈŠ€¼‰±†|¡‚x‘{s€tknlb`e]Re_Oe^Lf^Kf^Kh]Ij^Hk_Io_Fw_G[C’YF­ZLÇVPÞRSõQXÿX_ðUSãKFÙ>9Õ60Ù6/Ü90Û9.Ö9*Ó7(Ñ8(Ò9)Ô8)×7+Ü5,ß4,Ý4-Î0'É5)È9+Ç>.ÄA/Á@-¿<*¾9(Ä8)Ë<.äREÜH<È4(Ì:-È:,Â4&Ê=,Ë<+Ê;*Ê;*Ë:)Ì9)Î8)Ð7)Ó7*Ö8,Ù7,Ø4*Õ1'Ø1(Þ7.ç<5øDGñ8>í/9ï/:ð0=î.;ë1<ë6?å6=Ü36Ø24ß:8îDDùIIøDCó?>é:7ç98å97â96á77à87á98á98à87â88å99ç9:é9;ì9<í9<ï8<ó6:ò59î68ê88ä;8Ü:5Ó9/Ë7+Æ8*Ã:*Â:*À;*Á<+Á<)Á<+Á<)½9$Â@*»:%³5º;(Á;/Ê94Ø<?ÿ]iÿPdÿA[ù8Wö6[õ;`ô>dãIe«?Lƒ?>`;3G;/:>08>2F<:R>=N0.S8/VK7ciEx[°pÂ}¡Æš¹}š¹€š¶ƒ©xrŽ^YuETp=\{B_@b†@iEm“Hl”Kk“Mj‘PiOgŒGe‰Cc†Bd‡EgŠJiŒLi‹NhŠMiOiMiŽKhHgŒGhGl’Im•Lp›SqœTtŸW-1#-1#,/&,.)//-11/34/56.:<1<>1@B7FGAKMLQRWVVbXWi\Yt^]fdŒpn zx·…ƒÎ‹ßêŽïŽŒíŠ‰ç‡„ßÓ|Ë}È€ņ…LjˆÆŠŠÊŒŠÉŽ‰É‡ÅŒ„¿‹‚·‰€­†|¡€v{p€ujpoeci_Vc]M_aL_aKc^Jg\Jl[In\Ho]Ir^FwaIxX?‡S=£VDÇXOãUSøOTþMSâ>=Þ<7Ý84Þ71á6/â7/Ý7+Ú7(Ô7&Ó8&Ô9'Õ8'Ø6)Ý5*à3,Ý4-Ë3(Ä6*Â8+Á<-Â>/Â>/Á<-À8*Ã5)ÜI?ÚF<ÕA7Ï<2Ä6*Ä:-¾6&Æ:)Ç:)È;*É:*Ë9*Ë7)Ì6(Î4(Õ9-Õ7,×4+×3*Ú3+ß6/å:3é<8ð<=í49ë07í29î3<í4<ë7@ê=CÝ7;áAAìNMøYUýYWúQNïB>å84â62à72à74à74á85â96ä::ä::á77ä88æ8:é9<ë8<ì9=ë8<ì8;ï58ï58ì57ç77â:7Ù:4Ï8/Ç7,Â8+¿:+½;+»<+»<+»<)»<+»<)¸9&½@*³9$±6$¶;+µ0'Ã40ìPTÿ[iÿJ`õ:Uð7Vñ@]ïHfçHdÍNa‚89e?6R@2DA09=,57)?7,L:0F.$R=,g]Bˆ_“ªt—»{–Áz–¿{”³zœ¸‡š´…€šm]vLHb5Nh8\wB_}?cƒ@hŒDl’Gk“Ji‘JgLgNd‰Dd‡Cc†DeˆFh‹KkŽNkOkOkOkOiMhJgHi‘Hl”Ko™Mu¡Vt¢Wv¤Y24&04&12*01+12-23.34.46+9;-;>-?A3DF9JKENPORQWTT^XVd\Zoda~nl”zw¬„‚ÃŒ‰Ö‘㔑ê“뎋≅قÌ|Ã|¿€~¿„‚Á†…Á‰ˆÂŠÃŒ‡¿‹„¸‡®…}¤…{€vŽyn~rgmmaak^Vi[Pc\J^aL]aJc^Jh[JmZKqZJtZIv[FsWAxR;ŠQ=«ZGÍ[PãTPðFIñ>AÛ2/Ü5/á51ã60ã5.á5+à6)Û8)Ö6&Ó8&Ò9'Ô9'Ø6)Ü6*à3,Ú6-É7*À8*¼7(½9*¿=-Â>/Ã;-Ä8+Æ3)éUKÔ=4Ì8.ÑA6¾4'À<-À<-À8(Ä8'Å9(Ç:)È9)Ë7)Ì6(Í3'Ò6*Ô3)Õ2)Ü5-ã:3é>7ì?9ì=:è45ì59ï6<î5;ê2:æ39ä7=â<@óUVübbÿmjÿidóVQäA<ß63Þ50ß61Þ71Þ63ß74á85â96å99æ::å78æ89è8;é9<ë8<ë8<ë8<ì7<ï6;î68ê67å97ß<7Ö<4Ì9/Å9,¾9*º;*·<*µ<)µ<+´=)´<+³<(³:'·@,­8&­8'³;-«+"Ã54ý`iÿTdúG]ð<Uë=XèH`áOdÒO_´SZvGAXH9KD2FE1BE0=?*:8#;3?3PG*nkHŠ“f—«v“³tŽ·s‘ºxžº‡¡¸Œ¦l‚[K_:BW0Mb7Yq?`|Adƒ@iŠClFi‘Hg‘IeKeŽJb‡Bc†Bd‡EgŠHjMlOm‘Qn’RlPj‘Nj’Li‘Ji‘Hi“Gm—KpœOv¤Yw¥Zy§\78(68*77-56056167267/68+;>-=@-@C.DG4IK>MNFQPNRRRVUSYX]a_lkius›€}²ˆ†ÇŒŠÓ•’ᔑâÜ‹‡Ó„Ä}º|µ|³~·„º‡„¹‰…·Š„²†¨z›€x€tˆznzrfjm_^j[Ti[PjZKfZJb_Lb_Le^Li\Kn[Lr[Kw\K|[HVB‡S>›RA¶VFÏSIÚG@â88å33Ý1-ß3/â51ã4/á3,ß3)Þ6)Ü9(Ó8$Ð9$Ð;'Ñ:'Õ8)Ù7*Ý5,Ø7-Æ:+»9)µ6%·8'½;+Ã>/Ç;.Ç7,Ð90õ\TÖ=5É5+ÏA5¹4%·:(¼?-À;*Ã:*Æ:+È:,Ê;-Ì:-Ï8-Ñ7-Ð3*Ò1)Ö1+Þ71å<7ê>:é<8æ74é77ï;<ð<?ë6;å28ä5:èBFíMOÿxwÿqnñ`[ÝJCÑ83Ñ2.Ü75ç?<à93à93à72à72â64ã75å76å76ç79ç79ê7;ë8<ë8>ë8>è7=ê7;ï8<î7;ê7:ä::ß=:Ö=7Ë;2Ã;/º8*µ:*³;*¯<)¯<*¬<(¬;)¬;)«<)­>+§9(§9*ª8-¬/)Ë@CÿhrôM^óH[îEZåH[ÙO^ÉT]·TWœXUdM?PM:LG4KF2FD-@C(>E$?I$KV.\g<xTŒ˜h‘¤m¨n²r—¹}Ÿ¶ˆ’§€u†dRcC?P0BS1Oa9Wm>b{Be‚BiŠCkEi‘HfHbHcŽGb‡Bf†CgŠHiŒJkŽNmPn’Ro“Sk’Ok’Ok“Mi“Ki“Ik•Io™MržQv¤Yv¦Zw§[?=.=>0==3==5=<7<=7;=2;=/?B/@D-CG.FJ3KL:NOAQQIRRHYWJZZN`_]gerqn‰{y¡ƒ€·‡…Čьӊϊ…ǃº~y¯zw¦yv¥{v¬|y®€|®ƒ}©ƒ}£x—|t‹zrvksrffn`]j\Sk[NlZLl[Kk[Ki]Mg^Mi]Mj]Mo^Ns^Mz]M‚[J“`O›VG§N@¸J=Å@7Ï60Ø1+Þ1+á51â70â5/â4-à2)Þ4'Ü6&Ú;(Ñ9$Í;$Í<'Î;'Ñ:)Ö9*Ù7,Ó9-Â=,µ:(°5#³6$»9)Ä<.É;/Ë7-Ù?7ø[TãIAÎ:0Ì@3¸6&¬3 µ<)½:(¿7'À7'Ã7(Å7)É7*Î7,Ñ7-Ù<3Ü;3ß:4å<7ê>:ë>:ç85ã41è96ë;;ì::è8:ì>@øORÿbeÿppùheãUQÊ=6À1+É40Ö;7ß=;à;9â;5â;5â94á83ã75ä65å55æ66é69ê7:ê7;ë8<ë8>ë8>è7=ê7=ï8=ì8;è8:ã;:Ý>:Ó>7Ê=3À</¶8)²:)®;)«<)©<(¨;'¦;'¥:(¥<) 9( ;) 9*¢6*µ>8ÛTXûepîK\ïI]éJ^ÛM[ÉQZ´VV ZRŠ`RPI7IN:NI5H@+;578>O%Lf6lŠTw”\„›e‰šd›f‘¢l•¬t˜°|ƒ•mn}\Q`C<J09F,AP1O_;Wj=d{EfƒCkŠDlFi‘He‘FaFcŽGcˆCi‰FjKlMlOlOm‘Qn’Rm”Qm•Om–Pl–Ll–Ln˜LržOs¢R{¬]{«_zª^EB1DB3DB6CC;CC;CC;BB6BC3DF0EH-GJ-JM2ON9RQ?TREUSD\ZC\\D\]Oaaaihxrq{z¦~µ†‚¿ˆƒÃˆ„Á„º{®ys¡to—ql•qmŸrn¡vpžwršwr’to…skzrinmb`l_Wj\Qk[Lm\Lo\Mp]Lq[Mq[No[Pm]Nl_Om`Os`O{`O†ZMŸ_S¥QG®A:º;4Æ6.Î1*Ö2)Ý5,â70á6/á4.á4-à4*Ý5(Ù8&Ô9%Ï:"Ê="Ê>%Ê>'Í<)Ò;*Õ9,Ï;-¿@-±<(¬5!®3!º8(Ä<.Ê:/Î5-Ø93ðNIñTMÙB9ÌB5¾?.¦1´=)¿=-Á9+Á7*Ã7*Å7+É9.Ï;1Õ<4âE>ãA<ä?;ç>;é=;é;:è88ç85è96æ95æ66é;<ôJKÿ\]ÿdeøbaÌ=9Á82½4.Ä92ÕA=ÞE@ß=;Ù42â;5â;3â94â94ä84å84ç77ê88ê69ë7:ì7<ë8<ë8>è7=è7?é6<ë6;ê7:æ89à;9Û>9Ñ>6Æ<2¾</³8)®;)ª;(¦;'¤;(£:'¡:'Ÿ:&¡>+–7%œ=+š9)š2'ÃPKíkmî\fìP^éJ\ßHYÎLV¹RS¤[R’cQ€jUJM8DL7JB/H9$B7FH#Up=g“V~²p‚³qƒ¥h}’YƒYŽ–cŠ–d|Œ_XfCHU9:F.7C+:D,=J0JX7Wh>e|FiƒDl‹Em‘Gi“Gd’Ga‘GaGf‹FlŒImNn‘OlOkŽNkOm‘Qp—Tq™Sp™SpšPo›PqPv¢Sw¦V|­^z­^y¬]IC3JD6IE9JF;IF=IG;HF9HG5IH3JJ2LL2NN4RP;TQ>XRDYTA]Y>[Z>\YH_\Udahnk~xs“}x {§ƒ}«…­ƒ|¦}wvooi…lf‚ieˆjf‹mhˆmi‚mh|lfrkbgj`^g]Th\Nh[Kk\Io^Lq_Kq^Mq^Mp]Op]Op]Os]Ow]N~]N‡\L’XL¢VI¤F<«9/º7/Ê7/Ô7.Ú6-Þ6-ß6/à5.ß4,à5-ß7,Þ8*Ø6'Ñ6$Ï:$Ì<$Ë='Ë='Î;)Ñ;*Ó:,Î<-¾A/¯<'©4"¬3 ¶9'Á=.É;/Ì8.Í3+àA;ø[TàI@ÐD7ÊF7«2¹>,ÊF7ÌB5Ê@5Ë?2Î@4ÔA7ÜE<ãF?â@;â=9ã:7ã75ã54ä65æ:8å<9ä?9à=8Ü:5ß@<êLIêQLÓ?;¸)#¸-&¿6.É>7Ñ@;Ö>9Ú;8ã;;ç==â96â96â96ä86å95ç:6é99ê::ê88ê88ë8;ë8;é9<è8;ç6<ç6<é6:æ68â89Þ:8Ö=8Í>6Â<1¹;-®8*ª;*¦;)¢;( ;'Ÿ<)ž;(š;'˜?-Œ5"™=.˜8*—/&Í\X÷y|ßX_æXdÛQ^ÊKT¹LO©VRž`U‘hV€nVPW8?J*<;C=UQ+lvD„¢f”Á~‡¼v†¸s|žbn‚MvR‚‡^u}V[b@;D)4<%5=(=D2<E29C+CP2Vf?g{HiƒFmŒHm‘Gj“Gf’GbGcŽGhJlMo’Po’PlMiŽKjJj’Ls›UsUsSržQržQs¢Ry¥V{ªZv¦Zu¥[s£YRK;RK;RJ=RJ=RJ=RJ=RJ=RK;UN<VO=WP>XQ?YR@[TD\UE\UEc\Ib[IaYLbYRe][kaiqftuj{zn„|pˆs‹s‰|p„uj{mbrf^kc`k`_g_\c_Z^^ZY^YUaZRbZOe[Og[Ki\Kk\Il]Hm]Fm\Hj^HibOqfTqZJuOB‹WJœ\P¤ZM¬ZL¥M?¦E5§<,±7(Â8-Ñ80Ü41Ý1-ß6/Þ7.Þ7.Þ7.Þ7.Û7+Ù7*×7)Õ8)Ô8)Ò9)Ò9)Ò9+Ò9+Ô8+Í;,½;+¶>-®9(©1 «2!¸:+À</Ã9.É6,Î5-Ô:2ÛB:ÝK>ÔH9Â=,·2#ÝPFÙKAÔE=ÕE<ÚG?ÞG@àC>á=;à74æ87í;;ì::ç77ã75à85Ü=7ÙF>ÏB9Ä:0¼3)·1&º6*¿;/Ä@4Ã:0Ê=4Ó@8Û@;â=;ç;;ì8;í9<ç7:å8:å8:å99å97å97å95å95á51á51ä65å76æ89ç9:ç9;ç9;ë;>æ9;ß9;Ü=:ÖA=ÍB;ÁA6·?1©9+£<+ =*›<(™:&–9'•8&9&A0‹<-‡/#’0'¼LJämoçloÍVZ½LNµNOªPO¢UO›XP—]R•aTŠjSWZ/:M7FTa)~ŽP›°o¡¼y¼y’µs~ah€N\mCYdBT]BHP9?D0:=,@C2=A2;?1<C3:C0AN2Rd>]sBgƒHpKo“Kl’Gj’Ii“KgLlPm‘So“Sn“Pm’Mk“Jm–Jm˜IqœMqNrŸNr¡Pt£Rv§Vz©Y{©^y¦cm™ZcPWN?WN?WN?WN?WN?WN?WN?WN?XO@YPAZQB[RC\SD]TE^UF_VGd[Jd[LcYMcYOf[Uj_]nbdpdhreltgpvirvirsfmm`gg[_bXY^[VZZRZWPXULXTIXTH\VH^WGcZKcZIf[Ig\Hi]Gj^Fk_IiaJcbMngTv\MSF›WN«VO°RJ¸RF¯G:¬B2¬=,±9)¾8,Ë80Õ62Ù40Ý6.Ü8.Ü8.Ü8.Ü8.Ú8-Ù7,×7+×7+Õ7+Õ7+Õ7+Ô8+Ô8+Ô8+Î:,¾<.¶>.®9(¦1 §2 ²:)¹>.¾<.Æ:-È5+Ë4+Ò;2ÜE:áOBßQCÝOCÛF?Ø@;Ó;6Ò:5Ö=7Ú=8Ü86Þ44è8:ë78î79ë78ç77å97â=9ÛB<ÊA7À@5¸:,±6'¯5&²8)¸=-¿@1ÅA4Í@6×@7ß=8ã:7é77ï58ñ7<é6<ç6<ç7:æ89æ87å95å95ã:5â92ã:3ã:5ä;6ä;8ä;8æ::å8:ä:=ã:=ß<=Ù?=ÐA;Å@7·=2­<.¥;+ =*œ=+—<)–;(’:&‘8&Œ9'€9'€8)‰5*<5¿QP×eeÑ^a¸NN¬NL¤SOXQ˜\R—^S˜_T˜_VŒfQ`_/Sg*^r3zO™¯n¥¾|™²pˆ bj‚HbvCTe;KY8FP7@I69?158-:</AB4=?4:=2>B4:C0@M3Rd>^tEh„IqMp”Ln’Hm“Jk“Lj‘Nm‘Sn’To“So”Ql”Mk”Hl—Hm˜HpJpJp Ls¢Qu¦Tx©Xx©Xx¨^m—Xb‹QY‚H]TE]TE]TE]TE]TE]TE]TE]TE\SD\SD]TE^UF_VG`WHaXIaXGe]Je]Jd[Je[Oe[Qf[Uh]Yi^\j^^j^`k_ak__i^\f[YbWU_VQZUOWTKUQHRNCQMBSOCWQCXRB^WG_XFaYFc[Fg\Hi^Hk`LicMbaMngUy_PˆXN¢[U±VQ²IE¸E@¹@8¸>3·;/¸8+¼8+Ã9.É;/Ñ:/Ù8.Û7-Ü8.Û9.Ú8-Ú8-Ù7,×7+×7+Õ7+Õ7+Ô8+Ô8+Ô8+Ò9+Í;,À>0·?/­:(£2 £2 ª9'³>,º?/Ä?0Ä8+Å2(È4*Ð<0ØF9ÝN@âNDÙ:6Ø43Ô20Ö42Û97á=<æ<=é;<í9<î5:ë27ê37è58å99á<:Ù@:¾8-µ:+±6'®4%­5%°8(µ<+»=.ÈD7ÐC9ÖB8Ý>8â96è66î66ï79ë6;ê7;ê7:è88è88ç:6æ:6æ;4ã:3ä;4ä;6ã<6ã;8â:9á99Þ88Ý9:Ü<<Ú@>ÓB=È?9º;2­7+¥7(¡;,<+™<+”;)“:(9&8%Š9&z6#y6%ˆ9, F=¹SOÀWT¸PO«IF¢MHœSLšZQ—^S—aW—aW˜_V‹ePsrFzV“¦n¤¹€«À‡ž³{|[[o<@S%AS+BQ0?L2:C06<.69058/9;.@A3=?4:=2=A3:C0@M3Qc=`vGi…Js’Or–Np”Jo•Lm•Nl“Pp”Tq•Uo–Sn–Pl”Ml•Il—Hn™IpLpLpŸNu¤Sx©Xyª[u¦Wq X_‰JVGOx@aXIaXIaXIaXIaXIaXIaXIaXI_VG`WH`WHaXIbYJcZKd[Ld[Je]Hf^If^Kg^Mg^Of\Pf\Rf\Sh]Wh]Wh]Wh]Wg]Tf\RdZPc[P]YNZVKVRFRNBPL@PM>TN@UO?XRBYTA[VC]XDaZGd]Jf_LfaMdcQleUv\OŠ[Q©b\¸ZX¶FD¹<:Ã<9Æ;6Ä92Â8-¾8,½;+¾?.Ç?/Ó9-Ù7,Ú8-Ù9-Ú8-Ù9-Ø8,Õ7+Õ7+Ô8+Ô8+Ô8+Ô8+Ô8+Ò9+Í;,Á?1·?/­:(¢3 ž3¢7#¬=)µ@.¼?-¿:+Ã7*Å5*Ë7+Î:.Î</Ó:2Þ66à24Û12Ý34à88æ<=ê=?ì<?î7<ì38é06æ25å58á77Ú65Î61·5(¯7'®6&¬7&¬7&®9(²:)µ:*ÃA3ÊB6ÔA7Ü?8ã;8æ87ë76î79í6:ë7:ë78ê86ê86è94ç:4æ;4â92á:2ß:4à;7Þ:8Ý;9Ü:8Ù99Ö<:ÖA=ÒC?ÊA;¼<3¯6+¤6'ž7(œ;*˜;)”;)’;(:&Ž9%Œ7#‡9%€=*w6$5'™E:ªPH¬MG©LG¦QLPJ˜UL”ZO”^R•aV–bW—aWgT‰…_™©z­½Ž¦¸ˆ¡ts†YN`8/A->4C&:F.=F3;A3:=2:=4<=5::.?@2<>39<1<@29B/?L2Qc=awHj†Kt“Ps—Or–Lq—No—Pn–Pr—Ts˜Up˜Ro—Pm•Lm–Jn™Jp›KqžMržOt£Sy¨X|«]w§[mSe’M[„HS|DNw?d[Ld[Ld[Ld[Ld[Ld[Ld[Ld[LcZKcZKd[Ld[Le\Mf]Nf]Ng^Mf^Ig_Hh`IiaLiaNi`Oh_Ph_Pj`Tj`Ti`Qh_Ph_Nh_Nh`MhaOd^N`ZL[UGVPBPM>NK:NK:NK:QN=RO>TQ@VS@XWC[ZF]\H^]Kb`Qf^QmWJ†[R­jd¾c`ÁMMÈBCÐ;=Ô89Ó84Ì70Á9-º=+µB-¼B+Î;+×7)Ø8*×:+Ù9+Ö9*Ö9*Ô8)Ô8)Ô8)Ô8)Ò9)Ò9)Ò9)Ò9)Í;,Á?1¶>0«:(¡6"š4›7 £=&¯B-³;*º;,Â:,Ç9-Ë8.Î:0Ñ=3Ú;5é9<ì4<æ39ã28â38â59â38â17é6<é49ç4:ç7:ã9<Û76Ð21À/*´6*­9*­:(«:(«:(«:(¬9&¯7&¸:+Á;/Î>3Ø?7á>9ä;8è96ì87î68î66î66í74ê84è:3ç:3ä<3á:2ß;2ß<5Ü=7Û=:Ù><×=;Ô>=Î@<ÊC=ÅA<º>6­7-£5(ž7(š:*–;)“<)‘;*:(Š9&‰8%ˆ7$ƒ8%ƒ@-u4"{3%“G:¥RJ¡NFžNG¡WN™VM“YMZNŽ]O]R”`U—`YhWˆh˜¤|©ƒ€Žj]kHDS42@&$2-:&0;*5=.9?3<?4=>6;<4::099-?@2;=28;0;?18A.>K1Pb<bxIk‡Lu”Qt˜Ps—Ms™Pq™Rp˜RršSršSršSp˜Om—Mm—Kp›LsžOt Qv¢Uz¦Y{©^z¨_qŸVd’JZ‡D]†JW~GRyBe\Me\Me\Me\Me\Me\Me\Me\Me\Mf]Nf]Nf]Ng^Og^Oh_Ph_Nh`Kh`IiaLjbMjbOjbOjaPjaPjaPiaNh`Mh`Kh`Kh`IiaJjbKf_Mc^K^XHXRBSM=MJ9KH7IH6LK9LK9LM;NO=PQ?QTCSVETUE[YL^VIcQEzXN¡ha¶eaÄVU×RSÙ@Cß:>Ü87Õ83Ç;.¼?-±C*µA(Ê;*Õ8)Õ8)Õ9*×:+Õ9*Õ9*Õ9*Ô8)Ò9)Ò9)Ò9)Ò9)Ò9)Ò9)Í;,Á?1¶>0«<)£:%™6•5›;#§A*²B.¹@/¿;,Ã7*Å2(Ë4+Ò;2ß=:ê5:î3<ë6=é8>ç:>ä;>ã:=â9<ß58á7:â9>á=>Û=>Ñ96Ã2/¶0'¯9+«=,«=,©>*ª=)©<(©:'«8%¯6%¹7)Å;0Ð=3Ù<5ß<7ä;8é:7î87ï75ï75î85ë:4é;4ç<4ä=4â>5à?7ÞA:ÛB<ÙA>ÕA?ÒA>ÍB?Á@:»@8³=3ª8-¡5(›5'™9)•<*‘;*<)Š<(‰;'†9'„7%ƒ6$€7&}:)t3!~9*—OA£YNœRG•OE™WK•YN[MŽZMŒ[MŽ\Q“_T™`Y‘gY~wZyƒ`r|ZVaC;E,/;%0;*0<.3=25=27=3<?6@A9?A6<<277+89+>?1:<17:/;?17@->K1Oa;bxIk‡Lu”Qu™Qt˜Ns™PršSq™Rs›RsœPr›Op™Mn˜LpšNsžOv Ty¥X{§\|¨]z¥]qŸWg”O]ŠEX‚BaˆOY€ISzCg^Og^Og^Og^Og^Og^Og^Og^Og^Og^Og^Oh_Ph_Ph_Pi`Qi`OjaPjbOjbOjbOi`Oi`OiaNiaNiaNh`Kh`Kh`Ih`IhaGhaGhaGg`Me^Kb[I\WDWR?PM:MJ9IH6IG8GH8GJ9GK:HL;IM>JN?KM?PPDXRF[OCiRD„ZN–VL°SLÔZYÛIJâ?Bá99Û75Ï;1Ã@.´B*³<$É:)Ó7(Ô8)Ó:*Õ9*Ó:*Ó:*Ó:*Ò9)Ñ:)Ñ:)Ñ:)Ñ:)Ñ:)Ñ:)Í;,Á=0µ=/¬=,£<)˜8"4•9 ¡A)­C-¶A/¿=/À6+Â/%Ç0'Ð6.Þ:8è59î6>ì;Cê?EæAEàBCÜ@AÚ@@Í12Ð66Ó:<Ñ=;É;9¿82µ4.­4)ª<-¥>+¦?,¥@,¥>+¥?)§<(©:'ª7%²7'¼8+Å8.Ì70Ô94Þ<9æ>;ë97ì95ì95ë:4é;4è;4å=4â>4àB7ÝC9ÚC<ÕB;ÏA=Ê?<Ç=;¿>9±<3©:/¢8+œ6(˜7'”8)‘:):(‹<+‰<*‡<)ƒ:'‚9(€7&6%}6$x3#x5%†C3˜UEWK”PCPD•ZL“YMZN\Q\Q’[T•\U™\WŽbUkbEWa>JS4=G,6?*3>-4>35?66=69@9=B;CF=EG<DE7@>/;9*78*=>0:<17:/:>07@-=J0N`:awHk‡Lu”Qu™Qt˜NtšQršSq™Rq›OrNqœMp›LošKrNu¡Ty¥X«`~©az¥^qœWf‘L_‰G]‡E^ˆIb‰PY€KSzEh_Ph_Ph_Ph_Ph_Ph_Ph_Ph_Ph_Ph_Ph_Ph_Ph_Pi`Qi`Qi`QmdUlcTj`Ti`Qh_Pg^Oh_Nh`MiaNiaLiaLiaLiaJh`IhaGh`IgaKg`Me^Kb[H\WDUR?QN=ML:EF6EH7DH7DH7CJ:CJ:CI;EI;IK>SQDSPAYM=eK:tD6–I?ÂYSÙQQàDEà::Ý86Ö<4Ê>/º=)µ8"É:)Ð9(Ñ:)Ò;*Ò;*Ò;*Ò;*Ò;*Ñ:)Ñ:)Ñ:)Ñ:)Ñ:)Ñ:)Ñ:)Í;,Á;0¶:.­<,§>+™9#3“7Ÿ?'¢9$¯<)À>0Ç=2Ì8.Ð7/Ù<5ã?=ì=Bî?DêDHâDEØ@?Ê;7À50»1.¹/,¼51¾:6»<6³:2ª8.¤8,¢;,¡=-Ÿ>+ ?,¡@-¡@-¡A+¤?+¦=*©;*­:(²7(¹5)¿5+É90Ö>9àC>å<7è;5è;5ç<4å<5ä=4á>5Þ@5ÜD9ØD:ÒC;ËB:Ä?:½<7¸85°93¢7-™8(•5'“6'‘:)<,‹:)…8&ˆ=*…<+ƒ<*€<)~9)}9&{6&{6&z2$€8*ŒG8–SC“QC‹L=RE™_S‘WL’YN”[R–]T—^W—\V—ZU_RaX;EM(6@8A&>G2=F53=2-7.1817>6CF?GJ?HI;BC1?>*;:&78(=>09;069.:>06?,=J0N`:awHj†Ku”Qt˜Pt˜NtšQršSq™RqœMqœLqœLp›Kp›LsQw£V{§\‚­e€«dx£^j•P]‡EYƒA^ˆHePcŠSZLSzEi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi_Sj`Wj`Wj_Yj`Wj`Vj`Vj`TjaRjaRjaPjaPjbOjbOjbOjbMjbMg_Jg_Jf^Ie_Ib]IZXCSP=ML:HI9EH7AE6@D5?E7?G8?G:?E9GK=IK=BF5KJ6\Q;aE0ƒJ9Àj]Üg`ãUSäFEåA@àA=Õ>5É=0Æ=-Æ4%Ë5&Ì6'Í7(Í7(Ï9*Ñ;,Ó=.Ò<-Ò<-Ò<-Ò<-Ò<-Ñ;,Ñ;,Î<-»2(¶7.±;/¨:+š7"”5–7!œ9"¬A-²=,º6)Á4*Í6/×<7âC?êHEèDEéFIÝCEÉ98»61´80®8.©4+«9/©9.¥9/ 8-›9,–:+“<+’<+–=+˜=*™>+š?,›@-@. A/£@-¢;*¥:(«7(°6)·7,¾8-Ä;3Ì<4Ú=6à=6â?8âA7âA9ÞB6Ú@6×@5ØH=ÒE;ÇA8»;2²5/ª3-¦0,Ÿ2+™9-’;*‘9+:*‹:)ˆ;+‡;+…<+:(~9)|9(|9(|9){8'y6&x3$w- ‹A6˜PD“MAMA’RF“UJŽRG˜\R˜\R‘UMTL—ZU•XS”WT“gZ]T5IQ*BL)BK,>H/7@+2=-4?14<1HPCZ]RX\MMO:DF.AA'==%:;)>?1;=2:=2<@24=*;H.Pb<cyJlˆMu”Qs—Or–Lr˜OršSršSrNqžKrŸNrŸNsŸPv¢U{§\ªb‚­fx£^j“O`‰G^†Ga‰JfŽPi‘Ud‰S[€LTyEi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi_Sj_Yj_]j_]j_[j_Yj`Wj`Vj`Tj`TjaRjaRjaRjaRjaRjaPjaPh`Mh`Kg_Jg_Jd]J^YEUR?ON<IJ:FI8BD6@D5?E7?G8>F9=E6@F8>E5>F1HL5MI0U?(P<¼sdËcXà_ZëUTçGGâ@>àA>Ø?9Î:0Í9-Î<-Ï=.Ï=.Ï;-Î:,Î:,Î:,Î:,Ð:,Ð:,Ð:,Ð:,Ð:,Ð:,Í;.É?5ÅB:¼B7®=/ 7$—2–1›2¦5#²7(Ã:0ÑA8ßF@æIDéJFêKHÞCAÛEDÐB@¼;5¯9/©=0¥?1Ÿ=0Ÿ?1œ>2˜?1”>/=/Š>.‡@.ˆ?,Ž=*‘;*’<+“=,”>-–?,—>,š?-Ÿ@.¡=-¤:,¨8,¬8+±8-¶:0¼9/Ê;3Ð;4Ó?5ÖB8×C9ÖC9ÔD9ÑE8ÊB6ÃA4¹=3°:0©6/¢5. 5/™7.’</Ž=,Š;,ˆ;+†:*„;*ƒ;,<,~;*|:*{9)y:)x9(w8'v7(w3&€3)C9˜NC’L@K?QD’TIRG“SJ˜XO–UO˜WQœ]X”WRŽSOŠcT]W5Xc9_jBZfBIT66C)4@*<H4OXGYbQ_fTW\HJN7BE*??#<<"9:(=>0:<1:=2<@25>+;H.Pb<dzKlˆMu”Qt˜Pr–Ls™PršSq›QsŸPrŸLpLqNt Sx¤Y|§_ªc{¦aošUcŒJ]†Da‰JeNeNc‹Od‰S[€LTyEi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`QjaRjaRjaRjaRjaRjaRjaRj`Vk`\k__k__k`^k`\k`ZkaXkaWkaWkaUkaUkaUkaUkaUkaWkaUlaOk`LiaNiaNf_Ma\IYVESR@NL=IJ:DF8AE6AE6?F6>D6<D5=F57@-@H1IK3F?%W?'‡ZE·rb¶VJÙbZðebìTSæFHëGHæCDØ:7Ë7-É:,É:,É:,Ë9,Ê8+É7*È6)Ê8+Ë7+Ë7+Ì8,Ì8,Ì8,Ì8,Ë8.Â3-¾5/¶6-­3(¡0"ž. ¡2!§3$¼@4ÇC7ÖG?áLFèMIéJGåFBßD@×CAÏDAÁ@:±;1¤</¡A1œE4˜E3“D3‘D4B2ŠA0…@0‚A/~A.@.†:*‹9+‹:)Š;*‹<+<+Ž=,<*–?.—>.›;+9* 8+¥9-©:/®9/¸90¾90Á;0Ä>3Å?4ÅA5ÄB4ÁA4¶:.²9.ª8-£7+ž6+š8-™8/“;1‹</‰=-‡;-„;,‚:+€;+€;,<,};+{<-z;,w9*v8)u7(t6)v4&‰<2•G=–MDŽJ?ˆH<OB’TI’RI’OI™TO™SQ˜WSš]Z“YU[Tl[}X~‰^€‹alxRLX46D#=J.LZ@eqYeoW]eMPU>EI0?C(=@#:<$89';<.9;09<1=A36?,<I/Pb<dzKm‰Nv•Rt˜Ps—Ms™PršSpšPu¡Rp LnLpŸOw£V{§\}¨a|§bp™UfM\„E\„EeŒMj‘RfN`†IcˆRZLSxEi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`QjaRjaRjaRjaRjaRjaRjaRj`Vk`\k__k`^k`\k`\kaXkaXkaWkaUkaUkaUkaUkaWkaWkaXkaWnbRmbPjbOjbOibPe^L_YIYVERO@NL=GH:DF8CE7BD6@D5<C3<H4:C.FJ3MG1P;&qL9šbQª^P¡A5ÆSLçc_ð^^íSUëJOéDJáACÌ92Ç9-Å7-Å7+È8/Ê:/Ë;2Í:0Ñ>6Ñ>4Ò=6Ò>4Ó>7Ó?5Ó>7Ó>7Ô@<ÑB>ËD>ÆF=ÂF<ÃI>ÇM@ÏQEÙSJÞQJâMGäIEäFCâC@àA=ÛB=ÕFBÉD?º?7«=0 ?/šC2–H4”I6ŽG5ŒE3ˆC3…B2€A0~A/zA0}@.‚:,†8,…9+†:,†:,‡;-‡;+ˆ;+‰:+‹9+9*‘9+•9,™;/=1¢<0ª:/®9/°:0°:.°:.°:.¯9+®8*¨7)¥7*ž6)›6*•7+’8-9/Ž<0ˆ<.…<-„;,‚:+:+~9*~;+};+|:,z;,y;,w9,s8*q6(r7)u5)ŒC:“I>‘KAŠH<‡I<‹OD“TK—TL–QL›TP—QO”SO–\X_Xh^—~j””p…’fu‚WYh?CR+?O*P`<crQetU\iKOY>CL1?E+?C*=A(;='78(:;-79.9<1=A37@-<I/Oa;bxIlˆMv•Ru™Qt˜NtšQršSpšRsŸPožMožMs¢R|¨]~©ay¤_tŸZcŒJ^‡E[ƒD_‡HgŽOj‘PfL`‡Hb‡QY~KRwDi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`QjaRjaRjaRjaRjaRjaRjaRj`Tk`Zk`\k`ZkaXkaXkaUkaUkbSkbSkbSkbSkaUkaWkaWkaXkaWocUnbRkbQlcRkbShaQd]M`ZJXRBSP?NK<IG8GE6DE5BC3>B1=I1?G/LG1S>+g=-•ZL­_Sœ>6ž3+¶?9ØXUóigödeëRUæJNéOQÚIDÓF<Í@7Ë>4Î?7ÒD:ÕF>×G>ÚJBÚJAÝJCÝJBÞKDÞKCàKEàKEëSRèTTãSRÝSPØSLØSLÛTNàUPàLHáIFãEBâC@äB@âC@äEBáGEÙIHÊDAº?8¬=2¡?2˜B1’E3G6ŒE3‰D4‡B3„A1?1~?0z?1|>/€:.ƒ9.ƒ9.„:/ƒ;-ƒ;-ƒ;-ƒ;-9*ƒ:+…9+‡9,Š;,;-<.“;/›:1ž9/Ÿ9- :.¡9,£9,¢8*¢8*Ÿ8)œ8)˜8(”8)9*Œ:,‰:-‡;-„:-‚:,9+€8*}7+}7+|8+{9+{9-y9-x:-v8-q5*o5)q7+u:,ŒH=ŽJ?‰I=„I;†L@ŒRF“WM˜XO˜QMœUQ—SP“VQ’`YˆbWƒg[‡{enrQZi@JY0BS)IZ0WiAdvNj|VXiEL[:?L.:D)<D,>C-<A-:=,89+:;-79.9<1>B47@-;H.L^8_uFi…Jt“Pt˜Pt˜NtšQs›Tq›SnMmžLp¡Pw¨Y|ªaz¨`rXj”RZ‚C\„EaˆIeŒMgŽMgŽKhJg‹Mc†PZ|JRtBi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`QkbSkbSkbSkbSkbSkbSkbSkaUlbYlbYlbYlbVlbVlcRlcRldQldQldQlcRlcTlbVlbXlbXlbXocUnbRkbQlcRlcTkbSg`Pd]M^WGYSCTN@MJ;KH9GE6FC4@C0;H.@I.OC-a=-„F;¬YS´NJž,+²:9¹=;ÓSRòpnþvvñehëX^ð^_ãUQÚPFÔG@ÐC:ÑD=ÔG>ÖGAÖG?ÙHCÚJBÜHDÝJCÞJFÞKDàKGàKGâHHáGIÜHHÙGGÖHD×HDØGDÛEDàBAäABæBAèBBçCBäB@ßA>ÛA?ÛIIÊC@¹<6®>3¢@3˜@2‘B3D3ŠA2ˆ@1‡?1…=1‚<2€<1=1=1;1;1ƒ:3;1;1€</€<1=/€</€=-;/€;,‚:,9*‚8+ƒ7*Œ:/8.‘9-”:/—;.š=.ž</Ÿ>.™9+—:+“:*:+Š;,‡;+„;,‚:+‚:,9+€8*~6(|6*{5){5){7*x6*x8,x:/s7,p4)o5)r:-w=1‹M@‰K>„J<‚M=…QC‹VH’XM—WN“NI™TO—VR–]Ve\|_QgWGa_HEO->N)?O(J\4_qGk}SewMXj@N`8@Q-6E&7D*=F1=D4:>07;-8:,:;-68-9<1?C57@-9F,I[5[qBeFr‘Ns—Ot˜NtšQs›Tq›SmœLo Os¤Ux¨\z¨`s [i“Q`ŠHYB^†GeŒMgŽMgŽKeGgŒGhŒLa„NXzHQsAi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`QkbSkbSkbSkbSkbSkbSkbSkbSlbXlbVlbVlcRlcRldOldOldMldMldMldOldQlcTlbVlbVlbVocUnbTkbSlcTmdUlcTjaRf_Ob[K^WGXQARL<OI9JG6IC3AC.:G+AG+U@+xG9£PLµII¶8<º39ÈAEÄ?@ÊJIßb`ñqpðnpçbeâZ\ÛQNÕLDÐE@ÍB;ÏD?ÐE>ÐB>ÎA:ÒC?ÒC=ÔC@ÕD?ØDBØD@ÙECÚDCÝADÝADÞDFÝGHßIHàJIãIIåGHçACêADìBEìBEçAAâ@>Û=:Õ=:ÚFFÉ=<¹83±<3¦@4˜?1>0ŽA1‹=0Š<0‰;1ˆ:0‡81†93…:4„;4;3€<3:4€<3<3}=1}=3}=1|<0|=.|<0|=.};-{9)z8*{7*‚:.ƒ9.‡9-‰9.9.‘;.•<.–=-’9+‘9+Ž;+Š;*‡;+ƒ<*€;+<+€8*€8,~6*}5)|3*z4*z4*y5*u2)v6,w9.s7,p4*o5*s:/x@3‹QC†N?N=‚Q@…VF‰XIŽUJ’SJ“PJ—SP”TR‘\VŠe\n[LPK7EK1AN0KZ9WgC`rLgyQdyNWm?G\1AV-7H$1@!6B*=F5<D98=67:3:</;<.79.9<1?C57@-7D*FX2Vl=b~CoŽKq•Ms—MtšQtœUrœTožPq¢Qu¦Wv¦Zs¡Yj—RbŒJ[…E^†H`ˆId‹LfLhJhHf‹Fe‰Ia„NXzHPr@i`Qi`Qi`Qi`Qi`Qi`Qi`Qi`QkbSkbSkbSkbSkbSkbSkbSkbSlbVlcTlcTlcRldQldOldOldMldMldOldOldQlcRlcTlbVlcTnbTmaSmaSmaSmdUlcTjaRg`Pd]M_YIZSCTN>PK8MH5ID1DC.@F*DD([B,ˆTG¯\X«>A¬/5ÎHOÆ?EÀ;>»;<ÄFGØZ[ãefÛY[ÌGHÑJGÐEBÍB?ÐB>ÔFBÔFBÐB>Ê?8ÏD?ÏD?ÒD@ÔEAÖEBÙECÚDEÝDFß@Dß@DÞBEßEGáGGàFFàBCá>?èBDé@Cè>Aç=>ä>>ãA?áC@ßEC×CCÅ98¶50°;4¦?6š>3=/?2ˆ</‡:0‡:0‡81‡83ˆ94ˆ94ˆ;5ƒ:3;3€:2;2~<0~<0|<0|<0x8,y9-z:.z:.{<-{<-{<-z;,};/9/€7.7,„6*…5*†7*‡8)Š8,ˆ9*ˆ:-…<-„<-€=,~<,~<,}9,}7-|6,z6+z4*x4)y5,x5,r2(u5+v8-r6+n4)n5*t;0xB6ŠUG„PB€O@„SDˆWIŒVJŒRGNG•TN”UP‹RK„XOcUf[GGK2=J,IX9ZkIhyUcxQZoFSh?Pb:L^6;M'0?,95>)=C5<B8:<79<5;=2;=079.9<1?C58?-8B)EU1Uh;azCnŠMr“Nr–PtšQtœUrœTt Uu£Xv¤[t¢ZošUfN^ˆH[ƒDdŒNa‰K`‡HcŠIhJiŽKeŠEa…E`ƒMWyGPr@i`Qi`QjaRjaRjaRkbSkbSkbSjaRjaRjaRjaRjaRjaRjaRjaRkbSkbSkbSkbSkbQkbQkbQkbQlcRlcRlcRlcRlcTlcTlcTnbTk]PqaRtdWrdWnbVj`TiaThbTgaSebQc]M[VCVQ=TO9NH2GA)KG,I?$bI3‘gW¶wn»lg¸YWºPR¶BE½BEÂDGÈFHÍHKÐJKÒLMÓKMÏEEÐDEÓEDÖFEÕFBÒC?ÏD=ÏF<ÈC:ÉD;ÊE<ÌE?ÒD@×CCÚADÜ@DáBFâBDáCDàDEàDEáEFãEDåEEãCCäB@ä@?ä@?ã?>â@=ãA>ÞC?ÓB?Æ?;¶93ª70Ÿ:0—=2Ž>3†>2ƒ?4?3=2‚<4„93‡83‰92‰92…;0„<.„<.ƒ;-;/;/€:.€:.~:-~:-~:/~:/};/};/};/};/}90}90~80~8.€7.€7.8/9-€7.~8,}9.|8-{9-z8,x8,x8,x8.x8.w7-v8-v6,t6+s4+q5+m1'r6,n4)m3(o6+m4)q8-I=…SH…SJ‡RJˆQJŒQIQJ”QK•RL“TMTK‰[N‚cQo_HYU:MV7O_;j~YbxQZpIUjCRg@Pa=IY5DR17D&4>#2:#6;'<>0@B5@@6<>358-39-4:.7:/9=/;?.=B,=F)S_;arFo†RtUt”St™SsSsUužZ~§e~§ep˜YbŠK^†G^†H^„G`†IbˆKdŠMfNeŒMcŠK`‡H^„G_‚LTvDKm;i`Qi`QjaRjaRjaRkbSkbSkbSjaRjaRjaRjaRjaRjaRjaRjaRkbSkbSkbSkbSkbSkbSkbSkbSlcTlcTlcTlcTlcTlcTlcTnbTrbSqaRrbUrdWrfZogZmeXjdVgcWliZmjYjgThcOc^H[U=RL4PJ0I?&Q?)kP=XI„NDˆE=”EA±WV¸TT»QQÀPOÀNMÁMMÃMKÃKJÐTTÈHIÂ=>Ä=:ÐB@ÓEAÏB;Ç>4ÊD9ÊF:ËF=ÎH?ÔFBØDDÜAEÝAEáBFáCDáCDâDEâDEáEFáFDáFDàEAßD@àB?ßA>àA=àA=àA=ÞC?ÔE?ÈC<º>6­;1 90”:/Š<0ƒ=1€@4~@5~>4€=4ƒ:3†91‰92‰90‡;.…<-…<-„;,ƒ;-‚:,‚:,‚:,9-9-9/9/~:/~:/~:/~:/}90}90}90}90}90}90|90|90|90z:0z:0z:0y9/y9/x:/w9.w8/w8/t8.s7-r6,r6,p6+p6+l2'q7,m4)l3(o6+l3(p7,~H>…SJ…SLˆQLŒQMQL”PM•QN”SOŠOG…SH€[K{ePsiPilMfqQgxT^tMXnGPf@Ma<M^<L[:HU7CP4<F-8@)6;'7:)<=/?@2>>2;=04:04<15;16<0:</<?.>A,>D*Q[9^mDnSsŒUr’Ss˜SsSsžVxŸ^|¢exžak‘T`†I]ƒF]ƒF\‚E`†Ia‡JdŠMe‹Ne‹NbˆK`†I^„I]LRtBIk9i`Qi`QjaRjaRjaRkbSkbSkbSjaRjaRjaRjaRjaRjaRjaRjaRkbSkbSkbSkbSkbSkbSkbSkbSlcTlcTlcTlcTlcTlcTlcTnbTqcVo_Rm\Rm_Tqd[og\ldYhbVfbWqma{xi~{j€zj{vcqjWe`JTT<FF.C>(MB.S@/U8*]7*m>4n70u91~;5‡@:’IB›PJ¥XP­ZT»^YºRO·GE¼B?ÈDBÑEDÓD@Ï@:ÐA;ÐC<ÒE>ÔG@ÖGCÚFFÛEFÞDFßCDßCDßCDàDEàDEßEEßECàFDßECÞDBÜD?ÛC>ÜC>ÜC>ÜC=ÛC>ÖE@ÏF@ÃB<³>5¢:1”8-‰9.ƒ;/‚@2?3~>2€>2ƒ:1†91‰92‰90‡;.…<-„:-„:-ƒ;-‚:,‚:.‚:.9-9-~:/~:/~:/~:/~:/~:/}90}90}90}90|90|90|90{8/{;1{;1z:0y;0y;0x:/x:/x:/t8.t8.s7-s7-r6,q5+p6+o5*j1&p7,m4)k2'l6*i3'm7+}G=‡PIˆQJŒQKŽQL‘RM“TO”UP‘VPŒWO‡[P~^OtbNoiQorUlwYfwUQeBK_:EY6DU3EV6GV9GT8ER8@J2<D/9>*7;*:<.<>0;=/9;.6<25=26<26<0:</<>0=@-=C)MW5Zi@h{Mn‡PpQs˜RuŸUtŸWz¡`w`n”Wc‰L\‚E\‚E\‚E[D_…Ha‡Jc‰LdŠMc‰La‡J_…H]ƒH[}JPr@Gh9i`Qi`QjaRjaRjaRkbSkbSkbSjaRjaRjaRjaRjaRjaRjaRjaRkbSkbSkbSkbSkbSkbSkbSkbSlcTlcTlcTlcTlcTlcTlcTnbTrdWpbUm_Tl_VkaWlcZle[jf]jf]yujˆ„x‘•’Œ~‰‚r}zg`cNOT>DG2GF2HC0F=,L<,VC4P9+R6*V4*Y4+\6+a9/e=3n>4ŠKBRL®UQ·OL¼FFÆABÒDCÙGGÔ@>ÕA?ÖB>ÖE@ÙECÚFDÛEDÝEDÞDDßCDßCDÞDDÞDDÝEDÞFCÞFCÛFBÛFBÚE?ØE>×D=×D=ÙD=ØE>ÔD<ÓF?ÉF>ºA8§;1˜8,Œ8-…;.ƒ@0@1~?0€>0ƒ:1„:/ˆ:0ˆ:.„:-„;,„:-„:-‚:,‚:,9-9-9-9-~:/~:/~:/~:/~:/~:/}90|90}90{8/{8/{8/{8/y9/{;1z<1y;0y;0x:/x:/x:/v:/t8.s7-s7-r6,q5+o5*o5*m4)j1&o6+l3(h2&k5)h2&l6*|F<ŠOGŒOJPKRM‘TO‘VPWPŒZQ‰]R…aUy_Pj[Hd_IdhO\fKN]@EU8AQ4>M0=L/?M3DQ7FR:GS;BK6>G2:A/9=,9=.9=.8<-7;-7=36=56;47=3:<1;=/<?,<A*JS4Ve>dwIl…LpQušTw¡Wx¢Z{¢ar˜[e‹N\‚EZ€C\‚E\‚EZ€C_…H`†Ia‡JbˆKa‡J`†I^„G]ƒHZ|INp>Ef7haQhaQibRibRibRjcSjcSjcSibRibRibRibRibRibRibRibRkbSkbSkbSkbSkbSkbSkbSkbSlcTlcTlcTlcTlcTlcTlcTlcTrfZth\sf]ndZjaXle]snh{xq~w† ”¨¥œ«§œ¨¤™£‘™–‡z{kdgTOR?GJ7EH5BE2BE2EH5KL<JH9GD5D>0B:-A7+@6*G5)S5*qB8ŒPHŸPK¯HI¿GIÌEIÓBEÖ@BÙ@BÚBAÜDCÚEAÛFBÝEBÜDAÞDDÞDFÞDFÞDFÞDDÝEDÝEDÛEDÚFB×FAÖF>ÔE=ÔE=ÓF=ÔE=ÕF>ÔA:ÓC;ÎE=ÁB9®>3Ÿ:.‘;.‹=0„?0?/€>.>.;/„:-‡;.‡;.„:-ƒ;-ƒ;-‚:,‚:,9+9-9-9/~:/~:/~:/}:1}:1}:1}:1|91z:1|91y90y90x8/x8/w8/y:1y:1x90v:0v:0u9/u9/t:/r7/q6.q6.p5-o4,o4,n3+m4+j1(m7-j4*h2(j4*f2'j6+}D;NGNHQJTLUOŽWPŠYR„\R{YMw]PkZJ]UBYXDY^HOYA?K3:H/7E.5A+5A+8D.?H3CL7EN9BK8@I6<E4:A19@07>.5<,4:,5<45<56;56;49;0:</;>-;@)GP1Sb;buGk„Kq‘RwœVy£Yy£[xŸ`n‘W`ƒIZ}C\E^G^G]€F`ƒIa„Jb…Kb…Kb…K`ƒI_‚H^IY{INo@Ef9haQhaQibRibRibRjcSjcSjcSibRibRibRibRibRibRibRibRkbSkbSkbSkbSkbSkbSkbSkbSlcTlcTlcTlcTlcTlcTlcTlcTkaUoe[pf\lcZkd\rmg„|‘Œ§£ µ±®ÄÁ¼ÉÆÁÉľÅÀºÀ¹±¹²¨¤œˆ‚rgdUPQ?FI8>E3;D1:F28E38E38C3:B3<B6@C8CD<HE<>4*P:/e?6€EA¡PO¿X[ËRWÊCIÕFJ×EFÚFFÜFEÞFCÞDBÞE@ÞCAÞDDÞDFÞDFÞDFÜDCÜDCÜDCÚDCÙEA×FAÕF@ÓF=ÓF=ÑG=ÑG=ÔE=Ô?8Õ@9ÐC:ÆC9¶A7¥=0–=/Œ=.†>/‚?/>.>.<-ƒ;-…;.…;.ƒ;-‚:,‚:,‚:,9+:+9-~8,~:/~:/~:/~:/}:1}:1}:1}:1z:1z:1z:1y90x8/v7.v7.t8.w8/u9/u9/t:/t8.s9.s9.r8-q6.q6.p5-o4,o4,m4+l3*j4*h2(m7-i3)f2'i5*e1&i5*{B9ŽMG’MH‘PJTLVO‡XN‚ZP|\Qs\Nl\M`WFVSBQRBJQ?@I64@,3<+2;*09(09(2;*5>-9B1<E4?H7?H7>G6;F5:C25@/3>-1<,3:33954954928919;.;>-;@*CL/O^7`sEk„Mr’SyžYy£Yw¡Yq˜Yf‰OZ}CX{A\E^G^G^G`ƒI`ƒI`ƒI`ƒI`ƒI_‚H^G^KXzHLm@Cd7haQhaQibRibRibRjcSjcSjcSibRibRibRibRibRibRibRibRkbSkbSkbSkbSkbSkbSkbSkbSlcTlcTlcTlcTlcTlcTlcTlbVj`VjaXkdZlh_uplˆ„Ÿžš°°®ÃÂÀÓÒÐâáßçæäçãàâÞÛÜ×ÓØÏÈμ²¸¥——‡zym]_YIKL:AF2<E0?K7>I8>F7;C6;>5:;3983872==3C<2N71a84ˆHH¯]_Å`dÊWZÍQSÓNO×MKÛKJÞHGáFDãDAâBBßCFÞCGÞDFÝCEÝCEÝCEÜBBÛCBÚDCØD@ÕD?ÓF?ÒE>ÐE>ÐG=ÔE=Ù@:Ù@:ÑB:ÉD;¼C:¬@4™;/Œ9+‰=/ƒ>.>->-<,ƒ;,„<-„<-‚:,‚:,‚:.9-9-9-~8.}9.~:/~:/}:1}:1}:1}:1}:2}:2{;2y:1y:1x90w8/t8.s7-r8-t8.s9.r8-q8-r8-p7,p7,p7,o6-o6-o6-n5,m4+l3*l3*i3)h2(k7,h4)f2'h4)b0%f4)zA8MG“NI‘PJŽULˆXNYOxZOr\Nk^N_XHRPAKN=EI:9B13;,08)17+17-06,06,06*17+2:+4<-9D4;F5=H7<I7;F56C13@,1>-.800621622717829;0:<.:?)?H+LZ6]pCjƒLs’Vyž[w¡YsœVgP^IVyAX{C[~F[~F[~F]€H_‚J_‚J_‚J_‚J_‚J^I]€H]€JUvIJk@Ab7haQhaQibRibRibRjcSjcSjcSibRibRibRibRibRibRibRibRkbSkbSkbSkbSkbSkbSkbSkbSlcTlcTlcTlcTlcTlcTlcTlbVqh_ng_mhbtqj‡ƒ€¡ ž¼¼ºÍÏÎÏÏÏàààòòòúøùû÷ø÷óòñëëîãßèÐÆÝÁµÁ«¢‘}ub^\GKM7CH2AI2AH6@G7BD9BB:B=9C97?:6:=6>?7C82J.+e77QR´hjÆnmÀ\\ÇZWÐVS×QNÝMLâHHæCDåBEàDGÝDGÝDFÝCEÝCEÜBDÜBBÜBBÜDCÙCB×C?ÓD>ÒE>ÐE>ÑG=ÔE=ÜC=ÛA9ÒB:ÊD;¿E:°A6œ:-Œ6'Š</…=.‚=->-<,<,„<-„<-‚:,‚:,‚:.9-9-~8,}9.}9.~:/~:/}:1}:1}:1}:1}:2{;2z;2w;1x90v:0u9/s9.r8-r8-r8-q8-p7,n8,p7,m7+o6+o6+o6-o6-n5,m4+m4+j4*i3)h4)f2'k7,h4)c1&f4)b0%e3(xB8NH’OIRM‹VN„XOzZOq[Mj]MZTDIJ:@D5>D69A219,/7*6<247058157247025.06,08-2:-6A3:E5=J9>K9<I77F33B-1>-,6..400511606718:/:<.:?+<E*IW4[nAiMr‘Vxœ\užXp™U`†IX{CSv>WzB[~FZ}EY|D\G_‚J_‚J_‚J^I^I]€H]€H]LStIHhA@^8icSicSicSicSicSicSicSicSicSicSicSicSicSicSicSjcSkbSkbSlcTlcTlcTmdUmdUmdUmdUmdUmdUmdUmdUmdUmdUldWjc[gd]vsn“’Ž¯¯­ÄÆÅÚÜÛêîïóôöö÷ùüüþÿÿÿÿþÿÿûúüööýòî÷áÔòØÇàɷƵ¡ª ‡ˆ„ibbFEH-EI0CG0FE3GC7F<3C60G53I;:>=9>?:B:7I75cGF’jjÅ“’è­©Ò‹‡ÇtnÀ]XÆSPÕONàKMçFKéFKßDHßIKÛEGÕ<?Ø>@áGIàDGÖ:=Ú@@Ú@@ÙA@ÖB@ÔC>ÒC=ÐA;ÑA9ÞC>ÛA9Ó@9ÊA9¾B8°@5Ÿ:.8*Œ=0‡>/ƒ>.>-€=,€=,<,<,:+9-9-~8,~8.}9.|8-|8-|90|90|90|90z:1z:1z:1z:1y=5w<4w;3u:2t91q8/p7.p7.o6-m7-m7-l8-m7-l8-m7-m7-i2+m6/p92p92l5.g2*g2*h3+e0(i7.d2)^.$`0&_/%b2(s>6ŒOJQLˆQLRJ}XOx]RhXITN>DE5@D5:B37?24</3;04:049279478366457246116//6./7,.9+2=-6C2:G6:I68G44C.1?.*4+,2.-2./4.45/79.:</:?+6>&ES2YkCj‚Ru“]y_r›Yk”R[~DXyDTu@Tu@XyDZ{F[|GZ{F^JbƒNbƒN^J\}H_€K`L_NTsJFd@<W6icSicSicSicSicSicSicSicSicSicSicSicSicSicSicSicSkbSkbSlcTlcTlcTmdUmdUmdUmdUmdUmdUmdUmdUmdUmdUldYgd]onj†…ƒ¤¤¢ÁÃÂÖÚÛêîï÷ûü÷ûþøüÿüýÿþþþÿþÿÿþüÿüûÿúóÿðàüêÔíÞÇ×ͲÀ»ž¤£„‚ƒcgjKLQ3GJ/EC.GA1H>4I:3L95K<9?:7CB@NIF]RPyjg£Ž‹Î²®èÅ¿ÿ×Ñ벩͂|Àc^ÊVVØRSßHMÚADÖDEÕEEØHHÜJKÛEFÕ<>Ö<>ÛACÙ??Ù??ÙA@×A@ÖB>ÓB=ÒA<ÔA:ÜA<Û@;ÔA:ËB:¿C;±A6 ;1’8-Œ=0‡>/ƒ>.>-€=,€=,<,<-9-9-9-~8,}9.}9.|8-|8-|90|90|90|90{;2{;2{;2z;2w<4u<3u:2s:1r90n8.p7.m7-m7-l8-l8-l8-l8-j8-l8-l8-k6.n70p92n91l7/i4,g2*e3*c1(d4*_/%^.$b2(^.$`0&p>7‚KF‡RN‡XR~XOrVKdRFRI:A?0<@18@15@23>04<14<15:37:379677577557246116/07//7,.9+1<.5B19F59H58G44E24B1.8//6/.3--2+23+46+8:-9=,7?(DQ3YkEjUv”`yœbp˜ZgQY|DWxCTtBTu@VvDYzEYyGYzE[{I_€K`€N\}H[{I^J^~L^{MSnKF_A9R5icSicSicSicSicSicSicSicSicSicSicSicSicSicSicSicSkbSkbSlcTlcTlcTmdUmdUmdUmdUmdUmdUmdUneVneVneVlfZed_y{x—™˜²¶·ÍÑÒäéìôùüúÿÿûÿÿüÿÿýþÿþþþÿþüÿÿûÿÿúÿÿôþüçúùÝðïÑáåÄÒØ´½Å  ¨ƒ‡‘l`gEQX9EH-DC.JD4LD9KA8J?;C;9SJKia_wvœ’¾³¯ÙÎÈêÜÓþèÝÿóéÿäÛð©£ÃecµBEÇDIÚRVÛUTÑMKÊDAÍCAÔFE×EFØDDÙCDÖ=?×>@Ø@?Ö@?ÖB@ÓB?ÓB?ÕA=Ù@;Ù@:ÓC;ËE<ÀD<²B7¡<2“9.Ž<0‰=0ƒ>/>.=-=-€=-€=-9-9/~:/}9.}9.}9.{8/{8/}:1}:1{;2{;2{;2{;2z;4x<4t;2q;1r90o9/n8.l8-l6,k7,l8-j8-j8-j8-j8-i9-j8-j8-n91m82m82m82m82i70f4-c1*e3,a0)],%_0(c4,\-%_0(sD<}PKVP~YQpSK^J?OC7@=.46(3:*1<,1<.2=/5=26<27:37:379679668368357227018008-.9+0;-2?.6C27E48G49H59F54>33:205.,2(/0(13(57*7;*6>'ER6[lJm„Zy–fyœfl“Z`‡NWwEWuCUrBUsAWtDXvDYvFYwEZwG^|J_|L]{I]zJ_}K^{KZwKPgJAW@3I2icSicSicSicSicSicSicSicSicSicSicSicSicSicSicSicSjcSkbSlcTlcTlcTmdUmdUmdUmdUmdUmdUneVneVneVofWmg[jkfƒ‡ˆ£§¨¹¾ÁÐÕØåíïóûýõýÿûÿÿûÿÿüÿÿüþûýþùþýøÿþ÷ÿÿóùýæöýÞî÷ØçñÎÞèÃÎÚ´¶À›¡«†€‡efmLNR7FH0JI7KI<HD9D@7OGDj`_‹€¤š™·¯¬ËÆÂÞÛÔêæÝúñèÿûñÿ÷íÿÝÕûµ³åŽÊcf°@?ÃPKÉTMÉPHÄGAÈGBÔMJÖKHÐ@?Ò>>Ó??Õ?>ÕA?ÕA?ÔC@ÓB?ÓB=Ö>9Õ@:ÒC=ÌE?ÀE>²A9¢=5•;2Ž<1‰=0ƒ>/>.=/=-€=-€</9/9/~:/}9.}9.}9.{8/{8/~;2~;2|<3|<3{;2{;2z;4x<4r90o9/o9/m9.l8-k7,j6+h6+i7,i7,i7,h8,h8,h8,h8,h8.m;4l71j5/i70j81j81f4-a0)e4-a2*].&a2*b3+Y*"a2*yNG\VvWRjOHXD;I<3@:.:;-8<.08)/:*3;.4</6<26<27:169279479468349238139/19.19..9+/:,1<,2?.5B17E4;H6<I89C87?428.-3'./'/1&24'48'4<'ER8_pPtŠd}šny›ifXU|GSsBTqASp@Sp@TqAUrBVsCVsCXuE[xH]zJ]zJ^{K_|L\yIWrIK_F<M;.?-gdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSicSjcSkbSlcTlcTlcTmdUmdUmdUmdUmdUneVneVofWofWofWng]qqo‡Œ¤©¬·¿ÂÍÕØãíïòüþôþÿøÿÿûÿÿûÿüýÿúüýõúüñøøìöøê÷ÿèóÿäòüáîùÙêôÒÞèÅÊѯ¶½›£}‚bY]BIM6GJ9FJ;CF;AB:c^X…}z«¡ŸÁ·µÌÂÁ×ÏÍæáÝñîéú÷ðüõíÿñèÿòéÿóíÿåß騤¸id§MBµPDÁYNÈ\RÆQH¿D=ÂA<ËDAÌA>Î@>Ð@?ÑA@ÒC?ÑC?ÑC?ÒC?Ó?;ÒA<ÐE@ÉE@½C>¯@9 =7•<4Ž<1‰<2ƒ=1=0=1=/=/=/~:/~:/~:/}9.|90|90{8/{8/|<3|<3|<3{;2z;4y:3y:3w;3n70m80m80l7/k6.i7.h6-h6-i7.h8.h8.g8.g8.g8.g8.h8.k92h6/f4-g5.i70h70e4-b1*c2+c4,_0(]1(]1(W+"c7.{ULtXTaNHN?8A7.=6,;9-9;.9<139-3;.5;/6<06<07:/68-47.69049238139/39/2:/19.19,08+.9+/:,1<.3>.6C2:E5<G7=E8:B55;/06(02'02%13%26%2:%GS;dtWyk~šrs”g]ƒRJp?Oo>Qn>Qn>Qn>Qn>Ro?Sp@TqAWtD[xH]zJ]zJ_|L`}MZwGSmFCU?6D7(6)gdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSicSjcSkbSlcTlcTlcTmdUmdUmdUmdUmdUneVneVofWpgXpgXoh^lnmz‚…“š «µ·ÄÎÐÜæèí÷ùôþÿõþýöÿüúÿúûÿùûþóøúíõöèñôãõüêôýèôüåóùßòöÛéìÏØ×¹ÅĦ±°’ŽrggONP;GK:FL>HPEKQG{{sŸš”ž¸ØÎÌßÓÓçÛÛóëéü÷ôðïëüûöÿÿöÿýôÿøñÿóêÿçÞÿ×ËØ“ƒ¸eS¤K;´TF½WIµF;·@8ÈKEÇC>ÊC?ÍC@ÎC@ÎC>ÎC>ÍD>ÍB=ÑB<ÒC?ÎDAÅD?¸A=ª=8ž;6•<6Ž;3‰<4ƒ=3=2=1=1=1=/~:/~:/~:/}9.|90|90{8/{8/|<3|<3{;2z:1y:3x92w81u91n70m80l7/j8/i7.i7.h6-g7-h8.h8.g8.g8.g8.g8.g8.g8.h70h6/g5.g5.h70h70g6/f5.a2*e6.^2)\0'`4+a5,i=4uSJXG@E>6<5/:6-;8199/57,36+7:/5;/7:/7:/69.58-57,36+28,19,28.19,19.19,19,19,08+08+.9+/:,0;+3>.6A18C3<D5:C28>05;-57*35(13%04%18&HT>gw\wŒmv’lhˆ_RwKBh9Kk<Nk;Pm=Pm=Ol<Nk;Pm=Qn>WtDZwG]zJ^{K`}M_|LVsCNg@<J90;3%/'gdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSicSjcSkbSlcTlcTlcTmdUmdUmdUmdUmdUneVofWofWpgXqhYoh^hikmtz…Œ”£¬±¿ÈÍÓÞâåðòðüüòüûõþùøÿ÷úÿöüÿòúüîøùçö÷çööêù÷ëú÷èüöæýõâ÷ìØçØÃÕƯÀ±šž“}vn[ZWFPQCSVK\c[fme•˜²²¨ÕÎÈèÝÛóãäúêëÿñôÿ÷ùÿýýþýùùúôøùñüüòÿÿóÿÿñÿûêÿæÑñª”¼o[©VD®RCµPD»LA¿JAÂG@ÆE@ÉE@ÊE@ÊE>ÉD=ÈC<ÉB<ÑC?ÐE@ÌEAÂC=³=9¦;5œ;5•<6Œ<5‡<6…<5=4<3=1=1=1~:/~:/~:/}9.|90|90{80{80{;2{;2y:3x92w81v70v70t80n70k90j8/j8/j8/h8.h8.h8.g7-f7-f7-f7-d8-d8-d8-f7-g6/h70i81i81h70i81j;3l=5g80l=5c7.a5,oC:xLCtI@nMDD:167/45/891:;556.14+25,58/58/57,46+46+46+46)48*08).9)08+08)08+08)08)08)19,08+08+08+08+2:-3;.4<-9B1:C0;B2:A1:<.68*35'/3$29'IU?eu[oƒghƒbYyTInE?d8Hg;Li;Ol>Nk=Mj<Li;Mj<Ol>UrDYvH[xJ]zL^{M\yKQn@G_;6B4+4/#)%gdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSicSjcSjcSkcVlbVlbVmcWmdUmdUmdUleUmfVngWogZoi]oh^mjekormtzƒŠ¥®³ÃÌÑÕßáæîñôüþôýú÷ýùùþ÷úÿöýÿòýÿñüÿîýþðûøïþúñÿùïÿúíÿùéÿòßïàËÝηÁ²›¢—|ubb_NXZL^dXmwn|†}¦¬¢¾¿·ÚÕÏîäâüîîÿôôÿô÷þôõþøøûúøûýøüÿúøÿõôüñ÷ýñÿÿñÿùèÿôãÿÌ»½pœRE©SF¶TI²C:ÀIAÄH@ÇF@ÉF>ÉF>ÈE=ÆC;ÆC;ÍG>ÌG>ÇG>¼C;­>5 ;3˜;4‘>6Š=5†=6ƒ=5=4€<3€<1;1;1~:/~:/~:1}90|90|90{80{80z:1z:1x92w81v70v70u6/q6.m80k90k90j8/i9/i9/i9/i9/g7-f7-g7-f7-f7-f7-f7-f7-f5.j81m;4k:3j92j:0m>4oC8mA6oD;e=3d>3zVJ†dZyWMbLA>:13814927<569214-25,9<336-25,24)03(13(25*46+47,/7*-8*/7*/7*/7*/7*/7*/7*19.08-08-/7,/7,/7,08-08+7?09B1<E4=D4;A38<.26'-4$2;*JVBcr[i{a^uXRmLGeAAa:Hd;Kh<Nk?Nk?Kh<Jg9Li=Nk=TqEXuIZwK[xL]zNZvMNjAC[;2>4*00!''heVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVjdVjdVkeYldYlcZmeZmeXmfVg`NkfSnkXol]he\feasqr‚†Š“–ž¡«³¶ÃÈËØÝàêîïö÷ùùûúüþýþþüÿÿúýþöûüôúüñûýòüþóùúòúúòùùíüúëþüçù÷àéåÊÕÔ¶º¹›˜˜|qtY_dMdkYr}l„‚‘›´¹²ËÌÇãâÞòîë÷óòû÷öýùøüø÷ÿþüþþüþþüýÿúýÿúýÿúýÿúýÿúúü÷ÿÿúÿûöÿêåا £`XœE>µNG¿MCÂF>ÄD9ËF=ÎI@ÎKAËH@ÇG<ÆG8ÃH8½J8³H8¦E5šB4‘B5‹C5†B7„B6ƒA5‚>3‚<2„:1†91†91€:2~:1|91|91{80z7/w7.w7.w7.w7.w8/w8/v7.u6-q5+o4,l7/i81i81h70h70g6/g6/g6/f5.g6/i70i81i81g6/f5.e3,h3-j5/m80k90j:0i;.j>1kA3gB2jI:dH:v_O~k\ŠxjŒoRJ=79.4:04:039/39/39/28.28.17-17-36-06,25,06,14+/5+/4-.5-/4-/4-/4-/4-/4-/4-05.05./4-.3,.3,/4-05./6.1;23=26@59C89D67B45@03>-4?.DQ=XfO[kQRbHEX<BU9BW6Jd?Ke>Ke>Ke>Je<Je:Mh?Oj?UpGYtK\vO]wP]wRWqNHaA;N8&1+&+.$),heVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVkdZkdZlc\md[meZmfVidQjhSmjWjk[gg_lll~„“š¨¯µ¸ÂÄÑÖÙâçêòóõûüþÿþÿÿþÿþýûÿþúÿÿúÿþùûüôùúòøûòùüóøùñøùñøúí÷úéùûåòõÚßâÅÌÏ°´·˜‘–vkqUZbJbkVu€oŒ˜Š§œ¿Á¼ÓÓÑççåóóñ÷÷õûûùüüúûûùþþüþþüþþüþþüþþüþþüþþüûÿþõÿÿõÿÿþÿÿÿûúÿíêð¿ºÂ~uŸKA¯MB¹J?ÂL@ÅK>ÃE9¼=4¾?6ÃE9ÄF7ÃJ7½L:³I9¦F6™C4‘C6E7…C7‚B8A7>5‚<4ƒ:3†91„93:3}:2{;2z:1y90x8/v7.v7.v7.v7.u9/u9/t8.r6,p6+m4+l7/i81j81h70i70h70g6/g6/e3,f4-g5.h6/j81j81k92k92k60l71k90k;1l<0j>1j@0iD2gH6lQ>gRAvgTue‹†s†ƒrKL<69.39/39/39/28.28.28.28.17-17-17-06,06,06,/5+/5+/4./4./4./4./4./4./4./4.05//4./4..3-.3-/4./4./6/.80/:22>44@66B66B66B45B16C1CP>P]IR`IIW@AO6BP7FV;Jb@Ke@LfAKe@Ic<Hc:Id;Je<SnEXrK\vQ]wT\uUTmOC\?6I5&1-',0%*.heVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVkdZkdZlc\md[meZmfVmhUljUmjWjk[kkcwww‘’—§¬²¿ÆÌÒÜÞìñô÷üÿþÿÿþÿÿÿþÿÿþÿþýûÿþúÿÿúþýøúûóö÷ïóöëóöëõ÷ìöøíöøêõøåõ÷áîîÔÛÛ¿ÉÊ«°±’“–yuy`kpZt{iˆŸ§œ®µ­ÍÏÊÞÞÜïïíøøöûûùþþüþþüýýûþþüþþüþþüþþüþþüþþüþþüýÿþûÿÿûÿÿþþþÿûùÿúôÿ÷íýÑÆØž•M?¥RD©L=§@1·G;ÏYMÏUJ¼@4ÄD7ÆH:ÄK@¹I=«C8?5—@7“D=‰@9…B:@:>8~>5}=4<4}=4z;4x<4x<4w;3u:2t91t91t91r90r90r90r90o9/n8.l6,k5+m80j81l71j81k60i70i70h6/g5.g5.f5.g6/h70i81k:3l;4l;4j;3i:0h<1k?2jC4iD2fE2gJ8lVAjYGujV†m‘Ž{€mDG658-39/28.28.17-17-17-17-17-17-17-06,06,06,/5+/5+/4./4./4./4./4./4./4./4./4./4..3--2,-2,.3-/4..5.+5-+6.-9//;12>25A56B47D38E3?L:ER>CQ:;I28F->L3DT9J_@Jb@LdBKc?Ia=G`9F_8G`9RkDXpL]uS^vVZqTPgK=T8.A.&1-',0%*.heVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVkdZkdZlc\md[meZmfVniVljUlkWlm]pqi€‚ž¡¦¹¾ÄÄËÑÛåçõúýûÿÿüýÿüýÿþüýüûùÿþüÿÿûÿþùüüôõöîïñæëîãéìáîðãñóåñôãñôßòñÜêêÐØؼÇÇ«²±•¡¡‰‘“}“€œž‘ª­¢¶»´ÀÅ¿ÜÜÚééçööôûûùýýûÿÿýÿÿýýýûþþüþþüþþüþþüþþüþþüþþüþþþûûýÿþÿÿþÿ÷òïüóìÿüóÿúíÿôäì²¹p•P@¢O?¸XJ·M?µE9ÀG<ÁA6ÈE;ÅIA½F>¯@9¡;6š=8—B??;‡@<@<}@;z?9y@9y@9y@9v=4v=4v=4u<3s=3r<2r<2r<2o;0o;0o;0n:/k9.k9.j8-i7.m82n72n72l71l71k60i70i70l:3j92h70f7/f7/g80h91g;2j?6f>4e=1f>2hC3iE5fG3cG2cJ6hV@i\IskV…‚ozor_9=,28,28.28.17-17-06,06,06,17-17-17-06,06,06,/5+/5+.3-.3-.3-.3-.3-.3-.3-.3-.3-.3--2,-2,-2,-2,.3--4-*4,)4,*6,+7-.:01=14@46B46C2:G5<I78E12?+2@)8F/>N4DX<E]=K`AJb@K`?G_;H^:F^:ShGXpN`uV^uX[oTLcI9M4):(%.+%*.$)-heVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVkdZkdZlc\md[meZmfVlgTljUnmYop`tum…‡†¤§¬¿ÄÊÎÕÛæðòûÿÿûÿÿûüþýþÿÿþÿþýûÿÿýÿÿûþýøøøðïðèèêßâåÚàäÖçëÜêïÛíðÛìðÙîîÖèèÐÚØ¿Ìʱ½§·µ ±®¶´§Á¾µÉÈÃÒÓÎÙÙ×èèæòòðúúøüüúýýûÿÿýÿÿýüüúþþüþþüþþüþþüþþüþþüþþüÿþüÿüÿÿüÿÿûúüû÷ýÿùþÿøÿÿôÿþíÿþìøßËÅœŠbP–J:¥L<µQA¼L>¿@7ÆC;ÅF@¿D?±>;¦:8ž::™>=‘=;Š?<„@=}@=xA<tB;rC;rC;q?6s>6s>6r=5r=5r=5p>5p>5n>4m=3l<2k;1j;1i:0i:0j:0n72p62p62n72m61l71i70i70l;4k:3h91e90e90e90f;2d<2fB6dB6cC4dD5dG5dI6bI3_I2^L6eV?jbMrmW„ƒo„‡r\aM3:(28,28.28.17-17-06,06,06,17-17-17-06,06,06,/5+/5+.3-.3-.3-.3-.3-.3-.3-.3-.3--2,,1+,1+,1+,1+-2,-4-,6.+5-*4,*4+,6-.8-0:/2=/2=-5@/7B15A-2>*1=)5A-8F/=O7@T9FX>H\@J]?I^=K^>K`?TgI[oScvZauZZlTJ]G6G4'5&$-*$),"'*heVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVkdZkdZlc\md[meZlfVjgTkjUlnYorasvm…„Ÿ¤¨¸¿ÇÖßäí÷ùûÿÿûÿÿûüÿþÿÿÿþÿþýûÿÿûÿÿúüüôôôêëíâäæÙßãÕÞâÓãèÔçìÖéíÖêìÔëëÓèæÏßÚÄÓθÓκÌƶËøÐÉÁ×ÒÎàÛØêæåðïíóòðùù÷ýýûýýûýýûÿÿýþþüüüúþþüþþüþþüþþüþþüþþüþþüÿýüÿûüÿøùÿþýþÿýùÿýôÿøðÿõ÷ÿöð÷çÿÿíÿîÛͧ”¤kX¢[GªWE­L;¹D:ÀD<ÀE>¼E?´A>ª=:¢:9š:;•=<?=…?=~A<wB<sD<oD;oD;p?8q?6q?8q?6q?8q?6p?8o?5o@8n?5m>6k<2i=4h<1h<3l;4o83r73p62p62n72l71j81i81h70g80e90e:1d<2e?4f@5dB6_C5aG8cL:dM;cM8`K6^L4]M4^R:bX?mhRss[€ƒnv{eFO:4=*39-39/28.28.17-17-17-17-17-17-17-06,06,06,/5+/5+.3-.3-.3-.3-.3-.3-.3-.3--2,,1+,1++0*+0*,1+,1+,3,/6/,6.+5-*4,*4++5,-7,.8--8*0;+4?/5@/4?.3?+4?.3@,7F19K3@O8CU;GW<H[?M]BM`DUeJ\nTdtZ`rZXgRGXE4B1$2%$-*$),"'*heVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVjdVjdVkdZkdZlc\md[lfZlfVliVlkVkmXlo^lrhz€~• ®·¾ÒÛàêóøûÿÿùþÿùúþþÿÿÿþÿúù÷ÿÿûþýøùùñòòèéëÞäæØáåÖâçÓäéÒçíÓèìÓçéÑèèÐçåÎàÛÇ×оÚÓÃÙÑÆÞÔËæÝØîäãóéêúñôÿùûúù÷þþüÿÿýýýûýýûÿÿýÿÿýüüúþþüþþüþþüþþüþþüþþüþþüÿýüÿùøÿúùÿþýüÿý÷ÿþîÿùñÿÿòÿý÷ÿúõùëÿýíÿúèôλ«wbQ:ª\H²N>¸J=¹I>¸I@´G@¯D>¥=:œ:7–=9>:ˆ?9€A:yB;tD:pF:pE<p?8q?8q>:q?8q>:q?8p?:p?8qB<pA9n?9l=5j=7j>5j=7n=6o83r73q73p62n72l71j81i81d8/d90d<2d>3d@4cA5cA5_C5ZE4_N<gVBhWCcS<^O8[O5\R7]V<]Y>nlUtv^|kcmU2>(6B.3;.39/39/39/28.28.28.28.17-17-17-06,06,06,/5+/5+-2,-2,-2,-2,-2,-2,-2,-2,,1+,1++0*+0*+0*+0*,1++2+-4-+5-*4,*4,+5,+5,,6--7,,6+/:,2=/6A17B27B15@04?.2?-4C.:G3=L5AO8DT:JX?L\BTbI\kTcp\^mZUbQDRC2>0#/%'0-&,,$**heVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVjdVjdVkdZkdZlc\md[lfZlfVolYmlWjlWgkZgmcr{xŽ˜š¨±¸ÊÓØãìñøýÿ÷üÿúûÿþÿÿÿþÿúùõÿÿúýýõøøîññåéëÝæéØåéØçìÖæìÒéíÒêíÒèèÎèæÏèãÏáÚÈØÐÃØÎÄÝÒÌéÞÚøíëÿôöÿõùÿõûÿùüÿýþÿÿýÿÿýþþüþþüÿÿýÿÿýýýûþþüþþüþþüþþüþþüþþüþþüÿþúÿýûÿýûýüúùýüøÿÿõÿÿóÿÿíýúóÿûüÿúÿÿôÿöæÿóßÿãÍ×­•©oY¨WD®Q@¬O>¯OA±OB­K@¤C<™<5•>7?6‰@9A7{B7uD6qE8qE:p?8q>:s>:q>:q>:q>:r?;q@;sB=qB<p?:m>8l=7k>8m>8o>9o83q73o83m82m82j92h91f:1f;2d>3d@4bB5`C5]A3\@2WB1TG4\T?f^Gj_IbX?ZS9ZS7\W:[W<XW;kmUsw^u}fUaI&28D03;.4:04:039/39/39/28.28.17-17-17-06,06,06,/5+/5+-2,-2,-2,-2,-2,-2,-2,-2,,1++0*+0**/)*/)+0*+0*,1++2+)3+*4,+5-,6-,6--7.-7.-7./9.2<16A39D69D47B46A10;+2?-6C19F2<I5AO8FT=JX?R`I[hTan\]jYQ]OBN@0<0",#+1/(..&,,ifWheVheVheVheVheVheVheVifWifWifWifWifWifWifWifWkeWkeWle[le[md]ne\mg[mgWqn[kmWknYkr`kshpyv‡‘“Ÿª°»ÄÉÐÙÞêïóöûþüýÿþÿÿÿþÿþýùÿÿúþþöúúð÷÷ëôöèñôãìðßéîØñõÚíòÔëîÓììÔèæÑáÜÉÝÕÈÞÔËáÔÎèÚÙòääúëîþòôÿ÷ûÿùÿÿüÿÿýþþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþÿúÿþúÿþúþþüýÿþûÿÿúÿÿúÿÿûÿÿþÿÿÿÿýÿûõÿûñÿüìÿûåÿóÛÿêѺ‚i¦bK—O9ŸT?¨ZF£RAžK; M?Ž<0‹=0†>2=/x=/t?/sB3uE7r=7s>:t=:t?;u@<u@<t?;q>:s@<rA<r?;q@;p?:o@:o>9o>9k92m82l:3l;4l;4h<3g<3d>3c?3^>1dG9cG9T=-N9(M8'@1XR<PN7KI0OK2]Y>ieJeaDVU7XX<^aDpt[z€fdlU>J2-9#2>*4</5;15;14:04:039/39/39/39/39/39/28.28.17-17-06,16016005/05/05//4./4./4.,1+,1+,1+,1+,1+,1+,1++0*.5..5.-4--4--4--4-.5./6.+2*-4,1805=29A6=E8@H=?J<7B26A03>-1=)3?+9E/BN8IU?O[GWcO]hWZeULWI<F;/90)3+)/+(.,'-+heVheVheVheVheVheVheVheVifWifWifWifWifWifWifWifWkeWkeWle[le[md]ne\mg[khWonZjlVknYlsajtiq|x‰”–£®´¾ÇÌÒÛàëðô÷üÿýþÿþÿÿÿýþþýùÿÿúþþôûûïøùëô÷æñôáìñÝèíÖêïÑæëËäçÊææÎãàÍßÙËÞÔËßÔÎçÙØíßßöçêûïóÿôøÿ÷ûÿúþÿüÿÿþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüýÿúýÿúýÿüýþÿþýÿÿüÿÿüÿÿûÿÿüÿÿüÿÿûùÿüõÿþñÿÿíÿûåÿòÙÿëÑà±—§u\’\D–ZBšYCšVCšSAŽG5‹F6ˆE4ƒD3|C2wB0s@/o>/u@8t?9u>;u@:t?;p>7p=9tB;q>:p?8p?:o>7o>9m>6n=8m>6k<4l=5m>6k?6j?6gA6eA5bB5dG9[A2^G7_J9O>,F7$G8%?7"LL4HL3DG,CF+MM1[[?baC`aBZZ>dgJsw^sy_X`I:D,/;%7C/6>17=36<26<26<25;15;15;15;15;15;14:04:04:039/39/27127127116016016005/05/.3-.3--2,-2,,1+,1++0*+0**1**1*)0))0)*1**1*+2+,3,.5..5-.5-07/4;3:B7?F>BJ?;F8:E57B14?.3?+6B.<H2@L6LXDS_KYdTWbRLVK=G<1;2+5-+1-*0,)/-heVheVheVheVheVheVheVheVifWifWifWifWifWifWifWifWkeWkeWmd[md[md]ne\mg[khWnmYimVjoYktaiuiq}yŠ˜™¥²¸¿ÊÐÔÝâíòö÷üÿüýÿýÿþÿýþþýùÿÿ÷ýýóúúîøùëô÷äðóÞéîØåëÑâçÉÞáÂÝÝÁÞÞÆÞÛÈÝ×ËàÕÏäÙ×îâäóçëúîòÿôøÿ÷ûÿùüÿúýÿýýÿþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüýÿüúÿüúÿüûÿþþþþÿüÿÿúÿÿùÿÿøÿÿùÿÿúÿÿúúÿýøÿÿöÿÿóýÿïÿúæÿóÝÿøàÿìÕ㿧¬‚j‡YB†R<’[F—]IS?F2u>)r>)tA,tD0vE6q?4n<3q<6tB9tB;o?5q@9xH>n=6m>4m>6m>4l=5j>3l=5j>5g?5gA6hB7gC7eC7cC6aD6^D5bK;UB1ZI7`S@RG3D<'E=(FA+BF-BH.AE*<@%?B%LO2_`AijKaaEnqTvzagmSJO95=&5=(=F39?38>48>48>47=37=37=37=38>48>48>47=37=37=36<26<25:45:449349338238238238205/05//4..3--2,,1++0*+0*).*).*).*).*).**/++0,,1-162/4.,1+,1+05/6;4=B<AH@@K=>K:<I78E34A-2?+3A*5C,DQ=KXDQ^MQ^MHTH<H<2>4.8/-4--4-,2.gdUgdUheVheVheVifWifWifWifWifWifWifWifWifWifWifWkeWkeWmd[md[md]mf\mg[jiWkmXimVjoYjs`hthn}xˆ˜˜¦³¹¿ÊÐÓÜãëðööûÿüýÿýÿþÿÿýÿþúþþöýýñúûíøùéô÷äïóÜçìÕãçÎÜßÀ×Ú»ÖÖ¼Ù×ÂÝ×ÇÞ×ÍåÛÙìààøìðûðöÿõûÿùþÿúýÿûûÿûûÿýüÿþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüýÿüúÿþøÿþûÿþþþþÿüþÿúÿÿùÿÿøþÿúýÿùüÿùùÿýúÿÿúÿÿøûÿõüþðÿÿïÿûëÿñßÿðÝÿïÚñÒ½´zyS>tJ4uH3vI4zM8~O;yL7nA.e7'{M@tE;qB8sD:oC8g;0d8-g=1i?3i?3i?3g?3g?3f>2f>2e?2cA5bB5`C5`D6_C5[D4ZE4WD3XI6OB/\T?oiSc^HMK4IG0IK3>D*?H-@F*<B&<A#EJ,XY:deFmmQxx\tv^[_FAD/6;%:?+>B19?39?59?58>48>48>47=37=39?59?58>48>48>48>48>48>47<67<67<66;56;56;55:45:438238227105//4.-2,,1+,1++0,+0,+0,+0,+0,,1--2.-2.051.3/+0,+0*-2.3828=9;B:AL>@M;@M;=J68E14A-1?(1?(=J6BO;IVDJWFDPB;G;2>4.:0,6..5.-4-gdUgdUgdUheVheVifWifWifWifWifWifWifWifWifWifWifWkeWldWmd[md[md]mf\mg[jiWlnYinWiqZgs_drejyt…••£²·½ÈÎÒÛâêïõôùýûüÿýÿþÿÿýÿÿúÿÿøÿÿóþÿñüýë÷úåñõÞèíÖãçÌÙÜ¿ÕÕ¹ÒйÔѾÚÔÈàÙÑêàßôéíþóùÿ÷üÿûÿÿýÿÿþÿÿþüÿþúÿþúþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüýÿþúÿÿúÿÿûÿÿþþþÿýþÿüüÿûüÿûúÿúøÿù÷ÿúøÿüùÿÿûÿÿûýÿúýþùùôîÿþöÿýôÿüóÿûîÿ÷çûæÕéÒÀÏ´¡¶š…”uawVClI6mH6rM=uP@mF7jC4gB2kF6nI9nJ:oK;pL<eA1cB1cB1cB1cB1cB1bC1`C3]F6\G6]H7ZG6ZG6WH5TG4RG3PH3OI3fdM~~frrZVX@JL4GM3<E*<F+?H+AG+AF(CH*MN/TU6xw[{z^nnVUU=CB.?A,?@.;>-;>39?59?58>48>47=37=37=38>48>48>48>48>48>48>48>49>89>89>89>88=78=77<67<66;56;55:438227105//4./4.-2.-2.,1-,1-,1-,1--2.-2.-10,0/,0/-2..211623764;4;G9=L9@O<@O:<K67F/4C,2A*6E.:I4@O<BP??M>8F71?2-9-,6--4,,3+fcTgdUgdUheVheVifWjgXjgXifWifWifWifWifWifWifWifWldWldWmd[md[md]mf\mg[jiWkmXinWiqZgs_bpcgxr‚””£²·ÀËÑÔÝäëðöõúþûüÿýÿþÿÿýÿÿúÿÿøÿÿôÿÿóÿÿïúýèó÷àéïÕãçÌ×Ú½ÑѵÍË´Î˺ÖÏÅÞ×Ñìâã÷îóÿöþÿúÿÿýÿÿþÿÿÿýþÿúþÿùþÿúþÿúþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþþýþÿýþÿýþÿýÿþýÿüþÿúþÿùÿÿ÷ýýóýýõþýøþýùÿþüþþþÿýÿÿþÿþùÿÿüÿÿûüûöóÿøòÿýôÿþñÿþíÿúéÿóà÷äÓçÒ¿Ôº©ºŸŽŸƒurd|]K}^LtUCbE3X;)Y<*[>,X=*`E2`E2`E2`G3`G3`G3`G3^I4\K7\M:\M:ZM:XM9UM8SM7QL6NL5QQ9jlT|€gmqXSY?FL2>G,<F+<F+?H+DJ.EJ,DG*HI*LM.yx\tsWfdMTR;LI6KJ6FE3<=-<?4:@69?59?58>48>48>48>47=37=38>48>48>49?59?59?5;@::?9:?9:?99>89>89>89>89>88=77<66;55:4493382382/40.3/-2.,1-+0,+0,+0,+0,+/.,0/-10.21/32/32/32.5.4@27F3=L7@O:?N7<K49H18G05D-8G0<K6>M:<J97E61?2-9-+5,-4,,3+fcTfcTgdUheVifWifWjgXjgXifWifWifWifWifWifWifWifWldWldWmd[md[md]mf\mg[jiWjlWhmVhrZfs_cqdhys…——¥·»ÇÒØÚãêðõûøýÿüýÿýÿþÿÿýÿþùÿÿ÷ÿÿóÿÿðýþìøûæðôÝäêÐÞâÇÕÕ¹Î̳ÉÄ°ÊÄ´ÐÉ¿ÚÒÏéàãöíòÿ÷ÿÿúÿÿýÿÿþÿÿÿýýÿúüÿøüÿøýÿúþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþþÿüÿÿüÿþýÿýÿþúÿúøÿùøÿõøÿóøÿóøÿõüÿøýÿúÿýþÿüÿÿüÿÿûÿý÷ÿÿúÿÿüÿÿýÿÿþÿþýûûûóúøìÿÿñÿÿïÿÿïÿþíÿýíÿöçÿîâýêÛúãÑÿæÐãÊ´¥xt^GeO8cM6\H0^J2\J2\J2]K3]K3^L4^L4\M6YN8XP;XP;VP:UO9SN8PN7NN6MO7PT;`fLfoTU^CEO4AK0<F+?I.?I.CL/HN2HM/GJ-OP1YX:qmRkgLa\F[V@YTATQ>MJ9BC3>A6;A7;A7;A7:@6:@6:@69?58>48>48>49?59?5:@6:@6:@6;@:;@:;@::?9:?99>89>89>8:?9:?9:?99>88=78=78=77<6495384162/40-2.,1-,0/+/.,0/-10-10.21.23.23-12,2.+9*/@-6H2<N8=O7<N6:L2:L25G/7I1:L6<M:;L:6G70@3-;.,6--4,,3+cdTcdRdeUgfThfWigXigXjhYhfWifWifWifWifWifWifWkeWkeWkeWmeZle[md]mf\kg[jiWikVhmWis[gt`dqgk|v‰›¬»ÀÍØÞàçíôùÿúÿÿûÿÿýÿüþÿúþþöúúðúûíúûëøùçôöáëí×ßãÊÙÜÁÓѸÌDZž¬Æ¾±ÌüÖÎËæÝàôêòþ÷ÿÿúÿÿþÿÿþÿþþþýÿúüÿúüÿúýÿüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüÿþüÿþüÿþüÿýþÿüÿÿüÿÿýÿýÿþûÿüøÿù÷ÿ÷÷ÿõøÿöùÿöüÿøÿÿûÿþýÿüÿÿûÿÿúÿÿúÿÿûÿÿüÿÿýÿþýÿûýüüþûþÿúùúòûûñýúñþúïÿùìÿûìÿýïÿýìÿðÛÿûâìÜÞŽu`P7RB)XH/XH.[M3[M3ZN4ZN4[O5[O5\P6[Q8UO7TO9TO9QO8PN7NN6KM5IM4JN5LR8S\APY>@I,<E(AL.?J,DM0EN1JP4MR4KN1LL0YY=kjNhdIb^E^ZA_ZD`[GZUAQO:KJ8AB4@B5@B5>A6>A6>A6=@7=@79?59?59?5:@6:@6:B7:B7;C8;@9;@9;@::?8:?9:?89>89>7;@:;@9;@:;@9:?9:?8:?9:?98?87=94;4382160/4..3/.3/.21.21-2.,2.,3,,3+,3+)6%$6*>"2F+8L3;O6<N6;M5;M58J29K3;M5=O7<N87H51B0.<--7..5--4,]eP^fO_gRbgQdiUfiVgjWijXfgUhgUheVheVjdVkeWlfZlfXlfXkhYmg[kg\mf^jf]ieZgeVghVfkUenYbo]dqht„–¨¬¸ÇÎÒÛâäéïò÷û÷üÿøüûüþùüÿøüþó÷÷ëùúêø÷åòñßîíÙëêÖáßÊ×Ò¾×ϼËÀ®½´¥½³©Â·±ÌÂÁÛÒ×êàèúóûüöÿþûÿÿýÿþýÿüýÿüþýüþýþþþþþþþþþþþþþþþþþþÿþüÿþüÿþüÿþüþýùþýùÿüùÿýúÿþûÿþûÿþÿÿýþÿüýÿýþÿÿÿþÿýýÿüûýøÿÿûüý÷ÿýøÿþúÿýøÿúöÿ÷ôÿùùÿúÿÿüÿÿýÿÿþÿÿÿÿþþüýÿþüþýÿÿÿÿÿÿÿþüÿþùÿþõÿþðÿýêÿýæúôÜÿúàçàƈnUN2WM2TK.SJ+WN1WN1UN1UN1TO2TO2TN4SO4QM4RN5QO6PP6MO7KO6HM6GL5JP6FO4AJ-=F)@G(DK*FM+EL*PV4PS4KN/IL/TT8bbFccIZZ@[Y@\ZA][B][B[Y@XV=US:SQ8HF1GD1EB1B@1A?2>>2??5>@5;>59?59?59A69A48C58C59C8:B79A69@88@58?79A69@8:B7:A9:B7:A9:B7;B:<D9=D<>E=8B:8B:8B98@56>14</39/271.40/51070.8-.;)0@&6F)7M';V+:W+;U0;T4;R8=P<>O<>O<:L6@R8EW=FY=DX=@T;5H2+<*,6+-4,+2*ZfN[gO^hP_iQbjSckTglXhkXhiWghVifWifWkeWlfXmeZmgYmgYkhYkg[kg\je_jf]hfZfgWhiWglVfo\erajwnzŠ‰œ«²ºÈÑÐÙàãèìò÷ûøþþùþúúÿøûþõùýïøùë÷øèõôâíìÚéæÓåâÏÜ×ÄÒ˹ʿ­Á´¤¹­¡¼¯¦Á¶²ËÁÀÛÐÖæßæûóþý÷ÿþûÿÿýÿþýÿýüÿüýÿüýÿþþþþþþþþþþþþþþþþþþÿþüÿþüÿþüÿþüÿýúÿüùÿüùÿýúÿýùÿþúÿþýÿýüÿüýÿýþÿþÿÿþÿÿýþýûüÿþýÿþûÿüúÿøóøíçòåÝöèßûðêÿúýÿüÿÿýÿÿÿýÿÿýþþüýÿþüýÿþýÿþýÿÿýÿÿþüÿý÷ÿÿðÿþèÿÿäúöÝýûâäàÇ‹‡lRM0SN1RK.QK+UO/UO/TO1TO1SO2SO2QP4QO6QM2PO3PN5NQ6MO7JP6HM6EM5HQ6FO4BK.?H)CH(GM+JP,KQ-OS0PT1VZ9^aB_bCZ]@VV<UU=VV>WU>XV=YW>YW>XW;WV:XT9QK3PJ4LG4ID1DA2B@3A?3>@5<=59?59?59A67B48C57C57C5:B7:B79A68@58@59A6:B7:B7:B7:B7:B7:B7;C8<D9=E:<F;=G?<H><F;;F6<D5:B39?38=67>76=63=52>04C,9L,BY/Ga1Qo;Mm;Li=Fa>BY?<R=<M=:K9=O9DV<K^BNaCL`DH\A:Q71D0+5*+2*)0(ZfN[gO\hP`jRbjSdlUglXilYijXijXkhYkhYmgYmgYog\nhZmgYkhYkg[jf[je_jf]hfZfgWhiWejTdmZgtco|sŽ¬³¶ÄÍÍÖÝÞæéñöúøþþúþýùþøøûòôøêóôæðñáêé×áàÎÜÙÆ×ÔÁÐ˸ÇÀ®¿³£½° ¼°¤Ã¶®ËÀ¾ÕËÌãØÞëäëüôÿý÷ÿþûÿÿýÿþýÿýüÿüýÿýÿþþþþþþþþþþþþþþþþþþþÿþüÿþüÿþüÿþüÿýúÿýúÿüùÿüùÿüøÿüøÿýüÿüûÿûüÿüýÿþÿÿþÿÿýþþüýÿþýÿþûÿýûüóîêßÙâÕÍëÝÔ÷ìæÿúýÿüÿÿýÿÿÿýÿÿýþþüýÿþüýÿþýÿþýÿÿþÿÿÿýÿþõÿþíÿýçÿþãû÷ÞþüããßƉ…jPK.RM0QJ-QJ-UO/UO/UP2UP2TP3SO2QP4PO3QM2ON2PN5MP5MO7JP6IN7GO7HQ6FO4CL/CL-GL,KQ/OU1SY5QY2X`9jpLy]qvVY^@LO4MP5QQ9QQ9RP9SQ8TR9VT;YU<ZV=XR<VP:RM:NI6HE6DB5CA5?A6<=59?5:@69A67B48C57C57C5:B7:B79A69A69A69A6:B7:B7:B7:B7:B7:B7;C8<D9>F;<F;?IA>J@?I>?J:@H9>F7>D8=B;>E><C<7A95A39H1BU5Pg=XrB`~J\|JXuINiFD[A9O:6G74E3<N8EW=NaESfHSgKNbG@W=6I5/9./6.-4,ZfN[gO\hP^jRblTemVhmYinZklZklZlj[liZnhZnhZph]oi[liZkhYkg[jf[id^ie\hfZghXfgUbgQajWerao|s~Ž–¥¬«¹ÂÇÐ×Úáçîó÷öüüøüûõúôóöíîòäéêÜãäÔÜÛÉÓÒÀÎ˸ÉƳþ«½¶¤Ã·§Ç¹¬ÍÁµÖÉÁßÔÒèÞßóèîøñøýõÿþøÿÿüÿÿüÿýüÿýýÿüþýýÿþþþþþþþþþþþþþþþþþþþÿþüÿþüþýûÿþüÿýúÿýúÿýúÿüùÿû÷ÿû÷ÿýüÿüûþúûÿûüÿýþÿþÿÿýþþüýÿüûÿþûÿýûýôïíâÜæÙÑðâÙüñëÿúýÿüÿÿýþÿÿýÿÿûþÿúýÿþüýÿþýÿþýÿÿþÿÿÿýÿþõÿþíÿüæÿüãþùãÿþçäßÉŠ†mPJ0RM0SL/SL/UO/UO/UP2VQ3TP3SO2PO3ON2PL1ON2OM4LO4MO7KQ7JO8HP8JS8GP5GP3IR3NS3PV4W]9\d=grHtU‡’jšu‡ŽlnuTZaBSW<MO7NN6MM5NL5OM6RP9WR<YT>ZT>XR<TO<QL9KH9GE8EC7AC8=>6:@6:@69A67B47B46B46B4;C8:B7:B79A69A6:B7:B7;C8;C8:B7:B7;C8<D9=E:>F;=G<=G?=I?>H=>I9?G8>F7>D8=B;=D=;B;6@85A3:I2DW7Ri?[uE\zFXxFTqEIdA>U;2H3/@0.?-6H2@R8L_CReGSgKOcH@W=6I51;007/-4,YgNZhO\hP^jRblTemVinZjo[mn\lm[mk\mj[oi[oi[oi]oi[liZkhYjfZieZid^ie\ig[ghXghVchRajWerao|s{‹ŠŸ¦¢°¹ÁËÔÔÝäéñôòúüôúúñöòíðçèìÞâãÕÚÛËÒÑ¿ÌɸÉıþ«¿¸¦¼³¢Ê¾®ÓŸÜÐÄæÙÑíâàöìíÿôúÿùÿÿ÷ÿÿúÿÿüÿÿüÿýüÿüüþüþýþÿÿþþþþþþþþþþþþþþþþþþÿþüÿþüþýûþýûÿýúÿýúÿýúÿüùÿúöþùõÿýüÿûúýùúþúûþüýÿýþÿþÿÿýþÿüûÿýúÿüúÿøó÷ìæòåÝøêáÿôîÿúýÿüÿÿýþÿÿýÿÿûþÿúýÿþüýÿýüÿþýÿÿþÿÿÿýÿþõÿýìÿûåþúáÿüæÿÿéçâÌŒˆoRL2TO2TM0UN1UO/UO/VQ3VQ3UQ4SO2ON2NM1PL1NM1NL3KN3LN6KQ7LQ:JR:LU:IR7JS6OX9TY9U[9]c?fnG‚’c’¦sŸ°ƒ›ª” zˆ”pr{\\bFLP7LN6LK6LJ5LJ5QL8TM:VP:WQ;VP:SN;QL9MJ;IG:GE9CE:=>6:@6:@69A67B47B46B46B4;C8;C8:B7:B7:B7:B7;C8;C8;C8;C8;C8;C8<D9=E:>F;=G<=G?<H>=G<=H8?G8=E6=C7=B;:A:9@96@85A39H1BU5Ne;Vp@Vt@SsAPmAE`=9P6-C.+<,+<*1C-<N4H[?PcERfJNbG@W=5H4,6++2*'.& \ No newline at end of file
diff --git a/contrib/libs/libjpeg-turbo/testimages/testorig12.jpg b/contrib/libs/libjpeg-turbo/testimages/testorig12.jpg
deleted file mode 100644
index 861aff98e2..0000000000
--- a/contrib/libs/libjpeg-turbo/testimages/testorig12.jpg
+++ /dev/null
Binary files differ
diff --git a/contrib/libs/libjpeg-turbo/testimages/vgl_5674_0098.bmp b/contrib/libs/libjpeg-turbo/testimages/vgl_5674_0098.bmp
deleted file mode 100644
index d74ea64a61..0000000000
--- a/contrib/libs/libjpeg-turbo/testimages/vgl_5674_0098.bmp
+++ /dev/null
Binary files differ
diff --git a/contrib/libs/libjpeg-turbo/testimages/vgl_6434_0018a.bmp b/contrib/libs/libjpeg-turbo/testimages/vgl_6434_0018a.bmp
deleted file mode 100644
index 25e77b7683..0000000000
--- a/contrib/libs/libjpeg-turbo/testimages/vgl_6434_0018a.bmp
+++ /dev/null
Binary files differ
diff --git a/contrib/libs/libjpeg-turbo/testimages/vgl_6548_0026a.bmp b/contrib/libs/libjpeg-turbo/testimages/vgl_6548_0026a.bmp
deleted file mode 100644
index 41e35b59e0..0000000000
--- a/contrib/libs/libjpeg-turbo/testimages/vgl_6548_0026a.bmp
+++ /dev/null
Binary files differ
diff --git a/contrib/libs/libjpeg-turbo/tjunittest.c b/contrib/libs/libjpeg-turbo/tjunittest.c
deleted file mode 100644
index b3f031139a..0000000000
--- a/contrib/libs/libjpeg-turbo/tjunittest.c
+++ /dev/null
@@ -1,936 +0,0 @@
-/*
- * Copyright (C)2009-2014, 2017-2019, 2022 D. R. Commander.
- * All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * - Neither the name of the libjpeg-turbo Project nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS",
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This program tests the various code paths in the TurboJPEG C Wrapper
- */
-
-#ifdef _MSC_VER
-#define _CRT_SECURE_NO_DEPRECATE
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include "tjutil.h"
-#include "turbojpeg.h"
-#include "md5/md5.h"
-#include "cmyk.h"
-#ifdef _WIN32
-#include <time.h>
-#define random() rand()
-#else
-#include <unistd.h>
-#endif
-
-
-static void usage(char *progName)
-{
- printf("\nUSAGE: %s [options]\n\n", progName);
- printf("Options:\n");
- printf("-yuv = test YUV encoding/decoding support\n");
- printf("-noyuvpad = do not pad each line of each Y, U, and V plane to the nearest\n");
- printf(" 4-byte boundary\n");
- printf("-alloc = test automatic buffer allocation\n");
- printf("-bmp = tjLoadImage()/tjSaveImage() unit test\n\n");
- exit(1);
-}
-
-
-#define THROW_TJ() { \
- printf("TurboJPEG ERROR:\n%s\n", tjGetErrorStr()); \
- BAILOUT() \
-}
-#define TRY_TJ(f) { if ((f) == -1) THROW_TJ(); }
-#define THROW(m) { printf("ERROR: %s\n", m); BAILOUT() }
-#define THROW_MD5(filename, md5sum, ref) { \
- printf("\n%s has an MD5 sum of %s.\n Should be %s.\n", filename, md5sum, \
- ref); \
- BAILOUT() \
-}
-
-const char *subNameLong[TJ_NUMSAMP] = {
- "4:4:4", "4:2:2", "4:2:0", "GRAY", "4:4:0", "4:1:1"
-};
-const char *subName[TJ_NUMSAMP] = {
- "444", "422", "420", "GRAY", "440", "411"
-};
-
-const char *pixFormatStr[TJ_NUMPF] = {
- "RGB", "BGR", "RGBX", "BGRX", "XBGR", "XRGB", "Grayscale",
- "RGBA", "BGRA", "ABGR", "ARGB", "CMYK"
-};
-
-const int _3byteFormats[] = { TJPF_RGB, TJPF_BGR };
-const int _4byteFormats[] = {
- TJPF_RGBX, TJPF_BGRX, TJPF_XBGR, TJPF_XRGB, TJPF_CMYK
-};
-const int _onlyGray[] = { TJPF_GRAY };
-const int _onlyRGB[] = { TJPF_RGB };
-
-int doYUV = 0, alloc = 0, pad = 4;
-
-int exitStatus = 0;
-#define BAILOUT() { exitStatus = -1; goto bailout; }
-
-
-static void initBuf(unsigned char *buf, int w, int h, int pf, int flags)
-{
- int roffset = tjRedOffset[pf];
- int goffset = tjGreenOffset[pf];
- int boffset = tjBlueOffset[pf];
- int ps = tjPixelSize[pf];
- int index, row, col, halfway = 16;
-
- if (pf == TJPF_GRAY) {
- memset(buf, 0, w * h * ps);
- for (row = 0; row < h; row++) {
- for (col = 0; col < w; col++) {
- if (flags & TJFLAG_BOTTOMUP) index = (h - row - 1) * w + col;
- else index = row * w + col;
- if (((row / 8) + (col / 8)) % 2 == 0)
- buf[index] = (row < halfway) ? 255 : 0;
- else buf[index] = (row < halfway) ? 76 : 226;
- }
- }
- } else if (pf == TJPF_CMYK) {
- memset(buf, 255, w * h * ps);
- for (row = 0; row < h; row++) {
- for (col = 0; col < w; col++) {
- if (flags & TJFLAG_BOTTOMUP) index = (h - row - 1) * w + col;
- else index = row * w + col;
- if (((row / 8) + (col / 8)) % 2 == 0) {
- if (row >= halfway) buf[index * ps + 3] = 0;
- } else {
- buf[index * ps + 2] = 0;
- if (row < halfway) buf[index * ps + 1] = 0;
- }
- }
- }
- } else {
- memset(buf, 0, w * h * ps);
- for (row = 0; row < h; row++) {
- for (col = 0; col < w; col++) {
- if (flags & TJFLAG_BOTTOMUP) index = (h - row - 1) * w + col;
- else index = row * w + col;
- if (((row / 8) + (col / 8)) % 2 == 0) {
- if (row < halfway) {
- buf[index * ps + roffset] = 255;
- buf[index * ps + goffset] = 255;
- buf[index * ps + boffset] = 255;
- }
- } else {
- buf[index * ps + roffset] = 255;
- if (row >= halfway) buf[index * ps + goffset] = 255;
- }
- }
- }
- }
-}
-
-
-#define CHECKVAL(v, cv) { \
- if (v < cv - 1 || v > cv + 1) { \
- printf("\nComp. %s at %d,%d should be %d, not %d\n", #v, row, col, cv, \
- v); \
- retval = 0; exitStatus = -1; goto bailout; \
- } \
-}
-
-#define CHECKVAL0(v) { \
- if (v > 1) { \
- printf("\nComp. %s at %d,%d should be 0, not %d\n", #v, row, col, v); \
- retval = 0; exitStatus = -1; goto bailout; \
- } \
-}
-
-#define CHECKVAL255(v) { \
- if (v < 254) { \
- printf("\nComp. %s at %d,%d should be 255, not %d\n", #v, row, col, v); \
- retval = 0; exitStatus = -1; goto bailout; \
- } \
-}
-
-
-static int checkBuf(unsigned char *buf, int w, int h, int pf, int subsamp,
- tjscalingfactor sf, int flags)
-{
- int roffset = tjRedOffset[pf];
- int goffset = tjGreenOffset[pf];
- int boffset = tjBlueOffset[pf];
- int aoffset = tjAlphaOffset[pf];
- int ps = tjPixelSize[pf];
- int index, row, col, retval = 1;
- int halfway = 16 * sf.num / sf.denom;
- int blocksize = 8 * sf.num / sf.denom;
-
- if (pf == TJPF_GRAY) roffset = goffset = boffset = 0;
-
- if (pf == TJPF_CMYK) {
- for (row = 0; row < h; row++) {
- for (col = 0; col < w; col++) {
- unsigned char c, m, y, k;
-
- if (flags & TJFLAG_BOTTOMUP) index = (h - row - 1) * w + col;
- else index = row * w + col;
- c = buf[index * ps];
- m = buf[index * ps + 1];
- y = buf[index * ps + 2];
- k = buf[index * ps + 3];
- if (((row / blocksize) + (col / blocksize)) % 2 == 0) {
- CHECKVAL255(c); CHECKVAL255(m); CHECKVAL255(y);
- if (row < halfway) CHECKVAL255(k)
- else CHECKVAL0(k)
- } else {
- CHECKVAL255(c); CHECKVAL0(y); CHECKVAL255(k);
- if (row < halfway) CHECKVAL0(m)
- else CHECKVAL255(m)
- }
- }
- }
- return 1;
- }
-
- for (row = 0; row < h; row++) {
- for (col = 0; col < w; col++) {
- unsigned char r, g, b, a;
-
- if (flags & TJFLAG_BOTTOMUP) index = (h - row - 1) * w + col;
- else index = row * w + col;
- r = buf[index * ps + roffset];
- g = buf[index * ps + goffset];
- b = buf[index * ps + boffset];
- a = aoffset >= 0 ? buf[index * ps + aoffset] : 0xFF;
- if (((row / blocksize) + (col / blocksize)) % 2 == 0) {
- if (row < halfway) {
- CHECKVAL255(r); CHECKVAL255(g); CHECKVAL255(b);
- } else {
- CHECKVAL0(r); CHECKVAL0(g); CHECKVAL0(b);
- }
- } else {
- if (subsamp == TJSAMP_GRAY) {
- if (row < halfway) {
- CHECKVAL(r, 76); CHECKVAL(g, 76); CHECKVAL(b, 76);
- } else {
- CHECKVAL(r, 226); CHECKVAL(g, 226); CHECKVAL(b, 226);
- }
- } else {
- if (row < halfway) {
- CHECKVAL255(r); CHECKVAL0(g); CHECKVAL0(b);
- } else {
- CHECKVAL255(r); CHECKVAL255(g); CHECKVAL0(b);
- }
- }
- }
- CHECKVAL255(a);
- }
- }
-
-bailout:
- if (retval == 0) {
- for (row = 0; row < h; row++) {
- for (col = 0; col < w; col++) {
- if (pf == TJPF_CMYK)
- printf("%.3d/%.3d/%.3d/%.3d ", buf[(row * w + col) * ps],
- buf[(row * w + col) * ps + 1], buf[(row * w + col) * ps + 2],
- buf[(row * w + col) * ps + 3]);
- else
- printf("%.3d/%.3d/%.3d ", buf[(row * w + col) * ps + roffset],
- buf[(row * w + col) * ps + goffset],
- buf[(row * w + col) * ps + boffset]);
- }
- printf("\n");
- }
- }
- return retval;
-}
-
-
-#define PAD(v, p) ((v + (p) - 1) & (~((p) - 1)))
-
-static int checkBufYUV(unsigned char *buf, int w, int h, int subsamp,
- tjscalingfactor sf)
-{
- int row, col;
- int hsf = tjMCUWidth[subsamp] / 8, vsf = tjMCUHeight[subsamp] / 8;
- int pw = PAD(w, hsf), ph = PAD(h, vsf);
- int cw = pw / hsf, ch = ph / vsf;
- int ypitch = PAD(pw, pad), uvpitch = PAD(cw, pad);
- int retval = 1;
- int halfway = 16 * sf.num / sf.denom;
- int blocksize = 8 * sf.num / sf.denom;
-
- for (row = 0; row < ph; row++) {
- for (col = 0; col < pw; col++) {
- unsigned char y = buf[ypitch * row + col];
-
- if (((row / blocksize) + (col / blocksize)) % 2 == 0) {
- if (row < halfway) CHECKVAL255(y)
- else CHECKVAL0(y);
- } else {
- if (row < halfway) CHECKVAL(y, 76)
- else CHECKVAL(y, 226);
- }
- }
- }
- if (subsamp != TJSAMP_GRAY) {
- halfway = 16 / vsf * sf.num / sf.denom;
-
- for (row = 0; row < ch; row++) {
- for (col = 0; col < cw; col++) {
- unsigned char u = buf[ypitch * ph + (uvpitch * row + col)],
- v = buf[ypitch * ph + uvpitch * ch + (uvpitch * row + col)];
-
- if (((row * vsf / blocksize) + (col * hsf / blocksize)) % 2 == 0) {
- CHECKVAL(u, 128); CHECKVAL(v, 128);
- } else {
- if (row < halfway) {
- CHECKVAL(u, 85); CHECKVAL255(v);
- } else {
- CHECKVAL0(u); CHECKVAL(v, 149);
- }
- }
- }
- }
- }
-
-bailout:
- if (retval == 0) {
- for (row = 0; row < ph; row++) {
- for (col = 0; col < pw; col++)
- printf("%.3d ", buf[ypitch * row + col]);
- printf("\n");
- }
- printf("\n");
- for (row = 0; row < ch; row++) {
- for (col = 0; col < cw; col++)
- printf("%.3d ", buf[ypitch * ph + (uvpitch * row + col)]);
- printf("\n");
- }
- printf("\n");
- for (row = 0; row < ch; row++) {
- for (col = 0; col < cw; col++)
- printf("%.3d ",
- buf[ypitch * ph + uvpitch * ch + (uvpitch * row + col)]);
- printf("\n");
- }
- }
-
- return retval;
-}
-
-
-static void writeJPEG(unsigned char *jpegBuf, unsigned long jpegSize,
- char *filename)
-{
- FILE *file = fopen(filename, "wb");
-
- if (!file || fwrite(jpegBuf, jpegSize, 1, file) != 1) {
- printf("ERROR: Could not write to %s.\n%s\n", filename, strerror(errno));
- BAILOUT()
- }
-
-bailout:
- if (file) fclose(file);
-}
-
-
-static void compTest(tjhandle handle, unsigned char **dstBuf,
- unsigned long *dstSize, int w, int h, int pf,
- char *basename, int subsamp, int jpegQual, int flags)
-{
- char tempStr[1024];
- unsigned char *srcBuf = NULL, *yuvBuf = NULL;
- const char *pfStr = pixFormatStr[pf];
- const char *buStrLong =
- (flags & TJFLAG_BOTTOMUP) ? "Bottom-Up" : "Top-Down ";
- const char *buStr = (flags & TJFLAG_BOTTOMUP) ? "BU" : "TD";
-
- if ((srcBuf = (unsigned char *)malloc(w * h * tjPixelSize[pf])) == NULL)
- THROW("Memory allocation failure");
- initBuf(srcBuf, w, h, pf, flags);
-
- if (*dstBuf && *dstSize > 0) memset(*dstBuf, 0, *dstSize);
-
- if (!alloc) flags |= TJFLAG_NOREALLOC;
- if (doYUV) {
- unsigned long yuvSize = tjBufSizeYUV2(w, pad, h, subsamp);
- tjscalingfactor sf = { 1, 1 };
- tjhandle handle2 = tjInitCompress();
-
- if (!handle2) THROW_TJ();
-
- if ((yuvBuf = (unsigned char *)malloc(yuvSize)) == NULL)
- THROW("Memory allocation failure");
- memset(yuvBuf, 0, yuvSize);
-
- printf("%s %s -> YUV %s ... ", pfStr, buStrLong, subNameLong[subsamp]);
- TRY_TJ(tjEncodeYUV3(handle2, srcBuf, w, 0, h, pf, yuvBuf, pad, subsamp,
- flags));
- tjDestroy(handle2);
- if (checkBufYUV(yuvBuf, w, h, subsamp, sf)) printf("Passed.\n");
- else printf("FAILED!\n");
-
- printf("YUV %s %s -> JPEG Q%d ... ", subNameLong[subsamp], buStrLong,
- jpegQual);
- TRY_TJ(tjCompressFromYUV(handle, yuvBuf, w, pad, h, subsamp, dstBuf,
- dstSize, jpegQual, flags));
- } else {
- printf("%s %s -> %s Q%d ... ", pfStr, buStrLong, subNameLong[subsamp],
- jpegQual);
- TRY_TJ(tjCompress2(handle, srcBuf, w, 0, h, pf, dstBuf, dstSize, subsamp,
- jpegQual, flags));
- }
-
- SNPRINTF(tempStr, 1024, "%s_enc_%s_%s_%s_Q%d.jpg", basename, pfStr, buStr,
- subName[subsamp], jpegQual);
- writeJPEG(*dstBuf, *dstSize, tempStr);
- printf("Done.\n Result in %s\n", tempStr);
-
-bailout:
- free(yuvBuf);
- free(srcBuf);
-}
-
-
-static void _decompTest(tjhandle handle, unsigned char *jpegBuf,
- unsigned long jpegSize, int w, int h, int pf,
- char *basename, int subsamp, int flags,
- tjscalingfactor sf)
-{
- unsigned char *dstBuf = NULL, *yuvBuf = NULL;
- int _hdrw = 0, _hdrh = 0, _hdrsubsamp = -1;
- int scaledWidth = TJSCALED(w, sf);
- int scaledHeight = TJSCALED(h, sf);
- unsigned long dstSize = 0;
-
- TRY_TJ(tjDecompressHeader2(handle, jpegBuf, jpegSize, &_hdrw, &_hdrh,
- &_hdrsubsamp));
- if (_hdrw != w || _hdrh != h || _hdrsubsamp != subsamp)
- THROW("Incorrect JPEG header");
-
- dstSize = scaledWidth * scaledHeight * tjPixelSize[pf];
- if ((dstBuf = (unsigned char *)malloc(dstSize)) == NULL)
- THROW("Memory allocation failure");
- memset(dstBuf, 0, dstSize);
-
- if (doYUV) {
- unsigned long yuvSize = tjBufSizeYUV2(scaledWidth, pad, scaledHeight,
- subsamp);
- tjhandle handle2 = tjInitDecompress();
-
- if (!handle2) THROW_TJ();
-
- if ((yuvBuf = (unsigned char *)malloc(yuvSize)) == NULL)
- THROW("Memory allocation failure");
- memset(yuvBuf, 0, yuvSize);
-
- printf("JPEG -> YUV %s ", subNameLong[subsamp]);
- if (sf.num != 1 || sf.denom != 1)
- printf("%d/%d ... ", sf.num, sf.denom);
- else printf("... ");
- TRY_TJ(tjDecompressToYUV2(handle, jpegBuf, jpegSize, yuvBuf, scaledWidth,
- pad, scaledHeight, flags));
- if (checkBufYUV(yuvBuf, scaledWidth, scaledHeight, subsamp, sf))
- printf("Passed.\n");
- else printf("FAILED!\n");
-
- printf("YUV %s -> %s %s ... ", subNameLong[subsamp], pixFormatStr[pf],
- (flags & TJFLAG_BOTTOMUP) ? "Bottom-Up" : "Top-Down ");
- TRY_TJ(tjDecodeYUV(handle2, yuvBuf, pad, subsamp, dstBuf, scaledWidth, 0,
- scaledHeight, pf, flags));
- tjDestroy(handle2);
- } else {
- printf("JPEG -> %s %s ", pixFormatStr[pf],
- (flags & TJFLAG_BOTTOMUP) ? "Bottom-Up" : "Top-Down ");
- if (sf.num != 1 || sf.denom != 1)
- printf("%d/%d ... ", sf.num, sf.denom);
- else printf("... ");
- TRY_TJ(tjDecompress2(handle, jpegBuf, jpegSize, dstBuf, scaledWidth, 0,
- scaledHeight, pf, flags));
- }
-
- if (checkBuf(dstBuf, scaledWidth, scaledHeight, pf, subsamp, sf, flags))
- printf("Passed.");
- else printf("FAILED!");
- printf("\n");
-
-bailout:
- free(yuvBuf);
- free(dstBuf);
-}
-
-
-static void decompTest(tjhandle handle, unsigned char *jpegBuf,
- unsigned long jpegSize, int w, int h, int pf,
- char *basename, int subsamp, int flags)
-{
- int i, n = 0;
- tjscalingfactor *sf = tjGetScalingFactors(&n);
-
- if (!sf || !n) THROW_TJ();
-
- for (i = 0; i < n; i++) {
- if (subsamp == TJSAMP_444 || subsamp == TJSAMP_GRAY ||
- (subsamp == TJSAMP_411 && sf[i].num == 1 &&
- (sf[i].denom == 2 || sf[i].denom == 1)) ||
- (subsamp != TJSAMP_411 && sf[i].num == 1 &&
- (sf[i].denom == 4 || sf[i].denom == 2 || sf[i].denom == 1)))
- _decompTest(handle, jpegBuf, jpegSize, w, h, pf, basename, subsamp,
- flags, sf[i]);
- }
-
-bailout:
- return;
-}
-
-
-static void doTest(int w, int h, const int *formats, int nformats, int subsamp,
- char *basename)
-{
- tjhandle chandle = NULL, dhandle = NULL;
- unsigned char *dstBuf = NULL;
- unsigned long size = 0;
- int pfi, pf, i;
-
- if (!alloc)
- size = tjBufSize(w, h, subsamp);
- if (size != 0)
- if ((dstBuf = (unsigned char *)tjAlloc(size)) == NULL)
- THROW("Memory allocation failure.");
-
- if ((chandle = tjInitCompress()) == NULL ||
- (dhandle = tjInitDecompress()) == NULL)
- THROW_TJ();
-
- for (pfi = 0; pfi < nformats; pfi++) {
- for (i = 0; i < 2; i++) {
- int flags = 0;
-
- if (subsamp == TJSAMP_422 || subsamp == TJSAMP_420 ||
- subsamp == TJSAMP_440 || subsamp == TJSAMP_411)
- flags |= TJFLAG_FASTUPSAMPLE;
- if (i == 1) flags |= TJFLAG_BOTTOMUP;
- pf = formats[pfi];
- compTest(chandle, &dstBuf, &size, w, h, pf, basename, subsamp, 100,
- flags);
- decompTest(dhandle, dstBuf, size, w, h, pf, basename, subsamp, flags);
- if (pf >= TJPF_RGBX && pf <= TJPF_XRGB) {
- printf("\n");
- decompTest(dhandle, dstBuf, size, w, h, pf + (TJPF_RGBA - TJPF_RGBX),
- basename, subsamp, flags);
- }
- printf("\n");
- }
- }
- printf("--------------------\n\n");
-
-bailout:
- if (chandle) tjDestroy(chandle);
- if (dhandle) tjDestroy(dhandle);
- tjFree(dstBuf);
-}
-
-
-#if SIZEOF_SIZE_T == 8
-#define CHECKSIZE(function) { \
- if ((unsigned long long)size < (unsigned long long)0xFFFFFFFF) \
- THROW(#function " overflow"); \
-}
-#else
-#define CHECKSIZE(function) { \
- if (size != (unsigned long)(-1) || \
- !strcmp(tjGetErrorStr2(NULL), "No error")) \
- THROW(#function " overflow"); \
-}
-#endif
-
-static void overflowTest(void)
-{
- /* Ensure that the various buffer size functions don't overflow */
- unsigned long size;
-
- size = tjBufSize(26755, 26755, TJSAMP_444);
- CHECKSIZE(tjBufSize());
- size = TJBUFSIZE(26755, 26755);
- CHECKSIZE(TJBUFSIZE());
- size = tjBufSizeYUV2(37838, 1, 37838, TJSAMP_444);
- CHECKSIZE(tjBufSizeYUV2());
- size = TJBUFSIZEYUV(37838, 37838, TJSAMP_444);
- CHECKSIZE(TJBUFSIZEYUV());
- size = tjBufSizeYUV(37838, 37838, TJSAMP_444);
- CHECKSIZE(tjBufSizeYUV());
- size = tjPlaneSizeYUV(0, 65536, 0, 65536, TJSAMP_444);
- CHECKSIZE(tjPlaneSizeYUV());
-
-bailout:
- return;
-}
-
-
-static void bufSizeTest(void)
-{
- int w, h, i, subsamp;
- unsigned char *srcBuf = NULL, *dstBuf = NULL;
- tjhandle handle = NULL;
- unsigned long dstSize = 0;
-
- if ((handle = tjInitCompress()) == NULL) THROW_TJ();
-
- printf("Buffer size regression test\n");
- for (subsamp = 0; subsamp < TJ_NUMSAMP; subsamp++) {
- for (w = 1; w < 48; w++) {
- int maxh = (w == 1) ? 2048 : 48;
-
- for (h = 1; h < maxh; h++) {
- if (h % 100 == 0) printf("%.4d x %.4d\b\b\b\b\b\b\b\b\b\b\b", w, h);
- if ((srcBuf = (unsigned char *)malloc(w * h * 4)) == NULL)
- THROW("Memory allocation failure");
- if (!alloc || doYUV) {
- if (doYUV) dstSize = tjBufSizeYUV2(w, pad, h, subsamp);
- else dstSize = tjBufSize(w, h, subsamp);
- if ((dstBuf = (unsigned char *)tjAlloc(dstSize)) == NULL)
- THROW("Memory allocation failure");
- }
-
- for (i = 0; i < w * h * 4; i++) {
- if (random() < RAND_MAX / 2) srcBuf[i] = 0;
- else srcBuf[i] = 255;
- }
-
- if (doYUV) {
- TRY_TJ(tjEncodeYUV3(handle, srcBuf, w, 0, h, TJPF_BGRX, dstBuf, pad,
- subsamp, 0));
- } else {
- TRY_TJ(tjCompress2(handle, srcBuf, w, 0, h, TJPF_BGRX, &dstBuf,
- &dstSize, subsamp, 100,
- alloc ? 0 : TJFLAG_NOREALLOC));
- }
- free(srcBuf); srcBuf = NULL;
- if (!alloc || doYUV) {
- tjFree(dstBuf); dstBuf = NULL;
- }
-
- if ((srcBuf = (unsigned char *)malloc(h * w * 4)) == NULL)
- THROW("Memory allocation failure");
- if (!alloc || doYUV) {
- if (doYUV) dstSize = tjBufSizeYUV2(h, pad, w, subsamp);
- else dstSize = tjBufSize(h, w, subsamp);
- if ((dstBuf = (unsigned char *)tjAlloc(dstSize)) == NULL)
- THROW("Memory allocation failure");
- }
-
- for (i = 0; i < h * w * 4; i++) {
- if (random() < RAND_MAX / 2) srcBuf[i] = 0;
- else srcBuf[i] = 255;
- }
-
- if (doYUV) {
- TRY_TJ(tjEncodeYUV3(handle, srcBuf, h, 0, w, TJPF_BGRX, dstBuf, pad,
- subsamp, 0));
- } else {
- TRY_TJ(tjCompress2(handle, srcBuf, h, 0, w, TJPF_BGRX, &dstBuf,
- &dstSize, subsamp, 100,
- alloc ? 0 : TJFLAG_NOREALLOC));
- }
- free(srcBuf); srcBuf = NULL;
- if (!alloc || doYUV) {
- tjFree(dstBuf); dstBuf = NULL;
- }
- }
- }
- }
- printf("Done. \n");
-
-bailout:
- free(srcBuf);
- tjFree(dstBuf);
- if (handle) tjDestroy(handle);
-}
-
-
-static void initBitmap(unsigned char *buf, int width, int pitch, int height,
- int pf, int flags)
-{
- int roffset = tjRedOffset[pf];
- int goffset = tjGreenOffset[pf];
- int boffset = tjBlueOffset[pf];
- int ps = tjPixelSize[pf];
- int i, j;
-
- for (j = 0; j < height; j++) {
- int row = (flags & TJFLAG_BOTTOMUP) ? height - j - 1 : j;
-
- for (i = 0; i < width; i++) {
- unsigned char r = (i * 256 / width) % 256;
- unsigned char g = (j * 256 / height) % 256;
- unsigned char b = (j * 256 / height + i * 256 / width) % 256;
-
- memset(&buf[row * pitch + i * ps], 0, ps);
- if (pf == TJPF_GRAY) buf[row * pitch + i * ps] = b;
- else if (pf == TJPF_CMYK)
- rgb_to_cmyk(r, g, b, &buf[row * pitch + i * ps + 0],
- &buf[row * pitch + i * ps + 1],
- &buf[row * pitch + i * ps + 2],
- &buf[row * pitch + i * ps + 3]);
- else {
- buf[row * pitch + i * ps + roffset] = r;
- buf[row * pitch + i * ps + goffset] = g;
- buf[row * pitch + i * ps + boffset] = b;
- }
- }
- }
-}
-
-
-static int cmpBitmap(unsigned char *buf, int width, int pitch, int height,
- int pf, int flags, int gray2rgb)
-{
- int roffset = tjRedOffset[pf];
- int goffset = tjGreenOffset[pf];
- int boffset = tjBlueOffset[pf];
- int aoffset = tjAlphaOffset[pf];
- int ps = tjPixelSize[pf];
- int i, j;
-
- for (j = 0; j < height; j++) {
- int row = (flags & TJFLAG_BOTTOMUP) ? height - j - 1 : j;
-
- for (i = 0; i < width; i++) {
- unsigned char r = (i * 256 / width) % 256;
- unsigned char g = (j * 256 / height) % 256;
- unsigned char b = (j * 256 / height + i * 256 / width) % 256;
-
- if (pf == TJPF_GRAY) {
- if (buf[row * pitch + i * ps] != b)
- return 0;
- } else if (pf == TJPF_CMYK) {
- unsigned char rf, gf, bf;
-
- cmyk_to_rgb(buf[row * pitch + i * ps + 0],
- buf[row * pitch + i * ps + 1],
- buf[row * pitch + i * ps + 2],
- buf[row * pitch + i * ps + 3], &rf, &gf, &bf);
- if (gray2rgb) {
- if (rf != b || gf != b || bf != b)
- return 0;
- } else if (rf != r || gf != g || bf != b) return 0;
- } else {
- if (gray2rgb) {
- if (buf[row * pitch + i * ps + roffset] != b ||
- buf[row * pitch + i * ps + goffset] != b ||
- buf[row * pitch + i * ps + boffset] != b)
- return 0;
- } else if (buf[row * pitch + i * ps + roffset] != r ||
- buf[row * pitch + i * ps + goffset] != g ||
- buf[row * pitch + i * ps + boffset] != b)
- return 0;
- if (aoffset >= 0 && buf[row * pitch + i * ps + aoffset] != 0xFF)
- return 0;
- }
- }
- }
- return 1;
-}
-
-
-static int doBmpTest(const char *ext, int width, int align, int height, int pf,
- int flags)
-{
- char filename[80], *md5sum, md5buf[65];
- int ps = tjPixelSize[pf], pitch = PAD(width * ps, align), loadWidth = 0,
- loadHeight = 0, retval = 0, pixelFormat = pf;
- unsigned char *buf = NULL;
- char *md5ref;
-
- if (pf == TJPF_GRAY) {
- md5ref = !strcasecmp(ext, "ppm") ? "112c682e82ce5de1cca089e20d60000b" :
- "51976530acf75f02beddf5d21149101d";
- } else {
- md5ref = !strcasecmp(ext, "ppm") ? "c0c9f772b464d1896326883a5c79c545" :
- "6d659071b9bfcdee2def22cb58ddadca";
- }
-
- if ((buf = (unsigned char *)tjAlloc(pitch * height)) == NULL)
- THROW("Could not allocate memory");
- initBitmap(buf, width, pitch, height, pf, flags);
-
- SNPRINTF(filename, 80, "test_bmp_%s_%d_%s.%s", pixFormatStr[pf], align,
- (flags & TJFLAG_BOTTOMUP) ? "bu" : "td", ext);
- TRY_TJ(tjSaveImage(filename, buf, width, pitch, height, pf, flags));
- md5sum = MD5File(filename, md5buf);
- if (strcasecmp(md5sum, md5ref))
- THROW_MD5(filename, md5sum, md5ref);
-
- tjFree(buf); buf = NULL;
- if ((buf = tjLoadImage(filename, &loadWidth, align, &loadHeight, &pf,
- flags)) == NULL)
- THROW_TJ();
- if (width != loadWidth || height != loadHeight) {
- printf("\n Image dimensions of %s are bogus\n", filename);
- retval = -1; goto bailout;
- }
- if (!cmpBitmap(buf, width, pitch, height, pf, flags, 0)) {
- printf("\n Pixel data in %s is bogus\n", filename);
- retval = -1; goto bailout;
- }
- if (pf == TJPF_GRAY) {
- tjFree(buf); buf = NULL;
- pf = TJPF_XBGR;
- if ((buf = tjLoadImage(filename, &loadWidth, align, &loadHeight, &pf,
- flags)) == NULL)
- THROW_TJ();
- pitch = PAD(width * tjPixelSize[pf], align);
- if (!cmpBitmap(buf, width, pitch, height, pf, flags, 1)) {
- printf("\n Converting %s to RGB failed\n", filename);
- retval = -1; goto bailout;
- }
-
- tjFree(buf); buf = NULL;
- pf = TJPF_CMYK;
- if ((buf = tjLoadImage(filename, &loadWidth, align, &loadHeight, &pf,
- flags)) == NULL)
- THROW_TJ();
- pitch = PAD(width * tjPixelSize[pf], align);
- if (!cmpBitmap(buf, width, pitch, height, pf, flags, 1)) {
- printf("\n Converting %s to CMYK failed\n", filename);
- retval = -1; goto bailout;
- }
- }
- /* Verify that tjLoadImage() returns the proper "preferred" pixel format for
- the file type. */
- tjFree(buf); buf = NULL;
- pf = pixelFormat;
- pixelFormat = TJPF_UNKNOWN;
- if ((buf = tjLoadImage(filename, &loadWidth, align, &loadHeight,
- &pixelFormat, flags)) == NULL)
- THROW_TJ();
- if ((pf == TJPF_GRAY && pixelFormat != TJPF_GRAY) ||
- (pf != TJPF_GRAY && !strcasecmp(ext, "bmp") &&
- pixelFormat != TJPF_BGR) ||
- (pf != TJPF_GRAY && !strcasecmp(ext, "ppm") &&
- pixelFormat != TJPF_RGB)) {
- printf("\n tjLoadImage() returned unexpected pixel format: %s\n",
- pixFormatStr[pixelFormat]);
- retval = -1;
- }
- unlink(filename);
-
-bailout:
- tjFree(buf);
- if (exitStatus < 0) return exitStatus;
- return retval;
-}
-
-
-static int bmpTest(void)
-{
- int align, width = 35, height = 39, format;
-
- for (align = 1; align <= 8; align *= 2) {
- for (format = 0; format < TJ_NUMPF; format++) {
- printf("%s Top-Down BMP (row alignment = %d bytes) ... ",
- pixFormatStr[format], align);
- if (doBmpTest("bmp", width, align, height, format, 0) == -1)
- return -1;
- printf("OK.\n");
-
- printf("%s Top-Down PPM (row alignment = %d bytes) ... ",
- pixFormatStr[format], align);
- if (doBmpTest("ppm", width, align, height, format,
- TJFLAG_BOTTOMUP) == -1)
- return -1;
- printf("OK.\n");
-
- printf("%s Bottom-Up BMP (row alignment = %d bytes) ... ",
- pixFormatStr[format], align);
- if (doBmpTest("bmp", width, align, height, format, 0) == -1)
- return -1;
- printf("OK.\n");
-
- printf("%s Bottom-Up PPM (row alignment = %d bytes) ... ",
- pixFormatStr[format], align);
- if (doBmpTest("ppm", width, align, height, format,
- TJFLAG_BOTTOMUP) == -1)
- return -1;
- printf("OK.\n");
- }
- }
-
- return 0;
-}
-
-
-int main(int argc, char *argv[])
-{
- int i, num4bf = 5;
-
-#ifdef _WIN32
- srand((unsigned int)time(NULL));
-#endif
- if (argc > 1) {
- for (i = 1; i < argc; i++) {
- if (!strcasecmp(argv[i], "-yuv")) doYUV = 1;
- else if (!strcasecmp(argv[i], "-noyuvpad")) pad = 1;
- else if (!strcasecmp(argv[i], "-alloc")) alloc = 1;
- else if (!strcasecmp(argv[i], "-bmp")) return bmpTest();
- else usage(argv[0]);
- }
- }
- if (alloc) printf("Testing automatic buffer allocation\n");
- if (doYUV) num4bf = 4;
- overflowTest();
- doTest(35, 39, _3byteFormats, 2, TJSAMP_444, "test");
- doTest(39, 41, _4byteFormats, num4bf, TJSAMP_444, "test");
- doTest(41, 35, _3byteFormats, 2, TJSAMP_422, "test");
- doTest(35, 39, _4byteFormats, num4bf, TJSAMP_422, "test");
- doTest(39, 41, _3byteFormats, 2, TJSAMP_420, "test");
- doTest(41, 35, _4byteFormats, num4bf, TJSAMP_420, "test");
- doTest(35, 39, _3byteFormats, 2, TJSAMP_440, "test");
- doTest(39, 41, _4byteFormats, num4bf, TJSAMP_440, "test");
- doTest(41, 35, _3byteFormats, 2, TJSAMP_411, "test");
- doTest(35, 39, _4byteFormats, num4bf, TJSAMP_411, "test");
- doTest(39, 41, _onlyGray, 1, TJSAMP_GRAY, "test");
- doTest(41, 35, _3byteFormats, 2, TJSAMP_GRAY, "test");
- doTest(35, 39, _4byteFormats, 4, TJSAMP_GRAY, "test");
- bufSizeTest();
- if (doYUV) {
- printf("\n--------------------\n\n");
- doTest(48, 48, _onlyRGB, 1, TJSAMP_444, "test_yuv0");
- doTest(48, 48, _onlyRGB, 1, TJSAMP_422, "test_yuv0");
- doTest(48, 48, _onlyRGB, 1, TJSAMP_420, "test_yuv0");
- doTest(48, 48, _onlyRGB, 1, TJSAMP_440, "test_yuv0");
- doTest(48, 48, _onlyRGB, 1, TJSAMP_411, "test_yuv0");
- doTest(48, 48, _onlyRGB, 1, TJSAMP_GRAY, "test_yuv0");
- doTest(48, 48, _onlyGray, 1, TJSAMP_GRAY, "test_yuv0");
- }
-
- return exitStatus;
-}
diff --git a/contrib/libs/libjpeg-turbo/tjunittest/ya.make b/contrib/libs/libjpeg-turbo/tjunittest/ya.make
deleted file mode 100644
index 82eb9886ee..0000000000
--- a/contrib/libs/libjpeg-turbo/tjunittest/ya.make
+++ /dev/null
@@ -1,28 +0,0 @@
-# Generated by devtools/yamaker.
-
-PROGRAM()
-
-WITHOUT_LICENSE_TEXTS()
-
-PEERDIR(
- contrib/libs/libjpeg-turbo
-)
-
-ADDINCL(
- contrib/libs/libjpeg-turbo
-)
-
-NO_COMPILER_WARNINGS()
-
-NO_RUNTIME()
-
-SRCDIR(contrib/libs/libjpeg-turbo)
-
-SRCS(
- md5/md5.c
- md5/md5hl.c
- tjunittest.c
- tjutil.c
-)
-
-END()
diff --git a/contrib/libs/libjpeg-turbo/tjutil.c b/contrib/libs/libjpeg-turbo/tjutil.c
deleted file mode 100644
index 2018160b16..0000000000
--- a/contrib/libs/libjpeg-turbo/tjutil.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C)2011, 2019 D. R. Commander. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * - Neither the name of the libjpeg-turbo Project nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS",
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifdef _WIN32
-
-#include <windows.h>
-#include "tjutil.h"
-
-static double getFreq(void)
-{
- LARGE_INTEGER freq;
-
- if (!QueryPerformanceFrequency(&freq)) return 0.0;
- return (double)freq.QuadPart;
-}
-
-static double f = -1.0;
-
-double getTime(void)
-{
- LARGE_INTEGER t;
-
- if (f < 0.0) f = getFreq();
- if (f == 0.0) return (double)GetTickCount() / 1000.;
- else {
- QueryPerformanceCounter(&t);
- return (double)t.QuadPart / f;
- }
-}
-
-#else
-
-#include <stdlib.h>
-#include <sys/time.h>
-#include "tjutil.h"
-
-double getTime(void)
-{
- struct timeval tv;
-
- if (gettimeofday(&tv, NULL) < 0) return 0.0;
- else return (double)tv.tv_sec + ((double)tv.tv_usec / 1000000.);
-}
-
-#endif
diff --git a/contrib/libs/libjpeg-turbo/tjutil.h b/contrib/libs/libjpeg-turbo/tjutil.h
deleted file mode 100644
index 10272e9886..0000000000
--- a/contrib/libs/libjpeg-turbo/tjutil.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C)2011, 2022 D. R. Commander. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * - Neither the name of the libjpeg-turbo Project nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS",
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifdef _WIN32
-#ifndef strcasecmp
-#define strcasecmp stricmp
-#endif
-#ifndef strncasecmp
-#define strncasecmp strnicmp
-#endif
-#endif
-
-#ifdef _MSC_VER
-#define SNPRINTF(str, n, format, ...) \
- _snprintf_s(str, n, _TRUNCATE, format, ##__VA_ARGS__)
-#else
-#define SNPRINTF snprintf
-#endif
-
-#ifndef min
-#define min(a, b) ((a) < (b) ? (a) : (b))
-#endif
-
-#ifndef max
-#define max(a, b) ((a) > (b) ? (a) : (b))
-#endif
-
-extern double getTime(void);
diff --git a/contrib/libs/libjpeg-turbo/transupp.c b/contrib/libs/libjpeg-turbo/transupp.c
deleted file mode 100644
index a3d878cc73..0000000000
--- a/contrib/libs/libjpeg-turbo/transupp.c
+++ /dev/null
@@ -1,2373 +0,0 @@
-/*
- * transupp.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1997-2019, Thomas G. Lane, Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2017, 2021-2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains image transformation routines and other utility code
- * used by the jpegtran sample application. These are NOT part of the core
- * JPEG library. But we keep these routines separate from jpegtran.c to
- * ease the task of maintaining jpegtran-like programs that have other user
- * interfaces.
- */
-
-/* Although this file really shouldn't have access to the library internals,
- * it's helpful to let it call jround_up() and jcopy_block_row().
- */
-#define JPEG_INTERNALS
-
-#include "jinclude.h"
-#include "jpeglib.h"
-#include "transupp.h" /* My own external interface */
-#include "jpegcomp.h"
-#include <ctype.h> /* to declare isdigit() */
-
-
-#if JPEG_LIB_VERSION >= 70
-#define dstinfo_min_DCT_h_scaled_size dstinfo->min_DCT_h_scaled_size
-#define dstinfo_min_DCT_v_scaled_size dstinfo->min_DCT_v_scaled_size
-#else
-#define dstinfo_min_DCT_h_scaled_size DCTSIZE
-#define dstinfo_min_DCT_v_scaled_size DCTSIZE
-#endif
-
-
-#if TRANSFORMS_SUPPORTED
-
-/*
- * Lossless image transformation routines. These routines work on DCT
- * coefficient arrays and thus do not require any lossy decompression
- * or recompression of the image.
- * Thanks to Guido Vollbeding for the initial design and code of this feature,
- * and to Ben Jackson for introducing the cropping feature.
- *
- * Horizontal flipping is done in-place, using a single top-to-bottom
- * pass through the virtual source array. It will thus be much the
- * fastest option for images larger than main memory.
- *
- * The other routines require a set of destination virtual arrays, so they
- * need twice as much memory as jpegtran normally does. The destination
- * arrays are always written in normal scan order (top to bottom) because
- * the virtual array manager expects this. The source arrays will be scanned
- * in the corresponding order, which means multiple passes through the source
- * arrays for most of the transforms. That could result in much thrashing
- * if the image is larger than main memory.
- *
- * If cropping or trimming is involved, the destination arrays may be smaller
- * than the source arrays. Note it is not possible to do horizontal flip
- * in-place when a nonzero Y crop offset is specified, since we'd have to move
- * data from one block row to another but the virtual array manager doesn't
- * guarantee we can touch more than one row at a time. So in that case,
- * we have to use a separate destination array.
- *
- * Some notes about the operating environment of the individual transform
- * routines:
- * 1. Both the source and destination virtual arrays are allocated from the
- * source JPEG object, and therefore should be manipulated by calling the
- * source's memory manager.
- * 2. The destination's component count should be used. It may be smaller
- * than the source's when forcing to grayscale.
- * 3. Likewise the destination's sampling factors should be used. When
- * forcing to grayscale the destination's sampling factors will be all 1,
- * and we may as well take that as the effective iMCU size.
- * 4. When "trim" is in effect, the destination's dimensions will be the
- * trimmed values but the source's will be untrimmed.
- * 5. When "crop" is in effect, the destination's dimensions will be the
- * cropped values but the source's will be uncropped. Each transform
- * routine is responsible for picking up source data starting at the
- * correct X and Y offset for the crop region. (The X and Y offsets
- * passed to the transform routines are measured in iMCU blocks of the
- * destination.)
- * 6. All the routines assume that the source and destination buffers are
- * padded out to a full iMCU boundary. This is true, although for the
- * source buffer it is an undocumented property of jdcoefct.c.
- */
-
-
-LOCAL(void)
-dequant_comp(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- jvirt_barray_ptr coef_array, JQUANT_TBL *qtblptr1)
-{
- JDIMENSION blk_x, blk_y;
- int offset_y, k;
- JQUANT_TBL *qtblptr;
- JBLOCKARRAY buffer;
- JBLOCKROW block;
- JCOEFPTR ptr;
-
- qtblptr = compptr->quant_table;
- for (blk_y = 0; blk_y < compptr->height_in_blocks;
- blk_y += compptr->v_samp_factor) {
- buffer = (*cinfo->mem->access_virt_barray)
- ((j_common_ptr)cinfo, coef_array, blk_y,
- (JDIMENSION)compptr->v_samp_factor, TRUE);
- for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) {
- block = buffer[offset_y];
- for (blk_x = 0; blk_x < compptr->width_in_blocks; blk_x++) {
- ptr = block[blk_x];
- for (k = 0; k < DCTSIZE2; k++)
- if (qtblptr->quantval[k] != qtblptr1->quantval[k])
- ptr[k] *= qtblptr->quantval[k] / qtblptr1->quantval[k];
- }
- }
- }
-}
-
-
-LOCAL(void)
-requant_comp(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- jvirt_barray_ptr coef_array, JQUANT_TBL *qtblptr1)
-{
- JDIMENSION blk_x, blk_y;
- int offset_y, k;
- JQUANT_TBL *qtblptr;
- JBLOCKARRAY buffer;
- JBLOCKROW block;
- JCOEFPTR ptr;
- JCOEF temp, qval;
-
- qtblptr = compptr->quant_table;
- for (blk_y = 0; blk_y < compptr->height_in_blocks;
- blk_y += compptr->v_samp_factor) {
- buffer = (*cinfo->mem->access_virt_barray)
- ((j_common_ptr)cinfo, coef_array, blk_y,
- (JDIMENSION)compptr->v_samp_factor, TRUE);
- for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) {
- block = buffer[offset_y];
- for (blk_x = 0; blk_x < compptr->width_in_blocks; blk_x++) {
- ptr = block[blk_x];
- for (k = 0; k < DCTSIZE2; k++) {
- temp = qtblptr->quantval[k];
- qval = qtblptr1->quantval[k];
- if (temp != qval) {
- temp *= ptr[k];
- /* The following quantization code is copied from jcdctmgr.c */
-#ifdef FAST_DIVIDE
-#define DIVIDE_BY(a, b) a /= b
-#else
-#define DIVIDE_BY(a, b) if (a >= b) a /= b; else a = 0
-#endif
- if (temp < 0) {
- temp = -temp;
- temp += qval >> 1; /* for rounding */
- DIVIDE_BY(temp, qval);
- temp = -temp;
- } else {
- temp += qval >> 1; /* for rounding */
- DIVIDE_BY(temp, qval);
- }
- ptr[k] = temp;
- }
- }
- }
- }
- }
-}
-
-
-/*
- * Calculate largest common denominator using Euclid's algorithm.
- */
-LOCAL(JCOEF)
-largest_common_denominator(JCOEF a, JCOEF b)
-{
- JCOEF c;
-
- do {
- c = a % b;
- a = b;
- b = c;
- } while (c);
-
- return a;
-}
-
-
-LOCAL(void)
-adjust_quant(j_decompress_ptr srcinfo, jvirt_barray_ptr *src_coef_arrays,
- j_decompress_ptr dropinfo, jvirt_barray_ptr *drop_coef_arrays,
- boolean trim, j_compress_ptr dstinfo)
-{
- jpeg_component_info *compptr1, *compptr2;
- JQUANT_TBL *qtblptr1, *qtblptr2, *qtblptr3;
- int ci, k;
-
- for (ci = 0; ci < dstinfo->num_components && ci < dropinfo->num_components;
- ci++) {
- compptr1 = srcinfo->comp_info + ci;
- compptr2 = dropinfo->comp_info + ci;
- qtblptr1 = compptr1->quant_table;
- qtblptr2 = compptr2->quant_table;
- for (k = 0; k < DCTSIZE2; k++) {
- if (qtblptr1->quantval[k] != qtblptr2->quantval[k]) {
- if (trim)
- requant_comp(dropinfo, compptr2, drop_coef_arrays[ci], qtblptr1);
- else {
- qtblptr3 = dstinfo->quant_tbl_ptrs[compptr1->quant_tbl_no];
- for (k = 0; k < DCTSIZE2; k++)
- if (qtblptr1->quantval[k] != qtblptr2->quantval[k])
- qtblptr3->quantval[k] =
- largest_common_denominator(qtblptr1->quantval[k],
- qtblptr2->quantval[k]);
- dequant_comp(srcinfo, compptr1, src_coef_arrays[ci], qtblptr3);
- dequant_comp(dropinfo, compptr2, drop_coef_arrays[ci], qtblptr3);
- }
- break;
- }
- }
- }
-}
-
-
-LOCAL(void)
-do_drop(j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
- JDIMENSION x_crop_offset, JDIMENSION y_crop_offset,
- jvirt_barray_ptr *src_coef_arrays,
- j_decompress_ptr dropinfo, jvirt_barray_ptr *drop_coef_arrays,
- JDIMENSION drop_width, JDIMENSION drop_height)
-/* Drop (insert) the contents of another image into the source image. If the
- * number of components in the drop image is smaller than the number of
- * components in the destination image, then we fill in the remaining
- * components with zero. This allows for dropping the contents of grayscale
- * images into (arbitrarily sampled) color images.
- */
-{
- JDIMENSION comp_width, comp_height;
- JDIMENSION blk_y, x_drop_blocks, y_drop_blocks;
- int ci, offset_y;
- JBLOCKARRAY src_buffer, dst_buffer;
- jpeg_component_info *compptr;
-
- for (ci = 0; ci < dstinfo->num_components; ci++) {
- compptr = dstinfo->comp_info + ci;
- comp_width = drop_width * compptr->h_samp_factor;
- comp_height = drop_height * compptr->v_samp_factor;
- x_drop_blocks = x_crop_offset * compptr->h_samp_factor;
- y_drop_blocks = y_crop_offset * compptr->v_samp_factor;
- for (blk_y = 0; blk_y < comp_height; blk_y += compptr->v_samp_factor) {
- dst_buffer = (*srcinfo->mem->access_virt_barray)
- ((j_common_ptr)srcinfo, src_coef_arrays[ci], blk_y + y_drop_blocks,
- (JDIMENSION)compptr->v_samp_factor, TRUE);
- if (ci < dropinfo->num_components) {
- src_buffer = (*dropinfo->mem->access_virt_barray)
- ((j_common_ptr)dropinfo, drop_coef_arrays[ci], blk_y,
- (JDIMENSION)compptr->v_samp_factor, FALSE);
- for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) {
- jcopy_block_row(src_buffer[offset_y],
- dst_buffer[offset_y] + x_drop_blocks, comp_width);
- }
- } else {
- for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) {
- memset(dst_buffer[offset_y] + x_drop_blocks, 0,
- comp_width * sizeof(JBLOCK));
- }
- }
- }
- }
-}
-
-
-LOCAL(void)
-do_crop(j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
- JDIMENSION x_crop_offset, JDIMENSION y_crop_offset,
- jvirt_barray_ptr *src_coef_arrays,
- jvirt_barray_ptr *dst_coef_arrays)
-/* Crop. This is only used when no rotate/flip is requested with the crop. */
-{
- JDIMENSION dst_blk_y, x_crop_blocks, y_crop_blocks;
- int ci, offset_y;
- JBLOCKARRAY src_buffer, dst_buffer;
- jpeg_component_info *compptr;
-
- /* We simply have to copy the right amount of data (the destination's
- * image size) starting at the given X and Y offsets in the source.
- */
- for (ci = 0; ci < dstinfo->num_components; ci++) {
- compptr = dstinfo->comp_info + ci;
- x_crop_blocks = x_crop_offset * compptr->h_samp_factor;
- y_crop_blocks = y_crop_offset * compptr->v_samp_factor;
- for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks;
- dst_blk_y += compptr->v_samp_factor) {
- dst_buffer = (*srcinfo->mem->access_virt_barray)
- ((j_common_ptr)srcinfo, dst_coef_arrays[ci], dst_blk_y,
- (JDIMENSION)compptr->v_samp_factor, TRUE);
- src_buffer = (*srcinfo->mem->access_virt_barray)
- ((j_common_ptr)srcinfo, src_coef_arrays[ci], dst_blk_y + y_crop_blocks,
- (JDIMENSION)compptr->v_samp_factor, FALSE);
- for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) {
- jcopy_block_row(src_buffer[offset_y] + x_crop_blocks,
- dst_buffer[offset_y], compptr->width_in_blocks);
- }
- }
- }
-}
-
-
-LOCAL(void)
-do_crop_ext_zero(j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
- JDIMENSION x_crop_offset, JDIMENSION y_crop_offset,
- jvirt_barray_ptr *src_coef_arrays,
- jvirt_barray_ptr *dst_coef_arrays)
-/* Crop. This is only used when no rotate/flip is requested with the crop.
- * Extension: If the destination size is larger than the source, we fill in the
- * expanded region with zero (neutral gray). Note that we also have to zero
- * partial iMCUs at the right and bottom edge of the source image area in this
- * case.
- */
-{
- JDIMENSION MCU_cols, MCU_rows, comp_width, comp_height;
- JDIMENSION dst_blk_y, x_crop_blocks, y_crop_blocks;
- int ci, offset_y;
- JBLOCKARRAY src_buffer, dst_buffer;
- jpeg_component_info *compptr;
-
- MCU_cols = srcinfo->output_width /
- (dstinfo->max_h_samp_factor * dstinfo_min_DCT_h_scaled_size);
- MCU_rows = srcinfo->output_height /
- (dstinfo->max_v_samp_factor * dstinfo_min_DCT_v_scaled_size);
-
- for (ci = 0; ci < dstinfo->num_components; ci++) {
- compptr = dstinfo->comp_info + ci;
- comp_width = MCU_cols * compptr->h_samp_factor;
- comp_height = MCU_rows * compptr->v_samp_factor;
- x_crop_blocks = x_crop_offset * compptr->h_samp_factor;
- y_crop_blocks = y_crop_offset * compptr->v_samp_factor;
- for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks;
- dst_blk_y += compptr->v_samp_factor) {
- dst_buffer = (*srcinfo->mem->access_virt_barray)
- ((j_common_ptr)srcinfo, dst_coef_arrays[ci], dst_blk_y,
- (JDIMENSION)compptr->v_samp_factor, TRUE);
- if (dstinfo->_jpeg_height > srcinfo->output_height) {
- if (dst_blk_y < y_crop_blocks ||
- dst_blk_y >= y_crop_blocks + comp_height) {
- for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) {
- memset(dst_buffer[offset_y], 0,
- compptr->width_in_blocks * sizeof(JBLOCK));
- }
- continue;
- }
- src_buffer = (*srcinfo->mem->access_virt_barray)
- ((j_common_ptr)srcinfo, src_coef_arrays[ci],
- dst_blk_y - y_crop_blocks, (JDIMENSION)compptr->v_samp_factor,
- FALSE);
- } else {
- src_buffer = (*srcinfo->mem->access_virt_barray)
- ((j_common_ptr)srcinfo, src_coef_arrays[ci],
- dst_blk_y + y_crop_blocks, (JDIMENSION)compptr->v_samp_factor,
- FALSE);
- }
- for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) {
- if (dstinfo->_jpeg_width > srcinfo->output_width) {
- if (x_crop_blocks > 0) {
- memset(dst_buffer[offset_y], 0, x_crop_blocks * sizeof(JBLOCK));
- }
- jcopy_block_row(src_buffer[offset_y],
- dst_buffer[offset_y] + x_crop_blocks, comp_width);
- if (compptr->width_in_blocks > x_crop_blocks + comp_width) {
- memset(dst_buffer[offset_y] + x_crop_blocks + comp_width, 0,
- (compptr->width_in_blocks - x_crop_blocks - comp_width) *
- sizeof(JBLOCK));
- }
- } else {
- jcopy_block_row(src_buffer[offset_y] + x_crop_blocks,
- dst_buffer[offset_y], compptr->width_in_blocks);
- }
- }
- }
- }
-}
-
-
-LOCAL(void)
-do_crop_ext_flat(j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
- JDIMENSION x_crop_offset, JDIMENSION y_crop_offset,
- jvirt_barray_ptr *src_coef_arrays,
- jvirt_barray_ptr *dst_coef_arrays)
-/* Crop. This is only used when no rotate/flip is requested with the crop.
- * Extension: The destination width is larger than the source, and we fill in
- * the expanded region with the DC coefficient of the adjacent block. Note
- * that we also have to fill partial iMCUs at the right and bottom edge of the
- * source image area in this case.
- */
-{
- JDIMENSION MCU_cols, MCU_rows, comp_width, comp_height;
- JDIMENSION dst_blk_x, dst_blk_y, x_crop_blocks, y_crop_blocks;
- int ci, offset_y;
- JCOEF dc;
- JBLOCKARRAY src_buffer, dst_buffer;
- jpeg_component_info *compptr;
-
- MCU_cols = srcinfo->output_width /
- (dstinfo->max_h_samp_factor * dstinfo_min_DCT_h_scaled_size);
- MCU_rows = srcinfo->output_height /
- (dstinfo->max_v_samp_factor * dstinfo_min_DCT_v_scaled_size);
-
- for (ci = 0; ci < dstinfo->num_components; ci++) {
- compptr = dstinfo->comp_info + ci;
- comp_width = MCU_cols * compptr->h_samp_factor;
- comp_height = MCU_rows * compptr->v_samp_factor;
- x_crop_blocks = x_crop_offset * compptr->h_samp_factor;
- y_crop_blocks = y_crop_offset * compptr->v_samp_factor;
- for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks;
- dst_blk_y += compptr->v_samp_factor) {
- dst_buffer = (*srcinfo->mem->access_virt_barray)
- ((j_common_ptr)srcinfo, dst_coef_arrays[ci], dst_blk_y,
- (JDIMENSION)compptr->v_samp_factor, TRUE);
- if (dstinfo->_jpeg_height > srcinfo->output_height) {
- if (dst_blk_y < y_crop_blocks ||
- dst_blk_y >= y_crop_blocks + comp_height) {
- for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) {
- memset(dst_buffer[offset_y], 0,
- compptr->width_in_blocks * sizeof(JBLOCK));
- }
- continue;
- }
- src_buffer = (*srcinfo->mem->access_virt_barray)
- ((j_common_ptr)srcinfo, src_coef_arrays[ci],
- dst_blk_y - y_crop_blocks, (JDIMENSION)compptr->v_samp_factor,
- FALSE);
- } else {
- src_buffer = (*srcinfo->mem->access_virt_barray)
- ((j_common_ptr)srcinfo, src_coef_arrays[ci],
- dst_blk_y + y_crop_blocks, (JDIMENSION)compptr->v_samp_factor,
- FALSE);
- }
- for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) {
- if (x_crop_blocks > 0) {
- memset(dst_buffer[offset_y], 0, x_crop_blocks * sizeof(JBLOCK));
- dc = src_buffer[offset_y][0][0];
- for (dst_blk_x = 0; dst_blk_x < x_crop_blocks; dst_blk_x++) {
- dst_buffer[offset_y][dst_blk_x][0] = dc;
- }
- }
- jcopy_block_row(src_buffer[offset_y],
- dst_buffer[offset_y] + x_crop_blocks, comp_width);
- if (compptr->width_in_blocks > x_crop_blocks + comp_width) {
- memset(dst_buffer[offset_y] + x_crop_blocks + comp_width, 0,
- (compptr->width_in_blocks - x_crop_blocks - comp_width) *
- sizeof(JBLOCK));
- dc = src_buffer[offset_y][comp_width - 1][0];
- for (dst_blk_x = x_crop_blocks + comp_width;
- dst_blk_x < compptr->width_in_blocks; dst_blk_x++) {
- dst_buffer[offset_y][dst_blk_x][0] = dc;
- }
- }
- }
- }
- }
-}
-
-
-LOCAL(void)
-do_crop_ext_reflect(j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
- JDIMENSION x_crop_offset, JDIMENSION y_crop_offset,
- jvirt_barray_ptr *src_coef_arrays,
- jvirt_barray_ptr *dst_coef_arrays)
-/* Crop. This is only used when no rotate/flip is requested with the crop.
- * Extension: The destination width is larger than the source, and we fill in
- * the expanded region with repeated reflections of the source image. Note
- * that we also have to fill partial iMCUs at the right and bottom edge of the
- * source image area in this case.
- */
-{
- JDIMENSION MCU_cols, MCU_rows, comp_width, comp_height, src_blk_x;
- JDIMENSION dst_blk_x, dst_blk_y, x_crop_blocks, y_crop_blocks;
- int ci, k, offset_y;
- JBLOCKARRAY src_buffer, dst_buffer;
- JBLOCKROW src_row_ptr, dst_row_ptr;
- JCOEFPTR src_ptr, dst_ptr;
- jpeg_component_info *compptr;
-
- MCU_cols = srcinfo->output_width /
- (dstinfo->max_h_samp_factor * dstinfo_min_DCT_h_scaled_size);
- MCU_rows = srcinfo->output_height /
- (dstinfo->max_v_samp_factor * dstinfo_min_DCT_v_scaled_size);
-
- for (ci = 0; ci < dstinfo->num_components; ci++) {
- compptr = dstinfo->comp_info + ci;
- comp_width = MCU_cols * compptr->h_samp_factor;
- comp_height = MCU_rows * compptr->v_samp_factor;
- x_crop_blocks = x_crop_offset * compptr->h_samp_factor;
- y_crop_blocks = y_crop_offset * compptr->v_samp_factor;
- for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks;
- dst_blk_y += compptr->v_samp_factor) {
- dst_buffer = (*srcinfo->mem->access_virt_barray)
- ((j_common_ptr)srcinfo, dst_coef_arrays[ci], dst_blk_y,
- (JDIMENSION)compptr->v_samp_factor, TRUE);
- if (dstinfo->_jpeg_height > srcinfo->output_height) {
- if (dst_blk_y < y_crop_blocks ||
- dst_blk_y >= y_crop_blocks + comp_height) {
- for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) {
- memset(dst_buffer[offset_y], 0,
- compptr->width_in_blocks * sizeof(JBLOCK));
- }
- continue;
- }
- src_buffer = (*srcinfo->mem->access_virt_barray)
- ((j_common_ptr)srcinfo, src_coef_arrays[ci],
- dst_blk_y - y_crop_blocks, (JDIMENSION)compptr->v_samp_factor,
- FALSE);
- } else {
- src_buffer = (*srcinfo->mem->access_virt_barray)
- ((j_common_ptr)srcinfo, src_coef_arrays[ci],
- dst_blk_y + y_crop_blocks, (JDIMENSION)compptr->v_samp_factor,
- FALSE);
- }
- for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) {
- /* Copy source region */
- jcopy_block_row(src_buffer[offset_y],
- dst_buffer[offset_y] + x_crop_blocks, comp_width);
- if (x_crop_blocks > 0) {
- /* Reflect to left */
- dst_row_ptr = dst_buffer[offset_y] + x_crop_blocks;
- for (dst_blk_x = x_crop_blocks; dst_blk_x > 0;) {
- src_row_ptr = dst_row_ptr; /* (re)set axis of reflection */
- for (src_blk_x = comp_width; src_blk_x > 0 && dst_blk_x > 0;
- src_blk_x--, dst_blk_x--) {
- dst_ptr = *(--dst_row_ptr); /* destination goes left */
- src_ptr = *src_row_ptr++; /* source goes right */
- /* This unrolled loop doesn't need to know which row it's on. */
- for (k = 0; k < DCTSIZE2; k += 2) {
- *dst_ptr++ = *src_ptr++; /* copy even column */
- *dst_ptr++ = -(*src_ptr++); /* copy odd column with sign
- change */
- }
- }
- }
- }
- if (compptr->width_in_blocks > x_crop_blocks + comp_width) {
- /* Reflect to right */
- dst_row_ptr = dst_buffer[offset_y] + x_crop_blocks + comp_width;
- for (dst_blk_x = compptr->width_in_blocks - x_crop_blocks - comp_width;
- dst_blk_x > 0;) {
- src_row_ptr = dst_row_ptr; /* (re)set axis of reflection */
- for (src_blk_x = comp_width; src_blk_x > 0 && dst_blk_x > 0;
- src_blk_x--, dst_blk_x--) {
- dst_ptr = *dst_row_ptr++; /* destination goes right */
- src_ptr = *(--src_row_ptr); /* source goes left */
- /* This unrolled loop doesn't need to know which row it's on. */
- for (k = 0; k < DCTSIZE2; k += 2) {
- *dst_ptr++ = *src_ptr++; /* copy even column */
- *dst_ptr++ = -(*src_ptr++); /* copy odd column with sign
- change */
- }
- }
- }
- }
- }
- }
- }
-}
-
-
-LOCAL(void)
-do_wipe(j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
- JDIMENSION x_crop_offset, JDIMENSION y_crop_offset,
- jvirt_barray_ptr *src_coef_arrays,
- JDIMENSION drop_width, JDIMENSION drop_height)
-/* Wipe - discard image contents of specified region and fill with zero
- * (neutral gray)
- */
-{
- JDIMENSION x_wipe_blocks, wipe_width;
- JDIMENSION y_wipe_blocks, wipe_bottom;
- int ci, offset_y;
- JBLOCKARRAY buffer;
- jpeg_component_info *compptr;
-
- for (ci = 0; ci < dstinfo->num_components; ci++) {
- compptr = dstinfo->comp_info + ci;
- x_wipe_blocks = x_crop_offset * compptr->h_samp_factor;
- wipe_width = drop_width * compptr->h_samp_factor;
- y_wipe_blocks = y_crop_offset * compptr->v_samp_factor;
- wipe_bottom = drop_height * compptr->v_samp_factor + y_wipe_blocks;
- for (; y_wipe_blocks < wipe_bottom;
- y_wipe_blocks += compptr->v_samp_factor) {
- buffer = (*srcinfo->mem->access_virt_barray)
- ((j_common_ptr)srcinfo, src_coef_arrays[ci], y_wipe_blocks,
- (JDIMENSION)compptr->v_samp_factor, TRUE);
- for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) {
- memset(buffer[offset_y] + x_wipe_blocks, 0,
- wipe_width * sizeof(JBLOCK));
- }
- }
- }
-}
-
-
-LOCAL(void)
-do_flatten(j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
- JDIMENSION x_crop_offset, JDIMENSION y_crop_offset,
- jvirt_barray_ptr *src_coef_arrays,
- JDIMENSION drop_width, JDIMENSION drop_height)
-/* Flatten - discard image contents of specified region, similarly to wipe,
- * but fill with the average of adjacent blocks instead of zero.
- */
-{
- JDIMENSION x_wipe_blocks, wipe_width, wipe_right;
- JDIMENSION y_wipe_blocks, wipe_bottom, blk_x;
- int ci, offset_y, dc_left_value, dc_right_value, average;
- JBLOCKARRAY buffer;
- jpeg_component_info *compptr;
-
- for (ci = 0; ci < dstinfo->num_components; ci++) {
- compptr = dstinfo->comp_info + ci;
- x_wipe_blocks = x_crop_offset * compptr->h_samp_factor;
- wipe_width = drop_width * compptr->h_samp_factor;
- wipe_right = wipe_width + x_wipe_blocks;
- y_wipe_blocks = y_crop_offset * compptr->v_samp_factor;
- wipe_bottom = drop_height * compptr->v_samp_factor + y_wipe_blocks;
- for (; y_wipe_blocks < wipe_bottom;
- y_wipe_blocks += compptr->v_samp_factor) {
- buffer = (*srcinfo->mem->access_virt_barray)
- ((j_common_ptr)srcinfo, src_coef_arrays[ci], y_wipe_blocks,
- (JDIMENSION)compptr->v_samp_factor, TRUE);
- for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) {
- memset(buffer[offset_y] + x_wipe_blocks, 0,
- wipe_width * sizeof(JBLOCK));
- if (x_wipe_blocks > 0) {
- dc_left_value = buffer[offset_y][x_wipe_blocks - 1][0];
- if (wipe_right < compptr->width_in_blocks) {
- dc_right_value = buffer[offset_y][wipe_right][0];
- average = (dc_left_value + dc_right_value) >> 1;
- } else {
- average = dc_left_value;
- }
- } else if (wipe_right < compptr->width_in_blocks) {
- average = buffer[offset_y][wipe_right][0];
- } else continue;
- for (blk_x = x_wipe_blocks; blk_x < wipe_right; blk_x++) {
- buffer[offset_y][blk_x][0] = (JCOEF)average;
- }
- }
- }
- }
-}
-
-
-LOCAL(void)
-do_reflect(j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
- JDIMENSION x_crop_offset, jvirt_barray_ptr *src_coef_arrays,
- JDIMENSION drop_width, JDIMENSION drop_height)
-/* Reflect - discard image contents of specified region, similarly to wipe,
- * but fill with repeated reflections of the outside region instead of zero.
- * NB: y_crop_offset is assumed to be zero.
- */
-{
- JDIMENSION x_wipe_blocks, wipe_width;
- JDIMENSION y_wipe_blocks, wipe_bottom;
- JDIMENSION src_blk_x, dst_blk_x;
- int ci, k, offset_y;
- JBLOCKARRAY buffer;
- JBLOCKROW src_row_ptr, dst_row_ptr;
- JCOEFPTR src_ptr, dst_ptr;
- jpeg_component_info *compptr;
-
- for (ci = 0; ci < dstinfo->num_components; ci++) {
- compptr = dstinfo->comp_info + ci;
- x_wipe_blocks = x_crop_offset * compptr->h_samp_factor;
- wipe_width = drop_width * compptr->h_samp_factor;
- wipe_bottom = drop_height * compptr->v_samp_factor;
- for (y_wipe_blocks = 0; y_wipe_blocks < wipe_bottom;
- y_wipe_blocks += compptr->v_samp_factor) {
- buffer = (*srcinfo->mem->access_virt_barray)
- ((j_common_ptr)srcinfo, src_coef_arrays[ci], y_wipe_blocks,
- (JDIMENSION)compptr->v_samp_factor, TRUE);
- for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) {
- if (x_wipe_blocks > 0) {
- /* Reflect from left */
- dst_row_ptr = buffer[offset_y] + x_wipe_blocks;
- for (dst_blk_x = wipe_width; dst_blk_x > 0;) {
- src_row_ptr = dst_row_ptr; /* (re)set axis of reflection */
- for (src_blk_x = x_wipe_blocks;
- src_blk_x > 0 && dst_blk_x > 0; src_blk_x--, dst_blk_x--) {
- dst_ptr = *dst_row_ptr++; /* destination goes right */
- src_ptr = *(--src_row_ptr); /* source goes left */
- /* this unrolled loop doesn't need to know which row it's on... */
- for (k = 0; k < DCTSIZE2; k += 2) {
- *dst_ptr++ = *src_ptr++; /* copy even column */
- *dst_ptr++ = -(*src_ptr++); /* copy odd column with sign change */
- }
- }
- }
- } else if (compptr->width_in_blocks > x_wipe_blocks + wipe_width) {
- /* Reflect from right */
- dst_row_ptr = buffer[offset_y] + x_wipe_blocks + wipe_width;
- for (dst_blk_x = wipe_width; dst_blk_x > 0;) {
- src_row_ptr = dst_row_ptr; /* (re)set axis of reflection */
- src_blk_x = compptr->width_in_blocks - x_wipe_blocks - wipe_width;
- for (; src_blk_x > 0 && dst_blk_x > 0; src_blk_x--, dst_blk_x--) {
- dst_ptr = *(--dst_row_ptr); /* destination goes left */
- src_ptr = *src_row_ptr++; /* source goes right */
- /* this unrolled loop doesn't need to know which row it's on... */
- for (k = 0; k < DCTSIZE2; k += 2) {
- *dst_ptr++ = *src_ptr++; /* copy even column */
- *dst_ptr++ = -(*src_ptr++); /* copy odd column with sign change */
- }
- }
- }
- } else {
- memset(buffer[offset_y] + x_wipe_blocks, 0,
- wipe_width * sizeof(JBLOCK));
- }
- }
- }
- }
-}
-
-
-LOCAL(void)
-do_flip_h_no_crop(j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
- JDIMENSION x_crop_offset, jvirt_barray_ptr *src_coef_arrays)
-/* Horizontal flip; done in-place, so no separate dest array is required.
- * NB: this only works when y_crop_offset is zero.
- */
-{
- JDIMENSION MCU_cols, comp_width, blk_x, blk_y, x_crop_blocks;
- int ci, k, offset_y;
- JBLOCKARRAY buffer;
- JCOEFPTR ptr1, ptr2;
- JCOEF temp1, temp2;
- jpeg_component_info *compptr;
-
- /* Horizontal mirroring of DCT blocks is accomplished by swapping
- * pairs of blocks in-place. Within a DCT block, we perform horizontal
- * mirroring by changing the signs of odd-numbered columns.
- * Partial iMCUs at the right edge are left untouched.
- */
- MCU_cols = srcinfo->output_width /
- (dstinfo->max_h_samp_factor * dstinfo_min_DCT_h_scaled_size);
-
- for (ci = 0; ci < dstinfo->num_components; ci++) {
- compptr = dstinfo->comp_info + ci;
- comp_width = MCU_cols * compptr->h_samp_factor;
- x_crop_blocks = x_crop_offset * compptr->h_samp_factor;
- for (blk_y = 0; blk_y < compptr->height_in_blocks;
- blk_y += compptr->v_samp_factor) {
- buffer = (*srcinfo->mem->access_virt_barray)
- ((j_common_ptr)srcinfo, src_coef_arrays[ci], blk_y,
- (JDIMENSION)compptr->v_samp_factor, TRUE);
- for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) {
- /* Do the mirroring */
- for (blk_x = 0; blk_x * 2 < comp_width; blk_x++) {
- ptr1 = buffer[offset_y][blk_x];
- ptr2 = buffer[offset_y][comp_width - blk_x - 1];
- /* this unrolled loop doesn't need to know which row it's on... */
- for (k = 0; k < DCTSIZE2; k += 2) {
- temp1 = *ptr1; /* swap even column */
- temp2 = *ptr2;
- *ptr1++ = temp2;
- *ptr2++ = temp1;
- temp1 = *ptr1; /* swap odd column with sign change */
- temp2 = *ptr2;
- *ptr1++ = -temp2;
- *ptr2++ = -temp1;
- }
- }
- if (x_crop_blocks > 0) {
- /* Now left-justify the portion of the data to be kept.
- * We can't use a single jcopy_block_row() call because that routine
- * depends on memcpy(), whose behavior is unspecified for overlapping
- * source and destination areas. Sigh.
- */
- for (blk_x = 0; blk_x < compptr->width_in_blocks; blk_x++) {
- jcopy_block_row(buffer[offset_y] + blk_x + x_crop_blocks,
- buffer[offset_y] + blk_x, (JDIMENSION)1);
- }
- }
- }
- }
- }
-}
-
-
-LOCAL(void)
-do_flip_h(j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
- JDIMENSION x_crop_offset, JDIMENSION y_crop_offset,
- jvirt_barray_ptr *src_coef_arrays,
- jvirt_barray_ptr *dst_coef_arrays)
-/* Horizontal flip in general cropping case */
-{
- JDIMENSION MCU_cols, comp_width, dst_blk_x, dst_blk_y;
- JDIMENSION x_crop_blocks, y_crop_blocks;
- int ci, k, offset_y;
- JBLOCKARRAY src_buffer, dst_buffer;
- JBLOCKROW src_row_ptr, dst_row_ptr;
- JCOEFPTR src_ptr, dst_ptr;
- jpeg_component_info *compptr;
-
- /* Here we must output into a separate array because we can't touch
- * different rows of a single virtual array simultaneously. Otherwise,
- * this is essentially the same as the routine above.
- */
- MCU_cols = srcinfo->output_width /
- (dstinfo->max_h_samp_factor * dstinfo_min_DCT_h_scaled_size);
-
- for (ci = 0; ci < dstinfo->num_components; ci++) {
- compptr = dstinfo->comp_info + ci;
- comp_width = MCU_cols * compptr->h_samp_factor;
- x_crop_blocks = x_crop_offset * compptr->h_samp_factor;
- y_crop_blocks = y_crop_offset * compptr->v_samp_factor;
- for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks;
- dst_blk_y += compptr->v_samp_factor) {
- dst_buffer = (*srcinfo->mem->access_virt_barray)
- ((j_common_ptr)srcinfo, dst_coef_arrays[ci], dst_blk_y,
- (JDIMENSION)compptr->v_samp_factor, TRUE);
- src_buffer = (*srcinfo->mem->access_virt_barray)
- ((j_common_ptr)srcinfo, src_coef_arrays[ci], dst_blk_y + y_crop_blocks,
- (JDIMENSION)compptr->v_samp_factor, FALSE);
- for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) {
- dst_row_ptr = dst_buffer[offset_y];
- src_row_ptr = src_buffer[offset_y];
- for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks;
- dst_blk_x++) {
- if (x_crop_blocks + dst_blk_x < comp_width) {
- /* Do the mirrorable blocks */
- dst_ptr = dst_row_ptr[dst_blk_x];
- src_ptr = src_row_ptr[comp_width - x_crop_blocks - dst_blk_x - 1];
- /* this unrolled loop doesn't need to know which row it's on... */
- for (k = 0; k < DCTSIZE2; k += 2) {
- *dst_ptr++ = *src_ptr++; /* copy even column */
- *dst_ptr++ = -(*src_ptr++); /* copy odd column with sign
- change */
- }
- } else {
- /* Copy last partial block(s) verbatim */
- jcopy_block_row(src_row_ptr + dst_blk_x + x_crop_blocks,
- dst_row_ptr + dst_blk_x, (JDIMENSION)1);
- }
- }
- }
- }
- }
-}
-
-
-LOCAL(void)
-do_flip_v(j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
- JDIMENSION x_crop_offset, JDIMENSION y_crop_offset,
- jvirt_barray_ptr *src_coef_arrays,
- jvirt_barray_ptr *dst_coef_arrays)
-/* Vertical flip */
-{
- JDIMENSION MCU_rows, comp_height, dst_blk_x, dst_blk_y;
- JDIMENSION x_crop_blocks, y_crop_blocks;
- int ci, i, j, offset_y;
- JBLOCKARRAY src_buffer, dst_buffer;
- JBLOCKROW src_row_ptr, dst_row_ptr;
- JCOEFPTR src_ptr, dst_ptr;
- jpeg_component_info *compptr;
-
- /* We output into a separate array because we can't touch different
- * rows of the source virtual array simultaneously. Otherwise, this
- * is a pretty straightforward analog of horizontal flip.
- * Within a DCT block, vertical mirroring is done by changing the signs
- * of odd-numbered rows.
- * Partial iMCUs at the bottom edge are copied verbatim.
- */
- MCU_rows = srcinfo->output_height /
- (dstinfo->max_v_samp_factor * dstinfo_min_DCT_v_scaled_size);
-
- for (ci = 0; ci < dstinfo->num_components; ci++) {
- compptr = dstinfo->comp_info + ci;
- comp_height = MCU_rows * compptr->v_samp_factor;
- x_crop_blocks = x_crop_offset * compptr->h_samp_factor;
- y_crop_blocks = y_crop_offset * compptr->v_samp_factor;
- for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks;
- dst_blk_y += compptr->v_samp_factor) {
- dst_buffer = (*srcinfo->mem->access_virt_barray)
- ((j_common_ptr)srcinfo, dst_coef_arrays[ci], dst_blk_y,
- (JDIMENSION)compptr->v_samp_factor, TRUE);
- if (y_crop_blocks + dst_blk_y < comp_height) {
- /* Row is within the mirrorable area. */
- src_buffer = (*srcinfo->mem->access_virt_barray)
- ((j_common_ptr)srcinfo, src_coef_arrays[ci],
- comp_height - y_crop_blocks - dst_blk_y -
- (JDIMENSION)compptr->v_samp_factor,
- (JDIMENSION)compptr->v_samp_factor, FALSE);
- } else {
- /* Bottom-edge blocks will be copied verbatim. */
- src_buffer = (*srcinfo->mem->access_virt_barray)
- ((j_common_ptr)srcinfo, src_coef_arrays[ci],
- dst_blk_y + y_crop_blocks,
- (JDIMENSION)compptr->v_samp_factor, FALSE);
- }
- for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) {
- if (y_crop_blocks + dst_blk_y < comp_height) {
- /* Row is within the mirrorable area. */
- dst_row_ptr = dst_buffer[offset_y];
- src_row_ptr = src_buffer[compptr->v_samp_factor - offset_y - 1];
- src_row_ptr += x_crop_blocks;
- for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks;
- dst_blk_x++) {
- dst_ptr = dst_row_ptr[dst_blk_x];
- src_ptr = src_row_ptr[dst_blk_x];
- for (i = 0; i < DCTSIZE; i += 2) {
- /* copy even row */
- for (j = 0; j < DCTSIZE; j++)
- *dst_ptr++ = *src_ptr++;
- /* copy odd row with sign change */
- for (j = 0; j < DCTSIZE; j++)
- *dst_ptr++ = -(*src_ptr++);
- }
- }
- } else {
- /* Just copy row verbatim. */
- jcopy_block_row(src_buffer[offset_y] + x_crop_blocks,
- dst_buffer[offset_y], compptr->width_in_blocks);
- }
- }
- }
- }
-}
-
-
-LOCAL(void)
-do_transpose(j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
- JDIMENSION x_crop_offset, JDIMENSION y_crop_offset,
- jvirt_barray_ptr *src_coef_arrays,
- jvirt_barray_ptr *dst_coef_arrays)
-/* Transpose source into destination */
-{
- JDIMENSION dst_blk_x, dst_blk_y, x_crop_blocks, y_crop_blocks;
- int ci, i, j, offset_x, offset_y;
- JBLOCKARRAY src_buffer, dst_buffer;
- JCOEFPTR src_ptr, dst_ptr;
- jpeg_component_info *compptr;
-
- /* Transposing pixels within a block just requires transposing the
- * DCT coefficients.
- * Partial iMCUs at the edges require no special treatment; we simply
- * process all the available DCT blocks for every component.
- */
- for (ci = 0; ci < dstinfo->num_components; ci++) {
- compptr = dstinfo->comp_info + ci;
- x_crop_blocks = x_crop_offset * compptr->h_samp_factor;
- y_crop_blocks = y_crop_offset * compptr->v_samp_factor;
- for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks;
- dst_blk_y += compptr->v_samp_factor) {
- dst_buffer = (*srcinfo->mem->access_virt_barray)
- ((j_common_ptr)srcinfo, dst_coef_arrays[ci], dst_blk_y,
- (JDIMENSION)compptr->v_samp_factor, TRUE);
- for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) {
- for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks;
- dst_blk_x += compptr->h_samp_factor) {
- src_buffer = (*srcinfo->mem->access_virt_barray)
- ((j_common_ptr)srcinfo, src_coef_arrays[ci],
- dst_blk_x + x_crop_blocks,
- (JDIMENSION)compptr->h_samp_factor, FALSE);
- for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) {
- dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x];
- src_ptr =
- src_buffer[offset_x][dst_blk_y + offset_y + y_crop_blocks];
- for (i = 0; i < DCTSIZE; i++)
- for (j = 0; j < DCTSIZE; j++)
- dst_ptr[j * DCTSIZE + i] = src_ptr[i * DCTSIZE + j];
- }
- }
- }
- }
- }
-}
-
-
-LOCAL(void)
-do_rot_90(j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
- JDIMENSION x_crop_offset, JDIMENSION y_crop_offset,
- jvirt_barray_ptr *src_coef_arrays,
- jvirt_barray_ptr *dst_coef_arrays)
-/* 90 degree rotation is equivalent to
- * 1. Transposing the image;
- * 2. Horizontal mirroring.
- * These two steps are merged into a single processing routine.
- */
-{
- JDIMENSION MCU_cols, comp_width, dst_blk_x, dst_blk_y;
- JDIMENSION x_crop_blocks, y_crop_blocks;
- int ci, i, j, offset_x, offset_y;
- JBLOCKARRAY src_buffer, dst_buffer;
- JCOEFPTR src_ptr, dst_ptr;
- jpeg_component_info *compptr;
-
- /* Because of the horizontal mirror step, we can't process partial iMCUs
- * at the (output) right edge properly. They just get transposed and
- * not mirrored.
- */
- MCU_cols = srcinfo->output_height /
- (dstinfo->max_h_samp_factor * dstinfo_min_DCT_h_scaled_size);
-
- for (ci = 0; ci < dstinfo->num_components; ci++) {
- compptr = dstinfo->comp_info + ci;
- comp_width = MCU_cols * compptr->h_samp_factor;
- x_crop_blocks = x_crop_offset * compptr->h_samp_factor;
- y_crop_blocks = y_crop_offset * compptr->v_samp_factor;
- for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks;
- dst_blk_y += compptr->v_samp_factor) {
- dst_buffer = (*srcinfo->mem->access_virt_barray)
- ((j_common_ptr)srcinfo, dst_coef_arrays[ci], dst_blk_y,
- (JDIMENSION)compptr->v_samp_factor, TRUE);
- for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) {
- for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks;
- dst_blk_x += compptr->h_samp_factor) {
- if (x_crop_blocks + dst_blk_x < comp_width) {
- /* Block is within the mirrorable area. */
- src_buffer = (*srcinfo->mem->access_virt_barray)
- ((j_common_ptr)srcinfo, src_coef_arrays[ci],
- comp_width - x_crop_blocks - dst_blk_x -
- (JDIMENSION)compptr->h_samp_factor,
- (JDIMENSION)compptr->h_samp_factor, FALSE);
- } else {
- /* Edge blocks are transposed but not mirrored. */
- src_buffer = (*srcinfo->mem->access_virt_barray)
- ((j_common_ptr)srcinfo, src_coef_arrays[ci],
- dst_blk_x + x_crop_blocks,
- (JDIMENSION)compptr->h_samp_factor, FALSE);
- }
- for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) {
- dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x];
- if (x_crop_blocks + dst_blk_x < comp_width) {
- /* Block is within the mirrorable area. */
- src_ptr = src_buffer[compptr->h_samp_factor - offset_x - 1]
- [dst_blk_y + offset_y + y_crop_blocks];
- for (i = 0; i < DCTSIZE; i++) {
- for (j = 0; j < DCTSIZE; j++)
- dst_ptr[j * DCTSIZE + i] = src_ptr[i * DCTSIZE + j];
- i++;
- for (j = 0; j < DCTSIZE; j++)
- dst_ptr[j * DCTSIZE + i] = -src_ptr[i * DCTSIZE + j];
- }
- } else {
- /* Edge blocks are transposed but not mirrored. */
- src_ptr = src_buffer[offset_x]
- [dst_blk_y + offset_y + y_crop_blocks];
- for (i = 0; i < DCTSIZE; i++)
- for (j = 0; j < DCTSIZE; j++)
- dst_ptr[j * DCTSIZE + i] = src_ptr[i * DCTSIZE + j];
- }
- }
- }
- }
- }
- }
-}
-
-
-LOCAL(void)
-do_rot_270(j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
- JDIMENSION x_crop_offset, JDIMENSION y_crop_offset,
- jvirt_barray_ptr *src_coef_arrays,
- jvirt_barray_ptr *dst_coef_arrays)
-/* 270 degree rotation is equivalent to
- * 1. Horizontal mirroring;
- * 2. Transposing the image.
- * These two steps are merged into a single processing routine.
- */
-{
- JDIMENSION MCU_rows, comp_height, dst_blk_x, dst_blk_y;
- JDIMENSION x_crop_blocks, y_crop_blocks;
- int ci, i, j, offset_x, offset_y;
- JBLOCKARRAY src_buffer, dst_buffer;
- JCOEFPTR src_ptr, dst_ptr;
- jpeg_component_info *compptr;
-
- /* Because of the horizontal mirror step, we can't process partial iMCUs
- * at the (output) bottom edge properly. They just get transposed and
- * not mirrored.
- */
- MCU_rows = srcinfo->output_width /
- (dstinfo->max_v_samp_factor * dstinfo_min_DCT_v_scaled_size);
-
- for (ci = 0; ci < dstinfo->num_components; ci++) {
- compptr = dstinfo->comp_info + ci;
- comp_height = MCU_rows * compptr->v_samp_factor;
- x_crop_blocks = x_crop_offset * compptr->h_samp_factor;
- y_crop_blocks = y_crop_offset * compptr->v_samp_factor;
- for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks;
- dst_blk_y += compptr->v_samp_factor) {
- dst_buffer = (*srcinfo->mem->access_virt_barray)
- ((j_common_ptr)srcinfo, dst_coef_arrays[ci], dst_blk_y,
- (JDIMENSION)compptr->v_samp_factor, TRUE);
- for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) {
- for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks;
- dst_blk_x += compptr->h_samp_factor) {
- src_buffer = (*srcinfo->mem->access_virt_barray)
- ((j_common_ptr)srcinfo, src_coef_arrays[ci],
- dst_blk_x + x_crop_blocks,
- (JDIMENSION)compptr->h_samp_factor, FALSE);
- for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) {
- dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x];
- if (y_crop_blocks + dst_blk_y < comp_height) {
- /* Block is within the mirrorable area. */
- src_ptr = src_buffer[offset_x]
- [comp_height - y_crop_blocks - dst_blk_y - offset_y - 1];
- for (i = 0; i < DCTSIZE; i++) {
- for (j = 0; j < DCTSIZE; j++) {
- dst_ptr[j * DCTSIZE + i] = src_ptr[i * DCTSIZE + j];
- j++;
- dst_ptr[j * DCTSIZE + i] = -src_ptr[i * DCTSIZE + j];
- }
- }
- } else {
- /* Edge blocks are transposed but not mirrored. */
- src_ptr = src_buffer[offset_x]
- [dst_blk_y + offset_y + y_crop_blocks];
- for (i = 0; i < DCTSIZE; i++)
- for (j = 0; j < DCTSIZE; j++)
- dst_ptr[j * DCTSIZE + i] = src_ptr[i * DCTSIZE + j];
- }
- }
- }
- }
- }
- }
-}
-
-
-LOCAL(void)
-do_rot_180(j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
- JDIMENSION x_crop_offset, JDIMENSION y_crop_offset,
- jvirt_barray_ptr *src_coef_arrays,
- jvirt_barray_ptr *dst_coef_arrays)
-/* 180 degree rotation is equivalent to
- * 1. Vertical mirroring;
- * 2. Horizontal mirroring.
- * These two steps are merged into a single processing routine.
- */
-{
- JDIMENSION MCU_cols, MCU_rows, comp_width, comp_height, dst_blk_x, dst_blk_y;
- JDIMENSION x_crop_blocks, y_crop_blocks;
- int ci, i, j, offset_y;
- JBLOCKARRAY src_buffer, dst_buffer;
- JBLOCKROW src_row_ptr, dst_row_ptr;
- JCOEFPTR src_ptr, dst_ptr;
- jpeg_component_info *compptr;
-
- MCU_cols = srcinfo->output_width /
- (dstinfo->max_h_samp_factor * dstinfo_min_DCT_h_scaled_size);
- MCU_rows = srcinfo->output_height /
- (dstinfo->max_v_samp_factor * dstinfo_min_DCT_v_scaled_size);
-
- for (ci = 0; ci < dstinfo->num_components; ci++) {
- compptr = dstinfo->comp_info + ci;
- comp_width = MCU_cols * compptr->h_samp_factor;
- comp_height = MCU_rows * compptr->v_samp_factor;
- x_crop_blocks = x_crop_offset * compptr->h_samp_factor;
- y_crop_blocks = y_crop_offset * compptr->v_samp_factor;
- for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks;
- dst_blk_y += compptr->v_samp_factor) {
- dst_buffer = (*srcinfo->mem->access_virt_barray)
- ((j_common_ptr)srcinfo, dst_coef_arrays[ci], dst_blk_y,
- (JDIMENSION)compptr->v_samp_factor, TRUE);
- if (y_crop_blocks + dst_blk_y < comp_height) {
- /* Row is within the vertically mirrorable area. */
- src_buffer = (*srcinfo->mem->access_virt_barray)
- ((j_common_ptr)srcinfo, src_coef_arrays[ci],
- comp_height - y_crop_blocks - dst_blk_y -
- (JDIMENSION)compptr->v_samp_factor,
- (JDIMENSION)compptr->v_samp_factor, FALSE);
- } else {
- /* Bottom-edge rows are only mirrored horizontally. */
- src_buffer = (*srcinfo->mem->access_virt_barray)
- ((j_common_ptr)srcinfo, src_coef_arrays[ci],
- dst_blk_y + y_crop_blocks,
- (JDIMENSION)compptr->v_samp_factor, FALSE);
- }
- for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) {
- dst_row_ptr = dst_buffer[offset_y];
- if (y_crop_blocks + dst_blk_y < comp_height) {
- /* Row is within the mirrorable area. */
- src_row_ptr = src_buffer[compptr->v_samp_factor - offset_y - 1];
- for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks;
- dst_blk_x++) {
- dst_ptr = dst_row_ptr[dst_blk_x];
- if (x_crop_blocks + dst_blk_x < comp_width) {
- /* Process the blocks that can be mirrored both ways. */
- src_ptr =
- src_row_ptr[comp_width - x_crop_blocks - dst_blk_x - 1];
- for (i = 0; i < DCTSIZE; i += 2) {
- /* For even row, negate every odd column. */
- for (j = 0; j < DCTSIZE; j += 2) {
- *dst_ptr++ = *src_ptr++;
- *dst_ptr++ = -(*src_ptr++);
- }
- /* For odd row, negate every even column. */
- for (j = 0; j < DCTSIZE; j += 2) {
- *dst_ptr++ = -(*src_ptr++);
- *dst_ptr++ = *src_ptr++;
- }
- }
- } else {
- /* Any remaining right-edge blocks are only mirrored vertically. */
- src_ptr = src_row_ptr[x_crop_blocks + dst_blk_x];
- for (i = 0; i < DCTSIZE; i += 2) {
- for (j = 0; j < DCTSIZE; j++)
- *dst_ptr++ = *src_ptr++;
- for (j = 0; j < DCTSIZE; j++)
- *dst_ptr++ = -(*src_ptr++);
- }
- }
- }
- } else {
- /* Remaining rows are just mirrored horizontally. */
- src_row_ptr = src_buffer[offset_y];
- for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks;
- dst_blk_x++) {
- if (x_crop_blocks + dst_blk_x < comp_width) {
- /* Process the blocks that can be mirrored. */
- dst_ptr = dst_row_ptr[dst_blk_x];
- src_ptr =
- src_row_ptr[comp_width - x_crop_blocks - dst_blk_x - 1];
- for (i = 0; i < DCTSIZE2; i += 2) {
- *dst_ptr++ = *src_ptr++;
- *dst_ptr++ = -(*src_ptr++);
- }
- } else {
- /* Any remaining right-edge blocks are only copied. */
- jcopy_block_row(src_row_ptr + dst_blk_x + x_crop_blocks,
- dst_row_ptr + dst_blk_x, (JDIMENSION)1);
- }
- }
- }
- }
- }
- }
-}
-
-
-LOCAL(void)
-do_transverse(j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
- JDIMENSION x_crop_offset, JDIMENSION y_crop_offset,
- jvirt_barray_ptr *src_coef_arrays,
- jvirt_barray_ptr *dst_coef_arrays)
-/* Transverse transpose is equivalent to
- * 1. 180 degree rotation;
- * 2. Transposition;
- * or
- * 1. Horizontal mirroring;
- * 2. Transposition;
- * 3. Horizontal mirroring.
- * These steps are merged into a single processing routine.
- */
-{
- JDIMENSION MCU_cols, MCU_rows, comp_width, comp_height, dst_blk_x, dst_blk_y;
- JDIMENSION x_crop_blocks, y_crop_blocks;
- int ci, i, j, offset_x, offset_y;
- JBLOCKARRAY src_buffer, dst_buffer;
- JCOEFPTR src_ptr, dst_ptr;
- jpeg_component_info *compptr;
-
- MCU_cols = srcinfo->output_height /
- (dstinfo->max_h_samp_factor * dstinfo_min_DCT_h_scaled_size);
- MCU_rows = srcinfo->output_width /
- (dstinfo->max_v_samp_factor * dstinfo_min_DCT_v_scaled_size);
-
- for (ci = 0; ci < dstinfo->num_components; ci++) {
- compptr = dstinfo->comp_info + ci;
- comp_width = MCU_cols * compptr->h_samp_factor;
- comp_height = MCU_rows * compptr->v_samp_factor;
- x_crop_blocks = x_crop_offset * compptr->h_samp_factor;
- y_crop_blocks = y_crop_offset * compptr->v_samp_factor;
- for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks;
- dst_blk_y += compptr->v_samp_factor) {
- dst_buffer = (*srcinfo->mem->access_virt_barray)
- ((j_common_ptr)srcinfo, dst_coef_arrays[ci], dst_blk_y,
- (JDIMENSION)compptr->v_samp_factor, TRUE);
- for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) {
- for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks;
- dst_blk_x += compptr->h_samp_factor) {
- if (x_crop_blocks + dst_blk_x < comp_width) {
- /* Block is within the mirrorable area. */
- src_buffer = (*srcinfo->mem->access_virt_barray)
- ((j_common_ptr)srcinfo, src_coef_arrays[ci],
- comp_width - x_crop_blocks - dst_blk_x -
- (JDIMENSION)compptr->h_samp_factor,
- (JDIMENSION)compptr->h_samp_factor, FALSE);
- } else {
- src_buffer = (*srcinfo->mem->access_virt_barray)
- ((j_common_ptr)srcinfo, src_coef_arrays[ci],
- dst_blk_x + x_crop_blocks,
- (JDIMENSION)compptr->h_samp_factor, FALSE);
- }
- for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) {
- dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x];
- if (y_crop_blocks + dst_blk_y < comp_height) {
- if (x_crop_blocks + dst_blk_x < comp_width) {
- /* Block is within the mirrorable area. */
- src_ptr = src_buffer[compptr->h_samp_factor - offset_x - 1]
- [comp_height - y_crop_blocks - dst_blk_y - offset_y - 1];
- for (i = 0; i < DCTSIZE; i++) {
- for (j = 0; j < DCTSIZE; j++) {
- dst_ptr[j * DCTSIZE + i] = src_ptr[i * DCTSIZE + j];
- j++;
- dst_ptr[j * DCTSIZE + i] = -src_ptr[i * DCTSIZE + j];
- }
- i++;
- for (j = 0; j < DCTSIZE; j++) {
- dst_ptr[j * DCTSIZE + i] = -src_ptr[i * DCTSIZE + j];
- j++;
- dst_ptr[j * DCTSIZE + i] = src_ptr[i * DCTSIZE + j];
- }
- }
- } else {
- /* Right-edge blocks are mirrored in y only */
- src_ptr = src_buffer[offset_x]
- [comp_height - y_crop_blocks - dst_blk_y - offset_y - 1];
- for (i = 0; i < DCTSIZE; i++) {
- for (j = 0; j < DCTSIZE; j++) {
- dst_ptr[j * DCTSIZE + i] = src_ptr[i * DCTSIZE + j];
- j++;
- dst_ptr[j * DCTSIZE + i] = -src_ptr[i * DCTSIZE + j];
- }
- }
- }
- } else {
- if (x_crop_blocks + dst_blk_x < comp_width) {
- /* Bottom-edge blocks are mirrored in x only */
- src_ptr = src_buffer[compptr->h_samp_factor - offset_x - 1]
- [dst_blk_y + offset_y + y_crop_blocks];
- for (i = 0; i < DCTSIZE; i++) {
- for (j = 0; j < DCTSIZE; j++)
- dst_ptr[j * DCTSIZE + i] = src_ptr[i * DCTSIZE + j];
- i++;
- for (j = 0; j < DCTSIZE; j++)
- dst_ptr[j * DCTSIZE + i] = -src_ptr[i * DCTSIZE + j];
- }
- } else {
- /* At lower right corner, just transpose, no mirroring */
- src_ptr = src_buffer[offset_x]
- [dst_blk_y + offset_y + y_crop_blocks];
- for (i = 0; i < DCTSIZE; i++)
- for (j = 0; j < DCTSIZE; j++)
- dst_ptr[j * DCTSIZE + i] = src_ptr[i * DCTSIZE + j];
- }
- }
- }
- }
- }
- }
- }
-}
-
-
-/* Parse an unsigned integer: subroutine for jtransform_parse_crop_spec.
- * Returns TRUE if valid integer found, FALSE if not.
- * *strptr is advanced over the digit string, and *result is set to its value.
- */
-
-LOCAL(boolean)
-jt_read_integer(const char **strptr, JDIMENSION *result)
-{
- const char *ptr = *strptr;
- JDIMENSION val = 0;
-
- for (; isdigit(*ptr); ptr++) {
- val = val * 10 + (JDIMENSION)(*ptr - '0');
- }
- *result = val;
- if (ptr == *strptr)
- return FALSE; /* oops, no digits */
- *strptr = ptr;
- return TRUE;
-}
-
-
-/* Parse a crop specification (written in X11 geometry style).
- * The routine returns TRUE if the spec string is valid, FALSE if not.
- *
- * The crop spec string should have the format
- * <width>[{fr}]x<height>[{fr}]{+-}<xoffset>{+-}<yoffset>
- * where width, height, xoffset, and yoffset are unsigned integers.
- * Each of the elements can be omitted to indicate a default value.
- * (A weakness of this style is that it is not possible to omit xoffset
- * while specifying yoffset, since they look alike.)
- *
- * This code is loosely based on XParseGeometry from the X11 distribution.
- */
-
-GLOBAL(boolean)
-jtransform_parse_crop_spec(jpeg_transform_info *info, const char *spec)
-{
- info->crop = FALSE;
- info->crop_width_set = JCROP_UNSET;
- info->crop_height_set = JCROP_UNSET;
- info->crop_xoffset_set = JCROP_UNSET;
- info->crop_yoffset_set = JCROP_UNSET;
-
- if (isdigit(*spec)) {
- /* fetch width */
- if (!jt_read_integer(&spec, &info->crop_width))
- return FALSE;
- if (*spec == 'f' || *spec == 'F') {
- spec++;
- info->crop_width_set = JCROP_FORCE;
- } else if (*spec == 'r' || *spec == 'R') {
- spec++;
- info->crop_width_set = JCROP_REFLECT;
- } else
- info->crop_width_set = JCROP_POS;
- }
- if (*spec == 'x' || *spec == 'X') {
- /* fetch height */
- spec++;
- if (!jt_read_integer(&spec, &info->crop_height))
- return FALSE;
- if (*spec == 'f' || *spec == 'F') {
- spec++;
- info->crop_height_set = JCROP_FORCE;
- } else if (*spec == 'r' || *spec == 'R') {
- spec++;
- info->crop_height_set = JCROP_REFLECT;
- } else
- info->crop_height_set = JCROP_POS;
- }
- if (*spec == '+' || *spec == '-') {
- /* fetch xoffset */
- info->crop_xoffset_set = (*spec == '-') ? JCROP_NEG : JCROP_POS;
- spec++;
- if (!jt_read_integer(&spec, &info->crop_xoffset))
- return FALSE;
- }
- if (*spec == '+' || *spec == '-') {
- /* fetch yoffset */
- info->crop_yoffset_set = (*spec == '-') ? JCROP_NEG : JCROP_POS;
- spec++;
- if (!jt_read_integer(&spec, &info->crop_yoffset))
- return FALSE;
- }
- /* We had better have gotten to the end of the string. */
- if (*spec != '\0')
- return FALSE;
- info->crop = TRUE;
- return TRUE;
-}
-
-
-/* Trim off any partial iMCUs on the indicated destination edge */
-
-LOCAL(void)
-trim_right_edge(jpeg_transform_info *info, JDIMENSION full_width)
-{
- JDIMENSION MCU_cols;
-
- MCU_cols = info->output_width / info->iMCU_sample_width;
- if (MCU_cols > 0 && info->x_crop_offset + MCU_cols ==
- full_width / info->iMCU_sample_width)
- info->output_width = MCU_cols * info->iMCU_sample_width;
-}
-
-LOCAL(void)
-trim_bottom_edge(jpeg_transform_info *info, JDIMENSION full_height)
-{
- JDIMENSION MCU_rows;
-
- MCU_rows = info->output_height / info->iMCU_sample_height;
- if (MCU_rows > 0 && info->y_crop_offset + MCU_rows ==
- full_height / info->iMCU_sample_height)
- info->output_height = MCU_rows * info->iMCU_sample_height;
-}
-
-
-/* Request any required workspace.
- *
- * This routine figures out the size that the output image will be
- * (which implies that all the transform parameters must be set before
- * it is called).
- *
- * We allocate the workspace virtual arrays from the source decompression
- * object, so that all the arrays (both the original data and the workspace)
- * will be taken into account while making memory management decisions.
- * Hence, this routine must be called after jpeg_read_header (which reads
- * the image dimensions) and before jpeg_read_coefficients (which realizes
- * the source's virtual arrays).
- *
- * This function returns FALSE right away if -perfect is given
- * and transformation is not perfect. Otherwise returns TRUE.
- */
-
-GLOBAL(boolean)
-jtransform_request_workspace(j_decompress_ptr srcinfo,
- jpeg_transform_info *info)
-{
- jvirt_barray_ptr *coef_arrays;
- boolean need_workspace, transpose_it;
- jpeg_component_info *compptr;
- JDIMENSION xoffset, yoffset, dtemp;
- JDIMENSION width_in_iMCUs, height_in_iMCUs;
- JDIMENSION width_in_blocks, height_in_blocks;
- int itemp, ci, h_samp_factor, v_samp_factor;
-
- /* Determine number of components in output image */
- if (info->force_grayscale &&
- srcinfo->jpeg_color_space == JCS_YCbCr &&
- srcinfo->num_components == 3)
- /* We'll only process the first component */
- info->num_components = 1;
- else
- /* Process all the components */
- info->num_components = srcinfo->num_components;
-
- /* Compute output image dimensions and related values. */
-#if JPEG_LIB_VERSION >= 80
- jpeg_core_output_dimensions(srcinfo);
-#else
- srcinfo->output_width = srcinfo->image_width;
- srcinfo->output_height = srcinfo->image_height;
-#endif
-
- /* Return right away if -perfect is given and transformation is not perfect.
- */
- if (info->perfect) {
- if (info->num_components == 1) {
- if (!jtransform_perfect_transform(srcinfo->output_width,
- srcinfo->output_height,
- srcinfo->_min_DCT_h_scaled_size,
- srcinfo->_min_DCT_v_scaled_size,
- info->transform))
- return FALSE;
- } else {
- if (!jtransform_perfect_transform(srcinfo->output_width,
- srcinfo->output_height,
- srcinfo->max_h_samp_factor * srcinfo->_min_DCT_h_scaled_size,
- srcinfo->max_v_samp_factor * srcinfo->_min_DCT_v_scaled_size,
- info->transform))
- return FALSE;
- }
- }
-
- /* If there is only one output component, force the iMCU size to be 1;
- * else use the source iMCU size. (This allows us to do the right thing
- * when reducing color to grayscale, and also provides a handy way of
- * cleaning up "funny" grayscale images whose sampling factors are not 1x1.)
- */
- switch (info->transform) {
- case JXFORM_TRANSPOSE:
- case JXFORM_TRANSVERSE:
- case JXFORM_ROT_90:
- case JXFORM_ROT_270:
- info->output_width = srcinfo->output_height;
- info->output_height = srcinfo->output_width;
- if (info->num_components == 1) {
- info->iMCU_sample_width = srcinfo->_min_DCT_v_scaled_size;
- info->iMCU_sample_height = srcinfo->_min_DCT_h_scaled_size;
- } else {
- info->iMCU_sample_width =
- srcinfo->max_v_samp_factor * srcinfo->_min_DCT_v_scaled_size;
- info->iMCU_sample_height =
- srcinfo->max_h_samp_factor * srcinfo->_min_DCT_h_scaled_size;
- }
- break;
- default:
- info->output_width = srcinfo->output_width;
- info->output_height = srcinfo->output_height;
- if (info->num_components == 1) {
- info->iMCU_sample_width = srcinfo->_min_DCT_h_scaled_size;
- info->iMCU_sample_height = srcinfo->_min_DCT_v_scaled_size;
- } else {
- info->iMCU_sample_width =
- srcinfo->max_h_samp_factor * srcinfo->_min_DCT_h_scaled_size;
- info->iMCU_sample_height =
- srcinfo->max_v_samp_factor * srcinfo->_min_DCT_v_scaled_size;
- }
- break;
- }
-
- /* If cropping has been requested, compute the crop area's position and
- * dimensions, ensuring that its upper left corner falls at an iMCU boundary.
- */
- if (info->crop) {
- /* Insert default values for unset crop parameters */
- if (info->crop_xoffset_set == JCROP_UNSET)
- info->crop_xoffset = 0; /* default to +0 */
- if (info->crop_yoffset_set == JCROP_UNSET)
- info->crop_yoffset = 0; /* default to +0 */
- if (info->crop_width_set == JCROP_UNSET) {
- if (info->crop_xoffset >= info->output_width)
- ERREXIT(srcinfo, JERR_BAD_CROP_SPEC);
- info->crop_width = info->output_width - info->crop_xoffset;
- } else {
- /* Check for crop extension */
- if (info->crop_width > info->output_width) {
- /* Crop extension does not work when transforming! */
- if (info->transform != JXFORM_NONE ||
- info->crop_xoffset >= info->crop_width ||
- info->crop_xoffset > info->crop_width - info->output_width)
- ERREXIT(srcinfo, JERR_BAD_CROP_SPEC);
- } else {
- if (info->crop_xoffset >= info->output_width ||
- info->crop_width <= 0 ||
- info->crop_xoffset > info->output_width - info->crop_width)
- ERREXIT(srcinfo, JERR_BAD_CROP_SPEC);
- }
- }
- if (info->crop_height_set == JCROP_UNSET) {
- if (info->crop_yoffset >= info->output_height)
- ERREXIT(srcinfo, JERR_BAD_CROP_SPEC);
- info->crop_height = info->output_height - info->crop_yoffset;
- } else {
- /* Check for crop extension */
- if (info->crop_height > info->output_height) {
- /* Crop extension does not work when transforming! */
- if (info->transform != JXFORM_NONE ||
- info->crop_yoffset >= info->crop_height ||
- info->crop_yoffset > info->crop_height - info->output_height)
- ERREXIT(srcinfo, JERR_BAD_CROP_SPEC);
- } else {
- if (info->crop_yoffset >= info->output_height ||
- info->crop_height <= 0 ||
- info->crop_yoffset > info->output_height - info->crop_height)
- ERREXIT(srcinfo, JERR_BAD_CROP_SPEC);
- }
- }
- /* Convert negative crop offsets into regular offsets */
- if (info->crop_xoffset_set != JCROP_NEG)
- xoffset = info->crop_xoffset;
- else if (info->crop_width > info->output_width) /* crop extension */
- xoffset = info->crop_width - info->output_width - info->crop_xoffset;
- else
- xoffset = info->output_width - info->crop_width - info->crop_xoffset;
- if (info->crop_yoffset_set != JCROP_NEG)
- yoffset = info->crop_yoffset;
- else if (info->crop_height > info->output_height) /* crop extension */
- yoffset = info->crop_height - info->output_height - info->crop_yoffset;
- else
- yoffset = info->output_height - info->crop_height - info->crop_yoffset;
- /* Now adjust so that upper left corner falls at an iMCU boundary */
- switch (info->transform) {
- case JXFORM_DROP:
- /* Ensure the effective drop region will not exceed the requested */
- itemp = info->iMCU_sample_width;
- dtemp = itemp - 1 - ((xoffset + itemp - 1) % itemp);
- xoffset += dtemp;
- if (info->crop_width <= dtemp)
- info->drop_width = 0;
- else if (xoffset + info->crop_width - dtemp == info->output_width)
- /* Matching right edge: include partial iMCU */
- info->drop_width = (info->crop_width - dtemp + itemp - 1) / itemp;
- else
- info->drop_width = (info->crop_width - dtemp) / itemp;
- itemp = info->iMCU_sample_height;
- dtemp = itemp - 1 - ((yoffset + itemp - 1) % itemp);
- yoffset += dtemp;
- if (info->crop_height <= dtemp)
- info->drop_height = 0;
- else if (yoffset + info->crop_height - dtemp == info->output_height)
- /* Matching bottom edge: include partial iMCU */
- info->drop_height = (info->crop_height - dtemp + itemp - 1) / itemp;
- else
- info->drop_height = (info->crop_height - dtemp) / itemp;
- /* Check if sampling factors match for dropping */
- if (info->drop_width != 0 && info->drop_height != 0)
- for (ci = 0; ci < info->num_components &&
- ci < info->drop_ptr->num_components; ci++) {
- if (info->drop_ptr->comp_info[ci].h_samp_factor *
- srcinfo->max_h_samp_factor !=
- srcinfo->comp_info[ci].h_samp_factor *
- info->drop_ptr->max_h_samp_factor)
- ERREXIT6(srcinfo, JERR_BAD_DROP_SAMPLING, ci,
- info->drop_ptr->comp_info[ci].h_samp_factor,
- info->drop_ptr->max_h_samp_factor,
- srcinfo->comp_info[ci].h_samp_factor,
- srcinfo->max_h_samp_factor, 'h');
- if (info->drop_ptr->comp_info[ci].v_samp_factor *
- srcinfo->max_v_samp_factor !=
- srcinfo->comp_info[ci].v_samp_factor *
- info->drop_ptr->max_v_samp_factor)
- ERREXIT6(srcinfo, JERR_BAD_DROP_SAMPLING, ci,
- info->drop_ptr->comp_info[ci].v_samp_factor,
- info->drop_ptr->max_v_samp_factor,
- srcinfo->comp_info[ci].v_samp_factor,
- srcinfo->max_v_samp_factor, 'v');
- }
- break;
- case JXFORM_WIPE:
- /* Ensure the effective wipe region will cover the requested */
- info->drop_width = (JDIMENSION)jdiv_round_up
- ((long)(info->crop_width + (xoffset % info->iMCU_sample_width)),
- (long)info->iMCU_sample_width);
- info->drop_height = (JDIMENSION)jdiv_round_up
- ((long)(info->crop_height + (yoffset % info->iMCU_sample_height)),
- (long)info->iMCU_sample_height);
- break;
- default:
- /* Ensure the effective crop region will cover the requested */
- if (info->crop_width_set == JCROP_FORCE ||
- info->crop_width > info->output_width)
- info->output_width = info->crop_width;
- else
- info->output_width =
- info->crop_width + (xoffset % info->iMCU_sample_width);
- if (info->crop_height_set == JCROP_FORCE ||
- info->crop_height > info->output_height)
- info->output_height = info->crop_height;
- else
- info->output_height =
- info->crop_height + (yoffset % info->iMCU_sample_height);
- }
- /* Save x/y offsets measured in iMCUs */
- info->x_crop_offset = xoffset / info->iMCU_sample_width;
- info->y_crop_offset = yoffset / info->iMCU_sample_height;
- } else {
- info->x_crop_offset = 0;
- info->y_crop_offset = 0;
- }
-
- /* Figure out whether we need workspace arrays,
- * and if so whether they are transposed relative to the source.
- */
- need_workspace = FALSE;
- transpose_it = FALSE;
- switch (info->transform) {
- case JXFORM_NONE:
- if (info->x_crop_offset != 0 || info->y_crop_offset != 0 ||
- info->output_width > srcinfo->output_width ||
- info->output_height > srcinfo->output_height)
- need_workspace = TRUE;
- /* No workspace needed if neither cropping nor transforming */
- break;
- case JXFORM_FLIP_H:
- if (info->trim)
- trim_right_edge(info, srcinfo->output_width);
- if (info->y_crop_offset != 0 || info->slow_hflip)
- need_workspace = TRUE;
- /* do_flip_h_no_crop doesn't need a workspace array */
- break;
- case JXFORM_FLIP_V:
- if (info->trim)
- trim_bottom_edge(info, srcinfo->output_height);
- /* Need workspace arrays having same dimensions as source image. */
- need_workspace = TRUE;
- break;
- case JXFORM_TRANSPOSE:
- /* transpose does NOT have to trim anything */
- /* Need workspace arrays having transposed dimensions. */
- need_workspace = TRUE;
- transpose_it = TRUE;
- break;
- case JXFORM_TRANSVERSE:
- if (info->trim) {
- trim_right_edge(info, srcinfo->output_height);
- trim_bottom_edge(info, srcinfo->output_width);
- }
- /* Need workspace arrays having transposed dimensions. */
- need_workspace = TRUE;
- transpose_it = TRUE;
- break;
- case JXFORM_ROT_90:
- if (info->trim)
- trim_right_edge(info, srcinfo->output_height);
- /* Need workspace arrays having transposed dimensions. */
- need_workspace = TRUE;
- transpose_it = TRUE;
- break;
- case JXFORM_ROT_180:
- if (info->trim) {
- trim_right_edge(info, srcinfo->output_width);
- trim_bottom_edge(info, srcinfo->output_height);
- }
- /* Need workspace arrays having same dimensions as source image. */
- need_workspace = TRUE;
- break;
- case JXFORM_ROT_270:
- if (info->trim)
- trim_bottom_edge(info, srcinfo->output_width);
- /* Need workspace arrays having transposed dimensions. */
- need_workspace = TRUE;
- transpose_it = TRUE;
- break;
- case JXFORM_WIPE:
- break;
- case JXFORM_DROP:
- break;
- }
-
- /* Allocate workspace if needed.
- * Note that we allocate arrays padded out to the next iMCU boundary,
- * so that transform routines need not worry about missing edge blocks.
- */
- if (need_workspace) {
- coef_arrays = (jvirt_barray_ptr *)
- (*srcinfo->mem->alloc_small) ((j_common_ptr)srcinfo, JPOOL_IMAGE,
- sizeof(jvirt_barray_ptr) * info->num_components);
- width_in_iMCUs = (JDIMENSION)
- jdiv_round_up((long)info->output_width, (long)info->iMCU_sample_width);
- height_in_iMCUs = (JDIMENSION)
- jdiv_round_up((long)info->output_height, (long)info->iMCU_sample_height);
- for (ci = 0; ci < info->num_components; ci++) {
- compptr = srcinfo->comp_info + ci;
- if (info->num_components == 1) {
- /* we're going to force samp factors to 1x1 in this case */
- h_samp_factor = v_samp_factor = 1;
- } else if (transpose_it) {
- h_samp_factor = compptr->v_samp_factor;
- v_samp_factor = compptr->h_samp_factor;
- } else {
- h_samp_factor = compptr->h_samp_factor;
- v_samp_factor = compptr->v_samp_factor;
- }
- width_in_blocks = width_in_iMCUs * h_samp_factor;
- height_in_blocks = height_in_iMCUs * v_samp_factor;
- coef_arrays[ci] = (*srcinfo->mem->request_virt_barray)
- ((j_common_ptr)srcinfo, JPOOL_IMAGE, FALSE,
- width_in_blocks, height_in_blocks, (JDIMENSION)v_samp_factor);
- }
- info->workspace_coef_arrays = coef_arrays;
- } else
- info->workspace_coef_arrays = NULL;
-
- return TRUE;
-}
-
-
-/* Transpose destination image parameters */
-
-LOCAL(void)
-transpose_critical_parameters(j_compress_ptr dstinfo)
-{
- int tblno, i, j, ci, itemp;
- jpeg_component_info *compptr;
- JQUANT_TBL *qtblptr;
- JDIMENSION jtemp;
- UINT16 qtemp;
-
- /* Transpose image dimensions */
- jtemp = dstinfo->image_width;
- dstinfo->image_width = dstinfo->image_height;
- dstinfo->image_height = jtemp;
-#if JPEG_LIB_VERSION >= 70
- itemp = dstinfo->min_DCT_h_scaled_size;
- dstinfo->min_DCT_h_scaled_size = dstinfo->min_DCT_v_scaled_size;
- dstinfo->min_DCT_v_scaled_size = itemp;
-#endif
-
- /* Transpose sampling factors */
- for (ci = 0; ci < dstinfo->num_components; ci++) {
- compptr = dstinfo->comp_info + ci;
- itemp = compptr->h_samp_factor;
- compptr->h_samp_factor = compptr->v_samp_factor;
- compptr->v_samp_factor = itemp;
- }
-
- /* Transpose quantization tables */
- for (tblno = 0; tblno < NUM_QUANT_TBLS; tblno++) {
- qtblptr = dstinfo->quant_tbl_ptrs[tblno];
- if (qtblptr != NULL) {
- for (i = 0; i < DCTSIZE; i++) {
- for (j = 0; j < i; j++) {
- qtemp = qtblptr->quantval[i * DCTSIZE + j];
- qtblptr->quantval[i * DCTSIZE + j] =
- qtblptr->quantval[j * DCTSIZE + i];
- qtblptr->quantval[j * DCTSIZE + i] = qtemp;
- }
- }
- }
- }
-}
-
-
-/* Adjust Exif image parameters.
- *
- * We try to adjust the Tags ExifImageWidth and ExifImageHeight if possible.
- */
-
-LOCAL(void)
-adjust_exif_parameters(JOCTET *data, unsigned int length, JDIMENSION new_width,
- JDIMENSION new_height)
-{
- boolean is_motorola; /* Flag for byte order */
- unsigned int number_of_tags, tagnum;
- unsigned int firstoffset, offset;
- JDIMENSION new_value;
-
- if (length < 12) return; /* Length of an IFD entry */
-
- /* Discover byte order */
- if (data[0] == 0x49 && data[1] == 0x49)
- is_motorola = FALSE;
- else if (data[0] == 0x4D && data[1] == 0x4D)
- is_motorola = TRUE;
- else
- return;
-
- /* Check Tag Mark */
- if (is_motorola) {
- if (data[2] != 0) return;
- if (data[3] != 0x2A) return;
- } else {
- if (data[3] != 0) return;
- if (data[2] != 0x2A) return;
- }
-
- /* Get first IFD offset (offset to IFD0) */
- if (is_motorola) {
- if (data[4] != 0) return;
- if (data[5] != 0) return;
- firstoffset = data[6];
- firstoffset <<= 8;
- firstoffset += data[7];
- } else {
- if (data[7] != 0) return;
- if (data[6] != 0) return;
- firstoffset = data[5];
- firstoffset <<= 8;
- firstoffset += data[4];
- }
- if (firstoffset > length - 2) return; /* check end of data segment */
-
- /* Get the number of directory entries contained in this IFD */
- if (is_motorola) {
- number_of_tags = data[firstoffset];
- number_of_tags <<= 8;
- number_of_tags += data[firstoffset + 1];
- } else {
- number_of_tags = data[firstoffset + 1];
- number_of_tags <<= 8;
- number_of_tags += data[firstoffset];
- }
- if (number_of_tags == 0) return;
- firstoffset += 2;
-
- /* Search for ExifSubIFD offset Tag in IFD0 */
- for (;;) {
- if (firstoffset > length - 12) return; /* check end of data segment */
- /* Get Tag number */
- if (is_motorola) {
- tagnum = data[firstoffset];
- tagnum <<= 8;
- tagnum += data[firstoffset + 1];
- } else {
- tagnum = data[firstoffset + 1];
- tagnum <<= 8;
- tagnum += data[firstoffset];
- }
- if (tagnum == 0x8769) break; /* found ExifSubIFD offset Tag */
- if (--number_of_tags == 0) return;
- firstoffset += 12;
- }
-
- /* Get the ExifSubIFD offset */
- if (is_motorola) {
- if (data[firstoffset + 8] != 0) return;
- if (data[firstoffset + 9] != 0) return;
- offset = data[firstoffset + 10];
- offset <<= 8;
- offset += data[firstoffset + 11];
- } else {
- if (data[firstoffset + 11] != 0) return;
- if (data[firstoffset + 10] != 0) return;
- offset = data[firstoffset + 9];
- offset <<= 8;
- offset += data[firstoffset + 8];
- }
- if (offset > length - 2) return; /* check end of data segment */
-
- /* Get the number of directory entries contained in this SubIFD */
- if (is_motorola) {
- number_of_tags = data[offset];
- number_of_tags <<= 8;
- number_of_tags += data[offset + 1];
- } else {
- number_of_tags = data[offset + 1];
- number_of_tags <<= 8;
- number_of_tags += data[offset];
- }
- if (number_of_tags < 2) return;
- offset += 2;
-
- /* Search for ExifImageWidth and ExifImageHeight Tags in this SubIFD */
- do {
- if (offset > length - 12) return; /* check end of data segment */
- /* Get Tag number */
- if (is_motorola) {
- tagnum = data[offset];
- tagnum <<= 8;
- tagnum += data[offset + 1];
- } else {
- tagnum = data[offset + 1];
- tagnum <<= 8;
- tagnum += data[offset];
- }
- if (tagnum == 0xA002 || tagnum == 0xA003) {
- if (tagnum == 0xA002)
- new_value = new_width; /* ExifImageWidth Tag */
- else
- new_value = new_height; /* ExifImageHeight Tag */
- if (is_motorola) {
- data[offset + 2] = 0; /* Format = unsigned long (4 octets) */
- data[offset + 3] = 4;
- data[offset + 4] = 0; /* Number Of Components = 1 */
- data[offset + 5] = 0;
- data[offset + 6] = 0;
- data[offset + 7] = 1;
- data[offset + 8] = 0;
- data[offset + 9] = 0;
- data[offset + 10] = (JOCTET)((new_value >> 8) & 0xFF);
- data[offset + 11] = (JOCTET)(new_value & 0xFF);
- } else {
- data[offset + 2] = 4; /* Format = unsigned long (4 octets) */
- data[offset + 3] = 0;
- data[offset + 4] = 1; /* Number Of Components = 1 */
- data[offset + 5] = 0;
- data[offset + 6] = 0;
- data[offset + 7] = 0;
- data[offset + 8] = (JOCTET)(new_value & 0xFF);
- data[offset + 9] = (JOCTET)((new_value >> 8) & 0xFF);
- data[offset + 10] = 0;
- data[offset + 11] = 0;
- }
- }
- offset += 12;
- } while (--number_of_tags);
-}
-
-
-/* Adjust output image parameters as needed.
- *
- * This must be called after jpeg_copy_critical_parameters()
- * and before jpeg_write_coefficients().
- *
- * The return value is the set of virtual coefficient arrays to be written
- * (either the ones allocated by jtransform_request_workspace, or the
- * original source data arrays). The caller will need to pass this value
- * to jpeg_write_coefficients().
- */
-
-GLOBAL(jvirt_barray_ptr *)
-jtransform_adjust_parameters(j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
- jvirt_barray_ptr *src_coef_arrays,
- jpeg_transform_info *info)
-{
- /* If force-to-grayscale is requested, adjust destination parameters */
- if (info->force_grayscale) {
- /* First, ensure we have YCbCr or grayscale data, and that the source's
- * Y channel is full resolution. (No reasonable person would make Y
- * be less than full resolution, so actually coping with that case
- * isn't worth extra code space. But we check it to avoid crashing.)
- */
- if (((dstinfo->jpeg_color_space == JCS_YCbCr &&
- dstinfo->num_components == 3) ||
- (dstinfo->jpeg_color_space == JCS_GRAYSCALE &&
- dstinfo->num_components == 1)) &&
- srcinfo->comp_info[0].h_samp_factor == srcinfo->max_h_samp_factor &&
- srcinfo->comp_info[0].v_samp_factor == srcinfo->max_v_samp_factor) {
- /* We use jpeg_set_colorspace to make sure subsidiary settings get fixed
- * properly. Among other things, it sets the target h_samp_factor &
- * v_samp_factor to 1, which typically won't match the source.
- * We have to preserve the source's quantization table number, however.
- */
- int sv_quant_tbl_no = dstinfo->comp_info[0].quant_tbl_no;
- jpeg_set_colorspace(dstinfo, JCS_GRAYSCALE);
- dstinfo->comp_info[0].quant_tbl_no = sv_quant_tbl_no;
- } else {
- /* Sorry, can't do it */
- ERREXIT(dstinfo, JERR_CONVERSION_NOTIMPL);
- }
- } else if (info->num_components == 1) {
- /* For a single-component source, we force the destination sampling factors
- * to 1x1, with or without force_grayscale. This is useful because some
- * decoders choke on grayscale images with other sampling factors.
- */
- dstinfo->comp_info[0].h_samp_factor = 1;
- dstinfo->comp_info[0].v_samp_factor = 1;
- }
-
- /* Correct the destination's image dimensions as necessary
- * for rotate/flip, resize, and crop operations.
- */
-#if JPEG_LIB_VERSION >= 80
- dstinfo->jpeg_width = info->output_width;
- dstinfo->jpeg_height = info->output_height;
-#endif
-
- /* Transpose destination image parameters, adjust quantization */
- switch (info->transform) {
- case JXFORM_TRANSPOSE:
- case JXFORM_TRANSVERSE:
- case JXFORM_ROT_90:
- case JXFORM_ROT_270:
-#if JPEG_LIB_VERSION < 80
- dstinfo->image_width = info->output_height;
- dstinfo->image_height = info->output_width;
-#endif
- transpose_critical_parameters(dstinfo);
- break;
- case JXFORM_DROP:
- if (info->drop_width != 0 && info->drop_height != 0)
- adjust_quant(srcinfo, src_coef_arrays,
- info->drop_ptr, info->drop_coef_arrays,
- info->trim, dstinfo);
- break;
- default:
-#if JPEG_LIB_VERSION < 80
- dstinfo->image_width = info->output_width;
- dstinfo->image_height = info->output_height;
-#endif
- break;
- }
-
- /* Adjust Exif properties */
- if (srcinfo->marker_list != NULL &&
- srcinfo->marker_list->marker == JPEG_APP0 + 1 &&
- srcinfo->marker_list->data_length >= 6 &&
- srcinfo->marker_list->data[0] == 0x45 &&
- srcinfo->marker_list->data[1] == 0x78 &&
- srcinfo->marker_list->data[2] == 0x69 &&
- srcinfo->marker_list->data[3] == 0x66 &&
- srcinfo->marker_list->data[4] == 0 &&
- srcinfo->marker_list->data[5] == 0) {
- /* Suppress output of JFIF marker */
- dstinfo->write_JFIF_header = FALSE;
- /* Adjust Exif image parameters */
-#if JPEG_LIB_VERSION >= 80
- if (dstinfo->jpeg_width != srcinfo->image_width ||
- dstinfo->jpeg_height != srcinfo->image_height)
- /* Align data segment to start of TIFF structure for parsing */
- adjust_exif_parameters(srcinfo->marker_list->data + 6,
- srcinfo->marker_list->data_length - 6,
- dstinfo->jpeg_width, dstinfo->jpeg_height);
-#else
- if (dstinfo->image_width != srcinfo->image_width ||
- dstinfo->image_height != srcinfo->image_height)
- /* Align data segment to start of TIFF structure for parsing */
- adjust_exif_parameters(srcinfo->marker_list->data + 6,
- srcinfo->marker_list->data_length - 6,
- dstinfo->image_width, dstinfo->image_height);
-#endif
- }
-
- /* Return the appropriate output data set */
- if (info->workspace_coef_arrays != NULL)
- return info->workspace_coef_arrays;
- return src_coef_arrays;
-}
-
-
-/* Execute the actual transformation, if any.
- *
- * This must be called *after* jpeg_write_coefficients, because it depends
- * on jpeg_write_coefficients to have computed subsidiary values such as
- * the per-component width and height fields in the destination object.
- *
- * Note that some transformations will modify the source data arrays!
- */
-
-GLOBAL(void)
-jtransform_execute_transform(j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
- jvirt_barray_ptr *src_coef_arrays,
- jpeg_transform_info *info)
-{
- jvirt_barray_ptr *dst_coef_arrays = info->workspace_coef_arrays;
-
- /* Note: conditions tested here should match those in switch statement
- * in jtransform_request_workspace()
- */
- switch (info->transform) {
- case JXFORM_NONE:
- if (info->output_width > srcinfo->output_width ||
- info->output_height > srcinfo->output_height) {
- if (info->output_width > srcinfo->output_width &&
- info->crop_width_set == JCROP_REFLECT)
- do_crop_ext_reflect(srcinfo, dstinfo,
- info->x_crop_offset, info->y_crop_offset,
- src_coef_arrays, dst_coef_arrays);
- else if (info->output_width > srcinfo->output_width &&
- info->crop_width_set == JCROP_FORCE)
- do_crop_ext_flat(srcinfo, dstinfo,
- info->x_crop_offset, info->y_crop_offset,
- src_coef_arrays, dst_coef_arrays);
- else
- do_crop_ext_zero(srcinfo, dstinfo,
- info->x_crop_offset, info->y_crop_offset,
- src_coef_arrays, dst_coef_arrays);
- } else if (info->x_crop_offset != 0 || info->y_crop_offset != 0)
- do_crop(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset,
- src_coef_arrays, dst_coef_arrays);
- break;
- case JXFORM_FLIP_H:
- if (info->y_crop_offset != 0 || info->slow_hflip)
- do_flip_h(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset,
- src_coef_arrays, dst_coef_arrays);
- else
- do_flip_h_no_crop(srcinfo, dstinfo, info->x_crop_offset,
- src_coef_arrays);
- break;
- case JXFORM_FLIP_V:
- do_flip_v(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset,
- src_coef_arrays, dst_coef_arrays);
- break;
- case JXFORM_TRANSPOSE:
- do_transpose(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset,
- src_coef_arrays, dst_coef_arrays);
- break;
- case JXFORM_TRANSVERSE:
- do_transverse(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset,
- src_coef_arrays, dst_coef_arrays);
- break;
- case JXFORM_ROT_90:
- do_rot_90(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset,
- src_coef_arrays, dst_coef_arrays);
- break;
- case JXFORM_ROT_180:
- do_rot_180(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset,
- src_coef_arrays, dst_coef_arrays);
- break;
- case JXFORM_ROT_270:
- do_rot_270(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset,
- src_coef_arrays, dst_coef_arrays);
- break;
- case JXFORM_WIPE:
- if (info->crop_width_set == JCROP_REFLECT &&
- info->y_crop_offset == 0 && info->drop_height ==
- (JDIMENSION)jdiv_round_up
- ((long)info->output_height, (long)info->iMCU_sample_height) &&
- (info->x_crop_offset == 0 ||
- info->x_crop_offset + info->drop_width ==
- (JDIMENSION)jdiv_round_up
- ((long)info->output_width, (long)info->iMCU_sample_width)))
- do_reflect(srcinfo, dstinfo, info->x_crop_offset,
- src_coef_arrays, info->drop_width, info->drop_height);
- else if (info->crop_width_set == JCROP_FORCE)
- do_flatten(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset,
- src_coef_arrays, info->drop_width, info->drop_height);
- else
- do_wipe(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset,
- src_coef_arrays, info->drop_width, info->drop_height);
- break;
- case JXFORM_DROP:
- if (info->drop_width != 0 && info->drop_height != 0)
- do_drop(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset,
- src_coef_arrays, info->drop_ptr, info->drop_coef_arrays,
- info->drop_width, info->drop_height);
- break;
- }
-}
-
-/* jtransform_perfect_transform
- *
- * Determine whether lossless transformation is perfectly
- * possible for a specified image and transformation.
- *
- * Inputs:
- * image_width, image_height: source image dimensions.
- * MCU_width, MCU_height: pixel dimensions of MCU.
- * transform: transformation identifier.
- * Parameter sources from initialized jpeg_struct
- * (after reading source header):
- * image_width = cinfo.image_width
- * image_height = cinfo.image_height
- * MCU_width = cinfo.max_h_samp_factor * cinfo.block_size
- * MCU_height = cinfo.max_v_samp_factor * cinfo.block_size
- * Result:
- * TRUE = perfect transformation possible
- * FALSE = perfect transformation not possible
- * (may use custom action then)
- */
-
-GLOBAL(boolean)
-jtransform_perfect_transform(JDIMENSION image_width, JDIMENSION image_height,
- int MCU_width, int MCU_height,
- JXFORM_CODE transform)
-{
- boolean result = TRUE; /* initialize TRUE */
-
- switch (transform) {
- case JXFORM_FLIP_H:
- case JXFORM_ROT_270:
- if (image_width % (JDIMENSION)MCU_width)
- result = FALSE;
- break;
- case JXFORM_FLIP_V:
- case JXFORM_ROT_90:
- if (image_height % (JDIMENSION)MCU_height)
- result = FALSE;
- break;
- case JXFORM_TRANSVERSE:
- case JXFORM_ROT_180:
- if (image_width % (JDIMENSION)MCU_width)
- result = FALSE;
- if (image_height % (JDIMENSION)MCU_height)
- result = FALSE;
- break;
- default:
- break;
- }
-
- return result;
-}
-
-#endif /* TRANSFORMS_SUPPORTED */
-
-
-/* Setup decompression object to save desired markers in memory.
- * This must be called before jpeg_read_header() to have the desired effect.
- */
-
-GLOBAL(void)
-jcopy_markers_setup(j_decompress_ptr srcinfo, JCOPY_OPTION option)
-{
-#ifdef SAVE_MARKERS_SUPPORTED
- int m;
-
- /* Save comments except under NONE option */
- if (option != JCOPYOPT_NONE && option != JCOPYOPT_ICC) {
- jpeg_save_markers(srcinfo, JPEG_COM, 0xFFFF);
- }
- /* Save all types of APPn markers iff ALL option */
- if (option == JCOPYOPT_ALL || option == JCOPYOPT_ALL_EXCEPT_ICC) {
- for (m = 0; m < 16; m++) {
- if (option == JCOPYOPT_ALL_EXCEPT_ICC && m == 2)
- continue;
- jpeg_save_markers(srcinfo, JPEG_APP0 + m, 0xFFFF);
- }
- }
- /* Save only APP2 markers if ICC option selected */
- if (option == JCOPYOPT_ICC) {
- jpeg_save_markers(srcinfo, JPEG_APP0 + 2, 0xFFFF);
- }
-#endif /* SAVE_MARKERS_SUPPORTED */
-}
-
-/* Copy markers saved in the given source object to the destination object.
- * This should be called just after jpeg_start_compress() or
- * jpeg_write_coefficients().
- * Note that those routines will have written the SOI, and also the
- * JFIF APP0 or Adobe APP14 markers if selected.
- */
-
-GLOBAL(void)
-jcopy_markers_execute(j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
- JCOPY_OPTION option)
-{
- jpeg_saved_marker_ptr marker;
-
- /* In the current implementation, we don't actually need to examine the
- * option flag here; we just copy everything that got saved.
- * But to avoid confusion, we do not output JFIF and Adobe APP14 markers
- * if the encoder library already wrote one.
- */
- for (marker = srcinfo->marker_list; marker != NULL; marker = marker->next) {
- if (dstinfo->write_JFIF_header &&
- marker->marker == JPEG_APP0 &&
- marker->data_length >= 5 &&
- marker->data[0] == 0x4A &&
- marker->data[1] == 0x46 &&
- marker->data[2] == 0x49 &&
- marker->data[3] == 0x46 &&
- marker->data[4] == 0)
- continue; /* reject duplicate JFIF */
- if (dstinfo->write_Adobe_marker &&
- marker->marker == JPEG_APP0 + 14 &&
- marker->data_length >= 5 &&
- marker->data[0] == 0x41 &&
- marker->data[1] == 0x64 &&
- marker->data[2] == 0x6F &&
- marker->data[3] == 0x62 &&
- marker->data[4] == 0x65)
- continue; /* reject duplicate Adobe */
- jpeg_write_marker(dstinfo, marker->marker,
- marker->data, marker->data_length);
- }
-}
diff --git a/contrib/libs/libjpeg-turbo/transupp.h b/contrib/libs/libjpeg-turbo/transupp.h
deleted file mode 100644
index cea1f40921..0000000000
--- a/contrib/libs/libjpeg-turbo/transupp.h
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * transupp.h
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1997-2019, Thomas G. Lane, Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2017, 2021, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains declarations for image transformation routines and
- * other utility code used by the jpegtran sample application. These are
- * NOT part of the core JPEG library. But we keep these routines separate
- * from jpegtran.c to ease the task of maintaining jpegtran-like programs
- * that have other user interfaces.
- *
- * NOTE: all the routines declared here have very specific requirements
- * about when they are to be executed during the reading and writing of the
- * source and destination files. See the comments in transupp.c, or see
- * jpegtran.c for an example of correct usage.
- */
-
-/* If you happen not to want the image transform support, disable it here */
-#ifndef TRANSFORMS_SUPPORTED
-#define TRANSFORMS_SUPPORTED 1 /* 0 disables transform code */
-#endif
-
-/*
- * Although rotating and flipping data expressed as DCT coefficients is not
- * hard, there is an asymmetry in the JPEG format specification for images
- * whose dimensions aren't multiples of the iMCU size. The right and bottom
- * image edges are padded out to the next iMCU boundary with junk data; but
- * no padding is possible at the top and left edges. If we were to flip
- * the whole image including the pad data, then pad garbage would become
- * visible at the top and/or left, and real pixels would disappear into the
- * pad margins --- perhaps permanently, since encoders & decoders may not
- * bother to preserve DCT blocks that appear to be completely outside the
- * nominal image area. So, we have to exclude any partial iMCUs from the
- * basic transformation.
- *
- * Transpose is the only transformation that can handle partial iMCUs at the
- * right and bottom edges completely cleanly. flip_h can flip partial iMCUs
- * at the bottom, but leaves any partial iMCUs at the right edge untouched.
- * Similarly flip_v leaves any partial iMCUs at the bottom edge untouched.
- * The other transforms are defined as combinations of these basic transforms
- * and process edge blocks in a way that preserves the equivalence.
- *
- * The "trim" option causes untransformable partial iMCUs to be dropped;
- * this is not strictly lossless, but it usually gives the best-looking
- * result for odd-size images. Note that when this option is active,
- * the expected mathematical equivalences between the transforms may not hold.
- * (For example, -rot 270 -trim trims only the bottom edge, but -rot 90 -trim
- * followed by -rot 180 -trim trims both edges.)
- *
- * We also offer a lossless-crop option, which discards data outside a given
- * image region but losslessly preserves what is inside. Like the rotate and
- * flip transforms, lossless crop is restricted by the JPEG format: the upper
- * left corner of the selected region must fall on an iMCU boundary. If this
- * does not hold for the given crop parameters, we silently move the upper left
- * corner up and/or left to make it so, simultaneously increasing the region
- * dimensions to keep the lower right crop corner unchanged. (Thus, the
- * output image covers at least the requested region, but may cover more.)
- * The adjustment of the region dimensions may be optionally disabled.
- *
- * A complementary lossless wipe option is provided to discard (gray out) data
- * inside a given image region while losslessly preserving what is outside.
- * A lossless drop option is also provided, which allows another JPEG image to
- * be inserted ("dropped") into the source image data at a given position,
- * replacing the existing image data at that position. Both the source image
- * and the drop image must have the same subsampling level. It is best if they
- * also have the same quantization (quality.) Otherwise, the quantization of
- * the output image will be adapted to accommodate the higher of the source
- * image quality and the drop image quality. The trim option can be used with
- * the drop option to requantize the drop image to match the source image.
- *
- * We also provide a lossless-resize option, which is kind of a lossless-crop
- * operation in the DCT coefficient block domain - it discards higher-order
- * coefficients and losslessly preserves lower-order coefficients of a
- * sub-block.
- *
- * Rotate/flip transform, resize, and crop can be requested together in a
- * single invocation. The crop is applied last --- that is, the crop region
- * is specified in terms of the destination image after transform/resize.
- *
- * We also offer a "force to grayscale" option, which simply discards the
- * chrominance channels of a YCbCr image. This is lossless in the sense that
- * the luminance channel is preserved exactly. It's not the same kind of
- * thing as the rotate/flip transformations, but it's convenient to handle it
- * as part of this package, mainly because the transformation routines have to
- * be aware of the option to know how many components to work on.
- */
-
-
-/*
- * Codes for supported types of image transformations.
- */
-
-typedef enum {
- JXFORM_NONE, /* no transformation */
- JXFORM_FLIP_H, /* horizontal flip */
- JXFORM_FLIP_V, /* vertical flip */
- JXFORM_TRANSPOSE, /* transpose across UL-to-LR axis */
- JXFORM_TRANSVERSE, /* transpose across UR-to-LL axis */
- JXFORM_ROT_90, /* 90-degree clockwise rotation */
- JXFORM_ROT_180, /* 180-degree rotation */
- JXFORM_ROT_270, /* 270-degree clockwise (or 90 ccw) */
- JXFORM_WIPE, /* wipe */
- JXFORM_DROP /* drop */
-} JXFORM_CODE;
-
-/*
- * Codes for crop parameters, which can individually be unspecified,
- * positive or negative for xoffset or yoffset,
- * positive or force or reflect for width or height.
- */
-
-typedef enum {
- JCROP_UNSET,
- JCROP_POS,
- JCROP_NEG,
- JCROP_FORCE,
- JCROP_REFLECT
-} JCROP_CODE;
-
-/*
- * Transform parameters struct.
- * NB: application must not change any elements of this struct after
- * calling jtransform_request_workspace.
- */
-
-typedef struct {
- /* Options: set by caller */
- JXFORM_CODE transform; /* image transform operator */
- boolean perfect; /* if TRUE, fail if partial MCUs are requested */
- boolean trim; /* if TRUE, trim partial MCUs as needed */
- boolean force_grayscale; /* if TRUE, convert color image to grayscale */
- boolean crop; /* if TRUE, crop or wipe source image, or drop */
- boolean slow_hflip; /* For best performance, the JXFORM_FLIP_H transform
- normally modifies the source coefficients in place.
- Setting this to TRUE will instead use a slower,
- double-buffered algorithm, which leaves the source
- coefficients in tact (necessary if other transformed
- images must be generated from the same set of
- coefficients. */
-
- /* Crop parameters: application need not set these unless crop is TRUE.
- * These can be filled in by jtransform_parse_crop_spec().
- */
- JDIMENSION crop_width; /* Width of selected region */
- JCROP_CODE crop_width_set; /* (force-disables adjustment) */
- JDIMENSION crop_height; /* Height of selected region */
- JCROP_CODE crop_height_set; /* (force-disables adjustment) */
- JDIMENSION crop_xoffset; /* X offset of selected region */
- JCROP_CODE crop_xoffset_set; /* (negative measures from right edge) */
- JDIMENSION crop_yoffset; /* Y offset of selected region */
- JCROP_CODE crop_yoffset_set; /* (negative measures from bottom edge) */
-
- /* Drop parameters: set by caller for drop request */
- j_decompress_ptr drop_ptr;
- jvirt_barray_ptr *drop_coef_arrays;
-
- /* Internal workspace: caller should not touch these */
- int num_components; /* # of components in workspace */
- jvirt_barray_ptr *workspace_coef_arrays; /* workspace for transformations */
- JDIMENSION output_width; /* cropped destination dimensions */
- JDIMENSION output_height;
- JDIMENSION x_crop_offset; /* destination crop offsets measured in iMCUs */
- JDIMENSION y_crop_offset;
- JDIMENSION drop_width; /* drop/wipe dimensions measured in iMCUs */
- JDIMENSION drop_height;
- int iMCU_sample_width; /* destination iMCU size */
- int iMCU_sample_height;
-} jpeg_transform_info;
-
-
-#if TRANSFORMS_SUPPORTED
-
-/* Parse a crop specification (written in X11 geometry style) */
-EXTERN(boolean) jtransform_parse_crop_spec(jpeg_transform_info *info,
- const char *spec);
-/* Request any required workspace */
-EXTERN(boolean) jtransform_request_workspace(j_decompress_ptr srcinfo,
- jpeg_transform_info *info);
-/* Adjust output image parameters */
-EXTERN(jvirt_barray_ptr *) jtransform_adjust_parameters
- (j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
- jvirt_barray_ptr *src_coef_arrays, jpeg_transform_info *info);
-/* Execute the actual transformation, if any */
-EXTERN(void) jtransform_execute_transform(j_decompress_ptr srcinfo,
- j_compress_ptr dstinfo,
- jvirt_barray_ptr *src_coef_arrays,
- jpeg_transform_info *info);
-/* Determine whether lossless transformation is perfectly
- * possible for a specified image and transformation.
- */
-EXTERN(boolean) jtransform_perfect_transform(JDIMENSION image_width,
- JDIMENSION image_height,
- int MCU_width, int MCU_height,
- JXFORM_CODE transform);
-
-/* jtransform_execute_transform used to be called
- * jtransform_execute_transformation, but some compilers complain about
- * routine names that long. This macro is here to avoid breaking any
- * old source code that uses the original name...
- */
-#define jtransform_execute_transformation jtransform_execute_transform
-
-#endif /* TRANSFORMS_SUPPORTED */
-
-
-/*
- * Support for copying optional markers from source to destination file.
- */
-
-typedef enum {
- JCOPYOPT_NONE, /* copy no optional markers */
- JCOPYOPT_COMMENTS, /* copy only comment (COM) markers */
- JCOPYOPT_ALL, /* copy all optional markers */
- JCOPYOPT_ALL_EXCEPT_ICC, /* copy all optional markers except APP2 */
- JCOPYOPT_ICC /* copy only ICC profile (APP2) markers */
-} JCOPY_OPTION;
-
-#define JCOPYOPT_DEFAULT JCOPYOPT_COMMENTS /* recommended default */
-
-/* Setup decompression object to save desired markers in memory */
-EXTERN(void) jcopy_markers_setup(j_decompress_ptr srcinfo,
- JCOPY_OPTION option);
-/* Copy markers saved in the given source object to the destination object */
-EXTERN(void) jcopy_markers_execute(j_decompress_ptr srcinfo,
- j_compress_ptr dstinfo,
- JCOPY_OPTION option);
diff --git a/contrib/libs/libjpeg-turbo/turbojpeg-mapfile b/contrib/libs/libjpeg-turbo/turbojpeg-mapfile
deleted file mode 100644
index 5477fed2c3..0000000000
--- a/contrib/libs/libjpeg-turbo/turbojpeg-mapfile
+++ /dev/null
@@ -1,65 +0,0 @@
-TURBOJPEG_1.0
-{
- global:
- tjInitCompress;
- tjCompress;
- TJBUFSIZE;
- tjInitDecompress;
- tjDecompressHeader;
- tjDecompress;
- tjDestroy;
- tjGetErrorStr;
- local:
- *;
-};
-
-TURBOJPEG_1.1
-{
- global:
- TJBUFSIZEYUV;
- tjDecompressHeader2;
- tjDecompressToYUV;
- tjEncodeYUV;
-} TURBOJPEG_1.0;
-
-TURBOJPEG_1.2
-{
- global:
- tjAlloc;
- tjBufSize;
- tjBufSizeYUV;
- tjCompress2;
- tjDecompress2;
- tjEncodeYUV2;
- tjFree;
- tjGetScalingFactors;
- tjInitTransform;
- tjTransform;
-} TURBOJPEG_1.1;
-
-TURBOJPEG_1.4
-{
- global:
- tjBufSizeYUV2;
- tjCompressFromYUV;
- tjCompressFromYUVPlanes;
- tjDecodeYUV;
- tjDecodeYUVPlanes;
- tjDecompressHeader3;
- tjDecompressToYUV2;
- tjDecompressToYUVPlanes;
- tjEncodeYUV3;
- tjEncodeYUVPlanes;
- tjPlaneHeight;
- tjPlaneSizeYUV;
- tjPlaneWidth;
-} TURBOJPEG_1.2;
-
-TURBOJPEG_2.0
-{
- global:
- tjGetErrorCode;
- tjGetErrorStr2;
- tjLoadImage;
- tjSaveImage;
-} TURBOJPEG_1.4;
diff --git a/contrib/libs/libjpeg-turbo/turbojpeg.c b/contrib/libs/libjpeg-turbo/turbojpeg.c
deleted file mode 100644
index a1544f2431..0000000000
--- a/contrib/libs/libjpeg-turbo/turbojpeg.c
+++ /dev/null
@@ -1,2248 +0,0 @@
-/*
- * Copyright (C)2009-2022 D. R. Commander. All Rights Reserved.
- * Copyright (C)2021 Alex Richardson. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * - Neither the name of the libjpeg-turbo Project nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS",
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/* TurboJPEG/LJT: this implements the TurboJPEG API using libjpeg or
- libjpeg-turbo */
-
-#include <ctype.h>
-#include <jinclude.h>
-#define JPEG_INTERNALS
-#include <jpeglib.h>
-#include <jerror.h>
-#include <setjmp.h>
-#include <errno.h>
-#include "./turbojpeg.h"
-#include "./tjutil.h"
-#include "transupp.h"
-#include "./jpegcomp.h"
-#include "./cdjpeg.h"
-#include "jconfigint.h"
-
-extern void jpeg_mem_dest_tj(j_compress_ptr, unsigned char **, unsigned long *,
- boolean);
-extern void jpeg_mem_src_tj(j_decompress_ptr, const unsigned char *,
- unsigned long);
-
-#define PAD(v, p) ((v + (p) - 1) & (~((p) - 1)))
-#define IS_POW2(x) (((x) & (x - 1)) == 0)
-
-
-/* Error handling (based on example in example.txt) */
-
-static THREAD_LOCAL char errStr[JMSG_LENGTH_MAX] = "No error";
-
-struct my_error_mgr {
- struct jpeg_error_mgr pub;
- jmp_buf setjmp_buffer;
- void (*emit_message) (j_common_ptr, int);
- boolean warning, stopOnWarning;
-};
-typedef struct my_error_mgr *my_error_ptr;
-
-#define JMESSAGE(code, string) string,
-static const char *turbojpeg_message_table[] = {
-#include "cderror.h"
- NULL
-};
-
-static void my_error_exit(j_common_ptr cinfo)
-{
- my_error_ptr myerr = (my_error_ptr)cinfo->err;
-
- (*cinfo->err->output_message) (cinfo);
- longjmp(myerr->setjmp_buffer, 1);
-}
-
-/* Based on output_message() in jerror.c */
-
-static void my_output_message(j_common_ptr cinfo)
-{
- (*cinfo->err->format_message) (cinfo, errStr);
-}
-
-static void my_emit_message(j_common_ptr cinfo, int msg_level)
-{
- my_error_ptr myerr = (my_error_ptr)cinfo->err;
-
- myerr->emit_message(cinfo, msg_level);
- if (msg_level < 0) {
- myerr->warning = TRUE;
- if (myerr->stopOnWarning) longjmp(myerr->setjmp_buffer, 1);
- }
-}
-
-
-/* Global structures, macros, etc. */
-
-enum { COMPRESS = 1, DECOMPRESS = 2 };
-
-typedef struct _tjinstance {
- struct jpeg_compress_struct cinfo;
- struct jpeg_decompress_struct dinfo;
- struct my_error_mgr jerr;
- int init, headerRead;
- char errStr[JMSG_LENGTH_MAX];
- boolean isInstanceError;
-} tjinstance;
-
-struct my_progress_mgr {
- struct jpeg_progress_mgr pub;
- tjinstance *this;
-};
-typedef struct my_progress_mgr *my_progress_ptr;
-
-static void my_progress_monitor(j_common_ptr dinfo)
-{
- my_error_ptr myerr = (my_error_ptr)dinfo->err;
- my_progress_ptr myprog = (my_progress_ptr)dinfo->progress;
-
- if (dinfo->is_decompressor) {
- int scan_no = ((j_decompress_ptr)dinfo)->input_scan_number;
-
- if (scan_no > 500) {
- SNPRINTF(myprog->this->errStr, JMSG_LENGTH_MAX,
- "Progressive JPEG image has more than 500 scans");
- SNPRINTF(errStr, JMSG_LENGTH_MAX,
- "Progressive JPEG image has more than 500 scans");
- myprog->this->isInstanceError = TRUE;
- myerr->warning = FALSE;
- longjmp(myerr->setjmp_buffer, 1);
- }
- }
-}
-
-static const int pixelsize[TJ_NUMSAMP] = { 3, 3, 3, 1, 3, 3 };
-
-static const JXFORM_CODE xformtypes[TJ_NUMXOP] = {
- JXFORM_NONE, JXFORM_FLIP_H, JXFORM_FLIP_V, JXFORM_TRANSPOSE,
- JXFORM_TRANSVERSE, JXFORM_ROT_90, JXFORM_ROT_180, JXFORM_ROT_270
-};
-
-#define NUMSF 16
-static const tjscalingfactor sf[NUMSF] = {
- { 2, 1 },
- { 15, 8 },
- { 7, 4 },
- { 13, 8 },
- { 3, 2 },
- { 11, 8 },
- { 5, 4 },
- { 9, 8 },
- { 1, 1 },
- { 7, 8 },
- { 3, 4 },
- { 5, 8 },
- { 1, 2 },
- { 3, 8 },
- { 1, 4 },
- { 1, 8 }
-};
-
-static J_COLOR_SPACE pf2cs[TJ_NUMPF] = {
- JCS_EXT_RGB, JCS_EXT_BGR, JCS_EXT_RGBX, JCS_EXT_BGRX, JCS_EXT_XBGR,
- JCS_EXT_XRGB, JCS_GRAYSCALE, JCS_EXT_RGBA, JCS_EXT_BGRA, JCS_EXT_ABGR,
- JCS_EXT_ARGB, JCS_CMYK
-};
-
-static int cs2pf[JPEG_NUMCS] = {
- TJPF_UNKNOWN, TJPF_GRAY,
-#if RGB_RED == 0 && RGB_GREEN == 1 && RGB_BLUE == 2 && RGB_PIXELSIZE == 3
- TJPF_RGB,
-#elif RGB_RED == 2 && RGB_GREEN == 1 && RGB_BLUE == 0 && RGB_PIXELSIZE == 3
- TJPF_BGR,
-#elif RGB_RED == 0 && RGB_GREEN == 1 && RGB_BLUE == 2 && RGB_PIXELSIZE == 4
- TJPF_RGBX,
-#elif RGB_RED == 2 && RGB_GREEN == 1 && RGB_BLUE == 0 && RGB_PIXELSIZE == 4
- TJPF_BGRX,
-#elif RGB_RED == 3 && RGB_GREEN == 2 && RGB_BLUE == 1 && RGB_PIXELSIZE == 4
- TJPF_XBGR,
-#elif RGB_RED == 1 && RGB_GREEN == 2 && RGB_BLUE == 3 && RGB_PIXELSIZE == 4
- TJPF_XRGB,
-#endif
- TJPF_UNKNOWN, TJPF_CMYK, TJPF_UNKNOWN, TJPF_RGB, TJPF_RGBX, TJPF_BGR,
- TJPF_BGRX, TJPF_XBGR, TJPF_XRGB, TJPF_RGBA, TJPF_BGRA, TJPF_ABGR, TJPF_ARGB,
- TJPF_UNKNOWN
-};
-
-#define THROWG(m) { \
- SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s", m); \
- retval = -1; goto bailout; \
-}
-#ifdef _MSC_VER
-#define THROW_UNIX(m) { \
- char strerrorBuf[80] = { 0 }; \
- strerror_s(strerrorBuf, 80, errno); \
- SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s\n%s", m, strerrorBuf); \
- retval = -1; goto bailout; \
-}
-#else
-#define THROW_UNIX(m) { \
- SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s\n%s", m, strerror(errno)); \
- retval = -1; goto bailout; \
-}
-#endif
-#define THROW(m) { \
- SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s", m); \
- this->isInstanceError = TRUE; THROWG(m) \
-}
-
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
-/* Private flag that triggers different TurboJPEG API behavior when fuzzing */
-#define TJFLAG_FUZZING (1 << 30)
-#endif
-
-#define GET_INSTANCE(handle) \
- tjinstance *this = (tjinstance *)handle; \
- j_compress_ptr cinfo = NULL; \
- j_decompress_ptr dinfo = NULL; \
- \
- if (!this) { \
- SNPRINTF(errStr, JMSG_LENGTH_MAX, "Invalid handle"); \
- return -1; \
- } \
- cinfo = &this->cinfo; dinfo = &this->dinfo; \
- this->jerr.warning = FALSE; \
- this->isInstanceError = FALSE;
-
-#define GET_CINSTANCE(handle) \
- tjinstance *this = (tjinstance *)handle; \
- j_compress_ptr cinfo = NULL; \
- \
- if (!this) { \
- SNPRINTF(errStr, JMSG_LENGTH_MAX, "Invalid handle"); \
- return -1; \
- } \
- cinfo = &this->cinfo; \
- this->jerr.warning = FALSE; \
- this->isInstanceError = FALSE;
-
-#define GET_DINSTANCE(handle) \
- tjinstance *this = (tjinstance *)handle; \
- j_decompress_ptr dinfo = NULL; \
- \
- if (!this) { \
- SNPRINTF(errStr, JMSG_LENGTH_MAX, "Invalid handle"); \
- return -1; \
- } \
- dinfo = &this->dinfo; \
- this->jerr.warning = FALSE; \
- this->isInstanceError = FALSE;
-
-static int getPixelFormat(int pixelSize, int flags)
-{
- if (pixelSize == 1) return TJPF_GRAY;
- if (pixelSize == 3) {
- if (flags & TJ_BGR) return TJPF_BGR;
- else return TJPF_RGB;
- }
- if (pixelSize == 4) {
- if (flags & TJ_ALPHAFIRST) {
- if (flags & TJ_BGR) return TJPF_XBGR;
- else return TJPF_XRGB;
- } else {
- if (flags & TJ_BGR) return TJPF_BGRX;
- else return TJPF_RGBX;
- }
- }
- return -1;
-}
-
-static void setCompDefaults(struct jpeg_compress_struct *cinfo,
- int pixelFormat, int subsamp, int jpegQual,
- int flags)
-{
-#ifndef NO_GETENV
- char env[7] = { 0 };
-#endif
-
- cinfo->in_color_space = pf2cs[pixelFormat];
- cinfo->input_components = tjPixelSize[pixelFormat];
- jpeg_set_defaults(cinfo);
-
-#ifndef NO_GETENV
- if (!GETENV_S(env, 7, "TJ_OPTIMIZE") && !strcmp(env, "1"))
- cinfo->optimize_coding = TRUE;
- if (!GETENV_S(env, 7, "TJ_ARITHMETIC") && !strcmp(env, "1"))
- cinfo->arith_code = TRUE;
- if (!GETENV_S(env, 7, "TJ_RESTART") && strlen(env) > 0) {
- int temp = -1;
- char tempc = 0;
-
-#ifdef _MSC_VER
- if (sscanf_s(env, "%d%c", &temp, &tempc, 1) >= 1 && temp >= 0 &&
- temp <= 65535) {
-#else
- if (sscanf(env, "%d%c", &temp, &tempc) >= 1 && temp >= 0 &&
- temp <= 65535) {
-#endif
- if (toupper(tempc) == 'B') {
- cinfo->restart_interval = temp;
- cinfo->restart_in_rows = 0;
- } else
- cinfo->restart_in_rows = temp;
- }
- }
-#endif
-
- if (jpegQual >= 0) {
- jpeg_set_quality(cinfo, jpegQual, TRUE);
- if (jpegQual >= 96 || flags & TJFLAG_ACCURATEDCT)
- cinfo->dct_method = JDCT_ISLOW;
- else
- cinfo->dct_method = JDCT_FASTEST;
- }
- if (subsamp == TJSAMP_GRAY)
- jpeg_set_colorspace(cinfo, JCS_GRAYSCALE);
- else if (pixelFormat == TJPF_CMYK)
- jpeg_set_colorspace(cinfo, JCS_YCCK);
- else
- jpeg_set_colorspace(cinfo, JCS_YCbCr);
-
- if (flags & TJFLAG_PROGRESSIVE)
- jpeg_simple_progression(cinfo);
-#ifndef NO_GETENV
- else if (!GETENV_S(env, 7, "TJ_PROGRESSIVE") && !strcmp(env, "1"))
- jpeg_simple_progression(cinfo);
-#endif
-
- cinfo->comp_info[0].h_samp_factor = tjMCUWidth[subsamp] / 8;
- cinfo->comp_info[1].h_samp_factor = 1;
- cinfo->comp_info[2].h_samp_factor = 1;
- if (cinfo->num_components > 3)
- cinfo->comp_info[3].h_samp_factor = tjMCUWidth[subsamp] / 8;
- cinfo->comp_info[0].v_samp_factor = tjMCUHeight[subsamp] / 8;
- cinfo->comp_info[1].v_samp_factor = 1;
- cinfo->comp_info[2].v_samp_factor = 1;
- if (cinfo->num_components > 3)
- cinfo->comp_info[3].v_samp_factor = tjMCUHeight[subsamp] / 8;
-}
-
-
-static int getSubsamp(j_decompress_ptr dinfo)
-{
- int retval = -1, i, k;
-
- /* The sampling factors actually have no meaning with grayscale JPEG files,
- and in fact it's possible to generate grayscale JPEGs with sampling
- factors > 1 (even though those sampling factors are ignored by the
- decompressor.) Thus, we need to treat grayscale as a special case. */
- if (dinfo->num_components == 1 && dinfo->jpeg_color_space == JCS_GRAYSCALE)
- return TJSAMP_GRAY;
-
- for (i = 0; i < NUMSUBOPT; i++) {
- if (dinfo->num_components == pixelsize[i] ||
- ((dinfo->jpeg_color_space == JCS_YCCK ||
- dinfo->jpeg_color_space == JCS_CMYK) &&
- pixelsize[i] == 3 && dinfo->num_components == 4)) {
- if (dinfo->comp_info[0].h_samp_factor == tjMCUWidth[i] / 8 &&
- dinfo->comp_info[0].v_samp_factor == tjMCUHeight[i] / 8) {
- int match = 0;
-
- for (k = 1; k < dinfo->num_components; k++) {
- int href = 1, vref = 1;
-
- if ((dinfo->jpeg_color_space == JCS_YCCK ||
- dinfo->jpeg_color_space == JCS_CMYK) && k == 3) {
- href = tjMCUWidth[i] / 8; vref = tjMCUHeight[i] / 8;
- }
- if (dinfo->comp_info[k].h_samp_factor == href &&
- dinfo->comp_info[k].v_samp_factor == vref)
- match++;
- }
- if (match == dinfo->num_components - 1) {
- retval = i; break;
- }
- }
- /* Handle 4:2:2 and 4:4:0 images whose sampling factors are specified
- in non-standard ways. */
- if (dinfo->comp_info[0].h_samp_factor == 2 &&
- dinfo->comp_info[0].v_samp_factor == 2 &&
- (i == TJSAMP_422 || i == TJSAMP_440)) {
- int match = 0;
-
- for (k = 1; k < dinfo->num_components; k++) {
- int href = tjMCUHeight[i] / 8, vref = tjMCUWidth[i] / 8;
-
- if ((dinfo->jpeg_color_space == JCS_YCCK ||
- dinfo->jpeg_color_space == JCS_CMYK) && k == 3) {
- href = vref = 2;
- }
- if (dinfo->comp_info[k].h_samp_factor == href &&
- dinfo->comp_info[k].v_samp_factor == vref)
- match++;
- }
- if (match == dinfo->num_components - 1) {
- retval = i; break;
- }
- }
- /* Handle 4:4:4 images whose sampling factors are specified in
- non-standard ways. */
- if (dinfo->comp_info[0].h_samp_factor *
- dinfo->comp_info[0].v_samp_factor <=
- D_MAX_BLOCKS_IN_MCU / pixelsize[i] && i == TJSAMP_444) {
- int match = 0;
- for (k = 1; k < dinfo->num_components; k++) {
- if (dinfo->comp_info[k].h_samp_factor ==
- dinfo->comp_info[0].h_samp_factor &&
- dinfo->comp_info[k].v_samp_factor ==
- dinfo->comp_info[0].v_samp_factor)
- match++;
- if (match == dinfo->num_components - 1) {
- retval = i; break;
- }
- }
- }
- }
- }
- return retval;
-}
-
-
-/* General API functions */
-
-DLLEXPORT char *tjGetErrorStr2(tjhandle handle)
-{
- tjinstance *this = (tjinstance *)handle;
-
- if (this && this->isInstanceError) {
- this->isInstanceError = FALSE;
- return this->errStr;
- } else
- return errStr;
-}
-
-
-DLLEXPORT char *tjGetErrorStr(void)
-{
- return errStr;
-}
-
-
-DLLEXPORT int tjGetErrorCode(tjhandle handle)
-{
- tjinstance *this = (tjinstance *)handle;
-
- if (this && this->jerr.warning) return TJERR_WARNING;
- else return TJERR_FATAL;
-}
-
-
-DLLEXPORT int tjDestroy(tjhandle handle)
-{
- GET_INSTANCE(handle);
-
- if (setjmp(this->jerr.setjmp_buffer)) return -1;
- if (this->init & COMPRESS) jpeg_destroy_compress(cinfo);
- if (this->init & DECOMPRESS) jpeg_destroy_decompress(dinfo);
- free(this);
- return 0;
-}
-
-
-/* These are exposed mainly because Windows can't malloc() and free() across
- DLL boundaries except when the CRT DLL is used, and we don't use the CRT DLL
- with turbojpeg.dll for compatibility reasons. However, these functions
- can potentially be used for other purposes by different implementations. */
-
-DLLEXPORT void tjFree(unsigned char *buf)
-{
- free(buf);
-}
-
-
-DLLEXPORT unsigned char *tjAlloc(int bytes)
-{
- return (unsigned char *)malloc(bytes);
-}
-
-
-/* Compressor */
-
-static tjhandle _tjInitCompress(tjinstance *this)
-{
- static unsigned char buffer[1];
- unsigned char *buf = buffer;
- unsigned long size = 1;
-
- /* This is also straight out of example.txt */
- this->cinfo.err = jpeg_std_error(&this->jerr.pub);
- this->jerr.pub.error_exit = my_error_exit;
- this->jerr.pub.output_message = my_output_message;
- this->jerr.emit_message = this->jerr.pub.emit_message;
- this->jerr.pub.emit_message = my_emit_message;
- this->jerr.pub.addon_message_table = turbojpeg_message_table;
- this->jerr.pub.first_addon_message = JMSG_FIRSTADDONCODE;
- this->jerr.pub.last_addon_message = JMSG_LASTADDONCODE;
-
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- free(this);
- return NULL;
- }
-
- jpeg_create_compress(&this->cinfo);
- /* Make an initial call so it will create the destination manager */
- jpeg_mem_dest_tj(&this->cinfo, &buf, &size, 0);
-
- this->init |= COMPRESS;
- return (tjhandle)this;
-}
-
-DLLEXPORT tjhandle tjInitCompress(void)
-{
- tjinstance *this = NULL;
-
- if ((this = (tjinstance *)malloc(sizeof(tjinstance))) == NULL) {
- SNPRINTF(errStr, JMSG_LENGTH_MAX,
- "tjInitCompress(): Memory allocation failure");
- return NULL;
- }
- memset(this, 0, sizeof(tjinstance));
- SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "No error");
- return _tjInitCompress(this);
-}
-
-
-DLLEXPORT unsigned long tjBufSize(int width, int height, int jpegSubsamp)
-{
- unsigned long long retval = 0;
- int mcuw, mcuh, chromasf;
-
- if (width < 1 || height < 1 || jpegSubsamp < 0 || jpegSubsamp >= NUMSUBOPT)
- THROWG("tjBufSize(): Invalid argument");
-
- /* This allows for rare corner cases in which a JPEG image can actually be
- larger than the uncompressed input (we wouldn't mention it if it hadn't
- happened before.) */
- mcuw = tjMCUWidth[jpegSubsamp];
- mcuh = tjMCUHeight[jpegSubsamp];
- chromasf = jpegSubsamp == TJSAMP_GRAY ? 0 : 4 * 64 / (mcuw * mcuh);
- retval = PAD(width, mcuw) * PAD(height, mcuh) * (2ULL + chromasf) + 2048ULL;
- if (retval > (unsigned long long)((unsigned long)-1))
- THROWG("tjBufSize(): Image is too large");
-
-bailout:
- return (unsigned long)retval;
-}
-
-DLLEXPORT unsigned long TJBUFSIZE(int width, int height)
-{
- unsigned long long retval = 0;
-
- if (width < 1 || height < 1)
- THROWG("TJBUFSIZE(): Invalid argument");
-
- /* This allows for rare corner cases in which a JPEG image can actually be
- larger than the uncompressed input (we wouldn't mention it if it hadn't
- happened before.) */
- retval = PAD(width, 16) * PAD(height, 16) * 6ULL + 2048ULL;
- if (retval > (unsigned long long)((unsigned long)-1))
- THROWG("TJBUFSIZE(): Image is too large");
-
-bailout:
- return (unsigned long)retval;
-}
-
-
-DLLEXPORT unsigned long tjBufSizeYUV2(int width, int pad, int height,
- int subsamp)
-{
- unsigned long long retval = 0;
- int nc, i;
-
- if (subsamp < 0 || subsamp >= NUMSUBOPT)
- THROWG("tjBufSizeYUV2(): Invalid argument");
-
- nc = (subsamp == TJSAMP_GRAY ? 1 : 3);
- for (i = 0; i < nc; i++) {
- int pw = tjPlaneWidth(i, width, subsamp);
- int stride = PAD(pw, pad);
- int ph = tjPlaneHeight(i, height, subsamp);
-
- if (pw < 0 || ph < 0) return -1;
- else retval += (unsigned long long)stride * ph;
- }
- if (retval > (unsigned long long)((unsigned long)-1))
- THROWG("tjBufSizeYUV2(): Image is too large");
-
-bailout:
- return (unsigned long)retval;
-}
-
-DLLEXPORT unsigned long tjBufSizeYUV(int width, int height, int subsamp)
-{
- return tjBufSizeYUV2(width, 4, height, subsamp);
-}
-
-DLLEXPORT unsigned long TJBUFSIZEYUV(int width, int height, int subsamp)
-{
- return tjBufSizeYUV(width, height, subsamp);
-}
-
-
-DLLEXPORT int tjPlaneWidth(int componentID, int width, int subsamp)
-{
- int pw, nc, retval = 0;
-
- if (width < 1 || subsamp < 0 || subsamp >= TJ_NUMSAMP)
- THROWG("tjPlaneWidth(): Invalid argument");
- nc = (subsamp == TJSAMP_GRAY ? 1 : 3);
- if (componentID < 0 || componentID >= nc)
- THROWG("tjPlaneWidth(): Invalid argument");
-
- pw = PAD(width, tjMCUWidth[subsamp] / 8);
- if (componentID == 0)
- retval = pw;
- else
- retval = pw * 8 / tjMCUWidth[subsamp];
-
-bailout:
- return retval;
-}
-
-
-DLLEXPORT int tjPlaneHeight(int componentID, int height, int subsamp)
-{
- int ph, nc, retval = 0;
-
- if (height < 1 || subsamp < 0 || subsamp >= TJ_NUMSAMP)
- THROWG("tjPlaneHeight(): Invalid argument");
- nc = (subsamp == TJSAMP_GRAY ? 1 : 3);
- if (componentID < 0 || componentID >= nc)
- THROWG("tjPlaneHeight(): Invalid argument");
-
- ph = PAD(height, tjMCUHeight[subsamp] / 8);
- if (componentID == 0)
- retval = ph;
- else
- retval = ph * 8 / tjMCUHeight[subsamp];
-
-bailout:
- return retval;
-}
-
-
-DLLEXPORT unsigned long tjPlaneSizeYUV(int componentID, int width, int stride,
- int height, int subsamp)
-{
- unsigned long long retval = 0;
- int pw, ph;
-
- if (width < 1 || height < 1 || subsamp < 0 || subsamp >= NUMSUBOPT)
- THROWG("tjPlaneSizeYUV(): Invalid argument");
-
- pw = tjPlaneWidth(componentID, width, subsamp);
- ph = tjPlaneHeight(componentID, height, subsamp);
- if (pw < 0 || ph < 0) return -1;
-
- if (stride == 0) stride = pw;
- else stride = abs(stride);
-
- retval = (unsigned long long)stride * (ph - 1) + pw;
- if (retval > (unsigned long long)((unsigned long)-1))
- THROWG("tjPlaneSizeYUV(): Image is too large");
-
-bailout:
- return (unsigned long)retval;
-}
-
-
-DLLEXPORT int tjCompress2(tjhandle handle, const unsigned char *srcBuf,
- int width, int pitch, int height, int pixelFormat,
- unsigned char **jpegBuf, unsigned long *jpegSize,
- int jpegSubsamp, int jpegQual, int flags)
-{
- int i, retval = 0;
- boolean alloc = TRUE;
- JSAMPROW *row_pointer = NULL;
-
- GET_CINSTANCE(handle)
- this->jerr.stopOnWarning = (flags & TJFLAG_STOPONWARNING) ? TRUE : FALSE;
- if ((this->init & COMPRESS) == 0)
- THROW("tjCompress2(): Instance has not been initialized for compression");
-
- if (srcBuf == NULL || width <= 0 || pitch < 0 || height <= 0 ||
- pixelFormat < 0 || pixelFormat >= TJ_NUMPF || jpegBuf == NULL ||
- jpegSize == NULL || jpegSubsamp < 0 || jpegSubsamp >= NUMSUBOPT ||
- jpegQual < 0 || jpegQual > 100)
- THROW("tjCompress2(): Invalid argument");
-
- if (pitch == 0) pitch = width * tjPixelSize[pixelFormat];
-
- if ((row_pointer = (JSAMPROW *)malloc(sizeof(JSAMPROW) * height)) == NULL)
- THROW("tjCompress2(): Memory allocation failure");
-
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- retval = -1; goto bailout;
- }
-
- cinfo->image_width = width;
- cinfo->image_height = height;
-
-#ifndef NO_PUTENV
- if (flags & TJFLAG_FORCEMMX) PUTENV_S("JSIMD_FORCEMMX", "1");
- else if (flags & TJFLAG_FORCESSE) PUTENV_S("JSIMD_FORCESSE", "1");
- else if (flags & TJFLAG_FORCESSE2) PUTENV_S("JSIMD_FORCESSE2", "1");
-#endif
-
- if (flags & TJFLAG_NOREALLOC) {
- alloc = FALSE; *jpegSize = tjBufSize(width, height, jpegSubsamp);
- }
- jpeg_mem_dest_tj(cinfo, jpegBuf, jpegSize, alloc);
- setCompDefaults(cinfo, pixelFormat, jpegSubsamp, jpegQual, flags);
-
- jpeg_start_compress(cinfo, TRUE);
- for (i = 0; i < height; i++) {
- if (flags & TJFLAG_BOTTOMUP)
- row_pointer[i] = (JSAMPROW)&srcBuf[(height - i - 1) * (size_t)pitch];
- else
- row_pointer[i] = (JSAMPROW)&srcBuf[i * (size_t)pitch];
- }
- while (cinfo->next_scanline < cinfo->image_height)
- jpeg_write_scanlines(cinfo, &row_pointer[cinfo->next_scanline],
- cinfo->image_height - cinfo->next_scanline);
- jpeg_finish_compress(cinfo);
-
-bailout:
- if (cinfo->global_state > CSTATE_START) {
- if (alloc) (*cinfo->dest->term_destination) (cinfo);
- jpeg_abort_compress(cinfo);
- }
- free(row_pointer);
- if (this->jerr.warning) retval = -1;
- this->jerr.stopOnWarning = FALSE;
- return retval;
-}
-
-DLLEXPORT int tjCompress(tjhandle handle, unsigned char *srcBuf, int width,
- int pitch, int height, int pixelSize,
- unsigned char *jpegBuf, unsigned long *jpegSize,
- int jpegSubsamp, int jpegQual, int flags)
-{
- int retval = 0;
- unsigned long size;
-
- if (flags & TJ_YUV) {
- size = tjBufSizeYUV(width, height, jpegSubsamp);
- retval = tjEncodeYUV2(handle, srcBuf, width, pitch, height,
- getPixelFormat(pixelSize, flags), jpegBuf,
- jpegSubsamp, flags);
- } else {
- retval = tjCompress2(handle, srcBuf, width, pitch, height,
- getPixelFormat(pixelSize, flags), &jpegBuf, &size,
- jpegSubsamp, jpegQual, flags | TJFLAG_NOREALLOC);
- }
- *jpegSize = size;
- return retval;
-}
-
-
-DLLEXPORT int tjEncodeYUVPlanes(tjhandle handle, const unsigned char *srcBuf,
- int width, int pitch, int height,
- int pixelFormat, unsigned char **dstPlanes,
- int *strides, int subsamp, int flags)
-{
- JSAMPROW *row_pointer = NULL;
- JSAMPLE *_tmpbuf[MAX_COMPONENTS], *_tmpbuf2[MAX_COMPONENTS];
- JSAMPROW *tmpbuf[MAX_COMPONENTS], *tmpbuf2[MAX_COMPONENTS];
- JSAMPROW *outbuf[MAX_COMPONENTS];
- int i, retval = 0, row, pw0, ph0, pw[MAX_COMPONENTS], ph[MAX_COMPONENTS];
- JSAMPLE *ptr;
- jpeg_component_info *compptr;
-
- GET_CINSTANCE(handle);
- this->jerr.stopOnWarning = (flags & TJFLAG_STOPONWARNING) ? TRUE : FALSE;
-
- for (i = 0; i < MAX_COMPONENTS; i++) {
- tmpbuf[i] = NULL; _tmpbuf[i] = NULL;
- tmpbuf2[i] = NULL; _tmpbuf2[i] = NULL; outbuf[i] = NULL;
- }
-
- if ((this->init & COMPRESS) == 0)
- THROW("tjEncodeYUVPlanes(): Instance has not been initialized for compression");
-
- if (srcBuf == NULL || width <= 0 || pitch < 0 || height <= 0 ||
- pixelFormat < 0 || pixelFormat >= TJ_NUMPF || !dstPlanes ||
- !dstPlanes[0] || subsamp < 0 || subsamp >= NUMSUBOPT)
- THROW("tjEncodeYUVPlanes(): Invalid argument");
- if (subsamp != TJSAMP_GRAY && (!dstPlanes[1] || !dstPlanes[2]))
- THROW("tjEncodeYUVPlanes(): Invalid argument");
-
- if (pixelFormat == TJPF_CMYK)
- THROW("tjEncodeYUVPlanes(): Cannot generate YUV images from CMYK pixels");
-
- if (pitch == 0) pitch = width * tjPixelSize[pixelFormat];
-
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- retval = -1; goto bailout;
- }
-
- cinfo->image_width = width;
- cinfo->image_height = height;
-
-#ifndef NO_PUTENV
- if (flags & TJFLAG_FORCEMMX) PUTENV_S("JSIMD_FORCEMMX", "1");
- else if (flags & TJFLAG_FORCESSE) PUTENV_S("JSIMD_FORCESSE", "1");
- else if (flags & TJFLAG_FORCESSE2) PUTENV_S("JSIMD_FORCESSE2", "1");
-#endif
-
- setCompDefaults(cinfo, pixelFormat, subsamp, -1, flags);
-
- /* Execute only the parts of jpeg_start_compress() that we need. If we
- were to call the whole jpeg_start_compress() function, then it would try
- to write the file headers, which could overflow the output buffer if the
- YUV image were very small. */
- if (cinfo->global_state != CSTATE_START)
- THROW("tjEncodeYUVPlanes(): libjpeg API is in the wrong state");
- (*cinfo->err->reset_error_mgr) ((j_common_ptr)cinfo);
- jinit_c_master_control(cinfo, FALSE);
- jinit_color_converter(cinfo);
- jinit_downsampler(cinfo);
- (*cinfo->cconvert->start_pass) (cinfo);
-
- pw0 = PAD(width, cinfo->max_h_samp_factor);
- ph0 = PAD(height, cinfo->max_v_samp_factor);
-
- if ((row_pointer = (JSAMPROW *)malloc(sizeof(JSAMPROW) * ph0)) == NULL)
- THROW("tjEncodeYUVPlanes(): Memory allocation failure");
- for (i = 0; i < height; i++) {
- if (flags & TJFLAG_BOTTOMUP)
- row_pointer[i] = (JSAMPROW)&srcBuf[(height - i - 1) * (size_t)pitch];
- else
- row_pointer[i] = (JSAMPROW)&srcBuf[i * (size_t)pitch];
- }
- if (height < ph0)
- for (i = height; i < ph0; i++) row_pointer[i] = row_pointer[height - 1];
-
- for (i = 0; i < cinfo->num_components; i++) {
- compptr = &cinfo->comp_info[i];
- _tmpbuf[i] = (JSAMPLE *)malloc(
- PAD((compptr->width_in_blocks * cinfo->max_h_samp_factor * DCTSIZE) /
- compptr->h_samp_factor, 32) *
- cinfo->max_v_samp_factor + 32);
- if (!_tmpbuf[i])
- THROW("tjEncodeYUVPlanes(): Memory allocation failure");
- tmpbuf[i] =
- (JSAMPROW *)malloc(sizeof(JSAMPROW) * cinfo->max_v_samp_factor);
- if (!tmpbuf[i])
- THROW("tjEncodeYUVPlanes(): Memory allocation failure");
- for (row = 0; row < cinfo->max_v_samp_factor; row++) {
- unsigned char *_tmpbuf_aligned =
- (unsigned char *)PAD((JUINTPTR)_tmpbuf[i], 32);
-
- tmpbuf[i][row] = &_tmpbuf_aligned[
- PAD((compptr->width_in_blocks * cinfo->max_h_samp_factor * DCTSIZE) /
- compptr->h_samp_factor, 32) * row];
- }
- _tmpbuf2[i] =
- (JSAMPLE *)malloc(PAD(compptr->width_in_blocks * DCTSIZE, 32) *
- compptr->v_samp_factor + 32);
- if (!_tmpbuf2[i])
- THROW("tjEncodeYUVPlanes(): Memory allocation failure");
- tmpbuf2[i] = (JSAMPROW *)malloc(sizeof(JSAMPROW) * compptr->v_samp_factor);
- if (!tmpbuf2[i])
- THROW("tjEncodeYUVPlanes(): Memory allocation failure");
- for (row = 0; row < compptr->v_samp_factor; row++) {
- unsigned char *_tmpbuf2_aligned =
- (unsigned char *)PAD((JUINTPTR)_tmpbuf2[i], 32);
-
- tmpbuf2[i][row] =
- &_tmpbuf2_aligned[PAD(compptr->width_in_blocks * DCTSIZE, 32) * row];
- }
- pw[i] = pw0 * compptr->h_samp_factor / cinfo->max_h_samp_factor;
- ph[i] = ph0 * compptr->v_samp_factor / cinfo->max_v_samp_factor;
- outbuf[i] = (JSAMPROW *)malloc(sizeof(JSAMPROW) * ph[i]);
- if (!outbuf[i])
- THROW("tjEncodeYUVPlanes(): Memory allocation failure");
- ptr = dstPlanes[i];
- for (row = 0; row < ph[i]; row++) {
- outbuf[i][row] = ptr;
- ptr += (strides && strides[i] != 0) ? strides[i] : pw[i];
- }
- }
-
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- retval = -1; goto bailout;
- }
-
- for (row = 0; row < ph0; row += cinfo->max_v_samp_factor) {
- (*cinfo->cconvert->color_convert) (cinfo, &row_pointer[row], tmpbuf, 0,
- cinfo->max_v_samp_factor);
- (cinfo->downsample->downsample) (cinfo, tmpbuf, 0, tmpbuf2, 0);
- for (i = 0, compptr = cinfo->comp_info; i < cinfo->num_components;
- i++, compptr++)
- jcopy_sample_rows(tmpbuf2[i], 0, outbuf[i],
- row * compptr->v_samp_factor / cinfo->max_v_samp_factor,
- compptr->v_samp_factor, pw[i]);
- }
- cinfo->next_scanline += height;
- jpeg_abort_compress(cinfo);
-
-bailout:
- if (cinfo->global_state > CSTATE_START) jpeg_abort_compress(cinfo);
- free(row_pointer);
- for (i = 0; i < MAX_COMPONENTS; i++) {
- free(tmpbuf[i]);
- free(_tmpbuf[i]);
- free(tmpbuf2[i]);
- free(_tmpbuf2[i]);
- free(outbuf[i]);
- }
- if (this->jerr.warning) retval = -1;
- this->jerr.stopOnWarning = FALSE;
- return retval;
-}
-
-DLLEXPORT int tjEncodeYUV3(tjhandle handle, const unsigned char *srcBuf,
- int width, int pitch, int height, int pixelFormat,
- unsigned char *dstBuf, int pad, int subsamp,
- int flags)
-{
- unsigned char *dstPlanes[3];
- int pw0, ph0, strides[3], retval = -1;
- tjinstance *this = (tjinstance *)handle;
-
- if (!this) THROWG("tjEncodeYUV3(): Invalid handle");
- this->isInstanceError = FALSE;
-
- if (width <= 0 || height <= 0 || dstBuf == NULL || pad < 0 ||
- !IS_POW2(pad) || subsamp < 0 || subsamp >= NUMSUBOPT)
- THROW("tjEncodeYUV3(): Invalid argument");
-
- pw0 = tjPlaneWidth(0, width, subsamp);
- ph0 = tjPlaneHeight(0, height, subsamp);
- dstPlanes[0] = dstBuf;
- strides[0] = PAD(pw0, pad);
- if (subsamp == TJSAMP_GRAY) {
- strides[1] = strides[2] = 0;
- dstPlanes[1] = dstPlanes[2] = NULL;
- } else {
- int pw1 = tjPlaneWidth(1, width, subsamp);
- int ph1 = tjPlaneHeight(1, height, subsamp);
-
- strides[1] = strides[2] = PAD(pw1, pad);
- dstPlanes[1] = dstPlanes[0] + strides[0] * ph0;
- dstPlanes[2] = dstPlanes[1] + strides[1] * ph1;
- }
-
- return tjEncodeYUVPlanes(handle, srcBuf, width, pitch, height, pixelFormat,
- dstPlanes, strides, subsamp, flags);
-
-bailout:
- return retval;
-}
-
-DLLEXPORT int tjEncodeYUV2(tjhandle handle, unsigned char *srcBuf, int width,
- int pitch, int height, int pixelFormat,
- unsigned char *dstBuf, int subsamp, int flags)
-{
- return tjEncodeYUV3(handle, srcBuf, width, pitch, height, pixelFormat,
- dstBuf, 4, subsamp, flags);
-}
-
-DLLEXPORT int tjEncodeYUV(tjhandle handle, unsigned char *srcBuf, int width,
- int pitch, int height, int pixelSize,
- unsigned char *dstBuf, int subsamp, int flags)
-{
- return tjEncodeYUV2(handle, srcBuf, width, pitch, height,
- getPixelFormat(pixelSize, flags), dstBuf, subsamp,
- flags);
-}
-
-
-DLLEXPORT int tjCompressFromYUVPlanes(tjhandle handle,
- const unsigned char **srcPlanes,
- int width, const int *strides,
- int height, int subsamp,
- unsigned char **jpegBuf,
- unsigned long *jpegSize, int jpegQual,
- int flags)
-{
- int i, row, retval = 0;
- boolean alloc = TRUE;
- int pw[MAX_COMPONENTS], ph[MAX_COMPONENTS], iw[MAX_COMPONENTS],
- tmpbufsize = 0, usetmpbuf = 0, th[MAX_COMPONENTS];
- JSAMPLE *_tmpbuf = NULL, *ptr;
- JSAMPROW *inbuf[MAX_COMPONENTS], *tmpbuf[MAX_COMPONENTS];
-
- GET_CINSTANCE(handle)
- this->jerr.stopOnWarning = (flags & TJFLAG_STOPONWARNING) ? TRUE : FALSE;
-
- for (i = 0; i < MAX_COMPONENTS; i++) {
- tmpbuf[i] = NULL; inbuf[i] = NULL;
- }
-
- if ((this->init & COMPRESS) == 0)
- THROW("tjCompressFromYUVPlanes(): Instance has not been initialized for compression");
-
- if (!srcPlanes || !srcPlanes[0] || width <= 0 || height <= 0 ||
- subsamp < 0 || subsamp >= NUMSUBOPT || jpegBuf == NULL ||
- jpegSize == NULL || jpegQual < 0 || jpegQual > 100)
- THROW("tjCompressFromYUVPlanes(): Invalid argument");
- if (subsamp != TJSAMP_GRAY && (!srcPlanes[1] || !srcPlanes[2]))
- THROW("tjCompressFromYUVPlanes(): Invalid argument");
-
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- retval = -1; goto bailout;
- }
-
- cinfo->image_width = width;
- cinfo->image_height = height;
-
-#ifndef NO_PUTENV
- if (flags & TJFLAG_FORCEMMX) PUTENV_S("JSIMD_FORCEMMX", "1");
- else if (flags & TJFLAG_FORCESSE) PUTENV_S("JSIMD_FORCESSE", "1");
- else if (flags & TJFLAG_FORCESSE2) PUTENV_S("JSIMD_FORCESSE2", "1");
-#endif
-
- if (flags & TJFLAG_NOREALLOC) {
- alloc = FALSE; *jpegSize = tjBufSize(width, height, subsamp);
- }
- jpeg_mem_dest_tj(cinfo, jpegBuf, jpegSize, alloc);
- setCompDefaults(cinfo, TJPF_RGB, subsamp, jpegQual, flags);
- cinfo->raw_data_in = TRUE;
-
- jpeg_start_compress(cinfo, TRUE);
- for (i = 0; i < cinfo->num_components; i++) {
- jpeg_component_info *compptr = &cinfo->comp_info[i];
- int ih;
-
- iw[i] = compptr->width_in_blocks * DCTSIZE;
- ih = compptr->height_in_blocks * DCTSIZE;
- pw[i] = PAD(cinfo->image_width, cinfo->max_h_samp_factor) *
- compptr->h_samp_factor / cinfo->max_h_samp_factor;
- ph[i] = PAD(cinfo->image_height, cinfo->max_v_samp_factor) *
- compptr->v_samp_factor / cinfo->max_v_samp_factor;
- if (iw[i] != pw[i] || ih != ph[i]) usetmpbuf = 1;
- th[i] = compptr->v_samp_factor * DCTSIZE;
- tmpbufsize += iw[i] * th[i];
- if ((inbuf[i] = (JSAMPROW *)malloc(sizeof(JSAMPROW) * ph[i])) == NULL)
- THROW("tjCompressFromYUVPlanes(): Memory allocation failure");
- ptr = (JSAMPLE *)srcPlanes[i];
- for (row = 0; row < ph[i]; row++) {
- inbuf[i][row] = ptr;
- ptr += (strides && strides[i] != 0) ? strides[i] : pw[i];
- }
- }
- if (usetmpbuf) {
- if ((_tmpbuf = (JSAMPLE *)malloc(sizeof(JSAMPLE) * tmpbufsize)) == NULL)
- THROW("tjCompressFromYUVPlanes(): Memory allocation failure");
- ptr = _tmpbuf;
- for (i = 0; i < cinfo->num_components; i++) {
- if ((tmpbuf[i] = (JSAMPROW *)malloc(sizeof(JSAMPROW) * th[i])) == NULL)
- THROW("tjCompressFromYUVPlanes(): Memory allocation failure");
- for (row = 0; row < th[i]; row++) {
- tmpbuf[i][row] = ptr;
- ptr += iw[i];
- }
- }
- }
-
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- retval = -1; goto bailout;
- }
-
- for (row = 0; row < (int)cinfo->image_height;
- row += cinfo->max_v_samp_factor * DCTSIZE) {
- JSAMPARRAY yuvptr[MAX_COMPONENTS];
- int crow[MAX_COMPONENTS];
-
- for (i = 0; i < cinfo->num_components; i++) {
- jpeg_component_info *compptr = &cinfo->comp_info[i];
-
- crow[i] = row * compptr->v_samp_factor / cinfo->max_v_samp_factor;
- if (usetmpbuf) {
- int j, k;
-
- for (j = 0; j < MIN(th[i], ph[i] - crow[i]); j++) {
- memcpy(tmpbuf[i][j], inbuf[i][crow[i] + j], pw[i]);
- /* Duplicate last sample in row to fill out MCU */
- for (k = pw[i]; k < iw[i]; k++)
- tmpbuf[i][j][k] = tmpbuf[i][j][pw[i] - 1];
- }
- /* Duplicate last row to fill out MCU */
- for (j = ph[i] - crow[i]; j < th[i]; j++)
- memcpy(tmpbuf[i][j], tmpbuf[i][ph[i] - crow[i] - 1], iw[i]);
- yuvptr[i] = tmpbuf[i];
- } else
- yuvptr[i] = &inbuf[i][crow[i]];
- }
- jpeg_write_raw_data(cinfo, yuvptr, cinfo->max_v_samp_factor * DCTSIZE);
- }
- jpeg_finish_compress(cinfo);
-
-bailout:
- if (cinfo->global_state > CSTATE_START) {
- if (alloc) (*cinfo->dest->term_destination) (cinfo);
- jpeg_abort_compress(cinfo);
- }
- for (i = 0; i < MAX_COMPONENTS; i++) {
- free(tmpbuf[i]);
- free(inbuf[i]);
- }
- free(_tmpbuf);
- if (this->jerr.warning) retval = -1;
- this->jerr.stopOnWarning = FALSE;
- return retval;
-}
-
-DLLEXPORT int tjCompressFromYUV(tjhandle handle, const unsigned char *srcBuf,
- int width, int pad, int height, int subsamp,
- unsigned char **jpegBuf,
- unsigned long *jpegSize, int jpegQual,
- int flags)
-{
- const unsigned char *srcPlanes[3];
- int pw0, ph0, strides[3], retval = -1;
- tjinstance *this = (tjinstance *)handle;
-
- if (!this) THROWG("tjCompressFromYUV(): Invalid handle");
- this->isInstanceError = FALSE;
-
- if (srcBuf == NULL || width <= 0 || pad < 1 || height <= 0 || subsamp < 0 ||
- subsamp >= NUMSUBOPT)
- THROW("tjCompressFromYUV(): Invalid argument");
-
- pw0 = tjPlaneWidth(0, width, subsamp);
- ph0 = tjPlaneHeight(0, height, subsamp);
- srcPlanes[0] = srcBuf;
- strides[0] = PAD(pw0, pad);
- if (subsamp == TJSAMP_GRAY) {
- strides[1] = strides[2] = 0;
- srcPlanes[1] = srcPlanes[2] = NULL;
- } else {
- int pw1 = tjPlaneWidth(1, width, subsamp);
- int ph1 = tjPlaneHeight(1, height, subsamp);
-
- strides[1] = strides[2] = PAD(pw1, pad);
- srcPlanes[1] = srcPlanes[0] + strides[0] * ph0;
- srcPlanes[2] = srcPlanes[1] + strides[1] * ph1;
- }
-
- return tjCompressFromYUVPlanes(handle, srcPlanes, width, strides, height,
- subsamp, jpegBuf, jpegSize, jpegQual, flags);
-
-bailout:
- return retval;
-}
-
-
-/* Decompressor */
-
-static tjhandle _tjInitDecompress(tjinstance *this)
-{
- static unsigned char buffer[1];
-
- /* This is also straight out of example.txt */
- this->dinfo.err = jpeg_std_error(&this->jerr.pub);
- this->jerr.pub.error_exit = my_error_exit;
- this->jerr.pub.output_message = my_output_message;
- this->jerr.emit_message = this->jerr.pub.emit_message;
- this->jerr.pub.emit_message = my_emit_message;
- this->jerr.pub.addon_message_table = turbojpeg_message_table;
- this->jerr.pub.first_addon_message = JMSG_FIRSTADDONCODE;
- this->jerr.pub.last_addon_message = JMSG_LASTADDONCODE;
-
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- free(this);
- return NULL;
- }
-
- jpeg_create_decompress(&this->dinfo);
- /* Make an initial call so it will create the source manager */
- jpeg_mem_src_tj(&this->dinfo, buffer, 1);
-
- this->init |= DECOMPRESS;
- return (tjhandle)this;
-}
-
-DLLEXPORT tjhandle tjInitDecompress(void)
-{
- tjinstance *this;
-
- if ((this = (tjinstance *)malloc(sizeof(tjinstance))) == NULL) {
- SNPRINTF(errStr, JMSG_LENGTH_MAX,
- "tjInitDecompress(): Memory allocation failure");
- return NULL;
- }
- memset(this, 0, sizeof(tjinstance));
- SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "No error");
- return _tjInitDecompress(this);
-}
-
-
-DLLEXPORT int tjDecompressHeader3(tjhandle handle,
- const unsigned char *jpegBuf,
- unsigned long jpegSize, int *width,
- int *height, int *jpegSubsamp,
- int *jpegColorspace)
-{
- int retval = 0;
-
- GET_DINSTANCE(handle);
- if ((this->init & DECOMPRESS) == 0)
- THROW("tjDecompressHeader3(): Instance has not been initialized for decompression");
-
- if (jpegBuf == NULL || jpegSize <= 0 || width == NULL || height == NULL ||
- jpegSubsamp == NULL || jpegColorspace == NULL)
- THROW("tjDecompressHeader3(): Invalid argument");
-
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- return -1;
- }
-
- jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);
-
- /* jpeg_read_header() calls jpeg_abort() and returns JPEG_HEADER_TABLES_ONLY
- if the datastream is a tables-only datastream. Since we aren't using a
- suspending data source, the only other value it can return is
- JPEG_HEADER_OK. */
- if (jpeg_read_header(dinfo, FALSE) == JPEG_HEADER_TABLES_ONLY)
- return 0;
-
- *width = dinfo->image_width;
- *height = dinfo->image_height;
- *jpegSubsamp = getSubsamp(dinfo);
- switch (dinfo->jpeg_color_space) {
- case JCS_GRAYSCALE: *jpegColorspace = TJCS_GRAY; break;
- case JCS_RGB: *jpegColorspace = TJCS_RGB; break;
- case JCS_YCbCr: *jpegColorspace = TJCS_YCbCr; break;
- case JCS_CMYK: *jpegColorspace = TJCS_CMYK; break;
- case JCS_YCCK: *jpegColorspace = TJCS_YCCK; break;
- default: *jpegColorspace = -1; break;
- }
-
- jpeg_abort_decompress(dinfo);
-
- if (*jpegSubsamp < 0)
- THROW("tjDecompressHeader3(): Could not determine subsampling type for JPEG image");
- if (*jpegColorspace < 0)
- THROW("tjDecompressHeader3(): Could not determine colorspace of JPEG image");
- if (*width < 1 || *height < 1)
- THROW("tjDecompressHeader3(): Invalid data returned in header");
-
-bailout:
- if (this->jerr.warning) retval = -1;
- return retval;
-}
-
-DLLEXPORT int tjDecompressHeader2(tjhandle handle, unsigned char *jpegBuf,
- unsigned long jpegSize, int *width,
- int *height, int *jpegSubsamp)
-{
- int jpegColorspace;
-
- return tjDecompressHeader3(handle, jpegBuf, jpegSize, width, height,
- jpegSubsamp, &jpegColorspace);
-}
-
-DLLEXPORT int tjDecompressHeader(tjhandle handle, unsigned char *jpegBuf,
- unsigned long jpegSize, int *width,
- int *height)
-{
- int jpegSubsamp;
-
- return tjDecompressHeader2(handle, jpegBuf, jpegSize, width, height,
- &jpegSubsamp);
-}
-
-
-DLLEXPORT tjscalingfactor *tjGetScalingFactors(int *numscalingfactors)
-{
- if (numscalingfactors == NULL) {
- SNPRINTF(errStr, JMSG_LENGTH_MAX,
- "tjGetScalingFactors(): Invalid argument");
- return NULL;
- }
-
- *numscalingfactors = NUMSF;
- return (tjscalingfactor *)sf;
-}
-
-
-DLLEXPORT int tjDecompress2(tjhandle handle, const unsigned char *jpegBuf,
- unsigned long jpegSize, unsigned char *dstBuf,
- int width, int pitch, int height, int pixelFormat,
- int flags)
-{
- JSAMPROW *row_pointer = NULL;
- int i, retval = 0, jpegwidth, jpegheight, scaledw, scaledh;
- struct my_progress_mgr progress;
-
- GET_DINSTANCE(handle);
- this->jerr.stopOnWarning = (flags & TJFLAG_STOPONWARNING) ? TRUE : FALSE;
- if ((this->init & DECOMPRESS) == 0)
- THROW("tjDecompress2(): Instance has not been initialized for decompression");
-
- if (jpegBuf == NULL || jpegSize <= 0 || dstBuf == NULL || width < 0 ||
- pitch < 0 || height < 0 || pixelFormat < 0 || pixelFormat >= TJ_NUMPF)
- THROW("tjDecompress2(): Invalid argument");
-
-#ifndef NO_PUTENV
- if (flags & TJFLAG_FORCEMMX) PUTENV_S("JSIMD_FORCEMMX", "1");
- else if (flags & TJFLAG_FORCESSE) PUTENV_S("JSIMD_FORCESSE", "1");
- else if (flags & TJFLAG_FORCESSE2) PUTENV_S("JSIMD_FORCESSE2", "1");
-#endif
-
- if (flags & TJFLAG_LIMITSCANS) {
- memset(&progress, 0, sizeof(struct my_progress_mgr));
- progress.pub.progress_monitor = my_progress_monitor;
- progress.this = this;
- dinfo->progress = &progress.pub;
- } else
- dinfo->progress = NULL;
-
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- retval = -1; goto bailout;
- }
-
- jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);
- jpeg_read_header(dinfo, TRUE);
- this->dinfo.out_color_space = pf2cs[pixelFormat];
- if (flags & TJFLAG_FASTDCT) this->dinfo.dct_method = JDCT_FASTEST;
- if (flags & TJFLAG_FASTUPSAMPLE) dinfo->do_fancy_upsampling = FALSE;
-
- jpegwidth = dinfo->image_width; jpegheight = dinfo->image_height;
- if (width == 0) width = jpegwidth;
- if (height == 0) height = jpegheight;
- for (i = 0; i < NUMSF; i++) {
- scaledw = TJSCALED(jpegwidth, sf[i]);
- scaledh = TJSCALED(jpegheight, sf[i]);
- if (scaledw <= width && scaledh <= height)
- break;
- }
- if (i >= NUMSF)
- THROW("tjDecompress2(): Could not scale down to desired image dimensions");
- width = scaledw; height = scaledh;
- dinfo->scale_num = sf[i].num;
- dinfo->scale_denom = sf[i].denom;
-
- jpeg_start_decompress(dinfo);
- if (pitch == 0) pitch = dinfo->output_width * tjPixelSize[pixelFormat];
-
- if ((row_pointer =
- (JSAMPROW *)malloc(sizeof(JSAMPROW) * dinfo->output_height)) == NULL)
- THROW("tjDecompress2(): Memory allocation failure");
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- retval = -1; goto bailout;
- }
- for (i = 0; i < (int)dinfo->output_height; i++) {
- if (flags & TJFLAG_BOTTOMUP)
- row_pointer[i] = &dstBuf[(dinfo->output_height - i - 1) * (size_t)pitch];
- else
- row_pointer[i] = &dstBuf[i * (size_t)pitch];
- }
- while (dinfo->output_scanline < dinfo->output_height)
- jpeg_read_scanlines(dinfo, &row_pointer[dinfo->output_scanline],
- dinfo->output_height - dinfo->output_scanline);
- jpeg_finish_decompress(dinfo);
-
-bailout:
- if (dinfo->global_state > DSTATE_START) jpeg_abort_decompress(dinfo);
- free(row_pointer);
- if (this->jerr.warning) retval = -1;
- this->jerr.stopOnWarning = FALSE;
- return retval;
-}
-
-DLLEXPORT int tjDecompress(tjhandle handle, unsigned char *jpegBuf,
- unsigned long jpegSize, unsigned char *dstBuf,
- int width, int pitch, int height, int pixelSize,
- int flags)
-{
- if (flags & TJ_YUV)
- return tjDecompressToYUV(handle, jpegBuf, jpegSize, dstBuf, flags);
- else
- return tjDecompress2(handle, jpegBuf, jpegSize, dstBuf, width, pitch,
- height, getPixelFormat(pixelSize, flags), flags);
-}
-
-
-static int setDecodeDefaults(struct jpeg_decompress_struct *dinfo,
- int pixelFormat, int subsamp, int flags)
-{
- int i;
-
- dinfo->scale_num = dinfo->scale_denom = 1;
-
- if (subsamp == TJSAMP_GRAY) {
- dinfo->num_components = dinfo->comps_in_scan = 1;
- dinfo->jpeg_color_space = JCS_GRAYSCALE;
- } else {
- dinfo->num_components = dinfo->comps_in_scan = 3;
- dinfo->jpeg_color_space = JCS_YCbCr;
- }
-
- dinfo->comp_info = (jpeg_component_info *)
- (*dinfo->mem->alloc_small) ((j_common_ptr)dinfo, JPOOL_IMAGE,
- dinfo->num_components *
- sizeof(jpeg_component_info));
-
- for (i = 0; i < dinfo->num_components; i++) {
- jpeg_component_info *compptr = &dinfo->comp_info[i];
-
- compptr->h_samp_factor = (i == 0) ? tjMCUWidth[subsamp] / 8 : 1;
- compptr->v_samp_factor = (i == 0) ? tjMCUHeight[subsamp] / 8 : 1;
- compptr->component_index = i;
- compptr->component_id = i + 1;
- compptr->quant_tbl_no = compptr->dc_tbl_no =
- compptr->ac_tbl_no = (i == 0) ? 0 : 1;
- dinfo->cur_comp_info[i] = compptr;
- }
- dinfo->data_precision = 8;
- for (i = 0; i < 2; i++) {
- if (dinfo->quant_tbl_ptrs[i] == NULL)
- dinfo->quant_tbl_ptrs[i] = jpeg_alloc_quant_table((j_common_ptr)dinfo);
- }
-
- return 0;
-}
-
-
-static int my_read_markers(j_decompress_ptr dinfo)
-{
- return JPEG_REACHED_SOS;
-}
-
-static void my_reset_marker_reader(j_decompress_ptr dinfo)
-{
-}
-
-DLLEXPORT int tjDecodeYUVPlanes(tjhandle handle,
- const unsigned char **srcPlanes,
- const int *strides, int subsamp,
- unsigned char *dstBuf, int width, int pitch,
- int height, int pixelFormat, int flags)
-{
- JSAMPROW *row_pointer = NULL;
- JSAMPLE *_tmpbuf[MAX_COMPONENTS];
- JSAMPROW *tmpbuf[MAX_COMPONENTS], *inbuf[MAX_COMPONENTS];
- int i, retval = 0, row, pw0, ph0, pw[MAX_COMPONENTS], ph[MAX_COMPONENTS];
- JSAMPLE *ptr;
- jpeg_component_info *compptr;
- int (*old_read_markers) (j_decompress_ptr);
- void (*old_reset_marker_reader) (j_decompress_ptr);
-
- GET_DINSTANCE(handle);
- this->jerr.stopOnWarning = (flags & TJFLAG_STOPONWARNING) ? TRUE : FALSE;
-
- for (i = 0; i < MAX_COMPONENTS; i++) {
- tmpbuf[i] = NULL; _tmpbuf[i] = NULL; inbuf[i] = NULL;
- }
-
- if ((this->init & DECOMPRESS) == 0)
- THROW("tjDecodeYUVPlanes(): Instance has not been initialized for decompression");
-
- if (!srcPlanes || !srcPlanes[0] || subsamp < 0 || subsamp >= NUMSUBOPT ||
- dstBuf == NULL || width <= 0 || pitch < 0 || height <= 0 ||
- pixelFormat < 0 || pixelFormat >= TJ_NUMPF)
- THROW("tjDecodeYUVPlanes(): Invalid argument");
- if (subsamp != TJSAMP_GRAY && (!srcPlanes[1] || !srcPlanes[2]))
- THROW("tjDecodeYUVPlanes(): Invalid argument");
-
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- retval = -1; goto bailout;
- }
-
- if (pixelFormat == TJPF_CMYK)
- THROW("tjDecodeYUVPlanes(): Cannot decode YUV images into CMYK pixels.");
-
- if (pitch == 0) pitch = width * tjPixelSize[pixelFormat];
- dinfo->image_width = width;
- dinfo->image_height = height;
-
-#ifndef NO_PUTENV
- if (flags & TJFLAG_FORCEMMX) PUTENV_S("JSIMD_FORCEMMX", "1");
- else if (flags & TJFLAG_FORCESSE) PUTENV_S("JSIMD_FORCESSE", "1");
- else if (flags & TJFLAG_FORCESSE2) PUTENV_S("JSIMD_FORCESSE2", "1");
-#endif
-
- dinfo->progressive_mode = dinfo->inputctl->has_multiple_scans = FALSE;
- dinfo->Ss = dinfo->Ah = dinfo->Al = 0;
- dinfo->Se = DCTSIZE2 - 1;
- if (setDecodeDefaults(dinfo, pixelFormat, subsamp, flags) == -1) {
- retval = -1; goto bailout;
- }
- old_read_markers = dinfo->marker->read_markers;
- dinfo->marker->read_markers = my_read_markers;
- old_reset_marker_reader = dinfo->marker->reset_marker_reader;
- dinfo->marker->reset_marker_reader = my_reset_marker_reader;
- jpeg_read_header(dinfo, TRUE);
- dinfo->marker->read_markers = old_read_markers;
- dinfo->marker->reset_marker_reader = old_reset_marker_reader;
-
- this->dinfo.out_color_space = pf2cs[pixelFormat];
- if (flags & TJFLAG_FASTDCT) this->dinfo.dct_method = JDCT_FASTEST;
- dinfo->do_fancy_upsampling = FALSE;
- dinfo->Se = DCTSIZE2 - 1;
- jinit_master_decompress(dinfo);
- (*dinfo->upsample->start_pass) (dinfo);
-
- pw0 = PAD(width, dinfo->max_h_samp_factor);
- ph0 = PAD(height, dinfo->max_v_samp_factor);
-
- if (pitch == 0) pitch = dinfo->output_width * tjPixelSize[pixelFormat];
-
- if ((row_pointer = (JSAMPROW *)malloc(sizeof(JSAMPROW) * ph0)) == NULL)
- THROW("tjDecodeYUVPlanes(): Memory allocation failure");
- for (i = 0; i < height; i++) {
- if (flags & TJFLAG_BOTTOMUP)
- row_pointer[i] = &dstBuf[(height - i - 1) * (size_t)pitch];
- else
- row_pointer[i] = &dstBuf[i * (size_t)pitch];
- }
- if (height < ph0)
- for (i = height; i < ph0; i++) row_pointer[i] = row_pointer[height - 1];
-
- for (i = 0; i < dinfo->num_components; i++) {
- compptr = &dinfo->comp_info[i];
- _tmpbuf[i] =
- (JSAMPLE *)malloc(PAD(compptr->width_in_blocks * DCTSIZE, 32) *
- compptr->v_samp_factor + 32);
- if (!_tmpbuf[i])
- THROW("tjDecodeYUVPlanes(): Memory allocation failure");
- tmpbuf[i] = (JSAMPROW *)malloc(sizeof(JSAMPROW) * compptr->v_samp_factor);
- if (!tmpbuf[i])
- THROW("tjDecodeYUVPlanes(): Memory allocation failure");
- for (row = 0; row < compptr->v_samp_factor; row++) {
- unsigned char *_tmpbuf_aligned =
- (unsigned char *)PAD((JUINTPTR)_tmpbuf[i], 32);
-
- tmpbuf[i][row] =
- &_tmpbuf_aligned[PAD(compptr->width_in_blocks * DCTSIZE, 32) * row];
- }
- pw[i] = pw0 * compptr->h_samp_factor / dinfo->max_h_samp_factor;
- ph[i] = ph0 * compptr->v_samp_factor / dinfo->max_v_samp_factor;
- inbuf[i] = (JSAMPROW *)malloc(sizeof(JSAMPROW) * ph[i]);
- if (!inbuf[i])
- THROW("tjDecodeYUVPlanes(): Memory allocation failure");
- ptr = (JSAMPLE *)srcPlanes[i];
- for (row = 0; row < ph[i]; row++) {
- inbuf[i][row] = ptr;
- ptr += (strides && strides[i] != 0) ? strides[i] : pw[i];
- }
- }
-
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- retval = -1; goto bailout;
- }
-
- for (row = 0; row < ph0; row += dinfo->max_v_samp_factor) {
- JDIMENSION inrow = 0, outrow = 0;
-
- for (i = 0, compptr = dinfo->comp_info; i < dinfo->num_components;
- i++, compptr++)
- jcopy_sample_rows(inbuf[i],
- row * compptr->v_samp_factor / dinfo->max_v_samp_factor, tmpbuf[i], 0,
- compptr->v_samp_factor, pw[i]);
- (dinfo->upsample->upsample) (dinfo, tmpbuf, &inrow,
- dinfo->max_v_samp_factor, &row_pointer[row],
- &outrow, dinfo->max_v_samp_factor);
- }
- jpeg_abort_decompress(dinfo);
-
-bailout:
- if (dinfo->global_state > DSTATE_START) jpeg_abort_decompress(dinfo);
- free(row_pointer);
- for (i = 0; i < MAX_COMPONENTS; i++) {
- free(tmpbuf[i]);
- free(_tmpbuf[i]);
- free(inbuf[i]);
- }
- if (this->jerr.warning) retval = -1;
- this->jerr.stopOnWarning = FALSE;
- return retval;
-}
-
-DLLEXPORT int tjDecodeYUV(tjhandle handle, const unsigned char *srcBuf,
- int pad, int subsamp, unsigned char *dstBuf,
- int width, int pitch, int height, int pixelFormat,
- int flags)
-{
- const unsigned char *srcPlanes[3];
- int pw0, ph0, strides[3], retval = -1;
- tjinstance *this = (tjinstance *)handle;
-
- if (!this) THROWG("tjDecodeYUV(): Invalid handle");
- this->isInstanceError = FALSE;
-
- if (srcBuf == NULL || pad < 0 || !IS_POW2(pad) || subsamp < 0 ||
- subsamp >= NUMSUBOPT || width <= 0 || height <= 0)
- THROW("tjDecodeYUV(): Invalid argument");
-
- pw0 = tjPlaneWidth(0, width, subsamp);
- ph0 = tjPlaneHeight(0, height, subsamp);
- srcPlanes[0] = srcBuf;
- strides[0] = PAD(pw0, pad);
- if (subsamp == TJSAMP_GRAY) {
- strides[1] = strides[2] = 0;
- srcPlanes[1] = srcPlanes[2] = NULL;
- } else {
- int pw1 = tjPlaneWidth(1, width, subsamp);
- int ph1 = tjPlaneHeight(1, height, subsamp);
-
- strides[1] = strides[2] = PAD(pw1, pad);
- srcPlanes[1] = srcPlanes[0] + strides[0] * ph0;
- srcPlanes[2] = srcPlanes[1] + strides[1] * ph1;
- }
-
- return tjDecodeYUVPlanes(handle, srcPlanes, strides, subsamp, dstBuf, width,
- pitch, height, pixelFormat, flags);
-
-bailout:
- return retval;
-}
-
-DLLEXPORT int tjDecompressToYUVPlanes(tjhandle handle,
- const unsigned char *jpegBuf,
- unsigned long jpegSize,
- unsigned char **dstPlanes, int width,
- int *strides, int height, int flags)
-{
- int i, sfi, row, retval = 0;
- int jpegwidth, jpegheight, jpegSubsamp, scaledw, scaledh;
- int pw[MAX_COMPONENTS], ph[MAX_COMPONENTS], iw[MAX_COMPONENTS],
- tmpbufsize = 0, usetmpbuf = 0, th[MAX_COMPONENTS];
- JSAMPLE *_tmpbuf = NULL, *ptr;
- JSAMPROW *outbuf[MAX_COMPONENTS], *tmpbuf[MAX_COMPONENTS];
- int dctsize;
- struct my_progress_mgr progress;
-
- GET_DINSTANCE(handle);
- this->jerr.stopOnWarning = (flags & TJFLAG_STOPONWARNING) ? TRUE : FALSE;
-
- for (i = 0; i < MAX_COMPONENTS; i++) {
- tmpbuf[i] = NULL; outbuf[i] = NULL;
- }
-
- if ((this->init & DECOMPRESS) == 0)
- THROW("tjDecompressToYUVPlanes(): Instance has not been initialized for decompression");
-
- if (jpegBuf == NULL || jpegSize <= 0 || !dstPlanes || !dstPlanes[0] ||
- width < 0 || height < 0)
- THROW("tjDecompressToYUVPlanes(): Invalid argument");
-
-#ifndef NO_PUTENV
- if (flags & TJFLAG_FORCEMMX) PUTENV_S("JSIMD_FORCEMMX", "1");
- else if (flags & TJFLAG_FORCESSE) PUTENV_S("JSIMD_FORCESSE", "1");
- else if (flags & TJFLAG_FORCESSE2) PUTENV_S("JSIMD_FORCESSE2", "1");
-#endif
-
- if (flags & TJFLAG_LIMITSCANS) {
- memset(&progress, 0, sizeof(struct my_progress_mgr));
- progress.pub.progress_monitor = my_progress_monitor;
- progress.this = this;
- dinfo->progress = &progress.pub;
- } else
- dinfo->progress = NULL;
-
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- retval = -1; goto bailout;
- }
-
- if (!this->headerRead) {
- jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);
- jpeg_read_header(dinfo, TRUE);
- }
- this->headerRead = 0;
- jpegSubsamp = getSubsamp(dinfo);
- if (jpegSubsamp < 0)
- THROW("tjDecompressToYUVPlanes(): Could not determine subsampling type for JPEG image");
-
- if (jpegSubsamp != TJSAMP_GRAY && (!dstPlanes[1] || !dstPlanes[2]))
- THROW("tjDecompressToYUVPlanes(): Invalid argument");
-
- jpegwidth = dinfo->image_width; jpegheight = dinfo->image_height;
- if (width == 0) width = jpegwidth;
- if (height == 0) height = jpegheight;
- for (i = 0; i < NUMSF; i++) {
- scaledw = TJSCALED(jpegwidth, sf[i]);
- scaledh = TJSCALED(jpegheight, sf[i]);
- if (scaledw <= width && scaledh <= height)
- break;
- }
- if (i >= NUMSF)
- THROW("tjDecompressToYUVPlanes(): Could not scale down to desired image dimensions");
- if (dinfo->num_components > 3)
- THROW("tjDecompressToYUVPlanes(): JPEG image must have 3 or fewer components");
-
- width = scaledw; height = scaledh;
- dinfo->scale_num = sf[i].num;
- dinfo->scale_denom = sf[i].denom;
- sfi = i;
- jpeg_calc_output_dimensions(dinfo);
-
- dctsize = DCTSIZE * sf[sfi].num / sf[sfi].denom;
-
- for (i = 0; i < dinfo->num_components; i++) {
- jpeg_component_info *compptr = &dinfo->comp_info[i];
- int ih;
-
- iw[i] = compptr->width_in_blocks * dctsize;
- ih = compptr->height_in_blocks * dctsize;
- pw[i] = tjPlaneWidth(i, dinfo->output_width, jpegSubsamp);
- ph[i] = tjPlaneHeight(i, dinfo->output_height, jpegSubsamp);
- if (iw[i] != pw[i] || ih != ph[i]) usetmpbuf = 1;
- th[i] = compptr->v_samp_factor * dctsize;
- tmpbufsize += iw[i] * th[i];
- if ((outbuf[i] = (JSAMPROW *)malloc(sizeof(JSAMPROW) * ph[i])) == NULL)
- THROW("tjDecompressToYUVPlanes(): Memory allocation failure");
- ptr = dstPlanes[i];
- for (row = 0; row < ph[i]; row++) {
- outbuf[i][row] = ptr;
- ptr += (strides && strides[i] != 0) ? strides[i] : pw[i];
- }
- }
- if (usetmpbuf) {
- if ((_tmpbuf = (JSAMPLE *)malloc(sizeof(JSAMPLE) * tmpbufsize)) == NULL)
- THROW("tjDecompressToYUVPlanes(): Memory allocation failure");
- ptr = _tmpbuf;
- for (i = 0; i < dinfo->num_components; i++) {
- if ((tmpbuf[i] = (JSAMPROW *)malloc(sizeof(JSAMPROW) * th[i])) == NULL)
- THROW("tjDecompressToYUVPlanes(): Memory allocation failure");
- for (row = 0; row < th[i]; row++) {
- tmpbuf[i][row] = ptr;
- ptr += iw[i];
- }
- }
- }
-
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- retval = -1; goto bailout;
- }
-
- if (flags & TJFLAG_FASTUPSAMPLE) dinfo->do_fancy_upsampling = FALSE;
- if (flags & TJFLAG_FASTDCT) dinfo->dct_method = JDCT_FASTEST;
- dinfo->raw_data_out = TRUE;
-
- jpeg_start_decompress(dinfo);
- for (row = 0; row < (int)dinfo->output_height;
- row += dinfo->max_v_samp_factor * dinfo->_min_DCT_scaled_size) {
- JSAMPARRAY yuvptr[MAX_COMPONENTS];
- int crow[MAX_COMPONENTS];
-
- for (i = 0; i < dinfo->num_components; i++) {
- jpeg_component_info *compptr = &dinfo->comp_info[i];
-
- if (jpegSubsamp == TJ_420) {
- /* When 4:2:0 subsampling is used with IDCT scaling, libjpeg will try
- to be clever and use the IDCT to perform upsampling on the U and V
- planes. For instance, if the output image is to be scaled by 1/2
- relative to the JPEG image, then the scaling factor and upsampling
- effectively cancel each other, so a normal 8x8 IDCT can be used.
- However, this is not desirable when using the decompress-to-YUV
- functionality in TurboJPEG, since we want to output the U and V
- planes in their subsampled form. Thus, we have to override some
- internal libjpeg parameters to force it to use the "scaled" IDCT
- functions on the U and V planes. */
- compptr->_DCT_scaled_size = dctsize;
- compptr->MCU_sample_width = tjMCUWidth[jpegSubsamp] *
- sf[sfi].num / sf[sfi].denom *
- compptr->v_samp_factor / dinfo->max_v_samp_factor;
- dinfo->idct->inverse_DCT[i] = dinfo->idct->inverse_DCT[0];
- }
- crow[i] = row * compptr->v_samp_factor / dinfo->max_v_samp_factor;
- if (usetmpbuf) yuvptr[i] = tmpbuf[i];
- else yuvptr[i] = &outbuf[i][crow[i]];
- }
- jpeg_read_raw_data(dinfo, yuvptr,
- dinfo->max_v_samp_factor * dinfo->_min_DCT_scaled_size);
- if (usetmpbuf) {
- int j;
-
- for (i = 0; i < dinfo->num_components; i++) {
- for (j = 0; j < MIN(th[i], ph[i] - crow[i]); j++) {
- memcpy(outbuf[i][crow[i] + j], tmpbuf[i][j], pw[i]);
- }
- }
- }
- }
- jpeg_finish_decompress(dinfo);
-
-bailout:
- if (dinfo->global_state > DSTATE_START) jpeg_abort_decompress(dinfo);
- for (i = 0; i < MAX_COMPONENTS; i++) {
- free(tmpbuf[i]);
- free(outbuf[i]);
- }
- free(_tmpbuf);
- if (this->jerr.warning) retval = -1;
- this->jerr.stopOnWarning = FALSE;
- return retval;
-}
-
-DLLEXPORT int tjDecompressToYUV2(tjhandle handle, const unsigned char *jpegBuf,
- unsigned long jpegSize, unsigned char *dstBuf,
- int width, int pad, int height, int flags)
-{
- unsigned char *dstPlanes[3];
- int pw0, ph0, strides[3], retval = -1, jpegSubsamp = -1;
- int i, jpegwidth, jpegheight, scaledw, scaledh;
-
- GET_DINSTANCE(handle);
- this->jerr.stopOnWarning = (flags & TJFLAG_STOPONWARNING) ? TRUE : FALSE;
-
- if (jpegBuf == NULL || jpegSize <= 0 || dstBuf == NULL || width < 0 ||
- pad < 1 || !IS_POW2(pad) || height < 0)
- THROW("tjDecompressToYUV2(): Invalid argument");
-
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- return -1;
- }
-
- jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);
- jpeg_read_header(dinfo, TRUE);
- jpegSubsamp = getSubsamp(dinfo);
- if (jpegSubsamp < 0)
- THROW("tjDecompressToYUV2(): Could not determine subsampling type for JPEG image");
-
- jpegwidth = dinfo->image_width; jpegheight = dinfo->image_height;
- if (width == 0) width = jpegwidth;
- if (height == 0) height = jpegheight;
-
- for (i = 0; i < NUMSF; i++) {
- scaledw = TJSCALED(jpegwidth, sf[i]);
- scaledh = TJSCALED(jpegheight, sf[i]);
- if (scaledw <= width && scaledh <= height)
- break;
- }
- if (i >= NUMSF)
- THROW("tjDecompressToYUV2(): Could not scale down to desired image dimensions");
-
- pw0 = tjPlaneWidth(0, width, jpegSubsamp);
- ph0 = tjPlaneHeight(0, height, jpegSubsamp);
- dstPlanes[0] = dstBuf;
- strides[0] = PAD(pw0, pad);
- if (jpegSubsamp == TJSAMP_GRAY) {
- strides[1] = strides[2] = 0;
- dstPlanes[1] = dstPlanes[2] = NULL;
- } else {
- int pw1 = tjPlaneWidth(1, width, jpegSubsamp);
- int ph1 = tjPlaneHeight(1, height, jpegSubsamp);
-
- strides[1] = strides[2] = PAD(pw1, pad);
- dstPlanes[1] = dstPlanes[0] + strides[0] * ph0;
- dstPlanes[2] = dstPlanes[1] + strides[1] * ph1;
- }
-
- this->headerRead = 1;
- return tjDecompressToYUVPlanes(handle, jpegBuf, jpegSize, dstPlanes, width,
- strides, height, flags);
-
-bailout:
- this->jerr.stopOnWarning = FALSE;
- return retval;
-}
-
-DLLEXPORT int tjDecompressToYUV(tjhandle handle, unsigned char *jpegBuf,
- unsigned long jpegSize, unsigned char *dstBuf,
- int flags)
-{
- return tjDecompressToYUV2(handle, jpegBuf, jpegSize, dstBuf, 0, 4, 0, flags);
-}
-
-
-/* Transformer */
-
-DLLEXPORT tjhandle tjInitTransform(void)
-{
- tjinstance *this = NULL;
- tjhandle handle = NULL;
-
- if ((this = (tjinstance *)malloc(sizeof(tjinstance))) == NULL) {
- SNPRINTF(errStr, JMSG_LENGTH_MAX,
- "tjInitTransform(): Memory allocation failure");
- return NULL;
- }
- memset(this, 0, sizeof(tjinstance));
- SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "No error");
- handle = _tjInitCompress(this);
- if (!handle) return NULL;
- handle = _tjInitDecompress(this);
- return handle;
-}
-
-
-DLLEXPORT int tjTransform(tjhandle handle, const unsigned char *jpegBuf,
- unsigned long jpegSize, int n,
- unsigned char **dstBufs, unsigned long *dstSizes,
- tjtransform *t, int flags)
-{
- jpeg_transform_info *xinfo = NULL;
- jvirt_barray_ptr *srccoefs, *dstcoefs;
- int retval = 0, i, jpegSubsamp, saveMarkers = 0;
- boolean alloc = TRUE;
- struct my_progress_mgr progress;
-
- GET_INSTANCE(handle);
- this->jerr.stopOnWarning = (flags & TJFLAG_STOPONWARNING) ? TRUE : FALSE;
- if ((this->init & COMPRESS) == 0 || (this->init & DECOMPRESS) == 0)
- THROW("tjTransform(): Instance has not been initialized for transformation");
-
- if (jpegBuf == NULL || jpegSize <= 0 || n < 1 || dstBufs == NULL ||
- dstSizes == NULL || t == NULL || flags < 0)
- THROW("tjTransform(): Invalid argument");
-
-#ifndef NO_PUTENV
- if (flags & TJFLAG_FORCEMMX) PUTENV_S("JSIMD_FORCEMMX", "1");
- else if (flags & TJFLAG_FORCESSE) PUTENV_S("JSIMD_FORCESSE", "1");
- else if (flags & TJFLAG_FORCESSE2) PUTENV_S("JSIMD_FORCESSE2", "1");
-#endif
-
- if (flags & TJFLAG_LIMITSCANS) {
- memset(&progress, 0, sizeof(struct my_progress_mgr));
- progress.pub.progress_monitor = my_progress_monitor;
- progress.this = this;
- dinfo->progress = &progress.pub;
- } else
- dinfo->progress = NULL;
-
- if ((xinfo =
- (jpeg_transform_info *)malloc(sizeof(jpeg_transform_info) * n)) == NULL)
- THROW("tjTransform(): Memory allocation failure");
- memset(xinfo, 0, sizeof(jpeg_transform_info) * n);
-
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- retval = -1; goto bailout;
- }
-
- jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);
-
- for (i = 0; i < n; i++) {
- xinfo[i].transform = xformtypes[t[i].op];
- xinfo[i].perfect = (t[i].options & TJXOPT_PERFECT) ? 1 : 0;
- xinfo[i].trim = (t[i].options & TJXOPT_TRIM) ? 1 : 0;
- xinfo[i].force_grayscale = (t[i].options & TJXOPT_GRAY) ? 1 : 0;
- xinfo[i].crop = (t[i].options & TJXOPT_CROP) ? 1 : 0;
- if (n != 1 && t[i].op == TJXOP_HFLIP) xinfo[i].slow_hflip = 1;
- else xinfo[i].slow_hflip = 0;
-
- if (xinfo[i].crop) {
- xinfo[i].crop_xoffset = t[i].r.x; xinfo[i].crop_xoffset_set = JCROP_POS;
- xinfo[i].crop_yoffset = t[i].r.y; xinfo[i].crop_yoffset_set = JCROP_POS;
- if (t[i].r.w != 0) {
- xinfo[i].crop_width = t[i].r.w; xinfo[i].crop_width_set = JCROP_POS;
- } else
- xinfo[i].crop_width = JCROP_UNSET;
- if (t[i].r.h != 0) {
- xinfo[i].crop_height = t[i].r.h; xinfo[i].crop_height_set = JCROP_POS;
- } else
- xinfo[i].crop_height = JCROP_UNSET;
- }
- if (!(t[i].options & TJXOPT_COPYNONE)) saveMarkers = 1;
- }
-
- jcopy_markers_setup(dinfo, saveMarkers ? JCOPYOPT_ALL : JCOPYOPT_NONE);
- jpeg_read_header(dinfo, TRUE);
- jpegSubsamp = getSubsamp(dinfo);
- if (jpegSubsamp < 0)
- THROW("tjTransform(): Could not determine subsampling type for JPEG image");
-
- for (i = 0; i < n; i++) {
- if (!jtransform_request_workspace(dinfo, &xinfo[i]))
- THROW("tjTransform(): Transform is not perfect");
-
- if (xinfo[i].crop) {
- if ((t[i].r.x % tjMCUWidth[jpegSubsamp]) != 0 ||
- (t[i].r.y % tjMCUHeight[jpegSubsamp]) != 0) {
- SNPRINTF(this->errStr, JMSG_LENGTH_MAX,
- "To crop this JPEG image, x must be a multiple of %d\n"
- "and y must be a multiple of %d.\n",
- tjMCUWidth[jpegSubsamp], tjMCUHeight[jpegSubsamp]);
- this->isInstanceError = TRUE;
- retval = -1; goto bailout;
- }
- }
- }
-
- srccoefs = jpeg_read_coefficients(dinfo);
-
- for (i = 0; i < n; i++) {
- int w, h;
-
- if (!xinfo[i].crop) {
- w = dinfo->image_width; h = dinfo->image_height;
- } else {
- w = xinfo[i].crop_width; h = xinfo[i].crop_height;
- }
- if (flags & TJFLAG_NOREALLOC) {
- alloc = FALSE; dstSizes[i] = tjBufSize(w, h, jpegSubsamp);
- }
- if (!(t[i].options & TJXOPT_NOOUTPUT))
- jpeg_mem_dest_tj(cinfo, &dstBufs[i], &dstSizes[i], alloc);
- jpeg_copy_critical_parameters(dinfo, cinfo);
- dstcoefs = jtransform_adjust_parameters(dinfo, cinfo, srccoefs, &xinfo[i]);
- if (flags & TJFLAG_PROGRESSIVE || t[i].options & TJXOPT_PROGRESSIVE)
- jpeg_simple_progression(cinfo);
- if (!(t[i].options & TJXOPT_NOOUTPUT)) {
- jpeg_write_coefficients(cinfo, dstcoefs);
- jcopy_markers_execute(dinfo, cinfo, t[i].options & TJXOPT_COPYNONE ?
- JCOPYOPT_NONE : JCOPYOPT_ALL);
- } else
- jinit_c_master_control(cinfo, TRUE);
- jtransform_execute_transformation(dinfo, cinfo, srccoefs, &xinfo[i]);
- if (t[i].customFilter) {
- int ci, y;
- JDIMENSION by;
-
- for (ci = 0; ci < cinfo->num_components; ci++) {
- jpeg_component_info *compptr = &cinfo->comp_info[ci];
- tjregion arrayRegion = { 0, 0, 0, 0 };
- tjregion planeRegion = { 0, 0, 0, 0 };
-
- arrayRegion.w = compptr->width_in_blocks * DCTSIZE;
- arrayRegion.h = DCTSIZE;
- planeRegion.w = compptr->width_in_blocks * DCTSIZE;
- planeRegion.h = compptr->height_in_blocks * DCTSIZE;
-
- for (by = 0; by < compptr->height_in_blocks;
- by += compptr->v_samp_factor) {
- JBLOCKARRAY barray = (dinfo->mem->access_virt_barray)
- ((j_common_ptr)dinfo, dstcoefs[ci], by, compptr->v_samp_factor,
- TRUE);
-
- for (y = 0; y < compptr->v_samp_factor; y++) {
- if (t[i].customFilter(barray[y][0], arrayRegion, planeRegion, ci,
- i, &t[i]) == -1)
- THROW("tjTransform(): Error in custom filter");
- arrayRegion.y += DCTSIZE;
- }
- }
- }
- }
- if (!(t[i].options & TJXOPT_NOOUTPUT)) jpeg_finish_compress(cinfo);
- }
-
- jpeg_finish_decompress(dinfo);
-
-bailout:
- if (cinfo->global_state > CSTATE_START) {
- if (alloc) (*cinfo->dest->term_destination) (cinfo);
- jpeg_abort_compress(cinfo);
- }
- if (dinfo->global_state > DSTATE_START) jpeg_abort_decompress(dinfo);
- free(xinfo);
- if (this->jerr.warning) retval = -1;
- this->jerr.stopOnWarning = FALSE;
- return retval;
-}
-
-
-DLLEXPORT unsigned char *tjLoadImage(const char *filename, int *width,
- int align, int *height, int *pixelFormat,
- int flags)
-{
- int retval = 0, tempc;
- size_t pitch;
- tjhandle handle = NULL;
- tjinstance *this;
- j_compress_ptr cinfo = NULL;
- cjpeg_source_ptr src;
- unsigned char *dstBuf = NULL;
- FILE *file = NULL;
- boolean invert;
-
- if (!filename || !width || align < 1 || !height || !pixelFormat ||
- *pixelFormat < TJPF_UNKNOWN || *pixelFormat >= TJ_NUMPF)
- THROWG("tjLoadImage(): Invalid argument");
- if ((align & (align - 1)) != 0)
- THROWG("tjLoadImage(): Alignment must be a power of 2");
-
- if ((handle = tjInitCompress()) == NULL) return NULL;
- this = (tjinstance *)handle;
- cinfo = &this->cinfo;
-
-#ifdef _MSC_VER
- if (fopen_s(&file, filename, "rb") || file == NULL)
-#else
- if ((file = fopen(filename, "rb")) == NULL)
-#endif
- THROW_UNIX("tjLoadImage(): Cannot open input file");
-
- if ((tempc = getc(file)) < 0 || ungetc(tempc, file) == EOF)
- THROW_UNIX("tjLoadImage(): Could not read input file")
- else if (tempc == EOF)
- THROWG("tjLoadImage(): Input file contains no data");
-
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- retval = -1; goto bailout;
- }
-
- if (*pixelFormat == TJPF_UNKNOWN) cinfo->in_color_space = JCS_UNKNOWN;
- else cinfo->in_color_space = pf2cs[*pixelFormat];
- if (tempc == 'B') {
- if ((src = jinit_read_bmp(cinfo, FALSE)) == NULL)
- THROWG("tjLoadImage(): Could not initialize bitmap loader");
- invert = (flags & TJFLAG_BOTTOMUP) == 0;
- } else if (tempc == 'P') {
- if ((src = jinit_read_ppm(cinfo)) == NULL)
- THROWG("tjLoadImage(): Could not initialize bitmap loader");
- invert = (flags & TJFLAG_BOTTOMUP) != 0;
- } else
- THROWG("tjLoadImage(): Unsupported file type");
-
- src->input_file = file;
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
- /* Refuse to load images larger than 1 Megapixel when fuzzing. */
- if (flags & TJFLAG_FUZZING)
- src->max_pixels = 1048576;
-#endif
- (*src->start_input) (cinfo, src);
- (*cinfo->mem->realize_virt_arrays) ((j_common_ptr)cinfo);
-
- *width = cinfo->image_width; *height = cinfo->image_height;
- *pixelFormat = cs2pf[cinfo->in_color_space];
-
- pitch = PAD((*width) * tjPixelSize[*pixelFormat], align);
- if ((unsigned long long)pitch * (unsigned long long)(*height) >
- (unsigned long long)((size_t)-1) ||
- (dstBuf = (unsigned char *)malloc(pitch * (*height))) == NULL)
- THROWG("tjLoadImage(): Memory allocation failure");
-
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- retval = -1; goto bailout;
- }
-
- while (cinfo->next_scanline < cinfo->image_height) {
- int i, nlines = (*src->get_pixel_rows) (cinfo, src);
-
- for (i = 0; i < nlines; i++) {
- unsigned char *dstptr;
- int row;
-
- row = cinfo->next_scanline + i;
- if (invert) dstptr = &dstBuf[((*height) - row - 1) * pitch];
- else dstptr = &dstBuf[row * pitch];
- memcpy(dstptr, src->buffer[i], (*width) * tjPixelSize[*pixelFormat]);
- }
- cinfo->next_scanline += nlines;
- }
-
- (*src->finish_input) (cinfo, src);
-
-bailout:
- if (handle) tjDestroy(handle);
- if (file) fclose(file);
- if (retval < 0) { free(dstBuf); dstBuf = NULL; }
- return dstBuf;
-}
-
-
-DLLEXPORT int tjSaveImage(const char *filename, unsigned char *buffer,
- int width, int pitch, int height, int pixelFormat,
- int flags)
-{
- int retval = 0;
- tjhandle handle = NULL;
- tjinstance *this;
- j_decompress_ptr dinfo = NULL;
- djpeg_dest_ptr dst;
- FILE *file = NULL;
- char *ptr = NULL;
- boolean invert;
-
- if (!filename || !buffer || width < 1 || pitch < 0 || height < 1 ||
- pixelFormat < 0 || pixelFormat >= TJ_NUMPF)
- THROWG("tjSaveImage(): Invalid argument");
-
- if ((handle = tjInitDecompress()) == NULL)
- return -1;
- this = (tjinstance *)handle;
- dinfo = &this->dinfo;
-
-#ifdef _MSC_VER
- if (fopen_s(&file, filename, "wb") || file == NULL)
-#else
- if ((file = fopen(filename, "wb")) == NULL)
-#endif
- THROW_UNIX("tjSaveImage(): Cannot open output file");
-
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- retval = -1; goto bailout;
- }
-
- this->dinfo.out_color_space = pf2cs[pixelFormat];
- dinfo->image_width = width; dinfo->image_height = height;
- dinfo->global_state = DSTATE_READY;
- dinfo->scale_num = dinfo->scale_denom = 1;
-
- ptr = strrchr(filename, '.');
- if (ptr && !strcasecmp(ptr, ".bmp")) {
- if ((dst = jinit_write_bmp(dinfo, FALSE, FALSE)) == NULL)
- THROWG("tjSaveImage(): Could not initialize bitmap writer");
- invert = (flags & TJFLAG_BOTTOMUP) == 0;
- } else {
- if ((dst = jinit_write_ppm(dinfo)) == NULL)
- THROWG("tjSaveImage(): Could not initialize PPM writer");
- invert = (flags & TJFLAG_BOTTOMUP) != 0;
- }
-
- dst->output_file = file;
- (*dst->start_output) (dinfo, dst);
- (*dinfo->mem->realize_virt_arrays) ((j_common_ptr)dinfo);
-
- if (pitch == 0) pitch = width * tjPixelSize[pixelFormat];
-
- while (dinfo->output_scanline < dinfo->output_height) {
- unsigned char *rowptr;
-
- if (invert)
- rowptr = &buffer[(height - dinfo->output_scanline - 1) * pitch];
- else
- rowptr = &buffer[dinfo->output_scanline * pitch];
- memcpy(dst->buffer[0], rowptr, width * tjPixelSize[pixelFormat]);
- (*dst->put_pixel_rows) (dinfo, dst, 1);
- dinfo->output_scanline++;
- }
-
- (*dst->finish_output) (dinfo, dst);
-
-bailout:
- if (handle) tjDestroy(handle);
- if (file) fclose(file);
- return retval;
-}
diff --git a/contrib/libs/libjpeg-turbo/turbojpeg.h b/contrib/libs/libjpeg-turbo/turbojpeg.h
deleted file mode 100644
index 02b54ca99c..0000000000
--- a/contrib/libs/libjpeg-turbo/turbojpeg.h
+++ /dev/null
@@ -1,1767 +0,0 @@
-/*
- * Copyright (C)2009-2015, 2017, 2020-2021 D. R. Commander.
- * All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * - Neither the name of the libjpeg-turbo Project nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS",
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __TURBOJPEG_H__
-#define __TURBOJPEG_H__
-
-#if defined(_WIN32) && defined(DLLDEFINE)
-#define DLLEXPORT __declspec(dllexport)
-#else
-#define DLLEXPORT
-#endif
-#define DLLCALL
-
-
-/**
- * @addtogroup TurboJPEG
- * TurboJPEG API. This API provides an interface for generating, decoding, and
- * transforming planar YUV and JPEG images in memory.
- *
- * @anchor YUVnotes
- * YUV Image Format Notes
- * ----------------------
- * Technically, the JPEG format uses the YCbCr colorspace (which is technically
- * not a colorspace but a color transform), but per the convention of the
- * digital video community, the TurboJPEG API uses "YUV" to refer to an image
- * format consisting of Y, Cb, and Cr image planes.
- *
- * Each plane is simply a 2D array of bytes, each byte representing the value
- * of one of the components (Y, Cb, or Cr) at a particular location in the
- * image. The width and height of each plane are determined by the image
- * width, height, and level of chrominance subsampling. The luminance plane
- * width is the image width padded to the nearest multiple of the horizontal
- * subsampling factor (2 in the case of 4:2:0 and 4:2:2, 4 in the case of
- * 4:1:1, 1 in the case of 4:4:4 or grayscale.) Similarly, the luminance plane
- * height is the image height padded to the nearest multiple of the vertical
- * subsampling factor (2 in the case of 4:2:0 or 4:4:0, 1 in the case of 4:4:4
- * or grayscale.) This is irrespective of any additional padding that may be
- * specified as an argument to the various YUV functions. The chrominance
- * plane width is equal to the luminance plane width divided by the horizontal
- * subsampling factor, and the chrominance plane height is equal to the
- * luminance plane height divided by the vertical subsampling factor.
- *
- * For example, if the source image is 35 x 35 pixels and 4:2:2 subsampling is
- * used, then the luminance plane would be 36 x 35 bytes, and each of the
- * chrominance planes would be 18 x 35 bytes. If you specify a line padding of
- * 4 bytes on top of this, then the luminance plane would be 36 x 35 bytes, and
- * each of the chrominance planes would be 20 x 35 bytes.
- *
- * @{
- */
-
-
-/**
- * The number of chrominance subsampling options
- */
-#define TJ_NUMSAMP 6
-
-/**
- * Chrominance subsampling options.
- * When pixels are converted from RGB to YCbCr (see #TJCS_YCbCr) or from CMYK
- * to YCCK (see #TJCS_YCCK) as part of the JPEG compression process, some of
- * the Cb and Cr (chrominance) components can be discarded or averaged together
- * to produce a smaller image with little perceptible loss of image clarity
- * (the human eye is more sensitive to small changes in brightness than to
- * small changes in color.) This is called "chrominance subsampling".
- */
-enum TJSAMP {
- /**
- * 4:4:4 chrominance subsampling (no chrominance subsampling). The JPEG or
- * YUV image will contain one chrominance component for every pixel in the
- * source image.
- */
- TJSAMP_444 = 0,
- /**
- * 4:2:2 chrominance subsampling. The JPEG or YUV image will contain one
- * chrominance component for every 2x1 block of pixels in the source image.
- */
- TJSAMP_422,
- /**
- * 4:2:0 chrominance subsampling. The JPEG or YUV image will contain one
- * chrominance component for every 2x2 block of pixels in the source image.
- */
- TJSAMP_420,
- /**
- * Grayscale. The JPEG or YUV image will contain no chrominance components.
- */
- TJSAMP_GRAY,
- /**
- * 4:4:0 chrominance subsampling. The JPEG or YUV image will contain one
- * chrominance component for every 1x2 block of pixels in the source image.
- *
- * @note 4:4:0 subsampling is not fully accelerated in libjpeg-turbo.
- */
- TJSAMP_440,
- /**
- * 4:1:1 chrominance subsampling. The JPEG or YUV image will contain one
- * chrominance component for every 4x1 block of pixels in the source image.
- * JPEG images compressed with 4:1:1 subsampling will be almost exactly the
- * same size as those compressed with 4:2:0 subsampling, and in the
- * aggregate, both subsampling methods produce approximately the same
- * perceptual quality. However, 4:1:1 is better able to reproduce sharp
- * horizontal features.
- *
- * @note 4:1:1 subsampling is not fully accelerated in libjpeg-turbo.
- */
- TJSAMP_411
-};
-
-/**
- * MCU block width (in pixels) for a given level of chrominance subsampling.
- * MCU block sizes:
- * - 8x8 for no subsampling or grayscale
- * - 16x8 for 4:2:2
- * - 8x16 for 4:4:0
- * - 16x16 for 4:2:0
- * - 32x8 for 4:1:1
- */
-static const int tjMCUWidth[TJ_NUMSAMP] = { 8, 16, 16, 8, 8, 32 };
-
-/**
- * MCU block height (in pixels) for a given level of chrominance subsampling.
- * MCU block sizes:
- * - 8x8 for no subsampling or grayscale
- * - 16x8 for 4:2:2
- * - 8x16 for 4:4:0
- * - 16x16 for 4:2:0
- * - 32x8 for 4:1:1
- */
-static const int tjMCUHeight[TJ_NUMSAMP] = { 8, 8, 16, 8, 16, 8 };
-
-
-/**
- * The number of pixel formats
- */
-#define TJ_NUMPF 12
-
-/**
- * Pixel formats
- */
-enum TJPF {
- /**
- * RGB pixel format. The red, green, and blue components in the image are
- * stored in 3-byte pixels in the order R, G, B from lowest to highest byte
- * address within each pixel.
- */
- TJPF_RGB = 0,
- /**
- * BGR pixel format. The red, green, and blue components in the image are
- * stored in 3-byte pixels in the order B, G, R from lowest to highest byte
- * address within each pixel.
- */
- TJPF_BGR,
- /**
- * RGBX pixel format. The red, green, and blue components in the image are
- * stored in 4-byte pixels in the order R, G, B from lowest to highest byte
- * address within each pixel. The X component is ignored when compressing
- * and undefined when decompressing.
- */
- TJPF_RGBX,
- /**
- * BGRX pixel format. The red, green, and blue components in the image are
- * stored in 4-byte pixels in the order B, G, R from lowest to highest byte
- * address within each pixel. The X component is ignored when compressing
- * and undefined when decompressing.
- */
- TJPF_BGRX,
- /**
- * XBGR pixel format. The red, green, and blue components in the image are
- * stored in 4-byte pixels in the order R, G, B from highest to lowest byte
- * address within each pixel. The X component is ignored when compressing
- * and undefined when decompressing.
- */
- TJPF_XBGR,
- /**
- * XRGB pixel format. The red, green, and blue components in the image are
- * stored in 4-byte pixels in the order B, G, R from highest to lowest byte
- * address within each pixel. The X component is ignored when compressing
- * and undefined when decompressing.
- */
- TJPF_XRGB,
- /**
- * Grayscale pixel format. Each 1-byte pixel represents a luminance
- * (brightness) level from 0 to 255.
- */
- TJPF_GRAY,
- /**
- * RGBA pixel format. This is the same as @ref TJPF_RGBX, except that when
- * decompressing, the X component is guaranteed to be 0xFF, which can be
- * interpreted as an opaque alpha channel.
- */
- TJPF_RGBA,
- /**
- * BGRA pixel format. This is the same as @ref TJPF_BGRX, except that when
- * decompressing, the X component is guaranteed to be 0xFF, which can be
- * interpreted as an opaque alpha channel.
- */
- TJPF_BGRA,
- /**
- * ABGR pixel format. This is the same as @ref TJPF_XBGR, except that when
- * decompressing, the X component is guaranteed to be 0xFF, which can be
- * interpreted as an opaque alpha channel.
- */
- TJPF_ABGR,
- /**
- * ARGB pixel format. This is the same as @ref TJPF_XRGB, except that when
- * decompressing, the X component is guaranteed to be 0xFF, which can be
- * interpreted as an opaque alpha channel.
- */
- TJPF_ARGB,
- /**
- * CMYK pixel format. Unlike RGB, which is an additive color model used
- * primarily for display, CMYK (Cyan/Magenta/Yellow/Key) is a subtractive
- * color model used primarily for printing. In the CMYK color model, the
- * value of each color component typically corresponds to an amount of cyan,
- * magenta, yellow, or black ink that is applied to a white background. In
- * order to convert between CMYK and RGB, it is necessary to use a color
- * management system (CMS.) A CMS will attempt to map colors within the
- * printer's gamut to perceptually similar colors in the display's gamut and
- * vice versa, but the mapping is typically not 1:1 or reversible, nor can it
- * be defined with a simple formula. Thus, such a conversion is out of scope
- * for a codec library. However, the TurboJPEG API allows for compressing
- * CMYK pixels into a YCCK JPEG image (see #TJCS_YCCK) and decompressing YCCK
- * JPEG images into CMYK pixels.
- */
- TJPF_CMYK,
- /**
- * Unknown pixel format. Currently this is only used by #tjLoadImage().
- */
- TJPF_UNKNOWN = -1
-};
-
-/**
- * Red offset (in bytes) for a given pixel format. This specifies the number
- * of bytes that the red component is offset from the start of the pixel. For
- * instance, if a pixel of format TJ_BGRX is stored in <tt>char pixel[]</tt>,
- * then the red component will be <tt>pixel[tjRedOffset[TJ_BGRX]]</tt>. This
- * will be -1 if the pixel format does not have a red component.
- */
-static const int tjRedOffset[TJ_NUMPF] = {
- 0, 2, 0, 2, 3, 1, -1, 0, 2, 3, 1, -1
-};
-/**
- * Green offset (in bytes) for a given pixel format. This specifies the number
- * of bytes that the green component is offset from the start of the pixel.
- * For instance, if a pixel of format TJ_BGRX is stored in
- * <tt>char pixel[]</tt>, then the green component will be
- * <tt>pixel[tjGreenOffset[TJ_BGRX]]</tt>. This will be -1 if the pixel format
- * does not have a green component.
- */
-static const int tjGreenOffset[TJ_NUMPF] = {
- 1, 1, 1, 1, 2, 2, -1, 1, 1, 2, 2, -1
-};
-/**
- * Blue offset (in bytes) for a given pixel format. This specifies the number
- * of bytes that the Blue component is offset from the start of the pixel. For
- * instance, if a pixel of format TJ_BGRX is stored in <tt>char pixel[]</tt>,
- * then the blue component will be <tt>pixel[tjBlueOffset[TJ_BGRX]]</tt>. This
- * will be -1 if the pixel format does not have a blue component.
- */
-static const int tjBlueOffset[TJ_NUMPF] = {
- 2, 0, 2, 0, 1, 3, -1, 2, 0, 1, 3, -1
-};
-/**
- * Alpha offset (in bytes) for a given pixel format. This specifies the number
- * of bytes that the Alpha component is offset from the start of the pixel.
- * For instance, if a pixel of format TJ_BGRA is stored in
- * <tt>char pixel[]</tt>, then the alpha component will be
- * <tt>pixel[tjAlphaOffset[TJ_BGRA]]</tt>. This will be -1 if the pixel format
- * does not have an alpha component.
- */
-static const int tjAlphaOffset[TJ_NUMPF] = {
- -1, -1, -1, -1, -1, -1, -1, 3, 3, 0, 0, -1
-};
-/**
- * Pixel size (in bytes) for a given pixel format
- */
-static const int tjPixelSize[TJ_NUMPF] = {
- 3, 3, 4, 4, 4, 4, 1, 4, 4, 4, 4, 4
-};
-
-
-/**
- * The number of JPEG colorspaces
- */
-#define TJ_NUMCS 5
-
-/**
- * JPEG colorspaces
- */
-enum TJCS {
- /**
- * RGB colorspace. When compressing the JPEG image, the R, G, and B
- * components in the source image are reordered into image planes, but no
- * colorspace conversion or subsampling is performed. RGB JPEG images can be
- * decompressed to any of the extended RGB pixel formats or grayscale, but
- * they cannot be decompressed to YUV images.
- */
- TJCS_RGB = 0,
- /**
- * YCbCr colorspace. YCbCr is not an absolute colorspace but rather a
- * mathematical transformation of RGB designed solely for storage and
- * transmission. YCbCr images must be converted to RGB before they can
- * actually be displayed. In the YCbCr colorspace, the Y (luminance)
- * component represents the black & white portion of the original image, and
- * the Cb and Cr (chrominance) components represent the color portion of the
- * original image. Originally, the analog equivalent of this transformation
- * allowed the same signal to drive both black & white and color televisions,
- * but JPEG images use YCbCr primarily because it allows the color data to be
- * optionally subsampled for the purposes of reducing bandwidth or disk
- * space. YCbCr is the most common JPEG colorspace, and YCbCr JPEG images
- * can be compressed from and decompressed to any of the extended RGB pixel
- * formats or grayscale, or they can be decompressed to YUV planar images.
- */
- TJCS_YCbCr,
- /**
- * Grayscale colorspace. The JPEG image retains only the luminance data (Y
- * component), and any color data from the source image is discarded.
- * Grayscale JPEG images can be compressed from and decompressed to any of
- * the extended RGB pixel formats or grayscale, or they can be decompressed
- * to YUV planar images.
- */
- TJCS_GRAY,
- /**
- * CMYK colorspace. When compressing the JPEG image, the C, M, Y, and K
- * components in the source image are reordered into image planes, but no
- * colorspace conversion or subsampling is performed. CMYK JPEG images can
- * only be decompressed to CMYK pixels.
- */
- TJCS_CMYK,
- /**
- * YCCK colorspace. YCCK (AKA "YCbCrK") is not an absolute colorspace but
- * rather a mathematical transformation of CMYK designed solely for storage
- * and transmission. It is to CMYK as YCbCr is to RGB. CMYK pixels can be
- * reversibly transformed into YCCK, and as with YCbCr, the chrominance
- * components in the YCCK pixels can be subsampled without incurring major
- * perceptual loss. YCCK JPEG images can only be compressed from and
- * decompressed to CMYK pixels.
- */
- TJCS_YCCK
-};
-
-
-/**
- * The uncompressed source/destination image is stored in bottom-up (Windows,
- * OpenGL) order, not top-down (X11) order.
- */
-#define TJFLAG_BOTTOMUP 2
-/**
- * When decompressing an image that was compressed using chrominance
- * subsampling, use the fastest chrominance upsampling algorithm available in
- * the underlying codec. The default is to use smooth upsampling, which
- * creates a smooth transition between neighboring chrominance components in
- * order to reduce upsampling artifacts in the decompressed image.
- */
-#define TJFLAG_FASTUPSAMPLE 256
-/**
- * Disable buffer (re)allocation. If passed to one of the JPEG compression or
- * transform functions, this flag will cause those functions to generate an
- * error if the JPEG image buffer is invalid or too small rather than
- * attempting to allocate or reallocate that buffer. This reproduces the
- * behavior of earlier versions of TurboJPEG.
- */
-#define TJFLAG_NOREALLOC 1024
-/**
- * Use the fastest DCT/IDCT algorithm available in the underlying codec. The
- * default if this flag is not specified is implementation-specific. For
- * example, the implementation of TurboJPEG for libjpeg[-turbo] uses the fast
- * algorithm by default when compressing, because this has been shown to have
- * only a very slight effect on accuracy, but it uses the accurate algorithm
- * when decompressing, because this has been shown to have a larger effect.
- */
-#define TJFLAG_FASTDCT 2048
-/**
- * Use the most accurate DCT/IDCT algorithm available in the underlying codec.
- * The default if this flag is not specified is implementation-specific. For
- * example, the implementation of TurboJPEG for libjpeg[-turbo] uses the fast
- * algorithm by default when compressing, because this has been shown to have
- * only a very slight effect on accuracy, but it uses the accurate algorithm
- * when decompressing, because this has been shown to have a larger effect.
- */
-#define TJFLAG_ACCURATEDCT 4096
-/**
- * Immediately discontinue the current compression/decompression/transform
- * operation if the underlying codec throws a warning (non-fatal error). The
- * default behavior is to allow the operation to complete unless a fatal error
- * is encountered.
- */
-#define TJFLAG_STOPONWARNING 8192
-/**
- * Use progressive entropy coding in JPEG images generated by the compression
- * and transform functions. Progressive entropy coding will generally improve
- * compression relative to baseline entropy coding (the default), but it will
- * reduce compression and decompression performance considerably.
- */
-#define TJFLAG_PROGRESSIVE 16384
-/**
- * Limit the number of progressive JPEG scans that the decompression and
- * transform functions will process. If a progressive JPEG image contains an
- * unreasonably large number of scans, then this flag will cause the
- * decompression and transform functions to return an error. The primary
- * purpose of this is to allow security-critical applications to guard against
- * an exploit of the progressive JPEG format described in
- * <a href="https://libjpeg-turbo.org/pmwiki/uploads/About/TwoIssueswiththeJPEGStandard.pdf" target="_blank">this report</a>.
- */
-#define TJFLAG_LIMITSCANS 32768
-
-
-/**
- * The number of error codes
- */
-#define TJ_NUMERR 2
-
-/**
- * Error codes
- */
-enum TJERR {
- /**
- * The error was non-fatal and recoverable, but the image may still be
- * corrupt.
- */
- TJERR_WARNING = 0,
- /**
- * The error was fatal and non-recoverable.
- */
- TJERR_FATAL
-};
-
-
-/**
- * The number of transform operations
- */
-#define TJ_NUMXOP 8
-
-/**
- * Transform operations for #tjTransform()
- */
-enum TJXOP {
- /**
- * Do not transform the position of the image pixels
- */
- TJXOP_NONE = 0,
- /**
- * Flip (mirror) image horizontally. This transform is imperfect if there
- * are any partial MCU blocks on the right edge (see #TJXOPT_PERFECT.)
- */
- TJXOP_HFLIP,
- /**
- * Flip (mirror) image vertically. This transform is imperfect if there are
- * any partial MCU blocks on the bottom edge (see #TJXOPT_PERFECT.)
- */
- TJXOP_VFLIP,
- /**
- * Transpose image (flip/mirror along upper left to lower right axis.) This
- * transform is always perfect.
- */
- TJXOP_TRANSPOSE,
- /**
- * Transverse transpose image (flip/mirror along upper right to lower left
- * axis.) This transform is imperfect if there are any partial MCU blocks in
- * the image (see #TJXOPT_PERFECT.)
- */
- TJXOP_TRANSVERSE,
- /**
- * Rotate image clockwise by 90 degrees. This transform is imperfect if
- * there are any partial MCU blocks on the bottom edge (see
- * #TJXOPT_PERFECT.)
- */
- TJXOP_ROT90,
- /**
- * Rotate image 180 degrees. This transform is imperfect if there are any
- * partial MCU blocks in the image (see #TJXOPT_PERFECT.)
- */
- TJXOP_ROT180,
- /**
- * Rotate image counter-clockwise by 90 degrees. This transform is imperfect
- * if there are any partial MCU blocks on the right edge (see
- * #TJXOPT_PERFECT.)
- */
- TJXOP_ROT270
-};
-
-
-/**
- * This option will cause #tjTransform() to return an error if the transform is
- * not perfect. Lossless transforms operate on MCU blocks, whose size depends
- * on the level of chrominance subsampling used (see #tjMCUWidth
- * and #tjMCUHeight.) If the image's width or height is not evenly divisible
- * by the MCU block size, then there will be partial MCU blocks on the right
- * and/or bottom edges. It is not possible to move these partial MCU blocks to
- * the top or left of the image, so any transform that would require that is
- * "imperfect." If this option is not specified, then any partial MCU blocks
- * that cannot be transformed will be left in place, which will create
- * odd-looking strips on the right or bottom edge of the image.
- */
-#define TJXOPT_PERFECT 1
-/**
- * This option will cause #tjTransform() to discard any partial MCU blocks that
- * cannot be transformed.
- */
-#define TJXOPT_TRIM 2
-/**
- * This option will enable lossless cropping. See #tjTransform() for more
- * information.
- */
-#define TJXOPT_CROP 4
-/**
- * This option will discard the color data in the input image and produce
- * a grayscale output image.
- */
-#define TJXOPT_GRAY 8
-/**
- * This option will prevent #tjTransform() from outputting a JPEG image for
- * this particular transform (this can be used in conjunction with a custom
- * filter to capture the transformed DCT coefficients without transcoding
- * them.)
- */
-#define TJXOPT_NOOUTPUT 16
-/**
- * This option will enable progressive entropy coding in the output image
- * generated by this particular transform. Progressive entropy coding will
- * generally improve compression relative to baseline entropy coding (the
- * default), but it will reduce compression and decompression performance
- * considerably.
- */
-#define TJXOPT_PROGRESSIVE 32
-/**
- * This option will prevent #tjTransform() from copying any extra markers
- * (including EXIF and ICC profile data) from the source image to the output
- * image.
- */
-#define TJXOPT_COPYNONE 64
-
-
-/**
- * Scaling factor
- */
-typedef struct {
- /**
- * Numerator
- */
- int num;
- /**
- * Denominator
- */
- int denom;
-} tjscalingfactor;
-
-/**
- * Cropping region
- */
-typedef struct {
- /**
- * The left boundary of the cropping region. This must be evenly divisible
- * by the MCU block width (see #tjMCUWidth.)
- */
- int x;
- /**
- * The upper boundary of the cropping region. This must be evenly divisible
- * by the MCU block height (see #tjMCUHeight.)
- */
- int y;
- /**
- * The width of the cropping region. Setting this to 0 is the equivalent of
- * setting it to the width of the source JPEG image - x.
- */
- int w;
- /**
- * The height of the cropping region. Setting this to 0 is the equivalent of
- * setting it to the height of the source JPEG image - y.
- */
- int h;
-} tjregion;
-
-/**
- * Lossless transform
- */
-typedef struct tjtransform {
- /**
- * Cropping region
- */
- tjregion r;
- /**
- * One of the @ref TJXOP "transform operations"
- */
- int op;
- /**
- * The bitwise OR of one of more of the @ref TJXOPT_CROP "transform options"
- */
- int options;
- /**
- * Arbitrary data that can be accessed within the body of the callback
- * function
- */
- void *data;
- /**
- * A callback function that can be used to modify the DCT coefficients
- * after they are losslessly transformed but before they are transcoded to a
- * new JPEG image. This allows for custom filters or other transformations
- * to be applied in the frequency domain.
- *
- * @param coeffs pointer to an array of transformed DCT coefficients. (NOTE:
- * this pointer is not guaranteed to be valid once the callback returns, so
- * applications wishing to hand off the DCT coefficients to another function
- * or library should make a copy of them within the body of the callback.)
- *
- * @param arrayRegion #tjregion structure containing the width and height of
- * the array pointed to by <tt>coeffs</tt> as well as its offset relative to
- * the component plane. TurboJPEG implementations may choose to split each
- * component plane into multiple DCT coefficient arrays and call the callback
- * function once for each array.
- *
- * @param planeRegion #tjregion structure containing the width and height of
- * the component plane to which <tt>coeffs</tt> belongs
- *
- * @param componentID ID number of the component plane to which
- * <tt>coeffs</tt> belongs (Y, Cb, and Cr have, respectively, ID's of 0, 1,
- * and 2 in typical JPEG images.)
- *
- * @param transformID ID number of the transformed image to which
- * <tt>coeffs</tt> belongs. This is the same as the index of the transform
- * in the <tt>transforms</tt> array that was passed to #tjTransform().
- *
- * @param transform a pointer to a #tjtransform structure that specifies the
- * parameters and/or cropping region for this transform
- *
- * @return 0 if the callback was successful, or -1 if an error occurred.
- */
- int (*customFilter) (short *coeffs, tjregion arrayRegion,
- tjregion planeRegion, int componentIndex,
- int transformIndex, struct tjtransform *transform);
-} tjtransform;
-
-/**
- * TurboJPEG instance handle
- */
-typedef void *tjhandle;
-
-
-/**
- * Pad the given width to the nearest 32-bit boundary
- */
-#define TJPAD(width) (((width) + 3) & (~3))
-
-/**
- * Compute the scaled value of <tt>dimension</tt> using the given scaling
- * factor. This macro performs the integer equivalent of <tt>ceil(dimension *
- * scalingFactor)</tt>.
- */
-#define TJSCALED(dimension, scalingFactor) \
- (((dimension) * scalingFactor.num + scalingFactor.denom - 1) / \
- scalingFactor.denom)
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/**
- * Create a TurboJPEG compressor instance.
- *
- * @return a handle to the newly-created instance, or NULL if an error
- * occurred (see #tjGetErrorStr2().)
- */
-DLLEXPORT tjhandle tjInitCompress(void);
-
-
-/**
- * Compress an RGB, grayscale, or CMYK image into a JPEG image.
- *
- * @param handle a handle to a TurboJPEG compressor or transformer instance
- *
- * @param srcBuf pointer to an image buffer containing RGB, grayscale, or
- * CMYK pixels to be compressed
- *
- * @param width width (in pixels) of the source image
- *
- * @param pitch bytes per line in the source image. Normally, this should be
- * <tt>width * #tjPixelSize[pixelFormat]</tt> if the image is unpadded, or
- * <tt>#TJPAD(width * #tjPixelSize[pixelFormat])</tt> if each line of the image
- * is padded to the nearest 32-bit boundary, as is the case for Windows
- * bitmaps. You can also be clever and use this parameter to skip lines, etc.
- * Setting this parameter to 0 is the equivalent of setting it to
- * <tt>width * #tjPixelSize[pixelFormat]</tt>.
- *
- * @param height height (in pixels) of the source image
- *
- * @param pixelFormat pixel format of the source image (see @ref TJPF
- * "Pixel formats".)
- *
- * @param jpegBuf address of a pointer to an image buffer that will receive the
- * JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer
- * to accommodate the size of the JPEG image. Thus, you can choose to:
- * -# pre-allocate the JPEG buffer with an arbitrary size using #tjAlloc() and
- * let TurboJPEG grow the buffer as needed,
- * -# set <tt>*jpegBuf</tt> to NULL to tell TurboJPEG to allocate the buffer
- * for you, or
- * -# pre-allocate the buffer to a "worst case" size determined by calling
- * #tjBufSize(). This should ensure that the buffer never has to be
- * re-allocated (setting #TJFLAG_NOREALLOC guarantees that it won't be.)
- * .
- * If you choose option 1, <tt>*jpegSize</tt> should be set to the size of your
- * pre-allocated buffer. In any case, unless you have set #TJFLAG_NOREALLOC,
- * you should always check <tt>*jpegBuf</tt> upon return from this function, as
- * it may have changed.
- *
- * @param jpegSize pointer to an unsigned long variable that holds the size of
- * the JPEG image buffer. If <tt>*jpegBuf</tt> points to a pre-allocated
- * buffer, then <tt>*jpegSize</tt> should be set to the size of the buffer.
- * Upon return, <tt>*jpegSize</tt> will contain the size of the JPEG image (in
- * bytes.) If <tt>*jpegBuf</tt> points to a JPEG image buffer that is being
- * reused from a previous call to one of the JPEG compression functions, then
- * <tt>*jpegSize</tt> is ignored.
- *
- * @param jpegSubsamp the level of chrominance subsampling to be used when
- * generating the JPEG image (see @ref TJSAMP
- * "Chrominance subsampling options".)
- *
- * @param jpegQual the image quality of the generated JPEG image (1 = worst,
- * 100 = best)
- *
- * @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
- * "flags"
- *
- * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2()
- * and #tjGetErrorCode().)
-*/
-DLLEXPORT int tjCompress2(tjhandle handle, const unsigned char *srcBuf,
- int width, int pitch, int height, int pixelFormat,
- unsigned char **jpegBuf, unsigned long *jpegSize,
- int jpegSubsamp, int jpegQual, int flags);
-
-
-/**
- * Compress a YUV planar image into a JPEG image.
- *
- * @param handle a handle to a TurboJPEG compressor or transformer instance
- *
- * @param srcBuf pointer to an image buffer containing a YUV planar image to be
- * compressed. The size of this buffer should match the value returned by
- * #tjBufSizeYUV2() for the given image width, height, padding, and level of
- * chrominance subsampling. The Y, U (Cb), and V (Cr) image planes should be
- * stored sequentially in the source buffer (refer to @ref YUVnotes
- * "YUV Image Format Notes".)
- *
- * @param width width (in pixels) of the source image. If the width is not an
- * even multiple of the MCU block width (see #tjMCUWidth), then an intermediate
- * buffer copy will be performed within TurboJPEG.
- *
- * @param pad the line padding used in the source image. For instance, if each
- * line in each plane of the YUV image is padded to the nearest multiple of 4
- * bytes, then <tt>pad</tt> should be set to 4.
- *
- * @param height height (in pixels) of the source image. If the height is not
- * an even multiple of the MCU block height (see #tjMCUHeight), then an
- * intermediate buffer copy will be performed within TurboJPEG.
- *
- * @param subsamp the level of chrominance subsampling used in the source
- * image (see @ref TJSAMP "Chrominance subsampling options".)
- *
- * @param jpegBuf address of a pointer to an image buffer that will receive the
- * JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer to
- * accommodate the size of the JPEG image. Thus, you can choose to:
- * -# pre-allocate the JPEG buffer with an arbitrary size using #tjAlloc() and
- * let TurboJPEG grow the buffer as needed,
- * -# set <tt>*jpegBuf</tt> to NULL to tell TurboJPEG to allocate the buffer
- * for you, or
- * -# pre-allocate the buffer to a "worst case" size determined by calling
- * #tjBufSize(). This should ensure that the buffer never has to be
- * re-allocated (setting #TJFLAG_NOREALLOC guarantees that it won't be.)
- * .
- * If you choose option 1, <tt>*jpegSize</tt> should be set to the size of your
- * pre-allocated buffer. In any case, unless you have set #TJFLAG_NOREALLOC,
- * you should always check <tt>*jpegBuf</tt> upon return from this function, as
- * it may have changed.
- *
- * @param jpegSize pointer to an unsigned long variable that holds the size of
- * the JPEG image buffer. If <tt>*jpegBuf</tt> points to a pre-allocated
- * buffer, then <tt>*jpegSize</tt> should be set to the size of the buffer.
- * Upon return, <tt>*jpegSize</tt> will contain the size of the JPEG image (in
- * bytes.) If <tt>*jpegBuf</tt> points to a JPEG image buffer that is being
- * reused from a previous call to one of the JPEG compression functions, then
- * <tt>*jpegSize</tt> is ignored.
- *
- * @param jpegQual the image quality of the generated JPEG image (1 = worst,
- * 100 = best)
- *
- * @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
- * "flags"
- *
- * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2()
- * and #tjGetErrorCode().)
-*/
-DLLEXPORT int tjCompressFromYUV(tjhandle handle, const unsigned char *srcBuf,
- int width, int pad, int height, int subsamp,
- unsigned char **jpegBuf,
- unsigned long *jpegSize, int jpegQual,
- int flags);
-
-
-/**
- * Compress a set of Y, U (Cb), and V (Cr) image planes into a JPEG image.
- *
- * @param handle a handle to a TurboJPEG compressor or transformer instance
- *
- * @param srcPlanes an array of pointers to Y, U (Cb), and V (Cr) image planes
- * (or just a Y plane, if compressing a grayscale image) that contain a YUV
- * image to be compressed. These planes can be contiguous or non-contiguous in
- * memory. The size of each plane should match the value returned by
- * #tjPlaneSizeYUV() for the given image width, height, strides, and level of
- * chrominance subsampling. Refer to @ref YUVnotes "YUV Image Format Notes"
- * for more details.
- *
- * @param width width (in pixels) of the source image. If the width is not an
- * even multiple of the MCU block width (see #tjMCUWidth), then an intermediate
- * buffer copy will be performed within TurboJPEG.
- *
- * @param strides an array of integers, each specifying the number of bytes per
- * line in the corresponding plane of the YUV source image. Setting the stride
- * for any plane to 0 is the same as setting it to the plane width (see
- * @ref YUVnotes "YUV Image Format Notes".) If <tt>strides</tt> is NULL, then
- * the strides for all planes will be set to their respective plane widths.
- * You can adjust the strides in order to specify an arbitrary amount of line
- * padding in each plane or to create a JPEG image from a subregion of a larger
- * YUV planar image.
- *
- * @param height height (in pixels) of the source image. If the height is not
- * an even multiple of the MCU block height (see #tjMCUHeight), then an
- * intermediate buffer copy will be performed within TurboJPEG.
- *
- * @param subsamp the level of chrominance subsampling used in the source
- * image (see @ref TJSAMP "Chrominance subsampling options".)
- *
- * @param jpegBuf address of a pointer to an image buffer that will receive the
- * JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer to
- * accommodate the size of the JPEG image. Thus, you can choose to:
- * -# pre-allocate the JPEG buffer with an arbitrary size using #tjAlloc() and
- * let TurboJPEG grow the buffer as needed,
- * -# set <tt>*jpegBuf</tt> to NULL to tell TurboJPEG to allocate the buffer
- * for you, or
- * -# pre-allocate the buffer to a "worst case" size determined by calling
- * #tjBufSize(). This should ensure that the buffer never has to be
- * re-allocated (setting #TJFLAG_NOREALLOC guarantees that it won't be.)
- * .
- * If you choose option 1, <tt>*jpegSize</tt> should be set to the size of your
- * pre-allocated buffer. In any case, unless you have set #TJFLAG_NOREALLOC,
- * you should always check <tt>*jpegBuf</tt> upon return from this function, as
- * it may have changed.
- *
- * @param jpegSize pointer to an unsigned long variable that holds the size of
- * the JPEG image buffer. If <tt>*jpegBuf</tt> points to a pre-allocated
- * buffer, then <tt>*jpegSize</tt> should be set to the size of the buffer.
- * Upon return, <tt>*jpegSize</tt> will contain the size of the JPEG image (in
- * bytes.) If <tt>*jpegBuf</tt> points to a JPEG image buffer that is being
- * reused from a previous call to one of the JPEG compression functions, then
- * <tt>*jpegSize</tt> is ignored.
- *
- * @param jpegQual the image quality of the generated JPEG image (1 = worst,
- * 100 = best)
- *
- * @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
- * "flags"
- *
- * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2()
- * and #tjGetErrorCode().)
-*/
-DLLEXPORT int tjCompressFromYUVPlanes(tjhandle handle,
- const unsigned char **srcPlanes,
- int width, const int *strides,
- int height, int subsamp,
- unsigned char **jpegBuf,
- unsigned long *jpegSize, int jpegQual,
- int flags);
-
-
-/**
- * The maximum size of the buffer (in bytes) required to hold a JPEG image with
- * the given parameters. The number of bytes returned by this function is
- * larger than the size of the uncompressed source image. The reason for this
- * is that the JPEG format uses 16-bit coefficients, and it is thus possible
- * for a very high-quality JPEG image with very high-frequency content to
- * expand rather than compress when converted to the JPEG format. Such images
- * represent a very rare corner case, but since there is no way to predict the
- * size of a JPEG image prior to compression, the corner case has to be
- * handled.
- *
- * @param width width (in pixels) of the image
- *
- * @param height height (in pixels) of the image
- *
- * @param jpegSubsamp the level of chrominance subsampling to be used when
- * generating the JPEG image (see @ref TJSAMP
- * "Chrominance subsampling options".)
- *
- * @return the maximum size of the buffer (in bytes) required to hold the
- * image, or -1 if the arguments are out of bounds.
- */
-DLLEXPORT unsigned long tjBufSize(int width, int height, int jpegSubsamp);
-
-
-/**
- * The size of the buffer (in bytes) required to hold a YUV planar image with
- * the given parameters.
- *
- * @param width width (in pixels) of the image
- *
- * @param pad the width of each line in each plane of the image is padded to
- * the nearest multiple of this number of bytes (must be a power of 2.)
- *
- * @param height height (in pixels) of the image
- *
- * @param subsamp level of chrominance subsampling in the image (see
- * @ref TJSAMP "Chrominance subsampling options".)
- *
- * @return the size of the buffer (in bytes) required to hold the image, or
- * -1 if the arguments are out of bounds.
- */
-DLLEXPORT unsigned long tjBufSizeYUV2(int width, int pad, int height,
- int subsamp);
-
-
-/**
- * The size of the buffer (in bytes) required to hold a YUV image plane with
- * the given parameters.
- *
- * @param componentID ID number of the image plane (0 = Y, 1 = U/Cb, 2 = V/Cr)
- *
- * @param width width (in pixels) of the YUV image. NOTE: this is the width of
- * the whole image, not the plane width.
- *
- * @param stride bytes per line in the image plane. Setting this to 0 is the
- * equivalent of setting it to the plane width.
- *
- * @param height height (in pixels) of the YUV image. NOTE: this is the height
- * of the whole image, not the plane height.
- *
- * @param subsamp level of chrominance subsampling in the image (see
- * @ref TJSAMP "Chrominance subsampling options".)
- *
- * @return the size of the buffer (in bytes) required to hold the YUV image
- * plane, or -1 if the arguments are out of bounds.
- */
-DLLEXPORT unsigned long tjPlaneSizeYUV(int componentID, int width, int stride,
- int height, int subsamp);
-
-
-/**
- * The plane width of a YUV image plane with the given parameters. Refer to
- * @ref YUVnotes "YUV Image Format Notes" for a description of plane width.
- *
- * @param componentID ID number of the image plane (0 = Y, 1 = U/Cb, 2 = V/Cr)
- *
- * @param width width (in pixels) of the YUV image
- *
- * @param subsamp level of chrominance subsampling in the image (see
- * @ref TJSAMP "Chrominance subsampling options".)
- *
- * @return the plane width of a YUV image plane with the given parameters, or
- * -1 if the arguments are out of bounds.
- */
-DLLEXPORT int tjPlaneWidth(int componentID, int width, int subsamp);
-
-
-/**
- * The plane height of a YUV image plane with the given parameters. Refer to
- * @ref YUVnotes "YUV Image Format Notes" for a description of plane height.
- *
- * @param componentID ID number of the image plane (0 = Y, 1 = U/Cb, 2 = V/Cr)
- *
- * @param height height (in pixels) of the YUV image
- *
- * @param subsamp level of chrominance subsampling in the image (see
- * @ref TJSAMP "Chrominance subsampling options".)
- *
- * @return the plane height of a YUV image plane with the given parameters, or
- * -1 if the arguments are out of bounds.
- */
-DLLEXPORT int tjPlaneHeight(int componentID, int height, int subsamp);
-
-
-/**
- * Encode an RGB or grayscale image into a YUV planar image. This function
- * uses the accelerated color conversion routines in the underlying
- * codec but does not execute any of the other steps in the JPEG compression
- * process.
- *
- * @param handle a handle to a TurboJPEG compressor or transformer instance
- *
- * @param srcBuf pointer to an image buffer containing RGB or grayscale pixels
- * to be encoded
- *
- * @param width width (in pixels) of the source image
- *
- * @param pitch bytes per line in the source image. Normally, this should be
- * <tt>width * #tjPixelSize[pixelFormat]</tt> if the image is unpadded, or
- * <tt>#TJPAD(width * #tjPixelSize[pixelFormat])</tt> if each line of the image
- * is padded to the nearest 32-bit boundary, as is the case for Windows
- * bitmaps. You can also be clever and use this parameter to skip lines, etc.
- * Setting this parameter to 0 is the equivalent of setting it to
- * <tt>width * #tjPixelSize[pixelFormat]</tt>.
- *
- * @param height height (in pixels) of the source image
- *
- * @param pixelFormat pixel format of the source image (see @ref TJPF
- * "Pixel formats".)
- *
- * @param dstBuf pointer to an image buffer that will receive the YUV image.
- * Use #tjBufSizeYUV2() to determine the appropriate size for this buffer based
- * on the image width, height, padding, and level of chrominance subsampling.
- * The Y, U (Cb), and V (Cr) image planes will be stored sequentially in the
- * buffer (refer to @ref YUVnotes "YUV Image Format Notes".)
- *
- * @param pad the width of each line in each plane of the YUV image will be
- * padded to the nearest multiple of this number of bytes (must be a power of
- * 2.) To generate images suitable for X Video, <tt>pad</tt> should be set to
- * 4.
- *
- * @param subsamp the level of chrominance subsampling to be used when
- * generating the YUV image (see @ref TJSAMP
- * "Chrominance subsampling options".) To generate images suitable for X
- * Video, <tt>subsamp</tt> should be set to @ref TJSAMP_420. This produces an
- * image compatible with the I420 (AKA "YUV420P") format.
- *
- * @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
- * "flags"
- *
- * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2()
- * and #tjGetErrorCode().)
-*/
-DLLEXPORT int tjEncodeYUV3(tjhandle handle, const unsigned char *srcBuf,
- int width, int pitch, int height, int pixelFormat,
- unsigned char *dstBuf, int pad, int subsamp,
- int flags);
-
-
-/**
- * Encode an RGB or grayscale image into separate Y, U (Cb), and V (Cr) image
- * planes. This function uses the accelerated color conversion routines in the
- * underlying codec but does not execute any of the other steps in the JPEG
- * compression process.
- *
- * @param handle a handle to a TurboJPEG compressor or transformer instance
- *
- * @param srcBuf pointer to an image buffer containing RGB or grayscale pixels
- * to be encoded
- *
- * @param width width (in pixels) of the source image
- *
- * @param pitch bytes per line in the source image. Normally, this should be
- * <tt>width * #tjPixelSize[pixelFormat]</tt> if the image is unpadded, or
- * <tt>#TJPAD(width * #tjPixelSize[pixelFormat])</tt> if each line of the image
- * is padded to the nearest 32-bit boundary, as is the case for Windows
- * bitmaps. You can also be clever and use this parameter to skip lines, etc.
- * Setting this parameter to 0 is the equivalent of setting it to
- * <tt>width * #tjPixelSize[pixelFormat]</tt>.
- *
- * @param height height (in pixels) of the source image
- *
- * @param pixelFormat pixel format of the source image (see @ref TJPF
- * "Pixel formats".)
- *
- * @param dstPlanes an array of pointers to Y, U (Cb), and V (Cr) image planes
- * (or just a Y plane, if generating a grayscale image) that will receive the
- * encoded image. These planes can be contiguous or non-contiguous in memory.
- * Use #tjPlaneSizeYUV() to determine the appropriate size for each plane based
- * on the image width, height, strides, and level of chrominance subsampling.
- * Refer to @ref YUVnotes "YUV Image Format Notes" for more details.
- *
- * @param strides an array of integers, each specifying the number of bytes per
- * line in the corresponding plane of the output image. Setting the stride for
- * any plane to 0 is the same as setting it to the plane width (see
- * @ref YUVnotes "YUV Image Format Notes".) If <tt>strides</tt> is NULL, then
- * the strides for all planes will be set to their respective plane widths.
- * You can adjust the strides in order to add an arbitrary amount of line
- * padding to each plane or to encode an RGB or grayscale image into a
- * subregion of a larger YUV planar image.
- *
- * @param subsamp the level of chrominance subsampling to be used when
- * generating the YUV image (see @ref TJSAMP
- * "Chrominance subsampling options".) To generate images suitable for X
- * Video, <tt>subsamp</tt> should be set to @ref TJSAMP_420. This produces an
- * image compatible with the I420 (AKA "YUV420P") format.
- *
- * @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
- * "flags"
- *
- * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2()
- * and #tjGetErrorCode().)
-*/
-DLLEXPORT int tjEncodeYUVPlanes(tjhandle handle, const unsigned char *srcBuf,
- int width, int pitch, int height,
- int pixelFormat, unsigned char **dstPlanes,
- int *strides, int subsamp, int flags);
-
-
-/**
- * Create a TurboJPEG decompressor instance.
- *
- * @return a handle to the newly-created instance, or NULL if an error
- * occurred (see #tjGetErrorStr2().)
-*/
-DLLEXPORT tjhandle tjInitDecompress(void);
-
-
-/**
- * Retrieve information about a JPEG image without decompressing it, or prime
- * the decompressor with quantization and Huffman tables.
- *
- * @param handle a handle to a TurboJPEG decompressor or transformer instance
- *
- * @param jpegBuf pointer to a buffer containing a JPEG image or an
- * "abbreviated table specification" (AKA "tables-only") datastream. Passing a
- * tables-only datastream to this function primes the decompressor with
- * quantization and Huffman tables that can be used when decompressing
- * subsequent "abbreviated image" datastreams. This is useful, for instance,
- * when decompressing video streams in which all frames share the same
- * quantization and Huffman tables.
- *
- * @param jpegSize size of the JPEG image or tables-only datastream (in bytes)
- *
- * @param width pointer to an integer variable that will receive the width (in
- * pixels) of the JPEG image. If <tt>jpegBuf</tt> points to a tables-only
- * datastream, then <tt>width</tt> is ignored.
- *
- * @param height pointer to an integer variable that will receive the height
- * (in pixels) of the JPEG image. If <tt>jpegBuf</tt> points to a tables-only
- * datastream, then <tt>height</tt> is ignored.
- *
- * @param jpegSubsamp pointer to an integer variable that will receive the
- * level of chrominance subsampling used when the JPEG image was compressed
- * (see @ref TJSAMP "Chrominance subsampling options".) If <tt>jpegBuf</tt>
- * points to a tables-only datastream, then <tt>jpegSubsamp</tt> is ignored.
- *
- * @param jpegColorspace pointer to an integer variable that will receive one
- * of the JPEG colorspace constants, indicating the colorspace of the JPEG
- * image (see @ref TJCS "JPEG colorspaces".) If <tt>jpegBuf</tt>
- * points to a tables-only datastream, then <tt>jpegColorspace</tt> is ignored.
- *
- * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2()
- * and #tjGetErrorCode().)
-*/
-DLLEXPORT int tjDecompressHeader3(tjhandle handle,
- const unsigned char *jpegBuf,
- unsigned long jpegSize, int *width,
- int *height, int *jpegSubsamp,
- int *jpegColorspace);
-
-
-/**
- * Returns a list of fractional scaling factors that the JPEG decompressor in
- * this implementation of TurboJPEG supports.
- *
- * @param numscalingfactors pointer to an integer variable that will receive
- * the number of elements in the list
- *
- * @return a pointer to a list of fractional scaling factors, or NULL if an
- * error is encountered (see #tjGetErrorStr2().)
-*/
-DLLEXPORT tjscalingfactor *tjGetScalingFactors(int *numscalingfactors);
-
-
-/**
- * Decompress a JPEG image to an RGB, grayscale, or CMYK image.
- *
- * @param handle a handle to a TurboJPEG decompressor or transformer instance
- *
- * @param jpegBuf pointer to a buffer containing the JPEG image to decompress
- *
- * @param jpegSize size of the JPEG image (in bytes)
- *
- * @param dstBuf pointer to an image buffer that will receive the decompressed
- * image. This buffer should normally be <tt>pitch * scaledHeight</tt> bytes
- * in size, where <tt>scaledHeight</tt> can be determined by calling
- * #TJSCALED() with the JPEG image height and one of the scaling factors
- * returned by #tjGetScalingFactors(). The <tt>dstBuf</tt> pointer may also be
- * used to decompress into a specific region of a larger buffer.
- *
- * @param width desired width (in pixels) of the destination image. If this is
- * different than the width of the JPEG image being decompressed, then
- * TurboJPEG will use scaling in the JPEG decompressor to generate the largest
- * possible image that will fit within the desired width. If <tt>width</tt> is
- * set to 0, then only the height will be considered when determining the
- * scaled image size.
- *
- * @param pitch bytes per line in the destination image. Normally, this is
- * <tt>scaledWidth * #tjPixelSize[pixelFormat]</tt> if the decompressed image
- * is unpadded, else <tt>#TJPAD(scaledWidth * #tjPixelSize[pixelFormat])</tt>
- * if each line of the decompressed image is padded to the nearest 32-bit
- * boundary, as is the case for Windows bitmaps. (NOTE: <tt>scaledWidth</tt>
- * can be determined by calling #TJSCALED() with the JPEG image width and one
- * of the scaling factors returned by #tjGetScalingFactors().) You can also be
- * clever and use the pitch parameter to skip lines, etc. Setting this
- * parameter to 0 is the equivalent of setting it to
- * <tt>scaledWidth * #tjPixelSize[pixelFormat]</tt>.
- *
- * @param height desired height (in pixels) of the destination image. If this
- * is different than the height of the JPEG image being decompressed, then
- * TurboJPEG will use scaling in the JPEG decompressor to generate the largest
- * possible image that will fit within the desired height. If <tt>height</tt>
- * is set to 0, then only the width will be considered when determining the
- * scaled image size.
- *
- * @param pixelFormat pixel format of the destination image (see @ref
- * TJPF "Pixel formats".)
- *
- * @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
- * "flags"
- *
- * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2()
- * and #tjGetErrorCode().)
- */
-DLLEXPORT int tjDecompress2(tjhandle handle, const unsigned char *jpegBuf,
- unsigned long jpegSize, unsigned char *dstBuf,
- int width, int pitch, int height, int pixelFormat,
- int flags);
-
-
-/**
- * Decompress a JPEG image to a YUV planar image. This function performs JPEG
- * decompression but leaves out the color conversion step, so a planar YUV
- * image is generated instead of an RGB image.
- *
- * @param handle a handle to a TurboJPEG decompressor or transformer instance
- *
- * @param jpegBuf pointer to a buffer containing the JPEG image to decompress
- *
- * @param jpegSize size of the JPEG image (in bytes)
- *
- * @param dstBuf pointer to an image buffer that will receive the YUV image.
- * Use #tjBufSizeYUV2() to determine the appropriate size for this buffer based
- * on the image width, height, padding, and level of subsampling. The Y,
- * U (Cb), and V (Cr) image planes will be stored sequentially in the buffer
- * (refer to @ref YUVnotes "YUV Image Format Notes".)
- *
- * @param width desired width (in pixels) of the YUV image. If this is
- * different than the width of the JPEG image being decompressed, then
- * TurboJPEG will use scaling in the JPEG decompressor to generate the largest
- * possible image that will fit within the desired width. If <tt>width</tt> is
- * set to 0, then only the height will be considered when determining the
- * scaled image size. If the scaled width is not an even multiple of the MCU
- * block width (see #tjMCUWidth), then an intermediate buffer copy will be
- * performed within TurboJPEG.
- *
- * @param pad the width of each line in each plane of the YUV image will be
- * padded to the nearest multiple of this number of bytes (must be a power of
- * 2.) To generate images suitable for X Video, <tt>pad</tt> should be set to
- * 4.
- *
- * @param height desired height (in pixels) of the YUV image. If this is
- * different than the height of the JPEG image being decompressed, then
- * TurboJPEG will use scaling in the JPEG decompressor to generate the largest
- * possible image that will fit within the desired height. If <tt>height</tt>
- * is set to 0, then only the width will be considered when determining the
- * scaled image size. If the scaled height is not an even multiple of the MCU
- * block height (see #tjMCUHeight), then an intermediate buffer copy will be
- * performed within TurboJPEG.
- *
- * @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
- * "flags"
- *
- * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2()
- * and #tjGetErrorCode().)
- */
-DLLEXPORT int tjDecompressToYUV2(tjhandle handle, const unsigned char *jpegBuf,
- unsigned long jpegSize, unsigned char *dstBuf,
- int width, int pad, int height, int flags);
-
-
-/**
- * Decompress a JPEG image into separate Y, U (Cb), and V (Cr) image
- * planes. This function performs JPEG decompression but leaves out the color
- * conversion step, so a planar YUV image is generated instead of an RGB image.
- *
- * @param handle a handle to a TurboJPEG decompressor or transformer instance
- *
- * @param jpegBuf pointer to a buffer containing the JPEG image to decompress
- *
- * @param jpegSize size of the JPEG image (in bytes)
- *
- * @param dstPlanes an array of pointers to Y, U (Cb), and V (Cr) image planes
- * (or just a Y plane, if decompressing a grayscale image) that will receive
- * the YUV image. These planes can be contiguous or non-contiguous in memory.
- * Use #tjPlaneSizeYUV() to determine the appropriate size for each plane based
- * on the scaled image width, scaled image height, strides, and level of
- * chrominance subsampling. Refer to @ref YUVnotes "YUV Image Format Notes"
- * for more details.
- *
- * @param width desired width (in pixels) of the YUV image. If this is
- * different than the width of the JPEG image being decompressed, then
- * TurboJPEG will use scaling in the JPEG decompressor to generate the largest
- * possible image that will fit within the desired width. If <tt>width</tt> is
- * set to 0, then only the height will be considered when determining the
- * scaled image size. If the scaled width is not an even multiple of the MCU
- * block width (see #tjMCUWidth), then an intermediate buffer copy will be
- * performed within TurboJPEG.
- *
- * @param strides an array of integers, each specifying the number of bytes per
- * line in the corresponding plane of the output image. Setting the stride for
- * any plane to 0 is the same as setting it to the scaled plane width (see
- * @ref YUVnotes "YUV Image Format Notes".) If <tt>strides</tt> is NULL, then
- * the strides for all planes will be set to their respective scaled plane
- * widths. You can adjust the strides in order to add an arbitrary amount of
- * line padding to each plane or to decompress the JPEG image into a subregion
- * of a larger YUV planar image.
- *
- * @param height desired height (in pixels) of the YUV image. If this is
- * different than the height of the JPEG image being decompressed, then
- * TurboJPEG will use scaling in the JPEG decompressor to generate the largest
- * possible image that will fit within the desired height. If <tt>height</tt>
- * is set to 0, then only the width will be considered when determining the
- * scaled image size. If the scaled height is not an even multiple of the MCU
- * block height (see #tjMCUHeight), then an intermediate buffer copy will be
- * performed within TurboJPEG.
- *
- * @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
- * "flags"
- *
- * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2()
- * and #tjGetErrorCode().)
- */
-DLLEXPORT int tjDecompressToYUVPlanes(tjhandle handle,
- const unsigned char *jpegBuf,
- unsigned long jpegSize,
- unsigned char **dstPlanes, int width,
- int *strides, int height, int flags);
-
-
-/**
- * Decode a YUV planar image into an RGB or grayscale image. This function
- * uses the accelerated color conversion routines in the underlying
- * codec but does not execute any of the other steps in the JPEG decompression
- * process.
- *
- * @param handle a handle to a TurboJPEG decompressor or transformer instance
- *
- * @param srcBuf pointer to an image buffer containing a YUV planar image to be
- * decoded. The size of this buffer should match the value returned by
- * #tjBufSizeYUV2() for the given image width, height, padding, and level of
- * chrominance subsampling. The Y, U (Cb), and V (Cr) image planes should be
- * stored sequentially in the source buffer (refer to @ref YUVnotes
- * "YUV Image Format Notes".)
- *
- * @param pad Use this parameter to specify that the width of each line in each
- * plane of the YUV source image is padded to the nearest multiple of this
- * number of bytes (must be a power of 2.)
- *
- * @param subsamp the level of chrominance subsampling used in the YUV source
- * image (see @ref TJSAMP "Chrominance subsampling options".)
- *
- * @param dstBuf pointer to an image buffer that will receive the decoded
- * image. This buffer should normally be <tt>pitch * height</tt> bytes in
- * size, but the <tt>dstBuf</tt> pointer can also be used to decode into a
- * specific region of a larger buffer.
- *
- * @param width width (in pixels) of the source and destination images
- *
- * @param pitch bytes per line in the destination image. Normally, this should
- * be <tt>width * #tjPixelSize[pixelFormat]</tt> if the destination image is
- * unpadded, or <tt>#TJPAD(width * #tjPixelSize[pixelFormat])</tt> if each line
- * of the destination image should be padded to the nearest 32-bit boundary, as
- * is the case for Windows bitmaps. You can also be clever and use the pitch
- * parameter to skip lines, etc. Setting this parameter to 0 is the equivalent
- * of setting it to <tt>width * #tjPixelSize[pixelFormat]</tt>.
- *
- * @param height height (in pixels) of the source and destination images
- *
- * @param pixelFormat pixel format of the destination image (see @ref TJPF
- * "Pixel formats".)
- *
- * @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
- * "flags"
- *
- * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2()
- * and #tjGetErrorCode().)
- */
-DLLEXPORT int tjDecodeYUV(tjhandle handle, const unsigned char *srcBuf,
- int pad, int subsamp, unsigned char *dstBuf,
- int width, int pitch, int height, int pixelFormat,
- int flags);
-
-
-/**
- * Decode a set of Y, U (Cb), and V (Cr) image planes into an RGB or grayscale
- * image. This function uses the accelerated color conversion routines in the
- * underlying codec but does not execute any of the other steps in the JPEG
- * decompression process.
- *
- * @param handle a handle to a TurboJPEG decompressor or transformer instance
- *
- * @param srcPlanes an array of pointers to Y, U (Cb), and V (Cr) image planes
- * (or just a Y plane, if decoding a grayscale image) that contain a YUV image
- * to be decoded. These planes can be contiguous or non-contiguous in memory.
- * The size of each plane should match the value returned by #tjPlaneSizeYUV()
- * for the given image width, height, strides, and level of chrominance
- * subsampling. Refer to @ref YUVnotes "YUV Image Format Notes" for more
- * details.
- *
- * @param strides an array of integers, each specifying the number of bytes per
- * line in the corresponding plane of the YUV source image. Setting the stride
- * for any plane to 0 is the same as setting it to the plane width (see
- * @ref YUVnotes "YUV Image Format Notes".) If <tt>strides</tt> is NULL, then
- * the strides for all planes will be set to their respective plane widths.
- * You can adjust the strides in order to specify an arbitrary amount of line
- * padding in each plane or to decode a subregion of a larger YUV planar image.
- *
- * @param subsamp the level of chrominance subsampling used in the YUV source
- * image (see @ref TJSAMP "Chrominance subsampling options".)
- *
- * @param dstBuf pointer to an image buffer that will receive the decoded
- * image. This buffer should normally be <tt>pitch * height</tt> bytes in
- * size, but the <tt>dstBuf</tt> pointer can also be used to decode into a
- * specific region of a larger buffer.
- *
- * @param width width (in pixels) of the source and destination images
- *
- * @param pitch bytes per line in the destination image. Normally, this should
- * be <tt>width * #tjPixelSize[pixelFormat]</tt> if the destination image is
- * unpadded, or <tt>#TJPAD(width * #tjPixelSize[pixelFormat])</tt> if each line
- * of the destination image should be padded to the nearest 32-bit boundary, as
- * is the case for Windows bitmaps. You can also be clever and use the pitch
- * parameter to skip lines, etc. Setting this parameter to 0 is the equivalent
- * of setting it to <tt>width * #tjPixelSize[pixelFormat]</tt>.
- *
- * @param height height (in pixels) of the source and destination images
- *
- * @param pixelFormat pixel format of the destination image (see @ref TJPF
- * "Pixel formats".)
- *
- * @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
- * "flags"
- *
- * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2()
- * and #tjGetErrorCode().)
- */
-DLLEXPORT int tjDecodeYUVPlanes(tjhandle handle,
- const unsigned char **srcPlanes,
- const int *strides, int subsamp,
- unsigned char *dstBuf, int width, int pitch,
- int height, int pixelFormat, int flags);
-
-
-/**
- * Create a new TurboJPEG transformer instance.
- *
- * @return a handle to the newly-created instance, or NULL if an error
- * occurred (see #tjGetErrorStr2().)
- */
-DLLEXPORT tjhandle tjInitTransform(void);
-
-
-/**
- * Losslessly transform a JPEG image into another JPEG image. Lossless
- * transforms work by moving the raw DCT coefficients from one JPEG image
- * structure to another without altering the values of the coefficients. While
- * this is typically faster than decompressing the image, transforming it, and
- * re-compressing it, lossless transforms are not free. Each lossless
- * transform requires reading and performing Huffman decoding on all of the
- * coefficients in the source image, regardless of the size of the destination
- * image. Thus, this function provides a means of generating multiple
- * transformed images from the same source or applying multiple
- * transformations simultaneously, in order to eliminate the need to read the
- * source coefficients multiple times.
- *
- * @param handle a handle to a TurboJPEG transformer instance
- *
- * @param jpegBuf pointer to a buffer containing the JPEG source image to
- * transform
- *
- * @param jpegSize size of the JPEG source image (in bytes)
- *
- * @param n the number of transformed JPEG images to generate
- *
- * @param dstBufs pointer to an array of n image buffers. <tt>dstBufs[i]</tt>
- * will receive a JPEG image that has been transformed using the parameters in
- * <tt>transforms[i]</tt>. TurboJPEG has the ability to reallocate the JPEG
- * buffer to accommodate the size of the JPEG image. Thus, you can choose to:
- * -# pre-allocate the JPEG buffer with an arbitrary size using #tjAlloc() and
- * let TurboJPEG grow the buffer as needed,
- * -# set <tt>dstBufs[i]</tt> to NULL to tell TurboJPEG to allocate the buffer
- * for you, or
- * -# pre-allocate the buffer to a "worst case" size determined by calling
- * #tjBufSize() with the transformed or cropped width and height. Under normal
- * circumstances, this should ensure that the buffer never has to be
- * re-allocated (setting #TJFLAG_NOREALLOC guarantees that it won't be.) Note,
- * however, that there are some rare cases (such as transforming images with a
- * large amount of embedded EXIF or ICC profile data) in which the output image
- * will be larger than the worst-case size, and #TJFLAG_NOREALLOC cannot be
- * used in those cases.
- * .
- * If you choose option 1, <tt>dstSizes[i]</tt> should be set to the size of
- * your pre-allocated buffer. In any case, unless you have set
- * #TJFLAG_NOREALLOC, you should always check <tt>dstBufs[i]</tt> upon return
- * from this function, as it may have changed.
- *
- * @param dstSizes pointer to an array of n unsigned long variables that will
- * receive the actual sizes (in bytes) of each transformed JPEG image. If
- * <tt>dstBufs[i]</tt> points to a pre-allocated buffer, then
- * <tt>dstSizes[i]</tt> should be set to the size of the buffer. Upon return,
- * <tt>dstSizes[i]</tt> will contain the size of the JPEG image (in bytes.)
- *
- * @param transforms pointer to an array of n #tjtransform structures, each of
- * which specifies the transform parameters and/or cropping region for the
- * corresponding transformed output image.
- *
- * @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
- * "flags"
- *
- * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2()
- * and #tjGetErrorCode().)
- */
-DLLEXPORT int tjTransform(tjhandle handle, const unsigned char *jpegBuf,
- unsigned long jpegSize, int n,
- unsigned char **dstBufs, unsigned long *dstSizes,
- tjtransform *transforms, int flags);
-
-
-/**
- * Destroy a TurboJPEG compressor, decompressor, or transformer instance.
- *
- * @param handle a handle to a TurboJPEG compressor, decompressor or
- * transformer instance
- *
- * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2().)
- */
-DLLEXPORT int tjDestroy(tjhandle handle);
-
-
-/**
- * Allocate an image buffer for use with TurboJPEG. You should always use
- * this function to allocate the JPEG destination buffer(s) for the compression
- * and transform functions unless you are disabling automatic buffer
- * (re)allocation (by setting #TJFLAG_NOREALLOC.)
- *
- * @param bytes the number of bytes to allocate
- *
- * @return a pointer to a newly-allocated buffer with the specified number of
- * bytes.
- *
- * @sa tjFree()
- */
-DLLEXPORT unsigned char *tjAlloc(int bytes);
-
-
-/**
- * Load an uncompressed image from disk into memory.
- *
- * @param filename name of a file containing an uncompressed image in Windows
- * BMP or PBMPLUS (PPM/PGM) format
- *
- * @param width pointer to an integer variable that will receive the width (in
- * pixels) of the uncompressed image
- *
- * @param align row alignment of the image buffer to be returned (must be a
- * power of 2.) For instance, setting this parameter to 4 will cause all rows
- * in the image buffer to be padded to the nearest 32-bit boundary, and setting
- * this parameter to 1 will cause all rows in the image buffer to be unpadded.
- *
- * @param height pointer to an integer variable that will receive the height
- * (in pixels) of the uncompressed image
- *
- * @param pixelFormat pointer to an integer variable that specifies or will
- * receive the pixel format of the uncompressed image buffer. The behavior of
- * #tjLoadImage() will vary depending on the value of <tt>*pixelFormat</tt>
- * passed to the function:
- * - @ref TJPF_UNKNOWN : The uncompressed image buffer returned by the function
- * will use the most optimal pixel format for the file type, and
- * <tt>*pixelFormat</tt> will contain the ID of this pixel format upon
- * successful return from the function.
- * - @ref TJPF_GRAY : Only PGM files and 8-bit BMP files with a grayscale
- * colormap can be loaded.
- * - @ref TJPF_CMYK : The RGB or grayscale pixels stored in the file will be
- * converted using a quick & dirty algorithm that is suitable only for testing
- * purposes (proper conversion between CMYK and other formats requires a color
- * management system.)
- * - Other @ref TJPF "pixel formats" : The uncompressed image buffer will use
- * the specified pixel format, and pixel format conversion will be performed if
- * necessary.
- *
- * @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP
- * "flags".
- *
- * @return a pointer to a newly-allocated buffer containing the uncompressed
- * image, converted to the chosen pixel format and with the chosen row
- * alignment, or NULL if an error occurred (see #tjGetErrorStr2().) This
- * buffer should be freed using #tjFree().
- */
-DLLEXPORT unsigned char *tjLoadImage(const char *filename, int *width,
- int align, int *height, int *pixelFormat,
- int flags);
-
-
-/**
- * Save an uncompressed image from memory to disk.
- *
- * @param filename name of a file to which to save the uncompressed image.
- * The image will be stored in Windows BMP or PBMPLUS (PPM/PGM) format,
- * depending on the file extension.
- *
- * @param buffer pointer to an image buffer containing RGB, grayscale, or
- * CMYK pixels to be saved
- *
- * @param width width (in pixels) of the uncompressed image
- *
- * @param pitch bytes per line in the image buffer. Setting this parameter to
- * 0 is the equivalent of setting it to
- * <tt>width * #tjPixelSize[pixelFormat]</tt>.
- *
- * @param height height (in pixels) of the uncompressed image
- *
- * @param pixelFormat pixel format of the image buffer (see @ref TJPF
- * "Pixel formats".) If this parameter is set to @ref TJPF_GRAY, then the
- * image will be stored in PGM or 8-bit (indexed color) BMP format. Otherwise,
- * the image will be stored in PPM or 24-bit BMP format. If this parameter
- * is set to @ref TJPF_CMYK, then the CMYK pixels will be converted to RGB
- * using a quick & dirty algorithm that is suitable only for testing (proper
- * conversion between CMYK and other formats requires a color management
- * system.)
- *
- * @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP
- * "flags".
- *
- * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2().)
- */
-DLLEXPORT int tjSaveImage(const char *filename, unsigned char *buffer,
- int width, int pitch, int height, int pixelFormat,
- int flags);
-
-
-/**
- * Free an image buffer previously allocated by TurboJPEG. You should always
- * use this function to free JPEG destination buffer(s) that were automatically
- * (re)allocated by the compression and transform functions or that were
- * manually allocated using #tjAlloc().
- *
- * @param buffer address of the buffer to free. If the address is NULL, then
- * this function has no effect.
- *
- * @sa tjAlloc()
- */
-DLLEXPORT void tjFree(unsigned char *buffer);
-
-
-/**
- * Returns a descriptive error message explaining why the last command failed.
- *
- * @param handle a handle to a TurboJPEG compressor, decompressor, or
- * transformer instance, or NULL if the error was generated by a global
- * function (but note that retrieving the error message for a global function
- * is thread-safe only on platforms that support thread-local storage.)
- *
- * @return a descriptive error message explaining why the last command failed.
- */
-DLLEXPORT char *tjGetErrorStr2(tjhandle handle);
-
-
-/**
- * Returns a code indicating the severity of the last error. See
- * @ref TJERR "Error codes".
- *
- * @param handle a handle to a TurboJPEG compressor, decompressor or
- * transformer instance
- *
- * @return a code indicating the severity of the last error. See
- * @ref TJERR "Error codes".
- */
-DLLEXPORT int tjGetErrorCode(tjhandle handle);
-
-
-/* Deprecated functions and macros */
-#define TJFLAG_FORCEMMX 8
-#define TJFLAG_FORCESSE 16
-#define TJFLAG_FORCESSE2 32
-#define TJFLAG_FORCESSE3 128
-
-
-/* Backward compatibility functions and macros (nothing to see here) */
-#define NUMSUBOPT TJ_NUMSAMP
-#define TJ_444 TJSAMP_444
-#define TJ_422 TJSAMP_422
-#define TJ_420 TJSAMP_420
-#define TJ_411 TJSAMP_420
-#define TJ_GRAYSCALE TJSAMP_GRAY
-
-#define TJ_BGR 1
-#define TJ_BOTTOMUP TJFLAG_BOTTOMUP
-#define TJ_FORCEMMX TJFLAG_FORCEMMX
-#define TJ_FORCESSE TJFLAG_FORCESSE
-#define TJ_FORCESSE2 TJFLAG_FORCESSE2
-#define TJ_ALPHAFIRST 64
-#define TJ_FORCESSE3 TJFLAG_FORCESSE3
-#define TJ_FASTUPSAMPLE TJFLAG_FASTUPSAMPLE
-#define TJ_YUV 512
-
-DLLEXPORT unsigned long TJBUFSIZE(int width, int height);
-
-DLLEXPORT unsigned long TJBUFSIZEYUV(int width, int height, int jpegSubsamp);
-
-DLLEXPORT unsigned long tjBufSizeYUV(int width, int height, int subsamp);
-
-DLLEXPORT int tjCompress(tjhandle handle, unsigned char *srcBuf, int width,
- int pitch, int height, int pixelSize,
- unsigned char *dstBuf, unsigned long *compressedSize,
- int jpegSubsamp, int jpegQual, int flags);
-
-DLLEXPORT int tjEncodeYUV(tjhandle handle, unsigned char *srcBuf, int width,
- int pitch, int height, int pixelSize,
- unsigned char *dstBuf, int subsamp, int flags);
-
-DLLEXPORT int tjEncodeYUV2(tjhandle handle, unsigned char *srcBuf, int width,
- int pitch, int height, int pixelFormat,
- unsigned char *dstBuf, int subsamp, int flags);
-
-DLLEXPORT int tjDecompressHeader(tjhandle handle, unsigned char *jpegBuf,
- unsigned long jpegSize, int *width,
- int *height);
-
-DLLEXPORT int tjDecompressHeader2(tjhandle handle, unsigned char *jpegBuf,
- unsigned long jpegSize, int *width,
- int *height, int *jpegSubsamp);
-
-DLLEXPORT int tjDecompress(tjhandle handle, unsigned char *jpegBuf,
- unsigned long jpegSize, unsigned char *dstBuf,
- int width, int pitch, int height, int pixelSize,
- int flags);
-
-DLLEXPORT int tjDecompressToYUV(tjhandle handle, unsigned char *jpegBuf,
- unsigned long jpegSize, unsigned char *dstBuf,
- int flags);
-
-DLLEXPORT char *tjGetErrorStr(void);
-
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/contrib/libs/libjpeg-turbo/ut/bittests.py b/contrib/libs/libjpeg-turbo/ut/bittests.py
deleted file mode 100644
index 4500db73ca..0000000000
--- a/contrib/libs/libjpeg-turbo/ut/bittests.py
+++ /dev/null
@@ -1,380 +0,0 @@
-#2!/usr/bin/python
-
-import yatest.common
-import hashlib
-import shutil
-import re
-import glob
-import os
-
-# Based heavily on Makefile.am from upstream
-
-# Helper routines
-
-_TJ_ROOT = "contrib/libs/libjpeg-turbo/"
-_TESTIMAGES_ROOT = "contrib/libs/libjpeg-turbo/testimages/"
-_TESTIMAGES_RE = re.compile(r'^\$\(srcdir\)/testimages/(.*)$')
-_TESTORIG = "testorig.jpg"
-
-def cp_testimage(name, newname):
- shutil.copyfile(yatest.common.source_path(_TESTIMAGES_ROOT + name), newname)
-
-def run(command):
- command = command.split()
- ut = ""
- command[0] = yatest.common.binary_path(_TJ_ROOT + ut + command[0] + "/" + command[0])
- for i in range(1, len(command)):
- m = _TESTIMAGES_RE.match(command[i])
- if m:
- name = m.group(1)
- if name == "$(TESTORIG)":
- name = _TESTORIG
- command[i] = yatest.common.source_path(_TESTIMAGES_ROOT + name)
- yatest.common.execute(command)
-
-def md5cmp(hexdigest, filename):
- with open(filename, 'rb') as f:
- assert(hexdigest == hashlib.md5(f.read()).hexdigest())
-
-def rm_f(patterns):
- for pattern in patterns.split():
- for fn in glob.glob(pattern):
- if "/" in fn:
- raise Exception("/ seems supsicious in a file name to remove")
- os.unlink(fn)
-
-# Makefile.am mimic
-MD5_JPEG_RGB_ISLOW = "768e970dd57b340ff1b83c9d3d47c77b"
-MD5_PPM_RGB_ISLOW = "00a257f5393fef8821f2b88ac7421291"
-MD5_BMP_RGB_ISLOW_565 = "f07d2e75073e4bb10f6c6f4d36e2e3be"
-MD5_BMP_RGB_ISLOW_565D = "4cfa0928ef3e6bb626d7728c924cfda4"
-MD5_JPEG_422_IFAST_OPT = "2540287b79d913f91665e660303ab2c8"
-MD5_PPM_422_IFAST = "35bd6b3f833bad23de82acea847129fa"
-MD5_PPM_422M_IFAST = "8dbc65323d62cca7c91ba02dd1cfa81d"
-MD5_BMP_422M_IFAST_565 = "3294bd4d9a1f2b3d08ea6020d0db7065"
-MD5_BMP_422M_IFAST_565D = "da98c9c7b6039511be4a79a878a9abc1"
-MD5_JPEG_420_IFAST_Q100_PROG = "990cbe0329c882420a2094da7e5adade"
-MD5_PPM_420_Q100_IFAST = "5a732542015c278ff43635e473a8a294"
-MD5_PPM_420M_Q100_IFAST = "ff692ee9323a3b424894862557c092f1"
-MD5_JPEG_GRAY_ISLOW = "72b51f894b8f4a10b3ee3066770aa38d"
-MD5_PPM_GRAY_ISLOW = "8d3596c56eace32f205deccc229aa5ed"
-MD5_PPM_GRAY_ISLOW_RGB = "116424ac07b79e5e801f00508eab48ec"
-MD5_BMP_GRAY_ISLOW_565 = "12f78118e56a2f48b966f792fedf23cc"
-MD5_BMP_GRAY_ISLOW_565D = "bdbbd616441a24354c98553df5dc82db"
-MD5_JPEG_420S_IFAST_OPT = "388708217ac46273ca33086b22827ed8"
-# See README.md for more details on why this next bit is necessary.
-MD5_JPEG_3x2_FLOAT_PROG_SSE = "343e3f8caf8af5986ebaf0bdc13b5c71"
-MD5_PPM_3x2_FLOAT_SSE = "1a75f36e5904d6fc3a85a43da9ad89bb"
-MD5_JPEG_3x2_FLOAT_PROG_32BIT = "9bca803d2042bd1eb03819e2bf92b3e5"
-MD5_PPM_3x2_FLOAT_32BIT = "f6bfab038438ed8f5522fbd33595dcdc"
-MD5_PPM_3x2_FLOAT_64BIT = "0e917a34193ef976b679a6b069b1be26"
-MD5_JPEG_3x2_IFAST_PROG = "1ee5d2c1a77f2da495f993c8c7cceca5"
-MD5_PPM_3x2_IFAST = "fd283664b3b49127984af0a7f118fccd"
-MD5_JPEG_420_ISLOW_ARI = "e986fb0a637a8d833d96e8a6d6d84ea1"
-MD5_JPEG_444_ISLOW_PROGARI = "0a8f1c8f66e113c3cf635df0a475a617"
-MD5_PPM_420M_IFAST_ARI = "72b59a99bcf1de24c5b27d151bde2437"
-MD5_JPEG_420_ISLOW = "9a68f56bc76e466aa7e52f415d0f4a5f"
-MD5_PPM_420M_ISLOW_2_1 = "9f9de8c0612f8d06869b960b05abf9c9"
-MD5_PPM_420M_ISLOW_15_8 = "b6875bc070720b899566cc06459b63b7"
-MD5_PPM_420M_ISLOW_13_8 = "bc3452573c8152f6ae552939ee19f82f"
-MD5_PPM_420M_ISLOW_11_8 = "d8cc73c0aaacd4556569b59437ba00a5"
-MD5_PPM_420M_ISLOW_9_8 = "d25e61bc7eac0002f5b393aa223747b6"
-MD5_PPM_420M_ISLOW_7_8 = "ddb564b7c74a09494016d6cd7502a946"
-MD5_PPM_420M_ISLOW_3_4 = "8ed8e68808c3fbc4ea764fc9d2968646"
-MD5_PPM_420M_ISLOW_5_8 = "a3363274999da2366a024efae6d16c9b"
-MD5_PPM_420M_ISLOW_1_2 = "e692a315cea26b988c8e8b29a5dbcd81"
-MD5_PPM_420M_ISLOW_3_8 = "79eca9175652ced755155c90e785a996"
-MD5_PPM_420M_ISLOW_1_4 = "79cd778f8bf1a117690052cacdd54eca"
-MD5_PPM_420M_ISLOW_1_8 = "391b3d4aca640c8567d6f8745eb2142f"
-MD5_BMP_420_ISLOW_256 = "4980185e3776e89bd931736e1cddeee6"
-MD5_BMP_420_ISLOW_565 = "bf9d13e16c4923b92e1faa604d7922cb"
-MD5_BMP_420_ISLOW_565D = "6bde71526acc44bcff76f696df8638d2"
-MD5_BMP_420M_ISLOW_565 = "8dc0185245353cfa32ad97027342216f"
-MD5_BMP_420M_ISLOW_565D = "ce034037d212bc403330df6f915c161b"
-MD5_PPM_420_ISLOW_SKIP15_31 = "c4c65c1e43d7275cd50328a61e6534f0"
-MD5_PPM_420_ISLOW_ARI_SKIP16_139 = "087c6b123db16ac00cb88c5b590bb74a"
-MD5_PPM_420_ISLOW_PROG_CROP62x62_71_71 = "26eb36ccc7d1f0cb80cdabb0ac8b5d99"
-MD5_PPM_420_ISLOW_ARI_CROP53x53_4_4 = "886c6775af22370257122f8b16207e6d"
-MD5_PPM_444_ISLOW_SKIP1_6 = "5606f86874cf26b8fcee1117a0a436a6"
-MD5_PPM_444_ISLOW_PROG_CROP98x98_13_13 = "db87dc7ce26bcdc7a6b56239ce2b9d6c"
-MD5_PPM_444_ISLOW_ARI_CROP37x37_0_0 = "cb57b32bd6d03e35432362f7bf184b6d"
-MD5_JPEG_CROP = "b4197f377e621c4e9b1d20471432610d"
-
-
-def test_bittest():
-
-# These tests are carefully crafted to provide full coverage of as many of the
-# underlying algorithms as possible (including all of the SIMD-accelerated
-# ones.)
-
-# CC: null SAMP: fullsize FDCT: islow ENT: huff
- run("cjpeg -rgb -dct int -outfile testout_rgb_islow.jpg $(srcdir)/testimages/testorig.ppm")
- md5cmp(MD5_JPEG_RGB_ISLOW, "testout_rgb_islow.jpg")
-# CC: null SAMP: fullsize IDCT: islow ENT: huff
- run("djpeg -dct int -ppm -outfile testout_rgb_islow.ppm testout_rgb_islow.jpg")
- md5cmp(MD5_PPM_RGB_ISLOW, "testout_rgb_islow.ppm")
- rm_f("testout_rgb_islow.ppm")
-#if WITH_12BIT
-# rm_f("testout_rgb_islow.jpg")
-#else
-# CC: RGB->RGB565 SAMP: fullsize IDCT: islow ENT: huff
- run("djpeg -dct int -rgb565 -dither none -bmp -outfile testout_rgb_islow_565.bmp testout_rgb_islow.jpg")
- md5cmp(MD5_BMP_RGB_ISLOW_565, "testout_rgb_islow_565.bmp")
- rm_f("testout_rgb_islow_565.bmp")
-# CC: RGB->RGB565 (dithered) SAMP: fullsize IDCT: islow ENT: huff
- run("djpeg -dct int -rgb565 -bmp -outfile testout_rgb_islow_565D.bmp testout_rgb_islow.jpg")
- md5cmp(MD5_BMP_RGB_ISLOW_565D, "testout_rgb_islow_565D.bmp")
- rm_f("testout_rgb_islow_565D.bmp testout_rgb_islow.jpg")
-#endif
-
-# CC: RGB->YCC SAMP: fullsize/h2v1 FDCT: ifast ENT: 2-pass huff
- run("cjpeg -sample 2x1 -dct fast -opt -outfile testout_422_ifast_opt.jpg $(srcdir)/testimages/testorig.ppm")
- md5cmp(MD5_JPEG_422_IFAST_OPT, "testout_422_ifast_opt.jpg")
-# CC: YCC->RGB SAMP: fullsize/h2v1 fancy IDCT: ifast ENT: huff
- run("djpeg -dct fast -outfile testout_422_ifast.ppm testout_422_ifast_opt.jpg")
- md5cmp(MD5_PPM_422_IFAST, "testout_422_ifast.ppm")
- rm_f("testout_422_ifast.ppm")
-# CC: YCC->RGB SAMP: h2v1 merged IDCT: ifast ENT: huff
- run("djpeg -dct fast -nosmooth -outfile testout_422m_ifast.ppm testout_422_ifast_opt.jpg")
- md5cmp(MD5_PPM_422M_IFAST, "testout_422m_ifast.ppm")
- rm_f("testout_422m_ifast.ppm")
-#if WITH_12BIT
-# rm_f("testout_422_ifast_opt.jpg")
-#else
-# CC: YCC->RGB565 SAMP: h2v1 merged IDCT: ifast ENT: huff
- run("djpeg -dct int -nosmooth -rgb565 -dither none -bmp -outfile testout_422m_ifast_565.bmp testout_422_ifast_opt.jpg")
- md5cmp(MD5_BMP_422M_IFAST_565, "testout_422m_ifast_565.bmp")
- rm_f("testout_422m_ifast_565.bmp")
-# CC: YCC->RGB565 (dithered) SAMP: h2v1 merged IDCT: ifast ENT: huff
- run("djpeg -dct int -nosmooth -rgb565 -bmp -outfile testout_422m_ifast_565D.bmp testout_422_ifast_opt.jpg")
- md5cmp(MD5_BMP_422M_IFAST_565D, "testout_422m_ifast_565D.bmp")
- rm_f("testout_422m_ifast_565D.bmp testout_422_ifast_opt.jpg")
-#endif
-
-# CC: RGB->YCC SAMP: fullsize/h2v2 FDCT: ifast ENT: prog huff
- run("cjpeg -sample 2x2 -quality 100 -dct fast -prog -outfile testout_420_q100_ifast_prog.jpg $(srcdir)/testimages/testorig.ppm")
- md5cmp(MD5_JPEG_420_IFAST_Q100_PROG, "testout_420_q100_ifast_prog.jpg")
-# CC: YCC->RGB SAMP: fullsize/h2v2 fancy IDCT: ifast ENT: prog huff
- run("djpeg -dct fast -outfile testout_420_q100_ifast.ppm testout_420_q100_ifast_prog.jpg")
- md5cmp(MD5_PPM_420_Q100_IFAST, "testout_420_q100_ifast.ppm")
- rm_f("testout_420_q100_ifast.ppm")
-# CC: YCC->RGB SAMP: h2v2 merged IDCT: ifast ENT: prog huff
- run("djpeg -dct fast -nosmooth -outfile testout_420m_q100_ifast.ppm testout_420_q100_ifast_prog.jpg")
- md5cmp(MD5_PPM_420M_Q100_IFAST, "testout_420m_q100_ifast.ppm")
- rm_f("testout_420m_q100_ifast.ppm testout_420_q100_ifast_prog.jpg")
-
-# CC: RGB->Gray SAMP: fullsize FDCT: islow ENT: huff
- run("cjpeg -gray -dct int -outfile testout_gray_islow.jpg $(srcdir)/testimages/testorig.ppm")
- md5cmp(MD5_JPEG_GRAY_ISLOW, "testout_gray_islow.jpg")
-# CC: Gray->Gray SAMP: fullsize IDCT: islow ENT: huff
- run("djpeg -dct int -outfile testout_gray_islow.ppm testout_gray_islow.jpg")
- md5cmp(MD5_PPM_GRAY_ISLOW, "testout_gray_islow.ppm")
- rm_f("testout_gray_islow.ppm")
-# CC: Gray->RGB SAMP: fullsize IDCT: islow ENT: huff
- run("djpeg -dct int -rgb -outfile testout_gray_islow_rgb.ppm testout_gray_islow.jpg")
- md5cmp(MD5_PPM_GRAY_ISLOW_RGB, "testout_gray_islow_rgb.ppm")
- rm_f("testout_gray_islow_rgb.ppm")
-#if WITH_12BIT
-# rm_f("testout_gray_islow.jpg")
-#else
-# CC: Gray->RGB565 SAMP: fullsize IDCT: islow ENT: huff
- run("djpeg -dct int -rgb565 -dither none -bmp -outfile testout_gray_islow_565.bmp testout_gray_islow.jpg")
- md5cmp(MD5_BMP_GRAY_ISLOW_565, "testout_gray_islow_565.bmp")
- rm_f("testout_gray_islow_565.bmp")
-# CC: Gray->RGB565 (dithered) SAMP: fullsize IDCT: islow ENT: huff
- run("djpeg -dct int -rgb565 -bmp -outfile testout_gray_islow_565D.bmp testout_gray_islow.jpg")
- md5cmp(MD5_BMP_GRAY_ISLOW_565D, "testout_gray_islow_565D.bmp")
- rm_f("testout_gray_islow_565D.bmp testout_gray_islow.jpg")
-#endif
-
-# CC: RGB->YCC SAMP: fullsize smooth/h2v2 smooth FDCT: islow
-# ENT: 2-pass huff
- run("cjpeg -sample 2x2 -smooth 1 -dct int -opt -outfile testout_420s_ifast_opt.jpg $(srcdir)/testimages/testorig.ppm")
- md5cmp(MD5_JPEG_420S_IFAST_OPT, "testout_420s_ifast_opt.jpg")
- rm_f("testout_420s_ifast_opt.jpg")
-
-# The output of the floating point tests is not validated by default, because
-# the output differs depending on the type of floating point math used, and
-# this is only deterministic if the DCT/IDCT are implemented using SIMD
-# instructions on a particular platform. Pass one of the following on the make
-# command line to validate the floating point tests against one of the expected
-# results:
-#
-# FLOATTEST=sse validate against the expected results from the libjpeg-turbo
-# SSE SIMD extensions
-# FLOATTEST=32bit validate against the expected results from the C code
-# when running on a 32-bit FPU (or when SSE is being used for
-# floating point math, which is generally the default with
-# x86-64 compilers)
-# FLOATTEST=64bit validate against the exepected results from the C code
-# when running on a 64-bit FPU
-
-# CC: RGB->YCC SAMP: fullsize/int FDCT: float ENT: prog huff
-# run("cjpeg -sample 3x2 -dct float -prog -outfile testout_3x2_float_prog.jpg $(srcdir)/testimages/testorig.ppm")
-# if [ "${FLOATTEST}" = "sse" ]; then \
-# md5cmp(MD5_JPEG_3x2_FLOAT_PROG_SSE, "testout_3x2_float_prog.jpg"); \
-# elif [ "${FLOATTEST}" = "32bit" -o "${FLOATTEST}" = "64bit" ]; then \
-# md5cmp(MD5_JPEG_3x2_FLOAT_PROG_32BIT, "testout_3x2_float_prog.jpg"); \
-# fi
-# CC: YCC->RGB SAMP: fullsize/int IDCT: float ENT: prog huff
-# run("djpeg -dct float -outfile testout_3x2_float.ppm testout_3x2_float_prog.jpg")
-# if [ "${FLOATTEST}" = "sse" ]; then \
-# md5cmp(MD5_PPM_3x2_FLOAT_SSE, "testout_3x2_float.ppm"); \
-# elif [ "${FLOATTEST}" = "32bit" ]; then \
-# md5cmp(MD5_PPM_3x2_FLOAT_32BIT, "testout_3x2_float.ppm"); \
-# elif [ "${FLOATTEST}" = "64bit" ]; then \
-# md5cmp(MD5_PPM_3x2_FLOAT_64BIT, "testout_3x2_float.ppm"); \
-# fi
-# rm_f("testout_3x2_float.ppm testout_3x2_float_prog.jpg")
-
-# CC: RGB->YCC SAMP: fullsize/int FDCT: ifast ENT: prog huff
- run("cjpeg -sample 3x2 -dct fast -prog -outfile testout_3x2_ifast_prog.jpg $(srcdir)/testimages/testorig.ppm")
- md5cmp(MD5_JPEG_3x2_IFAST_PROG, "testout_3x2_ifast_prog.jpg")
-# CC: YCC->RGB SAMP: fullsize/int IDCT: ifast ENT: prog huff
- run("djpeg -dct fast -outfile testout_3x2_ifast.ppm testout_3x2_ifast_prog.jpg")
- md5cmp(MD5_PPM_3x2_IFAST, "testout_3x2_ifast.ppm")
- rm_f("testout_3x2_ifast.ppm testout_3x2_ifast_prog.jpg")
-
-#if WITH_ARITH_ENC
-# CC: YCC->RGB SAMP: fullsize/h2v2 FDCT: islow ENT: arith
- run("cjpeg -dct int -arithmetic -outfile testout_420_islow_ari.jpg $(srcdir)/testimages/testorig.ppm")
- md5cmp(MD5_JPEG_420_ISLOW_ARI, "testout_420_islow_ari.jpg")
- rm_f("testout_420_islow_ari.jpg")
- run("jpegtran -arithmetic -outfile testout_420_islow_ari.jpg $(srcdir)/testimages/testimgint.jpg")
- md5cmp(MD5_JPEG_420_ISLOW_ARI, "testout_420_islow_ari.jpg")
- rm_f("testout_420_islow_ari.jpg")
-# CC: YCC->RGB SAMP: fullsize FDCT: islow ENT: prog arith
- run("cjpeg -sample 1x1 -dct int -prog -arithmetic -outfile testout_444_islow_progari.jpg $(srcdir)/testimages/testorig.ppm")
- md5cmp(MD5_JPEG_444_ISLOW_PROGARI, "testout_444_islow_progari.jpg")
- rm_f("testout_444_islow_progari.jpg")
-#endif
-#if WITH_ARITH_DEC
-# CC: RGB->YCC SAMP: h2v2 merged IDCT: ifast ENT: arith
- run("djpeg -fast -ppm -outfile testout_420m_ifast_ari.ppm $(srcdir)/testimages/testimgari.jpg")
- md5cmp(MD5_PPM_420M_IFAST_ARI, "testout_420m_ifast_ari.ppm")
- rm_f("testout_420m_ifast_ari.ppm")
- run("jpegtran -outfile testout_420_islow.jpg $(srcdir)/testimages/testimgari.jpg")
- md5cmp(MD5_JPEG_420_ISLOW, "testout_420_islow.jpg")
- rm_f("testout_420_islow.jpg")
-#endif
-
-# CC: YCC->RGB SAMP: h2v2 merged IDCT: 16x16 islow ENT: huff
- run("djpeg -dct int -scale 2/1 -nosmooth -ppm -outfile testout_420m_islow_2_1.ppm $(srcdir)/testimages/$(TESTORIG)")
- md5cmp(MD5_PPM_420M_ISLOW_2_1, "testout_420m_islow_2_1.ppm")
- rm_f("testout_420m_islow_2_1.ppm")
-# CC: YCC->RGB SAMP: h2v2 merged IDCT: 15x15 islow ENT: huff
- run("djpeg -dct int -scale 15/8 -nosmooth -ppm -outfile testout_420m_islow_15_8.ppm $(srcdir)/testimages/$(TESTORIG)")
- md5cmp(MD5_PPM_420M_ISLOW_15_8, "testout_420m_islow_15_8.ppm")
- rm_f("testout_420m_islow_15_8.ppm")
-# CC: YCC->RGB SAMP: h2v2 merged IDCT: 13x13 islow ENT: huff
- run("djpeg -dct int -scale 13/8 -nosmooth -ppm -outfile testout_420m_islow_13_8.ppm $(srcdir)/testimages/$(TESTORIG)")
- md5cmp(MD5_PPM_420M_ISLOW_13_8, "testout_420m_islow_13_8.ppm")
- rm_f("testout_420m_islow_13_8.ppm")
-# CC: YCC->RGB SAMP: h2v2 merged IDCT: 11x11 islow ENT: huff
- run("djpeg -dct int -scale 11/8 -nosmooth -ppm -outfile testout_420m_islow_11_8.ppm $(srcdir)/testimages/$(TESTORIG)")
- md5cmp(MD5_PPM_420M_ISLOW_11_8, "testout_420m_islow_11_8.ppm")
- rm_f("testout_420m_islow_11_8.ppm")
-# CC: YCC->RGB SAMP: h2v2 merged IDCT: 9x9 islow ENT: huff
- run("djpeg -dct int -scale 9/8 -nosmooth -ppm -outfile testout_420m_islow_9_8.ppm $(srcdir)/testimages/$(TESTORIG)")
- md5cmp(MD5_PPM_420M_ISLOW_9_8, "testout_420m_islow_9_8.ppm")
- rm_f("testout_420m_islow_9_8.ppm")
-# CC: YCC->RGB SAMP: h2v2 merged IDCT: 7x7 islow/14x14 islow ENT: huff
- run("djpeg -dct int -scale 7/8 -nosmooth -ppm -outfile testout_420m_islow_7_8.ppm $(srcdir)/testimages/$(TESTORIG)")
- md5cmp(MD5_PPM_420M_ISLOW_7_8, "testout_420m_islow_7_8.ppm")
- rm_f("testout_420m_islow_7_8.ppm")
-# CC: YCC->RGB SAMP: h2v2 merged IDCT: 6x6 islow/12x12 islow ENT: huff
- run("djpeg -dct int -scale 3/4 -nosmooth -ppm -outfile testout_420m_islow_3_4.ppm $(srcdir)/testimages/$(TESTORIG)")
- md5cmp(MD5_PPM_420M_ISLOW_3_4, "testout_420m_islow_3_4.ppm")
- rm_f("testout_420m_islow_3_4.ppm")
-# CC: YCC->RGB SAMP: h2v2 merged IDCT: 5x5 islow/10x10 islow ENT: huff
- run("djpeg -dct int -scale 5/8 -nosmooth -ppm -outfile testout_420m_islow_5_8.ppm $(srcdir)/testimages/$(TESTORIG)")
- md5cmp(MD5_PPM_420M_ISLOW_5_8, "testout_420m_islow_5_8.ppm")
- rm_f("testout_420m_islow_5_8.ppm")
-# CC: YCC->RGB SAMP: h2v2 merged IDCT: 4x4 islow/8x8 islow ENT: huff
- run("djpeg -dct int -scale 1/2 -nosmooth -ppm -outfile testout_420m_islow_1_2.ppm $(srcdir)/testimages/$(TESTORIG)")
- md5cmp(MD5_PPM_420M_ISLOW_1_2, "testout_420m_islow_1_2.ppm")
- rm_f("testout_420m_islow_1_2.ppm")
-# CC: YCC->RGB SAMP: h2v2 merged IDCT: 3x3 islow/6x6 islow ENT: huff
- run("djpeg -dct int -scale 3/8 -nosmooth -ppm -outfile testout_420m_islow_3_8.ppm $(srcdir)/testimages/$(TESTORIG)")
- md5cmp(MD5_PPM_420M_ISLOW_3_8, "testout_420m_islow_3_8.ppm")
- rm_f("testout_420m_islow_3_8.ppm")
-# CC: YCC->RGB SAMP: h2v2 merged IDCT: 2x2 islow/4x4 islow ENT: huff
- run("djpeg -dct int -scale 1/4 -nosmooth -ppm -outfile testout_420m_islow_1_4.ppm $(srcdir)/testimages/$(TESTORIG)")
- md5cmp(MD5_PPM_420M_ISLOW_1_4, "testout_420m_islow_1_4.ppm")
- rm_f("testout_420m_islow_1_4.ppm")
-# CC: YCC->RGB SAMP: h2v2 merged IDCT: 1x1 islow/2x2 islow ENT: huff
- run("djpeg -dct int -scale 1/8 -nosmooth -ppm -outfile testout_420m_islow_1_8.ppm $(srcdir)/testimages/$(TESTORIG)")
- md5cmp(MD5_PPM_420M_ISLOW_1_8, "testout_420m_islow_1_8.ppm")
- rm_f("testout_420m_islow_1_8.ppm")
-#if WITH_12BIT
-#else
-# CC: YCC->RGB (dithered) SAMP: h2v2 fancy IDCT: islow ENT: huff
- run("djpeg -dct int -colors 256 -bmp -outfile testout_420_islow_256.bmp $(srcdir)/testimages/$(TESTORIG)")
- md5cmp(MD5_BMP_420_ISLOW_256, "testout_420_islow_256.bmp")
- rm_f("testout_420_islow_256.bmp")
-# CC: YCC->RGB565 SAMP: h2v2 fancy IDCT: islow ENT: huff
- run("djpeg -dct int -rgb565 -dither none -bmp -outfile testout_420_islow_565.bmp $(srcdir)/testimages/$(TESTORIG)")
- md5cmp(MD5_BMP_420_ISLOW_565, "testout_420_islow_565.bmp")
- rm_f("testout_420_islow_565.bmp")
-# CC: YCC->RGB565 (dithered) SAMP: h2v2 fancy IDCT: islow ENT: huff
- run("djpeg -dct int -rgb565 -bmp -outfile testout_420_islow_565D.bmp $(srcdir)/testimages/$(TESTORIG)")
- md5cmp(MD5_BMP_420_ISLOW_565D, "testout_420_islow_565D.bmp")
- rm_f("testout_420_islow_565D.bmp")
-# CC: YCC->RGB565 SAMP: h2v2 merged IDCT: islow ENT: huff
- run("djpeg -dct int -nosmooth -rgb565 -dither none -bmp -outfile testout_420m_islow_565.bmp $(srcdir)/testimages/$(TESTORIG)")
- md5cmp(MD5_BMP_420M_ISLOW_565, "testout_420m_islow_565.bmp")
- rm_f("testout_420m_islow_565.bmp")
-# CC: YCC->RGB565 (dithered) SAMP: h2v2 merged IDCT: islow ENT: huff
- run("djpeg -dct int -nosmooth -rgb565 -bmp -outfile testout_420m_islow_565D.bmp $(srcdir)/testimages/$(TESTORIG)")
- md5cmp(MD5_BMP_420M_ISLOW_565D, "testout_420m_islow_565D.bmp")
- rm_f("testout_420m_islow_565D.bmp")
-#endif
-
-# Partial decode tests. These tests are designed to cover all of the possible
-# code paths in jpeg_skip_scanlines().
-
-# Context rows: Yes Intra-iMCU row: Yes iMCU row prefetch: No ENT: huff
- run("djpeg -dct int -skip 15,31 -ppm -outfile testout_420_islow_skip15,31.ppm $(srcdir)/testimages/$(TESTORIG)")
- md5cmp(MD5_PPM_420_ISLOW_SKIP15_31, "testout_420_islow_skip15,31.ppm")
- rm_f("testout_420_islow_skip15,31.ppm")
-# Context rows: Yes Intra-iMCU row: No iMCU row prefetch: Yes ENT: arith
-#if WITH_ARITH_DEC
- run("djpeg -dct int -skip 16,139 -ppm -outfile testout_420_islow_ari_skip16,139.ppm $(srcdir)/testimages/testimgari.jpg")
- md5cmp(MD5_PPM_420_ISLOW_ARI_SKIP16_139, "testout_420_islow_ari_skip16,139.ppm")
- rm_f("testout_420_islow_ari_skip16,139.ppm")
-#endif
-# Context rows: Yes Intra-iMCU row: No iMCU row prefetch: No ENT: prog huff
- run("cjpeg -dct int -prog -outfile testout_420_islow_prog.jpg $(srcdir)/testimages/testorig.ppm")
- run("djpeg -dct int -crop 62x62+71+71 -ppm -outfile testout_420_islow_prog_crop62x62,71,71.ppm testout_420_islow_prog.jpg")
- md5cmp(MD5_PPM_420_ISLOW_PROG_CROP62x62_71_71, "testout_420_islow_prog_crop62x62,71,71.ppm")
- rm_f("testout_420_islow_prog_crop62x62,71,71.ppm testout_420_islow_prog.jpg")
-# Context rows: Yes Intra-iMCU row: No iMCU row prefetch: No ENT: arith
-#if WITH_ARITH_DEC
- run("djpeg -dct int -crop 53x53+4+4 -ppm -outfile testout_420_islow_ari_crop53x53,4,4.ppm $(srcdir)/testimages/testimgari.jpg")
- md5cmp(MD5_PPM_420_ISLOW_ARI_CROP53x53_4_4, "testout_420_islow_ari_crop53x53,4,4.ppm")
- rm_f("testout_420_islow_ari_crop53x53,4,4.ppm")
-#endif
-# Context rows: No Intra-iMCU row: Yes ENT: huff
- run("cjpeg -dct int -sample 1x1 -outfile testout_444_islow.jpg $(srcdir)/testimages/testorig.ppm")
- run("djpeg -dct int -skip 1,6 -ppm -outfile testout_444_islow_skip1,6.ppm testout_444_islow.jpg")
- md5cmp(MD5_PPM_444_ISLOW_SKIP1_6, "testout_444_islow_skip1,6.ppm")
- rm_f("testout_444_islow_skip1,6.ppm testout_444_islow.jpg")
-# Context rows: No Intra-iMCU row: No ENT: prog huff
- run("cjpeg -dct int -prog -sample 1x1 -outfile testout_444_islow_prog.jpg $(srcdir)/testimages/testorig.ppm")
- run("djpeg -dct int -crop 98x98+13+13 -ppm -outfile testout_444_islow_prog_crop98x98,13,13.ppm testout_444_islow_prog.jpg")
- md5cmp(MD5_PPM_444_ISLOW_PROG_CROP98x98_13_13, "testout_444_islow_prog_crop98x98,13,13.ppm")
- rm_f("testout_444_islow_prog_crop98x98,13,13.ppm testout_444_islow_prog.jpg")
-# Context rows: No Intra-iMCU row: No ENT: arith
-#if WITH_ARITH_ENC
- run("cjpeg -dct int -arithmetic -sample 1x1 -outfile testout_444_islow_ari.jpg $(srcdir)/testimages/testorig.ppm")
-#if WITH_ARITH_DEC
- run("djpeg -dct int -crop 37x37+0+0 -ppm -outfile testout_444_islow_ari_crop37x37,0,0.ppm testout_444_islow_ari.jpg")
- md5cmp(MD5_PPM_444_ISLOW_ARI_CROP37x37_0_0, "testout_444_islow_ari_crop37x37,0,0.ppm")
- rm_f("testout_444_islow_ari_crop37x37,0,0.ppm")
-#endif
- rm_f("testout_444_islow_ari.jpg")
-#endif
-
- run("jpegtran -crop 120x90+20+50 -transpose -perfect -outfile testout_crop.jpg $(srcdir)/testimages/$(TESTORIG)")
- md5cmp(MD5_JPEG_CROP, "testout_crop.jpg")
- rm_f("testout_crop.jpg")
diff --git a/contrib/libs/libjpeg-turbo/ut/canondata/result.json b/contrib/libs/libjpeg-turbo/ut/canondata/result.json
deleted file mode 100644
index 4afb45615c..0000000000
--- a/contrib/libs/libjpeg-turbo/ut/canondata/result.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "tjunittest.test_tjunittest": {
- "checksum": "3ad83d649fb076b109644289097e1e4c",
- "uri": "sbr://132419515/tjunittest.test_tjunittest/tjunittest.out.txt"
- },
- "tjunittest.test_tjunittest_alloc": {
- "checksum": "6547866c25c62ea63e573c996cab1961",
- "uri": "sbr://132419515/tjunittest.test_tjunittest_alloc/tjunittest.out.txt.0"
- },
- "tjunittest.test_tjunittest_yuv": {
- "checksum": "9c1931df701c3ae1c45effb008edde2e",
- "uri": "sbr://132419515/tjunittest.test_tjunittest_yuv/tjunittest.out.txt.1"
- },
- "tjunittest.test_tjunittest_yuv_alloc": {
- "checksum": "ef32f9cac945fa04aeed61f450fddf79",
- "uri": "sbr://132419515/tjunittest.test_tjunittest_yuv_alloc/tjunittest.out.txt.2"
- },
- "tjunittest.test_tjunittest_yuv_noyuvpad": {
- "checksum": "9c1931df701c3ae1c45effb008edde2e",
- "uri": "sbr://132419515/tjunittest.test_tjunittest_yuv_noyuvpad/tjunittest.out.txt.3"
- }
-} \ No newline at end of file
diff --git a/contrib/libs/libjpeg-turbo/ut/tjunittest.py b/contrib/libs/libjpeg-turbo/ut/tjunittest.py
deleted file mode 100644
index 972e069b29..0000000000
--- a/contrib/libs/libjpeg-turbo/ut/tjunittest.py
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/usr/bin/python
-
-import yatest.common
-
-_TJUNITTEST = "contrib/libs/libjpeg-turbo/tjunittest/tjunittest"
-
-def run_unit(args=None):
- binary = yatest.common.binary_path(_TJUNITTEST)
- return yatest.common.canonical_execute(binary, args)
-
-def test_tjunittest():
- return run_unit()
-
-def test_tjunittest_alloc():
- return run_unit(["-alloc"])
-
-def test_tjunittest_yuv():
- return run_unit(["-yuv"])
-
-def test_tjunittest_yuv_alloc():
- return run_unit(["-yuv", "-alloc"])
-
-def test_tjunittest_yuv_noyuvpad():
- return run_unit(["-yuv", "-noyuvpad"])
diff --git a/contrib/libs/libjpeg-turbo/ut/ya.make b/contrib/libs/libjpeg-turbo/ut/ya.make
deleted file mode 100644
index bdec380d81..0000000000
--- a/contrib/libs/libjpeg-turbo/ut/ya.make
+++ /dev/null
@@ -1,23 +0,0 @@
-PY3TEST()
-
-WITHOUT_LICENSE_TEXTS()
-
-NO_LINT()
-
-SIZE(MEDIUM)
-
-TEST_SRCS(
- tjunittest.py
- bittests.py
-)
-
-DEPENDS(
- contrib/libs/libjpeg-turbo/cjpeg
- contrib/libs/libjpeg-turbo/djpeg
- contrib/libs/libjpeg-turbo/jpegtran
- contrib/libs/libjpeg-turbo/tjunittest
-)
-
-DATA(arcadia/contrib/libs/libjpeg-turbo/testimages)
-
-END()
diff --git a/contrib/libs/libjpeg-turbo/wrbmp.c b/contrib/libs/libjpeg-turbo/wrbmp.c
deleted file mode 100644
index 45fff684d8..0000000000
--- a/contrib/libs/libjpeg-turbo/wrbmp.c
+++ /dev/null
@@ -1,552 +0,0 @@
-/*
- * wrbmp.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2013, Linaro Limited.
- * Copyright (C) 2014-2015, 2017, 2019, 2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains routines to write output images in Microsoft "BMP"
- * format (MS Windows 3.x and OS/2 1.x flavors).
- * Either 8-bit colormapped or 24-bit full-color format can be written.
- * No compression is supported.
- *
- * These routines may need modification for non-Unix environments or
- * specialized applications. As they stand, they assume output to
- * an ordinary stdio stream.
- *
- * This code contributed by James Arthur Boucher.
- */
-
-#include "cmyk.h"
-#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
-#include "jconfigint.h"
-
-#ifdef BMP_SUPPORTED
-
-
-/*
- * To support 12-bit JPEG data, we'd have to scale output down to 8 bits.
- * This is not yet implemented.
- */
-
-#if BITS_IN_JSAMPLE != 8
- Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */
-#endif
-
-/*
- * Since BMP stores scanlines bottom-to-top, we have to invert the image
- * from JPEG's top-to-bottom order. To do this, we save the outgoing data
- * in a virtual array during put_pixel_row calls, then actually emit the
- * BMP file during finish_output. The virtual array contains one JSAMPLE per
- * pixel if the output is grayscale or colormapped, three if it is full color.
- */
-
-/* Private version of data destination object */
-
-typedef struct {
- struct djpeg_dest_struct pub; /* public fields */
-
- boolean is_os2; /* saves the OS2 format request flag */
-
- jvirt_sarray_ptr whole_image; /* needed to reverse row order */
- JDIMENSION data_width; /* JSAMPLEs per row */
- JDIMENSION row_width; /* physical width of one row in the BMP file */
- int pad_bytes; /* number of padding bytes needed per row */
- JDIMENSION cur_output_row; /* next row# to write to virtual array */
-
- boolean use_inversion_array; /* TRUE = buffer the whole image, which is
- stored to disk in bottom-up order, and
- receive rows from the calling program in
- top-down order
-
- FALSE = the calling program will maintain
- its own image buffer and write the rows in
- bottom-up order */
-
- JSAMPLE *iobuffer; /* I/O buffer (used to buffer a single row to
- disk if use_inversion_array == FALSE) */
-} bmp_dest_struct;
-
-typedef bmp_dest_struct *bmp_dest_ptr;
-
-
-/* Forward declarations */
-LOCAL(void) write_colormap(j_decompress_ptr cinfo, bmp_dest_ptr dest,
- int map_colors, int map_entry_size);
-
-
-static INLINE boolean is_big_endian(void)
-{
- int test_value = 1;
- if (*(char *)&test_value != 1)
- return TRUE;
- return FALSE;
-}
-
-
-/*
- * Write some pixel data.
- * In this module rows_supplied will always be 1.
- */
-
-METHODDEF(void)
-put_pixel_rows(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
- JDIMENSION rows_supplied)
-/* This version is for writing 24-bit pixels */
-{
- bmp_dest_ptr dest = (bmp_dest_ptr)dinfo;
- JSAMPARRAY image_ptr;
- register JSAMPROW inptr, outptr;
- register JDIMENSION col;
- int pad;
-
- if (dest->use_inversion_array) {
- /* Access next row in virtual array */
- image_ptr = (*cinfo->mem->access_virt_sarray)
- ((j_common_ptr)cinfo, dest->whole_image,
- dest->cur_output_row, (JDIMENSION)1, TRUE);
- dest->cur_output_row++;
- outptr = image_ptr[0];
- } else {
- outptr = dest->iobuffer;
- }
-
- /* Transfer data. Note destination values must be in BGR order
- * (even though Microsoft's own documents say the opposite).
- */
- inptr = dest->pub.buffer[0];
-
- if (cinfo->out_color_space == JCS_EXT_BGR) {
- memcpy(outptr, inptr, dest->row_width);
- outptr += cinfo->output_width * 3;
- } else if (cinfo->out_color_space == JCS_RGB565) {
- boolean big_endian = is_big_endian();
- unsigned short *inptr2 = (unsigned short *)inptr;
- for (col = cinfo->output_width; col > 0; col--) {
- if (big_endian) {
- outptr[0] = (*inptr2 >> 5) & 0xF8;
- outptr[1] = ((*inptr2 << 5) & 0xE0) | ((*inptr2 >> 11) & 0x1C);
- outptr[2] = *inptr2 & 0xF8;
- } else {
- outptr[0] = (*inptr2 << 3) & 0xF8;
- outptr[1] = (*inptr2 >> 3) & 0xFC;
- outptr[2] = (*inptr2 >> 8) & 0xF8;
- }
- outptr += 3;
- inptr2++;
- }
- } else if (cinfo->out_color_space == JCS_CMYK) {
- for (col = cinfo->output_width; col > 0; col--) {
- JSAMPLE c = *inptr++, m = *inptr++, y = *inptr++, k = *inptr++;
- cmyk_to_rgb(c, m, y, k, outptr + 2, outptr + 1, outptr);
- outptr += 3;
- }
- } else {
- register int rindex = rgb_red[cinfo->out_color_space];
- register int gindex = rgb_green[cinfo->out_color_space];
- register int bindex = rgb_blue[cinfo->out_color_space];
- register int ps = rgb_pixelsize[cinfo->out_color_space];
-
- for (col = cinfo->output_width; col > 0; col--) {
- outptr[0] = inptr[bindex];
- outptr[1] = inptr[gindex];
- outptr[2] = inptr[rindex];
- outptr += 3; inptr += ps;
- }
- }
-
- /* Zero out the pad bytes. */
- pad = dest->pad_bytes;
- while (--pad >= 0)
- *outptr++ = 0;
-
- if (!dest->use_inversion_array)
- fwrite(dest->iobuffer, 1, dest->row_width, dest->pub.output_file);
-}
-
-METHODDEF(void)
-put_gray_rows(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
- JDIMENSION rows_supplied)
-/* This version is for grayscale OR quantized color output */
-{
- bmp_dest_ptr dest = (bmp_dest_ptr)dinfo;
- JSAMPARRAY image_ptr;
- register JSAMPROW inptr, outptr;
- int pad;
-
- if (dest->use_inversion_array) {
- /* Access next row in virtual array */
- image_ptr = (*cinfo->mem->access_virt_sarray)
- ((j_common_ptr)cinfo, dest->whole_image,
- dest->cur_output_row, (JDIMENSION)1, TRUE);
- dest->cur_output_row++;
- outptr = image_ptr[0];
- } else {
- outptr = dest->iobuffer;
- }
-
- /* Transfer data. */
- inptr = dest->pub.buffer[0];
- memcpy(outptr, inptr, cinfo->output_width);
- outptr += cinfo->output_width;
-
- /* Zero out the pad bytes. */
- pad = dest->pad_bytes;
- while (--pad >= 0)
- *outptr++ = 0;
-
- if (!dest->use_inversion_array)
- fwrite(dest->iobuffer, 1, dest->row_width, dest->pub.output_file);
-}
-
-
-/*
- * Finish up at the end of the file.
- *
- * Here is where we really output the BMP file.
- *
- * First, routines to write the Windows and OS/2 variants of the file header.
- */
-
-LOCAL(void)
-write_bmp_header(j_decompress_ptr cinfo, bmp_dest_ptr dest)
-/* Write a Windows-style BMP file header, including colormap if needed */
-{
- char bmpfileheader[14];
- char bmpinfoheader[40];
-
-#define PUT_2B(array, offset, value) \
- (array[offset] = (char)((value) & 0xFF), \
- array[offset + 1] = (char)(((value) >> 8) & 0xFF))
-#define PUT_4B(array, offset, value) \
- (array[offset] = (char)((value) & 0xFF), \
- array[offset + 1] = (char)(((value) >> 8) & 0xFF), \
- array[offset + 2] = (char)(((value) >> 16) & 0xFF), \
- array[offset + 3] = (char)(((value) >> 24) & 0xFF))
-
- long headersize, bfSize;
- int bits_per_pixel, cmap_entries;
-
- /* Compute colormap size and total file size */
- if (IsExtRGB(cinfo->out_color_space)) {
- if (cinfo->quantize_colors) {
- /* Colormapped RGB */
- bits_per_pixel = 8;
- cmap_entries = 256;
- } else {
- /* Unquantized, full color RGB */
- bits_per_pixel = 24;
- cmap_entries = 0;
- }
- } else if (cinfo->out_color_space == JCS_RGB565 ||
- cinfo->out_color_space == JCS_CMYK) {
- bits_per_pixel = 24;
- cmap_entries = 0;
- } else {
- /* Grayscale output. We need to fake a 256-entry colormap. */
- bits_per_pixel = 8;
- cmap_entries = 256;
- }
- /* File size */
- headersize = 14 + 40 + cmap_entries * 4; /* Header and colormap */
- bfSize = headersize + (long)dest->row_width * (long)cinfo->output_height;
-
- /* Set unused fields of header to 0 */
- memset(bmpfileheader, 0, sizeof(bmpfileheader));
- memset(bmpinfoheader, 0, sizeof(bmpinfoheader));
-
- /* Fill the file header */
- bmpfileheader[0] = 0x42; /* first 2 bytes are ASCII 'B', 'M' */
- bmpfileheader[1] = 0x4D;
- PUT_4B(bmpfileheader, 2, bfSize); /* bfSize */
- /* we leave bfReserved1 & bfReserved2 = 0 */
- PUT_4B(bmpfileheader, 10, headersize); /* bfOffBits */
-
- /* Fill the info header (Microsoft calls this a BITMAPINFOHEADER) */
- PUT_2B(bmpinfoheader, 0, 40); /* biSize */
- PUT_4B(bmpinfoheader, 4, cinfo->output_width); /* biWidth */
- PUT_4B(bmpinfoheader, 8, cinfo->output_height); /* biHeight */
- PUT_2B(bmpinfoheader, 12, 1); /* biPlanes - must be 1 */
- PUT_2B(bmpinfoheader, 14, bits_per_pixel); /* biBitCount */
- /* we leave biCompression = 0, for none */
- /* we leave biSizeImage = 0; this is correct for uncompressed data */
- if (cinfo->density_unit == 2) { /* if have density in dots/cm, then */
- PUT_4B(bmpinfoheader, 24, (long)(cinfo->X_density * 100)); /* XPels/M */
- PUT_4B(bmpinfoheader, 28, (long)(cinfo->Y_density * 100)); /* XPels/M */
- }
- PUT_2B(bmpinfoheader, 32, cmap_entries); /* biClrUsed */
- /* we leave biClrImportant = 0 */
-
- if (fwrite(bmpfileheader, 1, 14, dest->pub.output_file) != (size_t)14)
- ERREXIT(cinfo, JERR_FILE_WRITE);
- if (fwrite(bmpinfoheader, 1, 40, dest->pub.output_file) != (size_t)40)
- ERREXIT(cinfo, JERR_FILE_WRITE);
-
- if (cmap_entries > 0)
- write_colormap(cinfo, dest, cmap_entries, 4);
-}
-
-
-LOCAL(void)
-write_os2_header(j_decompress_ptr cinfo, bmp_dest_ptr dest)
-/* Write an OS2-style BMP file header, including colormap if needed */
-{
- char bmpfileheader[14];
- char bmpcoreheader[12];
- long headersize, bfSize;
- int bits_per_pixel, cmap_entries;
-
- /* Compute colormap size and total file size */
- if (IsExtRGB(cinfo->out_color_space)) {
- if (cinfo->quantize_colors) {
- /* Colormapped RGB */
- bits_per_pixel = 8;
- cmap_entries = 256;
- } else {
- /* Unquantized, full color RGB */
- bits_per_pixel = 24;
- cmap_entries = 0;
- }
- } else if (cinfo->out_color_space == JCS_RGB565 ||
- cinfo->out_color_space == JCS_CMYK) {
- bits_per_pixel = 24;
- cmap_entries = 0;
- } else {
- /* Grayscale output. We need to fake a 256-entry colormap. */
- bits_per_pixel = 8;
- cmap_entries = 256;
- }
- /* File size */
- headersize = 14 + 12 + cmap_entries * 3; /* Header and colormap */
- bfSize = headersize + (long)dest->row_width * (long)cinfo->output_height;
-
- /* Set unused fields of header to 0 */
- memset(bmpfileheader, 0, sizeof(bmpfileheader));
- memset(bmpcoreheader, 0, sizeof(bmpcoreheader));
-
- /* Fill the file header */
- bmpfileheader[0] = 0x42; /* first 2 bytes are ASCII 'B', 'M' */
- bmpfileheader[1] = 0x4D;
- PUT_4B(bmpfileheader, 2, bfSize); /* bfSize */
- /* we leave bfReserved1 & bfReserved2 = 0 */
- PUT_4B(bmpfileheader, 10, headersize); /* bfOffBits */
-
- /* Fill the info header (Microsoft calls this a BITMAPCOREHEADER) */
- PUT_2B(bmpcoreheader, 0, 12); /* bcSize */
- PUT_2B(bmpcoreheader, 4, cinfo->output_width); /* bcWidth */
- PUT_2B(bmpcoreheader, 6, cinfo->output_height); /* bcHeight */
- PUT_2B(bmpcoreheader, 8, 1); /* bcPlanes - must be 1 */
- PUT_2B(bmpcoreheader, 10, bits_per_pixel); /* bcBitCount */
-
- if (fwrite(bmpfileheader, 1, 14, dest->pub.output_file) != (size_t)14)
- ERREXIT(cinfo, JERR_FILE_WRITE);
- if (fwrite(bmpcoreheader, 1, 12, dest->pub.output_file) != (size_t)12)
- ERREXIT(cinfo, JERR_FILE_WRITE);
-
- if (cmap_entries > 0)
- write_colormap(cinfo, dest, cmap_entries, 3);
-}
-
-
-/*
- * Write the colormap.
- * Windows uses BGR0 map entries; OS/2 uses BGR entries.
- */
-
-LOCAL(void)
-write_colormap(j_decompress_ptr cinfo, bmp_dest_ptr dest, int map_colors,
- int map_entry_size)
-{
- JSAMPARRAY colormap = cinfo->colormap;
- int num_colors = cinfo->actual_number_of_colors;
- FILE *outfile = dest->pub.output_file;
- int i;
-
- if (colormap != NULL) {
- if (cinfo->out_color_components == 3) {
- /* Normal case with RGB colormap */
- for (i = 0; i < num_colors; i++) {
- putc(colormap[2][i], outfile);
- putc(colormap[1][i], outfile);
- putc(colormap[0][i], outfile);
- if (map_entry_size == 4)
- putc(0, outfile);
- }
- } else {
- /* Grayscale colormap (only happens with grayscale quantization) */
- for (i = 0; i < num_colors; i++) {
- putc(colormap[0][i], outfile);
- putc(colormap[0][i], outfile);
- putc(colormap[0][i], outfile);
- if (map_entry_size == 4)
- putc(0, outfile);
- }
- }
- } else {
- /* If no colormap, must be grayscale data. Generate a linear "map". */
- for (i = 0; i < 256; i++) {
- putc(i, outfile);
- putc(i, outfile);
- putc(i, outfile);
- if (map_entry_size == 4)
- putc(0, outfile);
- }
- }
- /* Pad colormap with zeros to ensure specified number of colormap entries */
- if (i > map_colors)
- ERREXIT1(cinfo, JERR_TOO_MANY_COLORS, i);
- for (; i < map_colors; i++) {
- putc(0, outfile);
- putc(0, outfile);
- putc(0, outfile);
- if (map_entry_size == 4)
- putc(0, outfile);
- }
-}
-
-
-/*
- * Startup: write the file header unless the inversion array is being used.
- */
-
-METHODDEF(void)
-start_output_bmp(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
-{
- bmp_dest_ptr dest = (bmp_dest_ptr)dinfo;
-
- if (!dest->use_inversion_array) {
- /* Write the header and colormap */
- if (dest->is_os2)
- write_os2_header(cinfo, dest);
- else
- write_bmp_header(cinfo, dest);
- }
-}
-
-
-METHODDEF(void)
-finish_output_bmp(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
-{
- bmp_dest_ptr dest = (bmp_dest_ptr)dinfo;
- register FILE *outfile = dest->pub.output_file;
- JSAMPARRAY image_ptr;
- register JSAMPROW data_ptr;
- JDIMENSION row;
- cd_progress_ptr progress = (cd_progress_ptr)cinfo->progress;
-
- if (dest->use_inversion_array) {
- /* Write the header and colormap */
- if (dest->is_os2)
- write_os2_header(cinfo, dest);
- else
- write_bmp_header(cinfo, dest);
-
- /* Write the file body from our virtual array */
- for (row = cinfo->output_height; row > 0; row--) {
- if (progress != NULL) {
- progress->pub.pass_counter = (long)(cinfo->output_height - row);
- progress->pub.pass_limit = (long)cinfo->output_height;
- (*progress->pub.progress_monitor) ((j_common_ptr)cinfo);
- }
- image_ptr = (*cinfo->mem->access_virt_sarray)
- ((j_common_ptr)cinfo, dest->whole_image, row - 1, (JDIMENSION)1,
- FALSE);
- data_ptr = image_ptr[0];
- fwrite(data_ptr, 1, dest->row_width, outfile);
- }
- if (progress != NULL)
- progress->completed_extra_passes++;
- }
-
- /* Make sure we wrote the output file OK */
- fflush(outfile);
- if (ferror(outfile))
- ERREXIT(cinfo, JERR_FILE_WRITE);
-}
-
-
-/*
- * The module selection routine for BMP format output.
- */
-
-GLOBAL(djpeg_dest_ptr)
-jinit_write_bmp(j_decompress_ptr cinfo, boolean is_os2,
- boolean use_inversion_array)
-{
- bmp_dest_ptr dest;
- JDIMENSION row_width;
-
- /* Create module interface object, fill in method pointers */
- dest = (bmp_dest_ptr)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- sizeof(bmp_dest_struct));
- dest->pub.start_output = start_output_bmp;
- dest->pub.finish_output = finish_output_bmp;
- dest->pub.calc_buffer_dimensions = NULL;
- dest->is_os2 = is_os2;
-
- if (cinfo->out_color_space == JCS_GRAYSCALE) {
- dest->pub.put_pixel_rows = put_gray_rows;
- } else if (IsExtRGB(cinfo->out_color_space)) {
- if (cinfo->quantize_colors)
- dest->pub.put_pixel_rows = put_gray_rows;
- else
- dest->pub.put_pixel_rows = put_pixel_rows;
- } else if (!cinfo->quantize_colors &&
- (cinfo->out_color_space == JCS_RGB565 ||
- cinfo->out_color_space == JCS_CMYK)) {
- dest->pub.put_pixel_rows = put_pixel_rows;
- } else {
- ERREXIT(cinfo, JERR_BMP_COLORSPACE);
- }
-
- /* Calculate output image dimensions so we can allocate space */
- jpeg_calc_output_dimensions(cinfo);
-
- /* Determine width of rows in the BMP file (padded to 4-byte boundary). */
- if (cinfo->out_color_space == JCS_RGB565) {
- row_width = cinfo->output_width * 2;
- dest->row_width = dest->data_width = cinfo->output_width * 3;
- while ((row_width & 3) != 0) row_width++;
- } else if (!cinfo->quantize_colors &&
- (IsExtRGB(cinfo->out_color_space) ||
- cinfo->out_color_space == JCS_CMYK)) {
- row_width = cinfo->output_width * cinfo->output_components;
- dest->row_width = dest->data_width = cinfo->output_width * 3;
- } else {
- row_width = cinfo->output_width * cinfo->output_components;
- dest->row_width = dest->data_width = row_width;
- }
- while ((dest->row_width & 3) != 0) dest->row_width++;
- dest->pad_bytes = (int)(dest->row_width - dest->data_width);
-
-
- if (use_inversion_array) {
- /* Allocate space for inversion array, prepare for write pass */
- dest->whole_image = (*cinfo->mem->request_virt_sarray)
- ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE,
- dest->row_width, cinfo->output_height, (JDIMENSION)1);
- dest->cur_output_row = 0;
- if (cinfo->progress != NULL) {
- cd_progress_ptr progress = (cd_progress_ptr)cinfo->progress;
- progress->total_extra_passes++; /* count file input as separate pass */
- }
- } else {
- dest->iobuffer = (JSAMPLE *)(*cinfo->mem->alloc_small)
- ((j_common_ptr)cinfo, JPOOL_IMAGE, dest->row_width);
- }
- dest->use_inversion_array = use_inversion_array;
-
- /* Create decompressor output buffer. */
- dest->pub.buffer = (*cinfo->mem->alloc_sarray)
- ((j_common_ptr)cinfo, JPOOL_IMAGE, row_width, (JDIMENSION)1);
- dest->pub.buffer_height = 1;
-
- return (djpeg_dest_ptr)dest;
-}
-
-#endif /* BMP_SUPPORTED */
diff --git a/contrib/libs/libjpeg-turbo/wrgif.c b/contrib/libs/libjpeg-turbo/wrgif.c
deleted file mode 100644
index 620a3ba917..0000000000
--- a/contrib/libs/libjpeg-turbo/wrgif.c
+++ /dev/null
@@ -1,580 +0,0 @@
-/*
- * wrgif.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * Modified 2015-2019 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2015, 2017, 2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains routines to write output images in GIF format.
- *
- * These routines may need modification for non-Unix environments or
- * specialized applications. As they stand, they assume output to
- * an ordinary stdio stream.
- */
-
-/*
- * This code is loosely based on ppmtogif from the PBMPLUS distribution
- * of Feb. 1991. That file contains the following copyright notice:
- * Based on GIFENCODE by David Rowley <mgardi@watdscu.waterloo.edu>.
- * Lempel-Ziv compression based on "compress" by Spencer W. Thomas et al.
- * Copyright (C) 1989 by Jef Poskanzer.
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose and without fee is hereby granted, provided
- * that the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation. This software is provided "as is" without express or
- * implied warranty.
- */
-
-#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
-
-#ifdef GIF_SUPPORTED
-
-
-#define MAX_LZW_BITS 12 /* maximum LZW code size (4096 symbols) */
-
-typedef INT16 code_int; /* must hold -1 .. 2**MAX_LZW_BITS */
-
-#define LZW_TABLE_SIZE ((code_int)1 << MAX_LZW_BITS)
-
-#define HSIZE 5003 /* hash table size for 80% occupancy */
-
-typedef int hash_int; /* must hold -2*HSIZE..2*HSIZE */
-
-#define MAXCODE(n_bits) (((code_int)1 << (n_bits)) - 1)
-
-
-/*
- * The LZW hash table consists of two parallel arrays:
- * hash_code[i] code of symbol in slot i, or 0 if empty slot
- * hash_value[i] symbol's value; undefined if empty slot
- * where slot values (i) range from 0 to HSIZE-1. The symbol value is
- * its prefix symbol's code concatenated with its suffix character.
- *
- * Algorithm: use open addressing double hashing (no chaining) on the
- * prefix code / suffix character combination. We do a variant of Knuth's
- * algorithm D (vol. 3, sec. 6.4) along with G. Knott's relatively-prime
- * secondary probe.
- */
-
-typedef int hash_entry; /* must hold (code_int << 8) | byte */
-
-#define HASH_ENTRY(prefix, suffix) ((((hash_entry)(prefix)) << 8) | (suffix))
-
-
-/* Private version of data destination object */
-
-typedef struct {
- struct djpeg_dest_struct pub; /* public fields */
-
- j_decompress_ptr cinfo; /* back link saves passing separate parm */
-
- /* State for packing variable-width codes into a bitstream */
- int n_bits; /* current number of bits/code */
- code_int maxcode; /* maximum code, given n_bits */
- int init_bits; /* initial n_bits ... restored after clear */
- int cur_accum; /* holds bits not yet output */
- int cur_bits; /* # of bits in cur_accum */
-
- /* LZW string construction */
- code_int waiting_code; /* symbol not yet output; may be extendable */
- boolean first_byte; /* if TRUE, waiting_code is not valid */
-
- /* State for GIF code assignment */
- code_int ClearCode; /* clear code (doesn't change) */
- code_int EOFCode; /* EOF code (ditto) */
- code_int free_code; /* LZW: first not-yet-used symbol code */
- code_int code_counter; /* not LZW: counts output symbols */
-
- /* LZW hash table */
- code_int *hash_code; /* => hash table of symbol codes */
- hash_entry *hash_value; /* => hash table of symbol values */
-
- /* GIF data packet construction buffer */
- int bytesinpkt; /* # of bytes in current packet */
- char packetbuf[256]; /* workspace for accumulating packet */
-
-} gif_dest_struct;
-
-typedef gif_dest_struct *gif_dest_ptr;
-
-
-/*
- * Routines to package finished data bytes into GIF data blocks.
- * A data block consists of a count byte (1..255) and that many data bytes.
- */
-
-LOCAL(void)
-flush_packet(gif_dest_ptr dinfo)
-/* flush any accumulated data */
-{
- if (dinfo->bytesinpkt > 0) { /* never write zero-length packet */
- dinfo->packetbuf[0] = (char)dinfo->bytesinpkt++;
- if (fwrite(dinfo->packetbuf, 1, dinfo->bytesinpkt,
- dinfo->pub.output_file) != (size_t)dinfo->bytesinpkt)
- ERREXIT(dinfo->cinfo, JERR_FILE_WRITE);
- dinfo->bytesinpkt = 0;
- }
-}
-
-
-/* Add a character to current packet; flush to disk if necessary */
-#define CHAR_OUT(dinfo, c) { \
- (dinfo)->packetbuf[++(dinfo)->bytesinpkt] = (char)(c); \
- if ((dinfo)->bytesinpkt >= 255) \
- flush_packet(dinfo); \
-}
-
-
-/* Routine to convert variable-width codes into a byte stream */
-
-LOCAL(void)
-output(gif_dest_ptr dinfo, code_int code)
-/* Emit a code of n_bits bits */
-/* Uses cur_accum and cur_bits to reblock into 8-bit bytes */
-{
- dinfo->cur_accum |= ((long)code) << dinfo->cur_bits;
- dinfo->cur_bits += dinfo->n_bits;
-
- while (dinfo->cur_bits >= 8) {
- CHAR_OUT(dinfo, dinfo->cur_accum & 0xFF);
- dinfo->cur_accum >>= 8;
- dinfo->cur_bits -= 8;
- }
-
- /*
- * If the next entry is going to be too big for the code size,
- * then increase it, if possible. We do this here to ensure
- * that it's done in sync with the decoder's codesize increases.
- */
- if (dinfo->free_code > dinfo->maxcode) {
- dinfo->n_bits++;
- if (dinfo->n_bits == MAX_LZW_BITS)
- dinfo->maxcode = LZW_TABLE_SIZE; /* free_code will never exceed this */
- else
- dinfo->maxcode = MAXCODE(dinfo->n_bits);
- }
-}
-
-
-/* Compression initialization & termination */
-
-
-LOCAL(void)
-clear_hash(gif_dest_ptr dinfo)
-/* Fill the hash table with empty entries */
-{
- /* It's sufficient to zero hash_code[] */
- memset(dinfo->hash_code, 0, HSIZE * sizeof(code_int));
-}
-
-
-LOCAL(void)
-clear_block(gif_dest_ptr dinfo)
-/* Reset compressor and issue a Clear code */
-{
- clear_hash(dinfo); /* delete all the symbols */
- dinfo->free_code = dinfo->ClearCode + 2;
- output(dinfo, dinfo->ClearCode); /* inform decoder */
- dinfo->n_bits = dinfo->init_bits; /* reset code size */
- dinfo->maxcode = MAXCODE(dinfo->n_bits);
-}
-
-
-LOCAL(void)
-compress_init(gif_dest_ptr dinfo, int i_bits)
-/* Initialize compressor */
-{
- /* init all the state variables */
- dinfo->n_bits = dinfo->init_bits = i_bits;
- dinfo->maxcode = MAXCODE(dinfo->n_bits);
- dinfo->ClearCode = ((code_int) 1 << (i_bits - 1));
- dinfo->EOFCode = dinfo->ClearCode + 1;
- dinfo->code_counter = dinfo->free_code = dinfo->ClearCode + 2;
- dinfo->first_byte = TRUE; /* no waiting symbol yet */
- /* init output buffering vars */
- dinfo->bytesinpkt = 0;
- dinfo->cur_accum = 0;
- dinfo->cur_bits = 0;
- /* clear hash table */
- if (dinfo->hash_code != NULL)
- clear_hash(dinfo);
- /* GIF specifies an initial Clear code */
- output(dinfo, dinfo->ClearCode);
-}
-
-
-LOCAL(void)
-compress_term(gif_dest_ptr dinfo)
-/* Clean up at end */
-{
- /* Flush out the buffered LZW code */
- if (!dinfo->first_byte)
- output(dinfo, dinfo->waiting_code);
- /* Send an EOF code */
- output(dinfo, dinfo->EOFCode);
- /* Flush the bit-packing buffer */
- if (dinfo->cur_bits > 0) {
- CHAR_OUT(dinfo, dinfo->cur_accum & 0xFF);
- }
- /* Flush the packet buffer */
- flush_packet(dinfo);
-}
-
-
-/* GIF header construction */
-
-
-LOCAL(void)
-put_word(gif_dest_ptr dinfo, unsigned int w)
-/* Emit a 16-bit word, LSB first */
-{
- putc(w & 0xFF, dinfo->pub.output_file);
- putc((w >> 8) & 0xFF, dinfo->pub.output_file);
-}
-
-
-LOCAL(void)
-put_3bytes(gif_dest_ptr dinfo, int val)
-/* Emit 3 copies of same byte value --- handy subr for colormap construction */
-{
- putc(val, dinfo->pub.output_file);
- putc(val, dinfo->pub.output_file);
- putc(val, dinfo->pub.output_file);
-}
-
-
-LOCAL(void)
-emit_header(gif_dest_ptr dinfo, int num_colors, JSAMPARRAY colormap)
-/* Output the GIF file header, including color map */
-/* If colormap == NULL, synthesize a grayscale colormap */
-{
- int BitsPerPixel, ColorMapSize, InitCodeSize, FlagByte;
- int cshift = dinfo->cinfo->data_precision - 8;
- int i;
-
- if (num_colors > 256)
- ERREXIT1(dinfo->cinfo, JERR_TOO_MANY_COLORS, num_colors);
- /* Compute bits/pixel and related values */
- BitsPerPixel = 1;
- while (num_colors > (1 << BitsPerPixel))
- BitsPerPixel++;
- ColorMapSize = 1 << BitsPerPixel;
- if (BitsPerPixel <= 1)
- InitCodeSize = 2;
- else
- InitCodeSize = BitsPerPixel;
- /*
- * Write the GIF header.
- * Note that we generate a plain GIF87 header for maximum compatibility.
- */
- putc('G', dinfo->pub.output_file);
- putc('I', dinfo->pub.output_file);
- putc('F', dinfo->pub.output_file);
- putc('8', dinfo->pub.output_file);
- putc('7', dinfo->pub.output_file);
- putc('a', dinfo->pub.output_file);
- /* Write the Logical Screen Descriptor */
- put_word(dinfo, (unsigned int)dinfo->cinfo->output_width);
- put_word(dinfo, (unsigned int)dinfo->cinfo->output_height);
- FlagByte = 0x80; /* Yes, there is a global color table */
- FlagByte |= (BitsPerPixel - 1) << 4; /* color resolution */
- FlagByte |= (BitsPerPixel - 1); /* size of global color table */
- putc(FlagByte, dinfo->pub.output_file);
- putc(0, dinfo->pub.output_file); /* Background color index */
- putc(0, dinfo->pub.output_file); /* Reserved (aspect ratio in GIF89) */
- /* Write the Global Color Map */
- /* If the color map is more than 8 bits precision, */
- /* we reduce it to 8 bits by shifting */
- for (i = 0; i < ColorMapSize; i++) {
- if (i < num_colors) {
- if (colormap != NULL) {
- if (dinfo->cinfo->out_color_space == JCS_RGB) {
- /* Normal case: RGB color map */
- putc(colormap[0][i] >> cshift, dinfo->pub.output_file);
- putc(colormap[1][i] >> cshift, dinfo->pub.output_file);
- putc(colormap[2][i] >> cshift, dinfo->pub.output_file);
- } else {
- /* Grayscale "color map": possible if quantizing grayscale image */
- put_3bytes(dinfo, colormap[0][i] >> cshift);
- }
- } else {
- /* Create a grayscale map of num_colors values, range 0..255 */
- put_3bytes(dinfo, (i * 255 + (num_colors - 1) / 2) / (num_colors - 1));
- }
- } else {
- /* fill out the map to a power of 2 */
- put_3bytes(dinfo, CENTERJSAMPLE >> cshift);
- }
- }
- /* Write image separator and Image Descriptor */
- putc(',', dinfo->pub.output_file); /* separator */
- put_word(dinfo, 0); /* left/top offset */
- put_word(dinfo, 0);
- put_word(dinfo, (unsigned int)dinfo->cinfo->output_width); /* image size */
- put_word(dinfo, (unsigned int)dinfo->cinfo->output_height);
- /* flag byte: not interlaced, no local color map */
- putc(0x00, dinfo->pub.output_file);
- /* Write Initial Code Size byte */
- putc(InitCodeSize, dinfo->pub.output_file);
-
- /* Initialize for compression of image data */
- compress_init(dinfo, InitCodeSize + 1);
-}
-
-
-/*
- * Startup: write the file header.
- */
-
-METHODDEF(void)
-start_output_gif(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
-{
- gif_dest_ptr dest = (gif_dest_ptr)dinfo;
-
- if (cinfo->quantize_colors)
- emit_header(dest, cinfo->actual_number_of_colors, cinfo->colormap);
- else
- emit_header(dest, 256, (JSAMPARRAY)NULL);
-}
-
-
-/*
- * Write some pixel data.
- * In this module rows_supplied will always be 1.
- */
-
-
-/*
- * The LZW algorithm proper
- */
-
-METHODDEF(void)
-put_LZW_pixel_rows(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
- JDIMENSION rows_supplied)
-{
- gif_dest_ptr dest = (gif_dest_ptr)dinfo;
- register JSAMPROW ptr;
- register JDIMENSION col;
- code_int c;
- register hash_int i;
- register hash_int disp;
- register hash_entry probe_value;
-
- ptr = dest->pub.buffer[0];
- for (col = cinfo->output_width; col > 0; col--) {
- /* Accept and compress one 8-bit byte */
- c = (code_int)(*ptr++);
-
- if (dest->first_byte) { /* need to initialize waiting_code */
- dest->waiting_code = c;
- dest->first_byte = FALSE;
- continue;
- }
-
- /* Probe hash table to see if a symbol exists for
- * waiting_code followed by c.
- * If so, replace waiting_code by that symbol and continue.
- */
- i = ((hash_int)c << (MAX_LZW_BITS - 8)) + dest->waiting_code;
- /* i is less than twice 2**MAX_LZW_BITS, therefore less than twice HSIZE */
- if (i >= HSIZE)
- i -= HSIZE;
-
- probe_value = HASH_ENTRY(dest->waiting_code, c);
-
- if (dest->hash_code[i] == 0) {
- /* hit empty slot; desired symbol not in table */
- output(dest, dest->waiting_code);
- if (dest->free_code < LZW_TABLE_SIZE) {
- dest->hash_code[i] = dest->free_code++; /* add symbol to hashtable */
- dest->hash_value[i] = probe_value;
- } else
- clear_block(dest);
- dest->waiting_code = c;
- continue;
- }
- if (dest->hash_value[i] == probe_value) {
- dest->waiting_code = dest->hash_code[i];
- continue;
- }
-
- if (i == 0) /* secondary hash (after G. Knott) */
- disp = 1;
- else
- disp = HSIZE - i;
- for (;;) {
- i -= disp;
- if (i < 0)
- i += HSIZE;
- if (dest->hash_code[i] == 0) {
- /* hit empty slot; desired symbol not in table */
- output(dest, dest->waiting_code);
- if (dest->free_code < LZW_TABLE_SIZE) {
- dest->hash_code[i] = dest->free_code++; /* add symbol to hashtable */
- dest->hash_value[i] = probe_value;
- } else
- clear_block(dest);
- dest->waiting_code = c;
- break;
- }
- if (dest->hash_value[i] == probe_value) {
- dest->waiting_code = dest->hash_code[i];
- break;
- }
- }
- }
-}
-
-
-/*
- * The pseudo-compression algorithm.
- *
- * In this version we simply output each pixel value as a separate symbol;
- * thus, no compression occurs. In fact, there is expansion of one bit per
- * pixel, because we use a symbol width one bit wider than the pixel width.
- *
- * GIF ordinarily uses variable-width symbols, and the decoder will expect
- * to ratchet up the symbol width after a fixed number of symbols.
- * To simplify the logic and keep the expansion penalty down, we emit a
- * GIF Clear code to reset the decoder just before the width would ratchet up.
- * Thus, all the symbols in the output file will have the same bit width.
- * Note that emitting the Clear codes at the right times is a mere matter of
- * counting output symbols and is in no way dependent on the LZW algorithm.
- *
- * With a small basic pixel width (low color count), Clear codes will be
- * needed very frequently, causing the file to expand even more. So this
- * simplistic approach wouldn't work too well on bilevel images, for example.
- * But for output of JPEG conversions the pixel width will usually be 8 bits
- * (129 to 256 colors), so the overhead added by Clear symbols is only about
- * one symbol in every 256.
- */
-
-METHODDEF(void)
-put_raw_pixel_rows(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
- JDIMENSION rows_supplied)
-{
- gif_dest_ptr dest = (gif_dest_ptr)dinfo;
- register JSAMPROW ptr;
- register JDIMENSION col;
- code_int c;
-
- ptr = dest->pub.buffer[0];
- for (col = cinfo->output_width; col > 0; col--) {
- c = (code_int)(*ptr++);
- /* Accept and output one pixel value.
- * The given value must be less than n_bits wide.
- */
-
- /* Output the given pixel value as a symbol. */
- output(dest, c);
- /* Issue Clear codes often enough to keep the reader from ratcheting up
- * its symbol size.
- */
- if (dest->code_counter < dest->maxcode) {
- dest->code_counter++;
- } else {
- output(dest, dest->ClearCode);
- dest->code_counter = dest->ClearCode + 2; /* reset the counter */
- }
- }
-}
-
-
-/*
- * Finish up at the end of the file.
- */
-
-METHODDEF(void)
-finish_output_gif(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
-{
- gif_dest_ptr dest = (gif_dest_ptr)dinfo;
-
- /* Flush compression mechanism */
- compress_term(dest);
- /* Write a zero-length data block to end the series */
- putc(0, dest->pub.output_file);
- /* Write the GIF terminator mark */
- putc(';', dest->pub.output_file);
- /* Make sure we wrote the output file OK */
- fflush(dest->pub.output_file);
- if (ferror(dest->pub.output_file))
- ERREXIT(cinfo, JERR_FILE_WRITE);
-}
-
-
-/*
- * Re-calculate buffer dimensions based on output dimensions.
- */
-
-METHODDEF(void)
-calc_buffer_dimensions_gif(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
-{
-}
-
-
-/*
- * The module selection routine for GIF format output.
- */
-
-GLOBAL(djpeg_dest_ptr)
-jinit_write_gif(j_decompress_ptr cinfo, boolean is_lzw)
-{
- gif_dest_ptr dest;
-
- /* Create module interface object, fill in method pointers */
- dest = (gif_dest_ptr)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- sizeof(gif_dest_struct));
- dest->cinfo = cinfo; /* make back link for subroutines */
- dest->pub.start_output = start_output_gif;
- dest->pub.finish_output = finish_output_gif;
- dest->pub.calc_buffer_dimensions = calc_buffer_dimensions_gif;
-
- if (cinfo->out_color_space != JCS_GRAYSCALE &&
- cinfo->out_color_space != JCS_RGB)
- ERREXIT(cinfo, JERR_GIF_COLORSPACE);
-
- /* Force quantization if color or if > 8 bits input */
- if (cinfo->out_color_space != JCS_GRAYSCALE || cinfo->data_precision > 8) {
- /* Force quantization to at most 256 colors */
- cinfo->quantize_colors = TRUE;
- if (cinfo->desired_number_of_colors > 256)
- cinfo->desired_number_of_colors = 256;
- }
-
- /* Calculate output image dimensions so we can allocate space */
- jpeg_calc_output_dimensions(cinfo);
-
- if (cinfo->output_components != 1) /* safety check: just one component? */
- ERREXIT(cinfo, JERR_GIF_BUG);
-
- /* Create decompressor output buffer. */
- dest->pub.buffer = (*cinfo->mem->alloc_sarray)
- ((j_common_ptr)cinfo, JPOOL_IMAGE, cinfo->output_width, (JDIMENSION)1);
- dest->pub.buffer_height = 1;
-
- if (is_lzw) {
- dest->pub.put_pixel_rows = put_LZW_pixel_rows;
- /* Allocate space for hash table */
- dest->hash_code = (code_int *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- HSIZE * sizeof(code_int));
- dest->hash_value = (hash_entry *)
- (*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- HSIZE * sizeof(hash_entry));
- } else {
- dest->pub.put_pixel_rows = put_raw_pixel_rows;
- /* Mark tables unused */
- dest->hash_code = NULL;
- dest->hash_value = NULL;
- }
-
- return (djpeg_dest_ptr)dest;
-}
-
-#endif /* GIF_SUPPORTED */
diff --git a/contrib/libs/libjpeg-turbo/wrppm.c b/contrib/libs/libjpeg-turbo/wrppm.c
deleted file mode 100644
index 57c8aaffac..0000000000
--- a/contrib/libs/libjpeg-turbo/wrppm.c
+++ /dev/null
@@ -1,366 +0,0 @@
-/*
- * wrppm.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1996, Thomas G. Lane.
- * Modified 2009 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2017, 2019-2020, 2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains routines to write output images in PPM/PGM format.
- * The extended 2-byte-per-sample raw PPM/PGM formats are supported.
- * The PBMPLUS library is NOT required to compile this software
- * (but it is highly useful as a set of PPM image manipulation programs).
- *
- * These routines may need modification for non-Unix environments or
- * specialized applications. As they stand, they assume output to
- * an ordinary stdio stream.
- */
-
-#include "cmyk.h"
-#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
-
-#ifdef PPM_SUPPORTED
-
-
-/*
- * For 12-bit JPEG data, we either downscale the values to 8 bits
- * (to write standard byte-per-sample PPM/PGM files), or output
- * nonstandard word-per-sample PPM/PGM files. Downscaling is done
- * if PPM_NORAWWORD is defined (this can be done in the Makefile
- * or in jconfig.h).
- * (When the core library supports data precision reduction, a cleaner
- * implementation will be to ask for that instead.)
- */
-
-#if BITS_IN_JSAMPLE == 8
-#define PUTPPMSAMPLE(ptr, v) *ptr++ = (char)(v)
-#define BYTESPERSAMPLE 1
-#define PPM_MAXVAL 255
-#else
-#ifdef PPM_NORAWWORD
-#define PUTPPMSAMPLE(ptr, v) *ptr++ = (char)((v) >> (BITS_IN_JSAMPLE - 8))
-#define BYTESPERSAMPLE 1
-#define PPM_MAXVAL 255
-#else
-/* The word-per-sample format always puts the MSB first. */
-#define PUTPPMSAMPLE(ptr, v) { \
- register int val_ = v; \
- *ptr++ = (char)((val_ >> 8) & 0xFF); \
- *ptr++ = (char)(val_ & 0xFF); \
-}
-#define BYTESPERSAMPLE 2
-#define PPM_MAXVAL ((1 << BITS_IN_JSAMPLE) - 1)
-#endif
-#endif
-
-
-/*
- * When JSAMPLE is the same size as char, we can just fwrite() the
- * decompressed data to the PPM or PGM file.
- */
-
-
-/* Private version of data destination object */
-
-typedef struct {
- struct djpeg_dest_struct pub; /* public fields */
-
- /* Usually these two pointers point to the same place: */
- char *iobuffer; /* fwrite's I/O buffer */
- JSAMPROW pixrow; /* decompressor output buffer */
- size_t buffer_width; /* width of I/O buffer */
- JDIMENSION samples_per_row; /* JSAMPLEs per output row */
-} ppm_dest_struct;
-
-typedef ppm_dest_struct *ppm_dest_ptr;
-
-
-/*
- * Write some pixel data.
- * In this module rows_supplied will always be 1.
- *
- * put_pixel_rows handles the "normal" 8-bit case where the decompressor
- * output buffer is physically the same as the fwrite buffer.
- */
-
-METHODDEF(void)
-put_pixel_rows(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
- JDIMENSION rows_supplied)
-{
- ppm_dest_ptr dest = (ppm_dest_ptr)dinfo;
-
- fwrite(dest->iobuffer, 1, dest->buffer_width, dest->pub.output_file);
-}
-
-
-/*
- * This code is used when we have to copy the data and apply a pixel
- * format translation. Typically this only happens in 12-bit mode.
- */
-
-METHODDEF(void)
-copy_pixel_rows(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
- JDIMENSION rows_supplied)
-{
- ppm_dest_ptr dest = (ppm_dest_ptr)dinfo;
- register char *bufferptr;
- register JSAMPROW ptr;
-#if BITS_IN_JSAMPLE != 8
- register JDIMENSION col;
-#endif
-
- ptr = dest->pub.buffer[0];
- bufferptr = dest->iobuffer;
-#if BITS_IN_JSAMPLE == 8
- memcpy(bufferptr, ptr, dest->samples_per_row);
-#else
- for (col = dest->samples_per_row; col > 0; col--) {
- PUTPPMSAMPLE(bufferptr, *ptr++);
- }
-#endif
- fwrite(dest->iobuffer, 1, dest->buffer_width, dest->pub.output_file);
-}
-
-
-/*
- * Convert extended RGB to RGB.
- */
-
-METHODDEF(void)
-put_rgb(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, JDIMENSION rows_supplied)
-{
- ppm_dest_ptr dest = (ppm_dest_ptr)dinfo;
- register char *bufferptr;
- register JSAMPROW ptr;
- register JDIMENSION col;
- register int rindex = rgb_red[cinfo->out_color_space];
- register int gindex = rgb_green[cinfo->out_color_space];
- register int bindex = rgb_blue[cinfo->out_color_space];
- register int ps = rgb_pixelsize[cinfo->out_color_space];
-
- ptr = dest->pub.buffer[0];
- bufferptr = dest->iobuffer;
- for (col = cinfo->output_width; col > 0; col--) {
- PUTPPMSAMPLE(bufferptr, ptr[rindex]);
- PUTPPMSAMPLE(bufferptr, ptr[gindex]);
- PUTPPMSAMPLE(bufferptr, ptr[bindex]);
- ptr += ps;
- }
- fwrite(dest->iobuffer, 1, dest->buffer_width, dest->pub.output_file);
-}
-
-
-/*
- * Convert CMYK to RGB.
- */
-
-METHODDEF(void)
-put_cmyk(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
- JDIMENSION rows_supplied)
-{
- ppm_dest_ptr dest = (ppm_dest_ptr)dinfo;
- register char *bufferptr;
- register JSAMPROW ptr;
- register JDIMENSION col;
-
- ptr = dest->pub.buffer[0];
- bufferptr = dest->iobuffer;
- for (col = cinfo->output_width; col > 0; col--) {
- JSAMPLE r, g, b, c = *ptr++, m = *ptr++, y = *ptr++, k = *ptr++;
- cmyk_to_rgb(c, m, y, k, &r, &g, &b);
- PUTPPMSAMPLE(bufferptr, r);
- PUTPPMSAMPLE(bufferptr, g);
- PUTPPMSAMPLE(bufferptr, b);
- }
- fwrite(dest->iobuffer, 1, dest->buffer_width, dest->pub.output_file);
-}
-
-
-/*
- * Write some pixel data when color quantization is in effect.
- * We have to demap the color index values to straight data.
- */
-
-METHODDEF(void)
-put_demapped_rgb(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
- JDIMENSION rows_supplied)
-{
- ppm_dest_ptr dest = (ppm_dest_ptr)dinfo;
- register char *bufferptr;
- register int pixval;
- register JSAMPROW ptr;
- register JSAMPROW color_map0 = cinfo->colormap[0];
- register JSAMPROW color_map1 = cinfo->colormap[1];
- register JSAMPROW color_map2 = cinfo->colormap[2];
- register JDIMENSION col;
-
- ptr = dest->pub.buffer[0];
- bufferptr = dest->iobuffer;
- for (col = cinfo->output_width; col > 0; col--) {
- pixval = *ptr++;
- PUTPPMSAMPLE(bufferptr, color_map0[pixval]);
- PUTPPMSAMPLE(bufferptr, color_map1[pixval]);
- PUTPPMSAMPLE(bufferptr, color_map2[pixval]);
- }
- fwrite(dest->iobuffer, 1, dest->buffer_width, dest->pub.output_file);
-}
-
-
-METHODDEF(void)
-put_demapped_gray(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
- JDIMENSION rows_supplied)
-{
- ppm_dest_ptr dest = (ppm_dest_ptr)dinfo;
- register char *bufferptr;
- register JSAMPROW ptr;
- register JSAMPROW color_map = cinfo->colormap[0];
- register JDIMENSION col;
-
- ptr = dest->pub.buffer[0];
- bufferptr = dest->iobuffer;
- for (col = cinfo->output_width; col > 0; col--) {
- PUTPPMSAMPLE(bufferptr, color_map[*ptr++]);
- }
- fwrite(dest->iobuffer, 1, dest->buffer_width, dest->pub.output_file);
-}
-
-
-/*
- * Startup: write the file header.
- */
-
-METHODDEF(void)
-start_output_ppm(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
-{
- ppm_dest_ptr dest = (ppm_dest_ptr)dinfo;
-
- /* Emit file header */
- switch (cinfo->out_color_space) {
- case JCS_GRAYSCALE:
- /* emit header for raw PGM format */
- fprintf(dest->pub.output_file, "P5\n%ld %ld\n%d\n",
- (long)cinfo->output_width, (long)cinfo->output_height, PPM_MAXVAL);
- break;
- case JCS_RGB:
- case JCS_EXT_RGB:
- case JCS_EXT_RGBX:
- case JCS_EXT_BGR:
- case JCS_EXT_BGRX:
- case JCS_EXT_XBGR:
- case JCS_EXT_XRGB:
- case JCS_EXT_RGBA:
- case JCS_EXT_BGRA:
- case JCS_EXT_ABGR:
- case JCS_EXT_ARGB:
- case JCS_CMYK:
- if (!IsExtRGB(cinfo->out_color_space) && cinfo->quantize_colors)
- ERREXIT(cinfo, JERR_PPM_COLORSPACE);
- /* emit header for raw PPM format */
- fprintf(dest->pub.output_file, "P6\n%ld %ld\n%d\n",
- (long)cinfo->output_width, (long)cinfo->output_height, PPM_MAXVAL);
- break;
- default:
- ERREXIT(cinfo, JERR_PPM_COLORSPACE);
- }
-}
-
-
-/*
- * Finish up at the end of the file.
- */
-
-METHODDEF(void)
-finish_output_ppm(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
-{
- /* Make sure we wrote the output file OK */
- fflush(dinfo->output_file);
- if (ferror(dinfo->output_file))
- ERREXIT(cinfo, JERR_FILE_WRITE);
-}
-
-
-/*
- * Re-calculate buffer dimensions based on output dimensions.
- */
-
-METHODDEF(void)
-calc_buffer_dimensions_ppm(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
-{
- ppm_dest_ptr dest = (ppm_dest_ptr)dinfo;
-
- if (cinfo->out_color_space == JCS_GRAYSCALE)
- dest->samples_per_row = cinfo->output_width * cinfo->out_color_components;
- else
- dest->samples_per_row = cinfo->output_width * 3;
- dest->buffer_width = dest->samples_per_row * (BYTESPERSAMPLE * sizeof(char));
-}
-
-
-/*
- * The module selection routine for PPM format output.
- */
-
-GLOBAL(djpeg_dest_ptr)
-jinit_write_ppm(j_decompress_ptr cinfo)
-{
- ppm_dest_ptr dest;
-
- /* Create module interface object, fill in method pointers */
- dest = (ppm_dest_ptr)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- sizeof(ppm_dest_struct));
- dest->pub.start_output = start_output_ppm;
- dest->pub.finish_output = finish_output_ppm;
- dest->pub.calc_buffer_dimensions = calc_buffer_dimensions_ppm;
-
- /* Calculate output image dimensions so we can allocate space */
- jpeg_calc_output_dimensions(cinfo);
-
- /* Create physical I/O buffer */
- dest->pub.calc_buffer_dimensions(cinfo, (djpeg_dest_ptr)dest);
- dest->iobuffer = (char *)(*cinfo->mem->alloc_small)
- ((j_common_ptr)cinfo, JPOOL_IMAGE, dest->buffer_width);
-
- if (cinfo->quantize_colors || BITS_IN_JSAMPLE != 8 ||
- sizeof(JSAMPLE) != sizeof(char) ||
-#if RGB_RED == 0 && RGB_GREEN == 1 && RGB_BLUE == 2 && RGB_PIXELSIZE == 3
- (cinfo->out_color_space != JCS_EXT_RGB &&
- cinfo->out_color_space != JCS_RGB)) {
-#else
- cinfo->out_color_space != JCS_EXT_RGB) {
-#endif
- /* When quantizing, we need an output buffer for colormap indexes
- * that's separate from the physical I/O buffer. We also need a
- * separate buffer if pixel format translation must take place.
- */
- dest->pub.buffer = (*cinfo->mem->alloc_sarray)
- ((j_common_ptr)cinfo, JPOOL_IMAGE,
- cinfo->output_width * cinfo->output_components, (JDIMENSION)1);
- dest->pub.buffer_height = 1;
- if (!cinfo->quantize_colors) {
- if (IsExtRGB(cinfo->out_color_space))
- dest->pub.put_pixel_rows = put_rgb;
- else if (cinfo->out_color_space == JCS_CMYK)
- dest->pub.put_pixel_rows = put_cmyk;
- else
- dest->pub.put_pixel_rows = copy_pixel_rows;
- } else if (cinfo->out_color_space == JCS_GRAYSCALE)
- dest->pub.put_pixel_rows = put_demapped_gray;
- else
- dest->pub.put_pixel_rows = put_demapped_rgb;
- } else {
- /* We will fwrite() directly from decompressor output buffer. */
- /* Synthesize a JSAMPARRAY pointer structure */
- dest->pixrow = (JSAMPROW)dest->iobuffer;
- dest->pub.buffer = &dest->pixrow;
- dest->pub.buffer_height = 1;
- dest->pub.put_pixel_rows = put_pixel_rows;
- }
-
- return (djpeg_dest_ptr)dest;
-}
-
-#endif /* PPM_SUPPORTED */
diff --git a/contrib/libs/libjpeg-turbo/wrtarga.c b/contrib/libs/libjpeg-turbo/wrtarga.c
deleted file mode 100644
index 67ca1f00a4..0000000000
--- a/contrib/libs/libjpeg-turbo/wrtarga.c
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * wrtarga.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1996, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2017, 2019, 2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains routines to write output images in Targa format.
- *
- * These routines may need modification for non-Unix environments or
- * specialized applications. As they stand, they assume output to
- * an ordinary stdio stream.
- *
- * Based on code contributed by Lee Daniel Crocker.
- */
-
-#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
-
-#ifdef TARGA_SUPPORTED
-
-
-/*
- * To support 12-bit JPEG data, we'd have to scale output down to 8 bits.
- * This is not yet implemented.
- */
-
-#if BITS_IN_JSAMPLE != 8
- Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */
-#endif
-
-
-/* Private version of data destination object */
-
-typedef struct {
- struct djpeg_dest_struct pub; /* public fields */
-
- char *iobuffer; /* physical I/O buffer */
- JDIMENSION buffer_width; /* width of one row */
-} tga_dest_struct;
-
-typedef tga_dest_struct *tga_dest_ptr;
-
-
-LOCAL(void)
-write_header(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, int num_colors)
-/* Create and write a Targa header */
-{
- char targaheader[18];
-
- /* Set unused fields of header to 0 */
- memset(targaheader, 0, sizeof(targaheader));
-
- if (num_colors > 0) {
- targaheader[1] = 1; /* color map type 1 */
- targaheader[5] = (char)(num_colors & 0xFF);
- targaheader[6] = (char)(num_colors >> 8);
- targaheader[7] = 24; /* 24 bits per cmap entry */
- }
-
- targaheader[12] = (char)(cinfo->output_width & 0xFF);
- targaheader[13] = (char)(cinfo->output_width >> 8);
- targaheader[14] = (char)(cinfo->output_height & 0xFF);
- targaheader[15] = (char)(cinfo->output_height >> 8);
- targaheader[17] = 0x20; /* Top-down, non-interlaced */
-
- if (cinfo->out_color_space == JCS_GRAYSCALE) {
- targaheader[2] = 3; /* image type = uncompressed grayscale */
- targaheader[16] = 8; /* bits per pixel */
- } else { /* must be RGB */
- if (num_colors > 0) {
- targaheader[2] = 1; /* image type = colormapped RGB */
- targaheader[16] = 8;
- } else {
- targaheader[2] = 2; /* image type = uncompressed RGB */
- targaheader[16] = 24;
- }
- }
-
- if (fwrite(targaheader, 1, 18, dinfo->output_file) != (size_t)18)
- ERREXIT(cinfo, JERR_FILE_WRITE);
-}
-
-
-/*
- * Write some pixel data.
- * In this module rows_supplied will always be 1.
- */
-
-METHODDEF(void)
-put_pixel_rows(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
- JDIMENSION rows_supplied)
-/* used for unquantized full-color output */
-{
- tga_dest_ptr dest = (tga_dest_ptr)dinfo;
- register JSAMPROW inptr;
- register char *outptr;
- register JDIMENSION col;
-
- inptr = dest->pub.buffer[0];
- outptr = dest->iobuffer;
- for (col = cinfo->output_width; col > 0; col--) {
- outptr[0] = inptr[2]; /* RGB to BGR order */
- outptr[1] = inptr[1];
- outptr[2] = inptr[0];
- inptr += 3, outptr += 3;
- }
- fwrite(dest->iobuffer, 1, dest->buffer_width, dest->pub.output_file);
-}
-
-METHODDEF(void)
-put_gray_rows(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
- JDIMENSION rows_supplied)
-/* used for grayscale OR quantized color output */
-{
- tga_dest_ptr dest = (tga_dest_ptr)dinfo;
- register JSAMPROW inptr;
- register char *outptr;
-
- inptr = dest->pub.buffer[0];
- outptr = dest->iobuffer;
- memcpy(outptr, inptr, cinfo->output_width);
- fwrite(dest->iobuffer, 1, dest->buffer_width, dest->pub.output_file);
-}
-
-
-/*
- * Write some demapped pixel data when color quantization is in effect.
- * For Targa, this is only applied to grayscale data.
- */
-
-METHODDEF(void)
-put_demapped_gray(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
- JDIMENSION rows_supplied)
-{
- tga_dest_ptr dest = (tga_dest_ptr)dinfo;
- register JSAMPROW inptr;
- register char *outptr;
- register JSAMPROW color_map0 = cinfo->colormap[0];
- register JDIMENSION col;
-
- inptr = dest->pub.buffer[0];
- outptr = dest->iobuffer;
- for (col = cinfo->output_width; col > 0; col--) {
- *outptr++ = color_map0[*inptr++];
- }
- fwrite(dest->iobuffer, 1, dest->buffer_width, dest->pub.output_file);
-}
-
-
-/*
- * Startup: write the file header.
- */
-
-METHODDEF(void)
-start_output_tga(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
-{
- tga_dest_ptr dest = (tga_dest_ptr)dinfo;
- int num_colors, i;
- FILE *outfile;
-
- if (cinfo->out_color_space == JCS_GRAYSCALE) {
- /* Targa doesn't have a mapped grayscale format, so we will */
- /* demap quantized gray output. Never emit a colormap. */
- write_header(cinfo, dinfo, 0);
- if (cinfo->quantize_colors)
- dest->pub.put_pixel_rows = put_demapped_gray;
- else
- dest->pub.put_pixel_rows = put_gray_rows;
- } else if (cinfo->out_color_space == JCS_RGB) {
- if (cinfo->quantize_colors) {
- /* We only support 8-bit colormap indexes, so only 256 colors */
- num_colors = cinfo->actual_number_of_colors;
- if (num_colors > 256)
- ERREXIT1(cinfo, JERR_TOO_MANY_COLORS, num_colors);
- write_header(cinfo, dinfo, num_colors);
- /* Write the colormap. Note Targa uses BGR byte order */
- outfile = dest->pub.output_file;
- for (i = 0; i < num_colors; i++) {
- putc(cinfo->colormap[2][i], outfile);
- putc(cinfo->colormap[1][i], outfile);
- putc(cinfo->colormap[0][i], outfile);
- }
- dest->pub.put_pixel_rows = put_gray_rows;
- } else {
- write_header(cinfo, dinfo, 0);
- dest->pub.put_pixel_rows = put_pixel_rows;
- }
- } else {
- ERREXIT(cinfo, JERR_TGA_COLORSPACE);
- }
-}
-
-
-/*
- * Finish up at the end of the file.
- */
-
-METHODDEF(void)
-finish_output_tga(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
-{
- /* Make sure we wrote the output file OK */
- fflush(dinfo->output_file);
- if (ferror(dinfo->output_file))
- ERREXIT(cinfo, JERR_FILE_WRITE);
-}
-
-
-/*
- * Re-calculate buffer dimensions based on output dimensions.
- */
-
-METHODDEF(void)
-calc_buffer_dimensions_tga(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
-{
- tga_dest_ptr dest = (tga_dest_ptr)dinfo;
-
- dest->buffer_width = cinfo->output_width * cinfo->output_components;
-}
-
-
-/*
- * The module selection routine for Targa format output.
- */
-
-GLOBAL(djpeg_dest_ptr)
-jinit_write_targa(j_decompress_ptr cinfo)
-{
- tga_dest_ptr dest;
-
- /* Create module interface object, fill in method pointers */
- dest = (tga_dest_ptr)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- sizeof(tga_dest_struct));
- dest->pub.start_output = start_output_tga;
- dest->pub.finish_output = finish_output_tga;
- dest->pub.calc_buffer_dimensions = calc_buffer_dimensions_tga;
-
- /* Calculate output image dimensions so we can allocate space */
- jpeg_calc_output_dimensions(cinfo);
-
- /* Create I/O buffer. */
- dest->pub.calc_buffer_dimensions(cinfo, (djpeg_dest_ptr)dest);
- dest->iobuffer = (char *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- (size_t)(dest->buffer_width * sizeof(char)));
-
- /* Create decompressor output buffer. */
- dest->pub.buffer = (*cinfo->mem->alloc_sarray)
- ((j_common_ptr)cinfo, JPOOL_IMAGE, dest->buffer_width, (JDIMENSION)1);
- dest->pub.buffer_height = 1;
-
- return (djpeg_dest_ptr)dest;
-}
-
-#endif /* TARGA_SUPPORTED */
diff --git a/contrib/libs/libjpeg-turbo/ya.make b/contrib/libs/libjpeg-turbo/ya.make
deleted file mode 100644
index 1893eef41b..0000000000
--- a/contrib/libs/libjpeg-turbo/ya.make
+++ /dev/null
@@ -1,259 +0,0 @@
-# Generated by devtools/yamaker from nixpkgs 22.05.
-
-LIBRARY()
-
-LICENSE(
- BSD-3-Clause AND
- Beerware AND
- IJG AND
- Libpbm AND
- Public-Domain AND
- Zlib
-)
-
-LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
-
-VERSION(2.1.4)
-
-ORIGINAL_SOURCE(https://github.com/libjpeg-turbo/libjpeg-turbo/archive/2.1.4.tar.gz)
-
-ADDINCL(
- contrib/libs/libjpeg-turbo
- FOR
- asm
- contrib/libs/libjpeg-turbo/simd/nasm
-)
-
-IF (OS_DARWIN OR OS_IOS)
- SET(ASM_PREFIX '_')
-ENDIF()
-
-NO_COMPILER_WARNINGS()
-
-NO_RUNTIME()
-
-CFLAGS(
- -DBMP_SUPPORTED
- -DPPM_SUPPORTED
-)
-
-IF (SANITIZER_TYPE)
- CFLAGS(
- -DWITH_SANITIZER
- )
-ENDIF()
-
-IF (OS_ANDROID)
- SRCS(
- jsimd_none.c
- )
-ELSEIF (ARCH_I386)
- SRCS(
- simd/i386/jccolor-avx2.asm
- simd/i386/jccolor-mmx.asm
- simd/i386/jccolor-sse2.asm
- simd/i386/jcgray-avx2.asm
- simd/i386/jcgray-mmx.asm
- simd/i386/jcgray-sse2.asm
- simd/i386/jchuff-sse2.asm
- simd/i386/jcphuff-sse2.asm
- simd/i386/jcsample-avx2.asm
- simd/i386/jcsample-mmx.asm
- simd/i386/jcsample-sse2.asm
- simd/i386/jdcolor-avx2.asm
- simd/i386/jdcolor-mmx.asm
- simd/i386/jdcolor-sse2.asm
- simd/i386/jdmerge-avx2.asm
- simd/i386/jdmerge-mmx.asm
- simd/i386/jdmerge-sse2.asm
- simd/i386/jdsample-avx2.asm
- simd/i386/jdsample-mmx.asm
- simd/i386/jdsample-sse2.asm
- simd/i386/jfdctflt-3dn.asm
- simd/i386/jfdctflt-sse.asm
- simd/i386/jfdctfst-mmx.asm
- simd/i386/jfdctfst-sse2.asm
- simd/i386/jfdctint-avx2.asm
- simd/i386/jfdctint-mmx.asm
- simd/i386/jfdctint-sse2.asm
- simd/i386/jidctflt-3dn.asm
- simd/i386/jidctflt-sse.asm
- simd/i386/jidctflt-sse2.asm
- simd/i386/jidctfst-mmx.asm
- simd/i386/jidctfst-sse2.asm
- simd/i386/jidctint-avx2.asm
- simd/i386/jidctint-mmx.asm
- simd/i386/jidctint-sse2.asm
- simd/i386/jidctred-mmx.asm
- simd/i386/jidctred-sse2.asm
- simd/i386/jquant-3dn.asm
- simd/i386/jquant-mmx.asm
- simd/i386/jquant-sse.asm
- simd/i386/jquantf-sse2.asm
- simd/i386/jquanti-avx2.asm
- simd/i386/jquanti-sse2.asm
- simd/i386/jsimd.c
- simd/i386/jsimdcpu.asm
- )
-ELSEIF (ARCH_X86_64)
- SRCS(
- simd/x86_64/jccolor-avx2.asm
- simd/x86_64/jccolor-sse2.asm
- simd/x86_64/jcgray-avx2.asm
- simd/x86_64/jcgray-sse2.asm
- simd/x86_64/jchuff-sse2.asm
- simd/x86_64/jcphuff-sse2.asm
- simd/x86_64/jcsample-avx2.asm
- simd/x86_64/jcsample-sse2.asm
- simd/x86_64/jdcolor-avx2.asm
- simd/x86_64/jdcolor-sse2.asm
- simd/x86_64/jdmerge-avx2.asm
- simd/x86_64/jdmerge-sse2.asm
- simd/x86_64/jdsample-avx2.asm
- simd/x86_64/jdsample-sse2.asm
- simd/x86_64/jfdctflt-sse.asm
- simd/x86_64/jfdctfst-sse2.asm
- simd/x86_64/jfdctint-avx2.asm
- simd/x86_64/jfdctint-sse2.asm
- simd/x86_64/jidctflt-sse2.asm
- simd/x86_64/jidctfst-sse2.asm
- simd/x86_64/jidctint-avx2.asm
- simd/x86_64/jidctint-sse2.asm
- simd/x86_64/jidctred-sse2.asm
- simd/x86_64/jquantf-sse2.asm
- simd/x86_64/jquanti-avx2.asm
- simd/x86_64/jquanti-sse2.asm
- simd/x86_64/jsimd.c
- simd/x86_64/jsimdcpu.asm
- )
-ELSEIF (ARCH_ARM7_NEON AND NOT MSVC)
- ADDINCL(
- contrib/libs/libjpeg-turbo/simd/arm
- )
- SRCS(
- simd/arm/aarch32/jchuff-neon.c
- simd/arm/aarch32/jsimd.c
- simd/arm/aarch32/jsimd_neon.S
- simd/arm/jccolor-neon.c
- simd/arm/jcgray-neon.c
- simd/arm/jcphuff-neon.c
- simd/arm/jcsample-neon.c
- simd/arm/jdcolor-neon.c
- simd/arm/jdmerge-neon.c
- simd/arm/jdsample-neon.c
- simd/arm/jfdctfst-neon.c
- simd/arm/jfdctint-neon.c
- simd/arm/jidctfst-neon.c
- simd/arm/jidctint-neon.c
- simd/arm/jidctred-neon.c
- simd/arm/jquanti-neon.c
- )
-ELSEIF (ARCH_ARM7 AND NOT MSVC)
- SRCS(
- simd/arm/aarch32/jchuff-neon.c
- simd/arm/aarch32/jsimd.c
- simd/arm/aarch32/jsimd_neon.S
- )
-ELSEIF (ARCH_ARM64 AND NOT MSVC)
- ADDINCL(
- contrib/libs/libjpeg-turbo/simd/arm
- )
- SRCS(
- simd/arm/aarch64/jchuff-neon.c
- simd/arm/aarch64/jsimd.c
- simd/arm/jccolor-neon.c
- simd/arm/jcgray-neon.c
- simd/arm/jcphuff-neon.c
- simd/arm/jcsample-neon.c
- simd/arm/jdcolor-neon.c
- simd/arm/jdmerge-neon.c
- simd/arm/jdsample-neon.c
- simd/arm/jfdctfst-neon.c
- simd/arm/jfdctint-neon.c
- simd/arm/jidctfst-neon.c
- simd/arm/jidctint-neon.c
- simd/arm/jidctred-neon.c
- simd/arm/jquanti-neon.c
- )
-ELSE()
- SRCS(
- jsimd_none.c
- )
-ENDIF()
-
-SRCS(
- jaricom.c
- jcapimin.c
- jcapistd.c
- jcarith.c
- jccoefct.c
- jccolor.c
- jcdctmgr.c
- jchuff.c
- jcicc.c
- jcinit.c
- jcmainct.c
- jcmarker.c
- jcmaster.c
- jcomapi.c
- jcparam.c
- jcphuff.c
- jcprepct.c
- jcsample.c
- jctrans.c
- jdapimin.c
- jdapistd.c
- jdarith.c
- jdatadst-tj.c
- jdatadst.c
- jdatasrc-tj.c
- jdatasrc.c
- jdcoefct.c
- jdcolor.c
- jddctmgr.c
- jdhuff.c
- jdicc.c
- jdinput.c
- jdmainct.c
- jdmarker.c
- jdmaster.c
- jdmerge.c
- jdphuff.c
- jdpostct.c
- jdsample.c
- jdtrans.c
- jerror.c
- jfdctflt.c
- jfdctfst.c
- jfdctint.c
- jidctflt.c
- jidctfst.c
- jidctint.c
- jidctred.c
- jmemmgr.c
- jmemnobs.c
- jquant1.c
- jquant2.c
- jutils.c
- rdbmp.c
- rdppm.c
- transupp.c
- turbojpeg.c
- wrbmp.c
- wrppm.c
-)
-
-END()
-
-RECURSE(
- cjpeg
- djpeg
- jpegtran
- tjunittest
-)
-
-IF (NOT OS_ANDROID AND NOT OS_IOS)
- RECURSE_FOR_TESTS(
- ut
- )
-ENDIF()
diff --git a/contrib/libs/libpng/.yandex_meta/__init__.py b/contrib/libs/libpng/.yandex_meta/__init__.py
deleted file mode 100644
index 6dbbc897ae..0000000000
--- a/contrib/libs/libpng/.yandex_meta/__init__.py
+++ /dev/null
@@ -1,58 +0,0 @@
-import os
-
-from devtools.yamaker.fileutil import files
-from devtools.yamaker.modules import Switch, Linkable
-from devtools.yamaker.project import GNUMakeNixProject
-
-
-def post_install(self):
- with self.yamakes["."] as libpng:
- # libpng generates export script, but we are going to link statically
- os.remove(f"{self.dstdir}/libpng.vers")
-
- # libpng generates config.h but does not use any of its defines.
- os.remove(f"{self.dstdir}/config.h")
- libpng.CFLAGS.remove("-DHAVE_CONFIG_H")
-
- # Support ARM.
- arm_srcs = files(f"{self.dstdir}/arm", rel=self.dstdir)
- self.yamakes["."].after(
- "SRCS",
- Switch(
- {
- "NOT MSVC": Switch(
- {
- "ARCH_AARCH64 OR ARCH_ARM": Linkable(SRCS=arm_srcs),
- }
- )
- }
- ),
- )
-
- libpng.RECURSE.add("include")
-
-
-libpng = GNUMakeNixProject(
- owners=["g:cpp-contrib"],
- arcdir="contrib/libs/libpng",
- nixattr="libpng",
- makeflags=["libpng16.la"],
- copy_sources=[
- "arm/*",
- "pngprefix.h",
- ],
- disable_includes=[
- "config.h",
- "pngusr.h",
- "mem.h",
- "PNG_MIPS_MMI_FILE",
- "PNG_MIPS_MSA_FILE",
- "PNG_POWERPC_VSX_FILE",
- "PNG_ARM_NEON_FILE",
- ],
- # Original libpng layout provides unnecessary ADDINCL(include/libpng16)
- keep_paths=["include/ya.make"],
- ignore_commands=["gawk"],
- inclink={"include": ["png.h", "pngconf.h", "pnglibconf.h"]},
- post_install=post_install,
-)
diff --git a/contrib/libs/libpng/.yandex_meta/devtools.copyrights.report b/contrib/libs/libpng/.yandex_meta/devtools.copyrights.report
deleted file mode 100644
index 5c31247129..0000000000
--- a/contrib/libs/libpng/.yandex_meta/devtools.copyrights.report
+++ /dev/null
@@ -1,452 +0,0 @@
-# File format ($ symbol means the beginning of a line):
-#
-# $ # this message
-# $ # =======================
-# $ # comments (all commentaries should starts with some number of spaces and # symbol)
-# ${action} {license id} {license text hash}
-# $BELONGS ./ya/make/file/relative/path/1/ya.make ./ya/make/2/ya.make
-# ${all_file_action} filename
-# $ # user commentaries (many lines)
-# $ generated description - files with this license, license text... (some number of lines that starts with some number of spaces, do not modify)
-# ${action} {license spdx} {license text hash}
-# $BELONGS ./ya/make/file/relative/path/3/ya.make
-# ${all_file_action} filename
-# $ # user commentaries
-# $ generated description
-# $ ...
-#
-# You can modify action, all_file_action and add commentaries
-# Available actions:
-# keep - keep license in contrib and use in credits
-# skip - skip license
-# remove - remove all files with this license
-# rename - save license text/links into licenses texts file, but not store SPDX into LINCENSE macro. You should store correct license id into devtools.license.spdx.txt file
-#
-# {all file action} records will be generated when license text contains filename that exists on filesystem (in contrib directory)
-# We suppose that that files can contain some license info
-# Available all file actions:
-# FILE_IGNORE - ignore file (do nothing)
-# FILE_INCLUDE - include all file data into licenses text file
-# =======================
-
-KEEP COPYRIGHT_SERVICE_LABEL 0208742090016a7a2164aa2bdcb63383
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- pngwio.c [3:6]
-
-KEEP COPYRIGHT_SERVICE_LABEL 04f8b1b4b2cbfeeb2e57bfc469890488
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- pngconf.h [5:8]
- pngrio.c [3:6]
- pngwtran.c [3:6]
-
-KEEP COPYRIGHT_SERVICE_LABEL 1a83a20a442f29d288b04d4b75acecee
-BELONGS ya.make
- License text:
- * Copyright (c) 2018 Cosmin Truta
- * Copyright (c) 2017 Glenn Randers-Pehrson
- * Written by Vadim Barkov, 2017.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- powerpc/filter_vsx_intrinsics.c [3:5]
- powerpc/powerpc_init.c [3:5]
-
-KEEP COPYRIGHT_SERVICE_LABEL 222e0a740b7c184c1ce8edc0294b9350
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- LICENSE [13:17]
- png.c [3:6]
- png.c [797:803]
- png.h [5:8]
- png.h [35:39]
- pngconf.h [5:8]
- pnglibconf.h [5:6]
- pngread.c [3:6]
- pngset.c [3:6]
- pngwrite.c [3:6]
-
-KEEP COPYRIGHT_SERVICE_LABEL 29987a3e22887759d4116a65229bc445
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- pnginfo.h [3:6]
-
-KEEP COPYRIGHT_SERVICE_LABEL 3ac342a1877c8d682e0323f5fc8d82cd
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- LICENSE [77:81]
- png.h [99:103]
-
-KEEP COPYRIGHT_SERVICE_LABEL 3e85c5cdcf5b38e730d8ce8321bc4e79
-BELONGS ya.make
- License text:
- * Copyright (c) 2018-2022 Cosmin Truta
- * Copyright (c) 2014,2016 Glenn Randers-Pehrson
- * Written by Mans Rullgard, 2011.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- arm/arm_init.c [3:5]
- arm/filter_neon_intrinsics.c [3:6]
-
-KEEP COPYRIGHT_SERVICE_LABEL 408ae0448441d3cd270208218c23a2d3
-BELONGS ya.make
- License text:
- Copyright (c) 2022 Cosmin Truta
- Copyright (c) 1998-2002,2006-2016 Glenn Randers-Pehrson
- This document is released under the libpng license.
- For conditions of distribution and use, see the disclaimer
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- INSTALL [459:462]
-
-KEEP COPYRIGHT_SERVICE_LABEL 4223c36ebcb4c20e63cea90ec6c1c336
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- arm/filter_neon_intrinsics.c [3:6]
- intel/filter_sse2_intrinsics.c [3:6]
- intel/intel_init.c [3:6]
- pngdebug.h [3:6]
- pnginfo.h [3:6]
- pngmem.c [3:6]
- pngrio.c [3:6]
- pngwio.c [3:6]
- pngwtran.c [3:6]
- powerpc/filter_vsx_intrinsics.c [3:5]
- powerpc/powerpc_init.c [3:5]
-
-KEEP COPYRIGHT_SERVICE_LABEL 4ab05cc7c9d27c8a3fbcc6350cf56230
-BELONGS ya.make
- License text:
- * Copyright (c) 2018-2019 Cosmin Truta
- * Copyright (c) 2017-2018 Arm Holdings. All rights reserved.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- arm/palette_neon_intrinsics.c [3:4]
-
-KEEP COPYRIGHT_SERVICE_LABEL 4d546ee23b58fd971b989e767c9f5a33
-BELONGS ya.make
- License text:
- * Copyright (c) 2018 Cosmin Truta
- * Copyright (c) 2016-2017 Glenn Randers-Pehrson
- * Written by Mike Klein and Matt Sarett
- * Derived from arm/filter_neon_intrinsics.c
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- intel/filter_sse2_intrinsics.c [3:6]
- intel/intel_init.c [3:6]
-
-KEEP COPYRIGHT_SERVICE_LABEL 51b32ca44bdc2a734f625cee7a36472b
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- arm/arm_init.c [3:5]
- pngstruct.h [3:6]
-
-KEEP COPYRIGHT_SERVICE_LABEL 5fc45730df09b1e4ad9f9d6a2d097232
-BELONGS ya.make
- License text:
- Copyright (c) 2006-2007 Andrew Smith, Copyright (c) 2008-2025 Max Stepin,
- and are delimited by "#ifdef PNG_APNG_SUPPORTED / #endif" directives
- surrounding them in the modified libpng source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- LICENSE [6:8]
- png.h [28:30]
-
-KEEP COPYRIGHT_SERVICE_LABEL 62c7eae75018b876086b46cbfa6ba011
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- LICENSE [13:17]
- LICENSE [87:91]
- png.c [3:6]
- png.c [797:803]
- png.h [5:8]
- png.h [35:39]
- png.h [109:113]
- pngconf.h [5:8]
- pngdebug.h [3:6]
- pngerror.c [3:6]
- pngget.c [3:6]
- pnginfo.h [3:6]
- pngmem.c [3:6]
- pngpread.c [3:6]
- pngpriv.h [3:6]
- pngread.c [3:6]
- pngrio.c [3:6]
- pngrtran.c [3:6]
- pngrutil.c [3:6]
- pngset.c [3:6]
- pngstruct.h [3:6]
- pngtrans.c [3:6]
- pngwio.c [3:6]
- pngwrite.c [3:6]
- pngwtran.c [3:6]
- pngwutil.c [3:6]
-
-KEEP COPYRIGHT_SERVICE_LABEL 7e44d6c54a35ce9344b977e884ef180c
-BELONGS ya.make
- License text:
- * Copyright (c) 2024 Cosmin Truta
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- arm/filter_neon.S [3:3]
- mips/filter_mmi_inline_assembly.c [3:4]
-
-KEEP COPYRIGHT_SERVICE_LABEL 9198506c7cb59dc577addf9c14d6ade1
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- png.c [3:6]
- png.c [797:803]
- png.h [5:8]
- pngget.c [3:6]
- pnglibconf.h [5:6]
- pngpread.c [3:6]
- pngpriv.h [3:6]
- pngread.c [3:6]
- pngrtran.c [3:6]
- pngrutil.c [3:6]
- pngstruct.h [3:6]
- pngtrans.c [3:6]
- pngwrite.c [3:6]
- pngwutil.c [3:6]
-
-KEEP COPYRIGHT_SERVICE_LABEL 94d354c99282b55820e97e6195cce85a
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- LICENSE [13:17]
- png.h [35:39]
-
-KEEP COPYRIGHT_SERVICE_LABEL a8a352211455dc7608a2fcc17b1d1029
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- mips/filter_msa_intrinsics.c [3:5]
- mips/mips_init.c [3:6]
- pngerror.c [3:6]
- pngget.c [3:6]
- pngpread.c [3:6]
- pngpriv.h [3:6]
- pngrtran.c [3:6]
- pngrutil.c [3:6]
- pngtrans.c [3:6]
- pngwutil.c [3:6]
-
-KEEP COPYRIGHT_SERVICE_LABEL a9fe2e1b3b86d7489fcd47a2c9749dfe
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- LICENSE [13:17]
- LICENSE [103:104]
- png.c [3:6]
- png.c [797:803]
- png.h [5:8]
- png.h [35:39]
- png.h [125:126]
- pngconf.h [5:8]
- pngdebug.h [3:6]
- pngerror.c [3:6]
- pngget.c [3:6]
- pnginfo.h [3:6]
- pngmem.c [3:6]
- pngpread.c [3:6]
- pngpriv.h [3:6]
- pngread.c [3:6]
- pngrio.c [3:6]
- pngrtran.c [3:6]
- pngrutil.c [3:6]
- pngset.c [3:6]
- pngstruct.h [3:6]
- pngtrans.c [3:6]
- pngwio.c [3:6]
- pngwrite.c [3:6]
- pngwtran.c [3:6]
- pngwutil.c [3:6]
-
-KEEP COPYRIGHT_SERVICE_LABEL b585c8f7e4acf8c0948a1fd9ab5daaaa
-BELONGS ya.make
- License text:
- * Copyright (c) 2018-2019 Cosmin Truta
- * Copyright (c) 2017-2018 Arm Holdings. All rights reserved.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- arm/palette_neon_intrinsics.c [3:4]
-
-KEEP COPYRIGHT_SERVICE_LABEL b91f4788e32d0095f31d9f6910440991
-BELONGS ya.make
- License text:
- * Copyright (c) 2018-2025 Cosmin Truta
- * Copyright (c) 1998-2018 Glenn Randers-Pehrson
- * Copyright (c) 1996-1997 Andreas Dilger
- * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- pngset.c [3:6]
-
-KEEP COPYRIGHT_SERVICE_LABEL bf6d1f6f38395afb2d26a1bab41d837c
-BELONGS ya.make
- License text:
- Copyright (c) 2006-2007 Andrew Smith, Copyright (c) 2008-2025 Max Stepin,
- and are delimited by "#ifdef PNG_APNG_SUPPORTED / #endif" directives
- surrounding them in the modified libpng source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- LICENSE [6:8]
- png.h [28:30]
-
-KEEP COPYRIGHT_SERVICE_LABEL c486f222c872d0101647b08aaad5c74c
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- pngerror.c [3:6]
-
-KEEP COPYRIGHT_SERVICE_LABEL ce9b1ec1cd75a32b887bd8ce4e049914
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- LICENSE [13:17]
- LICENSE [48:52]
- png.h [35:39]
- png.h [70:74]
-
-KEEP COPYRIGHT_SERVICE_LABEL cf0cd6fc41c47054b3d8821a52817bd0
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- pngmem.c [3:6]
-
-KEEP COPYRIGHT_SERVICE_LABEL d90f491706af2972a0d052bf061202af
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- pngdebug.h [3:6]
-
-KEEP COPYRIGHT_SERVICE_LABEL dd52acdc7afddfc8b562adacbabdfc2b
-BELONGS ya.make
- License text:
- Copyright (c) 2022 Cosmin Truta
- Copyright (c) 1998-2002,2006-2016 Glenn Randers-Pehrson
- This document is released under the libpng license.
- For conditions of distribution and use, see the disclaimer
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- INSTALL [459:462]
-
-KEEP COPYRIGHT_SERVICE_LABEL e8596f616c40e549d2ea24adacc49cf7
-BELONGS ya.make
- License text:
- * Copyright (c) 2018-2024 Cosmin Truta
- * Copyright (c) 2016 Glenn Randers-Pehrson
- * Written by Mandar Sahastrabuddhe, August 2016
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- mips/filter_msa_intrinsics.c [3:5]
- mips/mips_init.c [3:6]
diff --git a/contrib/libs/libpng/.yandex_meta/devtools.licenses.report b/contrib/libs/libpng/.yandex_meta/devtools.licenses.report
deleted file mode 100644
index b1895bd381..0000000000
--- a/contrib/libs/libpng/.yandex_meta/devtools.licenses.report
+++ /dev/null
@@ -1,498 +0,0 @@
-# File format ($ symbol means the beginning of a line):
-#
-# $ # this message
-# $ # =======================
-# $ # comments (all commentaries should starts with some number of spaces and # symbol)
-# ${action} {license spdx} {license text hash}
-# $BELONGS ./ya/make/file/relative/path/1/ya.make ./ya/make/2/ya.make
-# ${all_file_action} filename
-# $ # user commentaries (many lines)
-# $ generated description - files with this license, license text... (some number of lines that starts with some number of spaces, do not modify)
-# ${action} {license spdx} {license text hash}
-# $BELONGS ./ya/make/file/relative/path/3/ya.make
-# ${all_file_action} filename
-# $ # user commentaries
-# $ generated description
-# $ ...
-#
-# You can modify action, all_file_action and add commentaries
-# Available actions:
-# keep - keep license in contrib and use in credits
-# skip - skip license
-# remove - remove all files with this license
-# rename - save license text/links into licenses texts file, but not store SPDX into LINCENSE macro. You should store correct license id into devtools.license.spdx.txt file
-#
-# {all file action} records will be generated when license text contains filename that exists on filesystem (in contrib directory)
-# We suppose that that files can contain some license info
-# Available all file actions:
-# FILE_IGNORE - ignore file (do nothing)
-# FILE_INCLUDE - include all file data into licenses text file
-# =======================
-
-KEEP Libpng 147dc0e952990823ef472540ecd32e49
-BELONGS ya.make
-FILE_INCLUDE TRADEMARK found in files: TRADEMARK at line 1
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: Libpng
- Score : 15.44
- Match type : TEXT
- Links : http://libpng.org/pub/png/src/libpng-LICENSE.txt, http://www.libpng.org/pub/png/libpng.html, https://spdx.org/licenses/Libpng
- Files with this license:
- TRADEMARK [1:8]
-
-KEEP Libpng 1942a89dbd61e16b215bc61494170e4d
-BELONGS ya.make
- License text:
- * Some files in the "scripts" directory have other copyright owners,
- * but are released under this license.
- *
- * libpng versions 0.5, May 1995, through 0.88, January 1996, are
- Scancode info:
- Original SPDX id: Libpng
- Score : 95.00
- Match type : REFERENCE
- Links : http://libpng.org/pub/png/src/libpng-LICENSE.txt, http://www.libpng.org/pub/png/libpng.html, https://spdx.org/licenses/Libpng
- Files with this license:
- png.h [122:125]
-
-KEEP Libpng 1d940ec90e4aa15211472accfdd6ed04
-BELONGS ya.make
- License text:
- Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
- Scancode info:
- Original SPDX id: Libpng
- Score : 100.00
- Match type : REFERENCE
- Links : http://libpng.org/pub/png/src/libpng-LICENSE.txt, http://www.libpng.org/pub/png/libpng.html, https://spdx.org/licenses/Libpng
- Files with this license:
- LICENSE [88:88]
-
-KEEP Libpng 224bcee9a35938d1a8891ca9437e34f9
-BELONGS ya.make
- License text:
- * Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
- * libpng-0.96, and are distributed according to the same disclaimer and
- Scancode info:
- Original SPDX id: Libpng
- Score : 100.00
- Match type : REFERENCE
- Links : http://libpng.org/pub/png/src/libpng-LICENSE.txt, http://www.libpng.org/pub/png/libpng.html, https://spdx.org/licenses/Libpng
- Files with this license:
- png.h [100:101]
-
-KEEP Libpng 2258163fda85c81b35966fee33b40b5b
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: Libpng
- Score : 60.81
- Match type : TEXT
- Links : http://libpng.org/pub/png/src/libpng-LICENSE.txt, http://www.libpng.org/pub/png/libpng.html, https://spdx.org/licenses/Libpng
- Files with this license:
- LICENSE [79:140]
-
-KEEP Libpng 254aadd201002dc2215b08754257c4ad
-BELONGS ya.make
- License text:
- Added a reference to the libpng license in each file.
- Scancode info:
- Original SPDX id: Libpng
- Score : 100.00
- Match type : REFERENCE
- Links : http://libpng.org/pub/png/src/libpng-LICENSE.txt, http://www.libpng.org/pub/png/libpng.html, https://spdx.org/licenses/Libpng
- Files with this license:
- CHANGES [2339:2339]
-
-KEEP Libpng 3a05dbc8218dced9bf7960ae06850ddd
-BELONGS ya.make
-FILE_IGNORE include/png.h found in files: arm/arm_init.c at line 9, arm/filter_neon.S at line 7, arm/filter_neon_intrinsics.c at line 10, arm/palette_neon_intrinsics.c at line 9, intel/filter_sse2_intrinsics.c at line 10, intel/intel_init.c at line 10, mips/filter_mmi_inline_assembly.c at line 8, mips/filter_msa_intrinsics.c at line 9, mips/mips_init.c at line 10, png.c at line 10, pngconf.h at line 12, pngdebug.h at line 10, pngerror.c at line 10, pngget.c at line 10, pnginfo.h at line 10, pngmem.c at line 10, pngpread.c at line 10, pngpriv.h at line 10, pngread.c at line 10, pngrio.c at line 10, pngrtran.c at line 10, pngrutil.c at line 10, pngset.c at line 10, pngstruct.h at line 10, pngtrans.c at line 10, pngwio.c at line 10, pngwrite.c at line 10, pngwtran.c at line 10, pngwutil.c at line 10, powerpc/filter_vsx_intrinsics.c at line 9, powerpc/powerpc_init.c at line 9
-FILE_IGNORE png.h found in files: arm/arm_init.c at line 9, arm/filter_neon.S at line 7, arm/filter_neon_intrinsics.c at line 10, arm/palette_neon_intrinsics.c at line 9, intel/filter_sse2_intrinsics.c at line 10, intel/intel_init.c at line 10, mips/filter_mmi_inline_assembly.c at line 8, mips/filter_msa_intrinsics.c at line 9, mips/mips_init.c at line 10, png.c at line 10, pngconf.h at line 12, pngdebug.h at line 10, pngerror.c at line 10, pngget.c at line 10, pnginfo.h at line 10, pngmem.c at line 10, pngpread.c at line 10, pngpriv.h at line 10, pngread.c at line 10, pngrio.c at line 10, pngrtran.c at line 10, pngrutil.c at line 10, pngset.c at line 10, pngstruct.h at line 10, pngtrans.c at line 10, pngwio.c at line 10, pngwrite.c at line 10, pngwtran.c at line 10, pngwutil.c at line 10, powerpc/filter_vsx_intrinsics.c at line 9, powerpc/powerpc_init.c at line 9
- License text:
- * This code is released under the libpng license.
- * For conditions of distribution and use, see the disclaimer
- * and license in png.h
- Scancode info:
- Original SPDX id: Libpng
- Score : 100.00
- Match type : NOTICE
- Links : http://libpng.org/pub/png/src/libpng-LICENSE.txt, http://www.libpng.org/pub/png/libpng.html, https://spdx.org/licenses/Libpng
- Files with this license:
- arm/arm_init.c [7:9]
- arm/filter_neon.S [5:7]
- arm/filter_neon_intrinsics.c [8:10]
- arm/palette_neon_intrinsics.c [7:9]
- intel/filter_sse2_intrinsics.c [8:10]
- intel/intel_init.c [8:10]
- mips/filter_mmi_inline_assembly.c [6:8]
- mips/filter_msa_intrinsics.c [7:9]
- mips/mips_init.c [8:10]
- png.c [8:10]
- pngconf.h [10:12]
- pngdebug.h [8:10]
- pngerror.c [8:10]
- pngget.c [8:10]
- pnginfo.h [8:10]
- pngmem.c [8:10]
- pngpread.c [8:10]
- pngpriv.h [8:10]
- pngread.c [8:10]
- pngrio.c [8:10]
- pngrtran.c [8:10]
- pngrutil.c [8:10]
- pngset.c [8:10]
- pngstruct.h [8:10]
- pngtrans.c [8:10]
- pngwio.c [8:10]
- pngwrite.c [8:10]
- pngwtran.c [8:10]
- pngwutil.c [8:10]
- powerpc/filter_vsx_intrinsics.c [7:9]
- powerpc/powerpc_init.c [7:9]
-
-KEEP Libpng 419f10c6f64f7f94b607500def672b4c
-BELONGS ya.make
- License text:
- derived from libpng-1.0.6, and are distributed according to the same
- Scancode info:
- Original SPDX id: Libpng
- Score : 100.00
- Match type : REFERENCE
- Links : http://libpng.org/pub/png/src/libpng-LICENSE.txt, http://www.libpng.org/pub/png/libpng.html, https://spdx.org/licenses/Libpng
- Files with this license:
- LICENSE [50:50]
-
-KEEP libpng-2.0 4beda1c70e573a3713d776864e366f19
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: libpng-2.0
- Score : 93.22
- Match type : TEXT
- Links : http://www.libpng.org/pub/png/src/libpng-LICENSE.txt, https://spdx.org/licenses/libpng-2.0
- Files with this license:
- png.h [35:64]
-
-KEEP Libpng 4bf58b7572cda8b7eb2355dfa5b6069b
-BELONGS ya.make
-FILE_IGNORE include/png.h found in files: pnglibconf.h at line 10
-FILE_IGNORE png.h found in files: pnglibconf.h at line 10
- License text:
- /* This code is released under the libpng license. */
- /* For conditions of distribution and use, see the disclaimer */
- /* and license in png.h */
- Scancode info:
- Original SPDX id: Libpng
- Score : 100.00
- Match type : NOTICE
- Links : http://libpng.org/pub/png/src/libpng-LICENSE.txt, http://www.libpng.org/pub/png/libpng.html, https://spdx.org/licenses/Libpng
- Files with this license:
- pnglibconf.h [8:10]
-
-KEEP libpng-2.0 5208e45400f1dd9d333b740e7fdfe0aa
-BELONGS ya.make
-FILE_INCLUDE LICENSE found in files: LICENSE at line 1
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: libpng-2.0
- Score : 95.76
- Match type : TEXT
- Links : http://www.libpng.org/pub/png/src/libpng-LICENSE.txt, https://spdx.org/licenses/libpng-2.0
- Files with this license:
- LICENSE [1:42]
-
-SKIP LicenseRef-scancode-unknown-license-reference 57999f604e5825fbd6cf183bd21ff5a7
-BELONGS ya.make
-FILE_IGNORE include/png.h found in files: CHANGES at line 527
-FILE_IGNORE png.h found in files: CHANGES at line 527
- # changes file
- License text:
- Added "Libpng is OSI Certified Open Source Software" statement to png.h
- Scancode info:
- Original SPDX id: LicenseRef-scancode-unknown-license-reference
- Score : 100.00
- Match type : REFERENCE
- Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/unknown-license-reference.LICENSE
- Files with this license:
- CHANGES [527:527]
-
-KEEP Libpng 6b2439904246134939cdf008b304af8a
-BELONGS ya.make
- License text:
- the libpng license.
- Scancode info:
- Original SPDX id: Libpng
- Score : 100.00
- Match type : REFERENCE
- Links : http://libpng.org/pub/png/src/libpng-LICENSE.txt, http://www.libpng.org/pub/png/libpng.html, https://spdx.org/licenses/Libpng
- Files with this license:
- CHANGES [2692:2692]
-
-SKIP LicenseRef-scancode-free-unknown 7223032bb9df755f6ce7298a13e95cee
-BELONGS ya.make
- # we have no contrib in libpng directory
- License text:
- files that are distributed with libpng have other copyright owners, and
- are released under other open source licenses.
- Scancode info:
- Original SPDX id: LicenseRef-scancode-free-unknown
- Score : 100.00
- Match type : NOTICE
- Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/free-unknown.LICENSE
- Files with this license:
- LICENSE [74:75]
-
-KEEP Libpng 7600efc02108131a57254bd359eb81ec
-BELONGS ya.make
-FILE_IGNORE include/png.h found in files: INSTALL at line 463
-FILE_IGNORE png.h found in files: INSTALL at line 463
- License text:
- This document is released under the libpng license.
- For conditions of distribution and use, see the disclaimer
- and license in png.h.
- Scancode info:
- Original SPDX id: Libpng
- Score : 100.00
- Match type : NOTICE
- Links : http://libpng.org/pub/png/src/libpng-LICENSE.txt, http://www.libpng.org/pub/png/libpng.html, https://spdx.org/licenses/Libpng
- Files with this license:
- INSTALL [461:463]
-
-KEEP Libpng 7efd0a90adbbc5ab678061147a6c1b22
-BELONGS ya.make
- License text:
- Some files in the "scripts" directory have other copyright owners,
- but are released under this license.
- libpng versions 0.5, May 1995, through 0.88, January 1996, are
- Scancode info:
- Original SPDX id: Libpng
- Score : 95.00
- Match type : REFERENCE
- Links : http://libpng.org/pub/png/src/libpng-LICENSE.txt, http://www.libpng.org/pub/png/libpng.html, https://spdx.org/licenses/Libpng
- Files with this license:
- LICENSE [100:103]
-
-KEEP Libpng 8052e10193c850afb17b137c4fefb079
-BELONGS ya.make
-FILE_INCLUDE LICENSE found in files: png.h at line 10
- License text:
- * This code is released under the libpng license. (See LICENSE, below.)
- Scancode info:
- Original SPDX id: Libpng
- Score : 100.00
- Match type : NOTICE
- Links : http://libpng.org/pub/png/src/libpng-LICENSE.txt, http://www.libpng.org/pub/png/libpng.html, https://spdx.org/licenses/Libpng
- Files with this license:
- png.h [10:10]
-
-KEEP Libpng 89f1af56c09553ceb984867cb39121fd
-BELONGS ya.make
- License text:
- released under the libpng license described below. The modifications are
- Scancode info:
- Original SPDX id: Libpng
- Score : 100.00
- Match type : NOTICE
- Links : http://libpng.org/pub/png/src/libpng-LICENSE.txt, http://www.libpng.org/pub/png/libpng.html, https://spdx.org/licenses/Libpng
- Files with this license:
- LICENSE [5:5]
-
-SKIP LicenseRef-scancode-free-unknown 95502569dcf2568eaa3effc6d65a8c30
-BELONGS ya.make
- # Regards ci and contrib directories which we do not store
- License text:
- of the tools-generated files that are distributed with libpng, have
- other copyright owners, and are released under other open source
- licenses.
- Scancode info:
- Original SPDX id: LicenseRef-scancode-free-unknown
- Score : 100.00
- Match type : NOTICE
- Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/free-unknown.LICENSE
- Files with this license:
- AUTHORS [60:62]
-
-KEEP Libpng a1fa29c834710a6f595de023fcd8738f
-BELONGS ya.make
- License text:
- * Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
- Scancode info:
- Original SPDX id: Libpng
- Score : 100.00
- Match type : REFERENCE
- Links : http://libpng.org/pub/png/src/libpng-LICENSE.txt, http://www.libpng.org/pub/png/libpng.html, https://spdx.org/licenses/Libpng
- Files with this license:
- png.h [110:110]
-
-KEEP Libpng a4cede44049edd3aa6708c55870aa4e2
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: Libpng
- Score : 60.81
- Match type : TEXT
- Links : http://libpng.org/pub/png/src/libpng-LICENSE.txt, http://www.libpng.org/pub/png/libpng.html, https://spdx.org/licenses/Libpng
- Files with this license:
- png.h [101:162]
-
-KEEP Libpng b3dffe414d279acaf02a20ca7ddac567
-BELONGS ya.make
- License text:
- * released under the libpng license described below. The modifications are
- Scancode info:
- Original SPDX id: Libpng
- Score : 100.00
- Match type : NOTICE
- Links : http://libpng.org/pub/png/src/libpng-LICENSE.txt, http://www.libpng.org/pub/png/libpng.html, https://spdx.org/licenses/Libpng
- Files with this license:
- png.h [27:27]
-
-KEEP Libpng b962c792285cc610bb3aed619261d8a9
-BELONGS ya.make
-FILE_INCLUDE INSTALL found in files: README at line 110
-FILE_INCLUDE LICENSE found in files: README at line 111
- License text:
- INSTALL => Instructions to install libpng
- LICENSE => License to use and redistribute libpng
- Scancode info:
- Original SPDX id: Libpng
- Score : 100.00
- Match type : REFERENCE
- Links : http://libpng.org/pub/png/src/libpng-LICENSE.txt, http://www.libpng.org/pub/png/libpng.html, https://spdx.org/licenses/Libpng
- Files with this license:
- README [110:111]
-
-KEEP MIT c77269c6dd6f51bfbe84805b0c8a235f
-BELONGS ya.make
- License text:
- Relicensed the CI scripts to the MIT License.
- Scancode info:
- Original SPDX id: MIT
- Score : 100.00
- Match type : REFERENCE
- Links : http://opensource.org/licenses/mit-license.php, https://spdx.org/licenses/MIT
- Files with this license:
- CHANGES [6160:6160]
-
-KEEP Libpng c8298e366a3ed11e6a851c27f5f62556
-BELONGS ya.make
- License text:
- other copyright owners, but are released under the libpng license.
- Scancode info:
- Original SPDX id: Libpng
- Score : 100.00
- Match type : NOTICE
- Links : http://libpng.org/pub/png/src/libpng-LICENSE.txt, http://www.libpng.org/pub/png/libpng.html, https://spdx.org/licenses/Libpng
- Files with this license:
- AUTHORS [57:57]
-
-SKIP LicenseRef-scancode-free-unknown d21cb537845df6d3bd33063822351d5a
-BELONGS ya.make
- # we have no contrib in libpng directory
- License text:
- * files that are distributed with libpng have other copyright owners, and
- * are released under other open source licenses.
- Scancode info:
- Original SPDX id: LicenseRef-scancode-free-unknown
- Score : 100.00
- Match type : NOTICE
- Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/free-unknown.LICENSE
- Files with this license:
- png.h [96:97]
-
-KEEP Libpng d25adc0a2183d65a4e22d7e88851e2ff
-BELONGS ya.make
- License text:
- Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
- libpng-0.96, and are distributed according to the same disclaimer and
- Scancode info:
- Original SPDX id: Libpng
- Score : 100.00
- Match type : REFERENCE
- Links : http://libpng.org/pub/png/src/libpng-LICENSE.txt, http://www.libpng.org/pub/png/libpng.html, https://spdx.org/licenses/Libpng
- Files with this license:
- LICENSE [78:79]
-
-KEEP Libpng d63e65265a41bd1533d43bdbd32e0b94
-BELONGS ya.make
- License text:
- necessarily under the libpng license, and that some makefiles have
- Scancode info:
- Original SPDX id: Libpng
- Score : 100.00
- Match type : REFERENCE
- Links : http://libpng.org/pub/png/src/libpng-LICENSE.txt, http://www.libpng.org/pub/png/libpng.html, https://spdx.org/licenses/Libpng
- Files with this license:
- CHANGES [5527:5527]
-
-KEEP Libpng d71f918f487643ebd6b9a8bd6ab5539c
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: Libpng
- Score : 17.56
- Match type : TEXT
- Links : http://libpng.org/pub/png/src/libpng-LICENSE.txt, http://www.libpng.org/pub/png/libpng.html, https://spdx.org/licenses/Libpng
- Files with this license:
- png.h [72:93]
-
-KEEP Libpng e9bb4f8fbab91484ba62ccb1611b70bb
-BELONGS ya.make
- License text:
- * derived from libpng-1.0.6, and are distributed according to the same
- Scancode info:
- Original SPDX id: Libpng
- Score : 100.00
- Match type : REFERENCE
- Links : http://libpng.org/pub/png/src/libpng-LICENSE.txt, http://www.libpng.org/pub/png/libpng.html, https://spdx.org/licenses/Libpng
- Files with this license:
- png.h [72:72]
-
-KEEP Libpng e9ec5df2670a4a277520cf3f626cccae
-BELONGS ya.make
- License text:
- Refer to the libpng license instead of the libpng license in each file.
- Scancode info:
- Original SPDX id: Libpng
- Score : 100.00
- Match type : REFERENCE
- Links : http://libpng.org/pub/png/src/libpng-LICENSE.txt, http://www.libpng.org/pub/png/libpng.html, https://spdx.org/licenses/Libpng
- Files with this license:
- CHANGES [2342:2342]
-
-KEEP Libpng eedcb004636ffbb973655257d0a0476d
-BELONGS ya.make
- License text:
- Fixed a typo in the libpng license v2.
- Scancode info:
- Original SPDX id: Libpng
- Score : 100.00
- Match type : REFERENCE
- Links : http://libpng.org/pub/png/src/libpng-LICENSE.txt, http://www.libpng.org/pub/png/libpng.html, https://spdx.org/licenses/Libpng
- Files with this license:
- CHANGES [6101:6101]
-
-SKIP LicenseRef-scancode-warranty-disclaimer fc06b30972b7cf612e820f3e79c9095c
-BELONGS ya.make
- # warrantly disclaimer
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: LicenseRef-scancode-warranty-disclaimer
- Score : 100.00
- Match type : NOTICE
- Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/warranty-disclaimer.LICENSE
- Files with this license:
- LICENSE [64:71]
-
-KEEP Libpng fc125ac8e86409d9543ae23600641ce9
-BELONGS ya.make
- License text:
- derived from libpng-1.0.6, and are distributed according to the same
- disclaimer and license as libpng-1.0.6 with the following individuals
- Scancode info:
- Original SPDX id: Libpng
- Score : 100.00
- Match type : REFERENCE
- Links : http://libpng.org/pub/png/src/libpng-LICENSE.txt, http://www.libpng.org/pub/png/libpng.html, https://spdx.org/licenses/Libpng
- Files with this license:
- LICENSE [50:51]
diff --git a/contrib/libs/libpng/.yandex_meta/licenses.list.txt b/contrib/libs/libpng/.yandex_meta/licenses.list.txt
deleted file mode 100644
index 7586de61ed..0000000000
--- a/contrib/libs/libpng/.yandex_meta/licenses.list.txt
+++ /dev/null
@@ -1,1093 +0,0 @@
-====================COPYRIGHT====================
- * Copyright (c) 1995-2025 The PNG Reference Library Authors.
- * Copyright (c) 2018-2025 Cosmin Truta.
- * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson.
- * Copyright (c) 1996-1997 Andreas Dilger.
- * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
-
-
-====================COPYRIGHT====================
- * Copyright (c) 2018 Cosmin Truta
- * Copyright (c) 1998-2002,2004,2006-2013 Glenn Randers-Pehrson
- * Copyright (c) 1996-1997 Andreas Dilger
- * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
-
-
-====================COPYRIGHT====================
- * Copyright (c) 2018 Cosmin Truta
- * Copyright (c) 1998-2002,2004,2006-2013,2018 Glenn Randers-Pehrson
- * Copyright (c) 1996-1997 Andreas Dilger
- * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
-
-
-====================COPYRIGHT====================
- * Copyright (c) 2018 Cosmin Truta
- * Copyright (c) 1998-2002,2004,2006-2014,2016 Glenn Randers-Pehrson
- * Copyright (c) 1996-1997 Andreas Dilger
- * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
-
-
-====================COPYRIGHT====================
- * Copyright (c) 2018 Cosmin Truta
- * Copyright (c) 1998-2002,2004,2006-2014,2016,2018 Glenn Randers-Pehrson
- * Copyright (c) 1996-1997 Andreas Dilger
- * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
-
-
-====================COPYRIGHT====================
- * Copyright (c) 2018 Cosmin Truta
- * Copyright (c) 2016-2017 Glenn Randers-Pehrson
- * Written by Mike Klein and Matt Sarett
- * Derived from arm/filter_neon_intrinsics.c
-
-
-====================COPYRIGHT====================
- * Copyright (c) 2018 Cosmin Truta
- * Copyright (c) 2017 Glenn Randers-Pehrson
- * Written by Vadim Barkov, 2017.
-
-
-====================COPYRIGHT====================
- * Copyright (c) 2018-2019 Cosmin Truta
- * Copyright (c) 2017-2018 Arm Holdings. All rights reserved.
-
-
-====================COPYRIGHT====================
- * Copyright (c) 2018-2022 Cosmin Truta
- * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
- * Copyright (c) 1996-1997 Andreas Dilger
- * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
-
-
-====================COPYRIGHT====================
- * Copyright (c) 2018-2022 Cosmin Truta
- * Copyright (c) 2014,2016 Glenn Randers-Pehrson
- * Written by Mans Rullgard, 2011.
-
-
-====================COPYRIGHT====================
- * Copyright (c) 2018-2024 Cosmin Truta
- * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
- * Copyright (c) 1996-1997 Andreas Dilger
- * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
-
-
-====================COPYRIGHT====================
- * Copyright (c) 2018-2024 Cosmin Truta
- * Copyright (c) 2016 Glenn Randers-Pehrson
- * Written by Mandar Sahastrabuddhe, August 2016
-
-
-====================COPYRIGHT====================
- * Copyright (c) 2018-2025 Cosmin Truta
- * Copyright (c) 1998-2002,2004,2006-2016,2018 Glenn Randers-Pehrson
- * Copyright (c) 1996-1997 Andreas Dilger
- * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
-
-
-====================COPYRIGHT====================
- * Copyright (c) 2018-2025 Cosmin Truta
- * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
- * Copyright (c) 1996-1997 Andreas Dilger
- * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
-
-
-====================COPYRIGHT====================
- * Copyright (c) 2018-2025 Cosmin Truta
- * Copyright (c) 1998-2018 Glenn Randers-Pehrson
- * Copyright (c) 1996-1997 Andreas Dilger
- * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
-
-
-====================COPYRIGHT====================
- * Copyright (c) 2024 Cosmin Truta
-
-
-====================COPYRIGHT====================
-Copyright (c) 2006-2007 Andrew Smith, Copyright (c) 2008-2025 Max Stepin,
-and are delimited by "#ifdef PNG_APNG_SUPPORTED / #endif" directives
-surrounding them in the modified libpng source files.
-
-
-====================COPYRIGHT====================
-Copyright (c) 2022 Cosmin Truta
-Copyright (c) 1998-2002,2006-2016 Glenn Randers-Pehrson
-This document is released under the libpng license.
-For conditions of distribution and use, see the disclaimer
-
-
-====================COPYRIGHT====================
-libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
-Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
-libpng-0.96, and are distributed according to the same disclaimer and
-license as libpng-0.96, with the following individuals added to the
-list of Contributing Authors:
-
-
-====================File: INSTALL====================
- Installing libpng
-
-Contents
-
- I. Simple installation
- II. Rebuilding the configure scripts
- III. Using scripts/makefile*
- IV. Using cmake
- V. Directory structure
- VI. Building with project files
- VII. Building with makefiles
- VIII. Configuring libpng for 16-bit platforms
- IX. Configuring for DOS
- X. Configuring for Medium Model
- XI. Prepending a prefix to exported symbols
- XII. Configuring for compiler xxx:
- XIII. Removing unwanted object code
- XIV. Enabling or disabling hardware optimizations
- XV. Changes to the build and configuration of libpng in libpng-1.5.x
- XVI. Setjmp/longjmp issues
- XVII. Common linking failures
- XVIII. Other sources of information about libpng
-
-I. Simple installation
-
-On Unix/Linux and similar systems, you can simply type
-
- ./configure [--prefix=/path]
- make check
- make install
-
-and ignore the rest of this document. "/path" is the path to the directory
-where you want to install the libpng "lib", "include", and "bin"
-subdirectories.
-
-If you downloaded a GIT clone, you will need to run ./autogen.sh before
-running ./configure, to create "configure" and "Makefile.in" which are
-not included in the GIT repository.
-
-Note that "configure" is only included in the "*.tar" distributions and not
-in the "*.zip" or "*.7z" distributions. If you downloaded one of those
-distributions, see "Building with project files" or "Building with makefiles",
-below.
-
-II. Rebuilding the configure scripts
-
-If configure does not work on your system, or if you have a need to
-change configure.ac or Makefile.am, and you have a reasonably
-up-to-date set of tools, running ./autogen.sh in a git clone before
-running ./configure may fix the problem. To be really sure that you
-aren't using any of the included pre-built scripts, especially if you
-are building from a tar distribution instead of a git distribution,
-do this:
-
- ./configure --enable-maintainer-mode
- make maintainer-clean
- ./autogen.sh --maintainer --clean
- ./autogen.sh --maintainer
- ./configure [--prefix=/path] [other options]
- make
- make install
- make check
-
-III. Using scripts/makefile*
-
-Instead, you can use one of the custom-built makefiles in the
-"scripts" directory
-
- cp scripts/pnglibconf.h.prebuilt pnglibconf.h
- cp scripts/makefile.system makefile
- make test
- make install
-
-The files that are presently available in the scripts directory
-are listed and described in scripts/README.txt.
-
-Or you can use one of the "projects" in the "projects" directory.
-
-Before installing libpng, you must first install zlib, if it
-is not already on your system. zlib can usually be found
-wherever you got libpng; otherwise go to https://zlib.net/. You can
-place zlib in the same directory as libpng or in another directory.
-
-If your system already has a preinstalled zlib you will still need
-to have access to the zlib.h and zconf.h include files that
-correspond to the version of zlib that's installed.
-
-If you wish to test with a particular zlib that is not first in the
-standard library search path, put ZLIBLIB, ZLIBINC, CPPFLAGS, LDFLAGS,
-and LD_LIBRARY_PATH in your environment before running "make test"
-or "make distcheck":
-
- ZLIBLIB=/path/to/lib export ZLIBLIB
- ZLIBINC=/path/to/include export ZLIBINC
- CPPFLAGS="-I$ZLIBINC" export CPPFLAGS
- LDFLAGS="-L$ZLIBLIB" export LDFLAGS
- LD_LIBRARY_PATH="$ZLIBLIB:$LD_LIBRARY_PATH" export LD_LIBRARY_PATH
-
-If you are using one of the makefile scripts, put ZLIBLIB and ZLIBINC
-in your environment and type
-
- make ZLIBLIB=$ZLIBLIB ZLIBINC=$ZLIBINC test
-
-IV. Using cmake
-
-If you want to use "cmake" (see www.cmake.org), type
-
- cmake . -DCMAKE_INSTALL_PREFIX=/path
- make
- make install
-
-As when using the simple configure method described above, "/path" points to
-the installation directory where you want to put the libpng "lib", "include",
-and "bin" subdirectories.
-
-V. Directory structure
-
-You can rename the directories that you downloaded (they
-might be called "libpng-x.y.z" or "libpngNN" and "zlib-1.2.8"
-or "zlib128") so that you have directories called "zlib" and "libpng".
-
-Your directory structure should look like this:
-
- .. (the parent directory)
- libpng (this directory)
- INSTALL (this file)
- README
- *.h, *.c => libpng source files
- CMakeLists.txt => "cmake" script
- ci
- ci_*.sh
- configuration files:
- configure.ac, configure, Makefile.am, Makefile.in,
- autogen.sh, config.guess, ltmain.sh, missing, libpng.pc.in,
- libpng-config.in, aclocal.m4, config.h.in, config.sub,
- depcomp, install-sh, mkinstalldirs, test-pngtest.sh, etc.
- contrib
- arm-neon, conftest, examples, gregbook, libtests, pngminim,
- pngminus, pngsuite, tools, visupng
- projects
- owatcom, visualc71, vstudio
- scripts
- makefile.*
- *.def (module definition files)
- etc.
- pngtest.png
- etc.
- zlib
- README, *.h, *.c, contrib, etc.
-
-If the line endings in the files look funny, you may wish to get the other
-distribution of libpng. It is available in both tar.gz (UNIX style line
-endings) and zip (DOS style line endings) formats.
-
-VI. Building with project files
-
-If you are building libpng with Microsoft Visual Studio, you can enter
-the directory projects\visualc71 or projects\vstudio and follow the
-instructions in README.txt.
-
-Otherwise, enter the zlib directory and follow the instructions in
-zlib/README, then come back here and run "configure" or choose the
-appropriate makefile in the scripts directory.
-
-VII. Building with makefiles
-
-Copy the file (or files) that you need from the
-scripts directory into this directory, for example
-
-UNIX example:
-
- cp scripts/makefile.std Makefile
- make
-
-Windows example:
-
- nmake -f scripts\makefile.vcwin32
-
-Read the makefile to see if you need to change any source or
-target directories to match your preferences.
-
-Then read pnglibconf.dfa to see if you want to make any configuration
-changes.
-
-Then just run "make" which will create the libpng library in
-this directory and "make test" which will run a quick test that reads
-the "pngtest.png" file and writes a "pngout.png" file that should be
-identical to it. Look for "9782 zero samples" in the output of the
-test. For more confidence, you can run another test by typing
-"pngtest pngnow.png" and looking for "289 zero samples" in the output.
-Also, you can run "pngtest -m contrib/pngsuite/*.png" and compare
-your output with the result shown in contrib/pngsuite/README.
-
-Most of the makefiles used to allow you to run "make install" to put
-the library in its final resting place, but that feature is no longer
-supported. The only tested and supported manners to install libpng are
-the conventional build and install procedures driven by the configure
-script or by the CMake file.
-
-VIII. Configuring for DOS and other 16-bit platforms
-
-Officially, the support for 16-bit platforms has been removed.
-
-For DOS users who only have access to the lower 640K, you will
-have to limit zlib's memory usage via a png_set_compression_mem_level()
-call. See zlib.h or zconf.h in the zlib library for more information.
-
-You may be or may not be in luck if you target the "large" memory model,
-but all the smaller models ("small", "compact" and "medium") are known
-to be unworkable. For DOS users who have access beyond the lower 640K,
-a "flat" 32-bit DOS model (such as DJGPP) is strongly recommended.
-
-For DOS users who only have access to the lower 640K, you will have to
-limit zlib's memory usage via a png_set_compression_mem_level() call.
-You will also have to look into zconf.h to tell zlib (and thus libpng)
-that it cannot allocate more than 64K at a time. Even if you can, the
-memory won't be accessible. Therefore, you should limit zlib and libpng
-to 64K by defining MAXSEG_64K.
-
-IX. Prepending a prefix to exported symbols
-
-Starting with libpng-1.6.0, you can configure libpng (when using the
-"configure" script) to prefix all exported symbols by means of the
-configuration option "--with-libpng-prefix=FOO_", where FOO_ can be any
-string beginning with a letter and containing only uppercase
-and lowercase letters, digits, and the underscore (i.e., a C language
-identifier). This creates a set of macros in pnglibconf.h, so this is
-transparent to applications; their function calls get transformed by
-the macros to use the modified names.
-
-X. Configuring for compiler xxx:
-
-All includes for libpng are in pngconf.h. If you need to add, change
-or delete an include, this is the place to do it.
-The includes that are not needed outside libpng are placed in pngpriv.h,
-which is only used by the routines inside libpng itself.
-The files in libpng proper only include pngpriv.h and png.h, which
-in turn includes pngconf.h and, as of libpng-1.5.0, pnglibconf.h.
-As of libpng-1.5.0, pngpriv.h also includes three other private header
-files, pngstruct.h, pnginfo.h, and pngdebug.h, which contain material
-that previously appeared in the public headers.
-
-XI. Removing unwanted object code
-
-There are a bunch of #define's in pngconf.h that control what parts of
-libpng are compiled. All the defines end in _SUPPORTED. If you are
-never going to use a capability, you can change the #define to #undef
-before recompiling libpng and save yourself code and data space, or
-you can turn off individual capabilities with defines that begin with
-"PNG_NO_".
-
-In libpng-1.5.0 and later, the #define's are in pnglibconf.h instead.
-
-You can also turn all of the transforms and ancillary chunk capabilities
-off en masse with compiler directives that define
-PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS,
-or all four, along with directives to turn on any of the capabilities that
-you do want. The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable the
-extra transformations but still leave the library fully capable of reading
-and writing PNG files with all known public chunks. Use of the
-PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive produces a library
-that is incapable of reading or writing ancillary chunks. If you are
-not using the progressive reading capability, you can turn that off
-with PNG_NO_PROGRESSIVE_READ (don't confuse this with the INTERLACING
-capability, which you'll still have).
-
-All the reading and writing specific code are in separate files, so the
-linker should only grab the files it needs. However, if you want to
-make sure, or if you are building a stand alone library, all the
-reading files start with "pngr" and all the writing files start with "pngw".
-The files that don't match either (like png.c, pngtrans.c, etc.)
-are used for both reading and writing, and always need to be included.
-The progressive reader is in pngpread.c
-
-If you are creating or distributing a dynamically linked library (a .so
-or DLL file), you should not remove or disable any parts of the library,
-as this will cause applications linked with different versions of the
-library to fail if they call functions not available in your library.
-The size of the library itself should not be an issue, because only
-those sections that are actually used will be loaded into memory.
-
-XII. Enabling or disabling hardware optimizations
-
-Certain hardware capabilities, such as the Intel SSE instructions,
-are normally detected at run time. Enable them with configure options
-such as one of
-
- --enable-arm-neon=yes
- --enable-mips-msa=yes
- --enable-intel-sse=yes
- --enable-powerpc-vsx=yes
-
-or enable them all at once with
-
- --enable-hardware-optimizations=yes
-
-or, if you are not using "configure", you can use one
-or more of
-
- CPPFLAGS += "-DPNG_ARM_NEON"
- CPPFLAGS += "-DPNG_MIPS_MSA"
- CPPFLAGS += "-DPNG_INTEL_SSE"
- CPPFLAGS += "-DPNG_POWERPC_VSX"
-
-See for example scripts/makefile.linux-opt
-
-If you wish to avoid using them,
-you can disable them via the configure option
-
- --disable-hardware-optimizations
-
-to disable them all, or
-
- --enable-intel-sse=no
-
-to disable a particular one,
-or via compiler-command options such as
-
- CPPFLAGS += "-DPNG_ARM_NEON_OPT=0, -DPNG_MIPS_MSA_OPT=0,
- -DPNG_INTEL_SSE_OPT=0, -DPNG_POWERPC_VSX_OPT=0"
-
-If you are using cmake, hardware optimizations are "on"
-by default. To disable them, use
-
- cmake . -DPNG_ARM_NEON=no -DPNG_INTEL_SSE=no \
- -DPNG_MIPS_MSA=no -DPNG_POWERPC_VSX=no
-
-or disable them all at once with
-
- cmake . -DPNG_HARDWARE_OPTIMIZATIONS=no
-
-XIII. Changes to the build and configuration of libpng in libpng-1.5.x
-
-Details of internal changes to the library code can be found in the CHANGES
-file and in the GIT repository logs. These will be of no concern to the vast
-majority of library users or builders; however, the few who configure libpng
-to a non-default feature set may need to change how this is done.
-
-There should be no need for library builders to alter build scripts if
-these use the distributed build support - configure or the makefiles -
-however, users of the makefiles may care to update their build scripts
-to build pnglibconf.h where the corresponding makefile does not do so.
-
-Building libpng with a non-default configuration has changed completely.
-The old method using pngusr.h should still work correctly even though the
-way pngusr.h is used in the build has been changed; however, library
-builders will probably want to examine the changes to take advantage of
-new capabilities and to simplify their build system.
-
-A. Specific changes to library configuration capabilities
-
-The exact mechanism used to control attributes of API functions has
-changed. A single set of operating system independent macro definitions
-is used and operating system specific directives are defined in
-pnglibconf.h
-
-As part of this the mechanism used to choose procedure call standards on
-those systems that allow a choice has been changed. At present this only
-affects certain Microsoft (DOS, Windows) and IBM (OS/2) operating systems
-running on Intel processors. As before, PNGAPI is defined where required
-to control the exported API functions; however, two new macros, PNGCBAPI
-and PNGCAPI, are used instead for callback functions (PNGCBAPI) and
-(PNGCAPI) for functions that must match a C library prototype (currently
-only png_longjmp_ptr, which must match the C longjmp function.) The new
-approach is documented in pngconf.h
-
-Despite these changes, libpng 1.5.0 only supports the native C function
-calling standard on those platforms tested so far ("__cdecl" on Microsoft
-Windows). This is because the support requirements for alternative
-calling conventions seem to no longer exist. Developers who find it
-necessary to set PNG_API_RULE to 1 should advise the mailing list
-(png-mng-implement) of this and library builders who use Openwatcom and
-therefore set PNG_API_RULE to 2 should also contact the mailing list.
-
-B. Changes to the configuration mechanism
-
-Prior to libpng-1.5.0 library builders who needed to configure libpng
-had either to modify the exported pngconf.h header file to add system
-specific configuration or had to write feature selection macros into
-pngusr.h and cause this to be included into pngconf.h by defining
-PNG_USER_CONFIG. The latter mechanism had the disadvantage that an
-application built without PNG_USER_CONFIG defined would see the
-unmodified, default, libpng API and thus would probably fail to link.
-
-These mechanisms still work in the configure build and in any makefile
-build that builds pnglibconf.h, although the feature selection macros
-have changed somewhat as described above. In 1.5.0, however, pngusr.h is
-processed only once, at the time the exported header file pnglibconf.h is
-built. pngconf.h no longer includes pngusr.h; therefore, pngusr.h is ignored
-after the build of pnglibconf.h and it is never included in an application
-build.
-
-The formerly used alternative of adding a list of feature macros to the
-CPPFLAGS setting in the build also still works; however, the macros will be
-copied to pnglibconf.h and this may produce macro redefinition warnings
-when the individual C files are compiled.
-
-All configuration now only works if pnglibconf.h is built from
-scripts/pnglibconf.dfa. This requires the program awk. Brian Kernighan
-(the original author of awk) maintains C source code of that awk and this
-and all known later implementations (often called by subtly different
-names - nawk and gawk for example) are adequate to build pnglibconf.h.
-The Sun Microsystems (now Oracle) program 'awk' is an earlier version
-and does not work; this may also apply to other systems that have a
-functioning awk called 'nawk'.
-
-Configuration options are now documented in scripts/pnglibconf.dfa. This
-file also includes dependency information that ensures a configuration is
-consistent; that is, if a feature is switched off, dependent features are
-also switched off. As a recommended alternative to using feature macros in
-pngusr.h a system builder may also define equivalent options in pngusr.dfa
-(or, indeed, any file) and add that to the configuration by setting
-DFA_XTRA to the file name. The makefiles in contrib/pngminim illustrate
-how to do this, and also illustrate a case where pngusr.h is still required.
-
-After you have built libpng, the definitions that were recorded in
-pnglibconf.h are available to your application (pnglibconf.h is included
-in png.h and gets installed alongside png.h and pngconf.h in your
-$PREFIX/include directory). Do not edit pnglibconf.h after you have built
-libpng, because than the settings would not accurately reflect the settings
-that were used to build libpng.
-
-XIV. Setjmp/longjmp issues
-
-Libpng uses setjmp()/longjmp() for error handling. Unfortunately setjmp()
-is known to be not thread-safe on some platforms and we don't know of
-any platform where it is guaranteed to be thread-safe. Therefore, if
-your application is going to be using multiple threads, you should
-configure libpng with PNG_NO_SETJMP in your pngusr.dfa file, with
--DPNG_NO_SETJMP on your compile line, or with
-
- #undef PNG_SETJMP_SUPPORTED
-
-in your pnglibconf.h or pngusr.h.
-
-Starting with libpng-1.6.0, the library included a "simplified API".
-This requires setjmp/longjmp, so you must either build the library
-with PNG_SETJMP_SUPPORTED defined, or with PNG_SIMPLIFIED_READ_SUPPORTED
-and PNG_SIMPLIFIED_WRITE_SUPPORTED undefined.
-
-XV. Common linking failures
-
-If your application fails to find libpng or zlib entries while linking:
-
- Be sure "-lz" appears after "-lpng" on your linking command.
-
- Be sure you have built libpng, zlib, and your application for the
- same platform (e.g., 32-bit or 64-bit).
-
- If you are using the vstudio project, observe the WARNING in
- project/vstudio/README.txt.
-
-XVI. Other sources of information about libpng:
-
-Further information can be found in the README and libpng-manual.txt
-files, in the individual makefiles, in png.h, and the manual pages
-libpng.3 and png.5.
-
-Copyright (c) 2022 Cosmin Truta
-Copyright (c) 1998-2002,2006-2016 Glenn Randers-Pehrson
-This document is released under the libpng license.
-For conditions of distribution and use, see the disclaimer
-and license in png.h.
-
-
-====================File: LICENSE====================
-COPYRIGHT NOTICE, DISCLAIMER, and LICENSE
-=========================================
-
-This modified version of libpng code adds animated PNG support and is
-released under the libpng license described below. The modifications are
-Copyright (c) 2006-2007 Andrew Smith, Copyright (c) 2008-2025 Max Stepin,
-and are delimited by "#ifdef PNG_APNG_SUPPORTED / #endif" directives
-surrounding them in the modified libpng source files.
-
-PNG Reference Library License version 2
----------------------------------------
-
- * Copyright (c) 1995-2025 The PNG Reference Library Authors.
- * Copyright (c) 2018-2025 Cosmin Truta.
- * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson.
- * Copyright (c) 1996-1997 Andreas Dilger.
- * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
-
-The software is supplied "as is", without warranty of any kind,
-express or implied, including, without limitation, the warranties
-of merchantability, fitness for a particular purpose, title, and
-non-infringement. In no event shall the Copyright owners, or
-anyone distributing the software, be liable for any damages or
-other liability, whether in contract, tort or otherwise, arising
-from, out of, or in connection with the software, or the use or
-other dealings in the software, even if advised of the possibility
-of such damage.
-
-Permission is hereby granted to use, copy, modify, and distribute
-this software, or portions hereof, for any purpose, without fee,
-subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you
- must not claim that you wrote the original software. If you
- use this software in a product, an acknowledgment in the product
- documentation would be appreciated, but is not required.
-
- 2. Altered source versions must be plainly marked as such, and must
- not be misrepresented as being the original software.
-
- 3. This Copyright notice may not be removed or altered from any
- source or altered source distribution.
-
-
-PNG Reference Library License version 1 (for libpng 0.5 through 1.6.35)
------------------------------------------------------------------------
-
-libpng versions 1.0.7, July 1, 2000, through 1.6.35, July 15, 2018 are
-Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson, are
-derived from libpng-1.0.6, and are distributed according to the same
-disclaimer and license as libpng-1.0.6 with the following individuals
-added to the list of Contributing Authors:
-
- Simon-Pierre Cadieux
- Eric S. Raymond
- Mans Rullgard
- Cosmin Truta
- Gilles Vollant
- James Yu
- Mandar Sahastrabuddhe
- Google Inc.
- Vadim Barkov
-
-and with the following additions to the disclaimer:
-
- There is no warranty against interference with your enjoyment of
- the library or against infringement. There is no warranty that our
- efforts or the library will fulfill any of your particular purposes
- or needs. This library is provided with all faults, and the entire
- risk of satisfactory quality, performance, accuracy, and effort is
- with the user.
-
-Some files in the "contrib" directory and some configure-generated
-files that are distributed with libpng have other copyright owners, and
-are released under other open source licenses.
-
-libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
-Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
-libpng-0.96, and are distributed according to the same disclaimer and
-license as libpng-0.96, with the following individuals added to the
-list of Contributing Authors:
-
- Tom Lane
- Glenn Randers-Pehrson
- Willem van Schaik
-
-libpng versions 0.89, June 1996, through 0.96, May 1997, are
-Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
-and are distributed according to the same disclaimer and license as
-libpng-0.88, with the following individuals added to the list of
-Contributing Authors:
-
- John Bowler
- Kevin Bracey
- Sam Bushell
- Magnus Holmgren
- Greg Roelofs
- Tom Tanner
-
-Some files in the "scripts" directory have other copyright owners,
-but are released under this license.
-
-libpng versions 0.5, May 1995, through 0.88, January 1996, are
-Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
-
-For the purposes of this copyright and license, "Contributing Authors"
-is defined as the following set of individuals:
-
- Andreas Dilger
- Dave Martindale
- Guy Eric Schalnat
- Paul Schmidt
- Tim Wegner
-
-The PNG Reference Library is supplied "AS IS". The Contributing
-Authors and Group 42, Inc. disclaim all warranties, expressed or
-implied, including, without limitation, the warranties of
-merchantability and of fitness for any purpose. The Contributing
-Authors and Group 42, Inc. assume no liability for direct, indirect,
-incidental, special, exemplary, or consequential damages, which may
-result from the use of the PNG Reference Library, even if advised of
-the possibility of such damage.
-
-Permission is hereby granted to use, copy, modify, and distribute this
-source code, or portions hereof, for any purpose, without fee, subject
-to the following restrictions:
-
- 1. The origin of this source code must not be misrepresented.
-
- 2. Altered versions must be plainly marked as such and must not
- be misrepresented as being the original source.
-
- 3. This Copyright notice may not be removed or altered from any
- source or altered source distribution.
-
-The Contributing Authors and Group 42, Inc. specifically permit,
-without fee, and encourage the use of this source code as a component
-to supporting the PNG file format in commercial products. If you use
-this source code in a product, acknowledgment is not required but would
-be appreciated.
-
-
-====================File: TRADEMARK====================
-TRADEMARK
-=========
-
-The name "libpng" has not been registered by the Copyright owners
-as a trademark in any jurisdiction. However, because libpng has
-been distributed and maintained world-wide, continually since 1995,
-the Copyright owners claim "common-law trademark protection" in any
-jurisdiction where common-law trademark is recognized.
-
-
-====================Libpng====================
- INSTALL => Instructions to install libpng
- LICENSE => License to use and redistribute libpng
-
-
-====================Libpng====================
- necessarily under the libpng license, and that some makefiles have
-
-
-====================Libpng====================
- the libpng license.
-
-
-====================Libpng====================
- Added a reference to the libpng license in each file.
-
-
-====================Libpng====================
- Fixed a typo in the libpng license v2.
-
-
-====================Libpng====================
- Refer to the libpng license instead of the libpng license in each file.
-
-
-====================Libpng====================
- * Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
-
-
-====================Libpng====================
- * Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
- * libpng-0.96, and are distributed according to the same disclaimer and
-
-
-====================Libpng====================
- * Some files in the "scripts" directory have other copyright owners,
- * but are released under this license.
- *
- * libpng versions 0.5, May 1995, through 0.88, January 1996, are
-
-
-====================Libpng====================
- * This code is released under the libpng license.
- * For conditions of distribution and use, see the disclaimer
- * and license in png.h
-
-
-====================Libpng====================
- * This code is released under the libpng license. (See LICENSE, below.)
-
-
-====================Libpng====================
- * derived from libpng-1.0.6, and are distributed according to the same
-
-
-====================Libpng====================
- * derived from libpng-1.0.6, and are distributed according to the same
- * disclaimer and license as libpng-1.0.6 with the following individuals
- * added to the list of Contributing Authors:
- *
- * Simon-Pierre Cadieux
- * Eric S. Raymond
- * Mans Rullgard
- * Cosmin Truta
- * Gilles Vollant
- * James Yu
- * Mandar Sahastrabuddhe
- * Google Inc.
- * Vadim Barkov
- *
- * and with the following additions to the disclaimer:
- *
- * There is no warranty against interference with your enjoyment of
- * the library or against infringement. There is no warranty that our
- * efforts or the library will fulfill any of your particular purposes
- * or needs. This library is provided with all faults, and the entire
- * risk of satisfactory quality, performance, accuracy, and effort is
- * with the user.
-
-
-====================Libpng====================
- * libpng-0.96, and are distributed according to the same disclaimer and
- * license as libpng-0.96, with the following individuals added to the
- * list of Contributing Authors:
- *
- * Tom Lane
- * Glenn Randers-Pehrson
- * Willem van Schaik
- *
- * libpng versions 0.89, June 1996, through 0.96, May 1997, are
- * Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
- * and are distributed according to the same disclaimer and license as
- * libpng-0.88, with the following individuals added to the list of
- * Contributing Authors:
- *
- * John Bowler
- * Kevin Bracey
- * Sam Bushell
- * Magnus Holmgren
- * Greg Roelofs
- * Tom Tanner
- *
- * Some files in the "scripts" directory have other copyright owners,
- * but are released under this license.
- *
- * libpng versions 0.5, May 1995, through 0.88, January 1996, are
- * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
- *
- * For the purposes of this copyright and license, "Contributing Authors"
- * is defined as the following set of individuals:
- *
- * Andreas Dilger
- * Dave Martindale
- * Guy Eric Schalnat
- * Paul Schmidt
- * Tim Wegner
- *
- * The PNG Reference Library is supplied "AS IS". The Contributing
- * Authors and Group 42, Inc. disclaim all warranties, expressed or
- * implied, including, without limitation, the warranties of
- * merchantability and of fitness for any purpose. The Contributing
- * Authors and Group 42, Inc. assume no liability for direct, indirect,
- * incidental, special, exemplary, or consequential damages, which may
- * result from the use of the PNG Reference Library, even if advised of
- * the possibility of such damage.
- *
- * Permission is hereby granted to use, copy, modify, and distribute this
- * source code, or portions hereof, for any purpose, without fee, subject
- * to the following restrictions:
- *
- * 1. The origin of this source code must not be misrepresented.
- *
- * 2. Altered versions must be plainly marked as such and must not
- * be misrepresented as being the original source.
- *
- * 3. This Copyright notice may not be removed or altered from any
- * source or altered source distribution.
- *
- * The Contributing Authors and Group 42, Inc. specifically permit,
- * without fee, and encourage the use of this source code as a component
- * to supporting the PNG file format in commercial products. If you use
- * this source code in a product, acknowledgment is not required but would
- * be appreciated.
-
-
-====================Libpng====================
- * released under the libpng license described below. The modifications are
-
-
-====================Libpng====================
-/* This code is released under the libpng license. */
-/* For conditions of distribution and use, see the disclaimer */
-/* and license in png.h */
-
-
-====================Libpng====================
-Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
-
-
-====================Libpng====================
-Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
-libpng-0.96, and are distributed according to the same disclaimer and
-
-
-====================Libpng====================
-Some files in the "scripts" directory have other copyright owners,
-but are released under this license.
-
-libpng versions 0.5, May 1995, through 0.88, January 1996, are
-
-
-====================Libpng====================
-TRADEMARK
-=========
-
-The name "libpng" has not been registered by the Copyright owners
-as a trademark in any jurisdiction. However, because libpng has
-been distributed and maintained world-wide, continually since 1995,
-the Copyright owners claim "common-law trademark protection" in any
-jurisdiction where common-law trademark is recognized.
-
-====================Libpng====================
-This document is released under the libpng license.
-For conditions of distribution and use, see the disclaimer
-and license in png.h.
-
-====================Libpng====================
-derived from libpng-1.0.6, and are distributed according to the same
-
-
-====================Libpng====================
-derived from libpng-1.0.6, and are distributed according to the same
-disclaimer and license as libpng-1.0.6 with the following individuals
-
-
-====================Libpng====================
-libpng-0.96, and are distributed according to the same disclaimer and
-license as libpng-0.96, with the following individuals added to the
-list of Contributing Authors:
-
- Tom Lane
- Glenn Randers-Pehrson
- Willem van Schaik
-
-libpng versions 0.89, June 1996, through 0.96, May 1997, are
-Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
-and are distributed according to the same disclaimer and license as
-libpng-0.88, with the following individuals added to the list of
-Contributing Authors:
-
- John Bowler
- Kevin Bracey
- Sam Bushell
- Magnus Holmgren
- Greg Roelofs
- Tom Tanner
-
-Some files in the "scripts" directory have other copyright owners,
-but are released under this license.
-
-libpng versions 0.5, May 1995, through 0.88, January 1996, are
-Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
-
-For the purposes of this copyright and license, "Contributing Authors"
-is defined as the following set of individuals:
-
- Andreas Dilger
- Dave Martindale
- Guy Eric Schalnat
- Paul Schmidt
- Tim Wegner
-
-The PNG Reference Library is supplied "AS IS". The Contributing
-Authors and Group 42, Inc. disclaim all warranties, expressed or
-implied, including, without limitation, the warranties of
-merchantability and of fitness for any purpose. The Contributing
-Authors and Group 42, Inc. assume no liability for direct, indirect,
-incidental, special, exemplary, or consequential damages, which may
-result from the use of the PNG Reference Library, even if advised of
-the possibility of such damage.
-
-Permission is hereby granted to use, copy, modify, and distribute this
-source code, or portions hereof, for any purpose, without fee, subject
-to the following restrictions:
-
- 1. The origin of this source code must not be misrepresented.
-
- 2. Altered versions must be plainly marked as such and must not
- be misrepresented as being the original source.
-
- 3. This Copyright notice may not be removed or altered from any
- source or altered source distribution.
-
-The Contributing Authors and Group 42, Inc. specifically permit,
-without fee, and encourage the use of this source code as a component
-to supporting the PNG file format in commercial products. If you use
-this source code in a product, acknowledgment is not required but would
-be appreciated.
-
-====================Libpng====================
-other copyright owners, but are released under the libpng license.
-
-
-====================Libpng====================
-released under the libpng license described below. The modifications are
-
-
-====================MIT====================
- Relicensed the CI scripts to the MIT License.
-
-
-====================libpng-2.0====================
- * * Copyright (c) 1995-2025 The PNG Reference Library Authors.
- * * Copyright (c) 2018-2025 Cosmin Truta.
- * * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson.
- * * Copyright (c) 1996-1997 Andreas Dilger.
- * * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
- *
- * The software is supplied "as is", without warranty of any kind,
- * express or implied, including, without limitation, the warranties
- * of merchantability, fitness for a particular purpose, title, and
- * non-infringement. In no event shall the Copyright owners, or
- * anyone distributing the software, be liable for any damages or
- * other liability, whether in contract, tort or otherwise, arising
- * from, out of, or in connection with the software, or the use or
- * other dealings in the software, even if advised of the possibility
- * of such damage.
- *
- * Permission is hereby granted to use, copy, modify, and distribute
- * this software, or portions hereof, for any purpose, without fee,
- * subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you
- * must not claim that you wrote the original software. If you
- * use this software in a product, an acknowledgment in the product
- * documentation would be appreciated, but is not required.
- *
- * 2. Altered source versions must be plainly marked as such, and must
- * not be misrepresented as being the original software.
- *
- * 3. This Copyright notice may not be removed or altered from any
- * source or altered source distribution.
-
-
-====================libpng-2.0====================
-COPYRIGHT NOTICE, DISCLAIMER, and LICENSE
-=========================================
-
-This modified version of libpng code adds animated PNG support and is
-released under the libpng license described below. The modifications are
-Copyright (c) 2006-2007 Andrew Smith, Copyright (c) 2008-2025 Max Stepin,
-and are delimited by "#ifdef PNG_APNG_SUPPORTED / #endif" directives
-surrounding them in the modified libpng source files.
-
-PNG Reference Library License version 2
----------------------------------------
-
- * Copyright (c) 1995-2025 The PNG Reference Library Authors.
- * Copyright (c) 2018-2025 Cosmin Truta.
- * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson.
- * Copyright (c) 1996-1997 Andreas Dilger.
- * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
-
-The software is supplied "as is", without warranty of any kind,
-express or implied, including, without limitation, the warranties
-of merchantability, fitness for a particular purpose, title, and
-non-infringement. In no event shall the Copyright owners, or
-anyone distributing the software, be liable for any damages or
-other liability, whether in contract, tort or otherwise, arising
-from, out of, or in connection with the software, or the use or
-other dealings in the software, even if advised of the possibility
-of such damage.
-
-Permission is hereby granted to use, copy, modify, and distribute
-this software, or portions hereof, for any purpose, without fee,
-subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you
- must not claim that you wrote the original software. If you
- use this software in a product, an acknowledgment in the product
- documentation would be appreciated, but is not required.
-
- 2. Altered source versions must be plainly marked as such, and must
- not be misrepresented as being the original software.
-
- 3. This Copyright notice may not be removed or altered from any
- source or altered source distribution.
diff --git a/contrib/libs/libpng/.yandex_meta/override.nix b/contrib/libs/libpng/.yandex_meta/override.nix
deleted file mode 100644
index 56a98cd3b0..0000000000
--- a/contrib/libs/libpng/.yandex_meta/override.nix
+++ /dev/null
@@ -1,19 +0,0 @@
-pkgs: attrs: with pkgs; rec {
- version = "1.6.46";
-
- src = fetchFromGitHub {
- owner = "pnggroup";
- repo = "libpng";
- rev = "v${version}";
- hash = "sha256-SP4rpTKFihEEyZ6Zuomy3mhhvIqMkWURjnrntsWO8fo=";
- };
-
- # nixpkgs applies apng patch from sourceforge.net, which changes for every libpng version.
- # We apply a sligthly modified version of this patch via patches/apng.patch
- patches = [];
- postPatch = "";
-
- configureFlags = [
- "--build=x86_64-pc-linux-gnu"
- ];
-}
diff --git a/contrib/libs/libpng/ANNOUNCE b/contrib/libs/libpng/ANNOUNCE
deleted file mode 100644
index 579824fbe9..0000000000
--- a/contrib/libs/libpng/ANNOUNCE
+++ /dev/null
@@ -1,44 +0,0 @@
-libpng 1.6.46 - January 23, 2025
-================================
-
-This is a public release of libpng, intended for use in production code.
-
-
-Files available for download
-----------------------------
-
-Source files with LF line endings (for Unix/Linux):
-
- * libpng-1.6.46.tar.xz (LZMA-compressed, recommended)
- * libpng-1.6.46.tar.gz (deflate-compressed)
-
-Source files with CRLF line endings (for Windows):
-
- * lpng1646.7z (LZMA-compressed, recommended)
- * lpng1646.zip (deflate-compressed)
-
-Other information:
-
- * README.md
- * LICENSE.md
- * AUTHORS.md
- * TRADEMARK.md
-
-
-Changes from version 1.6.45 to version 1.6.46
----------------------------------------------
-
- * Added support for the mDCV and cLLI chunks.
- (Contributed by John Bowler)
- * Fixed a build issue affecting C89 compilers.
- This was a regression introduced in libpng-1.6.45.
- (Contributed by John Bowler)
- * Added makefile.c89, specifically for testing C89 compilers.
- * Cleaned up contrib/pngminus: corrected an old typo, removed an old
- workaround, and updated the CMake file.
-
-
-Send comments/corrections/commendations to png-mng-implement at lists.sf.net.
-Subscription is required; visit
-https://lists.sourceforge.net/lists/listinfo/png-mng-implement
-to subscribe.
diff --git a/contrib/libs/libpng/AUTHORS b/contrib/libs/libpng/AUTHORS
deleted file mode 100644
index f30a4ee192..0000000000
--- a/contrib/libs/libpng/AUTHORS
+++ /dev/null
@@ -1,62 +0,0 @@
-PNG REFERENCE LIBRARY AUTHORS
-=============================
-
-This is the list of PNG Reference Library ("libpng") Contributing
-Authors, for copyright and licensing purposes.
-
- * Adam Richter
- * Andreas Dilger
- * Chris Blume
- * Cosmin Truta
- * Dave Martindale
- * Eric S. Raymond
- * Gilles Vollant
- * Glenn Randers-Pehrson
- * Greg Roelofs
- * Guy Eric Schalnat
- * James Yu
- * John Bowler
- * Kevin Bracey
- * Lucas Chollet
- * Magnus Holmgren
- * Mandar Sahastrabuddhe
- * Mans Rullgard
- * Matt Sarett
- * Mike Klein
- * Pascal Massimino
- * Paul Schmidt
- * Philippe Antoine
- * Qiang Zhou
- * Sam Bushell
- * Samuel Williams
- * Simon-Pierre Cadieux
- * Tim Wegner
- * Tom Lane
- * Tom Tanner
- * Vadim Barkov
- * Willem van Schaik
- * Zhijie Liang
- * Apple Inc.
- - Zixu Wang (王å­æ—­)
- * Arm Holdings
- - Richard Townsend
- * Google Inc.
- - Dan Field
- - Leon Scroggins III
- - Matt Sarett
- - Mike Klein
- - Sami Boukortt
- - Wan-Teh Chang
- * Loongson Technology Corporation Ltd.
- - GuXiWei (顾希伟)
- - JinBo (金波)
- - ZhangLixia (张利霞)
-
-The build projects, the build scripts, the test scripts, and other
-files in the "projects", "scripts" and "tests" directories, have
-other copyright owners, but are released under the libpng license.
-
-Some files in the "ci" and "contrib" directories, as well as some
-of the tools-generated files that are distributed with libpng, have
-other copyright owners, and are released under other open source
-licenses.
diff --git a/contrib/libs/libpng/CHANGES b/contrib/libs/libpng/CHANGES
deleted file mode 100644
index e6aa1db13f..0000000000
--- a/contrib/libs/libpng/CHANGES
+++ /dev/null
@@ -1,6245 +0,0 @@
-CHANGES - changes for libpng
-
-version 0.1 [March 29, 1995]
- initial work-in-progress release
-
-version 0.2 [April 1, 1995]
- added reader into png.h
- fixed small problems in stub file
-
-version 0.3 [April 8, 1995]
- added pull reader
- split up pngwrite.c to several files
- added pnglib.txt
- added example.c
- cleaned up writer, adding a few new transformations
- fixed some bugs in writer
- interfaced with zlib 0.5
- added K&R support
- added check for 64 KB blocks for 16 bit machines
-
-version 0.4 [April 26, 1995]
- cleaned up code and commented code
- simplified time handling into png_time
- created png_color_16 and png_color_8 to handle color needs
- cleaned up color type defines
- fixed various bugs
- made various names more consistent
- interfaced with zlib 0.71
- cleaned up zTXt reader and writer (using zlib's Reset functions)
- split transformations into pngrtran.c and pngwtran.c
-
-version 0.5 [April 30, 1995]
- interfaced with zlib 0.8
- fixed many reading and writing bugs
- saved using 3 spaces instead of tabs
-
-version 0.6 [May 1, 1995]
- first beta release
- added png_large_malloc() and png_large_free()
- added png_size_t
- cleaned up some compiler warnings
- added png_start_read_image()
-
-version 0.7 [June 24, 1995]
- cleaned up lots of bugs
- finished dithering and other stuff
- added test program
- changed name from pnglib to libpng
-
-version 0.71 [June 26, 1995]
- changed pngtest.png for zlib 0.93
- fixed error in libpng.txt and example.c
-
-version 0.8 [August 20, 1995]
- cleaned up some bugs
- added png_set_filler()
- split up pngstub.c into pngmem.c, pngio.c, and pngerror.c
- added #define's to remove unwanted code
- moved png_info_init() to png.c
- added old_size into png_realloc()
- added functions to manually set filtering and compression info
- changed compression parameters based on image type
- optimized filter selection code
- added version info
- changed external functions passing floats to doubles (k&r problems?)
- put all the configurable stuff in pngconf.h
- enabled png_set_shift to work with paletted images on read
- added png_read_update_info() - updates info structure with transformations
-
-Version 0.81 [August, 1995]
- incorporated Tim Wegner's medium model code (thanks, Tim)
-
-Version 0.82 [September, 1995]
- [unspecified changes]
-
-Version 0.85 [December, 1995]
- added more medium model code (almost everything's a far)
- added i/o, error, and memory callback functions
- fixed some bugs (16-bit, 4-bit interlaced, etc.)
- added first run progressive reader (barely tested)
-
-Version 0.86 [January, 1996]
- fixed bugs
- improved documentation
-
-Version 0.87 [January, 1996]
- fixed medium model bugs
- fixed other bugs introduced in 0.85 and 0.86
- added some minor documentation
-
-Version 0.88 [January, 1996]
- fixed progressive bugs
- replaced tabs with spaces
- cleaned up documentation
- added callbacks for read/write and warning/error functions
-
-Version 0.89 [June 5, 1996]
- Added new initialization API to make libpng work better with shared libs
- we now have png_create_read_struct(), png_create_write_struct(),
- png_create_info_struct(), png_destroy_read_struct(), and
- png_destroy_write_struct() instead of the separate calls to
- malloc and png_read_init(), png_info_init(), and png_write_init()
- Changed warning/error callback functions to fix bug - this means you
- should use the new initialization API if you were using the old
- png_set_message_fn() calls, and that the old API no longer exists
- so that people are aware that they need to change their code
- Changed filter selection API to allow selection of multiple filters
- since it didn't work in previous versions of libpng anyways
- Optimized filter selection code
- Fixed png_set_background() to allow using an arbitrary RGB color for
- paletted images
- Fixed gamma and background correction for paletted images, so
- png_correct_palette is not needed unless you are correcting an
- external palette (you will need to #define PNG_CORRECT_PALETTE_SUPPORTED
- in pngconf.h) - if nobody uses this, it may disappear in the future.
- Fixed bug with Borland 64K memory allocation (Alexander Lehmann)
- Fixed bug in interlace handling (Smarasderagd, I think)
- Added more error checking for writing and image to reduce invalid files
- Separated read and write functions so that they won't both be linked
- into a binary when only reading or writing functionality is used
- New pngtest image also has interlacing and zTXt
- Updated documentation to reflect new API
-
-Version 0.89c [June 17, 1996]
- Bug fixes.
-
-Version 0.90 [January, 1997]
- Made CRC errors/warnings on critical and ancillary chunks configurable
- libpng will use the zlib CRC routines by (compile-time) default
- Changed DOS small/medium model memory support - needs zlib 1.04 (Tim Wegner)
- Added external C++ wrapper statements to png.h (Gilles Dauphin)
- Allow PNG file to be read when some or all of file signature has already
- been read from the beginning of the stream. ****This affects the size
- of info_struct and invalidates all programs that use a shared libpng****
- Fixed png_filler() declarations
- Fixed? background color conversions
- Fixed order of error function pointers to match documentation
- Current chunk name is now available in png_struct to reduce the number
- of nearly identical error messages (will simplify multi-lingual
- support when available)
- Try to get ready for unknown-chunk callback functions:
- - previously read critical chunks are flagged, so the chunk handling
- routines can determine if the chunk is in the right place
- - all chunk handling routines have the same prototypes, so we will
- be able to handle all chunks via a callback mechanism
- Try to fix Linux "setjmp" buffer size problems
- Removed png_large_malloc, png_large_free, and png_realloc functions.
-
-Version 0.95 [March, 1997]
- Fixed bug in pngwutil.c allocating "up_row" twice and "avg_row" never
- Fixed bug in PNG file signature compares when start != 0
- Changed parameter type of png_set_filler(...filler...) from png_byte
- to png_uint_32
- Added test for MACOS to ensure that both math.h and fp.h are not #included
- Added macros for libpng to be compiled as a Windows DLL (Andreas Kupries)
- Added "packswap" transformation, which changes the endianness of
- packed-pixel bytes (Kevin Bracey)
- Added "strip_alpha" transformation, which removes the alpha channel of
- input images without using it (not necessarily a good idea)
- Added "swap_alpha" transformation, which puts the alpha channel in front
- of the color bytes instead of after
- Removed all implicit variable tests which assume NULL == 0 (I think)
- Changed several variables to "png_size_t" to show 16/32-bit limitations
- Added new pCAL chunk read/write support
- Added experimental filter selection weighting (Greg Roelofs)
- Removed old png_set_rgbx() and png_set_xrgb() functions that have been
- obsolete for about 2 years now (use png_set_filler() instead)
- Added macros to read 16- and 32-bit ints directly from buffer, to be
- used only on those systems that support it (namely PowerPC and 680x0)
- With some testing, this may become the default for MACOS/PPC systems.
- Only calculate CRC on data if we are going to use it
- Added macros for zTXt compression type PNG_zTXt_COMPRESSION_???
- Added macros for simple libpng debugging output selectable at compile time
- Removed PNG_READ_END_MODE in progressive reader (Smarasderagd)
- More description of info_struct in libpng.txt and png.h
- More instructions in example.c
- More chunk types tested in pngtest.c
- Renamed pngrcb.c to pngset.c, and all png_read_<chunk> functions to be
- png_set_<chunk>. We now have corresponding png_get_<chunk>
- functions in pngget.c to get information in info_ptr. This isolates
- the application from the internal organization of png_info_struct
- (good for shared library implementations).
-
-Version 0.96 [May, 1997]
- Fixed serious bug with < 8bpp images introduced in 0.95
- Fixed 256-color transparency bug (Greg Roelofs)
- Fixed up documentation (Greg Roelofs, Laszlo Nyul)
- Fixed "error" in pngconf.h for Linux setjmp() behavior
- Fixed DOS medium model support (Tim Wegner)
- Fixed png_check_keyword() for case with error in static string text
- Added read of CRC after IEND chunk for embedded PNGs (Laszlo Nyul)
- Added typecasts to quiet compiler errors
- Added more debugging info
-
-Version 0.97 [January, 1998]
- Removed PNG_USE_OWN_CRC capability
- Relocated png_set_crc_action from pngrutil.c to pngrtran.c
- Fixed typecasts of "new_key", etc. (Andreas Dilger)
- Added RFC 1152 [sic] date support
- Fixed bug in gamma handling of 4-bit grayscale
- Added 2-bit grayscale gamma handling (Glenn R-P)
- Added more typecasts. 65536L becomes (png_uint_32)65536L, etc. (Glenn R-P)
- Minor corrections in libpng.txt
- Added simple sRGB support (Glenn R-P)
- Easier conditional compiling, e.g.,
- define PNG_READ/WRITE_NOT_FULLY_SUPPORTED;
- all configurable options can be selected from command line instead
- of having to edit pngconf.h (Glenn R-P)
- Fixed memory leak in pngwrite.c (free info_ptr->text) (Glenn R-P)
- Added more conditions for png_do_background, to avoid changing
- black pixels to background when a background is supplied and
- no pixels are transparent
- Repaired PNG_NO_STDIO behavior
- Tested NODIV support and made it default behavior (Greg Roelofs)
- Added "-m" option and PNGTEST_DEBUG_MEMORY to pngtest (John Bowler)
- Regularized version numbering scheme and bumped shared-library major
- version number to 2 to avoid problems with libpng 0.89 apps
- (Greg Roelofs)
-
-Version 0.98 [January, 1998]
- Cleaned up some typos in libpng.txt and in code documentation
- Fixed memory leaks in pCAL chunk processing (Glenn R-P and John Bowler)
- Cosmetic change "display_gamma" to "screen_gamma" in pngrtran.c
- Changed recommendation about file_gamma for PC images to .51 from .45,
- in example.c and libpng.txt, added comments to distinguish between
- screen_gamma, viewing_gamma, and display_gamma.
- Changed all references to RFC1152 to read RFC1123 and changed the
- PNG_TIME_RFC1152_SUPPORTED macro to PNG_TIME_RFC1123_SUPPORTED
- Added png_invert_alpha capability (Glenn R-P -- suggestion by Jon Vincent)
- Changed srgb_intent from png_byte to int to avoid compiler bugs
-
-Version 0.99 [January 30, 1998]
- Free info_ptr->text instead of end_info_ptr->text in pngread.c (John Bowler)
- Fixed a longstanding "packswap" bug in pngtrans.c
- Fixed some inconsistencies in pngconf.h that prevented compiling with
- PNG_READ_GAMMA_SUPPORTED and PNG_READ_hIST_SUPPORTED undefined
- Fixed some typos and made other minor rearrangement of libpng.txt (Andreas)
- Changed recommendation about file_gamma for PC images to .50 from .51 in
- example.c and libpng.txt, and changed file_gamma for sRGB images to .45
- Added a number of functions to access information from the png structure
- png_get_image_height(), etc. (Glenn R-P, suggestion by Brad Pettit)
- Added TARGET_MACOS similar to zlib-1.0.8
- Define PNG_ALWAYS_EXTERN when __MWERKS__ && WIN32 are defined
- Added type casting to all png_malloc() function calls
-
-Version 0.99a [January 31, 1998]
- Added type casts and parentheses to all returns that return a value.(Tim W.)
-
-Version 0.99b [February 4, 1998]
- Added type cast png_uint_32 on malloc function calls where needed.
- Changed type of num_hist from png_uint_32 to int (same as num_palette).
- Added checks for rowbytes overflow, in case png_size_t is less than 32 bits.
- Renamed makefile.elf to makefile.lnx.
-
-Version 0.99c [February 7, 1998]
- More type casting. Removed erroneous overflow test in pngmem.c.
- Added png_buffered_memcpy() and png_buffered_memset(), apply them to rowbytes.
- Added UNIX manual pages libpng.3 (incorporating libpng.txt) and png.5.
-
-Version 0.99d [February 11, 1998]
- Renamed "far_to_near()" "png_far_to_near()"
- Revised libpng.3
- Version 99c "buffered" operations didn't work as intended. Replaced them
- with png_memcpy_check() and png_memset_check().
- Added many "if (png_ptr == NULL) return" to quell compiler warnings about
- unused png_ptr, mostly in pngget.c and pngset.c.
- Check for overlength tRNS chunk present when indexed-color PLTE is read.
- Cleaned up spelling errors in libpng.3/libpng.txt
- Corrected a problem with png_get_tRNS() which returned undefined trans array
-
-Version 0.99e [February 28, 1998]
- Corrected png_get_tRNS() again.
- Add parentheses for easier reading of pngget.c, fixed "||" should be "&&".
- Touched up example.c to make more of it compileable, although the entire
- file still can't be compiled (Willem van Schaik)
- Fixed a bug in png_do_shift() (Bryan Tsai)
- Added a space in png.h prototype for png_write_chunk_start()
- Replaced pngtest.png with one created with zlib 1.1.1
- Changed pngtest to report PASS even when file size is different (Jean-loup G.)
- Corrected some logic errors in png_do_invert_alpha() (Chris Patterson)
-
-Version 0.99f [March 5, 1998]
- Corrected a bug in pngpread() introduced in version 99c (Kevin Bracey)
- Moved makefiles into a "scripts" directory, and added INSTALL instruction file
- Added makefile.os2 and pngos2.def (A. Zabolotny) and makefile.s2x (W. Sebok)
- Added pointers to "note on libpng versions" in makefile.lnx and README
- Added row callback feature when reading and writing nonprogressive rows
- and added a test of this feature in pngtest.c
- Added user transform callbacks, with test of the feature in pngtest.c
-
-Version 0.99g [March 6, 1998, morning]
- Minor changes to pngtest.c to suppress compiler warnings.
- Removed "beta" language from documentation.
-
-Version 0.99h [March 6, 1998, evening]
- Minor changes to previous minor changes to pngtest.c
- Changed PNG_READ_NOT_FULLY_SUPPORTED to PNG_READ_TRANSFORMS_NOT_SUPPORTED
- and added PNG_PROGRESSIVE_READ_NOT_SUPPORTED macro
- Added user transform capability
-
-Version 1.00 [March 7, 1998]
- Changed several typedefs in pngrutil.c
- Added makefile.wat (Pawel Mrochen), updated makefile.tc3 (Willem van Schaik)
- Replaced "while(1)" with "for(;;)"
- Added PNGARG() to prototypes in pngtest.c and removed some prototypes
- Updated some of the makefiles (Tom Lane)
- Changed some typedefs (s_start, etc.) in pngrutil.c
- Fixed dimensions of "short_months" array in pngwrite.c
- Replaced ansi2knr.c with the one from jpeg-v6
-
-Version 1.0.0 [March 8, 1998]
- Changed name from 1.00 to 1.0.0 (Adam Costello)
- Added smakefile.ppc (with SCOPTIONS.ppc) for Amiga PPC (Andreas Kleinert)
-
-Version 1.0.0a [March 9, 1998]
- Fixed three bugs in pngrtran.c to make gamma+background handling consistent
- (Greg Roelofs)
- Changed format of the PNG_LIBPNG_VER integer to xyyzz instead of xyz
- for major, minor, and bugfix releases. This is 10001. (Adam Costello,
- Tom Lane)
- Make months range from 1-12 in png_convert_to_rfc1123
-
-Version 1.0.0b [March 13, 1998]
- Quieted compiler complaints about two empty "for" loops in pngrutil.c
- Minor changes to makefile.s2x
- Removed #ifdef/#endif around a png_free() in pngread.c
-
-Version 1.0.1 [March 14, 1998]
- Changed makefile.s2x to reduce security risk of using a relative pathname
- Fixed some typos in the documentation (Greg).
- Fixed a problem with value of "channels" returned by png_read_update_info()
-
-Version 1.0.1a [April 21, 1998]
- Optimized Paeth calculations by replacing abs() function calls with intrinsics
- plus other loop optimizations. Improves avg decoding speed by about 20%.
- Commented out i386istic "align" compiler flags in makefile.lnx.
- Reduced the default warning level in some makefiles, to make them consistent.
- Removed references to IJG and JPEG in the ansi2knr.c copyright statement.
- Fixed a bug in png_do_strip_filler with XXRRGGBB => RRGGBB transformation.
- Added grayscale and 16-bit capability to png_do_read_filler().
- Fixed a bug in pngset.c, introduced in version 0.99c, that sets rowbytes
- too large when writing an image with bit_depth < 8 (Bob Dellaca).
- Corrected some bugs in the experimental weighted filtering heuristics.
- Moved a misplaced pngrutil code block that truncates tRNS if it has more
- than num_palette entries -- test was done before num_palette was defined.
- Fixed a png_convert_to_rfc1123() bug that converts day 31 to 0 (Steve Eddins).
- Changed compiler flags in makefile.wat for better optimization
- (Pawel Mrochen).
-
-Version 1.0.1b [May 2, 1998]
- Relocated png_do_gray_to_rgb() within png_do_read_transformations() (Greg).
- Relocated the png_composite macros from pngrtran.c to png.h (Greg).
- Added makefile.sco (contributed by Mike Hopkirk).
- Fixed two bugs (missing definitions of "istop") introduced in libpng-1.0.1a.
- Fixed a bug in pngrtran.c that would set channels=5 under some circumstances.
- More work on the Paeth-filtering, achieving imperceptible speedup
- (A Kleinert).
- More work on loop optimization which may help when compiled with C++
- compilers.
- Added warnings when people try to use transforms they've defined out.
- Collapsed 4 "i" and "c" loops into single "i" loops in pngrtran and pngwtran.
- Revised paragraph about png_set_expand() in libpng.txt and libpng.3 (Greg)
-
-Version 1.0.1c [May 11, 1998]
- Fixed a bug in pngrtran.c (introduced in libpng-1.0.1a) where the masks for
- filler bytes should have been 0xff instead of 0xf.
- Added max_pixel_depth=32 in pngrutil.c when using FILLER with palette images.
- Moved PNG_WRITE_WEIGHTED_FILTER_SUPPORTED and PNG_WRITE_FLUSH_SUPPORTED
- out of the PNG_WRITE_TRANSFORMS_NOT_SUPPORTED block of pngconf.h
- Added "PNG_NO_WRITE_TRANSFORMS" etc., as alternatives for *_NOT_SUPPORTED,
- for consistency, in pngconf.h
- Added individual "ifndef PNG_NO_[CAPABILITY]" in pngconf.h to make it easier
- to remove unwanted capabilities via the compile line
- Made some corrections to grammar (which, it's) in documentation (Greg).
- Corrected example.c, use of row_pointers in png_write_image().
-
-Version 1.0.1d [May 24, 1998]
- Corrected several statements that used side effects illegally in pngrutil.c
- and pngtrans.c, that were introduced in version 1.0.1b
- Revised png_read_rows() to avoid repeated if-testing for NULL (A Kleinert)
- More corrections to example.c, use of row_pointers in png_write_image()
- and png_read_rows().
- Added pngdll.mak and pngdef.pas to scripts directory, contributed by
- Bob Dellaca, to make a png32bd.dll with Borland C++ 4.5
- Fixed error in example.c with png_set_text: num_text is 3, not 2 (Guido V.)
- Changed several loops from count-down to count-up, for consistency.
-
-Version 1.0.1e [June 6, 1998]
- Revised libpng.txt and libpng.3 description of png_set_read|write_fn(), and
- added warnings when people try to set png_read_fn and png_write_fn in
- the same structure.
- Added a test such that png_do_gamma will be done when num_trans==0
- for truecolor images that have defined a background. This corrects an
- error that was introduced in libpng-0.90 that can cause gamma processing
- to be skipped.
- Added tests in png.h to include "trans" and "trans_values" in structures
- when PNG_READ_BACKGROUND_SUPPORTED or PNG_READ_EXPAND_SUPPORTED is defined.
- Add png_free(png_ptr->time_buffer) in png_destroy_read_struct()
- Moved png_convert_to_rfc_1123() from pngwrite.c to png.c
- Added capability for user-provided malloc_fn() and free_fn() functions,
- and revised pngtest.c to demonstrate their use, replacing the
- PNGTEST_DEBUG_MEM feature.
- Added makefile.w32, for Microsoft C++ 4.0 and later (Tim Wegner).
-
-Version 1.0.2 [June 14, 1998]
- Fixed two bugs in makefile.bor .
-
-Version 1.0.2a [December 30, 1998]
- Replaced and extended code that was removed from png_set_filler() in 1.0.1a.
- Fixed a bug in png_do_filler() that made it fail to write filler bytes in
- the left-most pixel of each row (Kevin Bracey).
- Changed "static pngcharp tIME_string" to "static char tIME_string[30]"
- in pngtest.c (Duncan Simpson).
- Fixed a bug in pngtest.c that caused pngtest to try to write a tIME chunk
- even when no tIME chunk was present in the source file.
- Fixed a problem in pngrutil.c: gray_to_rgb didn't always work with 16-bit.
- Fixed a problem in png_read_push_finish_row(), which would not skip some
- passes that it should skip, for images that are less than 3 pixels high.
- Interchanged the order of calls to png_do_swap() and png_do_shift()
- in pngwtran.c (John Cromer).
- Added #ifdef PNG_DEBUG/#endif surrounding use of PNG_DEBUG in png.h .
- Changed "bad adaptive filter type" from error to warning in pngrutil.c .
- Fixed a documentation error about default filtering with 8-bit indexed-color.
- Separated the PNG_NO_STDIO macro into PNG_NO_STDIO and PNG_NO_CONSOLE_IO
- (L. Peter Deutsch).
- Added png_set_rgb_to_gray() and png_get_rgb_to_gray_status() functions.
- Added png_get_copyright() and png_get_header_version() functions.
- Revised comments on png_set_progressive_read_fn() in libpng.txt and example.c
- Added information about debugging in libpng.txt and libpng.3 .
- Changed "ln -sf" to "ln -s -f" in makefile.s2x, makefile.lnx, and
- makefile.sco.
- Removed lines after Dynamic Dependencies" in makefile.aco .
- Revised makefile.dec to make a shared library (Jeremie Petit).
- Removed trailing blanks from all files.
-
-Version 1.0.2a [January 6, 1999]
- Removed misplaced #endif and #ifdef PNG_NO_EXTERN near the end of png.h
- Added "if" tests to silence complaints about unused png_ptr in png.h and png.c
- Changed "check_if_png" function in example.c to return true (nonzero) if PNG.
- Changed libpng.txt to demonstrate png_sig_cmp() instead of png_check_sig()
- which is obsolete.
-
-Version 1.0.3 [January 14, 1999]
- Added makefile.hux, for Hewlett Packard HPUX 10.20 and 11.00 (Jim Rice)
- Added a statement of Y2K compliance in png.h, libpng.3, and Y2KINFO.
-
-Version 1.0.3a [August 12, 1999]
- Added check for PNG_READ_INTERLACE_SUPPORTED in pngread.c; issue a warning
- if an attempt is made to read an interlaced image when it's not supported.
- Added check if png_ptr->trans is defined before freeing it in pngread.c
- Modified the Y2K statement to include versions back to version 0.71
- Fixed a bug in the check for valid IHDR bit_depth/color_types in pngrutil.c
- Modified makefile.wat (added -zp8 flag, ".symbolic", changed some comments)
- Replaced leading blanks with tab characters in makefile.hux
- Changed "dworkin.wustl.edu" to "ccrc.wustl.edu" in various documents.
- Changed (float)red and (float)green to (double)red, (double)green
- in png_set_rgb_to_gray() to avoid "promotion" problems in AIX.
- Fixed a bug in pngconf.h that omitted <stdio.h> when PNG_DEBUG==0 (K Bracey).
- Reformatted libpng.3 and libpngpf.3 with proper fonts (script by J. vanZandt).
- Updated documentation to refer to the PNG-1.2 specification.
- Removed ansi2knr.c and left pointers to the latest source for ansi2knr.c
- in makefile.knr, INSTALL, and README (L. Peter Deutsch)
- Fixed bugs in calculation of the length of rowbytes when adding alpha
- channels to 16-bit images, in pngrtran.c (Chris Nokleberg)
- Added function png_set_user_transform_info() to store user_transform_ptr,
- user_depth, and user_channels into the png_struct, and a function
- png_get_user_transform_ptr() to retrieve the pointer (Chris Nokleberg)
- Added function png_set_empty_plte_permitted() to make libpng useable
- in MNG applications.
- Corrected the typedef for png_free_ptr in png.h (Jesse Jones).
- Correct gamma with srgb is 45455 instead of 45000 in pngrutil.c, to be
- consistent with PNG-1.2, and allow variance of 500 before complaining.
- Added assembler code contributed by Intel in file pngvcrd.c and modified
- makefile.w32 to use it (Nirav Chhatrapati, INTEL Corporation,
- Gilles Vollant)
- Changed "ln -s -f" to "ln -f -s" in the makefiles to make Solaris happy.
- Added some aliases for png_set_expand() in pngrtran.c, namely
- png_set_expand_PLTE(), png_set_expand_depth(), and png_set_expand_tRNS()
- (Greg Roelofs, in "PNG: The Definitive Guide").
- Added makefile.beo for BEOS on X86, contributed by Sander Stok.
-
-Version 1.0.3b [August 26, 1999]
- Replaced 2147483647L several places with PNG_MAX_UINT macro, defined in png.h
- Changed leading blanks to tabs in all makefiles.
- Define PNG_USE_PNGVCRD in makefile.w32, to get MMX assembler code.
- Made alternate versions of png_set_expand() in pngrtran.c, namely
- png_set_gray_1_2_4_to_8, png_set_palette_to_rgb, and png_set_tRNS_to_alpha
- (Greg Roelofs, in "PNG: The Definitive Guide"). Deleted the 1.0.3a aliases.
- Relocated start of 'extern "C"' block in png.h so it doesn't include pngconf.h
- Revised calculation of num_blocks in pngmem.c to avoid a potentially
- negative shift distance, whose results are undefined in the C language.
- Added a check in pngset.c to prevent writing multiple tIME chunks.
- Added a check in pngwrite.c to detect invalid small window_bits sizes.
-
-Version 1.0.3d [September 4, 1999]
- Fixed type casting of igamma in pngrutil.c
- Added new png_expand functions to scripts/pngdef.pas and pngos2.def
- Added a demo read_user_transform_fn that examines the row filters in pngtest.c
-
-Version 1.0.4 [September 24, 1999, not distributed publicly]
- Define PNG_ALWAYS_EXTERN in pngconf.h if __STDC__ is defined
- Delete #define PNG_INTERNAL and include "png.h" from pngasmrd.h
- Made several minor corrections to pngtest.c
- Renamed the makefiles with longer but more user friendly extensions.
- Copied the PNG copyright and license to a separate LICENSE file.
- Revised documentation, png.h, and example.c to remove reference to
- "viewing_gamma" which no longer appears in the PNG specification.
- Revised pngvcrd.c to use MMX code for interlacing only on the final pass.
- Updated pngvcrd.c to use the faster C filter algorithms from libpng-1.0.1a
- Split makefile.win32vc into two versions, makefile.vcawin32 (uses MMX
- assembler code) and makefile.vcwin32 (doesn't).
- Added a CPU timing report to pngtest.c (enabled by defining PNGTEST_TIMING)
- Added a copy of pngnow.png to the distribution.
-
-Version 1.0.4a [September 25, 1999]
- Increase max_pixel_depth in pngrutil.c if a user transform needs it.
- Changed several division operations to right-shifts in pngvcrd.c
-
-Version 1.0.4b [September 30, 1999]
- Added parentheses in line 3732 of pngvcrd.c
- Added a comment in makefile.linux warning about buggy -O3 in pgcc 2.95.1
-
-Version 1.0.4c [October 1, 1999]
- Added a "png_check_version" function in png.c and pngtest.c that will generate
- a helpful compiler error if an old png.h is found in the search path.
- Changed type of png_user_transform_depth|channels from int to png_byte.
- Added "Libpng is OSI Certified Open Source Software" statement to png.h
-
-Version 1.0.4d [October 6, 1999]
- Changed 0.45 to 0.45455 in png_set_sRGB()
- Removed unused PLTE entries from pngnow.png
- Re-enabled some parts of pngvcrd.c (png_combine_row) that work properly.
-
-Version 1.0.4e [October 10, 1999]
- Fixed sign error in pngvcrd.c (Greg Roelofs)
- Replaced some instances of memcpy with simple assignments in pngvcrd (GR-P)
-
-Version 1.0.4f [October 15, 1999]
- Surrounded example.c code with #if 0 .. #endif to prevent people from
- inadvertently trying to compile it.
- Changed png_get_header_version() from a function to a macro in png.h
- Added type casting mostly in pngrtran.c and pngwtran.c
- Removed some pointless "ptr = NULL" in pngmem.c
- Added a "contrib" directory containing the source code from Greg's book.
-
-Version 1.0.5 [October 15, 1999]
- Minor editing of the INSTALL and README files.
-
-Version 1.0.5a [October 23, 1999]
- Added contrib/pngsuite and contrib/pngminus (Willem van Schaik)
- Fixed a typo in the png_set_sRGB() function call in example.c (Jan Nijtmans)
- Further optimization and bugfix of pngvcrd.c
- Revised pngset.c so that it does not allocate or free memory in the user's
- text_ptr structure. Instead, it makes its own copy.
- Created separate write_end_info_struct in pngtest.c for a more severe test.
- Added code in pngwrite.c to free info_ptr->text[i].key to stop a memory leak.
-
-Version 1.0.5b [November 23, 1999]
- Moved PNG_FLAG_HAVE_CHUNK_HEADER, PNG_FLAG_BACKGROUND_IS_GRAY and
- PNG_FLAG_WROTE_tIME from flags to mode.
- Added png_write_info_before_PLTE() function.
- Fixed some typecasting in contrib/gregbook/*.c
- Updated scripts/makevms.com and added makevms.com to contrib/gregbook
- and contrib/pngminus (Martin Zinser)
-
-Version 1.0.5c [November 26, 1999]
- Moved png_get_header_version from png.h to png.c, to accommodate ansi2knr.
- Removed all global arrays (according to PNG_NO_GLOBAL_ARRAYS macro), to
- accommodate making DLL's: Moved usr_png_ver from global variable to function
- png_get_header_ver() in png.c. Moved png_sig to png_sig_bytes in png.c and
- eliminated use of png_sig in pngwutil.c. Moved the various png_CHNK arrays
- into pngtypes.h. Eliminated use of global png_pass arrays. Declared the
- png_CHNK and png_pass arrays to be "const". Made the global arrays
- available to applications (although none are used in libpng itself) when
- PNG_NO_GLOBAL_ARRAYS is not defined or when PNG_GLOBAL_ARRAYS is defined.
- Removed some extraneous "-I" from contrib/pngminus/makefile.std
- Changed the PNG_sRGB_INTENT macros in png.h to be consistent with PNG-1.2.
- Change PNG_SRGB_INTENT to PNG_sRGB_INTENT in libpng.txt and libpng.3
-
-Version 1.0.5d [November 29, 1999]
- Add type cast (png_const_charp) two places in png.c
- Eliminated pngtypes.h; use macros instead to declare PNG_CHNK arrays.
- Renamed "PNG_GLOBAL_ARRAYS" to "PNG_USE_GLOBAL_ARRAYS" and made available
- to applications a macro "PNG_USE_LOCAL_ARRAYS".
- comment out (with #ifdef) all the new declarations when
- PNG_USE_GLOBAL_ARRAYS is defined.
- Added PNG_EXPORT_VAR macro to accommodate making DLL's.
-
-Version 1.0.5e [November 30, 1999]
- Added iCCP, iTXt, and sPLT support; added "lang" member to the png_text
- structure; refactored the inflate/deflate support to make adding new chunks
- with trailing compressed parts easier in the future, and added new functions
- png_free_iCCP, png_free_pCAL, png_free_sPLT, png_free_text, png_get_iCCP,
- png_get_spalettes, png_set_iCCP, png_set_spalettes (Eric S. Raymond).
- NOTE: Applications that write text chunks MUST define png_text->lang
- before calling png_set_text(). It must be set to NULL if you want to
- write tEXt or zTXt chunks. If you want your application to be able to
- run with older versions of libpng, use
-
- #ifdef PNG_iTXt_SUPPORTED
- png_text[i].lang = NULL;
- #endif
-
- Changed png_get_oFFs() and png_set_oFFs() to use signed rather than unsigned
- offsets (Eric S. Raymond).
- Combined PNG_READ_cHNK_SUPPORTED and PNG_WRITE_cHNK_SUPPORTED macros into
- PNG_cHNK_SUPPORTED and combined the three types of PNG_text_SUPPORTED
- macros, leaving the separate macros also available.
- Removed comments on #endifs at the end of many short, non-nested #if-blocks.
-
-Version 1.0.5f [December 6, 1999]
- Changed makefile.solaris to issue a warning about potential problems when
- the ucb "ld" is in the path ahead of the ccs "ld".
- Removed "- [date]" from the "synopsis" line in libpng.3 and libpngpf.3.
- Added sCAL chunk support (Eric S. Raymond).
-
-Version 1.0.5g [December 7, 1999]
- Fixed "png_free_spallettes" typo in png.h
- Added code to handle new chunks in pngpread.c
- Moved PNG_CHNK string macro definitions outside of PNG_NO_EXTERN block
- Added "translated_key" to png_text structure and png_write_iTXt().
- Added code in pngwrite.c to work around a newly discovered zlib bug.
-
-Version 1.0.5h [December 10, 1999]
- NOTE: regarding the note for version 1.0.5e, the following must also
- be included in your code:
- png_text[i].translated_key = NULL;
- Unknown chunk handling is now supported.
- Option to eliminate all floating point support was added. Some new
- fixed-point functions such as png_set_gAMA_fixed() were added.
- Expanded tabs and removed trailing blanks in source files.
-
-Version 1.0.5i [December 13, 1999]
- Added some type casts to silence compiler warnings.
- Renamed "png_free_spalette" to "png_free_spalettes" for consistency.
- Removed leading blanks from a #define in pngvcrd.c
- Added some parameters to the new png_set_keep_unknown_chunks() function.
- Added a test for up->location != 0 in the first instance of writing
- unknown chunks in pngwrite.c
- Changed "num" to "i" in png_free_spalettes() and png_free_unknowns() to
- prevent recursion.
- Added png_free_hIST() function.
- Various patches to fix bugs in the sCAL and integer cHRM processing,
- and to add some convenience macros for use with sCAL.
-
-Version 1.0.5j [December 21, 1999]
- Changed "unit" parameter of png_write_sCAL from png_byte to int, to work
- around buggy compilers.
- Added new type "png_fixed_point" for integers that hold float*100000 values
- Restored backward compatibility of tEXt/zTXt chunk processing:
- Restored the first four members of png_text to the same order as v.1.0.5d.
- Added members "lang_key" and "itxt_length" to png_text struct. Set
- text_length=0 when "text" contains iTXt data. Use the "compression"
- member to distinguish among tEXt/zTXt/iTXt types. Added
- PNG_ITXT_COMPRESSION_NONE (1) and PNG_ITXT_COMPRESSION_zTXt(2) macros.
- The "Note" above, about backward incompatibility of libpng-1.0.5e, no
- longer applies.
- Fixed png_read|write_iTXt() to read|write parameters in the right order,
- and to write the iTXt chunk after IDAT if it appears in the end_ptr.
- Added pnggccrd.c, version of pngvcrd.c Intel assembler for gcc (Greg Roelofs)
- Reversed the order of trying to write floating-point and fixed-point gAMA.
-
-Version 1.0.5k [December 27, 1999]
- Added many parentheses, e.g., "if (a && b & c)" becomes "if (a && (b & c))"
- Added png_handle_as_unknown() function (Glenn)
- Added png_free_chunk_list() function and chunk_list and num_chunk_list members
- of png_ptr.
- Eliminated erroneous warnings about multiple sPLT chunks and sPLT-after-PLTE.
- Fixed a libpng-1.0.5h bug in pngrutil.c that was issuing erroneous warnings
- about ignoring incorrect gAMA with sRGB (gAMA was in fact not ignored)
- Added png_free_tRNS(); png_set_tRNS() now malloc's its own trans array (ESR).
- Define png_get_int_32 when oFFs chunk is supported as well as when pCAL is.
- Changed type of proflen from png_int_32 to png_uint_32 in png_get_iCCP().
-
-Version 1.0.5l [January 1, 2000]
- Added functions png_set_read_user_chunk_fn() and png_get_user_chunk_ptr()
- for setting a callback function to handle unknown chunks and for
- retrieving the associated user pointer (Glenn).
-
-Version 1.0.5m [January 7, 2000]
- Added high-level functions png_read_png(), png_write_png(), png_free_pixels().
-
-Version 1.0.5n [January 9, 2000]
- Added png_free_PLTE() function, and modified png_set_PLTE() to malloc its
- own memory for info_ptr->palette. This makes it safe for the calling
- application to free its copy of the palette any time after it calls
- png_set_PLTE().
-
-Version 1.0.5o [January 20, 2000]
- Cosmetic changes only (removed some trailing blanks and TABs)
-
-Version 1.0.5p [January 31, 2000]
- Renamed pngdll.mak to makefile.bd32
- Cosmetic changes in pngtest.c
-
-Version 1.0.5q [February 5, 2000]
- Relocated the makefile.solaris warning about PATH problems.
- Fixed pngvcrd.c bug by pushing/popping registers in mmxsupport (Bruce Oberg)
- Revised makefile.gcmmx
- Added PNG_SETJMP_SUPPORTED, PNG_SETJMP_NOT_SUPPORTED, and PNG_ABORT() macros
-
-Version 1.0.5r [February 7, 2000]
- Removed superfluous prototype for png_get_itxt from png.h
- Fixed a bug in pngrtran.c that improperly expanded the background color.
- Return *num_text=0 from png_get_text() when appropriate, and fix documentation
- of png_get_text() in libpng.txt/libpng.3.
-
-Version 1.0.5s [February 18, 2000]
- Added "png_jmp_env()" macro to pngconf.h, to help people migrate to the
- new error handler that's planned for the next libpng release, and changed
- example.c, pngtest.c, and contrib programs to use this macro.
- Revised some of the DLL-export macros in pngconf.h (Greg Roelofs)
- Fixed a bug in png_read_png() that caused it to fail to expand some images
- that it should have expanded.
- Fixed some mistakes in the unused and undocumented INCH_CONVERSIONS functions
- in pngget.c
- Changed the allocation of palette, history, and trans arrays back to
- the version 1.0.5 method (linking instead of copying) which restores
- backward compatibility with version 1.0.5. Added some remarks about
- that in example.c. Added "free_me" member to info_ptr and png_ptr
- and added png_free_data() function.
- Updated makefile.linux and makefile.gccmmx to make directories conditionally.
- Made cosmetic changes to pngasmrd.h
- Added png_set_rows() and png_get_rows(), for use with png_read|write_png().
- Modified png_read_png() to allocate info_ptr->row_pointers only if it
- hasn't already been allocated.
-
-Version 1.0.5t [March 4, 2000]
- Changed png_jmp_env() migration aiding macro to png_jmpbuf().
- Fixed "interlace" typo (should be "interlaced") in contrib/gregbook/read2-x.c
- Fixed bug with use of PNG_BEFORE_IHDR bit in png_ptr->mode, introduced when
- PNG_FLAG_HAVE_CHUNK_HEADER was moved into png_ptr->mode in version 1.0.5b
- Files in contrib/gregbook were revised to use png_jmpbuf() and to select
- a 24-bit visual if one is available, and to allow abbreviated options.
- Files in contrib/pngminus were revised to use the png_jmpbuf() macro.
- Removed spaces in makefile.linux and makefile.gcmmx, introduced in 1.0.5s
-
-Version 1.0.5u [March 5, 2000]
- Simplified the code that detects old png.h in png.c and pngtest.c
- Renamed png_spalette (_p, _pp) to png_sPLT_t (_tp, _tpp)
- Increased precision of rgb_to_gray calculations from 8 to 15 bits and
- added png_set_rgb_to_gray_fixed() function.
- Added makefile.bc32 (32-bit Borland C++, C mode)
-
-Version 1.0.5v [March 11, 2000]
- Added some parentheses to the png_jmpbuf macro definition.
- Updated references to the zlib home page, which has moved to freesoftware.com.
- Corrected bugs in documentation regarding png_read_row() and png_write_row().
- Updated documentation of png_rgb_to_gray calculations in libpng.3/libpng.txt.
- Renamed makefile.borland,turboc3 back to makefile.bor,tc3 as in version 1.0.3,
- revised borland makefiles; added makefile.ibmvac3 and makefile.gcc (Cosmin)
-
-Version 1.0.6 [March 20, 2000]
- Minor revisions of makefile.bor, libpng.txt, and gregbook/rpng2-win.c
- Added makefile.sggcc (SGI IRIX with gcc)
-
-Version 1.0.6d [April 7, 2000]
- Changed sprintf() to strcpy() in png_write_sCAL_s() to work without STDIO
- Added data_length parameter to png_decompress_chunk() function
- Revised documentation to remove reference to abandoned png_free_chnk functions
- Fixed an error in png_rgb_to_gray_fixed()
- Revised example.c, usage of png_destroy_write_struct().
- Renamed makefile.ibmvac3 to makefile.ibmc, added libpng.icc IBM project file
- Added a check for info_ptr->free_me&PNG_FREE_TEXT when freeing text in png.c
- Simplify png_sig_bytes() function to remove use of non-ISO-C strdup().
-
-Version 1.0.6e [April 9, 2000]
- Added png_data_freer() function.
- In the code that checks for over-length tRNS chunks, added check of
- info_ptr->num_trans as well as png_ptr->num_trans (Matthias Benckmann)
- Minor revisions of libpng.txt/libpng.3.
- Check for existing data and free it if the free_me flag is set, in png_set_*()
- and png_handle_*().
- Only define PNG_WEIGHTED_FILTERS_SUPPORTED when PNG_FLOATING_POINT_SUPPORTED
- is defined.
- Changed several instances of PNG_NO_CONSOLE_ID to PNG_NO_STDIO in pngrutil.c
- and mentioned the purposes of the two macros in libpng.txt/libpng.3.
-
-Version 1.0.6f [April 14, 2000]
- Revised png_set_iCCP() and png_set_rows() to avoid prematurely freeing data.
- Add checks in png_set_text() for NULL members of the input text structure.
- Revised libpng.txt/libpng.3.
- Removed superfluous prototype for png_set_iTXt from png.h
- Removed "else" from pngread.c, after png_error(), and changed "0" to "length".
- Changed several png_errors about malformed ancillary chunks to png_warnings.
-
-Version 1.0.6g [April 24, 2000]
- Added png_pass-* arrays to pnggccrd.c when PNG_USE_LOCAL_ARRAYS is defined.
- Relocated paragraph about png_set_background() in libpng.3/libpng.txt
- and other revisions (Matthias Benckmann)
- Relocated info_ptr->free_me, png_ptr->free_me, and other info_ptr and
- png_ptr members to restore binary compatibility with libpng-1.0.5
- (breaks compatibility with libpng-1.0.6).
-
-Version 1.0.6h [April 24, 2000]
- Changed shared library so-number pattern from 2.x.y.z to xy.z (this builds
- libpng.so.10 & libpng.so.10.6h instead of libpng.so.2 & libpng.so.2.1.0.6h)
- This is a temporary change for test purposes.
-
-Version 1.0.6i [May 2, 2000]
- Rearranged some members at the end of png_info and png_struct, to put
- unknown_chunks_num and free_me within the original size of the png_structs
- and free_me, png_read_user_fn, and png_free_fn within the original png_info,
- because some old applications allocate the structs directly instead of
- using png_create_*().
- Added documentation of user memory functions in libpng.txt/libpng.3
- Modified png_read_png so that it will use user_allocated row_pointers
- if present, unless free_me directs that it be freed, and added description
- of the use of png_set_rows() and png_get_rows() in libpng.txt/libpng.3.
- Added PNG_LEGACY_SUPPORTED macro, and #ifdef out all new (since version
- 1.00) members of png_struct and png_info, to regain binary compatibility
- when you define this macro. Capabilities lost in this event
- are user transforms (new in version 1.0.0),the user transform pointer
- (new in version 1.0.2), rgb_to_gray (new in 1.0.5), iCCP, sCAL, sPLT,
- the high-level interface, and unknown chunks support (all new in 1.0.6).
- This was necessary because of old applications that allocate the structs
- directly as authors were instructed to do in libpng-0.88 and earlier,
- instead of using png_create_*().
- Added modes PNG_CREATED_READ_STRUCT and PNG_CREATED_WRITE_STRUCT which
- can be used to detect codes that directly allocate the structs, and
- code to check these modes in png_read_init() and png_write_init() and
- generate a libpng error if the modes aren't set and PNG_LEGACY_SUPPORTED
- was not defined.
- Added makefile.intel and updated makefile.watcom (Pawel Mrochen)
-
-Version 1.0.6j [May 3, 2000]
- Overloaded png_read_init() and png_write_init() with macros that convert
- calls to png_read_init_2() or png_write_init_2() that check the version
- and structure sizes.
-
-Version 1.0.7beta11 [May 7, 2000]
- Removed the new PNG_CREATED_READ_STRUCT and PNG_CREATED_WRITE_STRUCT modes
- which are no longer used.
- Eliminated the three new members of png_text when PNG_LEGACY_SUPPORTED is
- defined or when neither PNG_READ_iTXt_SUPPORTED nor PNG_WRITE_iTXt_SUPPORTED
- is defined.
- Made PNG_NO_READ|WRITE_iTXt the default setting, to avoid memory
- overrun when old applications fill the info_ptr->text structure directly.
- Added PNGAPI macro, and added it to the definitions of all exported functions.
- Relocated version macro definitions ahead of the includes of zlib.h and
- pngconf.h in png.h.
-
-Version 1.0.7beta12 [May 12, 2000]
- Revised pngset.c to avoid a problem with expanding the png_debug macro.
- Deleted some extraneous defines from pngconf.h
- Made PNG_NO_CONSOLE_IO the default condition when PNG_BUILD_DLL is defined.
- Use MSC _RPTn debugging instead of fprintf if _MSC_VER is defined.
- Added png_access_version_number() function.
- Check for mask&PNG_FREE_CHNK (for TEXT, SCAL, PCAL) in png_free_data().
- Expanded libpng.3/libpng.txt information about png_data_freer().
-
-Version 1.0.7beta14 [May 17, 2000] (beta13 was not published)
- Changed pnggccrd.c and pngvcrd.c to handle bad adaptive filter types as
- warnings instead of errors, as pngrutil.c does.
- Set the PNG_INFO_IDAT valid flag in png_set_rows() so png_write_png()
- will actually write IDATs.
- Made the default PNG_USE_LOCAL_ARRAYS depend on PNG_DLL instead of WIN32.
- Make png_free_data() ignore its final parameter except when freeing data
- that can have multiple instances (text, sPLT, unknowns).
- Fixed a new bug in png_set_rows().
- Removed info_ptr->valid tests from png_free_data(), as in version 1.0.5.
- Added png_set_invalid() function.
- Fixed incorrect illustrations of png_destroy_write_struct() in example.c.
-
-Version 1.0.7beta15 [May 30, 2000]
- Revised the deliberately erroneous Linux setjmp code in pngconf.h to produce
- fewer error messages.
- Rearranged checks for Z_OK to check the most likely path first in pngpread.c
- and pngwutil.c.
- Added checks in pngtest.c for png_create_*() returning NULL, and mentioned
- in libpng.txt/libpng.3 the need for applications to check this.
- Changed names of png_default_*() functions in pngtest to pngtest_*().
- Changed return type of png_get_x|y_offset_*() from png_uint_32 to png_int_32.
- Fixed some bugs in the unused PNG_INCH_CONVERSIONS functions in pngget.c
- Set each pointer to NULL after freeing it in png_free_data().
- Worked around a problem in pngconf.h; AIX's strings.h defines an "index"
- macro that conflicts with libpng's png_color_16.index. (Dimitri
- Papadapoulos)
- Added "msvc" directory with MSVC++ project files (Simon-Pierre Cadieux).
-
-Version 1.0.7beta16 [June 4, 2000]
- Revised the workaround of AIX string.h "index" bug.
- Added a check for overlength PLTE chunk in pngrutil.c.
- Added PNG_NO_POINTER_INDEXING macro to use array-indexing instead of pointer
- indexing in pngrutil.c and pngwutil.c to accommodate a buggy compiler.
- Added a warning in png_decompress_chunk() when it runs out of data, e.g.
- when it tries to read an erroneous PhotoShop iCCP chunk.
- Added PNG_USE_DLL macro.
- Revised the copyright/disclaimer/license notice.
- Added contrib/msvctest directory
-
-Version 1.0.7rc1 [June 9, 2000]
- Corrected the definition of PNG_TRANSFORM_INVERT_ALPHA (0x0400 not 0x0200)
- Added contrib/visupng directory (Willem van Schaik)
-
-Version 1.0.7beta18 [June 23, 2000]
- Revised PNGAPI definition, and pngvcrd.c to work with __GCC__
- and do not redefine PNGAPI if it is passed in via a compiler directive.
- Revised visupng/PngFile.c to remove returns from within the Try block.
- Removed leading underscores from "_PNG_H" and "_PNG_SAVE_BSD_SOURCE" macros.
- Updated contrib/visupng/cexcept.h to version 1.0.0.
- Fixed bugs in pngwrite.c and pngwutil.c that prevented writing iCCP chunks.
-
-Version 1.0.7rc2 [June 28, 2000]
- Updated license to include disclaimers required by UCITA.
- Fixed "DJBPP" typo in pnggccrd.c introduced in beta18.
-
-Version 1.0.7 [July 1, 2000]
- Revised the definition of "trans_values" in libpng.3/libpng.txt
-
-Version 1.0.8beta1 [July 8, 2000]
- Added png_free(png_ptr, key) two places in pngpread.c to stop memory leaks.
- Changed PNG_NO_STDIO to PNG_NO_CONSOLE_IO, several places in pngrutil.c and
- pngwutil.c.
- Changed PNG_EXPORT_VAR to use PNG_IMPEXP, in pngconf.h.
- Removed unused "#include <assert.h>" from png.c
- Added WindowsCE support.
- Revised pnggccrd.c to work with gcc-2.95.2 and in the Cygwin environment.
-
-Version 1.0.8beta2 [July 10, 2000]
- Added project files to the wince directory and made further revisions
- of pngtest.c, pngrio.c, and pngwio.c in support of WindowsCE.
-
-Version 1.0.8beta3 [July 11, 2000]
- Only set the PNG_FLAG_FREE_TRNS or PNG_FREE_TRNS flag in png_handle_tRNS()
- for indexed-color input files to avoid potential double-freeing trans array
- under some unusual conditions; problem was introduced in version 1.0.6f.
- Further revisions to pngtest.c and files in the wince subdirectory.
-
-Version 1.0.8beta4 [July 14, 2000]
- Added the files pngbar.png and pngbar.jpg to the distribution.
- Added makefile.cygwin, and cygwin support in pngconf.h
- Added PNG_NO_ZALLOC_ZERO macro (makes png_zalloc skip zeroing memory)
-
-Version 1.0.8rc1 [July 16, 2000]
- Revised png_debug() macros and statements to eliminate compiler warnings.
-
-Version 1.0.8 [July 24, 2000]
- Added png_flush() in pngwrite.c, after png_write_IEND().
- Updated makefile.hpux to build a shared library.
-
-Version 1.0.9beta1 [November 10, 2000]
- Fixed typo in scripts/makefile.hpux
- Updated makevms.com in scripts and contrib/* and contrib/* (Martin Zinser)
- Fixed sequence-point bug in contrib/pngminus/png2pnm (Martin Zinser)
- Changed "cdrom.com" in documentation to "libpng.org"
- Revised pnggccrd.c to get it all working, and updated makefile.gcmmx (Greg).
- Changed type of "params" from voidp to png_voidp in png_read|write_png().
- Make sure PNGAPI and PNG_IMPEXP are defined in pngconf.h.
- Revised the 3 instances of WRITEFILE in pngtest.c.
- Relocated "msvc" and "wince" project subdirectories into "dll" subdirectory.
- Updated png.rc in dll/msvc project
- Revised makefile.dec to define and use LIBPATH and INCPATH
- Increased size of global png_libpng_ver[] array from 12 to 18 chars.
- Made global png_libpng_ver[], png_sig[] and png_pass_*[] arrays const.
- Removed duplicate png_crc_finish() from png_handle_bKGD() function.
- Added a warning when application calls png_read_update_info() multiple times.
- Revised makefile.cygwin
- Fixed bugs in iCCP support in pngrutil.c and pngwutil.c.
- Replaced png_set_empty_plte_permitted() with png_permit_mng_features().
-
-Version 1.0.9beta2 [November 19, 2000]
- Renamed the "dll" subdirectory "projects".
- Added borland project files to "projects" subdirectory.
- Set VS_FF_PRERELEASE and VS_FF_PATCHED flags in msvc/png.rc when appropriate.
- Add error message in png_set_compression_buffer_size() when malloc fails.
-
-Version 1.0.9beta3 [November 23, 2000]
- Revised PNG_LIBPNG_BUILD_TYPE macro in png.h, used in the msvc project.
- Removed the png_flush() in pngwrite.c that crashes some applications
- that don't set png_output_flush_fn.
- Added makefile.macosx and makefile.aix to scripts directory.
-
-Version 1.0.9beta4 [December 1, 2000]
- Change png_chunk_warning to png_warning in png_check_keyword().
- Increased the first part of msg buffer from 16 to 18 in png_chunk_error().
-
-Version 1.0.9beta5 [December 15, 2000]
- Added support for filter method 64 (for PNG datastreams embedded in MNG).
-
-Version 1.0.9beta6 [December 18, 2000]
- Revised png_set_filter() to accept filter method 64 when appropriate.
- Added new PNG_HAVE_PNG_SIGNATURE bit to png_ptr->mode and use it to
- help prevent applications from using MNG features in PNG datastreams.
- Added png_permit_mng_features() function.
- Revised libpng.3/libpng.txt. Changed "filter type" to "filter method".
-
-Version 1.0.9rc1 [December 23, 2000]
- Revised test for PNG_HAVE_PNG_SIGNATURE in pngrutil.c
- Fixed error handling of unknown compression type in png_decompress_chunk().
- In pngconf.h, define __cdecl when _MSC_VER is defined.
-
-Version 1.0.9beta7 [December 28, 2000]
- Changed PNG_TEXT_COMPRESSION_zTXt to PNG_COMPRESSION_TYPE_BASE several places.
- Revised memory management in png_set_hIST and png_handle_hIST in a backward
- compatible manner. PLTE and tRNS were revised similarly.
- Revised the iCCP chunk reader to ignore trailing garbage.
-
-Version 1.0.9beta8 [January 12, 2001]
- Moved pngasmrd.h into pngconf.h.
- Improved handling of out-of-spec garbage iCCP chunks generated by PhotoShop.
-
-Version 1.0.9beta9 [January 15, 2001]
- Added png_set_invalid, png_permit_mng_features, and png_mmx_supported to
- wince and msvc project module definition files.
- Minor revision of makefile.cygwin.
- Fixed bug with progressive reading of narrow interlaced images in pngpread.c
-
-Version 1.0.9beta10 [January 16, 2001]
- Do not typedef png_FILE_p in pngconf.h when PNG_NO_STDIO is defined.
- Fixed "png_mmx_supported" typo in project definition files.
-
-Version 1.0.9beta11 [January 19, 2001]
- Updated makefile.sgi to make shared library.
- Removed png_mmx_support() function and disabled PNG_MNG_FEATURES_SUPPORTED
- by default, for the benefit of DLL forward compatibility. These will
- be re-enabled in version 1.2.0.
-
-Version 1.0.9rc2 [January 22, 2001]
- Revised cygwin support.
-
-Version 1.0.9 [January 31, 2001]
- Added check of cygwin's ALL_STATIC in pngconf.h
- Added "-nommx" parameter to contrib/gregbook/rpng2-win and rpng2-x demos.
-
-Version 1.0.10beta1 [March 14, 2001]
- Revised makefile.dec, makefile.sgi, and makefile.sggcc; added makefile.hpgcc.
- Reformatted libpng.3 to eliminate bad line breaks.
- Added checks for _mmx_supported in the read_filter_row function of pnggccrd.c
- Added prototype for png_mmx_support() near the top of pnggccrd.c
- Moved some error checking from png_handle_IHDR to png_set_IHDR.
- Added PNG_NO_READ_SUPPORTED and PNG_NO_WRITE_SUPPORTED macros.
- Revised png_mmx_support() function in pnggccrd.c
- Restored version 1.0.8 PNG_WRITE_EMPTY_PLTE_SUPPORTED behavior in pngwutil.c
- Fixed memory leak in contrib/visupng/PngFile.c
- Fixed bugs in png_combine_row() in pnggccrd.c and pngvcrd.c (C version)
- Added warnings when retrieving or setting gamma=0.
- Increased the first part of msg buffer from 16 to 18 in png_chunk_warning().
-
-Version 1.0.10rc1 [March 23, 2001]
- Changed all instances of memcpy, strcpy, and strlen to png_memcpy, png_strcpy,
- and png_strlen.
- Revised png_mmx_supported() function in pnggccrd.c to return proper value.
- Fixed bug in progressive reading (pngpread.c) with small images (height < 8).
-
-Version 1.0.10 [March 30, 2001]
- Deleted extraneous space (introduced in 1.0.9) from line 42 of makefile.cygwin
- Added beos project files (Chris Herborth)
-
-Version 1.0.11beta1 [April 3, 2001]
- Added type casts on several png_malloc() calls (Dimitri Papadapoulos).
- Removed a no-longer needed AIX work-around from pngconf.h
- Changed several "//" single-line comments to C-style in pnggccrd.c
-
-Version 1.0.11beta2 [April 11, 2001]
- Removed PNGAPI from several functions whose prototypes did not have PNGAPI.
- Updated scripts/pngos2.def
-
-Version 1.0.11beta3 [April 14, 2001]
- Added checking the results of many instances of png_malloc() for NULL
-
-Version 1.0.11beta4 [April 20, 2001]
- Undid the changes from version 1.0.11beta3. Added a check for NULL return
- from user's malloc_fn().
- Removed some useless type casts of the NULL pointer.
- Added makefile.netbsd
-
-Version 1.0.11 [April 27, 2001]
- Revised makefile.netbsd
-
-Version 1.0.12beta1 [May 14, 2001]
- Test for Windows platform in pngconf.h when including malloc.h (Emmanuel Blot)
- Updated makefile.cygwin and handling of Cygwin's ALL_STATIC in pngconf.h
- Added some never-to-be-executed code in pnggccrd.c to quiet compiler warnings.
- Eliminated the png_error about apps using png_read|write_init(). Instead,
- libpng will reallocate the png_struct and info_struct if they are too small.
- This retains future binary compatibility for old applications written for
- libpng-0.88 and earlier.
-
-Version 1.2.0beta1 [May 6, 2001]
- Bumped DLLNUM to 2.
- Re-enabled PNG_MNG_FEATURES_SUPPORTED and enabled PNG_ASSEMBLER_CODE_SUPPORTED
- by default.
- Added runtime selection of MMX features.
- Added png_set_strip_error_numbers function and related macros.
-
-Version 1.2.0beta2 [May 7, 2001]
- Finished merging 1.2.0beta1 with version 1.0.11
- Added a check for attempts to read or write PLTE in grayscale PNG datastreams.
-
-Version 1.2.0beta3 [May 17, 2001]
- Enabled user memory function by default.
- Modified png_create_struct so it passes user mem_ptr to user memory allocator.
- Increased png_mng_features flag from png_byte to png_uint_32.
- Bumped shared-library (so-number) and dll-number to 3.
-
-Version 1.2.0beta4 [June 23, 2001]
- Check for missing profile length field in iCCP chunk and free chunk_data
- in case of truncated iCCP chunk.
- Bumped shared-library number to 3 in makefile.sgi and makefile.sggcc
- Bumped dll-number from 2 to 3 in makefile.cygwin
- Revised contrib/gregbook/rpng*-x.c to avoid a memory leak and to exit cleanly
- if user attempts to run it on an 8-bit display.
- Updated contrib/gregbook
- Use png_malloc instead of png_zalloc to allocate palette in pngset.c
- Updated makefile.ibmc
- Added some typecasts to eliminate gcc 3.0 warnings. Changed prototypes
- of png_write_oFFS width and height from png_uint_32 to png_int_32.
- Updated example.c
- Revised prototypes for png_debug_malloc and png_debug_free in pngtest.c
-
-Version 1.2.0beta5 [August 8, 2001]
- Revised contrib/gregbook
- Revised makefile.gcmmx
- Revised pnggccrd.c to conditionally compile some thread-unsafe code only
- when PNG_THREAD_UNSAFE_OK is defined.
- Added tests to prevent pngwutil.c from writing a bKGD or tRNS chunk with
- value exceeding 2^bit_depth-1
- Revised makefile.sgi and makefile.sggcc
- Replaced calls to fprintf(stderr,...) with png_warning() in pnggccrd.c
- Removed restriction that do_invert_mono only operate on 1-bit opaque files
-
-Version 1.2.0 [September 1, 2001]
- Changed a png_warning() to png_debug() in pnggccrd.c
- Fixed contrib/gregbook/rpng-x.c, rpng2-x.c to avoid crash with XFreeGC().
-
-Version 1.2.1beta1 [October 19, 2001]
- Revised makefile.std in contrib/pngminus
- Include background_1 in png_struct regardless of gamma support.
- Revised makefile.netbsd and makefile.macosx, added makefile.darwin.
- Revised example.c to provide more details about using row_callback().
-
-Version 1.2.1beta2 [October 25, 2001]
- Added type cast to each NULL appearing in a function call, except for
- WINCE functions.
- Added makefile.so9.
-
-Version 1.2.1beta3 [October 27, 2001]
- Removed type casts from all NULLs.
- Simplified png_create_struct_2().
-
-Version 1.2.1beta4 [November 7, 2001]
- Revised png_create_info_struct() and png_creat_struct_2().
- Added error message if png_write_info() was omitted.
- Type cast NULLs appearing in function calls when _NO_PROTO or
- PNG_TYPECAST_NULL is defined.
-
-Version 1.2.1rc1 [November 24, 2001]
- Type cast NULLs appearing in function calls except when PNG_NO_TYPECAST_NULL
- is defined.
- Changed typecast of "size" argument to png_size_t in pngmem.c calls to
- the user malloc_fn, to agree with the prototype in png.h
- Added a pop/push operation to pnggccrd.c, to preserve Eflag (Maxim Sobolev)
- Updated makefile.sgi to recognize LIBPATH and INCPATH.
- Updated various makefiles so "make clean" does not remove previous major
- version of the shared library.
-
-Version 1.2.1rc2 [December 4, 2001]
- Always allocate 256-entry internal palette, hist, and trans arrays, to
- avoid out-of-bounds memory reference caused by invalid PNG datastreams.
- Added a check for prefix_length > data_length in iCCP chunk handler.
-
-Version 1.2.1 [December 7, 2001]
- None.
-
-Version 1.2.2beta1 [February 22, 2002]
- Fixed a bug with reading the length of iCCP profiles (Larry Reeves).
- Revised makefile.linux, makefile.gcmmx, and makefile.sgi to generate
- libpng.a, libpng12.so (not libpng.so.3), and libpng12/png.h
- Revised makefile.darwin to remove "-undefined suppress" option.
- Added checks for gamma and chromaticity values over 21474.83, which exceed
- the limit for PNG unsigned 32-bit integers when encoded.
- Revised calls to png_create_read_struct() and png_create_write_struct()
- for simpler debugging.
- Revised png_zalloc() so zlib handles errors (uses PNG_FLAG_MALLOC_NULL_MEM_OK)
-
-Version 1.2.2beta2 [February 23, 2002]
- Check chunk_length and idat_size for invalid (over PNG_MAX_UINT) lengths.
- Check for invalid image dimensions in png_get_IHDR.
- Added missing "fi;" in the install target of the SGI makefiles.
- Added install-static to all makefiles that make shared libraries.
- Always do gamma compensation when image is partially transparent.
-
-Version 1.2.2beta3 [March 7, 2002]
- Compute background.gray and background_1.gray even when color_type is RGB
- in case image gets reduced to gray later.
- Modified shared-library makefiles to install pkgconfig/libpngNN.pc.
- Export (with PNGAPI) png_zalloc, png_zfree, and png_handle_as_unknown
- Removed unused png_write_destroy_info prototype from png.h
- Eliminated incorrect use of width_mmx from pnggccrd.c in pixel_bytes == 8 case
- Added install-shared target to all makefiles that make shared libraries.
- Stopped a double free of palette, hist, and trans when not using free_me.
- Added makefile.32sunu for Sun Ultra 32 and makefile.64sunu for Sun Ultra 64.
-
-Version 1.2.2beta4 [March 8, 2002]
- Compute background.gray and background_1.gray even when color_type is RGB
- in case image gets reduced to gray later (Jason Summers).
- Relocated a misplaced /bin/rm in the "install-shared" makefile targets
- Added PNG_1_0_X macro which can be used to build a 1.0.x-compatible library.
-
-Version 1.2.2beta5 [March 26, 2002]
- Added missing PNGAPI to several function definitions.
- Check for invalid bit_depth or color_type in png_get_IHDR(), and
- check for missing PLTE or IHDR in png_push_read_chunk() (Matthias Clasen).
- Revised iTXt support to accept NULL for lang and lang_key.
- Compute gamma for color components of background even when color_type is gray.
- Changed "()" to "{}" in scripts/libpng.pc.in.
- Revised makefiles to put png.h and pngconf.h only in $prefix/include/libpngNN
- Revised makefiles to make symlink to libpng.so.NN in addition to libpngNN.so
-
-Version 1.2.2beta6 [March 31, 2002]
-
-Version 1.0.13beta1 [March 31, 2002]
- Prevent png_zalloc() from trying to memset memory that it failed to acquire.
- Add typecasts of PNG_MAX_UINT in pngset_cHRM_fixed() (Matt Holgate).
- Ensure that the right function (user or default) is used to free the
- png_struct after an error in png_create_read_struct_2().
-
-Version 1.2.2rc1 [April 7, 2002]
-
-Version 1.0.13rc1 [April 7, 2002]
- Save the ebx register in pnggccrd.c (Sami Farin)
- Add "mem_ptr = png_ptr->mem_ptr" in png_destroy_write_struct() (Paul Gardner).
- Updated makefiles to put headers in include/libpng and remove old include/*.h.
-
-Version 1.2.2 [April 15, 2002]
-
-Version 1.0.13 [April 15, 2002]
- Revised description of png_set_filter() in libpng.3/libpng.txt.
- Revised makefile.netbsd and added makefile.neNNbsd and makefile.freebsd
-
-Version 1.0.13patch01 [April 17, 2002]
-
-Version 1.2.2patch01 [April 17, 2002]
- Changed ${PNGMAJ}.${PNGVER} bug to ${PNGVER} in makefile.sgi and
- makefile.sggcc
- Fixed VER -> PNGVER typo in makefile.macosx and added install-static to
- install
- Added install: target to makefile.32sunu and makefile.64sunu
-
-Version 1.0.13patch03 [April 18, 2002]
-
-Version 1.2.2patch03 [April 18, 2002]
- Revised 15 makefiles to link libpng.a to libpngNN.a and the include libpng
- subdirectory to libpngNN subdirectory without the full pathname.
- Moved generation of libpng.pc from "install" to "all" in 15 makefiles.
-
-Version 1.2.3rc1 [April 28, 2002]
- Added install-man target to 15 makefiles (Dimitri Papadopolous-Orfanos).
- Added $(DESTDIR) feature to 24 makefiles (Tim Mooney)
- Fixed bug with $prefix, should be $(prefix) in makefile.hpux.
- Updated cygwin-specific portion of pngconf.h and revised makefile.cygwin
- Added a link from libpngNN.pc to libpng.pc in 15 makefiles.
- Added links from include/libpngNN/*.h to include/*.h in 24 makefiles.
- Revised makefile.darwin to make relative links without full pathname.
- Added setjmp() at the end of png_create_*_struct_2() in case user forgets
- to put one in their application.
- Restored png_zalloc() and png_zfree() prototypes to version 1.2.1 and
- removed them from module definition files.
-
-Version 1.2.3rc2 [May 1, 2002]
- Fixed bug in reporting number of channels in pngget.c and pngset.c,
- that was introduced in version 1.2.2beta5.
- Exported png_zalloc(), png_zfree(), png_default_read(), png_default_write(),
- png_default_flush(), and png_push_fill_buffer() and included them in
- module definition files.
- Added "libpng.pc" dependency to the "install-shared" target in 15 makefiles.
-
-Version 1.2.3rc3 [May 1, 2002]
- Revised prototype for png_default_flush()
- Remove old libpng.pc and libpngNN.pc before installing new ones.
-
-Version 1.2.3rc4 [May 2, 2002]
- Typos in *.def files (png_default_read|write -> png_default_read|write_data)
- In makefiles, changed rm libpng.NN.pc to rm libpngNN.pc
- Added libpng-config and libpngNN-config and modified makefiles to install
- them.
- Changed $(MANPATH) to $(DESTDIR)$(MANPATH) in makefiles
- Added "Win32 DLL VB" configuration to projects/msvc/libpng.dsp
-
-Version 1.2.3rc5 [May 11, 2002]
- Changed "error" and "message" in prototypes to "error_message" and
- "warning_message" to avoid namespace conflict.
- Revised 15 makefiles to build libpng-config from libpng-config-*.in
- Once more restored png_zalloc and png_zfree to regular nonexported form.
- Restored png_default_read|write_data, png_default_flush, png_read_fill_buffer
- to nonexported form, but with PNGAPI, and removed them from module def
- files.
-
-Version 1.2.3rc6 [May 14, 2002]
- Removed "PNGAPI" from png_zalloc() and png_zfree() in png.c
- Changed "Gz" to "Gd" in projects/msvc/libpng.dsp and zlib.dsp.
- Removed leftover libpng-config "sed" script from four makefiles.
- Revised libpng-config creating script in 16 makefiles.
-
-Version 1.2.3 [May 22, 2002]
- Revised libpng-config target in makefile.cygwin.
- Removed description of png_set_mem_fn() from documentation.
- Revised makefile.freebsd.
- Minor cosmetic changes to 15 makefiles, e.g., $(DI) = $(DESTDIR)/$(INCDIR).
- Revised projects/msvc/README.txt
- Changed -lpng to -lpngNN in LDFLAGS in several makefiles.
-
-Version 1.2.4beta1 [May 24, 2002]
- Added libpng.pc and libpng-config to "all:" target in 16 makefiles.
- Fixed bug in 16 makefiles: $(DESTDIR)/$(LIBPATH) to $(DESTDIR)$(LIBPATH)
- Added missing "\" before closing double quote in makefile.gcmmx.
- Plugged various memory leaks; added png_malloc_warn() and png_set_text_2()
- functions.
-
-Version 1.2.4beta2 [June 25, 2002]
- Plugged memory leak of png_ptr->current_text (Matt Holgate).
- Check for buffer overflow before reading CRC in pngpread.c (Warwick Allison)
- Added -soname to the loader flags in makefile.dec, makefile.sgi, and
- makefile.sggcc.
- Added "test-installed" target to makefile.linux, makefile.gcmmx,
- makefile.sgi, and makefile.sggcc.
-
-Version 1.2.4beta3 [June 28, 2002]
- Plugged memory leak of row_buf in pngtest.c when there is a png_error().
- Detect buffer overflow in pngpread.c when IDAT is corrupted with extra data.
- Added "test-installed" target to makefile.32sunu, makefile.64sunu,
- makefile.beos, makefile.darwin, makefile.dec, makefile.macosx,
- makefile.solaris, makefile.hpux, makefile.hpgcc, and makefile.so9.
-
-Version 1.2.4rc1 and 1.0.14rc1 [July 2, 2002]
- Added "test-installed" target to makefile.cygwin and makefile.sco.
- Revised pnggccrd.c to be able to back out version 1.0.x via PNG_1_0_X macro.
-
-Version 1.2.4 and 1.0.14 [July 8, 2002]
- Changed png_warning() to png_error() when width is too large to process.
-
-Version 1.2.4patch01 [July 20, 2002]
- Revised makefile.cygwin to use DLL number 12 instead of 13.
-
-Version 1.2.5beta1 [August 6, 2002]
- Added code to contrib/gregbook/readpng2.c to ignore unused chunks.
- Replaced toucan.png in contrib/gregbook (it has been corrupt since 1.0.11)
- Removed some stray *.o files from contrib/gregbook.
- Changed png_error() to png_warning() about "Too much data" in pngpread.c
- and about "Extra compressed data" in pngrutil.c.
- Prevent png_ptr->pass from exceeding 7 in png_push_finish_row().
- Updated makefile.hpgcc
- Updated png.c and pnggccrd.c handling of return from png_mmx_support()
-
-Version 1.2.5beta2 [August 15, 2002]
- Only issue png_warning() about "Too much data" in pngpread.c when avail_in
- is nonzero.
- Updated makefiles to install a separate libpng.so.3 with its own rpath.
-
-Version 1.2.5rc1 and 1.0.15rc1 [August 24, 2002]
- Revised makefiles to not remove previous minor versions of shared libraries.
-
-Version 1.2.5rc2 and 1.0.15rc2 [September 16, 2002]
- Revised 13 makefiles to remove "-lz" and "-L$(ZLIBLIB)", etc., from shared
- library loader directive.
- Added missing "$OBJSDLL" line to makefile.gcmmx.
- Added missing "; fi" to makefile.32sunu.
-
-Version 1.2.5rc3 and 1.0.15rc3 [September 18, 2002]
- Revised libpng-config script.
-
-Version 1.2.5 and 1.0.15 [October 3, 2002]
- Revised makefile.macosx, makefile.darwin, makefile.hpgcc, and makefile.hpux,
- and makefile.aix.
- Relocated two misplaced PNGAPI lines in pngtest.c
-
-Version 1.2.6beta1 [October 22, 2002]
- Commented out warning about uninitialized mmx_support in pnggccrd.c.
- Changed "IBMCPP__" flag to "__IBMCPP__" in pngconf.h.
- Relocated two more misplaced PNGAPI lines in pngtest.c
- Fixed memory overrun bug in png_do_read_filler() with 16-bit datastreams,
- introduced in version 1.0.2.
- Revised makefile.macosx, makefile.dec, makefile.aix, and makefile.32sunu.
-
-Version 1.2.6beta2 [November 1, 2002]
- Added libpng-config "--ldopts" output.
- Added "AR=ar" and "ARFLAGS=rc" and changed "ar rc" to "$(AR) $(ARFLAGS)"
- in makefiles.
-
-Version 1.2.6beta3 [July 18, 2004]
- Reverted makefile changes from version 1.2.6beta2 and some of the changes
- from version 1.2.6beta1; these will be postponed until version 1.2.7.
- Version 1.2.6 is going to be a simple bugfix release.
- Changed the one instance of "ln -sf" to "ln -f -s" in each Sun makefile.
- Fixed potential overrun in pngerror.c by using strncpy instead of memcpy.
- Added "#!/bin/sh" at the top of configure, for recognition of the
- 'x' flag under Cygwin (Cosmin).
- Optimized vacuous tests that silence compiler warnings, in png.c (Cosmin).
- Added support for PNG_USER_CONFIG, in pngconf.h (Cosmin).
- Fixed the special memory handler for Borland C under DOS, in pngmem.c
- (Cosmin).
- Removed some spurious assignments in pngrutil.c (Cosmin).
- Replaced 65536 with 65536L, and 0xffff with 0xffffL, to silence warnings
- on 16-bit platforms (Cosmin).
- Enclosed shift op expressions in parentheses, to silence warnings (Cosmin).
- Used proper type png_fixed_point, to avoid problems on 16-bit platforms,
- in png_handle_sRGB() (Cosmin).
- Added compression_type to png_struct, and optimized the window size
- inside the deflate stream (Cosmin).
- Fixed definition of isnonalpha(), in pngerror.c and pngrutil.c (Cosmin).
- Fixed handling of unknown chunks that come after IDAT (Cosmin).
- Allowed png_error() and png_warning() to work even if png_ptr == NULL
- (Cosmin).
- Replaced row_info->rowbytes with row_bytes in png_write_find_filter()
- (Cosmin).
- Fixed definition of PNG_LIBPNG_VER_DLLNUM (Simon-Pierre).
- Used PNG_LIBPNG_VER and PNG_LIBPNG_VER_STRING instead of the hardcoded
- values in png.c (Simon-Pierre, Cosmin).
- Initialized png_libpng_ver[] with PNG_LIBPNG_VER_STRING (Simon-Pierre).
- Replaced PNG_LIBPNG_VER_MAJOR with PNG_LIBPNG_VER_DLLNUM in png.rc
- (Simon-Pierre).
- Moved the definition of PNG_HEADER_VERSION_STRING near the definitions
- of the other PNG_LIBPNG_VER_... symbols in png.h (Cosmin).
- Relocated #ifndef PNGAPI guards in pngconf.h (Simon-Pierre, Cosmin).
- Updated scripts/makefile.vc(a)win32 (Cosmin).
- Updated the MSVC project (Simon-Pierre, Cosmin).
- Updated the Borland C++ Builder project (Cosmin).
- Avoided access to asm_flags in pngvcrd.c, if PNG_1_0_X is defined (Cosmin).
- Commented out warning about uninitialized mmx_support in pngvcrd.c (Cosmin).
- Removed scripts/makefile.bd32 and scripts/pngdef.pas (Cosmin).
- Added extra guard around inclusion of Turbo C memory headers, in pngconf.h
- (Cosmin).
- Renamed projects/msvc/ to projects/visualc6/, and projects/borland/ to
- projects/cbuilder5/ (Cosmin).
- Moved projects/visualc6/png32ms.def to scripts/pngw32.def,
- and projects/visualc6/png.rc to scripts/pngw32.rc (Cosmin).
- Added projects/visualc6/pngtest.dsp; removed contrib/msvctest/ (Cosmin).
- Changed line endings to DOS style in cbuilder5 and visualc6 files, even
- in the tar.* distributions (Cosmin).
- Updated contrib/visupng/VisualPng.dsp (Cosmin).
- Updated contrib/visupng/cexcept.h to version 2.0.0 (Cosmin).
- Added a separate distribution with "configure" and supporting files (Junichi).
-
-Version 1.2.6beta4 [July 28, 2004]
- Added user ability to change png_size_t via a PNG_SIZE_T macro.
- Added png_sizeof() and png_convert_size() functions.
- Added PNG_SIZE_MAX (maximum value of a png_size_t variable.
- Added check in png_malloc_default() for (size_t)size != (png_uint_32)size
- which would indicate an overflow.
- Changed sPLT failure action from png_error to png_warning and abandon chunk.
- Changed sCAL and iCCP failures from png_error to png_warning and abandon.
- Added png_get_uint_31(png_ptr, buf) function.
- Added PNG_UINT_32_MAX macro.
- Renamed PNG_MAX_UINT to PNG_UINT_31_MAX.
- Made png_zalloc() issue a png_warning and return NULL on potential
- overflow.
- Turn on PNG_NO_ZALLOC_ZERO by default in version 1.2.x
- Revised "clobber list" in pnggccrd.c so it will compile under gcc-3.4.
- Revised Borland portion of png_malloc() to return NULL or issue
- png_error() according to setting of PNG_FLAG_MALLOC_NULL_MEM_OK.
- Added PNG_NO_SEQUENTIAL_READ_SUPPORTED macro to conditionally remove
- sequential read support.
- Added some "#if PNG_WRITE_SUPPORTED" blocks.
- Added #ifdef to remove some redundancy in png_malloc_default().
- Use png_malloc instead of png_zalloc to allocate the palette.
-
-Version 1.0.16rc1 and 1.2.6rc1 [August 4, 2004]
- Fixed buffer overflow vulnerability (CVE-2004-0597) in png_handle_tRNS().
- Fixed NULL dereference vulnerability (CVE-2004-0598) in png_handle_iCCP().
- Fixed integer overflow vulnerability (CVE-2004-0599) in png_read_png().
- Fixed some harmless bugs in png_handle_sBIT, etc, that would cause
- duplicate chunk types to go undetected.
- Fixed some timestamps in the -config version
- Rearranged order of processing of color types in png_handle_tRNS().
- Added ROWBYTES macro to calculate rowbytes without integer overflow.
- Updated makefile.darwin and removed makefile.macosx from scripts directory.
- Imposed default one million column, one-million row limits on the image
- dimensions, and added png_set_user_limits() function to override them.
- Revised use of PNG_SET_USER_LIMITS_SUPPORTED macro.
- Fixed wrong cast of returns from png_get_user_width|height_max().
- Changed some "keep the compiler happy" from empty statements to returns,
- Revised libpng.txt to remove 1.2.x stuff from the 1.0.x distribution
-
-Version 1.0.16rc2 and 1.2.6rc2 [August 7, 2004]
- Revised makefile.darwin and makefile.solaris. Removed makefile.macosx.
- Revised pngtest's png_debug_malloc() to use png_malloc() instead of
- png_malloc_default() which is not supposed to be exported.
- Fixed off-by-one error in one of the conversions to PNG_ROWBYTES() in
- pngpread.c. Bug was introduced in 1.2.6rc1.
- Fixed bug in RGB to RGBX transformation introduced in 1.2.6rc1.
- Fixed old bug in RGB to Gray transformation.
- Fixed problem with 64-bit compilers by casting arguments to abs()
- to png_int_32.
- Changed "ln -sf" to "ln -f -s" in three makefiles (solaris, sco, so9).
- Changed "HANDLE_CHUNK_*" to "PNG_HANDLE_CHUNK_*" (Cosmin)
- Added "-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)" to 15 *NIX makefiles.
- Added code to update the row_info->colortype in png_do_read_filler() (MSB).
-
-Version 1.0.16rc3 and 1.2.6rc3 [August 9, 2004]
- Eliminated use of "abs()" in testing cHRM and gAMA values, to avoid
- trouble with some 64-bit compilers. Created PNG_OUT_OF_RANGE() macro.
- Revised documentation of png_set_keep_unknown_chunks().
- Check handle_as_unknown status in pngpread.c, as in pngread.c previously.
- Moved "PNG_HANDLE_CHUNK_*" macros out of PNG_INTERNAL section of png.h
- Added "rim" definitions for CONST4 and CONST6 in pnggccrd.c
-
-Version 1.0.16rc4 and 1.2.6rc4 [August 10, 2004]
- Fixed mistake in pngtest.c introduced in 1.2.6rc2 (declaration of
- "pinfo" was out of place).
-
-Version 1.0.16rc5 and 1.2.6rc5 [August 10, 2004]
- Moved "PNG_HANDLE_CHUNK_*" macros out of PNG_ASSEMBLER_CODE_SUPPORTED
- section of png.h where they were inadvertently placed in version rc3.
-
-Version 1.2.6 and 1.0.16 [August 15, 2004]
- Revised pngtest so memory allocation testing is only done when PNG_DEBUG==1.
-
-Version 1.2.7beta1 [August 26, 2004]
- Removed unused pngasmrd.h file.
- Removed references to uu.net for archived files. Added references to
- PNG Spec (second edition) and the PNG ISO/IEC Standard.
- Added "test-dd" target in 15 makefiles, to run pngtest in DESTDIR.
- Fixed bug with "optimized window size" in the IDAT datastream, that
- causes libpng to write PNG files with incorrect zlib header bytes.
-
-Version 1.2.7beta2 [August 28, 2004]
- Fixed bug with sCAL chunk and big-endian machines (David Munro).
- Undid new code added in 1.2.6rc2 to update the color_type in
- png_set_filler().
- Added png_set_add_alpha() that updates color type.
-
-Version 1.0.17rc1 and 1.2.7rc1 [September 4, 2004]
- Revised png_set_strip_filler() to not remove alpha if color_type has alpha.
-
-Version 1.2.7 and 1.0.17 [September 12, 2004]
- Added makefile.hp64
- Changed projects/msvc/png32ms.def to scripts/png32ms.def in makefile.cygwin
-
-Version 1.2.8beta1 [November 1, 2004]
- Fixed bug in png_text_compress() that would fail to complete a large block.
- Fixed bug, introduced in libpng-1.2.7, that overruns a buffer during
- strip alpha operation in png_do_strip_filler().
- Added PNG_1_2_X definition in pngconf.h
- Use #ifdef to comment out png_info_init in png.c and png_read_init in
- pngread.c (as of 1.3.0)
-
-Version 1.2.8beta2 [November 2, 2004]
- Reduce color_type to a nonalpha type after strip alpha operation in
- png_do_strip_filler().
-
-Version 1.2.8beta3 [November 3, 2004]
- Revised definitions of PNG_MAX_UINT_32, PNG_MAX_SIZE, and PNG_MAXSUM
-
-Version 1.2.8beta4 [November 12, 2004]
- Fixed (again) definition of PNG_LIBPNG_VER_DLLNUM in png.h (Cosmin).
- Added PNG_LIBPNG_BUILD_PRIVATE in png.h (Cosmin).
- Set png_ptr->zstream.data_type to Z_BINARY, to avoid unnecessary detection
- of data type in deflate (Cosmin).
- Deprecated but continue to support SPECIALBUILD and PRIVATEBUILD in favor of
- PNG_LIBPNG_BUILD_SPECIAL_STRING and PNG_LIBPNG_BUILD_PRIVATE_STRING.
-
-Version 1.2.8beta5 [November 20, 2004]
- Use png_ptr->flags instead of png_ptr->transformations to pass
- PNG_STRIP_ALPHA info to png_do_strip_filler(), to preserve ABI
- compatibility.
- Revised handling of SPECIALBUILD, PRIVATEBUILD,
- PNG_LIBPNG_BUILD_SPECIAL_STRING and PNG_LIBPNG_BUILD_PRIVATE_STRING.
-
-Version 1.2.8rc1 [November 24, 2004]
- Moved handling of BUILD macros from pngconf.h to png.h
- Added definition of PNG_LIBPNG_BASE_TYPE in png.h, inadvertently
- omitted from beta5.
- Revised scripts/pngw32.rc
- Despammed mailing addresses by masking "@" with "at".
- Inadvertently installed a supposedly faster test version of pngrutil.c
-
-Version 1.2.8rc2 [November 26, 2004]
- Added two missing "\" in png.h
- Change tests in pngread.c and pngpread.c to
- if (png_ptr->transformations || (png_ptr->flags&PNG_FLAG_STRIP_ALPHA))
- png_do_read_transformations(png_ptr);
-
-Version 1.2.8rc3 [November 28, 2004]
- Reverted pngrutil.c to version libpng-1.2.8beta5.
- Added scripts/makefile.elf with supporting code in pngconf.h for symbol
- versioning (John Bowler).
-
-Version 1.2.8rc4 [November 29, 2004]
- Added projects/visualc7 (Simon-pierre).
-
-Version 1.2.8rc5 [November 29, 2004]
- Fixed new typo in scripts/pngw32.rc
-
-Version 1.2.8 [December 3, 2004]
- Removed projects/visualc7, added projects/visualc71.
-
-Version 1.2.9beta1 [February 21, 2006]
- Initialized some structure members in pngwutil.c to avoid gcc-4.0.0 complaints
- Revised man page and libpng.txt to make it clear that one should not call
- png_read_end or png_write_end after png_read_png or png_write_png.
- Updated references to png-mng-implement mailing list.
- Fixed an incorrect typecast in pngrutil.c
- Added PNG_NO_READ_SUPPORTED conditional for making a write-only library.
- Added PNG_NO_WRITE_INTERLACING_SUPPORTED conditional.
- Optimized alpha-inversion loops in pngwtran.c
- Moved test for nonzero gamma outside of png_build_gamma_table() in pngrtran.c
- Make sure num_trans is <= 256 before copying data in png_set_tRNS().
- Make sure num_palette is <= 256 before copying data in png_set_PLTE().
- Interchanged order of write_swap_alpha and write_invert_alpha transforms.
- Added parentheses in the definition of PNG_LIBPNG_BUILD_TYPE (Cosmin).
- Optimized zlib window flag (CINFO) in contrib/pngsuite/*.png (Cosmin).
- Updated scripts/makefile.bc32 for Borland C++ 5.6 (Cosmin).
- Exported png_get_uint_32, png_save_uint_32, png_get_uint_16, png_save_uint_16,
- png_get_int_32, png_save_int_32, png_get_uint_31 (Cosmin).
- Added type cast (png_byte) in png_write_sCAL() (Cosmin).
- Fixed scripts/makefile.cygwin (Christian Biesinger, Cosmin).
- Default iTXt support was inadvertently enabled.
-
-Version 1.2.9beta2 [February 21, 2006]
- Check for png_rgb_to_gray and png_gray_to_rgb read transformations before
- checking for png_read_dither in pngrtran.c
- Revised checking of chromaticity limits to accommodate extended RGB
- colorspace (John Denker).
- Changed line endings in some of the project files to CRLF, even in the
- "Unix" tar distributions (Cosmin).
- Made png_get_int_32 and png_save_int_32 always available (Cosmin).
- Updated scripts/pngos2.def, scripts/pngw32.def and projects/wince/png32ce.def
- with the newly exported functions.
- Eliminated distributions without the "configure" script.
- Updated INSTALL instructions.
-
-Version 1.2.9beta3 [February 24, 2006]
- Fixed CRCRLF line endings in contrib/visupng/VisualPng.dsp
- Made libpng.pc respect EXEC_PREFIX (D. P. Kreil, J. Bowler)
- Removed reference to pngasmrd.h from Makefile.am
- Renamed CHANGES to ChangeLog.
- Renamed LICENSE to COPYING.
- Renamed ANNOUNCE to NEWS.
- Created AUTHORS file.
-
-Version 1.2.9beta4 [March 3, 2006]
- Changed definition of PKGCONFIG from $prefix/lib to $libdir in configure.ac
- Reverted to filenames LICENSE and ANNOUNCE; removed AUTHORS and COPYING.
- Removed newline from the end of some error and warning messages.
- Removed test for sqrt() from configure.ac and configure.
- Made swap tables in pngtrans.c PNG_CONST (Carlo Bramix).
- Disabled default iTXt support that was inadvertently enabled in
- libpng-1.2.9beta1.
- Added "OS2" to list of systems that don't need underscores, in pnggccrd.c
- Removed libpng version and date from *.c files.
-
-Version 1.2.9beta5 [March 4, 2006]
- Removed trailing blanks from source files.
- Put version and date of latest change in each source file, and changed
- copyright year accordingly.
- More cleanup of configure.ac, Makefile.am, and associated scripts.
- Restored scripts/makefile.elf which was inadvertently deleted.
-
-Version 1.2.9beta6 [March 6, 2006]
- Fixed typo (RELEASE) in configuration files.
-
-Version 1.2.9beta7 [March 7, 2006]
- Removed libpng.vers and libpng.sym from libpng12_la_SOURCES in Makefile.am
- Fixed inconsistent #ifdef's around png_sig_bytes() and png_set_sCAL_s()
- in png.h.
- Updated makefile.elf as suggested by debian.
- Made cosmetic changes to some makefiles, adding LN_SF and other macros.
- Made some makefiles accept "exec_prefix".
-
-Version 1.2.9beta8 [March 9, 2006]
- Fixed some "#if defined (..." which should be "#if defined(..."
- Bug introduced in libpng-1.2.8.
- Fixed inconsistency in definition of png_default_read_data()
- Restored blank that was lost from makefile.sggcc "clean" target in beta7.
- Revised calculation of "current" and "major" for irix in ltmain.sh
- Changed "mkdir" to "MKDIR_P" in some makefiles.
- Separated PNG_EXPAND and PNG_EXPAND_tRNS.
- Added png_set_expand_gray_1_2_4_to_8() and deprecated
- png_set_gray_1_2_4_to_8() which also expands tRNS to alpha.
-
-Version 1.2.9beta9 [March 10, 2006]
- Include "config.h" in pngconf.h when available.
- Added some checks for NULL png_ptr or NULL info_ptr (timeless)
-
-Version 1.2.9beta10 [March 20, 2006]
- Removed extra CR from contrib/visualpng/VisualPng.dsw (Cosmin)
- Made pnggccrd.c PIC-compliant (Christian Aichinger).
- Added makefile.mingw (Wolfgang Glas).
- Revised pngconf.h MMX checking.
-
-Version 1.2.9beta11 [March 22, 2006]
- Fixed out-of-order declaration in pngwrite.c that was introduced in beta9
- Simplified some makefiles by using LIBSO, LIBSOMAJ, and LIBSOVER macros.
-
-Version 1.2.9rc1 [March 31, 2006]
- Defined PNG_USER_PRIVATEBUILD when including "pngusr.h" (Cosmin).
- Removed nonsensical assertion check from pngtest.c (Cosmin).
-
-Version 1.2.9 [April 14, 2006]
- Revised makefile.beos and added "none" selector in ltmain.sh
-
-Version 1.2.10beta1 [April 15, 2006]
- Renamed "config.h" to "png_conf.h" and revised Makefile.am to add
- -DPNG_BUILDING_LIBPNG to compile directive, and modified pngconf.h
- to include png_conf.h only when PNG_BUILDING_LIBPNG is defined.
-
-Version 1.2.10beta2 [April 15, 2006]
- Manually updated Makefile.in and configure. Changed png_conf.h.in
- back to config.h.
-
-Version 1.2.10beta3 [April 15, 2006]
- Change png_conf.h back to config.h in pngconf.h.
-
-Version 1.2.10beta4 [April 16, 2006]
- Change PNG_BUILDING_LIBPNG to PNG_CONFIGURE_LIBPNG in config/Makefile*.
-
-Version 1.2.10beta5 [April 16, 2006]
- Added a configure check for compiling assembler code in pnggccrd.c
-
-Version 1.2.10beta6 [April 17, 2006]
- Revised the configure check for pnggccrd.c
- Moved -DPNG_CONFIGURE_LIBPNG into @LIBPNG_DEFINES@
- Added @LIBPNG_DEFINES@ to arguments when building libpng.sym
-
-Version 1.2.10beta7 [April 18, 2006]
- Change "exec_prefix=$prefix" to "exec_prefix=$(prefix)" in makefiles.
-
-Version 1.2.10rc1 [April 19, 2006]
- Ensure pngconf.h doesn't define both PNG_USE_PNGGCCRD and PNG_USE_PNGVCRD
- Fixed "LN_FS" typo in makefile.sco and makefile.solaris.
-
-Version 1.2.10rc2 [April 20, 2006]
- Added a backslash between -DPNG_CONFIGURE_LIBPNG and -DPNG_NO_ASSEMBLER_CODE
- in configure.ac and configure
- Made the configure warning about versioned symbols less arrogant.
-
-Version 1.2.10rc3 [April 21, 2006]
- Added a note in libpng.txt that png_set_sig_bytes(8) can be used when
- writing an embedded PNG without the 8-byte signature.
- Revised makefiles and configure to avoid making links to libpng.so.*
-
-Version 1.2.10 [April 23, 2006]
- Reverted configure to "rc2" state.
-
-Version 1.2.11beta1 [May 31, 2006]
- scripts/libpng.pc.in contained "configure" style version info and would
- not work with makefiles.
- The shared-library makefiles were linking to libpng.so.0 instead of
- libpng.so.3 compatibility as the library.
-
-Version 1.2.11beta2 [June 2, 2006]
- Increased sprintf buffer from 50 to 52 chars in pngrutil.c to avoid
- buffer overflow.
- Fixed bug in example.c (png_set_palette_rgb -> png_set_palette_to_rgb)
-
-Version 1.2.11beta3 [June 5, 2006]
- Prepended "#! /bin/sh" to ltmail.sh and contrib/pngminus/*.sh (Cosmin).
- Removed the accidental leftover Makefile.in~ (Cosmin).
- Avoided potential buffer overflow and optimized buffer in
- png_write_sCAL(), png_write_sCAL_s() (Cosmin).
- Removed the include directories and libraries from CFLAGS and LDFLAGS
- in scripts/makefile.gcc (Nelson A. de Oliveira, Cosmin).
-
-Version 1.2.11beta4 [June 6, 2006]
- Allow zero-length IDAT chunks after the entire zlib datastream, but not
- after another intervening chunk type.
-
-Version 1.0.19rc1, 1.2.11rc1 [June 13, 2006]
- Deleted extraneous square brackets from [config.h] in configure.ac
-
-Version 1.0.19rc2, 1.2.11rc2 [June 14, 2006]
- Added prototypes for PNG_INCH_CONVERSIONS functions to png.h
- Revised INSTALL and autogen.sh
- Fixed typo in several makefiles (-W1 should be -Wl)
- Added typedef for png_int_32 and png_uint_32 on 64-bit systems.
-
-Version 1.0.19rc3, 1.2.11rc3 [June 15, 2006]
- Removed the new typedefs for 64-bit systems (delay until version 1.4.0)
- Added one zero element to png_gamma_shift[] array in pngrtran.c to avoid
- reading out of bounds.
-
-Version 1.0.19rc4, 1.2.11rc4 [June 15, 2006]
- Really removed the new typedefs for 64-bit systems.
-
-Version 1.0.19rc5, 1.2.11rc5 [June 22, 2006]
- Removed png_sig_bytes entry from scripts/pngw32.def
-
-Version 1.0.19, 1.2.11 [June 26, 2006]
- None.
-
-Version 1.0.20, 1.2.12 [June 27, 2006]
- Really increased sprintf buffer from 50 to 52 chars in pngrutil.c to avoid
- buffer overflow.
-
-Version 1.2.13beta1 [October 2, 2006]
- Removed AC_FUNC_MALLOC from configure.ac
- Work around Intel-Mac compiler bug by setting PNG_NO_MMX_CODE in pngconf.h
- Change "logical" to "bitwise" throughout documentation.
- Detect and fix attempt to write wrong iCCP profile length (CVE-2006-7244)
-
-Version 1.0.21, 1.2.13 [November 14, 2006]
- Fix potential buffer overflow in sPLT chunk handler.
- Fix Makefile.am to not try to link to noexistent files.
- Check all exported functions for NULL png_ptr.
-
-Version 1.2.14beta1 [November 17, 2006]
- Relocated three misplaced tests for NULL png_ptr.
- Built Makefile.in with automake-1.9.6 instead of 1.9.2.
- Build configure with autoconf-2.60 instead of 2.59
-
-Version 1.2.14beta2 [November 17, 2006]
- Added some typecasts in png_zalloc().
-
-Version 1.2.14rc1 [November 20, 2006]
- Changed "strtod" to "png_strtod" in pngrutil.c
-
-Version 1.0.22, 1.2.14 [November 27, 2006]
- Added missing "$(srcdir)" in Makefile.am and Makefile.in
-
-Version 1.2.15beta1 [December 3, 2006]
- Generated configure with autoconf-2.61 instead of 2.60
- Revised configure.ac to update libpng.pc and libpng-config.
-
-Version 1.2.15beta2 [December 3, 2006]
- Always export MMX asm functions, just stubs if not building pnggccrd.c
-
-Version 1.2.15beta3 [December 4, 2006]
- Add "png_bytep" typecast to profile while calculating length in pngwutil.c
-
-Version 1.2.15beta4 [December 7, 2006]
- Added scripts/CMakeLists.txt
- Changed PNG_NO_ASSEMBLER_CODE to PNG_NO_MMX_CODE in scripts, like 1.4.0beta
-
-Version 1.2.15beta5 [December 7, 2006]
- Changed some instances of PNG_ASSEMBLER_* to PNG_MMX_* in pnggccrd.c
- Revised scripts/CMakeLists.txt
-
-Version 1.2.15beta6 [December 13, 2006]
- Revised scripts/CMakeLists.txt and configure.ac
-
-Version 1.2.15rc1 [December 18, 2006]
- Revised scripts/CMakeLists.txt
-
-Version 1.2.15rc2 [December 21, 2006]
- Added conditional #undef jmpbuf in pngtest.c to undo #define in AIX headers.
- Added scripts/makefile.nommx
-
-Version 1.2.15rc3 [December 25, 2006]
- Fixed shared library numbering error that was introduced in 1.2.15beta6.
-
-Version 1.2.15rc4 [December 27, 2006]
- Fixed handling of rgb_to_gray when png_ptr->color.gray isn't set.
-
-Version 1.2.15rc5 [December 31, 2006]
- Revised handling of rgb_to_gray.
-
-Version 1.2.15 [January 5, 2007]
- Added some (unsigned long) typecasts in pngtest.c to avoid printing errors.
-
-Version 1.2.16beta1 [January 6, 2007]
- Fix bugs in makefile.nommx
-
-Version 1.2.16beta2 [January 16, 2007]
- Revised scripts/CMakeLists.txt
-
-Version 1.2.16 [January 31, 2007]
- No changes.
-
-Version 1.2.17beta1 [March 6, 2007]
- Revised scripts/CMakeLists.txt to install both shared and static libraries.
- Deleted a redundant line from pngset.c.
-
-Version 1.2.17beta2 [April 26, 2007]
- Relocated misplaced test for png_ptr == NULL in pngpread.c
- Change "==" to "&" for testing PNG_RGB_TO_GRAY_ERR & PNG_RGB_TO_GRAY_WARN
- flags.
- Changed remaining instances of PNG_ASSEMBLER_* to PNG_MMX_*
- Added pngerror() when write_IHDR fails in deflateInit2().
- Added "const" to some array declarations.
- Mention examples of libpng usage in the libpng*.txt and libpng.3 documents.
-
-Version 1.2.17rc1 [May 4, 2007]
- No changes.
-
-Version 1.2.17rc2 [May 8, 2007]
- Moved several PNG_HAVE_* macros out of PNG_INTERNAL because applications
- calling set_unknown_chunk_location() need them.
- Changed transformation flag from PNG_EXPAND_tRNS to PNG_EXPAND in
- png_set_expand_gray_1_2_4_to_8().
- Added png_ptr->unknown_chunk to hold working unknown chunk data, so it
- can be free'ed in case of error. Revised unknown chunk handling in
- pngrutil.c and pngpread.c to use this structure.
-
-Version 1.2.17rc3 [May 8, 2007]
- Revised symbol-handling in configure script.
-
-Version 1.2.17rc4 [May 10, 2007]
- Revised unknown chunk handling to avoid storing unknown critical chunks.
-
-Version 1.0.25 [May 15, 2007]
-Version 1.2.17 [May 15, 2007]
- Added "png_ptr->num_trans=0" before error return in png_handle_tRNS,
- to eliminate a vulnerability (CVE-2007-2445, CERT VU#684664)
-
-Version 1.0.26 [May 15, 2007]
-Version 1.2.18 [May 15, 2007]
- Reverted the libpng-1.2.17rc3 change to symbol-handling in configure script
-
-Version 1.2.19beta1 [May 18, 2007]
- Changed "const static" to "static PNG_CONST" everywhere, mostly undoing
- change of libpng-1.2.17beta2. Changed other "const" to "PNG_CONST"
- Changed some handling of unused parameters, to avoid compiler warnings.
- "if (unused == NULL) return;" becomes "unused = unused".
-
-Version 1.2.19beta2 [May 18, 2007]
- Only use the valid bits of tRNS value in png_do_expand() (Brian Cartier)
-
-Version 1.2.19beta3 [May 19, 2007]
- Add some "png_byte" typecasts in png_check_keyword() and write new_key
- instead of key in zTXt chunk (Kevin Ryde).
-
-Version 1.2.19beta4 [May 21, 2007]
- Add png_snprintf() function and use it in place of sprint() for improved
- defense against buffer overflows.
-
-Version 1.2.19beta5 [May 21, 2007]
- Fixed png_handle_tRNS() to only use the valid bits of tRNS value.
- Changed handling of more unused parameters, to avoid compiler warnings.
- Removed some PNG_CONST in pngwutil.c to avoid compiler warnings.
-
-Version 1.2.19beta6 [May 22, 2007]
- Added some #ifdef PNG_MMX_CODE_SUPPORTED where needed in pngvcrd.c
- Added a special "_MSC_VER" case that defines png_snprintf to _snprintf
-
-Version 1.2.19beta7 [May 22, 2007]
- Squelched png_squelch_warnings() in pnggccrd.c and added
- an #ifdef PNG_MMX_CODE_SUPPORTED block around the declarations that caused
- the warnings that png_squelch_warnings was squelching.
-
-Version 1.2.19beta8 [May 22, 2007]
- Removed __MMX__ from test in pngconf.h.
-
-Version 1.2.19beta9 [May 23, 2007]
- Made png_squelch_warnings() available via PNG_SQUELCH_WARNINGS macro.
- Revised png_squelch_warnings() so it might work.
- Updated makefile.sgcc and makefile.solaris; added makefile.solaris-x86.
-
-Version 1.2.19beta10 [May 24, 2007]
- Resquelched png_squelch_warnings(), use "__attribute__((used))" instead.
-
-Version 1.4.0beta1 [April 20, 2006]
- Enabled iTXt support (changes png_struct, thus requires so-number change).
- Cleaned up PNG_ASSEMBLER_CODE_SUPPORTED vs PNG_MMX_CODE_SUPPORTED
- Eliminated PNG_1_0_X and PNG_1_2_X macros.
- Removed deprecated functions png_read_init, png_write_init, png_info_init,
- png_permit_empty_plte, png_set_gray_1_2_4_to_8, png_check_sig, and
- removed the deprecated macro PNG_MAX_UINT.
- Moved "PNG_INTERNAL" parts of png.h and pngconf.h into pngintrn.h
- Removed many WIN32_WCE #ifdefs (Cosmin).
- Reduced dependency on C-runtime library when on Windows (Simon-Pierre)
- Replaced sprintf() with png_sprintf() (Simon-Pierre)
-
-Version 1.4.0beta2 [April 20, 2006]
- Revised makefiles and configure to avoid making links to libpng.so.*
- Moved some leftover MMX-related defines from pngconf.h to pngintrn.h
- Updated scripts/pngos2.def, pngw32.def, and projects/wince/png32ce.def
-
-Version 1.4.0beta3 [May 10, 2006]
- Updated scripts/pngw32.def to comment out MMX functions.
- Added PNG_NO_GET_INT_32 and PNG_NO_SAVE_INT_32 macros.
- Scripts/libpng.pc.in contained "configure" style version info and would
- not work with makefiles.
- Revised pngconf.h and added pngconf.h.in, so makefiles and configure can
- pass defines to libpng and applications.
-
-Version 1.4.0beta4 [May 11, 2006]
- Revised configure.ac, Makefile.am, and many of the makefiles to write
- their defines in pngconf.h.
-
-Version 1.4.0beta5 [May 15, 2006]
- Added a missing semicolon in Makefile.am and Makefile.in
- Deleted extraneous square brackets from configure.ac
-
-Version 1.4.0beta6 [June 2, 2006]
- Increased sprintf buffer from 50 to 52 chars in pngrutil.c to avoid
- buffer overflow.
- Changed sonum from 0 to 1.
- Removed unused prototype for png_check_sig() from png.h
-
-Version 1.4.0beta7 [June 16, 2006]
- Exported png_write_sig (Cosmin).
- Optimized buffer in png_handle_cHRM() (Cosmin).
- Set pHYs = 2835 x 2835 pixels per meter, and added
- sCAL = 0.352778e-3 x 0.352778e-3 meters, in pngtest.png (Cosmin).
- Added png_set_benign_errors(), png_benign_error(), png_chunk_benign_error().
- Added typedef for png_int_32 and png_uint_32 on 64-bit systems.
- Added "(unsigned long)" typecast on png_uint_32 variables in printf lists.
-
-Version 1.4.0beta8 [June 22, 2006]
- Added demonstration of user chunk support in pngtest.c, to support the
- public sTER chunk and a private vpAg chunk.
-
-Version 1.4.0beta9 [July 3, 2006]
- Removed ordinals from scripts/pngw32.def and removed png_info_int and
- png_set_gray_1_2_4_to_8 entries.
- Inline call of png_get_uint_32() in png_get_uint_31().
- Use png_get_uint_31() to get vpAg width and height in pngtest.c
- Removed WINCE and Netware projects.
- Removed standalone Y2KINFO file.
-
-Version 1.4.0beta10 [July 12, 2006]
- Eliminated automatic copy of pngconf.h to pngconf.h.in from configure and
- some makefiles, because it was not working reliably. Instead, distribute
- pngconf.h.in along with pngconf.h and cause configure and some of the
- makefiles to update pngconf.h from pngconf.h.in.
- Added pngconf.h to DEPENDENCIES in Makefile.am
-
-Version 1.4.0beta11 [August 19, 2006]
- Removed AC_FUNC_MALLOC from configure.ac.
- Added a warning when writing iCCP profile with mismatched profile length.
- Patched pnggccrd.c to assemble on x86_64 platforms.
- Moved chunk header reading into a separate function png_read_chunk_header()
- in pngrutil.c. The chunk header (len+sig) is now serialized in a single
- operation (Cosmin).
- Implemented support for I/O states. Added png_ptr member io_state, and
- functions png_get_io_chunk_name() and png_get_io_state() in pngget.c
- (Cosmin).
- Added png_get_io_chunk_name and png_get_io_state to scripts/*.def (Cosmin).
- Renamed scripts/pngw32.* to scripts/pngwin.* (Cosmin).
- Removed the include directories and libraries from CFLAGS and LDFLAGS
- in scripts/makefile.gcc (Cosmin).
- Used png_save_uint_32() to set vpAg width and height in pngtest.c (Cosmin).
- Cast to proper type when getting/setting vpAg units in pngtest.c (Cosmin).
- Added pngintrn.h to the Visual C++ projects (Cosmin).
- Removed scripts/list (Cosmin).
- Updated copyright year in scripts/pngwin.def (Cosmin).
- Removed PNG_TYPECAST_NULL and used standard NULL consistently (Cosmin).
- Disallowed the user to redefine png_size_t, and enforced a consistent use
- of png_size_t across libpng (Cosmin).
- Changed the type of png_ptr->rowbytes, PNG_ROWBYTES() and friends
- to png_size_t (Cosmin).
- Removed png_convert_size() and replaced png_sizeof with sizeof (Cosmin).
- Removed some unnecessary type casts (Cosmin).
- Changed prototype of png_get_compression_buffer_size() and
- png_set_compression_buffer_size() to work with png_size_t instead of
- png_uint_32 (Cosmin).
- Removed png_memcpy_check() and png_memset_check() (Cosmin).
- Fixed a typo (png_byte --> png_bytep) in libpng.3 and libpng.txt (Cosmin).
- Clarified that png_zalloc() does not clear the allocated memory,
- and png_zalloc() and png_zfree() cannot be PNGAPI (Cosmin).
- Renamed png_mem_size_t to png_alloc_size_t, fixed its definition in
- pngconf.h, and used it in all memory allocation functions (Cosmin).
- Renamed pngintrn.h to pngpriv.h, added a comment at the top of the file
- mentioning that the symbols declared in that file are private, and
- updated the scripts and the Visual C++ projects accordingly (Cosmin).
- Removed circular references between pngconf.h and pngconf.h.in in
- scripts/makefile.vc*win32 (Cosmin).
- Removing trailing '.' from the warning and error messages (Cosmin).
- Added pngdefs.h that is built by makefile or configure, instead of
- pngconf.h.in (Glenn).
- Detect and fix attempt to write wrong iCCP profile length.
-
-Version 1.4.0beta12 [October 19, 2006]
- Changed "logical" to "bitwise" in the documentation.
- Work around Intel-Mac compiler bug by setting PNG_NO_MMX_CODE in pngconf.h
- Add a typecast to stifle compiler warning in pngrutil.c
-
-Version 1.4.0beta13 [November 10, 2006]
- Fix potential buffer overflow in sPLT chunk handler.
- Fix Makefile.am to not try to link to noexistent files.
-
-Version 1.4.0beta14 [November 15, 2006]
- Check all exported functions for NULL png_ptr.
-
-Version 1.4.0beta15 [November 17, 2006]
- Relocated two misplaced tests for NULL png_ptr.
- Built Makefile.in with automake-1.9.6 instead of 1.9.2.
- Build configure with autoconf-2.60 instead of 2.59
- Add "install: all" in Makefile.am so "configure; make install" will work.
-
-Version 1.4.0beta16 [November 17, 2006]
- Added a typecast in png_zalloc().
-
-Version 1.4.0beta17 [December 4, 2006]
- Changed "new_key[79] = '\0';" to "(*new_key)[79] = '\0';" in pngwutil.c
- Add "png_bytep" typecast to profile while calculating length in pngwutil.c
-
-Version 1.4.0beta18 [December 7, 2006]
- Added scripts/CMakeLists.txt
-
-Version 1.4.0beta19 [May 16, 2007]
- Revised scripts/CMakeLists.txt
- Rebuilt configure and Makefile.in with newer tools.
- Added conditional #undef jmpbuf in pngtest.c to undo #define in AIX headers.
- Added scripts/makefile.nommx
-
-Version 1.4.0beta20 [July 9, 2008]
- Moved several PNG_HAVE_* macros from pngpriv.h to png.h because applications
- calling set_unknown_chunk_location() need them.
- Moved several macro definitions from pngpriv.h to pngconf.h
- Merge with changes to the 1.2.X branch, as of 1.2.30beta04.
- Deleted all use of the MMX assembler code and Intel-licensed optimizations.
- Revised makefile.mingw
-
-Version 1.4.0beta21 [July 21, 2008]
- Moved local array "chunkdata" from pngrutil.c to the png_struct, so
- it will be freed by png_read_destroy() in case of a read error (Kurt
- Christensen).
-
-Version 1.4.0beta22 [July 21, 2008]
- Change "purpose" and "buffer" to png_ptr->chunkdata to avoid memory leaking.
-
-Version 1.4.0beta23 [July 22, 2008]
- Change "chunkdata = NULL" to "png_ptr->chunkdata = NULL" several places in
- png_decompress_chunk().
-
-Version 1.4.0beta24 [July 25, 2008]
- Change all remaining "chunkdata" to "png_ptr->chunkdata" in
- png_decompress_chunk(), and remove "chunkdata" from parameter list.
- Put a call to png_check_chunk_name() in png_read_chunk_header().
- Revised png_check_chunk_name() to reject a name with a lowercase 3rd byte.
- Removed two calls to png_check_chunk_name() occurring later in the process.
- Define PNG_NO_ERROR_NUMBERS by default in pngconf.h
-
-Version 1.4.0beta25 [July 30, 2008]
- Added a call to png_check_chunk_name() in pngpread.c
- Reverted png_check_chunk_name() to accept a name with a lowercase 3rd byte.
- Added png_push_have_buffer() function to pngpread.c
- Eliminated PNG_BIG_ENDIAN_SUPPORTED and associated png_get_* macros.
- Made inline expansion of png_get_*() optional with PNG_USE_READ_MACROS.
- Eliminated all PNG_USELESS_TESTS and PNG_CORRECT_PALETTE_SUPPORTED code.
- Synced contrib directory and configure files with libpng-1.2.30beta06.
- Eliminated no-longer-used pngdefs.h (but it's still built in the makefiles)
- Relocated a misplaced "#endif /* PNG_NO_WRITE_FILTER */" in pngwutil.c
-
-Version 1.4.0beta26 [August 4, 2008]
- Removed png_push_have_buffer() function in pngpread.c. It increased the
- compiled library size slightly.
- Changed "-Wall" to "-W -Wall" in the CFLAGS in all makefiles (Cosmin Truta)
- Declared png_ptr "volatile" in pngread.c and pngwrite.c to avoid warnings.
- Updated contrib/visupng/cexcept.h to version 2.0.1
- Added PNG_LITERAL_CHARACTER macros for #, [, and ].
-
-Version 1.4.0beta27 [August 5, 2008]
- Revised usage of PNG_LITERAL_SHARP in pngerror.c.
- Moved newline character from individual png_debug messages into the
- png_debug macros.
- Allow user to #define their own png_debug, png_debug1, and png_debug2.
-
-Version 1.4.0beta28 [August 5, 2008]
- Revised usage of PNG_LITERAL_SHARP in pngerror.c.
- Added PNG_STRING_NEWLINE macro
-
-Version 1.4.0beta29 [August 9, 2008]
- Revised usage of PNG_STRING_NEWLINE to work on non-ISO compilers.
- Added PNG_STRING_COPYRIGHT macro.
- Added non-ISO versions of png_debug macros.
-
-Version 1.4.0beta30 [August 14, 2008]
- Added premultiplied alpha feature (Volker Wiendl).
-
-Version 1.4.0beta31 [August 18, 2008]
- Moved png_set_premultiply_alpha from pngtrans.c to pngrtran.c
- Removed extra crc check at the end of png_handle_cHRM(). Bug introduced
- in libpng-1.4.0beta20.
-
-Version 1.4.0beta32 [August 19, 2008]
- Added PNG_WRITE_FLUSH_SUPPORTED block around new png_flush() call.
- Revised PNG_NO_STDIO version of png_write_flush()
-
-Version 1.4.0beta33 [August 20, 2008]
- Added png_get|set_chunk_cache_max() to limit the total number of sPLT,
- text, and unknown chunks that can be stored.
-
-Version 1.4.0beta34 [September 6, 2008]
- Shortened tIME_string to 29 bytes in pngtest.c
- Fixed off-by-one error introduced in png_push_read_zTXt() function in
- libpng-1.2.30beta04/pngpread.c (Harald van Dijk)
-
-Version 1.4.0beta35 [October 6, 2008]
- Changed "trans_values" to "trans_color".
- Changed so-number from 0 to 14. Some OS do not like 0.
- Revised makefile.darwin to fix shared library numbering.
- Change png_set_gray_1_2_4_to_8() to png_set_expand_gray_1_2_4_to_8()
- in example.c (debian bug report)
-
-Version 1.4.0beta36 [October 25, 2008]
- Sync with tEXt vulnerability fix in libpng-1.2.33rc02.
-
-Version 1.4.0beta37 [November 13, 2008]
- Added png_check_cHRM in png.c and moved checking from pngget.c, pngrutil.c,
- and pngwrite.c
-
-Version 1.4.0beta38 [November 22, 2008]
- Added check for zero-area RGB cHRM triangle in png_check_cHRM() and
- png_check_cHRM_fixed().
-
-Version 1.4.0beta39 [November 23, 2008]
- Revised png_warning() to write its message on standard output by default
- when warning_fn is NULL.
-
-Version 1.4.0beta40 [November 24, 2008]
- Eliminated png_check_cHRM(). Instead, always use png_check_cHRM_fixed().
- In png_check_cHRM_fixed(), ensure white_y is > 0, and removed redundant
- check for all-zero coordinates that is detected by the triangle check.
-
-Version 1.4.0beta41 [November 26, 2008]
- Fixed string vs pointer-to-string error in png_check_keyword().
- Rearranged test expressions in png_check_cHRM_fixed() to avoid internal
- overflows.
- Added PNG_NO_CHECK_cHRM conditional.
-
-Version 1.4.0beta42, 43 [December 1, 2008]
- Merge png_debug with version 1.2.34beta04.
-
-Version 1.4.0beta44 [December 6, 2008]
- Removed redundant check for key==NULL before calling png_check_keyword()
- to ensure that new_key gets initialized and removed extra warning
- (Merge with version 1.2.34beta05 -- Arvan Pritchard).
-
-Version 1.4.0beta45 [December 9, 2008]
- In png_write_png(), respect the placement of the filler bytes in an earlier
- call to png_set_filler() (Jim Barry).
-
-Version 1.4.0beta46 [December 10, 2008]
- Undid previous change and added PNG_TRANSFORM_STRIP_FILLER_BEFORE and
- PNG_TRANSFORM_STRIP_FILLER_AFTER conditionals and deprecated
- PNG_TRANSFORM_STRIP_FILLER (Jim Barry).
-
-Version 1.4.0beta47 [December 15, 2008]
- Support for dithering was disabled by default, because it has never
- been well tested and doesn't work very well. The code has not
- been removed, however, and can be enabled by building libpng with
- PNG_READ_DITHER_SUPPORTED defined.
-
-Version 1.4.0beta48 [February 14, 2009]
- Added new exported function png_calloc().
- Combined several instances of png_malloc(); png_memset() into png_calloc().
- Removed prototype for png_freeptr() that was added in libpng-1.4.0beta24
- but was never defined.
-
-Version 1.4.0beta49 [February 28, 2009]
- Added png_fileno() macro to pngconf.h, used in pngwio.c
- Corrected order of #ifdef's in png_debug definition in png.h
- Fixed bug introduced in libpng-1.4.0beta48 with the memset arguments
- for pcal_params.
- Fixed order of #ifdef directives in the png_debug defines in png.h
- (bug introduced in libpng-1.2.34/1.4.0beta29).
- Revised comments in png_set_read_fn() and png_set_write_fn().
-
-Version 1.4.0beta50 [March 18, 2009]
- Use png_calloc() instead of png_malloc() to allocate big_row_buf when
- reading an interlaced file, to avoid a possible UMR.
- Undid revision of PNG_NO_STDIO version of png_write_flush(). Users
- having trouble with fflush() can build with PNG_NO_WRITE_FLUSH defined
- or supply their own flush_fn() replacement.
- Revised libpng*.txt and png.h documentation about use of png_write_flush()
- and png_set_write_fn().
- Removed fflush() from pngtest.c.
- Added "#define PNG_NO_WRITE_FLUSH" to contrib/pngminim/encoder/pngusr.h
-
-Version 1.4.0beta51 [March 21, 2009]
- Removed new png_fileno() macro from pngconf.h .
-
-Version 1.4.0beta52 [March 27, 2009]
- Relocated png_do_chop() ahead of building gamma tables in pngrtran.c
- This avoids building 16-bit gamma tables unnecessarily.
- Removed fflush() from pngtest.c.
- Added "#define PNG_NO_WRITE_FLUSH" to contrib/pngminim/encoder/pngusr.h
- Added a section on differences between 1.0.x and 1.2.x to libpng.3/libpng.txt
-
-Version 1.4.0beta53 [April 1, 2009]
- Removed some remaining MMX macros from pngpriv.h
- Fixed potential memory leak of "new_name" in png_write_iCCP() (Ralph Giles)
-
-Version 1.4.0beta54 [April 13, 2009]
- Added "ifndef PNG_SKIP_SETJMP_CHECK" block in pngconf.h to allow
- application code writers to bypass the check for multiple inclusion
- of setjmp.h when they know that it is safe to ignore the situation.
- Eliminated internal use of setjmp() in pngread.c and pngwrite.c
- Reordered ancillary chunks in pngtest.png to be the same as what
- pngtest now produces, and made some cosmetic changes to pngtest output.
- Eliminated deprecated png_read_init_3() and png_write_init_3() functions.
-
-Version 1.4.0beta55 [April 15, 2009]
- Simplified error handling in pngread.c and pngwrite.c by putting
- the new png_read_cleanup() and png_write_cleanup() functions inline.
-
-Version 1.4.0beta56 [April 25, 2009]
- Renamed "user_chunk_data" to "my_user_chunk_data" in pngtest.c to suppress
- "shadowed declaration" warning from gcc-4.3.3.
- Renamed "gamma" to "png_gamma" in pngset.c to avoid "shadowed declaration"
- warning about a global "gamma" variable in math.h on some platforms.
-
-Version 1.4.0beta57 [May 2, 2009]
- Removed prototype for png_freeptr() that was added in libpng-1.4.0beta24
- but was never defined (again).
- Rebuilt configure scripts with autoconf-2.63 instead of 2.62
- Removed pngprefs.h and MMX from makefiles
-
-Version 1.4.0beta58 [May 14, 2009]
- Changed pngw32.def to pngwin.def in makefile.mingw (typo was introduced
- in beta57).
- Clarified usage of sig_bit versus sig_bit_p in example.c (Vincent Torri)
-
-Version 1.4.0beta59 [May 15, 2009]
- Reformatted sources in libpng style (3-space indentation, comment format)
- Fixed typo in libpng docs (PNG_FILTER_AVE should be PNG_FILTER_AVG)
- Added sections about the git repository and our coding style to the
- documentation
- Relocated misplaced #endif in pngwrite.c, sCAL chunk handler.
-
-Version 1.4.0beta60 [May 19, 2009]
- Conditionally compile png_read_finish_row() which is not used by
- progressive readers.
- Added contrib/pngminim/preader to demonstrate building minimal progressive
- decoder, based on contrib/gregbook with embedded libpng and zlib.
-
-Version 1.4.0beta61 [May 20, 2009]
- In contrib/pngminim/*, renamed "makefile.std" to "makefile", since there
- is only one makefile in those directories, and revised the README files
- accordingly.
- More reformatting of comments, mostly to capitalize sentences.
-
-Version 1.4.0beta62 [June 2, 2009]
- Added "#define PNG_NO_WRITE_SWAP" to contrib/pngminim/encoder/pngusr.h
- and "define PNG_NO_READ_SWAP" to decoder/pngusr.h and preader/pngusr.h
- Reformatted several remaining "else statement" into two lines.
- Added a section to the libpng documentation about using png_get_io_ptr()
- in configure scripts to detect the presence of libpng.
-
-Version 1.4.0beta63 [June 15, 2009]
- Revised libpng*.txt and libpng.3 to mention calling png_set_IHDR()
- multiple times and to specify the sample order in the tRNS chunk,
- because the ISO PNG specification has a typo in the tRNS table.
- Changed several PNG_UNKNOWN_CHUNK_SUPPORTED to
- PNG_HANDLE_AS_UNKNOWN_SUPPORTED, to make the png_set_keep mechanism
- available for ignoring known chunks even when not saving unknown chunks.
- Adopted preference for consistent use of "#ifdef" and "#ifndef" versus
- "#if defined()" and "if !defined()" where possible.
-
-Version 1.4.0beta64 [June 24, 2009]
- Eliminated PNG_LEGACY_SUPPORTED code.
- Moved the various unknown chunk macro definitions outside of the
- PNG_READ|WRITE_ANCILLARY_CHUNK_SUPPORTED blocks.
-
-Version 1.4.0beta65 [June 26, 2009]
- Added a reference to the libpng license in each file.
-
-Version 1.4.0beta66 [June 27, 2009]
- Refer to the libpng license instead of the libpng license in each file.
-
-Version 1.4.0beta67 [July 6, 2009]
- Relocated INVERT_ALPHA within png_read_png() and png_write_png().
- Added high-level API transform PNG_TRANSFORM_GRAY_TO_RGB.
- Added an "xcode" project to the projects directory (Alam Arias).
-
-Version 1.4.0beta68 [July 19, 2009]
- Avoid some tests in filter selection in pngwutil.c
-
-Version 1.4.0beta69 [July 25, 2009]
- Simplified the new filter-selection test. This runs faster in the
- common "PNG_ALL_FILTERS" and PNG_FILTER_NONE cases.
- Removed extraneous declaration from the new call to png_read_gray_to_rgb()
- (bug introduced in libpng-1.4.0beta67).
- Fixed up xcode project (Alam Arias)
- Added a prototype for png_64bit_product() in png.c
-
-Version 1.4.0beta70 [July 27, 2009]
- Avoid a possible NULL dereference in debug build, in png_set_text_2().
- (bug introduced in libpng-0.95, discovered by Evan Rouault)
-
-Version 1.4.0beta71 [July 29, 2009]
- Rebuilt configure scripts with autoconf-2.64.
-
-Version 1.4.0beta72 [August 1, 2009]
- Replaced *.tar.lzma with *.tar.xz in distribution. Get the xz codec
- from <http://tukaani.org/xz>.
-
-Version 1.4.0beta73 [August 1, 2009]
- Reject attempt to write iCCP chunk with negative embedded profile length
- (JD Chen) (CVE-2009-5063).
-
-Version 1.4.0beta74 [August 8, 2009]
- Changed png_ptr and info_ptr member "trans" to "trans_alpha".
-
-Version 1.4.0beta75 [August 21, 2009]
- Removed an extra png_debug() recently added to png_write_find_filter().
- Fixed incorrect #ifdef in pngset.c regarding unknown chunk support.
-
-Version 1.4.0beta76 [August 22, 2009]
- Moved an incorrectly located test in png_read_row() in pngread.c
-
-Version 1.4.0beta77 [August 27, 2009]
- Removed lpXYZ.tar.bz2 (with CRLF), KNOWNBUG, libpng-x.y.z-KNOWNBUG.txt,
- and the "noconfig" files from the distribution.
- Moved CMakeLists.txt from scripts into the main libpng directory.
- Various bugfixes and improvements to CMakeLists.txt (Philip Lowman)
-
-Version 1.4.0beta78 [August 31, 2009]
- Converted all PNG_NO_* tests to PNG_*_SUPPORTED everywhere except pngconf.h
- Eliminated PNG_NO_FREE_ME and PNG_FREE_ME_SUPPORTED macros.
- Use png_malloc plus a loop instead of png_calloc() to initialize
- row_pointers in png_read_png().
-
-Version 1.4.0beta79 [September 1, 2009]
- Eliminated PNG_GLOBAL_ARRAYS and PNG_LOCAL_ARRAYS; always use local arrays.
- Eliminated PNG_CALLOC_SUPPORTED macro and always provide png_calloc().
-
-Version 1.4.0beta80 [September 17, 2009]
- Removed scripts/libpng.icc
- Changed typecast of filler from png_byte to png_uint_16 in png_set_filler().
- (Dennis Gustafsson)
- Fixed typo introduced in beta78 in pngtest.c ("#if def " should be "#ifdef ")
-
-Version 1.4.0beta81 [September 23, 2009]
- Eliminated unused PNG_FLAG_FREE_* defines from pngpriv.h
- Expanded TAB characters in pngrtran.c
- Removed PNG_CONST from all "PNG_CONST PNG_CHNK" declarations to avoid
- compiler complaints about doubly declaring things "const".
- Changed all "#if [!]defined(X)" to "if[n]def X" where possible.
- Eliminated unused png_ptr->row_buf_size
-
-Version 1.4.0beta82 [September 25, 2009]
- Moved redundant IHDR checking into new png_check_IHDR() in png.c
- and report all errors found in the IHDR data.
- Eliminated useless call to png_check_cHRM() from pngset.c
-
-Version 1.4.0beta83 [September 25, 2009]
- Revised png_check_IHDR() to eliminate bogus complaint about filter_type.
-
-Version 1.4.0beta84 [September 30, 2009]
- Fixed some inconsistent indentation in pngconf.h
- Revised png_check_IHDR() to add a test for width variable less than 32-bit.
-
-Version 1.4.0beta85 [October 1, 2009]
- Revised png_check_IHDR() again, to check info_ptr members instead of
- the contents of the returned parameters.
-
-Version 1.4.0beta86 [October 9, 2009]
- Updated the "xcode" project (Alam Arias).
- Eliminated a shadowed declaration of "pp" in png_handle_sPLT().
-
-Version 1.4.0rc01 [October 19, 2009]
- Trivial cosmetic changes.
-
-Version 1.4.0beta87 [October 30, 2009]
- Moved version 1.4.0 back into beta.
-
-Version 1.4.0beta88 [October 30, 2009]
- Revised libpng*.txt section about differences between 1.2.x and 1.4.0
- because most of the new features have now been ported back to 1.2.41
-
-Version 1.4.0beta89 [November 1, 2009]
- More bugfixes and improvements to CMakeLists.txt (Philip Lowman)
- Removed a harmless extra png_set_invert_alpha() from pngwrite.c
- Apply png_user_chunk_cache_max within png_decompress_chunk().
- Merged libpng-1.2.41.txt with libpng-1.4.0.txt where appropriate.
-
-Version 1.4.0beta90 [November 2, 2009]
- Removed all remaining WIN32_WCE #ifdefs except those involving the
- time.h "tm" structure
-
-Version 1.4.0beta91 [November 3, 2009]
- Updated scripts/pngw32.def and projects/wince/png32ce.def
- Copied projects/wince/png32ce.def to the scripts directory.
- Added scripts/makefile.wce
- Patched ltmain.sh for wince support.
- Added PNG_CONVERT_tIME_SUPPORTED macro.
-
-Version 1.4.0beta92 [November 4, 2009]
- Make inclusion of time.h in pngconf.h depend on PNG_CONVERT_tIME_SUPPORTED
- Make #define PNG_CONVERT_tIME_SUPPORTED depend on PNG_WRITE_tIME_SUPPORTED
- Revised libpng*.txt to describe differences from 1.2.40 to 1.4.0 (instead
- of differences from 1.2.41 to 1.4.0)
-
-Version 1.4.0beta93 [November 7, 2009]
- Added PNG_DEPSTRUCT, PNG_DEPRECATED, PNG_USE_RESULT, PNG_NORETURN, and
- PNG_ALLOCATED macros to detect deprecated direct access to the
- png_struct or info_struct members and other deprecated usage in
- applications (John Bowler).
- Updated scripts/makefile* to add "-DPNG_CONFIGURE_LIBPNG" to CFLAGS,
- to prevent warnings about direct access to png structs by libpng
- functions while building libpng. They need to be tested, especially
- those using compilers other than gcc.
- Updated projects/visualc6 and visualc71 with "/d PNG_CONFIGURE_LIBPNG".
- They should work but still need to be updated to remove
- references to pnggccrd.c or pngvcrd.c and ASM building.
- Added README.txt to the beos, cbuilder5, netware, and xcode projects warning
- that they need to be updated, to remove references to pnggccrd.c and
- pngvcrd.c and to depend on pngpriv.h
- Removed three direct references to read_info_ptr members in pngtest.c
- that were detected by the new PNG_DEPSTRUCT macro.
- Moved the png_debug macro definitions and the png_read_destroy(),
- png_write_destroy() and png_far_to_near() prototypes from png.h
- to pngpriv.h (John Bowler)
- Moved the synopsis lines for png_read_destroy(), png_write_destroy()
- png_debug(), png_debug1(), and png_debug2() from libpng.3 to libpngpf.3.
-
-Version 1.4.0beta94 [November 9, 2009]
- Removed the obsolete, unused pnggccrd.c and pngvcrd.c files.
- Updated CMakeLists.txt to add "-DPNG_CONFIGURE_LIBPNG" to the definitions.
- Removed dependency of pngtest.o on pngpriv.h in the makefiles.
- Only #define PNG_DEPSTRUCT, etc. in pngconf.h if not already defined.
-
-Version 1.4.0beta95 [November 10, 2009]
- Changed png_check_sig() to !png_sig_cmp() in contrib programs.
- Added -DPNG_CONFIGURE_LIBPNG to contrib/pngminm/*/makefile
- Changed png_check_sig() to !png_sig_cmp() in contrib programs.
- Corrected the png_get_IHDR() call in contrib/gregbook/readpng2.c
- Changed pngminim/*/gather.sh to stop trying to remove pnggccrd.c and pngvcrd.c
- Added dependency on pngpriv.h in contrib/pngminim/*/makefile
-
-Version 1.4.0beta96 [November 12, 2009]
- Renamed scripts/makefile.wce to scripts/makefile.cegcc
- Revised Makefile.am to use libpng.sys while building libpng.so
- so that only PNG_EXPORT functions are exported.
- Removed the deprecated png_check_sig() function/macro.
- Removed recently removed function names from scripts/*.def
- Revised pngtest.png to put chunks in the same order written by pngtest
- (evidently the same change made in libpng-1.0beta54 was lost).
- Added PNG_PRIVATE macro definition in pngconf.h for possible future use.
-
-Version 1.4.0beta97 [November 13, 2009]
- Restored pngtest.png to the libpng-1.4.0beta7 version.
- Removed projects/beos and netware.txt; no one seems to be supporting them.
- Revised Makefile.in
-
-Version 1.4.0beta98 [November 13, 2009]
- Added the "xcode" project to zip distributions,
- Fixed a typo in scripts/pngwin.def introduced in beta97.
-
-Version 1.4.0beta99 [November 14, 2009]
- Moved libpng-config.in and libpng.pc-configure.in out of the scripts
- directory, to libpng-config.in and libpng-pc.in, respectively, and
- modified Makefile.am and configure.ac accordingly. Now "configure"
- needs nothing from the "scripts" directory.
- Avoid redefining PNG_CONST in pngconf.h
-
-Version 1.4.0beta100 [November 14, 2009]
- Removed ASM builds from projects/visualc6 and projects/visualc71
- Removed scripts/makefile.nommx and makefile.vcawin32
- Revised CMakeLists.txt to account for new location of libpng-config.in
- and libpng-pc.in
- Updated INSTALL to reflect removal and relocation of files.
-
-Version 1.4.0beta101 [November 14, 2009]
- Restored the binary files (*.jpg, *.png, some project files) that were
- accidentally deleted from the zip and 7z distributions when the xcode
- project was added.
-
-Version 1.4.0beta102 [November 18, 2009]
- Added libpng-config.in and libpng-pc.in to the zip and 7z distributions.
- Fixed a typo in projects/visualc6/pngtest.dsp, introduced in beta100.
- Moved descriptions of makefiles and other scripts out of INSTALL into
- scripts/README.txt
- Updated the copyright year in scripts/pngwin.rc from 2006 to 2009.
-
-Version 1.4.0beta103 [November 21, 2009]
- Removed obsolete comments about ASM from projects/visualc71/README_zlib.txt
- Align row_buf on 16-byte boundary in memory.
- Restored the PNG_WRITE_FLUSH_AFTER_IEND_SUPPORTED guard around the call
- to png_flush() after png_write_IEND(). See 1.4.0beta32, 1.4.0beta50
- changes above and 1.2.30, 1.2.30rc01 and rc03 in 1.2.41 CHANGES. Someone
- needs this feature.
- Make the 'png_jmpbuf' macro expand to a call that records the correct
- longjmp function as well as returning a pointer to the setjmp
- jmp_buf buffer, and marked direct access to jmpbuf 'deprecated'.
- (John Bowler)
-
-Version 1.4.0beta104 [November 22, 2009]
- Removed png_longjmp_ptr from scripts/*.def and libpng.3
- Rebuilt configure scripts with autoconf-2.65
-
-Version 1.4.0beta105 [November 25, 2009]
- Use fast integer PNG_DIVIDE_BY_255() or PNG_DIVIDE_BY_65535()
- to accomplish alpha premultiplication when
- PNG_READ_COMPOSITE_NODIV_SUPPORTED is defined.
- Changed "/255" to "/255.0" in background calculations to make it clear
- that the 255 is used as a double.
-
-Version 1.4.0beta106 [November 27, 2009]
- Removed premultiplied alpha feature.
-
-Version 1.4.0beta107 [December 4, 2009]
- Updated README
- Added "#define PNG_NO_PEDANTIC_WARNINGS" in the libpng source files.
- Removed "-DPNG_CONFIGURE_LIBPNG" from the makefiles and projects.
- Revised scripts/makefile.netbsd, makefile.openbsd, and makefile.sco
- to put png.h and pngconf.h in $prefix/include, like the other scripts,
- instead of in $prefix/include/libpng. Also revised makefile.sco
- to put them in $prefix/include/libpng15 instead of in
- $prefix/include/libpng/libpng15.
-
-Version 1.4.0beta108 [December 11, 2009]
- Removed leftover "-DPNG_CONFIGURE_LIBPNG" from contrib/pngminim/*/makefile
- Relocated png_do_chop() to its original position in pngrtran.c; the
- change in version 1.2.41beta08 caused transparency to be handled wrong
- in some 16-bit datastreams (Yusaku Sugai).
-
-Version 1.4.0beta109 [December 13, 2009]
- Added "bit_depth" parameter to the private png_build_gamma_table() function.
- Pass bit_depth=8 to png_build_gamma_table() when bit_depth is 16 but the
- PNG_16_TO_8 transform has been set, to avoid unnecessary build of 16-bit
- tables.
-
-Version 1.4.0rc02 [December 20, 2009]
- Declared png_cleanup_needed "volatile" in pngread.c and pngwrite.c
-
-Version 1.4.0rc03 [December 22, 2009]
- Renamed libpng-pc.in back to libpng.pc.in and revised CMakeLists.txt
- (revising the change in 1.4.0beta99)
-
-Version 1.4.0rc04 [December 25, 2009]
- Swapped PNG_UNKNOWN_CHUNKS_SUPPORTED and PNG_HANDLE_AS_UNKNOWN_SUPPORTED
- in pngset.c to be consistent with other changes in version 1.2.38.
-
-Version 1.4.0rc05 [December 25, 2009]
- Changed "libpng-pc.in" to "libpng.pc.in" in configure.ac, configure, and
- Makefile.in to be consistent with changes in libpng-1.4.0rc03
-
-Version 1.4.0rc06 [December 29, 2009]
- Reverted the gamma_table changes from libpng-1.4.0beta109.
- Fixed some indentation errors.
-
-Version 1.4.0rc07 [January 1, 2010]
- Revised libpng*.txt and libpng.3 about 1.2.x->1.4.x differences.
- Use png_calloc() instead of png_malloc(); png_memset() in pngrutil.c
- Update copyright year to 2010.
-
-Version 1.4.0rc08 [January 2, 2010]
- Avoid deprecated references to png_ptr-io_ptr and png_ptr->error_ptr
- in pngtest.c
-
-Version 1.4.0 [January 3, 2010]
- No changes.
-
-Version 1.4.1beta01 [January 8, 2010]
- Updated CMakeLists.txt for consistent indentation and to avoid an
- unclosed if-statement warning (Philip Lowman).
- Revised Makefile.am and Makefile.in to remove references to Y2KINFO,
- KNOWNBUG, and libpng.la (Robert Schwebel).
- Revised the makefiles to install the same files and symbolic
- links as configure, except for libpng.la and libpng14.la.
- Make png_set|get_compression_buffer_size() available even when
- PNG_WRITE_SUPPORTED is not enabled.
- Revised Makefile.am and Makefile.in to simplify their maintenance.
- Revised scripts/makefile.linux to install a link to libpng14.so.14.1
-
-Version 1.4.1beta02 [January 9, 2010]
- Revised the rest of the makefiles to install a link to libpng14.so.14.1
-
-Version 1.4.1beta03 [January 10, 2010]
- Removed png_set_premultiply_alpha() from scripts/*.def
-
-Version 1.4.1rc01 [January 16, 2010]
- No changes.
-
-Version 1.4.1beta04 [January 23, 2010]
- Revised png_decompress_chunk() to improve speed and memory usage when
- decoding large chunks.
- Added png_set|get_chunk_malloc_max() functions.
-
-Version 1.4.1beta05 [January 26, 2010]
- Relocated "int k" declaration in pngtest.c to minimize its scope.
-
-Version 1.4.1beta06 [January 28, 2010]
- Revised png_decompress_chunk() to use a two-pass method suggested by
- John Bowler.
-
-Version 1.4.1beta07 [February 6, 2010]
- Folded some long lines in the source files.
- Added definable PNG_USER_CHUNK_CACHE_MAX, PNG_USER_CHUNK_MALLOC_MAX,
- and a PNG_USER_LIMITS_SUPPORTED flag.
- Eliminated use of png_ptr->irowbytes and reused the slot in png_ptr as
- png_ptr->png_user_chunk_malloc_max.
- Revised png_push_save_buffer() to do fewer but larger png_malloc() calls.
-
-Version 1.4.1beta08 [February 6, 2010]
- Minor cleanup and updating of dates and copyright year.
-
-Version 1.5.0beta01 [February 7, 2010]
- Moved declaration of png_struct into private pngstruct.h and png_info
- into pnginfo.h
-
-Version 1.4.1beta09 and 1.5.0beta02 [February 7, 2010]
- Reverted to original png_push_save_buffer() code.
-
-Version 1.4.1beta10 and 1.5.0beta03 [February 8, 2010]
- Return allocated "old_buffer" in png_push_save_buffer() before
- calling png_error(), to avoid a potential memory leak.
- Updated configure script to use SO number 15.
-
-Version 1.5.0beta04 [February 9, 2010]
- Removed malformed "incomplete struct declaration" of png_info from png.h
-
-Version 1.5.0beta05 [February 12, 2010]
- Removed PNG_DEPSTRUCT markup in pngstruct.h and pnginfo.h, and undid the
- linewrapping that it entailed.
- Revised comments in pngstruct.h and pnginfo.h and added pointers to
- the libpng license.
- Changed PNG_INTERNAL to PNG_EXPOSE_INTERNAL_STRUCTURES
- Removed the cbuilder5 project, which has not been updated to 1.4.0.
-
-Version 1.4.1beta12 and 1.5.0beta06 [February 14, 2010]
- Fixed type declaration of png_get_chunk_malloc_max() in pngget.c (Daisuke
- Nishikawa)
-
-Version 1.5.0beta07 [omitted]
-
-Version 1.5.0beta08 [February 19, 2010]
- Changed #ifdef PNG_NO_STDIO_SUPPORTED to #ifdef PNG_NO_CONSOLE_IO_SUPPORTED
- wherever png_snprintf() is used to construct error and warning messages.
- Noted in scripts/makefile.mingw that it expects to be run under MSYS.
- Removed obsolete unused MMX-querying support from contrib/gregbook
- Added exported png_longjmp() function.
- Removed the AIX redefinition of jmpbuf in png.h
- Added -D_ALLSOURCE in configure.ac, makefile.aix, and CMakeLists.txt
- when building on AIX.
-
-Version 1.5.0beta09 [February 19, 2010]
- Removed -D_ALLSOURCE from configure.ac, makefile.aix, and CMakeLists.txt.
- Changed the name of png_ptr->jmpbuf to png_ptr->png_jmpbuf in pngstruct.h
-
-Version 1.5.0beta10 [February 25, 2010]
- Removed unused gzio.c from contrib/pngminim gather and makefile scripts
- Removed replacement error handlers from contrib/gregbook. Because of
- the new png_longjmp() function they are no longer needed.
-
-Version 1.5.0beta11 [March 6, 2010]
- Removed checking for already-included setjmp.h from pngconf.h
- Fixed inconsistent indentations and made numerous cosmetic changes.
- Revised the "SEE ALSO" style of libpng.3, libpngpf.3, and png.5
-
-Version 1.5.0beta12 [March 9, 2010]
- Moved "#include png.h" inside pngpriv.h and removed "#include png.h" from
- the source files, along with "#define PNG_EXPOSE_INTERNAL_STRUCTURES"
- and "#define PNG_NO_PEDANTIC_WARNINGS" (John Bowler).
- Created new pngdebug.h and moved debug definitions there.
-
-Version 1.5.0beta13 [March 10, 2010]
- Protect pngstruct.h, pnginfo.h, and pngdebug.h from being included twice.
- Revise the "#ifdef" blocks in png_inflate() so it will compile when neither
- PNG_USER_CHUNK_MALLOC_MAX nor PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
- is defined.
- Removed unused png_measure_compressed_chunk() from pngpriv.h and libpngpf.3
- Moved the 'config.h' support from pngconf.h to pngpriv.h
- Removed PNGAPI from the png_longjmp_ptr typedef.
- Eliminated dependence of pngtest.c on the private pngdebug.h file.
- Make all png_debug macros into *unterminated* statements or
- expressions (i.e. a trailing ';' must always be added) and correct
- the format statements in various png_debug messages.
-
-Version 1.5.0beta14 [March 14, 2010]
- Removed direct access to png_ptr->io_ptr from the Windows code in pngtest.c
- Revised Makefile.am to account for recent additions and replacements.
- Corrected CE and OS/2 DEF files (scripts/png*def) for symbols removed and
- added ordinal numbers to the Windows DEF file and corrected the duplicated
- ordinal numbers on CE symbols that are commented out.
- Added back in export symbols that can be present in the Windows build but
- are disabled by default.
- PNG_EXPORT changed to include an 'ordinal' field for DEF file generation.
- PNG_CALLBACK added to make callback definitions uniform. PNGAPI split
- into PNGCAPI (base C form), PNGAPI (exports) and PNGCBAPI (callbacks),
- and appropriate changes made to all files. Cygwin builds re-hinged to
- allow procedure call standard changes and to remove the need for the DEF
- file (fixes build on Cygwin).
- Enabled 'attribute' warnings that are relevant to library APIs and callbacks.
- Changed rules for generation of the various symbol files and added a new
- rule for a DEF file (which is also added to the distribution).
- Updated the symbol file generation to stop it adding spurious spaces
- to EOL (coming from preprocessor macro expansion). Added a facility
- to join tokens in the output and rewrite *.dfn to use this.
- Eliminated scripts/*.def in favor of libpng.def; updated projects/visualc71
- and removed scripts/makefile.cygwin.
- Made PNG_BUILD_DLL safe: it can be set whenever a DLL is being built.
- Removed the include of sys/types.h - apparently unnecessary now on the
- platforms on which it happened (all but Mac OS and RISC OS).
- Moved the Mac OS test into pngpriv.h (the only place it is used.)
-
-Version 1.5.0beta15 [March 17, 2010]
- Added symbols.chk target to Makefile.am to validate the symbols in png.h
- against the new DEF file scripts/symbols.def.
- Changed the default DEF file back to pngwin.def.
- Removed makefile.mingw.
- Eliminated PNG_NO_EXTERN and PNG_ALL_EXTERN
-
-Version 1.5.0beta16 [April 1, 2010]
- Make png_text_struct independent of PNG_iTXt_SUPPORTED, so that
- fields are initialized in all configurations. The READ/WRITE
- macros (PNG_(READ|WRITE)_iTXt_SUPPORTED) still function as
- before to disable code to actually read or write iTXt chunks
- and iTXt_SUPPORTED can be used to detect presence of either
- read or write support (but it is probably better to check for
- the one actually required - read or write.)
- Combined multiple png_warning() calls for a single error.
- Restored the macro definition of png_check_sig().
-
-Version 1.5.0beta17 [April 17, 2010]
- Added some "(long)" typecasts to printf calls in png_handle_cHRM().
- Documented the fact that png_set_dither() was disabled since libpng-1.4.0.
- Reenabled png_set_dither() but renamed it to png_set_quantize() to reflect
- more accurately what it actually does. At the same time, renamed
- the PNG_DITHER_[RED,GREEN_BLUE]_BITS macros to
- PNG_QUANTIZE_[RED,GREEN,BLUE]_BITS.
- Added some "(long)" typecasts to printf calls in png_handle_cHRM().
- Freeze build-time only configuration in the build.
- In all prior versions of libpng most configuration options
- controlled by compiler #defines had to be repeated by the
- application code that used libpng. This patch changes this
- so that compilation options that can only be changed at build
- time are frozen in the build. Options that are compiler
- dependent (and those that are system dependent) are evaluated
- each time - pngconf.h holds these. Options that can be changed
- per-file in the application are in png.h. Frozen options are
- in the new installed header file pnglibconf.h (John Bowler)
- Removed the xcode project because it has not been updated to work
- with libpng-1.5.0.
- Removed the ability to include optional pngusr.h
-
-Version 1.5.0beta18 [April 17, 2010]
- Restored the ability to include optional pngusr.h
- Moved replacements for png_error() and png_warning() from the
- contrib/pngminim project to pngerror.c, for use when warnings or
- errors are disabled via PNG_NO_WARN or PNG_NO_ERROR_TEXT, to avoid
- storing unneeded error/warning text.
- Updated contrib/pngminim project to work with the new pnglibconf.h
- Added some PNG_NO_* defines to contrib/pngminim/*/pngusr.h to save space.
-
-Version 1.5.0beta19 [April 24, 2010]
- Added PNG_{READ,WRITE}_INT_FUNCTIONS_SUPPORTED. This allows the functions
- to read and write ints to be disabled independently of PNG_USE_READ_MACROS,
- which allows libpng to be built with the functions even though the default
- is to use the macros - this allows applications to choose at app build
- time whether or not to use macros (previously impossible because the
- functions weren't in the default build.)
- Changed Windows calling convention back to __cdecl for API functions.
- For Windows/x86 platforms only:
- __stdcall is no longer needed for Visual Basic, so libpng-1.5.0 uses
- __cdecl throughout (both API functions and callbacks) on Windows/x86
- platforms.
- Replaced visualc6 and visualc71 projects with new vstudio project
- Relaxed the overly-restrictive permissions of some files.
-
-Version 1.5.0beta20 [April 24, 2010]
- Relaxed more overly-restrictive permissions of some files.
-
-Version 1.5.0beta21 [April 27, 2010]
- Removed some unwanted binary bytes and changed CRLF to NEWLINE in the new
- vstudio project files, and some trivial editing of some files in the
- scripts directory.
- Set PNG_NO_READ_BGR, PNG_NO_IO_STATE, and PNG_NO_TIME_RFC1123 in
- contrib/pngminim/decoder/pngusr.h to make a smaller decoder application.
-
-Version 1.5.0beta22 [April 28, 2010]
- Fixed dependencies of GET_INT_32 - it does not require READ_INT_FUNCTIONS
- because it has a macro equivalent.
- Improved the options.awk script; added an "everything off" option.
- Revised contrib/pngminim to use the "everything off" option in pngusr.dfa.
-
-Version 1.5.0beta23 [April 29, 2010]
- Corrected PNG_REMOVED macro to take five arguments.
- The macro was documented with two arguments (name,ordinal), however
- the symbol checking .dfn files assumed five arguments. The five
- argument form seems more useful so it is changed to that.
- Corrected PNG_UNKNOWN_CHUNKS_SUPPORTED to PNG_HANDLE_AS_UNKNOWN_SUPPORTED
- in gregbook/readpng2.c
- Corrected protection of png_get_user_transform_ptr. The API declaration in
- png.h is removed if both READ and WRITE USER_TRANSFORM are turned off
- but was left defined in pngtrans.c
- Added logunsupported=1 to cause pnglibconf.h to document disabled options.
- This makes the installed pnglibconf.h more readable but causes no
- other change. The intention is that users of libpng will find it
- easier to understand if an API they need is missing.
- Include png_reset_zstream() in png.c only when PNG_READ_SUPPORTED is defined.
- Removed dummy_inflate.c from contrib/pngminim/encoder
- Removed contrib/pngminim/*/gather.sh; gathering is now done in the makefile.
-
-Version 1.5.0beta24 [May 7, 2010]
- Use bitwise "&" instead of arithmetic mod in pngrutil.c calculation of the
- offset of the png_ptr->rowbuf pointer into png_ptr->big_row_buf.
- Added more blank lines for readability.
-
-Version 1.5.0beta25 [June 18, 2010]
- In pngpread.c: png_push_have_row() add check for new_row > height
- Removed the now-redundant check for out-of-bounds new_row from example.c
-
-Version 1.5.0beta26 [June 18, 2010]
- In pngpread.c: png_push_process_row() add check for too many rows.
-
-Version 1.5.0beta27 [June 18, 2010]
- Removed the check added in beta25 as it is now redundant.
-
-Version 1.5.0beta28 [June 20, 2010]
- Rewrote png_process_IDAT_data to consistently treat extra data as warnings
- and handle end conditions more cleanly.
- Removed the new (beta26) check in png_push_process_row().
-
-Version 1.5.0beta29 [June 21, 2010]
- Revised scripts/options.awk to work on Sunos (but still doesn't work)
- Added comment to options.awk and contrib/pngminim/*/makefile to try nawk.
-
-Version 1.5.0beta30 [June 22, 2010]
- Stop memory leak when reading a malformed sCAL chunk.
-
-Version 1.5.0beta31 [June 26, 2010]
- Revised pngpread.c patch of beta28 to avoid an endless loop.
- Removed some trailing blanks.
-
-Version 1.5.0beta32 [June 26, 2010]
- Removed leftover scripts/options.patch and scripts/options.rej
-
-Version 1.5.0beta33 [July 6, 3010]
- Made FIXED and FLOATING options consistent in the APIs they enable and
- disable. Corrected scripts/options.awk to handle both command line
- options and options specified in the .dfa files.
- Changed char *msg to PNG_CONST char *msg in pngrutil.c
- Make png_set_sRGB_gAMA_and_cHRM set values using either the fixed or
- floating point APIs, but not both.
- Reversed patch to remove error handler when the jmp_buf is stored in the
- main program structure, not the png_struct.
- The error handler is needed because the default handler in libpng will
- always use the jmp_buf in the library control structure; this is never
- set. The gregbook code is a useful example because, even though it
- uses setjmp/longjmp, it shows how error handling can be implemented
- using control mechanisms not directly supported by libpng. The
- technique will work correctly with mechanisms such as Microsoft
- Structure Exceptions or C++ exceptions (compiler willing - note that gcc
- does not by default support interworking of C and C++ error handling.)
- Reverted changes to call png_longjmp in contrib/gregbook where it is not
- appropriate. If mainprog->jmpbuf is used by setjmp, then png_longjmp
- cannot be used.
- Changed "extern PNG_EXPORT" to "PNG_EXPORT" in png.h (Jan Nijtmans)
- Changed "extern" to "PNG_EXTERN" in pngpriv.h (except for the 'extern "C" {')
-
-Version 1.5.0beta34 [July 12, 2010]
- Put #ifndef PNG_EXTERN, #endif around the define PNG_EXTERN in pngpriv.h
-
-Version 1.5.0beta35 [July 24, 2010]
- Removed some newly-added TAB characters.
- Added -DNO_PNG_SNPRINTF to CFLAGS in scripts/makefile.dj2
- Moved the definition of png_snprintf() outside of the enclosing
- #ifdef blocks in pngconf.h
-
-Version 1.5.0beta36 [July 29, 2010]
- Patches by John Bowler:
- Fixed point APIs are now supported throughout (no missing APIs).
- Internal fixed point arithmetic support exists for all internal floating
- point operations.
- sCAL validates the floating point strings it is passed.
- Safe, albeit rudimentary, Watcom support is provided by PNG_API_RULE==2
- Two new APIs exist to get the number of passes without turning on the
- PNG_INTERLACE transform and to get the number of rows in the current
- pass.
- A new test program, pngvalid.c, validates the gamma code.
- Errors in the 16-bit gamma correction (overflows) have been corrected.
- cHRM chunk testing is done consistently (previously the floating point
- API bypassed it, because the test really didn't work on FP, now the test
- is performed on the actual values to be stored in the PNG file so it
- works in the FP case too.)
- Most floating point APIs now simply call the fixed point APIs after
- converting the values to the fixed point form used in the PNG file.
- The standard headers no longer include zlib.h, which is currently only
- required for pngstruct.h and can therefore be internal.
- Revised png_get_int_32 to undo the PNG two's complement representation of
- negative numbers.
-
-Version 1.5.0beta37 [July 30, 2010]
- Added a typecast in png_get_int_32() in png.h and pngrutil.h to avoid
- a compiler warning.
- Replaced oFFs 0,0 with oFFs -10,20 in pngtest.png
-
-Version 1.5.0beta38 [July 31, 2010]
- Implemented remaining "_fixed" functions.
- Corrected a number of recently introduced warnings mostly resulting from
- safe but uncast assignments to shorter integers. Also added a zlib
- VStudio release library project because the latest zlib Official Windows
- build does not include such a thing.
- Revised png_get_int_16() to be similar to png_get_int_32().
- Restored projects/visualc71.
-
-Version 1.5.0beta39 [August 2, 2010]
- VisualC/GCC warning fixes, VisualC build fixes
- The changes include support for function attributes in VC in addition to
- those already present in GCC - necessary because without these some
- warnings are unavoidable. Fixes include signed/unsigned fixes in
- pngvalid and checks with gcc -Wall -Wextra -Wunused.
- VC requires function attributes on function definitions as well as
- declarations, PNG_FUNCTION has been added to enable this and the
- relevant function definitions changed.
-
-Version 1.5.0beta40 [August 6, 2010]
- Correct use of _WINDOWS_ in pngconf.h
- Removed png_mem_ #defines; they are no longer used.
- Added the sRGB chunk to pngtest.png
-
-Version 1.5.0beta41 [August 11, 2010]
- Added the cHRM chunk to pngtest.png
- Don't try to use version-script with cygwin/mingw.
- Revised contrib/gregbook to work under cygwin/mingw.
-
-Version 1.5.0beta42 [August 18, 2010]
- Add .dll.a to the list of extensions to be symlinked by Makefile.am (Yaakov)
- Made all API functions that have const arguments and constant string
- literal pointers declare them (John Bowler).
-
-Version 1.5.0beta43 [August 20, 2010]
- Removed spurious tabs, shorten long lines (no source change)
- Also added scripts/chkfmt to validate the format of all the files that can
- reasonably be validated (it is suggested to run "make distclean" before
- checking, because some machine generated files have long lines.)
- Reformatted the CHANGES file to be more consistent throughout.
- Made changes to address various issues identified by GCC, mostly
- signed/unsigned and shortening problems on assignment but also a few
- difficult to optimize (for GCC) loops.
- Fixed non-GCC fixed point builds. In png.c a declaration was misplaced
- in an earlier update. Fixed to declare the auto variables at the head.
- Use cexcept.h in pngvalid.c.
-
-Version 1.5.0beta44 [August 24, 2010]
- Updated CMakeLists.txt to use CMAKE_INSTALL_LIBDIR variable; useful for
- installing libpng in /usr/lib64 (Funda Wang).
- Revised CMakeLists.txt to put the man pages in share/man/man* not man/man*
- Revised CMakeLists.txt to make symlinks instead of copies when installing.
- Changed PNG_LIB_NAME from pngNN to libpngNN in CMakeLists.txt (Philip Lowman)
- Implemented memory checks within pngvalid
- Reformatted/rearranged pngvalid.c to assist use of progressive reader.
- Check interlaced images in pngvalid
- Clarified pngusr.h comments in pnglibconf.dfa
- Simplified the pngvalid error-handling code now that cexcept.h is in place.
- Implemented progressive reader in pngvalid.c for standard tests
- Implemented progressive read in pngvalid.c gamma tests
- Turn on progressive reader in pngvalid.c by default and tidy code.
-
-Version 1.5.0beta45 [August 26, 2010]
- Added an explicit make step to projects/vstudio for pnglibconf.h
- Also corrected zlib.vcxproj into which Visual Studio had introduced
- what it calls an "authoring error". The change to make pnglibconf.h
- simply copies the file; in the future it may actually generate the
- file from scripts/pnglibconf.dfa as the other build systems do.
- Changed pngvalid to work when floating point APIs are disabled
- Renamed the prebuilt scripts/pnglibconf.h to scripts/pnglibconf.h.prebuilt
- Supply default values for PNG_USER_PRIVATEBUILD and PNG_USER_DLLFNAME_POSTFIX
- in pngpriv.h in case the user neglected to define them in their pngusr.h
-
-Version 1.5.0beta46 [August 28, 2010]
- Added new private header files to libpng_sources in CMakeLists.txt
- Added PNG_READ_16BIT, PNG_WRITE_16BIT, and PNG_16BIT options.
- Added reference to scripts/pnglibconf.h.prebuilt in the visualc71 project.
-
-Version 1.5.0beta47 [September 11, 2010]
- Fixed a number of problems with 64-bit compilation reported by Visual
- Studio 2010 (John Bowler).
-
-Version 1.5.0beta48 [October 4, 2010]
- Updated CMakeLists.txt (Philip Lowman).
- Revised autogen.sh to recognize and use $AUTOCONF, $AUTOMAKE, $AUTOHEADER,
- $AUTOPOINT, $ACLOCAL and $LIBTOOLIZE
- Fixed problem with symbols creation in Makefile.am which was assuming that
- all versions of ccp write to standard output by default (Martin Banky). The
- bug was introduced in libpng-1.2.9beta5.
- Removed unused mkinstalldirs.
-
-Version 1.5.0beta49 [October 8, 2010]
- Undid Makefile.am revision of 1.5.0beta48.
-
-Version 1.5.0beta50 [October 14, 2010]
- Revised Makefile.in to account for mkinstalldirs being removed.
- Added some "(unsigned long)" typecasts in printf statements in pngvalid.c.
- Suppressed a compiler warning in png_handle_sPLT().
- Check for out-of-range text compression mode in png_set_text().
-
-Version 1.5.0beta51 [October 15, 2010]
- Changed embedded dates to "(PENDING RELEASE) in beta releases (and future
- rc releases) to minimize the difference between releases.
-
-Version 1.5.0beta52 [October 16, 2010]
- Restored some of the embedded dates (in png.h, png.c, documentation, etc.)
-
-Version 1.5.0beta53 [October 18, 2010]
- Updated INSTALL to mention using "make maintainer-clean" and to remove
- obsolete statement about a custom ltmain.sh
- Disabled "color-tests" by default in Makefile.am so it will work with
- automake versions earlier than 1.11.1
- Use document name "libpng-manual.txt" instead of "libpng-<version>.txt"
- to simplify version differences.
- Removed obsolete remarks about setjmp handling from INSTALL.
- Revised and renamed the typedef in png.h and png.c that was designed
- to catch library and header mismatch.
-
-Version 1.5.0beta54 [November 10, 2010]
- Require 48 bytes, not 64 bytes, for big_row_buf in overflow checks.
- Used a consistent structure for the pngget.c functions.
-
-Version 1.5.0beta55 [November 21, 2010]
- Revised png_get_uint_32, png_get_int_32, png_get_uint_16 (Cosmin)
- Moved reading of file signature into png_read_sig (Cosmin)
- Fixed atomicity of chunk header serialization (Cosmin)
- Added test for io_state in pngtest.c (Cosmin)
- Added "#!/bin/sh" at the top of contrib/pngminim/*/gather.sh scripts.
- Changes to remove gcc warnings (John Bowler)
- Certain optional gcc warning flags resulted in warnings in libpng code.
- With these changes only -Wconversion and -Wcast-qual cannot be turned on.
- Changes are trivial rearrangements of code. -Wconversion is not possible
- for pngrutil.c (because of the widespread use of += et al on variables
- smaller than (int) or (unsigned int)) and -Wcast-qual is not possible
- with pngwio.c and pngwutil.c because the 'write' callback and zlib
- compression both fail to declare their input buffers with 'const'.
-
-Version 1.5.0beta56 [December 7, 2010]
- Added the private PNG_UNUSED() macro definition in pngpriv.h.
- Added some commentary about PNG_EXPORT in png.h and pngconf.h
- Revised PNG_EXPORT() macro and added PNG_EXPORTA() macro, with the
- objective of simplifying and improving the cosmetic appearance of png.h.
- Fixed some incorrect "=" macro names in pnglibconf.dfa
- Included documentation of changes in 1.5.0 from 1.4.x in libpng-manual.txt
-
-Version 1.5.0beta57 [December 9, 2010]
- Documented the pngvalid gamma error summary with additional comments and
- print statements.
- Improved missing symbol handling in checksym.awk; symbols missing in both
- the old and new files can now be optionally ignored, treated as errors
- or warnings.
- Removed references to pngvcrd.c and pnggccrd.c from the vstudio project.
- Updated "libpng14" to "libpng15" in the visualc71 project.
- Enabled the strip16 tests in pngvalid.`
- Don't display test results (except PASS/FAIL) when running "make test".
- Instead put them in pngtest-log.txt
- Added "--with-zprefix=<string>" to configure.ac
- Updated the prebuilt configuration files to autoconf version 2.68
-
-Version 1.5.0beta58 [December 19, 2010]
- Fixed interlace image handling and add test cases (John Bowler)
- Fixed the clean rule in Makefile.am to remove pngtest-log.txt
- Made minor changes to work around warnings in gcc 3.4
-
-Version 1.5.0rc01 [December 27, 2010]
- No changes.
-
-Version 1.5.0rc02 [December 27, 2010]
- Eliminated references to the scripts/*.def files in project/visualc71.
-
-Version 1.5.0rc03 [December 28, 2010]
- Eliminated scripts/*.def and revised Makefile.am accordingly
-
-Version 1.5.0rc04 [December 29, 2010]
- Fixed bug in background transformation handling in pngrtran.c (it was
- looking for the flag in png_ptr->transformations instead of in
- png_ptr->flags) (David Raymond).
-
-Version 1.5.0rc05 [December 31, 2010]
- Fixed typo in a comment in CMakeLists.txt (libpng14 => libpng15) (Cosmin)
-
-Version 1.5.0rc06 [January 4, 2011]
- Changed the new configure option "zprefix=string" to "zlib-prefix=string"
-
-Version 1.5.0rc07 [January 4, 2011]
- Updated copyright year.
-
-Version 1.5.0 [January 6, 2011]
- No changes.
-
-version 1.5.1beta01 [January 8, 2011]
- Added description of png_set_crc_action() to the manual.
- Added a note in the manual that the type of the iCCP profile was changed
- from png_charpp to png_bytepp in png_get_iCCP(). This change happened
- in version 1.5.0beta36 but is not noted in the CHANGES. Similarly,
- it was changed from png_charpp to png_const_bytepp in png_set_iCCP().
- Ensure that png_rgb_to_gray ignores palette mapped images, if libpng
- internally happens to call it with one, and fixed a failure to handle
- palette mapped images correctly. This fixes CVE-2690.
-
-Version 1.5.1beta02 [January 14, 2011]
- Fixed a bug in handling of interlaced images (bero at arklinux.org).
- Updated CMakeLists.txt (Clifford Yapp)
-
-Version 1.5.1beta03 [January 14, 2011]
- Fixed typecasting of some png_debug() statements (Cosmin)
-
-Version 1.5.1beta04 [January 16, 2011]
- Updated documentation of png_set|get_tRNS() (Thomas Klausner).
- Mentioned in the documentation that applications must #include "zlib.h"
- if they need access to anything in zlib.h, and that a number of
- macros such as png_memset() are no longer accessible by applications.
- Corrected pngvalid gamma test "sample" function to access all of the color
- samples of each pixel, instead of sampling the red channel three times.
- Prefixed variable names index, div, exp, gamma with "png_" to avoid "shadow"
- warnings, and (mistakenly) changed png_exp() to exp().
-
-Version 1.5.1beta05 [January 16, 2011]
- Changed variable names png_index, png_div, png_exp, and png_gamma to
- char_index, divisor, exp_b10, and gamma_val, respectively, and
- changed exp() back to png_exp().
-
-Version 1.5.1beta06 [January 20, 2011]
- Prevent png_push_crc_skip() from hanging while reading an unknown chunk
- or an over-large compressed zTXt chunk with the progressive reader.
- Eliminated more GCC "shadow" warnings.
- Revised png_fixed() in png.c to avoid compiler warning about reaching the
- end without returning anything.
-
-Version 1.5.1beta07 [January 22, 2011]
- In the manual, describe the png_get_IHDR() arguments in the correct order.
- Added const_png_structp and const_png_infop types, and used them in
- prototypes for most png_get_*() functions.
-
-Version 1.5.1beta08 [January 23, 2011]
- Added png_get_io_chunk_type() and deprecated png_get_io_chunk_name()
- Added synopses for the IO_STATE functions and other missing synopses
- to the manual. Removed the synopses from libpngpf.3 because they
- were out of date and no longer useful. Better information can be
- obtained by reading the prototypes and comments in pngpriv.h
- Attempted to fix cpp on Solaris with S. Studio 12 cc, fix build
- Added a make macro DFNCPP that is a CPP that will accept the tokens in
- a .dfn file and adds configure stuff to test for such a CPP. ./configure
- should fail if one is not available.
- Corrected const_png_ in png.h to png_const_ to avoid polluting the namespace.
- Added png_get_current_row_number and png_get_current_pass_number for the
- benefit of the user transform callback.
- Added png_process_data_pause and png_process_data_skip for the benefit of
- progressive readers that need to stop data processing or want to optimize
- skipping of unread data (e.g., if the reader marks a chunk to be skipped.)
-
-Version 1.5.1beta09 [January 24, 2011]
- Enhanced pngvalid, corrected an error in gray_to_rgb, corrected doc error.
- pngvalid contains tests of transforms, which tests are currently disabled
- because they are incompletely tested. gray_to_rgb was failing to expand
- the bit depth for smaller bit depth images; this seems to be a long
- standing error and resulted, apparently, in invalid output
- (CVE-2011-0408, CERT VU#643140). The documentation did not accurately
- describe what libpng really does when converting RGB to gray.
-
-Version 1.5.1beta10 [January 27, 2010]
- Fixed incorrect examples of callback prototypes in the manual, that were
- introduced in libpng-1.0.0.
- In addition the order of the png_get_uint macros with respect to the
- relevant function definitions has been reversed. This helps the
- preprocessing of the symbol files be more robust. Furthermore, the
- symbol file preprocessing now uses -DPNG_NO_USE_READ_MACROS even when
- the library may actually be built with PNG_USE_READ_MACROS; this stops
- the read macros interfering with the symbol file format.
- Made the manual, synopses, and function prototypes use the function
- argument names file_gamma, int_file_gamma, and srgb_intent consistently.
-
-Version 1.5.1beta11 [January 28, 2011]
- Changed PNG_UNUSED from "param=param;" to "{if(param){}}".
- Corrected local variable type in new API png_process_data_skip()
- The type was self-evidently incorrect but only causes problems on 64-bit
- architectures.
- Added transform tests to pngvalid and simplified the arguments.
-
-Version 1.5.1rc01 [January 29, 2011]
- No changes.
-
-Version 1.5.1rc02 [January 31, 2011]
- Added a request in the manual that applications do not use "png_" or
- "PNG_" to begin any of their own symbols.
- Changed PNG_UNUSED to "(void)param;" and updated the commentary in pngpriv.h
-
-Version 1.5.1 [February 3, 2011]
- No changes.
-
-Version 1.5.2beta01 [February 13, 2011]
- More -Wshadow fixes for older gcc compilers. Older gcc versions apparently
- check formal parameters names in function declarations (as well as
- definitions) to see if they match a name in the global namespace.
- Revised PNG_EXPORTA macro to not use an empty parameter, to accommodate the
- old VisualC++ preprocessor.
- Turned on interlace handling in png_read_png().
- Fixed gcc pedantic warnings.
- Handle longjmp in Cygwin.
- Fixed png_get_current_row_number() in the interlaced case.
- Cleaned up ALPHA flags and transformations.
- Implemented expansion to 16 bits.
-
-Version 1.5.2beta02 [February 19, 2011]
- Fixed mistake in the descriptions of user read_transform and write_transform
- function prototypes in the manual. The row_info struct is png_row_infop.
- Reverted png_get_current_row_number() to previous (1.5.2beta01) behavior.
- Corrected png_get_current_row_number documentation
- Fixed the read/write row callback documentation.
- This documents the current behavior, where the callback is called after
- every row with information pertaining to the next row.
-
-Version 1.5.2beta03 [March 3, 2011]
- Fixed scripts/makefile.vcwin32
- Updated contrib/pngsuite/README to add the word "modify".
- Define PNG_ALLOCATED to blank when _MSC_VER<1300.
-
-Version 1.5.2rc01 [March 19, 2011]
- Define remaining attributes to blank when MSC_VER<1300.
- ifdef out mask arrays in pngread.c when interlacing is not supported.
-
-Version 1.5.2rc02 [March 22, 2011]
- Added a hint to try CPP=/bin/cpp if "cpp -E" fails in scripts/pnglibconf.mak
- and in contrib/pngminim/*/makefile, eg., on SunOS 5.10, and removed "strip"
- from the makefiles.
- Fixed a bug (present since libpng-1.0.7) that makes png_handle_sPLT() fail
- to compile when PNG_NO_POINTER_INDEXING is defined (Chubanov Kirill)
-
-Version 1.5.2rc03 [March 24, 2011]
- Don't include standard header files in png.h while building the symbol table,
- to avoid cpp failure on SunOS (introduced PNG_BUILDING_SYMBOL_TABLE macro).
-
-Version 1.5.2 [March 31, 2011]
- No changes.
-
-Version 1.5.3beta01 [April 1, 2011]
- Re-initialize the zlib compressor before compressing non-IDAT chunks.
- Added API functions (png_set_text_compression_level() and four others) to
- set parameters for zlib compression of non-IDAT chunks.
-
-Version 1.5.3beta02 [April 3, 2011]
- Updated scripts/symbols.def with new API functions.
- Only compile the new zlib re-initializing code when text or iCCP is
- supported, using PNG_WRITE_COMPRESSED_TEXT_SUPPORTED macro.
- Improved the optimization of the zlib CMF byte (see libpng-1.2.6beta03).
- Optimize the zlib CMF byte in non-IDAT compressed chunks
-
-Version 1.5.3beta03 [April 16, 2011]
- Fixed gcc -ansi -pedantic compile. A strict ANSI system does not have
- snprintf, and the "__STRICT_ANSI__" detects that condition more reliably
- than __STDC__ (John Bowler).
- Removed the PNG_PTR_NORETURN attribute because it too dangerous. It tells
- the compiler that a user supplied callback (the error handler) does not
- return, yet there is no guarantee in practice that the application code
- will correctly implement the error handler because the compiler only
- issues a warning if there is a mistake (John Bowler).
- Removed the no-longer-used PNG_DEPSTRUCT macro.
- Updated the zlib version to 1.2.5 in the VStudio project.
- Fixed 64-bit builds where png_uint_32 is smaller than png_size_t in
- pngwutil.c (John Bowler).
- Fixed bug with stripping the filler or alpha channel when writing, that
- was introduced in libpng-1.5.2beta01 (bug report by Andrew Church).
-
-Version 1.5.3beta04 [April 27, 2011]
- Updated pngtest.png with the new zlib CMF optimization.
- Cleaned up conditional compilation code and of background/gamma handling
- Internal changes only except a new option to avoid compiling the
- png_build_grayscale_palette API (which is not used at all internally.)
- The main change is to move the transform tests (READ_TRANSFORMS,
- WRITE_TRANSFORMS) up one level to the caller of the APIs. This avoids
- calls to spurious functions if all transforms are disabled and slightly
- simplifies those functions. Pngvalid modified to handle this.
- A minor change is to stop the strip_16 and expand_16 interfaces from
- disabling each other; this allows the future alpha premultiplication
- code to use 16-bit intermediate values while still producing 8-bit output.
- png_do_background and png_do_gamma have been simplified to take a single
- pointer to the png_struct rather than pointers to every item required
- from the png_struct. This makes no practical difference to the internal
- code.
- A serious bug in the pngvalid internal routine 'standard_display_init' has
- been fixed - this failed to initialize the red channel and accidentally
- initialized the alpha channel twice.
- Changed png_struct jmp_buf member name from png_jmpbuf to tmp_jmpbuf to
- avoid a possible clash with the png_jmpbuf macro on some platforms.
-
-Version 1.5.3beta05 [May 6, 2011]
- Added the "_POSIX_SOURCE" feature test macro to ensure libpng sees the
- correct API. _POSIX_SOURCE is defined in pngpriv.h, pngtest.c and
- pngvalid.c to ensure that POSIX conformant systems disable non-POSIX APIs.
- Removed png_snprintf and added formatted warning messages. This change adds
- internal APIs to allow png_warning messages to have parameters without
- requiring the host OS to implement snprintf. As a side effect the
- dependency of the tIME-supporting RFC1132 code on stdio is removed and
- PNG_NO_WARNINGS does actually work now.
- Pass "" instead of '\0' to png_default_error() in png_err(). This mistake
- was introduced in libpng-1.2.20beta01. This fixes CVE-2011-2691.
- Added PNG_WRITE_OPTIMIZE_CMF_SUPPORTED macro to make the zlib "CMF" byte
- optimization configurable.
- IDAT compression failed if preceded by a compressed text chunk (bug
- introduced in libpng-1.5.3beta01-02). This was because the attempt to
- reset the zlib stream in png_write_IDAT happened after the first IDAT
- chunk had been deflated - much too late. In this change internal
- functions were added to claim/release the z_stream and, hopefully, make
- the code more robust. Also deflateEnd checking is added - previously
- libpng would ignore an error at the end of the stream.
-
-Version 1.5.3beta06 [May 8, 2011]
- Removed the -D_ALL_SOURCE from definitions for AIX in CMakeLists.txt
- Implemented premultiplied alpha support: png_set_alpha_mode API
-
-Version 1.5.3beta07 [May 11, 2011]
- Added expand_16 support to the high level interface.
- Added named value and 'flag' gamma support to png_set_gamma. Made a minor
- change from the previous (unreleased) ABI/API to hide the exact value used
- for Macs - it's not a good idea to embed this in the ABI!
- Moved macro definitions for PNG_HAVE_IHDR, PNG_HAVE_PLTE, and PNG_AFTER_IDAT
- from pngpriv.h to png.h because they must be visible to applications
- that call png_set_unknown_chunks().
- Check for up->location !PNG_AFTER_IDAT when writing unknown chunks
- before IDAT.
-
-Version 1.5.3beta08 [May 16, 2011]
- Improved "pngvalid --speed" to exclude more of pngvalid from the time.
- Documented png_set_alpha_mode(), other changes in libpng.3/libpng-manual.txt
- The cHRM chunk now sets the defaults for png_set_rgb_to_gray() (when negative
- parameters are supplied by the caller), while in the absence of cHRM
- sRGB/Rec 709 values are still used. This introduced a divide-by-zero
- bug in png_handle_cHRM().
- The bKGD chunk no longer overwrites the background value set by
- png_set_background(), allowing the latter to be used before the file
- header is read. It never performed any useful function to override
- the default anyway.
- Added memory overwrite and palette image checks to pngvalid.c
- Previously palette image code was poorly checked. Since the transformation
- code has a special palette path in most cases this was a severe weakness.
- Minor cleanup and some extra checking in pngrutil.c and pngrtran.c. When
- expanding an indexed image, always expand to RGBA if transparency is
- present.
-
-Version 1.5.3beta09 [May 17, 2011]
- Reversed earlier 1.5.3 change of transformation order; move png_expand_16
- back where it was. The change doesn't work because it requires 16-bit
- gamma tables when the code only generates 8-bit ones. This fails
- silently; the libpng code just doesn't do any gamma correction. Moving
- the tests back leaves the old, inaccurate, 8-bit gamma calculations, but
- these are clearly better than none!
-
-Version 1.5.3beta10 [May 20, 2011]
-
- png_set_background() and png_expand_16() did not work together correctly.
- This problem is present in 1.5.2; if png_set_background is called with
- need_expand false and the matching 16 bit color libpng erroneously just
- treats it as an 8-bit color because of where png_do_expand_16 is in the
- transform list. This simple fix reduces the supplied colour to 8-bits,
- so it gets smashed, but this is better than the current behavior.
- Added tests for expand16, more fixes for palette image tests to pngvalid.
- Corrects the code for palette image tests and disables attempts to
- validate palette colors.
-
-Version 1.5.3rc01 [June 3, 2011]
- No changes.
-
-Version 1.5.3rc02 [June 8, 2011]
- Fixed uninitialized memory read in png_format_buffer() (Bug report by
- Frank Busse, CVE-2011-2501, related to CVE-2004-0421).
-
-Version 1.5.3beta11 [June 11, 2011]
- Fixed png_handle_sCAL which is broken in 1.5. This fixes CVE 2011-2692.
- Added sCAL to pngtest.png
- Revised documentation about png_set_user_limits() to say that it also affects
- png writing.
- Revised handling of png_set_user_limits() so that it can increase the
- limit beyond the PNG_USER_WIDTH|HEIGHT_MAX; previously it could only
- reduce it.
- Make the 16-to-8 scaling accurate. Dividing by 256 with no rounding is
- wrong (high by one) 25% of the time. Dividing by 257 with rounding is
- wrong in 128 out of 65536 cases. Getting the right answer all the time
- without division is easy.
- Added "_SUPPORTED" to the PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION macro.
- Added projects/owatcom, an IDE project for OpenWatcom to replace
- scripts/makefile.watcom. This project works with OpenWatcom 1.9. The
- IDE autogenerates appropriate makefiles (libpng.mk) for batch processing.
- The project is configurable, unlike the Visual Studio project, so long
- as the developer has an awk.
- Changed png_set_gAMA to limit the gamma value range so that the inverse
- of the stored value cannot overflow the fixed point representation,
- and changed other things OpenWatcom warns about.
- Revised pngvalid.c to test PNG_ALPHA_MODE_SUPPORTED correctly. This allows
- pngvalid to build when ALPHA_MODE is not supported, which is required if
- it is to build on libpng 1.4.
- Removed string/memory macros that are no longer used and are not
- necessarily fully supportable, particularly png_strncpy and png_snprintf.
- Added log option to pngvalid.c and attempted to improve gamma messages.
-
-Version 1.5.3 [omitted]
- People found the presence of a beta release following an rc release
- to be confusing; therefore we bump the version to libpng-1.5.4beta01
- and there will be no libpng-1.5.3 release.
-
-Version 1.5.4beta01 [June 14, 2011]
- Made it possible to undefine PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
- to get the same (inaccurate) output as libpng-1.5.2 and earlier.
- Moved definitions of PNG_HAVE_IHDR, PNG_AFTER_IDAT, and PNG_HAVE_PLTE
- outside of an unknown-chunk block in png.h because they are also
- needed for other uses.
-
-Version 1.5.4beta02 [June 14, 2011]
- Fixed and clarified LEGACY 16-to-8 scaling code.
- Added png_set_chop_16() API, to match inaccurate results from previous
- libpng versions.
- Removed the ACCURATE and LEGACY options (they are no longer useable)
- Use the old scaling method for background if png_set_chop_16() was
- called.
- Made png_set_chop_16() API removeable by disabling PNG_CHOP_16_TO_8_SUPPORTED
-
-Version 1.5.4beta03 [June 15, 2011]
- Fixed a problem in png_do_expand_palette() exposed by optimization in
- 1.5.3beta06
- Also removed a spurious and confusing "trans" member ("trans") from png_info.
- The palette expand optimization prevented expansion to an intermediate RGBA
- form if tRNS was present but alpha was marked to be stripped; this exposed
- a check for tRNS in png_do_expand_palette() which is inconsistent with the
- code elsewhere in libpng.
- Correction to the expand_16 code; removed extra instance of
- png_set_scale_16_to_8 from pngpriv.h
-
-Version 1.5.4beta04 [June 16, 2011]
- Added a missing "#ifdef PNG_READ_BACKGROUND_SUPPORTED/#endif" in pngrtran.c
- Added PNG_TRANSFORM_CHOP_16 to the high-level read transforms.
- Made PNG_READ_16_TO_8_ACCURATE_SCALE configurable again. If this is
- not enabled, png_set_strip_16() and png_do_scale_16_to_8() aren't built.
- Revised contrib/visupng, gregbook, and pngminim to demonstrate chop_16_to_8
-
-Version 1.5.4beta05 [June 16, 2011]
- Renamed png_set_strip_16() to png_set_scale_16() and renamed
- png_set_chop_16() to png_set_strip(16) in an attempt to minimize the
- behavior changes between libpng14 and libpng15.
-
-Version 1.5.4beta06 [June 18, 2011]
- Fixed new bug that was causing both strip_16 and scale_16 to be applied.
-
-Version 1.5.4beta07 [June 19, 2011]
- Fixed pngvalid, simplified macros, added checking for 0 in sCAL.
- The ACCURATE scale macro is no longer defined in 1.5 - call the
- png_scale_16_to_8 API. Made sure that PNG_READ_16_TO_8 is still defined
- if the png_strip_16_to_8 API is present. png_check_fp_number now
- maintains some state so that positive, negative and zero values are
- identified. sCAL uses these to be strictly spec conformant.
-
-Version 1.5.4beta08 [June 23, 2011]
- Fixed pngvalid if ACCURATE_SCALE is defined.
- Updated scripts/pnglibconf.h.prebuilt.
-
-Version 1.5.4rc01 [June 30, 2011]
- Define PNG_ALLOCATED to "restrict" only if MSC_VER >= 1400.
-
-Version 1.5.4 [July 7, 2011]
- No changes.
-
-Version 1.5.5beta01 [July 13, 2011]
- Fixed some typos and made other minor changes in the manual.
- Updated contrib/pngminus/makefile.std (Samuli Souminen)
-
-Version 1.5.5beta02 [July 14, 2011]
- Revised Makefile.am and Makefile.in to look in the right directory for
- pnglibconf.h.prebuilt
-
-Version 1.5.5beta03 [July 27, 2011]
- Enabled compilation with g++ compiler. This compiler does not recognize
- the file extension, so it always compiles with C++ rules. Made minor
- changes to pngrutil.c to cast results where C++ expects it but C does not.
- Minor editing of libpng.3 and libpng-manual.txt.
-
-Version 1.5.5beta04 [July 29, 2011]
- Revised CMakeLists.txt (Clifford Yapp)
- Updated commentary about the png_rgb_to_gray() default coefficients
- in the manual and in pngrtran.c
-
-Version 1.5.5beta05 [August 17, 2011]
- Prevent unexpected API exports from non-libpng DLLs on Windows. The "_DLL"
- is removed from the test of whether a DLL is being built (this erroneously
- caused the libpng APIs to be marked as DLL exports in static builds under
- Microsoft Visual Studio). Almost all of the libpng building configuration
- is moved from pngconf.h to pngpriv.h, but PNG_DLL_EXPORT remains in
- pngconf.h, though, so that it is colocated with the import definition (it
- is no longer used anywhere in the installed headers). The VStudio project
- definitions have been cleaned up: "_USRDLL" has been removed from the
- static library builds (this was incorrect), and PNG_USE_DLL has been added
- to pngvalid to test the functionality (pngtest does not supply it,
- deliberately). The spurious "_EXPORTS" has been removed from the
- libpng build (all these errors were a result of copy/paste between project
- configurations.)
- Added new types and internal functions for CIE RGB end point handling to
- pngpriv.h (functions yet to be implemented).
-
-Version 1.5.5beta06 [August 26, 2011]
- Ensure the CMAKE_LIBRARY_OUTPUT_DIRECTORY is set in CMakeLists.txt
- (Clifford Yap)
- Fixes to rgb_to_gray and cHRM XYZ APIs (John Bowler):
- The rgb_to_gray code had errors when combined with gamma correction.
- Some pixels were treated as true grey when they weren't and such pixels
- and true grey ones were not gamma corrected (the original value of the
- red component was used instead). APIs to get and set cHRM using color
- space end points have been added and the rgb_to_gray code that defaults
- based on cHRM, and the divide-by-zero bug in png_handle_cHRM (CERT
- VU#477046, CVE-2011-3328, introduced in 1.5.4) have been corrected.
- A considerable number of tests has been added to pngvalid for the
- rgb_to_gray transform.
- Arithmetic errors in rgb_to_gray whereby the calculated gray value was
- truncated to the bit depth rather than rounded have been fixed except in
- the 8-bit non-gamma-corrected case (where consistency seems more important
- than correctness.) The code still has considerable inaccuracies in the
- 8-bit case because 8-bit linear arithmetic is used.
-
-Version 1.5.5beta07 [September 7, 2011]
- Added "$(ARCH)" option to makefile.darwin
- Added SunOS support to configure.ac and Makefile.am
- Changed png_chunk_benign_error() to png_warning() in png.c, in
- png_XYZ_from_xy_checked().
-
-Version 1.5.5beta08 [September 10, 2011]
- Fixed 64-bit compilation errors (gcc). The errors fixed relate
- to conditions where types that are 32 bits in the GCC 32-bit
- world (uLong and png_size_t) become 64 bits in the 64-bit
- world. This produces potential truncation errors which the
- compiler correctly flags.
- Relocated new HAVE_SOLARIS_LD definition in configure.ac
- Constant changes for 64-bit compatibility (removal of L suffixes). The
- 16-bit cases still use "L" as we don't have a 16-bit test system.
-
-Version 1.5.5rc01 [September 15, 2011]
- Removed "L" suffixes in pngpriv.h
-
-Version 1.5.5 [September 22, 2011]
- No changes.
-
-Version 1.5.6beta01 [September 22, 2011]
- Fixed some 64-bit type conversion warnings in pngrtran.c
- Moved row_info from png_struct to a local variable.
- The various interlace mask arrays have been made into arrays of
- bytes and made PNG_CONST and static (previously some arrays were
- marked PNG_CONST and some weren't).
- Additional checks have been added to the transform code to validate the
- pixel depths after the transforms on both read and write.
- Removed some redundant code from pngwrite.c, in png_destroy_write_struct().
- Changed chunk reading/writing code to use png_uint_32 instead of png_byte[4].
- This removes the need to allocate temporary strings for chunk names on
- the stack in the read/write code. Unknown chunk handling still uses the
- string form because this is exposed in the API.
-
-Version 1.5.6beta02 [September 26, 2011]
- Added a note in the manual the png_read_update_info() must be called only
- once with a particular info_ptr.
- Fixed a typo in the definition of the new PNG_STRING_FROM_CHUNK(s,c) macro.
-
-Version 1.5.6beta03 [September 28, 2011]
- Revised test-pngtest.sh to report FAIL when pngtest fails.
- Added "--strict" option to pngtest, to report FAIL when the failure is
- only because the resulting valid files are different.
- Revised CMakeLists.txt to work with mingw and removed some material from
- CMakeLists.txt that is no longer useful in libpng-1.5.
-
-Version 1.5.6beta04 [October 5, 2011]
- Fixed typo in Makefile.in and Makefile.am ("-M Wl" should be "-M -Wl")."
-
-Version 1.5.6beta05 [October 12, 2011]
- Speed up png_combine_row() for interlaced images. This reduces the generality
- of the code, allowing it to be optimized for Adam7 interlace. The masks
- passed to png_combine_row() are now generated internally, avoiding
- some code duplication and localizing the interlace handling somewhat.
- Align png_struct::row_buf - previously it was always unaligned, caused by
- a bug in the code that attempted to align it; the code needs to subtract
- one from the pointer to take account of the filter byte prepended to
- each row.
- Optimized png_combine_row() when rows are aligned. This gains a small
- percentage for 16-bit and 32-bit pixels in the typical case where the
- output row buffers are appropriately aligned. The optimization was not
- previously possible because the png_struct buffer was always misaligned.
- Fixed bug in png_write_chunk_header() debug print, introduced in 1.5.6beta01.
-
-Version 1.5.6beta06 [October 17, 2011]
- Removed two redundant tests for uninitialized row.
- Fixed a relatively harmless memory overwrite in compressed text writing
- with a 1 byte zlib buffer.
- Add ability to call png_read_update_info multiple times to pngvalid.c.
- Fixes for multiple calls to png_read_update_info. These fixes attend to
- most of the errors revealed in pngvalid, however doing the gamma work
- twice results in inaccuracies that can't be easily fixed. There is now
- a warning in the code if this is going to happen.
- Turned on multiple png_read_update_info in pngvalid transform tests.
- Prevent libpng from overwriting unused bits at the end of the image when
- it is not byte aligned, while reading. Prior to libpng-1.5.6 libpng would
- overwrite the partial byte at the end of each row if the row width was not
- an exact multiple of 8 bits and the image is not interlaced.
-
-Version 1.5.6beta07 [October 21, 2011]
- Made png_ptr->prev_row an aligned pointer into png_ptr->big_prev_row
- (Mans Rullgard).
-
-Version 1.5.6rc01 [October 26, 2011]
- Changed misleading "Missing PLTE before cHRM" warning to "Out of place cHRM"
-
-Version 1.5.6rc02 [October 27, 2011]
- Added LSR() macro to defend against buggy compilers that evaluate non-taken
- code branches and complain about out-of-range shifts.
-
-Version 1.5.6rc03 [October 28, 2011]
- Renamed the LSR() macro to PNG_LSR() and added PNG_LSL() macro.
- Fixed compiler warnings with Intel and MSYS compilers. The logical shift
- fix for Microsoft Visual C is required by other compilers, so this
- enables that fix for all compilers when using compile-time constants.
- Under MSYS 'byte' is a name declared in a system header file, so we
- changed the name of a local variable to avoid the warnings that result.
- Added #define PNG_ALIGN_TYPE PNG_ALIGN_NONE to contrib/pngminim/*/pngusr.h
-
-Version 1.5.6 [November 3, 2011]
- No changes.
-
-Version 1.5.7beta01 [November 4, 2011]
- Added support for ARM processor, when decoding all PNG up-filtered rows
- and any other-filtered rows with 3 or 4 bytes per pixel (Mans Rullgard).
- Fixed bug in pngvalid on early allocation failure; fixed type cast in
- pngmem.c; pngvalid would attempt to call png_error() if the allocation
- of a png_struct or png_info failed. This would probably have led to a
- crash. The pngmem.c implementation of png_malloc() included a cast
- to png_size_t which would fail on large allocations on 16-bit systems.
- Fix for the preprocessor of the Intel C compiler. The preprocessor
- splits adjacent @ signs with a space; this changes the concatenation
- token from @-@-@ to PNG_JOIN; that should work with all compiler
- preprocessors.
- Paeth filter speed improvements from work by Siarhei Siamashka. This
- changes the 'Paeth' reconstruction function to improve the GCC code
- generation on x86. The changes are only part of the suggested ones;
- just the changes that definitely improve speed and remain simple.
- The changes also slightly increase the clarity of the code.
-
-Version 1.5.7beta02 [November 11, 2011]
- Check compression_type parameter in png_get_iCCP and remove spurious
- casts. The compression_type parameter is always assigned to, so must
- be non-NULL. The cast of the profile length potentially truncated the
- value unnecessarily on a 16-bit int system, so the cast of the (byte)
- compression type to (int) is specified by ANSI-C anyway.
- Fixed FP division by zero in pngvalid.c; the 'test_pixel' code left
- the sBIT fields in the test pixel as 0, which resulted in a floating
- point division by zero which was irrelevant but causes systems where
- FP exceptions cause a crash. Added code to pngvalid to turn on FP
- exceptions if the appropriate glibc support is there to ensure this is
- tested in the future.
- Updated scripts/pnglibconf.mak and scripts/makefile.std to handle the
- new PNG_JOIN macro.
- Added versioning to pnglibconf.h comments.
- Simplified read/write API initial version; basic read/write tested on
- a variety of images, limited documentation (in the header file.)
- Installed more accurate linear to sRGB conversion tables. The slightly
- modified tables reduce the number of 16-bit values that
- convert to an off-by-one 8-bit value. The "makesRGB.c" code that was used
- to generate the tables is now in a contrib/sRGBtables sub-directory.
-
-Version 1.5.7beta03 [November 17, 2011]
- Removed PNG_CONST from the sRGB table declarations in pngpriv.h and png.c
- Added run-time detection of NEON support.
- Added contrib/libtests; includes simplified API test and timing test and
- a color conversion utility for rapid checking of failed 'pngstest' results.
- Multiple transform bug fixes plus a work-round for double gamma correction.
- libpng does not support more than one transform that requires linear data
- at once - if this is tried typically the results is double gamma
- correction. Since the simplified APIs can need rgb to gray combined with
- a compose operation it is necessary to do one of these outside the main
- libpng transform code. This check-in also contains fixes to various bugs
- in the simplified APIs themselves and to some bugs in compose and rgb to
- gray (on palette) itself.
- Fixes for C++ compilation using g++ When libpng source is compiled
- using g++. The compiler imposes C++ rules on the C source; thus it
- is desirable to make the source work with either C or C++ rules
- without throwing away useful error information. This change adds
- png_voidcast to allow C semantic (void*) cases or the corresponding
- C++ static_cast operation, as appropriate.
- Added --noexecstack to assembler file compilation. GCC does not set
- this on assembler compilation, even though it does on C compilation.
- This creates security issues if assembler code is enabled; the
- work-around is to set it by default in the flags for $(CCAS)
- Work around compilers that don't support declaration of const data. Some
- compilers fault 'extern const' data declarations (because the data is
- not initialized); this turns on const-ness only for compilers where
- this is known to work.
-
-Version 1.5.7beta04 [November 17, 2011]
- Since the gcc driver does not recognize the --noexecstack flag, we must
- use the -Wa prefix to have it passed through to the assembler.
- Also removed a duplicate setting of this flag.
- Added files that were omitted from the libpng-1.5.7beta03 zip distribution.
-
-Version 1.5.7beta05 [November 25, 2011]
- Removed "zTXt" from warning in generic chunk decompression function.
- Validate time settings passed to png_set_tIME() and png_convert_to_rfc1123()
- (Frank Busse). Note: This prevented CVE-2015-7981 from affecting
- libpng-1.5.7 and later.
- Added MINGW support to CMakeLists.txt
- Reject invalid compression flag or method when reading the iTXt chunk.
- Backed out 'simplified' API changes. The API seems too complex and there
- is a lack of consensus or enthusiasm for the proposals. The API also
- reveals significant bugs inside libpng (double gamma correction and the
- known bug of being unable to retrieve a corrected palette). It seems
- better to wait until the bugs, at least, are corrected.
- Moved pngvalid.c into contrib/libtests
- Rebuilt Makefile.in, configure, etc., with autoconf-2.68
-
-Version 1.5.7rc01 [December 1, 2011]
- Replaced an "#if" with "#ifdef" in pngrtran.c
- Revised #if PNG_DO_BC block in png.c (use #ifdef and add #else)
-
-Version 1.5.7rc02 [December 5, 2011]
- Revised project files and contrib/pngvalid/pngvalid.c to account for
- the relocation of pngvalid into contrib/libtests.
- Revised pngconf.h to use " __declspec(restrict)" only when MSC_VER >= 1400,
- as in libpng-1.5.4.
- Put CRLF line endings in the owatcom project files.
-
-Version 1.5.7rc03 [December 7, 2011]
- Updated CMakeLists.txt to account for the relocation of pngvalid.c
-
-Version 1.5.7 [December 15, 2011]
- Minor fixes to pngvalid.c for gcc 4.6.2 compatibility to remove warnings
- reported by earlier versions.
- Fixed minor memset/sizeof errors in pngvalid.c.
-
-Version 1.6.0beta01 [December 15, 2011]
- Removed machine-generated configure files from the GIT repository (they will
- continue to appear in the tarball distributions and in the libpng15 and
- earlier GIT branches).
- Restored the new 'simplified' API, which was started in libpng-1.5.7beta02
- but later deleted from libpng-1.5.7beta05.
- Added example programs for the new 'simplified' API.
- Added ANSI-C (C90) headers and require them, and take advantage of the
- change. Also fixed some of the projects/* and contrib/* files that needed
- updates for libpng16 and the move of pngvalid.c.
- With this change the required ANSI-C header files are assumed to exist: the
- implementation must provide float.h, limits.h, stdarg.h and stddef.h and
- libpng relies on limits.h and stddef.h existing and behaving as defined
- (the other two required headers aren't used). Non-ANSI systems that don't
- have stddef.h or limits.h will have to provide an appropriate fake
- containing the relevant types and #defines.
- Dropped support for 16-bit platforms. The use of FAR/far has been eliminated
- and the definition of png_alloc_size_t is now controlled by a flag so
- that 'small size_t' systems can select it if necessary. Libpng 1.6 may
- not currently work on such systems -- it seems likely that it will
- ask 'malloc' for more than 65535 bytes with any image that has a
- sufficiently large row size (rather than simply failing to read such
- images).
- New tools directory containing tools used to generate libpng code.
- Fixed race conditions in parallel make builds. With higher degrees of
- parallelism during 'make' the use of the same temporary file names such
- as 'dfn*' can result in a race where a temporary file from one arm of the
- build is deleted or overwritten in another arm. This changes the
- temporary files for suffix rules to always use $* and ensures that the
- non-suffix rules use unique file names.
-
-Version 1.6.0beta02 [December 21, 2011]
- Correct configure builds where build and source directories are separate.
- The include path of 'config.h' was erroneously made relative in pngvalid.c
- in libpng 1.5.7.
-
-Version 1.6.0beta03 [December 22, 2011]
- Start-up code size improvements, error handler flexibility. These changes
- alter how the tricky allocation of the initial png_struct and png_info
- structures are handled. png_info is now handled in pretty much the same
- way as everything else, except that the allocations handle NULL return
- silently. png_struct is changed in a similar way on allocation and on
- deallocation a 'safety' error handler is put in place (which should never
- be required). The error handler itself is changed to permit mismatches
- in the application and libpng error buffer size; however, this means a
- silent change to the API to return the jmp_buf if the size doesn't match
- the size from the libpng compilation; libpng now allocates the memory and
- this may fail. Overall these changes result in slight code size
- reductions; however, this is a reduction in code that is always executed
- so is particularly valuable. Overall on a 64-bit system the libpng DLL
- decreases in code size by 1733 bytes. pngerror.o increases in size by
- about 465 bytes because of the new functionality.
- Added png_convert_to_rfc1123_buffer() and deprecated png_convert_to_rfc1123()
- to avoid including a spurious buffer in the png_struct.
-
-Version 1.6.0beta04 [December 30, 2011]
- Regenerated configure scripts with automake-1.11.2
- Eliminated png_info_destroy(). It is now used only in png.c and only calls
- one other internal function and memset().
- Enabled png_get_sCAL_fixed() if floating point APIs are enabled. Previously
- it was disabled whenever internal fixed point arithmetic was selected,
- which meant it didn't exist even on systems where FP was available but not
- preferred.
- Added pngvalid.c compile time checks for const APIs.
- Implemented 'restrict' for png_info and png_struct. Because of the way
- libpng works both png_info and png_struct are always accessed via a
- single pointer. This means adding C99 'restrict' to the pointer gives
- the compiler some opportunity to optimize the code. This change allows
- that.
- Moved AC_MSG_CHECKING([if libraries can be versioned]) later to the proper
- location in configure.ac (Gilles Espinasse).
- Changed png_memcpy to C assignment where appropriate. Changed all those
- uses of png_memcpy that were doing a simple assignment to assignments
- (all those cases where the thing being copied is a non-array C L-value).
- Added some error checking to png_set_*() routines.
- Removed the reference to the non-exported function png_memcpy() from
- example.c.
- Fixed the Visual C 64-bit build - it requires jmp_buf to be aligned, but
- it had become misaligned.
- Revised contrib/pngminus/pnm2png.c to avoid warnings when png_uint_32
- and unsigned long are of different sizes.
-
-Version 1.6.0beta05 [January 15, 2012]
- Updated manual with description of the simplified API (copied from png.h)
- Fix bug in pngerror.c: some long warnings were being improperly truncated
- (CVE-2011-3464, bug introduced in libpng-1.5.3beta05).
-
-Version 1.6.0beta06 [January 24, 2012]
- Added palette support to the simplified APIs. This commit
- changes some of the macro definitions in png.h, app code
- may need corresponding changes.
- Increased the formatted warning buffer to 192 bytes.
- Added color-map support to simplified API. This is an initial version for
- review; the documentation has not yet been updated.
- Fixed Min/GW uninstall to remove libpng.dll.a
-
-Version 1.6.0beta07 [January 28, 2012]
- Eliminated Intel icc/icl compiler warnings. The Intel (GCC derived)
- compiler issues slightly different warnings from those issued by the
- current versions of GCC. This eliminates those warnings by
- adding/removing casts and small code rewrites.
- Updated configure.ac from autoupdate: added --enable-werror option.
- Also some layout regularization and removal of introduced tab characters
- (replaced with 3-character indentation). Obsolete macros identified by
- autoupdate have been removed; the replacements are all in 2.59 so
- the pre-req hasn't been changed. --enable-werror checks for support
- for -Werror (or the given argument) in the compiler. This mimics the
- gcc configure option by allowing -Werror to be turned on safely; without
- the option the tests written in configure itself fail compilation because
- they cause compiler warnings.
- Rewrote autogen.sh to run autoreconf instead of running tools one-by-one.
- Conditionalize the install rules for MINGW and CYGWIN in CMakeLists.txt and
- set CMAKE_LIBRARY_OUTPUT_DIRECTORY to "lib" on all platforms (C. Yapp).
- Freeze libtool files in the 'scripts' directory. This version of autogen.sh
- attempts to dissuade people from running it when it is not, or should not,
- be necessary. In fact, autogen.sh does not work when run in a libpng
- directory extracted from a tar distribution anymore. You must run it in
- a GIT clone instead.
- Added two images to contrib/pngsuite (1-bit and 2-bit transparent grayscale),
- and renamed three whose names were inconsistent with those in
- pngsuite/README.txt.
-
-Version 1.6.0beta08 [February 1, 2012]
- Fixed Image::colormap misalignment in pngstest.c
- Check libtool/libtoolize version number (2.4.2) in configure.ac
- Divide test-pngstest.sh into separate pngstest runs for basic and
- transparent images.
- Moved automake options to AM_INIT_AUTOMAKE in configure.ac
- Added color-tests, silent-rules (Not yet implemented in Makefile.am) and
- version checking to configure.ac
- Improved pngstest speed by not doing redundant tests and add const to
- the background parameter of png_image_finish_read. The --background
- option is now done automagically only when required, so that command-line
- option no longer exists.
- Cleaned up pngpriv.h to consistently declare all functions and data.
- Also eliminated PNG_CONST_DATA, which is apparently not needed but we
- can't be sure until it is gone.
- Added symbol prefixing that allows all the libpng external symbols
- to be prefixed (suggested by Reuben Hawkins).
- Updated "ftbb*.png" list in the owatcom and vstudio projects.
- Fixed 'prefix' builds on clean systems. The generation of pngprefix.h
- should not require itself.
- Updated INSTALL to explain that autogen.sh must be run in a GIT clone,
- not in a libpng directory extracted from a tar distribution.
-
-Version 1.6.0beta09 [February 1, 2012]
- Reverted the prebuilt configure files to libpng-1.6.0beta05 condition.
-
-Version 1.6.0beta10 [February 3, 2012]
- Added Z_SOLO for zlib-1.2.6+ and correct pngstest tests
- Updated list of test images in CMakeLists.txt
- Updated the prebuilt configure files to current condition.
- Revised INSTALL information about autogen.sh; it works in tar distributions.
-
-Version 1.6.0beta11 [February 16, 2012]
- Fix character count in pngstest command in projects/owatcom/pngstest.tgt
- Revised test-pngstest.sh to report PASS/FAIL for each image.
- Updated documentation about the simplified API.
- Corrected estimate of error in libpng png_set_rgb_to_gray API. The API is
- extremely inaccurate for sRGB conversions because it uses an 8-bit
- intermediate linear value and it does not use the sRGB transform, so it
- suffers from the known instability in gamma transforms for values close
- to 0 (see Poynton). The net result is that the calculation has a maximum
- error of 14.99/255; 0.5/255^(1/2.2). pngstest now uses 15 for the
- permitted 8-bit error. This may still not be enough because of arithmetic
- error.
- Removed some unused arrays (with #ifdef) from png_read_push_finish_row().
- Fixed a memory overwrite bug in simplified read of RGB PNG with
- non-linear gamma Also bugs in the error checking in pngread.c and changed
- quite a lot of the checks in pngstest.c to be correct; either correctly
- written or not over-optimistic. The pngstest changes are insufficient to
- allow all possible RGB transforms to be passed; pngstest cmppixel needs
- to be rewritten to make it clearer which errors it allows and then changed
- to permit known inaccuracies.
- Removed tests for no-longer-used *_EMPTY_PLTE_SUPPORTED from pngstruct.h
- Fixed fixed/float API export conditionals. 1) If FIXED_POINT or
- FLOATING_POINT options were switched off, png.h ended up with lone ';'
- characters. This is not valid ANSI-C outside a function. The ';'
- characters have been moved inside the definition of PNG_FP_EXPORT and
- PNG_FIXED_EXPORT. 2) If either option was switched off, the declaration
- of the corresponding functions were completely omitted, even though some
- of them are still used internally. The result is still valid, but
- produces warnings from gcc with some warning options (including -Wall). The
- fix is to cause png.h to declare the functions with PNG_INTERNAL_FUNCTION
- when png.h is included from pngpriv.h.
- Check for invalid palette index while reading paletted PNG. When one is
- found, issue a warning and increase png_ptr->num_palette accordingly.
- Apps are responsible for checking to see if that happened.
-
-Version 1.6.0beta12 [February 18, 2012]
- Do not increase num_palette on invalid_index.
- Relocated check for invalid palette index to pngrtran.c, after unpacking
- the sub-8-bit pixels.
- Fixed CVE-2011-3026 buffer overrun bug. This bug was introduced when
- iCCP chunk support was added at libpng-1.0.6. Deal more correctly with the
- test on iCCP chunk length. Also removed spurious casts that may hide
- problems on 16-bit systems.
-
-Version 1.6.0beta13 [February 24, 2012]
- Eliminated redundant png_push_read_tEXt|zTXt|iTXt|unknown code from
- pngpread.c and use the sequential png_handle_tEXt, etc., in pngrutil.c;
- now that png_ptr->buffer is inaccessible to applications, the special
- handling is no longer useful.
- Added PNG_SAFE_LIMITS feature to pnglibconf.dfa, pngpriv.h, and new
- pngusr.dfa to reset the user limits to safe ones if PNG_SAFE_LIMITS is
- defined. To enable, use "CPPFLAGS=-DPNG_SAFE_LIMITS_SUPPORTED=1" on the
- configure command or put #define PNG_SAFE_LIMITS_SUPPORTED in
- pnglibconf.h.prebuilt and pnglibconf.h.
-
-Version 1.6.0beta14 [February 27, 2012]
- Added information about the new limits in the manual.
- Updated Makefile.in
-
-Version 1.6.0beta15 [March 2, 2012]
- Removed unused "current_text" members of png_struct and the png_free()
- of png_ptr->current_text from pngread.c
- Rewrote pngstest.c for substantial speed improvement.
- Fixed transparent pixel and 16-bit rgb tests in pngstest and removed a
- spurious check in pngwrite.c
- Added PNG_IMAGE_FLAG_FAST for the benefit of applications that store
- intermediate files, or intermediate in-memory data, while processing
- image data with the simplified API. The option makes the files larger
- but faster to write and read. pngstest now uses this by default; this
- can be disabled with the --slow option.
- Improved pngstest fine tuning of error numbers, new test file generator.
- The generator generates images that test the full range of sample values,
- allow the error numbers in pngstest to be tuned and checked. makepng
- also allows generation of images with extra chunks, although this is
- still work-in-progress.
- Added check for invalid palette index while reading.
- Fixed some bugs in ICC profile writing. The code should now accept
- all potentially valid ICC profiles and reject obviously invalid ones.
- It now uses png_error() to do so rather than casually writing a PNG
- without the necessary color data.
- Removed whitespace from the end of lines in all source files and scripts.
-
-Version 1.6.0beta16 [March 6, 2012]
- Relocated palette-index checking function from pngrutil.c to pngtrans.c
- Added palette-index checking while writing.
- Changed png_inflate() and calling routines to avoid overflow problems.
- This is an intermediate check-in that solves the immediate problems and
- introduces one performance improvement (avoiding a copy via png_ptr->zbuf.)
- Further changes will be made to make ICC profile handling more secure.
- Fixed build warnings (MSVC, GCC, GCC v3). Cygwin GCC with default options
- declares 'index' as a global, causing a warning if it is used as a local
- variable. GCC 64-bit warns about assigning a (size_t) (unsigned 64-bit)
- to an (int) (signed 32-bit). MSVC, however, warns about using the
- unary '-' operator on an unsigned value (even though it is well defined
- by ANSI-C to be ~x+1). The padding calculation was changed to use a
- different method. Removed the tests on png_ptr->pass.
- Added contrib/libtests/tarith.c to test internal arithmetic functions from
- png.c. This is a libpng maintainer program used to validate changes to the
- internal arithmetic functions.
- Made read 'inflate' handling like write 'deflate' handling. The read
- code now claims and releases png_ptr->zstream, like the write code.
- The bug whereby the progressive reader failed to release the zstream
- is now fixed, all initialization is delayed, and the code checks for
- changed parameters on deflate rather than always calling
- deflatedEnd/deflateInit.
- Validate the zTXt strings in pngvalid.
- Added code to validate the windowBits value passed to deflateInit2().
- If the call to deflateInit2() is wrong a png_warning will be issued
- (in fact this is harmless, but the PNG data produced may be sub-optimal).
-
-Version 1.6.0beta17 [March 10, 2012]
- Fixed PNG_LIBPNG_BUILD_BASE_TYPE definition.
- Reject all iCCP chunks after the first, even if the first one is invalid.
- Deflate/inflate was reworked to move common zlib calls into single
- functions [rw]util.c. A new shared keyword check routine was also added
- and the 'zbuf' is no longer allocated on progressive read. It is now
- possible to call png_inflate() incrementally. A warning is no longer
- issued if the language tag or translated keyword in the iTXt chunk
- has zero length.
- If benign errors are disabled use maximum window on ancillary inflate.
- This works round a bug introduced in 1.5.4 where compressed ancillary
- chunks could end up with a too-small windowBits value in the deflate
- header.
-
-Version 1.6.0beta18 [March 16, 2012]
- Issue a png_benign_error() instead of png_warning() about bad palette index.
- In pngtest, treat benign errors as errors if "-strict" is present.
- Fixed an off-by-one error in the palette index checking function.
- Fixed a compiler warning under Cygwin (Windows-7, 32-bit system)
- Revised example.c to put text strings in a temporary character array
- instead of directly assigning string constants to png_textp members.
- This avoids compiler warnings when -Wwrite-strings is enabled.
- Added output flushing to aid debugging under Visual Studio. Unfortunately
- this is necessary because the VS2010 output window otherwise simply loses
- the error messages on error (they weren't flushed to the window before
- the process exited, apparently!)
- Added configuration support for benign errors and changed the read
- default. Also changed some warnings in the iCCP and sRGB handling
- from to benign errors. Configuration now makes read benign
- errors warnings and write benign errors to errors by default (thus
- changing the behavior on read). The simplified API always forces
- read benign errors to warnings (regardless of the system default, unless
- this is disabled in which case the simplified API can't be built.)
-
-Version 1.6.0beta19 [March 18, 2012]
- Work around for duplicate row start calls; added warning messages.
- This turns on PNG_FLAG_DETECT_UNINITIALIZED to detect app code that
- fails to call one of the 'start' routines (not enabled in libpng-1.5
- because it is technically an API change, since it did normally work
- before.) It also makes duplicate calls to png_read_start_row (an
- internal function called at the start of the image read) benign, as
- they were before changes to use png_inflate_claim. Somehow webkit is
- causing this to happen; this is probably a mis-feature in the zlib
- changes so this commit is only a work-round.
- Removed erroneous setting of DETECT_UNINITIALIZED and added more
- checks. The code now does a png_error if an attempt is made to do the
- row initialization twice; this is an application error and it has
- serious consequences because the transform data in png_struct is
- changed by each call.
- Added application error reporting and added chunk names to read
- benign errors; also added --strict to pngstest - not enabled
- yet because a warning is produced.
- Avoid the double gamma correction warning in the simplified API.
- This allows the --strict option to pass in the pngstest checks
-
-Version 1.6.0beta20 [March 29, 2012]
- Changed chunk handler warnings into benign errors, incrementally load iCCP
- Added checksum-icc.c to contrib/tools
- Prevent PNG_EXPAND+PNG_SHIFT doing the shift twice.
- Recognize known sRGB ICC profiles while reading; prefer writing the
- iCCP profile over writing the sRGB chunk, controlled by the
- PNG_sRGB_PROFILE_CHECKS option.
- Revised png_set_text_2() to avoid potential memory corruption (fixes
- CVE-2011-3048, also known as CVE-2012-3425).
-
-Version 1.6.0beta21 [April 27, 2012]
- Revised scripts/makefile.darwin: use system zlib; remove quotes around
- architecture list; add missing ppc architecture; add architecture options
- to shared library link; don't try to create a shared lib based on missing
- RELEASE variable.
- Enable png_set_check_for_invalid_index() for both read and write.
- Removed #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED in pngpriv.h around
- declaration of png_handle_unknown().
- Added -lssp_nonshared in a comment in scripts/makefile.freebsd
- and changed deprecated NOOBJ and NOPROFILE to NO_OBJ and NO_PROFILE.
-
-Version 1.6.0beta22 [May 23, 2012]
- Removed need for -Wno-cast-align with clang. clang correctly warns on
- alignment increasing pointer casts when -Wcast-align is passed. This
- fixes the cases that clang warns about either by eliminating the
- casts from png_bytep to png_uint_16p (pngread.c), or, for pngrutil.c
- where the cast is previously verified or pngstest.c where it is OK, by
- introducing new png_aligncast macros to do the cast in a way that clang
- accepts.
-
-Version 1.6.0beta23 [June 6, 2012]
- Revised CMakeLists.txt to not attempt to make a symlink under mingw.
- Made fixes for new optimization warnings from gcc 4.7.0. The compiler
- performs an optimization which is safe; however it then warns about it.
- Changing the type of 'palette_number' in pngvalid.c removes the warning.
- Do not depend upon a GCC feature macro being available for use in generating
- the linker mapfile symbol prefix.
- Improved performance of new do_check_palette_indexes() function (only
- update the value when it actually increases, move test for whether
- the check is wanted out of the function.
-
-Version 1.6.0beta24 [June 7, 2012]
- Don't check palette indexes if num_palette is 0 (as it can be in MNG files).
-
-Version 1.6.0beta25 [June 16, 2012]
- Revised png_set_keep_unknown_chunks() so num_chunks < 0 means ignore all
- unknown chunks and all known chunks except for IHDR, PLTE, tRNS, IDAT,
- and IEND. Previously it only meant ignore all unknown chunks, the
- same as num_chunks == 0. Revised png_image_skip_unused_chunks() to
- provide a list of chunks to be processed instead of a list of chunks to
- ignore. Revised contrib/gregbook/readpng2.c accordingly.
-
-Version 1.6.0beta26 [July 10, 2012]
- Removed scripts/makefile.cegcc from the *.zip and *.7z distributions; it
- depends on configure, which is not included in those archives.
- Moved scripts/chkfmt to contrib/tools.
- Changed "a+w" to "u+w" in Makefile.in to fix CVE-2012-3386.
-
-Version 1.6.0beta27 [August 11, 2012]
- Do not compile PNG_DEPRECATED, PNG_ALLOC and PNG_PRIVATE when __GNUC__ < 3.
- Do not use __restrict when GNUC is <= 3.1
- Removed references to png_zalloc() and png_zfree() from the manual.
- Fixed configurations where floating point is completely disabled. Because
- of the changes to support symbol prefixing PNG_INTERNAL_FUNCTION declares
- floating point APIs during libpng builds even if they are completely
- disabled. This requires the png floating point types (png_double*) to be
- declared even though the functions are never actually defined. This
- change provides a dummy definition so that the declarations work, yet any
- implementation will fail to compile because of an incomplete type.
- Re-eliminated the use of strcpy() in pngtest.c. An unnecessary use of
- strcpy() was accidentally re-introduced in libpng16; this change replaces
- it with strncpy().
- Eliminated use of png_sizeof(); use sizeof() instead.
- Use a consistent style for (sizeof type) and (sizeof (array))
- Cleanup of png_set_filler(). This function does very different things on
- read and write. In libpng 1.6 the two cases can be distinguished and
- considerable code cleanup, and extra error checking, is possible. This
- makes calls on the write side that have no effect be ignored with a
- png_app_error(), which can be disabled in the app using
- png_set_benign_errors(), and removes the spurious use of usr_channels
- on the read side.
- Insist on autotools 1.12.1 for git builds because there are security issues
- with 1.12 and insisting on anything less would allow 1.12 to be used.
- Removed info_ptr->signature[8] from WRITE-only builds.
- Add some conditions for compiling png_fixed(). This is a small function
- but it requires "-lm" on some platforms.
- Cause pngtest --strict to fail on any warning from libpng (not just errors)
- and cause it not to fail at the comparison step if libpng lacks support
- for writing chunks that it reads from the input (currently only implemented
- for compressed text chunks).
- Make all three "make check" test programs work without READ or WRITE support.
- Now "make check" will succeed even if libpng is compiled with -DPNG_NO_READ
- or -DPNG_NO_WRITE. The tests performed are reduced, but the basic reading
- and writing of a PNG file is always tested by one or more of the tests.
- Consistently use strlen(), memset(), memcpy(), and memcmp() instead of the
- png_strlen(), png_memset(), png_memcpy(), and png_memcmp() macros.
- Removed the png_sizeof(), png_strlen(), png_memset(), png_memcpy(), and
- png_memcmp() macros.
- Work around gcc 3.x and Microsoft Visual Studio 2010 complaints. Both object
- to the split initialization of num_chunks.
-
-Version 1.6.0beta28 [August 29, 2012]
- Unknown handling fixes and clean up. This adds more correct option
- control of the unknown handling, corrects the pre-existing bug where
- the per-chunk 'keep' setting is ignored and makes it possible to skip
- IDAT chunks in the sequential reader (broken in earlier 1.6 versions).
- There is a new test program, test-unknown.c, which is a work in progress
- (not currently part of the test suite). Comments in the header files now
- explain how the unknown handling works.
- Allow fine grain control of unknown chunk APIs. This change allows
- png_set_keep_unknown_chunks() to be turned off if not required and causes
- both read and write to behave appropriately (on read this is only possible
- if the user callback is used to handle unknown chunks). The change
- also removes the support for storing unknown chunks in the info_struct
- if the only unknown handling enabled is via the callback, allowing libpng
- to be configured with callback reading and none of the unnecessary code.
- Corrected fix for unknown handling in pngtest. This reinstates the
- libpng handling of unknown chunks other than vpAg and sTER (including
- unsafe-to-copy chunks which were dropped before) and eliminates the
- repositioning of vpAg and sTER in pngtest.png by changing pngtest.png
- (so the chunks are where libpng would put them).
- Added "tunknown" test and corrected a logic error in png_handle_unknown()
- when SAVE support is absent. Moved the shell test scripts for
- contrib/libtests from the libpng top directory to contrib/libtests.
- png_handle_unknown() must always read or skip the chunk, if
- SAVE_UNKNOWN_CHUNKS is turned off *and* the application does not set
- a user callback an unknown chunk will not be read, leading to a read
- error, which was revealed by the "tunknown" test.
- Cleaned up and corrected ICC profile handling.
- contrib/libtests/makepng: corrected 'rgb' and 'gray' cases. profile_error
- messages could be truncated; made a correct buffer size calculation and
- adjusted pngerror.c appropriately. png_icc_check_* checking improved;
- changed the functions to receive the correct color type of the PNG on read
- or write and check that it matches the color space of the profile (despite
- what the comments said before, there is danger in assuming the app will
- cope correctly with an RGB profile on a grayscale image and, since it
- violates the PNG spec, allowing it is certain to produce inconsistent
- app behavior and might even cause app crashes.) Check that profiles
- contain the tags needed to process the PNG (tags all required by the ICC
- spec). Removed unused PNG_STATIC from pngpriv.h.
-
-Version 1.6.0beta29 [September 4, 2012]
- Fixed the simplified API example programs to add the *colormap parameter
- to several of he API and improved the error message if the version field
- is not set.
- Added contrib/examples/* to the *.zip and *.7z distributions.
- Updated simplified API synopses and description of the png_image structure
- in the manual.
- Made makepng and pngtest produce identical PNGs, add "--relaxed" option
- to pngtest. The "--relaxed" option turns off the benign errors that are
- enabled by default in pre-RC builds. makepng can now write ICC profiles
- where the length has not been extended to a multiple of 4, and pngtest
- now intercepts all libpng errors, allowing the previously-introduced
- "--strict test" on no warnings to actually work.
- Improved ICC profile handling including cHRM chunk generation and fixed
- Cygwin+MSVC build errors. The ICC profile handling now includes more
- checking. Several errors that caused rejection of the profile are now
- handled with a warning in such a way that the invalid profiles will be
- read by default in release (but not pre-RC) builds but will not be
- written by default. The easy part of handling the cHRM chunk is written,
- where the ICC profile contains the required data. The more difficult
- part plus guessing a gAMA value requires code to pass selected RGB values
- through the profile.
-
-Version 1.6.0beta30 [October 24, 2012]
- Changed ICC profile matrix/vector types to not depend on array type rules.
- By the ANSI-C standard the new types should be identical to the previous
- versions, and all known versions of gcc tested with the previous versions
- except for GCC-4.2.1 work with this version. The change makes the ANSI-C
- rule that const applied to an array of elements applies instead to the
- elements in the array moot by explicitly applying const to the base
- elements of the png_icc_matrix and png_icc_vector types. The accidental
- (harmless) 'const' previously applied to the parameters of two of the
- functions have also been removed.
- Added a work around for GCC 4.2 optimization bug.
- Marked the broken (bad white point) original HP sRGB profiles correctly and
- correct comments.
- Added -DZ_SOLO to contrib/pngminim/*/makefile to work with zlib-1.2.7
- Use /MDd for vstudio debug builds. Also added pngunkown to the vstudio
- builds, fixed build errors and corrected a minor exit code error in
- pngvalid if the 'touch' file name is invalid.
- Add updated WARNING file to projects/vstudio from libpng 1.5/vstudio
- Fixed build when using #define PNG_NO_READ_GAMMA in png_do_compose() in
- pngrtran.c (Domani Hannes).
-
-Version 1.6.0beta31 [November 1, 2012]
- Undid the erroneous change to vstudio/pngvalid build in libpng-1.6.0beta30.
- Made pngvalid so that it will build outside the libpng source tree.
- Made builds -DPNG_NO_READ_GAMMA compile (the unit tests still fail).
- Made PNG_NO_READ_GAMMA switch off interfaces that depend on READ_GAMMA.
- Prior to 1.6.0 switching off READ_GAMMA did unpredictable things to the
- interfaces that use it (specifically, png_do_background in 1.4 would
- simply display composite for grayscale images but do composition
- with the incorrect arithmetic for color ones). In 1.6 the semantic
- of -DPNG_NO_READ_GAMMA is changed to simply disable any interface that
- depends on it; this obliges people who set it to consider whether they
- really want it off if they happen to use any of the interfaces in
- question (typically most users who disable it won't).
- Fixed GUIDs in projects/vstudio. Some were duplicated or missing,
- resulting in VS2010 having to update the files.
- Removed non-working ICC profile support code that was mostly added to
- libpng-1.6.0beta29 and beta30. There was too much code for too little
- gain; implementing full ICC color correction may be desirable but is left
- up to applications.
-
-Version 1.6.0beta32 [November 25, 2012]
- Fixed an intermittent SEGV in pngstest due to an uninitialized array element.
- Added the ability for contrib/libtests/makepng.c to make a PNG with just one
- color. This is useful for debugging pngstest color inaccuracy reports.
- Fixed error checking in the simplified write API (Olaf van der Spek)
- Made png_user_version_check() ok to use with libpng version 1.10.x and later.
-
-Version 1.6.0beta33 [December 15, 2012]
- Fixed typo in png.c (PNG_SET_CHUNK_MALLOC_MAX should be PNG_CHUNK_MALLOC_MAX)
- that causes the MALLOC_MAX limit not to work (John Bowler)
- Change png_warning() to png_app_error() in pngwrite.c and comment the
- fall-through condition.
- Change png_warning() to png_app_warning() in png_write_tRNS().
- Rearranged the ARM-NEON optimizations: Isolated the machine specific code
- to the hardware subdirectory and added comments to pngrutil.c so that
- implementors of other optimizations know what to do.
- Fixed cases of unquoted DESTDIR in Makefile.am
- Rebuilt Makefile.in, etc., with autoconf-2.69 and automake-1.12.5.
-
-Version 1.6.0beta34 [December 19, 2012]
- Cleaned up whitespace in the synopsis portion of the manpage "libpng.3"
- Disassembled the version number in scripts/options.awk (necessary for
- building on SunOs).
-
-Version 1.6.0beta35 [December 23, 2012]
- Made default Zlib compression settings be configurable. This adds #defines to
- pnglibconf.h to control the defaults.
- Fixed Windows build issues, enabled ARM compilation. Various warnings issued
- by earlier versions of GCC fixed for Cygwin and Min/GW (which both use old
- GCCs.) ARM support is enabled by default in zlib.props (unsupported by
- Microsoft) and ARM compilation is made possible by deleting the check for
- x86. The test programs cannot be run because they are not signed.
-
-Version 1.6.0beta36 [January 2, 2013]
- Discontinued distributing libpng-1.x.x.tar.bz2.
- Discontinued distributing libpng-1.7.0-1.6.0-diff.txt and similar.
- Rebuilt configure with autoconf-2.69 (inadvertently not done in beta33)
- Fixed 'make distcheck' on SUN OS - libpng.so was not being removed
-
-Version 1.6.0beta37 [January 10, 2013]
- Fixed conceivable but difficult to repro overflow. Also added two test
- programs to generate and test a PNG which should have the problem.
-
-Version 1.6.0beta39 [January 19, 2013]
- Again corrected attempt at overflow detection in png_set_unknown_chunks()
- (CVE-2013-7353). Added overflow detection in png_set_sPLT() and
- png_set_text_2() (CVE-2013-7354).
-
-Version 1.6.0beta40 [January 20, 2013]
- Use consistent handling of overflows in text, sPLT and unknown png_set_* APIs
-
-Version 1.6.0rc01 [January 26, 2013]
- No changes.
-
-Version 1.6.0rc02 [February 4, 2013]
- Added png_get_palette_max() function.
-
-Version 1.6.0rc03 [February 5, 2013]
- Fixed the png_get_palette_max API.
-
-Version 1.6.0rc04 [February 7, 2013]
- Turn serial tests back on (recently turned off by autotools upgrade).
-
-Version 1.6.0rc05 [February 8, 2013]
- Update manual about png_get_palette_max().
-
-Version 1.6.0rc06 [February 9, 2013]
- Fixed missing dependency in --prefix builds The intermediate
- internal 'prefix.h' file can only be generated correctly after
- pnglibconf.h, however the dependency was not in Makefile.am. The
- symptoms are unpredictable depending on the order make chooses to
- build pngprefix.h and pnglibconf.h, often the error goes unnoticed
- because there is a system pnglibconf.h to use instead.
-
-Version 1.6.0rc07 [February 10, 2013]
- Enclosed the new png_get_palette_max in #ifdef PNG_GET_PALETTE_MAX_SUPPORTED
- block, and revised pnglibconf.h and pnglibconf.h.prebuilt accordingly.
-
-Version 1.6.0rc08 [February 10, 2013]
- Fix typo in png.h #ifdef
-
-Version 1.6.0 [February 14, 2013]
- No changes.
-
-Version 1.6.1beta01 [February 16, 2013]
- Made symbol prefixing work with the ARM neon optimizations. Also allow
- pngpriv.h to be included for preprocessor definitions only, so it can
- be used in non-C/C++ files. Back ported from libpng 1.7.
- Made sRGB check numbers consistent.
- Ported libpng 1.5 options.awk/dfn file handling to 1.6, fixed one bug.
- Removed cc -E workround, corrected png_get_palette_max API Tested on
- SUN OS cc 5.9, which demonstrates the tokenization problem previously
- avoided by using /lib/cpp. Since all .dfn output is now protected in
- double quotes unless it is to be macro substituted the fix should
- work everywhere.
- Enabled parallel tests - back ported from libpng-1.7.
- scripts/pnglibconf.dfa formatting improvements back ported from libpng17.
- Fixed a race condition in the creation of the build 'scripts' directory
- while building with a parallel make.
- Use approved/supported Android method to check for NEON, use Linux/POSIX
- 1003.1 API to check /proc/self/auxv avoiding buffer allocation and other
- library calls (ported from libpng15).
-
-Version 1.6.1beta02 [February 19, 2013]
- Use parentheses more consistently in "#if defined(MACRO)" tests.
- Folded long lines.
- Reenabled code to allow zero length PLTE chunks for MNG.
-
-Version 1.6.1beta03 [February 22, 2013]
- Fixed ALIGNED_MEMORY support.
- Added a new configure option:
- --enable-arm-neon=always will stop the run-time checks. New checks
- within arm/arm_init.c will cause the code not to be compiled unless
- __ARM_NEON__ is set. This should make it fail safe (if someone asks
- for it on then the build will fail if it can't be done.)
- Updated the INSTALL document.
-
-Version 1.6.1beta04 [February 27, 2013]
- Revised INSTALL to recommend using CPPFLAGS instead of INCLUDES.
- Revised scripts/makefile.freebsd to respect ZLIBLIB and ZLIBINC.
- Revised scripts/dfn.awk to work with the buggy MSYS awk that has trouble
- with CRLF line endings.
-
-Version 1.6.1beta05 [March 1, 2013]
- Avoid a possible memory leak in contrib/gregbook/readpng.c
-
-Version 1.6.1beta06 [March 4, 2013]
- Better documentation of unknown handling API interactions.
- Corrected Android builds and corrected libpng.vers with symbol
- prefixing. It also makes those tests compile and link on Android.
- Added an API png_set_option() to set optimization options externally,
- providing an alternative and general solution for the non-portable
- run-time tests used by the ARM Neon code, using the PNG_ARM_NEON option.
- The order of settings vs options in pnglibconf.h is reversed to allow
- settings to depend on options and options can now set (or override) the
- defaults for settings.
-
-Version 1.6.1beta07 [March 7, 2013]
- Corrected simplified API default gamma for color-mapped output, added
- a flag to change default. In 1.6.0 when the simplified API was used
- to produce color-mapped output from an input image with no gamma
- information the gamma assumed for the input could be different from
- that assumed for non-color-mapped output. In particular 16-bit depth
- input files were assumed to be sRGB encoded, whereas in the 'direct'
- case they were assumed to have linear data. This was an error. The
- fix makes the simplified API treat all input files the same way and
- adds a new flag to the png_image::flags member to allow the
- application/user to specify that 16-bit files contain sRGB data
- rather than the default linear.
- Fixed bugs in the pngpixel and makepng test programs.
-
-Version 1.6.1beta08 [March 7, 2013]
- Fixed CMakelists.txt to allow building a single variant of the library
- (Claudio Bley):
- Introduced a PNG_LIB_TARGETS variable that lists all activated library
- targets. It is an error if this variable ends up empty, ie. you have
- to build at least one library variant.
- Made the *_COPY targets only depend on library targets actually being build.
- Use PNG_LIB_TARGETS to unify a code path.
- Changed the CREATE_SYMLINK macro to expect the full path to a file as the
- first argument. When symlinking the filename component of that path is
- determined and used as the link target.
- Use copy_if_different in the CREATE_SYMLINK macro.
-
-Version 1.6.1beta09 [March 13, 2013]
- Eliminated two warnings from the Intel C compiler. The warnings are
- technically valid, although a reasonable treatment of division would
- show it to be incorrect.
-
-Version 1.6.1rc01 [March 21, 2013]
- No changes.
-
-Version 1.6.1 [March 28, 2013]
- No changes.
-
-Version 1.6.2beta01 [April 14, 2013]
- Updated documentation of 1.5.x to 1.6.x changes in iCCP chunk handling.
- Fixed incorrect warning of excess deflate data. End condition - the
- warning would be produced if the end of the deflate stream wasn't read
- in the last row. The warning is harmless.
- Corrected the test on user transform changes on read. It was in the
- png_set of the transform function, but that doesn't matter unless the
- transform function changes the rowbuf size, and that is only valid if
- transform_info is called.
- Corrected a misplaced closing bracket in contrib/libtests/pngvalid.c
- (Flavio Medeiros).
- Corrected length written to uncompressed iTXt chunks (Samuli Suominen).
- Bug was introduced in libpng-1.6.0.
-
-Version 1.6.2rc01 [April 18, 2013]
- Added contrib/tools/fixitxt.c, to repair the erroneous iTXt chunk length
- written by libpng-1.6.0 and 1.6.1.
- Disallow storing sRGB information when the sRGB is not supported.
-
-Version 1.6.2rc02 [April 18, 2013]
- Merge pngtest.c with libpng-1.7.0
-
-Version 1.6.2rc03 [April 22, 2013]
- Trivial spelling cleanup.
-
-Version 1.6.2rc04 and 1.6.2rc05 [omitted]
-
-Version 1.6.2rc06 [April 24, 2013]
- Reverted to version 1.6.2rc03. Recent changes to arm/neon support
- have been ported to libpng-1.7.0beta09 and will reappear in version
- 1.6.3beta01.
-
-Version 1.6.2 [April 25, 2013]
- No changes.
-
-Version 1.6.3beta01 [April 25, 2013]
- Revised stack marking in arm/filter_neon.S and configure.ac.
- Ensure that NEON filter stuff is completely disabled when switched 'off'.
- Previously the ARM NEON specific files were still built if the option
- was switched 'off' as opposed to being explicitly disabled.
-
-Version 1.6.3beta02 [April 26, 2013]
- Test for 'arm*' not just 'arm' in the host_cpu configure variable.
- Rebuilt the configure scripts.
-
-Version 1.6.3beta03 [April 30, 2013]
- Expanded manual paragraph about writing private chunks, particularly
- the need to call png_set_keep_unknown_chunks() when writing them.
- Avoid dereferencing NULL pointer possibly returned from
- png_create_write_struct() (Andrew Church).
-
-Version 1.6.3beta05 [May 9, 2013]
- Calculate our own zlib windowBits when decoding rather than trusting the
- CMF bytes in the PNG datastream.
- Added an option to force maximum window size for inflating, which was
- the behavior of libpng15 and earlier, via a new PNG_MAXIMUM_INFLATE_WINDOW
- option for png_set_options().
- Added png-fix-itxt and png-fix-too-far-back to the built programs and
- removed warnings from the source code and timepng that are revealed as
- a result.
- Detect wrong libpng versions linked to png-fix-too-far-back, which currently
- only works with libpng versions that can be made to reliably fail when
- the deflate data contains an out-of-window reference. This means only
- 1.6 and later.
- Fixed gnu issues: g++ needs a static_cast, gcc 4.4.7 has a broken warning
- message which it is easier to work round than ignore.
- Updated contrib/pngminus/pnm2png.c (Paul Stewart):
- Check for EOF
- Ignore "#" delimited comments in input file to pnm2png.c.
- Fixed whitespace handling
- Added a call to png_set_packing()
- Initialize dimension values so if sscanf fails at least we have known
- invalid values.
- Attempt to detect configuration issues with png-fix-too-far-back, which
- requires both the correct libpng and the correct zlib to function
- correctly.
- Check ZLIB_VERNUM for mismatches, enclose #error in quotes
- Added information in the documentation about problems with and fixes for
- the bad CRC and bad iTXt chunk situations.
-
-Version 1.6.3beta06 [May 12, 2013]
- Allow contrib/pngminus/pnm2png.c to compile without WRITE_INVERT and
- WRITE_PACK supported (writes error message that it can't read P1 or
- P4 PBM files).
- Improved png-fix-too-far-back usage message, added --suffix option.
- Revised contrib/pngminim/*/makefile to generate pnglibconf.h with the
- right zlib header files.
- Separated CPPFLAGS and CFLAGS in contrib/pngminim/*/makefile
-
-Version 1.6.3beta07 [June 8, 2013]
- Removed a redundant test in png_set_IHDR().
- Added set(CMAKE_CONFIGURATION_TYPES ...) to CMakeLists.txt (Andrew Hundt)
- Deleted set(CMAKE_BUILD_TYPE) block from CMakeLists.txt
- Enclose the prototypes for the simplified write API in
- #ifdef PNG_STDIO_SUPPORTED/#endif
- Make ARM NEON support work at compile time (not just configure time).
- This moves the test on __ARM_NEON__ into pngconf.h to avoid issues when
- using a compiler that compiles for multiple architectures at one time.
- Removed PNG_FILTER_OPTIMIZATIONS and PNG_ARM_NEON_SUPPORTED from
- pnglibconf.h, allowing more of the decisions to be made internally
- (pngpriv.h) during the compile. Without this, symbol prefixing is broken
- under certain circumstances on ARM platforms. Now only the API parts of
- the optimizations ('check' vs 'api') are exposed in the public header files
- except that the new setting PNG_ARM_NEON_OPT documents how libpng makes the
- decision about whether or not to use the optimizations.
- Protect symbol prefixing against CC/CPPFLAGS/CFLAGS usage.
- Previous iOS/Xcode fixes for the ARM NEON optimizations moved the test
- on __ARM_NEON__ from configure time to compile time. This breaks symbol
- prefixing because the definition of the special png_init_filter_functions
- call was hidden at configure time if the relevant compiler arguments are
- passed in CFLAGS as opposed to CC. This change attempts to avoid all
- the confusion that would result by declaring the init function even when
- it is not used, so that it will always get prefixed.
-
-Version 1.6.3beta08 [June 18, 2013]
- Revised libpng.3 so that "doclifter" can process it.
-
-Version 1.6.3beta09 [June 27, 2013]
- Revised example.c to illustrate use of PNG_DEFAULT_sRGB and PNG_GAMMA_MAC_18
- as parameters for png_set_gamma(). These have been available since
- libpng-1.5.4.
- Renamed contrib/tools/png-fix-too-far-back.c to pngfix.c and revised it
- to check all compressed chunks known to libpng.
-
-Version 1.6.3beta10 [July 5, 2013]
- Updated documentation to show default behavior of benign errors correctly.
- Only compile ARM code when PNG_READ_SUPPORTED is defined.
- Fixed undefined behavior in contrib/tools/pngfix.c and added new strip
- option. pngfix relied on undefined behavior and even a simple change from
- gcc to g++ caused it to fail. The new strip option 'unsafe' has been
- implemented and is the default if --max is given. Option names have
- been clarified, with --strip=transform now stripping the bKGD chunk,
- which was stripped previously with --strip=unused.
- Added all documented chunk types to pngpriv.h
- Unified pngfix.c source with libpng17.
-
-Version 1.6.3rc01 [July 11, 2013]
- No changes.
-
-Version 1.6.3 [July 18, 2013]
- Revised manual about changes in iTXt chunk handling made in libpng-1.6.0.
- Added "/* SAFE */" comments in pngrutil.c and pngrtran.c where warnings
- may be erroneously issued by code-checking applications.
-
-Version 1.6.4beta01 [August 21, 2013]
- Added information about png_set_options() to the manual.
- Delay calling png_init_filter_functions() until a row with nonzero filter
- is found.
-
-Version 1.6.4beta02 [August 30, 2013]
- Fixed inconsistent conditional compilation of png_chunk_unknown_handling()
- prototype, definition, and usage. Made it depend on
- PNG_HANDLE_AS_UNKNOWN_SUPPORTED everywhere.
-
-Version 1.6.4rc01 [September 5, 2013]
- No changes.
-
-Version 1.6.4 [September 12, 2013]
- No changes.
-
-Version 1.6.5 [September 14, 2013]
- Removed two stray lines of code from arm/arm_init.c.
-
-Version 1.6.6 [September 16, 2013]
- Removed two stray lines of code from arm/arm_init.c, again.
-
-Version 1.6.7beta01 [September 30, 2013]
- Revised unknown chunk code to correct several bugs in the NO_SAVE_/NO_WRITE
- combination
- Allow HANDLE_AS_UNKNOWN to work when other options are configured off. Also
- fixed the pngminim makefiles to work when $(MAKEFLAGS) contains stuff
- which terminates the make options (as by default in recent versions of
- Gentoo).
- Avoid up-cast warnings in pngvalid.c. On ARM the alignment requirements of
- png_modifier are greater than that of png_store and as a consequence
- compilation of pngvalid.c results in a warning about increased alignment
- requirements because of the bare cast to (png_modifier*). The code is safe,
- because the pointer is known to point to a stack allocated png_modifier,
- but this change avoids the warning.
- Fixed default behavior of ARM_NEON_API. If the ARM NEON API option was
- compiled without the CHECK option it defaulted to on, not off.
- Check user callback behavior in pngunknown.c. Previous versions compiled
- if SAVE_UNKNOWN was not available but did nothing since the callback
- was never implemented.
- Merged pngunknown.c with 1.7 version and back ported 1.7 improvements/fixes
-
-Version 1.6.7beta02 [October 12, 2013]
- Made changes for compatibility with automake 1.14:
- 1) Added the 'compile' program to the list of programs that must be cleaned
- in autogen.sh
- 2) Added 'subdir-objects' which causes .c files in sub-directories to be
- compiled such that the corresponding .o files are also in the
- sub-directory. This is because automake 1.14 warns that the
- current behavior of compiling to the top level directory may be removed
- in the future.
- 3) Updated dependencies on pnglibconf.h to match the new .o locations and
- added all the files in contrib/libtests and contrib/tools that depend
- on pnglibconf.h
- 4) Added 'BUILD_SOURCES = pnglibconf.h'; this is the automake recommended
- way of handling the dependencies of sources that are machine generated;
- unfortunately it only works if the user does 'make all' or 'make check',
- so the dependencies (3) are still required.
- Cleaned up (char*) casts of zlib messages. The latest version of the Intel C
- compiler complains about casting a string literal as (char*), so copied the
- treatment of z_const from the library code into pngfix.c
- Simplified error message code in pngunknown. The simplification has the
- useful side effect of avoiding a bogus warning generated by the latest
- version of the Intel C compiler (it objects to
- condition ? string-literal : string-literal).
- Make autogen.sh work with automake 1.13 as well as 1.14. Do this by always
- removing the 1.14 'compile' script but never checking for it.
-
-Version 1.6.7beta03 [October 19, 2013]
- Added ARMv8 support (James Yu <james.yu at linaro.org>). Added file
- arm/filter_neon_intrinsics.c; enable with -mfpu=neon.
- Revised pngvalid to generate size images with as many filters as it can
- manage, limited by the number of rows.
- Cleaned up ARM NEON compilation handling. The tests are now in pngpriv.h
- and detect the broken GCC compilers.
-
-Version 1.6.7beta04 [October 26, 2013]
- Allow clang derived from older GCC versions to use ARM intrinsics. This
- causes all clang builds that use -mfpu=neon to use the intrinsics code,
- not the assembler code. This has only been tested on iOS 7. It may be
- necessary to exclude some earlier clang versions but this seems unlikely.
- Changed NEON implementation selection mechanism. This allows assembler
- or intrinsics to be turned on at compile time during the build by defining
- PNG_ARM_NEON_IMPLEMENTATION to the correct value (2 or 1). This macro
- is undefined by default and the build type is selected in pngpriv.h.
-
-Version 1.6.7rc01 [November 2, 2013]
- No changes.
-
-Version 1.6.7rc02 [November 7, 2013]
- Fixed #include in filter_neon_intrinsics.c and ctype macros. The ctype char
- checking macros take an unsigned char argument, not a signed char.
-
-Version 1.6.7 [November 14, 2013]
- No changes.
-
-Version 1.6.8beta01 [November 24, 2013]
- Moved prototype for png_handle_unknown() in pngpriv.h outside of
- the #ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED/#endif block.
- Added "-Wall" to CFLAGS in contrib/pngminim/*/makefile
- Conditionally compile some unused functions reported by -Wall in
- pngminim.
- Fixed 'minimal' builds. Various obviously useful minimal configurations
- don't build because of missing contrib/libtests test programs and
- overly complex dependencies in scripts/pnglibconf.dfa. This change
- adds contrib/conftest/*.dfa files that can be used in automatic build
- scripts to ensure that these configurations continue to build.
- Enabled WRITE_INVERT and WRITE_PACK in contrib/pngminim/encoder.
- Fixed pngvalid 'fail' function declaration on the Intel C Compiler.
- This reverts to the previous 'static' implementation and works round
- the 'unused static function' warning by using PNG_UNUSED().
-
-Version 1.6.8beta02 [November 30, 2013]
- Removed or marked PNG_UNUSED some harmless "dead assignments" reported
- by clang scan-build.
- Changed tabs to 3 spaces in png_debug macros and changed '"%s"m'
- to '"%s" m' to improve portability among compilers.
- Changed png_free_default() to free() in pngtest.c
-
-Version 1.6.8rc01 [December 12, 2013]
- Tidied up pngfix inits and fixed pngtest no-write builds.
-
-Version 1.6.8rc02 [December 14, 2013]
- Handle zero-length PLTE chunk or NULL palette with png_error()
- instead of png_chunk_report(), which by default issues a warning
- rather than an error, leading to later reading from a NULL pointer
- (png_ptr->palette) in png_do_expand_palette(). This is CVE-2013-6954
- and VU#650142. Libpng-1.6.1 through 1.6.7 are vulnerable.
- Libpng-1.6.0 and earlier do not have this bug.
-
-Version 1.6.8 [December 19, 2013]
- No changes.
-
-Version 1.6.9beta01 [December 26, 2013]
- Bookkeeping: Moved functions around (no changes). Moved transform
- function definitions before the place where they are called so that
- they can be made static. Move the intrapixel functions and the
- grayscale palette builder out of the png?tran.c files. The latter
- isn't a transform function and is no longer used internally, and the
- former MNG specific functions are better placed in pngread/pngwrite.c
- Made transform implementation functions static. This makes the internal
- functions called by png_do_{read|write}_transformations static. On an
- x86-64 DLL build (Gentoo Linux) this reduces the size of the text
- segment of the DLL by 1208 bytes, about 0.6%. It also simplifies
- maintenance by removing the declarations from pngpriv.h and allowing
- easier changes to the internal interfaces.
- Rebuilt configure scripts with automake-1.14.1 and autoconf-2.69
- in the tar distributions.
-
-Version 1.6.9beta02 [January 1, 2014]
- Added checks for libpng 1.5 to pngvalid.c. This supports the use of
- this version of pngvalid in libpng 1.5
- Merged with pngvalid.c from libpng-1.7 changes to create a single
- pngvalid.c
- Removed #error macro from contrib/tools/pngfix.c (Thomas Klausner).
- Merged pngrio.c, pngtrans.c, pngwio.c, and pngerror.c with libpng-1.7.0
- Merged libpng-1.7.0 changes to make no-interlace configurations work
- with test programs.
- Revised pngvalid.c to support libpng 1.5, which does not support the
- PNG_MAXIMUM_INFLATE_WINDOW option, so #define it out when appropriate in
- pngvalid.c
- Allow unversioned links created on install to be disabled in configure.
- In configure builds 'make install' changes/adds links like png.h
- and libpng.a to point to the newly installed, versioned, files (e.g.
- libpng17/png.h and libpng17.a). Three new configure options and some
- rearrangement of Makefile.am allow creation of these links to be disabled.
-
-Version 1.6.9beta03 [January 10, 2014]
- Removed potentially misleading warning from png_check_IHDR().
-
-Version 1.6.9beta04 [January 20, 2014]
- Updated scripts/makefile.* to use CPPFLAGS (Cosmin).
- Added clang attribute support (Cosmin).
-
-Version 1.6.9rc01 [January 28, 2014]
- No changes.
-
-Version 1.6.9rc02 [January 30, 2014]
- Quiet an uninitialized memory warning from VC2013 in png_get_png().
-
-Version 1.6.9 [February 6, 2014]
-
-Version 1.6.10beta01 [February 9, 2014]
- Backported changes from libpng-1.7.0beta30 and beta31:
- Fixed a large number of instances where PNGCBAPI was omitted from
- function definitions.
- Added pngimage test program for png_read_png() and png_write_png()
- with two new test scripts.
- Removed dependence on !PNG_READ_EXPAND_SUPPORTED for calling
- png_set_packing() in png_read_png().
- Fixed combination of ~alpha with shift. On read invert alpha, processing
- occurred after shift processing, which causes the final values to be
- outside the range that should be produced by the shift. Reversing the
- order on read makes the two transforms work together correctly and mirrors
- the order used on write.
- Do not read invalid sBIT chunks. Previously libpng only checked sBIT
- values on write, so a malicious PNG writer could therefore cause
- the read code to return an invalid sBIT chunk, which might lead to
- application errors or crashes. Such chunks are now skipped (with
- chunk_benign_error).
- Make png_read_png() and png_write_png() prototypes in png.h depend
- upon PNG_READ_SUPPORTED and PNG_WRITE_SUPPORTED.
- Support builds with unsupported PNG_TRANSFORM_* values. All of the
- PNG_TRANSFORM_* values are always defined in png.h and, because they
- are used for both read and write in some cases, it is not reliable
- to #if out ones that are totally unsupported. This change adds error
- detection in png_read_image() and png_write_image() to do a
- png_app_error() if the app requests something that cannot be done
- and it adds corresponding code to pngimage.c to handle such options
- by not attempting to test them.
-
-Version 1.6.10beta02 [February 23, 2014]
- Moved redefines of png_error(), png_warning(), png_chunk_error(),
- and png_chunk_warning() from pngpriv.h to png.h to make them visible
- to libpng-calling applications.
- Moved OS dependent code from arm/arm_init.c, to allow the included
- implementation of the ARM NEON discovery function to be set at
- build-time and provide sample implementations from the current code in the
- contrib/arm-neon subdirectory. The __linux__ code has also been changed to
- compile and link on Android by using /proc/cpuinfo, and the old linux code
- is in contrib/arm-neon/linux-auxv.c. The new code avoids POSIX and Linux
- dependencies apart from opening /proc/cpuinfo and is C90 compliant.
- Check for info_ptr == NULL early in png_read_end() so we don't need to
- run all the png_handle_*() and depend on them to return if info_ptr == NULL.
- This improves the performance of png_read_end(png_ptr, NULL) and makes
- it more robust against future programming errors.
- Check for __has_extension before using it in pngconf.h, to
- support older Clang versions (Jeremy Sequoia).
- Treat CRC error handling with png_set_crc_action(), instead of with
- png_set_benign_errors(), which has been the case since libpng-1.6.0beta18.
- Use a user warning handler in contrib/gregbook/readpng2.c instead of default,
- so warnings will be put on stderr even if libpng has CONSOLE_IO disabled.
- Added png_ptr->process_mode = PNG_READ_IDAT_MODE in png_push_read_chunk
- after recognizing the IDAT chunk, which avoids an infinite loop while
- reading a datastream whose first IDAT chunk is of zero-length.
- This fixes CERT VU#684412 and CVE-2014-0333.
- Don't recognize known sRGB profiles as sRGB if they have been hacked,
- but don't reject them and don't issue a copyright violation warning.
-
-Version 1.6.10beta03 [February 25, 2014]
- Moved some documentation from png.h to libpng.3 and libpng-manual.txt
- Minor editing of contrib/arm-neon/README and contrib/examples/*.c
-
-Version 1.6.10rc01 [February 27, 2014]
- Fixed typos in the manual and in scripts/pnglibconf.dfa (CFLAGS -> CPPFLAGS
- and PNG_USR_CONFIG -> PNG_USER_CONFIG).
-
-Version 1.6.10rc02 [February 28, 2014]
- Removed unreachable return statement after png_chunk_error()
- in pngrutil.c
-
-Version 1.6.10rc03 [March 4, 2014]
- Un-deprecated png_data_freer().
-
-Version 1.6.10 [March 6, 2014]
- No changes.
-
-Version 1.6.11beta01 [March 17, 2014]
- Use "if (value != 0)" instead of "if (value)" consistently.
- Changed ZlibSrcDir from 1.2.5 to 1.2.8 in projects/vstudio.
- Moved configuration information from the manual to the INSTALL file.
-
-Version 1.6.11beta02 [April 6, 2014]
- Removed #if/#else/#endif from inside two pow() calls in pngvalid.c because
- they were handled improperly by Portland Group's PGI-14.1 - PGI-14.3
- when using its "__builtin_pow()" function.
- Silence 'unused parameter' build warnings (Cosmin Truta).
- $(CP) is now used alongside $(RM_F). Also, use 'copy' instead of 'cp'
- where applicable, and applied other minor makefile changes (Cosmin).
- Don't warn about invalid dimensions exceeding user limits (Cosmin).
- Allow an easy replacement of the default pre-built configuration
- header with a custom header, via the make PNGLIBCONF_H_PREBUILT
- macro (Cosmin).
-
-Version 1.6.11beta03 [April 6, 2014]
- Fixed a typo in pngrutil.c, introduced in libpng-1.5.6, that interferes
- with "blocky" expansion of sub-8-bit interlaced PNG files (Eric Huss).
- Optionally use __builtin_bswap16() in png_do_swap().
-
-Version 1.6.11beta04 [April 19, 2014]
- Made progressive reading of interlaced images consistent with the
- behavior of the sequential reader and consistent with the manual, by
- moving some code out of the PNG_READ_INTERLACING_SUPPORTED blocks. The
- row_callback now receives the proper pass number and unexpanded rows, when
- png_combine_row() isn't built or used, and png_set_interlace_handling()
- is not called.
- Allow PNG_sRGB_PROFILE_CHECKING = (-1) to mean no sRGB profile checking.
-
-Version 1.6.11beta05 [April 26, 2014]
- Do not reject ICC V2 profiles that lack padding (Kai-Uwe Behrmann).
- Relocated closing bracket of the sRGB profile test loop to avoid getting
- "Not recognizing known sRGB profile that has been edited" warning for
- ICC V2 profiles that lack the MD5 signature in the profile header.
-
-Version 1.6.11beta06 [May 19, 2014]
- Added PNG_SKIP_sRGB_CHECK_PROFILE choice for png_set_option().
-
-Version 1.6.11rc01 [May 27, 2014]
- No changes.
-
-Version 1.6.11rc02 [June 3, 2014]
- Test ZLIB_VERNUM instead of PNG_ZLIB_VERNUM in contrib/tools/pngfix.c
-
-Version 1.6.11 [June 5, 2014]
- No changes.
-
-Version 1.6.12rc01 [June 6, 2014]
- Relocated new code from 1.6.11beta06 in png.c to a point after the
- declarations (Max Stepin).
-
-Version 1.6.12rc02 [June 7, 2014]
- Changed file permissions of contrib/tools/intgamma.sh,
- test-driver, and compile from 0644 to 0755 (Cosmin).
-
-Version 1.6.12rc03 [June 8, 2014]
- Ensure "__has_attribute()" macro exists before trying to use it with
- old clang compilers (MacPorts Ticket #43939).
-
-Version 1.6.12 [June 12, 2014]
- No changes.
-
-Version 1.6.13beta01 [July 4, 2014]
- Quieted -Wsign-compare and -Wclobber compiler warnings in
- contrib/pngminus/*.c
- Added "(void) png_ptr;" where needed in contrib/gregbook to quiet
- compiler complaints about unused pointers.
- Split a long output string in contrib/gregbook/rpng2-x.c.
- Added "PNG_SET_OPTION" requirement for sRGB chunk support to pnglibconf.dfa,
- Needed for write-only support (John Bowler).
- Changed "if defined(__ARM_NEON__)" to
- "if (defined(__ARM_NEON__) || defined(__ARM_NEON))" (James Wu).
- Fixed clang no-warning builds: png_digit was defined but never used.
-
-Version 1.6.13beta02 [July 21, 2014]
- Fixed an incorrect separator ("/" should be "\") in scripts/makefile.vcwin32
- (bug report from Wolfgang S. Kechel). Bug was introduced in libpng-1.6.11.
- Also fixed makefile.bc32, makefile.bor, makefile.msc, makefile.intel, and
- makefile.tc3 similarly.
-
-Version 1.6.13beta03 [August 3, 2014]
- Removed scripts/makefile.elf. It has not worked since libpng-1.5.0beta14
- due to elimination of the PNG_FUNCTION_EXPORT and PNG_DATA_EXPORT
- definitions from pngconf.h.
- Ensure that CMakeLists.txt makes the target "lib" directory before making
- symbolic link into it (SourceForge bug report #226 by Rolf Timmermans).
-
-Version 1.6.13beta04 [August 8, 2014]
- Added opinion that the ECCN (Export Control Classification Number) for
- libpng is EAR99 to the README file.
- Eliminated use of "$<" in makefile explicit rules, when copying
- $PNGLIBCONF_H_PREBUILT. This does not work on some versions of make;
- bug introduced in libpng version 1.6.11.
-
-Version 1.6.13rc01 [August 14, 2014]
- Made "ccopts" agree with "CFLAGS" in scripts/makefile.hp* and makefile.*sunu
-
-Version 1.6.13 [August 21, 2014]
- No changes.
-
-Version 1.6.14beta01 [September 14, 2014]
- Guard usage of png_ptr->options with #ifdef PNG_SET_OPTION_SUPPORTED.
- Do not build contrib/tools/pngfix.c when PNG_SETJMP_NOT_SUPPORTED,
- to allow "make" to complete without setjmp support (bug report by
- Claudio Fontana)
- Add "#include <setjmp.h>" to contrib/tools/pngfix.c (John Bowler)
-
-Version 1.6.14beta02 [September 18, 2014]
- Use nanosleep() instead of usleep() in contrib/gregbook/rpng2-x.c
- because usleep() is deprecated.
- Define usleep() in contrib/gregbook/rpng2-x.c if not already defined
- in unistd.h and nanosleep() is not available; fixes error introduced
- in libpng-1.6.13.
- Disable floating point exception handling in pngvalid.c when
- PNG_FLOATING_ARITHMETIC is not supported (bug report by "zootus
- at users.sourceforge.net").
-
-Version 1.6.14beta03 [September 19, 2014]
- Define FE_DIVBYZERO, FE_INVALID, and FE_OVERFLOW in pngvalid.c if not
- already defined. Revert floating point exception handling in pngvalid.c
- to version 1.6.14beta01 behavior.
-
-Version 1.6.14beta04 [September 27, 2014]
- Fixed incorrect handling of the iTXt compression flag in pngrutil.c
- (bug report by Shunsaku Hirata). Bug was introduced in libpng-1.6.0.
-
-Version 1.6.14beta05 [October 1, 2014]
- Added "option READ_iCCP enables READ_COMPRESSED_TEXT" to pnglibconf.dfa
-
-Version 1.6.14beta06 [October 5, 2014]
- Removed unused "text_len" parameter from private function png_write_zTXt().
- Conditionally compile some code in png_deflate_claim(), when
- PNG_WARNINGS_SUPPORTED and PNG_ERROR_TEXT_SUPPORTED are disabled.
- Replaced repeated code in pngpread.c with PNG_PUSH_SAVE_BUFFER_IF_FULL.
- Added "chunk iTXt enables TEXT" and "chunk zTXt enables TEXT"
- to pnglibconf.dfa.
- Removed "option READ_COMPRESSED_TEXT enables READ_TEXT" from pnglibconf.dfa,
- to make it possible to configure a libpng that supports iCCP but not TEXT.
-
-Version 1.6.14beta07 [October 7, 2014]
- Removed "option WRITE_COMPRESSED_TEXT enables WRITE_TEXT" from pnglibconf.dfa
- Only mark text chunks as written after successfully writing them.
-
-Version 1.6.14rc01 [October 15, 2014]
- Fixed some typos in comments.
-
-Version 1.6.14rc02 [October 17, 2014]
- Changed png_convert_to_rfc_1123() to png_convert_to_rfc_1123_buffer()
- in the manual, to reflect the change made in libpng-1.6.0.
- Updated README file to explain that direct access to the png_struct
- and info_struct members has not been permitted since libpng-1.5.0.
-
-Version 1.6.14 [October 23, 2014]
- No changes.
-
-Version 1.6.15beta01 [October 29, 2014]
- Changed "if (!x)" to "if (x == 0)" and "if (x)" to "if (x != 0)"
- Simplified png_free_data().
- Added missing "ptr = NULL" after some instances of png_free().
-
-Version 1.6.15beta02 [November 1, 2014]
- Changed remaining "if (!x)" to "if (x == 0)" and "if (x)" to "if (x != 0)"
-
-Version 1.6.15beta03 [November 3, 2014]
- Added PNG_USE_ARM_NEON configuration flag (Marcin Juszkiewicz).
-
-Version 1.6.15beta04 [November 4, 2014]
- Removed new PNG_USE_ARM_NEON configuration flag and made a one-line
- revision to configure.ac to support ARM on aarch64 instead (John Bowler).
-
-Version 1.6.15beta05 [November 5, 2014]
- Use png_get_libpng_ver(NULL) instead of PNG_LIBPNG_VER_STRING in
- example.c, pngtest.c, and applications in the contrib directory.
- Fixed an out-of-range read in png_user_version_check() (Bug report from
- Qixue Xiao, CVE-2015-8540).
- Simplified and future-proofed png_user_version_check().
- Fixed GCC unsigned int->float warnings. Various versions of GCC
- seem to generate warnings when an unsigned value is implicitly
- converted to double. This is probably a GCC bug but this change
- avoids the issue by explicitly converting to (int) where safe.
- Free all allocated memory in pngimage. The file buffer cache was left
- allocated at the end of the program, harmless but it causes memory
- leak reports from clang.
- Fixed array size calculations to avoid warnings. At various points
- in the code the number of elements in an array is calculated using
- sizeof. This generates a compile time constant of type (size_t) which
- is then typically assigned to an (unsigned int) or (int). Some versions
- of GCC on 64-bit systems warn about the apparent narrowing, even though
- the same compiler does apparently generate the correct, in-range,
- numeric constant. This adds appropriate, safe, casts to make the
- warnings go away.
-
-Version 1.6.15beta06 [November 6, 2014]
- Reverted use png_get_libpng_ver(NULL) instead of PNG_LIBPNG_VER_STRING
- in the manual, example.c, pngtest.c, and applications in the contrib
- directory. It was incorrect advice.
-
-Version 1.6.15beta07 [November 7, 2014]
- Removed #ifdef PNG_16BIT_SUPPORTED/#endif around png_product2(); it is
- needed by png_reciprocal2().
- Added #ifdef PNG_16BIT_SUPPORTED/#endif around png_log16bit() and
- png_do_swap().
- Changed all "#endif /* PNG_FEATURE_SUPPORTED */" to "#endif /* FEATURE */"
-
-Version 1.6.15beta08 [November 8, 2014]
- More housecleaning in *.h
-
-Version 1.6.15rc01 [November 13, 2014]
-
-Version 1.6.15rc02 [November 14, 2014]
- The macros passed in the command line to Borland make were ignored if
- similarly-named macros were already defined in makefiles. This behavior
- is different from POSIX make and other make programs. Surround the
- macro definitions with ifndef guards (Cosmin).
-
-Version 1.6.15rc03 [November 16, 2014]
- Added "-D_CRT_SECURE_NO_WARNINGS" to CFLAGS in scripts/makefile.vcwin32.
- Removed the obsolete $ARCH variable from scripts/makefile.darwin.
-
-Version 1.6.15 [November 20, 2014]
- No changes.
-
-Version 1.6.16beta01 [December 14, 2014]
- Added ".align 2" to arm/filter_neon.S to support old GAS assemblers that
- don't do alignment correctly.
- Revised Makefile.am and scripts/symbols.dfn to work with MinGW/MSYS
- (Bob Friesenhahn).
-
-Version 1.6.16beta02 [December 15, 2014]
- Revised Makefile.am and scripts/*.dfn again to work with MinGW/MSYS;
- renamed scripts/*.dfn to scripts/*.c (John Bowler).
-
-Version 1.6.16beta03 [December 21, 2014]
- Quiet a "comparison always true" warning in pngstest.c (John Bowler).
-
-Version 1.6.16rc01 [December 21, 2014]
- Restored a test on width that was removed from png.c at libpng-1.6.9
- (Bug report by Alex Eubanks, CVE-2015-0973).
-
-Version 1.6.16rc02 [December 21, 2014]
- Undid the update to pngrutil.c in 1.6.16rc01.
-
-Version 1.6.16rc03 [December 21, 2014]
- Fixed an overflow in png_combine_row() with very wide interlaced images
- (Bug report and fix by John Bowler, CVE-2014-9495).
-
-Version 1.6.16 [December 22, 2014]
- No changes.
-
-Version 1.6.17beta01 [January 29, 2015]
- Removed duplicate PNG_SAFE_LIMITS_SUPPORTED handling from pngconf.h
- Corrected the width limit calculation in png_check_IHDR().
- Removed user limits from pngfix. Also pass NULL pointers to
- png_read_row to skip the unnecessary row de-interlace stuff.
- Added testing of png_set_packing() to pngvalid.c
- Regenerated configure scripts in the *.tar distributions with libtool-2.4.4
- Implement previously untested cases of libpng transforms in pngvalid.c
- Fixed byte order in png_do_read_filler() with 16-bit input. Previously
- the high and low bytes of the filler, from png_set_filler() or from
- png_set_add_alpha(), were read in the wrong order.
- Made the check for out-of-range values in png_set_tRNS() detect
- values that are exactly 2^bit_depth, and work on 16-bit platforms.
- Merged some parts of libpng-1.6.17beta01 and libpng-1.7.0beta47.
- Added #ifndef __COVERITY__ where needed in png.c, pngrutil.c and
- pngset.c to avoid warnings about dead code.
- Added "& 0xff" to many instances of expressions that are typecast
- to (png_byte), to avoid Coverity warnings.
-
-Version 1.6.17beta02 [February 7, 2015]
- Work around one more Coverity-scan dead-code warning.
- Do not build png_product2() when it is unused.
-
-Version 1.6.17beta03 [February 17, 2015]
- Display user limits in the output from pngtest.
- Eliminated the PNG_SAFE_LIMITS macro and restored the 1-million-column
- and 1-million-row default limits in pnglibconf.dfa, that can be reset
- by the user at build time or run time. This provides a more robust
- defense against DOS and as-yet undiscovered overflows.
-
-Version 1.6.17beta04 [February 21, 2015]
- Added PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED macro, on by default.
- Allow user to call png_get_IHDR() with NULL arguments (Reuben Hawkins).
- Rebuilt configure scripts with automake-1.15 and libtool-2.4.6
-
-Version 1.6.17beta05 [February 25, 2015]
- Restored compiling of png_reciprocal2 with PNG_NO_16BIT.
-
-Version 1.6.17beta06 [February 27, 2015]
- Moved png_set_filter() prototype into a PNG_WRITE_SUPPORTED block
- of png.h.
- Avoid runtime checks when converting integer to png_byte with
- Visual Studio (Sergey Kosarevsky)
-
-Version 1.6.17rc01 [March 4, 2015]
- No changes.
-
-Version 1.6.17rc02 [March 9, 2015]
- Removed some comments that the configure script did not handle
- properly from scripts/pnglibconf.dfa and pnglibconf.h.prebuilt.
- Free the unknown_chunks structure even when it contains no data.
-
-Version 1.6.17rc03 [March 12, 2015]
- Updated CMakeLists.txt to add OSX framework, change YES/NO to ON/OFF
- for consistency, and remove some useless tests (Alexey Petruchik).
-
-Version 1.6.17rc04 [March 16, 2015]
- Remove pnglibconf.h, pnglibconf.c, and pnglibconf.out instead of
- pnglibconf.* in "make clean" (Cosmin).
- Fix bug in calculation of maxbits, in png_write_sBIT, introduced
- in libpng-1.6.17beta01 (John Bowler).
-
-Version 1.6.17rc05 [March 21, 2015]
- Define PNG_FILTER_* and PNG_FILTER_VALUE_* in png.h even when WRITE
- is not supported (John Bowler). This fixes an error introduced in
- libpng-1.6.17beta06.
- Reverted "& 0xff" additions of version 1.6.17beta01. Libpng passes
- the Coverity scan without them.
-
-Version 1.6.17rc06 [March 23, 2015]
- Remove pnglibconf.dfn and pnglibconf.pre with "make clean".
- Reformatted some "&0xff" instances to "& 0xff".
- Fixed simplified 8-bit-linear to sRGB alpha. The calculated alpha
- value was wrong. It's not clear if this affected the final stored
- value; in the obvious code path the upper and lower 8-bits of the
- alpha value were identical and the alpha was truncated to 8-bits
- rather than dividing by 257 (John Bowler).
-
-Version 1.6.17 [March 26, 2015]
- No changes.
-
-Version 1.6.18beta01 [April 1, 2015]
- Removed PNG_SET_CHUNK_[CACHE|MALLOC]_LIMIT_SUPPORTED macros. They
- have been combined with PNG_SET_USER_LIMITS_SUPPORTED (resolves
- bug report by Andrew Church).
- Fixed rgb_to_gray checks and added tRNS checks to pngvalid.c. This
- fixes some arithmetic errors that caused some tests to fail on
- some 32-bit platforms (Bug reports by Peter Breitenlohner [i686]
- and Petr Gajdos [i586]).
-
-Version 1.6.18beta02 [April 26, 2015]
- Suppressed some warnings from the Borland C++ 5.5.1/5.82 compiler
- (Bug report by Viktor Szakats).
-
-Version 1.6.18beta03 [May 6, 2015]
- Replaced "unexpected" with an integer (0xabadca11) in pngset.c
- where a long was expected, to avoid a compiler warning when PNG_DEBUG > 1.
- Added contrib/examples/simpleover.c, to demonstrate how to handle
- alpha compositing of multiple images, using the "simplified API"
- and an example PNG generation tool, contrib/examples/genpng.c
- (John Bowler).
-
-Version 1.6.18beta04 [May 20, 2015]
- PNG_RELEASE_BUILD replaces tests where the code depended on the build base
- type and can be defined on the command line, allowing testing in beta
- builds (John Bowler).
- Avoid Coverity issue 80858 (REVERSE NULL) in pngtest.c PNG_DEBUG builds.
- Avoid a harmless potential integer overflow in png_XYZ_from_xy() (Bug
- report from Christopher Ferris).
-
-Version 1.6.18beta05 [May 31, 2015]
- Backport filter selection code from libpng-1.7.0beta51, to combine
- sub_row, up_row, avg_row, and paeth_row into try_row and tst_row.
- Changed png_voidcast(), etc., to voidcast(), etc., in contrib/tools/pngfix.c
- to avoid confusion with the libpng private macros.
- Fixed old cut&paste bug in the weighted filter selection code in
- pngwutil.c, introduced in libpng-0.95, March 1997.
-
-Version 1.6.18beta06 [June 1, 2015]
- Removed WRITE_WEIGHTED_FILTERED code, to save a few kbytes of the
- compiled library size. It never worked properly and as far as we can
- tell, no one uses it. The png_set_filter_heuristics() and
- png_set_filter_heuristics_fixed() APIs are retained but deprecated
- and do nothing.
-
-Version 1.6.18beta07 [June 6, 2015]
- Removed non-working progressive reader 'skip' function. This
- function has apparently never been used. It was implemented
- to support back-door modification of png_struct in libpng-1.4.x
- but (because it does nothing and cannot do anything) was apparently
- never tested (John Bowler).
- Fixed cexcept.h in which GCC 5 now reports that one of the auto
- variables in the Try macro needs to be volatile to prevent value
- being lost over the setjmp (John Bowler).
- Fixed NO_WRITE_FILTER and -Wconversion build breaks (John Bowler).
- Fix g++ build breaks (John Bowler).
- Quieted some Coverity issues in pngfix.c, png-fix-itxt.c, pngvalid.c,
- pngstest.c, and pngimage.c. Most seem harmless, but png-fix-itxt
- would only work with iTXt chunks with length 255 or less.
- Added #ifdef's to contrib/examples programs so people don't try
- to compile them without the minimum required support enabled
- (suggested by Flavio Medeiros).
-
-Version 1.6.18beta08 [June 30, 2015]
- Eliminated the final two Coverity defects (insecure temporary file
- handling in contrib/libtests/pngstest.c; possible overflow of
- unsigned char in contrib/tools/png-fix-itxt.c). To use the "secure"
- file handling, define PNG_USE_MKSTEMP, otherwise "tmpfile()" will
- be used.
- Removed some unused WEIGHTED_FILTER macros from png.h and pngstruct.h
-
-Version 1.6.18beta09 [July 5, 2015]
- Removed some useless typecasts from contrib/tools/png-fix-itxt.c
- Fixed a new signed-unsigned comparison in pngrtran.c (Max Stepin).
- Replaced arbitrary use of 'extern' with #define PNG_LINKAGE_*. To
- preserve API compatibility, the new defines all default to "extern"
- (requested by Jan Nijtmans).
-
-Version 1.6.18rc01 [July 9, 2015]
- Belatedly added Mans Rullgard and James Yu to the list of Contributing
- Authors.
-
-Version 1.6.18rc02 [July 12, 2015]
- Restored unused FILTER_HEURISTIC macros removed at libpng-1.6.18beta08
- to png.h to avoid compatibility warnings.
-
-Version 1.6.18rc03 [July 15, 2015]
- Minor changes to the man page
-
-Version 1.6.18 [July 23, 2015]
- No changes.
-
-Version 1.6.19beta01 [July 30, 2015]
- Updated obsolete information about the simplified API macros in the
- manual pages (Bug report by Arc Riley).
- Avoid potentially dereferencing NULL info_ptr in png_info_init_3().
- Rearranged png.h to put the major sections in the same order as
- in libpng17.
- Eliminated unused PNG_COST_SHIFT, PNG_WEIGHT_SHIFT, PNG_COST_FACTOR, and
- PNG_WEIGHT_FACTOR macros.
- Suppressed some warnings from the Borland C++ 5.5.1/5.82 compiler
- (Bug report by Viktor Szakats). Several warnings remain and are
- unavoidable, where we test for overflow.
- Fixed potential leak of png_pixels in contrib/pngminus/pnm2png.c
- Fixed uninitialized variable in contrib/gregbook/rpng2-x.c
-
-Version 1.6.19beta02 [August 19, 2015]
- Moved config.h.in~ from the "libpng_autotools_files" list to the
- "libpng_autotools_extra" list in autogen.sh because it was causing a
- false positive for missing files (bug report by Robert C. Seacord).
- Removed unreachable "break" statements in png.c, pngread.c, and pngrtran.c
- to suppress clang warnings (Bug report by Viktor Szakats).
- Fixed some bad links in the man page.
- Changed "n bit" to "n-bit" in comments.
- Added signed/unsigned 16-bit safety net. This removes the dubious
- 0x8000 flag definitions on 16-bit systems. They aren't supported
- yet the defs *probably* work, however it seems much safer to do this
- and be advised if anyone, contrary to advice, is building libpng 1.6
- on a 16-bit system. It also adds back various switch default clauses
- for GCC; GCC errors out if they are not present (with an appropriately
- high level of warnings).
- Safely convert num_bytes to a png_byte in png_set_sig_bytes() (Robert
- Seacord).
- Fixed the recently reported 1's complement security issue by replacing
- the value that is illegal in the PNG spec, in both signed and unsigned
- values, with 0. Illegal unsigned values (anything greater than or equal
- to 0x80000000) can still pass through, but since these are not illegal
- in ANSI-C (unlike 0x80000000 in the signed case) the checking that
- occurs later can catch them (John Bowler).
-
-Version 1.6.19beta03 [September 26, 2015]
- Fixed png_save_int_32 when int is not 2's complement (John Bowler).
- Updated libpng16 with all the recent test changes from libpng17,
- including changes to pngvalid.c to ensure that the original,
- distributed, version of contrib/visupng/cexcept.h can be used
- (John Bowler).
- pngvalid contains the correction to the use of SAVE/STORE_
- UNKNOWN_CHUNKS; a bug revealed by changes in libpng 1.7. More
- tests contain the --strict option to detect warnings and the
- pngvalid-standard test has been corrected so that it does not
- turn on progressive-read. There is a separate test which does
- that. (John Bowler)
- Also made some signed/unsigned fixes.
- Make pngstest error limits version specific. Splitting the machine
- generated error structs out to a file allows the values to be updated
- without changing pngstest.c itself. Since libpng 1.6 and 1.7 have
- slightly different error limits this simplifies maintenance. The
- makepngs.sh script has also been updated to more accurately reflect
- current problems in libpng 1.7 (John Bowler).
- Incorporated new test PNG files into make check. tests/pngstest-*
- are changed so that the new test files are divided into 8 groups by
- gamma and alpha channel. These tests have considerably better code
- and pixel-value coverage than contrib/pngsuite; however,coverage is
- still incomplete (John Bowler).
- Removed the '--strict' in 1.6 because of the double-gamma-correction
- warning, updated pngstest-errors.h for the errors detected with the
- new contrib/testspngs PNG test files (John Bowler).
-
-Version 1.6.19beta04 [October 15, 2015]
- Worked around rgb-to-gray issues in libpng 1.6. The previous
- attempts to ignore the errors in the code aren't quite enough to
- deal with the 'channel selection' encoding added to libpng 1.7; abort.
- pngvalid.c is changed to drop this encoding in prior versions.
- Fixed 'pow' macros in pngvalid.c. It is legal for 'pow' to be a
- macro, therefore the argument list cannot contain preprocessing
- directives. Make sure pow is a function where this happens. This is
- a minimal safe fix, the issue only arises in non-performance-critical
- code (bug report by Curtis Leach, fix by John Bowler).
- Added sPLT support to pngtest.c
-
-Version 1.6.19rc01 [October 23, 2015]
- No changes.
-
-Version 1.6.19rc02 [October 31, 2015]
- Prevent setting or writing over-length PLTE chunk (Cosmin Truta).
- Silently truncate over-length PLTE chunk while reading.
- Libpng incorrectly calculated the output rowbytes when the application
- decreased either the number of channels or the bit depth (or both) in
- a user transform. This was safe; libpng overallocated buffer space
- (potentially by quite a lot; up to 4 times the amount required) but,
- from 1.5.4 on, resulted in a png_error (John Bowler).
-
-Version 1.6.19rc03 [November 3, 2015]
- Fixed some inconsequential cut-and-paste typos in png_set_cHRM_XYZ_fixed().
- Clarified COPYRIGHT information to state explicitly that versions
- are derived from previous versions.
- Removed much of the long list of previous versions from png.h and
- libpng.3.
-
-Version 1.6.19rc04 [November 5, 2015]
- Fixed new bug with CRC error after reading an over-length palette
- (bug report by Cosmin Truta) (CVE-2015-8126).
-
-Version 1.6.19 [November 12, 2015]
- Cleaned up coding style in png_handle_PLTE().
-
-Version 1.6.20beta01 [November 20, 2015]
- Avoid potential pointer overflow/underflow in png_handle_sPLT() and
- png_handle_pCAL() (Bug report by John Regehr).
-
-Version 1.6.20beta02 [November 23, 2015]
- Fixed incorrect implementation of png_set_PLTE() that uses png_ptr
- not info_ptr, that left png_set_PLTE() open to the CVE-2015-8126
- vulnerability. Fixes CVE-2015-8472.
-
-Version 1.6.20beta03 [November 24, 2015]
- Backported tests from libpng-1.7.0beta69.
-
-Version 1.6.20rc01 [November 26, 2015]
- Fixed an error in handling of bad zlib CMINFO field in pngfix, found by
- American Fuzzy Lop, reported by Brian Carpenter. inflate() doesn't
- immediately fault a bad CMINFO field; instead a 'too far back' error
- happens later (at least some times). pngfix failed to limit CMINFO to
- the allowed values but then assumed that window_bits was in range,
- triggering an assert. The bug is mostly harmless; the PNG file cannot
- be fixed.
-
-Version 1.6.20rc02 [November 29, 2015]
- In libpng 1.6 zlib initialization was changed to use the window size
- in the zlib stream, not a fixed value. This causes some invalid images,
- where CINFO is too large, to display 'correctly' if the rest of the
- data is valid. This provides a workaround for zlib versions where the
- error arises (ones that support the API change to use the window size
- in the stream).
-
-Version 1.6.20 [December 3, 2015]
- No changes.
-
-Version 1.6.21beta01 [December 11, 2015]
- Fixed syntax "$(command)" in tests/pngstest that some shells other than
- bash could not parse (Bug report by Nelson Beebe). Use `command` instead.
-
-Version 1.6.21beta02 [December 14, 2015]
- Moved png_check_keyword() from pngwutil.c to pngset.c
- Removed LE/BE dependencies in pngvalid, to 'fix' the current problem
- in the BigEndian tests by not testing it, making the BE code the same
- as the LE version.
- Fixes to pngvalid for various reduced build configurations (eliminate unused
- statics) and a fix for the case in rgb_to_gray when the digitize option
- reduces graylo to 0, producing a large error.
-
-Version 1.6.21beta03 [December 18, 2015]
- Widened the 'limit' check on the internally calculated error limits in
- the 'DIGITIZE' case (the code used prior to 1.7 for rgb_to_gray error
- checks) and changed the check to only operate in non-release builds
- (base build type not RC or RELEASE.)
- Fixed undefined behavior in pngvalid.c, undefined because
- (png_byte) << shift is undefined if it changes the signed bit
- (because png_byte is promoted to int). The libpng exported functions
- png_get_uint_32 and png_get_uint_16 handle this. (Bug reported by
- David Drysdale as a result of reports from UBSAN in clang 3.8).
- This changes pngvalid to use BE random numbers; this used to produce
- errors but these should not be fixed as a result of the previous changes.
-
-Version 1.6.21rc01 [January 4, 2016]
- In projects/vstudio, combined readme.txt and WARNING into README.txt
-
-Version 1.6.21rc02 [January 7, 2016]
- Relocated assert() in contrib/tools/pngfix.c, bug found by American
- Fuzzy Lop, reported by Brian Carpenter.
- Marked 'limit' UNUSED in transform_range_check(). This only affects
- release builds.
-
-Version 1.6.21 [January 15, 2016]
- Worked around a false-positive Coverity issue in pngvalid.c.
-
-Version 1.6.22beta01 [January 23, 2016]
- Changed PNG_USE_MKSTEMP to __COVERITY__ to select alternate
- "tmpfile()" implementation in contrib/libtests/pngstest.c
- Fixed NO_STDIO build of pngunknown.c to skip calling png_init_io()
- if there is no stdio.h support.
- Added a png_image_write_to_memory() API and a number of assist macros
- to allow an application that uses the simplified API write to bypass
- stdio and write directly to memory.
- Added some warnings (png.h) and some check code to detect *possible*
- overflow in the ROW_STRIDE and simplified image SIZE macros. This
- disallows image width/height/format that *might* overflow. This is
- a quiet API change that limits in-memory image size (uncompressed) to
- less than 4GByte and image row size (stride) to less than 2GByte.
- Revised workaround for false-positive Coverity issue in pngvalid.c.
-
-Version 1.6.22beta02 [February 8, 2016]
- Only use exit(77) in configure builds.
- Corrected error in PNG_IMAGE_PNG_SIZE_MAX. This new macro underreported
- the palette size because it failed to take into account that the memory
- palette has to be expanded to full RGB when it is written to PNG.
- Updated CMakeLists.txt, added supporting scripts/gen*.cmake.in
- and test.cmake.in (Roger Leigh).
- Relaxed limit checks on gamma values in pngrtran.c. As suggested in
- the comments gamma values outside the range currently permitted
- by png_set_alpha_mode are useful for HDR data encoding. These values
- are already permitted by png_set_gamma so it is reasonable caution to
- extend the png_set_alpha_mode range as HDR imaging systems are starting
- to emerge.
-
-Version 1.6.22beta03 [March 9, 2016]
- Added a common-law trademark notice and export control information
- to the LICENSE file, png.h, and the man page.
- Restored "& 0xff" in png_save_uint_16() and png_save_uint_32() that
- were accidentally removed from libpng-1.6.17.
- Changed PNG_INFO_cHNK and PNG_FREE_cHNK from 0xnnnn to 0xnnnnU in png.h
- (Robert C. Seacord).
- Removed dubious "#if INT_MAX" test from png.h that was added to
- libpng-1.6.19beta02 (John Bowler).
- Add ${INCLUDES} in scripts/genout.cmake.in (Bug report by Nixon Kwok).
- Updated LICENSE to say files in the contrib directory are not
- necessarily under the libpng license, and that some makefiles have
- other copyright owners.
- Added INTEL-SSE2 support (Mike Klein and Matt Sarett, Google, Inc.).
- Made contrib/libtests/timepng more robust. The code no longer gives
- up/fails on invalid PNG data, it just skips it (with error messages).
- The code no longer fails on PNG files with data beyond IEND. Options
- exist to use png_read_png (reading the whole image, not by row) and, in
- that case, to apply any of the supported transforms. This makes for
- more realistic testing; the decoded data actually gets used in a
- meaningful fashion (John Bowler).
- Fixed some misleading indentation (Krishnaraj Bhat).
-
-Version 1.6.22beta04 [April 5, 2016]
- Force GCC compilation to C89 if needed (Dagobert Michelsen).
- SSE filter speed improvements for bpp=3:
- memcpy-free implementations of load3() / store3().
- call load3() only when needed at the end of a scanline.
-
-Version 1.6.22beta05 [April 27, 2016]
- Added PNG_FAST_FILTERS macro (defined as
- PNG_FILTER_NONE|PNG_FILTER_SUB|PNG_FILTER_UP).
- Various fixes for contrib/libtests/timepng.c
- Moved INTEL-SSE code from pngpriv.h into contrib/intel/intel_sse.patch.
- Fixed typo (missing underscore) in #define PNG_READ_16_TO_8_SUPPORTED
- (Bug report by Y.Ohashik).
-
-Version 1.6.22beta06 [May 5, 2016]
- Rebased contrib/intel_sse.patch.
- Quieted two Coverity issues in contrib/libtests/timepng.c.
- Fixed issues with scripts/genout.cmake.in (David Capello, Nixon Kwok):
- Added support to use multiple directories in ZLIBINCDIR variable,
- Fixed CMAKE_C_FLAGS with multiple values when genout is compiled on MSVC,
- Fixed pnglibconf.c compilation on OS X including the sysroot path.
-
-Version 1.6.22rc01 [May 14, 2016]
- No changes.
-
-Version 1.6.22rc02 [May 16, 2016]
- Removed contrib/timepng from default build; it does not build on platforms
- that don't supply clock_gettime().
-
-Version 1.6.22rc03 [May 17, 2016]
- Restored contrib/timepng to default build but check for the presence
- of clock_gettime() in configure.ac and Makefile.am.
-
-Version 1.6.22 [May 26, 2016]
- No changes.
-
-Version 1.6.23beta01 [May 29, 2016]
- Stop a potential memory leak in png_set_tRNS() (Bug report by Ted Ying).
- Fixed the progressive reader to handle empty first IDAT chunk properly
- (patch by Timothy Nikkel). This bug was introduced in libpng-1.6.0 and
- only affected the libpng16 branch.
- Added tests in pngvalid.c to check zero-length IDAT chunks in various
- positions. Fixed the sequential reader to handle these more robustly
- (John Bowler).
-
-Version 1.6.23rc01 [June 2, 2016]
- Corrected progressive read input buffer in pngvalid.c. The previous version
- the code invariably passed just one byte at a time to libpng. The intent
- was to pass a random number of bytes in the range 0..511.
- Moved sse2 prototype from pngpriv.h to contrib/intel/intel_sse.patch.
- Added missing ")" in pngerror.c (Matt Sarrett).
-
-Version 1.6.23rc02 [June 4, 2016]
- Fixed undefined behavior in png_push_save_buffer(). Do not call
- memcpy() with a null source, even if count is zero (Leon Scroggins III).
-
-Version 1.6.23 [June 9, 2016]
- Fixed bad link to RFC2083 in png.5 (Nikola Forro).
-
-Version 1.6.24beta01 [June 11, 2016]
- Avoid potential overflow of the PNG_IMAGE_SIZE macro. This macro
- is not used within libpng, but is used in some of the examples.
-
-Version 1.6.24beta02 [June 23, 2016]
- Correct filter heuristic overflow handling. This was broken when the
- write filter code was moved out-of-line; if there is a single filter and
- the heuristic sum overflows the calculation of the filtered line is not
- completed. In versions prior to 1.6 the code was duplicated in-line
- and the check not performed, so the filter operation completed; however,
- in the multi-filter case where the sum is performed the 'none' filter would
- be selected if all the sums overflowed, even if it wasn't in the filter
- list. The fix to the first problem is simply to provide PNG_SIZE_MAX as
- the current lmins sum value; this means the sum can never exceed it and
- overflows silently. A reasonable compiler that does choose to inline
- the code will simply eliminate the sum check.
- The fix to the second problem is to use high precision arithmetic (this is
- implemented in 1.7), however a simple safe fix here is to chose the lowest
- numbered filter in the list from png_set_filter (this only works if the
- first problem is also fixed) (John Bowler).
- Use a more efficient absolute value calculation on SSE2 (Matthieu Darbois).
- Fixed the case where PNG_IMAGE_BUFFER_SIZE can overflow in the application
- as a result of the application using an increased 'row_stride'; previously
- png_image_finish_read only checked for overflow on the base calculation of
- components. (I.e. it checked for overflow of a 32-bit number on the total
- number of pixel components in the output format, not the possibly padded row
- length and not the number of bytes, which for linear formats is twice the
- number of components.)
- MSVC does not like '-(unsigned)', so replaced it with 0U-(unsigned)
- MSVC does not like (uInt) = -(unsigned) (i.e. as an initializer), unless
- the conversion is explicitly invoked by a cast.
- Put the SKIP definition in the correct place. It needs to come after the
- png.h include (see all the other .c files in contrib/libtests) because it
- depends on PNG_LIBPNG_VER.
- Removed the three compile warning options from the individual project
- files into the zlib.props globals. It increases the warning level from 4
- to All and adds a list of the warnings that need to be turned off. This is
- semi-documentary; the intent is to tell libpng users which warnings have
- been examined and judged non-fixable at present. The warning about
- structure padding is fixable, but it would be a significant change (moving
- structure members around).
-
-Version 1.6.24beta03 [July 4, 2016]
- Optimized absolute value calculation in filter selection, similar to
- code in the PAETH decoder in pngrutil.c. Build with PNG_USE_ABS to
- use this.
- Added pngcp to the build together with a pngcp.dfa configuration test.
- Added high resolution timing to pngcp.
- Added "Common linking failures" section to INSTALL.
- Relocated misplaced #endif in png.c sRGB profile checking.
- Fixed two Coverity issues in pngcp.c.
-
-Version 1.6.24beta04 [July 8, 2016]
- Avoid filter-selection heuristic sum calculations in cases where only one
- filter is a candidate for selection. This trades off code size (added
- private png_setup_*_row_only() functions) for speed.
-
-Version 1.6.24beta05 [July 13, 2016]
- Fixed some indentation to comply with our coding style.
- Added contrib/tools/reindent.
-
-Version 1.6.24beta06 [July 18, 2016]
- Fixed more indentation to comply with our coding style.
- Eliminated unnecessary tests of boolean png_isaligned() vs 0.
-
-Version 1.6.24rc01 [July 25, 2016]
- No changes.
-
-Version 1.6.24rc02 [August 1, 2016]
- Conditionally compile SSE2 headers in contrib/intel/intel_sse.patch
- Conditionally compile png_decompress_chunk().
-
-Version 1.6.24rc03 [August 2, 2016]
- Conditionally compile ARM_NEON headers in pngpriv.h
- Updated contrib/intel/intel_sse.patch
-
-Version 1.6.24[August 4, 2016]
- No changes.
-
-Version 1.6.25beta01 [August 12, 2016]
- Reject oversized iCCP profile immediately.
- Cleaned up PNG_DEBUG compile of pngtest.c.
- Conditionally compile png_inflate().
-
-Version 1.6.25beta02 [August 18, 2016]
- Don't install pngcp; it conflicts with pngcp in the pngtools package.
- Minor editing of INSTALL, (whitespace, added copyright line)
-
-Version 1.6.25rc01 [August 24, 2016]
- No changes.
-
-Version 1.6.25rc02 [August 29, 2016]
- Added MIPS support (Mandar Sahastrabuddhe <Mandar.Sahastrabuddhe@imgtec.com>).
- Only the UP filter is currently implemented.
-
-Version 1.6.25rc03 [August 29, 2016]
- Rebased contrib/intel/intel_sse.patch after the MIPS implementation.
-
-Version 1.6.25rc04 [August 30, 2016]
- Added MIPS support for SUB, AVG, and PAETH filters (Mandar Sahastrabuddhe).
-
-Version 1.6.25rc05 [August 30, 2016]
- Rebased contrib/intel/intel_sse.patch after the MIPS implementation update..
-
-Version 1.6.25 [September 1, 2016]
- No changes.
-
-Version 1.6.26beta01 [September 26, 2016]
- Fixed handling zero length IDAT in pngfix (bug report by Agostino Sarubbo,
- bugfix by John Bowler).
- Do not issue a png_error() on read in png_set_pCAL() because png_handle_pCAL
- has allocated memory that libpng needs to free.
- Conditionally compile png_set_benign_errors() in pngread.c and pngtest.c
- Issue a png_benign_error instead of a png_error on ADLER32 mismatch
- while decoding compressed data chunks.
- Changed PNG_ZLIB_VERNUM to ZLIB_VERNUM in pngpriv.h, pngstruct.h, and
- pngrutil.c.
- If CRC handling of critical chunks has been set to PNG_CRC_QUIET_USE,
- ignore the ADLER32 checksum in the IDAT chunk as well as the chunk CRCs.
- Issue png_benign_error() on ADLER32 checksum mismatch instead of png_error().
- Add tests/badcrc.png and tests/badadler.png to tests/pngtest.
- Merged pngtest.c with libpng-1.7.0beta84/pngtest.c
-
-Version 1.6.26beta02 [October 1, 2016]
- Updated the documentation about CRC and ADLER32 handling.
- Quieted 117 warnings from clang-3.8 in pngtrans.c, pngread.c,
- pngwrite.c, pngunknown.c, and pngvalid.c.
- Quieted 58 (out of 144) -Wconversion compiler warnings by changing
- flag definitions in pngpriv.h from 0xnnnn to 0xnnnnU and trivial changes
- in png.c, pngread.c, and pngwutil.c.
-
-Version 1.6.26beta03 [October 2, 2016]
- Removed contrib/libtests/*.orig and *.rej that slipped into the tarballs.
- Quieted the 86 remaining -Wconversion compiler warnings by
- revising the png_isaligned() macro and trivial changes in png.c,
- pngerror.c, pngget.c, pngmem.c, pngset.c, pngrtran.c, pngrutil.c,
- pngwtran.c, pngwrite.c, and pngwutil.c.
-
-Version 1.6.26beta04 [October 3, 2016]
- Quieted (bogus?) clang warnings about "absolute value has no effect"
- when PNG_USE_ABS is defined.
- Fixed offsets in contrib/intel/intel_sse.patch
-
-Version 1.6.26beta05 [October 6, 2016]
- Changed integer constant 4294967294 to unsigned 4294967294U in pngconf.h
- to avoid a signed/unsigned compare in the preprocessor.
-
-Version 1.6.26beta06 [October 7, 2016]
- Use zlib-1.2.8.1 inflateValidate() instead of inflateReset2() to
- optionally avoid ADLER32 evaluation.
-
-Version 1.6.26rc01 [October 12, 2016]
- No changes.
-
-Version 1.6.26 [October 20, 2016]
- Cosmetic change, "ptr != 0" to "ptr != NULL" in png.c and pngrutil.c
- Despammed email addresses (replaced "@" with " at ").
-
-Version 1.6.27beta01 [November 2, 2016]
- Restrict the new ADLER32-skipping to IDAT chunks. It broke iCCP chunk
- handling: an erroneous iCCP chunk would throw a png_error and reject the
- entire PNG image instead of rejecting just the iCCP chunk with a warning,
- if built with zlib-1.2.8.1.
-
-Version 1.6.27rc01 [December 27, 2016]
- Control ADLER32 checking with new PNG_IGNORE_ADLER32 option. Fixes
- an endless loop when handling erroneous ADLER32 checksums; bug
- introduced in libpng-1.6.26.
- Removed the use of a macro containing the pre-processor 'defined'
- operator. It is unclear whether this is valid; a macro that
- "generates" 'defined' is not permitted, but the use of the word
- "generates" within the C90 standard seems to imply more than simple
- substitution of an expression itself containing a well-formed defined
- operation.
- Added ARM support to CMakeLists.txt (Andreas Franek).
-
-Version 1.6.27 [December 29, 2016]
- Fixed a potential null pointer dereference in png_set_text_2() (bug report
- and patch by Patrick Keshishian, CVE-2016-10087).
-
-Version 1.6.28rc01 [January 3, 2017]
- Fixed arm/aarch64 detection in CMakeLists.txt (Gianfranco Costamagna).
- Added option to Cmake build allowing a custom location of zlib to be
- specified in a scenario where libpng is being built as a subproject
- alongside zlib by another project (Sam Serrels).
- Changed png_ptr->options from a png_byte to png_uint_32, to accommodate
- up to 16 options.
-
-Version 1.6.28rc02 [January 4, 2017]
- Added "include(GNUInstallDirs)" to CMakeLists.txt (Gianfranco Costamagna).
- Moved SSE2 optimization code into the main libpng source directory.
- Configure libpng with "configure --enable-intel-sse" or compile
- libpng with "-DPNG_INTEL_SSE" in CPPFLAGS to enable it.
-
-Version 1.6.28rc03 [January 4, 2017]
- Backed out the SSE optimization and last CMakeLists.txt to allow time for QA.
-
-Version 1.6.28 [January 5, 2017]
- No changes.
-
-Version 1.6.29beta01 [January 12, 2017]
- Readded "include(GNUInstallDirs)" to CMakeLists.txt (Gianfranco Costamagna).
- Moved SSE2 optimization code into the main libpng source directory.
- Configure libpng with "configure --enable-intel-sse" or compile
- libpng with "-DPNG_INTEL_SSE" in CPPFLAGS to enable it.
- Simplified conditional compilation in pngvalid.c, for AIX (Michael Felt).
-
-Version 1.6.29beta02 [February 22, 2017]
- Avoid conditional directives that break statements in pngrutil.c (Romero
- Malaquias)
- The contrib/examples/pngtopng.c recovery code was in the wrong "if"
- branches; the comments were correct.
- Added code for PowerPC VSX optimisation (Vadim Barkov).
-
-Version 1.6.29beta03 [March 1, 2017]
- Avoid potential overflow of shift operations in png_do_expand() (Aaron Boxer).
- Change test ZLIB_VERNUM >= 0x1281 to ZLIB_VERNUM >= 0x1290 in pngrutil.c
- because Solaris 11 distributes zlib-1.2.8.f that is older than 1.2.8.1,
- as suggested in zlib FAQ, item 24.
- Suppress clang warnings about implicit sign changes in png.c
-
-Version 1.6.29 [March 16, 2017]
- No changes.
-
-Version 1.6.30beta01 [April 1, 2017]
- Added missing "$(CPPFLAGS)" to the compile line for c.pic.o in
- makefile.linux and makefile.solaris-x86 (Cosmin).
- Revised documentation of png_get_error_ptr() in the libpng manual.
- Silence clang -Wcomma and const drop warnings (Viktor Szakats).
- Update Sourceforge URLs in documentation (https instead of http).
-
-Version 1.6.30beta02 [April 22, 2017]
- Document need to check for integer overflow when allocating a pixel
- buffer for multiple rows in contrib/gregbook, contrib/pngminus,
- example.c, and in the manual (suggested by Jaeseung Choi). This
- is similar to the bug reported against pngquant in CVE-2016-5735.
- Removed reference to the obsolete PNG_SAFE_LIMITS macro in the documentation.
-
-Version 1.6.30beta03 [May 22, 2017]
- Check for integer overflow in contrib/visupng and contrib/tools/genpng.
- Do not double evaluate CMAKE_SYSTEM_PROCESSOR in CMakeLists.txt.
- Test CMAKE_HOST_WIN32 instead of WIN32 in CMakeLists.txt.
- Fix some URL in documentation.
-
-Version 1.6.30beta04 [June 7, 2017]
- Avoid writing an empty IDAT when the last IDAT exactly fills the
- compression buffer (bug report by Brian Baird). This bug was
- introduced in libpng-1.6.0.
-
-Version 1.6.30rc01 [June 14, 2017]
- No changes.
-
-Version 1.6.30rc02 [June 25, 2017]
- Update copyright year in pnglibconf.h, make ltmain.sh executable.
- Add a reference to the libpng.download site in README.
-
-Version 1.6.30 [June 28, 2017]
- No changes.
-
-Version 1.6.31beta01 [July 5, 2017]
- Guard the definition of _POSIX_SOURCE in pngpriv.h (AIX already defines it;
- bug report by Michael Felt).
- Revised pngpriv.h to work around failure to compile arm/filter_neon.S
- ("typedef" directive is unrecognized by the assembler). The problem
- was introduced in libpng-1.6.30beta01.
- Added "Requires: zlib" to libpng.pc.in (Pieter Neerincx).
- Added special case for FreeBSD in arm/filter_neon.S (Maya Rashish).
-
-Version 1.6.31beta02 [July 8, 2017]
- Added instructions for disabling hardware optimizations in INSTALL.
- Added "--enable-hardware-optimizations" configuration flag to enable
- or disable all hardware optimizations with one flag.
-
-Version 1.6.31beta03 [July 9, 2017]
- Updated CMakeLists.txt to add INTEL_SSE and MIPS_MSA platforms.
- Changed "int" to "png_size_t" in intel/filter_sse2.c to prevent
- possible integer overflow (Bug report by John Bowler).
- Quieted "declaration after statement" warnings in intel/filter_sse2.c.
- Added scripts/makefile-linux-opt, which has hardware optimizations enabled.
-
-Version 1.6.31beta04 [July 11, 2017]
- Removed one of the GCC-7.1.0 'strict-overflow' warnings that result when
- integers appear on both sides of a compare. Worked around the others by
- forcing the strict-overflow setting in the relevant functions to a level
- where they are not reported (John Bowler).
- Changed "FALL THROUGH" comments to "FALLTHROUGH" because GCC doesn't like
- the space.
- Worked around some C-style casts from (void*) because g++ 5.4.0 objects
- to them.
- Increased the buffer size for 'sprint' to pass the gcc 7.1.0 'sprint
- overflow' check that is on by default with -Wall -Wextra.
-
-Version 1.6.31beta05 [July 13, 2017]
- Added eXIf chunk support.
-
-Version 1.6.31beta06 [July 17, 2017]
- Added a minimal eXIf chunk (with Orientation and FocalLengthIn35mmFilm
- tags) to pngtest.png.
-
-Version 1.6.31beta07 [July 18, 2017]
- Revised the eXIf chunk in pngtest.png to fix "Bad IFD1 Directory" warning.
-
-Version 1.6.31rc01 [July 19, 2017]
- No changes.
-
-Version 1.6.31rc02 [July 25, 2017]
- Fixed typo in example.c (png_free_image should be png_image_free) (Bug
- report by John Smith)
-
-Version 1.6.31 [July 27, 2017]
- No changes.
-
-Version 1.6.32beta01 [July 31, 2017]
- Avoid possible NULL dereference in png_handle_eXIf when benign_errors
- are allowed. Avoid leaking the input buffer "eXIf_buf".
- Eliminated png_ptr->num_exif member from pngstruct.h and added num_exif
- to arguments for png_get_eXIf() and png_set_eXIf().
- Added calls to png_handle_eXIf(() in pngread.c and png_write_eXIf() in
- pngwrite.c, and made various other fixes to png_write_eXIf().
- Changed name of png_get_eXIF and png_set_eXIf() to png_get_eXIf_1() and
- png_set_eXIf_1(), respectively, to avoid breaking API compatibility
- with libpng-1.6.31.
-
-Version 1.6.32beta02 [August 1, 2017]
- Updated contrib/libtests/pngunknown.c with eXIf chunk.
-
-Version 1.6.32beta03 [August 2, 2017]
- Initialized btoa[] in pngstest.c
- Stop memory leak when returning from png_handle_eXIf() with an error
- (Bug report from the OSS-fuzz project).
-
-Version 1.6.32beta04 [August 2, 2017]
- Replaced local eXIf_buf with info_ptr->eXIf_buf in png_handle_eXIf().
- Update libpng.3 and libpng-manual.txt about eXIf functions.
-
-Version 1.6.32beta05 [August 2, 2017]
- Restored png_get_eXIf() and png_set_eXIf() to maintain API compatibility.
-
-Version 1.6.32beta06 [August 2, 2017]
- Removed png_get_eXIf_1() and png_set_eXIf_1().
-
-Version 1.6.32beta07 [August 3, 2017]
- Check length of all chunks except IDAT against user limit to fix an
- OSS-fuzz issue (Fixes CVE-2017-12652).
-
-Version 1.6.32beta08 [August 3, 2017]
- Check length of IDAT against maximum possible IDAT size, accounting
- for height, rowbytes, interlacing and zlib/deflate overhead.
- Restored png_get_eXIf_1() and png_set_eXIf_1(), because strlen(eXIf_buf)
- does not work (the eXIf chunk data can contain zeroes).
-
-Version 1.6.32beta09 [August 3, 2017]
- Require cmake-2.8.8 in CMakeLists.txt. Revised symlink creation,
- no longer using deprecated cmake LOCATION feature (Clifford Yapp).
- Fixed five-byte error in the calculation of IDAT maximum possible size.
-
-Version 1.6.32beta10 [August 5, 2017]
- Moved chunk-length check into a png_check_chunk_length() private
- function (Suggested by Max Stepin).
- Moved bad pngs from tests to contrib/libtests/crashers
- Moved testing of bad pngs into a separate tests/pngtest-badpngs script
- Added the --xfail (expected FAIL) option to pngtest.c. It writes XFAIL
- in the output but PASS for the libpng test.
- Require cmake-3.0.2 in CMakeLists.txt (Clifford Yapp).
- Fix "const" declaration info_ptr argument to png_get_eXIf_1() and the
- num_exif argument to png_get_eXIf_1() (Github Issue 171).
-
-Version 1.6.32beta11 [August 7, 2017]
- Added "eXIf" to "chunks_to_ignore[]" in png_set_keep_unknown_chunks().
- Added huge_IDAT.png and empty_ancillary_chunks.png to testpngs/crashers.
- Make pngtest --strict, --relax, --xfail options imply -m (multiple).
- Removed unused chunk_name parameter from png_check_chunk_length().
- Relocated setting free_me for eXIf data, to stop an OSS-fuzz leak.
- Initialize profile_header[] in png_handle_iCCP() to fix OSS-fuzz issue.
- Initialize png_ptr->row_buf[0] to 255 in png_read_row() to fix OSS-fuzz UMR.
- Attempt to fix a UMR in png_set_text_2() to fix OSS-fuzz issue.
- Increase minimum zlib stream from 9 to 14 in png_handle_iCCP(), to account
- for the minimum 'deflate' stream, and relocate the test to a point
- after the keyword has been read.
- Check that the eXIf chunk has at least 2 bytes and begins with "II" or "MM".
-
-Version 1.6.32rc01 [August 18, 2017]
- Added a set of "huge_xxxx_chunk.png" files to contrib/testpngs/crashers,
- one for each known chunk type, with length = 2GB-1.
- Check for 0 return from png_get_rowbytes() and added some (size_t) typecasts
- in contrib/pngminus/*.c to stop some Coverity issues (162705, 162706,
- and 162707).
- Renamed chunks in contrib/testpngs/crashers to avoid having files whose
- names differ only in case; this causes problems with some platforms
- (github issue #172).
-
-Version 1.6.32rc02 [August 22, 2017]
- Added contrib/oss-fuzz directory which contains files used by the oss-fuzz
- project (https://github.com/google/oss-fuzz/tree/master/projects/libpng).
-
-Version 1.6.32 [August 24, 2017]
- No changes.
-
-Version 1.6.33beta01 [August 28, 2017]
- Added PNGMINUS_UNUSED macro to contrib/pngminus/p*.c and added missing
- parenthesis in contrib/pngminus/pnm2png.c (bug report by Christian Hesse).
- Fixed off-by-one error in png_do_check_palette_indexes() (Bug report
- by Mick P., Source Forge Issue #269).
-
-Version 1.6.33beta02 [September 3, 2017]
- Initialize png_handler.row_ptr in contrib/oss-fuzz/libpng_read_fuzzer.cc
- to fix shortlived oss-fuzz issue 3234.
- Compute a larger limit on IDAT because some applications write a deflate
- buffer for each row (Bug report by Andrew Church).
- Use current date (DATE) instead of release-date (RDATE) in last
- changed date of contrib/oss-fuzz files.
- Enabled ARM support in CMakeLists.txt (Bernd Kuhls).
-
-Version 1.6.33beta03 [September 14, 2017]
- Fixed incorrect typecast of some arguments to png_malloc() and
- png_calloc() that were png_uint_32 instead of png_alloc_size_t
- (Bug report by "irwir" in Github libpng issue #175).
- Use pnglibconf.h.prebuilt when building for ANDROID with cmake (Github
- issue 162, by rcdailey).
-
-Version 1.6.33rc01 [September 20, 2017]
- Initialize memory allocated by png_inflate to zero, using memset, to
- stop an oss-fuzz "use of uninitialized value" detection in png_set_text_2()
- due to truncated iTXt or zTXt chunk.
- Initialize memory allocated by png_read_buffer to zero, using memset, to
- stop an oss-fuzz "use of uninitialized value" detection in
- png_icc_check_tag_table() due to truncated iCCP chunk.
- Removed a redundant test (suggested by "irwir" in Github issue #180).
-
-Version 1.6.33rc02 [September 23, 2017]
- Added an interlaced version of each file in contrib/pngsuite.
- Relocate new memset() call in pngrutil.c.
- Removed more redundant tests (suggested by "irwir" in Github issue #180).
- Add support for loading images with associated alpha in the Simplified
- API (Samuel Williams).
-
-Version 1.6.33 [September 28, 2017]
- Revert contrib/oss-fuzz/libpng_read_fuzzer.cc to libpng-1.6.32 state.
- Initialize png_handler.row_ptr in contrib/oss-fuzz/libpng_read_fuzzer.cc
- Add end_info structure and png_read_end() to the libpng fuzzer.
-
-Version 1.6.34 [September 29, 2017]
- Removed contrib/pngsuite/i*.png; some of them caused test failures.
-
-Version 1.6.35beta01 [March 6, 2018]
- Restored 21 of the contrib/pngsuite/i*.png, which do not cause test
- failures. Placed the remainder in contrib/pngsuite/interlaced/i*.png.
- Added calls to png_set_*() transforms commonly used by browsers to
- the fuzzer.
- Removed some unnecessary brackets in pngrtran.c
- Fixed miscellaneous typos (Patch by github user "luzpaz").
- Change "ASM C" to "C ASM" in CMakeLists.txt
- Fixed incorrect handling of bKGD chunk in sub-8-bit files (Cosmin)
- Added hardware optimization directories to zip and 7z distributions.
- Fixed incorrect bitmask for options.
- Fixed many spelling typos.
-
-Version 1.6.35beta02 [March 28, 2018]
- Make png_get_iCCP consistent with man page (allow compression-type argument
- to be NULL, bug report by Lenard Szolnoki).
-
-Version 1.6.35 [July 15, 2018]
- Replaced the remaining uses of png_size_t with size_t (Cosmin)
- Fixed the calculation of row_factor in png_check_chunk_length
- (reported by Thuan Pham in SourceForge issue #278)
- Added missing parentheses to a macro definition
- (suggested by "irwir" in GitHub issue #216)
-
-Version 1.6.36 [December 1, 2018]
- Optimized png_do_expand_palette for ARM processors.
- Improved performance by around 10-22% on a recent ARM Chromebook.
- (Contributed by Richard Townsend, ARM Holdings)
- Fixed manipulation of machine-specific optimization options.
- (Contributed by Vicki Pfau)
- Used memcpy instead of manual pointer arithmetic on Intel SSE2.
- (Contributed by Samuel Williams)
- Fixed build errors with MSVC on ARM64.
- (Contributed by Zhijie Liang)
- Fixed detection of libm in CMakeLists.
- (Contributed by Cameron Cawley)
- Fixed incorrect creation of pkg-config file in CMakeLists.
- (Contributed by Kyle Bentley)
- Fixed the CMake build on Windows MSYS by avoiding symlinks.
- Fixed a build warning on OpenBSD.
- (Contributed by Theo Buehler)
- Fixed various typos in comments.
- (Contributed by "luz.paz")
- Raised the minimum required CMake version from 3.0.2 to 3.1.
- Removed yet more of the vestigial support for pre-ANSI C compilers.
- Removed ancient makefiles for ancient systems that have been broken
- across all previous libpng-1.6.x versions.
- Removed the Y2K compliance statement and the export control
- information.
- Applied various code style and documentation fixes.
-
-Version 1.6.37 [April 14, 2019]
- Fixed a use-after-free vulnerability (CVE-2019-7317) in png_image_free.
- Fixed a memory leak in the ARM NEON implementation of png_do_expand_palette.
- Fixed a memory leak in pngtest.c.
- Fixed two vulnerabilities (CVE-2018-14048, CVE-2018-14550) in
- contrib/pngminus; refactor.
- Changed the license of contrib/pngminus to MIT; refresh makefile and docs.
- (Contributed by Willem van Schaik)
- Fixed a typo in the libpng license v2.
- (Contributed by Miguel Ojeda)
- Added makefiles for AddressSanitizer-enabled builds.
- Cleaned up various makefiles.
-
-Version 1.6.38 [September 14, 2022]
- Added configurations and scripts for continuous integration.
- Fixed various errors in the handling of tRNS, hIST and eXIf.
- Implemented many stability improvements across all platforms.
- Updated the internal documentation.
-
-Version 1.6.39 [November 20, 2022]
- Changed the error handler of oversized chunks (i.e. larger than
- PNG_USER_CHUNK_MALLOC_MAX) from png_chunk_error to png_benign_error.
- Fixed a buffer overflow error in contrib/tools/pngfix.
- Fixed a memory leak (CVE-2019-6129) in contrib/tools/pngcp.
- Disabled the ARM Neon optimizations by default in the CMake file,
- following the default behavior of the configure script.
- Allowed configure.ac to work with the trunk version of autoconf.
- Removed the support for "install" targets from the legacy makefiles;
- removed the obsolete makefile.cegcc.
- Cleaned up the code and updated the internal documentation.
-
-Version 1.6.40 [June 21, 2023]
- Fixed the eXIf chunk multiplicity checks.
- Fixed a memory leak in pCAL processing.
- Corrected the validity report about tRNS inside png_get_valid().
- Fixed various build issues on *BSD, Mac and Windows.
- Updated the configurations and the scripts for continuous integration.
- Cleaned up the code, the build scripts, and the documentation.
-
-Version 1.6.41 [January 24, 2024]
- Added SIMD-optimized code for the LoongArch LSX hardware.
- (Contributed by GuXiWei, JinBo and ZhangLixia)
- Fixed the run-time discovery of MIPS MSA hardware.
- (Contributed by Sui Jingfeng)
- Fixed an off-by-one error in the function png_do_check_palette_indexes(),
- which failed to recognize errors that might have existed in the first
- column of a broken palette-encoded image. This was a benign regression
- accidentally introduced in libpng-1.6.33. No pixel was harmed.
- (Contributed by Adam Richter; reviewed by John Bowler)
- Fixed, improved and modernized the contrib/pngminus programs, i.e.,
- png2pnm.c and pnm2png.c
- Removed old and peculiar portability hacks that were meant to silence
- warnings issued by gcc version 7.1 alone.
- (Contributed by John Bowler)
- Fixed and modernized the CMake file, and raised the minimum required
- CMake version from 3.1 to 3.6.
- (Contributed by Clinton Ingram, Timothy Lyanguzov, Tyler Kropp, et al.)
- Allowed the configure script to disable the building of auxiliary tools
- and tests, thus catching up with the CMake file.
- (Contributed by Carlo Bramini)
- Fixed a build issue on Mac.
- (Contributed by Zixu Wang)
- Moved the Autoconf macro files to scripts/autoconf.
- Moved the CMake files (except for the main CMakeLists.txt) to
- scripts/cmake and moved the list of their contributing authors to
- scripts/cmake/AUTHORS.md
- Updated the CI configurations and scripts.
- Relicensed the CI scripts to the MIT License.
- Improved the test coverage.
- (Contributed by John Bowler)
-
-Version 1.6.42 [January 29, 2024]
- Fixed the implementation of the macro function png_check_sig().
- This was an API regression, introduced in libpng-1.6.41.
- (Reported by Matthieu Darbois)
- Fixed and updated the libpng manual.
-
-Version 1.6.43 [February 23, 2024]
- Fixed the row width check in png_check_IHDR().
- This corrected a bug that was specific to the 16-bit platforms,
- and removed a spurious compiler warning from the 64-bit builds.
- (Reported by Jacek Caban; fixed by John Bowler)
- Added eXIf chunk support to the push-mode reader in pngpread.c.
- (Contributed by Chris Blume)
- Added contrib/pngexif for the benefit of the users who would like
- to inspect the content of eXIf chunks.
- Added contrib/conftest/basic.dfa, a basic build-time configuration.
- (Contributed by John Bowler)
- Fixed a preprocessor condition in pngread.c that broke build-time
- configurations like contrib/conftest/pngcp.dfa.
- (Contributed by John Bowler)
- Added CMake build support for LoongArch LSX.
- (Contributed by GuXiWei)
- Fixed a CMake build error that occurred under a peculiar state of the
- dependency tree. This was a regression introduced in libpng-1.6.41.
- (Contributed by Dan Rosser)
- Marked the installed libpng headers as system headers in CMake.
- (Contributed by Benjamin Buch)
- Updated the build support for RISCOS.
- (Contributed by Cameron Cawley)
- Updated the makefiles to allow cross-platform builds to initialize
- conventional make variables like AR and ARFLAGS.
- Added various improvements to the CI scripts in areas like version
- consistency verification and text linting.
- Added version consistency verification to pngtest.c also.
-
-Version 1.6.44 [September 12, 2024]
- Hardened calculations in chroma handling to prevent overflows, and
- relaxed a constraint in cHRM validation to accomodate the standard
- ACES AP1 set of color primaries.
- (Contributed by John Bowler)
- Removed the ASM implementation of ARM Neon optimizations and updated
- the build accordingly. Only the remaining C implementation shall be
- used from now on, thus ensuring the support of the PAC/BTI security
- features on ARM64.
- (Contributed by Ross Burton and John Bowler)
- Fixed the pickup of the PNG_HARDWARE_OPTIMIZATIONS option in the
- CMake build on FreeBSD/amd64. This is an important performance fix
- on this platform.
- Applied various fixes and improvements to the CMake build.
- (Contributed by Eric Riff, Benjamin Buch and Erik Scholz)
- Added fuzzing targets for the simplified read API.
- (Contributed by Mikhail Khachayants)
- Fixed a build error involving pngtest.c under a custom config.
- This was a regression introduced in a code cleanup in libpng-1.6.43.
- (Contributed by Ben Wagner)
- Fixed and improved the config files for AppVeyor CI and Travis CI.
-
-Version 1.6.45 [January 7, 2025]
- Added support for the cICP chunk.
- (Contributed by Lucas Chollet and John Bowler)
- Adjusted and improved various checks in colorspace calculations.
- (Contributed by John Bowler)
- Rearranged the write order of colorspace chunks for better conformance
- with the PNG v3 draft specification.
- (Contributed by John Bowler)
- Raised the minimum required CMake version from 3.6 to 3.14.
- Forked off a development branch for libpng version 1.8.
-
-Version 1.6.46 [January 23, 2025]
- Added support for the mDCV and cLLI chunks.
- (Contributed by John Bowler)
- Fixed a build issue affecting C89 compilers.
- This was a regression introduced in libpng-1.6.45.
- (Contributed by John Bowler)
- Added makefile.c89, specifically for testing C89 compilers.
- Cleaned up contrib/pngminus: corrected an old typo, removed an old
- workaround, and updated the CMake file.
-
-Send comments/corrections/commendations to png-mng-implement at lists.sf.net.
-Subscription is required; visit
-https://lists.sourceforge.net/lists/listinfo/png-mng-implement
-to subscribe.
diff --git a/contrib/libs/libpng/INSTALL b/contrib/libs/libpng/INSTALL
deleted file mode 100644
index df1a494468..0000000000
--- a/contrib/libs/libpng/INSTALL
+++ /dev/null
@@ -1,463 +0,0 @@
- Installing libpng
-
-Contents
-
- I. Simple installation
- II. Rebuilding the configure scripts
- III. Using scripts/makefile*
- IV. Using cmake
- V. Directory structure
- VI. Building with project files
- VII. Building with makefiles
- VIII. Configuring libpng for 16-bit platforms
- IX. Configuring for DOS
- X. Configuring for Medium Model
- XI. Prepending a prefix to exported symbols
- XII. Configuring for compiler xxx:
- XIII. Removing unwanted object code
- XIV. Enabling or disabling hardware optimizations
- XV. Changes to the build and configuration of libpng in libpng-1.5.x
- XVI. Setjmp/longjmp issues
- XVII. Common linking failures
- XVIII. Other sources of information about libpng
-
-I. Simple installation
-
-On Unix/Linux and similar systems, you can simply type
-
- ./configure [--prefix=/path]
- make check
- make install
-
-and ignore the rest of this document. "/path" is the path to the directory
-where you want to install the libpng "lib", "include", and "bin"
-subdirectories.
-
-If you downloaded a GIT clone, you will need to run ./autogen.sh before
-running ./configure, to create "configure" and "Makefile.in" which are
-not included in the GIT repository.
-
-Note that "configure" is only included in the "*.tar" distributions and not
-in the "*.zip" or "*.7z" distributions. If you downloaded one of those
-distributions, see "Building with project files" or "Building with makefiles",
-below.
-
-II. Rebuilding the configure scripts
-
-If configure does not work on your system, or if you have a need to
-change configure.ac or Makefile.am, and you have a reasonably
-up-to-date set of tools, running ./autogen.sh in a git clone before
-running ./configure may fix the problem. To be really sure that you
-aren't using any of the included pre-built scripts, especially if you
-are building from a tar distribution instead of a git distribution,
-do this:
-
- ./configure --enable-maintainer-mode
- make maintainer-clean
- ./autogen.sh --maintainer --clean
- ./autogen.sh --maintainer
- ./configure [--prefix=/path] [other options]
- make
- make install
- make check
-
-III. Using scripts/makefile*
-
-Instead, you can use one of the custom-built makefiles in the
-"scripts" directory
-
- cp scripts/pnglibconf.h.prebuilt pnglibconf.h
- cp scripts/makefile.system makefile
- make test
- make install
-
-The files that are presently available in the scripts directory
-are listed and described in scripts/README.txt.
-
-Or you can use one of the "projects" in the "projects" directory.
-
-Before installing libpng, you must first install zlib, if it
-is not already on your system. zlib can usually be found
-wherever you got libpng; otherwise go to https://zlib.net/. You can
-place zlib in the same directory as libpng or in another directory.
-
-If your system already has a preinstalled zlib you will still need
-to have access to the zlib.h and zconf.h include files that
-correspond to the version of zlib that's installed.
-
-If you wish to test with a particular zlib that is not first in the
-standard library search path, put ZLIBLIB, ZLIBINC, CPPFLAGS, LDFLAGS,
-and LD_LIBRARY_PATH in your environment before running "make test"
-or "make distcheck":
-
- ZLIBLIB=/path/to/lib export ZLIBLIB
- ZLIBINC=/path/to/include export ZLIBINC
- CPPFLAGS="-I$ZLIBINC" export CPPFLAGS
- LDFLAGS="-L$ZLIBLIB" export LDFLAGS
- LD_LIBRARY_PATH="$ZLIBLIB:$LD_LIBRARY_PATH" export LD_LIBRARY_PATH
-
-If you are using one of the makefile scripts, put ZLIBLIB and ZLIBINC
-in your environment and type
-
- make ZLIBLIB=$ZLIBLIB ZLIBINC=$ZLIBINC test
-
-IV. Using cmake
-
-If you want to use "cmake" (see www.cmake.org), type
-
- cmake . -DCMAKE_INSTALL_PREFIX=/path
- make
- make install
-
-As when using the simple configure method described above, "/path" points to
-the installation directory where you want to put the libpng "lib", "include",
-and "bin" subdirectories.
-
-V. Directory structure
-
-You can rename the directories that you downloaded (they
-might be called "libpng-x.y.z" or "libpngNN" and "zlib-1.2.8"
-or "zlib128") so that you have directories called "zlib" and "libpng".
-
-Your directory structure should look like this:
-
- .. (the parent directory)
- libpng (this directory)
- INSTALL (this file)
- README
- *.h, *.c => libpng source files
- CMakeLists.txt => "cmake" script
- ci
- ci_*.sh
- configuration files:
- configure.ac, configure, Makefile.am, Makefile.in,
- autogen.sh, config.guess, ltmain.sh, missing, libpng.pc.in,
- libpng-config.in, aclocal.m4, config.h.in, config.sub,
- depcomp, install-sh, mkinstalldirs, test-pngtest.sh, etc.
- contrib
- arm-neon, conftest, examples, gregbook, libtests, pngminim,
- pngminus, pngsuite, tools, visupng
- projects
- owatcom, visualc71, vstudio
- scripts
- makefile.*
- *.def (module definition files)
- etc.
- pngtest.png
- etc.
- zlib
- README, *.h, *.c, contrib, etc.
-
-If the line endings in the files look funny, you may wish to get the other
-distribution of libpng. It is available in both tar.gz (UNIX style line
-endings) and zip (DOS style line endings) formats.
-
-VI. Building with project files
-
-If you are building libpng with Microsoft Visual Studio, you can enter
-the directory projects\visualc71 or projects\vstudio and follow the
-instructions in README.txt.
-
-Otherwise, enter the zlib directory and follow the instructions in
-zlib/README, then come back here and run "configure" or choose the
-appropriate makefile in the scripts directory.
-
-VII. Building with makefiles
-
-Copy the file (or files) that you need from the
-scripts directory into this directory, for example
-
-UNIX example:
-
- cp scripts/makefile.std Makefile
- make
-
-Windows example:
-
- nmake -f scripts\makefile.vcwin32
-
-Read the makefile to see if you need to change any source or
-target directories to match your preferences.
-
-Then read pnglibconf.dfa to see if you want to make any configuration
-changes.
-
-Then just run "make" which will create the libpng library in
-this directory and "make test" which will run a quick test that reads
-the "pngtest.png" file and writes a "pngout.png" file that should be
-identical to it. Look for "9782 zero samples" in the output of the
-test. For more confidence, you can run another test by typing
-"pngtest pngnow.png" and looking for "289 zero samples" in the output.
-Also, you can run "pngtest -m contrib/pngsuite/*.png" and compare
-your output with the result shown in contrib/pngsuite/README.
-
-Most of the makefiles used to allow you to run "make install" to put
-the library in its final resting place, but that feature is no longer
-supported. The only tested and supported manners to install libpng are
-the conventional build and install procedures driven by the configure
-script or by the CMake file.
-
-VIII. Configuring for DOS and other 16-bit platforms
-
-Officially, the support for 16-bit platforms has been removed.
-
-For DOS users who only have access to the lower 640K, you will
-have to limit zlib's memory usage via a png_set_compression_mem_level()
-call. See zlib.h or zconf.h in the zlib library for more information.
-
-You may be or may not be in luck if you target the "large" memory model,
-but all the smaller models ("small", "compact" and "medium") are known
-to be unworkable. For DOS users who have access beyond the lower 640K,
-a "flat" 32-bit DOS model (such as DJGPP) is strongly recommended.
-
-For DOS users who only have access to the lower 640K, you will have to
-limit zlib's memory usage via a png_set_compression_mem_level() call.
-You will also have to look into zconf.h to tell zlib (and thus libpng)
-that it cannot allocate more than 64K at a time. Even if you can, the
-memory won't be accessible. Therefore, you should limit zlib and libpng
-to 64K by defining MAXSEG_64K.
-
-IX. Prepending a prefix to exported symbols
-
-Starting with libpng-1.6.0, you can configure libpng (when using the
-"configure" script) to prefix all exported symbols by means of the
-configuration option "--with-libpng-prefix=FOO_", where FOO_ can be any
-string beginning with a letter and containing only uppercase
-and lowercase letters, digits, and the underscore (i.e., a C language
-identifier). This creates a set of macros in pnglibconf.h, so this is
-transparent to applications; their function calls get transformed by
-the macros to use the modified names.
-
-X. Configuring for compiler xxx:
-
-All includes for libpng are in pngconf.h. If you need to add, change
-or delete an include, this is the place to do it.
-The includes that are not needed outside libpng are placed in pngpriv.h,
-which is only used by the routines inside libpng itself.
-The files in libpng proper only include pngpriv.h and png.h, which
-in turn includes pngconf.h and, as of libpng-1.5.0, pnglibconf.h.
-As of libpng-1.5.0, pngpriv.h also includes three other private header
-files, pngstruct.h, pnginfo.h, and pngdebug.h, which contain material
-that previously appeared in the public headers.
-
-XI. Removing unwanted object code
-
-There are a bunch of #define's in pngconf.h that control what parts of
-libpng are compiled. All the defines end in _SUPPORTED. If you are
-never going to use a capability, you can change the #define to #undef
-before recompiling libpng and save yourself code and data space, or
-you can turn off individual capabilities with defines that begin with
-"PNG_NO_".
-
-In libpng-1.5.0 and later, the #define's are in pnglibconf.h instead.
-
-You can also turn all of the transforms and ancillary chunk capabilities
-off en masse with compiler directives that define
-PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS,
-or all four, along with directives to turn on any of the capabilities that
-you do want. The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable the
-extra transformations but still leave the library fully capable of reading
-and writing PNG files with all known public chunks. Use of the
-PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive produces a library
-that is incapable of reading or writing ancillary chunks. If you are
-not using the progressive reading capability, you can turn that off
-with PNG_NO_PROGRESSIVE_READ (don't confuse this with the INTERLACING
-capability, which you'll still have).
-
-All the reading and writing specific code are in separate files, so the
-linker should only grab the files it needs. However, if you want to
-make sure, or if you are building a stand alone library, all the
-reading files start with "pngr" and all the writing files start with "pngw".
-The files that don't match either (like png.c, pngtrans.c, etc.)
-are used for both reading and writing, and always need to be included.
-The progressive reader is in pngpread.c
-
-If you are creating or distributing a dynamically linked library (a .so
-or DLL file), you should not remove or disable any parts of the library,
-as this will cause applications linked with different versions of the
-library to fail if they call functions not available in your library.
-The size of the library itself should not be an issue, because only
-those sections that are actually used will be loaded into memory.
-
-XII. Enabling or disabling hardware optimizations
-
-Certain hardware capabilities, such as the Intel SSE instructions,
-are normally detected at run time. Enable them with configure options
-such as one of
-
- --enable-arm-neon=yes
- --enable-mips-msa=yes
- --enable-intel-sse=yes
- --enable-powerpc-vsx=yes
-
-or enable them all at once with
-
- --enable-hardware-optimizations=yes
-
-or, if you are not using "configure", you can use one
-or more of
-
- CPPFLAGS += "-DPNG_ARM_NEON"
- CPPFLAGS += "-DPNG_MIPS_MSA"
- CPPFLAGS += "-DPNG_INTEL_SSE"
- CPPFLAGS += "-DPNG_POWERPC_VSX"
-
-See for example scripts/makefile.linux-opt
-
-If you wish to avoid using them,
-you can disable them via the configure option
-
- --disable-hardware-optimizations
-
-to disable them all, or
-
- --enable-intel-sse=no
-
-to disable a particular one,
-or via compiler-command options such as
-
- CPPFLAGS += "-DPNG_ARM_NEON_OPT=0, -DPNG_MIPS_MSA_OPT=0,
- -DPNG_INTEL_SSE_OPT=0, -DPNG_POWERPC_VSX_OPT=0"
-
-If you are using cmake, hardware optimizations are "on"
-by default. To disable them, use
-
- cmake . -DPNG_ARM_NEON=no -DPNG_INTEL_SSE=no \
- -DPNG_MIPS_MSA=no -DPNG_POWERPC_VSX=no
-
-or disable them all at once with
-
- cmake . -DPNG_HARDWARE_OPTIMIZATIONS=no
-
-XIII. Changes to the build and configuration of libpng in libpng-1.5.x
-
-Details of internal changes to the library code can be found in the CHANGES
-file and in the GIT repository logs. These will be of no concern to the vast
-majority of library users or builders; however, the few who configure libpng
-to a non-default feature set may need to change how this is done.
-
-There should be no need for library builders to alter build scripts if
-these use the distributed build support - configure or the makefiles -
-however, users of the makefiles may care to update their build scripts
-to build pnglibconf.h where the corresponding makefile does not do so.
-
-Building libpng with a non-default configuration has changed completely.
-The old method using pngusr.h should still work correctly even though the
-way pngusr.h is used in the build has been changed; however, library
-builders will probably want to examine the changes to take advantage of
-new capabilities and to simplify their build system.
-
-A. Specific changes to library configuration capabilities
-
-The exact mechanism used to control attributes of API functions has
-changed. A single set of operating system independent macro definitions
-is used and operating system specific directives are defined in
-pnglibconf.h
-
-As part of this the mechanism used to choose procedure call standards on
-those systems that allow a choice has been changed. At present this only
-affects certain Microsoft (DOS, Windows) and IBM (OS/2) operating systems
-running on Intel processors. As before, PNGAPI is defined where required
-to control the exported API functions; however, two new macros, PNGCBAPI
-and PNGCAPI, are used instead for callback functions (PNGCBAPI) and
-(PNGCAPI) for functions that must match a C library prototype (currently
-only png_longjmp_ptr, which must match the C longjmp function.) The new
-approach is documented in pngconf.h
-
-Despite these changes, libpng 1.5.0 only supports the native C function
-calling standard on those platforms tested so far ("__cdecl" on Microsoft
-Windows). This is because the support requirements for alternative
-calling conventions seem to no longer exist. Developers who find it
-necessary to set PNG_API_RULE to 1 should advise the mailing list
-(png-mng-implement) of this and library builders who use Openwatcom and
-therefore set PNG_API_RULE to 2 should also contact the mailing list.
-
-B. Changes to the configuration mechanism
-
-Prior to libpng-1.5.0 library builders who needed to configure libpng
-had either to modify the exported pngconf.h header file to add system
-specific configuration or had to write feature selection macros into
-pngusr.h and cause this to be included into pngconf.h by defining
-PNG_USER_CONFIG. The latter mechanism had the disadvantage that an
-application built without PNG_USER_CONFIG defined would see the
-unmodified, default, libpng API and thus would probably fail to link.
-
-These mechanisms still work in the configure build and in any makefile
-build that builds pnglibconf.h, although the feature selection macros
-have changed somewhat as described above. In 1.5.0, however, pngusr.h is
-processed only once, at the time the exported header file pnglibconf.h is
-built. pngconf.h no longer includes pngusr.h; therefore, pngusr.h is ignored
-after the build of pnglibconf.h and it is never included in an application
-build.
-
-The formerly used alternative of adding a list of feature macros to the
-CPPFLAGS setting in the build also still works; however, the macros will be
-copied to pnglibconf.h and this may produce macro redefinition warnings
-when the individual C files are compiled.
-
-All configuration now only works if pnglibconf.h is built from
-scripts/pnglibconf.dfa. This requires the program awk. Brian Kernighan
-(the original author of awk) maintains C source code of that awk and this
-and all known later implementations (often called by subtly different
-names - nawk and gawk for example) are adequate to build pnglibconf.h.
-The Sun Microsystems (now Oracle) program 'awk' is an earlier version
-and does not work; this may also apply to other systems that have a
-functioning awk called 'nawk'.
-
-Configuration options are now documented in scripts/pnglibconf.dfa. This
-file also includes dependency information that ensures a configuration is
-consistent; that is, if a feature is switched off, dependent features are
-also switched off. As a recommended alternative to using feature macros in
-pngusr.h a system builder may also define equivalent options in pngusr.dfa
-(or, indeed, any file) and add that to the configuration by setting
-DFA_XTRA to the file name. The makefiles in contrib/pngminim illustrate
-how to do this, and also illustrate a case where pngusr.h is still required.
-
-After you have built libpng, the definitions that were recorded in
-pnglibconf.h are available to your application (pnglibconf.h is included
-in png.h and gets installed alongside png.h and pngconf.h in your
-$PREFIX/include directory). Do not edit pnglibconf.h after you have built
-libpng, because than the settings would not accurately reflect the settings
-that were used to build libpng.
-
-XIV. Setjmp/longjmp issues
-
-Libpng uses setjmp()/longjmp() for error handling. Unfortunately setjmp()
-is known to be not thread-safe on some platforms and we don't know of
-any platform where it is guaranteed to be thread-safe. Therefore, if
-your application is going to be using multiple threads, you should
-configure libpng with PNG_NO_SETJMP in your pngusr.dfa file, with
--DPNG_NO_SETJMP on your compile line, or with
-
- #undef PNG_SETJMP_SUPPORTED
-
-in your pnglibconf.h or pngusr.h.
-
-Starting with libpng-1.6.0, the library included a "simplified API".
-This requires setjmp/longjmp, so you must either build the library
-with PNG_SETJMP_SUPPORTED defined, or with PNG_SIMPLIFIED_READ_SUPPORTED
-and PNG_SIMPLIFIED_WRITE_SUPPORTED undefined.
-
-XV. Common linking failures
-
-If your application fails to find libpng or zlib entries while linking:
-
- Be sure "-lz" appears after "-lpng" on your linking command.
-
- Be sure you have built libpng, zlib, and your application for the
- same platform (e.g., 32-bit or 64-bit).
-
- If you are using the vstudio project, observe the WARNING in
- project/vstudio/README.txt.
-
-XVI. Other sources of information about libpng:
-
-Further information can be found in the README and libpng-manual.txt
-files, in the individual makefiles, in png.h, and the manual pages
-libpng.3 and png.5.
-
-Copyright (c) 2022 Cosmin Truta
-Copyright (c) 1998-2002,2006-2016 Glenn Randers-Pehrson
-This document is released under the libpng license.
-For conditions of distribution and use, see the disclaimer
-and license in png.h.
diff --git a/contrib/libs/libpng/LICENSE b/contrib/libs/libpng/LICENSE
deleted file mode 100644
index 7e6e5b25b0..0000000000
--- a/contrib/libs/libpng/LICENSE
+++ /dev/null
@@ -1,140 +0,0 @@
-COPYRIGHT NOTICE, DISCLAIMER, and LICENSE
-=========================================
-
-This modified version of libpng code adds animated PNG support and is
-released under the libpng license described below. The modifications are
-Copyright (c) 2006-2007 Andrew Smith, Copyright (c) 2008-2025 Max Stepin,
-and are delimited by "#ifdef PNG_APNG_SUPPORTED / #endif" directives
-surrounding them in the modified libpng source files.
-
-PNG Reference Library License version 2
----------------------------------------
-
- * Copyright (c) 1995-2025 The PNG Reference Library Authors.
- * Copyright (c) 2018-2025 Cosmin Truta.
- * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson.
- * Copyright (c) 1996-1997 Andreas Dilger.
- * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
-
-The software is supplied "as is", without warranty of any kind,
-express or implied, including, without limitation, the warranties
-of merchantability, fitness for a particular purpose, title, and
-non-infringement. In no event shall the Copyright owners, or
-anyone distributing the software, be liable for any damages or
-other liability, whether in contract, tort or otherwise, arising
-from, out of, or in connection with the software, or the use or
-other dealings in the software, even if advised of the possibility
-of such damage.
-
-Permission is hereby granted to use, copy, modify, and distribute
-this software, or portions hereof, for any purpose, without fee,
-subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you
- must not claim that you wrote the original software. If you
- use this software in a product, an acknowledgment in the product
- documentation would be appreciated, but is not required.
-
- 2. Altered source versions must be plainly marked as such, and must
- not be misrepresented as being the original software.
-
- 3. This Copyright notice may not be removed or altered from any
- source or altered source distribution.
-
-
-PNG Reference Library License version 1 (for libpng 0.5 through 1.6.35)
------------------------------------------------------------------------
-
-libpng versions 1.0.7, July 1, 2000, through 1.6.35, July 15, 2018 are
-Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson, are
-derived from libpng-1.0.6, and are distributed according to the same
-disclaimer and license as libpng-1.0.6 with the following individuals
-added to the list of Contributing Authors:
-
- Simon-Pierre Cadieux
- Eric S. Raymond
- Mans Rullgard
- Cosmin Truta
- Gilles Vollant
- James Yu
- Mandar Sahastrabuddhe
- Google Inc.
- Vadim Barkov
-
-and with the following additions to the disclaimer:
-
- There is no warranty against interference with your enjoyment of
- the library or against infringement. There is no warranty that our
- efforts or the library will fulfill any of your particular purposes
- or needs. This library is provided with all faults, and the entire
- risk of satisfactory quality, performance, accuracy, and effort is
- with the user.
-
-Some files in the "contrib" directory and some configure-generated
-files that are distributed with libpng have other copyright owners, and
-are released under other open source licenses.
-
-libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
-Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
-libpng-0.96, and are distributed according to the same disclaimer and
-license as libpng-0.96, with the following individuals added to the
-list of Contributing Authors:
-
- Tom Lane
- Glenn Randers-Pehrson
- Willem van Schaik
-
-libpng versions 0.89, June 1996, through 0.96, May 1997, are
-Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
-and are distributed according to the same disclaimer and license as
-libpng-0.88, with the following individuals added to the list of
-Contributing Authors:
-
- John Bowler
- Kevin Bracey
- Sam Bushell
- Magnus Holmgren
- Greg Roelofs
- Tom Tanner
-
-Some files in the "scripts" directory have other copyright owners,
-but are released under this license.
-
-libpng versions 0.5, May 1995, through 0.88, January 1996, are
-Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
-
-For the purposes of this copyright and license, "Contributing Authors"
-is defined as the following set of individuals:
-
- Andreas Dilger
- Dave Martindale
- Guy Eric Schalnat
- Paul Schmidt
- Tim Wegner
-
-The PNG Reference Library is supplied "AS IS". The Contributing
-Authors and Group 42, Inc. disclaim all warranties, expressed or
-implied, including, without limitation, the warranties of
-merchantability and of fitness for any purpose. The Contributing
-Authors and Group 42, Inc. assume no liability for direct, indirect,
-incidental, special, exemplary, or consequential damages, which may
-result from the use of the PNG Reference Library, even if advised of
-the possibility of such damage.
-
-Permission is hereby granted to use, copy, modify, and distribute this
-source code, or portions hereof, for any purpose, without fee, subject
-to the following restrictions:
-
- 1. The origin of this source code must not be misrepresented.
-
- 2. Altered versions must be plainly marked as such and must not
- be misrepresented as being the original source.
-
- 3. This Copyright notice may not be removed or altered from any
- source or altered source distribution.
-
-The Contributing Authors and Group 42, Inc. specifically permit,
-without fee, and encourage the use of this source code as a component
-to supporting the PNG file format in commercial products. If you use
-this source code in a product, acknowledgment is not required but would
-be appreciated.
diff --git a/contrib/libs/libpng/README b/contrib/libs/libpng/README
deleted file mode 100644
index 3f3f02023e..0000000000
--- a/contrib/libs/libpng/README
+++ /dev/null
@@ -1,182 +0,0 @@
-README for libpng version 1.6.46
-================================
-
-See the note about version numbers near the top of `png.h`.
-See `INSTALL` for instructions on how to install libpng.
-
-Libpng comes in several distribution formats. Get `libpng-*.tar.gz`
-or `libpng-*.tar.xz` if you want UNIX-style line endings in the text
-files, or `lpng*.7z` or `lpng*.zip` if you want DOS-style line endings.
-
-For a detailed description on using libpng, read `libpng-manual.txt`.
-For examples of libpng in a program, see `example.c` and `pngtest.c`.
-For usage information and restrictions (what little they are) on libpng,
-see `png.h`. For a description on using zlib (the compression library
-used by libpng) and zlib's restrictions, see `zlib.h`.
-
-You should use zlib 1.0.4 or later to run this, but it _may_ work with
-versions as old as zlib 0.95. Even so, there are bugs in older zlib
-versions which can cause the output of invalid compression streams for
-some images.
-
-You should also note that zlib is a compression library that is useful
-for more things than just PNG files. You can use zlib as a drop-in
-replacement for `fread()` and `fwrite()`, if you are so inclined.
-
-zlib should be available at the same place that libpng is, or at
-https://zlib.net .
-
-You may also want a copy of the PNG specification. It is available
-as an RFC, a W3C Recommendation, and an ISO/IEC Standard. You can find
-these at http://www.libpng.org/pub/png/pngdocs.html .
-
-This code is currently being archived at https://libpng.sourceforge.io
-in the download area, and at http://libpng.download/src .
-
-This release, based in a large way on Glenn's, Guy's and Andreas'
-earlier work, was created and will be supported by myself and the PNG
-development group.
-
-Send comments, corrections and commendations to `png-mng-implement`
-at `lists.sourceforge.net`. (Subscription is required; visit
-https://lists.sourceforge.net/lists/listinfo/png-mng-implement
-to subscribe.)
-
-Send general questions about the PNG specification to `png-mng-misc`
-at `lists.sourceforge.net`. (Subscription is required; visit
-https://lists.sourceforge.net/lists/listinfo/png-mng-misc
-to subscribe.)
-
-Historical notes
-----------------
-
-The libpng library has been in extensive use and testing since mid-1995.
-Version 0.89, published a year later, was the first official release.
-By late 1997, it had finally gotten to the stage where there hadn't
-been significant changes to the API in some time, and people have a bad
-feeling about libraries with versions below 1.0. Version 1.0.0 was
-released in March 1998.
-
-Note that some of the changes to the `png_info` structure render this
-version of the library binary incompatible with libpng-0.89 or
-earlier versions if you are using a shared library. The type of the
-`filler` parameter for `png_set_filler()` has changed from `png_byte`
-to `png_uint_32`, which will affect shared-library applications that
-use this function.
-
-To avoid problems with changes to the internals of the `info_struct`,
-new APIs have been made available in 0.95 to avoid direct application
-access to `info_ptr`. These functions are the `png_set_<chunk>` and
-`png_get_<chunk>` functions. These functions should be used when
-accessing/storing the `info_struct` data, rather than manipulating it
-directly, to avoid such problems in the future.
-
-It is important to note that the APIs did not make current programs
-that access the info struct directly incompatible with the new
-library, through libpng-1.2.x. In libpng-1.4.x, which was meant to
-be a transitional release, members of the `png_struct` and the
-`info_struct` can still be accessed, but the compiler will issue a
-warning about deprecated usage. Since libpng-1.5.0, direct access
-to these structs is not allowed, and the definitions of the structs
-reside in private `pngstruct.h` and `pnginfo.h` header files that are
-not accessible to applications. It is strongly suggested that new
-programs use the new APIs (as shown in `example.c` and `pngtest.c`),
-and older programs be converted to the new format, to facilitate
-upgrades in the future.
-
-The additions since 0.89 include the ability to read from a PNG stream
-which has had some (or all) of the signature bytes read by the calling
-application. This also allows the reading of embedded PNG streams that
-do not have the PNG file signature. As well, it is now possible to set
-the library action on the detection of chunk CRC errors. It is possible
-to set different actions based on whether the CRC error occurred in a
-critical or an ancillary chunk.
-
-The additions since 0.90 include the ability to compile libpng as a
-Windows DLL, and new APIs for accessing data in the `info_struct`.
-Experimental functions included the ability to set weighting and cost
-factors for row filter selection, direct reads of integers from buffers
-on big-endian processors that support misaligned data access, faster
-methods of doing alpha composition, and more accurate 16-to-8 bit color
-conversion. Some of these experimental functions, such as the weighted
-filter heuristics, have since been removed.
-
-Files included in this distribution
------------------------------------
-
- ANNOUNCE => Announcement of this version, with recent changes
- AUTHORS => List of contributing authors
- CHANGES => Description of changes between libpng versions
- INSTALL => Instructions to install libpng
- LICENSE => License to use and redistribute libpng
- README => This file
- TODO => Things not implemented in the current library
- TRADEMARK => Trademark information
- example.c => Example code for using libpng functions
- libpng.3 => Manual page for libpng (includes libpng-manual.txt)
- libpng-manual.txt => Description of libpng and its functions
- libpngpf.3 => Manual page for libpng's private functions (deprecated)
- png.5 => Manual page for the PNG format
- png.c => Basic interface functions common to library
- png.h => Library function and interface declarations (public)
- pngpriv.h => Library function and interface declarations (private)
- pngconf.h => System specific library configuration (public)
- pngstruct.h => png_struct declaration (private)
- pnginfo.h => png_info struct declaration (private)
- pngdebug.h => debugging macros (private)
- pngerror.c => Error/warning message I/O functions
- pngget.c => Functions for retrieving info from struct
- pngmem.c => Memory handling functions
- pngbar.png => PNG logo, 88x31
- pngnow.png => PNG logo, 98x31
- pngpread.c => Progressive reading functions
- pngread.c => Read data/helper high-level functions
- pngrio.c => Lowest-level data read I/O functions
- pngrtran.c => Read data transformation functions
- pngrutil.c => Read data utility functions
- pngset.c => Functions for storing data into the info_struct
- pngtest.c => Library test program
- pngtest.png => Library test sample image
- pngtrans.c => Common data transformation functions
- pngwio.c => Lowest-level write I/O functions
- pngwrite.c => High-level write functions
- pngwtran.c => Write data transformations
- pngwutil.c => Write utility functions
- arm/ => Optimized code for ARM Neon
- intel/ => Optimized code for INTEL SSE2
- loongarch/ => Optimized code for LoongArch LSX
- mips/ => Optimized code for MIPS MSA and MIPS MMI
- powerpc/ => Optimized code for PowerPC VSX
- ci/ => Scripts for continuous integration
- contrib/ => External contributions
- arm-neon/ => Optimized code for the ARM-NEON platform
- mips-msa/ => Optimized code for the MIPS-MSA platform
- powerpc-vsx/ => Optimized code for the POWERPC-VSX platform
- examples/ => Examples of libpng usage
- gregbook/ => Source code for PNG reading and writing, from
- "PNG: The Definitive Guide" by Greg Roelofs,
- O'Reilly, 1999
- libtests/ => Test programs
- pngexif/ => Program to inspect the EXIF information in PNG files
- pngminim/ => Minimal decoder, encoder, and progressive decoder
- programs demonstrating the use of pngusr.dfa
- pngminus/ => Simple pnm2png and png2pnm programs
- pngsuite/ => Test images
- testpngs/ => Test images
- tools/ => Various tools
- visupng/ => VisualPng, a Windows viewer for PNG images
- projects/ => Project files and workspaces for various IDEs
- owatcom/ => OpenWatcom project
- visualc71/ => Microsoft Visual C++ 7.1 workspace
- vstudio/ => Microsoft Visual Studio workspace
- scripts/ => Scripts and makefiles for building libpng
- (see scripts/README.txt for the complete list)
- tests/ => Test scripts
-
-Good luck, and happy coding!
-
- * Cosmin Truta (current maintainer, since 2018)
- * Glenn Randers-Pehrson (former maintainer, 1998-2018)
- * Andreas Eric Dilger (former maintainer, 1996-1997)
- * Guy Eric Schalnat (original author and former maintainer, 1995-1996)
- (formerly of Group 42, Inc.)
diff --git a/contrib/libs/libpng/TODO b/contrib/libs/libpng/TODO
deleted file mode 100644
index 8ddb7d123c..0000000000
--- a/contrib/libs/libpng/TODO
+++ /dev/null
@@ -1,22 +0,0 @@
-TODO list for libpng
---------------------
-
- * Fix all defects (duh!)
- * cHRM transformation.
- * Palette creation.
- * "grayscale->palette" transformation and "palette->grayscale" detection.
- * Improved dithering.
- * Multi-lingual error and warning message support.
- * Complete sRGB transformation. (Currently it simply uses gamma=0.45455.)
- * Man pages for function calls.
- * Better documentation.
- * Better filter selection
- (e.g., counting huffman bits/precompression; filter inertia; filter costs).
- * Histogram creation.
- * Text conversion between different code pages (e.g., Latin-1 to Mac).
- * Avoid building gamma tables whenever possible.
- * Greater precision in changing to linear gamma for compositing against
- background, and in doing rgb-to-gray transformations.
- * Investigate pre-incremented loop counters and other loop constructions.
- * Interpolated method of handling interlacing.
- * More validations for libpng transformations.
diff --git a/contrib/libs/libpng/TRADEMARK b/contrib/libs/libpng/TRADEMARK
deleted file mode 100644
index ac667187d6..0000000000
--- a/contrib/libs/libpng/TRADEMARK
+++ /dev/null
@@ -1,8 +0,0 @@
-TRADEMARK
-=========
-
-The name "libpng" has not been registered by the Copyright owners
-as a trademark in any jurisdiction. However, because libpng has
-been distributed and maintained world-wide, continually since 1995,
-the Copyright owners claim "common-law trademark protection" in any
-jurisdiction where common-law trademark is recognized.
diff --git a/contrib/libs/libpng/arm/arm_init.c b/contrib/libs/libpng/arm/arm_init.c
deleted file mode 100644
index d7f137b3cb..0000000000
--- a/contrib/libs/libpng/arm/arm_init.c
+++ /dev/null
@@ -1,138 +0,0 @@
-/* arm_init.c - NEON optimised filter functions
- *
- * Copyright (c) 2018-2022 Cosmin Truta
- * Copyright (c) 2014,2016 Glenn Randers-Pehrson
- * Written by Mans Rullgard, 2011.
- *
- * This code is released under the libpng license.
- * For conditions of distribution and use, see the disclaimer
- * and license in png.h
- */
-
-/* This module requires POSIX 1003.1 functions. */
-#define _POSIX_SOURCE 1
-
-#include "../pngpriv.h"
-
-#ifdef PNG_READ_SUPPORTED
-
-#if PNG_ARM_NEON_OPT > 0
-#ifdef PNG_ARM_NEON_CHECK_SUPPORTED /* Do run-time checks */
-/* WARNING: it is strongly recommended that you do not build libpng with
- * run-time checks for CPU features if at all possible. In the case of the ARM
- * NEON instructions there is no processor-specific way of detecting the
- * presence of the required support, therefore run-time detection is extremely
- * OS specific.
- *
- * You may set the macro PNG_ARM_NEON_FILE to the file name of file containing
- * a fragment of C source code which defines the png_have_neon function. There
- * are a number of implementations in contrib/arm-neon, but the only one that
- * has partial support is contrib/arm-neon/linux.c - a generic Linux
- * implementation which reads /proc/cpufino.
- */
-#include <signal.h> /* for sig_atomic_t */
-
-#ifndef PNG_ARM_NEON_FILE
-# if defined(__aarch64__) || defined(_M_ARM64)
- /* ARM Neon is expected to be unconditionally available on ARM64. */
-# error "PNG_ARM_NEON_CHECK_SUPPORTED must not be defined on ARM64"
-# elif defined(__ARM_NEON__) || defined(__ARM_NEON)
- /* ARM Neon is expected to be available on the target CPU architecture. */
-# error "PNG_ARM_NEON_CHECK_SUPPORTED must not be defined on this CPU arch"
-# elif defined(__linux__)
-# define PNG_ARM_NEON_FILE "contrib/arm-neon/linux.c"
-# else
-# error "No support for run-time ARM Neon checking; use compile-time options"
-# endif
-#endif
-
-static int png_have_neon(png_structp png_ptr);
-#ifdef PNG_ARM_NEON_FILE
-# error #include PNG_ARM_NEON_FILE
-#endif
-#endif /* PNG_ARM_NEON_CHECK_SUPPORTED */
-
-#ifndef PNG_ALIGNED_MEMORY_SUPPORTED
-# error "ALIGNED_MEMORY is required; set: -DPNG_ALIGNED_MEMORY_SUPPORTED"
-#endif
-
-void
-png_init_filter_functions_neon(png_structp pp, unsigned int bpp)
-{
- /* The switch statement is compiled in for ARM_NEON_API, the call to
- * png_have_neon is compiled in for ARM_NEON_CHECK. If both are defined
- * the check is only performed if the API has not set the NEON option on
- * or off explicitly. In this case the check controls what happens.
- *
- * If the CHECK is not compiled in and the option is UNSET the behavior prior
- * to 1.6.7 was to use the NEON code - this was a bug caused by having the
- * wrong order of the 'ON' and 'default' cases. UNSET now defaults to OFF,
- * as documented in png.h
- */
- png_debug(1, "in png_init_filter_functions_neon");
-#ifdef PNG_ARM_NEON_API_SUPPORTED
- switch ((pp->options >> PNG_ARM_NEON) & 3)
- {
- case PNG_OPTION_UNSET:
- /* Allow the run-time check to execute if it has been enabled -
- * thus both API and CHECK can be turned on. If it isn't supported
- * this case will fall through to the 'default' below, which just
- * returns.
- */
-#endif /* PNG_ARM_NEON_API_SUPPORTED */
-#ifdef PNG_ARM_NEON_CHECK_SUPPORTED
- {
- static volatile sig_atomic_t no_neon = -1; /* not checked */
-
- if (no_neon < 0)
- no_neon = !png_have_neon(pp);
-
- if (no_neon)
- return;
- }
-#ifdef PNG_ARM_NEON_API_SUPPORTED
- break;
-#endif
-#endif /* PNG_ARM_NEON_CHECK_SUPPORTED */
-
-#ifdef PNG_ARM_NEON_API_SUPPORTED
- default: /* OFF or INVALID */
- return;
-
- case PNG_OPTION_ON:
- /* Option turned on */
- break;
- }
-#endif
-
- /* IMPORTANT: any new external functions used here must be declared using
- * PNG_INTERNAL_FUNCTION in ../pngpriv.h. This is required so that the
- * 'prefix' option to configure works:
- *
- * ./configure --with-libpng-prefix=foobar_
- *
- * Verify you have got this right by running the above command, doing a build
- * and examining pngprefix.h; it must contain a #define for every external
- * function you add. (Notice that this happens automatically for the
- * initialization function.)
- */
- pp->read_filter[PNG_FILTER_VALUE_UP-1] = png_read_filter_row_up_neon;
-
- if (bpp == 3)
- {
- pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub3_neon;
- pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg3_neon;
- pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =
- png_read_filter_row_paeth3_neon;
- }
-
- else if (bpp == 4)
- {
- pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub4_neon;
- pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg4_neon;
- pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =
- png_read_filter_row_paeth4_neon;
- }
-}
-#endif /* PNG_ARM_NEON_OPT > 0 */
-#endif /* READ */
diff --git a/contrib/libs/libpng/arm/filter_neon.S b/contrib/libs/libpng/arm/filter_neon.S
deleted file mode 100644
index 0cbd372cb1..0000000000
--- a/contrib/libs/libpng/arm/filter_neon.S
+++ /dev/null
@@ -1,60 +0,0 @@
-/* filter_neon.S - placeholder file
- *
- * Copyright (c) 2024 Cosmin Truta
- *
- * This code is released under the libpng license.
- * For conditions of distribution and use, see the disclaimer
- * and license in png.h
- */
-
-/* IMPORTANT NOTE:
- *
- * Historically, the hand-coded assembler implementation of Neon optimizations
- * in this module had not been in sync with the intrinsics-based implementation
- * in filter_neon_intrinsics.c and palette_neon_intrinsics.c, at least since
- * the introduction of riffled palette optimizations. Moreover, the assembler
- * code used to work on 32-bit ARM only, and it caused problems, even if empty,
- * on 64-bit ARM.
- *
- * All references to this module from our internal build scripts and projects
- * have been removed.
- *
- * For the external projects that might still expect this module to be present,
- * we leave this stub in place, for the remaining lifetime of libpng-1.6.x.
- * Everything should continue to function normally, as long as there are no
- * deliberate attempts to use the old hand-made assembler code. A build error
- * will be raised otherwise.
- */
-
-/* This is required to get the symbol renames, which are #defines, and the
- * definitions (or not) of PNG_ARM_NEON_OPT and PNG_ARM_NEON_IMPLEMENTATION.
- */
-#define PNG_VERSION_INFO_ONLY
-#include "../pngpriv.h"
-
-#ifdef PNG_READ_SUPPORTED
-#if PNG_ARM_NEON_IMPLEMENTATION == 2 /* hand-coded assembler */
-#if PNG_ARM_NEON_OPT > 0
-
-#if defined(__clang__)
-#define GNUC_VERSION 0 /* not gcc, although it might pretend to be */
-#elif defined(__GNUC__)
-#define GNUC_MAJOR (__GNUC__ + 0)
-#define GNUC_MINOR (__GNUC_MINOR__ + 0)
-#define GNUC_PATCHLEVEL (__GNUC_PATCHLEVEL__ + 0)
-#define GNUC_VERSION (GNUC_MAJOR * 10000 + GNUC_MINOR * 100 + GNUC_PATCHLEVEL)
-#else
-#define GNUC_VERSION 0 /* not gcc */
-#endif
-
-#if (GNUC_VERSION > 0) && (GNUC_VERSION < 40300)
-#error "PNG_ARM_NEON is not supported with gcc versions earlier than 4.3.0"
-#elif GNUC_VERSION == 40504
-#error "PNG_ARM_NEON is not supported with gcc version 4.5.4"
-#else
-#error "Please use 'arm/*_neon_intrinsics.c' for PNG_ARM_NEON support"
-#endif
-
-#endif /* PNG_ARM_NEON_OPT > 0 */
-#endif /* PNG_ARM_NEON_IMPLEMENTATION == 2 */
-#endif /* READ */
diff --git a/contrib/libs/libpng/arm/filter_neon_intrinsics.c b/contrib/libs/libpng/arm/filter_neon_intrinsics.c
deleted file mode 100644
index 7c3e0da4d8..0000000000
--- a/contrib/libs/libpng/arm/filter_neon_intrinsics.c
+++ /dev/null
@@ -1,401 +0,0 @@
-/* filter_neon_intrinsics.c - NEON optimised filter functions
- *
- * Copyright (c) 2018 Cosmin Truta
- * Copyright (c) 2014,2016 Glenn Randers-Pehrson
- * Written by James Yu <james.yu at linaro.org>, October 2013.
- * Based on filter_neon.S, written by Mans Rullgard, 2011.
- *
- * This code is released under the libpng license.
- * For conditions of distribution and use, see the disclaimer
- * and license in png.h
- */
-
-#include "../pngpriv.h"
-
-#ifdef PNG_READ_SUPPORTED
-
-/* This code requires -mfpu=neon on the command line: */
-#if PNG_ARM_NEON_IMPLEMENTATION == 1 /* intrinsics code from pngpriv.h */
-
-#if defined(_MSC_VER) && !defined(__clang__) && defined(_M_ARM64)
-# include <arm64_neon.h>
-#else
-# include <arm_neon.h>
-#endif
-
-/* libpng row pointers are not necessarily aligned to any particular boundary,
- * however this code will only work with appropriate alignment. arm/arm_init.c
- * checks for this (and will not compile unless it is done). This code uses
- * variants of png_aligncast to avoid compiler warnings.
- */
-#define png_ptr(type,pointer) png_aligncast(type *,pointer)
-#define png_ptrc(type,pointer) png_aligncastconst(const type *,pointer)
-
-/* The following relies on a variable 'temp_pointer' being declared with type
- * 'type'. This is written this way just to hide the GCC strict aliasing
- * warning; note that the code is safe because there never is an alias between
- * the input and output pointers.
- *
- * When compiling with MSVC ARM64, the png_ldr macro can't be passed directly
- * to vst4_lane_u32, because of an internal compiler error inside MSVC.
- * To avoid this compiler bug, we use a temporary variable (vdest_val) to store
- * the result of png_ldr.
- */
-#define png_ldr(type,pointer)\
- (temp_pointer = png_ptr(type,pointer), *temp_pointer)
-
-#if PNG_ARM_NEON_OPT > 0
-
-void
-png_read_filter_row_up_neon(png_row_infop row_info, png_bytep row,
- png_const_bytep prev_row)
-{
- png_bytep rp = row;
- png_bytep rp_stop = row + row_info->rowbytes;
- png_const_bytep pp = prev_row;
-
- png_debug(1, "in png_read_filter_row_up_neon");
-
- for (; rp < rp_stop; rp += 16, pp += 16)
- {
- uint8x16_t qrp, qpp;
-
- qrp = vld1q_u8(rp);
- qpp = vld1q_u8(pp);
- qrp = vaddq_u8(qrp, qpp);
- vst1q_u8(rp, qrp);
- }
-}
-
-void
-png_read_filter_row_sub3_neon(png_row_infop row_info, png_bytep row,
- png_const_bytep prev_row)
-{
- png_bytep rp = row;
- png_bytep rp_stop = row + row_info->rowbytes;
-
- uint8x16_t vtmp = vld1q_u8(rp);
- uint8x8x2_t *vrpt = png_ptr(uint8x8x2_t, &vtmp);
- uint8x8x2_t vrp = *vrpt;
-
- uint8x8x4_t vdest;
- vdest.val[3] = vdup_n_u8(0);
-
- png_debug(1, "in png_read_filter_row_sub3_neon");
-
- for (; rp < rp_stop;)
- {
- uint8x8_t vtmp1, vtmp2;
- uint32x2_t *temp_pointer;
-
- vtmp1 = vext_u8(vrp.val[0], vrp.val[1], 3);
- vdest.val[0] = vadd_u8(vdest.val[3], vrp.val[0]);
- vtmp2 = vext_u8(vrp.val[0], vrp.val[1], 6);
- vdest.val[1] = vadd_u8(vdest.val[0], vtmp1);
-
- vtmp1 = vext_u8(vrp.val[1], vrp.val[1], 1);
- vdest.val[2] = vadd_u8(vdest.val[1], vtmp2);
- vdest.val[3] = vadd_u8(vdest.val[2], vtmp1);
-
- vtmp = vld1q_u8(rp + 12);
- vrpt = png_ptr(uint8x8x2_t, &vtmp);
- vrp = *vrpt;
-
- vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[0]), 0);
- rp += 3;
- vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[1]), 0);
- rp += 3;
- vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[2]), 0);
- rp += 3;
- vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[3]), 0);
- rp += 3;
- }
-
- PNG_UNUSED(prev_row)
-}
-
-void
-png_read_filter_row_sub4_neon(png_row_infop row_info, png_bytep row,
- png_const_bytep prev_row)
-{
- png_bytep rp = row;
- png_bytep rp_stop = row + row_info->rowbytes;
-
- uint8x8x4_t vdest;
- vdest.val[3] = vdup_n_u8(0);
-
- png_debug(1, "in png_read_filter_row_sub4_neon");
-
- for (; rp < rp_stop; rp += 16)
- {
- uint32x2x4_t vtmp = vld4_u32(png_ptr(uint32_t,rp));
- uint8x8x4_t *vrpt = png_ptr(uint8x8x4_t,&vtmp);
- uint8x8x4_t vrp = *vrpt;
- uint32x2x4_t *temp_pointer;
- uint32x2x4_t vdest_val;
-
- vdest.val[0] = vadd_u8(vdest.val[3], vrp.val[0]);
- vdest.val[1] = vadd_u8(vdest.val[0], vrp.val[1]);
- vdest.val[2] = vadd_u8(vdest.val[1], vrp.val[2]);
- vdest.val[3] = vadd_u8(vdest.val[2], vrp.val[3]);
-
- vdest_val = png_ldr(uint32x2x4_t, &vdest);
- vst4_lane_u32(png_ptr(uint32_t,rp), vdest_val, 0);
- }
-
- PNG_UNUSED(prev_row)
-}
-
-void
-png_read_filter_row_avg3_neon(png_row_infop row_info, png_bytep row,
- png_const_bytep prev_row)
-{
- png_bytep rp = row;
- png_const_bytep pp = prev_row;
- png_bytep rp_stop = row + row_info->rowbytes;
-
- uint8x16_t vtmp;
- uint8x8x2_t *vrpt;
- uint8x8x2_t vrp;
- uint8x8x4_t vdest;
- vdest.val[3] = vdup_n_u8(0);
-
- vtmp = vld1q_u8(rp);
- vrpt = png_ptr(uint8x8x2_t,&vtmp);
- vrp = *vrpt;
-
- png_debug(1, "in png_read_filter_row_avg3_neon");
-
- for (; rp < rp_stop; pp += 12)
- {
- uint8x8_t vtmp1, vtmp2, vtmp3;
-
- uint8x8x2_t *vppt;
- uint8x8x2_t vpp;
-
- uint32x2_t *temp_pointer;
-
- vtmp = vld1q_u8(pp);
- vppt = png_ptr(uint8x8x2_t,&vtmp);
- vpp = *vppt;
-
- vtmp1 = vext_u8(vrp.val[0], vrp.val[1], 3);
- vdest.val[0] = vhadd_u8(vdest.val[3], vpp.val[0]);
- vdest.val[0] = vadd_u8(vdest.val[0], vrp.val[0]);
-
- vtmp2 = vext_u8(vpp.val[0], vpp.val[1], 3);
- vtmp3 = vext_u8(vrp.val[0], vrp.val[1], 6);
- vdest.val[1] = vhadd_u8(vdest.val[0], vtmp2);
- vdest.val[1] = vadd_u8(vdest.val[1], vtmp1);
-
- vtmp2 = vext_u8(vpp.val[0], vpp.val[1], 6);
- vtmp1 = vext_u8(vrp.val[1], vrp.val[1], 1);
-
- vtmp = vld1q_u8(rp + 12);
- vrpt = png_ptr(uint8x8x2_t,&vtmp);
- vrp = *vrpt;
-
- vdest.val[2] = vhadd_u8(vdest.val[1], vtmp2);
- vdest.val[2] = vadd_u8(vdest.val[2], vtmp3);
-
- vtmp2 = vext_u8(vpp.val[1], vpp.val[1], 1);
-
- vdest.val[3] = vhadd_u8(vdest.val[2], vtmp2);
- vdest.val[3] = vadd_u8(vdest.val[3], vtmp1);
-
- vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[0]), 0);
- rp += 3;
- vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[1]), 0);
- rp += 3;
- vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[2]), 0);
- rp += 3;
- vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[3]), 0);
- rp += 3;
- }
-}
-
-void
-png_read_filter_row_avg4_neon(png_row_infop row_info, png_bytep row,
- png_const_bytep prev_row)
-{
- png_bytep rp = row;
- png_bytep rp_stop = row + row_info->rowbytes;
- png_const_bytep pp = prev_row;
-
- uint8x8x4_t vdest;
- vdest.val[3] = vdup_n_u8(0);
-
- png_debug(1, "in png_read_filter_row_avg4_neon");
-
- for (; rp < rp_stop; rp += 16, pp += 16)
- {
- uint32x2x4_t vtmp;
- uint8x8x4_t *vrpt, *vppt;
- uint8x8x4_t vrp, vpp;
- uint32x2x4_t *temp_pointer;
- uint32x2x4_t vdest_val;
-
- vtmp = vld4_u32(png_ptr(uint32_t,rp));
- vrpt = png_ptr(uint8x8x4_t,&vtmp);
- vrp = *vrpt;
- vtmp = vld4_u32(png_ptrc(uint32_t,pp));
- vppt = png_ptr(uint8x8x4_t,&vtmp);
- vpp = *vppt;
-
- vdest.val[0] = vhadd_u8(vdest.val[3], vpp.val[0]);
- vdest.val[0] = vadd_u8(vdest.val[0], vrp.val[0]);
- vdest.val[1] = vhadd_u8(vdest.val[0], vpp.val[1]);
- vdest.val[1] = vadd_u8(vdest.val[1], vrp.val[1]);
- vdest.val[2] = vhadd_u8(vdest.val[1], vpp.val[2]);
- vdest.val[2] = vadd_u8(vdest.val[2], vrp.val[2]);
- vdest.val[3] = vhadd_u8(vdest.val[2], vpp.val[3]);
- vdest.val[3] = vadd_u8(vdest.val[3], vrp.val[3]);
-
- vdest_val = png_ldr(uint32x2x4_t, &vdest);
- vst4_lane_u32(png_ptr(uint32_t,rp), vdest_val, 0);
- }
-}
-
-static uint8x8_t
-paeth(uint8x8_t a, uint8x8_t b, uint8x8_t c)
-{
- uint8x8_t d, e;
- uint16x8_t p1, pa, pb, pc;
-
- p1 = vaddl_u8(a, b); /* a + b */
- pc = vaddl_u8(c, c); /* c * 2 */
- pa = vabdl_u8(b, c); /* pa */
- pb = vabdl_u8(a, c); /* pb */
- pc = vabdq_u16(p1, pc); /* pc */
-
- p1 = vcleq_u16(pa, pb); /* pa <= pb */
- pa = vcleq_u16(pa, pc); /* pa <= pc */
- pb = vcleq_u16(pb, pc); /* pb <= pc */
-
- p1 = vandq_u16(p1, pa); /* pa <= pb && pa <= pc */
-
- d = vmovn_u16(pb);
- e = vmovn_u16(p1);
-
- d = vbsl_u8(d, b, c);
- e = vbsl_u8(e, a, d);
-
- return e;
-}
-
-void
-png_read_filter_row_paeth3_neon(png_row_infop row_info, png_bytep row,
- png_const_bytep prev_row)
-{
- png_bytep rp = row;
- png_const_bytep pp = prev_row;
- png_bytep rp_stop = row + row_info->rowbytes;
-
- uint8x16_t vtmp;
- uint8x8x2_t *vrpt;
- uint8x8x2_t vrp;
- uint8x8_t vlast = vdup_n_u8(0);
- uint8x8x4_t vdest;
- vdest.val[3] = vdup_n_u8(0);
-
- vtmp = vld1q_u8(rp);
- vrpt = png_ptr(uint8x8x2_t,&vtmp);
- vrp = *vrpt;
-
- png_debug(1, "in png_read_filter_row_paeth3_neon");
-
- for (; rp < rp_stop; pp += 12)
- {
- uint8x8x2_t *vppt;
- uint8x8x2_t vpp;
- uint8x8_t vtmp1, vtmp2, vtmp3;
- uint32x2_t *temp_pointer;
-
- vtmp = vld1q_u8(pp);
- vppt = png_ptr(uint8x8x2_t,&vtmp);
- vpp = *vppt;
-
- vdest.val[0] = paeth(vdest.val[3], vpp.val[0], vlast);
- vdest.val[0] = vadd_u8(vdest.val[0], vrp.val[0]);
-
- vtmp1 = vext_u8(vrp.val[0], vrp.val[1], 3);
- vtmp2 = vext_u8(vpp.val[0], vpp.val[1], 3);
- vdest.val[1] = paeth(vdest.val[0], vtmp2, vpp.val[0]);
- vdest.val[1] = vadd_u8(vdest.val[1], vtmp1);
-
- vtmp1 = vext_u8(vrp.val[0], vrp.val[1], 6);
- vtmp3 = vext_u8(vpp.val[0], vpp.val[1], 6);
- vdest.val[2] = paeth(vdest.val[1], vtmp3, vtmp2);
- vdest.val[2] = vadd_u8(vdest.val[2], vtmp1);
-
- vtmp1 = vext_u8(vrp.val[1], vrp.val[1], 1);
- vtmp2 = vext_u8(vpp.val[1], vpp.val[1], 1);
-
- vtmp = vld1q_u8(rp + 12);
- vrpt = png_ptr(uint8x8x2_t,&vtmp);
- vrp = *vrpt;
-
- vdest.val[3] = paeth(vdest.val[2], vtmp2, vtmp3);
- vdest.val[3] = vadd_u8(vdest.val[3], vtmp1);
-
- vlast = vtmp2;
-
- vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[0]), 0);
- rp += 3;
- vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[1]), 0);
- rp += 3;
- vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[2]), 0);
- rp += 3;
- vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[3]), 0);
- rp += 3;
- }
-}
-
-void
-png_read_filter_row_paeth4_neon(png_row_infop row_info, png_bytep row,
- png_const_bytep prev_row)
-{
- png_bytep rp = row;
- png_bytep rp_stop = row + row_info->rowbytes;
- png_const_bytep pp = prev_row;
-
- uint8x8_t vlast = vdup_n_u8(0);
- uint8x8x4_t vdest;
- vdest.val[3] = vdup_n_u8(0);
-
- png_debug(1, "in png_read_filter_row_paeth4_neon");
-
- for (; rp < rp_stop; rp += 16, pp += 16)
- {
- uint32x2x4_t vtmp;
- uint8x8x4_t *vrpt, *vppt;
- uint8x8x4_t vrp, vpp;
- uint32x2x4_t *temp_pointer;
- uint32x2x4_t vdest_val;
-
- vtmp = vld4_u32(png_ptr(uint32_t,rp));
- vrpt = png_ptr(uint8x8x4_t,&vtmp);
- vrp = *vrpt;
- vtmp = vld4_u32(png_ptrc(uint32_t,pp));
- vppt = png_ptr(uint8x8x4_t,&vtmp);
- vpp = *vppt;
-
- vdest.val[0] = paeth(vdest.val[3], vpp.val[0], vlast);
- vdest.val[0] = vadd_u8(vdest.val[0], vrp.val[0]);
- vdest.val[1] = paeth(vdest.val[0], vpp.val[1], vpp.val[0]);
- vdest.val[1] = vadd_u8(vdest.val[1], vrp.val[1]);
- vdest.val[2] = paeth(vdest.val[1], vpp.val[2], vpp.val[1]);
- vdest.val[2] = vadd_u8(vdest.val[2], vrp.val[2]);
- vdest.val[3] = paeth(vdest.val[2], vpp.val[3], vpp.val[2]);
- vdest.val[3] = vadd_u8(vdest.val[3], vrp.val[3]);
-
- vlast = vpp.val[3];
-
- vdest_val = png_ldr(uint32x2x4_t, &vdest);
- vst4_lane_u32(png_ptr(uint32_t,rp), vdest_val, 0);
- }
-}
-
-#endif /* PNG_ARM_NEON_OPT > 0 */
-#endif /* PNG_ARM_NEON_IMPLEMENTATION == 1 (intrinsics) */
-#endif /* READ */
diff --git a/contrib/libs/libpng/arm/palette_neon_intrinsics.c b/contrib/libs/libpng/arm/palette_neon_intrinsics.c
deleted file mode 100644
index 3068e9b6e6..0000000000
--- a/contrib/libs/libpng/arm/palette_neon_intrinsics.c
+++ /dev/null
@@ -1,150 +0,0 @@
-/* palette_neon_intrinsics.c - NEON optimised palette expansion functions
- *
- * Copyright (c) 2018-2019 Cosmin Truta
- * Copyright (c) 2017-2018 Arm Holdings. All rights reserved.
- * Written by Richard Townsend <Richard.Townsend@arm.com>, February 2017.
- *
- * This code is released under the libpng license.
- * For conditions of distribution and use, see the disclaimer
- * and license in png.h
- */
-
-#include "../pngpriv.h"
-
-#if PNG_ARM_NEON_IMPLEMENTATION == 1
-
-#if defined(_MSC_VER) && !defined(__clang__) && defined(_M_ARM64)
-# include <arm64_neon.h>
-#else
-# include <arm_neon.h>
-#endif
-
-/* Build an RGBA8 palette from the separate RGB and alpha palettes. */
-void
-png_riffle_palette_neon(png_structrp png_ptr)
-{
- png_const_colorp palette = png_ptr->palette;
- png_bytep riffled_palette = png_ptr->riffled_palette;
- png_const_bytep trans_alpha = png_ptr->trans_alpha;
- int num_trans = png_ptr->num_trans;
- int i;
-
- /* Initially black, opaque. */
- uint8x16x4_t w = {{
- vdupq_n_u8(0x00),
- vdupq_n_u8(0x00),
- vdupq_n_u8(0x00),
- vdupq_n_u8(0xff),
- }};
-
- png_debug(1, "in png_riffle_palette_neon");
-
- /* First, riffle the RGB colours into an RGBA8 palette.
- * The alpha component is set to opaque for now.
- */
- for (i = 0; i < 256; i += 16)
- {
- uint8x16x3_t v = vld3q_u8((png_const_bytep)(palette + i));
- w.val[0] = v.val[0];
- w.val[1] = v.val[1];
- w.val[2] = v.val[2];
- vst4q_u8(riffled_palette + (i << 2), w);
- }
-
- /* Fix up the missing transparency values. */
- for (i = 0; i < num_trans; i++)
- riffled_palette[(i << 2) + 3] = trans_alpha[i];
-}
-
-/* Expands a palettized row into RGBA8. */
-int
-png_do_expand_palette_rgba8_neon(png_structrp png_ptr, png_row_infop row_info,
- png_const_bytep row, png_bytepp ssp, png_bytepp ddp)
-{
- png_uint_32 row_width = row_info->width;
- const png_uint_32 *riffled_palette =
- png_aligncastconst(png_const_uint_32p, png_ptr->riffled_palette);
- const png_uint_32 pixels_per_chunk = 4;
- png_uint_32 i;
-
- png_debug(1, "in png_do_expand_palette_rgba8_neon");
-
- PNG_UNUSED(row)
- if (row_width < pixels_per_chunk)
- return 0;
-
- /* This function originally gets the last byte of the output row.
- * The NEON part writes forward from a given position, so we have
- * to seek this back by 4 pixels x 4 bytes.
- */
- *ddp = *ddp - ((pixels_per_chunk * sizeof(png_uint_32)) - 1);
-
- for (i = 0; i < row_width; i += pixels_per_chunk)
- {
- uint32x4_t cur;
- png_bytep sp = *ssp - i, dp = *ddp - (i << 2);
- cur = vld1q_dup_u32 (riffled_palette + *(sp - 3));
- cur = vld1q_lane_u32(riffled_palette + *(sp - 2), cur, 1);
- cur = vld1q_lane_u32(riffled_palette + *(sp - 1), cur, 2);
- cur = vld1q_lane_u32(riffled_palette + *(sp - 0), cur, 3);
- vst1q_u32((void *)dp, cur);
- }
- if (i != row_width)
- {
- /* Remove the amount that wasn't processed. */
- i -= pixels_per_chunk;
- }
-
- /* Decrement output pointers. */
- *ssp = *ssp - i;
- *ddp = *ddp - (i << 2);
- return i;
-}
-
-/* Expands a palettized row into RGB8. */
-int
-png_do_expand_palette_rgb8_neon(png_structrp png_ptr, png_row_infop row_info,
- png_const_bytep row, png_bytepp ssp, png_bytepp ddp)
-{
- png_uint_32 row_width = row_info->width;
- png_const_bytep palette = (png_const_bytep)png_ptr->palette;
- const png_uint_32 pixels_per_chunk = 8;
- png_uint_32 i;
-
- png_debug(1, "in png_do_expand_palette_rgb8_neon");
-
- PNG_UNUSED(row)
- if (row_width <= pixels_per_chunk)
- return 0;
-
- /* Seeking this back by 8 pixels x 3 bytes. */
- *ddp = *ddp - ((pixels_per_chunk * sizeof(png_color)) - 1);
-
- for (i = 0; i < row_width; i += pixels_per_chunk)
- {
- uint8x8x3_t cur;
- png_bytep sp = *ssp - i, dp = *ddp - ((i << 1) + i);
- cur = vld3_dup_u8(palette + sizeof(png_color) * (*(sp - 7)));
- cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 6)), cur, 1);
- cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 5)), cur, 2);
- cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 4)), cur, 3);
- cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 3)), cur, 4);
- cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 2)), cur, 5);
- cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 1)), cur, 6);
- cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 0)), cur, 7);
- vst3_u8((void *)dp, cur);
- }
-
- if (i != row_width)
- {
- /* Remove the amount that wasn't processed. */
- i -= pixels_per_chunk;
- }
-
- /* Decrement output pointers. */
- *ssp = *ssp - i;
- *ddp = *ddp - ((i << 1) + i);
- return i;
-}
-
-#endif /* PNG_ARM_NEON_IMPLEMENTATION */
diff --git a/contrib/libs/libpng/include/png.h b/contrib/libs/libpng/include/png.h
deleted file mode 100644
index d3f1ef672a..0000000000
--- a/contrib/libs/libpng/include/png.h
+++ /dev/null
@@ -1 +0,0 @@
-#include "../png.h" /* inclink generated by yamaker */
diff --git a/contrib/libs/libpng/include/pngconf.h b/contrib/libs/libpng/include/pngconf.h
deleted file mode 100644
index 552721dccf..0000000000
--- a/contrib/libs/libpng/include/pngconf.h
+++ /dev/null
@@ -1 +0,0 @@
-#include "../pngconf.h" /* inclink generated by yamaker */
diff --git a/contrib/libs/libpng/include/pnglibconf.h b/contrib/libs/libpng/include/pnglibconf.h
deleted file mode 100644
index 4106523e1c..0000000000
--- a/contrib/libs/libpng/include/pnglibconf.h
+++ /dev/null
@@ -1 +0,0 @@
-#include "../pnglibconf.h" /* inclink generated by yamaker */
diff --git a/contrib/libs/libpng/include/ya.make b/contrib/libs/libpng/include/ya.make
deleted file mode 100644
index 1b0f8afad2..0000000000
--- a/contrib/libs/libpng/include/ya.make
+++ /dev/null
@@ -1,17 +0,0 @@
-LIBRARY()
-
-WITHOUT_LICENSE_TEXTS()
-
-VERSION(Service-proxy-version)
-
-LICENSE(libpng-2.0)
-
-PEERDIR(
- contrib/libs/libpng
-)
-
-ADDINCL(
- GLOBAL contrib/libs/libpng/include
-)
-
-END()
diff --git a/contrib/libs/libpng/intel/filter_sse2_intrinsics.c b/contrib/libs/libpng/intel/filter_sse2_intrinsics.c
deleted file mode 100644
index 2993f650b7..0000000000
--- a/contrib/libs/libpng/intel/filter_sse2_intrinsics.c
+++ /dev/null
@@ -1,390 +0,0 @@
-/* filter_sse2_intrinsics.c - SSE2 optimized filter functions
- *
- * Copyright (c) 2018 Cosmin Truta
- * Copyright (c) 2016-2017 Glenn Randers-Pehrson
- * Written by Mike Klein and Matt Sarett
- * Derived from arm/filter_neon_intrinsics.c
- *
- * This code is released under the libpng license.
- * For conditions of distribution and use, see the disclaimer
- * and license in png.h
- */
-
-#include "../pngpriv.h"
-
-#ifdef PNG_READ_SUPPORTED
-
-#if PNG_INTEL_SSE_IMPLEMENTATION > 0
-
-#include <immintrin.h>
-
-/* Functions in this file look at most 3 pixels (a,b,c) to predict the 4th (d).
- * They're positioned like this:
- * prev: c b
- * row: a d
- * The Sub filter predicts d=a, Avg d=(a+b)/2, and Paeth predicts d to be
- * whichever of a, b, or c is closest to p=a+b-c.
- */
-
-static __m128i load4(const void* p) {
- int tmp;
- memcpy(&tmp, p, sizeof(tmp));
- return _mm_cvtsi32_si128(tmp);
-}
-
-static void store4(void* p, __m128i v) {
- int tmp = _mm_cvtsi128_si32(v);
- memcpy(p, &tmp, sizeof(int));
-}
-
-static __m128i load3(const void* p) {
- png_uint_32 tmp = 0;
- memcpy(&tmp, p, 3);
- return _mm_cvtsi32_si128(tmp);
-}
-
-static void store3(void* p, __m128i v) {
- int tmp = _mm_cvtsi128_si32(v);
- memcpy(p, &tmp, 3);
-}
-
-void png_read_filter_row_sub3_sse2(png_row_infop row_info, png_bytep row,
- png_const_bytep prev)
-{
- /* The Sub filter predicts each pixel as the previous pixel, a.
- * There is no pixel to the left of the first pixel. It's encoded directly.
- * That works with our main loop if we just say that left pixel was zero.
- */
- size_t rb;
-
- __m128i a, d = _mm_setzero_si128();
-
- png_debug(1, "in png_read_filter_row_sub3_sse2");
-
- rb = row_info->rowbytes;
- while (rb >= 4) {
- a = d; d = load4(row);
- d = _mm_add_epi8(d, a);
- store3(row, d);
-
- row += 3;
- rb -= 3;
- }
- if (rb > 0) {
- a = d; d = load3(row);
- d = _mm_add_epi8(d, a);
- store3(row, d);
-
- row += 3;
- rb -= 3;
- }
- PNG_UNUSED(prev)
-}
-
-void png_read_filter_row_sub4_sse2(png_row_infop row_info, png_bytep row,
- png_const_bytep prev)
-{
- /* The Sub filter predicts each pixel as the previous pixel, a.
- * There is no pixel to the left of the first pixel. It's encoded directly.
- * That works with our main loop if we just say that left pixel was zero.
- */
- size_t rb;
-
- __m128i a, d = _mm_setzero_si128();
-
- png_debug(1, "in png_read_filter_row_sub4_sse2");
-
- rb = row_info->rowbytes+4;
- while (rb > 4) {
- a = d; d = load4(row);
- d = _mm_add_epi8(d, a);
- store4(row, d);
-
- row += 4;
- rb -= 4;
- }
- PNG_UNUSED(prev)
-}
-
-void png_read_filter_row_avg3_sse2(png_row_infop row_info, png_bytep row,
- png_const_bytep prev)
-{
- /* The Avg filter predicts each pixel as the (truncated) average of a and b.
- * There's no pixel to the left of the first pixel. Luckily, it's
- * predicted to be half of the pixel above it. So again, this works
- * perfectly with our loop if we make sure a starts at zero.
- */
-
- size_t rb;
-
- const __m128i zero = _mm_setzero_si128();
-
- __m128i b;
- __m128i a, d = zero;
-
- png_debug(1, "in png_read_filter_row_avg3_sse2");
- rb = row_info->rowbytes;
- while (rb >= 4) {
- __m128i avg;
- b = load4(prev);
- a = d; d = load4(row );
-
- /* PNG requires a truncating average, so we can't just use _mm_avg_epu8 */
- avg = _mm_avg_epu8(a,b);
- /* ...but we can fix it up by subtracting off 1 if it rounded up. */
- avg = _mm_sub_epi8(avg, _mm_and_si128(_mm_xor_si128(a,b),
- _mm_set1_epi8(1)));
- d = _mm_add_epi8(d, avg);
- store3(row, d);
-
- prev += 3;
- row += 3;
- rb -= 3;
- }
- if (rb > 0) {
- __m128i avg;
- b = load3(prev);
- a = d; d = load3(row );
-
- /* PNG requires a truncating average, so we can't just use _mm_avg_epu8 */
- avg = _mm_avg_epu8(a,b);
- /* ...but we can fix it up by subtracting off 1 if it rounded up. */
- avg = _mm_sub_epi8(avg, _mm_and_si128(_mm_xor_si128(a,b),
- _mm_set1_epi8(1)));
-
- d = _mm_add_epi8(d, avg);
- store3(row, d);
-
- prev += 3;
- row += 3;
- rb -= 3;
- }
-}
-
-void png_read_filter_row_avg4_sse2(png_row_infop row_info, png_bytep row,
- png_const_bytep prev)
-{
- /* The Avg filter predicts each pixel as the (truncated) average of a and b.
- * There's no pixel to the left of the first pixel. Luckily, it's
- * predicted to be half of the pixel above it. So again, this works
- * perfectly with our loop if we make sure a starts at zero.
- */
- size_t rb;
- const __m128i zero = _mm_setzero_si128();
- __m128i b;
- __m128i a, d = zero;
-
- png_debug(1, "in png_read_filter_row_avg4_sse2");
-
- rb = row_info->rowbytes+4;
- while (rb > 4) {
- __m128i avg;
- b = load4(prev);
- a = d; d = load4(row );
-
- /* PNG requires a truncating average, so we can't just use _mm_avg_epu8 */
- avg = _mm_avg_epu8(a,b);
- /* ...but we can fix it up by subtracting off 1 if it rounded up. */
- avg = _mm_sub_epi8(avg, _mm_and_si128(_mm_xor_si128(a,b),
- _mm_set1_epi8(1)));
-
- d = _mm_add_epi8(d, avg);
- store4(row, d);
-
- prev += 4;
- row += 4;
- rb -= 4;
- }
-}
-
-/* Returns |x| for 16-bit lanes. */
-static __m128i abs_i16(__m128i x) {
-#if PNG_INTEL_SSE_IMPLEMENTATION >= 2
- return _mm_abs_epi16(x);
-#else
- /* Read this all as, return x<0 ? -x : x.
- * To negate two's complement, you flip all the bits then add 1.
- */
- __m128i is_negative = _mm_cmplt_epi16(x, _mm_setzero_si128());
-
- /* Flip negative lanes. */
- x = _mm_xor_si128(x, is_negative);
-
- /* +1 to negative lanes, else +0. */
- x = _mm_sub_epi16(x, is_negative);
- return x;
-#endif
-}
-
-/* Bytewise c ? t : e. */
-static __m128i if_then_else(__m128i c, __m128i t, __m128i e) {
-#if PNG_INTEL_SSE_IMPLEMENTATION >= 3
- return _mm_blendv_epi8(e,t,c);
-#else
- return _mm_or_si128(_mm_and_si128(c, t), _mm_andnot_si128(c, e));
-#endif
-}
-
-void png_read_filter_row_paeth3_sse2(png_row_infop row_info, png_bytep row,
- png_const_bytep prev)
-{
- /* Paeth tries to predict pixel d using the pixel to the left of it, a,
- * and two pixels from the previous row, b and c:
- * prev: c b
- * row: a d
- * The Paeth function predicts d to be whichever of a, b, or c is nearest to
- * p=a+b-c.
- *
- * The first pixel has no left context, and so uses an Up filter, p = b.
- * This works naturally with our main loop's p = a+b-c if we force a and c
- * to zero.
- * Here we zero b and d, which become c and a respectively at the start of
- * the loop.
- */
- size_t rb;
- const __m128i zero = _mm_setzero_si128();
- __m128i c, b = zero,
- a, d = zero;
-
- png_debug(1, "in png_read_filter_row_paeth3_sse2");
-
- rb = row_info->rowbytes;
- while (rb >= 4) {
- /* It's easiest to do this math (particularly, deal with pc) with 16-bit
- * intermediates.
- */
- __m128i pa,pb,pc,smallest,nearest;
- c = b; b = _mm_unpacklo_epi8(load4(prev), zero);
- a = d; d = _mm_unpacklo_epi8(load4(row ), zero);
-
- /* (p-a) == (a+b-c - a) == (b-c) */
-
- pa = _mm_sub_epi16(b,c);
-
- /* (p-b) == (a+b-c - b) == (a-c) */
- pb = _mm_sub_epi16(a,c);
-
- /* (p-c) == (a+b-c - c) == (a+b-c-c) == (b-c)+(a-c) */
- pc = _mm_add_epi16(pa,pb);
-
- pa = abs_i16(pa); /* |p-a| */
- pb = abs_i16(pb); /* |p-b| */
- pc = abs_i16(pc); /* |p-c| */
-
- smallest = _mm_min_epi16(pc, _mm_min_epi16(pa, pb));
-
- /* Paeth breaks ties favoring a over b over c. */
- nearest = if_then_else(_mm_cmpeq_epi16(smallest, pa), a,
- if_then_else(_mm_cmpeq_epi16(smallest, pb), b,
- c));
-
- /* Note `_epi8`: we need addition to wrap modulo 255. */
- d = _mm_add_epi8(d, nearest);
- store3(row, _mm_packus_epi16(d,d));
-
- prev += 3;
- row += 3;
- rb -= 3;
- }
- if (rb > 0) {
- /* It's easiest to do this math (particularly, deal with pc) with 16-bit
- * intermediates.
- */
- __m128i pa,pb,pc,smallest,nearest;
- c = b; b = _mm_unpacklo_epi8(load3(prev), zero);
- a = d; d = _mm_unpacklo_epi8(load3(row ), zero);
-
- /* (p-a) == (a+b-c - a) == (b-c) */
- pa = _mm_sub_epi16(b,c);
-
- /* (p-b) == (a+b-c - b) == (a-c) */
- pb = _mm_sub_epi16(a,c);
-
- /* (p-c) == (a+b-c - c) == (a+b-c-c) == (b-c)+(a-c) */
- pc = _mm_add_epi16(pa,pb);
-
- pa = abs_i16(pa); /* |p-a| */
- pb = abs_i16(pb); /* |p-b| */
- pc = abs_i16(pc); /* |p-c| */
-
- smallest = _mm_min_epi16(pc, _mm_min_epi16(pa, pb));
-
- /* Paeth breaks ties favoring a over b over c. */
- nearest = if_then_else(_mm_cmpeq_epi16(smallest, pa), a,
- if_then_else(_mm_cmpeq_epi16(smallest, pb), b,
- c));
-
- /* Note `_epi8`: we need addition to wrap modulo 255. */
- d = _mm_add_epi8(d, nearest);
- store3(row, _mm_packus_epi16(d,d));
-
- prev += 3;
- row += 3;
- rb -= 3;
- }
-}
-
-void png_read_filter_row_paeth4_sse2(png_row_infop row_info, png_bytep row,
- png_const_bytep prev)
-{
- /* Paeth tries to predict pixel d using the pixel to the left of it, a,
- * and two pixels from the previous row, b and c:
- * prev: c b
- * row: a d
- * The Paeth function predicts d to be whichever of a, b, or c is nearest to
- * p=a+b-c.
- *
- * The first pixel has no left context, and so uses an Up filter, p = b.
- * This works naturally with our main loop's p = a+b-c if we force a and c
- * to zero.
- * Here we zero b and d, which become c and a respectively at the start of
- * the loop.
- */
- size_t rb;
- const __m128i zero = _mm_setzero_si128();
- __m128i pa,pb,pc,smallest,nearest;
- __m128i c, b = zero,
- a, d = zero;
-
- png_debug(1, "in png_read_filter_row_paeth4_sse2");
-
- rb = row_info->rowbytes+4;
- while (rb > 4) {
- /* It's easiest to do this math (particularly, deal with pc) with 16-bit
- * intermediates.
- */
- c = b; b = _mm_unpacklo_epi8(load4(prev), zero);
- a = d; d = _mm_unpacklo_epi8(load4(row ), zero);
-
- /* (p-a) == (a+b-c - a) == (b-c) */
- pa = _mm_sub_epi16(b,c);
-
- /* (p-b) == (a+b-c - b) == (a-c) */
- pb = _mm_sub_epi16(a,c);
-
- /* (p-c) == (a+b-c - c) == (a+b-c-c) == (b-c)+(a-c) */
- pc = _mm_add_epi16(pa,pb);
-
- pa = abs_i16(pa); /* |p-a| */
- pb = abs_i16(pb); /* |p-b| */
- pc = abs_i16(pc); /* |p-c| */
-
- smallest = _mm_min_epi16(pc, _mm_min_epi16(pa, pb));
-
- /* Paeth breaks ties favoring a over b over c. */
- nearest = if_then_else(_mm_cmpeq_epi16(smallest, pa), a,
- if_then_else(_mm_cmpeq_epi16(smallest, pb), b,
- c));
-
- /* Note `_epi8`: we need addition to wrap modulo 255. */
- d = _mm_add_epi8(d, nearest);
- store4(row, _mm_packus_epi16(d,d));
-
- prev += 4;
- row += 4;
- rb -= 4;
- }
-}
-
-#endif /* PNG_INTEL_SSE_IMPLEMENTATION > 0 */
-#endif /* READ */
diff --git a/contrib/libs/libpng/intel/intel_init.c b/contrib/libs/libpng/intel/intel_init.c
deleted file mode 100644
index 9e4610d25b..0000000000
--- a/contrib/libs/libpng/intel/intel_init.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/* intel_init.c - SSE2 optimized filter functions
- *
- * Copyright (c) 2018 Cosmin Truta
- * Copyright (c) 2016-2017 Glenn Randers-Pehrson
- * Written by Mike Klein and Matt Sarett, Google, Inc.
- * Derived from arm/arm_init.c
- *
- * This code is released under the libpng license.
- * For conditions of distribution and use, see the disclaimer
- * and license in png.h
- */
-
-#include "../pngpriv.h"
-
-#ifdef PNG_READ_SUPPORTED
-#if PNG_INTEL_SSE_IMPLEMENTATION > 0
-
-void
-png_init_filter_functions_sse2(png_structp pp, unsigned int bpp)
-{
- /* The techniques used to implement each of these filters in SSE operate on
- * one pixel at a time.
- * So they generally speed up 3bpp images about 3x, 4bpp images about 4x.
- * They can scale up to 6 and 8 bpp images and down to 2 bpp images,
- * but they'd not likely have any benefit for 1bpp images.
- * Most of these can be implemented using only MMX and 64-bit registers,
- * but they end up a bit slower than using the equally-ubiquitous SSE2.
- */
- png_debug(1, "in png_init_filter_functions_sse2");
- if (bpp == 3)
- {
- pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub3_sse2;
- pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg3_sse2;
- pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =
- png_read_filter_row_paeth3_sse2;
- }
- else if (bpp == 4)
- {
- pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub4_sse2;
- pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg4_sse2;
- pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =
- png_read_filter_row_paeth4_sse2;
- }
-
- /* No need optimize PNG_FILTER_VALUE_UP. The compiler should
- * autovectorize.
- */
-}
-
-#endif /* PNG_INTEL_SSE_IMPLEMENTATION > 0 */
-#endif /* PNG_READ_SUPPORTED */
diff --git a/contrib/libs/libpng/mips/filter_mmi_inline_assembly.c b/contrib/libs/libpng/mips/filter_mmi_inline_assembly.c
deleted file mode 100644
index b330a46538..0000000000
--- a/contrib/libs/libpng/mips/filter_mmi_inline_assembly.c
+++ /dev/null
@@ -1,525 +0,0 @@
-/* filter_mmi_intrinsics.c - MMI optimized filter functions
- *
- * Copyright (c) 2024 Cosmin Truta
- * Written by zhanglixia and guxiwei, 2023
- *
- * This code is released under the libpng license.
- * For conditions of distribution and use, see the disclaimer
- * and license in png.h
- */
-
-#include "../pngpriv.h"
-
-#ifdef PNG_READ_SUPPORTED
-
-#if PNG_MIPS_MMI_IMPLEMENTATION == 2 /* Inline Assembly */
-
-/* Functions in this file look at most 3 pixels (a,b,c) to predict the 4th (d).
- * They're positioned like this:
- * prev: c b
- * row: a d
- * The Sub filter predicts d=a, Avg d=(a+b)/2, and Paeth predicts d to be
- * whichever of a, b, or c is closest to p=a+b-c.
- */
-
-void png_read_filter_row_up_mmi(png_row_infop row_info, png_bytep row,
- png_const_bytep prev_row)
-{
- int istop = row_info->rowbytes;
- double rp,pp;
- __asm__ volatile (
- "1: \n\t"
- "ldc1 %[rp], 0x00(%[row]) \n\t"
- "ldc1 %[pp], 0x00(%[prev_row]) \n\t"
- "paddb %[rp], %[rp], %[pp] \n\t"
- "sdc1 %[rp], 0x00(%[row]) \n\t"
-
- "daddiu %[row], %[row], 0x08 \n\t"
- "daddiu %[prev_row], %[prev_row], 0x08 \n\t"
- "daddiu %[istop], %[istop], -0x08 \n\t"
- "bgtz %[istop], 1b \n\t"
- : [rp]"=&f"(rp), [pp]"=&f"(pp)
- : [row]"r"(row), [prev_row]"r"(prev_row),
- [istop]"r"(istop)
- : "memory"
- );
-}
-
-void png_read_filter_row_sub3_mmi(png_row_infop row_info, png_bytep row,
- png_const_bytep prev)
-{
- int istop = row_info->rowbytes;
- double rp, pp, dest;
- double eight, sixteen, twenty_four, forty_eight;
- double tmp0;
- double ftmp[2];
-
- __asm__ volatile (
- "li %[tmp0], 0x08 \n\t"
- "dmtc1 %[tmp0], %[eight] \n\t"
- "li %[tmp0], 0x10 \n\t"
- "dmtc1 %[tmp0], %[sixteen] \n\t"
- "li %[tmp0], 0x18 \n\t"
- "dmtc1 %[tmp0], %[twenty_four] \n\t"
- "li %[tmp0], 0x30 \n\t"
- "dmtc1 %[tmp0], %[forty_eight] \n\t"
- "xor %[dest], %[dest], %[dest] \n\t"
-
- "1: \n\t"
- "gsldrc1 %[rp], 0x00(%[row]) \n\t"
- "gsldlc1 %[rp], 0x07(%[row]) \n\t"
- "gsldrc1 %[pp], 0x08(%[row]) \n\t"
- "gsldlc1 %[pp], 0x0f(%[row]) \n\t"
-
- "paddb %[ftmp0], %[dest], %[rp] \n\t"
- "swc1 %[ftmp0], 0x00(%[row]) \n\t"
-
- "dsrl %[ftmp1], %[rp], %[twenty_four] \n\t"
- "paddb %[dest], %[ftmp1], %[ftmp0] \n\t"
- "gsswrc1 %[dest], 0x03(%[row]) \n\t"
- "gsswlc1 %[dest], 0x06(%[row]) \n\t"
-
- "dsrl %[ftmp0], %[rp], %[forty_eight] \n\t"
- "dsll %[ftmp1], %[pp], %[sixteen] \n\t"
- "or %[ftmp0], %[ftmp0], %[ftmp1] \n\t"
- "paddb %[dest], %[dest], %[ftmp0] \n\t"
- "gsswrc1 %[dest], 0x06(%[row]) \n\t"
- "gsswlc1 %[dest], 0x09(%[row]) \n\t"
-
- "dsrl %[ftmp0], %[pp], %[eight] \n\t"
- "paddb %[dest], %[dest], %[ftmp0] \n\t"
- "gsswrc1 %[dest], 0x09(%[row]) \n\t"
- "daddiu %[row], %[row], 0x0c \n\t"
- "daddiu %[istop], %[istop], -0x0c \n\t"
- "bgtz %[istop], 1b \n\t"
- : [rp]"=&f"(rp), [pp]"=&f"(pp), [dest]"=&f"(dest),
- [tmp0]"=&r"(tmp0), [ftmp0]"=&f"(ftmp[0]),
- [ftmp1]"=&f"(ftmp[1]), [eight]"=&f"(eight),
- [sixteen]"=&f"(sixteen), [twenty_four]"=&f"(twenty_four),
- [forty_eight]"=&f"(forty_eight)
- : [row]"r"(row), [istop]"r"(istop)
- : "memory"
- );
-
- PNG_UNUSED(prev)
-}
-
-void png_read_filter_row_sub4_mmi(png_row_infop row_info, png_bytep row,
- png_const_bytep prev)
-{
- /* The Sub filter predicts each pixel as the previous pixel, a.
- * There is no pixel to the left of the first pixel. It's encoded directly.
- * That works with our main loop if we just say that left pixel was zero.
- */
- int istop = row_info->rowbytes;
- double rp,pp;
-
- __asm__ volatile (
- "1: \n\t"
- "lwc1 %[pp], 0x00(%[row]) \n\t"
- "lwc1 %[rp], 0x04(%[row]) \n\t"
- "paddb %[rp], %[rp], %[pp] \n\t"
- "swc1 %[rp], 0x04(%[row]) \n\t"
-
- "daddiu %[row], %[row], 0x04 \n\t"
- "daddiu %[istop], %[istop], -0x04 \n\t"
- "bgtz %[istop], 1b \n\t"
- : [rp]"=&f"(rp), [pp]"=&f"(pp)
- : [row]"r"(row), [istop]"r"(istop)
- : "memory"
- );
-
- PNG_UNUSED(prev)
-}
-
-void png_read_filter_row_avg3_mmi(png_row_infop row_info, png_bytep row,
- png_const_bytep prev)
-{
- int istop = row_info->rowbytes;
- double rp, pp, rp1, pp1;
- double tmp0;
- double ftmp[3];
- double one, dest;
- double eight, sixteen, twenty_four, forty_eight;
-
- __asm__ volatile (
- "li %[tmp0], 0x08 \n\t"
- "dmtc1 %[tmp0], %[eight] \n\t"
- "li %[tmp0], 0x10 \n\t"
- "dmtc1 %[tmp0], %[sixteen] \n\t"
- "li %[tmp0], 0x18 \n\t"
- "dmtc1 %[tmp0], %[twenty_four] \n\t"
- "li %[tmp0], 0x30 \n\t"
- "dmtc1 %[tmp0], %[forty_eight] \n\t"
- "xor %[dest], %[dest], %[dest] \n\t"
-
- "li %[tmp0], 0x01 \n\t"
- "ins %[tmp0], %[tmp0], 8, 8 \n\t"
- "dmtc1 %[tmp0], %[one] \n\t"
- "pshufh %[one], %[one], %[dest] \n\t"
-
- "1: \n\t"
- "gsldrc1 %[rp], 0x00(%[row]) \n\t"
- "gsldlc1 %[rp], 0x07(%[row]) \n\t"
- "gsldrc1 %[pp], 0x00(%[prev]) \n\t"
- "gsldlc1 %[pp], 0x07(%[prev]) \n\t"
- "gsldrc1 %[rp1], 0x08(%[row]) \n\t"
- "gsldlc1 %[rp1], 0x0f(%[row]) \n\t"
- "gsldrc1 %[pp1], 0x08(%[prev]) \n\t"
- "gsldlc1 %[pp1], 0x0f(%[prev]) \n\t"
-
- "xor %[ftmp0], %[pp], %[dest] \n\t"
- "pavgb %[ftmp1], %[pp], %[dest] \n\t"
- "and %[ftmp0], %[ftmp0], %[one] \n\t"
- "psubb %[ftmp1], %[ftmp1], %[ftmp0] \n\t"
- "paddb %[dest], %[rp], %[ftmp1] \n\t"
- "swc1 %[dest], 0x00(%[row]) \n\t"
-
- "dsrl %[ftmp0], %[rp], %[twenty_four] \n\t"
- "dsrl %[ftmp1], %[pp], %[twenty_four] \n\t"
-
- "xor %[ftmp2], %[ftmp1], %[dest] \n\t"
- "pavgb %[ftmp1], %[ftmp1], %[dest] \n\t"
- "and %[ftmp2], %[ftmp2], %[one] \n\t"
- "psubb %[ftmp1], %[ftmp1], %[ftmp2] \n\t"
- "paddb %[dest], %[ftmp0], %[ftmp1] \n\t"
- "gsswrc1 %[dest], 0x03(%[row]) \n\t"
- "gsswlc1 %[dest], 0x06(%[row]) \n\t"
-
- "dsrl %[ftmp0], %[rp], %[forty_eight] \n\t"
- "dsll %[ftmp1], %[rp1], %[sixteen] \n\t"
- "or %[ftmp0], %[ftmp0], %[ftmp1] \n\t"
- "dsrl %[ftmp2], %[pp], %[forty_eight] \n\t"
- "dsll %[ftmp1], %[pp1], %[sixteen] \n\t"
- "or %[ftmp1], %[ftmp2], %[ftmp1] \n\t"
-
- "xor %[ftmp2], %[ftmp1], %[dest] \n\t"
- "pavgb %[ftmp1], %[ftmp1], %[dest] \n\t"
- "and %[ftmp2], %[ftmp2], %[one] \n\t"
- "psubb %[ftmp1], %[ftmp1], %[ftmp2] \n\t"
- "paddb %[dest], %[ftmp0], %[ftmp1] \n\t"
- "gsswrc1 %[dest], 0x06(%[row]) \n\t"
- "gsswlc1 %[dest], 0x09(%[row]) \n\t"
-
- "dsrl %[ftmp0], %[rp1], %[eight] \n\t"
- "dsrl %[ftmp1], %[pp1], %[eight] \n\t"
-
- "xor %[ftmp2], %[ftmp1], %[dest] \n\t"
- "pavgb %[ftmp1], %[ftmp1], %[dest] \n\t"
- "and %[ftmp2], %[ftmp2], %[one] \n\t"
- "psubb %[ftmp1], %[ftmp1], %[ftmp2] \n\t"
- "paddb %[dest], %[ftmp0], %[ftmp1] \n\t"
- "gsswrc1 %[dest], 0x09(%[row]) \n\t"
- "daddiu %[row], %[row], 0x0c \n\t"
- "daddiu %[prev], %[prev], 0x0c \n\t"
- "daddiu %[istop], %[istop], -0x0c \n\t"
- "bgtz %[istop], 1b \n\t"
- : [rp]"=&f"(rp), [pp]"=&f"(pp), [rp1]"=&f"(rp1),
- [pp1]"=&f"(pp1), [tmp0]"=&r"(tmp0), [ftmp0]"=&f"(ftmp[0]),
- [ftmp1]"=&f"(ftmp[1]), [ftmp2]"=&f"(ftmp[2]), [one]"=&f"(one),
- [dest]"=&f"(dest), [eight]"=&f"(eight), [sixteen]"=&f"(sixteen),
- [twenty_four]"=&f"(twenty_four), [forty_eight]"=&f"(forty_eight)
- : [row]"r"(row), [prev]"r"(prev), [istop]"r"(istop)
- : "memory"
- );
-}
-
-void png_read_filter_row_avg4_mmi(png_row_infop row_info, png_bytep row,
- png_const_bytep prev)
-{
- int istop = row_info->rowbytes;
- double rp,pp;
- double dest;
- double ftmp[2];
- double tmp;
-
- __asm__ volatile (
- "xor %[dest], %[dest], %[dest] \n\t"
- "li %[tmp], 0x01 \n\t"
- "ins %[tmp], %[tmp], 8, 8 \n\t"
- "dmtc1 %[tmp], %[ftmp1] \n\t"
- "pshufh %[ftmp1], %[ftmp1], %[dest] \n\t"
-
- "1: \n\t"
- "lwc1 %[rp], 0x00(%[row]) \n\t"
- "lwc1 %[pp], 0x00(%[prev]) \n\t"
- "xor %[ftmp0], %[pp], %[dest] \n\t"
- "pavgb %[pp], %[pp], %[dest] \n\t"
- "and %[ftmp0], %[ftmp0], %[ftmp1] \n\t"
- "psubb %[pp], %[pp], %[ftmp0] \n\t"
- "paddb %[dest], %[rp], %[pp] \n\t"
- "swc1 %[dest], 0x00(%[row]) \n\t"
- "daddiu %[row], %[row], 0x04 \n\t"
- "daddiu %[prev], %[prev], 0x04 \n\t"
- "daddiu %[istop], %[istop], -0x04 \n\t"
- "bgtz %[istop], 1b \n\t"
- : [rp]"=&f"(rp), [pp]"=&f"(pp), [ftmp0]"=&f"(ftmp[0]),
- [ftmp1]"=&f"(ftmp[1]), [dest]"=&f"(dest), [tmp]"=&r"(tmp)
- : [row]"r"(row), [prev]"r"(prev), [istop]"r"(istop)
- : "memory"
- );
-}
-
-void png_read_filter_row_paeth3_mmi(png_row_infop row_info, png_bytep row,
- png_const_bytep prev)
-{
- /* Paeth tries to predict pixel d using the pixel to the left of it, a,
- * and two pixels from the previous row, b and c:
- * prev: c b
- * row: a d
- * The Paeth function predicts d to be whichever of a, b, or c is nearest to
- * p=a+b-c.
- *
- * The first pixel has no left context, and so uses an Up filter, p = b.
- * This works naturally with our main loop's p = a+b-c if we force a and c
- * to zero.
- * Here we zero b and d, which become c and a respectively at the start of
- * the loop.
- */
- int istop = row_info->rowbytes;
- double rp, pp, rp1, pp1, zero;
- double a, b, c, d, pa, pb, pc;
- double tmp0;
- double ftmp[3];
- double eight, sixteen, twenty_four, forty_eight;
-
- __asm__ volatile (
- "xor %[a], %[a], %[a] \n\t"
- "xor %[c], %[c], %[c] \n\t"
- "xor %[zero], %[zero], %[zero] \n\t"
- "li %[tmp0], 0x08 \n\t"
- "dmtc1 %[tmp0], %[eight] \n\t"
- "li %[tmp0], 0x10 \n\t"
- "dmtc1 %[tmp0], %[sixteen] \n\t"
- "li %[tmp0], 0x18 \n\t"
- "dmtc1 %[tmp0], %[twenty_four] \n\t"
- "li %[tmp0], 0x30 \n\t"
- "dmtc1 %[tmp0], %[forty_eight] \n\t"
-
- "1: \n\t"
- "gsldrc1 %[rp], 0x00(%[row]) \n\t"
- "gsldlc1 %[rp], 0x07(%[row]) \n\t"
- "gsldrc1 %[pp], 0x00(%[prev]) \n\t"
- "gsldlc1 %[pp], 0x07(%[prev]) \n\t"
- "gsldrc1 %[rp1], 0x08(%[row]) \n\t"
- "gsldlc1 %[rp1], 0x0f(%[row]) \n\t"
- "gsldrc1 %[pp1], 0x08(%[prev]) \n\t"
- "gsldlc1 %[pp1], 0x0f(%[prev]) \n\t"
-
- "punpcklbh %[b], %[pp], %[zero] \n\t"
- "punpcklbh %[d], %[rp], %[zero] \n\t"
- "packushb %[ftmp0], %[c], %[c] \n\t"
- "packushb %[ftmp1], %[a], %[a] \n\t"
- "pasubub %[pa], %[pp], %[ftmp0] \n\t"
- "pasubub %[pb], %[ftmp1], %[ftmp0] \n\t"
- "psubh %[ftmp0], %[b], %[c] \n\t"
- "psubh %[ftmp1], %[a], %[c] \n\t"
- "paddh %[pc], %[ftmp0], %[ftmp1] \n\t"
- "pcmpgth %[ftmp0], %[zero], %[pc] \n\t"
- "xor %[pc], %[pc], %[ftmp0] \n\t"
- "psubh %[pc], %[pc], %[ftmp0] \n\t"
- "punpcklbh %[pa], %[pa], %[zero] \n\t"
- "punpcklbh %[pb], %[pb], %[zero] \n\t"
- "pcmpgth %[ftmp0], %[pa], %[pb] \n\t"
- "and %[ftmp1], %[b], %[ftmp0] \n\t"
- "pandn %[a], %[ftmp0], %[a] \n\t"
- "or %[a], %[a], %[ftmp1] \n\t"
- "pminsh %[pa], %[pa], %[pb] \n\t"
- "pcmpgth %[ftmp0], %[pa], %[pc] \n\t"
- "and %[ftmp1], %[c], %[ftmp0] \n\t"
- "pandn %[a], %[ftmp0], %[a] \n\t"
- "or %[a], %[a], %[ftmp1] \n\t"
- "paddb %[a], %[a], %[d] \n\t"
- "packushb %[d], %[a], %[a] \n\t"
- "punpcklbh %[c], %[pp], %[zero] \n\t"
- "swc1 %[d], 0x00(%[row]) \n\t"
-
- "dsrl %[ftmp0], %[rp], %[twenty_four] \n\t"
- "dsrl %[ftmp2], %[pp], %[twenty_four] \n\t"
-
- "punpcklbh %[b], %[ftmp2], %[zero] \n\t"
- "punpcklbh %[d], %[ftmp0], %[zero] \n\t"
- "packushb %[ftmp0], %[c], %[c] \n\t"
- "packushb %[ftmp1], %[a], %[a] \n\t"
- "pasubub %[pa], %[ftmp2], %[ftmp0] \n\t"
- "pasubub %[pb], %[ftmp1], %[ftmp0] \n\t"
- "psubh %[ftmp0], %[b], %[c] \n\t"
- "psubh %[ftmp1], %[a], %[c] \n\t"
- "paddh %[pc], %[ftmp0], %[ftmp1] \n\t"
- "pcmpgth %[ftmp0], %[zero], %[pc] \n\t"
- "xor %[pc], %[pc], %[ftmp0] \n\t"
- "psubh %[pc], %[pc], %[ftmp0] \n\t"
- "punpcklbh %[pa], %[pa], %[zero] \n\t"
- "punpcklbh %[pb], %[pb], %[zero] \n\t"
- "pcmpgth %[ftmp0], %[pa], %[pb] \n\t"
- "and %[ftmp1], %[b], %[ftmp0] \n\t"
- "pandn %[a], %[ftmp0], %[a] \n\t"
- "or %[a], %[a], %[ftmp1] \n\t"
- "pminsh %[pa], %[pa], %[pb] \n\t"
- "pcmpgth %[ftmp0], %[pa], %[pc] \n\t"
- "and %[ftmp1], %[c], %[ftmp0] \n\t"
- "pandn %[a], %[ftmp0], %[a] \n\t"
- "or %[a], %[a], %[ftmp1] \n\t"
- "paddb %[a], %[a], %[d] \n\t"
- "packushb %[d], %[a], %[a] \n\t"
- "punpcklbh %[c], %[ftmp2], %[zero] \n\t"
- "gsswrc1 %[d], 0x03(%[row]) \n\t"
- "gsswlc1 %[d], 0x06(%[row]) \n\t"
-
- "dsrl %[ftmp0], %[rp], %[forty_eight] \n\t"
- "dsll %[ftmp1], %[rp1], %[sixteen] \n\t"
- "or %[ftmp0], %[ftmp0], %[ftmp1] \n\t"
- "dsrl %[ftmp2], %[pp], %[forty_eight] \n\t"
- "dsll %[ftmp1], %[pp1], %[sixteen] \n\t"
- "or %[ftmp2], %[ftmp2], %[ftmp1] \n\t"
-
- "punpcklbh %[b], %[ftmp2], %[zero] \n\t"
- "punpcklbh %[d], %[ftmp0], %[zero] \n\t"
- "packushb %[ftmp0], %[c], %[c] \n\t"
- "packushb %[ftmp1], %[a], %[a] \n\t"
- "pasubub %[pa], %[ftmp2], %[ftmp0] \n\t"
- "pasubub %[pb], %[ftmp1], %[ftmp0] \n\t"
- "psubh %[ftmp0], %[b], %[c] \n\t"
- "psubh %[ftmp1], %[a], %[c] \n\t"
- "paddh %[pc], %[ftmp0], %[ftmp1] \n\t"
- "pcmpgth %[ftmp0], %[zero], %[pc] \n\t"
- "xor %[pc], %[pc], %[ftmp0] \n\t"
- "psubh %[pc], %[pc], %[ftmp0] \n\t"
- "punpcklbh %[pa], %[pa], %[zero] \n\t"
- "punpcklbh %[pb], %[pb], %[zero] \n\t"
- "pcmpgth %[ftmp0], %[pa], %[pb] \n\t"
- "and %[ftmp1], %[b], %[ftmp0] \n\t"
- "pandn %[a], %[ftmp0], %[a] \n\t"
- "or %[a], %[a], %[ftmp1] \n\t"
- "pminsh %[pa], %[pa], %[pb] \n\t"
- "pcmpgth %[ftmp0], %[pa], %[pc] \n\t"
- "and %[ftmp1], %[c], %[ftmp0] \n\t"
- "pandn %[a], %[ftmp0], %[a] \n\t"
- "or %[a], %[a], %[ftmp1] \n\t"
- "paddb %[a], %[a], %[d] \n\t"
- "packushb %[d], %[a], %[a] \n\t"
- "punpcklbh %[c], %[ftmp2], %[zero] \n\t"
- "gsswrc1 %[d], 0x06(%[row]) \n\t"
- "gsswlc1 %[d], 0x09(%[row]) \n\t"
-
- "dsrl %[ftmp0], %[rp1], %[eight] \n\t"
- "dsrl %[ftmp2], %[pp1], %[eight] \n\t"
-
- "punpcklbh %[b], %[ftmp2], %[zero] \n\t"
- "punpcklbh %[d], %[ftmp0], %[zero] \n\t"
- "packushb %[ftmp0], %[c], %[c] \n\t"
- "packushb %[ftmp1], %[a], %[a] \n\t"
- "pasubub %[pa], %[ftmp2], %[ftmp0] \n\t"
- "pasubub %[pb], %[ftmp1], %[ftmp0] \n\t"
- "psubh %[ftmp0], %[b], %[c] \n\t"
- "psubh %[ftmp1], %[a], %[c] \n\t"
- "paddh %[pc], %[ftmp0], %[ftmp1] \n\t"
- "pcmpgth %[ftmp0], %[zero], %[pc] \n\t"
- "xor %[pc], %[pc], %[ftmp0] \n\t"
- "psubh %[pc], %[pc], %[ftmp0] \n\t"
- "punpcklbh %[pa], %[pa], %[zero] \n\t"
- "punpcklbh %[pb], %[pb], %[zero] \n\t"
- "pcmpgth %[ftmp0], %[pa], %[pb] \n\t"
- "and %[ftmp1], %[b], %[ftmp0] \n\t"
- "pandn %[a], %[ftmp0], %[a] \n\t"
- "or %[a], %[a], %[ftmp1] \n\t"
- "pminsh %[pa], %[pa], %[pb] \n\t"
- "pcmpgth %[ftmp0], %[pa], %[pc] \n\t"
- "and %[ftmp1], %[c], %[ftmp0] \n\t"
- "pandn %[a], %[ftmp0], %[a] \n\t"
- "or %[a], %[a], %[ftmp1] \n\t"
- "paddb %[a], %[a], %[d] \n\t"
- "packushb %[d], %[a], %[a] \n\t"
- "punpcklbh %[c], %[ftmp2], %[zero] \n\t"
- "gsswrc1 %[d], 0x09(%[row]) \n\t"
-
- "daddiu %[row], %[row], 0x0c \n\t"
- "daddiu %[prev], %[prev], 0x0c \n\t"
- "daddiu %[istop], %[istop], -0x0c \n\t"
- "bgtz %[istop], 1b \n\t"
- : [rp]"=&f"(rp), [pp]"=&f"(pp), [rp1]"=&f"(rp1), [pp1]"=&f"(pp1),
- [zero]"=&f"(zero), [a]"=&f"(a),[b]"=&f"(b), [c]"=&f"(c),
- [d]"=&f"(d), [pa]"=&f"(pa), [pb]"=&f"(pb), [pc]"=&f"(pc),
- [tmp0]"=&r"(tmp0), [ftmp0]"=&f"(ftmp[0]), [ftmp1]"=&f"(ftmp[1]),
- [ftmp2]"=&f"(ftmp[2]), [eight]"=&f"(eight), [sixteen]"=&f"(sixteen),
- [twenty_four]"=&f"(twenty_four), [forty_eight]"=&f"(forty_eight)
- : [row]"r"(row), [prev]"r"(prev), [istop]"r"(istop)
- : "memory"
- );
-}
-
-void png_read_filter_row_paeth4_mmi(png_row_infop row_info, png_bytep row,
- png_const_bytep prev)
-{
- /* Paeth tries to predict pixel d using the pixel to the left of it, a,
- * and two pixels from the previous row, b and c:
- * prev: c b
- * row: a d
- * The Paeth function predicts d to be whichever of a, b, or c is nearest to
- * p=a+b-c.
- *
- * The first pixel has no left context, and so uses an Up filter, p = b.
- * This works naturally with our main loop's p = a+b-c if we force a and c
- * to zero.
- * Here we zero b and d, which become c and a respectively at the start of
- * the loop.
- */
- int istop = row_info->rowbytes;
- double rp, pp, zero;
- double a, b, c, d, pa, pb, pc;
- double ftmp[2];
-
- __asm__ volatile (
- "xor %[a], %[a], %[a] \n\t"
- "xor %[c], %[c], %[c] \n\t"
- "xor %[zero], %[zero], %[zero] \n\t"
-
- "1: \n\t"
- "lwc1 %[rp], 0x00(%[row]) \n\t"
- "lwc1 %[pp], 0x00(%[prev]) \n\t"
- "punpcklbh %[b], %[pp], %[zero] \n\t"
- "punpcklbh %[d], %[rp], %[zero] \n\t"
-
- "packushb %[ftmp0], %[c], %[c] \n\t"
- "packushb %[ftmp1], %[a], %[a] \n\t"
- "pasubub %[pa], %[pp], %[ftmp0] \n\t"
- "pasubub %[pb], %[ftmp1], %[ftmp0] \n\t"
- "psubh %[ftmp0], %[b], %[c] \n\t"
- "psubh %[ftmp1], %[a], %[c] \n\t"
- "paddh %[pc], %[ftmp0], %[ftmp1] \n\t"
- "pcmpgth %[ftmp0], %[zero], %[pc] \n\t"
- "xor %[pc], %[pc], %[ftmp0] \n\t"
- "psubh %[pc], %[pc], %[ftmp0] \n\t"
-
- "punpcklbh %[pa], %[pa], %[zero] \n\t"
- "punpcklbh %[pb], %[pb], %[zero] \n\t"
-
- "pcmpgth %[ftmp0], %[pa], %[pb] \n\t"
- "and %[ftmp1], %[b], %[ftmp0] \n\t"
- "pandn %[a], %[ftmp0], %[a] \n\t"
- "or %[a], %[a], %[ftmp1] \n\t"
- "pminsh %[pa], %[pa], %[pb] \n\t"
-
- "pcmpgth %[ftmp0], %[pa], %[pc] \n\t"
- "and %[ftmp1], %[c], %[ftmp0] \n\t"
- "pandn %[a], %[ftmp0], %[a] \n\t"
- "or %[a], %[a], %[ftmp1] \n\t"
- "paddb %[a], %[a], %[d] \n\t"
- "packushb %[d], %[a], %[a] \n\t"
- "swc1 %[d], 0x00(%[row]) \n\t"
- "punpcklbh %[c], %[pp], %[zero] \n\t"
- "daddiu %[row], %[row], 0x04 \n\t"
- "daddiu %[prev], %[prev], 0x04 \n\t"
- "daddiu %[istop], %[istop], -0x04 \n\t"
- "bgtz %[istop], 1b \n\t"
- : [rp]"=&f"(rp), [pp]"=&f"(pp), [zero]"=&f"(zero),
- [a]"=&f"(a), [b]"=&f"(b), [c]"=&f"(c), [d]"=&f"(d),
- [pa]"=&f"(pa), [pb]"=&f"(pb), [pc]"=&f"(pc),
- [ftmp0]"=&f"(ftmp[0]), [ftmp1]"=&f"(ftmp[1])
- : [row]"r"(row), [prev]"r"(prev), [istop]"r"(istop)
- : "memory"
- );
-}
-
-#endif /* PNG_MIPS_MMI_IMPLEMENTATION > 0 */
-#endif /* READ */
diff --git a/contrib/libs/libpng/mips/filter_msa_intrinsics.c b/contrib/libs/libpng/mips/filter_msa_intrinsics.c
deleted file mode 100644
index a294f55130..0000000000
--- a/contrib/libs/libpng/mips/filter_msa_intrinsics.c
+++ /dev/null
@@ -1,807 +0,0 @@
-/* filter_msa_intrinsics.c - MSA optimised filter functions
- *
- * Copyright (c) 2018-2024 Cosmin Truta
- * Copyright (c) 2016 Glenn Randers-Pehrson
- * Written by Mandar Sahastrabuddhe, August 2016
- *
- * This code is released under the libpng license.
- * For conditions of distribution and use, see the disclaimer
- * and license in png.h
- */
-
-#include <stdio.h>
-#include "../pngpriv.h"
-
-#ifdef PNG_READ_SUPPORTED
-
-/* This code requires -mfpu=msa on the command line: */
-#if PNG_MIPS_MSA_IMPLEMENTATION == 1 /* intrinsics code from pngpriv.h */
-
-#include <msa.h>
-#include <stdint.h>
-
-/* libpng row pointers are not necessarily aligned to any particular boundary,
- * however this code will only work with appropriate alignment. mips/mips_init.c
- * checks for this (and will not compile unless it is done). This code uses
- * variants of png_aligncast to avoid compiler warnings.
- */
-#define png_ptr(type,pointer) png_aligncast(type *,pointer)
-#define png_ptrc(type,pointer) png_aligncastconst(const type *,pointer)
-
-/* The following relies on a variable 'temp_pointer' being declared with type
- * 'type'. This is written this way just to hide the GCC strict aliasing
- * warning; note that the code is safe because there never is an alias between
- * the input and output pointers.
- */
-#define png_ldr(type,pointer)\
- (temp_pointer = png_ptr(type,pointer), *temp_pointer)
-
-#if PNG_MIPS_MSA_OPT > 0
-
-#ifdef CLANG_BUILD
- #define MSA_SRLI_B(a, b) __msa_srli_b((v16i8) a, b)
-
- #define LW(psrc) \
- ( { \
- uint8_t *psrc_lw_m = (uint8_t *) (psrc); \
- uint32_t val_m; \
- \
- __asm__ volatile ( \
- "lw %[val_m], %[psrc_lw_m] \n\t" \
- \
- : [val_m] "=r" (val_m) \
- : [psrc_lw_m] "m" (*psrc_lw_m) \
- ); \
- \
- val_m; \
- } )
-
- #define SH(val, pdst) \
- { \
- uint8_t *pdst_sh_m = (uint8_t *) (pdst); \
- uint16_t val_m = (val); \
- \
- __asm__ volatile ( \
- "sh %[val_m], %[pdst_sh_m] \n\t" \
- \
- : [pdst_sh_m] "=m" (*pdst_sh_m) \
- : [val_m] "r" (val_m) \
- ); \
- }
-
- #define SW(val, pdst) \
- { \
- uint8_t *pdst_sw_m = (uint8_t *) (pdst); \
- uint32_t val_m = (val); \
- \
- __asm__ volatile ( \
- "sw %[val_m], %[pdst_sw_m] \n\t" \
- \
- : [pdst_sw_m] "=m" (*pdst_sw_m) \
- : [val_m] "r" (val_m) \
- ); \
- }
-
- #if __mips == 64
- #define SD(val, pdst) \
- { \
- uint8_t *pdst_sd_m = (uint8_t *) (pdst); \
- uint64_t val_m = (val); \
- \
- __asm__ volatile ( \
- "sd %[val_m], %[pdst_sd_m] \n\t" \
- \
- : [pdst_sd_m] "=m" (*pdst_sd_m) \
- : [val_m] "r" (val_m) \
- ); \
- }
- #else
- #define SD(val, pdst) \
- { \
- uint8_t *pdst_sd_m = (uint8_t *) (pdst); \
- uint32_t val0_m, val1_m; \
- \
- val0_m = (uint32_t) ((val) & 0x00000000FFFFFFFF); \
- val1_m = (uint32_t) (((val) >> 32) & 0x00000000FFFFFFFF); \
- \
- SW(val0_m, pdst_sd_m); \
- SW(val1_m, pdst_sd_m + 4); \
- }
- #endif /* __mips == 64 */
-#else
- #define MSA_SRLI_B(a, b) (a >> b)
-
-#if __mips_isa_rev >= 6
- #define LW(psrc) \
- ( { \
- uint8_t *psrc_lw_m = (uint8_t *) (psrc); \
- uint32_t val_m; \
- \
- __asm__ volatile ( \
- "lw %[val_m], %[psrc_lw_m] \n\t" \
- \
- : [val_m] "=r" (val_m) \
- : [psrc_lw_m] "m" (*psrc_lw_m) \
- ); \
- \
- val_m; \
- } )
-
- #define SH(val, pdst) \
- { \
- uint8_t *pdst_sh_m = (uint8_t *) (pdst); \
- uint16_t val_m = (val); \
- \
- __asm__ volatile ( \
- "sh %[val_m], %[pdst_sh_m] \n\t" \
- \
- : [pdst_sh_m] "=m" (*pdst_sh_m) \
- : [val_m] "r" (val_m) \
- ); \
- }
-
- #define SW(val, pdst) \
- { \
- uint8_t *pdst_sw_m = (uint8_t *) (pdst); \
- uint32_t val_m = (val); \
- \
- __asm__ volatile ( \
- "sw %[val_m], %[pdst_sw_m] \n\t" \
- \
- : [pdst_sw_m] "=m" (*pdst_sw_m) \
- : [val_m] "r" (val_m) \
- ); \
- }
-
- #if __mips == 64
- #define SD(val, pdst) \
- { \
- uint8_t *pdst_sd_m = (uint8_t *) (pdst); \
- uint64_t val_m = (val); \
- \
- __asm__ volatile ( \
- "sd %[val_m], %[pdst_sd_m] \n\t" \
- \
- : [pdst_sd_m] "=m" (*pdst_sd_m) \
- : [val_m] "r" (val_m) \
- ); \
- }
- #else
- #define SD(val, pdst) \
- { \
- uint8_t *pdst_sd_m = (uint8_t *) (pdst); \
- uint32_t val0_m, val1_m; \
- \
- val0_m = (uint32_t) ((val) & 0x00000000FFFFFFFF); \
- val1_m = (uint32_t) (((val) >> 32) & 0x00000000FFFFFFFF); \
- \
- SW(val0_m, pdst_sd_m); \
- SW(val1_m, pdst_sd_m + 4); \
- }
- #endif /* __mips == 64 */
-#else
- #define LW(psrc) \
- ( { \
- uint8_t *psrc_lw_m = (uint8_t *) (psrc); \
- uint32_t val_m; \
- \
- __asm__ volatile ( \
- "ulw %[val_m], %[psrc_lw_m] \n\t" \
- \
- : [val_m] "=r" (val_m) \
- : [psrc_lw_m] "m" (*psrc_lw_m) \
- ); \
- \
- val_m; \
- } )
-
- #define SH(val, pdst) \
- { \
- uint8_t *pdst_sh_m = (uint8_t *) (pdst); \
- uint16_t val_m = (val); \
- \
- __asm__ volatile ( \
- "ush %[val_m], %[pdst_sh_m] \n\t" \
- \
- : [pdst_sh_m] "=m" (*pdst_sh_m) \
- : [val_m] "r" (val_m) \
- ); \
- }
-
- #define SW(val, pdst) \
- { \
- uint8_t *pdst_sw_m = (uint8_t *) (pdst); \
- uint32_t val_m = (val); \
- \
- __asm__ volatile ( \
- "usw %[val_m], %[pdst_sw_m] \n\t" \
- \
- : [pdst_sw_m] "=m" (*pdst_sw_m) \
- : [val_m] "r" (val_m) \
- ); \
- }
-
- #define SD(val, pdst) \
- { \
- uint8_t *pdst_sd_m = (uint8_t *) (pdst); \
- uint32_t val0_m, val1_m; \
- \
- val0_m = (uint32_t) ((val) & 0x00000000FFFFFFFF); \
- val1_m = (uint32_t) (((val) >> 32) & 0x00000000FFFFFFFF); \
- \
- SW(val0_m, pdst_sd_m); \
- SW(val1_m, pdst_sd_m + 4); \
- }
-
- #define SW_ZERO(pdst) \
- { \
- uint8_t *pdst_m = (uint8_t *) (pdst); \
- \
- __asm__ volatile ( \
- "usw $0, %[pdst_m] \n\t" \
- \
- : [pdst_m] "=m" (*pdst_m) \
- : \
- ); \
- }
-#endif /* __mips_isa_rev >= 6 */
-#endif
-
-#define LD_B(RTYPE, psrc) *((RTYPE *) (psrc))
-#define LD_UB(...) LD_B(v16u8, __VA_ARGS__)
-#define LD_B2(RTYPE, psrc, stride, out0, out1) \
-{ \
- out0 = LD_B(RTYPE, (psrc)); \
- out1 = LD_B(RTYPE, (psrc) + stride); \
-}
-#define LD_UB2(...) LD_B2(v16u8, __VA_ARGS__)
-#define LD_B4(RTYPE, psrc, stride, out0, out1, out2, out3) \
-{ \
- LD_B2(RTYPE, (psrc), stride, out0, out1); \
- LD_B2(RTYPE, (psrc) + 2 * stride , stride, out2, out3); \
-}
-#define LD_UB4(...) LD_B4(v16u8, __VA_ARGS__)
-
-#define ST_B(RTYPE, in, pdst) *((RTYPE *) (pdst)) = (in)
-#define ST_UB(...) ST_B(v16u8, __VA_ARGS__)
-#define ST_B2(RTYPE, in0, in1, pdst, stride) \
-{ \
- ST_B(RTYPE, in0, (pdst)); \
- ST_B(RTYPE, in1, (pdst) + stride); \
-}
-#define ST_UB2(...) ST_B2(v16u8, __VA_ARGS__)
-#define ST_B4(RTYPE, in0, in1, in2, in3, pdst, stride) \
-{ \
- ST_B2(RTYPE, in0, in1, (pdst), stride); \
- ST_B2(RTYPE, in2, in3, (pdst) + 2 * stride, stride); \
-}
-#define ST_UB4(...) ST_B4(v16u8, __VA_ARGS__)
-
-#define ADD2(in0, in1, in2, in3, out0, out1) \
-{ \
- out0 = in0 + in1; \
- out1 = in2 + in3; \
-}
-#define ADD3(in0, in1, in2, in3, in4, in5, \
- out0, out1, out2) \
-{ \
- ADD2(in0, in1, in2, in3, out0, out1); \
- out2 = in4 + in5; \
-}
-#define ADD4(in0, in1, in2, in3, in4, in5, in6, in7, \
- out0, out1, out2, out3) \
-{ \
- ADD2(in0, in1, in2, in3, out0, out1); \
- ADD2(in4, in5, in6, in7, out2, out3); \
-}
-
-#define ILVR_B2(RTYPE, in0, in1, in2, in3, out0, out1) \
-{ \
- out0 = (RTYPE) __msa_ilvr_b((v16i8) in0, (v16i8) in1); \
- out1 = (RTYPE) __msa_ilvr_b((v16i8) in2, (v16i8) in3); \
-}
-#define ILVR_B2_SH(...) ILVR_B2(v8i16, __VA_ARGS__)
-
-#define HSUB_UB2(RTYPE, in0, in1, out0, out1) \
-{ \
- out0 = (RTYPE) __msa_hsub_u_h((v16u8) in0, (v16u8) in0); \
- out1 = (RTYPE) __msa_hsub_u_h((v16u8) in1, (v16u8) in1); \
-}
-#define HSUB_UB2_SH(...) HSUB_UB2(v8i16, __VA_ARGS__)
-
-#define SLDI_B2_0(RTYPE, in0, in1, out0, out1, slide_val) \
-{ \
- v16i8 zero_m = { 0 }; \
- out0 = (RTYPE) __msa_sldi_b((v16i8) zero_m, (v16i8) in0, slide_val); \
- out1 = (RTYPE) __msa_sldi_b((v16i8) zero_m, (v16i8) in1, slide_val); \
-}
-#define SLDI_B2_0_UB(...) SLDI_B2_0(v16u8, __VA_ARGS__)
-
-#define SLDI_B3_0(RTYPE, in0, in1, in2, out0, out1, out2, slide_val) \
-{ \
- v16i8 zero_m = { 0 }; \
- SLDI_B2_0(RTYPE, in0, in1, out0, out1, slide_val); \
- out2 = (RTYPE) __msa_sldi_b((v16i8) zero_m, (v16i8) in2, slide_val); \
-}
-#define SLDI_B3_0_UB(...) SLDI_B3_0(v16u8, __VA_ARGS__)
-
-#define ILVEV_W2(RTYPE, in0, in1, in2, in3, out0, out1) \
-{ \
- out0 = (RTYPE) __msa_ilvev_w((v4i32) in1, (v4i32) in0); \
- out1 = (RTYPE) __msa_ilvev_w((v4i32) in3, (v4i32) in2); \
-}
-#define ILVEV_W2_UB(...) ILVEV_W2(v16u8, __VA_ARGS__)
-
-#define ADD_ABS_H3(RTYPE, in0, in1, in2, out0, out1, out2) \
-{ \
- RTYPE zero = {0}; \
- \
- out0 = __msa_add_a_h((v8i16) zero, in0); \
- out1 = __msa_add_a_h((v8i16) zero, in1); \
- out2 = __msa_add_a_h((v8i16) zero, in2); \
-}
-#define ADD_ABS_H3_SH(...) ADD_ABS_H3(v8i16, __VA_ARGS__)
-
-#define VSHF_B2(RTYPE, in0, in1, in2, in3, mask0, mask1, out0, out1) \
-{ \
- out0 = (RTYPE) __msa_vshf_b((v16i8) mask0, (v16i8) in1, (v16i8) in0); \
- out1 = (RTYPE) __msa_vshf_b((v16i8) mask1, (v16i8) in3, (v16i8) in2); \
-}
-#define VSHF_B2_UB(...) VSHF_B2(v16u8, __VA_ARGS__)
-
-#define CMP_AND_SELECT(inp0, inp1, inp2, inp3, inp4, inp5, out0) \
-{ \
- v8i16 _sel_h0, _sel_h1; \
- v16u8 _sel_b0, _sel_b1; \
- _sel_h0 = (v8i16) __msa_clt_u_h((v8u16) inp1, (v8u16) inp0); \
- _sel_b0 = (v16u8) __msa_pckev_b((v16i8) _sel_h0, (v16i8) _sel_h0); \
- inp0 = (v8i16) __msa_bmnz_v((v16u8) inp0, (v16u8) inp1, (v16u8) _sel_h0); \
- inp4 = (v16u8) __msa_bmnz_v(inp3, inp4, _sel_b0); \
- _sel_h1 = (v8i16) __msa_clt_u_h((v8u16) inp2, (v8u16) inp0); \
- _sel_b1 = (v16u8) __msa_pckev_b((v16i8) _sel_h1, (v16i8) _sel_h1); \
- inp4 = (v16u8) __msa_bmnz_v(inp4, inp5, _sel_b1); \
- out0 += inp4; \
-}
-
-void png_read_filter_row_up_msa(png_row_infop row_info, png_bytep row,
- png_const_bytep prev_row)
-{
- size_t i, cnt, cnt16, cnt32;
- size_t istop = row_info->rowbytes;
- png_bytep rp = row;
- png_const_bytep pp = prev_row;
- v16u8 src0, src1, src2, src3, src4, src5, src6, src7;
-
- for (i = 0; i < (istop >> 6); i++)
- {
- LD_UB4(rp, 16, src0, src1, src2, src3);
- LD_UB4(pp, 16, src4, src5, src6, src7);
- pp += 64;
-
- ADD4(src0, src4, src1, src5, src2, src6, src3, src7,
- src0, src1, src2, src3);
-
- ST_UB4(src0, src1, src2, src3, rp, 16);
- rp += 64;
- }
-
- if (istop & 0x3F)
- {
- cnt32 = istop & 0x20;
- cnt16 = istop & 0x10;
- cnt = istop & 0xF;
-
- if(cnt32)
- {
- if (cnt16 && cnt)
- {
- LD_UB4(rp, 16, src0, src1, src2, src3);
- LD_UB4(pp, 16, src4, src5, src6, src7);
-
- ADD4(src0, src4, src1, src5, src2, src6, src3, src7,
- src0, src1, src2, src3);
-
- ST_UB4(src0, src1, src2, src3, rp, 16);
- rp += 64;
- }
- else if (cnt16 || cnt)
- {
- LD_UB2(rp, 16, src0, src1);
- LD_UB2(pp, 16, src4, src5);
- pp += 32;
- src2 = LD_UB(rp + 32);
- src6 = LD_UB(pp);
-
- ADD3(src0, src4, src1, src5, src2, src6, src0, src1, src2);
-
- ST_UB2(src0, src1, rp, 16);
- rp += 32;
- ST_UB(src2, rp);
- rp += 16;
- }
- else
- {
- LD_UB2(rp, 16, src0, src1);
- LD_UB2(pp, 16, src4, src5);
-
- ADD2(src0, src4, src1, src5, src0, src1);
-
- ST_UB2(src0, src1, rp, 16);
- rp += 32;
- }
- }
- else if (cnt16 && cnt)
- {
- LD_UB2(rp, 16, src0, src1);
- LD_UB2(pp, 16, src4, src5);
-
- ADD2(src0, src4, src1, src5, src0, src1);
-
- ST_UB2(src0, src1, rp, 16);
- rp += 32;
- }
- else if (cnt16 || cnt)
- {
- src0 = LD_UB(rp);
- src4 = LD_UB(pp);
- pp += 16;
-
- src0 += src4;
-
- ST_UB(src0, rp);
- rp += 16;
- }
- }
-}
-
-void png_read_filter_row_sub4_msa(png_row_infop row_info, png_bytep row,
- png_const_bytep prev_row)
-{
- size_t count;
- size_t istop = row_info->rowbytes;
- png_bytep src = row;
- png_bytep nxt = row + 4;
- int32_t inp0;
- v16u8 src0, src1, src2, src3, src4;
- v16u8 dst0, dst1;
- v16u8 zero = { 0 };
-
- istop -= 4;
-
- inp0 = LW(src);
- src += 4;
- src0 = (v16u8) __msa_insert_w((v4i32) zero, 0, inp0);
-
- for (count = 0; count < istop; count += 16)
- {
- src1 = LD_UB(src);
- src += 16;
-
- src2 = (v16u8) __msa_sldi_b((v16i8) zero, (v16i8) src1, 4);
- src3 = (v16u8) __msa_sldi_b((v16i8) zero, (v16i8) src1, 8);
- src4 = (v16u8) __msa_sldi_b((v16i8) zero, (v16i8) src1, 12);
- src1 += src0;
- src2 += src1;
- src3 += src2;
- src4 += src3;
- src0 = src4;
- ILVEV_W2_UB(src1, src2, src3, src4, dst0, dst1);
- dst0 = (v16u8) __msa_pckev_d((v2i64) dst1, (v2i64) dst0);
-
- ST_UB(dst0, nxt);
- nxt += 16;
- }
-}
-
-void png_read_filter_row_sub3_msa(png_row_infop row_info, png_bytep row,
- png_const_bytep prev_row)
-{
- size_t count;
- size_t istop = row_info->rowbytes;
- png_bytep src = row;
- png_bytep nxt = row + 3;
- int64_t out0;
- int32_t inp0, out1;
- v16u8 src0, src1, src2, src3, src4, dst0, dst1;
- v16u8 zero = { 0 };
- v16i8 mask0 = { 0, 1, 2, 16, 17, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- v16i8 mask1 = { 0, 1, 2, 3, 4, 5, 16, 17, 18, 19, 20, 21, 0, 0, 0, 0 };
-
- istop -= 3;
-
- inp0 = LW(src);
- src += 3;
- src0 = (v16u8) __msa_insert_w((v4i32) zero, 0, inp0);
-
- for (count = 0; count < istop; count += 12)
- {
- src1 = LD_UB(src);
- src += 12;
-
- src2 = (v16u8) __msa_sldi_b((v16i8) zero, (v16i8) src1, 3);
- src3 = (v16u8) __msa_sldi_b((v16i8) zero, (v16i8) src1, 6);
- src4 = (v16u8) __msa_sldi_b((v16i8) zero, (v16i8) src1, 9);
- src1 += src0;
- src2 += src1;
- src3 += src2;
- src4 += src3;
- src0 = src4;
- VSHF_B2_UB(src1, src2, src3, src4, mask0, mask0, dst0, dst1);
- dst0 = (v16u8) __msa_vshf_b(mask1, (v16i8) dst1, (v16i8) dst0);
- out0 = __msa_copy_s_d((v2i64) dst0, 0);
- out1 = __msa_copy_s_w((v4i32) dst0, 2);
-
- SD(out0, nxt);
- nxt += 8;
- SW(out1, nxt);
- nxt += 4;
- }
-}
-
-void png_read_filter_row_avg4_msa(png_row_infop row_info, png_bytep row,
- png_const_bytep prev_row)
-{
- size_t i;
- png_bytep src = row;
- png_bytep nxt = row;
- png_const_bytep pp = prev_row;
- size_t istop = row_info->rowbytes - 4;
- int32_t inp0, inp1, out0;
- v16u8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, dst0, dst1;
- v16u8 zero = { 0 };
-
- inp0 = LW(pp);
- pp += 4;
- inp1 = LW(src);
- src += 4;
- src0 = (v16u8) __msa_insert_w((v4i32) zero, 0, inp0);
- src1 = (v16u8) __msa_insert_w((v4i32) zero, 0, inp1);
- src0 = (v16u8) MSA_SRLI_B(src0, 1);
- src1 += src0;
- out0 = __msa_copy_s_w((v4i32) src1, 0);
- SW(out0, nxt);
- nxt += 4;
-
- for (i = 0; i < istop; i += 16)
- {
- src2 = LD_UB(pp);
- pp += 16;
- src6 = LD_UB(src);
- src += 16;
-
- SLDI_B2_0_UB(src2, src6, src3, src7, 4);
- SLDI_B2_0_UB(src2, src6, src4, src8, 8);
- SLDI_B2_0_UB(src2, src6, src5, src9, 12);
- src2 = __msa_ave_u_b(src2, src1);
- src6 += src2;
- src3 = __msa_ave_u_b(src3, src6);
- src7 += src3;
- src4 = __msa_ave_u_b(src4, src7);
- src8 += src4;
- src5 = __msa_ave_u_b(src5, src8);
- src9 += src5;
- src1 = src9;
- ILVEV_W2_UB(src6, src7, src8, src9, dst0, dst1);
- dst0 = (v16u8) __msa_pckev_d((v2i64) dst1, (v2i64) dst0);
-
- ST_UB(dst0, nxt);
- nxt += 16;
- }
-}
-
-void png_read_filter_row_avg3_msa(png_row_infop row_info, png_bytep row,
- png_const_bytep prev_row)
-{
- size_t i;
- png_bytep src = row;
- png_bytep nxt = row;
- png_const_bytep pp = prev_row;
- size_t istop = row_info->rowbytes - 3;
- int64_t out0;
- int32_t inp0, inp1, out1;
- int16_t out2;
- v16u8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, dst0, dst1;
- v16u8 zero = { 0 };
- v16i8 mask0 = { 0, 1, 2, 16, 17, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- v16i8 mask1 = { 0, 1, 2, 3, 4, 5, 16, 17, 18, 19, 20, 21, 0, 0, 0, 0 };
-
- inp0 = LW(pp);
- pp += 3;
- inp1 = LW(src);
- src += 3;
- src0 = (v16u8) __msa_insert_w((v4i32) zero, 0, inp0);
- src1 = (v16u8) __msa_insert_w((v4i32) zero, 0, inp1);
- src0 = (v16u8) MSA_SRLI_B(src0, 1);
- src1 += src0;
- out2 = __msa_copy_s_h((v8i16) src1, 0);
- SH(out2, nxt);
- nxt += 2;
- nxt[0] = src1[2];
- nxt++;
-
- for (i = 0; i < istop; i += 12)
- {
- src2 = LD_UB(pp);
- pp += 12;
- src6 = LD_UB(src);
- src += 12;
-
- SLDI_B2_0_UB(src2, src6, src3, src7, 3);
- SLDI_B2_0_UB(src2, src6, src4, src8, 6);
- SLDI_B2_0_UB(src2, src6, src5, src9, 9);
- src2 = __msa_ave_u_b(src2, src1);
- src6 += src2;
- src3 = __msa_ave_u_b(src3, src6);
- src7 += src3;
- src4 = __msa_ave_u_b(src4, src7);
- src8 += src4;
- src5 = __msa_ave_u_b(src5, src8);
- src9 += src5;
- src1 = src9;
- VSHF_B2_UB(src6, src7, src8, src9, mask0, mask0, dst0, dst1);
- dst0 = (v16u8) __msa_vshf_b(mask1, (v16i8) dst1, (v16i8) dst0);
- out0 = __msa_copy_s_d((v2i64) dst0, 0);
- out1 = __msa_copy_s_w((v4i32) dst0, 2);
-
- SD(out0, nxt);
- nxt += 8;
- SW(out1, nxt);
- nxt += 4;
- }
-}
-
-void png_read_filter_row_paeth4_msa(png_row_infop row_info,
- png_bytep row,
- png_const_bytep prev_row)
-{
- int32_t count, rp_end;
- png_bytep nxt;
- png_const_bytep prev_nxt;
- int32_t inp0, inp1, res0;
- v16u8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9;
- v16u8 src10, src11, src12, src13, dst0, dst1;
- v8i16 vec0, vec1, vec2;
- v16u8 zero = { 0 };
-
- nxt = row;
- prev_nxt = prev_row;
-
- inp0 = LW(nxt);
- inp1 = LW(prev_nxt);
- prev_nxt += 4;
- src0 = (v16u8) __msa_insert_w((v4i32) zero, 0, inp0);
- src1 = (v16u8) __msa_insert_w((v4i32) zero, 0, inp1);
-
- src1 += src0;
- res0 = __msa_copy_s_w((v4i32) src1, 0);
-
- SW(res0, nxt);
- nxt += 4;
-
- /* Remainder */
- rp_end = row_info->rowbytes - 4;
-
- for (count = 0; count < rp_end; count += 16)
- {
- src2 = LD_UB(prev_nxt);
- prev_nxt += 16;
- src6 = LD_UB(prev_row);
- prev_row += 16;
- src10 = LD_UB(nxt);
-
- SLDI_B3_0_UB(src2, src6, src10, src3, src7, src11, 4);
- SLDI_B3_0_UB(src2, src6, src10, src4, src8, src12, 8);
- SLDI_B3_0_UB(src2, src6, src10, src5, src9, src13, 12);
- ILVR_B2_SH(src2, src6, src1, src6, vec0, vec1);
- HSUB_UB2_SH(vec0, vec1, vec0, vec1);
- vec2 = vec0 + vec1;
- ADD_ABS_H3_SH(vec0, vec1, vec2, vec0, vec1, vec2);
- CMP_AND_SELECT(vec0, vec1, vec2, src1, src2, src6, src10);
- ILVR_B2_SH(src3, src7, src10, src7, vec0, vec1);
- HSUB_UB2_SH(vec0, vec1, vec0, vec1);
- vec2 = vec0 + vec1;
- ADD_ABS_H3_SH(vec0, vec1, vec2, vec0, vec1, vec2);
- CMP_AND_SELECT(vec0, vec1, vec2, src10, src3, src7, src11);
- ILVR_B2_SH(src4, src8, src11, src8, vec0, vec1);
- HSUB_UB2_SH(vec0, vec1, vec0, vec1);
- vec2 = vec0 + vec1;
- ADD_ABS_H3_SH(vec0, vec1, vec2, vec0, vec1, vec2);
- CMP_AND_SELECT(vec0, vec1, vec2, src11, src4, src8, src12);
- ILVR_B2_SH(src5, src9, src12, src9, vec0, vec1);
- HSUB_UB2_SH(vec0, vec1, vec0, vec1);
- vec2 = vec0 + vec1;
- ADD_ABS_H3_SH(vec0, vec1, vec2, vec0, vec1, vec2);
- CMP_AND_SELECT(vec0, vec1, vec2, src12, src5, src9, src13);
- src1 = src13;
- ILVEV_W2_UB(src10, src11, src12, src1, dst0, dst1);
- dst0 = (v16u8) __msa_pckev_d((v2i64) dst1, (v2i64) dst0);
-
- ST_UB(dst0, nxt);
- nxt += 16;
- }
-}
-
-void png_read_filter_row_paeth3_msa(png_row_infop row_info,
- png_bytep row,
- png_const_bytep prev_row)
-{
- int32_t count, rp_end;
- png_bytep nxt;
- png_const_bytep prev_nxt;
- int64_t out0;
- int32_t inp0, inp1, out1;
- int16_t out2;
- v16u8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, dst0, dst1;
- v16u8 src10, src11, src12, src13;
- v8i16 vec0, vec1, vec2;
- v16u8 zero = { 0 };
- v16i8 mask0 = { 0, 1, 2, 16, 17, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- v16i8 mask1 = { 0, 1, 2, 3, 4, 5, 16, 17, 18, 19, 20, 21, 0, 0, 0, 0 };
-
- nxt = row;
- prev_nxt = prev_row;
-
- inp0 = LW(nxt);
- inp1 = LW(prev_nxt);
- prev_nxt += 3;
- src0 = (v16u8) __msa_insert_w((v4i32) zero, 0, inp0);
- src1 = (v16u8) __msa_insert_w((v4i32) zero, 0, inp1);
-
- src1 += src0;
- out2 = __msa_copy_s_h((v8i16) src1, 0);
-
- SH(out2, nxt);
- nxt += 2;
- nxt[0] = src1[2];
- nxt++;
-
- /* Remainder */
- rp_end = row_info->rowbytes - 3;
-
- for (count = 0; count < rp_end; count += 12)
- {
- src2 = LD_UB(prev_nxt);
- prev_nxt += 12;
- src6 = LD_UB(prev_row);
- prev_row += 12;
- src10 = LD_UB(nxt);
-
- SLDI_B3_0_UB(src2, src6, src10, src3, src7, src11, 3);
- SLDI_B3_0_UB(src2, src6, src10, src4, src8, src12, 6);
- SLDI_B3_0_UB(src2, src6, src10, src5, src9, src13, 9);
- ILVR_B2_SH(src2, src6, src1, src6, vec0, vec1);
- HSUB_UB2_SH(vec0, vec1, vec0, vec1);
- vec2 = vec0 + vec1;
- ADD_ABS_H3_SH(vec0, vec1, vec2, vec0, vec1, vec2);
- CMP_AND_SELECT(vec0, vec1, vec2, src1, src2, src6, src10);
- ILVR_B2_SH(src3, src7, src10, src7, vec0, vec1);
- HSUB_UB2_SH(vec0, vec1, vec0, vec1);
- vec2 = vec0 + vec1;
- ADD_ABS_H3_SH(vec0, vec1, vec2, vec0, vec1, vec2);
- CMP_AND_SELECT(vec0, vec1, vec2, src10, src3, src7, src11);
- ILVR_B2_SH(src4, src8, src11, src8, vec0, vec1);
- HSUB_UB2_SH(vec0, vec1, vec0, vec1);
- vec2 = vec0 + vec1;
- ADD_ABS_H3_SH(vec0, vec1, vec2, vec0, vec1, vec2);
- CMP_AND_SELECT(vec0, vec1, vec2, src11, src4, src8, src12);
- ILVR_B2_SH(src5, src9, src12, src9, vec0, vec1);
- HSUB_UB2_SH(vec0, vec1, vec0, vec1);
- vec2 = vec0 + vec1;
- ADD_ABS_H3_SH(vec0, vec1, vec2, vec0, vec1, vec2);
- CMP_AND_SELECT(vec0, vec1, vec2, src12, src5, src9, src13);
- src1 = src13;
- VSHF_B2_UB(src10, src11, src12, src13, mask0, mask0, dst0, dst1);
- dst0 = (v16u8) __msa_vshf_b(mask1, (v16i8) dst1, (v16i8) dst0);
- out0 = __msa_copy_s_d((v2i64) dst0, 0);
- out1 = __msa_copy_s_w((v4i32) dst0, 2);
-
- SD(out0, nxt);
- nxt += 8;
- SW(out1, nxt);
- nxt += 4;
- }
-}
-
-#endif /* PNG_MIPS_MSA_OPT > 0 */
-#endif /* PNG_MIPS_MSA_IMPLEMENTATION == 1 (intrinsics) */
-#endif /* READ */
diff --git a/contrib/libs/libpng/mips/mips_init.c b/contrib/libs/libpng/mips/mips_init.c
deleted file mode 100644
index 3531454c75..0000000000
--- a/contrib/libs/libpng/mips/mips_init.c
+++ /dev/null
@@ -1,203 +0,0 @@
-/* mips_init.c - MSA optimised filter functions
- *
- * Copyright (c) 2018-2024 Cosmin Truta
- * Copyright (c) 2016 Glenn Randers-Pehrson
- * Written by Mandar Sahastrabuddhe, 2016
- * Updated by guxiwei, 2023
- *
- * This code is released under the libpng license.
- * For conditions of distribution and use, see the disclaimer
- * and license in png.h
- */
-
-/* Below, after checking __linux__, various non-C90 POSIX 1003.1 functions are
- * called.
- */
-#define _POSIX_SOURCE 1
-
-#include <stdio.h>
-#include "../pngpriv.h"
-
-#ifdef PNG_READ_SUPPORTED
-
-#if PNG_MIPS_MSA_IMPLEMENTATION == 1 || PNG_MIPS_MMI_IMPLEMENTATION > 0
-
-#ifdef PNG_MIPS_MSA_CHECK_SUPPORTED /* Do MIPS MSA run-time checks */
-/* WARNING: it is strongly recommended that you do not build libpng with
- * run-time checks for CPU features if at all possible. In the case of the MIPS
- * MSA instructions there is no processor-specific way of detecting the
- * presence of the required support, therefore run-time detection is extremely
- * OS specific.
- *
- * You may set the macro PNG_MIPS_MSA_FILE to the file name of file containing
- * a fragment of C source code which defines the png_have_msa function. There
- * are a number of implementations in contrib/mips-msa, but the only one that
- * has partial support is contrib/mips-msa/linux.c - a generic Linux
- * implementation which reads /proc/cpufino.
- */
-#ifndef PNG_MIPS_MSA_FILE
-# ifdef __linux__
-# define PNG_MIPS_MSA_FILE "contrib/mips-msa/linux.c"
-# endif
-#endif
-
-#ifdef PNG_MIPS_MSA_FILE
-
-#include <signal.h> /* for sig_atomic_t */
-static int png_have_msa(png_structp png_ptr);
-#error #include PNG_MIPS_MSA_FILE
-
-#else /* PNG_MIPS_MSA_FILE */
-# error "PNG_MIPS_MSA_FILE undefined: no support for run-time MIPS MSA checks"
-#endif /* PNG_MIPS_MSA_FILE */
-#endif /* PNG_MIPS_MSA_CHECK_SUPPORTED */
-
-#ifdef PNG_MIPS_MMI_CHECK_SUPPORTED /* Do MIPS MMI run-times checks */
-#ifndef PNG_MIPS_MMI_FILE
-# ifdef __linux__
-# define PNG_MIPS_MMI_FILE "contrib/mips-mmi/linux.c"
-# endif
-#endif
-
-#ifdef PNG_MIPS_MMI_FILE
-
-#include <signal.h> /* for sig_atomic_t */
-static int png_have_mmi();
-#error #include PNG_MIPS_MMI_FILE
-
-#else /* PNG_MIPS_MMI_FILE */
-# error "PNG_MIPS_MMI_FILE undefined: no support for run-time MIPS MMI checks"
-#endif /* PNG_MIPS_MMI_FILE */
-#endif /* PNG_MIPS_MMI_CHECK_SUPPORTED*/
-
-#ifndef PNG_ALIGNED_MEMORY_SUPPORTED
-# error "ALIGNED_MEMORY is required; set: -DPNG_ALIGNED_MEMORY_SUPPORTED"
-#endif
-
-/* MIPS supports two optimizations: MMI and MSA. The appropriate
- * optimization is chosen at runtime
- */
-void
-png_init_filter_functions_mips(png_structp pp, unsigned int bpp)
-{
-#if PNG_MIPS_MMI_IMPLEMENTATION > 0
-#ifdef PNG_MIPS_MMI_API_SUPPORTED
- switch ((pp->options >> PNG_MIPS_MMI) & 3)
- {
- case PNG_OPTION_UNSET:
-#endif /* PNG_MIPS_MMI_API_SUPPORTED */
-#ifdef PNG_MIPS_MMI_CHECK_SUPPORTED
- {
- static volatile sig_atomic_t no_mmi = -1; /* not checked */
-
- if (no_mmi < 0)
- no_mmi = !png_have_mmi();
-
- if (no_mmi)
- goto MIPS_MSA_INIT;
- }
-#ifdef PNG_MIPS_MMI_API_SUPPORTED
- break;
-#endif
-#endif /* PNG_MIPS_MMI_CHECK_SUPPORTED */
-
-#ifdef PNG_MIPS_MMI_API_SUPPORTED
- default: /* OFF or INVALID */
- goto MIPS_MSA_INIT;
-
- case PNG_OPTION_ON:
- /* Option turned on */
- break;
- }
-#endif
- pp->read_filter[PNG_FILTER_VALUE_UP-1] = png_read_filter_row_up_mmi;
- if (bpp == 3)
- {
- pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub3_mmi;
- pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg3_mmi;
- pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =
- png_read_filter_row_paeth3_mmi;
- }
- else if (bpp == 4)
- {
- pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub4_mmi;
- pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg4_mmi;
- pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =
- png_read_filter_row_paeth4_mmi;
- }
-#endif /* PNG_MIPS_MMI_IMPLEMENTATION > 0 */
-
-MIPS_MSA_INIT:
-#if PNG_MIPS_MSA_IMPLEMENTATION == 1
- /* The switch statement is compiled in for MIPS_MSA_API, the call to
- * png_have_msa is compiled in for MIPS_MSA_CHECK. If both are defined
- * the check is only performed if the API has not set the MSA option on
- * or off explicitly. In this case the check controls what happens.
- */
-
-#ifdef PNG_MIPS_MSA_API_SUPPORTED
- switch ((pp->options >> PNG_MIPS_MSA) & 3)
- {
- case PNG_OPTION_UNSET:
- /* Allow the run-time check to execute if it has been enabled -
- * thus both API and CHECK can be turned on. If it isn't supported
- * this case will fall through to the 'default' below, which just
- * returns.
- */
-#endif /* PNG_MIPS_MSA_API_SUPPORTED */
-#ifdef PNG_MIPS_MSA_CHECK_SUPPORTED
- {
- static volatile sig_atomic_t no_msa = -1; /* not checked */
-
- if (no_msa < 0)
- no_msa = !png_have_msa(pp);
-
- if (no_msa)
- return;
- }
-#ifdef PNG_MIPS_MSA_API_SUPPORTED
- break;
-#endif
-#endif /* PNG_MIPS_MSA_CHECK_SUPPORTED */
-
-#ifdef PNG_MIPS_MSA_API_SUPPORTED
- default: /* OFF or INVALID */
- return;
-
- case PNG_OPTION_ON:
- /* Option turned on */
- break;
- }
-#endif
-
- /* IMPORTANT: any new external functions used here must be declared using
- * PNG_INTERNAL_FUNCTION in ../pngpriv.h. This is required so that the
- * 'prefix' option to configure works:
- *
- * ./configure --with-libpng-prefix=foobar_
- *
- * Verify you have got this right by running the above command, doing a build
- * and examining pngprefix.h; it must contain a #define for every external
- * function you add. (Notice that this happens automatically for the
- * initialization function.)
- */
- pp->read_filter[PNG_FILTER_VALUE_UP-1] = png_read_filter_row_up_msa;
-
- if (bpp == 3)
- {
- pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub3_msa;
- pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg3_msa;
- pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = png_read_filter_row_paeth3_msa;
- }
-
- else if (bpp == 4)
- {
- pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub4_msa;
- pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg4_msa;
- pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = png_read_filter_row_paeth4_msa;
- }
-#endif /* PNG_MIPS_MSA_IMPLEMENTATION == 1 */
- return;
-}
-#endif /* PNG_MIPS_MSA_IMPLEMENTATION == 1 || PNG_MIPS_MMI_IMPLEMENTATION > 0 */
-#endif /* READ */
diff --git a/contrib/libs/libpng/patches/apng.patch b/contrib/libs/libpng/patches/apng.patch
deleted file mode 100644
index 28bd8b0ebc..0000000000
--- a/contrib/libs/libpng/patches/apng.patch
+++ /dev/null
@@ -1,1564 +0,0 @@
-Index: LICENSE
-===================================================================
---- a/LICENSE
-+++ b/LICENSE
-@@ -1,6 +1,12 @@
- COPYRIGHT NOTICE, DISCLAIMER, and LICENSE
- =========================================
-
-+This modified version of libpng code adds animated PNG support and is
-+released under the libpng license described below. The modifications are
-+Copyright (c) 2006-2007 Andrew Smith, Copyright (c) 2008-2025 Max Stepin,
-+and are delimited by "#ifdef PNG_APNG_SUPPORTED / #endif" directives
-+surrounding them in the modified libpng source files.
-+
- PNG Reference Library License version 2
- ---------------------------------------
-
-Index: pngread.c
-===================================================================
---- a/pngread.c
-+++ b/pngread.c
-@@ -160,6 +160,9 @@
-
- else if (chunk_name == png_IDAT)
- {
-+#ifdef PNG_READ_APNG_SUPPORTED
-+ png_have_info(png_ptr, info_ptr);
-+#endif
- png_ptr->idat_size = length;
- break;
- }
-@@ -269,6 +272,17 @@
- png_handle_iTXt(png_ptr, info_ptr, length);
- #endif
-
-+#ifdef PNG_READ_APNG_SUPPORTED
-+ else if (chunk_name == png_acTL)
-+ png_handle_acTL(png_ptr, info_ptr, length);
-+
-+ else if (chunk_name == png_fcTL)
-+ png_handle_fcTL(png_ptr, info_ptr, length);
-+
-+ else if (chunk_name == png_fdAT)
-+ png_handle_fdAT(png_ptr, info_ptr, length);
-+#endif
-+
- else
- png_handle_unknown(png_ptr, info_ptr, length,
- PNG_HANDLE_CHUNK_AS_DEFAULT);
-@@ -276,6 +290,72 @@
- }
- #endif /* SEQUENTIAL_READ */
-
-+#ifdef PNG_READ_APNG_SUPPORTED
-+void PNGAPI
-+png_read_frame_head(png_structp png_ptr, png_infop info_ptr)
-+{
-+ png_byte have_chunk_after_DAT; /* after IDAT or after fdAT */
-+
-+ png_debug(0, "Reading frame head");
-+
-+ if ((png_ptr->mode & PNG_HAVE_acTL) == 0)
-+ png_error(png_ptr, "attempt to png_read_frame_head() but "
-+ "no acTL present");
-+
-+ /* do nothing for the main IDAT */
-+ if (png_ptr->num_frames_read == 0)
-+ return;
-+
-+ png_read_reset(png_ptr);
-+ png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
-+ png_ptr->mode &= ~PNG_HAVE_fcTL;
-+
-+ have_chunk_after_DAT = 0;
-+ for (;;)
-+ {
-+ png_uint_32 length = png_read_chunk_header(png_ptr);
-+
-+ if (png_ptr->chunk_name == png_IDAT)
-+ {
-+ /* discard trailing IDATs for the first frame */
-+ if (have_chunk_after_DAT != 0 || png_ptr->num_frames_read > 1)
-+ png_error(png_ptr, "png_read_frame_head(): out of place IDAT");
-+ png_crc_finish(png_ptr, length);
-+ }
-+
-+ else if (png_ptr->chunk_name == png_fcTL)
-+ {
-+ png_handle_fcTL(png_ptr, info_ptr, length);
-+ have_chunk_after_DAT = 1;
-+ }
-+
-+ else if (png_ptr->chunk_name == png_fdAT)
-+ {
-+ png_ensure_sequence_number(png_ptr, length);
-+
-+ /* discard trailing fdATs for frames other than the first */
-+ if (have_chunk_after_DAT == 0 && png_ptr->num_frames_read > 1)
-+ png_crc_finish(png_ptr, length - 4);
-+ else if (png_ptr->mode & PNG_HAVE_fcTL)
-+ {
-+ png_ptr->idat_size = length - 4;
-+ png_ptr->mode |= PNG_HAVE_IDAT;
-+
-+ break;
-+ }
-+ else
-+ png_error(png_ptr, "png_read_frame_head(): out of place fdAT");
-+ }
-+ else
-+ {
-+ png_warning(png_ptr, "Skipped (ignored) a chunk "
-+ "between APNG chunks");
-+ png_crc_finish(png_ptr, length);
-+ }
-+ }
-+}
-+#endif /* READ_APNG */
-+
- /* Optional call to update the users info_ptr structure */
- void PNGAPI
- png_read_update_info(png_structrp png_ptr, png_inforp info_ptr)
-Index: pngget.c
-===================================================================
---- a/pngget.c
-+++ b/pngget.c
-@@ -1393,4 +1393,166 @@
- # endif
- #endif
-
-+#ifdef PNG_APNG_SUPPORTED
-+png_uint_32 PNGAPI
-+png_get_acTL(png_structp png_ptr, png_infop info_ptr,
-+ png_uint_32 *num_frames, png_uint_32 *num_plays)
-+{
-+ png_debug1(1, "in %s retrieval function", "acTL");
-+
-+ if (png_ptr != NULL && info_ptr != NULL &&
-+ (info_ptr->valid & PNG_INFO_acTL) != 0 &&
-+ num_frames != NULL && num_plays != NULL)
-+ {
-+ *num_frames = info_ptr->num_frames;
-+ *num_plays = info_ptr->num_plays;
-+ return (1);
-+ }
-+
-+ return (0);
-+}
-+
-+png_uint_32 PNGAPI
-+png_get_num_frames(png_structp png_ptr, png_infop info_ptr)
-+{
-+ png_debug(1, "in png_get_num_frames()");
-+
-+ if (png_ptr != NULL && info_ptr != NULL)
-+ return (info_ptr->num_frames);
-+ return (0);
-+}
-+
-+png_uint_32 PNGAPI
-+png_get_num_plays(png_structp png_ptr, png_infop info_ptr)
-+{
-+ png_debug(1, "in png_get_num_plays()");
-+
-+ if (png_ptr != NULL && info_ptr != NULL)
-+ return (info_ptr->num_plays);
-+ return (0);
-+}
-+
-+png_uint_32 PNGAPI
-+png_get_next_frame_fcTL(png_structp png_ptr, png_infop info_ptr,
-+ png_uint_32 *width, png_uint_32 *height,
-+ png_uint_32 *x_offset, png_uint_32 *y_offset,
-+ png_uint_16 *delay_num, png_uint_16 *delay_den,
-+ png_byte *dispose_op, png_byte *blend_op)
-+{
-+ png_debug1(1, "in %s retrieval function", "fcTL");
-+
-+ if (png_ptr != NULL && info_ptr != NULL &&
-+ (info_ptr->valid & PNG_INFO_fcTL) != 0 &&
-+ width != NULL && height != NULL &&
-+ x_offset != NULL && y_offset != NULL &&
-+ delay_num != NULL && delay_den != NULL &&
-+ dispose_op != NULL && blend_op != NULL)
-+ {
-+ *width = info_ptr->next_frame_width;
-+ *height = info_ptr->next_frame_height;
-+ *x_offset = info_ptr->next_frame_x_offset;
-+ *y_offset = info_ptr->next_frame_y_offset;
-+ *delay_num = info_ptr->next_frame_delay_num;
-+ *delay_den = info_ptr->next_frame_delay_den;
-+ *dispose_op = info_ptr->next_frame_dispose_op;
-+ *blend_op = info_ptr->next_frame_blend_op;
-+ return (1);
-+ }
-+
-+ return (0);
-+}
-+
-+png_uint_32 PNGAPI
-+png_get_next_frame_width(png_structp png_ptr, png_infop info_ptr)
-+{
-+ png_debug(1, "in png_get_next_frame_width()");
-+
-+ if (png_ptr != NULL && info_ptr != NULL)
-+ return (info_ptr->next_frame_width);
-+ return (0);
-+}
-+
-+png_uint_32 PNGAPI
-+png_get_next_frame_height(png_structp png_ptr, png_infop info_ptr)
-+{
-+ png_debug(1, "in png_get_next_frame_height()");
-+
-+ if (png_ptr != NULL && info_ptr != NULL)
-+ return (info_ptr->next_frame_height);
-+ return (0);
-+}
-+
-+png_uint_32 PNGAPI
-+png_get_next_frame_x_offset(png_structp png_ptr, png_infop info_ptr)
-+{
-+ png_debug(1, "in png_get_next_frame_x_offset()");
-+
-+ if (png_ptr != NULL && info_ptr != NULL)
-+ return (info_ptr->next_frame_x_offset);
-+ return (0);
-+}
-+
-+png_uint_32 PNGAPI
-+png_get_next_frame_y_offset(png_structp png_ptr, png_infop info_ptr)
-+{
-+ png_debug(1, "in png_get_next_frame_y_offset()");
-+
-+ if (png_ptr != NULL && info_ptr != NULL)
-+ return (info_ptr->next_frame_y_offset);
-+ return (0);
-+}
-+
-+png_uint_16 PNGAPI
-+png_get_next_frame_delay_num(png_structp png_ptr, png_infop info_ptr)
-+{
-+ png_debug(1, "in png_get_next_frame_delay_num()");
-+
-+ if (png_ptr != NULL && info_ptr != NULL)
-+ return (info_ptr->next_frame_delay_num);
-+ return (0);
-+}
-+
-+png_uint_16 PNGAPI
-+png_get_next_frame_delay_den(png_structp png_ptr, png_infop info_ptr)
-+{
-+ png_debug(1, "in png_get_next_frame_delay_den()");
-+
-+ if (png_ptr != NULL && info_ptr != NULL)
-+ return (info_ptr->next_frame_delay_den);
-+ return (0);
-+}
-+
-+png_byte PNGAPI
-+png_get_next_frame_dispose_op(png_structp png_ptr, png_infop info_ptr)
-+{
-+ png_debug(1, "in png_get_next_frame_dispose_op()");
-+
-+ if (png_ptr != NULL && info_ptr != NULL)
-+ return (info_ptr->next_frame_dispose_op);
-+ return (0);
-+}
-+
-+png_byte PNGAPI
-+png_get_next_frame_blend_op(png_structp png_ptr, png_infop info_ptr)
-+{
-+ png_debug(1, "in png_get_next_frame_blend_op()");
-+
-+ if (png_ptr != NULL && info_ptr != NULL)
-+ return (info_ptr->next_frame_blend_op);
-+ return (0);
-+}
-+
-+png_byte PNGAPI
-+png_get_first_frame_is_hidden(png_structp png_ptr, png_infop info_ptr)
-+{
-+ png_debug(1, "in png_first_frame_is_hidden()");
-+
-+ if (png_ptr != NULL)
-+ return (png_byte)(png_ptr->apng_flags & PNG_FIRST_FRAME_HIDDEN);
-+
-+ PNG_UNUSED(info_ptr)
-+
-+ return 0;
-+}
-+#endif /* APNG */
- #endif /* READ || WRITE */
-Index: png.h
-===================================================================
---- a/png.h
-+++ b/png.h
-@@ -23,6 +23,12 @@
- * COPYRIGHT NOTICE, DISCLAIMER, and LICENSE
- * =========================================
- *
-+ * This modified version of libpng code adds animated PNG support and is
-+ * released under the libpng license described below. The modifications are
-+ * Copyright (c) 2006-2007 Andrew Smith, Copyright (c) 2008-2025 Max Stepin,
-+ * and are delimited by "#ifdef PNG_APNG_SUPPORTED / #endif" directives
-+ * surrounding them in the modified libpng source files.
-+ *
- * PNG Reference Library License version 2
- * ---------------------------------------
- *
-@@ -328,6 +335,10 @@
- # include "pnglibconf.h"
- #endif
-
-+#define PNG_APNG_SUPPORTED
-+#define PNG_READ_APNG_SUPPORTED
-+#define PNG_WRITE_APNG_SUPPORTED
-+
- #ifndef PNG_VERSION_INFO_ONLY
- /* Machine specific configuration. */
- # include "pngconf.h"
-@@ -423,6 +434,17 @@
- * See pngconf.h for base types that vary by machine/system
- */
-
-+#ifdef PNG_APNG_SUPPORTED
-+/* dispose_op flags from inside fcTL */
-+#define PNG_DISPOSE_OP_NONE 0x00
-+#define PNG_DISPOSE_OP_BACKGROUND 0x01
-+#define PNG_DISPOSE_OP_PREVIOUS 0x02
-+
-+/* blend_op flags from inside fcTL */
-+#define PNG_BLEND_OP_SOURCE 0x00
-+#define PNG_BLEND_OP_OVER 0x01
-+#endif /* APNG */
-+
- /* This triggers a compiler error in png.c, if png.c and png.h
- * do not agree upon the version number.
- */
-@@ -796,6 +818,10 @@
- #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
- typedef PNG_CALLBACK(void, *png_progressive_info_ptr, (png_structp, png_infop));
- typedef PNG_CALLBACK(void, *png_progressive_end_ptr, (png_structp, png_infop));
-+#ifdef PNG_APNG_SUPPORTED
-+typedef PNG_CALLBACK(void, *png_progressive_frame_ptr, (png_structp,
-+ png_uint_32));
-+#endif
-
- /* The following callback receives png_uint_32 row_number, int pass for the
- * png_bytep data of the row. When transforming an interlaced image the
-@@ -3338,6 +3364,75 @@
- * END OF HARDWARE AND SOFTWARE OPTIONS
- ******************************************************************************/
-
-+#ifdef PNG_APNG_SUPPORTED
-+PNG_EXPORT(260, png_uint_32, png_get_acTL, (png_structp png_ptr,
-+ png_infop info_ptr, png_uint_32 *num_frames, png_uint_32 *num_plays));
-+
-+PNG_EXPORT(261, png_uint_32, png_set_acTL, (png_structp png_ptr,
-+ png_infop info_ptr, png_uint_32 num_frames, png_uint_32 num_plays));
-+
-+PNG_EXPORT(262, png_uint_32, png_get_num_frames, (png_structp png_ptr,
-+ png_infop info_ptr));
-+
-+PNG_EXPORT(263, png_uint_32, png_get_num_plays, (png_structp png_ptr,
-+ png_infop info_ptr));
-+
-+PNG_EXPORT(264, png_uint_32, png_get_next_frame_fcTL,
-+ (png_structp png_ptr, png_infop info_ptr, png_uint_32 *width,
-+ png_uint_32 *height, png_uint_32 *x_offset, png_uint_32 *y_offset,
-+ png_uint_16 *delay_num, png_uint_16 *delay_den, png_byte *dispose_op,
-+ png_byte *blend_op));
-+
-+PNG_EXPORT(265, png_uint_32, png_set_next_frame_fcTL,
-+ (png_structp png_ptr, png_infop info_ptr, png_uint_32 width,
-+ png_uint_32 height, png_uint_32 x_offset, png_uint_32 y_offset,
-+ png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op,
-+ png_byte blend_op));
-+
-+PNG_EXPORT(266, png_uint_32, png_get_next_frame_width,
-+ (png_structp png_ptr, png_infop info_ptr));
-+PNG_EXPORT(267, png_uint_32, png_get_next_frame_height,
-+ (png_structp png_ptr, png_infop info_ptr));
-+PNG_EXPORT(268, png_uint_32, png_get_next_frame_x_offset,
-+ (png_structp png_ptr, png_infop info_ptr));
-+PNG_EXPORT(269, png_uint_32, png_get_next_frame_y_offset,
-+ (png_structp png_ptr, png_infop info_ptr));
-+PNG_EXPORT(270, png_uint_16, png_get_next_frame_delay_num,
-+ (png_structp png_ptr, png_infop info_ptr));
-+PNG_EXPORT(271, png_uint_16, png_get_next_frame_delay_den,
-+ (png_structp png_ptr, png_infop info_ptr));
-+PNG_EXPORT(272, png_byte, png_get_next_frame_dispose_op,
-+ (png_structp png_ptr, png_infop info_ptr));
-+PNG_EXPORT(273, png_byte, png_get_next_frame_blend_op,
-+ (png_structp png_ptr, png_infop info_ptr));
-+PNG_EXPORT(274, png_byte, png_get_first_frame_is_hidden,
-+ (png_structp png_ptr, png_infop info_ptr));
-+PNG_EXPORT(275, png_uint_32, png_set_first_frame_is_hidden,
-+ (png_structp png_ptr, png_infop info_ptr, png_byte is_hidden));
-+
-+#ifdef PNG_READ_APNG_SUPPORTED
-+PNG_EXPORT(276, void, png_read_frame_head, (png_structp png_ptr,
-+ png_infop info_ptr));
-+#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
-+PNG_EXPORT(277, void, png_set_progressive_frame_fn, (png_structp png_ptr,
-+ png_progressive_frame_ptr frame_info_fn,
-+ png_progressive_frame_ptr frame_end_fn));
-+#endif /* PROGRESSIVE_READ */
-+#endif /* READ_APNG */
-+
-+#ifdef PNG_WRITE_APNG_SUPPORTED
-+PNG_EXPORT(278, void, png_write_frame_head, (png_structp png_ptr,
-+ png_infop info_ptr, png_bytepp row_pointers,
-+ png_uint_32 width, png_uint_32 height,
-+ png_uint_32 x_offset, png_uint_32 y_offset,
-+ png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op,
-+ png_byte blend_op));
-+
-+PNG_EXPORT(279, void, png_write_frame_tail, (png_structp png_ptr,
-+ png_infop info_ptr));
-+#endif /* WRITE_APNG */
-+#endif /* APNG */
-+
- /* Maintainer: Put new public prototypes here ^, in libpng.3, in project
- * defs, and in scripts/symbols.def.
- */
-@@ -3346,7 +3441,11 @@
- * one to use is one more than this.)
- */
- #ifdef PNG_EXPORT_LAST_ORDINAL
-+#ifdef PNG_APNG_SUPPORTED
-+ PNG_EXPORT_LAST_ORDINAL(279);
-+#else
- PNG_EXPORT_LAST_ORDINAL(259);
-+#endif /* APNG */
- #endif
-
- #ifdef __cplusplus
-Index: pngpriv.h
-===================================================================
---- a/pngpriv.h
-+++ b/pngpriv.h
-@@ -620,6 +620,10 @@
- #define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000U /* Have another chunk after IDAT */
- #define PNG_WROTE_eXIf 0x4000U
- #define PNG_IS_READ_STRUCT 0x8000U /* Else is a write struct */
-+#ifdef PNG_APNG_SUPPORTED
-+#define PNG_HAVE_acTL 0x10000U
-+#define PNG_HAVE_fcTL 0x20000U
-+#endif
-
- /* Flags for the transformations the PNG library does on the image data */
- #define PNG_BGR 0x0001U
-@@ -861,6 +865,16 @@
- #define png_tRNS PNG_U32(116, 82, 78, 83)
- #define png_zTXt PNG_U32(122, 84, 88, 116)
-
-+#ifdef PNG_APNG_SUPPORTED
-+#define png_acTL PNG_U32( 97, 99, 84, 76)
-+#define png_fcTL PNG_U32(102, 99, 84, 76)
-+#define png_fdAT PNG_U32(102, 100, 65, 84)
-+
-+/* For png_struct.apng_flags: */
-+#define PNG_FIRST_FRAME_HIDDEN 0x0001U
-+#define PNG_APNG_APP 0x0002U
-+#endif
-+
- /* The following will work on (signed char*) strings, whereas the get_uint_32
- * macro will fail on top-bit-set values because of the sign extension.
- */
-@@ -1689,6 +1703,49 @@
-
- #endif /* PROGRESSIVE_READ */
-
-+#ifdef PNG_APNG_SUPPORTED
-+PNG_INTERNAL_FUNCTION(void,png_ensure_fcTL_is_valid,(png_structp png_ptr,
-+ png_uint_32 width, png_uint_32 height,
-+ png_uint_32 x_offset, png_uint_32 y_offset,
-+ png_uint_16 delay_num, png_uint_16 delay_den,
-+ png_byte dispose_op, png_byte blend_op),PNG_EMPTY);
-+
-+#ifdef PNG_READ_APNG_SUPPORTED
-+PNG_INTERNAL_FUNCTION(void,png_handle_acTL,(png_structp png_ptr,
-+ png_infop info_ptr, png_uint_32 length),PNG_EMPTY);
-+PNG_INTERNAL_FUNCTION(void,png_handle_fcTL,(png_structp png_ptr,
-+ png_infop info_ptr, png_uint_32 length),PNG_EMPTY);
-+PNG_INTERNAL_FUNCTION(void,png_handle_fdAT,(png_structp png_ptr,
-+ png_infop info_ptr, png_uint_32 length),PNG_EMPTY);
-+PNG_INTERNAL_FUNCTION(void,png_have_info,(png_structp png_ptr,
-+ png_infop info_ptr),PNG_EMPTY);
-+PNG_INTERNAL_FUNCTION(void,png_ensure_sequence_number,(png_structp png_ptr,
-+ png_uint_32 length),PNG_EMPTY);
-+PNG_INTERNAL_FUNCTION(void,png_read_reset,(png_structp png_ptr),PNG_EMPTY);
-+PNG_INTERNAL_FUNCTION(void,png_read_reinit,(png_structp png_ptr,
-+ png_infop info_ptr),PNG_EMPTY);
-+#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
-+PNG_INTERNAL_FUNCTION(void,png_progressive_read_reset,(png_structp png_ptr),
-+ PNG_EMPTY);
-+#endif /* PROGRESSIVE_READ */
-+#endif /* READ_APNG */
-+
-+#ifdef PNG_WRITE_APNG_SUPPORTED
-+PNG_INTERNAL_FUNCTION(void,png_write_acTL,(png_structp png_ptr,
-+ png_uint_32 num_frames, png_uint_32 num_plays),PNG_EMPTY);
-+PNG_INTERNAL_FUNCTION(void,png_write_fcTL,(png_structp png_ptr,
-+ png_uint_32 width, png_uint_32 height,
-+ png_uint_32 x_offset, png_uint_32 y_offset,
-+ png_uint_16 delay_num, png_uint_16 delay_den,
-+ png_byte dispose_op, png_byte blend_op),PNG_EMPTY);
-+PNG_INTERNAL_FUNCTION(void,png_write_fdAT,(png_structp png_ptr,
-+ png_const_bytep data, size_t length),PNG_EMPTY);
-+PNG_INTERNAL_FUNCTION(void,png_write_reset,(png_structp png_ptr),PNG_EMPTY);
-+PNG_INTERNAL_FUNCTION(void,png_write_reinit,(png_structp png_ptr,
-+ png_infop info_ptr, png_uint_32 width, png_uint_32 height),PNG_EMPTY);
-+#endif /* WRITE_APNG */
-+#endif /* APNG */
-+
- /* Added at libpng version 1.6.0 */
- #ifdef PNG_GAMMA_SUPPORTED
- PNG_INTERNAL_FUNCTION(void,png_colorspace_set_gamma,(png_const_structrp png_ptr,
-Index: pnginfo.h
-===================================================================
---- a/pnginfo.h
-+++ b/pnginfo.h
-@@ -288,5 +288,18 @@
- png_bytepp row_pointers; /* the image bits */
- #endif
-
-+#ifdef PNG_APNG_SUPPORTED
-+ png_uint_32 num_frames; /* including default image */
-+ png_uint_32 num_plays;
-+ png_uint_32 next_frame_width;
-+ png_uint_32 next_frame_height;
-+ png_uint_32 next_frame_x_offset;
-+ png_uint_32 next_frame_y_offset;
-+ png_uint_16 next_frame_delay_num;
-+ png_uint_16 next_frame_delay_den;
-+ png_byte next_frame_dispose_op;
-+ png_byte next_frame_blend_op;
-+#endif
-+
- };
- #endif /* PNGINFO_H */
-Index: pngstruct.h
-===================================================================
---- a/pngstruct.h
-+++ b/pngstruct.h
-@@ -398,6 +398,27 @@
- png_byte filter_type;
- #endif
-
-+#ifdef PNG_APNG_SUPPORTED
-+ png_uint_32 apng_flags;
-+ png_uint_32 next_seq_num; /* next fcTL/fdAT chunk sequence number */
-+ png_uint_32 first_frame_width;
-+ png_uint_32 first_frame_height;
-+
-+#ifdef PNG_READ_APNG_SUPPORTED
-+ png_uint_32 num_frames_read; /* incremented after all image data of */
-+ /* a frame is read */
-+#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
-+ png_progressive_frame_ptr frame_info_fn; /* frame info read callback */
-+ png_progressive_frame_ptr frame_end_fn; /* frame data read callback */
-+#endif
-+#endif
-+
-+#ifdef PNG_WRITE_APNG_SUPPORTED
-+ png_uint_32 num_frames_to_write;
-+ png_uint_32 num_frames_written;
-+#endif
-+#endif /* APNG */
-+
- /* New members added in libpng-1.2.0 */
-
- /* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */
-Index: pngwrite.c
-===================================================================
---- a/pngwrite.c
-+++ b/pngwrite.c
-@@ -127,6 +127,10 @@
- * the application continues writing the PNG. So check the 'invalid'
- * flag here too.
- */
-+#ifdef PNG_WRITE_APNG_SUPPORTED
-+ if ((info_ptr->valid & PNG_INFO_acTL) != 0)
-+ png_write_acTL(png_ptr, info_ptr->num_frames, info_ptr->num_plays);
-+#endif
- #ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
- /* Write unknown chunks first; PNG v3 establishes a precedence order
- * for colourspace chunks. It is certain therefore that new
-@@ -422,6 +426,11 @@
- if ((png_ptr->mode & PNG_HAVE_IDAT) == 0)
- png_error(png_ptr, "No IDATs written into file");
-
-+#ifdef PNG_WRITE_APNG_SUPPORTED
-+ if (png_ptr->num_frames_written != png_ptr->num_frames_to_write)
-+ png_error(png_ptr, "Not enough frames written");
-+#endif
-+
- #ifdef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
- if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
- png_ptr->num_palette_max >= png_ptr->num_palette)
-@@ -2469,4 +2478,42 @@
- }
- #endif /* SIMPLIFIED_WRITE_STDIO */
- #endif /* SIMPLIFIED_WRITE */
-+
-+#ifdef PNG_WRITE_APNG_SUPPORTED
-+void PNGAPI
-+png_write_frame_head(png_structp png_ptr, png_infop info_ptr,
-+ png_bytepp row_pointers, png_uint_32 width, png_uint_32 height,
-+ png_uint_32 x_offset, png_uint_32 y_offset,
-+ png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op,
-+ png_byte blend_op)
-+{
-+ png_debug(1, "in png_write_frame_head");
-+
-+ /* there is a chance this has been set after png_write_info was called,
-+ * so it would be set but not written. is there a way to be sure? */
-+ if ((info_ptr->valid & PNG_INFO_acTL) == 0)
-+ png_error(png_ptr, "png_write_frame_head(): acTL not set");
-+
-+ png_write_reset(png_ptr);
-+
-+ png_write_reinit(png_ptr, info_ptr, width, height);
-+
-+ if ((png_ptr->apng_flags & PNG_FIRST_FRAME_HIDDEN) == 0 ||
-+ png_ptr->num_frames_written != 0)
-+ png_write_fcTL(png_ptr, width, height, x_offset, y_offset,
-+ delay_num, delay_den, dispose_op, blend_op);
-+
-+ PNG_UNUSED(row_pointers)
-+}
-+
-+void PNGAPI
-+png_write_frame_tail(png_structp png_ptr, png_infop info_ptr)
-+{
-+ png_debug(1, "in png_write_frame_tail");
-+
-+ png_ptr->num_frames_written++;
-+
-+ PNG_UNUSED(info_ptr)
-+}
-+#endif /* WRITE_APNG */
- #endif /* WRITE */
-Index: pngpread.c
-===================================================================
---- a/pngpread.c
-+++ b/pngpread.c
-@@ -209,6 +209,89 @@
-
- chunk_name = png_ptr->chunk_name;
-
-+#ifdef PNG_READ_APNG_SUPPORTED
-+ if (png_ptr->num_frames_read > 0 &&
-+ png_ptr->num_frames_read < info_ptr->num_frames)
-+ {
-+ if (chunk_name == png_IDAT)
-+ {
-+ /* Discard trailing IDATs for the first frame */
-+ if ((png_ptr->mode & PNG_HAVE_fcTL) != 0 ||
-+ png_ptr->num_frames_read > 1)
-+ png_error(png_ptr, "out of place IDAT");
-+
-+ PNG_PUSH_SAVE_BUFFER_IF_FULL
-+ png_crc_finish(png_ptr, png_ptr->push_length);
-+ png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
-+ }
-+
-+ else if (chunk_name == png_fdAT)
-+ {
-+ PNG_PUSH_SAVE_BUFFER_IF_LT(4)
-+ png_ensure_sequence_number(png_ptr, 4);
-+
-+ if ((png_ptr->mode & PNG_HAVE_fcTL) == 0)
-+ {
-+ /* Discard trailing fdATs for frames other than the first */
-+ if (png_ptr->num_frames_read < 2)
-+ png_error(png_ptr, "out of place fdAT");
-+
-+ PNG_PUSH_SAVE_BUFFER_IF_FULL
-+ png_crc_finish(png_ptr, png_ptr->push_length);
-+ png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
-+ }
-+
-+ else
-+ {
-+ /* frame data follows */
-+ png_ptr->idat_size = png_ptr->push_length - 4;
-+ png_ptr->mode |= PNG_HAVE_IDAT;
-+ png_ptr->process_mode = PNG_READ_IDAT_MODE;
-+ }
-+ }
-+
-+ else if (chunk_name == png_fcTL)
-+ {
-+ PNG_PUSH_SAVE_BUFFER_IF_FULL
-+ png_read_reset(png_ptr);
-+ png_ptr->mode &= ~PNG_HAVE_fcTL;
-+
-+ png_handle_fcTL(png_ptr, info_ptr, png_ptr->push_length);
-+
-+ if ((png_ptr->mode & PNG_HAVE_fcTL) == 0)
-+ png_error(png_ptr, "missing required fcTL chunk");
-+
-+ png_read_reinit(png_ptr, info_ptr);
-+ png_progressive_read_reset(png_ptr);
-+
-+ if (png_ptr->frame_info_fn != NULL)
-+ (*(png_ptr->frame_info_fn))(png_ptr, png_ptr->num_frames_read);
-+
-+ png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
-+ }
-+
-+ else if (chunk_name == png_IEND)
-+ {
-+ PNG_PUSH_SAVE_BUFFER_IF_FULL
-+ png_warning(png_ptr, "Number of actual frames fewer than expected");
-+ png_crc_finish(png_ptr, png_ptr->push_length);
-+ png_ptr->process_mode = PNG_READ_DONE_MODE;
-+ png_push_have_end(png_ptr, info_ptr);
-+ }
-+
-+ else
-+ {
-+ PNG_PUSH_SAVE_BUFFER_IF_FULL
-+ png_warning(png_ptr, "Skipped (ignored) a chunk "
-+ "between APNG chunks");
-+ png_crc_finish(png_ptr, png_ptr->push_length);
-+ png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
-+ }
-+
-+ return;
-+ }
-+#endif /* READ_APNG */
-+
- if (chunk_name == png_IDAT)
- {
- if ((png_ptr->mode & PNG_AFTER_IDAT) != 0)
-@@ -275,6 +358,9 @@
-
- else if (chunk_name == png_IDAT)
- {
-+#ifdef PNG_READ_APNG_SUPPORTED
-+ png_have_info(png_ptr, info_ptr);
-+#endif
- png_ptr->idat_size = png_ptr->push_length;
- png_ptr->process_mode = PNG_READ_IDAT_MODE;
- png_push_have_info(png_ptr, info_ptr);
-@@ -453,6 +539,20 @@
- }
- #endif
-
-+#ifdef PNG_READ_APNG_SUPPORTED
-+ else if (chunk_name == png_acTL)
-+ {
-+ PNG_PUSH_SAVE_BUFFER_IF_FULL
-+ png_handle_acTL(png_ptr, info_ptr, png_ptr->push_length);
-+ }
-+
-+ else if (chunk_name == png_fcTL)
-+ {
-+ PNG_PUSH_SAVE_BUFFER_IF_FULL
-+ png_handle_fcTL(png_ptr, info_ptr, png_ptr->push_length);
-+ }
-+
-+#endif /* READ_APNG */
- else
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
-@@ -585,7 +685,11 @@
- png_byte chunk_tag[4];
-
- /* TODO: this code can be commoned up with the same code in push_read */
-+#ifdef PNG_READ_APNG_SUPPORTED
-+ PNG_PUSH_SAVE_BUFFER_IF_LT(12)
-+#else
- PNG_PUSH_SAVE_BUFFER_IF_LT(8)
-+#endif
- png_push_fill_buffer(png_ptr, chunk_length, 4);
- png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length);
- png_reset_crc(png_ptr);
-@@ -593,17 +697,60 @@
- png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(chunk_tag);
- png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
-
-+#ifdef PNG_READ_APNG_SUPPORTED
-+ if (png_ptr->chunk_name != png_fdAT && png_ptr->num_frames_read > 0)
-+ {
-+ if ((png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED) != 0)
-+ {
-+ png_ptr->process_mode = PNG_READ_CHUNK_MODE;
-+ if (png_ptr->frame_end_fn != NULL)
-+ (*(png_ptr->frame_end_fn))(png_ptr, png_ptr->num_frames_read);
-+ png_ptr->num_frames_read++;
-+ return;
-+ }
-+ else
-+ {
-+ if (png_ptr->chunk_name == png_IEND)
-+ png_error(png_ptr, "Not enough image data");
-+ PNG_PUSH_SAVE_BUFFER_IF_FULL
-+ png_warning(png_ptr, "Skipping (ignoring) a chunk between "
-+ "APNG chunks");
-+ png_crc_finish(png_ptr, png_ptr->push_length);
-+ png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
-+ return;
-+ }
-+ }
-+ else
-+#endif
-+#ifdef PNG_READ_APNG_SUPPORTED
-+ if (png_ptr->chunk_name != png_IDAT && png_ptr->num_frames_read == 0)
-+#else
- if (png_ptr->chunk_name != png_IDAT)
-+#endif
- {
- png_ptr->process_mode = PNG_READ_CHUNK_MODE;
-
- if ((png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED) == 0)
- png_error(png_ptr, "Not enough compressed data");
-
-+#ifdef PNG_READ_APNG_SUPPORTED
-+ if (png_ptr->frame_end_fn != NULL)
-+ (*(png_ptr->frame_end_fn))(png_ptr, png_ptr->num_frames_read);
-+ png_ptr->num_frames_read++;
-+#endif
-+
- return;
- }
-
- png_ptr->idat_size = png_ptr->push_length;
-+
-+#ifdef PNG_READ_APNG_SUPPORTED
-+ if (png_ptr->num_frames_read > 0)
-+ {
-+ png_ensure_sequence_number(png_ptr, 4);
-+ png_ptr->idat_size -= 4;
-+ }
-+#endif
- }
-
- if (png_ptr->idat_size != 0 && png_ptr->save_buffer_size != 0)
-@@ -677,6 +824,16 @@
- if (!(buffer_length > 0) || buffer == NULL)
- png_error(png_ptr, "No IDAT data (internal error)");
-
-+#ifdef PNG_READ_APNG_SUPPORTED
-+ /* If the app is not APNG-aware, decode only the first frame */
-+ if ((png_ptr->apng_flags & PNG_APNG_APP) == 0 &&
-+ png_ptr->num_frames_read > 0)
-+ {
-+ png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED;
-+ return;
-+ }
-+#endif
-+
- /* This routine must process all the data it has been given
- * before returning, calling the row callback as required to
- * handle the uncompressed results.
-@@ -1110,6 +1267,18 @@
- png_set_read_fn(png_ptr, progressive_ptr, png_push_fill_buffer);
- }
-
-+#ifdef PNG_READ_APNG_SUPPORTED
-+void PNGAPI
-+png_set_progressive_frame_fn(png_structp png_ptr,
-+ png_progressive_frame_ptr frame_info_fn,
-+ png_progressive_frame_ptr frame_end_fn)
-+{
-+ png_ptr->frame_info_fn = frame_info_fn;
-+ png_ptr->frame_end_fn = frame_end_fn;
-+ png_ptr->apng_flags |= PNG_APNG_APP;
-+}
-+#endif
-+
- png_voidp PNGAPI
- png_get_progressive_ptr(png_const_structrp png_ptr)
- {
-Index: pngset.c
-===================================================================
---- a/pngset.c
-+++ b/pngset.c
-@@ -457,6 +457,11 @@
- info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth);
-
- info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, width);
-+
-+#ifdef PNG_APNG_SUPPORTED
-+ /* for non-animated png. this may be overwritten from an acTL chunk later */
-+ info_ptr->num_frames = 1;
-+#endif
- }
-
- #ifdef PNG_oFFs_SUPPORTED
-@@ -1328,6 +1333,146 @@
- }
- #endif /* sPLT */
-
-+#ifdef PNG_APNG_SUPPORTED
-+png_uint_32 PNGAPI
-+png_set_acTL(png_structp png_ptr, png_infop info_ptr,
-+ png_uint_32 num_frames, png_uint_32 num_plays)
-+{
-+ png_debug1(1, "in %s storage function", "acTL");
-+
-+ if (png_ptr == NULL || info_ptr == NULL)
-+ {
-+ png_warning(png_ptr,
-+ "Call to png_set_acTL() with NULL png_ptr "
-+ "or info_ptr ignored");
-+ return (0);
-+ }
-+ if (num_frames == 0)
-+ {
-+ png_warning(png_ptr,
-+ "Ignoring attempt to set acTL with num_frames zero");
-+ return (0);
-+ }
-+ if (num_frames > PNG_UINT_31_MAX)
-+ {
-+ png_warning(png_ptr,
-+ "Ignoring attempt to set acTL with num_frames > 2^31-1");
-+ return (0);
-+ }
-+ if (num_plays > PNG_UINT_31_MAX)
-+ {
-+ png_warning(png_ptr,
-+ "Ignoring attempt to set acTL with num_plays > 2^31-1");
-+ return (0);
-+ }
-+
-+ info_ptr->num_frames = num_frames;
-+ info_ptr->num_plays = num_plays;
-+
-+ info_ptr->valid |= PNG_INFO_acTL;
-+
-+ return (1);
-+}
-+
-+/* delay_num and delay_den can hold any 16-bit values including zero */
-+png_uint_32 PNGAPI
-+png_set_next_frame_fcTL(png_structp png_ptr, png_infop info_ptr,
-+ png_uint_32 width, png_uint_32 height,
-+ png_uint_32 x_offset, png_uint_32 y_offset,
-+ png_uint_16 delay_num, png_uint_16 delay_den,
-+ png_byte dispose_op, png_byte blend_op)
-+{
-+ png_debug1(1, "in %s storage function", "fcTL");
-+
-+ if (png_ptr == NULL || info_ptr == NULL)
-+ {
-+ png_warning(png_ptr,
-+ "Call to png_set_fcTL() with NULL png_ptr or info_ptr "
-+ "ignored");
-+ return (0);
-+ }
-+
-+ png_ensure_fcTL_is_valid(png_ptr, width, height, x_offset, y_offset,
-+ delay_num, delay_den, dispose_op, blend_op);
-+
-+ if (blend_op == PNG_BLEND_OP_OVER)
-+ {
-+ if ((png_ptr->color_type & PNG_COLOR_MASK_ALPHA) == 0 &&
-+ png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS) == 0)
-+ {
-+ png_warning(png_ptr, "PNG_BLEND_OP_OVER is meaningless "
-+ "and wasteful for opaque images, ignored");
-+ blend_op = PNG_BLEND_OP_SOURCE;
-+ }
-+ }
-+
-+ info_ptr->next_frame_width = width;
-+ info_ptr->next_frame_height = height;
-+ info_ptr->next_frame_x_offset = x_offset;
-+ info_ptr->next_frame_y_offset = y_offset;
-+ info_ptr->next_frame_delay_num = delay_num;
-+ info_ptr->next_frame_delay_den = delay_den;
-+ info_ptr->next_frame_dispose_op = dispose_op;
-+ info_ptr->next_frame_blend_op = blend_op;
-+
-+ info_ptr->valid |= PNG_INFO_fcTL;
-+
-+ return (1);
-+}
-+
-+void /* PRIVATE */
-+png_ensure_fcTL_is_valid(png_structp png_ptr,
-+ png_uint_32 width, png_uint_32 height,
-+ png_uint_32 x_offset, png_uint_32 y_offset,
-+ png_uint_16 delay_num, png_uint_16 delay_den,
-+ png_byte dispose_op, png_byte blend_op)
-+{
-+ if (width == 0 || width > PNG_UINT_31_MAX)
-+ png_error(png_ptr, "invalid width in fcTL (0 or > 2^31-1)");
-+ if (height == 0 || height > PNG_UINT_31_MAX)
-+ png_error(png_ptr, "invalid height in fcTL (0 or > 2^31-1)");
-+ if (x_offset > PNG_UINT_31_MAX)
-+ png_error(png_ptr, "invalid x_offset in fcTL (> 2^31-1)");
-+ if (y_offset > PNG_UINT_31_MAX)
-+ png_error(png_ptr, "invalid y_offset in fcTL (> 2^31-1)");
-+ if (width + x_offset > png_ptr->first_frame_width ||
-+ height + y_offset > png_ptr->first_frame_height)
-+ png_error(png_ptr, "dimensions of a frame are greater than "
-+ "the ones in IHDR");
-+
-+ if (dispose_op != PNG_DISPOSE_OP_NONE &&
-+ dispose_op != PNG_DISPOSE_OP_BACKGROUND &&
-+ dispose_op != PNG_DISPOSE_OP_PREVIOUS)
-+ png_error(png_ptr, "invalid dispose_op in fcTL");
-+
-+ if (blend_op != PNG_BLEND_OP_SOURCE &&
-+ blend_op != PNG_BLEND_OP_OVER)
-+ png_error(png_ptr, "invalid blend_op in fcTL");
-+
-+ PNG_UNUSED(delay_num)
-+ PNG_UNUSED(delay_den)
-+}
-+
-+png_uint_32 PNGAPI
-+png_set_first_frame_is_hidden(png_structp png_ptr, png_infop info_ptr,
-+ png_byte is_hidden)
-+{
-+ png_debug(1, "in png_first_frame_is_hidden()");
-+
-+ if (png_ptr == NULL)
-+ return 0;
-+
-+ if (is_hidden != 0)
-+ png_ptr->apng_flags |= PNG_FIRST_FRAME_HIDDEN;
-+ else
-+ png_ptr->apng_flags &= ~PNG_FIRST_FRAME_HIDDEN;
-+
-+ PNG_UNUSED(info_ptr)
-+
-+ return 1;
-+}
-+#endif /* APNG */
-+
- #ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
- static png_byte
- check_location(png_const_structrp png_ptr, int location)
-Index: pngrutil.c
-===================================================================
---- a/pngrutil.c
-+++ b/pngrutil.c
-@@ -877,6 +877,11 @@
- filter_type = buf[11];
- interlace_type = buf[12];
-
-+#ifdef PNG_READ_APNG_SUPPORTED
-+ png_ptr->first_frame_width = width;
-+ png_ptr->first_frame_height = height;
-+#endif
-+
- /* Set internal variables */
- png_ptr->width = width;
- png_ptr->height = height;
-@@ -3017,6 +3022,180 @@
- }
- #endif
-
-+#ifdef PNG_READ_APNG_SUPPORTED
-+void /* PRIVATE */
-+png_handle_acTL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
-+{
-+ png_byte data[8];
-+ png_uint_32 num_frames;
-+ png_uint_32 num_plays;
-+ png_uint_32 didSet;
-+
-+ png_debug(1, "in png_handle_acTL");
-+
-+ if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
-+ {
-+ png_error(png_ptr, "Missing IHDR before acTL");
-+ }
-+ else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
-+ {
-+ png_warning(png_ptr, "Invalid acTL after IDAT skipped");
-+ png_crc_finish(png_ptr, length);
-+ return;
-+ }
-+ else if ((png_ptr->mode & PNG_HAVE_acTL) != 0)
-+ {
-+ png_warning(png_ptr, "Duplicate acTL skipped");
-+ png_crc_finish(png_ptr, length);
-+ return;
-+ }
-+ else if (length != 8)
-+ {
-+ png_warning(png_ptr, "acTL with invalid length skipped");
-+ png_crc_finish(png_ptr, length);
-+ return;
-+ }
-+
-+ png_crc_read(png_ptr, data, 8);
-+ png_crc_finish(png_ptr, 0);
-+
-+ num_frames = png_get_uint_31(png_ptr, data);
-+ num_plays = png_get_uint_31(png_ptr, data + 4);
-+
-+ /* the set function will do error checking on num_frames */
-+ didSet = png_set_acTL(png_ptr, info_ptr, num_frames, num_plays);
-+ if (didSet != 0)
-+ png_ptr->mode |= PNG_HAVE_acTL;
-+}
-+
-+void /* PRIVATE */
-+png_handle_fcTL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
-+{
-+ png_byte data[22];
-+ png_uint_32 width;
-+ png_uint_32 height;
-+ png_uint_32 x_offset;
-+ png_uint_32 y_offset;
-+ png_uint_16 delay_num;
-+ png_uint_16 delay_den;
-+ png_byte dispose_op;
-+ png_byte blend_op;
-+
-+ png_debug(1, "in png_handle_fcTL");
-+
-+ png_ensure_sequence_number(png_ptr, length);
-+
-+ if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
-+ {
-+ png_error(png_ptr, "Missing IHDR before fcTL");
-+ }
-+ else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
-+ {
-+ /* for any frames other then the first this message may be misleading,
-+ * but correct. PNG_HAVE_IDAT is unset before the frame head is read
-+ * i can't think of a better message */
-+ png_warning(png_ptr, "Invalid fcTL after IDAT skipped");
-+ png_crc_finish(png_ptr, length-4);
-+ return;
-+ }
-+ else if ((png_ptr->mode & PNG_HAVE_fcTL) != 0)
-+ {
-+ png_warning(png_ptr, "Duplicate fcTL within one frame skipped");
-+ png_crc_finish(png_ptr, length-4);
-+ return;
-+ }
-+ else if (length != 26)
-+ {
-+ png_warning(png_ptr, "fcTL with invalid length skipped");
-+ png_crc_finish(png_ptr, length-4);
-+ return;
-+ }
-+
-+ png_crc_read(png_ptr, data, 22);
-+ png_crc_finish(png_ptr, 0);
-+
-+ width = png_get_uint_31(png_ptr, data);
-+ height = png_get_uint_31(png_ptr, data + 4);
-+ x_offset = png_get_uint_31(png_ptr, data + 8);
-+ y_offset = png_get_uint_31(png_ptr, data + 12);
-+ delay_num = png_get_uint_16(data + 16);
-+ delay_den = png_get_uint_16(data + 18);
-+ dispose_op = data[20];
-+ blend_op = data[21];
-+
-+ if (png_ptr->num_frames_read == 0 && (x_offset != 0 || y_offset != 0))
-+ {
-+ png_warning(png_ptr, "fcTL for the first frame must have zero offset");
-+ return;
-+ }
-+
-+ if (info_ptr != NULL)
-+ {
-+ if (png_ptr->num_frames_read == 0 &&
-+ (width != info_ptr->width || height != info_ptr->height))
-+ {
-+ png_warning(png_ptr, "size in first frame's fcTL must match "
-+ "the size in IHDR");
-+ return;
-+ }
-+
-+ /* The set function will do more error checking */
-+ png_set_next_frame_fcTL(png_ptr, info_ptr, width, height,
-+ x_offset, y_offset, delay_num, delay_den,
-+ dispose_op, blend_op);
-+
-+ png_read_reinit(png_ptr, info_ptr);
-+
-+ png_ptr->mode |= PNG_HAVE_fcTL;
-+ }
-+}
-+
-+void /* PRIVATE */
-+png_have_info(png_structp png_ptr, png_infop info_ptr)
-+{
-+ if ((info_ptr->valid & PNG_INFO_acTL) != 0 &&
-+ (info_ptr->valid & PNG_INFO_fcTL) == 0)
-+ {
-+ png_ptr->apng_flags |= PNG_FIRST_FRAME_HIDDEN;
-+ info_ptr->num_frames++;
-+ }
-+}
-+
-+void /* PRIVATE */
-+png_handle_fdAT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
-+{
-+ png_ensure_sequence_number(png_ptr, length);
-+
-+ /* This function is only called from png_read_end(), png_read_info(),
-+ * and png_push_read_chunk() which means that:
-+ * - the user doesn't want to read this frame
-+ * - or this is an out-of-place fdAT
-+ * in either case it is safe to ignore the chunk with a warning */
-+ png_warning(png_ptr, "ignoring fdAT chunk");
-+ png_crc_finish(png_ptr, length - 4);
-+ PNG_UNUSED(info_ptr)
-+}
-+
-+void /* PRIVATE */
-+png_ensure_sequence_number(png_structp png_ptr, png_uint_32 length)
-+{
-+ png_byte data[4];
-+ png_uint_32 sequence_number;
-+
-+ if (length < 4)
-+ png_error(png_ptr, "invalid fcTL or fdAT chunk found");
-+
-+ png_crc_read(png_ptr, data, 4);
-+ sequence_number = png_get_uint_31(png_ptr, data);
-+
-+ if (sequence_number != png_ptr->next_seq_num)
-+ png_error(png_ptr, "fcTL or fdAT chunk with out-of-order sequence "
-+ "number found");
-+
-+ png_ptr->next_seq_num++;
-+}
-+#endif /* READ_APNG */
-+
- #ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
- /* Utility function for png_handle_unknown; set up png_ptr::unknown_chunk */
- static int
-@@ -3322,7 +3501,11 @@
- if (PNG_USER_CHUNK_MALLOC_MAX < limit)
- limit = PNG_USER_CHUNK_MALLOC_MAX;
- # endif
-+#ifdef PNG_READ_APNG_SUPPORTED
-+ if (png_ptr->chunk_name == png_IDAT || png_ptr->chunk_name == png_fdAT)
-+#else
- if (png_ptr->chunk_name == png_IDAT)
-+#endif
- {
- png_alloc_size_t idat_limit = PNG_UINT_31_MAX;
- size_t row_factor =
-@@ -4322,6 +4505,38 @@
- uInt avail_in;
- png_bytep buffer;
-
-+#ifdef PNG_READ_APNG_SUPPORTED
-+ png_uint_32 bytes_to_skip = 0;
-+
-+ while (png_ptr->idat_size == 0 || bytes_to_skip != 0)
-+ {
-+ png_crc_finish(png_ptr, bytes_to_skip);
-+ bytes_to_skip = 0;
-+
-+ png_ptr->idat_size = png_read_chunk_header(png_ptr);
-+ if (png_ptr->num_frames_read == 0)
-+ {
-+ if (png_ptr->chunk_name != png_IDAT)
-+ png_error(png_ptr, "Not enough image data");
-+ }
-+ else
-+ {
-+ if (png_ptr->chunk_name == png_IEND)
-+ png_error(png_ptr, "Not enough image data");
-+ if (png_ptr->chunk_name != png_fdAT)
-+ {
-+ png_warning(png_ptr, "Skipped (ignored) a chunk "
-+ "between APNG chunks");
-+ bytes_to_skip = png_ptr->idat_size;
-+ continue;
-+ }
-+
-+ png_ensure_sequence_number(png_ptr, png_ptr->idat_size);
-+
-+ png_ptr->idat_size -= 4;
-+ }
-+ }
-+#else
- while (png_ptr->idat_size == 0)
- {
- png_crc_finish(png_ptr, 0);
-@@ -4333,6 +4548,7 @@
- if (png_ptr->chunk_name != png_IDAT)
- png_error(png_ptr, "Not enough image data");
- }
-+#endif /* READ_APNG */
-
- avail_in = png_ptr->IDAT_read_size;
-
-@@ -4396,6 +4612,9 @@
-
- png_ptr->mode |= PNG_AFTER_IDAT;
- png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED;
-+#ifdef PNG_READ_APNG_SUPPORTED
-+ png_ptr->num_frames_read++;
-+#endif
-
- if (png_ptr->zstream.avail_in > 0 || png_ptr->idat_size > 0)
- png_chunk_benign_error(png_ptr, "Extra compressed data");
-@@ -4805,4 +5024,80 @@
-
- png_ptr->flags |= PNG_FLAG_ROW_INIT;
- }
-+
-+#ifdef PNG_READ_APNG_SUPPORTED
-+/* This function is to be called after the main IDAT set has been read and
-+ * before a new IDAT is read. It resets some parts of png_ptr
-+ * to make them usable by the read functions again */
-+void /* PRIVATE */
-+png_read_reset(png_structp png_ptr)
-+{
-+ png_ptr->mode &= ~PNG_HAVE_IDAT;
-+ png_ptr->mode &= ~PNG_AFTER_IDAT;
-+ png_ptr->row_number = 0;
-+ png_ptr->pass = 0;
-+}
-+
-+void /* PRIVATE */
-+png_read_reinit(png_structp png_ptr, png_infop info_ptr)
-+{
-+ png_ptr->width = info_ptr->next_frame_width;
-+ png_ptr->height = info_ptr->next_frame_height;
-+ png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth,png_ptr->width);
-+ png_ptr->info_rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth,
-+ png_ptr->width);
-+ if (png_ptr->prev_row != NULL)
-+ memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
-+}
-+
-+#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
-+/* same as png_read_reset() but for the progressive reader */
-+void /* PRIVATE */
-+png_progressive_read_reset(png_structp png_ptr)
-+{
-+#ifdef PNG_READ_INTERLACING_SUPPORTED
-+ /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
-+
-+ /* Start of interlace block */
-+ static const png_byte png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
-+
-+ /* Offset to next interlace block */
-+ static const png_byte png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
-+
-+ /* Start of interlace block in the y direction */
-+ static const png_byte png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
-+
-+ /* Offset to next interlace block in the y direction */
-+ static const png_byte png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
-+
-+ if (png_ptr->interlaced != 0)
-+ {
-+ if ((png_ptr->transformations & PNG_INTERLACE) == 0)
-+ png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 -
-+ png_pass_ystart[0]) / png_pass_yinc[0];
-+ else
-+ png_ptr->num_rows = png_ptr->height;
-+
-+ png_ptr->iwidth = (png_ptr->width +
-+ png_pass_inc[png_ptr->pass] - 1 -
-+ png_pass_start[png_ptr->pass]) /
-+ png_pass_inc[png_ptr->pass];
-+ }
-+ else
-+#endif /* READ_INTERLACING */
-+ {
-+ png_ptr->num_rows = png_ptr->height;
-+ png_ptr->iwidth = png_ptr->width;
-+ }
-+ png_ptr->flags &= ~PNG_FLAG_ZSTREAM_ENDED;
-+ if (inflateReset(&(png_ptr->zstream)) != Z_OK)
-+ png_error(png_ptr, "inflateReset failed");
-+ png_ptr->zstream.avail_in = 0;
-+ png_ptr->zstream.next_in = 0;
-+ png_ptr->zstream.next_out = png_ptr->row_buf;
-+ png_ptr->zstream.avail_out = (uInt)PNG_ROWBYTES(png_ptr->pixel_depth,
-+ png_ptr->iwidth) + 1;
-+}
-+#endif /* PROGRESSIVE_READ */
-+#endif /* READ_APNG */
- #endif /* READ */
-Index: pngwutil.c
-===================================================================
---- a/pngwutil.c
-+++ b/pngwutil.c
-@@ -838,6 +838,11 @@
- /* Write the chunk */
- png_write_complete_chunk(png_ptr, png_IHDR, buf, 13);
-
-+#ifdef PNG_WRITE_APNG_SUPPORTED
-+ png_ptr->first_frame_width = width;
-+ png_ptr->first_frame_height = height;
-+#endif
-+
- if ((png_ptr->do_filter) == PNG_NO_FILTERS)
- {
- if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE ||
-@@ -1020,7 +1025,17 @@
- #endif
-
- if (size > 0)
-+#ifdef PNG_WRITE_APNG_SUPPORTED
-+ {
-+ if (png_ptr->num_frames_written == 0)
-+#endif
- png_write_complete_chunk(png_ptr, png_IDAT, data, size);
-+#ifdef PNG_WRITE_APNG_SUPPORTED
-+ else
-+ png_write_fdAT(png_ptr, data, size);
-+ }
-+#endif /* WRITE_APNG */
-+
- png_ptr->mode |= PNG_HAVE_IDAT;
-
- png_ptr->zstream.next_out = data;
-@@ -1067,7 +1082,17 @@
- #endif
-
- if (size > 0)
-+#ifdef PNG_WRITE_APNG_SUPPORTED
-+ {
-+ if (png_ptr->num_frames_written == 0)
-+#endif
- png_write_complete_chunk(png_ptr, png_IDAT, data, size);
-+#ifdef PNG_WRITE_APNG_SUPPORTED
-+ else
-+ png_write_fdAT(png_ptr, data, size);
-+ }
-+#endif /* WRITE_APNG */
-+
- png_ptr->zstream.avail_out = 0;
- png_ptr->zstream.next_out = NULL;
- png_ptr->mode |= PNG_HAVE_IDAT | PNG_AFTER_IDAT;
-@@ -1969,6 +1994,82 @@
- }
- #endif
-
-+#ifdef PNG_WRITE_APNG_SUPPORTED
-+void /* PRIVATE */
-+png_write_acTL(png_structp png_ptr,
-+ png_uint_32 num_frames, png_uint_32 num_plays)
-+{
-+ png_byte buf[8];
-+
-+ png_debug(1, "in png_write_acTL");
-+
-+ png_ptr->num_frames_to_write = num_frames;
-+
-+ if ((png_ptr->apng_flags & PNG_FIRST_FRAME_HIDDEN) != 0)
-+ num_frames--;
-+
-+ png_save_uint_32(buf, num_frames);
-+ png_save_uint_32(buf + 4, num_plays);
-+
-+ png_write_complete_chunk(png_ptr, png_acTL, buf, 8);
-+}
-+
-+void /* PRIVATE */
-+png_write_fcTL(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
-+ png_uint_32 x_offset, png_uint_32 y_offset,
-+ png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op,
-+ png_byte blend_op)
-+{
-+ png_byte buf[26];
-+
-+ png_debug(1, "in png_write_fcTL");
-+
-+ if (png_ptr->num_frames_written == 0 && (x_offset != 0 || y_offset != 0))
-+ png_error(png_ptr, "x and/or y offset for the first frame aren't 0");
-+ if (png_ptr->num_frames_written == 0 &&
-+ (width != png_ptr->first_frame_width ||
-+ height != png_ptr->first_frame_height))
-+ png_error(png_ptr, "width and/or height in the first frame's fcTL "
-+ "don't match the ones in IHDR");
-+
-+ /* more error checking */
-+ png_ensure_fcTL_is_valid(png_ptr, width, height, x_offset, y_offset,
-+ delay_num, delay_den, dispose_op, blend_op);
-+
-+ png_save_uint_32(buf, png_ptr->next_seq_num);
-+ png_save_uint_32(buf + 4, width);
-+ png_save_uint_32(buf + 8, height);
-+ png_save_uint_32(buf + 12, x_offset);
-+ png_save_uint_32(buf + 16, y_offset);
-+ png_save_uint_16(buf + 20, delay_num);
-+ png_save_uint_16(buf + 22, delay_den);
-+ buf[24] = dispose_op;
-+ buf[25] = blend_op;
-+
-+ png_write_complete_chunk(png_ptr, png_fcTL, buf, 26);
-+
-+ png_ptr->next_seq_num++;
-+}
-+
-+void /* PRIVATE */
-+png_write_fdAT(png_structp png_ptr,
-+ png_const_bytep data, size_t length)
-+{
-+ png_byte buf[4];
-+
-+ png_write_chunk_header(png_ptr, png_fdAT, (png_uint_32)(4 + length));
-+
-+ png_save_uint_32(buf, png_ptr->next_seq_num);
-+ png_write_chunk_data(png_ptr, buf, 4);
-+
-+ png_write_chunk_data(png_ptr, data, length);
-+
-+ png_write_chunk_end(png_ptr);
-+
-+ png_ptr->next_seq_num++;
-+}
-+#endif /* WRITE_APNG */
-+
- /* Initializes the row writing capability of libpng */
- void /* PRIVATE */
- png_write_start_row(png_structrp png_ptr)
-@@ -2822,4 +2923,39 @@
- }
- #endif /* WRITE_FLUSH */
- }
-+
-+#ifdef PNG_WRITE_APNG_SUPPORTED
-+void /* PRIVATE */
-+png_write_reset(png_structp png_ptr)
-+{
-+ png_ptr->row_number = 0;
-+ png_ptr->pass = 0;
-+ png_ptr->mode &= ~PNG_HAVE_IDAT;
-+}
-+
-+void /* PRIVATE */
-+png_write_reinit(png_structp png_ptr, png_infop info_ptr,
-+ png_uint_32 width, png_uint_32 height)
-+{
-+ if (png_ptr->num_frames_written == 0 &&
-+ (width != png_ptr->first_frame_width ||
-+ height != png_ptr->first_frame_height))
-+ png_error(png_ptr, "width and/or height in the first frame's fcTL "
-+ "don't match the ones in IHDR");
-+ if (width > png_ptr->first_frame_width ||
-+ height > png_ptr->first_frame_height)
-+ png_error(png_ptr, "width and/or height for a frame greater than "
-+ "the ones in IHDR");
-+
-+ png_set_IHDR(png_ptr, info_ptr, width, height,
-+ info_ptr->bit_depth, info_ptr->color_type,
-+ info_ptr->interlace_type, info_ptr->compression_type,
-+ info_ptr->filter_type);
-+
-+ png_ptr->width = width;
-+ png_ptr->height = height;
-+ png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, width);
-+ png_ptr->usr_width = png_ptr->width;
-+}
-+#endif /* WRITE_APNG */
- #endif /* WRITE */
diff --git a/contrib/libs/libpng/patches/pnglibconf.patch b/contrib/libs/libpng/patches/pnglibconf.patch
deleted file mode 100644
index c70fc8634a..0000000000
--- a/contrib/libs/libpng/patches/pnglibconf.patch
+++ /dev/null
@@ -1,8 +0,0 @@
---- a/pnglibconf.h
-+++ b/pnglibconf.h
-@@ -200,1 +2001 @@
--#define PNG_USER_CHUNK_CACHE_MAX 1000
-+#define PNG_USER_CHUNK_CACHE_MAX 32765
-@@ -209,1 +209,1 @@
--#define PNG_ZLIB_VERNUM 0x1310
-+#define PNG_ZLIB_VERNUM ZLIB_VERNUM
diff --git a/contrib/libs/libpng/png.c b/contrib/libs/libpng/png.c
deleted file mode 100644
index cbd54e1af8..0000000000
--- a/contrib/libs/libpng/png.c
+++ /dev/null
@@ -1,4680 +0,0 @@
-/* png.c - location for general purpose libpng functions
- *
- * Copyright (c) 2018-2025 Cosmin Truta
- * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
- * Copyright (c) 1996-1997 Andreas Dilger
- * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
- *
- * This code is released under the libpng license.
- * For conditions of distribution and use, see the disclaimer
- * and license in png.h
- */
-
-#include "pngpriv.h"
-
-/* Generate a compiler error if there is an old png.h in the search path. */
-typedef png_libpng_version_1_6_46 Your_png_h_is_not_version_1_6_46;
-
-/* Tells libpng that we have already handled the first "num_bytes" bytes
- * of the PNG file signature. If the PNG data is embedded into another
- * stream we can set num_bytes = 8 so that libpng will not attempt to read
- * or write any of the magic bytes before it starts on the IHDR.
- */
-
-#ifdef PNG_READ_SUPPORTED
-void PNGAPI
-png_set_sig_bytes(png_structrp png_ptr, int num_bytes)
-{
- unsigned int nb = (unsigned int)num_bytes;
-
- png_debug(1, "in png_set_sig_bytes");
-
- if (png_ptr == NULL)
- return;
-
- if (num_bytes < 0)
- nb = 0;
-
- if (nb > 8)
- png_error(png_ptr, "Too many bytes for PNG signature");
-
- png_ptr->sig_bytes = (png_byte)nb;
-}
-
-/* Checks whether the supplied bytes match the PNG signature. We allow
- * checking less than the full 8-byte signature so that those apps that
- * already read the first few bytes of a file to determine the file type
- * can simply check the remaining bytes for extra assurance. Returns
- * an integer less than, equal to, or greater than zero if sig is found,
- * respectively, to be less than, to match, or be greater than the correct
- * PNG signature (this is the same behavior as strcmp, memcmp, etc).
- */
-int PNGAPI
-png_sig_cmp(png_const_bytep sig, size_t start, size_t num_to_check)
-{
- static const png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};
-
- if (num_to_check > 8)
- num_to_check = 8;
-
- else if (num_to_check < 1)
- return -1;
-
- if (start > 7)
- return -1;
-
- if (start + num_to_check > 8)
- num_to_check = 8 - start;
-
- return memcmp(&sig[start], &png_signature[start], num_to_check);
-}
-
-#endif /* READ */
-
-#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
-/* Function to allocate memory for zlib */
-PNG_FUNCTION(voidpf /* PRIVATE */,
-png_zalloc,(voidpf png_ptr, uInt items, uInt size),PNG_ALLOCATED)
-{
- png_alloc_size_t num_bytes = size;
-
- if (png_ptr == NULL)
- return NULL;
-
- if (items >= (~(png_alloc_size_t)0)/size)
- {
- png_warning (png_voidcast(png_structrp, png_ptr),
- "Potential overflow in png_zalloc()");
- return NULL;
- }
-
- num_bytes *= items;
- return png_malloc_warn(png_voidcast(png_structrp, png_ptr), num_bytes);
-}
-
-/* Function to free memory for zlib */
-void /* PRIVATE */
-png_zfree(voidpf png_ptr, voidpf ptr)
-{
- png_free(png_voidcast(png_const_structrp,png_ptr), ptr);
-}
-
-/* Reset the CRC variable to 32 bits of 1's. Care must be taken
- * in case CRC is > 32 bits to leave the top bits 0.
- */
-void /* PRIVATE */
-png_reset_crc(png_structrp png_ptr)
-{
- /* The cast is safe because the crc is a 32-bit value. */
- png_ptr->crc = (png_uint_32)crc32(0, Z_NULL, 0);
-}
-
-/* Calculate the CRC over a section of data. We can only pass as
- * much data to this routine as the largest single buffer size. We
- * also check that this data will actually be used before going to the
- * trouble of calculating it.
- */
-void /* PRIVATE */
-png_calculate_crc(png_structrp png_ptr, png_const_bytep ptr, size_t length)
-{
- int need_crc = 1;
-
- if (PNG_CHUNK_ANCILLARY(png_ptr->chunk_name) != 0)
- {
- if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) ==
- (PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN))
- need_crc = 0;
- }
-
- else /* critical */
- {
- if ((png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE) != 0)
- need_crc = 0;
- }
-
- /* 'uLong' is defined in zlib.h as unsigned long; this means that on some
- * systems it is a 64-bit value. crc32, however, returns 32 bits so the
- * following cast is safe. 'uInt' may be no more than 16 bits, so it is
- * necessary to perform a loop here.
- */
- if (need_crc != 0 && length > 0)
- {
- uLong crc = png_ptr->crc; /* Should never issue a warning */
-
- do
- {
- uInt safe_length = (uInt)length;
-#ifndef __COVERITY__
- if (safe_length == 0)
- safe_length = (uInt)-1; /* evil, but safe */
-#endif
-
- crc = crc32(crc, ptr, safe_length);
-
- /* The following should never issue compiler warnings; if they do the
- * target system has characteristics that will probably violate other
- * assumptions within the libpng code.
- */
- ptr += safe_length;
- length -= safe_length;
- }
- while (length > 0);
-
- /* And the following is always safe because the crc is only 32 bits. */
- png_ptr->crc = (png_uint_32)crc;
- }
-}
-
-/* Check a user supplied version number, called from both read and write
- * functions that create a png_struct.
- */
-int
-png_user_version_check(png_structrp png_ptr, png_const_charp user_png_ver)
-{
- /* Libpng versions 1.0.0 and later are binary compatible if the version
- * string matches through the second '.'; we must recompile any
- * applications that use any older library version.
- */
-
- if (user_png_ver != NULL)
- {
- int i = -1;
- int found_dots = 0;
-
- do
- {
- i++;
- if (user_png_ver[i] != PNG_LIBPNG_VER_STRING[i])
- png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
- if (user_png_ver[i] == '.')
- found_dots++;
- } while (found_dots < 2 && user_png_ver[i] != 0 &&
- PNG_LIBPNG_VER_STRING[i] != 0);
- }
-
- else
- png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
-
- if ((png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH) != 0)
- {
-#ifdef PNG_WARNINGS_SUPPORTED
- size_t pos = 0;
- char m[128];
-
- pos = png_safecat(m, (sizeof m), pos,
- "Application built with libpng-");
- pos = png_safecat(m, (sizeof m), pos, user_png_ver);
- pos = png_safecat(m, (sizeof m), pos, " but running with ");
- pos = png_safecat(m, (sizeof m), pos, PNG_LIBPNG_VER_STRING);
- PNG_UNUSED(pos)
-
- png_warning(png_ptr, m);
-#endif
-
-#ifdef PNG_ERROR_NUMBERS_SUPPORTED
- png_ptr->flags = 0;
-#endif
-
- return 0;
- }
-
- /* Success return. */
- return 1;
-}
-
-/* Generic function to create a png_struct for either read or write - this
- * contains the common initialization.
- */
-PNG_FUNCTION(png_structp /* PRIVATE */,
-png_create_png_struct,(png_const_charp user_png_ver, png_voidp error_ptr,
- png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr,
- png_malloc_ptr malloc_fn, png_free_ptr free_fn),PNG_ALLOCATED)
-{
- png_struct create_struct;
-# ifdef PNG_SETJMP_SUPPORTED
- jmp_buf create_jmp_buf;
-# endif
-
- /* This temporary stack-allocated structure is used to provide a place to
- * build enough context to allow the user provided memory allocator (if any)
- * to be called.
- */
- memset(&create_struct, 0, (sizeof create_struct));
-
- /* Added at libpng-1.2.6 */
-# ifdef PNG_USER_LIMITS_SUPPORTED
- create_struct.user_width_max = PNG_USER_WIDTH_MAX;
- create_struct.user_height_max = PNG_USER_HEIGHT_MAX;
-
-# ifdef PNG_USER_CHUNK_CACHE_MAX
- /* Added at libpng-1.2.43 and 1.4.0 */
- create_struct.user_chunk_cache_max = PNG_USER_CHUNK_CACHE_MAX;
-# endif
-
-# ifdef PNG_USER_CHUNK_MALLOC_MAX
- /* Added at libpng-1.2.43 and 1.4.1, required only for read but exists
- * in png_struct regardless.
- */
- create_struct.user_chunk_malloc_max = PNG_USER_CHUNK_MALLOC_MAX;
-# endif
-# endif
-
- /* The following two API calls simply set fields in png_struct, so it is safe
- * to do them now even though error handling is not yet set up.
- */
-# ifdef PNG_USER_MEM_SUPPORTED
- png_set_mem_fn(&create_struct, mem_ptr, malloc_fn, free_fn);
-# else
- PNG_UNUSED(mem_ptr)
- PNG_UNUSED(malloc_fn)
- PNG_UNUSED(free_fn)
-# endif
-
- /* (*error_fn) can return control to the caller after the error_ptr is set,
- * this will result in a memory leak unless the error_fn does something
- * extremely sophisticated. The design lacks merit but is implicit in the
- * API.
- */
- png_set_error_fn(&create_struct, error_ptr, error_fn, warn_fn);
-
-# ifdef PNG_SETJMP_SUPPORTED
- if (!setjmp(create_jmp_buf))
-# endif
- {
-# ifdef PNG_SETJMP_SUPPORTED
- /* Temporarily fake out the longjmp information until we have
- * successfully completed this function. This only works if we have
- * setjmp() support compiled in, but it is safe - this stuff should
- * never happen.
- */
- create_struct.jmp_buf_ptr = &create_jmp_buf;
- create_struct.jmp_buf_size = 0; /*stack allocation*/
- create_struct.longjmp_fn = longjmp;
-# endif
- /* Call the general version checker (shared with read and write code):
- */
- if (png_user_version_check(&create_struct, user_png_ver) != 0)
- {
- png_structrp png_ptr = png_voidcast(png_structrp,
- png_malloc_warn(&create_struct, (sizeof *png_ptr)));
-
- if (png_ptr != NULL)
- {
- /* png_ptr->zstream holds a back-pointer to the png_struct, so
- * this can only be done now:
- */
- create_struct.zstream.zalloc = png_zalloc;
- create_struct.zstream.zfree = png_zfree;
- create_struct.zstream.opaque = png_ptr;
-
-# ifdef PNG_SETJMP_SUPPORTED
- /* Eliminate the local error handling: */
- create_struct.jmp_buf_ptr = NULL;
- create_struct.jmp_buf_size = 0;
- create_struct.longjmp_fn = 0;
-# endif
-
- *png_ptr = create_struct;
-
- /* This is the successful return point */
- return png_ptr;
- }
- }
- }
-
- /* A longjmp because of a bug in the application storage allocator or a
- * simple failure to allocate the png_struct.
- */
- return NULL;
-}
-
-/* Allocate the memory for an info_struct for the application. */
-PNG_FUNCTION(png_infop,PNGAPI
-png_create_info_struct,(png_const_structrp png_ptr),PNG_ALLOCATED)
-{
- png_inforp info_ptr;
-
- png_debug(1, "in png_create_info_struct");
-
- if (png_ptr == NULL)
- return NULL;
-
- /* Use the internal API that does not (or at least should not) error out, so
- * that this call always returns ok. The application typically sets up the
- * error handling *after* creating the info_struct because this is the way it
- * has always been done in 'example.c'.
- */
- info_ptr = png_voidcast(png_inforp, png_malloc_base(png_ptr,
- (sizeof *info_ptr)));
-
- if (info_ptr != NULL)
- memset(info_ptr, 0, (sizeof *info_ptr));
-
- return info_ptr;
-}
-
-/* This function frees the memory associated with a single info struct.
- * Normally, one would use either png_destroy_read_struct() or
- * png_destroy_write_struct() to free an info struct, but this may be
- * useful for some applications. From libpng 1.6.0 this function is also used
- * internally to implement the png_info release part of the 'struct' destroy
- * APIs. This ensures that all possible approaches free the same data (all of
- * it).
- */
-void PNGAPI
-png_destroy_info_struct(png_const_structrp png_ptr, png_infopp info_ptr_ptr)
-{
- png_inforp info_ptr = NULL;
-
- png_debug(1, "in png_destroy_info_struct");
-
- if (png_ptr == NULL)
- return;
-
- if (info_ptr_ptr != NULL)
- info_ptr = *info_ptr_ptr;
-
- if (info_ptr != NULL)
- {
- /* Do this first in case of an error below; if the app implements its own
- * memory management this can lead to png_free calling png_error, which
- * will abort this routine and return control to the app error handler.
- * An infinite loop may result if it then tries to free the same info
- * ptr.
- */
- *info_ptr_ptr = NULL;
-
- png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1);
- memset(info_ptr, 0, (sizeof *info_ptr));
- png_free(png_ptr, info_ptr);
- }
-}
-
-/* Initialize the info structure. This is now an internal function (0.89)
- * and applications using it are urged to use png_create_info_struct()
- * instead. Use deprecated in 1.6.0, internal use removed (used internally it
- * is just a memset).
- *
- * NOTE: it is almost inconceivable that this API is used because it bypasses
- * the user-memory mechanism and the user error handling/warning mechanisms in
- * those cases where it does anything other than a memset.
- */
-PNG_FUNCTION(void,PNGAPI
-png_info_init_3,(png_infopp ptr_ptr, size_t png_info_struct_size),
- PNG_DEPRECATED)
-{
- png_inforp info_ptr = *ptr_ptr;
-
- png_debug(1, "in png_info_init_3");
-
- if (info_ptr == NULL)
- return;
-
- if ((sizeof (png_info)) > png_info_struct_size)
- {
- *ptr_ptr = NULL;
- /* The following line is why this API should not be used: */
- free(info_ptr);
- info_ptr = png_voidcast(png_inforp, png_malloc_base(NULL,
- (sizeof *info_ptr)));
- if (info_ptr == NULL)
- return;
- *ptr_ptr = info_ptr;
- }
-
- /* Set everything to 0 */
- memset(info_ptr, 0, (sizeof *info_ptr));
-}
-
-void PNGAPI
-png_data_freer(png_const_structrp png_ptr, png_inforp info_ptr,
- int freer, png_uint_32 mask)
-{
- png_debug(1, "in png_data_freer");
-
- if (png_ptr == NULL || info_ptr == NULL)
- return;
-
- if (freer == PNG_DESTROY_WILL_FREE_DATA)
- info_ptr->free_me |= mask;
-
- else if (freer == PNG_USER_WILL_FREE_DATA)
- info_ptr->free_me &= ~mask;
-
- else
- png_error(png_ptr, "Unknown freer parameter in png_data_freer");
-}
-
-void PNGAPI
-png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,
- int num)
-{
- png_debug(1, "in png_free_data");
-
- if (png_ptr == NULL || info_ptr == NULL)
- return;
-
-#ifdef PNG_TEXT_SUPPORTED
- /* Free text item num or (if num == -1) all text items */
- if (info_ptr->text != NULL &&
- ((mask & PNG_FREE_TEXT) & info_ptr->free_me) != 0)
- {
- if (num != -1)
- {
- png_free(png_ptr, info_ptr->text[num].key);
- info_ptr->text[num].key = NULL;
- }
-
- else
- {
- int i;
-
- for (i = 0; i < info_ptr->num_text; i++)
- png_free(png_ptr, info_ptr->text[i].key);
-
- png_free(png_ptr, info_ptr->text);
- info_ptr->text = NULL;
- info_ptr->num_text = 0;
- info_ptr->max_text = 0;
- }
- }
-#endif
-
-#ifdef PNG_tRNS_SUPPORTED
- /* Free any tRNS entry */
- if (((mask & PNG_FREE_TRNS) & info_ptr->free_me) != 0)
- {
- info_ptr->valid &= ~PNG_INFO_tRNS;
- png_free(png_ptr, info_ptr->trans_alpha);
- info_ptr->trans_alpha = NULL;
- info_ptr->num_trans = 0;
- }
-#endif
-
-#ifdef PNG_sCAL_SUPPORTED
- /* Free any sCAL entry */
- if (((mask & PNG_FREE_SCAL) & info_ptr->free_me) != 0)
- {
- png_free(png_ptr, info_ptr->scal_s_width);
- png_free(png_ptr, info_ptr->scal_s_height);
- info_ptr->scal_s_width = NULL;
- info_ptr->scal_s_height = NULL;
- info_ptr->valid &= ~PNG_INFO_sCAL;
- }
-#endif
-
-#ifdef PNG_pCAL_SUPPORTED
- /* Free any pCAL entry */
- if (((mask & PNG_FREE_PCAL) & info_ptr->free_me) != 0)
- {
- png_free(png_ptr, info_ptr->pcal_purpose);
- png_free(png_ptr, info_ptr->pcal_units);
- info_ptr->pcal_purpose = NULL;
- info_ptr->pcal_units = NULL;
-
- if (info_ptr->pcal_params != NULL)
- {
- int i;
-
- for (i = 0; i < info_ptr->pcal_nparams; i++)
- png_free(png_ptr, info_ptr->pcal_params[i]);
-
- png_free(png_ptr, info_ptr->pcal_params);
- info_ptr->pcal_params = NULL;
- }
- info_ptr->valid &= ~PNG_INFO_pCAL;
- }
-#endif
-
-#ifdef PNG_iCCP_SUPPORTED
- /* Free any profile entry */
- if (((mask & PNG_FREE_ICCP) & info_ptr->free_me) != 0)
- {
- png_free(png_ptr, info_ptr->iccp_name);
- png_free(png_ptr, info_ptr->iccp_profile);
- info_ptr->iccp_name = NULL;
- info_ptr->iccp_profile = NULL;
- info_ptr->valid &= ~PNG_INFO_iCCP;
- }
-#endif
-
-#ifdef PNG_sPLT_SUPPORTED
- /* Free a given sPLT entry, or (if num == -1) all sPLT entries */
- if (info_ptr->splt_palettes != NULL &&
- ((mask & PNG_FREE_SPLT) & info_ptr->free_me) != 0)
- {
- if (num != -1)
- {
- png_free(png_ptr, info_ptr->splt_palettes[num].name);
- png_free(png_ptr, info_ptr->splt_palettes[num].entries);
- info_ptr->splt_palettes[num].name = NULL;
- info_ptr->splt_palettes[num].entries = NULL;
- }
-
- else
- {
- int i;
-
- for (i = 0; i < info_ptr->splt_palettes_num; i++)
- {
- png_free(png_ptr, info_ptr->splt_palettes[i].name);
- png_free(png_ptr, info_ptr->splt_palettes[i].entries);
- }
-
- png_free(png_ptr, info_ptr->splt_palettes);
- info_ptr->splt_palettes = NULL;
- info_ptr->splt_palettes_num = 0;
- info_ptr->valid &= ~PNG_INFO_sPLT;
- }
- }
-#endif
-
-#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
- if (info_ptr->unknown_chunks != NULL &&
- ((mask & PNG_FREE_UNKN) & info_ptr->free_me) != 0)
- {
- if (num != -1)
- {
- png_free(png_ptr, info_ptr->unknown_chunks[num].data);
- info_ptr->unknown_chunks[num].data = NULL;
- }
-
- else
- {
- int i;
-
- for (i = 0; i < info_ptr->unknown_chunks_num; i++)
- png_free(png_ptr, info_ptr->unknown_chunks[i].data);
-
- png_free(png_ptr, info_ptr->unknown_chunks);
- info_ptr->unknown_chunks = NULL;
- info_ptr->unknown_chunks_num = 0;
- }
- }
-#endif
-
-#ifdef PNG_eXIf_SUPPORTED
- /* Free any eXIf entry */
- if (((mask & PNG_FREE_EXIF) & info_ptr->free_me) != 0)
- {
-# ifdef PNG_READ_eXIf_SUPPORTED
- if (info_ptr->eXIf_buf)
- {
- png_free(png_ptr, info_ptr->eXIf_buf);
- info_ptr->eXIf_buf = NULL;
- }
-# endif
- if (info_ptr->exif)
- {
- png_free(png_ptr, info_ptr->exif);
- info_ptr->exif = NULL;
- }
- info_ptr->valid &= ~PNG_INFO_eXIf;
- }
-#endif
-
-#ifdef PNG_hIST_SUPPORTED
- /* Free any hIST entry */
- if (((mask & PNG_FREE_HIST) & info_ptr->free_me) != 0)
- {
- png_free(png_ptr, info_ptr->hist);
- info_ptr->hist = NULL;
- info_ptr->valid &= ~PNG_INFO_hIST;
- }
-#endif
-
- /* Free any PLTE entry that was internally allocated */
- if (((mask & PNG_FREE_PLTE) & info_ptr->free_me) != 0)
- {
- png_free(png_ptr, info_ptr->palette);
- info_ptr->palette = NULL;
- info_ptr->valid &= ~PNG_INFO_PLTE;
- info_ptr->num_palette = 0;
- }
-
-#ifdef PNG_INFO_IMAGE_SUPPORTED
- /* Free any image bits attached to the info structure */
- if (((mask & PNG_FREE_ROWS) & info_ptr->free_me) != 0)
- {
- if (info_ptr->row_pointers != NULL)
- {
- png_uint_32 row;
- for (row = 0; row < info_ptr->height; row++)
- png_free(png_ptr, info_ptr->row_pointers[row]);
-
- png_free(png_ptr, info_ptr->row_pointers);
- info_ptr->row_pointers = NULL;
- }
- info_ptr->valid &= ~PNG_INFO_IDAT;
- }
-#endif
-
- if (num != -1)
- mask &= ~PNG_FREE_MUL;
-
- info_ptr->free_me &= ~mask;
-}
-#endif /* READ || WRITE */
-
-/* This function returns a pointer to the io_ptr associated with the user
- * functions. The application should free any memory associated with this
- * pointer before png_write_destroy() or png_read_destroy() are called.
- */
-png_voidp PNGAPI
-png_get_io_ptr(png_const_structrp png_ptr)
-{
- if (png_ptr == NULL)
- return NULL;
-
- return png_ptr->io_ptr;
-}
-
-#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
-# ifdef PNG_STDIO_SUPPORTED
-/* Initialize the default input/output functions for the PNG file. If you
- * use your own read or write routines, you can call either png_set_read_fn()
- * or png_set_write_fn() instead of png_init_io(). If you have defined
- * PNG_NO_STDIO or otherwise disabled PNG_STDIO_SUPPORTED, you must use a
- * function of your own because "FILE *" isn't necessarily available.
- */
-void PNGAPI
-png_init_io(png_structrp png_ptr, png_FILE_p fp)
-{
- png_debug(1, "in png_init_io");
-
- if (png_ptr == NULL)
- return;
-
- png_ptr->io_ptr = (png_voidp)fp;
-}
-# endif
-
-# ifdef PNG_SAVE_INT_32_SUPPORTED
-/* PNG signed integers are saved in 32-bit 2's complement format. ANSI C-90
- * defines a cast of a signed integer to an unsigned integer either to preserve
- * the value, if it is positive, or to calculate:
- *
- * (UNSIGNED_MAX+1) + integer
- *
- * Where UNSIGNED_MAX is the appropriate maximum unsigned value, so when the
- * negative integral value is added the result will be an unsigned value
- * corresponding to the 2's complement representation.
- */
-void PNGAPI
-png_save_int_32(png_bytep buf, png_int_32 i)
-{
- png_save_uint_32(buf, (png_uint_32)i);
-}
-# endif
-
-# ifdef PNG_TIME_RFC1123_SUPPORTED
-/* Convert the supplied time into an RFC 1123 string suitable for use in
- * a "Creation Time" or other text-based time string.
- */
-int PNGAPI
-png_convert_to_rfc1123_buffer(char out[29], png_const_timep ptime)
-{
- static const char short_months[12][4] =
- {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
-
- if (out == NULL)
- return 0;
-
- if (ptime->year > 9999 /* RFC1123 limitation */ ||
- ptime->month == 0 || ptime->month > 12 ||
- ptime->day == 0 || ptime->day > 31 ||
- ptime->hour > 23 || ptime->minute > 59 ||
- ptime->second > 60)
- return 0;
-
- {
- size_t pos = 0;
- char number_buf[5] = {0, 0, 0, 0, 0}; /* enough for a four-digit year */
-
-# define APPEND_STRING(string) pos = png_safecat(out, 29, pos, (string))
-# define APPEND_NUMBER(format, value)\
- APPEND_STRING(PNG_FORMAT_NUMBER(number_buf, format, (value)))
-# define APPEND(ch) if (pos < 28) out[pos++] = (ch)
-
- APPEND_NUMBER(PNG_NUMBER_FORMAT_u, (unsigned)ptime->day);
- APPEND(' ');
- APPEND_STRING(short_months[(ptime->month - 1)]);
- APPEND(' ');
- APPEND_NUMBER(PNG_NUMBER_FORMAT_u, ptime->year);
- APPEND(' ');
- APPEND_NUMBER(PNG_NUMBER_FORMAT_02u, (unsigned)ptime->hour);
- APPEND(':');
- APPEND_NUMBER(PNG_NUMBER_FORMAT_02u, (unsigned)ptime->minute);
- APPEND(':');
- APPEND_NUMBER(PNG_NUMBER_FORMAT_02u, (unsigned)ptime->second);
- APPEND_STRING(" +0000"); /* This reliably terminates the buffer */
- PNG_UNUSED (pos)
-
-# undef APPEND
-# undef APPEND_NUMBER
-# undef APPEND_STRING
- }
-
- return 1;
-}
-
-# if PNG_LIBPNG_VER < 10700
-/* To do: remove the following from libpng-1.7 */
-/* Original API that uses a private buffer in png_struct.
- * Deprecated because it causes png_struct to carry a spurious temporary
- * buffer (png_struct::time_buffer), better to have the caller pass this in.
- */
-png_const_charp PNGAPI
-png_convert_to_rfc1123(png_structrp png_ptr, png_const_timep ptime)
-{
- if (png_ptr != NULL)
- {
- /* The only failure above if png_ptr != NULL is from an invalid ptime */
- if (png_convert_to_rfc1123_buffer(png_ptr->time_buffer, ptime) == 0)
- png_warning(png_ptr, "Ignoring invalid time value");
-
- else
- return png_ptr->time_buffer;
- }
-
- return NULL;
-}
-# endif /* LIBPNG_VER < 10700 */
-# endif /* TIME_RFC1123 */
-
-#endif /* READ || WRITE */
-
-png_const_charp PNGAPI
-png_get_copyright(png_const_structrp png_ptr)
-{
- PNG_UNUSED(png_ptr) /* Silence compiler warning about unused png_ptr */
-#ifdef PNG_STRING_COPYRIGHT
- return PNG_STRING_COPYRIGHT
-#else
- return PNG_STRING_NEWLINE \
- "libpng version 1.6.46" PNG_STRING_NEWLINE \
- "Copyright (c) 2018-2025 Cosmin Truta" PNG_STRING_NEWLINE \
- "Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson" \
- PNG_STRING_NEWLINE \
- "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
- "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
- PNG_STRING_NEWLINE;
-#endif
-}
-
-/* The following return the library version as a short string in the
- * format 1.0.0 through 99.99.99zz. To get the version of *.h files
- * used with your application, print out PNG_LIBPNG_VER_STRING, which
- * is defined in png.h.
- * Note: now there is no difference between png_get_libpng_ver() and
- * png_get_header_ver(). Due to the version_nn_nn_nn typedef guard,
- * it is guaranteed that png.c uses the correct version of png.h.
- */
-png_const_charp PNGAPI
-png_get_libpng_ver(png_const_structrp png_ptr)
-{
- /* Version of *.c files used when building libpng */
- return png_get_header_ver(png_ptr);
-}
-
-png_const_charp PNGAPI
-png_get_header_ver(png_const_structrp png_ptr)
-{
- /* Version of *.h files used when building libpng */
- PNG_UNUSED(png_ptr) /* Silence compiler warning about unused png_ptr */
- return PNG_LIBPNG_VER_STRING;
-}
-
-png_const_charp PNGAPI
-png_get_header_version(png_const_structrp png_ptr)
-{
- /* Returns longer string containing both version and date */
- PNG_UNUSED(png_ptr) /* Silence compiler warning about unused png_ptr */
-#ifdef __STDC__
- return PNG_HEADER_VERSION_STRING
-# ifndef PNG_READ_SUPPORTED
- " (NO READ SUPPORT)"
-# endif
- PNG_STRING_NEWLINE;
-#else
- return PNG_HEADER_VERSION_STRING;
-#endif
-}
-
-#ifdef PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED
-/* NOTE: this routine is not used internally! */
-/* Build a grayscale palette. Palette is assumed to be 1 << bit_depth
- * large of png_color. This lets grayscale images be treated as
- * paletted. Most useful for gamma correction and simplification
- * of code. This API is not used internally.
- */
-void PNGAPI
-png_build_grayscale_palette(int bit_depth, png_colorp palette)
-{
- int num_palette;
- int color_inc;
- int i;
- int v;
-
- png_debug(1, "in png_do_build_grayscale_palette");
-
- if (palette == NULL)
- return;
-
- switch (bit_depth)
- {
- case 1:
- num_palette = 2;
- color_inc = 0xff;
- break;
-
- case 2:
- num_palette = 4;
- color_inc = 0x55;
- break;
-
- case 4:
- num_palette = 16;
- color_inc = 0x11;
- break;
-
- case 8:
- num_palette = 256;
- color_inc = 1;
- break;
-
- default:
- num_palette = 0;
- color_inc = 0;
- break;
- }
-
- for (i = 0, v = 0; i < num_palette; i++, v += color_inc)
- {
- palette[i].red = (png_byte)(v & 0xff);
- palette[i].green = (png_byte)(v & 0xff);
- palette[i].blue = (png_byte)(v & 0xff);
- }
-}
-#endif
-
-#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
-int PNGAPI
-png_handle_as_unknown(png_const_structrp png_ptr, png_const_bytep chunk_name)
-{
- /* Check chunk_name and return "keep" value if it's on the list, else 0 */
- png_const_bytep p, p_end;
-
- if (png_ptr == NULL || chunk_name == NULL || png_ptr->num_chunk_list == 0)
- return PNG_HANDLE_CHUNK_AS_DEFAULT;
-
- p_end = png_ptr->chunk_list;
- p = p_end + png_ptr->num_chunk_list*5; /* beyond end */
-
- /* The code is the fifth byte after each four byte string. Historically this
- * code was always searched from the end of the list, this is no longer
- * necessary because the 'set' routine handles duplicate entries correctly.
- */
- do /* num_chunk_list > 0, so at least one */
- {
- p -= 5;
-
- if (memcmp(chunk_name, p, 4) == 0)
- return p[4];
- }
- while (p > p_end);
-
- /* This means that known chunks should be processed and unknown chunks should
- * be handled according to the value of png_ptr->unknown_default; this can be
- * confusing because, as a result, there are two levels of defaulting for
- * unknown chunks.
- */
- return PNG_HANDLE_CHUNK_AS_DEFAULT;
-}
-
-#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) ||\
- defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
-int /* PRIVATE */
-png_chunk_unknown_handling(png_const_structrp png_ptr, png_uint_32 chunk_name)
-{
- png_byte chunk_string[5];
-
- PNG_CSTRING_FROM_CHUNK(chunk_string, chunk_name);
- return png_handle_as_unknown(png_ptr, chunk_string);
-}
-#endif /* READ_UNKNOWN_CHUNKS || HANDLE_AS_UNKNOWN */
-#endif /* SET_UNKNOWN_CHUNKS */
-
-#ifdef PNG_READ_SUPPORTED
-/* This function, added to libpng-1.0.6g, is untested. */
-int PNGAPI
-png_reset_zstream(png_structrp png_ptr)
-{
- if (png_ptr == NULL)
- return Z_STREAM_ERROR;
-
- /* WARNING: this resets the window bits to the maximum! */
- return inflateReset(&png_ptr->zstream);
-}
-#endif /* READ */
-
-/* This function was added to libpng-1.0.7 */
-png_uint_32 PNGAPI
-png_access_version_number(void)
-{
- /* Version of *.c files used when building libpng */
- return (png_uint_32)PNG_LIBPNG_VER;
-}
-
-#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
-/* Ensure that png_ptr->zstream.msg holds some appropriate error message string.
- * If it doesn't 'ret' is used to set it to something appropriate, even in cases
- * like Z_OK or Z_STREAM_END where the error code is apparently a success code.
- */
-void /* PRIVATE */
-png_zstream_error(png_structrp png_ptr, int ret)
-{
- /* Translate 'ret' into an appropriate error string, priority is given to the
- * one in zstream if set. This always returns a string, even in cases like
- * Z_OK or Z_STREAM_END where the error code is a success code.
- */
- if (png_ptr->zstream.msg == NULL) switch (ret)
- {
- default:
- case Z_OK:
- png_ptr->zstream.msg = PNGZ_MSG_CAST("unexpected zlib return code");
- break;
-
- case Z_STREAM_END:
- /* Normal exit */
- png_ptr->zstream.msg = PNGZ_MSG_CAST("unexpected end of LZ stream");
- break;
-
- case Z_NEED_DICT:
- /* This means the deflate stream did not have a dictionary; this
- * indicates a bogus PNG.
- */
- png_ptr->zstream.msg = PNGZ_MSG_CAST("missing LZ dictionary");
- break;
-
- case Z_ERRNO:
- /* gz APIs only: should not happen */
- png_ptr->zstream.msg = PNGZ_MSG_CAST("zlib IO error");
- break;
-
- case Z_STREAM_ERROR:
- /* internal libpng error */
- png_ptr->zstream.msg = PNGZ_MSG_CAST("bad parameters to zlib");
- break;
-
- case Z_DATA_ERROR:
- png_ptr->zstream.msg = PNGZ_MSG_CAST("damaged LZ stream");
- break;
-
- case Z_MEM_ERROR:
- png_ptr->zstream.msg = PNGZ_MSG_CAST("insufficient memory");
- break;
-
- case Z_BUF_ERROR:
- /* End of input or output; not a problem if the caller is doing
- * incremental read or write.
- */
- png_ptr->zstream.msg = PNGZ_MSG_CAST("truncated");
- break;
-
- case Z_VERSION_ERROR:
- png_ptr->zstream.msg = PNGZ_MSG_CAST("unsupported zlib version");
- break;
-
- case PNG_UNEXPECTED_ZLIB_RETURN:
- /* Compile errors here mean that zlib now uses the value co-opted in
- * pngpriv.h for PNG_UNEXPECTED_ZLIB_RETURN; update the switch above
- * and change pngpriv.h. Note that this message is "... return",
- * whereas the default/Z_OK one is "... return code".
- */
- png_ptr->zstream.msg = PNGZ_MSG_CAST("unexpected zlib return");
- break;
- }
-}
-
-/* png_convert_size: a PNGAPI but no longer in png.h, so deleted
- * at libpng 1.5.5!
- */
-
-/* Added at libpng version 1.2.34 and 1.4.0 (moved from pngset.c) */
-#ifdef PNG_GAMMA_SUPPORTED /* always set if COLORSPACE */
-static int
-png_colorspace_check_gamma(png_const_structrp png_ptr,
- png_colorspacerp colorspace, png_fixed_point gAMA, int from)
- /* This is called to check a new gamma value against an existing one. The
- * routine returns false if the new gamma value should not be written.
- *
- * 'from' says where the new gamma value comes from:
- *
- * 0: the new gamma value is the libpng estimate for an ICC profile
- * 1: the new gamma value comes from a gAMA chunk
- * 2: the new gamma value comes from an sRGB chunk
- */
-{
- png_fixed_point gtest;
-
- if ((colorspace->flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 &&
- (png_muldiv(&gtest, colorspace->gamma, PNG_FP_1, gAMA) == 0 ||
- png_gamma_significant(gtest) != 0))
- {
- /* Either this is an sRGB image, in which case the calculated gamma
- * approximation should match, or this is an image with a profile and the
- * value libpng calculates for the gamma of the profile does not match the
- * value recorded in the file. The former, sRGB, case is an error, the
- * latter is just a warning.
- */
- if ((colorspace->flags & PNG_COLORSPACE_FROM_sRGB) != 0 || from == 2)
- {
- png_chunk_report(png_ptr, "gamma value does not match sRGB",
- PNG_CHUNK_ERROR);
- /* Do not overwrite an sRGB value */
- return from == 2;
- }
-
- else /* sRGB tag not involved */
- {
- png_chunk_report(png_ptr, "gamma value does not match libpng estimate",
- PNG_CHUNK_WARNING);
- return from == 1;
- }
- }
-
- return 1;
-}
-
-void /* PRIVATE */
-png_colorspace_set_gamma(png_const_structrp png_ptr,
- png_colorspacerp colorspace, png_fixed_point gAMA)
-{
- /* Changed in libpng-1.5.4 to limit the values to ensure overflow can't
- * occur. Since the fixed point representation is asymmetrical it is
- * possible for 1/gamma to overflow the limit of 21474 and this means the
- * gamma value must be at least 5/100000 and hence at most 20000.0. For
- * safety the limits here are a little narrower. The values are 0.00016 to
- * 6250.0, which are truly ridiculous gamma values (and will produce
- * displays that are all black or all white.)
- *
- * In 1.6.0 this test replaces the ones in pngrutil.c, in the gAMA chunk
- * handling code, which only required the value to be >0.
- */
- png_const_charp errmsg;
-
- if (gAMA < 16 || gAMA > 625000000)
- errmsg = "gamma value out of range";
-
-# ifdef PNG_READ_gAMA_SUPPORTED
- /* Allow the application to set the gamma value more than once */
- else if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 &&
- (colorspace->flags & PNG_COLORSPACE_FROM_gAMA) != 0)
- errmsg = "duplicate";
-# endif
-
- /* Do nothing if the colorspace is already invalid */
- else if ((colorspace->flags & PNG_COLORSPACE_INVALID) != 0)
- return;
-
- else
- {
- if (png_colorspace_check_gamma(png_ptr, colorspace, gAMA,
- 1/*from gAMA*/) != 0)
- {
- /* Store this gamma value. */
- colorspace->gamma = gAMA;
- colorspace->flags |=
- (PNG_COLORSPACE_HAVE_GAMMA | PNG_COLORSPACE_FROM_gAMA);
- }
-
- /* At present if the check_gamma test fails the gamma of the colorspace is
- * not updated however the colorspace is not invalidated. This
- * corresponds to the case where the existing gamma comes from an sRGB
- * chunk or profile. An error message has already been output.
- */
- return;
- }
-
- /* Error exit - errmsg has been set. */
- colorspace->flags |= PNG_COLORSPACE_INVALID;
- png_chunk_report(png_ptr, errmsg, PNG_CHUNK_WRITE_ERROR);
-}
-
-void /* PRIVATE */
-png_colorspace_sync_info(png_const_structrp png_ptr, png_inforp info_ptr)
-{
- if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) != 0)
- {
- /* Everything is invalid */
- info_ptr->valid &= ~(PNG_INFO_gAMA|PNG_INFO_cHRM|PNG_INFO_sRGB|
- PNG_INFO_iCCP);
-
-# ifdef PNG_COLORSPACE_SUPPORTED
- /* Clean up the iCCP profile now if it won't be used. */
- png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, -1/*not used*/);
-# else
- PNG_UNUSED(png_ptr)
-# endif
- }
-
- else
- {
-# ifdef PNG_COLORSPACE_SUPPORTED
- /* Leave the INFO_iCCP flag set if the pngset.c code has already set
- * it; this allows a PNG to contain a profile which matches sRGB and
- * yet still have that profile retrievable by the application.
- */
- if ((info_ptr->colorspace.flags & PNG_COLORSPACE_MATCHES_sRGB) != 0)
- info_ptr->valid |= PNG_INFO_sRGB;
-
- else
- info_ptr->valid &= ~PNG_INFO_sRGB;
-
- if ((info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
- info_ptr->valid |= PNG_INFO_cHRM;
-
- else
- info_ptr->valid &= ~PNG_INFO_cHRM;
-# endif
-
- if ((info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) != 0)
- info_ptr->valid |= PNG_INFO_gAMA;
-
- else
- info_ptr->valid &= ~PNG_INFO_gAMA;
- }
-}
-
-#ifdef PNG_READ_SUPPORTED
-void /* PRIVATE */
-png_colorspace_sync(png_const_structrp png_ptr, png_inforp info_ptr)
-{
- if (info_ptr == NULL) /* reduce code size; check here not in the caller */
- return;
-
- info_ptr->colorspace = png_ptr->colorspace;
- png_colorspace_sync_info(png_ptr, info_ptr);
-}
-#endif
-#endif /* GAMMA */
-
-#ifdef PNG_COLORSPACE_SUPPORTED
-static png_int_32
-png_fp_add(png_int_32 addend0, png_int_32 addend1, int *error)
-{
- /* Safely add two fixed point values setting an error flag and returning 0.5
- * on overflow.
- * IMPLEMENTATION NOTE: ANSI requires signed overflow not to occur, therefore
- * relying on addition of two positive values producing a negative one is not
- * safe.
- */
- if (addend0 > 0)
- {
- if (0x7fffffff - addend0 >= addend1)
- return addend0+addend1;
- }
- else if (addend0 < 0)
- {
- if (-0x7fffffff - addend0 <= addend1)
- return addend0+addend1;
- }
- else
- return addend1;
-
- *error = 1;
- return PNG_FP_1/2;
-}
-
-static png_int_32
-png_fp_sub(png_int_32 addend0, png_int_32 addend1, int *error)
-{
- /* As above but calculate addend0-addend1. */
- if (addend1 > 0)
- {
- if (-0x7fffffff + addend1 <= addend0)
- return addend0-addend1;
- }
- else if (addend1 < 0)
- {
- if (0x7fffffff + addend1 >= addend0)
- return addend0-addend1;
- }
- else
- return addend0;
-
- *error = 1;
- return PNG_FP_1/2;
-}
-
-static int
-png_safe_add(png_int_32 *addend0_and_result, png_int_32 addend1,
- png_int_32 addend2)
-{
- /* Safely add three integers. Returns 0 on success, 1 on overflow. Does not
- * set the result on overflow.
- */
- int error = 0;
- int result = png_fp_add(*addend0_and_result,
- png_fp_add(addend1, addend2, &error),
- &error);
- if (!error) *addend0_and_result = result;
- return error;
-}
-
-/* Added at libpng-1.5.5 to support read and write of true CIEXYZ values for
- * cHRM, as opposed to using chromaticities. These internal APIs return
- * non-zero on a parameter error. The X, Y and Z values are required to be
- * positive and less than 1.0.
- */
-static int
-png_xy_from_XYZ(png_xy *xy, const png_XYZ *XYZ)
-{
- png_int_32 d, dred, dgreen, dblue, dwhite, whiteX, whiteY;
-
- /* 'd' in each of the blocks below is just X+Y+Z for each component,
- * x, y and z are X,Y,Z/(X+Y+Z).
- */
- d = XYZ->red_X;
- if (png_safe_add(&d, XYZ->red_Y, XYZ->red_Z))
- return 1;
- dred = d;
- if (png_muldiv(&xy->redx, XYZ->red_X, PNG_FP_1, dred) == 0)
- return 1;
- if (png_muldiv(&xy->redy, XYZ->red_Y, PNG_FP_1, dred) == 0)
- return 1;
-
- d = XYZ->green_X;
- if (png_safe_add(&d, XYZ->green_Y, XYZ->green_Z))
- return 1;
- dgreen = d;
- if (png_muldiv(&xy->greenx, XYZ->green_X, PNG_FP_1, dgreen) == 0)
- return 1;
- if (png_muldiv(&xy->greeny, XYZ->green_Y, PNG_FP_1, dgreen) == 0)
- return 1;
-
- d = XYZ->blue_X;
- if (png_safe_add(&d, XYZ->blue_Y, XYZ->blue_Z))
- return 1;
- dblue = d;
- if (png_muldiv(&xy->bluex, XYZ->blue_X, PNG_FP_1, dblue) == 0)
- return 1;
- if (png_muldiv(&xy->bluey, XYZ->blue_Y, PNG_FP_1, dblue) == 0)
- return 1;
-
- /* The reference white is simply the sum of the end-point (X,Y,Z) vectors so
- * the fillowing calculates (X+Y+Z) of the reference white (media white,
- * encoding white) itself:
- */
- d = dblue;
- if (png_safe_add(&d, dred, dgreen))
- return 1;
- dwhite = d;
-
- /* Find the white X,Y values from the sum of the red, green and blue X,Y
- * values.
- */
- d = XYZ->red_X;
- if (png_safe_add(&d, XYZ->green_X, XYZ->blue_X))
- return 1;
- whiteX = d;
-
- d = XYZ->red_Y;
- if (png_safe_add(&d, XYZ->green_Y, XYZ->blue_Y))
- return 1;
- whiteY = d;
-
- if (png_muldiv(&xy->whitex, whiteX, PNG_FP_1, dwhite) == 0)
- return 1;
- if (png_muldiv(&xy->whitey, whiteY, PNG_FP_1, dwhite) == 0)
- return 1;
-
- return 0;
-}
-
-static int
-png_XYZ_from_xy(png_XYZ *XYZ, const png_xy *xy)
-{
- png_fixed_point red_inverse, green_inverse, blue_scale;
- png_fixed_point left, right, denominator;
-
- /* Check xy and, implicitly, z. Note that wide gamut color spaces typically
- * have end points with 0 tristimulus values (these are impossible end
- * points, but they are used to cover the possible colors). We check
- * xy->whitey against 5, not 0, to avoid a possible integer overflow.
- *
- * The limits here will *not* accept ACES AP0, where bluey is -7700
- * (-0.0770) because the PNG spec itself requires the xy values to be
- * unsigned. whitey is also required to be 5 or more to avoid overflow.
- *
- * Instead the upper limits have been relaxed to accomodate ACES AP1 where
- * redz ends up as -600 (-0.006). ProPhotoRGB was already "in range."
- * The new limit accomodates the AP0 and AP1 ranges for z but not AP0 redy.
- */
- const png_fixed_point fpLimit = PNG_FP_1+(PNG_FP_1/10);
- if (xy->redx < 0 || xy->redx > fpLimit) return 1;
- if (xy->redy < 0 || xy->redy > fpLimit-xy->redx) return 1;
- if (xy->greenx < 0 || xy->greenx > fpLimit) return 1;
- if (xy->greeny < 0 || xy->greeny > fpLimit-xy->greenx) return 1;
- if (xy->bluex < 0 || xy->bluex > fpLimit) return 1;
- if (xy->bluey < 0 || xy->bluey > fpLimit-xy->bluex) return 1;
- if (xy->whitex < 0 || xy->whitex > fpLimit) return 1;
- if (xy->whitey < 5 || xy->whitey > fpLimit-xy->whitex) return 1;
-
- /* The reverse calculation is more difficult because the original tristimulus
- * value had 9 independent values (red,green,blue)x(X,Y,Z) however only 8
- * derived values were recorded in the cHRM chunk;
- * (red,green,blue,white)x(x,y). This loses one degree of freedom and
- * therefore an arbitrary ninth value has to be introduced to undo the
- * original transformations.
- *
- * Think of the original end-points as points in (X,Y,Z) space. The
- * chromaticity values (c) have the property:
- *
- * C
- * c = ---------
- * X + Y + Z
- *
- * For each c (x,y,z) from the corresponding original C (X,Y,Z). Thus the
- * three chromaticity values (x,y,z) for each end-point obey the
- * relationship:
- *
- * x + y + z = 1
- *
- * This describes the plane in (X,Y,Z) space that intersects each axis at the
- * value 1.0; call this the chromaticity plane. Thus the chromaticity
- * calculation has scaled each end-point so that it is on the x+y+z=1 plane
- * and chromaticity is the intersection of the vector from the origin to the
- * (X,Y,Z) value with the chromaticity plane.
- *
- * To fully invert the chromaticity calculation we would need the three
- * end-point scale factors, (red-scale, green-scale, blue-scale), but these
- * were not recorded. Instead we calculated the reference white (X,Y,Z) and
- * recorded the chromaticity of this. The reference white (X,Y,Z) would have
- * given all three of the scale factors since:
- *
- * color-C = color-c * color-scale
- * white-C = red-C + green-C + blue-C
- * = red-c*red-scale + green-c*green-scale + blue-c*blue-scale
- *
- * But cHRM records only white-x and white-y, so we have lost the white scale
- * factor:
- *
- * white-C = white-c*white-scale
- *
- * To handle this the inverse transformation makes an arbitrary assumption
- * about white-scale:
- *
- * Assume: white-Y = 1.0
- * Hence: white-scale = 1/white-y
- * Or: red-Y + green-Y + blue-Y = 1.0
- *
- * Notice the last statement of the assumption gives an equation in three of
- * the nine values we want to calculate. 8 more equations come from the
- * above routine as summarised at the top above (the chromaticity
- * calculation):
- *
- * Given: color-x = color-X / (color-X + color-Y + color-Z)
- * Hence: (color-x - 1)*color-X + color.x*color-Y + color.x*color-Z = 0
- *
- * This is 9 simultaneous equations in the 9 variables "color-C" and can be
- * solved by Cramer's rule. Cramer's rule requires calculating 10 9x9 matrix
- * determinants, however this is not as bad as it seems because only 28 of
- * the total of 90 terms in the various matrices are non-zero. Nevertheless
- * Cramer's rule is notoriously numerically unstable because the determinant
- * calculation involves the difference of large, but similar, numbers. It is
- * difficult to be sure that the calculation is stable for real world values
- * and it is certain that it becomes unstable where the end points are close
- * together.
- *
- * So this code uses the perhaps slightly less optimal but more
- * understandable and totally obvious approach of calculating color-scale.
- *
- * This algorithm depends on the precision in white-scale and that is
- * (1/white-y), so we can immediately see that as white-y approaches 0 the
- * accuracy inherent in the cHRM chunk drops off substantially.
- *
- * libpng arithmetic: a simple inversion of the above equations
- * ------------------------------------------------------------
- *
- * white_scale = 1/white-y
- * white-X = white-x * white-scale
- * white-Y = 1.0
- * white-Z = (1 - white-x - white-y) * white_scale
- *
- * white-C = red-C + green-C + blue-C
- * = red-c*red-scale + green-c*green-scale + blue-c*blue-scale
- *
- * This gives us three equations in (red-scale,green-scale,blue-scale) where
- * all the coefficients are now known:
- *
- * red-x*red-scale + green-x*green-scale + blue-x*blue-scale
- * = white-x/white-y
- * red-y*red-scale + green-y*green-scale + blue-y*blue-scale = 1
- * red-z*red-scale + green-z*green-scale + blue-z*blue-scale
- * = (1 - white-x - white-y)/white-y
- *
- * In the last equation color-z is (1 - color-x - color-y) so we can add all
- * three equations together to get an alternative third:
- *
- * red-scale + green-scale + blue-scale = 1/white-y = white-scale
- *
- * So now we have a Cramer's rule solution where the determinants are just
- * 3x3 - far more tractible. Unfortunately 3x3 determinants still involve
- * multiplication of three coefficients so we can't guarantee to avoid
- * overflow in the libpng fixed point representation. Using Cramer's rule in
- * floating point is probably a good choice here, but it's not an option for
- * fixed point. Instead proceed to simplify the first two equations by
- * eliminating what is likely to be the largest value, blue-scale:
- *
- * blue-scale = white-scale - red-scale - green-scale
- *
- * Hence:
- *
- * (red-x - blue-x)*red-scale + (green-x - blue-x)*green-scale =
- * (white-x - blue-x)*white-scale
- *
- * (red-y - blue-y)*red-scale + (green-y - blue-y)*green-scale =
- * 1 - blue-y*white-scale
- *
- * And now we can trivially solve for (red-scale,green-scale):
- *
- * green-scale =
- * (white-x - blue-x)*white-scale - (red-x - blue-x)*red-scale
- * -----------------------------------------------------------
- * green-x - blue-x
- *
- * red-scale =
- * 1 - blue-y*white-scale - (green-y - blue-y) * green-scale
- * ---------------------------------------------------------
- * red-y - blue-y
- *
- * Hence:
- *
- * red-scale =
- * ( (green-x - blue-x) * (white-y - blue-y) -
- * (green-y - blue-y) * (white-x - blue-x) ) / white-y
- * -------------------------------------------------------------------------
- * (green-x - blue-x)*(red-y - blue-y)-(green-y - blue-y)*(red-x - blue-x)
- *
- * green-scale =
- * ( (red-y - blue-y) * (white-x - blue-x) -
- * (red-x - blue-x) * (white-y - blue-y) ) / white-y
- * -------------------------------------------------------------------------
- * (green-x - blue-x)*(red-y - blue-y)-(green-y - blue-y)*(red-x - blue-x)
- *
- * Accuracy:
- * The input values have 5 decimal digits of accuracy.
- *
- * In the previous implementation the values were all in the range 0 < value
- * < 1, so simple products are in the same range but may need up to 10
- * decimal digits to preserve the original precision and avoid underflow.
- * Because we are using a 32-bit signed representation we cannot match this;
- * the best is a little over 9 decimal digits, less than 10.
- *
- * This range has now been extended to allow values up to 1.1, or 110,000 in
- * fixed point.
- *
- * The approach used here is to preserve the maximum precision within the
- * signed representation. Because the red-scale calculation above uses the
- * difference between two products of values that must be in the range
- * -1.1..+1.1 it is sufficient to divide the product by 8;
- * ceil(121,000/32767*2). The factor is irrelevant in the calculation
- * because it is applied to both numerator and denominator.
- *
- * Note that the values of the differences of the products of the
- * chromaticities in the above equations tend to be small, for example for
- * the sRGB chromaticities they are:
- *
- * red numerator: -0.04751
- * green numerator: -0.08788
- * denominator: -0.2241 (without white-y multiplication)
- *
- * The resultant Y coefficients from the chromaticities of some widely used
- * color space definitions are (to 15 decimal places):
- *
- * sRGB
- * 0.212639005871510 0.715168678767756 0.072192315360734
- * Kodak ProPhoto
- * 0.288071128229293 0.711843217810102 0.000085653960605
- * Adobe RGB
- * 0.297344975250536 0.627363566255466 0.075291458493998
- * Adobe Wide Gamut RGB
- * 0.258728243040113 0.724682314948566 0.016589442011321
- */
- {
- int error = 0;
-
- /* By the argument above overflow should be impossible here, however the
- * code now simply returns a failure code. The xy subtracts in the
- * arguments to png_muldiv are *not* checked for overflow because the
- * checks at the start guarantee they are in the range 0..110000 and
- * png_fixed_point is a 32-bit signed number.
- */
- if (png_muldiv(&left, xy->greenx-xy->bluex, xy->redy - xy->bluey, 8) == 0)
- return 1;
- if (png_muldiv(&right, xy->greeny-xy->bluey, xy->redx - xy->bluex, 8) ==
- 0)
- return 1;
- denominator = png_fp_sub(left, right, &error);
- if (error) return 1;
-
- /* Now find the red numerator. */
- if (png_muldiv(&left, xy->greenx-xy->bluex, xy->whitey-xy->bluey, 8) == 0)
- return 1;
- if (png_muldiv(&right, xy->greeny-xy->bluey, xy->whitex-xy->bluex, 8) ==
- 0)
- return 1;
-
- /* Overflow is possible here and it indicates an extreme set of PNG cHRM
- * chunk values. This calculation actually returns the reciprocal of the
- * scale value because this allows us to delay the multiplication of
- * white-y into the denominator, which tends to produce a small number.
- */
- if (png_muldiv(&red_inverse, xy->whitey, denominator,
- png_fp_sub(left, right, &error)) == 0 || error ||
- red_inverse <= xy->whitey /* r+g+b scales = white scale */)
- return 1;
-
- /* Similarly for green_inverse: */
- if (png_muldiv(&left, xy->redy-xy->bluey, xy->whitex-xy->bluex, 8) == 0)
- return 1;
- if (png_muldiv(&right, xy->redx-xy->bluex, xy->whitey-xy->bluey, 8) == 0)
- return 1;
- if (png_muldiv(&green_inverse, xy->whitey, denominator,
- png_fp_sub(left, right, &error)) == 0 || error ||
- green_inverse <= xy->whitey)
- return 1;
-
- /* And the blue scale, the checks above guarantee this can't overflow but
- * it can still produce 0 for extreme cHRM values.
- */
- blue_scale = png_fp_sub(png_fp_sub(png_reciprocal(xy->whitey),
- png_reciprocal(red_inverse), &error),
- png_reciprocal(green_inverse), &error);
- if (error || blue_scale <= 0)
- return 1;
- }
-
- /* And fill in the png_XYZ. Again the subtracts are safe because of the
- * checks on the xy values at the start (the subtracts just calculate the
- * corresponding z values.)
- */
- if (png_muldiv(&XYZ->red_X, xy->redx, PNG_FP_1, red_inverse) == 0)
- return 1;
- if (png_muldiv(&XYZ->red_Y, xy->redy, PNG_FP_1, red_inverse) == 0)
- return 1;
- if (png_muldiv(&XYZ->red_Z, PNG_FP_1 - xy->redx - xy->redy, PNG_FP_1,
- red_inverse) == 0)
- return 1;
-
- if (png_muldiv(&XYZ->green_X, xy->greenx, PNG_FP_1, green_inverse) == 0)
- return 1;
- if (png_muldiv(&XYZ->green_Y, xy->greeny, PNG_FP_1, green_inverse) == 0)
- return 1;
- if (png_muldiv(&XYZ->green_Z, PNG_FP_1 - xy->greenx - xy->greeny, PNG_FP_1,
- green_inverse) == 0)
- return 1;
-
- if (png_muldiv(&XYZ->blue_X, xy->bluex, blue_scale, PNG_FP_1) == 0)
- return 1;
- if (png_muldiv(&XYZ->blue_Y, xy->bluey, blue_scale, PNG_FP_1) == 0)
- return 1;
- if (png_muldiv(&XYZ->blue_Z, PNG_FP_1 - xy->bluex - xy->bluey, blue_scale,
- PNG_FP_1) == 0)
- return 1;
-
- return 0; /*success*/
-}
-
-static int
-png_XYZ_normalize(png_XYZ *XYZ)
-{
- png_int_32 Y, Ytemp;
-
- /* Normalize by scaling so the sum of the end-point Y values is PNG_FP_1. */
- Ytemp = XYZ->red_Y;
- if (png_safe_add(&Ytemp, XYZ->green_Y, XYZ->blue_Y))
- return 1;
-
- Y = Ytemp;
-
- if (Y != PNG_FP_1)
- {
- if (png_muldiv(&XYZ->red_X, XYZ->red_X, PNG_FP_1, Y) == 0)
- return 1;
- if (png_muldiv(&XYZ->red_Y, XYZ->red_Y, PNG_FP_1, Y) == 0)
- return 1;
- if (png_muldiv(&XYZ->red_Z, XYZ->red_Z, PNG_FP_1, Y) == 0)
- return 1;
-
- if (png_muldiv(&XYZ->green_X, XYZ->green_X, PNG_FP_1, Y) == 0)
- return 1;
- if (png_muldiv(&XYZ->green_Y, XYZ->green_Y, PNG_FP_1, Y) == 0)
- return 1;
- if (png_muldiv(&XYZ->green_Z, XYZ->green_Z, PNG_FP_1, Y) == 0)
- return 1;
-
- if (png_muldiv(&XYZ->blue_X, XYZ->blue_X, PNG_FP_1, Y) == 0)
- return 1;
- if (png_muldiv(&XYZ->blue_Y, XYZ->blue_Y, PNG_FP_1, Y) == 0)
- return 1;
- if (png_muldiv(&XYZ->blue_Z, XYZ->blue_Z, PNG_FP_1, Y) == 0)
- return 1;
- }
-
- return 0;
-}
-
-static int
-png_colorspace_endpoints_match(const png_xy *xy1, const png_xy *xy2, int delta)
-{
- /* Allow an error of +/-0.01 (absolute value) on each chromaticity */
- if (PNG_OUT_OF_RANGE(xy1->whitex, xy2->whitex,delta) ||
- PNG_OUT_OF_RANGE(xy1->whitey, xy2->whitey,delta) ||
- PNG_OUT_OF_RANGE(xy1->redx, xy2->redx, delta) ||
- PNG_OUT_OF_RANGE(xy1->redy, xy2->redy, delta) ||
- PNG_OUT_OF_RANGE(xy1->greenx, xy2->greenx,delta) ||
- PNG_OUT_OF_RANGE(xy1->greeny, xy2->greeny,delta) ||
- PNG_OUT_OF_RANGE(xy1->bluex, xy2->bluex, delta) ||
- PNG_OUT_OF_RANGE(xy1->bluey, xy2->bluey, delta))
- return 0;
- return 1;
-}
-
-/* Added in libpng-1.6.0, a different check for the validity of a set of cHRM
- * chunk chromaticities. Earlier checks used to simply look for the overflow
- * condition (where the determinant of the matrix to solve for XYZ ends up zero
- * because the chromaticity values are not all distinct.) Despite this it is
- * theoretically possible to produce chromaticities that are apparently valid
- * but that rapidly degrade to invalid, potentially crashing, sets because of
- * arithmetic inaccuracies when calculations are performed on them. The new
- * check is to round-trip xy -> XYZ -> xy and then check that the result is
- * within a small percentage of the original.
- */
-static int
-png_colorspace_check_xy(png_XYZ *XYZ, const png_xy *xy)
-{
- int result;
- png_xy xy_test;
-
- /* As a side-effect this routine also returns the XYZ endpoints. */
- result = png_XYZ_from_xy(XYZ, xy);
- if (result != 0)
- return result;
-
- result = png_xy_from_XYZ(&xy_test, XYZ);
- if (result != 0)
- return result;
-
- if (png_colorspace_endpoints_match(xy, &xy_test,
- 5/*actually, the math is pretty accurate*/) != 0)
- return 0;
-
- /* Too much slip */
- return 1;
-}
-
-/* This is the check going the other way. The XYZ is modified to normalize it
- * (another side-effect) and the xy chromaticities are returned.
- */
-static int
-png_colorspace_check_XYZ(png_xy *xy, png_XYZ *XYZ)
-{
- int result;
- png_XYZ XYZtemp;
-
- result = png_XYZ_normalize(XYZ);
- if (result != 0)
- return result;
-
- result = png_xy_from_XYZ(xy, XYZ);
- if (result != 0)
- return result;
-
- XYZtemp = *XYZ;
- return png_colorspace_check_xy(&XYZtemp, xy);
-}
-
-/* Used to check for an endpoint match against sRGB */
-static const png_xy sRGB_xy = /* From ITU-R BT.709-3 */
-{
- /* color x y */
- /* red */ 64000, 33000,
- /* green */ 30000, 60000,
- /* blue */ 15000, 6000,
- /* white */ 31270, 32900
-};
-
-static int
-png_colorspace_set_xy_and_XYZ(png_const_structrp png_ptr,
- png_colorspacerp colorspace, const png_xy *xy, const png_XYZ *XYZ,
- int preferred)
-{
- if ((colorspace->flags & PNG_COLORSPACE_INVALID) != 0)
- return 0;
-
- /* The consistency check is performed on the chromaticities; this factors out
- * variations because of the normalization (or not) of the end point Y
- * values.
- */
- if (preferred < 2 &&
- (colorspace->flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
- {
- /* The end points must be reasonably close to any we already have. The
- * following allows an error of up to +/-.001
- */
- if (png_colorspace_endpoints_match(xy, &colorspace->end_points_xy,
- 100) == 0)
- {
- colorspace->flags |= PNG_COLORSPACE_INVALID;
- png_benign_error(png_ptr, "inconsistent chromaticities");
- return 0; /* failed */
- }
-
- /* Only overwrite with preferred values */
- if (preferred == 0)
- return 1; /* ok, but no change */
- }
-
- colorspace->end_points_xy = *xy;
- colorspace->end_points_XYZ = *XYZ;
- colorspace->flags |= PNG_COLORSPACE_HAVE_ENDPOINTS;
-
- /* The end points are normally quoted to two decimal digits, so allow +/-0.01
- * on this test.
- */
- if (png_colorspace_endpoints_match(xy, &sRGB_xy, 1000) != 0)
- colorspace->flags |= PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB;
-
- else
- colorspace->flags &= PNG_COLORSPACE_CANCEL(
- PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB);
-
- return 2; /* ok and changed */
-}
-
-int /* PRIVATE */
-png_colorspace_set_chromaticities(png_const_structrp png_ptr,
- png_colorspacerp colorspace, const png_xy *xy, int preferred)
-{
- /* We must check the end points to ensure they are reasonable - in the past
- * color management systems have crashed as a result of getting bogus
- * colorant values, while this isn't the fault of libpng it is the
- * responsibility of libpng because PNG carries the bomb and libpng is in a
- * position to protect against it.
- */
- png_XYZ XYZ;
-
- switch (png_colorspace_check_xy(&XYZ, xy))
- {
- case 0: /* success */
- return png_colorspace_set_xy_and_XYZ(png_ptr, colorspace, xy, &XYZ,
- preferred);
-
- case 1:
- /* We can't invert the chromaticities so we can't produce value XYZ
- * values. Likely as not a color management system will fail too.
- */
- colorspace->flags |= PNG_COLORSPACE_INVALID;
- png_benign_error(png_ptr, "invalid chromaticities");
- break;
-
- default:
- /* libpng is broken; this should be a warning but if it happens we
- * want error reports so for the moment it is an error.
- */
- colorspace->flags |= PNG_COLORSPACE_INVALID;
- png_error(png_ptr, "internal error checking chromaticities");
- }
-
- return 0; /* failed */
-}
-
-int /* PRIVATE */
-png_colorspace_set_endpoints(png_const_structrp png_ptr,
- png_colorspacerp colorspace, const png_XYZ *XYZ_in, int preferred)
-{
- png_XYZ XYZ = *XYZ_in;
- png_xy xy;
-
- switch (png_colorspace_check_XYZ(&xy, &XYZ))
- {
- case 0:
- return png_colorspace_set_xy_and_XYZ(png_ptr, colorspace, &xy, &XYZ,
- preferred);
-
- case 1:
- /* End points are invalid. */
- colorspace->flags |= PNG_COLORSPACE_INVALID;
- png_benign_error(png_ptr, "invalid end points");
- break;
-
- default:
- colorspace->flags |= PNG_COLORSPACE_INVALID;
- png_error(png_ptr, "internal error checking chromaticities");
- }
-
- return 0; /* failed */
-}
-
-#if defined(PNG_sRGB_SUPPORTED) || defined(PNG_iCCP_SUPPORTED)
-/* Error message generation */
-static char
-png_icc_tag_char(png_uint_32 byte)
-{
- byte &= 0xff;
- if (byte >= 32 && byte <= 126)
- return (char)byte;
- else
- return '?';
-}
-
-static void
-png_icc_tag_name(char *name, png_uint_32 tag)
-{
- name[0] = '\'';
- name[1] = png_icc_tag_char(tag >> 24);
- name[2] = png_icc_tag_char(tag >> 16);
- name[3] = png_icc_tag_char(tag >> 8);
- name[4] = png_icc_tag_char(tag );
- name[5] = '\'';
-}
-
-static int
-is_ICC_signature_char(png_alloc_size_t it)
-{
- return it == 32 || (it >= 48 && it <= 57) || (it >= 65 && it <= 90) ||
- (it >= 97 && it <= 122);
-}
-
-static int
-is_ICC_signature(png_alloc_size_t it)
-{
- return is_ICC_signature_char(it >> 24) /* checks all the top bits */ &&
- is_ICC_signature_char((it >> 16) & 0xff) &&
- is_ICC_signature_char((it >> 8) & 0xff) &&
- is_ICC_signature_char(it & 0xff);
-}
-
-static int
-png_icc_profile_error(png_const_structrp png_ptr, png_colorspacerp colorspace,
- png_const_charp name, png_alloc_size_t value, png_const_charp reason)
-{
- size_t pos;
- char message[196]; /* see below for calculation */
-
- if (colorspace != NULL)
- colorspace->flags |= PNG_COLORSPACE_INVALID;
-
- pos = png_safecat(message, (sizeof message), 0, "profile '"); /* 9 chars */
- pos = png_safecat(message, pos+79, pos, name); /* Truncate to 79 chars */
- pos = png_safecat(message, (sizeof message), pos, "': "); /* +2 = 90 */
- if (is_ICC_signature(value) != 0)
- {
- /* So 'value' is at most 4 bytes and the following cast is safe */
- png_icc_tag_name(message+pos, (png_uint_32)value);
- pos += 6; /* total +8; less than the else clause */
- message[pos++] = ':';
- message[pos++] = ' ';
- }
-# ifdef PNG_WARNINGS_SUPPORTED
- else
- {
- char number[PNG_NUMBER_BUFFER_SIZE]; /* +24 = 114 */
-
- pos = png_safecat(message, (sizeof message), pos,
- png_format_number(number, number+(sizeof number),
- PNG_NUMBER_FORMAT_x, value));
- pos = png_safecat(message, (sizeof message), pos, "h: "); /* +2 = 116 */
- }
-# endif
- /* The 'reason' is an arbitrary message, allow +79 maximum 195 */
- pos = png_safecat(message, (sizeof message), pos, reason);
- PNG_UNUSED(pos)
-
- /* This is recoverable, but make it unconditionally an app_error on write to
- * avoid writing invalid ICC profiles into PNG files (i.e., we handle them
- * on read, with a warning, but on write unless the app turns off
- * application errors the PNG won't be written.)
- */
- png_chunk_report(png_ptr, message,
- (colorspace != NULL) ? PNG_CHUNK_ERROR : PNG_CHUNK_WRITE_ERROR);
-
- return 0;
-}
-#endif /* sRGB || iCCP */
-
-#ifdef PNG_sRGB_SUPPORTED
-int /* PRIVATE */
-png_colorspace_set_sRGB(png_const_structrp png_ptr, png_colorspacerp colorspace,
- int intent)
-{
- /* sRGB sets known gamma, end points and (from the chunk) intent. */
- /* IMPORTANT: these are not necessarily the values found in an ICC profile
- * because ICC profiles store values adapted to a D50 environment; it is
- * expected that the ICC profile mediaWhitePointTag will be D50; see the
- * checks and code elsewhere to understand this better.
- *
- * These XYZ values, which are accurate to 5dp, produce rgb to gray
- * coefficients of (6968,23435,2366), which are reduced (because they add up
- * to 32769 not 32768) to (6968,23434,2366). These are the values that
- * libpng has traditionally used (and are the best values given the 15bit
- * algorithm used by the rgb to gray code.)
- */
- static const png_XYZ sRGB_XYZ = /* D65 XYZ (*not* the D50 adapted values!) */
- {
- /* color X Y Z */
- /* red */ 41239, 21264, 1933,
- /* green */ 35758, 71517, 11919,
- /* blue */ 18048, 7219, 95053
- };
-
- /* Do nothing if the colorspace is already invalidated. */
- if ((colorspace->flags & PNG_COLORSPACE_INVALID) != 0)
- return 0;
-
- /* Check the intent, then check for existing settings. It is valid for the
- * PNG file to have cHRM or gAMA chunks along with sRGB, but the values must
- * be consistent with the correct values. If, however, this function is
- * called below because an iCCP chunk matches sRGB then it is quite
- * conceivable that an older app recorded incorrect gAMA and cHRM because of
- * an incorrect calculation based on the values in the profile - this does
- * *not* invalidate the profile (though it still produces an error, which can
- * be ignored.)
- */
- if (intent < 0 || intent >= PNG_sRGB_INTENT_LAST)
- return png_icc_profile_error(png_ptr, colorspace, "sRGB",
- (png_alloc_size_t)intent, "invalid sRGB rendering intent");
-
- if ((colorspace->flags & PNG_COLORSPACE_HAVE_INTENT) != 0 &&
- colorspace->rendering_intent != intent)
- return png_icc_profile_error(png_ptr, colorspace, "sRGB",
- (png_alloc_size_t)intent, "inconsistent rendering intents");
-
- if ((colorspace->flags & PNG_COLORSPACE_FROM_sRGB) != 0)
- {
- png_benign_error(png_ptr, "duplicate sRGB information ignored");
- return 0;
- }
-
- /* If the standard sRGB cHRM chunk does not match the one from the PNG file
- * warn but overwrite the value with the correct one.
- */
- if ((colorspace->flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0 &&
- !png_colorspace_endpoints_match(&sRGB_xy, &colorspace->end_points_xy,
- 100))
- png_chunk_report(png_ptr, "cHRM chunk does not match sRGB",
- PNG_CHUNK_ERROR);
-
- /* This check is just done for the error reporting - the routine always
- * returns true when the 'from' argument corresponds to sRGB (2).
- */
- (void)png_colorspace_check_gamma(png_ptr, colorspace, PNG_GAMMA_sRGB_INVERSE,
- 2/*from sRGB*/);
-
- /* intent: bugs in GCC force 'int' to be used as the parameter type. */
- colorspace->rendering_intent = (png_uint_16)intent;
- colorspace->flags |= PNG_COLORSPACE_HAVE_INTENT;
-
- /* endpoints */
- colorspace->end_points_xy = sRGB_xy;
- colorspace->end_points_XYZ = sRGB_XYZ;
- colorspace->flags |=
- (PNG_COLORSPACE_HAVE_ENDPOINTS|PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB);
-
- /* gamma */
- colorspace->gamma = PNG_GAMMA_sRGB_INVERSE;
- colorspace->flags |= PNG_COLORSPACE_HAVE_GAMMA;
-
- /* Finally record that we have an sRGB profile */
- colorspace->flags |=
- (PNG_COLORSPACE_MATCHES_sRGB|PNG_COLORSPACE_FROM_sRGB);
-
- return 1; /* set */
-}
-#endif /* sRGB */
-
-#ifdef PNG_iCCP_SUPPORTED
-/* Encoded value of D50 as an ICC XYZNumber. From the ICC 2010 spec the value
- * is XYZ(0.9642,1.0,0.8249), which scales to:
- *
- * (63189.8112, 65536, 54060.6464)
- */
-static const png_byte D50_nCIEXYZ[12] =
- { 0x00, 0x00, 0xf6, 0xd6, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x2d };
-
-static int /* bool */
-icc_check_length(png_const_structrp png_ptr, png_colorspacerp colorspace,
- png_const_charp name, png_uint_32 profile_length)
-{
- if (profile_length < 132)
- return png_icc_profile_error(png_ptr, colorspace, name, profile_length,
- "too short");
- return 1;
-}
-
-#ifdef PNG_READ_iCCP_SUPPORTED
-int /* PRIVATE */
-png_icc_check_length(png_const_structrp png_ptr, png_colorspacerp colorspace,
- png_const_charp name, png_uint_32 profile_length)
-{
- if (!icc_check_length(png_ptr, colorspace, name, profile_length))
- return 0;
-
- /* This needs to be here because the 'normal' check is in
- * png_decompress_chunk, yet this happens after the attempt to
- * png_malloc_base the required data. We only need this on read; on write
- * the caller supplies the profile buffer so libpng doesn't allocate it. See
- * the call to icc_check_length below (the write case).
- */
-# ifdef PNG_SET_USER_LIMITS_SUPPORTED
- else if (png_ptr->user_chunk_malloc_max > 0 &&
- png_ptr->user_chunk_malloc_max < profile_length)
- return png_icc_profile_error(png_ptr, colorspace, name, profile_length,
- "exceeds application limits");
-# elif PNG_USER_CHUNK_MALLOC_MAX > 0
- else if (PNG_USER_CHUNK_MALLOC_MAX < profile_length)
- return png_icc_profile_error(png_ptr, colorspace, name, profile_length,
- "exceeds libpng limits");
-# else /* !SET_USER_LIMITS */
- /* This will get compiled out on all 32-bit and better systems. */
- else if (PNG_SIZE_MAX < profile_length)
- return png_icc_profile_error(png_ptr, colorspace, name, profile_length,
- "exceeds system limits");
-# endif /* !SET_USER_LIMITS */
-
- return 1;
-}
-#endif /* READ_iCCP */
-
-int /* PRIVATE */
-png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
- png_const_charp name, png_uint_32 profile_length,
- png_const_bytep profile/* first 132 bytes only */, int color_type)
-{
- png_uint_32 temp;
-
- /* Length check; this cannot be ignored in this code because profile_length
- * is used later to check the tag table, so even if the profile seems over
- * long profile_length from the caller must be correct. The caller can fix
- * this up on read or write by just passing in the profile header length.
- */
- temp = png_get_uint_32(profile);
- if (temp != profile_length)
- return png_icc_profile_error(png_ptr, colorspace, name, temp,
- "length does not match profile");
-
- temp = (png_uint_32) (*(profile+8));
- if (temp > 3 && (profile_length & 3))
- return png_icc_profile_error(png_ptr, colorspace, name, profile_length,
- "invalid length");
-
- temp = png_get_uint_32(profile+128); /* tag count: 12 bytes/tag */
- if (temp > 357913930 || /* (2^32-4-132)/12: maximum possible tag count */
- profile_length < 132+12*temp) /* truncated tag table */
- return png_icc_profile_error(png_ptr, colorspace, name, temp,
- "tag count too large");
-
- /* The 'intent' must be valid or we can't store it, ICC limits the intent to
- * 16 bits.
- */
- temp = png_get_uint_32(profile+64);
- if (temp >= 0xffff) /* The ICC limit */
- return png_icc_profile_error(png_ptr, colorspace, name, temp,
- "invalid rendering intent");
-
- /* This is just a warning because the profile may be valid in future
- * versions.
- */
- if (temp >= PNG_sRGB_INTENT_LAST)
- (void)png_icc_profile_error(png_ptr, NULL, name, temp,
- "intent outside defined range");
-
- /* At this point the tag table can't be checked because it hasn't necessarily
- * been loaded; however, various header fields can be checked. These checks
- * are for values permitted by the PNG spec in an ICC profile; the PNG spec
- * restricts the profiles that can be passed in an iCCP chunk (they must be
- * appropriate to processing PNG data!)
- */
-
- /* Data checks (could be skipped). These checks must be independent of the
- * version number; however, the version number doesn't accommodate changes in
- * the header fields (just the known tags and the interpretation of the
- * data.)
- */
- temp = png_get_uint_32(profile+36); /* signature 'ascp' */
- if (temp != 0x61637370)
- return png_icc_profile_error(png_ptr, colorspace, name, temp,
- "invalid signature");
-
- /* Currently the PCS illuminant/adopted white point (the computational
- * white point) are required to be D50,
- * however the profile contains a record of the illuminant so perhaps ICC
- * expects to be able to change this in the future (despite the rationale in
- * the introduction for using a fixed PCS adopted white.) Consequently the
- * following is just a warning.
- */
- if (memcmp(profile+68, D50_nCIEXYZ, 12) != 0)
- (void)png_icc_profile_error(png_ptr, NULL, name, 0/*no tag value*/,
- "PCS illuminant is not D50");
-
- /* The PNG spec requires this:
- * "If the iCCP chunk is present, the image samples conform to the colour
- * space represented by the embedded ICC profile as defined by the
- * International Color Consortium [ICC]. The colour space of the ICC profile
- * shall be an RGB colour space for colour images (PNG colour types 2, 3, and
- * 6), or a greyscale colour space for greyscale images (PNG colour types 0
- * and 4)."
- *
- * This checking code ensures the embedded profile (on either read or write)
- * conforms to the specification requirements. Notice that an ICC 'gray'
- * color-space profile contains the information to transform the monochrome
- * data to XYZ or L*a*b (according to which PCS the profile uses) and this
- * should be used in preference to the standard libpng K channel replication
- * into R, G and B channels.
- *
- * Previously it was suggested that an RGB profile on grayscale data could be
- * handled. However it it is clear that using an RGB profile in this context
- * must be an error - there is no specification of what it means. Thus it is
- * almost certainly more correct to ignore the profile.
- */
- temp = png_get_uint_32(profile+16); /* data colour space field */
- switch (temp)
- {
- case 0x52474220: /* 'RGB ' */
- if ((color_type & PNG_COLOR_MASK_COLOR) == 0)
- return png_icc_profile_error(png_ptr, colorspace, name, temp,
- "RGB color space not permitted on grayscale PNG");
- break;
-
- case 0x47524159: /* 'GRAY' */
- if ((color_type & PNG_COLOR_MASK_COLOR) != 0)
- return png_icc_profile_error(png_ptr, colorspace, name, temp,
- "Gray color space not permitted on RGB PNG");
- break;
-
- default:
- return png_icc_profile_error(png_ptr, colorspace, name, temp,
- "invalid ICC profile color space");
- }
-
- /* It is up to the application to check that the profile class matches the
- * application requirements; the spec provides no guidance, but it's pretty
- * weird if the profile is not scanner ('scnr'), monitor ('mntr'), printer
- * ('prtr') or 'spac' (for generic color spaces). Issue a warning in these
- * cases. Issue an error for device link or abstract profiles - these don't
- * contain the records necessary to transform the color-space to anything
- * other than the target device (and not even that for an abstract profile).
- * Profiles of these classes may not be embedded in images.
- */
- temp = png_get_uint_32(profile+12); /* profile/device class */
- switch (temp)
- {
- case 0x73636e72: /* 'scnr' */
- case 0x6d6e7472: /* 'mntr' */
- case 0x70727472: /* 'prtr' */
- case 0x73706163: /* 'spac' */
- /* All supported */
- break;
-
- case 0x61627374: /* 'abst' */
- /* May not be embedded in an image */
- return png_icc_profile_error(png_ptr, colorspace, name, temp,
- "invalid embedded Abstract ICC profile");
-
- case 0x6c696e6b: /* 'link' */
- /* DeviceLink profiles cannot be interpreted in a non-device specific
- * fashion, if an app uses the AToB0Tag in the profile the results are
- * undefined unless the result is sent to the intended device,
- * therefore a DeviceLink profile should not be found embedded in a
- * PNG.
- */
- return png_icc_profile_error(png_ptr, colorspace, name, temp,
- "unexpected DeviceLink ICC profile class");
-
- case 0x6e6d636c: /* 'nmcl' */
- /* A NamedColor profile is also device specific, however it doesn't
- * contain an AToB0 tag that is open to misinterpretation. Almost
- * certainly it will fail the tests below.
- */
- (void)png_icc_profile_error(png_ptr, NULL, name, temp,
- "unexpected NamedColor ICC profile class");
- break;
-
- default:
- /* To allow for future enhancements to the profile accept unrecognized
- * profile classes with a warning, these then hit the test below on the
- * tag content to ensure they are backward compatible with one of the
- * understood profiles.
- */
- (void)png_icc_profile_error(png_ptr, NULL, name, temp,
- "unrecognized ICC profile class");
- break;
- }
-
- /* For any profile other than a device link one the PCS must be encoded
- * either in XYZ or Lab.
- */
- temp = png_get_uint_32(profile+20);
- switch (temp)
- {
- case 0x58595a20: /* 'XYZ ' */
- case 0x4c616220: /* 'Lab ' */
- break;
-
- default:
- return png_icc_profile_error(png_ptr, colorspace, name, temp,
- "unexpected ICC PCS encoding");
- }
-
- return 1;
-}
-
-int /* PRIVATE */
-png_icc_check_tag_table(png_const_structrp png_ptr, png_colorspacerp colorspace,
- png_const_charp name, png_uint_32 profile_length,
- png_const_bytep profile /* header plus whole tag table */)
-{
- png_uint_32 tag_count = png_get_uint_32(profile+128);
- png_uint_32 itag;
- png_const_bytep tag = profile+132; /* The first tag */
-
- /* First scan all the tags in the table and add bits to the icc_info value
- * (temporarily in 'tags').
- */
- for (itag=0; itag < tag_count; ++itag, tag += 12)
- {
- png_uint_32 tag_id = png_get_uint_32(tag+0);
- png_uint_32 tag_start = png_get_uint_32(tag+4); /* must be aligned */
- png_uint_32 tag_length = png_get_uint_32(tag+8);/* not padded */
-
- /* The ICC specification does not exclude zero length tags, therefore the
- * start might actually be anywhere if there is no data, but this would be
- * a clear abuse of the intent of the standard so the start is checked for
- * being in range. All defined tag types have an 8 byte header - a 4 byte
- * type signature then 0.
- */
-
- /* This is a hard error; potentially it can cause read outside the
- * profile.
- */
- if (tag_start > profile_length || tag_length > profile_length - tag_start)
- return png_icc_profile_error(png_ptr, colorspace, name, tag_id,
- "ICC profile tag outside profile");
-
- if ((tag_start & 3) != 0)
- {
- /* CNHP730S.icc shipped with Microsoft Windows 64 violates this; it is
- * only a warning here because libpng does not care about the
- * alignment.
- */
- (void)png_icc_profile_error(png_ptr, NULL, name, tag_id,
- "ICC profile tag start not a multiple of 4");
- }
- }
-
- return 1; /* success, maybe with warnings */
-}
-
-#ifdef PNG_sRGB_SUPPORTED
-#if PNG_sRGB_PROFILE_CHECKS >= 0
-/* Information about the known ICC sRGB profiles */
-static const struct
-{
- png_uint_32 adler, crc, length;
- png_uint_32 md5[4];
- png_byte have_md5;
- png_byte is_broken;
- png_uint_16 intent;
-
-# define PNG_MD5(a,b,c,d) { a, b, c, d }, (a!=0)||(b!=0)||(c!=0)||(d!=0)
-# define PNG_ICC_CHECKSUM(adler, crc, md5, intent, broke, date, length, fname)\
- { adler, crc, length, md5, broke, intent },
-
-} png_sRGB_checks[] =
-{
- /* This data comes from contrib/tools/checksum-icc run on downloads of
- * all four ICC sRGB profiles from www.color.org.
- */
- /* adler32, crc32, MD5[4], intent, date, length, file-name */
- PNG_ICC_CHECKSUM(0x0a3fd9f6, 0x3b8772b9,
- PNG_MD5(0x29f83dde, 0xaff255ae, 0x7842fae4, 0xca83390d), 0, 0,
- "2009/03/27 21:36:31", 3048, "sRGB_IEC61966-2-1_black_scaled.icc")
-
- /* ICC sRGB v2 perceptual no black-compensation: */
- PNG_ICC_CHECKSUM(0x4909e5e1, 0x427ebb21,
- PNG_MD5(0xc95bd637, 0xe95d8a3b, 0x0df38f99, 0xc1320389), 1, 0,
- "2009/03/27 21:37:45", 3052, "sRGB_IEC61966-2-1_no_black_scaling.icc")
-
- PNG_ICC_CHECKSUM(0xfd2144a1, 0x306fd8ae,
- PNG_MD5(0xfc663378, 0x37e2886b, 0xfd72e983, 0x8228f1b8), 0, 0,
- "2009/08/10 17:28:01", 60988, "sRGB_v4_ICC_preference_displayclass.icc")
-
- /* ICC sRGB v4 perceptual */
- PNG_ICC_CHECKSUM(0x209c35d2, 0xbbef7812,
- PNG_MD5(0x34562abf, 0x994ccd06, 0x6d2c5721, 0xd0d68c5d), 0, 0,
- "2007/07/25 00:05:37", 60960, "sRGB_v4_ICC_preference.icc")
-
- /* The following profiles have no known MD5 checksum. If there is a match
- * on the (empty) MD5 the other fields are used to attempt a match and
- * a warning is produced. The first two of these profiles have a 'cprt' tag
- * which suggests that they were also made by Hewlett Packard.
- */
- PNG_ICC_CHECKSUM(0xa054d762, 0x5d5129ce,
- PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 1, 0,
- "2004/07/21 18:57:42", 3024, "sRGB_IEC61966-2-1_noBPC.icc")
-
- /* This is a 'mntr' (display) profile with a mediaWhitePointTag that does not
- * match the D50 PCS illuminant in the header (it is in fact the D65 values,
- * so the white point is recorded as the un-adapted value.) The profiles
- * below only differ in one byte - the intent - and are basically the same as
- * the previous profile except for the mediaWhitePointTag error and a missing
- * chromaticAdaptationTag.
- */
- PNG_ICC_CHECKSUM(0xf784f3fb, 0x182ea552,
- PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 0, 1/*broken*/,
- "1998/02/09 06:49:00", 3144, "HP-Microsoft sRGB v2 perceptual")
-
- PNG_ICC_CHECKSUM(0x0398f3fc, 0xf29e526d,
- PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 1, 1/*broken*/,
- "1998/02/09 06:49:00", 3144, "HP-Microsoft sRGB v2 media-relative")
-};
-
-static int
-png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr,
- png_const_bytep profile, uLong adler)
-{
- /* The quick check is to verify just the MD5 signature and trust the
- * rest of the data. Because the profile has already been verified for
- * correctness this is safe. png_colorspace_set_sRGB will check the 'intent'
- * field too, so if the profile has been edited with an intent not defined
- * by sRGB (but maybe defined by a later ICC specification) the read of
- * the profile will fail at that point.
- */
-
- png_uint_32 length = 0;
- png_uint_32 intent = 0x10000; /* invalid */
-#if PNG_sRGB_PROFILE_CHECKS > 1
- uLong crc = 0; /* the value for 0 length data */
-#endif
- unsigned int i;
-
-#ifdef PNG_SET_OPTION_SUPPORTED
- /* First see if PNG_SKIP_sRGB_CHECK_PROFILE has been set to "on" */
- if (((png_ptr->options >> PNG_SKIP_sRGB_CHECK_PROFILE) & 3) ==
- PNG_OPTION_ON)
- return 0;
-#endif
-
- for (i=0; i < (sizeof png_sRGB_checks) / (sizeof png_sRGB_checks[0]); ++i)
- {
- if (png_get_uint_32(profile+84) == png_sRGB_checks[i].md5[0] &&
- png_get_uint_32(profile+88) == png_sRGB_checks[i].md5[1] &&
- png_get_uint_32(profile+92) == png_sRGB_checks[i].md5[2] &&
- png_get_uint_32(profile+96) == png_sRGB_checks[i].md5[3])
- {
- /* This may be one of the old HP profiles without an MD5, in that
- * case we can only use the length and Adler32 (note that these
- * are not used by default if there is an MD5!)
- */
-# if PNG_sRGB_PROFILE_CHECKS == 0
- if (png_sRGB_checks[i].have_md5 != 0)
- return 1+png_sRGB_checks[i].is_broken;
-# endif
-
- /* Profile is unsigned or more checks have been configured in. */
- if (length == 0)
- {
- length = png_get_uint_32(profile);
- intent = png_get_uint_32(profile+64);
- }
-
- /* Length *and* intent must match */
- if (length == (png_uint_32) png_sRGB_checks[i].length &&
- intent == (png_uint_32) png_sRGB_checks[i].intent)
- {
- /* Now calculate the adler32 if not done already. */
- if (adler == 0)
- {
- adler = adler32(0, NULL, 0);
- adler = adler32(adler, profile, length);
- }
-
- if (adler == png_sRGB_checks[i].adler)
- {
- /* These basic checks suggest that the data has not been
- * modified, but if the check level is more than 1 perform
- * our own crc32 checksum on the data.
- */
-# if PNG_sRGB_PROFILE_CHECKS > 1
- if (crc == 0)
- {
- crc = crc32(0, NULL, 0);
- crc = crc32(crc, profile, length);
- }
-
- /* So this check must pass for the 'return' below to happen.
- */
- if (crc == png_sRGB_checks[i].crc)
-# endif
- {
- if (png_sRGB_checks[i].is_broken != 0)
- {
- /* These profiles are known to have bad data that may cause
- * problems if they are used, therefore attempt to
- * discourage their use, skip the 'have_md5' warning below,
- * which is made irrelevant by this error.
- */
- png_chunk_report(png_ptr, "known incorrect sRGB profile",
- PNG_CHUNK_ERROR);
- }
-
- /* Warn that this being done; this isn't even an error since
- * the profile is perfectly valid, but it would be nice if
- * people used the up-to-date ones.
- */
- else if (png_sRGB_checks[i].have_md5 == 0)
- {
- png_chunk_report(png_ptr,
- "out-of-date sRGB profile with no signature",
- PNG_CHUNK_WARNING);
- }
-
- return 1+png_sRGB_checks[i].is_broken;
- }
- }
-
-# if PNG_sRGB_PROFILE_CHECKS > 0
- /* The signature matched, but the profile had been changed in some
- * way. This probably indicates a data error or uninformed hacking.
- * Fall through to "no match".
- */
- png_chunk_report(png_ptr,
- "Not recognizing known sRGB profile that has been edited",
- PNG_CHUNK_WARNING);
- break;
-# endif
- }
- }
- }
-
- return 0; /* no match */
-}
-
-void /* PRIVATE */
-png_icc_set_sRGB(png_const_structrp png_ptr,
- png_colorspacerp colorspace, png_const_bytep profile, uLong adler)
-{
- /* Is this profile one of the known ICC sRGB profiles? If it is, just set
- * the sRGB information.
- */
- if (png_compare_ICC_profile_with_sRGB(png_ptr, profile, adler) != 0)
- (void)png_colorspace_set_sRGB(png_ptr, colorspace,
- (int)/*already checked*/png_get_uint_32(profile+64));
-}
-#endif /* PNG_sRGB_PROFILE_CHECKS >= 0 */
-#endif /* sRGB */
-
-int /* PRIVATE */
-png_colorspace_set_ICC(png_const_structrp png_ptr, png_colorspacerp colorspace,
- png_const_charp name, png_uint_32 profile_length, png_const_bytep profile,
- int color_type)
-{
- if ((colorspace->flags & PNG_COLORSPACE_INVALID) != 0)
- return 0;
-
- if (icc_check_length(png_ptr, colorspace, name, profile_length) != 0 &&
- png_icc_check_header(png_ptr, colorspace, name, profile_length, profile,
- color_type) != 0 &&
- png_icc_check_tag_table(png_ptr, colorspace, name, profile_length,
- profile) != 0)
- {
-# if defined(PNG_sRGB_SUPPORTED) && PNG_sRGB_PROFILE_CHECKS >= 0
- /* If no sRGB support, don't try storing sRGB information */
- png_icc_set_sRGB(png_ptr, colorspace, profile, 0);
-# endif
- return 1;
- }
-
- /* Failure case */
- return 0;
-}
-#endif /* iCCP */
-
-#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
-void /* PRIVATE */
-png_colorspace_set_rgb_coefficients(png_structrp png_ptr)
-{
- /* Set the rgb_to_gray coefficients from the colorspace. */
- if (png_ptr->rgb_to_gray_coefficients_set == 0 &&
- (png_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
- {
- /* png_set_background has not been called, get the coefficients from the Y
- * values of the colorspace colorants.
- */
- png_fixed_point r = png_ptr->colorspace.end_points_XYZ.red_Y;
- png_fixed_point g = png_ptr->colorspace.end_points_XYZ.green_Y;
- png_fixed_point b = png_ptr->colorspace.end_points_XYZ.blue_Y;
- png_fixed_point total = r+g+b;
-
- if (total > 0 &&
- r >= 0 && png_muldiv(&r, r, 32768, total) && r >= 0 && r <= 32768 &&
- g >= 0 && png_muldiv(&g, g, 32768, total) && g >= 0 && g <= 32768 &&
- b >= 0 && png_muldiv(&b, b, 32768, total) && b >= 0 && b <= 32768 &&
- r+g+b <= 32769)
- {
- /* We allow 0 coefficients here. r+g+b may be 32769 if two or
- * all of the coefficients were rounded up. Handle this by
- * reducing the *largest* coefficient by 1; this matches the
- * approach used for the default coefficients in pngrtran.c
- */
- int add = 0;
-
- if (r+g+b > 32768)
- add = -1;
- else if (r+g+b < 32768)
- add = 1;
-
- if (add != 0)
- {
- if (g >= r && g >= b)
- g += add;
- else if (r >= g && r >= b)
- r += add;
- else
- b += add;
- }
-
- /* Check for an internal error. */
- if (r+g+b != 32768)
- png_error(png_ptr,
- "internal error handling cHRM coefficients");
-
- else
- {
- png_ptr->rgb_to_gray_red_coeff = (png_uint_16)r;
- png_ptr->rgb_to_gray_green_coeff = (png_uint_16)g;
- }
- }
-
- /* This is a png_error at present even though it could be ignored -
- * it should never happen, but it is important that if it does, the
- * bug is fixed.
- */
- else
- png_error(png_ptr, "internal error handling cHRM->XYZ");
- }
-}
-#endif /* READ_RGB_TO_GRAY */
-
-#endif /* COLORSPACE */
-
-void /* PRIVATE */
-png_check_IHDR(png_const_structrp png_ptr,
- png_uint_32 width, png_uint_32 height, int bit_depth,
- int color_type, int interlace_type, int compression_type,
- int filter_type)
-{
- int error = 0;
-
- /* Check for width and height valid values */
- if (width == 0)
- {
- png_warning(png_ptr, "Image width is zero in IHDR");
- error = 1;
- }
-
- if (width > PNG_UINT_31_MAX)
- {
- png_warning(png_ptr, "Invalid image width in IHDR");
- error = 1;
- }
-
- /* The bit mask on the first line below must be at least as big as a
- * png_uint_32. "~7U" is not adequate on 16-bit systems because it will
- * be an unsigned 16-bit value. Casting to (png_alloc_size_t) makes the
- * type of the result at least as bit (in bits) as the RHS of the > operator
- * which also avoids a common warning on 64-bit systems that the comparison
- * of (png_uint_32) against the constant value on the RHS will always be
- * false.
- */
- if (((width + 7) & ~(png_alloc_size_t)7) >
- (((PNG_SIZE_MAX
- - 48 /* big_row_buf hack */
- - 1) /* filter byte */
- / 8) /* 8-byte RGBA pixels */
- - 1)) /* extra max_pixel_depth pad */
- {
- /* The size of the row must be within the limits of this architecture.
- * Because the read code can perform arbitrary transformations the
- * maximum size is checked here. Because the code in png_read_start_row
- * adds extra space "for safety's sake" in several places a conservative
- * limit is used here.
- *
- * NOTE: it would be far better to check the size that is actually used,
- * but the effect in the real world is minor and the changes are more
- * extensive, therefore much more dangerous and much more difficult to
- * write in a way that avoids compiler warnings.
- */
- png_warning(png_ptr, "Image width is too large for this architecture");
- error = 1;
- }
-
-#ifdef PNG_SET_USER_LIMITS_SUPPORTED
- if (width > png_ptr->user_width_max)
-#else
- if (width > PNG_USER_WIDTH_MAX)
-#endif
- {
- png_warning(png_ptr, "Image width exceeds user limit in IHDR");
- error = 1;
- }
-
- if (height == 0)
- {
- png_warning(png_ptr, "Image height is zero in IHDR");
- error = 1;
- }
-
- if (height > PNG_UINT_31_MAX)
- {
- png_warning(png_ptr, "Invalid image height in IHDR");
- error = 1;
- }
-
-#ifdef PNG_SET_USER_LIMITS_SUPPORTED
- if (height > png_ptr->user_height_max)
-#else
- if (height > PNG_USER_HEIGHT_MAX)
-#endif
- {
- png_warning(png_ptr, "Image height exceeds user limit in IHDR");
- error = 1;
- }
-
- /* Check other values */
- if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 &&
- bit_depth != 8 && bit_depth != 16)
- {
- png_warning(png_ptr, "Invalid bit depth in IHDR");
- error = 1;
- }
-
- if (color_type < 0 || color_type == 1 ||
- color_type == 5 || color_type > 6)
- {
- png_warning(png_ptr, "Invalid color type in IHDR");
- error = 1;
- }
-
- if (((color_type == PNG_COLOR_TYPE_PALETTE) && bit_depth > 8) ||
- ((color_type == PNG_COLOR_TYPE_RGB ||
- color_type == PNG_COLOR_TYPE_GRAY_ALPHA ||
- color_type == PNG_COLOR_TYPE_RGB_ALPHA) && bit_depth < 8))
- {
- png_warning(png_ptr, "Invalid color type/bit depth combination in IHDR");
- error = 1;
- }
-
- if (interlace_type >= PNG_INTERLACE_LAST)
- {
- png_warning(png_ptr, "Unknown interlace method in IHDR");
- error = 1;
- }
-
- if (compression_type != PNG_COMPRESSION_TYPE_BASE)
- {
- png_warning(png_ptr, "Unknown compression method in IHDR");
- error = 1;
- }
-
-#ifdef PNG_MNG_FEATURES_SUPPORTED
- /* Accept filter_method 64 (intrapixel differencing) only if
- * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and
- * 2. Libpng did not read a PNG signature (this filter_method is only
- * used in PNG datastreams that are embedded in MNG datastreams) and
- * 3. The application called png_permit_mng_features with a mask that
- * included PNG_FLAG_MNG_FILTER_64 and
- * 4. The filter_method is 64 and
- * 5. The color_type is RGB or RGBA
- */
- if ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) != 0 &&
- png_ptr->mng_features_permitted != 0)
- png_warning(png_ptr, "MNG features are not allowed in a PNG datastream");
-
- if (filter_type != PNG_FILTER_TYPE_BASE)
- {
- if (!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) != 0 &&
- (filter_type == PNG_INTRAPIXEL_DIFFERENCING) &&
- ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) == 0) &&
- (color_type == PNG_COLOR_TYPE_RGB ||
- color_type == PNG_COLOR_TYPE_RGB_ALPHA)))
- {
- png_warning(png_ptr, "Unknown filter method in IHDR");
- error = 1;
- }
-
- if ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) != 0)
- {
- png_warning(png_ptr, "Invalid filter method in IHDR");
- error = 1;
- }
- }
-
-#else
- if (filter_type != PNG_FILTER_TYPE_BASE)
- {
- png_warning(png_ptr, "Unknown filter method in IHDR");
- error = 1;
- }
-#endif
-
- if (error == 1)
- png_error(png_ptr, "Invalid IHDR data");
-}
-
-#if defined(PNG_sCAL_SUPPORTED) || defined(PNG_pCAL_SUPPORTED)
-/* ASCII to fp functions */
-/* Check an ASCII formatted floating point value, see the more detailed
- * comments in pngpriv.h
- */
-/* The following is used internally to preserve the sticky flags */
-#define png_fp_add(state, flags) ((state) |= (flags))
-#define png_fp_set(state, value) ((state) = (value) | ((state) & PNG_FP_STICKY))
-
-int /* PRIVATE */
-png_check_fp_number(png_const_charp string, size_t size, int *statep,
- size_t *whereami)
-{
- int state = *statep;
- size_t i = *whereami;
-
- while (i < size)
- {
- int type;
- /* First find the type of the next character */
- switch (string[i])
- {
- case 43: type = PNG_FP_SAW_SIGN; break;
- case 45: type = PNG_FP_SAW_SIGN + PNG_FP_NEGATIVE; break;
- case 46: type = PNG_FP_SAW_DOT; break;
- case 48: type = PNG_FP_SAW_DIGIT; break;
- case 49: case 50: case 51: case 52:
- case 53: case 54: case 55: case 56:
- case 57: type = PNG_FP_SAW_DIGIT + PNG_FP_NONZERO; break;
- case 69:
- case 101: type = PNG_FP_SAW_E; break;
- default: goto PNG_FP_End;
- }
-
- /* Now deal with this type according to the current
- * state, the type is arranged to not overlap the
- * bits of the PNG_FP_STATE.
- */
- switch ((state & PNG_FP_STATE) + (type & PNG_FP_SAW_ANY))
- {
- case PNG_FP_INTEGER + PNG_FP_SAW_SIGN:
- if ((state & PNG_FP_SAW_ANY) != 0)
- goto PNG_FP_End; /* not a part of the number */
-
- png_fp_add(state, type);
- break;
-
- case PNG_FP_INTEGER + PNG_FP_SAW_DOT:
- /* Ok as trailer, ok as lead of fraction. */
- if ((state & PNG_FP_SAW_DOT) != 0) /* two dots */
- goto PNG_FP_End;
-
- else if ((state & PNG_FP_SAW_DIGIT) != 0) /* trailing dot? */
- png_fp_add(state, type);
-
- else
- png_fp_set(state, PNG_FP_FRACTION | type);
-
- break;
-
- case PNG_FP_INTEGER + PNG_FP_SAW_DIGIT:
- if ((state & PNG_FP_SAW_DOT) != 0) /* delayed fraction */
- png_fp_set(state, PNG_FP_FRACTION | PNG_FP_SAW_DOT);
-
- png_fp_add(state, type | PNG_FP_WAS_VALID);
-
- break;
-
- case PNG_FP_INTEGER + PNG_FP_SAW_E:
- if ((state & PNG_FP_SAW_DIGIT) == 0)
- goto PNG_FP_End;
-
- png_fp_set(state, PNG_FP_EXPONENT);
-
- break;
-
- /* case PNG_FP_FRACTION + PNG_FP_SAW_SIGN:
- goto PNG_FP_End; ** no sign in fraction */
-
- /* case PNG_FP_FRACTION + PNG_FP_SAW_DOT:
- goto PNG_FP_End; ** Because SAW_DOT is always set */
-
- case PNG_FP_FRACTION + PNG_FP_SAW_DIGIT:
- png_fp_add(state, type | PNG_FP_WAS_VALID);
- break;
-
- case PNG_FP_FRACTION + PNG_FP_SAW_E:
- /* This is correct because the trailing '.' on an
- * integer is handled above - so we can only get here
- * with the sequence ".E" (with no preceding digits).
- */
- if ((state & PNG_FP_SAW_DIGIT) == 0)
- goto PNG_FP_End;
-
- png_fp_set(state, PNG_FP_EXPONENT);
-
- break;
-
- case PNG_FP_EXPONENT + PNG_FP_SAW_SIGN:
- if ((state & PNG_FP_SAW_ANY) != 0)
- goto PNG_FP_End; /* not a part of the number */
-
- png_fp_add(state, PNG_FP_SAW_SIGN);
-
- break;
-
- /* case PNG_FP_EXPONENT + PNG_FP_SAW_DOT:
- goto PNG_FP_End; */
-
- case PNG_FP_EXPONENT + PNG_FP_SAW_DIGIT:
- png_fp_add(state, PNG_FP_SAW_DIGIT | PNG_FP_WAS_VALID);
-
- break;
-
- /* case PNG_FP_EXPONEXT + PNG_FP_SAW_E:
- goto PNG_FP_End; */
-
- default: goto PNG_FP_End; /* I.e. break 2 */
- }
-
- /* The character seems ok, continue. */
- ++i;
- }
-
-PNG_FP_End:
- /* Here at the end, update the state and return the correct
- * return code.
- */
- *statep = state;
- *whereami = i;
-
- return (state & PNG_FP_SAW_DIGIT) != 0;
-}
-
-
-/* The same but for a complete string. */
-int
-png_check_fp_string(png_const_charp string, size_t size)
-{
- int state=0;
- size_t char_index=0;
-
- if (png_check_fp_number(string, size, &state, &char_index) != 0 &&
- (char_index == size || string[char_index] == 0))
- return state /* must be non-zero - see above */;
-
- return 0; /* i.e. fail */
-}
-#endif /* pCAL || sCAL */
-
-#ifdef PNG_sCAL_SUPPORTED
-# ifdef PNG_FLOATING_POINT_SUPPORTED
-/* Utility used below - a simple accurate power of ten from an integral
- * exponent.
- */
-static double
-png_pow10(int power)
-{
- int recip = 0;
- double d = 1;
-
- /* Handle negative exponent with a reciprocal at the end because
- * 10 is exact whereas .1 is inexact in base 2
- */
- if (power < 0)
- {
- if (power < DBL_MIN_10_EXP) return 0;
- recip = 1; power = -power;
- }
-
- if (power > 0)
- {
- /* Decompose power bitwise. */
- double mult = 10;
- do
- {
- if (power & 1) d *= mult;
- mult *= mult;
- power >>= 1;
- }
- while (power > 0);
-
- if (recip != 0) d = 1/d;
- }
- /* else power is 0 and d is 1 */
-
- return d;
-}
-
-/* Function to format a floating point value in ASCII with a given
- * precision.
- */
-void /* PRIVATE */
-png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, size_t size,
- double fp, unsigned int precision)
-{
- /* We use standard functions from math.h, but not printf because
- * that would require stdio. The caller must supply a buffer of
- * sufficient size or we will png_error. The tests on size and
- * the space in ascii[] consumed are indicated below.
- */
- if (precision < 1)
- precision = DBL_DIG;
-
- /* Enforce the limit of the implementation precision too. */
- if (precision > DBL_DIG+1)
- precision = DBL_DIG+1;
-
- /* Basic sanity checks */
- if (size >= precision+5) /* See the requirements below. */
- {
- if (fp < 0)
- {
- fp = -fp;
- *ascii++ = 45; /* '-' PLUS 1 TOTAL 1 */
- --size;
- }
-
- if (fp >= DBL_MIN && fp <= DBL_MAX)
- {
- int exp_b10; /* A base 10 exponent */
- double base; /* 10^exp_b10 */
-
- /* First extract a base 10 exponent of the number,
- * the calculation below rounds down when converting
- * from base 2 to base 10 (multiply by log10(2) -
- * 0.3010, but 77/256 is 0.3008, so exp_b10 needs to
- * be increased. Note that the arithmetic shift
- * performs a floor() unlike C arithmetic - using a
- * C multiply would break the following for negative
- * exponents.
- */
- (void)frexp(fp, &exp_b10); /* exponent to base 2 */
-
- exp_b10 = (exp_b10 * 77) >> 8; /* <= exponent to base 10 */
-
- /* Avoid underflow here. */
- base = png_pow10(exp_b10); /* May underflow */
-
- while (base < DBL_MIN || base < fp)
- {
- /* And this may overflow. */
- double test = png_pow10(exp_b10+1);
-
- if (test <= DBL_MAX)
- {
- ++exp_b10; base = test;
- }
-
- else
- break;
- }
-
- /* Normalize fp and correct exp_b10, after this fp is in the
- * range [.1,1) and exp_b10 is both the exponent and the digit
- * *before* which the decimal point should be inserted
- * (starting with 0 for the first digit). Note that this
- * works even if 10^exp_b10 is out of range because of the
- * test on DBL_MAX above.
- */
- fp /= base;
- while (fp >= 1)
- {
- fp /= 10; ++exp_b10;
- }
-
- /* Because of the code above fp may, at this point, be
- * less than .1, this is ok because the code below can
- * handle the leading zeros this generates, so no attempt
- * is made to correct that here.
- */
-
- {
- unsigned int czero, clead, cdigits;
- char exponent[10];
-
- /* Allow up to two leading zeros - this will not lengthen
- * the number compared to using E-n.
- */
- if (exp_b10 < 0 && exp_b10 > -3) /* PLUS 3 TOTAL 4 */
- {
- czero = 0U-exp_b10; /* PLUS 2 digits: TOTAL 3 */
- exp_b10 = 0; /* Dot added below before first output. */
- }
- else
- czero = 0; /* No zeros to add */
-
- /* Generate the digit list, stripping trailing zeros and
- * inserting a '.' before a digit if the exponent is 0.
- */
- clead = czero; /* Count of leading zeros */
- cdigits = 0; /* Count of digits in list. */
-
- do
- {
- double d;
-
- fp *= 10;
- /* Use modf here, not floor and subtract, so that
- * the separation is done in one step. At the end
- * of the loop don't break the number into parts so
- * that the final digit is rounded.
- */
- if (cdigits+czero+1 < precision+clead)
- fp = modf(fp, &d);
-
- else
- {
- d = floor(fp + .5);
-
- if (d > 9)
- {
- /* Rounding up to 10, handle that here. */
- if (czero > 0)
- {
- --czero; d = 1;
- if (cdigits == 0) --clead;
- }
- else
- {
- while (cdigits > 0 && d > 9)
- {
- int ch = *--ascii;
-
- if (exp_b10 != (-1))
- ++exp_b10;
-
- else if (ch == 46)
- {
- ch = *--ascii; ++size;
- /* Advance exp_b10 to '1', so that the
- * decimal point happens after the
- * previous digit.
- */
- exp_b10 = 1;
- }
-
- --cdigits;
- d = ch - 47; /* I.e. 1+(ch-48) */
- }
-
- /* Did we reach the beginning? If so adjust the
- * exponent but take into account the leading
- * decimal point.
- */
- if (d > 9) /* cdigits == 0 */
- {
- if (exp_b10 == (-1))
- {
- /* Leading decimal point (plus zeros?), if
- * we lose the decimal point here it must
- * be reentered below.
- */
- int ch = *--ascii;
-
- if (ch == 46)
- {
- ++size; exp_b10 = 1;
- }
-
- /* Else lost a leading zero, so 'exp_b10' is
- * still ok at (-1)
- */
- }
- else
- ++exp_b10;
-
- /* In all cases we output a '1' */
- d = 1;
- }
- }
- }
- fp = 0; /* Guarantees termination below. */
- }
-
- if (d == 0)
- {
- ++czero;
- if (cdigits == 0) ++clead;
- }
- else
- {
- /* Included embedded zeros in the digit count. */
- cdigits += czero - clead;
- clead = 0;
-
- while (czero > 0)
- {
- /* exp_b10 == (-1) means we just output the decimal
- * place - after the DP don't adjust 'exp_b10' any
- * more!
- */
- if (exp_b10 != (-1))
- {
- if (exp_b10 == 0)
- {
- *ascii++ = 46; --size;
- }
- /* PLUS 1: TOTAL 4 */
- --exp_b10;
- }
- *ascii++ = 48; --czero;
- }
-
- if (exp_b10 != (-1))
- {
- if (exp_b10 == 0)
- {
- *ascii++ = 46; --size; /* counted above */
- }
-
- --exp_b10;
- }
- *ascii++ = (char)(48 + (int)d); ++cdigits;
- }
- }
- while (cdigits+czero < precision+clead && fp > DBL_MIN);
-
- /* The total output count (max) is now 4+precision */
-
- /* Check for an exponent, if we don't need one we are
- * done and just need to terminate the string. At this
- * point, exp_b10==(-1) is effectively a flag: it got
- * to '-1' because of the decrement, after outputting
- * the decimal point above. (The exponent required is
- * *not* -1.)
- */
- if (exp_b10 >= (-1) && exp_b10 <= 2)
- {
- /* The following only happens if we didn't output the
- * leading zeros above for negative exponent, so this
- * doesn't add to the digit requirement. Note that the
- * two zeros here can only be output if the two leading
- * zeros were *not* output, so this doesn't increase
- * the output count.
- */
- while (exp_b10-- > 0) *ascii++ = 48;
-
- *ascii = 0;
-
- /* Total buffer requirement (including the '\0') is
- * 5+precision - see check at the start.
- */
- return;
- }
-
- /* Here if an exponent is required, adjust size for
- * the digits we output but did not count. The total
- * digit output here so far is at most 1+precision - no
- * decimal point and no leading or trailing zeros have
- * been output.
- */
- size -= cdigits;
-
- *ascii++ = 69; --size; /* 'E': PLUS 1 TOTAL 2+precision */
-
- /* The following use of an unsigned temporary avoids ambiguities in
- * the signed arithmetic on exp_b10 and permits GCC at least to do
- * better optimization.
- */
- {
- unsigned int uexp_b10;
-
- if (exp_b10 < 0)
- {
- *ascii++ = 45; --size; /* '-': PLUS 1 TOTAL 3+precision */
- uexp_b10 = 0U-exp_b10;
- }
-
- else
- uexp_b10 = 0U+exp_b10;
-
- cdigits = 0;
-
- while (uexp_b10 > 0)
- {
- exponent[cdigits++] = (char)(48 + uexp_b10 % 10);
- uexp_b10 /= 10;
- }
- }
-
- /* Need another size check here for the exponent digits, so
- * this need not be considered above.
- */
- if (size > cdigits)
- {
- while (cdigits > 0) *ascii++ = exponent[--cdigits];
-
- *ascii = 0;
-
- return;
- }
- }
- }
- else if (!(fp >= DBL_MIN))
- {
- *ascii++ = 48; /* '0' */
- *ascii = 0;
- return;
- }
- else
- {
- *ascii++ = 105; /* 'i' */
- *ascii++ = 110; /* 'n' */
- *ascii++ = 102; /* 'f' */
- *ascii = 0;
- return;
- }
- }
-
- /* Here on buffer too small. */
- png_error(png_ptr, "ASCII conversion buffer too small");
-}
-# endif /* FLOATING_POINT */
-
-# ifdef PNG_FIXED_POINT_SUPPORTED
-/* Function to format a fixed point value in ASCII.
- */
-void /* PRIVATE */
-png_ascii_from_fixed(png_const_structrp png_ptr, png_charp ascii,
- size_t size, png_fixed_point fp)
-{
- /* Require space for 10 decimal digits, a decimal point, a minus sign and a
- * trailing \0, 13 characters:
- */
- if (size > 12)
- {
- png_uint_32 num;
-
- /* Avoid overflow here on the minimum integer. */
- if (fp < 0)
- {
- *ascii++ = 45; num = (png_uint_32)(-fp);
- }
- else
- num = (png_uint_32)fp;
-
- if (num <= 0x80000000) /* else overflowed */
- {
- unsigned int ndigits = 0, first = 16 /* flag value */;
- char digits[10] = {0};
-
- while (num)
- {
- /* Split the low digit off num: */
- unsigned int tmp = num/10;
- num -= tmp*10;
- digits[ndigits++] = (char)(48 + num);
- /* Record the first non-zero digit, note that this is a number
- * starting at 1, it's not actually the array index.
- */
- if (first == 16 && num > 0)
- first = ndigits;
- num = tmp;
- }
-
- if (ndigits > 0)
- {
- while (ndigits > 5) *ascii++ = digits[--ndigits];
- /* The remaining digits are fractional digits, ndigits is '5' or
- * smaller at this point. It is certainly not zero. Check for a
- * non-zero fractional digit:
- */
- if (first <= 5)
- {
- unsigned int i;
- *ascii++ = 46; /* decimal point */
- /* ndigits may be <5 for small numbers, output leading zeros
- * then ndigits digits to first:
- */
- i = 5;
- while (ndigits < i)
- {
- *ascii++ = 48; --i;
- }
- while (ndigits >= first) *ascii++ = digits[--ndigits];
- /* Don't output the trailing zeros! */
- }
- }
- else
- *ascii++ = 48;
-
- /* And null terminate the string: */
- *ascii = 0;
- return;
- }
- }
-
- /* Here on buffer too small. */
- png_error(png_ptr, "ASCII conversion buffer too small");
-}
-# endif /* FIXED_POINT */
-#endif /* SCAL */
-
-#if defined(PNG_FLOATING_POINT_SUPPORTED) && \
- !defined(PNG_FIXED_POINT_MACRO_SUPPORTED) && \
- (defined(PNG_gAMA_SUPPORTED) || defined(PNG_cHRM_SUPPORTED) || \
- defined(PNG_sCAL_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) || \
- defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)) || \
- (defined(PNG_sCAL_SUPPORTED) && \
- defined(PNG_FLOATING_ARITHMETIC_SUPPORTED))
-png_fixed_point
-png_fixed(png_const_structrp png_ptr, double fp, png_const_charp text)
-{
- double r = floor(100000 * fp + .5);
-
- if (r > 2147483647. || r < -2147483648.)
- png_fixed_error(png_ptr, text);
-
-# ifndef PNG_ERROR_TEXT_SUPPORTED
- PNG_UNUSED(text)
-# endif
-
- return (png_fixed_point)r;
-}
-#endif
-
-#if defined(PNG_FLOATING_POINT_SUPPORTED) && \
- !defined(PNG_FIXED_POINT_MACRO_SUPPORTED) && \
- (defined(PNG_cLLI_SUPPORTED) || defined(PNG_mDCV_SUPPORTED))
-png_uint_32
-png_fixed_ITU(png_const_structrp png_ptr, double fp, png_const_charp text)
-{
- double r = floor(10000 * fp + .5);
-
- if (r > 2147483647. || r < 0)
- png_fixed_error(png_ptr, text);
-
-# ifndef PNG_ERROR_TEXT_SUPPORTED
- PNG_UNUSED(text)
-# endif
-
- return (png_uint_32)r;
-}
-#endif
-
-
-#if defined(PNG_GAMMA_SUPPORTED) || defined(PNG_COLORSPACE_SUPPORTED) ||\
- defined(PNG_INCH_CONVERSIONS_SUPPORTED) || defined(PNG_READ_pHYs_SUPPORTED)
-/* muldiv functions */
-/* This API takes signed arguments and rounds the result to the nearest
- * integer (or, for a fixed point number - the standard argument - to
- * the nearest .00001). Overflow and divide by zero are signalled in
- * the result, a boolean - true on success, false on overflow.
- */
-int
-png_muldiv(png_fixed_point_p res, png_fixed_point a, png_int_32 times,
- png_int_32 divisor)
-{
- /* Return a * times / divisor, rounded. */
- if (divisor != 0)
- {
- if (a == 0 || times == 0)
- {
- *res = 0;
- return 1;
- }
- else
- {
-#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
- double r = a;
- r *= times;
- r /= divisor;
- r = floor(r+.5);
-
- /* A png_fixed_point is a 32-bit integer. */
- if (r <= 2147483647. && r >= -2147483648.)
- {
- *res = (png_fixed_point)r;
- return 1;
- }
-#else
- int negative = 0;
- png_uint_32 A, T, D;
- png_uint_32 s16, s32, s00;
-
- if (a < 0)
- negative = 1, A = -a;
- else
- A = a;
-
- if (times < 0)
- negative = !negative, T = -times;
- else
- T = times;
-
- if (divisor < 0)
- negative = !negative, D = -divisor;
- else
- D = divisor;
-
- /* Following can't overflow because the arguments only
- * have 31 bits each, however the result may be 32 bits.
- */
- s16 = (A >> 16) * (T & 0xffff) +
- (A & 0xffff) * (T >> 16);
- /* Can't overflow because the a*times bit is only 30
- * bits at most.
- */
- s32 = (A >> 16) * (T >> 16) + (s16 >> 16);
- s00 = (A & 0xffff) * (T & 0xffff);
-
- s16 = (s16 & 0xffff) << 16;
- s00 += s16;
-
- if (s00 < s16)
- ++s32; /* carry */
-
- if (s32 < D) /* else overflow */
- {
- /* s32.s00 is now the 64-bit product, do a standard
- * division, we know that s32 < D, so the maximum
- * required shift is 31.
- */
- int bitshift = 32;
- png_fixed_point result = 0; /* NOTE: signed */
-
- while (--bitshift >= 0)
- {
- png_uint_32 d32, d00;
-
- if (bitshift > 0)
- d32 = D >> (32-bitshift), d00 = D << bitshift;
-
- else
- d32 = 0, d00 = D;
-
- if (s32 > d32)
- {
- if (s00 < d00) --s32; /* carry */
- s32 -= d32, s00 -= d00, result += 1<<bitshift;
- }
-
- else
- if (s32 == d32 && s00 >= d00)
- s32 = 0, s00 -= d00, result += 1<<bitshift;
- }
-
- /* Handle the rounding. */
- if (s00 >= (D >> 1))
- ++result;
-
- if (negative != 0)
- result = -result;
-
- /* Check for overflow. */
- if ((negative != 0 && result <= 0) ||
- (negative == 0 && result >= 0))
- {
- *res = result;
- return 1;
- }
- }
-#endif
- }
- }
-
- return 0;
-}
-#endif /* READ_GAMMA || INCH_CONVERSIONS */
-
-#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_INCH_CONVERSIONS_SUPPORTED)
-/* The following is for when the caller doesn't much care about the
- * result.
- */
-png_fixed_point
-png_muldiv_warn(png_const_structrp png_ptr, png_fixed_point a, png_int_32 times,
- png_int_32 divisor)
-{
- png_fixed_point result;
-
- if (png_muldiv(&result, a, times, divisor) != 0)
- return result;
-
- png_warning(png_ptr, "fixed point overflow ignored");
- return 0;
-}
-#endif
-
-#ifdef PNG_GAMMA_SUPPORTED /* more fixed point functions for gamma */
-/* Calculate a reciprocal, return 0 on div-by-zero or overflow. */
-png_fixed_point
-png_reciprocal(png_fixed_point a)
-{
-#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
- double r = floor(1E10/a+.5);
-
- if (r <= 2147483647. && r >= -2147483648.)
- return (png_fixed_point)r;
-#else
- png_fixed_point res;
-
- if (png_muldiv(&res, 100000, 100000, a) != 0)
- return res;
-#endif
-
- return 0; /* error/overflow */
-}
-
-/* This is the shared test on whether a gamma value is 'significant' - whether
- * it is worth doing gamma correction.
- */
-int /* PRIVATE */
-png_gamma_significant(png_fixed_point gamma_val)
-{
- return gamma_val < PNG_FP_1 - PNG_GAMMA_THRESHOLD_FIXED ||
- gamma_val > PNG_FP_1 + PNG_GAMMA_THRESHOLD_FIXED;
-}
-#endif
-
-#ifdef PNG_READ_GAMMA_SUPPORTED
-#ifdef PNG_16BIT_SUPPORTED
-/* A local convenience routine. */
-static png_fixed_point
-png_product2(png_fixed_point a, png_fixed_point b)
-{
- /* The required result is 1/a * 1/b; the following preserves accuracy. */
-#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
- double r = a * 1E-5;
- r *= b;
- r = floor(r+.5);
-
- if (r <= 2147483647. && r >= -2147483648.)
- return (png_fixed_point)r;
-#else
- png_fixed_point res;
-
- if (png_muldiv(&res, a, b, 100000) != 0)
- return res;
-#endif
-
- return 0; /* overflow */
-}
-#endif /* 16BIT */
-
-/* The inverse of the above. */
-png_fixed_point
-png_reciprocal2(png_fixed_point a, png_fixed_point b)
-{
- /* The required result is 1/a * 1/b; the following preserves accuracy. */
-#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
- if (a != 0 && b != 0)
- {
- double r = 1E15/a;
- r /= b;
- r = floor(r+.5);
-
- if (r <= 2147483647. && r >= -2147483648.)
- return (png_fixed_point)r;
- }
-#else
- /* This may overflow because the range of png_fixed_point isn't symmetric,
- * but this API is only used for the product of file and screen gamma so it
- * doesn't matter that the smallest number it can produce is 1/21474, not
- * 1/100000
- */
- png_fixed_point res = png_product2(a, b);
-
- if (res != 0)
- return png_reciprocal(res);
-#endif
-
- return 0; /* overflow */
-}
-#endif /* READ_GAMMA */
-
-#ifdef PNG_READ_GAMMA_SUPPORTED /* gamma table code */
-#ifndef PNG_FLOATING_ARITHMETIC_SUPPORTED
-/* Fixed point gamma.
- *
- * The code to calculate the tables used below can be found in the shell script
- * contrib/tools/intgamma.sh
- *
- * To calculate gamma this code implements fast log() and exp() calls using only
- * fixed point arithmetic. This code has sufficient precision for either 8-bit
- * or 16-bit sample values.
- *
- * The tables used here were calculated using simple 'bc' programs, but C double
- * precision floating point arithmetic would work fine.
- *
- * 8-bit log table
- * This is a table of -log(value/255)/log(2) for 'value' in the range 128 to
- * 255, so it's the base 2 logarithm of a normalized 8-bit floating point
- * mantissa. The numbers are 32-bit fractions.
- */
-static const png_uint_32
-png_8bit_l2[128] =
-{
- 4270715492U, 4222494797U, 4174646467U, 4127164793U, 4080044201U, 4033279239U,
- 3986864580U, 3940795015U, 3895065449U, 3849670902U, 3804606499U, 3759867474U,
- 3715449162U, 3671346997U, 3627556511U, 3584073329U, 3540893168U, 3498011834U,
- 3455425220U, 3413129301U, 3371120137U, 3329393864U, 3287946700U, 3246774933U,
- 3205874930U, 3165243125U, 3124876025U, 3084770202U, 3044922296U, 3005329011U,
- 2965987113U, 2926893432U, 2888044853U, 2849438323U, 2811070844U, 2772939474U,
- 2735041326U, 2697373562U, 2659933400U, 2622718104U, 2585724991U, 2548951424U,
- 2512394810U, 2476052606U, 2439922311U, 2404001468U, 2368287663U, 2332778523U,
- 2297471715U, 2262364947U, 2227455964U, 2192742551U, 2158222529U, 2123893754U,
- 2089754119U, 2055801552U, 2022034013U, 1988449497U, 1955046031U, 1921821672U,
- 1888774511U, 1855902668U, 1823204291U, 1790677560U, 1758320682U, 1726131893U,
- 1694109454U, 1662251657U, 1630556815U, 1599023271U, 1567649391U, 1536433567U,
- 1505374214U, 1474469770U, 1443718700U, 1413119487U, 1382670639U, 1352370686U,
- 1322218179U, 1292211689U, 1262349810U, 1232631153U, 1203054352U, 1173618059U,
- 1144320946U, 1115161701U, 1086139034U, 1057251672U, 1028498358U, 999877854U,
- 971388940U, 943030410U, 914801076U, 886699767U, 858725327U, 830876614U,
- 803152505U, 775551890U, 748073672U, 720716771U, 693480120U, 666362667U,
- 639363374U, 612481215U, 585715177U, 559064263U, 532527486U, 506103872U,
- 479792461U, 453592303U, 427502463U, 401522014U, 375650043U, 349885648U,
- 324227938U, 298676034U, 273229066U, 247886176U, 222646516U, 197509248U,
- 172473545U, 147538590U, 122703574U, 97967701U, 73330182U, 48790236U,
- 24347096U, 0U
-
-#if 0
- /* The following are the values for 16-bit tables - these work fine for the
- * 8-bit conversions but produce very slightly larger errors in the 16-bit
- * log (about 1.2 as opposed to 0.7 absolute error in the final value). To
- * use these all the shifts below must be adjusted appropriately.
- */
- 65166, 64430, 63700, 62976, 62257, 61543, 60835, 60132, 59434, 58741, 58054,
- 57371, 56693, 56020, 55352, 54689, 54030, 53375, 52726, 52080, 51439, 50803,
- 50170, 49542, 48918, 48298, 47682, 47070, 46462, 45858, 45257, 44661, 44068,
- 43479, 42894, 42312, 41733, 41159, 40587, 40020, 39455, 38894, 38336, 37782,
- 37230, 36682, 36137, 35595, 35057, 34521, 33988, 33459, 32932, 32408, 31887,
- 31369, 30854, 30341, 29832, 29325, 28820, 28319, 27820, 27324, 26830, 26339,
- 25850, 25364, 24880, 24399, 23920, 23444, 22970, 22499, 22029, 21562, 21098,
- 20636, 20175, 19718, 19262, 18808, 18357, 17908, 17461, 17016, 16573, 16132,
- 15694, 15257, 14822, 14390, 13959, 13530, 13103, 12678, 12255, 11834, 11415,
- 10997, 10582, 10168, 9756, 9346, 8937, 8531, 8126, 7723, 7321, 6921, 6523,
- 6127, 5732, 5339, 4947, 4557, 4169, 3782, 3397, 3014, 2632, 2251, 1872, 1495,
- 1119, 744, 372
-#endif
-};
-
-static png_int_32
-png_log8bit(unsigned int x)
-{
- unsigned int lg2 = 0;
- /* Each time 'x' is multiplied by 2, 1 must be subtracted off the final log,
- * because the log is actually negate that means adding 1. The final
- * returned value thus has the range 0 (for 255 input) to 7.994 (for 1
- * input), return -1 for the overflow (log 0) case, - so the result is
- * always at most 19 bits.
- */
- if ((x &= 0xff) == 0)
- return -1;
-
- if ((x & 0xf0) == 0)
- lg2 = 4, x <<= 4;
-
- if ((x & 0xc0) == 0)
- lg2 += 2, x <<= 2;
-
- if ((x & 0x80) == 0)
- lg2 += 1, x <<= 1;
-
- /* result is at most 19 bits, so this cast is safe: */
- return (png_int_32)((lg2 << 16) + ((png_8bit_l2[x-128]+32768)>>16));
-}
-
-/* The above gives exact (to 16 binary places) log2 values for 8-bit images,
- * for 16-bit images we use the most significant 8 bits of the 16-bit value to
- * get an approximation then multiply the approximation by a correction factor
- * determined by the remaining up to 8 bits. This requires an additional step
- * in the 16-bit case.
- *
- * We want log2(value/65535), we have log2(v'/255), where:
- *
- * value = v' * 256 + v''
- * = v' * f
- *
- * So f is value/v', which is equal to (256+v''/v') since v' is in the range 128
- * to 255 and v'' is in the range 0 to 255 f will be in the range 256 to less
- * than 258. The final factor also needs to correct for the fact that our 8-bit
- * value is scaled by 255, whereas the 16-bit values must be scaled by 65535.
- *
- * This gives a final formula using a calculated value 'x' which is value/v' and
- * scaling by 65536 to match the above table:
- *
- * log2(x/257) * 65536
- *
- * Since these numbers are so close to '1' we can use simple linear
- * interpolation between the two end values 256/257 (result -368.61) and 258/257
- * (result 367.179). The values used below are scaled by a further 64 to give
- * 16-bit precision in the interpolation:
- *
- * Start (256): -23591
- * Zero (257): 0
- * End (258): 23499
- */
-#ifdef PNG_16BIT_SUPPORTED
-static png_int_32
-png_log16bit(png_uint_32 x)
-{
- unsigned int lg2 = 0;
-
- /* As above, but now the input has 16 bits. */
- if ((x &= 0xffff) == 0)
- return -1;
-
- if ((x & 0xff00) == 0)
- lg2 = 8, x <<= 8;
-
- if ((x & 0xf000) == 0)
- lg2 += 4, x <<= 4;
-
- if ((x & 0xc000) == 0)
- lg2 += 2, x <<= 2;
-
- if ((x & 0x8000) == 0)
- lg2 += 1, x <<= 1;
-
- /* Calculate the base logarithm from the top 8 bits as a 28-bit fractional
- * value.
- */
- lg2 <<= 28;
- lg2 += (png_8bit_l2[(x>>8)-128]+8) >> 4;
-
- /* Now we need to interpolate the factor, this requires a division by the top
- * 8 bits. Do this with maximum precision.
- */
- x = ((x << 16) + (x >> 9)) / (x >> 8);
-
- /* Since we divided by the top 8 bits of 'x' there will be a '1' at 1<<24,
- * the value at 1<<16 (ignoring this) will be 0 or 1; this gives us exactly
- * 16 bits to interpolate to get the low bits of the result. Round the
- * answer. Note that the end point values are scaled by 64 to retain overall
- * precision and that 'lg2' is current scaled by an extra 12 bits, so adjust
- * the overall scaling by 6-12. Round at every step.
- */
- x -= 1U << 24;
-
- if (x <= 65536U) /* <= '257' */
- lg2 += ((23591U * (65536U-x)) + (1U << (16+6-12-1))) >> (16+6-12);
-
- else
- lg2 -= ((23499U * (x-65536U)) + (1U << (16+6-12-1))) >> (16+6-12);
-
- /* Safe, because the result can't have more than 20 bits: */
- return (png_int_32)((lg2 + 2048) >> 12);
-}
-#endif /* 16BIT */
-
-/* The 'exp()' case must invert the above, taking a 20-bit fixed point
- * logarithmic value and returning a 16 or 8-bit number as appropriate. In
- * each case only the low 16 bits are relevant - the fraction - since the
- * integer bits (the top 4) simply determine a shift.
- *
- * The worst case is the 16-bit distinction between 65535 and 65534. This
- * requires perhaps spurious accuracy in the decoding of the logarithm to
- * distinguish log2(65535/65534.5) - 10^-5 or 17 bits. There is little chance
- * of getting this accuracy in practice.
- *
- * To deal with this the following exp() function works out the exponent of the
- * fractional part of the logarithm by using an accurate 32-bit value from the
- * top four fractional bits then multiplying in the remaining bits.
- */
-static const png_uint_32
-png_32bit_exp[16] =
-{
- /* NOTE: the first entry is deliberately set to the maximum 32-bit value. */
- 4294967295U, 4112874773U, 3938502376U, 3771522796U, 3611622603U, 3458501653U,
- 3311872529U, 3171459999U, 3037000500U, 2908241642U, 2784941738U, 2666869345U,
- 2553802834U, 2445529972U, 2341847524U, 2242560872U
-};
-
-/* Adjustment table; provided to explain the numbers in the code below. */
-#if 0
-for (i=11;i>=0;--i){ print i, " ", (1 - e(-(2^i)/65536*l(2))) * 2^(32-i), "\n"}
- 11 44937.64284865548751208448
- 10 45180.98734845585101160448
- 9 45303.31936980687359311872
- 8 45364.65110595323018870784
- 7 45395.35850361789624614912
- 6 45410.72259715102037508096
- 5 45418.40724413220722311168
- 4 45422.25021786898173001728
- 3 45424.17186732298419044352
- 2 45425.13273269940811464704
- 1 45425.61317555035558641664
- 0 45425.85339951654943850496
-#endif
-
-static png_uint_32
-png_exp(png_fixed_point x)
-{
- if (x > 0 && x <= 0xfffff) /* Else overflow or zero (underflow) */
- {
- /* Obtain a 4-bit approximation */
- png_uint_32 e = png_32bit_exp[(x >> 12) & 0x0f];
-
- /* Incorporate the low 12 bits - these decrease the returned value by
- * multiplying by a number less than 1 if the bit is set. The multiplier
- * is determined by the above table and the shift. Notice that the values
- * converge on 45426 and this is used to allow linear interpolation of the
- * low bits.
- */
- if (x & 0x800)
- e -= (((e >> 16) * 44938U) + 16U) >> 5;
-
- if (x & 0x400)
- e -= (((e >> 16) * 45181U) + 32U) >> 6;
-
- if (x & 0x200)
- e -= (((e >> 16) * 45303U) + 64U) >> 7;
-
- if (x & 0x100)
- e -= (((e >> 16) * 45365U) + 128U) >> 8;
-
- if (x & 0x080)
- e -= (((e >> 16) * 45395U) + 256U) >> 9;
-
- if (x & 0x040)
- e -= (((e >> 16) * 45410U) + 512U) >> 10;
-
- /* And handle the low 6 bits in a single block. */
- e -= (((e >> 16) * 355U * (x & 0x3fU)) + 256U) >> 9;
-
- /* Handle the upper bits of x. */
- e >>= x >> 16;
- return e;
- }
-
- /* Check for overflow */
- if (x <= 0)
- return png_32bit_exp[0];
-
- /* Else underflow */
- return 0;
-}
-
-static png_byte
-png_exp8bit(png_fixed_point lg2)
-{
- /* Get a 32-bit value: */
- png_uint_32 x = png_exp(lg2);
-
- /* Convert the 32-bit value to 0..255 by multiplying by 256-1. Note that the
- * second, rounding, step can't overflow because of the first, subtraction,
- * step.
- */
- x -= x >> 8;
- return (png_byte)(((x + 0x7fffffU) >> 24) & 0xff);
-}
-
-#ifdef PNG_16BIT_SUPPORTED
-static png_uint_16
-png_exp16bit(png_fixed_point lg2)
-{
- /* Get a 32-bit value: */
- png_uint_32 x = png_exp(lg2);
-
- /* Convert the 32-bit value to 0..65535 by multiplying by 65536-1: */
- x -= x >> 16;
- return (png_uint_16)((x + 32767U) >> 16);
-}
-#endif /* 16BIT */
-#endif /* FLOATING_ARITHMETIC */
-
-png_byte
-png_gamma_8bit_correct(unsigned int value, png_fixed_point gamma_val)
-{
- if (value > 0 && value < 255)
- {
-# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
- /* 'value' is unsigned, ANSI-C90 requires the compiler to correctly
- * convert this to a floating point value. This includes values that
- * would overflow if 'value' were to be converted to 'int'.
- *
- * Apparently GCC, however, does an intermediate conversion to (int)
- * on some (ARM) but not all (x86) platforms, possibly because of
- * hardware FP limitations. (E.g. if the hardware conversion always
- * assumes the integer register contains a signed value.) This results
- * in ANSI-C undefined behavior for large values.
- *
- * Other implementations on the same machine might actually be ANSI-C90
- * conformant and therefore compile spurious extra code for the large
- * values.
- *
- * We can be reasonably sure that an unsigned to float conversion
- * won't be faster than an int to float one. Therefore this code
- * assumes responsibility for the undefined behavior, which it knows
- * can't happen because of the check above.
- *
- * Note the argument to this routine is an (unsigned int) because, on
- * 16-bit platforms, it is assigned a value which might be out of
- * range for an (int); that would result in undefined behavior in the
- * caller if the *argument* ('value') were to be declared (int).
- */
- double r = floor(255*pow((int)/*SAFE*/value/255.,gamma_val*.00001)+.5);
- return (png_byte)r;
-# else
- png_int_32 lg2 = png_log8bit(value);
- png_fixed_point res;
-
- if (png_muldiv(&res, gamma_val, lg2, PNG_FP_1) != 0)
- return png_exp8bit(res);
-
- /* Overflow. */
- value = 0;
-# endif
- }
-
- return (png_byte)(value & 0xff);
-}
-
-#ifdef PNG_16BIT_SUPPORTED
-png_uint_16
-png_gamma_16bit_correct(unsigned int value, png_fixed_point gamma_val)
-{
- if (value > 0 && value < 65535)
- {
-# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
- /* The same (unsigned int)->(double) constraints apply here as above,
- * however in this case the (unsigned int) to (int) conversion can
- * overflow on an ANSI-C90 compliant system so the cast needs to ensure
- * that this is not possible.
- */
- double r = floor(65535*pow((png_int_32)value/65535.,
- gamma_val*.00001)+.5);
- return (png_uint_16)r;
-# else
- png_int_32 lg2 = png_log16bit(value);
- png_fixed_point res;
-
- if (png_muldiv(&res, gamma_val, lg2, PNG_FP_1) != 0)
- return png_exp16bit(res);
-
- /* Overflow. */
- value = 0;
-# endif
- }
-
- return (png_uint_16)value;
-}
-#endif /* 16BIT */
-
-/* This does the right thing based on the bit_depth field of the
- * png_struct, interpreting values as 8-bit or 16-bit. While the result
- * is nominally a 16-bit value if bit depth is 8 then the result is
- * 8-bit (as are the arguments.)
- */
-png_uint_16 /* PRIVATE */
-png_gamma_correct(png_structrp png_ptr, unsigned int value,
- png_fixed_point gamma_val)
-{
- if (png_ptr->bit_depth == 8)
- return png_gamma_8bit_correct(value, gamma_val);
-
-#ifdef PNG_16BIT_SUPPORTED
- else
- return png_gamma_16bit_correct(value, gamma_val);
-#else
- /* should not reach this */
- return 0;
-#endif /* 16BIT */
-}
-
-#ifdef PNG_16BIT_SUPPORTED
-/* Internal function to build a single 16-bit table - the table consists of
- * 'num' 256 entry subtables, where 'num' is determined by 'shift' - the amount
- * to shift the input values right (or 16-number_of_signifiant_bits).
- *
- * The caller is responsible for ensuring that the table gets cleaned up on
- * png_error (i.e. if one of the mallocs below fails) - i.e. the *table argument
- * should be somewhere that will be cleaned.
- */
-static void
-png_build_16bit_table(png_structrp png_ptr, png_uint_16pp *ptable,
- unsigned int shift, png_fixed_point gamma_val)
-{
- /* Various values derived from 'shift': */
- unsigned int num = 1U << (8U - shift);
-#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
- /* CSE the division and work round wacky GCC warnings (see the comments
- * in png_gamma_8bit_correct for where these come from.)
- */
- double fmax = 1.0 / (((png_int_32)1 << (16U - shift)) - 1);
-#endif
- unsigned int max = (1U << (16U - shift)) - 1U;
- unsigned int max_by_2 = 1U << (15U - shift);
- unsigned int i;
-
- png_uint_16pp table = *ptable =
- (png_uint_16pp)png_calloc(png_ptr, num * (sizeof (png_uint_16p)));
-
- for (i = 0; i < num; i++)
- {
- png_uint_16p sub_table = table[i] =
- (png_uint_16p)png_malloc(png_ptr, 256 * (sizeof (png_uint_16)));
-
- /* The 'threshold' test is repeated here because it can arise for one of
- * the 16-bit tables even if the others don't hit it.
- */
- if (png_gamma_significant(gamma_val) != 0)
- {
- /* The old code would overflow at the end and this would cause the
- * 'pow' function to return a result >1, resulting in an
- * arithmetic error. This code follows the spec exactly; ig is
- * the recovered input sample, it always has 8-16 bits.
- *
- * We want input * 65535/max, rounded, the arithmetic fits in 32
- * bits (unsigned) so long as max <= 32767.
- */
- unsigned int j;
- for (j = 0; j < 256; j++)
- {
- png_uint_32 ig = (j << (8-shift)) + i;
-# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
- /* Inline the 'max' scaling operation: */
- /* See png_gamma_8bit_correct for why the cast to (int) is
- * required here.
- */
- double d = floor(65535.*pow(ig*fmax, gamma_val*.00001)+.5);
- sub_table[j] = (png_uint_16)d;
-# else
- if (shift != 0)
- ig = (ig * 65535U + max_by_2)/max;
-
- sub_table[j] = png_gamma_16bit_correct(ig, gamma_val);
-# endif
- }
- }
- else
- {
- /* We must still build a table, but do it the fast way. */
- unsigned int j;
-
- for (j = 0; j < 256; j++)
- {
- png_uint_32 ig = (j << (8-shift)) + i;
-
- if (shift != 0)
- ig = (ig * 65535U + max_by_2)/max;
-
- sub_table[j] = (png_uint_16)ig;
- }
- }
- }
-}
-
-/* NOTE: this function expects the *inverse* of the overall gamma transformation
- * required.
- */
-static void
-png_build_16to8_table(png_structrp png_ptr, png_uint_16pp *ptable,
- unsigned int shift, png_fixed_point gamma_val)
-{
- unsigned int num = 1U << (8U - shift);
- unsigned int max = (1U << (16U - shift))-1U;
- unsigned int i;
- png_uint_32 last;
-
- png_uint_16pp table = *ptable =
- (png_uint_16pp)png_calloc(png_ptr, num * (sizeof (png_uint_16p)));
-
- /* 'num' is the number of tables and also the number of low bits of low
- * bits of the input 16-bit value used to select a table. Each table is
- * itself indexed by the high 8 bits of the value.
- */
- for (i = 0; i < num; i++)
- table[i] = (png_uint_16p)png_malloc(png_ptr,
- 256 * (sizeof (png_uint_16)));
-
- /* 'gamma_val' is set to the reciprocal of the value calculated above, so
- * pow(out,g) is an *input* value. 'last' is the last input value set.
- *
- * In the loop 'i' is used to find output values. Since the output is
- * 8-bit there are only 256 possible values. The tables are set up to
- * select the closest possible output value for each input by finding
- * the input value at the boundary between each pair of output values
- * and filling the table up to that boundary with the lower output
- * value.
- *
- * The boundary values are 0.5,1.5..253.5,254.5. Since these are 9-bit
- * values the code below uses a 16-bit value in i; the values start at
- * 128.5 (for 0.5) and step by 257, for a total of 254 values (the last
- * entries are filled with 255). Start i at 128 and fill all 'last'
- * table entries <= 'max'
- */
- last = 0;
- for (i = 0; i < 255; ++i) /* 8-bit output value */
- {
- /* Find the corresponding maximum input value */
- png_uint_16 out = (png_uint_16)(i * 257U); /* 16-bit output value */
-
- /* Find the boundary value in 16 bits: */
- png_uint_32 bound = png_gamma_16bit_correct(out+128U, gamma_val);
-
- /* Adjust (round) to (16-shift) bits: */
- bound = (bound * max + 32768U)/65535U + 1U;
-
- while (last < bound)
- {
- table[last & (0xffU >> shift)][last >> (8U - shift)] = out;
- last++;
- }
- }
-
- /* And fill in the final entries. */
- while (last < (num << 8))
- {
- table[last & (0xff >> shift)][last >> (8U - shift)] = 65535U;
- last++;
- }
-}
-#endif /* 16BIT */
-
-/* Build a single 8-bit table: same as the 16-bit case but much simpler (and
- * typically much faster). Note that libpng currently does no sBIT processing
- * (apparently contrary to the spec) so a 256-entry table is always generated.
- */
-static void
-png_build_8bit_table(png_structrp png_ptr, png_bytepp ptable,
- png_fixed_point gamma_val)
-{
- unsigned int i;
- png_bytep table = *ptable = (png_bytep)png_malloc(png_ptr, 256);
-
- if (png_gamma_significant(gamma_val) != 0)
- for (i=0; i<256; i++)
- table[i] = png_gamma_8bit_correct(i, gamma_val);
-
- else
- for (i=0; i<256; ++i)
- table[i] = (png_byte)(i & 0xff);
-}
-
-/* Used from png_read_destroy and below to release the memory used by the gamma
- * tables.
- */
-void /* PRIVATE */
-png_destroy_gamma_table(png_structrp png_ptr)
-{
- png_free(png_ptr, png_ptr->gamma_table);
- png_ptr->gamma_table = NULL;
-
-#ifdef PNG_16BIT_SUPPORTED
- if (png_ptr->gamma_16_table != NULL)
- {
- int i;
- int istop = (1 << (8 - png_ptr->gamma_shift));
- for (i = 0; i < istop; i++)
- {
- png_free(png_ptr, png_ptr->gamma_16_table[i]);
- }
- png_free(png_ptr, png_ptr->gamma_16_table);
- png_ptr->gamma_16_table = NULL;
- }
-#endif /* 16BIT */
-
-#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
- defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \
- defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
- png_free(png_ptr, png_ptr->gamma_from_1);
- png_ptr->gamma_from_1 = NULL;
- png_free(png_ptr, png_ptr->gamma_to_1);
- png_ptr->gamma_to_1 = NULL;
-
-#ifdef PNG_16BIT_SUPPORTED
- if (png_ptr->gamma_16_from_1 != NULL)
- {
- int i;
- int istop = (1 << (8 - png_ptr->gamma_shift));
- for (i = 0; i < istop; i++)
- {
- png_free(png_ptr, png_ptr->gamma_16_from_1[i]);
- }
- png_free(png_ptr, png_ptr->gamma_16_from_1);
- png_ptr->gamma_16_from_1 = NULL;
- }
- if (png_ptr->gamma_16_to_1 != NULL)
- {
- int i;
- int istop = (1 << (8 - png_ptr->gamma_shift));
- for (i = 0; i < istop; i++)
- {
- png_free(png_ptr, png_ptr->gamma_16_to_1[i]);
- }
- png_free(png_ptr, png_ptr->gamma_16_to_1);
- png_ptr->gamma_16_to_1 = NULL;
- }
-#endif /* 16BIT */
-#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */
-}
-
-/* We build the 8- or 16-bit gamma tables here. Note that for 16-bit
- * tables, we don't make a full table if we are reducing to 8-bit in
- * the future. Note also how the gamma_16 tables are segmented so that
- * we don't need to allocate > 64K chunks for a full 16-bit table.
- */
-void /* PRIVATE */
-png_build_gamma_table(png_structrp png_ptr, int bit_depth)
-{
- png_debug(1, "in png_build_gamma_table");
-
- /* Remove any existing table; this copes with multiple calls to
- * png_read_update_info. The warning is because building the gamma tables
- * multiple times is a performance hit - it's harmless but the ability to
- * call png_read_update_info() multiple times is new in 1.5.6 so it seems
- * sensible to warn if the app introduces such a hit.
- */
- if (png_ptr->gamma_table != NULL || png_ptr->gamma_16_table != NULL)
- {
- png_warning(png_ptr, "gamma table being rebuilt");
- png_destroy_gamma_table(png_ptr);
- }
-
- if (bit_depth <= 8)
- {
- png_build_8bit_table(png_ptr, &png_ptr->gamma_table,
- png_ptr->screen_gamma > 0 ?
- png_reciprocal2(png_ptr->colorspace.gamma,
- png_ptr->screen_gamma) : PNG_FP_1);
-
-#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
- defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \
- defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
- if ((png_ptr->transformations & (PNG_COMPOSE | PNG_RGB_TO_GRAY)) != 0)
- {
- png_build_8bit_table(png_ptr, &png_ptr->gamma_to_1,
- png_reciprocal(png_ptr->colorspace.gamma));
-
- png_build_8bit_table(png_ptr, &png_ptr->gamma_from_1,
- png_ptr->screen_gamma > 0 ?
- png_reciprocal(png_ptr->screen_gamma) :
- png_ptr->colorspace.gamma/* Probably doing rgb_to_gray */);
- }
-#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */
- }
-#ifdef PNG_16BIT_SUPPORTED
- else
- {
- png_byte shift, sig_bit;
-
- if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0)
- {
- sig_bit = png_ptr->sig_bit.red;
-
- if (png_ptr->sig_bit.green > sig_bit)
- sig_bit = png_ptr->sig_bit.green;
-
- if (png_ptr->sig_bit.blue > sig_bit)
- sig_bit = png_ptr->sig_bit.blue;
- }
- else
- sig_bit = png_ptr->sig_bit.gray;
-
- /* 16-bit gamma code uses this equation:
- *
- * ov = table[(iv & 0xff) >> gamma_shift][iv >> 8]
- *
- * Where 'iv' is the input color value and 'ov' is the output value -
- * pow(iv, gamma).
- *
- * Thus the gamma table consists of up to 256 256-entry tables. The table
- * is selected by the (8-gamma_shift) most significant of the low 8 bits
- * of the color value then indexed by the upper 8 bits:
- *
- * table[low bits][high 8 bits]
- *
- * So the table 'n' corresponds to all those 'iv' of:
- *
- * <all high 8-bit values><n << gamma_shift>..<(n+1 << gamma_shift)-1>
- *
- */
- if (sig_bit > 0 && sig_bit < 16U)
- /* shift == insignificant bits */
- shift = (png_byte)((16U - sig_bit) & 0xff);
-
- else
- shift = 0; /* keep all 16 bits */
-
- if ((png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8)) != 0)
- {
- /* PNG_MAX_GAMMA_8 is the number of bits to keep - effectively
- * the significant bits in the *input* when the output will
- * eventually be 8 bits. By default it is 11.
- */
- if (shift < (16U - PNG_MAX_GAMMA_8))
- shift = (16U - PNG_MAX_GAMMA_8);
- }
-
- if (shift > 8U)
- shift = 8U; /* Guarantees at least one table! */
-
- png_ptr->gamma_shift = shift;
-
- /* NOTE: prior to 1.5.4 this test used to include PNG_BACKGROUND (now
- * PNG_COMPOSE). This effectively smashed the background calculation for
- * 16-bit output because the 8-bit table assumes the result will be
- * reduced to 8 bits.
- */
- if ((png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8)) != 0)
- png_build_16to8_table(png_ptr, &png_ptr->gamma_16_table, shift,
- png_ptr->screen_gamma > 0 ? png_product2(png_ptr->colorspace.gamma,
- png_ptr->screen_gamma) : PNG_FP_1);
-
- else
- png_build_16bit_table(png_ptr, &png_ptr->gamma_16_table, shift,
- png_ptr->screen_gamma > 0 ? png_reciprocal2(png_ptr->colorspace.gamma,
- png_ptr->screen_gamma) : PNG_FP_1);
-
-#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
- defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \
- defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
- if ((png_ptr->transformations & (PNG_COMPOSE | PNG_RGB_TO_GRAY)) != 0)
- {
- png_build_16bit_table(png_ptr, &png_ptr->gamma_16_to_1, shift,
- png_reciprocal(png_ptr->colorspace.gamma));
-
- /* Notice that the '16 from 1' table should be full precision, however
- * the lookup on this table still uses gamma_shift, so it can't be.
- * TODO: fix this.
- */
- png_build_16bit_table(png_ptr, &png_ptr->gamma_16_from_1, shift,
- png_ptr->screen_gamma > 0 ? png_reciprocal(png_ptr->screen_gamma) :
- png_ptr->colorspace.gamma/* Probably doing rgb_to_gray */);
- }
-#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */
- }
-#endif /* 16BIT */
-}
-#endif /* READ_GAMMA */
-
-/* HARDWARE OR SOFTWARE OPTION SUPPORT */
-#ifdef PNG_SET_OPTION_SUPPORTED
-int PNGAPI
-png_set_option(png_structrp png_ptr, int option, int onoff)
-{
- if (png_ptr != NULL && option >= 0 && option < PNG_OPTION_NEXT &&
- (option & 1) == 0)
- {
- png_uint_32 mask = 3U << option;
- png_uint_32 setting = (2U + (onoff != 0)) << option;
- png_uint_32 current = png_ptr->options;
-
- png_ptr->options = (png_uint_32)((current & ~mask) | setting);
-
- return (int)(current & mask) >> option;
- }
-
- return PNG_OPTION_INVALID;
-}
-#endif
-
-/* sRGB support */
-#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\
- defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)
-/* sRGB conversion tables; these are machine generated with the code in
- * contrib/tools/makesRGB.c. The actual sRGB transfer curve defined in the
- * specification (see the article at https://en.wikipedia.org/wiki/SRGB)
- * is used, not the gamma=1/2.2 approximation use elsewhere in libpng.
- * The sRGB to linear table is exact (to the nearest 16-bit linear fraction).
- * The inverse (linear to sRGB) table has accuracies as follows:
- *
- * For all possible (255*65535+1) input values:
- *
- * error: -0.515566 - 0.625971, 79441 (0.475369%) of readings inexact
- *
- * For the input values corresponding to the 65536 16-bit values:
- *
- * error: -0.513727 - 0.607759, 308 (0.469978%) of readings inexact
- *
- * In all cases the inexact readings are only off by one.
- */
-
-#ifdef PNG_SIMPLIFIED_READ_SUPPORTED
-/* The convert-to-sRGB table is only currently required for read. */
-const png_uint_16 png_sRGB_table[256] =
-{
- 0,20,40,60,80,99,119,139,
- 159,179,199,219,241,264,288,313,
- 340,367,396,427,458,491,526,562,
- 599,637,677,718,761,805,851,898,
- 947,997,1048,1101,1156,1212,1270,1330,
- 1391,1453,1517,1583,1651,1720,1790,1863,
- 1937,2013,2090,2170,2250,2333,2418,2504,
- 2592,2681,2773,2866,2961,3058,3157,3258,
- 3360,3464,3570,3678,3788,3900,4014,4129,
- 4247,4366,4488,4611,4736,4864,4993,5124,
- 5257,5392,5530,5669,5810,5953,6099,6246,
- 6395,6547,6700,6856,7014,7174,7335,7500,
- 7666,7834,8004,8177,8352,8528,8708,8889,
- 9072,9258,9445,9635,9828,10022,10219,10417,
- 10619,10822,11028,11235,11446,11658,11873,12090,
- 12309,12530,12754,12980,13209,13440,13673,13909,
- 14146,14387,14629,14874,15122,15371,15623,15878,
- 16135,16394,16656,16920,17187,17456,17727,18001,
- 18277,18556,18837,19121,19407,19696,19987,20281,
- 20577,20876,21177,21481,21787,22096,22407,22721,
- 23038,23357,23678,24002,24329,24658,24990,25325,
- 25662,26001,26344,26688,27036,27386,27739,28094,
- 28452,28813,29176,29542,29911,30282,30656,31033,
- 31412,31794,32179,32567,32957,33350,33745,34143,
- 34544,34948,35355,35764,36176,36591,37008,37429,
- 37852,38278,38706,39138,39572,40009,40449,40891,
- 41337,41785,42236,42690,43147,43606,44069,44534,
- 45002,45473,45947,46423,46903,47385,47871,48359,
- 48850,49344,49841,50341,50844,51349,51858,52369,
- 52884,53401,53921,54445,54971,55500,56032,56567,
- 57105,57646,58190,58737,59287,59840,60396,60955,
- 61517,62082,62650,63221,63795,64372,64952,65535
-};
-#endif /* SIMPLIFIED_READ */
-
-/* The base/delta tables are required for both read and write (but currently
- * only the simplified versions.)
- */
-const png_uint_16 png_sRGB_base[512] =
-{
- 128,1782,3383,4644,5675,6564,7357,8074,
- 8732,9346,9921,10463,10977,11466,11935,12384,
- 12816,13233,13634,14024,14402,14769,15125,15473,
- 15812,16142,16466,16781,17090,17393,17690,17981,
- 18266,18546,18822,19093,19359,19621,19879,20133,
- 20383,20630,20873,21113,21349,21583,21813,22041,
- 22265,22487,22707,22923,23138,23350,23559,23767,
- 23972,24175,24376,24575,24772,24967,25160,25352,
- 25542,25730,25916,26101,26284,26465,26645,26823,
- 27000,27176,27350,27523,27695,27865,28034,28201,
- 28368,28533,28697,28860,29021,29182,29341,29500,
- 29657,29813,29969,30123,30276,30429,30580,30730,
- 30880,31028,31176,31323,31469,31614,31758,31902,
- 32045,32186,32327,32468,32607,32746,32884,33021,
- 33158,33294,33429,33564,33697,33831,33963,34095,
- 34226,34357,34486,34616,34744,34873,35000,35127,
- 35253,35379,35504,35629,35753,35876,35999,36122,
- 36244,36365,36486,36606,36726,36845,36964,37083,
- 37201,37318,37435,37551,37668,37783,37898,38013,
- 38127,38241,38354,38467,38580,38692,38803,38915,
- 39026,39136,39246,39356,39465,39574,39682,39790,
- 39898,40005,40112,40219,40325,40431,40537,40642,
- 40747,40851,40955,41059,41163,41266,41369,41471,
- 41573,41675,41777,41878,41979,42079,42179,42279,
- 42379,42478,42577,42676,42775,42873,42971,43068,
- 43165,43262,43359,43456,43552,43648,43743,43839,
- 43934,44028,44123,44217,44311,44405,44499,44592,
- 44685,44778,44870,44962,45054,45146,45238,45329,
- 45420,45511,45601,45692,45782,45872,45961,46051,
- 46140,46229,46318,46406,46494,46583,46670,46758,
- 46846,46933,47020,47107,47193,47280,47366,47452,
- 47538,47623,47709,47794,47879,47964,48048,48133,
- 48217,48301,48385,48468,48552,48635,48718,48801,
- 48884,48966,49048,49131,49213,49294,49376,49458,
- 49539,49620,49701,49782,49862,49943,50023,50103,
- 50183,50263,50342,50422,50501,50580,50659,50738,
- 50816,50895,50973,51051,51129,51207,51285,51362,
- 51439,51517,51594,51671,51747,51824,51900,51977,
- 52053,52129,52205,52280,52356,52432,52507,52582,
- 52657,52732,52807,52881,52956,53030,53104,53178,
- 53252,53326,53400,53473,53546,53620,53693,53766,
- 53839,53911,53984,54056,54129,54201,54273,54345,
- 54417,54489,54560,54632,54703,54774,54845,54916,
- 54987,55058,55129,55199,55269,55340,55410,55480,
- 55550,55620,55689,55759,55828,55898,55967,56036,
- 56105,56174,56243,56311,56380,56448,56517,56585,
- 56653,56721,56789,56857,56924,56992,57059,57127,
- 57194,57261,57328,57395,57462,57529,57595,57662,
- 57728,57795,57861,57927,57993,58059,58125,58191,
- 58256,58322,58387,58453,58518,58583,58648,58713,
- 58778,58843,58908,58972,59037,59101,59165,59230,
- 59294,59358,59422,59486,59549,59613,59677,59740,
- 59804,59867,59930,59993,60056,60119,60182,60245,
- 60308,60370,60433,60495,60558,60620,60682,60744,
- 60806,60868,60930,60992,61054,61115,61177,61238,
- 61300,61361,61422,61483,61544,61605,61666,61727,
- 61788,61848,61909,61969,62030,62090,62150,62211,
- 62271,62331,62391,62450,62510,62570,62630,62689,
- 62749,62808,62867,62927,62986,63045,63104,63163,
- 63222,63281,63340,63398,63457,63515,63574,63632,
- 63691,63749,63807,63865,63923,63981,64039,64097,
- 64155,64212,64270,64328,64385,64443,64500,64557,
- 64614,64672,64729,64786,64843,64900,64956,65013,
- 65070,65126,65183,65239,65296,65352,65409,65465
-};
-
-const png_byte png_sRGB_delta[512] =
-{
- 207,201,158,129,113,100,90,82,77,72,68,64,61,59,56,54,
- 52,50,49,47,46,45,43,42,41,40,39,39,38,37,36,36,
- 35,34,34,33,33,32,32,31,31,30,30,30,29,29,28,28,
- 28,27,27,27,27,26,26,26,25,25,25,25,24,24,24,24,
- 23,23,23,23,23,22,22,22,22,22,22,21,21,21,21,21,
- 21,20,20,20,20,20,20,20,20,19,19,19,19,19,19,19,
- 19,18,18,18,18,18,18,18,18,18,18,17,17,17,17,17,
- 17,17,17,17,17,17,16,16,16,16,16,16,16,16,16,16,
- 16,16,16,16,15,15,15,15,15,15,15,15,15,15,15,15,
- 15,15,15,15,14,14,14,14,14,14,14,14,14,14,14,14,
- 14,14,14,14,14,14,14,13,13,13,13,13,13,13,13,13,
- 13,13,13,13,13,13,13,13,13,13,13,13,13,13,12,12,
- 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
- 12,12,12,12,12,12,12,12,12,12,12,12,11,11,11,11,
- 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,
- 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,
- 11,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,
- 10,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
- 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
- 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
- 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
- 9,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
- 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
- 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
- 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
- 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
- 8,8,8,8,8,8,8,8,8,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
-};
-#endif /* SIMPLIFIED READ/WRITE sRGB support */
-
-/* SIMPLIFIED READ/WRITE SUPPORT */
-#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\
- defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)
-static int
-png_image_free_function(png_voidp argument)
-{
- png_imagep image = png_voidcast(png_imagep, argument);
- png_controlp cp = image->opaque;
- png_control c;
-
- /* Double check that we have a png_ptr - it should be impossible to get here
- * without one.
- */
- if (cp->png_ptr == NULL)
- return 0;
-
- /* First free any data held in the control structure. */
-# ifdef PNG_STDIO_SUPPORTED
- if (cp->owned_file != 0)
- {
- FILE *fp = png_voidcast(FILE*, cp->png_ptr->io_ptr);
- cp->owned_file = 0;
-
- /* Ignore errors here. */
- if (fp != NULL)
- {
- cp->png_ptr->io_ptr = NULL;
- (void)fclose(fp);
- }
- }
-# endif
-
- /* Copy the control structure so that the original, allocated, version can be
- * safely freed. Notice that a png_error here stops the remainder of the
- * cleanup, but this is probably fine because that would indicate bad memory
- * problems anyway.
- */
- c = *cp;
- image->opaque = &c;
- png_free(c.png_ptr, cp);
-
- /* Then the structures, calling the correct API. */
- if (c.for_write != 0)
- {
-# ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED
- png_destroy_write_struct(&c.png_ptr, &c.info_ptr);
-# else
- png_error(c.png_ptr, "simplified write not supported");
-# endif
- }
- else
- {
-# ifdef PNG_SIMPLIFIED_READ_SUPPORTED
- png_destroy_read_struct(&c.png_ptr, &c.info_ptr, NULL);
-# else
- png_error(c.png_ptr, "simplified read not supported");
-# endif
- }
-
- /* Success. */
- return 1;
-}
-
-void PNGAPI
-png_image_free(png_imagep image)
-{
- /* Safely call the real function, but only if doing so is safe at this point
- * (if not inside an error handling context). Otherwise assume
- * png_safe_execute will call this API after the return.
- */
- if (image != NULL && image->opaque != NULL &&
- image->opaque->error_buf == NULL)
- {
- png_image_free_function(image);
- image->opaque = NULL;
- }
-}
-
-int /* PRIVATE */
-png_image_error(png_imagep image, png_const_charp error_message)
-{
- /* Utility to log an error. */
- png_safecat(image->message, (sizeof image->message), 0, error_message);
- image->warning_or_error |= PNG_IMAGE_ERROR;
- png_image_free(image);
- return 0;
-}
-
-#endif /* SIMPLIFIED READ/WRITE */
-#endif /* READ || WRITE */
diff --git a/contrib/libs/libpng/png.h b/contrib/libs/libpng/png.h
deleted file mode 100644
index 0723af3f23..0000000000
--- a/contrib/libs/libpng/png.h
+++ /dev/null
@@ -1,3456 +0,0 @@
-/* png.h - header file for PNG reference library
- *
- * libpng version 1.6.46
- *
- * Copyright (c) 2018-2025 Cosmin Truta
- * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
- * Copyright (c) 1996-1997 Andreas Dilger
- * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
- *
- * This code is released under the libpng license. (See LICENSE, below.)
- *
- * Authors and maintainers:
- * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
- * libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger
- * libpng versions 0.97, January 1998, through 1.6.35, July 2018:
- * Glenn Randers-Pehrson
- * libpng versions 1.6.36, December 2018, through 1.6.46, January 2025:
- * Cosmin Truta
- * See also "Contributing Authors", below.
- */
-
-/*
- * COPYRIGHT NOTICE, DISCLAIMER, and LICENSE
- * =========================================
- *
- * This modified version of libpng code adds animated PNG support and is
- * released under the libpng license described below. The modifications are
- * Copyright (c) 2006-2007 Andrew Smith, Copyright (c) 2008-2025 Max Stepin,
- * and are delimited by "#ifdef PNG_APNG_SUPPORTED / #endif" directives
- * surrounding them in the modified libpng source files.
- *
- * PNG Reference Library License version 2
- * ---------------------------------------
- *
- * * Copyright (c) 1995-2025 The PNG Reference Library Authors.
- * * Copyright (c) 2018-2025 Cosmin Truta.
- * * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson.
- * * Copyright (c) 1996-1997 Andreas Dilger.
- * * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
- *
- * The software is supplied "as is", without warranty of any kind,
- * express or implied, including, without limitation, the warranties
- * of merchantability, fitness for a particular purpose, title, and
- * non-infringement. In no event shall the Copyright owners, or
- * anyone distributing the software, be liable for any damages or
- * other liability, whether in contract, tort or otherwise, arising
- * from, out of, or in connection with the software, or the use or
- * other dealings in the software, even if advised of the possibility
- * of such damage.
- *
- * Permission is hereby granted to use, copy, modify, and distribute
- * this software, or portions hereof, for any purpose, without fee,
- * subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you
- * must not claim that you wrote the original software. If you
- * use this software in a product, an acknowledgment in the product
- * documentation would be appreciated, but is not required.
- *
- * 2. Altered source versions must be plainly marked as such, and must
- * not be misrepresented as being the original software.
- *
- * 3. This Copyright notice may not be removed or altered from any
- * source or altered source distribution.
- *
- *
- * PNG Reference Library License version 1 (for libpng 0.5 through 1.6.35)
- * -----------------------------------------------------------------------
- *
- * libpng versions 1.0.7, July 1, 2000, through 1.6.35, July 15, 2018 are
- * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson, are
- * derived from libpng-1.0.6, and are distributed according to the same
- * disclaimer and license as libpng-1.0.6 with the following individuals
- * added to the list of Contributing Authors:
- *
- * Simon-Pierre Cadieux
- * Eric S. Raymond
- * Mans Rullgard
- * Cosmin Truta
- * Gilles Vollant
- * James Yu
- * Mandar Sahastrabuddhe
- * Google Inc.
- * Vadim Barkov
- *
- * and with the following additions to the disclaimer:
- *
- * There is no warranty against interference with your enjoyment of
- * the library or against infringement. There is no warranty that our
- * efforts or the library will fulfill any of your particular purposes
- * or needs. This library is provided with all faults, and the entire
- * risk of satisfactory quality, performance, accuracy, and effort is
- * with the user.
- *
- * Some files in the "contrib" directory and some configure-generated
- * files that are distributed with libpng have other copyright owners, and
- * are released under other open source licenses.
- *
- * libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
- * Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
- * libpng-0.96, and are distributed according to the same disclaimer and
- * license as libpng-0.96, with the following individuals added to the
- * list of Contributing Authors:
- *
- * Tom Lane
- * Glenn Randers-Pehrson
- * Willem van Schaik
- *
- * libpng versions 0.89, June 1996, through 0.96, May 1997, are
- * Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
- * and are distributed according to the same disclaimer and license as
- * libpng-0.88, with the following individuals added to the list of
- * Contributing Authors:
- *
- * John Bowler
- * Kevin Bracey
- * Sam Bushell
- * Magnus Holmgren
- * Greg Roelofs
- * Tom Tanner
- *
- * Some files in the "scripts" directory have other copyright owners,
- * but are released under this license.
- *
- * libpng versions 0.5, May 1995, through 0.88, January 1996, are
- * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
- *
- * For the purposes of this copyright and license, "Contributing Authors"
- * is defined as the following set of individuals:
- *
- * Andreas Dilger
- * Dave Martindale
- * Guy Eric Schalnat
- * Paul Schmidt
- * Tim Wegner
- *
- * The PNG Reference Library is supplied "AS IS". The Contributing
- * Authors and Group 42, Inc. disclaim all warranties, expressed or
- * implied, including, without limitation, the warranties of
- * merchantability and of fitness for any purpose. The Contributing
- * Authors and Group 42, Inc. assume no liability for direct, indirect,
- * incidental, special, exemplary, or consequential damages, which may
- * result from the use of the PNG Reference Library, even if advised of
- * the possibility of such damage.
- *
- * Permission is hereby granted to use, copy, modify, and distribute this
- * source code, or portions hereof, for any purpose, without fee, subject
- * to the following restrictions:
- *
- * 1. The origin of this source code must not be misrepresented.
- *
- * 2. Altered versions must be plainly marked as such and must not
- * be misrepresented as being the original source.
- *
- * 3. This Copyright notice may not be removed or altered from any
- * source or altered source distribution.
- *
- * The Contributing Authors and Group 42, Inc. specifically permit,
- * without fee, and encourage the use of this source code as a component
- * to supporting the PNG file format in commercial products. If you use
- * this source code in a product, acknowledgment is not required but would
- * be appreciated.
- *
- * END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE.
- *
- * TRADEMARK
- * =========
- *
- * The name "libpng" has not been registered by the Copyright owners
- * as a trademark in any jurisdiction. However, because libpng has
- * been distributed and maintained world-wide, continually since 1995,
- * the Copyright owners claim "common-law trademark protection" in any
- * jurisdiction where common-law trademark is recognized.
- */
-
-/*
- * A "png_get_copyright" function is available, for convenient use in "about"
- * boxes and the like:
- *
- * printf("%s", png_get_copyright(NULL));
- *
- * Also, the PNG logo (in PNG format, of course) is supplied in the
- * files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
- */
-
-/*
- * The contributing authors would like to thank all those who helped
- * with testing, bug fixes, and patience. This wouldn't have been
- * possible without all of you.
- *
- * Thanks to Frank J. T. Wojcik for helping with the documentation.
- */
-
-/* Note about libpng version numbers:
- *
- * Due to various miscommunications, unforeseen code incompatibilities
- * and occasional factors outside the authors' control, version numbering
- * on the library has not always been consistent and straightforward.
- * The following table summarizes matters since version 0.89c, which was
- * the first widely used release:
- *
- * source png.h png.h shared-lib
- * version string int version
- * ------- ------ ----- ----------
- * 0.89c "1.0 beta 3" 0.89 89 1.0.89
- * 0.90 "1.0 beta 4" 0.90 90 0.90 [should have been 2.0.90]
- * 0.95 "1.0 beta 5" 0.95 95 0.95 [should have been 2.0.95]
- * 0.96 "1.0 beta 6" 0.96 96 0.96 [should have been 2.0.96]
- * 0.97b "1.00.97 beta 7" 1.00.97 97 1.0.1 [should have been 2.0.97]
- * 0.97c 0.97 97 2.0.97
- * 0.98 0.98 98 2.0.98
- * 0.99 0.99 98 2.0.99
- * 0.99a-m 0.99 99 2.0.99
- * 1.00 1.00 100 2.1.0 [100 should be 10000]
- * 1.0.0 (from here on, the 100 2.1.0 [100 should be 10000]
- * 1.0.1 png.h string is 10001 2.1.0
- * 1.0.1a-e identical to the 10002 from here on, the shared library
- * 1.0.2 source version) 10002 is 2.V where V is the source code
- * 1.0.2a-b 10003 version, except as noted.
- * 1.0.3 10003
- * 1.0.3a-d 10004
- * 1.0.4 10004
- * 1.0.4a-f 10005
- * 1.0.5 (+ 2 patches) 10005
- * 1.0.5a-d 10006
- * 1.0.5e-r 10100 (not source compatible)
- * 1.0.5s-v 10006 (not binary compatible)
- * 1.0.6 (+ 3 patches) 10006 (still binary incompatible)
- * 1.0.6d-f 10007 (still binary incompatible)
- * 1.0.6g 10007
- * 1.0.6h 10007 10.6h (testing xy.z so-numbering)
- * 1.0.6i 10007 10.6i
- * 1.0.6j 10007 2.1.0.6j (incompatible with 1.0.0)
- * 1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14 (binary compatible)
- * 1.0.7beta15-18 1 10007 2.1.0.7beta15-18 (binary compatible)
- * 1.0.7rc1-2 1 10007 2.1.0.7rc1-2 (binary compatible)
- * 1.0.7 1 10007 (still compatible)
- * ...
- * 1.0.69 10 10069 10.so.0.69[.0]
- * ...
- * 1.2.59 13 10259 12.so.0.59[.0]
- * ...
- * 1.4.20 14 10420 14.so.0.20[.0]
- * ...
- * 1.5.30 15 10530 15.so.15.30[.0]
- * ...
- * 1.6.46 16 10646 16.so.16.46[.0]
- *
- * Henceforth the source version will match the shared-library major and
- * minor numbers; the shared-library major version number will be used for
- * changes in backward compatibility, as it is intended.
- * The PNG_LIBPNG_VER macro, which is not used within libpng but is
- * available for applications, is an unsigned integer of the form XYYZZ
- * corresponding to the source version X.Y.Z (leading zeros in Y and Z).
- * Beta versions were given the previous public release number plus a
- * letter, until version 1.0.6j; from then on they were given the upcoming
- * public release number plus "betaNN" or "rcNN".
- *
- * Binary incompatibility exists only when applications make direct access
- * to the info_ptr or png_ptr members through png.h, and the compiled
- * application is loaded with a different version of the library.
- *
- * See libpng.txt or libpng.3 for more information. The PNG specification
- * is available as a W3C Recommendation and as an ISO/IEC Standard; see
- * <https://www.w3.org/TR/2003/REC-PNG-20031110/>
- */
-
-#ifndef PNG_H
-#define PNG_H
-
-/* This is not the place to learn how to use libpng. The file libpng-manual.txt
- * describes how to use libpng, and the file example.c summarizes it
- * with some code on which to build. This file is useful for looking
- * at the actual function definitions and structure components. If that
- * file has been stripped from your copy of libpng, you can find it at
- * <http://www.libpng.org/pub/png/libpng-manual.txt>
- *
- * If you just need to read a PNG file and don't want to read the documentation
- * skip to the end of this file and read the section entitled 'simplified API'.
- */
-
-/* Version information for png.h - this should match the version in png.c */
-#define PNG_LIBPNG_VER_STRING "1.6.46"
-#define PNG_HEADER_VERSION_STRING " libpng version " PNG_LIBPNG_VER_STRING "\n"
-
-/* The versions of shared library builds should stay in sync, going forward */
-#define PNG_LIBPNG_VER_SHAREDLIB 16
-#define PNG_LIBPNG_VER_SONUM PNG_LIBPNG_VER_SHAREDLIB /* [Deprecated] */
-#define PNG_LIBPNG_VER_DLLNUM PNG_LIBPNG_VER_SHAREDLIB /* [Deprecated] */
-
-/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
-#define PNG_LIBPNG_VER_MAJOR 1
-#define PNG_LIBPNG_VER_MINOR 6
-#define PNG_LIBPNG_VER_RELEASE 46
-
-/* This should be zero for a public release, or non-zero for a
- * development version.
- */
-#define PNG_LIBPNG_VER_BUILD 0
-
-/* Release Status */
-#define PNG_LIBPNG_BUILD_ALPHA 1
-#define PNG_LIBPNG_BUILD_BETA 2
-#define PNG_LIBPNG_BUILD_RC 3
-#define PNG_LIBPNG_BUILD_STABLE 4
-#define PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK 7
-
-/* Release-Specific Flags */
-#define PNG_LIBPNG_BUILD_PATCH 8 /* Can be OR'ed with
- PNG_LIBPNG_BUILD_STABLE only */
-#define PNG_LIBPNG_BUILD_PRIVATE 16 /* Cannot be OR'ed with
- PNG_LIBPNG_BUILD_SPECIAL */
-#define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with
- PNG_LIBPNG_BUILD_PRIVATE */
-
-#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE
-
-/* Careful here. At one time, Guy wanted to use 082, but that
- * would be octal. We must not include leading zeros.
- * Versions 0.7 through 1.0.0 were in the range 0 to 100 here
- * (only version 1.0.0 was mis-numbered 100 instead of 10000).
- * From version 1.0.1 it is:
- * XXYYZZ, where XX=major, YY=minor, ZZ=release
- */
-#define PNG_LIBPNG_VER 10646 /* 1.6.46 */
-
-/* Library configuration: these options cannot be changed after
- * the library has been built.
- */
-#ifndef PNGLCONF_H
-/* If pnglibconf.h is missing, you can
- * copy scripts/pnglibconf.h.prebuilt to pnglibconf.h
- */
-# include "pnglibconf.h"
-#endif
-
-#define PNG_APNG_SUPPORTED
-#define PNG_READ_APNG_SUPPORTED
-#define PNG_WRITE_APNG_SUPPORTED
-
-#ifndef PNG_VERSION_INFO_ONLY
-/* Machine specific configuration. */
-# include "pngconf.h"
-#endif
-
-/*
- * Added at libpng-1.2.8
- *
- * Ref MSDN: Private as priority over Special
- * VS_FF_PRIVATEBUILD File *was not* built using standard release
- * procedures. If this value is given, the StringFileInfo block must
- * contain a PrivateBuild string.
- *
- * VS_FF_SPECIALBUILD File *was* built by the original company using
- * standard release procedures but is a variation of the standard
- * file of the same version number. If this value is given, the
- * StringFileInfo block must contain a SpecialBuild string.
- */
-
-#ifdef PNG_USER_PRIVATEBUILD /* From pnglibconf.h */
-# define PNG_LIBPNG_BUILD_TYPE \
- (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_PRIVATE)
-#else
-# ifdef PNG_LIBPNG_SPECIALBUILD
-# define PNG_LIBPNG_BUILD_TYPE \
- (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_SPECIAL)
-# else
-# define PNG_LIBPNG_BUILD_TYPE (PNG_LIBPNG_BUILD_BASE_TYPE)
-# endif
-#endif
-
-#ifndef PNG_VERSION_INFO_ONLY
-
-/* Inhibit C++ name-mangling for libpng functions but not for system calls. */
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/* Version information for C files, stored in png.c. This had better match
- * the version above.
- */
-#define png_libpng_ver png_get_header_ver(NULL)
-
-/* This file is arranged in several sections:
- *
- * 1. [omitted]
- * 2. Any configuration options that can be specified by for the application
- * code when it is built. (Build time configuration is in pnglibconf.h)
- * 3. Type definitions (base types are defined in pngconf.h), structure
- * definitions.
- * 4. Exported library functions.
- * 5. Simplified API.
- * 6. Implementation options.
- *
- * The library source code has additional files (principally pngpriv.h) that
- * allow configuration of the library.
- */
-
-/* Section 1: [omitted] */
-
-/* Section 2: run time configuration
- * See pnglibconf.h for build time configuration
- *
- * Run time configuration allows the application to choose between
- * implementations of certain arithmetic APIs. The default is set
- * at build time and recorded in pnglibconf.h, but it is safe to
- * override these (and only these) settings. Note that this won't
- * change what the library does, only application code, and the
- * settings can (and probably should) be made on a per-file basis
- * by setting the #defines before including png.h
- *
- * Use macros to read integers from PNG data or use the exported
- * functions?
- * PNG_USE_READ_MACROS: use the macros (see below) Note that
- * the macros evaluate their argument multiple times.
- * PNG_NO_USE_READ_MACROS: call the relevant library function.
- *
- * Use the alternative algorithm for compositing alpha samples that
- * does not use division?
- * PNG_READ_COMPOSITE_NODIV_SUPPORTED: use the 'no division'
- * algorithm.
- * PNG_NO_READ_COMPOSITE_NODIV: use the 'division' algorithm.
- *
- * How to handle benign errors if PNG_ALLOW_BENIGN_ERRORS is
- * false?
- * PNG_ALLOW_BENIGN_ERRORS: map calls to the benign error
- * APIs to png_warning.
- * Otherwise the calls are mapped to png_error.
- */
-
-/* Section 3: type definitions, including structures and compile time
- * constants.
- * See pngconf.h for base types that vary by machine/system
- */
-
-#ifdef PNG_APNG_SUPPORTED
-/* dispose_op flags from inside fcTL */
-#define PNG_DISPOSE_OP_NONE 0x00
-#define PNG_DISPOSE_OP_BACKGROUND 0x01
-#define PNG_DISPOSE_OP_PREVIOUS 0x02
-
-/* blend_op flags from inside fcTL */
-#define PNG_BLEND_OP_SOURCE 0x00
-#define PNG_BLEND_OP_OVER 0x01
-#endif /* APNG */
-
-/* This triggers a compiler error in png.c, if png.c and png.h
- * do not agree upon the version number.
- */
-typedef char* png_libpng_version_1_6_46;
-
-/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
- *
- * png_struct is the cache of information used while reading or writing a single
- * PNG file. One of these is always required, although the simplified API
- * (below) hides the creation and destruction of it.
- */
-typedef struct png_struct_def png_struct;
-typedef const png_struct * png_const_structp;
-typedef png_struct * png_structp;
-typedef png_struct * * png_structpp;
-
-/* png_info contains information read from or to be written to a PNG file. One
- * or more of these must exist while reading or creating a PNG file. The
- * information is not used by libpng during read but is used to control what
- * gets written when a PNG file is created. "png_get_" function calls read
- * information during read and "png_set_" functions calls write information
- * when creating a PNG.
- * been moved into a separate header file that is not accessible to
- * applications. Read libpng-manual.txt or libpng.3 for more info.
- */
-typedef struct png_info_def png_info;
-typedef png_info * png_infop;
-typedef const png_info * png_const_infop;
-typedef png_info * * png_infopp;
-
-/* Types with names ending 'p' are pointer types. The corresponding types with
- * names ending 'rp' are identical pointer types except that the pointer is
- * marked 'restrict', which means that it is the only pointer to the object
- * passed to the function. Applications should not use the 'restrict' types;
- * it is always valid to pass 'p' to a pointer with a function argument of the
- * corresponding 'rp' type. Different compilers have different rules with
- * regard to type matching in the presence of 'restrict'. For backward
- * compatibility libpng callbacks never have 'restrict' in their parameters and,
- * consequentially, writing portable application code is extremely difficult if
- * an attempt is made to use 'restrict'.
- */
-typedef png_struct * PNG_RESTRICT png_structrp;
-typedef const png_struct * PNG_RESTRICT png_const_structrp;
-typedef png_info * PNG_RESTRICT png_inforp;
-typedef const png_info * PNG_RESTRICT png_const_inforp;
-
-/* Three color definitions. The order of the red, green, and blue, (and the
- * exact size) is not important, although the size of the fields need to
- * be png_byte or png_uint_16 (as defined below).
- */
-typedef struct png_color_struct
-{
- png_byte red;
- png_byte green;
- png_byte blue;
-} png_color;
-typedef png_color * png_colorp;
-typedef const png_color * png_const_colorp;
-typedef png_color * * png_colorpp;
-
-typedef struct png_color_16_struct
-{
- png_byte index; /* used for palette files */
- png_uint_16 red; /* for use in red green blue files */
- png_uint_16 green;
- png_uint_16 blue;
- png_uint_16 gray; /* for use in grayscale files */
-} png_color_16;
-typedef png_color_16 * png_color_16p;
-typedef const png_color_16 * png_const_color_16p;
-typedef png_color_16 * * png_color_16pp;
-
-typedef struct png_color_8_struct
-{
- png_byte red; /* for use in red green blue files */
- png_byte green;
- png_byte blue;
- png_byte gray; /* for use in grayscale files */
- png_byte alpha; /* for alpha channel files */
-} png_color_8;
-typedef png_color_8 * png_color_8p;
-typedef const png_color_8 * png_const_color_8p;
-typedef png_color_8 * * png_color_8pp;
-
-/*
- * The following two structures are used for the in-core representation
- * of sPLT chunks.
- */
-typedef struct png_sPLT_entry_struct
-{
- png_uint_16 red;
- png_uint_16 green;
- png_uint_16 blue;
- png_uint_16 alpha;
- png_uint_16 frequency;
-} png_sPLT_entry;
-typedef png_sPLT_entry * png_sPLT_entryp;
-typedef const png_sPLT_entry * png_const_sPLT_entryp;
-typedef png_sPLT_entry * * png_sPLT_entrypp;
-
-/* When the depth of the sPLT palette is 8 bits, the color and alpha samples
- * occupy the LSB of their respective members, and the MSB of each member
- * is zero-filled. The frequency member always occupies the full 16 bits.
- */
-
-typedef struct png_sPLT_struct
-{
- png_charp name; /* palette name */
- png_byte depth; /* depth of palette samples */
- png_sPLT_entryp entries; /* palette entries */
- png_int_32 nentries; /* number of palette entries */
-} png_sPLT_t;
-typedef png_sPLT_t * png_sPLT_tp;
-typedef const png_sPLT_t * png_const_sPLT_tp;
-typedef png_sPLT_t * * png_sPLT_tpp;
-
-#ifdef PNG_TEXT_SUPPORTED
-/* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file,
- * and whether that contents is compressed or not. The "key" field
- * points to a regular zero-terminated C string. The "text" fields can be a
- * regular C string, an empty string, or a NULL pointer.
- * However, the structure returned by png_get_text() will always contain
- * the "text" field as a regular zero-terminated C string (possibly
- * empty), never a NULL pointer, so it can be safely used in printf() and
- * other string-handling functions. Note that the "itxt_length", "lang", and
- * "lang_key" members of the structure only exist when the library is built
- * with iTXt chunk support. Prior to libpng-1.4.0 the library was built by
- * default without iTXt support. Also note that when iTXt *is* supported,
- * the "lang" and "lang_key" fields contain NULL pointers when the
- * "compression" field contains * PNG_TEXT_COMPRESSION_NONE or
- * PNG_TEXT_COMPRESSION_zTXt. Note that the "compression value" is not the
- * same as what appears in the PNG tEXt/zTXt/iTXt chunk's "compression flag"
- * which is always 0 or 1, or its "compression method" which is always 0.
- */
-typedef struct png_text_struct
-{
- int compression; /* compression value:
- -1: tEXt, none
- 0: zTXt, deflate
- 1: iTXt, none
- 2: iTXt, deflate */
- png_charp key; /* keyword, 1-79 character description of "text" */
- png_charp text; /* comment, may be an empty string (ie "")
- or a NULL pointer */
- size_t text_length; /* length of the text string */
- size_t itxt_length; /* length of the itxt string */
- png_charp lang; /* language code, 0-79 characters
- or a NULL pointer */
- png_charp lang_key; /* keyword translated UTF-8 string, 0 or more
- chars or a NULL pointer */
-} png_text;
-typedef png_text * png_textp;
-typedef const png_text * png_const_textp;
-typedef png_text * * png_textpp;
-#endif
-
-/* Supported compression types for text in PNG files (tEXt, and zTXt).
- * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. */
-#define PNG_TEXT_COMPRESSION_NONE_WR -3
-#define PNG_TEXT_COMPRESSION_zTXt_WR -2
-#define PNG_TEXT_COMPRESSION_NONE -1
-#define PNG_TEXT_COMPRESSION_zTXt 0
-#define PNG_ITXT_COMPRESSION_NONE 1
-#define PNG_ITXT_COMPRESSION_zTXt 2
-#define PNG_TEXT_COMPRESSION_LAST 3 /* Not a valid value */
-
-/* png_time is a way to hold the time in an machine independent way.
- * Two conversions are provided, both from time_t and struct tm. There
- * is no portable way to convert to either of these structures, as far
- * as I know. If you know of a portable way, send it to me. As a side
- * note - PNG has always been Year 2000 compliant!
- */
-typedef struct png_time_struct
-{
- png_uint_16 year; /* full year, as in, 1995 */
- png_byte month; /* month of year, 1 - 12 */
- png_byte day; /* day of month, 1 - 31 */
- png_byte hour; /* hour of day, 0 - 23 */
- png_byte minute; /* minute of hour, 0 - 59 */
- png_byte second; /* second of minute, 0 - 60 (for leap seconds) */
-} png_time;
-typedef png_time * png_timep;
-typedef const png_time * png_const_timep;
-typedef png_time * * png_timepp;
-
-#if defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED) ||\
- defined(PNG_USER_CHUNKS_SUPPORTED)
-/* png_unknown_chunk is a structure to hold queued chunks for which there is
- * no specific support. The idea is that we can use this to queue
- * up private chunks for output even though the library doesn't actually
- * know about their semantics.
- *
- * The data in the structure is set by libpng on read and used on write.
- */
-typedef struct png_unknown_chunk_t
-{
- png_byte name[5]; /* Textual chunk name with '\0' terminator */
- png_byte *data; /* Data, should not be modified on read! */
- size_t size;
-
- /* On write 'location' must be set using the flag values listed below.
- * Notice that on read it is set by libpng however the values stored have
- * more bits set than are listed below. Always treat the value as a
- * bitmask. On write set only one bit - setting multiple bits may cause the
- * chunk to be written in multiple places.
- */
- png_byte location; /* mode of operation at read time */
-}
-png_unknown_chunk;
-
-typedef png_unknown_chunk * png_unknown_chunkp;
-typedef const png_unknown_chunk * png_const_unknown_chunkp;
-typedef png_unknown_chunk * * png_unknown_chunkpp;
-#endif
-
-/* Flag values for the unknown chunk location byte. */
-#define PNG_HAVE_IHDR 0x01
-#define PNG_HAVE_PLTE 0x02
-#define PNG_AFTER_IDAT 0x08
-
-/* Maximum positive integer used in PNG is (2^31)-1 */
-#define PNG_UINT_31_MAX ((png_uint_32)0x7fffffffL)
-#define PNG_UINT_32_MAX ((png_uint_32)(-1))
-#define PNG_SIZE_MAX ((size_t)(-1))
-
-/* These are constants for fixed point values encoded in the
- * PNG specification manner (x100000)
- */
-#define PNG_FP_1 100000
-#define PNG_FP_HALF 50000
-#define PNG_FP_MAX ((png_fixed_point)0x7fffffffL)
-#define PNG_FP_MIN (-PNG_FP_MAX)
-
-/* These describe the color_type field in png_info. */
-/* color type masks */
-#define PNG_COLOR_MASK_PALETTE 1
-#define PNG_COLOR_MASK_COLOR 2
-#define PNG_COLOR_MASK_ALPHA 4
-
-/* color types. Note that not all combinations are legal */
-#define PNG_COLOR_TYPE_GRAY 0
-#define PNG_COLOR_TYPE_PALETTE (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE)
-#define PNG_COLOR_TYPE_RGB (PNG_COLOR_MASK_COLOR)
-#define PNG_COLOR_TYPE_RGB_ALPHA (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
-#define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA)
-/* aliases */
-#define PNG_COLOR_TYPE_RGBA PNG_COLOR_TYPE_RGB_ALPHA
-#define PNG_COLOR_TYPE_GA PNG_COLOR_TYPE_GRAY_ALPHA
-
-/* This is for compression type. PNG 1.0-1.2 only define the single type. */
-#define PNG_COMPRESSION_TYPE_BASE 0 /* Deflate method 8, 32K window */
-#define PNG_COMPRESSION_TYPE_DEFAULT PNG_COMPRESSION_TYPE_BASE
-
-/* This is for filter type. PNG 1.0-1.2 only define the single type. */
-#define PNG_FILTER_TYPE_BASE 0 /* Single row per-byte filtering */
-#define PNG_INTRAPIXEL_DIFFERENCING 64 /* Used only in MNG datastreams */
-#define PNG_FILTER_TYPE_DEFAULT PNG_FILTER_TYPE_BASE
-
-/* These are for the interlacing type. These values should NOT be changed. */
-#define PNG_INTERLACE_NONE 0 /* Non-interlaced image */
-#define PNG_INTERLACE_ADAM7 1 /* Adam7 interlacing */
-#define PNG_INTERLACE_LAST 2 /* Not a valid value */
-
-/* These are for the oFFs chunk. These values should NOT be changed. */
-#define PNG_OFFSET_PIXEL 0 /* Offset in pixels */
-#define PNG_OFFSET_MICROMETER 1 /* Offset in micrometers (1/10^6 meter) */
-#define PNG_OFFSET_LAST 2 /* Not a valid value */
-
-/* These are for the pCAL chunk. These values should NOT be changed. */
-#define PNG_EQUATION_LINEAR 0 /* Linear transformation */
-#define PNG_EQUATION_BASE_E 1 /* Exponential base e transform */
-#define PNG_EQUATION_ARBITRARY 2 /* Arbitrary base exponential transform */
-#define PNG_EQUATION_HYPERBOLIC 3 /* Hyperbolic sine transformation */
-#define PNG_EQUATION_LAST 4 /* Not a valid value */
-
-/* These are for the sCAL chunk. These values should NOT be changed. */
-#define PNG_SCALE_UNKNOWN 0 /* unknown unit (image scale) */
-#define PNG_SCALE_METER 1 /* meters per pixel */
-#define PNG_SCALE_RADIAN 2 /* radians per pixel */
-#define PNG_SCALE_LAST 3 /* Not a valid value */
-
-/* These are for the pHYs chunk. These values should NOT be changed. */
-#define PNG_RESOLUTION_UNKNOWN 0 /* pixels/unknown unit (aspect ratio) */
-#define PNG_RESOLUTION_METER 1 /* pixels/meter */
-#define PNG_RESOLUTION_LAST 2 /* Not a valid value */
-
-/* These are for the sRGB chunk. These values should NOT be changed. */
-#define PNG_sRGB_INTENT_PERCEPTUAL 0
-#define PNG_sRGB_INTENT_RELATIVE 1
-#define PNG_sRGB_INTENT_SATURATION 2
-#define PNG_sRGB_INTENT_ABSOLUTE 3
-#define PNG_sRGB_INTENT_LAST 4 /* Not a valid value */
-
-/* This is for text chunks */
-#define PNG_KEYWORD_MAX_LENGTH 79
-
-/* Maximum number of entries in PLTE/sPLT/tRNS arrays */
-#define PNG_MAX_PALETTE_LENGTH 256
-
-/* These determine if an ancillary chunk's data has been successfully read
- * from the PNG header, or if the application has filled in the corresponding
- * data in the info_struct to be written into the output file. The values
- * of the PNG_INFO_<chunk> defines should NOT be changed.
- */
-#define PNG_INFO_gAMA 0x0001U
-#define PNG_INFO_sBIT 0x0002U
-#define PNG_INFO_cHRM 0x0004U
-#define PNG_INFO_PLTE 0x0008U
-#define PNG_INFO_tRNS 0x0010U
-#define PNG_INFO_bKGD 0x0020U
-#define PNG_INFO_hIST 0x0040U
-#define PNG_INFO_pHYs 0x0080U
-#define PNG_INFO_oFFs 0x0100U
-#define PNG_INFO_tIME 0x0200U
-#define PNG_INFO_pCAL 0x0400U
-#define PNG_INFO_sRGB 0x0800U /* GR-P, 0.96a */
-#define PNG_INFO_iCCP 0x1000U /* ESR, 1.0.6 */
-#define PNG_INFO_sPLT 0x2000U /* ESR, 1.0.6 */
-#define PNG_INFO_sCAL 0x4000U /* ESR, 1.0.6 */
-#define PNG_INFO_IDAT 0x8000U /* ESR, 1.0.6 */
-#define PNG_INFO_eXIf 0x10000U /* GR-P, 1.6.31 */
-#define PNG_INFO_cICP 0x20000U /* PNGv3: 1.6.45 */
-#define PNG_INFO_cLLI 0x40000U /* PNGv3: 1.6.45 */
-#define PNG_INFO_mDCV 0x80000U /* PNGv3: 1.6.45 */
-/* APNG: these chunks are stored as unknown, these flags are never set
- * however they are provided as a convenience for implementors of APNG and
- * avoids any merge conflicts.
- *
- * Private chunks: these chunk names violate the chunk name recommendations
- * because the chunk definitions have no signature and because the private
- * chunks with these names have been reserved. Private definitions should
- * avoid them.
- */
-#define PNG_INFO_acTL 0x100000U /* PNGv3: 1.6.45: unknown */
-#define PNG_INFO_fcTL 0x200000U /* PNGv3: 1.6.45: unknown */
-#define PNG_INFO_fdAT 0x400000U /* PNGv3: 1.6.45: unknown */
-
-/* This is used for the transformation routines, as some of them
- * change these values for the row. It also should enable using
- * the routines for other purposes.
- */
-typedef struct png_row_info_struct
-{
- png_uint_32 width; /* width of row */
- size_t rowbytes; /* number of bytes in row */
- png_byte color_type; /* color type of row */
- png_byte bit_depth; /* bit depth of row */
- png_byte channels; /* number of channels (1, 2, 3, or 4) */
- png_byte pixel_depth; /* bits per pixel (depth * channels) */
-} png_row_info;
-
-typedef png_row_info * png_row_infop;
-typedef png_row_info * * png_row_infopp;
-
-/* These are the function types for the I/O functions and for the functions
- * that allow the user to override the default I/O functions with his or her
- * own. The png_error_ptr type should match that of user-supplied warning
- * and error functions, while the png_rw_ptr type should match that of the
- * user read/write data functions. Note that the 'write' function must not
- * modify the buffer it is passed. The 'read' function, on the other hand, is
- * expected to return the read data in the buffer.
- */
-typedef PNG_CALLBACK(void, *png_error_ptr, (png_structp, png_const_charp));
-typedef PNG_CALLBACK(void, *png_rw_ptr, (png_structp, png_bytep, size_t));
-typedef PNG_CALLBACK(void, *png_flush_ptr, (png_structp));
-typedef PNG_CALLBACK(void, *png_read_status_ptr, (png_structp, png_uint_32,
- int));
-typedef PNG_CALLBACK(void, *png_write_status_ptr, (png_structp, png_uint_32,
- int));
-
-#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
-typedef PNG_CALLBACK(void, *png_progressive_info_ptr, (png_structp, png_infop));
-typedef PNG_CALLBACK(void, *png_progressive_end_ptr, (png_structp, png_infop));
-#ifdef PNG_APNG_SUPPORTED
-typedef PNG_CALLBACK(void, *png_progressive_frame_ptr, (png_structp,
- png_uint_32));
-#endif
-
-/* The following callback receives png_uint_32 row_number, int pass for the
- * png_bytep data of the row. When transforming an interlaced image the
- * row number is the row number within the sub-image of the interlace pass, so
- * the value will increase to the height of the sub-image (not the full image)
- * then reset to 0 for the next pass.
- *
- * Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to
- * find the output pixel (x,y) given an interlaced sub-image pixel
- * (row,col,pass). (See below for these macros.)
- */
-typedef PNG_CALLBACK(void, *png_progressive_row_ptr, (png_structp, png_bytep,
- png_uint_32, int));
-#endif
-
-#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
- defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
-typedef PNG_CALLBACK(void, *png_user_transform_ptr, (png_structp, png_row_infop,
- png_bytep));
-#endif
-
-#ifdef PNG_USER_CHUNKS_SUPPORTED
-typedef PNG_CALLBACK(int, *png_user_chunk_ptr, (png_structp,
- png_unknown_chunkp));
-#endif
-#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
-/* not used anywhere */
-/* typedef PNG_CALLBACK(void, *png_unknown_chunk_ptr, (png_structp)); */
-#endif
-
-#ifdef PNG_SETJMP_SUPPORTED
-/* This must match the function definition in <setjmp.h>, and the application
- * must include this before png.h to obtain the definition of jmp_buf. The
- * function is required to be PNG_NORETURN, but this is not checked. If the
- * function does return the application will crash via an abort() or similar
- * system level call.
- *
- * If you get a warning here while building the library you may need to make
- * changes to ensure that pnglibconf.h records the calling convention used by
- * your compiler. This may be very difficult - try using a different compiler
- * to build the library!
- */
-PNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), (jmp_buf, int), typedef);
-#endif
-
-/* Transform masks for the high-level interface */
-#define PNG_TRANSFORM_IDENTITY 0x0000 /* read and write */
-#define PNG_TRANSFORM_STRIP_16 0x0001 /* read only */
-#define PNG_TRANSFORM_STRIP_ALPHA 0x0002 /* read only */
-#define PNG_TRANSFORM_PACKING 0x0004 /* read and write */
-#define PNG_TRANSFORM_PACKSWAP 0x0008 /* read and write */
-#define PNG_TRANSFORM_EXPAND 0x0010 /* read only */
-#define PNG_TRANSFORM_INVERT_MONO 0x0020 /* read and write */
-#define PNG_TRANSFORM_SHIFT 0x0040 /* read and write */
-#define PNG_TRANSFORM_BGR 0x0080 /* read and write */
-#define PNG_TRANSFORM_SWAP_ALPHA 0x0100 /* read and write */
-#define PNG_TRANSFORM_SWAP_ENDIAN 0x0200 /* read and write */
-#define PNG_TRANSFORM_INVERT_ALPHA 0x0400 /* read and write */
-#define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* write only */
-/* Added to libpng-1.2.34 */
-#define PNG_TRANSFORM_STRIP_FILLER_BEFORE PNG_TRANSFORM_STRIP_FILLER
-#define PNG_TRANSFORM_STRIP_FILLER_AFTER 0x1000 /* write only */
-/* Added to libpng-1.4.0 */
-#define PNG_TRANSFORM_GRAY_TO_RGB 0x2000 /* read only */
-/* Added to libpng-1.5.4 */
-#define PNG_TRANSFORM_EXPAND_16 0x4000 /* read only */
-#if ~0U > 0xffffU /* or else this might break on a 16-bit machine */
-#define PNG_TRANSFORM_SCALE_16 0x8000 /* read only */
-#endif
-
-/* Flags for MNG supported features */
-#define PNG_FLAG_MNG_EMPTY_PLTE 0x01
-#define PNG_FLAG_MNG_FILTER_64 0x04
-#define PNG_ALL_MNG_FEATURES 0x05
-
-/* NOTE: prior to 1.5 these functions had no 'API' style declaration,
- * this allowed the zlib default functions to be used on Windows
- * platforms. In 1.5 the zlib default malloc (which just calls malloc and
- * ignores the first argument) should be completely compatible with the
- * following.
- */
-typedef PNG_CALLBACK(png_voidp, *png_malloc_ptr, (png_structp,
- png_alloc_size_t));
-typedef PNG_CALLBACK(void, *png_free_ptr, (png_structp, png_voidp));
-
-/* Section 4: exported functions
- * Here are the function definitions most commonly used. This is not
- * the place to find out how to use libpng. See libpng-manual.txt for the
- * full explanation, see example.c for the summary. This just provides
- * a simple one line description of the use of each function.
- *
- * The PNG_EXPORT() and PNG_EXPORTA() macros used below are defined in
- * pngconf.h and in the *.dfn files in the scripts directory.
- *
- * PNG_EXPORT(ordinal, type, name, (args));
- *
- * ordinal: ordinal that is used while building
- * *.def files. The ordinal value is only
- * relevant when preprocessing png.h with
- * the *.dfn files for building symbol table
- * entries, and are removed by pngconf.h.
- * type: return type of the function
- * name: function name
- * args: function arguments, with types
- *
- * When we wish to append attributes to a function prototype we use
- * the PNG_EXPORTA() macro instead.
- *
- * PNG_EXPORTA(ordinal, type, name, (args), attributes);
- *
- * ordinal, type, name, and args: same as in PNG_EXPORT().
- * attributes: function attributes
- */
-
-/* Returns the version number of the library */
-PNG_EXPORT(1, png_uint_32, png_access_version_number, (void));
-
-/* Tell lib we have already handled the first <num_bytes> magic bytes.
- * Handling more than 8 bytes from the beginning of the file is an error.
- */
-PNG_EXPORT(2, void, png_set_sig_bytes, (png_structrp png_ptr, int num_bytes));
-
-/* Check sig[start] through sig[start + num_to_check - 1] to see if it's a
- * PNG file. Returns zero if the supplied bytes match the 8-byte PNG
- * signature, and non-zero otherwise. Having num_to_check == 0 or
- * start > 7 will always fail (i.e. return non-zero).
- */
-PNG_EXPORT(3, int, png_sig_cmp, (png_const_bytep sig, size_t start,
- size_t num_to_check));
-
-/* Simple signature checking function. This is the same as calling
- * png_check_sig(sig, n) := (png_sig_cmp(sig, 0, n) == 0).
- */
-#define png_check_sig(sig, n) (png_sig_cmp((sig), 0, (n)) == 0) /* DEPRECATED */
-
-/* Allocate and initialize png_ptr struct for reading, and any other memory. */
-PNG_EXPORTA(4, png_structp, png_create_read_struct,
- (png_const_charp user_png_ver, png_voidp error_ptr,
- png_error_ptr error_fn, png_error_ptr warn_fn),
- PNG_ALLOCATED);
-
-/* Allocate and initialize png_ptr struct for writing, and any other memory */
-PNG_EXPORTA(5, png_structp, png_create_write_struct,
- (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn,
- png_error_ptr warn_fn),
- PNG_ALLOCATED);
-
-PNG_EXPORT(6, size_t, png_get_compression_buffer_size,
- (png_const_structrp png_ptr));
-
-PNG_EXPORT(7, void, png_set_compression_buffer_size, (png_structrp png_ptr,
- size_t size));
-
-/* Moved from pngconf.h in 1.4.0 and modified to ensure setjmp/longjmp
- * match up.
- */
-#ifdef PNG_SETJMP_SUPPORTED
-/* This function returns the jmp_buf built in to *png_ptr. It must be
- * supplied with an appropriate 'longjmp' function to use on that jmp_buf
- * unless the default error function is overridden in which case NULL is
- * acceptable. The size of the jmp_buf is checked against the actual size
- * allocated by the library - the call will return NULL on a mismatch
- * indicating an ABI mismatch.
- */
-PNG_EXPORT(8, jmp_buf*, png_set_longjmp_fn, (png_structrp png_ptr,
- png_longjmp_ptr longjmp_fn, size_t jmp_buf_size));
-# define png_jmpbuf(png_ptr) \
- (*png_set_longjmp_fn((png_ptr), longjmp, (sizeof (jmp_buf))))
-#else
-# define png_jmpbuf(png_ptr) \
- (LIBPNG_WAS_COMPILED_WITH__PNG_NO_SETJMP)
-#endif
-/* This function should be used by libpng applications in place of
- * longjmp(png_ptr->jmpbuf, val). If longjmp_fn() has been set, it
- * will use it; otherwise it will call PNG_ABORT(). This function was
- * added in libpng-1.5.0.
- */
-PNG_EXPORTA(9, void, png_longjmp, (png_const_structrp png_ptr, int val),
- PNG_NORETURN);
-
-#ifdef PNG_READ_SUPPORTED
-/* Reset the compression stream */
-PNG_EXPORTA(10, int, png_reset_zstream, (png_structrp png_ptr), PNG_DEPRECATED);
-#endif
-
-/* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */
-#ifdef PNG_USER_MEM_SUPPORTED
-PNG_EXPORTA(11, png_structp, png_create_read_struct_2,
- (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn,
- png_error_ptr warn_fn,
- png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn),
- PNG_ALLOCATED);
-PNG_EXPORTA(12, png_structp, png_create_write_struct_2,
- (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn,
- png_error_ptr warn_fn,
- png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn),
- PNG_ALLOCATED);
-#endif
-
-/* Write the PNG file signature. */
-PNG_EXPORT(13, void, png_write_sig, (png_structrp png_ptr));
-
-/* Write a PNG chunk - size, type, (optional) data, CRC. */
-PNG_EXPORT(14, void, png_write_chunk, (png_structrp png_ptr, png_const_bytep
- chunk_name, png_const_bytep data, size_t length));
-
-/* Write the start of a PNG chunk - length and chunk name. */
-PNG_EXPORT(15, void, png_write_chunk_start, (png_structrp png_ptr,
- png_const_bytep chunk_name, png_uint_32 length));
-
-/* Write the data of a PNG chunk started with png_write_chunk_start(). */
-PNG_EXPORT(16, void, png_write_chunk_data, (png_structrp png_ptr,
- png_const_bytep data, size_t length));
-
-/* Finish a chunk started with png_write_chunk_start() (includes CRC). */
-PNG_EXPORT(17, void, png_write_chunk_end, (png_structrp png_ptr));
-
-/* Allocate and initialize the info structure */
-PNG_EXPORTA(18, png_infop, png_create_info_struct, (png_const_structrp png_ptr),
- PNG_ALLOCATED);
-
-/* DEPRECATED: this function allowed init structures to be created using the
- * default allocation method (typically malloc). Use is deprecated in 1.6.0 and
- * the API will be removed in the future.
- */
-PNG_EXPORTA(19, void, png_info_init_3, (png_infopp info_ptr,
- size_t png_info_struct_size), PNG_DEPRECATED);
-
-/* Writes all the PNG information before the image. */
-PNG_EXPORT(20, void, png_write_info_before_PLTE,
- (png_structrp png_ptr, png_const_inforp info_ptr));
-PNG_EXPORT(21, void, png_write_info,
- (png_structrp png_ptr, png_const_inforp info_ptr));
-
-#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
-/* Read the information before the actual image data. */
-PNG_EXPORT(22, void, png_read_info,
- (png_structrp png_ptr, png_inforp info_ptr));
-#endif
-
-#ifdef PNG_TIME_RFC1123_SUPPORTED
- /* Convert to a US string format: there is no localization support in this
- * routine. The original implementation used a 29 character buffer in
- * png_struct, this will be removed in future versions.
- */
-#if PNG_LIBPNG_VER < 10700
-/* To do: remove this from libpng17 (and from libpng17/png.c and pngstruct.h) */
-PNG_EXPORTA(23, png_const_charp, png_convert_to_rfc1123, (png_structrp png_ptr,
- png_const_timep ptime),PNG_DEPRECATED);
-#endif
-PNG_EXPORT(241, int, png_convert_to_rfc1123_buffer, (char out[29],
- png_const_timep ptime));
-#endif
-
-#ifdef PNG_CONVERT_tIME_SUPPORTED
-/* Convert from a struct tm to png_time */
-PNG_EXPORT(24, void, png_convert_from_struct_tm, (png_timep ptime,
- const struct tm * ttime));
-
-/* Convert from time_t to png_time. Uses gmtime() */
-PNG_EXPORT(25, void, png_convert_from_time_t, (png_timep ptime, time_t ttime));
-#endif /* CONVERT_tIME */
-
-#ifdef PNG_READ_EXPAND_SUPPORTED
-/* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */
-PNG_EXPORT(26, void, png_set_expand, (png_structrp png_ptr));
-PNG_EXPORT(27, void, png_set_expand_gray_1_2_4_to_8, (png_structrp png_ptr));
-PNG_EXPORT(28, void, png_set_palette_to_rgb, (png_structrp png_ptr));
-PNG_EXPORT(29, void, png_set_tRNS_to_alpha, (png_structrp png_ptr));
-#endif
-
-#ifdef PNG_READ_EXPAND_16_SUPPORTED
-/* Expand to 16-bit channels, forces conversion of palette to RGB and expansion
- * of a tRNS chunk if present.
- */
-PNG_EXPORT(221, void, png_set_expand_16, (png_structrp png_ptr));
-#endif
-
-#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
-/* Use blue, green, red order for pixels. */
-PNG_EXPORT(30, void, png_set_bgr, (png_structrp png_ptr));
-#endif
-
-#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
-/* Expand the grayscale to 24-bit RGB if necessary. */
-PNG_EXPORT(31, void, png_set_gray_to_rgb, (png_structrp png_ptr));
-#endif
-
-#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
-/* Reduce RGB to grayscale. */
-#define PNG_ERROR_ACTION_NONE 1
-#define PNG_ERROR_ACTION_WARN 2
-#define PNG_ERROR_ACTION_ERROR 3
-#define PNG_RGB_TO_GRAY_DEFAULT (-1)/*for red/green coefficients*/
-
-PNG_FP_EXPORT(32, void, png_set_rgb_to_gray, (png_structrp png_ptr,
- int error_action, double red, double green))
-PNG_FIXED_EXPORT(33, void, png_set_rgb_to_gray_fixed, (png_structrp png_ptr,
- int error_action, png_fixed_point red, png_fixed_point green))
-
-PNG_EXPORT(34, png_byte, png_get_rgb_to_gray_status, (png_const_structrp
- png_ptr));
-#endif
-
-#ifdef PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED
-PNG_EXPORT(35, void, png_build_grayscale_palette, (int bit_depth,
- png_colorp palette));
-#endif
-
-#ifdef PNG_READ_ALPHA_MODE_SUPPORTED
-/* How the alpha channel is interpreted - this affects how the color channels
- * of a PNG file are returned to the calling application when an alpha channel,
- * or a tRNS chunk in a palette file, is present.
- *
- * This has no effect on the way pixels are written into a PNG output
- * datastream. The color samples in a PNG datastream are never premultiplied
- * with the alpha samples.
- *
- * The default is to return data according to the PNG specification: the alpha
- * channel is a linear measure of the contribution of the pixel to the
- * corresponding composited pixel, and the color channels are unassociated
- * (not premultiplied). The gamma encoded color channels must be scaled
- * according to the contribution and to do this it is necessary to undo
- * the encoding, scale the color values, perform the composition and re-encode
- * the values. This is the 'PNG' mode.
- *
- * The alternative is to 'associate' the alpha with the color information by
- * storing color channel values that have been scaled by the alpha.
- * image. These are the 'STANDARD', 'ASSOCIATED' or 'PREMULTIPLIED' modes
- * (the latter being the two common names for associated alpha color channels).
- *
- * For the 'OPTIMIZED' mode, a pixel is treated as opaque only if the alpha
- * value is equal to the maximum value.
- *
- * The final choice is to gamma encode the alpha channel as well. This is
- * broken because, in practice, no implementation that uses this choice
- * correctly undoes the encoding before handling alpha composition. Use this
- * choice only if other serious errors in the software or hardware you use
- * mandate it; the typical serious error is for dark halos to appear around
- * opaque areas of the composited PNG image because of arithmetic overflow.
- *
- * The API function png_set_alpha_mode specifies which of these choices to use
- * with an enumerated 'mode' value and the gamma of the required output:
- */
-#define PNG_ALPHA_PNG 0 /* according to the PNG standard */
-#define PNG_ALPHA_STANDARD 1 /* according to Porter/Duff */
-#define PNG_ALPHA_ASSOCIATED 1 /* as above; this is the normal practice */
-#define PNG_ALPHA_PREMULTIPLIED 1 /* as above */
-#define PNG_ALPHA_OPTIMIZED 2 /* 'PNG' for opaque pixels, else 'STANDARD' */
-#define PNG_ALPHA_BROKEN 3 /* the alpha channel is gamma encoded */
-
-PNG_FP_EXPORT(227, void, png_set_alpha_mode, (png_structrp png_ptr, int mode,
- double output_gamma))
-PNG_FIXED_EXPORT(228, void, png_set_alpha_mode_fixed, (png_structrp png_ptr,
- int mode, png_fixed_point output_gamma))
-#endif
-
-#if defined(PNG_GAMMA_SUPPORTED) || defined(PNG_READ_ALPHA_MODE_SUPPORTED)
-/* The output_gamma value is a screen gamma in libpng terminology: it expresses
- * how to decode the output values, not how they are encoded.
- */
-#define PNG_DEFAULT_sRGB -1 /* sRGB gamma and color space */
-#define PNG_GAMMA_MAC_18 -2 /* Old Mac '1.8' gamma and color space */
-#define PNG_GAMMA_sRGB 220000 /* Television standards--matches sRGB gamma */
-#define PNG_GAMMA_LINEAR PNG_FP_1 /* Linear */
-#endif
-
-/* The following are examples of calls to png_set_alpha_mode to achieve the
- * required overall gamma correction and, where necessary, alpha
- * premultiplication.
- *
- * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB);
- * This is the default libpng handling of the alpha channel - it is not
- * pre-multiplied into the color components. In addition the call states
- * that the output is for a sRGB system and causes all PNG files without gAMA
- * chunks to be assumed to be encoded using sRGB.
- *
- * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC);
- * In this case the output is assumed to be something like an sRGB conformant
- * display preceded by a power-law lookup table of power 1.45. This is how
- * early Mac systems behaved.
- *
- * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_GAMMA_LINEAR);
- * This is the classic Jim Blinn approach and will work in academic
- * environments where everything is done by the book. It has the shortcoming
- * of assuming that input PNG data with no gamma information is linear - this
- * is unlikely to be correct unless the PNG files where generated locally.
- * Most of the time the output precision will be so low as to show
- * significant banding in dark areas of the image.
- *
- * png_set_expand_16(pp);
- * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_DEFAULT_sRGB);
- * This is a somewhat more realistic Jim Blinn inspired approach. PNG files
- * are assumed to have the sRGB encoding if not marked with a gamma value and
- * the output is always 16 bits per component. This permits accurate scaling
- * and processing of the data. If you know that your input PNG files were
- * generated locally you might need to replace PNG_DEFAULT_sRGB with the
- * correct value for your system.
- *
- * png_set_alpha_mode(pp, PNG_ALPHA_OPTIMIZED, PNG_DEFAULT_sRGB);
- * If you just need to composite the PNG image onto an existing background
- * and if you control the code that does this you can use the optimization
- * setting. In this case you just copy completely opaque pixels to the
- * output. For pixels that are not completely transparent (you just skip
- * those) you do the composition math using png_composite or png_composite_16
- * below then encode the resultant 8-bit or 16-bit values to match the output
- * encoding.
- *
- * Other cases
- * If neither the PNG nor the standard linear encoding work for you because
- * of the software or hardware you use then you have a big problem. The PNG
- * case will probably result in halos around the image. The linear encoding
- * will probably result in a washed out, too bright, image (it's actually too
- * contrasty.) Try the ALPHA_OPTIMIZED mode above - this will probably
- * substantially reduce the halos. Alternatively try:
- *
- * png_set_alpha_mode(pp, PNG_ALPHA_BROKEN, PNG_DEFAULT_sRGB);
- * This option will also reduce the halos, but there will be slight dark
- * halos round the opaque parts of the image where the background is light.
- * In the OPTIMIZED mode the halos will be light halos where the background
- * is dark. Take your pick - the halos are unavoidable unless you can get
- * your hardware/software fixed! (The OPTIMIZED approach is slightly
- * faster.)
- *
- * When the default gamma of PNG files doesn't match the output gamma.
- * If you have PNG files with no gamma information png_set_alpha_mode allows
- * you to provide a default gamma, but it also sets the output gamma to the
- * matching value. If you know your PNG files have a gamma that doesn't
- * match the output you can take advantage of the fact that
- * png_set_alpha_mode always sets the output gamma but only sets the PNG
- * default if it is not already set:
- *
- * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB);
- * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC);
- * The first call sets both the default and the output gamma values, the
- * second call overrides the output gamma without changing the default. This
- * is easier than achieving the same effect with png_set_gamma. You must use
- * PNG_ALPHA_PNG for the first call - internal checking in png_set_alpha will
- * fire if more than one call to png_set_alpha_mode and png_set_background is
- * made in the same read operation, however multiple calls with PNG_ALPHA_PNG
- * are ignored.
- */
-
-#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
-PNG_EXPORT(36, void, png_set_strip_alpha, (png_structrp png_ptr));
-#endif
-
-#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \
- defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
-PNG_EXPORT(37, void, png_set_swap_alpha, (png_structrp png_ptr));
-#endif
-
-#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \
- defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
-PNG_EXPORT(38, void, png_set_invert_alpha, (png_structrp png_ptr));
-#endif
-
-#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
-/* Add a filler byte to 8-bit or 16-bit Gray or 24-bit or 48-bit RGB images. */
-PNG_EXPORT(39, void, png_set_filler, (png_structrp png_ptr, png_uint_32 filler,
- int flags));
-/* The values of the PNG_FILLER_ defines should NOT be changed */
-# define PNG_FILLER_BEFORE 0
-# define PNG_FILLER_AFTER 1
-/* Add an alpha byte to 8-bit or 16-bit Gray or 24-bit or 48-bit RGB images. */
-PNG_EXPORT(40, void, png_set_add_alpha, (png_structrp png_ptr,
- png_uint_32 filler, int flags));
-#endif /* READ_FILLER || WRITE_FILLER */
-
-#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
-/* Swap bytes in 16-bit depth files. */
-PNG_EXPORT(41, void, png_set_swap, (png_structrp png_ptr));
-#endif
-
-#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
-/* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */
-PNG_EXPORT(42, void, png_set_packing, (png_structrp png_ptr));
-#endif
-
-#if defined(PNG_READ_PACKSWAP_SUPPORTED) || \
- defined(PNG_WRITE_PACKSWAP_SUPPORTED)
-/* Swap packing order of pixels in bytes. */
-PNG_EXPORT(43, void, png_set_packswap, (png_structrp png_ptr));
-#endif
-
-#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
-/* Converts files to legal bit depths. */
-PNG_EXPORT(44, void, png_set_shift, (png_structrp png_ptr, png_const_color_8p
- true_bits));
-#endif
-
-#if defined(PNG_READ_INTERLACING_SUPPORTED) || \
- defined(PNG_WRITE_INTERLACING_SUPPORTED)
-/* Have the code handle the interlacing. Returns the number of passes.
- * MUST be called before png_read_update_info or png_start_read_image,
- * otherwise it will not have the desired effect. Note that it is still
- * necessary to call png_read_row or png_read_rows png_get_image_height
- * times for each pass.
-*/
-PNG_EXPORT(45, int, png_set_interlace_handling, (png_structrp png_ptr));
-#endif
-
-#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
-/* Invert monochrome files */
-PNG_EXPORT(46, void, png_set_invert_mono, (png_structrp png_ptr));
-#endif
-
-#ifdef PNG_READ_BACKGROUND_SUPPORTED
-/* Handle alpha and tRNS by replacing with a background color. Prior to
- * libpng-1.5.4 this API must not be called before the PNG file header has been
- * read. Doing so will result in unexpected behavior and possible warnings or
- * errors if the PNG file contains a bKGD chunk.
- */
-PNG_FP_EXPORT(47, void, png_set_background, (png_structrp png_ptr,
- png_const_color_16p background_color, int background_gamma_code,
- int need_expand, double background_gamma))
-PNG_FIXED_EXPORT(215, void, png_set_background_fixed, (png_structrp png_ptr,
- png_const_color_16p background_color, int background_gamma_code,
- int need_expand, png_fixed_point background_gamma))
-#endif
-#ifdef PNG_READ_BACKGROUND_SUPPORTED
-# define PNG_BACKGROUND_GAMMA_UNKNOWN 0
-# define PNG_BACKGROUND_GAMMA_SCREEN 1
-# define PNG_BACKGROUND_GAMMA_FILE 2
-# define PNG_BACKGROUND_GAMMA_UNIQUE 3
-#endif
-
-#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
-/* Scale a 16-bit depth file down to 8-bit, accurately. */
-PNG_EXPORT(229, void, png_set_scale_16, (png_structrp png_ptr));
-#endif
-
-#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
-#define PNG_READ_16_TO_8_SUPPORTED /* Name prior to 1.5.4 */
-/* Strip the second byte of information from a 16-bit depth file. */
-PNG_EXPORT(48, void, png_set_strip_16, (png_structrp png_ptr));
-#endif
-
-#ifdef PNG_READ_QUANTIZE_SUPPORTED
-/* Turn on quantizing, and reduce the palette to the number of colors
- * available.
- */
-PNG_EXPORT(49, void, png_set_quantize, (png_structrp png_ptr,
- png_colorp palette, int num_palette, int maximum_colors,
- png_const_uint_16p histogram, int full_quantize));
-#endif
-
-#ifdef PNG_READ_GAMMA_SUPPORTED
-/* The threshold on gamma processing is configurable but hard-wired into the
- * library. The following is the floating point variant.
- */
-#define PNG_GAMMA_THRESHOLD (PNG_GAMMA_THRESHOLD_FIXED*.00001)
-
-/* Handle gamma correction. Screen_gamma=(display_exponent).
- * NOTE: this API simply sets the screen and file gamma values. It will
- * therefore override the value for gamma in a PNG file if it is called after
- * the file header has been read - use with care - call before reading the PNG
- * file for best results!
- *
- * These routines accept the same gamma values as png_set_alpha_mode (described
- * above). The PNG_GAMMA_ defines and PNG_DEFAULT_sRGB can be passed to either
- * API (floating point or fixed.) Notice, however, that the 'file_gamma' value
- * is the inverse of a 'screen gamma' value.
- */
-PNG_FP_EXPORT(50, void, png_set_gamma, (png_structrp png_ptr,
- double screen_gamma, double override_file_gamma))
-PNG_FIXED_EXPORT(208, void, png_set_gamma_fixed, (png_structrp png_ptr,
- png_fixed_point screen_gamma, png_fixed_point override_file_gamma))
-#endif
-
-#ifdef PNG_WRITE_FLUSH_SUPPORTED
-/* Set how many lines between output flushes - 0 for no flushing */
-PNG_EXPORT(51, void, png_set_flush, (png_structrp png_ptr, int nrows));
-/* Flush the current PNG output buffer */
-PNG_EXPORT(52, void, png_write_flush, (png_structrp png_ptr));
-#endif
-
-/* Optional update palette with requested transformations */
-PNG_EXPORT(53, void, png_start_read_image, (png_structrp png_ptr));
-
-/* Optional call to update the users info structure */
-PNG_EXPORT(54, void, png_read_update_info, (png_structrp png_ptr,
- png_inforp info_ptr));
-
-#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
-/* Read one or more rows of image data. */
-PNG_EXPORT(55, void, png_read_rows, (png_structrp png_ptr, png_bytepp row,
- png_bytepp display_row, png_uint_32 num_rows));
-#endif
-
-#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
-/* Read a row of data. */
-PNG_EXPORT(56, void, png_read_row, (png_structrp png_ptr, png_bytep row,
- png_bytep display_row));
-#endif
-
-#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
-/* Read the whole image into memory at once. */
-PNG_EXPORT(57, void, png_read_image, (png_structrp png_ptr, png_bytepp image));
-#endif
-
-/* Write a row of image data */
-PNG_EXPORT(58, void, png_write_row, (png_structrp png_ptr,
- png_const_bytep row));
-
-/* Write a few rows of image data: (*row) is not written; however, the type
- * is declared as writeable to maintain compatibility with previous versions
- * of libpng and to allow the 'display_row' array from read_rows to be passed
- * unchanged to write_rows.
- */
-PNG_EXPORT(59, void, png_write_rows, (png_structrp png_ptr, png_bytepp row,
- png_uint_32 num_rows));
-
-/* Write the image data */
-PNG_EXPORT(60, void, png_write_image, (png_structrp png_ptr, png_bytepp image));
-
-/* Write the end of the PNG file. */
-PNG_EXPORT(61, void, png_write_end, (png_structrp png_ptr,
- png_inforp info_ptr));
-
-#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
-/* Read the end of the PNG file. */
-PNG_EXPORT(62, void, png_read_end, (png_structrp png_ptr, png_inforp info_ptr));
-#endif
-
-/* Free any memory associated with the png_info_struct */
-PNG_EXPORT(63, void, png_destroy_info_struct, (png_const_structrp png_ptr,
- png_infopp info_ptr_ptr));
-
-/* Free any memory associated with the png_struct and the png_info_structs */
-PNG_EXPORT(64, void, png_destroy_read_struct, (png_structpp png_ptr_ptr,
- png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr));
-
-/* Free any memory associated with the png_struct and the png_info_structs */
-PNG_EXPORT(65, void, png_destroy_write_struct, (png_structpp png_ptr_ptr,
- png_infopp info_ptr_ptr));
-
-/* Set the libpng method of handling chunk CRC errors */
-PNG_EXPORT(66, void, png_set_crc_action, (png_structrp png_ptr, int crit_action,
- int ancil_action));
-
-/* Values for png_set_crc_action() say how to handle CRC errors in
- * ancillary and critical chunks, and whether to use the data contained
- * therein. Note that it is impossible to "discard" data in a critical
- * chunk. For versions prior to 0.90, the action was always error/quit,
- * whereas in version 0.90 and later, the action for CRC errors in ancillary
- * chunks is warn/discard. These values should NOT be changed.
- *
- * value action:critical action:ancillary
- */
-#define PNG_CRC_DEFAULT 0 /* error/quit warn/discard data */
-#define PNG_CRC_ERROR_QUIT 1 /* error/quit error/quit */
-#define PNG_CRC_WARN_DISCARD 2 /* (INVALID) warn/discard data */
-#define PNG_CRC_WARN_USE 3 /* warn/use data warn/use data */
-#define PNG_CRC_QUIET_USE 4 /* quiet/use data quiet/use data */
-#define PNG_CRC_NO_CHANGE 5 /* use current value use current value */
-
-#ifdef PNG_WRITE_SUPPORTED
-/* These functions give the user control over the scan-line filtering in
- * libpng and the compression methods used by zlib. These functions are
- * mainly useful for testing, as the defaults should work with most users.
- * Those users who are tight on memory or want faster performance at the
- * expense of compression can modify them. See the compression library
- * header file (zlib.h) for an explanation of the compression functions.
- */
-
-/* Set the filtering method(s) used by libpng. Currently, the only valid
- * value for "method" is 0.
- */
-PNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method,
- int filters));
-#endif /* WRITE */
-
-/* Flags for png_set_filter() to say which filters to use. The flags
- * are chosen so that they don't conflict with real filter types
- * below, in case they are supplied instead of the #defined constants.
- * These values should NOT be changed.
- */
-#define PNG_NO_FILTERS 0x00
-#define PNG_FILTER_NONE 0x08
-#define PNG_FILTER_SUB 0x10
-#define PNG_FILTER_UP 0x20
-#define PNG_FILTER_AVG 0x40
-#define PNG_FILTER_PAETH 0x80
-#define PNG_FAST_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP)
-#define PNG_ALL_FILTERS (PNG_FAST_FILTERS | PNG_FILTER_AVG | PNG_FILTER_PAETH)
-
-/* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now.
- * These defines should NOT be changed.
- */
-#define PNG_FILTER_VALUE_NONE 0
-#define PNG_FILTER_VALUE_SUB 1
-#define PNG_FILTER_VALUE_UP 2
-#define PNG_FILTER_VALUE_AVG 3
-#define PNG_FILTER_VALUE_PAETH 4
-#define PNG_FILTER_VALUE_LAST 5
-
-#ifdef PNG_WRITE_SUPPORTED
-#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* DEPRECATED */
-PNG_FP_EXPORT(68, void, png_set_filter_heuristics, (png_structrp png_ptr,
- int heuristic_method, int num_weights, png_const_doublep filter_weights,
- png_const_doublep filter_costs))
-PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed,
- (png_structrp png_ptr, int heuristic_method, int num_weights,
- png_const_fixed_point_p filter_weights,
- png_const_fixed_point_p filter_costs))
-#endif /* WRITE_WEIGHTED_FILTER */
-
-/* The following are no longer used and will be removed from libpng-1.7: */
-#define PNG_FILTER_HEURISTIC_DEFAULT 0 /* Currently "UNWEIGHTED" */
-#define PNG_FILTER_HEURISTIC_UNWEIGHTED 1 /* Used by libpng < 0.95 */
-#define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */
-#define PNG_FILTER_HEURISTIC_LAST 3 /* Not a valid value */
-
-/* Set the library compression level. Currently, valid values range from
- * 0 - 9, corresponding directly to the zlib compression levels 0 - 9
- * (0 - no compression, 9 - "maximal" compression). Note that tests have
- * shown that zlib compression levels 3-6 usually perform as well as level 9
- * for PNG images, and do considerably fewer calculations. In the future,
- * these values may not correspond directly to the zlib compression levels.
- */
-#ifdef PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED
-PNG_EXPORT(69, void, png_set_compression_level, (png_structrp png_ptr,
- int level));
-
-PNG_EXPORT(70, void, png_set_compression_mem_level, (png_structrp png_ptr,
- int mem_level));
-
-PNG_EXPORT(71, void, png_set_compression_strategy, (png_structrp png_ptr,
- int strategy));
-
-/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a
- * smaller value of window_bits if it can do so safely.
- */
-PNG_EXPORT(72, void, png_set_compression_window_bits, (png_structrp png_ptr,
- int window_bits));
-
-PNG_EXPORT(73, void, png_set_compression_method, (png_structrp png_ptr,
- int method));
-#endif /* WRITE_CUSTOMIZE_COMPRESSION */
-
-#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
-/* Also set zlib parameters for compressing non-IDAT chunks */
-PNG_EXPORT(222, void, png_set_text_compression_level, (png_structrp png_ptr,
- int level));
-
-PNG_EXPORT(223, void, png_set_text_compression_mem_level, (png_structrp png_ptr,
- int mem_level));
-
-PNG_EXPORT(224, void, png_set_text_compression_strategy, (png_structrp png_ptr,
- int strategy));
-
-/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a
- * smaller value of window_bits if it can do so safely.
- */
-PNG_EXPORT(225, void, png_set_text_compression_window_bits,
- (png_structrp png_ptr, int window_bits));
-
-PNG_EXPORT(226, void, png_set_text_compression_method, (png_structrp png_ptr,
- int method));
-#endif /* WRITE_CUSTOMIZE_ZTXT_COMPRESSION */
-#endif /* WRITE */
-
-/* These next functions are called for input/output, memory, and error
- * handling. They are in the file pngrio.c, pngwio.c, and pngerror.c,
- * and call standard C I/O routines such as fread(), fwrite(), and
- * fprintf(). These functions can be made to use other I/O routines
- * at run time for those applications that need to handle I/O in a
- * different manner by calling png_set_???_fn(). See libpng-manual.txt for
- * more information.
- */
-
-#ifdef PNG_STDIO_SUPPORTED
-/* Initialize the input/output for the PNG file to the default functions. */
-PNG_EXPORT(74, void, png_init_io, (png_structrp png_ptr, png_FILE_p fp));
-#endif
-
-/* Replace the (error and abort), and warning functions with user
- * supplied functions. If no messages are to be printed you must still
- * write and use replacement functions. The replacement error_fn should
- * still do a longjmp to the last setjmp location if you are using this
- * method of error handling. If error_fn or warning_fn is NULL, the
- * default function will be used.
- */
-
-PNG_EXPORT(75, void, png_set_error_fn, (png_structrp png_ptr,
- png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn));
-
-/* Return the user pointer associated with the error functions */
-PNG_EXPORT(76, png_voidp, png_get_error_ptr, (png_const_structrp png_ptr));
-
-/* Replace the default data output functions with a user supplied one(s).
- * If buffered output is not used, then output_flush_fn can be set to NULL.
- * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time
- * output_flush_fn will be ignored (and thus can be NULL).
- * It is probably a mistake to use NULL for output_flush_fn if
- * write_data_fn is not also NULL unless you have built libpng with
- * PNG_WRITE_FLUSH_SUPPORTED undefined, because in this case libpng's
- * default flush function, which uses the standard *FILE structure, will
- * be used.
- */
-PNG_EXPORT(77, void, png_set_write_fn, (png_structrp png_ptr, png_voidp io_ptr,
- png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn));
-
-/* Replace the default data input function with a user supplied one. */
-PNG_EXPORT(78, void, png_set_read_fn, (png_structrp png_ptr, png_voidp io_ptr,
- png_rw_ptr read_data_fn));
-
-/* Return the user pointer associated with the I/O functions */
-PNG_EXPORT(79, png_voidp, png_get_io_ptr, (png_const_structrp png_ptr));
-
-PNG_EXPORT(80, void, png_set_read_status_fn, (png_structrp png_ptr,
- png_read_status_ptr read_row_fn));
-
-PNG_EXPORT(81, void, png_set_write_status_fn, (png_structrp png_ptr,
- png_write_status_ptr write_row_fn));
-
-#ifdef PNG_USER_MEM_SUPPORTED
-/* Replace the default memory allocation functions with user supplied one(s). */
-PNG_EXPORT(82, void, png_set_mem_fn, (png_structrp png_ptr, png_voidp mem_ptr,
- png_malloc_ptr malloc_fn, png_free_ptr free_fn));
-/* Return the user pointer associated with the memory functions */
-PNG_EXPORT(83, png_voidp, png_get_mem_ptr, (png_const_structrp png_ptr));
-#endif
-
-#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
-PNG_EXPORT(84, void, png_set_read_user_transform_fn, (png_structrp png_ptr,
- png_user_transform_ptr read_user_transform_fn));
-#endif
-
-#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
-PNG_EXPORT(85, void, png_set_write_user_transform_fn, (png_structrp png_ptr,
- png_user_transform_ptr write_user_transform_fn));
-#endif
-
-#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
-PNG_EXPORT(86, void, png_set_user_transform_info, (png_structrp png_ptr,
- png_voidp user_transform_ptr, int user_transform_depth,
- int user_transform_channels));
-/* Return the user pointer associated with the user transform functions */
-PNG_EXPORT(87, png_voidp, png_get_user_transform_ptr,
- (png_const_structrp png_ptr));
-#endif
-
-#ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED
-/* Return information about the row currently being processed. Note that these
- * APIs do not fail but will return unexpected results if called outside a user
- * transform callback. Also note that when transforming an interlaced image the
- * row number is the row number within the sub-image of the interlace pass, so
- * the value will increase to the height of the sub-image (not the full image)
- * then reset to 0 for the next pass.
- *
- * Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to
- * find the output pixel (x,y) given an interlaced sub-image pixel
- * (row,col,pass). (See below for these macros.)
- */
-PNG_EXPORT(217, png_uint_32, png_get_current_row_number, (png_const_structrp));
-PNG_EXPORT(218, png_byte, png_get_current_pass_number, (png_const_structrp));
-#endif
-
-#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
-/* This callback is called only for *unknown* chunks. If
- * PNG_HANDLE_AS_UNKNOWN_SUPPORTED is set then it is possible to set known
- * chunks to be treated as unknown, however in this case the callback must do
- * any processing required by the chunk (e.g. by calling the appropriate
- * png_set_ APIs.)
- *
- * There is no write support - on write, by default, all the chunks in the
- * 'unknown' list are written in the specified position.
- *
- * The integer return from the callback function is interpreted thus:
- *
- * negative: An error occurred; png_chunk_error will be called.
- * zero: The chunk was not handled, the chunk will be saved. A critical
- * chunk will cause an error at this point unless it is to be saved.
- * positive: The chunk was handled, libpng will ignore/discard it.
- *
- * See "INTERACTION WITH USER CHUNK CALLBACKS" below for important notes about
- * how this behavior will change in libpng 1.7
- */
-PNG_EXPORT(88, void, png_set_read_user_chunk_fn, (png_structrp png_ptr,
- png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn));
-#endif
-
-#ifdef PNG_USER_CHUNKS_SUPPORTED
-PNG_EXPORT(89, png_voidp, png_get_user_chunk_ptr, (png_const_structrp png_ptr));
-#endif
-
-#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
-/* Sets the function callbacks for the push reader, and a pointer to a
- * user-defined structure available to the callback functions.
- */
-PNG_EXPORT(90, void, png_set_progressive_read_fn, (png_structrp png_ptr,
- png_voidp progressive_ptr, png_progressive_info_ptr info_fn,
- png_progressive_row_ptr row_fn, png_progressive_end_ptr end_fn));
-
-/* Returns the user pointer associated with the push read functions */
-PNG_EXPORT(91, png_voidp, png_get_progressive_ptr,
- (png_const_structrp png_ptr));
-
-/* Function to be called when data becomes available */
-PNG_EXPORT(92, void, png_process_data, (png_structrp png_ptr,
- png_inforp info_ptr, png_bytep buffer, size_t buffer_size));
-
-/* A function which may be called *only* within png_process_data to stop the
- * processing of any more data. The function returns the number of bytes
- * remaining, excluding any that libpng has cached internally. A subsequent
- * call to png_process_data must supply these bytes again. If the argument
- * 'save' is set to true the routine will first save all the pending data and
- * will always return 0.
- */
-PNG_EXPORT(219, size_t, png_process_data_pause, (png_structrp, int save));
-
-/* A function which may be called *only* outside (after) a call to
- * png_process_data. It returns the number of bytes of data to skip in the
- * input. Normally it will return 0, but if it returns a non-zero value the
- * application must skip than number of bytes of input data and pass the
- * following data to the next call to png_process_data.
- */
-PNG_EXPORT(220, png_uint_32, png_process_data_skip, (png_structrp));
-
-/* Function that combines rows. 'new_row' is a flag that should come from
- * the callback and be non-NULL if anything needs to be done; the library
- * stores its own version of the new data internally and ignores the passed
- * in value.
- */
-PNG_EXPORT(93, void, png_progressive_combine_row, (png_const_structrp png_ptr,
- png_bytep old_row, png_const_bytep new_row));
-#endif /* PROGRESSIVE_READ */
-
-PNG_EXPORTA(94, png_voidp, png_malloc, (png_const_structrp png_ptr,
- png_alloc_size_t size), PNG_ALLOCATED);
-/* Added at libpng version 1.4.0 */
-PNG_EXPORTA(95, png_voidp, png_calloc, (png_const_structrp png_ptr,
- png_alloc_size_t size), PNG_ALLOCATED);
-
-/* Added at libpng version 1.2.4 */
-PNG_EXPORTA(96, png_voidp, png_malloc_warn, (png_const_structrp png_ptr,
- png_alloc_size_t size), PNG_ALLOCATED);
-
-/* Frees a pointer allocated by png_malloc() */
-PNG_EXPORT(97, void, png_free, (png_const_structrp png_ptr, png_voidp ptr));
-
-/* Free data that was allocated internally */
-PNG_EXPORT(98, void, png_free_data, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 free_me, int num));
-
-/* Reassign the responsibility for freeing existing data, whether allocated
- * by libpng or by the application; this works on the png_info structure passed
- * in, without changing the state for other png_info structures.
- */
-PNG_EXPORT(99, void, png_data_freer, (png_const_structrp png_ptr,
- png_inforp info_ptr, int freer, png_uint_32 mask));
-
-/* Assignments for png_data_freer */
-#define PNG_DESTROY_WILL_FREE_DATA 1
-#define PNG_SET_WILL_FREE_DATA 1
-#define PNG_USER_WILL_FREE_DATA 2
-/* Flags for png_ptr->free_me and info_ptr->free_me */
-#define PNG_FREE_HIST 0x0008U
-#define PNG_FREE_ICCP 0x0010U
-#define PNG_FREE_SPLT 0x0020U
-#define PNG_FREE_ROWS 0x0040U
-#define PNG_FREE_PCAL 0x0080U
-#define PNG_FREE_SCAL 0x0100U
-#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
-# define PNG_FREE_UNKN 0x0200U
-#endif
-/* PNG_FREE_LIST 0x0400U removed in 1.6.0 because it is ignored */
-#define PNG_FREE_PLTE 0x1000U
-#define PNG_FREE_TRNS 0x2000U
-#define PNG_FREE_TEXT 0x4000U
-#define PNG_FREE_EXIF 0x8000U /* Added at libpng-1.6.31 */
-#define PNG_FREE_ALL 0xffffU
-#define PNG_FREE_MUL 0x4220U /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */
-
-#ifdef PNG_USER_MEM_SUPPORTED
-PNG_EXPORTA(100, png_voidp, png_malloc_default, (png_const_structrp png_ptr,
- png_alloc_size_t size), PNG_ALLOCATED PNG_DEPRECATED);
-PNG_EXPORTA(101, void, png_free_default, (png_const_structrp png_ptr,
- png_voidp ptr), PNG_DEPRECATED);
-#endif
-
-#ifdef PNG_ERROR_TEXT_SUPPORTED
-/* Fatal error in PNG image of libpng - can't continue */
-PNG_EXPORTA(102, void, png_error, (png_const_structrp png_ptr,
- png_const_charp error_message), PNG_NORETURN);
-
-/* The same, but the chunk name is prepended to the error string. */
-PNG_EXPORTA(103, void, png_chunk_error, (png_const_structrp png_ptr,
- png_const_charp error_message), PNG_NORETURN);
-
-#else
-/* Fatal error in PNG image of libpng - can't continue */
-PNG_EXPORTA(104, void, png_err, (png_const_structrp png_ptr), PNG_NORETURN);
-# define png_error(s1,s2) png_err(s1)
-# define png_chunk_error(s1,s2) png_err(s1)
-#endif
-
-#ifdef PNG_WARNINGS_SUPPORTED
-/* Non-fatal error in libpng. Can continue, but may have a problem. */
-PNG_EXPORT(105, void, png_warning, (png_const_structrp png_ptr,
- png_const_charp warning_message));
-
-/* Non-fatal error in libpng, chunk name is prepended to message. */
-PNG_EXPORT(106, void, png_chunk_warning, (png_const_structrp png_ptr,
- png_const_charp warning_message));
-#else
-# define png_warning(s1,s2) ((void)(s1))
-# define png_chunk_warning(s1,s2) ((void)(s1))
-#endif
-
-#ifdef PNG_BENIGN_ERRORS_SUPPORTED
-/* Benign error in libpng. Can continue, but may have a problem.
- * User can choose whether to handle as a fatal error or as a warning. */
-PNG_EXPORT(107, void, png_benign_error, (png_const_structrp png_ptr,
- png_const_charp warning_message));
-
-#ifdef PNG_READ_SUPPORTED
-/* Same, chunk name is prepended to message (only during read) */
-PNG_EXPORT(108, void, png_chunk_benign_error, (png_const_structrp png_ptr,
- png_const_charp warning_message));
-#endif
-
-PNG_EXPORT(109, void, png_set_benign_errors,
- (png_structrp png_ptr, int allowed));
-#else
-# ifdef PNG_ALLOW_BENIGN_ERRORS
-# define png_benign_error png_warning
-# define png_chunk_benign_error png_chunk_warning
-# else
-# define png_benign_error png_error
-# define png_chunk_benign_error png_chunk_error
-# endif
-#endif
-
-/* The png_set_<chunk> functions are for storing values in the png_info_struct.
- * Similarly, the png_get_<chunk> calls are used to read values from the
- * png_info_struct, either storing the parameters in the passed variables, or
- * setting pointers into the png_info_struct where the data is stored. The
- * png_get_<chunk> functions return a non-zero value if the data was available
- * in info_ptr, or return zero and do not change any of the parameters if the
- * data was not available.
- *
- * These functions should be used instead of directly accessing png_info
- * to avoid problems with future changes in the size and internal layout of
- * png_info_struct.
- */
-/* Returns "flag" if chunk data is valid in info_ptr. */
-PNG_EXPORT(110, png_uint_32, png_get_valid, (png_const_structrp png_ptr,
- png_const_inforp info_ptr, png_uint_32 flag));
-
-/* Returns number of bytes needed to hold a transformed row. */
-PNG_EXPORT(111, size_t, png_get_rowbytes, (png_const_structrp png_ptr,
- png_const_inforp info_ptr));
-
-#ifdef PNG_INFO_IMAGE_SUPPORTED
-/* Returns row_pointers, which is an array of pointers to scanlines that was
- * returned from png_read_png().
- */
-PNG_EXPORT(112, png_bytepp, png_get_rows, (png_const_structrp png_ptr,
- png_const_inforp info_ptr));
-
-/* Set row_pointers, which is an array of pointers to scanlines for use
- * by png_write_png().
- */
-PNG_EXPORT(113, void, png_set_rows, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_bytepp row_pointers));
-#endif
-
-/* Returns number of color channels in image. */
-PNG_EXPORT(114, png_byte, png_get_channels, (png_const_structrp png_ptr,
- png_const_inforp info_ptr));
-
-#ifdef PNG_EASY_ACCESS_SUPPORTED
-/* Returns image width in pixels. */
-PNG_EXPORT(115, png_uint_32, png_get_image_width, (png_const_structrp png_ptr,
- png_const_inforp info_ptr));
-
-/* Returns image height in pixels. */
-PNG_EXPORT(116, png_uint_32, png_get_image_height, (png_const_structrp png_ptr,
- png_const_inforp info_ptr));
-
-/* Returns image bit_depth. */
-PNG_EXPORT(117, png_byte, png_get_bit_depth, (png_const_structrp png_ptr,
- png_const_inforp info_ptr));
-
-/* Returns image color_type. */
-PNG_EXPORT(118, png_byte, png_get_color_type, (png_const_structrp png_ptr,
- png_const_inforp info_ptr));
-
-/* Returns image filter_type. */
-PNG_EXPORT(119, png_byte, png_get_filter_type, (png_const_structrp png_ptr,
- png_const_inforp info_ptr));
-
-/* Returns image interlace_type. */
-PNG_EXPORT(120, png_byte, png_get_interlace_type, (png_const_structrp png_ptr,
- png_const_inforp info_ptr));
-
-/* Returns image compression_type. */
-PNG_EXPORT(121, png_byte, png_get_compression_type, (png_const_structrp png_ptr,
- png_const_inforp info_ptr));
-
-/* Returns image resolution in pixels per meter, from pHYs chunk data. */
-PNG_EXPORT(122, png_uint_32, png_get_pixels_per_meter,
- (png_const_structrp png_ptr, png_const_inforp info_ptr));
-PNG_EXPORT(123, png_uint_32, png_get_x_pixels_per_meter,
- (png_const_structrp png_ptr, png_const_inforp info_ptr));
-PNG_EXPORT(124, png_uint_32, png_get_y_pixels_per_meter,
- (png_const_structrp png_ptr, png_const_inforp info_ptr));
-
-/* Returns pixel aspect ratio, computed from pHYs chunk data. */
-PNG_FP_EXPORT(125, float, png_get_pixel_aspect_ratio,
- (png_const_structrp png_ptr, png_const_inforp info_ptr))
-PNG_FIXED_EXPORT(210, png_fixed_point, png_get_pixel_aspect_ratio_fixed,
- (png_const_structrp png_ptr, png_const_inforp info_ptr))
-
-/* Returns image x, y offset in pixels or microns, from oFFs chunk data. */
-PNG_EXPORT(126, png_int_32, png_get_x_offset_pixels,
- (png_const_structrp png_ptr, png_const_inforp info_ptr));
-PNG_EXPORT(127, png_int_32, png_get_y_offset_pixels,
- (png_const_structrp png_ptr, png_const_inforp info_ptr));
-PNG_EXPORT(128, png_int_32, png_get_x_offset_microns,
- (png_const_structrp png_ptr, png_const_inforp info_ptr));
-PNG_EXPORT(129, png_int_32, png_get_y_offset_microns,
- (png_const_structrp png_ptr, png_const_inforp info_ptr));
-
-#endif /* EASY_ACCESS */
-
-#ifdef PNG_READ_SUPPORTED
-/* Returns pointer to signature string read from PNG header */
-PNG_EXPORT(130, png_const_bytep, png_get_signature, (png_const_structrp png_ptr,
- png_const_inforp info_ptr));
-#endif
-
-#ifdef PNG_bKGD_SUPPORTED
-PNG_EXPORT(131, png_uint_32, png_get_bKGD, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_color_16p *background));
-#endif
-
-#ifdef PNG_bKGD_SUPPORTED
-PNG_EXPORT(132, void, png_set_bKGD, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_const_color_16p background));
-#endif
-
-#ifdef PNG_cHRM_SUPPORTED
-PNG_FP_EXPORT(133, png_uint_32, png_get_cHRM, (png_const_structrp png_ptr,
- png_const_inforp info_ptr, double *white_x, double *white_y, double *red_x,
- double *red_y, double *green_x, double *green_y, double *blue_x,
- double *blue_y))
-PNG_FP_EXPORT(230, png_uint_32, png_get_cHRM_XYZ, (png_const_structrp png_ptr,
- png_const_inforp info_ptr, double *red_X, double *red_Y, double *red_Z,
- double *green_X, double *green_Y, double *green_Z, double *blue_X,
- double *blue_Y, double *blue_Z))
-PNG_FIXED_EXPORT(134, png_uint_32, png_get_cHRM_fixed,
- (png_const_structrp png_ptr, png_const_inforp info_ptr,
- png_fixed_point *int_white_x, png_fixed_point *int_white_y,
- png_fixed_point *int_red_x, png_fixed_point *int_red_y,
- png_fixed_point *int_green_x, png_fixed_point *int_green_y,
- png_fixed_point *int_blue_x, png_fixed_point *int_blue_y))
-PNG_FIXED_EXPORT(231, png_uint_32, png_get_cHRM_XYZ_fixed,
- (png_const_structrp png_ptr, png_const_inforp info_ptr,
- png_fixed_point *int_red_X, png_fixed_point *int_red_Y,
- png_fixed_point *int_red_Z, png_fixed_point *int_green_X,
- png_fixed_point *int_green_Y, png_fixed_point *int_green_Z,
- png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y,
- png_fixed_point *int_blue_Z))
-#endif
-
-#ifdef PNG_cHRM_SUPPORTED
-PNG_FP_EXPORT(135, void, png_set_cHRM, (png_const_structrp png_ptr,
- png_inforp info_ptr,
- double white_x, double white_y, double red_x, double red_y, double green_x,
- double green_y, double blue_x, double blue_y))
-PNG_FP_EXPORT(232, void, png_set_cHRM_XYZ, (png_const_structrp png_ptr,
- png_inforp info_ptr, double red_X, double red_Y, double red_Z,
- double green_X, double green_Y, double green_Z, double blue_X,
- double blue_Y, double blue_Z))
-PNG_FIXED_EXPORT(136, void, png_set_cHRM_fixed, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_fixed_point int_white_x,
- png_fixed_point int_white_y, png_fixed_point int_red_x,
- png_fixed_point int_red_y, png_fixed_point int_green_x,
- png_fixed_point int_green_y, png_fixed_point int_blue_x,
- png_fixed_point int_blue_y))
-PNG_FIXED_EXPORT(233, void, png_set_cHRM_XYZ_fixed, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_fixed_point int_red_X, png_fixed_point int_red_Y,
- png_fixed_point int_red_Z, png_fixed_point int_green_X,
- png_fixed_point int_green_Y, png_fixed_point int_green_Z,
- png_fixed_point int_blue_X, png_fixed_point int_blue_Y,
- png_fixed_point int_blue_Z))
-#endif
-
-#ifdef PNG_cICP_SUPPORTED
-PNG_EXPORT(250, png_uint_32, png_get_cICP, (png_const_structrp png_ptr,
- png_const_inforp info_ptr, png_bytep colour_primaries,
- png_bytep transfer_function, png_bytep matrix_coefficients,
- png_bytep video_full_range_flag));
-#endif
-
-#ifdef PNG_cICP_SUPPORTED
-PNG_EXPORT(251, void, png_set_cICP, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_byte colour_primaries,
- png_byte transfer_function, png_byte matrix_coefficients,
- png_byte video_full_range_flag));
-#endif
-
-#ifdef PNG_cLLI_SUPPORTED
-PNG_FP_EXPORT(252, png_uint_32, png_get_cLLI, (png_const_structrp png_ptr,
- png_const_inforp info_ptr, double *maximum_content_light_level,
- double *maximum_frame_average_light_level))
-PNG_FIXED_EXPORT(253, png_uint_32, png_get_cLLI_fixed,
- (png_const_structrp png_ptr, png_const_inforp info_ptr,
- /* The values below are in cd/m2 (nits) and are scaled by 10,000; not
- * 100,000 as in the case of png_fixed_point.
- */
- png_uint_32p maximum_content_light_level_scaled_by_10000,
- png_uint_32p maximum_frame_average_light_level_scaled_by_10000))
-#endif
-
-#ifdef PNG_cLLI_SUPPORTED
-PNG_FP_EXPORT(254, void, png_set_cLLI, (png_const_structrp png_ptr,
- png_inforp info_ptr, double maximum_content_light_level,
- double maximum_frame_average_light_level))
-PNG_FIXED_EXPORT(255, void, png_set_cLLI_fixed, (png_const_structrp png_ptr,
- png_inforp info_ptr,
- /* The values below are in cd/m2 (nits) and are scaled by 10,000; not
- * 100,000 as in the case of png_fixed_point.
- */
- png_uint_32 maximum_content_light_level_scaled_by_10000,
- png_uint_32 maximum_frame_average_light_level_scaled_by_10000))
-#endif
-
-#ifdef PNG_eXIf_SUPPORTED
-PNG_EXPORT(246, png_uint_32, png_get_eXIf, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_bytep *exif));
-PNG_EXPORT(247, void, png_set_eXIf, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_bytep exif));
-
-PNG_EXPORT(248, png_uint_32, png_get_eXIf_1, (png_const_structrp png_ptr,
- png_const_inforp info_ptr, png_uint_32 *num_exif, png_bytep *exif));
-PNG_EXPORT(249, void, png_set_eXIf_1, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 num_exif, png_bytep exif));
-#endif
-
-#ifdef PNG_gAMA_SUPPORTED
-PNG_FP_EXPORT(137, png_uint_32, png_get_gAMA, (png_const_structrp png_ptr,
- png_const_inforp info_ptr, double *file_gamma))
-PNG_FIXED_EXPORT(138, png_uint_32, png_get_gAMA_fixed,
- (png_const_structrp png_ptr, png_const_inforp info_ptr,
- png_fixed_point *int_file_gamma))
-#endif
-
-#ifdef PNG_gAMA_SUPPORTED
-PNG_FP_EXPORT(139, void, png_set_gAMA, (png_const_structrp png_ptr,
- png_inforp info_ptr, double file_gamma))
-PNG_FIXED_EXPORT(140, void, png_set_gAMA_fixed, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_fixed_point int_file_gamma))
-#endif
-
-#ifdef PNG_hIST_SUPPORTED
-PNG_EXPORT(141, png_uint_32, png_get_hIST, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_uint_16p *hist));
-PNG_EXPORT(142, void, png_set_hIST, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_const_uint_16p hist));
-#endif
-
-PNG_EXPORT(143, png_uint_32, png_get_IHDR, (png_const_structrp png_ptr,
- png_const_inforp info_ptr, png_uint_32 *width, png_uint_32 *height,
- int *bit_depth, int *color_type, int *interlace_method,
- int *compression_method, int *filter_method));
-
-PNG_EXPORT(144, void, png_set_IHDR, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth,
- int color_type, int interlace_method, int compression_method,
- int filter_method));
-
-#ifdef PNG_mDCV_SUPPORTED
-PNG_FP_EXPORT(256, png_uint_32, png_get_mDCV, (png_const_structrp png_ptr,
- png_const_inforp info_ptr,
- /* The chromaticities of the mastering display. As cHRM, but independent of
- * the encoding endpoints in cHRM, or cICP, or iCCP. These values will
- * always be in the range 0 to 1.3107.
- */
- double *white_x, double *white_y, double *red_x, double *red_y,
- double *green_x, double *green_y, double *blue_x, double *blue_y,
- /* Mastering display luminance in cd/m2 (nits). */
- double *mastering_display_maximum_luminance,
- double *mastering_display_minimum_luminance))
-
-PNG_FIXED_EXPORT(257, png_uint_32, png_get_mDCV_fixed,
- (png_const_structrp png_ptr, png_const_inforp info_ptr,
- png_fixed_point *int_white_x, png_fixed_point *int_white_y,
- png_fixed_point *int_red_x, png_fixed_point *int_red_y,
- png_fixed_point *int_green_x, png_fixed_point *int_green_y,
- png_fixed_point *int_blue_x, png_fixed_point *int_blue_y,
- /* Mastering display luminance in cd/m2 (nits) multiplied (scaled) by
- * 10,000.
- */
- png_uint_32p mastering_display_maximum_luminance_scaled_by_10000,
- png_uint_32p mastering_display_minimum_luminance_scaled_by_10000))
-#endif
-
-#ifdef PNG_mDCV_SUPPORTED
-PNG_FP_EXPORT(258, void, png_set_mDCV, (png_const_structrp png_ptr,
- png_inforp info_ptr,
- /* The chromaticities of the mastering display. As cHRM, but independent of
- * the encoding endpoints in cHRM, or cICP, or iCCP.
- */
- double white_x, double white_y, double red_x, double red_y, double green_x,
- double green_y, double blue_x, double blue_y,
- /* Mastering display luminance in cd/m2 (nits). */
- double mastering_display_maximum_luminance,
- double mastering_display_minimum_luminance))
-
-PNG_FIXED_EXPORT(259, void, png_set_mDCV_fixed, (png_const_structrp png_ptr,
- png_inforp info_ptr,
- /* The admissible range of these values is not the full range of a PNG
- * fixed point value. Negative values cannot be encoded and the maximum
- * value is about 1.3 */
- png_fixed_point int_white_x, png_fixed_point int_white_y,
- png_fixed_point int_red_x, png_fixed_point int_red_y,
- png_fixed_point int_green_x, png_fixed_point int_green_y,
- png_fixed_point int_blue_x, png_fixed_point int_blue_y,
- /* These are PNG unsigned 4 byte values: 31-bit unsigned values. The MSB
- * must be zero.
- */
- png_uint_32 mastering_display_maximum_luminance_scaled_by_10000,
- png_uint_32 mastering_display_minimum_luminance_scaled_by_10000))
-#endif
-
-#ifdef PNG_oFFs_SUPPORTED
-PNG_EXPORT(145, png_uint_32, png_get_oFFs, (png_const_structrp png_ptr,
- png_const_inforp info_ptr, png_int_32 *offset_x, png_int_32 *offset_y,
- int *unit_type));
-#endif
-
-#ifdef PNG_oFFs_SUPPORTED
-PNG_EXPORT(146, void, png_set_oFFs, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_int_32 offset_x, png_int_32 offset_y,
- int unit_type));
-#endif
-
-#ifdef PNG_pCAL_SUPPORTED
-PNG_EXPORT(147, png_uint_32, png_get_pCAL, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_charp *purpose, png_int_32 *X0,
- png_int_32 *X1, int *type, int *nparams, png_charp *units,
- png_charpp *params));
-#endif
-
-#ifdef PNG_pCAL_SUPPORTED
-PNG_EXPORT(148, void, png_set_pCAL, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_const_charp purpose, png_int_32 X0, png_int_32 X1,
- int type, int nparams, png_const_charp units, png_charpp params));
-#endif
-
-#ifdef PNG_pHYs_SUPPORTED
-PNG_EXPORT(149, png_uint_32, png_get_pHYs, (png_const_structrp png_ptr,
- png_const_inforp info_ptr, png_uint_32 *res_x, png_uint_32 *res_y,
- int *unit_type));
-#endif
-
-#ifdef PNG_pHYs_SUPPORTED
-PNG_EXPORT(150, void, png_set_pHYs, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type));
-#endif
-
-PNG_EXPORT(151, png_uint_32, png_get_PLTE, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_colorp *palette, int *num_palette));
-
-PNG_EXPORT(152, void, png_set_PLTE, (png_structrp png_ptr,
- png_inforp info_ptr, png_const_colorp palette, int num_palette));
-
-#ifdef PNG_sBIT_SUPPORTED
-PNG_EXPORT(153, png_uint_32, png_get_sBIT, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_color_8p *sig_bit));
-#endif
-
-#ifdef PNG_sBIT_SUPPORTED
-PNG_EXPORT(154, void, png_set_sBIT, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_const_color_8p sig_bit));
-#endif
-
-#ifdef PNG_sRGB_SUPPORTED
-PNG_EXPORT(155, png_uint_32, png_get_sRGB, (png_const_structrp png_ptr,
- png_const_inforp info_ptr, int *file_srgb_intent));
-#endif
-
-#ifdef PNG_sRGB_SUPPORTED
-PNG_EXPORT(156, void, png_set_sRGB, (png_const_structrp png_ptr,
- png_inforp info_ptr, int srgb_intent));
-PNG_EXPORT(157, void, png_set_sRGB_gAMA_and_cHRM, (png_const_structrp png_ptr,
- png_inforp info_ptr, int srgb_intent));
-#endif
-
-#ifdef PNG_iCCP_SUPPORTED
-PNG_EXPORT(158, png_uint_32, png_get_iCCP, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_charpp name, int *compression_type,
- png_bytepp profile, png_uint_32 *proflen));
-#endif
-
-#ifdef PNG_iCCP_SUPPORTED
-PNG_EXPORT(159, void, png_set_iCCP, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_const_charp name, int compression_type,
- png_const_bytep profile, png_uint_32 proflen));
-#endif
-
-#ifdef PNG_sPLT_SUPPORTED
-PNG_EXPORT(160, int, png_get_sPLT, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_sPLT_tpp entries));
-#endif
-
-#ifdef PNG_sPLT_SUPPORTED
-PNG_EXPORT(161, void, png_set_sPLT, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_const_sPLT_tp entries, int nentries));
-#endif
-
-#ifdef PNG_TEXT_SUPPORTED
-/* png_get_text also returns the number of text chunks in *num_text */
-PNG_EXPORT(162, int, png_get_text, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_textp *text_ptr, int *num_text));
-#endif
-
-/* Note while png_set_text() will accept a structure whose text,
- * language, and translated keywords are NULL pointers, the structure
- * returned by png_get_text will always contain regular
- * zero-terminated C strings. They might be empty strings but
- * they will never be NULL pointers.
- */
-
-#ifdef PNG_TEXT_SUPPORTED
-PNG_EXPORT(163, void, png_set_text, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_const_textp text_ptr, int num_text));
-#endif
-
-#ifdef PNG_tIME_SUPPORTED
-PNG_EXPORT(164, png_uint_32, png_get_tIME, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_timep *mod_time));
-#endif
-
-#ifdef PNG_tIME_SUPPORTED
-PNG_EXPORT(165, void, png_set_tIME, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_const_timep mod_time));
-#endif
-
-#ifdef PNG_tRNS_SUPPORTED
-PNG_EXPORT(166, png_uint_32, png_get_tRNS, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_bytep *trans_alpha, int *num_trans,
- png_color_16p *trans_color));
-#endif
-
-#ifdef PNG_tRNS_SUPPORTED
-PNG_EXPORT(167, void, png_set_tRNS, (png_structrp png_ptr,
- png_inforp info_ptr, png_const_bytep trans_alpha, int num_trans,
- png_const_color_16p trans_color));
-#endif
-
-#ifdef PNG_sCAL_SUPPORTED
-PNG_FP_EXPORT(168, png_uint_32, png_get_sCAL, (png_const_structrp png_ptr,
- png_const_inforp info_ptr, int *unit, double *width, double *height))
-#if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || \
- defined(PNG_FLOATING_POINT_SUPPORTED)
-/* NOTE: this API is currently implemented using floating point arithmetic,
- * consequently it can only be used on systems with floating point support.
- * In any case the range of values supported by png_fixed_point is small and it
- * is highly recommended that png_get_sCAL_s be used instead.
- */
-PNG_FIXED_EXPORT(214, png_uint_32, png_get_sCAL_fixed,
- (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit,
- png_fixed_point *width, png_fixed_point *height))
-#endif
-PNG_EXPORT(169, png_uint_32, png_get_sCAL_s,
- (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit,
- png_charpp swidth, png_charpp sheight));
-
-PNG_FP_EXPORT(170, void, png_set_sCAL, (png_const_structrp png_ptr,
- png_inforp info_ptr, int unit, double width, double height))
-PNG_FIXED_EXPORT(213, void, png_set_sCAL_fixed, (png_const_structrp png_ptr,
- png_inforp info_ptr, int unit, png_fixed_point width,
- png_fixed_point height))
-PNG_EXPORT(171, void, png_set_sCAL_s, (png_const_structrp png_ptr,
- png_inforp info_ptr, int unit,
- png_const_charp swidth, png_const_charp sheight));
-#endif /* sCAL */
-
-#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
-/* Provide the default handling for all unknown chunks or, optionally, for
- * specific unknown chunks.
- *
- * NOTE: prior to 1.6.0 the handling specified for particular chunks on read was
- * ignored and the default was used, the per-chunk setting only had an effect on
- * write. If you wish to have chunk-specific handling on read in code that must
- * work on earlier versions you must use a user chunk callback to specify the
- * desired handling (keep or discard.)
- *
- * The 'keep' parameter is a PNG_HANDLE_CHUNK_ value as listed below. The
- * parameter is interpreted as follows:
- *
- * READ:
- * PNG_HANDLE_CHUNK_AS_DEFAULT:
- * Known chunks: do normal libpng processing, do not keep the chunk (but
- * see the comments below about PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
- * Unknown chunks: for a specific chunk use the global default, when used
- * as the default discard the chunk data.
- * PNG_HANDLE_CHUNK_NEVER:
- * Discard the chunk data.
- * PNG_HANDLE_CHUNK_IF_SAFE:
- * Keep the chunk data if the chunk is not critical else raise a chunk
- * error.
- * PNG_HANDLE_CHUNK_ALWAYS:
- * Keep the chunk data.
- *
- * If the chunk data is saved it can be retrieved using png_get_unknown_chunks,
- * below. Notice that specifying "AS_DEFAULT" as a global default is equivalent
- * to specifying "NEVER", however when "AS_DEFAULT" is used for specific chunks
- * it simply resets the behavior to the libpng default.
- *
- * INTERACTION WITH USER CHUNK CALLBACKS:
- * The per-chunk handling is always used when there is a png_user_chunk_ptr
- * callback and the callback returns 0; the chunk is then always stored *unless*
- * it is critical and the per-chunk setting is other than ALWAYS. Notice that
- * the global default is *not* used in this case. (In effect the per-chunk
- * value is incremented to at least IF_SAFE.)
- *
- * IMPORTANT NOTE: this behavior will change in libpng 1.7 - the global and
- * per-chunk defaults will be honored. If you want to preserve the current
- * behavior when your callback returns 0 you must set PNG_HANDLE_CHUNK_IF_SAFE
- * as the default - if you don't do this libpng 1.6 will issue a warning.
- *
- * If you want unhandled unknown chunks to be discarded in libpng 1.6 and
- * earlier simply return '1' (handled).
- *
- * PNG_HANDLE_AS_UNKNOWN_SUPPORTED:
- * If this is *not* set known chunks will always be handled by libpng and
- * will never be stored in the unknown chunk list. Known chunks listed to
- * png_set_keep_unknown_chunks will have no effect. If it is set then known
- * chunks listed with a keep other than AS_DEFAULT will *never* be processed
- * by libpng, in addition critical chunks must either be processed by the
- * callback or saved.
- *
- * The IHDR and IEND chunks must not be listed. Because this turns off the
- * default handling for chunks that would otherwise be recognized the
- * behavior of libpng transformations may well become incorrect!
- *
- * WRITE:
- * When writing chunks the options only apply to the chunks specified by
- * png_set_unknown_chunks (below), libpng will *always* write known chunks
- * required by png_set_ calls and will always write the core critical chunks
- * (as required for PLTE).
- *
- * Each chunk in the png_set_unknown_chunks list is looked up in the
- * png_set_keep_unknown_chunks list to find the keep setting, this is then
- * interpreted as follows:
- *
- * PNG_HANDLE_CHUNK_AS_DEFAULT:
- * Write safe-to-copy chunks and write other chunks if the global
- * default is set to _ALWAYS, otherwise don't write this chunk.
- * PNG_HANDLE_CHUNK_NEVER:
- * Do not write the chunk.
- * PNG_HANDLE_CHUNK_IF_SAFE:
- * Write the chunk if it is safe-to-copy, otherwise do not write it.
- * PNG_HANDLE_CHUNK_ALWAYS:
- * Write the chunk.
- *
- * Note that the default behavior is effectively the opposite of the read case -
- * in read unknown chunks are not stored by default, in write they are written
- * by default. Also the behavior of PNG_HANDLE_CHUNK_IF_SAFE is very different
- * - on write the safe-to-copy bit is checked, on read the critical bit is
- * checked and on read if the chunk is critical an error will be raised.
- *
- * num_chunks:
- * ===========
- * If num_chunks is positive, then the "keep" parameter specifies the manner
- * for handling only those chunks appearing in the chunk_list array,
- * otherwise the chunk list array is ignored.
- *
- * If num_chunks is 0 the "keep" parameter specifies the default behavior for
- * unknown chunks, as described above.
- *
- * If num_chunks is negative, then the "keep" parameter specifies the manner
- * for handling all unknown chunks plus all chunks recognized by libpng
- * except for the IHDR, PLTE, tRNS, IDAT, and IEND chunks (which continue to
- * be processed by libpng.
- */
-#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
-PNG_EXPORT(172, void, png_set_keep_unknown_chunks, (png_structrp png_ptr,
- int keep, png_const_bytep chunk_list, int num_chunks));
-#endif /* HANDLE_AS_UNKNOWN */
-
-/* The "keep" PNG_HANDLE_CHUNK_ parameter for the specified chunk is returned;
- * the result is therefore true (non-zero) if special handling is required,
- * false for the default handling.
- */
-PNG_EXPORT(173, int, png_handle_as_unknown, (png_const_structrp png_ptr,
- png_const_bytep chunk_name));
-#endif /* SET_UNKNOWN_CHUNKS */
-
-#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
-PNG_EXPORT(174, void, png_set_unknown_chunks, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_const_unknown_chunkp unknowns,
- int num_unknowns));
- /* NOTE: prior to 1.6.0 this routine set the 'location' field of the added
- * unknowns to the location currently stored in the png_struct. This is
- * invariably the wrong value on write. To fix this call the following API
- * for each chunk in the list with the correct location. If you know your
- * code won't be compiled on earlier versions you can rely on
- * png_set_unknown_chunks(write-ptr, png_get_unknown_chunks(read-ptr)) doing
- * the correct thing.
- */
-
-PNG_EXPORT(175, void, png_set_unknown_chunk_location,
- (png_const_structrp png_ptr, png_inforp info_ptr, int chunk, int location));
-
-PNG_EXPORT(176, int, png_get_unknown_chunks, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_unknown_chunkpp entries));
-#endif
-
-/* Png_free_data() will turn off the "valid" flag for anything it frees.
- * If you need to turn it off for a chunk that your application has freed,
- * you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK);
- */
-PNG_EXPORT(177, void, png_set_invalid, (png_const_structrp png_ptr,
- png_inforp info_ptr, int mask));
-
-#ifdef PNG_INFO_IMAGE_SUPPORTED
-/* The "params" pointer is currently not used and is for future expansion. */
-#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
-PNG_EXPORT(178, void, png_read_png, (png_structrp png_ptr, png_inforp info_ptr,
- int transforms, png_voidp params));
-#endif
-#ifdef PNG_WRITE_SUPPORTED
-PNG_EXPORT(179, void, png_write_png, (png_structrp png_ptr, png_inforp info_ptr,
- int transforms, png_voidp params));
-#endif
-#endif
-
-PNG_EXPORT(180, png_const_charp, png_get_copyright,
- (png_const_structrp png_ptr));
-PNG_EXPORT(181, png_const_charp, png_get_header_ver,
- (png_const_structrp png_ptr));
-PNG_EXPORT(182, png_const_charp, png_get_header_version,
- (png_const_structrp png_ptr));
-PNG_EXPORT(183, png_const_charp, png_get_libpng_ver,
- (png_const_structrp png_ptr));
-
-#ifdef PNG_MNG_FEATURES_SUPPORTED
-PNG_EXPORT(184, png_uint_32, png_permit_mng_features, (png_structrp png_ptr,
- png_uint_32 mng_features_permitted));
-#endif
-
-/* For use in png_set_keep_unknown, added to version 1.2.6 */
-#define PNG_HANDLE_CHUNK_AS_DEFAULT 0
-#define PNG_HANDLE_CHUNK_NEVER 1
-#define PNG_HANDLE_CHUNK_IF_SAFE 2
-#define PNG_HANDLE_CHUNK_ALWAYS 3
-#define PNG_HANDLE_CHUNK_LAST 4
-
-/* Strip the prepended error numbers ("#nnn ") from error and warning
- * messages before passing them to the error or warning handler.
- */
-#ifdef PNG_ERROR_NUMBERS_SUPPORTED
-PNG_EXPORT(185, void, png_set_strip_error_numbers, (png_structrp png_ptr,
- png_uint_32 strip_mode));
-#endif
-
-/* Added in libpng-1.2.6 */
-#ifdef PNG_SET_USER_LIMITS_SUPPORTED
-PNG_EXPORT(186, void, png_set_user_limits, (png_structrp png_ptr,
- png_uint_32 user_width_max, png_uint_32 user_height_max));
-PNG_EXPORT(187, png_uint_32, png_get_user_width_max,
- (png_const_structrp png_ptr));
-PNG_EXPORT(188, png_uint_32, png_get_user_height_max,
- (png_const_structrp png_ptr));
-/* Added in libpng-1.4.0 */
-PNG_EXPORT(189, void, png_set_chunk_cache_max, (png_structrp png_ptr,
- png_uint_32 user_chunk_cache_max));
-PNG_EXPORT(190, png_uint_32, png_get_chunk_cache_max,
- (png_const_structrp png_ptr));
-/* Added in libpng-1.4.1 */
-PNG_EXPORT(191, void, png_set_chunk_malloc_max, (png_structrp png_ptr,
- png_alloc_size_t user_chunk_cache_max));
-PNG_EXPORT(192, png_alloc_size_t, png_get_chunk_malloc_max,
- (png_const_structrp png_ptr));
-#endif
-
-#if defined(PNG_INCH_CONVERSIONS_SUPPORTED)
-PNG_EXPORT(193, png_uint_32, png_get_pixels_per_inch,
- (png_const_structrp png_ptr, png_const_inforp info_ptr));
-
-PNG_EXPORT(194, png_uint_32, png_get_x_pixels_per_inch,
- (png_const_structrp png_ptr, png_const_inforp info_ptr));
-
-PNG_EXPORT(195, png_uint_32, png_get_y_pixels_per_inch,
- (png_const_structrp png_ptr, png_const_inforp info_ptr));
-
-PNG_FP_EXPORT(196, float, png_get_x_offset_inches,
- (png_const_structrp png_ptr, png_const_inforp info_ptr))
-#ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */
-PNG_FIXED_EXPORT(211, png_fixed_point, png_get_x_offset_inches_fixed,
- (png_const_structrp png_ptr, png_const_inforp info_ptr))
-#endif
-
-PNG_FP_EXPORT(197, float, png_get_y_offset_inches, (png_const_structrp png_ptr,
- png_const_inforp info_ptr))
-#ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */
-PNG_FIXED_EXPORT(212, png_fixed_point, png_get_y_offset_inches_fixed,
- (png_const_structrp png_ptr, png_const_inforp info_ptr))
-#endif
-
-# ifdef PNG_pHYs_SUPPORTED
-PNG_EXPORT(198, png_uint_32, png_get_pHYs_dpi, (png_const_structrp png_ptr,
- png_const_inforp info_ptr, png_uint_32 *res_x, png_uint_32 *res_y,
- int *unit_type));
-# endif /* pHYs */
-#endif /* INCH_CONVERSIONS */
-
-/* Added in libpng-1.4.0 */
-#ifdef PNG_IO_STATE_SUPPORTED
-PNG_EXPORT(199, png_uint_32, png_get_io_state, (png_const_structrp png_ptr));
-
-/* Removed from libpng 1.6; use png_get_io_chunk_type. */
-PNG_REMOVED(200, png_const_bytep, png_get_io_chunk_name, (png_structrp png_ptr),
- PNG_DEPRECATED)
-
-PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type,
- (png_const_structrp png_ptr));
-
-/* The flags returned by png_get_io_state() are the following: */
-# define PNG_IO_NONE 0x0000 /* no I/O at this moment */
-# define PNG_IO_READING 0x0001 /* currently reading */
-# define PNG_IO_WRITING 0x0002 /* currently writing */
-# define PNG_IO_SIGNATURE 0x0010 /* currently at the file signature */
-# define PNG_IO_CHUNK_HDR 0x0020 /* currently at the chunk header */
-# define PNG_IO_CHUNK_DATA 0x0040 /* currently at the chunk data */
-# define PNG_IO_CHUNK_CRC 0x0080 /* currently at the chunk crc */
-# define PNG_IO_MASK_OP 0x000f /* current operation: reading/writing */
-# define PNG_IO_MASK_LOC 0x00f0 /* current location: sig/hdr/data/crc */
-#endif /* IO_STATE */
-
-/* Interlace support. The following macros are always defined so that if
- * libpng interlace handling is turned off the macros may be used to handle
- * interlaced images within the application.
- */
-#define PNG_INTERLACE_ADAM7_PASSES 7
-
-/* Two macros to return the first row and first column of the original,
- * full, image which appears in a given pass. 'pass' is in the range 0
- * to 6 and the result is in the range 0 to 7.
- */
-#define PNG_PASS_START_ROW(pass) (((1&~(pass))<<(3-((pass)>>1)))&7)
-#define PNG_PASS_START_COL(pass) (((1& (pass))<<(3-(((pass)+1)>>1)))&7)
-
-/* A macro to return the offset between pixels in the output row for a pair of
- * pixels in the input - effectively the inverse of the 'COL_SHIFT' macro that
- * follows. Note that ROW_OFFSET is the offset from one row to the next whereas
- * COL_OFFSET is from one column to the next, within a row.
- */
-#define PNG_PASS_ROW_OFFSET(pass) ((pass)>2?(8>>(((pass)-1)>>1)):8)
-#define PNG_PASS_COL_OFFSET(pass) (1<<((7-(pass))>>1))
-
-/* Two macros to help evaluate the number of rows or columns in each
- * pass. This is expressed as a shift - effectively log2 of the number or
- * rows or columns in each 8x8 tile of the original image.
- */
-#define PNG_PASS_ROW_SHIFT(pass) ((pass)>2?(8-(pass))>>1:3)
-#define PNG_PASS_COL_SHIFT(pass) ((pass)>1?(7-(pass))>>1:3)
-
-/* Hence two macros to determine the number of rows or columns in a given
- * pass of an image given its height or width. In fact these macros may
- * return non-zero even though the sub-image is empty, because the other
- * dimension may be empty for a small image.
- */
-#define PNG_PASS_ROWS(height, pass) (((height)+(((1<<PNG_PASS_ROW_SHIFT(pass))\
- -1)-PNG_PASS_START_ROW(pass)))>>PNG_PASS_ROW_SHIFT(pass))
-#define PNG_PASS_COLS(width, pass) (((width)+(((1<<PNG_PASS_COL_SHIFT(pass))\
- -1)-PNG_PASS_START_COL(pass)))>>PNG_PASS_COL_SHIFT(pass))
-
-/* For the reader row callbacks (both progressive and sequential) it is
- * necessary to find the row in the output image given a row in an interlaced
- * image, so two more macros:
- */
-#define PNG_ROW_FROM_PASS_ROW(y_in, pass) \
- (((y_in)<<PNG_PASS_ROW_SHIFT(pass))+PNG_PASS_START_ROW(pass))
-#define PNG_COL_FROM_PASS_COL(x_in, pass) \
- (((x_in)<<PNG_PASS_COL_SHIFT(pass))+PNG_PASS_START_COL(pass))
-
-/* Two macros which return a boolean (0 or 1) saying whether the given row
- * or column is in a particular pass. These use a common utility macro that
- * returns a mask for a given pass - the offset 'off' selects the row or
- * column version. The mask has the appropriate bit set for each column in
- * the tile.
- */
-#define PNG_PASS_MASK(pass,off) ( \
- ((0x110145AF>>(((7-(off))-(pass))<<2)) & 0xF) | \
- ((0x01145AF0>>(((7-(off))-(pass))<<2)) & 0xF0))
-
-#define PNG_ROW_IN_INTERLACE_PASS(y, pass) \
- ((PNG_PASS_MASK(pass,0) >> ((y)&7)) & 1)
-#define PNG_COL_IN_INTERLACE_PASS(x, pass) \
- ((PNG_PASS_MASK(pass,1) >> ((x)&7)) & 1)
-
-#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED
-/* With these routines we avoid an integer divide, which will be slower on
- * most machines. However, it does take more operations than the corresponding
- * divide method, so it may be slower on a few RISC systems. There are two
- * shifts (by 8 or 16 bits) and an addition, versus a single integer divide.
- *
- * Note that the rounding factors are NOT supposed to be the same! 128 and
- * 32768 are correct for the NODIV code; 127 and 32767 are correct for the
- * standard method.
- *
- * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ]
- */
-
- /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */
-
-# define png_composite(composite, fg, alpha, bg) \
- { \
- png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) \
- * (png_uint_16)(alpha) \
- + (png_uint_16)(bg)*(png_uint_16)(255 \
- - (png_uint_16)(alpha)) + 128); \
- (composite) = (png_byte)(((temp + (temp >> 8)) >> 8) & 0xff); \
- }
-
-# define png_composite_16(composite, fg, alpha, bg) \
- { \
- png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) \
- * (png_uint_32)(alpha) \
- + (png_uint_32)(bg)*(65535 \
- - (png_uint_32)(alpha)) + 32768); \
- (composite) = (png_uint_16)(0xffff & ((temp + (temp >> 16)) >> 16)); \
- }
-
-#else /* Standard method using integer division */
-
-# define png_composite(composite, fg, alpha, bg) \
- (composite) = \
- (png_byte)(0xff & (((png_uint_16)(fg) * (png_uint_16)(alpha) + \
- (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \
- 127) / 255))
-
-# define png_composite_16(composite, fg, alpha, bg) \
- (composite) = \
- (png_uint_16)(0xffff & (((png_uint_32)(fg) * (png_uint_32)(alpha) + \
- (png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) + \
- 32767) / 65535))
-#endif /* READ_COMPOSITE_NODIV */
-
-#ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED
-PNG_EXPORT(201, png_uint_32, png_get_uint_32, (png_const_bytep buf));
-PNG_EXPORT(202, png_uint_16, png_get_uint_16, (png_const_bytep buf));
-PNG_EXPORT(203, png_int_32, png_get_int_32, (png_const_bytep buf));
-#endif
-
-PNG_EXPORT(204, png_uint_32, png_get_uint_31, (png_const_structrp png_ptr,
- png_const_bytep buf));
-/* No png_get_int_16 -- may be added if there's a real need for it. */
-
-/* Place a 32-bit number into a buffer in PNG byte order (big-endian). */
-#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED
-PNG_EXPORT(205, void, png_save_uint_32, (png_bytep buf, png_uint_32 i));
-#endif
-#ifdef PNG_SAVE_INT_32_SUPPORTED
-PNG_EXPORT(206, void, png_save_int_32, (png_bytep buf, png_int_32 i));
-#endif
-
-/* Place a 16-bit number into a buffer in PNG byte order.
- * The parameter is declared unsigned int, not png_uint_16,
- * just to avoid potential problems on pre-ANSI C compilers.
- */
-#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED
-PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i));
-/* No png_save_int_16 -- may be added if there's a real need for it. */
-#endif
-
-#ifdef PNG_USE_READ_MACROS
-/* Inline macros to do direct reads of bytes from the input buffer.
- * The png_get_int_32() routine assumes we are using two's complement
- * format for negative values, which is almost certainly true.
- */
-# define PNG_get_uint_32(buf) \
- (((png_uint_32)(*(buf)) << 24) + \
- ((png_uint_32)(*((buf) + 1)) << 16) + \
- ((png_uint_32)(*((buf) + 2)) << 8) + \
- ((png_uint_32)(*((buf) + 3))))
-
- /* From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the
- * function) incorrectly returned a value of type png_uint_32.
- */
-# define PNG_get_uint_16(buf) \
- ((png_uint_16) \
- (((unsigned int)(*(buf)) << 8) + \
- ((unsigned int)(*((buf) + 1)))))
-
-# define PNG_get_int_32(buf) \
- ((png_int_32)((*(buf) & 0x80) \
- ? -((png_int_32)(((png_get_uint_32(buf)^0xffffffffU)+1U)&0x7fffffffU)) \
- : (png_int_32)png_get_uint_32(buf)))
-
-/* If PNG_PREFIX is defined the same thing as below happens in pnglibconf.h,
- * but defining a macro name prefixed with PNG_PREFIX.
- */
-# ifndef PNG_PREFIX
-# define png_get_uint_32(buf) PNG_get_uint_32(buf)
-# define png_get_uint_16(buf) PNG_get_uint_16(buf)
-# define png_get_int_32(buf) PNG_get_int_32(buf)
-# endif
-#else
-# ifdef PNG_PREFIX
- /* No macros; revert to the (redefined) function */
-# define PNG_get_uint_32 (png_get_uint_32)
-# define PNG_get_uint_16 (png_get_uint_16)
-# define PNG_get_int_32 (png_get_int_32)
-# endif
-#endif
-
-#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
-PNG_EXPORT(242, void, png_set_check_for_invalid_index,
- (png_structrp png_ptr, int allowed));
-# ifdef PNG_GET_PALETTE_MAX_SUPPORTED
-PNG_EXPORT(243, int, png_get_palette_max, (png_const_structp png_ptr,
- png_const_infop info_ptr));
-# endif
-#endif /* CHECK_FOR_INVALID_INDEX */
-
-/*******************************************************************************
- * Section 5: SIMPLIFIED API
- *******************************************************************************
- *
- * Please read the documentation in libpng-manual.txt (TODO: write said
- * documentation) if you don't understand what follows.
- *
- * The simplified API hides the details of both libpng and the PNG file format
- * itself. It allows PNG files to be read into a very limited number of
- * in-memory bitmap formats or to be written from the same formats. If these
- * formats do not accommodate your needs then you can, and should, use the more
- * sophisticated APIs above - these support a wide variety of in-memory formats
- * and a wide variety of sophisticated transformations to those formats as well
- * as a wide variety of APIs to manipulate ancillary information.
- *
- * To read a PNG file using the simplified API:
- *
- * 1) Declare a 'png_image' structure (see below) on the stack, set the
- * version field to PNG_IMAGE_VERSION and the 'opaque' pointer to NULL
- * (this is REQUIRED, your program may crash if you don't do it.)
- * 2) Call the appropriate png_image_begin_read... function.
- * 3) Set the png_image 'format' member to the required sample format.
- * 4) Allocate a buffer for the image and, if required, the color-map.
- * 5) Call png_image_finish_read to read the image and, if required, the
- * color-map into your buffers.
- *
- * There are no restrictions on the format of the PNG input itself; all valid
- * color types, bit depths, and interlace methods are acceptable, and the
- * input image is transformed as necessary to the requested in-memory format
- * during the png_image_finish_read() step. The only caveat is that if you
- * request a color-mapped image from a PNG that is full-color or makes
- * complex use of an alpha channel the transformation is extremely lossy and the
- * result may look terrible.
- *
- * To write a PNG file using the simplified API:
- *
- * 1) Declare a 'png_image' structure on the stack and memset() it to all zero.
- * 2) Initialize the members of the structure that describe the image, setting
- * the 'format' member to the format of the image samples.
- * 3) Call the appropriate png_image_write... function with a pointer to the
- * image and, if necessary, the color-map to write the PNG data.
- *
- * png_image is a structure that describes the in-memory format of an image
- * when it is being read or defines the in-memory format of an image that you
- * need to write:
- */
-#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) || \
- defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)
-
-#define PNG_IMAGE_VERSION 1
-
-typedef struct png_control *png_controlp;
-typedef struct
-{
- png_controlp opaque; /* Initialize to NULL, free with png_image_free */
- png_uint_32 version; /* Set to PNG_IMAGE_VERSION */
- png_uint_32 width; /* Image width in pixels (columns) */
- png_uint_32 height; /* Image height in pixels (rows) */
- png_uint_32 format; /* Image format as defined below */
- png_uint_32 flags; /* A bit mask containing informational flags */
- png_uint_32 colormap_entries;
- /* Number of entries in the color-map */
-
- /* In the event of an error or warning the following field will be set to a
- * non-zero value and the 'message' field will contain a '\0' terminated
- * string with the libpng error or warning message. If both warnings and
- * an error were encountered, only the error is recorded. If there
- * are multiple warnings, only the first one is recorded.
- *
- * The upper 30 bits of this value are reserved, the low two bits contain
- * a value as follows:
- */
-# define PNG_IMAGE_WARNING 1
-# define PNG_IMAGE_ERROR 2
- /*
- * The result is a two-bit code such that a value more than 1 indicates
- * a failure in the API just called:
- *
- * 0 - no warning or error
- * 1 - warning
- * 2 - error
- * 3 - error preceded by warning
- */
-# define PNG_IMAGE_FAILED(png_cntrl) ((((png_cntrl).warning_or_error)&0x03)>1)
-
- png_uint_32 warning_or_error;
-
- char message[64];
-} png_image, *png_imagep;
-
-/* The samples of the image have one to four channels whose components have
- * original values in the range 0 to 1.0:
- *
- * 1: A single gray or luminance channel (G).
- * 2: A gray/luminance channel and an alpha channel (GA).
- * 3: Three red, green, blue color channels (RGB).
- * 4: Three color channels and an alpha channel (RGBA).
- *
- * The components are encoded in one of two ways:
- *
- * a) As a small integer, value 0..255, contained in a single byte. For the
- * alpha channel the original value is simply value/255. For the color or
- * luminance channels the value is encoded according to the sRGB specification
- * and matches the 8-bit format expected by typical display devices.
- *
- * The color/gray channels are not scaled (pre-multiplied) by the alpha
- * channel and are suitable for passing to color management software.
- *
- * b) As a value in the range 0..65535, contained in a 2-byte integer. All
- * channels can be converted to the original value by dividing by 65535; all
- * channels are linear. Color channels use the RGB encoding (RGB end-points) of
- * the sRGB specification. This encoding is identified by the
- * PNG_FORMAT_FLAG_LINEAR flag below.
- *
- * When the simplified API needs to convert between sRGB and linear colorspaces,
- * the actual sRGB transfer curve defined in the sRGB specification (see the
- * article at <https://en.wikipedia.org/wiki/SRGB>) is used, not the gamma=1/2.2
- * approximation used elsewhere in libpng.
- *
- * When an alpha channel is present it is expected to denote pixel coverage
- * of the color or luminance channels and is returned as an associated alpha
- * channel: the color/gray channels are scaled (pre-multiplied) by the alpha
- * value.
- *
- * The samples are either contained directly in the image data, between 1 and 8
- * bytes per pixel according to the encoding, or are held in a color-map indexed
- * by bytes in the image data. In the case of a color-map the color-map entries
- * are individual samples, encoded as above, and the image data has one byte per
- * pixel to select the relevant sample from the color-map.
- */
-
-/* PNG_FORMAT_*
- *
- * #defines to be used in png_image::format. Each #define identifies a
- * particular layout of sample data and, if present, alpha values. There are
- * separate defines for each of the two component encodings.
- *
- * A format is built up using single bit flag values. All combinations are
- * valid. Formats can be built up from the flag values or you can use one of
- * the predefined values below. When testing formats always use the FORMAT_FLAG
- * macros to test for individual features - future versions of the library may
- * add new flags.
- *
- * When reading or writing color-mapped images the format should be set to the
- * format of the entries in the color-map then png_image_{read,write}_colormap
- * called to read or write the color-map and set the format correctly for the
- * image data. Do not set the PNG_FORMAT_FLAG_COLORMAP bit directly!
- *
- * NOTE: libpng can be built with particular features disabled. If you see
- * compiler errors because the definition of one of the following flags has been
- * compiled out it is because libpng does not have the required support. It is
- * possible, however, for the libpng configuration to enable the format on just
- * read or just write; in that case you may see an error at run time. You can
- * guard against this by checking for the definition of the appropriate
- * "_SUPPORTED" macro, one of:
- *
- * PNG_SIMPLIFIED_{READ,WRITE}_{BGR,AFIRST}_SUPPORTED
- */
-#define PNG_FORMAT_FLAG_ALPHA 0x01U /* format with an alpha channel */
-#define PNG_FORMAT_FLAG_COLOR 0x02U /* color format: otherwise grayscale */
-#define PNG_FORMAT_FLAG_LINEAR 0x04U /* 2-byte channels else 1-byte */
-#define PNG_FORMAT_FLAG_COLORMAP 0x08U /* image data is color-mapped */
-
-#ifdef PNG_FORMAT_BGR_SUPPORTED
-# define PNG_FORMAT_FLAG_BGR 0x10U /* BGR colors, else order is RGB */
-#endif
-
-#ifdef PNG_FORMAT_AFIRST_SUPPORTED
-# define PNG_FORMAT_FLAG_AFIRST 0x20U /* alpha channel comes first */
-#endif
-
-#define PNG_FORMAT_FLAG_ASSOCIATED_ALPHA 0x40U /* alpha channel is associated */
-
-/* Commonly used formats have predefined macros.
- *
- * First the single byte (sRGB) formats:
- */
-#define PNG_FORMAT_GRAY 0
-#define PNG_FORMAT_GA PNG_FORMAT_FLAG_ALPHA
-#define PNG_FORMAT_AG (PNG_FORMAT_GA|PNG_FORMAT_FLAG_AFIRST)
-#define PNG_FORMAT_RGB PNG_FORMAT_FLAG_COLOR
-#define PNG_FORMAT_BGR (PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_BGR)
-#define PNG_FORMAT_RGBA (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_ALPHA)
-#define PNG_FORMAT_ARGB (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_AFIRST)
-#define PNG_FORMAT_BGRA (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_ALPHA)
-#define PNG_FORMAT_ABGR (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_AFIRST)
-
-/* Then the linear 2-byte formats. When naming these "Y" is used to
- * indicate a luminance (gray) channel.
- */
-#define PNG_FORMAT_LINEAR_Y PNG_FORMAT_FLAG_LINEAR
-#define PNG_FORMAT_LINEAR_Y_ALPHA (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_ALPHA)
-#define PNG_FORMAT_LINEAR_RGB (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR)
-#define PNG_FORMAT_LINEAR_RGB_ALPHA \
- (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA)
-
-/* With color-mapped formats the image data is one byte for each pixel, the byte
- * is an index into the color-map which is formatted as above. To obtain a
- * color-mapped format it is sufficient just to add the PNG_FOMAT_FLAG_COLORMAP
- * to one of the above definitions, or you can use one of the definitions below.
- */
-#define PNG_FORMAT_RGB_COLORMAP (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_COLORMAP)
-#define PNG_FORMAT_BGR_COLORMAP (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_COLORMAP)
-#define PNG_FORMAT_RGBA_COLORMAP (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_COLORMAP)
-#define PNG_FORMAT_ARGB_COLORMAP (PNG_FORMAT_ARGB|PNG_FORMAT_FLAG_COLORMAP)
-#define PNG_FORMAT_BGRA_COLORMAP (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_COLORMAP)
-#define PNG_FORMAT_ABGR_COLORMAP (PNG_FORMAT_ABGR|PNG_FORMAT_FLAG_COLORMAP)
-
-/* PNG_IMAGE macros
- *
- * These are convenience macros to derive information from a png_image
- * structure. The PNG_IMAGE_SAMPLE_ macros return values appropriate to the
- * actual image sample values - either the entries in the color-map or the
- * pixels in the image. The PNG_IMAGE_PIXEL_ macros return corresponding values
- * for the pixels and will always return 1 for color-mapped formats. The
- * remaining macros return information about the rows in the image and the
- * complete image.
- *
- * NOTE: All the macros that take a png_image::format parameter are compile time
- * constants if the format parameter is, itself, a constant. Therefore these
- * macros can be used in array declarations and case labels where required.
- * Similarly the macros are also pre-processor constants (sizeof is not used) so
- * they can be used in #if tests.
- *
- * First the information about the samples.
- */
-#define PNG_IMAGE_SAMPLE_CHANNELS(fmt)\
- (((fmt)&(PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA))+1)
- /* Return the total number of channels in a given format: 1..4 */
-
-#define PNG_IMAGE_SAMPLE_COMPONENT_SIZE(fmt)\
- ((((fmt) & PNG_FORMAT_FLAG_LINEAR) >> 2)+1)
- /* Return the size in bytes of a single component of a pixel or color-map
- * entry (as appropriate) in the image: 1 or 2.
- */
-
-#define PNG_IMAGE_SAMPLE_SIZE(fmt)\
- (PNG_IMAGE_SAMPLE_CHANNELS(fmt) * PNG_IMAGE_SAMPLE_COMPONENT_SIZE(fmt))
- /* This is the size of the sample data for one sample. If the image is
- * color-mapped it is the size of one color-map entry (and image pixels are
- * one byte in size), otherwise it is the size of one image pixel.
- */
-
-#define PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(fmt)\
- (PNG_IMAGE_SAMPLE_CHANNELS(fmt) * 256)
- /* The maximum size of the color-map required by the format expressed in a
- * count of components. This can be used to compile-time allocate a
- * color-map:
- *
- * png_uint_16 colormap[PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(linear_fmt)];
- *
- * png_byte colormap[PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(sRGB_fmt)];
- *
- * Alternatively use the PNG_IMAGE_COLORMAP_SIZE macro below to use the
- * information from one of the png_image_begin_read_ APIs and dynamically
- * allocate the required memory.
- */
-
-/* Corresponding information about the pixels */
-#define PNG_IMAGE_PIXEL_(test,fmt)\
- (((fmt)&PNG_FORMAT_FLAG_COLORMAP)?1:test(fmt))
-
-#define PNG_IMAGE_PIXEL_CHANNELS(fmt)\
- PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_CHANNELS,fmt)
- /* The number of separate channels (components) in a pixel; 1 for a
- * color-mapped image.
- */
-
-#define PNG_IMAGE_PIXEL_COMPONENT_SIZE(fmt)\
- PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_COMPONENT_SIZE,fmt)
- /* The size, in bytes, of each component in a pixel; 1 for a color-mapped
- * image.
- */
-
-#define PNG_IMAGE_PIXEL_SIZE(fmt) PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_SIZE,fmt)
- /* The size, in bytes, of a complete pixel; 1 for a color-mapped image. */
-
-/* Information about the whole row, or whole image */
-#define PNG_IMAGE_ROW_STRIDE(image)\
- (PNG_IMAGE_PIXEL_CHANNELS((image).format) * (image).width)
- /* Return the total number of components in a single row of the image; this
- * is the minimum 'row stride', the minimum count of components between each
- * row. For a color-mapped image this is the minimum number of bytes in a
- * row.
- *
- * WARNING: this macro overflows for some images with more than one component
- * and very large image widths. libpng will refuse to process an image where
- * this macro would overflow.
- */
-
-#define PNG_IMAGE_BUFFER_SIZE(image, row_stride)\
- (PNG_IMAGE_PIXEL_COMPONENT_SIZE((image).format)*(image).height*(row_stride))
- /* Return the size, in bytes, of an image buffer given a png_image and a row
- * stride - the number of components to leave space for in each row.
- *
- * WARNING: this macro overflows a 32-bit integer for some large PNG images,
- * libpng will refuse to process an image where such an overflow would occur.
- */
-
-#define PNG_IMAGE_SIZE(image)\
- PNG_IMAGE_BUFFER_SIZE(image, PNG_IMAGE_ROW_STRIDE(image))
- /* Return the size, in bytes, of the image in memory given just a png_image;
- * the row stride is the minimum stride required for the image.
- */
-
-#define PNG_IMAGE_COLORMAP_SIZE(image)\
- (PNG_IMAGE_SAMPLE_SIZE((image).format) * (image).colormap_entries)
- /* Return the size, in bytes, of the color-map of this image. If the image
- * format is not a color-map format this will return a size sufficient for
- * 256 entries in the given format; check PNG_FORMAT_FLAG_COLORMAP if
- * you don't want to allocate a color-map in this case.
- */
-
-/* PNG_IMAGE_FLAG_*
- *
- * Flags containing additional information about the image are held in the
- * 'flags' field of png_image.
- */
-#define PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB 0x01
- /* This indicates that the RGB values of the in-memory bitmap do not
- * correspond to the red, green and blue end-points defined by sRGB.
- */
-
-#define PNG_IMAGE_FLAG_FAST 0x02
- /* On write emphasise speed over compression; the resultant PNG file will be
- * larger but will be produced significantly faster, particular for large
- * images. Do not use this option for images which will be distributed, only
- * used it when producing intermediate files that will be read back in
- * repeatedly. For a typical 24-bit image the option will double the read
- * speed at the cost of increasing the image size by 25%, however for many
- * more compressible images the PNG file can be 10 times larger with only a
- * slight speed gain.
- */
-
-#define PNG_IMAGE_FLAG_16BIT_sRGB 0x04
- /* On read if the image is a 16-bit per component image and there is no gAMA
- * or sRGB chunk assume that the components are sRGB encoded. Notice that
- * images output by the simplified API always have gamma information; setting
- * this flag only affects the interpretation of 16-bit images from an
- * external source. It is recommended that the application expose this flag
- * to the user; the user can normally easily recognize the difference between
- * linear and sRGB encoding. This flag has no effect on write - the data
- * passed to the write APIs must have the correct encoding (as defined
- * above.)
- *
- * If the flag is not set (the default) input 16-bit per component data is
- * assumed to be linear.
- *
- * NOTE: the flag can only be set after the png_image_begin_read_ call,
- * because that call initializes the 'flags' field.
- */
-
-#ifdef PNG_SIMPLIFIED_READ_SUPPORTED
-/* READ APIs
- * ---------
- *
- * The png_image passed to the read APIs must have been initialized by setting
- * the png_controlp field 'opaque' to NULL (or, safer, memset the whole thing.)
- */
-#ifdef PNG_STDIO_SUPPORTED
-PNG_EXPORT(234, int, png_image_begin_read_from_file, (png_imagep image,
- const char *file_name));
- /* The named file is opened for read and the image header is filled in
- * from the PNG header in the file.
- */
-
-PNG_EXPORT(235, int, png_image_begin_read_from_stdio, (png_imagep image,
- FILE* file));
- /* The PNG header is read from the stdio FILE object. */
-#endif /* STDIO */
-
-PNG_EXPORT(236, int, png_image_begin_read_from_memory, (png_imagep image,
- png_const_voidp memory, size_t size));
- /* The PNG header is read from the given memory buffer. */
-
-PNG_EXPORT(237, int, png_image_finish_read, (png_imagep image,
- png_const_colorp background, void *buffer, png_int_32 row_stride,
- void *colormap));
- /* Finish reading the image into the supplied buffer and clean up the
- * png_image structure.
- *
- * row_stride is the step, in byte or 2-byte units as appropriate,
- * between adjacent rows. A positive stride indicates that the top-most row
- * is first in the buffer - the normal top-down arrangement. A negative
- * stride indicates that the bottom-most row is first in the buffer.
- *
- * background need only be supplied if an alpha channel must be removed from
- * a png_byte format and the removal is to be done by compositing on a solid
- * color; otherwise it may be NULL and any composition will be done directly
- * onto the buffer. The value is an sRGB color to use for the background,
- * for grayscale output the green channel is used.
- *
- * background must be supplied when an alpha channel must be removed from a
- * single byte color-mapped output format, in other words if:
- *
- * 1) The original format from png_image_begin_read_from_* had
- * PNG_FORMAT_FLAG_ALPHA set.
- * 2) The format set by the application does not.
- * 3) The format set by the application has PNG_FORMAT_FLAG_COLORMAP set and
- * PNG_FORMAT_FLAG_LINEAR *not* set.
- *
- * For linear output removing the alpha channel is always done by compositing
- * on black and background is ignored.
- *
- * colormap must be supplied when PNG_FORMAT_FLAG_COLORMAP is set. It must
- * be at least the size (in bytes) returned by PNG_IMAGE_COLORMAP_SIZE.
- * image->colormap_entries will be updated to the actual number of entries
- * written to the colormap; this may be less than the original value.
- */
-
-PNG_EXPORT(238, void, png_image_free, (png_imagep image));
- /* Free any data allocated by libpng in image->opaque, setting the pointer to
- * NULL. May be called at any time after the structure is initialized.
- */
-#endif /* SIMPLIFIED_READ */
-
-#ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED
-/* WRITE APIS
- * ----------
- * For write you must initialize a png_image structure to describe the image to
- * be written. To do this use memset to set the whole structure to 0 then
- * initialize fields describing your image.
- *
- * version: must be set to PNG_IMAGE_VERSION
- * opaque: must be initialized to NULL
- * width: image width in pixels
- * height: image height in rows
- * format: the format of the data (image and color-map) you wish to write
- * flags: set to 0 unless one of the defined flags applies; set
- * PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB for color format images where the RGB
- * values do not correspond to the colors in sRGB.
- * colormap_entries: set to the number of entries in the color-map (0 to 256)
- */
-#ifdef PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED
-PNG_EXPORT(239, int, png_image_write_to_file, (png_imagep image,
- const char *file, int convert_to_8bit, const void *buffer,
- png_int_32 row_stride, const void *colormap));
- /* Write the image to the named file. */
-
-PNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file,
- int convert_to_8_bit, const void *buffer, png_int_32 row_stride,
- const void *colormap));
- /* Write the image to the given (FILE*). */
-#endif /* SIMPLIFIED_WRITE_STDIO */
-
-/* With all write APIs if image is in one of the linear formats with 16-bit
- * data then setting convert_to_8_bit will cause the output to be an 8-bit PNG
- * gamma encoded according to the sRGB specification, otherwise a 16-bit linear
- * encoded PNG file is written.
- *
- * With color-mapped data formats the colormap parameter point to a color-map
- * with at least image->colormap_entries encoded in the specified format. If
- * the format is linear the written PNG color-map will be converted to sRGB
- * regardless of the convert_to_8_bit flag.
- *
- * With all APIs row_stride is handled as in the read APIs - it is the spacing
- * from one row to the next in component sized units (1 or 2 bytes) and if
- * negative indicates a bottom-up row layout in the buffer. If row_stride is
- * zero, libpng will calculate it for you from the image width and number of
- * channels.
- *
- * Note that the write API does not support interlacing, sub-8-bit pixels or
- * most ancillary chunks. If you need to write text chunks (e.g. for copyright
- * notices) you need to use one of the other APIs.
- */
-
-PNG_EXPORT(245, int, png_image_write_to_memory, (png_imagep image, void *memory,
- png_alloc_size_t * PNG_RESTRICT memory_bytes, int convert_to_8_bit,
- const void *buffer, png_int_32 row_stride, const void *colormap));
- /* Write the image to the given memory buffer. The function both writes the
- * whole PNG data stream to *memory and updates *memory_bytes with the count
- * of bytes written.
- *
- * 'memory' may be NULL. In this case *memory_bytes is not read however on
- * success the number of bytes which would have been written will still be
- * stored in *memory_bytes. On failure *memory_bytes will contain 0.
- *
- * If 'memory' is not NULL it must point to memory[*memory_bytes] of
- * writeable memory.
- *
- * If the function returns success memory[*memory_bytes] (if 'memory' is not
- * NULL) contains the written PNG data. *memory_bytes will always be less
- * than or equal to the original value.
- *
- * If the function returns false and *memory_bytes was not changed an error
- * occurred during write. If *memory_bytes was changed, or is not 0 if
- * 'memory' was NULL, the write would have succeeded but for the memory
- * buffer being too small. *memory_bytes contains the required number of
- * bytes and will be bigger that the original value.
- */
-
-#define png_image_write_get_memory_size(image, size, convert_to_8_bit, buffer,\
- row_stride, colormap)\
- png_image_write_to_memory(&(image), 0, &(size), convert_to_8_bit, buffer,\
- row_stride, colormap)
- /* Return the amount of memory in 'size' required to compress this image.
- * The png_image structure 'image' must be filled in as in the above
- * function and must not be changed before the actual write call, the buffer
- * and all other parameters must also be identical to that in the final
- * write call. The 'size' variable need not be initialized.
- *
- * NOTE: the macro returns true/false, if false is returned 'size' will be
- * set to zero and the write failed and probably will fail if tried again.
- */
-
-/* You can pre-allocate the buffer by making sure it is of sufficient size
- * regardless of the amount of compression achieved. The buffer size will
- * always be bigger than the original image and it will never be filled. The
- * following macros are provided to assist in allocating the buffer.
- */
-#define PNG_IMAGE_DATA_SIZE(image) (PNG_IMAGE_SIZE(image)+(image).height)
- /* The number of uncompressed bytes in the PNG byte encoding of the image;
- * uncompressing the PNG IDAT data will give this number of bytes.
- *
- * NOTE: while PNG_IMAGE_SIZE cannot overflow for an image in memory this
- * macro can because of the extra bytes used in the PNG byte encoding. You
- * need to avoid this macro if your image size approaches 2^30 in width or
- * height. The same goes for the remainder of these macros; they all produce
- * bigger numbers than the actual in-memory image size.
- */
-#ifndef PNG_ZLIB_MAX_SIZE
-# define PNG_ZLIB_MAX_SIZE(b) ((b)+(((b)+7U)>>3)+(((b)+63U)>>6)+11U)
- /* An upper bound on the number of compressed bytes given 'b' uncompressed
- * bytes. This is based on deflateBounds() in zlib; different
- * implementations of zlib compression may conceivably produce more data so
- * if your zlib implementation is not zlib itself redefine this macro
- * appropriately.
- */
-#endif
-
-#define PNG_IMAGE_COMPRESSED_SIZE_MAX(image)\
- PNG_ZLIB_MAX_SIZE((png_alloc_size_t)PNG_IMAGE_DATA_SIZE(image))
- /* An upper bound on the size of the data in the PNG IDAT chunks. */
-
-#define PNG_IMAGE_PNG_SIZE_MAX_(image, image_size)\
- ((8U/*sig*/+25U/*IHDR*/+16U/*gAMA*/+44U/*cHRM*/+12U/*IEND*/+\
- (((image).format&PNG_FORMAT_FLAG_COLORMAP)?/*colormap: PLTE, tRNS*/\
- 12U+3U*(image).colormap_entries/*PLTE data*/+\
- (((image).format&PNG_FORMAT_FLAG_ALPHA)?\
- 12U/*tRNS*/+(image).colormap_entries:0U):0U)+\
- 12U)+(12U*((image_size)/PNG_ZBUF_SIZE))/*IDAT*/+(image_size))
- /* A helper for the following macro; if your compiler cannot handle the
- * following macro use this one with the result of
- * PNG_IMAGE_COMPRESSED_SIZE_MAX(image) as the second argument (most
- * compilers should handle this just fine.)
- */
-
-#define PNG_IMAGE_PNG_SIZE_MAX(image)\
- PNG_IMAGE_PNG_SIZE_MAX_(image, PNG_IMAGE_COMPRESSED_SIZE_MAX(image))
- /* An upper bound on the total length of the PNG data stream for 'image'.
- * The result is of type png_alloc_size_t, on 32-bit systems this may
- * overflow even though PNG_IMAGE_DATA_SIZE does not overflow; the write will
- * run out of buffer space but return a corrected size which should work.
- */
-#endif /* SIMPLIFIED_WRITE */
-/*******************************************************************************
- * END OF SIMPLIFIED API
- ******************************************************************************/
-#endif /* SIMPLIFIED_{READ|WRITE} */
-
-/*******************************************************************************
- * Section 6: IMPLEMENTATION OPTIONS
- *******************************************************************************
- *
- * Support for arbitrary implementation-specific optimizations. The API allows
- * particular options to be turned on or off. 'Option' is the number of the
- * option and 'onoff' is 0 (off) or non-0 (on). The value returned is given
- * by the PNG_OPTION_ defines below.
- *
- * HARDWARE: normally hardware capabilities, such as the Intel SSE instructions,
- * are detected at run time, however sometimes it may be impossible
- * to do this in user mode, in which case it is necessary to discover
- * the capabilities in an OS specific way. Such capabilities are
- * listed here when libpng has support for them and must be turned
- * ON by the application if present.
- *
- * SOFTWARE: sometimes software optimizations actually result in performance
- * decrease on some architectures or systems, or with some sets of
- * PNG images. 'Software' options allow such optimizations to be
- * selected at run time.
- */
-#ifdef PNG_SET_OPTION_SUPPORTED
-#ifdef PNG_ARM_NEON_API_SUPPORTED
-# define PNG_ARM_NEON 0 /* HARDWARE: ARM Neon SIMD instructions supported */
-#endif
-#define PNG_MAXIMUM_INFLATE_WINDOW 2 /* SOFTWARE: force maximum window */
-#define PNG_SKIP_sRGB_CHECK_PROFILE 4 /* SOFTWARE: Check ICC profile for sRGB */
-#ifdef PNG_MIPS_MSA_API_SUPPORTED
-# define PNG_MIPS_MSA 6 /* HARDWARE: MIPS Msa SIMD instructions supported */
-#endif
-#ifdef PNG_DISABLE_ADLER32_CHECK_SUPPORTED
-# define PNG_IGNORE_ADLER32 8 /* SOFTWARE: disable Adler32 check on IDAT */
-#endif
-#ifdef PNG_POWERPC_VSX_API_SUPPORTED
-# define PNG_POWERPC_VSX 10 /* HARDWARE: PowerPC VSX SIMD instructions
- * supported */
-#endif
-#ifdef PNG_MIPS_MMI_API_SUPPORTED
-# define PNG_MIPS_MMI 12 /* HARDWARE: MIPS MMI SIMD instructions supported */
-#endif
-
-#define PNG_OPTION_NEXT 14 /* Next option - numbers must be even */
-
-/* Return values: NOTE: there are four values and 'off' is *not* zero */
-#define PNG_OPTION_UNSET 0 /* Unset - defaults to off */
-#define PNG_OPTION_INVALID 1 /* Option number out of range */
-#define PNG_OPTION_OFF 2
-#define PNG_OPTION_ON 3
-
-PNG_EXPORT(244, int, png_set_option, (png_structrp png_ptr, int option,
- int onoff));
-#endif /* SET_OPTION */
-
-/*******************************************************************************
- * END OF HARDWARE AND SOFTWARE OPTIONS
- ******************************************************************************/
-
-#ifdef PNG_APNG_SUPPORTED
-PNG_EXPORT(260, png_uint_32, png_get_acTL, (png_structp png_ptr,
- png_infop info_ptr, png_uint_32 *num_frames, png_uint_32 *num_plays));
-
-PNG_EXPORT(261, png_uint_32, png_set_acTL, (png_structp png_ptr,
- png_infop info_ptr, png_uint_32 num_frames, png_uint_32 num_plays));
-
-PNG_EXPORT(262, png_uint_32, png_get_num_frames, (png_structp png_ptr,
- png_infop info_ptr));
-
-PNG_EXPORT(263, png_uint_32, png_get_num_plays, (png_structp png_ptr,
- png_infop info_ptr));
-
-PNG_EXPORT(264, png_uint_32, png_get_next_frame_fcTL,
- (png_structp png_ptr, png_infop info_ptr, png_uint_32 *width,
- png_uint_32 *height, png_uint_32 *x_offset, png_uint_32 *y_offset,
- png_uint_16 *delay_num, png_uint_16 *delay_den, png_byte *dispose_op,
- png_byte *blend_op));
-
-PNG_EXPORT(265, png_uint_32, png_set_next_frame_fcTL,
- (png_structp png_ptr, png_infop info_ptr, png_uint_32 width,
- png_uint_32 height, png_uint_32 x_offset, png_uint_32 y_offset,
- png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op,
- png_byte blend_op));
-
-PNG_EXPORT(266, png_uint_32, png_get_next_frame_width,
- (png_structp png_ptr, png_infop info_ptr));
-PNG_EXPORT(267, png_uint_32, png_get_next_frame_height,
- (png_structp png_ptr, png_infop info_ptr));
-PNG_EXPORT(268, png_uint_32, png_get_next_frame_x_offset,
- (png_structp png_ptr, png_infop info_ptr));
-PNG_EXPORT(269, png_uint_32, png_get_next_frame_y_offset,
- (png_structp png_ptr, png_infop info_ptr));
-PNG_EXPORT(270, png_uint_16, png_get_next_frame_delay_num,
- (png_structp png_ptr, png_infop info_ptr));
-PNG_EXPORT(271, png_uint_16, png_get_next_frame_delay_den,
- (png_structp png_ptr, png_infop info_ptr));
-PNG_EXPORT(272, png_byte, png_get_next_frame_dispose_op,
- (png_structp png_ptr, png_infop info_ptr));
-PNG_EXPORT(273, png_byte, png_get_next_frame_blend_op,
- (png_structp png_ptr, png_infop info_ptr));
-PNG_EXPORT(274, png_byte, png_get_first_frame_is_hidden,
- (png_structp png_ptr, png_infop info_ptr));
-PNG_EXPORT(275, png_uint_32, png_set_first_frame_is_hidden,
- (png_structp png_ptr, png_infop info_ptr, png_byte is_hidden));
-
-#ifdef PNG_READ_APNG_SUPPORTED
-PNG_EXPORT(276, void, png_read_frame_head, (png_structp png_ptr,
- png_infop info_ptr));
-#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
-PNG_EXPORT(277, void, png_set_progressive_frame_fn, (png_structp png_ptr,
- png_progressive_frame_ptr frame_info_fn,
- png_progressive_frame_ptr frame_end_fn));
-#endif /* PROGRESSIVE_READ */
-#endif /* READ_APNG */
-
-#ifdef PNG_WRITE_APNG_SUPPORTED
-PNG_EXPORT(278, void, png_write_frame_head, (png_structp png_ptr,
- png_infop info_ptr, png_bytepp row_pointers,
- png_uint_32 width, png_uint_32 height,
- png_uint_32 x_offset, png_uint_32 y_offset,
- png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op,
- png_byte blend_op));
-
-PNG_EXPORT(279, void, png_write_frame_tail, (png_structp png_ptr,
- png_infop info_ptr));
-#endif /* WRITE_APNG */
-#endif /* APNG */
-
-/* Maintainer: Put new public prototypes here ^, in libpng.3, in project
- * defs, and in scripts/symbols.def.
- */
-
-/* The last ordinal number (this is the *last* one already used; the next
- * one to use is one more than this.)
- */
-#ifdef PNG_EXPORT_LAST_ORDINAL
-#ifdef PNG_APNG_SUPPORTED
- PNG_EXPORT_LAST_ORDINAL(279);
-#else
- PNG_EXPORT_LAST_ORDINAL(259);
-#endif /* APNG */
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* PNG_VERSION_INFO_ONLY */
-/* Do not put anything past this line */
-#endif /* PNG_H */
diff --git a/contrib/libs/libpng/pngconf.h b/contrib/libs/libpng/pngconf.h
deleted file mode 100644
index 6bc46bcfc9..0000000000
--- a/contrib/libs/libpng/pngconf.h
+++ /dev/null
@@ -1,622 +0,0 @@
-/* pngconf.h - machine-configurable file for libpng
- *
- * libpng version 1.6.46
- *
- * Copyright (c) 2018-2025 Cosmin Truta
- * Copyright (c) 1998-2002,2004,2006-2016,2018 Glenn Randers-Pehrson
- * Copyright (c) 1996-1997 Andreas Dilger
- * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
- *
- * This code is released under the libpng license.
- * For conditions of distribution and use, see the disclaimer
- * and license in png.h
- *
- * Any machine specific code is near the front of this file, so if you
- * are configuring libpng for a machine, you may want to read the section
- * starting here down to where it starts to typedef png_color, png_text,
- * and png_info.
- */
-
-#ifndef PNGCONF_H
-#define PNGCONF_H
-
-#ifndef PNG_BUILDING_SYMBOL_TABLE /* else includes may cause problems */
-
-/* From libpng 1.6.0 libpng requires an ANSI X3.159-1989 ("ISOC90") compliant C
- * compiler for correct compilation. The following header files are required by
- * the standard. If your compiler doesn't provide these header files, or they
- * do not match the standard, you will need to provide/improve them.
- */
-#include <limits.h>
-#include <stddef.h>
-
-/* Library header files. These header files are all defined by ISOC90; libpng
- * expects conformant implementations, however, an ISOC90 conformant system need
- * not provide these header files if the functionality cannot be implemented.
- * In this case it will be necessary to disable the relevant parts of libpng in
- * the build of pnglibconf.h.
- *
- * Prior to 1.6.0 string.h was included here; the API changes in 1.6.0 to not
- * include this unnecessary header file.
- */
-
-#ifdef PNG_STDIO_SUPPORTED
- /* Required for the definition of FILE: */
-# include <stdio.h>
-#endif
-
-#ifdef PNG_SETJMP_SUPPORTED
- /* Required for the definition of jmp_buf and the declaration of longjmp: */
-# include <setjmp.h>
-#endif
-
-#ifdef PNG_CONVERT_tIME_SUPPORTED
- /* Required for struct tm: */
-# include <time.h>
-#endif
-
-#endif /* PNG_BUILDING_SYMBOL_TABLE */
-
-/* Prior to 1.6.0, it was possible to turn off 'const' in declarations,
- * using PNG_NO_CONST. This is no longer supported.
- */
-#define PNG_CONST const /* backward compatibility only */
-
-/* This controls optimization of the reading of 16-bit and 32-bit
- * values from PNG files. It can be set on a per-app-file basis: it
- * just changes whether a macro is used when the function is called.
- * The library builder sets the default; if read functions are not
- * built into the library the macro implementation is forced on.
- */
-#ifndef PNG_READ_INT_FUNCTIONS_SUPPORTED
-# define PNG_USE_READ_MACROS
-#endif
-#if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS)
-# if PNG_DEFAULT_READ_MACROS
-# define PNG_USE_READ_MACROS
-# endif
-#endif
-
-/* COMPILER SPECIFIC OPTIONS.
- *
- * These options are provided so that a variety of difficult compilers
- * can be used. Some are fixed at build time (e.g. PNG_API_RULE
- * below) but still have compiler specific implementations, others
- * may be changed on a per-file basis when compiling against libpng.
- */
-
-/* The PNGARG macro was used in versions of libpng prior to 1.6.0 to protect
- * against legacy (pre ISOC90) compilers that did not understand function
- * prototypes. [Deprecated.]
- */
-#ifndef PNGARG
-# define PNGARG(arglist) arglist
-#endif
-
-/* Function calling conventions.
- * =============================
- * Normally it is not necessary to specify to the compiler how to call
- * a function - it just does it - however on x86 systems derived from
- * Microsoft and Borland C compilers ('IBM PC', 'DOS', 'Windows' systems
- * and some others) there are multiple ways to call a function and the
- * default can be changed on the compiler command line. For this reason
- * libpng specifies the calling convention of every exported function and
- * every function called via a user supplied function pointer. This is
- * done in this file by defining the following macros:
- *
- * PNGAPI Calling convention for exported functions.
- * PNGCBAPI Calling convention for user provided (callback) functions.
- * PNGCAPI Calling convention used by the ANSI-C library (required
- * for longjmp callbacks and sometimes used internally to
- * specify the calling convention for zlib).
- *
- * These macros should never be overridden. If it is necessary to
- * change calling convention in a private build this can be done
- * by setting PNG_API_RULE (which defaults to 0) to one of the values
- * below to select the correct 'API' variants.
- *
- * PNG_API_RULE=0 Use PNGCAPI - the 'C' calling convention - throughout.
- * This is correct in every known environment.
- * PNG_API_RULE=1 Use the operating system convention for PNGAPI and
- * the 'C' calling convention (from PNGCAPI) for
- * callbacks (PNGCBAPI). This is no longer required
- * in any known environment - if it has to be used
- * please post an explanation of the problem to the
- * libpng mailing list.
- *
- * These cases only differ if the operating system does not use the C
- * calling convention, at present this just means the above cases
- * (x86 DOS/Windows systems) and, even then, this does not apply to
- * Cygwin running on those systems.
- *
- * Note that the value must be defined in pnglibconf.h so that what
- * the application uses to call the library matches the conventions
- * set when building the library.
- */
-
-/* Symbol export
- * =============
- * When building a shared library it is almost always necessary to tell
- * the compiler which symbols to export. The png.h macro 'PNG_EXPORT'
- * is used to mark the symbols. On some systems these symbols can be
- * extracted at link time and need no special processing by the compiler,
- * on other systems the symbols are flagged by the compiler and just
- * the declaration requires a special tag applied (unfortunately) in a
- * compiler dependent way. Some systems can do either.
- *
- * A small number of older systems also require a symbol from a DLL to
- * be flagged to the program that calls it. This is a problem because
- * we do not know in the header file included by application code that
- * the symbol will come from a shared library, as opposed to a statically
- * linked one. For this reason the application must tell us by setting
- * the magic flag PNG_USE_DLL to turn on the special processing before
- * it includes png.h.
- *
- * Four additional macros are used to make this happen:
- *
- * PNG_IMPEXP The magic (if any) to cause a symbol to be exported from
- * the build or imported if PNG_USE_DLL is set - compiler
- * and system specific.
- *
- * PNG_EXPORT_TYPE(type) A macro that pre or appends PNG_IMPEXP to
- * 'type', compiler specific.
- *
- * PNG_DLL_EXPORT Set to the magic to use during a libpng build to
- * make a symbol exported from the DLL. Not used in the
- * public header files; see pngpriv.h for how it is used
- * in the libpng build.
- *
- * PNG_DLL_IMPORT Set to the magic to force the libpng symbols to come
- * from a DLL - used to define PNG_IMPEXP when
- * PNG_USE_DLL is set.
- */
-
-/* System specific discovery.
- * ==========================
- * This code is used at build time to find PNG_IMPEXP, the API settings
- * and PNG_EXPORT_TYPE(), it may also set a macro to indicate the DLL
- * import processing is possible. On Windows systems it also sets
- * compiler-specific macros to the values required to change the calling
- * conventions of the various functions.
- */
-#if defined(_WIN32) || defined(__WIN32__) || defined(__NT__) || \
- defined(__CYGWIN__)
- /* Windows system (DOS doesn't support DLLs). Includes builds under Cygwin or
- * MinGW on any architecture currently supported by Windows. Also includes
- * Watcom builds but these need special treatment because they are not
- * compatible with GCC or Visual C because of different calling conventions.
- */
-# if PNG_API_RULE == 2
- /* If this line results in an error, either because __watcall is not
- * understood or because of a redefine just below you cannot use *this*
- * build of the library with the compiler you are using. *This* build was
- * build using Watcom and applications must also be built using Watcom!
- */
-# define PNGCAPI __watcall
-# endif
-
-# if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 800))
-# define PNGCAPI __cdecl
-# if PNG_API_RULE == 1
- /* If this line results in an error __stdcall is not understood and
- * PNG_API_RULE should not have been set to '1'.
- */
-# define PNGAPI __stdcall
-# endif
-# else
- /* An older compiler, or one not detected (erroneously) above,
- * if necessary override on the command line to get the correct
- * variants for the compiler.
- */
-# ifndef PNGCAPI
-# define PNGCAPI _cdecl
-# endif
-# if PNG_API_RULE == 1 && !defined(PNGAPI)
-# define PNGAPI _stdcall
-# endif
-# endif /* compiler/api */
-
- /* NOTE: PNGCBAPI always defaults to PNGCAPI. */
-
-# if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD)
-# error "PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed"
-# endif
-
-# if (defined(_MSC_VER) && _MSC_VER < 800) ||\
- (defined(__BORLANDC__) && __BORLANDC__ < 0x500)
- /* older Borland and MSC
- * compilers used '__export' and required this to be after
- * the type.
- */
-# ifndef PNG_EXPORT_TYPE
-# define PNG_EXPORT_TYPE(type) type PNG_IMPEXP
-# endif
-# define PNG_DLL_EXPORT __export
-# else /* newer compiler */
-# define PNG_DLL_EXPORT __declspec(dllexport)
-# ifndef PNG_DLL_IMPORT
-# define PNG_DLL_IMPORT __declspec(dllimport)
-# endif
-# endif /* compiler */
-
-#else /* !Windows */
-# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)
-# define PNGAPI _System
-# else /* !Windows/x86 && !OS/2 */
- /* Use the defaults, or define PNG*API on the command line (but
- * this will have to be done for every compile!)
- */
-# endif /* other system, !OS/2 */
-#endif /* !Windows/x86 */
-
-/* Now do all the defaulting . */
-#ifndef PNGCAPI
-# define PNGCAPI
-#endif
-#ifndef PNGCBAPI
-# define PNGCBAPI PNGCAPI
-#endif
-#ifndef PNGAPI
-# define PNGAPI PNGCAPI
-#endif
-
-/* PNG_IMPEXP may be set on the compilation system command line or (if not set)
- * then in an internal header file when building the library, otherwise (when
- * using the library) it is set here.
- */
-#ifndef PNG_IMPEXP
-# if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT)
- /* This forces use of a DLL, disallowing static linking */
-# define PNG_IMPEXP PNG_DLL_IMPORT
-# endif
-
-# ifndef PNG_IMPEXP
-# define PNG_IMPEXP
-# endif
-#endif
-
-/* In 1.5.2 the definition of PNG_FUNCTION has been changed to always treat
- * 'attributes' as a storage class - the attributes go at the start of the
- * function definition, and attributes are always appended regardless of the
- * compiler. This considerably simplifies these macros but may cause problems
- * if any compilers both need function attributes and fail to handle them as
- * a storage class (this is unlikely.)
- */
-#ifndef PNG_FUNCTION
-# define PNG_FUNCTION(type, name, args, attributes) attributes type name args
-#endif
-
-#ifndef PNG_EXPORT_TYPE
-# define PNG_EXPORT_TYPE(type) PNG_IMPEXP type
-#endif
-
- /* The ordinal value is only relevant when preprocessing png.h for symbol
- * table entries, so we discard it here. See the .dfn files in the
- * scripts directory.
- */
-
-#ifndef PNG_EXPORTA
-# define PNG_EXPORTA(ordinal, type, name, args, attributes) \
- PNG_FUNCTION(PNG_EXPORT_TYPE(type), (PNGAPI name), args, \
- PNG_LINKAGE_API attributes)
-#endif
-
-/* ANSI-C (C90) does not permit a macro to be invoked with an empty argument,
- * so make something non-empty to satisfy the requirement:
- */
-#define PNG_EMPTY /*empty list*/
-
-#define PNG_EXPORT(ordinal, type, name, args) \
- PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY)
-
-/* Use PNG_REMOVED to comment out a removed interface. */
-#ifndef PNG_REMOVED
-# define PNG_REMOVED(ordinal, type, name, args, attributes)
-#endif
-
-#ifndef PNG_CALLBACK
-# define PNG_CALLBACK(type, name, args) type (PNGCBAPI name) args
-#endif
-
-/* Support for compiler specific function attributes. These are used
- * so that where compiler support is available incorrect use of API
- * functions in png.h will generate compiler warnings.
- *
- * Added at libpng-1.2.41.
- */
-
-#ifndef PNG_NO_PEDANTIC_WARNINGS
-# ifndef PNG_PEDANTIC_WARNINGS_SUPPORTED
-# define PNG_PEDANTIC_WARNINGS_SUPPORTED
-# endif
-#endif
-
-#ifdef PNG_PEDANTIC_WARNINGS_SUPPORTED
- /* Support for compiler specific function attributes. These are used
- * so that where compiler support is available, incorrect use of API
- * functions in png.h will generate compiler warnings. Added at libpng
- * version 1.2.41. Disabling these removes the warnings but may also produce
- * less efficient code.
- */
-# if defined(__clang__) && defined(__has_attribute)
- /* Clang defines both __clang__ and __GNUC__. Check __clang__ first. */
-# if !defined(PNG_USE_RESULT) && __has_attribute(__warn_unused_result__)
-# define PNG_USE_RESULT __attribute__((__warn_unused_result__))
-# endif
-# if !defined(PNG_NORETURN) && __has_attribute(__noreturn__)
-# define PNG_NORETURN __attribute__((__noreturn__))
-# endif
-# if !defined(PNG_ALLOCATED) && __has_attribute(__malloc__)
-# define PNG_ALLOCATED __attribute__((__malloc__))
-# endif
-# if !defined(PNG_DEPRECATED) && __has_attribute(__deprecated__)
-# define PNG_DEPRECATED __attribute__((__deprecated__))
-# endif
-# if !defined(PNG_PRIVATE)
-# ifdef __has_extension
-# if __has_extension(attribute_unavailable_with_message)
-# define PNG_PRIVATE __attribute__((__unavailable__(\
- "This function is not exported by libpng.")))
-# endif
-# endif
-# endif
-# ifndef PNG_RESTRICT
-# define PNG_RESTRICT __restrict
-# endif
-
-# elif defined(__GNUC__)
-# ifndef PNG_USE_RESULT
-# define PNG_USE_RESULT __attribute__((__warn_unused_result__))
-# endif
-# ifndef PNG_NORETURN
-# define PNG_NORETURN __attribute__((__noreturn__))
-# endif
-# if __GNUC__ >= 3
-# ifndef PNG_ALLOCATED
-# define PNG_ALLOCATED __attribute__((__malloc__))
-# endif
-# ifndef PNG_DEPRECATED
-# define PNG_DEPRECATED __attribute__((__deprecated__))
-# endif
-# ifndef PNG_PRIVATE
-# if 0 /* Doesn't work so we use deprecated instead*/
-# define PNG_PRIVATE \
- __attribute__((warning("This function is not exported by libpng.")))
-# else
-# define PNG_PRIVATE \
- __attribute__((__deprecated__))
-# endif
-# endif
-# if ((__GNUC__ > 3) || !defined(__GNUC_MINOR__) || (__GNUC_MINOR__ >= 1))
-# ifndef PNG_RESTRICT
-# define PNG_RESTRICT __restrict
-# endif
-# endif /* __GNUC__.__GNUC_MINOR__ > 3.0 */
-# endif /* __GNUC__ >= 3 */
-
-# elif defined(_MSC_VER) && (_MSC_VER >= 1300)
-# ifndef PNG_USE_RESULT
-# define PNG_USE_RESULT /* not supported */
-# endif
-# ifndef PNG_NORETURN
-# define PNG_NORETURN __declspec(noreturn)
-# endif
-# ifndef PNG_ALLOCATED
-# if (_MSC_VER >= 1400)
-# define PNG_ALLOCATED __declspec(restrict)
-# endif
-# endif
-# ifndef PNG_DEPRECATED
-# define PNG_DEPRECATED __declspec(deprecated)
-# endif
-# ifndef PNG_PRIVATE
-# define PNG_PRIVATE __declspec(deprecated)
-# endif
-# ifndef PNG_RESTRICT
-# if (_MSC_VER >= 1400)
-# define PNG_RESTRICT __restrict
-# endif
-# endif
-
-# elif defined(__WATCOMC__)
-# ifndef PNG_RESTRICT
-# define PNG_RESTRICT __restrict
-# endif
-# endif
-#endif /* PNG_PEDANTIC_WARNINGS */
-
-#ifndef PNG_DEPRECATED
-# define PNG_DEPRECATED /* Use of this function is deprecated */
-#endif
-#ifndef PNG_USE_RESULT
-# define PNG_USE_RESULT /* The result of this function must be checked */
-#endif
-#ifndef PNG_NORETURN
-# define PNG_NORETURN /* This function does not return */
-#endif
-#ifndef PNG_ALLOCATED
-# define PNG_ALLOCATED /* The result of the function is new memory */
-#endif
-#ifndef PNG_PRIVATE
-# define PNG_PRIVATE /* This is a private libpng function */
-#endif
-#ifndef PNG_RESTRICT
-# define PNG_RESTRICT /* The C99 "restrict" feature */
-#endif
-
-#ifndef PNG_FP_EXPORT /* A floating point API. */
-# ifdef PNG_FLOATING_POINT_SUPPORTED
-# define PNG_FP_EXPORT(ordinal, type, name, args)\
- PNG_EXPORT(ordinal, type, name, args);
-# else /* No floating point APIs */
-# define PNG_FP_EXPORT(ordinal, type, name, args)
-# endif
-#endif
-#ifndef PNG_FIXED_EXPORT /* A fixed point API. */
-# ifdef PNG_FIXED_POINT_SUPPORTED
-# define PNG_FIXED_EXPORT(ordinal, type, name, args)\
- PNG_EXPORT(ordinal, type, name, args);
-# else /* No fixed point APIs */
-# define PNG_FIXED_EXPORT(ordinal, type, name, args)
-# endif
-#endif
-
-#ifndef PNG_BUILDING_SYMBOL_TABLE
-/* Some typedefs to get us started. These should be safe on most of the common
- * platforms.
- *
- * png_uint_32 and png_int_32 may, currently, be larger than required to hold a
- * 32-bit value however this is not normally advisable.
- *
- * png_uint_16 and png_int_16 should always be two bytes in size - this is
- * verified at library build time.
- *
- * png_byte must always be one byte in size.
- *
- * The checks below use constants from limits.h, as defined by the ISOC90
- * standard.
- */
-#if CHAR_BIT == 8 && UCHAR_MAX == 255
- typedef unsigned char png_byte;
-#else
-# error "libpng requires 8-bit bytes"
-#endif
-
-#if INT_MIN == -32768 && INT_MAX == 32767
- typedef int png_int_16;
-#elif SHRT_MIN == -32768 && SHRT_MAX == 32767
- typedef short png_int_16;
-#else
-# error "libpng requires a signed 16-bit type"
-#endif
-
-#if UINT_MAX == 65535
- typedef unsigned int png_uint_16;
-#elif USHRT_MAX == 65535
- typedef unsigned short png_uint_16;
-#else
-# error "libpng requires an unsigned 16-bit type"
-#endif
-
-#if INT_MIN < -2147483646 && INT_MAX > 2147483646
- typedef int png_int_32;
-#elif LONG_MIN < -2147483646 && LONG_MAX > 2147483646
- typedef long int png_int_32;
-#else
-# error "libpng requires a signed 32-bit (or more) type"
-#endif
-
-#if UINT_MAX > 4294967294U
- typedef unsigned int png_uint_32;
-#elif ULONG_MAX > 4294967294U
- typedef unsigned long int png_uint_32;
-#else
-# error "libpng requires an unsigned 32-bit (or more) type"
-#endif
-
-/* Prior to 1.6.0, it was possible to disable the use of size_t and ptrdiff_t.
- * From 1.6.0 onwards, an ISO C90 compiler, as well as a standard-compliant
- * behavior of sizeof and ptrdiff_t are required.
- * The legacy typedefs are provided here for backwards compatibility.
- */
-typedef size_t png_size_t;
-typedef ptrdiff_t png_ptrdiff_t;
-
-/* libpng needs to know the maximum value of 'size_t' and this controls the
- * definition of png_alloc_size_t, below. This maximum value of size_t limits
- * but does not control the maximum allocations the library makes - there is
- * direct application control of this through png_set_user_limits().
- */
-#ifndef PNG_SMALL_SIZE_T
- /* Compiler specific tests for systems where size_t is known to be less than
- * 32 bits (some of these systems may no longer work because of the lack of
- * 'far' support; see above.)
- */
-# if (defined(__TURBOC__) && !defined(__FLAT__)) ||\
- (defined(_MSC_VER) && defined(MAXSEG_64K))
-# define PNG_SMALL_SIZE_T
-# endif
-#endif
-
-/* png_alloc_size_t is guaranteed to be no smaller than size_t, and no smaller
- * than png_uint_32. Casts from size_t or png_uint_32 to png_alloc_size_t are
- * not necessary; in fact, it is recommended not to use them at all, so that
- * the compiler can complain when something turns out to be problematic.
- *
- * Casts in the other direction (from png_alloc_size_t to size_t or
- * png_uint_32) should be explicitly applied; however, we do not expect to
- * encounter practical situations that require such conversions.
- *
- * PNG_SMALL_SIZE_T must be defined if the maximum value of size_t is less than
- * 4294967295 - i.e. less than the maximum value of png_uint_32.
- */
-#ifdef PNG_SMALL_SIZE_T
- typedef png_uint_32 png_alloc_size_t;
-#else
- typedef size_t png_alloc_size_t;
-#endif
-
-/* Prior to 1.6.0 libpng offered limited support for Microsoft C compiler
- * implementations of Intel CPU specific support of user-mode segmented address
- * spaces, where 16-bit pointers address more than 65536 bytes of memory using
- * separate 'segment' registers. The implementation requires two different
- * types of pointer (only one of which includes the segment value.)
- *
- * If required this support is available in version 1.2 of libpng and may be
- * available in versions through 1.5, although the correctness of the code has
- * not been verified recently.
- */
-
-/* Typedef for floating-point numbers that are converted to fixed-point with a
- * multiple of 100,000, e.g., gamma
- */
-typedef png_int_32 png_fixed_point;
-
-/* Add typedefs for pointers */
-typedef void * png_voidp;
-typedef const void * png_const_voidp;
-typedef png_byte * png_bytep;
-typedef const png_byte * png_const_bytep;
-typedef png_uint_32 * png_uint_32p;
-typedef const png_uint_32 * png_const_uint_32p;
-typedef png_int_32 * png_int_32p;
-typedef const png_int_32 * png_const_int_32p;
-typedef png_uint_16 * png_uint_16p;
-typedef const png_uint_16 * png_const_uint_16p;
-typedef png_int_16 * png_int_16p;
-typedef const png_int_16 * png_const_int_16p;
-typedef char * png_charp;
-typedef const char * png_const_charp;
-typedef png_fixed_point * png_fixed_point_p;
-typedef const png_fixed_point * png_const_fixed_point_p;
-typedef size_t * png_size_tp;
-typedef const size_t * png_const_size_tp;
-
-#ifdef PNG_STDIO_SUPPORTED
-typedef FILE * png_FILE_p;
-#endif
-
-#ifdef PNG_FLOATING_POINT_SUPPORTED
-typedef double * png_doublep;
-typedef const double * png_const_doublep;
-#endif
-
-/* Pointers to pointers; i.e. arrays */
-typedef png_byte * * png_bytepp;
-typedef png_uint_32 * * png_uint_32pp;
-typedef png_int_32 * * png_int_32pp;
-typedef png_uint_16 * * png_uint_16pp;
-typedef png_int_16 * * png_int_16pp;
-typedef const char * * png_const_charpp;
-typedef char * * png_charpp;
-typedef png_fixed_point * * png_fixed_point_pp;
-#ifdef PNG_FLOATING_POINT_SUPPORTED
-typedef double * * png_doublepp;
-#endif
-
-/* Pointers to pointers to pointers; i.e., pointer to array */
-typedef char * * * png_charppp;
-
-#endif /* PNG_BUILDING_SYMBOL_TABLE */
-
-#endif /* PNGCONF_H */
diff --git a/contrib/libs/libpng/pngdebug.h b/contrib/libs/libpng/pngdebug.h
deleted file mode 100644
index ab9ea632d9..0000000000
--- a/contrib/libs/libpng/pngdebug.h
+++ /dev/null
@@ -1,152 +0,0 @@
-/* pngdebug.h - Debugging macros for libpng, also used in pngtest.c
- *
- * Copyright (c) 2018 Cosmin Truta
- * Copyright (c) 1998-2002,2004,2006-2013 Glenn Randers-Pehrson
- * Copyright (c) 1996-1997 Andreas Dilger
- * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
- *
- * This code is released under the libpng license.
- * For conditions of distribution and use, see the disclaimer
- * and license in png.h
- */
-
-/* Define PNG_DEBUG at compile time for debugging information. Higher
- * numbers for PNG_DEBUG mean more debugging information. This has
- * only been added since version 0.95 so it is not implemented throughout
- * libpng yet, but more support will be added as needed.
- *
- * png_debug[1-2]?(level, message ,arg{0-2})
- * Expands to a statement (either a simple expression or a compound
- * do..while(0) statement) that outputs a message with parameter
- * substitution if PNG_DEBUG is defined to 2 or more. If PNG_DEBUG
- * is undefined, 0 or 1 every png_debug expands to a simple expression
- * (actually ((void)0)).
- *
- * level: level of detail of message, starting at 0. A level 'n'
- * message is preceded by 'n' 3-space indentations (not implemented
- * on Microsoft compilers unless PNG_DEBUG_FILE is also
- * defined, to allow debug DLL compilation with no standard IO).
- * message: a printf(3) style text string. A trailing '\n' is added
- * to the message.
- * arg: 0 to 2 arguments for printf(3) style substitution in message.
- */
-#ifndef PNGDEBUG_H
-#define PNGDEBUG_H
-/* These settings control the formatting of messages in png.c and pngerror.c */
-/* Moved to pngdebug.h at 1.5.0 */
-# ifndef PNG_LITERAL_SHARP
-# define PNG_LITERAL_SHARP 0x23
-# endif
-# ifndef PNG_LITERAL_LEFT_SQUARE_BRACKET
-# define PNG_LITERAL_LEFT_SQUARE_BRACKET 0x5b
-# endif
-# ifndef PNG_LITERAL_RIGHT_SQUARE_BRACKET
-# define PNG_LITERAL_RIGHT_SQUARE_BRACKET 0x5d
-# endif
-# ifndef PNG_STRING_NEWLINE
-# define PNG_STRING_NEWLINE "\n"
-# endif
-
-#ifdef PNG_DEBUG
-# if (PNG_DEBUG > 0)
-# if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER)
-# include <crtdbg.h>
-# if (PNG_DEBUG > 1)
-# ifndef _DEBUG
-# define _DEBUG
-# endif
-# ifndef png_debug
-# define png_debug(l,m) _RPT0(_CRT_WARN,m PNG_STRING_NEWLINE)
-# endif
-# ifndef png_debug1
-# define png_debug1(l,m,p1) _RPT1(_CRT_WARN,m PNG_STRING_NEWLINE,p1)
-# endif
-# ifndef png_debug2
-# define png_debug2(l,m,p1,p2) \
- _RPT2(_CRT_WARN,m PNG_STRING_NEWLINE,p1,p2)
-# endif
-# endif
-# else /* PNG_DEBUG_FILE || !_MSC_VER */
-# ifndef PNG_STDIO_SUPPORTED
-# include <stdio.h> /* not included yet */
-# endif
-# ifndef PNG_DEBUG_FILE
-# define PNG_DEBUG_FILE stderr
-# endif /* PNG_DEBUG_FILE */
-
-# if (PNG_DEBUG > 1)
-# ifdef __STDC__
-# ifndef png_debug
-# define png_debug(l,m) \
- do { \
- int num_tabs=l; \
- fprintf(PNG_DEBUG_FILE,"%s" m PNG_STRING_NEWLINE,(num_tabs==1 ? " " : \
- (num_tabs==2 ? " " : (num_tabs>2 ? " " : "")))); \
- } while (0)
-# endif
-# ifndef png_debug1
-# define png_debug1(l,m,p1) \
- do { \
- int num_tabs=l; \
- fprintf(PNG_DEBUG_FILE,"%s" m PNG_STRING_NEWLINE,(num_tabs==1 ? " " : \
- (num_tabs==2 ? " " : (num_tabs>2 ? " " : ""))),p1); \
- } while (0)
-# endif
-# ifndef png_debug2
-# define png_debug2(l,m,p1,p2) \
- do { \
- int num_tabs=l; \
- fprintf(PNG_DEBUG_FILE,"%s" m PNG_STRING_NEWLINE,(num_tabs==1 ? " " : \
- (num_tabs==2 ? " " : (num_tabs>2 ? " " : ""))),p1,p2);\
- } while (0)
-# endif
-# else /* __STDC __ */
-# ifndef png_debug
-# define png_debug(l,m) \
- do { \
- int num_tabs=l; \
- char format[256]; \
- snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
- (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
- m,PNG_STRING_NEWLINE); \
- fprintf(PNG_DEBUG_FILE,format); \
- } while (0)
-# endif
-# ifndef png_debug1
-# define png_debug1(l,m,p1) \
- do { \
- int num_tabs=l; \
- char format[256]; \
- snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
- (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
- m,PNG_STRING_NEWLINE); \
- fprintf(PNG_DEBUG_FILE,format,p1); \
- } while (0)
-# endif
-# ifndef png_debug2
-# define png_debug2(l,m,p1,p2) \
- do { \
- int num_tabs=l; \
- char format[256]; \
- snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
- (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
- m,PNG_STRING_NEWLINE); \
- fprintf(PNG_DEBUG_FILE,format,p1,p2); \
- } while (0)
-# endif
-# endif /* __STDC __ */
-# endif /* (PNG_DEBUG > 1) */
-
-# endif /* _MSC_VER */
-# endif /* (PNG_DEBUG > 0) */
-#endif /* PNG_DEBUG */
-#ifndef png_debug
-# define png_debug(l, m) ((void)0)
-#endif
-#ifndef png_debug1
-# define png_debug1(l, m, p1) ((void)0)
-#endif
-#ifndef png_debug2
-# define png_debug2(l, m, p1, p2) ((void)0)
-#endif
-#endif /* PNGDEBUG_H */
diff --git a/contrib/libs/libpng/pngerror.c b/contrib/libs/libpng/pngerror.c
deleted file mode 100644
index aa0ae58e15..0000000000
--- a/contrib/libs/libpng/pngerror.c
+++ /dev/null
@@ -1,957 +0,0 @@
-/* pngerror.c - stub functions for i/o and memory allocation
- *
- * Copyright (c) 2018-2024 Cosmin Truta
- * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
- * Copyright (c) 1996-1997 Andreas Dilger
- * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
- *
- * This code is released under the libpng license.
- * For conditions of distribution and use, see the disclaimer
- * and license in png.h
- *
- * This file provides a location for all error handling. Users who
- * need special error handling are expected to write replacement functions
- * and use png_set_error_fn() to use those functions. See the instructions
- * at each function.
- */
-
-#include "pngpriv.h"
-
-#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
-
-static PNG_FUNCTION(void /* PRIVATE */,
-png_default_error,(png_const_structrp png_ptr, png_const_charp error_message),
- PNG_NORETURN);
-
-#ifdef PNG_WARNINGS_SUPPORTED
-static void /* PRIVATE */
-png_default_warning(png_const_structrp png_ptr,
- png_const_charp warning_message);
-#endif /* WARNINGS */
-
-/* This function is called whenever there is a fatal error. This function
- * should not be changed. If there is a need to handle errors differently,
- * you should supply a replacement error function and use png_set_error_fn()
- * to replace the error function at run-time.
- */
-#ifdef PNG_ERROR_TEXT_SUPPORTED
-PNG_FUNCTION(void,PNGAPI
-png_error,(png_const_structrp png_ptr, png_const_charp error_message),
- PNG_NORETURN)
-{
-#ifdef PNG_ERROR_NUMBERS_SUPPORTED
- char msg[16];
- if (png_ptr != NULL)
- {
- if ((png_ptr->flags &
- (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) != 0)
- {
- if (*error_message == PNG_LITERAL_SHARP)
- {
- /* Strip "#nnnn " from beginning of error message. */
- int offset;
- for (offset = 1; offset<15; offset++)
- if (error_message[offset] == ' ')
- break;
-
- if ((png_ptr->flags & PNG_FLAG_STRIP_ERROR_TEXT) != 0)
- {
- int i;
- for (i = 0; i < offset - 1; i++)
- msg[i] = error_message[i + 1];
- msg[i - 1] = '\0';
- error_message = msg;
- }
-
- else
- error_message += offset;
- }
-
- else
- {
- if ((png_ptr->flags & PNG_FLAG_STRIP_ERROR_TEXT) != 0)
- {
- msg[0] = '0';
- msg[1] = '\0';
- error_message = msg;
- }
- }
- }
- }
-#endif
- if (png_ptr != NULL && png_ptr->error_fn != NULL)
- (*(png_ptr->error_fn))(png_constcast(png_structrp,png_ptr),
- error_message);
-
- /* If the custom handler doesn't exist, or if it returns,
- use the default handler, which will not return. */
- png_default_error(png_ptr, error_message);
-}
-#else
-PNG_FUNCTION(void,PNGAPI
-png_err,(png_const_structrp png_ptr),PNG_NORETURN)
-{
- /* Prior to 1.5.2 the error_fn received a NULL pointer, expressed
- * erroneously as '\0', instead of the empty string "". This was
- * apparently an error, introduced in libpng-1.2.20, and png_default_error
- * will crash in this case.
- */
- if (png_ptr != NULL && png_ptr->error_fn != NULL)
- (*(png_ptr->error_fn))(png_constcast(png_structrp,png_ptr), "");
-
- /* If the custom handler doesn't exist, or if it returns,
- use the default handler, which will not return. */
- png_default_error(png_ptr, "");
-}
-#endif /* ERROR_TEXT */
-
-/* Utility to safely appends strings to a buffer. This never errors out so
- * error checking is not required in the caller.
- */
-size_t
-png_safecat(png_charp buffer, size_t bufsize, size_t pos,
- png_const_charp string)
-{
- if (buffer != NULL && pos < bufsize)
- {
- if (string != NULL)
- while (*string != '\0' && pos < bufsize-1)
- buffer[pos++] = *string++;
-
- buffer[pos] = '\0';
- }
-
- return pos;
-}
-
-#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_TIME_RFC1123_SUPPORTED)
-/* Utility to dump an unsigned value into a buffer, given a start pointer and
- * and end pointer (which should point just *beyond* the end of the buffer!)
- * Returns the pointer to the start of the formatted string.
- */
-png_charp
-png_format_number(png_const_charp start, png_charp end, int format,
- png_alloc_size_t number)
-{
- int count = 0; /* number of digits output */
- int mincount = 1; /* minimum number required */
- int output = 0; /* digit output (for the fixed point format) */
-
- *--end = '\0';
-
- /* This is written so that the loop always runs at least once, even with
- * number zero.
- */
- while (end > start && (number != 0 || count < mincount))
- {
-
- static const char digits[] = "0123456789ABCDEF";
-
- switch (format)
- {
- case PNG_NUMBER_FORMAT_fixed:
- /* Needs five digits (the fraction) */
- mincount = 5;
- if (output != 0 || number % 10 != 0)
- {
- *--end = digits[number % 10];
- output = 1;
- }
- number /= 10;
- break;
-
- case PNG_NUMBER_FORMAT_02u:
- /* Expects at least 2 digits. */
- mincount = 2;
- /* FALLTHROUGH */
-
- case PNG_NUMBER_FORMAT_u:
- *--end = digits[number % 10];
- number /= 10;
- break;
-
- case PNG_NUMBER_FORMAT_02x:
- /* This format expects at least two digits */
- mincount = 2;
- /* FALLTHROUGH */
-
- case PNG_NUMBER_FORMAT_x:
- *--end = digits[number & 0xf];
- number >>= 4;
- break;
-
- default: /* an error */
- number = 0;
- break;
- }
-
- /* Keep track of the number of digits added */
- ++count;
-
- /* Float a fixed number here: */
- if ((format == PNG_NUMBER_FORMAT_fixed) && (count == 5) && (end > start))
- {
- /* End of the fraction, but maybe nothing was output? In that case
- * drop the decimal point. If the number is a true zero handle that
- * here.
- */
- if (output != 0)
- *--end = '.';
- else if (number == 0) /* and !output */
- *--end = '0';
- }
- }
-
- return end;
-}
-#endif
-
-#ifdef PNG_WARNINGS_SUPPORTED
-/* This function is called whenever there is a non-fatal error. This function
- * should not be changed. If there is a need to handle warnings differently,
- * you should supply a replacement warning function and use
- * png_set_error_fn() to replace the warning function at run-time.
- */
-void PNGAPI
-png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
-{
- int offset = 0;
- if (png_ptr != NULL)
- {
-#ifdef PNG_ERROR_NUMBERS_SUPPORTED
- if ((png_ptr->flags &
- (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) != 0)
-#endif
- {
- if (*warning_message == PNG_LITERAL_SHARP)
- {
- for (offset = 1; offset < 15; offset++)
- if (warning_message[offset] == ' ')
- break;
- }
- }
- }
- if (png_ptr != NULL && png_ptr->warning_fn != NULL)
- (*(png_ptr->warning_fn))(png_constcast(png_structrp,png_ptr),
- warning_message + offset);
- else
- png_default_warning(png_ptr, warning_message + offset);
-}
-
-/* These functions support 'formatted' warning messages with up to
- * PNG_WARNING_PARAMETER_COUNT parameters. In the format string the parameter
- * is introduced by @<number>, where 'number' starts at 1. This follows the
- * standard established by X/Open for internationalizable error messages.
- */
-void
-png_warning_parameter(png_warning_parameters p, int number,
- png_const_charp string)
-{
- if (number > 0 && number <= PNG_WARNING_PARAMETER_COUNT)
- (void)png_safecat(p[number-1], (sizeof p[number-1]), 0, string);
-}
-
-void
-png_warning_parameter_unsigned(png_warning_parameters p, int number, int format,
- png_alloc_size_t value)
-{
- char buffer[PNG_NUMBER_BUFFER_SIZE] = {0};
- png_warning_parameter(p, number, PNG_FORMAT_NUMBER(buffer, format, value));
-}
-
-void
-png_warning_parameter_signed(png_warning_parameters p, int number, int format,
- png_int_32 value)
-{
- png_alloc_size_t u;
- png_charp str;
- char buffer[PNG_NUMBER_BUFFER_SIZE] = {0};
-
- /* Avoid overflow by doing the negate in a png_alloc_size_t: */
- u = (png_alloc_size_t)value;
- if (value < 0)
- u = ~u + 1;
-
- str = PNG_FORMAT_NUMBER(buffer, format, u);
-
- if (value < 0 && str > buffer)
- *--str = '-';
-
- png_warning_parameter(p, number, str);
-}
-
-void
-png_formatted_warning(png_const_structrp png_ptr, png_warning_parameters p,
- png_const_charp message)
-{
- /* The internal buffer is just 192 bytes - enough for all our messages,
- * overflow doesn't happen because this code checks! If someone figures
- * out how to send us a message longer than 192 bytes, all that will
- * happen is that the message will be truncated appropriately.
- */
- size_t i = 0; /* Index in the msg[] buffer: */
- char msg[192];
-
- /* Each iteration through the following loop writes at most one character
- * to msg[i++] then returns here to validate that there is still space for
- * the trailing '\0'. It may (in the case of a parameter) read more than
- * one character from message[]; it must check for '\0' and continue to the
- * test if it finds the end of string.
- */
- while (i<(sizeof msg)-1 && *message != '\0')
- {
- /* '@' at end of string is now just printed (previously it was skipped);
- * it is an error in the calling code to terminate the string with @.
- */
- if (p != NULL && *message == '@' && message[1] != '\0')
- {
- int parameter_char = *++message; /* Consume the '@' */
- static const char valid_parameters[] = "123456789";
- int parameter = 0;
-
- /* Search for the parameter digit, the index in the string is the
- * parameter to use.
- */
- while (valid_parameters[parameter] != parameter_char &&
- valid_parameters[parameter] != '\0')
- ++parameter;
-
- /* If the parameter digit is out of range it will just get printed. */
- if (parameter < PNG_WARNING_PARAMETER_COUNT)
- {
- /* Append this parameter */
- png_const_charp parm = p[parameter];
- png_const_charp pend = p[parameter] + (sizeof p[parameter]);
-
- /* No need to copy the trailing '\0' here, but there is no guarantee
- * that parm[] has been initialized, so there is no guarantee of a
- * trailing '\0':
- */
- while (i<(sizeof msg)-1 && *parm != '\0' && parm < pend)
- msg[i++] = *parm++;
-
- /* Consume the parameter digit too: */
- ++message;
- continue;
- }
-
- /* else not a parameter and there is a character after the @ sign; just
- * copy that. This is known not to be '\0' because of the test above.
- */
- }
-
- /* At this point *message can't be '\0', even in the bad parameter case
- * above where there is a lone '@' at the end of the message string.
- */
- msg[i++] = *message++;
- }
-
- /* i is always less than (sizeof msg), so: */
- msg[i] = '\0';
-
- /* And this is the formatted message. It may be larger than
- * PNG_MAX_ERROR_TEXT, but that is only used for 'chunk' errors and these
- * are not (currently) formatted.
- */
- png_warning(png_ptr, msg);
-}
-#endif /* WARNINGS */
-
-#ifdef PNG_BENIGN_ERRORS_SUPPORTED
-void PNGAPI
-png_benign_error(png_const_structrp png_ptr, png_const_charp error_message)
-{
- if ((png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN) != 0)
- {
-# ifdef PNG_READ_SUPPORTED
- if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 &&
- png_ptr->chunk_name != 0)
- png_chunk_warning(png_ptr, error_message);
- else
-# endif
- png_warning(png_ptr, error_message);
- }
-
- else
- {
-# ifdef PNG_READ_SUPPORTED
- if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 &&
- png_ptr->chunk_name != 0)
- png_chunk_error(png_ptr, error_message);
- else
-# endif
- png_error(png_ptr, error_message);
- }
-
-# ifndef PNG_ERROR_TEXT_SUPPORTED
- PNG_UNUSED(error_message)
-# endif
-}
-
-void /* PRIVATE */
-png_app_warning(png_const_structrp png_ptr, png_const_charp error_message)
-{
- if ((png_ptr->flags & PNG_FLAG_APP_WARNINGS_WARN) != 0)
- png_warning(png_ptr, error_message);
- else
- png_error(png_ptr, error_message);
-
-# ifndef PNG_ERROR_TEXT_SUPPORTED
- PNG_UNUSED(error_message)
-# endif
-}
-
-void /* PRIVATE */
-png_app_error(png_const_structrp png_ptr, png_const_charp error_message)
-{
- if ((png_ptr->flags & PNG_FLAG_APP_ERRORS_WARN) != 0)
- png_warning(png_ptr, error_message);
- else
- png_error(png_ptr, error_message);
-
-# ifndef PNG_ERROR_TEXT_SUPPORTED
- PNG_UNUSED(error_message)
-# endif
-}
-#endif /* BENIGN_ERRORS */
-
-#define PNG_MAX_ERROR_TEXT 196 /* Currently limited by profile_error in png.c */
-#if defined(PNG_WARNINGS_SUPPORTED) || \
- (defined(PNG_READ_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED))
-/* These utilities are used internally to build an error message that relates
- * to the current chunk. The chunk name comes from png_ptr->chunk_name,
- * which is used to prefix the message. The message is limited in length
- * to 63 bytes. The name characters are output as hex digits wrapped in []
- * if the character is invalid.
- */
-#define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97))
-static const char png_digit[16] = {
- '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
- 'A', 'B', 'C', 'D', 'E', 'F'
-};
-
-static void /* PRIVATE */
-png_format_buffer(png_const_structrp png_ptr, png_charp buffer, png_const_charp
- error_message)
-{
- png_uint_32 chunk_name = png_ptr->chunk_name;
- int iout = 0, ishift = 24;
-
- while (ishift >= 0)
- {
- int c = (int)(chunk_name >> ishift) & 0xff;
-
- ishift -= 8;
- if (isnonalpha(c) != 0)
- {
- buffer[iout++] = PNG_LITERAL_LEFT_SQUARE_BRACKET;
- buffer[iout++] = png_digit[(c & 0xf0) >> 4];
- buffer[iout++] = png_digit[c & 0x0f];
- buffer[iout++] = PNG_LITERAL_RIGHT_SQUARE_BRACKET;
- }
-
- else
- {
- buffer[iout++] = (char)c;
- }
- }
-
- if (error_message == NULL)
- buffer[iout] = '\0';
-
- else
- {
- int iin = 0;
-
- buffer[iout++] = ':';
- buffer[iout++] = ' ';
-
- while (iin < PNG_MAX_ERROR_TEXT-1 && error_message[iin] != '\0')
- buffer[iout++] = error_message[iin++];
-
- /* iin < PNG_MAX_ERROR_TEXT, so the following is safe: */
- buffer[iout] = '\0';
- }
-}
-#endif /* WARNINGS || ERROR_TEXT */
-
-#if defined(PNG_READ_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED)
-PNG_FUNCTION(void,PNGAPI
-png_chunk_error,(png_const_structrp png_ptr, png_const_charp error_message),
- PNG_NORETURN)
-{
- char msg[18+PNG_MAX_ERROR_TEXT];
- if (png_ptr == NULL)
- png_error(png_ptr, error_message);
-
- else
- {
- png_format_buffer(png_ptr, msg, error_message);
- png_error(png_ptr, msg);
- }
-}
-#endif /* READ && ERROR_TEXT */
-
-#ifdef PNG_WARNINGS_SUPPORTED
-void PNGAPI
-png_chunk_warning(png_const_structrp png_ptr, png_const_charp warning_message)
-{
- char msg[18+PNG_MAX_ERROR_TEXT];
- if (png_ptr == NULL)
- png_warning(png_ptr, warning_message);
-
- else
- {
- png_format_buffer(png_ptr, msg, warning_message);
- png_warning(png_ptr, msg);
- }
-}
-#endif /* WARNINGS */
-
-#ifdef PNG_READ_SUPPORTED
-#ifdef PNG_BENIGN_ERRORS_SUPPORTED
-void PNGAPI
-png_chunk_benign_error(png_const_structrp png_ptr, png_const_charp
- error_message)
-{
- if ((png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN) != 0)
- png_chunk_warning(png_ptr, error_message);
-
- else
- png_chunk_error(png_ptr, error_message);
-
-# ifndef PNG_ERROR_TEXT_SUPPORTED
- PNG_UNUSED(error_message)
-# endif
-}
-#endif
-#endif /* READ */
-
-void /* PRIVATE */
-png_chunk_report(png_const_structrp png_ptr, png_const_charp message, int error)
-{
-# ifndef PNG_WARNINGS_SUPPORTED
- PNG_UNUSED(message)
-# endif
-
- /* This is always supported, but for just read or just write it
- * unconditionally does the right thing.
- */
-# if defined(PNG_READ_SUPPORTED) && defined(PNG_WRITE_SUPPORTED)
- if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
-# endif
-
-# ifdef PNG_READ_SUPPORTED
- {
- if (error < PNG_CHUNK_ERROR)
- png_chunk_warning(png_ptr, message);
-
- else
- png_chunk_benign_error(png_ptr, message);
- }
-# endif
-
-# if defined(PNG_READ_SUPPORTED) && defined(PNG_WRITE_SUPPORTED)
- else if ((png_ptr->mode & PNG_IS_READ_STRUCT) == 0)
-# endif
-
-# ifdef PNG_WRITE_SUPPORTED
- {
- if (error < PNG_CHUNK_WRITE_ERROR)
- png_app_warning(png_ptr, message);
-
- else
- png_app_error(png_ptr, message);
- }
-# endif
-}
-
-#ifdef PNG_ERROR_TEXT_SUPPORTED
-#ifdef PNG_FLOATING_POINT_SUPPORTED
-PNG_FUNCTION(void,
-png_fixed_error,(png_const_structrp png_ptr, png_const_charp name),PNG_NORETURN)
-{
-# define fixed_message "fixed point overflow in "
-# define fixed_message_ln ((sizeof fixed_message)-1)
- unsigned int iin;
- char msg[fixed_message_ln+PNG_MAX_ERROR_TEXT];
- memcpy(msg, fixed_message, fixed_message_ln);
- iin = 0;
- if (name != NULL)
- while (iin < (PNG_MAX_ERROR_TEXT-1) && name[iin] != 0)
- {
- msg[fixed_message_ln + iin] = name[iin];
- ++iin;
- }
- msg[fixed_message_ln + iin] = 0;
- png_error(png_ptr, msg);
-}
-#endif
-#endif
-
-#ifdef PNG_SETJMP_SUPPORTED
-/* This API only exists if ANSI-C style error handling is used,
- * otherwise it is necessary for png_default_error to be overridden.
- */
-jmp_buf* PNGAPI
-png_set_longjmp_fn(png_structrp png_ptr, png_longjmp_ptr longjmp_fn,
- size_t jmp_buf_size)
-{
- /* From libpng 1.6.0 the app gets one chance to set a 'jmpbuf_size' value
- * and it must not change after that. Libpng doesn't care how big the
- * buffer is, just that it doesn't change.
- *
- * If the buffer size is no *larger* than the size of jmp_buf when libpng is
- * compiled a built in jmp_buf is returned; this preserves the pre-1.6.0
- * semantics that this call will not fail. If the size is larger, however,
- * the buffer is allocated and this may fail, causing the function to return
- * NULL.
- */
- if (png_ptr == NULL)
- return NULL;
-
- if (png_ptr->jmp_buf_ptr == NULL)
- {
- png_ptr->jmp_buf_size = 0; /* not allocated */
-
- if (jmp_buf_size <= (sizeof png_ptr->jmp_buf_local))
- png_ptr->jmp_buf_ptr = &png_ptr->jmp_buf_local;
-
- else
- {
- png_ptr->jmp_buf_ptr = png_voidcast(jmp_buf *,
- png_malloc_warn(png_ptr, jmp_buf_size));
-
- if (png_ptr->jmp_buf_ptr == NULL)
- return NULL; /* new NULL return on OOM */
-
- png_ptr->jmp_buf_size = jmp_buf_size;
- }
- }
-
- else /* Already allocated: check the size */
- {
- size_t size = png_ptr->jmp_buf_size;
-
- if (size == 0)
- {
- size = (sizeof png_ptr->jmp_buf_local);
- if (png_ptr->jmp_buf_ptr != &png_ptr->jmp_buf_local)
- {
- /* This is an internal error in libpng: somehow we have been left
- * with a stack allocated jmp_buf when the application regained
- * control. It's always possible to fix this up, but for the moment
- * this is a png_error because that makes it easy to detect.
- */
- png_error(png_ptr, "Libpng jmp_buf still allocated");
- /* png_ptr->jmp_buf_ptr = &png_ptr->jmp_buf_local; */
- }
- }
-
- if (size != jmp_buf_size)
- {
- png_warning(png_ptr, "Application jmp_buf size changed");
- return NULL; /* caller will probably crash: no choice here */
- }
- }
-
- /* Finally fill in the function, now we have a satisfactory buffer. It is
- * valid to change the function on every call.
- */
- png_ptr->longjmp_fn = longjmp_fn;
- return png_ptr->jmp_buf_ptr;
-}
-
-void /* PRIVATE */
-png_free_jmpbuf(png_structrp png_ptr)
-{
- if (png_ptr != NULL)
- {
- jmp_buf *jb = png_ptr->jmp_buf_ptr;
-
- /* A size of 0 is used to indicate a local, stack, allocation of the
- * pointer; used here and in png.c
- */
- if (jb != NULL && png_ptr->jmp_buf_size > 0)
- {
-
- /* This stuff is so that a failure to free the error control structure
- * does not leave libpng in a state with no valid error handling: the
- * free always succeeds, if there is an error it gets ignored.
- */
- if (jb != &png_ptr->jmp_buf_local)
- {
- /* Make an internal, libpng, jmp_buf to return here */
- jmp_buf free_jmp_buf;
-
- if (!setjmp(free_jmp_buf))
- {
- png_ptr->jmp_buf_ptr = &free_jmp_buf; /* come back here */
- png_ptr->jmp_buf_size = 0; /* stack allocation */
- png_ptr->longjmp_fn = longjmp;
- png_free(png_ptr, jb); /* Return to setjmp on error */
- }
- }
- }
-
- /* *Always* cancel everything out: */
- png_ptr->jmp_buf_size = 0;
- png_ptr->jmp_buf_ptr = NULL;
- png_ptr->longjmp_fn = 0;
- }
-}
-#endif
-
-/* This is the default error handling function. Note that replacements for
- * this function MUST NOT RETURN, or the program will likely crash. This
- * function is used by default, or if the program supplies NULL for the
- * error function pointer in png_set_error_fn().
- */
-static PNG_FUNCTION(void /* PRIVATE */,
-png_default_error,(png_const_structrp png_ptr, png_const_charp error_message),
- PNG_NORETURN)
-{
-#ifdef PNG_CONSOLE_IO_SUPPORTED
-#ifdef PNG_ERROR_NUMBERS_SUPPORTED
- /* Check on NULL only added in 1.5.4 */
- if (error_message != NULL && *error_message == PNG_LITERAL_SHARP)
- {
- /* Strip "#nnnn " from beginning of error message. */
- int offset;
- char error_number[16];
- for (offset = 0; offset<15; offset++)
- {
- error_number[offset] = error_message[offset + 1];
- if (error_message[offset] == ' ')
- break;
- }
-
- if ((offset > 1) && (offset < 15))
- {
- error_number[offset - 1] = '\0';
- fprintf(stderr, "libpng error no. %s: %s",
- error_number, error_message + offset + 1);
- fprintf(stderr, PNG_STRING_NEWLINE);
- }
-
- else
- {
- fprintf(stderr, "libpng error: %s, offset=%d",
- error_message, offset);
- fprintf(stderr, PNG_STRING_NEWLINE);
- }
- }
- else
-#endif
- {
- fprintf(stderr, "libpng error: %s", error_message ? error_message :
- "undefined");
- fprintf(stderr, PNG_STRING_NEWLINE);
- }
-#else
- PNG_UNUSED(error_message) /* Make compiler happy */
-#endif
- png_longjmp(png_ptr, 1);
-}
-
-PNG_FUNCTION(void,PNGAPI
-png_longjmp,(png_const_structrp png_ptr, int val),PNG_NORETURN)
-{
-#ifdef PNG_SETJMP_SUPPORTED
- if (png_ptr != NULL && png_ptr->longjmp_fn != NULL &&
- png_ptr->jmp_buf_ptr != NULL)
- png_ptr->longjmp_fn(*png_ptr->jmp_buf_ptr, val);
-#else
- PNG_UNUSED(png_ptr)
- PNG_UNUSED(val)
-#endif
-
- /* If control reaches this point, png_longjmp() must not return. The only
- * choice is to terminate the whole process (or maybe the thread); to do
- * this the ANSI-C abort() function is used unless a different method is
- * implemented by overriding the default configuration setting for
- * PNG_ABORT().
- */
- PNG_ABORT();
-}
-
-#ifdef PNG_WARNINGS_SUPPORTED
-/* This function is called when there is a warning, but the library thinks
- * it can continue anyway. Replacement functions don't have to do anything
- * here if you don't want them to. In the default configuration, png_ptr is
- * not used, but it is passed in case it may be useful.
- */
-static void /* PRIVATE */
-png_default_warning(png_const_structrp png_ptr, png_const_charp warning_message)
-{
-#ifdef PNG_CONSOLE_IO_SUPPORTED
-# ifdef PNG_ERROR_NUMBERS_SUPPORTED
- if (*warning_message == PNG_LITERAL_SHARP)
- {
- int offset;
- char warning_number[16];
- for (offset = 0; offset < 15; offset++)
- {
- warning_number[offset] = warning_message[offset + 1];
- if (warning_message[offset] == ' ')
- break;
- }
-
- if ((offset > 1) && (offset < 15))
- {
- warning_number[offset + 1] = '\0';
- fprintf(stderr, "libpng warning no. %s: %s",
- warning_number, warning_message + offset);
- fprintf(stderr, PNG_STRING_NEWLINE);
- }
-
- else
- {
- fprintf(stderr, "libpng warning: %s",
- warning_message);
- fprintf(stderr, PNG_STRING_NEWLINE);
- }
- }
- else
-# endif
-
- {
- fprintf(stderr, "libpng warning: %s", warning_message);
- fprintf(stderr, PNG_STRING_NEWLINE);
- }
-#else
- PNG_UNUSED(warning_message) /* Make compiler happy */
-#endif
- PNG_UNUSED(png_ptr) /* Make compiler happy */
-}
-#endif /* WARNINGS */
-
-/* This function is called when the application wants to use another method
- * of handling errors and warnings. Note that the error function MUST NOT
- * return to the calling routine or serious problems will occur. The return
- * method used in the default routine calls longjmp(png_ptr->jmp_buf_ptr, 1)
- */
-void PNGAPI
-png_set_error_fn(png_structrp png_ptr, png_voidp error_ptr,
- png_error_ptr error_fn, png_error_ptr warning_fn)
-{
- if (png_ptr == NULL)
- return;
-
- png_ptr->error_ptr = error_ptr;
- png_ptr->error_fn = error_fn;
-#ifdef PNG_WARNINGS_SUPPORTED
- png_ptr->warning_fn = warning_fn;
-#else
- PNG_UNUSED(warning_fn)
-#endif
-}
-
-
-/* This function returns a pointer to the error_ptr associated with the user
- * functions. The application should free any memory associated with this
- * pointer before png_write_destroy and png_read_destroy are called.
- */
-png_voidp PNGAPI
-png_get_error_ptr(png_const_structrp png_ptr)
-{
- if (png_ptr == NULL)
- return NULL;
-
- return (png_voidp)png_ptr->error_ptr;
-}
-
-
-#ifdef PNG_ERROR_NUMBERS_SUPPORTED
-void PNGAPI
-png_set_strip_error_numbers(png_structrp png_ptr, png_uint_32 strip_mode)
-{
- if (png_ptr != NULL)
- {
- png_ptr->flags &=
- ((~(PNG_FLAG_STRIP_ERROR_NUMBERS |
- PNG_FLAG_STRIP_ERROR_TEXT))&strip_mode);
- }
-}
-#endif
-
-#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\
- defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)
- /* Currently the above both depend on SETJMP_SUPPORTED, however it would be
- * possible to implement without setjmp support just so long as there is some
- * way to handle the error return here:
- */
-PNG_FUNCTION(void /* PRIVATE */, (PNGCBAPI
-png_safe_error),(png_structp png_nonconst_ptr, png_const_charp error_message),
- PNG_NORETURN)
-{
- png_const_structrp png_ptr = png_nonconst_ptr;
- png_imagep image = png_voidcast(png_imagep, png_ptr->error_ptr);
-
- /* An error is always logged here, overwriting anything (typically a warning)
- * that is already there:
- */
- if (image != NULL)
- {
- png_safecat(image->message, (sizeof image->message), 0, error_message);
- image->warning_or_error |= PNG_IMAGE_ERROR;
-
- /* Retrieve the jmp_buf from within the png_control, making this work for
- * C++ compilation too is pretty tricky: C++ wants a pointer to the first
- * element of a jmp_buf, but C doesn't tell us the type of that.
- */
- if (image->opaque != NULL && image->opaque->error_buf != NULL)
- longjmp(png_control_jmp_buf(image->opaque), 1);
-
- /* Missing longjmp buffer, the following is to help debugging: */
- {
- size_t pos = png_safecat(image->message, (sizeof image->message), 0,
- "bad longjmp: ");
- png_safecat(image->message, (sizeof image->message), pos,
- error_message);
- }
- }
-
- /* Here on an internal programming error. */
- abort();
-}
-
-#ifdef PNG_WARNINGS_SUPPORTED
-void /* PRIVATE */ PNGCBAPI
-png_safe_warning(png_structp png_nonconst_ptr, png_const_charp warning_message)
-{
- png_const_structrp png_ptr = png_nonconst_ptr;
- png_imagep image = png_voidcast(png_imagep, png_ptr->error_ptr);
-
- /* A warning is only logged if there is no prior warning or error. */
- if (image->warning_or_error == 0)
- {
- png_safecat(image->message, (sizeof image->message), 0, warning_message);
- image->warning_or_error |= PNG_IMAGE_WARNING;
- }
-}
-#endif
-
-int /* PRIVATE */
-png_safe_execute(png_imagep image, int (*function)(png_voidp), png_voidp arg)
-{
- png_voidp saved_error_buf = image->opaque->error_buf;
- jmp_buf safe_jmpbuf;
- int result;
-
- /* Safely execute function(arg), with png_error returning back here. */
- if (setjmp(safe_jmpbuf) == 0)
- {
- image->opaque->error_buf = safe_jmpbuf;
- result = function(arg);
- image->opaque->error_buf = saved_error_buf;
- return result;
- }
-
- /* On png_error, return via longjmp, pop the jmpbuf, and free the image. */
- image->opaque->error_buf = saved_error_buf;
- png_image_free(image);
- return 0;
-}
-#endif /* SIMPLIFIED READ || SIMPLIFIED_WRITE */
-#endif /* READ || WRITE */
diff --git a/contrib/libs/libpng/pngget.c b/contrib/libs/libpng/pngget.c
deleted file mode 100644
index ee430a3643..0000000000
--- a/contrib/libs/libpng/pngget.c
+++ /dev/null
@@ -1,1558 +0,0 @@
-/* pngget.c - retrieval of values from info struct
- *
- * Copyright (c) 2018-2024 Cosmin Truta
- * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
- * Copyright (c) 1996-1997 Andreas Dilger
- * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
- *
- * This code is released under the libpng license.
- * For conditions of distribution and use, see the disclaimer
- * and license in png.h
- *
- */
-
-#include "pngpriv.h"
-
-#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
-
-png_uint_32 PNGAPI
-png_get_valid(png_const_structrp png_ptr, png_const_inforp info_ptr,
- png_uint_32 flag)
-{
- if (png_ptr != NULL && info_ptr != NULL)
- {
-#ifdef PNG_READ_tRNS_SUPPORTED
- /* png_handle_PLTE() may have canceled a valid tRNS chunk but left the
- * 'valid' flag for the detection of duplicate chunks. Do not report a
- * valid tRNS chunk in this case.
- */
- if (flag == PNG_INFO_tRNS && png_ptr->num_trans == 0)
- return 0;
-#endif
-
- return info_ptr->valid & flag;
- }
-
- return 0;
-}
-
-size_t PNGAPI
-png_get_rowbytes(png_const_structrp png_ptr, png_const_inforp info_ptr)
-{
- if (png_ptr != NULL && info_ptr != NULL)
- return info_ptr->rowbytes;
-
- return 0;
-}
-
-#ifdef PNG_INFO_IMAGE_SUPPORTED
-png_bytepp PNGAPI
-png_get_rows(png_const_structrp png_ptr, png_const_inforp info_ptr)
-{
- if (png_ptr != NULL && info_ptr != NULL)
- return info_ptr->row_pointers;
-
- return 0;
-}
-#endif
-
-#ifdef PNG_EASY_ACCESS_SUPPORTED
-/* Easy access to info, added in libpng-0.99 */
-png_uint_32 PNGAPI
-png_get_image_width(png_const_structrp png_ptr, png_const_inforp info_ptr)
-{
- if (png_ptr != NULL && info_ptr != NULL)
- return info_ptr->width;
-
- return 0;
-}
-
-png_uint_32 PNGAPI
-png_get_image_height(png_const_structrp png_ptr, png_const_inforp info_ptr)
-{
- if (png_ptr != NULL && info_ptr != NULL)
- return info_ptr->height;
-
- return 0;
-}
-
-png_byte PNGAPI
-png_get_bit_depth(png_const_structrp png_ptr, png_const_inforp info_ptr)
-{
- if (png_ptr != NULL && info_ptr != NULL)
- return info_ptr->bit_depth;
-
- return 0;
-}
-
-png_byte PNGAPI
-png_get_color_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
-{
- if (png_ptr != NULL && info_ptr != NULL)
- return info_ptr->color_type;
-
- return 0;
-}
-
-png_byte PNGAPI
-png_get_filter_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
-{
- if (png_ptr != NULL && info_ptr != NULL)
- return info_ptr->filter_type;
-
- return 0;
-}
-
-png_byte PNGAPI
-png_get_interlace_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
-{
- if (png_ptr != NULL && info_ptr != NULL)
- return info_ptr->interlace_type;
-
- return 0;
-}
-
-png_byte PNGAPI
-png_get_compression_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
-{
- if (png_ptr != NULL && info_ptr != NULL)
- return info_ptr->compression_type;
-
- return 0;
-}
-
-png_uint_32 PNGAPI
-png_get_x_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp
- info_ptr)
-{
-#ifdef PNG_pHYs_SUPPORTED
- png_debug(1, "in png_get_x_pixels_per_meter");
-
- if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_pHYs) != 0)
- {
- if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER)
- return info_ptr->x_pixels_per_unit;
- }
-#else
- PNG_UNUSED(png_ptr)
- PNG_UNUSED(info_ptr)
-#endif
-
- return 0;
-}
-
-png_uint_32 PNGAPI
-png_get_y_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp
- info_ptr)
-{
-#ifdef PNG_pHYs_SUPPORTED
- png_debug(1, "in png_get_y_pixels_per_meter");
-
- if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_pHYs) != 0)
- {
- if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER)
- return info_ptr->y_pixels_per_unit;
- }
-#else
- PNG_UNUSED(png_ptr)
- PNG_UNUSED(info_ptr)
-#endif
-
- return 0;
-}
-
-png_uint_32 PNGAPI
-png_get_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr)
-{
-#ifdef PNG_pHYs_SUPPORTED
- png_debug(1, "in png_get_pixels_per_meter");
-
- if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_pHYs) != 0)
- {
- if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER &&
- info_ptr->x_pixels_per_unit == info_ptr->y_pixels_per_unit)
- return info_ptr->x_pixels_per_unit;
- }
-#else
- PNG_UNUSED(png_ptr)
- PNG_UNUSED(info_ptr)
-#endif
-
- return 0;
-}
-
-#ifdef PNG_FLOATING_POINT_SUPPORTED
-float PNGAPI
-png_get_pixel_aspect_ratio(png_const_structrp png_ptr, png_const_inforp
- info_ptr)
-{
-#ifdef PNG_READ_pHYs_SUPPORTED
- png_debug(1, "in png_get_pixel_aspect_ratio");
-
- if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_pHYs) != 0)
- {
- if (info_ptr->x_pixels_per_unit != 0)
- return (float)info_ptr->y_pixels_per_unit
- / (float)info_ptr->x_pixels_per_unit;
- }
-#else
- PNG_UNUSED(png_ptr)
- PNG_UNUSED(info_ptr)
-#endif
-
- return (float)0.0;
-}
-#endif
-
-#ifdef PNG_FIXED_POINT_SUPPORTED
-png_fixed_point PNGAPI
-png_get_pixel_aspect_ratio_fixed(png_const_structrp png_ptr,
- png_const_inforp info_ptr)
-{
-#ifdef PNG_READ_pHYs_SUPPORTED
- png_debug(1, "in png_get_pixel_aspect_ratio_fixed");
-
- if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_pHYs) != 0 &&
- info_ptr->x_pixels_per_unit > 0 && info_ptr->y_pixels_per_unit > 0 &&
- info_ptr->x_pixels_per_unit <= PNG_UINT_31_MAX &&
- info_ptr->y_pixels_per_unit <= PNG_UINT_31_MAX)
- {
- png_fixed_point res;
-
- /* The following casts work because a PNG 4 byte integer only has a valid
- * range of 0..2^31-1; otherwise the cast might overflow.
- */
- if (png_muldiv(&res, (png_int_32)info_ptr->y_pixels_per_unit, PNG_FP_1,
- (png_int_32)info_ptr->x_pixels_per_unit) != 0)
- return res;
- }
-#else
- PNG_UNUSED(png_ptr)
- PNG_UNUSED(info_ptr)
-#endif
-
- return 0;
-}
-#endif
-
-png_int_32 PNGAPI
-png_get_x_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr)
-{
-#ifdef PNG_oFFs_SUPPORTED
- png_debug(1, "in png_get_x_offset_microns");
-
- if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_oFFs) != 0)
- {
- if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER)
- return info_ptr->x_offset;
- }
-#else
- PNG_UNUSED(png_ptr)
- PNG_UNUSED(info_ptr)
-#endif
-
- return 0;
-}
-
-png_int_32 PNGAPI
-png_get_y_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr)
-{
-#ifdef PNG_oFFs_SUPPORTED
- png_debug(1, "in png_get_y_offset_microns");
-
- if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_oFFs) != 0)
- {
- if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER)
- return info_ptr->y_offset;
- }
-#else
- PNG_UNUSED(png_ptr)
- PNG_UNUSED(info_ptr)
-#endif
-
- return 0;
-}
-
-png_int_32 PNGAPI
-png_get_x_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr)
-{
-#ifdef PNG_oFFs_SUPPORTED
- png_debug(1, "in png_get_x_offset_pixels");
-
- if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_oFFs) != 0)
- {
- if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL)
- return info_ptr->x_offset;
- }
-#else
- PNG_UNUSED(png_ptr)
- PNG_UNUSED(info_ptr)
-#endif
-
- return 0;
-}
-
-png_int_32 PNGAPI
-png_get_y_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr)
-{
-#ifdef PNG_oFFs_SUPPORTED
- png_debug(1, "in png_get_y_offset_pixels");
-
- if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_oFFs) != 0)
- {
- if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL)
- return info_ptr->y_offset;
- }
-#else
- PNG_UNUSED(png_ptr)
- PNG_UNUSED(info_ptr)
-#endif
-
- return 0;
-}
-
-#ifdef PNG_INCH_CONVERSIONS_SUPPORTED
-static png_uint_32
-ppi_from_ppm(png_uint_32 ppm)
-{
-#if 0
- /* The conversion is *(2.54/100), in binary (32 digits):
- * .00000110100000001001110101001001
- */
- png_uint_32 t1001, t1101;
- ppm >>= 1; /* .1 */
- t1001 = ppm + (ppm >> 3); /* .1001 */
- t1101 = t1001 + (ppm >> 1); /* .1101 */
- ppm >>= 20; /* .000000000000000000001 */
- t1101 += t1101 >> 15; /* .1101000000000001101 */
- t1001 >>= 11; /* .000000000001001 */
- t1001 += t1001 >> 12; /* .000000000001001000000001001 */
- ppm += t1001; /* .000000000001001000001001001 */
- ppm += t1101; /* .110100000001001110101001001 */
- return (ppm + 16) >> 5;/* .00000110100000001001110101001001 */
-#else
- /* The argument is a PNG unsigned integer, so it is not permitted
- * to be bigger than 2^31.
- */
- png_fixed_point result;
- if (ppm <= PNG_UINT_31_MAX && png_muldiv(&result, (png_int_32)ppm, 127,
- 5000) != 0)
- return (png_uint_32)result;
-
- /* Overflow. */
- return 0;
-#endif
-}
-
-png_uint_32 PNGAPI
-png_get_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr)
-{
- return ppi_from_ppm(png_get_pixels_per_meter(png_ptr, info_ptr));
-}
-
-png_uint_32 PNGAPI
-png_get_x_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr)
-{
- return ppi_from_ppm(png_get_x_pixels_per_meter(png_ptr, info_ptr));
-}
-
-png_uint_32 PNGAPI
-png_get_y_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr)
-{
- return ppi_from_ppm(png_get_y_pixels_per_meter(png_ptr, info_ptr));
-}
-
-#ifdef PNG_FIXED_POINT_SUPPORTED
-static png_fixed_point
-png_fixed_inches_from_microns(png_const_structrp png_ptr, png_int_32 microns)
-{
- /* Convert from meters * 1,000,000 to inches * 100,000, meters to
- * inches is simply *(100/2.54), so we want *(10/2.54) == 500/127.
- * Notice that this can overflow - a warning is output and 0 is
- * returned.
- */
- return png_muldiv_warn(png_ptr, microns, 500, 127);
-}
-
-png_fixed_point PNGAPI
-png_get_x_offset_inches_fixed(png_const_structrp png_ptr,
- png_const_inforp info_ptr)
-{
- return png_fixed_inches_from_microns(png_ptr,
- png_get_x_offset_microns(png_ptr, info_ptr));
-}
-#endif
-
-#ifdef PNG_FIXED_POINT_SUPPORTED
-png_fixed_point PNGAPI
-png_get_y_offset_inches_fixed(png_const_structrp png_ptr,
- png_const_inforp info_ptr)
-{
- return png_fixed_inches_from_microns(png_ptr,
- png_get_y_offset_microns(png_ptr, info_ptr));
-}
-#endif
-
-#ifdef PNG_FLOATING_POINT_SUPPORTED
-float PNGAPI
-png_get_x_offset_inches(png_const_structrp png_ptr, png_const_inforp info_ptr)
-{
- /* To avoid the overflow do the conversion directly in floating
- * point.
- */
- return (float)(png_get_x_offset_microns(png_ptr, info_ptr) * .00003937);
-}
-#endif
-
-#ifdef PNG_FLOATING_POINT_SUPPORTED
-float PNGAPI
-png_get_y_offset_inches(png_const_structrp png_ptr, png_const_inforp info_ptr)
-{
- /* To avoid the overflow do the conversion directly in floating
- * point.
- */
- return (float)(png_get_y_offset_microns(png_ptr, info_ptr) * .00003937);
-}
-#endif
-
-#ifdef PNG_pHYs_SUPPORTED
-png_uint_32 PNGAPI
-png_get_pHYs_dpi(png_const_structrp png_ptr, png_const_inforp info_ptr,
- png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
-{
- png_uint_32 retval = 0;
-
- png_debug1(1, "in %s retrieval function", "pHYs");
-
- if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_pHYs) != 0)
- {
- if (res_x != NULL)
- {
- *res_x = info_ptr->x_pixels_per_unit;
- retval |= PNG_INFO_pHYs;
- }
-
- if (res_y != NULL)
- {
- *res_y = info_ptr->y_pixels_per_unit;
- retval |= PNG_INFO_pHYs;
- }
-
- if (unit_type != NULL)
- {
- *unit_type = (int)info_ptr->phys_unit_type;
- retval |= PNG_INFO_pHYs;
-
- if (*unit_type == 1)
- {
- if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50);
- if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50);
- }
- }
- }
-
- return retval;
-}
-#endif /* pHYs */
-#endif /* INCH_CONVERSIONS */
-
-/* png_get_channels really belongs in here, too, but it's been around longer */
-
-#endif /* EASY_ACCESS */
-
-
-png_byte PNGAPI
-png_get_channels(png_const_structrp png_ptr, png_const_inforp info_ptr)
-{
- if (png_ptr != NULL && info_ptr != NULL)
- return info_ptr->channels;
-
- return 0;
-}
-
-#ifdef PNG_READ_SUPPORTED
-png_const_bytep PNGAPI
-png_get_signature(png_const_structrp png_ptr, png_const_inforp info_ptr)
-{
- if (png_ptr != NULL && info_ptr != NULL)
- return info_ptr->signature;
-
- return NULL;
-}
-#endif
-
-#ifdef PNG_bKGD_SUPPORTED
-png_uint_32 PNGAPI
-png_get_bKGD(png_const_structrp png_ptr, png_inforp info_ptr,
- png_color_16p *background)
-{
- png_debug1(1, "in %s retrieval function", "bKGD");
-
- if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_bKGD) != 0 &&
- background != NULL)
- {
- *background = &(info_ptr->background);
- return PNG_INFO_bKGD;
- }
-
- return 0;
-}
-#endif
-
-#ifdef PNG_cHRM_SUPPORTED
-/* The XYZ APIs were added in 1.5.5 to take advantage of the code added at the
- * same time to correct the rgb grayscale coefficient defaults obtained from the
- * cHRM chunk in 1.5.4
- */
-# ifdef PNG_FLOATING_POINT_SUPPORTED
-png_uint_32 PNGAPI
-png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr,
- double *white_x, double *white_y, double *red_x, double *red_y,
- double *green_x, double *green_y, double *blue_x, double *blue_y)
-{
- png_debug1(1, "in %s retrieval function", "cHRM");
-
- /* Quiet API change: this code used to only return the end points if a cHRM
- * chunk was present, but the end points can also come from iCCP or sRGB
- * chunks, so in 1.6.0 the png_get_ APIs return the end points regardless and
- * the png_set_ APIs merely check that set end points are mutually
- * consistent.
- */
- if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
- {
- if (white_x != NULL)
- *white_x = png_float(png_ptr,
- info_ptr->colorspace.end_points_xy.whitex, "cHRM white X");
- if (white_y != NULL)
- *white_y = png_float(png_ptr,
- info_ptr->colorspace.end_points_xy.whitey, "cHRM white Y");
- if (red_x != NULL)
- *red_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redx,
- "cHRM red X");
- if (red_y != NULL)
- *red_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redy,
- "cHRM red Y");
- if (green_x != NULL)
- *green_x = png_float(png_ptr,
- info_ptr->colorspace.end_points_xy.greenx, "cHRM green X");
- if (green_y != NULL)
- *green_y = png_float(png_ptr,
- info_ptr->colorspace.end_points_xy.greeny, "cHRM green Y");
- if (blue_x != NULL)
- *blue_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluex,
- "cHRM blue X");
- if (blue_y != NULL)
- *blue_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluey,
- "cHRM blue Y");
- return PNG_INFO_cHRM;
- }
-
- return 0;
-}
-
-png_uint_32 PNGAPI
-png_get_cHRM_XYZ(png_const_structrp png_ptr, png_const_inforp info_ptr,
- double *red_X, double *red_Y, double *red_Z, double *green_X,
- double *green_Y, double *green_Z, double *blue_X, double *blue_Y,
- double *blue_Z)
-{
- png_debug1(1, "in %s retrieval function", "cHRM_XYZ(float)");
-
- if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
- {
- if (red_X != NULL)
- *red_X = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_X,
- "cHRM red X");
- if (red_Y != NULL)
- *red_Y = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Y,
- "cHRM red Y");
- if (red_Z != NULL)
- *red_Z = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Z,
- "cHRM red Z");
- if (green_X != NULL)
- *green_X = png_float(png_ptr,
- info_ptr->colorspace.end_points_XYZ.green_X, "cHRM green X");
- if (green_Y != NULL)
- *green_Y = png_float(png_ptr,
- info_ptr->colorspace.end_points_XYZ.green_Y, "cHRM green Y");
- if (green_Z != NULL)
- *green_Z = png_float(png_ptr,
- info_ptr->colorspace.end_points_XYZ.green_Z, "cHRM green Z");
- if (blue_X != NULL)
- *blue_X = png_float(png_ptr,
- info_ptr->colorspace.end_points_XYZ.blue_X, "cHRM blue X");
- if (blue_Y != NULL)
- *blue_Y = png_float(png_ptr,
- info_ptr->colorspace.end_points_XYZ.blue_Y, "cHRM blue Y");
- if (blue_Z != NULL)
- *blue_Z = png_float(png_ptr,
- info_ptr->colorspace.end_points_XYZ.blue_Z, "cHRM blue Z");
- return PNG_INFO_cHRM;
- }
-
- return 0;
-}
-# endif
-
-# ifdef PNG_FIXED_POINT_SUPPORTED
-png_uint_32 PNGAPI
-png_get_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
- png_fixed_point *int_red_X, png_fixed_point *int_red_Y,
- png_fixed_point *int_red_Z, png_fixed_point *int_green_X,
- png_fixed_point *int_green_Y, png_fixed_point *int_green_Z,
- png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y,
- png_fixed_point *int_blue_Z)
-{
- png_debug1(1, "in %s retrieval function", "cHRM_XYZ");
-
- if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
- {
- if (int_red_X != NULL)
- *int_red_X = info_ptr->colorspace.end_points_XYZ.red_X;
- if (int_red_Y != NULL)
- *int_red_Y = info_ptr->colorspace.end_points_XYZ.red_Y;
- if (int_red_Z != NULL)
- *int_red_Z = info_ptr->colorspace.end_points_XYZ.red_Z;
- if (int_green_X != NULL)
- *int_green_X = info_ptr->colorspace.end_points_XYZ.green_X;
- if (int_green_Y != NULL)
- *int_green_Y = info_ptr->colorspace.end_points_XYZ.green_Y;
- if (int_green_Z != NULL)
- *int_green_Z = info_ptr->colorspace.end_points_XYZ.green_Z;
- if (int_blue_X != NULL)
- *int_blue_X = info_ptr->colorspace.end_points_XYZ.blue_X;
- if (int_blue_Y != NULL)
- *int_blue_Y = info_ptr->colorspace.end_points_XYZ.blue_Y;
- if (int_blue_Z != NULL)
- *int_blue_Z = info_ptr->colorspace.end_points_XYZ.blue_Z;
- return PNG_INFO_cHRM;
- }
-
- return 0;
-}
-
-png_uint_32 PNGAPI
-png_get_cHRM_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
- png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x,
- png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y,
- png_fixed_point *blue_x, png_fixed_point *blue_y)
-{
- png_debug1(1, "in %s retrieval function", "cHRM");
-
- if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
- {
- if (white_x != NULL)
- *white_x = info_ptr->colorspace.end_points_xy.whitex;
- if (white_y != NULL)
- *white_y = info_ptr->colorspace.end_points_xy.whitey;
- if (red_x != NULL)
- *red_x = info_ptr->colorspace.end_points_xy.redx;
- if (red_y != NULL)
- *red_y = info_ptr->colorspace.end_points_xy.redy;
- if (green_x != NULL)
- *green_x = info_ptr->colorspace.end_points_xy.greenx;
- if (green_y != NULL)
- *green_y = info_ptr->colorspace.end_points_xy.greeny;
- if (blue_x != NULL)
- *blue_x = info_ptr->colorspace.end_points_xy.bluex;
- if (blue_y != NULL)
- *blue_y = info_ptr->colorspace.end_points_xy.bluey;
- return PNG_INFO_cHRM;
- }
-
- return 0;
-}
-# endif
-#endif
-
-#ifdef PNG_gAMA_SUPPORTED
-# ifdef PNG_FIXED_POINT_SUPPORTED
-png_uint_32 PNGAPI
-png_get_gAMA_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
- png_fixed_point *file_gamma)
-{
- png_debug1(1, "in %s retrieval function", "gAMA");
-
- if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 &&
- file_gamma != NULL)
- {
- *file_gamma = info_ptr->colorspace.gamma;
- return PNG_INFO_gAMA;
- }
-
- return 0;
-}
-# endif
-
-# ifdef PNG_FLOATING_POINT_SUPPORTED
-png_uint_32 PNGAPI
-png_get_gAMA(png_const_structrp png_ptr, png_const_inforp info_ptr,
- double *file_gamma)
-{
- png_debug1(1, "in %s retrieval function", "gAMA(float)");
-
- if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 &&
- file_gamma != NULL)
- {
- *file_gamma = png_float(png_ptr, info_ptr->colorspace.gamma,
- "png_get_gAMA");
- return PNG_INFO_gAMA;
- }
-
- return 0;
-}
-# endif
-#endif
-
-#ifdef PNG_sRGB_SUPPORTED
-png_uint_32 PNGAPI
-png_get_sRGB(png_const_structrp png_ptr, png_const_inforp info_ptr,
- int *file_srgb_intent)
-{
- png_debug1(1, "in %s retrieval function", "sRGB");
-
- if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_sRGB) != 0 && file_srgb_intent != NULL)
- {
- *file_srgb_intent = info_ptr->colorspace.rendering_intent;
- return PNG_INFO_sRGB;
- }
-
- return 0;
-}
-#endif
-
-#ifdef PNG_iCCP_SUPPORTED
-png_uint_32 PNGAPI
-png_get_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
- png_charpp name, int *compression_type,
- png_bytepp profile, png_uint_32 *proflen)
-{
- png_debug1(1, "in %s retrieval function", "iCCP");
-
- if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_iCCP) != 0 &&
- name != NULL && profile != NULL && proflen != NULL)
- {
- *name = info_ptr->iccp_name;
- *profile = info_ptr->iccp_profile;
- *proflen = png_get_uint_32(info_ptr->iccp_profile);
- /* This is somewhat irrelevant since the profile data returned has
- * actually been uncompressed.
- */
- if (compression_type != NULL)
- *compression_type = PNG_COMPRESSION_TYPE_BASE;
- return PNG_INFO_iCCP;
- }
-
- return 0;
-
-}
-#endif
-
-#ifdef PNG_sPLT_SUPPORTED
-int PNGAPI
-png_get_sPLT(png_const_structrp png_ptr, png_inforp info_ptr,
- png_sPLT_tpp spalettes)
-{
- png_debug1(1, "in %s retrieval function", "sPLT");
-
- if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
- {
- *spalettes = info_ptr->splt_palettes;
- return info_ptr->splt_palettes_num;
- }
-
- return 0;
-}
-#endif
-
-#ifdef PNG_cICP_SUPPORTED
-png_uint_32 PNGAPI
-png_get_cICP(png_const_structrp png_ptr,
- png_const_inforp info_ptr, png_bytep colour_primaries,
- png_bytep transfer_function, png_bytep matrix_coefficients,
- png_bytep video_full_range_flag)
-{
- png_debug1(1, "in %s retrieval function", "cICP");
-
- if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_cICP) != 0 &&
- colour_primaries != NULL && transfer_function != NULL &&
- matrix_coefficients != NULL && video_full_range_flag != NULL)
- {
- *colour_primaries = info_ptr->cicp_colour_primaries;
- *transfer_function = info_ptr->cicp_transfer_function;
- *matrix_coefficients = info_ptr->cicp_matrix_coefficients;
- *video_full_range_flag = info_ptr->cicp_video_full_range_flag;
- return (PNG_INFO_cICP);
- }
-
- return 0;
-}
-#endif
-
-#ifdef PNG_cLLI_SUPPORTED
-# ifdef PNG_FIXED_POINT_SUPPORTED
-png_uint_32 PNGAPI
-png_get_cLLI_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
- png_uint_32p maxCLL,
- png_uint_32p maxFALL)
-{
- png_debug1(1, "in %s retrieval function", "cLLI");
-
- if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_cLLI) != 0)
- {
- if (maxCLL != NULL) *maxCLL = info_ptr->maxCLL;
- if (maxFALL != NULL) *maxFALL = info_ptr->maxFALL;
- return PNG_INFO_cLLI;
- }
-
- return 0;
-}
-# endif
-
-# ifdef PNG_FLOATING_POINT_SUPPORTED
-png_uint_32 PNGAPI
-png_get_cLLI(png_const_structrp png_ptr, png_const_inforp info_ptr,
- double *maxCLL, double *maxFALL)
-{
- png_debug1(1, "in %s retrieval function", "cLLI(float)");
-
- if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_cLLI) != 0)
- {
- if (maxCLL != NULL) *maxCLL = info_ptr->maxCLL * .0001;
- if (maxFALL != NULL) *maxFALL = info_ptr->maxFALL * .0001;
- return PNG_INFO_cLLI;
- }
-
- return 0;
-}
-# endif
-#endif /* cLLI */
-
-#ifdef PNG_mDCV_SUPPORTED
-# ifdef PNG_FIXED_POINT_SUPPORTED
-png_uint_32 PNGAPI
-png_get_mDCV_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
- png_fixed_point *white_x, png_fixed_point *white_y,
- png_fixed_point *red_x, png_fixed_point *red_y,
- png_fixed_point *green_x, png_fixed_point *green_y,
- png_fixed_point *blue_x, png_fixed_point *blue_y,
- png_uint_32p mastering_maxDL, png_uint_32p mastering_minDL)
-{
- png_debug1(1, "in %s retrieval function", "mDCV");
-
- if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_mDCV) != 0)
- {
- if (white_x != NULL) *white_x = info_ptr->mastering_white_x * 2;
- if (white_y != NULL) *white_y = info_ptr->mastering_white_y * 2;
- if (red_x != NULL) *red_x = info_ptr->mastering_red_x * 2;
- if (red_y != NULL) *red_y = info_ptr->mastering_red_y * 2;
- if (green_x != NULL) *green_x = info_ptr->mastering_green_x * 2;
- if (green_y != NULL) *green_y = info_ptr->mastering_green_y * 2;
- if (blue_x != NULL) *blue_x = info_ptr->mastering_blue_x * 2;
- if (blue_y != NULL) *blue_y = info_ptr->mastering_blue_y * 2;
- if (mastering_maxDL != NULL) *mastering_maxDL = info_ptr->mastering_maxDL;
- if (mastering_minDL != NULL) *mastering_minDL = info_ptr->mastering_minDL;
- return PNG_INFO_mDCV;
- }
-
- return 0;
-}
-# endif
-
-# ifdef PNG_FLOATING_POINT_SUPPORTED
-png_uint_32 PNGAPI
-png_get_mDCV(png_const_structrp png_ptr, png_const_inforp info_ptr,
- double *white_x, double *white_y, double *red_x, double *red_y,
- double *green_x, double *green_y, double *blue_x, double *blue_y,
- double *mastering_maxDL, double *mastering_minDL)
-{
- png_debug1(1, "in %s retrieval function", "mDCV(float)");
-
- if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_mDCV) != 0)
- {
- if (white_x != NULL) *white_x = info_ptr->mastering_white_x * .00002;
- if (white_y != NULL) *white_y = info_ptr->mastering_white_y * .00002;
- if (red_x != NULL) *red_x = info_ptr->mastering_red_x * .00002;
- if (red_y != NULL) *red_y = info_ptr->mastering_red_y * .00002;
- if (green_x != NULL) *green_x = info_ptr->mastering_green_x * .00002;
- if (green_y != NULL) *green_y = info_ptr->mastering_green_y * .00002;
- if (blue_x != NULL) *blue_x = info_ptr->mastering_blue_x * .00002;
- if (blue_y != NULL) *blue_y = info_ptr->mastering_blue_y * .00002;
- if (mastering_maxDL != NULL)
- *mastering_maxDL = info_ptr->mastering_maxDL * .0001;
- if (mastering_minDL != NULL)
- *mastering_minDL = info_ptr->mastering_minDL * .0001;
- return PNG_INFO_mDCV;
- }
-
- return 0;
-}
-# endif /* FLOATING_POINT */
-#endif /* mDCV */
-
-#ifdef PNG_eXIf_SUPPORTED
-png_uint_32 PNGAPI
-png_get_eXIf(png_const_structrp png_ptr, png_inforp info_ptr,
- png_bytep *exif)
-{
- png_warning(png_ptr, "png_get_eXIf does not work; use png_get_eXIf_1");
- PNG_UNUSED(info_ptr)
- PNG_UNUSED(exif)
- return 0;
-}
-
-png_uint_32 PNGAPI
-png_get_eXIf_1(png_const_structrp png_ptr, png_const_inforp info_ptr,
- png_uint_32 *num_exif, png_bytep *exif)
-{
- png_debug1(1, "in %s retrieval function", "eXIf");
-
- if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_eXIf) != 0 && exif != NULL)
- {
- *num_exif = info_ptr->num_exif;
- *exif = info_ptr->exif;
- return PNG_INFO_eXIf;
- }
-
- return 0;
-}
-#endif
-
-#ifdef PNG_hIST_SUPPORTED
-png_uint_32 PNGAPI
-png_get_hIST(png_const_structrp png_ptr, png_inforp info_ptr,
- png_uint_16p *hist)
-{
- png_debug1(1, "in %s retrieval function", "hIST");
-
- if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_hIST) != 0 && hist != NULL)
- {
- *hist = info_ptr->hist;
- return PNG_INFO_hIST;
- }
-
- return 0;
-}
-#endif
-
-png_uint_32 PNGAPI
-png_get_IHDR(png_const_structrp png_ptr, png_const_inforp info_ptr,
- png_uint_32 *width, png_uint_32 *height, int *bit_depth,
- int *color_type, int *interlace_type, int *compression_type,
- int *filter_type)
-{
- png_debug1(1, "in %s retrieval function", "IHDR");
-
- if (png_ptr == NULL || info_ptr == NULL)
- return 0;
-
- if (width != NULL)
- *width = info_ptr->width;
-
- if (height != NULL)
- *height = info_ptr->height;
-
- if (bit_depth != NULL)
- *bit_depth = info_ptr->bit_depth;
-
- if (color_type != NULL)
- *color_type = info_ptr->color_type;
-
- if (compression_type != NULL)
- *compression_type = info_ptr->compression_type;
-
- if (filter_type != NULL)
- *filter_type = info_ptr->filter_type;
-
- if (interlace_type != NULL)
- *interlace_type = info_ptr->interlace_type;
-
- /* This is redundant if we can be sure that the info_ptr values were all
- * assigned in png_set_IHDR(). We do the check anyhow in case an
- * application has ignored our advice not to mess with the members
- * of info_ptr directly.
- */
- png_check_IHDR(png_ptr, info_ptr->width, info_ptr->height,
- info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type,
- info_ptr->compression_type, info_ptr->filter_type);
-
- return 1;
-}
-
-#ifdef PNG_oFFs_SUPPORTED
-png_uint_32 PNGAPI
-png_get_oFFs(png_const_structrp png_ptr, png_const_inforp info_ptr,
- png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)
-{
- png_debug1(1, "in %s retrieval function", "oFFs");
-
- if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_oFFs) != 0 &&
- offset_x != NULL && offset_y != NULL && unit_type != NULL)
- {
- *offset_x = info_ptr->x_offset;
- *offset_y = info_ptr->y_offset;
- *unit_type = (int)info_ptr->offset_unit_type;
- return PNG_INFO_oFFs;
- }
-
- return 0;
-}
-#endif
-
-#ifdef PNG_pCAL_SUPPORTED
-png_uint_32 PNGAPI
-png_get_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
- png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
- png_charp *units, png_charpp *params)
-{
- png_debug1(1, "in %s retrieval function", "pCAL");
-
- if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_pCAL) != 0 &&
- purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
- nparams != NULL && units != NULL && params != NULL)
- {
- *purpose = info_ptr->pcal_purpose;
- *X0 = info_ptr->pcal_X0;
- *X1 = info_ptr->pcal_X1;
- *type = (int)info_ptr->pcal_type;
- *nparams = (int)info_ptr->pcal_nparams;
- *units = info_ptr->pcal_units;
- *params = info_ptr->pcal_params;
- return PNG_INFO_pCAL;
- }
-
- return 0;
-}
-#endif
-
-#ifdef PNG_sCAL_SUPPORTED
-# ifdef PNG_FIXED_POINT_SUPPORTED
-# if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || \
- defined(PNG_FLOATING_POINT_SUPPORTED)
-png_uint_32 PNGAPI
-png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
- int *unit, png_fixed_point *width, png_fixed_point *height)
-{
- png_debug1(1, "in %s retrieval function", "sCAL");
-
- if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_sCAL) != 0)
- {
- *unit = info_ptr->scal_unit;
- /*TODO: make this work without FP support; the API is currently eliminated
- * if neither floating point APIs nor internal floating point arithmetic
- * are enabled.
- */
- *width = png_fixed(png_ptr, atof(info_ptr->scal_s_width), "sCAL width");
- *height = png_fixed(png_ptr, atof(info_ptr->scal_s_height),
- "sCAL height");
- return PNG_INFO_sCAL;
- }
-
- return 0;
-}
-# endif /* FLOATING_ARITHMETIC */
-# endif /* FIXED_POINT */
-# ifdef PNG_FLOATING_POINT_SUPPORTED
-png_uint_32 PNGAPI
-png_get_sCAL(png_const_structrp png_ptr, png_const_inforp info_ptr,
- int *unit, double *width, double *height)
-{
- png_debug1(1, "in %s retrieval function", "sCAL(float)");
-
- if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_sCAL) != 0)
- {
- *unit = info_ptr->scal_unit;
- *width = atof(info_ptr->scal_s_width);
- *height = atof(info_ptr->scal_s_height);
- return PNG_INFO_sCAL;
- }
-
- return 0;
-}
-# endif /* FLOATING POINT */
-png_uint_32 PNGAPI
-png_get_sCAL_s(png_const_structrp png_ptr, png_const_inforp info_ptr,
- int *unit, png_charpp width, png_charpp height)
-{
- png_debug1(1, "in %s retrieval function", "sCAL(str)");
-
- if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_sCAL) != 0)
- {
- *unit = info_ptr->scal_unit;
- *width = info_ptr->scal_s_width;
- *height = info_ptr->scal_s_height;
- return PNG_INFO_sCAL;
- }
-
- return 0;
-}
-#endif /* sCAL */
-
-#ifdef PNG_pHYs_SUPPORTED
-png_uint_32 PNGAPI
-png_get_pHYs(png_const_structrp png_ptr, png_const_inforp info_ptr,
- png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
-{
- png_uint_32 retval = 0;
-
- png_debug1(1, "in %s retrieval function", "pHYs");
-
- if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_pHYs) != 0)
- {
- if (res_x != NULL)
- {
- *res_x = info_ptr->x_pixels_per_unit;
- retval |= PNG_INFO_pHYs;
- }
-
- if (res_y != NULL)
- {
- *res_y = info_ptr->y_pixels_per_unit;
- retval |= PNG_INFO_pHYs;
- }
-
- if (unit_type != NULL)
- {
- *unit_type = (int)info_ptr->phys_unit_type;
- retval |= PNG_INFO_pHYs;
- }
- }
-
- return retval;
-}
-#endif /* pHYs */
-
-png_uint_32 PNGAPI
-png_get_PLTE(png_const_structrp png_ptr, png_inforp info_ptr,
- png_colorp *palette, int *num_palette)
-{
- png_debug1(1, "in %s retrieval function", "PLTE");
-
- if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_PLTE) != 0 && palette != NULL)
- {
- *palette = info_ptr->palette;
- *num_palette = info_ptr->num_palette;
- png_debug1(3, "num_palette = %d", *num_palette);
- return PNG_INFO_PLTE;
- }
-
- return 0;
-}
-
-#ifdef PNG_sBIT_SUPPORTED
-png_uint_32 PNGAPI
-png_get_sBIT(png_const_structrp png_ptr, png_inforp info_ptr,
- png_color_8p *sig_bit)
-{
- png_debug1(1, "in %s retrieval function", "sBIT");
-
- if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_sBIT) != 0 && sig_bit != NULL)
- {
- *sig_bit = &(info_ptr->sig_bit);
- return PNG_INFO_sBIT;
- }
-
- return 0;
-}
-#endif
-
-#ifdef PNG_TEXT_SUPPORTED
-int PNGAPI
-png_get_text(png_const_structrp png_ptr, png_inforp info_ptr,
- png_textp *text_ptr, int *num_text)
-{
- if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
- {
- png_debug1(1, "in text retrieval function, chunk typeid = 0x%lx",
- (unsigned long)png_ptr->chunk_name);
-
- if (text_ptr != NULL)
- *text_ptr = info_ptr->text;
-
- if (num_text != NULL)
- *num_text = info_ptr->num_text;
-
- return info_ptr->num_text;
- }
-
- if (num_text != NULL)
- *num_text = 0;
-
- return 0;
-}
-#endif
-
-#ifdef PNG_tIME_SUPPORTED
-png_uint_32 PNGAPI
-png_get_tIME(png_const_structrp png_ptr, png_inforp info_ptr,
- png_timep *mod_time)
-{
- png_debug1(1, "in %s retrieval function", "tIME");
-
- if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_tIME) != 0 && mod_time != NULL)
- {
- *mod_time = &(info_ptr->mod_time);
- return PNG_INFO_tIME;
- }
-
- return 0;
-}
-#endif
-
-#ifdef PNG_tRNS_SUPPORTED
-png_uint_32 PNGAPI
-png_get_tRNS(png_const_structrp png_ptr, png_inforp info_ptr,
- png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color)
-{
- png_uint_32 retval = 0;
-
- png_debug1(1, "in %s retrieval function", "tRNS");
-
- if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_tRNS) != 0)
- {
- if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
- {
- if (trans_alpha != NULL)
- {
- *trans_alpha = info_ptr->trans_alpha;
- retval |= PNG_INFO_tRNS;
- }
-
- if (trans_color != NULL)
- *trans_color = &(info_ptr->trans_color);
- }
-
- else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */
- {
- if (trans_color != NULL)
- {
- *trans_color = &(info_ptr->trans_color);
- retval |= PNG_INFO_tRNS;
- }
-
- if (trans_alpha != NULL)
- *trans_alpha = NULL;
- }
-
- if (num_trans != NULL)
- {
- *num_trans = info_ptr->num_trans;
- retval |= PNG_INFO_tRNS;
- }
- }
-
- return retval;
-}
-#endif
-
-#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
-int PNGAPI
-png_get_unknown_chunks(png_const_structrp png_ptr, png_inforp info_ptr,
- png_unknown_chunkpp unknowns)
-{
- if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
- {
- *unknowns = info_ptr->unknown_chunks;
- return info_ptr->unknown_chunks_num;
- }
-
- return 0;
-}
-#endif
-
-#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
-png_byte PNGAPI
-png_get_rgb_to_gray_status(png_const_structrp png_ptr)
-{
- return (png_byte)(png_ptr ? png_ptr->rgb_to_gray_status : 0);
-}
-#endif
-
-#ifdef PNG_USER_CHUNKS_SUPPORTED
-png_voidp PNGAPI
-png_get_user_chunk_ptr(png_const_structrp png_ptr)
-{
- return (png_ptr ? png_ptr->user_chunk_ptr : NULL);
-}
-#endif
-
-size_t PNGAPI
-png_get_compression_buffer_size(png_const_structrp png_ptr)
-{
- if (png_ptr == NULL)
- return 0;
-
-#ifdef PNG_WRITE_SUPPORTED
- if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
-#endif
- {
-#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
- return png_ptr->IDAT_read_size;
-#else
- return PNG_IDAT_READ_SIZE;
-#endif
- }
-
-#ifdef PNG_WRITE_SUPPORTED
- else
- return png_ptr->zbuffer_size;
-#endif
-}
-
-#ifdef PNG_SET_USER_LIMITS_SUPPORTED
-/* These functions were added to libpng 1.2.6 and were enabled
- * by default in libpng-1.4.0 */
-png_uint_32 PNGAPI
-png_get_user_width_max(png_const_structrp png_ptr)
-{
- return (png_ptr ? png_ptr->user_width_max : 0);
-}
-
-png_uint_32 PNGAPI
-png_get_user_height_max(png_const_structrp png_ptr)
-{
- return (png_ptr ? png_ptr->user_height_max : 0);
-}
-
-/* This function was added to libpng 1.4.0 */
-png_uint_32 PNGAPI
-png_get_chunk_cache_max(png_const_structrp png_ptr)
-{
- return (png_ptr ? png_ptr->user_chunk_cache_max : 0);
-}
-
-/* This function was added to libpng 1.4.1 */
-png_alloc_size_t PNGAPI
-png_get_chunk_malloc_max(png_const_structrp png_ptr)
-{
- return (png_ptr ? png_ptr->user_chunk_malloc_max : 0);
-}
-#endif /* SET_USER_LIMITS */
-
-/* These functions were added to libpng 1.4.0 */
-#ifdef PNG_IO_STATE_SUPPORTED
-png_uint_32 PNGAPI
-png_get_io_state(png_const_structrp png_ptr)
-{
- return png_ptr->io_state;
-}
-
-png_uint_32 PNGAPI
-png_get_io_chunk_type(png_const_structrp png_ptr)
-{
- return png_ptr->chunk_name;
-}
-#endif /* IO_STATE */
-
-#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
-# ifdef PNG_GET_PALETTE_MAX_SUPPORTED
-int PNGAPI
-png_get_palette_max(png_const_structp png_ptr, png_const_infop info_ptr)
-{
- if (png_ptr != NULL && info_ptr != NULL)
- return png_ptr->num_palette_max;
-
- return -1;
-}
-# endif
-#endif
-
-#ifdef PNG_APNG_SUPPORTED
-png_uint_32 PNGAPI
-png_get_acTL(png_structp png_ptr, png_infop info_ptr,
- png_uint_32 *num_frames, png_uint_32 *num_plays)
-{
- png_debug1(1, "in %s retrieval function", "acTL");
-
- if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_acTL) != 0 &&
- num_frames != NULL && num_plays != NULL)
- {
- *num_frames = info_ptr->num_frames;
- *num_plays = info_ptr->num_plays;
- return (1);
- }
-
- return (0);
-}
-
-png_uint_32 PNGAPI
-png_get_num_frames(png_structp png_ptr, png_infop info_ptr)
-{
- png_debug(1, "in png_get_num_frames()");
-
- if (png_ptr != NULL && info_ptr != NULL)
- return (info_ptr->num_frames);
- return (0);
-}
-
-png_uint_32 PNGAPI
-png_get_num_plays(png_structp png_ptr, png_infop info_ptr)
-{
- png_debug(1, "in png_get_num_plays()");
-
- if (png_ptr != NULL && info_ptr != NULL)
- return (info_ptr->num_plays);
- return (0);
-}
-
-png_uint_32 PNGAPI
-png_get_next_frame_fcTL(png_structp png_ptr, png_infop info_ptr,
- png_uint_32 *width, png_uint_32 *height,
- png_uint_32 *x_offset, png_uint_32 *y_offset,
- png_uint_16 *delay_num, png_uint_16 *delay_den,
- png_byte *dispose_op, png_byte *blend_op)
-{
- png_debug1(1, "in %s retrieval function", "fcTL");
-
- if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_fcTL) != 0 &&
- width != NULL && height != NULL &&
- x_offset != NULL && y_offset != NULL &&
- delay_num != NULL && delay_den != NULL &&
- dispose_op != NULL && blend_op != NULL)
- {
- *width = info_ptr->next_frame_width;
- *height = info_ptr->next_frame_height;
- *x_offset = info_ptr->next_frame_x_offset;
- *y_offset = info_ptr->next_frame_y_offset;
- *delay_num = info_ptr->next_frame_delay_num;
- *delay_den = info_ptr->next_frame_delay_den;
- *dispose_op = info_ptr->next_frame_dispose_op;
- *blend_op = info_ptr->next_frame_blend_op;
- return (1);
- }
-
- return (0);
-}
-
-png_uint_32 PNGAPI
-png_get_next_frame_width(png_structp png_ptr, png_infop info_ptr)
-{
- png_debug(1, "in png_get_next_frame_width()");
-
- if (png_ptr != NULL && info_ptr != NULL)
- return (info_ptr->next_frame_width);
- return (0);
-}
-
-png_uint_32 PNGAPI
-png_get_next_frame_height(png_structp png_ptr, png_infop info_ptr)
-{
- png_debug(1, "in png_get_next_frame_height()");
-
- if (png_ptr != NULL && info_ptr != NULL)
- return (info_ptr->next_frame_height);
- return (0);
-}
-
-png_uint_32 PNGAPI
-png_get_next_frame_x_offset(png_structp png_ptr, png_infop info_ptr)
-{
- png_debug(1, "in png_get_next_frame_x_offset()");
-
- if (png_ptr != NULL && info_ptr != NULL)
- return (info_ptr->next_frame_x_offset);
- return (0);
-}
-
-png_uint_32 PNGAPI
-png_get_next_frame_y_offset(png_structp png_ptr, png_infop info_ptr)
-{
- png_debug(1, "in png_get_next_frame_y_offset()");
-
- if (png_ptr != NULL && info_ptr != NULL)
- return (info_ptr->next_frame_y_offset);
- return (0);
-}
-
-png_uint_16 PNGAPI
-png_get_next_frame_delay_num(png_structp png_ptr, png_infop info_ptr)
-{
- png_debug(1, "in png_get_next_frame_delay_num()");
-
- if (png_ptr != NULL && info_ptr != NULL)
- return (info_ptr->next_frame_delay_num);
- return (0);
-}
-
-png_uint_16 PNGAPI
-png_get_next_frame_delay_den(png_structp png_ptr, png_infop info_ptr)
-{
- png_debug(1, "in png_get_next_frame_delay_den()");
-
- if (png_ptr != NULL && info_ptr != NULL)
- return (info_ptr->next_frame_delay_den);
- return (0);
-}
-
-png_byte PNGAPI
-png_get_next_frame_dispose_op(png_structp png_ptr, png_infop info_ptr)
-{
- png_debug(1, "in png_get_next_frame_dispose_op()");
-
- if (png_ptr != NULL && info_ptr != NULL)
- return (info_ptr->next_frame_dispose_op);
- return (0);
-}
-
-png_byte PNGAPI
-png_get_next_frame_blend_op(png_structp png_ptr, png_infop info_ptr)
-{
- png_debug(1, "in png_get_next_frame_blend_op()");
-
- if (png_ptr != NULL && info_ptr != NULL)
- return (info_ptr->next_frame_blend_op);
- return (0);
-}
-
-png_byte PNGAPI
-png_get_first_frame_is_hidden(png_structp png_ptr, png_infop info_ptr)
-{
- png_debug(1, "in png_first_frame_is_hidden()");
-
- if (png_ptr != NULL)
- return (png_byte)(png_ptr->apng_flags & PNG_FIRST_FRAME_HIDDEN);
-
- PNG_UNUSED(info_ptr)
-
- return 0;
-}
-#endif /* APNG */
-#endif /* READ || WRITE */
diff --git a/contrib/libs/libpng/pnginfo.h b/contrib/libs/libpng/pnginfo.h
deleted file mode 100644
index 642f79070a..0000000000
--- a/contrib/libs/libpng/pnginfo.h
+++ /dev/null
@@ -1,305 +0,0 @@
-/* pnginfo.h - header file for PNG reference library
- *
- * Copyright (c) 2018 Cosmin Truta
- * Copyright (c) 1998-2002,2004,2006-2013,2018 Glenn Randers-Pehrson
- * Copyright (c) 1996-1997 Andreas Dilger
- * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
- *
- * This code is released under the libpng license.
- * For conditions of distribution and use, see the disclaimer
- * and license in png.h
- */
-
- /* png_info is a structure that holds the information in a PNG file so
- * that the application can find out the characteristics of the image.
- * If you are reading the file, this structure will tell you what is
- * in the PNG file. If you are writing the file, fill in the information
- * you want to put into the PNG file, using png_set_*() functions, then
- * call png_write_info().
- *
- * The names chosen should be very close to the PNG specification, so
- * consult that document for information about the meaning of each field.
- *
- * With libpng < 0.95, it was only possible to directly set and read the
- * the values in the png_info_struct, which meant that the contents and
- * order of the values had to remain fixed. With libpng 0.95 and later,
- * however, there are now functions that abstract the contents of
- * png_info_struct from the application, so this makes it easier to use
- * libpng with dynamic libraries, and even makes it possible to use
- * libraries that don't have all of the libpng ancillary chunk-handing
- * functionality. In libpng-1.5.0 this was moved into a separate private
- * file that is not visible to applications.
- *
- * The following members may have allocated storage attached that should be
- * cleaned up before the structure is discarded: palette, trans, text,
- * pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile,
- * splt_palettes, scal_unit, row_pointers, and unknowns. By default, these
- * are automatically freed when the info structure is deallocated, if they were
- * allocated internally by libpng. This behavior can be changed by means
- * of the png_data_freer() function.
- *
- * More allocation details: all the chunk-reading functions that
- * change these members go through the corresponding png_set_*
- * functions. A function to clear these members is available: see
- * png_free_data(). The png_set_* functions do not depend on being
- * able to point info structure members to any of the storage they are
- * passed (they make their own copies), EXCEPT that the png_set_text
- * functions use the same storage passed to them in the text_ptr or
- * itxt_ptr structure argument, and the png_set_rows and png_set_unknowns
- * functions do not make their own copies.
- */
-#ifndef PNGINFO_H
-#define PNGINFO_H
-
-struct png_info_def
-{
- /* The following are necessary for every PNG file */
- png_uint_32 width; /* width of image in pixels (from IHDR) */
- png_uint_32 height; /* height of image in pixels (from IHDR) */
- png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */
- size_t rowbytes; /* bytes needed to hold an untransformed row */
- png_colorp palette; /* array of color values (valid & PNG_INFO_PLTE) */
- png_uint_16 num_palette; /* number of color entries in "palette" (PLTE) */
- png_uint_16 num_trans; /* number of transparent palette color (tRNS) */
- png_byte bit_depth; /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */
- png_byte color_type; /* see PNG_COLOR_TYPE_ below (from IHDR) */
- /* The following three should have been named *_method not *_type */
- png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */
- png_byte filter_type; /* must be PNG_FILTER_TYPE_BASE (from IHDR) */
- png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
-
- /* The following are set by png_set_IHDR, called from the application on
- * write, but the are never actually used by the write code.
- */
- png_byte channels; /* number of data channels per pixel (1, 2, 3, 4) */
- png_byte pixel_depth; /* number of bits per pixel */
- png_byte spare_byte; /* to align the data, and for future use */
-
-#ifdef PNG_READ_SUPPORTED
- /* This is never set during write */
- png_byte signature[8]; /* magic bytes read by libpng from start of file */
-#endif
-
- /* The rest of the data is optional. If you are reading, check the
- * valid field to see if the information in these are valid. If you
- * are writing, set the valid field to those chunks you want written,
- * and initialize the appropriate fields below.
- */
-
-#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
- /* png_colorspace only contains 'flags' if neither GAMMA or COLORSPACE are
- * defined. When COLORSPACE is switched on all the colorspace-defining
- * chunks should be enabled, when GAMMA is switched on all the gamma-defining
- * chunks should be enabled. If this is not done it becomes possible to read
- * inconsistent PNG files and assign a probably incorrect interpretation to
- * the information. (In other words, by carefully choosing which chunks to
- * recognize the system configuration can select an interpretation for PNG
- * files containing ambiguous data and this will result in inconsistent
- * behavior between different libpng builds!)
- */
- png_colorspace colorspace;
-#endif
-
-#ifdef PNG_cICP_SUPPORTED
- /* cICP chunk data */
- png_byte cicp_colour_primaries;
- png_byte cicp_transfer_function;
- png_byte cicp_matrix_coefficients;
- png_byte cicp_video_full_range_flag;
-#endif
-
-#ifdef PNG_iCCP_SUPPORTED
- /* iCCP chunk data. */
- png_charp iccp_name; /* profile name */
- png_bytep iccp_profile; /* International Color Consortium profile data */
- png_uint_32 iccp_proflen; /* ICC profile data length */
-#endif
-
-#ifdef PNG_cLLI_SUPPORTED
- png_uint_32 maxCLL; /* cd/m2 (nits) * 10,000 */
- png_uint_32 maxFALL;
-#endif
-
-#ifdef PNG_mDCV_SUPPORTED
- png_uint_16 mastering_red_x; /* CIE (xy) x * 50,000 */
- png_uint_16 mastering_red_y;
- png_uint_16 mastering_green_x;
- png_uint_16 mastering_green_y;
- png_uint_16 mastering_blue_x;
- png_uint_16 mastering_blue_y;
- png_uint_16 mastering_white_x;
- png_uint_16 mastering_white_y;
- png_uint_32 mastering_maxDL; /* cd/m2 (nits) * 10,000 */
- png_uint_32 mastering_minDL;
-#endif
-
-#ifdef PNG_TEXT_SUPPORTED
- /* The tEXt, and zTXt chunks contain human-readable textual data in
- * uncompressed, compressed, and optionally compressed forms, respectively.
- * The data in "text" is an array of pointers to uncompressed,
- * null-terminated C strings. Each chunk has a keyword that describes the
- * textual data contained in that chunk. Keywords are not required to be
- * unique, and the text string may be empty. Any number of text chunks may
- * be in an image.
- */
- int num_text; /* number of comments read or comments to write */
- int max_text; /* current size of text array */
- png_textp text; /* array of comments read or comments to write */
-#endif /* TEXT */
-
-#ifdef PNG_tIME_SUPPORTED
- /* The tIME chunk holds the last time the displayed image data was
- * modified. See the png_time struct for the contents of this struct.
- */
- png_time mod_time;
-#endif
-
-#ifdef PNG_sBIT_SUPPORTED
- /* The sBIT chunk specifies the number of significant high-order bits
- * in the pixel data. Values are in the range [1, bit_depth], and are
- * only specified for the channels in the pixel data. The contents of
- * the low-order bits is not specified. Data is valid if
- * (valid & PNG_INFO_sBIT) is non-zero.
- */
- png_color_8 sig_bit; /* significant bits in color channels */
-#endif
-
-#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \
-defined(PNG_READ_BACKGROUND_SUPPORTED)
- /* The tRNS chunk supplies transparency data for paletted images and
- * other image types that don't need a full alpha channel. There are
- * "num_trans" transparency values for a paletted image, stored in the
- * same order as the palette colors, starting from index 0. Values
- * for the data are in the range [0, 255], ranging from fully transparent
- * to fully opaque, respectively. For non-paletted images, there is a
- * single color specified that should be treated as fully transparent.
- * Data is valid if (valid & PNG_INFO_tRNS) is non-zero.
- */
- png_bytep trans_alpha; /* alpha values for paletted image */
- png_color_16 trans_color; /* transparent color for non-palette image */
-#endif
-
-#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
- /* The bKGD chunk gives the suggested image background color if the
- * display program does not have its own background color and the image
- * is needs to composited onto a background before display. The colors
- * in "background" are normally in the same color space/depth as the
- * pixel data. Data is valid if (valid & PNG_INFO_bKGD) is non-zero.
- */
- png_color_16 background;
-#endif
-
-#ifdef PNG_oFFs_SUPPORTED
- /* The oFFs chunk gives the offset in "offset_unit_type" units rightwards
- * and downwards from the top-left corner of the display, page, or other
- * application-specific co-ordinate space. See the PNG_OFFSET_ defines
- * below for the unit types. Valid if (valid & PNG_INFO_oFFs) non-zero.
- */
- png_int_32 x_offset; /* x offset on page */
- png_int_32 y_offset; /* y offset on page */
- png_byte offset_unit_type; /* offset units type */
-#endif
-
-#ifdef PNG_pHYs_SUPPORTED
- /* The pHYs chunk gives the physical pixel density of the image for
- * display or printing in "phys_unit_type" units (see PNG_RESOLUTION_
- * defines below). Data is valid if (valid & PNG_INFO_pHYs) is non-zero.
- */
- png_uint_32 x_pixels_per_unit; /* horizontal pixel density */
- png_uint_32 y_pixels_per_unit; /* vertical pixel density */
- png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */
-#endif
-
-#ifdef PNG_eXIf_SUPPORTED
- int num_exif; /* Added at libpng-1.6.31 */
- png_bytep exif;
-# ifdef PNG_READ_eXIf_SUPPORTED
- png_bytep eXIf_buf; /* Added at libpng-1.6.32 */
-# endif
-#endif
-
-#ifdef PNG_hIST_SUPPORTED
- /* The hIST chunk contains the relative frequency or importance of the
- * various palette entries, so that a viewer can intelligently select a
- * reduced-color palette, if required. Data is an array of "num_palette"
- * values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST)
- * is non-zero.
- */
- png_uint_16p hist;
-#endif
-
-#ifdef PNG_pCAL_SUPPORTED
- /* The pCAL chunk describes a transformation between the stored pixel
- * values and original physical data values used to create the image.
- * The integer range [0, 2^bit_depth - 1] maps to the floating-point
- * range given by [pcal_X0, pcal_X1], and are further transformed by a
- * (possibly non-linear) transformation function given by "pcal_type"
- * and "pcal_params" into "pcal_units". Please see the PNG_EQUATION_
- * defines below, and the PNG-Group's PNG extensions document for a
- * complete description of the transformations and how they should be
- * implemented, and for a description of the ASCII parameter strings.
- * Data values are valid if (valid & PNG_INFO_pCAL) non-zero.
- */
- png_charp pcal_purpose; /* pCAL chunk description string */
- png_int_32 pcal_X0; /* minimum value */
- png_int_32 pcal_X1; /* maximum value */
- png_charp pcal_units; /* Latin-1 string giving physical units */
- png_charpp pcal_params; /* ASCII strings containing parameter values */
- png_byte pcal_type; /* equation type (see PNG_EQUATION_ below) */
- png_byte pcal_nparams; /* number of parameters given in pcal_params */
-#endif
-
-/* New members added in libpng-1.0.6 */
- png_uint_32 free_me; /* flags items libpng is responsible for freeing */
-
-#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
- /* Storage for unknown chunks that the library doesn't recognize. */
- png_unknown_chunkp unknown_chunks;
-
- /* The type of this field is limited by the type of
- * png_struct::user_chunk_cache_max, else overflow can occur.
- */
- int unknown_chunks_num;
-#endif
-
-#ifdef PNG_sPLT_SUPPORTED
- /* Data on sPLT chunks (there may be more than one). */
- png_sPLT_tp splt_palettes;
- int splt_palettes_num; /* Match type returned by png_get API */
-#endif
-
-#ifdef PNG_sCAL_SUPPORTED
- /* The sCAL chunk describes the actual physical dimensions of the
- * subject matter of the graphic. The chunk contains a unit specification
- * a byte value, and two ASCII strings representing floating-point
- * values. The values are width and height corresponding to one pixel
- * in the image. Data values are valid if (valid & PNG_INFO_sCAL) is
- * non-zero.
- */
- png_byte scal_unit; /* unit of physical scale */
- png_charp scal_s_width; /* string containing height */
- png_charp scal_s_height; /* string containing width */
-#endif
-
-#ifdef PNG_INFO_IMAGE_SUPPORTED
- /* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS)
- non-zero */
- /* Data valid if (valid & PNG_INFO_IDAT) non-zero */
- png_bytepp row_pointers; /* the image bits */
-#endif
-
-#ifdef PNG_APNG_SUPPORTED
- png_uint_32 num_frames; /* including default image */
- png_uint_32 num_plays;
- png_uint_32 next_frame_width;
- png_uint_32 next_frame_height;
- png_uint_32 next_frame_x_offset;
- png_uint_32 next_frame_y_offset;
- png_uint_16 next_frame_delay_num;
- png_uint_16 next_frame_delay_den;
- png_byte next_frame_dispose_op;
- png_byte next_frame_blend_op;
-#endif
-
-};
-#endif /* PNGINFO_H */
diff --git a/contrib/libs/libpng/pnglibconf.h b/contrib/libs/libpng/pnglibconf.h
deleted file mode 100644
index a8fb51d5c0..0000000000
--- a/contrib/libs/libpng/pnglibconf.h
+++ /dev/null
@@ -1,233 +0,0 @@
-/* pnglibconf.h - library build configuration */
-
-/* libpng version 1.6.46 */
-
-/* Copyright (c) 2018-2025 Cosmin Truta */
-/* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson */
-
-/* This code is released under the libpng license. */
-/* For conditions of distribution and use, see the disclaimer */
-/* and license in png.h */
-
-/* pnglibconf.h */
-/* Machine generated file: DO NOT EDIT */
-/* Derived from: scripts/pnglibconf.dfa */
-#ifndef PNGLCONF_H
-#define PNGLCONF_H
-/* options */
-#define PNG_16BIT_SUPPORTED
-#define PNG_ALIGNED_MEMORY_SUPPORTED
-/*#undef PNG_ARM_NEON_API_SUPPORTED*/
-/*#undef PNG_ARM_NEON_CHECK_SUPPORTED*/
-#define PNG_BENIGN_ERRORS_SUPPORTED
-#define PNG_BENIGN_READ_ERRORS_SUPPORTED
-/*#undef PNG_BENIGN_WRITE_ERRORS_SUPPORTED*/
-#define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED
-#define PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
-#define PNG_COLORSPACE_SUPPORTED
-#define PNG_CONSOLE_IO_SUPPORTED
-#define PNG_CONVERT_tIME_SUPPORTED
-/*#undef PNG_DISABLE_ADLER32_CHECK_SUPPORTED*/
-#define PNG_EASY_ACCESS_SUPPORTED
-/*#undef PNG_ERROR_NUMBERS_SUPPORTED*/
-#define PNG_ERROR_TEXT_SUPPORTED
-#define PNG_FIXED_POINT_SUPPORTED
-#define PNG_FLOATING_ARITHMETIC_SUPPORTED
-#define PNG_FLOATING_POINT_SUPPORTED
-#define PNG_FORMAT_AFIRST_SUPPORTED
-#define PNG_FORMAT_BGR_SUPPORTED
-#define PNG_GAMMA_SUPPORTED
-#define PNG_GET_PALETTE_MAX_SUPPORTED
-#define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
-#define PNG_INCH_CONVERSIONS_SUPPORTED
-#define PNG_INFO_IMAGE_SUPPORTED
-#define PNG_IO_STATE_SUPPORTED
-/*#undef PNG_MIPS_MMI_API_SUPPORTED*/
-/*#undef PNG_MIPS_MMI_CHECK_SUPPORTED*/
-/*#undef PNG_MIPS_MSA_API_SUPPORTED*/
-/*#undef PNG_MIPS_MSA_CHECK_SUPPORTED*/
-#define PNG_MNG_FEATURES_SUPPORTED
-#define PNG_POINTER_INDEXING_SUPPORTED
-/*#undef PNG_POWERPC_VSX_API_SUPPORTED*/
-/*#undef PNG_POWERPC_VSX_CHECK_SUPPORTED*/
-#define PNG_PROGRESSIVE_READ_SUPPORTED
-#define PNG_READ_16BIT_SUPPORTED
-#define PNG_READ_ALPHA_MODE_SUPPORTED
-#define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
-#define PNG_READ_BACKGROUND_SUPPORTED
-#define PNG_READ_BGR_SUPPORTED
-#define PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED
-#define PNG_READ_COMPOSITE_NODIV_SUPPORTED
-#define PNG_READ_COMPRESSED_TEXT_SUPPORTED
-#define PNG_READ_EXPAND_16_SUPPORTED
-#define PNG_READ_EXPAND_SUPPORTED
-#define PNG_READ_FILLER_SUPPORTED
-#define PNG_READ_GAMMA_SUPPORTED
-#define PNG_READ_GET_PALETTE_MAX_SUPPORTED
-#define PNG_READ_GRAY_TO_RGB_SUPPORTED
-#define PNG_READ_INTERLACING_SUPPORTED
-#define PNG_READ_INT_FUNCTIONS_SUPPORTED
-#define PNG_READ_INVERT_ALPHA_SUPPORTED
-#define PNG_READ_INVERT_SUPPORTED
-#define PNG_READ_OPT_PLTE_SUPPORTED
-#define PNG_READ_PACKSWAP_SUPPORTED
-#define PNG_READ_PACK_SUPPORTED
-#define PNG_READ_QUANTIZE_SUPPORTED
-#define PNG_READ_RGB_TO_GRAY_SUPPORTED
-#define PNG_READ_SCALE_16_TO_8_SUPPORTED
-#define PNG_READ_SHIFT_SUPPORTED
-#define PNG_READ_STRIP_16_TO_8_SUPPORTED
-#define PNG_READ_STRIP_ALPHA_SUPPORTED
-#define PNG_READ_SUPPORTED
-#define PNG_READ_SWAP_ALPHA_SUPPORTED
-#define PNG_READ_SWAP_SUPPORTED
-#define PNG_READ_TEXT_SUPPORTED
-#define PNG_READ_TRANSFORMS_SUPPORTED
-#define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
-#define PNG_READ_USER_CHUNKS_SUPPORTED
-#define PNG_READ_USER_TRANSFORM_SUPPORTED
-#define PNG_READ_bKGD_SUPPORTED
-#define PNG_READ_cHRM_SUPPORTED
-#define PNG_READ_cICP_SUPPORTED
-#define PNG_READ_cLLI_SUPPORTED
-#define PNG_READ_eXIf_SUPPORTED
-#define PNG_READ_gAMA_SUPPORTED
-#define PNG_READ_hIST_SUPPORTED
-#define PNG_READ_iCCP_SUPPORTED
-#define PNG_READ_iTXt_SUPPORTED
-#define PNG_READ_mDCV_SUPPORTED
-#define PNG_READ_oFFs_SUPPORTED
-#define PNG_READ_pCAL_SUPPORTED
-#define PNG_READ_pHYs_SUPPORTED
-#define PNG_READ_sBIT_SUPPORTED
-#define PNG_READ_sCAL_SUPPORTED
-#define PNG_READ_sPLT_SUPPORTED
-#define PNG_READ_sRGB_SUPPORTED
-#define PNG_READ_tEXt_SUPPORTED
-#define PNG_READ_tIME_SUPPORTED
-#define PNG_READ_tRNS_SUPPORTED
-#define PNG_READ_zTXt_SUPPORTED
-#define PNG_SAVE_INT_32_SUPPORTED
-#define PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
-#define PNG_SEQUENTIAL_READ_SUPPORTED
-#define PNG_SETJMP_SUPPORTED
-#define PNG_SET_OPTION_SUPPORTED
-#define PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
-#define PNG_SET_USER_LIMITS_SUPPORTED
-#define PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED
-#define PNG_SIMPLIFIED_READ_BGR_SUPPORTED
-#define PNG_SIMPLIFIED_READ_SUPPORTED
-#define PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED
-#define PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED
-#define PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED
-#define PNG_SIMPLIFIED_WRITE_SUPPORTED
-#define PNG_STDIO_SUPPORTED
-#define PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
-#define PNG_TEXT_SUPPORTED
-#define PNG_TIME_RFC1123_SUPPORTED
-#define PNG_UNKNOWN_CHUNKS_SUPPORTED
-#define PNG_USER_CHUNKS_SUPPORTED
-#define PNG_USER_LIMITS_SUPPORTED
-#define PNG_USER_MEM_SUPPORTED
-#define PNG_USER_TRANSFORM_INFO_SUPPORTED
-#define PNG_USER_TRANSFORM_PTR_SUPPORTED
-#define PNG_WARNINGS_SUPPORTED
-#define PNG_WRITE_16BIT_SUPPORTED
-#define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
-#define PNG_WRITE_BGR_SUPPORTED
-#define PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
-#define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED
-#define PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED
-#define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
-#define PNG_WRITE_FILLER_SUPPORTED
-#define PNG_WRITE_FILTER_SUPPORTED
-#define PNG_WRITE_FLUSH_SUPPORTED
-#define PNG_WRITE_GET_PALETTE_MAX_SUPPORTED
-#define PNG_WRITE_INTERLACING_SUPPORTED
-#define PNG_WRITE_INT_FUNCTIONS_SUPPORTED
-#define PNG_WRITE_INVERT_ALPHA_SUPPORTED
-#define PNG_WRITE_INVERT_SUPPORTED
-#define PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
-#define PNG_WRITE_PACKSWAP_SUPPORTED
-#define PNG_WRITE_PACK_SUPPORTED
-#define PNG_WRITE_SHIFT_SUPPORTED
-#define PNG_WRITE_SUPPORTED
-#define PNG_WRITE_SWAP_ALPHA_SUPPORTED
-#define PNG_WRITE_SWAP_SUPPORTED
-#define PNG_WRITE_TEXT_SUPPORTED
-#define PNG_WRITE_TRANSFORMS_SUPPORTED
-#define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
-#define PNG_WRITE_USER_TRANSFORM_SUPPORTED
-#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
-#define PNG_WRITE_bKGD_SUPPORTED
-#define PNG_WRITE_cHRM_SUPPORTED
-#define PNG_WRITE_cICP_SUPPORTED
-#define PNG_WRITE_cLLI_SUPPORTED
-#define PNG_WRITE_eXIf_SUPPORTED
-#define PNG_WRITE_gAMA_SUPPORTED
-#define PNG_WRITE_hIST_SUPPORTED
-#define PNG_WRITE_iCCP_SUPPORTED
-#define PNG_WRITE_iTXt_SUPPORTED
-#define PNG_WRITE_mDCV_SUPPORTED
-#define PNG_WRITE_oFFs_SUPPORTED
-#define PNG_WRITE_pCAL_SUPPORTED
-#define PNG_WRITE_pHYs_SUPPORTED
-#define PNG_WRITE_sBIT_SUPPORTED
-#define PNG_WRITE_sCAL_SUPPORTED
-#define PNG_WRITE_sPLT_SUPPORTED
-#define PNG_WRITE_sRGB_SUPPORTED
-#define PNG_WRITE_tEXt_SUPPORTED
-#define PNG_WRITE_tIME_SUPPORTED
-#define PNG_WRITE_tRNS_SUPPORTED
-#define PNG_WRITE_zTXt_SUPPORTED
-#define PNG_bKGD_SUPPORTED
-#define PNG_cHRM_SUPPORTED
-#define PNG_cICP_SUPPORTED
-#define PNG_cLLI_SUPPORTED
-#define PNG_eXIf_SUPPORTED
-#define PNG_gAMA_SUPPORTED
-#define PNG_hIST_SUPPORTED
-#define PNG_iCCP_SUPPORTED
-#define PNG_iTXt_SUPPORTED
-#define PNG_mDCV_SUPPORTED
-#define PNG_oFFs_SUPPORTED
-#define PNG_pCAL_SUPPORTED
-#define PNG_pHYs_SUPPORTED
-#define PNG_sBIT_SUPPORTED
-#define PNG_sCAL_SUPPORTED
-#define PNG_sPLT_SUPPORTED
-#define PNG_sRGB_SUPPORTED
-#define PNG_tEXt_SUPPORTED
-#define PNG_tIME_SUPPORTED
-#define PNG_tRNS_SUPPORTED
-#define PNG_zTXt_SUPPORTED
-/* end of options */
-/* settings */
-#define PNG_API_RULE 0
-#define PNG_DEFAULT_READ_MACROS 1
-#define PNG_GAMMA_THRESHOLD_FIXED 5000
-#define PNG_IDAT_READ_SIZE PNG_ZBUF_SIZE
-#define PNG_INFLATE_BUF_SIZE 1024
-#define PNG_LINKAGE_API extern
-#define PNG_LINKAGE_CALLBACK extern
-#define PNG_LINKAGE_DATA extern
-#define PNG_LINKAGE_FUNCTION extern
-#define PNG_MAX_GAMMA_8 11
-#define PNG_QUANTIZE_BLUE_BITS 5
-#define PNG_QUANTIZE_GREEN_BITS 5
-#define PNG_QUANTIZE_RED_BITS 5
-#define PNG_TEXT_Z_DEFAULT_COMPRESSION (-1)
-#define PNG_TEXT_Z_DEFAULT_STRATEGY 0
-#define PNG_USER_CHUNK_CACHE_MAX 32765
-#define PNG_USER_CHUNK_MALLOC_MAX 8000000
-#define PNG_USER_HEIGHT_MAX 1000000
-#define PNG_USER_WIDTH_MAX 1000000
-#define PNG_ZBUF_SIZE 8192
-#define PNG_ZLIB_VERNUM ZLIB_VERNUM
-#define PNG_Z_DEFAULT_COMPRESSION (-1)
-#define PNG_Z_DEFAULT_NOFILTER_STRATEGY 0
-#define PNG_Z_DEFAULT_STRATEGY 1
-#define PNG_sCAL_PRECISION 5
-#define PNG_sRGB_PROFILE_CHECKS 2
-/* end of settings */
-#endif /* PNGLCONF_H */
diff --git a/contrib/libs/libpng/pngmem.c b/contrib/libs/libpng/pngmem.c
deleted file mode 100644
index d391c13ff4..0000000000
--- a/contrib/libs/libpng/pngmem.c
+++ /dev/null
@@ -1,283 +0,0 @@
-/* pngmem.c - stub functions for memory allocation
- *
- * Copyright (c) 2018 Cosmin Truta
- * Copyright (c) 1998-2002,2004,2006-2014,2016 Glenn Randers-Pehrson
- * Copyright (c) 1996-1997 Andreas Dilger
- * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
- *
- * This code is released under the libpng license.
- * For conditions of distribution and use, see the disclaimer
- * and license in png.h
- *
- * This file provides a location for all memory allocation. Users who
- * need special memory handling are expected to supply replacement
- * functions for png_malloc() and png_free(), and to use
- * png_create_read_struct_2() and png_create_write_struct_2() to
- * identify the replacement functions.
- */
-
-#include "pngpriv.h"
-
-#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
-/* Free a png_struct */
-void /* PRIVATE */
-png_destroy_png_struct(png_structrp png_ptr)
-{
- if (png_ptr != NULL)
- {
- /* png_free might call png_error and may certainly call
- * png_get_mem_ptr, so fake a temporary png_struct to support this.
- */
- png_struct dummy_struct = *png_ptr;
- memset(png_ptr, 0, (sizeof *png_ptr));
- png_free(&dummy_struct, png_ptr);
-
-# ifdef PNG_SETJMP_SUPPORTED
- /* We may have a jmp_buf left to deallocate. */
- png_free_jmpbuf(&dummy_struct);
-# endif
- }
-}
-
-/* Allocate memory. For reasonable files, size should never exceed
- * 64K. However, zlib may allocate more than 64K if you don't tell
- * it not to. See zconf.h and png.h for more information. zlib does
- * need to allocate exactly 64K, so whatever you call here must
- * have the ability to do that.
- */
-PNG_FUNCTION(png_voidp,PNGAPI
-png_calloc,(png_const_structrp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
-{
- png_voidp ret;
-
- ret = png_malloc(png_ptr, size);
-
- if (ret != NULL)
- memset(ret, 0, size);
-
- return ret;
-}
-
-/* png_malloc_base, an internal function added at libpng 1.6.0, does the work of
- * allocating memory, taking into account limits and PNG_USER_MEM_SUPPORTED.
- * Checking and error handling must happen outside this routine; it returns NULL
- * if the allocation cannot be done (for any reason.)
- */
-PNG_FUNCTION(png_voidp /* PRIVATE */,
-png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size),
- PNG_ALLOCATED)
-{
- /* Moved to png_malloc_base from png_malloc_default in 1.6.0; the DOS
- * allocators have also been removed in 1.6.0, so any 16-bit system now has
- * to implement a user memory handler. This checks to be sure it isn't
- * called with big numbers.
- */
-#ifndef PNG_USER_MEM_SUPPORTED
- PNG_UNUSED(png_ptr)
-#endif
-
- /* Some compilers complain that this is always true. However, it
- * can be false when integer overflow happens.
- */
- if (size > 0 && size <= PNG_SIZE_MAX
-# ifdef PNG_MAX_MALLOC_64K
- && size <= 65536U
-# endif
- )
- {
-#ifdef PNG_USER_MEM_SUPPORTED
- if (png_ptr != NULL && png_ptr->malloc_fn != NULL)
- return png_ptr->malloc_fn(png_constcast(png_structrp,png_ptr), size);
-
- else
-#endif
- return malloc((size_t)size); /* checked for truncation above */
- }
-
- else
- return NULL;
-}
-
-#if defined(PNG_TEXT_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) ||\
- defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED)
-/* This is really here only to work round a spurious warning in GCC 4.6 and 4.7
- * that arises because of the checks in png_realloc_array that are repeated in
- * png_malloc_array.
- */
-static png_voidp
-png_malloc_array_checked(png_const_structrp png_ptr, int nelements,
- size_t element_size)
-{
- png_alloc_size_t req = (png_alloc_size_t)nelements; /* known to be > 0 */
-
- if (req <= PNG_SIZE_MAX/element_size)
- return png_malloc_base(png_ptr, req * element_size);
-
- /* The failure case when the request is too large */
- return NULL;
-}
-
-PNG_FUNCTION(png_voidp /* PRIVATE */,
-png_malloc_array,(png_const_structrp png_ptr, int nelements,
- size_t element_size),PNG_ALLOCATED)
-{
- if (nelements <= 0 || element_size == 0)
- png_error(png_ptr, "internal error: array alloc");
-
- return png_malloc_array_checked(png_ptr, nelements, element_size);
-}
-
-PNG_FUNCTION(png_voidp /* PRIVATE */,
-png_realloc_array,(png_const_structrp png_ptr, png_const_voidp old_array,
- int old_elements, int add_elements, size_t element_size),PNG_ALLOCATED)
-{
- /* These are internal errors: */
- if (add_elements <= 0 || element_size == 0 || old_elements < 0 ||
- (old_array == NULL && old_elements > 0))
- png_error(png_ptr, "internal error: array realloc");
-
- /* Check for overflow on the elements count (so the caller does not have to
- * check.)
- */
- if (add_elements <= INT_MAX - old_elements)
- {
- png_voidp new_array = png_malloc_array_checked(png_ptr,
- old_elements+add_elements, element_size);
-
- if (new_array != NULL)
- {
- /* Because png_malloc_array worked the size calculations below cannot
- * overflow.
- */
- if (old_elements > 0)
- memcpy(new_array, old_array, element_size*(unsigned)old_elements);
-
- memset((char*)new_array + element_size*(unsigned)old_elements, 0,
- element_size*(unsigned)add_elements);
-
- return new_array;
- }
- }
-
- return NULL; /* error */
-}
-#endif /* TEXT || sPLT || STORE_UNKNOWN_CHUNKS */
-
-/* Various functions that have different error handling are derived from this.
- * png_malloc always exists, but if PNG_USER_MEM_SUPPORTED is defined a separate
- * function png_malloc_default is also provided.
- */
-PNG_FUNCTION(png_voidp,PNGAPI
-png_malloc,(png_const_structrp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
-{
- png_voidp ret;
-
- if (png_ptr == NULL)
- return NULL;
-
- ret = png_malloc_base(png_ptr, size);
-
- if (ret == NULL)
- png_error(png_ptr, "Out of memory"); /* 'm' means png_malloc */
-
- return ret;
-}
-
-#ifdef PNG_USER_MEM_SUPPORTED
-PNG_FUNCTION(png_voidp,PNGAPI
-png_malloc_default,(png_const_structrp png_ptr, png_alloc_size_t size),
- PNG_ALLOCATED PNG_DEPRECATED)
-{
- png_voidp ret;
-
- if (png_ptr == NULL)
- return NULL;
-
- /* Passing 'NULL' here bypasses the application provided memory handler. */
- ret = png_malloc_base(NULL/*use malloc*/, size);
-
- if (ret == NULL)
- png_error(png_ptr, "Out of Memory"); /* 'M' means png_malloc_default */
-
- return ret;
-}
-#endif /* USER_MEM */
-
-/* This function was added at libpng version 1.2.3. The png_malloc_warn()
- * function will issue a png_warning and return NULL instead of issuing a
- * png_error, if it fails to allocate the requested memory.
- */
-PNG_FUNCTION(png_voidp,PNGAPI
-png_malloc_warn,(png_const_structrp png_ptr, png_alloc_size_t size),
- PNG_ALLOCATED)
-{
- if (png_ptr != NULL)
- {
- png_voidp ret = png_malloc_base(png_ptr, size);
-
- if (ret != NULL)
- return ret;
-
- png_warning(png_ptr, "Out of memory");
- }
-
- return NULL;
-}
-
-/* Free a pointer allocated by png_malloc(). If ptr is NULL, return
- * without taking any action.
- */
-void PNGAPI
-png_free(png_const_structrp png_ptr, png_voidp ptr)
-{
- if (png_ptr == NULL || ptr == NULL)
- return;
-
-#ifdef PNG_USER_MEM_SUPPORTED
- if (png_ptr->free_fn != NULL)
- png_ptr->free_fn(png_constcast(png_structrp,png_ptr), ptr);
-
- else
- png_free_default(png_ptr, ptr);
-}
-
-PNG_FUNCTION(void,PNGAPI
-png_free_default,(png_const_structrp png_ptr, png_voidp ptr),PNG_DEPRECATED)
-{
- if (png_ptr == NULL || ptr == NULL)
- return;
-#endif /* USER_MEM */
-
- free(ptr);
-}
-
-#ifdef PNG_USER_MEM_SUPPORTED
-/* This function is called when the application wants to use another method
- * of allocating and freeing memory.
- */
-void PNGAPI
-png_set_mem_fn(png_structrp png_ptr, png_voidp mem_ptr, png_malloc_ptr
- malloc_fn, png_free_ptr free_fn)
-{
- if (png_ptr != NULL)
- {
- png_ptr->mem_ptr = mem_ptr;
- png_ptr->malloc_fn = malloc_fn;
- png_ptr->free_fn = free_fn;
- }
-}
-
-/* This function returns a pointer to the mem_ptr associated with the user
- * functions. The application should free any memory associated with this
- * pointer before png_write_destroy and png_read_destroy are called.
- */
-png_voidp PNGAPI
-png_get_mem_ptr(png_const_structrp png_ptr)
-{
- if (png_ptr == NULL)
- return NULL;
-
- return png_ptr->mem_ptr;
-}
-#endif /* USER_MEM */
-#endif /* READ || WRITE */
diff --git a/contrib/libs/libpng/pngpread.c b/contrib/libs/libpng/pngpread.c
deleted file mode 100644
index fa0ccda99b..0000000000
--- a/contrib/libs/libpng/pngpread.c
+++ /dev/null
@@ -1,1290 +0,0 @@
-/* pngpread.c - read a png file in push mode
- *
- * Copyright (c) 2018-2024 Cosmin Truta
- * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
- * Copyright (c) 1996-1997 Andreas Dilger
- * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
- *
- * This code is released under the libpng license.
- * For conditions of distribution and use, see the disclaimer
- * and license in png.h
- */
-
-#include "pngpriv.h"
-
-#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
-
-/* Push model modes */
-#define PNG_READ_SIG_MODE 0
-#define PNG_READ_CHUNK_MODE 1
-#define PNG_READ_IDAT_MODE 2
-#define PNG_READ_tEXt_MODE 4
-#define PNG_READ_zTXt_MODE 5
-#define PNG_READ_DONE_MODE 6
-#define PNG_READ_iTXt_MODE 7
-#define PNG_ERROR_MODE 8
-
-#define PNG_PUSH_SAVE_BUFFER_IF_FULL \
-if (png_ptr->push_length + 4 > png_ptr->buffer_size) \
- { png_push_save_buffer(png_ptr); return; }
-#define PNG_PUSH_SAVE_BUFFER_IF_LT(N) \
-if (png_ptr->buffer_size < N) \
- { png_push_save_buffer(png_ptr); return; }
-
-#ifdef PNG_READ_INTERLACING_SUPPORTED
-/* Arrays to facilitate interlacing - use pass (0 - 6) as index. */
-
-/* Start of interlace block */
-static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
-/* Offset to next interlace block */
-static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
-/* Start of interlace block in the y direction */
-static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
-/* Offset to next interlace block in the y direction */
-static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
-
-/* TODO: Move these arrays to a common utility module to avoid duplication. */
-#endif
-
-void PNGAPI
-png_process_data(png_structrp png_ptr, png_inforp info_ptr,
- png_bytep buffer, size_t buffer_size)
-{
- if (png_ptr == NULL || info_ptr == NULL)
- return;
-
- png_push_restore_buffer(png_ptr, buffer, buffer_size);
-
- while (png_ptr->buffer_size)
- {
- png_process_some_data(png_ptr, info_ptr);
- }
-}
-
-size_t PNGAPI
-png_process_data_pause(png_structrp png_ptr, int save)
-{
- if (png_ptr != NULL)
- {
- /* It's easiest for the caller if we do the save; then the caller doesn't
- * have to supply the same data again:
- */
- if (save != 0)
- png_push_save_buffer(png_ptr);
- else
- {
- /* This includes any pending saved bytes: */
- size_t remaining = png_ptr->buffer_size;
- png_ptr->buffer_size = 0;
-
- /* So subtract the saved buffer size, unless all the data
- * is actually 'saved', in which case we just return 0
- */
- if (png_ptr->save_buffer_size < remaining)
- return remaining - png_ptr->save_buffer_size;
- }
- }
-
- return 0;
-}
-
-png_uint_32 PNGAPI
-png_process_data_skip(png_structrp png_ptr)
-{
-/* TODO: Deprecate and remove this API.
- * Somewhere the implementation of this seems to have been lost,
- * or abandoned. It was only to support some internal back-door access
- * to png_struct) in libpng-1.4.x.
- */
- png_app_warning(png_ptr,
-"png_process_data_skip is not implemented in any current version of libpng");
- return 0;
-}
-
-/* What we do with the incoming data depends on what we were previously
- * doing before we ran out of data...
- */
-void /* PRIVATE */
-png_process_some_data(png_structrp png_ptr, png_inforp info_ptr)
-{
- if (png_ptr == NULL)
- return;
-
- switch (png_ptr->process_mode)
- {
- case PNG_READ_SIG_MODE:
- {
- png_push_read_sig(png_ptr, info_ptr);
- break;
- }
-
- case PNG_READ_CHUNK_MODE:
- {
- png_push_read_chunk(png_ptr, info_ptr);
- break;
- }
-
- case PNG_READ_IDAT_MODE:
- {
- png_push_read_IDAT(png_ptr);
- break;
- }
-
- default:
- {
- png_ptr->buffer_size = 0;
- break;
- }
- }
-}
-
-/* Read any remaining signature bytes from the stream and compare them with
- * the correct PNG signature. It is possible that this routine is called
- * with bytes already read from the signature, either because they have been
- * checked by the calling application, or because of multiple calls to this
- * routine.
- */
-void /* PRIVATE */
-png_push_read_sig(png_structrp png_ptr, png_inforp info_ptr)
-{
- size_t num_checked = png_ptr->sig_bytes; /* SAFE, does not exceed 8 */
- size_t num_to_check = 8 - num_checked;
-
- if (png_ptr->buffer_size < num_to_check)
- {
- num_to_check = png_ptr->buffer_size;
- }
-
- png_push_fill_buffer(png_ptr, &(info_ptr->signature[num_checked]),
- num_to_check);
- png_ptr->sig_bytes = (png_byte)(png_ptr->sig_bytes + num_to_check);
-
- if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check) != 0)
- {
- if (num_checked < 4 &&
- png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4) != 0)
- png_error(png_ptr, "Not a PNG file");
-
- else
- png_error(png_ptr, "PNG file corrupted by ASCII conversion");
- }
- else
- {
- if (png_ptr->sig_bytes >= 8)
- {
- png_ptr->process_mode = PNG_READ_CHUNK_MODE;
- }
- }
-}
-
-void /* PRIVATE */
-png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
-{
- png_uint_32 chunk_name;
-#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
- int keep; /* unknown handling method */
-#endif
-
- /* First we make sure we have enough data for the 4-byte chunk name
- * and the 4-byte chunk length before proceeding with decoding the
- * chunk data. To fully decode each of these chunks, we also make
- * sure we have enough data in the buffer for the 4-byte CRC at the
- * end of every chunk (except IDAT, which is handled separately).
- */
- if ((png_ptr->mode & PNG_HAVE_CHUNK_HEADER) == 0)
- {
- png_byte chunk_length[4];
- png_byte chunk_tag[4];
-
- PNG_PUSH_SAVE_BUFFER_IF_LT(8)
- png_push_fill_buffer(png_ptr, chunk_length, 4);
- png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length);
- png_reset_crc(png_ptr);
- png_crc_read(png_ptr, chunk_tag, 4);
- png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(chunk_tag);
- png_check_chunk_name(png_ptr, png_ptr->chunk_name);
- png_check_chunk_length(png_ptr, png_ptr->push_length);
- png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
- }
-
- chunk_name = png_ptr->chunk_name;
-
-#ifdef PNG_READ_APNG_SUPPORTED
- if (png_ptr->num_frames_read > 0 &&
- png_ptr->num_frames_read < info_ptr->num_frames)
- {
- if (chunk_name == png_IDAT)
- {
- /* Discard trailing IDATs for the first frame */
- if ((png_ptr->mode & PNG_HAVE_fcTL) != 0 ||
- png_ptr->num_frames_read > 1)
- png_error(png_ptr, "out of place IDAT");
-
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_crc_finish(png_ptr, png_ptr->push_length);
- png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
- }
-
- else if (chunk_name == png_fdAT)
- {
- PNG_PUSH_SAVE_BUFFER_IF_LT(4)
- png_ensure_sequence_number(png_ptr, 4);
-
- if ((png_ptr->mode & PNG_HAVE_fcTL) == 0)
- {
- /* Discard trailing fdATs for frames other than the first */
- if (png_ptr->num_frames_read < 2)
- png_error(png_ptr, "out of place fdAT");
-
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_crc_finish(png_ptr, png_ptr->push_length);
- png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
- }
-
- else
- {
- /* frame data follows */
- png_ptr->idat_size = png_ptr->push_length - 4;
- png_ptr->mode |= PNG_HAVE_IDAT;
- png_ptr->process_mode = PNG_READ_IDAT_MODE;
- }
- }
-
- else if (chunk_name == png_fcTL)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_read_reset(png_ptr);
- png_ptr->mode &= ~PNG_HAVE_fcTL;
-
- png_handle_fcTL(png_ptr, info_ptr, png_ptr->push_length);
-
- if ((png_ptr->mode & PNG_HAVE_fcTL) == 0)
- png_error(png_ptr, "missing required fcTL chunk");
-
- png_read_reinit(png_ptr, info_ptr);
- png_progressive_read_reset(png_ptr);
-
- if (png_ptr->frame_info_fn != NULL)
- (*(png_ptr->frame_info_fn))(png_ptr, png_ptr->num_frames_read);
-
- png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
- }
-
- else if (chunk_name == png_IEND)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_warning(png_ptr, "Number of actual frames fewer than expected");
- png_crc_finish(png_ptr, png_ptr->push_length);
- png_ptr->process_mode = PNG_READ_DONE_MODE;
- png_push_have_end(png_ptr, info_ptr);
- }
-
- else
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_warning(png_ptr, "Skipped (ignored) a chunk "
- "between APNG chunks");
- png_crc_finish(png_ptr, png_ptr->push_length);
- png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
- }
-
- return;
- }
-#endif /* READ_APNG */
-
- if (chunk_name == png_IDAT)
- {
- if ((png_ptr->mode & PNG_AFTER_IDAT) != 0)
- png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
-
- /* If we reach an IDAT chunk, this means we have read all of the
- * header chunks, and we can start reading the image (or if this
- * is called after the image has been read - we have an error).
- */
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_error(png_ptr, "Missing IHDR before IDAT");
-
- else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
- (png_ptr->mode & PNG_HAVE_PLTE) == 0)
- png_error(png_ptr, "Missing PLTE before IDAT");
-
- png_ptr->process_mode = PNG_READ_IDAT_MODE;
-
- if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
- if ((png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) == 0)
- if (png_ptr->push_length == 0)
- return;
-
- png_ptr->mode |= PNG_HAVE_IDAT;
-
- if ((png_ptr->mode & PNG_AFTER_IDAT) != 0)
- png_benign_error(png_ptr, "Too many IDATs found");
- }
-
- if (chunk_name == png_IHDR)
- {
- if (png_ptr->push_length != 13)
- png_error(png_ptr, "Invalid IHDR length");
-
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_IHDR(png_ptr, info_ptr, png_ptr->push_length);
- }
-
- else if (chunk_name == png_IEND)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_IEND(png_ptr, info_ptr, png_ptr->push_length);
-
- png_ptr->process_mode = PNG_READ_DONE_MODE;
- png_push_have_end(png_ptr, info_ptr);
- }
-
-#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
- else if ((keep = png_chunk_unknown_handling(png_ptr, chunk_name)) != 0)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length, keep);
-
- if (chunk_name == png_PLTE)
- png_ptr->mode |= PNG_HAVE_PLTE;
- }
-#endif
-
- else if (chunk_name == png_PLTE)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_PLTE(png_ptr, info_ptr, png_ptr->push_length);
- }
-
- else if (chunk_name == png_IDAT)
- {
-#ifdef PNG_READ_APNG_SUPPORTED
- png_have_info(png_ptr, info_ptr);
-#endif
- png_ptr->idat_size = png_ptr->push_length;
- png_ptr->process_mode = PNG_READ_IDAT_MODE;
- png_push_have_info(png_ptr, info_ptr);
- png_ptr->zstream.avail_out =
- (uInt) PNG_ROWBYTES(png_ptr->pixel_depth,
- png_ptr->iwidth) + 1;
- png_ptr->zstream.next_out = png_ptr->row_buf;
- return;
- }
-
-#ifdef PNG_READ_gAMA_SUPPORTED
- else if (png_ptr->chunk_name == png_gAMA)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_gAMA(png_ptr, info_ptr, png_ptr->push_length);
- }
-
-#endif
-#ifdef PNG_READ_sBIT_SUPPORTED
- else if (png_ptr->chunk_name == png_sBIT)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_sBIT(png_ptr, info_ptr, png_ptr->push_length);
- }
-
-#endif
-#ifdef PNG_READ_cHRM_SUPPORTED
- else if (png_ptr->chunk_name == png_cHRM)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_cHRM(png_ptr, info_ptr, png_ptr->push_length);
- }
-
-#endif
-#ifdef PNG_READ_cICP_SUPPORTED
- else if (png_ptr->chunk_name == png_cICP)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_cICP(png_ptr, info_ptr, png_ptr->push_length);
- }
-
-#endif
-#ifdef PNG_READ_cLLI_SUPPORTED
- else if (png_ptr->chunk_name == png_cLLI)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_cLLI(png_ptr, info_ptr, png_ptr->push_length);
- }
-
-#endif
-#ifdef PNG_READ_mDCV_SUPPORTED
- else if (png_ptr->chunk_name == png_mDCV)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_mDCV(png_ptr, info_ptr, png_ptr->push_length);
- }
-
-#endif
-#ifdef PNG_READ_eXIf_SUPPORTED
- else if (png_ptr->chunk_name == png_eXIf)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_eXIf(png_ptr, info_ptr, png_ptr->push_length);
- }
-
-#endif
-#ifdef PNG_READ_sRGB_SUPPORTED
- else if (chunk_name == png_sRGB)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_sRGB(png_ptr, info_ptr, png_ptr->push_length);
- }
-
-#endif
-#ifdef PNG_READ_iCCP_SUPPORTED
- else if (png_ptr->chunk_name == png_iCCP)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_iCCP(png_ptr, info_ptr, png_ptr->push_length);
- }
-
-#endif
-#ifdef PNG_READ_sPLT_SUPPORTED
- else if (chunk_name == png_sPLT)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_sPLT(png_ptr, info_ptr, png_ptr->push_length);
- }
-
-#endif
-#ifdef PNG_READ_tRNS_SUPPORTED
- else if (chunk_name == png_tRNS)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_tRNS(png_ptr, info_ptr, png_ptr->push_length);
- }
-
-#endif
-#ifdef PNG_READ_bKGD_SUPPORTED
- else if (chunk_name == png_bKGD)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_bKGD(png_ptr, info_ptr, png_ptr->push_length);
- }
-
-#endif
-#ifdef PNG_READ_hIST_SUPPORTED
- else if (chunk_name == png_hIST)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_hIST(png_ptr, info_ptr, png_ptr->push_length);
- }
-
-#endif
-#ifdef PNG_READ_pHYs_SUPPORTED
- else if (chunk_name == png_pHYs)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_pHYs(png_ptr, info_ptr, png_ptr->push_length);
- }
-
-#endif
-#ifdef PNG_READ_oFFs_SUPPORTED
- else if (chunk_name == png_oFFs)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_oFFs(png_ptr, info_ptr, png_ptr->push_length);
- }
-#endif
-
-#ifdef PNG_READ_pCAL_SUPPORTED
- else if (chunk_name == png_pCAL)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_pCAL(png_ptr, info_ptr, png_ptr->push_length);
- }
-
-#endif
-#ifdef PNG_READ_sCAL_SUPPORTED
- else if (chunk_name == png_sCAL)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_sCAL(png_ptr, info_ptr, png_ptr->push_length);
- }
-
-#endif
-#ifdef PNG_READ_tIME_SUPPORTED
- else if (chunk_name == png_tIME)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_tIME(png_ptr, info_ptr, png_ptr->push_length);
- }
-
-#endif
-#ifdef PNG_READ_tEXt_SUPPORTED
- else if (chunk_name == png_tEXt)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_tEXt(png_ptr, info_ptr, png_ptr->push_length);
- }
-
-#endif
-#ifdef PNG_READ_zTXt_SUPPORTED
- else if (chunk_name == png_zTXt)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_zTXt(png_ptr, info_ptr, png_ptr->push_length);
- }
-
-#endif
-#ifdef PNG_READ_iTXt_SUPPORTED
- else if (chunk_name == png_iTXt)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length);
- }
-#endif
-
-#ifdef PNG_READ_APNG_SUPPORTED
- else if (chunk_name == png_acTL)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_acTL(png_ptr, info_ptr, png_ptr->push_length);
- }
-
- else if (chunk_name == png_fcTL)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_fcTL(png_ptr, info_ptr, png_ptr->push_length);
- }
-
-#endif /* READ_APNG */
- else
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length,
- PNG_HANDLE_CHUNK_AS_DEFAULT);
- }
-
- png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
-}
-
-void PNGCBAPI
-png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, size_t length)
-{
- png_bytep ptr;
-
- if (png_ptr == NULL)
- return;
-
- ptr = buffer;
- if (png_ptr->save_buffer_size != 0)
- {
- size_t save_size;
-
- if (length < png_ptr->save_buffer_size)
- save_size = length;
-
- else
- save_size = png_ptr->save_buffer_size;
-
- memcpy(ptr, png_ptr->save_buffer_ptr, save_size);
- length -= save_size;
- ptr += save_size;
- png_ptr->buffer_size -= save_size;
- png_ptr->save_buffer_size -= save_size;
- png_ptr->save_buffer_ptr += save_size;
- }
- if (length != 0 && png_ptr->current_buffer_size != 0)
- {
- size_t save_size;
-
- if (length < png_ptr->current_buffer_size)
- save_size = length;
-
- else
- save_size = png_ptr->current_buffer_size;
-
- memcpy(ptr, png_ptr->current_buffer_ptr, save_size);
- png_ptr->buffer_size -= save_size;
- png_ptr->current_buffer_size -= save_size;
- png_ptr->current_buffer_ptr += save_size;
- }
-}
-
-void /* PRIVATE */
-png_push_save_buffer(png_structrp png_ptr)
-{
- if (png_ptr->save_buffer_size != 0)
- {
- if (png_ptr->save_buffer_ptr != png_ptr->save_buffer)
- {
- size_t i, istop;
- png_bytep sp;
- png_bytep dp;
-
- istop = png_ptr->save_buffer_size;
- for (i = 0, sp = png_ptr->save_buffer_ptr, dp = png_ptr->save_buffer;
- i < istop; i++, sp++, dp++)
- {
- *dp = *sp;
- }
- }
- }
- if (png_ptr->save_buffer_size + png_ptr->current_buffer_size >
- png_ptr->save_buffer_max)
- {
- size_t new_max;
- png_bytep old_buffer;
-
- if (png_ptr->save_buffer_size > PNG_SIZE_MAX -
- (png_ptr->current_buffer_size + 256))
- {
- png_error(png_ptr, "Potential overflow of save_buffer");
- }
-
- new_max = png_ptr->save_buffer_size + png_ptr->current_buffer_size + 256;
- old_buffer = png_ptr->save_buffer;
- png_ptr->save_buffer = (png_bytep)png_malloc_warn(png_ptr,
- (size_t)new_max);
-
- if (png_ptr->save_buffer == NULL)
- {
- png_free(png_ptr, old_buffer);
- png_error(png_ptr, "Insufficient memory for save_buffer");
- }
-
- if (old_buffer)
- memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size);
- else if (png_ptr->save_buffer_size)
- png_error(png_ptr, "save_buffer error");
- png_free(png_ptr, old_buffer);
- png_ptr->save_buffer_max = new_max;
- }
- if (png_ptr->current_buffer_size)
- {
- memcpy(png_ptr->save_buffer + png_ptr->save_buffer_size,
- png_ptr->current_buffer_ptr, png_ptr->current_buffer_size);
- png_ptr->save_buffer_size += png_ptr->current_buffer_size;
- png_ptr->current_buffer_size = 0;
- }
- png_ptr->save_buffer_ptr = png_ptr->save_buffer;
- png_ptr->buffer_size = 0;
-}
-
-void /* PRIVATE */
-png_push_restore_buffer(png_structrp png_ptr, png_bytep buffer,
- size_t buffer_length)
-{
- png_ptr->current_buffer = buffer;
- png_ptr->current_buffer_size = buffer_length;
- png_ptr->buffer_size = buffer_length + png_ptr->save_buffer_size;
- png_ptr->current_buffer_ptr = png_ptr->current_buffer;
-}
-
-void /* PRIVATE */
-png_push_read_IDAT(png_structrp png_ptr)
-{
- if ((png_ptr->mode & PNG_HAVE_CHUNK_HEADER) == 0)
- {
- png_byte chunk_length[4];
- png_byte chunk_tag[4];
-
- /* TODO: this code can be commoned up with the same code in push_read */
-#ifdef PNG_READ_APNG_SUPPORTED
- PNG_PUSH_SAVE_BUFFER_IF_LT(12)
-#else
- PNG_PUSH_SAVE_BUFFER_IF_LT(8)
-#endif
- png_push_fill_buffer(png_ptr, chunk_length, 4);
- png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length);
- png_reset_crc(png_ptr);
- png_crc_read(png_ptr, chunk_tag, 4);
- png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(chunk_tag);
- png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
-
-#ifdef PNG_READ_APNG_SUPPORTED
- if (png_ptr->chunk_name != png_fdAT && png_ptr->num_frames_read > 0)
- {
- if ((png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED) != 0)
- {
- png_ptr->process_mode = PNG_READ_CHUNK_MODE;
- if (png_ptr->frame_end_fn != NULL)
- (*(png_ptr->frame_end_fn))(png_ptr, png_ptr->num_frames_read);
- png_ptr->num_frames_read++;
- return;
- }
- else
- {
- if (png_ptr->chunk_name == png_IEND)
- png_error(png_ptr, "Not enough image data");
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_warning(png_ptr, "Skipping (ignoring) a chunk between "
- "APNG chunks");
- png_crc_finish(png_ptr, png_ptr->push_length);
- png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
- return;
- }
- }
- else
-#endif
-#ifdef PNG_READ_APNG_SUPPORTED
- if (png_ptr->chunk_name != png_IDAT && png_ptr->num_frames_read == 0)
-#else
- if (png_ptr->chunk_name != png_IDAT)
-#endif
- {
- png_ptr->process_mode = PNG_READ_CHUNK_MODE;
-
- if ((png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED) == 0)
- png_error(png_ptr, "Not enough compressed data");
-
-#ifdef PNG_READ_APNG_SUPPORTED
- if (png_ptr->frame_end_fn != NULL)
- (*(png_ptr->frame_end_fn))(png_ptr, png_ptr->num_frames_read);
- png_ptr->num_frames_read++;
-#endif
-
- return;
- }
-
- png_ptr->idat_size = png_ptr->push_length;
-
-#ifdef PNG_READ_APNG_SUPPORTED
- if (png_ptr->num_frames_read > 0)
- {
- png_ensure_sequence_number(png_ptr, 4);
- png_ptr->idat_size -= 4;
- }
-#endif
- }
-
- if (png_ptr->idat_size != 0 && png_ptr->save_buffer_size != 0)
- {
- size_t save_size = png_ptr->save_buffer_size;
- png_uint_32 idat_size = png_ptr->idat_size;
-
- /* We want the smaller of 'idat_size' and 'current_buffer_size', but they
- * are of different types and we don't know which variable has the fewest
- * bits. Carefully select the smaller and cast it to the type of the
- * larger - this cannot overflow. Do not cast in the following test - it
- * will break on either 16-bit or 64-bit platforms.
- */
- if (idat_size < save_size)
- save_size = (size_t)idat_size;
-
- else
- idat_size = (png_uint_32)save_size;
-
- png_calculate_crc(png_ptr, png_ptr->save_buffer_ptr, save_size);
-
- png_process_IDAT_data(png_ptr, png_ptr->save_buffer_ptr, save_size);
-
- png_ptr->idat_size -= idat_size;
- png_ptr->buffer_size -= save_size;
- png_ptr->save_buffer_size -= save_size;
- png_ptr->save_buffer_ptr += save_size;
- }
-
- if (png_ptr->idat_size != 0 && png_ptr->current_buffer_size != 0)
- {
- size_t save_size = png_ptr->current_buffer_size;
- png_uint_32 idat_size = png_ptr->idat_size;
-
- /* We want the smaller of 'idat_size' and 'current_buffer_size', but they
- * are of different types and we don't know which variable has the fewest
- * bits. Carefully select the smaller and cast it to the type of the
- * larger - this cannot overflow.
- */
- if (idat_size < save_size)
- save_size = (size_t)idat_size;
-
- else
- idat_size = (png_uint_32)save_size;
-
- png_calculate_crc(png_ptr, png_ptr->current_buffer_ptr, save_size);
-
- png_process_IDAT_data(png_ptr, png_ptr->current_buffer_ptr, save_size);
-
- png_ptr->idat_size -= idat_size;
- png_ptr->buffer_size -= save_size;
- png_ptr->current_buffer_size -= save_size;
- png_ptr->current_buffer_ptr += save_size;
- }
-
- if (png_ptr->idat_size == 0)
- {
- PNG_PUSH_SAVE_BUFFER_IF_LT(4)
- png_crc_finish(png_ptr, 0);
- png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
- png_ptr->mode |= PNG_AFTER_IDAT;
- png_ptr->zowner = 0;
- }
-}
-
-void /* PRIVATE */
-png_process_IDAT_data(png_structrp png_ptr, png_bytep buffer,
- size_t buffer_length)
-{
- /* The caller checks for a non-zero buffer length. */
- if (!(buffer_length > 0) || buffer == NULL)
- png_error(png_ptr, "No IDAT data (internal error)");
-
-#ifdef PNG_READ_APNG_SUPPORTED
- /* If the app is not APNG-aware, decode only the first frame */
- if ((png_ptr->apng_flags & PNG_APNG_APP) == 0 &&
- png_ptr->num_frames_read > 0)
- {
- png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED;
- return;
- }
-#endif
-
- /* This routine must process all the data it has been given
- * before returning, calling the row callback as required to
- * handle the uncompressed results.
- */
- png_ptr->zstream.next_in = buffer;
- /* TODO: WARNING: TRUNCATION ERROR: DANGER WILL ROBINSON: */
- png_ptr->zstream.avail_in = (uInt)buffer_length;
-
- /* Keep going until the decompressed data is all processed
- * or the stream marked as finished.
- */
- while (png_ptr->zstream.avail_in > 0 &&
- (png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED) == 0)
- {
- int ret;
-
- /* We have data for zlib, but we must check that zlib
- * has someplace to put the results. It doesn't matter
- * if we don't expect any results -- it may be the input
- * data is just the LZ end code.
- */
- if (!(png_ptr->zstream.avail_out > 0))
- {
- /* TODO: WARNING: TRUNCATION ERROR: DANGER WILL ROBINSON: */
- png_ptr->zstream.avail_out = (uInt)(PNG_ROWBYTES(png_ptr->pixel_depth,
- png_ptr->iwidth) + 1);
-
- png_ptr->zstream.next_out = png_ptr->row_buf;
- }
-
- /* Using Z_SYNC_FLUSH here means that an unterminated
- * LZ stream (a stream with a missing end code) can still
- * be handled, otherwise (Z_NO_FLUSH) a future zlib
- * implementation might defer output and therefore
- * change the current behavior (see comments in inflate.c
- * for why this doesn't happen at present with zlib 1.2.5).
- */
- ret = PNG_INFLATE(png_ptr, Z_SYNC_FLUSH);
-
- /* Check for any failure before proceeding. */
- if (ret != Z_OK && ret != Z_STREAM_END)
- {
- /* Terminate the decompression. */
- png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED;
- png_ptr->zowner = 0;
-
- /* This may be a truncated stream (missing or
- * damaged end code). Treat that as a warning.
- */
- if (png_ptr->row_number >= png_ptr->num_rows ||
- png_ptr->pass > 6)
- png_warning(png_ptr, "Truncated compressed data in IDAT");
-
- else
- {
- if (ret == Z_DATA_ERROR)
- png_benign_error(png_ptr, "IDAT: ADLER32 checksum mismatch");
- else
- png_error(png_ptr, "Decompression error in IDAT");
- }
-
- /* Skip the check on unprocessed input */
- return;
- }
-
- /* Did inflate output any data? */
- if (png_ptr->zstream.next_out != png_ptr->row_buf)
- {
- /* Is this unexpected data after the last row?
- * If it is, artificially terminate the LZ output
- * here.
- */
- if (png_ptr->row_number >= png_ptr->num_rows ||
- png_ptr->pass > 6)
- {
- /* Extra data. */
- png_warning(png_ptr, "Extra compressed data in IDAT");
- png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED;
- png_ptr->zowner = 0;
-
- /* Do no more processing; skip the unprocessed
- * input check below.
- */
- return;
- }
-
- /* Do we have a complete row? */
- if (png_ptr->zstream.avail_out == 0)
- png_push_process_row(png_ptr);
- }
-
- /* And check for the end of the stream. */
- if (ret == Z_STREAM_END)
- png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED;
- }
-
- /* All the data should have been processed, if anything
- * is left at this point we have bytes of IDAT data
- * after the zlib end code.
- */
- if (png_ptr->zstream.avail_in > 0)
- png_warning(png_ptr, "Extra compression data in IDAT");
-}
-
-void /* PRIVATE */
-png_push_process_row(png_structrp png_ptr)
-{
- /* 1.5.6: row_info moved out of png_struct to a local here. */
- png_row_info row_info;
-
- row_info.width = png_ptr->iwidth; /* NOTE: width of current interlaced row */
- row_info.color_type = png_ptr->color_type;
- row_info.bit_depth = png_ptr->bit_depth;
- row_info.channels = png_ptr->channels;
- row_info.pixel_depth = png_ptr->pixel_depth;
- row_info.rowbytes = PNG_ROWBYTES(row_info.pixel_depth, row_info.width);
-
- if (png_ptr->row_buf[0] > PNG_FILTER_VALUE_NONE)
- {
- if (png_ptr->row_buf[0] < PNG_FILTER_VALUE_LAST)
- png_read_filter_row(png_ptr, &row_info, png_ptr->row_buf + 1,
- png_ptr->prev_row + 1, png_ptr->row_buf[0]);
- else
- png_error(png_ptr, "bad adaptive filter value");
- }
-
- /* libpng 1.5.6: the following line was copying png_ptr->rowbytes before
- * 1.5.6, while the buffer really is this big in current versions of libpng
- * it may not be in the future, so this was changed just to copy the
- * interlaced row count:
- */
- memcpy(png_ptr->prev_row, png_ptr->row_buf, row_info.rowbytes + 1);
-
-#ifdef PNG_READ_TRANSFORMS_SUPPORTED
- if (png_ptr->transformations != 0)
- png_do_read_transformations(png_ptr, &row_info);
-#endif
-
- /* The transformed pixel depth should match the depth now in row_info. */
- if (png_ptr->transformed_pixel_depth == 0)
- {
- png_ptr->transformed_pixel_depth = row_info.pixel_depth;
- if (row_info.pixel_depth > png_ptr->maximum_pixel_depth)
- png_error(png_ptr, "progressive row overflow");
- }
-
- else if (png_ptr->transformed_pixel_depth != row_info.pixel_depth)
- png_error(png_ptr, "internal progressive row size calculation error");
-
-
-#ifdef PNG_READ_INTERLACING_SUPPORTED
- /* Expand interlaced rows to full size */
- if (png_ptr->interlaced != 0 &&
- (png_ptr->transformations & PNG_INTERLACE) != 0)
- {
- if (png_ptr->pass < 6)
- png_do_read_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass,
- png_ptr->transformations);
-
- switch (png_ptr->pass)
- {
- case 0:
- {
- int i;
- for (i = 0; i < 8 && png_ptr->pass == 0; i++)
- {
- png_push_have_row(png_ptr, png_ptr->row_buf + 1);
- png_read_push_finish_row(png_ptr); /* Updates png_ptr->pass */
- }
-
- if (png_ptr->pass == 2) /* Pass 1 might be empty */
- {
- for (i = 0; i < 4 && png_ptr->pass == 2; i++)
- {
- png_push_have_row(png_ptr, NULL);
- png_read_push_finish_row(png_ptr);
- }
- }
-
- if (png_ptr->pass == 4 && png_ptr->height <= 4)
- {
- for (i = 0; i < 2 && png_ptr->pass == 4; i++)
- {
- png_push_have_row(png_ptr, NULL);
- png_read_push_finish_row(png_ptr);
- }
- }
-
- if (png_ptr->pass == 6 && png_ptr->height <= 4)
- {
- png_push_have_row(png_ptr, NULL);
- png_read_push_finish_row(png_ptr);
- }
-
- break;
- }
-
- case 1:
- {
- int i;
- for (i = 0; i < 8 && png_ptr->pass == 1; i++)
- {
- png_push_have_row(png_ptr, png_ptr->row_buf + 1);
- png_read_push_finish_row(png_ptr);
- }
-
- if (png_ptr->pass == 2) /* Skip top 4 generated rows */
- {
- for (i = 0; i < 4 && png_ptr->pass == 2; i++)
- {
- png_push_have_row(png_ptr, NULL);
- png_read_push_finish_row(png_ptr);
- }
- }
-
- break;
- }
-
- case 2:
- {
- int i;
-
- for (i = 0; i < 4 && png_ptr->pass == 2; i++)
- {
- png_push_have_row(png_ptr, png_ptr->row_buf + 1);
- png_read_push_finish_row(png_ptr);
- }
-
- for (i = 0; i < 4 && png_ptr->pass == 2; i++)
- {
- png_push_have_row(png_ptr, NULL);
- png_read_push_finish_row(png_ptr);
- }
-
- if (png_ptr->pass == 4) /* Pass 3 might be empty */
- {
- for (i = 0; i < 2 && png_ptr->pass == 4; i++)
- {
- png_push_have_row(png_ptr, NULL);
- png_read_push_finish_row(png_ptr);
- }
- }
-
- break;
- }
-
- case 3:
- {
- int i;
-
- for (i = 0; i < 4 && png_ptr->pass == 3; i++)
- {
- png_push_have_row(png_ptr, png_ptr->row_buf + 1);
- png_read_push_finish_row(png_ptr);
- }
-
- if (png_ptr->pass == 4) /* Skip top two generated rows */
- {
- for (i = 0; i < 2 && png_ptr->pass == 4; i++)
- {
- png_push_have_row(png_ptr, NULL);
- png_read_push_finish_row(png_ptr);
- }
- }
-
- break;
- }
-
- case 4:
- {
- int i;
-
- for (i = 0; i < 2 && png_ptr->pass == 4; i++)
- {
- png_push_have_row(png_ptr, png_ptr->row_buf + 1);
- png_read_push_finish_row(png_ptr);
- }
-
- for (i = 0; i < 2 && png_ptr->pass == 4; i++)
- {
- png_push_have_row(png_ptr, NULL);
- png_read_push_finish_row(png_ptr);
- }
-
- if (png_ptr->pass == 6) /* Pass 5 might be empty */
- {
- png_push_have_row(png_ptr, NULL);
- png_read_push_finish_row(png_ptr);
- }
-
- break;
- }
-
- case 5:
- {
- int i;
-
- for (i = 0; i < 2 && png_ptr->pass == 5; i++)
- {
- png_push_have_row(png_ptr, png_ptr->row_buf + 1);
- png_read_push_finish_row(png_ptr);
- }
-
- if (png_ptr->pass == 6) /* Skip top generated row */
- {
- png_push_have_row(png_ptr, NULL);
- png_read_push_finish_row(png_ptr);
- }
-
- break;
- }
-
- default:
- case 6:
- {
- png_push_have_row(png_ptr, png_ptr->row_buf + 1);
- png_read_push_finish_row(png_ptr);
-
- if (png_ptr->pass != 6)
- break;
-
- png_push_have_row(png_ptr, NULL);
- png_read_push_finish_row(png_ptr);
- }
- }
- }
- else
-#endif
- {
- png_push_have_row(png_ptr, png_ptr->row_buf + 1);
- png_read_push_finish_row(png_ptr);
- }
-}
-
-void /* PRIVATE */
-png_read_push_finish_row(png_structrp png_ptr)
-{
- png_ptr->row_number++;
- if (png_ptr->row_number < png_ptr->num_rows)
- return;
-
-#ifdef PNG_READ_INTERLACING_SUPPORTED
- if (png_ptr->interlaced != 0)
- {
- png_ptr->row_number = 0;
- memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
-
- do
- {
- png_ptr->pass++;
- if ((png_ptr->pass == 1 && png_ptr->width < 5) ||
- (png_ptr->pass == 3 && png_ptr->width < 3) ||
- (png_ptr->pass == 5 && png_ptr->width < 2))
- png_ptr->pass++;
-
- if (png_ptr->pass > 7)
- png_ptr->pass--;
-
- if (png_ptr->pass >= 7)
- break;
-
- png_ptr->iwidth = (png_ptr->width +
- png_pass_inc[png_ptr->pass] - 1 -
- png_pass_start[png_ptr->pass]) /
- png_pass_inc[png_ptr->pass];
-
- if ((png_ptr->transformations & PNG_INTERLACE) != 0)
- break;
-
- png_ptr->num_rows = (png_ptr->height +
- png_pass_yinc[png_ptr->pass] - 1 -
- png_pass_ystart[png_ptr->pass]) /
- png_pass_yinc[png_ptr->pass];
-
- } while (png_ptr->iwidth == 0 || png_ptr->num_rows == 0);
- }
-#endif /* READ_INTERLACING */
-}
-
-void /* PRIVATE */
-png_push_have_info(png_structrp png_ptr, png_inforp info_ptr)
-{
- if (png_ptr->info_fn != NULL)
- (*(png_ptr->info_fn))(png_ptr, info_ptr);
-}
-
-void /* PRIVATE */
-png_push_have_end(png_structrp png_ptr, png_inforp info_ptr)
-{
- if (png_ptr->end_fn != NULL)
- (*(png_ptr->end_fn))(png_ptr, info_ptr);
-}
-
-void /* PRIVATE */
-png_push_have_row(png_structrp png_ptr, png_bytep row)
-{
- if (png_ptr->row_fn != NULL)
- (*(png_ptr->row_fn))(png_ptr, row, png_ptr->row_number,
- (int)png_ptr->pass);
-}
-
-#ifdef PNG_READ_INTERLACING_SUPPORTED
-void PNGAPI
-png_progressive_combine_row(png_const_structrp png_ptr, png_bytep old_row,
- png_const_bytep new_row)
-{
- if (png_ptr == NULL)
- return;
-
- /* new_row is a flag here - if it is NULL then the app callback was called
- * from an empty row (see the calls to png_struct::row_fn below), otherwise
- * it must be png_ptr->row_buf+1
- */
- if (new_row != NULL)
- png_combine_row(png_ptr, old_row, 1/*blocky display*/);
-}
-#endif /* READ_INTERLACING */
-
-void PNGAPI
-png_set_progressive_read_fn(png_structrp png_ptr, png_voidp progressive_ptr,
- png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn,
- png_progressive_end_ptr end_fn)
-{
- if (png_ptr == NULL)
- return;
-
- png_ptr->info_fn = info_fn;
- png_ptr->row_fn = row_fn;
- png_ptr->end_fn = end_fn;
-
- png_set_read_fn(png_ptr, progressive_ptr, png_push_fill_buffer);
-}
-
-#ifdef PNG_READ_APNG_SUPPORTED
-void PNGAPI
-png_set_progressive_frame_fn(png_structp png_ptr,
- png_progressive_frame_ptr frame_info_fn,
- png_progressive_frame_ptr frame_end_fn)
-{
- png_ptr->frame_info_fn = frame_info_fn;
- png_ptr->frame_end_fn = frame_end_fn;
- png_ptr->apng_flags |= PNG_APNG_APP;
-}
-#endif
-
-png_voidp PNGAPI
-png_get_progressive_ptr(png_const_structrp png_ptr)
-{
- if (png_ptr == NULL)
- return NULL;
-
- return png_ptr->io_ptr;
-}
-#endif /* PROGRESSIVE_READ */
diff --git a/contrib/libs/libpng/pngprefix.h b/contrib/libs/libpng/pngprefix.h
deleted file mode 100644
index e69de29bb2..0000000000
--- a/contrib/libs/libpng/pngprefix.h
+++ /dev/null
diff --git a/contrib/libs/libpng/pngpriv.h b/contrib/libs/libpng/pngpriv.h
deleted file mode 100644
index a74e0cecae..0000000000
--- a/contrib/libs/libpng/pngpriv.h
+++ /dev/null
@@ -1,2284 +0,0 @@
-/* pngpriv.h - private declarations for use inside libpng
- *
- * Copyright (c) 2018-2024 Cosmin Truta
- * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
- * Copyright (c) 1996-1997 Andreas Dilger
- * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
- *
- * This code is released under the libpng license.
- * For conditions of distribution and use, see the disclaimer
- * and license in png.h
- */
-
-/* The symbols declared in this file (including the functions declared
- * as extern) are PRIVATE. They are not part of the libpng public
- * interface, and are not recommended for use by regular applications.
- * Some of them may become public in the future; others may stay private,
- * change in an incompatible way, or even disappear.
- * Although the libpng users are not forbidden to include this header,
- * they should be well aware of the issues that may arise from doing so.
- */
-
-#ifndef PNGPRIV_H
-#define PNGPRIV_H
-
-/* Feature Test Macros. The following are defined here to ensure that correctly
- * implemented libraries reveal the APIs libpng needs to build and hide those
- * that are not needed and potentially damaging to the compilation.
- *
- * Feature Test Macros must be defined before any system header is included (see
- * POSIX 1003.1 2.8.2 "POSIX Symbols."
- *
- * These macros only have an effect if the operating system supports either
- * POSIX 1003.1 or C99, or both. On other operating systems (particularly
- * Windows/Visual Studio) there is no effect; the OS specific tests below are
- * still required (as of 2011-05-02.)
- */
-#ifndef _POSIX_SOURCE
-# define _POSIX_SOURCE 1 /* Just the POSIX 1003.1 and C89 APIs */
-#endif
-
-#ifndef PNG_VERSION_INFO_ONLY
-/* Standard library headers not required by png.h: */
-# include <stdlib.h>
-# include <string.h>
-#endif
-
-#define PNGLIB_BUILD /*libpng is being built, not used*/
-
-/* If HAVE_CONFIG_H is defined during the build then the build system must
- * provide an appropriate "config.h" file on the include path. The header file
- * must provide definitions as required below (search for "HAVE_CONFIG_H");
- * see configure.ac for more details of the requirements. The macro
- * "PNG_NO_CONFIG_H" is provided for maintainers to test for dependencies on
- * 'configure'; define this macro to prevent the configure build including the
- * configure generated config.h. Libpng is expected to compile without *any*
- * special build system support on a reasonably ANSI-C compliant system.
- */
-#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H)
-# error #include <config.h>
-
- /* Pick up the definition of 'restrict' from config.h if it was read: */
-# define PNG_RESTRICT restrict
-#endif
-
-/* To support symbol prefixing it is necessary to know *before* including png.h
- * whether the fixed point (and maybe other) APIs are exported, because if they
- * are not internal definitions may be required. This is handled below just
- * before png.h is included, but load the configuration now if it is available.
- */
-#ifndef PNGLCONF_H
-# include "pnglibconf.h"
-#endif
-
-/* Local renames may change non-exported API functions from png.h */
-#if defined(PNG_PREFIX) && !defined(PNGPREFIX_H)
-# include "pngprefix.h"
-#endif
-
-#ifdef PNG_USER_CONFIG
-# error #include "pngusr.h"
- /* These should have been defined in pngusr.h */
-# ifndef PNG_USER_PRIVATEBUILD
-# define PNG_USER_PRIVATEBUILD "Custom libpng build"
-# endif
-# ifndef PNG_USER_DLLFNAME_POSTFIX
-# define PNG_USER_DLLFNAME_POSTFIX "Cb"
-# endif
-#endif
-
-/* Compile time options.
- * =====================
- * In a multi-arch build the compiler may compile the code several times for the
- * same object module, producing different binaries for different architectures.
- * When this happens configure-time setting of the target host options cannot be
- * done and this interferes with the handling of the ARM NEON optimizations, and
- * possibly other similar optimizations. Put additional tests here; in general
- * this is needed when the same option can be changed at both compile time and
- * run time depending on the target OS (i.e. iOS vs Android.)
- *
- * NOTE: symbol prefixing does not pass $(CFLAGS) to the preprocessor, because
- * this is not possible with certain compilers (Oracle SUN OS CC), as a result
- * it is necessary to ensure that all extern functions that *might* be used
- * regardless of $(CFLAGS) get declared in this file. The test on __ARM_NEON__
- * below is one example of this behavior because it is controlled by the
- * presence or not of -mfpu=neon on the GCC command line, it is possible to do
- * this in $(CC), e.g. "CC=gcc -mfpu=neon", but people who build libpng rarely
- * do this.
- */
-#ifndef PNG_ARM_NEON_OPT
- /* ARM NEON optimizations are being controlled by the compiler settings,
- * typically the target FPU. If the FPU has been set to NEON (-mfpu=neon
- * with GCC) then the compiler will define __ARM_NEON__ and we can rely
- * unconditionally on NEON instructions not crashing, otherwise we must
- * disable use of NEON instructions.
- *
- * NOTE: at present these optimizations depend on 'ALIGNED_MEMORY', so they
- * can only be turned on automatically if that is supported too. If
- * PNG_ARM_NEON_OPT is set in CPPFLAGS (to >0) then arm/arm_init.c will fail
- * to compile with an appropriate #error if ALIGNED_MEMORY has been turned
- * off.
- *
- * Note that gcc-4.9 defines __ARM_NEON instead of the deprecated
- * __ARM_NEON__, so we check both variants.
- *
- * To disable ARM_NEON optimizations entirely, and skip compiling the
- * associated assembler code, pass --enable-arm-neon=no to configure
- * or put -DPNG_ARM_NEON_OPT=0 in CPPFLAGS.
- */
-# if (defined(__ARM_NEON__) || defined(__ARM_NEON)) && \
- defined(PNG_ALIGNED_MEMORY_SUPPORTED)
-# define PNG_ARM_NEON_OPT 2
-# else
-# define PNG_ARM_NEON_OPT 0
-# endif
-#endif
-
-#if PNG_ARM_NEON_OPT > 0
- /* NEON optimizations are to be at least considered by libpng, so enable the
- * callbacks to do this.
- */
-# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_neon
-# ifndef PNG_ARM_NEON_IMPLEMENTATION
- /* Use the intrinsics code by default. */
-# define PNG_ARM_NEON_IMPLEMENTATION 1
-# endif
-#else /* PNG_ARM_NEON_OPT == 0 */
-# define PNG_ARM_NEON_IMPLEMENTATION 0
-#endif /* PNG_ARM_NEON_OPT > 0 */
-
-#ifndef PNG_MIPS_MSA_OPT
-# if defined(__mips_msa) && (__mips_isa_rev >= 5) && \
- defined(PNG_ALIGNED_MEMORY_SUPPORTED)
-# define PNG_MIPS_MSA_OPT 2
-# else
-# define PNG_MIPS_MSA_OPT 0
-# endif
-#endif
-
-#ifndef PNG_MIPS_MMI_OPT
-# ifdef PNG_MIPS_MMI
-# if defined(__mips_loongson_mmi) && (_MIPS_SIM == _ABI64) && \
- defined(PNG_ALIGNED_MEMORY_SUPPORTED)
-# define PNG_MIPS_MMI_OPT 1
-# else
-# define PNG_MIPS_MMI_OPT 0
-# endif
-# else
-# define PNG_MIPS_MMI_OPT 0
-# endif
-#endif
-
-#ifndef PNG_POWERPC_VSX_OPT
-# if defined(__PPC64__) && defined(__ALTIVEC__) && defined(__VSX__)
-# define PNG_POWERPC_VSX_OPT 2
-# else
-# define PNG_POWERPC_VSX_OPT 0
-# endif
-#endif
-
-#ifndef PNG_LOONGARCH_LSX_OPT
-# if defined(__loongarch_sx)
-# define PNG_LOONGARCH_LSX_OPT 1
-# else
-# define PNG_LOONGARCH_LSX_OPT 0
-# endif
-#endif
-
-#ifndef PNG_INTEL_SSE_OPT
-# ifdef PNG_INTEL_SSE
- /* Only check for SSE if the build configuration has been modified to
- * enable SSE optimizations. This means that these optimizations will
- * be off by default. See contrib/intel for more details.
- */
-# if defined(__SSE4_1__) || defined(__AVX__) || defined(__SSSE3__) || \
- defined(__SSE2__) || defined(_M_X64) || defined(_M_AMD64) || \
- (defined(_M_IX86_FP) && _M_IX86_FP >= 2)
-# define PNG_INTEL_SSE_OPT 1
-# else
-# define PNG_INTEL_SSE_OPT 0
-# endif
-# else
-# define PNG_INTEL_SSE_OPT 0
-# endif
-#endif
-
-#if PNG_INTEL_SSE_OPT > 0
-# ifndef PNG_INTEL_SSE_IMPLEMENTATION
-# if defined(__SSE4_1__) || defined(__AVX__)
- /* We are not actually using AVX, but checking for AVX is the best
- way we can detect SSE4.1 and SSSE3 on MSVC.
- */
-# define PNG_INTEL_SSE_IMPLEMENTATION 3
-# elif defined(__SSSE3__)
-# define PNG_INTEL_SSE_IMPLEMENTATION 2
-# elif defined(__SSE2__) || defined(_M_X64) || defined(_M_AMD64) || \
- (defined(_M_IX86_FP) && _M_IX86_FP >= 2)
-# define PNG_INTEL_SSE_IMPLEMENTATION 1
-# else
-# define PNG_INTEL_SSE_IMPLEMENTATION 0
-# endif
-# endif
-
-# if PNG_INTEL_SSE_IMPLEMENTATION > 0
-# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_sse2
-# endif
-#else
-# define PNG_INTEL_SSE_IMPLEMENTATION 0
-#endif
-
-#if PNG_MIPS_MSA_OPT > 0
-# ifndef PNG_MIPS_MSA_IMPLEMENTATION
-# if defined(__mips_msa)
-# if defined(__clang__)
-# elif defined(__GNUC__)
-# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7)
-# define PNG_MIPS_MSA_IMPLEMENTATION 2
-# endif /* no GNUC support */
-# endif /* __GNUC__ */
-# else /* !defined __mips_msa */
-# define PNG_MIPS_MSA_IMPLEMENTATION 2
-# endif /* __mips_msa */
-# endif /* !PNG_MIPS_MSA_IMPLEMENTATION */
-
-# ifndef PNG_MIPS_MSA_IMPLEMENTATION
-# define PNG_MIPS_MSA_IMPLEMENTATION 1
-# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_mips
-# endif
-#else
-# define PNG_MIPS_MSA_IMPLEMENTATION 0
-#endif /* PNG_MIPS_MSA_OPT > 0 */
-
-#if PNG_MIPS_MMI_OPT > 0
-# ifndef PNG_MIPS_MMI_IMPLEMENTATION
-# if defined(__mips_loongson_mmi) && (_MIPS_SIM == _ABI64)
-# define PNG_MIPS_MMI_IMPLEMENTATION 2
-# else /* !defined __mips_loongson_mmi || _MIPS_SIM != _ABI64 */
-# define PNG_MIPS_MMI_IMPLEMENTATION 0
-# endif /* __mips_loongson_mmi && _MIPS_SIM == _ABI64 */
-# endif /* !PNG_MIPS_MMI_IMPLEMENTATION */
-
-# if PNG_MIPS_MMI_IMPLEMENTATION > 0
-# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_mips
-# endif
-#else
-# define PNG_MIPS_MMI_IMPLEMENTATION 0
-#endif /* PNG_MIPS_MMI_OPT > 0 */
-
-#if PNG_POWERPC_VSX_OPT > 0
-# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_vsx
-# define PNG_POWERPC_VSX_IMPLEMENTATION 1
-#else
-# define PNG_POWERPC_VSX_IMPLEMENTATION 0
-#endif
-
-#if PNG_LOONGARCH_LSX_OPT > 0
-# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_lsx
-# define PNG_LOONGARCH_LSX_IMPLEMENTATION 1
-#else
-# define PNG_LOONGARCH_LSX_IMPLEMENTATION 0
-#endif
-
-/* Is this a build of a DLL where compilation of the object modules requires
- * different preprocessor settings to those required for a simple library? If
- * so PNG_BUILD_DLL must be set.
- *
- * If libpng is used inside a DLL but that DLL does not export the libpng APIs
- * PNG_BUILD_DLL must not be set. To avoid the code below kicking in build a
- * static library of libpng then link the DLL against that.
- */
-#ifndef PNG_BUILD_DLL
-# ifdef DLL_EXPORT
- /* This is set by libtool when files are compiled for a DLL; libtool
- * always compiles twice, even on systems where it isn't necessary. Set
- * PNG_BUILD_DLL in case it is necessary:
- */
-# define PNG_BUILD_DLL
-# else
-# ifdef _WINDLL
- /* This is set by the Microsoft Visual Studio IDE in projects that
- * build a DLL. It can't easily be removed from those projects (it
- * isn't visible in the Visual Studio UI) so it is a fairly reliable
- * indication that PNG_IMPEXP needs to be set to the DLL export
- * attributes.
- */
-# define PNG_BUILD_DLL
-# else
-# ifdef __DLL__
- /* This is set by the Borland C system when compiling for a DLL
- * (as above.)
- */
-# define PNG_BUILD_DLL
-# else
- /* Add additional compiler cases here. */
-# endif
-# endif
-# endif
-#endif /* Setting PNG_BUILD_DLL if required */
-
-/* See pngconf.h for more details: the builder of the library may set this on
- * the command line to the right thing for the specific compilation system or it
- * may be automagically set above (at present we know of no system where it does
- * need to be set on the command line.)
- *
- * PNG_IMPEXP must be set here when building the library to prevent pngconf.h
- * setting it to the "import" setting for a DLL build.
- */
-#ifndef PNG_IMPEXP
-# ifdef PNG_BUILD_DLL
-# define PNG_IMPEXP PNG_DLL_EXPORT
-# else
- /* Not building a DLL, or the DLL doesn't require specific export
- * definitions.
- */
-# define PNG_IMPEXP
-# endif
-#endif
-
-/* No warnings for private or deprecated functions in the build: */
-#ifndef PNG_DEPRECATED
-# define PNG_DEPRECATED
-#endif
-#ifndef PNG_PRIVATE
-# define PNG_PRIVATE
-#endif
-
-/* Symbol preprocessing support.
- *
- * To enable listing global, but internal, symbols the following macros should
- * always be used to declare an extern data or function object in this file.
- */
-#ifndef PNG_INTERNAL_DATA
-# define PNG_INTERNAL_DATA(type, name, array) PNG_LINKAGE_DATA type name array
-#endif
-
-#ifndef PNG_INTERNAL_FUNCTION
-# define PNG_INTERNAL_FUNCTION(type, name, args, attributes)\
- PNG_LINKAGE_FUNCTION PNG_FUNCTION(type, name, args, PNG_EMPTY attributes)
-#endif
-
-#ifndef PNG_INTERNAL_CALLBACK
-# define PNG_INTERNAL_CALLBACK(type, name, args, attributes)\
- PNG_LINKAGE_CALLBACK PNG_FUNCTION(type, (PNGCBAPI name), args,\
- PNG_EMPTY attributes)
-#endif
-
-/* If floating or fixed point APIs are disabled they may still be compiled
- * internally. To handle this make sure they are declared as the appropriate
- * internal extern function (otherwise the symbol prefixing stuff won't work and
- * the functions will be used without definitions.)
- *
- * NOTE: although all the API functions are declared here they are not all
- * actually built! Because the declarations are still made it is necessary to
- * fake out types that they depend on.
- */
-#ifndef PNG_FP_EXPORT
-# ifndef PNG_FLOATING_POINT_SUPPORTED
-# define PNG_FP_EXPORT(ordinal, type, name, args)\
- PNG_INTERNAL_FUNCTION(type, name, args, PNG_EMPTY);
-# ifndef PNG_VERSION_INFO_ONLY
- typedef struct png_incomplete png_double;
- typedef png_double* png_doublep;
- typedef const png_double* png_const_doublep;
- typedef png_double** png_doublepp;
-# endif
-# endif
-#endif
-#ifndef PNG_FIXED_EXPORT
-# ifndef PNG_FIXED_POINT_SUPPORTED
-# define PNG_FIXED_EXPORT(ordinal, type, name, args)\
- PNG_INTERNAL_FUNCTION(type, name, args, PNG_EMPTY);
-# endif
-#endif
-
-#include "png.h"
-
-/* pngconf.h does not set PNG_DLL_EXPORT unless it is required, so: */
-#ifndef PNG_DLL_EXPORT
-# define PNG_DLL_EXPORT
-#endif
-
-/* This is a global switch to set the compilation for an installed system
- * (a release build). It can be set for testing debug builds to ensure that
- * they will compile when the build type is switched to RC or STABLE, the
- * default is just to use PNG_LIBPNG_BUILD_BASE_TYPE. Set this in CPPFLAGS
- * with either:
- *
- * -DPNG_RELEASE_BUILD Turns on the release compile path
- * -DPNG_RELEASE_BUILD=0 Turns it off
- * or in your pngusr.h with
- * #define PNG_RELEASE_BUILD=1 Turns on the release compile path
- * #define PNG_RELEASE_BUILD=0 Turns it off
- */
-#ifndef PNG_RELEASE_BUILD
-# define PNG_RELEASE_BUILD (PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC)
-#endif
-
-/* SECURITY and SAFETY:
- *
- * libpng is built with support for internal limits on image dimensions and
- * memory usage. These are documented in scripts/pnglibconf.dfa of the
- * source and recorded in the machine generated header file pnglibconf.h.
- */
-
-/* If you are running on a machine where you cannot allocate more
- * than 64K of memory at once, uncomment this. While libpng will not
- * normally need that much memory in a chunk (unless you load up a very
- * large file), zlib needs to know how big of a chunk it can use, and
- * libpng thus makes sure to check any memory allocation to verify it
- * will fit into memory.
- *
- * zlib provides 'MAXSEG_64K' which, if defined, indicates the
- * same limit and pngconf.h (already included) sets the limit
- * if certain operating systems are detected.
- */
-#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K)
-# define PNG_MAX_MALLOC_64K
-#endif
-
-#ifndef PNG_UNUSED
-/* Unused formal parameter warnings are silenced using the following macro
- * which is expected to have no bad effects on performance (optimizing
- * compilers will probably remove it entirely). Note that if you replace
- * it with something other than whitespace, you must include the terminating
- * semicolon.
- */
-# define PNG_UNUSED(param) (void)param;
-#endif
-
-/* Just a little check that someone hasn't tried to define something
- * contradictory.
- */
-#if (PNG_ZBUF_SIZE > 65536L) && defined(PNG_MAX_MALLOC_64K)
-# undef PNG_ZBUF_SIZE
-# define PNG_ZBUF_SIZE 65536L
-#endif
-
-/* If warnings or errors are turned off the code is disabled or redirected here.
- * From 1.5.4 functions have been added to allow very limited formatting of
- * error and warning messages - this code will also be disabled here.
- */
-#ifdef PNG_WARNINGS_SUPPORTED
-# define PNG_WARNING_PARAMETERS(p) png_warning_parameters p;
-#else
-# define png_warning_parameter(p,number,string) ((void)0)
-# define png_warning_parameter_unsigned(p,number,format,value) ((void)0)
-# define png_warning_parameter_signed(p,number,format,value) ((void)0)
-# define png_formatted_warning(pp,p,message) ((void)(pp))
-# define PNG_WARNING_PARAMETERS(p)
-#endif
-#ifndef PNG_ERROR_TEXT_SUPPORTED
-# define png_fixed_error(s1,s2) png_err(s1)
-#endif
-
-/* Some fixed point APIs are still required even if not exported because
- * they get used by the corresponding floating point APIs. This magic
- * deals with this:
- */
-#ifdef PNG_FIXED_POINT_SUPPORTED
-# define PNGFAPI PNGAPI
-#else
-# define PNGFAPI /* PRIVATE */
-#endif
-
-#ifndef PNG_VERSION_INFO_ONLY
-/* Other defines specific to compilers can go here. Try to keep
- * them inside an appropriate ifdef/endif pair for portability.
- */
-
-/* C allows up-casts from (void*) to any pointer and (const void*) to any
- * pointer to a const object. C++ regards this as a type error and requires an
- * explicit, static, cast and provides the static_cast<> rune to ensure that
- * const is not cast away.
- */
-#ifdef __cplusplus
-# define png_voidcast(type, value) static_cast<type>(value)
-# define png_constcast(type, value) const_cast<type>(value)
-# define png_aligncast(type, value) \
- static_cast<type>(static_cast<void*>(value))
-# define png_aligncastconst(type, value) \
- static_cast<type>(static_cast<const void*>(value))
-#else
-# define png_voidcast(type, value) (value)
-# define png_constcast(type, value) ((type)(void*)(const void*)(value))
-# define png_aligncast(type, value) ((void*)(value))
-# define png_aligncastconst(type, value) ((const void*)(value))
-#endif /* __cplusplus */
-
-#if defined(PNG_FLOATING_POINT_SUPPORTED) ||\
- defined(PNG_FLOATING_ARITHMETIC_SUPPORTED)
- /* png.c requires the following ANSI-C constants if the conversion of
- * floating point to ASCII is implemented therein:
- *
- * DBL_DIG Maximum number of decimal digits (can be set to any constant)
- * DBL_MIN Smallest normalized fp number (can be set to an arbitrary value)
- * DBL_MAX Maximum floating point number (can be set to an arbitrary value)
- */
-# include <float.h>
-
-# include <math.h>
-
-# if defined(_AMIGA) && defined(__SASC) && defined(_M68881)
- /* Amiga SAS/C: We must include builtin FPU functions when compiling using
- * MATH=68881
- */
-# include <m68881.h>
-# endif
-#endif
-
-/* This provides the non-ANSI (far) memory allocation routines. */
-#if defined(__TURBOC__) && defined(__MSDOS__)
-# error #include <mem.h>
-# include <alloc.h>
-#endif
-
-#if defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
-# include <windows.h>
-#endif
-#endif /* PNG_VERSION_INFO_ONLY */
-
-/* Moved here around 1.5.0beta36 from pngconf.h */
-/* Users may want to use these so they are not private. Any library
- * functions that are passed far data must be model-independent.
- */
-
-/* Platform-independent functions */
-#ifndef PNG_ABORT
-# define PNG_ABORT() abort()
-#endif
-
-/* These macros may need to be architecture dependent. */
-#define PNG_ALIGN_NONE 0 /* do not use data alignment */
-#define PNG_ALIGN_ALWAYS 1 /* assume unaligned accesses are OK */
-#ifdef offsetof
-# define PNG_ALIGN_OFFSET 2 /* use offsetof to determine alignment */
-#else
-# define PNG_ALIGN_OFFSET -1 /* prevent the use of this */
-#endif
-#define PNG_ALIGN_SIZE 3 /* use sizeof to determine alignment */
-
-#ifndef PNG_ALIGN_TYPE
- /* Default to using aligned access optimizations and requiring alignment to a
- * multiple of the data type size. Override in a compiler specific fashion
- * if necessary by inserting tests here:
- */
-# define PNG_ALIGN_TYPE PNG_ALIGN_SIZE
-#endif
-
-#if PNG_ALIGN_TYPE == PNG_ALIGN_SIZE
- /* This is used because in some compiler implementations non-aligned
- * structure members are supported, so the offsetof approach below fails.
- * Set PNG_ALIGN_SIZE=0 for compiler combinations where unaligned access
- * is good for performance. Do not do this unless you have tested the
- * result and understand it.
- */
-# define png_alignof(type) (sizeof(type))
-#else
-# if PNG_ALIGN_TYPE == PNG_ALIGN_OFFSET
-# define png_alignof(type) offsetof(struct{char c; type t;}, t)
-# else
-# if PNG_ALIGN_TYPE == PNG_ALIGN_ALWAYS
-# define png_alignof(type) 1
-# endif
- /* Else leave png_alignof undefined to prevent use thereof */
-# endif
-#endif
-
-/* This implicitly assumes alignment is always a multiple of 2. */
-#ifdef png_alignof
-# define png_isaligned(ptr, type) \
- (((type)(size_t)((const void*)(ptr)) & (type)(png_alignof(type)-1)) == 0)
-#else
-# define png_isaligned(ptr, type) 0
-#endif
-
-/* End of memory model/platform independent support */
-/* End of 1.5.0beta36 move from pngconf.h */
-
-/* CONSTANTS and UTILITY MACROS
- * These are used internally by libpng and not exposed in the API
- */
-
-/* Various modes of operation. Note that after an init, mode is set to
- * zero automatically when the structure is created. Three of these
- * are defined in png.h because they need to be visible to applications
- * that call png_set_unknown_chunk().
- */
-/* #define PNG_HAVE_IHDR 0x01U (defined in png.h) */
-/* #define PNG_HAVE_PLTE 0x02U (defined in png.h) */
-#define PNG_HAVE_IDAT 0x04U
-/* #define PNG_AFTER_IDAT 0x08U (defined in png.h) */
-#define PNG_HAVE_IEND 0x10U
- /* 0x20U (unused) */
- /* 0x40U (unused) */
- /* 0x80U (unused) */
-#define PNG_HAVE_CHUNK_HEADER 0x100U
-#define PNG_WROTE_tIME 0x200U
-#define PNG_WROTE_INFO_BEFORE_PLTE 0x400U
-#define PNG_BACKGROUND_IS_GRAY 0x800U
-#define PNG_HAVE_PNG_SIGNATURE 0x1000U
-#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000U /* Have another chunk after IDAT */
-#define PNG_WROTE_eXIf 0x4000U
-#define PNG_IS_READ_STRUCT 0x8000U /* Else is a write struct */
-#ifdef PNG_APNG_SUPPORTED
-#define PNG_HAVE_acTL 0x10000U
-#define PNG_HAVE_fcTL 0x20000U
-#endif
-
-/* Flags for the transformations the PNG library does on the image data */
-#define PNG_BGR 0x0001U
-#define PNG_INTERLACE 0x0002U
-#define PNG_PACK 0x0004U
-#define PNG_SHIFT 0x0008U
-#define PNG_SWAP_BYTES 0x0010U
-#define PNG_INVERT_MONO 0x0020U
-#define PNG_QUANTIZE 0x0040U
-#define PNG_COMPOSE 0x0080U /* Was PNG_BACKGROUND */
-#define PNG_BACKGROUND_EXPAND 0x0100U
-#define PNG_EXPAND_16 0x0200U /* Added to libpng 1.5.2 */
-#define PNG_16_TO_8 0x0400U /* Becomes 'chop' in 1.5.4 */
-#define PNG_RGBA 0x0800U
-#define PNG_EXPAND 0x1000U
-#define PNG_GAMMA 0x2000U
-#define PNG_GRAY_TO_RGB 0x4000U
-#define PNG_FILLER 0x8000U
-#define PNG_PACKSWAP 0x10000U
-#define PNG_SWAP_ALPHA 0x20000U
-#define PNG_STRIP_ALPHA 0x40000U
-#define PNG_INVERT_ALPHA 0x80000U
-#define PNG_USER_TRANSFORM 0x100000U
-#define PNG_RGB_TO_GRAY_ERR 0x200000U
-#define PNG_RGB_TO_GRAY_WARN 0x400000U
-#define PNG_RGB_TO_GRAY 0x600000U /* two bits, RGB_TO_GRAY_ERR|WARN */
-#define PNG_ENCODE_ALPHA 0x800000U /* Added to libpng-1.5.4 */
-#define PNG_ADD_ALPHA 0x1000000U /* Added to libpng-1.2.7 */
-#define PNG_EXPAND_tRNS 0x2000000U /* Added to libpng-1.2.9 */
-#define PNG_SCALE_16_TO_8 0x4000000U /* Added to libpng-1.5.4 */
- /* 0x8000000U unused */
- /* 0x10000000U unused */
- /* 0x20000000U unused */
- /* 0x40000000U unused */
-/* Flags for png_create_struct */
-#define PNG_STRUCT_PNG 0x0001U
-#define PNG_STRUCT_INFO 0x0002U
-
-/* Flags for the png_ptr->flags rather than declaring a byte for each one */
-#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001U
-#define PNG_FLAG_ZSTREAM_INITIALIZED 0x0002U /* Added to libpng-1.6.0 */
- /* 0x0004U unused */
-#define PNG_FLAG_ZSTREAM_ENDED 0x0008U /* Added to libpng-1.6.0 */
- /* 0x0010U unused */
- /* 0x0020U unused */
-#define PNG_FLAG_ROW_INIT 0x0040U
-#define PNG_FLAG_FILLER_AFTER 0x0080U
-#define PNG_FLAG_CRC_ANCILLARY_USE 0x0100U
-#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200U
-#define PNG_FLAG_CRC_CRITICAL_USE 0x0400U
-#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800U
-#define PNG_FLAG_ASSUME_sRGB 0x1000U /* Added to libpng-1.5.4 */
-#define PNG_FLAG_OPTIMIZE_ALPHA 0x2000U /* Added to libpng-1.5.4 */
-#define PNG_FLAG_DETECT_UNINITIALIZED 0x4000U /* Added to libpng-1.5.4 */
-/* #define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000U */
-/* #define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000U */
-#define PNG_FLAG_LIBRARY_MISMATCH 0x20000U
-#define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000U
-#define PNG_FLAG_STRIP_ERROR_TEXT 0x80000U
-#define PNG_FLAG_BENIGN_ERRORS_WARN 0x100000U /* Added to libpng-1.4.0 */
-#define PNG_FLAG_APP_WARNINGS_WARN 0x200000U /* Added to libpng-1.6.0 */
-#define PNG_FLAG_APP_ERRORS_WARN 0x400000U /* Added to libpng-1.6.0 */
- /* 0x800000U unused */
- /* 0x1000000U unused */
- /* 0x2000000U unused */
- /* 0x4000000U unused */
- /* 0x8000000U unused */
- /* 0x10000000U unused */
- /* 0x20000000U unused */
- /* 0x40000000U unused */
-
-#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \
- PNG_FLAG_CRC_ANCILLARY_NOWARN)
-
-#define PNG_FLAG_CRC_CRITICAL_MASK (PNG_FLAG_CRC_CRITICAL_USE | \
- PNG_FLAG_CRC_CRITICAL_IGNORE)
-
-#define PNG_FLAG_CRC_MASK (PNG_FLAG_CRC_ANCILLARY_MASK | \
- PNG_FLAG_CRC_CRITICAL_MASK)
-
-/* Save typing and make code easier to understand */
-
-#define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \
- abs((int)((c1).green) - (int)((c2).green)) + \
- abs((int)((c1).blue) - (int)((c2).blue)))
-
-/* Added to libpng-1.6.0: scale a 16-bit value in the range 0..65535 to 0..255
- * by dividing by 257 *with rounding*. This macro is exact for the given range.
- * See the discourse in pngrtran.c png_do_scale_16_to_8. The values in the
- * macro were established by experiment (modifying the added value). The macro
- * has a second variant that takes a value already scaled by 255 and divides by
- * 65535 - this has a maximum error of .502. Over the range 0..65535*65535 it
- * only gives off-by-one errors and only for 0.5% (1 in 200) of the values.
- */
-#define PNG_DIV65535(v24) (((v24) + 32895) >> 16)
-#define PNG_DIV257(v16) PNG_DIV65535((png_uint_32)(v16) * 255)
-
-/* Added to libpng-1.2.6 JB */
-#define PNG_ROWBYTES(pixel_bits, width) \
- ((pixel_bits) >= 8 ? \
- ((size_t)(width) * (((size_t)(pixel_bits)) >> 3)) : \
- (( ((size_t)(width) * ((size_t)(pixel_bits))) + 7) >> 3) )
-
-/* This returns the number of trailing bits in the last byte of a row, 0 if the
- * last byte is completely full of pixels. It is, in principle, (pixel_bits x
- * width) % 8, but that would overflow for large 'width'. The second macro is
- * the same except that it returns the number of unused bits in the last byte;
- * (8-TRAILBITS), but 0 when TRAILBITS is 0.
- *
- * NOTE: these macros are intended to be self-evidently correct and never
- * overflow on the assumption that pixel_bits is in the range 0..255. The
- * arguments are evaluated only once and they can be signed (e.g. as a result of
- * the integral promotions). The result of the expression always has type
- * (png_uint_32), however the compiler always knows it is in the range 0..7.
- */
-#define PNG_TRAILBITS(pixel_bits, width) \
- (((pixel_bits) * ((width) % (png_uint_32)8)) % 8)
-
-#define PNG_PADBITS(pixel_bits, width) \
- ((8 - PNG_TRAILBITS(pixel_bits, width)) % 8)
-
-/* PNG_OUT_OF_RANGE returns true if value is outside the range
- * ideal-delta..ideal+delta. Each argument is evaluated twice.
- * "ideal" and "delta" should be constants, normally simple
- * integers, "value" a variable. Added to libpng-1.2.6 JB
- */
-#define PNG_OUT_OF_RANGE(value, ideal, delta) \
- ( (value) < (ideal)-(delta) || (value) > (ideal)+(delta) )
-
-/* Conversions between fixed and floating point, only defined if
- * required (to make sure the code doesn't accidentally use float
- * when it is supposedly disabled.)
- */
-#ifdef PNG_FLOATING_POINT_SUPPORTED
-/* The floating point conversion can't overflow, though it can and
- * does lose accuracy relative to the original fixed point value.
- * In practice this doesn't matter because png_fixed_point only
- * stores numbers with very low precision. The png_ptr and s
- * arguments are unused by default but are there in case error
- * checking becomes a requirement.
- */
-#define png_float(png_ptr, fixed, s) (.00001 * (fixed))
-
-/* The fixed point conversion performs range checking and evaluates
- * its argument multiple times, so must be used with care. The
- * range checking uses the PNG specification values for a signed
- * 32-bit fixed point value except that the values are deliberately
- * rounded-to-zero to an integral value - 21474 (21474.83 is roughly
- * (2^31-1) * 100000). 's' is a string that describes the value being
- * converted.
- *
- * NOTE: this macro will raise a png_error if the range check fails,
- * therefore it is normally only appropriate to use this on values
- * that come from API calls or other sources where an out of range
- * error indicates a programming error, not a data error!
- *
- * NOTE: by default this is off - the macro is not used - because the
- * function call saves a lot of code.
- */
-#ifdef PNG_FIXED_POINT_MACRO_SUPPORTED
-#define png_fixed(png_ptr, fp, s) ((fp) <= 21474 && (fp) >= -21474 ?\
- ((png_fixed_point)(100000 * (fp))) : (png_fixed_error(png_ptr, s),0))
-#define png_fixed_ITU(png_ptr, fp, s) ((fp) <= 214748 && (fp) >= 0 ?\
- ((png_uint_32)(10000 * (fp))) : (png_fixed_error(png_ptr, s),0))
-#endif
-/* else the corresponding function is defined below, inside the scope of the
- * cplusplus test.
- */
-#endif
-
-/* Constants for known chunk types. If you need to add a chunk, define the name
- * here. For historical reasons these constants have the form png_<name>; i.e.
- * the prefix is lower case. Please use decimal values as the parameters to
- * match the ISO PNG specification and to avoid relying on the C locale
- * interpretation of character values.
- *
- * Prior to 1.5.6 these constants were strings, as of 1.5.6 png_uint_32 values
- * are computed and a new macro (PNG_STRING_FROM_CHUNK) added to allow a string
- * to be generated if required.
- *
- * PNG_32b correctly produces a value shifted by up to 24 bits, even on
- * architectures where (int) is only 16 bits.
- */
-#define PNG_32b(b,s) ((png_uint_32)(b) << (s))
-#define PNG_U32(b1,b2,b3,b4) \
- (PNG_32b(b1,24) | PNG_32b(b2,16) | PNG_32b(b3,8) | PNG_32b(b4,0))
-
-/* Constants for known chunk types.
- *
- * MAINTAINERS: If you need to add a chunk, define the name here.
- * For historical reasons these constants have the form png_<name>; i.e.
- * the prefix is lower case. Please use decimal values as the parameters to
- * match the ISO PNG specification and to avoid relying on the C locale
- * interpretation of character values. Please keep the list sorted.
- *
- * Notice that PNG_U32 is used to define a 32-bit value for the 4 byte chunk
- * type. In fact the specification does not express chunk types this way,
- * however using a 32-bit value means that the chunk type can be read from the
- * stream using exactly the same code as used for a 32-bit unsigned value and
- * can be examined far more efficiently (using one arithmetic compare).
- *
- * Prior to 1.5.6 the chunk type constants were expressed as C strings. The
- * libpng API still uses strings for 'unknown' chunks and a macro,
- * PNG_STRING_FROM_CHUNK, allows a string to be generated if required. Notice
- * that for portable code numeric values must still be used; the string "IHDR"
- * is not portable and neither is PNG_U32('I', 'H', 'D', 'R').
- *
- * In 1.7.0 the definitions will be made public in png.h to avoid having to
- * duplicate the same definitions in application code.
- */
-#define png_IDAT PNG_U32( 73, 68, 65, 84)
-#define png_IEND PNG_U32( 73, 69, 78, 68)
-#define png_IHDR PNG_U32( 73, 72, 68, 82)
-#define png_PLTE PNG_U32( 80, 76, 84, 69)
-#define png_bKGD PNG_U32( 98, 75, 71, 68)
-#define png_cHRM PNG_U32( 99, 72, 82, 77)
-#define png_cICP PNG_U32( 99, 73, 67, 80) /* PNGv3 */
-#define png_cLLI PNG_U32( 99, 76, 76, 73) /* PNGv3 */
-#define png_eXIf PNG_U32(101, 88, 73, 102) /* registered July 2017 */
-#define png_fRAc PNG_U32(102, 82, 65, 99) /* registered, not defined */
-#define png_gAMA PNG_U32(103, 65, 77, 65)
-#define png_gIFg PNG_U32(103, 73, 70, 103)
-#define png_gIFt PNG_U32(103, 73, 70, 116) /* deprecated */
-#define png_gIFx PNG_U32(103, 73, 70, 120)
-#define png_hIST PNG_U32(104, 73, 83, 84)
-#define png_iCCP PNG_U32(105, 67, 67, 80)
-#define png_iTXt PNG_U32(105, 84, 88, 116)
-#define png_mDCV PNG_U32(109, 68, 67, 86) /* PNGv3 */
-#define png_oFFs PNG_U32(111, 70, 70, 115)
-#define png_pCAL PNG_U32(112, 67, 65, 76)
-#define png_pHYs PNG_U32(112, 72, 89, 115)
-#define png_sBIT PNG_U32(115, 66, 73, 84)
-#define png_sCAL PNG_U32(115, 67, 65, 76)
-#define png_sPLT PNG_U32(115, 80, 76, 84)
-#define png_sRGB PNG_U32(115, 82, 71, 66)
-#define png_sTER PNG_U32(115, 84, 69, 82)
-#define png_tEXt PNG_U32(116, 69, 88, 116)
-#define png_tIME PNG_U32(116, 73, 77, 69)
-#define png_tRNS PNG_U32(116, 82, 78, 83)
-#define png_zTXt PNG_U32(122, 84, 88, 116)
-
-#ifdef PNG_APNG_SUPPORTED
-#define png_acTL PNG_U32( 97, 99, 84, 76)
-#define png_fcTL PNG_U32(102, 99, 84, 76)
-#define png_fdAT PNG_U32(102, 100, 65, 84)
-
-/* For png_struct.apng_flags: */
-#define PNG_FIRST_FRAME_HIDDEN 0x0001U
-#define PNG_APNG_APP 0x0002U
-#endif
-
-/* The following will work on (signed char*) strings, whereas the get_uint_32
- * macro will fail on top-bit-set values because of the sign extension.
- */
-#define PNG_CHUNK_FROM_STRING(s)\
- PNG_U32(0xff & (s)[0], 0xff & (s)[1], 0xff & (s)[2], 0xff & (s)[3])
-
-/* This uses (char), not (png_byte) to avoid warnings on systems where (char) is
- * signed and the argument is a (char[]) This macro will fail miserably on
- * systems where (char) is more than 8 bits.
- */
-#define PNG_STRING_FROM_CHUNK(s,c)\
- (void)(((char*)(s))[0]=(char)(((c)>>24) & 0xff), \
- ((char*)(s))[1]=(char)(((c)>>16) & 0xff),\
- ((char*)(s))[2]=(char)(((c)>>8) & 0xff), \
- ((char*)(s))[3]=(char)((c & 0xff)))
-
-/* Do the same but terminate with a null character. */
-#define PNG_CSTRING_FROM_CHUNK(s,c)\
- (void)(PNG_STRING_FROM_CHUNK(s,c), ((char*)(s))[4] = 0)
-
-/* Test on flag values as defined in the spec (section 5.4): */
-#define PNG_CHUNK_ANCILLARY(c) (1 & ((c) >> 29))
-#define PNG_CHUNK_CRITICAL(c) (!PNG_CHUNK_ANCILLARY(c))
-#define PNG_CHUNK_PRIVATE(c) (1 & ((c) >> 21))
-#define PNG_CHUNK_RESERVED(c) (1 & ((c) >> 13))
-#define PNG_CHUNK_SAFE_TO_COPY(c) (1 & ((c) >> 5))
-
-/* Gamma values (new at libpng-1.5.4): */
-#define PNG_GAMMA_MAC_OLD 151724 /* Assume '1.8' is really 2.2/1.45! */
-#define PNG_GAMMA_MAC_INVERSE 65909
-#define PNG_GAMMA_sRGB_INVERSE 45455
-
-/* Almost everything below is C specific; the #defines above can be used in
- * non-C code (so long as it is C-preprocessed) the rest of this stuff cannot.
- */
-#ifndef PNG_VERSION_INFO_ONLY
-
-#include "pngstruct.h"
-#include "pnginfo.h"
-
-/* Validate the include paths - the include path used to generate pnglibconf.h
- * must match that used in the build, or we must be using pnglibconf.h.prebuilt:
- */
-#if PNG_ZLIB_VERNUM != 0 && PNG_ZLIB_VERNUM != ZLIB_VERNUM
-# error ZLIB_VERNUM != PNG_ZLIB_VERNUM \
- "-I (include path) error: see the notes in pngpriv.h"
- /* This means that when pnglibconf.h was built the copy of zlib.h that it
- * used is not the same as the one being used here. Because the build of
- * libpng makes decisions to use inflateInit2 and inflateReset2 based on the
- * zlib version number and because this affects handling of certain broken
- * PNG files the -I directives must match.
- *
- * The most likely explanation is that you passed a -I in CFLAGS. This will
- * not work; all the preprocessor directives and in particular all the -I
- * directives must be in CPPFLAGS.
- */
-#endif
-
-/* This is used for 16-bit gamma tables -- only the top level pointers are
- * const; this could be changed:
- */
-typedef const png_uint_16p * png_const_uint_16pp;
-
-/* Added to libpng-1.5.7: sRGB conversion tables */
-#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\
- defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)
-#ifdef PNG_SIMPLIFIED_READ_SUPPORTED
-PNG_INTERNAL_DATA(const png_uint_16, png_sRGB_table, [256]);
- /* Convert from an sRGB encoded value 0..255 to a 16-bit linear value,
- * 0..65535. This table gives the closest 16-bit answers (no errors).
- */
-#endif
-
-PNG_INTERNAL_DATA(const png_uint_16, png_sRGB_base, [512]);
-PNG_INTERNAL_DATA(const png_byte, png_sRGB_delta, [512]);
-
-#define PNG_sRGB_FROM_LINEAR(linear) \
- ((png_byte)(0xff & ((png_sRGB_base[(linear)>>15] \
- + ((((linear) & 0x7fff)*png_sRGB_delta[(linear)>>15])>>12)) >> 8)))
- /* Given a value 'linear' in the range 0..255*65535 calculate the 8-bit sRGB
- * encoded value with maximum error 0.646365. Note that the input is not a
- * 16-bit value; it has been multiplied by 255! */
-#endif /* SIMPLIFIED_READ/WRITE */
-
-
-/* Inhibit C++ name-mangling for libpng functions but not for system calls. */
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/* Internal functions; these are not exported from a DLL however because they
- * are used within several of the C source files they have to be C extern.
- *
- * All of these functions must be declared with PNG_INTERNAL_FUNCTION.
- */
-
-/* Zlib support */
-#define PNG_UNEXPECTED_ZLIB_RETURN (-7)
-PNG_INTERNAL_FUNCTION(void, png_zstream_error,(png_structrp png_ptr, int ret),
- PNG_EMPTY);
- /* Used by the zlib handling functions to ensure that z_stream::msg is always
- * set before they return.
- */
-
-#ifdef PNG_WRITE_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_free_buffer_list,(png_structrp png_ptr,
- png_compression_bufferp *list),PNG_EMPTY);
- /* Free the buffer list used by the compressed write code. */
-#endif
-
-#if defined(PNG_FLOATING_POINT_SUPPORTED) && \
- !defined(PNG_FIXED_POINT_MACRO_SUPPORTED) && \
- (defined(PNG_gAMA_SUPPORTED) || defined(PNG_cHRM_SUPPORTED) || \
- defined(PNG_sCAL_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) || \
- defined(PNG_mDCV_SUPPORTED) || \
- defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)) || \
- (defined(PNG_sCAL_SUPPORTED) && \
- defined(PNG_FLOATING_ARITHMETIC_SUPPORTED))
-PNG_INTERNAL_FUNCTION(png_fixed_point,png_fixed,(png_const_structrp png_ptr,
- double fp, png_const_charp text),PNG_EMPTY);
-#endif
-
-#if defined(PNG_FLOATING_POINT_SUPPORTED) && \
- !defined(PNG_FIXED_POINT_MACRO_SUPPORTED) && \
- (defined(PNG_cLLI_SUPPORTED) || defined(PNG_mDCV_SUPPORTED))
-PNG_INTERNAL_FUNCTION(png_uint_32,png_fixed_ITU,(png_const_structrp png_ptr,
- double fp, png_const_charp text),PNG_EMPTY);
-#endif
-
-/* Check the user version string for compatibility, returns false if the version
- * numbers aren't compatible.
- */
-PNG_INTERNAL_FUNCTION(int,png_user_version_check,(png_structrp png_ptr,
- png_const_charp user_png_ver),PNG_EMPTY);
-
-/* Internal base allocator - no messages, NULL on failure to allocate. This
- * does, however, call the application provided allocator and that could call
- * png_error (although that would be a bug in the application implementation.)
- */
-PNG_INTERNAL_FUNCTION(png_voidp,png_malloc_base,(png_const_structrp png_ptr,
- png_alloc_size_t size),PNG_ALLOCATED);
-
-#if defined(PNG_TEXT_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) ||\
- defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED)
-/* Internal array allocator, outputs no error or warning messages on failure,
- * just returns NULL.
- */
-PNG_INTERNAL_FUNCTION(png_voidp,png_malloc_array,(png_const_structrp png_ptr,
- int nelements, size_t element_size),PNG_ALLOCATED);
-
-/* The same but an existing array is extended by add_elements. This function
- * also memsets the new elements to 0 and copies the old elements. The old
- * array is not freed or altered.
- */
-PNG_INTERNAL_FUNCTION(png_voidp,png_realloc_array,(png_const_structrp png_ptr,
- png_const_voidp array, int old_elements, int add_elements,
- size_t element_size),PNG_ALLOCATED);
-#endif /* text, sPLT or unknown chunks */
-
-/* Magic to create a struct when there is no struct to call the user supplied
- * memory allocators. Because error handling has not been set up the memory
- * handlers can't safely call png_error, but this is an obscure and undocumented
- * restriction so libpng has to assume that the 'free' handler, at least, might
- * call png_error.
- */
-PNG_INTERNAL_FUNCTION(png_structp,png_create_png_struct,
- (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn,
- png_error_ptr warn_fn, png_voidp mem_ptr, png_malloc_ptr malloc_fn,
- png_free_ptr free_fn),PNG_ALLOCATED);
-
-/* Free memory from internal libpng struct */
-PNG_INTERNAL_FUNCTION(void,png_destroy_png_struct,(png_structrp png_ptr),
- PNG_EMPTY);
-
-/* Free an allocated jmp_buf (always succeeds) */
-PNG_INTERNAL_FUNCTION(void,png_free_jmpbuf,(png_structrp png_ptr),PNG_EMPTY);
-
-/* Function to allocate memory for zlib. PNGAPI is disallowed. */
-PNG_INTERNAL_FUNCTION(voidpf,png_zalloc,(voidpf png_ptr, uInt items, uInt size),
- PNG_ALLOCATED);
-
-/* Function to free memory for zlib. PNGAPI is disallowed. */
-PNG_INTERNAL_FUNCTION(void,png_zfree,(voidpf png_ptr, voidpf ptr),PNG_EMPTY);
-
-/* Next four functions are used internally as callbacks. PNGCBAPI is required
- * but not PNG_EXPORT. PNGAPI added at libpng version 1.2.3, changed to
- * PNGCBAPI at 1.5.0
- */
-
-PNG_INTERNAL_FUNCTION(void PNGCBAPI,png_default_read_data,(png_structp png_ptr,
- png_bytep data, size_t length),PNG_EMPTY);
-
-#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
-PNG_INTERNAL_FUNCTION(void PNGCBAPI,png_push_fill_buffer,(png_structp png_ptr,
- png_bytep buffer, size_t length),PNG_EMPTY);
-#endif
-
-PNG_INTERNAL_FUNCTION(void PNGCBAPI,png_default_write_data,(png_structp png_ptr,
- png_bytep data, size_t length),PNG_EMPTY);
-
-#ifdef PNG_WRITE_FLUSH_SUPPORTED
-# ifdef PNG_STDIO_SUPPORTED
-PNG_INTERNAL_FUNCTION(void PNGCBAPI,png_default_flush,(png_structp png_ptr),
- PNG_EMPTY);
-# endif
-#endif
-
-/* Reset the CRC variable */
-PNG_INTERNAL_FUNCTION(void,png_reset_crc,(png_structrp png_ptr),PNG_EMPTY);
-
-/* Write the "data" buffer to whatever output you are using */
-PNG_INTERNAL_FUNCTION(void,png_write_data,(png_structrp png_ptr,
- png_const_bytep data, size_t length),PNG_EMPTY);
-
-/* Read and check the PNG file signature */
-PNG_INTERNAL_FUNCTION(void,png_read_sig,(png_structrp png_ptr,
- png_inforp info_ptr),PNG_EMPTY);
-
-/* Read the chunk header (length + type name) */
-PNG_INTERNAL_FUNCTION(png_uint_32,png_read_chunk_header,(png_structrp png_ptr),
- PNG_EMPTY);
-
-/* Read data from whatever input you are using into the "data" buffer */
-PNG_INTERNAL_FUNCTION(void,png_read_data,(png_structrp png_ptr, png_bytep data,
- size_t length),PNG_EMPTY);
-
-/* Read bytes into buf, and update png_ptr->crc */
-PNG_INTERNAL_FUNCTION(void,png_crc_read,(png_structrp png_ptr, png_bytep buf,
- png_uint_32 length),PNG_EMPTY);
-
-/* Read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */
-PNG_INTERNAL_FUNCTION(int,png_crc_finish,(png_structrp png_ptr,
- png_uint_32 skip),PNG_EMPTY);
-
-/* Read the CRC from the file and compare it to the libpng calculated CRC */
-PNG_INTERNAL_FUNCTION(int,png_crc_error,(png_structrp png_ptr),PNG_EMPTY);
-
-/* Calculate the CRC over a section of data. Note that we are only
- * passing a maximum of 64K on systems that have this as a memory limit,
- * since this is the maximum buffer size we can specify.
- */
-PNG_INTERNAL_FUNCTION(void,png_calculate_crc,(png_structrp png_ptr,
- png_const_bytep ptr, size_t length),PNG_EMPTY);
-
-#ifdef PNG_WRITE_FLUSH_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_flush,(png_structrp png_ptr),PNG_EMPTY);
-#endif
-
-/* Write various chunks */
-
-/* Write the IHDR chunk, and update the png_struct with the necessary
- * information.
- */
-PNG_INTERNAL_FUNCTION(void,png_write_IHDR,(png_structrp png_ptr,
- png_uint_32 width, png_uint_32 height, int bit_depth, int color_type,
- int compression_method, int filter_method, int interlace_method),PNG_EMPTY);
-
-PNG_INTERNAL_FUNCTION(void,png_write_PLTE,(png_structrp png_ptr,
- png_const_colorp palette, png_uint_32 num_pal),PNG_EMPTY);
-
-PNG_INTERNAL_FUNCTION(void,png_compress_IDAT,(png_structrp png_ptr,
- png_const_bytep row_data, png_alloc_size_t row_data_length, int flush),
- PNG_EMPTY);
-
-PNG_INTERNAL_FUNCTION(void,png_write_IEND,(png_structrp png_ptr),PNG_EMPTY);
-
-#ifdef PNG_WRITE_gAMA_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_write_gAMA_fixed,(png_structrp png_ptr,
- png_fixed_point file_gamma),PNG_EMPTY);
-#endif
-
-#ifdef PNG_WRITE_sBIT_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_write_sBIT,(png_structrp png_ptr,
- png_const_color_8p sbit, int color_type),PNG_EMPTY);
-#endif
-
-#ifdef PNG_WRITE_cHRM_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_write_cHRM_fixed,(png_structrp png_ptr,
- const png_xy *xy), PNG_EMPTY);
- /* The xy value must have been previously validated */
-#endif
-
-#ifdef PNG_WRITE_cICP_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_write_cICP,(png_structrp png_ptr,
- png_byte colour_primaries, png_byte transfer_function,
- png_byte matrix_coefficients, png_byte video_full_range_flag), PNG_EMPTY);
-#endif
-
-#ifdef PNG_WRITE_cLLI_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_write_cLLI_fixed,(png_structrp png_ptr,
- png_uint_32 maxCLL, png_uint_32 maxFALL), PNG_EMPTY);
-#endif
-
-#ifdef PNG_WRITE_mDCV_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_write_mDCV_fixed,(png_structrp png_ptr,
- png_uint_16 red_x, png_uint_16 red_y,
- png_uint_16 green_x, png_uint_16 green_y,
- png_uint_16 blue_x, png_uint_16 blue_y,
- png_uint_16 white_x, png_uint_16 white_y,
- png_uint_32 maxDL, png_uint_32 minDL), PNG_EMPTY);
-#endif
-
-#ifdef PNG_WRITE_sRGB_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_write_sRGB,(png_structrp png_ptr,
- int intent),PNG_EMPTY);
-#endif
-
-#ifdef PNG_WRITE_eXIf_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_write_eXIf,(png_structrp png_ptr,
- png_bytep exif, int num_exif),PNG_EMPTY);
-#endif
-
-#ifdef PNG_WRITE_iCCP_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_write_iCCP,(png_structrp png_ptr,
- png_const_charp name, png_const_bytep profile), PNG_EMPTY);
- /* The profile must have been previously validated for correctness, the
- * length comes from the first four bytes. Only the base, deflate,
- * compression is supported.
- */
-#endif
-
-#ifdef PNG_WRITE_sPLT_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_write_sPLT,(png_structrp png_ptr,
- png_const_sPLT_tp palette),PNG_EMPTY);
-#endif
-
-#ifdef PNG_WRITE_tRNS_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_write_tRNS,(png_structrp png_ptr,
- png_const_bytep trans, png_const_color_16p values, int number,
- int color_type),PNG_EMPTY);
-#endif
-
-#ifdef PNG_WRITE_bKGD_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_write_bKGD,(png_structrp png_ptr,
- png_const_color_16p values, int color_type),PNG_EMPTY);
-#endif
-
-#ifdef PNG_WRITE_hIST_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_write_hIST,(png_structrp png_ptr,
- png_const_uint_16p hist, int num_hist),PNG_EMPTY);
-#endif
-
-/* Chunks that have keywords */
-#ifdef PNG_WRITE_tEXt_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_write_tEXt,(png_structrp png_ptr,
- png_const_charp key, png_const_charp text, size_t text_len),PNG_EMPTY);
-#endif
-
-#ifdef PNG_WRITE_zTXt_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_write_zTXt,(png_structrp png_ptr, png_const_charp
- key, png_const_charp text, int compression),PNG_EMPTY);
-#endif
-
-#ifdef PNG_WRITE_iTXt_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_write_iTXt,(png_structrp png_ptr,
- int compression, png_const_charp key, png_const_charp lang,
- png_const_charp lang_key, png_const_charp text),PNG_EMPTY);
-#endif
-
-#ifdef PNG_TEXT_SUPPORTED /* Added at version 1.0.14 and 1.2.4 */
-PNG_INTERNAL_FUNCTION(int,png_set_text_2,(png_const_structrp png_ptr,
- png_inforp info_ptr, png_const_textp text_ptr, int num_text),PNG_EMPTY);
-#endif
-
-#ifdef PNG_WRITE_oFFs_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_write_oFFs,(png_structrp png_ptr,
- png_int_32 x_offset, png_int_32 y_offset, int unit_type),PNG_EMPTY);
-#endif
-
-#ifdef PNG_WRITE_pCAL_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_write_pCAL,(png_structrp png_ptr,
- png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams,
- png_const_charp units, png_charpp params),PNG_EMPTY);
-#endif
-
-#ifdef PNG_WRITE_pHYs_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_write_pHYs,(png_structrp png_ptr,
- png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit,
- int unit_type),PNG_EMPTY);
-#endif
-
-#ifdef PNG_WRITE_tIME_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_write_tIME,(png_structrp png_ptr,
- png_const_timep mod_time),PNG_EMPTY);
-#endif
-
-#ifdef PNG_WRITE_sCAL_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_write_sCAL_s,(png_structrp png_ptr,
- int unit, png_const_charp width, png_const_charp height),PNG_EMPTY);
-#endif
-
-/* Called when finished processing a row of data */
-PNG_INTERNAL_FUNCTION(void,png_write_finish_row,(png_structrp png_ptr),
- PNG_EMPTY);
-
-/* Internal use only. Called before first row of data */
-PNG_INTERNAL_FUNCTION(void,png_write_start_row,(png_structrp png_ptr),
- PNG_EMPTY);
-
-/* Combine a row of data, dealing with alpha, etc. if requested. 'row' is an
- * array of png_ptr->width pixels. If the image is not interlaced or this
- * is the final pass this just does a memcpy, otherwise the "display" flag
- * is used to determine whether to copy pixels that are not in the current pass.
- *
- * Because 'png_do_read_interlace' (below) replicates pixels this allows this
- * function to achieve the documented 'blocky' appearance during interlaced read
- * if display is 1 and the 'sparkle' appearance, where existing pixels in 'row'
- * are not changed if they are not in the current pass, when display is 0.
- *
- * 'display' must be 0 or 1, otherwise the memcpy will be done regardless.
- *
- * The API always reads from the png_struct row buffer and always assumes that
- * it is full width (png_do_read_interlace has already been called.)
- *
- * This function is only ever used to write to row buffers provided by the
- * caller of the relevant libpng API and the row must have already been
- * transformed by the read transformations.
- *
- * The PNG_USE_COMPILE_TIME_MASKS option causes generation of pre-computed
- * bitmasks for use within the code, otherwise runtime generated masks are used.
- * The default is compile time masks.
- */
-#ifndef PNG_USE_COMPILE_TIME_MASKS
-# define PNG_USE_COMPILE_TIME_MASKS 1
-#endif
-PNG_INTERNAL_FUNCTION(void,png_combine_row,(png_const_structrp png_ptr,
- png_bytep row, int display),PNG_EMPTY);
-
-#ifdef PNG_READ_INTERLACING_SUPPORTED
-/* Expand an interlaced row: the 'row_info' describes the pass data that has
- * been read in and must correspond to the pixels in 'row', the pixels are
- * expanded (moved apart) in 'row' to match the final layout, when doing this
- * the pixels are *replicated* to the intervening space. This is essential for
- * the correct operation of png_combine_row, above.
- */
-PNG_INTERNAL_FUNCTION(void,png_do_read_interlace,(png_row_infop row_info,
- png_bytep row, int pass, png_uint_32 transformations),PNG_EMPTY);
-#endif
-
-/* GRR TO DO (2.0 or whenever): simplify other internal calling interfaces */
-
-#ifdef PNG_WRITE_INTERLACING_SUPPORTED
-/* Grab pixels out of a row for an interlaced pass */
-PNG_INTERNAL_FUNCTION(void,png_do_write_interlace,(png_row_infop row_info,
- png_bytep row, int pass),PNG_EMPTY);
-#endif
-
-/* Unfilter a row: check the filter value before calling this, there is no point
- * calling it for PNG_FILTER_VALUE_NONE.
- */
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row,(png_structrp pp, png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row, int filter),PNG_EMPTY);
-
-#if PNG_ARM_NEON_OPT > 0
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_neon,(png_row_infop row_info,
- png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_neon,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_neon,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_neon,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_neon,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_neon,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_neon,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-#endif
-
-#if PNG_MIPS_MSA_IMPLEMENTATION == 1
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_msa,(png_row_infop row_info,
- png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_msa,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_msa,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_msa,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_msa,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_msa,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_msa,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-#endif
-
-#if PNG_MIPS_MMI_IMPLEMENTATION > 0
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_mmi,(png_row_infop row_info,
- png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_mmi,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_mmi,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_mmi,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_mmi,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_mmi,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_mmi,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-#endif
-
-#if PNG_POWERPC_VSX_OPT > 0
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_vsx,(png_row_infop row_info,
- png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_vsx,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_vsx,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_vsx,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_vsx,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_vsx,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_vsx,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-#endif
-
-#if PNG_INTEL_SSE_IMPLEMENTATION > 0
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_sse2,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_sse2,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_sse2,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_sse2,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_sse2,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_sse2,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-#endif
-
-#if PNG_LOONGARCH_LSX_IMPLEMENTATION == 1
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_lsx,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_lsx,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_lsx,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_lsx,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_lsx,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_lsx,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_lsx,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-#endif
-
-/* Choose the best filter to use and filter the row data */
-PNG_INTERNAL_FUNCTION(void,png_write_find_filter,(png_structrp png_ptr,
- png_row_infop row_info),PNG_EMPTY);
-
-#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_read_IDAT_data,(png_structrp png_ptr,
- png_bytep output, png_alloc_size_t avail_out),PNG_EMPTY);
- /* Read 'avail_out' bytes of data from the IDAT stream. If the output buffer
- * is NULL the function checks, instead, for the end of the stream. In this
- * case a benign error will be issued if the stream end is not found or if
- * extra data has to be consumed.
- */
-PNG_INTERNAL_FUNCTION(void,png_read_finish_IDAT,(png_structrp png_ptr),
- PNG_EMPTY);
- /* This cleans up when the IDAT LZ stream does not end when the last image
- * byte is read; there is still some pending input.
- */
-
-PNG_INTERNAL_FUNCTION(void,png_read_finish_row,(png_structrp png_ptr),
- PNG_EMPTY);
- /* Finish a row while reading, dealing with interlacing passes, etc. */
-#endif /* SEQUENTIAL_READ */
-
-/* Initialize the row buffers, etc. */
-PNG_INTERNAL_FUNCTION(void,png_read_start_row,(png_structrp png_ptr),PNG_EMPTY);
-
-#if ZLIB_VERNUM >= 0x1240
-PNG_INTERNAL_FUNCTION(int,png_zlib_inflate,(png_structrp png_ptr, int flush),
- PNG_EMPTY);
-# define PNG_INFLATE(pp, flush) png_zlib_inflate(pp, flush)
-#else /* Zlib < 1.2.4 */
-# define PNG_INFLATE(pp, flush) inflate(&(pp)->zstream, flush)
-#endif /* Zlib < 1.2.4 */
-
-#ifdef PNG_READ_TRANSFORMS_SUPPORTED
-/* Optional call to update the users info structure */
-PNG_INTERNAL_FUNCTION(void,png_read_transform_info,(png_structrp png_ptr,
- png_inforp info_ptr),PNG_EMPTY);
-#endif
-
-/* Shared transform functions, defined in pngtran.c */
-#if defined(PNG_WRITE_FILLER_SUPPORTED) || \
- defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
-PNG_INTERNAL_FUNCTION(void,png_do_strip_channel,(png_row_infop row_info,
- png_bytep row, int at_start),PNG_EMPTY);
-#endif
-
-#ifdef PNG_16BIT_SUPPORTED
-#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
-PNG_INTERNAL_FUNCTION(void,png_do_swap,(png_row_infop row_info,
- png_bytep row),PNG_EMPTY);
-#endif
-#endif
-
-#if defined(PNG_READ_PACKSWAP_SUPPORTED) || \
- defined(PNG_WRITE_PACKSWAP_SUPPORTED)
-PNG_INTERNAL_FUNCTION(void,png_do_packswap,(png_row_infop row_info,
- png_bytep row),PNG_EMPTY);
-#endif
-
-#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
-PNG_INTERNAL_FUNCTION(void,png_do_invert,(png_row_infop row_info,
- png_bytep row),PNG_EMPTY);
-#endif
-
-#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
-PNG_INTERNAL_FUNCTION(void,png_do_bgr,(png_row_infop row_info,
- png_bytep row),PNG_EMPTY);
-#endif
-
-/* The following decodes the appropriate chunks, and does error correction,
- * then calls the appropriate callback for the chunk if it is valid.
- */
-
-/* Decode the IHDR chunk */
-PNG_INTERNAL_FUNCTION(void,png_handle_IHDR,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_handle_PLTE,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_handle_IEND,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-
-#ifdef PNG_READ_bKGD_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_handle_bKGD,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-#endif
-
-#ifdef PNG_READ_cHRM_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_handle_cHRM,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-#endif
-
-#ifdef PNG_READ_cICP_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_handle_cICP,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-#endif
-
-#ifdef PNG_READ_cLLI_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_handle_cLLI,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-#endif
-
-#ifdef PNG_READ_eXIf_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_handle_eXIf,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-#endif
-
-#ifdef PNG_READ_gAMA_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_handle_gAMA,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-#endif
-
-#ifdef PNG_READ_hIST_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_handle_hIST,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-#endif
-
-#ifdef PNG_READ_iCCP_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_handle_iCCP,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-#endif /* READ_iCCP */
-
-#ifdef PNG_READ_iTXt_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_handle_iTXt,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-#endif
-
-#ifdef PNG_READ_mDCV_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_handle_mDCV,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-#endif
-
-#ifdef PNG_READ_oFFs_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_handle_oFFs,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-#endif
-
-#ifdef PNG_READ_pCAL_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_handle_pCAL,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-#endif
-
-#ifdef PNG_READ_pHYs_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_handle_pHYs,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-#endif
-
-#ifdef PNG_READ_sBIT_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_handle_sBIT,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-#endif
-
-#ifdef PNG_READ_sCAL_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_handle_sCAL,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-#endif
-
-#ifdef PNG_READ_sPLT_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_handle_sPLT,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-#endif /* READ_sPLT */
-
-#ifdef PNG_READ_sRGB_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_handle_sRGB,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-#endif
-
-#ifdef PNG_READ_tEXt_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_handle_tEXt,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-#endif
-
-#ifdef PNG_READ_tIME_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_handle_tIME,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-#endif
-
-#ifdef PNG_READ_tRNS_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_handle_tRNS,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-#endif
-
-#ifdef PNG_READ_zTXt_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_handle_zTXt,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-#endif
-
-PNG_INTERNAL_FUNCTION(void,png_check_chunk_name,(png_const_structrp png_ptr,
- png_uint_32 chunk_name),PNG_EMPTY);
-
-PNG_INTERNAL_FUNCTION(void,png_check_chunk_length,(png_const_structrp png_ptr,
- png_uint_32 chunk_length),PNG_EMPTY);
-
-PNG_INTERNAL_FUNCTION(void,png_handle_unknown,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length, int keep),PNG_EMPTY);
- /* This is the function that gets called for unknown chunks. The 'keep'
- * argument is either non-zero for a known chunk that has been set to be
- * handled as unknown or zero for an unknown chunk. By default the function
- * just skips the chunk or errors out if it is critical.
- */
-
-#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) ||\
- defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
-PNG_INTERNAL_FUNCTION(int,png_chunk_unknown_handling,
- (png_const_structrp png_ptr, png_uint_32 chunk_name),PNG_EMPTY);
- /* Exactly as the API png_handle_as_unknown() except that the argument is a
- * 32-bit chunk name, not a string.
- */
-#endif /* READ_UNKNOWN_CHUNKS || HANDLE_AS_UNKNOWN */
-
-/* Handle the transformations for reading and writing */
-#ifdef PNG_READ_TRANSFORMS_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_do_read_transformations,(png_structrp png_ptr,
- png_row_infop row_info),PNG_EMPTY);
-#endif
-#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_do_write_transformations,(png_structrp png_ptr,
- png_row_infop row_info),PNG_EMPTY);
-#endif
-
-#ifdef PNG_READ_TRANSFORMS_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_init_read_transformations,(png_structrp png_ptr),
- PNG_EMPTY);
-#endif
-
-#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_push_read_chunk,(png_structrp png_ptr,
- png_inforp info_ptr),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_push_read_sig,(png_structrp png_ptr,
- png_inforp info_ptr),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_push_check_crc,(png_structrp png_ptr),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_push_save_buffer,(png_structrp png_ptr),
- PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_push_restore_buffer,(png_structrp png_ptr,
- png_bytep buffer, size_t buffer_length),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_push_read_IDAT,(png_structrp png_ptr),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_process_IDAT_data,(png_structrp png_ptr,
- png_bytep buffer, size_t buffer_length),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_push_process_row,(png_structrp png_ptr),
- PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_push_handle_unknown,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_push_have_info,(png_structrp png_ptr,
- png_inforp info_ptr),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_push_have_end,(png_structrp png_ptr,
- png_inforp info_ptr),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_push_have_row,(png_structrp png_ptr,
- png_bytep row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_push_read_end,(png_structrp png_ptr,
- png_inforp info_ptr),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_process_some_data,(png_structrp png_ptr,
- png_inforp info_ptr),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_push_finish_row,(png_structrp png_ptr),
- PNG_EMPTY);
-# ifdef PNG_READ_tEXt_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_push_handle_tEXt,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_push_read_tEXt,(png_structrp png_ptr,
- png_inforp info_ptr),PNG_EMPTY);
-# endif
-# ifdef PNG_READ_zTXt_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_push_handle_zTXt,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_push_read_zTXt,(png_structrp png_ptr,
- png_inforp info_ptr),PNG_EMPTY);
-# endif
-# ifdef PNG_READ_iTXt_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_push_handle_iTXt,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_push_read_iTXt,(png_structrp png_ptr,
- png_inforp info_ptr),PNG_EMPTY);
-# endif
-
-#endif /* PROGRESSIVE_READ */
-
-#ifdef PNG_APNG_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_ensure_fcTL_is_valid,(png_structp png_ptr,
- png_uint_32 width, png_uint_32 height,
- png_uint_32 x_offset, png_uint_32 y_offset,
- png_uint_16 delay_num, png_uint_16 delay_den,
- png_byte dispose_op, png_byte blend_op),PNG_EMPTY);
-
-#ifdef PNG_READ_APNG_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_handle_acTL,(png_structp png_ptr,
- png_infop info_ptr, png_uint_32 length),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_handle_fcTL,(png_structp png_ptr,
- png_infop info_ptr, png_uint_32 length),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_handle_fdAT,(png_structp png_ptr,
- png_infop info_ptr, png_uint_32 length),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_have_info,(png_structp png_ptr,
- png_infop info_ptr),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_ensure_sequence_number,(png_structp png_ptr,
- png_uint_32 length),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_reset,(png_structp png_ptr),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_reinit,(png_structp png_ptr,
- png_infop info_ptr),PNG_EMPTY);
-#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_progressive_read_reset,(png_structp png_ptr),
- PNG_EMPTY);
-#endif /* PROGRESSIVE_READ */
-#endif /* READ_APNG */
-
-#ifdef PNG_WRITE_APNG_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_write_acTL,(png_structp png_ptr,
- png_uint_32 num_frames, png_uint_32 num_plays),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_write_fcTL,(png_structp png_ptr,
- png_uint_32 width, png_uint_32 height,
- png_uint_32 x_offset, png_uint_32 y_offset,
- png_uint_16 delay_num, png_uint_16 delay_den,
- png_byte dispose_op, png_byte blend_op),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_write_fdAT,(png_structp png_ptr,
- png_const_bytep data, size_t length),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_write_reset,(png_structp png_ptr),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_write_reinit,(png_structp png_ptr,
- png_infop info_ptr, png_uint_32 width, png_uint_32 height),PNG_EMPTY);
-#endif /* WRITE_APNG */
-#endif /* APNG */
-
-/* Added at libpng version 1.6.0 */
-#ifdef PNG_GAMMA_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_colorspace_set_gamma,(png_const_structrp png_ptr,
- png_colorspacerp colorspace, png_fixed_point gAMA), PNG_EMPTY);
- /* Set the colorspace gamma with a value provided by the application or by
- * the gAMA chunk on read. The value will override anything set by an ICC
- * profile.
- */
-
-PNG_INTERNAL_FUNCTION(void,png_colorspace_sync_info,(png_const_structrp png_ptr,
- png_inforp info_ptr), PNG_EMPTY);
- /* Synchronize the info 'valid' flags with the colorspace */
-
-PNG_INTERNAL_FUNCTION(void,png_colorspace_sync,(png_const_structrp png_ptr,
- png_inforp info_ptr), PNG_EMPTY);
- /* Copy the png_struct colorspace to the info_struct and call the above to
- * synchronize the flags. Checks for NULL info_ptr and does nothing.
- */
-#endif
-
-/* Added at libpng version 1.4.0 */
-#ifdef PNG_COLORSPACE_SUPPORTED
-/* These internal functions are for maintaining the colorspace structure within
- * a png_info or png_struct (or, indeed, both).
- */
-PNG_INTERNAL_FUNCTION(int,png_colorspace_set_chromaticities,
- (png_const_structrp png_ptr, png_colorspacerp colorspace, const png_xy *xy,
- int preferred), PNG_EMPTY);
-
-PNG_INTERNAL_FUNCTION(int,png_colorspace_set_endpoints,
- (png_const_structrp png_ptr, png_colorspacerp colorspace, const png_XYZ *XYZ,
- int preferred), PNG_EMPTY);
-
-#ifdef PNG_sRGB_SUPPORTED
-PNG_INTERNAL_FUNCTION(int,png_colorspace_set_sRGB,(png_const_structrp png_ptr,
- png_colorspacerp colorspace, int intent), PNG_EMPTY);
- /* This does set the colorspace gAMA and cHRM values too, but doesn't set the
- * flags to write them, if it returns false there was a problem and an error
- * message has already been output (but the colorspace may still need to be
- * synced to record the invalid flag).
- */
-#endif /* sRGB */
-
-#ifdef PNG_iCCP_SUPPORTED
-PNG_INTERNAL_FUNCTION(int,png_colorspace_set_ICC,(png_const_structrp png_ptr,
- png_colorspacerp colorspace, png_const_charp name,
- png_uint_32 profile_length, png_const_bytep profile, int color_type),
- PNG_EMPTY);
- /* The 'name' is used for information only */
-
-/* Routines for checking parts of an ICC profile. */
-#ifdef PNG_READ_iCCP_SUPPORTED
-PNG_INTERNAL_FUNCTION(int,png_icc_check_length,(png_const_structrp png_ptr,
- png_colorspacerp colorspace, png_const_charp name,
- png_uint_32 profile_length), PNG_EMPTY);
-#endif /* READ_iCCP */
-PNG_INTERNAL_FUNCTION(int,png_icc_check_header,(png_const_structrp png_ptr,
- png_colorspacerp colorspace, png_const_charp name,
- png_uint_32 profile_length,
- png_const_bytep profile /* first 132 bytes only */, int color_type),
- PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(int,png_icc_check_tag_table,(png_const_structrp png_ptr,
- png_colorspacerp colorspace, png_const_charp name,
- png_uint_32 profile_length,
- png_const_bytep profile /* header plus whole tag table */), PNG_EMPTY);
-#ifdef PNG_sRGB_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_icc_set_sRGB,(
- png_const_structrp png_ptr, png_colorspacerp colorspace,
- png_const_bytep profile, uLong adler), PNG_EMPTY);
- /* 'adler' is the Adler32 checksum of the uncompressed profile data. It may
- * be zero to indicate that it is not available. It is used, if provided,
- * as a fast check on the profile when checking to see if it is sRGB.
- */
-#endif
-#endif /* iCCP */
-
-#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_colorspace_set_rgb_coefficients,
- (png_structrp png_ptr), PNG_EMPTY);
- /* Set the rgb_to_gray coefficients from the colorspace Y values */
-#endif /* READ_RGB_TO_GRAY */
-#endif /* COLORSPACE */
-
-/* Added at libpng version 1.4.0 */
-PNG_INTERNAL_FUNCTION(void,png_check_IHDR,(png_const_structrp png_ptr,
- png_uint_32 width, png_uint_32 height, int bit_depth,
- int color_type, int interlace_type, int compression_type,
- int filter_type),PNG_EMPTY);
-
-/* Added at libpng version 1.5.10 */
-#if defined(PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED) || \
- defined(PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED)
-PNG_INTERNAL_FUNCTION(void,png_do_check_palette_indexes,
- (png_structrp png_ptr, png_row_infop row_info),PNG_EMPTY);
-#endif
-
-#if defined(PNG_FLOATING_POINT_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED)
-PNG_INTERNAL_FUNCTION(void,png_fixed_error,(png_const_structrp png_ptr,
- png_const_charp name),PNG_NORETURN);
-#endif
-
-/* Puts 'string' into 'buffer' at buffer[pos], taking care never to overwrite
- * the end. Always leaves the buffer nul terminated. Never errors out (and
- * there is no error code.)
- */
-PNG_INTERNAL_FUNCTION(size_t,png_safecat,(png_charp buffer, size_t bufsize,
- size_t pos, png_const_charp string),PNG_EMPTY);
-
-/* Various internal functions to handle formatted warning messages, currently
- * only implemented for warnings.
- */
-#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_TIME_RFC1123_SUPPORTED)
-/* Utility to dump an unsigned value into a buffer, given a start pointer and
- * and end pointer (which should point just *beyond* the end of the buffer!)
- * Returns the pointer to the start of the formatted string. This utility only
- * does unsigned values.
- */
-PNG_INTERNAL_FUNCTION(png_charp,png_format_number,(png_const_charp start,
- png_charp end, int format, png_alloc_size_t number),PNG_EMPTY);
-
-/* Convenience macro that takes an array: */
-#define PNG_FORMAT_NUMBER(buffer,format,number) \
- png_format_number(buffer, buffer + (sizeof buffer), format, number)
-
-/* Suggested size for a number buffer (enough for 64 bits and a sign!) */
-#define PNG_NUMBER_BUFFER_SIZE 24
-
-/* These are the integer formats currently supported, the name is formed from
- * the standard printf(3) format string.
- */
-#define PNG_NUMBER_FORMAT_u 1 /* chose unsigned API! */
-#define PNG_NUMBER_FORMAT_02u 2
-#define PNG_NUMBER_FORMAT_d 1 /* chose signed API! */
-#define PNG_NUMBER_FORMAT_02d 2
-#define PNG_NUMBER_FORMAT_x 3
-#define PNG_NUMBER_FORMAT_02x 4
-#define PNG_NUMBER_FORMAT_fixed 5 /* choose the signed API */
-#endif
-
-#ifdef PNG_WARNINGS_SUPPORTED
-/* New defines and members adding in libpng-1.5.4 */
-# define PNG_WARNING_PARAMETER_SIZE 32
-# define PNG_WARNING_PARAMETER_COUNT 8 /* Maximum 9; see pngerror.c */
-
-/* An l-value of this type has to be passed to the APIs below to cache the
- * values of the parameters to a formatted warning message.
- */
-typedef char png_warning_parameters[PNG_WARNING_PARAMETER_COUNT][
- PNG_WARNING_PARAMETER_SIZE];
-
-PNG_INTERNAL_FUNCTION(void,png_warning_parameter,(png_warning_parameters p,
- int number, png_const_charp string),PNG_EMPTY);
- /* Parameters are limited in size to PNG_WARNING_PARAMETER_SIZE characters,
- * including the trailing '\0'.
- */
-PNG_INTERNAL_FUNCTION(void,png_warning_parameter_unsigned,
- (png_warning_parameters p, int number, int format, png_alloc_size_t value),
- PNG_EMPTY);
- /* Use png_alloc_size_t because it is an unsigned type as big as any we
- * need to output. Use the following for a signed value.
- */
-PNG_INTERNAL_FUNCTION(void,png_warning_parameter_signed,
- (png_warning_parameters p, int number, int format, png_int_32 value),
- PNG_EMPTY);
-
-PNG_INTERNAL_FUNCTION(void,png_formatted_warning,(png_const_structrp png_ptr,
- png_warning_parameters p, png_const_charp message),PNG_EMPTY);
- /* 'message' follows the X/Open approach of using @1, @2 to insert
- * parameters previously supplied using the above functions. Errors in
- * specifying the parameters will simply result in garbage substitutions.
- */
-#endif
-
-#ifdef PNG_BENIGN_ERRORS_SUPPORTED
-/* Application errors (new in 1.6); use these functions (declared below) for
- * errors in the parameters or order of API function calls on read. The
- * 'warning' should be used for an error that can be handled completely; the
- * 'error' for one which can be handled safely but which may lose application
- * information or settings.
- *
- * By default these both result in a png_error call prior to release, while in a
- * released version the 'warning' is just a warning. However if the application
- * explicitly disables benign errors (explicitly permitting the code to lose
- * information) they both turn into warnings.
- *
- * If benign errors aren't supported they end up as the corresponding base call
- * (png_warning or png_error.)
- */
-PNG_INTERNAL_FUNCTION(void,png_app_warning,(png_const_structrp png_ptr,
- png_const_charp message),PNG_EMPTY);
- /* The application provided invalid parameters to an API function or called
- * an API function at the wrong time, libpng can completely recover.
- */
-
-PNG_INTERNAL_FUNCTION(void,png_app_error,(png_const_structrp png_ptr,
- png_const_charp message),PNG_EMPTY);
- /* As above but libpng will ignore the call, or attempt some other partial
- * recovery from the error.
- */
-#else
-# define png_app_warning(pp,s) png_warning(pp,s)
-# define png_app_error(pp,s) png_error(pp,s)
-#endif
-
-PNG_INTERNAL_FUNCTION(void,png_chunk_report,(png_const_structrp png_ptr,
- png_const_charp message, int error),PNG_EMPTY);
- /* Report a recoverable issue in chunk data. On read this is used to report
- * a problem found while reading a particular chunk and the
- * png_chunk_benign_error or png_chunk_warning function is used as
- * appropriate. On write this is used to report an error that comes from
- * data set via an application call to a png_set_ API and png_app_error or
- * png_app_warning is used as appropriate.
- *
- * The 'error' parameter must have one of the following values:
- */
-#define PNG_CHUNK_WARNING 0 /* never an error */
-#define PNG_CHUNK_WRITE_ERROR 1 /* an error only on write */
-#define PNG_CHUNK_ERROR 2 /* always an error */
-
-/* ASCII to FP interfaces, currently only implemented if sCAL
- * support is required.
- */
-#if defined(PNG_sCAL_SUPPORTED)
-/* MAX_DIGITS is actually the maximum number of characters in an sCAL
- * width or height, derived from the precision (number of significant
- * digits - a build time settable option) and assumptions about the
- * maximum ridiculous exponent.
- */
-#define PNG_sCAL_MAX_DIGITS (PNG_sCAL_PRECISION+1/*.*/+1/*E*/+10/*exponent*/)
-
-#ifdef PNG_FLOATING_POINT_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_ascii_from_fp,(png_const_structrp png_ptr,
- png_charp ascii, size_t size, double fp, unsigned int precision),
- PNG_EMPTY);
-#endif /* FLOATING_POINT */
-
-#ifdef PNG_FIXED_POINT_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_ascii_from_fixed,(png_const_structrp png_ptr,
- png_charp ascii, size_t size, png_fixed_point fp),PNG_EMPTY);
-#endif /* FIXED_POINT */
-#endif /* sCAL */
-
-#if defined(PNG_sCAL_SUPPORTED) || defined(PNG_pCAL_SUPPORTED)
-/* An internal API to validate the format of a floating point number.
- * The result is the index of the next character. If the number is
- * not valid it will be the index of a character in the supposed number.
- *
- * The format of a number is defined in the PNG extensions specification
- * and this API is strictly conformant to that spec, not anyone elses!
- *
- * The format as a regular expression is:
- *
- * [+-]?[0-9]+.?([Ee][+-]?[0-9]+)?
- *
- * or:
- *
- * [+-]?.[0-9]+(.[0-9]+)?([Ee][+-]?[0-9]+)?
- *
- * The complexity is that either integer or fraction must be present and the
- * fraction is permitted to have no digits only if the integer is present.
- *
- * NOTE: The dangling E problem.
- * There is a PNG valid floating point number in the following:
- *
- * PNG floating point numbers are not greedy.
- *
- * Working this out requires *TWO* character lookahead (because of the
- * sign), the parser does not do this - it will fail at the 'r' - this
- * doesn't matter for PNG sCAL chunk values, but it requires more care
- * if the value were ever to be embedded in something more complex. Use
- * ANSI-C strtod if you need the lookahead.
- */
-/* State table for the parser. */
-#define PNG_FP_INTEGER 0 /* before or in integer */
-#define PNG_FP_FRACTION 1 /* before or in fraction */
-#define PNG_FP_EXPONENT 2 /* before or in exponent */
-#define PNG_FP_STATE 3 /* mask for the above */
-#define PNG_FP_SAW_SIGN 4 /* Saw +/- in current state */
-#define PNG_FP_SAW_DIGIT 8 /* Saw a digit in current state */
-#define PNG_FP_SAW_DOT 16 /* Saw a dot in current state */
-#define PNG_FP_SAW_E 32 /* Saw an E (or e) in current state */
-#define PNG_FP_SAW_ANY 60 /* Saw any of the above 4 */
-
-/* These three values don't affect the parser. They are set but not used.
- */
-#define PNG_FP_WAS_VALID 64 /* Preceding substring is a valid fp number */
-#define PNG_FP_NEGATIVE 128 /* A negative number, including "-0" */
-#define PNG_FP_NONZERO 256 /* A non-zero value */
-#define PNG_FP_STICKY 448 /* The above three flags */
-
-/* This is available for the caller to store in 'state' if required. Do not
- * call the parser after setting it (the parser sometimes clears it.)
- */
-#define PNG_FP_INVALID 512 /* Available for callers as a distinct value */
-
-/* Result codes for the parser (boolean - true means ok, false means
- * not ok yet.)
- */
-#define PNG_FP_MAYBE 0 /* The number may be valid in the future */
-#define PNG_FP_OK 1 /* The number is valid */
-
-/* Tests on the sticky non-zero and negative flags. To pass these checks
- * the state must also indicate that the whole number is valid - this is
- * achieved by testing PNG_FP_SAW_DIGIT (see the implementation for why this
- * is equivalent to PNG_FP_OK above.)
- */
-#define PNG_FP_NZ_MASK (PNG_FP_SAW_DIGIT | PNG_FP_NEGATIVE | PNG_FP_NONZERO)
- /* NZ_MASK: the string is valid and a non-zero negative value */
-#define PNG_FP_Z_MASK (PNG_FP_SAW_DIGIT | PNG_FP_NONZERO)
- /* Z MASK: the string is valid and a non-zero value. */
- /* PNG_FP_SAW_DIGIT: the string is valid. */
-#define PNG_FP_IS_ZERO(state) (((state) & PNG_FP_Z_MASK) == PNG_FP_SAW_DIGIT)
-#define PNG_FP_IS_POSITIVE(state) (((state) & PNG_FP_NZ_MASK) == PNG_FP_Z_MASK)
-#define PNG_FP_IS_NEGATIVE(state) (((state) & PNG_FP_NZ_MASK) == PNG_FP_NZ_MASK)
-
-/* The actual parser. This can be called repeatedly. It updates
- * the index into the string and the state variable (which must
- * be initialized to 0). It returns a result code, as above. There
- * is no point calling the parser any more if it fails to advance to
- * the end of the string - it is stuck on an invalid character (or
- * terminated by '\0').
- *
- * Note that the pointer will consume an E or even an E+ and then leave
- * a 'maybe' state even though a preceding integer.fraction is valid.
- * The PNG_FP_WAS_VALID flag indicates that a preceding substring was
- * a valid number. It's possible to recover from this by calling
- * the parser again (from the start, with state 0) but with a string
- * that omits the last character (i.e. set the size to the index of
- * the problem character.) This has not been tested within libpng.
- */
-PNG_INTERNAL_FUNCTION(int,png_check_fp_number,(png_const_charp string,
- size_t size, int *statep, size_t *whereami),PNG_EMPTY);
-
-/* This is the same but it checks a complete string and returns true
- * only if it just contains a floating point number. As of 1.5.4 this
- * function also returns the state at the end of parsing the number if
- * it was valid (otherwise it returns 0.) This can be used for testing
- * for negative or zero values using the sticky flag.
- */
-PNG_INTERNAL_FUNCTION(int,png_check_fp_string,(png_const_charp string,
- size_t size),PNG_EMPTY);
-#endif /* pCAL || sCAL */
-
-#if defined(PNG_GAMMA_SUPPORTED) ||\
- defined(PNG_INCH_CONVERSIONS_SUPPORTED) || defined(PNG_READ_pHYs_SUPPORTED)
-/* Added at libpng version 1.5.0 */
-/* This is a utility to provide a*times/div (rounded) and indicate
- * if there is an overflow. The result is a boolean - false (0)
- * for overflow, true (1) if no overflow, in which case *res
- * holds the result.
- */
-PNG_INTERNAL_FUNCTION(int,png_muldiv,(png_fixed_point_p res, png_fixed_point a,
- png_int_32 multiplied_by, png_int_32 divided_by),PNG_EMPTY);
-#endif
-
-#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_INCH_CONVERSIONS_SUPPORTED)
-/* Same deal, but issue a warning on overflow and return 0. */
-PNG_INTERNAL_FUNCTION(png_fixed_point,png_muldiv_warn,
- (png_const_structrp png_ptr, png_fixed_point a, png_int_32 multiplied_by,
- png_int_32 divided_by),PNG_EMPTY);
-#endif
-
-#ifdef PNG_GAMMA_SUPPORTED
-/* Calculate a reciprocal - used for gamma values. This returns
- * 0 if the argument is 0 in order to maintain an undefined value;
- * there are no warnings.
- */
-PNG_INTERNAL_FUNCTION(png_fixed_point,png_reciprocal,(png_fixed_point a),
- PNG_EMPTY);
-
-#ifdef PNG_READ_GAMMA_SUPPORTED
-/* The same but gives a reciprocal of the product of two fixed point
- * values. Accuracy is suitable for gamma calculations but this is
- * not exact - use png_muldiv for that. Only required at present on read.
- */
-PNG_INTERNAL_FUNCTION(png_fixed_point,png_reciprocal2,(png_fixed_point a,
- png_fixed_point b),PNG_EMPTY);
-#endif
-
-/* Return true if the gamma value is significantly different from 1.0 */
-PNG_INTERNAL_FUNCTION(int,png_gamma_significant,(png_fixed_point gamma_value),
- PNG_EMPTY);
-#endif
-
-#ifdef PNG_READ_GAMMA_SUPPORTED
-/* Internal fixed point gamma correction. These APIs are called as
- * required to convert single values - they don't need to be fast,
- * they are not used when processing image pixel values.
- *
- * While the input is an 'unsigned' value it must actually be the
- * correct bit value - 0..255 or 0..65535 as required.
- */
-PNG_INTERNAL_FUNCTION(png_uint_16,png_gamma_correct,(png_structrp png_ptr,
- unsigned int value, png_fixed_point gamma_value),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(png_uint_16,png_gamma_16bit_correct,(unsigned int value,
- png_fixed_point gamma_value),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(png_byte,png_gamma_8bit_correct,(unsigned int value,
- png_fixed_point gamma_value),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_destroy_gamma_table,(png_structrp png_ptr),
- PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_build_gamma_table,(png_structrp png_ptr,
- int bit_depth),PNG_EMPTY);
-#endif
-
-/* SIMPLIFIED READ/WRITE SUPPORT */
-#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\
- defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)
-/* The internal structure that png_image::opaque points to. */
-typedef struct png_control
-{
- png_structp png_ptr;
- png_infop info_ptr;
- png_voidp error_buf; /* Always a jmp_buf at present. */
-
- png_const_bytep memory; /* Memory buffer. */
- size_t size; /* Size of the memory buffer. */
-
- unsigned int for_write :1; /* Otherwise it is a read structure */
- unsigned int owned_file :1; /* We own the file in io_ptr */
-} png_control;
-
-/* Return the pointer to the jmp_buf from a png_control: necessary because C
- * does not reveal the type of the elements of jmp_buf.
- */
-#ifdef __cplusplus
-# define png_control_jmp_buf(pc) (((jmp_buf*)((pc)->error_buf))[0])
-#else
-# define png_control_jmp_buf(pc) ((pc)->error_buf)
-#endif
-
-/* Utility to safely execute a piece of libpng code catching and logging any
- * errors that might occur. Returns true on success, false on failure (either
- * of the function or as a result of a png_error.)
- */
-PNG_INTERNAL_CALLBACK(void,png_safe_error,(png_structp png_ptr,
- png_const_charp error_message),PNG_NORETURN);
-
-#ifdef PNG_WARNINGS_SUPPORTED
-PNG_INTERNAL_CALLBACK(void,png_safe_warning,(png_structp png_ptr,
- png_const_charp warning_message),PNG_EMPTY);
-#else
-# define png_safe_warning 0/*dummy argument*/
-#endif
-
-PNG_INTERNAL_FUNCTION(int,png_safe_execute,(png_imagep image,
- int (*function)(png_voidp), png_voidp arg),PNG_EMPTY);
-
-/* Utility to log an error; this also cleans up the png_image; the function
- * always returns 0 (false).
- */
-PNG_INTERNAL_FUNCTION(int,png_image_error,(png_imagep image,
- png_const_charp error_message),PNG_EMPTY);
-
-#ifndef PNG_SIMPLIFIED_READ_SUPPORTED
-/* png_image_free is used by the write code but not exported */
-PNG_INTERNAL_FUNCTION(void, png_image_free, (png_imagep image), PNG_EMPTY);
-#endif /* !SIMPLIFIED_READ */
-
-#endif /* SIMPLIFIED READ/WRITE */
-
-/* These are initialization functions for hardware specific PNG filter
- * optimizations; list these here then select the appropriate one at compile
- * time using the macro PNG_FILTER_OPTIMIZATIONS. If the macro is not defined
- * the generic code is used.
- */
-#ifdef PNG_FILTER_OPTIMIZATIONS
-PNG_INTERNAL_FUNCTION(void, PNG_FILTER_OPTIMIZATIONS, (png_structp png_ptr,
- unsigned int bpp), PNG_EMPTY);
- /* Just declare the optimization that will be used */
-#else
- /* List *all* the possible optimizations here - this branch is required if
- * the builder of libpng passes the definition of PNG_FILTER_OPTIMIZATIONS in
- * CFLAGS in place of CPPFLAGS *and* uses symbol prefixing.
- */
-# if PNG_ARM_NEON_OPT > 0
-PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_neon,
- (png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
-#endif
-
-#if PNG_MIPS_MSA_IMPLEMENTATION == 1
-PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_mips,
- (png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
-#endif
-
-# if PNG_MIPS_MMI_IMPLEMENTATION > 0
-PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_mips,
- (png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
-# endif
-
-# if PNG_INTEL_SSE_IMPLEMENTATION > 0
-PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_sse2,
- (png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
-# endif
-#endif
-
-#if PNG_LOONGARCH_LSX_OPT > 0
-PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_lsx,
- (png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
-#endif
-
-PNG_INTERNAL_FUNCTION(png_uint_32, png_check_keyword, (png_structrp png_ptr,
- png_const_charp key, png_bytep new_key), PNG_EMPTY);
-
-#if PNG_ARM_NEON_IMPLEMENTATION == 1
-PNG_INTERNAL_FUNCTION(void,
- png_riffle_palette_neon,
- (png_structrp),
- PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(int,
- png_do_expand_palette_rgba8_neon,
- (png_structrp,
- png_row_infop,
- png_const_bytep,
- const png_bytepp,
- const png_bytepp),
- PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(int,
- png_do_expand_palette_rgb8_neon,
- (png_structrp,
- png_row_infop,
- png_const_bytep,
- const png_bytepp,
- const png_bytepp),
- PNG_EMPTY);
-#endif
-
-/* Maintainer: Put new private prototypes here ^ */
-
-#include "pngdebug.h"
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* PNG_VERSION_INFO_ONLY */
-#endif /* PNGPRIV_H */
diff --git a/contrib/libs/libpng/pngread.c b/contrib/libs/libpng/pngread.c
deleted file mode 100644
index 4fc80c73b2..0000000000
--- a/contrib/libs/libpng/pngread.c
+++ /dev/null
@@ -1,4337 +0,0 @@
-/* pngread.c - read a PNG file
- *
- * Copyright (c) 2018-2025 Cosmin Truta
- * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
- * Copyright (c) 1996-1997 Andreas Dilger
- * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
- *
- * This code is released under the libpng license.
- * For conditions of distribution and use, see the disclaimer
- * and license in png.h
- *
- * This file contains routines that an application calls directly to
- * read a PNG file or stream.
- */
-
-#include "pngpriv.h"
-#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) && defined(PNG_STDIO_SUPPORTED)
-# include <errno.h>
-#endif
-
-#ifdef PNG_READ_SUPPORTED
-
-/* Create a PNG structure for reading, and allocate any memory needed. */
-PNG_FUNCTION(png_structp,PNGAPI
-png_create_read_struct,(png_const_charp user_png_ver, png_voidp error_ptr,
- png_error_ptr error_fn, png_error_ptr warn_fn),PNG_ALLOCATED)
-{
-#ifndef PNG_USER_MEM_SUPPORTED
- png_structp png_ptr = png_create_png_struct(user_png_ver, error_ptr,
- error_fn, warn_fn, NULL, NULL, NULL);
-#else
- return png_create_read_struct_2(user_png_ver, error_ptr, error_fn,
- warn_fn, NULL, NULL, NULL);
-}
-
-/* Alternate create PNG structure for reading, and allocate any memory
- * needed.
- */
-PNG_FUNCTION(png_structp,PNGAPI
-png_create_read_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
- png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr,
- png_malloc_ptr malloc_fn, png_free_ptr free_fn),PNG_ALLOCATED)
-{
- png_structp png_ptr = png_create_png_struct(user_png_ver, error_ptr,
- error_fn, warn_fn, mem_ptr, malloc_fn, free_fn);
-#endif /* USER_MEM */
-
- if (png_ptr != NULL)
- {
- png_ptr->mode = PNG_IS_READ_STRUCT;
-
- /* Added in libpng-1.6.0; this can be used to detect a read structure if
- * required (it will be zero in a write structure.)
- */
-# ifdef PNG_SEQUENTIAL_READ_SUPPORTED
- png_ptr->IDAT_read_size = PNG_IDAT_READ_SIZE;
-# endif
-
-# ifdef PNG_BENIGN_READ_ERRORS_SUPPORTED
- png_ptr->flags |= PNG_FLAG_BENIGN_ERRORS_WARN;
-
- /* In stable builds only warn if an application error can be completely
- * handled.
- */
-# if PNG_RELEASE_BUILD
- png_ptr->flags |= PNG_FLAG_APP_WARNINGS_WARN;
-# endif
-# endif
-
- /* TODO: delay this, it can be done in png_init_io (if the app doesn't
- * do it itself) avoiding setting the default function if it is not
- * required.
- */
- png_set_read_fn(png_ptr, NULL, NULL);
- }
-
- return png_ptr;
-}
-
-
-#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
-/* Read the information before the actual image data. This has been
- * changed in v0.90 to allow reading a file that already has the magic
- * bytes read from the stream. You can tell libpng how many bytes have
- * been read from the beginning of the stream (up to the maximum of 8)
- * via png_set_sig_bytes(), and we will only check the remaining bytes
- * here. The application can then have access to the signature bytes we
- * read if it is determined that this isn't a valid PNG file.
- */
-void PNGAPI
-png_read_info(png_structrp png_ptr, png_inforp info_ptr)
-{
-#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
- int keep;
-#endif
-
- png_debug(1, "in png_read_info");
-
- if (png_ptr == NULL || info_ptr == NULL)
- return;
-
- /* Read and check the PNG file signature. */
- png_read_sig(png_ptr, info_ptr);
-
- for (;;)
- {
- png_uint_32 length = png_read_chunk_header(png_ptr);
- png_uint_32 chunk_name = png_ptr->chunk_name;
-
- /* IDAT logic needs to happen here to simplify getting the two flags
- * right.
- */
- if (chunk_name == png_IDAT)
- {
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_chunk_error(png_ptr, "Missing IHDR before IDAT");
-
- else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
- (png_ptr->mode & PNG_HAVE_PLTE) == 0)
- png_chunk_error(png_ptr, "Missing PLTE before IDAT");
-
- else if ((png_ptr->mode & PNG_AFTER_IDAT) != 0)
- png_chunk_benign_error(png_ptr, "Too many IDATs found");
-
- png_ptr->mode |= PNG_HAVE_IDAT;
- }
-
- else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
- {
- png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
- png_ptr->mode |= PNG_AFTER_IDAT;
- }
-
- /* This should be a binary subdivision search or a hash for
- * matching the chunk name rather than a linear search.
- */
- if (chunk_name == png_IHDR)
- png_handle_IHDR(png_ptr, info_ptr, length);
-
- else if (chunk_name == png_IEND)
- png_handle_IEND(png_ptr, info_ptr, length);
-
-#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
- else if ((keep = png_chunk_unknown_handling(png_ptr, chunk_name)) != 0)
- {
- png_handle_unknown(png_ptr, info_ptr, length, keep);
-
- if (chunk_name == png_PLTE)
- png_ptr->mode |= PNG_HAVE_PLTE;
-
- else if (chunk_name == png_IDAT)
- {
- png_ptr->idat_size = 0; /* It has been consumed */
- break;
- }
- }
-#endif
- else if (chunk_name == png_PLTE)
- png_handle_PLTE(png_ptr, info_ptr, length);
-
- else if (chunk_name == png_IDAT)
- {
-#ifdef PNG_READ_APNG_SUPPORTED
- png_have_info(png_ptr, info_ptr);
-#endif
- png_ptr->idat_size = length;
- break;
- }
-
-#ifdef PNG_READ_bKGD_SUPPORTED
- else if (chunk_name == png_bKGD)
- png_handle_bKGD(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_cHRM_SUPPORTED
- else if (chunk_name == png_cHRM)
- png_handle_cHRM(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_cICP_SUPPORTED
- else if (chunk_name == png_cICP)
- png_handle_cICP(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_cLLI_SUPPORTED
- else if (chunk_name == png_cLLI)
- png_handle_cLLI(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_eXIf_SUPPORTED
- else if (chunk_name == png_eXIf)
- png_handle_eXIf(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_gAMA_SUPPORTED
- else if (chunk_name == png_gAMA)
- png_handle_gAMA(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_hIST_SUPPORTED
- else if (chunk_name == png_hIST)
- png_handle_hIST(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_mDCV_SUPPORTED
- else if (chunk_name == png_mDCV)
- png_handle_mDCV(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_oFFs_SUPPORTED
- else if (chunk_name == png_oFFs)
- png_handle_oFFs(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_pCAL_SUPPORTED
- else if (chunk_name == png_pCAL)
- png_handle_pCAL(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_sCAL_SUPPORTED
- else if (chunk_name == png_sCAL)
- png_handle_sCAL(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_pHYs_SUPPORTED
- else if (chunk_name == png_pHYs)
- png_handle_pHYs(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_sBIT_SUPPORTED
- else if (chunk_name == png_sBIT)
- png_handle_sBIT(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_sRGB_SUPPORTED
- else if (chunk_name == png_sRGB)
- png_handle_sRGB(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_iCCP_SUPPORTED
- else if (chunk_name == png_iCCP)
- png_handle_iCCP(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_sPLT_SUPPORTED
- else if (chunk_name == png_sPLT)
- png_handle_sPLT(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_tEXt_SUPPORTED
- else if (chunk_name == png_tEXt)
- png_handle_tEXt(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_tIME_SUPPORTED
- else if (chunk_name == png_tIME)
- png_handle_tIME(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_tRNS_SUPPORTED
- else if (chunk_name == png_tRNS)
- png_handle_tRNS(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_zTXt_SUPPORTED
- else if (chunk_name == png_zTXt)
- png_handle_zTXt(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_iTXt_SUPPORTED
- else if (chunk_name == png_iTXt)
- png_handle_iTXt(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_APNG_SUPPORTED
- else if (chunk_name == png_acTL)
- png_handle_acTL(png_ptr, info_ptr, length);
-
- else if (chunk_name == png_fcTL)
- png_handle_fcTL(png_ptr, info_ptr, length);
-
- else if (chunk_name == png_fdAT)
- png_handle_fdAT(png_ptr, info_ptr, length);
-#endif
-
- else
- png_handle_unknown(png_ptr, info_ptr, length,
- PNG_HANDLE_CHUNK_AS_DEFAULT);
- }
-}
-#endif /* SEQUENTIAL_READ */
-
-#ifdef PNG_READ_APNG_SUPPORTED
-void PNGAPI
-png_read_frame_head(png_structp png_ptr, png_infop info_ptr)
-{
- png_byte have_chunk_after_DAT; /* after IDAT or after fdAT */
-
- png_debug(0, "Reading frame head");
-
- if ((png_ptr->mode & PNG_HAVE_acTL) == 0)
- png_error(png_ptr, "attempt to png_read_frame_head() but "
- "no acTL present");
-
- /* do nothing for the main IDAT */
- if (png_ptr->num_frames_read == 0)
- return;
-
- png_read_reset(png_ptr);
- png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
- png_ptr->mode &= ~PNG_HAVE_fcTL;
-
- have_chunk_after_DAT = 0;
- for (;;)
- {
- png_uint_32 length = png_read_chunk_header(png_ptr);
-
- if (png_ptr->chunk_name == png_IDAT)
- {
- /* discard trailing IDATs for the first frame */
- if (have_chunk_after_DAT != 0 || png_ptr->num_frames_read > 1)
- png_error(png_ptr, "png_read_frame_head(): out of place IDAT");
- png_crc_finish(png_ptr, length);
- }
-
- else if (png_ptr->chunk_name == png_fcTL)
- {
- png_handle_fcTL(png_ptr, info_ptr, length);
- have_chunk_after_DAT = 1;
- }
-
- else if (png_ptr->chunk_name == png_fdAT)
- {
- png_ensure_sequence_number(png_ptr, length);
-
- /* discard trailing fdATs for frames other than the first */
- if (have_chunk_after_DAT == 0 && png_ptr->num_frames_read > 1)
- png_crc_finish(png_ptr, length - 4);
- else if (png_ptr->mode & PNG_HAVE_fcTL)
- {
- png_ptr->idat_size = length - 4;
- png_ptr->mode |= PNG_HAVE_IDAT;
-
- break;
- }
- else
- png_error(png_ptr, "png_read_frame_head(): out of place fdAT");
- }
- else
- {
- png_warning(png_ptr, "Skipped (ignored) a chunk "
- "between APNG chunks");
- png_crc_finish(png_ptr, length);
- }
- }
-}
-#endif /* READ_APNG */
-
-/* Optional call to update the users info_ptr structure */
-void PNGAPI
-png_read_update_info(png_structrp png_ptr, png_inforp info_ptr)
-{
- png_debug(1, "in png_read_update_info");
-
- if (png_ptr != NULL)
- {
- if ((png_ptr->flags & PNG_FLAG_ROW_INIT) == 0)
- {
- png_read_start_row(png_ptr);
-
-# ifdef PNG_READ_TRANSFORMS_SUPPORTED
- png_read_transform_info(png_ptr, info_ptr);
-# else
- PNG_UNUSED(info_ptr)
-# endif
- }
-
- /* New in 1.6.0 this avoids the bug of doing the initializations twice */
- else
- png_app_error(png_ptr,
- "png_read_update_info/png_start_read_image: duplicate call");
- }
-}
-
-#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
-/* Initialize palette, background, etc, after transformations
- * are set, but before any reading takes place. This allows
- * the user to obtain a gamma-corrected palette, for example.
- * If the user doesn't call this, we will do it ourselves.
- */
-void PNGAPI
-png_start_read_image(png_structrp png_ptr)
-{
- png_debug(1, "in png_start_read_image");
-
- if (png_ptr != NULL)
- {
- if ((png_ptr->flags & PNG_FLAG_ROW_INIT) == 0)
- png_read_start_row(png_ptr);
-
- /* New in 1.6.0 this avoids the bug of doing the initializations twice */
- else
- png_app_error(png_ptr,
- "png_start_read_image/png_read_update_info: duplicate call");
- }
-}
-#endif /* SEQUENTIAL_READ */
-
-#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
-#ifdef PNG_MNG_FEATURES_SUPPORTED
-/* Undoes intrapixel differencing,
- * NOTE: this is apparently only supported in the 'sequential' reader.
- */
-static void
-png_do_read_intrapixel(png_row_infop row_info, png_bytep row)
-{
- png_debug(1, "in png_do_read_intrapixel");
-
- if (
- (row_info->color_type & PNG_COLOR_MASK_COLOR) != 0)
- {
- int bytes_per_pixel;
- png_uint_32 row_width = row_info->width;
-
- if (row_info->bit_depth == 8)
- {
- png_bytep rp;
- png_uint_32 i;
-
- if (row_info->color_type == PNG_COLOR_TYPE_RGB)
- bytes_per_pixel = 3;
-
- else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
- bytes_per_pixel = 4;
-
- else
- return;
-
- for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
- {
- *(rp) = (png_byte)((256 + *rp + *(rp + 1)) & 0xff);
- *(rp+2) = (png_byte)((256 + *(rp + 2) + *(rp + 1)) & 0xff);
- }
- }
- else if (row_info->bit_depth == 16)
- {
- png_bytep rp;
- png_uint_32 i;
-
- if (row_info->color_type == PNG_COLOR_TYPE_RGB)
- bytes_per_pixel = 6;
-
- else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
- bytes_per_pixel = 8;
-
- else
- return;
-
- for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
- {
- png_uint_32 s0 = (png_uint_32)(*(rp ) << 8) | *(rp + 1);
- png_uint_32 s1 = (png_uint_32)(*(rp + 2) << 8) | *(rp + 3);
- png_uint_32 s2 = (png_uint_32)(*(rp + 4) << 8) | *(rp + 5);
- png_uint_32 red = (s0 + s1 + 65536) & 0xffff;
- png_uint_32 blue = (s2 + s1 + 65536) & 0xffff;
- *(rp ) = (png_byte)((red >> 8) & 0xff);
- *(rp + 1) = (png_byte)(red & 0xff);
- *(rp + 4) = (png_byte)((blue >> 8) & 0xff);
- *(rp + 5) = (png_byte)(blue & 0xff);
- }
- }
- }
-}
-#endif /* MNG_FEATURES */
-
-void PNGAPI
-png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row)
-{
- png_row_info row_info;
-
- if (png_ptr == NULL)
- return;
-
- png_debug2(1, "in png_read_row (row %lu, pass %d)",
- (unsigned long)png_ptr->row_number, png_ptr->pass);
-
- /* png_read_start_row sets the information (in particular iwidth) for this
- * interlace pass.
- */
- if ((png_ptr->flags & PNG_FLAG_ROW_INIT) == 0)
- png_read_start_row(png_ptr);
-
- /* 1.5.6: row_info moved out of png_struct to a local here. */
- row_info.width = png_ptr->iwidth; /* NOTE: width of current interlaced row */
- row_info.color_type = png_ptr->color_type;
- row_info.bit_depth = png_ptr->bit_depth;
- row_info.channels = png_ptr->channels;
- row_info.pixel_depth = png_ptr->pixel_depth;
- row_info.rowbytes = PNG_ROWBYTES(row_info.pixel_depth, row_info.width);
-
-#ifdef PNG_WARNINGS_SUPPORTED
- if (png_ptr->row_number == 0 && png_ptr->pass == 0)
- {
- /* Check for transforms that have been set but were defined out */
-#if defined(PNG_WRITE_INVERT_SUPPORTED) && !defined(PNG_READ_INVERT_SUPPORTED)
- if ((png_ptr->transformations & PNG_INVERT_MONO) != 0)
- png_warning(png_ptr, "PNG_READ_INVERT_SUPPORTED is not defined");
-#endif
-
-#if defined(PNG_WRITE_FILLER_SUPPORTED) && !defined(PNG_READ_FILLER_SUPPORTED)
- if ((png_ptr->transformations & PNG_FILLER) != 0)
- png_warning(png_ptr, "PNG_READ_FILLER_SUPPORTED is not defined");
-#endif
-
-#if defined(PNG_WRITE_PACKSWAP_SUPPORTED) && \
- !defined(PNG_READ_PACKSWAP_SUPPORTED)
- if ((png_ptr->transformations & PNG_PACKSWAP) != 0)
- png_warning(png_ptr, "PNG_READ_PACKSWAP_SUPPORTED is not defined");
-#endif
-
-#if defined(PNG_WRITE_PACK_SUPPORTED) && !defined(PNG_READ_PACK_SUPPORTED)
- if ((png_ptr->transformations & PNG_PACK) != 0)
- png_warning(png_ptr, "PNG_READ_PACK_SUPPORTED is not defined");
-#endif
-
-#if defined(PNG_WRITE_SHIFT_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED)
- if ((png_ptr->transformations & PNG_SHIFT) != 0)
- png_warning(png_ptr, "PNG_READ_SHIFT_SUPPORTED is not defined");
-#endif
-
-#if defined(PNG_WRITE_BGR_SUPPORTED) && !defined(PNG_READ_BGR_SUPPORTED)
- if ((png_ptr->transformations & PNG_BGR) != 0)
- png_warning(png_ptr, "PNG_READ_BGR_SUPPORTED is not defined");
-#endif
-
-#if defined(PNG_WRITE_SWAP_SUPPORTED) && !defined(PNG_READ_SWAP_SUPPORTED)
- if ((png_ptr->transformations & PNG_SWAP_BYTES) != 0)
- png_warning(png_ptr, "PNG_READ_SWAP_SUPPORTED is not defined");
-#endif
- }
-#endif /* WARNINGS */
-
-#ifdef PNG_READ_INTERLACING_SUPPORTED
- /* If interlaced and we do not need a new row, combine row and return.
- * Notice that the pixels we have from previous rows have been transformed
- * already; we can only combine like with like (transformed or
- * untransformed) and, because of the libpng API for interlaced images, this
- * means we must transform before de-interlacing.
- */
- if (png_ptr->interlaced != 0 &&
- (png_ptr->transformations & PNG_INTERLACE) != 0)
- {
- switch (png_ptr->pass)
- {
- case 0:
- if (png_ptr->row_number & 0x07)
- {
- if (dsp_row != NULL)
- png_combine_row(png_ptr, dsp_row, 1/*display*/);
- png_read_finish_row(png_ptr);
- return;
- }
- break;
-
- case 1:
- if ((png_ptr->row_number & 0x07) || png_ptr->width < 5)
- {
- if (dsp_row != NULL)
- png_combine_row(png_ptr, dsp_row, 1/*display*/);
-
- png_read_finish_row(png_ptr);
- return;
- }
- break;
-
- case 2:
- if ((png_ptr->row_number & 0x07) != 4)
- {
- if (dsp_row != NULL && (png_ptr->row_number & 4))
- png_combine_row(png_ptr, dsp_row, 1/*display*/);
-
- png_read_finish_row(png_ptr);
- return;
- }
- break;
-
- case 3:
- if ((png_ptr->row_number & 3) || png_ptr->width < 3)
- {
- if (dsp_row != NULL)
- png_combine_row(png_ptr, dsp_row, 1/*display*/);
-
- png_read_finish_row(png_ptr);
- return;
- }
- break;
-
- case 4:
- if ((png_ptr->row_number & 3) != 2)
- {
- if (dsp_row != NULL && (png_ptr->row_number & 2))
- png_combine_row(png_ptr, dsp_row, 1/*display*/);
-
- png_read_finish_row(png_ptr);
- return;
- }
- break;
-
- case 5:
- if ((png_ptr->row_number & 1) || png_ptr->width < 2)
- {
- if (dsp_row != NULL)
- png_combine_row(png_ptr, dsp_row, 1/*display*/);
-
- png_read_finish_row(png_ptr);
- return;
- }
- break;
-
- default:
- case 6:
- if ((png_ptr->row_number & 1) == 0)
- {
- png_read_finish_row(png_ptr);
- return;
- }
- break;
- }
- }
-#endif
-
- if ((png_ptr->mode & PNG_HAVE_IDAT) == 0)
- png_error(png_ptr, "Invalid attempt to read row data");
-
- /* Fill the row with IDAT data: */
- png_ptr->row_buf[0]=255; /* to force error if no data was found */
- png_read_IDAT_data(png_ptr, png_ptr->row_buf, row_info.rowbytes + 1);
-
- if (png_ptr->row_buf[0] > PNG_FILTER_VALUE_NONE)
- {
- if (png_ptr->row_buf[0] < PNG_FILTER_VALUE_LAST)
- png_read_filter_row(png_ptr, &row_info, png_ptr->row_buf + 1,
- png_ptr->prev_row + 1, png_ptr->row_buf[0]);
- else
- png_error(png_ptr, "bad adaptive filter value");
- }
-
- /* libpng 1.5.6: the following line was copying png_ptr->rowbytes before
- * 1.5.6, while the buffer really is this big in current versions of libpng
- * it may not be in the future, so this was changed just to copy the
- * interlaced count:
- */
- memcpy(png_ptr->prev_row, png_ptr->row_buf, row_info.rowbytes + 1);
-
-#ifdef PNG_MNG_FEATURES_SUPPORTED
- if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) != 0 &&
- (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING))
- {
- /* Intrapixel differencing */
- png_do_read_intrapixel(&row_info, png_ptr->row_buf + 1);
- }
-#endif
-
-#ifdef PNG_READ_TRANSFORMS_SUPPORTED
- if (png_ptr->transformations
-# ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
- || png_ptr->num_palette_max >= 0
-# endif
- )
- png_do_read_transformations(png_ptr, &row_info);
-#endif
-
- /* The transformed pixel depth should match the depth now in row_info. */
- if (png_ptr->transformed_pixel_depth == 0)
- {
- png_ptr->transformed_pixel_depth = row_info.pixel_depth;
- if (row_info.pixel_depth > png_ptr->maximum_pixel_depth)
- png_error(png_ptr, "sequential row overflow");
- }
-
- else if (png_ptr->transformed_pixel_depth != row_info.pixel_depth)
- png_error(png_ptr, "internal sequential row size calculation error");
-
-#ifdef PNG_READ_INTERLACING_SUPPORTED
- /* Expand interlaced rows to full size */
- if (png_ptr->interlaced != 0 &&
- (png_ptr->transformations & PNG_INTERLACE) != 0)
- {
- if (png_ptr->pass < 6)
- png_do_read_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass,
- png_ptr->transformations);
-
- if (dsp_row != NULL)
- png_combine_row(png_ptr, dsp_row, 1/*display*/);
-
- if (row != NULL)
- png_combine_row(png_ptr, row, 0/*row*/);
- }
-
- else
-#endif
- {
- if (row != NULL)
- png_combine_row(png_ptr, row, -1/*ignored*/);
-
- if (dsp_row != NULL)
- png_combine_row(png_ptr, dsp_row, -1/*ignored*/);
- }
- png_read_finish_row(png_ptr);
-
- if (png_ptr->read_row_fn != NULL)
- (*(png_ptr->read_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass);
-
-}
-#endif /* SEQUENTIAL_READ */
-
-#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
-/* Read one or more rows of image data. If the image is interlaced,
- * and png_set_interlace_handling() has been called, the rows need to
- * contain the contents of the rows from the previous pass. If the
- * image has alpha or transparency, and png_handle_alpha()[*] has been
- * called, the rows contents must be initialized to the contents of the
- * screen.
- *
- * "row" holds the actual image, and pixels are placed in it
- * as they arrive. If the image is displayed after each pass, it will
- * appear to "sparkle" in. "display_row" can be used to display a
- * "chunky" progressive image, with finer detail added as it becomes
- * available. If you do not want this "chunky" display, you may pass
- * NULL for display_row. If you do not want the sparkle display, and
- * you have not called png_handle_alpha(), you may pass NULL for rows.
- * If you have called png_handle_alpha(), and the image has either an
- * alpha channel or a transparency chunk, you must provide a buffer for
- * rows. In this case, you do not have to provide a display_row buffer
- * also, but you may. If the image is not interlaced, or if you have
- * not called png_set_interlace_handling(), the display_row buffer will
- * be ignored, so pass NULL to it.
- *
- * [*] png_handle_alpha() does not exist yet, as of this version of libpng
- */
-
-void PNGAPI
-png_read_rows(png_structrp png_ptr, png_bytepp row,
- png_bytepp display_row, png_uint_32 num_rows)
-{
- png_uint_32 i;
- png_bytepp rp;
- png_bytepp dp;
-
- png_debug(1, "in png_read_rows");
-
- if (png_ptr == NULL)
- return;
-
- rp = row;
- dp = display_row;
- if (rp != NULL && dp != NULL)
- for (i = 0; i < num_rows; i++)
- {
- png_bytep rptr = *rp++;
- png_bytep dptr = *dp++;
-
- png_read_row(png_ptr, rptr, dptr);
- }
-
- else if (rp != NULL)
- for (i = 0; i < num_rows; i++)
- {
- png_bytep rptr = *rp;
- png_read_row(png_ptr, rptr, NULL);
- rp++;
- }
-
- else if (dp != NULL)
- for (i = 0; i < num_rows; i++)
- {
- png_bytep dptr = *dp;
- png_read_row(png_ptr, NULL, dptr);
- dp++;
- }
-}
-#endif /* SEQUENTIAL_READ */
-
-#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
-/* Read the entire image. If the image has an alpha channel or a tRNS
- * chunk, and you have called png_handle_alpha()[*], you will need to
- * initialize the image to the current image that PNG will be overlaying.
- * We set the num_rows again here, in case it was incorrectly set in
- * png_read_start_row() by a call to png_read_update_info() or
- * png_start_read_image() if png_set_interlace_handling() wasn't called
- * prior to either of these functions like it should have been. You can
- * only call this function once. If you desire to have an image for
- * each pass of a interlaced image, use png_read_rows() instead.
- *
- * [*] png_handle_alpha() does not exist yet, as of this version of libpng
- */
-void PNGAPI
-png_read_image(png_structrp png_ptr, png_bytepp image)
-{
- png_uint_32 i, image_height;
- int pass, j;
- png_bytepp rp;
-
- png_debug(1, "in png_read_image");
-
- if (png_ptr == NULL)
- return;
-
-#ifdef PNG_READ_INTERLACING_SUPPORTED
- if ((png_ptr->flags & PNG_FLAG_ROW_INIT) == 0)
- {
- pass = png_set_interlace_handling(png_ptr);
- /* And make sure transforms are initialized. */
- png_start_read_image(png_ptr);
- }
- else
- {
- if (png_ptr->interlaced != 0 &&
- (png_ptr->transformations & PNG_INTERLACE) == 0)
- {
- /* Caller called png_start_read_image or png_read_update_info without
- * first turning on the PNG_INTERLACE transform. We can fix this here,
- * but the caller should do it!
- */
- png_warning(png_ptr, "Interlace handling should be turned on when "
- "using png_read_image");
- /* Make sure this is set correctly */
- png_ptr->num_rows = png_ptr->height;
- }
-
- /* Obtain the pass number, which also turns on the PNG_INTERLACE flag in
- * the above error case.
- */
- pass = png_set_interlace_handling(png_ptr);
- }
-#else
- if (png_ptr->interlaced)
- png_error(png_ptr,
- "Cannot read interlaced image -- interlace handler disabled");
-
- pass = 1;
-#endif
-
- image_height=png_ptr->height;
-
- for (j = 0; j < pass; j++)
- {
- rp = image;
- for (i = 0; i < image_height; i++)
- {
- png_read_row(png_ptr, *rp, NULL);
- rp++;
- }
- }
-}
-#endif /* SEQUENTIAL_READ */
-
-#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
-/* Read the end of the PNG file. Will not read past the end of the
- * file, will verify the end is accurate, and will read any comments
- * or time information at the end of the file, if info is not NULL.
- */
-void PNGAPI
-png_read_end(png_structrp png_ptr, png_inforp info_ptr)
-{
-#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
- int keep;
-#endif
-
- png_debug(1, "in png_read_end");
-
- if (png_ptr == NULL)
- return;
-
- /* If png_read_end is called in the middle of reading the rows there may
- * still be pending IDAT data and an owned zstream. Deal with this here.
- */
-#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
- if (png_chunk_unknown_handling(png_ptr, png_IDAT) == 0)
-#endif
- png_read_finish_IDAT(png_ptr);
-
-#ifdef PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED
- /* Report invalid palette index; added at libng-1.5.10 */
- if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
- png_ptr->num_palette_max >= png_ptr->num_palette)
- png_benign_error(png_ptr, "Read palette index exceeding num_palette");
-#endif
-
- do
- {
- png_uint_32 length = png_read_chunk_header(png_ptr);
- png_uint_32 chunk_name = png_ptr->chunk_name;
-
- if (chunk_name != png_IDAT)
- png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
-
- if (chunk_name == png_IEND)
- png_handle_IEND(png_ptr, info_ptr, length);
-
- else if (chunk_name == png_IHDR)
- png_handle_IHDR(png_ptr, info_ptr, length);
-
- else if (info_ptr == NULL)
- png_crc_finish(png_ptr, length);
-
-#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
- else if ((keep = png_chunk_unknown_handling(png_ptr, chunk_name)) != 0)
- {
- if (chunk_name == png_IDAT)
- {
- if ((length > 0 && !(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED))
- || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0)
- png_benign_error(png_ptr, ".Too many IDATs found");
- }
- png_handle_unknown(png_ptr, info_ptr, length, keep);
- if (chunk_name == png_PLTE)
- png_ptr->mode |= PNG_HAVE_PLTE;
- }
-#endif
-
- else if (chunk_name == png_IDAT)
- {
- /* Zero length IDATs are legal after the last IDAT has been
- * read, but not after other chunks have been read. 1.6 does not
- * always read all the deflate data; specifically it cannot be relied
- * upon to read the Adler32 at the end. If it doesn't ignore IDAT
- * chunks which are longer than zero as well:
- */
- if ((length > 0 && !(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED))
- || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0)
- png_benign_error(png_ptr, "..Too many IDATs found");
-
- png_crc_finish(png_ptr, length);
- }
- else if (chunk_name == png_PLTE)
- png_handle_PLTE(png_ptr, info_ptr, length);
-
-#ifdef PNG_READ_bKGD_SUPPORTED
- else if (chunk_name == png_bKGD)
- png_handle_bKGD(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_cHRM_SUPPORTED
- else if (chunk_name == png_cHRM)
- png_handle_cHRM(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_cICP_SUPPORTED
- else if (chunk_name == png_cICP)
- png_handle_cICP(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_cLLI_SUPPORTED
- else if (chunk_name == png_cLLI)
- png_handle_cLLI(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_eXIf_SUPPORTED
- else if (chunk_name == png_eXIf)
- png_handle_eXIf(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_gAMA_SUPPORTED
- else if (chunk_name == png_gAMA)
- png_handle_gAMA(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_hIST_SUPPORTED
- else if (chunk_name == png_hIST)
- png_handle_hIST(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_mDCV_SUPPORTED
- else if (chunk_name == png_mDCV)
- png_handle_mDCV(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_oFFs_SUPPORTED
- else if (chunk_name == png_oFFs)
- png_handle_oFFs(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_pCAL_SUPPORTED
- else if (chunk_name == png_pCAL)
- png_handle_pCAL(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_sCAL_SUPPORTED
- else if (chunk_name == png_sCAL)
- png_handle_sCAL(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_pHYs_SUPPORTED
- else if (chunk_name == png_pHYs)
- png_handle_pHYs(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_sBIT_SUPPORTED
- else if (chunk_name == png_sBIT)
- png_handle_sBIT(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_sRGB_SUPPORTED
- else if (chunk_name == png_sRGB)
- png_handle_sRGB(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_iCCP_SUPPORTED
- else if (chunk_name == png_iCCP)
- png_handle_iCCP(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_sPLT_SUPPORTED
- else if (chunk_name == png_sPLT)
- png_handle_sPLT(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_tEXt_SUPPORTED
- else if (chunk_name == png_tEXt)
- png_handle_tEXt(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_tIME_SUPPORTED
- else if (chunk_name == png_tIME)
- png_handle_tIME(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_tRNS_SUPPORTED
- else if (chunk_name == png_tRNS)
- png_handle_tRNS(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_zTXt_SUPPORTED
- else if (chunk_name == png_zTXt)
- png_handle_zTXt(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_iTXt_SUPPORTED
- else if (chunk_name == png_iTXt)
- png_handle_iTXt(png_ptr, info_ptr, length);
-#endif
-
- else
- png_handle_unknown(png_ptr, info_ptr, length,
- PNG_HANDLE_CHUNK_AS_DEFAULT);
- } while ((png_ptr->mode & PNG_HAVE_IEND) == 0);
-}
-#endif /* SEQUENTIAL_READ */
-
-/* Free all memory used in the read struct */
-static void
-png_read_destroy(png_structrp png_ptr)
-{
- png_debug(1, "in png_read_destroy");
-
-#ifdef PNG_READ_GAMMA_SUPPORTED
- png_destroy_gamma_table(png_ptr);
-#endif
-
- png_free(png_ptr, png_ptr->big_row_buf);
- png_ptr->big_row_buf = NULL;
- png_free(png_ptr, png_ptr->big_prev_row);
- png_ptr->big_prev_row = NULL;
- png_free(png_ptr, png_ptr->read_buffer);
- png_ptr->read_buffer = NULL;
-
-#ifdef PNG_READ_QUANTIZE_SUPPORTED
- png_free(png_ptr, png_ptr->palette_lookup);
- png_ptr->palette_lookup = NULL;
- png_free(png_ptr, png_ptr->quantize_index);
- png_ptr->quantize_index = NULL;
-#endif
-
- if ((png_ptr->free_me & PNG_FREE_PLTE) != 0)
- {
- png_zfree(png_ptr, png_ptr->palette);
- png_ptr->palette = NULL;
- }
- png_ptr->free_me &= ~PNG_FREE_PLTE;
-
-#if defined(PNG_tRNS_SUPPORTED) || \
- defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
- if ((png_ptr->free_me & PNG_FREE_TRNS) != 0)
- {
- png_free(png_ptr, png_ptr->trans_alpha);
- png_ptr->trans_alpha = NULL;
- }
- png_ptr->free_me &= ~PNG_FREE_TRNS;
-#endif
-
- inflateEnd(&png_ptr->zstream);
-
-#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
- png_free(png_ptr, png_ptr->save_buffer);
- png_ptr->save_buffer = NULL;
-#endif
-
-#if defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED) && \
- defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
- png_free(png_ptr, png_ptr->unknown_chunk.data);
- png_ptr->unknown_chunk.data = NULL;
-#endif
-
-#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
- png_free(png_ptr, png_ptr->chunk_list);
- png_ptr->chunk_list = NULL;
-#endif
-
-#if defined(PNG_READ_EXPAND_SUPPORTED) && \
- defined(PNG_ARM_NEON_IMPLEMENTATION)
- png_free(png_ptr, png_ptr->riffled_palette);
- png_ptr->riffled_palette = NULL;
-#endif
-
- /* NOTE: the 'setjmp' buffer may still be allocated and the memory and error
- * callbacks are still set at this point. They are required to complete the
- * destruction of the png_struct itself.
- */
-}
-
-/* Free all memory used by the read */
-void PNGAPI
-png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
- png_infopp end_info_ptr_ptr)
-{
- png_structrp png_ptr = NULL;
-
- png_debug(1, "in png_destroy_read_struct");
-
- if (png_ptr_ptr != NULL)
- png_ptr = *png_ptr_ptr;
-
- if (png_ptr == NULL)
- return;
-
- /* libpng 1.6.0: use the API to destroy info structs to ensure consistent
- * behavior. Prior to 1.6.0 libpng did extra 'info' destruction in this API.
- * The extra was, apparently, unnecessary yet this hides memory leak bugs.
- */
- png_destroy_info_struct(png_ptr, end_info_ptr_ptr);
- png_destroy_info_struct(png_ptr, info_ptr_ptr);
-
- *png_ptr_ptr = NULL;
- png_read_destroy(png_ptr);
- png_destroy_png_struct(png_ptr);
-}
-
-void PNGAPI
-png_set_read_status_fn(png_structrp png_ptr, png_read_status_ptr read_row_fn)
-{
- if (png_ptr == NULL)
- return;
-
- png_ptr->read_row_fn = read_row_fn;
-}
-
-
-#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
-#ifdef PNG_INFO_IMAGE_SUPPORTED
-void PNGAPI
-png_read_png(png_structrp png_ptr, png_inforp info_ptr,
- int transforms, voidp params)
-{
- png_debug(1, "in png_read_png");
-
- if (png_ptr == NULL || info_ptr == NULL)
- return;
-
- /* png_read_info() gives us all of the information from the
- * PNG file before the first IDAT (image data chunk).
- */
- png_read_info(png_ptr, info_ptr);
- if (info_ptr->height > PNG_UINT_32_MAX/(sizeof (png_bytep)))
- png_error(png_ptr, "Image is too high to process with png_read_png()");
-
- /* -------------- image transformations start here ------------------- */
- /* libpng 1.6.10: add code to cause a png_app_error if a selected TRANSFORM
- * is not implemented. This will only happen in de-configured (non-default)
- * libpng builds. The results can be unexpected - png_read_png may return
- * short or mal-formed rows because the transform is skipped.
- */
-
- /* Tell libpng to strip 16-bit/color files down to 8 bits per color.
- */
- if ((transforms & PNG_TRANSFORM_SCALE_16) != 0)
- /* Added at libpng-1.5.4. "strip_16" produces the same result that it
- * did in earlier versions, while "scale_16" is now more accurate.
- */
-#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
- png_set_scale_16(png_ptr);
-#else
- png_app_error(png_ptr, "PNG_TRANSFORM_SCALE_16 not supported");
-#endif
-
- /* If both SCALE and STRIP are required pngrtran will effectively cancel the
- * latter by doing SCALE first. This is ok and allows apps not to check for
- * which is supported to get the right answer.
- */
- if ((transforms & PNG_TRANSFORM_STRIP_16) != 0)
-#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
- png_set_strip_16(png_ptr);
-#else
- png_app_error(png_ptr, "PNG_TRANSFORM_STRIP_16 not supported");
-#endif
-
- /* Strip alpha bytes from the input data without combining with
- * the background (not recommended).
- */
- if ((transforms & PNG_TRANSFORM_STRIP_ALPHA) != 0)
-#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
- png_set_strip_alpha(png_ptr);
-#else
- png_app_error(png_ptr, "PNG_TRANSFORM_STRIP_ALPHA not supported");
-#endif
-
- /* Extract multiple pixels with bit depths of 1, 2, or 4 from a single
- * byte into separate bytes (useful for paletted and grayscale images).
- */
- if ((transforms & PNG_TRANSFORM_PACKING) != 0)
-#ifdef PNG_READ_PACK_SUPPORTED
- png_set_packing(png_ptr);
-#else
- png_app_error(png_ptr, "PNG_TRANSFORM_PACKING not supported");
-#endif
-
- /* Change the order of packed pixels to least significant bit first
- * (not useful if you are using png_set_packing).
- */
- if ((transforms & PNG_TRANSFORM_PACKSWAP) != 0)
-#ifdef PNG_READ_PACKSWAP_SUPPORTED
- png_set_packswap(png_ptr);
-#else
- png_app_error(png_ptr, "PNG_TRANSFORM_PACKSWAP not supported");
-#endif
-
- /* Expand paletted colors into true RGB triplets
- * Expand grayscale images to full 8 bits from 1, 2, or 4 bits/pixel
- * Expand paletted or RGB images with transparency to full alpha
- * channels so the data will be available as RGBA quartets.
- */
- if ((transforms & PNG_TRANSFORM_EXPAND) != 0)
-#ifdef PNG_READ_EXPAND_SUPPORTED
- png_set_expand(png_ptr);
-#else
- png_app_error(png_ptr, "PNG_TRANSFORM_EXPAND not supported");
-#endif
-
- /* We don't handle background color or gamma transformation or quantizing.
- */
-
- /* Invert monochrome files to have 0 as white and 1 as black
- */
- if ((transforms & PNG_TRANSFORM_INVERT_MONO) != 0)
-#ifdef PNG_READ_INVERT_SUPPORTED
- png_set_invert_mono(png_ptr);
-#else
- png_app_error(png_ptr, "PNG_TRANSFORM_INVERT_MONO not supported");
-#endif
-
- /* If you want to shift the pixel values from the range [0,255] or
- * [0,65535] to the original [0,7] or [0,31], or whatever range the
- * colors were originally in:
- */
- if ((transforms & PNG_TRANSFORM_SHIFT) != 0)
-#ifdef PNG_READ_SHIFT_SUPPORTED
- if ((info_ptr->valid & PNG_INFO_sBIT) != 0)
- png_set_shift(png_ptr, &info_ptr->sig_bit);
-#else
- png_app_error(png_ptr, "PNG_TRANSFORM_SHIFT not supported");
-#endif
-
- /* Flip the RGB pixels to BGR (or RGBA to BGRA) */
- if ((transforms & PNG_TRANSFORM_BGR) != 0)
-#ifdef PNG_READ_BGR_SUPPORTED
- png_set_bgr(png_ptr);
-#else
- png_app_error(png_ptr, "PNG_TRANSFORM_BGR not supported");
-#endif
-
- /* Swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */
- if ((transforms & PNG_TRANSFORM_SWAP_ALPHA) != 0)
-#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED
- png_set_swap_alpha(png_ptr);
-#else
- png_app_error(png_ptr, "PNG_TRANSFORM_SWAP_ALPHA not supported");
-#endif
-
- /* Swap bytes of 16-bit files to least significant byte first */
- if ((transforms & PNG_TRANSFORM_SWAP_ENDIAN) != 0)
-#ifdef PNG_READ_SWAP_SUPPORTED
- png_set_swap(png_ptr);
-#else
- png_app_error(png_ptr, "PNG_TRANSFORM_SWAP_ENDIAN not supported");
-#endif
-
-/* Added at libpng-1.2.41 */
- /* Invert the alpha channel from opacity to transparency */
- if ((transforms & PNG_TRANSFORM_INVERT_ALPHA) != 0)
-#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED
- png_set_invert_alpha(png_ptr);
-#else
- png_app_error(png_ptr, "PNG_TRANSFORM_INVERT_ALPHA not supported");
-#endif
-
-/* Added at libpng-1.2.41 */
- /* Expand grayscale image to RGB */
- if ((transforms & PNG_TRANSFORM_GRAY_TO_RGB) != 0)
-#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
- png_set_gray_to_rgb(png_ptr);
-#else
- png_app_error(png_ptr, "PNG_TRANSFORM_GRAY_TO_RGB not supported");
-#endif
-
-/* Added at libpng-1.5.4 */
- if ((transforms & PNG_TRANSFORM_EXPAND_16) != 0)
-#ifdef PNG_READ_EXPAND_16_SUPPORTED
- png_set_expand_16(png_ptr);
-#else
- png_app_error(png_ptr, "PNG_TRANSFORM_EXPAND_16 not supported");
-#endif
-
- /* We don't handle adding filler bytes */
-
- /* We use png_read_image and rely on that for interlace handling, but we also
- * call png_read_update_info therefore must turn on interlace handling now:
- */
- (void)png_set_interlace_handling(png_ptr);
-
- /* Optional call to gamma correct and add the background to the palette
- * and update info structure. REQUIRED if you are expecting libpng to
- * update the palette for you (i.e., you selected such a transform above).
- */
- png_read_update_info(png_ptr, info_ptr);
-
- /* -------------- image transformations end here ------------------- */
-
- png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0);
- if (info_ptr->row_pointers == NULL)
- {
- png_uint_32 iptr;
-
- info_ptr->row_pointers = png_voidcast(png_bytepp, png_malloc(png_ptr,
- info_ptr->height * (sizeof (png_bytep))));
-
- for (iptr=0; iptr<info_ptr->height; iptr++)
- info_ptr->row_pointers[iptr] = NULL;
-
- info_ptr->free_me |= PNG_FREE_ROWS;
-
- for (iptr = 0; iptr < info_ptr->height; iptr++)
- info_ptr->row_pointers[iptr] = png_voidcast(png_bytep,
- png_malloc(png_ptr, info_ptr->rowbytes));
- }
-
- png_read_image(png_ptr, info_ptr->row_pointers);
- info_ptr->valid |= PNG_INFO_IDAT;
-
- /* Read rest of file, and get additional chunks in info_ptr - REQUIRED */
- png_read_end(png_ptr, info_ptr);
-
- PNG_UNUSED(params)
-}
-#endif /* INFO_IMAGE */
-#endif /* SEQUENTIAL_READ */
-
-#ifdef PNG_SIMPLIFIED_READ_SUPPORTED
-/* SIMPLIFIED READ
- *
- * This code currently relies on the sequential reader, though it could easily
- * be made to work with the progressive one.
- */
-/* Arguments to png_image_finish_read: */
-
-/* Encoding of PNG data (used by the color-map code) */
-# define P_NOTSET 0 /* File encoding not yet known */
-# define P_sRGB 1 /* 8-bit encoded to sRGB gamma */
-# define P_LINEAR 2 /* 16-bit linear: not encoded, NOT pre-multiplied! */
-# define P_FILE 3 /* 8-bit encoded to file gamma, not sRGB or linear */
-# define P_LINEAR8 4 /* 8-bit linear: only from a file value */
-
-/* Color-map processing: after libpng has run on the PNG image further
- * processing may be needed to convert the data to color-map indices.
- */
-#define PNG_CMAP_NONE 0
-#define PNG_CMAP_GA 1 /* Process GA data to a color-map with alpha */
-#define PNG_CMAP_TRANS 2 /* Process GA data to a background index */
-#define PNG_CMAP_RGB 3 /* Process RGB data */
-#define PNG_CMAP_RGB_ALPHA 4 /* Process RGBA data */
-
-/* The following document where the background is for each processing case. */
-#define PNG_CMAP_NONE_BACKGROUND 256
-#define PNG_CMAP_GA_BACKGROUND 231
-#define PNG_CMAP_TRANS_BACKGROUND 254
-#define PNG_CMAP_RGB_BACKGROUND 256
-#define PNG_CMAP_RGB_ALPHA_BACKGROUND 216
-
-typedef struct
-{
- /* Arguments: */
- png_imagep image;
- png_voidp buffer;
- png_int_32 row_stride;
- png_voidp colormap;
- png_const_colorp background;
- /* Local variables: */
- png_voidp local_row;
- png_voidp first_row;
- ptrdiff_t row_bytes; /* step between rows */
- int file_encoding; /* E_ values above */
- png_fixed_point gamma_to_linear; /* For P_FILE, reciprocal of gamma */
- int colormap_processing; /* PNG_CMAP_ values above */
-} png_image_read_control;
-
-/* Do all the *safe* initialization - 'safe' means that png_error won't be
- * called, so setting up the jmp_buf is not required. This means that anything
- * called from here must *not* call png_malloc - it has to call png_malloc_warn
- * instead so that control is returned safely back to this routine.
- */
-static int
-png_image_read_init(png_imagep image)
-{
- if (image->opaque == NULL)
- {
- png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, image,
- png_safe_error, png_safe_warning);
-
- /* And set the rest of the structure to NULL to ensure that the various
- * fields are consistent.
- */
- memset(image, 0, (sizeof *image));
- image->version = PNG_IMAGE_VERSION;
-
- if (png_ptr != NULL)
- {
- png_infop info_ptr = png_create_info_struct(png_ptr);
-
- if (info_ptr != NULL)
- {
- png_controlp control = png_voidcast(png_controlp,
- png_malloc_warn(png_ptr, (sizeof *control)));
-
- if (control != NULL)
- {
- memset(control, 0, (sizeof *control));
-
- control->png_ptr = png_ptr;
- control->info_ptr = info_ptr;
- control->for_write = 0;
-
- image->opaque = control;
- return 1;
- }
-
- /* Error clean up */
- png_destroy_info_struct(png_ptr, &info_ptr);
- }
-
- png_destroy_read_struct(&png_ptr, NULL, NULL);
- }
-
- return png_image_error(image, "png_image_read: out of memory");
- }
-
- return png_image_error(image, "png_image_read: opaque pointer not NULL");
-}
-
-/* Utility to find the base format of a PNG file from a png_struct. */
-static png_uint_32
-png_image_format(png_structrp png_ptr)
-{
- png_uint_32 format = 0;
-
- if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0)
- format |= PNG_FORMAT_FLAG_COLOR;
-
- if ((png_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0)
- format |= PNG_FORMAT_FLAG_ALPHA;
-
- /* Use png_ptr here, not info_ptr, because by examination png_handle_tRNS
- * sets the png_struct fields; that's all we are interested in here. The
- * precise interaction with an app call to png_set_tRNS and PNG file reading
- * is unclear.
- */
- else if (png_ptr->num_trans > 0)
- format |= PNG_FORMAT_FLAG_ALPHA;
-
- if (png_ptr->bit_depth == 16)
- format |= PNG_FORMAT_FLAG_LINEAR;
-
- if ((png_ptr->color_type & PNG_COLOR_MASK_PALETTE) != 0)
- format |= PNG_FORMAT_FLAG_COLORMAP;
-
- return format;
-}
-
-/* Is the given gamma significantly different from sRGB? The test is the same
- * one used in pngrtran.c when deciding whether to do gamma correction. The
- * arithmetic optimizes the division by using the fact that the inverse of the
- * file sRGB gamma is 2.2
- */
-static int
-png_gamma_not_sRGB(png_fixed_point g)
-{
- if (g < PNG_FP_1)
- {
- /* An uninitialized gamma is assumed to be sRGB for the simplified API. */
- if (g == 0)
- return 0;
-
- return png_gamma_significant((g * 11 + 2)/5 /* i.e. *2.2, rounded */);
- }
-
- return 1;
-}
-
-/* Do the main body of a 'png_image_begin_read' function; read the PNG file
- * header and fill in all the information. This is executed in a safe context,
- * unlike the init routine above.
- */
-static int
-png_image_read_header(png_voidp argument)
-{
- png_imagep image = png_voidcast(png_imagep, argument);
- png_structrp png_ptr = image->opaque->png_ptr;
- png_inforp info_ptr = image->opaque->info_ptr;
-
-#ifdef PNG_BENIGN_ERRORS_SUPPORTED
- png_set_benign_errors(png_ptr, 1/*warn*/);
-#endif
- png_read_info(png_ptr, info_ptr);
-
- /* Do this the fast way; just read directly out of png_struct. */
- image->width = png_ptr->width;
- image->height = png_ptr->height;
-
- {
- png_uint_32 format = png_image_format(png_ptr);
-
- image->format = format;
-
-#ifdef PNG_COLORSPACE_SUPPORTED
- /* Does the colorspace match sRGB? If there is no color endpoint
- * (colorant) information assume yes, otherwise require the
- * 'ENDPOINTS_MATCHP_sRGB' colorspace flag to have been set. If the
- * colorspace has been determined to be invalid ignore it.
- */
- if ((format & PNG_FORMAT_FLAG_COLOR) != 0 && ((png_ptr->colorspace.flags
- & (PNG_COLORSPACE_HAVE_ENDPOINTS|PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB|
- PNG_COLORSPACE_INVALID)) == PNG_COLORSPACE_HAVE_ENDPOINTS))
- image->flags |= PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB;
-#endif
- }
-
- /* We need the maximum number of entries regardless of the format the
- * application sets here.
- */
- {
- png_uint_32 cmap_entries;
-
- switch (png_ptr->color_type)
- {
- case PNG_COLOR_TYPE_GRAY:
- cmap_entries = 1U << png_ptr->bit_depth;
- break;
-
- case PNG_COLOR_TYPE_PALETTE:
- cmap_entries = (png_uint_32)png_ptr->num_palette;
- break;
-
- default:
- cmap_entries = 256;
- break;
- }
-
- if (cmap_entries > 256)
- cmap_entries = 256;
-
- image->colormap_entries = cmap_entries;
- }
-
- return 1;
-}
-
-#ifdef PNG_STDIO_SUPPORTED
-int PNGAPI
-png_image_begin_read_from_stdio(png_imagep image, FILE* file)
-{
- if (image != NULL && image->version == PNG_IMAGE_VERSION)
- {
- if (file != NULL)
- {
- if (png_image_read_init(image) != 0)
- {
- /* This is slightly evil, but png_init_io doesn't do anything other
- * than this and we haven't changed the standard IO functions so
- * this saves a 'safe' function.
- */
- image->opaque->png_ptr->io_ptr = file;
- return png_safe_execute(image, png_image_read_header, image);
- }
- }
-
- else
- return png_image_error(image,
- "png_image_begin_read_from_stdio: invalid argument");
- }
-
- else if (image != NULL)
- return png_image_error(image,
- "png_image_begin_read_from_stdio: incorrect PNG_IMAGE_VERSION");
-
- return 0;
-}
-
-int PNGAPI
-png_image_begin_read_from_file(png_imagep image, const char *file_name)
-{
- if (image != NULL && image->version == PNG_IMAGE_VERSION)
- {
- if (file_name != NULL)
- {
- FILE *fp = fopen(file_name, "rb");
-
- if (fp != NULL)
- {
- if (png_image_read_init(image) != 0)
- {
- image->opaque->png_ptr->io_ptr = fp;
- image->opaque->owned_file = 1;
- return png_safe_execute(image, png_image_read_header, image);
- }
-
- /* Clean up: just the opened file. */
- (void)fclose(fp);
- }
-
- else
- return png_image_error(image, strerror(errno));
- }
-
- else
- return png_image_error(image,
- "png_image_begin_read_from_file: invalid argument");
- }
-
- else if (image != NULL)
- return png_image_error(image,
- "png_image_begin_read_from_file: incorrect PNG_IMAGE_VERSION");
-
- return 0;
-}
-#endif /* STDIO */
-
-static void PNGCBAPI
-png_image_memory_read(png_structp png_ptr, png_bytep out, size_t need)
-{
- if (png_ptr != NULL)
- {
- png_imagep image = png_voidcast(png_imagep, png_ptr->io_ptr);
- if (image != NULL)
- {
- png_controlp cp = image->opaque;
- if (cp != NULL)
- {
- png_const_bytep memory = cp->memory;
- size_t size = cp->size;
-
- if (memory != NULL && size >= need)
- {
- memcpy(out, memory, need);
- cp->memory = memory + need;
- cp->size = size - need;
- return;
- }
-
- png_error(png_ptr, "read beyond end of data");
- }
- }
-
- png_error(png_ptr, "invalid memory read");
- }
-}
-
-int PNGAPI png_image_begin_read_from_memory(png_imagep image,
- png_const_voidp memory, size_t size)
-{
- if (image != NULL && image->version == PNG_IMAGE_VERSION)
- {
- if (memory != NULL && size > 0)
- {
- if (png_image_read_init(image) != 0)
- {
- /* Now set the IO functions to read from the memory buffer and
- * store it into io_ptr. Again do this in-place to avoid calling a
- * libpng function that requires error handling.
- */
- image->opaque->memory = png_voidcast(png_const_bytep, memory);
- image->opaque->size = size;
- image->opaque->png_ptr->io_ptr = image;
- image->opaque->png_ptr->read_data_fn = png_image_memory_read;
-
- return png_safe_execute(image, png_image_read_header, image);
- }
- }
-
- else
- return png_image_error(image,
- "png_image_begin_read_from_memory: invalid argument");
- }
-
- else if (image != NULL)
- return png_image_error(image,
- "png_image_begin_read_from_memory: incorrect PNG_IMAGE_VERSION");
-
- return 0;
-}
-
-/* Utility function to skip chunks that are not used by the simplified image
- * read functions and an appropriate macro to call it.
- */
-#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
-static void
-png_image_skip_unused_chunks(png_structrp png_ptr)
-{
- /* Prepare the reader to ignore all recognized chunks whose data will not
- * be used, i.e., all chunks recognized by libpng except for those
- * involved in basic image reading:
- *
- * IHDR, PLTE, IDAT, IEND
- *
- * Or image data handling:
- *
- * tRNS, bKGD, gAMA, cHRM, sRGB, [iCCP] and sBIT.
- *
- * This provides a small performance improvement and eliminates any
- * potential vulnerability to security problems in the unused chunks.
- *
- * At present the iCCP chunk data isn't used, so iCCP chunk can be ignored
- * too. This allows the simplified API to be compiled without iCCP support,
- * however if the support is there the chunk is still checked to detect
- * errors (which are unfortunately quite common.)
- */
- {
- static const png_byte chunks_to_process[] = {
- 98, 75, 71, 68, '\0', /* bKGD */
- 99, 72, 82, 77, '\0', /* cHRM */
- 103, 65, 77, 65, '\0', /* gAMA */
-# ifdef PNG_READ_iCCP_SUPPORTED
- 105, 67, 67, 80, '\0', /* iCCP */
-# endif
- 115, 66, 73, 84, '\0', /* sBIT */
- 115, 82, 71, 66, '\0', /* sRGB */
- };
-
- /* Ignore unknown chunks and all other chunks except for the
- * IHDR, PLTE, tRNS, IDAT, and IEND chunks.
- */
- png_set_keep_unknown_chunks(png_ptr, PNG_HANDLE_CHUNK_NEVER,
- NULL, -1);
-
- /* But do not ignore image data handling chunks */
- png_set_keep_unknown_chunks(png_ptr, PNG_HANDLE_CHUNK_AS_DEFAULT,
- chunks_to_process, (int)/*SAFE*/(sizeof chunks_to_process)/5);
- }
-}
-
-# define PNG_SKIP_CHUNKS(p) png_image_skip_unused_chunks(p)
-#else
-# define PNG_SKIP_CHUNKS(p) ((void)0)
-#endif /* HANDLE_AS_UNKNOWN */
-
-/* The following macro gives the exact rounded answer for all values in the
- * range 0..255 (it actually divides by 51.2, but the rounding still generates
- * the correct numbers 0..5
- */
-#define PNG_DIV51(v8) (((v8) * 5 + 130) >> 8)
-
-/* Utility functions to make particular color-maps */
-static void
-set_file_encoding(png_image_read_control *display)
-{
- png_fixed_point g = display->image->opaque->png_ptr->colorspace.gamma;
- if (png_gamma_significant(g) != 0)
- {
- if (png_gamma_not_sRGB(g) != 0)
- {
- display->file_encoding = P_FILE;
- display->gamma_to_linear = png_reciprocal(g);
- }
-
- else
- display->file_encoding = P_sRGB;
- }
-
- else
- display->file_encoding = P_LINEAR8;
-}
-
-static unsigned int
-decode_gamma(png_image_read_control *display, png_uint_32 value, int encoding)
-{
- if (encoding == P_FILE) /* double check */
- encoding = display->file_encoding;
-
- if (encoding == P_NOTSET) /* must be the file encoding */
- {
- set_file_encoding(display);
- encoding = display->file_encoding;
- }
-
- switch (encoding)
- {
- case P_FILE:
- value = png_gamma_16bit_correct(value*257, display->gamma_to_linear);
- break;
-
- case P_sRGB:
- value = png_sRGB_table[value];
- break;
-
- case P_LINEAR:
- break;
-
- case P_LINEAR8:
- value *= 257;
- break;
-
-#ifdef __GNUC__
- default:
- png_error(display->image->opaque->png_ptr,
- "unexpected encoding (internal error)");
-#endif
- }
-
- return value;
-}
-
-static png_uint_32
-png_colormap_compose(png_image_read_control *display,
- png_uint_32 foreground, int foreground_encoding, png_uint_32 alpha,
- png_uint_32 background, int encoding)
-{
- /* The file value is composed on the background, the background has the given
- * encoding and so does the result, the file is encoded with P_FILE and the
- * file and alpha are 8-bit values. The (output) encoding will always be
- * P_LINEAR or P_sRGB.
- */
- png_uint_32 f = decode_gamma(display, foreground, foreground_encoding);
- png_uint_32 b = decode_gamma(display, background, encoding);
-
- /* The alpha is always an 8-bit value (it comes from the palette), the value
- * scaled by 255 is what PNG_sRGB_FROM_LINEAR requires.
- */
- f = f * alpha + b * (255-alpha);
-
- if (encoding == P_LINEAR)
- {
- /* Scale to 65535; divide by 255, approximately (in fact this is extremely
- * accurate, it divides by 255.00000005937181414556, with no overflow.)
- */
- f *= 257; /* Now scaled by 65535 */
- f += f >> 16;
- f = (f+32768) >> 16;
- }
-
- else /* P_sRGB */
- f = PNG_sRGB_FROM_LINEAR(f);
-
- return f;
-}
-
-/* NOTE: P_LINEAR values to this routine must be 16-bit, but P_FILE values must
- * be 8-bit.
- */
-static void
-png_create_colormap_entry(png_image_read_control *display,
- png_uint_32 ip, png_uint_32 red, png_uint_32 green, png_uint_32 blue,
- png_uint_32 alpha, int encoding)
-{
- png_imagep image = display->image;
- int output_encoding = (image->format & PNG_FORMAT_FLAG_LINEAR) != 0 ?
- P_LINEAR : P_sRGB;
- int convert_to_Y = (image->format & PNG_FORMAT_FLAG_COLOR) == 0 &&
- (red != green || green != blue);
-
- if (ip > 255)
- png_error(image->opaque->png_ptr, "color-map index out of range");
-
- /* Update the cache with whether the file gamma is significantly different
- * from sRGB.
- */
- if (encoding == P_FILE)
- {
- if (display->file_encoding == P_NOTSET)
- set_file_encoding(display);
-
- /* Note that the cached value may be P_FILE too, but if it is then the
- * gamma_to_linear member has been set.
- */
- encoding = display->file_encoding;
- }
-
- if (encoding == P_FILE)
- {
- png_fixed_point g = display->gamma_to_linear;
-
- red = png_gamma_16bit_correct(red*257, g);
- green = png_gamma_16bit_correct(green*257, g);
- blue = png_gamma_16bit_correct(blue*257, g);
-
- if (convert_to_Y != 0 || output_encoding == P_LINEAR)
- {
- alpha *= 257;
- encoding = P_LINEAR;
- }
-
- else
- {
- red = PNG_sRGB_FROM_LINEAR(red * 255);
- green = PNG_sRGB_FROM_LINEAR(green * 255);
- blue = PNG_sRGB_FROM_LINEAR(blue * 255);
- encoding = P_sRGB;
- }
- }
-
- else if (encoding == P_LINEAR8)
- {
- /* This encoding occurs quite frequently in test cases because PngSuite
- * includes a gAMA 1.0 chunk with most images.
- */
- red *= 257;
- green *= 257;
- blue *= 257;
- alpha *= 257;
- encoding = P_LINEAR;
- }
-
- else if (encoding == P_sRGB &&
- (convert_to_Y != 0 || output_encoding == P_LINEAR))
- {
- /* The values are 8-bit sRGB values, but must be converted to 16-bit
- * linear.
- */
- red = png_sRGB_table[red];
- green = png_sRGB_table[green];
- blue = png_sRGB_table[blue];
- alpha *= 257;
- encoding = P_LINEAR;
- }
-
- /* This is set if the color isn't gray but the output is. */
- if (encoding == P_LINEAR)
- {
- if (convert_to_Y != 0)
- {
- /* NOTE: these values are copied from png_do_rgb_to_gray */
- png_uint_32 y = (png_uint_32)6968 * red + (png_uint_32)23434 * green +
- (png_uint_32)2366 * blue;
-
- if (output_encoding == P_LINEAR)
- y = (y + 16384) >> 15;
-
- else
- {
- /* y is scaled by 32768, we need it scaled by 255: */
- y = (y + 128) >> 8;
- y *= 255;
- y = PNG_sRGB_FROM_LINEAR((y + 64) >> 7);
- alpha = PNG_DIV257(alpha);
- encoding = P_sRGB;
- }
-
- blue = red = green = y;
- }
-
- else if (output_encoding == P_sRGB)
- {
- red = PNG_sRGB_FROM_LINEAR(red * 255);
- green = PNG_sRGB_FROM_LINEAR(green * 255);
- blue = PNG_sRGB_FROM_LINEAR(blue * 255);
- alpha = PNG_DIV257(alpha);
- encoding = P_sRGB;
- }
- }
-
- if (encoding != output_encoding)
- png_error(image->opaque->png_ptr, "bad encoding (internal error)");
-
- /* Store the value. */
- {
-# ifdef PNG_FORMAT_AFIRST_SUPPORTED
- int afirst = (image->format & PNG_FORMAT_FLAG_AFIRST) != 0 &&
- (image->format & PNG_FORMAT_FLAG_ALPHA) != 0;
-# else
-# define afirst 0
-# endif
-# ifdef PNG_FORMAT_BGR_SUPPORTED
- int bgr = (image->format & PNG_FORMAT_FLAG_BGR) != 0 ? 2 : 0;
-# else
-# define bgr 0
-# endif
-
- if (output_encoding == P_LINEAR)
- {
- png_uint_16p entry = png_voidcast(png_uint_16p, display->colormap);
-
- entry += ip * PNG_IMAGE_SAMPLE_CHANNELS(image->format);
-
- /* The linear 16-bit values must be pre-multiplied by the alpha channel
- * value, if less than 65535 (this is, effectively, composite on black
- * if the alpha channel is removed.)
- */
- switch (PNG_IMAGE_SAMPLE_CHANNELS(image->format))
- {
- case 4:
- entry[afirst ? 0 : 3] = (png_uint_16)alpha;
- /* FALLTHROUGH */
-
- case 3:
- if (alpha < 65535)
- {
- if (alpha > 0)
- {
- blue = (blue * alpha + 32767U)/65535U;
- green = (green * alpha + 32767U)/65535U;
- red = (red * alpha + 32767U)/65535U;
- }
-
- else
- red = green = blue = 0;
- }
- entry[afirst + (2 ^ bgr)] = (png_uint_16)blue;
- entry[afirst + 1] = (png_uint_16)green;
- entry[afirst + bgr] = (png_uint_16)red;
- break;
-
- case 2:
- entry[1 ^ afirst] = (png_uint_16)alpha;
- /* FALLTHROUGH */
-
- case 1:
- if (alpha < 65535)
- {
- if (alpha > 0)
- green = (green * alpha + 32767U)/65535U;
-
- else
- green = 0;
- }
- entry[afirst] = (png_uint_16)green;
- break;
-
- default:
- break;
- }
- }
-
- else /* output encoding is P_sRGB */
- {
- png_bytep entry = png_voidcast(png_bytep, display->colormap);
-
- entry += ip * PNG_IMAGE_SAMPLE_CHANNELS(image->format);
-
- switch (PNG_IMAGE_SAMPLE_CHANNELS(image->format))
- {
- case 4:
- entry[afirst ? 0 : 3] = (png_byte)alpha;
- /* FALLTHROUGH */
- case 3:
- entry[afirst + (2 ^ bgr)] = (png_byte)blue;
- entry[afirst + 1] = (png_byte)green;
- entry[afirst + bgr] = (png_byte)red;
- break;
-
- case 2:
- entry[1 ^ afirst] = (png_byte)alpha;
- /* FALLTHROUGH */
- case 1:
- entry[afirst] = (png_byte)green;
- break;
-
- default:
- break;
- }
- }
-
-# ifdef afirst
-# undef afirst
-# endif
-# ifdef bgr
-# undef bgr
-# endif
- }
-}
-
-static int
-make_gray_file_colormap(png_image_read_control *display)
-{
- unsigned int i;
-
- for (i=0; i<256; ++i)
- png_create_colormap_entry(display, i, i, i, i, 255, P_FILE);
-
- return (int)i;
-}
-
-static int
-make_gray_colormap(png_image_read_control *display)
-{
- unsigned int i;
-
- for (i=0; i<256; ++i)
- png_create_colormap_entry(display, i, i, i, i, 255, P_sRGB);
-
- return (int)i;
-}
-#define PNG_GRAY_COLORMAP_ENTRIES 256
-
-static int
-make_ga_colormap(png_image_read_control *display)
-{
- unsigned int i, a;
-
- /* Alpha is retained, the output will be a color-map with entries
- * selected by six levels of alpha. One transparent entry, 6 gray
- * levels for all the intermediate alpha values, leaving 230 entries
- * for the opaque grays. The color-map entries are the six values
- * [0..5]*51, the GA processing uses PNG_DIV51(value) to find the
- * relevant entry.
- *
- * if (alpha > 229) // opaque
- * {
- * // The 231 entries are selected to make the math below work:
- * base = 0;
- * entry = (231 * gray + 128) >> 8;
- * }
- * else if (alpha < 26) // transparent
- * {
- * base = 231;
- * entry = 0;
- * }
- * else // partially opaque
- * {
- * base = 226 + 6 * PNG_DIV51(alpha);
- * entry = PNG_DIV51(gray);
- * }
- */
- i = 0;
- while (i < 231)
- {
- unsigned int gray = (i * 256 + 115) / 231;
- png_create_colormap_entry(display, i++, gray, gray, gray, 255, P_sRGB);
- }
-
- /* 255 is used here for the component values for consistency with the code
- * that undoes premultiplication in pngwrite.c.
- */
- png_create_colormap_entry(display, i++, 255, 255, 255, 0, P_sRGB);
-
- for (a=1; a<5; ++a)
- {
- unsigned int g;
-
- for (g=0; g<6; ++g)
- png_create_colormap_entry(display, i++, g*51, g*51, g*51, a*51,
- P_sRGB);
- }
-
- return (int)i;
-}
-
-#define PNG_GA_COLORMAP_ENTRIES 256
-
-static int
-make_rgb_colormap(png_image_read_control *display)
-{
- unsigned int i, r;
-
- /* Build a 6x6x6 opaque RGB cube */
- for (i=r=0; r<6; ++r)
- {
- unsigned int g;
-
- for (g=0; g<6; ++g)
- {
- unsigned int b;
-
- for (b=0; b<6; ++b)
- png_create_colormap_entry(display, i++, r*51, g*51, b*51, 255,
- P_sRGB);
- }
- }
-
- return (int)i;
-}
-
-#define PNG_RGB_COLORMAP_ENTRIES 216
-
-/* Return a palette index to the above palette given three 8-bit sRGB values. */
-#define PNG_RGB_INDEX(r,g,b) \
- ((png_byte)(6 * (6 * PNG_DIV51(r) + PNG_DIV51(g)) + PNG_DIV51(b)))
-
-static int
-png_image_read_colormap(png_voidp argument)
-{
- png_image_read_control *display =
- png_voidcast(png_image_read_control*, argument);
- png_imagep image = display->image;
-
- png_structrp png_ptr = image->opaque->png_ptr;
- png_uint_32 output_format = image->format;
- int output_encoding = (output_format & PNG_FORMAT_FLAG_LINEAR) != 0 ?
- P_LINEAR : P_sRGB;
-
- unsigned int cmap_entries;
- unsigned int output_processing; /* Output processing option */
- unsigned int data_encoding = P_NOTSET; /* Encoding libpng must produce */
-
- /* Background information; the background color and the index of this color
- * in the color-map if it exists (else 256).
- */
- unsigned int background_index = 256;
- png_uint_32 back_r, back_g, back_b;
-
- /* Flags to accumulate things that need to be done to the input. */
- int expand_tRNS = 0;
-
- /* Exclude the NYI feature of compositing onto a color-mapped buffer; it is
- * very difficult to do, the results look awful, and it is difficult to see
- * what possible use it is because the application can't control the
- * color-map.
- */
- if (((png_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0 ||
- png_ptr->num_trans > 0) /* alpha in input */ &&
- ((output_format & PNG_FORMAT_FLAG_ALPHA) == 0) /* no alpha in output */)
- {
- if (output_encoding == P_LINEAR) /* compose on black */
- back_b = back_g = back_r = 0;
-
- else if (display->background == NULL /* no way to remove it */)
- png_error(png_ptr,
- "background color must be supplied to remove alpha/transparency");
-
- /* Get a copy of the background color (this avoids repeating the checks
- * below.) The encoding is 8-bit sRGB or 16-bit linear, depending on the
- * output format.
- */
- else
- {
- back_g = display->background->green;
- if ((output_format & PNG_FORMAT_FLAG_COLOR) != 0)
- {
- back_r = display->background->red;
- back_b = display->background->blue;
- }
- else
- back_b = back_r = back_g;
- }
- }
-
- else if (output_encoding == P_LINEAR)
- back_b = back_r = back_g = 65535;
-
- else
- back_b = back_r = back_g = 255;
-
- /* Default the input file gamma if required - this is necessary because
- * libpng assumes that if no gamma information is present the data is in the
- * output format, but the simplified API deduces the gamma from the input
- * format.
- */
- if ((png_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) == 0)
- {
- /* Do this directly, not using the png_colorspace functions, to ensure
- * that it happens even if the colorspace is invalid (though probably if
- * it is the setting will be ignored) Note that the same thing can be
- * achieved at the application interface with png_set_gAMA.
- */
- if (png_ptr->bit_depth == 16 &&
- (image->flags & PNG_IMAGE_FLAG_16BIT_sRGB) == 0)
- png_ptr->colorspace.gamma = PNG_GAMMA_LINEAR;
-
- else
- png_ptr->colorspace.gamma = PNG_GAMMA_sRGB_INVERSE;
-
- png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA;
- }
-
- /* Decide what to do based on the PNG color type of the input data. The
- * utility function png_create_colormap_entry deals with most aspects of the
- * output transformations; this code works out how to produce bytes of
- * color-map entries from the original format.
- */
- switch (png_ptr->color_type)
- {
- case PNG_COLOR_TYPE_GRAY:
- if (png_ptr->bit_depth <= 8)
- {
- /* There at most 256 colors in the output, regardless of
- * transparency.
- */
- unsigned int step, i, val, trans = 256/*ignore*/, back_alpha = 0;
-
- cmap_entries = 1U << png_ptr->bit_depth;
- if (cmap_entries > image->colormap_entries)
- png_error(png_ptr, "gray[8] color-map: too few entries");
-
- step = 255 / (cmap_entries - 1);
- output_processing = PNG_CMAP_NONE;
-
- /* If there is a tRNS chunk then this either selects a transparent
- * value or, if the output has no alpha, the background color.
- */
- if (png_ptr->num_trans > 0)
- {
- trans = png_ptr->trans_color.gray;
-
- if ((output_format & PNG_FORMAT_FLAG_ALPHA) == 0)
- back_alpha = output_encoding == P_LINEAR ? 65535 : 255;
- }
-
- /* png_create_colormap_entry just takes an RGBA and writes the
- * corresponding color-map entry using the format from 'image',
- * including the required conversion to sRGB or linear as
- * appropriate. The input values are always either sRGB (if the
- * gamma correction flag is 0) or 0..255 scaled file encoded values
- * (if the function must gamma correct them).
- */
- for (i=val=0; i<cmap_entries; ++i, val += step)
- {
- /* 'i' is a file value. While this will result in duplicated
- * entries for 8-bit non-sRGB encoded files it is necessary to
- * have non-gamma corrected values to do tRNS handling.
- */
- if (i != trans)
- png_create_colormap_entry(display, i, val, val, val, 255,
- P_FILE/*8-bit with file gamma*/);
-
- /* Else this entry is transparent. The colors don't matter if
- * there is an alpha channel (back_alpha == 0), but it does no
- * harm to pass them in; the values are not set above so this
- * passes in white.
- *
- * NOTE: this preserves the full precision of the application
- * supplied background color when it is used.
- */
- else
- png_create_colormap_entry(display, i, back_r, back_g, back_b,
- back_alpha, output_encoding);
- }
-
- /* We need libpng to preserve the original encoding. */
- data_encoding = P_FILE;
-
- /* The rows from libpng, while technically gray values, are now also
- * color-map indices; however, they may need to be expanded to 1
- * byte per pixel. This is what png_set_packing does (i.e., it
- * unpacks the bit values into bytes.)
- */
- if (png_ptr->bit_depth < 8)
- png_set_packing(png_ptr);
- }
-
- else /* bit depth is 16 */
- {
- /* The 16-bit input values can be converted directly to 8-bit gamma
- * encoded values; however, if a tRNS chunk is present 257 color-map
- * entries are required. This means that the extra entry requires
- * special processing; add an alpha channel, sacrifice gray level
- * 254 and convert transparent (alpha==0) entries to that.
- *
- * Use libpng to chop the data to 8 bits. Convert it to sRGB at the
- * same time to minimize quality loss. If a tRNS chunk is present
- * this means libpng must handle it too; otherwise it is impossible
- * to do the exact match on the 16-bit value.
- *
- * If the output has no alpha channel *and* the background color is
- * gray then it is possible to let libpng handle the substitution by
- * ensuring that the corresponding gray level matches the background
- * color exactly.
- */
- data_encoding = P_sRGB;
-
- if (PNG_GRAY_COLORMAP_ENTRIES > image->colormap_entries)
- png_error(png_ptr, "gray[16] color-map: too few entries");
-
- cmap_entries = (unsigned int)make_gray_colormap(display);
-
- if (png_ptr->num_trans > 0)
- {
- unsigned int back_alpha;
-
- if ((output_format & PNG_FORMAT_FLAG_ALPHA) != 0)
- back_alpha = 0;
-
- else
- {
- if (back_r == back_g && back_g == back_b)
- {
- /* Background is gray; no special processing will be
- * required.
- */
- png_color_16 c;
- png_uint_32 gray = back_g;
-
- if (output_encoding == P_LINEAR)
- {
- gray = PNG_sRGB_FROM_LINEAR(gray * 255);
-
- /* And make sure the corresponding palette entry
- * matches.
- */
- png_create_colormap_entry(display, gray, back_g, back_g,
- back_g, 65535, P_LINEAR);
- }
-
- /* The background passed to libpng, however, must be the
- * sRGB value.
- */
- c.index = 0; /*unused*/
- c.gray = c.red = c.green = c.blue = (png_uint_16)gray;
-
- /* NOTE: does this work without expanding tRNS to alpha?
- * It should be the color->gray case below apparently
- * doesn't.
- */
- png_set_background_fixed(png_ptr, &c,
- PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/,
- 0/*gamma: not used*/);
-
- output_processing = PNG_CMAP_NONE;
- break;
- }
-#ifdef __COVERITY__
- /* Coverity claims that output_encoding cannot be 2 (P_LINEAR)
- * here.
- */
- back_alpha = 255;
-#else
- back_alpha = output_encoding == P_LINEAR ? 65535 : 255;
-#endif
- }
-
- /* output_processing means that the libpng-processed row will be
- * 8-bit GA and it has to be processing to single byte color-map
- * values. Entry 254 is replaced by either a completely
- * transparent entry or by the background color at full
- * precision (and the background color is not a simple gray
- * level in this case.)
- */
- expand_tRNS = 1;
- output_processing = PNG_CMAP_TRANS;
- background_index = 254;
-
- /* And set (overwrite) color-map entry 254 to the actual
- * background color at full precision.
- */
- png_create_colormap_entry(display, 254, back_r, back_g, back_b,
- back_alpha, output_encoding);
- }
-
- else
- output_processing = PNG_CMAP_NONE;
- }
- break;
-
- case PNG_COLOR_TYPE_GRAY_ALPHA:
- /* 8-bit or 16-bit PNG with two channels - gray and alpha. A minimum
- * of 65536 combinations. If, however, the alpha channel is to be
- * removed there are only 256 possibilities if the background is gray.
- * (Otherwise there is a subset of the 65536 possibilities defined by
- * the triangle between black, white and the background color.)
- *
- * Reduce 16-bit files to 8-bit and sRGB encode the result. No need to
- * worry about tRNS matching - tRNS is ignored if there is an alpha
- * channel.
- */
- data_encoding = P_sRGB;
-
- if ((output_format & PNG_FORMAT_FLAG_ALPHA) != 0)
- {
- if (PNG_GA_COLORMAP_ENTRIES > image->colormap_entries)
- png_error(png_ptr, "gray+alpha color-map: too few entries");
-
- cmap_entries = (unsigned int)make_ga_colormap(display);
-
- background_index = PNG_CMAP_GA_BACKGROUND;
- output_processing = PNG_CMAP_GA;
- }
-
- else /* alpha is removed */
- {
- /* Alpha must be removed as the PNG data is processed when the
- * background is a color because the G and A channels are
- * independent and the vector addition (non-parallel vectors) is a
- * 2-D problem.
- *
- * This can be reduced to the same algorithm as above by making a
- * colormap containing gray levels (for the opaque grays), a
- * background entry (for a transparent pixel) and a set of four six
- * level color values, one set for each intermediate alpha value.
- * See the comments in make_ga_colormap for how this works in the
- * per-pixel processing.
- *
- * If the background is gray, however, we only need a 256 entry gray
- * level color map. It is sufficient to make the entry generated
- * for the background color be exactly the color specified.
- */
- if ((output_format & PNG_FORMAT_FLAG_COLOR) == 0 ||
- (back_r == back_g && back_g == back_b))
- {
- /* Background is gray; no special processing will be required. */
- png_color_16 c;
- png_uint_32 gray = back_g;
-
- if (PNG_GRAY_COLORMAP_ENTRIES > image->colormap_entries)
- png_error(png_ptr, "gray-alpha color-map: too few entries");
-
- cmap_entries = (unsigned int)make_gray_colormap(display);
-
- if (output_encoding == P_LINEAR)
- {
- gray = PNG_sRGB_FROM_LINEAR(gray * 255);
-
- /* And make sure the corresponding palette entry matches. */
- png_create_colormap_entry(display, gray, back_g, back_g,
- back_g, 65535, P_LINEAR);
- }
-
- /* The background passed to libpng, however, must be the sRGB
- * value.
- */
- c.index = 0; /*unused*/
- c.gray = c.red = c.green = c.blue = (png_uint_16)gray;
-
- png_set_background_fixed(png_ptr, &c,
- PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/,
- 0/*gamma: not used*/);
-
- output_processing = PNG_CMAP_NONE;
- }
-
- else
- {
- png_uint_32 i, a;
-
- /* This is the same as png_make_ga_colormap, above, except that
- * the entries are all opaque.
- */
- if (PNG_GA_COLORMAP_ENTRIES > image->colormap_entries)
- png_error(png_ptr, "ga-alpha color-map: too few entries");
-
- i = 0;
- while (i < 231)
- {
- png_uint_32 gray = (i * 256 + 115) / 231;
- png_create_colormap_entry(display, i++, gray, gray, gray,
- 255, P_sRGB);
- }
-
- /* NOTE: this preserves the full precision of the application
- * background color.
- */
- background_index = i;
- png_create_colormap_entry(display, i++, back_r, back_g, back_b,
-#ifdef __COVERITY__
- /* Coverity claims that output_encoding
- * cannot be 2 (P_LINEAR) here.
- */ 255U,
-#else
- output_encoding == P_LINEAR ? 65535U : 255U,
-#endif
- output_encoding);
-
- /* For non-opaque input composite on the sRGB background - this
- * requires inverting the encoding for each component. The input
- * is still converted to the sRGB encoding because this is a
- * reasonable approximate to the logarithmic curve of human
- * visual sensitivity, at least over the narrow range which PNG
- * represents. Consequently 'G' is always sRGB encoded, while
- * 'A' is linear. We need the linear background colors.
- */
- if (output_encoding == P_sRGB) /* else already linear */
- {
- /* This may produce a value not exactly matching the
- * background, but that's ok because these numbers are only
- * used when alpha != 0
- */
- back_r = png_sRGB_table[back_r];
- back_g = png_sRGB_table[back_g];
- back_b = png_sRGB_table[back_b];
- }
-
- for (a=1; a<5; ++a)
- {
- unsigned int g;
-
- /* PNG_sRGB_FROM_LINEAR expects a 16-bit linear value scaled
- * by an 8-bit alpha value (0..255).
- */
- png_uint_32 alpha = 51 * a;
- png_uint_32 back_rx = (255-alpha) * back_r;
- png_uint_32 back_gx = (255-alpha) * back_g;
- png_uint_32 back_bx = (255-alpha) * back_b;
-
- for (g=0; g<6; ++g)
- {
- png_uint_32 gray = png_sRGB_table[g*51] * alpha;
-
- png_create_colormap_entry(display, i++,
- PNG_sRGB_FROM_LINEAR(gray + back_rx),
- PNG_sRGB_FROM_LINEAR(gray + back_gx),
- PNG_sRGB_FROM_LINEAR(gray + back_bx), 255, P_sRGB);
- }
- }
-
- cmap_entries = i;
- output_processing = PNG_CMAP_GA;
- }
- }
- break;
-
- case PNG_COLOR_TYPE_RGB:
- case PNG_COLOR_TYPE_RGB_ALPHA:
- /* Exclude the case where the output is gray; we can always handle this
- * with the cases above.
- */
- if ((output_format & PNG_FORMAT_FLAG_COLOR) == 0)
- {
- /* The color-map will be grayscale, so we may as well convert the
- * input RGB values to a simple grayscale and use the grayscale
- * code above.
- *
- * NOTE: calling this apparently damages the recognition of the
- * transparent color in background color handling; call
- * png_set_tRNS_to_alpha before png_set_background_fixed.
- */
- png_set_rgb_to_gray_fixed(png_ptr, PNG_ERROR_ACTION_NONE, -1,
- -1);
- data_encoding = P_sRGB;
-
- /* The output will now be one or two 8-bit gray or gray+alpha
- * channels. The more complex case arises when the input has alpha.
- */
- if ((png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA ||
- png_ptr->num_trans > 0) &&
- (output_format & PNG_FORMAT_FLAG_ALPHA) != 0)
- {
- /* Both input and output have an alpha channel, so no background
- * processing is required; just map the GA bytes to the right
- * color-map entry.
- */
- expand_tRNS = 1;
-
- if (PNG_GA_COLORMAP_ENTRIES > image->colormap_entries)
- png_error(png_ptr, "rgb[ga] color-map: too few entries");
-
- cmap_entries = (unsigned int)make_ga_colormap(display);
- background_index = PNG_CMAP_GA_BACKGROUND;
- output_processing = PNG_CMAP_GA;
- }
-
- else
- {
- /* Either the input or the output has no alpha channel, so there
- * will be no non-opaque pixels in the color-map; it will just be
- * grayscale.
- */
- if (PNG_GRAY_COLORMAP_ENTRIES > image->colormap_entries)
- png_error(png_ptr, "rgb[gray] color-map: too few entries");
-
- /* Ideally this code would use libpng to do the gamma correction,
- * but if an input alpha channel is to be removed we will hit the
- * libpng bug in gamma+compose+rgb-to-gray (the double gamma
- * correction bug). Fix this by dropping the gamma correction in
- * this case and doing it in the palette; this will result in
- * duplicate palette entries, but that's better than the
- * alternative of double gamma correction.
- */
- if ((png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA ||
- png_ptr->num_trans > 0) &&
- png_gamma_not_sRGB(png_ptr->colorspace.gamma) != 0)
- {
- cmap_entries = (unsigned int)make_gray_file_colormap(display);
- data_encoding = P_FILE;
- }
-
- else
- cmap_entries = (unsigned int)make_gray_colormap(display);
-
- /* But if the input has alpha or transparency it must be removed
- */
- if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA ||
- png_ptr->num_trans > 0)
- {
- png_color_16 c;
- png_uint_32 gray = back_g;
-
- /* We need to ensure that the application background exists in
- * the colormap and that completely transparent pixels map to
- * it. Achieve this simply by ensuring that the entry
- * selected for the background really is the background color.
- */
- if (data_encoding == P_FILE) /* from the fixup above */
- {
- /* The app supplied a gray which is in output_encoding, we
- * need to convert it to a value of the input (P_FILE)
- * encoding then set this palette entry to the required
- * output encoding.
- */
- if (output_encoding == P_sRGB)
- gray = png_sRGB_table[gray]; /* now P_LINEAR */
-
- gray = PNG_DIV257(png_gamma_16bit_correct(gray,
- png_ptr->colorspace.gamma)); /* now P_FILE */
-
- /* And make sure the corresponding palette entry contains
- * exactly the required sRGB value.
- */
- png_create_colormap_entry(display, gray, back_g, back_g,
- back_g, 0/*unused*/, output_encoding);
- }
-
- else if (output_encoding == P_LINEAR)
- {
- gray = PNG_sRGB_FROM_LINEAR(gray * 255);
-
- /* And make sure the corresponding palette entry matches.
- */
- png_create_colormap_entry(display, gray, back_g, back_g,
- back_g, 0/*unused*/, P_LINEAR);
- }
-
- /* The background passed to libpng, however, must be the
- * output (normally sRGB) value.
- */
- c.index = 0; /*unused*/
- c.gray = c.red = c.green = c.blue = (png_uint_16)gray;
-
- /* NOTE: the following is apparently a bug in libpng. Without
- * it the transparent color recognition in
- * png_set_background_fixed seems to go wrong.
- */
- expand_tRNS = 1;
- png_set_background_fixed(png_ptr, &c,
- PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/,
- 0/*gamma: not used*/);
- }
-
- output_processing = PNG_CMAP_NONE;
- }
- }
-
- else /* output is color */
- {
- /* We could use png_quantize here so long as there is no transparent
- * color or alpha; png_quantize ignores alpha. Easier overall just
- * to do it once and using PNG_DIV51 on the 6x6x6 reduced RGB cube.
- * Consequently we always want libpng to produce sRGB data.
- */
- data_encoding = P_sRGB;
-
- /* Is there any transparency or alpha? */
- if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA ||
- png_ptr->num_trans > 0)
- {
- /* Is there alpha in the output too? If so all four channels are
- * processed into a special RGB cube with alpha support.
- */
- if ((output_format & PNG_FORMAT_FLAG_ALPHA) != 0)
- {
- png_uint_32 r;
-
- if (PNG_RGB_COLORMAP_ENTRIES+1+27 > image->colormap_entries)
- png_error(png_ptr, "rgb+alpha color-map: too few entries");
-
- cmap_entries = (unsigned int)make_rgb_colormap(display);
-
- /* Add a transparent entry. */
- png_create_colormap_entry(display, cmap_entries, 255, 255,
- 255, 0, P_sRGB);
-
- /* This is stored as the background index for the processing
- * algorithm.
- */
- background_index = cmap_entries++;
-
- /* Add 27 r,g,b entries each with alpha 0.5. */
- for (r=0; r<256; r = (r << 1) | 0x7f)
- {
- png_uint_32 g;
-
- for (g=0; g<256; g = (g << 1) | 0x7f)
- {
- png_uint_32 b;
-
- /* This generates components with the values 0, 127 and
- * 255
- */
- for (b=0; b<256; b = (b << 1) | 0x7f)
- png_create_colormap_entry(display, cmap_entries++,
- r, g, b, 128, P_sRGB);
- }
- }
-
- expand_tRNS = 1;
- output_processing = PNG_CMAP_RGB_ALPHA;
- }
-
- else
- {
- /* Alpha/transparency must be removed. The background must
- * exist in the color map (achieved by setting adding it after
- * the 666 color-map). If the standard processing code will
- * pick up this entry automatically that's all that is
- * required; libpng can be called to do the background
- * processing.
- */
- unsigned int sample_size =
- PNG_IMAGE_SAMPLE_SIZE(output_format);
- png_uint_32 r, g, b; /* sRGB background */
-
- if (PNG_RGB_COLORMAP_ENTRIES+1+27 > image->colormap_entries)
- png_error(png_ptr, "rgb-alpha color-map: too few entries");
-
- cmap_entries = (unsigned int)make_rgb_colormap(display);
-
- png_create_colormap_entry(display, cmap_entries, back_r,
- back_g, back_b, 0/*unused*/, output_encoding);
-
- if (output_encoding == P_LINEAR)
- {
- r = PNG_sRGB_FROM_LINEAR(back_r * 255);
- g = PNG_sRGB_FROM_LINEAR(back_g * 255);
- b = PNG_sRGB_FROM_LINEAR(back_b * 255);
- }
-
- else
- {
- r = back_r;
- g = back_g;
- b = back_g;
- }
-
- /* Compare the newly-created color-map entry with the one the
- * PNG_CMAP_RGB algorithm will use. If the two entries don't
- * match, add the new one and set this as the background
- * index.
- */
- if (memcmp((png_const_bytep)display->colormap +
- sample_size * cmap_entries,
- (png_const_bytep)display->colormap +
- sample_size * PNG_RGB_INDEX(r,g,b),
- sample_size) != 0)
- {
- /* The background color must be added. */
- background_index = cmap_entries++;
-
- /* Add 27 r,g,b entries each with created by composing with
- * the background at alpha 0.5.
- */
- for (r=0; r<256; r = (r << 1) | 0x7f)
- {
- for (g=0; g<256; g = (g << 1) | 0x7f)
- {
- /* This generates components with the values 0, 127
- * and 255
- */
- for (b=0; b<256; b = (b << 1) | 0x7f)
- png_create_colormap_entry(display, cmap_entries++,
- png_colormap_compose(display, r, P_sRGB, 128,
- back_r, output_encoding),
- png_colormap_compose(display, g, P_sRGB, 128,
- back_g, output_encoding),
- png_colormap_compose(display, b, P_sRGB, 128,
- back_b, output_encoding),
- 0/*unused*/, output_encoding);
- }
- }
-
- expand_tRNS = 1;
- output_processing = PNG_CMAP_RGB_ALPHA;
- }
-
- else /* background color is in the standard color-map */
- {
- png_color_16 c;
-
- c.index = 0; /*unused*/
- c.red = (png_uint_16)back_r;
- c.gray = c.green = (png_uint_16)back_g;
- c.blue = (png_uint_16)back_b;
-
- png_set_background_fixed(png_ptr, &c,
- PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/,
- 0/*gamma: not used*/);
-
- output_processing = PNG_CMAP_RGB;
- }
- }
- }
-
- else /* no alpha or transparency in the input */
- {
- /* Alpha in the output is irrelevant, simply map the opaque input
- * pixels to the 6x6x6 color-map.
- */
- if (PNG_RGB_COLORMAP_ENTRIES > image->colormap_entries)
- png_error(png_ptr, "rgb color-map: too few entries");
-
- cmap_entries = (unsigned int)make_rgb_colormap(display);
- output_processing = PNG_CMAP_RGB;
- }
- }
- break;
-
- case PNG_COLOR_TYPE_PALETTE:
- /* It's already got a color-map. It may be necessary to eliminate the
- * tRNS entries though.
- */
- {
- unsigned int num_trans = png_ptr->num_trans;
- png_const_bytep trans = num_trans > 0 ? png_ptr->trans_alpha : NULL;
- png_const_colorp colormap = png_ptr->palette;
- int do_background = trans != NULL &&
- (output_format & PNG_FORMAT_FLAG_ALPHA) == 0;
- unsigned int i;
-
- /* Just in case: */
- if (trans == NULL)
- num_trans = 0;
-
- output_processing = PNG_CMAP_NONE;
- data_encoding = P_FILE; /* Don't change from color-map indices */
- cmap_entries = (unsigned int)png_ptr->num_palette;
- if (cmap_entries > 256)
- cmap_entries = 256;
-
- if (cmap_entries > (unsigned int)image->colormap_entries)
- png_error(png_ptr, "palette color-map: too few entries");
-
- for (i=0; i < cmap_entries; ++i)
- {
- if (do_background != 0 && i < num_trans && trans[i] < 255)
- {
- if (trans[i] == 0)
- png_create_colormap_entry(display, i, back_r, back_g,
- back_b, 0, output_encoding);
-
- else
- {
- /* Must compose the PNG file color in the color-map entry
- * on the sRGB color in 'back'.
- */
- png_create_colormap_entry(display, i,
- png_colormap_compose(display, colormap[i].red,
- P_FILE, trans[i], back_r, output_encoding),
- png_colormap_compose(display, colormap[i].green,
- P_FILE, trans[i], back_g, output_encoding),
- png_colormap_compose(display, colormap[i].blue,
- P_FILE, trans[i], back_b, output_encoding),
- output_encoding == P_LINEAR ? trans[i] * 257U :
- trans[i],
- output_encoding);
- }
- }
-
- else
- png_create_colormap_entry(display, i, colormap[i].red,
- colormap[i].green, colormap[i].blue,
- i < num_trans ? trans[i] : 255U, P_FILE/*8-bit*/);
- }
-
- /* The PNG data may have indices packed in fewer than 8 bits, it
- * must be expanded if so.
- */
- if (png_ptr->bit_depth < 8)
- png_set_packing(png_ptr);
- }
- break;
-
- default:
- png_error(png_ptr, "invalid PNG color type");
- /*NOT REACHED*/
- }
-
- /* Now deal with the output processing */
- if (expand_tRNS != 0 && png_ptr->num_trans > 0 &&
- (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) == 0)
- png_set_tRNS_to_alpha(png_ptr);
-
- switch (data_encoding)
- {
- case P_sRGB:
- /* Change to 8-bit sRGB */
- png_set_alpha_mode_fixed(png_ptr, PNG_ALPHA_PNG, PNG_GAMMA_sRGB);
- /* FALLTHROUGH */
-
- case P_FILE:
- if (png_ptr->bit_depth > 8)
- png_set_scale_16(png_ptr);
- break;
-
-#ifdef __GNUC__
- default:
- png_error(png_ptr, "bad data option (internal error)");
-#endif
- }
-
- if (cmap_entries > 256 || cmap_entries > image->colormap_entries)
- png_error(png_ptr, "color map overflow (BAD internal error)");
-
- image->colormap_entries = cmap_entries;
-
- /* Double check using the recorded background index */
- switch (output_processing)
- {
- case PNG_CMAP_NONE:
- if (background_index != PNG_CMAP_NONE_BACKGROUND)
- goto bad_background;
- break;
-
- case PNG_CMAP_GA:
- if (background_index != PNG_CMAP_GA_BACKGROUND)
- goto bad_background;
- break;
-
- case PNG_CMAP_TRANS:
- if (background_index >= cmap_entries ||
- background_index != PNG_CMAP_TRANS_BACKGROUND)
- goto bad_background;
- break;
-
- case PNG_CMAP_RGB:
- if (background_index != PNG_CMAP_RGB_BACKGROUND)
- goto bad_background;
- break;
-
- case PNG_CMAP_RGB_ALPHA:
- if (background_index != PNG_CMAP_RGB_ALPHA_BACKGROUND)
- goto bad_background;
- break;
-
- default:
- png_error(png_ptr, "bad processing option (internal error)");
-
- bad_background:
- png_error(png_ptr, "bad background index (internal error)");
- }
-
- display->colormap_processing = (int)output_processing;
-
- return 1/*ok*/;
-}
-
-/* The final part of the color-map read called from png_image_finish_read. */
-static int
-png_image_read_and_map(png_voidp argument)
-{
- png_image_read_control *display = png_voidcast(png_image_read_control*,
- argument);
- png_imagep image = display->image;
- png_structrp png_ptr = image->opaque->png_ptr;
- int passes;
-
- /* Called when the libpng data must be transformed into the color-mapped
- * form. There is a local row buffer in display->local and this routine must
- * do the interlace handling.
- */
- switch (png_ptr->interlaced)
- {
- case PNG_INTERLACE_NONE:
- passes = 1;
- break;
-
- case PNG_INTERLACE_ADAM7:
- passes = PNG_INTERLACE_ADAM7_PASSES;
- break;
-
- default:
- png_error(png_ptr, "unknown interlace type");
- }
-
- {
- png_uint_32 height = image->height;
- png_uint_32 width = image->width;
- int proc = display->colormap_processing;
- png_bytep first_row = png_voidcast(png_bytep, display->first_row);
- ptrdiff_t step_row = display->row_bytes;
- int pass;
-
- for (pass = 0; pass < passes; ++pass)
- {
- unsigned int startx, stepx, stepy;
- png_uint_32 y;
-
- if (png_ptr->interlaced == PNG_INTERLACE_ADAM7)
- {
- /* The row may be empty for a short image: */
- if (PNG_PASS_COLS(width, pass) == 0)
- continue;
-
- startx = PNG_PASS_START_COL(pass);
- stepx = PNG_PASS_COL_OFFSET(pass);
- y = PNG_PASS_START_ROW(pass);
- stepy = PNG_PASS_ROW_OFFSET(pass);
- }
-
- else
- {
- y = 0;
- startx = 0;
- stepx = stepy = 1;
- }
-
- for (; y<height; y += stepy)
- {
- png_bytep inrow = png_voidcast(png_bytep, display->local_row);
- png_bytep outrow = first_row + y * step_row;
- png_const_bytep end_row = outrow + width;
-
- /* Read read the libpng data into the temporary buffer. */
- png_read_row(png_ptr, inrow, NULL);
-
- /* Now process the row according to the processing option, note
- * that the caller verifies that the format of the libpng output
- * data is as required.
- */
- outrow += startx;
- switch (proc)
- {
- case PNG_CMAP_GA:
- for (; outrow < end_row; outrow += stepx)
- {
- /* The data is always in the PNG order */
- unsigned int gray = *inrow++;
- unsigned int alpha = *inrow++;
- unsigned int entry;
-
- /* NOTE: this code is copied as a comment in
- * make_ga_colormap above. Please update the
- * comment if you change this code!
- */
- if (alpha > 229) /* opaque */
- {
- entry = (231 * gray + 128) >> 8;
- }
- else if (alpha < 26) /* transparent */
- {
- entry = 231;
- }
- else /* partially opaque */
- {
- entry = 226 + 6 * PNG_DIV51(alpha) + PNG_DIV51(gray);
- }
-
- *outrow = (png_byte)entry;
- }
- break;
-
- case PNG_CMAP_TRANS:
- for (; outrow < end_row; outrow += stepx)
- {
- png_byte gray = *inrow++;
- png_byte alpha = *inrow++;
-
- if (alpha == 0)
- *outrow = PNG_CMAP_TRANS_BACKGROUND;
-
- else if (gray != PNG_CMAP_TRANS_BACKGROUND)
- *outrow = gray;
-
- else
- *outrow = (png_byte)(PNG_CMAP_TRANS_BACKGROUND+1);
- }
- break;
-
- case PNG_CMAP_RGB:
- for (; outrow < end_row; outrow += stepx)
- {
- *outrow = PNG_RGB_INDEX(inrow[0], inrow[1], inrow[2]);
- inrow += 3;
- }
- break;
-
- case PNG_CMAP_RGB_ALPHA:
- for (; outrow < end_row; outrow += stepx)
- {
- unsigned int alpha = inrow[3];
-
- /* Because the alpha entries only hold alpha==0.5 values
- * split the processing at alpha==0.25 (64) and 0.75
- * (196).
- */
-
- if (alpha >= 196)
- *outrow = PNG_RGB_INDEX(inrow[0], inrow[1],
- inrow[2]);
-
- else if (alpha < 64)
- *outrow = PNG_CMAP_RGB_ALPHA_BACKGROUND;
-
- else
- {
- /* Likewise there are three entries for each of r, g
- * and b. We could select the entry by popcount on
- * the top two bits on those architectures that
- * support it, this is what the code below does,
- * crudely.
- */
- unsigned int back_i = PNG_CMAP_RGB_ALPHA_BACKGROUND+1;
-
- /* Here are how the values map:
- *
- * 0x00 .. 0x3f -> 0
- * 0x40 .. 0xbf -> 1
- * 0xc0 .. 0xff -> 2
- *
- * So, as above with the explicit alpha checks, the
- * breakpoints are at 64 and 196.
- */
- if (inrow[0] & 0x80) back_i += 9; /* red */
- if (inrow[0] & 0x40) back_i += 9;
- if (inrow[0] & 0x80) back_i += 3; /* green */
- if (inrow[0] & 0x40) back_i += 3;
- if (inrow[0] & 0x80) back_i += 1; /* blue */
- if (inrow[0] & 0x40) back_i += 1;
-
- *outrow = (png_byte)back_i;
- }
-
- inrow += 4;
- }
- break;
-
- default:
- break;
- }
- }
- }
- }
-
- return 1;
-}
-
-static int
-png_image_read_colormapped(png_voidp argument)
-{
- png_image_read_control *display = png_voidcast(png_image_read_control*,
- argument);
- png_imagep image = display->image;
- png_controlp control = image->opaque;
- png_structrp png_ptr = control->png_ptr;
- png_inforp info_ptr = control->info_ptr;
-
- int passes = 0; /* As a flag */
-
- PNG_SKIP_CHUNKS(png_ptr);
-
- /* Update the 'info' structure and make sure the result is as required; first
- * make sure to turn on the interlace handling if it will be required
- * (because it can't be turned on *after* the call to png_read_update_info!)
- */
- if (display->colormap_processing == PNG_CMAP_NONE)
- passes = png_set_interlace_handling(png_ptr);
-
- png_read_update_info(png_ptr, info_ptr);
-
- /* The expected output can be deduced from the colormap_processing option. */
- switch (display->colormap_processing)
- {
- case PNG_CMAP_NONE:
- /* Output must be one channel and one byte per pixel, the output
- * encoding can be anything.
- */
- if ((info_ptr->color_type == PNG_COLOR_TYPE_PALETTE ||
- info_ptr->color_type == PNG_COLOR_TYPE_GRAY) &&
- info_ptr->bit_depth == 8)
- break;
-
- goto bad_output;
-
- case PNG_CMAP_TRANS:
- case PNG_CMAP_GA:
- /* Output must be two channels and the 'G' one must be sRGB, the latter
- * can be checked with an exact number because it should have been set
- * to this number above!
- */
- if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA &&
- info_ptr->bit_depth == 8 &&
- png_ptr->screen_gamma == PNG_GAMMA_sRGB &&
- image->colormap_entries == 256)
- break;
-
- goto bad_output;
-
- case PNG_CMAP_RGB:
- /* Output must be 8-bit sRGB encoded RGB */
- if (info_ptr->color_type == PNG_COLOR_TYPE_RGB &&
- info_ptr->bit_depth == 8 &&
- png_ptr->screen_gamma == PNG_GAMMA_sRGB &&
- image->colormap_entries == 216)
- break;
-
- goto bad_output;
-
- case PNG_CMAP_RGB_ALPHA:
- /* Output must be 8-bit sRGB encoded RGBA */
- if (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA &&
- info_ptr->bit_depth == 8 &&
- png_ptr->screen_gamma == PNG_GAMMA_sRGB &&
- image->colormap_entries == 244 /* 216 + 1 + 27 */)
- break;
-
- goto bad_output;
-
- default:
- bad_output:
- png_error(png_ptr, "bad color-map processing (internal error)");
- }
-
- /* Now read the rows. Do this here if it is possible to read directly into
- * the output buffer, otherwise allocate a local row buffer of the maximum
- * size libpng requires and call the relevant processing routine safely.
- */
- {
- png_voidp first_row = display->buffer;
- ptrdiff_t row_bytes = display->row_stride;
-
- /* The following expression is designed to work correctly whether it gives
- * a signed or an unsigned result.
- */
- if (row_bytes < 0)
- {
- char *ptr = png_voidcast(char*, first_row);
- ptr += (image->height-1) * (-row_bytes);
- first_row = png_voidcast(png_voidp, ptr);
- }
-
- display->first_row = first_row;
- display->row_bytes = row_bytes;
- }
-
- if (passes == 0)
- {
- int result;
- png_voidp row = png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr));
-
- display->local_row = row;
- result = png_safe_execute(image, png_image_read_and_map, display);
- display->local_row = NULL;
- png_free(png_ptr, row);
-
- return result;
- }
-
- else
- {
- png_alloc_size_t row_bytes = (png_alloc_size_t)display->row_bytes;
-
- while (--passes >= 0)
- {
- png_uint_32 y = image->height;
- png_bytep row = png_voidcast(png_bytep, display->first_row);
-
- for (; y > 0; --y)
- {
- png_read_row(png_ptr, row, NULL);
- row += row_bytes;
- }
- }
-
- return 1;
- }
-}
-
-/* Just the row reading part of png_image_read. */
-static int
-png_image_read_composite(png_voidp argument)
-{
- png_image_read_control *display = png_voidcast(png_image_read_control*,
- argument);
- png_imagep image = display->image;
- png_structrp png_ptr = image->opaque->png_ptr;
- int passes;
-
- switch (png_ptr->interlaced)
- {
- case PNG_INTERLACE_NONE:
- passes = 1;
- break;
-
- case PNG_INTERLACE_ADAM7:
- passes = PNG_INTERLACE_ADAM7_PASSES;
- break;
-
- default:
- png_error(png_ptr, "unknown interlace type");
- }
-
- {
- png_uint_32 height = image->height;
- png_uint_32 width = image->width;
- ptrdiff_t step_row = display->row_bytes;
- unsigned int channels =
- (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? 3 : 1;
- int pass;
-
- for (pass = 0; pass < passes; ++pass)
- {
- unsigned int startx, stepx, stepy;
- png_uint_32 y;
-
- if (png_ptr->interlaced == PNG_INTERLACE_ADAM7)
- {
- /* The row may be empty for a short image: */
- if (PNG_PASS_COLS(width, pass) == 0)
- continue;
-
- startx = PNG_PASS_START_COL(pass) * channels;
- stepx = PNG_PASS_COL_OFFSET(pass) * channels;
- y = PNG_PASS_START_ROW(pass);
- stepy = PNG_PASS_ROW_OFFSET(pass);
- }
-
- else
- {
- y = 0;
- startx = 0;
- stepx = channels;
- stepy = 1;
- }
-
- for (; y<height; y += stepy)
- {
- png_bytep inrow = png_voidcast(png_bytep, display->local_row);
- png_bytep outrow;
- png_const_bytep end_row;
-
- /* Read the row, which is packed: */
- png_read_row(png_ptr, inrow, NULL);
-
- outrow = png_voidcast(png_bytep, display->first_row);
- outrow += y * step_row;
- end_row = outrow + width * channels;
-
- /* Now do the composition on each pixel in this row. */
- outrow += startx;
- for (; outrow < end_row; outrow += stepx)
- {
- png_byte alpha = inrow[channels];
-
- if (alpha > 0) /* else no change to the output */
- {
- unsigned int c;
-
- for (c=0; c<channels; ++c)
- {
- png_uint_32 component = inrow[c];
-
- if (alpha < 255) /* else just use component */
- {
- /* This is PNG_OPTIMIZED_ALPHA, the component value
- * is a linear 8-bit value. Combine this with the
- * current outrow[c] value which is sRGB encoded.
- * Arithmetic here is 16-bits to preserve the output
- * values correctly.
- */
- component *= 257*255; /* =65535 */
- component += (255-alpha)*png_sRGB_table[outrow[c]];
-
- /* So 'component' is scaled by 255*65535 and is
- * therefore appropriate for the sRGB to linear
- * conversion table.
- */
- component = PNG_sRGB_FROM_LINEAR(component);
- }
-
- outrow[c] = (png_byte)component;
- }
- }
-
- inrow += channels+1; /* components and alpha channel */
- }
- }
- }
- }
-
- return 1;
-}
-
-/* The do_local_background case; called when all the following transforms are to
- * be done:
- *
- * PNG_RGB_TO_GRAY
- * PNG_COMPOSITE
- * PNG_GAMMA
- *
- * This is a work-around for the fact that both the PNG_RGB_TO_GRAY and
- * PNG_COMPOSITE code performs gamma correction, so we get double gamma
- * correction. The fix-up is to prevent the PNG_COMPOSITE operation from
- * happening inside libpng, so this routine sees an 8 or 16-bit gray+alpha
- * row and handles the removal or pre-multiplication of the alpha channel.
- */
-static int
-png_image_read_background(png_voidp argument)
-{
- png_image_read_control *display = png_voidcast(png_image_read_control*,
- argument);
- png_imagep image = display->image;
- png_structrp png_ptr = image->opaque->png_ptr;
- png_inforp info_ptr = image->opaque->info_ptr;
- png_uint_32 height = image->height;
- png_uint_32 width = image->width;
- int pass, passes;
-
- /* Double check the convoluted logic below. We expect to get here with
- * libpng doing rgb to gray and gamma correction but background processing
- * left to the png_image_read_background function. The rows libpng produce
- * might be 8 or 16-bit but should always have two channels; gray plus alpha.
- */
- if ((png_ptr->transformations & PNG_RGB_TO_GRAY) == 0)
- png_error(png_ptr, "lost rgb to gray");
-
- if ((png_ptr->transformations & PNG_COMPOSE) != 0)
- png_error(png_ptr, "unexpected compose");
-
- if (png_get_channels(png_ptr, info_ptr) != 2)
- png_error(png_ptr, "lost/gained channels");
-
- /* Expect the 8-bit case to always remove the alpha channel */
- if ((image->format & PNG_FORMAT_FLAG_LINEAR) == 0 &&
- (image->format & PNG_FORMAT_FLAG_ALPHA) != 0)
- png_error(png_ptr, "unexpected 8-bit transformation");
-
- switch (png_ptr->interlaced)
- {
- case PNG_INTERLACE_NONE:
- passes = 1;
- break;
-
- case PNG_INTERLACE_ADAM7:
- passes = PNG_INTERLACE_ADAM7_PASSES;
- break;
-
- default:
- png_error(png_ptr, "unknown interlace type");
- }
-
- /* Use direct access to info_ptr here because otherwise the simplified API
- * would require PNG_EASY_ACCESS_SUPPORTED (just for this.) Note this is
- * checking the value after libpng expansions, not the original value in the
- * PNG.
- */
- switch (info_ptr->bit_depth)
- {
- case 8:
- /* 8-bit sRGB gray values with an alpha channel; the alpha channel is
- * to be removed by composing on a background: either the row if
- * display->background is NULL or display->background->green if not.
- * Unlike the code above ALPHA_OPTIMIZED has *not* been done.
- */
- {
- png_bytep first_row = png_voidcast(png_bytep, display->first_row);
- ptrdiff_t step_row = display->row_bytes;
-
- for (pass = 0; pass < passes; ++pass)
- {
- unsigned int startx, stepx, stepy;
- png_uint_32 y;
-
- if (png_ptr->interlaced == PNG_INTERLACE_ADAM7)
- {
- /* The row may be empty for a short image: */
- if (PNG_PASS_COLS(width, pass) == 0)
- continue;
-
- startx = PNG_PASS_START_COL(pass);
- stepx = PNG_PASS_COL_OFFSET(pass);
- y = PNG_PASS_START_ROW(pass);
- stepy = PNG_PASS_ROW_OFFSET(pass);
- }
-
- else
- {
- y = 0;
- startx = 0;
- stepx = stepy = 1;
- }
-
- if (display->background == NULL)
- {
- for (; y<height; y += stepy)
- {
- png_bytep inrow = png_voidcast(png_bytep,
- display->local_row);
- png_bytep outrow = first_row + y * step_row;
- png_const_bytep end_row = outrow + width;
-
- /* Read the row, which is packed: */
- png_read_row(png_ptr, inrow, NULL);
-
- /* Now do the composition on each pixel in this row. */
- outrow += startx;
- for (; outrow < end_row; outrow += stepx)
- {
- png_byte alpha = inrow[1];
-
- if (alpha > 0) /* else no change to the output */
- {
- png_uint_32 component = inrow[0];
-
- if (alpha < 255) /* else just use component */
- {
- /* Since PNG_OPTIMIZED_ALPHA was not set it is
- * necessary to invert the sRGB transfer
- * function and multiply the alpha out.
- */
- component = png_sRGB_table[component] * alpha;
- component += png_sRGB_table[outrow[0]] *
- (255-alpha);
- component = PNG_sRGB_FROM_LINEAR(component);
- }
-
- outrow[0] = (png_byte)component;
- }
-
- inrow += 2; /* gray and alpha channel */
- }
- }
- }
-
- else /* constant background value */
- {
- png_byte background8 = display->background->green;
- png_uint_16 background = png_sRGB_table[background8];
-
- for (; y<height; y += stepy)
- {
- png_bytep inrow = png_voidcast(png_bytep,
- display->local_row);
- png_bytep outrow = first_row + y * step_row;
- png_const_bytep end_row = outrow + width;
-
- /* Read the row, which is packed: */
- png_read_row(png_ptr, inrow, NULL);
-
- /* Now do the composition on each pixel in this row. */
- outrow += startx;
- for (; outrow < end_row; outrow += stepx)
- {
- png_byte alpha = inrow[1];
-
- if (alpha > 0) /* else use background */
- {
- png_uint_32 component = inrow[0];
-
- if (alpha < 255) /* else just use component */
- {
- component = png_sRGB_table[component] * alpha;
- component += background * (255-alpha);
- component = PNG_sRGB_FROM_LINEAR(component);
- }
-
- outrow[0] = (png_byte)component;
- }
-
- else
- outrow[0] = background8;
-
- inrow += 2; /* gray and alpha channel */
- }
- }
- }
- }
- }
- break;
-
- case 16:
- /* 16-bit linear with pre-multiplied alpha; the pre-multiplication must
- * still be done and, maybe, the alpha channel removed. This code also
- * handles the alpha-first option.
- */
- {
- png_uint_16p first_row = png_voidcast(png_uint_16p,
- display->first_row);
- /* The division by two is safe because the caller passed in a
- * stride which was multiplied by 2 (below) to get row_bytes.
- */
- ptrdiff_t step_row = display->row_bytes / 2;
- unsigned int preserve_alpha = (image->format &
- PNG_FORMAT_FLAG_ALPHA) != 0;
- unsigned int outchannels = 1U+preserve_alpha;
- int swap_alpha = 0;
-
-# ifdef PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED
- if (preserve_alpha != 0 &&
- (image->format & PNG_FORMAT_FLAG_AFIRST) != 0)
- swap_alpha = 1;
-# endif
-
- for (pass = 0; pass < passes; ++pass)
- {
- unsigned int startx, stepx, stepy;
- png_uint_32 y;
-
- /* The 'x' start and step are adjusted to output components here.
- */
- if (png_ptr->interlaced == PNG_INTERLACE_ADAM7)
- {
- /* The row may be empty for a short image: */
- if (PNG_PASS_COLS(width, pass) == 0)
- continue;
-
- startx = PNG_PASS_START_COL(pass) * outchannels;
- stepx = PNG_PASS_COL_OFFSET(pass) * outchannels;
- y = PNG_PASS_START_ROW(pass);
- stepy = PNG_PASS_ROW_OFFSET(pass);
- }
-
- else
- {
- y = 0;
- startx = 0;
- stepx = outchannels;
- stepy = 1;
- }
-
- for (; y<height; y += stepy)
- {
- png_const_uint_16p inrow;
- png_uint_16p outrow = first_row + y*step_row;
- png_uint_16p end_row = outrow + width * outchannels;
-
- /* Read the row, which is packed: */
- png_read_row(png_ptr, png_voidcast(png_bytep,
- display->local_row), NULL);
- inrow = png_voidcast(png_const_uint_16p, display->local_row);
-
- /* Now do the pre-multiplication on each pixel in this row.
- */
- outrow += startx;
- for (; outrow < end_row; outrow += stepx)
- {
- png_uint_32 component = inrow[0];
- png_uint_16 alpha = inrow[1];
-
- if (alpha > 0) /* else 0 */
- {
- if (alpha < 65535) /* else just use component */
- {
- component *= alpha;
- component += 32767;
- component /= 65535;
- }
- }
-
- else
- component = 0;
-
- outrow[swap_alpha] = (png_uint_16)component;
- if (preserve_alpha != 0)
- outrow[1 ^ swap_alpha] = alpha;
-
- inrow += 2; /* components and alpha channel */
- }
- }
- }
- }
- break;
-
-#ifdef __GNUC__
- default:
- png_error(png_ptr, "unexpected bit depth");
-#endif
- }
-
- return 1;
-}
-
-/* The guts of png_image_finish_read as a png_safe_execute callback. */
-static int
-png_image_read_direct(png_voidp argument)
-{
- png_image_read_control *display = png_voidcast(png_image_read_control*,
- argument);
- png_imagep image = display->image;
- png_structrp png_ptr = image->opaque->png_ptr;
- png_inforp info_ptr = image->opaque->info_ptr;
-
- png_uint_32 format = image->format;
- int linear = (format & PNG_FORMAT_FLAG_LINEAR) != 0;
- int do_local_compose = 0;
- int do_local_background = 0; /* to avoid double gamma correction bug */
- int passes = 0;
-
- /* Add transforms to ensure the correct output format is produced then check
- * that the required implementation support is there. Always expand; always
- * need 8 bits minimum, no palette and expanded tRNS.
- */
- png_set_expand(png_ptr);
-
- /* Now check the format to see if it was modified. */
- {
- png_uint_32 base_format = png_image_format(png_ptr) &
- ~PNG_FORMAT_FLAG_COLORMAP /* removed by png_set_expand */;
- png_uint_32 change = format ^ base_format;
- png_fixed_point output_gamma;
- int mode; /* alpha mode */
-
- /* Do this first so that we have a record if rgb to gray is happening. */
- if ((change & PNG_FORMAT_FLAG_COLOR) != 0)
- {
- /* gray<->color transformation required. */
- if ((format & PNG_FORMAT_FLAG_COLOR) != 0)
- png_set_gray_to_rgb(png_ptr);
-
- else
- {
- /* libpng can't do both rgb to gray and
- * background/pre-multiplication if there is also significant gamma
- * correction, because both operations require linear colors and
- * the code only supports one transform doing the gamma correction.
- * Handle this by doing the pre-multiplication or background
- * operation in this code, if necessary.
- *
- * TODO: fix this by rewriting pngrtran.c (!)
- *
- * For the moment (given that fixing this in pngrtran.c is an
- * enormous change) 'do_local_background' is used to indicate that
- * the problem exists.
- */
- if ((base_format & PNG_FORMAT_FLAG_ALPHA) != 0)
- do_local_background = 1/*maybe*/;
-
- png_set_rgb_to_gray_fixed(png_ptr, PNG_ERROR_ACTION_NONE,
- PNG_RGB_TO_GRAY_DEFAULT, PNG_RGB_TO_GRAY_DEFAULT);
- }
-
- change &= ~PNG_FORMAT_FLAG_COLOR;
- }
-
- /* Set the gamma appropriately, linear for 16-bit input, sRGB otherwise.
- */
- {
- png_fixed_point input_gamma_default;
-
- if ((base_format & PNG_FORMAT_FLAG_LINEAR) != 0 &&
- (image->flags & PNG_IMAGE_FLAG_16BIT_sRGB) == 0)
- input_gamma_default = PNG_GAMMA_LINEAR;
- else
- input_gamma_default = PNG_DEFAULT_sRGB;
-
- /* Call png_set_alpha_mode to set the default for the input gamma; the
- * output gamma is set by a second call below.
- */
- png_set_alpha_mode_fixed(png_ptr, PNG_ALPHA_PNG, input_gamma_default);
- }
-
- if (linear != 0)
- {
- /* If there *is* an alpha channel in the input it must be multiplied
- * out; use PNG_ALPHA_STANDARD, otherwise just use PNG_ALPHA_PNG.
- */
- if ((base_format & PNG_FORMAT_FLAG_ALPHA) != 0)
- mode = PNG_ALPHA_STANDARD; /* associated alpha */
-
- else
- mode = PNG_ALPHA_PNG;
-
- output_gamma = PNG_GAMMA_LINEAR;
- }
-
- else
- {
- mode = PNG_ALPHA_PNG;
- output_gamma = PNG_DEFAULT_sRGB;
- }
-
- if ((change & PNG_FORMAT_FLAG_ASSOCIATED_ALPHA) != 0)
- {
- mode = PNG_ALPHA_OPTIMIZED;
- change &= ~PNG_FORMAT_FLAG_ASSOCIATED_ALPHA;
- }
-
- /* If 'do_local_background' is set check for the presence of gamma
- * correction; this is part of the work-round for the libpng bug
- * described above.
- *
- * TODO: fix libpng and remove this.
- */
- if (do_local_background != 0)
- {
- png_fixed_point gtest;
-
- /* This is 'png_gamma_threshold' from pngrtran.c; the test used for
- * gamma correction, the screen gamma hasn't been set on png_struct
- * yet; it's set below. png_struct::gamma, however, is set to the
- * final value.
- */
- if (png_muldiv(&gtest, output_gamma, png_ptr->colorspace.gamma,
- PNG_FP_1) != 0 && png_gamma_significant(gtest) == 0)
- do_local_background = 0;
-
- else if (mode == PNG_ALPHA_STANDARD)
- {
- do_local_background = 2/*required*/;
- mode = PNG_ALPHA_PNG; /* prevent libpng doing it */
- }
-
- /* else leave as 1 for the checks below */
- }
-
- /* If the bit-depth changes then handle that here. */
- if ((change & PNG_FORMAT_FLAG_LINEAR) != 0)
- {
- if (linear != 0 /*16-bit output*/)
- png_set_expand_16(png_ptr);
-
- else /* 8-bit output */
- png_set_scale_16(png_ptr);
-
- change &= ~PNG_FORMAT_FLAG_LINEAR;
- }
-
- /* Now the background/alpha channel changes. */
- if ((change & PNG_FORMAT_FLAG_ALPHA) != 0)
- {
- /* Removing an alpha channel requires composition for the 8-bit
- * formats; for the 16-bit it is already done, above, by the
- * pre-multiplication and the channel just needs to be stripped.
- */
- if ((base_format & PNG_FORMAT_FLAG_ALPHA) != 0)
- {
- /* If RGB->gray is happening the alpha channel must be left and the
- * operation completed locally.
- *
- * TODO: fix libpng and remove this.
- */
- if (do_local_background != 0)
- do_local_background = 2/*required*/;
-
- /* 16-bit output: just remove the channel */
- else if (linear != 0) /* compose on black (well, pre-multiply) */
- png_set_strip_alpha(png_ptr);
-
- /* 8-bit output: do an appropriate compose */
- else if (display->background != NULL)
- {
- png_color_16 c;
-
- c.index = 0; /*unused*/
- c.red = display->background->red;
- c.green = display->background->green;
- c.blue = display->background->blue;
- c.gray = display->background->green;
-
- /* This is always an 8-bit sRGB value, using the 'green' channel
- * for gray is much better than calculating the luminance here;
- * we can get off-by-one errors in that calculation relative to
- * the app expectations and that will show up in transparent
- * pixels.
- */
- png_set_background_fixed(png_ptr, &c,
- PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/,
- 0/*gamma: not used*/);
- }
-
- else /* compose on row: implemented below. */
- {
- do_local_compose = 1;
- /* This leaves the alpha channel in the output, so it has to be
- * removed by the code below. Set the encoding to the 'OPTIMIZE'
- * one so the code only has to hack on the pixels that require
- * composition.
- */
- mode = PNG_ALPHA_OPTIMIZED;
- }
- }
-
- else /* output needs an alpha channel */
- {
- /* This is tricky because it happens before the swap operation has
- * been accomplished; however, the swap does *not* swap the added
- * alpha channel (weird API), so it must be added in the correct
- * place.
- */
- png_uint_32 filler; /* opaque filler */
- int where;
-
- if (linear != 0)
- filler = 65535;
-
- else
- filler = 255;
-
-#ifdef PNG_FORMAT_AFIRST_SUPPORTED
- if ((format & PNG_FORMAT_FLAG_AFIRST) != 0)
- {
- where = PNG_FILLER_BEFORE;
- change &= ~PNG_FORMAT_FLAG_AFIRST;
- }
-
- else
-#endif
- where = PNG_FILLER_AFTER;
-
- png_set_add_alpha(png_ptr, filler, where);
- }
-
- /* This stops the (irrelevant) call to swap_alpha below. */
- change &= ~PNG_FORMAT_FLAG_ALPHA;
- }
-
- /* Now set the alpha mode correctly; this is always done, even if there is
- * no alpha channel in either the input or the output because it correctly
- * sets the output gamma.
- */
- png_set_alpha_mode_fixed(png_ptr, mode, output_gamma);
-
-# ifdef PNG_FORMAT_BGR_SUPPORTED
- if ((change & PNG_FORMAT_FLAG_BGR) != 0)
- {
- /* Check only the output format; PNG is never BGR; don't do this if
- * the output is gray, but fix up the 'format' value in that case.
- */
- if ((format & PNG_FORMAT_FLAG_COLOR) != 0)
- png_set_bgr(png_ptr);
-
- else
- format &= ~PNG_FORMAT_FLAG_BGR;
-
- change &= ~PNG_FORMAT_FLAG_BGR;
- }
-# endif
-
-# ifdef PNG_FORMAT_AFIRST_SUPPORTED
- if ((change & PNG_FORMAT_FLAG_AFIRST) != 0)
- {
- /* Only relevant if there is an alpha channel - it's particularly
- * important to handle this correctly because do_local_compose may
- * be set above and then libpng will keep the alpha channel for this
- * code to remove.
- */
- if ((format & PNG_FORMAT_FLAG_ALPHA) != 0)
- {
- /* Disable this if doing a local background,
- * TODO: remove this when local background is no longer required.
- */
- if (do_local_background != 2)
- png_set_swap_alpha(png_ptr);
- }
-
- else
- format &= ~PNG_FORMAT_FLAG_AFIRST;
-
- change &= ~PNG_FORMAT_FLAG_AFIRST;
- }
-# endif
-
- /* If the *output* is 16-bit then we need to check for a byte-swap on this
- * architecture.
- */
- if (linear != 0)
- {
- png_uint_16 le = 0x0001;
-
- if ((*(png_const_bytep) & le) != 0)
- png_set_swap(png_ptr);
- }
-
- /* If change is not now 0 some transformation is missing - error out. */
- if (change != 0)
- png_error(png_ptr, "png_read_image: unsupported transformation");
- }
-
- PNG_SKIP_CHUNKS(png_ptr);
-
- /* Update the 'info' structure and make sure the result is as required; first
- * make sure to turn on the interlace handling if it will be required
- * (because it can't be turned on *after* the call to png_read_update_info!)
- *
- * TODO: remove the do_local_background fixup below.
- */
- if (do_local_compose == 0 && do_local_background != 2)
- passes = png_set_interlace_handling(png_ptr);
-
- png_read_update_info(png_ptr, info_ptr);
-
- {
- png_uint_32 info_format = 0;
-
- if ((info_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0)
- info_format |= PNG_FORMAT_FLAG_COLOR;
-
- if ((info_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0)
- {
- /* do_local_compose removes this channel below. */
- if (do_local_compose == 0)
- {
- /* do_local_background does the same if required. */
- if (do_local_background != 2 ||
- (format & PNG_FORMAT_FLAG_ALPHA) != 0)
- info_format |= PNG_FORMAT_FLAG_ALPHA;
- }
- }
-
- else if (do_local_compose != 0) /* internal error */
- png_error(png_ptr, "png_image_read: alpha channel lost");
-
- if ((format & PNG_FORMAT_FLAG_ASSOCIATED_ALPHA) != 0) {
- info_format |= PNG_FORMAT_FLAG_ASSOCIATED_ALPHA;
- }
-
- if (info_ptr->bit_depth == 16)
- info_format |= PNG_FORMAT_FLAG_LINEAR;
-
-#ifdef PNG_FORMAT_BGR_SUPPORTED
- if ((png_ptr->transformations & PNG_BGR) != 0)
- info_format |= PNG_FORMAT_FLAG_BGR;
-#endif
-
-#ifdef PNG_FORMAT_AFIRST_SUPPORTED
- if (do_local_background == 2)
- {
- if ((format & PNG_FORMAT_FLAG_AFIRST) != 0)
- info_format |= PNG_FORMAT_FLAG_AFIRST;
- }
-
- if ((png_ptr->transformations & PNG_SWAP_ALPHA) != 0 ||
- ((png_ptr->transformations & PNG_ADD_ALPHA) != 0 &&
- (png_ptr->flags & PNG_FLAG_FILLER_AFTER) == 0))
- {
- if (do_local_background == 2)
- png_error(png_ptr, "unexpected alpha swap transformation");
-
- info_format |= PNG_FORMAT_FLAG_AFIRST;
- }
-# endif
-
- /* This is actually an internal error. */
- if (info_format != format)
- png_error(png_ptr, "png_read_image: invalid transformations");
- }
-
- /* Now read the rows. If do_local_compose is set then it is necessary to use
- * a local row buffer. The output will be GA, RGBA or BGRA and must be
- * converted to G, RGB or BGR as appropriate. The 'local_row' member of the
- * display acts as a flag.
- */
- {
- png_voidp first_row = display->buffer;
- ptrdiff_t row_bytes = display->row_stride;
-
- if (linear != 0)
- row_bytes *= 2;
-
- /* The following expression is designed to work correctly whether it gives
- * a signed or an unsigned result.
- */
- if (row_bytes < 0)
- {
- char *ptr = png_voidcast(char*, first_row);
- ptr += (image->height-1) * (-row_bytes);
- first_row = png_voidcast(png_voidp, ptr);
- }
-
- display->first_row = first_row;
- display->row_bytes = row_bytes;
- }
-
- if (do_local_compose != 0)
- {
- int result;
- png_voidp row = png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr));
-
- display->local_row = row;
- result = png_safe_execute(image, png_image_read_composite, display);
- display->local_row = NULL;
- png_free(png_ptr, row);
-
- return result;
- }
-
- else if (do_local_background == 2)
- {
- int result;
- png_voidp row = png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr));
-
- display->local_row = row;
- result = png_safe_execute(image, png_image_read_background, display);
- display->local_row = NULL;
- png_free(png_ptr, row);
-
- return result;
- }
-
- else
- {
- png_alloc_size_t row_bytes = (png_alloc_size_t)display->row_bytes;
-
- while (--passes >= 0)
- {
- png_uint_32 y = image->height;
- png_bytep row = png_voidcast(png_bytep, display->first_row);
-
- for (; y > 0; --y)
- {
- png_read_row(png_ptr, row, NULL);
- row += row_bytes;
- }
- }
-
- return 1;
- }
-}
-
-int PNGAPI
-png_image_finish_read(png_imagep image, png_const_colorp background,
- void *buffer, png_int_32 row_stride, void *colormap)
-{
- if (image != NULL && image->version == PNG_IMAGE_VERSION)
- {
- /* Check for row_stride overflow. This check is not performed on the
- * original PNG format because it may not occur in the output PNG format
- * and libpng deals with the issues of reading the original.
- */
- unsigned int channels = PNG_IMAGE_PIXEL_CHANNELS(image->format);
-
- /* The following checks just the 'row_stride' calculation to ensure it
- * fits in a signed 32-bit value. Because channels/components can be
- * either 1 or 2 bytes in size the length of a row can still overflow 32
- * bits; this is just to verify that the 'row_stride' argument can be
- * represented.
- */
- if (image->width <= 0x7fffffffU/channels) /* no overflow */
- {
- png_uint_32 check;
- png_uint_32 png_row_stride = image->width * channels;
-
- if (row_stride == 0)
- row_stride = (png_int_32)/*SAFE*/png_row_stride;
-
- if (row_stride < 0)
- check = (png_uint_32)(-row_stride);
-
- else
- check = (png_uint_32)row_stride;
-
- /* This verifies 'check', the absolute value of the actual stride
- * passed in and detects overflow in the application calculation (i.e.
- * if the app did actually pass in a non-zero 'row_stride'.
- */
- if (image->opaque != NULL && buffer != NULL && check >= png_row_stride)
- {
- /* Now check for overflow of the image buffer calculation; this
- * limits the whole image size to 32 bits for API compatibility with
- * the current, 32-bit, PNG_IMAGE_BUFFER_SIZE macro.
- *
- * The PNG_IMAGE_BUFFER_SIZE macro is:
- *
- * (PNG_IMAGE_PIXEL_COMPONENT_SIZE(fmt)*height*(row_stride))
- *
- * And the component size is always 1 or 2, so make sure that the
- * number of *bytes* that the application is saying are available
- * does actually fit into a 32-bit number.
- *
- * NOTE: this will be changed in 1.7 because PNG_IMAGE_BUFFER_SIZE
- * will be changed to use png_alloc_size_t; bigger images can be
- * accommodated on 64-bit systems.
- */
- if (image->height <=
- 0xffffffffU/PNG_IMAGE_PIXEL_COMPONENT_SIZE(image->format)/check)
- {
- if ((image->format & PNG_FORMAT_FLAG_COLORMAP) == 0 ||
- (image->colormap_entries > 0 && colormap != NULL))
- {
- int result;
- png_image_read_control display;
-
- memset(&display, 0, (sizeof display));
- display.image = image;
- display.buffer = buffer;
- display.row_stride = row_stride;
- display.colormap = colormap;
- display.background = background;
- display.local_row = NULL;
-
- /* Choose the correct 'end' routine; for the color-map case
- * all the setup has already been done.
- */
- if ((image->format & PNG_FORMAT_FLAG_COLORMAP) != 0)
- result =
- png_safe_execute(image,
- png_image_read_colormap, &display) &&
- png_safe_execute(image,
- png_image_read_colormapped, &display);
-
- else
- result =
- png_safe_execute(image,
- png_image_read_direct, &display);
-
- png_image_free(image);
- return result;
- }
-
- else
- return png_image_error(image,
- "png_image_finish_read[color-map]: no color-map");
- }
-
- else
- return png_image_error(image,
- "png_image_finish_read: image too large");
- }
-
- else
- return png_image_error(image,
- "png_image_finish_read: invalid argument");
- }
-
- else
- return png_image_error(image,
- "png_image_finish_read: row_stride too large");
- }
-
- else if (image != NULL)
- return png_image_error(image,
- "png_image_finish_read: damaged PNG_IMAGE_VERSION");
-
- return 0;
-}
-
-#endif /* SIMPLIFIED_READ */
-#endif /* READ */
diff --git a/contrib/libs/libpng/pngrio.c b/contrib/libs/libpng/pngrio.c
deleted file mode 100644
index 3b137f275f..0000000000
--- a/contrib/libs/libpng/pngrio.c
+++ /dev/null
@@ -1,119 +0,0 @@
-/* pngrio.c - functions for data input
- *
- * Copyright (c) 2018 Cosmin Truta
- * Copyright (c) 1998-2002,2004,2006-2016,2018 Glenn Randers-Pehrson
- * Copyright (c) 1996-1997 Andreas Dilger
- * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
- *
- * This code is released under the libpng license.
- * For conditions of distribution and use, see the disclaimer
- * and license in png.h
- *
- * This file provides a location for all input. Users who need
- * special handling are expected to write a function that has the same
- * arguments as this and performs a similar function, but that possibly
- * has a different input method. Note that you shouldn't change this
- * function, but rather write a replacement function and then make
- * libpng use it at run time with png_set_read_fn(...).
- */
-
-#include "pngpriv.h"
-
-#ifdef PNG_READ_SUPPORTED
-
-/* Read the data from whatever input you are using. The default routine
- * reads from a file pointer. Note that this routine sometimes gets called
- * with very small lengths, so you should implement some kind of simple
- * buffering if you are using unbuffered reads. This should never be asked
- * to read more than 64K on a 16-bit machine.
- */
-void /* PRIVATE */
-png_read_data(png_structrp png_ptr, png_bytep data, size_t length)
-{
- png_debug1(4, "reading %d bytes", (int)length);
-
- if (png_ptr->read_data_fn != NULL)
- (*(png_ptr->read_data_fn))(png_ptr, data, length);
-
- else
- png_error(png_ptr, "Call to NULL read function");
-}
-
-#ifdef PNG_STDIO_SUPPORTED
-/* This is the function that does the actual reading of data. If you are
- * not reading from a standard C stream, you should create a replacement
- * read_data function and use it at run time with png_set_read_fn(), rather
- * than changing the library.
- */
-void PNGCBAPI
-png_default_read_data(png_structp png_ptr, png_bytep data, size_t length)
-{
- size_t check;
-
- if (png_ptr == NULL)
- return;
-
- /* fread() returns 0 on error, so it is OK to store this in a size_t
- * instead of an int, which is what fread() actually returns.
- */
- check = fread(data, 1, length, png_voidcast(png_FILE_p, png_ptr->io_ptr));
-
- if (check != length)
- png_error(png_ptr, "Read Error");
-}
-#endif
-
-/* This function allows the application to supply a new input function
- * for libpng if standard C streams aren't being used.
- *
- * This function takes as its arguments:
- *
- * png_ptr - pointer to a png input data structure
- *
- * io_ptr - pointer to user supplied structure containing info about
- * the input functions. May be NULL.
- *
- * read_data_fn - pointer to a new input function that takes as its
- * arguments a pointer to a png_struct, a pointer to
- * a location where input data can be stored, and a 32-bit
- * unsigned int that is the number of bytes to be read.
- * To exit and output any fatal error messages the new write
- * function should call png_error(png_ptr, "Error msg").
- * May be NULL, in which case libpng's default function will
- * be used.
- */
-void PNGAPI
-png_set_read_fn(png_structrp png_ptr, png_voidp io_ptr,
- png_rw_ptr read_data_fn)
-{
- if (png_ptr == NULL)
- return;
-
- png_ptr->io_ptr = io_ptr;
-
-#ifdef PNG_STDIO_SUPPORTED
- if (read_data_fn != NULL)
- png_ptr->read_data_fn = read_data_fn;
-
- else
- png_ptr->read_data_fn = png_default_read_data;
-#else
- png_ptr->read_data_fn = read_data_fn;
-#endif
-
-#ifdef PNG_WRITE_SUPPORTED
- /* It is an error to write to a read device */
- if (png_ptr->write_data_fn != NULL)
- {
- png_ptr->write_data_fn = NULL;
- png_warning(png_ptr,
- "Can't set both read_data_fn and write_data_fn in the"
- " same structure");
- }
-#endif
-
-#ifdef PNG_WRITE_FLUSH_SUPPORTED
- png_ptr->output_flush_fn = NULL;
-#endif
-}
-#endif /* READ */
diff --git a/contrib/libs/libpng/pngrtran.c b/contrib/libs/libpng/pngrtran.c
deleted file mode 100644
index 124906635b..0000000000
--- a/contrib/libs/libpng/pngrtran.c
+++ /dev/null
@@ -1,5039 +0,0 @@
-/* pngrtran.c - transforms the data in a row for PNG readers
- *
- * Copyright (c) 2018-2024 Cosmin Truta
- * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
- * Copyright (c) 1996-1997 Andreas Dilger
- * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
- *
- * This code is released under the libpng license.
- * For conditions of distribution and use, see the disclaimer
- * and license in png.h
- *
- * This file contains functions optionally called by an application
- * in order to tell libpng how to handle data when reading a PNG.
- * Transformations that are used in both reading and writing are
- * in pngtrans.c.
- */
-
-#include "pngpriv.h"
-
-#ifdef PNG_ARM_NEON_IMPLEMENTATION
-# if PNG_ARM_NEON_IMPLEMENTATION == 1
-# define PNG_ARM_NEON_INTRINSICS_AVAILABLE
-# if defined(_MSC_VER) && !defined(__clang__) && defined(_M_ARM64)
-# include <arm64_neon.h>
-# else
-# include <arm_neon.h>
-# endif
-# endif
-#endif
-
-#ifdef PNG_READ_SUPPORTED
-
-/* Set the action on getting a CRC error for an ancillary or critical chunk. */
-void PNGAPI
-png_set_crc_action(png_structrp png_ptr, int crit_action, int ancil_action)
-{
- png_debug(1, "in png_set_crc_action");
-
- if (png_ptr == NULL)
- return;
-
- /* Tell libpng how we react to CRC errors in critical chunks */
- switch (crit_action)
- {
- case PNG_CRC_NO_CHANGE: /* Leave setting as is */
- break;
-
- case PNG_CRC_WARN_USE: /* Warn/use data */
- png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK;
- png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE;
- break;
-
- case PNG_CRC_QUIET_USE: /* Quiet/use data */
- png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK;
- png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE |
- PNG_FLAG_CRC_CRITICAL_IGNORE;
- break;
-
- case PNG_CRC_WARN_DISCARD: /* Not a valid action for critical data */
- png_warning(png_ptr,
- "Can't discard critical data on CRC error");
- /* FALLTHROUGH */
- case PNG_CRC_ERROR_QUIT: /* Error/quit */
-
- case PNG_CRC_DEFAULT:
- default:
- png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK;
- break;
- }
-
- /* Tell libpng how we react to CRC errors in ancillary chunks */
- switch (ancil_action)
- {
- case PNG_CRC_NO_CHANGE: /* Leave setting as is */
- break;
-
- case PNG_CRC_WARN_USE: /* Warn/use data */
- png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK;
- png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE;
- break;
-
- case PNG_CRC_QUIET_USE: /* Quiet/use data */
- png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK;
- png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE |
- PNG_FLAG_CRC_ANCILLARY_NOWARN;
- break;
-
- case PNG_CRC_ERROR_QUIT: /* Error/quit */
- png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK;
- png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_NOWARN;
- break;
-
- case PNG_CRC_WARN_DISCARD: /* Warn/discard data */
-
- case PNG_CRC_DEFAULT:
- default:
- png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK;
- break;
- }
-}
-
-#ifdef PNG_READ_TRANSFORMS_SUPPORTED
-/* Is it OK to set a transformation now? Only if png_start_read_image or
- * png_read_update_info have not been called. It is not necessary for the IHDR
- * to have been read in all cases; the need_IHDR parameter allows for this
- * check too.
- */
-static int
-png_rtran_ok(png_structrp png_ptr, int need_IHDR)
-{
- if (png_ptr != NULL)
- {
- if ((png_ptr->flags & PNG_FLAG_ROW_INIT) != 0)
- png_app_error(png_ptr,
- "invalid after png_start_read_image or png_read_update_info");
-
- else if (need_IHDR && (png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_app_error(png_ptr, "invalid before the PNG header has been read");
-
- else
- {
- /* Turn on failure to initialize correctly for all transforms. */
- png_ptr->flags |= PNG_FLAG_DETECT_UNINITIALIZED;
-
- return 1; /* Ok */
- }
- }
-
- return 0; /* no png_error possible! */
-}
-#endif
-
-#ifdef PNG_READ_BACKGROUND_SUPPORTED
-/* Handle alpha and tRNS via a background color */
-void PNGFAPI
-png_set_background_fixed(png_structrp png_ptr,
- png_const_color_16p background_color, int background_gamma_code,
- int need_expand, png_fixed_point background_gamma)
-{
- png_debug(1, "in png_set_background_fixed");
-
- if (png_rtran_ok(png_ptr, 0) == 0 || background_color == NULL)
- return;
-
- if (background_gamma_code == PNG_BACKGROUND_GAMMA_UNKNOWN)
- {
- png_warning(png_ptr, "Application must supply a known background gamma");
- return;
- }
-
- png_ptr->transformations |= PNG_COMPOSE | PNG_STRIP_ALPHA;
- png_ptr->transformations &= ~PNG_ENCODE_ALPHA;
- png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;
-
- png_ptr->background = *background_color;
- png_ptr->background_gamma = background_gamma;
- png_ptr->background_gamma_type = (png_byte)(background_gamma_code);
- if (need_expand != 0)
- png_ptr->transformations |= PNG_BACKGROUND_EXPAND;
- else
- png_ptr->transformations &= ~PNG_BACKGROUND_EXPAND;
-}
-
-# ifdef PNG_FLOATING_POINT_SUPPORTED
-void PNGAPI
-png_set_background(png_structrp png_ptr,
- png_const_color_16p background_color, int background_gamma_code,
- int need_expand, double background_gamma)
-{
- png_set_background_fixed(png_ptr, background_color, background_gamma_code,
- need_expand, png_fixed(png_ptr, background_gamma, "png_set_background"));
-}
-# endif /* FLOATING_POINT */
-#endif /* READ_BACKGROUND */
-
-/* Scale 16-bit depth files to 8-bit depth. If both of these are set then the
- * one that pngrtran does first (scale) happens. This is necessary to allow the
- * TRANSFORM and API behavior to be somewhat consistent, and it's simpler.
- */
-#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
-void PNGAPI
-png_set_scale_16(png_structrp png_ptr)
-{
- png_debug(1, "in png_set_scale_16");
-
- if (png_rtran_ok(png_ptr, 0) == 0)
- return;
-
- png_ptr->transformations |= PNG_SCALE_16_TO_8;
-}
-#endif
-
-#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
-/* Chop 16-bit depth files to 8-bit depth */
-void PNGAPI
-png_set_strip_16(png_structrp png_ptr)
-{
- png_debug(1, "in png_set_strip_16");
-
- if (png_rtran_ok(png_ptr, 0) == 0)
- return;
-
- png_ptr->transformations |= PNG_16_TO_8;
-}
-#endif
-
-#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
-void PNGAPI
-png_set_strip_alpha(png_structrp png_ptr)
-{
- png_debug(1, "in png_set_strip_alpha");
-
- if (png_rtran_ok(png_ptr, 0) == 0)
- return;
-
- png_ptr->transformations |= PNG_STRIP_ALPHA;
-}
-#endif
-
-#if defined(PNG_READ_ALPHA_MODE_SUPPORTED) || defined(PNG_READ_GAMMA_SUPPORTED)
-static png_fixed_point
-translate_gamma_flags(png_structrp png_ptr, png_fixed_point output_gamma,
- int is_screen)
-{
- /* Check for flag values. The main reason for having the old Mac value as a
- * flag is that it is pretty near impossible to work out what the correct
- * value is from Apple documentation - a working Mac system is needed to
- * discover the value!
- */
- if (output_gamma == PNG_DEFAULT_sRGB ||
- output_gamma == PNG_FP_1 / PNG_DEFAULT_sRGB)
- {
- /* If there is no sRGB support this just sets the gamma to the standard
- * sRGB value. (This is a side effect of using this function!)
- */
-# ifdef PNG_READ_sRGB_SUPPORTED
- png_ptr->flags |= PNG_FLAG_ASSUME_sRGB;
-# else
- PNG_UNUSED(png_ptr)
-# endif
- if (is_screen != 0)
- output_gamma = PNG_GAMMA_sRGB;
- else
- output_gamma = PNG_GAMMA_sRGB_INVERSE;
- }
-
- else if (output_gamma == PNG_GAMMA_MAC_18 ||
- output_gamma == PNG_FP_1 / PNG_GAMMA_MAC_18)
- {
- if (is_screen != 0)
- output_gamma = PNG_GAMMA_MAC_OLD;
- else
- output_gamma = PNG_GAMMA_MAC_INVERSE;
- }
-
- return output_gamma;
-}
-
-# ifdef PNG_FLOATING_POINT_SUPPORTED
-static png_fixed_point
-convert_gamma_value(png_structrp png_ptr, double output_gamma)
-{
- /* The following silently ignores cases where fixed point (times 100,000)
- * gamma values are passed to the floating point API. This is safe and it
- * means the fixed point constants work just fine with the floating point
- * API. The alternative would just lead to undetected errors and spurious
- * bug reports. Negative values fail inside the _fixed API unless they
- * correspond to the flag values.
- */
- if (output_gamma > 0 && output_gamma < 128)
- output_gamma *= PNG_FP_1;
-
- /* This preserves -1 and -2 exactly: */
- output_gamma = floor(output_gamma + .5);
-
- if (output_gamma > PNG_FP_MAX || output_gamma < PNG_FP_MIN)
- png_fixed_error(png_ptr, "gamma value");
-
- return (png_fixed_point)output_gamma;
-}
-# endif
-#endif /* READ_ALPHA_MODE || READ_GAMMA */
-
-#ifdef PNG_READ_ALPHA_MODE_SUPPORTED
-void PNGFAPI
-png_set_alpha_mode_fixed(png_structrp png_ptr, int mode,
- png_fixed_point output_gamma)
-{
- int compose = 0;
- png_fixed_point file_gamma;
-
- png_debug(1, "in png_set_alpha_mode_fixed");
-
- if (png_rtran_ok(png_ptr, 0) == 0)
- return;
-
- output_gamma = translate_gamma_flags(png_ptr, output_gamma, 1/*screen*/);
-
- /* Validate the value to ensure it is in a reasonable range. The value
- * is expected to be 1 or greater, but this range test allows for some
- * viewing correction values. The intent is to weed out the API users
- * who might use the inverse of the gamma value accidentally!
- *
- * In libpng 1.6.0, we changed from 0.07..3 to 0.01..100, to accommodate
- * the optimal 16-bit gamma of 36 and its reciprocal.
- */
- if (output_gamma < 1000 || output_gamma > 10000000)
- png_error(png_ptr, "output gamma out of expected range");
-
- /* The default file gamma is the inverse of the output gamma; the output
- * gamma may be changed below so get the file value first:
- */
- file_gamma = png_reciprocal(output_gamma);
-
- /* There are really 8 possibilities here, composed of any combination
- * of:
- *
- * premultiply the color channels
- * do not encode non-opaque pixels
- * encode the alpha as well as the color channels
- *
- * The differences disappear if the input/output ('screen') gamma is 1.0,
- * because then the encoding is a no-op and there is only the choice of
- * premultiplying the color channels or not.
- *
- * png_set_alpha_mode and png_set_background interact because both use
- * png_compose to do the work. Calling both is only useful when
- * png_set_alpha_mode is used to set the default mode - PNG_ALPHA_PNG - along
- * with a default gamma value. Otherwise PNG_COMPOSE must not be set.
- */
- switch (mode)
- {
- case PNG_ALPHA_PNG: /* default: png standard */
- /* No compose, but it may be set by png_set_background! */
- png_ptr->transformations &= ~PNG_ENCODE_ALPHA;
- png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;
- break;
-
- case PNG_ALPHA_ASSOCIATED: /* color channels premultiplied */
- compose = 1;
- png_ptr->transformations &= ~PNG_ENCODE_ALPHA;
- png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;
- /* The output is linear: */
- output_gamma = PNG_FP_1;
- break;
-
- case PNG_ALPHA_OPTIMIZED: /* associated, non-opaque pixels linear */
- compose = 1;
- png_ptr->transformations &= ~PNG_ENCODE_ALPHA;
- png_ptr->flags |= PNG_FLAG_OPTIMIZE_ALPHA;
- /* output_gamma records the encoding of opaque pixels! */
- break;
-
- case PNG_ALPHA_BROKEN: /* associated, non-linear, alpha encoded */
- compose = 1;
- png_ptr->transformations |= PNG_ENCODE_ALPHA;
- png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;
- break;
-
- default:
- png_error(png_ptr, "invalid alpha mode");
- }
-
- /* Only set the default gamma if the file gamma has not been set (this has
- * the side effect that the gamma in a second call to png_set_alpha_mode will
- * be ignored.)
- */
- if (png_ptr->colorspace.gamma == 0)
- {
- png_ptr->colorspace.gamma = file_gamma;
- png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA;
- }
-
- /* But always set the output gamma: */
- png_ptr->screen_gamma = output_gamma;
-
- /* Finally, if pre-multiplying, set the background fields to achieve the
- * desired result.
- */
- if (compose != 0)
- {
- /* And obtain alpha pre-multiplication by composing on black: */
- memset(&png_ptr->background, 0, (sizeof png_ptr->background));
- png_ptr->background_gamma = png_ptr->colorspace.gamma; /* just in case */
- png_ptr->background_gamma_type = PNG_BACKGROUND_GAMMA_FILE;
- png_ptr->transformations &= ~PNG_BACKGROUND_EXPAND;
-
- if ((png_ptr->transformations & PNG_COMPOSE) != 0)
- png_error(png_ptr,
- "conflicting calls to set alpha mode and background");
-
- png_ptr->transformations |= PNG_COMPOSE;
- }
-}
-
-# ifdef PNG_FLOATING_POINT_SUPPORTED
-void PNGAPI
-png_set_alpha_mode(png_structrp png_ptr, int mode, double output_gamma)
-{
- png_set_alpha_mode_fixed(png_ptr, mode, convert_gamma_value(png_ptr,
- output_gamma));
-}
-# endif
-#endif
-
-#ifdef PNG_READ_QUANTIZE_SUPPORTED
-/* Dither file to 8-bit. Supply a palette, the current number
- * of elements in the palette, the maximum number of elements
- * allowed, and a histogram if possible. If the current number
- * of colors is greater than the maximum number, the palette will be
- * modified to fit in the maximum number. "full_quantize" indicates
- * whether we need a quantizing cube set up for RGB images, or if we
- * simply are reducing the number of colors in a paletted image.
- */
-
-typedef struct png_dsort_struct
-{
- struct png_dsort_struct * next;
- png_byte left;
- png_byte right;
-} png_dsort;
-typedef png_dsort * png_dsortp;
-typedef png_dsort * * png_dsortpp;
-
-void PNGAPI
-png_set_quantize(png_structrp png_ptr, png_colorp palette,
- int num_palette, int maximum_colors, png_const_uint_16p histogram,
- int full_quantize)
-{
- png_debug(1, "in png_set_quantize");
-
- if (png_rtran_ok(png_ptr, 0) == 0)
- return;
-
- png_ptr->transformations |= PNG_QUANTIZE;
-
- if (full_quantize == 0)
- {
- int i;
-
- png_ptr->quantize_index = (png_bytep)png_malloc(png_ptr,
- (png_alloc_size_t)num_palette);
- for (i = 0; i < num_palette; i++)
- png_ptr->quantize_index[i] = (png_byte)i;
- }
-
- if (num_palette > maximum_colors)
- {
- if (histogram != NULL)
- {
- /* This is easy enough, just throw out the least used colors.
- * Perhaps not the best solution, but good enough.
- */
-
- int i;
-
- /* Initialize an array to sort colors */
- png_ptr->quantize_sort = (png_bytep)png_malloc(png_ptr,
- (png_alloc_size_t)num_palette);
-
- /* Initialize the quantize_sort array */
- for (i = 0; i < num_palette; i++)
- png_ptr->quantize_sort[i] = (png_byte)i;
-
- /* Find the least used palette entries by starting a
- * bubble sort, and running it until we have sorted
- * out enough colors. Note that we don't care about
- * sorting all the colors, just finding which are
- * least used.
- */
-
- for (i = num_palette - 1; i >= maximum_colors; i--)
- {
- int done; /* To stop early if the list is pre-sorted */
- int j;
-
- done = 1;
- for (j = 0; j < i; j++)
- {
- if (histogram[png_ptr->quantize_sort[j]]
- < histogram[png_ptr->quantize_sort[j + 1]])
- {
- png_byte t;
-
- t = png_ptr->quantize_sort[j];
- png_ptr->quantize_sort[j] = png_ptr->quantize_sort[j + 1];
- png_ptr->quantize_sort[j + 1] = t;
- done = 0;
- }
- }
-
- if (done != 0)
- break;
- }
-
- /* Swap the palette around, and set up a table, if necessary */
- if (full_quantize != 0)
- {
- int j = num_palette;
-
- /* Put all the useful colors within the max, but don't
- * move the others.
- */
- for (i = 0; i < maximum_colors; i++)
- {
- if ((int)png_ptr->quantize_sort[i] >= maximum_colors)
- {
- do
- j--;
- while ((int)png_ptr->quantize_sort[j] >= maximum_colors);
-
- palette[i] = palette[j];
- }
- }
- }
- else
- {
- int j = num_palette;
-
- /* Move all the used colors inside the max limit, and
- * develop a translation table.
- */
- for (i = 0; i < maximum_colors; i++)
- {
- /* Only move the colors we need to */
- if ((int)png_ptr->quantize_sort[i] >= maximum_colors)
- {
- png_color tmp_color;
-
- do
- j--;
- while ((int)png_ptr->quantize_sort[j] >= maximum_colors);
-
- tmp_color = palette[j];
- palette[j] = palette[i];
- palette[i] = tmp_color;
- /* Indicate where the color went */
- png_ptr->quantize_index[j] = (png_byte)i;
- png_ptr->quantize_index[i] = (png_byte)j;
- }
- }
-
- /* Find closest color for those colors we are not using */
- for (i = 0; i < num_palette; i++)
- {
- if ((int)png_ptr->quantize_index[i] >= maximum_colors)
- {
- int min_d, k, min_k, d_index;
-
- /* Find the closest color to one we threw out */
- d_index = png_ptr->quantize_index[i];
- min_d = PNG_COLOR_DIST(palette[d_index], palette[0]);
- for (k = 1, min_k = 0; k < maximum_colors; k++)
- {
- int d;
-
- d = PNG_COLOR_DIST(palette[d_index], palette[k]);
-
- if (d < min_d)
- {
- min_d = d;
- min_k = k;
- }
- }
- /* Point to closest color */
- png_ptr->quantize_index[i] = (png_byte)min_k;
- }
- }
- }
- png_free(png_ptr, png_ptr->quantize_sort);
- png_ptr->quantize_sort = NULL;
- }
- else
- {
- /* This is much harder to do simply (and quickly). Perhaps
- * we need to go through a median cut routine, but those
- * don't always behave themselves with only a few colors
- * as input. So we will just find the closest two colors,
- * and throw out one of them (chosen somewhat randomly).
- * [We don't understand this at all, so if someone wants to
- * work on improving it, be our guest - AED, GRP]
- */
- int i;
- int max_d;
- int num_new_palette;
- png_dsortp t;
- png_dsortpp hash;
-
- t = NULL;
-
- /* Initialize palette index arrays */
- png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr,
- (png_alloc_size_t)num_palette);
- png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr,
- (png_alloc_size_t)num_palette);
-
- /* Initialize the sort array */
- for (i = 0; i < num_palette; i++)
- {
- png_ptr->index_to_palette[i] = (png_byte)i;
- png_ptr->palette_to_index[i] = (png_byte)i;
- }
-
- hash = (png_dsortpp)png_calloc(png_ptr, (png_alloc_size_t)(769 *
- (sizeof (png_dsortp))));
-
- num_new_palette = num_palette;
-
- /* Initial wild guess at how far apart the farthest pixel
- * pair we will be eliminating will be. Larger
- * numbers mean more areas will be allocated, Smaller
- * numbers run the risk of not saving enough data, and
- * having to do this all over again.
- *
- * I have not done extensive checking on this number.
- */
- max_d = 96;
-
- while (num_new_palette > maximum_colors)
- {
- for (i = 0; i < num_new_palette - 1; i++)
- {
- int j;
-
- for (j = i + 1; j < num_new_palette; j++)
- {
- int d;
-
- d = PNG_COLOR_DIST(palette[i], palette[j]);
-
- if (d <= max_d)
- {
-
- t = (png_dsortp)png_malloc_warn(png_ptr,
- (png_alloc_size_t)(sizeof (png_dsort)));
-
- if (t == NULL)
- break;
-
- t->next = hash[d];
- t->left = (png_byte)i;
- t->right = (png_byte)j;
- hash[d] = t;
- }
- }
- if (t == NULL)
- break;
- }
-
- if (t != NULL)
- for (i = 0; i <= max_d; i++)
- {
- if (hash[i] != NULL)
- {
- png_dsortp p;
-
- for (p = hash[i]; p; p = p->next)
- {
- if ((int)png_ptr->index_to_palette[p->left]
- < num_new_palette &&
- (int)png_ptr->index_to_palette[p->right]
- < num_new_palette)
- {
- int j, next_j;
-
- if (num_new_palette & 0x01)
- {
- j = p->left;
- next_j = p->right;
- }
- else
- {
- j = p->right;
- next_j = p->left;
- }
-
- num_new_palette--;
- palette[png_ptr->index_to_palette[j]]
- = palette[num_new_palette];
- if (full_quantize == 0)
- {
- int k;
-
- for (k = 0; k < num_palette; k++)
- {
- if (png_ptr->quantize_index[k] ==
- png_ptr->index_to_palette[j])
- png_ptr->quantize_index[k] =
- png_ptr->index_to_palette[next_j];
-
- if ((int)png_ptr->quantize_index[k] ==
- num_new_palette)
- png_ptr->quantize_index[k] =
- png_ptr->index_to_palette[j];
- }
- }
-
- png_ptr->index_to_palette[png_ptr->palette_to_index
- [num_new_palette]] = png_ptr->index_to_palette[j];
-
- png_ptr->palette_to_index[png_ptr->index_to_palette[j]]
- = png_ptr->palette_to_index[num_new_palette];
-
- png_ptr->index_to_palette[j] =
- (png_byte)num_new_palette;
-
- png_ptr->palette_to_index[num_new_palette] =
- (png_byte)j;
- }
- if (num_new_palette <= maximum_colors)
- break;
- }
- if (num_new_palette <= maximum_colors)
- break;
- }
- }
-
- for (i = 0; i < 769; i++)
- {
- if (hash[i] != NULL)
- {
- png_dsortp p = hash[i];
- while (p)
- {
- t = p->next;
- png_free(png_ptr, p);
- p = t;
- }
- }
- hash[i] = 0;
- }
- max_d += 96;
- }
- png_free(png_ptr, hash);
- png_free(png_ptr, png_ptr->palette_to_index);
- png_free(png_ptr, png_ptr->index_to_palette);
- png_ptr->palette_to_index = NULL;
- png_ptr->index_to_palette = NULL;
- }
- num_palette = maximum_colors;
- }
- if (png_ptr->palette == NULL)
- {
- png_ptr->palette = palette;
- }
- png_ptr->num_palette = (png_uint_16)num_palette;
-
- if (full_quantize != 0)
- {
- int i;
- png_bytep distance;
- int total_bits = PNG_QUANTIZE_RED_BITS + PNG_QUANTIZE_GREEN_BITS +
- PNG_QUANTIZE_BLUE_BITS;
- int num_red = (1 << PNG_QUANTIZE_RED_BITS);
- int num_green = (1 << PNG_QUANTIZE_GREEN_BITS);
- int num_blue = (1 << PNG_QUANTIZE_BLUE_BITS);
- size_t num_entries = ((size_t)1 << total_bits);
-
- png_ptr->palette_lookup = (png_bytep)png_calloc(png_ptr,
- (png_alloc_size_t)(num_entries));
-
- distance = (png_bytep)png_malloc(png_ptr, (png_alloc_size_t)num_entries);
-
- memset(distance, 0xff, num_entries);
-
- for (i = 0; i < num_palette; i++)
- {
- int ir, ig, ib;
- int r = (palette[i].red >> (8 - PNG_QUANTIZE_RED_BITS));
- int g = (palette[i].green >> (8 - PNG_QUANTIZE_GREEN_BITS));
- int b = (palette[i].blue >> (8 - PNG_QUANTIZE_BLUE_BITS));
-
- for (ir = 0; ir < num_red; ir++)
- {
- /* int dr = abs(ir - r); */
- int dr = ((ir > r) ? ir - r : r - ir);
- int index_r = (ir << (PNG_QUANTIZE_BLUE_BITS +
- PNG_QUANTIZE_GREEN_BITS));
-
- for (ig = 0; ig < num_green; ig++)
- {
- /* int dg = abs(ig - g); */
- int dg = ((ig > g) ? ig - g : g - ig);
- int dt = dr + dg;
- int dm = ((dr > dg) ? dr : dg);
- int index_g = index_r | (ig << PNG_QUANTIZE_BLUE_BITS);
-
- for (ib = 0; ib < num_blue; ib++)
- {
- int d_index = index_g | ib;
- /* int db = abs(ib - b); */
- int db = ((ib > b) ? ib - b : b - ib);
- int dmax = ((dm > db) ? dm : db);
- int d = dmax + dt + db;
-
- if (d < (int)distance[d_index])
- {
- distance[d_index] = (png_byte)d;
- png_ptr->palette_lookup[d_index] = (png_byte)i;
- }
- }
- }
- }
- }
-
- png_free(png_ptr, distance);
- }
-}
-#endif /* READ_QUANTIZE */
-
-#ifdef PNG_READ_GAMMA_SUPPORTED
-void PNGFAPI
-png_set_gamma_fixed(png_structrp png_ptr, png_fixed_point scrn_gamma,
- png_fixed_point file_gamma)
-{
- png_debug(1, "in png_set_gamma_fixed");
-
- if (png_rtran_ok(png_ptr, 0) == 0)
- return;
-
- /* New in libpng-1.5.4 - reserve particular negative values as flags. */
- scrn_gamma = translate_gamma_flags(png_ptr, scrn_gamma, 1/*screen*/);
- file_gamma = translate_gamma_flags(png_ptr, file_gamma, 0/*file*/);
-
- /* Checking the gamma values for being >0 was added in 1.5.4 along with the
- * premultiplied alpha support; this actually hides an undocumented feature
- * of the previous implementation which allowed gamma processing to be
- * disabled in background handling. There is no evidence (so far) that this
- * was being used; however, png_set_background itself accepted and must still
- * accept '0' for the gamma value it takes, because it isn't always used.
- *
- * Since this is an API change (albeit a very minor one that removes an
- * undocumented API feature) the following checks were only enabled in
- * libpng-1.6.0.
- */
- if (file_gamma <= 0)
- png_error(png_ptr, "invalid file gamma in png_set_gamma");
-
- if (scrn_gamma <= 0)
- png_error(png_ptr, "invalid screen gamma in png_set_gamma");
-
- /* Set the gamma values unconditionally - this overrides the value in the PNG
- * file if a gAMA chunk was present. png_set_alpha_mode provides a
- * different, easier, way to default the file gamma.
- */
- png_ptr->colorspace.gamma = file_gamma;
- png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA;
- png_ptr->screen_gamma = scrn_gamma;
-}
-
-# ifdef PNG_FLOATING_POINT_SUPPORTED
-void PNGAPI
-png_set_gamma(png_structrp png_ptr, double scrn_gamma, double file_gamma)
-{
- png_set_gamma_fixed(png_ptr, convert_gamma_value(png_ptr, scrn_gamma),
- convert_gamma_value(png_ptr, file_gamma));
-}
-# endif /* FLOATING_POINT */
-#endif /* READ_GAMMA */
-
-#ifdef PNG_READ_EXPAND_SUPPORTED
-/* Expand paletted images to RGB, expand grayscale images of
- * less than 8-bit depth to 8-bit depth, and expand tRNS chunks
- * to alpha channels.
- */
-void PNGAPI
-png_set_expand(png_structrp png_ptr)
-{
- png_debug(1, "in png_set_expand");
-
- if (png_rtran_ok(png_ptr, 0) == 0)
- return;
-
- png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
-}
-
-/* GRR 19990627: the following three functions currently are identical
- * to png_set_expand(). However, it is entirely reasonable that someone
- * might wish to expand an indexed image to RGB but *not* expand a single,
- * fully transparent palette entry to a full alpha channel--perhaps instead
- * convert tRNS to the grayscale/RGB format (16-bit RGB value), or replace
- * the transparent color with a particular RGB value, or drop tRNS entirely.
- * IOW, a future version of the library may make the transformations flag
- * a bit more fine-grained, with separate bits for each of these three
- * functions.
- *
- * More to the point, these functions make it obvious what libpng will be
- * doing, whereas "expand" can (and does) mean any number of things.
- *
- * GRP 20060307: In libpng-1.2.9, png_set_gray_1_2_4_to_8() was modified
- * to expand only the sample depth but not to expand the tRNS to alpha
- * and its name was changed to png_set_expand_gray_1_2_4_to_8().
- */
-
-/* Expand paletted images to RGB. */
-void PNGAPI
-png_set_palette_to_rgb(png_structrp png_ptr)
-{
- png_debug(1, "in png_set_palette_to_rgb");
-
- if (png_rtran_ok(png_ptr, 0) == 0)
- return;
-
- png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
-}
-
-/* Expand grayscale images of less than 8-bit depth to 8 bits. */
-void PNGAPI
-png_set_expand_gray_1_2_4_to_8(png_structrp png_ptr)
-{
- png_debug(1, "in png_set_expand_gray_1_2_4_to_8");
-
- if (png_rtran_ok(png_ptr, 0) == 0)
- return;
-
- png_ptr->transformations |= PNG_EXPAND;
-}
-
-/* Expand tRNS chunks to alpha channels. */
-void PNGAPI
-png_set_tRNS_to_alpha(png_structrp png_ptr)
-{
- png_debug(1, "in png_set_tRNS_to_alpha");
-
- if (png_rtran_ok(png_ptr, 0) == 0)
- return;
-
- png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
-}
-#endif /* READ_EXPAND */
-
-#ifdef PNG_READ_EXPAND_16_SUPPORTED
-/* Expand to 16-bit channels, expand the tRNS chunk too (because otherwise
- * it may not work correctly.)
- */
-void PNGAPI
-png_set_expand_16(png_structrp png_ptr)
-{
- png_debug(1, "in png_set_expand_16");
-
- if (png_rtran_ok(png_ptr, 0) == 0)
- return;
-
- png_ptr->transformations |= (PNG_EXPAND_16 | PNG_EXPAND | PNG_EXPAND_tRNS);
-}
-#endif
-
-#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
-void PNGAPI
-png_set_gray_to_rgb(png_structrp png_ptr)
-{
- png_debug(1, "in png_set_gray_to_rgb");
-
- if (png_rtran_ok(png_ptr, 0) == 0)
- return;
-
- /* Because rgb must be 8 bits or more: */
- png_set_expand_gray_1_2_4_to_8(png_ptr);
- png_ptr->transformations |= PNG_GRAY_TO_RGB;
-}
-#endif
-
-#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
-void PNGFAPI
-png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action,
- png_fixed_point red, png_fixed_point green)
-{
- png_debug(1, "in png_set_rgb_to_gray_fixed");
-
- /* Need the IHDR here because of the check on color_type below. */
- /* TODO: fix this */
- if (png_rtran_ok(png_ptr, 1) == 0)
- return;
-
- switch (error_action)
- {
- case PNG_ERROR_ACTION_NONE:
- png_ptr->transformations |= PNG_RGB_TO_GRAY;
- break;
-
- case PNG_ERROR_ACTION_WARN:
- png_ptr->transformations |= PNG_RGB_TO_GRAY_WARN;
- break;
-
- case PNG_ERROR_ACTION_ERROR:
- png_ptr->transformations |= PNG_RGB_TO_GRAY_ERR;
- break;
-
- default:
- png_error(png_ptr, "invalid error action to rgb_to_gray");
- }
-
- if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
-#ifdef PNG_READ_EXPAND_SUPPORTED
- png_ptr->transformations |= PNG_EXPAND;
-#else
- {
- /* Make this an error in 1.6 because otherwise the application may assume
- * that it just worked and get a memory overwrite.
- */
- png_error(png_ptr,
- "Cannot do RGB_TO_GRAY without EXPAND_SUPPORTED");
-
- /* png_ptr->transformations &= ~PNG_RGB_TO_GRAY; */
- }
-#endif
- {
- if (red >= 0 && green >= 0 && red + green <= PNG_FP_1)
- {
- png_uint_16 red_int, green_int;
-
- /* NOTE: this calculation does not round, but this behavior is retained
- * for consistency; the inaccuracy is very small. The code here always
- * overwrites the coefficients, regardless of whether they have been
- * defaulted or set already.
- */
- red_int = (png_uint_16)(((png_uint_32)red*32768)/100000);
- green_int = (png_uint_16)(((png_uint_32)green*32768)/100000);
-
- png_ptr->rgb_to_gray_red_coeff = red_int;
- png_ptr->rgb_to_gray_green_coeff = green_int;
- png_ptr->rgb_to_gray_coefficients_set = 1;
- }
-
- else
- {
- if (red >= 0 && green >= 0)
- png_app_warning(png_ptr,
- "ignoring out of range rgb_to_gray coefficients");
-
- /* Use the defaults, from the cHRM chunk if set, else the historical
- * values which are close to the sRGB/HDTV/ITU-Rec 709 values. See
- * png_do_rgb_to_gray for more discussion of the values. In this case
- * the coefficients are not marked as 'set' and are not overwritten if
- * something has already provided a default.
- */
- if (png_ptr->rgb_to_gray_red_coeff == 0 &&
- png_ptr->rgb_to_gray_green_coeff == 0)
- {
- png_ptr->rgb_to_gray_red_coeff = 6968;
- png_ptr->rgb_to_gray_green_coeff = 23434;
- /* png_ptr->rgb_to_gray_blue_coeff = 2366; */
- }
- }
- }
-}
-
-#ifdef PNG_FLOATING_POINT_SUPPORTED
-/* Convert a RGB image to a grayscale of the same width. This allows us,
- * for example, to convert a 24 bpp RGB image into an 8 bpp grayscale image.
- */
-
-void PNGAPI
-png_set_rgb_to_gray(png_structrp png_ptr, int error_action, double red,
- double green)
-{
- png_set_rgb_to_gray_fixed(png_ptr, error_action,
- png_fixed(png_ptr, red, "rgb to gray red coefficient"),
- png_fixed(png_ptr, green, "rgb to gray green coefficient"));
-}
-#endif /* FLOATING POINT */
-
-#endif /* RGB_TO_GRAY */
-
-#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
- defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
-void PNGAPI
-png_set_read_user_transform_fn(png_structrp png_ptr, png_user_transform_ptr
- read_user_transform_fn)
-{
- png_debug(1, "in png_set_read_user_transform_fn");
-
-#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
- png_ptr->transformations |= PNG_USER_TRANSFORM;
- png_ptr->read_user_transform_fn = read_user_transform_fn;
-#endif
-}
-#endif
-
-#ifdef PNG_READ_TRANSFORMS_SUPPORTED
-#ifdef PNG_READ_GAMMA_SUPPORTED
-/* In the case of gamma transformations only do transformations on images where
- * the [file] gamma and screen_gamma are not close reciprocals, otherwise it
- * slows things down slightly, and also needlessly introduces small errors.
- */
-static int /* PRIVATE */
-png_gamma_threshold(png_fixed_point screen_gamma, png_fixed_point file_gamma)
-{
- /* PNG_GAMMA_THRESHOLD is the threshold for performing gamma
- * correction as a difference of the overall transform from 1.0
- *
- * We want to compare the threshold with s*f - 1, if we get
- * overflow here it is because of wacky gamma values so we
- * turn on processing anyway.
- */
- png_fixed_point gtest;
- return !png_muldiv(&gtest, screen_gamma, file_gamma, PNG_FP_1) ||
- png_gamma_significant(gtest);
-}
-#endif
-
-/* Initialize everything needed for the read. This includes modifying
- * the palette.
- */
-
-/* For the moment 'png_init_palette_transformations' and
- * 'png_init_rgb_transformations' only do some flag canceling optimizations.
- * The intent is that these two routines should have palette or rgb operations
- * extracted from 'png_init_read_transformations'.
- */
-static void /* PRIVATE */
-png_init_palette_transformations(png_structrp png_ptr)
-{
- /* Called to handle the (input) palette case. In png_do_read_transformations
- * the first step is to expand the palette if requested, so this code must
- * take care to only make changes that are invariant with respect to the
- * palette expansion, or only do them if there is no expansion.
- *
- * STRIP_ALPHA has already been handled in the caller (by setting num_trans
- * to 0.)
- */
- int input_has_alpha = 0;
- int input_has_transparency = 0;
-
- if (png_ptr->num_trans > 0)
- {
- int i;
-
- /* Ignore if all the entries are opaque (unlikely!) */
- for (i=0; i<png_ptr->num_trans; ++i)
- {
- if (png_ptr->trans_alpha[i] == 255)
- continue;
- else if (png_ptr->trans_alpha[i] == 0)
- input_has_transparency = 1;
- else
- {
- input_has_transparency = 1;
- input_has_alpha = 1;
- break;
- }
- }
- }
-
- /* If no alpha we can optimize. */
- if (input_has_alpha == 0)
- {
- /* Any alpha means background and associative alpha processing is
- * required, however if the alpha is 0 or 1 throughout OPTIMIZE_ALPHA
- * and ENCODE_ALPHA are irrelevant.
- */
- png_ptr->transformations &= ~PNG_ENCODE_ALPHA;
- png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;
-
- if (input_has_transparency == 0)
- png_ptr->transformations &= ~(PNG_COMPOSE | PNG_BACKGROUND_EXPAND);
- }
-
-#if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED)
- /* png_set_background handling - deals with the complexity of whether the
- * background color is in the file format or the screen format in the case
- * where an 'expand' will happen.
- */
-
- /* The following code cannot be entered in the alpha pre-multiplication case
- * because PNG_BACKGROUND_EXPAND is cancelled below.
- */
- if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) != 0 &&
- (png_ptr->transformations & PNG_EXPAND) != 0)
- {
- {
- png_ptr->background.red =
- png_ptr->palette[png_ptr->background.index].red;
- png_ptr->background.green =
- png_ptr->palette[png_ptr->background.index].green;
- png_ptr->background.blue =
- png_ptr->palette[png_ptr->background.index].blue;
-
-#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED
- if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0)
- {
- if ((png_ptr->transformations & PNG_EXPAND_tRNS) == 0)
- {
- /* Invert the alpha channel (in tRNS) unless the pixels are
- * going to be expanded, in which case leave it for later
- */
- int i, istop = png_ptr->num_trans;
-
- for (i = 0; i < istop; i++)
- png_ptr->trans_alpha[i] =
- (png_byte)(255 - png_ptr->trans_alpha[i]);
- }
- }
-#endif /* READ_INVERT_ALPHA */
- }
- } /* background expand and (therefore) no alpha association. */
-#endif /* READ_EXPAND && READ_BACKGROUND */
-}
-
-static void /* PRIVATE */
-png_init_rgb_transformations(png_structrp png_ptr)
-{
- /* Added to libpng-1.5.4: check the color type to determine whether there
- * is any alpha or transparency in the image and simply cancel the
- * background and alpha mode stuff if there isn't.
- */
- int input_has_alpha = (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0;
- int input_has_transparency = png_ptr->num_trans > 0;
-
- /* If no alpha we can optimize. */
- if (input_has_alpha == 0)
- {
- /* Any alpha means background and associative alpha processing is
- * required, however if the alpha is 0 or 1 throughout OPTIMIZE_ALPHA
- * and ENCODE_ALPHA are irrelevant.
- */
-# ifdef PNG_READ_ALPHA_MODE_SUPPORTED
- png_ptr->transformations &= ~PNG_ENCODE_ALPHA;
- png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;
-# endif
-
- if (input_has_transparency == 0)
- png_ptr->transformations &= ~(PNG_COMPOSE | PNG_BACKGROUND_EXPAND);
- }
-
-#if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED)
- /* png_set_background handling - deals with the complexity of whether the
- * background color is in the file format or the screen format in the case
- * where an 'expand' will happen.
- */
-
- /* The following code cannot be entered in the alpha pre-multiplication case
- * because PNG_BACKGROUND_EXPAND is cancelled below.
- */
- if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) != 0 &&
- (png_ptr->transformations & PNG_EXPAND) != 0 &&
- (png_ptr->color_type & PNG_COLOR_MASK_COLOR) == 0)
- /* i.e., GRAY or GRAY_ALPHA */
- {
- {
- /* Expand background and tRNS chunks */
- int gray = png_ptr->background.gray;
- int trans_gray = png_ptr->trans_color.gray;
-
- switch (png_ptr->bit_depth)
- {
- case 1:
- gray *= 0xff;
- trans_gray *= 0xff;
- break;
-
- case 2:
- gray *= 0x55;
- trans_gray *= 0x55;
- break;
-
- case 4:
- gray *= 0x11;
- trans_gray *= 0x11;
- break;
-
- default:
-
- case 8:
- /* FALLTHROUGH */ /* (Already 8 bits) */
-
- case 16:
- /* Already a full 16 bits */
- break;
- }
-
- png_ptr->background.red = png_ptr->background.green =
- png_ptr->background.blue = (png_uint_16)gray;
-
- if ((png_ptr->transformations & PNG_EXPAND_tRNS) == 0)
- {
- png_ptr->trans_color.red = png_ptr->trans_color.green =
- png_ptr->trans_color.blue = (png_uint_16)trans_gray;
- }
- }
- } /* background expand and (therefore) no alpha association. */
-#endif /* READ_EXPAND && READ_BACKGROUND */
-}
-
-void /* PRIVATE */
-png_init_read_transformations(png_structrp png_ptr)
-{
- png_debug(1, "in png_init_read_transformations");
-
- /* This internal function is called from png_read_start_row in pngrutil.c
- * and it is called before the 'rowbytes' calculation is done, so the code
- * in here can change or update the transformations flags.
- *
- * First do updates that do not depend on the details of the PNG image data
- * being processed.
- */
-
-#ifdef PNG_READ_GAMMA_SUPPORTED
- /* Prior to 1.5.4 these tests were performed from png_set_gamma, 1.5.4 adds
- * png_set_alpha_mode and this is another source for a default file gamma so
- * the test needs to be performed later - here. In addition prior to 1.5.4
- * the tests were repeated for the PALETTE color type here - this is no
- * longer necessary (and doesn't seem to have been necessary before.)
- */
- {
- /* The following temporary indicates if overall gamma correction is
- * required.
- */
- int gamma_correction = 0;
-
- if (png_ptr->colorspace.gamma != 0) /* has been set */
- {
- if (png_ptr->screen_gamma != 0) /* screen set too */
- gamma_correction = png_gamma_threshold(png_ptr->colorspace.gamma,
- png_ptr->screen_gamma);
-
- else
- /* Assume the output matches the input; a long time default behavior
- * of libpng, although the standard has nothing to say about this.
- */
- png_ptr->screen_gamma = png_reciprocal(png_ptr->colorspace.gamma);
- }
-
- else if (png_ptr->screen_gamma != 0)
- /* The converse - assume the file matches the screen, note that this
- * perhaps undesirable default can (from 1.5.4) be changed by calling
- * png_set_alpha_mode (even if the alpha handling mode isn't required
- * or isn't changed from the default.)
- */
- png_ptr->colorspace.gamma = png_reciprocal(png_ptr->screen_gamma);
-
- else /* neither are set */
- /* Just in case the following prevents any processing - file and screen
- * are both assumed to be linear and there is no way to introduce a
- * third gamma value other than png_set_background with 'UNIQUE', and,
- * prior to 1.5.4
- */
- png_ptr->screen_gamma = png_ptr->colorspace.gamma = PNG_FP_1;
-
- /* We have a gamma value now. */
- png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA;
-
- /* Now turn the gamma transformation on or off as appropriate. Notice
- * that PNG_GAMMA just refers to the file->screen correction. Alpha
- * composition may independently cause gamma correction because it needs
- * linear data (e.g. if the file has a gAMA chunk but the screen gamma
- * hasn't been specified.) In any case this flag may get turned off in
- * the code immediately below if the transform can be handled outside the
- * row loop.
- */
- if (gamma_correction != 0)
- png_ptr->transformations |= PNG_GAMMA;
-
- else
- png_ptr->transformations &= ~PNG_GAMMA;
- }
-#endif
-
- /* Certain transformations have the effect of preventing other
- * transformations that happen afterward in png_do_read_transformations;
- * resolve the interdependencies here. From the code of
- * png_do_read_transformations the order is:
- *
- * 1) PNG_EXPAND (including PNG_EXPAND_tRNS)
- * 2) PNG_STRIP_ALPHA (if no compose)
- * 3) PNG_RGB_TO_GRAY
- * 4) PNG_GRAY_TO_RGB iff !PNG_BACKGROUND_IS_GRAY
- * 5) PNG_COMPOSE
- * 6) PNG_GAMMA
- * 7) PNG_STRIP_ALPHA (if compose)
- * 8) PNG_ENCODE_ALPHA
- * 9) PNG_SCALE_16_TO_8
- * 10) PNG_16_TO_8
- * 11) PNG_QUANTIZE (converts to palette)
- * 12) PNG_EXPAND_16
- * 13) PNG_GRAY_TO_RGB iff PNG_BACKGROUND_IS_GRAY
- * 14) PNG_INVERT_MONO
- * 15) PNG_INVERT_ALPHA
- * 16) PNG_SHIFT
- * 17) PNG_PACK
- * 18) PNG_BGR
- * 19) PNG_PACKSWAP
- * 20) PNG_FILLER (includes PNG_ADD_ALPHA)
- * 21) PNG_SWAP_ALPHA
- * 22) PNG_SWAP_BYTES
- * 23) PNG_USER_TRANSFORM [must be last]
- */
-#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
- if ((png_ptr->transformations & PNG_STRIP_ALPHA) != 0 &&
- (png_ptr->transformations & PNG_COMPOSE) == 0)
- {
- /* Stripping the alpha channel happens immediately after the 'expand'
- * transformations, before all other transformation, so it cancels out
- * the alpha handling. It has the side effect negating the effect of
- * PNG_EXPAND_tRNS too:
- */
- png_ptr->transformations &= ~(PNG_BACKGROUND_EXPAND | PNG_ENCODE_ALPHA |
- PNG_EXPAND_tRNS);
- png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;
-
- /* Kill the tRNS chunk itself too. Prior to 1.5.4 this did not happen
- * so transparency information would remain just so long as it wasn't
- * expanded. This produces unexpected API changes if the set of things
- * that do PNG_EXPAND_tRNS changes (perfectly possible given the
- * documentation - which says ask for what you want, accept what you
- * get.) This makes the behavior consistent from 1.5.4:
- */
- png_ptr->num_trans = 0;
- }
-#endif /* STRIP_ALPHA supported, no COMPOSE */
-
-#ifdef PNG_READ_ALPHA_MODE_SUPPORTED
- /* If the screen gamma is about 1.0 then the OPTIMIZE_ALPHA and ENCODE_ALPHA
- * settings will have no effect.
- */
- if (png_gamma_significant(png_ptr->screen_gamma) == 0)
- {
- png_ptr->transformations &= ~PNG_ENCODE_ALPHA;
- png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;
- }
-#endif
-
-#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
- /* Make sure the coefficients for the rgb to gray conversion are set
- * appropriately.
- */
- if ((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0)
- png_colorspace_set_rgb_coefficients(png_ptr);
-#endif
-
-#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
-#if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED)
- /* Detect gray background and attempt to enable optimization for
- * gray --> RGB case.
- *
- * Note: if PNG_BACKGROUND_EXPAND is set and color_type is either RGB or
- * RGB_ALPHA (in which case need_expand is superfluous anyway), the
- * background color might actually be gray yet not be flagged as such.
- * This is not a problem for the current code, which uses
- * PNG_BACKGROUND_IS_GRAY only to decide when to do the
- * png_do_gray_to_rgb() transformation.
- *
- * TODO: this code needs to be revised to avoid the complexity and
- * interdependencies. The color type of the background should be recorded in
- * png_set_background, along with the bit depth, then the code has a record
- * of exactly what color space the background is currently in.
- */
- if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) != 0)
- {
- /* PNG_BACKGROUND_EXPAND: the background is in the file color space, so if
- * the file was grayscale the background value is gray.
- */
- if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) == 0)
- png_ptr->mode |= PNG_BACKGROUND_IS_GRAY;
- }
-
- else if ((png_ptr->transformations & PNG_COMPOSE) != 0)
- {
- /* PNG_COMPOSE: png_set_background was called with need_expand false,
- * so the color is in the color space of the output or png_set_alpha_mode
- * was called and the color is black. Ignore RGB_TO_GRAY because that
- * happens before GRAY_TO_RGB.
- */
- if ((png_ptr->transformations & PNG_GRAY_TO_RGB) != 0)
- {
- if (png_ptr->background.red == png_ptr->background.green &&
- png_ptr->background.red == png_ptr->background.blue)
- {
- png_ptr->mode |= PNG_BACKGROUND_IS_GRAY;
- png_ptr->background.gray = png_ptr->background.red;
- }
- }
- }
-#endif /* READ_EXPAND && READ_BACKGROUND */
-#endif /* READ_GRAY_TO_RGB */
-
- /* For indexed PNG data (PNG_COLOR_TYPE_PALETTE) many of the transformations
- * can be performed directly on the palette, and some (such as rgb to gray)
- * can be optimized inside the palette. This is particularly true of the
- * composite (background and alpha) stuff, which can be pretty much all done
- * in the palette even if the result is expanded to RGB or gray afterward.
- *
- * NOTE: this is Not Yet Implemented, the code behaves as in 1.5.1 and
- * earlier and the palette stuff is actually handled on the first row. This
- * leads to the reported bug that the palette returned by png_get_PLTE is not
- * updated.
- */
- if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
- png_init_palette_transformations(png_ptr);
-
- else
- png_init_rgb_transformations(png_ptr);
-
-#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \
- defined(PNG_READ_EXPAND_16_SUPPORTED)
- if ((png_ptr->transformations & PNG_EXPAND_16) != 0 &&
- (png_ptr->transformations & PNG_COMPOSE) != 0 &&
- (png_ptr->transformations & PNG_BACKGROUND_EXPAND) == 0 &&
- png_ptr->bit_depth != 16)
- {
- /* TODO: fix this. Because the expand_16 operation is after the compose
- * handling the background color must be 8, not 16, bits deep, but the
- * application will supply a 16-bit value so reduce it here.
- *
- * The PNG_BACKGROUND_EXPAND code above does not expand to 16 bits at
- * present, so that case is ok (until do_expand_16 is moved.)
- *
- * NOTE: this discards the low 16 bits of the user supplied background
- * color, but until expand_16 works properly there is no choice!
- */
-# define CHOP(x) (x)=((png_uint_16)PNG_DIV257(x))
- CHOP(png_ptr->background.red);
- CHOP(png_ptr->background.green);
- CHOP(png_ptr->background.blue);
- CHOP(png_ptr->background.gray);
-# undef CHOP
- }
-#endif /* READ_BACKGROUND && READ_EXPAND_16 */
-
-#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \
- (defined(PNG_READ_SCALE_16_TO_8_SUPPORTED) || \
- defined(PNG_READ_STRIP_16_TO_8_SUPPORTED))
- if ((png_ptr->transformations & (PNG_16_TO_8|PNG_SCALE_16_TO_8)) != 0 &&
- (png_ptr->transformations & PNG_COMPOSE) != 0 &&
- (png_ptr->transformations & PNG_BACKGROUND_EXPAND) == 0 &&
- png_ptr->bit_depth == 16)
- {
- /* On the other hand, if a 16-bit file is to be reduced to 8-bits per
- * component this will also happen after PNG_COMPOSE and so the background
- * color must be pre-expanded here.
- *
- * TODO: fix this too.
- */
- png_ptr->background.red = (png_uint_16)(png_ptr->background.red * 257);
- png_ptr->background.green =
- (png_uint_16)(png_ptr->background.green * 257);
- png_ptr->background.blue = (png_uint_16)(png_ptr->background.blue * 257);
- png_ptr->background.gray = (png_uint_16)(png_ptr->background.gray * 257);
- }
-#endif
-
- /* NOTE: below 'PNG_READ_ALPHA_MODE_SUPPORTED' is presumed to also enable the
- * background support (see the comments in scripts/pnglibconf.dfa), this
- * allows pre-multiplication of the alpha channel to be implemented as
- * compositing on black. This is probably sub-optimal and has been done in
- * 1.5.4 betas simply to enable external critique and testing (i.e. to
- * implement the new API quickly, without lots of internal changes.)
- */
-
-#ifdef PNG_READ_GAMMA_SUPPORTED
-# ifdef PNG_READ_BACKGROUND_SUPPORTED
- /* Includes ALPHA_MODE */
- png_ptr->background_1 = png_ptr->background;
-# endif
-
- /* This needs to change - in the palette image case a whole set of tables are
- * built when it would be quicker to just calculate the correct value for
- * each palette entry directly. Also, the test is too tricky - why check
- * PNG_RGB_TO_GRAY if PNG_GAMMA is not set? The answer seems to be that
- * PNG_GAMMA is cancelled even if the gamma is known? The test excludes the
- * PNG_COMPOSE case, so apparently if there is no *overall* gamma correction
- * the gamma tables will not be built even if composition is required on a
- * gamma encoded value.
- *
- * In 1.5.4 this is addressed below by an additional check on the individual
- * file gamma - if it is not 1.0 both RGB_TO_GRAY and COMPOSE need the
- * tables.
- */
- if ((png_ptr->transformations & PNG_GAMMA) != 0 ||
- ((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0 &&
- (png_gamma_significant(png_ptr->colorspace.gamma) != 0 ||
- png_gamma_significant(png_ptr->screen_gamma) != 0)) ||
- ((png_ptr->transformations & PNG_COMPOSE) != 0 &&
- (png_gamma_significant(png_ptr->colorspace.gamma) != 0 ||
- png_gamma_significant(png_ptr->screen_gamma) != 0
-# ifdef PNG_READ_BACKGROUND_SUPPORTED
- || (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_UNIQUE &&
- png_gamma_significant(png_ptr->background_gamma) != 0)
-# endif
- )) || ((png_ptr->transformations & PNG_ENCODE_ALPHA) != 0 &&
- png_gamma_significant(png_ptr->screen_gamma) != 0))
- {
- png_build_gamma_table(png_ptr, png_ptr->bit_depth);
-
-#ifdef PNG_READ_BACKGROUND_SUPPORTED
- if ((png_ptr->transformations & PNG_COMPOSE) != 0)
- {
- /* Issue a warning about this combination: because RGB_TO_GRAY is
- * optimized to do the gamma transform if present yet do_background has
- * to do the same thing if both options are set a
- * double-gamma-correction happens. This is true in all versions of
- * libpng to date.
- */
- if ((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0)
- png_warning(png_ptr,
- "libpng does not support gamma+background+rgb_to_gray");
-
- if ((png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) != 0)
- {
- /* We don't get to here unless there is a tRNS chunk with non-opaque
- * entries - see the checking code at the start of this function.
- */
- png_color back, back_1;
- png_colorp palette = png_ptr->palette;
- int num_palette = png_ptr->num_palette;
- int i;
- if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_FILE)
- {
-
- back.red = png_ptr->gamma_table[png_ptr->background.red];
- back.green = png_ptr->gamma_table[png_ptr->background.green];
- back.blue = png_ptr->gamma_table[png_ptr->background.blue];
-
- back_1.red = png_ptr->gamma_to_1[png_ptr->background.red];
- back_1.green = png_ptr->gamma_to_1[png_ptr->background.green];
- back_1.blue = png_ptr->gamma_to_1[png_ptr->background.blue];
- }
- else
- {
- png_fixed_point g, gs;
-
- switch (png_ptr->background_gamma_type)
- {
- case PNG_BACKGROUND_GAMMA_SCREEN:
- g = (png_ptr->screen_gamma);
- gs = PNG_FP_1;
- break;
-
- case PNG_BACKGROUND_GAMMA_FILE:
- g = png_reciprocal(png_ptr->colorspace.gamma);
- gs = png_reciprocal2(png_ptr->colorspace.gamma,
- png_ptr->screen_gamma);
- break;
-
- case PNG_BACKGROUND_GAMMA_UNIQUE:
- g = png_reciprocal(png_ptr->background_gamma);
- gs = png_reciprocal2(png_ptr->background_gamma,
- png_ptr->screen_gamma);
- break;
- default:
- g = PNG_FP_1; /* back_1 */
- gs = PNG_FP_1; /* back */
- break;
- }
-
- if (png_gamma_significant(gs) != 0)
- {
- back.red = png_gamma_8bit_correct(png_ptr->background.red,
- gs);
- back.green = png_gamma_8bit_correct(png_ptr->background.green,
- gs);
- back.blue = png_gamma_8bit_correct(png_ptr->background.blue,
- gs);
- }
-
- else
- {
- back.red = (png_byte)png_ptr->background.red;
- back.green = (png_byte)png_ptr->background.green;
- back.blue = (png_byte)png_ptr->background.blue;
- }
-
- if (png_gamma_significant(g) != 0)
- {
- back_1.red = png_gamma_8bit_correct(png_ptr->background.red,
- g);
- back_1.green = png_gamma_8bit_correct(
- png_ptr->background.green, g);
- back_1.blue = png_gamma_8bit_correct(png_ptr->background.blue,
- g);
- }
-
- else
- {
- back_1.red = (png_byte)png_ptr->background.red;
- back_1.green = (png_byte)png_ptr->background.green;
- back_1.blue = (png_byte)png_ptr->background.blue;
- }
- }
-
- for (i = 0; i < num_palette; i++)
- {
- if (i < (int)png_ptr->num_trans &&
- png_ptr->trans_alpha[i] != 0xff)
- {
- if (png_ptr->trans_alpha[i] == 0)
- {
- palette[i] = back;
- }
- else /* if (png_ptr->trans_alpha[i] != 0xff) */
- {
- png_byte v, w;
-
- v = png_ptr->gamma_to_1[palette[i].red];
- png_composite(w, v, png_ptr->trans_alpha[i], back_1.red);
- palette[i].red = png_ptr->gamma_from_1[w];
-
- v = png_ptr->gamma_to_1[palette[i].green];
- png_composite(w, v, png_ptr->trans_alpha[i], back_1.green);
- palette[i].green = png_ptr->gamma_from_1[w];
-
- v = png_ptr->gamma_to_1[palette[i].blue];
- png_composite(w, v, png_ptr->trans_alpha[i], back_1.blue);
- palette[i].blue = png_ptr->gamma_from_1[w];
- }
- }
- else
- {
- palette[i].red = png_ptr->gamma_table[palette[i].red];
- palette[i].green = png_ptr->gamma_table[palette[i].green];
- palette[i].blue = png_ptr->gamma_table[palette[i].blue];
- }
- }
-
- /* Prevent the transformations being done again.
- *
- * NOTE: this is highly dubious; it removes the transformations in
- * place. This seems inconsistent with the general treatment of the
- * transformations elsewhere.
- */
- png_ptr->transformations &= ~(PNG_COMPOSE | PNG_GAMMA);
- } /* color_type == PNG_COLOR_TYPE_PALETTE */
-
- /* if (png_ptr->background_gamma_type!=PNG_BACKGROUND_GAMMA_UNKNOWN) */
- else /* color_type != PNG_COLOR_TYPE_PALETTE */
- {
- int gs_sig, g_sig;
- png_fixed_point g = PNG_FP_1; /* Correction to linear */
- png_fixed_point gs = PNG_FP_1; /* Correction to screen */
-
- switch (png_ptr->background_gamma_type)
- {
- case PNG_BACKGROUND_GAMMA_SCREEN:
- g = png_ptr->screen_gamma;
- /* gs = PNG_FP_1; */
- break;
-
- case PNG_BACKGROUND_GAMMA_FILE:
- g = png_reciprocal(png_ptr->colorspace.gamma);
- gs = png_reciprocal2(png_ptr->colorspace.gamma,
- png_ptr->screen_gamma);
- break;
-
- case PNG_BACKGROUND_GAMMA_UNIQUE:
- g = png_reciprocal(png_ptr->background_gamma);
- gs = png_reciprocal2(png_ptr->background_gamma,
- png_ptr->screen_gamma);
- break;
-
- default:
- png_error(png_ptr, "invalid background gamma type");
- }
-
- g_sig = png_gamma_significant(g);
- gs_sig = png_gamma_significant(gs);
-
- if (g_sig != 0)
- png_ptr->background_1.gray = png_gamma_correct(png_ptr,
- png_ptr->background.gray, g);
-
- if (gs_sig != 0)
- png_ptr->background.gray = png_gamma_correct(png_ptr,
- png_ptr->background.gray, gs);
-
- if ((png_ptr->background.red != png_ptr->background.green) ||
- (png_ptr->background.red != png_ptr->background.blue) ||
- (png_ptr->background.red != png_ptr->background.gray))
- {
- /* RGB or RGBA with color background */
- if (g_sig != 0)
- {
- png_ptr->background_1.red = png_gamma_correct(png_ptr,
- png_ptr->background.red, g);
-
- png_ptr->background_1.green = png_gamma_correct(png_ptr,
- png_ptr->background.green, g);
-
- png_ptr->background_1.blue = png_gamma_correct(png_ptr,
- png_ptr->background.blue, g);
- }
-
- if (gs_sig != 0)
- {
- png_ptr->background.red = png_gamma_correct(png_ptr,
- png_ptr->background.red, gs);
-
- png_ptr->background.green = png_gamma_correct(png_ptr,
- png_ptr->background.green, gs);
-
- png_ptr->background.blue = png_gamma_correct(png_ptr,
- png_ptr->background.blue, gs);
- }
- }
-
- else
- {
- /* GRAY, GRAY ALPHA, RGB, or RGBA with gray background */
- png_ptr->background_1.red = png_ptr->background_1.green
- = png_ptr->background_1.blue = png_ptr->background_1.gray;
-
- png_ptr->background.red = png_ptr->background.green
- = png_ptr->background.blue = png_ptr->background.gray;
- }
-
- /* The background is now in screen gamma: */
- png_ptr->background_gamma_type = PNG_BACKGROUND_GAMMA_SCREEN;
- } /* color_type != PNG_COLOR_TYPE_PALETTE */
- }/* png_ptr->transformations & PNG_BACKGROUND */
-
- else
- /* Transformation does not include PNG_BACKGROUND */
-#endif /* READ_BACKGROUND */
- if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE
-#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
- /* RGB_TO_GRAY needs to have non-gamma-corrected values! */
- && ((png_ptr->transformations & PNG_EXPAND) == 0 ||
- (png_ptr->transformations & PNG_RGB_TO_GRAY) == 0)
-#endif
- )
- {
- png_colorp palette = png_ptr->palette;
- int num_palette = png_ptr->num_palette;
- int i;
-
- /* NOTE: there are other transformations that should probably be in
- * here too.
- */
- for (i = 0; i < num_palette; i++)
- {
- palette[i].red = png_ptr->gamma_table[palette[i].red];
- palette[i].green = png_ptr->gamma_table[palette[i].green];
- palette[i].blue = png_ptr->gamma_table[palette[i].blue];
- }
-
- /* Done the gamma correction. */
- png_ptr->transformations &= ~PNG_GAMMA;
- } /* color_type == PALETTE && !PNG_BACKGROUND transformation */
- }
-#ifdef PNG_READ_BACKGROUND_SUPPORTED
- else
-#endif
-#endif /* READ_GAMMA */
-
-#ifdef PNG_READ_BACKGROUND_SUPPORTED
- /* No GAMMA transformation (see the hanging else 4 lines above) */
- if ((png_ptr->transformations & PNG_COMPOSE) != 0 &&
- (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE))
- {
- int i;
- int istop = (int)png_ptr->num_trans;
- png_color back;
- png_colorp palette = png_ptr->palette;
-
- back.red = (png_byte)png_ptr->background.red;
- back.green = (png_byte)png_ptr->background.green;
- back.blue = (png_byte)png_ptr->background.blue;
-
- for (i = 0; i < istop; i++)
- {
- if (png_ptr->trans_alpha[i] == 0)
- {
- palette[i] = back;
- }
-
- else if (png_ptr->trans_alpha[i] != 0xff)
- {
- /* The png_composite() macro is defined in png.h */
- png_composite(palette[i].red, palette[i].red,
- png_ptr->trans_alpha[i], back.red);
-
- png_composite(palette[i].green, palette[i].green,
- png_ptr->trans_alpha[i], back.green);
-
- png_composite(palette[i].blue, palette[i].blue,
- png_ptr->trans_alpha[i], back.blue);
- }
- }
-
- png_ptr->transformations &= ~PNG_COMPOSE;
- }
-#endif /* READ_BACKGROUND */
-
-#ifdef PNG_READ_SHIFT_SUPPORTED
- if ((png_ptr->transformations & PNG_SHIFT) != 0 &&
- (png_ptr->transformations & PNG_EXPAND) == 0 &&
- (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE))
- {
- int i;
- int istop = png_ptr->num_palette;
- int shift = 8 - png_ptr->sig_bit.red;
-
- png_ptr->transformations &= ~PNG_SHIFT;
-
- /* significant bits can be in the range 1 to 7 for a meaningful result, if
- * the number of significant bits is 0 then no shift is done (this is an
- * error condition which is silently ignored.)
- */
- if (shift > 0 && shift < 8)
- for (i=0; i<istop; ++i)
- {
- int component = png_ptr->palette[i].red;
-
- component >>= shift;
- png_ptr->palette[i].red = (png_byte)component;
- }
-
- shift = 8 - png_ptr->sig_bit.green;
- if (shift > 0 && shift < 8)
- for (i=0; i<istop; ++i)
- {
- int component = png_ptr->palette[i].green;
-
- component >>= shift;
- png_ptr->palette[i].green = (png_byte)component;
- }
-
- shift = 8 - png_ptr->sig_bit.blue;
- if (shift > 0 && shift < 8)
- for (i=0; i<istop; ++i)
- {
- int component = png_ptr->palette[i].blue;
-
- component >>= shift;
- png_ptr->palette[i].blue = (png_byte)component;
- }
- }
-#endif /* READ_SHIFT */
-}
-
-/* Modify the info structure to reflect the transformations. The
- * info should be updated so a PNG file could be written with it,
- * assuming the transformations result in valid PNG data.
- */
-void /* PRIVATE */
-png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr)
-{
- png_debug(1, "in png_read_transform_info");
-
-#ifdef PNG_READ_EXPAND_SUPPORTED
- if ((png_ptr->transformations & PNG_EXPAND) != 0)
- {
- if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
- {
- /* This check must match what actually happens in
- * png_do_expand_palette; if it ever checks the tRNS chunk to see if
- * it is all opaque we must do the same (at present it does not.)
- */
- if (png_ptr->num_trans > 0)
- info_ptr->color_type = PNG_COLOR_TYPE_RGB_ALPHA;
-
- else
- info_ptr->color_type = PNG_COLOR_TYPE_RGB;
-
- info_ptr->bit_depth = 8;
- info_ptr->num_trans = 0;
-
- if (png_ptr->palette == NULL)
- png_error (png_ptr, "Palette is NULL in indexed image");
- }
- else
- {
- if (png_ptr->num_trans != 0)
- {
- if ((png_ptr->transformations & PNG_EXPAND_tRNS) != 0)
- info_ptr->color_type |= PNG_COLOR_MASK_ALPHA;
- }
- if (info_ptr->bit_depth < 8)
- info_ptr->bit_depth = 8;
-
- info_ptr->num_trans = 0;
- }
- }
-#endif
-
-#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
- defined(PNG_READ_ALPHA_MODE_SUPPORTED)
- /* The following is almost certainly wrong unless the background value is in
- * the screen space!
- */
- if ((png_ptr->transformations & PNG_COMPOSE) != 0)
- info_ptr->background = png_ptr->background;
-#endif
-
-#ifdef PNG_READ_GAMMA_SUPPORTED
- /* The following used to be conditional on PNG_GAMMA (prior to 1.5.4),
- * however it seems that the code in png_init_read_transformations, which has
- * been called before this from png_read_update_info->png_read_start_row
- * sometimes does the gamma transform and cancels the flag.
- *
- * TODO: this looks wrong; the info_ptr should end up with a gamma equal to
- * the screen_gamma value. The following probably results in weirdness if
- * the info_ptr is used by the app after the rows have been read.
- */
- info_ptr->colorspace.gamma = png_ptr->colorspace.gamma;
-#endif
-
- if (info_ptr->bit_depth == 16)
- {
-# ifdef PNG_READ_16BIT_SUPPORTED
-# ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
- if ((png_ptr->transformations & PNG_SCALE_16_TO_8) != 0)
- info_ptr->bit_depth = 8;
-# endif
-
-# ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
- if ((png_ptr->transformations & PNG_16_TO_8) != 0)
- info_ptr->bit_depth = 8;
-# endif
-
-# else
- /* No 16-bit support: force chopping 16-bit input down to 8, in this case
- * the app program can chose if both APIs are available by setting the
- * correct scaling to use.
- */
-# ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
- /* For compatibility with previous versions use the strip method by
- * default. This code works because if PNG_SCALE_16_TO_8 is already
- * set the code below will do that in preference to the chop.
- */
- png_ptr->transformations |= PNG_16_TO_8;
- info_ptr->bit_depth = 8;
-# else
-
-# ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
- png_ptr->transformations |= PNG_SCALE_16_TO_8;
- info_ptr->bit_depth = 8;
-# else
-
- CONFIGURATION ERROR: you must enable at least one 16 to 8 method
-# endif
-# endif
-#endif /* !READ_16BIT */
- }
-
-#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
- if ((png_ptr->transformations & PNG_GRAY_TO_RGB) != 0)
- info_ptr->color_type = (png_byte)(info_ptr->color_type |
- PNG_COLOR_MASK_COLOR);
-#endif
-
-#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
- if ((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0)
- info_ptr->color_type = (png_byte)(info_ptr->color_type &
- ~PNG_COLOR_MASK_COLOR);
-#endif
-
-#ifdef PNG_READ_QUANTIZE_SUPPORTED
- if ((png_ptr->transformations & PNG_QUANTIZE) != 0)
- {
- if (((info_ptr->color_type == PNG_COLOR_TYPE_RGB) ||
- (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)) &&
- png_ptr->palette_lookup != 0 && info_ptr->bit_depth == 8)
- {
- info_ptr->color_type = PNG_COLOR_TYPE_PALETTE;
- }
- }
-#endif
-
-#ifdef PNG_READ_EXPAND_16_SUPPORTED
- if ((png_ptr->transformations & PNG_EXPAND_16) != 0 &&
- info_ptr->bit_depth == 8 &&
- info_ptr->color_type != PNG_COLOR_TYPE_PALETTE)
- {
- info_ptr->bit_depth = 16;
- }
-#endif
-
-#ifdef PNG_READ_PACK_SUPPORTED
- if ((png_ptr->transformations & PNG_PACK) != 0 &&
- (info_ptr->bit_depth < 8))
- info_ptr->bit_depth = 8;
-#endif
-
- if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
- info_ptr->channels = 1;
-
- else if ((info_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0)
- info_ptr->channels = 3;
-
- else
- info_ptr->channels = 1;
-
-#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
- if ((png_ptr->transformations & PNG_STRIP_ALPHA) != 0)
- {
- info_ptr->color_type = (png_byte)(info_ptr->color_type &
- ~PNG_COLOR_MASK_ALPHA);
- info_ptr->num_trans = 0;
- }
-#endif
-
- if ((info_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0)
- info_ptr->channels++;
-
-#ifdef PNG_READ_FILLER_SUPPORTED
- /* STRIP_ALPHA and FILLER allowed: MASK_ALPHA bit stripped above */
- if ((png_ptr->transformations & PNG_FILLER) != 0 &&
- (info_ptr->color_type == PNG_COLOR_TYPE_RGB ||
- info_ptr->color_type == PNG_COLOR_TYPE_GRAY))
- {
- info_ptr->channels++;
- /* If adding a true alpha channel not just filler */
- if ((png_ptr->transformations & PNG_ADD_ALPHA) != 0)
- info_ptr->color_type |= PNG_COLOR_MASK_ALPHA;
- }
-#endif
-
-#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) && \
-defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
- if ((png_ptr->transformations & PNG_USER_TRANSFORM) != 0)
- {
- if (png_ptr->user_transform_depth != 0)
- info_ptr->bit_depth = png_ptr->user_transform_depth;
-
- if (png_ptr->user_transform_channels != 0)
- info_ptr->channels = png_ptr->user_transform_channels;
- }
-#endif
-
- info_ptr->pixel_depth = (png_byte)(info_ptr->channels *
- info_ptr->bit_depth);
-
- info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, info_ptr->width);
-
- /* Adding in 1.5.4: cache the above value in png_struct so that we can later
- * check in png_rowbytes that the user buffer won't get overwritten. Note
- * that the field is not always set - if png_read_update_info isn't called
- * the application has to either not do any transforms or get the calculation
- * right itself.
- */
- png_ptr->info_rowbytes = info_ptr->rowbytes;
-
-#ifndef PNG_READ_EXPAND_SUPPORTED
- if (png_ptr != NULL)
- return;
-#endif
-}
-
-#ifdef PNG_READ_PACK_SUPPORTED
-/* Unpack pixels of 1, 2, or 4 bits per pixel into 1 byte per pixel,
- * without changing the actual values. Thus, if you had a row with
- * a bit depth of 1, you would end up with bytes that only contained
- * the numbers 0 or 1. If you would rather they contain 0 and 255, use
- * png_do_shift() after this.
- */
-static void
-png_do_unpack(png_row_infop row_info, png_bytep row)
-{
- png_debug(1, "in png_do_unpack");
-
- if (row_info->bit_depth < 8)
- {
- png_uint_32 i;
- png_uint_32 row_width=row_info->width;
-
- switch (row_info->bit_depth)
- {
- case 1:
- {
- png_bytep sp = row + (size_t)((row_width - 1) >> 3);
- png_bytep dp = row + (size_t)row_width - 1;
- png_uint_32 shift = 7U - ((row_width + 7U) & 0x07);
- for (i = 0; i < row_width; i++)
- {
- *dp = (png_byte)((*sp >> shift) & 0x01);
-
- if (shift == 7)
- {
- shift = 0;
- sp--;
- }
-
- else
- shift++;
-
- dp--;
- }
- break;
- }
-
- case 2:
- {
-
- png_bytep sp = row + (size_t)((row_width - 1) >> 2);
- png_bytep dp = row + (size_t)row_width - 1;
- png_uint_32 shift = ((3U - ((row_width + 3U) & 0x03)) << 1);
- for (i = 0; i < row_width; i++)
- {
- *dp = (png_byte)((*sp >> shift) & 0x03);
-
- if (shift == 6)
- {
- shift = 0;
- sp--;
- }
-
- else
- shift += 2;
-
- dp--;
- }
- break;
- }
-
- case 4:
- {
- png_bytep sp = row + (size_t)((row_width - 1) >> 1);
- png_bytep dp = row + (size_t)row_width - 1;
- png_uint_32 shift = ((1U - ((row_width + 1U) & 0x01)) << 2);
- for (i = 0; i < row_width; i++)
- {
- *dp = (png_byte)((*sp >> shift) & 0x0f);
-
- if (shift == 4)
- {
- shift = 0;
- sp--;
- }
-
- else
- shift = 4;
-
- dp--;
- }
- break;
- }
-
- default:
- break;
- }
- row_info->bit_depth = 8;
- row_info->pixel_depth = (png_byte)(8 * row_info->channels);
- row_info->rowbytes = row_width * row_info->channels;
- }
-}
-#endif
-
-#ifdef PNG_READ_SHIFT_SUPPORTED
-/* Reverse the effects of png_do_shift. This routine merely shifts the
- * pixels back to their significant bits values. Thus, if you have
- * a row of bit depth 8, but only 5 are significant, this will shift
- * the values back to 0 through 31.
- */
-static void
-png_do_unshift(png_row_infop row_info, png_bytep row,
- png_const_color_8p sig_bits)
-{
- int color_type;
-
- png_debug(1, "in png_do_unshift");
-
- /* The palette case has already been handled in the _init routine. */
- color_type = row_info->color_type;
-
- if (color_type != PNG_COLOR_TYPE_PALETTE)
- {
- int shift[4];
- int channels = 0;
- int bit_depth = row_info->bit_depth;
-
- if ((color_type & PNG_COLOR_MASK_COLOR) != 0)
- {
- shift[channels++] = bit_depth - sig_bits->red;
- shift[channels++] = bit_depth - sig_bits->green;
- shift[channels++] = bit_depth - sig_bits->blue;
- }
-
- else
- {
- shift[channels++] = bit_depth - sig_bits->gray;
- }
-
- if ((color_type & PNG_COLOR_MASK_ALPHA) != 0)
- {
- shift[channels++] = bit_depth - sig_bits->alpha;
- }
-
- {
- int c, have_shift;
-
- for (c = have_shift = 0; c < channels; ++c)
- {
- /* A shift of more than the bit depth is an error condition but it
- * gets ignored here.
- */
- if (shift[c] <= 0 || shift[c] >= bit_depth)
- shift[c] = 0;
-
- else
- have_shift = 1;
- }
-
- if (have_shift == 0)
- return;
- }
-
- switch (bit_depth)
- {
- default:
- /* Must be 1bpp gray: should not be here! */
- /* NOTREACHED */
- break;
-
- case 2:
- /* Must be 2bpp gray */
- /* assert(channels == 1 && shift[0] == 1) */
- {
- png_bytep bp = row;
- png_bytep bp_end = bp + row_info->rowbytes;
-
- while (bp < bp_end)
- {
- int b = (*bp >> 1) & 0x55;
- *bp++ = (png_byte)b;
- }
- break;
- }
-
- case 4:
- /* Must be 4bpp gray */
- /* assert(channels == 1) */
- {
- png_bytep bp = row;
- png_bytep bp_end = bp + row_info->rowbytes;
- int gray_shift = shift[0];
- int mask = 0xf >> gray_shift;
-
- mask |= mask << 4;
-
- while (bp < bp_end)
- {
- int b = (*bp >> gray_shift) & mask;
- *bp++ = (png_byte)b;
- }
- break;
- }
-
- case 8:
- /* Single byte components, G, GA, RGB, RGBA */
- {
- png_bytep bp = row;
- png_bytep bp_end = bp + row_info->rowbytes;
- int channel = 0;
-
- while (bp < bp_end)
- {
- int b = *bp >> shift[channel];
- if (++channel >= channels)
- channel = 0;
- *bp++ = (png_byte)b;
- }
- break;
- }
-
-#ifdef PNG_READ_16BIT_SUPPORTED
- case 16:
- /* Double byte components, G, GA, RGB, RGBA */
- {
- png_bytep bp = row;
- png_bytep bp_end = bp + row_info->rowbytes;
- int channel = 0;
-
- while (bp < bp_end)
- {
- int value = (bp[0] << 8) + bp[1];
-
- value >>= shift[channel];
- if (++channel >= channels)
- channel = 0;
- *bp++ = (png_byte)(value >> 8);
- *bp++ = (png_byte)value;
- }
- break;
- }
-#endif
- }
- }
-}
-#endif
-
-#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
-/* Scale rows of bit depth 16 down to 8 accurately */
-static void
-png_do_scale_16_to_8(png_row_infop row_info, png_bytep row)
-{
- png_debug(1, "in png_do_scale_16_to_8");
-
- if (row_info->bit_depth == 16)
- {
- png_bytep sp = row; /* source */
- png_bytep dp = row; /* destination */
- png_bytep ep = sp + row_info->rowbytes; /* end+1 */
-
- while (sp < ep)
- {
- /* The input is an array of 16-bit components, these must be scaled to
- * 8 bits each. For a 16-bit value V the required value (from the PNG
- * specification) is:
- *
- * (V * 255) / 65535
- *
- * This reduces to round(V / 257), or floor((V + 128.5)/257)
- *
- * Represent V as the two byte value vhi.vlo. Make a guess that the
- * result is the top byte of V, vhi, then the correction to this value
- * is:
- *
- * error = floor(((V-vhi.vhi) + 128.5) / 257)
- * = floor(((vlo-vhi) + 128.5) / 257)
- *
- * This can be approximated using integer arithmetic (and a signed
- * shift):
- *
- * error = (vlo-vhi+128) >> 8;
- *
- * The approximate differs from the exact answer only when (vlo-vhi) is
- * 128; it then gives a correction of +1 when the exact correction is
- * 0. This gives 128 errors. The exact answer (correct for all 16-bit
- * input values) is:
- *
- * error = (vlo-vhi+128)*65535 >> 24;
- *
- * An alternative arithmetic calculation which also gives no errors is:
- *
- * (V * 255 + 32895) >> 16
- */
-
- png_int_32 tmp = *sp++; /* must be signed! */
- tmp += (((int)*sp++ - tmp + 128) * 65535) >> 24;
- *dp++ = (png_byte)tmp;
- }
-
- row_info->bit_depth = 8;
- row_info->pixel_depth = (png_byte)(8 * row_info->channels);
- row_info->rowbytes = row_info->width * row_info->channels;
- }
-}
-#endif
-
-#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
-static void
-/* Simply discard the low byte. This was the default behavior prior
- * to libpng-1.5.4.
- */
-png_do_chop(png_row_infop row_info, png_bytep row)
-{
- png_debug(1, "in png_do_chop");
-
- if (row_info->bit_depth == 16)
- {
- png_bytep sp = row; /* source */
- png_bytep dp = row; /* destination */
- png_bytep ep = sp + row_info->rowbytes; /* end+1 */
-
- while (sp < ep)
- {
- *dp++ = *sp;
- sp += 2; /* skip low byte */
- }
-
- row_info->bit_depth = 8;
- row_info->pixel_depth = (png_byte)(8 * row_info->channels);
- row_info->rowbytes = row_info->width * row_info->channels;
- }
-}
-#endif
-
-#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED
-static void
-png_do_read_swap_alpha(png_row_infop row_info, png_bytep row)
-{
- png_uint_32 row_width = row_info->width;
-
- png_debug(1, "in png_do_read_swap_alpha");
-
- if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
- {
- /* This converts from RGBA to ARGB */
- if (row_info->bit_depth == 8)
- {
- png_bytep sp = row + row_info->rowbytes;
- png_bytep dp = sp;
- png_byte save;
- png_uint_32 i;
-
- for (i = 0; i < row_width; i++)
- {
- save = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = save;
- }
- }
-
-#ifdef PNG_READ_16BIT_SUPPORTED
- /* This converts from RRGGBBAA to AARRGGBB */
- else
- {
- png_bytep sp = row + row_info->rowbytes;
- png_bytep dp = sp;
- png_byte save[2];
- png_uint_32 i;
-
- for (i = 0; i < row_width; i++)
- {
- save[0] = *(--sp);
- save[1] = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = save[0];
- *(--dp) = save[1];
- }
- }
-#endif
- }
-
- else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
- {
- /* This converts from GA to AG */
- if (row_info->bit_depth == 8)
- {
- png_bytep sp = row + row_info->rowbytes;
- png_bytep dp = sp;
- png_byte save;
- png_uint_32 i;
-
- for (i = 0; i < row_width; i++)
- {
- save = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = save;
- }
- }
-
-#ifdef PNG_READ_16BIT_SUPPORTED
- /* This converts from GGAA to AAGG */
- else
- {
- png_bytep sp = row + row_info->rowbytes;
- png_bytep dp = sp;
- png_byte save[2];
- png_uint_32 i;
-
- for (i = 0; i < row_width; i++)
- {
- save[0] = *(--sp);
- save[1] = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = save[0];
- *(--dp) = save[1];
- }
- }
-#endif
- }
-}
-#endif
-
-#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED
-static void
-png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
-{
- png_uint_32 row_width;
- png_debug(1, "in png_do_read_invert_alpha");
-
- row_width = row_info->width;
- if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
- {
- if (row_info->bit_depth == 8)
- {
- /* This inverts the alpha channel in RGBA */
- png_bytep sp = row + row_info->rowbytes;
- png_bytep dp = sp;
- png_uint_32 i;
-
- for (i = 0; i < row_width; i++)
- {
- *(--dp) = (png_byte)(255 - *(--sp));
-
-/* This does nothing:
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- We can replace it with:
-*/
- sp-=3;
- dp=sp;
- }
- }
-
-#ifdef PNG_READ_16BIT_SUPPORTED
- /* This inverts the alpha channel in RRGGBBAA */
- else
- {
- png_bytep sp = row + row_info->rowbytes;
- png_bytep dp = sp;
- png_uint_32 i;
-
- for (i = 0; i < row_width; i++)
- {
- *(--dp) = (png_byte)(255 - *(--sp));
- *(--dp) = (png_byte)(255 - *(--sp));
-
-/* This does nothing:
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- We can replace it with:
-*/
- sp-=6;
- dp=sp;
- }
- }
-#endif
- }
- else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
- {
- if (row_info->bit_depth == 8)
- {
- /* This inverts the alpha channel in GA */
- png_bytep sp = row + row_info->rowbytes;
- png_bytep dp = sp;
- png_uint_32 i;
-
- for (i = 0; i < row_width; i++)
- {
- *(--dp) = (png_byte)(255 - *(--sp));
- *(--dp) = *(--sp);
- }
- }
-
-#ifdef PNG_READ_16BIT_SUPPORTED
- else
- {
- /* This inverts the alpha channel in GGAA */
- png_bytep sp = row + row_info->rowbytes;
- png_bytep dp = sp;
- png_uint_32 i;
-
- for (i = 0; i < row_width; i++)
- {
- *(--dp) = (png_byte)(255 - *(--sp));
- *(--dp) = (png_byte)(255 - *(--sp));
-/*
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
-*/
- sp-=2;
- dp=sp;
- }
- }
-#endif
- }
-}
-#endif
-
-#ifdef PNG_READ_FILLER_SUPPORTED
-/* Add filler channel if we have RGB color */
-static void
-png_do_read_filler(png_row_infop row_info, png_bytep row,
- png_uint_32 filler, png_uint_32 flags)
-{
- png_uint_32 i;
- png_uint_32 row_width = row_info->width;
-
-#ifdef PNG_READ_16BIT_SUPPORTED
- png_byte hi_filler = (png_byte)(filler>>8);
-#endif
- png_byte lo_filler = (png_byte)filler;
-
- png_debug(1, "in png_do_read_filler");
-
- if (
- row_info->color_type == PNG_COLOR_TYPE_GRAY)
- {
- if (row_info->bit_depth == 8)
- {
- if ((flags & PNG_FLAG_FILLER_AFTER) != 0)
- {
- /* This changes the data from G to GX */
- png_bytep sp = row + (size_t)row_width;
- png_bytep dp = sp + (size_t)row_width;
- for (i = 1; i < row_width; i++)
- {
- *(--dp) = lo_filler;
- *(--dp) = *(--sp);
- }
- *(--dp) = lo_filler;
- row_info->channels = 2;
- row_info->pixel_depth = 16;
- row_info->rowbytes = row_width * 2;
- }
-
- else
- {
- /* This changes the data from G to XG */
- png_bytep sp = row + (size_t)row_width;
- png_bytep dp = sp + (size_t)row_width;
- for (i = 0; i < row_width; i++)
- {
- *(--dp) = *(--sp);
- *(--dp) = lo_filler;
- }
- row_info->channels = 2;
- row_info->pixel_depth = 16;
- row_info->rowbytes = row_width * 2;
- }
- }
-
-#ifdef PNG_READ_16BIT_SUPPORTED
- else if (row_info->bit_depth == 16)
- {
- if ((flags & PNG_FLAG_FILLER_AFTER) != 0)
- {
- /* This changes the data from GG to GGXX */
- png_bytep sp = row + (size_t)row_width * 2;
- png_bytep dp = sp + (size_t)row_width * 2;
- for (i = 1; i < row_width; i++)
- {
- *(--dp) = lo_filler;
- *(--dp) = hi_filler;
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- }
- *(--dp) = lo_filler;
- *(--dp) = hi_filler;
- row_info->channels = 2;
- row_info->pixel_depth = 32;
- row_info->rowbytes = row_width * 4;
- }
-
- else
- {
- /* This changes the data from GG to XXGG */
- png_bytep sp = row + (size_t)row_width * 2;
- png_bytep dp = sp + (size_t)row_width * 2;
- for (i = 0; i < row_width; i++)
- {
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = lo_filler;
- *(--dp) = hi_filler;
- }
- row_info->channels = 2;
- row_info->pixel_depth = 32;
- row_info->rowbytes = row_width * 4;
- }
- }
-#endif
- } /* COLOR_TYPE == GRAY */
- else if (row_info->color_type == PNG_COLOR_TYPE_RGB)
- {
- if (row_info->bit_depth == 8)
- {
- if ((flags & PNG_FLAG_FILLER_AFTER) != 0)
- {
- /* This changes the data from RGB to RGBX */
- png_bytep sp = row + (size_t)row_width * 3;
- png_bytep dp = sp + (size_t)row_width;
- for (i = 1; i < row_width; i++)
- {
- *(--dp) = lo_filler;
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- }
- *(--dp) = lo_filler;
- row_info->channels = 4;
- row_info->pixel_depth = 32;
- row_info->rowbytes = row_width * 4;
- }
-
- else
- {
- /* This changes the data from RGB to XRGB */
- png_bytep sp = row + (size_t)row_width * 3;
- png_bytep dp = sp + (size_t)row_width;
- for (i = 0; i < row_width; i++)
- {
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = lo_filler;
- }
- row_info->channels = 4;
- row_info->pixel_depth = 32;
- row_info->rowbytes = row_width * 4;
- }
- }
-
-#ifdef PNG_READ_16BIT_SUPPORTED
- else if (row_info->bit_depth == 16)
- {
- if ((flags & PNG_FLAG_FILLER_AFTER) != 0)
- {
- /* This changes the data from RRGGBB to RRGGBBXX */
- png_bytep sp = row + (size_t)row_width * 6;
- png_bytep dp = sp + (size_t)row_width * 2;
- for (i = 1; i < row_width; i++)
- {
- *(--dp) = lo_filler;
- *(--dp) = hi_filler;
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- }
- *(--dp) = lo_filler;
- *(--dp) = hi_filler;
- row_info->channels = 4;
- row_info->pixel_depth = 64;
- row_info->rowbytes = row_width * 8;
- }
-
- else
- {
- /* This changes the data from RRGGBB to XXRRGGBB */
- png_bytep sp = row + (size_t)row_width * 6;
- png_bytep dp = sp + (size_t)row_width * 2;
- for (i = 0; i < row_width; i++)
- {
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = lo_filler;
- *(--dp) = hi_filler;
- }
-
- row_info->channels = 4;
- row_info->pixel_depth = 64;
- row_info->rowbytes = row_width * 8;
- }
- }
-#endif
- } /* COLOR_TYPE == RGB */
-}
-#endif
-
-#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
-/* Expand grayscale files to RGB, with or without alpha */
-static void
-png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
-{
- png_uint_32 i;
- png_uint_32 row_width = row_info->width;
-
- png_debug(1, "in png_do_gray_to_rgb");
-
- if (row_info->bit_depth >= 8 &&
- (row_info->color_type & PNG_COLOR_MASK_COLOR) == 0)
- {
- if (row_info->color_type == PNG_COLOR_TYPE_GRAY)
- {
- if (row_info->bit_depth == 8)
- {
- /* This changes G to RGB */
- png_bytep sp = row + (size_t)row_width - 1;
- png_bytep dp = sp + (size_t)row_width * 2;
- for (i = 0; i < row_width; i++)
- {
- *(dp--) = *sp;
- *(dp--) = *sp;
- *(dp--) = *(sp--);
- }
- }
-
- else
- {
- /* This changes GG to RRGGBB */
- png_bytep sp = row + (size_t)row_width * 2 - 1;
- png_bytep dp = sp + (size_t)row_width * 4;
- for (i = 0; i < row_width; i++)
- {
- *(dp--) = *sp;
- *(dp--) = *(sp - 1);
- *(dp--) = *sp;
- *(dp--) = *(sp - 1);
- *(dp--) = *(sp--);
- *(dp--) = *(sp--);
- }
- }
- }
-
- else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
- {
- if (row_info->bit_depth == 8)
- {
- /* This changes GA to RGBA */
- png_bytep sp = row + (size_t)row_width * 2 - 1;
- png_bytep dp = sp + (size_t)row_width * 2;
- for (i = 0; i < row_width; i++)
- {
- *(dp--) = *(sp--);
- *(dp--) = *sp;
- *(dp--) = *sp;
- *(dp--) = *(sp--);
- }
- }
-
- else
- {
- /* This changes GGAA to RRGGBBAA */
- png_bytep sp = row + (size_t)row_width * 4 - 1;
- png_bytep dp = sp + (size_t)row_width * 4;
- for (i = 0; i < row_width; i++)
- {
- *(dp--) = *(sp--);
- *(dp--) = *(sp--);
- *(dp--) = *sp;
- *(dp--) = *(sp - 1);
- *(dp--) = *sp;
- *(dp--) = *(sp - 1);
- *(dp--) = *(sp--);
- *(dp--) = *(sp--);
- }
- }
- }
- row_info->channels = (png_byte)(row_info->channels + 2);
- row_info->color_type |= PNG_COLOR_MASK_COLOR;
- row_info->pixel_depth = (png_byte)(row_info->channels *
- row_info->bit_depth);
- row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);
- }
-}
-#endif
-
-#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
-/* Reduce RGB files to grayscale, with or without alpha
- * using the equation given in Poynton's ColorFAQ of 1998-01-04 at
- * <http://www.inforamp.net/~poynton/> (THIS LINK IS DEAD June 2008 but
- * versions dated 1998 through November 2002 have been archived at
- * https://web.archive.org/web/20000816232553/www.inforamp.net/
- * ~poynton/notes/colour_and_gamma/ColorFAQ.txt )
- * Charles Poynton poynton at poynton.com
- *
- * Y = 0.212671 * R + 0.715160 * G + 0.072169 * B
- *
- * which can be expressed with integers as
- *
- * Y = (6969 * R + 23434 * G + 2365 * B)/32768
- *
- * Poynton's current link (as of January 2003 through July 2011):
- * <http://www.poynton.com/notes/colour_and_gamma/>
- * has changed the numbers slightly:
- *
- * Y = 0.2126*R + 0.7152*G + 0.0722*B
- *
- * which can be expressed with integers as
- *
- * Y = (6966 * R + 23436 * G + 2366 * B)/32768
- *
- * Historically, however, libpng uses numbers derived from the ITU-R Rec 709
- * end point chromaticities and the D65 white point. Depending on the
- * precision used for the D65 white point this produces a variety of different
- * numbers, however if the four decimal place value used in ITU-R Rec 709 is
- * used (0.3127,0.3290) the Y calculation would be:
- *
- * Y = (6968 * R + 23435 * G + 2366 * B)/32768
- *
- * While this is correct the rounding results in an overflow for white, because
- * the sum of the rounded coefficients is 32769, not 32768. Consequently
- * libpng uses, instead, the closest non-overflowing approximation:
- *
- * Y = (6968 * R + 23434 * G + 2366 * B)/32768
- *
- * Starting with libpng-1.5.5, if the image being converted has a cHRM chunk
- * (including an sRGB chunk) then the chromaticities are used to calculate the
- * coefficients. See the chunk handling in pngrutil.c for more information.
- *
- * In all cases the calculation is to be done in a linear colorspace. If no
- * gamma information is available to correct the encoding of the original RGB
- * values this results in an implicit assumption that the original PNG RGB
- * values were linear.
- *
- * Other integer coefficients can be used via png_set_rgb_to_gray(). Because
- * the API takes just red and green coefficients the blue coefficient is
- * calculated to make the sum 32768. This will result in different rounding
- * to that used above.
- */
-static int
-png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row)
-{
- int rgb_error = 0;
-
- png_debug(1, "in png_do_rgb_to_gray");
-
- if ((row_info->color_type & PNG_COLOR_MASK_PALETTE) == 0 &&
- (row_info->color_type & PNG_COLOR_MASK_COLOR) != 0)
- {
- png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff;
- png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff;
- png_uint_32 bc = 32768 - rc - gc;
- png_uint_32 row_width = row_info->width;
- int have_alpha = (row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0;
-
- if (row_info->bit_depth == 8)
- {
-#ifdef PNG_READ_GAMMA_SUPPORTED
- /* Notice that gamma to/from 1 are not necessarily inverses (if
- * there is an overall gamma correction). Prior to 1.5.5 this code
- * checked the linearized values for equality; this doesn't match
- * the documentation, the original values must be checked.
- */
- if (png_ptr->gamma_from_1 != NULL && png_ptr->gamma_to_1 != NULL)
- {
- png_bytep sp = row;
- png_bytep dp = row;
- png_uint_32 i;
-
- for (i = 0; i < row_width; i++)
- {
- png_byte red = *(sp++);
- png_byte green = *(sp++);
- png_byte blue = *(sp++);
-
- if (red != green || red != blue)
- {
- red = png_ptr->gamma_to_1[red];
- green = png_ptr->gamma_to_1[green];
- blue = png_ptr->gamma_to_1[blue];
-
- rgb_error |= 1;
- *(dp++) = png_ptr->gamma_from_1[
- (rc*red + gc*green + bc*blue + 16384)>>15];
- }
-
- else
- {
- /* If there is no overall correction the table will not be
- * set.
- */
- if (png_ptr->gamma_table != NULL)
- red = png_ptr->gamma_table[red];
-
- *(dp++) = red;
- }
-
- if (have_alpha != 0)
- *(dp++) = *(sp++);
- }
- }
- else
-#endif
- {
- png_bytep sp = row;
- png_bytep dp = row;
- png_uint_32 i;
-
- for (i = 0; i < row_width; i++)
- {
- png_byte red = *(sp++);
- png_byte green = *(sp++);
- png_byte blue = *(sp++);
-
- if (red != green || red != blue)
- {
- rgb_error |= 1;
- /* NOTE: this is the historical approach which simply
- * truncates the results.
- */
- *(dp++) = (png_byte)((rc*red + gc*green + bc*blue)>>15);
- }
-
- else
- *(dp++) = red;
-
- if (have_alpha != 0)
- *(dp++) = *(sp++);
- }
- }
- }
-
- else /* RGB bit_depth == 16 */
- {
-#ifdef PNG_READ_GAMMA_SUPPORTED
- if (png_ptr->gamma_16_to_1 != NULL && png_ptr->gamma_16_from_1 != NULL)
- {
- png_bytep sp = row;
- png_bytep dp = row;
- png_uint_32 i;
-
- for (i = 0; i < row_width; i++)
- {
- png_uint_16 red, green, blue, w;
- png_byte hi,lo;
-
- hi=*(sp)++; lo=*(sp)++; red = (png_uint_16)((hi << 8) | (lo));
- hi=*(sp)++; lo=*(sp)++; green = (png_uint_16)((hi << 8) | (lo));
- hi=*(sp)++; lo=*(sp)++; blue = (png_uint_16)((hi << 8) | (lo));
-
- if (red == green && red == blue)
- {
- if (png_ptr->gamma_16_table != NULL)
- w = png_ptr->gamma_16_table[(red & 0xff)
- >> png_ptr->gamma_shift][red >> 8];
-
- else
- w = red;
- }
-
- else
- {
- png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red & 0xff)
- >> png_ptr->gamma_shift][red>>8];
- png_uint_16 green_1 =
- png_ptr->gamma_16_to_1[(green & 0xff) >>
- png_ptr->gamma_shift][green>>8];
- png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue & 0xff)
- >> png_ptr->gamma_shift][blue>>8];
- png_uint_16 gray16 = (png_uint_16)((rc*red_1 + gc*green_1
- + bc*blue_1 + 16384)>>15);
- w = png_ptr->gamma_16_from_1[(gray16 & 0xff) >>
- png_ptr->gamma_shift][gray16 >> 8];
- rgb_error |= 1;
- }
-
- *(dp++) = (png_byte)((w>>8) & 0xff);
- *(dp++) = (png_byte)(w & 0xff);
-
- if (have_alpha != 0)
- {
- *(dp++) = *(sp++);
- *(dp++) = *(sp++);
- }
- }
- }
- else
-#endif
- {
- png_bytep sp = row;
- png_bytep dp = row;
- png_uint_32 i;
-
- for (i = 0; i < row_width; i++)
- {
- png_uint_16 red, green, blue, gray16;
- png_byte hi,lo;
-
- hi=*(sp)++; lo=*(sp)++; red = (png_uint_16)((hi << 8) | (lo));
- hi=*(sp)++; lo=*(sp)++; green = (png_uint_16)((hi << 8) | (lo));
- hi=*(sp)++; lo=*(sp)++; blue = (png_uint_16)((hi << 8) | (lo));
-
- if (red != green || red != blue)
- rgb_error |= 1;
-
- /* From 1.5.5 in the 16-bit case do the accurate conversion even
- * in the 'fast' case - this is because this is where the code
- * ends up when handling linear 16-bit data.
- */
- gray16 = (png_uint_16)((rc*red + gc*green + bc*blue + 16384) >>
- 15);
- *(dp++) = (png_byte)((gray16 >> 8) & 0xff);
- *(dp++) = (png_byte)(gray16 & 0xff);
-
- if (have_alpha != 0)
- {
- *(dp++) = *(sp++);
- *(dp++) = *(sp++);
- }
- }
- }
- }
-
- row_info->channels = (png_byte)(row_info->channels - 2);
- row_info->color_type = (png_byte)(row_info->color_type &
- ~PNG_COLOR_MASK_COLOR);
- row_info->pixel_depth = (png_byte)(row_info->channels *
- row_info->bit_depth);
- row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);
- }
- return rgb_error;
-}
-#endif
-
-#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
- defined(PNG_READ_ALPHA_MODE_SUPPORTED)
-/* Replace any alpha or transparency with the supplied background color.
- * "background" is already in the screen gamma, while "background_1" is
- * at a gamma of 1.0. Paletted files have already been taken care of.
- */
-static void
-png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
-{
-#ifdef PNG_READ_GAMMA_SUPPORTED
- png_const_bytep gamma_table = png_ptr->gamma_table;
- png_const_bytep gamma_from_1 = png_ptr->gamma_from_1;
- png_const_bytep gamma_to_1 = png_ptr->gamma_to_1;
- png_const_uint_16pp gamma_16 = png_ptr->gamma_16_table;
- png_const_uint_16pp gamma_16_from_1 = png_ptr->gamma_16_from_1;
- png_const_uint_16pp gamma_16_to_1 = png_ptr->gamma_16_to_1;
- int gamma_shift = png_ptr->gamma_shift;
- int optimize = (png_ptr->flags & PNG_FLAG_OPTIMIZE_ALPHA) != 0;
-#endif
-
- png_bytep sp;
- png_uint_32 i;
- png_uint_32 row_width = row_info->width;
- int shift;
-
- png_debug(1, "in png_do_compose");
-
- switch (row_info->color_type)
- {
- case PNG_COLOR_TYPE_GRAY:
- {
- switch (row_info->bit_depth)
- {
- case 1:
- {
- sp = row;
- shift = 7;
- for (i = 0; i < row_width; i++)
- {
- if ((png_uint_16)((*sp >> shift) & 0x01)
- == png_ptr->trans_color.gray)
- {
- unsigned int tmp = *sp & (0x7f7f >> (7 - shift));
- tmp |=
- (unsigned int)(png_ptr->background.gray << shift);
- *sp = (png_byte)(tmp & 0xff);
- }
-
- if (shift == 0)
- {
- shift = 7;
- sp++;
- }
-
- else
- shift--;
- }
- break;
- }
-
- case 2:
- {
-#ifdef PNG_READ_GAMMA_SUPPORTED
- if (gamma_table != NULL)
- {
- sp = row;
- shift = 6;
- for (i = 0; i < row_width; i++)
- {
- if ((png_uint_16)((*sp >> shift) & 0x03)
- == png_ptr->trans_color.gray)
- {
- unsigned int tmp = *sp & (0x3f3f >> (6 - shift));
- tmp |=
- (unsigned int)png_ptr->background.gray << shift;
- *sp = (png_byte)(tmp & 0xff);
- }
-
- else
- {
- unsigned int p = (*sp >> shift) & 0x03;
- unsigned int g = (gamma_table [p | (p << 2) |
- (p << 4) | (p << 6)] >> 6) & 0x03;
- unsigned int tmp = *sp & (0x3f3f >> (6 - shift));
- tmp |= (unsigned int)(g << shift);
- *sp = (png_byte)(tmp & 0xff);
- }
-
- if (shift == 0)
- {
- shift = 6;
- sp++;
- }
-
- else
- shift -= 2;
- }
- }
-
- else
-#endif
- {
- sp = row;
- shift = 6;
- for (i = 0; i < row_width; i++)
- {
- if ((png_uint_16)((*sp >> shift) & 0x03)
- == png_ptr->trans_color.gray)
- {
- unsigned int tmp = *sp & (0x3f3f >> (6 - shift));
- tmp |=
- (unsigned int)png_ptr->background.gray << shift;
- *sp = (png_byte)(tmp & 0xff);
- }
-
- if (shift == 0)
- {
- shift = 6;
- sp++;
- }
-
- else
- shift -= 2;
- }
- }
- break;
- }
-
- case 4:
- {
-#ifdef PNG_READ_GAMMA_SUPPORTED
- if (gamma_table != NULL)
- {
- sp = row;
- shift = 4;
- for (i = 0; i < row_width; i++)
- {
- if ((png_uint_16)((*sp >> shift) & 0x0f)
- == png_ptr->trans_color.gray)
- {
- unsigned int tmp = *sp & (0x0f0f >> (4 - shift));
- tmp |=
- (unsigned int)(png_ptr->background.gray << shift);
- *sp = (png_byte)(tmp & 0xff);
- }
-
- else
- {
- unsigned int p = (*sp >> shift) & 0x0f;
- unsigned int g = (gamma_table[p | (p << 4)] >> 4) &
- 0x0f;
- unsigned int tmp = *sp & (0x0f0f >> (4 - shift));
- tmp |= (unsigned int)(g << shift);
- *sp = (png_byte)(tmp & 0xff);
- }
-
- if (shift == 0)
- {
- shift = 4;
- sp++;
- }
-
- else
- shift -= 4;
- }
- }
-
- else
-#endif
- {
- sp = row;
- shift = 4;
- for (i = 0; i < row_width; i++)
- {
- if ((png_uint_16)((*sp >> shift) & 0x0f)
- == png_ptr->trans_color.gray)
- {
- unsigned int tmp = *sp & (0x0f0f >> (4 - shift));
- tmp |=
- (unsigned int)(png_ptr->background.gray << shift);
- *sp = (png_byte)(tmp & 0xff);
- }
-
- if (shift == 0)
- {
- shift = 4;
- sp++;
- }
-
- else
- shift -= 4;
- }
- }
- break;
- }
-
- case 8:
- {
-#ifdef PNG_READ_GAMMA_SUPPORTED
- if (gamma_table != NULL)
- {
- sp = row;
- for (i = 0; i < row_width; i++, sp++)
- {
- if (*sp == png_ptr->trans_color.gray)
- *sp = (png_byte)png_ptr->background.gray;
-
- else
- *sp = gamma_table[*sp];
- }
- }
- else
-#endif
- {
- sp = row;
- for (i = 0; i < row_width; i++, sp++)
- {
- if (*sp == png_ptr->trans_color.gray)
- *sp = (png_byte)png_ptr->background.gray;
- }
- }
- break;
- }
-
- case 16:
- {
-#ifdef PNG_READ_GAMMA_SUPPORTED
- if (gamma_16 != NULL)
- {
- sp = row;
- for (i = 0; i < row_width; i++, sp += 2)
- {
- png_uint_16 v;
-
- v = (png_uint_16)(((*sp) << 8) + *(sp + 1));
-
- if (v == png_ptr->trans_color.gray)
- {
- /* Background is already in screen gamma */
- *sp = (png_byte)((png_ptr->background.gray >> 8)
- & 0xff);
- *(sp + 1) = (png_byte)(png_ptr->background.gray
- & 0xff);
- }
-
- else
- {
- v = gamma_16[*(sp + 1) >> gamma_shift][*sp];
- *sp = (png_byte)((v >> 8) & 0xff);
- *(sp + 1) = (png_byte)(v & 0xff);
- }
- }
- }
- else
-#endif
- {
- sp = row;
- for (i = 0; i < row_width; i++, sp += 2)
- {
- png_uint_16 v;
-
- v = (png_uint_16)(((*sp) << 8) + *(sp + 1));
-
- if (v == png_ptr->trans_color.gray)
- {
- *sp = (png_byte)((png_ptr->background.gray >> 8)
- & 0xff);
- *(sp + 1) = (png_byte)(png_ptr->background.gray
- & 0xff);
- }
- }
- }
- break;
- }
-
- default:
- break;
- }
- break;
- }
-
- case PNG_COLOR_TYPE_RGB:
- {
- if (row_info->bit_depth == 8)
- {
-#ifdef PNG_READ_GAMMA_SUPPORTED
- if (gamma_table != NULL)
- {
- sp = row;
- for (i = 0; i < row_width; i++, sp += 3)
- {
- if (*sp == png_ptr->trans_color.red &&
- *(sp + 1) == png_ptr->trans_color.green &&
- *(sp + 2) == png_ptr->trans_color.blue)
- {
- *sp = (png_byte)png_ptr->background.red;
- *(sp + 1) = (png_byte)png_ptr->background.green;
- *(sp + 2) = (png_byte)png_ptr->background.blue;
- }
-
- else
- {
- *sp = gamma_table[*sp];
- *(sp + 1) = gamma_table[*(sp + 1)];
- *(sp + 2) = gamma_table[*(sp + 2)];
- }
- }
- }
- else
-#endif
- {
- sp = row;
- for (i = 0; i < row_width; i++, sp += 3)
- {
- if (*sp == png_ptr->trans_color.red &&
- *(sp + 1) == png_ptr->trans_color.green &&
- *(sp + 2) == png_ptr->trans_color.blue)
- {
- *sp = (png_byte)png_ptr->background.red;
- *(sp + 1) = (png_byte)png_ptr->background.green;
- *(sp + 2) = (png_byte)png_ptr->background.blue;
- }
- }
- }
- }
- else /* if (row_info->bit_depth == 16) */
- {
-#ifdef PNG_READ_GAMMA_SUPPORTED
- if (gamma_16 != NULL)
- {
- sp = row;
- for (i = 0; i < row_width; i++, sp += 6)
- {
- png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1));
-
- png_uint_16 g = (png_uint_16)(((*(sp + 2)) << 8)
- + *(sp + 3));
-
- png_uint_16 b = (png_uint_16)(((*(sp + 4)) << 8)
- + *(sp + 5));
-
- if (r == png_ptr->trans_color.red &&
- g == png_ptr->trans_color.green &&
- b == png_ptr->trans_color.blue)
- {
- /* Background is already in screen gamma */
- *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff);
- *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff);
- *(sp + 2) = (png_byte)((png_ptr->background.green >> 8)
- & 0xff);
- *(sp + 3) = (png_byte)(png_ptr->background.green
- & 0xff);
- *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8)
- & 0xff);
- *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff);
- }
-
- else
- {
- png_uint_16 v = gamma_16[*(sp + 1) >> gamma_shift][*sp];
- *sp = (png_byte)((v >> 8) & 0xff);
- *(sp + 1) = (png_byte)(v & 0xff);
-
- v = gamma_16[*(sp + 3) >> gamma_shift][*(sp + 2)];
- *(sp + 2) = (png_byte)((v >> 8) & 0xff);
- *(sp + 3) = (png_byte)(v & 0xff);
-
- v = gamma_16[*(sp + 5) >> gamma_shift][*(sp + 4)];
- *(sp + 4) = (png_byte)((v >> 8) & 0xff);
- *(sp + 5) = (png_byte)(v & 0xff);
- }
- }
- }
-
- else
-#endif
- {
- sp = row;
- for (i = 0; i < row_width; i++, sp += 6)
- {
- png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1));
-
- png_uint_16 g = (png_uint_16)(((*(sp + 2)) << 8)
- + *(sp + 3));
-
- png_uint_16 b = (png_uint_16)(((*(sp + 4)) << 8)
- + *(sp + 5));
-
- if (r == png_ptr->trans_color.red &&
- g == png_ptr->trans_color.green &&
- b == png_ptr->trans_color.blue)
- {
- *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff);
- *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff);
- *(sp + 2) = (png_byte)((png_ptr->background.green >> 8)
- & 0xff);
- *(sp + 3) = (png_byte)(png_ptr->background.green
- & 0xff);
- *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8)
- & 0xff);
- *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff);
- }
- }
- }
- }
- break;
- }
-
- case PNG_COLOR_TYPE_GRAY_ALPHA:
- {
- if (row_info->bit_depth == 8)
- {
-#ifdef PNG_READ_GAMMA_SUPPORTED
- if (gamma_to_1 != NULL && gamma_from_1 != NULL &&
- gamma_table != NULL)
- {
- sp = row;
- for (i = 0; i < row_width; i++, sp += 2)
- {
- png_uint_16 a = *(sp + 1);
-
- if (a == 0xff)
- *sp = gamma_table[*sp];
-
- else if (a == 0)
- {
- /* Background is already in screen gamma */
- *sp = (png_byte)png_ptr->background.gray;
- }
-
- else
- {
- png_byte v, w;
-
- v = gamma_to_1[*sp];
- png_composite(w, v, a, png_ptr->background_1.gray);
- if (optimize == 0)
- w = gamma_from_1[w];
- *sp = w;
- }
- }
- }
- else
-#endif
- {
- sp = row;
- for (i = 0; i < row_width; i++, sp += 2)
- {
- png_byte a = *(sp + 1);
-
- if (a == 0)
- *sp = (png_byte)png_ptr->background.gray;
-
- else if (a < 0xff)
- png_composite(*sp, *sp, a, png_ptr->background.gray);
- }
- }
- }
- else /* if (png_ptr->bit_depth == 16) */
- {
-#ifdef PNG_READ_GAMMA_SUPPORTED
- if (gamma_16 != NULL && gamma_16_from_1 != NULL &&
- gamma_16_to_1 != NULL)
- {
- sp = row;
- for (i = 0; i < row_width; i++, sp += 4)
- {
- png_uint_16 a = (png_uint_16)(((*(sp + 2)) << 8)
- + *(sp + 3));
-
- if (a == (png_uint_16)0xffff)
- {
- png_uint_16 v;
-
- v = gamma_16[*(sp + 1) >> gamma_shift][*sp];
- *sp = (png_byte)((v >> 8) & 0xff);
- *(sp + 1) = (png_byte)(v & 0xff);
- }
-
- else if (a == 0)
- {
- /* Background is already in screen gamma */
- *sp = (png_byte)((png_ptr->background.gray >> 8)
- & 0xff);
- *(sp + 1) = (png_byte)(png_ptr->background.gray & 0xff);
- }
-
- else
- {
- png_uint_16 g, v, w;
-
- g = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp];
- png_composite_16(v, g, a, png_ptr->background_1.gray);
- if (optimize != 0)
- w = v;
- else
- w = gamma_16_from_1[(v & 0xff) >>
- gamma_shift][v >> 8];
- *sp = (png_byte)((w >> 8) & 0xff);
- *(sp + 1) = (png_byte)(w & 0xff);
- }
- }
- }
- else
-#endif
- {
- sp = row;
- for (i = 0; i < row_width; i++, sp += 4)
- {
- png_uint_16 a = (png_uint_16)(((*(sp + 2)) << 8)
- + *(sp + 3));
-
- if (a == 0)
- {
- *sp = (png_byte)((png_ptr->background.gray >> 8)
- & 0xff);
- *(sp + 1) = (png_byte)(png_ptr->background.gray & 0xff);
- }
-
- else if (a < 0xffff)
- {
- png_uint_16 g, v;
-
- g = (png_uint_16)(((*sp) << 8) + *(sp + 1));
- png_composite_16(v, g, a, png_ptr->background.gray);
- *sp = (png_byte)((v >> 8) & 0xff);
- *(sp + 1) = (png_byte)(v & 0xff);
- }
- }
- }
- }
- break;
- }
-
- case PNG_COLOR_TYPE_RGB_ALPHA:
- {
- if (row_info->bit_depth == 8)
- {
-#ifdef PNG_READ_GAMMA_SUPPORTED
- if (gamma_to_1 != NULL && gamma_from_1 != NULL &&
- gamma_table != NULL)
- {
- sp = row;
- for (i = 0; i < row_width; i++, sp += 4)
- {
- png_byte a = *(sp + 3);
-
- if (a == 0xff)
- {
- *sp = gamma_table[*sp];
- *(sp + 1) = gamma_table[*(sp + 1)];
- *(sp + 2) = gamma_table[*(sp + 2)];
- }
-
- else if (a == 0)
- {
- /* Background is already in screen gamma */
- *sp = (png_byte)png_ptr->background.red;
- *(sp + 1) = (png_byte)png_ptr->background.green;
- *(sp + 2) = (png_byte)png_ptr->background.blue;
- }
-
- else
- {
- png_byte v, w;
-
- v = gamma_to_1[*sp];
- png_composite(w, v, a, png_ptr->background_1.red);
- if (optimize == 0) w = gamma_from_1[w];
- *sp = w;
-
- v = gamma_to_1[*(sp + 1)];
- png_composite(w, v, a, png_ptr->background_1.green);
- if (optimize == 0) w = gamma_from_1[w];
- *(sp + 1) = w;
-
- v = gamma_to_1[*(sp + 2)];
- png_composite(w, v, a, png_ptr->background_1.blue);
- if (optimize == 0) w = gamma_from_1[w];
- *(sp + 2) = w;
- }
- }
- }
- else
-#endif
- {
- sp = row;
- for (i = 0; i < row_width; i++, sp += 4)
- {
- png_byte a = *(sp + 3);
-
- if (a == 0)
- {
- *sp = (png_byte)png_ptr->background.red;
- *(sp + 1) = (png_byte)png_ptr->background.green;
- *(sp + 2) = (png_byte)png_ptr->background.blue;
- }
-
- else if (a < 0xff)
- {
- png_composite(*sp, *sp, a, png_ptr->background.red);
-
- png_composite(*(sp + 1), *(sp + 1), a,
- png_ptr->background.green);
-
- png_composite(*(sp + 2), *(sp + 2), a,
- png_ptr->background.blue);
- }
- }
- }
- }
- else /* if (row_info->bit_depth == 16) */
- {
-#ifdef PNG_READ_GAMMA_SUPPORTED
- if (gamma_16 != NULL && gamma_16_from_1 != NULL &&
- gamma_16_to_1 != NULL)
- {
- sp = row;
- for (i = 0; i < row_width; i++, sp += 8)
- {
- png_uint_16 a = (png_uint_16)(((png_uint_16)(*(sp + 6))
- << 8) + (png_uint_16)(*(sp + 7)));
-
- if (a == (png_uint_16)0xffff)
- {
- png_uint_16 v;
-
- v = gamma_16[*(sp + 1) >> gamma_shift][*sp];
- *sp = (png_byte)((v >> 8) & 0xff);
- *(sp + 1) = (png_byte)(v & 0xff);
-
- v = gamma_16[*(sp + 3) >> gamma_shift][*(sp + 2)];
- *(sp + 2) = (png_byte)((v >> 8) & 0xff);
- *(sp + 3) = (png_byte)(v & 0xff);
-
- v = gamma_16[*(sp + 5) >> gamma_shift][*(sp + 4)];
- *(sp + 4) = (png_byte)((v >> 8) & 0xff);
- *(sp + 5) = (png_byte)(v & 0xff);
- }
-
- else if (a == 0)
- {
- /* Background is already in screen gamma */
- *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff);
- *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff);
- *(sp + 2) = (png_byte)((png_ptr->background.green >> 8)
- & 0xff);
- *(sp + 3) = (png_byte)(png_ptr->background.green
- & 0xff);
- *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8)
- & 0xff);
- *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff);
- }
-
- else
- {
- png_uint_16 v, w;
-
- v = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp];
- png_composite_16(w, v, a, png_ptr->background_1.red);
- if (optimize == 0)
- w = gamma_16_from_1[((w & 0xff) >> gamma_shift)][w >>
- 8];
- *sp = (png_byte)((w >> 8) & 0xff);
- *(sp + 1) = (png_byte)(w & 0xff);
-
- v = gamma_16_to_1[*(sp + 3) >> gamma_shift][*(sp + 2)];
- png_composite_16(w, v, a, png_ptr->background_1.green);
- if (optimize == 0)
- w = gamma_16_from_1[((w & 0xff) >> gamma_shift)][w >>
- 8];
-
- *(sp + 2) = (png_byte)((w >> 8) & 0xff);
- *(sp + 3) = (png_byte)(w & 0xff);
-
- v = gamma_16_to_1[*(sp + 5) >> gamma_shift][*(sp + 4)];
- png_composite_16(w, v, a, png_ptr->background_1.blue);
- if (optimize == 0)
- w = gamma_16_from_1[((w & 0xff) >> gamma_shift)][w >>
- 8];
-
- *(sp + 4) = (png_byte)((w >> 8) & 0xff);
- *(sp + 5) = (png_byte)(w & 0xff);
- }
- }
- }
-
- else
-#endif
- {
- sp = row;
- for (i = 0; i < row_width; i++, sp += 8)
- {
- png_uint_16 a = (png_uint_16)(((png_uint_16)(*(sp + 6))
- << 8) + (png_uint_16)(*(sp + 7)));
-
- if (a == 0)
- {
- *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff);
- *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff);
- *(sp + 2) = (png_byte)((png_ptr->background.green >> 8)
- & 0xff);
- *(sp + 3) = (png_byte)(png_ptr->background.green
- & 0xff);
- *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8)
- & 0xff);
- *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff);
- }
-
- else if (a < 0xffff)
- {
- png_uint_16 v;
-
- png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1));
- png_uint_16 g = (png_uint_16)(((*(sp + 2)) << 8)
- + *(sp + 3));
- png_uint_16 b = (png_uint_16)(((*(sp + 4)) << 8)
- + *(sp + 5));
-
- png_composite_16(v, r, a, png_ptr->background.red);
- *sp = (png_byte)((v >> 8) & 0xff);
- *(sp + 1) = (png_byte)(v & 0xff);
-
- png_composite_16(v, g, a, png_ptr->background.green);
- *(sp + 2) = (png_byte)((v >> 8) & 0xff);
- *(sp + 3) = (png_byte)(v & 0xff);
-
- png_composite_16(v, b, a, png_ptr->background.blue);
- *(sp + 4) = (png_byte)((v >> 8) & 0xff);
- *(sp + 5) = (png_byte)(v & 0xff);
- }
- }
- }
- }
- break;
- }
-
- default:
- break;
- }
-}
-#endif /* READ_BACKGROUND || READ_ALPHA_MODE */
-
-#ifdef PNG_READ_GAMMA_SUPPORTED
-/* Gamma correct the image, avoiding the alpha channel. Make sure
- * you do this after you deal with the transparency issue on grayscale
- * or RGB images. If your bit depth is 8, use gamma_table, if it
- * is 16, use gamma_16_table and gamma_shift. Build these with
- * build_gamma_table().
- */
-static void
-png_do_gamma(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
-{
- png_const_bytep gamma_table = png_ptr->gamma_table;
- png_const_uint_16pp gamma_16_table = png_ptr->gamma_16_table;
- int gamma_shift = png_ptr->gamma_shift;
-
- png_bytep sp;
- png_uint_32 i;
- png_uint_32 row_width=row_info->width;
-
- png_debug(1, "in png_do_gamma");
-
- if (((row_info->bit_depth <= 8 && gamma_table != NULL) ||
- (row_info->bit_depth == 16 && gamma_16_table != NULL)))
- {
- switch (row_info->color_type)
- {
- case PNG_COLOR_TYPE_RGB:
- {
- if (row_info->bit_depth == 8)
- {
- sp = row;
- for (i = 0; i < row_width; i++)
- {
- *sp = gamma_table[*sp];
- sp++;
- *sp = gamma_table[*sp];
- sp++;
- *sp = gamma_table[*sp];
- sp++;
- }
- }
-
- else /* if (row_info->bit_depth == 16) */
- {
- sp = row;
- for (i = 0; i < row_width; i++)
- {
- png_uint_16 v;
-
- v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];
- *sp = (png_byte)((v >> 8) & 0xff);
- *(sp + 1) = (png_byte)(v & 0xff);
- sp += 2;
-
- v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];
- *sp = (png_byte)((v >> 8) & 0xff);
- *(sp + 1) = (png_byte)(v & 0xff);
- sp += 2;
-
- v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];
- *sp = (png_byte)((v >> 8) & 0xff);
- *(sp + 1) = (png_byte)(v & 0xff);
- sp += 2;
- }
- }
- break;
- }
-
- case PNG_COLOR_TYPE_RGB_ALPHA:
- {
- if (row_info->bit_depth == 8)
- {
- sp = row;
- for (i = 0; i < row_width; i++)
- {
- *sp = gamma_table[*sp];
- sp++;
-
- *sp = gamma_table[*sp];
- sp++;
-
- *sp = gamma_table[*sp];
- sp++;
-
- sp++;
- }
- }
-
- else /* if (row_info->bit_depth == 16) */
- {
- sp = row;
- for (i = 0; i < row_width; i++)
- {
- png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];
- *sp = (png_byte)((v >> 8) & 0xff);
- *(sp + 1) = (png_byte)(v & 0xff);
- sp += 2;
-
- v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];
- *sp = (png_byte)((v >> 8) & 0xff);
- *(sp + 1) = (png_byte)(v & 0xff);
- sp += 2;
-
- v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];
- *sp = (png_byte)((v >> 8) & 0xff);
- *(sp + 1) = (png_byte)(v & 0xff);
- sp += 4;
- }
- }
- break;
- }
-
- case PNG_COLOR_TYPE_GRAY_ALPHA:
- {
- if (row_info->bit_depth == 8)
- {
- sp = row;
- for (i = 0; i < row_width; i++)
- {
- *sp = gamma_table[*sp];
- sp += 2;
- }
- }
-
- else /* if (row_info->bit_depth == 16) */
- {
- sp = row;
- for (i = 0; i < row_width; i++)
- {
- png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];
- *sp = (png_byte)((v >> 8) & 0xff);
- *(sp + 1) = (png_byte)(v & 0xff);
- sp += 4;
- }
- }
- break;
- }
-
- case PNG_COLOR_TYPE_GRAY:
- {
- if (row_info->bit_depth == 2)
- {
- sp = row;
- for (i = 0; i < row_width; i += 4)
- {
- int a = *sp & 0xc0;
- int b = *sp & 0x30;
- int c = *sp & 0x0c;
- int d = *sp & 0x03;
-
- *sp = (png_byte)(
- ((((int)gamma_table[a|(a>>2)|(a>>4)|(a>>6)]) ) & 0xc0)|
- ((((int)gamma_table[(b<<2)|b|(b>>2)|(b>>4)])>>2) & 0x30)|
- ((((int)gamma_table[(c<<4)|(c<<2)|c|(c>>2)])>>4) & 0x0c)|
- ((((int)gamma_table[(d<<6)|(d<<4)|(d<<2)|d])>>6) ));
- sp++;
- }
- }
-
- if (row_info->bit_depth == 4)
- {
- sp = row;
- for (i = 0; i < row_width; i += 2)
- {
- int msb = *sp & 0xf0;
- int lsb = *sp & 0x0f;
-
- *sp = (png_byte)((((int)gamma_table[msb | (msb >> 4)]) & 0xf0)
- | (((int)gamma_table[(lsb << 4) | lsb]) >> 4));
- sp++;
- }
- }
-
- else if (row_info->bit_depth == 8)
- {
- sp = row;
- for (i = 0; i < row_width; i++)
- {
- *sp = gamma_table[*sp];
- sp++;
- }
- }
-
- else if (row_info->bit_depth == 16)
- {
- sp = row;
- for (i = 0; i < row_width; i++)
- {
- png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];
- *sp = (png_byte)((v >> 8) & 0xff);
- *(sp + 1) = (png_byte)(v & 0xff);
- sp += 2;
- }
- }
- break;
- }
-
- default:
- break;
- }
- }
-}
-#endif
-
-#ifdef PNG_READ_ALPHA_MODE_SUPPORTED
-/* Encode the alpha channel to the output gamma (the input channel is always
- * linear.) Called only with color types that have an alpha channel. Needs the
- * from_1 tables.
- */
-static void
-png_do_encode_alpha(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
-{
- png_uint_32 row_width = row_info->width;
-
- png_debug(1, "in png_do_encode_alpha");
-
- if ((row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0)
- {
- if (row_info->bit_depth == 8)
- {
- png_bytep table = png_ptr->gamma_from_1;
-
- if (table != NULL)
- {
- int step = (row_info->color_type & PNG_COLOR_MASK_COLOR) ? 4 : 2;
-
- /* The alpha channel is the last component: */
- row += step - 1;
-
- for (; row_width > 0; --row_width, row += step)
- *row = table[*row];
-
- return;
- }
- }
-
- else if (row_info->bit_depth == 16)
- {
- png_uint_16pp table = png_ptr->gamma_16_from_1;
- int gamma_shift = png_ptr->gamma_shift;
-
- if (table != NULL)
- {
- int step = (row_info->color_type & PNG_COLOR_MASK_COLOR) ? 8 : 4;
-
- /* The alpha channel is the last component: */
- row += step - 2;
-
- for (; row_width > 0; --row_width, row += step)
- {
- png_uint_16 v;
-
- v = table[*(row + 1) >> gamma_shift][*row];
- *row = (png_byte)((v >> 8) & 0xff);
- *(row + 1) = (png_byte)(v & 0xff);
- }
-
- return;
- }
- }
- }
-
- /* Only get to here if called with a weird row_info; no harm has been done,
- * so just issue a warning.
- */
- png_warning(png_ptr, "png_do_encode_alpha: unexpected call");
-}
-#endif
-
-#ifdef PNG_READ_EXPAND_SUPPORTED
-/* Expands a palette row to an RGB or RGBA row depending
- * upon whether you supply trans and num_trans.
- */
-static void
-png_do_expand_palette(png_structrp png_ptr, png_row_infop row_info,
- png_bytep row, png_const_colorp palette, png_const_bytep trans_alpha,
- int num_trans)
-{
- int shift, value;
- png_bytep sp, dp;
- png_uint_32 i;
- png_uint_32 row_width=row_info->width;
-
- png_debug(1, "in png_do_expand_palette");
-
- if (row_info->color_type == PNG_COLOR_TYPE_PALETTE)
- {
- if (row_info->bit_depth < 8)
- {
- switch (row_info->bit_depth)
- {
- case 1:
- {
- sp = row + (size_t)((row_width - 1) >> 3);
- dp = row + (size_t)row_width - 1;
- shift = 7 - (int)((row_width + 7) & 0x07);
- for (i = 0; i < row_width; i++)
- {
- if ((*sp >> shift) & 0x01)
- *dp = 1;
-
- else
- *dp = 0;
-
- if (shift == 7)
- {
- shift = 0;
- sp--;
- }
-
- else
- shift++;
-
- dp--;
- }
- break;
- }
-
- case 2:
- {
- sp = row + (size_t)((row_width - 1) >> 2);
- dp = row + (size_t)row_width - 1;
- shift = (int)((3 - ((row_width + 3) & 0x03)) << 1);
- for (i = 0; i < row_width; i++)
- {
- value = (*sp >> shift) & 0x03;
- *dp = (png_byte)value;
- if (shift == 6)
- {
- shift = 0;
- sp--;
- }
-
- else
- shift += 2;
-
- dp--;
- }
- break;
- }
-
- case 4:
- {
- sp = row + (size_t)((row_width - 1) >> 1);
- dp = row + (size_t)row_width - 1;
- shift = (int)((row_width & 0x01) << 2);
- for (i = 0; i < row_width; i++)
- {
- value = (*sp >> shift) & 0x0f;
- *dp = (png_byte)value;
- if (shift == 4)
- {
- shift = 0;
- sp--;
- }
-
- else
- shift += 4;
-
- dp--;
- }
- break;
- }
-
- default:
- break;
- }
- row_info->bit_depth = 8;
- row_info->pixel_depth = 8;
- row_info->rowbytes = row_width;
- }
-
- if (row_info->bit_depth == 8)
- {
- {
- if (num_trans > 0)
- {
- sp = row + (size_t)row_width - 1;
- dp = row + ((size_t)row_width << 2) - 1;
-
- i = 0;
-#ifdef PNG_ARM_NEON_INTRINSICS_AVAILABLE
- if (png_ptr->riffled_palette != NULL)
- {
- /* The RGBA optimization works with png_ptr->bit_depth == 8
- * but sometimes row_info->bit_depth has been changed to 8.
- * In these cases, the palette hasn't been riffled.
- */
- i = png_do_expand_palette_rgba8_neon(png_ptr, row_info, row,
- &sp, &dp);
- }
-#else
- PNG_UNUSED(png_ptr)
-#endif
-
- for (; i < row_width; i++)
- {
- if ((int)(*sp) >= num_trans)
- *dp-- = 0xff;
- else
- *dp-- = trans_alpha[*sp];
- *dp-- = palette[*sp].blue;
- *dp-- = palette[*sp].green;
- *dp-- = palette[*sp].red;
- sp--;
- }
- row_info->bit_depth = 8;
- row_info->pixel_depth = 32;
- row_info->rowbytes = row_width * 4;
- row_info->color_type = 6;
- row_info->channels = 4;
- }
-
- else
- {
- sp = row + (size_t)row_width - 1;
- dp = row + (size_t)(row_width * 3) - 1;
- i = 0;
-#ifdef PNG_ARM_NEON_INTRINSICS_AVAILABLE
- i = png_do_expand_palette_rgb8_neon(png_ptr, row_info, row,
- &sp, &dp);
-#else
- PNG_UNUSED(png_ptr)
-#endif
-
- for (; i < row_width; i++)
- {
- *dp-- = palette[*sp].blue;
- *dp-- = palette[*sp].green;
- *dp-- = palette[*sp].red;
- sp--;
- }
-
- row_info->bit_depth = 8;
- row_info->pixel_depth = 24;
- row_info->rowbytes = row_width * 3;
- row_info->color_type = 2;
- row_info->channels = 3;
- }
- }
- }
- }
-}
-
-/* If the bit depth < 8, it is expanded to 8. Also, if the already
- * expanded transparency value is supplied, an alpha channel is built.
- */
-static void
-png_do_expand(png_row_infop row_info, png_bytep row,
- png_const_color_16p trans_color)
-{
- int shift, value;
- png_bytep sp, dp;
- png_uint_32 i;
- png_uint_32 row_width=row_info->width;
-
- png_debug(1, "in png_do_expand");
-
- if (row_info->color_type == PNG_COLOR_TYPE_GRAY)
- {
- unsigned int gray = trans_color != NULL ? trans_color->gray : 0;
-
- if (row_info->bit_depth < 8)
- {
- switch (row_info->bit_depth)
- {
- case 1:
- {
- gray = (gray & 0x01) * 0xff;
- sp = row + (size_t)((row_width - 1) >> 3);
- dp = row + (size_t)row_width - 1;
- shift = 7 - (int)((row_width + 7) & 0x07);
- for (i = 0; i < row_width; i++)
- {
- if ((*sp >> shift) & 0x01)
- *dp = 0xff;
-
- else
- *dp = 0;
-
- if (shift == 7)
- {
- shift = 0;
- sp--;
- }
-
- else
- shift++;
-
- dp--;
- }
- break;
- }
-
- case 2:
- {
- gray = (gray & 0x03) * 0x55;
- sp = row + (size_t)((row_width - 1) >> 2);
- dp = row + (size_t)row_width - 1;
- shift = (int)((3 - ((row_width + 3) & 0x03)) << 1);
- for (i = 0; i < row_width; i++)
- {
- value = (*sp >> shift) & 0x03;
- *dp = (png_byte)(value | (value << 2) | (value << 4) |
- (value << 6));
- if (shift == 6)
- {
- shift = 0;
- sp--;
- }
-
- else
- shift += 2;
-
- dp--;
- }
- break;
- }
-
- case 4:
- {
- gray = (gray & 0x0f) * 0x11;
- sp = row + (size_t)((row_width - 1) >> 1);
- dp = row + (size_t)row_width - 1;
- shift = (int)((1 - ((row_width + 1) & 0x01)) << 2);
- for (i = 0; i < row_width; i++)
- {
- value = (*sp >> shift) & 0x0f;
- *dp = (png_byte)(value | (value << 4));
- if (shift == 4)
- {
- shift = 0;
- sp--;
- }
-
- else
- shift = 4;
-
- dp--;
- }
- break;
- }
-
- default:
- break;
- }
-
- row_info->bit_depth = 8;
- row_info->pixel_depth = 8;
- row_info->rowbytes = row_width;
- }
-
- if (trans_color != NULL)
- {
- if (row_info->bit_depth == 8)
- {
- gray = gray & 0xff;
- sp = row + (size_t)row_width - 1;
- dp = row + ((size_t)row_width << 1) - 1;
-
- for (i = 0; i < row_width; i++)
- {
- if ((*sp & 0xffU) == gray)
- *dp-- = 0;
-
- else
- *dp-- = 0xff;
-
- *dp-- = *sp--;
- }
- }
-
- else if (row_info->bit_depth == 16)
- {
- unsigned int gray_high = (gray >> 8) & 0xff;
- unsigned int gray_low = gray & 0xff;
- sp = row + row_info->rowbytes - 1;
- dp = row + (row_info->rowbytes << 1) - 1;
- for (i = 0; i < row_width; i++)
- {
- if ((*(sp - 1) & 0xffU) == gray_high &&
- (*(sp) & 0xffU) == gray_low)
- {
- *dp-- = 0;
- *dp-- = 0;
- }
-
- else
- {
- *dp-- = 0xff;
- *dp-- = 0xff;
- }
-
- *dp-- = *sp--;
- *dp-- = *sp--;
- }
- }
-
- row_info->color_type = PNG_COLOR_TYPE_GRAY_ALPHA;
- row_info->channels = 2;
- row_info->pixel_depth = (png_byte)(row_info->bit_depth << 1);
- row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,
- row_width);
- }
- }
- else if (row_info->color_type == PNG_COLOR_TYPE_RGB &&
- trans_color != NULL)
- {
- if (row_info->bit_depth == 8)
- {
- png_byte red = (png_byte)(trans_color->red & 0xff);
- png_byte green = (png_byte)(trans_color->green & 0xff);
- png_byte blue = (png_byte)(trans_color->blue & 0xff);
- sp = row + (size_t)row_info->rowbytes - 1;
- dp = row + ((size_t)row_width << 2) - 1;
- for (i = 0; i < row_width; i++)
- {
- if (*(sp - 2) == red && *(sp - 1) == green && *(sp) == blue)
- *dp-- = 0;
-
- else
- *dp-- = 0xff;
-
- *dp-- = *sp--;
- *dp-- = *sp--;
- *dp-- = *sp--;
- }
- }
- else if (row_info->bit_depth == 16)
- {
- png_byte red_high = (png_byte)((trans_color->red >> 8) & 0xff);
- png_byte green_high = (png_byte)((trans_color->green >> 8) & 0xff);
- png_byte blue_high = (png_byte)((trans_color->blue >> 8) & 0xff);
- png_byte red_low = (png_byte)(trans_color->red & 0xff);
- png_byte green_low = (png_byte)(trans_color->green & 0xff);
- png_byte blue_low = (png_byte)(trans_color->blue & 0xff);
- sp = row + row_info->rowbytes - 1;
- dp = row + ((size_t)row_width << 3) - 1;
- for (i = 0; i < row_width; i++)
- {
- if (*(sp - 5) == red_high &&
- *(sp - 4) == red_low &&
- *(sp - 3) == green_high &&
- *(sp - 2) == green_low &&
- *(sp - 1) == blue_high &&
- *(sp ) == blue_low)
- {
- *dp-- = 0;
- *dp-- = 0;
- }
-
- else
- {
- *dp-- = 0xff;
- *dp-- = 0xff;
- }
-
- *dp-- = *sp--;
- *dp-- = *sp--;
- *dp-- = *sp--;
- *dp-- = *sp--;
- *dp-- = *sp--;
- *dp-- = *sp--;
- }
- }
- row_info->color_type = PNG_COLOR_TYPE_RGB_ALPHA;
- row_info->channels = 4;
- row_info->pixel_depth = (png_byte)(row_info->bit_depth << 2);
- row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);
- }
-}
-#endif
-
-#ifdef PNG_READ_EXPAND_16_SUPPORTED
-/* If the bit depth is 8 and the color type is not a palette type expand the
- * whole row to 16 bits. Has no effect otherwise.
- */
-static void
-png_do_expand_16(png_row_infop row_info, png_bytep row)
-{
- if (row_info->bit_depth == 8 &&
- row_info->color_type != PNG_COLOR_TYPE_PALETTE)
- {
- /* The row have a sequence of bytes containing [0..255] and we need
- * to turn it into another row containing [0..65535], to do this we
- * calculate:
- *
- * (input / 255) * 65535
- *
- * Which happens to be exactly input * 257 and this can be achieved
- * simply by byte replication in place (copying backwards).
- */
- png_byte *sp = row + row_info->rowbytes; /* source, last byte + 1 */
- png_byte *dp = sp + row_info->rowbytes; /* destination, end + 1 */
- while (dp > sp)
- {
- dp[-2] = dp[-1] = *--sp; dp -= 2;
- }
-
- row_info->rowbytes *= 2;
- row_info->bit_depth = 16;
- row_info->pixel_depth = (png_byte)(row_info->channels * 16);
- }
-}
-#endif
-
-#ifdef PNG_READ_QUANTIZE_SUPPORTED
-static void
-png_do_quantize(png_row_infop row_info, png_bytep row,
- png_const_bytep palette_lookup, png_const_bytep quantize_lookup)
-{
- png_bytep sp, dp;
- png_uint_32 i;
- png_uint_32 row_width=row_info->width;
-
- png_debug(1, "in png_do_quantize");
-
- if (row_info->bit_depth == 8)
- {
- if (row_info->color_type == PNG_COLOR_TYPE_RGB && palette_lookup)
- {
- int r, g, b, p;
- sp = row;
- dp = row;
- for (i = 0; i < row_width; i++)
- {
- r = *sp++;
- g = *sp++;
- b = *sp++;
-
- /* This looks real messy, but the compiler will reduce
- * it down to a reasonable formula. For example, with
- * 5 bits per color, we get:
- * p = (((r >> 3) & 0x1f) << 10) |
- * (((g >> 3) & 0x1f) << 5) |
- * ((b >> 3) & 0x1f);
- */
- p = (((r >> (8 - PNG_QUANTIZE_RED_BITS)) &
- ((1 << PNG_QUANTIZE_RED_BITS) - 1)) <<
- (PNG_QUANTIZE_GREEN_BITS + PNG_QUANTIZE_BLUE_BITS)) |
- (((g >> (8 - PNG_QUANTIZE_GREEN_BITS)) &
- ((1 << PNG_QUANTIZE_GREEN_BITS) - 1)) <<
- (PNG_QUANTIZE_BLUE_BITS)) |
- ((b >> (8 - PNG_QUANTIZE_BLUE_BITS)) &
- ((1 << PNG_QUANTIZE_BLUE_BITS) - 1));
-
- *dp++ = palette_lookup[p];
- }
-
- row_info->color_type = PNG_COLOR_TYPE_PALETTE;
- row_info->channels = 1;
- row_info->pixel_depth = row_info->bit_depth;
- row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);
- }
-
- else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA &&
- palette_lookup != NULL)
- {
- int r, g, b, p;
- sp = row;
- dp = row;
- for (i = 0; i < row_width; i++)
- {
- r = *sp++;
- g = *sp++;
- b = *sp++;
- sp++;
-
- p = (((r >> (8 - PNG_QUANTIZE_RED_BITS)) &
- ((1 << PNG_QUANTIZE_RED_BITS) - 1)) <<
- (PNG_QUANTIZE_GREEN_BITS + PNG_QUANTIZE_BLUE_BITS)) |
- (((g >> (8 - PNG_QUANTIZE_GREEN_BITS)) &
- ((1 << PNG_QUANTIZE_GREEN_BITS) - 1)) <<
- (PNG_QUANTIZE_BLUE_BITS)) |
- ((b >> (8 - PNG_QUANTIZE_BLUE_BITS)) &
- ((1 << PNG_QUANTIZE_BLUE_BITS) - 1));
-
- *dp++ = palette_lookup[p];
- }
-
- row_info->color_type = PNG_COLOR_TYPE_PALETTE;
- row_info->channels = 1;
- row_info->pixel_depth = row_info->bit_depth;
- row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);
- }
-
- else if (row_info->color_type == PNG_COLOR_TYPE_PALETTE &&
- quantize_lookup)
- {
- sp = row;
-
- for (i = 0; i < row_width; i++, sp++)
- {
- *sp = quantize_lookup[*sp];
- }
- }
- }
-}
-#endif /* READ_QUANTIZE */
-
-/* Transform the row. The order of transformations is significant,
- * and is very touchy. If you add a transformation, take care to
- * decide how it fits in with the other transformations here.
- */
-void /* PRIVATE */
-png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
-{
- png_debug(1, "in png_do_read_transformations");
-
- if (png_ptr->row_buf == NULL)
- {
- /* Prior to 1.5.4 this output row/pass where the NULL pointer is, but this
- * error is incredibly rare and incredibly easy to debug without this
- * information.
- */
- png_error(png_ptr, "NULL row buffer");
- }
-
- /* The following is debugging; prior to 1.5.4 the code was never compiled in;
- * in 1.5.4 PNG_FLAG_DETECT_UNINITIALIZED was added and the macro
- * PNG_WARN_UNINITIALIZED_ROW removed. In 1.6 the new flag is set only for
- * all transformations, however in practice the ROW_INIT always gets done on
- * demand, if necessary.
- */
- if ((png_ptr->flags & PNG_FLAG_DETECT_UNINITIALIZED) != 0 &&
- (png_ptr->flags & PNG_FLAG_ROW_INIT) == 0)
- {
- /* Application has failed to call either png_read_start_image() or
- * png_read_update_info() after setting transforms that expand pixels.
- * This check added to libpng-1.2.19 (but not enabled until 1.5.4).
- */
- png_error(png_ptr, "Uninitialized row");
- }
-
-#ifdef PNG_READ_EXPAND_SUPPORTED
- if ((png_ptr->transformations & PNG_EXPAND) != 0)
- {
- if (row_info->color_type == PNG_COLOR_TYPE_PALETTE)
- {
-#ifdef PNG_ARM_NEON_INTRINSICS_AVAILABLE
- if ((png_ptr->num_trans > 0) && (png_ptr->bit_depth == 8))
- {
- if (png_ptr->riffled_palette == NULL)
- {
- /* Initialize the accelerated palette expansion. */
- png_ptr->riffled_palette =
- (png_bytep)png_malloc(png_ptr, 256 * 4);
- png_riffle_palette_neon(png_ptr);
- }
- }
-#endif
- png_do_expand_palette(png_ptr, row_info, png_ptr->row_buf + 1,
- png_ptr->palette, png_ptr->trans_alpha, png_ptr->num_trans);
- }
-
- else
- {
- if (png_ptr->num_trans != 0 &&
- (png_ptr->transformations & PNG_EXPAND_tRNS) != 0)
- png_do_expand(row_info, png_ptr->row_buf + 1,
- &(png_ptr->trans_color));
-
- else
- png_do_expand(row_info, png_ptr->row_buf + 1, NULL);
- }
- }
-#endif
-
-#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
- if ((png_ptr->transformations & PNG_STRIP_ALPHA) != 0 &&
- (png_ptr->transformations & PNG_COMPOSE) == 0 &&
- (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA ||
- row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA))
- png_do_strip_channel(row_info, png_ptr->row_buf + 1,
- 0 /* at_start == false, because SWAP_ALPHA happens later */);
-#endif
-
-#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
- if ((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0)
- {
- int rgb_error =
- png_do_rgb_to_gray(png_ptr, row_info,
- png_ptr->row_buf + 1);
-
- if (rgb_error != 0)
- {
- png_ptr->rgb_to_gray_status=1;
- if ((png_ptr->transformations & PNG_RGB_TO_GRAY) ==
- PNG_RGB_TO_GRAY_WARN)
- png_warning(png_ptr, "png_do_rgb_to_gray found nongray pixel");
-
- if ((png_ptr->transformations & PNG_RGB_TO_GRAY) ==
- PNG_RGB_TO_GRAY_ERR)
- png_error(png_ptr, "png_do_rgb_to_gray found nongray pixel");
- }
- }
-#endif
-
-/* From Andreas Dilger e-mail to png-implement, 26 March 1998:
- *
- * In most cases, the "simple transparency" should be done prior to doing
- * gray-to-RGB, or you will have to test 3x as many bytes to check if a
- * pixel is transparent. You would also need to make sure that the
- * transparency information is upgraded to RGB.
- *
- * To summarize, the current flow is:
- * - Gray + simple transparency -> compare 1 or 2 gray bytes and composite
- * with background "in place" if transparent,
- * convert to RGB if necessary
- * - Gray + alpha -> composite with gray background and remove alpha bytes,
- * convert to RGB if necessary
- *
- * To support RGB backgrounds for gray images we need:
- * - Gray + simple transparency -> convert to RGB + simple transparency,
- * compare 3 or 6 bytes and composite with
- * background "in place" if transparent
- * (3x compare/pixel compared to doing
- * composite with gray bkgrnd)
- * - Gray + alpha -> convert to RGB + alpha, composite with background and
- * remove alpha bytes (3x float
- * operations/pixel compared with composite
- * on gray background)
- *
- * Greg's change will do this. The reason it wasn't done before is for
- * performance, as this increases the per-pixel operations. If we would check
- * in advance if the background was gray or RGB, and position the gray-to-RGB
- * transform appropriately, then it would save a lot of work/time.
- */
-
-#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
- /* If gray -> RGB, do so now only if background is non-gray; else do later
- * for performance reasons
- */
- if ((png_ptr->transformations & PNG_GRAY_TO_RGB) != 0 &&
- (png_ptr->mode & PNG_BACKGROUND_IS_GRAY) == 0)
- png_do_gray_to_rgb(row_info, png_ptr->row_buf + 1);
-#endif
-
-#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
- defined(PNG_READ_ALPHA_MODE_SUPPORTED)
- if ((png_ptr->transformations & PNG_COMPOSE) != 0)
- png_do_compose(row_info, png_ptr->row_buf + 1, png_ptr);
-#endif
-
-#ifdef PNG_READ_GAMMA_SUPPORTED
- if ((png_ptr->transformations & PNG_GAMMA) != 0 &&
-#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
- /* Because RGB_TO_GRAY does the gamma transform. */
- (png_ptr->transformations & PNG_RGB_TO_GRAY) == 0 &&
-#endif
-#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
- defined(PNG_READ_ALPHA_MODE_SUPPORTED)
- /* Because PNG_COMPOSE does the gamma transform if there is something to
- * do (if there is an alpha channel or transparency.)
- */
- !((png_ptr->transformations & PNG_COMPOSE) != 0 &&
- ((png_ptr->num_trans != 0) ||
- (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0)) &&
-#endif
- /* Because png_init_read_transformations transforms the palette, unless
- * RGB_TO_GRAY will do the transform.
- */
- (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE))
- png_do_gamma(row_info, png_ptr->row_buf + 1, png_ptr);
-#endif
-
-#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
- if ((png_ptr->transformations & PNG_STRIP_ALPHA) != 0 &&
- (png_ptr->transformations & PNG_COMPOSE) != 0 &&
- (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA ||
- row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA))
- png_do_strip_channel(row_info, png_ptr->row_buf + 1,
- 0 /* at_start == false, because SWAP_ALPHA happens later */);
-#endif
-
-#ifdef PNG_READ_ALPHA_MODE_SUPPORTED
- if ((png_ptr->transformations & PNG_ENCODE_ALPHA) != 0 &&
- (row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0)
- png_do_encode_alpha(row_info, png_ptr->row_buf + 1, png_ptr);
-#endif
-
-#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
- if ((png_ptr->transformations & PNG_SCALE_16_TO_8) != 0)
- png_do_scale_16_to_8(row_info, png_ptr->row_buf + 1);
-#endif
-
-#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
- /* There is no harm in doing both of these because only one has any effect,
- * by putting the 'scale' option first if the app asks for scale (either by
- * calling the API or in a TRANSFORM flag) this is what happens.
- */
- if ((png_ptr->transformations & PNG_16_TO_8) != 0)
- png_do_chop(row_info, png_ptr->row_buf + 1);
-#endif
-
-#ifdef PNG_READ_QUANTIZE_SUPPORTED
- if ((png_ptr->transformations & PNG_QUANTIZE) != 0)
- {
- png_do_quantize(row_info, png_ptr->row_buf + 1,
- png_ptr->palette_lookup, png_ptr->quantize_index);
-
- if (row_info->rowbytes == 0)
- png_error(png_ptr, "png_do_quantize returned rowbytes=0");
- }
-#endif /* READ_QUANTIZE */
-
-#ifdef PNG_READ_EXPAND_16_SUPPORTED
- /* Do the expansion now, after all the arithmetic has been done. Notice
- * that previous transformations can handle the PNG_EXPAND_16 flag if this
- * is efficient (particularly true in the case of gamma correction, where
- * better accuracy results faster!)
- */
- if ((png_ptr->transformations & PNG_EXPAND_16) != 0)
- png_do_expand_16(row_info, png_ptr->row_buf + 1);
-#endif
-
-#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
- /* NOTE: moved here in 1.5.4 (from much later in this list.) */
- if ((png_ptr->transformations & PNG_GRAY_TO_RGB) != 0 &&
- (png_ptr->mode & PNG_BACKGROUND_IS_GRAY) != 0)
- png_do_gray_to_rgb(row_info, png_ptr->row_buf + 1);
-#endif
-
-#ifdef PNG_READ_INVERT_SUPPORTED
- if ((png_ptr->transformations & PNG_INVERT_MONO) != 0)
- png_do_invert(row_info, png_ptr->row_buf + 1);
-#endif
-
-#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED
- if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0)
- png_do_read_invert_alpha(row_info, png_ptr->row_buf + 1);
-#endif
-
-#ifdef PNG_READ_SHIFT_SUPPORTED
- if ((png_ptr->transformations & PNG_SHIFT) != 0)
- png_do_unshift(row_info, png_ptr->row_buf + 1,
- &(png_ptr->shift));
-#endif
-
-#ifdef PNG_READ_PACK_SUPPORTED
- if ((png_ptr->transformations & PNG_PACK) != 0)
- png_do_unpack(row_info, png_ptr->row_buf + 1);
-#endif
-
-#ifdef PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED
- /* Added at libpng-1.5.10 */
- if (row_info->color_type == PNG_COLOR_TYPE_PALETTE &&
- png_ptr->num_palette_max >= 0)
- png_do_check_palette_indexes(png_ptr, row_info);
-#endif
-
-#ifdef PNG_READ_BGR_SUPPORTED
- if ((png_ptr->transformations & PNG_BGR) != 0)
- png_do_bgr(row_info, png_ptr->row_buf + 1);
-#endif
-
-#ifdef PNG_READ_PACKSWAP_SUPPORTED
- if ((png_ptr->transformations & PNG_PACKSWAP) != 0)
- png_do_packswap(row_info, png_ptr->row_buf + 1);
-#endif
-
-#ifdef PNG_READ_FILLER_SUPPORTED
- if ((png_ptr->transformations & PNG_FILLER) != 0)
- png_do_read_filler(row_info, png_ptr->row_buf + 1,
- (png_uint_32)png_ptr->filler, png_ptr->flags);
-#endif
-
-#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED
- if ((png_ptr->transformations & PNG_SWAP_ALPHA) != 0)
- png_do_read_swap_alpha(row_info, png_ptr->row_buf + 1);
-#endif
-
-#ifdef PNG_READ_16BIT_SUPPORTED
-#ifdef PNG_READ_SWAP_SUPPORTED
- if ((png_ptr->transformations & PNG_SWAP_BYTES) != 0)
- png_do_swap(row_info, png_ptr->row_buf + 1);
-#endif
-#endif
-
-#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
- if ((png_ptr->transformations & PNG_USER_TRANSFORM) != 0)
- {
- if (png_ptr->read_user_transform_fn != NULL)
- (*(png_ptr->read_user_transform_fn)) /* User read transform function */
- (png_ptr, /* png_ptr */
- row_info, /* row_info: */
- /* png_uint_32 width; width of row */
- /* size_t rowbytes; number of bytes in row */
- /* png_byte color_type; color type of pixels */
- /* png_byte bit_depth; bit depth of samples */
- /* png_byte channels; number of channels (1-4) */
- /* png_byte pixel_depth; bits per pixel (depth*channels) */
- png_ptr->row_buf + 1); /* start of pixel data for row */
-#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
- if (png_ptr->user_transform_depth != 0)
- row_info->bit_depth = png_ptr->user_transform_depth;
-
- if (png_ptr->user_transform_channels != 0)
- row_info->channels = png_ptr->user_transform_channels;
-#endif
- row_info->pixel_depth = (png_byte)(row_info->bit_depth *
- row_info->channels);
-
- row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_info->width);
- }
-#endif
-}
-
-#endif /* READ_TRANSFORMS */
-#endif /* READ */
diff --git a/contrib/libs/libpng/pngrutil.c b/contrib/libs/libpng/pngrutil.c
deleted file mode 100644
index f01c294963..0000000000
--- a/contrib/libs/libpng/pngrutil.c
+++ /dev/null
@@ -1,5103 +0,0 @@
-/* pngrutil.c - utilities to read a PNG file
- *
- * Copyright (c) 2018-2024 Cosmin Truta
- * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
- * Copyright (c) 1996-1997 Andreas Dilger
- * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
- *
- * This code is released under the libpng license.
- * For conditions of distribution and use, see the disclaimer
- * and license in png.h
- *
- * This file contains routines that are only called from within
- * libpng itself during the course of reading an image.
- */
-
-#include "pngpriv.h"
-
-#ifdef PNG_READ_SUPPORTED
-
-#ifdef PNG_READ_INTERLACING_SUPPORTED
-/* Arrays to facilitate interlacing - use pass (0 - 6) as index. */
-
-/* Start of interlace block */
-static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
-/* Offset to next interlace block */
-static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
-/* Start of interlace block in the y direction */
-static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
-/* Offset to next interlace block in the y direction */
-static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
-
-/* TODO: Move these arrays to a common utility module to avoid duplication. */
-#endif
-
-png_uint_32 PNGAPI
-png_get_uint_31(png_const_structrp png_ptr, png_const_bytep buf)
-{
- png_uint_32 uval = png_get_uint_32(buf);
-
- if (uval > PNG_UINT_31_MAX)
- png_error(png_ptr, "PNG unsigned integer out of range");
-
- return uval;
-}
-
-#if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_READ_cHRM_SUPPORTED)
-/* The following is a variation on the above for use with the fixed
- * point values used for gAMA and cHRM. Instead of png_error it
- * issues a warning and returns (-1) - an invalid value because both
- * gAMA and cHRM use *unsigned* integers for fixed point values.
- */
-#define PNG_FIXED_ERROR (-1)
-
-static png_fixed_point /* PRIVATE */
-png_get_fixed_point(png_structrp png_ptr, png_const_bytep buf)
-{
- png_uint_32 uval = png_get_uint_32(buf);
-
- if (uval <= PNG_UINT_31_MAX)
- return (png_fixed_point)uval; /* known to be in range */
-
- /* The caller can turn off the warning by passing NULL. */
- if (png_ptr != NULL)
- png_warning(png_ptr, "PNG fixed point integer out of range");
-
- return PNG_FIXED_ERROR;
-}
-#endif
-
-#ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED
-/* NOTE: the read macros will obscure these definitions, so that if
- * PNG_USE_READ_MACROS is set the library will not use them internally,
- * but the APIs will still be available externally.
- *
- * The parentheses around "PNGAPI function_name" in the following three
- * functions are necessary because they allow the macros to co-exist with
- * these (unused but exported) functions.
- */
-
-/* Grab an unsigned 32-bit integer from a buffer in big-endian format. */
-png_uint_32 (PNGAPI
-png_get_uint_32)(png_const_bytep buf)
-{
- png_uint_32 uval =
- ((png_uint_32)(*(buf )) << 24) +
- ((png_uint_32)(*(buf + 1)) << 16) +
- ((png_uint_32)(*(buf + 2)) << 8) +
- ((png_uint_32)(*(buf + 3)) ) ;
-
- return uval;
-}
-
-/* Grab a signed 32-bit integer from a buffer in big-endian format. The
- * data is stored in the PNG file in two's complement format and there
- * is no guarantee that a 'png_int_32' is exactly 32 bits, therefore
- * the following code does a two's complement to native conversion.
- */
-png_int_32 (PNGAPI
-png_get_int_32)(png_const_bytep buf)
-{
- png_uint_32 uval = png_get_uint_32(buf);
- if ((uval & 0x80000000) == 0) /* non-negative */
- return (png_int_32)uval;
-
- uval = (uval ^ 0xffffffff) + 1; /* 2's complement: -x = ~x+1 */
- if ((uval & 0x80000000) == 0) /* no overflow */
- return -(png_int_32)uval;
- /* The following has to be safe; this function only gets called on PNG data
- * and if we get here that data is invalid. 0 is the most safe value and
- * if not then an attacker would surely just generate a PNG with 0 instead.
- */
- return 0;
-}
-
-/* Grab an unsigned 16-bit integer from a buffer in big-endian format. */
-png_uint_16 (PNGAPI
-png_get_uint_16)(png_const_bytep buf)
-{
- /* ANSI-C requires an int value to accommodate at least 16 bits so this
- * works and allows the compiler not to worry about possible narrowing
- * on 32-bit systems. (Pre-ANSI systems did not make integers smaller
- * than 16 bits either.)
- */
- unsigned int val =
- ((unsigned int)(*buf) << 8) +
- ((unsigned int)(*(buf + 1)));
-
- return (png_uint_16)val;
-}
-
-#endif /* READ_INT_FUNCTIONS */
-
-/* Read and check the PNG file signature */
-void /* PRIVATE */
-png_read_sig(png_structrp png_ptr, png_inforp info_ptr)
-{
- size_t num_checked, num_to_check;
-
- /* Exit if the user application does not expect a signature. */
- if (png_ptr->sig_bytes >= 8)
- return;
-
- num_checked = png_ptr->sig_bytes;
- num_to_check = 8 - num_checked;
-
-#ifdef PNG_IO_STATE_SUPPORTED
- png_ptr->io_state = PNG_IO_READING | PNG_IO_SIGNATURE;
-#endif
-
- /* The signature must be serialized in a single I/O call. */
- png_read_data(png_ptr, &(info_ptr->signature[num_checked]), num_to_check);
- png_ptr->sig_bytes = 8;
-
- if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check) != 0)
- {
- if (num_checked < 4 &&
- png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4) != 0)
- png_error(png_ptr, "Not a PNG file");
- else
- png_error(png_ptr, "PNG file corrupted by ASCII conversion");
- }
- if (num_checked < 3)
- png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE;
-}
-
-/* Read the chunk header (length + type name).
- * Put the type name into png_ptr->chunk_name, and return the length.
- */
-png_uint_32 /* PRIVATE */
-png_read_chunk_header(png_structrp png_ptr)
-{
- png_byte buf[8];
- png_uint_32 length;
-
-#ifdef PNG_IO_STATE_SUPPORTED
- png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_HDR;
-#endif
-
- /* Read the length and the chunk name.
- * This must be performed in a single I/O call.
- */
- png_read_data(png_ptr, buf, 8);
- length = png_get_uint_31(png_ptr, buf);
-
- /* Put the chunk name into png_ptr->chunk_name. */
- png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(buf+4);
-
- png_debug2(0, "Reading chunk typeid = 0x%lx, length = %lu",
- (unsigned long)png_ptr->chunk_name, (unsigned long)length);
-
- /* Reset the crc and run it over the chunk name. */
- png_reset_crc(png_ptr);
- png_calculate_crc(png_ptr, buf + 4, 4);
-
- /* Check to see if chunk name is valid. */
- png_check_chunk_name(png_ptr, png_ptr->chunk_name);
-
- /* Check for too-large chunk length */
- png_check_chunk_length(png_ptr, length);
-
-#ifdef PNG_IO_STATE_SUPPORTED
- png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_DATA;
-#endif
-
- return length;
-}
-
-/* Read data, and (optionally) run it through the CRC. */
-void /* PRIVATE */
-png_crc_read(png_structrp png_ptr, png_bytep buf, png_uint_32 length)
-{
- if (png_ptr == NULL)
- return;
-
- png_read_data(png_ptr, buf, length);
- png_calculate_crc(png_ptr, buf, length);
-}
-
-/* Optionally skip data and then check the CRC. Depending on whether we
- * are reading an ancillary or critical chunk, and how the program has set
- * things up, we may calculate the CRC on the data and print a message.
- * Returns '1' if there was a CRC error, '0' otherwise.
- */
-int /* PRIVATE */
-png_crc_finish(png_structrp png_ptr, png_uint_32 skip)
-{
- /* The size of the local buffer for inflate is a good guess as to a
- * reasonable size to use for buffering reads from the application.
- */
- while (skip > 0)
- {
- png_uint_32 len;
- png_byte tmpbuf[PNG_INFLATE_BUF_SIZE];
-
- len = (sizeof tmpbuf);
- if (len > skip)
- len = skip;
- skip -= len;
-
- png_crc_read(png_ptr, tmpbuf, len);
- }
-
- if (png_crc_error(png_ptr) != 0)
- {
- if (PNG_CHUNK_ANCILLARY(png_ptr->chunk_name) != 0 ?
- (png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) == 0 :
- (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_USE) != 0)
- {
- png_chunk_warning(png_ptr, "CRC error");
- }
-
- else
- png_chunk_error(png_ptr, "CRC error");
-
- return 1;
- }
-
- return 0;
-}
-
-/* Compare the CRC stored in the PNG file with that calculated by libpng from
- * the data it has read thus far.
- */
-int /* PRIVATE */
-png_crc_error(png_structrp png_ptr)
-{
- png_byte crc_bytes[4];
- png_uint_32 crc;
- int need_crc = 1;
-
- if (PNG_CHUNK_ANCILLARY(png_ptr->chunk_name) != 0)
- {
- if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) ==
- (PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN))
- need_crc = 0;
- }
-
- else /* critical */
- {
- if ((png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE) != 0)
- need_crc = 0;
- }
-
-#ifdef PNG_IO_STATE_SUPPORTED
- png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_CRC;
-#endif
-
- /* The chunk CRC must be serialized in a single I/O call. */
- png_read_data(png_ptr, crc_bytes, 4);
-
- if (need_crc != 0)
- {
- crc = png_get_uint_32(crc_bytes);
- return crc != png_ptr->crc;
- }
-
- else
- return 0;
-}
-
-#if defined(PNG_READ_iCCP_SUPPORTED) || defined(PNG_READ_iTXt_SUPPORTED) ||\
- defined(PNG_READ_pCAL_SUPPORTED) || defined(PNG_READ_sCAL_SUPPORTED) ||\
- defined(PNG_READ_sPLT_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) ||\
- defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_SEQUENTIAL_READ_SUPPORTED)
-/* Manage the read buffer; this simply reallocates the buffer if it is not small
- * enough (or if it is not allocated). The routine returns a pointer to the
- * buffer; if an error occurs and 'warn' is set the routine returns NULL, else
- * it will call png_error (via png_malloc) on failure. (warn == 2 means
- * 'silent').
- */
-static png_bytep
-png_read_buffer(png_structrp png_ptr, png_alloc_size_t new_size, int warn)
-{
- png_bytep buffer = png_ptr->read_buffer;
-
- if (buffer != NULL && new_size > png_ptr->read_buffer_size)
- {
- png_ptr->read_buffer = NULL;
- png_ptr->read_buffer_size = 0;
- png_free(png_ptr, buffer);
- buffer = NULL;
- }
-
- if (buffer == NULL)
- {
- buffer = png_voidcast(png_bytep, png_malloc_base(png_ptr, new_size));
-
- if (buffer != NULL)
- {
- memset(buffer, 0, new_size); /* just in case */
- png_ptr->read_buffer = buffer;
- png_ptr->read_buffer_size = new_size;
- }
-
- else if (warn < 2) /* else silent */
- {
- if (warn != 0)
- png_chunk_warning(png_ptr, "insufficient memory to read chunk");
-
- else
- png_chunk_error(png_ptr, "insufficient memory to read chunk");
- }
- }
-
- return buffer;
-}
-#endif /* READ_iCCP|iTXt|pCAL|sCAL|sPLT|tEXt|zTXt|SEQUENTIAL_READ */
-
-/* png_inflate_claim: claim the zstream for some nefarious purpose that involves
- * decompression. Returns Z_OK on success, else a zlib error code. It checks
- * the owner but, in final release builds, just issues a warning if some other
- * chunk apparently owns the stream. Prior to release it does a png_error.
- */
-static int
-png_inflate_claim(png_structrp png_ptr, png_uint_32 owner)
-{
- if (png_ptr->zowner != 0)
- {
- char msg[64];
-
- PNG_STRING_FROM_CHUNK(msg, png_ptr->zowner);
- /* So the message that results is "<chunk> using zstream"; this is an
- * internal error, but is very useful for debugging. i18n requirements
- * are minimal.
- */
- (void)png_safecat(msg, (sizeof msg), 4, " using zstream");
-#if PNG_RELEASE_BUILD
- png_chunk_warning(png_ptr, msg);
- png_ptr->zowner = 0;
-#else
- png_chunk_error(png_ptr, msg);
-#endif
- }
-
- /* Implementation note: unlike 'png_deflate_claim' this internal function
- * does not take the size of the data as an argument. Some efficiency could
- * be gained by using this when it is known *if* the zlib stream itself does
- * not record the number; however, this is an illusion: the original writer
- * of the PNG may have selected a lower window size, and we really must
- * follow that because, for systems with with limited capabilities, we
- * would otherwise reject the application's attempts to use a smaller window
- * size (zlib doesn't have an interface to say "this or lower"!).
- *
- * inflateReset2 was added to zlib 1.2.4; before this the window could not be
- * reset, therefore it is necessary to always allocate the maximum window
- * size with earlier zlibs just in case later compressed chunks need it.
- */
- {
- int ret; /* zlib return code */
-#if ZLIB_VERNUM >= 0x1240
- int window_bits = 0;
-
-# if defined(PNG_SET_OPTION_SUPPORTED) && defined(PNG_MAXIMUM_INFLATE_WINDOW)
- if (((png_ptr->options >> PNG_MAXIMUM_INFLATE_WINDOW) & 3) ==
- PNG_OPTION_ON)
- {
- window_bits = 15;
- png_ptr->zstream_start = 0; /* fixed window size */
- }
-
- else
- {
- png_ptr->zstream_start = 1;
- }
-# endif
-
-#endif /* ZLIB_VERNUM >= 0x1240 */
-
- /* Set this for safety, just in case the previous owner left pointers to
- * memory allocations.
- */
- png_ptr->zstream.next_in = NULL;
- png_ptr->zstream.avail_in = 0;
- png_ptr->zstream.next_out = NULL;
- png_ptr->zstream.avail_out = 0;
-
- if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) != 0)
- {
-#if ZLIB_VERNUM >= 0x1240
- ret = inflateReset2(&png_ptr->zstream, window_bits);
-#else
- ret = inflateReset(&png_ptr->zstream);
-#endif
- }
-
- else
- {
-#if ZLIB_VERNUM >= 0x1240
- ret = inflateInit2(&png_ptr->zstream, window_bits);
-#else
- ret = inflateInit(&png_ptr->zstream);
-#endif
-
- if (ret == Z_OK)
- png_ptr->flags |= PNG_FLAG_ZSTREAM_INITIALIZED;
- }
-
-#ifdef PNG_DISABLE_ADLER32_CHECK_SUPPORTED
- if (((png_ptr->options >> PNG_IGNORE_ADLER32) & 3) == PNG_OPTION_ON)
- /* Turn off validation of the ADLER32 checksum in IDAT chunks */
- ret = inflateValidate(&png_ptr->zstream, 0);
-#endif
-
- if (ret == Z_OK)
- png_ptr->zowner = owner;
-
- else
- png_zstream_error(png_ptr, ret);
-
- return ret;
- }
-
-#ifdef window_bits
-# undef window_bits
-#endif
-}
-
-#if ZLIB_VERNUM >= 0x1240
-/* Handle the start of the inflate stream if we called inflateInit2(strm,0);
- * in this case some zlib versions skip validation of the CINFO field and, in
- * certain circumstances, libpng may end up displaying an invalid image, in
- * contrast to implementations that call zlib in the normal way (e.g. libpng
- * 1.5).
- */
-int /* PRIVATE */
-png_zlib_inflate(png_structrp png_ptr, int flush)
-{
- if (png_ptr->zstream_start && png_ptr->zstream.avail_in > 0)
- {
- if ((*png_ptr->zstream.next_in >> 4) > 7)
- {
- png_ptr->zstream.msg = "invalid window size (libpng)";
- return Z_DATA_ERROR;
- }
-
- png_ptr->zstream_start = 0;
- }
-
- return inflate(&png_ptr->zstream, flush);
-}
-#endif /* Zlib >= 1.2.4 */
-
-#ifdef PNG_READ_COMPRESSED_TEXT_SUPPORTED
-#if defined(PNG_READ_zTXt_SUPPORTED) || defined (PNG_READ_iTXt_SUPPORTED)
-/* png_inflate now returns zlib error codes including Z_OK and Z_STREAM_END to
- * allow the caller to do multiple calls if required. If the 'finish' flag is
- * set Z_FINISH will be passed to the final inflate() call and Z_STREAM_END must
- * be returned or there has been a problem, otherwise Z_SYNC_FLUSH is used and
- * Z_OK or Z_STREAM_END will be returned on success.
- *
- * The input and output sizes are updated to the actual amounts of data consumed
- * or written, not the amount available (as in a z_stream). The data pointers
- * are not changed, so the next input is (data+input_size) and the next
- * available output is (output+output_size).
- */
-static int
-png_inflate(png_structrp png_ptr, png_uint_32 owner, int finish,
- /* INPUT: */ png_const_bytep input, png_uint_32p input_size_ptr,
- /* OUTPUT: */ png_bytep output, png_alloc_size_t *output_size_ptr)
-{
- if (png_ptr->zowner == owner) /* Else not claimed */
- {
- int ret;
- png_alloc_size_t avail_out = *output_size_ptr;
- png_uint_32 avail_in = *input_size_ptr;
-
- /* zlib can't necessarily handle more than 65535 bytes at once (i.e. it
- * can't even necessarily handle 65536 bytes) because the type uInt is
- * "16 bits or more". Consequently it is necessary to chunk the input to
- * zlib. This code uses ZLIB_IO_MAX, from pngpriv.h, as the maximum (the
- * maximum value that can be stored in a uInt.) It is possible to set
- * ZLIB_IO_MAX to a lower value in pngpriv.h and this may sometimes have
- * a performance advantage, because it reduces the amount of data accessed
- * at each step and that may give the OS more time to page it in.
- */
- png_ptr->zstream.next_in = PNGZ_INPUT_CAST(input);
- /* avail_in and avail_out are set below from 'size' */
- png_ptr->zstream.avail_in = 0;
- png_ptr->zstream.avail_out = 0;
-
- /* Read directly into the output if it is available (this is set to
- * a local buffer below if output is NULL).
- */
- if (output != NULL)
- png_ptr->zstream.next_out = output;
-
- do
- {
- uInt avail;
- Byte local_buffer[PNG_INFLATE_BUF_SIZE];
-
- /* zlib INPUT BUFFER */
- /* The setting of 'avail_in' used to be outside the loop; by setting it
- * inside it is possible to chunk the input to zlib and simply rely on
- * zlib to advance the 'next_in' pointer. This allows arbitrary
- * amounts of data to be passed through zlib at the unavoidable cost of
- * requiring a window save (memcpy of up to 32768 output bytes)
- * every ZLIB_IO_MAX input bytes.
- */
- avail_in += png_ptr->zstream.avail_in; /* not consumed last time */
-
- avail = ZLIB_IO_MAX;
-
- if (avail_in < avail)
- avail = (uInt)avail_in; /* safe: < than ZLIB_IO_MAX */
-
- avail_in -= avail;
- png_ptr->zstream.avail_in = avail;
-
- /* zlib OUTPUT BUFFER */
- avail_out += png_ptr->zstream.avail_out; /* not written last time */
-
- avail = ZLIB_IO_MAX; /* maximum zlib can process */
-
- if (output == NULL)
- {
- /* Reset the output buffer each time round if output is NULL and
- * make available the full buffer, up to 'remaining_space'
- */
- png_ptr->zstream.next_out = local_buffer;
- if ((sizeof local_buffer) < avail)
- avail = (sizeof local_buffer);
- }
-
- if (avail_out < avail)
- avail = (uInt)avail_out; /* safe: < ZLIB_IO_MAX */
-
- png_ptr->zstream.avail_out = avail;
- avail_out -= avail;
-
- /* zlib inflate call */
- /* In fact 'avail_out' may be 0 at this point, that happens at the end
- * of the read when the final LZ end code was not passed at the end of
- * the previous chunk of input data. Tell zlib if we have reached the
- * end of the output buffer.
- */
- ret = PNG_INFLATE(png_ptr, avail_out > 0 ? Z_NO_FLUSH :
- (finish ? Z_FINISH : Z_SYNC_FLUSH));
- } while (ret == Z_OK);
-
- /* For safety kill the local buffer pointer now */
- if (output == NULL)
- png_ptr->zstream.next_out = NULL;
-
- /* Claw back the 'size' and 'remaining_space' byte counts. */
- avail_in += png_ptr->zstream.avail_in;
- avail_out += png_ptr->zstream.avail_out;
-
- /* Update the input and output sizes; the updated values are the amount
- * consumed or written, effectively the inverse of what zlib uses.
- */
- if (avail_out > 0)
- *output_size_ptr -= avail_out;
-
- if (avail_in > 0)
- *input_size_ptr -= avail_in;
-
- /* Ensure png_ptr->zstream.msg is set (even in the success case!) */
- png_zstream_error(png_ptr, ret);
- return ret;
- }
-
- else
- {
- /* This is a bad internal error. The recovery assigns to the zstream msg
- * pointer, which is not owned by the caller, but this is safe; it's only
- * used on errors!
- */
- png_ptr->zstream.msg = PNGZ_MSG_CAST("zstream unclaimed");
- return Z_STREAM_ERROR;
- }
-}
-
-/*
- * Decompress trailing data in a chunk. The assumption is that read_buffer
- * points at an allocated area holding the contents of a chunk with a
- * trailing compressed part. What we get back is an allocated area
- * holding the original prefix part and an uncompressed version of the
- * trailing part (the malloc area passed in is freed).
- */
-static int
-png_decompress_chunk(png_structrp png_ptr,
- png_uint_32 chunklength, png_uint_32 prefix_size,
- png_alloc_size_t *newlength /* must be initialized to the maximum! */,
- int terminate /*add a '\0' to the end of the uncompressed data*/)
-{
- /* TODO: implement different limits for different types of chunk.
- *
- * The caller supplies *newlength set to the maximum length of the
- * uncompressed data, but this routine allocates space for the prefix and
- * maybe a '\0' terminator too. We have to assume that 'prefix_size' is
- * limited only by the maximum chunk size.
- */
- png_alloc_size_t limit = PNG_SIZE_MAX;
-
-# ifdef PNG_SET_USER_LIMITS_SUPPORTED
- if (png_ptr->user_chunk_malloc_max > 0 &&
- png_ptr->user_chunk_malloc_max < limit)
- limit = png_ptr->user_chunk_malloc_max;
-# elif PNG_USER_CHUNK_MALLOC_MAX > 0
- if (PNG_USER_CHUNK_MALLOC_MAX < limit)
- limit = PNG_USER_CHUNK_MALLOC_MAX;
-# endif
-
- if (limit >= prefix_size + (terminate != 0))
- {
- int ret;
-
- limit -= prefix_size + (terminate != 0);
-
- if (limit < *newlength)
- *newlength = limit;
-
- /* Now try to claim the stream. */
- ret = png_inflate_claim(png_ptr, png_ptr->chunk_name);
-
- if (ret == Z_OK)
- {
- png_uint_32 lzsize = chunklength - prefix_size;
-
- ret = png_inflate(png_ptr, png_ptr->chunk_name, 1/*finish*/,
- /* input: */ png_ptr->read_buffer + prefix_size, &lzsize,
- /* output: */ NULL, newlength);
-
- if (ret == Z_STREAM_END)
- {
- /* Use 'inflateReset' here, not 'inflateReset2' because this
- * preserves the previously decided window size (otherwise it would
- * be necessary to store the previous window size.) In practice
- * this doesn't matter anyway, because png_inflate will call inflate
- * with Z_FINISH in almost all cases, so the window will not be
- * maintained.
- */
- if (inflateReset(&png_ptr->zstream) == Z_OK)
- {
- /* Because of the limit checks above we know that the new,
- * expanded, size will fit in a size_t (let alone an
- * png_alloc_size_t). Use png_malloc_base here to avoid an
- * extra OOM message.
- */
- png_alloc_size_t new_size = *newlength;
- png_alloc_size_t buffer_size = prefix_size + new_size +
- (terminate != 0);
- png_bytep text = png_voidcast(png_bytep, png_malloc_base(png_ptr,
- buffer_size));
-
- if (text != NULL)
- {
- memset(text, 0, buffer_size);
-
- ret = png_inflate(png_ptr, png_ptr->chunk_name, 1/*finish*/,
- png_ptr->read_buffer + prefix_size, &lzsize,
- text + prefix_size, newlength);
-
- if (ret == Z_STREAM_END)
- {
- if (new_size == *newlength)
- {
- if (terminate != 0)
- text[prefix_size + *newlength] = 0;
-
- if (prefix_size > 0)
- memcpy(text, png_ptr->read_buffer, prefix_size);
-
- {
- png_bytep old_ptr = png_ptr->read_buffer;
-
- png_ptr->read_buffer = text;
- png_ptr->read_buffer_size = buffer_size;
- text = old_ptr; /* freed below */
- }
- }
-
- else
- {
- /* The size changed on the second read, there can be no
- * guarantee that anything is correct at this point.
- * The 'msg' pointer has been set to "unexpected end of
- * LZ stream", which is fine, but return an error code
- * that the caller won't accept.
- */
- ret = PNG_UNEXPECTED_ZLIB_RETURN;
- }
- }
-
- else if (ret == Z_OK)
- ret = PNG_UNEXPECTED_ZLIB_RETURN; /* for safety */
-
- /* Free the text pointer (this is the old read_buffer on
- * success)
- */
- png_free(png_ptr, text);
-
- /* This really is very benign, but it's still an error because
- * the extra space may otherwise be used as a Trojan Horse.
- */
- if (ret == Z_STREAM_END &&
- chunklength - prefix_size != lzsize)
- png_chunk_benign_error(png_ptr, "extra compressed data");
- }
-
- else
- {
- /* Out of memory allocating the buffer */
- ret = Z_MEM_ERROR;
- png_zstream_error(png_ptr, Z_MEM_ERROR);
- }
- }
-
- else
- {
- /* inflateReset failed, store the error message */
- png_zstream_error(png_ptr, ret);
- ret = PNG_UNEXPECTED_ZLIB_RETURN;
- }
- }
-
- else if (ret == Z_OK)
- ret = PNG_UNEXPECTED_ZLIB_RETURN;
-
- /* Release the claimed stream */
- png_ptr->zowner = 0;
- }
-
- else /* the claim failed */ if (ret == Z_STREAM_END) /* impossible! */
- ret = PNG_UNEXPECTED_ZLIB_RETURN;
-
- return ret;
- }
-
- else
- {
- /* Application/configuration limits exceeded */
- png_zstream_error(png_ptr, Z_MEM_ERROR);
- return Z_MEM_ERROR;
- }
-}
-#endif /* READ_zTXt || READ_iTXt */
-#endif /* READ_COMPRESSED_TEXT */
-
-#ifdef PNG_READ_iCCP_SUPPORTED
-/* Perform a partial read and decompress, producing 'avail_out' bytes and
- * reading from the current chunk as required.
- */
-static int
-png_inflate_read(png_structrp png_ptr, png_bytep read_buffer, uInt read_size,
- png_uint_32p chunk_bytes, png_bytep next_out, png_alloc_size_t *out_size,
- int finish)
-{
- if (png_ptr->zowner == png_ptr->chunk_name)
- {
- int ret;
-
- /* next_in and avail_in must have been initialized by the caller. */
- png_ptr->zstream.next_out = next_out;
- png_ptr->zstream.avail_out = 0; /* set in the loop */
-
- do
- {
- if (png_ptr->zstream.avail_in == 0)
- {
- if (read_size > *chunk_bytes)
- read_size = (uInt)*chunk_bytes;
- *chunk_bytes -= read_size;
-
- if (read_size > 0)
- png_crc_read(png_ptr, read_buffer, read_size);
-
- png_ptr->zstream.next_in = read_buffer;
- png_ptr->zstream.avail_in = read_size;
- }
-
- if (png_ptr->zstream.avail_out == 0)
- {
- uInt avail = ZLIB_IO_MAX;
- if (avail > *out_size)
- avail = (uInt)*out_size;
- *out_size -= avail;
-
- png_ptr->zstream.avail_out = avail;
- }
-
- /* Use Z_SYNC_FLUSH when there is no more chunk data to ensure that all
- * the available output is produced; this allows reading of truncated
- * streams.
- */
- ret = PNG_INFLATE(png_ptr, *chunk_bytes > 0 ?
- Z_NO_FLUSH : (finish ? Z_FINISH : Z_SYNC_FLUSH));
- }
- while (ret == Z_OK && (*out_size > 0 || png_ptr->zstream.avail_out > 0));
-
- *out_size += png_ptr->zstream.avail_out;
- png_ptr->zstream.avail_out = 0; /* Should not be required, but is safe */
-
- /* Ensure the error message pointer is always set: */
- png_zstream_error(png_ptr, ret);
- return ret;
- }
-
- else
- {
- png_ptr->zstream.msg = PNGZ_MSG_CAST("zstream unclaimed");
- return Z_STREAM_ERROR;
- }
-}
-#endif /* READ_iCCP */
-
-/* Read and check the IDHR chunk */
-
-void /* PRIVATE */
-png_handle_IHDR(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
-{
- png_byte buf[13];
- png_uint_32 width, height;
- int bit_depth, color_type, compression_type, filter_type;
- int interlace_type;
-
- png_debug(1, "in png_handle_IHDR");
-
- if ((png_ptr->mode & PNG_HAVE_IHDR) != 0)
- png_chunk_error(png_ptr, "out of place");
-
- /* Check the length */
- if (length != 13)
- png_chunk_error(png_ptr, "invalid");
-
- png_ptr->mode |= PNG_HAVE_IHDR;
-
- png_crc_read(png_ptr, buf, 13);
- png_crc_finish(png_ptr, 0);
-
- width = png_get_uint_31(png_ptr, buf);
- height = png_get_uint_31(png_ptr, buf + 4);
- bit_depth = buf[8];
- color_type = buf[9];
- compression_type = buf[10];
- filter_type = buf[11];
- interlace_type = buf[12];
-
-#ifdef PNG_READ_APNG_SUPPORTED
- png_ptr->first_frame_width = width;
- png_ptr->first_frame_height = height;
-#endif
-
- /* Set internal variables */
- png_ptr->width = width;
- png_ptr->height = height;
- png_ptr->bit_depth = (png_byte)bit_depth;
- png_ptr->interlaced = (png_byte)interlace_type;
- png_ptr->color_type = (png_byte)color_type;
-#ifdef PNG_MNG_FEATURES_SUPPORTED
- png_ptr->filter_type = (png_byte)filter_type;
-#endif
- png_ptr->compression_type = (png_byte)compression_type;
-
- /* Find number of channels */
- switch (png_ptr->color_type)
- {
- default: /* invalid, png_set_IHDR calls png_error */
- case PNG_COLOR_TYPE_GRAY:
- case PNG_COLOR_TYPE_PALETTE:
- png_ptr->channels = 1;
- break;
-
- case PNG_COLOR_TYPE_RGB:
- png_ptr->channels = 3;
- break;
-
- case PNG_COLOR_TYPE_GRAY_ALPHA:
- png_ptr->channels = 2;
- break;
-
- case PNG_COLOR_TYPE_RGB_ALPHA:
- png_ptr->channels = 4;
- break;
- }
-
- /* Set up other useful info */
- png_ptr->pixel_depth = (png_byte)(png_ptr->bit_depth * png_ptr->channels);
- png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->width);
- png_debug1(3, "bit_depth = %d", png_ptr->bit_depth);
- png_debug1(3, "channels = %d", png_ptr->channels);
- png_debug1(3, "rowbytes = %lu", (unsigned long)png_ptr->rowbytes);
- png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth,
- color_type, interlace_type, compression_type, filter_type);
-}
-
-/* Read and check the palette */
-void /* PRIVATE */
-png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
-{
- png_color palette[PNG_MAX_PALETTE_LENGTH];
- int max_palette_length, num, i;
-#ifdef PNG_POINTER_INDEXING_SUPPORTED
- png_colorp pal_ptr;
-#endif
-
- png_debug(1, "in png_handle_PLTE");
-
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_chunk_error(png_ptr, "missing IHDR");
-
- /* Moved to before the 'after IDAT' check below because otherwise duplicate
- * PLTE chunks are potentially ignored (the spec says there shall not be more
- * than one PLTE, the error is not treated as benign, so this check trumps
- * the requirement that PLTE appears before IDAT.)
- */
- else if ((png_ptr->mode & PNG_HAVE_PLTE) != 0)
- png_chunk_error(png_ptr, "duplicate");
-
- else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
- {
- /* This is benign because the non-benign error happened before, when an
- * IDAT was encountered in a color-mapped image with no PLTE.
- */
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "out of place");
- return;
- }
-
- png_ptr->mode |= PNG_HAVE_PLTE;
-
- if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) == 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "ignored in grayscale PNG");
- return;
- }
-
-#ifndef PNG_READ_OPT_PLTE_SUPPORTED
- if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE)
- {
- png_crc_finish(png_ptr, length);
- return;
- }
-#endif
-
- if (length > 3*PNG_MAX_PALETTE_LENGTH || length % 3)
- {
- png_crc_finish(png_ptr, length);
-
- if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE)
- png_chunk_benign_error(png_ptr, "invalid");
-
- else
- png_chunk_error(png_ptr, "invalid");
-
- return;
- }
-
- /* The cast is safe because 'length' is less than 3*PNG_MAX_PALETTE_LENGTH */
- num = (int)length / 3;
-
- /* If the palette has 256 or fewer entries but is too large for the bit
- * depth, we don't issue an error, to preserve the behavior of previous
- * libpng versions. We silently truncate the unused extra palette entries
- * here.
- */
- if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
- max_palette_length = (1 << png_ptr->bit_depth);
- else
- max_palette_length = PNG_MAX_PALETTE_LENGTH;
-
- if (num > max_palette_length)
- num = max_palette_length;
-
-#ifdef PNG_POINTER_INDEXING_SUPPORTED
- for (i = 0, pal_ptr = palette; i < num; i++, pal_ptr++)
- {
- png_byte buf[3];
-
- png_crc_read(png_ptr, buf, 3);
- pal_ptr->red = buf[0];
- pal_ptr->green = buf[1];
- pal_ptr->blue = buf[2];
- }
-#else
- for (i = 0; i < num; i++)
- {
- png_byte buf[3];
-
- png_crc_read(png_ptr, buf, 3);
- /* Don't depend upon png_color being any order */
- palette[i].red = buf[0];
- palette[i].green = buf[1];
- palette[i].blue = buf[2];
- }
-#endif
-
- /* If we actually need the PLTE chunk (ie for a paletted image), we do
- * whatever the normal CRC configuration tells us. However, if we
- * have an RGB image, the PLTE can be considered ancillary, so
- * we will act as though it is.
- */
-#ifndef PNG_READ_OPT_PLTE_SUPPORTED
- if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
-#endif
- {
- png_crc_finish(png_ptr, (png_uint_32) (length - (unsigned int)num * 3));
- }
-
-#ifndef PNG_READ_OPT_PLTE_SUPPORTED
- else if (png_crc_error(png_ptr) != 0) /* Only if we have a CRC error */
- {
- /* If we don't want to use the data from an ancillary chunk,
- * we have two options: an error abort, or a warning and we
- * ignore the data in this chunk (which should be OK, since
- * it's considered ancillary for a RGB or RGBA image).
- *
- * IMPLEMENTATION NOTE: this is only here because png_crc_finish uses the
- * chunk type to determine whether to check the ancillary or the critical
- * flags.
- */
- if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_USE) == 0)
- {
- if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) != 0)
- return;
-
- else
- png_chunk_error(png_ptr, "CRC error");
- }
-
- /* Otherwise, we (optionally) emit a warning and use the chunk. */
- else if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) == 0)
- png_chunk_warning(png_ptr, "CRC error");
- }
-#endif
-
- /* TODO: png_set_PLTE has the side effect of setting png_ptr->palette to its
- * own copy of the palette. This has the side effect that when png_start_row
- * is called (this happens after any call to png_read_update_info) the
- * info_ptr palette gets changed. This is extremely unexpected and
- * confusing.
- *
- * Fix this by not sharing the palette in this way.
- */
- png_set_PLTE(png_ptr, info_ptr, palette, num);
-
- /* The three chunks, bKGD, hIST and tRNS *must* appear after PLTE and before
- * IDAT. Prior to 1.6.0 this was not checked; instead the code merely
- * checked the apparent validity of a tRNS chunk inserted before PLTE on a
- * palette PNG. 1.6.0 attempts to rigorously follow the standard and
- * therefore does a benign error if the erroneous condition is detected *and*
- * cancels the tRNS if the benign error returns. The alternative is to
- * amend the standard since it would be rather hypocritical of the standards
- * maintainers to ignore it.
- */
-#ifdef PNG_READ_tRNS_SUPPORTED
- if (png_ptr->num_trans > 0 ||
- (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS) != 0))
- {
- /* Cancel this because otherwise it would be used if the transforms
- * require it. Don't cancel the 'valid' flag because this would prevent
- * detection of duplicate chunks.
- */
- png_ptr->num_trans = 0;
-
- if (info_ptr != NULL)
- info_ptr->num_trans = 0;
-
- png_chunk_benign_error(png_ptr, "tRNS must be after");
- }
-#endif
-
-#ifdef PNG_READ_hIST_SUPPORTED
- if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST) != 0)
- png_chunk_benign_error(png_ptr, "hIST must be after");
-#endif
-
-#ifdef PNG_READ_bKGD_SUPPORTED
- if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD) != 0)
- png_chunk_benign_error(png_ptr, "bKGD must be after");
-#endif
-}
-
-void /* PRIVATE */
-png_handle_IEND(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
-{
- png_debug(1, "in png_handle_IEND");
-
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0 ||
- (png_ptr->mode & PNG_HAVE_IDAT) == 0)
- png_chunk_error(png_ptr, "out of place");
-
- png_ptr->mode |= (PNG_AFTER_IDAT | PNG_HAVE_IEND);
-
- png_crc_finish(png_ptr, length);
-
- if (length != 0)
- png_chunk_benign_error(png_ptr, "invalid");
-
- PNG_UNUSED(info_ptr)
-}
-
-#ifdef PNG_READ_gAMA_SUPPORTED
-void /* PRIVATE */
-png_handle_gAMA(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
-{
- png_fixed_point igamma;
- png_byte buf[4];
-
- png_debug(1, "in png_handle_gAMA");
-
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_chunk_error(png_ptr, "missing IHDR");
-
- else if ((png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE)) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "out of place");
- return;
- }
-
- if (length != 4)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "invalid");
- return;
- }
-
- png_crc_read(png_ptr, buf, 4);
-
- if (png_crc_finish(png_ptr, 0) != 0)
- return;
-
- igamma = png_get_fixed_point(NULL, buf);
-
- png_colorspace_set_gamma(png_ptr, &png_ptr->colorspace, igamma);
- png_colorspace_sync(png_ptr, info_ptr);
-}
-#endif
-
-#ifdef PNG_READ_sBIT_SUPPORTED
-void /* PRIVATE */
-png_handle_sBIT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
-{
- unsigned int truelen, i;
- png_byte sample_depth;
- png_byte buf[4];
-
- png_debug(1, "in png_handle_sBIT");
-
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_chunk_error(png_ptr, "missing IHDR");
-
- else if ((png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE)) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "out of place");
- return;
- }
-
- if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "duplicate");
- return;
- }
-
- if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
- {
- truelen = 3;
- sample_depth = 8;
- }
-
- else
- {
- truelen = png_ptr->channels;
- sample_depth = png_ptr->bit_depth;
- }
-
- if (length != truelen || length > 4)
- {
- png_chunk_benign_error(png_ptr, "invalid");
- png_crc_finish(png_ptr, length);
- return;
- }
-
- buf[0] = buf[1] = buf[2] = buf[3] = sample_depth;
- png_crc_read(png_ptr, buf, truelen);
-
- if (png_crc_finish(png_ptr, 0) != 0)
- return;
-
- for (i=0; i<truelen; ++i)
- {
- if (buf[i] == 0 || buf[i] > sample_depth)
- {
- png_chunk_benign_error(png_ptr, "invalid");
- return;
- }
- }
-
- if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0)
- {
- png_ptr->sig_bit.red = buf[0];
- png_ptr->sig_bit.green = buf[1];
- png_ptr->sig_bit.blue = buf[2];
- png_ptr->sig_bit.alpha = buf[3];
- }
-
- else
- {
- png_ptr->sig_bit.gray = buf[0];
- png_ptr->sig_bit.red = buf[0];
- png_ptr->sig_bit.green = buf[0];
- png_ptr->sig_bit.blue = buf[0];
- png_ptr->sig_bit.alpha = buf[1];
- }
-
- png_set_sBIT(png_ptr, info_ptr, &(png_ptr->sig_bit));
-}
-#endif
-
-#ifdef PNG_READ_cHRM_SUPPORTED
-void /* PRIVATE */
-png_handle_cHRM(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
-{
- png_byte buf[32];
- png_xy xy;
-
- png_debug(1, "in png_handle_cHRM");
-
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_chunk_error(png_ptr, "missing IHDR");
-
- else if ((png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE)) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "out of place");
- return;
- }
-
- if (length != 32)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "invalid");
- return;
- }
-
- png_crc_read(png_ptr, buf, 32);
-
- if (png_crc_finish(png_ptr, 0) != 0)
- return;
-
- xy.whitex = png_get_fixed_point(NULL, buf);
- xy.whitey = png_get_fixed_point(NULL, buf + 4);
- xy.redx = png_get_fixed_point(NULL, buf + 8);
- xy.redy = png_get_fixed_point(NULL, buf + 12);
- xy.greenx = png_get_fixed_point(NULL, buf + 16);
- xy.greeny = png_get_fixed_point(NULL, buf + 20);
- xy.bluex = png_get_fixed_point(NULL, buf + 24);
- xy.bluey = png_get_fixed_point(NULL, buf + 28);
-
- if (xy.whitex == PNG_FIXED_ERROR ||
- xy.whitey == PNG_FIXED_ERROR ||
- xy.redx == PNG_FIXED_ERROR ||
- xy.redy == PNG_FIXED_ERROR ||
- xy.greenx == PNG_FIXED_ERROR ||
- xy.greeny == PNG_FIXED_ERROR ||
- xy.bluex == PNG_FIXED_ERROR ||
- xy.bluey == PNG_FIXED_ERROR)
- {
- png_chunk_benign_error(png_ptr, "invalid values");
- return;
- }
-
- /* If a colorspace error has already been output skip this chunk */
- if ((png_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) != 0)
- return;
-
- if ((png_ptr->colorspace.flags & PNG_COLORSPACE_FROM_cHRM) != 0)
- {
- png_ptr->colorspace.flags |= PNG_COLORSPACE_INVALID;
- png_colorspace_sync(png_ptr, info_ptr);
- png_chunk_benign_error(png_ptr, "duplicate");
- return;
- }
-
- png_ptr->colorspace.flags |= PNG_COLORSPACE_FROM_cHRM;
- (void)png_colorspace_set_chromaticities(png_ptr, &png_ptr->colorspace, &xy,
- 1/*prefer cHRM values*/);
- png_colorspace_sync(png_ptr, info_ptr);
-}
-#endif
-
-#ifdef PNG_READ_sRGB_SUPPORTED
-void /* PRIVATE */
-png_handle_sRGB(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
-{
- png_byte intent;
-
- png_debug(1, "in png_handle_sRGB");
-
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_chunk_error(png_ptr, "missing IHDR");
-
- else if ((png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE)) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "out of place");
- return;
- }
-
- if (length != 1)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "invalid");
- return;
- }
-
- png_crc_read(png_ptr, &intent, 1);
-
- if (png_crc_finish(png_ptr, 0) != 0)
- return;
-
- /* If a colorspace error has already been output skip this chunk */
- if ((png_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) != 0)
- return;
-
- /* Only one sRGB or iCCP chunk is allowed, use the HAVE_INTENT flag to detect
- * this.
- */
- if ((png_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_INTENT) != 0)
- {
- png_ptr->colorspace.flags |= PNG_COLORSPACE_INVALID;
- png_colorspace_sync(png_ptr, info_ptr);
- png_chunk_benign_error(png_ptr, "too many profiles");
- return;
- }
-
- (void)png_colorspace_set_sRGB(png_ptr, &png_ptr->colorspace, intent);
- png_colorspace_sync(png_ptr, info_ptr);
-}
-#endif /* READ_sRGB */
-
-#ifdef PNG_READ_iCCP_SUPPORTED
-void /* PRIVATE */
-png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
-/* Note: this does not properly handle profiles that are > 64K under DOS */
-{
- png_const_charp errmsg = NULL; /* error message output, or no error */
- int finished = 0; /* crc checked */
-
- png_debug(1, "in png_handle_iCCP");
-
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_chunk_error(png_ptr, "missing IHDR");
-
- else if ((png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE)) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "out of place");
- return;
- }
-
- /* Consistent with all the above colorspace handling an obviously *invalid*
- * chunk is just ignored, so does not invalidate the color space. An
- * alternative is to set the 'invalid' flags at the start of this routine
- * and only clear them in they were not set before and all the tests pass.
- */
-
- /* The keyword must be at least one character and there is a
- * terminator (0) byte and the compression method byte, and the
- * 'zlib' datastream is at least 11 bytes.
- */
- if (length < 14)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "too short");
- return;
- }
-
- /* If a colorspace error has already been output skip this chunk */
- if ((png_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) != 0)
- {
- png_crc_finish(png_ptr, length);
- return;
- }
-
- /* Only one sRGB or iCCP chunk is allowed, use the HAVE_INTENT flag to detect
- * this.
- */
- if ((png_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_INTENT) == 0)
- {
- uInt read_length, keyword_length;
- char keyword[81];
-
- /* Find the keyword; the keyword plus separator and compression method
- * bytes can be at most 81 characters long.
- */
- read_length = 81; /* maximum */
- if (read_length > length)
- read_length = (uInt)length;
-
- png_crc_read(png_ptr, (png_bytep)keyword, read_length);
- length -= read_length;
-
- /* The minimum 'zlib' stream is assumed to be just the 2 byte header,
- * 5 bytes minimum 'deflate' stream, and the 4 byte checksum.
- */
- if (length < 11)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "too short");
- return;
- }
-
- keyword_length = 0;
- while (keyword_length < 80 && keyword_length < read_length &&
- keyword[keyword_length] != 0)
- ++keyword_length;
-
- /* TODO: make the keyword checking common */
- if (keyword_length >= 1 && keyword_length <= 79)
- {
- /* We only understand '0' compression - deflate - so if we get a
- * different value we can't safely decode the chunk.
- */
- if (keyword_length+1 < read_length &&
- keyword[keyword_length+1] == PNG_COMPRESSION_TYPE_BASE)
- {
- read_length -= keyword_length+2;
-
- if (png_inflate_claim(png_ptr, png_iCCP) == Z_OK)
- {
- Byte profile_header[132]={0};
- Byte local_buffer[PNG_INFLATE_BUF_SIZE];
- png_alloc_size_t size = (sizeof profile_header);
-
- png_ptr->zstream.next_in = (Bytef*)keyword + (keyword_length+2);
- png_ptr->zstream.avail_in = read_length;
- (void)png_inflate_read(png_ptr, local_buffer,
- (sizeof local_buffer), &length, profile_header, &size,
- 0/*finish: don't, because the output is too small*/);
-
- if (size == 0)
- {
- /* We have the ICC profile header; do the basic header checks.
- */
- png_uint_32 profile_length = png_get_uint_32(profile_header);
-
- if (png_icc_check_length(png_ptr, &png_ptr->colorspace,
- keyword, profile_length) != 0)
- {
- /* The length is apparently ok, so we can check the 132
- * byte header.
- */
- if (png_icc_check_header(png_ptr, &png_ptr->colorspace,
- keyword, profile_length, profile_header,
- png_ptr->color_type) != 0)
- {
- /* Now read the tag table; a variable size buffer is
- * needed at this point, allocate one for the whole
- * profile. The header check has already validated
- * that none of this stuff will overflow.
- */
- png_uint_32 tag_count =
- png_get_uint_32(profile_header + 128);
- png_bytep profile = png_read_buffer(png_ptr,
- profile_length, 2/*silent*/);
-
- if (profile != NULL)
- {
- memcpy(profile, profile_header,
- (sizeof profile_header));
-
- size = 12 * tag_count;
-
- (void)png_inflate_read(png_ptr, local_buffer,
- (sizeof local_buffer), &length,
- profile + (sizeof profile_header), &size, 0);
-
- /* Still expect a buffer error because we expect
- * there to be some tag data!
- */
- if (size == 0)
- {
- if (png_icc_check_tag_table(png_ptr,
- &png_ptr->colorspace, keyword, profile_length,
- profile) != 0)
- {
- /* The profile has been validated for basic
- * security issues, so read the whole thing in.
- */
- size = profile_length - (sizeof profile_header)
- - 12 * tag_count;
-
- (void)png_inflate_read(png_ptr, local_buffer,
- (sizeof local_buffer), &length,
- profile + (sizeof profile_header) +
- 12 * tag_count, &size, 1/*finish*/);
-
- if (length > 0 && !(png_ptr->flags &
- PNG_FLAG_BENIGN_ERRORS_WARN))
- errmsg = "extra compressed data";
-
- /* But otherwise allow extra data: */
- else if (size == 0)
- {
- if (length > 0)
- {
- /* This can be handled completely, so
- * keep going.
- */
- png_chunk_warning(png_ptr,
- "extra compressed data");
- }
-
- png_crc_finish(png_ptr, length);
- finished = 1;
-
-# if defined(PNG_sRGB_SUPPORTED) && PNG_sRGB_PROFILE_CHECKS >= 0
- /* Check for a match against sRGB */
- png_icc_set_sRGB(png_ptr,
- &png_ptr->colorspace, profile,
- png_ptr->zstream.adler);
-# endif
-
- /* Steal the profile for info_ptr. */
- if (info_ptr != NULL)
- {
- png_free_data(png_ptr, info_ptr,
- PNG_FREE_ICCP, 0);
-
- info_ptr->iccp_name = png_voidcast(char*,
- png_malloc_base(png_ptr,
- keyword_length+1));
- if (info_ptr->iccp_name != NULL)
- {
- memcpy(info_ptr->iccp_name, keyword,
- keyword_length+1);
- info_ptr->iccp_proflen =
- profile_length;
- info_ptr->iccp_profile = profile;
- png_ptr->read_buffer = NULL; /*steal*/
- info_ptr->free_me |= PNG_FREE_ICCP;
- info_ptr->valid |= PNG_INFO_iCCP;
- }
-
- else
- {
- png_ptr->colorspace.flags |=
- PNG_COLORSPACE_INVALID;
- errmsg = "out of memory";
- }
- }
-
- /* else the profile remains in the read
- * buffer which gets reused for subsequent
- * chunks.
- */
-
- if (info_ptr != NULL)
- png_colorspace_sync(png_ptr, info_ptr);
-
- if (errmsg == NULL)
- {
- png_ptr->zowner = 0;
- return;
- }
- }
- if (errmsg == NULL)
- errmsg = png_ptr->zstream.msg;
- }
- /* else png_icc_check_tag_table output an error */
- }
- else /* profile truncated */
- errmsg = png_ptr->zstream.msg;
- }
-
- else
- errmsg = "out of memory";
- }
-
- /* else png_icc_check_header output an error */
- }
-
- /* else png_icc_check_length output an error */
- }
-
- else /* profile truncated */
- errmsg = png_ptr->zstream.msg;
-
- /* Release the stream */
- png_ptr->zowner = 0;
- }
-
- else /* png_inflate_claim failed */
- errmsg = png_ptr->zstream.msg;
- }
-
- else
- errmsg = "bad compression method"; /* or missing */
- }
-
- else
- errmsg = "bad keyword";
- }
-
- else
- errmsg = "too many profiles";
-
- /* Failure: the reason is in 'errmsg' */
- if (finished == 0)
- png_crc_finish(png_ptr, length);
-
- png_ptr->colorspace.flags |= PNG_COLORSPACE_INVALID;
- png_colorspace_sync(png_ptr, info_ptr);
- if (errmsg != NULL) /* else already output */
- png_chunk_benign_error(png_ptr, errmsg);
-}
-#endif /* READ_iCCP */
-
-#ifdef PNG_READ_sPLT_SUPPORTED
-void /* PRIVATE */
-png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
-/* Note: this does not properly handle chunks that are > 64K under DOS */
-{
- png_bytep entry_start, buffer;
- png_sPLT_t new_palette;
- png_sPLT_entryp pp;
- png_uint_32 data_length;
- int entry_size, i;
- png_uint_32 skip = 0;
- png_uint_32 dl;
- size_t max_dl;
-
- png_debug(1, "in png_handle_sPLT");
-
-#ifdef PNG_USER_LIMITS_SUPPORTED
- if (png_ptr->user_chunk_cache_max != 0)
- {
- if (png_ptr->user_chunk_cache_max == 1)
- {
- png_crc_finish(png_ptr, length);
- return;
- }
-
- if (--png_ptr->user_chunk_cache_max == 1)
- {
- png_warning(png_ptr, "No space in chunk cache for sPLT");
- png_crc_finish(png_ptr, length);
- return;
- }
- }
-#endif
-
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_chunk_error(png_ptr, "missing IHDR");
-
- else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "out of place");
- return;
- }
-
-#ifdef PNG_MAX_MALLOC_64K
- if (length > 65535U)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "too large to fit in memory");
- return;
- }
-#endif
-
- buffer = png_read_buffer(png_ptr, length+1, 2/*silent*/);
- if (buffer == NULL)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "out of memory");
- return;
- }
-
-
- /* WARNING: this may break if size_t is less than 32 bits; it is assumed
- * that the PNG_MAX_MALLOC_64K test is enabled in this case, but this is a
- * potential breakage point if the types in pngconf.h aren't exactly right.
- */
- png_crc_read(png_ptr, buffer, length);
-
- if (png_crc_finish(png_ptr, skip) != 0)
- return;
-
- buffer[length] = 0;
-
- for (entry_start = buffer; *entry_start; entry_start++)
- /* Empty loop to find end of name */ ;
-
- ++entry_start;
-
- /* A sample depth should follow the separator, and we should be on it */
- if (length < 2U || entry_start > buffer + (length - 2U))
- {
- png_warning(png_ptr, "malformed sPLT chunk");
- return;
- }
-
- new_palette.depth = *entry_start++;
- entry_size = (new_palette.depth == 8 ? 6 : 10);
- /* This must fit in a png_uint_32 because it is derived from the original
- * chunk data length.
- */
- data_length = length - (png_uint_32)(entry_start - buffer);
-
- /* Integrity-check the data length */
- if ((data_length % (unsigned int)entry_size) != 0)
- {
- png_warning(png_ptr, "sPLT chunk has bad length");
- return;
- }
-
- dl = (png_uint_32)(data_length / (unsigned int)entry_size);
- max_dl = PNG_SIZE_MAX / (sizeof (png_sPLT_entry));
-
- if (dl > max_dl)
- {
- png_warning(png_ptr, "sPLT chunk too long");
- return;
- }
-
- new_palette.nentries = (png_int_32)(data_length / (unsigned int)entry_size);
-
- new_palette.entries = (png_sPLT_entryp)png_malloc_warn(png_ptr,
- (png_alloc_size_t) new_palette.nentries * (sizeof (png_sPLT_entry)));
-
- if (new_palette.entries == NULL)
- {
- png_warning(png_ptr, "sPLT chunk requires too much memory");
- return;
- }
-
-#ifdef PNG_POINTER_INDEXING_SUPPORTED
- for (i = 0; i < new_palette.nentries; i++)
- {
- pp = new_palette.entries + i;
-
- if (new_palette.depth == 8)
- {
- pp->red = *entry_start++;
- pp->green = *entry_start++;
- pp->blue = *entry_start++;
- pp->alpha = *entry_start++;
- }
-
- else
- {
- pp->red = png_get_uint_16(entry_start); entry_start += 2;
- pp->green = png_get_uint_16(entry_start); entry_start += 2;
- pp->blue = png_get_uint_16(entry_start); entry_start += 2;
- pp->alpha = png_get_uint_16(entry_start); entry_start += 2;
- }
-
- pp->frequency = png_get_uint_16(entry_start); entry_start += 2;
- }
-#else
- pp = new_palette.entries;
-
- for (i = 0; i < new_palette.nentries; i++)
- {
-
- if (new_palette.depth == 8)
- {
- pp[i].red = *entry_start++;
- pp[i].green = *entry_start++;
- pp[i].blue = *entry_start++;
- pp[i].alpha = *entry_start++;
- }
-
- else
- {
- pp[i].red = png_get_uint_16(entry_start); entry_start += 2;
- pp[i].green = png_get_uint_16(entry_start); entry_start += 2;
- pp[i].blue = png_get_uint_16(entry_start); entry_start += 2;
- pp[i].alpha = png_get_uint_16(entry_start); entry_start += 2;
- }
-
- pp[i].frequency = png_get_uint_16(entry_start); entry_start += 2;
- }
-#endif
-
- /* Discard all chunk data except the name and stash that */
- new_palette.name = (png_charp)buffer;
-
- png_set_sPLT(png_ptr, info_ptr, &new_palette, 1);
-
- png_free(png_ptr, new_palette.entries);
-}
-#endif /* READ_sPLT */
-
-#ifdef PNG_READ_tRNS_SUPPORTED
-void /* PRIVATE */
-png_handle_tRNS(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
-{
- png_byte readbuf[PNG_MAX_PALETTE_LENGTH];
-
- png_debug(1, "in png_handle_tRNS");
-
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_chunk_error(png_ptr, "missing IHDR");
-
- else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "out of place");
- return;
- }
-
- else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "duplicate");
- return;
- }
-
- if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY)
- {
- png_byte buf[2];
-
- if (length != 2)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "invalid");
- return;
- }
-
- png_crc_read(png_ptr, buf, 2);
- png_ptr->num_trans = 1;
- png_ptr->trans_color.gray = png_get_uint_16(buf);
- }
-
- else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB)
- {
- png_byte buf[6];
-
- if (length != 6)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "invalid");
- return;
- }
-
- png_crc_read(png_ptr, buf, length);
- png_ptr->num_trans = 1;
- png_ptr->trans_color.red = png_get_uint_16(buf);
- png_ptr->trans_color.green = png_get_uint_16(buf + 2);
- png_ptr->trans_color.blue = png_get_uint_16(buf + 4);
- }
-
- else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
- {
- if ((png_ptr->mode & PNG_HAVE_PLTE) == 0)
- {
- /* TODO: is this actually an error in the ISO spec? */
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "out of place");
- return;
- }
-
- if (length > (unsigned int) png_ptr->num_palette ||
- length > (unsigned int) PNG_MAX_PALETTE_LENGTH ||
- length == 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "invalid");
- return;
- }
-
- png_crc_read(png_ptr, readbuf, length);
- png_ptr->num_trans = (png_uint_16)length;
- }
-
- else
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "invalid with alpha channel");
- return;
- }
-
- if (png_crc_finish(png_ptr, 0) != 0)
- {
- png_ptr->num_trans = 0;
- return;
- }
-
- /* TODO: this is a horrible side effect in the palette case because the
- * png_struct ends up with a pointer to the tRNS buffer owned by the
- * png_info. Fix this.
- */
- png_set_tRNS(png_ptr, info_ptr, readbuf, png_ptr->num_trans,
- &(png_ptr->trans_color));
-}
-#endif
-
-#ifdef PNG_READ_bKGD_SUPPORTED
-void /* PRIVATE */
-png_handle_bKGD(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
-{
- unsigned int truelen;
- png_byte buf[6];
- png_color_16 background;
-
- png_debug(1, "in png_handle_bKGD");
-
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_chunk_error(png_ptr, "missing IHDR");
-
- else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0 ||
- (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
- (png_ptr->mode & PNG_HAVE_PLTE) == 0))
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "out of place");
- return;
- }
-
- else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "duplicate");
- return;
- }
-
- if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
- truelen = 1;
-
- else if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0)
- truelen = 6;
-
- else
- truelen = 2;
-
- if (length != truelen)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "invalid");
- return;
- }
-
- png_crc_read(png_ptr, buf, truelen);
-
- if (png_crc_finish(png_ptr, 0) != 0)
- return;
-
- /* We convert the index value into RGB components so that we can allow
- * arbitrary RGB values for background when we have transparency, and
- * so it is easy to determine the RGB values of the background color
- * from the info_ptr struct.
- */
- if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
- {
- background.index = buf[0];
-
- if (info_ptr != NULL && info_ptr->num_palette != 0)
- {
- if (buf[0] >= info_ptr->num_palette)
- {
- png_chunk_benign_error(png_ptr, "invalid index");
- return;
- }
-
- background.red = (png_uint_16)png_ptr->palette[buf[0]].red;
- background.green = (png_uint_16)png_ptr->palette[buf[0]].green;
- background.blue = (png_uint_16)png_ptr->palette[buf[0]].blue;
- }
-
- else
- background.red = background.green = background.blue = 0;
-
- background.gray = 0;
- }
-
- else if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) == 0) /* GRAY */
- {
- if (png_ptr->bit_depth <= 8)
- {
- if (buf[0] != 0 || buf[1] >= (unsigned int)(1 << png_ptr->bit_depth))
- {
- png_chunk_benign_error(png_ptr, "invalid gray level");
- return;
- }
- }
-
- background.index = 0;
- background.red =
- background.green =
- background.blue =
- background.gray = png_get_uint_16(buf);
- }
-
- else
- {
- if (png_ptr->bit_depth <= 8)
- {
- if (buf[0] != 0 || buf[2] != 0 || buf[4] != 0)
- {
- png_chunk_benign_error(png_ptr, "invalid color");
- return;
- }
- }
-
- background.index = 0;
- background.red = png_get_uint_16(buf);
- background.green = png_get_uint_16(buf + 2);
- background.blue = png_get_uint_16(buf + 4);
- background.gray = 0;
- }
-
- png_set_bKGD(png_ptr, info_ptr, &background);
-}
-#endif
-
-#ifdef PNG_READ_cICP_SUPPORTED
-void /* PRIVATE */
-png_handle_cICP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
-{
- png_byte buf[4];
-
- png_debug(1, "in png_handle_cICP");
-
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_chunk_error(png_ptr, "missing IHDR");
-
- else if ((png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE)) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "out of place");
- return;
- }
-
- else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_cICP) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "duplicate");
- return;
- }
-
- else if (length != 4)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "invalid");
- return;
- }
-
- png_crc_read(png_ptr, buf, 4);
-
- if (png_crc_finish(png_ptr, 0) != 0)
- return;
-
- png_set_cICP(png_ptr, info_ptr, buf[0], buf[1], buf[2], buf[3]);
-}
-#endif
-
-#ifdef PNG_READ_cLLI_SUPPORTED
-void /* PRIVATE */
-png_handle_cLLI(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
-{
- png_byte buf[8];
-
- png_debug(1, "in png_handle_cLLI");
-
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_chunk_error(png_ptr, "missing IHDR");
-
- else if ((png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE)) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "out of place");
- return;
- }
-
- else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_cLLI) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "duplicate");
- return;
- }
-
- else if (length != 8)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "invalid");
- return;
- }
-
- png_crc_read(png_ptr, buf, 8);
-
- if (png_crc_finish(png_ptr, 0) != 0)
- return;
-
- /* The error checking happens here, this puts it in just one place: */
- png_set_cLLI_fixed(png_ptr, info_ptr, png_get_uint_32(buf),
- png_get_uint_32(buf+4));
-}
-#endif
-
-#ifdef PNG_READ_mDCV_SUPPORTED
-void /* PRIVATE */
-png_handle_mDCV(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
-{
- png_byte buf[24];
-
- png_debug(1, "in png_handle_mDCV");
-
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_chunk_error(png_ptr, "missing IHDR");
-
- else if ((png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE)) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "out of place");
- return;
- }
-
- else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_mDCV) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "duplicate");
- return;
- }
-
- else if (length != 24)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "invalid");
- return;
- }
-
- png_crc_read(png_ptr, buf, 24);
-
- if (png_crc_finish(png_ptr, 0) != 0)
- return;
-
- /* The error checking happens here, this puts it in just one place. The
- * odd /50000 scaling factor makes it more difficult but the (x.y) values are
- * only two bytes so a <<1 is safe.
- *
- * WARNING: the PNG specification defines the cHRM chunk to **start** with
- * the white point (x,y). The W3C PNG v3 specification puts the white point
- * **after* R,G,B. The x,y values in mDCV are also scaled by 50,000 and
- * stored in just two bytes, whereas those in cHRM are scaled by 100,000 and
- * stored in four bytes. This is very, very confusing. These APIs remove
- * the confusion by copying the existing, well established, API.
- */
- png_set_mDCV_fixed(png_ptr, info_ptr,
- png_get_uint_16(buf+12U) << 1U, /* white x */
- png_get_uint_16(buf+14U) << 1U, /* white y */
- png_get_uint_16(buf+ 0U) << 1U, /* red x */
- png_get_uint_16(buf+ 2U) << 1U, /* red y */
- png_get_uint_16(buf+ 4U) << 1U, /* green x */
- png_get_uint_16(buf+ 6U) << 1U, /* green y */
- png_get_uint_16(buf+ 8U) << 1U, /* blue x */
- png_get_uint_16(buf+10U) << 1U, /* blue y */
- png_get_uint_32(buf+16U), /* peak luminance */
- png_get_uint_32(buf+20U));/* minimum perceivable luminance */
-}
-#endif
-
-#ifdef PNG_READ_eXIf_SUPPORTED
-void /* PRIVATE */
-png_handle_eXIf(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
-{
- unsigned int i;
-
- png_debug(1, "in png_handle_eXIf");
-
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_chunk_error(png_ptr, "missing IHDR");
-
- if (length < 2)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "too short");
- return;
- }
-
- else if (info_ptr == NULL || (info_ptr->valid & PNG_INFO_eXIf) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "duplicate");
- return;
- }
-
- info_ptr->free_me |= PNG_FREE_EXIF;
-
- info_ptr->eXIf_buf = png_voidcast(png_bytep,
- png_malloc_warn(png_ptr, length));
-
- if (info_ptr->eXIf_buf == NULL)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "out of memory");
- return;
- }
-
- for (i = 0; i < length; i++)
- {
- png_byte buf[1];
- png_crc_read(png_ptr, buf, 1);
- info_ptr->eXIf_buf[i] = buf[0];
- if (i == 1)
- {
- if ((buf[0] != 'M' && buf[0] != 'I') ||
- (info_ptr->eXIf_buf[0] != buf[0]))
- {
- png_crc_finish(png_ptr, length - 2);
- png_chunk_benign_error(png_ptr, "incorrect byte-order specifier");
- png_free(png_ptr, info_ptr->eXIf_buf);
- info_ptr->eXIf_buf = NULL;
- return;
- }
- }
- }
-
- if (png_crc_finish(png_ptr, 0) == 0)
- png_set_eXIf_1(png_ptr, info_ptr, length, info_ptr->eXIf_buf);
-
- png_free(png_ptr, info_ptr->eXIf_buf);
- info_ptr->eXIf_buf = NULL;
-}
-#endif
-
-#ifdef PNG_READ_hIST_SUPPORTED
-void /* PRIVATE */
-png_handle_hIST(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
-{
- unsigned int num, i;
- png_uint_16 readbuf[PNG_MAX_PALETTE_LENGTH];
-
- png_debug(1, "in png_handle_hIST");
-
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_chunk_error(png_ptr, "missing IHDR");
-
- else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0 ||
- (png_ptr->mode & PNG_HAVE_PLTE) == 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "out of place");
- return;
- }
-
- else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "duplicate");
- return;
- }
-
- num = length / 2 ;
-
- if (length != num * 2 ||
- num != (unsigned int)png_ptr->num_palette ||
- num > (unsigned int)PNG_MAX_PALETTE_LENGTH)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "invalid");
- return;
- }
-
- for (i = 0; i < num; i++)
- {
- png_byte buf[2];
-
- png_crc_read(png_ptr, buf, 2);
- readbuf[i] = png_get_uint_16(buf);
- }
-
- if (png_crc_finish(png_ptr, 0) != 0)
- return;
-
- png_set_hIST(png_ptr, info_ptr, readbuf);
-}
-#endif
-
-#ifdef PNG_READ_pHYs_SUPPORTED
-void /* PRIVATE */
-png_handle_pHYs(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
-{
- png_byte buf[9];
- png_uint_32 res_x, res_y;
- int unit_type;
-
- png_debug(1, "in png_handle_pHYs");
-
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_chunk_error(png_ptr, "missing IHDR");
-
- else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "out of place");
- return;
- }
-
- else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "duplicate");
- return;
- }
-
- if (length != 9)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "invalid");
- return;
- }
-
- png_crc_read(png_ptr, buf, 9);
-
- if (png_crc_finish(png_ptr, 0) != 0)
- return;
-
- res_x = png_get_uint_32(buf);
- res_y = png_get_uint_32(buf + 4);
- unit_type = buf[8];
- png_set_pHYs(png_ptr, info_ptr, res_x, res_y, unit_type);
-}
-#endif
-
-#ifdef PNG_READ_oFFs_SUPPORTED
-void /* PRIVATE */
-png_handle_oFFs(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
-{
- png_byte buf[9];
- png_int_32 offset_x, offset_y;
- int unit_type;
-
- png_debug(1, "in png_handle_oFFs");
-
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_chunk_error(png_ptr, "missing IHDR");
-
- else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "out of place");
- return;
- }
-
- else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "duplicate");
- return;
- }
-
- if (length != 9)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "invalid");
- return;
- }
-
- png_crc_read(png_ptr, buf, 9);
-
- if (png_crc_finish(png_ptr, 0) != 0)
- return;
-
- offset_x = png_get_int_32(buf);
- offset_y = png_get_int_32(buf + 4);
- unit_type = buf[8];
- png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y, unit_type);
-}
-#endif
-
-#ifdef PNG_READ_pCAL_SUPPORTED
-/* Read the pCAL chunk (described in the PNG Extensions document) */
-void /* PRIVATE */
-png_handle_pCAL(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
-{
- png_int_32 X0, X1;
- png_byte type, nparams;
- png_bytep buffer, buf, units, endptr;
- png_charpp params;
- int i;
-
- png_debug(1, "in png_handle_pCAL");
-
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_chunk_error(png_ptr, "missing IHDR");
-
- else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "out of place");
- return;
- }
-
- else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "duplicate");
- return;
- }
-
- png_debug1(2, "Allocating and reading pCAL chunk data (%u bytes)",
- length + 1);
-
- buffer = png_read_buffer(png_ptr, length+1, 2/*silent*/);
-
- if (buffer == NULL)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "out of memory");
- return;
- }
-
- png_crc_read(png_ptr, buffer, length);
-
- if (png_crc_finish(png_ptr, 0) != 0)
- return;
-
- buffer[length] = 0; /* Null terminate the last string */
-
- png_debug(3, "Finding end of pCAL purpose string");
- for (buf = buffer; *buf; buf++)
- /* Empty loop */ ;
-
- endptr = buffer + length;
-
- /* We need to have at least 12 bytes after the purpose string
- * in order to get the parameter information.
- */
- if (endptr - buf <= 12)
- {
- png_chunk_benign_error(png_ptr, "invalid");
- return;
- }
-
- png_debug(3, "Reading pCAL X0, X1, type, nparams, and units");
- X0 = png_get_int_32((png_bytep)buf+1);
- X1 = png_get_int_32((png_bytep)buf+5);
- type = buf[9];
- nparams = buf[10];
- units = buf + 11;
-
- png_debug(3, "Checking pCAL equation type and number of parameters");
- /* Check that we have the right number of parameters for known
- * equation types.
- */
- if ((type == PNG_EQUATION_LINEAR && nparams != 2) ||
- (type == PNG_EQUATION_BASE_E && nparams != 3) ||
- (type == PNG_EQUATION_ARBITRARY && nparams != 3) ||
- (type == PNG_EQUATION_HYPERBOLIC && nparams != 4))
- {
- png_chunk_benign_error(png_ptr, "invalid parameter count");
- return;
- }
-
- else if (type >= PNG_EQUATION_LAST)
- {
- png_chunk_benign_error(png_ptr, "unrecognized equation type");
- }
-
- for (buf = units; *buf; buf++)
- /* Empty loop to move past the units string. */ ;
-
- png_debug(3, "Allocating pCAL parameters array");
-
- params = png_voidcast(png_charpp, png_malloc_warn(png_ptr,
- nparams * (sizeof (png_charp))));
-
- if (params == NULL)
- {
- png_chunk_benign_error(png_ptr, "out of memory");
- return;
- }
-
- /* Get pointers to the start of each parameter string. */
- for (i = 0; i < nparams; i++)
- {
- buf++; /* Skip the null string terminator from previous parameter. */
-
- png_debug1(3, "Reading pCAL parameter %d", i);
-
- for (params[i] = (png_charp)buf; buf <= endptr && *buf != 0; buf++)
- /* Empty loop to move past each parameter string */ ;
-
- /* Make sure we haven't run out of data yet */
- if (buf > endptr)
- {
- png_free(png_ptr, params);
- png_chunk_benign_error(png_ptr, "invalid data");
- return;
- }
- }
-
- png_set_pCAL(png_ptr, info_ptr, (png_charp)buffer, X0, X1, type, nparams,
- (png_charp)units, params);
-
- png_free(png_ptr, params);
-}
-#endif
-
-#ifdef PNG_READ_sCAL_SUPPORTED
-/* Read the sCAL chunk */
-void /* PRIVATE */
-png_handle_sCAL(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
-{
- png_bytep buffer;
- size_t i;
- int state;
-
- png_debug(1, "in png_handle_sCAL");
-
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_chunk_error(png_ptr, "missing IHDR");
-
- else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "out of place");
- return;
- }
-
- else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sCAL) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "duplicate");
- return;
- }
-
- /* Need unit type, width, \0, height: minimum 4 bytes */
- else if (length < 4)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "invalid");
- return;
- }
-
- png_debug1(2, "Allocating and reading sCAL chunk data (%u bytes)",
- length + 1);
-
- buffer = png_read_buffer(png_ptr, length+1, 2/*silent*/);
-
- if (buffer == NULL)
- {
- png_chunk_benign_error(png_ptr, "out of memory");
- png_crc_finish(png_ptr, length);
- return;
- }
-
- png_crc_read(png_ptr, buffer, length);
- buffer[length] = 0; /* Null terminate the last string */
-
- if (png_crc_finish(png_ptr, 0) != 0)
- return;
-
- /* Validate the unit. */
- if (buffer[0] != 1 && buffer[0] != 2)
- {
- png_chunk_benign_error(png_ptr, "invalid unit");
- return;
- }
-
- /* Validate the ASCII numbers, need two ASCII numbers separated by
- * a '\0' and they need to fit exactly in the chunk data.
- */
- i = 1;
- state = 0;
-
- if (png_check_fp_number((png_const_charp)buffer, length, &state, &i) == 0 ||
- i >= length || buffer[i++] != 0)
- png_chunk_benign_error(png_ptr, "bad width format");
-
- else if (PNG_FP_IS_POSITIVE(state) == 0)
- png_chunk_benign_error(png_ptr, "non-positive width");
-
- else
- {
- size_t heighti = i;
-
- state = 0;
- if (png_check_fp_number((png_const_charp)buffer, length,
- &state, &i) == 0 || i != length)
- png_chunk_benign_error(png_ptr, "bad height format");
-
- else if (PNG_FP_IS_POSITIVE(state) == 0)
- png_chunk_benign_error(png_ptr, "non-positive height");
-
- else
- /* This is the (only) success case. */
- png_set_sCAL_s(png_ptr, info_ptr, buffer[0],
- (png_charp)buffer+1, (png_charp)buffer+heighti);
- }
-}
-#endif
-
-#ifdef PNG_READ_tIME_SUPPORTED
-void /* PRIVATE */
-png_handle_tIME(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
-{
- png_byte buf[7];
- png_time mod_time;
-
- png_debug(1, "in png_handle_tIME");
-
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_chunk_error(png_ptr, "missing IHDR");
-
- else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "duplicate");
- return;
- }
-
- if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
- png_ptr->mode |= PNG_AFTER_IDAT;
-
- if (length != 7)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "invalid");
- return;
- }
-
- png_crc_read(png_ptr, buf, 7);
-
- if (png_crc_finish(png_ptr, 0) != 0)
- return;
-
- mod_time.second = buf[6];
- mod_time.minute = buf[5];
- mod_time.hour = buf[4];
- mod_time.day = buf[3];
- mod_time.month = buf[2];
- mod_time.year = png_get_uint_16(buf);
-
- png_set_tIME(png_ptr, info_ptr, &mod_time);
-}
-#endif
-
-#ifdef PNG_READ_tEXt_SUPPORTED
-/* Note: this does not properly handle chunks that are > 64K under DOS */
-void /* PRIVATE */
-png_handle_tEXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
-{
- png_text text_info;
- png_bytep buffer;
- png_charp key;
- png_charp text;
- png_uint_32 skip = 0;
-
- png_debug(1, "in png_handle_tEXt");
-
-#ifdef PNG_USER_LIMITS_SUPPORTED
- if (png_ptr->user_chunk_cache_max != 0)
- {
- if (png_ptr->user_chunk_cache_max == 1)
- {
- png_crc_finish(png_ptr, length);
- return;
- }
-
- if (--png_ptr->user_chunk_cache_max == 1)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "no space in chunk cache");
- return;
- }
- }
-#endif
-
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_chunk_error(png_ptr, "missing IHDR");
-
- if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
- png_ptr->mode |= PNG_AFTER_IDAT;
-
-#ifdef PNG_MAX_MALLOC_64K
- if (length > 65535U)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "too large to fit in memory");
- return;
- }
-#endif
-
- buffer = png_read_buffer(png_ptr, length+1, 1/*warn*/);
-
- if (buffer == NULL)
- {
- png_chunk_benign_error(png_ptr, "out of memory");
- return;
- }
-
- png_crc_read(png_ptr, buffer, length);
-
- if (png_crc_finish(png_ptr, skip) != 0)
- return;
-
- key = (png_charp)buffer;
- key[length] = 0;
-
- for (text = key; *text; text++)
- /* Empty loop to find end of key */ ;
-
- if (text != key + length)
- text++;
-
- text_info.compression = PNG_TEXT_COMPRESSION_NONE;
- text_info.key = key;
- text_info.lang = NULL;
- text_info.lang_key = NULL;
- text_info.itxt_length = 0;
- text_info.text = text;
- text_info.text_length = strlen(text);
-
- if (png_set_text_2(png_ptr, info_ptr, &text_info, 1) != 0)
- png_warning(png_ptr, "Insufficient memory to process text chunk");
-}
-#endif
-
-#ifdef PNG_READ_zTXt_SUPPORTED
-/* Note: this does not correctly handle chunks that are > 64K under DOS */
-void /* PRIVATE */
-png_handle_zTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
-{
- png_const_charp errmsg = NULL;
- png_bytep buffer;
- png_uint_32 keyword_length;
-
- png_debug(1, "in png_handle_zTXt");
-
-#ifdef PNG_USER_LIMITS_SUPPORTED
- if (png_ptr->user_chunk_cache_max != 0)
- {
- if (png_ptr->user_chunk_cache_max == 1)
- {
- png_crc_finish(png_ptr, length);
- return;
- }
-
- if (--png_ptr->user_chunk_cache_max == 1)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "no space in chunk cache");
- return;
- }
- }
-#endif
-
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_chunk_error(png_ptr, "missing IHDR");
-
- if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
- png_ptr->mode |= PNG_AFTER_IDAT;
-
- /* Note, "length" is sufficient here; we won't be adding
- * a null terminator later.
- */
- buffer = png_read_buffer(png_ptr, length, 2/*silent*/);
-
- if (buffer == NULL)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "out of memory");
- return;
- }
-
- png_crc_read(png_ptr, buffer, length);
-
- if (png_crc_finish(png_ptr, 0) != 0)
- return;
-
- /* TODO: also check that the keyword contents match the spec! */
- for (keyword_length = 0;
- keyword_length < length && buffer[keyword_length] != 0;
- ++keyword_length)
- /* Empty loop to find end of name */ ;
-
- if (keyword_length > 79 || keyword_length < 1)
- errmsg = "bad keyword";
-
- /* zTXt must have some LZ data after the keyword, although it may expand to
- * zero bytes; we need a '\0' at the end of the keyword, the compression type
- * then the LZ data:
- */
- else if (keyword_length + 3 > length)
- errmsg = "truncated";
-
- else if (buffer[keyword_length+1] != PNG_COMPRESSION_TYPE_BASE)
- errmsg = "unknown compression type";
-
- else
- {
- png_alloc_size_t uncompressed_length = PNG_SIZE_MAX;
-
- /* TODO: at present png_decompress_chunk imposes a single application
- * level memory limit, this should be split to different values for iCCP
- * and text chunks.
- */
- if (png_decompress_chunk(png_ptr, length, keyword_length+2,
- &uncompressed_length, 1/*terminate*/) == Z_STREAM_END)
- {
- png_text text;
-
- if (png_ptr->read_buffer == NULL)
- errmsg="Read failure in png_handle_zTXt";
- else
- {
- /* It worked; png_ptr->read_buffer now looks like a tEXt chunk
- * except for the extra compression type byte and the fact that
- * it isn't necessarily '\0' terminated.
- */
- buffer = png_ptr->read_buffer;
- buffer[uncompressed_length+(keyword_length+2)] = 0;
-
- text.compression = PNG_TEXT_COMPRESSION_zTXt;
- text.key = (png_charp)buffer;
- text.text = (png_charp)(buffer + keyword_length+2);
- text.text_length = uncompressed_length;
- text.itxt_length = 0;
- text.lang = NULL;
- text.lang_key = NULL;
-
- if (png_set_text_2(png_ptr, info_ptr, &text, 1) != 0)
- errmsg = "insufficient memory";
- }
- }
-
- else
- errmsg = png_ptr->zstream.msg;
- }
-
- if (errmsg != NULL)
- png_chunk_benign_error(png_ptr, errmsg);
-}
-#endif
-
-#ifdef PNG_READ_iTXt_SUPPORTED
-/* Note: this does not correctly handle chunks that are > 64K under DOS */
-void /* PRIVATE */
-png_handle_iTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
-{
- png_const_charp errmsg = NULL;
- png_bytep buffer;
- png_uint_32 prefix_length;
-
- png_debug(1, "in png_handle_iTXt");
-
-#ifdef PNG_USER_LIMITS_SUPPORTED
- if (png_ptr->user_chunk_cache_max != 0)
- {
- if (png_ptr->user_chunk_cache_max == 1)
- {
- png_crc_finish(png_ptr, length);
- return;
- }
-
- if (--png_ptr->user_chunk_cache_max == 1)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "no space in chunk cache");
- return;
- }
- }
-#endif
-
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_chunk_error(png_ptr, "missing IHDR");
-
- if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
- png_ptr->mode |= PNG_AFTER_IDAT;
-
- buffer = png_read_buffer(png_ptr, length+1, 1/*warn*/);
-
- if (buffer == NULL)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "out of memory");
- return;
- }
-
- png_crc_read(png_ptr, buffer, length);
-
- if (png_crc_finish(png_ptr, 0) != 0)
- return;
-
- /* First the keyword. */
- for (prefix_length=0;
- prefix_length < length && buffer[prefix_length] != 0;
- ++prefix_length)
- /* Empty loop */ ;
-
- /* Perform a basic check on the keyword length here. */
- if (prefix_length > 79 || prefix_length < 1)
- errmsg = "bad keyword";
-
- /* Expect keyword, compression flag, compression type, language, translated
- * keyword (both may be empty but are 0 terminated) then the text, which may
- * be empty.
- */
- else if (prefix_length + 5 > length)
- errmsg = "truncated";
-
- else if (buffer[prefix_length+1] == 0 ||
- (buffer[prefix_length+1] == 1 &&
- buffer[prefix_length+2] == PNG_COMPRESSION_TYPE_BASE))
- {
- int compressed = buffer[prefix_length+1] != 0;
- png_uint_32 language_offset, translated_keyword_offset;
- png_alloc_size_t uncompressed_length = 0;
-
- /* Now the language tag */
- prefix_length += 3;
- language_offset = prefix_length;
-
- for (; prefix_length < length && buffer[prefix_length] != 0;
- ++prefix_length)
- /* Empty loop */ ;
-
- /* WARNING: the length may be invalid here, this is checked below. */
- translated_keyword_offset = ++prefix_length;
-
- for (; prefix_length < length && buffer[prefix_length] != 0;
- ++prefix_length)
- /* Empty loop */ ;
-
- /* prefix_length should now be at the trailing '\0' of the translated
- * keyword, but it may already be over the end. None of this arithmetic
- * can overflow because chunks are at most 2^31 bytes long, but on 16-bit
- * systems the available allocation may overflow.
- */
- ++prefix_length;
-
- if (compressed == 0 && prefix_length <= length)
- uncompressed_length = length - prefix_length;
-
- else if (compressed != 0 && prefix_length < length)
- {
- uncompressed_length = PNG_SIZE_MAX;
-
- /* TODO: at present png_decompress_chunk imposes a single application
- * level memory limit, this should be split to different values for
- * iCCP and text chunks.
- */
- if (png_decompress_chunk(png_ptr, length, prefix_length,
- &uncompressed_length, 1/*terminate*/) == Z_STREAM_END)
- buffer = png_ptr->read_buffer;
-
- else
- errmsg = png_ptr->zstream.msg;
- }
-
- else
- errmsg = "truncated";
-
- if (errmsg == NULL)
- {
- png_text text;
-
- buffer[uncompressed_length+prefix_length] = 0;
-
- if (compressed == 0)
- text.compression = PNG_ITXT_COMPRESSION_NONE;
-
- else
- text.compression = PNG_ITXT_COMPRESSION_zTXt;
-
- text.key = (png_charp)buffer;
- text.lang = (png_charp)buffer + language_offset;
- text.lang_key = (png_charp)buffer + translated_keyword_offset;
- text.text = (png_charp)buffer + prefix_length;
- text.text_length = 0;
- text.itxt_length = uncompressed_length;
-
- if (png_set_text_2(png_ptr, info_ptr, &text, 1) != 0)
- errmsg = "insufficient memory";
- }
- }
-
- else
- errmsg = "bad compression info";
-
- if (errmsg != NULL)
- png_chunk_benign_error(png_ptr, errmsg);
-}
-#endif
-
-#ifdef PNG_READ_APNG_SUPPORTED
-void /* PRIVATE */
-png_handle_acTL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
-{
- png_byte data[8];
- png_uint_32 num_frames;
- png_uint_32 num_plays;
- png_uint_32 didSet;
-
- png_debug(1, "in png_handle_acTL");
-
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- {
- png_error(png_ptr, "Missing IHDR before acTL");
- }
- else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
- {
- png_warning(png_ptr, "Invalid acTL after IDAT skipped");
- png_crc_finish(png_ptr, length);
- return;
- }
- else if ((png_ptr->mode & PNG_HAVE_acTL) != 0)
- {
- png_warning(png_ptr, "Duplicate acTL skipped");
- png_crc_finish(png_ptr, length);
- return;
- }
- else if (length != 8)
- {
- png_warning(png_ptr, "acTL with invalid length skipped");
- png_crc_finish(png_ptr, length);
- return;
- }
-
- png_crc_read(png_ptr, data, 8);
- png_crc_finish(png_ptr, 0);
-
- num_frames = png_get_uint_31(png_ptr, data);
- num_plays = png_get_uint_31(png_ptr, data + 4);
-
- /* the set function will do error checking on num_frames */
- didSet = png_set_acTL(png_ptr, info_ptr, num_frames, num_plays);
- if (didSet != 0)
- png_ptr->mode |= PNG_HAVE_acTL;
-}
-
-void /* PRIVATE */
-png_handle_fcTL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
-{
- png_byte data[22];
- png_uint_32 width;
- png_uint_32 height;
- png_uint_32 x_offset;
- png_uint_32 y_offset;
- png_uint_16 delay_num;
- png_uint_16 delay_den;
- png_byte dispose_op;
- png_byte blend_op;
-
- png_debug(1, "in png_handle_fcTL");
-
- png_ensure_sequence_number(png_ptr, length);
-
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- {
- png_error(png_ptr, "Missing IHDR before fcTL");
- }
- else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
- {
- /* for any frames other then the first this message may be misleading,
- * but correct. PNG_HAVE_IDAT is unset before the frame head is read
- * i can't think of a better message */
- png_warning(png_ptr, "Invalid fcTL after IDAT skipped");
- png_crc_finish(png_ptr, length-4);
- return;
- }
- else if ((png_ptr->mode & PNG_HAVE_fcTL) != 0)
- {
- png_warning(png_ptr, "Duplicate fcTL within one frame skipped");
- png_crc_finish(png_ptr, length-4);
- return;
- }
- else if (length != 26)
- {
- png_warning(png_ptr, "fcTL with invalid length skipped");
- png_crc_finish(png_ptr, length-4);
- return;
- }
-
- png_crc_read(png_ptr, data, 22);
- png_crc_finish(png_ptr, 0);
-
- width = png_get_uint_31(png_ptr, data);
- height = png_get_uint_31(png_ptr, data + 4);
- x_offset = png_get_uint_31(png_ptr, data + 8);
- y_offset = png_get_uint_31(png_ptr, data + 12);
- delay_num = png_get_uint_16(data + 16);
- delay_den = png_get_uint_16(data + 18);
- dispose_op = data[20];
- blend_op = data[21];
-
- if (png_ptr->num_frames_read == 0 && (x_offset != 0 || y_offset != 0))
- {
- png_warning(png_ptr, "fcTL for the first frame must have zero offset");
- return;
- }
-
- if (info_ptr != NULL)
- {
- if (png_ptr->num_frames_read == 0 &&
- (width != info_ptr->width || height != info_ptr->height))
- {
- png_warning(png_ptr, "size in first frame's fcTL must match "
- "the size in IHDR");
- return;
- }
-
- /* The set function will do more error checking */
- png_set_next_frame_fcTL(png_ptr, info_ptr, width, height,
- x_offset, y_offset, delay_num, delay_den,
- dispose_op, blend_op);
-
- png_read_reinit(png_ptr, info_ptr);
-
- png_ptr->mode |= PNG_HAVE_fcTL;
- }
-}
-
-void /* PRIVATE */
-png_have_info(png_structp png_ptr, png_infop info_ptr)
-{
- if ((info_ptr->valid & PNG_INFO_acTL) != 0 &&
- (info_ptr->valid & PNG_INFO_fcTL) == 0)
- {
- png_ptr->apng_flags |= PNG_FIRST_FRAME_HIDDEN;
- info_ptr->num_frames++;
- }
-}
-
-void /* PRIVATE */
-png_handle_fdAT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
-{
- png_ensure_sequence_number(png_ptr, length);
-
- /* This function is only called from png_read_end(), png_read_info(),
- * and png_push_read_chunk() which means that:
- * - the user doesn't want to read this frame
- * - or this is an out-of-place fdAT
- * in either case it is safe to ignore the chunk with a warning */
- png_warning(png_ptr, "ignoring fdAT chunk");
- png_crc_finish(png_ptr, length - 4);
- PNG_UNUSED(info_ptr)
-}
-
-void /* PRIVATE */
-png_ensure_sequence_number(png_structp png_ptr, png_uint_32 length)
-{
- png_byte data[4];
- png_uint_32 sequence_number;
-
- if (length < 4)
- png_error(png_ptr, "invalid fcTL or fdAT chunk found");
-
- png_crc_read(png_ptr, data, 4);
- sequence_number = png_get_uint_31(png_ptr, data);
-
- if (sequence_number != png_ptr->next_seq_num)
- png_error(png_ptr, "fcTL or fdAT chunk with out-of-order sequence "
- "number found");
-
- png_ptr->next_seq_num++;
-}
-#endif /* READ_APNG */
-
-#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
-/* Utility function for png_handle_unknown; set up png_ptr::unknown_chunk */
-static int
-png_cache_unknown_chunk(png_structrp png_ptr, png_uint_32 length)
-{
- png_alloc_size_t limit = PNG_SIZE_MAX;
-
- if (png_ptr->unknown_chunk.data != NULL)
- {
- png_free(png_ptr, png_ptr->unknown_chunk.data);
- png_ptr->unknown_chunk.data = NULL;
- }
-
-# ifdef PNG_SET_USER_LIMITS_SUPPORTED
- if (png_ptr->user_chunk_malloc_max > 0 &&
- png_ptr->user_chunk_malloc_max < limit)
- limit = png_ptr->user_chunk_malloc_max;
-
-# elif PNG_USER_CHUNK_MALLOC_MAX > 0
- if (PNG_USER_CHUNK_MALLOC_MAX < limit)
- limit = PNG_USER_CHUNK_MALLOC_MAX;
-# endif
-
- if (length <= limit)
- {
- PNG_CSTRING_FROM_CHUNK(png_ptr->unknown_chunk.name, png_ptr->chunk_name);
- /* The following is safe because of the PNG_SIZE_MAX init above */
- png_ptr->unknown_chunk.size = (size_t)length/*SAFE*/;
- /* 'mode' is a flag array, only the bottom four bits matter here */
- png_ptr->unknown_chunk.location = (png_byte)png_ptr->mode/*SAFE*/;
-
- if (length == 0)
- png_ptr->unknown_chunk.data = NULL;
-
- else
- {
- /* Do a 'warn' here - it is handled below. */
- png_ptr->unknown_chunk.data = png_voidcast(png_bytep,
- png_malloc_warn(png_ptr, length));
- }
- }
-
- if (png_ptr->unknown_chunk.data == NULL && length > 0)
- {
- /* This is benign because we clean up correctly */
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "unknown chunk exceeds memory limits");
- return 0;
- }
-
- else
- {
- if (length > 0)
- png_crc_read(png_ptr, png_ptr->unknown_chunk.data, length);
- png_crc_finish(png_ptr, 0);
- return 1;
- }
-}
-#endif /* READ_UNKNOWN_CHUNKS */
-
-/* Handle an unknown, or known but disabled, chunk */
-void /* PRIVATE */
-png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
- png_uint_32 length, int keep)
-{
- int handled = 0; /* the chunk was handled */
-
- png_debug(1, "in png_handle_unknown");
-
-#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
- /* NOTE: this code is based on the code in libpng-1.4.12 except for fixing
- * the bug which meant that setting a non-default behavior for a specific
- * chunk would be ignored (the default was always used unless a user
- * callback was installed).
- *
- * 'keep' is the value from the png_chunk_unknown_handling, the setting for
- * this specific chunk_name, if PNG_HANDLE_AS_UNKNOWN_SUPPORTED, if not it
- * will always be PNG_HANDLE_CHUNK_AS_DEFAULT and it needs to be set here.
- * This is just an optimization to avoid multiple calls to the lookup
- * function.
- */
-# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
-# ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
- keep = png_chunk_unknown_handling(png_ptr, png_ptr->chunk_name);
-# endif
-# endif
-
- /* One of the following methods will read the chunk or skip it (at least one
- * of these is always defined because this is the only way to switch on
- * PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
- */
-# ifdef PNG_READ_USER_CHUNKS_SUPPORTED
- /* The user callback takes precedence over the chunk keep value, but the
- * keep value is still required to validate a save of a critical chunk.
- */
- if (png_ptr->read_user_chunk_fn != NULL)
- {
- if (png_cache_unknown_chunk(png_ptr, length) != 0)
- {
- /* Callback to user unknown chunk handler */
- int ret = (*(png_ptr->read_user_chunk_fn))(png_ptr,
- &png_ptr->unknown_chunk);
-
- /* ret is:
- * negative: An error occurred; png_chunk_error will be called.
- * zero: The chunk was not handled, the chunk will be discarded
- * unless png_set_keep_unknown_chunks has been used to set
- * a 'keep' behavior for this particular chunk, in which
- * case that will be used. A critical chunk will cause an
- * error at this point unless it is to be saved.
- * positive: The chunk was handled, libpng will ignore/discard it.
- */
- if (ret < 0)
- png_chunk_error(png_ptr, "error in user chunk");
-
- else if (ret == 0)
- {
- /* If the keep value is 'default' or 'never' override it, but
- * still error out on critical chunks unless the keep value is
- * 'always' While this is weird it is the behavior in 1.4.12.
- * A possible improvement would be to obey the value set for the
- * chunk, but this would be an API change that would probably
- * damage some applications.
- *
- * The png_app_warning below catches the case that matters, where
- * the application has not set specific save or ignore for this
- * chunk or global save or ignore.
- */
- if (keep < PNG_HANDLE_CHUNK_IF_SAFE)
- {
-# ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
- if (png_ptr->unknown_default < PNG_HANDLE_CHUNK_IF_SAFE)
- {
- png_chunk_warning(png_ptr, "Saving unknown chunk:");
- png_app_warning(png_ptr,
- "forcing save of an unhandled chunk;"
- " please call png_set_keep_unknown_chunks");
- /* with keep = PNG_HANDLE_CHUNK_IF_SAFE */
- }
-# endif
- keep = PNG_HANDLE_CHUNK_IF_SAFE;
- }
- }
-
- else /* chunk was handled */
- {
- handled = 1;
- /* Critical chunks can be safely discarded at this point. */
- keep = PNG_HANDLE_CHUNK_NEVER;
- }
- }
-
- else
- keep = PNG_HANDLE_CHUNK_NEVER; /* insufficient memory */
- }
-
- else
- /* Use the SAVE_UNKNOWN_CHUNKS code or skip the chunk */
-# endif /* READ_USER_CHUNKS */
-
-# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
- {
- /* keep is currently just the per-chunk setting, if there was no
- * setting change it to the global default now (not that this may
- * still be AS_DEFAULT) then obtain the cache of the chunk if required,
- * if not simply skip the chunk.
- */
- if (keep == PNG_HANDLE_CHUNK_AS_DEFAULT)
- keep = png_ptr->unknown_default;
-
- if (keep == PNG_HANDLE_CHUNK_ALWAYS ||
- (keep == PNG_HANDLE_CHUNK_IF_SAFE &&
- PNG_CHUNK_ANCILLARY(png_ptr->chunk_name)))
- {
- if (png_cache_unknown_chunk(png_ptr, length) == 0)
- keep = PNG_HANDLE_CHUNK_NEVER;
- }
-
- else
- png_crc_finish(png_ptr, length);
- }
-# else
-# ifndef PNG_READ_USER_CHUNKS_SUPPORTED
-# error no method to support READ_UNKNOWN_CHUNKS
-# endif
-
- {
- /* If here there is no read callback pointer set and no support is
- * compiled in to just save the unknown chunks, so simply skip this
- * chunk. If 'keep' is something other than AS_DEFAULT or NEVER then
- * the app has erroneously asked for unknown chunk saving when there
- * is no support.
- */
- if (keep > PNG_HANDLE_CHUNK_NEVER)
- png_app_error(png_ptr, "no unknown chunk support available");
-
- png_crc_finish(png_ptr, length);
- }
-# endif
-
-# ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
- /* Now store the chunk in the chunk list if appropriate, and if the limits
- * permit it.
- */
- if (keep == PNG_HANDLE_CHUNK_ALWAYS ||
- (keep == PNG_HANDLE_CHUNK_IF_SAFE &&
- PNG_CHUNK_ANCILLARY(png_ptr->chunk_name)))
- {
-# ifdef PNG_USER_LIMITS_SUPPORTED
- switch (png_ptr->user_chunk_cache_max)
- {
- case 2:
- png_ptr->user_chunk_cache_max = 1;
- png_chunk_benign_error(png_ptr, "no space in chunk cache");
- /* FALLTHROUGH */
- case 1:
- /* NOTE: prior to 1.6.0 this case resulted in an unknown critical
- * chunk being skipped, now there will be a hard error below.
- */
- break;
-
- default: /* not at limit */
- --(png_ptr->user_chunk_cache_max);
- /* FALLTHROUGH */
- case 0: /* no limit */
-# endif /* USER_LIMITS */
- /* Here when the limit isn't reached or when limits are compiled
- * out; store the chunk.
- */
- png_set_unknown_chunks(png_ptr, info_ptr,
- &png_ptr->unknown_chunk, 1);
- handled = 1;
-# ifdef PNG_USER_LIMITS_SUPPORTED
- break;
- }
-# endif
- }
-# else /* no store support: the chunk must be handled by the user callback */
- PNG_UNUSED(info_ptr)
-# endif
-
- /* Regardless of the error handling below the cached data (if any) can be
- * freed now. Notice that the data is not freed if there is a png_error, but
- * it will be freed by destroy_read_struct.
- */
- if (png_ptr->unknown_chunk.data != NULL)
- png_free(png_ptr, png_ptr->unknown_chunk.data);
- png_ptr->unknown_chunk.data = NULL;
-
-#else /* !PNG_READ_UNKNOWN_CHUNKS_SUPPORTED */
- /* There is no support to read an unknown chunk, so just skip it. */
- png_crc_finish(png_ptr, length);
- PNG_UNUSED(info_ptr)
- PNG_UNUSED(keep)
-#endif /* !READ_UNKNOWN_CHUNKS */
-
- /* Check for unhandled critical chunks */
- if (handled == 0 && PNG_CHUNK_CRITICAL(png_ptr->chunk_name))
- png_chunk_error(png_ptr, "unhandled critical chunk");
-}
-
-/* This function is called to verify that a chunk name is valid.
- * This function can't have the "critical chunk check" incorporated
- * into it, since in the future we will need to be able to call user
- * functions to handle unknown critical chunks after we check that
- * the chunk name itself is valid.
- */
-
-/* Bit hacking: the test for an invalid byte in the 4 byte chunk name is:
- *
- * ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97))
- */
-
-void /* PRIVATE */
-png_check_chunk_name(png_const_structrp png_ptr, png_uint_32 chunk_name)
-{
- int i;
- png_uint_32 cn=chunk_name;
-
- png_debug(1, "in png_check_chunk_name");
-
- for (i=1; i<=4; ++i)
- {
- int c = cn & 0xff;
-
- if (c < 65 || c > 122 || (c > 90 && c < 97))
- png_chunk_error(png_ptr, "invalid chunk type");
-
- cn >>= 8;
- }
-}
-
-void /* PRIVATE */
-png_check_chunk_length(png_const_structrp png_ptr, png_uint_32 length)
-{
- png_alloc_size_t limit = PNG_UINT_31_MAX;
-
-# ifdef PNG_SET_USER_LIMITS_SUPPORTED
- if (png_ptr->user_chunk_malloc_max > 0 &&
- png_ptr->user_chunk_malloc_max < limit)
- limit = png_ptr->user_chunk_malloc_max;
-# elif PNG_USER_CHUNK_MALLOC_MAX > 0
- if (PNG_USER_CHUNK_MALLOC_MAX < limit)
- limit = PNG_USER_CHUNK_MALLOC_MAX;
-# endif
-#ifdef PNG_READ_APNG_SUPPORTED
- if (png_ptr->chunk_name == png_IDAT || png_ptr->chunk_name == png_fdAT)
-#else
- if (png_ptr->chunk_name == png_IDAT)
-#endif
- {
- png_alloc_size_t idat_limit = PNG_UINT_31_MAX;
- size_t row_factor =
- (size_t)png_ptr->width
- * (size_t)png_ptr->channels
- * (png_ptr->bit_depth > 8? 2: 1)
- + 1
- + (png_ptr->interlaced? 6: 0);
- if (png_ptr->height > PNG_UINT_32_MAX/row_factor)
- idat_limit = PNG_UINT_31_MAX;
- else
- idat_limit = png_ptr->height * row_factor;
- row_factor = row_factor > 32566? 32566 : row_factor;
- idat_limit += 6 + 5*(idat_limit/row_factor+1); /* zlib+deflate overhead */
- idat_limit=idat_limit < PNG_UINT_31_MAX? idat_limit : PNG_UINT_31_MAX;
- limit = limit < idat_limit? idat_limit : limit;
- }
-
- if (length > limit)
- {
- png_debug2(0," length = %lu, limit = %lu",
- (unsigned long)length,(unsigned long)limit);
- png_benign_error(png_ptr, "chunk data is too large");
- }
-}
-
-/* Combines the row recently read in with the existing pixels in the row. This
- * routine takes care of alpha and transparency if requested. This routine also
- * handles the two methods of progressive display of interlaced images,
- * depending on the 'display' value; if 'display' is true then the whole row
- * (dp) is filled from the start by replicating the available pixels. If
- * 'display' is false only those pixels present in the pass are filled in.
- */
-void /* PRIVATE */
-png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
-{
- unsigned int pixel_depth = png_ptr->transformed_pixel_depth;
- png_const_bytep sp = png_ptr->row_buf + 1;
- png_alloc_size_t row_width = png_ptr->width;
- unsigned int pass = png_ptr->pass;
- png_bytep end_ptr = 0;
- png_byte end_byte = 0;
- unsigned int end_mask;
-
- png_debug(1, "in png_combine_row");
-
- /* Added in 1.5.6: it should not be possible to enter this routine until at
- * least one row has been read from the PNG data and transformed.
- */
- if (pixel_depth == 0)
- png_error(png_ptr, "internal row logic error");
-
- /* Added in 1.5.4: the pixel depth should match the information returned by
- * any call to png_read_update_info at this point. Do not continue if we got
- * this wrong.
- */
- if (png_ptr->info_rowbytes != 0 && png_ptr->info_rowbytes !=
- PNG_ROWBYTES(pixel_depth, row_width))
- png_error(png_ptr, "internal row size calculation error");
-
- /* Don't expect this to ever happen: */
- if (row_width == 0)
- png_error(png_ptr, "internal row width error");
-
- /* Preserve the last byte in cases where only part of it will be overwritten,
- * the multiply below may overflow, we don't care because ANSI-C guarantees
- * we get the low bits.
- */
- end_mask = (pixel_depth * row_width) & 7;
- if (end_mask != 0)
- {
- /* end_ptr == NULL is a flag to say do nothing */
- end_ptr = dp + PNG_ROWBYTES(pixel_depth, row_width) - 1;
- end_byte = *end_ptr;
-# ifdef PNG_READ_PACKSWAP_SUPPORTED
- if ((png_ptr->transformations & PNG_PACKSWAP) != 0)
- /* little-endian byte */
- end_mask = (unsigned int)(0xff << end_mask);
-
- else /* big-endian byte */
-# endif
- end_mask = 0xff >> end_mask;
- /* end_mask is now the bits to *keep* from the destination row */
- }
-
- /* For non-interlaced images this reduces to a memcpy(). A memcpy()
- * will also happen if interlacing isn't supported or if the application
- * does not call png_set_interlace_handling(). In the latter cases the
- * caller just gets a sequence of the unexpanded rows from each interlace
- * pass.
- */
-#ifdef PNG_READ_INTERLACING_SUPPORTED
- if (png_ptr->interlaced != 0 &&
- (png_ptr->transformations & PNG_INTERLACE) != 0 &&
- pass < 6 && (display == 0 ||
- /* The following copies everything for 'display' on passes 0, 2 and 4. */
- (display == 1 && (pass & 1) != 0)))
- {
- /* Narrow images may have no bits in a pass; the caller should handle
- * this, but this test is cheap:
- */
- if (row_width <= PNG_PASS_START_COL(pass))
- return;
-
- if (pixel_depth < 8)
- {
- /* For pixel depths up to 4 bpp the 8-pixel mask can be expanded to fit
- * into 32 bits, then a single loop over the bytes using the four byte
- * values in the 32-bit mask can be used. For the 'display' option the
- * expanded mask may also not require any masking within a byte. To
- * make this work the PACKSWAP option must be taken into account - it
- * simply requires the pixels to be reversed in each byte.
- *
- * The 'regular' case requires a mask for each of the first 6 passes,
- * the 'display' case does a copy for the even passes in the range
- * 0..6. This has already been handled in the test above.
- *
- * The masks are arranged as four bytes with the first byte to use in
- * the lowest bits (little-endian) regardless of the order (PACKSWAP or
- * not) of the pixels in each byte.
- *
- * NOTE: the whole of this logic depends on the caller of this function
- * only calling it on rows appropriate to the pass. This function only
- * understands the 'x' logic; the 'y' logic is handled by the caller.
- *
- * The following defines allow generation of compile time constant bit
- * masks for each pixel depth and each possibility of swapped or not
- * swapped bytes. Pass 'p' is in the range 0..6; 'x', a pixel index,
- * is in the range 0..7; and the result is 1 if the pixel is to be
- * copied in the pass, 0 if not. 'S' is for the sparkle method, 'B'
- * for the block method.
- *
- * With some compilers a compile time expression of the general form:
- *
- * (shift >= 32) ? (a >> (shift-32)) : (b >> shift)
- *
- * Produces warnings with values of 'shift' in the range 33 to 63
- * because the right hand side of the ?: expression is evaluated by
- * the compiler even though it isn't used. Microsoft Visual C (various
- * versions) and the Intel C compiler are known to do this. To avoid
- * this the following macros are used in 1.5.6. This is a temporary
- * solution to avoid destabilizing the code during the release process.
- */
-# if PNG_USE_COMPILE_TIME_MASKS
-# define PNG_LSR(x,s) ((x)>>((s) & 0x1f))
-# define PNG_LSL(x,s) ((x)<<((s) & 0x1f))
-# else
-# define PNG_LSR(x,s) ((x)>>(s))
-# define PNG_LSL(x,s) ((x)<<(s))
-# endif
-# define S_COPY(p,x) (((p)<4 ? PNG_LSR(0x80088822,(3-(p))*8+(7-(x))) :\
- PNG_LSR(0xaa55ff00,(7-(p))*8+(7-(x)))) & 1)
-# define B_COPY(p,x) (((p)<4 ? PNG_LSR(0xff0fff33,(3-(p))*8+(7-(x))) :\
- PNG_LSR(0xff55ff00,(7-(p))*8+(7-(x)))) & 1)
-
- /* Return a mask for pass 'p' pixel 'x' at depth 'd'. The mask is
- * little endian - the first pixel is at bit 0 - however the extra
- * parameter 's' can be set to cause the mask position to be swapped
- * within each byte, to match the PNG format. This is done by XOR of
- * the shift with 7, 6 or 4 for bit depths 1, 2 and 4.
- */
-# define PIXEL_MASK(p,x,d,s) \
- (PNG_LSL(((PNG_LSL(1U,(d)))-1),(((x)*(d))^((s)?8-(d):0))))
-
- /* Hence generate the appropriate 'block' or 'sparkle' pixel copy mask.
- */
-# define S_MASKx(p,x,d,s) (S_COPY(p,x)?PIXEL_MASK(p,x,d,s):0)
-# define B_MASKx(p,x,d,s) (B_COPY(p,x)?PIXEL_MASK(p,x,d,s):0)
-
- /* Combine 8 of these to get the full mask. For the 1-bpp and 2-bpp
- * cases the result needs replicating, for the 4-bpp case the above
- * generates a full 32 bits.
- */
-# define MASK_EXPAND(m,d) ((m)*((d)==1?0x01010101:((d)==2?0x00010001:1)))
-
-# define S_MASK(p,d,s) MASK_EXPAND(S_MASKx(p,0,d,s) + S_MASKx(p,1,d,s) +\
- S_MASKx(p,2,d,s) + S_MASKx(p,3,d,s) + S_MASKx(p,4,d,s) +\
- S_MASKx(p,5,d,s) + S_MASKx(p,6,d,s) + S_MASKx(p,7,d,s), d)
-
-# define B_MASK(p,d,s) MASK_EXPAND(B_MASKx(p,0,d,s) + B_MASKx(p,1,d,s) +\
- B_MASKx(p,2,d,s) + B_MASKx(p,3,d,s) + B_MASKx(p,4,d,s) +\
- B_MASKx(p,5,d,s) + B_MASKx(p,6,d,s) + B_MASKx(p,7,d,s), d)
-
-#if PNG_USE_COMPILE_TIME_MASKS
- /* Utility macros to construct all the masks for a depth/swap
- * combination. The 's' parameter says whether the format is PNG
- * (big endian bytes) or not. Only the three odd-numbered passes are
- * required for the display/block algorithm.
- */
-# define S_MASKS(d,s) { S_MASK(0,d,s), S_MASK(1,d,s), S_MASK(2,d,s),\
- S_MASK(3,d,s), S_MASK(4,d,s), S_MASK(5,d,s) }
-
-# define B_MASKS(d,s) { B_MASK(1,d,s), B_MASK(3,d,s), B_MASK(5,d,s) }
-
-# define DEPTH_INDEX(d) ((d)==1?0:((d)==2?1:2))
-
- /* Hence the pre-compiled masks indexed by PACKSWAP (or not), depth and
- * then pass:
- */
- static const png_uint_32 row_mask[2/*PACKSWAP*/][3/*depth*/][6] =
- {
- /* Little-endian byte masks for PACKSWAP */
- { S_MASKS(1,0), S_MASKS(2,0), S_MASKS(4,0) },
- /* Normal (big-endian byte) masks - PNG format */
- { S_MASKS(1,1), S_MASKS(2,1), S_MASKS(4,1) }
- };
-
- /* display_mask has only three entries for the odd passes, so index by
- * pass>>1.
- */
- static const png_uint_32 display_mask[2][3][3] =
- {
- /* Little-endian byte masks for PACKSWAP */
- { B_MASKS(1,0), B_MASKS(2,0), B_MASKS(4,0) },
- /* Normal (big-endian byte) masks - PNG format */
- { B_MASKS(1,1), B_MASKS(2,1), B_MASKS(4,1) }
- };
-
-# define MASK(pass,depth,display,png)\
- ((display)?display_mask[png][DEPTH_INDEX(depth)][pass>>1]:\
- row_mask[png][DEPTH_INDEX(depth)][pass])
-
-#else /* !PNG_USE_COMPILE_TIME_MASKS */
- /* This is the runtime alternative: it seems unlikely that this will
- * ever be either smaller or faster than the compile time approach.
- */
-# define MASK(pass,depth,display,png)\
- ((display)?B_MASK(pass,depth,png):S_MASK(pass,depth,png))
-#endif /* !USE_COMPILE_TIME_MASKS */
-
- /* Use the appropriate mask to copy the required bits. In some cases
- * the byte mask will be 0 or 0xff; optimize these cases. row_width is
- * the number of pixels, but the code copies bytes, so it is necessary
- * to special case the end.
- */
- png_uint_32 pixels_per_byte = 8 / pixel_depth;
- png_uint_32 mask;
-
-# ifdef PNG_READ_PACKSWAP_SUPPORTED
- if ((png_ptr->transformations & PNG_PACKSWAP) != 0)
- mask = MASK(pass, pixel_depth, display, 0);
-
- else
-# endif
- mask = MASK(pass, pixel_depth, display, 1);
-
- for (;;)
- {
- png_uint_32 m;
-
- /* It doesn't matter in the following if png_uint_32 has more than
- * 32 bits because the high bits always match those in m<<24; it is,
- * however, essential to use OR here, not +, because of this.
- */
- m = mask;
- mask = (m >> 8) | (m << 24); /* rotate right to good compilers */
- m &= 0xff;
-
- if (m != 0) /* something to copy */
- {
- if (m != 0xff)
- *dp = (png_byte)((*dp & ~m) | (*sp & m));
- else
- *dp = *sp;
- }
-
- /* NOTE: this may overwrite the last byte with garbage if the image
- * is not an exact number of bytes wide; libpng has always done
- * this.
- */
- if (row_width <= pixels_per_byte)
- break; /* May need to restore part of the last byte */
-
- row_width -= pixels_per_byte;
- ++dp;
- ++sp;
- }
- }
-
- else /* pixel_depth >= 8 */
- {
- unsigned int bytes_to_copy, bytes_to_jump;
-
- /* Validate the depth - it must be a multiple of 8 */
- if (pixel_depth & 7)
- png_error(png_ptr, "invalid user transform pixel depth");
-
- pixel_depth >>= 3; /* now in bytes */
- row_width *= pixel_depth;
-
- /* Regardless of pass number the Adam 7 interlace always results in a
- * fixed number of pixels to copy then to skip. There may be a
- * different number of pixels to skip at the start though.
- */
- {
- unsigned int offset = PNG_PASS_START_COL(pass) * pixel_depth;
-
- row_width -= offset;
- dp += offset;
- sp += offset;
- }
-
- /* Work out the bytes to copy. */
- if (display != 0)
- {
- /* When doing the 'block' algorithm the pixel in the pass gets
- * replicated to adjacent pixels. This is why the even (0,2,4,6)
- * passes are skipped above - the entire expanded row is copied.
- */
- bytes_to_copy = (1<<((6-pass)>>1)) * pixel_depth;
-
- /* But don't allow this number to exceed the actual row width. */
- if (bytes_to_copy > row_width)
- bytes_to_copy = (unsigned int)/*SAFE*/row_width;
- }
-
- else /* normal row; Adam7 only ever gives us one pixel to copy. */
- bytes_to_copy = pixel_depth;
-
- /* In Adam7 there is a constant offset between where the pixels go. */
- bytes_to_jump = PNG_PASS_COL_OFFSET(pass) * pixel_depth;
-
- /* And simply copy these bytes. Some optimization is possible here,
- * depending on the value of 'bytes_to_copy'. Special case the low
- * byte counts, which we know to be frequent.
- *
- * Notice that these cases all 'return' rather than 'break' - this
- * avoids an unnecessary test on whether to restore the last byte
- * below.
- */
- switch (bytes_to_copy)
- {
- case 1:
- for (;;)
- {
- *dp = *sp;
-
- if (row_width <= bytes_to_jump)
- return;
-
- dp += bytes_to_jump;
- sp += bytes_to_jump;
- row_width -= bytes_to_jump;
- }
-
- case 2:
- /* There is a possibility of a partial copy at the end here; this
- * slows the code down somewhat.
- */
- do
- {
- dp[0] = sp[0]; dp[1] = sp[1];
-
- if (row_width <= bytes_to_jump)
- return;
-
- sp += bytes_to_jump;
- dp += bytes_to_jump;
- row_width -= bytes_to_jump;
- }
- while (row_width > 1);
-
- /* And there can only be one byte left at this point: */
- *dp = *sp;
- return;
-
- case 3:
- /* This can only be the RGB case, so each copy is exactly one
- * pixel and it is not necessary to check for a partial copy.
- */
- for (;;)
- {
- dp[0] = sp[0]; dp[1] = sp[1]; dp[2] = sp[2];
-
- if (row_width <= bytes_to_jump)
- return;
-
- sp += bytes_to_jump;
- dp += bytes_to_jump;
- row_width -= bytes_to_jump;
- }
-
- default:
-#if PNG_ALIGN_TYPE != PNG_ALIGN_NONE
- /* Check for double byte alignment and, if possible, use a
- * 16-bit copy. Don't attempt this for narrow images - ones that
- * are less than an interlace panel wide. Don't attempt it for
- * wide bytes_to_copy either - use the memcpy there.
- */
- if (bytes_to_copy < 16 /*else use memcpy*/ &&
- png_isaligned(dp, png_uint_16) &&
- png_isaligned(sp, png_uint_16) &&
- bytes_to_copy % (sizeof (png_uint_16)) == 0 &&
- bytes_to_jump % (sizeof (png_uint_16)) == 0)
- {
- /* Everything is aligned for png_uint_16 copies, but try for
- * png_uint_32 first.
- */
- if (png_isaligned(dp, png_uint_32) &&
- png_isaligned(sp, png_uint_32) &&
- bytes_to_copy % (sizeof (png_uint_32)) == 0 &&
- bytes_to_jump % (sizeof (png_uint_32)) == 0)
- {
- png_uint_32p dp32 = png_aligncast(png_uint_32p,dp);
- png_const_uint_32p sp32 = png_aligncastconst(
- png_const_uint_32p, sp);
- size_t skip = (bytes_to_jump-bytes_to_copy) /
- (sizeof (png_uint_32));
-
- do
- {
- size_t c = bytes_to_copy;
- do
- {
- *dp32++ = *sp32++;
- c -= (sizeof (png_uint_32));
- }
- while (c > 0);
-
- if (row_width <= bytes_to_jump)
- return;
-
- dp32 += skip;
- sp32 += skip;
- row_width -= bytes_to_jump;
- }
- while (bytes_to_copy <= row_width);
-
- /* Get to here when the row_width truncates the final copy.
- * There will be 1-3 bytes left to copy, so don't try the
- * 16-bit loop below.
- */
- dp = (png_bytep)dp32;
- sp = (png_const_bytep)sp32;
- do
- *dp++ = *sp++;
- while (--row_width > 0);
- return;
- }
-
- /* Else do it in 16-bit quantities, but only if the size is
- * not too large.
- */
- else
- {
- png_uint_16p dp16 = png_aligncast(png_uint_16p, dp);
- png_const_uint_16p sp16 = png_aligncastconst(
- png_const_uint_16p, sp);
- size_t skip = (bytes_to_jump-bytes_to_copy) /
- (sizeof (png_uint_16));
-
- do
- {
- size_t c = bytes_to_copy;
- do
- {
- *dp16++ = *sp16++;
- c -= (sizeof (png_uint_16));
- }
- while (c > 0);
-
- if (row_width <= bytes_to_jump)
- return;
-
- dp16 += skip;
- sp16 += skip;
- row_width -= bytes_to_jump;
- }
- while (bytes_to_copy <= row_width);
-
- /* End of row - 1 byte left, bytes_to_copy > row_width: */
- dp = (png_bytep)dp16;
- sp = (png_const_bytep)sp16;
- do
- *dp++ = *sp++;
- while (--row_width > 0);
- return;
- }
- }
-#endif /* ALIGN_TYPE code */
-
- /* The true default - use a memcpy: */
- for (;;)
- {
- memcpy(dp, sp, bytes_to_copy);
-
- if (row_width <= bytes_to_jump)
- return;
-
- sp += bytes_to_jump;
- dp += bytes_to_jump;
- row_width -= bytes_to_jump;
- if (bytes_to_copy > row_width)
- bytes_to_copy = (unsigned int)/*SAFE*/row_width;
- }
- }
-
- /* NOT REACHED*/
- } /* pixel_depth >= 8 */
-
- /* Here if pixel_depth < 8 to check 'end_ptr' below. */
- }
- else
-#endif /* READ_INTERLACING */
-
- /* If here then the switch above wasn't used so just memcpy the whole row
- * from the temporary row buffer (notice that this overwrites the end of the
- * destination row if it is a partial byte.)
- */
- memcpy(dp, sp, PNG_ROWBYTES(pixel_depth, row_width));
-
- /* Restore the overwritten bits from the last byte if necessary. */
- if (end_ptr != NULL)
- *end_ptr = (png_byte)((end_byte & end_mask) | (*end_ptr & ~end_mask));
-}
-
-#ifdef PNG_READ_INTERLACING_SUPPORTED
-void /* PRIVATE */
-png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
- png_uint_32 transformations /* Because these may affect the byte layout */)
-{
- png_debug(1, "in png_do_read_interlace");
- if (row != NULL && row_info != NULL)
- {
- png_uint_32 final_width;
-
- final_width = row_info->width * png_pass_inc[pass];
-
- switch (row_info->pixel_depth)
- {
- case 1:
- {
- png_bytep sp = row + (size_t)((row_info->width - 1) >> 3);
- png_bytep dp = row + (size_t)((final_width - 1) >> 3);
- unsigned int sshift, dshift;
- unsigned int s_start, s_end;
- int s_inc;
- int jstop = (int)png_pass_inc[pass];
- png_byte v;
- png_uint_32 i;
- int j;
-
-#ifdef PNG_READ_PACKSWAP_SUPPORTED
- if ((transformations & PNG_PACKSWAP) != 0)
- {
- sshift = ((row_info->width + 7) & 0x07);
- dshift = ((final_width + 7) & 0x07);
- s_start = 7;
- s_end = 0;
- s_inc = -1;
- }
-
- else
-#endif
- {
- sshift = 7 - ((row_info->width + 7) & 0x07);
- dshift = 7 - ((final_width + 7) & 0x07);
- s_start = 0;
- s_end = 7;
- s_inc = 1;
- }
-
- for (i = 0; i < row_info->width; i++)
- {
- v = (png_byte)((*sp >> sshift) & 0x01);
- for (j = 0; j < jstop; j++)
- {
- unsigned int tmp = *dp & (0x7f7f >> (7 - dshift));
- tmp |= (unsigned int)(v << dshift);
- *dp = (png_byte)(tmp & 0xff);
-
- if (dshift == s_end)
- {
- dshift = s_start;
- dp--;
- }
-
- else
- dshift = (unsigned int)((int)dshift + s_inc);
- }
-
- if (sshift == s_end)
- {
- sshift = s_start;
- sp--;
- }
-
- else
- sshift = (unsigned int)((int)sshift + s_inc);
- }
- break;
- }
-
- case 2:
- {
- png_bytep sp = row + (png_uint_32)((row_info->width - 1) >> 2);
- png_bytep dp = row + (png_uint_32)((final_width - 1) >> 2);
- unsigned int sshift, dshift;
- unsigned int s_start, s_end;
- int s_inc;
- int jstop = (int)png_pass_inc[pass];
- png_uint_32 i;
-
-#ifdef PNG_READ_PACKSWAP_SUPPORTED
- if ((transformations & PNG_PACKSWAP) != 0)
- {
- sshift = (((row_info->width + 3) & 0x03) << 1);
- dshift = (((final_width + 3) & 0x03) << 1);
- s_start = 6;
- s_end = 0;
- s_inc = -2;
- }
-
- else
-#endif
- {
- sshift = ((3 - ((row_info->width + 3) & 0x03)) << 1);
- dshift = ((3 - ((final_width + 3) & 0x03)) << 1);
- s_start = 0;
- s_end = 6;
- s_inc = 2;
- }
-
- for (i = 0; i < row_info->width; i++)
- {
- png_byte v;
- int j;
-
- v = (png_byte)((*sp >> sshift) & 0x03);
- for (j = 0; j < jstop; j++)
- {
- unsigned int tmp = *dp & (0x3f3f >> (6 - dshift));
- tmp |= (unsigned int)(v << dshift);
- *dp = (png_byte)(tmp & 0xff);
-
- if (dshift == s_end)
- {
- dshift = s_start;
- dp--;
- }
-
- else
- dshift = (unsigned int)((int)dshift + s_inc);
- }
-
- if (sshift == s_end)
- {
- sshift = s_start;
- sp--;
- }
-
- else
- sshift = (unsigned int)((int)sshift + s_inc);
- }
- break;
- }
-
- case 4:
- {
- png_bytep sp = row + (size_t)((row_info->width - 1) >> 1);
- png_bytep dp = row + (size_t)((final_width - 1) >> 1);
- unsigned int sshift, dshift;
- unsigned int s_start, s_end;
- int s_inc;
- png_uint_32 i;
- int jstop = (int)png_pass_inc[pass];
-
-#ifdef PNG_READ_PACKSWAP_SUPPORTED
- if ((transformations & PNG_PACKSWAP) != 0)
- {
- sshift = (((row_info->width + 1) & 0x01) << 2);
- dshift = (((final_width + 1) & 0x01) << 2);
- s_start = 4;
- s_end = 0;
- s_inc = -4;
- }
-
- else
-#endif
- {
- sshift = ((1 - ((row_info->width + 1) & 0x01)) << 2);
- dshift = ((1 - ((final_width + 1) & 0x01)) << 2);
- s_start = 0;
- s_end = 4;
- s_inc = 4;
- }
-
- for (i = 0; i < row_info->width; i++)
- {
- png_byte v = (png_byte)((*sp >> sshift) & 0x0f);
- int j;
-
- for (j = 0; j < jstop; j++)
- {
- unsigned int tmp = *dp & (0xf0f >> (4 - dshift));
- tmp |= (unsigned int)(v << dshift);
- *dp = (png_byte)(tmp & 0xff);
-
- if (dshift == s_end)
- {
- dshift = s_start;
- dp--;
- }
-
- else
- dshift = (unsigned int)((int)dshift + s_inc);
- }
-
- if (sshift == s_end)
- {
- sshift = s_start;
- sp--;
- }
-
- else
- sshift = (unsigned int)((int)sshift + s_inc);
- }
- break;
- }
-
- default:
- {
- size_t pixel_bytes = (row_info->pixel_depth >> 3);
-
- png_bytep sp = row + (size_t)(row_info->width - 1)
- * pixel_bytes;
-
- png_bytep dp = row + (size_t)(final_width - 1) * pixel_bytes;
-
- int jstop = (int)png_pass_inc[pass];
- png_uint_32 i;
-
- for (i = 0; i < row_info->width; i++)
- {
- png_byte v[8]; /* SAFE; pixel_depth does not exceed 64 */
- int j;
-
- memcpy(v, sp, pixel_bytes);
-
- for (j = 0; j < jstop; j++)
- {
- memcpy(dp, v, pixel_bytes);
- dp -= pixel_bytes;
- }
-
- sp -= pixel_bytes;
- }
- break;
- }
- }
-
- row_info->width = final_width;
- row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, final_width);
- }
-#ifndef PNG_READ_PACKSWAP_SUPPORTED
- PNG_UNUSED(transformations) /* Silence compiler warning */
-#endif
-}
-#endif /* READ_INTERLACING */
-
-static void
-png_read_filter_row_sub(png_row_infop row_info, png_bytep row,
- png_const_bytep prev_row)
-{
- size_t i;
- size_t istop = row_info->rowbytes;
- unsigned int bpp = (row_info->pixel_depth + 7) >> 3;
- png_bytep rp = row + bpp;
-
- PNG_UNUSED(prev_row)
-
- for (i = bpp; i < istop; i++)
- {
- *rp = (png_byte)(((int)(*rp) + (int)(*(rp-bpp))) & 0xff);
- rp++;
- }
-}
-
-static void
-png_read_filter_row_up(png_row_infop row_info, png_bytep row,
- png_const_bytep prev_row)
-{
- size_t i;
- size_t istop = row_info->rowbytes;
- png_bytep rp = row;
- png_const_bytep pp = prev_row;
-
- for (i = 0; i < istop; i++)
- {
- *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff);
- rp++;
- }
-}
-
-static void
-png_read_filter_row_avg(png_row_infop row_info, png_bytep row,
- png_const_bytep prev_row)
-{
- size_t i;
- png_bytep rp = row;
- png_const_bytep pp = prev_row;
- unsigned int bpp = (row_info->pixel_depth + 7) >> 3;
- size_t istop = row_info->rowbytes - bpp;
-
- for (i = 0; i < bpp; i++)
- {
- *rp = (png_byte)(((int)(*rp) +
- ((int)(*pp++) / 2 )) & 0xff);
-
- rp++;
- }
-
- for (i = 0; i < istop; i++)
- {
- *rp = (png_byte)(((int)(*rp) +
- (int)(*pp++ + *(rp-bpp)) / 2 ) & 0xff);
-
- rp++;
- }
-}
-
-static void
-png_read_filter_row_paeth_1byte_pixel(png_row_infop row_info, png_bytep row,
- png_const_bytep prev_row)
-{
- png_bytep rp_end = row + row_info->rowbytes;
- int a, c;
-
- /* First pixel/byte */
- c = *prev_row++;
- a = *row + c;
- *row++ = (png_byte)a;
-
- /* Remainder */
- while (row < rp_end)
- {
- int b, pa, pb, pc, p;
-
- a &= 0xff; /* From previous iteration or start */
- b = *prev_row++;
-
- p = b - c;
- pc = a - c;
-
-#ifdef PNG_USE_ABS
- pa = abs(p);
- pb = abs(pc);
- pc = abs(p + pc);
-#else
- pa = p < 0 ? -p : p;
- pb = pc < 0 ? -pc : pc;
- pc = (p + pc) < 0 ? -(p + pc) : p + pc;
-#endif
-
- /* Find the best predictor, the least of pa, pb, pc favoring the earlier
- * ones in the case of a tie.
- */
- if (pb < pa)
- {
- pa = pb; a = b;
- }
- if (pc < pa) a = c;
-
- /* Calculate the current pixel in a, and move the previous row pixel to c
- * for the next time round the loop
- */
- c = b;
- a += *row;
- *row++ = (png_byte)a;
- }
-}
-
-static void
-png_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row,
- png_const_bytep prev_row)
-{
- unsigned int bpp = (row_info->pixel_depth + 7) >> 3;
- png_bytep rp_end = row + bpp;
-
- /* Process the first pixel in the row completely (this is the same as 'up'
- * because there is only one candidate predictor for the first row).
- */
- while (row < rp_end)
- {
- int a = *row + *prev_row++;
- *row++ = (png_byte)a;
- }
-
- /* Remainder */
- rp_end = rp_end + (row_info->rowbytes - bpp);
-
- while (row < rp_end)
- {
- int a, b, c, pa, pb, pc, p;
-
- c = *(prev_row - bpp);
- a = *(row - bpp);
- b = *prev_row++;
-
- p = b - c;
- pc = a - c;
-
-#ifdef PNG_USE_ABS
- pa = abs(p);
- pb = abs(pc);
- pc = abs(p + pc);
-#else
- pa = p < 0 ? -p : p;
- pb = pc < 0 ? -pc : pc;
- pc = (p + pc) < 0 ? -(p + pc) : p + pc;
-#endif
-
- if (pb < pa)
- {
- pa = pb; a = b;
- }
- if (pc < pa) a = c;
-
- a += *row;
- *row++ = (png_byte)a;
- }
-}
-
-static void
-png_init_filter_functions(png_structrp pp)
- /* This function is called once for every PNG image (except for PNG images
- * that only use PNG_FILTER_VALUE_NONE for all rows) to set the
- * implementations required to reverse the filtering of PNG rows. Reversing
- * the filter is the first transformation performed on the row data. It is
- * performed in place, therefore an implementation can be selected based on
- * the image pixel format. If the implementation depends on image width then
- * take care to ensure that it works correctly if the image is interlaced -
- * interlacing causes the actual row width to vary.
- */
-{
- unsigned int bpp = (pp->pixel_depth + 7) >> 3;
-
- pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub;
- pp->read_filter[PNG_FILTER_VALUE_UP-1] = png_read_filter_row_up;
- pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg;
- if (bpp == 1)
- pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =
- png_read_filter_row_paeth_1byte_pixel;
- else
- pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =
- png_read_filter_row_paeth_multibyte_pixel;
-
-#ifdef PNG_FILTER_OPTIMIZATIONS
- /* To use this define PNG_FILTER_OPTIMIZATIONS as the name of a function to
- * call to install hardware optimizations for the above functions; simply
- * replace whatever elements of the pp->read_filter[] array with a hardware
- * specific (or, for that matter, generic) optimization.
- *
- * To see an example of this examine what configure.ac does when
- * --enable-arm-neon is specified on the command line.
- */
- PNG_FILTER_OPTIMIZATIONS(pp, bpp);
-#endif
-}
-
-void /* PRIVATE */
-png_read_filter_row(png_structrp pp, png_row_infop row_info, png_bytep row,
- png_const_bytep prev_row, int filter)
-{
- /* OPTIMIZATION: DO NOT MODIFY THIS FUNCTION, instead #define
- * PNG_FILTER_OPTIMIZATIONS to a function that overrides the generic
- * implementations. See png_init_filter_functions above.
- */
- if (filter > PNG_FILTER_VALUE_NONE && filter < PNG_FILTER_VALUE_LAST)
- {
- if (pp->read_filter[0] == NULL)
- png_init_filter_functions(pp);
-
- pp->read_filter[filter-1](row_info, row, prev_row);
- }
-}
-
-#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
-void /* PRIVATE */
-png_read_IDAT_data(png_structrp png_ptr, png_bytep output,
- png_alloc_size_t avail_out)
-{
- /* Loop reading IDATs and decompressing the result into output[avail_out] */
- png_ptr->zstream.next_out = output;
- png_ptr->zstream.avail_out = 0; /* safety: set below */
-
- if (output == NULL)
- avail_out = 0;
-
- do
- {
- int ret;
- png_byte tmpbuf[PNG_INFLATE_BUF_SIZE];
-
- if (png_ptr->zstream.avail_in == 0)
- {
- uInt avail_in;
- png_bytep buffer;
-
-#ifdef PNG_READ_APNG_SUPPORTED
- png_uint_32 bytes_to_skip = 0;
-
- while (png_ptr->idat_size == 0 || bytes_to_skip != 0)
- {
- png_crc_finish(png_ptr, bytes_to_skip);
- bytes_to_skip = 0;
-
- png_ptr->idat_size = png_read_chunk_header(png_ptr);
- if (png_ptr->num_frames_read == 0)
- {
- if (png_ptr->chunk_name != png_IDAT)
- png_error(png_ptr, "Not enough image data");
- }
- else
- {
- if (png_ptr->chunk_name == png_IEND)
- png_error(png_ptr, "Not enough image data");
- if (png_ptr->chunk_name != png_fdAT)
- {
- png_warning(png_ptr, "Skipped (ignored) a chunk "
- "between APNG chunks");
- bytes_to_skip = png_ptr->idat_size;
- continue;
- }
-
- png_ensure_sequence_number(png_ptr, png_ptr->idat_size);
-
- png_ptr->idat_size -= 4;
- }
- }
-#else
- while (png_ptr->idat_size == 0)
- {
- png_crc_finish(png_ptr, 0);
-
- png_ptr->idat_size = png_read_chunk_header(png_ptr);
- /* This is an error even in the 'check' case because the code just
- * consumed a non-IDAT header.
- */
- if (png_ptr->chunk_name != png_IDAT)
- png_error(png_ptr, "Not enough image data");
- }
-#endif /* READ_APNG */
-
- avail_in = png_ptr->IDAT_read_size;
-
- if (avail_in > png_ptr->idat_size)
- avail_in = (uInt)png_ptr->idat_size;
-
- /* A PNG with a gradually increasing IDAT size will defeat this attempt
- * to minimize memory usage by causing lots of re-allocs, but
- * realistically doing IDAT_read_size re-allocs is not likely to be a
- * big problem.
- */
- buffer = png_read_buffer(png_ptr, avail_in, 0/*error*/);
-
- png_crc_read(png_ptr, buffer, avail_in);
- png_ptr->idat_size -= avail_in;
-
- png_ptr->zstream.next_in = buffer;
- png_ptr->zstream.avail_in = avail_in;
- }
-
- /* And set up the output side. */
- if (output != NULL) /* standard read */
- {
- uInt out = ZLIB_IO_MAX;
-
- if (out > avail_out)
- out = (uInt)avail_out;
-
- avail_out -= out;
- png_ptr->zstream.avail_out = out;
- }
-
- else /* after last row, checking for end */
- {
- png_ptr->zstream.next_out = tmpbuf;
- png_ptr->zstream.avail_out = (sizeof tmpbuf);
- }
-
- /* Use NO_FLUSH; this gives zlib the maximum opportunity to optimize the
- * process. If the LZ stream is truncated the sequential reader will
- * terminally damage the stream, above, by reading the chunk header of the
- * following chunk (it then exits with png_error).
- *
- * TODO: deal more elegantly with truncated IDAT lists.
- */
- ret = PNG_INFLATE(png_ptr, Z_NO_FLUSH);
-
- /* Take the unconsumed output back. */
- if (output != NULL)
- avail_out += png_ptr->zstream.avail_out;
-
- else /* avail_out counts the extra bytes */
- avail_out += (sizeof tmpbuf) - png_ptr->zstream.avail_out;
-
- png_ptr->zstream.avail_out = 0;
-
- if (ret == Z_STREAM_END)
- {
- /* Do this for safety; we won't read any more into this row. */
- png_ptr->zstream.next_out = NULL;
-
- png_ptr->mode |= PNG_AFTER_IDAT;
- png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED;
-#ifdef PNG_READ_APNG_SUPPORTED
- png_ptr->num_frames_read++;
-#endif
-
- if (png_ptr->zstream.avail_in > 0 || png_ptr->idat_size > 0)
- png_chunk_benign_error(png_ptr, "Extra compressed data");
- break;
- }
-
- if (ret != Z_OK)
- {
- png_zstream_error(png_ptr, ret);
-
- if (output != NULL)
- png_chunk_error(png_ptr, png_ptr->zstream.msg);
-
- else /* checking */
- {
- png_chunk_benign_error(png_ptr, png_ptr->zstream.msg);
- return;
- }
- }
- } while (avail_out > 0);
-
- if (avail_out > 0)
- {
- /* The stream ended before the image; this is the same as too few IDATs so
- * should be handled the same way.
- */
- if (output != NULL)
- png_error(png_ptr, "Not enough image data");
-
- else /* the deflate stream contained extra data */
- png_chunk_benign_error(png_ptr, "Too much image data");
- }
-}
-
-void /* PRIVATE */
-png_read_finish_IDAT(png_structrp png_ptr)
-{
- /* We don't need any more data and the stream should have ended, however the
- * LZ end code may actually not have been processed. In this case we must
- * read it otherwise stray unread IDAT data or, more likely, an IDAT chunk
- * may still remain to be consumed.
- */
- if ((png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED) == 0)
- {
- /* The NULL causes png_read_IDAT_data to swallow any remaining bytes in
- * the compressed stream, but the stream may be damaged too, so even after
- * this call we may need to terminate the zstream ownership.
- */
- png_read_IDAT_data(png_ptr, NULL, 0);
- png_ptr->zstream.next_out = NULL; /* safety */
-
- /* Now clear everything out for safety; the following may not have been
- * done.
- */
- if ((png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED) == 0)
- {
- png_ptr->mode |= PNG_AFTER_IDAT;
- png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED;
- }
- }
-
- /* If the zstream has not been released do it now *and* terminate the reading
- * of the final IDAT chunk.
- */
- if (png_ptr->zowner == png_IDAT)
- {
- /* Always do this; the pointers otherwise point into the read buffer. */
- png_ptr->zstream.next_in = NULL;
- png_ptr->zstream.avail_in = 0;
-
- /* Now we no longer own the zstream. */
- png_ptr->zowner = 0;
-
- /* The slightly weird semantics of the sequential IDAT reading is that we
- * are always in or at the end of an IDAT chunk, so we always need to do a
- * crc_finish here. If idat_size is non-zero we also need to read the
- * spurious bytes at the end of the chunk now.
- */
- (void)png_crc_finish(png_ptr, png_ptr->idat_size);
- }
-}
-
-void /* PRIVATE */
-png_read_finish_row(png_structrp png_ptr)
-{
- png_debug(1, "in png_read_finish_row");
- png_ptr->row_number++;
- if (png_ptr->row_number < png_ptr->num_rows)
- return;
-
- if (png_ptr->interlaced != 0)
- {
- png_ptr->row_number = 0;
-
- /* TO DO: don't do this if prev_row isn't needed (requires
- * read-ahead of the next row's filter byte.
- */
- memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
-
- do
- {
- png_ptr->pass++;
-
- if (png_ptr->pass >= 7)
- break;
-
- png_ptr->iwidth = (png_ptr->width +
- png_pass_inc[png_ptr->pass] - 1 -
- png_pass_start[png_ptr->pass]) /
- png_pass_inc[png_ptr->pass];
-
- if ((png_ptr->transformations & PNG_INTERLACE) == 0)
- {
- png_ptr->num_rows = (png_ptr->height +
- png_pass_yinc[png_ptr->pass] - 1 -
- png_pass_ystart[png_ptr->pass]) /
- png_pass_yinc[png_ptr->pass];
- }
-
- else /* if (png_ptr->transformations & PNG_INTERLACE) */
- break; /* libpng deinterlacing sees every row */
-
- } while (png_ptr->num_rows == 0 || png_ptr->iwidth == 0);
-
- if (png_ptr->pass < 7)
- return;
- }
-
- /* Here after at the end of the last row of the last pass. */
- png_read_finish_IDAT(png_ptr);
-}
-#endif /* SEQUENTIAL_READ */
-
-void /* PRIVATE */
-png_read_start_row(png_structrp png_ptr)
-{
- unsigned int max_pixel_depth;
- size_t row_bytes;
-
- png_debug(1, "in png_read_start_row");
-
-#ifdef PNG_READ_TRANSFORMS_SUPPORTED
- png_init_read_transformations(png_ptr);
-#endif
- if (png_ptr->interlaced != 0)
- {
- if ((png_ptr->transformations & PNG_INTERLACE) == 0)
- png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 -
- png_pass_ystart[0]) / png_pass_yinc[0];
-
- else
- png_ptr->num_rows = png_ptr->height;
-
- png_ptr->iwidth = (png_ptr->width +
- png_pass_inc[png_ptr->pass] - 1 -
- png_pass_start[png_ptr->pass]) /
- png_pass_inc[png_ptr->pass];
- }
-
- else
- {
- png_ptr->num_rows = png_ptr->height;
- png_ptr->iwidth = png_ptr->width;
- }
-
- max_pixel_depth = (unsigned int)png_ptr->pixel_depth;
-
- /* WARNING: * png_read_transform_info (pngrtran.c) performs a simpler set of
- * calculations to calculate the final pixel depth, then
- * png_do_read_transforms actually does the transforms. This means that the
- * code which effectively calculates this value is actually repeated in three
- * separate places. They must all match. Innocent changes to the order of
- * transformations can and will break libpng in a way that causes memory
- * overwrites.
- *
- * TODO: fix this.
- */
-#ifdef PNG_READ_PACK_SUPPORTED
- if ((png_ptr->transformations & PNG_PACK) != 0 && png_ptr->bit_depth < 8)
- max_pixel_depth = 8;
-#endif
-
-#ifdef PNG_READ_EXPAND_SUPPORTED
- if ((png_ptr->transformations & PNG_EXPAND) != 0)
- {
- if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
- {
- if (png_ptr->num_trans != 0)
- max_pixel_depth = 32;
-
- else
- max_pixel_depth = 24;
- }
-
- else if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY)
- {
- if (max_pixel_depth < 8)
- max_pixel_depth = 8;
-
- if (png_ptr->num_trans != 0)
- max_pixel_depth *= 2;
- }
-
- else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB)
- {
- if (png_ptr->num_trans != 0)
- {
- max_pixel_depth *= 4;
- max_pixel_depth /= 3;
- }
- }
- }
-#endif
-
-#ifdef PNG_READ_EXPAND_16_SUPPORTED
- if ((png_ptr->transformations & PNG_EXPAND_16) != 0)
- {
-# ifdef PNG_READ_EXPAND_SUPPORTED
- /* In fact it is an error if it isn't supported, but checking is
- * the safe way.
- */
- if ((png_ptr->transformations & PNG_EXPAND) != 0)
- {
- if (png_ptr->bit_depth < 16)
- max_pixel_depth *= 2;
- }
- else
-# endif
- png_ptr->transformations &= ~PNG_EXPAND_16;
- }
-#endif
-
-#ifdef PNG_READ_FILLER_SUPPORTED
- if ((png_ptr->transformations & (PNG_FILLER)) != 0)
- {
- if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY)
- {
- if (max_pixel_depth <= 8)
- max_pixel_depth = 16;
-
- else
- max_pixel_depth = 32;
- }
-
- else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB ||
- png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
- {
- if (max_pixel_depth <= 32)
- max_pixel_depth = 32;
-
- else
- max_pixel_depth = 64;
- }
- }
-#endif
-
-#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
- if ((png_ptr->transformations & PNG_GRAY_TO_RGB) != 0)
- {
- if (
-#ifdef PNG_READ_EXPAND_SUPPORTED
- (png_ptr->num_trans != 0 &&
- (png_ptr->transformations & PNG_EXPAND) != 0) ||
-#endif
-#ifdef PNG_READ_FILLER_SUPPORTED
- (png_ptr->transformations & (PNG_FILLER)) != 0 ||
-#endif
- png_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
- {
- if (max_pixel_depth <= 16)
- max_pixel_depth = 32;
-
- else
- max_pixel_depth = 64;
- }
-
- else
- {
- if (max_pixel_depth <= 8)
- {
- if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
- max_pixel_depth = 32;
-
- else
- max_pixel_depth = 24;
- }
-
- else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
- max_pixel_depth = 64;
-
- else
- max_pixel_depth = 48;
- }
- }
-#endif
-
-#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) && \
-defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
- if ((png_ptr->transformations & PNG_USER_TRANSFORM) != 0)
- {
- unsigned int user_pixel_depth = png_ptr->user_transform_depth *
- png_ptr->user_transform_channels;
-
- if (user_pixel_depth > max_pixel_depth)
- max_pixel_depth = user_pixel_depth;
- }
-#endif
-
- /* This value is stored in png_struct and double checked in the row read
- * code.
- */
- png_ptr->maximum_pixel_depth = (png_byte)max_pixel_depth;
- png_ptr->transformed_pixel_depth = 0; /* calculated on demand */
-
- /* Align the width on the next larger 8 pixels. Mainly used
- * for interlacing
- */
- row_bytes = ((png_ptr->width + 7) & ~((png_uint_32)7));
- /* Calculate the maximum bytes needed, adding a byte and a pixel
- * for safety's sake
- */
- row_bytes = PNG_ROWBYTES(max_pixel_depth, row_bytes) +
- 1 + ((max_pixel_depth + 7) >> 3U);
-
-#ifdef PNG_MAX_MALLOC_64K
- if (row_bytes > (png_uint_32)65536L)
- png_error(png_ptr, "This image requires a row greater than 64KB");
-#endif
-
- if (row_bytes + 48 > png_ptr->old_big_row_buf_size)
- {
- png_free(png_ptr, png_ptr->big_row_buf);
- png_free(png_ptr, png_ptr->big_prev_row);
-
- if (png_ptr->interlaced != 0)
- png_ptr->big_row_buf = (png_bytep)png_calloc(png_ptr,
- row_bytes + 48);
-
- else
- png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes + 48);
-
- png_ptr->big_prev_row = (png_bytep)png_malloc(png_ptr, row_bytes + 48);
-
-#ifdef PNG_ALIGNED_MEMORY_SUPPORTED
- /* Use 16-byte aligned memory for row_buf with at least 16 bytes
- * of padding before and after row_buf; treat prev_row similarly.
- * NOTE: the alignment is to the start of the pixels, one beyond the start
- * of the buffer, because of the filter byte. Prior to libpng 1.5.6 this
- * was incorrect; the filter byte was aligned, which had the exact
- * opposite effect of that intended.
- */
- {
- png_bytep temp = png_ptr->big_row_buf + 32;
- size_t extra = (size_t)temp & 0x0f;
- png_ptr->row_buf = temp - extra - 1/*filter byte*/;
-
- temp = png_ptr->big_prev_row + 32;
- extra = (size_t)temp & 0x0f;
- png_ptr->prev_row = temp - extra - 1/*filter byte*/;
- }
-#else
- /* Use 31 bytes of padding before and 17 bytes after row_buf. */
- png_ptr->row_buf = png_ptr->big_row_buf + 31;
- png_ptr->prev_row = png_ptr->big_prev_row + 31;
-#endif
- png_ptr->old_big_row_buf_size = row_bytes + 48;
- }
-
-#ifdef PNG_MAX_MALLOC_64K
- if (png_ptr->rowbytes > 65535)
- png_error(png_ptr, "This image requires a row greater than 64KB");
-
-#endif
- if (png_ptr->rowbytes > (PNG_SIZE_MAX - 1))
- png_error(png_ptr, "Row has too many bytes to allocate in memory");
-
- memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
-
- png_debug1(3, "width = %u,", png_ptr->width);
- png_debug1(3, "height = %u,", png_ptr->height);
- png_debug1(3, "iwidth = %u,", png_ptr->iwidth);
- png_debug1(3, "num_rows = %u,", png_ptr->num_rows);
- png_debug1(3, "rowbytes = %lu,", (unsigned long)png_ptr->rowbytes);
- png_debug1(3, "irowbytes = %lu",
- (unsigned long)PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->iwidth) + 1);
-
- /* The sequential reader needs a buffer for IDAT, but the progressive reader
- * does not, so free the read buffer now regardless; the sequential reader
- * reallocates it on demand.
- */
- if (png_ptr->read_buffer != NULL)
- {
- png_bytep buffer = png_ptr->read_buffer;
-
- png_ptr->read_buffer_size = 0;
- png_ptr->read_buffer = NULL;
- png_free(png_ptr, buffer);
- }
-
- /* Finally claim the zstream for the inflate of the IDAT data, use the bits
- * value from the stream (note that this will result in a fatal error if the
- * IDAT stream has a bogus deflate header window_bits value, but this should
- * not be happening any longer!)
- */
- if (png_inflate_claim(png_ptr, png_IDAT) != Z_OK)
- png_error(png_ptr, png_ptr->zstream.msg);
-
- png_ptr->flags |= PNG_FLAG_ROW_INIT;
-}
-
-#ifdef PNG_READ_APNG_SUPPORTED
-/* This function is to be called after the main IDAT set has been read and
- * before a new IDAT is read. It resets some parts of png_ptr
- * to make them usable by the read functions again */
-void /* PRIVATE */
-png_read_reset(png_structp png_ptr)
-{
- png_ptr->mode &= ~PNG_HAVE_IDAT;
- png_ptr->mode &= ~PNG_AFTER_IDAT;
- png_ptr->row_number = 0;
- png_ptr->pass = 0;
-}
-
-void /* PRIVATE */
-png_read_reinit(png_structp png_ptr, png_infop info_ptr)
-{
- png_ptr->width = info_ptr->next_frame_width;
- png_ptr->height = info_ptr->next_frame_height;
- png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth,png_ptr->width);
- png_ptr->info_rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth,
- png_ptr->width);
- if (png_ptr->prev_row != NULL)
- memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
-}
-
-#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
-/* same as png_read_reset() but for the progressive reader */
-void /* PRIVATE */
-png_progressive_read_reset(png_structp png_ptr)
-{
-#ifdef PNG_READ_INTERLACING_SUPPORTED
- /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
-
- /* Start of interlace block */
- static const png_byte png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
-
- /* Offset to next interlace block */
- static const png_byte png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
-
- /* Start of interlace block in the y direction */
- static const png_byte png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
-
- /* Offset to next interlace block in the y direction */
- static const png_byte png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
-
- if (png_ptr->interlaced != 0)
- {
- if ((png_ptr->transformations & PNG_INTERLACE) == 0)
- png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 -
- png_pass_ystart[0]) / png_pass_yinc[0];
- else
- png_ptr->num_rows = png_ptr->height;
-
- png_ptr->iwidth = (png_ptr->width +
- png_pass_inc[png_ptr->pass] - 1 -
- png_pass_start[png_ptr->pass]) /
- png_pass_inc[png_ptr->pass];
- }
- else
-#endif /* READ_INTERLACING */
- {
- png_ptr->num_rows = png_ptr->height;
- png_ptr->iwidth = png_ptr->width;
- }
- png_ptr->flags &= ~PNG_FLAG_ZSTREAM_ENDED;
- if (inflateReset(&(png_ptr->zstream)) != Z_OK)
- png_error(png_ptr, "inflateReset failed");
- png_ptr->zstream.avail_in = 0;
- png_ptr->zstream.next_in = 0;
- png_ptr->zstream.next_out = png_ptr->row_buf;
- png_ptr->zstream.avail_out = (uInt)PNG_ROWBYTES(png_ptr->pixel_depth,
- png_ptr->iwidth) + 1;
-}
-#endif /* PROGRESSIVE_READ */
-#endif /* READ_APNG */
-#endif /* READ */
diff --git a/contrib/libs/libpng/pngset.c b/contrib/libs/libpng/pngset.c
deleted file mode 100644
index b090bf71db..0000000000
--- a/contrib/libs/libpng/pngset.c
+++ /dev/null
@@ -1,2128 +0,0 @@
-/* pngset.c - storage of image information into info struct
- *
- * Copyright (c) 2018-2025 Cosmin Truta
- * Copyright (c) 1998-2018 Glenn Randers-Pehrson
- * Copyright (c) 1996-1997 Andreas Dilger
- * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
- *
- * This code is released under the libpng license.
- * For conditions of distribution and use, see the disclaimer
- * and license in png.h
- *
- * The functions here are used during reads to store data from the file
- * into the info struct, and during writes to store application data
- * into the info struct for writing into the file. This abstracts the
- * info struct and allows us to change the structure in the future.
- */
-
-#include "pngpriv.h"
-
-#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
-
-#ifdef PNG_bKGD_SUPPORTED
-void PNGAPI
-png_set_bKGD(png_const_structrp png_ptr, png_inforp info_ptr,
- png_const_color_16p background)
-{
- png_debug1(1, "in %s storage function", "bKGD");
-
- if (png_ptr == NULL || info_ptr == NULL || background == NULL)
- return;
-
- info_ptr->background = *background;
- info_ptr->valid |= PNG_INFO_bKGD;
-}
-#endif
-
-#ifdef PNG_cHRM_SUPPORTED
-void PNGFAPI
-png_set_cHRM_fixed(png_const_structrp png_ptr, png_inforp info_ptr,
- png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x,
- png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y,
- png_fixed_point blue_x, png_fixed_point blue_y)
-{
- png_xy xy;
-
- png_debug1(1, "in %s storage function", "cHRM fixed");
-
- if (png_ptr == NULL || info_ptr == NULL)
- return;
-
- xy.redx = red_x;
- xy.redy = red_y;
- xy.greenx = green_x;
- xy.greeny = green_y;
- xy.bluex = blue_x;
- xy.bluey = blue_y;
- xy.whitex = white_x;
- xy.whitey = white_y;
-
- if (png_colorspace_set_chromaticities(png_ptr, &info_ptr->colorspace, &xy,
- 2/* override with app values*/) != 0)
- info_ptr->colorspace.flags |= PNG_COLORSPACE_FROM_cHRM;
-
- png_colorspace_sync_info(png_ptr, info_ptr);
-}
-
-void PNGFAPI
-png_set_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_inforp info_ptr,
- png_fixed_point int_red_X, png_fixed_point int_red_Y,
- png_fixed_point int_red_Z, png_fixed_point int_green_X,
- png_fixed_point int_green_Y, png_fixed_point int_green_Z,
- png_fixed_point int_blue_X, png_fixed_point int_blue_Y,
- png_fixed_point int_blue_Z)
-{
- png_XYZ XYZ;
-
- png_debug1(1, "in %s storage function", "cHRM XYZ fixed");
-
- if (png_ptr == NULL || info_ptr == NULL)
- return;
-
- XYZ.red_X = int_red_X;
- XYZ.red_Y = int_red_Y;
- XYZ.red_Z = int_red_Z;
- XYZ.green_X = int_green_X;
- XYZ.green_Y = int_green_Y;
- XYZ.green_Z = int_green_Z;
- XYZ.blue_X = int_blue_X;
- XYZ.blue_Y = int_blue_Y;
- XYZ.blue_Z = int_blue_Z;
-
- if (png_colorspace_set_endpoints(png_ptr, &info_ptr->colorspace,
- &XYZ, 2) != 0)
- info_ptr->colorspace.flags |= PNG_COLORSPACE_FROM_cHRM;
-
- png_colorspace_sync_info(png_ptr, info_ptr);
-}
-
-# ifdef PNG_FLOATING_POINT_SUPPORTED
-void PNGAPI
-png_set_cHRM(png_const_structrp png_ptr, png_inforp info_ptr,
- double white_x, double white_y, double red_x, double red_y,
- double green_x, double green_y, double blue_x, double blue_y)
-{
- png_set_cHRM_fixed(png_ptr, info_ptr,
- png_fixed(png_ptr, white_x, "cHRM White X"),
- png_fixed(png_ptr, white_y, "cHRM White Y"),
- png_fixed(png_ptr, red_x, "cHRM Red X"),
- png_fixed(png_ptr, red_y, "cHRM Red Y"),
- png_fixed(png_ptr, green_x, "cHRM Green X"),
- png_fixed(png_ptr, green_y, "cHRM Green Y"),
- png_fixed(png_ptr, blue_x, "cHRM Blue X"),
- png_fixed(png_ptr, blue_y, "cHRM Blue Y"));
-}
-
-void PNGAPI
-png_set_cHRM_XYZ(png_const_structrp png_ptr, png_inforp info_ptr, double red_X,
- double red_Y, double red_Z, double green_X, double green_Y, double green_Z,
- double blue_X, double blue_Y, double blue_Z)
-{
- png_set_cHRM_XYZ_fixed(png_ptr, info_ptr,
- png_fixed(png_ptr, red_X, "cHRM Red X"),
- png_fixed(png_ptr, red_Y, "cHRM Red Y"),
- png_fixed(png_ptr, red_Z, "cHRM Red Z"),
- png_fixed(png_ptr, green_X, "cHRM Green X"),
- png_fixed(png_ptr, green_Y, "cHRM Green Y"),
- png_fixed(png_ptr, green_Z, "cHRM Green Z"),
- png_fixed(png_ptr, blue_X, "cHRM Blue X"),
- png_fixed(png_ptr, blue_Y, "cHRM Blue Y"),
- png_fixed(png_ptr, blue_Z, "cHRM Blue Z"));
-}
-# endif /* FLOATING_POINT */
-
-#endif /* cHRM */
-
-#ifdef PNG_cICP_SUPPORTED
-void PNGAPI
-png_set_cICP(png_const_structrp png_ptr, png_inforp info_ptr,
- png_byte colour_primaries, png_byte transfer_function,
- png_byte matrix_coefficients, png_byte video_full_range_flag)
-{
- png_debug1(1, "in %s storage function", "cICP");
-
- if (png_ptr == NULL || info_ptr == NULL)
- return;
-
- info_ptr->cicp_colour_primaries = colour_primaries;
- info_ptr->cicp_transfer_function = transfer_function;
- info_ptr->cicp_matrix_coefficients = matrix_coefficients;
- info_ptr->cicp_video_full_range_flag = video_full_range_flag;
-
- if (info_ptr->cicp_matrix_coefficients != 0)
- {
- png_warning(png_ptr, "Invalid cICP matrix coefficients");
- return;
- }
-
- info_ptr->valid |= PNG_INFO_cICP;
-}
-#endif /* cICP */
-
-#ifdef PNG_cLLI_SUPPORTED
-void PNGFAPI
-png_set_cLLI_fixed(png_const_structrp png_ptr, png_inforp info_ptr,
- /* The values below are in cd/m2 (nits) and are scaled by 10,000; not
- * 100,000 as in the case of png_fixed_point.
- */
- png_uint_32 maxCLL, png_uint_32 maxFALL)
-{
- png_debug1(1, "in %s storage function", "cLLI");
-
- if (png_ptr == NULL || info_ptr == NULL)
- return;
-
- /* Check the light level range: */
- if (maxCLL > 0x7FFFFFFFU || maxFALL > 0x7FFFFFFFU)
- {
- /* The limit is 200kcd/m2; somewhat bright but not inconceivable because
- * human vision is said to run up to 100Mcd/m2. The sun is about 2Gcd/m2.
- *
- * The reference sRGB monitor is 80cd/m2 and the limit of PQ encoding is
- * 2kcd/m2.
- */
- png_chunk_report(png_ptr, "cLLI light level exceeds PNG limit",
- PNG_CHUNK_WRITE_ERROR);
- return;
- }
-
- info_ptr->maxCLL = maxCLL;
- info_ptr->maxFALL = maxFALL;
- info_ptr->valid |= PNG_INFO_cLLI;
-}
-
-# ifdef PNG_FLOATING_POINT_SUPPORTED
-void PNGAPI
-png_set_cLLI(png_const_structrp png_ptr, png_inforp info_ptr,
- double maxCLL, double maxFALL)
-{
- png_set_cLLI_fixed(png_ptr, info_ptr,
- png_fixed_ITU(png_ptr, maxCLL, "png_set_cLLI(maxCLL)"),
- png_fixed_ITU(png_ptr, maxFALL, "png_set_cLLI(maxFALL)"));
-}
-# endif /* FLOATING_POINT */
-#endif /* cLLI */
-
-#ifdef PNG_mDCV_SUPPORTED
-static png_uint_16
-png_ITU_fixed_16(png_const_structrp png_ptr, png_fixed_point v,
- png_const_charp text)
-{
- /* Return a safe uint16_t value scaled according to the ITU H273 rules for
- * 16-bit display chromaticities. Functions like the corresponding
- * png_fixed() internal function with regard to errors: it's an error on
- * write, a chunk_benign_error on read: See the definition of
- * png_chunk_report in pngpriv.h.
- */
- v /= 2; /* rounds to 0 in C: avoids insignificant arithmetic errors */
- if (v > 65535 || v < 0)
- png_fixed_error(png_ptr, text);
-
-# ifndef PNG_ERROR_TEXT_SUPPORTED
- PNG_UNUSED(text)
-# endif
-
- return (png_uint_16)/*SAFE*/v;
-}
-
-void PNGAPI
-png_set_mDCV_fixed(png_const_structrp png_ptr, png_inforp info_ptr,
- png_fixed_point white_x, png_fixed_point white_y,
- png_fixed_point red_x, png_fixed_point red_y,
- png_fixed_point green_x, png_fixed_point green_y,
- png_fixed_point blue_x, png_fixed_point blue_y,
- png_uint_32 maxDL,
- png_uint_32 minDL)
-{
- png_uint_16 rx, ry, gx, gy, bx, by, wx, wy;
-
- png_debug1(1, "in %s storage function", "mDCV");
-
- if (png_ptr == NULL || info_ptr == NULL)
- return;
-
- /* Check the input values to ensure they are in the expected range: */
- rx = png_ITU_fixed_16(png_ptr, red_x, "png_set_mDCV(red(x))");
- ry = png_ITU_fixed_16(png_ptr, red_y, "png_set_mDCV(red(y))");
- gx = png_ITU_fixed_16(png_ptr, green_x, "png_set_mDCV(green(x))");
- gy = png_ITU_fixed_16(png_ptr, green_y, "png_set_mDCV(green(y))");
- bx = png_ITU_fixed_16(png_ptr, blue_x, "png_set_mDCV(blue(x))");
- by = png_ITU_fixed_16(png_ptr, blue_y, "png_set_mDCV(blue(y))");
- wx = png_ITU_fixed_16(png_ptr, white_x, "png_set_mDCV(white(x))");
- wy = png_ITU_fixed_16(png_ptr, white_y, "png_set_mDCV(white(y))");
-
- /* Check the light level range: */
- if (maxDL > 0x7FFFFFFFU || minDL > 0x7FFFFFFFU)
- {
- /* The limit is 200kcd/m2; somewhat bright but not inconceivable because
- * human vision is said to run up to 100Mcd/m2. The sun is about 2Gcd/m2.
- *
- * The reference sRGB monitor is 80cd/m2 and the limit of PQ encoding is
- * 2kcd/m2.
- */
- png_chunk_report(png_ptr, "mDCV display light level exceeds PNG limit",
- PNG_CHUNK_WRITE_ERROR);
- return;
- }
-
- /* All values are safe, the settings are accepted.
- *
- * IMPLEMENTATION NOTE: in practice the values can be checked and assigned
- * but the result is confusing if a writing app calls png_set_mDCV more than
- * once, the second time with an invalid value. This approach is more
- * obviously correct at the cost of typing and a very slight machine
- * overhead.
- */
- info_ptr->mastering_red_x = rx;
- info_ptr->mastering_red_y = ry;
- info_ptr->mastering_green_x = gx;
- info_ptr->mastering_green_y = gy;
- info_ptr->mastering_blue_x = bx;
- info_ptr->mastering_blue_y = by;
- info_ptr->mastering_white_x = wx;
- info_ptr->mastering_white_y = wy;
- info_ptr->mastering_maxDL = maxDL;
- info_ptr->mastering_minDL = minDL;
- info_ptr->valid |= PNG_INFO_mDCV;
-}
-
-# ifdef PNG_FLOATING_POINT_SUPPORTED
-void PNGAPI
-png_set_mDCV(png_const_structrp png_ptr, png_inforp info_ptr,
- double white_x, double white_y, double red_x, double red_y, double green_x,
- double green_y, double blue_x, double blue_y,
- double maxDL, double minDL)
-{
- png_set_mDCV_fixed(png_ptr, info_ptr,
- /* The ITU approach is to scale by 50,000, not 100,000 so just divide
- * the input values by 2 and use png_fixed:
- */
- png_fixed(png_ptr, white_x / 2, "png_set_mDCV(white(x))"),
- png_fixed(png_ptr, white_y / 2, "png_set_mDCV(white(y))"),
- png_fixed(png_ptr, red_x / 2, "png_set_mDCV(red(x))"),
- png_fixed(png_ptr, red_y / 2, "png_set_mDCV(red(y))"),
- png_fixed(png_ptr, green_x / 2, "png_set_mDCV(green(x))"),
- png_fixed(png_ptr, green_y / 2, "png_set_mDCV(green(y))"),
- png_fixed(png_ptr, blue_x / 2, "png_set_mDCV(blue(x))"),
- png_fixed(png_ptr, blue_y / 2, "png_set_mDCV(blue(y))"),
- png_fixed_ITU(png_ptr, maxDL, "png_set_mDCV(maxDL)"),
- png_fixed_ITU(png_ptr, minDL, "png_set_mDCV(minDL)"));
-}
-# endif /* FLOATING_POINT */
-#endif /* mDCV */
-
-#ifdef PNG_eXIf_SUPPORTED
-void PNGAPI
-png_set_eXIf(png_const_structrp png_ptr, png_inforp info_ptr,
- png_bytep exif)
-{
- png_warning(png_ptr, "png_set_eXIf does not work; use png_set_eXIf_1");
- PNG_UNUSED(info_ptr)
- PNG_UNUSED(exif)
-}
-
-void PNGAPI
-png_set_eXIf_1(png_const_structrp png_ptr, png_inforp info_ptr,
- png_uint_32 num_exif, png_bytep exif)
-{
- png_bytep new_exif;
-
- png_debug1(1, "in %s storage function", "eXIf");
-
- if (png_ptr == NULL || info_ptr == NULL ||
- (png_ptr->mode & PNG_WROTE_eXIf) != 0)
- return;
-
- new_exif = png_voidcast(png_bytep, png_malloc_warn(png_ptr, num_exif));
-
- if (new_exif == NULL)
- {
- png_warning(png_ptr, "Insufficient memory for eXIf chunk data");
- return;
- }
-
- memcpy(new_exif, exif, (size_t)num_exif);
-
- png_free_data(png_ptr, info_ptr, PNG_FREE_EXIF, 0);
-
- info_ptr->num_exif = num_exif;
- info_ptr->exif = new_exif;
- info_ptr->free_me |= PNG_FREE_EXIF;
- info_ptr->valid |= PNG_INFO_eXIf;
-}
-#endif /* eXIf */
-
-#ifdef PNG_gAMA_SUPPORTED
-void PNGFAPI
-png_set_gAMA_fixed(png_const_structrp png_ptr, png_inforp info_ptr,
- png_fixed_point file_gamma)
-{
- png_debug1(1, "in %s storage function", "gAMA");
-
- if (png_ptr == NULL || info_ptr == NULL)
- return;
-
- png_colorspace_set_gamma(png_ptr, &info_ptr->colorspace, file_gamma);
- png_colorspace_sync_info(png_ptr, info_ptr);
-}
-
-# ifdef PNG_FLOATING_POINT_SUPPORTED
-void PNGAPI
-png_set_gAMA(png_const_structrp png_ptr, png_inforp info_ptr, double file_gamma)
-{
- png_set_gAMA_fixed(png_ptr, info_ptr, png_fixed(png_ptr, file_gamma,
- "png_set_gAMA"));
-}
-# endif
-#endif
-
-#ifdef PNG_hIST_SUPPORTED
-void PNGAPI
-png_set_hIST(png_const_structrp png_ptr, png_inforp info_ptr,
- png_const_uint_16p hist)
-{
- int i;
-
- png_debug1(1, "in %s storage function", "hIST");
-
- if (png_ptr == NULL || info_ptr == NULL)
- return;
-
- if (info_ptr->num_palette == 0 || info_ptr->num_palette
- > PNG_MAX_PALETTE_LENGTH)
- {
- png_warning(png_ptr,
- "Invalid palette size, hIST allocation skipped");
-
- return;
- }
-
- png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0);
-
- /* Changed from info->num_palette to PNG_MAX_PALETTE_LENGTH in
- * version 1.2.1
- */
- info_ptr->hist = png_voidcast(png_uint_16p, png_malloc_warn(png_ptr,
- PNG_MAX_PALETTE_LENGTH * (sizeof (png_uint_16))));
-
- if (info_ptr->hist == NULL)
- {
- png_warning(png_ptr, "Insufficient memory for hIST chunk data");
- return;
- }
-
- for (i = 0; i < info_ptr->num_palette; i++)
- info_ptr->hist[i] = hist[i];
-
- info_ptr->free_me |= PNG_FREE_HIST;
- info_ptr->valid |= PNG_INFO_hIST;
-}
-#endif
-
-void PNGAPI
-png_set_IHDR(png_const_structrp png_ptr, png_inforp info_ptr,
- png_uint_32 width, png_uint_32 height, int bit_depth,
- int color_type, int interlace_type, int compression_type,
- int filter_type)
-{
- png_debug1(1, "in %s storage function", "IHDR");
-
- if (png_ptr == NULL || info_ptr == NULL)
- return;
-
- info_ptr->width = width;
- info_ptr->height = height;
- info_ptr->bit_depth = (png_byte)bit_depth;
- info_ptr->color_type = (png_byte)color_type;
- info_ptr->compression_type = (png_byte)compression_type;
- info_ptr->filter_type = (png_byte)filter_type;
- info_ptr->interlace_type = (png_byte)interlace_type;
-
- png_check_IHDR (png_ptr, info_ptr->width, info_ptr->height,
- info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type,
- info_ptr->compression_type, info_ptr->filter_type);
-
- if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
- info_ptr->channels = 1;
-
- else if ((info_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0)
- info_ptr->channels = 3;
-
- else
- info_ptr->channels = 1;
-
- if ((info_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0)
- info_ptr->channels++;
-
- info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth);
-
- info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, width);
-
-#ifdef PNG_APNG_SUPPORTED
- /* for non-animated png. this may be overwritten from an acTL chunk later */
- info_ptr->num_frames = 1;
-#endif
-}
-
-#ifdef PNG_oFFs_SUPPORTED
-void PNGAPI
-png_set_oFFs(png_const_structrp png_ptr, png_inforp info_ptr,
- png_int_32 offset_x, png_int_32 offset_y, int unit_type)
-{
- png_debug1(1, "in %s storage function", "oFFs");
-
- if (png_ptr == NULL || info_ptr == NULL)
- return;
-
- info_ptr->x_offset = offset_x;
- info_ptr->y_offset = offset_y;
- info_ptr->offset_unit_type = (png_byte)unit_type;
- info_ptr->valid |= PNG_INFO_oFFs;
-}
-#endif
-
-#ifdef PNG_pCAL_SUPPORTED
-void PNGAPI
-png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
- png_const_charp purpose, png_int_32 X0, png_int_32 X1, int type,
- int nparams, png_const_charp units, png_charpp params)
-{
- size_t length;
- int i;
-
- png_debug1(1, "in %s storage function", "pCAL");
-
- if (png_ptr == NULL || info_ptr == NULL || purpose == NULL || units == NULL
- || (nparams > 0 && params == NULL))
- return;
-
- length = strlen(purpose) + 1;
- png_debug1(3, "allocating purpose for info (%lu bytes)",
- (unsigned long)length);
-
- /* TODO: validate format of calibration name and unit name */
-
- /* Check that the type matches the specification. */
- if (type < 0 || type > 3)
- {
- png_chunk_report(png_ptr, "Invalid pCAL equation type",
- PNG_CHUNK_WRITE_ERROR);
- return;
- }
-
- if (nparams < 0 || nparams > 255)
- {
- png_chunk_report(png_ptr, "Invalid pCAL parameter count",
- PNG_CHUNK_WRITE_ERROR);
- return;
- }
-
- /* Validate params[nparams] */
- for (i=0; i<nparams; ++i)
- {
- if (params[i] == NULL ||
- !png_check_fp_string(params[i], strlen(params[i])))
- {
- png_chunk_report(png_ptr, "Invalid format for pCAL parameter",
- PNG_CHUNK_WRITE_ERROR);
- return;
- }
- }
-
- info_ptr->pcal_purpose = png_voidcast(png_charp,
- png_malloc_warn(png_ptr, length));
-
- if (info_ptr->pcal_purpose == NULL)
- {
- png_chunk_report(png_ptr, "Insufficient memory for pCAL purpose",
- PNG_CHUNK_WRITE_ERROR);
- return;
- }
-
- memcpy(info_ptr->pcal_purpose, purpose, length);
-
- info_ptr->free_me |= PNG_FREE_PCAL;
-
- png_debug(3, "storing X0, X1, type, and nparams in info");
- info_ptr->pcal_X0 = X0;
- info_ptr->pcal_X1 = X1;
- info_ptr->pcal_type = (png_byte)type;
- info_ptr->pcal_nparams = (png_byte)nparams;
-
- length = strlen(units) + 1;
- png_debug1(3, "allocating units for info (%lu bytes)",
- (unsigned long)length);
-
- info_ptr->pcal_units = png_voidcast(png_charp,
- png_malloc_warn(png_ptr, length));
-
- if (info_ptr->pcal_units == NULL)
- {
- png_warning(png_ptr, "Insufficient memory for pCAL units");
- return;
- }
-
- memcpy(info_ptr->pcal_units, units, length);
-
- info_ptr->pcal_params = png_voidcast(png_charpp, png_malloc_warn(png_ptr,
- (size_t)(((unsigned int)nparams + 1) * (sizeof (png_charp)))));
-
- if (info_ptr->pcal_params == NULL)
- {
- png_warning(png_ptr, "Insufficient memory for pCAL params");
- return;
- }
-
- memset(info_ptr->pcal_params, 0, ((unsigned int)nparams + 1) *
- (sizeof (png_charp)));
-
- for (i = 0; i < nparams; i++)
- {
- length = strlen(params[i]) + 1;
- png_debug2(3, "allocating parameter %d for info (%lu bytes)", i,
- (unsigned long)length);
-
- info_ptr->pcal_params[i] = (png_charp)png_malloc_warn(png_ptr, length);
-
- if (info_ptr->pcal_params[i] == NULL)
- {
- png_warning(png_ptr, "Insufficient memory for pCAL parameter");
- return;
- }
-
- memcpy(info_ptr->pcal_params[i], params[i], length);
- }
-
- info_ptr->valid |= PNG_INFO_pCAL;
-}
-#endif
-
-#ifdef PNG_sCAL_SUPPORTED
-void PNGAPI
-png_set_sCAL_s(png_const_structrp png_ptr, png_inforp info_ptr,
- int unit, png_const_charp swidth, png_const_charp sheight)
-{
- size_t lengthw = 0, lengthh = 0;
-
- png_debug1(1, "in %s storage function", "sCAL");
-
- if (png_ptr == NULL || info_ptr == NULL)
- return;
-
- /* Double check the unit (should never get here with an invalid
- * unit unless this is an API call.)
- */
- if (unit != 1 && unit != 2)
- png_error(png_ptr, "Invalid sCAL unit");
-
- if (swidth == NULL || (lengthw = strlen(swidth)) == 0 ||
- swidth[0] == 45 /* '-' */ || !png_check_fp_string(swidth, lengthw))
- png_error(png_ptr, "Invalid sCAL width");
-
- if (sheight == NULL || (lengthh = strlen(sheight)) == 0 ||
- sheight[0] == 45 /* '-' */ || !png_check_fp_string(sheight, lengthh))
- png_error(png_ptr, "Invalid sCAL height");
-
- info_ptr->scal_unit = (png_byte)unit;
-
- ++lengthw;
-
- png_debug1(3, "allocating unit for info (%u bytes)", (unsigned int)lengthw);
-
- info_ptr->scal_s_width = png_voidcast(png_charp,
- png_malloc_warn(png_ptr, lengthw));
-
- if (info_ptr->scal_s_width == NULL)
- {
- png_warning(png_ptr, "Memory allocation failed while processing sCAL");
-
- return;
- }
-
- memcpy(info_ptr->scal_s_width, swidth, lengthw);
-
- ++lengthh;
-
- png_debug1(3, "allocating unit for info (%u bytes)", (unsigned int)lengthh);
-
- info_ptr->scal_s_height = png_voidcast(png_charp,
- png_malloc_warn(png_ptr, lengthh));
-
- if (info_ptr->scal_s_height == NULL)
- {
- png_free(png_ptr, info_ptr->scal_s_width);
- info_ptr->scal_s_width = NULL;
-
- png_warning(png_ptr, "Memory allocation failed while processing sCAL");
- return;
- }
-
- memcpy(info_ptr->scal_s_height, sheight, lengthh);
-
- info_ptr->free_me |= PNG_FREE_SCAL;
- info_ptr->valid |= PNG_INFO_sCAL;
-}
-
-# ifdef PNG_FLOATING_POINT_SUPPORTED
-void PNGAPI
-png_set_sCAL(png_const_structrp png_ptr, png_inforp info_ptr, int unit,
- double width, double height)
-{
- png_debug1(1, "in %s storage function", "sCAL");
-
- /* Check the arguments. */
- if (width <= 0)
- png_warning(png_ptr, "Invalid sCAL width ignored");
-
- else if (height <= 0)
- png_warning(png_ptr, "Invalid sCAL height ignored");
-
- else
- {
- /* Convert 'width' and 'height' to ASCII. */
- char swidth[PNG_sCAL_MAX_DIGITS+1];
- char sheight[PNG_sCAL_MAX_DIGITS+1];
-
- png_ascii_from_fp(png_ptr, swidth, (sizeof swidth), width,
- PNG_sCAL_PRECISION);
- png_ascii_from_fp(png_ptr, sheight, (sizeof sheight), height,
- PNG_sCAL_PRECISION);
-
- png_set_sCAL_s(png_ptr, info_ptr, unit, swidth, sheight);
- }
-}
-# endif
-
-# ifdef PNG_FIXED_POINT_SUPPORTED
-void PNGAPI
-png_set_sCAL_fixed(png_const_structrp png_ptr, png_inforp info_ptr, int unit,
- png_fixed_point width, png_fixed_point height)
-{
- png_debug1(1, "in %s storage function", "sCAL");
-
- /* Check the arguments. */
- if (width <= 0)
- png_warning(png_ptr, "Invalid sCAL width ignored");
-
- else if (height <= 0)
- png_warning(png_ptr, "Invalid sCAL height ignored");
-
- else
- {
- /* Convert 'width' and 'height' to ASCII. */
- char swidth[PNG_sCAL_MAX_DIGITS+1];
- char sheight[PNG_sCAL_MAX_DIGITS+1];
-
- png_ascii_from_fixed(png_ptr, swidth, (sizeof swidth), width);
- png_ascii_from_fixed(png_ptr, sheight, (sizeof sheight), height);
-
- png_set_sCAL_s(png_ptr, info_ptr, unit, swidth, sheight);
- }
-}
-# endif
-#endif
-
-#ifdef PNG_pHYs_SUPPORTED
-void PNGAPI
-png_set_pHYs(png_const_structrp png_ptr, png_inforp info_ptr,
- png_uint_32 res_x, png_uint_32 res_y, int unit_type)
-{
- png_debug1(1, "in %s storage function", "pHYs");
-
- if (png_ptr == NULL || info_ptr == NULL)
- return;
-
- info_ptr->x_pixels_per_unit = res_x;
- info_ptr->y_pixels_per_unit = res_y;
- info_ptr->phys_unit_type = (png_byte)unit_type;
- info_ptr->valid |= PNG_INFO_pHYs;
-}
-#endif
-
-void PNGAPI
-png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr,
- png_const_colorp palette, int num_palette)
-{
-
- png_uint_32 max_palette_length;
-
- png_debug1(1, "in %s storage function", "PLTE");
-
- if (png_ptr == NULL || info_ptr == NULL)
- return;
-
- max_palette_length = (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) ?
- (1 << info_ptr->bit_depth) : PNG_MAX_PALETTE_LENGTH;
-
- if (num_palette < 0 || num_palette > (int) max_palette_length)
- {
- if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
- png_error(png_ptr, "Invalid palette length");
-
- else
- {
- png_warning(png_ptr, "Invalid palette length");
-
- return;
- }
- }
-
- if ((num_palette > 0 && palette == NULL) ||
- (num_palette == 0
-# ifdef PNG_MNG_FEATURES_SUPPORTED
- && (png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) == 0
-# endif
- ))
- {
- png_error(png_ptr, "Invalid palette");
- }
-
- /* It may not actually be necessary to set png_ptr->palette here;
- * we do it for backward compatibility with the way the png_handle_tRNS
- * function used to do the allocation.
- *
- * 1.6.0: the above statement appears to be incorrect; something has to set
- * the palette inside png_struct on read.
- */
- png_free_data(png_ptr, info_ptr, PNG_FREE_PLTE, 0);
-
- /* Changed in libpng-1.2.1 to allocate PNG_MAX_PALETTE_LENGTH instead
- * of num_palette entries, in case of an invalid PNG file or incorrect
- * call to png_set_PLTE() with too-large sample values.
- */
- png_ptr->palette = png_voidcast(png_colorp, png_calloc(png_ptr,
- PNG_MAX_PALETTE_LENGTH * (sizeof (png_color))));
-
- if (num_palette > 0)
- memcpy(png_ptr->palette, palette, (unsigned int)num_palette *
- (sizeof (png_color)));
-
- info_ptr->palette = png_ptr->palette;
- info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette;
- info_ptr->free_me |= PNG_FREE_PLTE;
- info_ptr->valid |= PNG_INFO_PLTE;
-}
-
-#ifdef PNG_sBIT_SUPPORTED
-void PNGAPI
-png_set_sBIT(png_const_structrp png_ptr, png_inforp info_ptr,
- png_const_color_8p sig_bit)
-{
- png_debug1(1, "in %s storage function", "sBIT");
-
- if (png_ptr == NULL || info_ptr == NULL || sig_bit == NULL)
- return;
-
- info_ptr->sig_bit = *sig_bit;
- info_ptr->valid |= PNG_INFO_sBIT;
-}
-#endif
-
-#ifdef PNG_sRGB_SUPPORTED
-void PNGAPI
-png_set_sRGB(png_const_structrp png_ptr, png_inforp info_ptr, int srgb_intent)
-{
- png_debug1(1, "in %s storage function", "sRGB");
-
- if (png_ptr == NULL || info_ptr == NULL)
- return;
-
- (void)png_colorspace_set_sRGB(png_ptr, &info_ptr->colorspace, srgb_intent);
- png_colorspace_sync_info(png_ptr, info_ptr);
-}
-
-void PNGAPI
-png_set_sRGB_gAMA_and_cHRM(png_const_structrp png_ptr, png_inforp info_ptr,
- int srgb_intent)
-{
- png_debug1(1, "in %s storage function", "sRGB_gAMA_and_cHRM");
-
- if (png_ptr == NULL || info_ptr == NULL)
- return;
-
- if (png_colorspace_set_sRGB(png_ptr, &info_ptr->colorspace,
- srgb_intent) != 0)
- {
- /* This causes the gAMA and cHRM to be written too */
- info_ptr->colorspace.flags |=
- PNG_COLORSPACE_FROM_gAMA|PNG_COLORSPACE_FROM_cHRM;
- }
-
- png_colorspace_sync_info(png_ptr, info_ptr);
-}
-#endif /* sRGB */
-
-
-#ifdef PNG_iCCP_SUPPORTED
-void PNGAPI
-png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
- png_const_charp name, int compression_type,
- png_const_bytep profile, png_uint_32 proflen)
-{
- png_charp new_iccp_name;
- png_bytep new_iccp_profile;
- size_t length;
-
- png_debug1(1, "in %s storage function", "iCCP");
-
- if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL)
- return;
-
- if (compression_type != PNG_COMPRESSION_TYPE_BASE)
- png_app_error(png_ptr, "Invalid iCCP compression method");
-
- /* Set the colorspace first because this validates the profile; do not
- * override previously set app cHRM or gAMA here (because likely as not the
- * application knows better than libpng what the correct values are.) Pass
- * the info_ptr color_type field to png_colorspace_set_ICC because in the
- * write case it has not yet been stored in png_ptr.
- */
- {
- int result = png_colorspace_set_ICC(png_ptr, &info_ptr->colorspace, name,
- proflen, profile, info_ptr->color_type);
-
- png_colorspace_sync_info(png_ptr, info_ptr);
-
- /* Don't do any of the copying if the profile was bad, or inconsistent. */
- if (result == 0)
- return;
-
- /* But do write the gAMA and cHRM chunks from the profile. */
- info_ptr->colorspace.flags |=
- PNG_COLORSPACE_FROM_gAMA|PNG_COLORSPACE_FROM_cHRM;
- }
-
- length = strlen(name)+1;
- new_iccp_name = png_voidcast(png_charp, png_malloc_warn(png_ptr, length));
-
- if (new_iccp_name == NULL)
- {
- png_benign_error(png_ptr, "Insufficient memory to process iCCP chunk");
-
- return;
- }
-
- memcpy(new_iccp_name, name, length);
- new_iccp_profile = png_voidcast(png_bytep,
- png_malloc_warn(png_ptr, proflen));
-
- if (new_iccp_profile == NULL)
- {
- png_free(png_ptr, new_iccp_name);
- png_benign_error(png_ptr,
- "Insufficient memory to process iCCP profile");
-
- return;
- }
-
- memcpy(new_iccp_profile, profile, proflen);
-
- png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, 0);
-
- info_ptr->iccp_proflen = proflen;
- info_ptr->iccp_name = new_iccp_name;
- info_ptr->iccp_profile = new_iccp_profile;
- info_ptr->free_me |= PNG_FREE_ICCP;
- info_ptr->valid |= PNG_INFO_iCCP;
-}
-#endif
-
-#ifdef PNG_TEXT_SUPPORTED
-void PNGAPI
-png_set_text(png_const_structrp png_ptr, png_inforp info_ptr,
- png_const_textp text_ptr, int num_text)
-{
- int ret;
- ret = png_set_text_2(png_ptr, info_ptr, text_ptr, num_text);
-
- if (ret != 0)
- png_error(png_ptr, "Insufficient memory to store text");
-}
-
-int /* PRIVATE */
-png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
- png_const_textp text_ptr, int num_text)
-{
- int i;
-
- png_debug1(1, "in text storage function, chunk typeid = 0x%lx",
- png_ptr == NULL ? 0xabadca11UL : (unsigned long)png_ptr->chunk_name);
-
- if (png_ptr == NULL || info_ptr == NULL || num_text <= 0 || text_ptr == NULL)
- return 0;
-
- /* Make sure we have enough space in the "text" array in info_struct
- * to hold all of the incoming text_ptr objects. This compare can't overflow
- * because max_text >= num_text (anyway, subtract of two positive integers
- * can't overflow in any case.)
- */
- if (num_text > info_ptr->max_text - info_ptr->num_text)
- {
- int old_num_text = info_ptr->num_text;
- int max_text;
- png_textp new_text = NULL;
-
- /* Calculate an appropriate max_text, checking for overflow. */
- max_text = old_num_text;
- if (num_text <= INT_MAX - max_text)
- {
- max_text += num_text;
-
- /* Round up to a multiple of 8 */
- if (max_text < INT_MAX-8)
- max_text = (max_text + 8) & ~0x7;
-
- else
- max_text = INT_MAX;
-
- /* Now allocate a new array and copy the old members in; this does all
- * the overflow checks.
- */
- new_text = png_voidcast(png_textp,png_realloc_array(png_ptr,
- info_ptr->text, old_num_text, max_text-old_num_text,
- sizeof *new_text));
- }
-
- if (new_text == NULL)
- {
- png_chunk_report(png_ptr, "too many text chunks",
- PNG_CHUNK_WRITE_ERROR);
-
- return 1;
- }
-
- png_free(png_ptr, info_ptr->text);
-
- info_ptr->text = new_text;
- info_ptr->free_me |= PNG_FREE_TEXT;
- info_ptr->max_text = max_text;
- /* num_text is adjusted below as the entries are copied in */
-
- png_debug1(3, "allocated %d entries for info_ptr->text", max_text);
- }
-
- for (i = 0; i < num_text; i++)
- {
- size_t text_length, key_len;
- size_t lang_len, lang_key_len;
- png_textp textp = &(info_ptr->text[info_ptr->num_text]);
-
- if (text_ptr[i].key == NULL)
- continue;
-
- if (text_ptr[i].compression < PNG_TEXT_COMPRESSION_NONE ||
- text_ptr[i].compression >= PNG_TEXT_COMPRESSION_LAST)
- {
- png_chunk_report(png_ptr, "text compression mode is out of range",
- PNG_CHUNK_WRITE_ERROR);
- continue;
- }
-
- key_len = strlen(text_ptr[i].key);
-
- if (text_ptr[i].compression <= 0)
- {
- lang_len = 0;
- lang_key_len = 0;
- }
-
- else
-# ifdef PNG_iTXt_SUPPORTED
- {
- /* Set iTXt data */
-
- if (text_ptr[i].lang != NULL)
- lang_len = strlen(text_ptr[i].lang);
-
- else
- lang_len = 0;
-
- if (text_ptr[i].lang_key != NULL)
- lang_key_len = strlen(text_ptr[i].lang_key);
-
- else
- lang_key_len = 0;
- }
-# else /* iTXt */
- {
- png_chunk_report(png_ptr, "iTXt chunk not supported",
- PNG_CHUNK_WRITE_ERROR);
- continue;
- }
-# endif
-
- if (text_ptr[i].text == NULL || text_ptr[i].text[0] == '\0')
- {
- text_length = 0;
-# ifdef PNG_iTXt_SUPPORTED
- if (text_ptr[i].compression > 0)
- textp->compression = PNG_ITXT_COMPRESSION_NONE;
-
- else
-# endif
- textp->compression = PNG_TEXT_COMPRESSION_NONE;
- }
-
- else
- {
- text_length = strlen(text_ptr[i].text);
- textp->compression = text_ptr[i].compression;
- }
-
- textp->key = png_voidcast(png_charp,png_malloc_base(png_ptr,
- key_len + text_length + lang_len + lang_key_len + 4));
-
- if (textp->key == NULL)
- {
- png_chunk_report(png_ptr, "text chunk: out of memory",
- PNG_CHUNK_WRITE_ERROR);
-
- return 1;
- }
-
- png_debug2(2, "Allocated %lu bytes at %p in png_set_text",
- (unsigned long)(png_uint_32)
- (key_len + lang_len + lang_key_len + text_length + 4),
- textp->key);
-
- memcpy(textp->key, text_ptr[i].key, key_len);
- *(textp->key + key_len) = '\0';
-
- if (text_ptr[i].compression > 0)
- {
- textp->lang = textp->key + key_len + 1;
- memcpy(textp->lang, text_ptr[i].lang, lang_len);
- *(textp->lang + lang_len) = '\0';
- textp->lang_key = textp->lang + lang_len + 1;
- memcpy(textp->lang_key, text_ptr[i].lang_key, lang_key_len);
- *(textp->lang_key + lang_key_len) = '\0';
- textp->text = textp->lang_key + lang_key_len + 1;
- }
-
- else
- {
- textp->lang=NULL;
- textp->lang_key=NULL;
- textp->text = textp->key + key_len + 1;
- }
-
- if (text_length != 0)
- memcpy(textp->text, text_ptr[i].text, text_length);
-
- *(textp->text + text_length) = '\0';
-
-# ifdef PNG_iTXt_SUPPORTED
- if (textp->compression > 0)
- {
- textp->text_length = 0;
- textp->itxt_length = text_length;
- }
-
- else
-# endif
- {
- textp->text_length = text_length;
- textp->itxt_length = 0;
- }
-
- info_ptr->num_text++;
- png_debug1(3, "transferred text chunk %d", info_ptr->num_text);
- }
-
- return 0;
-}
-#endif
-
-#ifdef PNG_tIME_SUPPORTED
-void PNGAPI
-png_set_tIME(png_const_structrp png_ptr, png_inforp info_ptr,
- png_const_timep mod_time)
-{
- png_debug1(1, "in %s storage function", "tIME");
-
- if (png_ptr == NULL || info_ptr == NULL || mod_time == NULL ||
- (png_ptr->mode & PNG_WROTE_tIME) != 0)
- return;
-
- if (mod_time->month == 0 || mod_time->month > 12 ||
- mod_time->day == 0 || mod_time->day > 31 ||
- mod_time->hour > 23 || mod_time->minute > 59 ||
- mod_time->second > 60)
- {
- png_warning(png_ptr, "Ignoring invalid time value");
-
- return;
- }
-
- info_ptr->mod_time = *mod_time;
- info_ptr->valid |= PNG_INFO_tIME;
-}
-#endif
-
-#ifdef PNG_tRNS_SUPPORTED
-void PNGAPI
-png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr,
- png_const_bytep trans_alpha, int num_trans, png_const_color_16p trans_color)
-{
- png_debug1(1, "in %s storage function", "tRNS");
-
- if (png_ptr == NULL || info_ptr == NULL)
-
- return;
-
- if (trans_alpha != NULL)
- {
- /* It may not actually be necessary to set png_ptr->trans_alpha here;
- * we do it for backward compatibility with the way the png_handle_tRNS
- * function used to do the allocation.
- *
- * 1.6.0: The above statement is incorrect; png_handle_tRNS effectively
- * relies on png_set_tRNS storing the information in png_struct
- * (otherwise it won't be there for the code in pngrtran.c).
- */
-
- png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0);
-
- if (num_trans > 0 && num_trans <= PNG_MAX_PALETTE_LENGTH)
- {
- /* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */
- info_ptr->trans_alpha = png_voidcast(png_bytep,
- png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH));
- memcpy(info_ptr->trans_alpha, trans_alpha, (size_t)num_trans);
-
- info_ptr->free_me |= PNG_FREE_TRNS;
- info_ptr->valid |= PNG_INFO_tRNS;
- }
- png_ptr->trans_alpha = info_ptr->trans_alpha;
- }
-
- if (trans_color != NULL)
- {
-#ifdef PNG_WARNINGS_SUPPORTED
- if (info_ptr->bit_depth < 16)
- {
- int sample_max = (1 << info_ptr->bit_depth) - 1;
-
- if ((info_ptr->color_type == PNG_COLOR_TYPE_GRAY &&
- trans_color->gray > sample_max) ||
- (info_ptr->color_type == PNG_COLOR_TYPE_RGB &&
- (trans_color->red > sample_max ||
- trans_color->green > sample_max ||
- trans_color->blue > sample_max)))
- png_warning(png_ptr,
- "tRNS chunk has out-of-range samples for bit_depth");
- }
-#endif
-
- info_ptr->trans_color = *trans_color;
-
- if (num_trans == 0)
- num_trans = 1;
- }
-
- info_ptr->num_trans = (png_uint_16)num_trans;
-
- if (num_trans != 0)
- {
- info_ptr->free_me |= PNG_FREE_TRNS;
- info_ptr->valid |= PNG_INFO_tRNS;
- }
-}
-#endif
-
-#ifdef PNG_sPLT_SUPPORTED
-void PNGAPI
-png_set_sPLT(png_const_structrp png_ptr,
- png_inforp info_ptr, png_const_sPLT_tp entries, int nentries)
-/*
- * entries - array of png_sPLT_t structures
- * to be added to the list of palettes
- * in the info structure.
- *
- * nentries - number of palette structures to be
- * added.
- */
-{
- png_sPLT_tp np;
-
- png_debug1(1, "in %s storage function", "sPLT");
-
- if (png_ptr == NULL || info_ptr == NULL || nentries <= 0 || entries == NULL)
- return;
-
- /* Use the internal realloc function, which checks for all the possible
- * overflows. Notice that the parameters are (int) and (size_t)
- */
- np = png_voidcast(png_sPLT_tp,png_realloc_array(png_ptr,
- info_ptr->splt_palettes, info_ptr->splt_palettes_num, nentries,
- sizeof *np));
-
- if (np == NULL)
- {
- /* Out of memory or too many chunks */
- png_chunk_report(png_ptr, "too many sPLT chunks", PNG_CHUNK_WRITE_ERROR);
- return;
- }
-
- png_free(png_ptr, info_ptr->splt_palettes);
-
- info_ptr->splt_palettes = np;
- info_ptr->free_me |= PNG_FREE_SPLT;
-
- np += info_ptr->splt_palettes_num;
-
- do
- {
- size_t length;
-
- /* Skip invalid input entries */
- if (entries->name == NULL || entries->entries == NULL)
- {
- /* png_handle_sPLT doesn't do this, so this is an app error */
- png_app_error(png_ptr, "png_set_sPLT: invalid sPLT");
- /* Just skip the invalid entry */
- continue;
- }
-
- np->depth = entries->depth;
-
- /* In the event of out-of-memory just return - there's no point keeping
- * on trying to add sPLT chunks.
- */
- length = strlen(entries->name) + 1;
- np->name = png_voidcast(png_charp, png_malloc_base(png_ptr, length));
-
- if (np->name == NULL)
- break;
-
- memcpy(np->name, entries->name, length);
-
- /* IMPORTANT: we have memory now that won't get freed if something else
- * goes wrong; this code must free it. png_malloc_array produces no
- * warnings; use a png_chunk_report (below) if there is an error.
- */
- np->entries = png_voidcast(png_sPLT_entryp, png_malloc_array(png_ptr,
- entries->nentries, sizeof (png_sPLT_entry)));
-
- if (np->entries == NULL)
- {
- png_free(png_ptr, np->name);
- np->name = NULL;
- break;
- }
-
- np->nentries = entries->nentries;
- /* This multiply can't overflow because png_malloc_array has already
- * checked it when doing the allocation.
- */
- memcpy(np->entries, entries->entries,
- (unsigned int)entries->nentries * sizeof (png_sPLT_entry));
-
- /* Note that 'continue' skips the advance of the out pointer and out
- * count, so an invalid entry is not added.
- */
- info_ptr->valid |= PNG_INFO_sPLT;
- ++(info_ptr->splt_palettes_num);
- ++np;
- ++entries;
- }
- while (--nentries);
-
- if (nentries > 0)
- png_chunk_report(png_ptr, "sPLT out of memory", PNG_CHUNK_WRITE_ERROR);
-}
-#endif /* sPLT */
-
-#ifdef PNG_APNG_SUPPORTED
-png_uint_32 PNGAPI
-png_set_acTL(png_structp png_ptr, png_infop info_ptr,
- png_uint_32 num_frames, png_uint_32 num_plays)
-{
- png_debug1(1, "in %s storage function", "acTL");
-
- if (png_ptr == NULL || info_ptr == NULL)
- {
- png_warning(png_ptr,
- "Call to png_set_acTL() with NULL png_ptr "
- "or info_ptr ignored");
- return (0);
- }
- if (num_frames == 0)
- {
- png_warning(png_ptr,
- "Ignoring attempt to set acTL with num_frames zero");
- return (0);
- }
- if (num_frames > PNG_UINT_31_MAX)
- {
- png_warning(png_ptr,
- "Ignoring attempt to set acTL with num_frames > 2^31-1");
- return (0);
- }
- if (num_plays > PNG_UINT_31_MAX)
- {
- png_warning(png_ptr,
- "Ignoring attempt to set acTL with num_plays > 2^31-1");
- return (0);
- }
-
- info_ptr->num_frames = num_frames;
- info_ptr->num_plays = num_plays;
-
- info_ptr->valid |= PNG_INFO_acTL;
-
- return (1);
-}
-
-/* delay_num and delay_den can hold any 16-bit values including zero */
-png_uint_32 PNGAPI
-png_set_next_frame_fcTL(png_structp png_ptr, png_infop info_ptr,
- png_uint_32 width, png_uint_32 height,
- png_uint_32 x_offset, png_uint_32 y_offset,
- png_uint_16 delay_num, png_uint_16 delay_den,
- png_byte dispose_op, png_byte blend_op)
-{
- png_debug1(1, "in %s storage function", "fcTL");
-
- if (png_ptr == NULL || info_ptr == NULL)
- {
- png_warning(png_ptr,
- "Call to png_set_fcTL() with NULL png_ptr or info_ptr "
- "ignored");
- return (0);
- }
-
- png_ensure_fcTL_is_valid(png_ptr, width, height, x_offset, y_offset,
- delay_num, delay_den, dispose_op, blend_op);
-
- if (blend_op == PNG_BLEND_OP_OVER)
- {
- if ((png_ptr->color_type & PNG_COLOR_MASK_ALPHA) == 0 &&
- png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS) == 0)
- {
- png_warning(png_ptr, "PNG_BLEND_OP_OVER is meaningless "
- "and wasteful for opaque images, ignored");
- blend_op = PNG_BLEND_OP_SOURCE;
- }
- }
-
- info_ptr->next_frame_width = width;
- info_ptr->next_frame_height = height;
- info_ptr->next_frame_x_offset = x_offset;
- info_ptr->next_frame_y_offset = y_offset;
- info_ptr->next_frame_delay_num = delay_num;
- info_ptr->next_frame_delay_den = delay_den;
- info_ptr->next_frame_dispose_op = dispose_op;
- info_ptr->next_frame_blend_op = blend_op;
-
- info_ptr->valid |= PNG_INFO_fcTL;
-
- return (1);
-}
-
-void /* PRIVATE */
-png_ensure_fcTL_is_valid(png_structp png_ptr,
- png_uint_32 width, png_uint_32 height,
- png_uint_32 x_offset, png_uint_32 y_offset,
- png_uint_16 delay_num, png_uint_16 delay_den,
- png_byte dispose_op, png_byte blend_op)
-{
- if (width == 0 || width > PNG_UINT_31_MAX)
- png_error(png_ptr, "invalid width in fcTL (0 or > 2^31-1)");
- if (height == 0 || height > PNG_UINT_31_MAX)
- png_error(png_ptr, "invalid height in fcTL (0 or > 2^31-1)");
- if (x_offset > PNG_UINT_31_MAX)
- png_error(png_ptr, "invalid x_offset in fcTL (> 2^31-1)");
- if (y_offset > PNG_UINT_31_MAX)
- png_error(png_ptr, "invalid y_offset in fcTL (> 2^31-1)");
- if (width + x_offset > png_ptr->first_frame_width ||
- height + y_offset > png_ptr->first_frame_height)
- png_error(png_ptr, "dimensions of a frame are greater than "
- "the ones in IHDR");
-
- if (dispose_op != PNG_DISPOSE_OP_NONE &&
- dispose_op != PNG_DISPOSE_OP_BACKGROUND &&
- dispose_op != PNG_DISPOSE_OP_PREVIOUS)
- png_error(png_ptr, "invalid dispose_op in fcTL");
-
- if (blend_op != PNG_BLEND_OP_SOURCE &&
- blend_op != PNG_BLEND_OP_OVER)
- png_error(png_ptr, "invalid blend_op in fcTL");
-
- PNG_UNUSED(delay_num)
- PNG_UNUSED(delay_den)
-}
-
-png_uint_32 PNGAPI
-png_set_first_frame_is_hidden(png_structp png_ptr, png_infop info_ptr,
- png_byte is_hidden)
-{
- png_debug(1, "in png_first_frame_is_hidden()");
-
- if (png_ptr == NULL)
- return 0;
-
- if (is_hidden != 0)
- png_ptr->apng_flags |= PNG_FIRST_FRAME_HIDDEN;
- else
- png_ptr->apng_flags &= ~PNG_FIRST_FRAME_HIDDEN;
-
- PNG_UNUSED(info_ptr)
-
- return 1;
-}
-#endif /* APNG */
-
-#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
-static png_byte
-check_location(png_const_structrp png_ptr, int location)
-{
- location &= (PNG_HAVE_IHDR|PNG_HAVE_PLTE|PNG_AFTER_IDAT);
-
- /* New in 1.6.0; copy the location and check it. This is an API
- * change; previously the app had to use the
- * png_set_unknown_chunk_location API below for each chunk.
- */
- if (location == 0 && (png_ptr->mode & PNG_IS_READ_STRUCT) == 0)
- {
- /* Write struct, so unknown chunks come from the app */
- png_app_warning(png_ptr,
- "png_set_unknown_chunks now expects a valid location");
- /* Use the old behavior */
- location = (png_byte)(png_ptr->mode &
- (PNG_HAVE_IHDR|PNG_HAVE_PLTE|PNG_AFTER_IDAT));
- }
-
- /* This need not be an internal error - if the app calls
- * png_set_unknown_chunks on a read pointer it must get the location right.
- */
- if (location == 0)
- png_error(png_ptr, "invalid location in png_set_unknown_chunks");
-
- /* Now reduce the location to the top-most set bit by removing each least
- * significant bit in turn.
- */
- while (location != (location & -location))
- location &= ~(location & -location);
-
- /* The cast is safe because 'location' is a bit mask and only the low four
- * bits are significant.
- */
- return (png_byte)location;
-}
-
-void PNGAPI
-png_set_unknown_chunks(png_const_structrp png_ptr,
- png_inforp info_ptr, png_const_unknown_chunkp unknowns, int num_unknowns)
-{
- png_unknown_chunkp np;
-
- if (png_ptr == NULL || info_ptr == NULL || num_unknowns <= 0 ||
- unknowns == NULL)
- return;
-
- /* Check for the failure cases where support has been disabled at compile
- * time. This code is hardly ever compiled - it's here because
- * STORE_UNKNOWN_CHUNKS is set by both read and write code (compiling in this
- * code) but may be meaningless if the read or write handling of unknown
- * chunks is not compiled in.
- */
-# if !defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) && \
- defined(PNG_READ_SUPPORTED)
- if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
- {
- png_app_error(png_ptr, "no unknown chunk support on read");
-
- return;
- }
-# endif
-# if !defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) && \
- defined(PNG_WRITE_SUPPORTED)
- if ((png_ptr->mode & PNG_IS_READ_STRUCT) == 0)
- {
- png_app_error(png_ptr, "no unknown chunk support on write");
-
- return;
- }
-# endif
-
- /* Prior to 1.6.0 this code used png_malloc_warn; however, this meant that
- * unknown critical chunks could be lost with just a warning resulting in
- * undefined behavior. Now png_chunk_report is used to provide behavior
- * appropriate to read or write.
- */
- np = png_voidcast(png_unknown_chunkp, png_realloc_array(png_ptr,
- info_ptr->unknown_chunks, info_ptr->unknown_chunks_num, num_unknowns,
- sizeof *np));
-
- if (np == NULL)
- {
- png_chunk_report(png_ptr, "too many unknown chunks",
- PNG_CHUNK_WRITE_ERROR);
- return;
- }
-
- png_free(png_ptr, info_ptr->unknown_chunks);
-
- info_ptr->unknown_chunks = np; /* safe because it is initialized */
- info_ptr->free_me |= PNG_FREE_UNKN;
-
- np += info_ptr->unknown_chunks_num;
-
- /* Increment unknown_chunks_num each time round the loop to protect the
- * just-allocated chunk data.
- */
- for (; num_unknowns > 0; --num_unknowns, ++unknowns)
- {
- memcpy(np->name, unknowns->name, (sizeof np->name));
- np->name[(sizeof np->name)-1] = '\0';
- np->location = check_location(png_ptr, unknowns->location);
-
- if (unknowns->size == 0)
- {
- np->data = NULL;
- np->size = 0;
- }
-
- else
- {
- np->data = png_voidcast(png_bytep,
- png_malloc_base(png_ptr, unknowns->size));
-
- if (np->data == NULL)
- {
- png_chunk_report(png_ptr, "unknown chunk: out of memory",
- PNG_CHUNK_WRITE_ERROR);
- /* But just skip storing the unknown chunk */
- continue;
- }
-
- memcpy(np->data, unknowns->data, unknowns->size);
- np->size = unknowns->size;
- }
-
- /* These increments are skipped on out-of-memory for the data - the
- * unknown chunk entry gets overwritten if the png_chunk_report returns.
- * This is correct in the read case (the chunk is just dropped.)
- */
- ++np;
- ++(info_ptr->unknown_chunks_num);
- }
-}
-
-void PNGAPI
-png_set_unknown_chunk_location(png_const_structrp png_ptr, png_inforp info_ptr,
- int chunk, int location)
-{
- /* This API is pretty pointless in 1.6.0 because the location can be set
- * before the call to png_set_unknown_chunks.
- *
- * TODO: add a png_app_warning in 1.7
- */
- if (png_ptr != NULL && info_ptr != NULL && chunk >= 0 &&
- chunk < info_ptr->unknown_chunks_num)
- {
- if ((location & (PNG_HAVE_IHDR|PNG_HAVE_PLTE|PNG_AFTER_IDAT)) == 0)
- {
- png_app_error(png_ptr, "invalid unknown chunk location");
- /* Fake out the pre 1.6.0 behavior: */
- if (((unsigned int)location & PNG_HAVE_IDAT) != 0) /* undocumented! */
- location = PNG_AFTER_IDAT;
-
- else
- location = PNG_HAVE_IHDR; /* also undocumented */
- }
-
- info_ptr->unknown_chunks[chunk].location =
- check_location(png_ptr, location);
- }
-}
-#endif /* STORE_UNKNOWN_CHUNKS */
-
-#ifdef PNG_MNG_FEATURES_SUPPORTED
-png_uint_32 PNGAPI
-png_permit_mng_features(png_structrp png_ptr, png_uint_32 mng_features)
-{
- png_debug(1, "in png_permit_mng_features");
-
- if (png_ptr == NULL)
- return 0;
-
- png_ptr->mng_features_permitted = mng_features & PNG_ALL_MNG_FEATURES;
-
- return png_ptr->mng_features_permitted;
-}
-#endif
-
-#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
-static unsigned int
-add_one_chunk(png_bytep list, unsigned int count, png_const_bytep add, int keep)
-{
- unsigned int i;
-
- /* Utility function: update the 'keep' state of a chunk if it is already in
- * the list, otherwise add it to the list.
- */
- for (i=0; i<count; ++i, list += 5)
- {
- if (memcmp(list, add, 4) == 0)
- {
- list[4] = (png_byte)keep;
-
- return count;
- }
- }
-
- if (keep != PNG_HANDLE_CHUNK_AS_DEFAULT)
- {
- ++count;
- memcpy(list, add, 4);
- list[4] = (png_byte)keep;
- }
-
- return count;
-}
-
-void PNGAPI
-png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
- png_const_bytep chunk_list, int num_chunks_in)
-{
- png_bytep new_list;
- unsigned int num_chunks, old_num_chunks;
-
- if (png_ptr == NULL)
- return;
-
- if (keep < 0 || keep >= PNG_HANDLE_CHUNK_LAST)
- {
- png_app_error(png_ptr, "png_set_keep_unknown_chunks: invalid keep");
-
- return;
- }
-
- if (num_chunks_in <= 0)
- {
- png_ptr->unknown_default = keep;
-
- /* '0' means just set the flags, so stop here */
- if (num_chunks_in == 0)
- return;
- }
-
- if (num_chunks_in < 0)
- {
- /* Ignore all unknown chunks and all chunks recognized by
- * libpng except for IHDR, PLTE, tRNS, IDAT, and IEND
- */
- static const png_byte chunks_to_ignore[] = {
- 98, 75, 71, 68, '\0', /* bKGD */
- 99, 72, 82, 77, '\0', /* cHRM */
- 99, 73, 67, 80, '\0', /* cICP */
- 99, 76, 76, 73, '\0', /* cLLI */
- 101, 88, 73, 102, '\0', /* eXIf */
- 103, 65, 77, 65, '\0', /* gAMA */
- 104, 73, 83, 84, '\0', /* hIST */
- 105, 67, 67, 80, '\0', /* iCCP */
- 105, 84, 88, 116, '\0', /* iTXt */
- 109, 68, 67, 86, '\0', /* mDCV */
- 111, 70, 70, 115, '\0', /* oFFs */
- 112, 67, 65, 76, '\0', /* pCAL */
- 112, 72, 89, 115, '\0', /* pHYs */
- 115, 66, 73, 84, '\0', /* sBIT */
- 115, 67, 65, 76, '\0', /* sCAL */
- 115, 80, 76, 84, '\0', /* sPLT */
- 115, 84, 69, 82, '\0', /* sTER */
- 115, 82, 71, 66, '\0', /* sRGB */
- 116, 69, 88, 116, '\0', /* tEXt */
- 116, 73, 77, 69, '\0', /* tIME */
- 122, 84, 88, 116, '\0' /* zTXt */
- };
-
- chunk_list = chunks_to_ignore;
- num_chunks = (unsigned int)/*SAFE*/(sizeof chunks_to_ignore)/5U;
- }
-
- else /* num_chunks_in > 0 */
- {
- if (chunk_list == NULL)
- {
- /* Prior to 1.6.0 this was silently ignored, now it is an app_error
- * which can be switched off.
- */
- png_app_error(png_ptr, "png_set_keep_unknown_chunks: no chunk list");
-
- return;
- }
-
- num_chunks = (unsigned int)num_chunks_in;
- }
-
- old_num_chunks = png_ptr->num_chunk_list;
- if (png_ptr->chunk_list == NULL)
- old_num_chunks = 0;
-
- /* Since num_chunks is always restricted to UINT_MAX/5 this can't overflow.
- */
- if (num_chunks + old_num_chunks > UINT_MAX/5)
- {
- png_app_error(png_ptr, "png_set_keep_unknown_chunks: too many chunks");
-
- return;
- }
-
- /* If these chunks are being reset to the default then no more memory is
- * required because add_one_chunk above doesn't extend the list if the 'keep'
- * parameter is the default.
- */
- if (keep != 0)
- {
- new_list = png_voidcast(png_bytep, png_malloc(png_ptr,
- 5 * (num_chunks + old_num_chunks)));
-
- if (old_num_chunks > 0)
- memcpy(new_list, png_ptr->chunk_list, 5*old_num_chunks);
- }
-
- else if (old_num_chunks > 0)
- new_list = png_ptr->chunk_list;
-
- else
- new_list = NULL;
-
- /* Add the new chunks together with each one's handling code. If the chunk
- * already exists the code is updated, otherwise the chunk is added to the
- * end. (In libpng 1.6.0 order no longer matters because this code enforces
- * the earlier convention that the last setting is the one that is used.)
- */
- if (new_list != NULL)
- {
- png_const_bytep inlist;
- png_bytep outlist;
- unsigned int i;
-
- for (i=0; i<num_chunks; ++i)
- {
- old_num_chunks = add_one_chunk(new_list, old_num_chunks,
- chunk_list+5*i, keep);
- }
-
- /* Now remove any spurious 'default' entries. */
- num_chunks = 0;
- for (i=0, inlist=outlist=new_list; i<old_num_chunks; ++i, inlist += 5)
- {
- if (inlist[4])
- {
- if (outlist != inlist)
- memcpy(outlist, inlist, 5);
- outlist += 5;
- ++num_chunks;
- }
- }
-
- /* This means the application has removed all the specialized handling. */
- if (num_chunks == 0)
- {
- if (png_ptr->chunk_list != new_list)
- png_free(png_ptr, new_list);
-
- new_list = NULL;
- }
- }
-
- else
- num_chunks = 0;
-
- png_ptr->num_chunk_list = num_chunks;
-
- if (png_ptr->chunk_list != new_list)
- {
- if (png_ptr->chunk_list != NULL)
- png_free(png_ptr, png_ptr->chunk_list);
-
- png_ptr->chunk_list = new_list;
- }
-}
-#endif
-
-#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
-void PNGAPI
-png_set_read_user_chunk_fn(png_structrp png_ptr, png_voidp user_chunk_ptr,
- png_user_chunk_ptr read_user_chunk_fn)
-{
- png_debug(1, "in png_set_read_user_chunk_fn");
-
- if (png_ptr == NULL)
- return;
-
- png_ptr->read_user_chunk_fn = read_user_chunk_fn;
- png_ptr->user_chunk_ptr = user_chunk_ptr;
-}
-#endif
-
-#ifdef PNG_INFO_IMAGE_SUPPORTED
-void PNGAPI
-png_set_rows(png_const_structrp png_ptr, png_inforp info_ptr,
- png_bytepp row_pointers)
-{
- png_debug(1, "in png_set_rows");
-
- if (png_ptr == NULL || info_ptr == NULL)
- return;
-
- if (info_ptr->row_pointers != NULL &&
- (info_ptr->row_pointers != row_pointers))
- png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0);
-
- info_ptr->row_pointers = row_pointers;
-
- if (row_pointers != NULL)
- info_ptr->valid |= PNG_INFO_IDAT;
-}
-#endif
-
-void PNGAPI
-png_set_compression_buffer_size(png_structrp png_ptr, size_t size)
-{
- png_debug(1, "in png_set_compression_buffer_size");
-
- if (png_ptr == NULL)
- return;
-
- if (size == 0 || size > PNG_UINT_31_MAX)
- png_error(png_ptr, "invalid compression buffer size");
-
-# ifdef PNG_SEQUENTIAL_READ_SUPPORTED
- if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
- {
- png_ptr->IDAT_read_size = (png_uint_32)size; /* checked above */
- return;
- }
-# endif
-
-# ifdef PNG_WRITE_SUPPORTED
- if ((png_ptr->mode & PNG_IS_READ_STRUCT) == 0)
- {
- if (png_ptr->zowner != 0)
- {
- png_warning(png_ptr,
- "Compression buffer size cannot be changed because it is in use");
-
- return;
- }
-
-#ifndef __COVERITY__
- /* Some compilers complain that this is always false. However, it
- * can be true when integer overflow happens.
- */
- if (size > ZLIB_IO_MAX)
- {
- png_warning(png_ptr,
- "Compression buffer size limited to system maximum");
- size = ZLIB_IO_MAX; /* must fit */
- }
-#endif
-
- if (size < 6)
- {
- /* Deflate will potentially go into an infinite loop on a SYNC_FLUSH
- * if this is permitted.
- */
- png_warning(png_ptr,
- "Compression buffer size cannot be reduced below 6");
-
- return;
- }
-
- if (png_ptr->zbuffer_size != size)
- {
- png_free_buffer_list(png_ptr, &png_ptr->zbuffer_list);
- png_ptr->zbuffer_size = (uInt)size;
- }
- }
-# endif
-}
-
-void PNGAPI
-png_set_invalid(png_const_structrp png_ptr, png_inforp info_ptr, int mask)
-{
- if (png_ptr != NULL && info_ptr != NULL)
- info_ptr->valid &= (unsigned int)(~mask);
-}
-
-
-#ifdef PNG_SET_USER_LIMITS_SUPPORTED
-/* This function was added to libpng 1.2.6 */
-void PNGAPI
-png_set_user_limits(png_structrp png_ptr, png_uint_32 user_width_max,
- png_uint_32 user_height_max)
-{
- png_debug(1, "in png_set_user_limits");
-
- /* Images with dimensions larger than these limits will be
- * rejected by png_set_IHDR(). To accept any PNG datastream
- * regardless of dimensions, set both limits to 0x7fffffff.
- */
- if (png_ptr == NULL)
- return;
-
- png_ptr->user_width_max = user_width_max;
- png_ptr->user_height_max = user_height_max;
-}
-
-/* This function was added to libpng 1.4.0 */
-void PNGAPI
-png_set_chunk_cache_max(png_structrp png_ptr, png_uint_32 user_chunk_cache_max)
-{
- png_debug(1, "in png_set_chunk_cache_max");
-
- if (png_ptr != NULL)
- png_ptr->user_chunk_cache_max = user_chunk_cache_max;
-}
-
-/* This function was added to libpng 1.4.1 */
-void PNGAPI
-png_set_chunk_malloc_max(png_structrp png_ptr,
- png_alloc_size_t user_chunk_malloc_max)
-{
- png_debug(1, "in png_set_chunk_malloc_max");
-
- if (png_ptr != NULL)
- png_ptr->user_chunk_malloc_max = user_chunk_malloc_max;
-}
-#endif /* ?SET_USER_LIMITS */
-
-
-#ifdef PNG_BENIGN_ERRORS_SUPPORTED
-void PNGAPI
-png_set_benign_errors(png_structrp png_ptr, int allowed)
-{
- png_debug(1, "in png_set_benign_errors");
-
- /* If allowed is 1, png_benign_error() is treated as a warning.
- *
- * If allowed is 0, png_benign_error() is treated as an error (which
- * is the default behavior if png_set_benign_errors() is not called).
- */
-
- if (allowed != 0)
- png_ptr->flags |= PNG_FLAG_BENIGN_ERRORS_WARN |
- PNG_FLAG_APP_WARNINGS_WARN | PNG_FLAG_APP_ERRORS_WARN;
-
- else
- png_ptr->flags &= ~(PNG_FLAG_BENIGN_ERRORS_WARN |
- PNG_FLAG_APP_WARNINGS_WARN | PNG_FLAG_APP_ERRORS_WARN);
-}
-#endif /* BENIGN_ERRORS */
-
-#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
- /* Whether to report invalid palette index; added at libng-1.5.10.
- * It is possible for an indexed (color-type==3) PNG file to contain
- * pixels with invalid (out-of-range) indexes if the PLTE chunk has
- * fewer entries than the image's bit-depth would allow. We recover
- * from this gracefully by filling any incomplete palette with zeros
- * (opaque black). By default, when this occurs libpng will issue
- * a benign error. This API can be used to override that behavior.
- */
-void PNGAPI
-png_set_check_for_invalid_index(png_structrp png_ptr, int allowed)
-{
- png_debug(1, "in png_set_check_for_invalid_index");
-
- if (allowed > 0)
- png_ptr->num_palette_max = 0;
-
- else
- png_ptr->num_palette_max = -1;
-}
-#endif
-
-#if defined(PNG_TEXT_SUPPORTED) || defined(PNG_pCAL_SUPPORTED) || \
- defined(PNG_iCCP_SUPPORTED) || defined(PNG_sPLT_SUPPORTED)
-/* Check that the tEXt or zTXt keyword is valid per PNG 1.0 specification,
- * and if invalid, correct the keyword rather than discarding the entire
- * chunk. The PNG 1.0 specification requires keywords 1-79 characters in
- * length, forbids leading or trailing whitespace, multiple internal spaces,
- * and the non-break space (0x80) from ISO 8859-1. Returns keyword length.
- *
- * The 'new_key' buffer must be 80 characters in size (for the keyword plus a
- * trailing '\0'). If this routine returns 0 then there was no keyword, or a
- * valid one could not be generated, and the caller must png_error.
- */
-png_uint_32 /* PRIVATE */
-png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key)
-{
-#ifdef PNG_WARNINGS_SUPPORTED
- png_const_charp orig_key = key;
-#endif
- png_uint_32 key_len = 0;
- int bad_character = 0;
- int space = 1;
-
- png_debug(1, "in png_check_keyword");
-
- if (key == NULL)
- {
- *new_key = 0;
- return 0;
- }
-
- while (*key && key_len < 79)
- {
- png_byte ch = (png_byte)*key++;
-
- if ((ch > 32 && ch <= 126) || (ch >= 161 /*&& ch <= 255*/))
- {
- *new_key++ = ch; ++key_len; space = 0;
- }
-
- else if (space == 0)
- {
- /* A space or an invalid character when one wasn't seen immediately
- * before; output just a space.
- */
- *new_key++ = 32; ++key_len; space = 1;
-
- /* If the character was not a space then it is invalid. */
- if (ch != 32)
- bad_character = ch;
- }
-
- else if (bad_character == 0)
- bad_character = ch; /* just skip it, record the first error */
- }
-
- if (key_len > 0 && space != 0) /* trailing space */
- {
- --key_len; --new_key;
- if (bad_character == 0)
- bad_character = 32;
- }
-
- /* Terminate the keyword */
- *new_key = 0;
-
- if (key_len == 0)
- return 0;
-
-#ifdef PNG_WARNINGS_SUPPORTED
- /* Try to only output one warning per keyword: */
- if (*key != 0) /* keyword too long */
- png_warning(png_ptr, "keyword truncated");
-
- else if (bad_character != 0)
- {
- PNG_WARNING_PARAMETERS(p)
-
- png_warning_parameter(p, 1, orig_key);
- png_warning_parameter_signed(p, 2, PNG_NUMBER_FORMAT_02x, bad_character);
-
- png_formatted_warning(png_ptr, p, "keyword \"@1\": bad character '0x@2'");
- }
-#else /* !WARNINGS */
- PNG_UNUSED(png_ptr)
-#endif /* !WARNINGS */
-
- return key_len;
-}
-#endif /* TEXT || pCAL || iCCP || sPLT */
-#endif /* READ || WRITE */
diff --git a/contrib/libs/libpng/pngstruct.h b/contrib/libs/libpng/pngstruct.h
deleted file mode 100644
index 40dee6d814..0000000000
--- a/contrib/libs/libpng/pngstruct.h
+++ /dev/null
@@ -1,499 +0,0 @@
-/* pngstruct.h - header file for PNG reference library
- *
- * Copyright (c) 2018-2022 Cosmin Truta
- * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
- * Copyright (c) 1996-1997 Andreas Dilger
- * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
- *
- * This code is released under the libpng license.
- * For conditions of distribution and use, see the disclaimer
- * and license in png.h
- */
-
-/* The structure that holds the information to read and write PNG files.
- * The only people who need to care about what is inside of this are the
- * people who will be modifying the library for their own special needs.
- * It should NOT be accessed directly by an application.
- */
-
-#ifndef PNGSTRUCT_H
-#define PNGSTRUCT_H
-/* zlib.h defines the structure z_stream, an instance of which is included
- * in this structure and is required for decompressing the LZ compressed
- * data in PNG files.
- */
-#ifndef ZLIB_CONST
- /* We must ensure that zlib uses 'const' in declarations. */
-# define ZLIB_CONST
-#endif
-#include "zlib.h"
-#ifdef const
- /* zlib.h sometimes #defines const to nothing, undo this. */
-# undef const
-#endif
-
-/* zlib.h has mediocre z_const use before 1.2.6, this stuff is for compatibility
- * with older builds.
- */
-#if ZLIB_VERNUM < 0x1260
-# define PNGZ_MSG_CAST(s) png_constcast(char*,s)
-# define PNGZ_INPUT_CAST(b) png_constcast(png_bytep,b)
-#else
-# define PNGZ_MSG_CAST(s) (s)
-# define PNGZ_INPUT_CAST(b) (b)
-#endif
-
-/* zlib.h declares a magic type 'uInt' that limits the amount of data that zlib
- * can handle at once. This type need be no larger than 16 bits (so maximum of
- * 65535), this define allows us to discover how big it is, but limited by the
- * maximum for size_t. The value can be overridden in a library build
- * (pngusr.h, or set it in CPPFLAGS) and it works to set it to a considerably
- * lower value (e.g. 255 works). A lower value may help memory usage (slightly)
- * and may even improve performance on some systems (and degrade it on others.)
- */
-#ifndef ZLIB_IO_MAX
-# define ZLIB_IO_MAX ((uInt)-1)
-#endif
-
-#ifdef PNG_WRITE_SUPPORTED
-/* The type of a compression buffer list used by the write code. */
-typedef struct png_compression_buffer
-{
- struct png_compression_buffer *next;
- png_byte output[1]; /* actually zbuf_size */
-} png_compression_buffer, *png_compression_bufferp;
-
-#define PNG_COMPRESSION_BUFFER_SIZE(pp)\
- (offsetof(png_compression_buffer, output) + (pp)->zbuffer_size)
-#endif
-
-/* Colorspace support; structures used in png_struct, png_info and in internal
- * functions to hold and communicate information about the color space.
- *
- * PNG_COLORSPACE_SUPPORTED is only required if the application will perform
- * colorspace corrections, otherwise all the colorspace information can be
- * skipped and the size of libpng can be reduced (significantly) by compiling
- * out the colorspace support.
- */
-#ifdef PNG_COLORSPACE_SUPPORTED
-/* The chromaticities of the red, green and blue colorants and the chromaticity
- * of the corresponding white point (i.e. of rgb(1.0,1.0,1.0)).
- */
-typedef struct png_xy
-{
- png_fixed_point redx, redy;
- png_fixed_point greenx, greeny;
- png_fixed_point bluex, bluey;
- png_fixed_point whitex, whitey;
-} png_xy;
-
-/* The same data as above but encoded as CIE XYZ values. When this data comes
- * from chromaticities the sum of the Y values is assumed to be 1.0
- */
-typedef struct png_XYZ
-{
- png_fixed_point red_X, red_Y, red_Z;
- png_fixed_point green_X, green_Y, green_Z;
- png_fixed_point blue_X, blue_Y, blue_Z;
-} png_XYZ;
-#endif /* COLORSPACE */
-
-#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
-/* A colorspace is all the above plus, potentially, profile information;
- * however at present libpng does not use the profile internally so it is only
- * stored in the png_info struct (if iCCP is supported.) The rendering intent
- * is retained here and is checked.
- *
- * The file gamma encoding information is also stored here and gamma correction
- * is done by libpng, whereas color correction must currently be done by the
- * application.
- */
-typedef struct png_colorspace
-{
-#ifdef PNG_GAMMA_SUPPORTED
- png_fixed_point gamma; /* File gamma */
-#endif
-
-#ifdef PNG_COLORSPACE_SUPPORTED
- png_xy end_points_xy; /* End points as chromaticities */
- png_XYZ end_points_XYZ; /* End points as CIE XYZ colorant values */
- png_uint_16 rendering_intent; /* Rendering intent of a profile */
-#endif
-
- /* Flags are always defined to simplify the code. */
- png_uint_16 flags; /* As defined below */
-} png_colorspace, * PNG_RESTRICT png_colorspacerp;
-
-typedef const png_colorspace * PNG_RESTRICT png_const_colorspacerp;
-
-/* General flags for the 'flags' field */
-#define PNG_COLORSPACE_HAVE_GAMMA 0x0001
-#define PNG_COLORSPACE_HAVE_ENDPOINTS 0x0002
-#define PNG_COLORSPACE_HAVE_INTENT 0x0004
-#define PNG_COLORSPACE_FROM_gAMA 0x0008
-#define PNG_COLORSPACE_FROM_cHRM 0x0010
-#define PNG_COLORSPACE_FROM_sRGB 0x0020
-#define PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB 0x0040
-#define PNG_COLORSPACE_MATCHES_sRGB 0x0080 /* exact match on profile */
-#define PNG_COLORSPACE_INVALID 0x8000
-#define PNG_COLORSPACE_CANCEL(flags) (0xffff ^ (flags))
-#endif /* COLORSPACE || GAMMA */
-
-struct png_struct_def
-{
-#ifdef PNG_SETJMP_SUPPORTED
- jmp_buf jmp_buf_local; /* New name in 1.6.0 for jmp_buf in png_struct */
- png_longjmp_ptr longjmp_fn;/* setjmp non-local goto function. */
- jmp_buf *jmp_buf_ptr; /* passed to longjmp_fn */
- size_t jmp_buf_size; /* size of the above, if allocated */
-#endif
- png_error_ptr error_fn; /* function for printing errors and aborting */
-#ifdef PNG_WARNINGS_SUPPORTED
- png_error_ptr warning_fn; /* function for printing warnings */
-#endif
- png_voidp error_ptr; /* user supplied struct for error functions */
- png_rw_ptr write_data_fn; /* function for writing output data */
- png_rw_ptr read_data_fn; /* function for reading input data */
- png_voidp io_ptr; /* ptr to application struct for I/O functions */
-
-#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
- png_user_transform_ptr read_user_transform_fn; /* user read transform */
-#endif
-
-#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
- png_user_transform_ptr write_user_transform_fn; /* user write transform */
-#endif
-
-/* These were added in libpng-1.0.2 */
-#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
-#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
- defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
- png_voidp user_transform_ptr; /* user supplied struct for user transform */
- png_byte user_transform_depth; /* bit depth of user transformed pixels */
- png_byte user_transform_channels; /* channels in user transformed pixels */
-#endif
-#endif
-
- png_uint_32 mode; /* tells us where we are in the PNG file */
- png_uint_32 flags; /* flags indicating various things to libpng */
- png_uint_32 transformations; /* which transformations to perform */
-
- png_uint_32 zowner; /* ID (chunk type) of zstream owner, 0 if none */
- z_stream zstream; /* decompression structure */
-
-#ifdef PNG_WRITE_SUPPORTED
- png_compression_bufferp zbuffer_list; /* Created on demand during write */
- uInt zbuffer_size; /* size of the actual buffer */
-
- int zlib_level; /* holds zlib compression level */
- int zlib_method; /* holds zlib compression method */
- int zlib_window_bits; /* holds zlib compression window bits */
- int zlib_mem_level; /* holds zlib compression memory level */
- int zlib_strategy; /* holds zlib compression strategy */
-#endif
-/* Added at libpng 1.5.4 */
-#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
- int zlib_text_level; /* holds zlib compression level */
- int zlib_text_method; /* holds zlib compression method */
- int zlib_text_window_bits; /* holds zlib compression window bits */
- int zlib_text_mem_level; /* holds zlib compression memory level */
- int zlib_text_strategy; /* holds zlib compression strategy */
-#endif
-/* End of material added at libpng 1.5.4 */
-/* Added at libpng 1.6.0 */
-#ifdef PNG_WRITE_SUPPORTED
- int zlib_set_level; /* Actual values set into the zstream on write */
- int zlib_set_method;
- int zlib_set_window_bits;
- int zlib_set_mem_level;
- int zlib_set_strategy;
-#endif
-
- png_uint_32 width; /* width of image in pixels */
- png_uint_32 height; /* height of image in pixels */
- png_uint_32 num_rows; /* number of rows in current pass */
- png_uint_32 usr_width; /* width of row at start of write */
- size_t rowbytes; /* size of row in bytes */
- png_uint_32 iwidth; /* width of current interlaced row in pixels */
- png_uint_32 row_number; /* current row in interlace pass */
- png_uint_32 chunk_name; /* PNG_CHUNK() id of current chunk */
- png_bytep prev_row; /* buffer to save previous (unfiltered) row.
- * While reading this is a pointer into
- * big_prev_row; while writing it is separately
- * allocated if needed.
- */
- png_bytep row_buf; /* buffer to save current (unfiltered) row.
- * While reading, this is a pointer into
- * big_row_buf; while writing it is separately
- * allocated.
- */
-#ifdef PNG_WRITE_FILTER_SUPPORTED
- png_bytep try_row; /* buffer to save trial row when filtering */
- png_bytep tst_row; /* buffer to save best trial row when filtering */
-#endif
- size_t info_rowbytes; /* Added in 1.5.4: cache of updated row bytes */
-
- png_uint_32 idat_size; /* current IDAT size for read */
- png_uint_32 crc; /* current chunk CRC value */
- png_colorp palette; /* palette from the input file */
- png_uint_16 num_palette; /* number of color entries in palette */
-
-/* Added at libpng-1.5.10 */
-#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
- int num_palette_max; /* maximum palette index found in IDAT */
-#endif
-
- png_uint_16 num_trans; /* number of transparency values */
- png_byte compression; /* file compression type (always 0) */
- png_byte filter; /* file filter type (always 0) */
- png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
- png_byte pass; /* current interlace pass (0 - 6) */
- png_byte do_filter; /* row filter flags (see PNG_FILTER_ in png.h ) */
- png_byte color_type; /* color type of file */
- png_byte bit_depth; /* bit depth of file */
- png_byte usr_bit_depth; /* bit depth of users row: write only */
- png_byte pixel_depth; /* number of bits per pixel */
- png_byte channels; /* number of channels in file */
-#ifdef PNG_WRITE_SUPPORTED
- png_byte usr_channels; /* channels at start of write: write only */
-#endif
- png_byte sig_bytes; /* magic bytes read/written from start of file */
- png_byte maximum_pixel_depth;
- /* pixel depth used for the row buffers */
- png_byte transformed_pixel_depth;
- /* pixel depth after read/write transforms */
-#if ZLIB_VERNUM >= 0x1240
- png_byte zstream_start; /* at start of an input zlib stream */
-#endif /* Zlib >= 1.2.4 */
-#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
- png_uint_16 filler; /* filler bytes for pixel expansion */
-#endif
-
-#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
- defined(PNG_READ_ALPHA_MODE_SUPPORTED)
- png_byte background_gamma_type;
- png_fixed_point background_gamma;
- png_color_16 background; /* background color in screen gamma space */
-#ifdef PNG_READ_GAMMA_SUPPORTED
- png_color_16 background_1; /* background normalized to gamma 1.0 */
-#endif
-#endif /* bKGD */
-
-#ifdef PNG_WRITE_FLUSH_SUPPORTED
- png_flush_ptr output_flush_fn; /* Function for flushing output */
- png_uint_32 flush_dist; /* how many rows apart to flush, 0 - no flush */
- png_uint_32 flush_rows; /* number of rows written since last flush */
-#endif
-
-#ifdef PNG_READ_GAMMA_SUPPORTED
- int gamma_shift; /* number of "insignificant" bits in 16-bit gamma */
- png_fixed_point screen_gamma; /* screen gamma value (display_exponent) */
-
- png_bytep gamma_table; /* gamma table for 8-bit depth files */
- png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */
-#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
- defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \
- defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
- png_bytep gamma_from_1; /* converts from 1.0 to screen */
- png_bytep gamma_to_1; /* converts from file to 1.0 */
- png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */
- png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */
-#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */
-#endif
-
-#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED)
- png_color_8 sig_bit; /* significant bits in each available channel */
-#endif
-
-#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
- png_color_8 shift; /* shift for significant bit transformation */
-#endif
-
-#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \
- || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
- png_bytep trans_alpha; /* alpha values for paletted files */
- png_color_16 trans_color; /* transparent color for non-paletted files */
-#endif
-
- png_read_status_ptr read_row_fn; /* called after each row is decoded */
- png_write_status_ptr write_row_fn; /* called after each row is encoded */
-#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
- png_progressive_info_ptr info_fn; /* called after header data fully read */
- png_progressive_row_ptr row_fn; /* called after a prog. row is decoded */
- png_progressive_end_ptr end_fn; /* called after image is complete */
- png_bytep save_buffer_ptr; /* current location in save_buffer */
- png_bytep save_buffer; /* buffer for previously read data */
- png_bytep current_buffer_ptr; /* current location in current_buffer */
- png_bytep current_buffer; /* buffer for recently used data */
- png_uint_32 push_length; /* size of current input chunk */
- png_uint_32 skip_length; /* bytes to skip in input data */
- size_t save_buffer_size; /* amount of data now in save_buffer */
- size_t save_buffer_max; /* total size of save_buffer */
- size_t buffer_size; /* total amount of available input data */
- size_t current_buffer_size; /* amount of data now in current_buffer */
- int process_mode; /* what push library is currently doing */
- int cur_palette; /* current push library palette index */
-#endif /* PROGRESSIVE_READ */
-
-#ifdef PNG_READ_QUANTIZE_SUPPORTED
- png_bytep palette_lookup; /* lookup table for quantizing */
- png_bytep quantize_index; /* index translation for palette files */
-#endif
-
-/* Options */
-#ifdef PNG_SET_OPTION_SUPPORTED
- png_uint_32 options; /* On/off state (up to 16 options) */
-#endif
-
-#if PNG_LIBPNG_VER < 10700
-/* To do: remove this from libpng-1.7 */
-#ifdef PNG_TIME_RFC1123_SUPPORTED
- char time_buffer[29]; /* String to hold RFC 1123 time text */
-#endif
-#endif
-
-/* New members added in libpng-1.0.6 */
-
- png_uint_32 free_me; /* flags items libpng is responsible for freeing */
-
-#ifdef PNG_USER_CHUNKS_SUPPORTED
- png_voidp user_chunk_ptr;
-#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
- png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */
-#endif
-#endif
-
-#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
- int unknown_default; /* As PNG_HANDLE_* */
- unsigned int num_chunk_list; /* Number of entries in the list */
- png_bytep chunk_list; /* List of png_byte[5]; the textual chunk name
- * followed by a PNG_HANDLE_* byte */
-#endif
-
-/* New members added in libpng-1.0.3 */
-#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
- png_byte rgb_to_gray_status;
- /* Added in libpng 1.5.5 to record setting of coefficients: */
- png_byte rgb_to_gray_coefficients_set;
- /* These were changed from png_byte in libpng-1.0.6 */
- png_uint_16 rgb_to_gray_red_coeff;
- png_uint_16 rgb_to_gray_green_coeff;
- /* deleted in 1.5.5: rgb_to_gray_blue_coeff; */
-#endif
-
-/* New member added in libpng-1.6.36 */
-#if defined(PNG_READ_EXPAND_SUPPORTED) && \
- defined(PNG_ARM_NEON_IMPLEMENTATION)
- png_bytep riffled_palette; /* buffer for accelerated palette expansion */
-#endif
-
-/* New member added in libpng-1.0.4 (renamed in 1.0.9) */
-#if defined(PNG_MNG_FEATURES_SUPPORTED)
-/* Changed from png_byte to png_uint_32 at version 1.2.0 */
- png_uint_32 mng_features_permitted;
-#endif
-
-/* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */
-#ifdef PNG_MNG_FEATURES_SUPPORTED
- png_byte filter_type;
-#endif
-
-#ifdef PNG_APNG_SUPPORTED
- png_uint_32 apng_flags;
- png_uint_32 next_seq_num; /* next fcTL/fdAT chunk sequence number */
- png_uint_32 first_frame_width;
- png_uint_32 first_frame_height;
-
-#ifdef PNG_READ_APNG_SUPPORTED
- png_uint_32 num_frames_read; /* incremented after all image data of */
- /* a frame is read */
-#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
- png_progressive_frame_ptr frame_info_fn; /* frame info read callback */
- png_progressive_frame_ptr frame_end_fn; /* frame data read callback */
-#endif
-#endif
-
-#ifdef PNG_WRITE_APNG_SUPPORTED
- png_uint_32 num_frames_to_write;
- png_uint_32 num_frames_written;
-#endif
-#endif /* APNG */
-
-/* New members added in libpng-1.2.0 */
-
-/* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */
-#ifdef PNG_USER_MEM_SUPPORTED
- png_voidp mem_ptr; /* user supplied struct for mem functions */
- png_malloc_ptr malloc_fn; /* function for allocating memory */
- png_free_ptr free_fn; /* function for freeing memory */
-#endif
-
-/* New member added in libpng-1.0.13 and 1.2.0 */
- png_bytep big_row_buf; /* buffer to save current (unfiltered) row */
-
-#ifdef PNG_READ_QUANTIZE_SUPPORTED
-/* The following three members were added at version 1.0.14 and 1.2.4 */
- png_bytep quantize_sort; /* working sort array */
- png_bytep index_to_palette; /* where the original index currently is
- in the palette */
- png_bytep palette_to_index; /* which original index points to this
- palette color */
-#endif
-
-/* New members added in libpng-1.0.16 and 1.2.6 */
- png_byte compression_type;
-
-#ifdef PNG_USER_LIMITS_SUPPORTED
- png_uint_32 user_width_max;
- png_uint_32 user_height_max;
-
- /* Added in libpng-1.4.0: Total number of sPLT, text, and unknown
- * chunks that can be stored (0 means unlimited).
- */
- png_uint_32 user_chunk_cache_max;
-
- /* Total memory that a zTXt, sPLT, iTXt, iCCP, or unknown chunk
- * can occupy when decompressed. 0 means unlimited.
- */
- png_alloc_size_t user_chunk_malloc_max;
-#endif
-
-/* New member added in libpng-1.0.25 and 1.2.17 */
-#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
- /* Temporary storage for unknown chunk that the library doesn't recognize,
- * used while reading the chunk.
- */
- png_unknown_chunk unknown_chunk;
-#endif
-
-/* New member added in libpng-1.2.26 */
- size_t old_big_row_buf_size;
-
-#ifdef PNG_READ_SUPPORTED
-/* New member added in libpng-1.2.30 */
- png_bytep read_buffer; /* buffer for reading chunk data */
- png_alloc_size_t read_buffer_size; /* current size of the buffer */
-#endif
-#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
- uInt IDAT_read_size; /* limit on read buffer size for IDAT */
-#endif
-
-#ifdef PNG_IO_STATE_SUPPORTED
-/* New member added in libpng-1.4.0 */
- png_uint_32 io_state;
-#endif
-
-/* New member added in libpng-1.5.6 */
- png_bytep big_prev_row;
-
-/* New member added in libpng-1.5.7 */
- void (*read_filter[PNG_FILTER_VALUE_LAST-1])(png_row_infop row_info,
- png_bytep row, png_const_bytep prev_row);
-
-#ifdef PNG_READ_SUPPORTED
-#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
- png_colorspace colorspace;
-#endif
-#endif
-};
-#endif /* PNGSTRUCT_H */
diff --git a/contrib/libs/libpng/pngtrans.c b/contrib/libs/libpng/pngtrans.c
deleted file mode 100644
index 222b4987f9..0000000000
--- a/contrib/libs/libpng/pngtrans.c
+++ /dev/null
@@ -1,867 +0,0 @@
-/* pngtrans.c - transforms the data in a row (used by both readers and writers)
- *
- * Copyright (c) 2018-2024 Cosmin Truta
- * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
- * Copyright (c) 1996-1997 Andreas Dilger
- * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
- *
- * This code is released under the libpng license.
- * For conditions of distribution and use, see the disclaimer
- * and license in png.h
- */
-
-#include "pngpriv.h"
-
-#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
-
-#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
-/* Turn on BGR-to-RGB mapping */
-void PNGAPI
-png_set_bgr(png_structrp png_ptr)
-{
- png_debug(1, "in png_set_bgr");
-
- if (png_ptr == NULL)
- return;
-
- png_ptr->transformations |= PNG_BGR;
-}
-#endif
-
-#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
-/* Turn on 16-bit byte swapping */
-void PNGAPI
-png_set_swap(png_structrp png_ptr)
-{
- png_debug(1, "in png_set_swap");
-
- if (png_ptr == NULL)
- return;
-
- if (png_ptr->bit_depth == 16)
- png_ptr->transformations |= PNG_SWAP_BYTES;
-}
-#endif
-
-#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
-/* Turn on pixel packing */
-void PNGAPI
-png_set_packing(png_structrp png_ptr)
-{
- png_debug(1, "in png_set_packing");
-
- if (png_ptr == NULL)
- return;
-
- if (png_ptr->bit_depth < 8)
- {
- png_ptr->transformations |= PNG_PACK;
-# ifdef PNG_WRITE_SUPPORTED
- png_ptr->usr_bit_depth = 8;
-# endif
- }
-}
-#endif
-
-#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED)
-/* Turn on packed pixel swapping */
-void PNGAPI
-png_set_packswap(png_structrp png_ptr)
-{
- png_debug(1, "in png_set_packswap");
-
- if (png_ptr == NULL)
- return;
-
- if (png_ptr->bit_depth < 8)
- png_ptr->transformations |= PNG_PACKSWAP;
-}
-#endif
-
-#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
-void PNGAPI
-png_set_shift(png_structrp png_ptr, png_const_color_8p true_bits)
-{
- png_debug(1, "in png_set_shift");
-
- if (png_ptr == NULL)
- return;
-
- png_ptr->transformations |= PNG_SHIFT;
- png_ptr->shift = *true_bits;
-}
-#endif
-
-#if defined(PNG_READ_INTERLACING_SUPPORTED) || \
- defined(PNG_WRITE_INTERLACING_SUPPORTED)
-int PNGAPI
-png_set_interlace_handling(png_structrp png_ptr)
-{
- png_debug(1, "in png_set_interlace handling");
-
- if (png_ptr != 0 && png_ptr->interlaced != 0)
- {
- png_ptr->transformations |= PNG_INTERLACE;
- return 7;
- }
-
- return 1;
-}
-#endif
-
-#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
-/* Add a filler byte on read, or remove a filler or alpha byte on write.
- * The filler type has changed in v0.95 to allow future 2-byte fillers
- * for 48-bit input data, as well as to avoid problems with some compilers
- * that don't like bytes as parameters.
- */
-void PNGAPI
-png_set_filler(png_structrp png_ptr, png_uint_32 filler, int filler_loc)
-{
- png_debug(1, "in png_set_filler");
-
- if (png_ptr == NULL)
- return;
-
- /* In libpng 1.6 it is possible to determine whether this is a read or write
- * operation and therefore to do more checking here for a valid call.
- */
- if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
- {
-# ifdef PNG_READ_FILLER_SUPPORTED
- /* On read png_set_filler is always valid, regardless of the base PNG
- * format, because other transformations can give a format where the
- * filler code can execute (basically an 8 or 16-bit component RGB or G
- * format.)
- *
- * NOTE: usr_channels is not used by the read code! (This has led to
- * confusion in the past.) The filler is only used in the read code.
- */
- png_ptr->filler = (png_uint_16)filler;
-# else
- png_app_error(png_ptr, "png_set_filler not supported on read");
- PNG_UNUSED(filler) /* not used in the write case */
- return;
-# endif
- }
-
- else /* write */
- {
-# ifdef PNG_WRITE_FILLER_SUPPORTED
- /* On write the usr_channels parameter must be set correctly at the
- * start to record the number of channels in the app-supplied data.
- */
- switch (png_ptr->color_type)
- {
- case PNG_COLOR_TYPE_RGB:
- png_ptr->usr_channels = 4;
- break;
-
- case PNG_COLOR_TYPE_GRAY:
- if (png_ptr->bit_depth >= 8)
- {
- png_ptr->usr_channels = 2;
- break;
- }
-
- else
- {
- /* There simply isn't any code in libpng to strip out bits
- * from bytes when the components are less than a byte in
- * size!
- */
- png_app_error(png_ptr,
- "png_set_filler is invalid for"
- " low bit depth gray output");
- return;
- }
-
- default:
- png_app_error(png_ptr,
- "png_set_filler: inappropriate color type");
- return;
- }
-# else
- png_app_error(png_ptr, "png_set_filler not supported on write");
- return;
-# endif
- }
-
- /* Here on success - libpng supports the operation, set the transformation
- * and the flag to say where the filler channel is.
- */
- png_ptr->transformations |= PNG_FILLER;
-
- if (filler_loc == PNG_FILLER_AFTER)
- png_ptr->flags |= PNG_FLAG_FILLER_AFTER;
-
- else
- png_ptr->flags &= ~PNG_FLAG_FILLER_AFTER;
-}
-
-/* Added to libpng-1.2.7 */
-void PNGAPI
-png_set_add_alpha(png_structrp png_ptr, png_uint_32 filler, int filler_loc)
-{
- png_debug(1, "in png_set_add_alpha");
-
- if (png_ptr == NULL)
- return;
-
- png_set_filler(png_ptr, filler, filler_loc);
- /* The above may fail to do anything. */
- if ((png_ptr->transformations & PNG_FILLER) != 0)
- png_ptr->transformations |= PNG_ADD_ALPHA;
-}
-
-#endif
-
-#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \
- defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
-void PNGAPI
-png_set_swap_alpha(png_structrp png_ptr)
-{
- png_debug(1, "in png_set_swap_alpha");
-
- if (png_ptr == NULL)
- return;
-
- png_ptr->transformations |= PNG_SWAP_ALPHA;
-}
-#endif
-
-#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \
- defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
-void PNGAPI
-png_set_invert_alpha(png_structrp png_ptr)
-{
- png_debug(1, "in png_set_invert_alpha");
-
- if (png_ptr == NULL)
- return;
-
- png_ptr->transformations |= PNG_INVERT_ALPHA;
-}
-#endif
-
-#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
-void PNGAPI
-png_set_invert_mono(png_structrp png_ptr)
-{
- png_debug(1, "in png_set_invert_mono");
-
- if (png_ptr == NULL)
- return;
-
- png_ptr->transformations |= PNG_INVERT_MONO;
-}
-
-/* Invert monochrome grayscale data */
-void /* PRIVATE */
-png_do_invert(png_row_infop row_info, png_bytep row)
-{
- png_debug(1, "in png_do_invert");
-
- /* This test removed from libpng version 1.0.13 and 1.2.0:
- * if (row_info->bit_depth == 1 &&
- */
- if (row_info->color_type == PNG_COLOR_TYPE_GRAY)
- {
- png_bytep rp = row;
- size_t i;
- size_t istop = row_info->rowbytes;
-
- for (i = 0; i < istop; i++)
- {
- *rp = (png_byte)(~(*rp));
- rp++;
- }
- }
-
- else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA &&
- row_info->bit_depth == 8)
- {
- png_bytep rp = row;
- size_t i;
- size_t istop = row_info->rowbytes;
-
- for (i = 0; i < istop; i += 2)
- {
- *rp = (png_byte)(~(*rp));
- rp += 2;
- }
- }
-
-#ifdef PNG_16BIT_SUPPORTED
- else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA &&
- row_info->bit_depth == 16)
- {
- png_bytep rp = row;
- size_t i;
- size_t istop = row_info->rowbytes;
-
- for (i = 0; i < istop; i += 4)
- {
- *rp = (png_byte)(~(*rp));
- *(rp + 1) = (png_byte)(~(*(rp + 1)));
- rp += 4;
- }
- }
-#endif
-}
-#endif
-
-#ifdef PNG_16BIT_SUPPORTED
-#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
-/* Swaps byte order on 16-bit depth images */
-void /* PRIVATE */
-png_do_swap(png_row_infop row_info, png_bytep row)
-{
- png_debug(1, "in png_do_swap");
-
- if (row_info->bit_depth == 16)
- {
- png_bytep rp = row;
- png_uint_32 i;
- png_uint_32 istop= row_info->width * row_info->channels;
-
- for (i = 0; i < istop; i++, rp += 2)
- {
-#ifdef PNG_BUILTIN_BSWAP16_SUPPORTED
- /* Feature added to libpng-1.6.11 for testing purposes, not
- * enabled by default.
- */
- *(png_uint_16*)rp = __builtin_bswap16(*(png_uint_16*)rp);
-#else
- png_byte t = *rp;
- *rp = *(rp + 1);
- *(rp + 1) = t;
-#endif
- }
- }
-}
-#endif
-#endif
-
-#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED)
-static const png_byte onebppswaptable[256] = {
- 0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0,
- 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0,
- 0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8,
- 0x18, 0x98, 0x58, 0xD8, 0x38, 0xB8, 0x78, 0xF8,
- 0x04, 0x84, 0x44, 0xC4, 0x24, 0xA4, 0x64, 0xE4,
- 0x14, 0x94, 0x54, 0xD4, 0x34, 0xB4, 0x74, 0xF4,
- 0x0C, 0x8C, 0x4C, 0xCC, 0x2C, 0xAC, 0x6C, 0xEC,
- 0x1C, 0x9C, 0x5C, 0xDC, 0x3C, 0xBC, 0x7C, 0xFC,
- 0x02, 0x82, 0x42, 0xC2, 0x22, 0xA2, 0x62, 0xE2,
- 0x12, 0x92, 0x52, 0xD2, 0x32, 0xB2, 0x72, 0xF2,
- 0x0A, 0x8A, 0x4A, 0xCA, 0x2A, 0xAA, 0x6A, 0xEA,
- 0x1A, 0x9A, 0x5A, 0xDA, 0x3A, 0xBA, 0x7A, 0xFA,
- 0x06, 0x86, 0x46, 0xC6, 0x26, 0xA6, 0x66, 0xE6,
- 0x16, 0x96, 0x56, 0xD6, 0x36, 0xB6, 0x76, 0xF6,
- 0x0E, 0x8E, 0x4E, 0xCE, 0x2E, 0xAE, 0x6E, 0xEE,
- 0x1E, 0x9E, 0x5E, 0xDE, 0x3E, 0xBE, 0x7E, 0xFE,
- 0x01, 0x81, 0x41, 0xC1, 0x21, 0xA1, 0x61, 0xE1,
- 0x11, 0x91, 0x51, 0xD1, 0x31, 0xB1, 0x71, 0xF1,
- 0x09, 0x89, 0x49, 0xC9, 0x29, 0xA9, 0x69, 0xE9,
- 0x19, 0x99, 0x59, 0xD9, 0x39, 0xB9, 0x79, 0xF9,
- 0x05, 0x85, 0x45, 0xC5, 0x25, 0xA5, 0x65, 0xE5,
- 0x15, 0x95, 0x55, 0xD5, 0x35, 0xB5, 0x75, 0xF5,
- 0x0D, 0x8D, 0x4D, 0xCD, 0x2D, 0xAD, 0x6D, 0xED,
- 0x1D, 0x9D, 0x5D, 0xDD, 0x3D, 0xBD, 0x7D, 0xFD,
- 0x03, 0x83, 0x43, 0xC3, 0x23, 0xA3, 0x63, 0xE3,
- 0x13, 0x93, 0x53, 0xD3, 0x33, 0xB3, 0x73, 0xF3,
- 0x0B, 0x8B, 0x4B, 0xCB, 0x2B, 0xAB, 0x6B, 0xEB,
- 0x1B, 0x9B, 0x5B, 0xDB, 0x3B, 0xBB, 0x7B, 0xFB,
- 0x07, 0x87, 0x47, 0xC7, 0x27, 0xA7, 0x67, 0xE7,
- 0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7,
- 0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF,
- 0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF
-};
-
-static const png_byte twobppswaptable[256] = {
- 0x00, 0x40, 0x80, 0xC0, 0x10, 0x50, 0x90, 0xD0,
- 0x20, 0x60, 0xA0, 0xE0, 0x30, 0x70, 0xB0, 0xF0,
- 0x04, 0x44, 0x84, 0xC4, 0x14, 0x54, 0x94, 0xD4,
- 0x24, 0x64, 0xA4, 0xE4, 0x34, 0x74, 0xB4, 0xF4,
- 0x08, 0x48, 0x88, 0xC8, 0x18, 0x58, 0x98, 0xD8,
- 0x28, 0x68, 0xA8, 0xE8, 0x38, 0x78, 0xB8, 0xF8,
- 0x0C, 0x4C, 0x8C, 0xCC, 0x1C, 0x5C, 0x9C, 0xDC,
- 0x2C, 0x6C, 0xAC, 0xEC, 0x3C, 0x7C, 0xBC, 0xFC,
- 0x01, 0x41, 0x81, 0xC1, 0x11, 0x51, 0x91, 0xD1,
- 0x21, 0x61, 0xA1, 0xE1, 0x31, 0x71, 0xB1, 0xF1,
- 0x05, 0x45, 0x85, 0xC5, 0x15, 0x55, 0x95, 0xD5,
- 0x25, 0x65, 0xA5, 0xE5, 0x35, 0x75, 0xB5, 0xF5,
- 0x09, 0x49, 0x89, 0xC9, 0x19, 0x59, 0x99, 0xD9,
- 0x29, 0x69, 0xA9, 0xE9, 0x39, 0x79, 0xB9, 0xF9,
- 0x0D, 0x4D, 0x8D, 0xCD, 0x1D, 0x5D, 0x9D, 0xDD,
- 0x2D, 0x6D, 0xAD, 0xED, 0x3D, 0x7D, 0xBD, 0xFD,
- 0x02, 0x42, 0x82, 0xC2, 0x12, 0x52, 0x92, 0xD2,
- 0x22, 0x62, 0xA2, 0xE2, 0x32, 0x72, 0xB2, 0xF2,
- 0x06, 0x46, 0x86, 0xC6, 0x16, 0x56, 0x96, 0xD6,
- 0x26, 0x66, 0xA6, 0xE6, 0x36, 0x76, 0xB6, 0xF6,
- 0x0A, 0x4A, 0x8A, 0xCA, 0x1A, 0x5A, 0x9A, 0xDA,
- 0x2A, 0x6A, 0xAA, 0xEA, 0x3A, 0x7A, 0xBA, 0xFA,
- 0x0E, 0x4E, 0x8E, 0xCE, 0x1E, 0x5E, 0x9E, 0xDE,
- 0x2E, 0x6E, 0xAE, 0xEE, 0x3E, 0x7E, 0xBE, 0xFE,
- 0x03, 0x43, 0x83, 0xC3, 0x13, 0x53, 0x93, 0xD3,
- 0x23, 0x63, 0xA3, 0xE3, 0x33, 0x73, 0xB3, 0xF3,
- 0x07, 0x47, 0x87, 0xC7, 0x17, 0x57, 0x97, 0xD7,
- 0x27, 0x67, 0xA7, 0xE7, 0x37, 0x77, 0xB7, 0xF7,
- 0x0B, 0x4B, 0x8B, 0xCB, 0x1B, 0x5B, 0x9B, 0xDB,
- 0x2B, 0x6B, 0xAB, 0xEB, 0x3B, 0x7B, 0xBB, 0xFB,
- 0x0F, 0x4F, 0x8F, 0xCF, 0x1F, 0x5F, 0x9F, 0xDF,
- 0x2F, 0x6F, 0xAF, 0xEF, 0x3F, 0x7F, 0xBF, 0xFF
-};
-
-static const png_byte fourbppswaptable[256] = {
- 0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70,
- 0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0,
- 0x01, 0x11, 0x21, 0x31, 0x41, 0x51, 0x61, 0x71,
- 0x81, 0x91, 0xA1, 0xB1, 0xC1, 0xD1, 0xE1, 0xF1,
- 0x02, 0x12, 0x22, 0x32, 0x42, 0x52, 0x62, 0x72,
- 0x82, 0x92, 0xA2, 0xB2, 0xC2, 0xD2, 0xE2, 0xF2,
- 0x03, 0x13, 0x23, 0x33, 0x43, 0x53, 0x63, 0x73,
- 0x83, 0x93, 0xA3, 0xB3, 0xC3, 0xD3, 0xE3, 0xF3,
- 0x04, 0x14, 0x24, 0x34, 0x44, 0x54, 0x64, 0x74,
- 0x84, 0x94, 0xA4, 0xB4, 0xC4, 0xD4, 0xE4, 0xF4,
- 0x05, 0x15, 0x25, 0x35, 0x45, 0x55, 0x65, 0x75,
- 0x85, 0x95, 0xA5, 0xB5, 0xC5, 0xD5, 0xE5, 0xF5,
- 0x06, 0x16, 0x26, 0x36, 0x46, 0x56, 0x66, 0x76,
- 0x86, 0x96, 0xA6, 0xB6, 0xC6, 0xD6, 0xE6, 0xF6,
- 0x07, 0x17, 0x27, 0x37, 0x47, 0x57, 0x67, 0x77,
- 0x87, 0x97, 0xA7, 0xB7, 0xC7, 0xD7, 0xE7, 0xF7,
- 0x08, 0x18, 0x28, 0x38, 0x48, 0x58, 0x68, 0x78,
- 0x88, 0x98, 0xA8, 0xB8, 0xC8, 0xD8, 0xE8, 0xF8,
- 0x09, 0x19, 0x29, 0x39, 0x49, 0x59, 0x69, 0x79,
- 0x89, 0x99, 0xA9, 0xB9, 0xC9, 0xD9, 0xE9, 0xF9,
- 0x0A, 0x1A, 0x2A, 0x3A, 0x4A, 0x5A, 0x6A, 0x7A,
- 0x8A, 0x9A, 0xAA, 0xBA, 0xCA, 0xDA, 0xEA, 0xFA,
- 0x0B, 0x1B, 0x2B, 0x3B, 0x4B, 0x5B, 0x6B, 0x7B,
- 0x8B, 0x9B, 0xAB, 0xBB, 0xCB, 0xDB, 0xEB, 0xFB,
- 0x0C, 0x1C, 0x2C, 0x3C, 0x4C, 0x5C, 0x6C, 0x7C,
- 0x8C, 0x9C, 0xAC, 0xBC, 0xCC, 0xDC, 0xEC, 0xFC,
- 0x0D, 0x1D, 0x2D, 0x3D, 0x4D, 0x5D, 0x6D, 0x7D,
- 0x8D, 0x9D, 0xAD, 0xBD, 0xCD, 0xDD, 0xED, 0xFD,
- 0x0E, 0x1E, 0x2E, 0x3E, 0x4E, 0x5E, 0x6E, 0x7E,
- 0x8E, 0x9E, 0xAE, 0xBE, 0xCE, 0xDE, 0xEE, 0xFE,
- 0x0F, 0x1F, 0x2F, 0x3F, 0x4F, 0x5F, 0x6F, 0x7F,
- 0x8F, 0x9F, 0xAF, 0xBF, 0xCF, 0xDF, 0xEF, 0xFF
-};
-
-/* Swaps pixel packing order within bytes */
-void /* PRIVATE */
-png_do_packswap(png_row_infop row_info, png_bytep row)
-{
- png_debug(1, "in png_do_packswap");
-
- if (row_info->bit_depth < 8)
- {
- png_bytep rp;
- png_const_bytep end, table;
-
- end = row + row_info->rowbytes;
-
- if (row_info->bit_depth == 1)
- table = onebppswaptable;
-
- else if (row_info->bit_depth == 2)
- table = twobppswaptable;
-
- else if (row_info->bit_depth == 4)
- table = fourbppswaptable;
-
- else
- return;
-
- for (rp = row; rp < end; rp++)
- *rp = table[*rp];
- }
-}
-#endif /* PACKSWAP || WRITE_PACKSWAP */
-
-#if defined(PNG_WRITE_FILLER_SUPPORTED) || \
- defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
-/* Remove a channel - this used to be 'png_do_strip_filler' but it used a
- * somewhat weird combination of flags to determine what to do. All the calls
- * to png_do_strip_filler are changed in 1.5.2 to call this instead with the
- * correct arguments.
- *
- * The routine isn't general - the channel must be the channel at the start or
- * end (not in the middle) of each pixel.
- */
-void /* PRIVATE */
-png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
-{
- png_bytep sp = row; /* source pointer */
- png_bytep dp = row; /* destination pointer */
- png_bytep ep = row + row_info->rowbytes; /* One beyond end of row */
-
- png_debug(1, "in png_do_strip_channel");
-
- /* At the start sp will point to the first byte to copy and dp to where
- * it is copied to. ep always points just beyond the end of the row, so
- * the loop simply copies (channels-1) channels until sp reaches ep.
- *
- * at_start: 0 -- convert AG, XG, ARGB, XRGB, AAGG, XXGG, etc.
- * nonzero -- convert GA, GX, RGBA, RGBX, GGAA, RRGGBBXX, etc.
- */
-
- /* GA, GX, XG cases */
- if (row_info->channels == 2)
- {
- if (row_info->bit_depth == 8)
- {
- if (at_start != 0) /* Skip initial filler */
- ++sp;
- else /* Skip initial channel and, for sp, the filler */
- {
- sp += 2; ++dp;
- }
-
- /* For a 1 pixel wide image there is nothing to do */
- while (sp < ep)
- {
- *dp++ = *sp; sp += 2;
- }
-
- row_info->pixel_depth = 8;
- }
-
- else if (row_info->bit_depth == 16)
- {
- if (at_start != 0) /* Skip initial filler */
- sp += 2;
- else /* Skip initial channel and, for sp, the filler */
- {
- sp += 4; dp += 2;
- }
-
- while (sp < ep)
- {
- *dp++ = *sp++; *dp++ = *sp; sp += 3;
- }
-
- row_info->pixel_depth = 16;
- }
-
- else
- return; /* bad bit depth */
-
- row_info->channels = 1;
-
- /* Finally fix the color type if it records an alpha channel */
- if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
- row_info->color_type = PNG_COLOR_TYPE_GRAY;
- }
-
- /* RGBA, RGBX, XRGB cases */
- else if (row_info->channels == 4)
- {
- if (row_info->bit_depth == 8)
- {
- if (at_start != 0) /* Skip initial filler */
- ++sp;
- else /* Skip initial channels and, for sp, the filler */
- {
- sp += 4; dp += 3;
- }
-
- /* Note that the loop adds 3 to dp and 4 to sp each time. */
- while (sp < ep)
- {
- *dp++ = *sp++; *dp++ = *sp++; *dp++ = *sp; sp += 2;
- }
-
- row_info->pixel_depth = 24;
- }
-
- else if (row_info->bit_depth == 16)
- {
- if (at_start != 0) /* Skip initial filler */
- sp += 2;
- else /* Skip initial channels and, for sp, the filler */
- {
- sp += 8; dp += 6;
- }
-
- while (sp < ep)
- {
- /* Copy 6 bytes, skip 2 */
- *dp++ = *sp++; *dp++ = *sp++;
- *dp++ = *sp++; *dp++ = *sp++;
- *dp++ = *sp++; *dp++ = *sp; sp += 3;
- }
-
- row_info->pixel_depth = 48;
- }
-
- else
- return; /* bad bit depth */
-
- row_info->channels = 3;
-
- /* Finally fix the color type if it records an alpha channel */
- if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
- row_info->color_type = PNG_COLOR_TYPE_RGB;
- }
-
- else
- return; /* The filler channel has gone already */
-
- /* Fix the rowbytes value. */
- row_info->rowbytes = (size_t)(dp-row);
-}
-#endif
-
-#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
-/* Swaps red and blue bytes within a pixel */
-void /* PRIVATE */
-png_do_bgr(png_row_infop row_info, png_bytep row)
-{
- png_debug(1, "in png_do_bgr");
-
- if ((row_info->color_type & PNG_COLOR_MASK_COLOR) != 0)
- {
- png_uint_32 row_width = row_info->width;
- if (row_info->bit_depth == 8)
- {
- if (row_info->color_type == PNG_COLOR_TYPE_RGB)
- {
- png_bytep rp;
- png_uint_32 i;
-
- for (i = 0, rp = row; i < row_width; i++, rp += 3)
- {
- png_byte save = *rp;
- *rp = *(rp + 2);
- *(rp + 2) = save;
- }
- }
-
- else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
- {
- png_bytep rp;
- png_uint_32 i;
-
- for (i = 0, rp = row; i < row_width; i++, rp += 4)
- {
- png_byte save = *rp;
- *rp = *(rp + 2);
- *(rp + 2) = save;
- }
- }
- }
-
-#ifdef PNG_16BIT_SUPPORTED
- else if (row_info->bit_depth == 16)
- {
- if (row_info->color_type == PNG_COLOR_TYPE_RGB)
- {
- png_bytep rp;
- png_uint_32 i;
-
- for (i = 0, rp = row; i < row_width; i++, rp += 6)
- {
- png_byte save = *rp;
- *rp = *(rp + 4);
- *(rp + 4) = save;
- save = *(rp + 1);
- *(rp + 1) = *(rp + 5);
- *(rp + 5) = save;
- }
- }
-
- else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
- {
- png_bytep rp;
- png_uint_32 i;
-
- for (i = 0, rp = row; i < row_width; i++, rp += 8)
- {
- png_byte save = *rp;
- *rp = *(rp + 4);
- *(rp + 4) = save;
- save = *(rp + 1);
- *(rp + 1) = *(rp + 5);
- *(rp + 5) = save;
- }
- }
- }
-#endif
- }
-}
-#endif /* READ_BGR || WRITE_BGR */
-
-#if defined(PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED) || \
- defined(PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED)
-/* Added at libpng-1.5.10 */
-void /* PRIVATE */
-png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info)
-{
- png_debug(1, "in png_do_check_palette_indexes");
-
- if (png_ptr->num_palette < (1 << row_info->bit_depth) &&
- png_ptr->num_palette > 0) /* num_palette can be 0 in MNG files */
- {
- /* Calculations moved outside switch in an attempt to stop different
- * compiler warnings. 'padding' is in *bits* within the last byte, it is
- * an 'int' because pixel_depth becomes an 'int' in the expression below,
- * and this calculation is used because it avoids warnings that other
- * forms produced on either GCC or MSVC.
- */
- int padding = PNG_PADBITS(row_info->pixel_depth, row_info->width);
- png_bytep rp = png_ptr->row_buf + row_info->rowbytes;
-
- switch (row_info->bit_depth)
- {
- case 1:
- {
- /* in this case, all bytes must be 0 so we don't need
- * to unpack the pixels except for the rightmost one.
- */
- for (; rp > png_ptr->row_buf; rp--)
- {
- if ((*rp >> padding) != 0)
- png_ptr->num_palette_max = 1;
- padding = 0;
- }
-
- break;
- }
-
- case 2:
- {
- for (; rp > png_ptr->row_buf; rp--)
- {
- int i = ((*rp >> padding) & 0x03);
-
- if (i > png_ptr->num_palette_max)
- png_ptr->num_palette_max = i;
-
- i = (((*rp >> padding) >> 2) & 0x03);
-
- if (i > png_ptr->num_palette_max)
- png_ptr->num_palette_max = i;
-
- i = (((*rp >> padding) >> 4) & 0x03);
-
- if (i > png_ptr->num_palette_max)
- png_ptr->num_palette_max = i;
-
- i = (((*rp >> padding) >> 6) & 0x03);
-
- if (i > png_ptr->num_palette_max)
- png_ptr->num_palette_max = i;
-
- padding = 0;
- }
-
- break;
- }
-
- case 4:
- {
- for (; rp > png_ptr->row_buf; rp--)
- {
- int i = ((*rp >> padding) & 0x0f);
-
- if (i > png_ptr->num_palette_max)
- png_ptr->num_palette_max = i;
-
- i = (((*rp >> padding) >> 4) & 0x0f);
-
- if (i > png_ptr->num_palette_max)
- png_ptr->num_palette_max = i;
-
- padding = 0;
- }
-
- break;
- }
-
- case 8:
- {
- for (; rp > png_ptr->row_buf; rp--)
- {
- if (*rp > png_ptr->num_palette_max)
- png_ptr->num_palette_max = (int) *rp;
- }
-
- break;
- }
-
- default:
- break;
- }
- }
-}
-#endif /* CHECK_FOR_INVALID_INDEX */
-
-#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
- defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
-#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
-void PNGAPI
-png_set_user_transform_info(png_structrp png_ptr, png_voidp
- user_transform_ptr, int user_transform_depth, int user_transform_channels)
-{
- png_debug(1, "in png_set_user_transform_info");
-
- if (png_ptr == NULL)
- return;
-
-#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
- if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 &&
- (png_ptr->flags & PNG_FLAG_ROW_INIT) != 0)
- {
- png_app_error(png_ptr,
- "info change after png_start_read_image or png_read_update_info");
- return;
- }
-#endif
-
- png_ptr->user_transform_ptr = user_transform_ptr;
- png_ptr->user_transform_depth = (png_byte)user_transform_depth;
- png_ptr->user_transform_channels = (png_byte)user_transform_channels;
-}
-#endif
-
-/* This function returns a pointer to the user_transform_ptr associated with
- * the user transform functions. The application should free any memory
- * associated with this pointer before png_write_destroy and png_read_destroy
- * are called.
- */
-#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
-png_voidp PNGAPI
-png_get_user_transform_ptr(png_const_structrp png_ptr)
-{
- if (png_ptr == NULL)
- return NULL;
-
- return png_ptr->user_transform_ptr;
-}
-#endif
-
-#ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED
-png_uint_32 PNGAPI
-png_get_current_row_number(png_const_structrp png_ptr)
-{
- /* See the comments in png.h - this is the sub-image row when reading an
- * interlaced image.
- */
- if (png_ptr != NULL)
- return png_ptr->row_number;
-
- return PNG_UINT_32_MAX; /* help the app not to fail silently */
-}
-
-png_byte PNGAPI
-png_get_current_pass_number(png_const_structrp png_ptr)
-{
- if (png_ptr != NULL)
- return png_ptr->pass;
- return 8; /* invalid */
-}
-#endif /* USER_TRANSFORM_INFO */
-#endif /* READ_USER_TRANSFORM || WRITE_USER_TRANSFORM */
-#endif /* READ || WRITE */
diff --git a/contrib/libs/libpng/pngwio.c b/contrib/libs/libpng/pngwio.c
deleted file mode 100644
index 38c9c006cb..0000000000
--- a/contrib/libs/libpng/pngwio.c
+++ /dev/null
@@ -1,167 +0,0 @@
-/* pngwio.c - functions for data output
- *
- * Copyright (c) 2018 Cosmin Truta
- * Copyright (c) 1998-2002,2004,2006-2014,2016,2018 Glenn Randers-Pehrson
- * Copyright (c) 1996-1997 Andreas Dilger
- * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
- *
- * This code is released under the libpng license.
- * For conditions of distribution and use, see the disclaimer
- * and license in png.h
- *
- * This file provides a location for all output. Users who need
- * special handling are expected to write functions that have the same
- * arguments as these and perform similar functions, but that possibly
- * use different output methods. Note that you shouldn't change these
- * functions, but rather write replacement functions and then change
- * them at run time with png_set_write_fn(...).
- */
-
-#include "pngpriv.h"
-
-#ifdef PNG_WRITE_SUPPORTED
-
-/* Write the data to whatever output you are using. The default routine
- * writes to a file pointer. Note that this routine sometimes gets called
- * with very small lengths, so you should implement some kind of simple
- * buffering if you are using unbuffered writes. This should never be asked
- * to write more than 64K on a 16-bit machine.
- */
-
-void /* PRIVATE */
-png_write_data(png_structrp png_ptr, png_const_bytep data, size_t length)
-{
- /* NOTE: write_data_fn must not change the buffer! */
- if (png_ptr->write_data_fn != NULL )
- (*(png_ptr->write_data_fn))(png_ptr, png_constcast(png_bytep,data),
- length);
-
- else
- png_error(png_ptr, "Call to NULL write function");
-}
-
-#ifdef PNG_STDIO_SUPPORTED
-/* This is the function that does the actual writing of data. If you are
- * not writing to a standard C stream, you should create a replacement
- * write_data function and use it at run time with png_set_write_fn(), rather
- * than changing the library.
- */
-void PNGCBAPI
-png_default_write_data(png_structp png_ptr, png_bytep data, size_t length)
-{
- size_t check;
-
- if (png_ptr == NULL)
- return;
-
- check = fwrite(data, 1, length, (png_FILE_p)(png_ptr->io_ptr));
-
- if (check != length)
- png_error(png_ptr, "Write Error");
-}
-#endif
-
-/* This function is called to output any data pending writing (normally
- * to disk). After png_flush is called, there should be no data pending
- * writing in any buffers.
- */
-#ifdef PNG_WRITE_FLUSH_SUPPORTED
-void /* PRIVATE */
-png_flush(png_structrp png_ptr)
-{
- if (png_ptr->output_flush_fn != NULL)
- (*(png_ptr->output_flush_fn))(png_ptr);
-}
-
-# ifdef PNG_STDIO_SUPPORTED
-void PNGCBAPI
-png_default_flush(png_structp png_ptr)
-{
- png_FILE_p io_ptr;
-
- if (png_ptr == NULL)
- return;
-
- io_ptr = png_voidcast(png_FILE_p, (png_ptr->io_ptr));
- fflush(io_ptr);
-}
-# endif
-#endif
-
-/* This function allows the application to supply new output functions for
- * libpng if standard C streams aren't being used.
- *
- * This function takes as its arguments:
- * png_ptr - pointer to a png output data structure
- * io_ptr - pointer to user supplied structure containing info about
- * the output functions. May be NULL.
- * write_data_fn - pointer to a new output function that takes as its
- * arguments a pointer to a png_struct, a pointer to
- * data to be written, and a 32-bit unsigned int that is
- * the number of bytes to be written. The new write
- * function should call png_error(png_ptr, "Error msg")
- * to exit and output any fatal error messages. May be
- * NULL, in which case libpng's default function will
- * be used.
- * flush_data_fn - pointer to a new flush function that takes as its
- * arguments a pointer to a png_struct. After a call to
- * the flush function, there should be no data in any buffers
- * or pending transmission. If the output method doesn't do
- * any buffering of output, a function prototype must still be
- * supplied although it doesn't have to do anything. If
- * PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile
- * time, output_flush_fn will be ignored, although it must be
- * supplied for compatibility. May be NULL, in which case
- * libpng's default function will be used, if
- * PNG_WRITE_FLUSH_SUPPORTED is defined. This is not
- * a good idea if io_ptr does not point to a standard
- * *FILE structure.
- */
-void PNGAPI
-png_set_write_fn(png_structrp png_ptr, png_voidp io_ptr,
- png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)
-{
- if (png_ptr == NULL)
- return;
-
- png_ptr->io_ptr = io_ptr;
-
-#ifdef PNG_STDIO_SUPPORTED
- if (write_data_fn != NULL)
- png_ptr->write_data_fn = write_data_fn;
-
- else
- png_ptr->write_data_fn = png_default_write_data;
-#else
- png_ptr->write_data_fn = write_data_fn;
-#endif
-
-#ifdef PNG_WRITE_FLUSH_SUPPORTED
-# ifdef PNG_STDIO_SUPPORTED
-
- if (output_flush_fn != NULL)
- png_ptr->output_flush_fn = output_flush_fn;
-
- else
- png_ptr->output_flush_fn = png_default_flush;
-
-# else
- png_ptr->output_flush_fn = output_flush_fn;
-# endif
-#else
- PNG_UNUSED(output_flush_fn)
-#endif /* WRITE_FLUSH */
-
-#ifdef PNG_READ_SUPPORTED
- /* It is an error to read while writing a png file */
- if (png_ptr->read_data_fn != NULL)
- {
- png_ptr->read_data_fn = NULL;
-
- png_warning(png_ptr,
- "Can't set both read_data_fn and write_data_fn in the"
- " same structure");
- }
-#endif
-}
-#endif /* WRITE */
diff --git a/contrib/libs/libpng/pngwrite.c b/contrib/libs/libpng/pngwrite.c
deleted file mode 100644
index c78d3d8fad..0000000000
--- a/contrib/libs/libpng/pngwrite.c
+++ /dev/null
@@ -1,2519 +0,0 @@
-/* pngwrite.c - general routines to write a PNG file
- *
- * Copyright (c) 2018-2025 Cosmin Truta
- * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
- * Copyright (c) 1996-1997 Andreas Dilger
- * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
- *
- * This code is released under the libpng license.
- * For conditions of distribution and use, see the disclaimer
- * and license in png.h
- */
-
-#include "pngpriv.h"
-#ifdef PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED
-# include <errno.h>
-#endif /* SIMPLIFIED_WRITE_STDIO */
-
-#ifdef PNG_WRITE_SUPPORTED
-
-#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
-/* Write out all the unknown chunks for the current given location */
-static void
-write_unknown_chunks(png_structrp png_ptr, png_const_inforp info_ptr,
- unsigned int where)
-{
- if (info_ptr->unknown_chunks_num != 0)
- {
- png_const_unknown_chunkp up;
-
- png_debug(5, "writing extra chunks");
-
- for (up = info_ptr->unknown_chunks;
- up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num;
- ++up)
- if ((up->location & where) != 0)
- {
- /* If per-chunk unknown chunk handling is enabled use it, otherwise
- * just write the chunks the application has set.
- */
-#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
- int keep = png_handle_as_unknown(png_ptr, up->name);
-
- /* NOTE: this code is radically different from the read side in the
- * matter of handling an ancillary unknown chunk. In the read side
- * the default behavior is to discard it, in the code below the default
- * behavior is to write it. Critical chunks are, however, only
- * written if explicitly listed or if the default is set to write all
- * unknown chunks.
- *
- * The default handling is also slightly weird - it is not possible to
- * stop the writing of all unsafe-to-copy chunks!
- *
- * TODO: REVIEW: this would seem to be a bug.
- */
- if (keep != PNG_HANDLE_CHUNK_NEVER &&
- ((up->name[3] & 0x20) /* safe-to-copy overrides everything */ ||
- keep == PNG_HANDLE_CHUNK_ALWAYS ||
- (keep == PNG_HANDLE_CHUNK_AS_DEFAULT &&
- png_ptr->unknown_default == PNG_HANDLE_CHUNK_ALWAYS)))
-#endif
- {
- /* TODO: review, what is wrong with a zero length unknown chunk? */
- if (up->size == 0)
- png_warning(png_ptr, "Writing zero-length unknown chunk");
-
- png_write_chunk(png_ptr, up->name, up->data, up->size);
- }
- }
- }
-}
-#endif /* WRITE_UNKNOWN_CHUNKS */
-
-/* Writes all the PNG information. This is the suggested way to use the
- * library. If you have a new chunk to add, make a function to write it,
- * and put it in the correct location here. If you want the chunk written
- * after the image data, put it in png_write_end(). I strongly encourage
- * you to supply a PNG_INFO_<chunk> flag, and check info_ptr->valid before
- * writing the chunk, as that will keep the code from breaking if you want
- * to just write a plain PNG file. If you have long comments, I suggest
- * writing them in png_write_end(), and compressing them.
- */
-void PNGAPI
-png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr)
-{
- png_debug(1, "in png_write_info_before_PLTE");
-
- if (png_ptr == NULL || info_ptr == NULL)
- return;
-
- if ((png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE) == 0)
- {
- /* Write PNG signature */
- png_write_sig(png_ptr);
-
-#ifdef PNG_MNG_FEATURES_SUPPORTED
- if ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) != 0 && \
- png_ptr->mng_features_permitted != 0)
- {
- png_warning(png_ptr,
- "MNG features are not allowed in a PNG datastream");
- png_ptr->mng_features_permitted = 0;
- }
-#endif
-
- /* Write IHDR information. */
- png_write_IHDR(png_ptr, info_ptr->width, info_ptr->height,
- info_ptr->bit_depth, info_ptr->color_type, info_ptr->compression_type,
- info_ptr->filter_type,
-#ifdef PNG_WRITE_INTERLACING_SUPPORTED
- info_ptr->interlace_type
-#else
- 0
-#endif
- );
-
- /* The rest of these check to see if the valid field has the appropriate
- * flag set, and if it does, writes the chunk.
- *
- * 1.6.0: COLORSPACE support controls the writing of these chunks too, and
- * the chunks will be written if the WRITE routine is there and
- * information * is available in the COLORSPACE. (See
- * png_colorspace_sync_info in png.c for where the valid flags get set.)
- *
- * Under certain circumstances the colorspace can be invalidated without
- * syncing the info_struct 'valid' flags; this happens if libpng detects
- * an error and calls png_error while the color space is being set, yet
- * the application continues writing the PNG. So check the 'invalid'
- * flag here too.
- */
-#ifdef PNG_WRITE_APNG_SUPPORTED
- if ((info_ptr->valid & PNG_INFO_acTL) != 0)
- png_write_acTL(png_ptr, info_ptr->num_frames, info_ptr->num_plays);
-#endif
-#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
- /* Write unknown chunks first; PNG v3 establishes a precedence order
- * for colourspace chunks. It is certain therefore that new
- * colourspace chunks will have a precedence and very likely it will be
- * higher than all known so far. Writing the unknown chunks here is
- * most likely to present the chunks in the most convenient order.
- *
- * FUTURE: maybe write chunks in the order the app calls png_set_chnk
- * to give the app control.
- */
- write_unknown_chunks(png_ptr, info_ptr, PNG_HAVE_IHDR);
-#endif
-
-#ifdef PNG_WRITE_sBIT_SUPPORTED
- /* PNG v3: a streaming app will need to see this before cICP because
- * the information is helpful in handling HLG encoding (which is
- * natively 10 bits but gets expanded to 16 in PNG.)
- *
- * The app shouldn't care about the order ideally, but it might have
- * no choice. In PNG v3, apps are allowed to reject PNGs where the
- * APNG chunks are out of order so it behooves libpng to be nice here.
- */
- if ((info_ptr->valid & PNG_INFO_sBIT) != 0)
- png_write_sBIT(png_ptr, &(info_ptr->sig_bit), info_ptr->color_type);
-#endif
-
- /* PNG v3: the July 2004 version of the TR introduced the concept of colour
- * space priority. As above it therefore behooves libpng to write the colour
- * space chunks in the priority order so that a streaming app need not buffer
- * them.
- *
- * PNG v3: Chunks mDCV and cLLI provide ancillary information for the
- * interpretation of the colourspace chunkgs but do not require support for
- * those chunks so are outside the "COLORSPACE" check but before the write of
- * the colourspace chunks themselves.
- */
-#ifdef PNG_WRITE_cLLI_SUPPORTED
- if ((info_ptr->valid & PNG_INFO_cLLI) != 0)
- {
- png_write_cLLI_fixed(png_ptr, info_ptr->maxCLL, info_ptr->maxFALL);
- }
-#endif
-#ifdef PNG_WRITE_mDCV_SUPPORTED
- if ((info_ptr->valid & PNG_INFO_mDCV) != 0)
- {
- png_write_mDCV_fixed(png_ptr,
- info_ptr->mastering_red_x, info_ptr->mastering_red_y,
- info_ptr->mastering_green_x, info_ptr->mastering_green_y,
- info_ptr->mastering_blue_x, info_ptr->mastering_blue_y,
- info_ptr->mastering_white_x, info_ptr->mastering_white_y,
- info_ptr->mastering_maxDL, info_ptr->mastering_minDL);
- }
-#endif
-
-#ifdef PNG_COLORSPACE_SUPPORTED
-# ifdef PNG_WRITE_cICP_SUPPORTED /* Priority 4 */
- if ((info_ptr->valid & PNG_INFO_cICP) != 0)
- {
- png_write_cICP(png_ptr,
- info_ptr->cicp_colour_primaries,
- info_ptr->cicp_transfer_function,
- info_ptr->cicp_matrix_coefficients,
- info_ptr->cicp_video_full_range_flag);
- }
-# endif
-
- /* PNG v3 change: it is now permitted to write both sRGB and ICC profiles,
- * however because the libpng code auto-generates an sRGB for the
- * corresponding ICC profiles and because PNG v2 disallowed this we need
- * to only write one.
- *
- * Remove the PNG v2 warning about writing an sRGB ICC profile as well
- * because it's invalid with PNG v3.
- */
-# ifdef PNG_WRITE_iCCP_SUPPORTED /* Priority 3 */
- if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&
- (info_ptr->valid & PNG_INFO_iCCP) != 0)
- {
- png_write_iCCP(png_ptr, info_ptr->iccp_name,
- info_ptr->iccp_profile);
- }
-# ifdef PNG_WRITE_sRGB_SUPPORTED
- else
-# endif
-# endif
-
-# ifdef PNG_WRITE_sRGB_SUPPORTED /* Priority 2 */
- if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&
- (info_ptr->valid & PNG_INFO_sRGB) != 0)
- png_write_sRGB(png_ptr, info_ptr->colorspace.rendering_intent);
-# endif /* WRITE_sRGB */
-#endif /* COLORSPACE */
-
-#ifdef PNG_GAMMA_SUPPORTED
-# ifdef PNG_WRITE_gAMA_SUPPORTED /* Priority 1 */
- if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&
- (info_ptr->colorspace.flags & PNG_COLORSPACE_FROM_gAMA) != 0 &&
- (info_ptr->valid & PNG_INFO_gAMA) != 0)
- png_write_gAMA_fixed(png_ptr, info_ptr->colorspace.gamma);
-# endif
-#endif
-
-#ifdef PNG_COLORSPACE_SUPPORTED
-# ifdef PNG_WRITE_cHRM_SUPPORTED /* Also priority 1 */
- if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&
- (info_ptr->colorspace.flags & PNG_COLORSPACE_FROM_cHRM) != 0 &&
- (info_ptr->valid & PNG_INFO_cHRM) != 0)
- png_write_cHRM_fixed(png_ptr, &info_ptr->colorspace.end_points_xy);
-# endif
-#endif
-
- png_ptr->mode |= PNG_WROTE_INFO_BEFORE_PLTE;
- }
-}
-
-void PNGAPI
-png_write_info(png_structrp png_ptr, png_const_inforp info_ptr)
-{
-#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED)
- int i;
-#endif
-
- png_debug(1, "in png_write_info");
-
- if (png_ptr == NULL || info_ptr == NULL)
- return;
-
- png_write_info_before_PLTE(png_ptr, info_ptr);
-
- if ((info_ptr->valid & PNG_INFO_PLTE) != 0)
- png_write_PLTE(png_ptr, info_ptr->palette,
- (png_uint_32)info_ptr->num_palette);
-
- else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
- png_error(png_ptr, "Valid palette required for paletted images");
-
-#ifdef PNG_WRITE_tRNS_SUPPORTED
- if ((info_ptr->valid & PNG_INFO_tRNS) !=0)
- {
-#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
- /* Invert the alpha channel (in tRNS) */
- if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0 &&
- info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
- {
- int j, jend;
-
- jend = info_ptr->num_trans;
- if (jend > PNG_MAX_PALETTE_LENGTH)
- jend = PNG_MAX_PALETTE_LENGTH;
-
- for (j = 0; j<jend; ++j)
- info_ptr->trans_alpha[j] =
- (png_byte)(255 - info_ptr->trans_alpha[j]);
- }
-#endif
- png_write_tRNS(png_ptr, info_ptr->trans_alpha, &(info_ptr->trans_color),
- info_ptr->num_trans, info_ptr->color_type);
- }
-#endif
-#ifdef PNG_WRITE_bKGD_SUPPORTED
- if ((info_ptr->valid & PNG_INFO_bKGD) != 0)
- png_write_bKGD(png_ptr, &(info_ptr->background), info_ptr->color_type);
-#endif
-
-#ifdef PNG_WRITE_eXIf_SUPPORTED
- if ((info_ptr->valid & PNG_INFO_eXIf) != 0)
- {
- png_write_eXIf(png_ptr, info_ptr->exif, info_ptr->num_exif);
- png_ptr->mode |= PNG_WROTE_eXIf;
- }
-#endif
-
-#ifdef PNG_WRITE_hIST_SUPPORTED
- if ((info_ptr->valid & PNG_INFO_hIST) != 0)
- png_write_hIST(png_ptr, info_ptr->hist, info_ptr->num_palette);
-#endif
-
-#ifdef PNG_WRITE_oFFs_SUPPORTED
- if ((info_ptr->valid & PNG_INFO_oFFs) != 0)
- png_write_oFFs(png_ptr, info_ptr->x_offset, info_ptr->y_offset,
- info_ptr->offset_unit_type);
-#endif
-
-#ifdef PNG_WRITE_pCAL_SUPPORTED
- if ((info_ptr->valid & PNG_INFO_pCAL) != 0)
- png_write_pCAL(png_ptr, info_ptr->pcal_purpose, info_ptr->pcal_X0,
- info_ptr->pcal_X1, info_ptr->pcal_type, info_ptr->pcal_nparams,
- info_ptr->pcal_units, info_ptr->pcal_params);
-#endif
-
-#ifdef PNG_WRITE_sCAL_SUPPORTED
- if ((info_ptr->valid & PNG_INFO_sCAL) != 0)
- png_write_sCAL_s(png_ptr, (int)info_ptr->scal_unit,
- info_ptr->scal_s_width, info_ptr->scal_s_height);
-#endif /* sCAL */
-
-#ifdef PNG_WRITE_pHYs_SUPPORTED
- if ((info_ptr->valid & PNG_INFO_pHYs) != 0)
- png_write_pHYs(png_ptr, info_ptr->x_pixels_per_unit,
- info_ptr->y_pixels_per_unit, info_ptr->phys_unit_type);
-#endif /* pHYs */
-
-#ifdef PNG_WRITE_tIME_SUPPORTED
- if ((info_ptr->valid & PNG_INFO_tIME) != 0)
- {
- png_write_tIME(png_ptr, &(info_ptr->mod_time));
- png_ptr->mode |= PNG_WROTE_tIME;
- }
-#endif /* tIME */
-
-#ifdef PNG_WRITE_sPLT_SUPPORTED
- if ((info_ptr->valid & PNG_INFO_sPLT) != 0)
- for (i = 0; i < (int)info_ptr->splt_palettes_num; i++)
- png_write_sPLT(png_ptr, info_ptr->splt_palettes + i);
-#endif /* sPLT */
-
-#ifdef PNG_WRITE_TEXT_SUPPORTED
- /* Check to see if we need to write text chunks */
- for (i = 0; i < info_ptr->num_text; i++)
- {
- png_debug2(2, "Writing header text chunk %d, type %d", i,
- info_ptr->text[i].compression);
- /* An internationalized chunk? */
- if (info_ptr->text[i].compression > 0)
- {
-#ifdef PNG_WRITE_iTXt_SUPPORTED
- /* Write international chunk */
- png_write_iTXt(png_ptr,
- info_ptr->text[i].compression,
- info_ptr->text[i].key,
- info_ptr->text[i].lang,
- info_ptr->text[i].lang_key,
- info_ptr->text[i].text);
- /* Mark this chunk as written */
- if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE)
- info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;
- else
- info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR;
-#else
- png_warning(png_ptr, "Unable to write international text");
-#endif
- }
-
- /* If we want a compressed text chunk */
- else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_zTXt)
- {
-#ifdef PNG_WRITE_zTXt_SUPPORTED
- /* Write compressed chunk */
- png_write_zTXt(png_ptr, info_ptr->text[i].key,
- info_ptr->text[i].text, info_ptr->text[i].compression);
- /* Mark this chunk as written */
- info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR;
-#else
- png_warning(png_ptr, "Unable to write compressed text");
-#endif
- }
-
- else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE)
- {
-#ifdef PNG_WRITE_tEXt_SUPPORTED
- /* Write uncompressed chunk */
- png_write_tEXt(png_ptr, info_ptr->text[i].key,
- info_ptr->text[i].text,
- 0);
- /* Mark this chunk as written */
- info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;
-#else
- /* Can't get here */
- png_warning(png_ptr, "Unable to write uncompressed text");
-#endif
- }
- }
-#endif /* tEXt */
-
-#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
- write_unknown_chunks(png_ptr, info_ptr, PNG_HAVE_PLTE);
-#endif
-}
-
-/* Writes the end of the PNG file. If you don't want to write comments or
- * time information, you can pass NULL for info. If you already wrote these
- * in png_write_info(), do not write them again here. If you have long
- * comments, I suggest writing them here, and compressing them.
- */
-void PNGAPI
-png_write_end(png_structrp png_ptr, png_inforp info_ptr)
-{
- png_debug(1, "in png_write_end");
-
- if (png_ptr == NULL)
- return;
-
- if ((png_ptr->mode & PNG_HAVE_IDAT) == 0)
- png_error(png_ptr, "No IDATs written into file");
-
-#ifdef PNG_WRITE_APNG_SUPPORTED
- if (png_ptr->num_frames_written != png_ptr->num_frames_to_write)
- png_error(png_ptr, "Not enough frames written");
-#endif
-
-#ifdef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
- if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
- png_ptr->num_palette_max >= png_ptr->num_palette)
- png_benign_error(png_ptr, "Wrote palette index exceeding num_palette");
-#endif
-
- /* See if user wants us to write information chunks */
- if (info_ptr != NULL)
- {
-#ifdef PNG_WRITE_TEXT_SUPPORTED
- int i; /* local index variable */
-#endif
-#ifdef PNG_WRITE_tIME_SUPPORTED
- /* Check to see if user has supplied a time chunk */
- if ((info_ptr->valid & PNG_INFO_tIME) != 0 &&
- (png_ptr->mode & PNG_WROTE_tIME) == 0)
- png_write_tIME(png_ptr, &(info_ptr->mod_time));
-
-#endif
-#ifdef PNG_WRITE_TEXT_SUPPORTED
- /* Loop through comment chunks */
- for (i = 0; i < info_ptr->num_text; i++)
- {
- png_debug2(2, "Writing trailer text chunk %d, type %d", i,
- info_ptr->text[i].compression);
- /* An internationalized chunk? */
- if (info_ptr->text[i].compression > 0)
- {
-#ifdef PNG_WRITE_iTXt_SUPPORTED
- /* Write international chunk */
- png_write_iTXt(png_ptr,
- info_ptr->text[i].compression,
- info_ptr->text[i].key,
- info_ptr->text[i].lang,
- info_ptr->text[i].lang_key,
- info_ptr->text[i].text);
- /* Mark this chunk as written */
- if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE)
- info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;
- else
- info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR;
-#else
- png_warning(png_ptr, "Unable to write international text");
-#endif
- }
-
- else if (info_ptr->text[i].compression >= PNG_TEXT_COMPRESSION_zTXt)
- {
-#ifdef PNG_WRITE_zTXt_SUPPORTED
- /* Write compressed chunk */
- png_write_zTXt(png_ptr, info_ptr->text[i].key,
- info_ptr->text[i].text, info_ptr->text[i].compression);
- /* Mark this chunk as written */
- info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR;
-#else
- png_warning(png_ptr, "Unable to write compressed text");
-#endif
- }
-
- else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE)
- {
-#ifdef PNG_WRITE_tEXt_SUPPORTED
- /* Write uncompressed chunk */
- png_write_tEXt(png_ptr, info_ptr->text[i].key,
- info_ptr->text[i].text, 0);
- /* Mark this chunk as written */
- info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;
-#else
- png_warning(png_ptr, "Unable to write uncompressed text");
-#endif
- }
- }
-#endif
-
-#ifdef PNG_WRITE_eXIf_SUPPORTED
- if ((info_ptr->valid & PNG_INFO_eXIf) != 0 &&
- (png_ptr->mode & PNG_WROTE_eXIf) == 0)
- png_write_eXIf(png_ptr, info_ptr->exif, info_ptr->num_exif);
-#endif
-
-#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
- write_unknown_chunks(png_ptr, info_ptr, PNG_AFTER_IDAT);
-#endif
- }
-
- png_ptr->mode |= PNG_AFTER_IDAT;
-
- /* Write end of PNG file */
- png_write_IEND(png_ptr);
-
- /* This flush, added in libpng-1.0.8, removed from libpng-1.0.9beta03,
- * and restored again in libpng-1.2.30, may cause some applications that
- * do not set png_ptr->output_flush_fn to crash. If your application
- * experiences a problem, please try building libpng with
- * PNG_WRITE_FLUSH_AFTER_IEND_SUPPORTED defined, and report the event to
- * png-mng-implement at lists.sf.net .
- */
-#ifdef PNG_WRITE_FLUSH_SUPPORTED
-# ifdef PNG_WRITE_FLUSH_AFTER_IEND_SUPPORTED
- png_flush(png_ptr);
-# endif
-#endif
-}
-
-#ifdef PNG_CONVERT_tIME_SUPPORTED
-void PNGAPI
-png_convert_from_struct_tm(png_timep ptime, const struct tm * ttime)
-{
- png_debug(1, "in png_convert_from_struct_tm");
-
- ptime->year = (png_uint_16)(1900 + ttime->tm_year);
- ptime->month = (png_byte)(ttime->tm_mon + 1);
- ptime->day = (png_byte)ttime->tm_mday;
- ptime->hour = (png_byte)ttime->tm_hour;
- ptime->minute = (png_byte)ttime->tm_min;
- ptime->second = (png_byte)ttime->tm_sec;
-}
-
-void PNGAPI
-png_convert_from_time_t(png_timep ptime, time_t ttime)
-{
- struct tm *tbuf;
-
- png_debug(1, "in png_convert_from_time_t");
-
- tbuf = gmtime(&ttime);
- if (tbuf == NULL)
- {
- /* TODO: add a safe function which takes a png_ptr argument and raises
- * a png_error if the ttime argument is invalid and the call to gmtime
- * fails as a consequence.
- */
- memset(ptime, 0, sizeof(*ptime));
- return;
- }
-
- png_convert_from_struct_tm(ptime, tbuf);
-}
-#endif
-
-/* Initialize png_ptr structure, and allocate any memory needed */
-PNG_FUNCTION(png_structp,PNGAPI
-png_create_write_struct,(png_const_charp user_png_ver, png_voidp error_ptr,
- png_error_ptr error_fn, png_error_ptr warn_fn),PNG_ALLOCATED)
-{
-#ifndef PNG_USER_MEM_SUPPORTED
- png_structrp png_ptr = png_create_png_struct(user_png_ver, error_ptr,
- error_fn, warn_fn, NULL, NULL, NULL);
-#else
- return png_create_write_struct_2(user_png_ver, error_ptr, error_fn,
- warn_fn, NULL, NULL, NULL);
-}
-
-/* Alternate initialize png_ptr structure, and allocate any memory needed */
-PNG_FUNCTION(png_structp,PNGAPI
-png_create_write_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
- png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr,
- png_malloc_ptr malloc_fn, png_free_ptr free_fn),PNG_ALLOCATED)
-{
- png_structrp png_ptr = png_create_png_struct(user_png_ver, error_ptr,
- error_fn, warn_fn, mem_ptr, malloc_fn, free_fn);
-#endif /* USER_MEM */
- if (png_ptr != NULL)
- {
- /* Set the zlib control values to defaults; they can be overridden by the
- * application after the struct has been created.
- */
- png_ptr->zbuffer_size = PNG_ZBUF_SIZE;
-
- /* The 'zlib_strategy' setting is irrelevant because png_default_claim in
- * pngwutil.c defaults it according to whether or not filters will be
- * used, and ignores this setting.
- */
- png_ptr->zlib_strategy = PNG_Z_DEFAULT_STRATEGY;
- png_ptr->zlib_level = PNG_Z_DEFAULT_COMPRESSION;
- png_ptr->zlib_mem_level = 8;
- png_ptr->zlib_window_bits = 15;
- png_ptr->zlib_method = 8;
-
-#ifdef PNG_WRITE_COMPRESSED_TEXT_SUPPORTED
- png_ptr->zlib_text_strategy = PNG_TEXT_Z_DEFAULT_STRATEGY;
- png_ptr->zlib_text_level = PNG_TEXT_Z_DEFAULT_COMPRESSION;
- png_ptr->zlib_text_mem_level = 8;
- png_ptr->zlib_text_window_bits = 15;
- png_ptr->zlib_text_method = 8;
-#endif /* WRITE_COMPRESSED_TEXT */
-
- /* This is a highly dubious configuration option; by default it is off,
- * but it may be appropriate for private builds that are testing
- * extensions not conformant to the current specification, or of
- * applications that must not fail to write at all costs!
- */
-#ifdef PNG_BENIGN_WRITE_ERRORS_SUPPORTED
- /* In stable builds only warn if an application error can be completely
- * handled.
- */
- png_ptr->flags |= PNG_FLAG_BENIGN_ERRORS_WARN;
-#endif
-
- /* App warnings are warnings in release (or release candidate) builds but
- * are errors during development.
- */
-#if PNG_RELEASE_BUILD
- png_ptr->flags |= PNG_FLAG_APP_WARNINGS_WARN;
-#endif
-
- /* TODO: delay this, it can be done in png_init_io() (if the app doesn't
- * do it itself) avoiding setting the default function if it is not
- * required.
- */
- png_set_write_fn(png_ptr, NULL, NULL, NULL);
- }
-
- return png_ptr;
-}
-
-
-/* Write a few rows of image data. If the image is interlaced,
- * either you will have to write the 7 sub images, or, if you
- * have called png_set_interlace_handling(), you will have to
- * "write" the image seven times.
- */
-void PNGAPI
-png_write_rows(png_structrp png_ptr, png_bytepp row,
- png_uint_32 num_rows)
-{
- png_uint_32 i; /* row counter */
- png_bytepp rp; /* row pointer */
-
- png_debug(1, "in png_write_rows");
-
- if (png_ptr == NULL)
- return;
-
- /* Loop through the rows */
- for (i = 0, rp = row; i < num_rows; i++, rp++)
- {
- png_write_row(png_ptr, *rp);
- }
-}
-
-/* Write the image. You only need to call this function once, even
- * if you are writing an interlaced image.
- */
-void PNGAPI
-png_write_image(png_structrp png_ptr, png_bytepp image)
-{
- png_uint_32 i; /* row index */
- int pass, num_pass; /* pass variables */
- png_bytepp rp; /* points to current row */
-
- if (png_ptr == NULL)
- return;
-
- png_debug(1, "in png_write_image");
-
-#ifdef PNG_WRITE_INTERLACING_SUPPORTED
- /* Initialize interlace handling. If image is not interlaced,
- * this will set pass to 1
- */
- num_pass = png_set_interlace_handling(png_ptr);
-#else
- num_pass = 1;
-#endif
- /* Loop through passes */
- for (pass = 0; pass < num_pass; pass++)
- {
- /* Loop through image */
- for (i = 0, rp = image; i < png_ptr->height; i++, rp++)
- {
- png_write_row(png_ptr, *rp);
- }
- }
-}
-
-#ifdef PNG_MNG_FEATURES_SUPPORTED
-/* Performs intrapixel differencing */
-static void
-png_do_write_intrapixel(png_row_infop row_info, png_bytep row)
-{
- png_debug(1, "in png_do_write_intrapixel");
-
- if ((row_info->color_type & PNG_COLOR_MASK_COLOR) != 0)
- {
- int bytes_per_pixel;
- png_uint_32 row_width = row_info->width;
- if (row_info->bit_depth == 8)
- {
- png_bytep rp;
- png_uint_32 i;
-
- if (row_info->color_type == PNG_COLOR_TYPE_RGB)
- bytes_per_pixel = 3;
-
- else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
- bytes_per_pixel = 4;
-
- else
- return;
-
- for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
- {
- *(rp) = (png_byte)(*rp - *(rp + 1));
- *(rp + 2) = (png_byte)(*(rp + 2) - *(rp + 1));
- }
- }
-
-#ifdef PNG_WRITE_16BIT_SUPPORTED
- else if (row_info->bit_depth == 16)
- {
- png_bytep rp;
- png_uint_32 i;
-
- if (row_info->color_type == PNG_COLOR_TYPE_RGB)
- bytes_per_pixel = 6;
-
- else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
- bytes_per_pixel = 8;
-
- else
- return;
-
- for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
- {
- png_uint_32 s0 = (png_uint_32)(*(rp ) << 8) | *(rp + 1);
- png_uint_32 s1 = (png_uint_32)(*(rp + 2) << 8) | *(rp + 3);
- png_uint_32 s2 = (png_uint_32)(*(rp + 4) << 8) | *(rp + 5);
- png_uint_32 red = (png_uint_32)((s0 - s1) & 0xffffL);
- png_uint_32 blue = (png_uint_32)((s2 - s1) & 0xffffL);
- *(rp ) = (png_byte)(red >> 8);
- *(rp + 1) = (png_byte)red;
- *(rp + 4) = (png_byte)(blue >> 8);
- *(rp + 5) = (png_byte)blue;
- }
- }
-#endif /* WRITE_16BIT */
- }
-}
-#endif /* MNG_FEATURES */
-
-/* Called by user to write a row of image data */
-void PNGAPI
-png_write_row(png_structrp png_ptr, png_const_bytep row)
-{
- /* 1.5.6: moved from png_struct to be a local structure: */
- png_row_info row_info;
-
- png_debug2(1, "in png_write_row (row %u, pass %d)",
- png_ptr->row_number, png_ptr->pass);
-
- if (png_ptr == NULL)
- return;
-
- /* Initialize transformations and other stuff if first time */
- if (png_ptr->row_number == 0 && png_ptr->pass == 0)
- {
- /* Make sure we wrote the header info */
- if ((png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE) == 0)
- png_error(png_ptr,
- "png_write_info was never called before png_write_row");
-
- /* Check for transforms that have been set but were defined out */
-#if !defined(PNG_WRITE_INVERT_SUPPORTED) && defined(PNG_READ_INVERT_SUPPORTED)
- if ((png_ptr->transformations & PNG_INVERT_MONO) != 0)
- png_warning(png_ptr, "PNG_WRITE_INVERT_SUPPORTED is not defined");
-#endif
-
-#if !defined(PNG_WRITE_FILLER_SUPPORTED) && defined(PNG_READ_FILLER_SUPPORTED)
- if ((png_ptr->transformations & PNG_FILLER) != 0)
- png_warning(png_ptr, "PNG_WRITE_FILLER_SUPPORTED is not defined");
-#endif
-#if !defined(PNG_WRITE_PACKSWAP_SUPPORTED) && \
- defined(PNG_READ_PACKSWAP_SUPPORTED)
- if ((png_ptr->transformations & PNG_PACKSWAP) != 0)
- png_warning(png_ptr,
- "PNG_WRITE_PACKSWAP_SUPPORTED is not defined");
-#endif
-
-#if !defined(PNG_WRITE_PACK_SUPPORTED) && defined(PNG_READ_PACK_SUPPORTED)
- if ((png_ptr->transformations & PNG_PACK) != 0)
- png_warning(png_ptr, "PNG_WRITE_PACK_SUPPORTED is not defined");
-#endif
-
-#if !defined(PNG_WRITE_SHIFT_SUPPORTED) && defined(PNG_READ_SHIFT_SUPPORTED)
- if ((png_ptr->transformations & PNG_SHIFT) != 0)
- png_warning(png_ptr, "PNG_WRITE_SHIFT_SUPPORTED is not defined");
-#endif
-
-#if !defined(PNG_WRITE_BGR_SUPPORTED) && defined(PNG_READ_BGR_SUPPORTED)
- if ((png_ptr->transformations & PNG_BGR) != 0)
- png_warning(png_ptr, "PNG_WRITE_BGR_SUPPORTED is not defined");
-#endif
-
-#if !defined(PNG_WRITE_SWAP_SUPPORTED) && defined(PNG_READ_SWAP_SUPPORTED)
- if ((png_ptr->transformations & PNG_SWAP_BYTES) != 0)
- png_warning(png_ptr, "PNG_WRITE_SWAP_SUPPORTED is not defined");
-#endif
-
- png_write_start_row(png_ptr);
- }
-
-#ifdef PNG_WRITE_INTERLACING_SUPPORTED
- /* If interlaced and not interested in row, return */
- if (png_ptr->interlaced != 0 &&
- (png_ptr->transformations & PNG_INTERLACE) != 0)
- {
- switch (png_ptr->pass)
- {
- case 0:
- if ((png_ptr->row_number & 0x07) != 0)
- {
- png_write_finish_row(png_ptr);
- return;
- }
- break;
-
- case 1:
- if ((png_ptr->row_number & 0x07) != 0 || png_ptr->width < 5)
- {
- png_write_finish_row(png_ptr);
- return;
- }
- break;
-
- case 2:
- if ((png_ptr->row_number & 0x07) != 4)
- {
- png_write_finish_row(png_ptr);
- return;
- }
- break;
-
- case 3:
- if ((png_ptr->row_number & 0x03) != 0 || png_ptr->width < 3)
- {
- png_write_finish_row(png_ptr);
- return;
- }
- break;
-
- case 4:
- if ((png_ptr->row_number & 0x03) != 2)
- {
- png_write_finish_row(png_ptr);
- return;
- }
- break;
-
- case 5:
- if ((png_ptr->row_number & 0x01) != 0 || png_ptr->width < 2)
- {
- png_write_finish_row(png_ptr);
- return;
- }
- break;
-
- case 6:
- if ((png_ptr->row_number & 0x01) == 0)
- {
- png_write_finish_row(png_ptr);
- return;
- }
- break;
-
- default: /* error: ignore it */
- break;
- }
- }
-#endif
-
- /* Set up row info for transformations */
- row_info.color_type = png_ptr->color_type;
- row_info.width = png_ptr->usr_width;
- row_info.channels = png_ptr->usr_channels;
- row_info.bit_depth = png_ptr->usr_bit_depth;
- row_info.pixel_depth = (png_byte)(row_info.bit_depth * row_info.channels);
- row_info.rowbytes = PNG_ROWBYTES(row_info.pixel_depth, row_info.width);
-
- png_debug1(3, "row_info->color_type = %d", row_info.color_type);
- png_debug1(3, "row_info->width = %u", row_info.width);
- png_debug1(3, "row_info->channels = %d", row_info.channels);
- png_debug1(3, "row_info->bit_depth = %d", row_info.bit_depth);
- png_debug1(3, "row_info->pixel_depth = %d", row_info.pixel_depth);
- png_debug1(3, "row_info->rowbytes = %lu", (unsigned long)row_info.rowbytes);
-
- /* Copy user's row into buffer, leaving room for filter byte. */
- memcpy(png_ptr->row_buf + 1, row, row_info.rowbytes);
-
-#ifdef PNG_WRITE_INTERLACING_SUPPORTED
- /* Handle interlacing */
- if (png_ptr->interlaced && png_ptr->pass < 6 &&
- (png_ptr->transformations & PNG_INTERLACE) != 0)
- {
- png_do_write_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass);
- /* This should always get caught above, but still ... */
- if (row_info.width == 0)
- {
- png_write_finish_row(png_ptr);
- return;
- }
- }
-#endif
-
-#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
- /* Handle other transformations */
- if (png_ptr->transformations != 0)
- png_do_write_transformations(png_ptr, &row_info);
-#endif
-
- /* At this point the row_info pixel depth must match the 'transformed' depth,
- * which is also the output depth.
- */
- if (row_info.pixel_depth != png_ptr->pixel_depth ||
- row_info.pixel_depth != png_ptr->transformed_pixel_depth)
- png_error(png_ptr, "internal write transform logic error");
-
-#ifdef PNG_MNG_FEATURES_SUPPORTED
- /* Write filter_method 64 (intrapixel differencing) only if
- * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and
- * 2. Libpng did not write a PNG signature (this filter_method is only
- * used in PNG datastreams that are embedded in MNG datastreams) and
- * 3. The application called png_permit_mng_features with a mask that
- * included PNG_FLAG_MNG_FILTER_64 and
- * 4. The filter_method is 64 and
- * 5. The color_type is RGB or RGBA
- */
- if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) != 0 &&
- (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING))
- {
- /* Intrapixel differencing */
- png_do_write_intrapixel(&row_info, png_ptr->row_buf + 1);
- }
-#endif
-
-/* Added at libpng-1.5.10 */
-#ifdef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
- /* Check for out-of-range palette index */
- if (row_info.color_type == PNG_COLOR_TYPE_PALETTE &&
- png_ptr->num_palette_max >= 0)
- png_do_check_palette_indexes(png_ptr, &row_info);
-#endif
-
- /* Find a filter if necessary, filter the row and write it out. */
- png_write_find_filter(png_ptr, &row_info);
-
- if (png_ptr->write_row_fn != NULL)
- (*(png_ptr->write_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass);
-}
-
-#ifdef PNG_WRITE_FLUSH_SUPPORTED
-/* Set the automatic flush interval or 0 to turn flushing off */
-void PNGAPI
-png_set_flush(png_structrp png_ptr, int nrows)
-{
- png_debug(1, "in png_set_flush");
-
- if (png_ptr == NULL)
- return;
-
- png_ptr->flush_dist = (nrows < 0 ? 0 : (png_uint_32)nrows);
-}
-
-/* Flush the current output buffers now */
-void PNGAPI
-png_write_flush(png_structrp png_ptr)
-{
- png_debug(1, "in png_write_flush");
-
- if (png_ptr == NULL)
- return;
-
- /* We have already written out all of the data */
- if (png_ptr->row_number >= png_ptr->num_rows)
- return;
-
- png_compress_IDAT(png_ptr, NULL, 0, Z_SYNC_FLUSH);
- png_ptr->flush_rows = 0;
- png_flush(png_ptr);
-}
-#endif /* WRITE_FLUSH */
-
-/* Free any memory used in png_ptr struct without freeing the struct itself. */
-static void
-png_write_destroy(png_structrp png_ptr)
-{
- png_debug(1, "in png_write_destroy");
-
- /* Free any memory zlib uses */
- if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) != 0)
- deflateEnd(&png_ptr->zstream);
-
- /* Free our memory. png_free checks NULL for us. */
- png_free_buffer_list(png_ptr, &png_ptr->zbuffer_list);
- png_free(png_ptr, png_ptr->row_buf);
- png_ptr->row_buf = NULL;
-#ifdef PNG_WRITE_FILTER_SUPPORTED
- png_free(png_ptr, png_ptr->prev_row);
- png_free(png_ptr, png_ptr->try_row);
- png_free(png_ptr, png_ptr->tst_row);
- png_ptr->prev_row = NULL;
- png_ptr->try_row = NULL;
- png_ptr->tst_row = NULL;
-#endif
-
-#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
- png_free(png_ptr, png_ptr->chunk_list);
- png_ptr->chunk_list = NULL;
-#endif
-
- /* The error handling and memory handling information is left intact at this
- * point: the jmp_buf may still have to be freed. See png_destroy_png_struct
- * for how this happens.
- */
-}
-
-/* Free all memory used by the write.
- * In libpng 1.6.0 this API changed quietly to no longer accept a NULL value for
- * *png_ptr_ptr. Prior to 1.6.0 it would accept such a value and it would free
- * the passed in info_structs but it would quietly fail to free any of the data
- * inside them. In 1.6.0 it quietly does nothing (it has to be quiet because it
- * has no png_ptr.)
- */
-void PNGAPI
-png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
-{
- png_debug(1, "in png_destroy_write_struct");
-
- if (png_ptr_ptr != NULL)
- {
- png_structrp png_ptr = *png_ptr_ptr;
-
- if (png_ptr != NULL) /* added in libpng 1.6.0 */
- {
- png_destroy_info_struct(png_ptr, info_ptr_ptr);
-
- *png_ptr_ptr = NULL;
- png_write_destroy(png_ptr);
- png_destroy_png_struct(png_ptr);
- }
- }
-}
-
-/* Allow the application to select one or more row filters to use. */
-void PNGAPI
-png_set_filter(png_structrp png_ptr, int method, int filters)
-{
- png_debug(1, "in png_set_filter");
-
- if (png_ptr == NULL)
- return;
-
-#ifdef PNG_MNG_FEATURES_SUPPORTED
- if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) != 0 &&
- (method == PNG_INTRAPIXEL_DIFFERENCING))
- method = PNG_FILTER_TYPE_BASE;
-
-#endif
- if (method == PNG_FILTER_TYPE_BASE)
- {
- switch (filters & (PNG_ALL_FILTERS | 0x07))
- {
-#ifdef PNG_WRITE_FILTER_SUPPORTED
- case 5:
- case 6:
- case 7: png_app_error(png_ptr, "Unknown row filter for method 0");
-#endif /* WRITE_FILTER */
- /* FALLTHROUGH */
- case PNG_FILTER_VALUE_NONE:
- png_ptr->do_filter = PNG_FILTER_NONE; break;
-
-#ifdef PNG_WRITE_FILTER_SUPPORTED
- case PNG_FILTER_VALUE_SUB:
- png_ptr->do_filter = PNG_FILTER_SUB; break;
-
- case PNG_FILTER_VALUE_UP:
- png_ptr->do_filter = PNG_FILTER_UP; break;
-
- case PNG_FILTER_VALUE_AVG:
- png_ptr->do_filter = PNG_FILTER_AVG; break;
-
- case PNG_FILTER_VALUE_PAETH:
- png_ptr->do_filter = PNG_FILTER_PAETH; break;
-
- default:
- png_ptr->do_filter = (png_byte)filters; break;
-#else
- default:
- png_app_error(png_ptr, "Unknown row filter for method 0");
-#endif /* WRITE_FILTER */
- }
-
-#ifdef PNG_WRITE_FILTER_SUPPORTED
- /* If we have allocated the row_buf, this means we have already started
- * with the image and we should have allocated all of the filter buffers
- * that have been selected. If prev_row isn't already allocated, then
- * it is too late to start using the filters that need it, since we
- * will be missing the data in the previous row. If an application
- * wants to start and stop using particular filters during compression,
- * it should start out with all of the filters, and then remove them
- * or add them back after the start of compression.
- *
- * NOTE: this is a nasty constraint on the code, because it means that the
- * prev_row buffer must be maintained even if there are currently no
- * 'prev_row' requiring filters active.
- */
- if (png_ptr->row_buf != NULL)
- {
- int num_filters;
- png_alloc_size_t buf_size;
-
- /* Repeat the checks in png_write_start_row; 1 pixel high or wide
- * images cannot benefit from certain filters. If this isn't done here
- * the check below will fire on 1 pixel high images.
- */
- if (png_ptr->height == 1)
- filters &= ~(PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH);
-
- if (png_ptr->width == 1)
- filters &= ~(PNG_FILTER_SUB|PNG_FILTER_AVG|PNG_FILTER_PAETH);
-
- if ((filters & (PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH)) != 0
- && png_ptr->prev_row == NULL)
- {
- /* This is the error case, however it is benign - the previous row
- * is not available so the filter can't be used. Just warn here.
- */
- png_app_warning(png_ptr,
- "png_set_filter: UP/AVG/PAETH cannot be added after start");
- filters &= ~(PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH);
- }
-
- num_filters = 0;
-
- if (filters & PNG_FILTER_SUB)
- num_filters++;
-
- if (filters & PNG_FILTER_UP)
- num_filters++;
-
- if (filters & PNG_FILTER_AVG)
- num_filters++;
-
- if (filters & PNG_FILTER_PAETH)
- num_filters++;
-
- /* Allocate needed row buffers if they have not already been
- * allocated.
- */
- buf_size = PNG_ROWBYTES(png_ptr->usr_channels * png_ptr->usr_bit_depth,
- png_ptr->width) + 1;
-
- if (png_ptr->try_row == NULL)
- png_ptr->try_row = png_voidcast(png_bytep,
- png_malloc(png_ptr, buf_size));
-
- if (num_filters > 1)
- {
- if (png_ptr->tst_row == NULL)
- png_ptr->tst_row = png_voidcast(png_bytep,
- png_malloc(png_ptr, buf_size));
- }
- }
- png_ptr->do_filter = (png_byte)filters;
-#endif
- }
- else
- png_error(png_ptr, "Unknown custom filter method");
-}
-
-#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* DEPRECATED */
-/* Provide floating and fixed point APIs */
-#ifdef PNG_FLOATING_POINT_SUPPORTED
-void PNGAPI
-png_set_filter_heuristics(png_structrp png_ptr, int heuristic_method,
- int num_weights, png_const_doublep filter_weights,
- png_const_doublep filter_costs)
-{
- PNG_UNUSED(png_ptr)
- PNG_UNUSED(heuristic_method)
- PNG_UNUSED(num_weights)
- PNG_UNUSED(filter_weights)
- PNG_UNUSED(filter_costs)
-}
-#endif /* FLOATING_POINT */
-
-#ifdef PNG_FIXED_POINT_SUPPORTED
-void PNGAPI
-png_set_filter_heuristics_fixed(png_structrp png_ptr, int heuristic_method,
- int num_weights, png_const_fixed_point_p filter_weights,
- png_const_fixed_point_p filter_costs)
-{
- PNG_UNUSED(png_ptr)
- PNG_UNUSED(heuristic_method)
- PNG_UNUSED(num_weights)
- PNG_UNUSED(filter_weights)
- PNG_UNUSED(filter_costs)
-}
-#endif /* FIXED_POINT */
-#endif /* WRITE_WEIGHTED_FILTER */
-
-#ifdef PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED
-void PNGAPI
-png_set_compression_level(png_structrp png_ptr, int level)
-{
- png_debug(1, "in png_set_compression_level");
-
- if (png_ptr == NULL)
- return;
-
- png_ptr->zlib_level = level;
-}
-
-void PNGAPI
-png_set_compression_mem_level(png_structrp png_ptr, int mem_level)
-{
- png_debug(1, "in png_set_compression_mem_level");
-
- if (png_ptr == NULL)
- return;
-
- png_ptr->zlib_mem_level = mem_level;
-}
-
-void PNGAPI
-png_set_compression_strategy(png_structrp png_ptr, int strategy)
-{
- png_debug(1, "in png_set_compression_strategy");
-
- if (png_ptr == NULL)
- return;
-
- /* The flag setting here prevents the libpng dynamic selection of strategy.
- */
- png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_STRATEGY;
- png_ptr->zlib_strategy = strategy;
-}
-
-/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a
- * smaller value of window_bits if it can do so safely.
- */
-void PNGAPI
-png_set_compression_window_bits(png_structrp png_ptr, int window_bits)
-{
- png_debug(1, "in png_set_compression_window_bits");
-
- if (png_ptr == NULL)
- return;
-
- /* Prior to 1.6.0 this would warn but then set the window_bits value. This
- * meant that negative window bits values could be selected that would cause
- * libpng to write a non-standard PNG file with raw deflate or gzip
- * compressed IDAT or ancillary chunks. Such files can be read and there is
- * no warning on read, so this seems like a very bad idea.
- */
- if (window_bits > 15)
- {
- png_warning(png_ptr, "Only compression windows <= 32k supported by PNG");
- window_bits = 15;
- }
-
- else if (window_bits < 8)
- {
- png_warning(png_ptr, "Only compression windows >= 256 supported by PNG");
- window_bits = 8;
- }
-
- png_ptr->zlib_window_bits = window_bits;
-}
-
-void PNGAPI
-png_set_compression_method(png_structrp png_ptr, int method)
-{
- png_debug(1, "in png_set_compression_method");
-
- if (png_ptr == NULL)
- return;
-
- /* This would produce an invalid PNG file if it worked, but it doesn't and
- * deflate will fault it, so it is harmless to just warn here.
- */
- if (method != 8)
- png_warning(png_ptr, "Only compression method 8 is supported by PNG");
-
- png_ptr->zlib_method = method;
-}
-#endif /* WRITE_CUSTOMIZE_COMPRESSION */
-
-/* The following were added to libpng-1.5.4 */
-#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
-void PNGAPI
-png_set_text_compression_level(png_structrp png_ptr, int level)
-{
- png_debug(1, "in png_set_text_compression_level");
-
- if (png_ptr == NULL)
- return;
-
- png_ptr->zlib_text_level = level;
-}
-
-void PNGAPI
-png_set_text_compression_mem_level(png_structrp png_ptr, int mem_level)
-{
- png_debug(1, "in png_set_text_compression_mem_level");
-
- if (png_ptr == NULL)
- return;
-
- png_ptr->zlib_text_mem_level = mem_level;
-}
-
-void PNGAPI
-png_set_text_compression_strategy(png_structrp png_ptr, int strategy)
-{
- png_debug(1, "in png_set_text_compression_strategy");
-
- if (png_ptr == NULL)
- return;
-
- png_ptr->zlib_text_strategy = strategy;
-}
-
-/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a
- * smaller value of window_bits if it can do so safely.
- */
-void PNGAPI
-png_set_text_compression_window_bits(png_structrp png_ptr, int window_bits)
-{
- png_debug(1, "in png_set_text_compression_window_bits");
-
- if (png_ptr == NULL)
- return;
-
- if (window_bits > 15)
- {
- png_warning(png_ptr, "Only compression windows <= 32k supported by PNG");
- window_bits = 15;
- }
-
- else if (window_bits < 8)
- {
- png_warning(png_ptr, "Only compression windows >= 256 supported by PNG");
- window_bits = 8;
- }
-
- png_ptr->zlib_text_window_bits = window_bits;
-}
-
-void PNGAPI
-png_set_text_compression_method(png_structrp png_ptr, int method)
-{
- png_debug(1, "in png_set_text_compression_method");
-
- if (png_ptr == NULL)
- return;
-
- if (method != 8)
- png_warning(png_ptr, "Only compression method 8 is supported by PNG");
-
- png_ptr->zlib_text_method = method;
-}
-#endif /* WRITE_CUSTOMIZE_ZTXT_COMPRESSION */
-/* end of API added to libpng-1.5.4 */
-
-void PNGAPI
-png_set_write_status_fn(png_structrp png_ptr, png_write_status_ptr write_row_fn)
-{
- png_debug(1, "in png_set_write_status_fn");
-
- if (png_ptr == NULL)
- return;
-
- png_ptr->write_row_fn = write_row_fn;
-}
-
-#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
-void PNGAPI
-png_set_write_user_transform_fn(png_structrp png_ptr, png_user_transform_ptr
- write_user_transform_fn)
-{
- png_debug(1, "in png_set_write_user_transform_fn");
-
- if (png_ptr == NULL)
- return;
-
- png_ptr->transformations |= PNG_USER_TRANSFORM;
- png_ptr->write_user_transform_fn = write_user_transform_fn;
-}
-#endif
-
-
-#ifdef PNG_INFO_IMAGE_SUPPORTED
-void PNGAPI
-png_write_png(png_structrp png_ptr, png_inforp info_ptr,
- int transforms, voidp params)
-{
- png_debug(1, "in png_write_png");
-
- if (png_ptr == NULL || info_ptr == NULL)
- return;
-
- if ((info_ptr->valid & PNG_INFO_IDAT) == 0)
- {
- png_app_error(png_ptr, "no rows for png_write_image to write");
- return;
- }
-
- /* Write the file header information. */
- png_write_info(png_ptr, info_ptr);
-
- /* ------ these transformations don't touch the info structure ------- */
-
- /* Invert monochrome pixels */
- if ((transforms & PNG_TRANSFORM_INVERT_MONO) != 0)
-#ifdef PNG_WRITE_INVERT_SUPPORTED
- png_set_invert_mono(png_ptr);
-#else
- png_app_error(png_ptr, "PNG_TRANSFORM_INVERT_MONO not supported");
-#endif
-
- /* Shift the pixels up to a legal bit depth and fill in
- * as appropriate to correctly scale the image.
- */
- if ((transforms & PNG_TRANSFORM_SHIFT) != 0)
-#ifdef PNG_WRITE_SHIFT_SUPPORTED
- if ((info_ptr->valid & PNG_INFO_sBIT) != 0)
- png_set_shift(png_ptr, &info_ptr->sig_bit);
-#else
- png_app_error(png_ptr, "PNG_TRANSFORM_SHIFT not supported");
-#endif
-
- /* Pack pixels into bytes */
- if ((transforms & PNG_TRANSFORM_PACKING) != 0)
-#ifdef PNG_WRITE_PACK_SUPPORTED
- png_set_packing(png_ptr);
-#else
- png_app_error(png_ptr, "PNG_TRANSFORM_PACKING not supported");
-#endif
-
- /* Swap location of alpha bytes from ARGB to RGBA */
- if ((transforms & PNG_TRANSFORM_SWAP_ALPHA) != 0)
-#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
- png_set_swap_alpha(png_ptr);
-#else
- png_app_error(png_ptr, "PNG_TRANSFORM_SWAP_ALPHA not supported");
-#endif
-
- /* Remove a filler (X) from XRGB/RGBX/AG/GA into to convert it into
- * RGB, note that the code expects the input color type to be G or RGB; no
- * alpha channel.
- */
- if ((transforms & (PNG_TRANSFORM_STRIP_FILLER_AFTER|
- PNG_TRANSFORM_STRIP_FILLER_BEFORE)) != 0)
- {
-#ifdef PNG_WRITE_FILLER_SUPPORTED
- if ((transforms & PNG_TRANSFORM_STRIP_FILLER_AFTER) != 0)
- {
- if ((transforms & PNG_TRANSFORM_STRIP_FILLER_BEFORE) != 0)
- png_app_error(png_ptr,
- "PNG_TRANSFORM_STRIP_FILLER: BEFORE+AFTER not supported");
-
- /* Continue if ignored - this is the pre-1.6.10 behavior */
- png_set_filler(png_ptr, 0, PNG_FILLER_AFTER);
- }
-
- else if ((transforms & PNG_TRANSFORM_STRIP_FILLER_BEFORE) != 0)
- png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
-#else
- png_app_error(png_ptr, "PNG_TRANSFORM_STRIP_FILLER not supported");
-#endif
- }
-
- /* Flip BGR pixels to RGB */
- if ((transforms & PNG_TRANSFORM_BGR) != 0)
-#ifdef PNG_WRITE_BGR_SUPPORTED
- png_set_bgr(png_ptr);
-#else
- png_app_error(png_ptr, "PNG_TRANSFORM_BGR not supported");
-#endif
-
- /* Swap bytes of 16-bit files to most significant byte first */
- if ((transforms & PNG_TRANSFORM_SWAP_ENDIAN) != 0)
-#ifdef PNG_WRITE_SWAP_SUPPORTED
- png_set_swap(png_ptr);
-#else
- png_app_error(png_ptr, "PNG_TRANSFORM_SWAP_ENDIAN not supported");
-#endif
-
- /* Swap bits of 1-bit, 2-bit, 4-bit packed pixel formats */
- if ((transforms & PNG_TRANSFORM_PACKSWAP) != 0)
-#ifdef PNG_WRITE_PACKSWAP_SUPPORTED
- png_set_packswap(png_ptr);
-#else
- png_app_error(png_ptr, "PNG_TRANSFORM_PACKSWAP not supported");
-#endif
-
- /* Invert the alpha channel from opacity to transparency */
- if ((transforms & PNG_TRANSFORM_INVERT_ALPHA) != 0)
-#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
- png_set_invert_alpha(png_ptr);
-#else
- png_app_error(png_ptr, "PNG_TRANSFORM_INVERT_ALPHA not supported");
-#endif
-
- /* ----------------------- end of transformations ------------------- */
-
- /* Write the bits */
- png_write_image(png_ptr, info_ptr->row_pointers);
-
- /* It is REQUIRED to call this to finish writing the rest of the file */
- png_write_end(png_ptr, info_ptr);
-
- PNG_UNUSED(params)
-}
-#endif
-
-
-#ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED
-/* Initialize the write structure - general purpose utility. */
-static int
-png_image_write_init(png_imagep image)
-{
- png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, image,
- png_safe_error, png_safe_warning);
-
- if (png_ptr != NULL)
- {
- png_infop info_ptr = png_create_info_struct(png_ptr);
-
- if (info_ptr != NULL)
- {
- png_controlp control = png_voidcast(png_controlp,
- png_malloc_warn(png_ptr, (sizeof *control)));
-
- if (control != NULL)
- {
- memset(control, 0, (sizeof *control));
-
- control->png_ptr = png_ptr;
- control->info_ptr = info_ptr;
- control->for_write = 1;
-
- image->opaque = control;
- return 1;
- }
-
- /* Error clean up */
- png_destroy_info_struct(png_ptr, &info_ptr);
- }
-
- png_destroy_write_struct(&png_ptr, NULL);
- }
-
- return png_image_error(image, "png_image_write_: out of memory");
-}
-
-/* Arguments to png_image_write_main: */
-typedef struct
-{
- /* Arguments: */
- png_imagep image;
- png_const_voidp buffer;
- png_int_32 row_stride;
- png_const_voidp colormap;
- int convert_to_8bit;
- /* Local variables: */
- png_const_voidp first_row;
- ptrdiff_t row_bytes;
- png_voidp local_row;
- /* Byte count for memory writing */
- png_bytep memory;
- png_alloc_size_t memory_bytes; /* not used for STDIO */
- png_alloc_size_t output_bytes; /* running total */
-} png_image_write_control;
-
-/* Write png_uint_16 input to a 16-bit PNG; the png_ptr has already been set to
- * do any necessary byte swapping. The component order is defined by the
- * png_image format value.
- */
-static int
-png_write_image_16bit(png_voidp argument)
-{
- png_image_write_control *display = png_voidcast(png_image_write_control*,
- argument);
- png_imagep image = display->image;
- png_structrp png_ptr = image->opaque->png_ptr;
-
- png_const_uint_16p input_row = png_voidcast(png_const_uint_16p,
- display->first_row);
- png_uint_16p output_row = png_voidcast(png_uint_16p, display->local_row);
- png_uint_16p row_end;
- unsigned int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ?
- 3 : 1;
- int aindex = 0;
- png_uint_32 y = image->height;
-
- if ((image->format & PNG_FORMAT_FLAG_ALPHA) != 0)
- {
-# ifdef PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED
- if ((image->format & PNG_FORMAT_FLAG_AFIRST) != 0)
- {
- aindex = -1;
- ++input_row; /* To point to the first component */
- ++output_row;
- }
- else
- aindex = (int)channels;
-# else
- aindex = (int)channels;
-# endif
- }
-
- else
- png_error(png_ptr, "png_write_image: internal call error");
-
- /* Work out the output row end and count over this, note that the increment
- * above to 'row' means that row_end can actually be beyond the end of the
- * row; this is correct.
- */
- row_end = output_row + image->width * (channels+1);
-
- for (; y > 0; --y)
- {
- png_const_uint_16p in_ptr = input_row;
- png_uint_16p out_ptr = output_row;
-
- while (out_ptr < row_end)
- {
- png_uint_16 alpha = in_ptr[aindex];
- png_uint_32 reciprocal = 0;
- int c;
-
- out_ptr[aindex] = alpha;
-
- /* Calculate a reciprocal. The correct calculation is simply
- * component/alpha*65535 << 15. (I.e. 15 bits of precision); this
- * allows correct rounding by adding .5 before the shift. 'reciprocal'
- * is only initialized when required.
- */
- if (alpha > 0 && alpha < 65535)
- reciprocal = ((0xffff<<15)+(alpha>>1))/alpha;
-
- c = (int)channels;
- do /* always at least one channel */
- {
- png_uint_16 component = *in_ptr++;
-
- /* The following gives 65535 for an alpha of 0, which is fine,
- * otherwise if 0/0 is represented as some other value there is more
- * likely to be a discontinuity which will probably damage
- * compression when moving from a fully transparent area to a
- * nearly transparent one. (The assumption here is that opaque
- * areas tend not to be 0 intensity.)
- */
- if (component >= alpha)
- component = 65535;
-
- /* component<alpha, so component/alpha is less than one and
- * component*reciprocal is less than 2^31.
- */
- else if (component > 0 && alpha < 65535)
- {
- png_uint_32 calc = component * reciprocal;
- calc += 16384; /* round to nearest */
- component = (png_uint_16)(calc >> 15);
- }
-
- *out_ptr++ = component;
- }
- while (--c > 0);
-
- /* Skip to next component (skip the intervening alpha channel) */
- ++in_ptr;
- ++out_ptr;
- }
-
- png_write_row(png_ptr, png_voidcast(png_const_bytep, display->local_row));
- input_row += (png_uint_16)display->row_bytes/(sizeof (png_uint_16));
- }
-
- return 1;
-}
-
-/* Given 16-bit input (1 to 4 channels) write 8-bit output. If an alpha channel
- * is present it must be removed from the components, the components are then
- * written in sRGB encoding. No components are added or removed.
- *
- * Calculate an alpha reciprocal to reverse pre-multiplication. As above the
- * calculation can be done to 15 bits of accuracy; however, the output needs to
- * be scaled in the range 0..255*65535, so include that scaling here.
- */
-# define UNP_RECIPROCAL(alpha) ((((0xffff*0xff)<<7)+((alpha)>>1))/(alpha))
-
-static png_byte
-png_unpremultiply(png_uint_32 component, png_uint_32 alpha,
- png_uint_32 reciprocal/*from the above macro*/)
-{
- /* The following gives 1.0 for an alpha of 0, which is fine, otherwise if 0/0
- * is represented as some other value there is more likely to be a
- * discontinuity which will probably damage compression when moving from a
- * fully transparent area to a nearly transparent one. (The assumption here
- * is that opaque areas tend not to be 0 intensity.)
- *
- * There is a rounding problem here; if alpha is less than 128 it will end up
- * as 0 when scaled to 8 bits. To avoid introducing spurious colors into the
- * output change for this too.
- */
- if (component >= alpha || alpha < 128)
- return 255;
-
- /* component<alpha, so component/alpha is less than one and
- * component*reciprocal is less than 2^31.
- */
- else if (component > 0)
- {
- /* The test is that alpha/257 (rounded) is less than 255, the first value
- * that becomes 255 is 65407.
- * NOTE: this must agree with the PNG_DIV257 macro (which must, therefore,
- * be exact!) [Could also test reciprocal != 0]
- */
- if (alpha < 65407)
- {
- component *= reciprocal;
- component += 64; /* round to nearest */
- component >>= 7;
- }
-
- else
- component *= 255;
-
- /* Convert the component to sRGB. */
- return (png_byte)PNG_sRGB_FROM_LINEAR(component);
- }
-
- else
- return 0;
-}
-
-static int
-png_write_image_8bit(png_voidp argument)
-{
- png_image_write_control *display = png_voidcast(png_image_write_control*,
- argument);
- png_imagep image = display->image;
- png_structrp png_ptr = image->opaque->png_ptr;
-
- png_const_uint_16p input_row = png_voidcast(png_const_uint_16p,
- display->first_row);
- png_bytep output_row = png_voidcast(png_bytep, display->local_row);
- png_uint_32 y = image->height;
- unsigned int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ?
- 3 : 1;
-
- if ((image->format & PNG_FORMAT_FLAG_ALPHA) != 0)
- {
- png_bytep row_end;
- int aindex;
-
-# ifdef PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED
- if ((image->format & PNG_FORMAT_FLAG_AFIRST) != 0)
- {
- aindex = -1;
- ++input_row; /* To point to the first component */
- ++output_row;
- }
-
- else
-# endif
- aindex = (int)channels;
-
- /* Use row_end in place of a loop counter: */
- row_end = output_row + image->width * (channels+1);
-
- for (; y > 0; --y)
- {
- png_const_uint_16p in_ptr = input_row;
- png_bytep out_ptr = output_row;
-
- while (out_ptr < row_end)
- {
- png_uint_16 alpha = in_ptr[aindex];
- png_byte alphabyte = (png_byte)PNG_DIV257(alpha);
- png_uint_32 reciprocal = 0;
- int c;
-
- /* Scale and write the alpha channel. */
- out_ptr[aindex] = alphabyte;
-
- if (alphabyte > 0 && alphabyte < 255)
- reciprocal = UNP_RECIPROCAL(alpha);
-
- c = (int)channels;
- do /* always at least one channel */
- *out_ptr++ = png_unpremultiply(*in_ptr++, alpha, reciprocal);
- while (--c > 0);
-
- /* Skip to next component (skip the intervening alpha channel) */
- ++in_ptr;
- ++out_ptr;
- } /* while out_ptr < row_end */
-
- png_write_row(png_ptr, png_voidcast(png_const_bytep,
- display->local_row));
- input_row += (png_uint_16)display->row_bytes/(sizeof (png_uint_16));
- } /* while y */
- }
-
- else
- {
- /* No alpha channel, so the row_end really is the end of the row and it
- * is sufficient to loop over the components one by one.
- */
- png_bytep row_end = output_row + image->width * channels;
-
- for (; y > 0; --y)
- {
- png_const_uint_16p in_ptr = input_row;
- png_bytep out_ptr = output_row;
-
- while (out_ptr < row_end)
- {
- png_uint_32 component = *in_ptr++;
-
- component *= 255;
- *out_ptr++ = (png_byte)PNG_sRGB_FROM_LINEAR(component);
- }
-
- png_write_row(png_ptr, output_row);
- input_row += (png_uint_16)display->row_bytes/(sizeof (png_uint_16));
- }
- }
-
- return 1;
-}
-
-static void
-png_image_set_PLTE(png_image_write_control *display)
-{
- png_imagep image = display->image;
- const void *cmap = display->colormap;
- int entries = image->colormap_entries > 256 ? 256 :
- (int)image->colormap_entries;
-
- /* NOTE: the caller must check for cmap != NULL and entries != 0 */
- png_uint_32 format = image->format;
- unsigned int channels = PNG_IMAGE_SAMPLE_CHANNELS(format);
-
-# if defined(PNG_FORMAT_BGR_SUPPORTED) &&\
- defined(PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED)
- int afirst = (format & PNG_FORMAT_FLAG_AFIRST) != 0 &&
- (format & PNG_FORMAT_FLAG_ALPHA) != 0;
-# else
-# define afirst 0
-# endif
-
-# ifdef PNG_FORMAT_BGR_SUPPORTED
- int bgr = (format & PNG_FORMAT_FLAG_BGR) != 0 ? 2 : 0;
-# else
-# define bgr 0
-# endif
-
- int i, num_trans;
- png_color palette[256];
- png_byte tRNS[256];
-
- memset(tRNS, 255, (sizeof tRNS));
- memset(palette, 0, (sizeof palette));
-
- for (i=num_trans=0; i<entries; ++i)
- {
- /* This gets automatically converted to sRGB with reversal of the
- * pre-multiplication if the color-map has an alpha channel.
- */
- if ((format & PNG_FORMAT_FLAG_LINEAR) != 0)
- {
- png_const_uint_16p entry = png_voidcast(png_const_uint_16p, cmap);
-
- entry += (unsigned int)i * channels;
-
- if ((channels & 1) != 0) /* no alpha */
- {
- if (channels >= 3) /* RGB */
- {
- palette[i].blue = (png_byte)PNG_sRGB_FROM_LINEAR(255 *
- entry[(2 ^ bgr)]);
- palette[i].green = (png_byte)PNG_sRGB_FROM_LINEAR(255 *
- entry[1]);
- palette[i].red = (png_byte)PNG_sRGB_FROM_LINEAR(255 *
- entry[bgr]);
- }
-
- else /* Gray */
- palette[i].blue = palette[i].red = palette[i].green =
- (png_byte)PNG_sRGB_FROM_LINEAR(255 * *entry);
- }
-
- else /* alpha */
- {
- png_uint_16 alpha = entry[afirst ? 0 : channels-1];
- png_byte alphabyte = (png_byte)PNG_DIV257(alpha);
- png_uint_32 reciprocal = 0;
-
- /* Calculate a reciprocal, as in the png_write_image_8bit code above
- * this is designed to produce a value scaled to 255*65535 when
- * divided by 128 (i.e. asr 7).
- */
- if (alphabyte > 0 && alphabyte < 255)
- reciprocal = (((0xffff*0xff)<<7)+(alpha>>1))/alpha;
-
- tRNS[i] = alphabyte;
- if (alphabyte < 255)
- num_trans = i+1;
-
- if (channels >= 3) /* RGB */
- {
- palette[i].blue = png_unpremultiply(entry[afirst + (2 ^ bgr)],
- alpha, reciprocal);
- palette[i].green = png_unpremultiply(entry[afirst + 1], alpha,
- reciprocal);
- palette[i].red = png_unpremultiply(entry[afirst + bgr], alpha,
- reciprocal);
- }
-
- else /* gray */
- palette[i].blue = palette[i].red = palette[i].green =
- png_unpremultiply(entry[afirst], alpha, reciprocal);
- }
- }
-
- else /* Color-map has sRGB values */
- {
- png_const_bytep entry = png_voidcast(png_const_bytep, cmap);
-
- entry += (unsigned int)i * channels;
-
- switch (channels)
- {
- case 4:
- tRNS[i] = entry[afirst ? 0 : 3];
- if (tRNS[i] < 255)
- num_trans = i+1;
- /* FALLTHROUGH */
- case 3:
- palette[i].blue = entry[afirst + (2 ^ bgr)];
- palette[i].green = entry[afirst + 1];
- palette[i].red = entry[afirst + bgr];
- break;
-
- case 2:
- tRNS[i] = entry[1 ^ afirst];
- if (tRNS[i] < 255)
- num_trans = i+1;
- /* FALLTHROUGH */
- case 1:
- palette[i].blue = palette[i].red = palette[i].green =
- entry[afirst];
- break;
-
- default:
- break;
- }
- }
- }
-
-# ifdef afirst
-# undef afirst
-# endif
-# ifdef bgr
-# undef bgr
-# endif
-
- png_set_PLTE(image->opaque->png_ptr, image->opaque->info_ptr, palette,
- entries);
-
- if (num_trans > 0)
- png_set_tRNS(image->opaque->png_ptr, image->opaque->info_ptr, tRNS,
- num_trans, NULL);
-
- image->colormap_entries = (png_uint_32)entries;
-}
-
-static int
-png_image_write_main(png_voidp argument)
-{
- png_image_write_control *display = png_voidcast(png_image_write_control*,
- argument);
- png_imagep image = display->image;
- png_structrp png_ptr = image->opaque->png_ptr;
- png_inforp info_ptr = image->opaque->info_ptr;
- png_uint_32 format = image->format;
-
- /* The following four ints are actually booleans */
- int colormap = (format & PNG_FORMAT_FLAG_COLORMAP);
- int linear = !colormap && (format & PNG_FORMAT_FLAG_LINEAR); /* input */
- int alpha = !colormap && (format & PNG_FORMAT_FLAG_ALPHA);
- int write_16bit = linear && (display->convert_to_8bit == 0);
-
-# ifdef PNG_BENIGN_ERRORS_SUPPORTED
- /* Make sure we error out on any bad situation */
- png_set_benign_errors(png_ptr, 0/*error*/);
-# endif
-
- /* Default the 'row_stride' parameter if required, also check the row stride
- * and total image size to ensure that they are within the system limits.
- */
- {
- unsigned int channels = PNG_IMAGE_PIXEL_CHANNELS(image->format);
-
- if (image->width <= 0x7fffffffU/channels) /* no overflow */
- {
- png_uint_32 check;
- png_uint_32 png_row_stride = image->width * channels;
-
- if (display->row_stride == 0)
- display->row_stride = (png_int_32)/*SAFE*/png_row_stride;
-
- if (display->row_stride < 0)
- check = (png_uint_32)(-display->row_stride);
-
- else
- check = (png_uint_32)display->row_stride;
-
- if (check >= png_row_stride)
- {
- /* Now check for overflow of the image buffer calculation; this
- * limits the whole image size to 32 bits for API compatibility with
- * the current, 32-bit, PNG_IMAGE_BUFFER_SIZE macro.
- */
- if (image->height > 0xffffffffU/png_row_stride)
- png_error(image->opaque->png_ptr, "memory image too large");
- }
-
- else
- png_error(image->opaque->png_ptr, "supplied row stride too small");
- }
-
- else
- png_error(image->opaque->png_ptr, "image row stride too large");
- }
-
- /* Set the required transforms then write the rows in the correct order. */
- if ((format & PNG_FORMAT_FLAG_COLORMAP) != 0)
- {
- if (display->colormap != NULL && image->colormap_entries > 0)
- {
- png_uint_32 entries = image->colormap_entries;
-
- png_set_IHDR(png_ptr, info_ptr, image->width, image->height,
- entries > 16 ? 8 : (entries > 4 ? 4 : (entries > 2 ? 2 : 1)),
- PNG_COLOR_TYPE_PALETTE, PNG_INTERLACE_NONE,
- PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
-
- png_image_set_PLTE(display);
- }
-
- else
- png_error(image->opaque->png_ptr,
- "no color-map for color-mapped image");
- }
-
- else
- png_set_IHDR(png_ptr, info_ptr, image->width, image->height,
- write_16bit ? 16 : 8,
- ((format & PNG_FORMAT_FLAG_COLOR) ? PNG_COLOR_MASK_COLOR : 0) +
- ((format & PNG_FORMAT_FLAG_ALPHA) ? PNG_COLOR_MASK_ALPHA : 0),
- PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
-
- /* Counter-intuitively the data transformations must be called *after*
- * png_write_info, not before as in the read code, but the 'set' functions
- * must still be called before. Just set the color space information, never
- * write an interlaced image.
- */
-
- if (write_16bit != 0)
- {
- /* The gamma here is 1.0 (linear) and the cHRM chunk matches sRGB. */
- png_set_gAMA_fixed(png_ptr, info_ptr, PNG_GAMMA_LINEAR);
-
- if ((image->flags & PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB) == 0)
- png_set_cHRM_fixed(png_ptr, info_ptr,
- /* color x y */
- /* white */ 31270, 32900,
- /* red */ 64000, 33000,
- /* green */ 30000, 60000,
- /* blue */ 15000, 6000
- );
- }
-
- else if ((image->flags & PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB) == 0)
- png_set_sRGB(png_ptr, info_ptr, PNG_sRGB_INTENT_PERCEPTUAL);
-
- /* Else writing an 8-bit file and the *colors* aren't sRGB, but the 8-bit
- * space must still be gamma encoded.
- */
- else
- png_set_gAMA_fixed(png_ptr, info_ptr, PNG_GAMMA_sRGB_INVERSE);
-
- /* Write the file header. */
- png_write_info(png_ptr, info_ptr);
-
- /* Now set up the data transformations (*after* the header is written),
- * remove the handled transformations from the 'format' flags for checking.
- *
- * First check for a little endian system if writing 16-bit files.
- */
- if (write_16bit != 0)
- {
- png_uint_16 le = 0x0001;
-
- if ((*(png_const_bytep) & le) != 0)
- png_set_swap(png_ptr);
- }
-
-# ifdef PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED
- if ((format & PNG_FORMAT_FLAG_BGR) != 0)
- {
- if (colormap == 0 && (format & PNG_FORMAT_FLAG_COLOR) != 0)
- png_set_bgr(png_ptr);
- format &= ~PNG_FORMAT_FLAG_BGR;
- }
-# endif
-
-# ifdef PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED
- if ((format & PNG_FORMAT_FLAG_AFIRST) != 0)
- {
- if (colormap == 0 && (format & PNG_FORMAT_FLAG_ALPHA) != 0)
- png_set_swap_alpha(png_ptr);
- format &= ~PNG_FORMAT_FLAG_AFIRST;
- }
-# endif
-
- /* If there are 16 or fewer color-map entries we wrote a lower bit depth
- * above, but the application data is still byte packed.
- */
- if (colormap != 0 && image->colormap_entries <= 16)
- png_set_packing(png_ptr);
-
- /* That should have handled all (both) the transforms. */
- if ((format & ~(png_uint_32)(PNG_FORMAT_FLAG_COLOR | PNG_FORMAT_FLAG_LINEAR |
- PNG_FORMAT_FLAG_ALPHA | PNG_FORMAT_FLAG_COLORMAP)) != 0)
- png_error(png_ptr, "png_write_image: unsupported transformation");
-
- {
- png_const_bytep row = png_voidcast(png_const_bytep, display->buffer);
- ptrdiff_t row_bytes = display->row_stride;
-
- if (linear != 0)
- row_bytes *= (sizeof (png_uint_16));
-
- if (row_bytes < 0)
- row += (image->height-1) * (-row_bytes);
-
- display->first_row = row;
- display->row_bytes = row_bytes;
- }
-
- /* Apply 'fast' options if the flag is set. */
- if ((image->flags & PNG_IMAGE_FLAG_FAST) != 0)
- {
- png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE, PNG_NO_FILTERS);
- /* NOTE: determined by experiment using pngstest, this reflects some
- * balance between the time to write the image once and the time to read
- * it about 50 times. The speed-up in pngstest was about 10-20% of the
- * total (user) time on a heavily loaded system.
- */
-# ifdef PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED
- png_set_compression_level(png_ptr, 3);
-# endif
- }
-
- /* Check for the cases that currently require a pre-transform on the row
- * before it is written. This only applies when the input is 16-bit and
- * either there is an alpha channel or it is converted to 8-bit.
- */
- if ((linear != 0 && alpha != 0 ) ||
- (colormap == 0 && display->convert_to_8bit != 0))
- {
- png_bytep row = png_voidcast(png_bytep, png_malloc(png_ptr,
- png_get_rowbytes(png_ptr, info_ptr)));
- int result;
-
- display->local_row = row;
- if (write_16bit != 0)
- result = png_safe_execute(image, png_write_image_16bit, display);
- else
- result = png_safe_execute(image, png_write_image_8bit, display);
- display->local_row = NULL;
-
- png_free(png_ptr, row);
-
- /* Skip the 'write_end' on error: */
- if (result == 0)
- return 0;
- }
-
- /* Otherwise this is the case where the input is in a format currently
- * supported by the rest of the libpng write code; call it directly.
- */
- else
- {
- png_const_bytep row = png_voidcast(png_const_bytep, display->first_row);
- ptrdiff_t row_bytes = display->row_bytes;
- png_uint_32 y = image->height;
-
- for (; y > 0; --y)
- {
- png_write_row(png_ptr, row);
- row += row_bytes;
- }
- }
-
- png_write_end(png_ptr, info_ptr);
- return 1;
-}
-
-
-static void (PNGCBAPI
-image_memory_write)(png_structp png_ptr, png_bytep/*const*/ data, size_t size)
-{
- png_image_write_control *display = png_voidcast(png_image_write_control*,
- png_ptr->io_ptr/*backdoor: png_get_io_ptr(png_ptr)*/);
- png_alloc_size_t ob = display->output_bytes;
-
- /* Check for overflow; this should never happen: */
- if (size <= ((png_alloc_size_t)-1) - ob)
- {
- /* I don't think libpng ever does this, but just in case: */
- if (size > 0)
- {
- if (display->memory_bytes >= ob+size) /* writing */
- memcpy(display->memory+ob, data, size);
-
- /* Always update the size: */
- display->output_bytes = ob+size;
- }
- }
-
- else
- png_error(png_ptr, "png_image_write_to_memory: PNG too big");
-}
-
-static void (PNGCBAPI
-image_memory_flush)(png_structp png_ptr)
-{
- PNG_UNUSED(png_ptr)
-}
-
-static int
-png_image_write_memory(png_voidp argument)
-{
- png_image_write_control *display = png_voidcast(png_image_write_control*,
- argument);
-
- /* The rest of the memory-specific init and write_main in an error protected
- * environment. This case needs to use callbacks for the write operations
- * since libpng has no built in support for writing to memory.
- */
- png_set_write_fn(display->image->opaque->png_ptr, display/*io_ptr*/,
- image_memory_write, image_memory_flush);
-
- return png_image_write_main(display);
-}
-
-int PNGAPI
-png_image_write_to_memory(png_imagep image, void *memory,
- png_alloc_size_t * PNG_RESTRICT memory_bytes, int convert_to_8bit,
- const void *buffer, png_int_32 row_stride, const void *colormap)
-{
- /* Write the image to the given buffer, or count the bytes if it is NULL */
- if (image != NULL && image->version == PNG_IMAGE_VERSION)
- {
- if (memory_bytes != NULL && buffer != NULL)
- {
- /* This is to give the caller an easier error detection in the NULL
- * case and guard against uninitialized variable problems:
- */
- if (memory == NULL)
- *memory_bytes = 0;
-
- if (png_image_write_init(image) != 0)
- {
- png_image_write_control display;
- int result;
-
- memset(&display, 0, (sizeof display));
- display.image = image;
- display.buffer = buffer;
- display.row_stride = row_stride;
- display.colormap = colormap;
- display.convert_to_8bit = convert_to_8bit;
- display.memory = png_voidcast(png_bytep, memory);
- display.memory_bytes = *memory_bytes;
- display.output_bytes = 0;
-
- result = png_safe_execute(image, png_image_write_memory, &display);
- png_image_free(image);
-
- /* write_memory returns true even if we ran out of buffer. */
- if (result)
- {
- /* On out-of-buffer this function returns '0' but still updates
- * memory_bytes:
- */
- if (memory != NULL && display.output_bytes > *memory_bytes)
- result = 0;
-
- *memory_bytes = display.output_bytes;
- }
-
- return result;
- }
-
- else
- return 0;
- }
-
- else
- return png_image_error(image,
- "png_image_write_to_memory: invalid argument");
- }
-
- else if (image != NULL)
- return png_image_error(image,
- "png_image_write_to_memory: incorrect PNG_IMAGE_VERSION");
-
- else
- return 0;
-}
-
-#ifdef PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED
-int PNGAPI
-png_image_write_to_stdio(png_imagep image, FILE *file, int convert_to_8bit,
- const void *buffer, png_int_32 row_stride, const void *colormap)
-{
- /* Write the image to the given (FILE*). */
- if (image != NULL && image->version == PNG_IMAGE_VERSION)
- {
- if (file != NULL && buffer != NULL)
- {
- if (png_image_write_init(image) != 0)
- {
- png_image_write_control display;
- int result;
-
- /* This is slightly evil, but png_init_io doesn't do anything other
- * than this and we haven't changed the standard IO functions so
- * this saves a 'safe' function.
- */
- image->opaque->png_ptr->io_ptr = file;
-
- memset(&display, 0, (sizeof display));
- display.image = image;
- display.buffer = buffer;
- display.row_stride = row_stride;
- display.colormap = colormap;
- display.convert_to_8bit = convert_to_8bit;
-
- result = png_safe_execute(image, png_image_write_main, &display);
- png_image_free(image);
- return result;
- }
-
- else
- return 0;
- }
-
- else
- return png_image_error(image,
- "png_image_write_to_stdio: invalid argument");
- }
-
- else if (image != NULL)
- return png_image_error(image,
- "png_image_write_to_stdio: incorrect PNG_IMAGE_VERSION");
-
- else
- return 0;
-}
-
-int PNGAPI
-png_image_write_to_file(png_imagep image, const char *file_name,
- int convert_to_8bit, const void *buffer, png_int_32 row_stride,
- const void *colormap)
-{
- /* Write the image to the named file. */
- if (image != NULL && image->version == PNG_IMAGE_VERSION)
- {
- if (file_name != NULL && buffer != NULL)
- {
- FILE *fp = fopen(file_name, "wb");
-
- if (fp != NULL)
- {
- if (png_image_write_to_stdio(image, fp, convert_to_8bit, buffer,
- row_stride, colormap) != 0)
- {
- int error; /* from fflush/fclose */
-
- /* Make sure the file is flushed correctly. */
- if (fflush(fp) == 0 && ferror(fp) == 0)
- {
- if (fclose(fp) == 0)
- return 1;
-
- error = errno; /* from fclose */
- }
-
- else
- {
- error = errno; /* from fflush or ferror */
- (void)fclose(fp);
- }
-
- (void)remove(file_name);
- /* The image has already been cleaned up; this is just used to
- * set the error (because the original write succeeded).
- */
- return png_image_error(image, strerror(error));
- }
-
- else
- {
- /* Clean up: just the opened file. */
- (void)fclose(fp);
- (void)remove(file_name);
- return 0;
- }
- }
-
- else
- return png_image_error(image, strerror(errno));
- }
-
- else
- return png_image_error(image,
- "png_image_write_to_file: invalid argument");
- }
-
- else if (image != NULL)
- return png_image_error(image,
- "png_image_write_to_file: incorrect PNG_IMAGE_VERSION");
-
- else
- return 0;
-}
-#endif /* SIMPLIFIED_WRITE_STDIO */
-#endif /* SIMPLIFIED_WRITE */
-
-#ifdef PNG_WRITE_APNG_SUPPORTED
-void PNGAPI
-png_write_frame_head(png_structp png_ptr, png_infop info_ptr,
- png_bytepp row_pointers, png_uint_32 width, png_uint_32 height,
- png_uint_32 x_offset, png_uint_32 y_offset,
- png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op,
- png_byte blend_op)
-{
- png_debug(1, "in png_write_frame_head");
-
- /* there is a chance this has been set after png_write_info was called,
- * so it would be set but not written. is there a way to be sure? */
- if ((info_ptr->valid & PNG_INFO_acTL) == 0)
- png_error(png_ptr, "png_write_frame_head(): acTL not set");
-
- png_write_reset(png_ptr);
-
- png_write_reinit(png_ptr, info_ptr, width, height);
-
- if ((png_ptr->apng_flags & PNG_FIRST_FRAME_HIDDEN) == 0 ||
- png_ptr->num_frames_written != 0)
- png_write_fcTL(png_ptr, width, height, x_offset, y_offset,
- delay_num, delay_den, dispose_op, blend_op);
-
- PNG_UNUSED(row_pointers)
-}
-
-void PNGAPI
-png_write_frame_tail(png_structp png_ptr, png_infop info_ptr)
-{
- png_debug(1, "in png_write_frame_tail");
-
- png_ptr->num_frames_written++;
-
- PNG_UNUSED(info_ptr)
-}
-#endif /* WRITE_APNG */
-#endif /* WRITE */
diff --git a/contrib/libs/libpng/pngwtran.c b/contrib/libs/libpng/pngwtran.c
deleted file mode 100644
index a20847023f..0000000000
--- a/contrib/libs/libpng/pngwtran.c
+++ /dev/null
@@ -1,574 +0,0 @@
-/* pngwtran.c - transforms the data in a row for PNG writers
- *
- * Copyright (c) 2018 Cosmin Truta
- * Copyright (c) 1998-2002,2004,2006-2016,2018 Glenn Randers-Pehrson
- * Copyright (c) 1996-1997 Andreas Dilger
- * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
- *
- * This code is released under the libpng license.
- * For conditions of distribution and use, see the disclaimer
- * and license in png.h
- */
-
-#include "pngpriv.h"
-
-#ifdef PNG_WRITE_SUPPORTED
-#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
-
-#ifdef PNG_WRITE_PACK_SUPPORTED
-/* Pack pixels into bytes. Pass the true bit depth in bit_depth. The
- * row_info bit depth should be 8 (one pixel per byte). The channels
- * should be 1 (this only happens on grayscale and paletted images).
- */
-static void
-png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
-{
- png_debug(1, "in png_do_pack");
-
- if (row_info->bit_depth == 8 &&
- row_info->channels == 1)
- {
- switch ((int)bit_depth)
- {
- case 1:
- {
- png_bytep sp, dp;
- int mask, v;
- png_uint_32 i;
- png_uint_32 row_width = row_info->width;
-
- sp = row;
- dp = row;
- mask = 0x80;
- v = 0;
-
- for (i = 0; i < row_width; i++)
- {
- if (*sp != 0)
- v |= mask;
-
- sp++;
-
- if (mask > 1)
- mask >>= 1;
-
- else
- {
- mask = 0x80;
- *dp = (png_byte)v;
- dp++;
- v = 0;
- }
- }
-
- if (mask != 0x80)
- *dp = (png_byte)v;
-
- break;
- }
-
- case 2:
- {
- png_bytep sp, dp;
- unsigned int shift;
- int v;
- png_uint_32 i;
- png_uint_32 row_width = row_info->width;
-
- sp = row;
- dp = row;
- shift = 6;
- v = 0;
-
- for (i = 0; i < row_width; i++)
- {
- png_byte value;
-
- value = (png_byte)(*sp & 0x03);
- v |= (value << shift);
-
- if (shift == 0)
- {
- shift = 6;
- *dp = (png_byte)v;
- dp++;
- v = 0;
- }
-
- else
- shift -= 2;
-
- sp++;
- }
-
- if (shift != 6)
- *dp = (png_byte)v;
-
- break;
- }
-
- case 4:
- {
- png_bytep sp, dp;
- unsigned int shift;
- int v;
- png_uint_32 i;
- png_uint_32 row_width = row_info->width;
-
- sp = row;
- dp = row;
- shift = 4;
- v = 0;
-
- for (i = 0; i < row_width; i++)
- {
- png_byte value;
-
- value = (png_byte)(*sp & 0x0f);
- v |= (value << shift);
-
- if (shift == 0)
- {
- shift = 4;
- *dp = (png_byte)v;
- dp++;
- v = 0;
- }
-
- else
- shift -= 4;
-
- sp++;
- }
-
- if (shift != 4)
- *dp = (png_byte)v;
-
- break;
- }
-
- default:
- break;
- }
-
- row_info->bit_depth = (png_byte)bit_depth;
- row_info->pixel_depth = (png_byte)(bit_depth * row_info->channels);
- row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,
- row_info->width);
- }
-}
-#endif
-
-#ifdef PNG_WRITE_SHIFT_SUPPORTED
-/* Shift pixel values to take advantage of whole range. Pass the
- * true number of bits in bit_depth. The row should be packed
- * according to row_info->bit_depth. Thus, if you had a row of
- * bit depth 4, but the pixels only had values from 0 to 7, you
- * would pass 3 as bit_depth, and this routine would translate the
- * data to 0 to 15.
- */
-static void
-png_do_shift(png_row_infop row_info, png_bytep row,
- png_const_color_8p bit_depth)
-{
- png_debug(1, "in png_do_shift");
-
- if (row_info->color_type != PNG_COLOR_TYPE_PALETTE)
- {
- int shift_start[4], shift_dec[4];
- unsigned int channels = 0;
-
- if ((row_info->color_type & PNG_COLOR_MASK_COLOR) != 0)
- {
- shift_start[channels] = row_info->bit_depth - bit_depth->red;
- shift_dec[channels] = bit_depth->red;
- channels++;
-
- shift_start[channels] = row_info->bit_depth - bit_depth->green;
- shift_dec[channels] = bit_depth->green;
- channels++;
-
- shift_start[channels] = row_info->bit_depth - bit_depth->blue;
- shift_dec[channels] = bit_depth->blue;
- channels++;
- }
-
- else
- {
- shift_start[channels] = row_info->bit_depth - bit_depth->gray;
- shift_dec[channels] = bit_depth->gray;
- channels++;
- }
-
- if ((row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0)
- {
- shift_start[channels] = row_info->bit_depth - bit_depth->alpha;
- shift_dec[channels] = bit_depth->alpha;
- channels++;
- }
-
- /* With low row depths, could only be grayscale, so one channel */
- if (row_info->bit_depth < 8)
- {
- png_bytep bp = row;
- size_t i;
- unsigned int mask;
- size_t row_bytes = row_info->rowbytes;
-
- if (bit_depth->gray == 1 && row_info->bit_depth == 2)
- mask = 0x55;
-
- else if (row_info->bit_depth == 4 && bit_depth->gray == 3)
- mask = 0x11;
-
- else
- mask = 0xff;
-
- for (i = 0; i < row_bytes; i++, bp++)
- {
- int j;
- unsigned int v, out;
-
- v = *bp;
- out = 0;
-
- for (j = shift_start[0]; j > -shift_dec[0]; j -= shift_dec[0])
- {
- if (j > 0)
- out |= v << j;
-
- else
- out |= (v >> (-j)) & mask;
- }
-
- *bp = (png_byte)(out & 0xff);
- }
- }
-
- else if (row_info->bit_depth == 8)
- {
- png_bytep bp = row;
- png_uint_32 i;
- png_uint_32 istop = channels * row_info->width;
-
- for (i = 0; i < istop; i++, bp++)
- {
- unsigned int c = i%channels;
- int j;
- unsigned int v, out;
-
- v = *bp;
- out = 0;
-
- for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c])
- {
- if (j > 0)
- out |= v << j;
-
- else
- out |= v >> (-j);
- }
-
- *bp = (png_byte)(out & 0xff);
- }
- }
-
- else
- {
- png_bytep bp;
- png_uint_32 i;
- png_uint_32 istop = channels * row_info->width;
-
- for (bp = row, i = 0; i < istop; i++)
- {
- unsigned int c = i%channels;
- int j;
- unsigned int value, v;
-
- v = png_get_uint_16(bp);
- value = 0;
-
- for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c])
- {
- if (j > 0)
- value |= v << j;
-
- else
- value |= v >> (-j);
- }
- *bp++ = (png_byte)((value >> 8) & 0xff);
- *bp++ = (png_byte)(value & 0xff);
- }
- }
- }
-}
-#endif
-
-#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
-static void
-png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
-{
- png_debug(1, "in png_do_write_swap_alpha");
-
- {
- if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
- {
- if (row_info->bit_depth == 8)
- {
- /* This converts from ARGB to RGBA */
- png_bytep sp, dp;
- png_uint_32 i;
- png_uint_32 row_width = row_info->width;
-
- for (i = 0, sp = dp = row; i < row_width; i++)
- {
- png_byte save = *(sp++);
- *(dp++) = *(sp++);
- *(dp++) = *(sp++);
- *(dp++) = *(sp++);
- *(dp++) = save;
- }
- }
-
-#ifdef PNG_WRITE_16BIT_SUPPORTED
- else
- {
- /* This converts from AARRGGBB to RRGGBBAA */
- png_bytep sp, dp;
- png_uint_32 i;
- png_uint_32 row_width = row_info->width;
-
- for (i = 0, sp = dp = row; i < row_width; i++)
- {
- png_byte save[2];
- save[0] = *(sp++);
- save[1] = *(sp++);
- *(dp++) = *(sp++);
- *(dp++) = *(sp++);
- *(dp++) = *(sp++);
- *(dp++) = *(sp++);
- *(dp++) = *(sp++);
- *(dp++) = *(sp++);
- *(dp++) = save[0];
- *(dp++) = save[1];
- }
- }
-#endif /* WRITE_16BIT */
- }
-
- else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
- {
- if (row_info->bit_depth == 8)
- {
- /* This converts from AG to GA */
- png_bytep sp, dp;
- png_uint_32 i;
- png_uint_32 row_width = row_info->width;
-
- for (i = 0, sp = dp = row; i < row_width; i++)
- {
- png_byte save = *(sp++);
- *(dp++) = *(sp++);
- *(dp++) = save;
- }
- }
-
-#ifdef PNG_WRITE_16BIT_SUPPORTED
- else
- {
- /* This converts from AAGG to GGAA */
- png_bytep sp, dp;
- png_uint_32 i;
- png_uint_32 row_width = row_info->width;
-
- for (i = 0, sp = dp = row; i < row_width; i++)
- {
- png_byte save[2];
- save[0] = *(sp++);
- save[1] = *(sp++);
- *(dp++) = *(sp++);
- *(dp++) = *(sp++);
- *(dp++) = save[0];
- *(dp++) = save[1];
- }
- }
-#endif /* WRITE_16BIT */
- }
- }
-}
-#endif
-
-#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
-static void
-png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
-{
- png_debug(1, "in png_do_write_invert_alpha");
-
- {
- if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
- {
- if (row_info->bit_depth == 8)
- {
- /* This inverts the alpha channel in RGBA */
- png_bytep sp, dp;
- png_uint_32 i;
- png_uint_32 row_width = row_info->width;
-
- for (i = 0, sp = dp = row; i < row_width; i++)
- {
- /* Does nothing
- *(dp++) = *(sp++);
- *(dp++) = *(sp++);
- *(dp++) = *(sp++);
- */
- sp+=3; dp = sp;
- *dp = (png_byte)(255 - *(sp++));
- }
- }
-
-#ifdef PNG_WRITE_16BIT_SUPPORTED
- else
- {
- /* This inverts the alpha channel in RRGGBBAA */
- png_bytep sp, dp;
- png_uint_32 i;
- png_uint_32 row_width = row_info->width;
-
- for (i = 0, sp = dp = row; i < row_width; i++)
- {
- /* Does nothing
- *(dp++) = *(sp++);
- *(dp++) = *(sp++);
- *(dp++) = *(sp++);
- *(dp++) = *(sp++);
- *(dp++) = *(sp++);
- *(dp++) = *(sp++);
- */
- sp+=6; dp = sp;
- *(dp++) = (png_byte)(255 - *(sp++));
- *dp = (png_byte)(255 - *(sp++));
- }
- }
-#endif /* WRITE_16BIT */
- }
-
- else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
- {
- if (row_info->bit_depth == 8)
- {
- /* This inverts the alpha channel in GA */
- png_bytep sp, dp;
- png_uint_32 i;
- png_uint_32 row_width = row_info->width;
-
- for (i = 0, sp = dp = row; i < row_width; i++)
- {
- *(dp++) = *(sp++);
- *(dp++) = (png_byte)(255 - *(sp++));
- }
- }
-
-#ifdef PNG_WRITE_16BIT_SUPPORTED
- else
- {
- /* This inverts the alpha channel in GGAA */
- png_bytep sp, dp;
- png_uint_32 i;
- png_uint_32 row_width = row_info->width;
-
- for (i = 0, sp = dp = row; i < row_width; i++)
- {
- /* Does nothing
- *(dp++) = *(sp++);
- *(dp++) = *(sp++);
- */
- sp+=2; dp = sp;
- *(dp++) = (png_byte)(255 - *(sp++));
- *dp = (png_byte)(255 - *(sp++));
- }
- }
-#endif /* WRITE_16BIT */
- }
- }
-}
-#endif
-
-/* Transform the data according to the user's wishes. The order of
- * transformations is significant.
- */
-void /* PRIVATE */
-png_do_write_transformations(png_structrp png_ptr, png_row_infop row_info)
-{
- png_debug(1, "in png_do_write_transformations");
-
- if (png_ptr == NULL)
- return;
-
-#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
- if ((png_ptr->transformations & PNG_USER_TRANSFORM) != 0)
- if (png_ptr->write_user_transform_fn != NULL)
- (*(png_ptr->write_user_transform_fn)) /* User write transform
- function */
- (png_ptr, /* png_ptr */
- row_info, /* row_info: */
- /* png_uint_32 width; width of row */
- /* size_t rowbytes; number of bytes in row */
- /* png_byte color_type; color type of pixels */
- /* png_byte bit_depth; bit depth of samples */
- /* png_byte channels; number of channels (1-4) */
- /* png_byte pixel_depth; bits per pixel (depth*channels) */
- png_ptr->row_buf + 1); /* start of pixel data for row */
-#endif
-
-#ifdef PNG_WRITE_FILLER_SUPPORTED
- if ((png_ptr->transformations & PNG_FILLER) != 0)
- png_do_strip_channel(row_info, png_ptr->row_buf + 1,
- !(png_ptr->flags & PNG_FLAG_FILLER_AFTER));
-#endif
-
-#ifdef PNG_WRITE_PACKSWAP_SUPPORTED
- if ((png_ptr->transformations & PNG_PACKSWAP) != 0)
- png_do_packswap(row_info, png_ptr->row_buf + 1);
-#endif
-
-#ifdef PNG_WRITE_PACK_SUPPORTED
- if ((png_ptr->transformations & PNG_PACK) != 0)
- png_do_pack(row_info, png_ptr->row_buf + 1,
- (png_uint_32)png_ptr->bit_depth);
-#endif
-
-#ifdef PNG_WRITE_SWAP_SUPPORTED
-# ifdef PNG_16BIT_SUPPORTED
- if ((png_ptr->transformations & PNG_SWAP_BYTES) != 0)
- png_do_swap(row_info, png_ptr->row_buf + 1);
-# endif
-#endif
-
-#ifdef PNG_WRITE_SHIFT_SUPPORTED
- if ((png_ptr->transformations & PNG_SHIFT) != 0)
- png_do_shift(row_info, png_ptr->row_buf + 1,
- &(png_ptr->shift));
-#endif
-
-#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
- if ((png_ptr->transformations & PNG_SWAP_ALPHA) != 0)
- png_do_write_swap_alpha(row_info, png_ptr->row_buf + 1);
-#endif
-
-#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
- if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0)
- png_do_write_invert_alpha(row_info, png_ptr->row_buf + 1);
-#endif
-
-#ifdef PNG_WRITE_BGR_SUPPORTED
- if ((png_ptr->transformations & PNG_BGR) != 0)
- png_do_bgr(row_info, png_ptr->row_buf + 1);
-#endif
-
-#ifdef PNG_WRITE_INVERT_SUPPORTED
- if ((png_ptr->transformations & PNG_INVERT_MONO) != 0)
- png_do_invert(row_info, png_ptr->row_buf + 1);
-#endif
-}
-#endif /* WRITE_TRANSFORMS */
-#endif /* WRITE */
diff --git a/contrib/libs/libpng/pngwutil.c b/contrib/libs/libpng/pngwutil.c
deleted file mode 100644
index 4e82c12d9a..0000000000
--- a/contrib/libs/libpng/pngwutil.c
+++ /dev/null
@@ -1,2961 +0,0 @@
-/* pngwutil.c - utilities to write a PNG file
- *
- * Copyright (c) 2018-2024 Cosmin Truta
- * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
- * Copyright (c) 1996-1997 Andreas Dilger
- * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
- *
- * This code is released under the libpng license.
- * For conditions of distribution and use, see the disclaimer
- * and license in png.h
- *
- * This file contains routines that are only called from within
- * libpng itself during the course of writing an image.
- */
-
-#include "pngpriv.h"
-
-#ifdef PNG_WRITE_SUPPORTED
-
-#ifdef PNG_WRITE_INTERLACING_SUPPORTED
-/* Arrays to facilitate interlacing - use pass (0 - 6) as index. */
-
-/* Start of interlace block */
-static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
-/* Offset to next interlace block */
-static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
-/* Start of interlace block in the y direction */
-static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
-/* Offset to next interlace block in the y direction */
-static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
-
-/* TODO: Move these arrays to a common utility module to avoid duplication. */
-#endif
-
-#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED
-/* Place a 32-bit number into a buffer in PNG byte order. We work
- * with unsigned numbers for convenience, although one supported
- * ancillary chunk uses signed (two's complement) numbers.
- */
-void PNGAPI
-png_save_uint_32(png_bytep buf, png_uint_32 i)
-{
- buf[0] = (png_byte)((i >> 24) & 0xffU);
- buf[1] = (png_byte)((i >> 16) & 0xffU);
- buf[2] = (png_byte)((i >> 8) & 0xffU);
- buf[3] = (png_byte)( i & 0xffU);
-}
-
-/* Place a 16-bit number into a buffer in PNG byte order.
- * The parameter is declared unsigned int, not png_uint_16,
- * just to avoid potential problems on pre-ANSI C compilers.
- */
-void PNGAPI
-png_save_uint_16(png_bytep buf, unsigned int i)
-{
- buf[0] = (png_byte)((i >> 8) & 0xffU);
- buf[1] = (png_byte)( i & 0xffU);
-}
-#endif
-
-/* Simple function to write the signature. If we have already written
- * the magic bytes of the signature, or more likely, the PNG stream is
- * being embedded into another stream and doesn't need its own signature,
- * we should call png_set_sig_bytes() to tell libpng how many of the
- * bytes have already been written.
- */
-void PNGAPI
-png_write_sig(png_structrp png_ptr)
-{
- png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};
-
-#ifdef PNG_IO_STATE_SUPPORTED
- /* Inform the I/O callback that the signature is being written */
- png_ptr->io_state = PNG_IO_WRITING | PNG_IO_SIGNATURE;
-#endif
-
- /* Write the rest of the 8 byte signature */
- png_write_data(png_ptr, &png_signature[png_ptr->sig_bytes],
- (size_t)(8 - png_ptr->sig_bytes));
-
- if (png_ptr->sig_bytes < 3)
- png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE;
-}
-
-/* Write the start of a PNG chunk. The type is the chunk type.
- * The total_length is the sum of the lengths of all the data you will be
- * passing in png_write_chunk_data().
- */
-static void
-png_write_chunk_header(png_structrp png_ptr, png_uint_32 chunk_name,
- png_uint_32 length)
-{
- png_byte buf[8];
-
-#if defined(PNG_DEBUG) && (PNG_DEBUG > 0)
- PNG_CSTRING_FROM_CHUNK(buf, chunk_name);
- png_debug2(0, "Writing %s chunk, length = %lu", buf, (unsigned long)length);
-#endif
-
- if (png_ptr == NULL)
- return;
-
-#ifdef PNG_IO_STATE_SUPPORTED
- /* Inform the I/O callback that the chunk header is being written.
- * PNG_IO_CHUNK_HDR requires a single I/O call.
- */
- png_ptr->io_state = PNG_IO_WRITING | PNG_IO_CHUNK_HDR;
-#endif
-
- /* Write the length and the chunk name */
- png_save_uint_32(buf, length);
- png_save_uint_32(buf + 4, chunk_name);
- png_write_data(png_ptr, buf, 8);
-
- /* Put the chunk name into png_ptr->chunk_name */
- png_ptr->chunk_name = chunk_name;
-
- /* Reset the crc and run it over the chunk name */
- png_reset_crc(png_ptr);
-
- png_calculate_crc(png_ptr, buf + 4, 4);
-
-#ifdef PNG_IO_STATE_SUPPORTED
- /* Inform the I/O callback that chunk data will (possibly) be written.
- * PNG_IO_CHUNK_DATA does NOT require a specific number of I/O calls.
- */
- png_ptr->io_state = PNG_IO_WRITING | PNG_IO_CHUNK_DATA;
-#endif
-}
-
-void PNGAPI
-png_write_chunk_start(png_structrp png_ptr, png_const_bytep chunk_string,
- png_uint_32 length)
-{
- png_write_chunk_header(png_ptr, PNG_CHUNK_FROM_STRING(chunk_string), length);
-}
-
-/* Write the data of a PNG chunk started with png_write_chunk_header().
- * Note that multiple calls to this function are allowed, and that the
- * sum of the lengths from these calls *must* add up to the total_length
- * given to png_write_chunk_header().
- */
-void PNGAPI
-png_write_chunk_data(png_structrp png_ptr, png_const_bytep data, size_t length)
-{
- /* Write the data, and run the CRC over it */
- if (png_ptr == NULL)
- return;
-
- if (data != NULL && length > 0)
- {
- png_write_data(png_ptr, data, length);
-
- /* Update the CRC after writing the data,
- * in case the user I/O routine alters it.
- */
- png_calculate_crc(png_ptr, data, length);
- }
-}
-
-/* Finish a chunk started with png_write_chunk_header(). */
-void PNGAPI
-png_write_chunk_end(png_structrp png_ptr)
-{
- png_byte buf[4];
-
- if (png_ptr == NULL) return;
-
-#ifdef PNG_IO_STATE_SUPPORTED
- /* Inform the I/O callback that the chunk CRC is being written.
- * PNG_IO_CHUNK_CRC requires a single I/O function call.
- */
- png_ptr->io_state = PNG_IO_WRITING | PNG_IO_CHUNK_CRC;
-#endif
-
- /* Write the crc in a single operation */
- png_save_uint_32(buf, png_ptr->crc);
-
- png_write_data(png_ptr, buf, 4);
-}
-
-/* Write a PNG chunk all at once. The type is an array of ASCII characters
- * representing the chunk name. The array must be at least 4 bytes in
- * length, and does not need to be null terminated. To be safe, pass the
- * pre-defined chunk names here, and if you need a new one, define it
- * where the others are defined. The length is the length of the data.
- * All the data must be present. If that is not possible, use the
- * png_write_chunk_start(), png_write_chunk_data(), and png_write_chunk_end()
- * functions instead.
- */
-static void
-png_write_complete_chunk(png_structrp png_ptr, png_uint_32 chunk_name,
- png_const_bytep data, size_t length)
-{
- if (png_ptr == NULL)
- return;
-
- /* On 64-bit architectures 'length' may not fit in a png_uint_32. */
- if (length > PNG_UINT_31_MAX)
- png_error(png_ptr, "length exceeds PNG maximum");
-
- png_write_chunk_header(png_ptr, chunk_name, (png_uint_32)length);
- png_write_chunk_data(png_ptr, data, length);
- png_write_chunk_end(png_ptr);
-}
-
-/* This is the API that calls the internal function above. */
-void PNGAPI
-png_write_chunk(png_structrp png_ptr, png_const_bytep chunk_string,
- png_const_bytep data, size_t length)
-{
- png_write_complete_chunk(png_ptr, PNG_CHUNK_FROM_STRING(chunk_string), data,
- length);
-}
-
-/* This is used below to find the size of an image to pass to png_deflate_claim,
- * so it only needs to be accurate if the size is less than 16384 bytes (the
- * point at which a lower LZ window size can be used.)
- */
-static png_alloc_size_t
-png_image_size(png_structrp png_ptr)
-{
- /* Only return sizes up to the maximum of a png_uint_32; do this by limiting
- * the width and height used to 15 bits.
- */
- png_uint_32 h = png_ptr->height;
-
- if (png_ptr->rowbytes < 32768 && h < 32768)
- {
- if (png_ptr->interlaced != 0)
- {
- /* Interlacing makes the image larger because of the replication of
- * both the filter byte and the padding to a byte boundary.
- */
- png_uint_32 w = png_ptr->width;
- unsigned int pd = png_ptr->pixel_depth;
- png_alloc_size_t cb_base;
- int pass;
-
- for (cb_base=0, pass=0; pass<=6; ++pass)
- {
- png_uint_32 pw = PNG_PASS_COLS(w, pass);
-
- if (pw > 0)
- cb_base += (PNG_ROWBYTES(pd, pw)+1) * PNG_PASS_ROWS(h, pass);
- }
-
- return cb_base;
- }
-
- else
- return (png_ptr->rowbytes+1) * h;
- }
-
- else
- return 0xffffffffU;
-}
-
-#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
- /* This is the code to hack the first two bytes of the deflate stream (the
- * deflate header) to correct the windowBits value to match the actual data
- * size. Note that the second argument is the *uncompressed* size but the
- * first argument is the *compressed* data (and it must be deflate
- * compressed.)
- */
-static void
-optimize_cmf(png_bytep data, png_alloc_size_t data_size)
-{
- /* Optimize the CMF field in the zlib stream. The resultant zlib stream is
- * still compliant to the stream specification.
- */
- if (data_size <= 16384) /* else windowBits must be 15 */
- {
- unsigned int z_cmf = data[0]; /* zlib compression method and flags */
-
- if ((z_cmf & 0x0f) == 8 && (z_cmf & 0xf0) <= 0x70)
- {
- unsigned int z_cinfo;
- unsigned int half_z_window_size;
-
- z_cinfo = z_cmf >> 4;
- half_z_window_size = 1U << (z_cinfo + 7);
-
- if (data_size <= half_z_window_size) /* else no change */
- {
- unsigned int tmp;
-
- do
- {
- half_z_window_size >>= 1;
- --z_cinfo;
- }
- while (z_cinfo > 0 && data_size <= half_z_window_size);
-
- z_cmf = (z_cmf & 0x0f) | (z_cinfo << 4);
-
- data[0] = (png_byte)z_cmf;
- tmp = data[1] & 0xe0;
- tmp += 0x1f - ((z_cmf << 8) + tmp) % 0x1f;
- data[1] = (png_byte)tmp;
- }
- }
- }
-}
-#endif /* WRITE_OPTIMIZE_CMF */
-
-/* Initialize the compressor for the appropriate type of compression. */
-static int
-png_deflate_claim(png_structrp png_ptr, png_uint_32 owner,
- png_alloc_size_t data_size)
-{
- if (png_ptr->zowner != 0)
- {
-#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_ERROR_TEXT_SUPPORTED)
- char msg[64];
-
- PNG_STRING_FROM_CHUNK(msg, owner);
- msg[4] = ':';
- msg[5] = ' ';
- PNG_STRING_FROM_CHUNK(msg+6, png_ptr->zowner);
- /* So the message that results is "<chunk> using zstream"; this is an
- * internal error, but is very useful for debugging. i18n requirements
- * are minimal.
- */
- (void)png_safecat(msg, (sizeof msg), 10, " using zstream");
-#endif
-#if PNG_RELEASE_BUILD
- png_warning(png_ptr, msg);
-
- /* Attempt sane error recovery */
- if (png_ptr->zowner == png_IDAT) /* don't steal from IDAT */
- {
- png_ptr->zstream.msg = PNGZ_MSG_CAST("in use by IDAT");
- return Z_STREAM_ERROR;
- }
-
- png_ptr->zowner = 0;
-#else
- png_error(png_ptr, msg);
-#endif
- }
-
- {
- int level = png_ptr->zlib_level;
- int method = png_ptr->zlib_method;
- int windowBits = png_ptr->zlib_window_bits;
- int memLevel = png_ptr->zlib_mem_level;
- int strategy; /* set below */
- int ret; /* zlib return code */
-
- if (owner == png_IDAT)
- {
- if ((png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_STRATEGY) != 0)
- strategy = png_ptr->zlib_strategy;
-
- else if (png_ptr->do_filter != PNG_FILTER_NONE)
- strategy = PNG_Z_DEFAULT_STRATEGY;
-
- else
- strategy = PNG_Z_DEFAULT_NOFILTER_STRATEGY;
- }
-
- else
- {
-#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
- level = png_ptr->zlib_text_level;
- method = png_ptr->zlib_text_method;
- windowBits = png_ptr->zlib_text_window_bits;
- memLevel = png_ptr->zlib_text_mem_level;
- strategy = png_ptr->zlib_text_strategy;
-#else
- /* If customization is not supported the values all come from the
- * IDAT values except for the strategy, which is fixed to the
- * default. (This is the pre-1.6.0 behavior too, although it was
- * implemented in a very different way.)
- */
- strategy = Z_DEFAULT_STRATEGY;
-#endif
- }
-
- /* Adjust 'windowBits' down if larger than 'data_size'; to stop this
- * happening just pass 32768 as the data_size parameter. Notice that zlib
- * requires an extra 262 bytes in the window in addition to the data to be
- * able to see the whole of the data, so if data_size+262 takes us to the
- * next windowBits size we need to fix up the value later. (Because even
- * though deflate needs the extra window, inflate does not!)
- */
- if (data_size <= 16384)
- {
- /* IMPLEMENTATION NOTE: this 'half_window_size' stuff is only here to
- * work round a Microsoft Visual C misbehavior which, contrary to C-90,
- * widens the result of the following shift to 64-bits if (and,
- * apparently, only if) it is used in a test.
- */
- unsigned int half_window_size = 1U << (windowBits-1);
-
- while (data_size + 262 <= half_window_size)
- {
- half_window_size >>= 1;
- --windowBits;
- }
- }
-
- /* Check against the previous initialized values, if any. */
- if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) != 0 &&
- (png_ptr->zlib_set_level != level ||
- png_ptr->zlib_set_method != method ||
- png_ptr->zlib_set_window_bits != windowBits ||
- png_ptr->zlib_set_mem_level != memLevel ||
- png_ptr->zlib_set_strategy != strategy))
- {
- if (deflateEnd(&png_ptr->zstream) != Z_OK)
- png_warning(png_ptr, "deflateEnd failed (ignored)");
-
- png_ptr->flags &= ~PNG_FLAG_ZSTREAM_INITIALIZED;
- }
-
- /* For safety clear out the input and output pointers (currently zlib
- * doesn't use them on Init, but it might in the future).
- */
- png_ptr->zstream.next_in = NULL;
- png_ptr->zstream.avail_in = 0;
- png_ptr->zstream.next_out = NULL;
- png_ptr->zstream.avail_out = 0;
-
- /* Now initialize if required, setting the new parameters, otherwise just
- * do a simple reset to the previous parameters.
- */
- if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) != 0)
- ret = deflateReset(&png_ptr->zstream);
-
- else
- {
- ret = deflateInit2(&png_ptr->zstream, level, method, windowBits,
- memLevel, strategy);
-
- if (ret == Z_OK)
- png_ptr->flags |= PNG_FLAG_ZSTREAM_INITIALIZED;
- }
-
- /* The return code is from either deflateReset or deflateInit2; they have
- * pretty much the same set of error codes.
- */
- if (ret == Z_OK)
- png_ptr->zowner = owner;
-
- else
- png_zstream_error(png_ptr, ret);
-
- return ret;
- }
-}
-
-/* Clean up (or trim) a linked list of compression buffers. */
-void /* PRIVATE */
-png_free_buffer_list(png_structrp png_ptr, png_compression_bufferp *listp)
-{
- png_compression_bufferp list = *listp;
-
- if (list != NULL)
- {
- *listp = NULL;
-
- do
- {
- png_compression_bufferp next = list->next;
-
- png_free(png_ptr, list);
- list = next;
- }
- while (list != NULL);
- }
-}
-
-#ifdef PNG_WRITE_COMPRESSED_TEXT_SUPPORTED
-/* This pair of functions encapsulates the operation of (a) compressing a
- * text string, and (b) issuing it later as a series of chunk data writes.
- * The compression_state structure is shared context for these functions
- * set up by the caller to allow access to the relevant local variables.
- *
- * compression_buffer (new in 1.6.0) is just a linked list of zbuffer_size
- * temporary buffers. From 1.6.0 it is retained in png_struct so that it will
- * be correctly freed in the event of a write error (previous implementations
- * just leaked memory.)
- */
-typedef struct
-{
- png_const_bytep input; /* The uncompressed input data */
- png_alloc_size_t input_len; /* Its length */
- png_uint_32 output_len; /* Final compressed length */
- png_byte output[1024]; /* First block of output */
-} compression_state;
-
-static void
-png_text_compress_init(compression_state *comp, png_const_bytep input,
- png_alloc_size_t input_len)
-{
- comp->input = input;
- comp->input_len = input_len;
- comp->output_len = 0;
-}
-
-/* Compress the data in the compression state input */
-static int
-png_text_compress(png_structrp png_ptr, png_uint_32 chunk_name,
- compression_state *comp, png_uint_32 prefix_len)
-{
- int ret;
-
- /* To find the length of the output it is necessary to first compress the
- * input. The result is buffered rather than using the two-pass algorithm
- * that is used on the inflate side; deflate is assumed to be slower and a
- * PNG writer is assumed to have more memory available than a PNG reader.
- *
- * IMPLEMENTATION NOTE: the zlib API deflateBound() can be used to find an
- * upper limit on the output size, but it is always bigger than the input
- * size so it is likely to be more efficient to use this linked-list
- * approach.
- */
- ret = png_deflate_claim(png_ptr, chunk_name, comp->input_len);
-
- if (ret != Z_OK)
- return ret;
-
- /* Set up the compression buffers, we need a loop here to avoid overflowing a
- * uInt. Use ZLIB_IO_MAX to limit the input. The output is always limited
- * by the output buffer size, so there is no need to check that. Since this
- * is ANSI-C we know that an 'int', hence a uInt, is always at least 16 bits
- * in size.
- */
- {
- png_compression_bufferp *end = &png_ptr->zbuffer_list;
- png_alloc_size_t input_len = comp->input_len; /* may be zero! */
- png_uint_32 output_len;
-
- /* zlib updates these for us: */
- png_ptr->zstream.next_in = PNGZ_INPUT_CAST(comp->input);
- png_ptr->zstream.avail_in = 0; /* Set below */
- png_ptr->zstream.next_out = comp->output;
- png_ptr->zstream.avail_out = (sizeof comp->output);
-
- output_len = png_ptr->zstream.avail_out;
-
- do
- {
- uInt avail_in = ZLIB_IO_MAX;
-
- if (avail_in > input_len)
- avail_in = (uInt)input_len;
-
- input_len -= avail_in;
-
- png_ptr->zstream.avail_in = avail_in;
-
- if (png_ptr->zstream.avail_out == 0)
- {
- png_compression_buffer *next;
-
- /* Chunk data is limited to 2^31 bytes in length, so the prefix
- * length must be counted here.
- */
- if (output_len + prefix_len > PNG_UINT_31_MAX)
- {
- ret = Z_MEM_ERROR;
- break;
- }
-
- /* Need a new (malloc'ed) buffer, but there may be one present
- * already.
- */
- next = *end;
- if (next == NULL)
- {
- next = png_voidcast(png_compression_bufferp, png_malloc_base
- (png_ptr, PNG_COMPRESSION_BUFFER_SIZE(png_ptr)));
-
- if (next == NULL)
- {
- ret = Z_MEM_ERROR;
- break;
- }
-
- /* Link in this buffer (so that it will be freed later) */
- next->next = NULL;
- *end = next;
- }
-
- png_ptr->zstream.next_out = next->output;
- png_ptr->zstream.avail_out = png_ptr->zbuffer_size;
- output_len += png_ptr->zstream.avail_out;
-
- /* Move 'end' to the next buffer pointer. */
- end = &next->next;
- }
-
- /* Compress the data */
- ret = deflate(&png_ptr->zstream,
- input_len > 0 ? Z_NO_FLUSH : Z_FINISH);
-
- /* Claw back input data that was not consumed (because avail_in is
- * reset above every time round the loop).
- */
- input_len += png_ptr->zstream.avail_in;
- png_ptr->zstream.avail_in = 0; /* safety */
- }
- while (ret == Z_OK);
-
- /* There may be some space left in the last output buffer. This needs to
- * be subtracted from output_len.
- */
- output_len -= png_ptr->zstream.avail_out;
- png_ptr->zstream.avail_out = 0; /* safety */
- comp->output_len = output_len;
-
- /* Now double check the output length, put in a custom message if it is
- * too long. Otherwise ensure the z_stream::msg pointer is set to
- * something.
- */
- if (output_len + prefix_len >= PNG_UINT_31_MAX)
- {
- png_ptr->zstream.msg = PNGZ_MSG_CAST("compressed data too long");
- ret = Z_MEM_ERROR;
- }
-
- else
- png_zstream_error(png_ptr, ret);
-
- /* Reset zlib for another zTXt/iTXt or image data */
- png_ptr->zowner = 0;
-
- /* The only success case is Z_STREAM_END, input_len must be 0; if not this
- * is an internal error.
- */
- if (ret == Z_STREAM_END && input_len == 0)
- {
-#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
- /* Fix up the deflate header, if required */
- optimize_cmf(comp->output, comp->input_len);
-#endif
- /* But Z_OK is returned, not Z_STREAM_END; this allows the claim
- * function above to return Z_STREAM_END on an error (though it never
- * does in the current versions of zlib.)
- */
- return Z_OK;
- }
-
- else
- return ret;
- }
-}
-
-/* Ship the compressed text out via chunk writes */
-static void
-png_write_compressed_data_out(png_structrp png_ptr, compression_state *comp)
-{
- png_uint_32 output_len = comp->output_len;
- png_const_bytep output = comp->output;
- png_uint_32 avail = (sizeof comp->output);
- png_compression_buffer *next = png_ptr->zbuffer_list;
-
- for (;;)
- {
- if (avail > output_len)
- avail = output_len;
-
- png_write_chunk_data(png_ptr, output, avail);
-
- output_len -= avail;
-
- if (output_len == 0 || next == NULL)
- break;
-
- avail = png_ptr->zbuffer_size;
- output = next->output;
- next = next->next;
- }
-
- /* This is an internal error; 'next' must have been NULL! */
- if (output_len > 0)
- png_error(png_ptr, "error writing ancillary chunked compressed data");
-}
-#endif /* WRITE_COMPRESSED_TEXT */
-
-/* Write the IHDR chunk, and update the png_struct with the necessary
- * information. Note that the rest of this code depends upon this
- * information being correct.
- */
-void /* PRIVATE */
-png_write_IHDR(png_structrp png_ptr, png_uint_32 width, png_uint_32 height,
- int bit_depth, int color_type, int compression_type, int filter_type,
- int interlace_type)
-{
- png_byte buf[13]; /* Buffer to store the IHDR info */
- int is_invalid_depth;
-
- png_debug(1, "in png_write_IHDR");
-
- /* Check that we have valid input data from the application info */
- switch (color_type)
- {
- case PNG_COLOR_TYPE_GRAY:
- switch (bit_depth)
- {
- case 1:
- case 2:
- case 4:
- case 8:
-#ifdef PNG_WRITE_16BIT_SUPPORTED
- case 16:
-#endif
- png_ptr->channels = 1; break;
-
- default:
- png_error(png_ptr,
- "Invalid bit depth for grayscale image");
- }
- break;
-
- case PNG_COLOR_TYPE_RGB:
- is_invalid_depth = (bit_depth != 8);
-#ifdef PNG_WRITE_16BIT_SUPPORTED
- is_invalid_depth = (is_invalid_depth && bit_depth != 16);
-#endif
- if (is_invalid_depth)
- png_error(png_ptr, "Invalid bit depth for RGB image");
-
- png_ptr->channels = 3;
- break;
-
- case PNG_COLOR_TYPE_PALETTE:
- switch (bit_depth)
- {
- case 1:
- case 2:
- case 4:
- case 8:
- png_ptr->channels = 1;
- break;
-
- default:
- png_error(png_ptr, "Invalid bit depth for paletted image");
- }
- break;
-
- case PNG_COLOR_TYPE_GRAY_ALPHA:
- is_invalid_depth = (bit_depth != 8);
-#ifdef PNG_WRITE_16BIT_SUPPORTED
- is_invalid_depth = (is_invalid_depth && bit_depth != 16);
-#endif
- if (is_invalid_depth)
- png_error(png_ptr, "Invalid bit depth for grayscale+alpha image");
-
- png_ptr->channels = 2;
- break;
-
- case PNG_COLOR_TYPE_RGB_ALPHA:
- is_invalid_depth = (bit_depth != 8);
-#ifdef PNG_WRITE_16BIT_SUPPORTED
- is_invalid_depth = (is_invalid_depth && bit_depth != 16);
-#endif
- if (is_invalid_depth)
- png_error(png_ptr, "Invalid bit depth for RGBA image");
-
- png_ptr->channels = 4;
- break;
-
- default:
- png_error(png_ptr, "Invalid image color type specified");
- }
-
- if (compression_type != PNG_COMPRESSION_TYPE_BASE)
- {
- png_warning(png_ptr, "Invalid compression type specified");
- compression_type = PNG_COMPRESSION_TYPE_BASE;
- }
-
- /* Write filter_method 64 (intrapixel differencing) only if
- * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and
- * 2. Libpng did not write a PNG signature (this filter_method is only
- * used in PNG datastreams that are embedded in MNG datastreams) and
- * 3. The application called png_permit_mng_features with a mask that
- * included PNG_FLAG_MNG_FILTER_64 and
- * 4. The filter_method is 64 and
- * 5. The color_type is RGB or RGBA
- */
- if (
-#ifdef PNG_MNG_FEATURES_SUPPORTED
- !((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) != 0 &&
- ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) == 0) &&
- (color_type == PNG_COLOR_TYPE_RGB ||
- color_type == PNG_COLOR_TYPE_RGB_ALPHA) &&
- (filter_type == PNG_INTRAPIXEL_DIFFERENCING)) &&
-#endif
- filter_type != PNG_FILTER_TYPE_BASE)
- {
- png_warning(png_ptr, "Invalid filter type specified");
- filter_type = PNG_FILTER_TYPE_BASE;
- }
-
-#ifdef PNG_WRITE_INTERLACING_SUPPORTED
- if (interlace_type != PNG_INTERLACE_NONE &&
- interlace_type != PNG_INTERLACE_ADAM7)
- {
- png_warning(png_ptr, "Invalid interlace type specified");
- interlace_type = PNG_INTERLACE_ADAM7;
- }
-#else
- interlace_type=PNG_INTERLACE_NONE;
-#endif
-
- /* Save the relevant information */
- png_ptr->bit_depth = (png_byte)bit_depth;
- png_ptr->color_type = (png_byte)color_type;
- png_ptr->interlaced = (png_byte)interlace_type;
-#ifdef PNG_MNG_FEATURES_SUPPORTED
- png_ptr->filter_type = (png_byte)filter_type;
-#endif
- png_ptr->compression_type = (png_byte)compression_type;
- png_ptr->width = width;
- png_ptr->height = height;
-
- png_ptr->pixel_depth = (png_byte)(bit_depth * png_ptr->channels);
- png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, width);
- /* Set the usr info, so any transformations can modify it */
- png_ptr->usr_width = png_ptr->width;
- png_ptr->usr_bit_depth = png_ptr->bit_depth;
- png_ptr->usr_channels = png_ptr->channels;
-
- /* Pack the header information into the buffer */
- png_save_uint_32(buf, width);
- png_save_uint_32(buf + 4, height);
- buf[8] = (png_byte)bit_depth;
- buf[9] = (png_byte)color_type;
- buf[10] = (png_byte)compression_type;
- buf[11] = (png_byte)filter_type;
- buf[12] = (png_byte)interlace_type;
-
- /* Write the chunk */
- png_write_complete_chunk(png_ptr, png_IHDR, buf, 13);
-
-#ifdef PNG_WRITE_APNG_SUPPORTED
- png_ptr->first_frame_width = width;
- png_ptr->first_frame_height = height;
-#endif
-
- if ((png_ptr->do_filter) == PNG_NO_FILTERS)
- {
- if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE ||
- png_ptr->bit_depth < 8)
- png_ptr->do_filter = PNG_FILTER_NONE;
-
- else
- png_ptr->do_filter = PNG_ALL_FILTERS;
- }
-
- png_ptr->mode = PNG_HAVE_IHDR; /* not READY_FOR_ZTXT */
-}
-
-/* Write the palette. We are careful not to trust png_color to be in the
- * correct order for PNG, so people can redefine it to any convenient
- * structure.
- */
-void /* PRIVATE */
-png_write_PLTE(png_structrp png_ptr, png_const_colorp palette,
- png_uint_32 num_pal)
-{
- png_uint_32 max_palette_length, i;
- png_const_colorp pal_ptr;
- png_byte buf[3];
-
- png_debug(1, "in png_write_PLTE");
-
- max_palette_length = (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) ?
- (1 << png_ptr->bit_depth) : PNG_MAX_PALETTE_LENGTH;
-
- if ((
-#ifdef PNG_MNG_FEATURES_SUPPORTED
- (png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) == 0 &&
-#endif
- num_pal == 0) || num_pal > max_palette_length)
- {
- if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
- {
- png_error(png_ptr, "Invalid number of colors in palette");
- }
-
- else
- {
- png_warning(png_ptr, "Invalid number of colors in palette");
- return;
- }
- }
-
- if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) == 0)
- {
- png_warning(png_ptr,
- "Ignoring request to write a PLTE chunk in grayscale PNG");
-
- return;
- }
-
- png_ptr->num_palette = (png_uint_16)num_pal;
- png_debug1(3, "num_palette = %d", png_ptr->num_palette);
-
- png_write_chunk_header(png_ptr, png_PLTE, (png_uint_32)(num_pal * 3));
-#ifdef PNG_POINTER_INDEXING_SUPPORTED
-
- for (i = 0, pal_ptr = palette; i < num_pal; i++, pal_ptr++)
- {
- buf[0] = pal_ptr->red;
- buf[1] = pal_ptr->green;
- buf[2] = pal_ptr->blue;
- png_write_chunk_data(png_ptr, buf, 3);
- }
-
-#else
- /* This is a little slower but some buggy compilers need to do this
- * instead
- */
- pal_ptr=palette;
-
- for (i = 0; i < num_pal; i++)
- {
- buf[0] = pal_ptr[i].red;
- buf[1] = pal_ptr[i].green;
- buf[2] = pal_ptr[i].blue;
- png_write_chunk_data(png_ptr, buf, 3);
- }
-
-#endif
- png_write_chunk_end(png_ptr);
- png_ptr->mode |= PNG_HAVE_PLTE;
-}
-
-/* This is similar to png_text_compress, above, except that it does not require
- * all of the data at once and, instead of buffering the compressed result,
- * writes it as IDAT chunks. Unlike png_text_compress it *can* png_error out
- * because it calls the write interface. As a result it does its own error
- * reporting and does not return an error code. In the event of error it will
- * just call png_error. The input data length may exceed 32-bits. The 'flush'
- * parameter is exactly the same as that to deflate, with the following
- * meanings:
- *
- * Z_NO_FLUSH: normal incremental output of compressed data
- * Z_SYNC_FLUSH: do a SYNC_FLUSH, used by png_write_flush
- * Z_FINISH: this is the end of the input, do a Z_FINISH and clean up
- *
- * The routine manages the acquire and release of the png_ptr->zstream by
- * checking and (at the end) clearing png_ptr->zowner; it does some sanity
- * checks on the 'mode' flags while doing this.
- */
-void /* PRIVATE */
-png_compress_IDAT(png_structrp png_ptr, png_const_bytep input,
- png_alloc_size_t input_len, int flush)
-{
- if (png_ptr->zowner != png_IDAT)
- {
- /* First time. Ensure we have a temporary buffer for compression and
- * trim the buffer list if it has more than one entry to free memory.
- * If 'WRITE_COMPRESSED_TEXT' is not set the list will never have been
- * created at this point, but the check here is quick and safe.
- */
- if (png_ptr->zbuffer_list == NULL)
- {
- png_ptr->zbuffer_list = png_voidcast(png_compression_bufferp,
- png_malloc(png_ptr, PNG_COMPRESSION_BUFFER_SIZE(png_ptr)));
- png_ptr->zbuffer_list->next = NULL;
- }
-
- else
- png_free_buffer_list(png_ptr, &png_ptr->zbuffer_list->next);
-
- /* It is a terminal error if we can't claim the zstream. */
- if (png_deflate_claim(png_ptr, png_IDAT, png_image_size(png_ptr)) != Z_OK)
- png_error(png_ptr, png_ptr->zstream.msg);
-
- /* The output state is maintained in png_ptr->zstream, so it must be
- * initialized here after the claim.
- */
- png_ptr->zstream.next_out = png_ptr->zbuffer_list->output;
- png_ptr->zstream.avail_out = png_ptr->zbuffer_size;
- }
-
- /* Now loop reading and writing until all the input is consumed or an error
- * terminates the operation. The _out values are maintained across calls to
- * this function, but the input must be reset each time.
- */
- png_ptr->zstream.next_in = PNGZ_INPUT_CAST(input);
- png_ptr->zstream.avail_in = 0; /* set below */
- for (;;)
- {
- int ret;
-
- /* INPUT: from the row data */
- uInt avail = ZLIB_IO_MAX;
-
- if (avail > input_len)
- avail = (uInt)input_len; /* safe because of the check */
-
- png_ptr->zstream.avail_in = avail;
- input_len -= avail;
-
- ret = deflate(&png_ptr->zstream, input_len > 0 ? Z_NO_FLUSH : flush);
-
- /* Include as-yet unconsumed input */
- input_len += png_ptr->zstream.avail_in;
- png_ptr->zstream.avail_in = 0;
-
- /* OUTPUT: write complete IDAT chunks when avail_out drops to zero. Note
- * that these two zstream fields are preserved across the calls, therefore
- * there is no need to set these up on entry to the loop.
- */
- if (png_ptr->zstream.avail_out == 0)
- {
- png_bytep data = png_ptr->zbuffer_list->output;
- uInt size = png_ptr->zbuffer_size;
-
- /* Write an IDAT containing the data then reset the buffer. The
- * first IDAT may need deflate header optimization.
- */
-#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
- if ((png_ptr->mode & PNG_HAVE_IDAT) == 0 &&
- png_ptr->compression_type == PNG_COMPRESSION_TYPE_BASE)
- optimize_cmf(data, png_image_size(png_ptr));
-#endif
-
- if (size > 0)
-#ifdef PNG_WRITE_APNG_SUPPORTED
- {
- if (png_ptr->num_frames_written == 0)
-#endif
- png_write_complete_chunk(png_ptr, png_IDAT, data, size);
-#ifdef PNG_WRITE_APNG_SUPPORTED
- else
- png_write_fdAT(png_ptr, data, size);
- }
-#endif /* WRITE_APNG */
-
- png_ptr->mode |= PNG_HAVE_IDAT;
-
- png_ptr->zstream.next_out = data;
- png_ptr->zstream.avail_out = size;
-
- /* For SYNC_FLUSH or FINISH it is essential to keep calling zlib with
- * the same flush parameter until it has finished output, for NO_FLUSH
- * it doesn't matter.
- */
- if (ret == Z_OK && flush != Z_NO_FLUSH)
- continue;
- }
-
- /* The order of these checks doesn't matter much; it just affects which
- * possible error might be detected if multiple things go wrong at once.
- */
- if (ret == Z_OK) /* most likely return code! */
- {
- /* If all the input has been consumed then just return. If Z_FINISH
- * was used as the flush parameter something has gone wrong if we get
- * here.
- */
- if (input_len == 0)
- {
- if (flush == Z_FINISH)
- png_error(png_ptr, "Z_OK on Z_FINISH with output space");
-
- return;
- }
- }
-
- else if (ret == Z_STREAM_END && flush == Z_FINISH)
- {
- /* This is the end of the IDAT data; any pending output must be
- * flushed. For small PNG files we may still be at the beginning.
- */
- png_bytep data = png_ptr->zbuffer_list->output;
- uInt size = png_ptr->zbuffer_size - png_ptr->zstream.avail_out;
-
-#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
- if ((png_ptr->mode & PNG_HAVE_IDAT) == 0 &&
- png_ptr->compression_type == PNG_COMPRESSION_TYPE_BASE)
- optimize_cmf(data, png_image_size(png_ptr));
-#endif
-
- if (size > 0)
-#ifdef PNG_WRITE_APNG_SUPPORTED
- {
- if (png_ptr->num_frames_written == 0)
-#endif
- png_write_complete_chunk(png_ptr, png_IDAT, data, size);
-#ifdef PNG_WRITE_APNG_SUPPORTED
- else
- png_write_fdAT(png_ptr, data, size);
- }
-#endif /* WRITE_APNG */
-
- png_ptr->zstream.avail_out = 0;
- png_ptr->zstream.next_out = NULL;
- png_ptr->mode |= PNG_HAVE_IDAT | PNG_AFTER_IDAT;
-
- png_ptr->zowner = 0; /* Release the stream */
- return;
- }
-
- else
- {
- /* This is an error condition. */
- png_zstream_error(png_ptr, ret);
- png_error(png_ptr, png_ptr->zstream.msg);
- }
- }
-}
-
-/* Write an IEND chunk */
-void /* PRIVATE */
-png_write_IEND(png_structrp png_ptr)
-{
- png_debug(1, "in png_write_IEND");
-
- png_write_complete_chunk(png_ptr, png_IEND, NULL, 0);
- png_ptr->mode |= PNG_HAVE_IEND;
-}
-
-#ifdef PNG_WRITE_gAMA_SUPPORTED
-/* Write a gAMA chunk */
-void /* PRIVATE */
-png_write_gAMA_fixed(png_structrp png_ptr, png_fixed_point file_gamma)
-{
- png_byte buf[4];
-
- png_debug(1, "in png_write_gAMA");
-
- /* file_gamma is saved in 1/100,000ths */
- png_save_uint_32(buf, (png_uint_32)file_gamma);
- png_write_complete_chunk(png_ptr, png_gAMA, buf, 4);
-}
-#endif
-
-#ifdef PNG_WRITE_sRGB_SUPPORTED
-/* Write a sRGB chunk */
-void /* PRIVATE */
-png_write_sRGB(png_structrp png_ptr, int srgb_intent)
-{
- png_byte buf[1];
-
- png_debug(1, "in png_write_sRGB");
-
- if (srgb_intent >= PNG_sRGB_INTENT_LAST)
- png_warning(png_ptr,
- "Invalid sRGB rendering intent specified");
-
- buf[0]=(png_byte)srgb_intent;
- png_write_complete_chunk(png_ptr, png_sRGB, buf, 1);
-}
-#endif
-
-#ifdef PNG_WRITE_iCCP_SUPPORTED
-/* Write an iCCP chunk */
-void /* PRIVATE */
-png_write_iCCP(png_structrp png_ptr, png_const_charp name,
- png_const_bytep profile)
-{
- png_uint_32 name_len;
- png_uint_32 profile_len;
- png_byte new_name[81]; /* 1 byte for the compression byte */
- compression_state comp;
- png_uint_32 temp;
-
- png_debug(1, "in png_write_iCCP");
-
- /* These are all internal problems: the profile should have been checked
- * before when it was stored.
- */
- if (profile == NULL)
- png_error(png_ptr, "No profile for iCCP chunk"); /* internal error */
-
- profile_len = png_get_uint_32(profile);
-
- if (profile_len < 132)
- png_error(png_ptr, "ICC profile too short");
-
- temp = (png_uint_32) (*(profile+8));
- if (temp > 3 && (profile_len & 0x03))
- png_error(png_ptr, "ICC profile length invalid (not a multiple of 4)");
-
- {
- png_uint_32 embedded_profile_len = png_get_uint_32(profile);
-
- if (profile_len != embedded_profile_len)
- png_error(png_ptr, "Profile length does not match profile");
- }
-
- name_len = png_check_keyword(png_ptr, name, new_name);
-
- if (name_len == 0)
- png_error(png_ptr, "iCCP: invalid keyword");
-
- new_name[++name_len] = PNG_COMPRESSION_TYPE_BASE;
-
- /* Make sure we include the NULL after the name and the compression type */
- ++name_len;
-
- png_text_compress_init(&comp, profile, profile_len);
-
- /* Allow for keyword terminator and compression byte */
- if (png_text_compress(png_ptr, png_iCCP, &comp, name_len) != Z_OK)
- png_error(png_ptr, png_ptr->zstream.msg);
-
- png_write_chunk_header(png_ptr, png_iCCP, name_len + comp.output_len);
-
- png_write_chunk_data(png_ptr, new_name, name_len);
-
- png_write_compressed_data_out(png_ptr, &comp);
-
- png_write_chunk_end(png_ptr);
-}
-#endif
-
-#ifdef PNG_WRITE_sPLT_SUPPORTED
-/* Write a sPLT chunk */
-void /* PRIVATE */
-png_write_sPLT(png_structrp png_ptr, png_const_sPLT_tp spalette)
-{
- png_uint_32 name_len;
- png_byte new_name[80];
- png_byte entrybuf[10];
- size_t entry_size = (spalette->depth == 8 ? 6 : 10);
- size_t palette_size = entry_size * (size_t)spalette->nentries;
- png_sPLT_entryp ep;
-#ifndef PNG_POINTER_INDEXING_SUPPORTED
- int i;
-#endif
-
- png_debug(1, "in png_write_sPLT");
-
- name_len = png_check_keyword(png_ptr, spalette->name, new_name);
-
- if (name_len == 0)
- png_error(png_ptr, "sPLT: invalid keyword");
-
- /* Make sure we include the NULL after the name */
- png_write_chunk_header(png_ptr, png_sPLT,
- (png_uint_32)(name_len + 2 + palette_size));
-
- png_write_chunk_data(png_ptr, (png_bytep)new_name, (size_t)(name_len + 1));
-
- png_write_chunk_data(png_ptr, &spalette->depth, 1);
-
- /* Loop through each palette entry, writing appropriately */
-#ifdef PNG_POINTER_INDEXING_SUPPORTED
- for (ep = spalette->entries; ep<spalette->entries + spalette->nentries; ep++)
- {
- if (spalette->depth == 8)
- {
- entrybuf[0] = (png_byte)ep->red;
- entrybuf[1] = (png_byte)ep->green;
- entrybuf[2] = (png_byte)ep->blue;
- entrybuf[3] = (png_byte)ep->alpha;
- png_save_uint_16(entrybuf + 4, ep->frequency);
- }
-
- else
- {
- png_save_uint_16(entrybuf + 0, ep->red);
- png_save_uint_16(entrybuf + 2, ep->green);
- png_save_uint_16(entrybuf + 4, ep->blue);
- png_save_uint_16(entrybuf + 6, ep->alpha);
- png_save_uint_16(entrybuf + 8, ep->frequency);
- }
-
- png_write_chunk_data(png_ptr, entrybuf, entry_size);
- }
-#else
- ep=spalette->entries;
- for (i = 0; i>spalette->nentries; i++)
- {
- if (spalette->depth == 8)
- {
- entrybuf[0] = (png_byte)ep[i].red;
- entrybuf[1] = (png_byte)ep[i].green;
- entrybuf[2] = (png_byte)ep[i].blue;
- entrybuf[3] = (png_byte)ep[i].alpha;
- png_save_uint_16(entrybuf + 4, ep[i].frequency);
- }
-
- else
- {
- png_save_uint_16(entrybuf + 0, ep[i].red);
- png_save_uint_16(entrybuf + 2, ep[i].green);
- png_save_uint_16(entrybuf + 4, ep[i].blue);
- png_save_uint_16(entrybuf + 6, ep[i].alpha);
- png_save_uint_16(entrybuf + 8, ep[i].frequency);
- }
-
- png_write_chunk_data(png_ptr, entrybuf, entry_size);
- }
-#endif
-
- png_write_chunk_end(png_ptr);
-}
-#endif
-
-#ifdef PNG_WRITE_sBIT_SUPPORTED
-/* Write the sBIT chunk */
-void /* PRIVATE */
-png_write_sBIT(png_structrp png_ptr, png_const_color_8p sbit, int color_type)
-{
- png_byte buf[4];
- size_t size;
-
- png_debug(1, "in png_write_sBIT");
-
- /* Make sure we don't depend upon the order of PNG_COLOR_8 */
- if ((color_type & PNG_COLOR_MASK_COLOR) != 0)
- {
- png_byte maxbits;
-
- maxbits = (png_byte)(color_type==PNG_COLOR_TYPE_PALETTE ? 8 :
- png_ptr->usr_bit_depth);
-
- if (sbit->red == 0 || sbit->red > maxbits ||
- sbit->green == 0 || sbit->green > maxbits ||
- sbit->blue == 0 || sbit->blue > maxbits)
- {
- png_warning(png_ptr, "Invalid sBIT depth specified");
- return;
- }
-
- buf[0] = sbit->red;
- buf[1] = sbit->green;
- buf[2] = sbit->blue;
- size = 3;
- }
-
- else
- {
- if (sbit->gray == 0 || sbit->gray > png_ptr->usr_bit_depth)
- {
- png_warning(png_ptr, "Invalid sBIT depth specified");
- return;
- }
-
- buf[0] = sbit->gray;
- size = 1;
- }
-
- if ((color_type & PNG_COLOR_MASK_ALPHA) != 0)
- {
- if (sbit->alpha == 0 || sbit->alpha > png_ptr->usr_bit_depth)
- {
- png_warning(png_ptr, "Invalid sBIT depth specified");
- return;
- }
-
- buf[size++] = sbit->alpha;
- }
-
- png_write_complete_chunk(png_ptr, png_sBIT, buf, size);
-}
-#endif
-
-#ifdef PNG_WRITE_cHRM_SUPPORTED
-/* Write the cHRM chunk */
-void /* PRIVATE */
-png_write_cHRM_fixed(png_structrp png_ptr, const png_xy *xy)
-{
- png_byte buf[32];
-
- png_debug(1, "in png_write_cHRM");
-
- /* Each value is saved in 1/100,000ths */
- png_save_int_32(buf, xy->whitex);
- png_save_int_32(buf + 4, xy->whitey);
-
- png_save_int_32(buf + 8, xy->redx);
- png_save_int_32(buf + 12, xy->redy);
-
- png_save_int_32(buf + 16, xy->greenx);
- png_save_int_32(buf + 20, xy->greeny);
-
- png_save_int_32(buf + 24, xy->bluex);
- png_save_int_32(buf + 28, xy->bluey);
-
- png_write_complete_chunk(png_ptr, png_cHRM, buf, 32);
-}
-#endif
-
-#ifdef PNG_WRITE_tRNS_SUPPORTED
-/* Write the tRNS chunk */
-void /* PRIVATE */
-png_write_tRNS(png_structrp png_ptr, png_const_bytep trans_alpha,
- png_const_color_16p tran, int num_trans, int color_type)
-{
- png_byte buf[6];
-
- png_debug(1, "in png_write_tRNS");
-
- if (color_type == PNG_COLOR_TYPE_PALETTE)
- {
- if (num_trans <= 0 || num_trans > (int)png_ptr->num_palette)
- {
- png_app_warning(png_ptr,
- "Invalid number of transparent colors specified");
- return;
- }
-
- /* Write the chunk out as it is */
- png_write_complete_chunk(png_ptr, png_tRNS, trans_alpha,
- (size_t)num_trans);
- }
-
- else if (color_type == PNG_COLOR_TYPE_GRAY)
- {
- /* One 16-bit value */
- if (tran->gray >= (1 << png_ptr->bit_depth))
- {
- png_app_warning(png_ptr,
- "Ignoring attempt to write tRNS chunk out-of-range for bit_depth");
-
- return;
- }
-
- png_save_uint_16(buf, tran->gray);
- png_write_complete_chunk(png_ptr, png_tRNS, buf, 2);
- }
-
- else if (color_type == PNG_COLOR_TYPE_RGB)
- {
- /* Three 16-bit values */
- png_save_uint_16(buf, tran->red);
- png_save_uint_16(buf + 2, tran->green);
- png_save_uint_16(buf + 4, tran->blue);
-#ifdef PNG_WRITE_16BIT_SUPPORTED
- if (png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4]) != 0)
-#else
- if ((buf[0] | buf[2] | buf[4]) != 0)
-#endif
- {
- png_app_warning(png_ptr,
- "Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8");
- return;
- }
-
- png_write_complete_chunk(png_ptr, png_tRNS, buf, 6);
- }
-
- else
- {
- png_app_warning(png_ptr, "Can't write tRNS with an alpha channel");
- }
-}
-#endif
-
-#ifdef PNG_WRITE_bKGD_SUPPORTED
-/* Write the background chunk */
-void /* PRIVATE */
-png_write_bKGD(png_structrp png_ptr, png_const_color_16p back, int color_type)
-{
- png_byte buf[6];
-
- png_debug(1, "in png_write_bKGD");
-
- if (color_type == PNG_COLOR_TYPE_PALETTE)
- {
- if (
-#ifdef PNG_MNG_FEATURES_SUPPORTED
- (png_ptr->num_palette != 0 ||
- (png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) == 0) &&
-#endif
- back->index >= png_ptr->num_palette)
- {
- png_warning(png_ptr, "Invalid background palette index");
- return;
- }
-
- buf[0] = back->index;
- png_write_complete_chunk(png_ptr, png_bKGD, buf, 1);
- }
-
- else if ((color_type & PNG_COLOR_MASK_COLOR) != 0)
- {
- png_save_uint_16(buf, back->red);
- png_save_uint_16(buf + 2, back->green);
- png_save_uint_16(buf + 4, back->blue);
-#ifdef PNG_WRITE_16BIT_SUPPORTED
- if (png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4]) != 0)
-#else
- if ((buf[0] | buf[2] | buf[4]) != 0)
-#endif
- {
- png_warning(png_ptr,
- "Ignoring attempt to write 16-bit bKGD chunk "
- "when bit_depth is 8");
-
- return;
- }
-
- png_write_complete_chunk(png_ptr, png_bKGD, buf, 6);
- }
-
- else
- {
- if (back->gray >= (1 << png_ptr->bit_depth))
- {
- png_warning(png_ptr,
- "Ignoring attempt to write bKGD chunk out-of-range for bit_depth");
-
- return;
- }
-
- png_save_uint_16(buf, back->gray);
- png_write_complete_chunk(png_ptr, png_bKGD, buf, 2);
- }
-}
-#endif
-
-#ifdef PNG_WRITE_cICP_SUPPORTED
-/* Write the cICP data */
-void /* PRIVATE */
-png_write_cICP(png_structrp png_ptr,
- png_byte colour_primaries, png_byte transfer_function,
- png_byte matrix_coefficients, png_byte video_full_range_flag)
-{
- png_byte buf[4];
-
- png_debug(1, "in png_write_cICP");
-
- png_write_chunk_header(png_ptr, png_cICP, 4);
-
- buf[0] = colour_primaries;
- buf[1] = transfer_function;
- buf[2] = matrix_coefficients;
- buf[3] = video_full_range_flag;
- png_write_chunk_data(png_ptr, buf, 4);
-
- png_write_chunk_end(png_ptr);
-}
-#endif
-
-#ifdef PNG_WRITE_cLLI_SUPPORTED
-void /* PRIVATE */
-png_write_cLLI_fixed(png_structrp png_ptr, png_uint_32 maxCLL,
- png_uint_32 maxFALL)
-{
- png_byte buf[8];
-
- png_debug(1, "in png_write_cLLI_fixed");
-
- png_save_uint_32(buf, maxCLL);
- png_save_uint_32(buf + 4, maxFALL);
-
- png_write_complete_chunk(png_ptr, png_cLLI, buf, 8);
-}
-#endif
-
-#ifdef PNG_WRITE_mDCV_SUPPORTED
-void /* PRIVATE */
-png_write_mDCV_fixed(png_structrp png_ptr,
- png_uint_16 red_x, png_uint_16 red_y,
- png_uint_16 green_x, png_uint_16 green_y,
- png_uint_16 blue_x, png_uint_16 blue_y,
- png_uint_16 white_x, png_uint_16 white_y,
- png_uint_32 maxDL, png_uint_32 minDL)
-{
- png_byte buf[24];
-
- png_debug(1, "in png_write_mDCV_fixed");
-
- png_save_uint_16(buf + 0, red_x);
- png_save_uint_16(buf + 2, red_y);
- png_save_uint_16(buf + 4, green_x);
- png_save_uint_16(buf + 6, green_y);
- png_save_uint_16(buf + 8, blue_x);
- png_save_uint_16(buf + 10, blue_y);
- png_save_uint_16(buf + 12, white_x);
- png_save_uint_16(buf + 14, white_y);
- png_save_uint_32(buf + 16, maxDL);
- png_save_uint_32(buf + 20, minDL);
-
- png_write_complete_chunk(png_ptr, png_mDCV, buf, 24);
-}
-#endif
-
-#ifdef PNG_WRITE_eXIf_SUPPORTED
-/* Write the Exif data */
-void /* PRIVATE */
-png_write_eXIf(png_structrp png_ptr, png_bytep exif, int num_exif)
-{
- int i;
- png_byte buf[1];
-
- png_debug(1, "in png_write_eXIf");
-
- png_write_chunk_header(png_ptr, png_eXIf, (png_uint_32)(num_exif));
-
- for (i = 0; i < num_exif; i++)
- {
- buf[0] = exif[i];
- png_write_chunk_data(png_ptr, buf, 1);
- }
-
- png_write_chunk_end(png_ptr);
-}
-#endif
-
-#ifdef PNG_WRITE_hIST_SUPPORTED
-/* Write the histogram */
-void /* PRIVATE */
-png_write_hIST(png_structrp png_ptr, png_const_uint_16p hist, int num_hist)
-{
- int i;
- png_byte buf[3];
-
- png_debug(1, "in png_write_hIST");
-
- if (num_hist > (int)png_ptr->num_palette)
- {
- png_debug2(3, "num_hist = %d, num_palette = %d", num_hist,
- png_ptr->num_palette);
-
- png_warning(png_ptr, "Invalid number of histogram entries specified");
- return;
- }
-
- png_write_chunk_header(png_ptr, png_hIST, (png_uint_32)(num_hist * 2));
-
- for (i = 0; i < num_hist; i++)
- {
- png_save_uint_16(buf, hist[i]);
- png_write_chunk_data(png_ptr, buf, 2);
- }
-
- png_write_chunk_end(png_ptr);
-}
-#endif
-
-#ifdef PNG_WRITE_tEXt_SUPPORTED
-/* Write a tEXt chunk */
-void /* PRIVATE */
-png_write_tEXt(png_structrp png_ptr, png_const_charp key, png_const_charp text,
- size_t text_len)
-{
- png_uint_32 key_len;
- png_byte new_key[80];
-
- png_debug(1, "in png_write_tEXt");
-
- key_len = png_check_keyword(png_ptr, key, new_key);
-
- if (key_len == 0)
- png_error(png_ptr, "tEXt: invalid keyword");
-
- if (text == NULL || *text == '\0')
- text_len = 0;
-
- else
- text_len = strlen(text);
-
- if (text_len > PNG_UINT_31_MAX - (key_len+1))
- png_error(png_ptr, "tEXt: text too long");
-
- /* Make sure we include the 0 after the key */
- png_write_chunk_header(png_ptr, png_tEXt,
- (png_uint_32)/*checked above*/(key_len + text_len + 1));
- /*
- * We leave it to the application to meet PNG-1.0 requirements on the
- * contents of the text. PNG-1.0 through PNG-1.2 discourage the use of
- * any non-Latin-1 characters except for NEWLINE. ISO PNG will forbid them.
- * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG.
- */
- png_write_chunk_data(png_ptr, new_key, key_len + 1);
-
- if (text_len != 0)
- png_write_chunk_data(png_ptr, (png_const_bytep)text, text_len);
-
- png_write_chunk_end(png_ptr);
-}
-#endif
-
-#ifdef PNG_WRITE_zTXt_SUPPORTED
-/* Write a compressed text chunk */
-void /* PRIVATE */
-png_write_zTXt(png_structrp png_ptr, png_const_charp key, png_const_charp text,
- int compression)
-{
- png_uint_32 key_len;
- png_byte new_key[81];
- compression_state comp;
-
- png_debug(1, "in png_write_zTXt");
-
- if (compression == PNG_TEXT_COMPRESSION_NONE)
- {
- png_write_tEXt(png_ptr, key, text, 0);
- return;
- }
-
- if (compression != PNG_TEXT_COMPRESSION_zTXt)
- png_error(png_ptr, "zTXt: invalid compression type");
-
- key_len = png_check_keyword(png_ptr, key, new_key);
-
- if (key_len == 0)
- png_error(png_ptr, "zTXt: invalid keyword");
-
- /* Add the compression method and 1 for the keyword separator. */
- new_key[++key_len] = PNG_COMPRESSION_TYPE_BASE;
- ++key_len;
-
- /* Compute the compressed data; do it now for the length */
- png_text_compress_init(&comp, (png_const_bytep)text,
- text == NULL ? 0 : strlen(text));
-
- if (png_text_compress(png_ptr, png_zTXt, &comp, key_len) != Z_OK)
- png_error(png_ptr, png_ptr->zstream.msg);
-
- /* Write start of chunk */
- png_write_chunk_header(png_ptr, png_zTXt, key_len + comp.output_len);
-
- /* Write key */
- png_write_chunk_data(png_ptr, new_key, key_len);
-
- /* Write the compressed data */
- png_write_compressed_data_out(png_ptr, &comp);
-
- /* Close the chunk */
- png_write_chunk_end(png_ptr);
-}
-#endif
-
-#ifdef PNG_WRITE_iTXt_SUPPORTED
-/* Write an iTXt chunk */
-void /* PRIVATE */
-png_write_iTXt(png_structrp png_ptr, int compression, png_const_charp key,
- png_const_charp lang, png_const_charp lang_key, png_const_charp text)
-{
- png_uint_32 key_len, prefix_len;
- size_t lang_len, lang_key_len;
- png_byte new_key[82];
- compression_state comp;
-
- png_debug(1, "in png_write_iTXt");
-
- key_len = png_check_keyword(png_ptr, key, new_key);
-
- if (key_len == 0)
- png_error(png_ptr, "iTXt: invalid keyword");
-
- /* Set the compression flag */
- switch (compression)
- {
- case PNG_ITXT_COMPRESSION_NONE:
- case PNG_TEXT_COMPRESSION_NONE:
- compression = new_key[++key_len] = 0; /* no compression */
- break;
-
- case PNG_TEXT_COMPRESSION_zTXt:
- case PNG_ITXT_COMPRESSION_zTXt:
- compression = new_key[++key_len] = 1; /* compressed */
- break;
-
- default:
- png_error(png_ptr, "iTXt: invalid compression");
- }
-
- new_key[++key_len] = PNG_COMPRESSION_TYPE_BASE;
- ++key_len; /* for the keywod separator */
-
- /* We leave it to the application to meet PNG-1.0 requirements on the
- * contents of the text. PNG-1.0 through PNG-1.2 discourage the use of
- * any non-Latin-1 characters except for NEWLINE. ISO PNG, however,
- * specifies that the text is UTF-8 and this really doesn't require any
- * checking.
- *
- * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG.
- *
- * TODO: validate the language tag correctly (see the spec.)
- */
- if (lang == NULL) lang = ""; /* empty language is valid */
- lang_len = strlen(lang)+1;
- if (lang_key == NULL) lang_key = ""; /* may be empty */
- lang_key_len = strlen(lang_key)+1;
- if (text == NULL) text = ""; /* may be empty */
-
- prefix_len = key_len;
- if (lang_len > PNG_UINT_31_MAX-prefix_len)
- prefix_len = PNG_UINT_31_MAX;
- else
- prefix_len = (png_uint_32)(prefix_len + lang_len);
-
- if (lang_key_len > PNG_UINT_31_MAX-prefix_len)
- prefix_len = PNG_UINT_31_MAX;
- else
- prefix_len = (png_uint_32)(prefix_len + lang_key_len);
-
- png_text_compress_init(&comp, (png_const_bytep)text, strlen(text));
-
- if (compression != 0)
- {
- if (png_text_compress(png_ptr, png_iTXt, &comp, prefix_len) != Z_OK)
- png_error(png_ptr, png_ptr->zstream.msg);
- }
-
- else
- {
- if (comp.input_len > PNG_UINT_31_MAX-prefix_len)
- png_error(png_ptr, "iTXt: uncompressed text too long");
-
- /* So the string will fit in a chunk: */
- comp.output_len = (png_uint_32)/*SAFE*/comp.input_len;
- }
-
- png_write_chunk_header(png_ptr, png_iTXt, comp.output_len + prefix_len);
-
- png_write_chunk_data(png_ptr, new_key, key_len);
-
- png_write_chunk_data(png_ptr, (png_const_bytep)lang, lang_len);
-
- png_write_chunk_data(png_ptr, (png_const_bytep)lang_key, lang_key_len);
-
- if (compression != 0)
- png_write_compressed_data_out(png_ptr, &comp);
-
- else
- png_write_chunk_data(png_ptr, (png_const_bytep)text, comp.output_len);
-
- png_write_chunk_end(png_ptr);
-}
-#endif
-
-#ifdef PNG_WRITE_oFFs_SUPPORTED
-/* Write the oFFs chunk */
-void /* PRIVATE */
-png_write_oFFs(png_structrp png_ptr, png_int_32 x_offset, png_int_32 y_offset,
- int unit_type)
-{
- png_byte buf[9];
-
- png_debug(1, "in png_write_oFFs");
-
- if (unit_type >= PNG_OFFSET_LAST)
- png_warning(png_ptr, "Unrecognized unit type for oFFs chunk");
-
- png_save_int_32(buf, x_offset);
- png_save_int_32(buf + 4, y_offset);
- buf[8] = (png_byte)unit_type;
-
- png_write_complete_chunk(png_ptr, png_oFFs, buf, 9);
-}
-#endif
-#ifdef PNG_WRITE_pCAL_SUPPORTED
-/* Write the pCAL chunk (described in the PNG extensions document) */
-void /* PRIVATE */
-png_write_pCAL(png_structrp png_ptr, png_charp purpose, png_int_32 X0,
- png_int_32 X1, int type, int nparams, png_const_charp units,
- png_charpp params)
-{
- png_uint_32 purpose_len;
- size_t units_len, total_len;
- size_t *params_len;
- png_byte buf[10];
- png_byte new_purpose[80];
- int i;
-
- png_debug1(1, "in png_write_pCAL (%d parameters)", nparams);
-
- if (type >= PNG_EQUATION_LAST)
- png_error(png_ptr, "Unrecognized equation type for pCAL chunk");
-
- purpose_len = png_check_keyword(png_ptr, purpose, new_purpose);
-
- if (purpose_len == 0)
- png_error(png_ptr, "pCAL: invalid keyword");
-
- ++purpose_len; /* terminator */
-
- png_debug1(3, "pCAL purpose length = %d", (int)purpose_len);
- units_len = strlen(units) + (nparams == 0 ? 0 : 1);
- png_debug1(3, "pCAL units length = %d", (int)units_len);
- total_len = purpose_len + units_len + 10;
-
- params_len = (size_t *)png_malloc(png_ptr,
- (png_alloc_size_t)((png_alloc_size_t)nparams * (sizeof (size_t))));
-
- /* Find the length of each parameter, making sure we don't count the
- * null terminator for the last parameter.
- */
- for (i = 0; i < nparams; i++)
- {
- params_len[i] = strlen(params[i]) + (i == nparams - 1 ? 0 : 1);
- png_debug2(3, "pCAL parameter %d length = %lu", i,
- (unsigned long)params_len[i]);
- total_len += params_len[i];
- }
-
- png_debug1(3, "pCAL total length = %d", (int)total_len);
- png_write_chunk_header(png_ptr, png_pCAL, (png_uint_32)total_len);
- png_write_chunk_data(png_ptr, new_purpose, purpose_len);
- png_save_int_32(buf, X0);
- png_save_int_32(buf + 4, X1);
- buf[8] = (png_byte)type;
- buf[9] = (png_byte)nparams;
- png_write_chunk_data(png_ptr, buf, 10);
- png_write_chunk_data(png_ptr, (png_const_bytep)units, (size_t)units_len);
-
- for (i = 0; i < nparams; i++)
- {
- png_write_chunk_data(png_ptr, (png_const_bytep)params[i], params_len[i]);
- }
-
- png_free(png_ptr, params_len);
- png_write_chunk_end(png_ptr);
-}
-#endif
-
-#ifdef PNG_WRITE_sCAL_SUPPORTED
-/* Write the sCAL chunk */
-void /* PRIVATE */
-png_write_sCAL_s(png_structrp png_ptr, int unit, png_const_charp width,
- png_const_charp height)
-{
- png_byte buf[64];
- size_t wlen, hlen, total_len;
-
- png_debug(1, "in png_write_sCAL_s");
-
- wlen = strlen(width);
- hlen = strlen(height);
- total_len = wlen + hlen + 2;
-
- if (total_len > 64)
- {
- png_warning(png_ptr, "Can't write sCAL (buffer too small)");
- return;
- }
-
- buf[0] = (png_byte)unit;
- memcpy(buf + 1, width, wlen + 1); /* Append the '\0' here */
- memcpy(buf + wlen + 2, height, hlen); /* Do NOT append the '\0' here */
-
- png_debug1(3, "sCAL total length = %u", (unsigned int)total_len);
- png_write_complete_chunk(png_ptr, png_sCAL, buf, total_len);
-}
-#endif
-
-#ifdef PNG_WRITE_pHYs_SUPPORTED
-/* Write the pHYs chunk */
-void /* PRIVATE */
-png_write_pHYs(png_structrp png_ptr, png_uint_32 x_pixels_per_unit,
- png_uint_32 y_pixels_per_unit,
- int unit_type)
-{
- png_byte buf[9];
-
- png_debug(1, "in png_write_pHYs");
-
- if (unit_type >= PNG_RESOLUTION_LAST)
- png_warning(png_ptr, "Unrecognized unit type for pHYs chunk");
-
- png_save_uint_32(buf, x_pixels_per_unit);
- png_save_uint_32(buf + 4, y_pixels_per_unit);
- buf[8] = (png_byte)unit_type;
-
- png_write_complete_chunk(png_ptr, png_pHYs, buf, 9);
-}
-#endif
-
-#ifdef PNG_WRITE_tIME_SUPPORTED
-/* Write the tIME chunk. Use either png_convert_from_struct_tm()
- * or png_convert_from_time_t(), or fill in the structure yourself.
- */
-void /* PRIVATE */
-png_write_tIME(png_structrp png_ptr, png_const_timep mod_time)
-{
- png_byte buf[7];
-
- png_debug(1, "in png_write_tIME");
-
- if (mod_time->month > 12 || mod_time->month < 1 ||
- mod_time->day > 31 || mod_time->day < 1 ||
- mod_time->hour > 23 || mod_time->second > 60)
- {
- png_warning(png_ptr, "Invalid time specified for tIME chunk");
- return;
- }
-
- png_save_uint_16(buf, mod_time->year);
- buf[2] = mod_time->month;
- buf[3] = mod_time->day;
- buf[4] = mod_time->hour;
- buf[5] = mod_time->minute;
- buf[6] = mod_time->second;
-
- png_write_complete_chunk(png_ptr, png_tIME, buf, 7);
-}
-#endif
-
-#ifdef PNG_WRITE_APNG_SUPPORTED
-void /* PRIVATE */
-png_write_acTL(png_structp png_ptr,
- png_uint_32 num_frames, png_uint_32 num_plays)
-{
- png_byte buf[8];
-
- png_debug(1, "in png_write_acTL");
-
- png_ptr->num_frames_to_write = num_frames;
-
- if ((png_ptr->apng_flags & PNG_FIRST_FRAME_HIDDEN) != 0)
- num_frames--;
-
- png_save_uint_32(buf, num_frames);
- png_save_uint_32(buf + 4, num_plays);
-
- png_write_complete_chunk(png_ptr, png_acTL, buf, 8);
-}
-
-void /* PRIVATE */
-png_write_fcTL(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
- png_uint_32 x_offset, png_uint_32 y_offset,
- png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op,
- png_byte blend_op)
-{
- png_byte buf[26];
-
- png_debug(1, "in png_write_fcTL");
-
- if (png_ptr->num_frames_written == 0 && (x_offset != 0 || y_offset != 0))
- png_error(png_ptr, "x and/or y offset for the first frame aren't 0");
- if (png_ptr->num_frames_written == 0 &&
- (width != png_ptr->first_frame_width ||
- height != png_ptr->first_frame_height))
- png_error(png_ptr, "width and/or height in the first frame's fcTL "
- "don't match the ones in IHDR");
-
- /* more error checking */
- png_ensure_fcTL_is_valid(png_ptr, width, height, x_offset, y_offset,
- delay_num, delay_den, dispose_op, blend_op);
-
- png_save_uint_32(buf, png_ptr->next_seq_num);
- png_save_uint_32(buf + 4, width);
- png_save_uint_32(buf + 8, height);
- png_save_uint_32(buf + 12, x_offset);
- png_save_uint_32(buf + 16, y_offset);
- png_save_uint_16(buf + 20, delay_num);
- png_save_uint_16(buf + 22, delay_den);
- buf[24] = dispose_op;
- buf[25] = blend_op;
-
- png_write_complete_chunk(png_ptr, png_fcTL, buf, 26);
-
- png_ptr->next_seq_num++;
-}
-
-void /* PRIVATE */
-png_write_fdAT(png_structp png_ptr,
- png_const_bytep data, size_t length)
-{
- png_byte buf[4];
-
- png_write_chunk_header(png_ptr, png_fdAT, (png_uint_32)(4 + length));
-
- png_save_uint_32(buf, png_ptr->next_seq_num);
- png_write_chunk_data(png_ptr, buf, 4);
-
- png_write_chunk_data(png_ptr, data, length);
-
- png_write_chunk_end(png_ptr);
-
- png_ptr->next_seq_num++;
-}
-#endif /* WRITE_APNG */
-
-/* Initializes the row writing capability of libpng */
-void /* PRIVATE */
-png_write_start_row(png_structrp png_ptr)
-{
- png_alloc_size_t buf_size;
- int usr_pixel_depth;
-
-#ifdef PNG_WRITE_FILTER_SUPPORTED
- png_byte filters;
-#endif
-
- png_debug(1, "in png_write_start_row");
-
- usr_pixel_depth = png_ptr->usr_channels * png_ptr->usr_bit_depth;
- buf_size = PNG_ROWBYTES(usr_pixel_depth, png_ptr->width) + 1;
-
- /* 1.5.6: added to allow checking in the row write code. */
- png_ptr->transformed_pixel_depth = png_ptr->pixel_depth;
- png_ptr->maximum_pixel_depth = (png_byte)usr_pixel_depth;
-
- /* Set up row buffer */
- png_ptr->row_buf = png_voidcast(png_bytep, png_malloc(png_ptr, buf_size));
-
- png_ptr->row_buf[0] = PNG_FILTER_VALUE_NONE;
-
-#ifdef PNG_WRITE_FILTER_SUPPORTED
- filters = png_ptr->do_filter;
-
- if (png_ptr->height == 1)
- filters &= 0xff & ~(PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH);
-
- if (png_ptr->width == 1)
- filters &= 0xff & ~(PNG_FILTER_SUB|PNG_FILTER_AVG|PNG_FILTER_PAETH);
-
- if (filters == 0)
- filters = PNG_FILTER_NONE;
-
- png_ptr->do_filter = filters;
-
- if (((filters & (PNG_FILTER_SUB | PNG_FILTER_UP | PNG_FILTER_AVG |
- PNG_FILTER_PAETH)) != 0) && png_ptr->try_row == NULL)
- {
- int num_filters = 0;
-
- png_ptr->try_row = png_voidcast(png_bytep, png_malloc(png_ptr, buf_size));
-
- if (filters & PNG_FILTER_SUB)
- num_filters++;
-
- if (filters & PNG_FILTER_UP)
- num_filters++;
-
- if (filters & PNG_FILTER_AVG)
- num_filters++;
-
- if (filters & PNG_FILTER_PAETH)
- num_filters++;
-
- if (num_filters > 1)
- png_ptr->tst_row = png_voidcast(png_bytep, png_malloc(png_ptr,
- buf_size));
- }
-
- /* We only need to keep the previous row if we are using one of the following
- * filters.
- */
- if ((filters & (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH)) != 0)
- png_ptr->prev_row = png_voidcast(png_bytep,
- png_calloc(png_ptr, buf_size));
-#endif /* WRITE_FILTER */
-
-#ifdef PNG_WRITE_INTERLACING_SUPPORTED
- /* If interlaced, we need to set up width and height of pass */
- if (png_ptr->interlaced != 0)
- {
- if ((png_ptr->transformations & PNG_INTERLACE) == 0)
- {
- png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 -
- png_pass_ystart[0]) / png_pass_yinc[0];
-
- png_ptr->usr_width = (png_ptr->width + png_pass_inc[0] - 1 -
- png_pass_start[0]) / png_pass_inc[0];
- }
-
- else
- {
- png_ptr->num_rows = png_ptr->height;
- png_ptr->usr_width = png_ptr->width;
- }
- }
-
- else
-#endif
- {
- png_ptr->num_rows = png_ptr->height;
- png_ptr->usr_width = png_ptr->width;
- }
-}
-
-/* Internal use only. Called when finished processing a row of data. */
-void /* PRIVATE */
-png_write_finish_row(png_structrp png_ptr)
-{
- png_debug(1, "in png_write_finish_row");
-
- /* Next row */
- png_ptr->row_number++;
-
- /* See if we are done */
- if (png_ptr->row_number < png_ptr->num_rows)
- return;
-
-#ifdef PNG_WRITE_INTERLACING_SUPPORTED
- /* If interlaced, go to next pass */
- if (png_ptr->interlaced != 0)
- {
- png_ptr->row_number = 0;
- if ((png_ptr->transformations & PNG_INTERLACE) != 0)
- {
- png_ptr->pass++;
- }
-
- else
- {
- /* Loop until we find a non-zero width or height pass */
- do
- {
- png_ptr->pass++;
-
- if (png_ptr->pass >= 7)
- break;
-
- png_ptr->usr_width = (png_ptr->width +
- png_pass_inc[png_ptr->pass] - 1 -
- png_pass_start[png_ptr->pass]) /
- png_pass_inc[png_ptr->pass];
-
- png_ptr->num_rows = (png_ptr->height +
- png_pass_yinc[png_ptr->pass] - 1 -
- png_pass_ystart[png_ptr->pass]) /
- png_pass_yinc[png_ptr->pass];
-
- if ((png_ptr->transformations & PNG_INTERLACE) != 0)
- break;
-
- } while (png_ptr->usr_width == 0 || png_ptr->num_rows == 0);
-
- }
-
- /* Reset the row above the image for the next pass */
- if (png_ptr->pass < 7)
- {
- if (png_ptr->prev_row != NULL)
- memset(png_ptr->prev_row, 0,
- PNG_ROWBYTES(png_ptr->usr_channels *
- png_ptr->usr_bit_depth, png_ptr->width) + 1);
-
- return;
- }
- }
-#endif
-
- /* If we get here, we've just written the last row, so we need
- to flush the compressor */
- png_compress_IDAT(png_ptr, NULL, 0, Z_FINISH);
-}
-
-#ifdef PNG_WRITE_INTERLACING_SUPPORTED
-/* Pick out the correct pixels for the interlace pass.
- * The basic idea here is to go through the row with a source
- * pointer and a destination pointer (sp and dp), and copy the
- * correct pixels for the pass. As the row gets compacted,
- * sp will always be >= dp, so we should never overwrite anything.
- * See the default: case for the easiest code to understand.
- */
-void /* PRIVATE */
-png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
-{
- png_debug(1, "in png_do_write_interlace");
-
- /* We don't have to do anything on the last pass (6) */
- if (pass < 6)
- {
- /* Each pixel depth is handled separately */
- switch (row_info->pixel_depth)
- {
- case 1:
- {
- png_bytep sp;
- png_bytep dp;
- unsigned int shift;
- int d;
- int value;
- png_uint_32 i;
- png_uint_32 row_width = row_info->width;
-
- dp = row;
- d = 0;
- shift = 7;
-
- for (i = png_pass_start[pass]; i < row_width;
- i += png_pass_inc[pass])
- {
- sp = row + (size_t)(i >> 3);
- value = (int)(*sp >> (7 - (int)(i & 0x07))) & 0x01;
- d |= (value << shift);
-
- if (shift == 0)
- {
- shift = 7;
- *dp++ = (png_byte)d;
- d = 0;
- }
-
- else
- shift--;
-
- }
- if (shift != 7)
- *dp = (png_byte)d;
-
- break;
- }
-
- case 2:
- {
- png_bytep sp;
- png_bytep dp;
- unsigned int shift;
- int d;
- int value;
- png_uint_32 i;
- png_uint_32 row_width = row_info->width;
-
- dp = row;
- shift = 6;
- d = 0;
-
- for (i = png_pass_start[pass]; i < row_width;
- i += png_pass_inc[pass])
- {
- sp = row + (size_t)(i >> 2);
- value = (*sp >> ((3 - (int)(i & 0x03)) << 1)) & 0x03;
- d |= (value << shift);
-
- if (shift == 0)
- {
- shift = 6;
- *dp++ = (png_byte)d;
- d = 0;
- }
-
- else
- shift -= 2;
- }
- if (shift != 6)
- *dp = (png_byte)d;
-
- break;
- }
-
- case 4:
- {
- png_bytep sp;
- png_bytep dp;
- unsigned int shift;
- int d;
- int value;
- png_uint_32 i;
- png_uint_32 row_width = row_info->width;
-
- dp = row;
- shift = 4;
- d = 0;
- for (i = png_pass_start[pass]; i < row_width;
- i += png_pass_inc[pass])
- {
- sp = row + (size_t)(i >> 1);
- value = (*sp >> ((1 - (int)(i & 0x01)) << 2)) & 0x0f;
- d |= (value << shift);
-
- if (shift == 0)
- {
- shift = 4;
- *dp++ = (png_byte)d;
- d = 0;
- }
-
- else
- shift -= 4;
- }
- if (shift != 4)
- *dp = (png_byte)d;
-
- break;
- }
-
- default:
- {
- png_bytep sp;
- png_bytep dp;
- png_uint_32 i;
- png_uint_32 row_width = row_info->width;
- size_t pixel_bytes;
-
- /* Start at the beginning */
- dp = row;
-
- /* Find out how many bytes each pixel takes up */
- pixel_bytes = (row_info->pixel_depth >> 3);
-
- /* Loop through the row, only looking at the pixels that matter */
- for (i = png_pass_start[pass]; i < row_width;
- i += png_pass_inc[pass])
- {
- /* Find out where the original pixel is */
- sp = row + (size_t)i * pixel_bytes;
-
- /* Move the pixel */
- if (dp != sp)
- memcpy(dp, sp, pixel_bytes);
-
- /* Next pixel */
- dp += pixel_bytes;
- }
- break;
- }
- }
- /* Set new row width */
- row_info->width = (row_info->width +
- png_pass_inc[pass] - 1 -
- png_pass_start[pass]) /
- png_pass_inc[pass];
-
- row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,
- row_info->width);
- }
-}
-#endif
-
-
-/* This filters the row, chooses which filter to use, if it has not already
- * been specified by the application, and then writes the row out with the
- * chosen filter.
- */
-static void /* PRIVATE */
-png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row,
- size_t row_bytes);
-
-#ifdef PNG_WRITE_FILTER_SUPPORTED
-static size_t /* PRIVATE */
-png_setup_sub_row(png_structrp png_ptr, png_uint_32 bpp,
- size_t row_bytes, size_t lmins)
-{
- png_bytep rp, dp, lp;
- size_t i;
- size_t sum = 0;
- unsigned int v;
-
- png_ptr->try_row[0] = PNG_FILTER_VALUE_SUB;
-
- for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1; i < bpp;
- i++, rp++, dp++)
- {
- v = *dp = *rp;
-#ifdef PNG_USE_ABS
- sum += 128 - abs((int)v - 128);
-#else
- sum += (v < 128) ? v : 256 - v;
-#endif
- }
-
- for (lp = png_ptr->row_buf + 1; i < row_bytes;
- i++, rp++, lp++, dp++)
- {
- v = *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff);
-#ifdef PNG_USE_ABS
- sum += 128 - abs((int)v - 128);
-#else
- sum += (v < 128) ? v : 256 - v;
-#endif
-
- if (sum > lmins) /* We are already worse, don't continue. */
- break;
- }
-
- return sum;
-}
-
-static void /* PRIVATE */
-png_setup_sub_row_only(png_structrp png_ptr, png_uint_32 bpp,
- size_t row_bytes)
-{
- png_bytep rp, dp, lp;
- size_t i;
-
- png_ptr->try_row[0] = PNG_FILTER_VALUE_SUB;
-
- for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1; i < bpp;
- i++, rp++, dp++)
- {
- *dp = *rp;
- }
-
- for (lp = png_ptr->row_buf + 1; i < row_bytes;
- i++, rp++, lp++, dp++)
- {
- *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff);
- }
-}
-
-static size_t /* PRIVATE */
-png_setup_up_row(png_structrp png_ptr, size_t row_bytes, size_t lmins)
-{
- png_bytep rp, dp, pp;
- size_t i;
- size_t sum = 0;
- unsigned int v;
-
- png_ptr->try_row[0] = PNG_FILTER_VALUE_UP;
-
- for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1,
- pp = png_ptr->prev_row + 1; i < row_bytes;
- i++, rp++, pp++, dp++)
- {
- v = *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff);
-#ifdef PNG_USE_ABS
- sum += 128 - abs((int)v - 128);
-#else
- sum += (v < 128) ? v : 256 - v;
-#endif
-
- if (sum > lmins) /* We are already worse, don't continue. */
- break;
- }
-
- return sum;
-}
-static void /* PRIVATE */
-png_setup_up_row_only(png_structrp png_ptr, size_t row_bytes)
-{
- png_bytep rp, dp, pp;
- size_t i;
-
- png_ptr->try_row[0] = PNG_FILTER_VALUE_UP;
-
- for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1,
- pp = png_ptr->prev_row + 1; i < row_bytes;
- i++, rp++, pp++, dp++)
- {
- *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff);
- }
-}
-
-static size_t /* PRIVATE */
-png_setup_avg_row(png_structrp png_ptr, png_uint_32 bpp,
- size_t row_bytes, size_t lmins)
-{
- png_bytep rp, dp, pp, lp;
- png_uint_32 i;
- size_t sum = 0;
- unsigned int v;
-
- png_ptr->try_row[0] = PNG_FILTER_VALUE_AVG;
-
- for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1,
- pp = png_ptr->prev_row + 1; i < bpp; i++)
- {
- v = *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff);
-
-#ifdef PNG_USE_ABS
- sum += 128 - abs((int)v - 128);
-#else
- sum += (v < 128) ? v : 256 - v;
-#endif
- }
-
- for (lp = png_ptr->row_buf + 1; i < row_bytes; i++)
- {
- v = *dp++ = (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2))
- & 0xff);
-
-#ifdef PNG_USE_ABS
- sum += 128 - abs((int)v - 128);
-#else
- sum += (v < 128) ? v : 256 - v;
-#endif
-
- if (sum > lmins) /* We are already worse, don't continue. */
- break;
- }
-
- return sum;
-}
-static void /* PRIVATE */
-png_setup_avg_row_only(png_structrp png_ptr, png_uint_32 bpp,
- size_t row_bytes)
-{
- png_bytep rp, dp, pp, lp;
- png_uint_32 i;
-
- png_ptr->try_row[0] = PNG_FILTER_VALUE_AVG;
-
- for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1,
- pp = png_ptr->prev_row + 1; i < bpp; i++)
- {
- *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff);
- }
-
- for (lp = png_ptr->row_buf + 1; i < row_bytes; i++)
- {
- *dp++ = (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2))
- & 0xff);
- }
-}
-
-static size_t /* PRIVATE */
-png_setup_paeth_row(png_structrp png_ptr, png_uint_32 bpp,
- size_t row_bytes, size_t lmins)
-{
- png_bytep rp, dp, pp, cp, lp;
- size_t i;
- size_t sum = 0;
- unsigned int v;
-
- png_ptr->try_row[0] = PNG_FILTER_VALUE_PAETH;
-
- for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1,
- pp = png_ptr->prev_row + 1; i < bpp; i++)
- {
- v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff);
-
-#ifdef PNG_USE_ABS
- sum += 128 - abs((int)v - 128);
-#else
- sum += (v < 128) ? v : 256 - v;
-#endif
- }
-
- for (lp = png_ptr->row_buf + 1, cp = png_ptr->prev_row + 1; i < row_bytes;
- i++)
- {
- int a, b, c, pa, pb, pc, p;
-
- b = *pp++;
- c = *cp++;
- a = *lp++;
-
- p = b - c;
- pc = a - c;
-
-#ifdef PNG_USE_ABS
- pa = abs(p);
- pb = abs(pc);
- pc = abs(p + pc);
-#else
- pa = p < 0 ? -p : p;
- pb = pc < 0 ? -pc : pc;
- pc = (p + pc) < 0 ? -(p + pc) : p + pc;
-#endif
-
- p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c;
-
- v = *dp++ = (png_byte)(((int)*rp++ - p) & 0xff);
-
-#ifdef PNG_USE_ABS
- sum += 128 - abs((int)v - 128);
-#else
- sum += (v < 128) ? v : 256 - v;
-#endif
-
- if (sum > lmins) /* We are already worse, don't continue. */
- break;
- }
-
- return sum;
-}
-static void /* PRIVATE */
-png_setup_paeth_row_only(png_structrp png_ptr, png_uint_32 bpp,
- size_t row_bytes)
-{
- png_bytep rp, dp, pp, cp, lp;
- size_t i;
-
- png_ptr->try_row[0] = PNG_FILTER_VALUE_PAETH;
-
- for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1,
- pp = png_ptr->prev_row + 1; i < bpp; i++)
- {
- *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff);
- }
-
- for (lp = png_ptr->row_buf + 1, cp = png_ptr->prev_row + 1; i < row_bytes;
- i++)
- {
- int a, b, c, pa, pb, pc, p;
-
- b = *pp++;
- c = *cp++;
- a = *lp++;
-
- p = b - c;
- pc = a - c;
-
-#ifdef PNG_USE_ABS
- pa = abs(p);
- pb = abs(pc);
- pc = abs(p + pc);
-#else
- pa = p < 0 ? -p : p;
- pb = pc < 0 ? -pc : pc;
- pc = (p + pc) < 0 ? -(p + pc) : p + pc;
-#endif
-
- p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c;
-
- *dp++ = (png_byte)(((int)*rp++ - p) & 0xff);
- }
-}
-#endif /* WRITE_FILTER */
-
-void /* PRIVATE */
-png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
-{
-#ifndef PNG_WRITE_FILTER_SUPPORTED
- png_write_filtered_row(png_ptr, png_ptr->row_buf, row_info->rowbytes+1);
-#else
- unsigned int filter_to_do = png_ptr->do_filter;
- png_bytep row_buf;
- png_bytep best_row;
- png_uint_32 bpp;
- size_t mins;
- size_t row_bytes = row_info->rowbytes;
-
- png_debug(1, "in png_write_find_filter");
-
- /* Find out how many bytes offset each pixel is */
- bpp = (row_info->pixel_depth + 7) >> 3;
-
- row_buf = png_ptr->row_buf;
- mins = PNG_SIZE_MAX - 256/* so we can detect potential overflow of the
- running sum */;
-
- /* The prediction method we use is to find which method provides the
- * smallest value when summing the absolute values of the distances
- * from zero, using anything >= 128 as negative numbers. This is known
- * as the "minimum sum of absolute differences" heuristic. Other
- * heuristics are the "weighted minimum sum of absolute differences"
- * (experimental and can in theory improve compression), and the "zlib
- * predictive" method (not implemented yet), which does test compressions
- * of lines using different filter methods, and then chooses the
- * (series of) filter(s) that give minimum compressed data size (VERY
- * computationally expensive).
- *
- * GRR 980525: consider also
- *
- * (1) minimum sum of absolute differences from running average (i.e.,
- * keep running sum of non-absolute differences & count of bytes)
- * [track dispersion, too? restart average if dispersion too large?]
- *
- * (1b) minimum sum of absolute differences from sliding average, probably
- * with window size <= deflate window (usually 32K)
- *
- * (2) minimum sum of squared differences from zero or running average
- * (i.e., ~ root-mean-square approach)
- */
-
-
- /* We don't need to test the 'no filter' case if this is the only filter
- * that has been chosen, as it doesn't actually do anything to the data.
- */
- best_row = png_ptr->row_buf;
-
- if (PNG_SIZE_MAX/128 <= row_bytes)
- {
- /* Overflow can occur in the calculation, just select the lowest set
- * filter.
- */
- filter_to_do &= 0U-filter_to_do;
- }
- else if ((filter_to_do & PNG_FILTER_NONE) != 0 &&
- filter_to_do != PNG_FILTER_NONE)
- {
- /* Overflow not possible and multiple filters in the list, including the
- * 'none' filter.
- */
- png_bytep rp;
- size_t sum = 0;
- size_t i;
- unsigned int v;
-
- {
- for (i = 0, rp = row_buf + 1; i < row_bytes; i++, rp++)
- {
- v = *rp;
-#ifdef PNG_USE_ABS
- sum += 128 - abs((int)v - 128);
-#else
- sum += (v < 128) ? v : 256 - v;
-#endif
- }
- }
-
- mins = sum;
- }
-
- /* Sub filter */
- if (filter_to_do == PNG_FILTER_SUB)
- /* It's the only filter so no testing is needed */
- {
- png_setup_sub_row_only(png_ptr, bpp, row_bytes);
- best_row = png_ptr->try_row;
- }
-
- else if ((filter_to_do & PNG_FILTER_SUB) != 0)
- {
- size_t sum;
- size_t lmins = mins;
-
- sum = png_setup_sub_row(png_ptr, bpp, row_bytes, lmins);
-
- if (sum < mins)
- {
- mins = sum;
- best_row = png_ptr->try_row;
- if (png_ptr->tst_row != NULL)
- {
- png_ptr->try_row = png_ptr->tst_row;
- png_ptr->tst_row = best_row;
- }
- }
- }
-
- /* Up filter */
- if (filter_to_do == PNG_FILTER_UP)
- {
- png_setup_up_row_only(png_ptr, row_bytes);
- best_row = png_ptr->try_row;
- }
-
- else if ((filter_to_do & PNG_FILTER_UP) != 0)
- {
- size_t sum;
- size_t lmins = mins;
-
- sum = png_setup_up_row(png_ptr, row_bytes, lmins);
-
- if (sum < mins)
- {
- mins = sum;
- best_row = png_ptr->try_row;
- if (png_ptr->tst_row != NULL)
- {
- png_ptr->try_row = png_ptr->tst_row;
- png_ptr->tst_row = best_row;
- }
- }
- }
-
- /* Avg filter */
- if (filter_to_do == PNG_FILTER_AVG)
- {
- png_setup_avg_row_only(png_ptr, bpp, row_bytes);
- best_row = png_ptr->try_row;
- }
-
- else if ((filter_to_do & PNG_FILTER_AVG) != 0)
- {
- size_t sum;
- size_t lmins = mins;
-
- sum= png_setup_avg_row(png_ptr, bpp, row_bytes, lmins);
-
- if (sum < mins)
- {
- mins = sum;
- best_row = png_ptr->try_row;
- if (png_ptr->tst_row != NULL)
- {
- png_ptr->try_row = png_ptr->tst_row;
- png_ptr->tst_row = best_row;
- }
- }
- }
-
- /* Paeth filter */
- if (filter_to_do == PNG_FILTER_PAETH)
- {
- png_setup_paeth_row_only(png_ptr, bpp, row_bytes);
- best_row = png_ptr->try_row;
- }
-
- else if ((filter_to_do & PNG_FILTER_PAETH) != 0)
- {
- size_t sum;
- size_t lmins = mins;
-
- sum = png_setup_paeth_row(png_ptr, bpp, row_bytes, lmins);
-
- if (sum < mins)
- {
- best_row = png_ptr->try_row;
- if (png_ptr->tst_row != NULL)
- {
- png_ptr->try_row = png_ptr->tst_row;
- png_ptr->tst_row = best_row;
- }
- }
- }
-
- /* Do the actual writing of the filtered row data from the chosen filter. */
- png_write_filtered_row(png_ptr, best_row, row_info->rowbytes+1);
-
-#endif /* WRITE_FILTER */
-}
-
-
-/* Do the actual writing of a previously filtered row. */
-static void
-png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row,
- size_t full_row_length/*includes filter byte*/)
-{
- png_debug(1, "in png_write_filtered_row");
-
- png_debug1(2, "filter = %d", filtered_row[0]);
-
- png_compress_IDAT(png_ptr, filtered_row, full_row_length, Z_NO_FLUSH);
-
-#ifdef PNG_WRITE_FILTER_SUPPORTED
- /* Swap the current and previous rows */
- if (png_ptr->prev_row != NULL)
- {
- png_bytep tptr;
-
- tptr = png_ptr->prev_row;
- png_ptr->prev_row = png_ptr->row_buf;
- png_ptr->row_buf = tptr;
- }
-#endif /* WRITE_FILTER */
-
- /* Finish row - updates counters and flushes zlib if last row */
- png_write_finish_row(png_ptr);
-
-#ifdef PNG_WRITE_FLUSH_SUPPORTED
- png_ptr->flush_rows++;
-
- if (png_ptr->flush_dist > 0 &&
- png_ptr->flush_rows >= png_ptr->flush_dist)
- {
- png_write_flush(png_ptr);
- }
-#endif /* WRITE_FLUSH */
-}
-
-#ifdef PNG_WRITE_APNG_SUPPORTED
-void /* PRIVATE */
-png_write_reset(png_structp png_ptr)
-{
- png_ptr->row_number = 0;
- png_ptr->pass = 0;
- png_ptr->mode &= ~PNG_HAVE_IDAT;
-}
-
-void /* PRIVATE */
-png_write_reinit(png_structp png_ptr, png_infop info_ptr,
- png_uint_32 width, png_uint_32 height)
-{
- if (png_ptr->num_frames_written == 0 &&
- (width != png_ptr->first_frame_width ||
- height != png_ptr->first_frame_height))
- png_error(png_ptr, "width and/or height in the first frame's fcTL "
- "don't match the ones in IHDR");
- if (width > png_ptr->first_frame_width ||
- height > png_ptr->first_frame_height)
- png_error(png_ptr, "width and/or height for a frame greater than "
- "the ones in IHDR");
-
- png_set_IHDR(png_ptr, info_ptr, width, height,
- info_ptr->bit_depth, info_ptr->color_type,
- info_ptr->interlace_type, info_ptr->compression_type,
- info_ptr->filter_type);
-
- png_ptr->width = width;
- png_ptr->height = height;
- png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, width);
- png_ptr->usr_width = png_ptr->width;
-}
-#endif /* WRITE_APNG */
-#endif /* WRITE */
diff --git a/contrib/libs/libpng/powerpc/filter_vsx_intrinsics.c b/contrib/libs/libpng/powerpc/filter_vsx_intrinsics.c
deleted file mode 100644
index 01cf8800dc..0000000000
--- a/contrib/libs/libpng/powerpc/filter_vsx_intrinsics.c
+++ /dev/null
@@ -1,768 +0,0 @@
-/* filter_vsx_intrinsics.c - PowerPC optimised filter functions
- *
- * Copyright (c) 2018 Cosmin Truta
- * Copyright (c) 2017 Glenn Randers-Pehrson
- * Written by Vadim Barkov, 2017.
- *
- * This code is released under the libpng license.
- * For conditions of distribution and use, see the disclaimer
- * and license in png.h
- */
-
-#include <stdio.h>
-#include <stdint.h>
-#include "../pngpriv.h"
-
-#ifdef PNG_READ_SUPPORTED
-
-/* This code requires -maltivec and -mvsx on the command line: */
-#if PNG_POWERPC_VSX_IMPLEMENTATION == 1 /* intrinsics code from pngpriv.h */
-
-#include <altivec.h>
-
-#if PNG_POWERPC_VSX_OPT > 0
-
-#ifndef __VSX__
-# error "This code requires VSX support (POWER7 and later). Please provide -mvsx compiler flag."
-#endif
-
-#define vec_ld_unaligned(vec,data) vec = vec_vsx_ld(0,data)
-#define vec_st_unaligned(vec,data) vec_vsx_st(vec,0,data)
-
-
-/* Functions in this file look at most 3 pixels (a,b,c) to predict the 4th (d).
- * They're positioned like this:
- * prev: c b
- * row: a d
- * The Sub filter predicts d=a, Avg d=(a+b)/2, and Paeth predicts d to be
- * whichever of a, b, or c is closest to p=a+b-c.
- * ( this is taken from ../intel/filter_sse2_intrinsics.c )
- */
-
-#define vsx_declare_common_vars(row_info,row,prev_row,offset) \
- png_byte i;\
- png_bytep rp = row + offset;\
- png_const_bytep pp = prev_row;\
- size_t unaligned_top = 16 - (((size_t)rp % 16));\
- size_t istop;\
- if(unaligned_top == 16)\
- unaligned_top = 0;\
- istop = row_info->rowbytes;\
- if((unaligned_top < istop))\
- istop -= unaligned_top;\
- else{\
- unaligned_top = istop;\
- istop = 0;\
- }
-
-void png_read_filter_row_up_vsx(png_row_infop row_info, png_bytep row,
- png_const_bytep prev_row)
-{
- vector unsigned char rp_vec;
- vector unsigned char pp_vec;
- vsx_declare_common_vars(row_info,row,prev_row,0)
-
- /* Altivec operations require 16-byte aligned data
- * but input can be unaligned. So we calculate
- * unaligned part as usual.
- */
- for (i = 0; i < unaligned_top; i++)
- {
- *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff);
- rp++;
- }
-
- /* Using SIMD while we can */
- while( istop >= 16 )
- {
- rp_vec = vec_ld(0,rp);
- vec_ld_unaligned(pp_vec,pp);
-
- rp_vec = vec_add(rp_vec,pp_vec);
-
- vec_st(rp_vec,0,rp);
-
- pp += 16;
- rp += 16;
- istop -= 16;
- }
-
- if(istop > 0)
- {
- /* If byte count of row is not divisible by 16
- * we will process remaining part as usual
- */
- for (i = 0; i < istop; i++)
- {
- *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff);
- rp++;
- }
-}
-
-}
-
-static const vector unsigned char VSX_LEFTSHIFTED1_4 = {16,16,16,16, 0, 1, 2, 3,16,16,16,16,16,16,16,16};
-static const vector unsigned char VSX_LEFTSHIFTED2_4 = {16,16,16,16,16,16,16,16, 4, 5, 6, 7,16,16,16,16};
-static const vector unsigned char VSX_LEFTSHIFTED3_4 = {16,16,16,16,16,16,16,16,16,16,16,16, 8, 9,10,11};
-
-static const vector unsigned char VSX_LEFTSHIFTED1_3 = {16,16,16, 0, 1, 2,16,16,16,16,16,16,16,16,16,16};
-static const vector unsigned char VSX_LEFTSHIFTED2_3 = {16,16,16,16,16,16, 3, 4, 5,16,16,16,16,16,16,16};
-static const vector unsigned char VSX_LEFTSHIFTED3_3 = {16,16,16,16,16,16,16,16,16, 6, 7, 8,16,16,16,16};
-static const vector unsigned char VSX_LEFTSHIFTED4_3 = {16,16,16,16,16,16,16,16,16,16,16,16, 9,10,11,16};
-
-static const vector unsigned char VSX_NOT_SHIFTED1_4 = {16,16,16,16, 4, 5, 6, 7,16,16,16,16,16,16,16,16};
-static const vector unsigned char VSX_NOT_SHIFTED2_4 = {16,16,16,16,16,16,16,16, 8, 9,10,11,16,16,16,16};
-static const vector unsigned char VSX_NOT_SHIFTED3_4 = {16,16,16,16,16,16,16,16,16,16,16,16,12,13,14,15};
-
-static const vector unsigned char VSX_NOT_SHIFTED1_3 = {16,16,16, 3, 4, 5,16,16,16,16,16,16,16,16,16,16};
-static const vector unsigned char VSX_NOT_SHIFTED2_3 = {16,16,16,16,16,16, 6, 7, 8,16,16,16,16,16,16,16};
-static const vector unsigned char VSX_NOT_SHIFTED3_3 = {16,16,16,16,16,16,16,16,16, 9,10,11,16,16,16,16};
-static const vector unsigned char VSX_NOT_SHIFTED4_3 = {16,16,16,16,16,16,16,16,16,16,16,16,12,13,14,16};
-
-static const vector unsigned char VSX_CHAR_ZERO = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
-#ifdef __LITTLE_ENDIAN__
-
-static const vector unsigned char VSX_CHAR_TO_SHORT1_4 = { 4,16, 5,16, 6,16, 7,16,16,16,16,16,16,16,16,16};
-static const vector unsigned char VSX_CHAR_TO_SHORT2_4 = { 8,16, 9,16,10,16,11,16,16,16,16,16,16,16,16,16};
-static const vector unsigned char VSX_CHAR_TO_SHORT3_4 = {12,16,13,16,14,16,15,16,16,16,16,16,16,16,16,16};
-
-static const vector unsigned char VSX_SHORT_TO_CHAR1_4 = {16,16,16,16, 0, 2, 4, 6,16,16,16,16,16,16,16,16};
-static const vector unsigned char VSX_SHORT_TO_CHAR2_4 = {16,16,16,16,16,16,16,16, 0, 2, 4, 6,16,16,16,16};
-static const vector unsigned char VSX_SHORT_TO_CHAR3_4 = {16,16,16,16,16,16,16,16,16,16,16,16, 0, 2, 4, 6};
-
-static const vector unsigned char VSX_CHAR_TO_SHORT1_3 = { 3,16, 4,16, 5,16,16,16,16,16,16,16,16,16,16,16};
-static const vector unsigned char VSX_CHAR_TO_SHORT2_3 = { 6,16, 7,16, 8,16,16,16,16,16,16,16,16,16,16,16};
-static const vector unsigned char VSX_CHAR_TO_SHORT3_3 = { 9,16,10,16,11,16,16,16,16,16,16,16,16,16,16,16};
-static const vector unsigned char VSX_CHAR_TO_SHORT4_3 = {12,16,13,16,14,16,16,16,16,16,16,16,16,16,16,16};
-
-static const vector unsigned char VSX_SHORT_TO_CHAR1_3 = {16,16,16, 0, 2, 4,16,16,16,16,16,16,16,16,16,16};
-static const vector unsigned char VSX_SHORT_TO_CHAR2_3 = {16,16,16,16,16,16, 0, 2, 4,16,16,16,16,16,16,16};
-static const vector unsigned char VSX_SHORT_TO_CHAR3_3 = {16,16,16,16,16,16,16,16,16, 0, 2, 4,16,16,16,16};
-static const vector unsigned char VSX_SHORT_TO_CHAR4_3 = {16,16,16,16,16,16,16,16,16,16,16,16, 0, 2, 4,16};
-
-#elif defined(__BIG_ENDIAN__)
-
-static const vector unsigned char VSX_CHAR_TO_SHORT1_4 = {16, 4,16, 5,16, 6,16, 7,16,16,16,16,16,16,16,16};
-static const vector unsigned char VSX_CHAR_TO_SHORT2_4 = {16, 8,16, 9,16,10,16,11,16,16,16,16,16,16,16,16};
-static const vector unsigned char VSX_CHAR_TO_SHORT3_4 = {16,12,16,13,16,14,16,15,16,16,16,16,16,16,16,16};
-
-static const vector unsigned char VSX_SHORT_TO_CHAR1_4 = {16,16,16,16, 1, 3, 5, 7,16,16,16,16,16,16,16,16};
-static const vector unsigned char VSX_SHORT_TO_CHAR2_4 = {16,16,16,16,16,16,16,16, 1, 3, 5, 7,16,16,16,16};
-static const vector unsigned char VSX_SHORT_TO_CHAR3_4 = {16,16,16,16,16,16,16,16,16,16,16,16, 1, 3, 5, 7};
-
-static const vector unsigned char VSX_CHAR_TO_SHORT1_3 = {16, 3,16, 4,16, 5,16,16,16,16,16,16,16,16,16,16};
-static const vector unsigned char VSX_CHAR_TO_SHORT2_3 = {16, 6,16, 7,16, 8,16,16,16,16,16,16,16,16,16,16};
-static const vector unsigned char VSX_CHAR_TO_SHORT3_3 = {16, 9,16,10,16,11,16,16,16,16,16,16,16,16,16,16};
-static const vector unsigned char VSX_CHAR_TO_SHORT4_3 = {16,12,16,13,16,14,16,16,16,16,16,16,16,16,16,16};
-
-static const vector unsigned char VSX_SHORT_TO_CHAR1_3 = {16,16,16, 1, 3, 5,16,16,16,16,16,16,16,16,16,16};
-static const vector unsigned char VSX_SHORT_TO_CHAR2_3 = {16,16,16,16,16,16, 1, 3, 5,16,16,16,16,16,16,16};
-static const vector unsigned char VSX_SHORT_TO_CHAR3_3 = {16,16,16,16,16,16,16,16,16, 1, 3, 5,16,16,16,16};
-static const vector unsigned char VSX_SHORT_TO_CHAR4_3 = {16,16,16,16,16,16,16,16,16,16,16,16, 1, 3, 5,16};
-
-#endif
-
-#define vsx_char_to_short(vec,offset,bpp) (vector unsigned short)vec_perm((vec),VSX_CHAR_ZERO,VSX_CHAR_TO_SHORT##offset##_##bpp)
-#define vsx_short_to_char(vec,offset,bpp) vec_perm(((vector unsigned char)(vec)),VSX_CHAR_ZERO,VSX_SHORT_TO_CHAR##offset##_##bpp)
-
-#ifdef PNG_USE_ABS
-# define vsx_abs(number) abs(number)
-#else
-# define vsx_abs(number) (number > 0) ? (number) : -(number)
-#endif
-
-void png_read_filter_row_sub4_vsx(png_row_infop row_info, png_bytep row,
- png_const_bytep prev_row)
-{
- png_byte bpp = 4;
-
- vector unsigned char rp_vec;
- vector unsigned char part_vec;
-
- vsx_declare_common_vars(row_info,row,prev_row,bpp)
-
- PNG_UNUSED(pp)
-
- /* Altivec operations require 16-byte aligned data
- * but input can be unaligned. So we calculate
- * unaligned part as usual.
- */
- for (i = 0; i < unaligned_top; i++)
- {
- *rp = (png_byte)(((int)(*rp) + (int)(*(rp-bpp))) & 0xff);
- rp++;
- }
-
- /* Using SIMD while we can */
- while( istop >= 16 )
- {
- for(i=0;i < bpp ; i++)
- {
- *rp = (png_byte)(((int)(*rp) + (int)(*(rp-bpp))) & 0xff);
- rp++;
- }
- rp -= bpp;
-
- rp_vec = vec_ld(0,rp);
- part_vec = vec_perm(rp_vec,VSX_CHAR_ZERO,VSX_LEFTSHIFTED1_4);
- rp_vec = vec_add(rp_vec,part_vec);
-
- part_vec = vec_perm(rp_vec,VSX_CHAR_ZERO,VSX_LEFTSHIFTED2_4);
- rp_vec = vec_add(rp_vec,part_vec);
-
- part_vec = vec_perm(rp_vec,VSX_CHAR_ZERO,VSX_LEFTSHIFTED3_4);
- rp_vec = vec_add(rp_vec,part_vec);
-
- vec_st(rp_vec,0,rp);
-
- rp += 16;
- istop -= 16;
- }
-
- if(istop > 0)
- for (i = 0; i < istop % 16; i++)
- {
- *rp = (png_byte)(((int)(*rp) + (int)(*(rp - bpp))) & 0xff);
- rp++;
- }
-
-}
-
-void png_read_filter_row_sub3_vsx(png_row_infop row_info, png_bytep row,
- png_const_bytep prev_row)
-{
- png_byte bpp = 3;
-
- vector unsigned char rp_vec;
- vector unsigned char part_vec;
-
- vsx_declare_common_vars(row_info,row,prev_row,bpp)
-
- PNG_UNUSED(pp)
-
- /* Altivec operations require 16-byte aligned data
- * but input can be unaligned. So we calculate
- * unaligned part as usual.
- */
- for (i = 0; i < unaligned_top; i++)
- {
- *rp = (png_byte)(((int)(*rp) + (int)(*(rp-bpp))) & 0xff);
- rp++;
- }
-
- /* Using SIMD while we can */
- while( istop >= 16 )
- {
- for(i=0;i < bpp ; i++)
- {
- *rp = (png_byte)(((int)(*rp) + (int)(*(rp-bpp))) & 0xff);
- rp++;
- }
- rp -= bpp;
-
- rp_vec = vec_ld(0,rp);
- part_vec = vec_perm(rp_vec,VSX_CHAR_ZERO,VSX_LEFTSHIFTED1_3);
- rp_vec = vec_add(rp_vec,part_vec);
-
- part_vec = vec_perm(rp_vec,VSX_CHAR_ZERO,VSX_LEFTSHIFTED2_3);
- rp_vec = vec_add(rp_vec,part_vec);
-
- part_vec = vec_perm(rp_vec,VSX_CHAR_ZERO,VSX_LEFTSHIFTED3_3);
- rp_vec = vec_add(rp_vec,part_vec);
-
- part_vec = vec_perm(rp_vec,VSX_CHAR_ZERO,VSX_LEFTSHIFTED4_3);
- rp_vec = vec_add(rp_vec,part_vec);
-
- vec_st(rp_vec,0,rp);
- rp += 15;
- istop -= 16;
-
- /* Since 16 % bpp = 16 % 3 = 1, last element of array must
- * be proceeded manually
- */
- *rp = (png_byte)(((int)(*rp) + (int)(*(rp-bpp))) & 0xff);
- rp++;
- }
-
- if(istop > 0)
- for (i = 0; i < istop % 16; i++)
- {
- *rp = (png_byte)(((int)(*rp) + (int)(*(rp-bpp))) & 0xff);
- rp++;
- }
-}
-
-void png_read_filter_row_avg4_vsx(png_row_infop row_info, png_bytep row,
- png_const_bytep prev_row)
-{
- png_byte bpp = 4;
-
- vector unsigned char rp_vec;
- vector unsigned char pp_vec;
- vector unsigned char pp_part_vec;
- vector unsigned char rp_part_vec;
- vector unsigned char avg_vec;
-
- vsx_declare_common_vars(row_info,row,prev_row,bpp)
- rp -= bpp;
- if(istop >= bpp)
- istop -= bpp;
-
- for (i = 0; i < bpp; i++)
- {
- *rp = (png_byte)(((int)(*rp) +
- ((int)(*pp++) / 2 )) & 0xff);
-
- rp++;
- }
-
- /* Altivec operations require 16-byte aligned data
- * but input can be unaligned. So we calculate
- * unaligned part as usual.
- */
- for (i = 0; i < unaligned_top; i++)
- {
- *rp = (png_byte)(((int)(*rp) +
- (int)(*pp++ + *(rp-bpp)) / 2 ) & 0xff);
-
- rp++;
- }
-
- /* Using SIMD while we can */
- while( istop >= 16 )
- {
- for(i=0;i < bpp ; i++)
- {
- *rp = (png_byte)(((int)(*rp) +
- (int)(*pp++ + *(rp-bpp)) / 2 ) & 0xff);
-
- rp++;
- }
- rp -= bpp;
- pp -= bpp;
-
- vec_ld_unaligned(pp_vec,pp);
- rp_vec = vec_ld(0,rp);
-
- rp_part_vec = vec_perm(rp_vec,VSX_CHAR_ZERO,VSX_LEFTSHIFTED1_4);
- pp_part_vec = vec_perm(pp_vec,VSX_CHAR_ZERO,VSX_NOT_SHIFTED1_4);
- avg_vec = vec_avg(rp_part_vec,pp_part_vec);
- avg_vec = vec_sub(avg_vec, vec_and(vec_xor(rp_part_vec,pp_part_vec),vec_splat_u8(1)));
- rp_vec = vec_add(rp_vec,avg_vec);
-
- rp_part_vec = vec_perm(rp_vec,VSX_CHAR_ZERO,VSX_LEFTSHIFTED2_4);
- pp_part_vec = vec_perm(pp_vec,VSX_CHAR_ZERO,VSX_NOT_SHIFTED2_4);
- avg_vec = vec_avg(rp_part_vec,pp_part_vec);
- avg_vec = vec_sub(avg_vec, vec_and(vec_xor(rp_part_vec,pp_part_vec),vec_splat_u8(1)));
- rp_vec = vec_add(rp_vec,avg_vec);
-
- rp_part_vec = vec_perm(rp_vec,VSX_CHAR_ZERO,VSX_LEFTSHIFTED3_4);
- pp_part_vec = vec_perm(pp_vec,VSX_CHAR_ZERO,VSX_NOT_SHIFTED3_4);
- avg_vec = vec_avg(rp_part_vec,pp_part_vec);
- avg_vec = vec_sub(avg_vec, vec_and(vec_xor(rp_part_vec,pp_part_vec),vec_splat_u8(1)));
- rp_vec = vec_add(rp_vec,avg_vec);
-
- vec_st(rp_vec,0,rp);
-
- rp += 16;
- pp += 16;
- istop -= 16;
- }
-
- if(istop > 0)
- for (i = 0; i < istop % 16; i++)
- {
- *rp = (png_byte)(((int)(*rp) +
- (int)(*pp++ + *(rp-bpp)) / 2 ) & 0xff);
-
- rp++;
- }
-}
-
-void png_read_filter_row_avg3_vsx(png_row_infop row_info, png_bytep row,
- png_const_bytep prev_row)
-{
- png_byte bpp = 3;
-
- vector unsigned char rp_vec;
- vector unsigned char pp_vec;
- vector unsigned char pp_part_vec;
- vector unsigned char rp_part_vec;
- vector unsigned char avg_vec;
-
- vsx_declare_common_vars(row_info,row,prev_row,bpp)
- rp -= bpp;
- if(istop >= bpp)
- istop -= bpp;
-
- for (i = 0; i < bpp; i++)
- {
- *rp = (png_byte)(((int)(*rp) +
- ((int)(*pp++) / 2 )) & 0xff);
-
- rp++;
- }
-
- /* Altivec operations require 16-byte aligned data
- * but input can be unaligned. So we calculate
- * unaligned part as usual.
- */
- for (i = 0; i < unaligned_top; i++)
- {
- *rp = (png_byte)(((int)(*rp) +
- (int)(*pp++ + *(rp-bpp)) / 2 ) & 0xff);
-
- rp++;
- }
-
- /* Using SIMD while we can */
- while( istop >= 16 )
- {
- for(i=0;i < bpp ; i++)
- {
- *rp = (png_byte)(((int)(*rp) +
- (int)(*pp++ + *(rp-bpp)) / 2 ) & 0xff);
-
- rp++;
- }
- rp -= bpp;
- pp -= bpp;
-
- vec_ld_unaligned(pp_vec,pp);
- rp_vec = vec_ld(0,rp);
-
- rp_part_vec = vec_perm(rp_vec,VSX_CHAR_ZERO,VSX_LEFTSHIFTED1_3);
- pp_part_vec = vec_perm(pp_vec,VSX_CHAR_ZERO,VSX_NOT_SHIFTED1_3);
- avg_vec = vec_avg(rp_part_vec,pp_part_vec);
- avg_vec = vec_sub(avg_vec, vec_and(vec_xor(rp_part_vec,pp_part_vec),vec_splat_u8(1)));
- rp_vec = vec_add(rp_vec,avg_vec);
-
- rp_part_vec = vec_perm(rp_vec,VSX_CHAR_ZERO,VSX_LEFTSHIFTED2_3);
- pp_part_vec = vec_perm(pp_vec,VSX_CHAR_ZERO,VSX_NOT_SHIFTED2_3);
- avg_vec = vec_avg(rp_part_vec,pp_part_vec);
- avg_vec = vec_sub(avg_vec, vec_and(vec_xor(rp_part_vec,pp_part_vec),vec_splat_u8(1)));
- rp_vec = vec_add(rp_vec,avg_vec);
-
- rp_part_vec = vec_perm(rp_vec,VSX_CHAR_ZERO,VSX_LEFTSHIFTED3_3);
- pp_part_vec = vec_perm(pp_vec,VSX_CHAR_ZERO,VSX_NOT_SHIFTED3_3);
- avg_vec = vec_avg(rp_part_vec,pp_part_vec);
- avg_vec = vec_sub(avg_vec, vec_and(vec_xor(rp_part_vec,pp_part_vec),vec_splat_u8(1)));
- rp_vec = vec_add(rp_vec,avg_vec);
-
- rp_part_vec = vec_perm(rp_vec,VSX_CHAR_ZERO,VSX_LEFTSHIFTED4_3);
- pp_part_vec = vec_perm(pp_vec,VSX_CHAR_ZERO,VSX_NOT_SHIFTED4_3);
- avg_vec = vec_avg(rp_part_vec,pp_part_vec);
- avg_vec = vec_sub(avg_vec, vec_and(vec_xor(rp_part_vec,pp_part_vec),vec_splat_u8(1)));
- rp_vec = vec_add(rp_vec,avg_vec);
-
- vec_st(rp_vec,0,rp);
-
- rp += 15;
- pp += 15;
- istop -= 16;
-
- /* Since 16 % bpp = 16 % 3 = 1, last element of array must
- * be proceeded manually
- */
- *rp = (png_byte)(((int)(*rp) +
- (int)(*pp++ + *(rp-bpp)) / 2 ) & 0xff);
- rp++;
- }
-
- if(istop > 0)
- for (i = 0; i < istop % 16; i++)
- {
- *rp = (png_byte)(((int)(*rp) +
- (int)(*pp++ + *(rp-bpp)) / 2 ) & 0xff);
-
- rp++;
- }
-}
-
-/* Bytewise c ? t : e. */
-#define if_then_else(c,t,e) vec_sel(e,t,c)
-
-#define vsx_paeth_process(rp,pp,a,b,c,pa,pb,pc,bpp) {\
- c = *(pp - bpp);\
- a = *(rp - bpp);\
- b = *pp++;\
- p = b - c;\
- pc = a - c;\
- pa = vsx_abs(p);\
- pb = vsx_abs(pc);\
- pc = vsx_abs(p + pc);\
- if (pb < pa) pa = pb, a = b;\
- if (pc < pa) a = c;\
- a += *rp;\
- *rp++ = (png_byte)a;\
- }
-
-void png_read_filter_row_paeth4_vsx(png_row_infop row_info, png_bytep row,
- png_const_bytep prev_row)
-{
- png_byte bpp = 4;
-
- int a, b, c, pa, pb, pc, p;
- vector unsigned char rp_vec;
- vector unsigned char pp_vec;
- vector unsigned short a_vec,b_vec,c_vec,nearest_vec;
- vector signed short pa_vec,pb_vec,pc_vec,smallest_vec;
-
- vsx_declare_common_vars(row_info,row,prev_row,bpp)
- rp -= bpp;
- if(istop >= bpp)
- istop -= bpp;
-
- /* Process the first pixel in the row completely (this is the same as 'up'
- * because there is only one candidate predictor for the first row).
- */
- for(i = 0; i < bpp ; i++)
- {
- *rp = (png_byte)( *rp + *pp);
- rp++;
- pp++;
- }
-
- for(i = 0; i < unaligned_top ; i++)
- {
- vsx_paeth_process(rp,pp,a,b,c,pa,pb,pc,bpp)
- }
-
- while( istop >= 16)
- {
- for(i = 0; i < bpp ; i++)
- {
- vsx_paeth_process(rp,pp,a,b,c,pa,pb,pc,bpp)
- }
-
- rp -= bpp;
- pp -= bpp;
- rp_vec = vec_ld(0,rp);
- vec_ld_unaligned(pp_vec,pp);
-
- a_vec = vsx_char_to_short(vec_perm(rp_vec , VSX_CHAR_ZERO , VSX_LEFTSHIFTED1_4),1,4);
- b_vec = vsx_char_to_short(vec_perm(pp_vec , VSX_CHAR_ZERO , VSX_NOT_SHIFTED1_4),1,4);
- c_vec = vsx_char_to_short(vec_perm(pp_vec , VSX_CHAR_ZERO , VSX_LEFTSHIFTED1_4),1,4);
- pa_vec = (vector signed short) vec_sub(b_vec,c_vec);
- pb_vec = (vector signed short) vec_sub(a_vec , c_vec);
- pc_vec = vec_add(pa_vec,pb_vec);
- pa_vec = vec_abs(pa_vec);
- pb_vec = vec_abs(pb_vec);
- pc_vec = vec_abs(pc_vec);
- smallest_vec = vec_min(pc_vec, vec_min(pa_vec,pb_vec));
- nearest_vec = if_then_else(
- vec_cmpeq(pa_vec,smallest_vec),
- a_vec,
- if_then_else(
- vec_cmpeq(pb_vec,smallest_vec),
- b_vec,
- c_vec
- )
- );
- rp_vec = vec_add(rp_vec,(vsx_short_to_char(nearest_vec,1,4)));
-
- a_vec = vsx_char_to_short(vec_perm(rp_vec , VSX_CHAR_ZERO , VSX_LEFTSHIFTED2_4),2,4);
- b_vec = vsx_char_to_short(vec_perm(pp_vec , VSX_CHAR_ZERO , VSX_NOT_SHIFTED2_4),2,4);
- c_vec = vsx_char_to_short(vec_perm(pp_vec , VSX_CHAR_ZERO , VSX_LEFTSHIFTED2_4),2,4);
- pa_vec = (vector signed short) vec_sub(b_vec,c_vec);
- pb_vec = (vector signed short) vec_sub(a_vec , c_vec);
- pc_vec = vec_add(pa_vec,pb_vec);
- pa_vec = vec_abs(pa_vec);
- pb_vec = vec_abs(pb_vec);
- pc_vec = vec_abs(pc_vec);
- smallest_vec = vec_min(pc_vec, vec_min(pa_vec,pb_vec));
- nearest_vec = if_then_else(
- vec_cmpeq(pa_vec,smallest_vec),
- a_vec,
- if_then_else(
- vec_cmpeq(pb_vec,smallest_vec),
- b_vec,
- c_vec
- )
- );
- rp_vec = vec_add(rp_vec,(vsx_short_to_char(nearest_vec,2,4)));
-
- a_vec = vsx_char_to_short(vec_perm(rp_vec , VSX_CHAR_ZERO , VSX_LEFTSHIFTED3_4),3,4);
- b_vec = vsx_char_to_short(vec_perm(pp_vec , VSX_CHAR_ZERO , VSX_NOT_SHIFTED3_4),3,4);
- c_vec = vsx_char_to_short(vec_perm(pp_vec , VSX_CHAR_ZERO , VSX_LEFTSHIFTED3_4),3,4);
- pa_vec = (vector signed short) vec_sub(b_vec,c_vec);
- pb_vec = (vector signed short) vec_sub(a_vec , c_vec);
- pc_vec = vec_add(pa_vec,pb_vec);
- pa_vec = vec_abs(pa_vec);
- pb_vec = vec_abs(pb_vec);
- pc_vec = vec_abs(pc_vec);
- smallest_vec = vec_min(pc_vec, vec_min(pa_vec,pb_vec));
- nearest_vec = if_then_else(
- vec_cmpeq(pa_vec,smallest_vec),
- a_vec,
- if_then_else(
- vec_cmpeq(pb_vec,smallest_vec),
- b_vec,
- c_vec
- )
- );
- rp_vec = vec_add(rp_vec,(vsx_short_to_char(nearest_vec,3,4)));
-
- vec_st(rp_vec,0,rp);
-
- rp += 16;
- pp += 16;
- istop -= 16;
- }
-
- if(istop > 0)
- for (i = 0; i < istop % 16; i++)
- {
- vsx_paeth_process(rp,pp,a,b,c,pa,pb,pc,bpp)
- }
-}
-
-void png_read_filter_row_paeth3_vsx(png_row_infop row_info, png_bytep row,
- png_const_bytep prev_row)
-{
- png_byte bpp = 3;
-
- int a, b, c, pa, pb, pc, p;
- vector unsigned char rp_vec;
- vector unsigned char pp_vec;
- vector unsigned short a_vec,b_vec,c_vec,nearest_vec;
- vector signed short pa_vec,pb_vec,pc_vec,smallest_vec;
-
- vsx_declare_common_vars(row_info,row,prev_row,bpp)
- rp -= bpp;
- if(istop >= bpp)
- istop -= bpp;
-
- /* Process the first pixel in the row completely (this is the same as 'up'
- * because there is only one candidate predictor for the first row).
- */
- for(i = 0; i < bpp ; i++)
- {
- *rp = (png_byte)( *rp + *pp);
- rp++;
- pp++;
- }
-
- for(i = 0; i < unaligned_top ; i++)
- {
- vsx_paeth_process(rp,pp,a,b,c,pa,pb,pc,bpp)
- }
-
- while( istop >= 16)
- {
- for(i = 0; i < bpp ; i++)
- {
- vsx_paeth_process(rp,pp,a,b,c,pa,pb,pc,bpp)
- }
-
- rp -= bpp;
- pp -= bpp;
- rp_vec = vec_ld(0,rp);
- vec_ld_unaligned(pp_vec,pp);
-
- a_vec = vsx_char_to_short(vec_perm(rp_vec , VSX_CHAR_ZERO , VSX_LEFTSHIFTED1_3),1,3);
- b_vec = vsx_char_to_short(vec_perm(pp_vec , VSX_CHAR_ZERO , VSX_NOT_SHIFTED1_3),1,3);
- c_vec = vsx_char_to_short(vec_perm(pp_vec , VSX_CHAR_ZERO , VSX_LEFTSHIFTED1_3),1,3);
- pa_vec = (vector signed short) vec_sub(b_vec,c_vec);
- pb_vec = (vector signed short) vec_sub(a_vec , c_vec);
- pc_vec = vec_add(pa_vec,pb_vec);
- pa_vec = vec_abs(pa_vec);
- pb_vec = vec_abs(pb_vec);
- pc_vec = vec_abs(pc_vec);
- smallest_vec = vec_min(pc_vec, vec_min(pa_vec,pb_vec));
- nearest_vec = if_then_else(
- vec_cmpeq(pa_vec,smallest_vec),
- a_vec,
- if_then_else(
- vec_cmpeq(pb_vec,smallest_vec),
- b_vec,
- c_vec
- )
- );
- rp_vec = vec_add(rp_vec,(vsx_short_to_char(nearest_vec,1,3)));
-
- a_vec = vsx_char_to_short(vec_perm(rp_vec , VSX_CHAR_ZERO , VSX_LEFTSHIFTED2_3),2,3);
- b_vec = vsx_char_to_short(vec_perm(pp_vec , VSX_CHAR_ZERO , VSX_NOT_SHIFTED2_3),2,3);
- c_vec = vsx_char_to_short(vec_perm(pp_vec , VSX_CHAR_ZERO , VSX_LEFTSHIFTED2_3),2,3);
- pa_vec = (vector signed short) vec_sub(b_vec,c_vec);
- pb_vec = (vector signed short) vec_sub(a_vec , c_vec);
- pc_vec = vec_add(pa_vec,pb_vec);
- pa_vec = vec_abs(pa_vec);
- pb_vec = vec_abs(pb_vec);
- pc_vec = vec_abs(pc_vec);
- smallest_vec = vec_min(pc_vec, vec_min(pa_vec,pb_vec));
- nearest_vec = if_then_else(
- vec_cmpeq(pa_vec,smallest_vec),
- a_vec,
- if_then_else(
- vec_cmpeq(pb_vec,smallest_vec),
- b_vec,
- c_vec
- )
- );
- rp_vec = vec_add(rp_vec,(vsx_short_to_char(nearest_vec,2,3)));
-
- a_vec = vsx_char_to_short(vec_perm(rp_vec , VSX_CHAR_ZERO , VSX_LEFTSHIFTED3_3),3,3);
- b_vec = vsx_char_to_short(vec_perm(pp_vec , VSX_CHAR_ZERO , VSX_NOT_SHIFTED3_3),3,3);
- c_vec = vsx_char_to_short(vec_perm(pp_vec , VSX_CHAR_ZERO , VSX_LEFTSHIFTED3_3),3,3);
- pa_vec = (vector signed short) vec_sub(b_vec,c_vec);
- pb_vec = (vector signed short) vec_sub(a_vec , c_vec);
- pc_vec = vec_add(pa_vec,pb_vec);
- pa_vec = vec_abs(pa_vec);
- pb_vec = vec_abs(pb_vec);
- pc_vec = vec_abs(pc_vec);
- smallest_vec = vec_min(pc_vec, vec_min(pa_vec,pb_vec));
- nearest_vec = if_then_else(
- vec_cmpeq(pa_vec,smallest_vec),
- a_vec,
- if_then_else(
- vec_cmpeq(pb_vec,smallest_vec),
- b_vec,
- c_vec
- )
- );
- rp_vec = vec_add(rp_vec,(vsx_short_to_char(nearest_vec,3,3)));
-
- a_vec = vsx_char_to_short(vec_perm(rp_vec , VSX_CHAR_ZERO , VSX_LEFTSHIFTED4_3),4,3);
- b_vec = vsx_char_to_short(vec_perm(pp_vec , VSX_CHAR_ZERO , VSX_NOT_SHIFTED4_3),4,3);
- c_vec = vsx_char_to_short(vec_perm(pp_vec , VSX_CHAR_ZERO , VSX_LEFTSHIFTED4_3),4,3);
- pa_vec = (vector signed short) vec_sub(b_vec,c_vec);
- pb_vec = (vector signed short) vec_sub(a_vec , c_vec);
- pc_vec = vec_add(pa_vec,pb_vec);
- pa_vec = vec_abs(pa_vec);
- pb_vec = vec_abs(pb_vec);
- pc_vec = vec_abs(pc_vec);
- smallest_vec = vec_min(pc_vec, vec_min(pa_vec,pb_vec));
- nearest_vec = if_then_else(
- vec_cmpeq(pa_vec,smallest_vec),
- a_vec,
- if_then_else(
- vec_cmpeq(pb_vec,smallest_vec),
- b_vec,
- c_vec
- )
- );
- rp_vec = vec_add(rp_vec,(vsx_short_to_char(nearest_vec,4,3)));
-
- vec_st(rp_vec,0,rp);
-
- rp += 15;
- pp += 15;
- istop -= 16;
-
- /* Since 16 % bpp = 16 % 3 = 1, last element of array must
- * be proceeded manually
- */
- vsx_paeth_process(rp,pp,a,b,c,pa,pb,pc,bpp)
- }
-
- if(istop > 0)
- for (i = 0; i < istop % 16; i++)
- {
- vsx_paeth_process(rp,pp,a,b,c,pa,pb,pc,bpp)
- }
-}
-
-#endif /* PNG_POWERPC_VSX_OPT > 0 */
-#endif /* PNG_POWERPC_VSX_IMPLEMENTATION == 1 (intrinsics) */
-#endif /* READ */
diff --git a/contrib/libs/libpng/powerpc/powerpc_init.c b/contrib/libs/libpng/powerpc/powerpc_init.c
deleted file mode 100644
index b533cc5527..0000000000
--- a/contrib/libs/libpng/powerpc/powerpc_init.c
+++ /dev/null
@@ -1,125 +0,0 @@
-/* powerpc_init.c - POWERPC optimised filter functions
- *
- * Copyright (c) 2018 Cosmin Truta
- * Copyright (c) 2017 Glenn Randers-Pehrson
- * Written by Vadim Barkov, 2017.
- *
- * This code is released under the libpng license.
- * For conditions of distribution and use, see the disclaimer
- * and license in png.h
- */
-
-/* Below, after checking __linux__, various non-C90 POSIX 1003.1 functions are
- * called.
- */
-#define _POSIX_SOURCE 1
-
-#include <stdio.h>
-#include "../pngpriv.h"
-
-#ifdef PNG_READ_SUPPORTED
-
-#if PNG_POWERPC_VSX_OPT > 0
-#ifdef PNG_POWERPC_VSX_CHECK_SUPPORTED /* Do run-time checks */
-/* WARNING: it is strongly recommended that you do not build libpng with
- * run-time checks for CPU features if at all possible. In the case of the PowerPC
- * VSX instructions there is no processor-specific way of detecting the
- * presence of the required support, therefore run-time detection is extremely
- * OS specific.
- *
- * You may set the macro PNG_POWERPC_VSX_FILE to the file name of file containing
- * a fragment of C source code which defines the png_have_vsx function. There
- * are a number of implementations in contrib/powerpc-vsx, but the only one that
- * has partial support is contrib/powerpc-vsx/linux.c - a generic Linux
- * implementation which reads /proc/cpufino.
- */
-#ifndef PNG_POWERPC_VSX_FILE
-# ifdef __linux__
-# define PNG_POWERPC_VSX_FILE "contrib/powerpc-vsx/linux_aux.c"
-# endif
-#endif
-
-#ifdef PNG_POWERPC_VSX_FILE
-
-#include <signal.h> /* for sig_atomic_t */
-static int png_have_vsx(png_structp png_ptr);
-#error #include PNG_POWERPC_VSX_FILE
-
-#else /* PNG_POWERPC_VSX_FILE */
-# error "PNG_POWERPC_VSX_FILE undefined: no support for run-time POWERPC VSX checks"
-#endif /* PNG_POWERPC_VSX_FILE */
-#endif /* PNG_POWERPC_VSX_CHECK_SUPPORTED */
-
-void
-png_init_filter_functions_vsx(png_structp pp, unsigned int bpp)
-{
- /* The switch statement is compiled in for POWERPC_VSX_API, the call to
- * png_have_vsx is compiled in for POWERPC_VSX_CHECK. If both are defined
- * the check is only performed if the API has not set the PowerPC option on
- * or off explicitly. In this case the check controls what happens.
- */
-
-#ifdef PNG_POWERPC_VSX_API_SUPPORTED
- switch ((pp->options >> PNG_POWERPC_VSX) & 3)
- {
- case PNG_OPTION_UNSET:
- /* Allow the run-time check to execute if it has been enabled -
- * thus both API and CHECK can be turned on. If it isn't supported
- * this case will fall through to the 'default' below, which just
- * returns.
- */
-#endif /* PNG_POWERPC_VSX_API_SUPPORTED */
-#ifdef PNG_POWERPC_VSX_CHECK_SUPPORTED
- {
- static volatile sig_atomic_t no_vsx = -1; /* not checked */
-
- if (no_vsx < 0)
- no_vsx = !png_have_vsx(pp);
-
- if (no_vsx)
- return;
- }
-#ifdef PNG_POWERPC_VSX_API_SUPPORTED
- break;
-#endif
-#endif /* PNG_POWERPC_VSX_CHECK_SUPPORTED */
-
-#ifdef PNG_POWERPC_VSX_API_SUPPORTED
- default: /* OFF or INVALID */
- return;
-
- case PNG_OPTION_ON:
- /* Option turned on */
- break;
- }
-#endif
-
- /* IMPORTANT: any new internal functions used here must be declared using
- * PNG_INTERNAL_FUNCTION in ../pngpriv.h. This is required so that the
- * 'prefix' option to configure works:
- *
- * ./configure --with-libpng-prefix=foobar_
- *
- * Verify you have got this right by running the above command, doing a build
- * and examining pngprefix.h; it must contain a #define for every external
- * function you add. (Notice that this happens automatically for the
- * initialization function.)
- */
- pp->read_filter[PNG_FILTER_VALUE_UP-1] = png_read_filter_row_up_vsx;
-
- if (bpp == 3)
- {
- pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub3_vsx;
- pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg3_vsx;
- pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = png_read_filter_row_paeth3_vsx;
- }
-
- else if (bpp == 4)
- {
- pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub4_vsx;
- pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg4_vsx;
- pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = png_read_filter_row_paeth4_vsx;
- }
-}
-#endif /* PNG_POWERPC_VSX_OPT > 0 */
-#endif /* READ */
diff --git a/contrib/libs/libpng/ya.make b/contrib/libs/libpng/ya.make
deleted file mode 100644
index c9fede46ba..0000000000
--- a/contrib/libs/libpng/ya.make
+++ /dev/null
@@ -1,69 +0,0 @@
-# Generated by devtools/yamaker from nixpkgs 24.05.
-
-LIBRARY()
-
-LICENSE(
- Libpng AND
- MIT AND
- libpng-2.0
-)
-
-LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
-
-VERSION(1.6.46)
-
-ORIGINAL_SOURCE(https://github.com/pnggroup/libpng/archive/v1.6.46.tar.gz)
-
-PEERDIR(
- contrib/libs/zlib
-)
-
-ADDINCL(
- contrib/libs/libpng
-)
-
-NO_COMPILER_WARNINGS()
-
-NO_RUNTIME()
-
-SRCS(
- intel/filter_sse2_intrinsics.c
- intel/intel_init.c
- mips/filter_mmi_inline_assembly.c
- mips/filter_msa_intrinsics.c
- mips/mips_init.c
- png.c
- pngerror.c
- pngget.c
- pngmem.c
- pngpread.c
- pngread.c
- pngrio.c
- pngrtran.c
- pngrutil.c
- pngset.c
- pngtrans.c
- pngwio.c
- pngwrite.c
- pngwtran.c
- pngwutil.c
- powerpc/filter_vsx_intrinsics.c
- powerpc/powerpc_init.c
-)
-
-IF (NOT MSVC)
- IF (ARCH_AARCH64 OR ARCH_ARM)
- SRCS(
- arm/arm_init.c
- arm/filter_neon.S
- arm/filter_neon_intrinsics.c
- arm/palette_neon_intrinsics.c
- )
- ENDIF()
-ENDIF()
-
-END()
-
-RECURSE(
- include
-)
diff --git a/contrib/libs/libtiff/.yandex_meta/__init__.py b/contrib/libs/libtiff/.yandex_meta/__init__.py
deleted file mode 100644
index 67f11e32e2..0000000000
--- a/contrib/libs/libtiff/.yandex_meta/__init__.py
+++ /dev/null
@@ -1,37 +0,0 @@
-from devtools.yamaker.modules import Linkable, Switch
-from devtools.yamaker.project import CMakeNinjaNixProject
-
-
-def post_install(self):
- m = self.yamakes["."]
- # Support Windows (if it is configured).
- m.SRCS.remove("tif_unix.c")
- m.after(
- "SRCS",
- Switch(
- OS_WINDOWS=Linkable(SRCS=["tif_win32.c"]),
- default=Linkable(SRCS=["tif_unix.c"]),
- ),
- )
-
-
-libtiff = CMakeNinjaNixProject(
- owners=["g:cpp-contrib", "g:images"],
- arcdir="contrib/libs/libtiff",
- nixattr="libtiff",
- build_targets=["tiff", "tiffxx"],
- disable_includes=[
- "jbig.h",
- "libdeflate.h",
- "Lerc_c_api.h",
- "LIBJPEG_12_PATH",
- ],
- install_subdir="libtiff",
- put_with={"tiff": {"tiffxx"}},
- copy_sources=[
- "tif_win32.c",
- "tiffio.hxx",
- ],
- addincl_global={".": {"."}},
- post_install=post_install,
-)
diff --git a/contrib/libs/libtiff/.yandex_meta/devtools.copyrights.report b/contrib/libs/libtiff/.yandex_meta/devtools.copyrights.report
deleted file mode 100644
index 918e51b5ea..0000000000
--- a/contrib/libs/libtiff/.yandex_meta/devtools.copyrights.report
+++ /dev/null
@@ -1,433 +0,0 @@
-# File format ($ symbol means the beginning of a line):
-#
-# $ # this message
-# $ # =======================
-# $ # comments (all commentaries should starts with some number of spaces and # symbol)
-# ${action} {license id} {license text hash}
-# $BELONGS ./ya/make/file/relative/path/1/ya.make ./ya/make/2/ya.make
-# ${all_file_action} filename
-# $ # user commentaries (many lines)
-# $ generated description - files with this license, license text... (some number of lines that starts with some number of spaces, do not modify)
-# ${action} {license spdx} {license text hash}
-# $BELONGS ./ya/make/file/relative/path/3/ya.make
-# ${all_file_action} filename
-# $ # user commentaries
-# $ generated description
-# $ ...
-#
-# You can modify action, all_file_action and add commentaries
-# Available actions:
-# keep - keep license in contrib and use in credits
-# skip - skip license
-# remove - remove all files with this license
-# rename - save license text/links into licenses texts file, but not store SPDX into LINCENSE macro. You should store correct license id into devtools.license.spdx.txt file
-#
-# {all file action} records will be generated when license text contains filename that exists on filesystem (in contrib directory)
-# We suppose that that files can contain some license info
-# Available all file actions:
-# FILE_IGNORE - ignore file (do nothing)
-# FILE_INCLUDE - include all file data into licenses text file
-# =======================
-
-KEEP COPYRIGHT_SERVICE_LABEL 02f4a551d37156b2cadc0a423496ee1b
-BELONGS ya.make
- License text:
- * Copyright (c) 1997 Greg Ward Larson
- * Copyright (c) 1997 Silicon Graphics, Inc.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- tif_luv.c [2:3]
-
-KEEP COPYRIGHT_SERVICE_LABEL 0f5876ba2b92a993e7778db495e68853
-BELONGS ya.make
- License text:
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- tif_stream.cxx [2:3]
-
-KEEP COPYRIGHT_SERVICE_LABEL 126b1d950b05c63796863bb1785c8301
-BELONGS ya.make
- License text:
- * Copyright (c) 2017, Planet Labs
- * Author: <even.rouault at spatialys.com>
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- tif_zstd.c [2:3]
-
-KEEP COPYRIGHT_SERVICE_LABEL 1a1ec6cbe72c1313391b7bfc4a429b1b
-BELONGS ya.make
- License text:
- * Copyright (c) 1997 Greg Ward Larson
- * Copyright (c) 1997 Silicon Graphics, Inc.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- tif_luv.c [2:3]
-
-KEEP COPYRIGHT_SERVICE_LABEL 26e3e126c3c9461c3df25463865d5aed
-BELONGS ya.make
- License text:
- * Copyright (c) 1992-1997 Sam Leffler
- * Copyright (c) 1992-1997 Silicon Graphics, Inc.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- tif_version.c [2:3]
-
-KEEP COPYRIGHT_SERVICE_LABEL 3703921323d1de27dda336a418a929e1
-BELONGS ya.make
- License text:
- Copyright (c) Joris Van Damme <info@awaresystems.be>
- Copyright (c) AWare Systems <http://www.awaresystems.be/>
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- tif_ojpeg.c [26:27]
-
-KEEP COPYRIGHT_SERVICE_LABEL 3af43c3228d92ca332f5da1a4e74c462
-BELONGS ya.make
- License text:
- * Copyright (c) 2018, Even Rouault
- * Author: <even.rouault at spatialys.com>
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- tif_lerc.c [2:3]
-
-KEEP COPYRIGHT_SERVICE_LABEL 43efd0408882fc6ab7b4d0e6a509486a
-BELONGS ya.make
- License text:
- * Copyright (c) 1994-1997 Sam Leffler
- * Copyright (c) 1994-1997 Silicon Graphics, Inc.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- tif_jpeg.c [2:3]
-
-KEEP COPYRIGHT_SERVICE_LABEL 5291d67777cdb207939ae625c800cf7a
-BELONGS ya.make
- License text:
- Copyright (c) Joris Van Damme <info@awaresystems.be>
- Copyright (c) AWare Systems <http://www.awaresystems.be/>
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- tif_ojpeg.c [26:27]
-
-KEEP COPYRIGHT_SERVICE_LABEL 5d275e91067f862067c44dab63f228bf
-BELONGS ya.make
- License text:
- * Copyright (c) 1994-1997 Sam Leffler
- * Copyright (c) 1994-1997 Silicon Graphics, Inc.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- tif_jpeg.c [2:3]
-
-KEEP COPYRIGHT_SERVICE_LABEL 6c8bec88a9b26ce67c07897c4f51fc24
-BELONGS ya.make
- License text:
- Copyright © 1988-1997 Sam Leffler\
- Copyright © 1991-1997 Silicon Graphics, Inc.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- LICENSE.md [3:4]
- README.md [49:50]
- t4.h [2:3]
- tif_aux.c [2:3]
- tif_close.c [2:3]
- tif_codec.c [2:3]
- tif_color.c [2:3]
- tif_compress.c [2:3]
- tif_dir.c [2:3]
- tif_dir.h [2:3]
- tif_dirinfo.c [2:3]
- tif_dirread.c [2:3]
- tif_dirwrite.c [2:3]
- tif_dumpmode.c [2:3]
- tif_error.c [2:3]
- tif_extension.c [2:3]
- tif_fax3.c [2:3]
- tif_fax3.h [2:3]
- tif_flush.c [2:3]
- tif_getimage.c [2:3]
- tif_jbig.c [2:3]
- tif_lzw.c [2:4]
- tif_next.c [2:3]
- tif_open.c [2:3]
- tif_packbits.c [2:3]
- tif_predict.c [2:3]
- tif_print.c [2:3]
- tif_read.c [2:3]
- tif_strip.c [2:3]
- tif_swab.c [2:3]
- tif_thunder.c [2:3]
- tif_tile.c [2:3]
- tif_unix.c [2:3]
- tif_warning.c [2:3]
- tif_win32.c [2:3]
- tif_write.c [2:3]
- tiff.h [2:3]
- tiffio.h [2:3]
- tiffio.hxx [2:3]
- tiffiop.h [2:3]
-
-KEEP COPYRIGHT_SERVICE_LABEL 73224a0952a09c8cd38738dc21c2a50b
-BELONGS ya.make
- License text:
- * Copyright (c) 1995-1997 Sam Leffler
- * Copyright (c) 1995-1997 Silicon Graphics, Inc.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- tif_predict.h [2:3]
- tif_zip.c [2:3]
-
-KEEP COPYRIGHT_SERVICE_LABEL 82fa6685ddccc6547af260e76986db7c
-BELONGS ya.make
- License text:
- * Copyright (C) 1990, 1995 Frank D. Cringle.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- tif_fax3.c [37:37]
- tif_fax3.h [34:34]
-
-KEEP COPYRIGHT_SERVICE_LABEL 875bb98a0d0a89c2bdf8807f21c47ee2
-BELONGS ya.make
- License text:
- Copyright © 1988-1997 Sam Leffler\
- Copyright © 1991-1997 Silicon Graphics, Inc.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- LICENSE.md [3:4]
- README.md [49:50]
- t4.h [2:3]
- tif_close.c [2:3]
- tif_codec.c [2:3]
- tif_color.c [2:3]
- tif_compress.c [2:3]
- tif_dir.c [2:3]
- tif_dir.h [2:3]
- tif_dirinfo.c [2:3]
- tif_dirread.c [2:3]
- tif_dirwrite.c [2:3]
- tif_dumpmode.c [2:3]
- tif_error.c [2:3]
- tif_extension.c [2:3]
- tif_flush.c [2:3]
- tif_jbig.c [2:3]
- tif_lzw.c [2:4]
- tif_next.c [2:3]
- tif_open.c [2:3]
- tif_packbits.c [2:3]
- tif_predict.c [2:3]
- tif_print.c [2:3]
- tif_read.c [2:3]
- tif_swab.c [2:3]
- tif_thunder.c [2:3]
- tif_unix.c [2:3]
- tif_warning.c [2:3]
- tif_win32.c [2:3]
- tif_write.c [2:3]
- tiff.h [2:3]
- tiffio.h [2:3]
- tiffio.hxx [2:3]
- tiffiop.h [2:3]
-
-KEEP COPYRIGHT_SERVICE_LABEL 8c360d6f0ec71502a00b51fc651777c0
-BELONGS ya.make
- License text:
- * Copyright (c) 2008-2009, Even Rouault <even dot rouault at spatialys.com>
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- tif_hash_set.c [8:8]
- tif_hash_set.h [10:10]
-
-KEEP COPYRIGHT_SERVICE_LABEL a3cb1aa41ae8a9d75ec398f4f3c190f4
-BELONGS ya.make
- License text:
- * Copyright (c) 2018, Mapbox
- * Author: <norman.barker at mapbox.com>
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- tif_webp.c [2:3]
-
-KEEP COPYRIGHT_SERVICE_LABEL aa60014c4f4fa0103095e881c9058943
-BELONGS ya.make
- License text:
- * Copyright (c) 1990-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- tif_fax3.c [2:3]
- tif_fax3.h [2:3]
-
-KEEP COPYRIGHT_SERVICE_LABEL ab503c149bbdb62e62af4464df420c15
-BELONGS ya.make
- License text:
- Use and Copyright
- -----------------
- Silicon Graphics has seen fit to allow us to give this work away. It
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- README.md [39:41]
-
-KEEP COPYRIGHT_SERVICE_LABEL b8ac42940a6acdcc47bb98264d0c6bb7
-BELONGS ya.make
- License text:
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- tif_stream.cxx [2:3]
-
-KEEP COPYRIGHT_SERVICE_LABEL bbe9fa01e09eaf94b8fa91c442f4aa07
-BELONGS ya.make
- License text:
- * Copyright (c) 1988-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
- * Copyright (c) 2022 Even Rouault
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- tif_lzw.c [2:4]
-
-KEEP COPYRIGHT_SERVICE_LABEL c095539af5a5517848bb0a8904574572
-BELONGS ya.make
- License text:
- * Copyright (c) 1995-1997 Sam Leffler
- * Copyright (c) 1995-1997 Silicon Graphics, Inc.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- tif_predict.h [2:3]
- tif_zip.c [2:3]
-
-KEEP COPYRIGHT_SERVICE_LABEL cafbf6d6a83504f46e9f5a9ad7dfa19a
-BELONGS ya.make
- License text:
- * Copyright (c) 1996-1997 Sam Leffler
- * Copyright (c) 1996 Pixar
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- tif_pixarlog.c [2:3]
-
-KEEP COPYRIGHT_SERVICE_LABEL e00084e446b0b91449c0de64cf5ac662
-BELONGS ya.make
- License text:
- * Copyright (c) 2010, Andrey Kiselev <dron@ak4719.spb.edu>
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- tif_lzma.c [2:2]
-
-KEEP COPYRIGHT_SERVICE_LABEL ea717385f3024bc2714f0b3f66b21801
-BELONGS ya.make
- License text:
- * Copyright (c) 1985, 1986 The Regents of the University of California.
- * All rights reserved.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- tif_lzw.c [1437:1438]
-
-KEEP COPYRIGHT_SERVICE_LABEL ef9e24bc2ee738c92b1a0aae6c46127d
-BELONGS ya.make
- License text:
- * Copyright (c) 1992-1997 Sam Leffler
- * Copyright (c) 1992-1997 Silicon Graphics, Inc.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- tif_version.c [2:3]
-
-KEEP COPYRIGHT_SERVICE_LABEL f20aeb63cf72afacb350c783e7f989dd
-BELONGS ya.make
- License text:
- * Copyright (c) 1996-1997 Sam Leffler
- * Copyright (c) 1996 Pixar
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- tif_pixarlog.c [2:3]
-
-KEEP COPYRIGHT_SERVICE_LABEL fc174ce2b63ba019d5be7c31f6de92ec
-BELONGS ya.make
- License text:
- * Copyright (c) 1991-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- tif_aux.c [2:3]
- tif_getimage.c [2:3]
- tif_strip.c [2:3]
- tif_tile.c [2:3]
diff --git a/contrib/libs/libtiff/.yandex_meta/devtools.licenses.report b/contrib/libs/libtiff/.yandex_meta/devtools.licenses.report
deleted file mode 100644
index 3ac1388219..0000000000
--- a/contrib/libs/libtiff/.yandex_meta/devtools.licenses.report
+++ /dev/null
@@ -1,169 +0,0 @@
-# File format ($ symbol means the beginning of a line):
-#
-# $ # this message
-# $ # =======================
-# $ # comments (all commentaries should starts with some number of spaces and # symbol)
-# ${action} {license spdx} {license text hash}
-# $BELONGS ./ya/make/file/relative/path/1/ya.make ./ya/make/2/ya.make
-# ${all_file_action} filename
-# $ # user commentaries (many lines)
-# $ generated description - files with this license, license text... (some number of lines that starts with some number of spaces, do not modify)
-# ${action} {license spdx} {license text hash}
-# $BELONGS ./ya/make/file/relative/path/3/ya.make
-# ${all_file_action} filename
-# $ # user commentaries
-# $ generated description
-# $ ...
-#
-# You can modify action, all_file_action and add commentaries
-# Available actions:
-# keep - keep license in contrib and use in credits
-# skip - skip license
-# remove - remove all files with this license
-# rename - save license text/links into licenses texts file, but not store SPDX into LINCENSE macro. You should store correct license id into devtools.license.spdx.txt file
-#
-# {all file action} records will be generated when license text contains filename that exists on filesystem (in contrib directory)
-# We suppose that that files can contain some license info
-# Available all file actions:
-# FILE_IGNORE - ignore file (do nothing)
-# FILE_INCLUDE - include all file data into licenses text file
-# =======================
-
-KEEP libtiff 1087b085d6ed8ae05e8e0da2fd9d523c
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: libtiff
- Score : 98.25
- Match type : TEXT
- Links : https://fedoraproject.org/wiki/Licensing/libtiff, https://spdx.org/licenses/libtiff
- Files with this license:
- tif_luv.c [5:22]
-
-KEEP BSD-3-Clause 136eef2e91c907bcedb253a3820d035b
-BELONGS ya.make
- License text:
- * port/{getopt.c, strcasecmp.c, strtoul.c}: Update modules from
- the NetBSD source tree (the old 4-clause BSD license changed to
- the new 3-clause one).
- Scancode info:
- Original SPDX id: BSD-3-Clause
- Score : 99.00
- Match type : NOTICE
- Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
- Files with this license:
- ChangeLog [14240:14242]
-
-KEEP MIT 85545b6051abd36fce0fc9cd8d2d53cc
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: MIT
- Score : 100.00
- Match type : TEXT
- Links : http://opensource.org/licenses/mit-license.php, https://spdx.org/licenses/MIT
- Files with this license:
- tif_hash_set.c [10:26]
- tif_hash_set.h [12:28]
-
-KEEP BSLA 8857e9639c91f42b460d4f3a33b2d1d4
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: LicenseRef-scancode-bsla
- Score : 100.00
- Match type : TEXT
- Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/bsla.LICENSE
- Files with this license:
- tif_lzw.c [1444:1454]
-
-KEEP libtiff a9ebcbf36a981b235e0c3e99fd1fad00
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: libtiff
- Score : 98.25
- Match type : TEXT
- Links : https://fedoraproject.org/wiki/Licensing/libtiff, https://spdx.org/licenses/libtiff
- Files with this license:
- tif_pixarlog.c [5:22]
-
-KEEP libtiff beaf73a8c96d48397cfe40c78d71ff1e
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: libtiff
- Score : 98.68
- Match type : NOTICE
- Links : https://fedoraproject.org/wiki/Licensing/libtiff, https://spdx.org/licenses/libtiff
- Files with this license:
- tif_ojpeg.c [29:37]
-
-KEEP libtiff cb289c781ede561c455760d78519a374
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: libtiff
- Score : 100.00
- Match type : TEXT
- Links : https://fedoraproject.org/wiki/Licensing/libtiff, https://spdx.org/licenses/libtiff
- Files with this license:
- t4.h [5:22]
- tif_aux.c [5:22]
- tif_close.c [5:22]
- tif_codec.c [5:22]
- tif_color.c [5:22]
- tif_compress.c [5:22]
- tif_dir.c [5:22]
- tif_dir.h [5:22]
- tif_dirinfo.c [5:22]
- tif_dirread.c [5:22]
- tif_dirwrite.c [5:22]
- tif_dumpmode.c [5:22]
- tif_error.c [5:22]
- tif_extension.c [5:22]
- tif_fax3.c [5:22]
- tif_fax3.h [5:22]
- tif_flush.c [5:22]
- tif_getimage.c [5:22]
- tif_jbig.c [5:22]
- tif_jpeg.c [5:22]
- tif_lerc.c [5:22]
- tif_lzma.c [4:21]
- tif_lzw.c [6:23]
- tif_next.c [5:22]
- tif_open.c [5:22]
- tif_packbits.c [5:22]
- tif_predict.c [5:22]
- tif_predict.h [5:22]
- tif_print.c [5:22]
- tif_read.c [5:22]
- tif_stream.cxx [5:22]
- tif_strip.c [5:22]
- tif_swab.c [5:22]
- tif_thunder.c [5:22]
- tif_tile.c [5:22]
- tif_unix.c [5:22]
- tif_version.c [5:22]
- tif_warning.c [5:22]
- tif_webp.c [5:22]
- tif_win32.c [5:22]
- tif_write.c [5:22]
- tif_zip.c [5:22]
- tif_zstd.c [5:22]
- tiff.h [5:22]
- tiffio.h [5:22]
- tiffio.hxx [5:22]
- tiffiop.h [5:22]
-
-KEEP libtiff e4630084e374a313643fc490bf5e1bfc
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: libtiff
- Score : 100.00
- Match type : TEXT
- Links : https://fedoraproject.org/wiki/Licensing/libtiff, https://spdx.org/licenses/libtiff
- Files with this license:
- LICENSE.md [6:23]
- README.md [52:69]
diff --git a/contrib/libs/libtiff/.yandex_meta/licenses.list.txt b/contrib/libs/libtiff/.yandex_meta/licenses.list.txt
deleted file mode 100644
index 4126a5ca00..0000000000
--- a/contrib/libs/libtiff/.yandex_meta/licenses.list.txt
+++ /dev/null
@@ -1,228 +0,0 @@
-====================BSD-3-Clause====================
- * port/{getopt.c, strcasecmp.c, strtoul.c}: Update modules from
- the NetBSD source tree (the old 4-clause BSD license changed to
- the new 3-clause one).
-
-
-====================BSLA====================
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-
-
-====================COPYRIGHT====================
- Copyright (c) Joris Van Damme <info@awaresystems.be>
- Copyright (c) AWare Systems <http://www.awaresystems.be/>
-
-
-====================COPYRIGHT====================
- * Copyright (C) 1990, 1995 Frank D. Cringle.
-
-
-====================COPYRIGHT====================
- * Copyright (c) 1985, 1986 The Regents of the University of California.
- * All rights reserved.
-
-
-====================COPYRIGHT====================
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
-
-
-====================COPYRIGHT====================
- * Copyright (c) 1988-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
- * Copyright (c) 2022 Even Rouault
-
-
-====================COPYRIGHT====================
- * Copyright (c) 1990-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
-
-
-====================COPYRIGHT====================
- * Copyright (c) 1991-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
-
-
-====================COPYRIGHT====================
- * Copyright (c) 1992-1997 Sam Leffler
- * Copyright (c) 1992-1997 Silicon Graphics, Inc.
-
-
-====================COPYRIGHT====================
- * Copyright (c) 1994-1997 Sam Leffler
- * Copyright (c) 1994-1997 Silicon Graphics, Inc.
-
-
-====================COPYRIGHT====================
- * Copyright (c) 1995-1997 Sam Leffler
- * Copyright (c) 1995-1997 Silicon Graphics, Inc.
-
-
-====================COPYRIGHT====================
- * Copyright (c) 1996-1997 Sam Leffler
- * Copyright (c) 1996 Pixar
-
-
-====================COPYRIGHT====================
- * Copyright (c) 1997 Greg Ward Larson
- * Copyright (c) 1997 Silicon Graphics, Inc.
-
-
-====================COPYRIGHT====================
- * Copyright (c) 2008-2009, Even Rouault <even dot rouault at spatialys.com>
-
-
-====================COPYRIGHT====================
- * Copyright (c) 2010, Andrey Kiselev <dron@ak4719.spb.edu>
-
-
-====================COPYRIGHT====================
- * Copyright (c) 2017, Planet Labs
- * Author: <even.rouault at spatialys.com>
-
-
-====================COPYRIGHT====================
- * Copyright (c) 2018, Even Rouault
- * Author: <even.rouault at spatialys.com>
-
-
-====================COPYRIGHT====================
- * Copyright (c) 2018, Mapbox
- * Author: <norman.barker at mapbox.com>
-
-
-====================COPYRIGHT====================
-Copyright © 1988-1997 Sam Leffler\
-Copyright © 1991-1997 Silicon Graphics, Inc.
-
-
-====================COPYRIGHT====================
-Use and Copyright
------------------
-Silicon Graphics has seen fit to allow us to give this work away. It
-
-
-====================MIT====================
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
-
-
-====================libtiff====================
- The licence agreement for this file is the same as the rest of the LibTiff
- library.
-
- IN NO EVENT SHALL JORIS VAN DAMME OR AWARE SYSTEMS BE LIABLE FOR
- ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- OF THIS SOFTWARE.
-
-
-====================libtiff====================
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Pixar, Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Pixar, Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL PIXAR, SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
-
-
-====================libtiff====================
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
-
-
-====================libtiff====================
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler, Greg Larson and Silicon Graphics may not be used in any
- * advertising or publicity relating to the software without the specific,
- * prior written permission of Sam Leffler, Greg Larson and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER, GREG LARSON OR SILICON GRAPHICS BE LIABLE
- * FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
-
-
-====================libtiff====================
-Permission to use, copy, modify, distribute, and sell this software and
-its documentation for any purpose is hereby granted without fee, provided
-that (i) the above copyright notices and this permission notice appear in
-all copies of the software and related documentation, and (ii) the names of
-Sam Leffler and Silicon Graphics may not be used in any advertising or
-publicity relating to the software without the specific, prior written
-permission of Sam Leffler and Silicon Graphics.
-
-THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
-EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
-WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
-
-IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
-ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
-OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
-LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
-OF THIS SOFTWARE. \ No newline at end of file
diff --git a/contrib/libs/libtiff/.yandex_meta/override.nix b/contrib/libs/libtiff/.yandex_meta/override.nix
deleted file mode 100644
index f2bace9f33..0000000000
--- a/contrib/libs/libtiff/.yandex_meta/override.nix
+++ /dev/null
@@ -1,29 +0,0 @@
-pkgs: attrs: with pkgs; rec {
- version = "4.7.0";
-
- src = fetchFromGitLab {
- owner = "libtiff";
- repo = "libtiff";
- rev = "v${version}";
- hash = "sha256-SuK9/a6OUAumEe1kz1itFJGKxJzbmHkBVLMnyXhIwmQ=";
- };
-
- patches = [];
- postPatch = "";
-
- nativeBuildInputs = [
- cmake
- ];
-
- buildInputs = [
- libjpeg
- libwebp
- xz
- zlib
- zstd
- ];
-
- cmakeFlags = [
- "-Dlzma=ON"
- ];
-}
diff --git a/contrib/libs/libtiff/CONTRIBUTING.md b/contrib/libs/libtiff/CONTRIBUTING.md
deleted file mode 100644
index 1291d61cf7..0000000000
--- a/contrib/libs/libtiff/CONTRIBUTING.md
+++ /dev/null
@@ -1,19 +0,0 @@
-Contributing
-------------
-
-libtiff uses a ``.clang-format`` file to enforce code formatting rules.
-
-Automatic code reformatting can be done with pre-commit.
-
-Install (once) pre-commit with ``python -m pip install pre-commit``.
-
-Install it (once) in the libtiff git repository with ``pre-commit install``.
-
-Then the rules defined in the ``.pre-commit-config.yaml`` file will be
-enforced at ``git commit`` time, with automatic reformatting.
-
-Due to whole-tree code reformatting done during libtiff 4.5 development,
-``git blame`` information might be misleading. To avoid that, you need
-to modify your git configuration as following to ignore the revision of
-the whole-tree reformatting:
-``git config blame.ignoreRevsFile .git-blame-ignore-revs``.
diff --git a/contrib/libs/libtiff/ChangeLog b/contrib/libs/libtiff/ChangeLog
deleted file mode 100644
index a6ab18783c..0000000000
--- a/contrib/libs/libtiff/ChangeLog
+++ /dev/null
@@ -1,17406 +0,0 @@
-2024-09-11 Even Rouault <even.rouault@spatialys.com>
-
- libtiff v4.7.0rc2 preparation
-
-2024-09-11 Even Rouault <even.rouault@spatialys.com>
-
- configure.ac: make a provision to look for up to python 3.16 ...
- hopefully we'll have ditched autoconf support at that point...
-
- Fix test dependency on tiff2rgba-32BPP that breaks 'make check -jX'
-
- test/tiff2ps*.sh scripts: try to use POSIX only diff flags.
-
-2024-09-11 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'automake_doc_fix' into 'master'
- doc/Makefile.am: make sure that 'doc-html' and 'doc-man' targets have dependencies to avoid them to be rebuilt by successive make
-
- See merge request libtiff/libtiff!657
-
-2024-09-10 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch '4_7_0_rst_rgb2ycbcr_thumbnail' into 'master'
- v4.7.0.rst: clarify that rgb2ycbcr and thumbnail are not installed
-
- See merge request libtiff/libtiff!659
-
-2024-09-10 Even Rouault <even.rouault@spatialys.com>
-
- v4.7.0.rst: clarify that rgb2ycbcr and thumbnail are not installed.
-
-2024-09-08 Even Rouault <even.rouault@spatialys.com>
-
- doc/Makefile.am: make sure that 'doc-html' and 'doc-man' targets have dependencies to avoid them to be rebuilt by successive make
-
- doc/Makefile.am: move rst_sources and EXTRA_DIST variables on top of file
-
-2024-09-07 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'index_rst_formatting_issue' into 'master'
- index.rst: fix formatting issue
-
- See merge request libtiff/libtiff!656
-
-2024-09-07 Even Rouault <even.rouault@spatialys.com>
-
- index.rst: fix formatting issue.
-
-2024-09-07 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'prepare_release_4_7_0' into 'master'
- Prepare release 4.7.0
-
- See merge request libtiff/libtiff!654
-
-2024-09-07 Even Rouault <even.rouault@spatialys.com>
-
- Doc: remove 'Master' terminlogy.
-
- v4.7.0.rst: remove mention about autoconf-archive since that change has been reverted
-
- Revert "autotools: allow pulling in updated macros from autoconf-archive"
- This reverts commit c820d16c30c27b3be6c3d10834b6d75607ae9d77.
-
- Revert "HOWTO-RELEASE: document the necessary dependencies for producing dist tarballs"
- This reverts commit f1a91e42b3f23641cb5559fb60e1d73d201275eb.
-
- Revert "configure.ac: fix HAVE_OPENGL determination due to recent changes"
- This reverts commit c370e67f7fd9320674544113218b7fbca4f65c2b.
-
- configure.ac: fix HAVE_OPENGL determination due to recent changes.
-
- Update version numbers for 4.7.0.
-
- Update ChangeLog and create release notes for v4.7.0.
-
-2024-09-06 Even Rouault <even.rouault@spatialys.com>
-
- typo fixes.
-
-2024-09-06 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'autoconf-archive' into 'master'
- autotools: allow pulling in updated macros from autoconf-archive
-
- See merge request libtiff/libtiff!645
-
-2024-09-06 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'remove_last_usage_of_get_field_type' into 'master'
- Change last usage of get_field_type at TIFFWriteDirectorySec() to set_field_type
-
- See merge request libtiff/libtiff!653
-
-2024-09-06 Even Rouault <even.rouault@spatialys.com>
-
- libtiff v4.7.0rc1 preparation
-
-2024-09-06 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'autoconf-archive' into 'master'
- autotools: allow pulling in updated macros from autoconf-archive
-
- See merge request libtiff/libtiff!645
-
-2024-09-06 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'remove_last_usage_of_get_field_type' into 'master'
- Change last usage of get_field_type at TIFFWriteDirectorySec() to set_field_type
-
- See merge request libtiff/libtiff!653
-
-2024-09-05 Su_Laus <sulau@freenet.de>
-
- Change last usage of get_field_type at TIFFWriteDirectorySec() for codec related tags to set_field_type.
-
-2024-09-03 Eli Schwartz <eschwartz93@gmail.com>
-
- HOWTO-RELEASE: document the necessary dependencies for producing dist tarballs
-
- autogen.sh: actually return failure if any step failed.
- Previously, it exited with failure if and only if the wget calls failed.
- But it is possible for any command to fail, e.g. if the autotools are
- broken, misconfigured, or missing dependencies.
-
-2024-09-03 Eli Schwartz <eschwartz93@gmail.com>
-
- autotools: allow pulling in updated macros from autoconf-archive.
- Instead of inlining a few macros in acinclude.m4 and forgetting about
- them, teach aclocal to install the macros to m4/ when autoreconf is run.
- They are no longer tracked in one big file, nor tracked at all in git,
- but producing dist tarballs will bundle them up just like `configure`
- and `Makefile.in`.
-
- Note: previous behavior of AX_CHECK_GL* was to simply ignore support and
- proceed, if it was asked for and not found. The updated macros expect to
- opt into this by specifying action-if-not-found.
-
- VL_* is obsolete. Upgrade to AX_CFLAGS_WARN_ALL.
-
-2024-09-03 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'XZY2RGB' into 'master'
- Fixes #644 Index comparison as size_t to avoid overflow in TIFFXYZToRGB
-
- Closes #644
-
- See merge request libtiff/libtiff!649
-
-2024-09-03 Nicolas Badoux <n.badoux@hotmail.com>
-
- Fixes #644 Index comparison as size_t to avoid overflow in TIFFXYZToRGB.
-
-2024-09-01 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'ci_werror' into 'master'
- CI: build with -Wall -Wextra -Werror
-
- See merge request libtiff/libtiff!652
-
-2024-08-30 Even Rouault <even.rouault@spatialys.com>
-
- configure.ac: avoid -Werror passed to CFLAGS to interfere with feature detection
-
- CI: build with -Wall -Wextra -Werror.
-
-2024-08-30 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'ci-old-update' into 'master'
- ci: Update "old" build jobs to use Ubuntu 22.04
-
- See merge request libtiff/libtiff!651
-
-2024-08-30 Roger Leigh <rleigh@codelibre.net>
-
- ci: Update "old" build jobs to use Ubuntu 22.04.
-
-2024-08-30 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'ci-ubuntu-22.04' into 'master'
- ci: Update to use Ubuntu 24.04 CI images
-
- See merge request libtiff/libtiff!650
-
-2024-08-30 Roger Leigh <rleigh@codelibre.net>
-
- ci: Update to use Ubuntu 24.04 CI images.
-
-2024-08-28 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'uv_encode' into 'master'
- Fix #645 by using unsigned int for variable indexing an array in uv_decode() and uv_encode()
-
- Closes #645
-
- See merge request libtiff/libtiff!648
-
-2024-08-28 Nicolas Badoux <n.badoux@hotmail.com>
-
- Fix #645 by using unsigned int for variable indexing an array in uv_decode() and uv_encode()
- Change `vi` to unsigned int in `uv_decode()` and `uv_encode()` to ensure that upper bound `UV_NVS` cannot be satisfied by a negative value which will overflow when cast to an unsigned value at array access time. This fixes issue #645 where a segmentation fault was caused.
-
-2024-08-27 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_643_solitary_CustomDirectory_read' into 'master'
- Fix #643 by initializing pointer to TIFFSetField() and TIFFGetField() before TIFFReadGPSDirectory
-
- Closes #643
-
- See merge request libtiff/libtiff!647
-
-2024-08-27 Su Laus <sulau@freenet.de>
-
- Fix #643 by initializing pointer to TIFFSetField() and TIFFGetField() before TIFFReadGPSDirectory
- Initialize pointer to TIFFSetField() and TIFFGetField() (i.e. tif-\>tif_tagmethods.vsetfield and tif-\>tif_tagmethods.vgetfield) even if the file is opened with "h" option. This fixes issue #643 where a segmentation fault was caused.
-
-2024-08-25 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiff_strip' into 'master'
- Add non-zero check before division in TIFFComputeStrip
-
- See merge request libtiff/libtiff!646
-
-2024-08-23 Nicolas Badoux <n.badoux@hotmail.com>
-
- Add non-zero check before division in TIFFComputeStrip.
-
-2024-08-15 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_564' into 'master'
- TIFFScanlineSize64(): revert merge request #564
-
- See merge request libtiff/libtiff!644
-
-2024-08-15 Even Rouault <even.rouault@spatialys.com>
-
- TIFFScanlineSize64(): revert merge request #564.
- https://gitlab.com/libtiff/libtiff/-/merge_requests/564 broke decoding of: "tools/tiffcp -c none in.tif out.tif"
- with [in.tif](/uploads/0475a88cf6e66652b030a0a3a0c47313/in.tif)
- leading to shift each line of the target image by one extra pixel at each line.
- Unfortunately, this cancels what https://gitlab.com/libtiff/libtiff/-/merge_requests/564 tried to fix. I'll let @caolanm propose an alternative fix in a follow-up merge request
-
-2024-08-15 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'coverity_fix_from_MR_634' into 'master'
- Fix some Coverity Scan issues introduced by MR 634.
-
- See merge request libtiff/libtiff!643
-
-2024-08-14 Su_Laus <sulau@freenet.de>
-
- Fix some Coverity Scan issues introduced by MR 634.
-
-2024-08-11 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'lerc-pkgconfig' into 'master'
- libtiff-4.pc: Fix `Requires.private` missing `Lerc`.
-
- See merge request libtiff/libtiff!633
-
-2024-08-11 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'manpage_update_directory_incrementing' into 'master'
- Amend manpages for changes in current directory index behaviour.
-
- See merge request libtiff/libtiff!639
-
-2024-08-11 Su Laus <sulau@freenet.de>
-
- Amend manpages for changes in current directory index behaviour.
-
-2024-08-11 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiffcrop_coverity_20240723' into 'master'
- Attempt to address tiffcrop Coverity scan issues 1605444, 1605445, and 1605449.
-
- See merge request libtiff/libtiff!642
-
-2024-08-11 Lee Howard <faxguy@howardsilvan.com>
-
- Attempt to address tiffcrop Coverity scan issues 1605444, 1605445, and 1605449.
-
-2024-08-11 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_CurDir_wrong_incrementing' into 'master'
- Fix cases where tif_curdir is set incorrectly
-
- See merge request libtiff/libtiff!634
-
-2024-08-11 Su Laus <sulau@freenet.de>
-
- Fix cases where tif_curdir is set incorrectly.
- Fix cases where the current directory number (tif_curdir) is set inconsistently or incorrectly, depending on the previous history.
-
- See additional checks and tests in test/test_directory.c of this MR for intended setting of tif_curdir (i.e. TIFFCurrentDirectory(tif)).
-
-2024-07-12 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'coverity_fixes_tiff2pdf_#2' into 'master'
- Try to fix additional Coverity issues in tiff2pdf
-
- See merge request libtiff/libtiff!641
-
-2024-07-12 Su Laus <sulau@freenet.de>
-
- Try to fix additional Coverity issues in tiff2pdf.
-
-2024-07-10 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_autoconf_diff_parameter_crlf' into 'master'
- Add parameter for "diff" used in autoconf test scripts to ignore LF and CRLF differences.
-
- See merge request libtiff/libtiff!640
-
-2024-07-09 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'coverity_fixes_tiff2pdf' into 'master'
- Fix Coverity issues in tiff2pdf.
-
- See merge request libtiff/libtiff!638
-
-2024-07-09 Su Laus <sulau@freenet.de>
-
- Fix Coverity issues in tiff2pdf.
-
-2024-06-29 Su_Laus <sulau@freenet.de>
-
- Add parameter for "diff" used in autoconf test scripts to ignore LF and CRLF differences.
-
-2024-06-28 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'coverity_fixes_test_thumbnail' into 'master'
- Coverity Scan fixes in thumbnail.c and custom_dir_EXIF_231.c
-
- See merge request libtiff/libtiff!637
-
-2024-06-28 Su Laus <sulau@freenet.de>
-
- Coverity Scan fixes in thumbnail.c and custom_dir_EXIF_231.c.
-
-2024-06-25 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'coverity_fixes' into 'master'
- Try to silence new Coverity Scan false positives
-
- See merge request libtiff/libtiff!636
-
-2024-06-24 Even Rouault <even.rouault@spatialys.com>
-
- Try to silence new Coverity Scan false positives.
- There are other warnings in tools/ that I'll let others deal with.
-
-2024-06-24 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix/make' into 'master'
- fix: error when running make clean
-
- Closes #630
-
- See merge request libtiff/libtiff!635
-
-2024-06-24 Kévin Dunglas <kevin@dunglas.fr>
-
- fix: error when running make clean.
-
-2024-06-15 Niklas Hambüchen <mail@nh2.me>
-
- libtiff-4.pc: Fix `Requires.private` missing `Lerc`.
- It provides a `.pc` file starting from version 4 in:
-
- https://github.com/Esri/lerc/blob/8d6e8251544bbe1379feb0fe0a0934e43ca1a6cd/Lerc.pc.in
-
- libtiff's CMake build system already has support for this,
- adding `Lerc` to `Requires.private` if Lerc is >= 4.
-
- In contrast to the CMake build system, autoconf has no good way
- to check for checking the Lerc version, we do it unconditionally
- there.
-
-2024-06-13 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'rfc02_text__restore_tools' into 'master'
- Text for RFC 2: Restoring needed libtiff tools
-
- See merge request libtiff/libtiff!581
-
-2024-06-13 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'add_some_conversion_test_to_cmake' into 'master'
- Port some basic sanity checks from autoconf to cmake.
-
- See merge request libtiff/libtiff!630
-
-2024-06-10 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiffcp_coverity_check_malloc_return' into 'master'
- tiffcp: Add check for limitMalloc return to fix Coverity CID 1603334
-
- See merge request libtiff/libtiff!632
-
-2024-06-10 Su_Laus <sulau@freenet.de>
-
- tiffcp add check for limitMalloc return to fix Coverity CID 1603334.
-
-2024-06-07 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'aim-nara-master-patch-67955' into 'master'
- Remove unnecessary `2` in tiffcmp name
-
- See merge request libtiff/libtiff!631
-
-2024-06-07 AIM | Nara <takeshi.naramidate@ai-ms.com>
-
- Remove unnecessary `2` in tiffcmp name.
-
-2024-05-30 Su_Laus <sulau@freenet.de>
-
- Port some basic sanity checks from autoconf to cmake. Checks are for tiffcp and tiffcrop RGB->YCbCr JPEG conversions (see MR !611 / 'tiffcp_tiffcrop_RGB_YCbCr_tests')
-
-2024-05-29 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'ofz65182' into 'master'
- an issue seen in putcontig8bitYCbCr22tile
-
- See merge request libtiff/libtiff!564
-
-2024-05-29 Caolán McNamara <caolanm@gmail.com>
-
- TIFFScanlineSize64(): fix computation in non-JPEG YCbCr case (#564)
- Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=65182
-
-2024-05-29 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_375' into 'master'
- TIFFRead[Scanline/EncodedStrip/EncodeTile]: 0-initialize output buffer if setupdecode fails ; most codecs: zero-initialize (not-yet-written parts of) output buffer if failure
-
- Closes #375
-
- See merge request libtiff/libtiff!628
-
-2024-05-29 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiff2pdf-planar' into 'master'
- Inconsistent PLANARCONFIG value for the input and output TIFF in tiff2pdf.c
-
- See merge request libtiff/libtiff!629
-
-2024-05-29 Timothy Lyanguzov <timothy.lyanguzov@sap.com>
-
- Inconsistent PLANARCONFIG value for the input and output TIFF in tiff2pdf.c
- Fixed a bug in tiff2pdf.c whereas the PLANARCONFIG for the output TIFF is set to a fixed value of PLANARCONFIG_CONTIG as opposed to match the value of the input TIFF.
- This mainly manifest in the heap-buffer-overread due to the difference of sizes in the buffers (between input and output) allocated and read to the size of output buffer.
-
- Reimplementation of !92
-
-2024-05-27 Even Rouault <even.rouault@spatialys.com>
-
- tif_lzma/tif_lzw: add code comments.
-
-2024-05-26 Even Rouault <even.rouault@spatialys.com>
-
- ZSTDDecode: zero-initialize (not-yet-written parts of) output buffer if failure
-
- PixarLogDecode: zero-initialize output buffer if failure.
-
- PackBitsDecode: zero-initialize (not-yet-written parts of) output buffer if failure
-
- JPEGDecode: zero-initialize (not-yet-written parts of) output buffer if failure
-
- LERCDecode: zero-initialize output buffer if failure.
-
- LZMADecode: zero-initialize (not-yet-written parts of) output buffer if failure, and handle repeated calls to decoding same tile/strip if previous failure occured
-
- TWebPDecode: zero-initialize output buffer if failure, and handle repeated calls to decoding same tile/strip if previous failure occured
-
- ThunderDecode: zero-initialize (not-yet-written parts of) output buffer if failure
-
- OJPEGDecode: zero-initialize output buffer if failure.
-
- JBIGDecode: zero-initialize (not-yet-written parts of) output buffer if failure
-
- ZIPDecode: zero-initialize (not-yet-written parts of) output buffer if failure, and handle repeated calls to decoding same tile/strip if previous failure occured
-
- LZWDecode: zero-initialize (not-yet-written parts of) output buffer if failure
-
- TIFFRead[Scanline/EncodedStrip/EncodeTile]: 0-initialize output buffer if setupdecode fails
- Fixes #375
-
-2024-05-25 Su_Laus <sulau@freenet.de>
-
- Text for RFC 2: Restoring needed libtiff tools - file added to doc/Makefile.am and rebased.
-
- Text for RFC 2: Restoring needed libtiff tools - approved with voting history updated.
-
- Text for RFC 2: Restoring needed libtiff tools - further amended.
-
- Text for RFC 2: Restoring needed libtiff tools - amended.
-
- Text for RFC 2: Restoring needed libtiff tools.
-
-2024-05-23 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiff2pdf_539' into 'master'
- fix tiff2pdf issue #539; however, there certainly remain many JPEG-compressed...
-
- See merge request libtiff/libtiff!597
-
-2024-05-23 Lee Howard <faxguy@howardsilvan.com>
-
- tiff2pdf: fix issue with JPEG restart-interval marker when converting from JPEG-compressed files
- Fixes #539
-
- however, there certainly remain many JPEG-compressed TIFFs which tiff2pdf will fumble without disabling data passthrough (using the -n option) - I supect that it has to do with the JPEG tables being removed from the JPEG and placed into the TIFF headers - as tiff2pdf would need to put these back into the JPEG instead of just passing the data through to the PDF
-
-2024-05-22 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'test_fix' into 'master'
- test/Makefile.am: make sure that all test images are bundled by make dist even...
-
- See merge request libtiff/libtiff!626
-
-2024-05-22 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'add_missing_rst_files' into 'master'
- doc/Makefile.am: add rfcs/ files in rst_sources variable
-
- See merge request libtiff/libtiff!624
-
-2024-05-22 Even Rouault <even.rouault@spatialys.com>
-
- test/Makefile.am: make sure that all test images are bundled by make dist even if JPEG or JBIG is not available
-
-2024-05-22 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'timothyl/32bpp-cmake-test' into 'master'
- Add new test to CMake
-
- See merge request libtiff/libtiff!625
-
-2024-05-22 Timothy Lyanguzov <timothy.lyanguzov@sap.com>
-
- Add new test to CMake.
- See previous merge request libtiff/libtiff!611
-
-2024-05-22 Even Rouault <even.rouault@spatialys.com>
-
- doc/Makefile.am: add rfcs/ files in rst_sources variable.
-
-2024-05-22 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiffcp_tiffcrop_RGB_YCbCr_tests' into 'master'
- Add some basic sanity checks for tiffcp and tiffcrop RGB->YCbCr JPEG conversions.
-
- See merge request libtiff/libtiff!611
-
-2024-05-22 Lee Howard <faxguy@howardsilvan.com>
-
- Add some basic sanity checks for tiffcp and tiffcrop RGB->YCbCr JPEG conversions.
-
-2024-05-21 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiffcp_LZW_JBIG_test' into 'master'
- Add basic sanity check for tiffcp LZW->JBIG conversion.
-
- See merge request libtiff/libtiff!612
-
-2024-05-21 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiffcrop_masonwilde_fix' into 'master'
- Apply "Fix heap-buffer-overflow in function extractImageSection"
-
- See merge request libtiff/libtiff!613
-
-2024-05-21 Lee Howard <faxguy@howardsilvan.com>
-
- tiffcrop: Apply "Fix heap-buffer-overflow in function extractImageSection"
- https://gitlab.com/masonwilde/libtiff/-/commit/848434a81c443f59ec90d41218eba6e48a450a11
-
- authored by zhailiangliang commit 848434a81c443f59ec90d41218eba6e48a450a11
-
- The overflow conditions were previously addressed, but this provides additional error messages.
-
-2024-05-21 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_183_alternative' into 'master'
- OJPEG: reset subsampling_convert_state =0 in OJPEGPreDecode (fixes tiff2pdf issue #183)
-
- See merge request libtiff/libtiff!621
-
-2024-05-21 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'thunder-fix' into 'master'
- A fix for Thunder RLE
-
- See merge request libtiff/libtiff!623
-
-2024-05-21 Timothy Lyanguzov <theta682@gmail.com>
-
- A fix for Thunder RLE.
- The commit https://gitlab.com/robinwatts/libtiff/-/commit/be0519ca3d222c19008fe160873f3b5c28e6b36b states:
-
- Thunder RLE can fail to decode last run. Bug seen with GhostPDL. Decode of test tif file gives valgrind errors due to the "thunder decode" failing to extract the final run of compressed pixels.
-
- The logic in the decoder, presumably intended to spot overruns of data, is incorrect in that runs that end at the end of a row (npixels == maxpixels) will not be decoded.
-
- Fix this by limiting 'n', the number of pixels to copy. Note that npixels is updated by the 'unlimited' value to ensure the error reporting at the end of the loop still works.
-
-2024-05-18 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiff2ps_fax2tiff_476' into 'master'
- fix fax2ps and fax2tiff bugs #476
-
- See merge request libtiff/libtiff!598
-
-2024-05-18 Lee Howard <faxguy@howardsilvan.com>
-
- Fix fax2ps and fax2tiff memory leaks.
- Fixes #476
-
-2024-05-17 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiff2rgba_469' into 'master'
- fix tiff2rgba issue #469
-
- See merge request libtiff/libtiff!600
-
-2024-05-17 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'formatting-fixes' into 'master'
- Formatting fixes
-
- See merge request libtiff/libtiff!622
-
-2024-05-17 Even Rouault <even.rouault@spatialys.com>
-
- Formatting fixes.
-
-2024-05-17 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'coverity_fixes' into 'master'
- 3 Coverity Scan fixes in tools & contrib
-
- See merge request libtiff/libtiff!592
-
-2024-05-17 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiff2pdf_596' into 'master'
- tiff2pdf issue #596
-
- See merge request libtiff/libtiff!594
-
-2024-05-17 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiffdither_473' into 'master'
- fix tiffdither bug #473
-
- See merge request libtiff/libtiff!599
-
-2024-05-17 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fax2tiff_468' into 'master'
- fix fax2tiff issue #468
-
- See merge request libtiff/libtiff!601
-
-2024-05-17 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiff2rgba_background' into 'master'
- Add background gradient option for tiff2rgba alpha compositing.
-
- See merge request libtiff/libtiff!610
-
-2024-05-17 Lee Howard <faxguy@howardsilvan.com>
-
- Add background gradient option for tiff2rgba alpha compositing.
-
-2024-05-17 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiff2pdf_253' into 'master'
- Fix tiff2pdf issue #253 - red and blue were being swapped for RGBA decoding
-
- See merge request libtiff/libtiff!603
-
-2024-05-17 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fax2tiff_249' into 'master'
- Fix fax2tiff issue #249, unreasonable width input
-
- See merge request libtiff/libtiff!604
-
-2024-05-17 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiffcp_tiffcrop_228' into 'master'
- correct tiffcp and tiffcrop issue #228
-
- See merge request libtiff/libtiff!605
-
-2024-05-17 Even Rouault <even.rouault@spatialys.com>
-
- OJPEG: reset subsampling_convert_state =0 in OJPEGPreDecode (fixes tiff2pdf issue #183)
-
-2024-05-17 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fax2tiff_191' into 'master'
- Fix fax2tiff issue #191 - EOFB interpretation
-
- See merge request libtiff/libtiff!606
-
-2024-05-17 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiff2pdf_98' into 'master'
- Fix tiff2pdf documentation issue #98
-
- See merge request libtiff/libtiff!608
-
-2024-05-17 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiffgt_warning' into 'master'
- Avoids a warning regarding fallthrough.
-
- See merge request libtiff/libtiff!609
-
-2024-05-17 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiffcrop_542_550_552' into 'master'
- tiffcrop: fixes #542, #550, #552 (buffer overflows, use after free)
-
- See merge request libtiff/libtiff!595
-
-2024-05-17 Lee Howard <faxguy@howardsilvan.com>
-
- tiffcrop: fixes #542, #550, #552 (buffer overflows, use after free)
-
-2024-05-17 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'Fedora_am_version' into 'master'
- libtiff-am-version.patch from Fedora stating:
-
- See merge request libtiff/libtiff!617
-
-2024-05-17 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'formatting-fixes' into 'master'
- Code formatting fixes
-
- See merge request libtiff/libtiff!620
-
-2024-05-17 Even Rouault <even.rouault@spatialys.com>
-
- Code formatting fixes.
- Result of running ``pre-commit run --all``
-
-2024-05-17 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'sphinx_quotes_dashes' into 'master'
- Don't let Sphinx inconsistently alter quotes and dashes in rst files.
-
- See merge request libtiff/libtiff!615
-
-2024-05-17 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiffmedian_599' into 'master'
- tiffmedian issue #599
-
- See merge request libtiff/libtiff!593
-
-2024-05-17 Lee Howard <faxguy@howardsilvan.com>
-
- tiffmedian: fix memory leaks.
- Closes #599
-
-2024-05-17 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'more_spelling_corrections' into 'master'
- Typo fixes following...
-
- See merge request libtiff/libtiff!618
-
-2024-05-17 Lee Howard <faxguy@howardsilvan.com>
-
- Typo fixes following https://gitlab.com/libtiff/libtiff/-/commit/c95c77350820e19c8e273925bc97259727d19695
-
-2024-05-16 Lee Howard <faxguy@howardsilvan.com>
-
- libtiff-am-version.patch from Fedora stating: Back off the minimum required automake version to 1.11. There isn't anything in libtiff currently that actually requires 1.12, and changing this allows the package to be built on pre-F18 machines for easier testing.
-
- Don't let Sphinx inconsistently alter quotes and dashes in rst files. Author: Laszlo Boszormenyi (GCS) <gcs@debian.org> Bug-Debian: https://bugs.debian.org/1028456
-
- Add basic sanity check for tiffcp LZW->JBIG conversion.
-
- Avoids a warning regarding fallthrough.
-
- Fix tiff2pdf documentation issue #98.
-
- Fix fax2tiff issue #191 - EOFB interpretation.
-
- Update tiffcp.c.
-
- Correct tiffcrop output of RGB JPEG and tiffcp/tiffcrop documentation - issue #228
-
- Fix tiffcp and tiffcrop issue 228 - step 1.
-
- Fix fax2tiff issue #249, unreasonable width input.
-
- Fix tiff2pdf issue #253 - red and blue were being swapped for RGBA decoding
-
- fix fax2tiff issue #468.
-
- fix tiff2rgba issue #469.
-
- fix tiffdither bug #473.
-
- tiff2pdf issue #596.
-
-2024-05-16 Even Rouault <even.rouault@spatialys.com>
-
- contrib/addtiffo: validate return of TIFFWriteEncodedXXXX() calls (CID 1024680)
-
- tiffdump.c: fix wrong printf formattre in error message (CID 1472932)
-
- tiffset.c: avoid false positive Coverity Scan warning on 64-bit builds (CID 1518997)
-
-2024-05-16 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'master' into 'master'
- Fix some Coverity warnings.
-
- See merge request libtiff/libtiff!590
-
-2024-05-16 Lee Howard <faxguy@howardsilvan.com>
-
- Fix some Coverity warnings.
-
-2024-05-13 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'revert_tools_removement' into 'master'
- Restore tools from archive and unsupported and tiffcp -i option with revert.
-
- See merge request libtiff/libtiff!589
-
-2024-05-11 Su_Laus <sulau@freenet.de>
-
- Apply some newer changes to the reverted code and prepare note for 4.7.0.
-
- Revert "Remove -i option (ignore errors) from tiffcp, because almost all fuzzer issues were consequential errors from ignored errors because of the "-i" option."
- This reverts commit 280a568ae887c27a422a5da862398ffdbcd9b84d.
-
-2024-05-11 Su_Laus <sulau@freenet.de>
-
- Revert "Move most TIFF tools to archive and keep some as unsupported (see #580)."
- This reverts commit eab89a627f0a65e9a1a47c4b30b4802c80b1ac45.
-
- # Conflicts:
- # tools/unsupported/CMakeLists.txt
- # tools/unsupported/tif_tools-unsupported_versioninfo.rc
-
-2024-05-10 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'calloc-transposed-args' into 'master'
- Fix -Werror=calloc-transposed-args with gcc 14
-
- See merge request libtiff/libtiff!588
-
-2024-05-10 Even Rouault <even.rouault@spatialys.com>
-
- Fix -Werror=calloc-transposed-args with gcc 14.
-
-2024-05-09 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'EvaluateIFDdatasizeReading_ossfuzz_68327' into 'master'
- EvaluateIFDdatasizeReading(): avoid unsigned integer overflow (master only)
-
- See merge request libtiff/libtiff!586
-
-2024-04-27 Even Rouault <even.rouault@spatialys.com>
-
- EvaluateIFDdatasizeReading(): avoid unsigned integer overflow (master only)
- Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=68327
-
-2024-04-25 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'ci-appveyor-cygwin-upgrade' into 'master'
- appveyor: Upgrade cygwin packages
-
- See merge request libtiff/libtiff!585
-
-2024-04-25 Roger Leigh <rleigh@codelibre.net>
-
- appveyor: Upgrade cygwin packages.
-
-2024-04-25 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'libjpeg_turbo_3_0' into 'master'
- Change messages/comments refering libjpeg-turbo 2.2 to 3.0
-
- See merge request libtiff/libtiff!584
-
-2024-04-24 Even Rouault <even.rouault@spatialys.com>
-
- Change messages/comments refering libjpeg-turbo 2.2 to 3.0.
- libjpeg-turbo 2.2 was actually released as 3.0. Reflect that
-
-2024-04-22 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'EvaluateIFDdatasizeReading_unsigned_int_overflow_fix' into 'master'
- EvaluateIFDdatasizeReading(): avoid potential unsigned integer overflow on corrupted tag
-
- See merge request libtiff/libtiff!582
-
-2024-04-22 Even Rouault <even.rouault@spatialys.com>
-
- EvaluateIFDdatasizeReading(): avoid potential unsigned integer overflow on corrupted tag
-
-2024-04-22 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tif_dir_logging-627' into 'master'
- tif_dir.c: Log source file, line number, and input tif for directory count error.
-
- Closes #627
-
- See merge request libtiff/libtiff!583
-
-2024-04-22 Kurt Schwehr <schwehr@gmail.com>
-
- tif_dir.c: Log source file, line number, and input tif for directory count error.
-
-2024-04-14 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_readrgbastrip_fpe' into 'master'
- Avoiding FPEs (division by zero) in tif_getimage.c
-
- See merge request libtiff/libtiff!580
-
-2024-04-09 Zurab Tsinadze <zurab.tsinadze@epfl.ch>
-
- Avoid FPEs (division by zero) in tif_getimage.c.
-
-2024-04-06 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'appveyor-vs2022' into 'master'
- appveyor: Add VS2022 builds
-
- See merge request libtiff/libtiff!579
-
-2024-04-06 Roger Leigh <rleigh@codelibre.net>
-
- appveyor: Add VS2022 builds.
-
-2024-04-04 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'appveyor-mingw-fix' into 'master'
- appveyor: Use MinGW-w64
-
- See merge request libtiff/libtiff!578
-
-2024-04-04 Roger Leigh <rleigh@codelibre.net>
-
- appveyor: Use MinGW-w64.
-
-2024-04-03 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'update_rfc1_status' into 'master'
- RFC1: update status to adopted
-
- See merge request libtiff/libtiff!577
-
-2024-04-03 Even Rouault <even.rouault@spatialys.com>
-
- RFC1: update status to adopted.
-
-2024-04-03 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'rfc1_psc' into 'master'
- Doc: add 'RFC 1: Project Steering Committee Guidelines' and a PSC page
-
- See merge request libtiff/libtiff!566
-
-2024-04-03 Even Rouault <even.rouault@spatialys.com>
-
- Doc: add 'RFC 1: Project Steering Committee Guidelines' and a PSC page.
-
-2024-04-02 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_coverity_test_directory_expansion' into 'master'
- Fix coverity scan issue in test_directory.c
-
- See merge request libtiff/libtiff!576
-
-2024-04-02 Su_Laus <sulau@freenet.de>
-
- Fix coverity scan issue in test_directory.c.
-
-2024-04-02 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'typo_fixes' into 'master'
- Various typo fixes
-
- See merge request libtiff/libtiff!575
-
-2024-04-02 Even Rouault <even.rouault@spatialys.com>
-
- Various typo fixes.
-
-2024-03-31 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'test_directory_expansion_endianness' into 'master'
- Enhance test_directory.c with big-endian and little-endian test cases
-
- See merge request libtiff/libtiff!574
-
-2024-03-30 Su_Laus <sulau@freenet.de>
-
- Enhance test/test_directory.c with big-endian and little-endian test cases.
- Insert testcase into test_directory.c for #618 "Failure in TIFFSetSubDirectory() will break subsequent TIFFSetDirectory() calls".
-
-2024-03-29 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'correct_coverity_issues_from_avoid_IFD_overwriting' into 'master'
- Correct some coverity issues from "avoid IFD overwriting"
-
- See merge request libtiff/libtiff!573
-
-2024-03-29 Su_Laus <sulau@freenet.de>
-
- Correct some coverity issues from "avoid IFD overwriting".
-
-2024-03-28 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_gdal_9548' into 'master'
- LERC codec: deal with issues with multi-band PlanarConfig=Contig and NaN values
-
- See merge request libtiff/libtiff!572
-
-2024-03-26 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'avoid_IFD_overwriting_other_data_TIFFWriteDirectory' into 'master'
- TIFFWriteDirectory: Avoid overwriting following data if an IFD is enlarged.
-
- See merge request libtiff/libtiff!565
-
-2024-03-26 Su Laus <sulau@freenet.de>
-
- TIFFWriteDirectory: Avoid overwriting following data if an IFD is enlarged.
- Avoid overwriting other data if an IFD that has already been written is enlarged. If entries are to be changed in an IFD that has already been written to the file, the memory area can be overwritten as long as the IFD data volume has not increased. Otherwise, the IFD must be written to a different location in the file. Up to now, LibTIFF has simply overwritten the IFD and other data areas in the file.
-
- With this MR, the size of the IFD, and location of IFD data, is tracked and checked if the IFD can be safely overwritten or has to be re-written to another location.
-
-2024-03-24 Even Rouault <even.rouault@spatialys.com>
-
- LERC codec: deal with issues with multi-band PlanarConfig=Contig and NaN values
- Fixes https://github.com/OSGeo/gdal/issues/9530.
- Cf https://github.com/OSGeo/gdal/pull/9548 for the GDAL specific fix.
-
- The LERC codec up-to-now didn't do any special processing when writing a strile
- in a multi-band PlanarConfig=Contig file, resulting in corruptions. Now we
- generate a mask buffer in that situation. Actually, if the NaN values are not
- at the same location accross bands, we need to write one mask-per-band, which
- requires liblerc >= 3.0, and in that situation change the LERC blob to
- multi-band instead of multi-depth/dim, with liblerc >= 3.0. When all bands have
- NaN values at the same location, we generate a single mask, which is compatible
- of liblerc < 3.0, but requires at last this version of libtiff to be read. This
- is the best solution we come with to fix the issue while having the maximum
- backward compatibility.
-
-2024-03-24 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'harmonize_TIFFheader_swapping' into 'master'
- Correct and harmonize swapping of internal 'tif_header' parameters.
-
- See merge request libtiff/libtiff!571
-
-2024-03-24 Su Laus <sulau@freenet.de>
-
- Correct and harmonize swapping of internal 'tif_header' parameters.
-
-2024-03-19 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'chore/printf-format-specifiers' into 'master'
- chore: use correct format specifiers
-
- See merge request libtiff/libtiff!570
-
-2024-03-19 Tom <tom@msbit.com.au>
-
- chore: use correct format specifiers.
- When building on my Mac, I get the following warnings:
-
- libtiff/tools/tiffcp.c:154:24: warning: format specifies type 'unsigned short' but the argument has type 'tdir_t' (aka 'unsigned int') [-Wformat]
- comma, nextImage);
- ^~~~~~~~~
- libtiff/tools/tiffcp.c:1295:39: warning: format specifies type 'unsigned short' but the argument has type 'tdir_t' (aka 'unsigned int') [-Wformat]
- TIFFFileName(bias), TIFFCurrentDirectory(bias),
- ^~~~~~~~~~~~~~~~~~~~~~~~~~
- libtiff/tools/tiffcp.c:1296:37: warning: format specifies type 'unsigned short' but the argument has type 'tdir_t' (aka 'unsigned int') [-Wformat]
- TIFFFileName(in), TIFFCurrentDirectory(in));
- ^~~~~~~~~~~~~~~~~~~~~~~~
- libtiff/tools/tiffcp.c:1303:37: warning: format specifies type 'unsigned short' but the argument has type 'tdir_t' (aka 'unsigned int') [-Wformat]
- TIFFFileName(in), TIFFCurrentDirectory(in));
- ^~~~~~~~~~~~~~~~~~~~~~~~
- libtiff/tools/tiffsplit.c:174:21: warning: format specifies type 'long long' but the argument has type 'size_t' (aka 'unsigned long') [-Wformat]
- path_len);
- ^~~~~~~~
-
- This updates the format specifiers from `PRIu16` to `PRIu32` for `tdir_t`
- (which is a `typdef`ed `uint32_t`) and from `TIFF_SSIZE_FORMAT` to
- `TIFF_SIZE_FORMAT` for `size_t`, which makes sense given that it's an unsigned
- type.
-
-2024-03-16 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_628_FPE_at_TIFFhowmany' into 'master'
- Avoiding FPE (division by zero) for TIFFhowmany_32() and TIFFhowmany_64()...
-
- Closes #628
-
- See merge request libtiff/libtiff!568
-
-2024-03-15 Su_Laus <sulau@freenet.de>
-
- Avoiding FPE (division by zero) for TIFFhowmany_32() and TIFFhowmany_64() macros by checking for denominator not zero before macros are executed. Fixes #628.
-
-2024-03-14 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_wrong_return_TIFFIsBigTIFF_if_swapping_case' into 'master'
- Fix wrong return of TIFFIsBigTIFF() in case byte-swapping is acitve
-
- See merge request libtiff/libtiff!567
-
-2024-03-13 Su_Laus <sulau@freenet.de>
-
- Fix wrong return of TIFFIsBigTIFF() in case byte-swapping is acitve (i.e. little endian image on a big endian machine).
-
-2024-01-30 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'master' into 'master'
- Setting the TIFFFieldInfo field `set_field_type` should consider `field_writecount` not `field_readcount`
-
- See merge request libtiff/libtiff!544
-
-2024-01-30 Timo Stüber <omit66@gmail.com>
-
- Setting the TIFFFieldInfo field `set_field_type` should consider `field_writecount` not `field_readcount`
- In most of the cases the field_writecount and field_readcount of the TIFFFieldInfo are equal. But they do not have to be the same.
-
- I encountered this issues when using an older release of Pillow. Since they use custom fields for decoding only, they set the readcount value to 0. As the result _TIFFSetGetType can not identify the type correctly and set TIFF_SETGET_UNDEFINED.
-
- Error Message:
- ```
- TIFFLib: _TIFFWriteDirectorySec(): Rational2Double: .set_field_type is not 4 but 1.
- ```
-
- During the execution of TIFFMergeFieldInfo the fields get_field_type and set_field_type set. I guess the set_field_type should dependent on the field_writecount.
-
-2024-01-24 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'avoid_memory_leaks_using_TIFFCreateDirectory' into 'master'
- Avoiding memory leaks when using TIFFCreateDirectory()
-
- See merge request libtiff/libtiff!563
-
-2024-01-24 Su_Laus <sulau@freenet.de>
-
- Avoiding memory leaks when using TIFFCreateDirectory() by releasing the allocated memory in the tif-structure.
-
-2024-01-10 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'WIN32' into 'master'
- Use #ifdef _WIN32 to test for Windows, and tiffio.h: remove definition of __WIN32__
-
- See merge request libtiff/libtiff!562
-
-2024-01-08 Even Rouault <even.rouault@spatialys.com>
-
- test/raw_decode.c: remove likely ifdef tricks related to old compilers or unusual setups
-
- tif_jpeg.c/tif_ojpeg.c: remove likely ifdef tricks related to old compilers or unusual setups
-
- Remove _TIFFUInt64ToFloat() and _TIFFUInt64ToDouble()
-
- Remove support for _MSC_VER < 1500.
-
-2024-01-07 Even Rouault <even.rouault@spatialys.com>
-
- Use #ifdef _WIN32 to test for Windows, and tiffio.h: remove definition of __WIN32__
-
-2023-12-20 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_579_non_terminated_ASCII_deletes_one_byte' into 'master'
- Fixed issue with non-terminated ASCII arrays where the last character is overwritten (fixes #579)
-
- Closes #579
-
- See merge request libtiff/libtiff!561
-
-2023-12-20 Su_Laus <sulau@freenet.de>
-
- For non-terminated ASCII arrays, the buffer is first enlarged before a NULL is set at the end to avoid deleting the last character. Fixes #579. Some editorials in tif_dir.c.
-
-2023-12-09 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_624_check_TIFFCreateAnonField_return' into 'master'
- Fix 624: Check return value of _TIFFCreateAnonField()
-
- Closes #624
-
- See merge request libtiff/libtiff!560
-
-2023-12-01 Su_Laus <sulau@freenet.de>
-
- Check return value of _TIFFCreateAnonField().
- Fixes #624
-
-2023-11-27 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'TIFFOpenOptionsSetMaxCumulatedMemAlloc' into 'master'
- Add TIFFOpenOptionsSetMaxCumulatedMemAlloc()
-
- See merge request libtiff/libtiff!556
-
-2023-11-27 Even Rouault <even.rouault@spatialys.com>
-
- Add TIFFOpenOptionsSetMaxCumulatedMemAlloc()
- This function complements ``TIFFOpenOptionsSetMaxSingleMemAlloc()`` to define the maximum cumulated memory allocations in byte, for a given TIFF handle, that libtiff internal memory allocation functions are allowed.
-
-2023-11-23 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'unity_clang_fixes' into 'master'
- Fixes to avoid CLang warnings on unity builds
-
- See merge request libtiff/libtiff!558
-
-2023-11-23 Even Rouault <even.rouault@spatialys.com>
-
- Fixes to avoid CLang warnings on unity builds.
-
-2023-11-22 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'cmake_UNITY_BUILD' into 'master'
- Changes to allow building with cmake -DCMAKE_UNITY_BUILD=ON
-
- See merge request libtiff/libtiff!557
-
-2023-11-22 Even Rouault <even.rouault@spatialys.com>
-
- CI: test -DCMAKE_UNITY_BUILD=ON.
-
- Changes to allow building with cmake -DCMAKE_UNITY_BUILD=ON.
-
-2023-11-22 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'manpage_506_TIFFClose_check_with_TIFFFlush' into 'master'
- manpage: Note on using TIFFFlush() before TIFFClose()
-
- Closes #506
-
- See merge request libtiff/libtiff!555
-
-2023-11-16 Su_Laus <sulau@freenet.de>
-
- manpage: Note on using TIFFFlush() before TIFFClose() to check that the data has been successfully written to the file.
- Closes #506
-
-2023-11-11 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'manpage_621_TIFFOpenOptionsSetMaxSingleMemAlloc' into 'master'
- manpage: Update TIFF documentation about TIFFOpenOptions.rst and memory limitting.
-
- Closes #621
-
- See merge request libtiff/libtiff!553
-
-2023-11-11 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'rectify_some_shadowed_declarations' into 'master'
- Rectify some shadowed declarations and warnings in tools and test modules.
-
- See merge request libtiff/libtiff!552
-
-2023-11-11 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_TIFFRealloc_usage_to_TIFFReallocExt' into 'master'
- Change internally used _TIFFRealloc() to _TIFFReallocExt()
-
- See merge request libtiff/libtiff!554
-
-2023-11-11 Su_Laus <sulau@freenet.de>
-
- Change internally used _TIFFRealloc() to _TIFFReallocExt(), which respects the TIFFOpenOptionsSetMaxSingleMemAlloc() limit.
-
-2023-11-11 Timothy Lyanguzov <theta682@gmail.com>
-
- Fix typo.
-
-2023-11-09 Su_Laus <sulau@freenet.de>
-
- manpage: Update TIFF documentation about TIFFOpenOptions.rst and TIFFOpenOptionsSetMaxSingleMemAlloc() usage and some other small fixes.
-
-2023-11-08 Su_Laus <sulau@freenet.de>
-
- Rectify some shadowed declarations and warnings in tools and test modules.
-
-2023-11-04 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_583' into 'master'
- tif_fax3.c: error out after a number of times end-of-file has been reached (fixes #583)
-
- Closes #583
-
- See merge request libtiff/libtiff!547
-
-2023-11-04 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_622' into 'master'
- TIFFReadRGBAStrip/TIFFReadRGBATile: add more validation of col/row (fixes #622)
-
- Closes #622
-
- See merge request libtiff/libtiff!546
-
-2023-10-31 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'extra_limit_getfilesize' into 'master'
- tif_dirread.c: only issue TIFFGetFileSize() for large enough RAM requests
-
- See merge request libtiff/libtiff!551
-
-2023-10-31 Even Rouault <even.rouault@spatialys.com>
-
- tif_dirread.c: only issue TIFFGetFileSize() for large enough RAM requests
-
-2023-10-31 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'TIFFFetchDirectory_remove_useless_check' into 'master'
- TIFFFetchDirectory(): remove useless allocsize vs filesize check
-
- See merge request libtiff/libtiff!550
-
-2023-10-31 Even Rouault <even.rouault@spatialys.com>
-
- TIFFFetchDirectory(): remove useless allocsize vs filesize check.
- CoverityScan rightly points that the max value for dircount16 * dirsize
- is 4096 * 20. That's small enough not to do any check
-
-2023-10-31 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'limit_getfilesize' into 'master'
- tif_dirread.c: only issue TIFFGetFileSize() for large enough RAM requests
-
- See merge request libtiff/libtiff!549
-
-2023-10-31 Even Rouault <even.rouault@spatialys.com>
-
- tif_dirread.c: only issue TIFFGetFileSize() for large enough RAM requests
- Ammends 5320c9d89c054fa805d037d84c57da874470b01a
-
- This fixes a performance regression caught by the GDAL regression test
- suite.
-
-2023-10-31 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tif_dirread-typo' into 'master'
- tif_dirread.c: Fix typo: greather -> greater
-
- See merge request libtiff/libtiff!548
-
-2023-10-31 Kurt Schwehr <schwehr@google.com>
-
- tif_dirread.c: Fix typo: greather -> greater.
-
-2023-10-31 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_614_check_mem_allocation_vs_filelength' into 'master'
- Prevent some out-of-memory attacks
-
- See merge request libtiff/libtiff!545
-
-2023-10-31 Su Laus <sulau@freenet.de>
-
- Prevent some out-of-memory attacks.
- Some small fuzzer files fake large amounts of data and provoke out-of-memory situations. For non-compressed data content / tags, out-of-memory can be prevented by comparing with the file size.
-
- At image reading, data size of some tags / data structures (StripByteCounts, StripOffsets, StripArray, TIFF directory) is compared with file size to prevent provoked out-of-memory attacks.
-
- See issue https://gitlab.com/libtiff/libtiff/-/issues/614#note_1602683857
-
-2023-10-31 Even Rouault <even.rouault@spatialys.com>
-
- tif_fax3.c: error out after a number of times end-of-file has been reached (fixes #583)
-
- TIFFReadRGBAStrip/TIFFReadRGBATile: add more validation of col/row (fixes #622)
-
-2023-10-30 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_failed_subdirectory_read' into 'master'
- #618: ensure absolute seeking is forced independent
-
- See merge request libtiff/libtiff!543
-
-2023-10-25 Manuel Massing <m.massing@virtualities.de>
-
- #618: ensure absolute seeking is forced independent of TIFFReadDirectory success.
- This fixes TIFFSetDirectory calls for the case where
- TIFFReadDirectory was unsuccessful.
-
-2023-10-17 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'cmake' into 'master'
- CMake: Fix TIFF_INCLUDE_DIRS
-
- See merge request libtiff/libtiff!541
-
-2023-10-12 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_616' into 'master'
- tif_lzw.c: avoid warning about misaligned address with UBSAN (fixes #616)
-
- Closes #616
-
- See merge request libtiff/libtiff!542
-
-2023-10-12 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiffcp_cancel_ycbcr' into 'master'
- tiffcp: replace PHOTOMETRIC_YCBCR with PHOTOMETRIC_RGB when outputing to...
-
- See merge request libtiff/libtiff!540
-
-2023-10-12 Even Rouault <even.rouault@spatialys.com>
-
- tif_lzw.c: avoid warning about misaligned address with UBSAN (fixes #616)
- The branch suppressed by this commit wasn't useful as I've verified that
- with -O2 and -O3 and gcc or clang, doing a memcpy() + _byteswap_uint64()
- generates exactly the same code as _byteswap_uint64(*ptr).
- The warning with UBSAN thus only comes from UBSAN generating special code
- to catch the misalignment, but is unlikely to cause any issue in
- practice given the above observation.
-
-2023-10-12 Julien Schueller <schueller@phimeca.com>
-
- CMake: Fix TIFF_INCLUDE_DIRS.
-
-2023-10-08 Even Rouault <even.rouault@spatialys.com>
-
- tiffcp: preserve TIFFTAG_REFERENCEBLACKWHITE when doing YCbCr JPEG -> YCbCr JPEG
-
-2023-10-07 Even Rouault <even.rouault@spatialys.com>
-
- tiffcp: replace PHOTOMETRIC_YCBCR with PHOTOMETRIC_RGB when outputing to compression != JPEG (refs #571)
-
-2023-10-05 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'kmilos-master-patch-42063' into 'master'
- CMake: MinGW compilers don't need a .def file for shared library
-
- See merge request libtiff/libtiff!448
-
-2023-10-05 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'kmilos-master-patch-64997' into 'master'
- CMake: move libdeflate and Lerc to Requires.private
-
- See merge request libtiff/libtiff!536
-
-2023-10-05 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'clarify_archive' into 'master'
- Doc: clarify unsupported (still in tarball) and archived (only in git) utilities
-
- See merge request libtiff/libtiff!532
-
-2023-10-05 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_571_alternative' into 'master'
- tiffcp: Setting the correct photometric interpretation for the output image...
-
- Closes #571
-
- See merge request libtiff/libtiff!539
-
-2023-10-04 Even Rouault <even.rouault@spatialys.com>
-
- tiffcp: do not copy tags YCBCRCOEFFICIENTS, YCBCRSUBSAMPLING, YCBCRPOSITIONING, REFERENCEBLACKWHITE. Only set TIFFTAG_YCBCRSUBSAMPLING when generating YCbCr JPEG
-
- tiffcp: Setting the correct photometric interpretation for the output image when converting JPEG-YCBCR to JPEG-RGB images.
- Closes #571
-
-2023-09-28 MiloÅ¡ KomarÄević <miloskomarcevic@aim.com>
-
- CMake: move libdeflate and Lerc to Requires.private.
-
-2023-09-27 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'kmilos-windres' into 'master'
- CMake: enable resource compilation on all Windows
-
- See merge request libtiff/libtiff!537
-
-2023-09-27 MiloÅ¡ KomarÄević <miloskomarcevic@aim.com>
-
- CMake: enable resource compilation on all Windows.
-
-2023-09-15 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_608' into 'master'
- tif_dirinfo.c: re-enable TIFFTAG_EP_CFAREPEATPATTERNDIM and TIFFTAG_EP_CFAPATTERN tags (fixes #608)
-
- Closes #608
-
- See merge request libtiff/libtiff!534
-
-2023-09-15 Even Rouault <even.rouault@spatialys.com>
-
- tif_dirinfo.c: re-enable TIFFTAG_EP_CFAREPEATPATTERNDIM and TIFFTAG_EP_CFAPATTERN tags (fixes #608)
-
-2023-09-09 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_606_tiffcp_check_also_input_compression_codec' into 'master'
- tiffcp: Fixes #606. Check also codec of input image, not only from output image.
-
- Closes #606
-
- See merge request libtiff/libtiff!533
-
-2023-09-09 Su_Laus <sulau@freenet.de>
-
- Check also if codec of input image is available, independently from codec check of output image and return with error if not. Fixes #606.
-
-2023-09-08 Even Rouault <even.rouault@spatialys.com>
-
- Doc: clarify unsupported (still in tarball) and archived (only in git) utilities
-
-2023-09-08 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'update_release_date' into 'master'
- Update RELEASE-DATE
-
- See merge request libtiff/libtiff!531
-
-2023-09-08 Even Rouault <even.rouault@spatialys.com>
-
- Update RELEASE-DATE.
-
-2023-09-08 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_605' into 'master'
- autoconf.ac: fix detection of windows.h for mingw (fixes #605)
-
- Closes #605
-
- See merge request libtiff/libtiff!530
-
-2023-09-07 Even Rouault <even.rouault@spatialys.com>
-
- autoconf.ac: fix detection of windows.h for mingw (fixes #605)
-
-2023-09-06 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'prepare_v4_6_0' into 'master'
- Prepare for libtiff 4.6.0 release
-
- See merge request libtiff/libtiff!528
-
-2023-09-05 Even Rouault <even.rouault@spatialys.com>
-
- doc/index.rst: add warning about tools removal.
-
-2023-09-05 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_603_readme_doc_reference_update' into 'master'
- Update documentation reference within README.md. Fixes #603.
-
- Closes #603
-
- See merge request libtiff/libtiff!529
-
-2023-09-05 Su_Laus <sulau@freenet.de>
-
- Update documentation reference within README.md. Fixes #603.
-
-2023-09-05 Even Rouault <even.rouault@spatialys.com>
-
- Fix references to mailing list.
-
-2023-09-05 Even Rouault <even.rouault@spatialys.com>
-
- libtiff v4.6.0 released
-
-2023-09-05 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_600' into 'master'
- CMake: fix build with -Dstrip-chopping=off (fixes #600)
-
- See merge request libtiff/libtiff!527
-
-2023-09-05 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'georgthegreat-master-patch-87447' into 'master'
- Fix using __attribute__ libtiff with clang-for-windows
-
- See merge request libtiff/libtiff!525
-
-2023-09-05 Yuriy Chernyshov <georgthegreat@gmail.com>
-
- Fix using __attribute__ libtiff with clang-for-windows.
-
-2023-09-05 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'manpage_TIFFField_docu_update' into 'master'
- manpages: TiffField functions documentation updated with return behaviour for...
-
- See merge request libtiff/libtiff!526
-
-2023-09-05 Even Rouault <even.rouault@spatialys.com>
-
- CMake: fix build with -Dstrip-chopping=off (fixes #600)
-
-2023-09-03 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'consistently_update_TIFF-version_from_configure-ac' into 'master'
- Update CMake and autoconf scripts to consistently update LibTIFF version...
-
- See merge request libtiff/libtiff!456
-
-2023-09-03 Su Laus <sulau@freenet.de>
-
- Update CMake and autoconf scripts to consistently update LibTIFF version defines and references in various files when version definition in configure.ac has been changed.
- - Move in tiffvers.h from .\libtiff source directory to .\libtiff build directory.
- - Remove unused version information from tif_config.h
- - With every CMake build the version defines (e.g. 4.5.1) within tiffvers.h are consistently updated from configure.ac. The version release-date is taken from file RELEASE-DATE.
- - The files VERSION and RELEASE-DATE are only updated with a special CMake target build: cmake --build . --target tiff_release.
-
- - For autotools, version information is updated from configure.ac with ./autogen.sh. LIBTIFF_RELEASE_DATE is taken form file RELEASE-DATE.
- - ./configure generates tiffvers.h with the cached version information and LIBTIFF_RELEASE_DATE.
- - "make release" updates tiffvers.h and VERSION file with cached version info and RELEASE-DATE file and tiffves.h with the current date.
-
-2023-08-28 Su_Laus <sulau@freenet.de>
-
- manpages: TiffField functions documentation updated with return behaviour for not defined tags and determination of write-/read-count size.
-
-2023-08-22 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'change_long_to_int32_t_in_two_test_apps' into 'master'
- Change "long" to "int32_t" in two test apps, because can be either int32_t or...
-
- See merge request libtiff/libtiff!524
-
-2023-08-21 Su_Laus <sulau@freenet.de>
-
- Change "long" to "int32_t" in two test apps, because can be either int32_t or int64_t, depending on compiler and system.
-
-2023-08-16 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'CI_CMake_static_build' into 'master'
- Add static build for CI/CD to run testcases which need private interface functions.
-
- See merge request libtiff/libtiff!521
-
-2023-08-16 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_#597_tiffset_different_signedness' into 'master'
- tiffset fix #597: warning: comparison of integer expressions of different signedness.
-
- Closes #597
-
- See merge request libtiff/libtiff!523
-
-2023-08-16 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiffcp_remove_i_option' into 'master'
- tiffcp: remove -i option (ignore errors)
-
- See merge request libtiff/libtiff!522
-
-2023-08-16 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'move_tools_to_unsupported_a_archive' into 'master'
- Move most TIFF tools to archive and keep some as unsupported (see #580).
-
- See merge request libtiff/libtiff!520
-
-2023-08-16 Su Laus <sulau@freenet.de>
-
- Move most TIFF tools to archive and keep some as unsupported (see #580).
-
-2023-08-12 Su_Laus <sulau@freenet.de>
-
- Add static build for CI/CD to run testcases which need private interface functions.
-
- tiffset fix #597: warning: comparison of integer expressions of different signedness.
-
- Remove -i option (ignore errors) from tiffcp, because almost all fuzzer issues were consequential errors from ignored errors because of the "-i" option.
-
-2023-08-11 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_585_test_write_read_tags_autoconf' into 'master'
- Add missing test_write_read_tags.c and test_transferfunction_write_read.c in...
-
- Closes #585
-
- See merge request libtiff/libtiff!519
-
-2023-07-24 Even Rouault <even.rouault@spatialys.com>
-
- Fix copy paste error.
-
-2023-07-23 Su_Laus <sulau@freenet.de>
-
- Add missing test_write_read_tags.c and test_transferfunction_write_read.c in tarball (fixes #585) and correct „long“ issue.
- Don't use "long" because can be int32_t or int64_t, depending on compiler and system.
-
-2023-07-20 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'clang-format-tools' into 'master'
- Automatically format with clang-format
-
- See merge request libtiff/libtiff!518
-
-2023-07-20 Timothy Lyanguzov <timothy.lyanguzov@sap.com>
-
- Automatically format with clang-format.
-
-2023-07-20 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_589' into 'master'
- TiffConfig.cmake.in: set TIFF_INCLUDE_DIR, TIFF_INCLUDE_DIRS and...
-
- Closes #589
-
- See merge request libtiff/libtiff!514
-
-2023-07-20 Even Rouault <even.rouault@spatialys.com>
-
- TiffConfig.cmake.in: set TIFF_INCLUDE_DIR, TIFF_INCLUDE_DIRS and...
-
-2023-07-19 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'master-patch-6fc6' into 'master'
- raw2tiff: fix integer overflow and bypass of the check (fixes #592)
-
- See merge request libtiff/libtiff!516
-
-2023-07-19 Arie Haenel <arie.haenel@jct.ac.il>
-
- raw2tiff: fix integer overflow and bypass of the check (fixes #592)
-
-2023-07-19 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'master-patch-05a4' into 'master'
- tiffcp: fix memory corruption (overflow) on hostile images (fixes #591)
-
- See merge request libtiff/libtiff!515
-
-2023-07-19 Arie Haenel <arie.haenel@jct.ac.il>
-
- tiffcp: fix memory corruption (overflow) on hostile images (fixes #591)
-
-2023-07-17 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix-numtrunc' into 'master'
- fix numtrunc at tiff_dirread.c
-
- See merge request libtiff/libtiff!512
-
-2023-07-17 headshog <craaaaaachind@gmail.com>
-
- TIFFReadDirectoryCheckOrder: avoid integer overflow.
- When it occurs, it should be harmless in practice though
-
-2023-07-17 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'webp_lossless_exact' into 'master'
- WebP codec: turn exact mode when creating lossless files to avoid altering...
-
- See merge request libtiff/libtiff!511
-
-2023-07-11 Even Rouault <even.rouault@spatialys.com>
-
- WebP codec: turn exact mode when creating lossless files to avoid altering R,G,B values in areas where alpha=0
- Fixes https://github.com/OSGeo/gdal/issues/8038
-
-2023-07-05 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'webp_reg_fix' into 'master'
- WebP decoder: fix error when reading a 3-band blob in a RGBA image
-
- See merge request libtiff/libtiff!510
-
-2023-07-05 Even Rouault <even.rouault@spatialys.com>
-
- WebP decoder: fix error when reading a 3-band blob in a RGBA image.
- Fixes regression of 350ff161c8a61b6483a1e4689e09cd47dd0dd5f9 (master only)
-
-2023-06-26 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'appveyor_fix' into 'master'
- .appveyor.yml: workaround build error
-
- See merge request libtiff/libtiff!509
-
-2023-06-26 Even Rouault <even.rouault@spatialys.com>
-
- .appveyor.yml: workaround build error.
-
-2023-06-26 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tif_webp_warning_fixes' into 'master'
- tif_webp.c: fix signed vs unsigned comparison warnings (fix previous commit)
-
- See merge request libtiff/libtiff!508
-
-2023-06-26 Even Rouault <even.rouault@spatialys.com>
-
- tif_webp.c: fix signed vs unsigned comparison warnings (fix previous commit)
-
-2023-06-26 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_TransferFunction_writing' into 'master'
- Fix TransferFunction writing of only two transfer functions.
-
- See merge request libtiff/libtiff!502
-
-2023-06-26 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_581_582' into 'master'
- WebP decoder: validate WebP blob width, height, band count against TIFF parameters
-
- Closes #582 et #581
-
- See merge request libtiff/libtiff!507
-
-2023-06-19 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'warning_cmake_config_file' into 'master'
- v4.5.1 release note: add warning about CMake config file being preview
-
- See merge request libtiff/libtiff!506
-
-2023-06-17 Even Rouault <even.rouault@spatialys.com>
-
- WebP decoder: validate WebP blob width, height, band count against TIFF parameters
- to avoid use of uninitialized variable, or decoding corrupted content
- without explicit error
-
- Fixes #581, fixes #582
-
-2023-06-15 Even Rouault <even.rouault@spatialys.com>
-
- v4.5.1 release note: add warning about CMake config file being preview.
-
-2023-06-14 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'HOWTO-RELEASE-gitlab-release' into 'master'
- HOWTO-RELEASE: mention creating a gitlab release
-
- See merge request libtiff/libtiff!505
-
-2023-06-14 Even Rouault <even.rouault@spatialys.com>
-
- HOWTO-RELEASE: mention creating a gitlab release.
-
-2023-06-10 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'TIFFOpenWExt_O_RDWR' into 'master'
- TIFFOpenWExt(): mode r+ in the Windows implementation adjusted to that of Linux
-
- See merge request libtiff/libtiff!504
-
-2023-06-10 Even Rouault <even.rouault@spatialys.com>
-
- TIFFOpenWExt(): mode r+ in the Windows implementation adjusted to that of Linux
-
-2023-06-10 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_ossfuzz_59751' into 'master'
- TIFFReadDirectory(): fix crash when reading tag TIFFTAG_EP_BATTERYLEVEL
-
- See merge request libtiff/libtiff!503
-
-2023-06-10 Even Rouault <even.rouault@spatialys.com>
-
- TIFFReadDirectory(): fix crash when reading tag TIFFTAG_EP_BATTERYLEVEL.
- Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=59751
-
- In 738e0409 (refs #575), we disabled DNG / EP tags, but there was a
- special processing for TIFFTAG_EP_BATTERYLEVEL that must be disabled
- since the tag is no longer defined.
-
-2023-06-09 Su_Laus <sulau@freenet.de>
-
- Fix TransferFunction writing of only two transfer functions. The TIFFWriteDirectoryTagTransferfunction() function writes in some cases only two transfer functions, although only exactly one or exactly three transfer functions are allowed. This then leads to an error when reading. --> TIFFReadDirectory: Warning, Incorrect count for "TransferFunction"; tag ignored.
- This MR corrects the behaviour of TIFFWriteDirectoryTagTransferfunction() accordingly. Furthermore, a possible buffer overflow is avoided.
-
-2023-06-09 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_win_build' into 'master'
- Fix Windows build
-
- Closes #578
-
- See merge request libtiff/libtiff!501
-
-2023-06-09 Even Rouault <even.rouault@spatialys.com>
-
- cmake/PkgConfig.cmake: avoid CMake error when prefix or suffix is empty.
-
- Add tif_win32_versioninfo.rc and tif_tools_versioninfo.rc to EXTRA_DIST.
-
-2023-06-09 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_coverity_build' into 'master'
- build/gitlab-ci: fix coverity_build()
-
- See merge request libtiff/libtiff!499
-
-2023-06-09 Even Rouault <even.rouault@spatialys.com>
-
- build/gitlab-ci: fix coverity_build()
-
-2023-06-09 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'v4.5.1rc1_preparation' into 'master'
- Prepare release 4.5.1
-
- See merge request libtiff/libtiff!498
-
-2023-06-09 Even Rouault <even.rouault@spatialys.com>
-
- Prepare for v4.5.1 release.
-
- Merge remote-tracking branch 'sulaus/Rel_4.5.1_preparation'
-
-2023-06-09 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'disable_dng_tags' into 'master'
- tif_dirinfo.c: disable DNG 1.2->1.6 tags
-
- Closes #575
-
- See merge request libtiff/libtiff!497
-
-2023-06-09 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_577' into 'master'
- CMake related fixes
-
- Closes #577
-
- See merge request libtiff/libtiff!496
-
-2023-06-09 Even Rouault <even.rouault@spatialys.com>
-
- libtiff v4.5.1 released
-
-2023-06-09 Even Rouault <even.rouault@spatialys.com>
-
- Merge remote-tracking branch 'sulaus/Rel_4.5.1_preparation'
-
-2023-06-09 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'disable_dng_tags' into 'master'
- tif_dirinfo.c: disable DNG 1.2->1.6 tags
-
- Closes #575
-
- See merge request libtiff/libtiff!497
-
-2023-06-09 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_577' into 'master'
- CMake related fixes
-
- Closes #577
-
- See merge request libtiff/libtiff!496
-
-2023-06-07 Even Rouault <even.rouault@spatialys.com>
-
- tif_dirinfo.c: disable DNG 1.2->1.6 tags.
- They were added per b90b20d36d7833f54a1f3014c324f6c21b988006 but it has
- been found in https://gitlab.com/libtiff/libtiff/-/issues/575 that it
- could cause compatibility issues with libtiff users, so this addition
- should be deferred for a feature release (likely 4.6.0) and not a patch one.
-
- Fixes #575
-
-2023-06-06 Timothy Lyanguzov <theta682@gmail.com>
-
- Apply 1 suggestion(s) to 1 file(s)
-
-2023-06-05 Even Rouault <even.rouault@spatialys.com>
-
- CI: add testing of find_package(Tiff CONFIG)
-
- CMake: export TiffConfig.cmake and TiffConfigVersion.cmake files.
-
- libtiff/CMakeLists.txt: fix export of INTERFACE_INCLUDE_DIRECTORIES.
-
- libtiff/CMakeLists.txt: correctly define TIFF::tiff alias (fixes #577)
-
-2023-06-05 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'TIFFField_downgrade_errors_to_warnings' into 'master'
- TIFFFieldWithName() and TIFFFieldWithTag() downgrade errors to warnings.
-
- See merge request libtiff/libtiff!495
-
-2023-05-28 Su_Laus <sulau@freenet.de>
-
- TIFFFieldWithName() and TIFFFieldWithTag() downgrade errors to warnings. see https://gitlab.com/libtiff/libtiff/-/issues/575#note_1407633888
-
-2023-05-25 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'bebuch-master-patch-58347' into 'master'
- check if upstream lzma (xz) config was used and bind to it if so
-
- See merge request libtiff/libtiff!494
-
-2023-05-25 Benjamin Buch <benni.buch@gmail.com>
-
- check if upstream lzma (xz) config was used and bind to it if so.
-
-2023-05-25 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'upstream-zstd-config' into 'master'
- check if upstream zstd config was used and bind to it if so
-
- See merge request libtiff/libtiff!493
-
-2023-05-25 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'cmake_FindDeflate_bugs_see_526' into 'master'
- CMake: FindDeflate several errors fixed (see #526)
-
- See merge request libtiff/libtiff!491
-
-2023-05-24 Su_Laus <sulau@freenet.de>
-
- CMake: FindDeflate several errors (see #526)
- There are CMake issues if the library is not included in the environment path and only set with CMake -D option.
- - For FindDeflate.cmake, FindJBIG.cmake, FindLERC.cmake, FindWebP.cmake, FindZSTD.cmake:
- Set IMPORTED_LOCATION (without debug or release) if neither <library>_LIBRARY_RELEASE nor <library>_LIBRARY_DEBUG were set.
- - FindDeflate.cmake: Correct code to retrieve library version information from libdeflate.h
- - FindLERC.cmake version string return added.
-
-2023-05-24 Benjamin Buch <benni.buch@gmail.com>
-
- prefer shared over static.
-
- check if upstream zstd config was used and bind to it if so.
-
-2023-05-24 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'master' into 'master'
- make WebP component name compatible with upstream ConfigWebP.cmake
-
- See merge request libtiff/libtiff!492
-
-2023-05-24 Benjamin Buch <benni.buch@gmail.com>
-
- CMake: make WebP component name compatible with upstream ConfigWebP.cmake
-
-2023-05-18 Su_Laus <sulau@freenet.de>
-
- Prepare release 4.5.1 - Update till 18.05.23 after fix_559_DNG_1.6_passcount_error
-
- Prepare release 4.5.1.
-
-2023-05-18 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_559_DNG_1.6_passcount_error' into 'master'
- Fix #559 DNG 1.6 passcount assertion
-
- Closes #574 et #559
-
- See merge request libtiff/libtiff!489
-
-2023-05-18 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_557_TagExtender_for_CustomDirectories_not_possible' into 'master'
- manpage: TIFFSetTagExtender() cannot add tags to custom directories. Closes #557.
-
- Closes #557
-
- See merge request libtiff/libtiff!490
-
-2023-05-18 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_559_DNG_1.6_passcount_error' into 'master'
- Fix #559 DNG 1.6 passcount assertion
-
- Closes #574 et #559
-
- See merge request libtiff/libtiff!489
-
-2023-05-18 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_557_TagExtender_for_CustomDirectories_not_possible' into 'master'
- manpage: TIFFSetTagExtender() cannot add tags to custom directories. Closes #557.
-
- Closes #557
-
- See merge request libtiff/libtiff!490
-
-2023-05-17 Su_Laus <sulau@freenet.de>
-
- Documentation update: TIFFSetTagExtender() cannot add tags to custom directories.
- Closes #557.
-
-2023-05-16 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_558' into 'master'
- Hardcode HOST_FILLORDER to FILLORDER_LSB2MSB, and make 'H' flag of TIFFOpen()...
-
- See merge request libtiff/libtiff!488
-
-2023-05-16 Su_Laus <sulau@freenet.de>
-
- Fix #559 DNG 1.6 passcount assertion.
- Amend DNG tags definition introduced with MR 482:
- - DNG 1.6 tags specified as UTF-8 strings are defined as variable TIFF_BYTE with passcount=TRUE.
- - For all tags with TIFF_SETGET_C32_UINT8 the readcount and writecount were corrected to -3 (TIFF_VARIABLE2).
-
- Testprogram to write and read all tags defined within LibTIFF is introduced.
- It also checks for valid passcount flag setting for the defined tags but some special tags are excluded from that check.
-
- Closes #559.
-
-2023-05-09 Even Rouault <even.rouault@spatialys.com>
-
- Hardcode HOST_FILLORDER to FILLORDER_LSB2MSB, and make 'H' flag of TIFFOpen() to warn and an alias of FILLORDER_MSB2LSB
-
- tif_lerc.c: use WORDS_BIGENDIAN instead of HOST_BIGENDIAN.
-
-2023-05-07 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_484_TIFFDirectory_32_64_bit' into 'master'
- Fix 484 TIFFDirectory td_fieldsset uses unsigned long which can be 32 or 64 bits.
-
- Closes #484
-
- See merge request libtiff/libtiff!471
-
-2023-05-07 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'DNG_1.6_EP_tags' into 'master'
- Add DNG tags up to version 1.6.0.0 and some TIFF/EP tags and update documentation
-
- See merge request libtiff/libtiff!482
-
-2023-05-07 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue547' into 'master'
- do not install libtiff-4.pc when tiff-install is reset
-
- Closes #547
-
- See merge request libtiff/libtiff!481
-
-2023-05-06 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_548' into 'master'
- LZWDecode(): avoid crash when trying to read again from a strip with a...
-
- Closes #548
-
- See merge request libtiff/libtiff!484
-
-2023-05-06 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiffcrop_fix_553_multi-image-errors' into 'master'
- tiffcrop: fix 553 by considering error return of writeSelections()
-
- Closes #553
-
- See merge request libtiff/libtiff!485
-
-2023-05-06 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tif_ojpeg_fix-554_FPE' into 'master'
- tif_ojpeg.c fix 554 by checking for division by zero
-
- Closes #554
-
- See merge request libtiff/libtiff!486
-
-2023-05-06 Su Laus <sulau@freenet.de>
-
- tif_ojpeg.c fix 554 by checking for division by zero.
-
-2023-05-05 Su_Laus <sulau@freenet.de>
-
- Consider error return of writeSelections(). Fixes #553.
-
-2023-04-29 Even Rouault <even.rouault@spatialys.com>
-
- LZWDecode(): avoid crash when trying to read again from a strip with a missing end-of-information marker (fixes #548)
-
-2023-04-25 Su_Laus <sulau@freenet.de>
-
- Add DNG tags up to version 1.6.0.0 and some TIFF/EP tags and update documentation
- Amend MR !337 'Add support for DNG tags up to version 1.6.0.0 and some TIFF/EP tags' from Sami Liedes:
- - Set most tags to OkToChange=1.
- - Define BATTERYLEVEL tag as ASCII and convert values of rational variant to ASCII.
- - TIFF documentation updated for tags recognized by LibTiff (DNG 1.6 and others).
- - TIFF/EP tags added, which are equivalent to EXIF tags. This addresses part of #418 as well.
- - Definition of tags reformatted (clang-format off) for better readability of tag comments in tiff.h and tif_dirinfo.c
-
-2023-04-23 Roman <kosobrodov@fastmail.fm>
-
- do not install libtiff-4.pc when tiff-install is reset.
-
-2023-04-21 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'mymaster1' into 'master'
- fix runtime error: applying zero offset to null pointer
-
- See merge request libtiff/libtiff!479
-
-2023-04-21 xiaoxiaoafeifei <lliangliang2007@163.com>
-
- countInkNamesString(): fix `UndefinedBehaviorSanitizer`: applying zero offset to null pointer
-
-2023-03-26 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tif_ovrcache_TIFFSetSubDirectory' into 'master'
- tif_ovrcache.c: check TIFFSetSubDirectory() return value (CID 1524573)
-
- See merge request libtiff/libtiff!478
-
-2023-03-26 Even Rouault <even.rouault@spatialys.com>
-
- tif_ovrcache.c: check TIFFSetSubDirectory() return value (CID 1524573)
-
-2023-03-26 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'even_faster_setdirectory_with_IFDlist' into 'master'
- Even faster TIFFSetDirectory() using IFD list.
-
- See merge request libtiff/libtiff!477
-
-2023-03-26 Su Laus <sulau@freenet.de>
-
- Even faster TIFFSetDirectory() using IFD list.
-
-2023-03-12 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'faster-setdirectory_newMR' into 'master'
- Optimize relative seeking with TIFFSetDirectory
-
- See merge request libtiff/libtiff!474
-
-2023-03-12 Su Laus <sulau@freenet.de>
-
- Optimize relative seeking with TIFFSetDirectory.
-
-2023-03-11 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'master' into 'master'
- Fix memory leak in tiffcrop.c
-
- See merge request libtiff/libtiff!475
-
-2023-03-08 zhailiangliang <zhailiangliang@loongson.cn>
-
- Fix memory leak in tiffcrop.c.
-
-2023-02-23 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'skip-thumbnail-test' into 'master'
- test: avoid running tool tests if not built
-
- Closes #421
-
- See merge request libtiff/libtiff!334
-
-2023-02-22 Sam James <sam@gentoo.org>
-
- test (cmake): skip script tests if tools aren't built.
- In Gentoo, we avoid building the tools for multilib (32-bit, x86) builds on
- amd64/x86_64 because we only need the library to keep binary applications working.
-
- This causes a test failure in e.g. tiffcp-thumbnail.sh as the 'thumbnail'
- binary isn't built. Skip it if unavailable.
-
- Fixes: https://gitlab.com/libtiff/libtiff/-/issues/421
-
-2023-02-22 Sam James <sam@gentoo.org>
-
- test (autotools): skip script tests if tools aren't built.
- In Gentoo, we avoid building the tools for multilib (32-bit, x86) builds on
- amd64/x86_64 because we only need the library to keep binary applications working.
-
- This causes a test failure in e.g. tiffcp-thumbnail.sh as the 'thumbnail'
- binary isn't built. Skip it if unavailable.
-
- Fixes: https://gitlab.com/libtiff/libtiff/-/issues/421
-
-2023-02-16 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_Unlink_first_directory_0' into 'master'
- Fix TIFFUnlinkDirectory(0) case and unlink of first directory.
-
- See merge request libtiff/libtiff!460
-
-2023-02-16 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tif_luv_check_NaN_fix_#530' into 'master'
- tif_luv: Check and correct for NaN data in uv_encode().
-
- Closes #530
-
- See merge request libtiff/libtiff!473
-
-2023-02-16 Su_Laus <sulau@freenet.de>
-
- tif_luv: Check and correct for NaN data in uv_encode().
- Closes #530
-
- See merge request !473
-
-2023-02-14 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiffcrop_dont_reuse_input_buffer_fix_527' into 'master'
- tiffcrop: Do not reuse input buffer for subsequent images. Fix issue 527
-
- Closes #527
-
- See merge request libtiff/libtiff!472
-
-2023-02-14 Su_Laus <sulau@freenet.de>
-
- tiffcrop: Do not reuse input buffer for subsequent images. Fix issue 527
- Reuse of read_buff within loadImage() from previous image is quite unsafe, because other functions (like rotateImage() etc.) reallocate that buffer with different size without updating the local prev_readsize value.
-
- Closes #527
-
-2023-02-08 Su_Laus <sulau@freenet.de>
-
- Fix 484 TIFFDirectory td_fieldsset uses unsigned long which can be 32 or 64 bits.
- Closes #484
-
-2023-02-08 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'test_ifd_loop_detection_fix_CoverityScan_ln_55' into 'master'
- test_ifd_loop_detection: fix Coverity Scan issue CID 1520750: Null pointer...
-
- See merge request libtiff/libtiff!470
-
-2023-02-08 Su_Laus <sulau@freenet.de>
-
- test_ifd_loop_detection: fix Coverity Scan issue CID 1520750: Null pointer dereferences (NULL_RETURNS) line 55.
-
-2023-02-06 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiffcrop_fix_CoverityScan_line_9676' into 'master'
- Fix Coverity Scan issue CID 1520761: Integer handling issues...
-
- See merge request libtiff/libtiff!469
-
-2023-02-06 Su_Laus <sulau@freenet.de>
-
- Fix Coverity Scan issue CID 1520761: Integer handling issues (OVERFLOW_BEFORE_WIDEN) tiffcrop.c: 9676 in rotateImage()
-
-2023-02-05 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiffcrop_R270_fix#492' into 'master'
- tiffcrop: Amend rotateImage() not to toggle the input (main) image width and...
-
- Closes #519, #518, #499, #495, #494, #493 et #492
-
- See merge request libtiff/libtiff!465
-
-2023-02-05 Su_Laus <sulau@freenet.de>
-
- tiffcrop: Amend rotateImage() not to toggle the input (main) image width and length parameters when only cropped image sections are rotated. Remove buffptr from region structure because never used.
- Closes #492 #493 #494 #495 #499 #518 #519
-
-2023-02-05 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiffcrop_correctly_update_buffersize_after_rotate_fix#520' into 'master'
- tiffcrop correctly update buffersize after rotateImage() fix#520
-
- Closes #520
-
- See merge request libtiff/libtiff!467
-
-2023-02-05 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiffcrop_composite_image_assumption_test_fix#496' into 'master'
- tiffcrop: added check for assumption on composite images (fixes #496)
-
- Closes #501, #500, #498, #497 et #496
-
- See merge request libtiff/libtiff!466
-
-2023-02-05 Su Laus <sulau@freenet.de>
-
- tiffcrop: added check for assumption on composite images (fixes #496)
- tiffcrop: For composite images with more than one region, the combined_length or combined_width always needs to be equal, respectively. Otherwise, even the first section/region copy action might cause buffer overrun. This is now checked before the first copy action.
-
- Closes #496, #497, #498, #500, #501.
-
-2023-02-04 Su_Laus <sulau@freenet.de>
-
- tiffcrop correctly update buffersize after rotateImage() fix#520 -- enlarge buffsize and check integer overflow within rotateImage().
-
-2023-02-04 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'test_subidf_loop' into 'master'
- test_ifd_loop_detection: Added test to check loops in SubIFDs that are chained.
-
- See merge request libtiff/libtiff!464
-
-2023-02-04 Su Laus <sulau@freenet.de>
-
- test_ifd_loop_detection: Added test to check loops in SubIFDs that are chained.
-
-2023-02-04 Su_Laus <sulau@freenet.de>
-
- Fix TIFFUnlinkDirectory(0) case and unlink of first directory.
- If directory number 0 is unlinked, then the base offset variables within LibTiff are not updated. As a result, a subsequent TIFFSetDirectory() first goes to the unlinked former directory number 0.
-
- In addition, the error case for dirn=0 is handled.
-
- This MR fixes that by updating the base offset variables tif->tif_header.classic.tiff_diroff and tif->tif_header.big.tiff_diroff.
-
-2023-02-03 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'TiffClose_NULL_ptr_dereferencing_fix_515' into 'master'
- TIFFClose() avoid NULL pointer dereferencing. fix#515
-
- Closes #515
-
- See merge request libtiff/libtiff!468
-
-2023-02-03 Su_Laus <sulau@freenet.de>
-
- TIFFClose() avoid NULL pointer dereferencing. fix#515.
- Closes #515
-
- tiffcrop correctly update buffersize after rotateImage() fix#520 rotateImage() set up a new buffer and calculates its size individually. Therefore, seg_buffs[] size needs to be updated accordingly. Before this fix, the seg_buffs buffer size was calculated with a different formula than within rotateImage().
- Closes #520.
-
-2023-01-25 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'add_windows_DLL_versioninfo' into 'master'
- Add versioninfo resource files for DLL and tools compiled with Windows MSVC and MINGW.
-
- See merge request libtiff/libtiff!455
-
-2023-01-25 Su Laus <sulau@freenet.de>
-
- Add versioninfo resource files for DLL and tools compiled with Windows MSVC and MINGW.
-
-2023-01-22 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tif_hash_set_order_include' into 'master'
- tif_hash_set.c: include tif_hash_set.h after tif_config.h to let a chance for...
-
- See merge request libtiff/libtiff!462
-
-2023-01-22 Even Rouault <even.rouault@spatialys.com>
-
- tif_hash_set.c: include tif_hash_set.h after tif_config.h to let a chance for GDAL symbol renaming trick
-
-2023-01-22 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_513' into 'master'
- Fax3: fix failure to decode some fax3 images (fixes #513)
-
- Closes #513
-
- See merge request libtiff/libtiff!461
-
-2023-01-21 Even Rouault <even.rouault@spatialys.com>
-
- Add test for Fax3 decoding issues (refs #513)
-
-2023-01-21 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiffcrop_fix_#488' into 'master'
- tiffcrop: Correct simple copy paste error. Fix #488.
-
- Closes #488
-
- See merge request libtiff/libtiff!459
-
-2023-01-21 Su Laus <sulau@freenet.de>
-
- tiffcrop: Correct simple copy paste error. Fix #488.
-
-2023-01-21 Even Rouault <even.rouault@spatialys.com>
-
- Fax3: fix failure to decode some fax3 images (fixes #513)
- Patch by @jsummers26
-
-2023-01-12 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiffmedian_fix_#477' into 'master'
- tiffmedian: avoid zero num_colors, fixes #477
-
- Closes #477
-
- See merge request libtiff/libtiff!458
-
-2023-01-12 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fax2ps_fixes_#475' into 'master'
- fax2ps: fixes #475 buffer overflow in qsort function pcompar.
-
- Closes #475
-
- See merge request libtiff/libtiff!457
-
-2023-01-12 Su_Laus <sulau@freenet.de>
-
- tiffmedian: avoid zero num_colors, fixes #477.
-
- fax2ps: fixes #475 buffer overflow in qsort function pcompar.
-
-2023-01-09 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_241_tiffset_file_size_limit' into 'master'
- tiffset: get filesize to allocate only the required memory. Fixes issue #241
-
- Closes #241
-
- See merge request libtiff/libtiff!451
-
-2023-01-09 Su Laus <sulau@freenet.de>
-
- tiffset: get filesize to allocate only the required memory. Fixes issue #241
-
-2023-01-09 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch '_TIFFCleanupIFDOffsetAndNumberMaps' into 'master'
- Add _TIFFCleanupIFDOffsetAndNumberMaps() and call it from TIFFUnlinkDirectory()
-
- See merge request libtiff/libtiff!454
-
-2023-01-06 Even Rouault <even.rouault@spatialys.com>
-
- Remove use of tif_dirnumber.
-
- TIFFSetSubDirectory(): call _TIFFCleanupIFDOffsetAndNumberMaps()
-
- struct tiff: remove unused tif_dirlistoff.
-
- TIFFUnlinkDirectory(): reset tif_dirnumber.
-
- Add _TIFFCleanupIFDOffsetAndNumberMaps() and call it from TIFFUnlinkDirectory()
-
-2022-12-29 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'cmake_in_files_formatting_sensitive' into 'master'
- Disable clang-formatting for tif_config.h.cmake.in and tiffconf.h.cmake.in...
-
- See merge request libtiff/libtiff!452
-
-2022-12-28 Su_Laus <sulau@freenet.de>
-
- Disable clang-formatting for tif_config.h.cmake.in and tiffconf.h.cmake.in because sensitive for CMake scripts. - explanation added
-
-2022-12-26 Su_Laus <sulau@freenet.de>
-
- Disable clang-formatting for tif_config.h.cmake.in and tiffconf.h.cmake.in because sensitive for CMake scripts.
-
-2022-12-19 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'manpage_multi-page-TIFF' into 'master'
- manpage: Add multi page TIFF and SubIFDs description and read / write example.
-
- See merge request libtiff/libtiff!450
-
-2022-12-19 Su Laus <sulau@freenet.de>
-
- manpage: Add multi page TIFF and SubIFDs description and read / write example.
-
-2022-12-18 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'TIFFOpen_r+_windows_behaviour' into 'master'
- Behavior of TIFFOpen() mode "r+" in the Windows implementation adjusted to that of Linux.
-
- See merge request libtiff/libtiff!449
-
-2022-12-16 Su_Laus <sulau@freenet.de>
-
- Behavior of TIFFOpen() mode "r+" in the Windows implementation adjusted to that of Linux.
-
-2022-12-15 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'ossfuzz_54343' into 'master'
- TIFFSetDirectory: avoid harmless unsigned-integer-overflow
-
- See merge request libtiff/libtiff!447
-
-2022-12-15 Even Rouault <even.rouault@spatialys.com>
-
- TIFFSetDirectory: avoid harmless unsigned-integer-overflow.
- Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=54343
-
-2022-12-14 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'ossfuzz_54311' into 'master'
- TIFFWriteDirectorySec(): avoid harmless unsigned-integer-overflow
-
- See merge request libtiff/libtiff!446
-
-2022-12-14 Even Rouault <even.rouault@spatialys.com>
-
- TIFFWriteDirectorySec(): avoid harmless unsigned-integer-overflow.
- Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=54311
-
-2022-12-14 Even Rouault <even.rouault@spatialys.com>
-
- libtiff v4.5.0rc2 preparation
-
-2022-12-14 Su_Laus <sulau@freenet.de>
-
- tiffinfo: update curdir from uint16_t to tdir_t for more than 64k IFD handling.
-
-2022-12-13 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_502' into 'master'
- Make TIFFSetDirectory(tiff, 65534) work again (fixes #502)
-
- Closes #502
-
- See merge request libtiff/libtiff!436
-
-2022-12-13 Even Rouault <even.rouault@spatialys.com>
-
- Add tests for IFD loop detection.
-
- Fix IFD loop detection.
-
- Use UINT_MAX.
-
- Make TIFF_MAX_DIR_COUNT a autoconf/CMake setting.
-
-2022-12-13 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'build-shared-by-default' into 'master'
- Restore shared libraries by default
-
- See merge request libtiff/libtiff!437
-
-2022-12-13 shaun walbridge <shaun.walbridge@gmail.com>
-
- CMake: restore shared libraries by default for top-level build.
-
-2022-12-12 Even Rouault <even.rouault@spatialys.com>
-
- Add a TIFF_MAX_DIR_COUNT public #define.
-
- TIFFCurrentDirectory(), TIFFNumberOfDirectories(), TIFFSetDirectory(), TIFFUnlinkDirectory(): use tdir_t that is now a uint32_t, and raise limit of IFDs to 1048576
-
- IFD loop checking: use hashmap to avoid quadratic performance.
-
- Add a hashset/hashmap implementation (ported from GDAL's CPLHashSet)
-
- Make TIFFSetDirectory(tiff, 65534) work again (fixes #502)
-
-2022-12-11 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'do_not_format_tiffvers_h' into 'master'
- Revert formatting of tiffvers.h and add TIFFLIB_MAJOR_VERSION, TIFFLIB_MINOR_VERSION, TIFFLIB_MICRO_VERSION defines
-
- See merge request libtiff/libtiff!434
-
-2022-12-11 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiffcrop_exclude_some_comment_from_clang-format' into 'master'
- tiffcrop: Exclude some comments from clang-format
-
- See merge request libtiff/libtiff!435
-
-2022-12-11 Su Laus <sulau@freenet.de>
-
- tiffcrop: Exclude some comments from clang-format.
-
-2022-12-11 Even Rouault <even.rouault@spatialys.com>
-
- tiffvers.h.in: add clang-format off/on.
-
-2022-12-10 Even Rouault <even.rouault@spatialys.com>
-
- tiffvers.h: add TIFFLIB_MAJOR_VERSION, TIFFLIB_MINOR_VERSION, TIFFLIB_MICRO_VERSION defines
- Also add a TIFFLIB_AT_LEAST() macro
-
- tiffvers.h: revert formatting.
-
- Exclude reformatting of tiffvers.h which breaks version detection for FindTIFF.cmake
-
-2022-12-09 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'release_4_5_0' into 'master'
- Prepare v4.5.0 release
-
- See merge request libtiff/libtiff!433
-
-2022-12-09 Even Rouault <even.rouault@spatialys.com>
-
- libtiff v4.5.0rc1 preparation
-
-2022-12-08 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'reformat' into 'master'
- Whole code-base reformatting
-
- See merge request libtiff/libtiff!431
-
-2022-12-08 Even Rouault <even.rouault@spatialys.com>
-
- Add .git-blame-ignore-revs.
-
- tiffcrop: remove version_id and rev_date.
-
-2022-12-08 pre-commit run by Even Rouault <even.rouault-bot@spatialys.com>
-
- Reformatting in all other directories using 'pre-commit run'
-
- Reformatting in test/ using 'pre-commit run'
-
- Reformatting in tools/ using 'pre-commit run'
-
- Reformatting in libtiff/ using 'pre-commit run'
-
-2022-12-08 Even Rouault <even.rouault@spatialys.com>
-
- Add .clang-format, .pre-commit-config.yaml and CONTRIBUTING.md.
-
- Remove vim/emacs formatting footers.
-
-2022-11-29 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_489' into 'master'
- TIFFWriteRawStrip(): restore capabilities to append data in the current strip (fixes #489)
-
- Closes #489
-
- See merge request libtiff/libtiff!430
-
-2022-11-29 Even Rouault <even.rouault@spatialys.com>
-
- Add test case for scenario of issue #489.
-
- TIFFWriteRawStrip(): restore capabilities to append data in the current strip (fixes #489)
- This fixes a regression of libtiff 4.4.0
-
-2022-11-29 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'manpage_re-entrant_error_handler' into 'master'
- manpage update for re-entrant error handler TIFFErrorExtR(), TIFFOpenExt() and...
-
- See merge request libtiff/libtiff!427
-
-2022-11-29 Su Laus <sulau@freenet.de>
-
- manpage update for re-entrant error handler TIFFErrorExtR(), TIFFOpenExt() and...
-
-2022-11-27 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiffcrop_fix_#169' into 'master'
- tiffcrop: Add check if (bps != 1) in writeSingleSection() for...
-
- Closes #169
-
- See merge request libtiff/libtiff!429
-
-2022-11-27 Su Laus <sulau@freenet.de>
-
- tiffcrop: Add check if (bps != 1) in writeSingleSection() for...
-
-2022-11-26 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'TIFFErrorExtR_fix_missing_calls' into 'master'
- TIFFErrorExt() was not replaced with TIFFErrorExtR() everywhere in libtiff....
-
- See merge request libtiff/libtiff!428
-
-2022-11-26 Su Laus <sulau@freenet.de>
-
- TIFFErrorExt() was not replaced with TIFFErrorExtR() everywhere in libtiff....
-
-2022-11-25 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tif_jpeg_build_fix' into 'master'
- tif_jpeg.c: fix compilation with MSVC (fixes commit 0fd1a81d3547acb8f5be50bbbc3e44bde01c014b)
-
- See merge request libtiff/libtiff!426
-
-2022-11-25 Even Rouault <even.rouault@spatialys.com>
-
- tif_jpeg.c: fix compilation with MSVC (fixes commit 0fd1a81d3547acb8f5be50bbbc3e44bde01c014b)
-
-2022-11-25 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_0fd1a81d3547acb8f5be50bbbc3e44bde01c014b' into 'master'
- JPEGEncode(): fix wrong pointer data type with libjpeg-turbo 2.2dev in 12-bit mode
-
- See merge request libtiff/libtiff!425
-
-2022-11-25 Even Rouault <even.rouault@spatialys.com>
-
- JPEGEncode(): fix wrong pointer data type with libjpeg-turbo 2.2dev in 12-bit mode
- (fixes commit 0fd1a81d3547acb8f5be50bbbc3e44bde01c014b)
-
-2022-11-25 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'libjpegturbo_dual' into 'master'
- Add support for libjpeg-turbo 2.2-dev 8/12 bit dual mode
-
- See merge request libtiff/libtiff!422
-
-2022-11-25 Even Rouault <even.rouault@spatialys.com>
-
- Add support for libjpeg-turbo 2.2-dev 8/12 bit dual mode.
-
-2022-11-23 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'windows-fix' into 'master'
- libtiff: Fix TIFFOpen* for the Windows platform in tif_unix.c
-
- See merge request libtiff/libtiff!424
-
-2022-11-23 Francois Bleibel <fbleibel@gmail.com>
-
- libtiff: Fix TIFFOpen* for the Windows platform in tif_unix.c.
- I'm not sure where this change was made, but it must have been in a recent update. TIFFOpenWEx is now TIFFOpenWExt, and _TIFFgetMode takes additional arguments.
-
- Verified: Tested libtiff on a local Windows build.
-
-2022-11-23 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiffcrop_signed_vs_unsigned' into 'master'
- tiffcrop.c: fix warning about signed vs unsigned comparison
-
- See merge request libtiff/libtiff!423
-
-2022-11-23 Even Rouault <even.rouault@spatialys.com>
-
- tiffcrop.c: fix warning about signed vs unsigned comparison.
-
-2022-11-23 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'TIFFClientOpenExt_warning_fix' into 'master'
- TIFFClientOpenExt(): fix warning on 32-bit platforms (master only)
-
- See merge request libtiff/libtiff!421
-
-2022-11-23 Even Rouault <even.rouault@spatialys.com>
-
- TIFFClientOpenExt(): fix warning on 32-bit platforms (master only)
-
-2022-11-23 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiffcp_TIFFOpenOptionsFree_memleak_fix' into 'master'
- tiffcp: fix leak of TIFFOpenOptionsAlloc() introduced in latest commit (master only)
-
- See merge request libtiff/libtiff!420
-
-2022-11-23 Even Rouault <even.rouault@spatialys.com>
-
- tiffcp: fix leak of TIFFOpenOptionsAlloc() introduced in latest commit (master only)
- Fixes Coverity CID 1517032
-
-2022-11-23 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'TIFFOpenOptionsSetMaxSingleMemAlloc' into 'master'
- Add TIFFOpenOptionsSetMaxSingleMemAlloc() to define a limit in bytes for a single memory allocation done by libtiff
-
- See merge request libtiff/libtiff!419
-
-2022-11-23 Even Rouault <even.rouault@spatialys.com>
-
- Emit explicit error message when tif_max_single_mem_alloc is exceeded.
-
- test_open_options: test TIFFOpenOptionsSetMaxSingleMemAlloc()
-
- Rename test_error_handlers to test_open_options.
-
- tiffinfo, tiffcp, tiffcrop, tiffsplit, tiff2rgba, tiff2ps: use TIFFOpenOptionsSetMaxSingleMemAlloc()
-
- Convert uses of _TIFFmalloc/realloc/calloc/free to the Ext functions.
-
-2022-11-22 Even Rouault <even.rouault@spatialys.com>
-
- Add TIFFOpenOptionsSetMaxSingleMemAlloc()
- to define a limit in bytes for a single memory allocation done by libtiff.
-
- Also add internal functions used in replacement of the non Ext ones:
- void* _TIFFmallocExt(TIFF* tif, tmsize_t s);
- void* _TIFFcallocExt(TIFF* tif, tmsize_t nmemb, tmsize_t siz);
- void* _TIFFreallocExt(TIFF* tif, void* p, tmsize_t s);
- void _TIFFfreeExt(TIFF* tif, void* p);
-
-2022-11-22 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'TIFFOpenEx' into 'master'
- Add TIFFOpenExt(), TIFFOpenWExt() and TIFFFdOpenExt() with re-entrant error handlers
-
- See merge request libtiff/libtiff!413
-
-2022-11-21 Even Rouault <even.rouault@spatialys.com>
-
- Remove TIFFSetErrorHandlerExtR() and TIFFSetWarningHandlerExtR() that were temporarily added in master
-
- Add a _TIFFErrorEarly() function to be able to use the re-entrant error handler, even before TIFF* is valid
-
- Rework TIFFOpenExt() and similar to use an opaque TIFFOpenOptions* opts argument, with alloc, free and setters
-
- Document TIFFOpenExt, TIFFOpenWExt, TIFFFdOpenExt, TIFFClientOpenExt, TIFFSetErrorHandlerExtR, TIFFSetWarningHandlerExtR
-
-2022-11-21 Even Rouault <even.rouault@spatialys.com>
-
- Add TIFFOpenExt(), TIFFOpenWExt() and TIFFFdOpenExt() with re-entrant error handlers
- Rename TIFFClientOpenEx() to TIFFClientOpenExt()
-
- Rework signature of the re-entrant error handlers and of
- TIFFSetWarningHandlerExt() and TIFFSetErrorHandlerExt()
-
- Use structures that can be extended as extra argument.
-
- Leverages and amends https://gitlab.com/libtiff/libtiff/-/merge_requests/409
-
-2022-11-21 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'manpage_fix485_file-descriptor_clientdata' into 'master'
- manpage: Correct description of file handle/descriptors tif_fd and tif_clientdata. Closes #485.
-
- Closes #485
-
- See merge request libtiff/libtiff!418
-
-2022-11-21 Su Laus <sulau@freenet.de>
-
- manpage: Correct description of file handle/descriptors tif_fd and tif_clientdata. Closes #485.
-
-2022-11-20 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'manpage_fix440_fix28_TIFFOpen_SubIFD_update' into 'master'
- manpage: fix28, fix440, update TIFFOpen and SubIFD
-
- Closes #440 et #28
-
- See merge request libtiff/libtiff!417
-
-2022-11-20 Su Laus <sulau@freenet.de>
-
- manpage: fix28, fix440, update TIFFOpen and SubIFD.
-
-2022-11-17 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'cmake_tiff_install_warning' into 'master'
- CMakeLists.txt: fix warning with -Wdev
-
- See merge request libtiff/libtiff!416
-
-2022-11-13 Even Rouault <even.rouault@spatialys.com>
-
- CMakeLists.txt: fix warning with -Wdev.
- ```
- CMake Warning (dev) at CMakeLists.txt:62 (option):
- Policy CMP0077 is not set: option() honors normal variables. Run "cmake
- --help-policy CMP0077" for policy details. Use the cmake_policy command to
- set the policy and suppress this warning.
-
- For compatibility with older versions of CMake, option is clearing the
- normal variable 'tiff-install'.
- This warning is for project developers. Use -Wno-dev to suppress it.
- ```
-
-2022-11-12 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_479' into 'master'
- _TIFFReadEncodedTileAndAllocBuffer(): avoid excessive memory allocation on...
-
- See merge request libtiff/libtiff!412
-
-2022-11-12 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'typo_fix' into 'master'
- tif_dirread.c: fix typo in comment
-
- See merge request libtiff/libtiff!414
-
-2022-11-12 Even Rouault <even.rouault@spatialys.com>
-
- tif_dirread.c: fix typo in comment.
-
-2022-11-11 Even Rouault <even.rouault@spatialys.com>
-
- _TIFFReadEncodedTileAndAllocBuffer(): avoid excessive memory allocation on broken files (fixes #479)
-
-2022-11-10 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'bugfix/tiff2pdf-stdout' into 'master'
- tiff2pdf Don't try to seek into stdout.
-
- See merge request libtiff/libtiff!367
-
-2022-11-10 Claus-Justus Heine <himself@claus-justus-heine.de>
-
- tiff2pdf: Don't try to seek into stdout.
- Fixes #441
-
-2022-11-08 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_coverity_1516759' into 'master'
- TIFFErrorExtR(): fix Dereference after null check (CID 1516759)
-
- See merge request libtiff/libtiff!411
-
-2022-11-08 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_ossfuzz_53137' into 'master'
- TIFFReadRGBATileExt(): fix (unsigned) integer overflow on strips/tiles > 2 GB
-
- See merge request libtiff/libtiff!410
-
-2022-11-08 Even Rouault <even.rouault@spatialys.com>
-
- TIFFErrorExtR(): fix Dereference after null check (CID 1516759)
-
-2022-11-08 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'no_sprintf' into 'master'
- Replace sprintf calls with snprintf
-
- See merge request libtiff/libtiff!408
-
-2022-11-08 Mark Mentovai <mark@chromium.org>
-
- Replace sprintf calls with snprintf.
- This makes it possible to build libtiff without warnings using the macOS
- 13 SDK. Calls to sprintf are replaced with snprintf, passing appropriate
- buffer sizes.
-
- It doesn’t appear that any of the changed uses of sprintf were actually
- unsafe, so no behavior change is expected aside from SDK compatibility.
-
- The macOS 13 SDK deprecates sprintf as it’s difficult to use safely. The
- deprecation warning message is visible when building C++, but it is not
- normally visible when building plain C code due to a quirk in how
- sprintf is declared in the SDK. However, the deprecation message is
- visible when building plain C under Address Sanitizer
- (-fsanitize=address). This discrepancy was discovered at
- https://crbug.com/1381706 and reported to Apple with a copy at
- https://openradar.appspot.com/FB11761475.
-
- The macOS 13 SDK is packaged in Xcode 14.1, released on 2022-11-01. This
- also affects the iOS 16 SDK and other 2022-era Apple OS SDKs packaged in
- Xcode 14.0, released on 2022-09-12.
-
- libtiff is visible to the Chromium build via PDFium, and this change is
- needed to allow Chromium to move forward to the macOS 13 SDK.
-
- This change is limited to the libtiff directory. Other uses of sprintf
- were found in contrib, test, and tools.
-
-2022-11-08 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'reentrant' into 'master'
- Add reentrant error functions
-
- See merge request libtiff/libtiff!409
-
-2022-11-08 Even Rouault <even.rouault@spatialys.com>
-
- TIFFReadRGBATileExt(): fix (unsigned) integer overflow on strips/tiles > 2 GB
- Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=53137
-
-2022-11-08 Laramie Leavitt <lar@google.com>
-
- Add reentrant error functions.
- Prior to this change, libtiff relied on global error handlers,
- which is problematic when libtiff used by multiple independent
- libraries from within the same process, as they may unwittingly
- clobber the error handling, introduce race conditions when setting
- handlers, or otherwise have unintended side effects.
-
- This change adds error handlers to the TIFF struct, which are
- used preferentially when available. The error handlers are invoked
- when the re-entrant error functions are called:
-
- void TIFFErrorExtR(TIFF*, const char* module, const char* fmt, ...)
- void TIFFWarningExtR(TIFF*, const char* module, const char* fmt, ...)
-
- The handlers have a similar signature to the existing extended
- handlers, additionally returning an int:
-
- int TIFFErrorHandlerExtR(thandle_t, const char*, const char*, va_list)
-
- thandle_t is the userdata passed to TIFFOpen
- When the handler returns 1, the global handlers are not called.
-
- Custom error/warning handlers may be installed on a per-file
- basis by calling the Set functions:
-
- TIFF* tif = TIFFOpen(...);
- TIFFSetErrorHandlerExtR(tif, MyErrorHandler);
- TIFFSetWarningHandlerExtR(tif, MyWarningHandler);
-
- Additionally, the callsites to TIFFErrorExt and TIFFWarningExt
- have been updated to call the reentrant versions.
-
-2022-11-08 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiffcrop_fix_CoverityScan_tmsize_issue' into 'master'
- tiffcrop: should fix some Coverity Scan issues OVERFLOW_BEFORE_WIDEN
-
- See merge request libtiff/libtiff!403
-
-2022-11-08 Su Laus <sulau@freenet.de>
-
- tiffcrop: should fix some Coverity Scan issues OVERFLOW_BEFORE_WIDEN.
-
-2022-11-02 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'typo_fix' into 'master'
- tif_dirread.c: fix typo in comment
-
- See merge request libtiff/libtiff!407
-
-2022-11-02 Even Rouault <even.rouault@spatialys.com>
-
- tif_dirread.c: fix typo in comment.
-
-2022-10-23 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiffcrop_formatting_fix' into 'master'
- tiffcrop: add casts in TIFFError() to fix compiler warnings
-
- See merge request libtiff/libtiff!406
-
-2022-10-23 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_482' into 'master'
- CMake: correctly set default value of 'lzma' option when liblzma is detected (fixes #482)
-
- Closes #482
-
- See merge request libtiff/libtiff!404
-
-2022-10-23 Even Rouault <even.rouault@spatialys.com>
-
- tiffcrop: add casts in TIFFError() to fix compiler warnings.
-
- CMake: correctly set default value of 'lzma' option when liblzma is detected (fixes #482)
-
-2022-10-20 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_480' into 'master'
- Fix incorrect printf() formatters introduced in recent commits (fixes #480)
-
- Closes #480
-
- See merge request libtiff/libtiff!401
-
-2022-10-19 Even Rouault <even.rouault@spatialys.com>
-
- Fix incorrect printf() formatters introduced in recent commits (fixes #480)
-
-2022-10-13 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'CLIPPATH_tags_corrected' into 'master'
- CLIPPATH tags defined twice but differently and also wrongly (#439) - corrected
-
- Closes #439
-
- See merge request libtiff/libtiff!366
-
-2022-10-13 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'FIELD_IGNORE_warning-messages' into 'master'
- Warning messages for FIELD_IGNORE tags for writing and for TIFF_SETGET_UNDEFINED for reading added. (#438)
-
- Closes #438
-
- See merge request libtiff/libtiff!365
-
-2022-10-13 Su Laus <sulau@freenet.de>
-
- Warning messages for FIELD_IGNORE tags for writing and for TIFF_SETGET_UNDEFINED for reading added. (#438)
-
-2022-10-13 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tag-def_COMPRESSION_corrected' into 'master'
- tif_dirinfo.c TIFFTAG_COMPRESSION and _BITSPERSAMPLE definition corrected
-
- See merge request libtiff/libtiff!364
-
-2022-10-13 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_getopt_included_twice' into 'master'
- Fix including module getopt.c twice with CMake and HAVE_GETOPT=false
-
- See merge request libtiff/libtiff!381
-
-2022-10-13 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiffcrop_CoverityScan_fix_PRINTF_ARGS' into 'master'
- tiffcrop: fix Coverity Scan issues about PRINTF_ARGS.
-
- See merge request libtiff/libtiff!400
-
-2022-10-13 Su_Laus <sulau@freenet.de>
-
- tiffcrop fix Coverity Scan issues about PRINTF_ARGS.
-
-2022-10-13 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiffcrop_fix_#450_too-many-mode-options' into 'master'
- tiffcrop: fix #450 too many 'mode' options on command line.
-
- Closes #470 et #450
-
- See merge request libtiff/libtiff!384
-
-2022-10-13 Su Laus <sulau@freenet.de>
-
- tiffcrop: fix #450 too many 'mode' options on command line.
-
-2022-10-13 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiffcrop_fix_#435' into 'master'
- tiffcrop subroutines require a larger buffer (fixes #271, #381, #386, #388, #389, #435)
-
- Closes #465, #464, #435, #389, #388, #386, #381 et #271
-
- See merge request libtiff/libtiff!382
-
-2022-10-13 Su Laus <sulau@freenet.de>
-
- tiffcrop subroutines require a larger buffer (fixes #271, #381, #386, #388, #389, #435)
-
-2022-10-12 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'InkNames_NumberOfInks_handling_revised' into 'master'
- Revised handling of TIFFTAG_INKNAMES and related TIFFTAG_NUMBEROFINKS value (fixes #149, #150, #152, #168, #250, #269, #398 and #456)
-
- Closes #474, #463, #387, #456, #398, #269, #250, #168, #152, #150 et #149
-
- See merge request libtiff/libtiff!385
-
-2022-10-12 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiffcrop_fix_#411_#413' into 'master'
- tiffcrop: disable incompatibility of -Z, -X, -Y, -z options with any PAGE_MODE_x option (fixes #411, #413 and #426)
-
- Closes #426, #413 et #411
-
- See merge request libtiff/libtiff!383
-
-2022-10-10 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'TIFFAdvanceDirectory_mapped_uio' into 'master'
- TIFFAdvanceDirectory(): fix unsigned-integer-overflow in mapped case
-
- See merge request libtiff/libtiff!398
-
-2022-10-10 Even Rouault <even.rouault@spatialys.com>
-
- TIFFAdvanceDirectory(): fix unsigned-integer-overflow in mapped case.
- Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=52309
-
-2022-10-08 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiffinfo_parse_SubIFDs' into 'master'
- tiffinfo: Updated to parse through SubIFDs and show their tags.
-
- See merge request libtiff/libtiff!396
-
-2022-10-08 Su Laus <sulau@freenet.de>
-
- tiffinfo: Updated to parse through SubIFDs and show their tags.
-
-2022-10-07 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'master' into 'master'
- Moved linking of CMath::CMath into CMath_LIBRARY check
-
- See merge request libtiff/libtiff!397
-
-2022-10-07 Frei Herr <herr.frei@googlemail.com>
-
- Moved linking of CMath::CMath into CMath_LIBRARY check.
-
-2022-10-06 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'rational_precision2double_coverity-fix' into 'master'
- rational_precision2double.c: Fix issue from Coverity Scan.
-
- See merge request libtiff/libtiff!395
-
-2022-10-06 Su_Laus <sulau@freenet.de>
-
- rational_precision2double.c: Fix issue from Coverity Scan.
-
- Fix including module getopt.c twice with CMake and HAVE_GETOPT=false.
- The "make-files" for the tools- and test- programmes include the module getopt.c once directly as additional source and then again by including port.lib.
- This can be avoided by including getopt.c as source in port.lib within port\CMakeLists.txt not with PUBLIC but with PRIVATE.
-
-2022-10-06 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix-455_Improved-IFD-loop-handling' into 'master'
- Improved IFD-Loop Handling (fixes #455)
-
- Closes #455
-
- See merge request libtiff/libtiff!386
-
-2022-10-06 Su Laus <sulau@freenet.de>
-
- Improved IFD-Loop Handling (fixes #455)
- IFD infinite looping was not fixed by MR 20 (see #455).
- An improved IFD loop handling is proposed.
-
- Basic approach:
-
- - The order in the entire chain must be checked, and not only whether an offset has already been read once.
- - To do this, pairs of directory number and offset are stored and checked.
- - The offset of a directory number can change.
- - TIFFAdvanceDirectory() must also perform an IFD loop check.
- - TIFFCheckDirOffset() is replaced by _TIFFCheckDirNumberAndOffset().
-
- Rules for the check:
-
- - If an offset is already in the list, it must have the same IFD number. Otherwise it is an IDF loop.
- - If the offset is not in the list and the IFD number is greater than there are list entries, a new list entry is added.
- - Otherwise, the offset of the IFD number is updated.
-
- Reference is also made to old bugzilla bug 2772 and MR 20, which did not solve the general issue.
- This MR closes #455
-
-2022-10-05 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'fix-cmake-subproject' into 'master'
- Fix CMake build to be compatible with FetchContent
-
- See merge request libtiff/libtiff!394
-
-2022-10-04 Timothy Lyanguzov <theta682@gmail.com>
-
- Apply 9 suggestion(s) to 3 file(s)
-
-2022-10-04 Jeremy Maitin-Shepard <jbms@google.com>
-
- Fix CMake build to be compatible with FetchContent.
- Recent versions of CMake have improved support for including
- dependencies, using the FetchContent module, which allows a dependency
- to be imported as a subproject and then later found automatically by
- calls to `find_package`.
-
- This change makes libtiff's CMake better behaved when used as a
- sub-project:
-
- - CMake has a single global namespace for all target names in all
- sub-projects. This commit renames the following CMake targets:
-
- - port -> tiff_port
- - mkg3states -> tiff_mkg3states
- - faxtable -> tiff_faxtable
- - release -> tiff_release
-
- - When building TIFF as a sub-project, it is not normally useful to
- create install rules for its targets. This commit adds a
- `tiff-install` option that controls whether the install rules are
- added and defaults to OFF when libtiff is included as a sub-project.
-
- - Previously, libtiff set `BUILD_SHARED_LIBS` to ON by default. With
- this commit, that default is only set if libtiff is the top-level
- project.
-
- - When using `find_package(TIFF)`, the targets `TIFF::TIFF` and
- `TIFF::CXX` are defined. This commit makes libtiff itself define
- those targets as aliases, to allow other cmake projects to use
- either `find_package` or `FetchContent` interchangeably.
-
- - Adds ZSTD_HAVE_DECOMPRESS_STREAM variable which may be set to bypass
- `check_symbol_exists` call. Fixes
- https://gitlab.com/libtiff/libtiff/-/issues/472.
-
-2022-09-27 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'getimage_overflow' into 'master'
- Update getimage to support reading large raster images
-
- See merge request libtiff/libtiff!389
-
-2022-09-26 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'MinGW-warnings_ipctutil' into 'master'
- Fix #458: MinGW Windows 64: warning because 'long' is a 32 bits type in...
-
- Closes #458
-
- See merge request libtiff/libtiff!391
-
-2022-09-26 Su Laus <sulau@freenet.de>
-
- Fix #458: MinGW Windows 64: warning because 'long' is a 32 bits type in...
-
-2022-09-16 Eric Siegel <siegel.eric@gmail.com>
-
- Update getimage to support large raster images.
-
-2022-09-08 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'typo_fix' into 'master'
- tif_lzw.c: fix typo in code comment
-
- See merge request libtiff/libtiff!387
-
-2022-09-08 Even Rouault <even.rouault@spatialys.com>
-
- tif_lzw.c: fix typo in code comment.
-
-2022-08-30 Su_Laus <sulau@freenet.de>
-
- Revised handling of TIFFTAG_INKNAMES and related TIFFTAG_NUMBEROFINKS value
- In order to solve the buffer overflow issues related to TIFFTAG_INKNAMES and related TIFFTAG_NUMBEROFINKS value, a revised handling of those tags within LibTiff is proposed:
-
- Behaviour for writing:
- `NumberOfInks` MUST fit to the number of inks in the `InkNames` string.
- `NumberOfInks` is automatically set when `InkNames` is set.
- If `NumberOfInks` is different to the number of inks within `InkNames` string, that will be corrected and a warning is issued.
- If `NumberOfInks` is not equal to samplesperpixel only a warning will be issued.
-
- Behaviour for reading:
- When reading `InkNames` from a TIFF file, the `NumberOfInks` will be set automatically to the number of inks in `InkNames` string.
- If `NumberOfInks` is different to the number of inks within `InkNames` string, that will be corrected and a warning is issued.
- If `NumberOfInks` is not equal to samplesperpixel only a warning will be issued.
-
- This allows the safe use of the NumberOfInks value to read out the InkNames without buffer overflow
-
- This MR will close the following issues: #149, #150, #152, #168 (to be checked), #250, #269, #398 and #456.
-
- It also fixes the old bug at http://bugzilla.maptools.org/show_bug.cgi?id=2599, for which the limitation of `NumberOfInks = SPP` was introduced, which is in my opinion not necessary and does not solve the general issue.
-
-2022-08-25 Su_Laus <sulau@freenet.de>
-
- tiffcrop: disable incompatibility of -Z, -X, -Y, -z options with any PAGE_MODE_x option (fixes #411 and #413)
- tiffcrop does not support –Z, -z, -X and –Y options together with any other PAGE_MODE_x options like -H, -V, -P, -J, -K or –S.
-
- Code analysis:
-
- With the options –Z, -z, the crop.selections are set to a value > 0. Within main(), this triggers the call of processCropSelections(), which copies the sections from the read_buff into seg_buffs[].
- In the following code in main(), the only supported step, where that seg_buffs are further handled are within an if-clause with if (page.mode == PAGE_MODE_NONE) .
-
- Execution of the else-clause often leads to buffer-overflows.
-
- Therefore, the above option combination is not supported and will be disabled to prevent those buffer-overflows.
-
- The MR solves issues #411 and #413.
-
-2022-08-21 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiffcrop_S-option_mutually_exclusive' into 'master'
- tiffcrop: -S option mutually exclusive (fixes #349, #414, #422, #423, #424)
-
- Closes #424, #423, #422, #414 et #349
-
- See merge request libtiff/libtiff!378
-
-2022-08-20 Su_Laus <sulau@freenet.de>
-
- tiffcrop -S option: Make decision simpler.
-
-2022-08-20 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'remove_death_commented_code' into 'master'
- Remove dead code from tif_dirread.c, tif_dirwrite.c and tif_getimage.c
-
- See merge request libtiff/libtiff!380
-
-2022-08-20 Su Laus <sulau@freenet.de>
-
- Remove dead code from tif_dirread.c, tif_dirwrite.c and tif_getimage.c.
-
-2022-08-16 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'coverity_fixes' into 'master'
- Silence Coverity Scan false positive warnings about out-of-bounds access
-
- See merge request libtiff/libtiff!379
-
-2022-08-16 Even Rouault <even.rouault@spatialys.com>
-
- tif_zip.c: silence Coverity Scan false positive warnings about out-of-bounds access (CID 1491190, 1491197, 1491201)
-
- tif_dirread.c: silence Coverity Scan false positive warnings about out-of-bounds access (CID 1491182, 1491186)
-
-2022-08-16 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'default_tag_values_extended' into 'master'
- Presetting of default tag values extended (e.g. PlanarConfig). (fixes #449)
-
- Closes #449
-
- See merge request libtiff/libtiff!377
-
-2022-08-16 Su Laus <sulau@freenet.de>
-
- Presetting of default tag values extended (e.g. PlanarConfig). (fixes #449)
-
-2022-08-15 Su_Laus <sulau@freenet.de>
-
- According to Richard Nolde https://gitlab.com/libtiff/libtiff/-/issues/401#note_877637400 the tiffcrop option „-S“ is also mutually exclusive to the other crop options (-X|-Y), -Z and -z.
- This is now checked and ends tiffcrop if those arguments are not mutually exclusive.
-
- This MR will fix the following tiffcrop issues: #349, #414, #422, #423, #424
-
-2022-08-09 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'warning_fix' into 'master'
- Fix warning about shadowing
-
- See merge request libtiff/libtiff!376
-
-2022-08-09 Even Rouault <even.rouault@spatialys.com>
-
- Fix warning about shadowing.
-
-2022-08-09 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_225' into 'master'
- Deal with RichTIFFIPTC tag written with LONG type (fixes #225)
-
- Closes #225
-
- See merge request libtiff/libtiff!374
-
-2022-08-09 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'Writing_IFD8_to_ClassicTIFF_bugfix' into 'master'
- Correcting defects reported by Coverity Scan for MR !369
-
- See merge request libtiff/libtiff!375
-
-2022-08-09 Su Laus <sulau@freenet.de>
-
- Correcting defects reported by Coverity Scan for MR !369.
-
-2022-08-09 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_442_Writing_IFD8_to_ClassicTIFF' into 'master'
- TIFFSetValue(): Writing IFD8 & LONG8 tags to ClassicTIFF corrected (fixes #442)
-
- Closes #442
-
- See merge request libtiff/libtiff!369
-
-2022-08-09 Su Laus <sulau@freenet.de>
-
- TIFFSetValue(): Writing IFD8 & LONG8 tags to ClassicTIFF corrected (fixes #442)
-
-2022-08-09 Even Rouault <even.rouault@spatialys.com>
-
- Deal with RichTIFFIPTC tag written with LONG type (fixes #225)
-
-2022-08-07 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'manpage-functions-added' into 'master'
- doc: Missing public functions added to TIFF documentation in Sphinx
-
- See merge request libtiff/libtiff!372
-
-2022-08-07 Su Laus <sulau@freenet.de>
-
- doc: Missing public functions added to TIFF documentation in Sphinx.
-
-2022-07-29 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tifjpeg_version_check' into 'master'
- tif_jpeg.c: allow to pass -DEXPECTED_JPEG_LIB_VERSION=number to do optional...
-
- See merge request libtiff/libtiff!373
-
-2022-07-29 Even Rouault <even.rouault@spatialys.com>
-
- tif_jpeg.c: allow to pass -DEXPECTED_JPEG_LIB_VERSION=number to do optional compile-time version check
-
-2022-07-21 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'TIFFReadFromUserBuffer_fix' into 'master'
- TIFFReadFromUserBuffer(): fix clearing of TIFF_CODERSETUP flag that could...
-
- See merge request libtiff/libtiff!371
-
-2022-07-21 Even Rouault <even.rouault@spatialys.com>
-
- TIFFReadFromUserBuffer(): fix clearing of TIFF_CODERSETUP flag that could cause issues with reading JPEG compressed files
-
-2022-07-21 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'vs2022-fixes' into 'master'
- cmake: Correct duplicate definition of _CRT_SECURE_NO_WARNINGS
-
- Closes #443
-
- See merge request libtiff/libtiff!370
-
-2022-07-13 Roger Leigh <rleigh@codelibre.net>
-
- cmake: Correct duplicate definition of _CRT_SECURE_NO_WARNINGS.
-
-2022-07-13 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'vs2022-fixes' into 'master'
- cmake: Fixes for Visual Studio 2022
-
- See merge request libtiff/libtiff!368
-
-2022-07-13 Roger Leigh <rleigh@codelibre.net>
-
- cmake: Fixes for Visual Studio 2022.
-
-2022-07-03 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'elf-symbol-export' into 'master'
- Explicit export of versioned ELF symbols
-
- Closes #437
-
- See merge request libtiff/libtiff!361
-
-2022-07-03 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_433' into 'master'
- _TIFFCheckFieldIsValidForCodec(): return FALSE when passed a codec-specific...
-
- Closes #433
-
- See merge request libtiff/libtiff!363
-
-2022-07-01 Su_Laus <sulau@freenet.de>
-
- CLIPPATH tags defined twice but differently and also wrongly.
- In tif_dirinfo.c the tags for clippath are wrongly defined and the tag TIFFTAG_XCLIPPATHUNITS is even different twice. Therefore, those tags cannot be written / read correctly and may even lead to buffer overflow.
- E.g.: In the case of TIFFSetField(YCLIPPATHUNITS), a 1 byte storage space is allocated because of TIFF_SETGET_UNDEFINED, in which an int32_t value should be stored because of TIFF_SLONG type definition. Then, an int32_t value is read from that 1 byte storage location.
-
- The current definition is:
-
- { TIFFTAG_CLIPPATH, -1, -3, TIFF_BYTE, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "ClipPath", NULL },
- { TIFFTAG_XCLIPPATHUNITS, 1, 1, TIFF_SLONG, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "XClipPathUnits", NULL },
- { TIFFTAG_XCLIPPATHUNITS, 1, 1, TIFF_SBYTE, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "XClipPathUnits", NULL },
- { TIFFTAG_YCLIPPATHUNITS, 1, 1, TIFF_SLONG, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "YClipPathUnits", NULL },
-
- Whereas the correct definition according to TIFF Specification Supplement 1 (https://www.awaresystems.be/imaging/tiff/specification/TIFFPM6.pdf) should be:
-
- { TIFFTAG_CLIPPATH, -3, -3, TIFF_BYTE, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "ClipPath", NULL },
- { TIFFTAG_XCLIPPATHUNITS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "XClipPathUnits", NULL },
- { TIFFTAG_YCLIPPATHUNITS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "YClipPathUnits", NULL },
-
- Also the set_get_field of the following tag should be corrected from
-
- { TIFFTAG_INTEROPERABILITYIFD, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "InteroperabilityIFDOffset", NULL },
- to
- { TIFFTAG_INTEROPERABILITYIFD, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_IFD8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "InteroperabilityIFDOffset", NULL },
-
- However, if those tags should not be handled by LibTiff because they are deemed as abandoned or unwanted tags, those tags need to be defined with FIELD_IGNORE instead of FIELD_CUSTOM and keeping set_field_type = TIFF_SETGET_UNDEFINED
-
-2022-07-01 Su_Laus <sulau@freenet.de>
-
- In tif_dirinfo.c the definition for TIFFTAG_COMPRESSION has different settings of field_readcount=TIFF_VARIABLE (-1) and field_writecount=1. The tag is defined with Count=1, thus field_readcount is wrong and should also be 1. Although TIFFTAG_BITSPERSAMPLE is defined with Count:N=SamplesPerPixel, only ONE uint16_t value is passed with TIFFSetField() and TIFFGetField(). However, an array with N=SamplesPerPixel equal values is written into the TIFF file. Shouldn't field_readcount = field_writecount = 1 then? The behaviour of TiffLib does not change, because the handling is coded directly.
-
-2022-06-27 Even Rouault <even.rouault@spatialys.com>
-
- _TIFFCheckFieldIsValidForCodec(): return FALSE when passed a codec-specific tag and the codec is not configured (fixes #433)
- This avoids crashes when querying such tags
-
-2022-06-27 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch '16bit_cielab' into 'master'
- add basic 16bit-cielab support
-
- See merge request libtiff/libtiff!336
-
-2022-06-27 Caolán McNamara <caolan@skynet.ie>
-
- Add basic 16bit-cielab support.
- just a copy of putcontig8bitCIELab that reads 16bit vals but divide l by
- 257, a and b by 256 before passing to TIFFCIELabToXYZ
-
- motivation: https://bugs.documentfoundation.org/show_bug.cgi?id=131199
- the "clavijo16bitlab.tiff" example where tiffinfo says:
- ```
- Image Width: 2601 Image Length: 3503
- Resolution: 96, 96 pixels/inch
- Bits/Sample: 16
- Compression Scheme: AdobeDeflate
- Photometric Interpretation: CIE L*a*b*
- Orientation: row 0 top, col 0 lhs
- Samples/Pixel: 3
- Rows/Strip: 1
- Planar Configuration: single image plane
- DateTime: 2020:03:07 10:20:42
- ```
-
-2022-06-24 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'manpage-fixes' into 'master'
- Sphinx documentation fixes
-
- See merge request libtiff/libtiff!362
-
-2022-06-24 Roger Leigh <rleigh@codelibre.net>
-
- doc: Correct types and cross-references.
-
- doc: Correct manual page path.
-
- build: Make rational2double static only for automake.
- This copies the same logic as used by CMake.
-
- build: Update autoconf version to 4.5.0 and soname to 6.0.0.
-
- build: Update autoconf ld-version-script default.
-
- libtiff: Correct version script for changes since v4.4.0.
-
- libtiff: Update version script documentation.
-
- libtiff: Add symbol versioning of all exported symbols.
-
-2022-06-24 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'webp_mem_improvements' into 'master'
- WEBP codec: avoid temporary buffer and memcpy() on whole tile/strip decoding
-
- See merge request libtiff/libtiff!360
-
-2022-06-24 Roger Leigh <rleigh@codelibre.net>
-
- build: Enable symbol versioning by default.
-
-2022-06-24 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'sphinx-manpages' into 'master'
- doc: Add Sphinx conversion of all manpages
-
- Closes #361
-
- See merge request libtiff/libtiff!356
-
-2022-06-24 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'remove-wince' into 'master'
- Remove obsolete WinCE source file
-
- See merge request libtiff/libtiff!357
-
-2022-06-23 Even Rouault <even.rouault@spatialys.com>
-
- WEBP codec: avoid temporary buffer and memcpy() on whole tile/strip decoding
-
-2022-06-22 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'horAcc8_fix' into 'master'
- tif_predict.c: make horAcc8() work with icc (ICC) 2021.6.0 20220226 -O2
-
- See merge request libtiff/libtiff!359
-
-2022-06-22 Even Rouault <even.rouault@spatialys.com>
-
- tif_predict.c: make horAcc8() work with icc (ICC) 2021.6.0 20220226 -O2.
- For a reason I don't understand, recent ICC generates wrong code in -O2
- mode for the stride = 3 and 4 cases. The modified code is more
- straightforward, so go for it.
-
-2022-06-19 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'ci-restore-old' into 'master'
- ci: Restore testing with Ubuntu 20.04
-
- See merge request libtiff/libtiff!358
-
-2022-06-19 Roger Leigh <rleigh@codelibre.net>
-
- ci: Restore testing with Ubuntu 20.04.
-
- Remove obsolete WinCE source file.
-
- doc: Add missing punctuation.
-
- doc: Remove semicolon from c:function definition.
-
- doc: Remove remaining HTML entities.
-
- doc: Improve the build page.
-
-2022-06-18 Roger Leigh <rleigh@codelibre.net>
-
- doc: Add Sphinx conversion of all manpages.
-
-2022-06-18 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'dist-html' into 'master'
- build: Distribute and install HTML documentation
-
- See merge request libtiff/libtiff!352
-
-2022-06-13 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'pkgconfig' into 'master'
- Adding Requires.private generation
-
- See merge request libtiff/libtiff!355
-
-2022-06-13 Yishen Miao <mys721tx@gmail.com>
-
- Adding Requires.private generation.
- Adds Requires.private generation so that pkg-config can correctly find
- the dependencies of libtiff.
-
-2022-06-11 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'ci-dist' into 'master'
- ci: Archive distribution tar and zip files
-
- See merge request libtiff/libtiff!354
-
-2022-06-11 Roger Leigh <rleigh@codelibre.net>
-
- ci: Archive distribution tar and zip files.
-
-2022-06-11 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'export_TIFFClampDoubleToUInt32' into 'master'
- libtiff.def: export _TIFFClampDoubleToUInt32
-
- See merge request libtiff/libtiff!353
-
-2022-06-11 Even Rouault <even.rouault@spatialys.com>
-
- libtiff.def: export _TIFFClampDoubleToUInt32.
-
-2022-06-11 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue-415+427+428' into 'master'
- fix the FPE in tiffcrop (#415, #427, and #428)
-
- Closes #428, #427 et #415
-
- See merge request libtiff/libtiff!346
-
-2022-06-11 4ugustus <wangdw.augustus@qq.com>
-
- fix the FPE in tiffcrop (#415, #427, and #428)
-
-2022-06-11 Roger Leigh <rleigh@codelibre.net>
-
- build: Distribute and install HTML documentation.
-
-2022-06-10 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tif_jpeg_warning_fix' into 'master'
- tif_jpeg.c: fix error message
-
- See merge request libtiff/libtiff!351
-
-2022-06-10 Even Rouault <even.rouault@spatialys.com>
-
- tif_jpeg.c: fix error message.
-
-2022-06-10 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'android_libm' into 'master'
- Fix dependency on libm on Android
-
- See merge request libtiff/libtiff!350
-
-2022-06-09 Matthias Kuhn <matthias@opengis.ch>
-
- Always link to libm if available.
-
-2022-06-05 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'vasyl5-master-patch-97651' into 'master'
- libtoolize: command not found on macOS.
-
- See merge request libtiff/libtiff!289
-
-2022-06-05 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'rst-docs' into 'master'
- Convert HTML documentation to Sphinx RST
-
- See merge request libtiff/libtiff!349
-
-2022-06-05 Roger Leigh <rleigh@codelibre.net>
-
- Merge remote-tracking branch 'origin/master' into rst-docs.
-
-2022-06-05 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'cmake-xc-faxtable' into 'master'
- cmake: Do not build faxtable target when cross-compiling
-
- See merge request libtiff/libtiff!342
-
-2022-06-05 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'cmake-disable-options' into 'master'
- Add options for disabling tools, tests, contrib and docs
-
- See merge request libtiff/libtiff!343
-
-2022-06-05 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'cmake-msvc-options' into 'master'
- cmake: Add MSVC options when building all libraries and executables
-
- See merge request libtiff/libtiff!344
-
-2022-06-05 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'cmake-win32-libtiffxx-static' into 'master'
- cmake: libtiffxx is static on win32
-
- See merge request libtiff/libtiff!338
-
-2022-06-05 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'licence-file' into 'master'
- Rename COPYRIGHT to LICENSE.md
-
- See merge request libtiff/libtiff!345
-
-2022-06-05 Roger Leigh <rleigh@codelibre.net>
-
- Rename COPYRIGHT to LICENSE.md.
-
- doc: Fix make distcheck.
-
- doc: Update automake configuration.
-
- doc: Do not pass srcdir and builddir to sphinx-build.
-
- doc: Additional top-level tidying.
-
- doc: Tidy top-level index.
-
- doc: Move bugs to project.
-
- doc: Move misc to project.
-
- doc: Move all BigTIFF documentation into specification directory.
- * Remove the BigTIFF proposal since this has long been completed
- * Update the BigTIFF PR to note completion of the work and replace
- present with past tense.
-
- doc: Split release history.
- This permits the newer releases to be included in the top-level
- toctree without polluting it with dozens of old releases.
-
- doc: Correct accents.
-
- doc: BigTIFF design markup improvements.
-
- Add doc/_static.
-
- doc: Move TIFF specification and design notes into subdirectory.
-
- doc: Move releases into subdirectory.
-
- doc: Mark up TIFF tech note 2.
-
- doc: Use sphinxdox theme.
- The sphix_rtd_theme formats complex tables badly.
-
- doc: Clean up HTML tags.
-
-2022-06-04 Roger Leigh <rleigh@codelibre.net>
-
- ci: Install Sphinx manual for use by GitLab pages.
-
- doc: Use sphinx_rtd_theme.
-
- Convert HTML documentation to Sphinx RST.
- * Add CMake build logic
- * Add Autotools build logic
- * Move from html/ to doc/
- * Manual pages are still generated HTML for the time being
-
- git: Ignore common IDE build files.
-
-2022-06-04 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'ci-ubuntu-22.04' into 'master'
- ci: Update to use Ubuntu 22.04 CI images
-
- Closes #429
-
- See merge request libtiff/libtiff!348
-
-2022-06-04 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'opengl-option' into 'master'
- cmake: Add tiff-opengl option
-
- See merge request libtiff/libtiff!340
-
-2022-06-04 Roger Leigh <rleigh@codelibre.net>
-
- tiffdump: Avoid overflow warning when reading.
-
- ci: Update to use Ubuntu 22.04 CI images.
-
-2022-06-04 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'master' into 'master'
- Include stdlib.h in tif_lzw.c.
-
- See merge request libtiff/libtiff!347
-
-2022-06-04 Brian Ledger <brian.peter.ledger@gmail.com>
-
- Merge branch 'master' of https://gitlab.com/libtiff/libtiff.
-
-2022-06-04 Brian Ledger <brian.peter.ledger@gmail.com>
-
- Include stdlib.h in tif_lzw.c.
- In `tif_lzw.c`, a call is made to `_byteswap_uint64`. This is declared in `stdlib.h`. `stdlib.h` is not included in `tib_lzw.c`, so a name error may occur.
-
- This change adds `#include stdlib.h` to `tif_lzw.c`, to prevent a name error from occurring when `stdlib.h` is not included.
-
-2022-05-29 Roger Leigh <rleigh@codelibre.net>
-
- Add options for disabling tools, tests, contrib and docs.
-
- cmake: Add MSVC options when building all libraries and executables.
-
- cmake: Do not build faxtable target when cross-compiling.
-
- cmake: Use add_compile_definitions and add_compile_options.
- It seems that some CMake versions can't export targets using PRIVATE
- linking, even though the private target is never used.
-
- Merge remote-tracking branch 'origin/master' into cmake-msvc-options.
-
- Merge remote-tracking branch 'origin/master' into cmake-win32-libtiffxx-static
-
-2022-05-29 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'ci-x64' into 'master'
- ci: Remove arm64 temporarily
-
- See merge request libtiff/libtiff!341
-
-2022-05-29 Roger Leigh <rleigh@codelibre.net>
-
- ci: Remove arm64 temporarily.
-
- autoconf: Add --disable-opengl option.
-
- cmake: Add tiff-opengl option.
-
- cmake: Add MSVC options when building all libraries and executables.
-
- cmake: libtiffxx is static on win32.
-
-2022-05-22 Even Rouault <even.rouault@spatialys.com>
-
- html/Makefile.am: add v4.4.0.html to docfiles.
-
-2022-05-20 Even Rouault <even.rouault@spatialys.com>
-
- Update HOWTO-RELEASE with .tar.xz.
-
- Prepare for release 4.4.0.
-
-2022-05-16 Even Rouault <even.rouault@spatialys.com>
-
- libtiff v4.4.0 released
-
-2022-05-16 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'pkgconf_abs_path' into 'master'
- Handle absolute paths in pkg-config file
-
- See merge request libtiff/libtiff!333
-
-2022-05-16 MiloÅ¡ KomarÄević <miloskomarcevic@aim.com>
-
- Handle absolute paths in pkg-config file.
-
-2022-05-15 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix-tests-with-ro-source-dir' into 'master'
- cmake: allow running the tests with a read-only source directory
-
- See merge request libtiff/libtiff!332
-
-2022-05-15 Alex Richardson <alexrichardson@google.com>
-
- cmake: allow running the tests with a read-only source directory.
- Prior to this commit CTest would invoke all simple_tests tests with the
- current working directory set to the source directory. However, some of
- the tests (e.g. rewrite) will output files to the current working
- directory and will therefore fail when run with a read-only source
- directory. This can happen e.g. when testing a cross-compiled version of
- libtiff where the sources are mounted read-only in the virtual machine.
-
- Simply changing the working directory to CMAKE_CURRENT_BINARY_DIR allows
- all but raw_decode to pass. The raw_decode test looks for files in the
- source directory, and uses the `srcdir` environment variable to find, so
- we also have to add a set_tests_properties() call to specify that env var.
-
-2022-05-14 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiffcrop_pipeline_error' into 'master'
- tiffcrop: Fixes complain of pipeline "cmake-ninja-arm64" about abs() on...
-
- See merge request libtiff/libtiff!331
-
-2022-05-14 Su Laus <sulau@freenet.de>
-
- tiffcrop: Fixes complain of pipeline "cmake-ninja-arm64" about abs() on...
-
-2022-05-14 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'TIFFField_SetGetSize_CountSize' into 'master'
- Public functions TIFFFieldSetGetSize() and TIFFieldSetGetCountSize() added.
-
- See merge request libtiff/libtiff!284
-
-2022-05-14 Su Laus <sulau@freenet.de>
-
- Public functions TIFFFieldSetGetSize() and TIFFieldSetGetCountSize() added.
-
-2022-05-13 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'jondo-master-patch-87274' into 'master'
- Replace add_compile_definitions for CMake versions before 3.12 (#238)
-
- See merge request libtiff/libtiff!330
-
-2022-05-13 Robert Pollak <robert.pollak@posteo.net>
-
- Replace add_compile_definitions for CMake versions before 3.12 (#238)
-
-2022-05-13 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'master' into 'master'
- Remove incorrect assert.
-
- See merge request libtiff/libtiff!329
-
-2022-05-13 Ben Laurie <benl@google.com>
-
- Remove incorrect assert.
-
-2022-05-10 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'Fix_Issue#330' into 'master'
- tiffcrop: Fix issue #330 and some more from 320 to 349
-
- Closes #330
-
- See merge request libtiff/libtiff!298
-
-2022-05-10 Su Laus <sulau@freenet.de>
-
- tiffcrop: Fix issue #330 and some more from 320 to 349.
-
-2022-05-10 Even Rouault <even.rouault@spatialys.com>
-
- test_signed_tags.c: fix CID 1504376.
-
-2022-05-10 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_#29_tiffcp_orientationTag' into 'master'
- tiffcp: Fix incomprehensible setting of orientation tag (fixes #29)
-
- Closes #29
-
- See merge request libtiff/libtiff!327
-
-2022-05-10 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'palette-8bit' into 'master'
- tiff2pdf: handle 8-bit palette colormap
-
- See merge request libtiff/libtiff!328
-
-2022-05-09 Jay Berkenbilt <ejb@ql.org>
-
- tiff2pdf: handle 8-bit palette colormap.
- If all the colors in a palette are in the range [0, 255], treat the
- palette as an 8-bit colormap. This workaround already exists elsewhere
- in the software including in tiff2ps.
-
-2022-05-08 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_#40_ReadSignedTags' into 'master'
- Reading of signed tags added (fixes #40)
-
- Closes #40
-
- See merge request libtiff/libtiff!326
-
-2022-05-08 Su Laus <sulau@freenet.de>
-
- Reading of signed tags added (fixes #40)
-
-2022-05-08 Even Rouault <even.rouault@spatialys.com>
-
- Fix typos in comments.
-
-2022-05-08 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_400' into 'master'
- tiffcp: avoid buffer overflow in "mode" string (fixes #400)
-
- Closes #400
-
- See merge request libtiff/libtiff!323
-
-2022-05-08 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'CheckForBigTiff' into 'master'
- TIFFIsBigTiff() function added.
-
- See merge request libtiff/libtiff!325
-
-2022-05-08 Su Laus <sulau@freenet.de>
-
- TIFFIsBigTiff() function added.
-
-2022-05-01 Su_Laus <sulau@freenet.de>
-
- tiffcp: Fix incomprehensible setting of orientation tag (fixes #29)
-
-2022-04-23 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_#8_FreeAnonTag' into 'master'
- extra flag for anonymous (unknown) tags (fixes #8)
-
- Closes #400 et #8
-
- See merge request libtiff/libtiff!324
-
-2022-04-22 Even Rouault <even.rouault@spatialys.com>
-
- tif_lzw.c: fix potential out-of-bounds error when trying to read in the same tile/strip after an error has occurred (fixes #410)
-
-2022-04-06 Su_Laus <sulau@freenet.de>
-
- extra flag for anonymous (unknown) tags (fixes #8)
-
-2022-04-02 Su_Laus <sulau@freenet.de>
-
- tiffcp: avoid buffer overflow in "mode" string (fixes #400)
-
-2022-03-21 Even Rouault <even.rouault@spatialys.com>
-
- avoid hang in TIFFRewriteDirectory() if a classic file > 4 GB is attempted to be created
- Fixes https://github.com/OSGeo/gdal/issues/5479
-
-2022-03-19 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'Correct_tag_auto-registration_description' into 'master'
- Correct reading description for anonymous tag auto-registration in addingtags.html (closes 353)
-
- Closes #353
-
- See merge request libtiff/libtiff!320
-
-2022-03-19 Su Laus <sulau@freenet.de>
-
- Correct reading description for anonymous tag auto-registration in addingtags.html (closes 353)
-
-2022-03-18 Even Rouault <even.rouault@spatialys.com>
-
- tif_lzw.c: avoid harmless unsigned-integer-overflow (https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=45741)
-
-2022-03-17 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_396' into 'master'
- tiffcp: do not try to fetch compressor-specific tags when not appropriate (fixes #396)
-
- Closes #396
-
- See merge request libtiff/libtiff!316
-
-2022-03-17 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'Fix_cmake_warnings' into 'master'
- Fix some CMake warnings
-
- See merge request libtiff/libtiff!319
-
-2022-03-17 Su Laus <sulau@freenet.de>
-
- Fix some CMake warnings.
-
-2022-03-17 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'lzw_decode_improvements' into 'master'
- LZWDecode(): major speed improvements
-
- See merge request libtiff/libtiff!318
-
-2022-03-16 Even Rouault <even.rouault@spatialys.com>
-
- LZWDecode(): major speed improvements.
- This mostly comes from dealing specifically with codes that expand to
- 2, 3 and 4 bytes or more to avoid branches, and dealing with longer
- repeated sequences (e.g. lots of bytes to 0).
-
- With the following bench.c, execution time is 32% faster on a 8000x8000
- 4 bands uint16 predictor=2 image that has a 1.6x compression ratio. with
- gcc 9.4.0, on x86_64
-
- bench.c:
- ```
- #include "tiffio.h"
- #include <stdlib.h>
- #include <stdint.h>
-
- int main(int argc, char* argv[])
- {
- if( argc != 2 )
- {
- fprintf(stderr, "Usage: ./bench my.tif\n");
- exit(1);
- }
- TIFF* tif = TIFFOpen(argv[1], "r");
- if( tif == NULL )
- {
- fprintf(stderr, "Cannot open %s\n", argv[1]);
- exit(1);
- }
- if( !TIFFIsTiled(tif) )
- {
- fprintf(stderr, "Only tiled image supported\n");
- exit(1);
- }
- int tilesize = (int)TIFFTileSize(tif);
- char* c = malloc(tilesize);
- if( c == NULL )
- {
- fprintf(stderr, "Out of memory\n");
- exit(1);
- }
- const uint32_t numtiles = TIFFNumberOfTiles(tif);
- //int numloops = 4 * (int)(1e9 / ((double)tilesize * numtiles));
- //printf("Number of loops: %d\n", numloops);
- int numloops = 1;
- for(int i =0; i< numloops; i++)
- {
- for(uint32_t tileindex = 0; tileindex < numtiles; tileindex++ )
- {
- TIFFReadEncodedTile(tif, tileindex, c, tilesize);
- }
- }
- free(c);
- TIFFClose(tif);
- return 0;
- }
- ```
-
-2022-03-16 Even Rouault <even.rouault@spatialys.com>
-
- LZWDecode(): modest speed improvement: fetch input data by chunks of the largest natural integer of the architecture
-
-2022-03-14 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'kmilos-master-patch-45885' into 'master'
- Correct fix for the pkgconf file relative paths
-
- See merge request libtiff/libtiff!317
-
-2022-03-10 Even Rouault <even.rouault@spatialys.com>
-
- tif_lzw.c: make LZW_CHECKEOS non-optional.
-
- tiffsplit.c: fix compiler warning on 32-bit.
-
-2022-03-10 MiloÅ¡ KomarÄević <miloskomarcevic@aim.com>
-
- Correct fix for the pkgconf file relative paths.
-
-2022-03-10 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue-278' into 'master'
- fix heap buffer overflow in tiffcp (#278)
-
- Closes #278
-
- See merge request libtiff/libtiff!311
-
-2022-03-10 4ugustus <wangdw.augustus@qq.com>
-
- fix heap buffer overflow in tiffcp (#278)
-
-2022-03-09 Even Rouault <even.rouault@spatialys.com>
-
- tiffcp: do not try to fetch compressor-specific tags when not appropriate (fixes #396)
-
-2022-03-09 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'i_am_a_unsympathetic_person' into 'master'
- index.html: make it clear that I'm a unsympathetic person
-
- See merge request libtiff/libtiff!315
-
-2022-03-09 Even Rouault <even.rouault@spatialys.com>
-
- index.html: make it clear that I'm a unsympathetic person.
-
-2022-03-08 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'Fix_Issue#395' into 'master'
- tiffcrop: fix issue #395: generation of strange section images.
-
- Closes #395
-
- See merge request libtiff/libtiff!312
-
-2022-03-08 Su Laus <sulau@freenet.de>
-
- tiffcrop: fix issue #395: generation of strange section images.
-
-2022-03-08 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'Fix_Issue#380' into 'master'
- tiffcrop: fix issue #380 and #382 heap buffer overflow in extractImageSection
-
- Closes #382 et #380
-
- See merge request libtiff/libtiff!307
-
-2022-03-08 Su Laus <sulau@freenet.de>
-
- tiffcrop: fix issue #380 and #382 heap buffer overflow in extractImageSection
-
-2022-03-08 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue-392' into 'master'
- add checks for return value of limitMalloc (#392)
-
- Closes #392
-
- See merge request libtiff/libtiff!314
-
-2022-03-08 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue-393' into 'master'
- fix the FPE in tiffcrop (#393)
-
- Closes #393
-
- See merge request libtiff/libtiff!310
-
-2022-03-08 4ugustus <wangdw.augustus@qq.com>
-
- fix the FPE in tiffcrop (#393)
-
-2022-03-08 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'kmilos-master-patch-56785' into 'master'
- Fix pkgconf file relative paths
-
- Closes #394
-
- See merge request libtiff/libtiff!309
-
-2022-03-07 Augustus <wangdw.augustus@qq.com>
-
- add checks for return value of limitMalloc (#392)
-
-2022-03-02 MiloÅ¡ KomarÄević <miloskomarcevic@aim.com>
-
- Fix pkgconf file relative paths.
-
-2022-02-25 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_385' into 'master'
- tif_jbig.c: fix crash when reading a file with multiple IFD in memory-mapped...
-
- Closes #385
-
- See merge request libtiff/libtiff!306
-
-2022-02-24 Even Rouault <even.rouault@spatialys.com>
-
- tif_jbig.c: fix crash when reading a file with multiple IFD in memory-mapped mode and when bit reversal is needed (fixes #385)
-
-2022-02-24 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'string_size_limit' into 'master'
- _TIFFVSetField(): when passing a string without explicit length, check that...
-
- See merge request libtiff/libtiff!304
-
-2022-02-24 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'TIFFClientOpen_cleanup' into 'master'
- TIFFClientOpen(): remove useless initializations of tif_rawcc and tif_flags...
-
- See merge request libtiff/libtiff!303
-
-2022-02-20 Even Rouault <even.rouault@spatialys.com>
-
- Remove extra word in comment.
-
- TIFFPrintDirectory(): avoid potential multi-threading issue when reading the DotRange tag
- The severity of the issue would be low (mix of values displayed) and the
- time window where that would occur would be short.
-
- Constify signature of _TIFFsetXXXXArray() functions, and remove unused _TIFFsetString()
-
- _TIFFVSetField(): when passing a string without explicit length, check that the length doesn't except the 1 << 31 maximum bytes we support
-
-2022-02-19 Even Rouault <even.rouault@spatialys.com>
-
- tiffsplit.c: fix use after free introduced in master per commit 8ed97f401552a2b4300d3c489b03dcada86a21fd (related to #290)
-
-2022-02-19 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'Fix_Issue#284' into 'master'
- tiff2ps: In limitMalloc() check for negative size (fixes #284)
-
- Closes #284
-
- See merge request libtiff/libtiff!300
-
-2022-02-19 Su Laus <sulau@freenet.de>
-
- tiff2ps: In limitMalloc() check for negative size (fixes #284)
-
-2022-02-19 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_288' into 'master'
- tiffinfo: limit more memory allocations using -M switch (fixes #288)
-
- Closes #288
-
- See merge request libtiff/libtiff!299
-
-2022-02-19 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'Fix_Issue#290' into 'master'
- tiffsplit: limitMalloc() and getopt() introduced and more error messages. (fixes #290)
-
- Closes #290
-
- See merge request libtiff/libtiff!301
-
-2022-02-19 Su Laus <sulau@freenet.de>
-
- tiffsplit: limitMalloc() and getopt() introduced and more error messages. (fixes #290)
-
-2022-02-19 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'Fix_Issue#273_#275' into 'master'
- tiffcrop: buffsize check formula in loadImage() amended (fixes #273,#275)
-
- Closes #275 et #273
-
- See merge request libtiff/libtiff!302
-
-2022-02-19 Su Laus <sulau@freenet.de>
-
- tiffcrop: buffsize check formula in loadImage() amended (fixes #273,#275)
-
-2022-02-19 Even Rouault <even.rouault@spatialys.com>
-
- TIFFClientOpen(): remove useless initializations of tif_rawcc and tif_flags after TIFFReadDirectory()
- Those initializations date back to the initial commit of libtiff, but I
- strongly suspect there are no longer needed those days.
- Setting tif_rawcc to (tmsize_t)-1 is weird. AFAICS, nowhere else in the library
- -1 is used as a special markeri for that field. Immediately after TIFFReadDirectory()
- returns it is set to 0, and this is the value used in tif_read.c/tif_write.c to
- reset it.
- And setting the TIFF_BUFFERSETUP bit of tif_flags is even more
- suspicious as the only place where it is set otherwise is in
- TIFFWriteBufferSetup(). I suspect this bogus setting of the flag was the
- reason for commit dbf2339a1 where BUFFERCHECK() in addition to checking
- the bit also checked the tif_rawdata against nullptr.
-
- If setting those 2 fields was needed, it would mean that TIFFClientOpen() with the
- 'h' hint to disable automatic TIFFReadDirectory() would be broken,
- because someone issuing a manual TIFFReadDirectory() couldn't set them,
- as being private members.
-
- The libtiff test suite is happy with that change, and the GDAL one too.
-
-2022-02-19 Even Rouault <even.rouault@spatialys.com>
-
- TIFFFetchNormalTag(): speed optimization when reading a (very large) nul-terminated ASCII tag
-
- TIFFWriteDirectoryTagData(): turn assertion on data length into a runtime check
- For example, the assertion could actually be triggered when writing an
- ASCII tag with more than 1 << 31 bytes.
-
-2022-02-17 Even Rouault <even.rouault@spatialys.com>
-
- TIFFFetchNormalTag(): avoid calling memcpy() with a null source pointer and size of zero (fixes #383)
-
-2022-02-15 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'tl/fix-cpack' into 'master'
- Fix packaging with CPack
-
- See merge request libtiff/libtiff!292
-
-2022-02-11 Even Rouault <even.rouault@spatialys.com>
-
- tiffinfo: limit more memory allocations using -M switch (fixes #288)
-
- tif_dirwrite.c: take into account COMPRESSION_JXL.
-
-2022-02-11 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'predictor_2_64bit' into 'master'
- Predictor 2 (horizontal differentiation): support 64-bit
-
- See merge request libtiff/libtiff!296
-
-2022-02-10 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'Fix_Issue#365' into 'master'
- tiff2pdf: Fixes issues #365, #258 and #257 related to initializing 't2p->pdf_compressionquality'.
-
- Closes #257, #258 et #365
-
- See merge request libtiff/libtiff!297
-
-2022-02-10 Su Laus <sulau@freenet.de>
-
- tiff2pdf: Fixes issues #365, #258 and #257 related to initializing 't2p->pdf_compressionquality'.
-
-2022-02-09 Even Rouault <even.rouault@spatialys.com>
-
- Predictor 2 (horizontal differentiation): support 64-bit.
- There's no reason not to support 64-bit. The TIFF 6 specification
- doesn't say anything about that (and even mention 4-bit, which we don't
- support)
-
-2022-02-09 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'Fix_Issue#352' into 'master'
- tiffcrop.c: Fix issue #352 heap-buffer-overflow by correcting uint32_t underflow.
-
- Closes #352
-
- See merge request libtiff/libtiff!294
-
-2022-02-09 Su Laus <sulau@freenet.de>
-
- tiffcrop.c: Fix issue #352 heap-buffer-overflow by correcting uint32_t underflow.
-
-2022-02-08 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'custom_dir_EXIF_Coverity_fixes' into 'master'
- Fix Coverity Scan report issues for custom_dir_EXIF_231.c and test_directory.c
-
- See merge request libtiff/libtiff!295
-
-2022-02-08 Su Laus <sulau@freenet.de>
-
- Fix Coverity Scan report issues for custom_dir_EXIF_231.c and test_directory.c
-
-2022-02-06 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'cmake-test' into 'master'
- Correct CMake testing
-
- Closes #317
-
- See merge request libtiff/libtiff!291
-
-2022-02-06 Even Rouault <even.rouault@spatialys.com>
-
- LogLuvEncode32(): avoid undefined behaviour of left shift on a signed integer
-
- TIFFFetchStripThing(): avoid calling memcpy() with a null source pointer and size of zero (fixes #362)
-
-2022-02-05 Even Rouault <even.rouault@spatialys.com>
-
- TIFFReadDirectory(): avoid calling memcpy() with a null source pointer and size of zero (fixes #362)
-
-2022-01-29 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'Jamaika1-master-patch-68264' into 'master'
- Added stdlib.h
-
- See merge request libtiff/libtiff!293
-
-2022-01-29 Jamaika <lukaszcz18@wp.pl>
-
- tif_win32.c: include stdlib.h.
-
-2022-01-28 Timothy Lyanguzov <timothy.lyanguzov@sap.com>
-
- Fix packaging with CPack.
- Replace all CMAKE_INSTALL_FULL_<DIR> with CMAKE_INSTALL_<DIR> to allow CPack setting CMAKE_INSTALL_PREFIX
-
-2022-01-25 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'master' into 'master'
- Fix the global-buffer-overflow in tiffset
-
- See merge request libtiff/libtiff!287
-
-2022-01-25 4ugustus <wangdw.augustus@qq.com>
-
- tiffset: fix global-buffer-overflow for ASCII tags where count is required (fixes #355)
-
-2022-01-23 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'autogen' into 'master'
- Fix autogen.sh permissions issues during mv
-
- See merge request libtiff/libtiff!290
-
-2022-01-23 Roger Leigh <rleigh@codelibre.net>
-
- Correct CMake testing.
- * Use functions rather than macros to avoid problems with variables in
- conditions (since macro arguments are not variables)
- * Conditionally add to file lists and test program lists based upon the
- configuration options (e.g. JPEG and old-JPEG availability)
- * Sync tests, files and option usage with current automake usage
-
-2022-01-19 Will Cohen <willcohen@users.noreply.github.com>
-
- autogen.sh: mv -f for config.sub and config.guess.
-
-2022-01-12 Even Rouault <even.rouault@spatialys.com>
-
- TIFFYCbCrToRGBInit(): avoid Integer-overflow in gdal_TIFFYCbCrToRGBInit. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=43559
-
-2022-01-10 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_TIFFFillStrip_wrong_check' into 'master'
- Fix sanity check in TIFFFillStrip()/TIFFFillStrile()
-
- See merge request libtiff/libtiff!288
-
-2022-01-10 Even Rouault <even.rouault@spatialys.com>
-
- TIFFFillStrip()/TIFFFillStrile(): remove useless test.
-
- Fix sanity check in TIFFFillStrip()/TIFFFillStrile()
- A sanity check comparing the compressed vs uncompressed file that was
- originally written 'correctly' but relied on undefined behaviour was
- changed in 1b5e3b6a23827c33acf19ad50ce5ce78f12b3773 in an incorrect way.
- Fix that. Credits to @burn for spotting this in
- https://gitlab.com/libtiff/libtiff/-/issues/343#note_806089714
-
-2021-12-29 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'Fix_FieldName_NULL' into 'master'
- Fix Issue #354 Segmentation Fault due to field_name=NULL
-
- See merge request libtiff/libtiff!285
-
-2021-12-29 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'mingw-static' into 'master'
- build: Fix static library imports in mingw
-
- See merge request libtiff/libtiff!286
-
-2021-12-29 Biswapriyo Nath <nathbappai@gmail.com>
-
- build: Fix static library imports in mingw.
- This defines LERC_STATIC while creating libtiff static library
- in Win32 platform in presence of lerc library. Otherwise, the
- static library import lerc APIs with dllimport attribute and
- thus linked with shared lerc library.
-
-2021-12-28 Su_Laus <sulau@freenet.de>
-
- Fix Issue #354 Segmentation Fault due to field_name=NULL.
-
-2021-12-17 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_342' into 'master'
- TIFFGetField(TIFFTAG_STRIPBYTECOUNTS/TIFFTAG_STRIPOFFSETS): return error if...
-
- Closes #342
-
- See merge request libtiff/libtiff!283
-
-2021-12-16 Even Rouault <even.rouault@spatialys.com>
-
- TIFFGetField(TIFFTAG_STRIPBYTECOUNTS/TIFFTAG_STRIPOFFSETS): return error if returned pointer is NULL (fixes #342)
-
- tiff2pdf: validate TIFFGetField(input, TIFFTAG_STRIPBYTECOUNTS, &sbc) return (fixes #342)
-
-2021-12-16 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'master' into 'master'
- fix raw2tiff floating point exception(fixes #338)
-
- Closes #338
-
- See merge request libtiff/libtiff!282
-
-2021-12-16 t.feng <t.feng94@foxmail.com>
-
- raw2tiff: check that band number if not zero to avoid floating point exception(fixes #338)
-
-2021-12-14 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_337' into 'master'
- OJPEG: avoid assertion when using TIFFReadScanline() (fixes #337)
-
- Closes #337
-
- See merge request libtiff/libtiff!280
-
-2021-12-13 Even Rouault <even.rouault@spatialys.com>
-
- OJPEG: avoid assertion when using TIFFReadScanline() (fixes #337)
- Note: my analysis of the issue would be that the use of the scanline API
- is currently probably broken with OJPEG.
-
-2021-12-10 Even Rouault <even.rouault@spatialys.com>
-
- JPEG 12bit: make it easier for GDAL's RENAME_INTERNAL_LIBTIFF_SYMBOLS mode
-
-2021-12-09 Even Rouault <even.rouault@spatialys.com>
-
- tif_lzw.c: other warning fixes.
-
- tif_lzw.c: fix warnings of previous commit.
-
-2021-12-09 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'lzw_2gb_windows' into 'master'
- LZW codec: fix support for strips/tiles > 2 GB on Windows
-
- See merge request libtiff/libtiff!279
-
-2021-12-08 Even Rouault <even.rouault@spatialys.com>
-
- LZW codec: fix support for strips/tiles > 2 GB on Windows.
-
-2021-12-07 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_287' into 'master'
- tiffinfo: add a -M switch to define the maximum heap allocation, and default...
-
- Closes #287
-
- See merge request libtiff/libtiff!278
-
-2021-12-06 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_319' into 'master'
- TIFFReadDirectory: fix OJPEG hack (fixes #319)
-
- Closes #319
-
- See merge request libtiff/libtiff!277
-
-2021-12-06 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_309' into 'master'
- TIFFAppendToStrip(): fix rewrite-in-place logic (fixes #309)
-
- Closes #309
-
- See merge request libtiff/libtiff!276
-
-2021-12-05 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'b1' into 'master'
- Fix resource leak on error path
-
- See merge request libtiff/libtiff!263
-
-2021-12-05 bonniegong <yuanjungong96@gmail.com>
-
- rast2tiff: Fix resource leak on error path.
-
-2021-12-05 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiffsplit-leak' into 'master'
- tiffsplit.c: Fix memleak before exit
-
- See merge request libtiff/libtiff!270
-
-2021-12-05 Even Rouault <even.rouault@spatialys.com>
-
- tiffinfo: add a -M switch to define the maximum heap allocation, and default it to 256 MiB (fixes #287)
-
- tiffinfo: fix read of invalid pointer in TIFFReadRawDataTiled() (fixes #295)
-
-2021-12-05 Even Rouault <even.rouault@spatialys.com>
-
- TIFFReadDirectory: fix OJPEG hack (fixes #319)
- to avoid having the size of the strip arrays inconsistent with the
- number of strips returned by TIFFNumberOfStrips(), which may cause
- out-ouf-bounds array read afterwards.
-
- One of the OJPEG hack that alters SamplesPerPixel may influence the
- number of strips. Hence compute tif_dir.td_nstrips only afterwards.
-
-2021-12-04 Even Rouault <even.rouault@spatialys.com>
-
- TIFFAppendToStrip(): fix rewrite-in-place logic (fixes #309)
- Properly reset tif_curoff when writing strips/tiles
-
-2021-12-03 Even Rouault <even.rouault@spatialys.com>
-
- TIFFReInitJPEG_12(): avoid warning about unused variable in -DNDEBUG.
-
-2021-12-01 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_316' into 'master'
- TIFFReadCustomDirectory(): avoid crash when reading SubjectDistance tag on a non EXIF directory
-
- Closes #316
-
- See merge request libtiff/libtiff!273
-
-2021-12-01 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'VisualStudio_warnings_suppress' into 'master'
- Suppress unnecessary warnings in Visual Studio in AppVeyor test.
-
- See merge request libtiff/libtiff!234
-
-2021-11-30 Even Rouault <even.rouault@spatialys.com>
-
- TIFFReadCustomDirectory(): avoid crash when reading SubjectDistance tag on a non EXIF directory
- Fixes #316
-
- The Valgrind trace was
- ```
- TIFFReadCustomDirectory: Warning, Unknown field with tag 37382 (0x9206) encountered.
- ==3277355== Invalid read of size 1
- ==3277355== at 0x4842B60: memmove (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
- ==3277355== by 0x48BB799: _TIFFmemcpy (tif_unix.c:346)
- ==3277355== by 0x485B3CB: _TIFFVSetField (tif_dir.c:647)
- ==3277355== by 0x485C125: TIFFVSetField (tif_dir.c:890)
- ==3277355== by 0x485BEDC: TIFFSetField (tif_dir.c:834)
- ==3277355== by 0x486DA9A: TIFFFetchSubjectDistance (tif_dirread.c:5826)
- ==3277355== by 0x4869E35: TIFFReadCustomDirectory (tif_dirread.c:4530)
- ==3277355== by 0x4869F0A: TIFFReadGPSDirectory (tif_dirread.c:4564)
- ==3277355== by 0x10AA7A: main (tiffinfo.c:171)
- ==3277355== Address 0x3fc856aaaaaaaaab is not stack'd, malloc'd or (recently) free'd
- ==3277355==
- ```
-
-2021-11-29 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'add-null-check' into 'master'
- Added missing null check.
-
- See merge request libtiff/libtiff!274
-
-2021-11-28 Dirk Lemstra <dirk@lemstra.org>
-
- Added missing null check.
-
-2021-11-26 Even Rouault <even.rouault@spatialys.com>
-
- tif_print.c: remove duplicated if() in previous commit.
-
-2021-11-26 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'GPS_Print_BugFix' into 'master'
- Fix Segmentation fault printing GPS directory if Altitude tag is present (tif_print.c/tiffinfo.c)
-
- See merge request libtiff/libtiff!272
-
-2021-11-26 Su Laus <sulau@freenet.de>
-
- Fix Segmentation fault printing GPS directory if Altitude tag is present (tif_print.c/tiffinfo.c)
-
-2021-11-01 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'cmake_tiffconf' into 'master'
- Fix STRIPCHOP_DEFAULT value in CMake builds
-
- See merge request libtiff/libtiff!271
-
-2021-11-01 Even Rouault <even.rouault@spatialys.com>
-
- Fix STRIPCHOP_DEFAULT value in CMake builds.
- CMake builds erroneously used value 1 instead of TIFF_STRIPCHOP, which
- resulted in strip chopping not being enabled by default.
-
-2021-10-26 Even Rouault <even.rouault@spatialys.com>
-
- tif_jpeg.c: typo fix.
-
-2021-10-24 Han Han <hanhanzhiyeqianke@gmail.com>
-
- tiffsplit.c: Fix memleak before exit.
- Details of the memleak:
- $ valgrind --leak-check=full tiffsplit id:001763,sync:fuzzer07,src:001641,+cov
-
- ==2090657==
- ==2090657== HEAP SUMMARY:
- ==2090657== in use at exit: 13,517 bytes in 17 blocks
- ==2090657== total heap usage: 41 allocs, 24 frees, 29,351 bytes allocated
- ==2090657==
- ==2090657== 2,473 (1,249 direct, 1,224 indirect) bytes in 1 blocks are definitely lost in loss record 10 of 13
- ==2090657== at 0x484086F: malloc (vg_replace_malloc.c:381)
- ==2090657== by 0x48BF35C: TIFFClientOpen (tif_open.c:118)
- ==2090657== by 0x48CF058: TIFFFdOpen (tif_unix.c:209)
- ==2090657== by 0x48CF0C4: TIFFOpen (tif_unix.c:248)
- ==2090657== by 0x10954C: main (tiffsplit.c:91)
- ==2090657==
- ==2090657== 11,044 (1,300 direct, 9,744 indirect) bytes in 1 blocks are definitely lost in loss record 13 of 13
- ==2090657== at 0x484086F: malloc (vg_replace_malloc.c:381)
- ==2090657== by 0x48BF35C: TIFFClientOpen (tif_open.c:118)
- ==2090657== by 0x48CF058: TIFFFdOpen (tif_unix.c:209)
- ==2090657== by 0x48CF0C4: TIFFOpen (tif_unix.c:248)
- ==2090657== by 0x1093D9: main (tiffsplit.c:75)
- ==2090657==
- ==2090657== LEAK SUMMARY:
- ==2090657== definitely lost: 2,549 bytes in 2 blocks
- ==2090657== indirectly lost: 10,968 bytes in 15 blocks
- ==2090657== possibly lost: 0 bytes in 0 blocks
- ==2090657== still reachable: 0 bytes in 0 blocks
- ==2090657== suppressed: 0 bytes in 0 blocks
- ==2090657==
- ==2090657== For lists of detected and suppressed errors, rerun with: -s
- ==2090657== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
-
-2021-10-20 Even Rouault <even.rouault@spatialys.com>
-
- tif_webp.c: add explicit cast to please MSVC verbose warnings.
-
- tif_webp.c: white space fixing.
-
-2021-10-04 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'work/amyspark/psd-blobs' into 'master'
- Enable writing Photoshop blobs
-
- See merge request libtiff/libtiff!269
-
-2021-10-04 L. E. Segovia <amy@amyspark.me>
-
- Enable writing Photoshop blobs.
-
-2021-09-29 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'remove_packbits_hack' into 'master'
- PackBitsDecode: remove hack for when char is unsigned.
-
- See merge request libtiff/libtiff!267
-
-2021-09-28 Even Rouault <even.rouault@spatialys.com>
-
- PackBitsDecode: remove hack for when char is unsigned.
- The function has a hack for platforms where char is unsigned. This is
- better replaced by making bp a int8_t* pointer, which is guaranteed to
- be signed.
-
-2021-09-27 Even Rouault <even.rouault@spatialys.com>
-
- tiffcrop.c: remove useless 'set but not read' variables.
-
-2021-09-23 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_gdal_4538' into 'master'
- TIFFAppendToStrip(): fix rewrite-in-place logic
-
- See merge request libtiff/libtiff!266
-
-2021-09-23 Even Rouault <even.rouault@spatialys.com>
-
- TIFFAppendToStrip(): fix rewrite-in-place logic.
- reproducible in particular with packbits compression.
-
- Fixes https://github.com/OSGeo/gdal/issues/4538
-
-2021-09-17 Even Rouault <even.rouault@spatialys.com>
-
- tif_lzw.c: silence compiler warning about set but not used variable with recent clang
-
-2021-09-07 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_cygwin' into 'master'
- Fix build warnings on cygwin about 'argument 1 of type 'float[3]' with...
-
- See merge request libtiff/libtiff!265
-
-2021-09-06 Even Rouault <even.rouault@spatialys.com>
-
- test/rational_precision2double.c: add missing curly braces to fix -Werror=misleading-indentation
-
-2021-09-05 Even Rouault <even.rouault@spatialys.com>
-
- Fix build warnings on cygwin about 'argument 1 of type 'float[3]' with mismatched bound [-Werror=array-parameter=]'
-
-2021-09-05 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'rewrite-fix' into 'master'
- Fix TIFFRewriteDirectory discarding directories after the rewritten one
-
- See merge request libtiff/libtiff!264
-
-2021-09-05 Facundo Tuesca <facu@tuesca.com>
-
- tif_dirwrite.c: Fix TIFFRewriteDirectory discarding directories.
- This fixes a bug caused by the `tif_lastdiroff` optimization when
- rewriting directories.
-
- Rewriting the Nth directory temporarily zeroes the pointer to it
- (located in the N-1th directory) and relies on `TIFFLinkDirectory`
- traversing the whole directory list to find the zeroed pointer and
- linking the rewritten directory to it. Since `TIFFLinkDirectory` skips
- the traversal when `tif_lastdiroff` is set, this change unsets it
- to force the full traversal when rewriting a directory.
-
- A test to catch this particular issue is also added.
-
-2021-09-01 Even Rouault <even.rouault@spatialys.com>
-
- test_directory.c: fix compiler warnings.
-
-2021-09-01 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'multipage-optimization' into 'master'
- Keep track of last directory to improve performance for large multi-page files
-
- See merge request libtiff/libtiff!262
-
-2021-08-28 Facundo Tuesca <facu@tuesca.com>
-
- Add field to keep track of last written directory.
- This adds a new `tif_lastdiroff` field to the TIFF data structure
- and uses it to store the offset of the last written directory.
-
- Appending a new directory required traversing the whole file
- to find the last directory. By keeping track of its offset in this
- new field, the search is no longer necessary.
-
- Since this offset is only stored in-memory, the first directory
- append after opening a file will have to transverse the whole
- directory list. Subsequent calls will have access to the last
- offset, avoiding the transversal.
-
-2021-08-13 Even Rouault <even.rouault@spatialys.com>
-
- tif_jpeg.c: fix memory leak on error code path for JPEG 12 bit (CID 1086702)
-
-2021-07-29 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'jpeg12' into 'master'
- Enable JPEG 12bit support with a libjpeg that has a different ABI than the one for 8bit support
-
- See merge request libtiff/libtiff!261
-
-2021-07-28 Even Rouault <even.rouault@spatialys.com>
-
- Reformat tif_jpeg.c and tif_jpeg_12.c with clang-format-10.
-
-2021-07-27 Even Rouault <even.rouault@spatialys.com>
-
- Enable JPEG 12bit support with a libjpeg that has a different ABI than the one for 8bit support
- See https://github.com/OSGeo/gdal/pull/4139 for more details
-
- Note: this hasn't been tested for standalone libtiff builds.
-
-2021-07-09 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'wip/export-targets' into 'master'
- Export tiff targets
-
- See merge request libtiff/libtiff!258
-
-2021-07-09 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'pkgconfig' into 'master'
- Add version and requirements to pc file
-
- See merge request libtiff/libtiff!256
-
-2021-07-09 Kai Pastor <8989969-dg0yt@users.noreply.gitlab.com>
-
- Fix version in libtiff-4.pc.in, and CMake build: Add requirements to pc file
-
-2021-07-09 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'cmake' into 'master'
- Fix build issues with CMake 3.10
-
- See merge request libtiff/libtiff!260
-
-2021-07-04 Kai Pastor <dg0yt@darc.de>
-
- Fix reconfiguration with cmake.
-
- Fix build with CMake 3.10.
-
-2021-06-28 Milian Wolff <milian.wolff@kdab.com>
-
- Export tiff targets.
- Fixes build when including libtiff as a cmake subproject into
- another project and then installing a target from there which
- depends on tiff. For example we could end up with:
-
- ```
- CMake Error in 3rdParty/diplib/CMakeLists.txt:
- export called with target "DIP" which requires target "tiff" that is not in
- any export set.
- ```
-
-2021-06-21 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'libjpeg9d_support_simplification' into 'master'
- tif_jpeg.c: simplify libjpeg 9d support (refs #266)
-
- See merge request libtiff/libtiff!257
-
-2021-06-20 Even Rouault <even.rouault@spatialys.com>
-
- tif_jpeg.c: simplify libjpeg 9d support (refs #266)
- Credits to Guido Vollbeding for the suggestion
-
-2021-06-15 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'jpeg_in_tiff_jpeg_9d' into 'master'
- tif_jpeg.c: workaround bug of libjpeg 9d that defers Huffman table creation
-
- Closes #266
-
- See merge request libtiff/libtiff!255
-
-2021-06-15 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'jpeg_disable_progressive_with_mozjpeg' into 'master'
- tif_jpeg.c: do not emit progressive scans with mozjpeg and force optimize_coding
-
- See merge request libtiff/libtiff!254
-
-2021-06-12 Even Rouault <even.rouault@spatialys.com>
-
- tif_jpeg.c: with mozjpeg, disable emission of Huffman tables in JpegTables tag, and use optimize_coding
-
-2021-06-10 Even Rouault <even.rouault@spatialys.com>
-
- tif_jpeg.c: workaround bug of libjpeg 9d that defers Huffman table creation
- Fixes #266
-
- libjpeg-9d no longer creates default Huffman tables in
- jpeg_set_defaults(), which make their emission in the JpegTables tag no
- longer possible. Workaround that by borrowing code from libjpeg to
- manually create them when they are not initialized.
-
-2021-06-10 Even Rouault <even.rouault@spatialys.com>
-
- tif_jpeg.c: do not emit progressive scans with mozjpeg.
- Relates to #266
-
- - On writing, explicitly disable progressive scans, which is normally
- not enabled, except with mozjpeg.
- - On reading, emit a warning when encountering progressive scans.
-
-2021-06-10 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix-263' into 'master'
- Fix memory leak in tiff2pdf
-
- See merge request libtiff/libtiff!249
-
-2021-06-09 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'diizzyy-master-patch-20521' into 'master'
- html: Add missing pages when using CMake
-
- See merge request libtiff/libtiff!242
-
-2021-06-09 Daniel E <daniel.engberg.lists@pyret.net>
-
- html: Add missing pages when using CMake.
-
-2021-06-07 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'ci-reenable-cygwin' into 'master'
- ci: Re-enable cygwin builds
-
- See merge request libtiff/libtiff!252
-
-2021-06-06 Roger Leigh <rleigh@codelibre.net>
-
- ci: Re-enable cygwin builds.
-
-2021-06-06 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'ci-arm64' into 'master'
- ci: Add arm64 build
-
- See merge request libtiff/libtiff!251
-
-2021-06-06 Roger Leigh <rleigh@codelibre.net>
-
- ci: Add arm64 build.
-
-2021-06-05 Even Rouault <even.rouault@spatialys.com>
-
- _TIFFRewriteField(): fix when writing a IFD with a single tile that is a sparse one, on big endian hosts
-
-2021-06-02 Timothy Lyanguzov <timothy.lyanguzov@sap.com>
-
- Fix memory leak in tiff2pdf.
-
-2021-06-01 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'lzw_cleanup' into 'master'
- tif_lzw.c: cleanup, no functional change
-
- See merge request libtiff/libtiff!248
-
-2021-05-31 Even Rouault <even.rouault@spatialys.com>
-
- tif_lzw.c: cleanup, no functional change.
-
-2021-05-22 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'appveyor_disable_cygwin' into 'master'
- .appveyor.yml: disable cygwin configs for now as they are broken
-
- See merge request libtiff/libtiff!247
-
-2021-05-22 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'zstd_reuse_objects' into 'master'
- ZSTD codec: reuse compressor/decompressor objects
-
- See merge request libtiff/libtiff!246
-
-2021-05-22 Even Rouault <even.rouault@spatialys.com>
-
- .appveyor.yml: disable cygwin configs for now as they are broken.
-
- ZSTD codec: reuse compressor/decompressor objects.
- No need to recreate them each time in the PreEncode/Decode functions.
- They can be reused if already existing.
-
-2021-05-08 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'adobedeflate-fix' into 'master'
- Fix all remaining uses of legacy Deflate compression id and warn on use
-
- See merge request libtiff/libtiff!245
-
-2021-05-08 David Ryskalczyk <david.rysk@gmail.com>
-
- Fix all remaining uses of legacy Deflate compression id and warn on use.
-
-2021-05-06 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'improve_tiffinfo_tiffdump_for_gdal_tags' into 'master'
- tiffinfo/tiffdump: improve output for GDAL tags
-
- See merge request libtiff/libtiff!244
-
-2021-05-03 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue-252' into 'master'
- Prevent adding root directory to include list
-
- Closes #252 et #218
-
- See merge request libtiff/libtiff!243
-
-2021-05-03 Even Rouault <even.rouault@spatialys.com>
-
- tiffinfo/tiffdump: improve output for GDAL tags.
-
-2021-04-29 Timothy Lyanguzov <timothy.lyanguzov@sap.com>
-
- Prevent adding root directory to include list.
- there is a file VERSION in the root directory which clashes with C++20 standard header <version>
- "config.h" file is created in "config" subdirectory to prevent adding "-I.." to generated Makefile
-
- closes #218, #252
-
-2021-04-23 Laszlo Boszormenyi (GCS) <gcs@debian.org>
-
- fix TIFFReadRawStrip man and HTML page typo.
- From https://github.com/conda-forge/libtiff-feedstock/blob/master/recipe/patches/fix_TIFFReadRawStrip_man_page_typo.patch
-
-2021-04-20 Even Rouault <even.rouault@spatialys.com>
-
- HOWTO-RELEASE: update.
-
-2021-04-18 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'lerc_zstd_deflate' into 'master'
- Make LERC_SUPPORT conditional on ZLIB_SUPPORT. Make display of lerc options in tiffcp depend on actual zstd support.
-
- See merge request libtiff/libtiff!239
-
-2021-04-18 Miguel Medalha <medalist@sapo.pt>
-
- Make LERC_SUPPORT conditional on ZLIB_SUPPORT. Make display of lerc options in tiffcp depend on actual zstd support.
-
-2021-04-17 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'vtorri_xz' into 'master'
- automatic creation of xz archive when running make distcheck
-
- See merge request libtiff/libtiff!238
-
-2021-04-16 Even Rouault <even.rouault@spatialys.com>
-
- iptcutil.c: fix bug in EOF comparison, spotted on NetBSD 9 earmv7hf-el.
-
-2021-04-16 Even Rouault <even.rouault@spatialys.com>
-
- libtiff v4.3.0 released
-
-2021-04-15 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'libjpeg12_cmake' into 'master'
- libtiff/tif_config.h.cmake.in: surround LIBJPEG_12_PATH by double quotes
-
- See merge request libtiff/libtiff!237
-
-2021-04-15 Even Rouault <even.rouault@spatialys.com>
-
- libtiff/tif_config.h.cmake.in: surround LIBJPEG_12_PATH by double quotes
-
-2021-04-14 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'lerc_api_change' into 'master'
- tif_lerc.c: cope with API breakage in liblerc master
-
- See merge request libtiff/libtiff!236
-
-2021-04-14 Even Rouault <even.rouault@spatialys.com>
-
- tif_lerc.c: cope with API breakage in liblerc master.
-
-2021-04-08 Even Rouault <even.rouault@spatialys.com>
-
- libtiff: remove remaining #ifdef WIN32 and use PRI formatting.
-
-2021-03-10 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'kmilos-master-patch-73187' into 'master'
- tiffcp: Remove LZW help text, preset not supported
-
- See merge request libtiff/libtiff!229
-
-2021-03-10 MiloÅ¡ KomarÄević <miloskomarcevic@aim.com>
-
- tiffcp: Remove LZW help text, preset not supported.
-
-2021-03-10 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'feature/lerc' into 'master'
- Add LERC Compression Plugin (closes: #213)
-
- Closes #213
-
- See merge request libtiff/libtiff!228
-
-2021-03-10 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'cmake-fixes' into 'master'
- CMake fixes
-
- Closes #246 et #245
-
- See merge request libtiff/libtiff!232
-
-2021-03-09 Roger Leigh <rleigh@codelibre.net>
-
- cmake: Correct FindCMath.
-
- cmake: Correct ZSTD_USABLE typo.
-
-2021-03-07 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'cmake-find-lib-prefixes' into 'master'
- cmake: Correct find lib prefixes for Deflate and JBIG
-
- See merge request libtiff/libtiff!231
-
-2021-03-07 Roger Leigh <rleigh@codelibre.net>
-
- cmake: FindJBIG uses lib prefix on Windows.
-
- cmake: FindDeflate uses lib prefix on Windows.
-
-2021-03-07 Even Rouault <even.rouault@spatialys.com>
-
- TWebPDecode(): avoid potential overflow on multiplication (CID 1472928)
-
- TIFFReadDirEntryArrayWithLimit(): avoid false positive from Coverity Scan regarding out-of-bounds access (CID 1472927)
-
- tif_dirwrite.c: avoid setting a variable that is not read afterwards.
-
-2021-03-07 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'coverity-fixes' into 'master'
- Coverity fixes (high impact)
-
- See merge request libtiff/libtiff!227
-
-2021-03-07 Roger Leigh <rleigh@codelibre.net>
-
- Fix high-impact Coverity issues (resource leaks).
- The issues are in the tests and tiffcrop, not the core library. Real issues, but not high risk.
-
- Use to test if Coverity integration is performing properly on merge.
-
-2021-03-07 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_tif_fax3_encoder_regression' into 'master'
- tif_fax3.c: fix master regression in encoder
-
- See merge request libtiff/libtiff!230
-
-2021-03-07 Even Rouault <even.rouault@spatialys.com>
-
- tif_fax3.c: fix master regression in encoder.
- Fix issue introduced in 39a74eede0455ec8ee334dcddf71f5354d508d8b
-
- Spotted by gdal's tiff_write_76 test
-
-2021-03-07 Antonio Valentino <antonio.valentino@tiscali.it>
-
- Add LERC support in CMake.
-
-2021-03-07 Antonio Valentino <Antonio.Valentino@esa.int>
-
- Add LERC support in configure.ac and Makefile.am.
-
-2021-03-07 Antonio Valentino <antonio.valentino@tiscali.it>
-
- Add LERC support to tiffcp.
-
-2021-03-07 Antonio Valentino <Antonio.Valentino@esa.int>
-
- Add LERC plugin.
- The lerc plugin code has been copied from GDAL.
-
-2021-03-06 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'display_tool_purpose' into 'master'
- TIFF tools: insert a line of text summarizing each tool's purpose
-
- See merge request libtiff/libtiff!214
-
-2021-03-06 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'cmake-update' into 'master'
- CMake updates
-
- See merge request libtiff/libtiff!224
-
-2021-03-06 Even Rouault <even.rouault@spatialys.com>
-
- tiff.h: typo fix in comment.
-
-2021-02-15 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'remove-travis' into 'master'
- ci: Remove unused Travis-CI support
-
- See merge request libtiff/libtiff!226
-
-2021-02-14 Roger Leigh <rleigh@codelibre.net>
-
- ci: Remove unused Travis-CI support.
-
-2021-02-14 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'ci-coverity' into 'master'
- Enable Coverity static analysis with CI pipeline
-
- See merge request libtiff/libtiff!225
-
-2021-02-14 Roger Leigh <rleigh@codelibre.net>
-
- ci: Add Coverity static analysis job.
-
- ci: Use custom libtiff CI image.
-
-2021-02-13 Roger Leigh <rleigh@codelibre.net>
-
- cmake: Add release target.
-
- cmake: Remove empty contrib files.
-
- cmake: Tidy toplevel.
-
- cmake: Move pkg-config support to PkgConfig.cmake.
-
- cmake: Move library feature options to CXXLibraryFeatures.cmake.
-
- cmake: Move C++ support to CXXLibrary.cmake.
-
- cmake: Add FindCMath to handle libm linking portably.
-
- cmake: Tidy unused includes.
-
- cmake: Rename release date to build date.
-
- cmake: Compute timestamp portably.
-
- cmake: Remove remaining uses of report_values()
-
- cmake: Move JPEG12 checks to JPEGCodec.cmake.
-
- cmake: Move OpenGL checks to OpenGLChecks.cmake.
-
- cmake: Move OpenGL checks to OpenGLChecks.cmake.
-
- cmake: Move WebP codec support to WebPCodec.cmake.
-
- cmake: Use imported targets for WebP.
-
- cmake: Add FindWebP.
-
- cmake: Move ZSTD codec support to ZSTDCodec.cmake.
-
- cmake: Use imported targets for ZSTD.
-
- cmake: Add FindZSTD.
-
- cmake: Move LZMA codec support to LZMACodec.cmake.
-
- cmake: Use imported targets for LibLZMA.
-
- cmake: Move JBIG codec support to JBIGCodec.cmake.
-
- cmake: Use imported targets for JBIG.
-
- cmake: Add FindJBIG.
-
- cmake: Move PixarLog codec support to PixarLogCodec.cmake.
-
- cmake: Report system name in configuration report.
-
- cmake: Move JPEG codec support to JPEGCodec.cmake.
-
- cmake: Use imported targets for JPEG.
-
- cmake: Move Deflate codec support to DeflateCodec.cmake.
-
- cmake: Use imported targets for ZLIB and Deflate.
-
- cmake: Add FindDeflate.
-
- cmake: Move symbol checks to SymbolChecks.cmake.
-
- cmake: Move include checks to IncludeChecks.cmake.
-
- cmake: Move all autotools logic to separate files.
-
- cmake: Move internal codec options to InternalCodecs.cmake.
-
- cmake: Move LFS check to LargeFileSupport.cmake.
-
- cmake: Move Win32 IO feature to WindowsIOFeature.cmake.
-
- cmake: Move processor capability checks to ProcessorChecks.cmake.
-
- cmake: Move type size checks to TypeSizeChecks.cmake.
-
- cmake: Move linker checks to LinkerChecks.cmake.
-
- cmake: Move warning options to CompilerChecks.
-
- cmake: Move version introspection to AutotoolsVersion.cmake.
-
- cmake: Move compiler checks to CompilerChecks.cmake.
-
- cmake: Split into helper scripts.
-
-2021-02-08 Roger Leigh <rleigh@codelibre.net>
-
- cmake: Use target_sources.
-
- libport: Adjust header and library to only define and link if required.
- * Make libport an OBJECT library when in use, otherwise a dummy
- INTERFACE library
- * libport.h will work if getopt is present or not present. If
- present, will fall back to <unistd.h>, else will define
- symbols
- * Add generated libport_config.h to define HAVE_GETOPT and HAVE_UNISTD_H
- * dummy.c no longer needed with CMake
- * libtiff/libtiffxx no longer link with libport
-
- cmake: Remove unnecessary extra_dist usage.
- Only makes sense in the context of Automake. Was carried over
- for reference while porting, but is not needed.
-
- cmake: Update minimum version and policy version to 3.9.
-
-2021-02-08 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'remove-nmake' into 'master'
- Remove NMake build support
-
- See merge request libtiff/libtiff!223
-
-2021-02-08 Roger Leigh <rleigh@codelibre.net>
-
- Remove NMake build support.
- The functionality provided by the NMake build is now completely
- superseded by the CMake build.
-
-2021-02-08 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'warning-fixes' into 'master'
- Warning fixes
-
- See merge request libtiff/libtiff!222
-
-2021-02-07 Miguel Medalha <medalist@sapo.pt>
-
- Update tiffsplit.c.
-
- Reinsert summary line lost after conflicting merge.
-
- Merge branch 'master' into 'display_tool_purpose'
- # Conflicts:
- # tools/tiffsplit.c
-
-2021-02-06 Roger Leigh <rleigh@codelibre.net>
-
- ci: Enable fatal warnings with -Werror for AppVeyor/GCC.
-
- ci: Enable fatal warnings with -Werror for GitLab CI.
-
- tif_zstd.c: Remove unused variable warning.
-
- custom_dir_EXIF_231: Remove case statement fallthrough.
-
- custom_dir_EXIF_231: Correct use of strncpy.
-
- Correct include order.
-
- Eliminate implicit fallthrough usage.
- Use simple loops in place of manual loop unrolling. Rely on
- the compiler optimiser to unroll loops when appropriate.
-
- Suppress potential unused variable warning.
-
- Suppress warnings or avoid case statement fallthrough.
-
-2021-02-05 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'c99-ssize_t-fixes' into 'master'
- C99 ssize_t fixes
-
- Closes #239
-
- See merge request libtiff/libtiff!219
-
-2021-02-05 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiffsplit-too-many-args' into 'master'
- tiffsplit.c: exit with EXIT_FAILURE if there are extra args on the command line
-
- See merge request libtiff/libtiff!209
-
-2021-02-05 Roger Leigh <rleigh@codelibre.net>
-
- Add additional TIFF_SSIZE_FORMAT uses.
-
-2021-02-04 Roger Leigh <rleigh@codelibre.net>
-
- NMake fixes for size type formatting.
-
- Add TIFF_SIZE_FORMAT for portable use of %z.
- MinGW64 does support %z, but it issues a compiler warning.
-
- Align Autoconf tif_config.h and CMake tif_config.cmake.in.
-
- Use TIFF_SSIZE_FORMAT for formatting tmsize_t.
-
-2021-02-04 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'remove-lcc' into 'master'
- Remove Makefile.lcc
-
- See merge request libtiff/libtiff!221
-
-2021-02-04 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'remove-scons' into 'master'
- Remove SCons build
-
- See merge request libtiff/libtiff!220
-
-2021-02-03 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'c99-snprintf' into 'master'
- Use C99 snprintf
-
- See merge request libtiff/libtiff!217
-
-2021-02-03 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'tiff2ps-const' into 'master'
- tiff2ps.c: string literals must be const char *, not char *
-
- See merge request libtiff/libtiff!202
-
-2021-02-03 Roger Leigh <rleigh@codelibre.net>
-
- Remove SCons build.
- Unmaintained for 16 years.
-
-2021-02-03 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'codec_summary' into 'master'
- Modify 'CMakeLists.txt' to produce a meaningful summary of external codecs
-
- See merge request libtiff/libtiff!192
-
-2021-02-03 Roger Leigh <rleigh@codelibre.net>
-
- Remove Makefile.lcc.
- Unmaintained for 22 years.
-
-2021-02-02 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'ci-32-bit' into 'master'
- ci: Build 32- and 64-bit MSVC variants
-
- See merge request libtiff/libtiff!218
-
-2021-02-01 Roger Leigh <rleigh@codelibre.net>
-
- ci: Build 32- and 64-bit MSVC variants.
-
- Use C99 snprintf.
-
-2021-02-01 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'c99-strtol' into 'master'
- Use C99 strtol, strtoul, strtoll and strtoull
-
- See merge request libtiff/libtiff!216
-
-2021-01-31 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'c99-inline' into 'master'
- Use C99 inline
-
- See merge request libtiff/libtiff!215
-
-2021-01-31 Roger Leigh <rleigh@codelibre.net>
-
- Use C99 strtol, strtoul, strtoll and strtoull.
-
- tif_fax3: Use C99 inline.
-
- Remove inline feature tests and defines.
- Available as a standard feature with C99.
-
-2021-01-30 Miguel Medalha <medalist@sapo.pt>
-
- Update raw2tiff.c (remove duplicate description of tool)
-
-2021-01-30 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'c99-format-strings' into 'master'
- C99 format strings
-
- See merge request libtiff/libtiff!211
-
-2021-01-29 Miguel Medalha <medalist@sapo.pt>
-
- Update tiffdither.c (2 tabs caused slight misalignment of lines in usage info output)
-
-2021-01-28 Miguel Medalha <medalist@sapo.pt>
-
- Update ppm2tiff.c (slight misalignment of lines in usage info output)
-
- Update tiffset.c (small misalignment of lines in usage info output)
-
-2021-01-28 Medalha <medalist@sapo.pt>
-
- Display tool purpose.
-
-2021-01-28 Thomas Bernard <miniupnp@free.fr>
-
- tiff2ps.c: string literals must be const char *, not char *
-
-2021-01-28 Roger Leigh <rleigh@codelibre.net>
-
- libtiff: Use PRI format flags and remove unnecessary casts.
-
-2021-01-27 Roger Leigh <rleigh@codelibre.net>
-
- ascii_tag: Use PRI format flags and remove unnecessary casts.
-
- check_tag: Use PRI format flags and remove unnecessary casts.
-
- custom_dir_EXIF_231: Use PRI format flags and remove unnecessary casts.
-
- short_tag: Use PRI format flags and remove unnecessary casts.
-
- strip_rw: Use PRI format flags and remove unnecessary casts.
-
- fax2tiff: Use PRI format flags and remove unnecessary casts.
-
- ppm2tiff: Correct format strings.
-
- raw2tiff: Use PRI format flags and remove unnecessary casts.
-
- rgb2ycbcr: Use PRI format flags and remove unnecessary casts.
-
- tiff2pdf: Use PRI format flags and remove unnecessary casts.
-
- tiff2ps: Use PRI format flags and remove unnecessary casts.
-
- tiff2rgba: Use PRI format flags and remove unnecessary casts.
-
- tiffcmp: Use PRI format flags and remove unnecessary casts.
-
- tiffcp: Use PRI format flags and remove unnecessary casts.
-
- tiffcrop: Use PRI format flags and remove unnecessary casts.
-
- tiffinfo: Use PRI format flags and remove unnecessary casts.
-
- tiffdump: Use PRI format flags and remove unnecessary casts.
-
-2021-01-27 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'c99-require-stdtypes' into 'master'
- Use standard C99 integer types
-
- See merge request libtiff/libtiff!205
-
-2021-01-26 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'reserve_COMPRESSION_JXL' into 'master'
- tiff.h: reserve COMPRESSION_JXL=50002 for JPEGXL
-
- See merge request libtiff/libtiff!210
-
-2021-01-22 Even Rouault <even.rouault@spatialys.com>
-
- tiff.h: reserve COMPRESSION_JXL=50002 for JPEGXL.
-
-2021-01-22 Kurt Schwehr <schwehr@google.com>
-
- tiffsplit.c: exit with EXIT_FAILURE if there are extra args on the command line
- e.g. tiffsplit in.tif a_prefix_ junk
-
-2021-01-22 Roger Leigh <rleigh@codelibre.net>
-
- Add and enable TIFF_DISABLE_DEPRECATED for internal use.
-
- Add typedef deprecations for GCC/Clang and MSVC.
-
- Use standard C99 integer types.
-
-2021-01-20 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'ubuntu-zstd-wepb' into 'master'
- gitlab-ci : use libzstd-dev and libwebp-dev ubuntu packages
-
- See merge request libtiff/libtiff!208
-
-2021-01-20 Thomas Bernard <miniupnp@free.fr>
-
- gitlab-ci : use libzstd-dev and libwebp-dev ubuntu packages.
- should replace !206
-
-2021-01-20 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue-232' into 'master'
- tiff2ps: exit the loop in case of error
-
- Closes #232
-
- See merge request libtiff/libtiff!201
-
-2021-01-20 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiffsplit-exit-status' into 'master'
- tiffsplit: Exit with EXIT_FAILURE if unable to open the input file.
-
- See merge request libtiff/libtiff!207
-
-2021-01-20 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'config-cleanup' into 'master'
- Remove HAVE_INTTYPES_H, HAVE_LFIND & lfind, HAVE_SEARCH_H & include <search.h>
-
- See merge request libtiff/libtiff!203
-
-2021-01-19 Kurt Schwehr <schwehr@google.com>
-
- tiffsplit: Exit with EXIT_FAILURE if unable to open the input file.
-
-2021-01-18 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiffcmp' into 'master'
- tiffcmp: fix comparison with pixels that are fractional number of bytes
-
- Closes #53
-
- See merge request libtiff/libtiff!141
-
-2021-01-15 Kurt Schwehr <schwehr@google.com>
-
- CMakeLists.txt: Remove search for lfind.
-
- Remove HAVE_INTTYPES_H, HAVE_LFIND & lfind, HAVE_SEARCH_H & include <search.h>
- - HAVE_INTTYPES_H is replaced with TIFF_HAVE_INTTYPES_H
- - tif_dirinfo.c has a static td_lfind
-
-2021-01-15 Thomas Bernard <miniupnp@free.fr>
-
- tiffcmp: fix comparison with pixels that are fractional number of bytes
- For example : 4bits per sample + 3 samples per pixel => 1.5 bytes per pixel
-
- tiff2ps: exit the loop in case of error.
- fixes #232
-
-2021-01-15 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'rm-strcasecmp' into 'master'
- Remove port/strcasecmp.c as strcasecmp is not currently used in libtiff.
-
- Closes #235
-
- See merge request libtiff/libtiff!199
-
-2021-01-15 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'std-int-types' into 'master'
- Use standard C99 integer types
-
- See merge request libtiff/libtiff!185
-
-2021-01-13 Kurt Schwehr <schwehr@google.com>
-
- Remove port/strcasecmp.c as strcasecmp is not currently used in libtiff.
- Fixes #235
-
-2021-01-10 Miguel Medalha <medalist@sapo.pt>
-
- Update CMakeLists.txt. Delete unnecessary line from libdeflate codec support section
-
-2021-01-10 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'include_libport' into 'master'
- tiff tools and libtiff/mkg3states: include 'libport.h', remove local definition of 'getopt()'
-
- See merge request libtiff/libtiff!198
-
-2021-01-09 Miguel Medalha <medalist@sapo.pt>
-
- Update CMakeLists.txt. Cleanup of indentation space. Removal of leading '/' from webp include dir.
-
-2021-01-09 miguel <medalist@sapo.pt>
-
- cmake: Use target_include_directories correctly.
-
-2021-01-09 Roger Leigh <rleigh@codelibre.net>
-
- cmake: Use target_include_directories correctly.
-
- cmake: Drop unnecessary TOOL_INCLUDES.
-
-2021-01-07 Roger Leigh <rleigh@codelibre.net>
-
- cmake: Use target_include_directories correctly.
-
-2021-01-07 miguel <medalist@sapo.pt>
-
- tiff tools and libtiff/mkg3states: include 'libport.h', remove local definition of 'getopt()'
-
-2021-01-07 Miguel Medalha <medalist@sapo.pt>
-
- Update CMakeLists.txt.
-
-2021-01-07 miguel <medalist@sapo.pt>
-
- tiff tools: include 'libport.h', remove local definition of 'getopt()'
-
-2021-01-06 Roger Leigh <rleigh@codelibre.net>
-
- Remove conditional use of <string.h>
-
- cmake: Drop dlfcn.h check.
-
- cmake: Remove duplicate line.
-
- Use stdint.h types when available.
-
-2021-01-05 Olivier Paquet <olivier.paquet@gmail.com>
-
- Merge branch 'iptcutil' into 'master'
- contrib/iptcutil.c: set '#ifdef _WIN32' (was '#ifdef WIN32', which failed at build time)
-
- See merge request libtiff/libtiff!197
-
-2021-01-05 miguel <medalist@sapo.pt>
-
- tiff tools: include 'libport.h', remove local definition of 'getopt()'
-
- contrib/iptcutil.c - set '#ifdef _WIN32' (was '#ifdef WIN32', which failed at build time)
-
-2021-01-04 Even Rouault <even.rouault@spatialys.com>
-
- tools/CMakeLists.txt: add comment about rgb2ycbcr and thumbnail not to be installed
-
-2021-01-04 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'revert-5331ed49' into 'master'
- Revert "Merge branch 'install_targets' into 'master'"
-
- See merge request libtiff/libtiff!196
-
-2021-01-04 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'drop-wince' into 'master'
- Remove non-functional WinCE support
-
- See merge request libtiff/libtiff!188
-
-2021-01-04 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'drop-vms' into 'master'
- Remove non-functional VMS support
-
- See merge request libtiff/libtiff!187
-
-2021-01-03 Even Rouault <even.rouault@spatialys.com>
-
- Revert "Merge branch 'install_targets' into 'master'"
- This reverts merge request !193
-
-2021-01-03 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiffcp_b_parameter' into 'master'
- tiffcp: Remove unnecessary reference to compression from usage info for -b parameter
-
- See merge request libtiff/libtiff!189
-
-2021-01-03 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'cmake-faxtable' into 'master'
- cmake: Add faxtable target
-
- See merge request libtiff/libtiff!186
-
-2021-01-03 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'install_targets' into 'master'
- Update 'CMakeLists.txt' from 'tools'.
-
- See merge request libtiff/libtiff!193
-
-2021-01-03 Miguel Medalha <medalist@sapo.pt>
-
- Update 'CMakeLists.txt' from 'tools'.
-
- Update CMakeLists.txt.
-
-2021-01-03 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'usage_info' into 'master'
- thumbnail: Rename constant variable 'stuff' to 'usage_info'
-
- See merge request libtiff/libtiff!190
-
-2021-01-03 Miguel Medalha <medalist@sapo.pt>
-
- Modified 'CMakeLists.txt' to produce a meaningful summary of external codecs support.
-
- Removed unnecessary reference to compression from usage info for -b parameter
-
- Constant variable 'stuff' renamed to 'usage_info' for consistency with the other tools
-
-2021-01-02 Roger Leigh <rleigh@codelibre.net>
-
- Remove non-functional VMS support.
-
- Remove non-functional WinCE support.
-
-2021-01-02 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'codespell' into 'master'
- Fix spelling mistakes.
-
- See merge request libtiff/libtiff!183
-
-2021-01-02 Kurt Schwehr <schwehr@google.com>
-
- ChangeLog: Remove extraneous character from prior commit - 00fe7828.
-
-2021-01-02 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'codespell-custom_dir_EXIF_231' into 'master'
- custom_dir_EXIF_231.c: dos2unix and codespell
-
- See merge request libtiff/libtiff!184
-
-2021-01-01 Roger Leigh <rleigh@codelibre.net>
-
- mkg3states: Sync generator with current generated file content.
-
- cmake: Add faxtable and mkg3states targets.
-
-2020-12-31 Kurt Schwehr <schwehr@google.com>
-
- custom_dir_EXIF_231.c: dos2unix and codespell.
- additional, Variable, greater, always
-
-2020-12-31 Kurt Schwehr <schwehr@google.com>
-
- Fix spelling mistakes.
- Found with:
-
- codespell --version
- 1.17.1
-
-2020-12-29 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'remove-some-vms-ifdef' into 'master'
- Remove "ifdef VMS" that are no longer necessary.
-
- See merge request libtiff/libtiff!181
-
-2020-12-29 Kurt Schwehr <schwehr@google.com>
-
- Remove "ifdef VMS" that are no longer necessary.
- Both sides of the if are now the same.
-
-2020-12-29 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- _TIFFBuiltinCODECS should be const.
-
-2020-12-28 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue-202' into 'master'
- tiff2pdf.c: check that tiff_datasize fits in a signed tsize_t
-
- Closes #202
-
- See merge request libtiff/libtiff!166
-
-2020-12-28 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'w_report-when-libdeflate-is-found' into 'master'
- CMakeLists.txt: Report when libdeflate is found
-
- See merge request libtiff/libtiff!175
-
-2020-12-28 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- Declare gpsFields as static const.
-
-2020-12-28 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- Merge branch 'tools-reduce-initialized-data' into 'master'
- Reduce initialized data by making more data const and simplifying usage() implementation.
-
- See merge request libtiff/libtiff!180
-
-2020-12-28 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- Reduce initialized data by making more data const and simplifying usage() implementation.
-
-2020-12-27 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- Merge branch 'master' into 'master'
- tiff tools: display of compression methods is now conditional instead of hard-coded
-
- See merge request libtiff/libtiff!176
-
-2020-12-27 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- Merge branch 'build' into 'master'
- Fix wrong URL for fetching config.guess and config.sub
-
- See merge request libtiff/libtiff!177
-
-2020-12-26 Chocobo1 <Chocobo1@users.noreply.github.com>
-
- Fix wrong URL for fetching config.guess and config.sub.
-
-2020-12-25 miguel <medalist@sapo.pt>
-
- tiff tools: made display of compression methods and their parameters conditional on their actual availability
-
-2020-12-20 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- autogen.sh now updates config.guess and config.sub from master gnulib version.
-
-2020-12-19 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- Add a https://libtiff.gitlab.io/libtiff/ link.
-
- Remove stray character in URL area.
-
- Changes for 4.2.0 release.
-
- Changes for 4.2.0 release.
-
-2020-12-19 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff 4.2.0 released.
-
- * configure.ac: Pass tar-ustar option to AM_INIT_AUTOMAKE rather
- than tar-pax since ustar POSIX 1003.1-1988 format is more portable
- than PAX POSIX 1003.1-2001 format.
-
-2020-12-12 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'w_adjust-deflate_names' into 'master'
- Set 'deflate' to DEFLATE_NAMES, instead of 'libdeflate'
-
- See merge request libtiff/libtiff!174
-
-2020-12-12 Lemures Lemniscati <lemures.lemniscati@gmail.com>
-
- Set 'deflate' to DEFLATE_NAMES, instead of 'libdeflate'
- 'lib' will be automatically added as a prefix while doing find_library()
-
-2020-12-12 Even Rouault <even.rouault@spatialys.com>
-
- DoubleToRational(): avoid casting NaN to uint32 (fixes #227)
-
-2020-12-12 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_221' into 'master'
- tiffio.h: do not define __attribute__ but defines TIFF_ATTRIBUTE instead (fixes #221)
-
- Closes #221
-
- See merge request libtiff/libtiff!173
-
-2020-12-12 Even Rouault <even.rouault@spatialys.com>
-
- tiffio.h: do not define __attribute__ but defines TIFF_ATTRIBUTE instead (fixes #221)
-
-2020-12-08 Even Rouault <even.rouault@spatialys.com>
-
- TIFFReadDirEntryArrayWithLimit(): properly read from offline tag value when we clamp the number of strips to 1.
- Fixes regression of commit 7057734d986001b7fd6d2afde9667da7754ff2cc on reading
- a file with StripByteCounts with 1 element (broken) and StripOffsets with
- 896 elements, and where StripOffsets[0] is correct
-
- $ tiffdump foo.tif
- Magic: 0x4949 <little-endian> Version: 0x2a <ClassicTIFF>
- Directory 0: offset 25725448 (0x1888a08) next 0 (0)
- SubFileType (254) LONG (4) 1<0>
- ImageWidth (256) LONG (4) 1<640>
- ImageLength (257) LONG (4) 1<20098>
- BitsPerSample (258) SHORT (3) 1<16>
- Photometric (262) SHORT (3) 1<1>
- SamplesPerPixel (277) SHORT (3) 1<1>
- ResolutionUnit (296) SHORT (3) 1<2>
- StripByteCounts (279) LONG (4) 1<1806>
- StripOffsets (273) LONG (4) 896<8 648 1288 1928 2568 3208 3848 4488 5128 5768 6408 7048 7688 8328 8968 9608 10248 10888 11528 12168 12808 13448 14088 14728 ...>
-
-2020-12-02 Even Rouault <even.rouault@spatialys.com>
-
- tif_jpeg.c: avoid potential harmless unsigned integer overflow on data->fileoffset in JPEGFixupTagsSubsamplingSkip() by validating earlier. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28200
-
-2020-11-27 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'Jamaika1-master-patch-47839' into 'master'
- Change ULARGE_INTEGER to LARGE_INTEGER
-
- See merge request libtiff/libtiff!170
-
-2020-11-27 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'Jamaika1-master-patch-46397' into 'master'
- Added stdint.h
-
- See merge request libtiff/libtiff!171
-
-2020-11-27 Jamaika <lukaszcz18@wp.pl>
-
- Added stdint.h.
-
- ``` tif_win32.c: In function '_tiffSizeProc': tif_win32.c:159:23: warning: passing argument 2 of 'GetFileSizeEx' from incompatible pointer type [-Wincompatible-pointer-types] 159 | if (GetFileSizeEx(fd,&m)) | ^~ | | | ULARGE_INTEGER * In file included from c:\msys1021\x86_64-w64-mingw32\include\winbase.h:18, from c:\msys1021\x86_64-w64-mingw32\include\windows.h:70, from tif_win32.c:32: c:\msys1021\x86_64-w64-mingw32\include\fileapi.h:78:73: note: expected 'PLARGE_INTEGER' {aka 'LARGE_INTEGER *'} but argument is of type 'ULARGE_INTEGER *' 78 | WINBASEAPI WINBOOL WINAPI GetFileSizeEx (HANDLE hFile, PLARGE_INTEGER lpFileSize); | ~~~~~~~~~~~~~~~^~~~~~~~~~ ```
-
-2020-11-21 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue-113' into 'master'
- tiffcrop: fix buffer overrun in extractContigSamples24bits()
-
- Closes #113
-
- See merge request libtiff/libtiff!169
-
-2020-11-21 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue-156' into 'master'
- tiff2pdf: Check output size before writing
-
- Closes #156
-
- See merge request libtiff/libtiff!168
-
-2020-11-21 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue-201' into 'master'
- tiff2pdf: enforce memory limit for tiled pictures too
-
- Closes #201
-
- See merge request libtiff/libtiff!167
-
-2020-11-20 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue-207' into 'master'
- enforce (configurable) memory limit in tiff2rgba
-
- Closes #209 et #207
-
- See merge request libtiff/libtiff!165
-
-2020-11-20 Even Rouault <even.rouault@spatialys.com>
-
- tif_lzw.c: avoid false positive -Wnull-dereference of mingw32 gcc 7.3.
-
-2020-11-17 Thomas Bernard <miniupnp@free.fr>
-
- tiffcrop: fix buffer overrun in extractContigSamples24bits()
- fixes #113
-
- tiff2pdf: Check output size before writing.
- fixes #156
-
- tiff2pdf: enforce memory limit for tiled pictures too.
- fixes #201
-
-2020-11-15 Thomas Bernard <miniupnp@free.fr>
-
- tiff2rgba.1: -M option.
-
- enforce (configurable) memory limit in tiff2rgba.
- fixes #207
- fixes #209
-
-2020-11-14 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue-220' into 'master'
- tiff2pdf.c: properly calculate datasize when saving to JPEG YCbCr
-
- Closes #220
-
- See merge request libtiff/libtiff!159
-
-2020-11-14 Thomas Bernard <miniupnp@free.fr>
-
- tiff2pdf.c: properly calculate datasize when saving to JPEG YCbCr.
- fixes #220
-
-2020-11-14 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue-204' into 'master'
- avoid buffer overflow while writing jpeg end of file marker
-
- Closes #204
-
- See merge request libtiff/libtiff!161
-
-2020-11-14 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue-193' into 'master'
- fix buffer overflow in tiff2ps.c
-
- Closes #193
-
- See merge request libtiff/libtiff!162
-
-2020-11-14 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'skal65535-master-patch-91082' into 'master'
- More overflow fixes for large widths
-
- See merge request libtiff/libtiff!164
-
-2020-11-14 skal <pascal.massimino@gmail.com>
-
- More overflow fixes for large width.
- Also: use INT_MAX instead of hard-coded constants.
-
-2020-11-12 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'skal65535-master-patch-56655' into 'master'
- Fix potential overflow in gtStripContig()
-
- See merge request libtiff/libtiff!163
-
-2020-11-12 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue-211' into 'master'
- check for tile width overflow
-
- Closes #211
-
- See merge request libtiff/libtiff!160
-
-2020-11-12 skal <pascal.massimino@gmail.com>
-
- Fix potential overflow in gtStripContig()
- (w + w) might not fit in int32 if too large.
-
-2020-11-09 Thomas Bernard <miniupnp@free.fr>
-
- tiff2ps.c: fix buffer overread.
- fixes #193
-
- fix undefined behaviour (int shifted too much to the left)
-
- avoid buffer overflow while writing jpeg end of file marker.
- fixes #204
-
- gtTileContig(): check Tile width for overflow.
- fixes #211
-
- fix warning messages (v32 is unsigned)
-
-2020-10-26 Even Rouault <even.rouault@spatialys.com>
-
- TIFFStartStrip(): avoid potential crash in WebP codec when using scanline access on corrupted files. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=26650
-
-2020-10-20 Even Rouault <even.rouault@spatialys.com>
-
- tif_webp.c: validate tile/strip dimension to avoid unsigned integer overflow in RGBA.size computation
-
-2020-10-19 Even Rouault <even.rouault@spatialys.com>
-
- tif_zip.c: fix typo in comment.
-
-2020-10-16 Even Rouault <even.rouault@spatialys.com>
-
- tiff.h: remove irrelevant warning about webp related pseudo-tags not being registered: they are purely internal libtiff concepts
-
-2020-10-16 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'libdeflate' into 'master'
- Add support for building against libdeflate for faster Zip/Deflate compression/decompression
-
- See merge request libtiff/libtiff!158
-
-2020-10-16 Even Rouault <even.rouault@spatialys.com>
-
- test: add testdeflatelaststripextradata.sh.
-
-2020-10-16 Even Rouault <even.rouault@spatialys.com>
-
- Add support for optional building against libdeflate for faster Zip/Deflate compression/decompression.
- So we can have 2 kind of builds with the Zip/Deflate codec:
- - zlib only
- - zlib + libdeflate
-
- Speed improvements in the 35%-50% range can be expected when libdeflate is used.
- Compression level up to 12 is now supported (capped to 9 when zlib is used).
- Still requires zlib for situations where libdeflate cannot be used (that
- is for scanline access, since libdeflate has no streaming mode)
-
- Pseudo-tag TIFFTAG_DEFLATE_SUBCODEC=DEFLATE_SUBCODEC_ZLIB/DEFLATE_SUBCODEC_LIBDEFLATE
- is added to control which subcodec (zlib or libdeflate) should be used (it defaults
- of course to libdeflate, when it is available).
- This is mostly aimed at being used on the writing side, to be able to reproduce
- output of previous libtiff versions at a binary level, in situations where this would
- be really needed. Or as a safety belt in case there would be unforeseen issues
- with using libdeflate.
- It can be used to know when libdeflate is available at runtime (DEFLATE_SUBCODEC_LIBDEFLATE
- will be the default value in that situation).
-
- Of course, deflate codestreams produced by libdeflate can be read by zlib, and vice-versa.
-
-2020-10-14 Even Rouault <even.rouault@spatialys.com>
-
- tif_webp.c: fix compiler warnings with MSVC.
-
-2020-10-12 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'various_fixes' into 'master'
- Fix compiler warnings about unused variables when assert() expands to nothing
-
- See merge request libtiff/libtiff!157
-
-2020-10-12 Even Rouault <even.rouault@spatialys.com>
-
- .gitignore: add entries for new files in test/
-
- Fix compiler warnings about unused variables when assert() expands to nothing
-
-2020-10-09 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch '215-cygwin-appveyor-fail' into 'master'
- Update Appveyor CI build to build with VS2019 image
-
- Closes #215
-
- See merge request libtiff/libtiff!154
-
-2020-10-09 Roger Leigh <rleigh@codelibre.net>
-
- wip.
-
- wip.
-
- wip.
-
- wip.
-
- wip.
-
- wip.
-
-2020-10-09 Roger Leigh <rleigh@codelibre.net>
-
- Merge branch 'TIFF-217_m_lib_path' into 'master'
- cmake: Do not use absolute libm path
-
- Closes #217
-
- See merge request libtiff/libtiff!156
-
-2020-10-09 Roger Leigh <rleigh@codelibre.net>
-
- cmake: Do not use absolute libm path.
-
-2020-10-08 Even Rouault <even.rouault@spatialys.com>
-
- tif_fax3.h: restore systematic calls to CLEANUP_RUNS()
- now that SETVALUE() no longer cause overflows.
- Those were removed per b351db8be1b4d3f712bdb9424a79d3174cc03202 and
- 3440ac216463fcad170bbb391491e69730a59ffa.
-
- As SETVALUE() now returns an error, this allow the decoder to exit.
-
- Otherwise, the assert(x == lastx) in _TIFFFax3fillruns() can trigger.
-
- Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=26201
-
-2020-10-06 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'check_TIFFFlushData1' into 'master'
- FAX/JPEG/LZMA/PixarLog/ZIP/ZSTD codecs: make sure to check TIFFFlushData1() return value
-
- See merge request libtiff/libtiff!155
-
-2020-10-04 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'shared-memory' into 'master'
- Set the --shared-memory linker flag for Emscripten builds
-
- See merge request libtiff/libtiff!153
-
-2020-10-03 Even Rouault <even.rouault@spatialys.com>
-
- tiff2rgba.c: fix -Wold-style-declaration warning.
-
- FAX/JPEG/LZMA/PixarLog/ZIP/ZSTD codecs: make sure to check TIFFFlushData1() return value
-
-2020-09-26 Even Rouault <even.rouault@spatialys.com>
-
- tif_fax3.h: extra buffer overflow checks. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25934
-
-2020-09-25 Roger Leigh <rleigh@codelibre.net>
-
- wip.
-
- wip.
-
- wip.
-
- wip.
-
- wip.
-
- wip.
-
- Update AppVeyor image.
-
- test-appveyor.
-
-2020-09-24 Attila Oláh <atl@google.com>
-
- Also pass --shared-memory to raw_decode.
- This is needed when building for Emscripten with *both* WEBP and JPEG
- support.
-
- Set the --shared-memory linker flag for Emscripten builds.
- This is only needed when building with WEBP support, which uses atomics,
- therefore the linker needs the --shared-memory flag. The flag cannot be
- added globally because not all executables link against libwebp.
-
-2020-09-22 Even Rouault <even.rouault@spatialys.com>
-
- tif_fax3.h: return error when a buffer overflow occurs. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25552 and https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25849
-
-2020-09-11 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix-float-compare' into 'master'
- Fix comparison for max negative float value.
-
- See merge request libtiff/libtiff!152
-
-2020-09-11 Dirk Lemstra <dirk@lemstra.org>
-
- Fix comparison for max negative float value.
-
-2020-09-07 Even Rouault <even.rouault@spatialys.com>
-
- Fax3PreDecode(): reset curruns and refruns state variables.
- to avoid out-of-bounds write triggered by GDAL when repeatedly
- reading a corrupt strip.
-
- Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25493
-
-2020-06-06 Thomas Bernard <miniupnp@free.fr>
-
- Merge branch 'issue-17' into 'master'
- normalize tools behaviour regarding -h
-
- Closes #17
-
- See merge request libtiff/libtiff!115
-
-2020-05-31 Even Rouault <even.rouault@spatialys.com>
-
- TWebPSetupEncode(): fix logic problem (and instead of or) in test that checks input is 8bit unsigned data
-
-2020-05-12 Even Rouault <even.rouault@spatialys.com>
-
- TIFFGetConfiguredCODECs(): fix to avoid wrong structure to be returned for registered (ie non built-in) codecs
-
-2020-05-09 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'zstd-webp-update' into 'master'
- gitlab-ci: use latest zstd and webp versions
-
- See merge request libtiff/libtiff!148
-
-2020-05-09 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'deprecated' into 'master'
- ojpeg: s/Depreciated/Deprecated/
-
- See merge request libtiff/libtiff!149
-
-2020-05-09 Aaron Boxer <boxerab@gmail.com>
-
- ojpeg: s/Depreciated/Deprecated/
-
-2020-04-27 Even Rouault <even.rouault@spatialys.com>
-
- Fix typos.
-
- tif_jpeg.c: avoid potential division in previous fix (master only)
-
-2020-04-26 Thomas Bernard <miniupnp@free.fr>
-
- gitlab-ci: use latest zstd and webp versions.
-
-2020-04-26 Even Rouault <even.rouault@spatialys.com>
-
- tiff.h: fixes to use ASCII only characters (master only)
-
-2020-04-26 Thomas Bernard <miniupnp@free.fr>
-
- tiffsplit: use EXIT_SUCCESS / EXIT_FAILURE.
-
- tiffset: print usage on stdout when -h is used.
- also use EXIT_FAILURE / EXIT_SUCCESS
- see #17
-
- tiffmedian: shopw usage on stdout when -h is used.
- also use EXIT_SUCCESS/EXIT_FAILURE
- see #17
-
- tiffinfo: print usage on stdout when -h is used.
- also use EXIT_FAILURE / EXIT_SUCCESS
- see #17
-
- raw2tiff: print usage to stdout when -h is used.
- see #17
-
- tiff2pdf: print usage on stdout when -h is used.
- see #17
-
- tiffgt: output usage on stdout with -h.
- also use EXIT_SUCCESS / EXIT_FAILURE
-
- tiffdump: use EXIT_FAILURE / EXIT_SUCCESS.
- see #17
-
- tiffdither: print usage on stdout when -h is used.
- see #17
-
-2020-04-26 Thomas Bernard <miniupnp@free.fr>
-
- tiffcrop: -h / -v prints usage/version to stdout.
- also uses the standard C EXIT_SUCCESS / EXIT_FAILURE
- macros
-
- see #17
-
-2020-04-26 Thomas Bernard <miniupnp@free.fr>
-
- tiffcp: output usage to stdout when using -h.
- also use EXIT_FAILURE / EXIT_SUCCESS
- see #17
-
- tiffcmp: match exit status for posix cmp and diff tools.
-
- tiff2rgba: output usage to stdout when using -h.
- also uses std C EXIT_FAILURE / EXIT_SUCCESS
- see #17
-
- tiff2ps: sue EXIT_FAILURE / EXIT_SUCCESS.
- see #17
-
- tiff2bw: output usage on stdout when using -h.
- also uses EXIT_SUCCESS / EXIT_FAILURE
- see #17
-
- thumbnail: use EXIT_FAILURE / EXIT_SUCCESS.
- the -h option was already used so it cannot be used for help/usage
- see #17
-
- rgb2ycbcr: use EXIT_FAILURE / EXIT_SUCCESS.
- the -h option was already used so it cannot be used for help/usage
- see #17
-
- ppm2tiff: output usage to stdout when using -h option.
- also uses std C EXIT_SUCCESS / EXIT_FAILURE
- see #17
-
- pal2rgb: output usage to stdout when -h is used.
- see #17
-
- fax2tiff.c: print usage on stdout when using -h option.
- see #17
-
- fax2ps: output usage to stdout when using -h option.
- also use EXIT_SUCCESS, EXIT_FAILURE from C standard
-
-2020-04-25 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'jpeg_multiscan_dos_logic' into 'master'
- tif_jpeg.c: revise logic to detect potential excessive memory usage when...
-
- See merge request libtiff/libtiff!147
-
-2020-04-24 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue-176' into 'master'
- tiff2pdf: get rid of uninitialized memory content
-
- Closes #176
-
- See merge request libtiff/libtiff!143
-
-2020-04-24 Even Rouault <even.rouault@spatialys.com>
-
- tif_jpeg.c: revise logic to detect potential excessive memory usage when decoding multiscan JPEG compressed images
-
-2020-04-19 Thomas Bernard <miniupnp@free.fr>
-
- tiff2pdf: test the return code of TIFFReadRawStrip() and TIFFReadRawTile()
-
- tiff2pdf.c: fix some whitespace problems in source.
-
- tiff2pdf: get rid of uninitialized memory content.
- fixes #176
-
-2020-04-19 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue-18' into 'master'
- tiffset: pass size for TIFFTAG_INKNAMES
-
- Closes #18
-
- See merge request libtiff/libtiff!146
-
-2020-04-18 Olivier Paquet <olivier.paquet@gmail.com>
-
- Merge branch 'issue-80' into 'master'
- tiffinfo: fix dump of Tiled images
-
- Closes #80
-
- See merge request libtiff/libtiff!144
-
-2020-04-15 Even Rouault <even.rouault@spatialys.com>
-
- Fix wrong file size checks for memory-mapped BigTIFF files that could lead to image rejection
-
-2020-04-05 Thomas Bernard <miniupnp@free.fr>
-
- tiffset: pass size for TIFFTAG_INKNAMES.
- Uses TIFFFieldPassCount() to know which arguments need to be
- passed to TiffSetField()
-
- fixes #18
- see http://bugzilla.maptools.org/show_bug.cgi?id=2202
-
-2020-04-04 Thomas Bernard <miniupnp@free.fr>
-
- tiffinfo: showdata for tiled images.
-
- tiffinfo: fix dump of Tiled images.
- fixes #80
-
-2020-04-03 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue-117' into 'master'
- tiffcrop: enforce memory allocation limit
-
- Closes #117
-
- See merge request libtiff/libtiff!140
-
-2020-04-03 Thomas Bernard <miniupnp@free.fr>
-
- tiffcrop: enforce memory allocation limit.
- uses -k option to change limit (default to 256MiB)
- fixes #117 / http://bugzilla.maptools.org/show_bug.cgi?id=2757
-
-2020-04-02 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue-45' into 'master'
- tiffcp: disable strip chopping when trying to convert to JBIG compression
-
- Closes #45
-
- See merge request libtiff/libtiff!138
-
-2020-04-02 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue-124' into 'master'
- TIFFGetFields(3tiff): TIFFTAG_*BYTECOUNTS TIFFTAG_*OFFSETS are uint64
-
- Closes #124
-
- See merge request libtiff/libtiff!137
-
-2020-04-02 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'aix_itrunc' into 'master'
- Rename itrunc to fix name clash with a different itrunc in math.h on AIX. Fixes issue #189
-
- Closes #189
-
- See merge request libtiff/libtiff!139
-
-2020-04-01 Rob Boehne <robb@datalogics.com>
-
- Rename itrunc to fix name clash with a different itrunc in math.h on AIX. Fixes issue #189
-
-2020-04-01 Thomas Bernard <miniupnp@free.fr>
-
- tiffcp: disable strip chopping when trying to convert to JBIG compression
- fixes #45
-
-2020-03-29 Thomas Bernard <miniupnp@free.fr>
-
- TIFFGetFields(3tiff): TIFFTAG_*BYTECOUNTS TIFFTAG_*OFFSETS are uint64.
- fixes #124 / http://bugzilla.maptools.org/show_bug.cgi?id=2774
-
-2020-03-29 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue-48' into 'master'
- tiff2pdf: fix "raw" copy of Deflate streams
-
- Closes #48
-
- See merge request libtiff/libtiff!136
-
-2020-03-27 Thomas Bernard <miniupnp@free.fr>
-
- tiff2pdf: fix "raw" copy of Deflate streams.
- The Predictor parameter was not copied from the source tiff to the PDF.
- fixes #48 / http://bugzilla.maptools.org/show_bug.cgi?id=2442
-
-2020-03-26 Thomas Bernard <miniupnp@free.fr>
-
- tif_fax3: quit Fax3Decode2D() when a buffer overflow occurs.
- fixes #186
-
-2020-03-24 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue-143-144' into 'master'
- tiffdump: avoid unaligned memory access
-
- Closes #144 et #143
-
- See merge request libtiff/libtiff!133
-
-2020-03-24 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue-133' into 'master'
- tiff2pdf: avoid divide by 0
-
- Closes #133
-
- See merge request libtiff/libtiff!126
-
-2020-03-24 Thomas Bernard <miniupnp@free.fr>
-
- tiff2pdf: normalizePoint() macro to normalize the white point.
-
-2020-03-23 Thomas Bernard <miniupnp@free.fr>
-
- tiffdump: avoid unaligned memory access.
- fixes #143
- fixes #144
-
-2020-03-23 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'out-of-memory' into 'master'
- tiffcp/tiff2pdf/tiff2ps: enforce maximum malloc size
-
- Closes #153, #84, #116 et #115
-
- See merge request libtiff/libtiff!130
-
-2020-03-23 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue-157' into 'master'
- tiffset: check memory allocation
-
- Closes #157
-
- See merge request libtiff/libtiff!132
-
-2020-03-23 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue-185' into 'master'
- tif_fax3: more buffer overflow checks in Fax3Decode2D()
-
- Closes #185
-
- See merge request libtiff/libtiff!131
-
-2020-03-23 Thomas Bernard <miniupnp@free.fr>
-
- tiffset: check memory allocation.
- fixes #157 / http://bugzilla.maptools.org/show_bug.cgi?id=2850
-
- tif_fax3: more buffer overflow checks in Fax3Decode2D()
- fixes #185
-
-2020-03-21 Thomas Bernard <miniupnp@free.fr>
-
- tiff2ps: enforce memory allocation limit.
- fixes #153 / http://bugzilla.maptools.org/show_bug.cgi?id=2845
-
- tiff2pdf: enforce maximum data size.
- fixes #116 / http://bugzilla.maptools.org/show_bug.cgi?id=2756
- fixes #84 / http://bugzilla.maptools.org/show_bug.cgi?id=2683
-
- update man page for tiffcp regarding the -m option.
-
- tiffcp.c: _TIFFmalloc() => limitMalloc()
-
-2020-03-21 Thomas Bernard <miniupnp@free.fr>
-
- tiffcp: enforce maximum malloc size.
- default is 256MB. use -m option to change
-
- fixes #115 / http://bugzilla.maptools.org/show_bug.cgi?id=2755
-
-2020-03-21 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue-184' into 'master'
- CmakeLists.txt: define WORDS_BIGENDIAN when the CPU is big endian
-
- Closes #184
-
- See merge request libtiff/libtiff!127
-
-2020-03-21 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue-44' into 'master'
- tiff2pdf: "" causes the relevant argument not to be written
-
- Closes #44
-
- See merge request libtiff/libtiff!128
-
-2020-03-21 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue-56' into 'master'
- fix man for TIFFReadEncodedStrip(), TIFFStripSize, TIFFVStripSize, TIFFRawStripSize
-
- Closes #56
-
- See merge request libtiff/libtiff!129
-
-2020-03-20 Thomas Bernard <miniupnp@free.fr>
-
- fix man for TIFFReadEncodedStrip(), TIFFStripSize, TIFFVStripSize, TIFFRawStripSize
- fixes #56
- http://bugzilla.maptools.org/show_bug.cgi?id=2507
-
- tiff2pdf: "" causes the relevant argument not to be written.
- fixes #44
-
- CmakeLists.txt: define WORDS_BIGENDIAN when the CPU is big endian.
- fixes #184
-
-2020-03-17 Thomas Bernard <miniupnp@free.fr>
-
- tiff2pdf: avoid divide by 0.
- fixes #133 http://bugzilla.maptools.org/show_bug.cgi?id=2796
-
-2020-03-17 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue-22' into 'master'
- do not _tiffMapProc 0 size files
-
- Closes #22
-
- See merge request libtiff/libtiff!125
-
-2020-03-13 Thomas Bernard <miniupnp@free.fr>
-
- tif_win32.c: do not _tiffMapProc() 0 sized files.
- see #22
-
- tif_unix.c: do not _tiffMapProc 0 size files.
- fixes #22
- http://bugzilla.maptools.org/show_bug.cgi?id=2249
-
-2020-03-12 Even Rouault <even.rouault@spatialys.com>
-
- tif_fax3.c: fix warning C4018: '<': signed/unsigned mismatch introduced in past commits
-
-2020-03-11 Even Rouault <even.rouault@spatialys.com>
-
- tiff.h: mention TIFFTAG_RPCCOEFFICIENT, TIFFTAG_TIFF_RSID, TIFFTAG_GEO_METADATA
-
-2020-03-11 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue-60' into 'master'
- added support for more private tags
-
- Closes #60
-
- See merge request libtiff/libtiff!124
-
-2020-03-11 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue-160' into 'master'
- Fax3SetupState(): check consistency of rowbytes and rowpixels
-
- Closes #160
-
- See merge request libtiff/libtiff!123
-
-2020-03-11 Thomas Bernard <miniupnp@free.fr>
-
- added support for more private tags.
- see https://gitlab.com/libtiff/libtiff/-/issues/60
- bugzilla.maptools.org/show_bug.cgi?id=2525
-
- closes #60
-
- original author : art1@andreas-romeyke.de
-
-2020-03-11 Thomas Bernard <miniupnp@free.fr>
-
- Fax3SetupState(): check consistency of rowbytes and rowpixels.
- also add some parameter documentation to Fax3Decode1D()
-
- fixes #160
- http://bugzilla.maptools.org/show_bug.cgi?id=2854
-
-2020-03-10 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue-11-const-pointers' into 'master'
- Make pointers returned via TIFFGetField const
-
- Closes #11
-
- See merge request libtiff/libtiff!118
-
-2020-03-10 Even Rouault <even.rouault@spatialys.com>
-
- tif_ojpeg.c: relax again too strict sanity checks to allow reading of valid images such as https://gitlab.com/libtiff/libtiff/-/issues/181#note_302535232. Fixes #181
-
-2020-03-09 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue-52' into 'master'
- contrib/win_dib/tiff2dib: fix Uninitialized variable: lpBits
-
- Closes #52
-
- See merge request libtiff/libtiff!121
-
-2020-03-09 Thomas Bernard <miniupnp@free.fr>
-
- contrib/win_dib/tiff2dib: fix Uninitialized variable: lpBits.
- fixes #52
- http://bugzilla.maptools.org/show_bug.cgi?id=2469
-
-2020-03-08 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue-58' into 'master'
- Make TIFFTAG_CFAPATTERN variable count
-
- Closes #58
-
- See merge request libtiff/libtiff!120
-
-2020-03-08 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue-158-no-predictor-in-webp' into 'master'
- TIFFTAG_PREDICTOR is not supported for WebP
-
- Closes #158
-
- See merge request libtiff/libtiff!119
-
-2020-03-08 Sam Hasinoff <hasinoff@google.com>
-
- Make TIFFTAG_CFAPATTERN variable count.
- The TIFFTAG_CFAPATTERN tag (33422) from TIFF/EP, recently introduced in libtiff
- 3363eda09d082e3e1dfffa6281f53085cac51ad3 / http://bugzilla.maptools.org/show_bug.cgi?id=2457
- is described as having a fixed count of 4.
- But the TIFF/EP spec says this should support a variable count (= CFARepeatRows * CFARepeatCols):
-
- TIFF/EP, ISO 12234-2:2001
- http://www.barrypearson.co.uk/top2009/downloads/TAG2000-22_DIS12234-2.pdf
- page 18 and 26
-
-2020-03-08 Thomas Bernard <miniupnp@free.fr>
-
- TIFFTAG_PREDICTOR is not supported for WebP.
- fixes #158
- https://gitlab.com/libtiff/libtiff/-/issues/158
-
- this bug was introduced by 9eacd59fecc4ef593ac17689bc530ab451c8ec14
- merge request !32
-
-2020-03-07 Adam Goode <adam@spicenitz.org>
-
- Make the default whitepoint and ycbcrcoeffs arrays const.
- Now that we are returning const pointers in TIFFGetFieldDefaulted,
- we can now make these static default arrays const.
-
- see #11
-
-2020-03-07 Adam Goode <adam@spicenitz.org>
-
- Make pointers returned via TIFFGetField const.
- According to http://bugzilla.maptools.org/show_bug.cgi?id=2125#c6
- callers are not allowed to modify pointer or array values returned from
- TIFFGetField or the like. So, make this explicit in the documentation
- by specifying these things as const. Note that this is not an ABI
- change, since C does not encode const in libraries. Also, this is
- not really an API change, since the varargs call strips away all
- the types anyway. So it really is more of a documentation change.
-
- fixes #11
-
-2020-03-07 Even Rouault <even.rouault@spatialys.com>
-
- CMake: Skip custom_dir_EXIF_231 test on shared builds to avoid issues on Windows
-
-2020-03-07 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'EXIF231_GPS_upgrade' into 'master'
- EXIF 2.32 and GPS TIFF-tags and functionality upgraded.
-
- See merge request libtiff/libtiff!91
-
-2020-03-07 Su_Laus <sulau@freenet.de>
-
- EXIF 2.32 and GPS tags and functionality upgraded.
- - Existing EXIF field definition of tags is upgraded to EXIF version 2.3.2
- - EXIF-GPS structure, tags and access functions are added as special CustomDirectory (like it was done for EXIF).
- - Test program custom_dir_EXIF_231.c added to test writing/reading of EXID IFD and GPS IFD tags
- and to highlight some quirks of IFD-handling and peculiarities of reading/writing the different data types.
- - Reading error for FileSource and SceneType tags corrected.
-
- - EXIF_GPS_upgrade rebased onto c8c5309b765ef4ff097d2aaffbdb8f403db8967d (Merge branch 'Rational2DoublePrecision_correction' into 'master')
- and adapted:
- - tif_dirinfo.c: All rational tags set to TIFF_SETGET_FLOAT but only the GPSTAG_ tags set to TIFF_SETGET_DOUBLE.
- - custom_dir_EXIF_231.c: Editorials amended and gcc warnings fixed.
- - CMakeLists.txt: add_test(NAME "custom_dir_EXIF_231" COMMAND "custom_dir_EXIF_231") added.
-
-2020-03-07 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue-55' into 'master'
- ppm2tiff: support any bps value from 1 to 16
-
- Closes #55
-
- See merge request libtiff/libtiff!106
-
-2020-03-07 Thomas Bernard <miniupnp@free.fr>
-
- ppm2tiff: Add test for 16bpc PPM.
-
- ppm2tiff: remove unused argument warning.
-
-2020-03-07 Ludolf Holzheid <ludolf.holzheid@gmx.de>
-
- ppm2tiff: support any bps value from 1 to 16.
- fix #55
- http://bugzilla.maptools.org/show_bug.cgi?id=2505
-
- Patch originally submitted by Ludolf Holzheid <ludolf.holzheid@gmx.de>
-
-2020-03-06 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fax-test' into 'master'
- add test for fax4 decoding
-
- See merge request libtiff/libtiff!114
-
-2020-03-05 Thomas Bernard <miniupnp@free.fr>
-
- add test for fax4 decoding.
- This will check for regression on #46
- https://gitlab.com/libtiff/libtiff/issues/46
- http://bugzilla.maptools.org/show_bug.cgi?id=2434
-
-2020-03-05 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'freebsd-tests' into 'master'
- make tests pass under FreeBSD.
-
- See merge request libtiff/libtiff!113
-
-2020-03-05 Thomas Bernard <miniupnp@free.fr>
-
- make tests pass under FreeBSD.
- the -I option for the GNU diff and the FreeBSD diff
- behaves differently regarding escaping the ( ) and |
-
- By using two -I option, we avoid using such charracters.
-
-2020-03-05 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue-31' into 'master'
- HTML
-
- Closes #31
-
- See merge request libtiff/libtiff!111
-
-2020-03-05 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue-179' into 'master'
- tif_fax3.h: check for buffer overflow in EXPAND2D before "calling" CLEANUP_RUNS()
-
- Closes #179
-
- See merge request libtiff/libtiff!112
-
-2020-03-05 Thomas Bernard <miniupnp@free.fr>
-
- v4.1.0.html: fix for validation.
- long <!----------------> comments were replaced
- because they confused some parsers
-
- add DOCTYPE on v*.html.
-
- fix HTML files so they are valid according to https://validator.w3.org.
-
-2020-03-05 Thomas Bernard <miniupnp@free.fr>
-
- tif_fax3.h: check for buffer overflow in EXPAND2D before "calling" CLEANUP_RUNS()
- fixes #179
-
- this fixes the regression introduced in 02bb0175 / 72c4acef
- ( merge request !110 )
-
- It may be a better fix to do the overflow check in SETVALUE() but the
- macro do { } while(0) construct makes it difficult to quit the loop
- properly.
-
-2020-03-01 Thomas Bernard <miniupnp@free.fr>
-
- index.html: fix unclosed <tt> tag.
-
-2020-03-01 Thomas Bernard <miniupnp@free.fr>
-
- html: do not force colors (which are default anyway)
- If needed, style should be set using CSS.
-
- fixes #31
- https://gitlab.com/libtiff/libtiff/issues/31
- http://bugzilla.maptools.org/show_bug.cgi?id=2326
-
-2020-03-01 Even Rouault <even.rouault@spatialys.com>
-
- TIFFReadCustomDirectory(): fix potential heap buffer overflow when reading a custom directory, after a regular directory where a codec was active. Fixes https://gitlab.com/libtiff/libtiff/issues/178
-
-2020-03-01 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue-46' into 'master'
- fix decoding of fax4 images
-
- Closes #46
-
- See merge request libtiff/libtiff!110
-
-2020-02-29 Thomas Bernard <miniupnp@free.fr>
-
- tif_fax3: better fix for CVE-2011-0192.
- There are some legitimate case which were forbidden by the previous fix
-
- tif_fax3.h: allow 0 length run in DECODE2D.
- fixes #46
- https://gitlab.com/libtiff/libtiff/issues/46
- http://bugzilla.maptools.org/show_bug.cgi?id=2434
-
-2020-02-29 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'mingwlibm' into 'master'
- Don't use libm with libtiff due to conflict with libmsvcrt
-
- See merge request libtiff/libtiff!73
-
-2020-02-29 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'Rational2DoublePrecision_correction' into 'master'
- tif_dirwrite.c: bugfix DoubleToSrational() for plain signed integers
-
- See merge request libtiff/libtiff!109
-
-2020-02-29 Su_Laus <sulau@freenet.de>
-
- tif_dirwrite.c: bugfix DoubleToSrational(), which returns plain signed integer values always as unsigned rationals. Add a test into rational_precision2double.c for "-1.0" and some editorials in tif_dirwrite.c. (code is related to 6df997c786928757caea0dd68d26ea5f098f49df changes).
-
-2020-02-29 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue-174' into 'master'
- tif_fax3.c: check buffer overflow in Fax4Decode()
-
- Closes #174
-
- See merge request libtiff/libtiff!108
-
-2020-02-29 Thomas Bernard <miniupnp@free.fr>
-
- Fax4Decode(): log error message in case of buffer overrun.
-
- tif_fax3.c: check buffer overflow in Fax4Decode()
- fixes #174
-
-2020-02-28 Even Rouault <even.rouault@spatialys.com>
-
- typo fixes in code comments.
-
- ToRationalEuclideanGCD: remove useless test that confuses Coverity Scan about a potential later modulo by zero
-
-2020-02-27 Even Rouault <even.rouault@spatialys.com>
-
- tif_dirwrite.c: fix other warnings related to 6df997c786928757caea0dd68d26ea5f098f49df changes
-
- rational_precision2double.c: fix many warnings, and do not build it on CMake on shared lib builds
-
- tif_dirwrite.c: fix various warnings found when building GDAL with internal libtiff after 6df997c786928757caea0dd68d26ea5f098f49df changes
-
- tif_dirwrite.c: qualify ToRationalEuclideanGCD() with static.
-
-2020-02-27 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'Rational2DoublePrecision' into 'master'
- Rational with Double Precision Upgrade
-
- See merge request libtiff/libtiff!100
-
-2020-02-27 Su_Laus <sulau@freenet.de>
-
- Rational with Double Precision Upgrade.
- Unfortunately, custom rational tags (TIFF_RATIONAL with field_bit=FIELD_CUSTOM) are defined as TIFF_SETGET_DOUBLE
- but for the reading interface and LibTiff internally they are stored ALWAYS as floating point SINGLE precision.
- Double precision custom rational tags are not supported by LibTiff.
-
- For the GPS tags in WGS84 a higher accuracy / precision is needed.
- Therefore, this upgrade is made, keeping the old interface for the already defined tags and allowing a double precision definition,
- as well as calculating rationals with higher accuracy / precision.
- This higher accuracy can be used for newly defined tags like that in EXIF/GPS.
-
- Refer also to the very old Bugzilla issue 2542 (#69)
-
- A test file rational_precision2double.c is added, which shows prevention of the old interface to the already defined custom rational tags
- with the standard library as well as with the upgraded library.
-
- Also TIFFTAG_XRESOLUTION, TIFFTAG_YRESOLUTION, TIFFTAG_XPOSITION, TIFFTAG_YPOSITION amended from TIFF_SETGET_DOUBLE to TIFF_SETGET_FLOAT and testcase inserted in rational_precision2double.c
-
-2020-02-26 Chris Degawa <ccom@randomderp.com>
-
- mingw-w64 cmake: Don't find libm.
- mingw-w64 will provide libm symbols by default without -lm and mingw-64's
- libm is just a stub.
-
- This is just to make sure that on systems with msys2 and also cygwin, cmake
- doesn't find a libm that actually contains math functions.
-
-2020-02-26 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'division-by-zero' into 'master'
- tools/tiffcp.c: fix potential division by zero
-
- See merge request libtiff/libtiff!83
-
-2020-02-26 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix-unused-warning' into 'master'
- warnings: mark conditionally used parameters
-
- See merge request libtiff/libtiff!49
-
-2020-02-26 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'master' into 'master'
- fix issue #78 warnings regarding RichTIFFIPTC data type
-
- Closes #78
-
- See merge request libtiff/libtiff!99
-
-2020-02-26 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'win64-handle-casts-warn-fix' into 'master'
- Avoid warnings about casts between HANDLE and int in Win64 builds
-
- Closes #2
-
- See merge request libtiff/libtiff!93
-
-2020-02-26 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'bug2839' into 'master'
- raw2tiff: avoid divide by 0
-
- Closes #151
-
- See merge request libtiff/libtiff!103
-
-2020-02-26 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'bug2669' into 'master'
- tiff2pdf: palette bound check in t2p_sample_realize_palette()
-
- Closes #82
-
- See merge request libtiff/libtiff!104
-
-2020-02-26 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'int-shift' into 'master'
- tiffcrop: fix asan runtime error caused by integer promotion
-
- See merge request libtiff/libtiff!105
-
-2020-02-26 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'bug-2538' into 'master'
- libtiff.html: fix function casing
-
- Closes #68
-
- See merge request libtiff/libtiff!107
-
-2020-02-16 Thomas Bernard <miniupnp@free.fr>
-
- raw2tiff: avoid divide by 0.
- fixes #151 / http://bugzilla.maptools.org/show_bug.cgi?id=2839
-
- first memcmp() lines before computing correlation
- and always avoid divide by 0 anyway
-
-2020-02-09 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'bug2855' into 'master'
- tiff2ps: fix heap buffer read overflow in PSDataColorContig()
-
- Closes #161
-
- See merge request libtiff/libtiff!102
-
-2020-02-08 Thomas Bernard <miniupnp@free.fr>
-
- libtiff.html: fix function casing.
-
- libtiff.html: fix function casing.
- fixes #68 / http://bugzilla.maptools.org/show_bug.cgi?id=2538
-
-2020-02-08 Thomas Bernard <miniupnp@free.fr>
-
- tiffcrop: fix asan runtime error caused by integer promotion.
- tiffcrop.c:4027:20: runtime error: left shift of 190 by 24 places cannot be represented in type 'int'
-
- C treats (byte << 24) as an int expression.
- casting explicitly to unsigned type uint32 avoids the problem.
-
- the same issue has been fixed elsewhere with a24213691616e7cd35aa3e2805493de80c7e4fcf
-
- I detected the bug with the test file of #86
-
-2020-02-08 Thomas Bernard <miniupnp@free.fr>
-
- tiff2pdf: palette bound check in t2p_sample_realize_palette()
- fixes #82
-
-2020-02-08 Thomas Bernard <miniupnp@free.fr>
-
- tiff2ps: fix heap buffer read overflow in PSDataColorContig()
- fixes #161 / http://bugzilla.maptools.org/show_bug.cgi?id=2855
-
- in 05029fb7f1ecf771abaf90b5705b6cab9eb522a7 I missed that 1 extra byte is read
- in this loop.
-
-2020-02-05 Even Rouault <even.rouault@spatialys.com>
-
- tif_dirread.c: suppress CLang static Analyzer 9.0 false positive.
-
-2020-02-01 Even Rouault <even.rouault@spatialys.com>
-
- TIFFSetupStrips: enforce 2GB limitation of Strip/Tile Offsets/ByteCounts arrays
- TIFFWriteDirectoryTagData() has an assertion that checks that the
- arrays are not larger than 2GB. So error out earlier if in that situation.
-
-2020-01-29 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- Simplify nmake configuration for building port directory. Now there is only one boolean setting to enable building strtoll() and strtoull() port functions. The boolean setting enables the necessary port files to be built, but the remainder of the logic is via pre-processor code in the common tif_config.h, which was prepared before entering the port directory to do a build.
-
-2020-01-28 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- Make sure that tif_config.h is produced prior to entering the port directory and add an include path so that the port files can include tif_config.h. Do not actually include tif_config.h at this time since CMake and Autotools builds are not prepared for that. This issue could be handled by updating the CMake and Autotools builds or by adding a define which directs libport.h to include tif_config.h.
-
-2020-01-26 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- Fix nmake build mistakes in my last commit:
- tif_config.vc.h:
-
- Always define HAVE_STRTOL/HAVE_STRTOUL.
- Define HAVE_STRTOLL/HAVE_STRTOULL if _MSC_VER >= 1900.
-
- nmake.opt:
-
- Provide defaults suitable for MSVC prior to 14.0.
-
- libport.h:
-
- The sense of the pre-processor logic was inverted from what it
- should be. The intention is to only provide the prototype if the
- function is missing.
-
-2020-01-25 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- Add nmake build support for manually configuring the 'port' files to be built based on MSVC features. Include tif_config.h in tools/tiffset.c.
-
-2020-01-23 Even Rouault <even.rouault@spatialys.com>
-
- Adjust previous fix to avoid undue warning in some situations triggered by GDAL
-
-2020-01-12 Even Rouault <even.rouault@spatialys.com>
-
- _TIFFPartialReadStripArray: bring back support for non-conformant SLONG8 data type
- Such as in https://github.com/OSGeo/gdal/issues/2165
-
-2020-01-07 Even Rouault <even.rouault@spatialys.com>
-
- test: add test for single-strip OJPEG file without RowsPerStrip tag (like in CR2 files)
-
- OJPEGReadHeaderInfo: if rowsperstrip not defined, then assume one-single-strip. Complementary fix to 0356ea76bac908c61160d735f078437ace953bd3
-
-2019-12-16 Angel Sánchez <angelsanchez@inedit.com>
-
- fix issue #78 warnings regarding RichTIFFIPTC data type.
-
-2019-12-14 Even Rouault <even.rouault@spatialys.com>
-
- contrib/oss-fuzz/build.sh: fix broken if construct.
-
-2019-11-28 Even Rouault <even.rouault@spatialys.com>
-
- contrib/oss-fuzz/build.sh: other attempt at fixing build failure.
-
-2019-11-20 Even Rouault <even.rouault@spatialys.com>
-
- contrib/oss-fuzz/build.sh: install liblzma-dev for x86_64 builds.
-
-2019-11-17 Even Rouault <even.rouault@spatialys.com>
-
- contrib/oss-fuzz/build.sh: install liblzma-dev:i386 on i386 builds.
-
-2019-11-15 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'cmake-parse' into 'master'
- CMake: simplify parsing variables from configure
-
- See merge request libtiff/libtiff!98
-
-2019-11-15 Rolf Eike Beer <eb@emlix.com>
-
- CMake: simplify parsing variables from configure.
-
-2019-11-14 Even Rouault <even.rouault@spatialys.com>
-
- contrib/oss-fuzz/build.sh: fix ossfuzz build by statically linking to lzma
-
-2019-11-12 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_ojpeg_172' into 'master'
- OJPEG: fix broken sanity check added in 4.1.0 (#fixes 172)
-
- See merge request libtiff/libtiff!97
-
-2019-11-11 Even Rouault <even.rouault@spatialys.com>
-
- OJPEG: fix broken sanity check added in 4.1.0, and add two OJPEG test files
-
- test/: add missing generated .sh files.
-
-2019-11-04 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix-missing-checks-TIFFGetField-tiffcrop' into 'master'
- adds missing checks on TIFFGetField in tiffcrop tool
-
- Closes #170
-
- See merge request libtiff/libtiff!96
-
-2019-11-04 Bug Checkers <coolbugcheckers@gmail.com>
-
- adds missing checks on TIFFGetField in tiffcrop tool (fixes #170)
-
-2019-11-04 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'adds-missing-TIFFClose-rgb2ycbcr' into 'master'
- adds a missing TIFFClose in rgb2ycbcr tool
-
- See merge request libtiff/libtiff!95
-
-2019-11-04 Mansour Ahmadi <mansourweb@gmail.com>
-
- adds a missing TIFFClose in rgb2ycbcr tool.
-
-2019-11-03 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- libtiff 4.1.0 released.
-
- Added a step for updating the legacy ChangeLog file.
-
- Ignore emacs temporary files (ending with tilde character).
-
- Added release summary page for the 4.1.0 release.
-
- Fix Cmake HAVE_GETOPT for systems which declare getopt in stdio.h. Fix utility baked-in getopt prototype which appears when HAVE_GETOPT is not defined.
-
- Fax2tiff.sh needs to remove its output file in advance. Syntax changes so that bash is not required.
-
-2019-10-26 Even Rouault <even.rouault@spatialys.com>
-
- tif_jpeg.c: extra cast to silence Coverity warning. GDAL CID 1406475.
-
-2019-10-23 Even Rouault <even.rouault@spatialys.com>
-
- tif_jpeg.c: fix warning added by previous commit (on 32bit builds)
-
-2019-10-23 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'coverity-fixes' into 'master'
- Coverity fixes
-
- See merge request libtiff/libtiff!94
-
-2019-10-22 Timothy Lyanguzov <timothy.lyanguzov@sap.com>
-
- Use 64-bit calculations correctly.
-
- Fix size calculation to use 64-bit tmsize_t correctly.
-
- Make bytesperclumpline calculations using tmsize_t type.
-
-2019-10-03 Even Rouault <even.rouault@spatialys.com>
-
- tif_read: align code of TIFFReadRawStrip() and TIFFReadRawTile() that differed for non good reason. Non-functional change normally. (fixes GitLab #162)
-
-2019-10-01 Even Rouault <even.rouault@spatialys.com>
-
- HTML: update for GitLab issues.
-
-2019-09-29 Even Rouault <even.rouault@spatialys.com>
-
- html/v3.5.6-beta.html: redact URL of defunct web site.
-
- Website: update links to mailing list.
-
-2019-09-17 Even Rouault <even.rouault@spatialys.com>
-
- TIFFReadAndRealloc(): avoid too large memory allocation attempts. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=17244
-
-2019-09-03 Even Rouault <even.rouault@spatialys.com>
-
- ByteCountLooksBad and EstimateStripByteCounts: avoid unsigned integer overflows. Fixes https://oss-fuzz.com/testcase-detail/5686156066291712 and https://oss-fuzz.com/testcase-detail/6332499206078464
-
-2019-09-02 Even Rouault <even.rouault@spatialys.com>
-
- tif_ojpeg.c: avoid relying on isTiled macro being wrapped in ()
-
- tif_ojpeg.c: avoid use of uninitialized memory on edge/broken file. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=16844
-
- tiff_read_rgba_fuzzer.cc: add a -DSTANDALONE mode for easier reproduction of oss-fuzz reports
-
-2019-09-01 Even Rouault <even.rouault@spatialys.com>
-
- tif_dirread.c: allocChoppedUpStripArrays(). avoid unsigned integer overflow. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=16846
-
-2019-08-27 Even Rouault <even.rouault@spatialys.com>
-
- tif_ojpeg.c: avoid unsigned integer overflow. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=16793
-
-2019-08-26 Even Rouault <even.rouault@spatialys.com>
-
- TIFFReadDirEntryData(): rewrite to avoid unsigned integer overflow (not a bug). Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=16792
-
- TIFFFetchDirectory(): fix invalid cast from uint64 to tmsize_t. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=16784
-
-2019-08-25 Even Rouault <even.rouault@spatialys.com>
-
- JPEG: avoid use of uninitialized memory on corrupted files.
- Follow-up of cf3ce6fab894414a336546f62adc57f02590a22c
- Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=16602
- Credit to OSS Fuzz
-
-2019-08-23 Even Rouault <even.rouault@spatialys.com>
-
- _TIFFPartialReadStripArray(): avoid unsigned integer overflow. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=16685
-
- OJPEGWriteHeaderInfo(): avoid unsigned integer overflow on strile dimensions close to UINT32_MAX. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=16683
-
- TIFFFillStrip(): avoid harmless unsigned integer overflow. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=16653
-
- EstimateStripByteCounts(): avoid unsigned integer overflow. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=16643&
-
- tif_ojpeg: avoid unsigned integer overflow (probably not a bug). Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=16635
-
- tif_thunder: avoid unsigned integer overflow (not a bug). Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=16632
-
-2019-08-22 Even Rouault <even.rouault@spatialys.com>
-
- _TIFFMultiply32() / _TIFFMultiply64(): avoid relying on unsigned integer overflow (not a bug)
-
- EstimateStripByteCounts(): avoid unsigned integer overflow.
-
-2019-08-21 Even Rouault <even.rouault@spatialys.com>
-
- EstimateStripByteCounts(): avoid unsigned integer overflow.
-
-2019-08-20 Even Rouault <even.rouault@spatialys.com>
-
- EstimateStripByteCounts(): avoid harmless unsigned integer overflow.
-
- _TIFFPartialReadStripArray(): avoid triggering unsigned integer overflow with -fsanitize=unsigned-integer-overflow (not a bug, this is well defined by itself)
-
-2019-08-18 Even Rouault <even.rouault@spatialys.com>
-
- tiff2ps: fix use of wrong data type that caused issues (/Height being written as 0) on 64-bit big endian platforms
-
-2019-08-16 Even Rouault <even.rouault@spatialys.com>
-
- setByteArray(): fix previous commit.
-
- setByteArray(): avoid potential signed integer overflow. Pointed by Hendra Gunadi. No actual problem known (which does not mean there wouldn't be any. Particularly on 32bit builds)
-
-2019-08-15 Even Rouault <even.rouault@spatialys.com>
-
- RGBA interface: fix integer overflow potentially causing write heap buffer overflow, especially on 32 bit builds. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=16443. Credit to OSS Fuzz
-
-2019-08-14 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_integer_overflow' into 'master'
- Fix integer overflow in _TIFFCheckMalloc() and other implementation-defined behaviour (CVE-2019-14973)
-
- See merge request libtiff/libtiff!90
-
-2019-08-13 Even Rouault <even.rouault@spatialys.com>
-
- Fix integer overflow in _TIFFCheckMalloc() and other implementation-defined behaviour (CVE-2019-14973)
- _TIFFCheckMalloc()/_TIFFCheckRealloc() used a unsafe way to detect overflow
- in the multiplication of nmemb and elem_size (which are of type tmsize_t, thus
- signed), which was especially easily triggered on 32-bit builds (with recent
- enough compilers that assume that signed multiplication cannot overflow, since
- this is undefined behaviour by the C standard). The original issue which lead to
- this fix was triggered from tif_fax3.c
-
- There were also unsafe (implementation defied), and broken in practice on 64bit
- builds, ways of checking that a uint64 fits of a (signed) tmsize_t by doing
- (uint64)(tmsize_t)uint64_var != uint64_var comparisons. Those have no known
- at that time exploits, but are better to fix in a more bullet-proof way.
- Or similarly use of (int64)uint64_var <= 0.
-
-2019-08-12 Even Rouault <even.rouault@spatialys.com>
-
- TIFFClientOpen(): fix memory leak if one of the required callbacks is not provided. Fixed Coverity GDAL CID 1404110
-
- OJPEGReadBufferFill(): avoid very long processing time on corrupted files. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=16400. master only
-
-2019-08-10 Even Rouault <even.rouault@spatialys.com>
-
- oss-fuzz/tiff_read_rgba_fuzzer.cc: fix wrong env variable value in previous commit
-
- oss-fuzz/tiff_read_rgba_fuzzer.cc: avoid issue with libjpeg-turbo and MSAN
-
- OJPEG: fix integer division by zero on corrupted subsampling factors. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=15824. Credit to OSS Fuzz
-
- Merge branch 'ossfuzz_i386'
-
- contrib/oss-fuzz/build.sh: fix for i386 build of jbigkit, and use $LIB_FUZZING_ENGINE
-
-2019-08-10 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'patch-1' into 'master'
- fix two tiny typos
-
- See merge request libtiff/libtiff!89
-
-2019-08-10 Reto Kromer <rk@reto.ch>
-
- fix two tiny typos.
-
-2019-08-09 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'patch-1' into 'master'
- fix a typo in man page
-
- See merge request libtiff/libtiff!88
-
-2019-08-09 Reto Kromer <rk@reto.ch>
-
- fix typo.
-
-2019-08-04 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'TIFFTAGID_Zero_reading_IGNORE' into 'master'
- Suppressed Reading of Tiff tags with ID = 0 (like GPSVERSIONID) corrected.
-
- See merge request libtiff/libtiff!77
-
-2019-08-04 Su Laus <sulau@freenet.de>
-
- Reading of Tiff tags with ID = 0 (like GPSVERSIONID) corrected.
- IGNORE placeholder in tif_dirread.c is now replaced by a field dir_ignore in the TIFFDirEntry structure
-
- Currently, in tif_dirread.c a special IGNORE value for the tif tags is defined
- in order to flag status preventing already processed tags from further processing.
- This irrational behaviour prevents reading of custom tags with id code 0 - like tag GPSVERSIONID from EXIF 2.31 definition.
-
- An additional field 'tdir_ignore' is now added to the TIFFDirEntry structure and code is changed
- to allow tags with id code 0 to be read correctly.
-
- This change was already proposed as pending improvement in tif_dirread.c around line 32.
-
- Reference is also made to:
- - Discussion in https://gitlab.com/libtiff/libtiff/merge_requests/39
- - http://bugzilla.maptools.org/show_bug.cgi?id=2540
-
- Comments and indentation adapted.
-
- Preparation to rebase onto master
-
-2019-07-16 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'cmake_amd64' into 'master'
- CMakeLists.txt: properly set value of HOST_FILLORDER to LSB2MSB for Windows CMake builds
-
- See merge request libtiff/libtiff!87
-
-2019-07-15 Even Rouault <even.rouault@spatialys.com>
-
- CMakeLists.txt: properly set value of HOST_FILLORDER to LSB2MSB for Windows CMake builds
- As can be seen in https://ci.appveyor.com/project/rleigh-codelibre/libtiff-didfs/builds/25846668/job/ory5w098j8wcij9x
- log, the HOST_FILLORDER is not properly set:
-
- [00:02:58] -- CMAKE_HOST_SYSTEM_PROCESSOR set to AMD64
- [00:02:58] -- HOST_FILLORDER set to FILLORDER_MSB2LSB
-
- The reason is that we match the "amd64.*" lowercase string whereas
- CMAKE_HOST_SYSTEM_PROCESSOR is set to AMD64 uppercase.
-
-2019-07-09 Even Rouault <even.rouault@spatialys.com>
-
- TIFFWriteCheck(): call TIFFForceStrileArrayWriting() when needed (should have gone with eaeca6274ae71cdfaeb9f673b6fb0f3cfc0e6ce5) (master only)
-
-2019-07-09 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_chromium_925269' into 'master'
- OJPEG: avoid use of uninitialized memory on corrupted files
-
- See merge request libtiff/libtiff!86
-
-2019-07-05 Even Rouault <even.rouault@spatialys.com>
-
- OJPEG: avoid use of uninitialized memory on corrupted files.
- Fixes https://bugs.chromium.org/p/chromium/issues/detail?id=925269
- Patch from Lei Zhang with little adaptations.
-
-2019-06-29 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix-division-by-zero' into 'master'
- Return infinite distance when denominator is zero.
-
- See merge request libtiff/libtiff!85
-
-2019-06-29 Dirk Lemstra <dirk@lemstra.org>
-
- Return infinite distance when denominator is zero.
-
-2019-06-29 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'typetests' into 'master'
- Add test to check that libtiff types have the correct size
-
- See merge request libtiff/libtiff!57
-
-2019-05-31 Thomas Bernard <miniupnp@free.fr>
-
- make TIFF_SSIZE_T the same bitwidth as TIFF_SIZE_T.
- it was previously the same bitwidth as unsigned char *
- Pointers can be larger than size_t.
-
-2019-05-31 Thomas Bernard <miniupnp@free.fr>
-
- Add test to check that libtiff types have the correct size.
- in configure/CMakeList.txt :
-
- - TIFF_INT8_T/TIFF_UINT8_T is signed/unsigned char
- sizeof(char)==1 in C standard
- - TIFF_INT16_T/TIFF_UINT16_T is signed/unsigned short
- sizeof(short)>=2 in C standard
- - TIFF_INT32_T/TIFF_UINT32_T is defined so its sizeof() is 4
-
- - TIFF_INT64_T/TIFF_UINT64_T is defined so its sizeof() is 8
-
- - TIFF_SIZE_T is defined so it has same sizeof() than size_t
-
- - TIFF_SSIZE_T is defined so it has same sizeof() than unsigned char *
-
-2019-05-29 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'defer_strile_writing' into 'master'
- Add TIFFDeferStrileArrayWriting() and TIFFForceStrileArrayWriting()
-
- See merge request libtiff/libtiff!82
-
-2019-05-29 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'TIFFReadFromUserBuffer' into 'master'
- Add TIFFReadFromUserBuffer()
-
- See merge request libtiff/libtiff!81
-
-2019-05-26 Even Rouault <even.rouault@spatialys.com>
-
- Fix vulnerability in 'D' (DeferStrileLoad) mode (master only) (fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=14908)
-
-2019-05-25 Even Rouault <even.rouault@spatialys.com>
-
- Replace 'stripped' by 'striped' in error messages.
-
-2019-05-25 Even Rouault <even.rouault@spatialys.com>
-
- Add TIFFDeferStrileArrayWriting() and TIFFForceStrileArrayWriting()
- Those advanced writing functions must be used in a particular sequence
- to make their intended effect. Their aim is to control when/where
- the [Strip/Tile][Offsets/ByteCounts] arrays are written into the file.
-
- The purpose of this is to generate 'cloud-optimized geotiff' files where
- the first KB of the file only contain the IFD entries without the potentially
- large strile arrays. Those are written afterwards.
-
- The typical sequence of calls is:
- TIFFOpen()
- [ TIFFCreateDirectory(tif) ]
- Set fields with calls to TIFFSetField(tif, ...)
- TIFFDeferStrileArrayWriting(tif)
- TIFFWriteCheck(tif, ...)
- TIFFWriteDirectory(tif)
- ... potentially create other directories and come back to the above directory
- TIFFForceStrileArrayWriting(tif): emit the arrays at the end of file
-
- See test/defer_strile_writing.c for a practical example.
-
-2019-05-24 Even Rouault <even.rouault@spatialys.com>
-
- Fix vulnerability introduced by defer strile loading (master only)
- Found on GDAL with https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=14894
- Disabling the TIFF_DEFERSTRILELOAD bit in ChopupStripArray() was a
- bad idea since when using TIFFReadDirectory() to reload the directory again
- would lead to a different value of td_rowsperstrip, which could confuse
- readers if they relied on the value found initially.
-
- Fix typo in error message (master only)
-
-2019-05-22 Even Rouault <even.rouault@spatialys.com>
-
- Add TIFFReadFromUserBuffer()
- This function replaces the use of TIFFReadEncodedStrip()/TIFFReadEncodedTile()
- when the user can provide the buffer for the input data, for example when
- he wants to avoid libtiff to read the strile offset/count values from the
- [Strip|Tile][Offsets/ByteCounts] array.
-
- libtiff.def: add missing new symbols.
-
- test/defer_strile_loading.c: fix warning with Visual C++
-
- _TIFFRewriteField(): fix for bigtiff case (master only)
- 116cf67f4c59196605abdb244657c3070c4310af made StripByteCount/TileByteCount to
- always be rewritten as TIFF_LONG8.
-
-2019-05-21 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'ondemand_strile_offbytecount_loading' into 'master'
- Make defer strile offset/bytecount loading available at runtime
-
- See merge request libtiff/libtiff!79
-
-2019-05-21 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'bigtiff_write_bytecount_on_long_when_possible' into 'master'
- Create TileByteCounts/StripByteCounts tag with SHORT (ClassicTIFF/BigTIFF) or LONG (BigTIFF) type when possible
-
- See merge request libtiff/libtiff!78
-
-2019-05-21 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'html_link' into 'master'
- libtiff.html, bigtiffpr.html: absolute => relative link
-
- See merge request libtiff/libtiff!80
-
-2019-05-14 Thomas Bernard <miniupnp@free.fr>
-
- libtiff.html, bigtiffpr.html: absolute => relative link.
-
-2019-05-10 Even Rouault <even.rouault@spatialys.com>
-
- Make defer strile offset/bytecount loading available at runtime.
- ... and add per-strile offset/bytecount loading capabilities.
-
- Part of this commit makes the behaviour that was previously met when
- libtiff was compiled with -DDEFER_STRILE_LOAD available for default builds
- when specifying the new 'D' (Deferred) TIFFOpen() flag. In that mode, the [Tile/Strip][ByteCounts/Offsets]
- arrays are only loaded when first accessed. This can speed-up the opening
- of files stored on the network when just metadata retrieval is needed.
- This mode has been used for years by the GDAL library when compiled with
- its embedded libtiff copy.
-
- To avoid potential out-of-tree code (typically codecs) that would use
- the td_stripbytecount and td_stripoffset array inconditionnaly assuming they
- have been loaded, those have been suffixed with _p (for protected). The
- use of the new functions mentioned below is then recommended.
-
- Another addition of this commit is the capability of loading only the
- values of the offset/bytecount of the strile of interest instead of the
- whole array. This is enabled with the new 'O' (Ondemand) flag of TIFFOpen()
- (which implies 'D'). That behaviour has also been used by GDAL, which hacked
- into the td_stripoffset/td_stripbytecount arrays directly. The new code
- added in the _TIFFFetchStrileValue() and _TIFFPartialReadStripArray() internal
- functions is mostly a port of what was in GDAL GTiff driver previously.
-
- Related to that, the public TIFFGetStrileOffset[WithErr]() and TIFFGetStrileByteCount[WithErr]()
- functions have been added to API. They are of particular interest when
- using sparse files (with offset == bytecount == 0) and you want to detect
- if a strile is present or not without decompressing the data, or updating
- an existing sparse file.
- They will also be used to enable a future enhancement where client code can entirely
- skip bytecount loading in some situations
-
- A new test/defer_strile_loading.c test has been added to test the above
- capabilities.
-
-2019-05-10 Even Rouault <even.rouault@spatialys.com>
-
- Creation: use SHORT type when possible for StripByteCounts/TileByteCounts
- This follows the same logic as previous commit.
-
-2019-05-09 Even Rouault <even.rouault@spatialys.com>
-
- BigTIFF creation: write TileByteCounts/StripByteCounts tag with LONG when possible
- In most situations of BigTIFF file, the tile/strip sizes are of reasonable size,
- that is they fit on a 4-byte LONG. So in that case, use LONG instead of LONG8
- to save some space. For uncompressed file, it is easy to detect such situations
- by checking at the TIFFTileSize64()/TIFFStripSize64() return. For compressed file,
- we must take into account the fact that compression may sometimes result in
- larger compressed data. So we allow this optimization only for a few select
- compression times, and take a huge security margin (10x factor). We also only
- apply this optimization on multi-strip files, so as to allow easy on-the-fly
- growing of single-strip files whose strip size could grow above the 4GB threshold.
-
- This change is compatible with the BigTIFF specification. According to
- https://www.awaresystems.be/imaging/tiff/bigtiff.html:
- "The StripOffsets, StripByteCounts, TileOffsets, and TileByteCounts tags are
- allowed to have the datatype TIFF_LONG8 in BigTIFF. Old datatypes TIFF_LONG,
- and TIFF_SHORT where allowed in the TIFF 6.0 specification, are still valid in BigTIFF, too. "
- On a practical point of view, this is also compatible on reading/writing of
- older libtiff 4.X versions.
-
- The only glitch I found, which is rather minor, is when using such a BigTIFF
- file with TileByteCounts/StripByteCounts written with TIFF_LONG, and updating
- it with an older libtiff 4.X version with a change in the
- [Tile/Strip][ByteCounts/Offsets] array. In that case the _TIFFRewriteField()
- function will rewrite the directory and array with TIFF_LONG8, instead of updating
- the existing array (this is an issue fixed by this commit). The file will
- still be valid however, hence the minor severity of this.
-
-2019-05-08 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'bug2799' into 'master'
- fix fax2tiff
-
- See merge request libtiff/libtiff!55
-
-2019-05-08 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'bug_2829' into 'master'
- WIN32: use tif_win32.c when building with CMake
-
- See merge request libtiff/libtiff!75
-
-2019-05-06 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'FILESOURCE_SCENETYPE_reading' into 'master'
- Reading error for FileSource and SceneType tags corrected.
-
- See merge request libtiff/libtiff!76
-
-2019-05-06 Su Laus <sulau@freenet.de>
-
- Reading error for FileSource and SceneType tags corrected.
- EXIF tags FILESOURCE and SCENETYPE are defined as TIFF_UNDEFINED and field_readcount==1!
- There is a bug in TIFFReadDirEntryByte() preventing to read correctly type TIFF_UNDEFINED fields with field_readcount==1
- Upgrade of TIFFReadDirEntryByte() with added TIFF_UNDEFINED switch-entry allows libtiff to read those tags correctly.
-
-2019-04-25 Thomas Bernard <miniupnp@free.fr>
-
- WIN32: use tif_win32.c when building with CMake.
- see http://bugzilla.maptools.org/show_bug.cgi?id=2829
-
- the top CMakeLists.txt defines
- win32_io and USE_WIN32_FILEIO
-
- WIN32_IO is defined nowhere in CMake (only in automake things)
-
-2019-04-25 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'gitlab_pages' into 'master'
- Advertise https://libtiff.gitlab.io/libtiff/ as mirror
-
- See merge request libtiff/libtiff!70
-
-2019-04-25 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'bug_2844' into 'master'
- tiff2ps.c: PSDataColorContig(): avoid heap buffer overrun
-
- See merge request libtiff/libtiff!69
-
-2019-04-25 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue_2785' into 'master'
- tiff2pdf.c: don't call t2p_tile_collapse_left() for Ycbcr
-
- See merge request libtiff/libtiff!64
-
-2019-04-11 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_gdal_1439' into 'master'
- TIFFWriteEncodedStrip/TIFFWriteEncodedTile: fix rewriting of LZW-compressed data
-
- See merge request libtiff/libtiff!74
-
-2019-04-11 Even Rouault <even.rouault@spatialys.com>
-
- TIFFWriteEncodedStrip/TIFFWriteEncodedTile: fix rewriting of LZW-compressed data
- Fixes https://github.com/OSGeo/gdal/issues/1439
-
- When rewriting a LZW tile/strip whose existing size is very close to a multiple of
- 1024 bytes (and larger than 8192 bytes) with compressed data that is larger,
- the new data was not placed at the end of the file, causing corruption.
-
-2019-04-08 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'bug2848' into 'master'
- tif_luv.c: LogLuvSetupEncode() error must return 0
-
- See merge request libtiff/libtiff!72
-
-2019-04-03 Thomas Bernard <miniupnp@free.fr>
-
- build/gitlab-ci: fix typo.
-
- show test-suite.log in gitlab-ci.
- useful when build fails
-
- Add output check for tiff2ps.
- note : the reference files have been generated in master branch
-
-2019-03-23 Even Rouault <even.rouault@spatialys.com>
-
- tif_read.c: potentially fix false positive from Coverity Scan. CID 1400288
-
- tif_read.c: potentially fix false positive from Coverity Scan. CID 1400271
-
- tif_zip.c: remove dead code. CID 1400360.
-
- tif_webp.c: remove false positive warning about dereference before null check. CID 1400255
-
- tif_pixarlog.c: remove dead code. CID 1400342.
-
- tif_pixarlog.c: avoid false positive Coverity Scan warnings about overflow. CID 1400300 and 1400367
-
- tif_lzw.c: silence CoverityScan false positive. CID 1400355.
-
- tif_luv.c: silence CoverityScan false positive. CID 1400231, 1400251, 1400254, 1400272, 1400318, 1400356
-
- TryChopUpUncompressedBigTiff(): avoid potential division by zero. master only. GDAL Coverity CID 1400263
-
-2019-03-22 Thomas Bernard <miniupnp@free.fr>
-
- tif_luv.c: LogLuvSetupEncode() error must return 0.
- see http://bugzilla.maptools.org/show_bug.cgi?id=2848
-
- if wrongly returning 1, the processing of incorrect file continues,
- which causes problems.
-
-2019-03-22 Thomas Bernard <miniupnp@free.fr>
-
- add a test for fax2tiff tool.
-
-2019-02-28 Thomas Bernard <miniupnp@free.fr>
-
- tiff2pdf.c: don't call t2p_tile_collapse_left() when buffer size is wrong
- see http://bugzilla.maptools.org/show_bug.cgi?id=2785
-
- Advertise https://libtiff.gitlab.io/libtiff/ as mirror.
- I'm put it above the maptools.org mirror because
- Even Rouault believe at some point it will be completely removed
-
-2019-02-28 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'bug_2826' into 'master'
- tiff2pdf.c: check colormap pointers when loading CMYK with colormap
-
- See merge request libtiff/libtiff!65
-
-2019-02-28 Thomas Bernard <miniupnp@free.fr>
-
- tiff2pdf.c: check colormap pointers.
- Avoid access to non initialized pointers
- http://bugzilla.maptools.org/show_bug.cgi?id=2826
-
-2019-02-27 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_warnings' into 'master'
- tiff2ps.c: fix warning caused by integer promotion
-
- See merge request libtiff/libtiff!68
-
-2019-02-23 Thomas Bernard <miniupnp@free.fr>
-
- PSDataColorContig(): avoid heap buffer overrun.
- fixes http://bugzilla.maptools.org/show_bug.cgi?id=2844
- each iteration of the loop read nc bytes
-
-2019-02-22 Thomas Bernard <miniupnp@free.fr>
-
- tiff2ps.c: fix warning caused by integer promotion.
- uint8 value is promoted to int in (value << 24) so -fsanitize
- yield runtime errors :
- tiff2ps.c:2969:33: runtime error: left shift of 246 by 24 places cannot be represented in type 'int'
-
-2019-02-22 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'large_strile_improvements' into 'master'
- Large strile support improvements
-
- See merge request libtiff/libtiff!63
-
-2019-02-21 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'gitlab-pages' into 'master'
- ci: Add pages job
-
- See merge request libtiff/libtiff!45
-
-2019-02-19 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue_2833' into 'master'
- tiffcp.c: check that (Tile Width)*(Samples/Pixel) do no overflow
-
- See merge request libtiff/libtiff!60
-
-2019-02-19 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue_2831' into 'master'
- tiffcrop.c: fix invertImage() for bps 2 and 4
-
- See merge request libtiff/libtiff!61
-
-2019-02-19 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'issue_2842' into 'master'
- move _TIFFClampDoubleToFloat() to tif_aux.c
-
- See merge request libtiff/libtiff!62
-
-2019-02-19 Even Rouault <even.rouault@spatialys.com>
-
- tif_zip.c: allow reading and writing strips/tiles with more than 4 GB of compressed or uncompressed data
-
- tif_dirread.c: when strip chopping is enabled, extend this mechanism to multi-strip uncompressed files with strips larger than 2GB to expose them as strips of ~500 MB
-
-2019-02-19 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'size_t_typo' into 'master'
- CMakeLists.txt: fix TIFF_SIZE_T
-
- See merge request libtiff/libtiff!59
-
-2019-02-12 Thomas Bernard <miniupnp@free.fr>
-
- move _TIFFClampDoubleToFloat() to tif_aux.c.
- the same function was declared in tif_dir.c and tif_dirwrite.c
-
- see http://bugzilla.maptools.org/show_bug.cgi?id=2842
-
-2019-02-11 Thomas Bernard <miniupnp@free.fr>
-
- tiffcrop.c: fix invertImage() for bps 2 and 4.
- too much bytes were processed, causing a heap buffer overrun
- http://bugzilla.maptools.org/show_bug.cgi?id=2831
- the loop counter must be
- for (col = 0; col < width; col += 8 / bps)
-
- Also the values were not properly calculated. It should be
- 255-x, 15-x, 3-x for bps 8, 4, 2.
-
- But anyway it is easier to invert all bits as 255-x = ~x, etc.
- (subtracting from a binary number composed of all 1 is like inverting
- the bits)
-
-2019-02-11 Thomas Bernard <miniupnp@free.fr>
-
- tiffcp.c: use INT_MAX.
-
- check that (Tile Width)*(Samples/Pixel) do no overflow.
- fixes bug 2833
-
-2019-02-03 Thomas Bernard <miniupnp@free.fr>
-
- CMakeLists.txt: fix TIFF_SIZE_T.
-
-2019-02-02 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'master' into 'master'
- Fix for simple memory leak that was assigned CVE-2019-6128.
-
- See merge request libtiff/libtiff!50
-
-2019-02-02 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'bug2835' into 'master'
- tiff2ps: fix heap-buffer-overflow
-
- See merge request libtiff/libtiff!53
-
-2019-02-02 Even Rouault <even.rouault@spatialys.com>
-
- Fix warning (use of uninitialized value) added per d0a842c5dbad2609aed43c701a12ed12461d3405 (fixes https://gitlab.com/libtiff/libtiff/merge_requests/54#note_137742985)
-
-2019-02-02 Yuri Aksenov <yuri.aksenov@gmail.com>
-
- fix fax2tiff.
- see http://bugzilla.maptools.org/show_bug.cgi?id=2799
- fixes d9bc8472e72549f29c0062c1cbd3d56f279f3be2
-
-2019-02-02 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tiffcrop' into 'master'
- tiffcrop: shut up clang warnings
-
- See merge request libtiff/libtiff!52
-
-2019-02-01 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'bug2833' into 'master'
- TIFFWriteDirectoryTagTransferfunction() : fix NULL dereferencing
-
- See merge request libtiff/libtiff!54
-
-2019-02-01 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'gitignore' into 'master'
- add test/ files to .gitignore
-
- See merge request libtiff/libtiff!56
-
-2019-02-01 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'master' into 'master'
- tif_dir: unset transferfunction field if necessary (CVE-2018-19210)
-
- See merge request libtiff/libtiff!47
-
-2019-01-29 Thomas Bernard <miniupnp@free.fr>
-
- add test/ files to .gitignore.
-
-2019-01-29 Thomas Bernard <miniupnp@free.fr>
-
- TIFFWriteDirectoryTagTransferfunction() : fix NULL dereferencing.
- http://bugzilla.maptools.org/show_bug.cgi?id=2833
-
- we must check the pointer is not NULL before memcmp() the memory
-
-2019-01-29 Thomas Bernard <miniupnp@free.fr>
-
- tiff2ps: fix heap-buffer-overflow.
- http://bugzilla.maptools.org/show_bug.cgi?id=2834
-
- usually the test (i < byte_count) is OK because the byte_count is divisible by samplesperpixel.
- But if that is not the case, (i + ncomps) < byte_count should be used, or
- maybe (i + samplesperpixel) <= byte_count
-
-2019-01-28 Thomas Bernard <miniupnp@free.fr>
-
- tiffcrop: shut up clang warnings.
- make the out filename building a bit more simple
- and remove the use of strcat()
-
-2019-01-23 Scott Gayou <github.scott@gmail.com>
-
- Fix for simple memory leak that was assigned CVE-2019-6128.
- pal2rgb failed to free memory on a few errors. This was reported
- here: http://bugzilla.maptools.org/show_bug.cgi?id=2836.
-
-2019-01-05 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- Fix tiff2ps error regarding "Inconsistent value of es" by allowing es to be zero. Problem was reported to the tiff mailing list by Julian H. Stacey on January 5, 2019.
-
-2018-12-13 Hugo Lefeuvre <hle@debian.org>
-
- tif_dir: unset transferfunction field if necessary.
- The number of entries in the transfer table is determined as following:
-
- (td->td_samplesperpixel - td->td_extrasamples) > 1 ? 3 : 1
-
- This means that whenever td->td_samplesperpixel or td->td_extrasamples are
- modified we also need to make sure that the number of required entries in
- the transfer table didn't change.
-
- If it changed and the number of entries is higher than before we should
- invalidate the transfer table field and free previously allocated values.
- In the other case there's nothing to do, additional tf entries won't harm
- and properly written code will just ignore them since spp - es < 1.
-
- For instance this situation might happen when reading an OJPEG compressed
- image with missing SamplesPerPixel tag. In this case the SamplesPerPixel
- field might be updated after setting the transfer table.
-
- see http://bugzilla.maptools.org/show_bug.cgi?id=2500
-
- This commit addresses CVE-2018-19210.
-
-2018-12-08 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- Do not attempt to re-sync zip stream after reported data error from inflate().
-
-2018-12-07 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'resource-leaks' into 'master'
- Fix two resource leaks
-
- See merge request libtiff/libtiff!43
-
-2018-12-07 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'build-jbig' into 'master'
- add jbig support to the fuzzer
-
- See merge request libtiff/libtiff!42
-
-2018-12-01 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- tiffcrop.c: Avoid new clang warning about tools/tiffcrop.c "size argument in 'strncat' call appears to be size of the source".
-
-2018-11-28 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'webp_memleak' into 'master'
- fixed mem leak in webp compression
-
- See merge request libtiff/libtiff!48
-
-2018-11-28 Norman Barker <norman.barker@mapbox.com>
-
- fixed mem leak in webp compression.
-
-2018-11-20 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'lossless_webp' into 'master'
- fixed lossless webp compression config
-
- See merge request libtiff/libtiff!46
-
-2018-11-20 Norman Barker <norman.barker@mapbox.com>
-
- fixed lossless webp compression config.
-
-2018-11-18 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- snprintf porting fix for Visual Studio 2003.
-
-2018-11-18 Roger Leigh <rleigh@codelibre.net>
-
- ci: Add pages job.
-
-2018-11-10 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- Change references from defunct ftp site to https site.
-
-2018-11-10 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * configure.ac: libtiff 4.0.10 released.
-
- Change COMPRESSION_ZSTD to 50000 and COMPRESSION_WEBP to 50001.
-
-2018-11-04 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- Added preliminary release notes for release 4.0.10.
-
-2018-11-03 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- tiff2pdf: Eliminate compiler warning about snprintf output truncation when formatting pdf_datetime.
-
-2018-11-03 Olivier Paquet <olivier.paquet@gmail.com>
-
- Merge branch 'no_tif_platform_console' into 'master'
- Remove builtin support for GUI warning and error message boxes
-
- See merge request libtiff/libtiff!24
-
-2018-11-03 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- tiffcrop.c: Eliminate compiler warning about snprintf output truncation when formatting filenum.
-
- TWebPVGetField(): Add apparently missing break statement impacting TIFFTAG_WEBP_LOSSLESS.
-
- Eliminate compiler warnings about duplicate definitions of streq/strneq macros.
-
- Ignore generated files.
-
- Remove and ignore files which are a product of autogen.sh.
-
-2018-11-02 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- Fix TIFFErrorExt() formatting of size_t type for 32-bit compiles.
-
-2018-10-30 Even Rouault <even.rouault@spatialys.com>
-
- tiff2bw: avoid null pointer dereference in case of out of memory situation. Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2819 / CVE-2018-18661
-
- tiffio.h: fix comment.
-
-2018-10-26 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'header2' into 'master'
- Fix 725279bd: Standalone tif_predict.h: tiff.h should be tiffiop.h
-
- See merge request libtiff/libtiff!41
-
-2018-10-26 Kurt Schwehr <schwehr@google.com>
-
- Fix 725279bd: Standalone tif_predict.h: tiff.h should be tiffiop.h.
-
-2018-10-25 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'headers' into 'master'
- Add includes to headers to allow them to stand alone.
-
- See merge request libtiff/libtiff!40
-
-2018-10-24 Kurt Schwehr <schwehr@google.com>
-
- Add includes to headers to allow them to stand alone.
- This allows compilers that can do header stand alone header parsing
- to process libtiff.
-
-2018-10-18 Even Rouault <even.rouault@spatialys.com>
-
- LZMAPreEncode: emit verbose error if lzma_stream_encoder() fails (typically because not enough memory available)
-
-2018-10-17 Even Rouault <even.rouault@spatialys.com>
-
- tif_webp.c: fix previous commit that broke scanline decoding.
-
- tif_webp.c: fix potential read outside libwebp buffer on corrupted images
-
-2018-10-14 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'jbig_decode_overflow' into 'master'
- JBIG: fix potential out-of-bounds write in JBIGDecode()
-
- See merge request libtiff/libtiff!38
-
-2018-10-14 Even Rouault <even.rouault@spatialys.com>
-
- JBIG: fix potential out-of-bounds write in JBIGDecode()
- JBIGDecode doesn't check if the user provided buffer is large enough
- to store the JBIG decoded image, which can potentially cause out-of-bounds
- write in the buffer.
- This issue was reported and analyzed by Thomas Dullien.
-
- Also fixes a (harmless) potential use of uninitialized memory when
- tif->tif_rawsize > tif->tif_rawcc
-
- And in case libtiff is compiled with CHUNKY_STRIP_READ_SUPPORT, make sure
- that whole strip data is provided to JBIGDecode()
-
-2018-10-05 Even Rouault <even.rouault@spatialys.com>
-
- tif_webp.c: fix scanline reading/writing.
-
- WEBP codec: initialize nSamples in TWebPSetupDecode() and TWebPSetupEncode()
-
-2018-10-05 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'tif_webp' into 'master'
- webp support
-
- See merge request libtiff/libtiff!32
-
-2018-10-05 Norman Barker <norman.barker@mapbox.com>
-
- webp in tiff.
-
-2018-09-17 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'master' into 'master'
- fix three potential vulnerabilities.
-
- See merge request libtiff/libtiff!33
-
-2018-09-08 Young_X <YangX92@hotmail.com>
-
- fix out-of-bound read on some tiled images.
-
- avoid potential int32 overflows in multiply_ms()
-
- only read/write TIFFTAG_GROUP3OPTIONS or TIFFTAG_GROUP4OPTIONS if compression is COMPRESSION_CCITTFAX3 or COMPRESSION_CCITTFAX4
-
-2018-08-15 Even Rouault <even.rouault@spatialys.com>
-
- TIFFSetupStrips(): avoid potential uint32 overflow on 32-bit systems with large number of strips. Probably relates to http://bugzilla.maptools.org/show_bug.cgi?id=2788 / CVE-2018-10779
-
-2018-08-07 Even Rouault <even.rouault@spatialys.com>
-
- ZSTD: fix flush issue that can cause endless loop in ZSTDEncode()
- Fixes https://github.com/OSGeo/gdal/issues/833
-
-2018-08-07 Even Rouault <even.rouault@spatialys.com>
-
- Merge branch 'fix_bug_2800' into 'master'
- Fix libtiff 4.0.8 regression when reading LZW-compressed strips with scanline API
-
- See merge request libtiff/libtiff!31
-
-2018-08-07 Even Rouault <even.rouault@spatialys.com>
-
- Fix libtiff 4.0.8 regression when reading LZW-compressed strips with scanline API
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2800
-
-2018-07-05 Even Rouault <even.rouault@spatialys.com>
-
- Add tag and pseudo-tag definitions for ESRI LERC codec (out of tree codec whose source is at https://github.com/OSGeo/gdal/blob/master/gdal/frmts/gtiff/tif_lerc.c)
-
-2018-07-02 Even Rouault <even.rouault@spatialys.com>
-
- Fix TIFFTAG_ZSTD_LEVEL pseudo tag value to be > 65536, and the next one in the series
-
-2018-05-25 Stefan Weil <sw@weilnetz.de>
-
- Remove builtin support for GUI warning and error message boxes.
- Now warnings always go to the console by default unless applications
- define their own warning and error handlers.
-
- GUI applications (and Windows CE) are required to define such handlers.
-
-2018-05-12 Even Rouault <even.rouault@spatialys.com>
-
- LZWDecodeCompat(): fix potential index-out-of-bounds write. Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2780 / CVE-2018-8905
- The fix consists in using the similar code LZWDecode() to validate we
- don't write outside of the output buffer.
-
- TIFFFetchNormalTag(): avoid (probably false positive) clang-tidy clang-analyzer-core.NullDereference warnings
-
- TIFFWriteDirectorySec: avoid assertion. Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2795. CVE-2018-10963
-
-2018-05-04 Even Rouault <even.rouault@spatialys.com>
-
- tif_color.c: fix code comment.
-
-2018-04-17 Even Rouault <even.rouault@mines-paris.org>
-
- Merge branch 'fuzzer-fix' into 'master'
- remove a pointless multiplication and a variable that's not necessary
-
- See merge request libtiff/libtiff!29
-
-2018-04-17 Paul Kehrer <paul.l.kehrer@gmail.com>
-
- remove a pointless multiplication and a variable that's not necessary.
-
-2018-04-17 Even Rouault <even.rouault@mines-paris.org>
-
- Merge branch 'ossfuzz' into 'master'
- move oss-fuzz build script and fuzzer into libtiff tree
-
- See merge request libtiff/libtiff!28
-
-2018-04-17 Paul Kehrer <paul.l.kehrer@gmail.com>
-
- move oss-fuzz build script and fuzzer into libtiff tree.
-
-2018-04-14 Even Rouault <even.rouault@spatialys.com>
-
- _TIFFGetMaxColorChannels: update for LOGLUV, ITULAB and ICCLAB that have 3 color channels
-
-2018-04-12 Even Rouault <even.rouault@spatialys.com>
-
- Fix MSVC warning.
-
-2018-04-12 Even Rouault <even.rouault@mines-paris.org>
-
- Merge branch 'master' into 'master'
- Fix NULL pointer dereference in TIFFPrintDirectory (bugzilla 2778/CVE-2018-7456)
-
- See merge request libtiff/libtiff!27
-
-2018-04-11 Hugo Lefeuvre <hle@debian.org>
-
- Fix NULL pointer dereference in TIFFPrintDirectory.
- The TIFFPrintDirectory function relies on the following assumptions,
- supposed to be guaranteed by the specification:
-
- (a) A Transfer Function field is only present if the TIFF file has
- photometric type < 3.
-
- (b) If SamplesPerPixel > Color Channels, then the ExtraSamples field
- has count SamplesPerPixel - (Color Channels) and contains
- information about supplementary channels.
-
- While respect of (a) and (b) are essential for the well functioning of
- TIFFPrintDirectory, no checks are realized neither by the callee nor
- by TIFFPrintDirectory itself. Hence, following scenarios might happen
- and trigger the NULL pointer dereference:
-
- (1) TIFF File of photometric type 4 or more has illegal Transfer
- Function field.
-
- (2) TIFF File has photometric type 3 or less and defines a
- SamplesPerPixel field such that SamplesPerPixel > Color Channels
- without defining all extra samples in the ExtraSamples fields.
-
- In this patch, we address both issues with respect of the following
- principles:
-
- (A) In the case of (1), the defined transfer table should be printed
- safely even if it isn't 'legal'. This allows us to avoid expensive
- checks in TIFFPrintDirectory. Also, it is quite possible that
- an alternative photometric type would be developed (not part of the
- standard) and would allow definition of Transfer Table. We want
- libtiff to be able to handle this scenario out of the box.
-
- (B) In the case of (2), the transfer table should be printed at its
- right size, that is if TIFF file has photometric type Palette
- then the transfer table should have one row and not three, even
- if two extra samples are declared.
-
- In order to fulfill (A) we simply add a new 'i < 3' end condition to
- the broken TIFFPrintDirectory loop. This makes sure that in any case
- where (b) would be respected but not (a), everything stays fine.
-
- (B) is fulfilled by the loop condition
- 'i < td->td_samplesperpixel - td->td_extrasamples'. This is enough as
- long as (b) is respected.
-
- Naturally, we also make sure (b) is respected. This is done in the
- TIFFReadDirectory function by making sure any non-color channel is
- counted in ExtraSamples.
-
- This commit addresses CVE-2018-7456.
-
-2018-03-27 Even Rouault <even.rouault@mines-paris.org>
-
- Merge branch 'tiffset-long8' into 'master'
- tiffset: Add support for LONG8, SLONG8 and IFD8 field types
-
- See merge request libtiff/libtiff!25
-
-2018-03-26 Roger Leigh <rleigh@codelibre.net>
-
- port: Clean up NetBSD sources and headers to build standalone.
-
-2018-03-23 Roger Leigh <rleigh@dundee.ac.uk>
-
- port: Add strtol, strtoll and strtoull.
- Also update strtoul. All use the same implementation from NetBSD libc.
-
- tiffset: Add support for LONG8, SLONG8 and IFD8 field types.
-
-2018-03-17 Even Rouault <even.rouault@spatialys.com>
-
- ChopUpSingleUncompressedStrip: avoid memory exhaustion (CVE-2017-11613)
- Rework fix done in 3719385a3fac5cfb20b487619a5f08abbf967cf8 to work in more
- cases like https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=6979.
- Credit to OSS Fuzz
-
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2724
-
-2018-03-13 Even Rouault <even.rouault@spatialys.com>
-
- libtiff/tif_luv.c: rewrite loops in a more readable way (to avoid false positive reports like http://bugzilla.maptools.org/show_bug.cgi?id=2779)
-
-2018-03-13 Even Rouault <even.rouault@mines-paris.org>
-
- Merge branch 'avoid_memory_exhaustion_in_ChopUpSingleUncompressedStrip' into 'master'
- ChopUpSingleUncompressedStrip: avoid memory exhaustion (CVE-2017-11613)
-
- See merge request libtiff/libtiff!26
-
-2018-03-11 Even Rouault <even.rouault@spatialys.com>
-
- ChopUpSingleUncompressedStrip: avoid memory exhaustion (CVE-2017-11613)
- In ChopUpSingleUncompressedStrip(), if the computed number of strips is big
- enough and we are in read only mode, validate that the file size is consistent
- with that number of strips to avoid useless attempts at allocating a lot of
- memory for the td_stripbytecount and td_stripoffset arrays.
-
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2724
-
-2018-03-10 Even Rouault <even.rouault@spatialys.com>
-
- Typo fix in comment.
-
-2018-03-03 Even Rouault <even.rouault@spatialys.com>
-
- Avoid warning with gcc 8 (partially revert 647b0e8c11ee11896f319b92cf110775f538d75c)
-
-2018-02-25 Even Rouault <even.rouault@mines-paris.org>
-
- Merge branch 'typos' into 'master'
- Fix some typos
-
- See merge request libtiff/libtiff!23
-
-2018-02-24 Stefan Weil <sw@weilnetz.de>
-
- Fix some typos.
- Most of them were found by codespell.
-
-2018-02-14 Even Rouault <even.rouault@spatialys.com>
-
- Typo fix in comment.
-
- Merge branch 'zstd'
-
- Add warning about COMPRESSION_ZSTD not being officially registered.
-
-2018-02-14 Even Rouault <even.rouault@mines-paris.org>
-
- Merge branch 'bug2772' into 'master'
- Fix for bug 2772
-
- See merge request libtiff/libtiff!20
-
-2018-02-12 Nathan Baker <nathanb@lenovo-chrome.com>
-
- Fix for bug 2772.
- It is possible to craft a TIFF document where the IFD list is circular,
- leading to an infinite loop while traversing the chain. The libtiff
- directory reader has a failsafe that will break out of this loop after
- reading 65535 directory entries, but it will continue processing,
- consuming time and resources to process what is essentially a bogus TIFF
- document.
-
- This change fixes the above behavior by breaking out of processing when
- a TIFF document has >= 65535 directories and terminating with an error.
-
-2018-02-09 Even Rouault <even.rouault@mines-paris.org>
-
- Merge branch 'libtiff-as-subdirectory-fixes' into 'master'
- Prefer target_include_directories
-
- See merge request libtiff/libtiff!12
-
-2018-02-06 Even Rouault <even.rouault@mines-paris.org>
-
- Merge branch 'cmake-cleanups' into 'master'
- Cmake cleanups
-
- See merge request libtiff/libtiff!11
-
-2018-02-06 Even Rouault <even.rouault@mines-paris.org>
-
- Merge branch 'check-right-cxx-variable' into 'master'
- Check right cxx variable
-
- See merge request libtiff/libtiff!19
-
-2018-02-06 Even Rouault <even.rouault@mines-paris.org>
-
- Merge branch 'dont-leak-stream-open' into 'master'
- Fix a memory leak in TIFFStreamOpen
-
- See merge request libtiff/libtiff!17
-
-2018-02-06 Ben Boeckel <ben.boeckel@kitware.com>
-
- cmake: check CXX_SUPPORT.
- This variable is set in response to the `cxx` cache variable; use it
- instead.
-
-2018-02-04 Olivier Paquet <olivier.paquet@gmail.com>
-
- Merge branch 'warnings' into 'master'
- Fix all compiler warnings for default build
-
- See merge request libtiff/libtiff!16
-
-2018-02-04 Nathan Baker <elitebadger@gmail.com>
-
- Fix all compiler warnings for default build.
-
-2018-01-30 Paul Kehrer <paul.l.kehrer@gmail.com>
-
- tabs are hard.
-
-2018-01-29 Paul Kehrer <paul.l.kehrer@gmail.com>
-
- use hard tabs like the rest of the project.
-
- Fix a memory leak in TIFFStreamOpen.
- TIFFStreamOpen allocates a new tiff{o,i}s_data, but if TIFFClientOpen
- fails then that struct is leaked. Delete it if the returned TIFF * is
- null.
-
-2018-01-29 Kevin Funk <kfunk@kde.org>
-
- Bump minimum required CMake version to v2.8.11.
- Because we use the BUILD_INTERFACE generator expression
-
-2018-01-27 Even Rouault <even.rouault@mines-paris.org>
-
- Merge branch 'patch-1' into 'master'
- Update CMakeLists.txt for build fix on Windows
-
- See merge request libtiff/libtiff!14
-
-2018-01-27 Even Rouault <even.rouault@mines-paris.org>
-
- Merge branch 'patch-2' into 'master'
- Update tiffgt.c for build fix on Windows
-
- See merge request libtiff/libtiff!13
-
-2018-01-25 Olivier Paquet <olivier.paquet@gmail.com>
-
- Merge branch 'bug2750' into 'master'
- Add workaround to pal2rgb buffer overflow.
-
- See merge request libtiff/libtiff!15
-
-2018-01-25 Nathan Baker <elitebadger@gmail.com>
-
- Add workaround to pal2rgb buffer overflow.
-
-2018-01-23 Andrea <andrea@andreaplanet.com>
-
- Update tiffgt.c for build fix on Windows.
-
- Update CMakeLists.txt for build fix on Windows.
-
-2018-01-15 Even Rouault <even.rouault@mines-paris.org>
-
- Merge branch 'has-attribute-check' into 'master'
- tiffiop: use __has_attribute to detect the no_sanitize attribute
-
- See merge request libtiff/libtiff!10
-
-2018-01-15 Ben Boeckel <ben.boeckel@kitware.com>
-
- cmake: avoid setting hard-coded variables in the cache.
-
- cmake: avoid an unnecessary intermediate variable.
-
- cmake: avoid an unnecessary intermediate variable.
-
- cmake: avoid tautological logic.
-
- cmake: use check_symbol_exists.
- This accounts for symbols being provided by macros.
-
- cmake: remove unused configure checks.
-
-2018-01-12 Kevin Funk <kfunk@kde.org>
-
- Prefer target_include_directories.
- When libtiff is included in a super project via a simple
- `add_subdirectory(libtiff)`, this way the `tiff` library target has all
- the necessary information to build against it.
-
- Note: The BUILD_INTERFACE generator expression feature requires at least
- CMake v2.8.11 if I'm correct.
-
-2018-01-09 Ben Boeckel <ben.boeckel@kitware.com>
-
- tiffiop: use __has_attribute to detect the no_sanitize attribute.
-
-2017-12-31 Even Rouault <even.rouault@spatialys.com>
-
- man/TIFFquery.3tiff: remove reference to non-existing TIFFReadStrip() function in TIFFIsByteSwapped() documentation. Patch by Eric Piel. Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2763
-
- libtiff/tif_dir.c: _TIFFVGetField(): fix heap out-of-bounds access when requesting TIFFTAG_NUMBEROFINKS on a EXIF directory. Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2765. Reported by Google Autofuzz project
-
- libtiff/tif_print.c: TIFFPrintDirectory(): fix null pointer dereference on corrupted file. Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2770
-
-2017-12-21 Even Rouault <even.rouault@spatialys.com>
-
- Add libzstd to gitlab-ci.
-
-2017-12-21 Even Rouault <even.rouault@spatialys.com>
-
- Add ZSTD compression codec.
- From https://github.com/facebook/zstd
- "Zstandard, or zstd as short version, is a fast lossless compression
- algorithm, targeting real-time compression scenarios at zlib-level
- and better compression ratios. It's backed by a very fast entropy stage,
- provided by Huff0 and FSE library."
-
- We require libzstd >= 1.0.0 so as to be able to use streaming compression
- and decompression methods.
-
- The default compression level we have selected is 9 (range goes from 1 to 22),
- which experimentally offers equivalent or better compression ratio than
- the default deflate/ZIP level of 6, and much faster compression.
-
- For example on a 6600x4400 16bit image, tiffcp -c zip runs in 10.7 seconds,
- while tiffcp -c zstd runs in 5.3 seconds. Decompression time for zip is
- 840 ms, and for zstd 650 ms. File size is 42735936 for zip, and
- 42586822 for zstd. Similar findings on other images.
-
- On a 25894x16701 16bit image,
-
- Compression time Decompression time File size
-
- ZSTD 35 s 3.2 s 399 700 498
- ZIP/Deflate 1m 20 s 4.9 s 419 622 336
-
-2017-12-10 Even Rouault <even.rouault@mines-paris.org>
-
- Merge branch 'fix_cve-2017-9935' into 'master'
- Fix CVE-2017-9935
-
- See merge request libtiff/libtiff!7
-
-2017-12-10 Brian May <brian@linuxpenguins.xyz>
-
- tiff2pdf: Fix apparent incorrect type for transfer table.
- The standard says the transfer table contains unsigned 16 bit values,
- I have no idea why we refer to them as floats.
-
-2017-12-10 Brian May <brian@linuxpenguins.xyz>
-
- tiff2pdf: Fix CVE-2017-9935.
- Fix for http://bugzilla.maptools.org/show_bug.cgi?id=2704
-
- This vulnerability - at least for the supplied test case - is because we
- assume that a tiff will only have one transfer function that is the same
- for all pages. This is not required by the TIFF standards.
-
- We than read the transfer function for every page. Depending on the
- transfer function, we allocate either 2 or 4 bytes to the XREF buffer.
- We allocate this memory after we read in the transfer function for the
- page.
-
- For the first exploit - POC1, this file has 3 pages. For the first page
- we allocate 2 extra extra XREF entries. Then for the next page 2 more
- entries. Then for the last page the transfer function changes and we
- allocate 4 more entries.
-
- When we read the file into memory, we assume we have 4 bytes extra for
- each and every page (as per the last transfer function we read). Which
- is not correct, we only have 2 bytes extra for the first 2 pages. As a
- result, we end up writing past the end of the buffer.
-
- There are also some related issues that this also fixes. For example,
- TIFFGetField can return uninitialized pointer values, and the logic to
- detect a N=3 vs N=1 transfer function seemed rather strange.
-
- It is also strange that we declare the transfer functions to be of type
- float, when the standard says they are unsigned 16 bit values. This is
- fixed in another patch.
-
- This patch will check to ensure that the N value for every transfer
- function is the same for every page. If this changes, we abort with an
- error. In theory, we should perhaps check that the transfer function
- itself is identical for every page, however we don't do that due to the
- confusion of the type of the data in the transfer function.
-
-2017-12-10 Even Rouault <even.rouault@mines-paris.org>
-
- Merge branch 'undef-warn-fixes' into 'master'
- Fix a couple of harmless but annoying -Wundef warnings
-
- See merge request libtiff/libtiff!8
-
-2017-12-07 Vadim Zeitlin <vadim@zeitlins.org>
-
- Remove tests for undefined SIZEOF_VOIDP.
- As configure never uses AC_CHECK_SIZEOF(void*), this symbol is never
- defined and so it doesn't make sense to test it in the code, this just
- results in -Wundef warnings if they're enabled.
-
- Avoid harmless -Wundef warnings for __clang_major__
- Check that we're using Clang before checking its version.
-
-2017-12-02 Even Rouault <even.rouault@mines-paris.org>
-
- Merge branch 'remove_autogenerated_files' into 'master'
- Remove autogenerated files
-
- See merge request libtiff/libtiff!5
-
-2017-12-02 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- Merge branch 'tif_config_h_includes' into 'master'
- 'tif_config.h' or 'tiffiop.h' must be included before any system header.
-
- See merge request libtiff/libtiff!6
-
-2017-12-02 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- 'tif_config.h' or 'tiffio.h' must be included before any system header.
-
-2017-12-01 Even Rouault <even.rouault@spatialys.com>
-
- .gitignore: add patterns for build from root.
-
- Remove remaining .cvsignore files.
-
- Remove autoconf/automake generated files, and add them to .gitignore.
-
-2017-12-01 Olivier Paquet <olivier.paquet@gmail.com>
-
- Merge branch 'makedistcheck' into 'master'
- build/gitlab-ci and build/travis-ci: add a 'make dist' step in autoconf_build()…
-
- See merge request libtiff/libtiff!4
-
-2017-12-01 Even Rouault <even.rouault@spatialys.com>
-
- build/gitlab-ci and build/travis-ci: add a 'make dist' step in autoconf_build() target, to check we are release-ready
-
-2017-12-01 Even Rouault <even.rouault@mines-paris.org>
-
- Merge branch 'git_updates' into 'master'
- CVS to Git updates
-
- See merge request libtiff/libtiff!2
-
-2017-12-01 Even Rouault <even.rouault@spatialys.com>
-
- HOWTO-RELEASE: update to use signed tags.
-
- README.md: use markdown syntax for hyperlinks.
-
-2017-11-30 Even Rouault <even.rouault@spatialys.com>
-
- Add .gitignore.
-
- Regenerate autoconf files.
-
- Makefile.am: update to reflect removal of README.vms and README -> README.md
-
- Remove all $Id and $Headers comments with CVS versions.
-
- HOWTO-RELEASE: update for git.
-
- Remove outdated .cvsignore.
-
- Remove outdated commit script.
-
- Remove README.vms.
-
- Rename README as README.md, and update content.
-
- html/index.html: reflect change from CVS to gitlab.
-
-2017-11-30 Olivier Paquet <olivier.paquet@gmail.com>
-
- Merge branch 'test-ci' into 'master'
- Update CI configuration
-
- See merge request libtiff/libtiff!1
-
-2017-11-23 Roger Leigh <rleigh@codelibre.net>
-
- appveyor: Correct path for git clone and skip artifact archival.
-
-2017-11-22 Roger Leigh <rleigh@codelibre.net>
-
- travis-ci: Remove unused matrix exclusion.
-
- Add gitlab-ci build support.
-
-2017-11-18 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * configure.ac: libtiff 4.0.9 released.
-
- * html/v4.0.9.html: Add HTML file to document changes in libtiff
- v4.0.9.
-
-2017-11-17 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_aux.c, tif_getimage.c, tif_read.c: typo fixes in
- comments.
-
-2017-11-02 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * test/Makefile.am: Add some tests for tiff2bw.
-
-2017-11-01 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * tools/tiff2bw.c (main): Free memory allocated in the tiff2bw
- program. This is in response to the report associated with
- CVE-2017-16232 but does not solve the extremely high memory usage
- with the associated POC file.
-
-2017-10-29 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * tools/tiff2pdf.c (t2p_sample_realize_palette): Fix possible
- arithmetic overflow in bounds checking code and eliminate
- comparison between signed and unsigned type.
-
- * tools/fax2tiff.c (_FAX_Client_Data): Pass FAX_Client_Data as the
- client data. This client data is not used at all at the moment,
- but it makes the most sense. Issue that the value of
- client_data.fd was passed where a pointer is expected was reported
- via email by Gerald Schade on Sun, 29 Oct 2017.
-
-2017-10-23 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_getimage.c: avoid floating point division by zero in
- initCIELabConversion()
- Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=3733
- Credit to OSS Fuzz
-
-2017-10-17 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_jpeg.c: add compatibility with libjpeg-turbo 1.5.2 that
- honours max_memory_to_use > 0.
- Cf https://github.com/libjpeg-turbo/libjpeg-turbo/issues/162
-
-2017-10-10 Even Rouault <even.rouault at spatialys.com>
-
- * nmake.opt: support a DEBUG=1 option, so as to adjust OPTFLAGS and use
- /MDd runtime in debug mode.
-
-2017-10-01 Even Rouault <even.rouault at spatialys.com>
-
- * tools/tiffset.c: fix setting a single value for the ExtraSamples tag
- (and other tags with variable number of values).
- So 'tiffset -s ExtraSamples 1 X'. This only worked
- when setting 2 or more values, but not just one.
-
-2017-09-29 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/libtiff.def: add TIFFReadRGBAStripExt and TIFFReadRGBATileExt
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2735
-
-2017-09-09 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_dirread.c: add NULL check to avoid likely false positive
- null-pointer dereference warning by CLang Static Analyzer.
-
-2017-09-07 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tiffiop.h, tif_aux.c: redirect SeekOK() macro to a _TIFFSeekoK()
- function that checks if the offset is not bigger than INT64_MAX, so as
- to avoid a -1 error return code of TIFFSeekFile() to match a required
- seek to UINT64_MAX/-1.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2726
- Adapted from proposal by Nicolas Ruff.
-
-2017-08-29 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_jpeg.c: accept reading the last strip of a JPEG compressed
- file if the codestream height is larger than the truncated height of the
- strip. Emit a warning in this situation since this is non compliant.
-
-2017-08-28 Even Rouault <even.rouault at spatialys.com>
-
- * test/Makefile.am: add missing reference to images/quad-lzw-compat.tiff
- to fix "make distcheck". Patch by Roger Leigh
-
-2017-08-23 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_dirwrite.c: replace assertion to tag value not fitting
- on uint32 when selecting the value of SubIFD tag by runtime check
- (in TIFFWriteDirectoryTagSubifd()).
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2728
- Reported by team OWL337
-
-2017-08-23 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_dirwrite.c: replace assertion related to not finding the
- SubIFD tag by runtime check (in TIFFWriteDirectorySec())
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2727
- Reported by team OWL337
-
-2017-07-24 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_luv.c: further reduce memory requirements for temporary
- buffer when RowsPerStrip >= image_length in LogLuvInitState() and
- LogL16InitState().
- Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2700
- Credit to OSS Fuzz
-
-2017-07-24 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_getimage.c: fix fromskew computation when to-be-skipped
- pixel number is not a multiple of the horizontal subsampling, and
- also in some other cases. Impact putcontig8bitYCbCr44tile,
- putcontig8bitYCbCr42tile, putcontig8bitYCbCr41tile,
- putcontig8bitYCbCr21tile and putcontig8bitYCbCr12tile
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2637 (discovered
- by Agostino Sarubbo)
- and https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2691 (credit
- to OSS Fuzz)
-
-2017-07-24 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_getimage.c: gtTileContig() and gtTileSeparate():
- properly break from loops on error when stoponerr is set, instead
- of going on iterating on row based loop.
-
-2017-07-18 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_luv.c: LogLuvInitState(): avoid excessive memory
- allocation when RowsPerStrip tag is missing.
- Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2683
- Credit to OSS-Fuzz
-
-2017-07-15 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_read.c: add protection against excessive memory
- allocation attempts in TIFFReadDirEntryArray() on short files.
- Effective for mmap'ed case. And non-mmap'ed case, but restricted
- to 64bit builds.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2675
-
-2017-07-15 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_read.c: in TIFFFetchStripThing(), only grow the
- arrays that hold StripOffsets/StripByteCounts, when they are smaller
- than the expected number of striles, up to 1 million striles, and
- error out beyond. Can be tweaked by setting the environment variable
- LIBTIFF_STRILE_ARRAY_MAX_RESIZE_COUNT.
- This partially goes against a change added on 2002-12-17 to accept
- those arrays of wrong sizes, but is needed to avoid denial of services.
- Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2350
- Credit to OSS Fuzz
-
-2017-07-15 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_read.c: TIFFFillStrip() / TIFFFillTile().
- Complementary fix for http://bugzilla.maptools.org/show_bug.cgi?id=2708
- in the isMapped() case, so as to avoid excessive memory allocation
- when we need a temporary buffer but the file is truncated.
-
-2017-07-15 Even Rouault <even.rouault at spatialys.com>
-
- * tools/tiff2pdf.c: prevent heap buffer overflow write in "Raw"
- mode on PlanarConfig=Contig input images.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2715
- Reported by team OWL337
-
-2017-07-11 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_dir.c: avoid potential null pointer dereference in
- _TIFFVGetField() on corrupted TIFFTAG_NUMBEROFINKS tag instance.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2713
-
-2017-07-11 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_lzw.c: fix potential out-of-buffer read on 1-byte LZW
- strips. Crashing issue only on memory mapped files, where the strip
- offset is the last byte of the file, and the file size is a multiple
- of one page size on the CPU architecture (typically 4096). Credit
- to myself :-)
-
-2017-07-11 Even Rouault <even.rouault at spatialys.com>
-
- * test/tiffcp-lzw-compat.sh, test/images/quad-lzw-compat.tiff: new files
- to test old-style LZW decompression
- * test/common.sh, Makefile.am, CMakeList.txt: updated with above
-
-2017-07-11 Even Rouault <even.rouault at spatialys.com>
-
- * refresh autoconf/make stuff with what is on Ubuntu 16.04 (minor changes)
-
-2017-07-11 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_lzw.c: fix 4.0.8 regression in the decoding of old-style LZW
- compressed files.
-
-2017-07-10 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_pixarlog.c: avoid excessive memory allocation on decoding
- when RowsPerStrip tag is not defined (and thus td_rowsperstrip == UINT_MAX)
- Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2554
- Credit to OSS Fuzz
-
-2017-07-04 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_read.c, tiffiop.h: add a _TIFFReadEncodedTileAndAllocBuffer()
- and _TIFFReadTileAndAllocBuffer() variants of TIFFReadEncodedTile() and
- TIFFReadTile() that allocates the decoded buffer only after a first
- successful TIFFFillTile(). This avoids excessive memory allocation
- on corrupted files.
- * libtiff/tif_getimage.c: use _TIFFReadTileAndAllocBuffer().
- Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2470
- Credit to OSS Fuzz.
-
-2017-07-04 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_error.c, tif_warning.c: correctly use va_list when both
- an old-style and new-style warning/error handlers are installed.
- Patch by Paavo Helde (sent on the mailing list)
-
-2017-07-02 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_read.c: TIFFStartTile(): set tif_rawcc to
- tif_rawdataloaded when it is set. Similarly to TIFFStartStrip().
- This issue was revealed by the change of 2017-06-30 in TIFFFileTile(),
- limiting the number of bytes read. But it could probably have been hit
- too in CHUNKY_STRIP_READ_SUPPORT mode previously ?
- Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2454
- Credit to OSS Fuzz
-
-2017-06-30 Even Rouault <even.rouault at spatialys.com>
-
- * man: update documentation regarding SubIFD tag and
- TIFFSetSubDirectory() data type.
- Patch by Eric Piel
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2671
-
-2017-06-30 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_dirwrite.c: in TIFFWriteDirectoryTagCheckedXXXX()
- functions associated with LONG8/SLONG8 data type, replace assertion that
- the file is BigTIFF, by a non-fatal error.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2712
- Reported by team OWL337
-
-2017-06-30 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_read.c, tiffiop.h: add a _TIFFReadEncodedStripAndAllocBuffer()
- function, variant of TIFFReadEncodedStrip() that allocates the
- decoded buffer only after a first successful TIFFFillStrip(). This avoids
- excessive memory allocation on corrupted files.
- * libtiff/tif_getimage.c: use _TIFFReadEncodedStripAndAllocBuffer().
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2708 and
- https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2433 .
- Credit to OSS Fuzz
-
-2017-06-30 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_read.c: TIFFFillTile(): add limitation to the number
- of bytes read in case td_stripbytecount[strip] is bigger than
- reasonable, so as to avoid excessive memory allocation (similarly to
- what was done for TIFFFileStrip() on 2017-05-10)
-
-2017-06-29 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tiffiop.h, libtiff/tif_jpeg.c, libtiff/tif_jpeg_12.c,
- libtiff/tif_read.c: make TIFFReadScanline() works in
- CHUNKY_STRIP_READ_SUPPORT mode with JPEG stream with multiple scans.
- Also make configurable through a LIBTIFF_JPEG_MAX_ALLOWED_SCAN_NUMBER
- environment variable the maximum number of scans allowed. Defaults to
- 100.
-
-2017-06-27 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_dirread.c: in TIFFReadDirEntryFloat(), check that a
- double value can fit in a float before casting. Patch by Nicolas RUFF
-
-2017-06-26 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_jbig.c: fix memory leak in error code path of JBIGDecode()
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2706
- Reported by team OWL337
-
-2017-06-24 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_jpeg.c: error out at decoding time if anticipated libjpeg
- memory allocation is above 100 MB. libjpeg in case of multiple scans,
- which is allowed even in baseline JPEG, if components are spread over several
- scans and not interleavedin a single one, needs to allocate memory (or
- backing store) for the whole strip/tile.
- See http://www.libjpeg-turbo.org/pmwiki/uploads/About/TwoIssueswiththeJPEGStandard.pdf
- This limitation may be overridden by setting the
- LIBTIFF_ALLOW_LARGE_LIBJPEG_MEM_ALLOC environment variable, or recompiling
- libtiff with a custom value of TIFF_LIBJPEG_LARGEST_MEM_ALLOC macro.
-
-2017-06-24 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_jpeg.c: add anti-denial of service measure to avoid excessive
- CPU consumption on progressive JPEGs with a huge number of scans.
- See http://www.libjpeg-turbo.org/pmwiki/uploads/About/TwoIssueswiththeJPEGStandard.pdf
- Note: only affects libtiff since 2014-12-29 where support of non-baseline JPEG
- was added.
-
-2017-06-18 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tiffiop.h: add TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW macro to
- disable CLang warnings raised by -fsanitize=undefined,unsigned-integer-overflow
- * libtiff/tif_predict.c: decorate legitimate functions where unsigned int
- overflow occur with TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW
- * libtiff/tif_dirread.c: avoid unsigned int overflow in EstimateStripByteCounts()
- and BYTECOUNTLOOKSBAD when file is too short.
- * libtiff/tif_jpeg.c: avoid (harmless) unsigned int overflow on tiled images.
- * libtiff/tif_fax3.c: avoid unsigned int overflow in Fax3Encode2DRow(). Could
- potentially be a bug with huge rows.
- * libtiff/tif_getimage.c: avoid many (harmless) unsigned int overflows.
-
-2017-06-12 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_dirread.c: TIFFFetchStripThing(): limit the number of items
- read in StripOffsets/StripByteCounts tags to the number of strips to avoid
- excessive memory allocation.
- Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2215
- Credit to OSS Fuzz
-
-2017-06-12 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_dirread.c: fix regression of libtiff 4.0.8 in
- ChopUpSingleUncompressedStrip() regarding update of newly single-strip
- uncompressed files whose bytecount is 0. Before the change of 2016-12-03,
- the condition bytecount==0 used to trigger an early exit/disabling of
- strip chop. Re-introduce that in update mode. Otherwise this cause
- later incorrect setting for the value of StripByCounts/StripOffsets.
- ( https://trac.osgeo.org/gdal/ticket/6924 )
-
-2017-06-10 Even Rouault <even.rouault at spatialys.com>
-
- * .appveyor.yml, .travis.yml, build/travis-ci: apply patches
- 0001-ci-Travis-script-improvements.patch and
- 0002-ci-Invoke-helper-script-via-shell.patch by Roger Leigh
- (sent to mailing list)
-
-2017-06-08 Even Rouault <even.rouault at spatialys.com>
-
- * .travis.yml, build/travis-ci: new files from
- 0001-ci-Add-Travis-support-for-Linux-builds-with-Autoconf.patch by
- Roger Leigh (sent to mailing list on 2017-06-08)
- This patch adds support for the Travis-CI service.
-
- * .appveyor.yml: new file from
- 0002-ci-Add-AppVeyor-support.patch by Roger Leigh (sent to mailing
- list on 2017-06-08)
- This patch adds a .appveyor.yml file to the top-level. This allows
- one to opt in to having a branch built on Windows with Cygwin,
- MinGW and MSVC automatically when a branch is pushed to GitHub,
- GitLab, BitBucket or any other supported git hosting service.
-
- * CMakeLists.txt, test/CMakeLists.txt, test/TiffTestCommon.cmake: apply
- patch 0001-cmake-Improve-Cygwin-and-MingGW-test-support.patch from Roger
- Leigh (sent to mailing list on 2017-06-08)
- This patch makes the CMake build system support running the tests
- with MinGW or Cygwin.
-
-2017-06-08 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_swab.c: if DISABLE_CHECK_TIFFSWABMACROS is defined, do not do
- the #ifdef TIFFSwabXXX checks. Make it easier for GDAL to rename the symbols
- of its internal libtiff copy.
-
-2017-06-01 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_dirinfo.c, tif_dirread.c: add _TIFFCheckFieldIsValidForCodec(),
- and use it in TIFFReadDirectory() so as to ignore fields whose tag is a
- codec-specified tag but this codec is not enabled. This avoids TIFFGetField()
- to behave differently depending on whether the codec is enabled or not, and
- thus can avoid stack based buffer overflows in a number of TIFF utilities
- such as tiffsplit, tiffcmp, thumbnail, etc.
- Patch derived from 0063-Handle-properly-CODEC-specific-tags.patch
- (http://bugzilla.maptools.org/show_bug.cgi?id=2580) by Raphaël Hertzog.
- Fixes:
- http://bugzilla.maptools.org/show_bug.cgi?id=2580
- http://bugzilla.maptools.org/show_bug.cgi?id=2693
- http://bugzilla.maptools.org/show_bug.cgi?id=2625 (CVE-2016-10095)
- http://bugzilla.maptools.org/show_bug.cgi?id=2564 (CVE-2015-7554)
- http://bugzilla.maptools.org/show_bug.cgi?id=2561 (CVE-2016-5318)
- http://bugzilla.maptools.org/show_bug.cgi?id=2499 (CVE-2014-8128)
- http://bugzilla.maptools.org/show_bug.cgi?id=2441
- http://bugzilla.maptools.org/show_bug.cgi?id=2433
-
-2017-05-29 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_getimage.c: initYCbCrConversion(): stricter validation for
- refBlackWhite coefficients values. To avoid invalid float->int32 conversion
- (when refBlackWhite[0] == 2147483648.f)
- Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1907
- Credit to OSS Fuzz
-
-2017-05-29 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_color.c: TIFFYCbCrToRGBInit(): stricter clamping to avoid
- int32 overflow in TIFFYCbCrtoRGB().
- Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1844
- Credit to OSS Fuzz
-
-2017-05-21 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * configure.ac: libtiff 4.0.8 released.
-
- * html/v4.0.8.html: Add description of changes targeting the 4.0.8
- release.
-
-2017-05-20 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_getimage.c: initYCbCrConversion(): stricter validation for
- refBlackWhite coefficients values. To avoid invalid float->int32 conversion.
- Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1718
- Credit to OSS Fuzz
-
-2017-05-18 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_getimage.c: initYCbCrConversion(): check luma[1] is not zero
- to avoid division by zero.
- Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1665
- Credit to OSS Fuzz
-
-2017-05-17 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_read.c: _TIFFVSetField(): fix outside range cast of double to
- float.
- Credit to Google Autofuzz project
-
-2017-05-17 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_getimage.c: initYCbCrConversion(): add basic validation of
- luma and refBlackWhite coefficients (just check they are not NaN for now),
- to avoid potential float to int overflows.
- Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1663
- Credit to OSS Fuzz
-
-2017-05-17 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_pixarlog.c: PixarLogDecode(): resync tif_rawcp with
- next_in and tif_rawcc with avail_in at beginning and end of function,
- similarly to what is done in LZWDecode(). Likely needed so that it
- works properly with latest chnges in tif_read.c in CHUNKY_STRIP_READ_SUPPORT
- mode. But untested...
-
-2017-05-17 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_lzw.c: update dec_bitsleft at beginning of LZWDecode(),
- and update tif_rawcc at end of LZWDecode(). This is needed to properly
- work with the latest chnges in tif_read.c in CHUNKY_STRIP_READ_SUPPORT
- mode.
-
-2017-05-14 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_luv.c: LogL16InitState(): avoid excessive memory
- allocation when RowsPerStrip tag is missing.
- Credit to OSS-Fuzz (locally run, on GDAL)
-
-2017-05-14 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_packbits.c: fix out-of-buffer read in PackBitsDecode()
- Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1563
- Credit to OSS-Fuzz
-
-2017-05-13 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_pixarlog.c, tif_luv.c: avoid potential int32
- overflows in multiply_ms() and add_ms().
- Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1558
- Credit to OSS-Fuzz
-
-2017-05-13 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_color.c: avoid potential int32 overflow in
- TIFFYCbCrToRGBInit()
- Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1533
- Credit to OSS-Fuzz
-
-2017-05-13 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_read.c: update tif_rawcc in CHUNKY_STRIP_READ_SUPPORT
- mode with tif_rawdataloaded when calling TIFFStartStrip() or
- TIFFFillStripPartial(). This avoids reading beyond tif_rawdata
- when bytecount > tif_rawdatasize.
- Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1545.
- Credit to OSS-Fuzz
-
-2017-05-12 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_read.c: TIFFFillStripPartial():
- avoid excessive memory allocation in case of shorten files.
- Only effective on 64 bit builds.
- Credit to OSS-Fuzz (locally run, on GDAL)
-
-2017-05-12 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_read.c: TIFFFillStripPartial() / TIFFSeek(),
- avoid potential integer overflows with read_ahead in
- CHUNKY_STRIP_READ_SUPPORT mode. Should
- especially occur on 32 bit platforms.
-
-2017-05-10 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_read.c: TIFFFillStrip() and TIFFFillTile():
- avoid excessive memory allocation in case of shorten files.
- Only effective on 64 bit builds and non-mapped cases.
- Credit to OSS-Fuzz (locally run, on GDAL)
-
-2017-05-10 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_zip.c, tif_pixarlog.c, tif_predict.c: fix memory
- leak when the underlying codec (ZIP, PixarLog) succeeds its
- setupdecode() method, but PredictorSetup fails.
- Credit to OSS-Fuzz (locally run, on GDAL)
-
-2017-05-10 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_read.c: TIFFFillStrip(): add limitation to the number
- of bytes read in case td_stripbytecount[strip] is bigger than
- reasonable, so as to avoid excessive memory allocation.
-
-2017-04-28 Even Rouault <even.rouault at spatialys.com>
-
- * tools/tiff2bw.c: close TIFF handle in error code path.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2677
-
-2017-04-27 Even Rouault <even.rouault at spatialys.com>
-
- * litiff/tif_fax3.c: avoid crash in Fax3Close() on empty file.
- Patch by Alan Coopersmith + complement by myself.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2673
- * tools/fax2tiff.c: emit appropriate message if the input file is
- empty. Patch by Alan Coopersmith.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2672
-
-2017-04-27 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_ojpeg.c: fix potential memory leak in
- OJPEGReadHeaderInfoSecTablesQTable, OJPEGReadHeaderInfoSecTablesDcTable
- and OJPEGReadHeaderInfoSecTablesAcTable
- Patch by Nicolás Peña.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2670
-
-2017-04-27 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_dirread.c: fix memory leak in non DEFER_STRILE_LOAD
- mode (ie default) when there is both a StripOffsets and
- TileOffsets tag, or a StripByteCounts and TileByteCounts
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2689
- * tools/tiff2ps.c: call TIFFClose() in error code paths.
-
-2017-02-25 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_fax3.c, tif_predict.c, tif_getimage.c: fix GCC 7
- -Wimplicit-fallthrough warnings.
-
-2017-02-18 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_pixarlog.c: fix memory leak in error code path of
- PixarLogSetupDecode(). Patch by Nicolás Peña.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2665
-
-2017-02-18 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_lzw.c: in LZWPostEncode(), increase, if necessary, the
- code bit-width after flushing the remaining code and before emitting
- the EOI code.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=1982
-
-2017-01-31 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_jpeg.c: only run JPEGFixupTagsSubsampling() if the
- YCbCrSubsampling tag is not explicitly present. This helps a bit to reduce
- the I/O amount when the tag is present (especially on cloud hosted files).
-
-2017-01-14 Even Rouault <even.rouault at spatialys.com>
-
- * tools/raw2tiff.c: avoid integer division by zero.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2631
-
-2017-01-12 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_ojpeg.c: fix leak in OJPEGReadHeaderInfoSecTablesQTable,
- OJPEGReadHeaderInfoSecTablesDcTable and OJPEGReadHeaderInfoSecTablesAcTable
- when read fails.
- Patch by Nicolás Peña.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2659
-
-2017-01-11 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_luv.c, tif_lzw.c, tif_packbits.c: return 0 in Encode
- functions instead of -1 when TIFFFlushData1() fails.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2130
-
-2017-01-11 Even Rouault <even.rouault at spatialys.com>
-
- * tools/tiffcp.c: error out cleanly in cpContig2SeparateByRow and
- cpSeparate2ContigByRow if BitsPerSample != 8 to avoid heap based overflow.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2656 and
- http://bugzilla.maptools.org/show_bug.cgi?id=2657
-
-2017-01-11 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tiffio.h, tif_unix.c, tif_win32.c, tif_vms.c: add _TIFFcalloc()
-
- * libtiff/tif_read.c: TIFFReadBufferSetup(): use _TIFFcalloc() to zero
- initialize tif_rawdata.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2651
-
-2017-01-11 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_getimage.c: add explicit uint32 cast in putagreytile to
- avoid UndefinedBehaviorSanitizer warning.
- Patch by Nicolás Peña.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2658
-
-2017-01-11 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_read.c: avoid potential undefined behaviour on signed integer
- addition in TIFFReadRawStrip1() in isMapped() case.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2650
-
-2017-01-11 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_jpeg.c: validate BitsPerSample in JPEGSetupEncode() to avoid
- undefined behaviour caused by invalid shift exponent.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2648
-
-2017-01-11 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_dir.c, tif_dirread.c, tif_dirwrite.c: implement various clampings
- of double to other data types to avoid undefined behaviour if the output range
- isn't big enough to hold the input value.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2643
- http://bugzilla.maptools.org/show_bug.cgi?id=2642
- http://bugzilla.maptools.org/show_bug.cgi?id=2646
- http://bugzilla.maptools.org/show_bug.cgi?id=2647
-
-2017-01-11 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_dirread.c: avoid division by floating point 0 in
- TIFFReadDirEntryCheckedRational() and TIFFReadDirEntryCheckedSrational(),
- and return 0 in that case (instead of infinity as before presumably)
- Apparently some sanitizers do not like those divisions by zero.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2644
-
-2017-01-11 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_dirwrite.c: in TIFFWriteDirectoryTagCheckedRational, replace
- assertion by runtime check to error out if passed value is strictly
- negative.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2535
-
- * tools/tiffcrop.c: remove extraneous TIFFClose() in error code path, that
- caused double free.
- Related to http://bugzilla.maptools.org/show_bug.cgi?id=2535
-
-2017-01-11 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_jpeg.c: avoid integer division by zero in
- JPEGSetupEncode() when horizontal or vertical sampling is set to 0.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2653
-
-2017-01-03 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_jpeg.c: increase libjpeg max memory usable to
- 10 MB instead of libjpeg 1MB default. This helps when creating files
- with "big" tile, without using libjpeg temporary files.
- Related to https://trac.osgeo.org/gdal/ticket/6757
-
-2016-12-20 Even Rouault <even.rouault at spatialys.com>
-
- * tools/tiff2pdf.c: avoid potential heap-based overflow in
- t2p_readwrite_pdf_image_tile().
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2640
-
-2016-12-20 Even Rouault <even.rouault at spatialys.com>
-
- * tools/tiff2pdf.c: avoid potential invalid memory read in
- t2p_writeproc.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2639
-
-2016-12-20 Even Rouault <even.rouault at spatialys.com>
-
- * tools/tiff2pdf.c: fix wrong usage of memcpy() that can trigger
- unspecified behaviour.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2638
-
-2016-12-18 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_getimage.c: fix potential memory leaks in error code
- path of TIFFRGBAImageBegin().
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2627
-
-2016-12-18 Even Rouault <even.rouault at spatialys.com>
-
- * tools/tiff2pdf.c: prevent heap-based buffer overflow in -j mode
- on a paletted image. Note: this fix errors out before the overflow
- happens. There could probably be a better fix.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2635
-
-2016-12-17 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tiffio.h, libtiff/tif_getimage.c: add TIFFReadRGBAStripExt()
- and TIFFReadRGBATileExt() variants of the functions without ext, with
- an extra argument to control the stop_on_error behaviour.
-
-2016-12-17 Even Rouault <even.rouault at spatialys.com>
-
- * tools/tiff2ps.c: fix 2 heap-based buffer overflows (in PSDataBW
- and PSDataColorContig). Reported by Agostino Sarubbo.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2633 and
- http://bugzilla.maptools.org/show_bug.cgi?id=2634.
-
-2016-12-13 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_fax3.h: revert change done on 2016-01-09 that made
- Param member of TIFFFaxTabEnt structure a uint16 to reduce size of
- the binary. It happens that the Hylafax software uses the tables that
- follow this typedef (TIFFFaxMainTable, TIFFFaxWhiteTable,
- TIFFFaxBlackTable), although they are not in a public libtiff header.
- Raised by Lee Howard.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2636
-
-2016-12-04 Even Rouault <even.rouault at spatialys.com>
-
- * html/man/Makefile.am: remove thumbnail.1.html and rgb2ycbcr.1.html
- from installed pages since the corresponding utilities are no longer
- installed. Reported by Havard Eidnes
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2606
-
-2016-12-03 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_write.c: fix misleading indentation as warned by GCC.
-
-2016-12-03 Even Rouault <even.rouault at spatialys.com>
-
- * tools/tiffcp.c: replace assert( (bps % 8) == 0 ) by a non assert check.
- Reported by Agostino Sarubbo.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2605
-
-2016-12-03 Even Rouault <even.rouault at spatialys.com>
-
- * tools/tiffcp.c: fix uint32 underflow/overflow that can cause heap-based
- buffer overflow.
- Reported by Agostino Sarubbo.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2610
-
-2016-12-03 Even Rouault <even.rouault at spatialys.com>
-
- * tools/tiffcp.c: avoid potential division by zero is BitsPerSamples tag is
- missing.
- Reported by Agostino Sarubbo.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2607
-
-2016-12-03 Even Rouault <even.rouault at spatialys.com>
-
- * man/Makefile.am: remove thumbnail.1 and rgb2ycbcr.1 from installed man
- pages since the corresponding utilities are no longer installed.
- Reported by Havard Eidnes
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2606
-
-2016-12-03 Even Rouault <even.rouault at spatialys.com>
-
- * tools/tif_dir.c: when TIFFGetField(, TIFFTAG_NUMBEROFINKS, ) is called,
- limit the return number of inks to SamplesPerPixel, so that code that parses
- ink names doesn't go past the end of the buffer.
- Reported by Agostino Sarubbo.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2599
-
-2016-12-03 Even Rouault <even.rouault at spatialys.com>
-
- * tools/tiffcp.c: avoid potential division by zero is BitsPerSamples tag is
- missing.
- Reported by Agostino Sarubbo.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2597
-
-2016-12-03 Even Rouault <even.rouault at spatialys.com>
-
- * tools/tiffinfo.c: fix null pointer dereference in -r mode when the image has
- no StripByteCount tag.
- Reported by Agostino Sarubbo.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2594
-
-2016-12-03 Even Rouault <even.rouault at spatialys.com>
-
- * tools/tiffcrop.c: fix integer division by zero when BitsPerSample is missing.
- Reported by Agostino Sarubbo.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2619
-
-2016-12-03 Even Rouault <even.rouault at spatialys.com>
-
- * tools/tiffcrop.c: add 3 extra bytes at end of strip buffer in
- readSeparateStripsIntoBuffer() to avoid read outside of heap allocated buffer.
- Reported by Agostino Sarubbo.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2621
-
-2016-12-03 Even Rouault <even.rouault at spatialys.com>
-
- * tools/tiffcrop.c: fix readContigStripsIntoBuffer() in -i (ignore) mode so
- that the output buffer is correctly incremented to avoid write outside bounds.
- Reported by Agostino Sarubbo.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2620
-
-2016-12-03 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_ojpeg.c: make OJPEGDecode() early exit in case of failure in
- OJPEGPreDecode(). This will avoid a divide by zero, and potential other issues.
- Reported by Agostino Sarubbo.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2611
-
-2016-12-03 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_dirread.c: modify ChopUpSingleUncompressedStrip() to
- instantiate compute nstrips as TIFFhowmany_32(td->td_imagelength, rowsperstrip),
- instead of a logic based on the total size of data. Which is faulty is
- the total size of data is not sufficient to fill the whole image, and thus
- results in reading outside of the StripByCounts/StripOffsets arrays when
- using TIFFReadScanline().
- Reported by Agostino Sarubbo.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2608.
-
- * libtiff/tif_strip.c: revert the change in TIFFNumberOfStrips() done
- for http://bugzilla.maptools.org/show_bug.cgi?id=2587 / CVE-2016-9273 since
- the above change is a better fix that makes it unnecessary.
-
-2016-12-03 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_pixarlog.c, libtiff/tif_luv.c: fix heap-based buffer
- overflow on generation of PixarLog / LUV compressed files, with
- ColorMap, TransferFunction attached and nasty plays with bitspersample.
- The fix for LUV has not been tested, but suffers from the same kind
- of issue of PixarLog.
- Reported by Agostino Sarubbo.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2604
-
-2016-12-02 Even Rouault <even.rouault at spatialys.com>
-
- * tools/tiffcp.c: avoid uint32 underflow in cpDecodedStrips that
- can cause various issues, such as buffer overflows in the library.
- Reported by Agostino Sarubbo.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2598
-
-2016-12-02 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_read.c, libtiff/tiffiop.h: fix uint32 overflow in
- TIFFReadEncodedStrip() that caused an integer division by zero.
- Reported by Agostino Sarubbo.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2596
-
-2016-11-20 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_getimage.c, libtiff/tif_open.c: add parenthesis to
- fix cppcheck clarifyCalculation warnings
- * libtiff/tif_predict.c, libtiff/tif_print.c: fix printf unsigned
- vs signed formatting (cppcheck invalidPrintfArgType_uint warnings)
-
-2016-11-20 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * tools/fax2tiff.c (main): Applied patch by Jörg Ahrens to fix
- passing client data for Win32 builds using tif_win32.c
- (USE_WIN32_FILEIO defined) for file I/O. Patch was provided via
- email on November 20, 2016.
-
-2016-11-19 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff 4.0.7 released.
-
- * configure.ac: Update for 4.0.7 release.
-
- * tools/tiffdump.c (ReadDirectory): Remove uint32 cast to
- _TIFFmalloc() argument which resulted in Coverity report. Added
- more mutiplication overflow checks.
-
-2016-11-18 Even Rouault <even.rouault at spatialys.com>
-
- * tools/tiffcrop.c: Fix memory leak in (recent) error code path.
- Fixes Coverity 1394415.
-
-2016-11-17 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff/tif_getimage.c: Fix some benign warnings which appear in
- 64-bit compilation under Microsoft Visual Studio of the form
- "Arithmetic overflow: 32-bit value is shifted, then cast to 64-bit
- value. Results might not be an expected value.". Problem was
- reported on November 16, 2016 on the tiff mailing list.
-
-2016-11-16 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_dirread.c: in TIFFFetchNormalTag(), do not dereference
- NULL pointer when values of tags with TIFF_SETGET_C16_ASCII / TIFF_SETGET_C32_ASCII
- access are 0-byte arrays.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2593 (regression introduced
- by previous fix done on 2016-11-11 for CVE-2016-9297).
- Reported by Henri Salo. Assigned as CVE-2016-9448
-
-2016-11-12 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * tools/tiffinfo.c (TIFFReadContigTileData): Fix signed/unsigned
- comparison warning.
- (TIFFReadSeparateTileData): Fix signed/unsigned comparison
- warning.
-
- * tools/tiffcrop.c (readContigTilesIntoBuffer): Fix
- signed/unsigned comparison warning.
-
- * html/v4.0.7.html: Add a file to document the pending 4.0.7
- release.
-
-2016-11-11 Even Rouault <even.rouault at spatialys.com>
-
- * tools/tiff2pdf.c: avoid undefined behaviour related to overlapping
- of source and destination buffer in memcpy() call in
- t2p_sample_rgbaa_to_rgb()
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2577
-
-2016-11-11 Even Rouault <even.rouault at spatialys.com>
-
- * tools/tiff2pdf.c: fix potential integer overflows on 32 bit builds
- in t2p_read_tiff_size()
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2576
-
-2016-11-11 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_aux.c: fix crash in TIFFVGetFieldDefaulted()
- when requesting Predictor tag and that the zip/lzw codec is not
- configured.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2591
-
-2016-11-11 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_dirread.c: in TIFFFetchNormalTag(), make sure that
- values of tags with TIFF_SETGET_C16_ASCII / TIFF_SETGET_C32_ASCII
- access are null terminated, to avoid potential read outside buffer
- in _TIFFPrintField().
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2590 (CVE-2016-9297)
-
-2016-11-11 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_dirread.c: reject images with OJPEG compression that
- have no TileOffsets/StripOffsets tag, when OJPEG compression is
- disabled. Prevent null pointer dereference in TIFFReadRawStrip1()
- and other functions that expect td_stripbytecount to be non NULL.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2585
-
-2016-11-11 Even Rouault <even.rouault at spatialys.com>
-
- * tools/tiffcrop.c: fix multiple uint32 overflows in
- writeBufferToSeparateStrips(), writeBufferToContigTiles() and
- writeBufferToSeparateTiles() that could cause heap buffer overflows.
- Reported by Henri Salo from Nixu Corporation.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2592 (CVE-2016-9532)
-
-2016-11-10 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_strip.c: make TIFFNumberOfStrips() return the td->td_nstrips
- value when it is non-zero, instead of recomputing it. This is needed in
- TIFF_STRIPCHOP mode where td_nstrips is modified. Fixes a read outsize of
- array in tiffsplit (or other utilities using TIFFNumberOfStrips()).
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2587 (CVE-2016-9273)
-
-2016-11-04 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_predic.c: fix memory leaks in error code paths added in
- previous commit (fix for MSVR 35105)
-
-2016-10-31 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_predict.h, libtiff/tif_predict.c:
- Replace assertions by runtime checks to avoid assertions in debug mode,
- or buffer overflows in release mode. Can happen when dealing with
- unusual tile size like YCbCr with subsampling. Reported as MSVR 35105
- by Axel Souchet & Vishal Chauhan from the MSRC Vulnerabilities & Mitigations
- team.
-
-2016-10-26 Even Rouault <even.rouault at spatialys.com>
-
- * tools/fax2tiff.c: fix segfault when specifying -r without
- argument. Patch by Yuriy M. Kaminskiy.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2572
-
-2016-10-25 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_dir.c: discard values of SMinSampleValue and
- SMaxSampleValue when they have been read and the value of
- SamplesPerPixel is changed afterwards (like when reading a
- OJPEG compressed image with a missing SamplesPerPixel tag,
- and whose photometric is RGB or YCbCr, forcing SamplesPerPixel
- being 3). Otherwise when rewriting the directory (for example
- with tiffset, we will expect 3 values whereas the array had been
- allocated with just one), thus causing a out of bound read access.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2500
- (CVE-2014-8127, duplicate: CVE-2016-3658)
-
- * libtiff/tif_dirwrite.c: avoid null pointer dereference on td_stripoffset
- when writing directory, if FIELD_STRIPOFFSETS was artificially set
- for a hack case in OJPEG case.
- Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2500
- (CVE-2014-8127, duplicate: CVE-2016-3658)
-
-2016-10-25 Even Rouault <even.rouault at spatialys.com>
-
- * tools/tiffinfo.c: fix out-of-bound read on some tiled images.
- (http://bugzilla.maptools.org/show_bug.cgi?id=2517)
-
- * libtiff/tif_compress.c: make TIFFNoDecode() return 0 to indicate an
- error and make upper level read routines treat it accordingly.
- (linked to the test case of http://bugzilla.maptools.org/show_bug.cgi?id=2517)
-
-2016-10-14 Even Rouault <even.rouault at spatialys.com>
-
- * tools/tiffcrop.c: fix out-of-bound read of up to 3 bytes in
- readContigTilesIntoBuffer(). Reported as MSVR 35092 by Axel Souchet
- & Vishal Chauhan from the MSRC Vulnerabilities & Mitigations team.
-
-2016-10-09 Even Rouault <even.rouault at spatialys.com>
-
- * tools/tiff2pdf.c: fix write buffer overflow of 2 bytes on JPEG
- compressed images. Reported by Tyler Bohan of Cisco Talos as
- TALOS-CAN-0187 / CVE-2016-5652.
- Also prevents writing 2 extra uninitialized bytes to the file stream.
-
-2016-10-08 Even Rouault <even.rouault at spatialys.com>
-
- * tools/tiffcp.c: fix out-of-bounds write on tiled images with odd
- tile width vs image width. Reported as MSVR 35103
- by Axel Souchet and Vishal Chauhan from the MSRC Vulnerabilities &
- Mitigations team.
-
-2016-10-08 Even Rouault <even.rouault at spatialys.com>
-
- * tools/tiff2pdf.c: fix read -largely- outsize of buffer in
- t2p_readwrite_pdf_image_tile(), causing crash, when reading a
- JPEG compressed image with TIFFTAG_JPEGTABLES length being one.
- Reported as MSVR 35101 by Axel Souchet and Vishal Chauhan from
- the MSRC Vulnerabilities & Mitigations team. CVE-2016-9453
-
-2016-10-08 Even Rouault <even.rouault at spatialys.com>
-
- * tools/tiffcp.c: fix read of undefined variable in case of missing
- required tags. Found on test case of MSVR 35100.
- * tools/tiffcrop.c: fix read of undefined buffer in
- readContigStripsIntoBuffer() due to uint16 overflow. Probably not a
- security issue but I can be wrong. Reported as MSVR 35100 by Axel
- Souchet from the MSRC Vulnerabilities & Mitigations team.
-
-2016-09-25 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * html: Change as many remotesensing.org broken links to a working
- URL as possible.
-
-2016-09-24 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff/tif_getimage.c (TIFFRGBAImageOK): Reject attempts to
- read floating point images.
-
- * libtiff/tif_predict.c (PredictorSetup): Enforce bits-per-sample
- requirements of floating point predictor (3). Fixes CVE-2016-3622
- "Divide By Zero in the tiff2rgba tool."
-
-2016-09-23 Even Rouault <even.rouault at spatialys.com>
-
- * tools/tiffcrop.c: fix various out-of-bounds write vulnerabilities
- in heap or stack allocated buffers. Reported as MSVR 35093,
- MSVR 35096 and MSVR 35097. Discovered by Axel Souchet and Vishal
- Chauhan from the MSRC Vulnerabilities & Mitigations team.
- * tools/tiff2pdf.c: fix out-of-bounds write vulnerabilities in
- heap allocate buffer in t2p_process_jpeg_strip(). Reported as MSVR
- 35098. Discovered by Axel Souchet and Vishal Chauhan from the MSRC
- Vulnerabilities & Mitigations team.
- * libtiff/tif_pixarlog.c: fix out-of-bounds write vulnerabilities
- in heap allocated buffers. Reported as MSVR 35094. Discovered by
- Axel Souchet and Vishal Chauhan from the MSRC Vulnerabilities &
- Mitigations team.
- * libtiff/tif_write.c: fix issue in error code path of TIFFFlushData1()
- that didn't reset the tif_rawcc and tif_rawcp members. I'm not
- completely sure if that could happen in practice outside of the odd
- behaviour of t2p_seekproc() of tiff2pdf). The report points that a
- better fix could be to check the return value of TIFFFlushData1() in
- places where it isn't done currently, but it seems this patch is enough.
- Reported as MSVR 35095. Discovered by Axel Souchet & Vishal Chauhan &
- Suha Can from the MSRC Vulnerabilities & Mitigations team.
-
-2016-09-20 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * html/man/index.html: Comment out links to documentation for
- abandoned utilities.
-
-2016-09-17 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_lzma.c: typo fix in comment
-
-2016-09-04 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/*.c: fix warnings raised by clang 3.9 -Wcomma
-
-2016-09-03 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_dirwrite.c, libtiff/tif_color.c: fix warnings raised
- by GCC 5 / clang -Wfloat-conversion
-
-2016-08-16 Even Rouault <even.rouault at spatialys.com>
-
- * tools/tiffcrop.c: fix C99'ism.
-
-2016-08-15 Even Rouault <even.rouault at spatialys.com>
-
- * tools/tiff2bw.c: fix weight computation that could result of color
- value overflow (no security implication). Fix bugzilla #2550.
- Patch by Frank Freudenberg.
-
-2016-08-15 Even Rouault <even.rouault at spatialys.com>
-
- * tools/rgb2ycbcr.c: validate values of -v and -h parameters to
- avoid potential divide by zero. Fixes CVE-2016-3623 (bugzilla #2569)
-
-2016-08-15 Even Rouault <even.rouault at spatialys.com>
-
- * tools/tiffcrop.c: Fix out-of-bounds write in loadImage().
- From patch libtiff-CVE-2016-3991.patch from
- libtiff-4.0.3-25.el7_2.src.rpm by Nikola Forro (bugzilla #2543)
-
-2016-08-15 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_pixarlog.c: Fix write buffer overflow in PixarLogEncode
- if more input samples are provided than expected by PixarLogSetupEncode.
- Idea based on libtiff-CVE-2016-3990.patch from
- libtiff-4.0.3-25.el7_2.src.rpm by Nikola Forro, but with different and
- simpler check. (bugzilla #2544)
-
-2016-08-15 Even Rouault <even.rouault at spatialys.com>
-
- * tools/tiff2rgba.c: Fix integer overflow in size of allocated
- buffer, when -b mode is enabled, that could result in out-of-bounds
- write. Based initially on patch tiff-CVE-2016-3945.patch from
- libtiff-4.0.3-25.el7_2.src.rpm by Nikola Forro, with correction for
- invalid tests that rejected valid files. (bugzilla #2545)
-
-2016-07-11 Even Rouault <even.rouault at spatialys.com>
-
- * tools/tiffcrop.c: Avoid access outside of stack allocated array
- on a tiled separate TIFF with more than 8 samples per pixel.
- Reported by Kaixiang Zhang of the Cloud Security Team, Qihoo 360
- (CVE-2016-5321 / CVE-2016-5323 , bugzilla #2558 / #2559)
-
-2016-07-10 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_read.c: Fix out-of-bounds read on
- memory-mapped files in TIFFReadRawStrip1() and TIFFReadRawTile1()
- when stripoffset is beyond tmsize_t max value (reported by
- Mathias Svensson)
-
-2016-07-10 Even Rouault <even.rouault at spatialys.com>
-
- * tools/tiffdump.c: fix a few misaligned 64-bit reads warned
- by -fsanitize
-
-2016-07-03 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_read.c: make TIFFReadEncodedStrip() and
- TIFFReadEncodedTile() directly use user provided buffer when
- no compression (and other conditions) to save a memcpy().
-
- * libtiff/tif_write.c: make TIFFWriteEncodedStrip() and
- TIFFWriteEncodedTile() directly use user provided buffer when
- no compression to save a memcpy().
-
-2016-07-01 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_luv.c: validate that for COMPRESSION_SGILOG and
- PHOTOMETRIC_LOGL, there is only one sample per pixel. Avoid
- potential invalid memory write on corrupted/unexpected images when
- using the TIFFRGBAImageBegin() interface (reported by
- Clay Wood)
-
-2016-06-28 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_pixarlog.c: fix potential buffer write overrun in
- PixarLogDecode() on corrupted/unexpected images (reported by Mathias Svensson)
- (CVE-2016-5875)
-
-2016-06-15 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff/libtiff.def: Added _TIFFMultiply32 and _TIFFMultiply64
- to libtiff.def
-
-2016-06-05 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * tools/Makefile.am: The libtiff tools bmp2tiff, gif2tiff,
- ras2tiff, sgi2tiff, sgisv, and ycbcr are completely removed from
- the distribution. The libtiff tools rgb2ycbcr and thumbnail are
- only built in the build tree for testing. Old files are put in
- new 'archive' subdirectory of the source repository, but not in
- distribution archives. These changes are made in order to lessen
- the maintenance burden.
-
-2016-05-10 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff/tif_config.vc.h (HAVE_SNPRINTF): Add a '1' to the
- HAVE_SNPRINTF definition.'
-
-2016-05-09 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff/tif_config.vc.h (HAVE_SNPRINTF): Applied patch by Edward
- Lam to define HAVE_SNPRINTF for Visual Studio 2015.
-
-2016-04-27 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_dirread.c: when compiled with DEFER_STRILE_LOAD,
- fix regression, introduced on 2014-12-23, when reading a one-strip
- file without a StripByteCounts tag. GDAL #6490
-
-2016-04-07 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * html/bugs.html: Replace Andrey Kiselev with Bob Friesenhahn for
- purposes of security issue reporting.
-
-2016-01-23 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/*: upstream typo fixes (mostly contributed by Kurt Schwehr)
- coming from GDAL internal libtiff
-
-2016-01-09 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_fax3.h: make Param member of TIFFFaxTabEnt structure
- a uint16 to reduce size of the binary.
-
-2016-01-03 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_read.c, tif_dirread.c: fix indentation issues raised
- by GCC 6 -Wmisleading-indentation
-
-2015-12-27 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_pixarlog.c: avoid zlib error messages to pass a NULL
- string to %s formatter, which is undefined behaviour in sprintf().
-
-2015-12-27 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_next.c: fix potential out-of-bound write in NeXTDecode()
- triggered by http://lcamtuf.coredump.cx/afl/vulns/libtiff5.tif
- (bugzilla #2508)
-
-2015-12-27 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_luv.c: fix potential out-of-bound writes in decode
- functions in non debug builds by replacing assert()s by regular if
- checks (bugzilla #2522).
- Fix potential out-of-bound reads in case of short input data.
-
-2015-12-26 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_getimage.c: fix out-of-bound reads in TIFFRGBAImage
- interface in case of unsupported values of SamplesPerPixel/ExtraSamples
- for LogLUV / CIELab. Add explicit call to TIFFRGBAImageOK() in
- TIFFRGBAImageBegin(). Fix CVE-2015-8665 reported by limingxing and
- CVE-2015-8683 reported by zzf of Alibaba.
-
-2015-12-21 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_dirread.c: workaround false positive warning of Clang Static
- Analyzer about null pointer dereference in TIFFCheckDirOffset().
-
-2015-12-19 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_fax3.c: remove dead assignment in Fax3PutEOLgdal(). Found
- by Clang Static Analyzer
-
-2015-12-18 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_dirwrite.c: fix truncation to 32 bit of file offsets in
- TIFFLinkDirectory() and TIFFWriteDirectorySec() when aligning directory
- offsets on a even offset (affects BigTIFF). This was a regression of the
- changeset of 2015-10-19.
-
-2015-12-12 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_write.c: TIFFWriteEncodedStrip() and TIFFWriteEncodedTile()
- should return -1 in case of failure of tif_encodestrip() as documented
- * libtiff/tif_dumpmode.c: DumpModeEncode() should return 0 in case of
- failure so that the above mentioned functions detect the error.
-
-2015-12-06 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/uvcode.h: const'ify uv_code array
-
-2015-12-06 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_dirinfo.c: const'ify tiffFields, exifFields,
- tiffFieldArray and exifFieldArray arrays
-
-2015-12-06 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_print.c: constify photoNames and orientNames arrays
-
-2015-12-06 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_close.c, libtiff/tif_extension.c : rename link
- variable to avoid -Wshadow warnings
-
-2015-11-22 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/*.c: fix typos in comments (patch by Kurt Schwehr)
-
-2015-11-22 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/*.c: fix MSVC warnings related to cast shortening and
- assignment within conditional expression
-
-2015-11-18 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/*.c: fix clang -Wshorten-64-to-32 warnings
-
-2015-11-18 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_dirread.c: initialize double* data at line 3693 to NULL
- to please MSVC 2013
-
-2015-11-17 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_dirread.c: prevent reading ColorMap or TransferFunction
- if BitsPerPixel > 24, so as to avoid huge memory allocation and file
- read attempts
-
-2015-11-02 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_dirread.c: remove duplicated assignment (reported by
- Clang static analyzer)
-
-2015-10-28 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_dir.c, libtiff/tif_dirinfo.c, libtiff/tif_compress.c,
- libtiff/tif_jpeg_12.c: suppress warnings about 'no previous
- declaration/prototype'
-
-2015-10-19 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tiffiop.h, libtiff/tif_dirwrite.c: suffix constants by U to fix
- 'warning: negative integer implicitly converted to unsigned type' warning
- (part of -Wconversion)
-
-2015-10-17 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_dir.c, libtiff/tif_dirread.c, libtiff/tif_getimage.c,
- libtiff/tif_print.c: fix -Wshadow warnings (only in libtiff/)
-
-2015-09-12 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff 4.0.6 released.
-
- * html/v4.0.6.html: Added release notes for 4.0.6.
-
-2015-09-06 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * tools/tiffgt.c: Silence glut API deprecation warnings on MacOS
- X. Patch by Roger Leigh.
-
- * Makefile.am: Added a 'coverity' rule to assist with Coverity
- submissions.
-
- * tools/tiff2pdf.c: Fix compiler warning about unused function
- when JPEG is not available.
-
- * tools/fax2ps.c (main): Detect failure to write to temporary
- file.
-
-2015-09-05 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff/tif_dirread.c (TIFFReadDirEntryCheckRangeSlongSlong8):
- Change implementation so that it does not sometimes overflow the
- range of a 32-bit int and to avoid a signed vs unsigned compare
- compiler warning.
- (TIFF_INT64_MAX): Avoid use of platform-specific large constants.
- (TIFF_UINT32_MAX): Avoid use of platform-specific large constants.
-
-2015-09-01 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * Makefile.am (distcheck-hook), configure.ac: Applied patches by
- Roger Leigh (via tiff mailing list on 2015-09-01) to fix issue
- with BSD make and to make use of cmake in 'distcheck' target
- conditional on if cmake is available.
-
- * CMakeLists.txt, Makefile.am, configure.ac: Applied patches by
- Roger Leigh (via tiff mailing list on 2015-09-01).
-
- CMake build is now included in 'distcheck' target.
-
- Builds with CMake 2.8.9 and newer.
-
- Tar is now resquested to use POSIX PAX format.
-
-2015-08-31 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * CMakeLists.txt, libtiff/test/Makefile.am: Applied patches by
- Roger Leigh (via tiff mailing list on 2015-08-31.
-
- CMake reads all version information directly from configure.ac to
- avoid duplication of values. This basically greps over the file
- for the LIBTIFF_* variables, then translates them to the form
- needed for cmake. This includes the release version and libtool
- shared library version information.
-
- Make shared/static library building configurable. Currently it
- always builds shared libraries, with static libs having a _static
- suffix (copying zlib, but it means it's got a non-standard name).
- CMake has a -DBUILD_SHARED_LIBS=ON|OFF option to select one or the
- other, which is now used instead. There's now a single "tiff"
- target to build either shared or static as required, and all the
- tests and tools are linked with this. Note: the Windows tests fail
- when linked with a static libtiff (says: libtiff.dll not found).
- Not really a regression since this was not tested up to this
- point, and it's likely the unit tests haven't (ever?) been run on
- Windows with a static libtiff, so there's some additional
- portability issue here to address. Works fine on UNIX systems,
- and fine on Windows with the default to build a DLL.
-
- Add a missing file which wasn't being distributed, causing unit
- tests to fail. Note that "find . -name '*.cmake'" lists all the
- CMake files which need distributing in addition to all the
- CMakeLists.txt files (which now are distributed).
-
-2015-08-31 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_predict.c: pedantic change to add explicit masking
- with 0xff before casting to uchar in floating-point horizontal
- differencing and accumulation routines.
-
-2015-08-31 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_predict.c: fix generation of output with 16 bit
- or 32 bit integer, when byte swapping is needed, in
- horizontal predictor (#2521). Also fixes decoding when there is
- a single pixel to code (unlikely case...) and byte swapping is
- involved.
-
-2015-08-30 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_lzw.c: make nextdata a unsigned type to avoid
- undefined behaviour with shifts (gcc -fsanitize=shift)
-
-2015-08-30 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_fax3.c, libtiff/tif_lzw.c, libtiff/tif_predict.c:
- add explicit masking with 0xff before casting
- to unsigned char (make icc -check=conversions happy)
-
- * libtiff/tif_predict.c: operate on unsigned datatypes when
- computing/applying differences to avoid undefined behaviour of
- signed types (C standard compliance)
-
-2015-08-30 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * configure.ac: libtiff 4.0.5 released.
-
-2015-08-29 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * CMakeLists.txt: Applied patch by Roger Leigh (via tiff mailing
- list on 2015-08-29) to add ld-version-script option to cmake build
- to match autoconf. Note: defaults to 'on' to be ABI-compatible by
- default with common Linux distribution builds. Note that the
- autoconf configure script defaults to 'off'.
-
- * html/build.html: Applied patch by Roger Leigh (via tiff mailing
- list on 2015-08-29) to describe how to use CMake to build libtiff.
-
-2015-08-28 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * html/v4.0.5.html: Added HTML file describing the changes which
- will appear in the 4.0.5 release.
-
-2015-08-23 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff/tiffiop.h: For MinGW comiles, make sure that build
- supports necessary __MSVCRT_VERSION__ (at least at least 0x800).
- Otherwise large files can not be supported for POSIX-style I/O.
-
- * tools/fax2tiff.c (main): Eliminate a compiler warning in 64-bit
- builds about cast to thandle_t.
-
- * test/rewrite_tag.c (main): Does not require any arguments.
-
-2015-08-20 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * tools/CMakeLists.txt, port/snprintf.c: Patch by Roger Leigh to
- fix build issues when using Cmake due to Windows large file
- changes.
-
-2015-08-18 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff/tiffiop.h: First cut at supporting large files under
- Microsoft Windows using tif_unix.c and the libtiff tools. This
- only works if the Windows CDK is new enough to support the APIs
- used (Visual C++ 2005 or later). Support for large files is not
- actually tested yet.
-
-2015-08-15 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff/tif_jpeg.c: Applied patch by Räisä Olli to assure that
- client_data is initialized to a known value, and to report an
- error on two memory allocation failures.
-
-2015-08-13 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * CMakeLists.txt: Applied patch by Roger Leigh to fix libtiffxx
- symbol versioning. Patch was mailed to libtiff list on Thu, 13
- Aug 2015.
-
-2015-07-04 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * cmake: Add d suffix to debug libraries with MSVC. Patch #3 of 3
- by Roger Leigh posted to tiff list on Wed, 1 Jul 2015 15:58:20
- +0100.
-
- * cmake: Add extra warning flags. Patch #2 of 3 by Roger Leigh
- posted to tiff list on Wed, 1 Jul 2015 15:58:20 +0100.
-
- * cmake: Correct snprintf fallback for VS2015. Patch #1 of 3 by
- Roger Leigh posted to tiff list on Wed, 1 Jul 2015 15:58:20 +0100.
-
-2015-06-24 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * CMakeLists.txt: Add CMake patchset by Roger Leigh as posted to
- libtiff mailing list on Mon, 22 Jun 2015 21:21:01 +0100. Several
- corrections to ensure that the autotools build still works were
- added by me. I have not yet tested the build using 'cmake' or
- MSVC with 'nmake'.
-
-2015-06-21 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * test/Makefile.am: tiff2rgba-quad-tile.jpg.sh depends on the JPEG
- library so only execute if JPEG is available.
-
- * libtiff 4.0.4 released.
-
- * configure.ac: Add a HAVE_FOO Automake conditional for each
- add-on library.
-
- * test/Makefile.am (JPEG_DEPENDENT_CHECK_PROG): raw_decode
- requires JPEG support to compile. Use Automake conditional to
- only include it when JPEG support is available.
-
- * html/build.html: Try to improve the nmake-based VC++ build
- description.
-
- * libtiff/tiffconf.vc.h: Build fixes based on testing.
-
- * libtiff/tif_config.vc.h: Build fixes based on testing.
-
- * libtiff/libtiff.def: TIFFRasterScanline does not exist so remove
- export for it.
-
-2015-06-20 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff/tif_config.vc.h: Make adjustments to match the new
- definitions that configure produces, including for WIN64. Still
- needs to be tested.
-
- * configure.ac: For 64-bit MinGW, fix SSIZE_FORMAT formatting
- specifier. 64-bit MinGW supports 'long long' but support for
- 'lld' is not assured by the run-time DLLs and so GCC warns.
- Add TIFF_SIZE_T and TIFF_SIZE_FORMAT to provide a type definition
- and printf format specifier to deal with printing values of
- 'size_t' type. In particular, this was necessary for WIN64.
- Added a configure test for if the system headers provide 'optarg'
- (normal case) and block out the many explicit 'extern' statements
- in the utilities. This was found to be necessary under Windows
- when getopt is in a DLL and the symbols are already imported with
- dllimport via standard header files.
-
- * test/raw_decode.c (XMD_H): Avoid conflicting typedefs for INT32
- and boolean in MinGW build due to including jpeglib.h.
-
- * test/rewrite_tag.c (main): Fix problem with location of variable
- declaration.
-
- * libtiff/libtiff.def: Added exports for TIFFGetConfiguredCODECs,
- TIFFReadRGBAImageOriented, TIFFSetCompressionScheme,
- TIFFSwabArrayOfTriples, TIFFVGetFieldDefaulted, _TIFFCheckRealloc,
- TIFFRasterScanline, TIFFSetErrorHandlerExt,
- TIFFSetWarningHandlerExt, TIFFNumberOfDirectories,
- TIFFCreateCustomDirectory, TIFFCreateEXIFDirectory,
- TIFFWriteCustomDirectory, _TIFFRewriteField as recommended by
- Roger Leigh and justified by use in libtiff tests, documentation,
- and changelog notes. Also sorted symbol list and removed
- duplicate entries.
-
-2015-06-16 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff/tif_getimage.c: Fix four Coverity issues related to
- unintended sign extension.
-
-2015-06-16 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_unix.c: fix compilation with MSVC (fix by Jeff McKenna)
-
-2015-06-14 Lee Howard <faxguy@howardsilvan.com>
-
- * libtiff/tif_unix.c: contribution from Vadim Zeitlin on
- Bugzilla Bug #2510 fixes several harmless but still annoying
- warnings
-
- * configure: contribution from Ludolf Holzheid on Bugzilla
- Bug #2498. Adds an option to select the file I/O style on
- Windows hosts.
-
- * libtiff/tif_getimage.c: contribution from Gary Cramblitt
- on Bugzilla Bug #2409. Correct reading of certain tiled TIFFs.
-
- * configure, configure.ac: contribution from Marcos H. Woehrmann
- on Bugzilla Bug #2405. Correct shell equality operator.
-
- * tools/tiffgt.c (raster_draw): contribution from Jay Berkenbilt
- on Bugzilla Bug #2401. Appropriately call glFlush().
-
- * tools/tiff2pdf.c: change ColorTransform from "0" to "1"
- following Bugzilla Bug #2150.
-
-2015-06-13 Lee Howard <faxguy@howardsilvan.com>
-
- * libtiff/tif_lzw.c: contribution from Andy Cave - decode
- files that contain consecutive CODE_CLEAR codes.
-
- * tools/tiff2pdf.c: contribution from Antti S. Lankila on
- Bugzilla Bug #2078. Suppress initial output of the header.
-
- * tools/tiff2pdf.c: contribution from Yuriy M. Kaminskiy -
- Take care in using the return value from snprintf().
-
- * tools/tiffcrop.c: contribution from Eduardo Robles Elvira -
- correctly copy the compression tag from the source TIFF.
-
- * tools/tiff2ps.c: contribution from Eduardo Robles Elvira -
- correct sizing and scaling problems with output document.
-
-2015-06-10 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff/tif_jpeg.c (JPEGDecode): Split JPEGDecode() into two
- clean implementations in order to avoid pre-processor hell. Only
- one of the implementations is used in a given build.
-
-2015-06-08 Even Rouault <even.rouault at spatialys.com>
-
- * libtiff/tif_jpeg.c: Fix compilation in BITS_IN_JSAMPLE == 12
- case
-
-2015-06-07 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff/tif_write.c (TIFFWriteEncodedStrip): Fix Coverity 715975
- "Division or modulo by zero".
- (TIFFWriteEncodedTile): Fix Coverity 715976 and 715977 "Division
- or modulo by zero".
- (TIFFWriteRawStrip): Fix Coverity 715978 "Division or modulo by
- zero".
- (TIFFWriteScanline): Fix Coverity 715979 "Division or modulo by
- zero".
-
- * libtiff/tif_read.c (TIFFStartTile): Fix Coverity 715973 and
- 715974 "Division or modulo by zero".
-
-2015-05-31 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff/tif_dir.c (TIFFNumberOfDirectories): Quiet Coverity
- 1134470 "Logically dead code" by making the roll-over check
- explicit.
-
- * libtiff/tif_luv.c (LogLuvDecodeTile): Fix Coverity 991227
- "Division or modulo by zero".
- (LogLuvDecodeStrip): Fix Coverity 991239 "Division or modulo by
- zero".
- (LogLuvEncodeStrip): Fix Coverity 991240 "Division or modulo by
- zero".
- (LogLuvEncodeTile): Fix Coverity 991241 "Division or modulo by
- zero".
-
- * libtiff/tif_dirread.c (TIFFReadDirEntryDoubleArray): Fix
- Coverity 298626 "Logically dead code".
- (TIFFReadDirEntryFloatArray): Fix Coverity 298627 "Logically dead
- code".
- (TIFFReadDirEntryIfd8Array): Fix Coverity 298628 "Logically dead
- code".
- (TIFFReadDirEntrySlong8Array): Fix Coverity 298629 "Logically dead
- code"
-
- * libtiff/tif_dir.c (TIFFNumberOfDirectories): Don't depend on ++
- operator precedenc in evaluation. Might quench Coverity 1134470
- "Logically dead code".
-
- * libtiff/tif_jpeg.c (JPEGDecode): Fix Coverity 602597 "Operands
- don't affect result". This change uses ifdefs to include
- applicable code based on properties of libjpeg. Still needs to be
- re-tested with 12-bit "6b" and "MK1".
-
-2015-05-30 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff/tif_dirwrite.c (_TIFFRewriteField): Fix Coverity 1024310
- "Resource leak".
-
- * libtiff/tif_ojpeg.c (OJPEGReadHeaderInfoSecStreamDht): Fix
- Coverity 601720 "Resource leak".
-
- * libtiff/tif_jpeg.c (JPEGCleanup): Fix Coverity 298624
- "Dereference before null check".
-
- * libtiff/tif_ojpeg.c (OJPEGReadBufferFill): Fix Coverity 603400
- "Missing break in switch".
-
- * contrib/addtiffo/tif_overview.c (TIFF_DownSample): Check buffer
- size calculation for overflow.
-
- * contrib/addtiffo/addtiffo.c (main): Possibly address Coverity
- 1024226 "Untrusted value as argument".
-
- * tools/gif2tiff.c (readgifimage): Fix Coverity 1024222 "Untrusted
- value as argument".
- (checksignature): Fix Coverity 1024894 "Ignoring number of bytes
- read".
- (readextension): Fix Coverity 1024893 "Ignoring number of bytes
- read".
- (readgifimage): Fix Coverity 1024890 "Ignoring number of bytes
- read".
- (readraster): Fix Coverity 1024891 "Ignoring number of bytes
- read".
- (readgifimage): Fix Coverity 1024892 "Ignoring number of bytes
- read".
-
- * tools/tiff2pdf.c (t2p_readwrite_pdf_image): Fix Coverity 1024181
- "Structurally dead code".
-
- * tools/raw2tiff.c (main): Fix Coverity 1024887 "Unchecked return
- value from library".
- (guessSize): Fix Coverity 1024888 "Unchecked return value from
- library".
- (guessSize): Fix Coverity 1214162 "Ignoring number of bytes read".
- (guessSize): Fix Coverity 1024889 "Unchecked return value from
- library".
-
- * tools/tiff2pdf.c (t2p_readwrite_pdf_image): Fix Coverity 298621
- "Resource leak".
- (t2p_readwrite_pdf_image): Fix Coverity 1024181 "Structurally dead
- code".
- (t2p_write_pdf): Fix Coverity 1227690 "Unused value".
-
-2015-05-29 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * contrib/iptcutil/iptcutil.c (formatIPTC): Fix Coverity 1024468
- "Infinite loop".
- (formatIPTC): Fix Coverity 1024727 "Truncated stdio return value".
- (formatIPTC): Fix Coverity 1214240 "Untrusted loop bound".
-
-2015-05-28 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * contrib/addtiffo/tif_ovrcache.c (TIFFCreateOvrCache): Fix
- Coverity 298615 "Resource leak".
- (TIFFGetOvrBlock): Fix Coverity 1024649 "Unintended sign
- extension".
-
- * tools/bmp2tiff.c (main): Fix Coverity 1024225 "Untrusted value
- as argument".
- (main): Fix Coverity 1024678 "Unchecked return value from
- library".
- (main): Fix Coverity 1024679 "Unchecked return value from
- library".
- (main): Fix Coverity 1214160 "Ignoring number of bytes read".
-
- * contrib/addtiffo/tif_ovrcache.c (TIFFCreateOvrCache): Fix
- Coverity 298615 "Resource leak".
-
- * tools/tiffcp.c: Fix Coverity 1024306, 1024307, 1024308, 1024309
- "Resource leak".
-
- * tools/tiffsplit.c (cpTiles): Fix Coverity 1024304 "Resource
- leak".
- (cpStrips): Fix Coverity 1024305 "Resource leak".
-
-2015-05-27 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * tools/ras2tiff.c: Fix Sun Raster header definition to be safe
- for 64-bit systems. Add some header validations. Should fix many
- Coverity issues.
- (main): Fix Coverity 1301206: "Integer handling issues (BAD_SHIFT)".
- (main): Quiet Coverity 1024223 "Untrusted value as argument".
-
- * tools/tiffmedian.c (GetInputLine): Fix Coverity 1024795 "Nesting
- level does not match indentation".
- (get_histogram): Quiet Coverity 1024386 "Out-of-bounds read".
- This was a benign mis-diagnosis but added code to enforce against
- buffer overflow.
-
- * tools/tiffcrop.c (ROTATE_ANY): Fix Coverity 1294542 "Logical
- vs. bitwise operator".
- (readContigStripsIntoBuffer): Fix Coverity 1024545 "Division or
- modulo by zero".
- (readContigTilesIntoBuffer): Fix Coverity 1024586 "Logically dead
- code".
- (writeSingleSection): Fix Coverity 1024796 "Nesting level does not
- match indentation".
- (writeCroppedImage): Fix Coverity 1024797 "Nesting level does not
- match indentation".
- (loadImage): Fix Coverity 1299741 "Dereference before null check".
- (loadImage): Fix Coverity 1299740 "Out-of-bounds write".
-
-2015-03-02 Even Rouault <even.rouault@spatialys.com>
-
- * tools/tiffdither.c: check memory allocations to avoid writing to
- NULL pointer. Also check multiplication overflow. Fixes #2501,
- CVE-2014-8128. Derived from patch by Petr Gajdos.
-
-2015-01-26 Even Rouault <even.rouault@spatialys.com>
-
- * add html/v4.0.4beta.html under version control
- * HOWTO-RELEASE: write that cvs add html/vX.X.html must be used
-
-2015-01-26 Even Rouault <even.rouault@spatialys.com>
-
- * libtiff 4.0.4beta released
-
-2015-01-26 Even Rouault <even.rouault@spatialys.com>
-
- * automake: updated to 1.15
- * libtool: updated to 2.4.5
-
-2015-01-22 Even Rouault <even.rouault@spatialys.com>
-
- * tools/tiff2pdf.c: Fix two crashes (oCERT-2014-013)
-
-2015-01-05 Frank Warmerdam <warmerdam@pobox.com>
-
- * html/bugs.html: remove note about needing to email the tiff mailing
- list administrator about being approved for membership, this appears
- not to be true.
-
-2015-01-05 Olivier Paquet <olivier.paquet@gmail.com>
-
- * tools/tiff2pdf.c: Fixed unsigned integer addition overflow detection.
-
-2015-01-03 Even Rouault <even.rouault@spatialys.com>
-
- * libtiff/tif_dirread.c: in TIFFCheckDirOffset(), avoid uint16 overflow
- when reading more than 65535 directories, and effectively error out when
- reaching that limit.
-
-2014-12-29 Even Rouault <even.rouault@spatialys.com>
-
- * libtiff/tif_jpeg.c: in JPEGFixupTags(), recognize SOF2, SOF9 and SOF10
- markers to avoid emitting a warning (even if, according to the TechNote,
- there are admittedly unusual/not recommended or even forbidden variants, but
- they do work well with libjpeg for SOF2, and with libjpeg-turbo for SOF2,
- SOF9 and SOF10).
- Define in_color_space and input_components to the right values in
- JPEGSetupEncode(), before calling jpeg_set_defaults(), as specified by
- libjpeg API documentation, so as to be compatible with mozjpeg library.
- Note: the default settings of mozjpeg will produce progressive scans, which
- is forbidden by the TechNote.
-
-2014-12-29 Even Rouault <even.rouault@spatialys.com>
-
- * libtiff/tif_getimage.c: move test on vertical value of YCbCr subsampling.
- to avoid buffer leak (fix previous fix, found by Coverity scan)
-
-2014-12-29 Even Rouault <even.rouault@spatialys.com>
-
- * libtiff/tif_next.c: add new tests to check that we don't read outside of
- the compressed input stream buffer.
-
- * libtiff/tif_getimage.c: in OJPEG case, fix checks on strile width/height
- in the putcontig8bitYCbCr42tile, putcontig8bitYCbCr41tile and
- putcontig8bitYCbCr21tile cases.
-
-2014-12-27 Even Rouault <even.rouault@spatialys.com>
-
- * libtiff/tif_dir.c: in TIFFDefaultDirectory(), reset any already existing
- extended tags installed by user code through the extender mechanism before
- calling the extender callback (GDAL #5054)
-
-2014-12-26 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * tools/tiffcrop.c: Fix warnings about variables set but not used.
-
- * contrib/iptcutil/iptcutil.c: Fix warnings about variables set
- but not used.
-
- * tools/tiffgt.c: Fix warnings about unused parameters.
-
- * libtiff/tif_stream.cxx: Fix warnings about unused parameters.
-
-2014-12-25 Even Rouault <even.rouault@spatialys.com>
-
- * libtiff/tif_getimage.c, libtiff/tif_ojpeg.c, libtiff/tif_zip.c: fix
- various typos found by Debian lintian tool (GDAL #5756)
-
-2014-12-24 Even Rouault <even.rouault@spatialys.com>
-
- * libtiff/tif_getimage.c: avoid divide by zero on invalid YCbCr subsampling.
- http://bugzilla.maptools.org/show_bug.cgi?id=2235
-
-2014-12-24 Even Rouault <even.rouault@spatialys.com>
-
- * tools/tiff2pdf.c: fix buffer overflow on some YCbCr JPEG compressed images.
- http://bugzilla.maptools.org/show_bug.cgi?id=2445
-
-2014-12-24 Even Rouault <even.rouault@spatialys.com>
-
- * tools/tiff2pdf.c: fix buffer overflow on YCbCr JPEG compressed image.
- Derived from patch by Petr Gajdos,
- http://bugzilla.maptools.org/show_bug.cgi?id=2443
-
-2014-12-23 Even Rouault <even.rouault@spatialys.com>
-
- * libtiff/tif_dirread.c: In EstimateStripByteCounts(), check return code
- of _TIFFFillStriles(). This solves crashing bug on corrupted
- images generated by afl.
-
-2014-12-23 Even Rouault <even.rouault@spatialys.com>
-
- * libtiff/tif_read.c: fix several invalid comparisons of a uint64 value with
- <= 0 by casting it to int64 first. This solves crashing bug on corrupted
- images generated by afl.
-
-2014-12-21 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * tools/tiffdump.c: Guard against arithmetic overflow when
- calculating allocation buffer sizes.
-
-2014-12-21 Even Rouault <even.rouault@spatialys.com>
-
- * tools/tiff2bw.c: when Photometric=RGB, the utility only works if
- SamplesPerPixel = 3. Enforce that
- http://bugzilla.maptools.org/show_bug.cgi?id=2485 (CVE-2014-8127)
-
-2014-12-21 Even Rouault <even.rouault@spatialys.com>
-
- * tools/pal2rgb.c, tools/thumbnail.c: fix crash by disabling TIFFTAG_INKNAMES
- copying. The right fix would be to properly copy it, but not worth the burden
- for those esoteric utilities.
- http://bugzilla.maptools.org/show_bug.cgi?id=2484 (CVE-2014-8127)
-
-2014-12-21 Even Rouault <even.rouault@spatialys.com>
-
- * tools/thumbnail.c: fix out-of-buffer write
- http://bugzilla.maptools.org/show_bug.cgi?id=2489 (CVE-2014-8128)
-
-2014-12-21 Even Rouault <even.rouault@spatialys.com>
-
- * tools/thumbnail.c, tools/tiffcmp.c: only read/write TIFFTAG_GROUP3OPTIONS
- or TIFFTAG_GROUP4OPTIONS if compression is COMPRESSION_CCITTFAX3 or
- COMPRESSION_CCITTFAX4
- http://bugzilla.maptools.org/show_bug.cgi?id=2493 (CVE-2014-8128)
-
-2014-12-21 Even Rouault <even.rouault@spatialys.com>
-
- * libtiff/tif_next.c: check that BitsPerSample = 2. Fixes
- http://bugzilla.maptools.org/show_bug.cgi?id=2487 (CVE-2014-8129)
-
-2014-12-21 Even Rouault <even.rouault@spatialys.com>
-
- * tools/tiff2pdf.c: check return code of TIFFGetField() when reading
- TIFFTAG_SAMPLESPERPIXEL
-
-2014-12-21 Even Rouault <even.rouault@spatialys.com>
-
- * tools/tiffcp.c: fix crash when converting YCbCr JPEG-compressed to none.
- Based on patch by Tomasz Buchert (http://bugzilla.maptools.org/show_bug.cgi?id=2480)
- Description: fix for Debian bug #741451
- tiffcp crashes when converting JPEG-encoded TIFF to a different
- encoding (like none or lzw). For example this will probably fail:
- tiffcp -c none jpeg_encoded_file.tif output.tif
- The reason is that when the input file contains JPEG data,
- the tiffcp code forces conversion to RGB space. However,
- the output normally inherits YCbCr subsampling parameters
- from the input, which leads to a smaller working buffer
- than necessary. The buffer is subsequently overrun inside
- cpStripToTile() (called from writeBufferToContigTiles).
- Note that the resulting TIFF file would be scrambled even
- if tiffcp wouldn't crash, since the output file would contain
- RGB data interpreted as subsampled YCbCr values.
- This patch fixes the problem by forcing RGB space on the output
- TIF if the input is JPEG-encoded and output is *not* JPEG-encoded.
- Author: Tomasz Buchert <tomasz.buchert@inria.fr>
-
-2014-12-21 Even Rouault <even.rouault@spatialys.com>
-
- Fix various crash bugs on fuzzed images.
- * libtiff/tif_dir.c: TIFFSetField(): refuse to set negative values for
- TIFFTAG_XRESOLUTION and TIFFTAG_YRESOLUTION that cause asserts when writing
- the directory
- * libtiff/tif_dirread.c: TIFFReadDirectory(): refuse to read ColorMap or
- TransferFunction if BitsPerSample has not yet been read, otherwise reading
- it later will cause user code to crash if BitsPerSample > 1
- * libtiff/tif_getimage.c: TIFFRGBAImageOK(): return FALSE if LOGLUV with
- SamplesPerPixel != 3, or if CIELAB with SamplesPerPixel != 3 or BitsPerSample != 8
- * libtiff/tif_next.c: in the "run mode", use tilewidth for tiled images
- instead of imagewidth to avoid crash
- * tools/bmp2tiff.c: fix crash due to int overflow related to input BMP dimensions
- * tools/tiff2pdf.c: fix crash due to invalid tile count (should likely be checked by
- libtiff too). Detect invalid settings of BitsPerSample/SamplesPerPixel for CIELAB / ITULAB
- * tools/tiffcrop.c: fix crash due to invalid TileWidth/TileHeight
- * tools/tiffdump.c: fix crash due to overflow of entry count.
-
-2014-12-15 Even Rouault <even.rouault@spatialys.com>
-
- * libtiff/tif_jpeg.c: Fix regression introduced on 2010-05-07 that caused
- all tiles/strips to include quantization tables even when the jpegtablesmode
- had the JPEGTABLESMODE_QUANT bit set.
- Also add explicit removal of Huffman tables when jpegtablesmode has the
- JPEGTABLESMODE_HUFF bit set, which avoids Huffman tables to be emitted in the
- first tile/strip (only useful in update scenarios. create-only was
- fine)
-
-2014-12-09 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * tools/tiff2pdf.c: Assure that memory size calculations for
- _TIFFmalloc() do not overflow the range of tmsize_t.
-
-2014-12-07 Even Rouault <even.rouault@spatialys.com>
-
- * tools/thumbnail.c, tools/tiffcrop.c: "fix" heap read over-run found with
- Valgrind and Address Sanitizer on test suite
-
-2014-12-07 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * tools/tiff2pdf.c (t2p_read_tiff_init): TIFFTAG_TRANSFERFUNCTION
- tag can return one channel, with the other two channels set to
- NULL. The tiff2pdf code was expecting that other two channels
- were duplicate pointers in the case where there is only one
- channel. Detect this condition in order to avoid a crash, and
- presumably perform correctly with just one channel.
-
-2014-12-06 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * tools/tiffdump.c: Fix double-free bug.
-
-2014-11-27 Even Rouault <even.rouault@spatialys.com>
-
- * libtiff/tif_config.vc.h: no longer use "#define snprintf _snprintf" with
- Visual Studio 2015 aka VC 14 aka MSVC 1900
-
-2014-11-20 Even Rouault <even.rouault@spatialys.com>
-
- * libtiff/tif_lzw.c: prevent potential null dereference of
- sp->dec_codetab in LZWPreDecode (bug #2459)
-
- * libtiff/tif_read.c: in TIFFReadBufferSetup(), avoid passing -1 size
- to TIFFmalloc() if passed user buffer size is 0 (bug #2459)
-
- * libtiff/tif_ojpeg.c: make Coverity happier (not a bug, #2459)
-
- * libtiff/tif_dir.c: in _TIFFVGetField() and _TIFFVSetField(), make
- Coverity happier (not a bug, #2459)
-
- * libtiff/tif_dirread.c: in TIFFFetchNormalTag(), make Coverity happier
- (not a bug, #2459)
-
- * tools/tiff2pdf.c: close PDF file (bug #2479)
-
- * tools/fax2ps.c: check malloc()/realloc() result (bug #2470)
-
- * tools/tiffdump.c: detect cycle in TIFF directory chaining (bug #2463)
- and avoid passing a NULL pointer to read() if seek() failed before (bug #2459)
-
- * tools/tiffcrop.c: fix segfault if bad value passed to -Z option
- (bug #2459) and add missing va_end in dump_info (#2459)
-
- * tools/gif2tif.c: apply patch for CVE-2013-4243 (#2451)
-
-2014-11-20 Even Rouault <even.rouault@spatialys.com>
- * libtiff/tif_jpeg.c: fix segfault in JPEGFixupTagsSubsampling() on
- corrupted image where tif->tif_dir.td_stripoffset == NULL (bug #2471)
-
-2014-11-20 Even Rouault <even.rouault@spatialys.com>
- * automake: updated to 1.14.1
- * libtool: updated to 2.4.3
- * HOWTO-RELEASE: small update about autotools building order
-
-2014-10-20 Olivier Paquet <olivier.paquet@gmail.com>
- * tools/tiff2pdf.c: Preserve input file directory order when pages
- are tagged with the same page number.
-
-2014-08-31 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff/tif_dirread.c (TIFFReadDirEntryOutputErr): Incorrect
- count for tag should be a warning rather than an error since
- errors terminate processing.
-
-2014-06-07 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * tools/tiff2rgba.c (]): Fixed tiff2rgba usage message in that zip
- was wrongly described. Fix suggested by Miguel Medalha.
-
-2014-05-06 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff/tif_dirinfo.c (TIFFField) : Fix data type for
- TIFFTAG_GLOBALPARAMETERSIFD tag. Patch by Steve Underwood.
- Reviewed and forwarded by Lee Howard.
-
-2013-11-30 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_dir.c: fix last fix for TIFFNumberOfDirectories()
-
-2013-10-21 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_dir.c: generate error in case of directory count
- overflow.
-
-2013-10-01 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tiff.h, libtiff/tif_dirinfo.c: add definitions for
- TIFF/EP CFARepeatPatternDim and CFAPattern tags (bug #2457)
-
-2013-09-12 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff/tif_dir.c (TIFFAdvanceDirectory): If nextdir is found to
- be defective, then set it to zero before returning error in order
- to terminate processing of truncated TIFF. Issue found and fix
- suggested by Richard Nolde.
-
-2013-08-14 Frank Warmerdam <warmerdam@pobox.com>
-
- * tools/gif2tiff.c: fix possible OOB write (#2452, CVE-2013-4244)
-
-2013-08-13 Frank Warmerdam <warmerdam@pobox.com>
-
- * tools/gif2tiff.c: Be more careful about corrupt or
- hostile input files (#2450, CVE-2013-4231)
-
- * tools/tiff2pdf.c: terminate after failure of allocating
- ycbcr buffer (bug #2449, CVE-2013-4232)
-
-2013-07-09 Frank Warmerdam <warmerdam@google.com>
-
- * tools/tiffinfo.c: Default various values fetched with
- TIFFGetField() to avoid being uninitialized.
-
-2013-05-02 Tom Lane <tgl@sss.pgh.pa.us>
-
- * tools/tiff2pdf.c: Rewrite JPEG marker parsing in
- t2p_process_jpeg_strip to be at least marginally competent. The
- approach is still fundamentally flawed, but at least now it won't
- stomp all over memory when given bogus input. Fixes CVE-2013-1960.
-
-2013-05-02 Tom Lane <tgl@sss.pgh.pa.us>
-
- * contrib/dbs/xtiff/xtiff.c, libtiff/tif_codec.c,
- libtiff/tif_dirinfo.c, tools/rgb2ycbcr.c, tools/tiff2bw.c,
- tools/tiff2pdf.c, tools/tiff2ps.c, tools/tiffcrop.c,
- tools/tiffdither.c: Enlarge some fixed-size buffers that weren't
- large enough, and eliminate substantially all uses of sprintf(buf,
- ...) in favor of using snprintf(buf, sizeof(buf), ...), so as to
- protect against overflow of fixed-size buffers. This responds in
- particular to CVE-2013-1961 concerning overflow in tiff2pdf.c's
- t2p_write_pdf_page(), but in general it seems like a good idea to
- deprecate use of sprintf().
-
-2013-03-29 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * configure.ac: Applied patch by Brad Smith to improve pkg-config
- static linking by adding -lm to Libs.private when needed.
-
-2013-03-05 Tom Lane <tgl@sss.pgh.pa.us>
-
- * html/man/tiff2ps.1.html, html/man/tiffcp.1.html,
- html/man/tiffdither.1.html, man/tiff2ps.1, man/tiffcp.1,
- man/tiffdither.1, tools/tiff2ps.c, tools/tiffcp.c,
- tools/tiffdither.c: Sync tool usage printouts and man pages with
- reality (quite a few options had escaped being documented in one
- or both places). Per an old report from Miroslav Vadkerti.
-
-2013-01-25 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * tools/tiff2ps.c:Fix bug in auto rotate option code. Once a
- rotation angle was set by the auto rotate check, it was retained
- for all pages that followed instead ofa being retested for each
- page. Patch by Richard Nolde.
-
-2013-01-18 Frank Warmerdam <warmerdam@google.com>
-
- * libtiff/tif_write.c: tmsize_t related casting warning fixed for
- 64bit linux.
-
- * libtiff/tif_read.c: uint64/tmsize_t change for MSVC warnings.
- http://bugzilla.maptools.org/show_bug.cgi?id=2427
-
-2012-12-20 Tom Lane <tgl@sss.pgh.pa.us>
-
- * test/raw_decode.c: Relax raw_decode's pixel-value checks so that
- it will pass with more versions of libjpeg. (There are at least
- three in active use now, and JPEG_LIB_VERSION doesn't tell us
- enough to uniquely identify expected results.)
-
-2012-12-12 Tom Lane <tgl@sss.pgh.pa.us>
-
- * libtiff/tif_print.c: Fix TIFFPrintDirectory's handling of
- field_passcount fields: it had the TIFF_VARIABLE and
- TIFF_VARIABLE2 cases backwards.
-
-2012-12-10 Tom Lane <tgl@sss.pgh.pa.us>
-
- * tools/ppm2tiff.c: Improve previous patch for CVE-2012-4564:
- check the linebytes calculation too, get the max() calculation
- straight, avoid redundant error messages, check for malloc
- failure.
-
-2012-12-10 Tom Lane <tgl@sss.pgh.pa.us>
-
- * libtiff/tif_pixarlog.c: Improve previous patch for CVE-2012-4447
- (to enlarge tbuf for possible partial stride at end) so that
- overflow in the integer addition is detected. Per gripe from
- Huzaifa Sidhpurwala.
-
-2012-12-03 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * tools/tiffset.c: tiffset now supports a -u option to unset a
- tag. Patch by Zach Baker. See
- http://bugzilla.maptools.org/show_bug.cgi?id=2419
-
-2012-11-18 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * automake: Update Automake to 1.12.5 release.
-
- * libtiff/tif_{unix,vms,win32}.c (_TIFFmalloc): ANSI C does not
- require malloc() to return NULL pointer if requested allocation
- size is zero. Assure that _TIFFmalloc does.
-
-2012-11-01 Frank Warmerdam <warmerdam@pobox.com>
-
- * tools/ppm2tiff.c: avoid zero size buffer vulnerability.
- CVE-2012-4564 - Thanks to Huzaifa Sidhpurwala of the
- Red Hat Security Response team for the fix.
-
-2012-10-18 Frank Warmerdam <warmerdam@google.com>
-
- * tif_zip.c: Avoid crash on NULL error messages.
-
-2012-09-22 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff 4.0.3 released.
-
-2012-09-20 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * Makefile.am: Update to Automake 1.12.4
-
-2012-08-19 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * Makefile.in: Update to Automake 1.12.3
-
- * libtiff{tiff.h, tif_print.c, tif_dirinfo.c, tif_dirread.c}: Add
- some TIFF/FX support in libtiff. Add the tag definitions to
- tiff.h. Add the related TIFF field definitions to tif_dirinfo.c,
- and also fixes an error in a comment. Adds the photometric values
- to tif_print.c, and fixes a bug. These changes are by Steve
- Underwood.
-
-2012-08-13 Frank Warmerdam <warmerdam@google.com>
-
- * libtiff/tif_write.c: Fix bug rewriting image tiles in a
- compressed file: http://trac.osgeo.org/gdal/ticket/4771
-
-2012-08-02 Frank Warmerdam <warmerdam@google.com>
-
- * libtiff/tif_dirread.c: report error in case of mismatch value
- counts for tags (ie. DotRange).
-
-2012-07-26 Tom Lane <tgl@sss.pgh.pa.us>
-
- * libtiff/{tiffio.h, tif_dirinfo.c, libtiff.def}: Add six new
- functions TIFFFieldTag(), TIFFFieldName(), TIFFFieldDataType(),
- TIFFFieldPassCount(), TIFFFieldReadCount(), TIFFFieldWriteCount()
- as external accessors for the opaque type TIFFField.
-
- * tools/tiffset.c: Make tiffset use the above functions instead of
- relying on library private headers.
-
-2012-07-19 Tom Lane <tgl@sss.pgh.pa.us>
-
- * tools/tiff2pdf.c: Fix two places where t2p_error didn't get set
- after a malloc failure. No crash risk AFAICS, but the program
- might not report exit code 1 as desired. h/t mancha@mac.hush.com
-
-2012-07-18 Tom Lane <tgl@sss.pgh.pa.us>
-
- * tools/tiff2pdf.c: Fail when TIFFSetDirectory() fails. This
- prevents core dumps or perhaps even arbitrary code execution when
- processing a corrupt input file (CVE-2012-3401).
-
-2012-07-06 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * test/raw_decode.c (main): Test fixes to work with IJG JPEG 7+.
- IJG JPEG 7+ uses a different upsampling algorithm which produces
- different numeric results.
-
- * libtiff/tif_jpeg.c (JPEGPreDecode): Patch from Even Rouault to
- work with IJG JPEG 7+.
-
-2012-07-04 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * test/raw_decode.c: Add changes so that test can run with build
- directory outside of source directory.
-
-2012-07-02 Frank Warmerdam <warmerdam@google.com>
-
- * libtiff/tif_jpeg.c: Fix handling when writing RGBA jpeg compressed
- imagery (http://trac.osgeo.org/gdal/ticket/4732)
-
-2012-06-20 Frank Warmerdam <warmerdam@google.com>
-
- * libtiff/tif_fax3.c: fix memory initialization of runs, only
- partly done.
-
- * libtiff/tif_pixarlog.c: Make sure tbuf is large enough for one
- full "stride" past the end.
-
-2012-06-19 Frank Warmerdam <warmerdam@google.com>
-
- * libtiff/tif_packbits.c: fix read past end of data buffer.
-
-2012-06-15 Frank Warmerdam <warmerdam@google.com>
-
- * libtiff 4.0.2 released.
-
- * tools/tif2pdf.c, tools/tifdump.c: avoid uninitialized variable
- warnings with clang.
-
-2012-06-15 Tom Lane <tgl@sss.pgh.pa.us>
-
- * tools/tiff2pdf.c: Defend against integer overflows while
- calculating required buffer sizes (CVE-2012-2113).
-
-2012-06-12 Frank Warmerdam <warmerdam@google.com>
-
- * libtiff/tif_print.c: Be careful about printing corrupt inknames.
-
- * libtiff/tif_fax3.c: Ensure runs array is initialized to zeros.
-
-2012-06-07 Frank Warmerdam <warmerdam@google.com>
-
- * libtiff/tif_print.c: avoid pretty printing other fields when
- we don't have the proper amount and type of data or if the field
- is actually autodefined.
-
-2012-06-05 Frank Warmerdam <warmerdam@google.com>
-
- * libtiff/tif_tile.c, libtiff/tif_strip.c: Ensure that illegal
- ycbcrsubsampling values result in a runtime error, not just an
- assertion.
-
- * tests/custom_dir.c: Add testing of EXIF and custom directory
- reading and writing.
-
- * libtiff/tif_dir.c, libtiff/tiffio.h: Add TIFFCreateCustomDirectory()
- and TIFFCreateEXIFDirectory() functions.
-
- * libtiff/tif_dir.c, tif_print.c : Remove FIELD_CUSTOM handling for
- PAGENUMBER, HALFTONEHINTS, and YCBCRSUBSAMPLING. Implement DOTRANGE
- differently. This is to avoid using special TIFFGetField/TIFFSetField
- rules for these fields in non-image directories (like EXIF).
-
-2012-06-04 Frank Warmerdam <warmerdam@google.com>
-
- * libtiff/tif_jpeg.c: Remove code for fixing up h_sampling and v_sampling
- in JPEGPreDecode(). If a fixup will be done it needs to be done sooner
- in JPEGFixupTagsSubsampling() or else buffer sized may be wrong.
-
-2012-06-01 Frank Warmerdam <warmerdam@google.com>
-
- * tools/tiffinfo.c: Do not try to read image data in EXIF directories.
-
- * libtiff/tif_getimage.c: added support for _SEPARATED CMYK images.
- http://bugzilla.maptools.org/show_bug.cgi?id=2379
-
- * libtiff/tif_unix.c: use strerror() to return a more specific error message
- on failed open.
- http://bugzilla.maptools.org/show_bug.cgi?id=2341
-
- * libtiff/tif_jpeg.c: Fix JPEGDecodeRaw() bugs.
- http://bugzilla.maptools.org/show_bug.cgi?id=2386
-
- * tests/decode_raw.c, tests/images/quad-tile.jpg.tiff: add limited support
- for testing jpeg in tiff image decoding including the "raw" decode interface.
-
-2012-05-31 Frank Warmerdam <warmerdam@google.com>
-
- * libtiff/tif_jpeg.c: avoid overrunning the end of the output buffer in
- JPEGDecodeRaw() - mostly likely to occur when there is confusion about
- sampling values.
-
- * libtiff/tif_read.c: Make sure tif_rawdatasize is cleared when tif_rawdata is freed.
-
- * libtiff/tif_getimage.c: Add support for greyscale+alpha c/o Jérémie Laval.
- http://bugzilla.maptools.org/show_bug.cgi?id=2398
-
-2012-05-29 Frank Warmerdam <warmerdam@google.com>
-
- * libtiff/tif_dir.c: avoid using specific set/get logic to process fields in custom directories,
- like EXIF directories. This fixes problems like a tag "320" existing in a custom directory getting
- processed as if it were a colormap when it isn't really. Damn the wide variety of argument formulations
- to get/set functions for different tags!
-
- * libtiff/tif_dir.c: Ensure that we keep track of when tif_rawdata
- is a pointer into an mmap()ed file via TIFF_BUFFERMMAP flag.
-
-2012-05-24 Frank Warmerdam <warmerdam@google.com>
-
- * libtiff/tif_pixarlog.c: Allocate working buffer one word larger since we "forward
- accumulate" and overwrite the end by one word in at least some cases.
-
-2012-05-23 Frank Warmerdam <warmerdam@google.com>
-
- * libtiff/tif_pixarlog.c: avoid accessing out of the lookup arrays for out of range inputs.
-
- * tools/tiffinfo.c: initialize h=0 to avoid undefined variable for degenerate files.
-
- * libtiff/tif_ojpeg.c: if OJPEGWriteHeader() fails once do not bother trying again on
- the same image.
-
- * libtiff/tif_ojpeg.c: make things more resilient in the face of files without
- stripbytecounts or stripoffsets or where loading these fails.
-
- * libtiff/tif_print.c: be careful about whether min/max values are singular
- or one per sample.
-
- * libtiff/tif_print.c: Avoid confusion about count size when printing custom fields.
- May affect things like ISOSpeedRatings.
-
- * libtiff/tif_dir.c: avoid one byte past end of ink names reading
- in some cases.
-
-2012-05-19 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * man/TIFFGetField.3tiff: Correct the 'count' field type in the
- example for how to retrieve the value of unsupported tags.
-
-2012-03-30 Frank Warmerdam <warmerdam@google.com>
-
- * tif_getimage.c: Fix size overflow (zdi-can-1221,CVE-2012-1173)
- care of Tom Lane @ Red Hat.
-
-2012-02-18 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff 4.0.1 released.
-
- * Update automake used to 1.11.3.
-
- * libtiff/tiffio.h: Use double-underbar syntax in GCC printf
- attribute specification to lessen the risk of accidental macro
- substitution. Patch from Vincent Torri.
-
-2012-01-31 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_dir.c, libtiff/tif_dirread.c: Extra caution around
- assumption tag fetching is always successful.
-
- * libtiff/tif_jpeg.c: Extra caution for case where sp is NULL.
-
-2012-01-22 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * configure.ac: Add support for using library symbol versioning on
- ELF systems with the GNU linker. Support is enabled via
- --enable-ld-version-script. Disabled by default for now until
- there is a decision for how to deploy a libtiff with versioned
- symbols after libtiff 4.0.0 was already released.
-
-2011-12-22 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff/tif_win32.c: Eliminate some minor 64-bit warnings in
-
- tif_win32.c. Patch by Edward Lam.
-
- * configure.ac: Add libtiff private dependency on -llzma for
- pkg-config. Patch by Mark Brand.
- Updated Automake to 1.11.2.
-
-2011-12-21 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff 4.0.0 released.
-
-2011-12-08 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_dirread.c, libtiff/tif_read.c: more cautious checking
- of _TIFFFillStriles() results (#gdal 4372)
-
-2011-12-07 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_dirread.c: fixes to deal with invalid files where
- _TIFFFillStriles() fails, and we try to chop up strips (gdal #4372)
-
- * libtiff/tif_dirread.c: fix error reporting when there is no
- tag information struct and name (gdal #4373)
-
-2011-10-22 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * Update GNU libtool to 2.4.2.
-
- * tools/tiffsplit.c (tiffcp): TIFFGetField count field should be
- uint32 type for TIFFTAG_JPEGTABLES. Patch by Christophe
- Deroulers.
-
-2011-06-21 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/libtiff.def: Restore TIFFMergeFieldInfo.
-
-2011-05-31 Jim Meyering <meyering@redhat.com>
-
- * libtiff/tif_dirread.c (TIFFFetchStripThing): Free "data" also
- upon failure to allocate "resizeddata".
- * tools/tiff2ps.c (PSDataBW): Zero buffer *after* checking for
- allocation failure, not before.
- * libtiff/tif_ojpeg.c: plug leaks on OJPEG read failure path
- * tools/rgb2ycbcr.c (cvtRaster): unchecked malloc
- * libtiff/tif_jpeg.c, tools/tiff2pdf.c, tools/tiff2ps.c: mark
- NULL-deref and possible overflow
- * tools/tiff2pdf.c: remove decl+set of set-but-not-used local, "written"
- * libtiff/tif_jpeg.c (JPEGInitializeLibJPEG): Remove declaration
- and set of otherwise unused local, data_is_empty.
- * libtiff/tif_jpeg.c (JPEGDecodeRaw) [JPEG_LIB_MK1_OR_12BIT]:
- Diagnose out-of-memory failure and return 0 rather than
- dereferencing NULL.
-
-2011-05-24 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_dirread.c: produce special error message for zero tag
- directories instead of error out on the malloc(0) failure.
-
-2011-05-16 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_dirinfo.c: Restore TIFFMergeFieldInfo() and
- related declarations as they are in active use by libraries
- such as libgeotiff, and work just fine. (#2315)
-
-2011-04-20 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_dirinfo.c,tiffio.h: Remove the obsolete
- TIFFMergeFieldInfo/TIFFFindFieldInfo/TIFFFindFieldInfoByName API.
- http://bugzilla.maptools.org/show_bug.cgi?id=2315
-
- * libtiff/libtiff.def: add some missing (64bit) APIs.
- http://bugzilla.maptools.org/show_bug.cgi?id=2316
-
-2011-04-09 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff 4.0.0beta7 released.
-
-2011-04-09 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * configure.ac: Should use AC_CANONICAL_HOST since host specifies
- the run-time target whereas target is used to specify the final
- output target if the package is a build tool (like a compiler),
- which libtiff is not. Resolves libtiff bug 2307 "Use
- AC_CANONICAL_HOST macro".
-
-2011-04-02 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * configure.ac: Support configuring TIFF_INT64_FORMAT and
- TIFF_UINT64_FORMAT appropriately for MinGW32.
-
- * tools/tiffdump.c (ReadDirectory): MinGW32 needs to use WIN32
- printf conventions for 64-bit types because it uses the WIN32 CRT.
-
- * libtiff/{tif_dumpmode.c,tif_luv.c,tif_lzw.c,tif_print.c,
- tif_read.c,tif_strip.c,tif_thunder.c}: MinGW32 needs to use WIN32
- printf conventions for 64-bit types because it uses the WIN32 CRT.
-
- * tools/tiff2pdf.c (t2p_write_pdf_string): Fix printf syntax not
- understood by WIN32 CRT.
-
- * libtiff/tif_ojpeg.c: Fixes to compile with MinGW32 GCC.
-
- * tools/fax2ps.c (main): Use tmpfile() rather than mkstemp() since
- it is much more portable. Tmpfile is included in ISO/IEC
- 9899:1990 and the WIN32 CRT.
-
-2011-03-26 Frank Warmerdam <warmerdam@pobox.com>
-
- * tools/tiffset.c: add -d and -sd switches to allow operation on
- a particular directory, not just the first (jef).
-
-2011-03-21 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_thunder.c: Correct potential buffer overflow with
- thunder encoded files with wrong bitspersample set. The libtiff
- development team would like to thank Marin Barbella and TippingPoint's
- Zero Day Initiative for reporting this vulnerability (ZDI-CAN-1004,
- CVE-2011-1167).
- http://bugzilla.maptools.org/show_bug.cgi?id=2300
-
-2011-03-10 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_fax3.h: Fix to last change allowing zero length
- runs at the start of a scanline - needed for legal cases.
-
-2011-03-02 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_fax3.h: Protect against a fax VL(n) codeword commanding
- a move left. Without this, a malicious input file can generate an
- indefinitely large series of runs without a0 ever reaching the right
- margin, thus overrunning our buffer of run lengths. Per CVE-2011-0192.
- This is a modified version of a patch proposed by Drew Yao of Apple
- Product Security. It adds an unexpected() report, and disallows the
- equality case, since emitting a run without increasing a0 still allows
- buffer overrun.
-
-2011-02-23 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_jpeg.c: avoid divide by zero in degenerate case (#2296)
-
- * tools/tiff2rgba.c: close source file on error to make leak
- detection easier.
-
- * libtiff/tif_getimage.c: avoid leaks if TIFFRGBAImageBegin() fails.
-
- http://bugzilla.maptools.org/show_bug.cgi?id=2295
-
-2011-02-22 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_lzma.c: Maintain tif_rawcc/tif_rawcp (CHUNKY_STRING_READ
- _SUPPORT)
-
-2011-02-18 Frank Warmerdam <warmerdam@pobox.com>
-
- * configure.ac, configure: Added support for --enable-chunky-strip-read
- configure option to enable the experimental feature from a couple
- months ago for reading big strips in chunks.
-
- * configure.ac, tif_read.c, tif_readdir.c, tif_dir.h, tiffiop.h,
- tif_write.c, tif_print.c, tif_jpeg.c, tif_dirwrite.c, tif_write.c:
- Implement optional support for deferring the load of strip/tile
- offset and size tags for optimized scanning of directories. Enabled
- with the --enable-defer-strile-load configure option (DEFER_STRILE_LOAD
- #define in tif_config.h).
-
-2011-02-11 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_print.c: remove unused variable.
-
-2011-02-09 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_win32.c: avoid error/warning buffer overrun problem
- with non-console (popup message) builds on win32.
-
- http://bugzilla.maptools.org/show_bug.cgi?id=2293
-
-2011-01-24 Olivier Paquet <olivier.paquet@gmail.com>
-
- * libtiff/{tif_dir.{h,c}, tif_dirinfo.c, tif_dirread.c, tif_dirwrite.c,
- tif_print.c, tiff.h, tiffiop.h} : Added support for
- TIFFTAG_SMINSAMPLEVALUE and TIFFTAG_SMAXSAMPLEVALUE to have different
- values for each sample. Presents the min/max of all samples by default for
- compatibility. TIFFSetField/TIFFGetField can be made to handle those tags
- as arrays by changing the new TIFFTAG_PERSAMPLE pseudo tag.
- http://www.asmail.be/msg0055458208.html
-
-2011-01-06 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_pixarlog.c: Note that tif_rawcc/tif_rawcp are not
- maintained.
-
- * libtiff/tif_zip.c: Maintain tif_rawcc/tif_rawcp when decoding
- for CHUNKY_STRIP_READ_SUPPORT.
-
- * libtiff/tif_jpeg.c: ensure that rawcc and rawcp are maintained
- during JPEGPreDecode and JPEGDecode calls.
- * libtiff/tif_read.c: larger read ahead for CHUNKY_STRIP_READ_SUPPORT,
- as compression formats like JPEG keep 16 lines interleaved in a sense
- and might need to touch quite a bit of data.
-
- http://trac.osgeo.org/gdal/ticket/3894
-
-2011-01-03 Lee Howard <faxguy@howardsilvan.com>
-
- * libtiff/tif_jpeg.c: Fix regressions with 2 and 3 band images
- caused by commit on 2010-12-14. Submitted by e-mail from
- Even Rouault <even.rouault@mines-paris.org>
-
-2010-12-31 Olivier Paquet <olivier.paquet@gmail.com>
-
- * libtiff/tif_dirwrite.c: Fixed writing of TIFFTAG_REFERENCEBLACKWHITE.
- http://bugzilla.maptools.org/show_bug.cgi?id=2266
-
-2010-12-23 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiffcp.c, man/tiffcp.1: Added support for specifying the
- compression level parameter (preset) for Deflate and LZMA encoders,
- e.g "-c lzma:p1" or "-c zip:p9".
-
- * libtiff/tif_lzma.c: Properly set the LZMA2 compression level
- (preset) in LZMAVSetField().
-
-2010-12-18 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff/Makefile.am (libtiff_la_SOURCES): Added tif_lzma.c to
- Makefile.
-
-2010-12-14 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * configure.ac, libtiff/{tif_codec.c, tif_config.h.in, tiff.h,
- tiffiop.h, tif_lzma.c}, tools/tiffcp.c, man/tiffcp.1: Implement a new
- TIFF compression scheme LZMA reserving a new value 34925 for
- Compression tag. As per
- bug http://bugzilla.maptools.org/show_bug.cgi?id=2221
-
-2010-12-14 Lee Howard <faxguy@howardsilvan.com>
-
- * libtiff/tif_dirread.c: tolerate some cases where
- FIELD_COLORMAP is missing
- http://bugzilla.maptools.org/show_bug.cgi?id=2189
-
-2010-12-14 Lee Howard <faxguy@howardsilvan.com>
-
- * libtiff/tif_read.c: change read_ahead to tmsize_t
- http://bugzilla.maptools.org/show_bug.cgi?id=2222
-
-2010-12-14 Lee Howard <faxguy@howardsilvan.com>
-
- * configure.ac, libtiff/Makefile.am: Build tif_win32.c on
- Windows except on Cygwin
- http://bugzilla.maptools.org/show_bug.cgi?id=2224
-
-2010-12-14 Lee Howard <faxguy@howardsilvan.com>
-
- * tools/gif2tiff.c: fix buffer overrun
- http://bugzilla.maptools.org/show_bug.cgi?id=2270
-
-2010-12-14 Lee Howard <faxguy@howardsilvan.com>
-
- * libtiff/tif_jpeg.c: reduce usage of JCS_UNKNOWN in order
- to improve compatibility with various viewers
- submitted by e-mail from Dwight Kelly <dkelly@apago.com>
-
-2010-12-13 Lee Howard <faxguy@howardsilvan.com>
-
- * tools/fax2ps.c: be consistent with page-numbering
- http://bugzilla.maptools.org/show_bug.cgi?id=2225
-
-2010-12-13 Lee Howard <faxguy@howardsilvan.com>
-
- * libtiff/tif_color.c: prevent crash in handling bad TIFFs
- resolves CVE-2010-2595
- http://bugzilla.maptools.org/show_bug.cgi?id=2208
-
-2010-12-13 Lee Howard <faxguy@howardsilvan.com>
-
- * tools/tiffcrop.c: new release by Richard Nolde
- http://bugzilla.maptools.org/show_bug.cgi?id=2004
-
-2010-12-12 Lee Howard <faxguy@howardsilvan.com>
-
- * tools/tiff2pdf.c: fix colors for images with RGBA
- interleaved data
- http://bugzilla.maptools.org/show_bug.cgi?id=2250
-
-2010-12-12 Lee Howard <faxguy@howardsilvan.com>
-
- * libtiff/tif_dirread.c: fix for Zeiss LSM and Canon CR2 files
- http://bugzilla.maptools.org/show_bug.cgi?id=2164
-
-2010-12-11 Lee Howard <faxguy@howardsilvan.com>
-
- * tools/tiff2pdf.c: remove invalid duplication for Lab
- http://bugzilla.maptools.org/show_bug.cgi?id=2162
-
-2010-12-11 Lee Howard <faxguy@howardsilvan.com>
-
- * libtiff/tif_jpeg.c: fix use of clumplines calculation
- http://bugzilla.maptools.org/show_bug.cgi?id=2149
-
-2010-12-11 Lee Howard <faxguy@howardsilvan.com>
-
- * tools/fax2ps.c: replace unsafe tmpfile() with mkstemp()
- http://bugzilla.maptools.org/show_bug.cgi?id=2118
-
-2010-12-11 Lee Howard <faxguy@howardsilvan.com>
-
- * libtiff/tif_ojpeg.c, libtiff/tif_pixarlog.c,
- libtiff/tif_zip.c: fix build errors for VC6
- http://bugzilla.maptools.org/show_bug.cgi?id=2105
-
-2010-12-11 Lee Howard <faxguy@howardsilvan.com>
-
- * libtiff/tif_stream.cxx: warnings cleanup
- http://bugzilla.maptools.org/show_bug.cgi?id=2091
- * libtiff/tif_dirread.c: warnings cleanup
- http://bugzilla.maptools.org/show_bug.cgi?id=2092
-
-2010-12-11 Lee Howard <faxguy@howardsilvan.com>
-
- * tools/tiff2pdf.c: add fill-page option
- http://bugzilla.maptools.org/show_bug.cgi?id=2051
-
-2010-12-11 Lee Howard <faxguy@howardsilvan.com>
-
- * libtiff/tif_dirread.c: modify warnings
- http://bugzilla.maptools.org/show_bug.cgi?id=2016
-
-2010-12-11 Lee Howard <faxguy@howardsilvan.com>
-
- * libtiff/tif_ojpeg.c: fix buffer overflow on problem data
- http://bugzilla.maptools.org/show_bug.cgi?id=1999
-
-2010-12-11 Lee Howard <faxguy@howardsilvan.com>
-
- * tools/tiffinfoce.c: strip byte counts are uint64* now
-
-2010-12-11 Lee Howard <faxguy@howardsilvan.com>
-
- * libtiff/tif_ojpeg.c: fix crash when reading a TIFF with a zero
- or missing byte-count tag
- * tools/tiffsplit.c: abort when reading a TIFF without a byte-count
- per http://bugzilla.maptools.org/show_bug.cgi?id=1996
-
-2010-12-08 Lee Howard <faxguy@howardsilvan.com>
-
- * libtiff/tif_dirread.c: fix crash when reading a badly-constructed
- TIFF per http://bugzilla.maptools.org/show_bug.cgi?id=1994
-
-2010-12-06 Lee Howard <faxguy@howardsilvan.com>
-
- * libtiff/tif_open.c: Fix mode check before opening a file.
- http://bugzilla.maptools.org/show_bug.cgi?id=1906
-
-2010-11-27 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff-4.pc.in: Added libtiff pkg-config .pc file support.
- Patch by Vincent Torri.
-
-2010-10-21 Frank Warmerdam <warmerdam@pobox.com>
-
- * tools/tiffinfo.c: avoid direct reference to _TIFFerrorHandler.
-
- * libtiff/tif_config.vc.h: define snprintf to _snprintf for tiff2pdf.
-
- * libtiff/libtiff.def: export _TIFFCheckMalloc for tools.
-
-2010-09-25 Lee Howard <faxguy@howardsilvan.com>
-
- * tools/tiff2ps.c: improvements and enhancements from Richard Nolde
- with additional command line options for Document Title,
- Document Creator, and Page Orientation
-
-2010-07-13 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * tools/tiffcrop.c: Patch from Richard Nolde to avoid a
- potentially unterminated buffer due to using an exceptionally long
- file name.
-
-2010-07-08 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiff2pdf.c: Fixed ID buffer filling in
- t2p_write_pdf_trailer(), thanks to Dmitry V. Levin.
-
-2010-07-07 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_dirread.c: Really reset the tag count in CheckDirCount()
- to expected value as the warning message suggests. As per bug
- http://bugzilla.maptools.org/show_bug.cgi?id=1963
-
-2010-07-06 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiffset.c: Properly handle TIFFTAG_PAGENUMBER,
- TIFFTAG_HALFTONEHINTS, TIFFTAG_YCBCRSUBSAMPLING, TIFFTAG_DOTRANGE
- which should be set by value.
-
- * libtiff/tif_dirinfo.c: Don't use assertions in _TIFFFieldWithTag()
- and _TIFFFieldWithName() if the tag is not found in the tag table.
- This should be normal situation and returned NULL value should be
- properly handled by the caller.
-
-2010-07-02 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_getimage.c: Avoid wrong math du to the signed/unsigned
- integer type conversions. As per bug
- http://bugzilla.maptools.org/show_bug.cgi?id=2207
-
- * tools/{tiff2bw.c, thumbnail.c, pal2rgb.c}: Fix the count for
- WhitePoint tag as per bug
- http://bugzilla.maptools.org/show_bug.cgi?id=2042
-
- * libtiff/tif_getimage.c: Check the number of samples per pixel when
- working with YCbCr image in PickContigCase(). As per bug
- http://bugzilla.maptools.org/show_bug.cgi?id=2216
-
- * libtiff/tif_dir.c: Set the bogus post-decoding hook when processing
- TIFFTAG_BITSPERSAMPLE in _TIFFVSetField() for the case of 8 bit when
- we don't need any post-processing. That helps to reset the hook if we
- previously set this field to some other value and the hook was
- initialized accordingly. As per bug
- http://bugzilla.maptools.org/show_bug.cgi?id=2035
-
-2010-07-01 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiffgt.c: Properly check the raster buffer allocations for
- integer overflows. As per bug
- http://bugzilla.maptools.org/show_bug.cgi?id=2108
-
- * m4/acinclude.m4: Update GL/GLU/GLUt/Pthread macros from the
- upstream.
-
- * libtiff/{tif_aux.c, tif_strip.c, tif_tile.c, tiffiop.h}: Move
- multiply_32() and multiply_64() functions into tif_aux.c file and
- rename them into _TIFFMultiply32() and _TIFFMultiply64() respectively.
-
-2010-06-30 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiff2pdf.c: Better generation of ID field in
- t2p_write_pdf_trailer(). Get rid of GCC aliasing warnings.
-
- * tools/tiff2pdf.c: Fixed computation of the tile buffer size when
- converting JPEG encoded tiles.
-
- * tools/tiff2pdf.c: Better handling of string fields, use static
- string buffers instead of dynamically allocated, use strncpy() instead
- of strcpy(), control the string lengths.
-
-2010-06-25 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiffcp.c: Initialize buffer arrays with zero to avoid
- referencing to uninitialized memory in some cases (e.g. when tile size
- set bigger than the image size).
-
-2010-06-15 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * tools/tiffcrop.c: Patch from Richard Nolde. Reject YCbCr
- subsampled data since tiffcrop currently doesn't support it. Fix
- JPEG support.
-
-2010-06-13 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_dirinfo.c: Fix invocation of tag compare function (#2201)
-
- * tools/tiff2pdf.c: Fix assorted bugs in tiff2pdf: missing "return"
- in t2p_read_tiff_size() causes t2p->tiff_datasize to be set entirely
- wrong for COMPRESSION_JPEG case, resulting in memory stomp if actual
- size is larger. Also, there are a bunch of places that try to
- memset() a malloc'd buffer before checking for malloc failure, which
- would result in core dump if there actually were a failure. (#2211)
-
-2010-06-11 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff/tiffiop.h (TIFFSafeMultiply): Need more castings to
- avoid compiler warnings if parameter types are not sign
- consistent.
-
- * libtiff 4.0.0alpha6 released.
-
- * tools/tiffcrop.c: Applied patch from Richard Nolde: Corrected
- European page size dimensions. Added an option to allow the user
- to specify a custom page size on the command line. Fix the case
- where a page size specified with a fractional part was being
- coerced to an integer by retyping the variables that define the
- paper size.
-
- * html/index.html: Update for the 3.9.3 release.
-
- * tools/tiffcp.c (tiffcp): Applied Tom Lane's patch to reject
- YCbCr subsampled data since tiffcp currently doesn't support it.
- http://bugzilla.maptools.org/show_bug.cgi?id=2097
-
- * Update libtool to version 2.2.10.
-
-2010-06-10 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff/tiffiop.h (TIFFSafeMultiply): Work properly if
- multiplier is zero.
-
-2010-06-09 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff/tif_fax3.c (Fax3SetupState): Yesterday's fix for
- CVE-2010-1411 was not complete.
-
- * libtiff/tiffiop.h (TIFFSafeMultiply): New macro to safely
- multiply two integers. Returns zero if there is an integer
- overflow.
-
- * tools/tiffcp.c (main): tiffcp should not leak memory if an error
- is reported when reading the input file.
-
-2010-06-08 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * Update libtool to version 2.2.8.
-
- * libtiff/tif_fax3.c (Fax3SetupState): Avoid under-allocation of
- buffer due to integer overflow in TIFFroundup() and several other
- potential overflows. In conjunction with the fix to TIFFhowmany(),
- fixes CVE-2010-1411.
-
- * libtiff/tiffiop.h (TIFFhowmany): Return zero if parameters would
- result in an integer overflow. This causes TIFFroundup() to also
- return zero if there would be an integer overflow.
-
- * contrib: Add an emacs formatting mode footer to all source files
- so that emacs can be effectively used.
-
-2010-06-03 Oliver Chen Feng <scip8183@gmail.com>
-
- * libtiff/tools/tiffcp.c: add a new option -x to force merged tiff
- file PAGENUMBER value in sequence for users who care the page
- sequence, this will also prevent tiff2pdf from creating pdf file from
- the merged tiff file with wrong page sequence.
-
-2010-05-08 Olivier Paquet <olivier.paquet@gmail.com>
-
- * libtiff/tif_dirread.c: Restored TIFFReadDirEntryFloat function in order
- to add missing TIFF_SETGET_FLOAT case to TIFFFetchNormalTag.
- * libtiff/tif_dirinfo.c: Use correct set_field_type for
- TIFFTAG_PIXAR_FOVCOT so it is readable again (regression from 3.9.2).
- http://bugzilla.maptools.org/show_bug.cgi?id=2192
-
-2010-05-07 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_jpeg.c: Ensure that quality is always set in
- JPEGPreEncode(), not just when we want to output local tables.
- Otherwise the quality used during compression may not be right and
- might not match the tables in the tables tag. This bug only occurs
- when seeking between directories in the midst of writing blocks.
- http://trac.osgeo.org/gdal/ticket/3539
-
-2010-05-06 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * html/man/TIFFGetField.3tiff.html, html/man/TIFFSetField.3tiff.html:
- Regenerated from the source.
-
-2010-05-05 Olivier Paquet <olivier.paquet@gmail.com>
-
- * libtiff/tif_print.c: Fixed printing of TIFFTAG_REFERENCEBLACKWHITE which
- had stopped working. Also made it always print 6 floats instead of
- 2*SamplesPerPixel.
- http://bugzilla.maptools.org/show_bug.cgi?id=2191
- http://bugzilla.maptools.org/show_bug.cgi?id=2186
- * man/TIFFGetField.3tiff, man/TIFFSetField.3tiff: Fixed doc to reflect the
- fact that libtiff considers TIFFTAG_REFERENCEBLACKWHITE to be 6 floats.
-
-2010-05-05 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_jpeg.c: Fix to use memcmp(), not memcpy() when checking
- if the jpeg table was written. This is a fix for the last fix on 04-21.
-
-2010-04-21 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_jpeg.c: avoid preparing jpeg tables every time
- JPEGSetupEncode() is called if the tables already seem to be
- established. This prevents spurious updates and rewriting of
- directories with jpegtables when doing updates to existing images.
- http://trac.osgeo.org/gdal/ticket/3539
-
-2010-04-20 Olivier Paquet <olivier.paquet@gmail.com>
-
- * libtiff/tif_dirinfo.c: Use correct set_field_type for
- TIFFTAG_PIXAR_IMAGEFULLWIDTH, TIFFTAG_PIXAR_IMAGEFULLLENGTH,
- TIFFTAG_PIXAR_MATRIX_WORLDTOSCREEN and TIFFTAG_PIXAR_MATRIX_WORLDTOCAMERA.
- They were unreadable with TIFF_SETGET_UNDEFINED, a regression from 3.9.2.
- http://bugzilla.maptools.org/show_bug.cgi?id=2139
-
-2010-04-10 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff/tif_dir.c (_TIFFVSetField): Add a special error case for
- when the tag count value is zero. Error handling is still a
- regression since in 3.9.2, empty tags are skipped (with a warning)
- rather than returning a hard error and refusing to read the file.
-
- * tools/ppm2tiff.c (main): While case for parsing comment line
- requires extra parenthesis to work as expected. Reported by
- Thomas Sinclair.
-
-2010-04-02 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_read.c (primarily): Add support for
- CHUNKY_STRIP_READ_SUPPORT where large strips are
- read in chunks for applications using TIFFReadScanline().
- This is intended to make it more practical work with very
- large compressed one-strip files. Feature is off by default.
- Enable by defining CHUNK_STRIP_READ_SUPPORT as a macro.
- http://trac.osgeo.org/gdal/ticket/3514
-
-2010-03-31 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_flush.c: Use TIFFRewriteDirectory() when flushing
- directories so previously placed directories will be migrated to
- the end of file if needed.
-
-2010-03-30 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_lzw.c: change type of dec_bitsleft field to uint64
- to support operating on strips/tiles of more than 256MB.
- http://trac.osgeo.org/gdal/ticket/3512
-
-2010-03-10 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff/tif_aux.c (_TIFFCheckRealloc): Improve error message so
- that it is clearly a memory allocation error message, and also
- includes the size of the allocation request.
-
-2010-02-22 Lee Howard <faxguy@howardsilvan.com>
-
- * libtiff/tif_jpeg.c: Do not generate a JPEGTables tag when creating
- the JPEG TIFF as is is not required in order to prevent it from
- being unused and filled with invalid data. (Leave it to be
- generated by later activity.)
- http://bugzilla.maptools.org/show_bug.cgi?id=2135
- * tools/tiff2pdf.c: Write the JPEG SOI headers into the TIFF strip
- data rather than skipping them. This fixes the ability to view in
- Acrobat Reader, Evince, and Ghostscript.
- http://bugzilla.maptools.org/show_bug.cgi?id=2135
- * libtiff/tif_fax3.c: Don't return error on badly-terminated MMR
- strips.
- http://bugzilla.maptools.org/show_bug.cgi?id=2029
-
-2009-12-03 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_jpeg.c: Made JPEGDecodeRaw() check for buffer overruns.
- Made so that when working with downsampled images a stub function
- reporting an error is used for tif_decoderow. We cannot meaningfully
- support reading scanlines in this situation. (#1936)
-
- * libtiff/tif_jpeg.c: Ensure that tif_scanlinesize is computed after
- resetting of the upsampling values (gdal:#3259).
- http://bugzilla.maptools.org/show_bug.cgi?id=1936
-
-2009-11-30 Frank Warmerdam <warmerdam@pobox.com>
-
- * contrib/dbs/tiff-grayscale.c, contrib/tif-palette.c,
- tools/ras2tiff.c: Fix resource leaks on error.
- http://bugzilla.maptools.org/show_bug.cgi?id=2121
-
- * libtiff/tif_{aux.c,dir.c,dir.h,dirinfo.c}: Return to handling
- TIFFTAG_REFERENCEBLACKWHITE as a field in the TIFF directory instead
- of as a custom(generic) field to avoid a potential reentrancy problem.
- http://bugzilla.maptools.org/show_bug.cgi?id=2125
-
- * libtiff/tif_color.c, libtiff/tif_getimage.c, libtiff/tiffio.h,
- man/TIFFcolor.3tiff: Make TIFFDisplay argument in TIFFCIELabToRGBInit
- const, and display_sRGB static and const.
- http://bugzilla.maptools.org/show_bug.cgi?id=2124
-
-2009-11-04 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff 4.0.0alpha5 released.
-
-2009-11-03 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * tools/tiffcrop.c: Updated tiffcrop from Richard Nolde. This
- version has undergone substantial testing with arbitrary sample
- bit depths. Also eliminates GCC compilation warnings.
-
-2009-11-02 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * port/libport.h: Add extern declarations for getopt standard
- globals.
-
-2009-10-31 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff/tif_lzw.c (LZWDecode, LZWDecodeCompat): Fix warnings
- noticed in 64-bit build of libtiff with Visual Studio 2005.
- Resolves "Bug 2067 - Visual Studio 2005 64-bit warnings in
- tif_lzw.c", http://bugzilla.maptools.org/show_bug.cgi?id=2067
-
- * libtiff/tif_pixarlog.c (PixarLogEncode): Fix non-important
- warning noticed in Visual Studio 2005 build. Resolves "Bug 2068 -
- Visual Studio 2005 64-bit warning in tif_pixarlog.c",
- http://bugzilla.maptools.org/show_bug.cgi?id=2068
-
-2009-10-29 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff/tif_dirread.c: Eliminate GCC "dereferencing type-punned
- pointer" warnings.
-
-2009-10-28 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * html/tools.html: Add manual page links, and a summary
- description of tiffcrop.
-
-2009-10-07 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * configure.ac: x86_64 should use the same fill order as i386.
-
-2009-09-24 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * tools/tiffcrop.c, man/tiffcrop.1: New tiffcrop from Richard
- Nolde. Major updates to add significant functionality for reading
- and writing tile based images with bit depths not a multiple of 8
- which cannot be handled by tiffcp.
-
-2009-09-03 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff/tif_ojpeg.c (OJPEGWriteHeaderInfo): IJG JPEG 7 needs
- do_fancy_upsampling=FALSE in order to read raw data. Resolves
- "Bug 2090 - OJPEG crash with libjpeg v7".
- http://bugzilla.maptools.org/show_bug.cgi?id=2090
-
-2009-09-03 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_getimage.c: Fixed error recognition handling in RGBA
- interface when stoponerror is set.
- http://bugzilla.maptools.org/show_bug.cgi?id=2071
-
-2009-08-30 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * tools/{tiffcrop.c,tiffgt.c}: Applied patch from Oden Eriksson to
- fix build with gcc when using the "-Wformat
- -Werror=format-security" flags.
-
-2009-08-29 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * test/{bmp2tiff_palette.sh, bmp2tiff_rgb.sh, gif2tiff.sh,
- ppm2tiff_pbm.sh, ppm2tiff_pgm.sh, ppm2tiff_ppm.sh}: Additional
- utilities tests.
-
-2009-08-28 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * tools/tiffinfo.c: tiffinfo should return error status to the
- caller. Register a private error callback to accomplish that.
-
- * test/Makefile.am (TIFFIMAGES): Add test images in BMP, GIF, and
- PNM formats so that we will be able to test more of the tools.
- While adding these test images I notice that bmp2tiff and gif2tiff
- only support ancient versions of their respective formats.
-
-2009-08-27 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff 4.0.0alpha4 released.
-
- * HOWTO-RELEASE: Improved release instructions.
-
-2009-08-24 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * man/{TIFFClose.3tiff,raw2tiff.1,tiffcmp.1,tiffsplit.1}: Applied
- fixes for "Bug 2023 - nroff errors in manual pages".
- http://bugzilla.maptools.org/show_bug.cgi?id=2023
-
- * tools/{rgb2ycbcr.c, tiff2rgba.c}: Applied fixes for "Bug 2079 -
- CVE-2009-2347 libtiff: integer overflows in various inter-color
- space conversion tools".
- http://bugzilla.maptools.org/show_bug.cgi?id=2079
-
- * libtiff/tif_print.c (TIFFPrintDirectory): Apply fix from Jay
- Berkenbilt for "Bug 2024 - possible null pointer dereference with
- one-line fix".
- http://bugzilla.maptools.org/show_bug.cgi?id=2024
-
- * libtiff/tif_dirread.c (TIFFReadCustomDirectory): Apply patch
- from Jay Berkenbilt for "Bug 1895 - logic error in tif_dirread.c:
- segfault after setting tdir_tag = IGNORE".
- http://bugzilla.maptools.org/show_bug.cgi?id=1895
-
-2009-08-23 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * test/Makefile.am, test/tiffcrop*.sh: Split previously existing
- tiffcrop.sh into a collection of many specific tests. Re-wrote
- all of the existing tests to be based on some simple shell
- functions. Make distcheck works again.
-
- Export certain variables (MAKE, MAKEFLAGS, MEMCHECK) to tests and
- added 'memcheck' and 'ptrcheck' targets to make it easy to run the
- tests under valgrind.
-
-2009-08-21 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * test/tiffcp-logluv.sh: Fix test so that it works with a VPATH
- build.
-
- * test/Makefile.am (AUTOMAKE_OPTIONS): Colorized tests was not
- actually activated since it needed to be enabled in this
- Makefile.am. Also activated parallel-tests mode since it offers
- useful features such as per-test .log files and a summary test
- report .log file.
-
-2009-08-20 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * configure.ac: Updated autotools. Autoconf 2.64, Automake 1.11,
- libtool 2.2.6. Enabled support for silent build rules
- (--enable-silent-rules or 'make V=0') and colorized tests.
-
- * html/{index.html, v3.9.0.html}: Update for 3.9.0 release.
-
-2009-06-30 Frank Warmerdam <warmerdam@pobox.com>
-
- * tests/tiffcp-logluv.sh: minimal testing of sgilog compression.
-
- * tools/tiffcp.c: add -c sgilog support.
-
- * libtiff/tif_luv.c: correct return codes from encoderow to be
- 1 on success instead of zero.
- http://bugzilla.maptools.org/show_bug.cgi?id=2069
-
- * libtiff/tif_lzw.c: back out patch from #2065 and apply patch from
- #1085 for a better underflow fix that errors properly.
- http://bugzilla.maptools.org/show_bug.cgi?id=2065
- http://bugzilla.maptools.org/show_bug.cgi?id=1985
-
-2009-06-26 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_strip.c: Remove an inappropriate assertion that often
- fails on oddly sized 12bit jpeg compressed ycbcr images.
-
-2009-06-22 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_lzw.c: Fix buffer underflow bug.
- http://bugzilla.maptools.org/show_bug.cgi?id=2065
-
-2009-06-21 Frank Warmerdam <warmerdam@pobox.com>
-
- * configure.ac, libtiff/tif_jpeg.c, libtiff/tif_jpeg_12.c: add support
- for dual mode 8/12 bit jpeg support.
-
-2009-06-03 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_write.c: do not override the planar configuration to be
- contig for one sample files if planar configuration is already set.
- http://bugzilla.maptools.org/show_bug.cgi?id=2057
-
-2009-06-02 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/libtiff.def: Add TIFFUnsetField.
-
-2009-05-03 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/{tif_jpeg.c,tif_ojpeg.c,tif_getimage.c}: Fixed various
- error reports to use "%s" as format string.
- http://trac.osgeo.org/gdal/ticket/2976
-
-2009-03-12 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/{tif_fax3.c,tif_jpeg.c,tif_ojpeg.c}: Fix printdir chaining
- for some codecs (#2020).
-
-2009-02-12 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_luv.c: Fix handling of tiled logluv images.
- http://bugzilla.maptools.org/show_bug.cgi?id=2005
-
-2009-02-09 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_dirread.c: Improve allocation safety when allocated
- buffer for large tags. (#1998) Related to (#1993)
-
-2009-02-06 Frank Warmerdam <warmerdam@pobox.com>
-
- * tools/tiffcrop.c: Don't default image->res_unit to INCH. Now the
- test suite should pass.
-
-2009-02-05 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_dirread.c: Re-incorporated a sanity check on tag size,
- but at the 2GB boundary to avoid overflow on 32bit systems.
- http://bugzilla.maptools.org/show_bug.cgi?id=1993
-
- * libtiff/tif_dirread.c: Remove some assertions that blow due to
- corrupt files rather than in response to library internal
- inconsistencies.
- http://bugzilla.maptools.org/show_bug.cgi?id=1995
- http://bugzilla.maptools.org/show_bug.cgi?id=1991
-
- * libtiff/tif_dirread.c: Fixed testing for failed result from
- TIFFReadDirectoryFindFieldInfo().
- http://bugzilla.maptools.org/show_bug.cgi?id=1992
-
-2009-01-23 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_predict.c: Add support for 32bit integer horz. predictors.
- http://bugzilla.maptools.org/show_bug.cgi?id=1911
-
- * libtiff/tif_dirwrite.c: Fix byte swapping of next directory offset.
-
- http://bugzilla.maptools.org/show_bug.cgi?id=1924
-
- * tools/tiffcrop.c: initialize xres/yres values.
-
- * test/*.sh - default ${srcdir} to local directory.
-
- * test/common.sh - start verbose mode after common settings.
-
- * libtiff/tif_dirinfo.c: Replace lfind() with local equivalent to
- avoid type mismatches on different platforms.
- http://bugzilla.maptools.org/show_bug.cgi?id=1889
-
-2009-01-22 Frank Warmerdam <warmerdam@pobox.com>
-
- * tools/{fax2tiff.c,thumbnail.c,tiff2pdf.c,tiff2ps.c,tiffdump.c,
- tiffsplit.c}: avoid warnings, mostly 32bit/64bit casting issues.
-
- * port,tools: Introduce libport.h, and include in tools if NEED_LIBPORT
- defined, primarily to reduce prototype warnings on windows.
-
- * libtiff/tif_dirinfo.c,tif_dirread.c: Avoid warnings
- about unused parameters, and uninitialized variables.
-
-2009-01-21 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * test/common.sh: Execute tests like 'make VERBOSE=TRUE check' in
- order to trace full execution detail while executing the test suite.
-
-2009-01-20 Frank Warmerdam <warmerdam@pobox.com>
-
- * tools/tiffsplit.c: fix sampleformat to be shortv instead of longv.
-
-2009-01-20 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * test/Makefile.am (CLEANFILES): Make sure that test output files
- are removed by 'make clean'
-
- * Update autotools for 4.0.0 beta3
-
- * 4.0.0 beta3 produced.
-
-2009-01-12 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * test/tiffcrop.sh: New test script for tiffcrop from Richard
- Nolde.
-
- * tools/tiff2ps.c: Remove spurious message to stderr.
-
-2009-01-11 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * tools/tiff2ps.c: Incorporated significant functionality update
- from Richard Nolde. In particular, support for rotating the image
- by 90, 180, 270, and 'auto' has been added.
-
- * man/tiffcrop.1: Incorporated documentation updates from Richard
- Nolde.
-
- * tools/tiffcrop.c: Incorporated significant functionality update
- from Richard Nolde.
-
-2008-12-31 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff/tiffio.h: GCC will now validate format specifications
- for TIFFError(), TIFFErrorExt(), TIFFWarning(), and
- TIFFWarningExt() in order to reveal bugs.
-
- * Many fixes throughout to work better as a 64-bit build.
-
-2008-12-30 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * tools/{tiff2pdf.c, tiff2ps.c, tiffinfo.c}: Offset and length
- tags now require 64-bit parameter rather than 32-bit.
-
- * libtiff/tif_dirread.c: Fixed issues with unaligned access to
- 64-bit values.
-
- * tools/thumbnail.c: Eliminate crash noticed while running test
- suite.
-
-2008-12-29 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff/tif_ojpeg.c (OJPEGLibjpegJpegSourceMgrFillInputBuffer):
- Initialize stack variables to avoid compiler warning.
-
- * tools/tiffinfoce.c (main): Use toff_t for offset type when
- retrieving offset of EXIF IFD.
-
- * libtiff/tiffio.h: Undeprecate toff_t and restore its use in the
- TIFFClientOpen() callback and other external function definitions.
-
- * tools/tiffinfo.c (main): Offset to EXIF IFD requires a 64-bit
- type now. Fixes crash when dumping files containing an EXIF IFD.
-
- * m4/libtool.m4: Update to libtool 2.2.6.
-
-2008-12-21 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_dir.c, tiffio.h: Introduce TIFFUnsetField() function.
-
- * libtiff/tif_jpeg.c: Avoid errors if the application writes a full
- strip for the last partial strip in a jpeg compressed file.
- http://bugzilla.maptools.org/show_bug.cgi?id=1981
-
-2008-10-29 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_flush.c: Make sure that BEENWRITING is cleared when
- we take the shortcut to only update the strip/tile offsets in place.
- http://trac.osgeo.org/gdal/ticket/2621
-
-2008-10-21 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_jbig.c: Support the JBIG-KIT 2.0 (compatibility with
- the older versions retained).
-
-2008-10-09 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_jpeg.c: Add #ifdefs for changes needed if using
- IPP enabled version of libjpeg from Intel.
- http://bugzilla.maptools.org/show_bug.cgi?id=1951
-
-2008-09-05 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiffsplit.c: Use byte counts of proper size (uint64).
- Required for libtiff 4.0.
-
- * tools/tiffsplit.c: Use dynamically allocated array instead of static
- when constructing output file names.
-
-2008-09-03 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiffsplit.c: Get rid of unsafe strcpy()/strcat() calls when
- doing the filename/path construction.
-
- * tools/tiff2pdf.c: More appropriate format string in
- t2p_write_pdf_string(); avoid signed/unsigned mismatch.
-
- * libtiff/tif_lzw.c: Properly zero out the codetable. As per bug
-
- http://bugzilla.maptools.org/show_bug.cgi?id=1929
-
- * libtiff/tif_lzw.c: Properly zero out the string table. Fixes
- CVE-2008-2327 security issue.
-
-2008-09-01 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_dirread.c: Avoid unused TIFFReadDirEntryFloat() function.
-
- * libtiff/tif_dirwrite.c: modified to write IFDs as either IFD8 or IFD
- depending on whether the file is bigtiff or classic tiff.
- http://bugzilla.maptools.org/show_bug.cgi?id=1917
-
-2008-08-12 Edward Lam <edward@sidefx.com>
-
- * tools/tiffdump.c: When compiling for Microsoft Windows, apply
- consistent (__int64) casting when testing if _lseeki64 has
- successfully sought as requested. This is necessary for large
- file support to work since off_t is only 32-bit.
-
-2008-07-29 Frank Warmerdam <warmerdam@pobox.com>
-
- * tif_strip.c: Replace assertions related to samplesperpixel != 3 or
- the subsampling values not being 1, 2 or 4 (for jpeg compressed images)
- with control logic to return runtime errors (c/o Even Rouault) (#1927).
-
-2008-06-17 Frank Warmerdam <warmerdam@pobox.com>
-
- * tools/tiffcrop.c: Fix some portability problems.
-
- * libtiff/tif_ojpeg.c: Use same jpeg/win32 boolean/FAR hacks as are
- used in tif_jpeg.c.
-
- * libtiff/tif_win32.c: Ensure TIFFOpenW() uses same FILE_SHARE flags
- as TIFFOpen().
-
-2008-06-01 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_dirwrite.c: Fix alignment problems affecting architectures
- like Sparc/Solaris.
- http://bugzilla.maptools.org/show_bug.cgi?id=1892
-
-2008-05-27 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff.def: Add TIFFFindField
- http://bugzilla.maptools.org/show_bug.cgi?id=1891
-
-2008-05-26 Frank Warmerdam <warmerdam@pobox.com>
-
- * tif_config.*.h, tiffconf.*.h: Remove SIZEOF_LONG definition, unused.
-
- * li2008-04-15 Andrey Kiselev <dron@ak4719.spb.edu>
-
-btiff/tif_win32.c: Replace custom Win32 memory api with generic
- POSIX one. No apparent value to use of GlobalAlloc() in the modern
- age. http://bugzilla.maptools.org/show_bug.cgi?id=1885
-
- * libtiff/tiffconf.vc.h: Added JBIG_SUPPORT and MDI_SUPPORT items
- in windows version (care of Edward Lam).
-
-2008-05-24 Frank Warmerdam <warmerdam@pobox.com>
-
- * tif_codec.c: Avoid NULL pointer dereferencing for exotic
- compression codec codes.
-
- * tif_dirwrite.c: fix potential memory leak.
-
- * tif_dirread.c: Fix unchecked malloc result.
-
-2008-05-24 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * test {tiff2pdf.sh tiff2ps-EPS1.sh tiff2ps-PS1.sh tiff2ps-PS2.sh
- tiff2ps-PS3.sh tiffcp-g3-1d-fill.sh tiffcp-g3-1d.sh
- tiffcp-g3-2d-fill.sh tiffcp-g3-2d.sh tiffcp-g3.sh tiffcp-g4.sh
- tiffcp-split-join.sh tiffcp-split.sh tiffcp-thumbnail.sh
- tiffdump.sh tiffinfo.sh}: Added more test scripts based on
- suggestions from Lee Howard posted to the tiff list on 13 Sep
- 2007.
-
-2008-05-23 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_fax3.c: Add an assert in an effort to detect a
- possible runtime problem reported by coverity.
-
- * contrib/iptcutil/iptcutil.c: Fixed memory leak of str.
-
- * tools/tiffcrop.c, man/tiffcrop.1: Major update from Richard Nolde.
- http://bugzilla.maptools.org/show_bug.cgi?id=1888
-
- * tools/tiffdither.c: remove dead onestrip code. avoid memory leak.
-
- * tools/rgb2ycbcr.c: fix memory leak of raster buffer.
-
- * tools/tiffcp.c: Simplify inknames code to avoid pointless test.
- Cleanup scanline allocation to avoid coverity warning.
-
- * tools/thumbnail.c: Check for TIFFOpen() failure.
-
-2008-05-18 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_dirinfo.c: Use TIFF_SETGET_ASCII for PIXAR_TEXTUREFORMAT
- and PIXAR_WRAPMODES instead of TIFF_SETGET_UNDEFINED. Not exactly clear
- why this is needed.
-
-2008-05-09 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * Makefile.am (ACLOCAL_AMFLAGS): Libtool 2.2.4 does not like
- "ACLOCAL_AMFLAGS=-I ./m4". It wants "ACLOCAL_AMFLAGS=-I m4".
-
-2008-04-15 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * test/: Test suite updated. Everything is passed now.
-
- * libtiff/tif_dirinfo.c: Fixed description of the
- TIFFTAG_NUMBEROFINKS tag.
-
-2008-04-14 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tif_dirread.c, tif_dirwrite.c, tiffiop.h}:
- Get rid of some of "dereferencing type-punned" warnings by converting
- tdir_offset field of TIFFDirEntry structure into union.
-
-2008-04-10 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tif_flush.c, tif_dirwrite.c, tiffio.h, tiffiop.h}:
- TIFFRewriteField() renamed into _TIFFRewriteField() and moved out
- from the public interface. Type of its 'count' parameter changed
- from uint32 to tmsize_t.
-
- * /libtiff/tiffiop.h: Make tif_nfields and tif_nfieldscompat fields
- of the tiff structure have the size_t type instead of uint32.
-
-2008-04-09 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiffdump.c: Added support for MSVS 6.0.
-
- * libtiff/tif_dirread.c: Use custom functions _TIFFUInt64ToFloat()
- and _TIFFUInt64ToDouble() to convert 64-bit integers into floating
- point values on MSVS 6.0 platform.
-
-2008-03-14 Frank Warmerdam <warmerdam@pobox.com>
-
- * tif_dirread.c: Removed sanity checks on tags larger than 4MB in
- TIFFReadDirEntryArray() since they are interfering with seemingly
- legitimate files. http://trac.osgeo.org/gdal/ticket/2005
-
-2008-02-09 Joris Van Damme <joris.at.lebbeke@skynet.be>
-
- * tif_dirread.c: Added handling for the case of number of values for
- PageNumber tag different from 2 (previously resulted in an assert
- indicating lack of handling and was forgotten about)
-
-2008-02-01 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_jpeg.c: Do not try to fixup subsampling tags based on
- the actual jpeg data stream if the first strip/tile has zero size.
- This is the case when GDAL creates a new file with zero sizes, closes
- and reopens it.
-
-2008-01-07 Frank Warmerdam <warmerdam@pobox.com>
-
- * tools/tiff2ps.c: fix up 64bit issues (from Edward Lam).
-
-2008-01-01 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_dirwrite.c: #ifdef out lots of unused functions.
-
- * Makefile.vc, libtiff/Makefile.vc, tools/Makefile.vc: Improve clean
- targets.
-
- * tools/tiffinfo.c, tools/tiffcmp.c, tools/gif2tiff.c, tools/bmp2tiff.c
- tools/tiff2pdf.c: Fix 64-bit warnings when compiling under MSVC 2005
- (x64).
-
- * tools/tiffset.c: Changes to reflect the fact that TIFFFieldWithTag()
- and TIFFFieldWithName() now return TIFFField pointers instead of
- TIFFFieldInfo pointers.
-
- * tools/tiffdump.c: Added ssize_t typedef on Windows since it doesn't
- exist. This makes it compile again on Windows
-
- * tif_aux.c, tif_getimage.c, tif_next.c, tif_predict.c, tif_win32.c,
- tiffconf.vc.h: Various 64bit fixes from Edward Lam identified on win64.
-
- * test/rewrite_tag.c: New test for TIFFRewriteField().
-
-2007-12-31 Frank Warmerdam <warmerdam@pobox.com>
-
- * tif_dirwrite.c: Added TIFFRewriteField(). This new function
- rewrites one field "on disk" updating an existing directory
- entry. Lots of limitations still...
-
- * tiffiop.h, tif_write.c, tif_dirread.c, tif_flush.c: Keep track of
- TIFF_DIRTYSTRIP separately from TIFF_DIRTYDIRECT to indicate that
- the strip offset/size values are dirty but nothing else about the
- directory is dirty. In flush handle "just stripmaps dirty" as a
- special case that just rewrites these values without otherwise
- modifying the directory on disk using TIFFRewriteField().
-
- We also modify logic so that in update mode the directory is not
- marked dirty on read, but only when something is changed. This
- means we need to keep track of updates to the stripmap stuff in
- TIFFAppendToStrip().
-
-2007-12-10 Frank Warmerdam <warmerdam@pobox.com>
-
- * tif_jpeg.c: Improve ability to switch between encoding and decoding
- in the jpeg code (gdal bug #2033).
-
-2007-11-23 Frank Warmerdam <warmerdam@pobox.com>
-
- * tif_dir.c, tif_dirread.c, tif_dirwrite.c, tif_read.c, tif_write.c,
- tiffiop.h: Added TIFF_BUF4WRITE flag to indicate if contents of the
- rawcp/rawcc buffer are for writing and thus may require flushing.
- Necessary to distinguish whether they need to be written to disk when
- in mixed read/write mode and doing a mixture of writing followed by
- reading. http://trac.osgeo.org/gdal/ticket/1758
-
-2007-11-23 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * configure.com, libtiff/tif_vms.c: Better OpenVMS support. Patches
- from Alexey Chupahin.
-
-2007-11-02 Frank Warmerdam <warmerdam@pobox.com>
-
- * tif_write.c: Rip out the fancy logic in TIFFAppendToStrip() for
- establishing if an existing tile can be rewritten to the same location
- by comparing the current size to all the other blocks in the same
- directory. This is dangerous in many situations and can easily
- corrupt a file. (observed in esoteric GDAL situation that's hard to
- document). This change involves leaving the stripbytecount[] values
- unaltered till TIFFAppendToStrip(). Now we only write a block back
- to the same location it used to be at if the new data is the same
- size or smaller - otherwise we move it to the end of file.
-
- * tif_dirwrite.c: Try to avoid writing out a full readbuffer of tile
- data when writing the directory just because we have BEENWRITING at
- some point in the past. This was causing odd junk to be written out
- in a tile of data when a single tile had an interleaving of reading
- and writing with reading last. (highlighted by gdal
- autotest/gcore/tif_write.py test 7.
-
- * tif_predict.c: use working buffer in PredictorEncodeTile to avoid
- modifying callers buffer.
- http://trac.osgeo.org/gdal/ticket/1965
-
- * tif_predict.c/h: more fixes related to last item, keeping a
- distinct pfunc for encode and decode cases as these were getting
- mixed up sometimes.
- http://trac.osgeo.org/gdal/ticket/1948
-
-2007-11-01 Frank Warmerdam <warmerdam@pobox.com>
-
- * tif_predict.c/h, tif_lzw.c, tif_zip.c: Improvements so that
- predictor based encoding and decoding works in read-write update
- mode properly.
- http://trac.osgeo.org/gdal/ticket/1948
-
-2007-10-24 Joris Van Damme <joris.at.lebbeke@skynet.be>
-
- * tif_dirread.c: Fixed problem with bogus file triggering
- assert(td->td_planarconfig == PLANARCONFIG_CONTIG) in
- ChopUpSingleUncompressedStrip
-
-2007-10-22 Joris Van Damme <joris.at.lebbeke@skynet.be>
-
- * tif_jpeg.c: Resolved buffer incrementation bug that lead to faulty images
- at best, access violation at worst, when subsampled JPEG compressed imagery
- is decoded without the JPEG_COLORMODE feature
-
-2007-10-11 Frank Warmerdam <warmerdam@pobox.com>
-
- * html/index.html: Update "people responsible" section.
-
-2007-10-05 Frank Warmerdam <warmerdam@pobox.com>
-
- * tools/tiff2pdf.c: Fix problem with alpha setting in some cases
- as reported on the mailing list.
-
-2007-10-01 Joris Van Damme <joris.at.lebbeke@skynet.be>
-
- * changed some more incorrect %lud printf flags to %lu
-
-2007-09-29 Joris Van Damme <joris.at.lebbeke@skynet.be>
-
- * tif_dirread.c: Strip chopping interfered badly with uncompressed
- subsampled images because it tried to divide subsampled rowblocks,
- leading to all sorts of errors throughout the library for these
- images. Fixed by making strip chopping divide in row counts that
- are a multiple of vertical subsampling value.
-
-2007-09-28 Joris Van Damme <joris.at.lebbeke@skynet.be>
-
- * tif_dirread.c: Logical cast working around compiler warning
-
- * tif_read.c: Correction of some error flags and parameter lists
-
-2007-09-27 Joris Van Damme <joris.at.lebbeke@skynet.be>
-
- * tif_dirread.c: Made calculation of td_maxsamplevalue more robust
- when dealing with large bitspersample values, shutting up purification
- tools that warn about truncation, though it remains incorrect and
- indicates a conceptual problem there.
-
- * tif_open.c: Moved early exit in case of 'h' flag (to disable reading
- of first IFD) to proper place because it badly interfered with memory
- mapping, resulting in mapping flag even with dummy mapping functions
- that returned 0 whilst at the same time the mapping tif_size wasn't
- set, thus resulting in continuous incorrect beyond-eof errors.
-
-2007-09-24 Joris Van Damme <joris.at.lebbeke@skynet.be>
-
- * tif_dirinfo.c: Fixed (MSVC) compiler reports about
- inconsistent use of const in tiffFields and exifFields definition
-
-2007-09-20 Frank Warmerdam <warmerdam@pobox.com>
-
- * tif_dirwrite.c: Always write tile/strip offsets and sizes
- using LONG8 type when output format is BigTIFF. The
- TIFFWriteDirectoryTagLongLong8Array() function was restructured
- accordingly.
-
- * tif_dirread.c: Improvements to error reporting text in
- TIFFFetchDirectory().
-
-2007-09-19 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * test/images: Added a small collection of test images for use by
- test programs and scripts.
- * test/tiffinfo.sh: A trivial example test script.
- * test/common.sh: Added small script for setting the environment
- used by script-based tests.
-
-2007-08-24 Frank Warmerdam <warmerdam@pobox.com>
-
- * tif_dirwrite.c: Write the tif_nextdiroff value instead of a fixed
- zero when writing directory contents to preserve the ability to
- rewrite directories in place, even in the middle of a directory
- chain.
-
- * tif_dirinfo.c: _TIFFMergeFields() now only merges in field
- definitions that are missing. Existing definitions are silently
- ignored.
-
- * tif_dirread.c: Add runtime error for fields for which no definition
- is found (in addition to an assert for developers) in
- TIFFFetchNormalTag(). Not sure if this is needed, but it seems
- prudent.
-
-2007-08-10 Joris Van Damme <joris.at.lebbeke@skynet.be>
-
- * libtiff/tif_getimage.c: removed SubsamplingHor and SubsamplingVer
- from _TIFFRGBAImage structure to revert unwanted ABI change.
-
-2007-08-10 Joris Van Damme <joris.at.lebbeke@skynet.be>
-
- * libtiff/tif_win32.c: use SetFilePointer instead of
- SetFilePointerEx, as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1580
-
-2007-07-19 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_stream.cxx: Put all callback functions declarations
- inside extern "C" block.
-
- * libtiff/{tif_lzw.c, tif_luv.c, tif_dumpmode.c, tif_print.c,
- tif_read.c, tif_strip.c, tif_thunder.c}: Use "%I64d" printf()
- formatter instead of "%lld" with MSVC compiler.
-
- * libtiff/{tiffiop.h, tif_aux.c}: Added _TIFFUInt64ToFloat() and
- _TIFFUInt64ToDouble() functions.
-
-2007-07-18 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_dirread.c: Handle the case of MSVC 6 when using 64-bit
- integer constants.
-
- * libtiff/{Makefile.am, Makefile.v}: Do not distribute tiffconf.h,
- remove tif_config.h/tiffconf.h during cleaning. As per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1573
-
- * libtiff/tif_unix.c: Do not use O_LARGEFILE. As per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1577
-
-2007-07-13 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff 4.0.0alpha released.
-
-2007-07-12 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiff2pdf.c: Added missed extern optind as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1567
-
- * libtiff/{tif_close.c, tif_dirinfo.c, tiffiop.c, tif_dirread.c,
- tif_dir.h, tif_dir.c, tiffio.h}: Transition to the new-style tag
- extending scheme completed.
-
-2007-07-11 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff/tif_stream.cxx: Adapt to use toff_t again. Update to
- use standard C++ library size types and attempt to detect overflow
- cases.
-
-2007-07-08 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tif_jpeg.c, tif_dir.h, tif_dir.c, tif_dirinfo.c, tiffio.h,
- tif_ojpeg.c, tif_print.c, tif_fax3.c, tif_dirread.c}: More work on new
- tag extending scheme. Use the new scheme everywhere.
-
- * libtiff/{tif_zip.c, tif_predict.c, tif_pixarlog.c, tif_luv.c,
- tif_fax3.c, tif_dirread.c, tif_dirwrite.c, tif_close.c, tif_ojpeg.c,
- tif_jpeg.c, tif_dirinfo.c, tif_dir.h, tiffio.h, tiffiop.h}:
- TIFFFIeldInfo structure replaced with TIFFField structure.
- TIFFFieldInfo retained for the backward compatibility.
-
-2007-07-05 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * tools/tiff2pdf.c: Fix a compile problem when JPEG_SUPPORT is not
- defined.
-
-2007-07-04 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tif_dir.c, tiff.h, tiffio.h, libtiff.def}: Unused
- TIFFReassignTagToIgnore() function and TIFFIgnoreSense enumeration
- removed.
-
- * libtiff/{tif_dirinfo.c, tif_fax3.c, tif_jbig.c, tif_jpeg.c}: Move
- tags TIFFTAG_FAXRECVPARAMS, TIFFTAG_FAXSUBADDRESS,
- TIFFTAG_FAXRECVTIME and TIFFTAG_FAXDCS to the common tag directory.
- These tags are not codec-specific and relate to image content, so
- process them as other normal tags.
-
- * libtiff/{tiffio.h, tif_dir.h}: TIFFTagValue structure moved from the
- public tiffio.h to private tif_dir.h.
-
- * contrib/{acorn, mac-cw, mac-mpw}: Removed as unmaintained and
- outdated.
-
-2007-07-03 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff{tif_acorn.c, tif_apple.c, tif_atari.c, tif_msdos.c,
- tif_win3.c}: Obsoleted portability stuff removed.
-
- * tools/tiff2ps.c: Added support 16-bit images as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1566
-
- Patch from William Bader.
-
- * tools/tiff2pdf.c: Fix for TIFFTAG_JPEGTABLES tag fetching and
- significant upgrade of the whole utility as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1560
-
- Now we don't need tiffiop.h in tiff2pdf anymore and will open output
- PDF file using TIFFClientOpen() machinery as it is implemented
- by Leon Bottou.
-
-2007-06-26 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * configure.ac: Fix typo when substituting value for unsigned 8 bit type.
- Added support for a TIFF_PTRDIFF_T type to use when doing pointer arithmetic.
- Added support for a TIFF_SSIZE_T in order to return memory sizes but still
- allow returning -1 for errors.
- * libtiff/tiffconf.vc.h: Add porting type definitions for WIN32.
-
-2007-06-25 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * port/strtoull.c: New porting function in case strtoull() is not
- available on the target system.
- * configure.ac: Add configure support for determining sized types
- in a portable way and performing necessary substitutions in
- tif_config.h and tiffconf.h. Updated tiff.h to use the new
- definitions.
-
-2007-04-27 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiff2pdf.c: Check the tmpfile() return status as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=154
-
-2007-04-07 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tif_dir.h, tif_dirread.c, tif_dirinfo.c, tif_jpeg.c,
- tif_fax3.c, tif_jbig.c, tif_luv.c, tif_ojpeg.c, tif_pixarlog.c,
- tif_predict.c, tif_zip.c}: Finally fix bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1274
-
- by introducing _TIFFMergeFieldInfo() returning integer error status
- instead of void in case of problems with field merging (e.g., if the
- field with such a tag already registered). TIFFMergeFieldInfo() in
- public API remains void. Use _TIFFMergeFieldInfo() everywhere and
- check returned value.
-
-2007-04-07 Frank Warmerdam <warmerdam@pobox.com>
-
- * contrib/addtiffo/tif_overview.c: Fix problems with odd sized output
- blocks in TIFF_DownSample_Subsampled() (bug 1542).
-
-2007-04-06 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_jpeg.c: Changed JPEGInitializeLibJPEG() so that it
- will convert from decompressor to compressor or compress to decompress
- if required by the force arguments. This works around a problem in
- where the JPEGFixupTestSubsampling() may cause a decompressor to
- be setup on a directory when later a compressor is required with the
- force flag set. Occurs with the addtiffo program for instance.
-
-2007-04-06 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiffcrop.c, man/tiffcrop.1: Significant update in
- functionality from Richard Nolde. As per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1525
-
-2007-03-28 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_fax3.c: "inline static" -> "static inline" for IRIC CC.
-
-2007-03-17 Joris Van Damme <joris.at.lebbeke@skynet.be>
-
- * start of BigTIFF upgrade - CVS HEAD unstable until further notice
-
-2007-03-07 Joris Van Damme <joris.at.lebbeke@skynet.be>
-
- * libtiff/tif_getimage.c: workaround for 'Fractional scanline' error reading
- OJPEG images with rowsperstrip that is not a multiple of vertical subsampling
- factor. This bug is mentioned in:
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1390
- http://www.asmail.be/msg0054766825.html
-
-2007-03-07 Joris Van Damme <joris.at.lebbeke@skynet.be>
-
- * libtiff/tif_win32.c: made inclusion of windows.h unconditional
-
- * libtiff/tif_win32.c: replaced preprocessor indication for consiously
- unused arguments by standard C indication for the same
-
-2007-02-27 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_dirread.c: Use uint32 type instead of tsize_t in byte
- counters in TIFFFetchData(). Should finally fix the issue
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=890
-
-2007-02-24 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiffset.c: Properly handle tags with TIFF_VARIABLE writecount.
- As per bug http://bugzilla.remotesensing.org/show_bug.cgi?id=1350
-
- * libtiff/tif_dirread.c: Added special function to handle
- SubjectDistance EXIF tag as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1362
-
- * tools/tiff2pdf.c: Do not assume inches when the resolution units
- do not specified. As per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1366
-
- * tools/{tiffcp.c, tiffcrop.c}: Do not change RowsPerStrip value if
- it was set as infinite. As per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1368
-
- * tools/tiffcrop.c, man/tiffcrop.1: New tiffcrop utility contributed
- by Richard Nolde. As per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1383
-
-2007-02-22 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_dir.c: Workaround for incorrect TIFFs with
- ExtraSamples == 999 produced by Corel Draw. As per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1490
-
- * libtiff/{tif_dirread.c, tif_read.c}: Type of the byte counters
- changed from tsize_t to uint32 to be able to work with data arrays
- larger than 2GB. Fixes bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=890
-
- Idea submitted by Matt Hancher.
-
-2007-01-31 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tif2rgba.c: This utility does not work properly on big-endian
- architectures. It was fixed including the bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1149
-
-2007-01-15 Mateusz Loskot <mateusz@loskot.net>
-
- * Submitted libtiff port for Windows CE platform
- * libtiff/tif_config.wince.h: Added configuration header for WinCE.
- * libtiff/tiffconf.wince.h: Ported old configuration header for WinCE.
- * libtiff/tif_wince.c: Added WinCE-specific implementation of some
- functions from tif_win32.c.
- * libtiff/tif_win32.c: Disabled some functions already reimplemented in tif_wince.c.
- * libtiff/tiffiop.h, port/lfind.c: Added conditional include of some
- standard header files for Windows CE build.
- * tools/tiffinfoce.c: Ported tiffinfo utility for Windows CE.
-
-2006-11-19 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_write.c: TIFFAppendToStrip() - clear sorted flag if
- we move a strip.
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1359
-
-2006-10-13 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_dir.c: More fixes for vulnerabilities, reported
- in Gentoo bug ():
-
- http://bugs.gentoo.org/show_bug.cgi?id=142383
-
- * libtiff/contrib/dbs/xtiff/xtiff.c: Make xtiff utility compilable.
- Though it is still far from the state of being working and useful.
-
-2006-10-12 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_fax3.c: Save the state of printdir codec dependent
- method.
-
- * libtiff/tif_jpeg.c: Save the state of printdir codec dependent method
- as per bug http://bugzilla.remotesensing.org/show_bug.cgi?id=1273
-
- * libtiff/tif_win32.c: Fixed problem with offset value manipulation
- as per bug http://bugzilla.remotesensing.org/show_bug.cgi?id=1322
-
- * libtiff/{tif_read.c, tif_jpeg.c, tif_dir.c}: More fixes for
- vulnerabilities, reported in Gentoo bug ():
-
- http://bugs.gentoo.org/show_bug.cgi?id=142383
-
-2006-09-28 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tif_fax3.c, tif_next.c, tif_pixarlog.c}: Fixed multiple
- vulnerabilities, as per Gentoo bug ():
-
- http://bugs.gentoo.org/show_bug.cgi?id=142383
-
-2006-09-27 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_lzw.c, libtiff/tif_zip.c: Fixed problems with mixing
- encoding and decoding on the same read-write TIFF handle. The LZW
- code can now maintain encode and decode state at the same time. The
- ZIP code will switch back and forth as needed.
- http://bugzilla.remotesensing.org/show_bug.cgi?id=757
-
-2006-09-20 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff: Rename config.h.vc and tif_config.h.vc to config.vc.h and
- tif_config.vc.h for easier identification by folks using an IDE.
-
-2006-07-25 Frank Warmerdam <warmerdam@pobox.com>
-
- * tif_msdos.c: Avoid handle leak for failed opens. c/o Thierry Pierron
-
-2006-07-19 Frank Warmerdam <warmerdam@pobox.com>
-
- * tif_dirwrite.c: take care not to flush out buffer of strip/tile
- data in _TIFFWriteDirectory if TIFF_BEENWRITING not set. Relates
- to bug report by Peng Gao with black strip at bottom of images.
-
-2006-07-12 Frank Warmerdam <warmerdam@pobox.com>
-
- * tif_dirwrite.c: make sure to use uint32 for wordcount in
- TIFFWriteNormanTag if writecount is VARIABLE2 for ASCII fields.
- It already seems to have been done for other field types. Needed
- for "tiffset" on files with geotiff ascii text.
-
-2006-07-04 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * {configure.ac, libtiff/tif_config.h.vc, libtiff/tif_jbig.c}
- (JBIGDecode): jbg_newlen is not available in older JBIG-KIT and
- its use does not appear to be required, so use it only when it is
- available.
-
-2006-06-24 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_dirinfo.c: Added missed EXIF tag ColorSpace (40961).
-
- * libtiff/tif_dirread.c: Move IFD fetching code in the separate
- function TIFFFetchDirectory() avoiding code duplication in
- TIFFReadDirectory() and TIFFReadCustomDirectory().
-
-2006-06-19 Frank Warmerdam <warmerdam@pobox.com>
-
- * tools/tiff2pdf.c: Fix handling of -q values.
- http://bugzilla.remotesensing.org/show_bug.cgi?id=587
-
-2006-06-17 Frank Warmerdam <warmerdam@pobox.com>
-
- * tif_readdir.c: Added case in EstimateStripByteCounts() for tiled
- files. Modified TIFFReadDirectory() to not invoke
- EstimateStripByteCounts() for case where entry 0 and 1 are unequal
- but one of them is zero.
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1204
-
-2006-06-08 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tif_open.c, tif_dirread.c, tiffiop.h}: Move IFD looping
- checking code in the separate function TIFFCheckDirOffset().
-
- * libtiff/tif_aux.c: Added _TIFFCheckRealloc() function.
-
- * tools/tiffcmp.c: Fixed floating point comparison logic as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1191
-
- * libtiff/tif_fax3.c: Fixed problems in fax decoder as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1194
-
- * tools/tiff2pdf.c: Fixed buffer overflow condition in
- t2p_write_pdf_string() as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1196
-
-2006-06-07 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * {configure, configure.ac, libtiff/tif_jbig.c, tools/tiffcp.c}: Added
- support for JBIG compression scheme (34661 code) contributed by Lee
- Howard. As per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=896
-
- * configure, configure.ac: OJPEG support enabled by default.
-
- * contrib/ojpeg/: Removed. New OJPEG support does not need this patch.
-
-2006-06-03 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff/{tif_dirinfo.c, tif_print.c} : Fix crash in
- TIFFPrintDirectory(). Joris Van Damme authored the fix.
-
-2006-04-21 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiff2pdf.c: Unified line ending characters (always use '\n')
- as per bug http://bugzilla.remotesensing.org/show_bug.cgi?id=1163
-
- * README.vms, Makefile.am, configure.com, libtiff/{Makefile.am,
- tif_config.h-vms, tif_stream.cxx, tif_vms.c, tiffconf.h-vms}:
- Added support for OpenVMS by Alexey Chupahin, elvis_75@mail.ru.
-
-2006-04-20 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/{fax2ps.c, fax2tiff.c, ppm2tiff.c, ras2tiff.c, tiff2pdf.c}:
- Properly set the binary mode for stdin stream as per bug
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1141
-
- * man/{bmp2tiff.1, fax2ps.1, fax2tiff.1, gif2tiff.1, ras2tiff.1,
- raw2tiff.1, rgb2ycbcr.1, sgi2tiff.1, tiff2bw.1, tiff2pdf.1, tiff2ps.1,
- tiff2rgba.1, tiffcmp.1, tiffcp.1, tiffdither.1, tiffdump.1, tiffgt.1,
- tiffset.1}: Improvements in page formatting as per bug
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1140
-
- * html/tools.html, html/man/Makefile.am, tools/tiff2pdf.c: Fixed
- typos as per bug http://bugzilla.remotesensing.org/show_bug.cgi?id=1139
-
-2006-04-18 Frank Warmerdam <warmerdam@pobox.com>
-
- * nmake.opt: use /EHsc for VS2005 compatibility. Also define
- _CRT_SECURE_NO_DEPRECATE to avoid noise on VS2005.
-
-2006-04-12 Joris Van Damme <joris.at.lebbeke@skynet.be>
-
- * libtiff/tif_getimage.c: Added support for planarconfig separate
- non-subsampled YCbCr (i.e. separate YCbCr with subsampling [1,1])
-
-2006-04-11 Joris Van Damme <joris.at.lebbeke@skynet.be>
-
- * libtiff/tif_getimage.c: Revision of all RGB(A) put routines
- - Conversion of unassociated alpha to associated alpha now done with
- more performant LUT, and calculation more correct
- - Conversion of 16bit data to 8bit data now done with
- more performant LUT, and calculation more correct
- - Bugfix of handling of 16bit RGB with unassociated alpha
-
-2006-04-11 Joris Van Damme <joris.at.lebbeke@skynet.be>
-
- * libtiff/tif_getimage.c:
- - When there is no alpha, gtTileSeparate and gtStripSeparate allocated
- buffer for alpha strile and filled it, only to never read it back.
- Removed allocation and fill.
- - Minor rename of vars in gtTileSeparate and gtStripSeparate
- anticipating planned functionality extension
-
-2006-04-08 Joris Van Damme <joris.at.lebbeke@skynet.be>
-
- * libtiff/tif_getimage.c: renamed pickTileContigCase to PickContigCase
- and pickTileSeparateCase to PickSeparateCase as both work on strips as
- well
-
- * libtiff/tif_getimage.c: moved img->get selection from
- TIFFRGBAImageBegin into PickContigCase and PickSeparateCase to create
- logical hook for planned functionality extension
-
-2006-04-08 Joris Van Damme <joris.at.lebbeke@skynet.be>
-
- * libtiff/tif_ojpeg.c: resolved memory leak that was a consequence
- of inappropriate use of jpeg_abort instead of jpeg_destroy
-
-2006-04-07 Joris Van Damme <joris.at.lebbeke@skynet.be>
-
- * libtiff/tif_getimage.c: replaced usage of TIFFScanlineSize in
- gtStripContig with TIFFNewScanlineSize so as to fix buggy behaviour
- on subsampled images - this ought to get sorted when we feel brave
- enough to replace TIFFScanlineSize altogether
-
- * libtiff/tif_ojpeg.c: fixed bug in OJPEGReadSkip
-
-2006-04-04 Joris Van Damme <joris.at.lebbeke@skynet.be>
-
- * libtiff/tiffio.h: added new type tstrile_t
-
- * libtiff/tif_dir.h: changed types of td_stripsperimage and td_nstrips
- to new tstrile_t, types of td_stripoffset and td_stripbytecount to
- toff_t*
-
- * libtiff/tif_ojpeg.c: totally new implementation
-
- * libtiff/tif_dirread.c: added several hacks to suit new support of
- OJPEG
-
- * libtiff/tif_getimage.c: removed TIFFTAG_JPEGCOLORMODE handling
- of OJPEG images in favor of tif_getimage.c native handling of
- YCbCr and desubsampling
-
-2006-03-29 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_jpeg.c: JPEGVSetField() so that altering the photometric
- interpretation causes the "upsampled" flag to be recomputed. Fixes
- peculiar bug where photometric flag had to be set before jpegcolormode
- flag.
-
-2006-03-25 Joris Van Damme <joris.at.lebbeke@skynet.be>
-
- * libtiff/tif_jpeg.c: strip size related bugfix in encode raw
-
- * libtiff/tif_strip.c: temporarily added two new versions of
- TIFFScanlineSize
- - TIFFNewScanlineSize: proposed new version, after all related
- issues and side-effects are sorted out
- - TIFFOldScanlineSize: old version, from prior to 2006-03-21 change
- This needs further sorting out.
-
-2006-03-25 Joris Van Damme <joris.at.lebbeke@skynet.be>
-
- * contrib/addtiffo/tif_ovrcache.c: bugfix to correctly pass size
- of last truncated strip data to TIFFWriteEncodedStrip
-
-2006-03-25 Joris Van Damme <joris.at.lebbeke@skynet.be>
-
- * libtiff/{tif_jpeg.c, tif_strip.c}: bugfix of tif_jpeg decode raw
-
-2006-03-25 Joris Van Damme <joris.at.lebbeke@skynet.be>
-
- * libtiff/tif_getimage.c: bugfix/rewrite of putcontig8bitYCbCr22tile
-
- * libtiff/tif_getimage.c: added putcontig8bitYCbCr12tile
-
- * libtiff/tif_read.c: added support for new TIFF_NOREADRAW flag to
- prepare the path for new tif_ojpeg.c
-
-2006-03-23 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff 3.8.2 released.
-
- * tools/Makefile.am: Use runtime paths linker flags when rpath
- option enabled.
-
-2006-03-21 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/libtiff.def: Added missed exports as per bug
- http://bugzilla.remotesensing.org/attachment.cgi?id=337
-
- * contrib/addtiffo/Makefile.vc, libtiff/Makefile.vc, port/Makefile.vc,
- tools/Makefile.vc: Makefiles improvements as per bug
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1128
-
- * nmake.opt libtiff/{tif_config.h.vc, tif_unix.c, tiffio.h},
- tools/{fax2ps.c, fax2tiff.c, tiff2pdf.c}: Fixed win32 I/O functions
- usage as per bug http://bugzilla.remotesensing.org/show_bug.cgi?id=1127
-
- * libtiff/tif_strip.c: Take subsampling in account when calculating
- TIFFScanlineSize().
-
- * tools/tiffcp.c: Do not set RowsPerStrip bigger than image length.
-
-2006-03-17 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/fax2tiff.c: Fixed wrong TIFFerror() invocations as per bug
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1125
-
- * tools/fax2ps.c: Fixed reading the input stream from stdin as per bug
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1124
-
-2006-03-16 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tiffiop.h: Added declaration for
- _TIFFSetDefaultCompressionState().
-
- * libtiff/{tif_jpeg.c, tif_fax3.c, tif_zip.c, tif_pixarlog.c,
- tif_lzw.c, tif_luv.c}: Use _TIFFSetDefaultCompressionState() in all
- codec cleanup methods. As per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1120
-
-2006-03-15 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_jpeg.c: Do not cleanup codec state in TIFFInitJPEG(). As
- per bug http://bugzilla.remotesensing.org/show_bug.cgi?id=1119
-
- * tools/raw2tiff.c: Do not set RowsPerStrip larger than ImageLength.
- As per bug http://bugzilla.remotesensing.org/show_bug.cgi?id=1110
-
- * libtiff/tiffiop.h: dblparam_t typedef removed; GLOBALDATA macro
- removed; move here the STRIP_SIZE_DEFAULT macro definition.
-
- * libtiff/{tif_dirread.c, tif_strip.c}: Removed STRIP_SIZE_DEFAULT
- macro definition.
-
- * libtiff/tif_dir.c: Use double type instead of dblparam_t.
-
-2006-03-14 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_dirread.c: Do not check the PlanarConfig tag presence
- in TIFFReadDirectory, because it is always set at the start of
- function and we allow TIFFs without that tag set.
-
-2005-03-13 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff 3.8.1 released.
-
-2006-03-07 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_dirread.c: Fixed error reporting in TIFFFetchAnyArray()
- function as per bug
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1102
-
- * libtiff/tif_dirread.c: More wise check for integer overflow
- condition as per bug
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1102
-
- * libtiff/{tif_jpeg.c, tif_pixarlog.c, tif_fax3.c, tif_zip.c}:
- Properly restore setfield/getfield methods in cleanup functions. As
- per bug http://bugzilla.remotesensing.org/show_bug.cgi?id=1102
-
-2006-03-03 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tif_predict.c, tif_predict.h}: Added new function
- TIFFPredictorCleanup() to restore parent decode/encode/field methods.
-
- * libtiff/{tif_lzw.c, tif_pixarlog.c, tif_zip.c}: Use
- TIFFPredictorCleanup() in codec cleanup methods. As per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1102
-
- * libtiff/tif_dirread.c: Fixed integer overflow condition in
- TIFFFetchData() function. As per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1102
-
-2006-03-01 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_ojpeg.c: Set the ReferenceBlackWhite with the
- TIFFSetField() method, not directly. As per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1043
-
- * tools/ppm2tiff.c: Added support for PBM files as per bug
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1044
-
-2006-02-27 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_write.c: Small code rearrangement in TIFFWriteScanline()
- to avoid crash as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1081.
-
-2006-02-26 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiff2pdf.c: Functions t2p_sample_rgbaa_to_rgb() and
- t2p_sample_rgba_to_rgb() was used in place of each other, that was
- resulted in problems with RGBA images with associated alpha.
- As per bug http://bugzilla.remotesensing.org/show_bug.cgi?id=1097
-
-2006-02-23 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_dirwrite.c: Properly write TIFFTAG_DOTRANGE tag as per
- bug http://bugzilla.remotesensing.org/show_bug.cgi?id=1088.
-
- * libtiff/tif_print.c: Properly read TIFFTAG_PAGENUMBER,
- TIFFTAG_HALFTONEHINTS, TIFFTAG_YCBCRSUBSAMPLING and TIFFTAG_DOTRANGE
- tags as per bug http://bugzilla.remotesensing.org/show_bug.cgi?id=1088.
-
- * tools/tiff2ps.c: Properly scale all the pages when converting
- multipage TIFF with /width/height/center options set. As per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1080
-
-2006-02-15 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiff2pdf.c: Do not create output file until all option checks
- will be done. As per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1072
-
- * tools/bmp2tiff.c: Added ability to create multipage TIFFs from the
- list of input files as per bug:
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1077
-
-2006-02-09 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_tile.c: Fix error reporting in TIFFCheckTile() as per
- bug http://bugzilla.remotesensing.org/show_bug.cgi?id=1063.
-
- * tools/tiffgt.c: Avoid crashing in case of image unsupported by
- TIFFRGBAImage interface.
-
- * libtiff/tif_color.c: Avoid overflow in case of wrong input as per
- bug http://bugzilla.remotesensing.org/show_bug.cgi?id=1065.
-
-2006-02-07 Frank Warmerdam <warmerdam@pobox.com>
-
- * tools/tiff2pdf.c: Fixed support for non-YCbCr encoded JPEG
- compressed TIFF files, per submission from Dan Cobra.
-
-2006-02-07 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tif_dirread.c, tif_packbits.c, tif_win32.c}: Properly
- cast values to avoid warnings. As per bug
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1033.
-
- * libtiff/tif_dirinfo.c: Use TIFF_NOTYPE instead of 0 when
- appropriate. As per bug
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1033.
-
- * libtiff/tif_aux.c: Fixed type of temporary variable in
- _TIFFCheckMalloc() as per bug
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1033.
-
-2006-02-06 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_aux.c: Return static array when fetching default
- YCbCrCoefficients (another problem, reported a the
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1029 entry).
-
-2006-02-03 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_dir.c: Special handling for PageNumber, HalftoneHints,
- YCbCrSubsampling and DotRange tags as per bugs
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1029
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1034
-
- * libtiff/tif_dirread.c: Use _TIFFGetExifFieldInfo() instead of
- _TIFFGetFieldInfo() in TIFFReadEXIFDirectory() call as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1026.
-
-2006-01-23 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtool related stuff updated from the 2.1a branch.
-
-2006-01-11 Frank Warmerdam <warmerdam@pobox.com>
-
- * tools/bmp2tiff,pal2rgb,ppm2tiff,ras2tiff,raw2tiff,sgi2tiff,
- tiff2bw,tiffcp: Fixed jpeg option processing so -c jpeg:r:50 works
- properly as per bug:
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1025
-
-2006-01-09 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * configure.ac: Fix with_default_strip_size comparison as reported
- by Norihiko Murase.
-
-2006-01-08 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * test/Makefile.am (LIBTIFF): Due to linking against libtiff
- incorrectly, tests were not actually testing the uninstalled
- libtiff. Now they are.
-
-2006-01-04 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_dirinfo.c: Change definitions for TIFFTAG_ICCPROFILE,
- TIFFTAG_PHOTOSHOP, TIFFTAG_RICHTIFFIPTC, TIFFTAG_XMLPACKET: readcount
- should be uint32 value.
-
-2006-01-02 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * html/man/Makefile.am (htmldoc): Fix htmldoc rule so that it can
- be used if build directory is not the same as source directory.
- * man/{TIFFGetField.3tiff, TIFFSetField.3tiff}: Documented
- TIFFTAG_PHOTOSHOP, TIFFTAG_RICHTIFFIPTC, and TIFFTAG_XMLPACKET,
- and re-sorted tag names in alphabetical order.
-
-2005-12-29 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff 3.8.0 released.
-
-2005-12-28 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * tools/bmp2tiff.c (main): Fixed warning regarding returning
- inconsistent types from a condition.
- * tools/tiffcmp.c (CheckLongTag): Eliminate warning due to printf
- format.
- * tools/bmp2tiff.c: Reduce compilation warnings on big-endian CPUs.
-
-2005-12-28 Joris Van Damme <joris.at.lebbeke@skynet.be>
-
- * html/{index.html, support.hml, libtiff.html}: Cleaned up HTML
-
-2005-12-27 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tiffio.h: Added VC_EXTRALEAN definition before including
- windows.h, to reduce the compile time.
-
-2005-12-26 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff/tif_jpeg.c: Improve compilation under MinGW.
-
-2005-12-26 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tif_dir.c, tif_dir.h, tif_dirread.c, tif_dirinfo.c}:
- tiffFieldInfo and exifFieldInfo arrays definitions moved back to
- tif_dirinfo.c; added _TIFFGetFieldInfo() and _TIFFGetExifFieldInfo()
- private functions to retrieve FieldInfo arrays.
-
-2005-12-24 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * html/build.html: Added some additional instructions for when
- building using MSVC under Windows. Also fixed two HTML syntax
- errors and used HTML Tidy to tidy up the HTML syntax and
- formatting.
-
-2005-12-24 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tif_aux.c, tif_dir.c, tif_dir.h, tif_dirwrite.c,
- tif_print.c, tif_getimage.c}: Make InkSet, NumberOfInks, DotRange and
- StoNits tags custom.
-
-2005-12-23 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tif_aux.c, tif_dir.c, tif_dir.h, tif_print.c}: Make
- WhitePoint tag custom.
-
- * libtiff/{tif_dir.h, tiff.h}: More EXIF tags added.
-
-2005-12-23 Joris Van Damme <joris.at.lebbeke@skynet.be>
-
- * libtiff/tiffio.h: fixed typo that potentially resulted in
- redefininition of USE_WIN32_FILEIO
-
- * libtiff/*: Added more 'dual-mode' error handling: Done TIFFWarning
- calls in core LibTiff.
-
-2005-12-21 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tif_dir.c, tif_dir.h, tif_print.c}: Make RichTIFFIPTC,
- Photoshop and ICCProfile tags custom.
-
-2005-12-21 Joris Van Damme <joris.at.lebbeke@skynet.be>
-
- * libtiff/*, contrib/*: Added 'dual-mode' error handling, enabling
- newer code to get context indicator in error handler and still
- remain compatible with older code: Done TIFFError calls everywhere
- except in tools
-
-2005-12-20 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiffcp.c: Added many error reporting messages; fixed integer
- overflow as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=789
-
-2005-12-16 Frank Warmerdam <warmerdam@pobox.com>
-
- * contrib/addtiffo/*: Major upgrade by Joris to support subsampled
- YCbCr images in jpeg compressed TIFF files.
-
-2005-12-14 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiffcp.c: Return non-zero status when reading fails (again).
-
-2005-12-13 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiffcp.c: Return non-zero status when reading fails.
-
-2005-12-12 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tif_dir.h, tiff.h}: Added more EXIF tags.
-
-2005-12-09 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tif_dir.c, tif_dir.h, tif_print.c}: Make XMLPacket tag
- custom.
-
- * tools/tiffinfo.c: Print EXIF directory contents if exist.
-
- * libtiff/tiff.h: Few EXIF tag numbers added.
-
- * libtiff/{tif_dirinfo.c, tif_dirread.c, tif_dir.h, tif_dir.c,
- tiffio.h}: Preliminary support to read custom directories. New
- functions: TIFFReadCustomDirectory() and TIFFReadEXIFDirectory().
-
-2005-12-07 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tif_dirinfo.c, tif_dirread.c, tif_dir.h, tif_dir.c}:
- More work to implement custom directory read support.
-
- * libtiff/{tif_aux.c, tif_dirinfo.c, tif_dirread.c, tif_dir.h,
- tif_dir.c, tif_print.c}: Make YCbCrCoefficients and ReferenceBlackWhite
- tags custom.
-
-2005-12-05 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_dirread.c: One more workaround for broken
- StripByteCounts tag. Handle the case when StripByteCounts array filled
- with completely wrong values.
-
-2005-11-30 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_dirinfo.c: Release file descriptor in case of failure
- in the TIFFOpenW() function as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1003
-
- * libtiff/tif_dirinfo.c: Correctly use bsearch() and lfind()
- functions as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1008
-
-2005-11-20 Frank Warmerdam <warmerdam@pobox.com>
-
- * tif_open.c, tiff.h, tiffdump.c: Incorporate preliminary support
- for MS MDI format.
- http://bugzilla.remotesensing.org/show_bug.cgi?id=1002
-
- * .cvsignore: many files added, and a few update according
- to suggestion of Brad HArds on tiff mailing list.
-
-2005-11-03 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/libtiff.def, tiffiop.h, tiffio.h: Made TIFFFreeDirectory
- public.
-
-2005-10-31 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/fax2tiff.c: Properly calculate sizes of temporary arrays
- as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=943
-
- * tools/fax2tiff.c: Added option '-r' to set RowsPerStrip parameter
- as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=944
-
- * tools/tiffdump.c: Fixed typeshift and typemask arrays initialization
- problem as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=946
-
- * tools/bmp2tiff.c: Fixed possible integer overflow error as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=965
-
- * libtiff/tif_dirinfo.c: Make XResolution, YResolution and
- ResolutionUnit tags modifiable during write process. As per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=977
-
- * tools/tiffsplit.c: Copy fax related fields over split parts
- as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=983
-
-2005-10-21 Frank Warmerdam <warmerdam@pobox.com>
-
- * tif_dirread.c: Don't try and split single strips into "0" strips
- in ChopUpSingleUncompressedStrip. This happens in some degenerate
- cases (like 1x1 files with stripbytecounts==0 (gtsmall.jp2 embed tiff)
-
-2005-10-20 Joris Van Damme <joris.at.lebbeke@skynet.be>
-
- * tif_fax3.c: changed 'at scanline ...' style warning/errors
- with incorrect use of tif_row, to 'at line ... of
- strip/tile ...' style
-
-2005-10-15 Frank Warmerdam <warmerdam@pobox.com>
-
- * tif_write.c: fixed setting of planarconfig as per bug report
- on the mailing list from Joris.
-
-2005-10-07 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * configure.ac, configure, nmake.opt, libtiff/{tif_config.h,
- tif_dirread.c}: Make the default strip size configurable via the
- --with-default-strip-size and STRIP_SIZE_DEFAULT options.
-
-2005-09-30 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * html/support.html: Fixed link to documentation on Greg Ward's
- LogLuv TIFF format.
-
-2005-09-28 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiffdump.c: Fixed crash when reading malformed tags.
-
-2005-09-20 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiff2pdf.c: Added missed 'break' statement as per bug
- http://bugzilla.remotesensing.org/show_bug.cgi?id=932
-
-2005-09-12 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff 3.7.4 released.
-
- * {configure, configure.ac, Makefile.am, autogen.sh}: Applied patch
- from Patrick Welche (all scripts moved in the 'config' and 'm4'
- directories).
-
-2005-09-12 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_open.c: reintroduce seek to avoid problem on solaris.
-
-2005-09-05 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_dir.c: When prefreeing tv->value in TIFFSetFieldV
- also set it to NULL to avoid double free when re-setting custom
- string fields as per:
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=922
-
-2005-08-12 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_print.c: avoid signed/unsigned warning.
-
- * libtiff/tif_dirread.c: removed unused variable.
-
-2005-07-30 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_dir.c: Fixed up support for swapping "double complex"
- values (128 bits as 2 64 bits doubles). GDAL gcore tests now
- pass on bigendian (macosx) system.
-
-2005-07-28 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tif_aux.c, tif_dirread.c, tif_fax3.c, tiffiop.h}: Rename
- CheckMalloc() function to _TIFFCheckMalloc() and make it available
- globally as an internal helper routine.
-
-2005-07-27 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_dir.c: More improvements in the "pass by value" part of
- the custom tags handling code.
-
-2005-07-26 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tif_dirread.c, tif_dirinfo.c}: Do not upcast BYTEs to
- SHORTs in the TIFFFetchByteArray(). Remove TIFFFetchExtraSamples()
- function, use TIFFFetchNormalTag() instead as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=831
-
- Remove TIFFFetchExtraSamples() function, use TIFFFetchNormalTag()
- instead.
-
- * libtiff/tiffconf.h.in: One more attempt to fix the AIX bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=39
-
-2005-07-25 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_print.c: Fixed printing of the BYTE and SBYTE arrays.
-
- * tools/tiffdump.c: Added support for TIFF_IFD datatype.
-
-2005-07-21 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_write.c: Do not check the PlanarConfiguration field in
- the TIFFWriteCheck() function in case of single band images (as per
- TIFF spec).
-
-2005-07-12 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * SConstruct, libtiff/SConstruct: Added the first very preliminary
- support for SCons software building tool (http://www.scons.org/).
- This is experimental infrastructure and it will exist along with the
- autotools mechanics.
-
-2005-07-07 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * port/{getopt.c, strcasecmp.c, strtoul.c}: Update modules from
- the NetBSD source tree (the old 4-clause BSD license changed to
- the new 3-clause one).
-
- * configure.ac, port/lfind.c, libtiff/tiffiop.h: Added lfind()
- replacement module.
-
- * port/dummy.c: Make the dummy function static.
-
-2005-07-06 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiffcp.c: Fixed WhitePoint tag copying.
-
- * libtiff/{tif_dir.c, tif_dir.h, tif_dirinfo.c, tif_print.c}:
- Make FieldOfViewCotangent, MatrixWorldToScreen, MatrixWorldToCamera,
- ImageFullWidth, ImageFullLength and PrimaryChromaticities tags custom.
-
-2005-07-04 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff 3.7.3 released.
-
- * configure, configure.ac: Do not use empty -R option when linking
- with --enable-rpath.
-
-2005-07-01 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tiffiop.h, tif_open.c}: Added open option 'h' to avoid
- reading the first IFD when needed. As per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=875
-
- * libtiff/tif_color.c: Better use of TIFFmin() macro to avoid side
- effects.
-
-2005-06-23 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiff2pdf.c: Print two characters per loop in the
- t2p_write_pdf_trailer(). As per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=594
-
- * tools/tiffgt.c: Use MacOS X OpenGL framework when appropriate. As
- per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=844
-
- * acinclude.m4: Updated to latest OpenGL test macros versions.
-
- * libtiff/tiff.h: Use correct int size on Sparc 64bit/Sun compiler
- platform. As per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=855
-
-2005-06-14 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_dirinfo.c: Added support for ClipPath, XClipPathUnits
- and YClipPathUnits tags.
-
-2005-06-07 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * contrib/addtiffo/tif_ovrcache.c: Properly extract tile/strip size;
- use pixel sized shift in contiguous case.
-
-2005-06-06 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * contrib/addtiffo/{tif_overview.c, tif_ovrcache.c, tif_ovrcache.h}:
- Make overviews working for contiguous images.
-
-2005-06-03 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_open.c: Replace runtime endianness check with the compile
- time one.
-
- * libtiff/tif_predict.c: Floating point predictor now works on
- big-endian hosts.
-
-2005-06-01 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_dir.c: Use _TIFFsetString() function when read custom
- ASCII values.
-
- * libtiff/{tif_dirinfo.c, tif_dir.h, tif_dir.c, tif_print.c}: Make
- DocumentName, Artist, HostComputer, ImageDescription, Make, Model,
- Copyright, DateTime, PageName, TextureFormat, TextureWrapModes and
- TargetPrinter tags custom.
-
- * libtiff/tif_jpeg.c: Cleanup the codec state depending on
- TIFF_CODERSETUP flag (to fix memry leaks).
-
- * libtiff/tif_jpeg.c: Initialize JPEGTables array with zero after
- allocating.
-
-2005-05-26 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * configure.ac, libtiff/Makefile.am: Added workaround for
- OpenBSD/MirOS soname problem as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=838
-
- * libtiff/tif_dirwrite.c: Use tdir_count when calling
- TIFFCvtNativeToIEEEDouble() in the TIFFWriteDoubleArray() function as
- per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=845
-
-2005-05-25 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/ppm2tiff.c: Fixed format string when read PPM file header with
- the fscanf() function. As per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=861
-
- * libtiff/{tif_dirinfo.c, tif_print.c}: TIFFFetchByteArray() returns
- uint16 array when fetching the BYTE and SBYTE filds, so we should
- consider result as pointer to uint16 array and not as array of chars.
- As per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=831
-
- * libtiff/tif_dir.c: More efficient custom tags retrieval as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=830
-
- * libtiff/tif_win32.c: Use FILE_SHARE_READ | FILE_SHARE_WRITE share
- mode in CreateFile() call as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=829
-
- * libtiff/Makefile.am: Fixed parallel compilation of the libtiff and
- libtiffxx libraries as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=826
-
- * contrib/addtiffo/{tif_overview.c, tif_ovrcache.h}: Sinchronized with
- GDAL.
-
-2005-05-23 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_jpeg.c: Substantial fix for addtiffo problems with
- JPEG encoded TIFF files. Pre-allocate lots of space for jpegtables
- in directory.
-
-2005-05-22 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_dirread.c: Changed the code that computes
- stripbytecount[0] if it appears bogus to ignore if stripoffset[0] is
- zero. This is a common case with GDAL indicating a "null" tile/strip.
-
-2005-05-17 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiffsplit.c: Check for JPEGTables tag presence before copying.
-
-2005-05-06 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_dirread.c: Applied similar change to
- TIFFFetchPerSampleLongs and TIFFFetchPerSampleAnys.
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=843
-
- * libtiff/tif_jpeg.c: added LIB_JPEG_MK1 support in JPEGDecodeRaw().
-
-2005-05-06 Andrey Kiselev <dron@ak4719.spb.edu>
- * tools/tiff2pdfr.c, man/tiff2pdf.1: Calculate the tile width properly;
- added new option '-b' to use interpolation in output PDF files (Bruno
- Ledoux).
-
-2005-05-05 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_dirread.c: Ensure that broken files with too many
- values in PerSampleShorts work ok instead of crashing.
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=843
-
-2005-04-27 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiffdither.c: Copy the PhotometricInterpretation tag from the
- input file.
-
-2005-04-15 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_predict.c: Added ability to encode floating point
- predictor, as per TIFF Technical Note 3.
-
-2005-04-14 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tif_predict.h, tif_predict.c}: Added ability to decode
- floating point predictor, as per TIFF Technical Note 3.
-
-2005-04-13 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tiffio.h, tiffiop.h, tif_dir.c, tif_read.c, tif_swab.c}:
- Added _TIFFSwab24BitData() and TIFFSwabArrayOfLong() functions used to
- swap 24-bit floating point values.
-
- * libtiff/tiff.h: Added predictor constants.
-
-2005-04-08 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tiffiop.h, tif_dir.c}: Use uint32 type for appropriate
- values in _TIFFVSetField() function. Inspired by the bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=816
-
- * man/TIFFSetField.3tiff: Fixed definition of the TIFFTAG_INKNAMES tag
- as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=816
-
-2005-03-30 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_open.c: Do not read header in case the output file
- should be truncated (Ron).
-
- * libtiff/{tif_dirinfo.c, tif_config.h.vc}: Use lfind() instead
- of bsearch() in _TIFFFindFieldInfoByName() function (Ron).
-
- * libtiff/{tiff.h, tif_dirinfo.c}: Fixes in EXIF tag ordering (Ron).
-
-2005-03-22 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * configure.ac, libtiff/Makefile.am: Use libtool machinery to pass
- rpath option.
-
-2005-03-21 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tif_dir.c, tif_print.c}: Handle all data types in custom
- tags.
-
-2005-03-18 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/dirinfo.c: Added DNG tags.
-
- * libtiff/{tif_dir.c, tif_print.c}: More improvements in custom tag
- handling code.
-
- * libtiff/tiff.h: More comments; added missed DNG tag (LensInfo);
- added DNG 1.1.0.0 tags.
-
- * tools/tif2pdf.c: Fixed problem with alpha channel handling as per
- bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=794
-
- * man/TIFFGetField.3tiff: Add a note about autoregistered tags.
-
-2005-03-17 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * nmake.opt: Build with Win32 CRT library by default.
-
- * tools/tiff2ps.c: Fixed typo in page size handling code.
-
- * libtiff/{tif_dir.c, tif_print.c}: Support for custom tags, passed
- by value.
-
- * libtiff/{tiff.h, tif_dirinfo.c, tiffiop.h}: Added EXIF related tags.
-
-2005-03-15 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff 3.7.2 released.
-
-2005-03-09 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiffcmp.c: Added ability to compare the 32-bit integer and
- floating point data; complain on unsupported bit depths.
-
-2005-03-05 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tif_stream.cxx: Use ios namespace instead of ios_base to support
- GCC 2.95.
-
- * libtiff/{tiff.h, tif_fax3.tif, tif_jpeg.c}: Applied correct patch from
- Lee Howard for HylaFax DCS tag
- (see http://bugzilla.remotesensing.org/show_bug.cgi?id=771)
-
-2005-03-04 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * configure, configure.ac: Use -rpath option instead of -R as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=732
-
- * libtiff/{tiff.h, tif_fax3.tif, tif_jpeg.c}: Applied patch from Lee
- Howard to support a new tag TIFFTAG_FAXDCS (34911) used in HylaFax
- software. As per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=771
-
- * nmake.opt, html/build.html: Add more comments, change the config
- file organization a bit as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=764
-
- * tools/tiffcmp.c: Use properly sized buffer in short arrays comparison
- as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=785
-
-2005-03-03 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_dirread.c: More logic to guess missed strip size as per
- bug http://bugzilla.remotesensing.org/show_bug.cgi?id=705
-
- * tools/fax2ps.c: Replace insecure mktemp() function with the
- tmpfile() as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=786
-
-2005-02-04 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tiff.h: Changed the int8 definition to be always signed char
- as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=727
-
- * libtiff/tiffio.h: Move TIFFOpenW() function into the extern "C"{}
- block as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=763
-
-2005-02-03 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * tools/tiffgt.c: Fix problem on big-endian CPUs so that images
- display more correctly. Images display brighter than they should
- on a Sun workstation.
-
-2005-02-03 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_dirread.c: Estimate strip size in case of wrong or
- suspicious values in the tags. As per bugs
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=705
-
- and
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=320
-
- * tools/tiff2ps.c: Fixed problem with page sizes as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=742
-
-2005-01-31 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff/tiff.h (TIFFTAG_TILEWIDTH): Corrected description.
- (TIFFTAG_TILELENGTH): Corrected description.
-
-2005-01-30 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * configure.ac: Fixes for --with-docdir option as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=759
-
- * libtiff/tif_open.c: Remove unnesessary TIFFSeekFile() call as per
- bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=756
-
- * libtiff/tif_stream.cxx: Fixes for C++ stream interface from
- Michael Rinne and Edward Lam.
-
-2005-01-15 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * configure.ac: Make the documentation directory location configurable
- via the --with-docdir option (as suggested by Jeremy C. Reed).
-
- * libtiff/tif_color.c: Use double as the second argument of pow()
- function in TIFFCIELabToRGBInit(). As per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=741
-
- * libtiff/tif_pixarlog.c: Avoid warnings when converting float to
- integer as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=740
-
- * libtiff/tif_getimage.c: Always fill the error message buffer in
- TIFFRGBAImageBegin() as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=739
-
-2005-01-12 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_jpeg.c: Added ability to read/write the fax specific
- TIFFTAG_FAXRECVPARAMS, TIFFTAG_FAXSUBADDRESS and TIFFTAG_FAXRECVTIME
- tags as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=736
-
- * libtiff/tif_win32.c: Fixed message formatting in functions
- Win32WarningHandler() and Win32ErrorHandler() as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=735
-
- * tools/tiff2ps.c: Interpret the -w and -h options independently. As
- per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=689
-
-2005-01-11 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tiffio.h: Move the color conversion routines in the 'extern
- "C"' section as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=727
-
- * libtiff/tiff.h: Restore back the workaround for AIX Visual Age C
- compiler to avoid double definition of BSD types as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=39
-
- * libtiff/Makefile.am: Place the C++ stream API in the separate
- library called libtiffxx to avoid unneeded dependencies. Probably
- there will be more C++ API in the future. As per bugs
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=733
-
- and
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=730
-
-2005-01-05 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiffdump.c: Fixed problem when read broken TIFFs with the
- wrong tag counts (Dmitry V. Levin, Martin Pitt).
-
- * configure.ac: Replace --disable-c++ with the --disable-cxx option as
- per bug http://bugzilla.remotesensing.org/show_bug.cgi?id=730
-
-2004-12-25 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_getimage.c: More fixes for multiple-alpha-channelled
- RGB-images as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=713
-
-
- * tools/tiffset.c: Convert character option to integer value as per
- bug http://bugzilla.remotesensing.org/show_bug.cgi?id=725
-
-2004-12-20 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff 3.7.1 released.
-
- * html/tiffset.1.html: Add missed manual page as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=678
-
- * libtiff/tiff.h: Revert back libtiff data type definitions as per
- bug http://bugzilla.remotesensing.org/show_bug.cgi?id=687
-
-2004-12-19 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_dirread.c: Do not forget about TIFF_VARIABLE2 when
- checking for tag count in TIFFReadDirectory() function. As per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=713
-
- * libtiff/{tif_dirread.c, tif_fax3.c}: More argument checking in
- CheckMallock() function.
-
- * libtiff/tif_getimage.c: Support for multiple-alpha-channelled
- RGB-images as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=718
-
-2004-12-15 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_getimage.c: #define A1 bracketing for clean build on
- SunPro compiler.
-
-2004-12-11 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * autogen.sh: aclocal and autoheader should be executed after
- libtoolize. Also add '-I .' to aclocal invocation to check
- current directory for macros.
-
-2004-12-10 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_dirwrite.c: Always write TIFFTAG_SUBIFD using LONG type
- as per bugs
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=703
-
- and
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=704
-
-2004-12-04 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * nmake.opt: Link with the user32.lib in windowed mode. As per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=697
-
- * libtiff/tif_win32.c: Use char* strings instead of TCHAR in windowed
- mode as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=697
-
- * libtiff/tif_config.in.vc: Removed unneeded definitions for
- read/open/close/lseek functions to fix the
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=680
-
-2004-12-03 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tif_dir.c, tif_dirread.c}: Remove TIFFReassignTagToIgnore()
- call from the TIFFReadDirectory() function. TIFFReassignTagToIgnore
- must be removed in the future, as it was never used properly. As per
- bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=692
-
-2004-11-30 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff/tif_jpeg.c: Added a work-around in order to allow
- compilation with the heavily modified version of libjpeg delivered
- with Cygwin.
-
-2004-11-29 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_dir.c: Properly handle tags, which have the uint32
- counts. As per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=693
-
- * tools/fax2ps.c: Be able to extract the first page (#0). As per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=690
-
-2004-11-28 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_unix.c: Make UNIX module compilable (and usable)
- on Windows.
-
- * nmake.opt: Add missed DLLNAME variable.
-
-2004-11-26 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/makefile.vc: make it easier to rename the libtiff DLL.
-
-2004-11-24 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * man/libtiff.3tiff: Improvements in the "LIST OF ROUTINES" table as
- per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=545
-
- * man/tiffset.1: Added manual page for tiffset tool written by Jay
- Berkenbilt. As per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=678
-
-2004-11-23 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_error.c: fixed TIFFerror call to be TIFFError.
-
-2004-11-21 Frank Warmerdam <warmerdam@pobox.com>
-
- * html/document.html: Updated Adobe web links as per email from Joris.
-
-2004-11-21 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tiffio.hxx, tiffio.h}: C++ stream interface moved to new
- file tiffio.hxx. We don't have any C++ in tiffio.h, those who want to
- use C++ streams should #include <tiffio.hxx>.
-
-2004-11-13 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tiff.h: Added Adobe DNG tags.
-
- * libtiff/tif_win32.c: Typo fixed.
-
- * libtiff/{tif_stream.cxx, tiffio.h}: C++ stream interface updated to
- be compliant with the latest standard. Appropriate additions in
- makefiles now completed.
-
-2004-11-11 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiffset.c, libtiff/tif_dirinfo.c: Properly handle the
- different tag types. As per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=600
-
-2004-11-10 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_aux.c: Set the appropriate ReferenceBlackWhite array for
- YCbCr image which lacks that tag (noted by Hans Petter Selasky).
-
-2004-11-09 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_color.c: Division by zero fixed (Hans Petter Selasky).
-
-2004-11-07 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tif_stream.cxx, tiffio.h}: Added C++ stream interface
- contributed by Edward Lam (see
- http://bugzilla.remotesensing.org/show_bug.cgi?id=654 for details).
- Though no changes in any makefiles yet.
-
-2004-11-05 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_open.c: Removed close() in TIFFClientOpen() if file
- is bad. This is the callers responsibility.
- http://bugzilla.remotesensing.org/show_bug.cgi?id=651
-
-2004-11-05 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tiffio.h, tif_win32.c, libtiff.def}: Added TIFFOpenW()
- function to work with the double byte strings (used to represent
- filenames in some locales). As per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=625
-
- * libtiff/tif_dirread.c: Fixed problem when fetching BitsPerSample and
- Compression tags of type LONG from broken TIFFS as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=662
-
- * libtiff/tif_dirinfo.c: Fixed definition for TIFFTAG_RICHTIFFIPTC,
- the writecount should have uint32 type. As per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=662
-
- * libtiff/tif_write.c: Fixed wrong if() statement in
- TIFFAppendToStrip() function as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=660
-
-2004-11-04 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_dirinfo.c: Change definition for TIFFTAG_EXTRASAMPLES
- field. The caller should supply a count when setting this field. As
- per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=648
-
- * libtiff/{tif_jpeg.c, tif_ojpeg.c}: TIFFTAG_JPEGTABLES should have
- uint32 count. Use this type everywhere.
-
-2004-11-03 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_next.c: avoid use of u_long and u_char types. Bug 653.
-
-2004-11-02 Frank Warmerdam <warmerdam@pobox.com>
-
- * tools/tiff2rgba.c: removed extra newlines in usage message.
-
-2004-10-30 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_dirwrite.c: Improvements in tag writing code.
-
- * tools/tiff2ps.c: Fixed wrong variable data type when read Position
- tags (Tristan Hill).
-
-2004-10-30 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tiffiop.h: added fallback definition of assert() if we
- don't have assert.h.
-
-2004-10-29 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_fax3.c: Fixed case with the wrong decode routines
- choosing when the incorrect Group4Options tag set. As per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=323
-
- * libtiff/tif_dirwrite.c: Fixed problem with passing count variable of
- wrong type when writing the TIFF_BYTE/TIFF_SBYTE tags in
- TIFFWriteNormalTag().
-
-2004-10-28 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiff2ps.c: Fixed wrong variable data type when read Resolution
- tags (Peter Fales).
-
- * tools/{bmp2tiff.c, raw2tiff.c}: Get rid of stream I/O functions.
-
-2004-10-28 Frank Warmerdam <warmerdam@pobox.com>
-
- * tools/tiff2pdf.c: added casts to avoid warnings.
-
- * libtiff/libtiff.def: Added several more entry points required
- to link fax2tiff.c against the DLL on windows.
-
-2004-10-27 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * configure, configure.ac: Added --enable-rpath option to embed linker
- paths into library binary.
-
-2004-10-26 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiffset.c: Check the malloc return value (Dmitry V. Levin).
-
- * libtiff/{tif_strip.c, tif_tile.c}: Zero division problem fixed
- (Vladimir Nadvornik, Dmitry V. Levin).
-
-2004-10-16 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff 3.7.0 released.
-
-2004-10-15 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff/tif_jpeg.c: There seems to be no need to include stdio.h
- in this file so its inclusion is removed. Including stdio.h
- sometimes incurs an INT32 typedef conflict between MinGW's
- basetsd.h and libjpeg's jmorecfg.h.
-
-2004-10-15 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * man/bmp2tiff.1: Added manual page for bmp2tiff utility.
-
-2004-10-13 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * tools/tiffcmp.c (leof): Renamed from 'eof' in order to avoid
- conflict noticed under MinGW.
- * ltmain.sh: Fix for MinGW compilation.
-
-2004-10-13 Frank Warmerdam <warmerdam@pobox.com>
-
- * man/tiffsplit.1: Fixed to indicate using aaa-zzz, not aa-zz.
- http://bugzilla.remotesensing.org/show_bug.cgi?id=635
-
-2004-10-12 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tif_dirread.c, tif_jpeg.c, tif_luv.c, tif_ojpeg.c,
- tif_pixarlog.c, tif_write.c}: Handle the zero strip/tile sizes
- properly (Dmitry V. Levin, Marcus Meissner).
-
-2004-10-11 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_dirinfo.c: Type of the TIFFTAG_SUBIFD field changed
- to TIFF_IFD.
-
-2004-10-10 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/bmp2tif.c: Check the space allocation results.
-
-2004-10-09 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_dir.c: Initialize td_tilewidth and td_tilelength fields
- of the TIFFDirectory structure with the 0 instead of -1 to avoid
- confusing integer overflows in TIFFTileRowSize() for striped images.
-
- * tools/tiff2pdf.c: Fixed TransferFunction tag handling reported
- by Ross A. Finlayson.
-
- * libtiff/tif_dir.c: Fixed custom tags handling as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=629
-
-2004-10-08 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_dirinfo.c: Fix bug with tif_foundfield and reallocation
- of tif_fieldinfo.
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=630
-
-2004-10-04 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * contrib/iptcutil/README: Added the missing README which goes
- along with iptcutil.
-
-2004-10-03 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_compress.c: Improved error reporting in
- TIFFGetConfiguredCODECs() (Dmitry V. Levin).
-
-2004-10-02 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff 3.7.0beta2 released.
-
- * libtiff/{tif_aux.c, tif_compress.c, tif_dirinfo.c, tif_dirwrite.c,
- tif_extension.c, tif_fax3.c, tif_luv.c, tif_packbits.c,
- tif_pixarlog.c, tif_write.c}: Added checks for failed memory
- allocations and integer overflows (Dmitry V. Levin).
-
- * libtiff/tiff.h: Missed TIFF_BIGTIFF_VERSION constant added.
-
-2004-10-01 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_open.c: added a more informative message if a BigTIFF
- file is opened.
-
-2004-09-30 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_dirinfo.c: changed type of XMLPacket (tag 700) to
- TIFFTAG_BYTE instead of TIFFTAG_UNDEFINED to comply with the info
- in the Adobe XMP Specification.
-
-2004-09-29 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tif_jpeg.c, tif_pixarlog.c}: Use _TIFFmemset() instead of
- memset().
-
- * libtiff/{tif_dirread.c, tif_strip.c, tif_tile.c}: Applied patches
- from Dmitry V. Levin to fix possible integer overflow problems.
-
-2004-09-28 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_getimage.c: Check for allocated buffers before clearing
- (Dmitry V. Levin).
-
-2004-09-26 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tif_dir.h, tif_dir.c, tif_dirread.c, tif_write.c}:
- Optimize checking for the strip bounds.
-
- * libtiff/{tif_dirread.c, tif_strip.c}: TIFFScanlineSize() and
- TIFFRasterScanlineSize() functions report zero in the case of integer
- overflow now. Properly handle this case in TIFFReadDirectory()
- (patches from Dmitry V. Levin).
-
-2004-09-25 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tif_dirinfo.c, tif_strip.c, tif_tile.c}: Use TIFFhowmany8()
- macro where appropriate.
-
- * tools/tiff2bw.c: Write ImageWidth/Height tags to output file, as
- noted by Gennady Khokhorin.
-
- * libtiff/tif_dirread.c: Always check the return values, returned
- by the _TIFFmalloc() (Dmitry V. Levin).
-
- * libtiff/tif_dir.c: Fixed possible integer overflow _TIFFset*Array()
- functions (Dmitry V. Levin).
-
- * libtiff/{tif_dirread.c, tif_dir.c, tif_write.c}:
- Potential memory leak fixed in TIFFReadDirectory(), _TIFFVSetField(),
- TIFFGrowStrips() (found by Dmitry V. Levin).
-
-2004-09-24 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tiffio.h, tif_compress.c}: Added TIFFGetConfiguredCODECs()
- to get the list of configured codecs.
-
- * libtiff/{tiffiop.h, tif_dirread.c}: More overflow fixes from
- Dmitry V. Levin.
-
-2004-09-23 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_dirread.c: Applied patch from Dmitry V. Levin to fix
- possible integer overflow in CheckMalloc() function.
-
-2004-09-22 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tiffiop.h, tif_strip.c}: Use TIFFhowmany8() macro instead
- of plain TIFFhowmany() where appropriate.
-
-2004-09-21 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_getimage.c: Initialize arrays after space allocation.
-
-2004-09-19 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff 3.7.0beta released.
-
- * libtiff/{tif_luv.c, tif_next.c, tif_thunder.c}: Several buffer
- overruns fixed, as noted by Chris Evans.
-
-2004-09-14 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * commit: Added a script to make it more convenient to commit
- updates. The CVS commit message is extracted from this ChangeLog
- file.
-
-2004-09-14 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * configure.ac, configure, aclocal.m4, libtiff/{mkspans.c, tif_fax3.c,
- tif_getimage.c, tif_luv.c, tif_lzw.c, tif_ojpeg.c, tif_packbits.c,
- tif_predict.c, tif_read.c, tif_swab.c, tif_thunder.c, tif_write.c,
- tif_dir.c, tif_dirread.c, tif_dirwrite.c, tif_jpeg.c, tif_dirinfo.c,
- tif_vms.c, tif_print.c, tif_strip.c, tif_tile.c, tif_dir.h,
- tif_config.h.in, tiffiop.h}:
- Get rid of BSD data types (u_char, u_short, u_int, u_long).
-
-2004-09-13 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * libtiff/tiff.h: Fix column tagging. Reference current Adobe XMP
- specification. Reference libtiff bug tracking system to submit
- private tag additions.
-
-2004-09-12 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * tools/tiffgt.c: Include "tif_config.h".
-
- * configure.ac: Use AM_PROG_CC_C_O since it is now needed to build
- tiffgt. This results in the 'compile' script being added to the
- project.
-
- * tools/Makefile.am (tiffgt_CFLAGS): Add extra build options
- required to find OpenGL headers necessary to build tiffgt. Also
- ensure that the libtiff that we built is used rather than some other
- libtiff installed on the system.
-
-2004-09-12 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * configure.ac, acinclude.m4, aclocal.m4: New macros to detect GLUT
- libraries.
-
-2004-09-11 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-
- * configure.ac: Pass library configuration defines via
- tif_config.h rather than extending CPPFLAGS. Configure a
- libtiff/tiffconf.h in order to satisfy application requirements
- (not used by library build). Do not define _POSIX_C_SOURCE=2 since
- this causes failure to build on systems which properly respect
- this request.
-
- * libtiff/tiffconf.h.in: New file to act as the template for the
- configured tiffconf.h
-
- * libtiff/files.lst (HDRS): Install the configured tiffconf.h.
-
-2004-09-10 Frank Warmerdam <warmerdam@pobox.com>
-
- * html/internals.html: Split off a discussion of adding new tags
- into addingtags.html.
-
-2004-09-10 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * test/{ascii_tag.c, long_tag.c}: Preliminary test suite added.
-
- * tools/tiff2pdf.c: Fixed reading TransferFunction tag as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=590
-
- * libtiff/tif_print.c: Fixes in InkNames and NumberOfInks reporting.
-
- * libtiff/tif_dirread.c: Don't reject to read tags of the
- SamplesPerPixel size when the tag count is greater than number of
- samples as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=576
-
- * libtiff/tiff.h: Use _TIFF_DATA_TYPEDEFS_ guardian to switch off
- defining int8/uint8/... etc. types. As per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=607
-
-2004-09-09 Frank Warmerdam <warmerdam@pobox.com>
-
- * tools/tiff2ps.c, tools/tiffmedian.c: fiddle with include files
- to avoid compile warnings about getopt() and a few other things.
-
-2004-09-02 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_dirread.c: Use memcpy() function instead of pointer
- assigning magic in TIFFFetchFloat().
-
-2004-09-01 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tiffio.h, tif_open.c}: Applied patches from Joris Van Damme
- to avoid requirement for tiffiop.h inclusion in some applications. See
- here
-
- http://www.asmail.be/msg0054799560.html
-
- for details.
-
- * tools/fax2tiff.c: Use the new functions in the code.
-
-2004-08-25 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiff2pdf.c: Initialize arrays properly.
-
- * tools/tiff2ps.c: Avoid zero division in setupPageState() function;
- properly initialize array in PSDataBW().
-
-2004-08-24 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiff2pdf.c: More fixes for bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=590
-
- from Ross Finlayson.
-
-2004-08-23 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiff2ps.c: Fixed problem with uninitialized values.
-
- * libtiff/tif_dir.c: Initialize tif_foundfield data member in the
- TIFFDefaultDirectory() (in addition to 2004-08-19 fix).
-
- * tools/tiff2pdf.c: Fixed a bunch of problems as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=590
-
-2004-08-20 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiff2pdf.c: Applied patch from Ross Finlayson that checks
- that the input file has compression, photometric interpretation,
- etcetra, tags or if not than a more descriptive error is returned.
-
- * libtiff/tif_dirread.c: Fixed problem in TIFFReadDirectory() in the
- code, responsible for tag data type checking.
-
-2004-08-19 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tiffiop.h, tif_dirinfo.c}: Fixed problem with the static
- variable as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=593
-
-2004-08-16 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/ras2tiff.c: Fixed issue with missed big-endian checks as per
- bug http://bugzilla.remotesensing.org/show_bug.cgi?id=586
-
-2004-08-01 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tif_config.h.in, tif_config.h.vc}: config.h.in and
- config.h.vc files renamed in the tif_config.h.in and tif_config.h.vc.
-
-2004-07-24 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_lzw.c: LZW compression code is merged back from the
- separate package. All libtiff tools are updated to not advertise an
- abcence of LZW support.
-
-2004-07-12 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tiffio.h: Revert thandle_t back to void* type.
-
-2004-07-11 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tif_read.c, tif_tile.c, tif_strip.c}: Fixes in error
- messages, as suggested by Bernd Herd.
-
-2004-07-03 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_dir.c: Call TIFFError() instead of producing warnings
- when setting custom tags by value. Reported by Eric Fieleke.
-
-2004-06-14 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/bmp2tiff.c: Add missed RawsPerStrip setting.
-
-2004-06-08 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/bmp2tiff.c: Added new utility to convert Windows BMP files
- into TIFFs.
-
-2004-06-07 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff 3.7.0alpha released.
-
-2004-06-06 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tiff.h, tif_dirwrite.c, tif_fax3.c, tif_packbits.c,}: Get rid
- of ugly 64-bit hacks, replace them with the clever (autoconf based )
- ones :-).
-
- * libtiff/tiffio.h: Define thandle_t as int, not void* (may cause
- problems in 64-bit environment).
-
-2004-06-05 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiffset.c: tiffset now can set any libtiff supported tags.
- Tags can be supplied by the mnemonic name or number.
-
- * libtiff/{tiffio.h, tif_dir.h, tif_dirinfo.c,}: Added two new
- functions TIFFFindFieldInfoByName() and TIFFFieldWithName().
-
-2004-05-27 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_ojpeg.c: Fixed problem with duplicated SOI and SOF
- markers as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=581
-
-2004-05-24 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiffsplit.c: Don't forget to copy Photometric
- Interpretation tag.
-
-2004-05-20 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tif_open.c, tiffio.h}: New function added:
- TIFFIsBigEndian(). Function returns nonzero if given was file written
- in big-endian order.
-
- * tools/tiffsplit.c: Fixed problem with unproperly written multibyte
- files. Now output files will be written using the same byte order
- flag as in the input image. See
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=574
-
- for details.
-
-2004-05-19 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_print.c: added (untested) support for printing
- SSHORT, SLONG and SRATIONAL fields.
-
- * tools/tiffcp.c: close output file on normal exit.
-
-2004-05-17 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_fax3.c: Avoid reading CCITT compression options
- if compression type mismatches. See
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=565
-
-2004-04-30 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_strip.c: Never return 0 from the
- TIFFNumberOfStrips().
-
-2004-04-29 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_dirread.c: Workaround for broken TIFF writers which
- store single SampleFormat value for multisampled images. See
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=562
-
-2004-04-25 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * configure.ac, libtiff/{tiff.h, config.h.in}: Added tests for int8,
- int16 and int32 types to avoid complains on some compilers. Details at
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=39
-
-2004-04-20 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiff2pdf.c: Fixed problem with unaligned access as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=555
-
-2004-04-14 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_write.c: Allow in-place updating of the compressed
- images (don't work properly with all codecs). For details see GDAL bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=534
-
-2004-04-06 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_jpeg.c: Workaround for wrong sampling factors used
- in the Intergarph JPEG compressed TIFF images as per bug:
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=532
-
-2004-04-04 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_open.c: close clientdata if TIFFClientOpen() fails
- via bad2.
-
-2004-03-26 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiffcp.c: Properly set Photometric Interpretation in case of
- JPEG compression of grayscale images.
-
- * tools/tiffcp.c: Don't emit warnings when Orientation tag does not
- present in the input image.
-
-2004-03-19 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * {many}: The first attempt to switch to autotools.
-
-2004-03-03 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_open.c: Use dummy mmap/munmap functions in
- TIFFClientOpen() when the appropriate client functions was not
- supplied by user.
-
-2004-03-02 Frank Warmerdam <warmerdam@pobox.com>
-
- * tools/ycbcr.c: fixed main() declaration as per:
- http://bugzilla.remotesensing.org/show_bug.cgi?id=513
-
-2004-02-26 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiffsplit.c: Copy JPEGTables tag contents for JPEG compressed
- images. Reported by Artem Mirolubov.
-
- * libtiff/tif_dirread.c: Fixed problem with handling TIFF_UNDEFINED
- tag type in TIFFFetchNormalTag() as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=508
-
-2004-02-17 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_codec.c: Fixed typo in TIFFInitPackBits name as per:
- http://bugzilla.remotesensing.org/show_bug.cgi?id=494
-
-2004-02-05 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_fax3.c: Fixed problem with CCITT encoding modes as per
- bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=483
-
- But we need more work on fax codec to support update mode.
-
-2004-01-30 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/libtiff.def: Added TIFFCurrentDirOffset, TIFFWriteCheck,
- TIFFRGBAImageOK, and TIFFNumberOfDirectories as suggested by
- Scott Reynolds.
-
-2004-01-29 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tiff.h: Fixed tag definitions for TIFFTAG_YCLIPPATHUNITS
- and TIFFTAG_INDEXED as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=475
-
- * libtiff/{tif_win32.c, tif_unix.c}: Check whether the pointer is
- NULL before proceeding further as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=474
-
- Check results, returned by the TIFFFdOpen() before returning and close
- file if TIFFFdOpen() failed as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=468
-
- * libtiff/tif_open.c: More fixes for
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=468
-
-2004-01-28 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{libtiff.def, tif_close.c, tiffio.h, tif_open.c}: Separate
- TIFFCleanup() from the TIFFClose() in order to fix the bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=468
-
- * tools/tiffcp.c: Fixed problem with wrong interpretation of the
- InkNames tag as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=466
-
- Memory leak fixed.
-
-2004-01-21 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_dirwrite.c: Fixed handling of writable ASCII tags that
- are field_passcount=TRUE properly. Arguably anonymous custom tags
- should be declared as passcount=FALSE, but I don't want to change
- that without a careful review.
-
-2004-01-20 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_write.c: Fixed reporting size of the buffer in case of
- stripped image in TIFFWriteBufferSetup(). As per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=460
-
-2004-01-11 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_dir.c: Incomplete cleanup in TIFFFreeDirectory(),
- patch from Gerben Koopmans.
-
- * libtiff/tif_dirread.c: Check field_passcount value before setting
- the value of undefined type, patch from Gerben Koopmans.
-
-2004-01-02 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiffcp.c: Fixed problem with wrong Photometric setting for
- non-RGB images.
-
-2003-12-31 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_win32.c: Fixed problem with _TIFFrealloc() when the NULL
- pointer passed. Patch supplied by Larry Grill.
-
- * libtiff/{tiff.h, tif_fax3.c}:Fixes for AMD 64 platform as
- suggested by Jeremy C. Reed.
-
-2003-12-26 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff 3.6.1 released.
-
-2003-12-24 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * config.guess, config.sub: Updated from the recent upstream.
-
-2003-12-22 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tif_color, tif_getimage.c, tiffio.h}, man/TIFFcolor.3t:
- More cleanups in color conversion interface, added appropriate manual
- page.
-
-2003-12-19 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tif_extension.c, tif_dirinfo.c, tiff.h}: Warnings fixed as
- per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=357
-
- * tools/tiff2ps.c: Added support for alpha channel. Fixes
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=428
-
- * libtiff/{libtiff.def, tif_color.c, tif_getimage.c, tiffio.h}:
- Interface for Lab->RGB color conversion is finally cleaned up.
- Added support for ReferenceBlackWhite tag handling when converted from
- YCbCr color space. The latter closes
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=120
-
-2003-12-07 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tif_getimage.c, tiffio.h}: Avoid warnings.
-
- * libtiff/makefile.vc, tools/makefile.vc: Support for IJG JPEG
- library.
-
-2003-12-06 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tif_getimage.c, tif_aux.c}: Read WhitePoint tag from the
- file and properly use it for CIE Lab->RGB transform.
-
-2003-12-04 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tif_getimage.c, tif_color.c, tiffio.h}: YCbCr->RGB
- conversion routines now in the tif_color.c module. New function
- TIFFYCbCrtoRGB() available in TIFF API.
-
- * libtiff/tif_dirwrite.c: Handle TIFF_IFD tag type correctly.
-
-2003-12-03 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tif_getimage.c, tif_color.c, tiffio.h}: Improvements in
- CIE Lab conversion code. Start moving YCbCr stuff to the tif_color.c
- module.
-
- * libtiff/{tif_getimage.c, tiffio.h}, man{TIFFReadRGBAImage.3t,
- TIFFReadRGBAStrip.3t, TIFFReadRGBATile.3t, TIFFRGBAImage.3t}:
- Finally resolved problems with orientation handling. TIFFRGBAImage
- interface now properly supports all possible orientations, i.e. images
- will be flipped both in horizontal and vertical directions if
- required. 'Known bugs' section now removed from the appropriate manual
- pages. Closed bug entry:
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=322
-
-2003-12-02 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_dir.c: Fixed order of the parameters in TIFFError()
- function calls as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=440
-
-2003-11-28 Ross Finlayson <libtiff@apexinternetsoftware.com>
-
- * tools/tiff2pdf.c: Some bugs fixed.
-
-2003-11-27 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_luv.c: Fixed bug in 48-bit to 24-bit conversion routine,
- reported by Antonio Scuri.
-
- * man/tiff2pdf.1: Few improvements in page layout.
-
- * Makefile.in, /man/Makefile.in, /html/man/tiff2pdf.1.html:
- Added support for tiff2pdf manual page.
-
-2003-11-26 Ross Finlayson <libtiff@apexinternetsoftware.com>
-
- * /man/tiff2pdf.1: File added to repository.
-
-2003-11-26 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * Makefile.in, /tools/{Makefile.in, makefile.vc}:
- Added support for tiff2pdf utility.
-
-2003-11-25 Ross Finlayson <libtiff@apexinternetsoftware.com>
-
- * /tools/tiff2pdf.c: File added to repository.
-
-2003-11-22 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * /tools/raw2tiff.c: sqrtf() replaced with sqrt().
-
-2003-11-21 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * /tools/raw2tiff.c: #include <getopt.h> removed.
-
- * tools/{Makefile.in, tiffgt.c}: Unmaintained and platform dependent
- sgigt utility removed and replaced with the completely rewritten
- portable tiffgt tool (depend on OpenGL and GLUT). Initial revision,
- there is a lot of things to improve.
-
- * libtiff/tif_ojpeg.c: TIFFVGetField() function now can properly
- extract the fields from the OJPEG files. Patch supplied by Ross
- Finlayson.
-
- * libtiff/{tiffio.h, tif_codec.c}, man/{libtiff.3t, TIFFcodec.3t}:
- Added new function TIFFIsCODECConfigured(), suggested by Ross
- Finlayson.
-
-2003-11-18 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_dirinfo.c: Implemented binary search in
- _TIFFMergeFieldInfo(). Patch supplied by Ross Finlayson.
-
- * libtiff/tif_dir.h: _TIFFFindOrRegisterdInfo declaration replaced
- with _TIFFFindOrRegisterFieldInfo as reported by Ross Finlayson.
-
-2003-11-17 Frank Warmerdam <warmerdam@pobox.com>
-
- * tif_dirread.c: do not mark all anonymously defined tags to be
- IGNOREd.
-
-2003-11-17 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * contrib/pds/{tif_pdsdirread.c, tif_pdsdirwrite.c}: Use
- TIFFDataWidth() function instead of tiffDataWidth array.
-
-2003-11-16 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tiff.h, tif_dirinfo.c}: Added support for IFD (13)
- datatype, introduced in "Adobe PageMaker TIFF Tech. Notes".
-
-2003-11-15 Frank Warmerdam <warmerdam@pobox.com>
-
- * Makefile.in: fixed missing backslash for tif_color.c in list.
-
-2003-11-13 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tif_color.c, tif_getimage.c, tiffio.h, Makefile.in}:
- New color space conversion code: CIE L*a*b* 1976 images now supported
- by the TIFFRGBAImage interface. All introduced routines go to new
- module tif_color.c. Eventually all color conversion functions should
- be moved there.
-
-2003-11-12 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/{ras2tiff.c, rasterfile.h}: Properly determine SUN Rasterfiles
- with the reverse byte order (it is reported by the magic header
- field). Problem reported by Andreas Wiesmann.
-
- * tools/raw2tiff.c, man/raw2tiff.1: Few improvements in correlation
- calculation function. Guessing mechanics now documented in manual page.
-
-2003-11-11 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/raw2tiff.c: Implemented image size guessing using
- correlation coefficient calculation between two neighbour lines.
-
-2003-11-09 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_tile.c: remove spurious use of "s" (sample) in the
- planarconfig_contig case in TIFFComputeTile().
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=387
-
-2003-11-09 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tiffiop.h: New macros: TIFFmax, TIFFmin and TIFFrint.
-
-2003-11-07 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tiffio.h, tif_strip.c}, man/{TIFFstrip.3t, libtiff.3t}:
- Added TIFFRawStripSize() function as suggested by Chris Hanson.
-
-2003-11-03 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tif_lzw.c, tif_fax3.c}: Proper support for update mode as
- per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=424
-
-2003-10-29 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/libtiff.def: Added TIFFReadRGBAImageOriented.
-
- * html/build.html: Added note about GNU make requirement.
-
-2003-10-25 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * Makefile.in: Fixes in using MAKEFLAGS as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=418
-
- * port/install.sh.in: Option -p added to the mkdir command to create
- all directory tree structure before installing.
-
-2003-10-18 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * /tools/tiff2ps.c: #include <strings.h> replaced with the
- #include <string.h>.
-
-2003-10-16 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * Makefile.in: Add an absolute path to the test_pics.sh call.
-
-2003-10-12 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tiffcomp.h: #define _BSDTYPES_DEFINED when defining BSD
- typedefs.
-
-2003-10-09 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * configure, libtiff/{Makefile.in, mkversion.c}:
- Relative buildings fixed.
-
- * tools/Makefile.in: Added "-I../libtiff" to the tiffset building
- rule.
-
-2003-10-07 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * Makefile.in: Added missed v3.6.0.html.
-
- * libtiff/tiffio.h: Typo fixed: ORIENTATION_BOTTOMLEFT replaced with
- ORIENTATION_BOTLEFT.
-
-2003-10-04 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * 3.6.0 final release.
-
-2003-10-03 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tif_getimage.c, tiffio.h}, man/TIFFReadRGBAImage.3t: New
- function TIFFReadRGBAImageOriented() implemented to retrieve raster
- array with user-specified origin position as suggested by Jason Frank.
- See
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=322
-
- for details.
-
- * tools/tiff2rgba.c: Switched to use TIFFReadRGBAImageOriented()
- instead of TIFFReadRGBAImage().
-
- * tools/tiff2ps.c: Fixed possible endless loop as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=404
-
-2003-09-30 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_dirread.c: Check field counter against number of fields
- in order to fix
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=366
-
- * libtiff/tif_fax3.c: Fix wrong line numbering as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=342
-
-2003-09-25 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/{tiffiop.h, tif_dirread.c, tif_dir.c, tif_open.c,
- tif_close.c}: Store a list of opened IFD to prevent looping as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=383
-
-2003-09-23 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_dirread.c: More fixes for EstimateStripByteCounts(). See
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=358
-
-2003-08-21 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiffmedian.c: int declaration replaced with the uint32 to
- support large images as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=382
-
-2003-08-12 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/Makefile.in: Fixed problem with building in different
- directory.
-
- * tools/tiff2ps.c: Added missing #include <strings.h>.
-
- * libtiff/tif_dirwrite.c: More fixes for custom tags code
- from Ashley Dreier.
-
-2003-08-07 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiff2ps.c: Added page size setting when creating PS Level 2.
- Patch submitted by Balatoni Denes (with corrections from Tom
- Kacvinsky).
-
- * tools/tiff2ps.c: Fixed PS comment emitted when FlateDecode is
- being used. Reported by Tom Kacvinsky.
-
- * libtiff/tif_dirwrite.c: Fixed problem with custom tags writing,
- reported by Ashley Dreier.
-
- * libtiff/tif_print.c: Fixed problem with float tags reading, support
- for printing RATIONAL and BYTE tags added.
-
-2003-08-05 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_lzw.c: Move LZW codec state block allocation back to
- TIFFInitLZW(), because its initialization in LZWSetupDecode() cause
- problems with predictor initialization. Remove O_RDONLY check during
- state block allocation to be able open LZW compressed files in update
- mode.
-
- Problem exist for libtiff version of the tif_lzw.c module. One from
- lzw-compression-kit hasn't such troubles.
-
-2003-08-04 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_write.c: modified tif_write.c so that the various
- encoded write functions use tif_postdecode() to apply byte order
- swapping (swab) to the application passed data buffer if the same
- would be done when reading. This allows us to write pixel data with
- more than 8 bits per sample to existing files of a non-native byte
- order. One side effect of this change is the applications buffer
- itself is altered in this case by the act of writing.
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=171
-
-2003-07-25 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_open.c: avoid signed/unsigned casting warning
- initializing typemask as per patch from J.A. Strother.
-
- * tools/tiffcp.c: fixed signed/unsigned casting warning.
-
- * libtiff/tif_print.c: dos2unix conversion.
-
- * tools/tiffsplit.c: increased the maximum number of pages that
- can be split. Patch provided by Andrew J. Montalenti.
-
-2003-07-11 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/raw2tiff.c: Added option `-p' to explicitly select color
- space of input image data. Closes
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=364
-
-2003-07-08 Frank Warmerdam <warmerdam@pobox.com>
-
- * tif_aux.c, tif_codec.c, tif_dir.c, tif_dirread.c, tif_extension.c,
- tif_fax3.c, tif_getimage.c, tif_luv.c, tif_lzw.c, tif_next.c,
- tif_packbits.c, tif_predict.c, tif_print.c, tif_swab.c, tif_thunder.c:
- avoid casting warning at /W4.
-
-2003-07-03 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/thumbnail.c: Memory leak fixed as reported by Robert S. Kissel.
-
-2003-06-30 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_pixarlog.c: Unused variables removed.
-
- * libtiff/{tif_dirread.c, tif_dir.c}: Fixed problem with
- EstimateStripByteCounts() as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=358
-
- * libtiff/{tif_dirwrite.c, tif_packbits.c}: Fixed compilation on
- 64-bit architectures as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=357
-
- * libtiff/tif_dirinfo.c: TIFFDataWidth() returns 0 in case of
- unknown data type.
-
-2003-06-19 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_print.c: fixed some serious bugs when printing
- custom tags ... almost certain to crash.
-
- * libtiff/tif_dirread.c: Don't ignore custom fields that are
- autodefined. Not sure how this got to be like this.
-
-2003-06-18 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * 3.6.0 Beta2 released.
-
- * tools/tiffcmp.c, man/tiffcmp.1: Fixed problem with unused data
- comparing as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=349
-
- `-z' option now can be used to set the number of reported different
- bytes.
-
-2003-06-09 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiffcp.c, man/tiffcp.1: Added possibility to specify value -1
- to -r option to get the entire image as one strip. See
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=343
-
- for details.
-
-2003-06-04 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiffcp.c: Set the correct RowsPerStrip and PageNumber
- values as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=343
-
-2003-05-27 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_jpeg.c: modified segment_height calculation to always
- be a full height tile for tiled images. Also changed error to just
- be a warning.
-
-2003-05-25 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/fax2tiff.c: Page numbering fixed, as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=341
-
-2003-05-20 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * contrib/ojpeg/{Makefile.in, jdhuff.h, jinclude.h, ojpeg.c, README},
- configure, Makefile.in: Switched back to the old behaviour. Likely
- better solution should be found for OJPEG support.
-
-2003-05-11 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/mkversion.c: Fixed problem with wrong string size when
- reading RELEASE-DATE file.
-
-2003-05-07 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiff2ps.c: Fixed bug in Ascii85EncodeBlock() function: array
- index was out of range.
-
-2003-05-06 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * contrib/ojpeg/{Makefile.in, jdhuff.h, jinclude.h, ojpeg.c, README},
- configure, Makefile.in: Improved libtiff compilation with OJPEG
- support. Now no need for patching IJG JPEG library, hack required by
- libtiff will be compiled and used in-place. Implemented with
- suggestion and help from Bill Allombert, Debian's libjpeg maintainer.
-
- * libtiff/tif_aux.c: Properly handle TIFFTAG_PREDICTOR in
- TIFFVGetFieldDefaulted() function.
-
-2003-05-05 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/ppm2tiff.c: PPM header parser improved: now able to skip
- comments.
-
- * tools/tiffdither.c: Fixed problem with bit fill order tag setting:
- was not copied from source image.
-
- * libtiff/getimage.c: Workaround for some images without correct
- info about alpha channel as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=331
-
-2003-04-29 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiff2ps.c, man/tiff2ps.1: Add ability to generate PS Level 3.
- It basically allows one to use the /flateDecode filter for ZIP
- compressed TIFF images. Patch supplied by Tom Kacvinsky. Fixes
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=328
-
- * tools/tiff2ps.c: Force deadzone printing when EPS output specified
- as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=325
-
-2003-04-17 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_dirread.c: Removed additional check for StripByteCounts
- due to problems with multidirectory images. Quality of error messages
- improved.
-
-2003-04-16 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiffcp.c: Fixed problem with colorspace conversion for JPEG
- encoded images. See bug entries
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=275
-
- and
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=23
-
- * libtiff/tif_dirread.c: Additional check for StripByteCounts
- correctness. Fixes
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=320
-
-2003-03-12 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/{fax2ps.c, fax2tiff.c, gif2tiff.c, pal2rgb.c, ppm2tiff.c,
- ras2tiff.c, raw2tiff.c, rgb2ycbcr.c, thumbnail.c, tiff2bw.c,
- tiff2ps.c, tiff2rgba.c, tiffcp.c, tiffdither.c, tiffinfo.c,
- tiffmedian.c}: Added library version reporting facility to all tools.
-
-2003-03-06 Frank Warmerdam <warmerdam@pobox.com>
-
- * port/install.sh.in: Fixed problems with install producing paths
- like ///usr/local/lib on cygwin.
-
-2003-02-27 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/fax2tiff.c, man/fax2tiff.1: New switch (-X) to set width of
- raw input page. Patch supplied by Julien Gaulmin. See
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=293
-
- for details.
-
-2003-02-26 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_dir.c: fixed up the tif_postdecode settings
- responsible for byte swapping complex image data.
-
- * libtiff/tif_lzw.c: fixed so that decoder state isn't allocated till
- LZWSetupDecode(). Needed to read LZW files in "r+" mode.
-
-2003-02-07 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/ppm2tiff.c: Fixed problem with too many arguments.
-
-2003-02-04 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/raw2tiff.c: Memory leak fixed.
-
-2003-02-03 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/fax2tiff.c, man/fax2tiff.1: Applied patch from Julien Gaulmin
- (thanks, Julien!). More switches for fax2tiff tool for better control
- of input and output. Details at
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=272
-
-2003-02-03 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_jpeg.c: Modified to defer initialization of jpeg
- library so that we can check if there is already any tile/strip data
- before deciding between creating a compressor or a decompressor.
-
-2003-01-31 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_write.c: TIFFWriteCheck() now fails if the image is
- a pre-existing compressed image. That is, image writing to
- pre-existing compressed images is not allowed.
-
- * libtiff/tif_open.c: Removed error if opening a compressed file
- in update mode.
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=198
-
-2003-01-31 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * config.guess, config.sub: Updated to recent upstream versions.
-
-2003-01-15 Frank Warmerdam <warmerdam@pobox.com>
-
- * cut 3.6.0 Beta release.
-
-2002-12-20 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/fax2ps.c, man/fax2ps.1: Page size was determined
- in wrong way as per bug
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=239
-
-2002-12-17 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_dirread.c: Allow wrong sized arrays in
- TIFFFetchStripThing().
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=49
-
-2002-12-02 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_dir.c: fix problem with test on td_customValueCount.
- Was using realloc even first time. Fix by Igor Venevtsev.
-
-2002-11-30 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_dir.c: fixed bug with resetting an existing custom
- field value.
-
- * libtiff/tif_dir.c: Fixed potential problem with ascii "custom"
- tags in TIFFVGetField() ... added missing break.
-
-2002-10-14 Frank Warmerdam <warmerdam@pobox.com>
-
- * tools/tiff2ps.c: fixes a problem where "tiff2ps -1e" did not make
- the scanline buffer long enough when writing rgb triplets.
- The scanline needs to be 3 X the number of dots or else it will
- contain an incomplete triplet and programs that try to separate
- the eps by redefining the colorimage operator will get messed up.
- Patch supplied by William Bader.
-
- * Makefile.in: added tif_extension.c to file list as per
- http://bugzilla.remotesensing.org/show_bug.cgi?id=218.
-
-2002-10-11 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * configure, config.site, libtiff/{tif_unix.c, Makefile.in}: Fix for
- large files (>2GiB) supporting. New option in the config.site:
- LARGEFILE="yes". Should be enough for I/O of the large files.
-
-2002-10-10 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/html/v3.6.0.html: new release notes.
-
- * libtiff/index.html: removed faq, cvs snapshot cruft. Added email
- link for Andrey. Pointer to v3.6.0.html.
-
- * libtiff/Makefile.in: added direct rule for tiffvers.h for release.
-
-2002-10-07 Andrey Kiselev <dron@ak4719.spb.edu>
- * tools/tiff2ps.c, man/tiff2ps.1: Applied patch form Sebastian Eken
- (thanks, Sebastian!). New switches:
- -b # for a bottom margin of # inches
- -c center image
- -l # for a left margin of # inches
- -r rotate the image by 180 degrees
- New features merged with code for shrinking/overlapping.
- Previously added -c and -n switches (for overriding PS units) renamed
- in -x and -y respectively.
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=200
-
- * html/man/*.html: Updated from actual manual pages.
-
-2002-10-06 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_jpeg.c: fixed problem with boolean defined with wrong
- size on windows. Use #define boolean hack.
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=188
-
- * libtiff/tiff.h: Don't do special type handling in tiff.h unless
- USING_VISUALAGE is defined.
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=39
-
-2002-10-03 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tiff.h: added COMPRESSION_JP2000.
-
-2002-10-02 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_dirread.c: Another fix for the fetching SBYTE arrays
- by the TIFFFetchByteArray() function. Should finally resolve
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=52
-
- * configure: Set -DPIXARLOG_SUPPORT option along with -DZIP_SUPPORT
-
- * html/Makefile.in: New targets added: html and groffhtml for
- producing HTML representations of the manual pages automatically.
- html target uses man2html tool, groffhtml uses groff tool.
-
-2002-09-29 Frank Warmerdam <warmerdam@pobox.com>
-
- * configure, libtiff/Makefile.in: Added SCO OpenServer 5.0.6 support
- from John H. DuBois III.
-
-2002-09-15 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * Makefile.in, /man/{raw2tiff.1, Makefile.in, libtiff.3}: Added
- manual page for raw2tiff(1) tool.
-
-2002-09-12 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * /libtiff/{tiffio.h, tif_dir.h}: TIFFDataWidth() declaration moved to
- the tiffio.h header file.
-
- * Makefile.in, /man/{TIFFDataWidth.3t, Makefile.in, libtiff.3}: Added
- manual page for TIFFDataWidth() function
-
-2002-09-08 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_dirread.c: Expand v[2] to v[4] in TIFFFetchShortPair()
- as per http://bugzilla.remotesensing.org/show_bug.cgi?id=196.
-
- * tools/tiff2ps.c: Don't emit BeginData/EndData DSC comments
- since we are unable to properly include the amount to skip.
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=80
-
-2002-09-02 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * /libtiff/tif_dirread.c: Fixed problem with SBYTE type data fetching
- in TIFFFetchByteArray(). Problem described at
- http://bugzilla.remotesensing.org/show_bug.cgi?id=52
-
-2002-08-22 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * /libtiff/tif_dirinfo.c: Further additions to free custom fields
- in _TIFFSetupFieldInfo() function.
- See http://bugzilla.remotesensing.org/show_bug.cgi?id=169 for details.
-
- * /libtiff/tif_lzw.c: Additional consistency checking added in
- LZWDecode() and LZWDecodeCompat().
- Fixes http://bugzilla.remotesensing.org/show_bug.cgi?id=190
- and http://bugzilla.remotesensing.org/show_bug.cgi?id=100
-
- * /libtiff/tif_lzw.c:
- Added check for valid code lengths in LZWDecode() and
- LZWDecodeCompat(). Fixes
- http://bugzilla.remotesensing.org/show_bug.cgi?id=115
-
-2002-08-16 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * /libtiff/{Makefile.vc, libtiff.def}:
- Missed declarations added.
-
-2002-08-15 Frank Warmerdam <warmerdam@pobox.com>
-
- * tif_getimage.c: Ensure that TIFFRGBAImageBegin() returns the
- return code from the underlying pick function.
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=177
-
- * tif_dir.h: changed FIELD_CODEC to 66 from 64 to avoid overlap
- with FIELD_CUSTOM as mentioned in bug 169.
-
- * tif_close.c: added logic to free dynamically created anonymous
- field definitions to correct a small memory leak.
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=169
-
-2002-08-10 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * /tools/{raw2tiff.c, Makefile.in, Makefile.lcc, Makefile.vc}:
- New tool: raw2tiff --- raw images to TIFF converter. No manual page yet.
-
-2002-07-31 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_jpeg.c: Fixed problem with setting of nrows in
- JPEGDecode() as per bugzilla bug (issue 1):
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=129
-
- * libtiff/{tif_jpeg.c,tif_strip.c,tif_print.c}: Hacked tif_jpeg.c to
- fetch TIFFTAG_YCBCRSUBSAMPLING from the jpeg data stream if it isn't
- present in the tiff tags.
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=168
-
- * libtiff/tif_read.c, libtiff/tif_write.c: TIFFReadScanline() and
- TIFFWriteScanline() now set tif_row explicitly in case the codec has
- fooled with the value.
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=129
-
-2002-06-22 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * /tools/tiff2ps.c: Added workaround for some software that may crash
- when last strip of image contains fewer number of scanlines than
- specified by the `/Height' variable. See
- http://bugzilla.remotesensing.org/show_bug.cgi?id=164
- for explanation.
-
-2002-06-21 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiff2ps, man/tiff2ps.1: New functionality for tiff2ps utility:
- splitting long images in several pages. See
- http://bugzilla.remotesensing.org/show_bug.cgi?id=142 for explanation.
- Patch granted by John Williams <williams@morinda.com>.
-
-2002-06-11 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/contrib/win95: renamed to contrib/win_dib. Added new
- Tiffile.cpp example of converting TIFF files into a DIB on Win32.
- This one is described in:
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=143
-
- * libtiff/tif_ojpeg.c: Major upgrade from Scott. See details at:
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=156
-
-2002-05-10 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiff2ps: New commandline switches to override resolution
- units obtained from the input file. Closes
- http://bugzilla.remotesensing.org/show_bug.cgi?id=131
-
-2002-04-26 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/libtiff.def: Added missed declaration.
-
-2002-04-22 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/fax2tiff.c: Updated to reflect latest changes in libtiff.
- Closes http://bugzilla.remotesensing.org/show_bug.cgi?id=125
-
-2002-04-20 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_open.c: Pointers to custom procedures
- in TIFFClientOpen() are checked to be not NULL-pointers.
-
-2002-04-18 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/libtiff.def: Added missed declarations.
-
- * libtiff/tif_pixarlog.c: Updated for using tif_tagmethods structure.
-
-2002-04-16 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_lzw.c: Additional checks for data integrity introduced.
- Should finally close
- http://bugzilla.remotesensing.org/show_bug.cgi?id=100
-
-2002-04-10 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/tiff2ps: Division by zero fixed.
- Closes http://bugzilla.remotesensing.org/show_bug.cgi?id=88
-
-2002-04-09 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/: tif_dirwrite.c, tif_write.c, tiffio.h:
- TIFFCheckpointDirectory() routine added.
- Closes http://bugzilla.remotesensing.org/show_bug.cgi?id=124
-
- * man/: TIFFWriteDirectory.3t, Makefile.in: Added description
- for the new function.
-
-2002-04-08 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/: tif_codec.c, tif_compress.c, tiffiop.h: Introduced
- additional members tif->tif_decodestatus and tif->tif_encodestatus
- for correct handling of unconfigured codecs (we should not try to read
- data or to define data size without correct codecs).
-
- * libtiff/tif_getimage.c: The way of codecs checking in TIFFRGBAImageOK
- changed. Now it has used tif->tif_decodestatus and
- tif->tif_encodestatus.
- Should fix http://bugzilla.remotesensing.org/show_bug.cgi?id=119 (in
- case of __cvs_8.tif test image).
-
- * libtiff/: tif_dirinfo.c, tif_dirread.c: Somebody makes a bug in
- tif_dirread.c when TIFFCreateAnonFieldInfo was introduced.
- Closes http://bugzilla.remotesensing.org/show_bug.cgi?id=119 in case
- of _cvs_00000-00.tif, _cvs_00000-01.tif and _cvs_00000-02.tif.
-
-2002-04-04 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/: tif_lzw.c: Assertions in LZWDecode and LZWDecodeCompat
- replaced by warnings. Now libtiff should read corrupted LZW-compressed
- files by skipping bad strips.
- Closes http://bugzilla.remotesensing.org/show_bug.cgi?id=100
-
-2002-04-03 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_dirwrite.c: Removed some dead code.
-
- * libtiff/*: Cleanup some warnings.
-
- * libtiff/tif_dir.c: Fixed bug with count returned by TIFFGetField()
- for variable length FIELD_CUSTOM values. Was int * but should be
- u_short *.
-
-2002-04-01 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * tools/: tifcp.c: Added support for 'Orientation' tag in tiffcp
- utility (at cpStripToTile routine).
-
-2002-03-27 Frank Warmerdam <warmerdam@pobox.com>
-
- * tif_dirread.c: avoid div-by-zero if rowbytes is zero in chop func.
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=111
-
- * tif_print.c: Fixed so that ASCII FIELD_CUSTOM values with
- passcount set FALSE can be printed (such as TIFFTAG_SOFTWARE).
-
- * libtiff/tif_dir.c,tif_dirinfo.c,tif_dir.h,tif_ojpeg.c: modified so
- that TIFFTAG_SOFTWARE uses FIELD_CUSTOM as an example.
-
-2002-03-26 Dwight Kelly <dbmalloc@remotesensing.org>
-
- * libtiff/: tiff.h, tif_dir.c, tif_dir.h, tif_dirinfo.c, tif_dirread.c,
- tif_dirwrite.c: Added get/put code for new tag XMLPACKET as defined
- in Adobe XMP Technote. Added missing INKSET tag value from TIFF 6.0 spec
- INKSET_MULTIINK (=2). Added missing tags from Adobe TIFF technotes:
- CLIPPATH, XCLIPPATHUNITS, YCLIPPATHUNITS, OPIIMAGEID, OPIPROXY and
- INDEXED. Added PHOTOMETRIC tag value from TIFF technote 4 ICCLAB (=9).
-
-2002-03-26 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/: tif_getimage.c: TIFFReadRGBAStrip and TIFFReadRGBATile
- now also uses TIFFRGBAImageOK before reading. This is additional fix
- for http://bugzilla.remotesensing.org/show_bug.cgi?id=110
-
-2002-03-25 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/: tif_getimage.c: Additional check for supported
- codecs added in TIFFRGBAImageOK and TIFFReadRGBAImage now uses
- TIFFRGBAImageOK before reading.
- Closes http://bugzilla.remotesensing.org/show_bug.cgi?id=110
-
-2002-03-15 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/: tif_dir.c, tif_dir.h, tif_dirinfo.c, tif_dirread.c,
- tif_dirwrite.c: Added routine TIFFDataWidth for detrmining
- TIFFDataType sizes instead of working with tiffDataWidth array
- directly. Should prevent out-of-borders bugs in case of unknown or
- broken data types. EstimateStripByteCounts routine modified, so it
- won't work when tags with unknown sizes founded.
- Closes http://bugzilla.remotesensing.org/show_bug.cgi?id=109
-
-2002-03-13 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/tif_getimage.c: Added support for correct handling
- `Orientation' tag in gtTileContig. Should be added in other gt*
- functions as well, but I have not images for testing yet. Partially
- resolves http://bugzilla.remotesensing.org/show_bug.cgi?id=23
-
-2002-03-10 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/: tif_dirinfo.c, tif_dirwrite.c: Added possibility to
- read broken TIFFs with LONG type used for TIFFTAG_COMPRESSION,
- TIFFTAG_BITSPERSAMPLE, TIFFTAG_PHOTOMETRIC. Closes
- http://bugzilla.remotesensing.org/show_bug.cgi?id=99
-
-2002-03-08 Andrey Kiselev <dron@ak4719.spb.edu>
-
- * libtiff/Makefile.in, tools/Makefile.in: Shared library will not
- be stripped when installing, utility binaries will do. Closes
- http://bugzilla.remotesensing.org/show_bug.cgi?id=93
-
-2002-02-28 Frank Warmerdam <warmerdam@pobox.com>
-
- * man/TIFFGetField: fixed type of TIFFTAG_COPYRIGHT.
-
- * man/libtiff.3t: added copyright tag info.
-
-2002-02-11 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/{tiff.h,tif_fax3.c}: Add support for __arch64__.
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=94
-
- * man/Makefile.in: Patch DESTDIR handling
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=95
-
- * configure: OpenBSD changes for Sparc64 and DSO version.
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=96
-
-2002-02-05 Frank Warmerdam <warmerdam@pobox.com>
-
- * config.site/configure: added support for OJPEG=yes option to enable
- OJPEG support from config.site.
-
-2002-01-27 Frank Warmerdam <warmerdam@pobox.com>
-
- * html/document.html: fixed links for TIFf 6 docs.
-
-2002-01-18 Frank Warmerdam <warmerdam@pobox.com>
-
- * config.guess, config.sub: Updated from ftp.gnu.org/pub/config.
-
- * libtiff/tif_read.c: Fixed TIFFReadEncodedStrip() to fail if the
- decodestrip function returns anything not greater than zero as per
- http://bugzilla.remotesensing.org/show_bug.cgi?id=97
-
- * configure: Modify CheckForBigEndian so it can work in a cross
- compiled situation.
-
-2002-01-16 Frank Warmerdam <warmerdam@pobox.com>
-
- * tools/tiffdump.c: include TIFFTAG_JPEGTABLES in tag list.
-
- * tools/tiffset.c: fix bug in error reporting.
-
- * tools/tiffcp.c: fix several warnings that show up with -Wall.
-
-2002-01-04 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_jpeg.c: fixed computation of segment_width for
- tiles files to avoid error about it not matching the
- cinfo.d.image_width values ("JPEGPreDecode: Improper JPEG strip/tile
- size.") for ITIFF files. Apparently the problem was incorporated since
- 3.5.5, presumably during the OJPEG/JPEG work recently.
-
-2001-12-15 Frank Warmerdam <warmerdam@pobox.com>
-
- * configure, libtiff/Makefile.in: Changes for building on MacOS 10.1.
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=94
-
- * libtiff/tif_getimage.c: If DEFAULT_EXTRASAMPLE_AS_ALPHA is 1
- (defined in tiffconf.h - 1 by default) then the RGBA interface
- will assume that a fourth extra sample is ASSOCALPHA if the
- EXTRASAMPLE value isn't set for it. This changes the behaviour of
- the library, but makes it work better with RGBA files produced by
- lots of applications that don't mark the alpha values properly.
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=93
- http://bugzilla.remotesensing.org/show_bug.cgi?id=65
-
-2001-12-12 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_jpeg.c: allow jpeg data stream sampling values to
- override those from tiff directory. This makes this work with
- ImageGear generated files.
-
-2001-12-07 Frank Warmerdam <warmerdam@pobox.com>
-
- * html/Makefile.in: added missing images per bug 92.
-
- * port/Makefile.in: fixed clean target per bug 92.
-
-2001-11-28 Frank Warmerdam <warmerdam@pobox.com>
-
- * Reissue 3.5.7 release.
-
- * libtiff/mkversion.c: Fix output of TIFF_VERSION to be
- YYYYMMDD so that it is increasing over time.
-
- * Makefile.in: Ensure that tiffvers.h is regenerated in the
- make release target.
-
- * Makefile.in: added libtiff/tiffvers.h to the release file list.
-
-2001-11-23 Frank Warmerdam <warmerdam@pobox.com>
-
- * added html/v3.5.7.html, updated html/index.html.
-
- * Makefile.in: added contrib/addtiffo/tif_ovrcache.{c,h}.
-
-2001-11-15 Frank Warmerdam <warmerdam@pobox.com>
-
- * configure: fixed test for -lm.
-
-2001-11-02 Frank Warmerdam <warmerdam@pobox.com>
-
- * Added PHOTOMETRIC_ITULAB as per bug 90.
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=90
-
-2001-10-10 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tiff.h: I have created COMPRESSION_CCITT_T4,
- COMPRESSION_CCITT_T6, TIFFTAG_T4OPTIONS and TIFFTAG_T6OPTIONS aliases
- in keeping with TIFF 6.0 standard in tiff.h
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=83
-
-2001-09-26 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_dirwrite.c: added TIFFRewriteDirectory() function.
- Updated TIFFWriteDirectory man page to include TIFFRewriteDirectory.
-
-2001-09-24 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_lzw.c: Avoid MS VC++ 5.0 optimization bug.
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=78
-
- * libtiff/tif_lzw.c: added dummy LZWSetupEncode() to report an
- error about LZW not being available.
-
- * libtiff/tif_dir.c: propagate failure to initialize compression
- back from TIFFSetField() as an error status, so applications can
- detect failure.
-
- * libtiff/tif_dir.c: removed the auto replacement of
- COMPRESSION_LZW with COMPRESSION_NONE in _TIFFVSetField().
-
- * Removed Makefile, tools/Makefile, port/install.sh, man/Makefile
- from CVS as they are all supposed to be auto-generated by configure.
-
-2001-09-22 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_ojpeg.c: new update from Scott.
-
-2001-09-09 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtif/tif_fax3.c: Removed #ifdef PURIFY logic, and modified to
- always use the "safe" version, even if there is a very slight
- cost in performance.
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=54
-
- * libtiff/Makefile.in: Fixed @DSOSUB_VERSION to be @DSOSUF_VERSION@
- in two places.
-
- * libtiff/tif_getimage.c: Fixed problem with reading strips or
- tiles that don't start on a tile boundary. Fix contributed by
- Josep Vallverdu (from HP), and further described in bug 47.
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=47
-
- * tools/tiff2ps.c: added OJPEG YCbCr to RGB support.
-
- * libtiff/tif_ojpeg.c: Applied substantial patch from Scott.
-
-2001-09-06 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_packbits.c: fixed memory overrun error.
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=77
-
-2001-08-31 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_getimage.c: relax handling of contig case where
- there are extra samples that are supposed to be ignored. This
- should now work for 8bit greyscale or paletted images.
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=75
-
-2001-08-28 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_getimage.c: Don't complain for CMYK (separated)
- images with more than four samples per pixel. See:
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=73
-
-2001-08-10 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_getimage.c: Use memmove() instead of TIFFmemcpy()
- in TIFFReadRGBATile() to avoid issues in cases of overlapping
- buffers. See Bug 69 in Bugzilla.
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=69
-
- * tools/tiff2rgba.c: fixed getopt() call so that -b works again.
-
-2001-08-09 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tiff.h, libtiff/tif_fax3.c: added check for __LP64__
- when checking for 64 bit architectures as per bugzilla bug 67.
-
-2001-07-27 Frank Warmerdam <warmerdam@pobox.com>
-
- * man/Makefile.in: add TIFFClientOpen link as per debian submitted
- bug 66.
-
-2001-07-20 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_jpeg.c: Define HAVE_BOOLEAN on windows if RPCNDR.H
- has been included.
-
-2001-07-19 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_open.c: Seek back to zero after failed read,
- before writing header.
-
-2001-07-18 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_ojpeg.c: updates from Scott. Handles colors
- much better. Now depends on having patched libjpeg as per
- patch in contrib/ojpeg/*.
-
-2001-07-17 Frank Warmerdam <warmerdam@pobox.com>
-
- * */Makefile.in: added DESTDIR support.
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=60
-
-2001-07-16 Frank Warmerdam <warmerdam@pobox.com>
-
- * configure, libtiff/Makefile.in: applied OpenBSD patches
- as per:
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=61
-
-2001-06-28 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_getimage.c: Fixed so that failure is properly
- reported by gtTileContig, gtStripContig, gtTileSeparate and
- gtStripSeparate.
-
- See http://bugzilla.remotesensing.org/show_bug.cgi?id=51
-
- * tiffcmp.c: Fixed multi samples per pixel support for ContigCompare.
- Updated bug section of tiffcmp.1 to note tiled file issues.
-
- See http://bugzilla.remotesensing.org/show_bug.cgi?id=53
-
-2001-06-22 Frank Warmerdam <warmerdam@pobox.com>
-
- * configure: Changes for DSO generation on AIX provided by
- John Marquart <jomarqua@indiana.edu>.
-
- * configure, libtiff/Makeifle.in: Modified to build DSOs properly
- on Darwin thanks to Robert Krajewski (rpk@alum.mit.edu) and
- Keisuke Fujii (fujiik@jlcuxf.kek.jp).
-
-2001-06-13 Frank Warmerdam <warmerdam@pobox.com>
-
- * tools/tiff2rgba.c: added -n flag to avoid emitting alpha component.
-
- * man/tiff2rgba.1: new
-
-2001-05-22 Frank Warmerdam <warmerdam@pobox.com>
-
- * Added tiffset and tif_ojpeg to the dist lists in Makefile.in.
-
-2001-05-13 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tools/thumbnail.c: changed default output compression
- to packbits from LZW since LZW isn't generally available.
-
-2001-05-12 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_ojpeg.c: New.
- libtiff/tif_jpeg.c, tiffconf.h, tif_getimage.c: changes related
- to OJPEG support.
-
- Scott Marovich <marovich@hpl.hp.com> supplied OJPEG support.
-
-2001-05-11 Frank Warmerdam <warmerdam@pobox.com>
-
- * tiff.h: removed, it duplicates libtiff/tiff.h.
-
-2001-05-08 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_dirinfo.c: moved pixar and copyright flags to
- ensure everything is in order.
-
- * libtiff/libtiff.def: added TIFFCreateDirectory and
- TIFFDefaultStripSize as per:
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=46
-
-2001-05-02 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_dirinfo.c: Modified the TIFF_BYTE definition for
- TIFFTAG_PHOTOSHOP to use a writecount of TIFF_VARIABLE2 (-3) to
- force use of uint32 counts instead of short counts.
-
- * libtiff/tif_dirwrite.c: Added support for TIFF_VARIABLE2 in the
- case of writing TIFF_BYTE/TIFF_SBYTE fields.
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=43
-
-2001-05-01 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_dirinfo.c: removed duplicate TIFFTAG_PHOTOSHOP as per
- bug report http://bugzilla.remotesensing.org/show_bug.cgi?id=44
-
-2001-04-05 Frank Warmerdam <warmerdam@pobox.com>
-
- * tiffio.h: removed C++ style comment.
-
- * configure: fixed up SCRIPT_SH/SHELL handling.
-
- * Makefile.in: Fixed SCRIPT_SH/SHELL handling.
-
- * config.guess: documented more variables as per bug 40.
-
-2001-04-03 Frank Warmerdam <warmerdam@pobox.com>
-
- * configure, *Makefile.in: Various changes to improve configuration
- for HP/UX specifically, and also in general. They include:
- - Try to handle /usr/bin/sh instead of /bin/sh where necessary.
- - Upgrade to HP/UX 10.x+ compiler, linker and dso options.
- - Fixed mmap() test to avoid MMAP_FIXED ... it isn't available on HP
- - Use -${MAKEFLAGS} in sub makes from makefiles.
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=40
-
-2001-04-02 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tiff.h: Applied hac to try and resolve the problem
- with the inttypes.h include file on AIX.
-
- See http://bugzilla.remotesensing.org/show_bug.cgi?id=39
-
- * VERSION: update to 3.5.7 beta in preparation for release.
-
- * configure/config.site: modified to check if -lm is needed for
- MACHDEPLIBS if not supplied by config.site. Needed for Darwin.
-
- * config.guess: updated wholesale to an FSF version apparently
- from 1998 (as opposed to 1994). This is mainly inspired by
- providing for MacOS X support.
-
-2001-03-29 Frank Warmerdam <warmerdam@pobox.com>
-
- * configure, Makefile.in, etc: added support for OPTIMIZER being
- set from config.site.
-
-2001-03-28 Frank Warmerdam <warmerdam@pobox.com>
-
- * fax2ps.c: Helge (libtiff at oldach.net) submitted fix:
-
- Here's a fix for fax2ps that corrects behaviour for non-Letter paper
- sizes. It fixes two problems:
-
- Without scaling (-S) the fax is now centered on the page size specified
- with -H and/or -W. Before, fax2ps was using an obscure and practically
- useless algorithm to allocate the image relative to Letter sized paper
- which sometime sled to useless whitespace on the paper, while at the
- same time cutting of the faxes printable area at the opposite border.
-
- Second, scaling now preserves aspect ratio, which makes unusual faxes
- (in particular short ones) print properly.
-
- See http://bugzilla.remotesensing.org/show_bug.cgi?id=35
-
- * tiff2ps.c/tiff2ps.1: Substantial changes to tiff2ps by
- Bruce A. Mallett. See check message for detailed information
- on all the changes, including a faster encoder, fixes for level
- 2 PostScript, and support for the imagemask operator.
-
-2001-03-27 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tiffio.h: Changed "#if LOGLUV_PUBLIC" to
- "#ifdef LOGLUV_PUBLIC" so it will work with VisualAge on AIX.
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=39
-
-2001-03-16 Frank Warmerdam <warmerdam@pobox.com>
-
- * tif_dirinfo.c: moved definition of copyright tag in field list.
- Apparently they have to be in sorted order by tag id.
-
-2001-03-13 Frank Warmerdam <warmerdam@pobox.com>
-
- * tif_getimage.c: Added support for 16bit minisblack/miniswhite
- images in RGBA interface.
-
-2001-03-02 Frank Warmerdam <warmerdam@pobox.com>
-
- * Added TIFFTAG_COPYRIGHT support.
-
-2001-02-19 Frank Warmerdam <warmerdam@pobox.com>
-
- * Brent Roman contributed updated tiffcp utility (and tiffcp.1)
- with support for extracting subimages with the ,n syntax, and also
- adding the -b bias removal flag.
-
-2001-02-16 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/libtiff.def: Brent Roman submitted new version adding
- several missing entry points.
-
- * libtiff/tif_dirinfo.c: don't declare tiffFieldInfo static on VMS.
- Some sort of weird VMS thing.
-
- http://bugzilla.remotesensing.org/show_bug.cgi?id=31
-
- * tif_luv.c/tiff.h/tiffio.h:
- New version of TIFF LogLuv (SGILOG) modules contributed by Greg Ward
- (greg@shutterfly.com). He writes:
-
- 1) I improved the gamut-mapping function in tif_luv.c for imaginary
- colors, because some images were being super-saturated on the input
- side and this resulted in some strange color shifts in the output.
-
- 2) I added a psuedotag in tiff.h to control random dithering during
- LogLuv encoding. This is turned off by default for 32-bit LogLuv and
- on for 24-bit LogLuv output. Dithering improves the average color
- accuracy over the image.
-
- 3) I added a #define for LOG_LUV_PUBLIC, which is enabled by default in
- tiffio.h, to expose internal routines for converting between LogLuv and
- XYZ coordinates. This is helpful for writing more efficient,
- specialized conversion routines, especially for reading LogLuv files.
-
- Changes applied with minor edits.
-
-2001-01-23 Frank Warmerdam <warmerdam@pobox.com>
-
- * tif_fax3.c: keep rw_mode flag internal to fax3 state to remember
- whether we are encoding or decoding. This is to ensure graceful
- recovery if TIFFClientOpen() discovers an attempt to open a compressed
- file for "r+" access, and subsequently close it, as it resets the
- tif_mode flag to O_RDONLY in this case to avoid writes, confusing the
- compressor's concept of whether it is in encode or decode mode.
-
-2001-01-08 Mike Welles <mike@bangstate.com>
-
- * Makefile.in: Now cleaning up after itself after creating the .tar.gz and .zip
-
-2001-01-07 Frank Warmerdam <warmerdam@pobox.com>
-
- * html/libtiff.html: Fixed arguments in example for TIFFRGBAImageGet()
- as per bug report by Patrick Connor.
-
-2000-12-28 Frank Warmerdam <warmerdam@pobox.com>
-
- * Added RELEASE-DATE file to release file list.
-
- * Fixed libtiff/makefile.vc to make tiffvers.h not version.h.
-
-2000-12-22 Mike Welles <mike@bangstate.com>
- * added link to CVS mirror from index.html
-
- * updated html/internals.html to note that LZW compression is
- not supported by default.
-
-2000-12-22 Frank Warmerdam <warmerdam@pobox.com>
-
- * updated html/libtiff.html to not point at Niles' old JPL web site
- for the man pages, point at www.libtiff.org.
-
-2000-12-21 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/tif_apple.c: Applied "Carbon" support patches supplied by
- Leonard Rosenthol <leonardr@lazerware.com>. May interfere
- with correct building on older systems. If so, please let me know.
-
-2000-12-19 Mike Welles <mike@bangsate.com>
-
- * Took out LZW Encoding from tif_lzw.c
-
- * Created HOWTO-RELEASE
-
- * Created html/v3.5.6.html
-
- * updated index.html
-
-2000-12-01 Frank Warmerdam <warmerdam@pobox.com>
-
- * Added patches for EOFB support in tif_fax3.c and tif_fax3.h.
- Patches supplied by Frank Cringle <fdc@cliwe.ping.de>
- Example file at: ftp://ftp.remotesensing.org/pub/libtiff/eofb_396.tif
-
-2000-11-24 Frank Warmerdam <warmerdam@pobox.com>
-
- * libtiff/Makefile.in: Added an installPrivateHdrs and install-private
- target so that the private headers required by libgeotiff can be
- installed with the others. They are not installed by default.
-
- * libtiff/Makefile.in: Added @MACHLIBDEPS@ to LINUXdso and GNULDdso
- targets so libtiff.so will be built with an explicit dependency
- on libm.so.
-
- * libtiff/Makefile.in: Use softlinks to link libtiff.so.3 to
- libtiff.so.3.5.5.
-
- * libtiff/Makefile.in & configure: Remove all references to the ALPHA
- file, or ALPHA version logic. Added stuff about DIST_POINT in
- place of DIST_TYPE and the alpha release number stuff.
-
-2000-11-22 Frank Warmerdam <warmerdam@pobox.com>
-
- * I have applied a patch from Steffen Moeller <moeller@ebi.ac.uk> to
- the configure script so that it now accepts the --prefix, and
- --exec-prefix directives.
-
-2000-11-13 Frank Warmerdam <warmerda@cs46980-c>
-
- * I have made a variety of modifications in an effort to ensure the
- TIFFLIB_VERSION macro is automatically generated from the RELEASE-DATE
- file which seems to be updated regularly.
-
- o mkversion.c now reads RELEASE-DATE and emits TIFFLIB_VERSION in
- version include file.
- o renamed version.h to tiffvers.h because we now have to install it
- with the public libtiff include files.
- o include tiffvers.h in tiffio.h.
- o updated tif_version.c to use tiffvers.h.
- o Updated Makefile.in accordingly.
-
- * As per http://bugzilla.remotesensing.org/show_bug.cgi?id=25
- I have updated the win32 detection rules in tiffcomp.h.
-
-2000-10-20 Frank Warmerdam <warmerda@cs46980-c>
-
- * tif_getimage.c: Fixed RGBA translation for YCbCr images for which
- the strip/tile width and height aren't multiples of the sampling size.
- See http://bugzilla.remotesensing.org/show_bug.cgi?id=20
- Some patches from Rick LaMont of Dot C Software.
-
- * Modified tif_packbits.c encoder to avoid compressing more
- data than provided if rowsize doesn't factor into provided data
- (such as occurs for YCbCr).
-
-2000-10-19 Frank Warmerdam <warmerda@cs46980-c>
-
- * tools/rgb2ycbcr.c: fixed output strip size to account for vertical
- roundup if rows_per_strip not a multiple of vertical sample size.
-
-2000-10-16 Frank Warmerdam <warmerda@cs46980-c>
-
- * tif_dir.c: Clear TIFF_ISTILED flag in TIFFDefaultDirectory
- as per http://bugzilla.remotesensing.org/show_bug.cgi?id=18
- from vandrove@vc.cvut.cz.
-
- * Modified tif_packbits.c decoding to avoid overrunning the
- output buffer, and to issue a warning if data needs to be
- discarded. See http://bugzilla.remotesensing.org/show_bug.cgi?id=18
-
-2000-10-12 Frank Warmerdam <warmerda@cs46980-c>
-
- * Modified tiff2bw to ensure portions add to 100%, and that
- white is properly recovered.
-
- See bug http://bugzilla.remotesensing.org/show_bug.cgi?id=15
- Patch c/o Stanislav Brabec <utx@penguin.cz>
-
-2000-09-30 Frank Warmerdam <warmerda@cs46980-c>
-
- * Modified TIFFClientOpen() to emit an error on an attempt to
- open a comperessed file for update (O_RDWR/r+) access. This is
- because the compressor/decompressor code gets very confused when
- the mode is O_RDWR, assuming this means writing only. See
- bug http://bugzilla.remotesensing.org/show_bug.cgi?id=13
-
-2000-09-27 Frank Warmerdam <warmerda@cs46980-c>
-
- * Added GNULDdso target an`d switched linux and freebsd to use it.
-
-2000-09-26 Frank Warmerdam <warmerda@cs46980-c>
-
- * Applied patch for 0x0000 sequences in tif_fax3.h's definition
- of EXPAND1D() as per bug 11 (from Roman).
-
-2000-09-25 Frank Warmerdam <warmerda@cs46980-c>
- * Fixed tiffcomp.h to avoid win32 stuff if unix #defined, to improve
- cygwin compatibility.
-
- * Applied patch from Roman Shpount to tif_fax3.c. This seems to
- be a proper fix to the buffer sizing problem. See
- http://bugzilla.remotesensing.org/show_bug.cgi?id=11
-
- * Fixed tif_getimage.c to fix overrun bug with YCbCr images without
- downsampling. http://bugzilla.remotesensing.org/show_bug.cgi?id=10
- Thanks to Nick Lamb <njl98r@ecs.soton.ac.uk> for reporting the
- bug and proving the patch.
-
-2000-09-18 Frank Warmerdam <warmerda@cs46980-c>
-
- * Fixed tif_jpeg.c so avoid destroying the decompressor before
- we are done access data thanks to bug report from:
- Michael Eckstein <eckstein@gepro.cz>.
-
- * Reverted tif_flush change.
-
-2000-09-14 Frank Warmerdam <warmerda@cs46980-c>
-
- * tif_flush.c: Changed so that TIFFFlushData() doesn't return an
- error when TIFF_BEENWRITING is not set. This ensures that the
- directory contents can still be flushed by TIFFFlush().
-
-2000-08-14 Frank Warmerdam <warmerda@rommel.atlsci.com>
-
- * tif_open.c: Don't set MMAP for O_RDWR files.
-
- * tif_open.c: Set STRIPCHOP_DEFAULT for O_RDWR as well as O_RDONLY
- so that files opened for update can be strip chopped too.
-
- * tif_read.c: fixed up bug with files missing rowsperstrip and
- the strips per separation fix done a few weeks ago.
-
-2000-07-17 Frank Warmerdam <warmerda@cs46980-c>
-
- * Tentatively added support for SAMPLEFORMAT_COMPLEXIEEEFP, and
- SAMPLEFORMAT_COMPLEXINT.
-
-2000-07-13 Mike Welles <mike@onshore.com>
-
- * index.html, bugs.html: added bugzilla info.
-
-2000-07-12 Frank Warmerdam <warmerda@rommel.atlsci.com>
-
- * tif_read.c: fix subtle bug with determining the number of
- rows for strips that are the last strip in a separation but
- not the last strip of all in TIFFReadEncodedStrip().
-
- * Applied 16/32 bit fix to tif_fax3.c. Fix supplied by
- Peter Skarpetis <peters@serendipity-software.com.au>
-
-2000-06-15 Frank Warmerdam <warmerda@rommel.atlsci.com>
-
- * Modified tiffio.h logic with regard to including windows.h. It
- won't include it when building with __CYGWIN__.
-
-2000-05-11 Frank Warmerdam <warmerda@cs46980-c>
-
- * README: update to mention www.libtiff.org, don't list Sam's old
- email address.
-
- * configure: Fixed DSO test for Linux as per patch from
- Jan Van Buggenhout <chipzz@Ace.ULYSSIS.Student.KULeuven.Ac.Be>.
-
-2000-04-21 Frank Warmerdam <warmerda@rommel.atlsci.com>
-
- * libtiff/tif_dirread.c: Don't use estimate strip byte count for
- one tile/strip images with an offset, and byte count of zero. These
- could be "unpopulated" images.
-
-2000-04-18 Frank Warmerdam <warmerda@rommel.atlsci.com>
-
- * contrib/addtiffo: Added "averaging" resampling option.
-
- * tools/tiffsplit.c: Copy TIFFTAG_SAMPLEFORMAT.
-
-Tue Apr 18 16:18:08 2000 Frank Warmerdam <warmerda@esabot.atlsci.com>
-
- * tools/Makefile.in: Modified to install properly on SGI.
-
-2000-04-12 Mike Welles <mike@onshore.com>
- * configure: Fixed stupid mistake in libc6 test on Linux
-
-2000-04-04 Mike Welles <mike@onshore.com>
- * tif_win32.c: Applied patch to fix overreads and ovverwrites
- caught by BoundsChecker. From Arvan Pritchard
- <arvan.pritchard@infomatix.co.uk> (untested).
-
- * tif_getimage.c: Applied patch to silence VC6 warnings. From
- Arvan Pritchard <arvan.pritchard@informatix.co.uk>
-
- * tif_lzw.c: Applied patch to silence VC6 warnings. From
- Arvan Pritchard <arvan.pritchard@informatix.co.uk>
-
-2000-03-28 Frank Warmerdam <warmerda@cs46980-c>
-
- * Added contrib/stream (stream io) code submitted by Avi Bleiweiss.
-
-2000-03-28 Frank Warmerdam <warmerda@cs46980-c> *** 3.5.5 release ***
-
- * fax2ps: Fixed mixup of width and height in bounding box statement
- as per submission by Nalin Dahyabhai <nalin@redhat.com>.
-
-2000-03-27 Mike Welles <mike@onshore.com>
-
- * fax2ps: Modified printruns to take uint32 instead of uint16.
- Patch courtesy of Bernt Herd <herd@herdsoft.com>
-
-2000-03-20 Mike Welles <mike@onshore.com>
-
- * configure: added test for libc6 for linux targets. Bug reported by
- Stanislav Brabec <utx@k332.feld.cvut.cz>
-
- * Added 3.5 docs to html/Makefile.in.
- Thanks to Stanislav Brabec <utx@k332.feld.cvut.cz>
-
- * configure: fixed bugs in sed scripts
- (applied sed script s:/@:s;@:;s:/s;;:;: to configure).
- fix submitted to Stanislav Brabec <utx@k332.feld.cvut.cz>
-
- * tools/iptcutil was not in files list, and wasn't being
- added to tar archive. Updated Makefile.in.
-
-2000-03-17 Frank Warmerdam <warmerda@cs46980-c>
-
- * tif_fax3.c: Fixed serious bug introduced during the uint16->uint32
- conversion for the run arrays.
-
-2000-03-03 Frank Warmerdam <warmerda@cs46980-c.mtnk1.on.wave.home.com>
-
- * Set td_sampleformat default to SAMPLEFORMAT_UINT instead of
- SAMPLEFORMAT_VOID in TIFFDefaultDirectory() in tif_dir.c.
-
-2000-03-02 Frank Warmerdam <warmerda@cs46980-c.mtnk1.on.wave.home.com>
-
- * Added "GetDefaulted" support for TIFFTAG_SAMPLEFORMAT in tif_aux.c.
-
- * Patched tif_fax3.c so that dsp->runs is allocated a bit bigger
- to avoid overruns encountered with frle_bug.tif.
-
-Tue Feb 15 22:01:05 2000 Frank Warmerdam <warmerda@gdal.velocet.ca>
-
- * Fixed tools/tiffcmp so that stopondiff testing works.
- Patch care of Joseph Orost <joe@sanskrit.lz.att.com>.
-
-2000-01-28 <warmerda@CS46980-B>
-
- * Modified tif_unix.c to support 2-4GB seeks if USE_64BIT_API is
- set to 1, and added default (off) setting in tiffconf.h. This
- should eventually be set by the configure script somehow.
-
- The original work on all these 2-4GB changes was done by
- Peter Smith (psmith@creo.com).
-
- * Modified tif_win32.c to support 2-4GB seeks.
-
- * tentatively changed toff_t to be unsigned instead of signed to
- facilitate support for 2-4GB files.
-
- * Updated a variety of files to use toff_t. Fixed some mixups
- between toff_t and tsize_t.
-
-Fri Jan 28 10:13:49 2000 Frank Warmerdam <warmerda@gdal.velocet.ca>
-
- * Largely reimplemented contrib/addtiffo to avoid temp files,
- updating the TIFF file in place. Fixed a few other bugs to.
-
- * Set tif_rawdatasize to zero when freeing raw data buffer in
- TIFFWriteDirectory().
-
- * Enabled "REWRITE_HACK" in tif_write.c by default.
-
- * Fix bug in tif_write.c when switching between reading one directory
- and writing to another.
-
- * Made TIFFWriteCheck() public, and added TIFFCreateDirectory()
-
-Wed Jan 5 12:37:48 2000 Frank Warmerdam <warmerda@gdal.velocet.ca>
-
- * Added TIFFmemory(3t) functions to libtiff.def.
-
-Tue Jan 4 13:39:00 2000 Frank Warmerdam <warmerda@gdal.velocet.ca>
-
- * Added libtiff/libtiff.def to TIFFILES distribution list.
-
-Mon Dec 27 12:13:39 EST 1999 Mike Welles <mike@onshore.com>
-
- * Created lzw compression kit, as a new module (libtiff-lzw-compression-kit).
-
- * Altered descriptions in tools to reflect "by default" lzw not supported
-
- * Updated index.html to note lzw compression kit.
-
-Tue Dec 21 14:01:51 1999 Frank Warmerdam <warmerda@gdal.velocet.ca>
-
- * Added fax3sm_winnt.c to distribution list in Makefile.in.
-
-Tue Dec 21 11:04:45 EST 1999 Mike Welles <mike@onshore.com> *** 3.5.4 release ***
-
- * Aadded Pixar tag support. Contributed by Phil Beffery <phil@pixar.com>
-
- * Made one more change to tif_dir.c for removal of LZW compression. Also added notice
- when LZW compression invoked.
-
- * Changed default compression in tools to TIFF_PACKBITS, and changed usage descriptions
- in tools to reflect removal of LZW compression
-
-Mon Dec 20 18:39:02 EST 1999 Mike Welles <mike@onshore.com>
-
- * Fixed bug that caused LZW (non) compression to segfault. Added
- warning about LZW compression removed being removed, and why.
-
- * Added nostrip to install in tools/Makefile.in so that debugging
- symbols are kept.
-
-Tue Dec 7 12:04:47 EST 1999 Mike Welles <mike@onshore.com>
-
- * Added patch from Ivo Penzar <ivo.penzar@infolink-software.com>,
- supporting Adobe ZIP deflate. Untested.
-
-Sat Dec 4 15:47:11 1999 Frank Warmerdam <warmerda@gdal.velocet.ca>
-
- * Made Packbits the default compression in tools/tiff2rgba.c instead
- of LZW.
-
-Tue Nov 30 14:41:43 1999 Frank Warmerdam <warmerda@gdal.velocet.ca> *** 3.5.3. release ***
-
- * Added tif_luv to contrib/djgpp/Makefile.lib.
-
-Tue Nov 30 14:15:32 EST 1999 Mike Welles <mike@onshore.com>
-
- * Added zip creation to release makefile target
-
- * Added html for TIFFWriteTile.3t man page.
-
-Tue Nov 30 09:20:16 1999 Frank Warmerdam <warmerda@gdal.velocet.ca>
-
- * Added some changes to tif_write.c to support rewriting existing
- fixed sized tiles and strips. Code mods disabled by default, only
- enabled if REWRITE_HACK is defined for now.
-
-Mon Nov 29 11:43:42 1999 Frank Warmerdam <warmerda@gdal.velocet.ca>
-
- * Added TIFFWriteTile.3t man page.
-
-Sun Nov 28 20:36:18 1999 Frank Warmerdam <warmerda@gdal.velocet.ca>
-
- * Added notes on use of makefile.vc in build.html, and fixed
- email subscription address.
-
-199-11-28 Mike Welles <mike@onshore.com>
-
- * Fixed apocalypse-inducing y2k bug in contrib/ras/ras2tiff.c
-
- * Did some casts cleaning up to reduce compiler warnings in tif_fax3.c,
- from Bruce Carmeron <cameron@petris.com> -- modifications of
- changes made by Frank (sun cc still complained on cast).
-
- * Added tiffconf.h to install target per request from Bill
- Radcliffe <billr@corbis.com>: "We need a way for ImageMagick to
- know features have been compiled into the TIFF library in order to
- handle things properly".
-
-Sat Nov 27 16:49:21 1999 Frank Warmerdam <warmerda@gdal.velocet.ca>
-
- * fixed various VC++ warnings as suggested by Gilles Vollant
- <info@winimage.com>.
-
-Wed Nov 24 12:08:16 1999 Frank Warmerdam <warmerda@gdal.velocet.ca>
-
- * Modified TIFFquery.3t man pages info on TIFFIsByteSwapped() to
- not imply applications are responsible for image data swapping.
-
-1999-11-22 Mike Welles <mike@onshore.com>
- * HTML-ized the man pages, added to html/man
-
- * Removed LZW Compression to comply with Unisys patent extortion.
-
-1999-09-29 Mike Welles <mike@onshore.com>
- * Corrected one remaining 16 -> 32 bit value in tif_fax3.c,
- From Ivo Penzar <ivo.penzar@infolink-software.com.
-
- * Added patch from Ivo Penzar to have TiffAdvanceDirectory handle
- memory mapped files. <ivo.penzar@infolink-software.com>
-
-1999-09-26 Mike Welles <mike@onshore.com> *** 3.5.2 release ***
- * Corrected alpha versioning.
-
- * Removed distinction between alpha and release targets in Makefile.in.
-
- * added release.stamp target, which tags cvs tree, and updates
- "RELEASE-DATE"
-
- * added releasediff target, which diffs tree with source as of
- date in "RELEASE-DATE"
-
- * Ticked up version to 3.5.2 (alpha 01 -- but I think we'll moving
- away from alpha/non-alpha distinctions).
-
- * updated html to reflect release
-
-1999-09-23 <warmerda@CS46980-B>
-
- * Set O_BINARY for tif_unix.c open() ... used on cygwin for instance.
-
- * Added CYGWIN case in configure.
-
-Fri Sep 17 00:13:51 CEST 1999 Mike Welles <mike@onshore.com>
-
- * Applied Francois Dagand's patch to handle fax decompression bug.
- (sizes >= 65536 were failing)
-
-Tue Sep 14 21:31:43 1999 Frank Warmerdam <warmerda@gdal.velocet.ca>
-
- * Applied "a" mode fix to tif_win32.c/TIFFOpen() as suggested
- by Christopher Lawton <clawton@mathworks.com>
-
-Wed Sep 8 08:19:18 1999 Frank Warmerdam <warmerda@gdal.velocet.ca>
-
- * Added IRIX/gcc, and OSF/1 4.x support on behalf of
- Albert Chin-A-Young <china@thewrittenword.com>
-
- * Added TIFFReassignTagToIgnore() API on behalf of
- Bruce Cameron <cameron@petris.com>. Man page still pending.
-
-Wed Aug 25 11:39:07 1999 Frank Warmerdam <warmerda@gdal.velocet.ca>
-
- * Added test target in Makefile, test_pics.sh script and pics/*.rpt
- files to provide for a rudimentary testsuite.
-
- * Added contrib/tags back from old distribution ... fixed up a bit.
-
-1999-08-16 <warmerda@CS46980-B>
-
- * Added simple makefile.vc makefiles for building with MS VC++
- on Windows NT/98/95 in console mode. Stuff in contrib/win* make give
- better solutions for some users.
-
-Mon Aug 16 21:52:11 1999 Frank Warmerdam <warmerda@gdal.velocet.ca>
-
- * Added addtiffo (add overviews to a TIFF file) in contrib. Didn't
- put it in tools since part of it is in C++.
-
-1999-08-16 Michael L. Welles <mike@kurtz.fake>
-
- * Updated html/index.html with anon CVS instructions.
-
-Mon Aug 16 13:18:41 1999 Frank Warmerdam <warmerda@gdal.velocet.ca>
-
- * pre-remove so link before softlink in LINUXdso action in
- libtiff/Makefile.in to avoid failure on LINUXdso builds other than
- the first.
-
- * Fixed problem with cvtcmap() in tif_getimage.c modifying the
- colormaps owned by the TIFF handle itself when trying to fixup wrong
- (eight bit) colormaps. Corrected by maintaining a private copy of
- the colormap.
-
- * Added TIFFReadRGBATile()/TIFFReadRGBAStrip() support in
- tif_getimage.c.
-
- * CVS Repository placed at remotesensing.org. ChangeLog added.
diff --git a/contrib/libs/libtiff/HOWTO-RELEASE b/contrib/libs/libtiff/HOWTO-RELEASE
deleted file mode 100644
index 3821faad1a..0000000000
--- a/contrib/libs/libtiff/HOWTO-RELEASE
+++ /dev/null
@@ -1,155 +0,0 @@
-HOWTO-RELEASE:
-
-Notes on releasing.
-
-0. Make sure that you have current FSF releases of autoconf, automake,
- and libtool packages installed under a common installation prefix
- and that these tools are in your executable search path prior to
- any other installed versions. Versions delivered with Linux may be
- altered so it is best to install official FSF releases. GNU 'm4'
- 1.4.16 is needed in order to avoid bugs in m4. These packages may
- be downloaded from the following ftp locations:
-
- m4 - ftp://ftp.gnu.org/pub/gnu/m4
- autoconf - ftp://ftp.gnu.org/pub/gnu/autoconf
- automake - ftp://ftp.gnu.org/pub/gnu/automake
- libtool - ftp://ftp.gnu.org/pub/gnu/libtool
-
- It is recommended to install m4 before autoconf, since the later
- requires the former.
-
- Release builds should only be done on a system with a functioning
- and correctly set system clock and on a filesystem which accurately
- records file update times. Use of GNU make is recommended.
-
-1. Commit any unsaved changes.
-
-2. Use gnulib's gitlog-to-changelog script to add new (since the last
- release) entries to the traditional ChangeLog file.
-
- http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob_plain;f=build-aux/gitlog-to-changelog
-
- Take note of
- the most recent change note time stamp and use that as the starting
- point. Concatenate the old logs to the new logs. The added logs
- may be used to help produce the release notes (in next step). For
- example:
-
- gitlog-to-changelog --since=`head -n 1 ChangeLog | sed -e 's/ .*//g'` --append-dot > ChangeLog.added
- printf "\n" >> ChangeLog.added
- cat ChangeLog.added ChangeLog > ChangeLog.new
- mv ChangeLog.new ChangeLog
- rm ChangeLog.added
-
-3. Create doc/releases/vX.X.rst and add it to git with 'git add doc/releases/vX.X.rst'.
- Update doc/releases/index.rst to point to the new file
- Take ChangeLog entries and rst-ify in there.
- Easist thing to do is take doc/releases/vX.(X-1).rst and use it as a template.
-
-4. Add vX.X.rst file to the list of 'rst_sources' files in the doc/Makefile.am.
-
-5. Update "Latest Stable Release" in doc/index.rst.
-
-6. Increment the release version in configure.ac. Put 'alpha' or
- 'beta' after the version, if applicable. For example:
-
- 4.0.0
- or
- 4.0.0beta7
-
- Version should be updated in two places: in the second argument of the
- AC_INIT macro and in LIBTIFF_xxx_VERSION variables.
-
-7. Update library ELF versioning in configure.ac (LIBTIFF_CURRENT,
- LIBTIFF_REVISION, and LIBTIFF_AGE). These numbers have nothing to
- do with the libtiff release version numbers.
-
- Note that as of libtiff 4.X, proper ELF versioning is used so
- please follow the rules listed in configure.ac. At a bare minimum,
- you should increment LIBTIFF_REVISION for each release so that
- installed library files don't overwrite existing files. If APIs
- have been added, removed, or interface structures have changed,
- then more care is required.
-
-8. Add an entry to Changelog similar to:
-
- * libtiff 4.0.0 released.
-
-9. In the source tree do
-
- ./autogen.sh
-
- This step may be skipped if you have already been using a
- maintainer build with current autoconf, automake, and libtool
- packages. It is only needed when updating tool versions.
-
-10. It is recommended (but not required) to build outside of the source
- tree so that the source tree is kept in a pristine state. This
- also allows sharing the source directory on several networked
- systems. For example:
-
- mkdir libtiff-build
- cd libtiff-build
- /path/to/libtiff/configure --enable-maintainer-mode
-
- otherwise do
-
- ./configure --enable-maintainer-mode
-
-11. In the build tree do
-
- make release
-
- This will update "RELEASE-DATE", "VERSION" in the source tree,
- and libtiff/tiffvers.h in the build tree.
-
-12. In the source tree, verify that the version info in RELEASE-DATE,
- VERSION is right.
- In the build tree, verify that the version info in
- libtiff/tiffvers.h is right.
-
-13. In the build tree do
-
- make
- make distcheck
-
- If 'make distcheck' fails, then correct any issues until it
- succeeds.
-
- Two files with names tiff-version.tar.gz and tiff-version.zip will
- be created in the top level build directory.
-
-14. In the source tree do
-
- 'git status', 'git add .', 'git commit' and 'git push'
-
-15. In the source tree, create a signed tag
-
- git tag -s v4.0.0 -m "Create tag for v4.0.0"
-
- (or the appropriate name for the release)
-
- and push it to "origin" (if "origin" points to the official repository)
-
- git push origin v4.0.0
-
-16. Sign the release files in the build tree using your private key
-
- export GPG_TTY=$(tty)
- for file in tiff-*.tar.gz tiff-*.tar.xz tiff-*.zip ; do \
- gpg2 --output ${file}.sig --detach-sig $file ; \
- done
-
- for file in tiff-*.tar.gz tiff-*.tar.xz tiff-*.zip ; do \
- gpg2 --verify ${file}.sig $file ; \
- done
-
-17. Copy release packages from the build tree to the
- ftp.remotesensing.org ftp site.
-
- scp tiff-*.tar.gz tiff-*.tar.gz.sig tiff-*.tar.xz tiff-*.tar.xz.sig tiff-*.zip tiff-*.zip.sig \
- bfriesen@upload.osgeo.org:/osgeo/download/libtiff
-
-18. Create a gitlab release at https://gitlab.com/libtiff/libtiff/-/releases
-
-19. Announce to list: tiff@lists.osgeo.org
diff --git a/contrib/libs/libtiff/HOWTO-SECURITY-RELEASE b/contrib/libs/libtiff/HOWTO-SECURITY-RELEASE
deleted file mode 100644
index ad23977ae2..0000000000
--- a/contrib/libs/libtiff/HOWTO-SECURITY-RELEASE
+++ /dev/null
@@ -1,19 +0,0 @@
-LibTIFF Security Issue Handling
-===============================
-
-Libtiff can be a significant security risk as many tools use it to read
-TIFF files which can come from hostile sources. Thus buffer overflows
-and other security holes in libtiff put many users at risk. To that end
-we try to deal with security problems fairly quickly and to provide advance
-notice to various interested parties to role out security fixes before they
-go out in a standard release.
-
-This document is new and will presumably evolve.
-
-1) The mailing list distros@vs.openwall.org can be used to notify folks
-at various linux OS distributions as well as the BSD folks about problems
-in libtiff. Make sure to prefix subject with [vs]. More info at:
-
- http://oss-security.openwall.org/wiki/mailing-lists/distros
-
-... to be continued ...
diff --git a/contrib/libs/libtiff/LICENSE.md b/contrib/libs/libtiff/LICENSE.md
deleted file mode 100644
index 55b65673ed..0000000000
--- a/contrib/libs/libtiff/LICENSE.md
+++ /dev/null
@@ -1,23 +0,0 @@
-# LibTIFF license
-
-Copyright © 1988-1997 Sam Leffler\
-Copyright © 1991-1997 Silicon Graphics, Inc.
-
-Permission to use, copy, modify, distribute, and sell this software and
-its documentation for any purpose is hereby granted without fee, provided
-that (i) the above copyright notices and this permission notice appear in
-all copies of the software and related documentation, and (ii) the names of
-Sam Leffler and Silicon Graphics may not be used in any advertising or
-publicity relating to the software without the specific, prior written
-permission of Sam Leffler and Silicon Graphics.
-
-THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
-EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
-WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
-
-IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
-ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
-OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
-LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
-OF THIS SOFTWARE.
diff --git a/contrib/libs/libtiff/README.md b/contrib/libs/libtiff/README.md
deleted file mode 100644
index 0d83ba24d9..0000000000
--- a/contrib/libs/libtiff/README.md
+++ /dev/null
@@ -1,69 +0,0 @@
-TIFF Software Distribution
---------------------------
-This file is just a placeholder; the entire documentation is now located
-as reStructuredText in the doc directory. To view the documentation
-as HTML, visit https://libtiff.gitlab.io/libtiff/ or
-http://www.simplesystems.org/libtiff/ or within the release package
-in the doc/html-prebuilt directory. The manual pages are
-located at doc/man-prebuilt.
-
-The release package can be downloaded at
-
-http://download.osgeo.org/libtiff/
-
-If you can't hack either of these options then basically what you
-want to do is:
-
- % ./configure
- % make
- % su
- # make install
-
-More information, email contacts, and mailing list information can be
-found online at http://www.simplesystems.org/libtiff/
-
-Source code repository
-----------------------
-
-[GitLab](https://gitlab.com/libtiff/libtiff)
-
-Bug database
-------------
-
-[GitLab issues](https://gitlab.com/libtiff/libtiff/issues)
-
-Previously, the project used
-[Bugzilla](http://bugzilla.maptools.org/buglist.cgi?product=libtiff). This
-is no longer in use, and all remaining issues have been migrated to GitLab.
-
-Use and Copyright
------------------
-Silicon Graphics has seen fit to allow us to give this work away. It
-is free. There is no support or guarantee of any sort as to its
-operations, correctness, or whatever. If you do anything useful with
-all or parts of it you need to honor the copyright notices. I would
-also be interested in knowing about it and, hopefully, be acknowledged.
-
-The legal way of saying that is:
-
-Copyright (c) 1988-1997 Sam Leffler
-Copyright (c) 1991-1997 Silicon Graphics, Inc.
-
-Permission to use, copy, modify, distribute, and sell this software and
-its documentation for any purpose is hereby granted without fee, provided
-that (i) the above copyright notices and this permission notice appear in
-all copies of the software and related documentation, and (ii) the names of
-Sam Leffler and Silicon Graphics may not be used in any advertising or
-publicity relating to the software without the specific, prior written
-permission of Sam Leffler and Silicon Graphics.
-
-THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
-EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
-WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
-
-IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
-ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
-OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
-LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
-OF THIS SOFTWARE.
diff --git a/contrib/libs/libtiff/RELEASE-DATE b/contrib/libs/libtiff/RELEASE-DATE
deleted file mode 100644
index 2abf40291e..0000000000
--- a/contrib/libs/libtiff/RELEASE-DATE
+++ /dev/null
@@ -1 +0,0 @@
-20240911
diff --git a/contrib/libs/libtiff/TODO b/contrib/libs/libtiff/TODO
deleted file mode 100644
index ea266aadf1..0000000000
--- a/contrib/libs/libtiff/TODO
+++ /dev/null
@@ -1,10 +0,0 @@
-o gif2tiff segaulting on selected images
-o tiffcmp read data by strip/tile instead of scanline
-o YCbCr sampling support
-o extracate colorspace conversion support
-o look at isolating all codecs from TIFF library
-o JPEG colormode order dependency problem
-o Write documentation on how do extend tags, and how the custom field
- stuff all works.
-
-
diff --git a/contrib/libs/libtiff/libtiff.map b/contrib/libs/libtiff/libtiff.map
deleted file mode 100644
index 3d15d9c76d..0000000000
--- a/contrib/libs/libtiff/libtiff.map
+++ /dev/null
@@ -1,220 +0,0 @@
-LIBTIFF_4.0 {
- global:
- TIFFAccessTagMethods;
- TIFFCIELabToRGBInit;
- TIFFCIELabToXYZ;
- TIFFCheckTile;
- TIFFCheckpointDirectory;
- TIFFCleanup;
- TIFFClientOpen;
- TIFFClientdata;
- TIFFClose;
- TIFFComputeStrip;
- TIFFComputeTile;
- TIFFCreateDirectory;
- TIFFCurrentDirOffset;
- TIFFCurrentDirectory;
- TIFFCurrentRow;
- TIFFCurrentStrip;
- TIFFCurrentTile;
- TIFFDataWidth;
- TIFFDefaultStripSize;
- TIFFDefaultTileSize;
- TIFFError;
- TIFFErrorExt;
- TIFFFdOpen;
- TIFFFieldWithName;
- TIFFFieldWithTag;
- TIFFFileName;
- TIFFFileno;
- TIFFFindCODEC;
- TIFFFindField;
- TIFFFlush;
- TIFFFlushData;
- TIFFFreeDirectory;
- TIFFGetBitRevTable;
- TIFFGetClientInfo;
- TIFFGetCloseProc;
- TIFFGetConfiguredCODECs;
- TIFFGetField;
- TIFFGetFieldDefaulted;
- TIFFGetMapFileProc;
- TIFFGetMode;
- TIFFGetReadProc;
- TIFFGetSeekProc;
- TIFFGetSizeProc;
- TIFFGetTagListCount;
- TIFFGetTagListEntry;
- TIFFGetUnmapFileProc;
- TIFFGetVersion;
- TIFFGetWriteProc;
- TIFFIsBigEndian;
- TIFFIsByteSwapped;
- TIFFIsCODECConfigured;
- TIFFIsMSB2LSB;
- TIFFIsTiled;
- TIFFIsUpSampled;
- TIFFLastDirectory;
- TIFFMergeFieldInfo;
- TIFFNumberOfDirectories;
- TIFFNumberOfStrips;
- TIFFNumberOfTiles;
- TIFFOpen;
- TIFFOpenW;
- TIFFPrintDirectory;
- TIFFRGBAImageBegin;
- TIFFRGBAImageEnd;
- TIFFRGBAImageGet;
- TIFFRGBAImageOK;
- TIFFRasterScanlineSize;
- TIFFRasterScanlineSize64;
- TIFFRawStripSize;
- TIFFRawStripSize64;
- TIFFReadBufferSetup;
- TIFFReadCustomDirectory;
- TIFFReadDirectory;
- TIFFReadEXIFDirectory;
- TIFFReadEncodedStrip;
- TIFFReadEncodedTile;
- TIFFReadRGBAImage;
- TIFFReadRGBAImageOriented;
- TIFFReadRGBAStrip;
- TIFFReadRGBATile;
- TIFFReadRawStrip;
- TIFFReadRawTile;
- TIFFReadScanline;
- TIFFReadTile;
- TIFFRegisterCODEC;
- TIFFReverseBits;
- TIFFRewriteDirectory;
- TIFFScanlineSize;
- TIFFScanlineSize64;
- TIFFSetClientInfo;
- TIFFSetClientdata;
- TIFFSetDirectory;
- TIFFSetErrorHandler;
- TIFFSetErrorHandlerExt;
- TIFFSetField;
- TIFFSetFileName;
- TIFFSetFileno;
- TIFFSetMode;
- TIFFSetSubDirectory;
- TIFFSetTagExtender;
- TIFFSetWarningHandler;
- TIFFSetWarningHandlerExt;
- TIFFSetWriteOffset;
- TIFFSetupStrips;
- TIFFStripSize;
- TIFFStripSize64;
- TIFFSwabArrayOfDouble;
- TIFFSwabArrayOfFloat;
- TIFFSwabArrayOfLong;
- TIFFSwabArrayOfLong8;
- TIFFSwabArrayOfShort;
- TIFFSwabArrayOfTriples;
- TIFFSwabDouble;
- TIFFSwabFloat;
- TIFFSwabLong;
- TIFFSwabLong8;
- TIFFSwabShort;
- TIFFTileRowSize;
- TIFFTileRowSize64;
- TIFFTileSize;
- TIFFTileSize64;
- TIFFUnRegisterCODEC;
- TIFFUnlinkDirectory;
- TIFFUnsetField;
- TIFFVGetField;
- TIFFVGetFieldDefaulted;
- TIFFVSetField;
- TIFFVStripSize;
- TIFFVStripSize64;
- TIFFVTileSize;
- TIFFVTileSize64;
- TIFFWarning;
- TIFFWarningExt;
- TIFFWriteBufferSetup;
- TIFFWriteCheck;
- TIFFWriteDirectory;
- TIFFWriteEncodedStrip;
- TIFFWriteEncodedTile;
- TIFFWriteRawStrip;
- TIFFWriteRawTile;
- TIFFWriteScanline;
- TIFFWriteTile;
- TIFFXYZToRGB;
- TIFFYCbCrToRGBInit;
- TIFFYCbCrtoRGB;
- _TIFFfree;
- _TIFFmalloc;
- _TIFFmemcmp;
- _TIFFmemcpy;
- _TIFFmemset;
- _TIFFrealloc;
-
- local:
- *;
-};
-
-LIBTIFF_4.1 {
- _TIFFCheckMalloc;
- _TIFFCheckRealloc;
- _TIFFMultiply32;
- _TIFFMultiply64;
- _TIFFRewriteField;
- TIFFCreateCustomDirectory;
- TIFFCreateEXIFDirectory;
- TIFFDeferStrileArrayWriting;
- TIFFFieldDataType;
- TIFFFieldName;
- TIFFFieldPassCount;
- TIFFFieldReadCount;
- TIFFFieldTag;
- TIFFFieldWriteCount;
- TIFFForceStrileArrayWriting;
- TIFFGetStrileByteCount;
- TIFFGetStrileByteCountWithErr;
- TIFFGetStrileOffset;
- TIFFGetStrileOffsetWithErr;
- TIFFReadFromUserBuffer;
- TIFFReadRGBAStripExt;
- TIFFReadRGBATileExt;
- TIFFSetCompressionScheme;
- TIFFWriteCustomDirectory;
-} LIBTIFF_4.0;
-
-LIBTIFF_4.2 {
- TIFFCreateGPSDirectory;
- TIFFReadGPSDirectory;
- _TIFFGetExifFields;
- _TIFFGetGpsFields;
-} LIBTIFF_4.1;
-
-LIBTIFF_4.3 {
-} LIBTIFF_4.2;
-
-LIBTIFF_4.4 {
- TIFFFieldIsAnonymous;
- TIFFFieldSetGetSize;
- TIFFFieldSetGetCountSize;
- TIFFIsBigTIFF;
-} LIBTIFF_4.3;
-
-LIBTIFF_4.5 {
- _TIFFClampDoubleToUInt32;
- TIFFClientOpenExt;
- TIFFFdOpenExt;
- TIFFOpenExt;
- TIFFOpenWExt;
- TIFFErrorExtR;
- TIFFWarningExtR;
- TIFFOpenOptionsAlloc;
- TIFFOpenOptionsFree;
- TIFFOpenOptionsSetMaxSingleMemAlloc;
- TIFFOpenOptionsSetErrorHandlerExtR;
- TIFFOpenOptionsSetWarningHandlerExtR;
-} LIBTIFF_4.4;
-
-LIBTIFF_4.6.1 {
- TIFFOpenOptionsSetMaxCumulatedMemAlloc;
-} LIBTIFF_4.5;
diff --git a/contrib/libs/libtiff/libtiffxx.map b/contrib/libs/libtiff/libtiffxx.map
deleted file mode 100644
index e2f648f9eb..0000000000
--- a/contrib/libs/libtiff/libtiffxx.map
+++ /dev/null
@@ -1,4 +0,0 @@
-LIBTIFFXX_4.0 {
- global:
- *;
-};
diff --git a/contrib/libs/libtiff/patches/02_fix_dirs_without_imagelength.patch b/contrib/libs/libtiff/patches/02_fix_dirs_without_imagelength.patch
deleted file mode 100644
index 6c5625feae..0000000000
--- a/contrib/libs/libtiff/patches/02_fix_dirs_without_imagelength.patch
+++ /dev/null
@@ -1,44 +0,0 @@
---- a/tif_dirread.c
-+++ b/tif_dirread.c
-@@ -3750,5 +3750,4 @@
- if (!TIFFFieldSet(tif, FIELD_IMAGEDIMENSIONS))
- {
-- MissingRequired(tif, "ImageLength");
-- goto bad;
-+ TIFFWarningExtR(tif, module, "TIFF directory is missing required ImageLength field");
- }
-@@ -4263,4 +4263,3 @@
- if (!tif->tif_scanlinesize) {
-- TIFFErrorExtR(tif, module, "Cannot handle zero scanline size");
-- return (0);
-+ TIFFWarningExtR(tif, module, "Cannot handle zero scanline size");
- }
-@@ -4263,4 +4263,3 @@
- if (!tif->tif_tilesize) {
-- TIFFErrorExtR(tif, module, "Cannot handle zero tile size");
-- return (0);
-+ TIFFWarningExtR(tif, module, "Cannot handle zero tile size");
- }
-@@ -4263,4 +4263,3 @@
- if (!TIFFStripSize(tif)) {
-- TIFFErrorExtR(tif, module, "Cannot handle zero strip size");
-- return (0);
-+ TIFFWarningExt(tif, module, "Cannot handle zero strip size");
- }
-@@ -5377,6 +5377,6 @@ static void MissingRequired(TIFF *tif, const char *tagname)
- {
- static const char module[] = "MissingRequired";
-
-- TIFFErrorExtR(tif, module,
-+ TIFFWarningExtR(tif, module,
- "TIFF directory is missing required \"%s\" field", tagname);
- }
---- a/tif_strip.c
-+++ b/tif_strip.c
-@@ -300,5 +300,5 @@
- if (scanline_size == 0)
- {
-- TIFFErrorExtR(tif, module, "Computed scanline size is zero");
-+ TIFFWarningExtR(tif, module, "Computed scanline size is zero");
- return 0;
- }
diff --git a/contrib/libs/libtiff/patches/03_directory_check.patch b/contrib/libs/libtiff/patches/03_directory_check.patch
deleted file mode 100644
index 576020e62d..0000000000
--- a/contrib/libs/libtiff/patches/03_directory_check.patch
+++ /dev/null
@@ -1,20 +0,0 @@
---- contrib/libs/libtiff/tif_dirread.c (index)
-+++ contrib/libs/libtiff/tif_dirread.c (working tree)
-@@ -5121,7 +5121,7 @@ int TIFFReadCustomDirectory(TIFF *tif, toff_t diroff,
- dircount = TIFFFetchDirectory(tif, diroff, &dir, NULL);
- if (!dircount)
- {
-- TIFFErrorExtR(tif, module,
-+ TIFFWarningExtR(tif, module,
- "Failed to read custom directory at offset %" PRIu64,
- diroff);
- return 0;
-@@ -5916,7 +5916,7 @@ static uint16_t TIFFFetchDirectory(TIFF *tif, uint64_t diroff,
- }
- if (dircount16 == 0)
- {
-- TIFFErrorExtR(tif, module,
-+ TIFFWarningExtR(tif, module,
- "Sanity check on directory count failed, zero tag "
- "directories not supported");
- return 0;
diff --git a/contrib/libs/libtiff/patches/04_fix_null_count.patch b/contrib/libs/libtiff/patches/04_fix_null_count.patch
deleted file mode 100644
index cdbc3cd26e..0000000000
--- a/contrib/libs/libtiff/patches/04_fix_null_count.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- contrib/libs/libtiff/tif_dir.c (index)
-+++ contrib/libs/libtiff/tif_dir.c (working tree)
-@@ -807,7 +807,7 @@ static int _TIFFVSetField(TIFF *tif, uint32_t tag, va_list ap)
- if (tv->count == 0)
- {
- status = 0;
-- TIFFErrorExtR(tif, module,
-+ TIFFWarningExtR(tif, module,
- "%s: Null count for \"%s\" (type "
- "%d, writecount %d, passcount %d)",
- tif->tif_name, fip->field_name,
diff --git a/contrib/libs/libtiff/t4.h b/contrib/libs/libtiff/t4.h
deleted file mode 100644
index f933d4a336..0000000000
--- a/contrib/libs/libtiff/t4.h
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- * Copyright (c) 1988-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-#ifndef _T4_
-#define _T4_
-/*
- * CCITT T.4 1D Huffman runlength codes and
- * related definitions. Given the small sizes
- * of these tables it does not seem
- * worthwhile to make code & length 8 bits.
- */
-typedef struct tableentry
-{
- unsigned short length; /* bit length of g3 code */
- unsigned short code; /* g3 code */
- short runlen; /* run length in bits */
-} tableentry;
-
-#define EOL 0x001 /* EOL code value - 0000 0000 0000 1 */
-
-/* status values returned instead of a run length */
-#define G3CODE_EOL -1 /* NB: ACT_EOL - ACT_WRUNT */
-#define G3CODE_INVALID -2 /* NB: ACT_INVALID - ACT_WRUNT */
-#define G3CODE_EOF -3 /* end of input data */
-#define G3CODE_INCOMP -4 /* incomplete run code */
-
-/*
- * Note that these tables are ordered such that the
- * index into the table is known to be either the
- * run length, or (run length / 64) + a fixed offset.
- *
- * NB: The G3CODE_INVALID entries are only used
- * during state generation (see mkg3states.c).
- */
-#ifdef G3CODES
-const tableentry TIFFFaxWhiteCodes[] = {
- {8, 0x35, 0}, /* 0011 0101 */
- {6, 0x7, 1}, /* 0001 11 */
- {4, 0x7, 2}, /* 0111 */
- {4, 0x8, 3}, /* 1000 */
- {4, 0xB, 4}, /* 1011 */
- {4, 0xC, 5}, /* 1100 */
- {4, 0xE, 6}, /* 1110 */
- {4, 0xF, 7}, /* 1111 */
- {5, 0x13, 8}, /* 1001 1 */
- {5, 0x14, 9}, /* 1010 0 */
- {5, 0x7, 10}, /* 0011 1 */
- {5, 0x8, 11}, /* 0100 0 */
- {6, 0x8, 12}, /* 0010 00 */
- {6, 0x3, 13}, /* 0000 11 */
- {6, 0x34, 14}, /* 1101 00 */
- {6, 0x35, 15}, /* 1101 01 */
- {6, 0x2A, 16}, /* 1010 10 */
- {6, 0x2B, 17}, /* 1010 11 */
- {7, 0x27, 18}, /* 0100 111 */
- {7, 0xC, 19}, /* 0001 100 */
- {7, 0x8, 20}, /* 0001 000 */
- {7, 0x17, 21}, /* 0010 111 */
- {7, 0x3, 22}, /* 0000 011 */
- {7, 0x4, 23}, /* 0000 100 */
- {7, 0x28, 24}, /* 0101 000 */
- {7, 0x2B, 25}, /* 0101 011 */
- {7, 0x13, 26}, /* 0010 011 */
- {7, 0x24, 27}, /* 0100 100 */
- {7, 0x18, 28}, /* 0011 000 */
- {8, 0x2, 29}, /* 0000 0010 */
- {8, 0x3, 30}, /* 0000 0011 */
- {8, 0x1A, 31}, /* 0001 1010 */
- {8, 0x1B, 32}, /* 0001 1011 */
- {8, 0x12, 33}, /* 0001 0010 */
- {8, 0x13, 34}, /* 0001 0011 */
- {8, 0x14, 35}, /* 0001 0100 */
- {8, 0x15, 36}, /* 0001 0101 */
- {8, 0x16, 37}, /* 0001 0110 */
- {8, 0x17, 38}, /* 0001 0111 */
- {8, 0x28, 39}, /* 0010 1000 */
- {8, 0x29, 40}, /* 0010 1001 */
- {8, 0x2A, 41}, /* 0010 1010 */
- {8, 0x2B, 42}, /* 0010 1011 */
- {8, 0x2C, 43}, /* 0010 1100 */
- {8, 0x2D, 44}, /* 0010 1101 */
- {8, 0x4, 45}, /* 0000 0100 */
- {8, 0x5, 46}, /* 0000 0101 */
- {8, 0xA, 47}, /* 0000 1010 */
- {8, 0xB, 48}, /* 0000 1011 */
- {8, 0x52, 49}, /* 0101 0010 */
- {8, 0x53, 50}, /* 0101 0011 */
- {8, 0x54, 51}, /* 0101 0100 */
- {8, 0x55, 52}, /* 0101 0101 */
- {8, 0x24, 53}, /* 0010 0100 */
- {8, 0x25, 54}, /* 0010 0101 */
- {8, 0x58, 55}, /* 0101 1000 */
- {8, 0x59, 56}, /* 0101 1001 */
- {8, 0x5A, 57}, /* 0101 1010 */
- {8, 0x5B, 58}, /* 0101 1011 */
- {8, 0x4A, 59}, /* 0100 1010 */
- {8, 0x4B, 60}, /* 0100 1011 */
- {8, 0x32, 61}, /* 0011 0010 */
- {8, 0x33, 62}, /* 0011 0011 */
- {8, 0x34, 63}, /* 0011 0100 */
- {5, 0x1B, 64}, /* 1101 1 */
- {5, 0x12, 128}, /* 1001 0 */
- {6, 0x17, 192}, /* 0101 11 */
- {7, 0x37, 256}, /* 0110 111 */
- {8, 0x36, 320}, /* 0011 0110 */
- {8, 0x37, 384}, /* 0011 0111 */
- {8, 0x64, 448}, /* 0110 0100 */
- {8, 0x65, 512}, /* 0110 0101 */
- {8, 0x68, 576}, /* 0110 1000 */
- {8, 0x67, 640}, /* 0110 0111 */
- {9, 0xCC, 704}, /* 0110 0110 0 */
- {9, 0xCD, 768}, /* 0110 0110 1 */
- {9, 0xD2, 832}, /* 0110 1001 0 */
- {9, 0xD3, 896}, /* 0110 1001 1 */
- {9, 0xD4, 960}, /* 0110 1010 0 */
- {9, 0xD5, 1024}, /* 0110 1010 1 */
- {9, 0xD6, 1088}, /* 0110 1011 0 */
- {9, 0xD7, 1152}, /* 0110 1011 1 */
- {9, 0xD8, 1216}, /* 0110 1100 0 */
- {9, 0xD9, 1280}, /* 0110 1100 1 */
- {9, 0xDA, 1344}, /* 0110 1101 0 */
- {9, 0xDB, 1408}, /* 0110 1101 1 */
- {9, 0x98, 1472}, /* 0100 1100 0 */
- {9, 0x99, 1536}, /* 0100 1100 1 */
- {9, 0x9A, 1600}, /* 0100 1101 0 */
- {6, 0x18, 1664}, /* 0110 00 */
- {9, 0x9B, 1728}, /* 0100 1101 1 */
- {11, 0x8, 1792}, /* 0000 0001 000 */
- {11, 0xC, 1856}, /* 0000 0001 100 */
- {11, 0xD, 1920}, /* 0000 0001 101 */
- {12, 0x12, 1984}, /* 0000 0001 0010 */
- {12, 0x13, 2048}, /* 0000 0001 0011 */
- {12, 0x14, 2112}, /* 0000 0001 0100 */
- {12, 0x15, 2176}, /* 0000 0001 0101 */
- {12, 0x16, 2240}, /* 0000 0001 0110 */
- {12, 0x17, 2304}, /* 0000 0001 0111 */
- {12, 0x1C, 2368}, /* 0000 0001 1100 */
- {12, 0x1D, 2432}, /* 0000 0001 1101 */
- {12, 0x1E, 2496}, /* 0000 0001 1110 */
- {12, 0x1F, 2560}, /* 0000 0001 1111 */
- {12, 0x1, G3CODE_EOL}, /* 0000 0000 0001 */
- {9, 0x1, G3CODE_INVALID}, /* 0000 0000 1 */
- {10, 0x1, G3CODE_INVALID}, /* 0000 0000 01 */
- {11, 0x1, G3CODE_INVALID}, /* 0000 0000 001 */
- {12, 0x0, G3CODE_INVALID}, /* 0000 0000 0000 */
-};
-
-const tableentry TIFFFaxBlackCodes[] = {
- {10, 0x37, 0}, /* 0000 1101 11 */
- {3, 0x2, 1}, /* 010 */
- {2, 0x3, 2}, /* 11 */
- {2, 0x2, 3}, /* 10 */
- {3, 0x3, 4}, /* 011 */
- {4, 0x3, 5}, /* 0011 */
- {4, 0x2, 6}, /* 0010 */
- {5, 0x3, 7}, /* 0001 1 */
- {6, 0x5, 8}, /* 0001 01 */
- {6, 0x4, 9}, /* 0001 00 */
- {7, 0x4, 10}, /* 0000 100 */
- {7, 0x5, 11}, /* 0000 101 */
- {7, 0x7, 12}, /* 0000 111 */
- {8, 0x4, 13}, /* 0000 0100 */
- {8, 0x7, 14}, /* 0000 0111 */
- {9, 0x18, 15}, /* 0000 1100 0 */
- {10, 0x17, 16}, /* 0000 0101 11 */
- {10, 0x18, 17}, /* 0000 0110 00 */
- {10, 0x8, 18}, /* 0000 0010 00 */
- {11, 0x67, 19}, /* 0000 1100 111 */
- {11, 0x68, 20}, /* 0000 1101 000 */
- {11, 0x6C, 21}, /* 0000 1101 100 */
- {11, 0x37, 22}, /* 0000 0110 111 */
- {11, 0x28, 23}, /* 0000 0101 000 */
- {11, 0x17, 24}, /* 0000 0010 111 */
- {11, 0x18, 25}, /* 0000 0011 000 */
- {12, 0xCA, 26}, /* 0000 1100 1010 */
- {12, 0xCB, 27}, /* 0000 1100 1011 */
- {12, 0xCC, 28}, /* 0000 1100 1100 */
- {12, 0xCD, 29}, /* 0000 1100 1101 */
- {12, 0x68, 30}, /* 0000 0110 1000 */
- {12, 0x69, 31}, /* 0000 0110 1001 */
- {12, 0x6A, 32}, /* 0000 0110 1010 */
- {12, 0x6B, 33}, /* 0000 0110 1011 */
- {12, 0xD2, 34}, /* 0000 1101 0010 */
- {12, 0xD3, 35}, /* 0000 1101 0011 */
- {12, 0xD4, 36}, /* 0000 1101 0100 */
- {12, 0xD5, 37}, /* 0000 1101 0101 */
- {12, 0xD6, 38}, /* 0000 1101 0110 */
- {12, 0xD7, 39}, /* 0000 1101 0111 */
- {12, 0x6C, 40}, /* 0000 0110 1100 */
- {12, 0x6D, 41}, /* 0000 0110 1101 */
- {12, 0xDA, 42}, /* 0000 1101 1010 */
- {12, 0xDB, 43}, /* 0000 1101 1011 */
- {12, 0x54, 44}, /* 0000 0101 0100 */
- {12, 0x55, 45}, /* 0000 0101 0101 */
- {12, 0x56, 46}, /* 0000 0101 0110 */
- {12, 0x57, 47}, /* 0000 0101 0111 */
- {12, 0x64, 48}, /* 0000 0110 0100 */
- {12, 0x65, 49}, /* 0000 0110 0101 */
- {12, 0x52, 50}, /* 0000 0101 0010 */
- {12, 0x53, 51}, /* 0000 0101 0011 */
- {12, 0x24, 52}, /* 0000 0010 0100 */
- {12, 0x37, 53}, /* 0000 0011 0111 */
- {12, 0x38, 54}, /* 0000 0011 1000 */
- {12, 0x27, 55}, /* 0000 0010 0111 */
- {12, 0x28, 56}, /* 0000 0010 1000 */
- {12, 0x58, 57}, /* 0000 0101 1000 */
- {12, 0x59, 58}, /* 0000 0101 1001 */
- {12, 0x2B, 59}, /* 0000 0010 1011 */
- {12, 0x2C, 60}, /* 0000 0010 1100 */
- {12, 0x5A, 61}, /* 0000 0101 1010 */
- {12, 0x66, 62}, /* 0000 0110 0110 */
- {12, 0x67, 63}, /* 0000 0110 0111 */
- {10, 0xF, 64}, /* 0000 0011 11 */
- {12, 0xC8, 128}, /* 0000 1100 1000 */
- {12, 0xC9, 192}, /* 0000 1100 1001 */
- {12, 0x5B, 256}, /* 0000 0101 1011 */
- {12, 0x33, 320}, /* 0000 0011 0011 */
- {12, 0x34, 384}, /* 0000 0011 0100 */
- {12, 0x35, 448}, /* 0000 0011 0101 */
- {13, 0x6C, 512}, /* 0000 0011 0110 0 */
- {13, 0x6D, 576}, /* 0000 0011 0110 1 */
- {13, 0x4A, 640}, /* 0000 0010 0101 0 */
- {13, 0x4B, 704}, /* 0000 0010 0101 1 */
- {13, 0x4C, 768}, /* 0000 0010 0110 0 */
- {13, 0x4D, 832}, /* 0000 0010 0110 1 */
- {13, 0x72, 896}, /* 0000 0011 1001 0 */
- {13, 0x73, 960}, /* 0000 0011 1001 1 */
- {13, 0x74, 1024}, /* 0000 0011 1010 0 */
- {13, 0x75, 1088}, /* 0000 0011 1010 1 */
- {13, 0x76, 1152}, /* 0000 0011 1011 0 */
- {13, 0x77, 1216}, /* 0000 0011 1011 1 */
- {13, 0x52, 1280}, /* 0000 0010 1001 0 */
- {13, 0x53, 1344}, /* 0000 0010 1001 1 */
- {13, 0x54, 1408}, /* 0000 0010 1010 0 */
- {13, 0x55, 1472}, /* 0000 0010 1010 1 */
- {13, 0x5A, 1536}, /* 0000 0010 1101 0 */
- {13, 0x5B, 1600}, /* 0000 0010 1101 1 */
- {13, 0x64, 1664}, /* 0000 0011 0010 0 */
- {13, 0x65, 1728}, /* 0000 0011 0010 1 */
- {11, 0x8, 1792}, /* 0000 0001 000 */
- {11, 0xC, 1856}, /* 0000 0001 100 */
- {11, 0xD, 1920}, /* 0000 0001 101 */
- {12, 0x12, 1984}, /* 0000 0001 0010 */
- {12, 0x13, 2048}, /* 0000 0001 0011 */
- {12, 0x14, 2112}, /* 0000 0001 0100 */
- {12, 0x15, 2176}, /* 0000 0001 0101 */
- {12, 0x16, 2240}, /* 0000 0001 0110 */
- {12, 0x17, 2304}, /* 0000 0001 0111 */
- {12, 0x1C, 2368}, /* 0000 0001 1100 */
- {12, 0x1D, 2432}, /* 0000 0001 1101 */
- {12, 0x1E, 2496}, /* 0000 0001 1110 */
- {12, 0x1F, 2560}, /* 0000 0001 1111 */
- {12, 0x1, G3CODE_EOL}, /* 0000 0000 0001 */
- {9, 0x1, G3CODE_INVALID}, /* 0000 0000 1 */
- {10, 0x1, G3CODE_INVALID}, /* 0000 0000 01 */
- {11, 0x1, G3CODE_INVALID}, /* 0000 0000 001 */
- {12, 0x0, G3CODE_INVALID}, /* 0000 0000 0000 */
-};
-#else
-extern const tableentry TIFFFaxWhiteCodes[];
-extern const tableentry TIFFFaxBlackCodes[];
-#endif
-#endif /* _T4_ */
diff --git a/contrib/libs/libtiff/tif_aux.c b/contrib/libs/libtiff/tif_aux.c
deleted file mode 100644
index e9606a42e0..0000000000
--- a/contrib/libs/libtiff/tif_aux.c
+++ /dev/null
@@ -1,411 +0,0 @@
-/*
- * Copyright (c) 1991-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-/*
- * TIFF Library.
- *
- * Auxiliary Support Routines.
- */
-#include "tif_predict.h"
-#include "tiffiop.h"
-#include <float.h>
-#include <math.h>
-
-uint32_t _TIFFMultiply32(TIFF *tif, uint32_t first, uint32_t second,
- const char *where)
-{
- if (second && first > UINT32_MAX / second)
- {
- TIFFErrorExtR(tif, where, "Integer overflow in %s", where);
- return 0;
- }
-
- return first * second;
-}
-
-uint64_t _TIFFMultiply64(TIFF *tif, uint64_t first, uint64_t second,
- const char *where)
-{
- if (second && first > UINT64_MAX / second)
- {
- TIFFErrorExtR(tif, where, "Integer overflow in %s", where);
- return 0;
- }
-
- return first * second;
-}
-
-tmsize_t _TIFFMultiplySSize(TIFF *tif, tmsize_t first, tmsize_t second,
- const char *where)
-{
- if (first <= 0 || second <= 0)
- {
- if (tif != NULL && where != NULL)
- {
- TIFFErrorExtR(tif, where,
- "Invalid argument to _TIFFMultiplySSize() in %s",
- where);
- }
- return 0;
- }
-
- if (first > TIFF_TMSIZE_T_MAX / second)
- {
- if (tif != NULL && where != NULL)
- {
- TIFFErrorExtR(tif, where, "Integer overflow in %s", where);
- }
- return 0;
- }
- return first * second;
-}
-
-tmsize_t _TIFFCastUInt64ToSSize(TIFF *tif, uint64_t val, const char *module)
-{
- if (val > (uint64_t)TIFF_TMSIZE_T_MAX)
- {
- if (tif != NULL && module != NULL)
- {
- TIFFErrorExtR(tif, module, "Integer overflow");
- }
- return 0;
- }
- return (tmsize_t)val;
-}
-
-void *_TIFFCheckRealloc(TIFF *tif, void *buffer, tmsize_t nmemb,
- tmsize_t elem_size, const char *what)
-{
- void *cp = NULL;
- tmsize_t count = _TIFFMultiplySSize(tif, nmemb, elem_size, NULL);
- /*
- * Check for integer overflow.
- */
- if (count != 0)
- {
- cp = _TIFFreallocExt(tif, buffer, count);
- }
-
- if (cp == NULL)
- {
- TIFFErrorExtR(tif, tif->tif_name,
- "Failed to allocate memory for %s "
- "(%" TIFF_SSIZE_FORMAT " elements of %" TIFF_SSIZE_FORMAT
- " bytes each)",
- what, nmemb, elem_size);
- }
-
- return cp;
-}
-
-void *_TIFFCheckMalloc(TIFF *tif, tmsize_t nmemb, tmsize_t elem_size,
- const char *what)
-{
- return _TIFFCheckRealloc(tif, NULL, nmemb, elem_size, what);
-}
-
-static int TIFFDefaultTransferFunction(TIFF *tif, TIFFDirectory *td)
-{
- uint16_t **tf = td->td_transferfunction;
- tmsize_t i, n, nbytes;
-
- tf[0] = tf[1] = tf[2] = 0;
- if (td->td_bitspersample >= sizeof(tmsize_t) * 8 - 2)
- return 0;
-
- n = ((tmsize_t)1) << td->td_bitspersample;
- nbytes = n * sizeof(uint16_t);
- tf[0] = (uint16_t *)_TIFFmallocExt(tif, nbytes);
- if (tf[0] == NULL)
- return 0;
- tf[0][0] = 0;
- for (i = 1; i < n; i++)
- {
- double t = (double)i / ((double)n - 1.);
- tf[0][i] = (uint16_t)floor(65535. * pow(t, 2.2) + .5);
- }
-
- if (td->td_samplesperpixel - td->td_extrasamples > 1)
- {
- tf[1] = (uint16_t *)_TIFFmallocExt(tif, nbytes);
- if (tf[1] == NULL)
- goto bad;
- _TIFFmemcpy(tf[1], tf[0], nbytes);
- tf[2] = (uint16_t *)_TIFFmallocExt(tif, nbytes);
- if (tf[2] == NULL)
- goto bad;
- _TIFFmemcpy(tf[2], tf[0], nbytes);
- }
- return 1;
-
-bad:
- if (tf[0])
- _TIFFfreeExt(tif, tf[0]);
- if (tf[1])
- _TIFFfreeExt(tif, tf[1]);
- if (tf[2])
- _TIFFfreeExt(tif, tf[2]);
- tf[0] = tf[1] = tf[2] = 0;
- return 0;
-}
-
-static int TIFFDefaultRefBlackWhite(TIFF *tif, TIFFDirectory *td)
-{
- int i;
-
- td->td_refblackwhite = (float *)_TIFFmallocExt(tif, 6 * sizeof(float));
- if (td->td_refblackwhite == NULL)
- return 0;
- if (td->td_photometric == PHOTOMETRIC_YCBCR)
- {
- /*
- * YCbCr (Class Y) images must have the ReferenceBlackWhite
- * tag set. Fix the broken images, which lacks that tag.
- */
- td->td_refblackwhite[0] = 0.0F;
- td->td_refblackwhite[1] = td->td_refblackwhite[3] =
- td->td_refblackwhite[5] = 255.0F;
- td->td_refblackwhite[2] = td->td_refblackwhite[4] = 128.0F;
- }
- else
- {
- /*
- * Assume RGB (Class R)
- */
- for (i = 0; i < 3; i++)
- {
- td->td_refblackwhite[2 * i + 0] = 0;
- td->td_refblackwhite[2 * i + 1] =
- (float)((1L << td->td_bitspersample) - 1L);
- }
- }
- return 1;
-}
-
-/*
- * Like TIFFGetField, but return any default
- * value if the tag is not present in the directory.
- *
- * NB: We use the value in the directory, rather than
- * explicit values so that defaults exist only one
- * place in the library -- in TIFFDefaultDirectory.
- */
-int TIFFVGetFieldDefaulted(TIFF *tif, uint32_t tag, va_list ap)
-{
- TIFFDirectory *td = &tif->tif_dir;
-
- if (TIFFVGetField(tif, tag, ap))
- return (1);
- switch (tag)
- {
- case TIFFTAG_SUBFILETYPE:
- *va_arg(ap, uint32_t *) = td->td_subfiletype;
- return (1);
- case TIFFTAG_BITSPERSAMPLE:
- *va_arg(ap, uint16_t *) = td->td_bitspersample;
- return (1);
- case TIFFTAG_THRESHHOLDING:
- *va_arg(ap, uint16_t *) = td->td_threshholding;
- return (1);
- case TIFFTAG_FILLORDER:
- *va_arg(ap, uint16_t *) = td->td_fillorder;
- return (1);
- case TIFFTAG_ORIENTATION:
- *va_arg(ap, uint16_t *) = td->td_orientation;
- return (1);
- case TIFFTAG_SAMPLESPERPIXEL:
- *va_arg(ap, uint16_t *) = td->td_samplesperpixel;
- return (1);
- case TIFFTAG_ROWSPERSTRIP:
- *va_arg(ap, uint32_t *) = td->td_rowsperstrip;
- return (1);
- case TIFFTAG_MINSAMPLEVALUE:
- *va_arg(ap, uint16_t *) = td->td_minsamplevalue;
- return (1);
- case TIFFTAG_MAXSAMPLEVALUE:
- {
- uint16_t maxsamplevalue;
- /* td_bitspersample=1 is always set in TIFFDefaultDirectory().
- * Therefore, td_maxsamplevalue has to be re-calculated in
- * TIFFGetFieldDefaulted(). */
- if (td->td_bitspersample > 0)
- {
- /* This shift operation into a uint16_t limits the value to
- * 65535 even if td_bitspersamle is > 16 */
- if (td->td_bitspersample <= 16)
- {
- maxsamplevalue = (1 << td->td_bitspersample) -
- 1; /* 2**(BitsPerSample) - 1 */
- }
- else
- {
- maxsamplevalue = 65535;
- }
- }
- else
- {
- maxsamplevalue = 0;
- }
- *va_arg(ap, uint16_t *) = maxsamplevalue;
- return (1);
- }
- case TIFFTAG_PLANARCONFIG:
- *va_arg(ap, uint16_t *) = td->td_planarconfig;
- return (1);
- case TIFFTAG_RESOLUTIONUNIT:
- *va_arg(ap, uint16_t *) = td->td_resolutionunit;
- return (1);
- case TIFFTAG_PREDICTOR:
- {
- TIFFPredictorState *sp = (TIFFPredictorState *)tif->tif_data;
- if (sp == NULL)
- {
- TIFFErrorExtR(
- tif, tif->tif_name,
- "Cannot get \"Predictor\" tag as plugin is not configured");
- *va_arg(ap, uint16_t *) = 0;
- return 0;
- }
- *va_arg(ap, uint16_t *) = (uint16_t)sp->predictor;
- return 1;
- }
- case TIFFTAG_DOTRANGE:
- *va_arg(ap, uint16_t *) = 0;
- *va_arg(ap, uint16_t *) = (1 << td->td_bitspersample) - 1;
- return (1);
- case TIFFTAG_INKSET:
- *va_arg(ap, uint16_t *) = INKSET_CMYK;
- return 1;
- case TIFFTAG_NUMBEROFINKS:
- *va_arg(ap, uint16_t *) = 4;
- return (1);
- case TIFFTAG_EXTRASAMPLES:
- *va_arg(ap, uint16_t *) = td->td_extrasamples;
- *va_arg(ap, const uint16_t **) = td->td_sampleinfo;
- return (1);
- case TIFFTAG_MATTEING:
- *va_arg(ap, uint16_t *) =
- (td->td_extrasamples == 1 &&
- td->td_sampleinfo[0] == EXTRASAMPLE_ASSOCALPHA);
- return (1);
- case TIFFTAG_TILEDEPTH:
- *va_arg(ap, uint32_t *) = td->td_tiledepth;
- return (1);
- case TIFFTAG_DATATYPE:
- *va_arg(ap, uint16_t *) = td->td_sampleformat - 1;
- return (1);
- case TIFFTAG_SAMPLEFORMAT:
- *va_arg(ap, uint16_t *) = td->td_sampleformat;
- return (1);
- case TIFFTAG_IMAGEDEPTH:
- *va_arg(ap, uint32_t *) = td->td_imagedepth;
- return (1);
- case TIFFTAG_YCBCRCOEFFICIENTS:
- {
- /* defaults are from CCIR Recommendation 601-1 */
- static const float ycbcrcoeffs[] = {0.299f, 0.587f, 0.114f};
- *va_arg(ap, const float **) = ycbcrcoeffs;
- return 1;
- }
- case TIFFTAG_YCBCRSUBSAMPLING:
- *va_arg(ap, uint16_t *) = td->td_ycbcrsubsampling[0];
- *va_arg(ap, uint16_t *) = td->td_ycbcrsubsampling[1];
- return (1);
- case TIFFTAG_YCBCRPOSITIONING:
- *va_arg(ap, uint16_t *) = td->td_ycbcrpositioning;
- return (1);
- case TIFFTAG_WHITEPOINT:
- {
- /* TIFF 6.0 specification tells that it is no default
- value for the WhitePoint, but AdobePhotoshop TIFF
- Technical Note tells that it should be CIE D50. */
- static const float whitepoint[] = {
- D50_X0 / (D50_X0 + D50_Y0 + D50_Z0),
- D50_Y0 / (D50_X0 + D50_Y0 + D50_Z0)};
- *va_arg(ap, const float **) = whitepoint;
- return 1;
- }
- case TIFFTAG_TRANSFERFUNCTION:
- if (!td->td_transferfunction[0] &&
- !TIFFDefaultTransferFunction(tif, td))
- {
- TIFFErrorExtR(tif, tif->tif_name,
- "No space for \"TransferFunction\" tag");
- return (0);
- }
- *va_arg(ap, const uint16_t **) = td->td_transferfunction[0];
- if (td->td_samplesperpixel - td->td_extrasamples > 1)
- {
- *va_arg(ap, const uint16_t **) = td->td_transferfunction[1];
- *va_arg(ap, const uint16_t **) = td->td_transferfunction[2];
- }
- return (1);
- case TIFFTAG_REFERENCEBLACKWHITE:
- if (!td->td_refblackwhite && !TIFFDefaultRefBlackWhite(tif, td))
- return (0);
- *va_arg(ap, const float **) = td->td_refblackwhite;
- return (1);
- }
- return 0;
-}
-
-/*
- * Like TIFFGetField, but return any default
- * value if the tag is not present in the directory.
- */
-int TIFFGetFieldDefaulted(TIFF *tif, uint32_t tag, ...)
-{
- int ok;
- va_list ap;
-
- va_start(ap, tag);
- ok = TIFFVGetFieldDefaulted(tif, tag, ap);
- va_end(ap);
- return (ok);
-}
-
-float _TIFFClampDoubleToFloat(double val)
-{
- if (val > FLT_MAX)
- return FLT_MAX;
- if (val < -FLT_MAX)
- return -FLT_MAX;
- return (float)val;
-}
-
-uint32_t _TIFFClampDoubleToUInt32(double val)
-{
- if (val < 0)
- return 0;
- if (val > 0xFFFFFFFFU || val != val)
- return 0xFFFFFFFFU;
- return (uint32_t)val;
-}
-
-int _TIFFSeekOK(TIFF *tif, toff_t off)
-{
- /* Huge offsets, especially -1 / UINT64_MAX, can cause issues */
- /* See http://bugzilla.maptools.org/show_bug.cgi?id=2726 */
- return off <= (~(uint64_t)0) / 2 && TIFFSeekFile(tif, off, SEEK_SET) == off;
-}
diff --git a/contrib/libs/libtiff/tif_close.c b/contrib/libs/libtiff/tif_close.c
deleted file mode 100644
index d6bb7f1d7c..0000000000
--- a/contrib/libs/libtiff/tif_close.c
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright (c) 1988-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-/*
- * TIFF Library.
- */
-#include "tiffiop.h"
-#include <string.h>
-
-/************************************************************************/
-/* TIFFCleanup() */
-/************************************************************************/
-
-/**
- * Auxiliary function to free the TIFF structure. Given structure will be
- * completely freed, so you should save opened file handle and pointer
- * to the close procedure in external variables before calling
- * _TIFFCleanup(), if you will need these ones to close the file.
- *
- * @param tif A TIFF pointer.
- */
-
-void TIFFCleanup(TIFF *tif)
-{
- /*
- * Flush buffered data and directory (if dirty).
- */
- if (tif->tif_mode != O_RDONLY)
- TIFFFlush(tif);
- (*tif->tif_cleanup)(tif);
- TIFFFreeDirectory(tif);
-
- _TIFFCleanupIFDOffsetAndNumberMaps(tif);
-
- /*
- * Clean up client info links.
- */
- while (tif->tif_clientinfo)
- {
- TIFFClientInfoLink *psLink = tif->tif_clientinfo;
-
- tif->tif_clientinfo = psLink->next;
- _TIFFfreeExt(tif, psLink->name);
- _TIFFfreeExt(tif, psLink);
- }
-
- if (tif->tif_rawdata && (tif->tif_flags & TIFF_MYBUFFER))
- _TIFFfreeExt(tif, tif->tif_rawdata);
- if (isMapped(tif))
- TIFFUnmapFileContents(tif, tif->tif_base, (toff_t)tif->tif_size);
-
- /*
- * Clean up custom fields.
- */
- if (tif->tif_fields && tif->tif_nfields > 0)
- {
- uint32_t i;
-
- for (i = 0; i < tif->tif_nfields; i++)
- {
- TIFFField *fld = tif->tif_fields[i];
- if (fld->field_name != NULL)
- {
- if (fld->field_bit == FIELD_CUSTOM &&
- /* caution: tif_fields[i] must not be the beginning of a
- * fields-array. Otherwise the following tags are also freed
- * with the first free().
- */
- TIFFFieldIsAnonymous(fld))
- {
- _TIFFfreeExt(tif, fld->field_name);
- _TIFFfreeExt(tif, fld);
- }
- }
- }
-
- _TIFFfreeExt(tif, tif->tif_fields);
- }
-
- if (tif->tif_nfieldscompat > 0)
- {
- uint32_t i;
-
- for (i = 0; i < tif->tif_nfieldscompat; i++)
- {
- if (tif->tif_fieldscompat[i].allocated_size)
- _TIFFfreeExt(tif, tif->tif_fieldscompat[i].fields);
- }
- _TIFFfreeExt(tif, tif->tif_fieldscompat);
- }
-
- if (tif->tif_cur_cumulated_mem_alloc != 0)
- {
- TIFFErrorExtR(tif, "TIFFCleanup",
- "tif_cur_cumulated_mem_alloc = %" PRIu64 " whereas it "
- "should be 0",
- (uint64_t)tif->tif_cur_cumulated_mem_alloc);
- }
-
- _TIFFfreeExt(NULL, tif);
-}
-
-/************************************************************************/
-/* _TIFFCleanupIFDOffsetAndNumberMaps() */
-/************************************************************************/
-
-void _TIFFCleanupIFDOffsetAndNumberMaps(TIFF *tif)
-{
- if (tif->tif_map_dir_offset_to_number)
- {
- TIFFHashSetDestroy(tif->tif_map_dir_offset_to_number);
- tif->tif_map_dir_offset_to_number = NULL;
- }
- if (tif->tif_map_dir_number_to_offset)
- {
- TIFFHashSetDestroy(tif->tif_map_dir_number_to_offset);
- tif->tif_map_dir_number_to_offset = NULL;
- }
-}
-
-/************************************************************************/
-/* TIFFClose() */
-/************************************************************************/
-
-/**
- * Close a previously opened TIFF file.
- *
- * TIFFClose closes a file that was previously opened with TIFFOpen().
- * Any buffered data are flushed to the file, including the contents of
- * the current directory (if modified); and all resources are reclaimed.
- *
- * @param tif A TIFF pointer.
- */
-
-void TIFFClose(TIFF *tif)
-{
- if (tif != NULL)
- {
- TIFFCloseProc closeproc = tif->tif_closeproc;
- thandle_t fd = tif->tif_clientdata;
-
- TIFFCleanup(tif);
- (void)(*closeproc)(fd);
- }
-}
diff --git a/contrib/libs/libtiff/tif_codec.c b/contrib/libs/libtiff/tif_codec.c
deleted file mode 100644
index d499b63a58..0000000000
--- a/contrib/libs/libtiff/tif_codec.c
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright (c) 1988-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-/*
- * TIFF Library
- *
- * Builtin Compression Scheme Configuration Support.
- */
-#include "tiffiop.h"
-
-static int NotConfigured(TIFF *, int);
-
-#ifndef LZW_SUPPORT
-#define TIFFInitLZW NotConfigured
-#endif
-#ifndef PACKBITS_SUPPORT
-#define TIFFInitPackBits NotConfigured
-#endif
-#ifndef THUNDER_SUPPORT
-#define TIFFInitThunderScan NotConfigured
-#endif
-#ifndef NEXT_SUPPORT
-#define TIFFInitNeXT NotConfigured
-#endif
-#ifndef JPEG_SUPPORT
-#define TIFFInitJPEG NotConfigured
-#endif
-#ifndef OJPEG_SUPPORT
-#define TIFFInitOJPEG NotConfigured
-#endif
-#ifndef CCITT_SUPPORT
-#define TIFFInitCCITTRLE NotConfigured
-#define TIFFInitCCITTRLEW NotConfigured
-#define TIFFInitCCITTFax3 NotConfigured
-#define TIFFInitCCITTFax4 NotConfigured
-#endif
-#ifndef JBIG_SUPPORT
-#define TIFFInitJBIG NotConfigured
-#endif
-#ifndef ZIP_SUPPORT
-#define TIFFInitZIP NotConfigured
-#endif
-#ifndef PIXARLOG_SUPPORT
-#define TIFFInitPixarLog NotConfigured
-#endif
-#ifndef LOGLUV_SUPPORT
-#define TIFFInitSGILog NotConfigured
-#endif
-#ifndef LERC_SUPPORT
-#define TIFFInitLERC NotConfigured
-#endif
-#ifndef LZMA_SUPPORT
-#define TIFFInitLZMA NotConfigured
-#endif
-#ifndef ZSTD_SUPPORT
-#define TIFFInitZSTD NotConfigured
-#endif
-#ifndef WEBP_SUPPORT
-#define TIFFInitWebP NotConfigured
-#endif
-
-/*
- * Compression schemes statically built into the library.
- */
-const TIFFCodec _TIFFBuiltinCODECS[] = {
- {"None", COMPRESSION_NONE, TIFFInitDumpMode},
- {"LZW", COMPRESSION_LZW, TIFFInitLZW},
- {"PackBits", COMPRESSION_PACKBITS, TIFFInitPackBits},
- {"ThunderScan", COMPRESSION_THUNDERSCAN, TIFFInitThunderScan},
- {"NeXT", COMPRESSION_NEXT, TIFFInitNeXT},
- {"JPEG", COMPRESSION_JPEG, TIFFInitJPEG},
- {"Old-style JPEG", COMPRESSION_OJPEG, TIFFInitOJPEG},
- {"CCITT RLE", COMPRESSION_CCITTRLE, TIFFInitCCITTRLE},
- {"CCITT RLE/W", COMPRESSION_CCITTRLEW, TIFFInitCCITTRLEW},
- {"CCITT Group 3", COMPRESSION_CCITTFAX3, TIFFInitCCITTFax3},
- {"CCITT Group 4", COMPRESSION_CCITTFAX4, TIFFInitCCITTFax4},
- {"ISO JBIG", COMPRESSION_JBIG, TIFFInitJBIG},
- {"Deflate", COMPRESSION_DEFLATE, TIFFInitZIP},
- {"AdobeDeflate", COMPRESSION_ADOBE_DEFLATE, TIFFInitZIP},
- {"PixarLog", COMPRESSION_PIXARLOG, TIFFInitPixarLog},
- {"SGILog", COMPRESSION_SGILOG, TIFFInitSGILog},
- {"SGILog24", COMPRESSION_SGILOG24, TIFFInitSGILog},
- {"LZMA", COMPRESSION_LZMA, TIFFInitLZMA},
- {"ZSTD", COMPRESSION_ZSTD, TIFFInitZSTD},
- {"WEBP", COMPRESSION_WEBP, TIFFInitWebP},
- {"LERC", COMPRESSION_LERC, TIFFInitLERC},
- {NULL, 0, NULL}};
-
-static int _notConfigured(TIFF *tif)
-{
- const TIFFCodec *c = TIFFFindCODEC(tif->tif_dir.td_compression);
- char compression_code[20];
-
- snprintf(compression_code, sizeof(compression_code), "%" PRIu16,
- tif->tif_dir.td_compression);
- TIFFErrorExtR(tif, tif->tif_name,
- "%s compression support is not configured",
- c ? c->name : compression_code);
- return (0);
-}
-
-static int NotConfigured(TIFF *tif, int scheme)
-{
- (void)scheme;
-
- tif->tif_fixuptags = _notConfigured;
- tif->tif_decodestatus = FALSE;
- tif->tif_setupdecode = _notConfigured;
- tif->tif_encodestatus = FALSE;
- tif->tif_setupencode = _notConfigured;
- return (1);
-}
-
-/************************************************************************/
-/* TIFFIsCODECConfigured() */
-/************************************************************************/
-
-/**
- * Check whether we have working codec for the specific coding scheme.
- *
- * @return returns 1 if the codec is configured and working. Otherwise
- * 0 will be returned.
- */
-
-int TIFFIsCODECConfigured(uint16_t scheme)
-{
- const TIFFCodec *codec = TIFFFindCODEC(scheme);
-
- if (codec == NULL)
- {
- return 0;
- }
- if (codec->init == NULL)
- {
- return 0;
- }
- if (codec->init != NotConfigured)
- {
- return 1;
- }
- return 0;
-}
diff --git a/contrib/libs/libtiff/tif_color.c b/contrib/libs/libtiff/tif_color.c
deleted file mode 100644
index a52fdacba5..0000000000
--- a/contrib/libs/libtiff/tif_color.c
+++ /dev/null
@@ -1,322 +0,0 @@
-/*
- * Copyright (c) 1988-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-/*
- * CIE L*a*b* to CIE XYZ and CIE XYZ to RGB conversion routines are taken
- * from the VIPS library (http://www.vips.ecs.soton.ac.uk) with
- * the permission of John Cupitt, the VIPS author.
- */
-
-/*
- * TIFF Library.
- *
- * Color space conversion routines.
- */
-
-#include "tiffiop.h"
-#include <math.h>
-
-/*
- * Convert color value from the CIE L*a*b* 1976 space to CIE XYZ.
- */
-void TIFFCIELabToXYZ(TIFFCIELabToRGB *cielab, uint32_t l, int32_t a, int32_t b,
- float *X, float *Y, float *Z)
-{
- TIFFCIELab16ToXYZ(cielab, l * 257, a * 256, b * 256, X, Y, Z);
-}
-
-/*
- * For CIELab encoded in 16 bits, L is an unsigned integer range [0,65535].
- * The a* and b* components are signed integers range [-32768,32767]. The 16
- * bit chrominance values are encoded as 256 times the 1976 CIE a* and b*
- * values
- */
-void TIFFCIELab16ToXYZ(TIFFCIELabToRGB *cielab, uint32_t l, int32_t a,
- int32_t b, float *X, float *Y, float *Z)
-{
- float L = (float)l * 100.0F / 65535.0F;
- float cby, tmp;
-
- if (L < 8.856F)
- {
- *Y = (L * cielab->Y0) / 903.292F;
- cby = 7.787F * (*Y / cielab->Y0) + 16.0F / 116.0F;
- }
- else
- {
- cby = (L + 16.0F) / 116.0F;
- *Y = cielab->Y0 * cby * cby * cby;
- }
-
- tmp = (float)a / 256.0F / 500.0F + cby;
- if (tmp < 0.2069F)
- *X = cielab->X0 * (tmp - 0.13793F) / 7.787F;
- else
- *X = cielab->X0 * tmp * tmp * tmp;
-
- tmp = cby - (float)b / 256.0F / 200.0F;
- if (tmp < 0.2069F)
- *Z = cielab->Z0 * (tmp - 0.13793F) / 7.787F;
- else
- *Z = cielab->Z0 * tmp * tmp * tmp;
-}
-
-#define RINT(R) ((uint32_t)((R) > 0 ? ((R) + 0.5) : ((R)-0.5)))
-/*
- * Convert color value from the XYZ space to RGB.
- */
-void TIFFXYZToRGB(TIFFCIELabToRGB *cielab, float X, float Y, float Z,
- uint32_t *r, uint32_t *g, uint32_t *b)
-{
- size_t i;
- float Yr, Yg, Yb;
- float *matrix = &cielab->display.d_mat[0][0];
-
- /* Multiply through the matrix to get luminosity values. */
- Yr = matrix[0] * X + matrix[1] * Y + matrix[2] * Z;
- Yg = matrix[3] * X + matrix[4] * Y + matrix[5] * Z;
- Yb = matrix[6] * X + matrix[7] * Y + matrix[8] * Z;
-
- /* Clip input */
- Yr = TIFFmax(Yr, cielab->display.d_Y0R);
- Yg = TIFFmax(Yg, cielab->display.d_Y0G);
- Yb = TIFFmax(Yb, cielab->display.d_Y0B);
-
- /* Avoid overflow in case of wrong input values */
- Yr = TIFFmin(Yr, cielab->display.d_YCR);
- Yg = TIFFmin(Yg, cielab->display.d_YCG);
- Yb = TIFFmin(Yb, cielab->display.d_YCB);
-
- /* Turn luminosity to colour value. */
- i = (size_t)((Yr - cielab->display.d_Y0R) / cielab->rstep);
- i = TIFFmin((size_t)cielab->range, i);
- *r = RINT(cielab->Yr2r[i]);
-
- i = (size_t)((Yg - cielab->display.d_Y0G) / cielab->gstep);
- i = TIFFmin((size_t)cielab->range, i);
- *g = RINT(cielab->Yg2g[i]);
-
- i = (size_t)((Yb - cielab->display.d_Y0B) / cielab->bstep);
- i = TIFFmin((size_t)cielab->range, i);
- *b = RINT(cielab->Yb2b[i]);
-
- /* Clip output. */
- *r = TIFFmin(*r, cielab->display.d_Vrwr);
- *g = TIFFmin(*g, cielab->display.d_Vrwg);
- *b = TIFFmin(*b, cielab->display.d_Vrwb);
-}
-#undef RINT
-
-/*
- * Allocate conversion state structures and make look_up tables for
- * the Yr,Yb,Yg <=> r,g,b conversions.
- */
-int TIFFCIELabToRGBInit(TIFFCIELabToRGB *cielab, const TIFFDisplay *display,
- float *refWhite)
-{
- size_t i;
- double dfGamma;
-
- cielab->range = CIELABTORGB_TABLE_RANGE;
-
- _TIFFmemcpy(&cielab->display, display, sizeof(TIFFDisplay));
-
- /* Red */
- dfGamma = 1.0 / cielab->display.d_gammaR;
- cielab->rstep =
- (cielab->display.d_YCR - cielab->display.d_Y0R) / cielab->range;
- for (i = 0; i <= (size_t)cielab->range; i++)
- {
- cielab->Yr2r[i] = cielab->display.d_Vrwr *
- ((float)pow((double)i / cielab->range, dfGamma));
- }
-
- /* Green */
- dfGamma = 1.0 / cielab->display.d_gammaG;
- cielab->gstep =
- (cielab->display.d_YCR - cielab->display.d_Y0R) / cielab->range;
- for (i = 0; i <= (size_t)cielab->range; i++)
- {
- cielab->Yg2g[i] = cielab->display.d_Vrwg *
- ((float)pow((double)i / cielab->range, dfGamma));
- }
-
- /* Blue */
- dfGamma = 1.0 / cielab->display.d_gammaB;
- cielab->bstep =
- (cielab->display.d_YCR - cielab->display.d_Y0R) / cielab->range;
- for (i = 0; i <= (size_t)cielab->range; i++)
- {
- cielab->Yb2b[i] = cielab->display.d_Vrwb *
- ((float)pow((double)i / cielab->range, dfGamma));
- }
-
- /* Init reference white point */
- cielab->X0 = refWhite[0];
- cielab->Y0 = refWhite[1];
- cielab->Z0 = refWhite[2];
-
- return 0;
-}
-
-/*
- * Convert color value from the YCbCr space to RGB.
- * The colorspace conversion algorithm comes from the IJG v5a code;
- * see below for more information on how it works.
- */
-#define SHIFT 16
-#define FIX(x) ((int32_t)((x) * (1L << SHIFT) + 0.5))
-#define ONE_HALF ((int32_t)(1 << (SHIFT - 1)))
-#define Code2V(c, RB, RW, CR) \
- ((((c) - (int32_t)(RB)) * (float)(CR)) / \
- (float)(((RW) - (RB) != 0) ? ((RW) - (RB)) : 1))
-/* !((f)>=(min)) written that way to deal with NaN */
-#define CLAMP(f, min, max) \
- ((!((f) >= (min))) ? (min) : (f) > (max) ? (max) : (f))
-#define HICLAMP(f, max) ((f) > (max) ? (max) : (f))
-
-void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *ycbcr, uint32_t Y, int32_t Cb, int32_t Cr,
- uint32_t *r, uint32_t *g, uint32_t *b)
-{
- int32_t i;
-
- /* XXX: Only 8-bit YCbCr input supported for now */
- Y = HICLAMP(Y, 255);
- Cb = CLAMP(Cb, 0, 255);
- Cr = CLAMP(Cr, 0, 255);
-
- i = ycbcr->Y_tab[Y] + ycbcr->Cr_r_tab[Cr];
- *r = CLAMP(i, 0, 255);
- i = ycbcr->Y_tab[Y] +
- (int)((ycbcr->Cb_g_tab[Cb] + ycbcr->Cr_g_tab[Cr]) >> SHIFT);
- *g = CLAMP(i, 0, 255);
- i = ycbcr->Y_tab[Y] + ycbcr->Cb_b_tab[Cb];
- *b = CLAMP(i, 0, 255);
-}
-
-/* Clamp function for sanitization purposes. Normally clamping should not */
-/* occur for well behaved chroma and refBlackWhite coefficients */
-static float CLAMPw(float v, float vmin, float vmax)
-{
- if (v < vmin)
- {
- /* printf("%f clamped to %f\n", v, vmin); */
- return vmin;
- }
- if (v > vmax)
- {
- /* printf("%f clamped to %f\n", v, vmax); */
- return vmax;
- }
- return v;
-}
-
-/*
- * Initialize the YCbCr->RGB conversion tables. The conversion
- * is done according to the 6.0 spec:
- *
- * R = Y + Cr*(2 - 2*LumaRed)
- * B = Y + Cb*(2 - 2*LumaBlue)
- * G = Y
- * - LumaBlue*Cb*(2-2*LumaBlue)/LumaGreen
- * - LumaRed*Cr*(2-2*LumaRed)/LumaGreen
- *
- * To avoid floating point arithmetic the fractional constants that
- * come out of the equations are represented as fixed point values
- * in the range 0...2^16. We also eliminate multiplications by
- * pre-calculating possible values indexed by Cb and Cr (this code
- * assumes conversion is being done for 8-bit samples).
- */
-int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB *ycbcr, float *luma, float *refBlackWhite)
-{
- TIFFRGBValue *clamptab;
- int i;
-
-#define LumaRed luma[0]
-#define LumaGreen luma[1]
-#define LumaBlue luma[2]
-
- clamptab =
- (TIFFRGBValue *)((uint8_t *)ycbcr +
- TIFFroundup_32(sizeof(TIFFYCbCrToRGB), sizeof(long)));
- _TIFFmemset(clamptab, 0, 256); /* v < 0 => 0 */
- ycbcr->clamptab = (clamptab += 256);
- for (i = 0; i < 256; i++)
- clamptab[i] = (TIFFRGBValue)i;
- _TIFFmemset(clamptab + 256, 255, 2 * 256); /* v > 255 => 255 */
- ycbcr->Cr_r_tab = (int *)(clamptab + 3 * 256);
- ycbcr->Cb_b_tab = ycbcr->Cr_r_tab + 256;
- ycbcr->Cr_g_tab = (int32_t *)(ycbcr->Cb_b_tab + 256);
- ycbcr->Cb_g_tab = ycbcr->Cr_g_tab + 256;
- ycbcr->Y_tab = ycbcr->Cb_g_tab + 256;
-
- {
- float f1 = 2 - 2 * LumaRed;
- int32_t D1 = FIX(CLAMP(f1, 0.0F, 2.0F));
- float f2 = LumaRed * f1 / LumaGreen;
- int32_t D2 = -FIX(CLAMP(f2, 0.0F, 2.0F));
- float f3 = 2 - 2 * LumaBlue;
- int32_t D3 = FIX(CLAMP(f3, 0.0F, 2.0F));
- float f4 = LumaBlue * f3 / LumaGreen;
- int32_t D4 = -FIX(CLAMP(f4, 0.0F, 2.0F));
- int x;
-
-#undef LumaBlue
-#undef LumaGreen
-#undef LumaRed
-
- /*
- * i is the actual input pixel value in the range 0..255
- * Cb and Cr values are in the range -128..127 (actually
- * they are in a range defined by the ReferenceBlackWhite
- * tag) so there is some range shifting to do here when
- * constructing tables indexed by the raw pixel data.
- */
- for (i = 0, x = -128; i < 256; i++, x++)
- {
- int32_t Cr = (int32_t)CLAMPw(Code2V(x, refBlackWhite[4] - 128.0F,
- refBlackWhite[5] - 128.0F, 127),
- -128.0F * 32, 128.0F * 32);
- int32_t Cb = (int32_t)CLAMPw(Code2V(x, refBlackWhite[2] - 128.0F,
- refBlackWhite[3] - 128.0F, 127),
- -128.0F * 32, 128.0F * 32);
-
- ycbcr->Cr_r_tab[i] = (int32_t)((D1 * Cr + ONE_HALF) >> SHIFT);
- ycbcr->Cb_b_tab[i] = (int32_t)((D3 * Cb + ONE_HALF) >> SHIFT);
- ycbcr->Cr_g_tab[i] = D2 * Cr;
- ycbcr->Cb_g_tab[i] = D4 * Cb + ONE_HALF;
- ycbcr->Y_tab[i] = (int32_t)CLAMPw(
- Code2V(x + 128, refBlackWhite[0], refBlackWhite[1], 255),
- -128.0F * 32, 128.0F * 32);
- }
- }
-
- return 0;
-}
-#undef HICLAMP
-#undef CLAMP
-#undef Code2V
-#undef SHIFT
-#undef ONE_HALF
-#undef FIX
diff --git a/contrib/libs/libtiff/tif_compress.c b/contrib/libs/libtiff/tif_compress.c
deleted file mode 100644
index c6e17d3e11..0000000000
--- a/contrib/libs/libtiff/tif_compress.c
+++ /dev/null
@@ -1,310 +0,0 @@
-/*
- * Copyright (c) 1988-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-/*
- * TIFF Library
- *
- * Compression Scheme Configuration Support.
- */
-#include "tiffiop.h"
-
-static int TIFFNoEncode(TIFF *tif, const char *method)
-{
- const TIFFCodec *c = TIFFFindCODEC(tif->tif_dir.td_compression);
-
- if (c)
- {
- TIFFErrorExtR(tif, tif->tif_name, "%s %s encoding is not implemented",
- c->name, method);
- }
- else
- {
- TIFFErrorExtR(tif, tif->tif_name,
- "Compression scheme %" PRIu16
- " %s encoding is not implemented",
- tif->tif_dir.td_compression, method);
- }
- return (-1);
-}
-
-int _TIFFNoRowEncode(TIFF *tif, uint8_t *pp, tmsize_t cc, uint16_t s)
-{
- (void)pp;
- (void)cc;
- (void)s;
- return (TIFFNoEncode(tif, "scanline"));
-}
-
-int _TIFFNoStripEncode(TIFF *tif, uint8_t *pp, tmsize_t cc, uint16_t s)
-{
- (void)pp;
- (void)cc;
- (void)s;
- return (TIFFNoEncode(tif, "strip"));
-}
-
-int _TIFFNoTileEncode(TIFF *tif, uint8_t *pp, tmsize_t cc, uint16_t s)
-{
- (void)pp;
- (void)cc;
- (void)s;
- return (TIFFNoEncode(tif, "tile"));
-}
-
-static int TIFFNoDecode(TIFF *tif, const char *method)
-{
- const TIFFCodec *c = TIFFFindCODEC(tif->tif_dir.td_compression);
-
- if (c)
- TIFFErrorExtR(tif, tif->tif_name, "%s %s decoding is not implemented",
- c->name, method);
- else
- TIFFErrorExtR(tif, tif->tif_name,
- "Compression scheme %" PRIu16
- " %s decoding is not implemented",
- tif->tif_dir.td_compression, method);
- return (0);
-}
-
-static int _TIFFNoFixupTags(TIFF *tif)
-{
- (void)tif;
- return (1);
-}
-
-int _TIFFNoRowDecode(TIFF *tif, uint8_t *pp, tmsize_t cc, uint16_t s)
-{
- (void)pp;
- (void)cc;
- (void)s;
- return (TIFFNoDecode(tif, "scanline"));
-}
-
-int _TIFFNoStripDecode(TIFF *tif, uint8_t *pp, tmsize_t cc, uint16_t s)
-{
- (void)pp;
- (void)cc;
- (void)s;
- return (TIFFNoDecode(tif, "strip"));
-}
-
-int _TIFFNoTileDecode(TIFF *tif, uint8_t *pp, tmsize_t cc, uint16_t s)
-{
- (void)pp;
- (void)cc;
- (void)s;
- return (TIFFNoDecode(tif, "tile"));
-}
-
-int _TIFFNoSeek(TIFF *tif, uint32_t off)
-{
- (void)off;
- TIFFErrorExtR(tif, tif->tif_name,
- "Compression algorithm does not support random access");
- return (0);
-}
-
-int _TIFFNoPreCode(TIFF *tif, uint16_t s)
-{
- (void)tif;
- (void)s;
- return (1);
-}
-
-static int _TIFFtrue(TIFF *tif)
-{
- (void)tif;
- return (1);
-}
-static void _TIFFvoid(TIFF *tif) { (void)tif; }
-
-void _TIFFSetDefaultCompressionState(TIFF *tif)
-{
- tif->tif_fixuptags = _TIFFNoFixupTags;
- tif->tif_decodestatus = TRUE;
- tif->tif_setupdecode = _TIFFtrue;
- tif->tif_predecode = _TIFFNoPreCode;
- tif->tif_decoderow = _TIFFNoRowDecode;
- tif->tif_decodestrip = _TIFFNoStripDecode;
- tif->tif_decodetile = _TIFFNoTileDecode;
- tif->tif_encodestatus = TRUE;
- tif->tif_setupencode = _TIFFtrue;
- tif->tif_preencode = _TIFFNoPreCode;
- tif->tif_postencode = _TIFFtrue;
- tif->tif_encoderow = _TIFFNoRowEncode;
- tif->tif_encodestrip = _TIFFNoStripEncode;
- tif->tif_encodetile = _TIFFNoTileEncode;
- tif->tif_close = _TIFFvoid;
- tif->tif_seek = _TIFFNoSeek;
- tif->tif_cleanup = _TIFFvoid;
- tif->tif_defstripsize = _TIFFDefaultStripSize;
- tif->tif_deftilesize = _TIFFDefaultTileSize;
- tif->tif_flags &= ~(TIFF_NOBITREV | TIFF_NOREADRAW);
-}
-
-int TIFFSetCompressionScheme(TIFF *tif, int scheme)
-{
- const TIFFCodec *c = TIFFFindCODEC((uint16_t)scheme);
-
- _TIFFSetDefaultCompressionState(tif);
- /*
- * Don't treat an unknown compression scheme as an error.
- * This permits applications to open files with data that
- * the library does not have builtin support for, but which
- * may still be meaningful.
- */
- return (c ? (*c->init)(tif, scheme) : 1);
-}
-
-/*
- * Other compression schemes may be registered. Registered
- * schemes can also override the builtin versions provided
- * by this library.
- */
-typedef struct _codec
-{
- struct _codec *next;
- TIFFCodec *info;
-} codec_t;
-static codec_t *registeredCODECS = NULL;
-
-const TIFFCodec *TIFFFindCODEC(uint16_t scheme)
-{
- const TIFFCodec *c;
- codec_t *cd;
-
- for (cd = registeredCODECS; cd; cd = cd->next)
- if (cd->info->scheme == scheme)
- return ((const TIFFCodec *)cd->info);
- for (c = _TIFFBuiltinCODECS; c->name; c++)
- if (c->scheme == scheme)
- return (c);
- return ((const TIFFCodec *)0);
-}
-
-TIFFCodec *TIFFRegisterCODEC(uint16_t scheme, const char *name,
- TIFFInitMethod init)
-{
- codec_t *cd = (codec_t *)_TIFFmallocExt(
- NULL,
- (tmsize_t)(sizeof(codec_t) + sizeof(TIFFCodec) + strlen(name) + 1));
-
- if (cd != NULL)
- {
- cd->info = (TIFFCodec *)((uint8_t *)cd + sizeof(codec_t));
- cd->info->name = (char *)((uint8_t *)cd->info + sizeof(TIFFCodec));
- strcpy(cd->info->name, name);
- cd->info->scheme = scheme;
- cd->info->init = init;
- cd->next = registeredCODECS;
- registeredCODECS = cd;
- }
- else
- {
- TIFFErrorExt(0, "TIFFRegisterCODEC",
- "No space to register compression scheme %s", name);
- return NULL;
- }
- return (cd->info);
-}
-
-void TIFFUnRegisterCODEC(TIFFCodec *c)
-{
- codec_t *cd;
- codec_t **pcd;
-
- for (pcd = &registeredCODECS; (cd = *pcd) != NULL; pcd = &cd->next)
- if (cd->info == c)
- {
- *pcd = cd->next;
- _TIFFfreeExt(NULL, cd);
- return;
- }
- TIFFErrorExt(0, "TIFFUnRegisterCODEC",
- "Cannot remove compression scheme %s; not registered",
- c->name);
-}
-
-/************************************************************************/
-/* TIFFGetConfisuredCODECs() */
-/************************************************************************/
-
-/**
- * Get list of configured codecs, both built-in and registered by user.
- * Caller is responsible to free this structure.
- *
- * @return returns array of TIFFCodec records (the last record should be NULL)
- * or NULL if function failed.
- */
-
-TIFFCodec *TIFFGetConfiguredCODECs()
-{
- int i = 1;
- codec_t *cd;
- const TIFFCodec *c;
- TIFFCodec *codecs = NULL;
- TIFFCodec *new_codecs;
-
- for (cd = registeredCODECS; cd; cd = cd->next)
- {
- new_codecs =
- (TIFFCodec *)_TIFFreallocExt(NULL, codecs, i * sizeof(TIFFCodec));
- if (!new_codecs)
- {
- _TIFFfreeExt(NULL, codecs);
- return NULL;
- }
- codecs = new_codecs;
- _TIFFmemcpy(codecs + i - 1, cd->info, sizeof(TIFFCodec));
- i++;
- }
- for (c = _TIFFBuiltinCODECS; c->name; c++)
- {
- if (TIFFIsCODECConfigured(c->scheme))
- {
- new_codecs = (TIFFCodec *)_TIFFreallocExt(NULL, codecs,
- i * sizeof(TIFFCodec));
- if (!new_codecs)
- {
- _TIFFfreeExt(NULL, codecs);
- return NULL;
- }
- codecs = new_codecs;
- _TIFFmemcpy(codecs + i - 1, (const void *)c, sizeof(TIFFCodec));
- i++;
- }
- }
-
- new_codecs =
- (TIFFCodec *)_TIFFreallocExt(NULL, codecs, i * sizeof(TIFFCodec));
- if (!new_codecs)
- {
- _TIFFfreeExt(NULL, codecs);
- return NULL;
- }
- codecs = new_codecs;
- _TIFFmemset(codecs + i - 1, 0, sizeof(TIFFCodec));
-
- return codecs;
-}
diff --git a/contrib/libs/libtiff/tif_config.h b/contrib/libs/libtiff/tif_config.h
deleted file mode 100644
index 2d6ea9bf6b..0000000000
--- a/contrib/libs/libtiff/tif_config.h
+++ /dev/null
@@ -1,157 +0,0 @@
-/* clang-format off */
-/* clang-format disabled because CMake scripts are very sensitive to the
- * formatting of this file. configure_file variables of type "" are
- * modified by clang-format and won't be substituted.
- */
-
-/* libtiff/tif_config.h.cmake.in. Not generated, but originated from autoheader. */
-/* This file must be kept up-to-date with needed substitutions from libtiff/tif_config.h.in. */
-
-#include "tiffconf.h"
-
-/* Support CCITT Group 3 & 4 algorithms */
-#define CCITT_SUPPORT 1
-
-/* Pick up YCbCr subsampling info from the JPEG data stream to support files
- lacking the tag (default enabled). */
-#define CHECK_JPEG_YCBCR_SUBSAMPLING 1
-
-/* enable partial strip reading for large strips (experimental) */
-/* #undef CHUNKY_STRIP_READ_SUPPORT */
-
-/* Support C++ stream API (requires C++ compiler) */
-#define CXX_SUPPORT 1
-
-/* enable deferred strip/tile offset/size loading (experimental) */
-/* #undef DEFER_STRILE_LOAD */
-
-/* Define to 1 if you have the <assert.h> header file. */
-#define HAVE_ASSERT_H 1
-
-/* Define to 1 if you have the declaration of `optarg', and to 0 if you don't. */
-#define HAVE_DECL_OPTARG 1
-
-/* Define to 1 if you have the <fcntl.h> header file. */
-#define HAVE_FCNTL_H 1
-
-/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
-/* #undef HAVE_FSEEKO */
-
-/* Define to 1 if you have the `getopt' function. */
-#define HAVE_GETOPT 1
-
-/* Define to 1 if you have the <GLUT/glut.h> header file. */
-/* #undef HAVE_GLUT_GLUT_H */
-
-/* Define to 1 if you have the <GL/glut.h> header file. */
-/* #undef HAVE_GL_GLUT_H */
-
-/* Define to 1 if you have the <GL/glu.h> header file. */
-/* #undef HAVE_GL_GLU_H */
-
-/* Define to 1 if you have the <GL/gl.h> header file. */
-/* #undef HAVE_GL_GL_H */
-
-/* Define to 1 if you have the <io.h> header file. */
-/* #undef HAVE_IO_H */
-
-/* Define to 1 if you have the `jbg_newlen' function. */
-/* #undef HAVE_JBG_NEWLEN */
-
-/* Define to 1 if you have the `mmap' function. */
-#define HAVE_MMAP 1
-
-/* Define to 1 if you have the <OpenGL/glu.h> header file. */
-/* #undef HAVE_OPENGL_GLU_H */
-
-/* Define to 1 if you have the <OpenGL/gl.h> header file. */
-/* #undef HAVE_OPENGL_GL_H */
-
-/* Define to 1 if you have the `setmode' function. */
-/* #undef HAVE_SETMODE */
-
-/* Define to 1 if you have the <strings.h> header file. */
-#define HAVE_STRINGS_H 1
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#define HAVE_SYS_TYPES_H 1
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#define HAVE_UNISTD_H 1
-
-/* 8/12 bit libjpeg dual mode enabled */
-/* #undef JPEG_DUAL_MODE_8_12 */
-
-/* Support LERC compression */
-/* #undef LERC_SUPPORT */
-
-/* 12bit libjpeg primary include file with path */
-#define LIBJPEG_12_PATH ""
-
-/* Support LZMA2 compression */
-#define LZMA_SUPPORT 1
-
-/* Name of package */
-#define PACKAGE "LibTIFF Software"
-
-/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT "tiff@lists.osgeo.org"
-
-/* Define to the full name of this package. */
-#define PACKAGE_NAME "LibTIFF Software"
-
-/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME "tiff"
-
-/* Define to the home page for this package. */
-#define PACKAGE_URL ""
-
-/* Size of size_t */
-#define SIZEOF_SIZE_T 8
-
-/* Default size of the strip in bytes (when strip chopping enabled) */
-#define STRIP_SIZE_DEFAULT 8192
-
-/** Maximum number of TIFF IFDs that libtiff can iterate through in a file. */
-#define TIFF_MAX_DIR_COUNT 1048576
-
-/* define to use win32 IO system */
-/* #undef USE_WIN32_FILEIO */
-
-/* Support WEBP compression */
-#define WEBP_SUPPORT 1
-
-/* Support ZSTD compression */
-#define ZSTD_SUPPORT 1
-
-
-/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
- significant byte first (like Motorola and SPARC, unlike Intel). */
-#if defined AC_APPLE_UNIVERSAL_BUILD
-# if defined __BIG_ENDIAN__
-# define WORDS_BIGENDIAN 1
-# endif
-#else
-# ifndef WORDS_BIGENDIAN
-# undef WORDS_BIGENDIAN
-# endif
-#endif
-
-#if !defined(__MINGW32__)
-# define TIFF_SIZE_FORMAT "zu"
-#endif
-#if SIZEOF_SIZE_T == 8
-# define TIFF_SSIZE_FORMAT PRId64
-# if defined(__MINGW32__)
-# define TIFF_SIZE_FORMAT PRIu64
-# endif
-#elif SIZEOF_SIZE_T == 4
-# define TIFF_SSIZE_FORMAT PRId32
-# if defined(__MINGW32__)
-# define TIFF_SIZE_FORMAT PRIu32
-# endif
-#else
-# error "Unsupported size_t size; please submit a bug report"
-#endif
-
-/* clang-format on */
diff --git a/contrib/libs/libtiff/tif_dir.c b/contrib/libs/libtiff/tif_dir.c
deleted file mode 100644
index 35375aa6e2..0000000000
--- a/contrib/libs/libtiff/tif_dir.c
+++ /dev/null
@@ -1,2365 +0,0 @@
-/*
- * Copyright (c) 1988-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-/*
- * TIFF Library.
- *
- * Directory Tag Get & Set Routines.
- * (and also some miscellaneous stuff)
- */
-#include "tiffiop.h"
-#include <float.h> /*--: for Rational2Double */
-#include <limits.h>
-
-/*
- * These are used in the backwards compatibility code...
- */
-#define DATATYPE_VOID 0 /* !untyped data */
-#define DATATYPE_INT 1 /* !signed integer data */
-#define DATATYPE_UINT 2 /* !unsigned integer data */
-#define DATATYPE_IEEEFP 3 /* !IEEE floating point data */
-
-static void setByteArray(TIFF *tif, void **vpp, const void *vp, size_t nmemb,
- size_t elem_size)
-{
- if (*vpp)
- {
- _TIFFfreeExt(tif, *vpp);
- *vpp = 0;
- }
- if (vp)
- {
- tmsize_t bytes = _TIFFMultiplySSize(NULL, nmemb, elem_size, NULL);
- if (bytes)
- *vpp = (void *)_TIFFmallocExt(tif, bytes);
- if (*vpp)
- _TIFFmemcpy(*vpp, vp, bytes);
- }
-}
-void _TIFFsetByteArray(void **vpp, const void *vp, uint32_t n)
-{
- setByteArray(NULL, vpp, vp, n, 1);
-}
-void _TIFFsetByteArrayExt(TIFF *tif, void **vpp, const void *vp, uint32_t n)
-{
- setByteArray(tif, vpp, vp, n, 1);
-}
-
-static void _TIFFsetNString(TIFF *tif, char **cpp, const char *cp, uint32_t n)
-{
- setByteArray(tif, (void **)cpp, cp, n, 1);
-}
-
-void _TIFFsetShortArray(uint16_t **wpp, const uint16_t *wp, uint32_t n)
-{
- setByteArray(NULL, (void **)wpp, wp, n, sizeof(uint16_t));
-}
-void _TIFFsetShortArrayExt(TIFF *tif, uint16_t **wpp, const uint16_t *wp,
- uint32_t n)
-{
- setByteArray(tif, (void **)wpp, wp, n, sizeof(uint16_t));
-}
-
-void _TIFFsetLongArray(uint32_t **lpp, const uint32_t *lp, uint32_t n)
-{
- setByteArray(NULL, (void **)lpp, lp, n, sizeof(uint32_t));
-}
-void _TIFFsetLongArrayExt(TIFF *tif, uint32_t **lpp, const uint32_t *lp,
- uint32_t n)
-{
- setByteArray(tif, (void **)lpp, lp, n, sizeof(uint32_t));
-}
-
-static void _TIFFsetLong8Array(TIFF *tif, uint64_t **lpp, const uint64_t *lp,
- uint32_t n)
-{
- setByteArray(tif, (void **)lpp, lp, n, sizeof(uint64_t));
-}
-
-void _TIFFsetFloatArray(float **fpp, const float *fp, uint32_t n)
-{
- setByteArray(NULL, (void **)fpp, fp, n, sizeof(float));
-}
-void _TIFFsetFloatArrayExt(TIFF *tif, float **fpp, const float *fp, uint32_t n)
-{
- setByteArray(tif, (void **)fpp, fp, n, sizeof(float));
-}
-
-void _TIFFsetDoubleArray(double **dpp, const double *dp, uint32_t n)
-{
- setByteArray(NULL, (void **)dpp, dp, n, sizeof(double));
-}
-void _TIFFsetDoubleArrayExt(TIFF *tif, double **dpp, const double *dp,
- uint32_t n)
-{
- setByteArray(tif, (void **)dpp, dp, n, sizeof(double));
-}
-
-static void setDoubleArrayOneValue(TIFF *tif, double **vpp, double value,
- size_t nmemb)
-{
- if (*vpp)
- _TIFFfreeExt(tif, *vpp);
- *vpp = _TIFFmallocExt(tif, nmemb * sizeof(double));
- if (*vpp)
- {
- while (nmemb--)
- ((double *)*vpp)[nmemb] = value;
- }
-}
-
-/*
- * Install extra samples information.
- */
-static int setExtraSamples(TIFF *tif, va_list ap, uint32_t *v)
-{
-/* XXX: Unassociated alpha data == 999 is a known Corel Draw bug, see below */
-#define EXTRASAMPLE_COREL_UNASSALPHA 999
-
- uint16_t *va;
- uint32_t i;
- TIFFDirectory *td = &tif->tif_dir;
- static const char module[] = "setExtraSamples";
-
- *v = (uint16_t)va_arg(ap, uint16_vap);
- if ((uint16_t)*v > td->td_samplesperpixel)
- return 0;
- va = va_arg(ap, uint16_t *);
- if (*v > 0 && va == NULL) /* typically missing param */
- return 0;
- for (i = 0; i < *v; i++)
- {
- if (va[i] > EXTRASAMPLE_UNASSALPHA)
- {
- /*
- * XXX: Corel Draw is known to produce incorrect
- * ExtraSamples tags which must be patched here if we
- * want to be able to open some of the damaged TIFF
- * files:
- */
- if (va[i] == EXTRASAMPLE_COREL_UNASSALPHA)
- va[i] = EXTRASAMPLE_UNASSALPHA;
- else
- return 0;
- }
- }
-
- if (td->td_transferfunction[0] != NULL &&
- (td->td_samplesperpixel - *v > 1) &&
- !(td->td_samplesperpixel - td->td_extrasamples > 1))
- {
- TIFFWarningExtR(tif, module,
- "ExtraSamples tag value is changing, "
- "but TransferFunction was read with a different value. "
- "Canceling it");
- TIFFClrFieldBit(tif, FIELD_TRANSFERFUNCTION);
- _TIFFfreeExt(tif, td->td_transferfunction[0]);
- td->td_transferfunction[0] = NULL;
- }
-
- td->td_extrasamples = (uint16_t)*v;
- _TIFFsetShortArrayExt(tif, &td->td_sampleinfo, va, td->td_extrasamples);
- return 1;
-
-#undef EXTRASAMPLE_COREL_UNASSALPHA
-}
-
-/*
- * Count ink names separated by \0. Returns
- * zero if the ink names are not as expected.
- */
-static uint16_t countInkNamesString(TIFF *tif, uint32_t slen, const char *s)
-{
- uint16_t i = 0;
-
- if (slen > 0)
- {
- const char *ep = s + slen;
- const char *cp = s;
- do
- {
- for (; cp < ep && *cp != '\0'; cp++)
- {
- }
- if (cp >= ep)
- goto bad;
- cp++; /* skip \0 */
- i++;
- } while (cp < ep);
- return (i);
- }
-bad:
- TIFFErrorExtR(tif, "TIFFSetField",
- "%s: Invalid InkNames value; no null at given buffer end "
- "location %" PRIu32 ", after %" PRIu16 " ink",
- tif->tif_name, slen, i);
- return (0);
-}
-
-static int _TIFFVSetField(TIFF *tif, uint32_t tag, va_list ap)
-{
- static const char module[] = "_TIFFVSetField";
-
- TIFFDirectory *td = &tif->tif_dir;
- int status = 1;
- uint32_t v32, v;
- double dblval;
- char *s;
- const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY);
- uint32_t standard_tag = tag;
- if (fip == NULL) /* cannot happen since OkToChangeTag() already checks it */
- return 0;
- /*
- * We want to force the custom code to be used for custom
- * fields even if the tag happens to match a well known
- * one - important for reinterpreted handling of standard
- * tag values in custom directories (i.e. EXIF)
- */
- if (fip->field_bit == FIELD_CUSTOM)
- {
- standard_tag = 0;
- }
-
- switch (standard_tag)
- {
- case TIFFTAG_SUBFILETYPE:
- td->td_subfiletype = (uint32_t)va_arg(ap, uint32_t);
- break;
- case TIFFTAG_IMAGEWIDTH:
- td->td_imagewidth = (uint32_t)va_arg(ap, uint32_t);
- break;
- case TIFFTAG_IMAGELENGTH:
- td->td_imagelength = (uint32_t)va_arg(ap, uint32_t);
- break;
- case TIFFTAG_BITSPERSAMPLE:
- td->td_bitspersample = (uint16_t)va_arg(ap, uint16_vap);
- /*
- * If the data require post-decoding processing to byte-swap
- * samples, set it up here. Note that since tags are required
- * to be ordered, compression code can override this behavior
- * in the setup method if it wants to roll the post decoding
- * work in with its normal work.
- */
- if (tif->tif_flags & TIFF_SWAB)
- {
- if (td->td_bitspersample == 8)
- tif->tif_postdecode = _TIFFNoPostDecode;
- else if (td->td_bitspersample == 16)
- tif->tif_postdecode = _TIFFSwab16BitData;
- else if (td->td_bitspersample == 24)
- tif->tif_postdecode = _TIFFSwab24BitData;
- else if (td->td_bitspersample == 32)
- tif->tif_postdecode = _TIFFSwab32BitData;
- else if (td->td_bitspersample == 64)
- tif->tif_postdecode = _TIFFSwab64BitData;
- else if (td->td_bitspersample == 128) /* two 64's */
- tif->tif_postdecode = _TIFFSwab64BitData;
- }
- break;
- case TIFFTAG_COMPRESSION:
- v = (uint16_t)va_arg(ap, uint16_vap);
- /*
- * If we're changing the compression scheme, notify the
- * previous module so that it can cleanup any state it's
- * setup.
- */
- if (TIFFFieldSet(tif, FIELD_COMPRESSION))
- {
- if ((uint32_t)td->td_compression == v)
- break;
- (*tif->tif_cleanup)(tif);
- tif->tif_flags &= ~TIFF_CODERSETUP;
- }
- /*
- * Setup new compression routine state.
- */
- if ((status = TIFFSetCompressionScheme(tif, v)) != 0)
- td->td_compression = (uint16_t)v;
- else
- status = 0;
- break;
- case TIFFTAG_PHOTOMETRIC:
- td->td_photometric = (uint16_t)va_arg(ap, uint16_vap);
- break;
- case TIFFTAG_THRESHHOLDING:
- td->td_threshholding = (uint16_t)va_arg(ap, uint16_vap);
- break;
- case TIFFTAG_FILLORDER:
- v = (uint16_t)va_arg(ap, uint16_vap);
- if (v != FILLORDER_LSB2MSB && v != FILLORDER_MSB2LSB)
- goto badvalue;
- td->td_fillorder = (uint16_t)v;
- break;
- case TIFFTAG_ORIENTATION:
- v = (uint16_t)va_arg(ap, uint16_vap);
- if (v < ORIENTATION_TOPLEFT || ORIENTATION_LEFTBOT < v)
- goto badvalue;
- else
- td->td_orientation = (uint16_t)v;
- break;
- case TIFFTAG_SAMPLESPERPIXEL:
- v = (uint16_t)va_arg(ap, uint16_vap);
- if (v == 0)
- goto badvalue;
- if (v != td->td_samplesperpixel)
- {
- /* See http://bugzilla.maptools.org/show_bug.cgi?id=2500 */
- if (td->td_sminsamplevalue != NULL)
- {
- TIFFWarningExtR(tif, module,
- "SamplesPerPixel tag value is changing, "
- "but SMinSampleValue tag was read with a "
- "different value. Canceling it");
- TIFFClrFieldBit(tif, FIELD_SMINSAMPLEVALUE);
- _TIFFfreeExt(tif, td->td_sminsamplevalue);
- td->td_sminsamplevalue = NULL;
- }
- if (td->td_smaxsamplevalue != NULL)
- {
- TIFFWarningExtR(tif, module,
- "SamplesPerPixel tag value is changing, "
- "but SMaxSampleValue tag was read with a "
- "different value. Canceling it");
- TIFFClrFieldBit(tif, FIELD_SMAXSAMPLEVALUE);
- _TIFFfreeExt(tif, td->td_smaxsamplevalue);
- td->td_smaxsamplevalue = NULL;
- }
- /* Test if 3 transfer functions instead of just one are now
- needed See http://bugzilla.maptools.org/show_bug.cgi?id=2820
- */
- if (td->td_transferfunction[0] != NULL &&
- (v - td->td_extrasamples > 1) &&
- !(td->td_samplesperpixel - td->td_extrasamples > 1))
- {
- TIFFWarningExtR(tif, module,
- "SamplesPerPixel tag value is changing, "
- "but TransferFunction was read with a "
- "different value. Canceling it");
- TIFFClrFieldBit(tif, FIELD_TRANSFERFUNCTION);
- _TIFFfreeExt(tif, td->td_transferfunction[0]);
- td->td_transferfunction[0] = NULL;
- }
- }
- td->td_samplesperpixel = (uint16_t)v;
- break;
- case TIFFTAG_ROWSPERSTRIP:
- v32 = (uint32_t)va_arg(ap, uint32_t);
- if (v32 == 0)
- goto badvalue32;
- td->td_rowsperstrip = v32;
- if (!TIFFFieldSet(tif, FIELD_TILEDIMENSIONS))
- {
- td->td_tilelength = v32;
- td->td_tilewidth = td->td_imagewidth;
- }
- break;
- case TIFFTAG_MINSAMPLEVALUE:
- td->td_minsamplevalue = (uint16_t)va_arg(ap, uint16_vap);
- break;
- case TIFFTAG_MAXSAMPLEVALUE:
- td->td_maxsamplevalue = (uint16_t)va_arg(ap, uint16_vap);
- break;
- case TIFFTAG_SMINSAMPLEVALUE:
- if (tif->tif_flags & TIFF_PERSAMPLE)
- _TIFFsetDoubleArrayExt(tif, &td->td_sminsamplevalue,
- va_arg(ap, double *),
- td->td_samplesperpixel);
- else
- setDoubleArrayOneValue(tif, &td->td_sminsamplevalue,
- va_arg(ap, double),
- td->td_samplesperpixel);
- break;
- case TIFFTAG_SMAXSAMPLEVALUE:
- if (tif->tif_flags & TIFF_PERSAMPLE)
- _TIFFsetDoubleArrayExt(tif, &td->td_smaxsamplevalue,
- va_arg(ap, double *),
- td->td_samplesperpixel);
- else
- setDoubleArrayOneValue(tif, &td->td_smaxsamplevalue,
- va_arg(ap, double),
- td->td_samplesperpixel);
- break;
- case TIFFTAG_XRESOLUTION:
- dblval = va_arg(ap, double);
- if (dblval != dblval || dblval < 0)
- goto badvaluedouble;
- td->td_xresolution = _TIFFClampDoubleToFloat(dblval);
- break;
- case TIFFTAG_YRESOLUTION:
- dblval = va_arg(ap, double);
- if (dblval != dblval || dblval < 0)
- goto badvaluedouble;
- td->td_yresolution = _TIFFClampDoubleToFloat(dblval);
- break;
- case TIFFTAG_PLANARCONFIG:
- v = (uint16_t)va_arg(ap, uint16_vap);
- if (v != PLANARCONFIG_CONTIG && v != PLANARCONFIG_SEPARATE)
- goto badvalue;
- td->td_planarconfig = (uint16_t)v;
- break;
- case TIFFTAG_XPOSITION:
- td->td_xposition = _TIFFClampDoubleToFloat(va_arg(ap, double));
- break;
- case TIFFTAG_YPOSITION:
- td->td_yposition = _TIFFClampDoubleToFloat(va_arg(ap, double));
- break;
- case TIFFTAG_RESOLUTIONUNIT:
- v = (uint16_t)va_arg(ap, uint16_vap);
- if (v < RESUNIT_NONE || RESUNIT_CENTIMETER < v)
- goto badvalue;
- td->td_resolutionunit = (uint16_t)v;
- break;
- case TIFFTAG_PAGENUMBER:
- td->td_pagenumber[0] = (uint16_t)va_arg(ap, uint16_vap);
- td->td_pagenumber[1] = (uint16_t)va_arg(ap, uint16_vap);
- break;
- case TIFFTAG_HALFTONEHINTS:
- td->td_halftonehints[0] = (uint16_t)va_arg(ap, uint16_vap);
- td->td_halftonehints[1] = (uint16_t)va_arg(ap, uint16_vap);
- break;
- case TIFFTAG_COLORMAP:
- v32 = (uint32_t)(1L << td->td_bitspersample);
- _TIFFsetShortArrayExt(tif, &td->td_colormap[0],
- va_arg(ap, uint16_t *), v32);
- _TIFFsetShortArrayExt(tif, &td->td_colormap[1],
- va_arg(ap, uint16_t *), v32);
- _TIFFsetShortArrayExt(tif, &td->td_colormap[2],
- va_arg(ap, uint16_t *), v32);
- break;
- case TIFFTAG_EXTRASAMPLES:
- if (!setExtraSamples(tif, ap, &v))
- goto badvalue;
- break;
- case TIFFTAG_MATTEING:
- td->td_extrasamples = (((uint16_t)va_arg(ap, uint16_vap)) != 0);
- if (td->td_extrasamples)
- {
- uint16_t sv = EXTRASAMPLE_ASSOCALPHA;
- _TIFFsetShortArrayExt(tif, &td->td_sampleinfo, &sv, 1);
- }
- break;
- case TIFFTAG_TILEWIDTH:
- v32 = (uint32_t)va_arg(ap, uint32_t);
- if (v32 % 16)
- {
- if (tif->tif_mode != O_RDONLY)
- goto badvalue32;
- TIFFWarningExtR(
- tif, tif->tif_name,
- "Nonstandard tile width %" PRIu32 ", convert file", v32);
- }
- td->td_tilewidth = v32;
- tif->tif_flags |= TIFF_ISTILED;
- break;
- case TIFFTAG_TILELENGTH:
- v32 = (uint32_t)va_arg(ap, uint32_t);
- if (v32 % 16)
- {
- if (tif->tif_mode != O_RDONLY)
- goto badvalue32;
- TIFFWarningExtR(
- tif, tif->tif_name,
- "Nonstandard tile length %" PRIu32 ", convert file", v32);
- }
- td->td_tilelength = v32;
- tif->tif_flags |= TIFF_ISTILED;
- break;
- case TIFFTAG_TILEDEPTH:
- v32 = (uint32_t)va_arg(ap, uint32_t);
- if (v32 == 0)
- goto badvalue32;
- td->td_tiledepth = v32;
- break;
- case TIFFTAG_DATATYPE:
- v = (uint16_t)va_arg(ap, uint16_vap);
- switch (v)
- {
- case DATATYPE_VOID:
- v = SAMPLEFORMAT_VOID;
- break;
- case DATATYPE_INT:
- v = SAMPLEFORMAT_INT;
- break;
- case DATATYPE_UINT:
- v = SAMPLEFORMAT_UINT;
- break;
- case DATATYPE_IEEEFP:
- v = SAMPLEFORMAT_IEEEFP;
- break;
- default:
- goto badvalue;
- }
- td->td_sampleformat = (uint16_t)v;
- break;
- case TIFFTAG_SAMPLEFORMAT:
- v = (uint16_t)va_arg(ap, uint16_vap);
- if (v < SAMPLEFORMAT_UINT || SAMPLEFORMAT_COMPLEXIEEEFP < v)
- goto badvalue;
- td->td_sampleformat = (uint16_t)v;
-
- /* Try to fix up the SWAB function for complex data. */
- if (td->td_sampleformat == SAMPLEFORMAT_COMPLEXINT &&
- td->td_bitspersample == 32 &&
- tif->tif_postdecode == _TIFFSwab32BitData)
- tif->tif_postdecode = _TIFFSwab16BitData;
- else if ((td->td_sampleformat == SAMPLEFORMAT_COMPLEXINT ||
- td->td_sampleformat == SAMPLEFORMAT_COMPLEXIEEEFP) &&
- td->td_bitspersample == 64 &&
- tif->tif_postdecode == _TIFFSwab64BitData)
- tif->tif_postdecode = _TIFFSwab32BitData;
- break;
- case TIFFTAG_IMAGEDEPTH:
- td->td_imagedepth = (uint32_t)va_arg(ap, uint32_t);
- break;
- case TIFFTAG_SUBIFD:
- if ((tif->tif_flags & TIFF_INSUBIFD) == 0)
- {
- td->td_nsubifd = (uint16_t)va_arg(ap, uint16_vap);
- _TIFFsetLong8Array(tif, &td->td_subifd,
- (uint64_t *)va_arg(ap, uint64_t *),
- (uint32_t)td->td_nsubifd);
- }
- else
- {
- TIFFErrorExtR(tif, module, "%s: Sorry, cannot nest SubIFDs",
- tif->tif_name);
- status = 0;
- }
- break;
- case TIFFTAG_YCBCRPOSITIONING:
- td->td_ycbcrpositioning = (uint16_t)va_arg(ap, uint16_vap);
- break;
- case TIFFTAG_YCBCRSUBSAMPLING:
- td->td_ycbcrsubsampling[0] = (uint16_t)va_arg(ap, uint16_vap);
- td->td_ycbcrsubsampling[1] = (uint16_t)va_arg(ap, uint16_vap);
- break;
- case TIFFTAG_TRANSFERFUNCTION:
- {
- uint32_t i;
- v = (td->td_samplesperpixel - td->td_extrasamples) > 1 ? 3 : 1;
- for (i = 0; i < v; i++)
- _TIFFsetShortArrayExt(tif, &td->td_transferfunction[i],
- va_arg(ap, uint16_t *),
- 1U << td->td_bitspersample);
- break;
- }
- case TIFFTAG_REFERENCEBLACKWHITE:
- /* XXX should check for null range */
- _TIFFsetFloatArrayExt(tif, &td->td_refblackwhite,
- va_arg(ap, float *), 6);
- break;
- case TIFFTAG_INKNAMES:
- {
- v = (uint16_t)va_arg(ap, uint16_vap);
- s = va_arg(ap, char *);
- uint16_t ninksinstring;
- ninksinstring = countInkNamesString(tif, v, s);
- status = ninksinstring > 0;
- if (ninksinstring > 0)
- {
- _TIFFsetNString(tif, &td->td_inknames, s, v);
- td->td_inknameslen = v;
- /* Set NumberOfInks to the value ninksinstring */
- if (TIFFFieldSet(tif, FIELD_NUMBEROFINKS))
- {
- if (td->td_numberofinks != ninksinstring)
- {
- TIFFErrorExtR(
- tif, module,
- "Warning %s; Tag %s:\n Value %" PRIu16
- " of NumberOfInks is different from the number of "
- "inks %" PRIu16
- ".\n -> NumberOfInks value adapted to %" PRIu16 "",
- tif->tif_name, fip->field_name, td->td_numberofinks,
- ninksinstring, ninksinstring);
- td->td_numberofinks = ninksinstring;
- }
- }
- else
- {
- td->td_numberofinks = ninksinstring;
- TIFFSetFieldBit(tif, FIELD_NUMBEROFINKS);
- }
- if (TIFFFieldSet(tif, FIELD_SAMPLESPERPIXEL))
- {
- if (td->td_numberofinks != td->td_samplesperpixel)
- {
- TIFFErrorExtR(tif, module,
- "Warning %s; Tag %s:\n Value %" PRIu16
- " of NumberOfInks is different from the "
- "SamplesPerPixel value %" PRIu16 "",
- tif->tif_name, fip->field_name,
- td->td_numberofinks,
- td->td_samplesperpixel);
- }
- }
- }
- }
- break;
- case TIFFTAG_NUMBEROFINKS:
- v = (uint16_t)va_arg(ap, uint16_vap);
- /* If InkNames already set also NumberOfInks is set accordingly and
- * should be equal */
- if (TIFFFieldSet(tif, FIELD_INKNAMES))
- {
- if (v != td->td_numberofinks)
- {
- TIFFErrorExtR(
- tif, module,
- "Error %s; Tag %s:\n It is not possible to set the "
- "value %" PRIu32
- " for NumberOfInks\n which is different from the "
- "number of inks in the InkNames tag (%" PRIu16 ")",
- tif->tif_name, fip->field_name, v, td->td_numberofinks);
- /* Do not set / overwrite number of inks already set by
- * InkNames case accordingly. */
- status = 0;
- }
- }
- else
- {
- td->td_numberofinks = (uint16_t)v;
- if (TIFFFieldSet(tif, FIELD_SAMPLESPERPIXEL))
- {
- if (td->td_numberofinks != td->td_samplesperpixel)
- {
- TIFFErrorExtR(tif, module,
- "Warning %s; Tag %s:\n Value %" PRIu32
- " of NumberOfInks is different from the "
- "SamplesPerPixel value %" PRIu16 "",
- tif->tif_name, fip->field_name, v,
- td->td_samplesperpixel);
- }
- }
- }
- break;
- case TIFFTAG_PERSAMPLE:
- v = (uint16_t)va_arg(ap, uint16_vap);
- if (v == PERSAMPLE_MULTI)
- tif->tif_flags |= TIFF_PERSAMPLE;
- else
- tif->tif_flags &= ~TIFF_PERSAMPLE;
- break;
- default:
- {
- TIFFTagValue *tv;
- int tv_size, iCustom;
-
- /*
- * This can happen if multiple images are open with different
- * codecs which have private tags. The global tag information
- * table may then have tags that are valid for one file but not
- * the other. If the client tries to set a tag that is not valid
- * for the image's codec then we'll arrive here. This
- * happens, for example, when tiffcp is used to convert between
- * compression schemes and codec-specific tags are blindly copied.
- *
- * This also happens when a FIELD_IGNORE tag is written.
- */
- if (fip->field_bit == FIELD_IGNORE)
- {
- TIFFErrorExtR(
- tif, module,
- "%s: Ignored %stag \"%s\" (not supported by libtiff)",
- tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "",
- fip->field_name);
- status = 0;
- break;
- }
- if (fip->field_bit != FIELD_CUSTOM)
- {
- TIFFErrorExtR(
- tif, module,
- "%s: Invalid %stag \"%s\" (not supported by codec)",
- tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "",
- fip->field_name);
- status = 0;
- break;
- }
-
- /*
- * Find the existing entry for this custom value.
- */
- tv = NULL;
- for (iCustom = 0; iCustom < td->td_customValueCount; iCustom++)
- {
- if (td->td_customValues[iCustom].info->field_tag == tag)
- {
- tv = td->td_customValues + iCustom;
- if (tv->value != NULL)
- {
- _TIFFfreeExt(tif, tv->value);
- tv->value = NULL;
- }
- break;
- }
- }
-
- /*
- * Grow the custom list if the entry was not found.
- */
- if (tv == NULL)
- {
- TIFFTagValue *new_customValues;
-
- td->td_customValueCount++;
- new_customValues = (TIFFTagValue *)_TIFFreallocExt(
- tif, td->td_customValues,
- sizeof(TIFFTagValue) * td->td_customValueCount);
- if (!new_customValues)
- {
- TIFFErrorExtR(tif, module,
- "%s: Failed to allocate space for list of "
- "custom values",
- tif->tif_name);
- status = 0;
- goto end;
- }
-
- td->td_customValues = new_customValues;
-
- tv = td->td_customValues + (td->td_customValueCount - 1);
- tv->info = fip;
- tv->value = NULL;
- tv->count = 0;
- }
-
- /*
- * Set custom value ... save a copy of the custom tag value.
- */
- /*--: Rational2Double: For Rationals evaluate "set_field_type" to
- * determine internal storage size. */
- tv_size = TIFFFieldSetGetSize(fip);
- if (tv_size == 0)
- {
- status = 0;
- TIFFErrorExtR(tif, module, "%s: Bad field type %d for \"%s\"",
- tif->tif_name, fip->field_type, fip->field_name);
- goto end;
- }
-
- if (fip->field_type == TIFF_ASCII)
- {
- uint32_t ma;
- const char *mb;
- if (fip->field_passcount)
- {
- assert(fip->field_writecount == TIFF_VARIABLE2);
- ma = (uint32_t)va_arg(ap, uint32_t);
- mb = (const char *)va_arg(ap, const char *);
- }
- else
- {
- mb = (const char *)va_arg(ap, const char *);
- size_t len = strlen(mb) + 1;
- if (len >= 0x80000000U)
- {
- status = 0;
- TIFFErrorExtR(tif, module,
- "%s: Too long string value for \"%s\". "
- "Maximum supported is 2147483647 bytes",
- tif->tif_name, fip->field_name);
- goto end;
- }
- ma = (uint32_t)len;
- }
- tv->count = ma;
- setByteArray(tif, &tv->value, mb, ma, 1);
- }
- else
- {
- if (fip->field_passcount)
- {
- if (fip->field_writecount == TIFF_VARIABLE2)
- tv->count = (uint32_t)va_arg(ap, uint32_t);
- else
- tv->count = (int)va_arg(ap, int);
- }
- else if (fip->field_writecount == TIFF_VARIABLE ||
- fip->field_writecount == TIFF_VARIABLE2)
- tv->count = 1;
- else if (fip->field_writecount == TIFF_SPP)
- tv->count = td->td_samplesperpixel;
- else
- tv->count = fip->field_writecount;
-
- if (tv->count == 0)
- {
- status = 0;
- TIFFWarningExtR(tif, module,
- "%s: Null count for \"%s\" (type "
- "%d, writecount %d, passcount %d)",
- tif->tif_name, fip->field_name,
- fip->field_type, fip->field_writecount,
- fip->field_passcount);
- goto end;
- }
-
- tv->value = _TIFFCheckMalloc(tif, tv->count, tv_size,
- "custom tag binary object");
- if (!tv->value)
- {
- status = 0;
- goto end;
- }
-
- if (fip->field_tag == TIFFTAG_DOTRANGE &&
- strcmp(fip->field_name, "DotRange") == 0)
- {
- /* TODO: This is an evil exception and should not have been
- handled this way ... likely best if we move it into
- the directory structure with an explicit field in
- libtiff 4.1 and assign it a FIELD_ value */
- uint16_t v2[2];
- v2[0] = (uint16_t)va_arg(ap, int);
- v2[1] = (uint16_t)va_arg(ap, int);
- _TIFFmemcpy(tv->value, &v2, 4);
- }
-
- else if (fip->field_passcount ||
- fip->field_writecount == TIFF_VARIABLE ||
- fip->field_writecount == TIFF_VARIABLE2 ||
- fip->field_writecount == TIFF_SPP || tv->count > 1)
- {
- /*--: Rational2Double: For Rationals tv_size is set above to
- * 4 or 8 according to fip->set_field_type! */
- _TIFFmemcpy(tv->value, va_arg(ap, void *),
- tv->count * tv_size);
- /* Test here for too big values for LONG8, SLONG8 in
- * ClassicTIFF and delete custom field from custom list */
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- {
- if (tv->info->field_type == TIFF_LONG8)
- {
- uint64_t *pui64 = (uint64_t *)tv->value;
- for (int i = 0; i < tv->count; i++)
- {
- if (pui64[i] > 0xffffffffu)
- {
- TIFFErrorExtR(
- tif, module,
- "%s: Bad LONG8 value %" PRIu64
- " at %d. array position for \"%s\" tag "
- "%d in ClassicTIFF. Tag won't be "
- "written to file",
- tif->tif_name, pui64[i], i,
- fip->field_name, tag);
- goto badvalueifd8long8;
- }
- }
- }
- else if (tv->info->field_type == TIFF_SLONG8)
- {
- int64_t *pi64 = (int64_t *)tv->value;
- for (int i = 0; i < tv->count; i++)
- {
- if (pi64[i] > 2147483647 ||
- pi64[i] < (-2147483647 - 1))
- {
- TIFFErrorExtR(
- tif, module,
- "%s: Bad SLONG8 value %" PRIi64
- " at %d. array position for \"%s\" tag "
- "%d in ClassicTIFF. Tag won't be "
- "written to file",
- tif->tif_name, pi64[i], i,
- fip->field_name, tag);
- goto badvalueifd8long8;
- }
- }
- }
- }
- }
- else
- {
- char *val = (char *)tv->value;
- assert(tv->count == 1);
-
- switch (fip->field_type)
- {
- case TIFF_BYTE:
- case TIFF_UNDEFINED:
- {
- uint8_t v2 = (uint8_t)va_arg(ap, int);
- _TIFFmemcpy(val, &v2, tv_size);
- }
- break;
- case TIFF_SBYTE:
- {
- int8_t v2 = (int8_t)va_arg(ap, int);
- _TIFFmemcpy(val, &v2, tv_size);
- }
- break;
- case TIFF_SHORT:
- {
- uint16_t v2 = (uint16_t)va_arg(ap, int);
- _TIFFmemcpy(val, &v2, tv_size);
- }
- break;
- case TIFF_SSHORT:
- {
- int16_t v2 = (int16_t)va_arg(ap, int);
- _TIFFmemcpy(val, &v2, tv_size);
- }
- break;
- case TIFF_LONG:
- case TIFF_IFD:
- {
- uint32_t v2 = va_arg(ap, uint32_t);
- _TIFFmemcpy(val, &v2, tv_size);
- }
- break;
- case TIFF_SLONG:
- {
- int32_t v2 = va_arg(ap, int32_t);
- _TIFFmemcpy(val, &v2, tv_size);
- }
- break;
- case TIFF_LONG8:
- case TIFF_IFD8:
- {
- uint64_t v2 = va_arg(ap, uint64_t);
- _TIFFmemcpy(val, &v2, tv_size);
- /* Test here for too big values for ClassicTIFF and
- * delete custom field from custom list */
- if (!(tif->tif_flags & TIFF_BIGTIFF) &&
- (v2 > 0xffffffffu))
- {
- TIFFErrorExtR(
- tif, module,
- "%s: Bad LONG8 or IFD8 value %" PRIu64
- " for \"%s\" tag %d in ClassicTIFF. Tag "
- "won't be written to file",
- tif->tif_name, v2, fip->field_name, tag);
- goto badvalueifd8long8;
- }
- }
- break;
- case TIFF_SLONG8:
- {
- int64_t v2 = va_arg(ap, int64_t);
- _TIFFmemcpy(val, &v2, tv_size);
- /* Test here for too big values for ClassicTIFF and
- * delete custom field from custom list */
- if (!(tif->tif_flags & TIFF_BIGTIFF) &&
- ((v2 > 2147483647) || (v2 < (-2147483647 - 1))))
- {
- TIFFErrorExtR(
- tif, module,
- "%s: Bad SLONG8 value %" PRIi64
- " for \"%s\" tag %d in ClassicTIFF. Tag "
- "won't be written to file",
- tif->tif_name, v2, fip->field_name, tag);
- goto badvalueifd8long8;
- }
- }
- break;
- case TIFF_RATIONAL:
- case TIFF_SRATIONAL:
- /*-- Rational2Double: For Rationals tv_size is set
- * above to 4 or 8 according to fip->set_field_type!
- */
- {
- if (tv_size == 8)
- {
- double v2 = va_arg(ap, double);
- _TIFFmemcpy(val, &v2, tv_size);
- }
- else
- {
- /*-- default should be tv_size == 4 */
- float v3 = (float)va_arg(ap, double);
- _TIFFmemcpy(val, &v3, tv_size);
- /*-- ToDo: After Testing, this should be
- * removed and tv_size==4 should be set as
- * default. */
- if (tv_size != 4)
- {
- TIFFErrorExtR(
- tif, module,
- "Rational2Double: .set_field_type "
- "in not 4 but %d",
- tv_size);
- }
- }
- }
- break;
- case TIFF_FLOAT:
- {
- float v2 =
- _TIFFClampDoubleToFloat(va_arg(ap, double));
- _TIFFmemcpy(val, &v2, tv_size);
- }
- break;
- case TIFF_DOUBLE:
- {
- double v2 = va_arg(ap, double);
- _TIFFmemcpy(val, &v2, tv_size);
- }
- break;
- default:
- _TIFFmemset(val, 0, tv_size);
- status = 0;
- break;
- }
- }
- }
- }
- }
- if (status)
- {
- const TIFFField *fip2 = TIFFFieldWithTag(tif, tag);
- if (fip2)
- TIFFSetFieldBit(tif, fip2->field_bit);
- tif->tif_flags |= TIFF_DIRTYDIRECT;
- }
-
-end:
- va_end(ap);
- return (status);
-badvalue:
-{
- const TIFFField *fip2 = TIFFFieldWithTag(tif, tag);
- TIFFErrorExtR(tif, module, "%s: Bad value %" PRIu32 " for \"%s\" tag",
- tif->tif_name, v, fip2 ? fip2->field_name : "Unknown");
- va_end(ap);
-}
- return (0);
-badvalue32:
-{
- const TIFFField *fip2 = TIFFFieldWithTag(tif, tag);
- TIFFErrorExtR(tif, module, "%s: Bad value %" PRIu32 " for \"%s\" tag",
- tif->tif_name, v32, fip2 ? fip2->field_name : "Unknown");
- va_end(ap);
-}
- return (0);
-badvaluedouble:
-{
- const TIFFField *fip2 = TIFFFieldWithTag(tif, tag);
- TIFFErrorExtR(tif, module, "%s: Bad value %f for \"%s\" tag", tif->tif_name,
- dblval, fip2 ? fip2->field_name : "Unknown");
- va_end(ap);
-}
- return (0);
-badvalueifd8long8:
-{
- /* Error message issued already above. */
- TIFFTagValue *tv2 = NULL;
- int iCustom2, iC2;
- /* Find the existing entry for this custom value. */
- for (iCustom2 = 0; iCustom2 < td->td_customValueCount; iCustom2++)
- {
- if (td->td_customValues[iCustom2].info->field_tag == tag)
- {
- tv2 = td->td_customValues + (iCustom2);
- break;
- }
- }
- if (tv2 != NULL)
- {
- /* Remove custom field from custom list */
- if (tv2->value != NULL)
- {
- _TIFFfreeExt(tif, tv2->value);
- tv2->value = NULL;
- }
- /* Shorten list and close gap in customValues list.
- * Re-allocation of td_customValues not necessary here. */
- td->td_customValueCount--;
- for (iC2 = iCustom2; iC2 < td->td_customValueCount; iC2++)
- {
- td->td_customValues[iC2] = td->td_customValues[iC2 + 1];
- }
- }
- else
- {
- assert(0);
- }
- va_end(ap);
-}
- return (0);
-} /*-- _TIFFVSetField() --*/
-
-/*
- * Return 1/0 according to whether or not
- * it is permissible to set the tag's value.
- * Note that we allow ImageLength to be changed
- * so that we can append and extend to images.
- * Any other tag may not be altered once writing
- * has commenced, unless its value has no effect
- * on the format of the data that is written.
- */
-static int OkToChangeTag(TIFF *tif, uint32_t tag)
-{
- const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY);
- if (!fip)
- { /* unknown tag */
- TIFFErrorExtR(tif, "TIFFSetField", "%s: Unknown %stag %" PRIu32,
- tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "", tag);
- return (0);
- }
- if (tag != TIFFTAG_IMAGELENGTH && (tif->tif_flags & TIFF_BEENWRITING) &&
- !fip->field_oktochange)
- {
- /*
- * Consult info table to see if tag can be changed
- * after we've started writing. We only allow changes
- * to those tags that don't/shouldn't affect the
- * compression and/or format of the data.
- */
- TIFFErrorExtR(tif, "TIFFSetField",
- "%s: Cannot modify tag \"%s\" while writing",
- tif->tif_name, fip->field_name);
- return (0);
- }
- return (1);
-}
-
-/*
- * Record the value of a field in the
- * internal directory structure. The
- * field will be written to the file
- * when/if the directory structure is
- * updated.
- */
-int TIFFSetField(TIFF *tif, uint32_t tag, ...)
-{
- va_list ap;
- int status;
-
- va_start(ap, tag);
- status = TIFFVSetField(tif, tag, ap);
- va_end(ap);
- return (status);
-}
-
-/*
- * Clear the contents of the field in the internal structure.
- */
-int TIFFUnsetField(TIFF *tif, uint32_t tag)
-{
- const TIFFField *fip = TIFFFieldWithTag(tif, tag);
- TIFFDirectory *td = &tif->tif_dir;
-
- if (!fip)
- return 0;
-
- if (fip->field_bit != FIELD_CUSTOM)
- TIFFClrFieldBit(tif, fip->field_bit);
- else
- {
- TIFFTagValue *tv = NULL;
- int i;
-
- for (i = 0; i < td->td_customValueCount; i++)
- {
-
- tv = td->td_customValues + i;
- if (tv->info->field_tag == tag)
- break;
- }
-
- if (i < td->td_customValueCount)
- {
- _TIFFfreeExt(tif, tv->value);
- for (; i < td->td_customValueCount - 1; i++)
- {
- td->td_customValues[i] = td->td_customValues[i + 1];
- }
- td->td_customValueCount--;
- }
- }
-
- tif->tif_flags |= TIFF_DIRTYDIRECT;
-
- return (1);
-}
-
-/*
- * Like TIFFSetField, but taking a varargs
- * parameter list. This routine is useful
- * for building higher-level interfaces on
- * top of the library.
- */
-int TIFFVSetField(TIFF *tif, uint32_t tag, va_list ap)
-{
- return OkToChangeTag(tif, tag)
- ? (*tif->tif_tagmethods.vsetfield)(tif, tag, ap)
- : 0;
-}
-
-static int _TIFFVGetField(TIFF *tif, uint32_t tag, va_list ap)
-{
- TIFFDirectory *td = &tif->tif_dir;
- int ret_val = 1;
- uint32_t standard_tag = tag;
- const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY);
- if (fip == NULL) /* cannot happen since TIFFGetField() already checks it */
- return 0;
-
- /*
- * We want to force the custom code to be used for custom
- * fields even if the tag happens to match a well known
- * one - important for reinterpreted handling of standard
- * tag values in custom directories (i.e. EXIF)
- */
- if (fip->field_bit == FIELD_CUSTOM)
- {
- standard_tag = 0;
- }
-
- switch (standard_tag)
- {
- case TIFFTAG_SUBFILETYPE:
- *va_arg(ap, uint32_t *) = td->td_subfiletype;
- break;
- case TIFFTAG_IMAGEWIDTH:
- *va_arg(ap, uint32_t *) = td->td_imagewidth;
- break;
- case TIFFTAG_IMAGELENGTH:
- *va_arg(ap, uint32_t *) = td->td_imagelength;
- break;
- case TIFFTAG_BITSPERSAMPLE:
- *va_arg(ap, uint16_t *) = td->td_bitspersample;
- break;
- case TIFFTAG_COMPRESSION:
- *va_arg(ap, uint16_t *) = td->td_compression;
- break;
- case TIFFTAG_PHOTOMETRIC:
- *va_arg(ap, uint16_t *) = td->td_photometric;
- break;
- case TIFFTAG_THRESHHOLDING:
- *va_arg(ap, uint16_t *) = td->td_threshholding;
- break;
- case TIFFTAG_FILLORDER:
- *va_arg(ap, uint16_t *) = td->td_fillorder;
- break;
- case TIFFTAG_ORIENTATION:
- *va_arg(ap, uint16_t *) = td->td_orientation;
- break;
- case TIFFTAG_SAMPLESPERPIXEL:
- *va_arg(ap, uint16_t *) = td->td_samplesperpixel;
- break;
- case TIFFTAG_ROWSPERSTRIP:
- *va_arg(ap, uint32_t *) = td->td_rowsperstrip;
- break;
- case TIFFTAG_MINSAMPLEVALUE:
- *va_arg(ap, uint16_t *) = td->td_minsamplevalue;
- break;
- case TIFFTAG_MAXSAMPLEVALUE:
- *va_arg(ap, uint16_t *) = td->td_maxsamplevalue;
- break;
- case TIFFTAG_SMINSAMPLEVALUE:
- if (tif->tif_flags & TIFF_PERSAMPLE)
- *va_arg(ap, double **) = td->td_sminsamplevalue;
- else
- {
- /* libtiff historically treats this as a single value. */
- uint16_t i;
- double v = td->td_sminsamplevalue[0];
- for (i = 1; i < td->td_samplesperpixel; ++i)
- if (td->td_sminsamplevalue[i] < v)
- v = td->td_sminsamplevalue[i];
- *va_arg(ap, double *) = v;
- }
- break;
- case TIFFTAG_SMAXSAMPLEVALUE:
- if (tif->tif_flags & TIFF_PERSAMPLE)
- *va_arg(ap, double **) = td->td_smaxsamplevalue;
- else
- {
- /* libtiff historically treats this as a single value. */
- uint16_t i;
- double v = td->td_smaxsamplevalue[0];
- for (i = 1; i < td->td_samplesperpixel; ++i)
- if (td->td_smaxsamplevalue[i] > v)
- v = td->td_smaxsamplevalue[i];
- *va_arg(ap, double *) = v;
- }
- break;
- case TIFFTAG_XRESOLUTION:
- *va_arg(ap, float *) = td->td_xresolution;
- break;
- case TIFFTAG_YRESOLUTION:
- *va_arg(ap, float *) = td->td_yresolution;
- break;
- case TIFFTAG_PLANARCONFIG:
- *va_arg(ap, uint16_t *) = td->td_planarconfig;
- break;
- case TIFFTAG_XPOSITION:
- *va_arg(ap, float *) = td->td_xposition;
- break;
- case TIFFTAG_YPOSITION:
- *va_arg(ap, float *) = td->td_yposition;
- break;
- case TIFFTAG_RESOLUTIONUNIT:
- *va_arg(ap, uint16_t *) = td->td_resolutionunit;
- break;
- case TIFFTAG_PAGENUMBER:
- *va_arg(ap, uint16_t *) = td->td_pagenumber[0];
- *va_arg(ap, uint16_t *) = td->td_pagenumber[1];
- break;
- case TIFFTAG_HALFTONEHINTS:
- *va_arg(ap, uint16_t *) = td->td_halftonehints[0];
- *va_arg(ap, uint16_t *) = td->td_halftonehints[1];
- break;
- case TIFFTAG_COLORMAP:
- *va_arg(ap, const uint16_t **) = td->td_colormap[0];
- *va_arg(ap, const uint16_t **) = td->td_colormap[1];
- *va_arg(ap, const uint16_t **) = td->td_colormap[2];
- break;
- case TIFFTAG_STRIPOFFSETS:
- case TIFFTAG_TILEOFFSETS:
- _TIFFFillStriles(tif);
- *va_arg(ap, const uint64_t **) = td->td_stripoffset_p;
- if (td->td_stripoffset_p == NULL)
- ret_val = 0;
- break;
- case TIFFTAG_STRIPBYTECOUNTS:
- case TIFFTAG_TILEBYTECOUNTS:
- _TIFFFillStriles(tif);
- *va_arg(ap, const uint64_t **) = td->td_stripbytecount_p;
- if (td->td_stripbytecount_p == NULL)
- ret_val = 0;
- break;
- case TIFFTAG_MATTEING:
- *va_arg(ap, uint16_t *) =
- (td->td_extrasamples == 1 &&
- td->td_sampleinfo[0] == EXTRASAMPLE_ASSOCALPHA);
- break;
- case TIFFTAG_EXTRASAMPLES:
- *va_arg(ap, uint16_t *) = td->td_extrasamples;
- *va_arg(ap, const uint16_t **) = td->td_sampleinfo;
- break;
- case TIFFTAG_TILEWIDTH:
- *va_arg(ap, uint32_t *) = td->td_tilewidth;
- break;
- case TIFFTAG_TILELENGTH:
- *va_arg(ap, uint32_t *) = td->td_tilelength;
- break;
- case TIFFTAG_TILEDEPTH:
- *va_arg(ap, uint32_t *) = td->td_tiledepth;
- break;
- case TIFFTAG_DATATYPE:
- switch (td->td_sampleformat)
- {
- case SAMPLEFORMAT_UINT:
- *va_arg(ap, uint16_t *) = DATATYPE_UINT;
- break;
- case SAMPLEFORMAT_INT:
- *va_arg(ap, uint16_t *) = DATATYPE_INT;
- break;
- case SAMPLEFORMAT_IEEEFP:
- *va_arg(ap, uint16_t *) = DATATYPE_IEEEFP;
- break;
- case SAMPLEFORMAT_VOID:
- *va_arg(ap, uint16_t *) = DATATYPE_VOID;
- break;
- }
- break;
- case TIFFTAG_SAMPLEFORMAT:
- *va_arg(ap, uint16_t *) = td->td_sampleformat;
- break;
- case TIFFTAG_IMAGEDEPTH:
- *va_arg(ap, uint32_t *) = td->td_imagedepth;
- break;
- case TIFFTAG_SUBIFD:
- *va_arg(ap, uint16_t *) = td->td_nsubifd;
- *va_arg(ap, const uint64_t **) = td->td_subifd;
- break;
- case TIFFTAG_YCBCRPOSITIONING:
- *va_arg(ap, uint16_t *) = td->td_ycbcrpositioning;
- break;
- case TIFFTAG_YCBCRSUBSAMPLING:
- *va_arg(ap, uint16_t *) = td->td_ycbcrsubsampling[0];
- *va_arg(ap, uint16_t *) = td->td_ycbcrsubsampling[1];
- break;
- case TIFFTAG_TRANSFERFUNCTION:
- *va_arg(ap, const uint16_t **) = td->td_transferfunction[0];
- if (td->td_samplesperpixel - td->td_extrasamples > 1)
- {
- *va_arg(ap, const uint16_t **) = td->td_transferfunction[1];
- *va_arg(ap, const uint16_t **) = td->td_transferfunction[2];
- }
- else
- {
- *va_arg(ap, const uint16_t **) = NULL;
- *va_arg(ap, const uint16_t **) = NULL;
- }
- break;
- case TIFFTAG_REFERENCEBLACKWHITE:
- *va_arg(ap, const float **) = td->td_refblackwhite;
- break;
- case TIFFTAG_INKNAMES:
- *va_arg(ap, const char **) = td->td_inknames;
- break;
- case TIFFTAG_NUMBEROFINKS:
- *va_arg(ap, uint16_t *) = td->td_numberofinks;
- break;
- default:
- {
- int i;
-
- /*
- * This can happen if multiple images are open
- * with different codecs which have private
- * tags. The global tag information table may
- * then have tags that are valid for one file
- * but not the other. If the client tries to
- * get a tag that is not valid for the image's
- * codec then we'll arrive here.
- */
- if (fip->field_bit != FIELD_CUSTOM)
- {
- TIFFErrorExtR(tif, "_TIFFVGetField",
- "%s: Invalid %stag \"%s\" "
- "(not supported by codec)",
- tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "",
- fip->field_name);
- ret_val = 0;
- break;
- }
-
- /*
- * Do we have a custom value?
- */
- ret_val = 0;
- for (i = 0; i < td->td_customValueCount; i++)
- {
- TIFFTagValue *tv = td->td_customValues + i;
-
- if (tv->info->field_tag != tag)
- continue;
-
- if (fip->field_passcount)
- {
- if (fip->field_readcount == TIFF_VARIABLE2)
- *va_arg(ap, uint32_t *) = (uint32_t)tv->count;
- else /* Assume TIFF_VARIABLE */
- *va_arg(ap, uint16_t *) = (uint16_t)tv->count;
- *va_arg(ap, const void **) = tv->value;
- ret_val = 1;
- }
- else if (fip->field_tag == TIFFTAG_DOTRANGE &&
- strcmp(fip->field_name, "DotRange") == 0)
- {
- /* TODO: This is an evil exception and should not have been
- handled this way ... likely best if we move it into
- the directory structure with an explicit field in
- libtiff 4.1 and assign it a FIELD_ value */
- *va_arg(ap, uint16_t *) = ((uint16_t *)tv->value)[0];
- *va_arg(ap, uint16_t *) = ((uint16_t *)tv->value)[1];
- ret_val = 1;
- }
- else
- {
- if (fip->field_type == TIFF_ASCII ||
- fip->field_readcount == TIFF_VARIABLE ||
- fip->field_readcount == TIFF_VARIABLE2 ||
- fip->field_readcount == TIFF_SPP || tv->count > 1)
- {
- *va_arg(ap, void **) = tv->value;
- ret_val = 1;
- }
- else
- {
- char *val = (char *)tv->value;
- assert(tv->count == 1);
- switch (fip->field_type)
- {
- case TIFF_BYTE:
- case TIFF_UNDEFINED:
- *va_arg(ap, uint8_t *) = *(uint8_t *)val;
- ret_val = 1;
- break;
- case TIFF_SBYTE:
- *va_arg(ap, int8_t *) = *(int8_t *)val;
- ret_val = 1;
- break;
- case TIFF_SHORT:
- *va_arg(ap, uint16_t *) = *(uint16_t *)val;
- ret_val = 1;
- break;
- case TIFF_SSHORT:
- *va_arg(ap, int16_t *) = *(int16_t *)val;
- ret_val = 1;
- break;
- case TIFF_LONG:
- case TIFF_IFD:
- *va_arg(ap, uint32_t *) = *(uint32_t *)val;
- ret_val = 1;
- break;
- case TIFF_SLONG:
- *va_arg(ap, int32_t *) = *(int32_t *)val;
- ret_val = 1;
- break;
- case TIFF_LONG8:
- case TIFF_IFD8:
- *va_arg(ap, uint64_t *) = *(uint64_t *)val;
- ret_val = 1;
- break;
- case TIFF_SLONG8:
- *va_arg(ap, int64_t *) = *(int64_t *)val;
- ret_val = 1;
- break;
- case TIFF_RATIONAL:
- case TIFF_SRATIONAL:
- {
- /*-- Rational2Double: For Rationals evaluate
- * "set_field_type" to determine internal
- * storage size and return value size. */
- int tv_size = TIFFFieldSetGetSize(fip);
- if (tv_size == 8)
- {
- *va_arg(ap, double *) = *(double *)val;
- ret_val = 1;
- }
- else
- {
- /*-- default should be tv_size == 4 */
- *va_arg(ap, float *) = *(float *)val;
- ret_val = 1;
- /*-- ToDo: After Testing, this should be
- * removed and tv_size==4 should be set as
- * default. */
- if (tv_size != 4)
- {
- TIFFErrorExtR(
- tif, "_TIFFVGetField",
- "Rational2Double: .set_field_type "
- "in not 4 but %d",
- tv_size);
- }
- }
- }
- break;
- case TIFF_FLOAT:
- *va_arg(ap, float *) = *(float *)val;
- ret_val = 1;
- break;
- case TIFF_DOUBLE:
- *va_arg(ap, double *) = *(double *)val;
- ret_val = 1;
- break;
- default:
- ret_val = 0;
- break;
- }
- }
- }
- break;
- }
- }
- }
- return (ret_val);
-}
-
-/*
- * Return the value of a field in the
- * internal directory structure.
- */
-int TIFFGetField(TIFF *tif, uint32_t tag, ...)
-{
- int status;
- va_list ap;
-
- va_start(ap, tag);
- status = TIFFVGetField(tif, tag, ap);
- va_end(ap);
- return (status);
-}
-
-/*
- * Like TIFFGetField, but taking a varargs
- * parameter list. This routine is useful
- * for building higher-level interfaces on
- * top of the library.
- */
-int TIFFVGetField(TIFF *tif, uint32_t tag, va_list ap)
-{
- const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY);
- return (fip && (isPseudoTag(tag) || TIFFFieldSet(tif, fip->field_bit))
- ? (*tif->tif_tagmethods.vgetfield)(tif, tag, ap)
- : 0);
-}
-
-#define CleanupField(member) \
- { \
- if (td->member) \
- { \
- _TIFFfreeExt(tif, td->member); \
- td->member = 0; \
- } \
- }
-
-/*
- * Release storage associated with a directory.
- */
-void TIFFFreeDirectory(TIFF *tif)
-{
- TIFFDirectory *td = &tif->tif_dir;
- int i;
-
- _TIFFmemset(td->td_fieldsset, 0, sizeof(td->td_fieldsset));
- CleanupField(td_sminsamplevalue);
- CleanupField(td_smaxsamplevalue);
- CleanupField(td_colormap[0]);
- CleanupField(td_colormap[1]);
- CleanupField(td_colormap[2]);
- CleanupField(td_sampleinfo);
- CleanupField(td_subifd);
- CleanupField(td_inknames);
- CleanupField(td_refblackwhite);
- CleanupField(td_transferfunction[0]);
- CleanupField(td_transferfunction[1]);
- CleanupField(td_transferfunction[2]);
- CleanupField(td_stripoffset_p);
- CleanupField(td_stripbytecount_p);
- td->td_stripoffsetbyteallocsize = 0;
- TIFFClrFieldBit(tif, FIELD_YCBCRSUBSAMPLING);
- TIFFClrFieldBit(tif, FIELD_YCBCRPOSITIONING);
-
- /* Cleanup custom tag values */
- for (i = 0; i < td->td_customValueCount; i++)
- {
- if (td->td_customValues[i].value)
- _TIFFfreeExt(tif, td->td_customValues[i].value);
- }
-
- td->td_customValueCount = 0;
- CleanupField(td_customValues);
-
- _TIFFmemset(&(td->td_stripoffset_entry), 0, sizeof(TIFFDirEntry));
- _TIFFmemset(&(td->td_stripbytecount_entry), 0, sizeof(TIFFDirEntry));
-
- /* Reset some internal parameters for IFD data size checking. */
- tif->tif_dir.td_dirdatasize_read = 0;
- tif->tif_dir.td_dirdatasize_write = 0;
- if (tif->tif_dir.td_dirdatasize_offsets != NULL)
- {
- _TIFFfreeExt(tif, tif->tif_dir.td_dirdatasize_offsets);
- tif->tif_dir.td_dirdatasize_offsets = NULL;
- tif->tif_dir.td_dirdatasize_Noffsets = 0;
- }
- tif->tif_dir.td_iswrittentofile = FALSE;
-}
-#undef CleanupField
-
-/*
- * Client Tag extension support (from Niles Ritter).
- */
-static TIFFExtendProc _TIFFextender = (TIFFExtendProc)NULL;
-
-TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc extender)
-{
- TIFFExtendProc prev = _TIFFextender;
- _TIFFextender = extender;
- return (prev);
-}
-
-/*
- * Setup for a new directory. Should we automatically call
- * TIFFWriteDirectory() if the current one is dirty?
- *
- * The newly created directory will not exist on the file till
- * TIFFWriteDirectory(), TIFFFlush() or TIFFClose() is called.
- */
-int TIFFCreateDirectory(TIFF *tif)
-{
- /* Free previously allocated memory and setup default values. */
- TIFFFreeDirectory(tif);
- TIFFDefaultDirectory(tif);
- tif->tif_diroff = 0;
- tif->tif_nextdiroff = 0;
- tif->tif_curoff = 0;
- tif->tif_row = (uint32_t)-1;
- tif->tif_curstrip = (uint32_t)-1;
- tif->tif_dir.td_iswrittentofile = FALSE;
-
- return 0;
-}
-
-int TIFFCreateCustomDirectory(TIFF *tif, const TIFFFieldArray *infoarray)
-{
- /* Free previously allocated memory and setup default values. */
- TIFFFreeDirectory(tif);
- TIFFDefaultDirectory(tif);
-
- /*
- * Reset the field definitions to match the application provided list.
- * Hopefully TIFFDefaultDirectory() won't have done anything irreversible
- * based on it's assumption this is an image directory.
- */
- _TIFFSetupFields(tif, infoarray);
-
- tif->tif_diroff = 0;
- tif->tif_nextdiroff = 0;
- tif->tif_curoff = 0;
- tif->tif_row = (uint32_t)-1;
- tif->tif_curstrip = (uint32_t)-1;
- /* invalidate directory index */
- tif->tif_curdir = TIFF_NON_EXISTENT_DIR_NUMBER;
- /* invalidate IFD loop lists */
- _TIFFCleanupIFDOffsetAndNumberMaps(tif);
- /* To be able to return from SubIFD or custom-IFD to main-IFD */
- tif->tif_setdirectory_force_absolute = TRUE;
-
- return 0;
-}
-
-int TIFFCreateEXIFDirectory(TIFF *tif)
-{
- const TIFFFieldArray *exifFieldArray;
- exifFieldArray = _TIFFGetExifFields();
- return TIFFCreateCustomDirectory(tif, exifFieldArray);
-}
-
-/*
- * Creates the EXIF GPS custom directory
- */
-int TIFFCreateGPSDirectory(TIFF *tif)
-{
- const TIFFFieldArray *gpsFieldArray;
- gpsFieldArray = _TIFFGetGpsFields();
- return TIFFCreateCustomDirectory(tif, gpsFieldArray);
-}
-
-/*
- * Setup a default directory structure.
- */
-int TIFFDefaultDirectory(TIFF *tif)
-{
- register TIFFDirectory *td = &tif->tif_dir;
- const TIFFFieldArray *tiffFieldArray;
-
- tiffFieldArray = _TIFFGetFields();
- _TIFFSetupFields(tif, tiffFieldArray);
-
- _TIFFmemset(td, 0, sizeof(*td));
- td->td_fillorder = FILLORDER_MSB2LSB;
- td->td_bitspersample = 1;
- td->td_threshholding = THRESHHOLD_BILEVEL;
- td->td_orientation = ORIENTATION_TOPLEFT;
- td->td_samplesperpixel = 1;
- td->td_rowsperstrip = (uint32_t)-1;
- td->td_tilewidth = 0;
- td->td_tilelength = 0;
- td->td_tiledepth = 1;
-#ifdef STRIPBYTECOUNTSORTED_UNUSED
- td->td_stripbytecountsorted = 1; /* Our own arrays always sorted. */
-#endif
- td->td_resolutionunit = RESUNIT_INCH;
- td->td_sampleformat = SAMPLEFORMAT_UINT;
- td->td_imagedepth = 1;
- td->td_ycbcrsubsampling[0] = 2;
- td->td_ycbcrsubsampling[1] = 2;
- td->td_ycbcrpositioning = YCBCRPOSITION_CENTERED;
- tif->tif_postdecode = _TIFFNoPostDecode;
- tif->tif_foundfield = NULL;
- tif->tif_tagmethods.vsetfield = _TIFFVSetField;
- tif->tif_tagmethods.vgetfield = _TIFFVGetField;
- tif->tif_tagmethods.printdir = NULL;
- /* additional default values */
- td->td_planarconfig = PLANARCONFIG_CONTIG;
- td->td_compression = COMPRESSION_NONE;
- td->td_subfiletype = 0;
- td->td_minsamplevalue = 0;
- /* td_bitspersample=1 is always set in TIFFDefaultDirectory().
- * Therefore, td_maxsamplevalue has to be re-calculated in
- * TIFFGetFieldDefaulted(). */
- td->td_maxsamplevalue = 1; /* Default for td_bitspersample=1 */
- td->td_extrasamples = 0;
- td->td_sampleinfo = NULL;
-
- /*
- * Give client code a chance to install their own
- * tag extensions & methods, prior to compression overloads,
- * but do some prior cleanup first.
- * (http://trac.osgeo.org/gdal/ticket/5054)
- */
- if (tif->tif_nfieldscompat > 0)
- {
- uint32_t i;
-
- for (i = 0; i < tif->tif_nfieldscompat; i++)
- {
- if (tif->tif_fieldscompat[i].allocated_size)
- _TIFFfreeExt(tif, tif->tif_fieldscompat[i].fields);
- }
- _TIFFfreeExt(tif, tif->tif_fieldscompat);
- tif->tif_nfieldscompat = 0;
- tif->tif_fieldscompat = NULL;
- }
- if (_TIFFextender)
- (*_TIFFextender)(tif);
- (void)TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE);
- /*
- * NB: The directory is marked dirty as a result of setting
- * up the default compression scheme. However, this really
- * isn't correct -- we want TIFF_DIRTYDIRECT to be set only
- * if the user does something. We could just do the setup
- * by hand, but it seems better to use the normal mechanism
- * (i.e. TIFFSetField).
- */
- tif->tif_flags &= ~TIFF_DIRTYDIRECT;
-
- /*
- * As per http://bugzilla.remotesensing.org/show_bug.cgi?id=19
- * we clear the ISTILED flag when setting up a new directory.
- * Should we also be clearing stuff like INSUBIFD?
- */
- tif->tif_flags &= ~TIFF_ISTILED;
-
- return (1);
-}
-
-static int TIFFAdvanceDirectory(TIFF *tif, uint64_t *nextdiroff, uint64_t *off,
- tdir_t *nextdirnum)
-{
- static const char module[] = "TIFFAdvanceDirectory";
-
- /* Add this directory to the directory list, if not already in. */
- if (!_TIFFCheckDirNumberAndOffset(tif, *nextdirnum, *nextdiroff))
- {
- TIFFErrorExtR(tif, module,
- "Starting directory %u at offset 0x%" PRIx64 " (%" PRIu64
- ") might cause an IFD loop",
- *nextdirnum, *nextdiroff, *nextdiroff);
- *nextdiroff = 0;
- *nextdirnum = 0;
- return (0);
- }
-
- if (isMapped(tif))
- {
- uint64_t poff = *nextdiroff;
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- {
- tmsize_t poffa, poffb, poffc, poffd;
- uint16_t dircount;
- uint32_t nextdir32;
- poffa = (tmsize_t)poff;
- poffb = poffa + sizeof(uint16_t);
- if (((uint64_t)poffa != poff) || (poffb < poffa) ||
- (poffb < (tmsize_t)sizeof(uint16_t)) || (poffb > tif->tif_size))
- {
- TIFFErrorExtR(tif, module,
- "%s:%d: %s: Error fetching directory count",
- __FILE__, __LINE__, tif->tif_name);
- *nextdiroff = 0;
- return (0);
- }
- _TIFFmemcpy(&dircount, tif->tif_base + poffa, sizeof(uint16_t));
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabShort(&dircount);
- poffc = poffb + dircount * 12;
- poffd = poffc + sizeof(uint32_t);
- if ((poffc < poffb) || (poffc < dircount * 12) || (poffd < poffc) ||
- (poffd < (tmsize_t)sizeof(uint32_t)) || (poffd > tif->tif_size))
- {
- TIFFErrorExtR(tif, module, "Error fetching directory link");
- return (0);
- }
- if (off != NULL)
- *off = (uint64_t)poffc;
- _TIFFmemcpy(&nextdir32, tif->tif_base + poffc, sizeof(uint32_t));
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong(&nextdir32);
- *nextdiroff = nextdir32;
- }
- else
- {
- tmsize_t poffa, poffb, poffc, poffd;
- uint64_t dircount64;
- uint16_t dircount16;
- if (poff > (uint64_t)TIFF_TMSIZE_T_MAX - sizeof(uint64_t))
- {
- TIFFErrorExtR(tif, module,
- "%s:%d: %s: Error fetching directory count",
- __FILE__, __LINE__, tif->tif_name);
- return (0);
- }
- poffa = (tmsize_t)poff;
- poffb = poffa + sizeof(uint64_t);
- if (poffb > tif->tif_size)
- {
- TIFFErrorExtR(tif, module,
- "%s:%d: %s: Error fetching directory count",
- __FILE__, __LINE__, tif->tif_name);
- return (0);
- }
- _TIFFmemcpy(&dircount64, tif->tif_base + poffa, sizeof(uint64_t));
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8(&dircount64);
- if (dircount64 > 0xFFFF)
- {
- TIFFErrorExtR(tif, module,
- "Sanity check on directory count failed");
- return (0);
- }
- dircount16 = (uint16_t)dircount64;
- if (poffb > TIFF_TMSIZE_T_MAX - (tmsize_t)(dircount16 * 20) -
- (tmsize_t)sizeof(uint64_t))
- {
- TIFFErrorExtR(tif, module, "Error fetching directory link");
- return (0);
- }
- poffc = poffb + dircount16 * 20;
- poffd = poffc + sizeof(uint64_t);
- if (poffd > tif->tif_size)
- {
- TIFFErrorExtR(tif, module, "Error fetching directory link");
- return (0);
- }
- if (off != NULL)
- *off = (uint64_t)poffc;
- _TIFFmemcpy(nextdiroff, tif->tif_base + poffc, sizeof(uint64_t));
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8(nextdiroff);
- }
- }
- else
- {
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- {
- uint16_t dircount;
- uint32_t nextdir32;
- if (!SeekOK(tif, *nextdiroff) ||
- !ReadOK(tif, &dircount, sizeof(uint16_t)))
- {
- TIFFErrorExtR(tif, module,
- "%s:%d: %s: Error fetching directory count",
- __FILE__, __LINE__, tif->tif_name);
- return (0);
- }
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabShort(&dircount);
- if (off != NULL)
- *off = TIFFSeekFile(tif, dircount * 12, SEEK_CUR);
- else
- (void)TIFFSeekFile(tif, dircount * 12, SEEK_CUR);
- if (!ReadOK(tif, &nextdir32, sizeof(uint32_t)))
- {
- TIFFErrorExtR(tif, module, "%s: Error fetching directory link",
- tif->tif_name);
- return (0);
- }
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong(&nextdir32);
- *nextdiroff = nextdir32;
- }
- else
- {
- uint64_t dircount64;
- uint16_t dircount16;
- if (!SeekOK(tif, *nextdiroff) ||
- !ReadOK(tif, &dircount64, sizeof(uint64_t)))
- {
- TIFFErrorExtR(tif, module,
- "%s:%d: %s: Error fetching directory count",
- __FILE__, __LINE__, tif->tif_name);
- return (0);
- }
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8(&dircount64);
- if (dircount64 > 0xFFFF)
- {
- TIFFErrorExtR(tif, module,
- "%s:%d: %s: Error fetching directory count",
- __FILE__, __LINE__, tif->tif_name);
- return (0);
- }
- dircount16 = (uint16_t)dircount64;
- if (off != NULL)
- *off = TIFFSeekFile(tif, dircount16 * 20, SEEK_CUR);
- else
- (void)TIFFSeekFile(tif, dircount16 * 20, SEEK_CUR);
- if (!ReadOK(tif, nextdiroff, sizeof(uint64_t)))
- {
- TIFFErrorExtR(tif, module, "%s: Error fetching directory link",
- tif->tif_name);
- return (0);
- }
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8(nextdiroff);
- }
- }
- if (*nextdiroff != 0)
- {
- (*nextdirnum)++;
- /* Check next directory for IFD looping and if so, set it as last
- * directory. */
- if (!_TIFFCheckDirNumberAndOffset(tif, *nextdirnum, *nextdiroff))
- {
- TIFFWarningExtR(
- tif, module,
- "the next directory %u at offset 0x%" PRIx64 " (%" PRIu64
- ") might be an IFD loop. Treating directory %d as "
- "last directory",
- *nextdirnum, *nextdiroff, *nextdiroff, (int)(*nextdirnum) - 1);
- *nextdiroff = 0;
- (*nextdirnum)--;
- }
- }
- return (1);
-}
-
-/*
- * Count the number of directories in a file.
- */
-tdir_t TIFFNumberOfDirectories(TIFF *tif)
-{
- uint64_t nextdiroff;
- tdir_t nextdirnum;
- tdir_t n;
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- nextdiroff = tif->tif_header.classic.tiff_diroff;
- else
- nextdiroff = tif->tif_header.big.tiff_diroff;
- nextdirnum = 0;
- n = 0;
- while (nextdiroff != 0 &&
- TIFFAdvanceDirectory(tif, &nextdiroff, NULL, &nextdirnum))
- {
- ++n;
- }
- /* Update number of main-IFDs in file. */
- tif->tif_curdircount = n;
- return (n);
-}
-
-/*
- * Set the n-th directory as the current directory.
- * NB: Directories are numbered starting at 0.
- */
-int TIFFSetDirectory(TIFF *tif, tdir_t dirn)
-{
- uint64_t nextdiroff;
- tdir_t nextdirnum = 0;
- tdir_t n;
-
- if (tif->tif_setdirectory_force_absolute)
- {
- /* tif_setdirectory_force_absolute=1 will force parsing the main IFD
- * chain from the beginning, thus IFD directory list needs to be cleared
- * from possible SubIFD offsets.
- */
- _TIFFCleanupIFDOffsetAndNumberMaps(tif); /* invalidate IFD loop lists */
- }
-
- /* Even faster path, if offset is available within IFD loop hash list. */
- if (!tif->tif_setdirectory_force_absolute &&
- _TIFFGetOffsetFromDirNumber(tif, dirn, &nextdiroff))
- {
- /* Set parameters for following TIFFReadDirectory() below. */
- tif->tif_nextdiroff = nextdiroff;
- tif->tif_curdir = dirn;
- /* Reset to relative stepping */
- tif->tif_setdirectory_force_absolute = FALSE;
- }
- else
- {
-
- /* Fast path when we just advance relative to the current directory:
- * start at the current dir offset and continue to seek from there.
- * Check special cases when relative is not allowed:
- * - jump back from SubIFD or custom directory
- * - right after TIFFWriteDirectory() jump back to that directory
- * using TIFFSetDirectory() */
- const int relative = (dirn >= tif->tif_curdir) &&
- (tif->tif_diroff != 0) &&
- !tif->tif_setdirectory_force_absolute;
-
- if (relative)
- {
- nextdiroff = tif->tif_diroff;
- dirn -= tif->tif_curdir;
- nextdirnum = tif->tif_curdir;
- }
- else if (!(tif->tif_flags & TIFF_BIGTIFF))
- nextdiroff = tif->tif_header.classic.tiff_diroff;
- else
- nextdiroff = tif->tif_header.big.tiff_diroff;
-
- /* Reset to relative stepping */
- tif->tif_setdirectory_force_absolute = FALSE;
-
- for (n = dirn; n > 0 && nextdiroff != 0; n--)
- if (!TIFFAdvanceDirectory(tif, &nextdiroff, NULL, &nextdirnum))
- return (0);
- /* If the n-th directory could not be reached (does not exist),
- * return here without touching anything further. */
- if (nextdiroff == 0 || n > 0)
- return (0);
-
- tif->tif_nextdiroff = nextdiroff;
-
- /* Set curdir to the actual directory index. */
- if (relative)
- tif->tif_curdir += dirn - n;
- else
- tif->tif_curdir = dirn - n;
- }
-
- /* The -1 decrement is because TIFFReadDirectory will increment
- * tif_curdir after successfully reading the directory. */
- if (tif->tif_curdir == 0)
- tif->tif_curdir = TIFF_NON_EXISTENT_DIR_NUMBER;
- else
- tif->tif_curdir--;
-
- tdir_t curdir = tif->tif_curdir;
-
- int retval = TIFFReadDirectory(tif);
-
- if (!retval && tif->tif_curdir == curdir)
- {
- /* If tif_curdir has not be incremented, TIFFFetchDirectory() in
- * TIFFReadDirectory() has failed and tif_curdir shall be set
- * specifically. */
- tif->tif_curdir = TIFF_NON_EXISTENT_DIR_NUMBER;
- }
- return (retval);
-}
-
-/*
- * Set the current directory to be the directory
- * located at the specified file offset. This interface
- * is used mainly to access directories linked with
- * the SubIFD tag (e.g. thumbnail images).
- */
-int TIFFSetSubDirectory(TIFF *tif, uint64_t diroff)
-{
- /* Match nextdiroff and curdir for consistent IFD-loop checking.
- * Only with TIFFSetSubDirectory() the IFD list can be corrupted with
- * invalid offsets within the main IFD tree. In the case of several subIFDs
- * of a main image, there are two possibilities that are not even mutually
- * exclusive. a.) The subIFD tag contains an array with all offsets of the
- * subIFDs. b.) The SubIFDs are concatenated with their NextIFD parameters.
- * (refer to
- * https://www.awaresystems.be/imaging/tiff/specification/TIFFPM6.pdf.)
- */
- int retval;
- uint32_t curdir = 0;
- int8_t probablySubIFD = 0;
- if (diroff == 0)
- {
- /* Special case to set tif_diroff=0, which is done in
- * TIFFReadDirectory() below to indicate that the currently read IFD is
- * treated as a new, fresh IFD. */
- tif->tif_curdir = TIFF_NON_EXISTENT_DIR_NUMBER;
- tif->tif_dir.td_iswrittentofile = FALSE;
- }
- else
- {
- if (!_TIFFGetDirNumberFromOffset(tif, diroff, &curdir))
- {
- /* Non-existing offsets might point to a SubIFD or invalid IFD.*/
- probablySubIFD = 1;
- }
- /* -1 because TIFFReadDirectory() will increment tif_curdir. */
- if (curdir >= 1)
- tif->tif_curdir = curdir - 1;
- else
- tif->tif_curdir = TIFF_NON_EXISTENT_DIR_NUMBER;
- }
- curdir = tif->tif_curdir;
-
- tif->tif_nextdiroff = diroff;
- retval = TIFFReadDirectory(tif);
-
- /* tif_curdir is incremented in TIFFReadDirectory(), but if it has not been
- * incremented, TIFFFetchDirectory() has failed there and tif_curdir shall
- * be set specifically. */
- if (!retval && diroff != 0 && tif->tif_curdir == curdir)
- {
- tif->tif_curdir = TIFF_NON_EXISTENT_DIR_NUMBER;
- }
-
- if (probablySubIFD)
- {
- if (retval)
- {
- /* Reset IFD list to start new one for SubIFD chain and also start
- * SubIFD chain with tif_curdir=0 for IFD loop checking. */
- /* invalidate IFD loop lists */
- _TIFFCleanupIFDOffsetAndNumberMaps(tif);
- tif->tif_curdir = 0; /* first directory of new chain */
- /* add this offset to new IFD list */
- _TIFFCheckDirNumberAndOffset(tif, tif->tif_curdir, diroff);
- }
- /* To be able to return from SubIFD or custom-IFD to main-IFD */
- tif->tif_setdirectory_force_absolute = TRUE;
- }
-
- return (retval);
-}
-
-/*
- * Return file offset of the current directory.
- */
-uint64_t TIFFCurrentDirOffset(TIFF *tif) { return (tif->tif_diroff); }
-
-/*
- * Return an indication of whether or not we are
- * at the last directory in the file.
- */
-int TIFFLastDirectory(TIFF *tif) { return (tif->tif_nextdiroff == 0); }
-
-/*
- * Unlink the specified directory from the directory chain.
- * Note: First directory starts with number dirn=1.
- * This is different to TIFFSetDirectory() where the first directory starts with
- * zero.
- */
-int TIFFUnlinkDirectory(TIFF *tif, tdir_t dirn)
-{
- static const char module[] = "TIFFUnlinkDirectory";
- uint64_t nextdir;
- tdir_t nextdirnum;
- uint64_t off;
- tdir_t n;
-
- if (tif->tif_mode == O_RDONLY)
- {
- TIFFErrorExtR(tif, module,
- "Can not unlink directory in read-only file");
- return (0);
- }
- if (dirn == 0)
- {
- TIFFErrorExtR(tif, module,
- "For TIFFUnlinkDirectory() first directory starts with "
- "number 1 and not 0");
- return (0);
- }
- /*
- * Go to the directory before the one we want
- * to unlink and nab the offset of the link
- * field we'll need to patch.
- */
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- {
- nextdir = tif->tif_header.classic.tiff_diroff;
- off = 4;
- }
- else
- {
- nextdir = tif->tif_header.big.tiff_diroff;
- off = 8;
- }
- nextdirnum = 0; /* First directory is dirn=0 */
-
- for (n = dirn - 1; n > 0; n--)
- {
- if (nextdir == 0)
- {
- TIFFErrorExtR(tif, module, "Directory %u does not exist", dirn);
- return (0);
- }
- if (!TIFFAdvanceDirectory(tif, &nextdir, &off, &nextdirnum))
- return (0);
- }
- /*
- * Advance to the directory to be unlinked and fetch
- * the offset of the directory that follows.
- */
- if (!TIFFAdvanceDirectory(tif, &nextdir, NULL, &nextdirnum))
- return (0);
- /*
- * Go back and patch the link field of the preceding
- * directory to point to the offset of the directory
- * that follows.
- */
- (void)TIFFSeekFile(tif, off, SEEK_SET);
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- {
- uint32_t nextdir32;
- nextdir32 = (uint32_t)nextdir;
- assert((uint64_t)nextdir32 == nextdir);
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong(&nextdir32);
- if (!WriteOK(tif, &nextdir32, sizeof(uint32_t)))
- {
- TIFFErrorExtR(tif, module, "Error writing directory link");
- return (0);
- }
- }
- else
- {
- /* Need local swap because nextdir has to be used unswapped below. */
- uint64_t nextdir64 = nextdir;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8(&nextdir64);
- if (!WriteOK(tif, &nextdir64, sizeof(uint64_t)))
- {
- TIFFErrorExtR(tif, module, "Error writing directory link");
- return (0);
- }
- }
-
- /* For dirn=1 (first directory) also update the libtiff internal
- * base offset variables. */
- if (dirn == 1)
- {
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- tif->tif_header.classic.tiff_diroff = (uint32_t)nextdir;
- else
- tif->tif_header.big.tiff_diroff = nextdir;
- }
-
- /*
- * Leave directory state setup safely. We don't have
- * facilities for doing inserting and removing directories,
- * so it's safest to just invalidate everything. This
- * means that the caller can only append to the directory
- * chain.
- */
- (*tif->tif_cleanup)(tif);
- if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata)
- {
- _TIFFfreeExt(tif, tif->tif_rawdata);
- tif->tif_rawdata = NULL;
- tif->tif_rawcc = 0;
- tif->tif_rawdataoff = 0;
- tif->tif_rawdataloaded = 0;
- }
- tif->tif_flags &= ~(TIFF_BEENWRITING | TIFF_BUFFERSETUP | TIFF_POSTENCODE |
- TIFF_BUF4WRITE);
- TIFFFreeDirectory(tif);
- TIFFDefaultDirectory(tif);
- tif->tif_diroff = 0; /* force link on next write */
- tif->tif_nextdiroff = 0; /* next write must be at end */
- tif->tif_lastdiroff = 0; /* will be updated on next link */
- tif->tif_curoff = 0;
- tif->tif_row = (uint32_t)-1;
- tif->tif_curstrip = (uint32_t)-1;
- tif->tif_curdir = TIFF_NON_EXISTENT_DIR_NUMBER;
- if (tif->tif_curdircount > 0)
- tif->tif_curdircount--;
- else
- tif->tif_curdircount = TIFF_NON_EXISTENT_DIR_NUMBER;
- _TIFFCleanupIFDOffsetAndNumberMaps(tif); /* invalidate IFD loop lists */
- return (1);
-}
diff --git a/contrib/libs/libtiff/tif_dir.h b/contrib/libs/libtiff/tif_dir.h
deleted file mode 100644
index ffad085e02..0000000000
--- a/contrib/libs/libtiff/tif_dir.h
+++ /dev/null
@@ -1,366 +0,0 @@
-/*
- * Copyright (c) 1988-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-#ifndef _TIFFDIR_
-#define _TIFFDIR_
-
-#include "tiff.h"
-#include "tiffio.h"
-
-/*
- * ``Library-private'' Directory-related Definitions.
- */
-
-typedef struct
-{
- const TIFFField *info;
- int count;
- void *value;
-} TIFFTagValue;
-
-/*
- * TIFF Image File Directories are comprised of a table of field
- * descriptors of the form shown below. The table is sorted in
- * ascending order by tag. The values associated with each entry are
- * disjoint and may appear anywhere in the file (so long as they are
- * placed on a word boundary).
- *
- * If the value is 4 bytes or less, in ClassicTIFF, or 8 bytes or less in
- * BigTIFF, then it is placed in the offset field to save space. If so,
- * it is left-justified in the offset field.
- */
-typedef struct
-{
- uint16_t tdir_tag; /* see below */
- uint16_t tdir_type; /* data type; see below */
- uint64_t tdir_count; /* number of items; length in spec */
- union
- {
- uint16_t toff_short;
- uint32_t toff_long;
- uint64_t toff_long8;
- } tdir_offset; /* either offset or the data itself if fits */
- uint8_t tdir_ignore; /* flag status to ignore tag when parsing tags in
- tif_dirread.c */
-} TIFFDirEntry;
-
-typedef struct
-{
- uint64_t offset;
- uint64_t length;
-} TIFFEntryOffsetAndLength; /* auxiliary for evaluating size of IFD data */
-
-/*
- * Internal format of a TIFF directory entry.
- */
-typedef struct
-{
-#define FIELDSET_ITEMS 4
- /* bit vector of fields that are set */
- uint32_t td_fieldsset[FIELDSET_ITEMS];
-
- uint32_t td_imagewidth, td_imagelength, td_imagedepth;
- uint32_t td_tilewidth, td_tilelength, td_tiledepth;
- uint32_t td_subfiletype;
- uint16_t td_bitspersample;
- uint16_t td_sampleformat;
- uint16_t td_compression;
- uint16_t td_photometric;
- uint16_t td_threshholding;
- uint16_t td_fillorder;
- uint16_t td_orientation;
- uint16_t td_samplesperpixel;
- uint32_t td_rowsperstrip;
- uint16_t td_minsamplevalue, td_maxsamplevalue;
- double *td_sminsamplevalue;
- double *td_smaxsamplevalue;
- float td_xresolution, td_yresolution;
- uint16_t td_resolutionunit;
- uint16_t td_planarconfig;
- float td_xposition, td_yposition;
- uint16_t td_pagenumber[2];
- uint16_t *td_colormap[3];
- uint16_t td_halftonehints[2];
- uint16_t td_extrasamples;
- uint16_t *td_sampleinfo;
- /* even though the name is misleading, td_stripsperimage is the number
- * of striles (=strips or tiles) per plane, and td_nstrips the total
- * number of striles */
- uint32_t td_stripsperimage;
- uint32_t td_nstrips; /* size of offset & bytecount arrays */
- uint64_t
- *td_stripoffset_p; /* should be accessed with TIFFGetStrileOffset */
- uint64_t *td_stripbytecount_p; /* should be accessed with
- TIFFGetStrileByteCount */
- uint32_t
- td_stripoffsetbyteallocsize; /* number of elements currently allocated
- for td_stripoffset/td_stripbytecount.
- Only used if TIFF_LAZYSTRILELOAD is set
- */
-#ifdef STRIPBYTECOUNTSORTED_UNUSED
- int td_stripbytecountsorted; /* is the bytecount array sorted ascending? */
-#endif
- /* Be aware that the parameters of td_stripoffset_entry and
- * td_stripbytecount_entry are swapped but tdir_offset is not
- * and has to be swapped when used. */
- TIFFDirEntry td_stripoffset_entry; /* for deferred loading */
- TIFFDirEntry td_stripbytecount_entry; /* for deferred loading */
- uint16_t td_nsubifd;
- uint64_t *td_subifd;
- /* YCbCr parameters */
- uint16_t td_ycbcrsubsampling[2];
- uint16_t td_ycbcrpositioning;
- /* Colorimetry parameters */
- uint16_t *td_transferfunction[3];
- float *td_refblackwhite;
- /* CMYK parameters */
- int td_inknameslen;
- char *td_inknames;
- uint16_t td_numberofinks; /* number of inks in InkNames string */
-
- int td_customValueCount;
- TIFFTagValue *td_customValues;
-
- unsigned char
- td_deferstrilearraywriting; /* see TIFFDeferStrileArrayWriting() */
-
- unsigned char
- td_iswrittentofile; /* indicates if current IFD is present on file */
-
- /* LibTIFF writes all data that does not fit into the IFD entries directly
- * after the IFD tag entry part. When reading, only the IFD data directly
- * and continuously behind the IFD tags is taken into account for the IFD
- * data size.*/
- uint64_t td_dirdatasize_write; /* auxiliary for evaluating size of IFD data
- to be written */
- uint64_t td_dirdatasize_read; /* auxiliary for evaluating size of IFD data
- read from file */
- uint32_t td_dirdatasize_Noffsets; /* auxiliary counter for
- tif_dir.td_dirdatasize_offsets array */
- TIFFEntryOffsetAndLength
- *td_dirdatasize_offsets; /* auxiliary array for all offsets of IFD tag
- entries with data outside the IFD tag
- entries. */
-} TIFFDirectory;
-
-/*
- * Field flags used to indicate fields that have been set in a directory, and
- * to reference fields when manipulating a directory.
- */
-
-/*
- * FIELD_IGNORE is used to signify tags that are to be processed but otherwise
- * ignored. This permits antiquated tags to be quietly read and discarded.
- * Note that a bit *is* allocated for ignored tags; this is understood by the
- * directory reading logic which uses this fact to avoid special-case handling
- */
-#define FIELD_IGNORE 0
-
-/* multi-item fields */
-#define FIELD_IMAGEDIMENSIONS 1
-#define FIELD_TILEDIMENSIONS 2
-#define FIELD_RESOLUTION 3
-#define FIELD_POSITION 4
-
-/* single-item fields */
-#define FIELD_SUBFILETYPE 5
-#define FIELD_BITSPERSAMPLE 6
-#define FIELD_COMPRESSION 7
-#define FIELD_PHOTOMETRIC 8
-#define FIELD_THRESHHOLDING 9
-#define FIELD_FILLORDER 10
-#define FIELD_ORIENTATION 15
-#define FIELD_SAMPLESPERPIXEL 16
-#define FIELD_ROWSPERSTRIP 17
-#define FIELD_MINSAMPLEVALUE 18
-#define FIELD_MAXSAMPLEVALUE 19
-#define FIELD_PLANARCONFIG 20
-#define FIELD_RESOLUTIONUNIT 22
-#define FIELD_PAGENUMBER 23
-#define FIELD_STRIPBYTECOUNTS 24
-#define FIELD_STRIPOFFSETS 25
-#define FIELD_COLORMAP 26
-#define FIELD_EXTRASAMPLES 31
-#define FIELD_SAMPLEFORMAT 32
-#define FIELD_SMINSAMPLEVALUE 33
-#define FIELD_SMAXSAMPLEVALUE 34
-#define FIELD_IMAGEDEPTH 35
-#define FIELD_TILEDEPTH 36
-#define FIELD_HALFTONEHINTS 37
-#define FIELD_YCBCRSUBSAMPLING 39
-#define FIELD_YCBCRPOSITIONING 40
-#define FIELD_REFBLACKWHITE 41
-#define FIELD_TRANSFERFUNCTION 44
-#define FIELD_INKNAMES 46
-#define FIELD_SUBIFD 49
-#define FIELD_NUMBEROFINKS 50
-/* FIELD_CUSTOM (see tiffio.h) 65 */
-/* end of support for well-known tags; codec-private tags follow */
-#define FIELD_CODEC 66 /* base of codec-private tags */
-
-/*
- * Pseudo-tags don't normally need field bits since they are not written to an
- * output file (by definition). The library also has express logic to always
- * query a codec for a pseudo-tag so allocating a field bit for one is a
- * waste. If codec wants to promote the notion of a pseudo-tag being ``set''
- * or ``unset'' then it can do using internal state flags without polluting
- * the field bit space defined for real tags.
- */
-#define FIELD_PSEUDO 0
-
-#define FIELD_LAST (32 * FIELDSET_ITEMS - 1)
-
-#define BITn(n) (((uint32_t)1L) << ((n)&0x1f))
-#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
-#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
-#define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
-#define TIFFClrFieldBit(tif, field) (BITFIELDn(tif, field) &= ~BITn(field))
-
-#define FieldSet(fields, f) (fields[(f) / 32] & BITn(f))
-#define ResetFieldBit(fields, f) (fields[(f) / 32] &= ~BITn(f))
-
-typedef enum
-{
- TIFF_SETGET_UNDEFINED = 0,
- TIFF_SETGET_ASCII = 1,
- TIFF_SETGET_UINT8 = 2,
- TIFF_SETGET_SINT8 = 3,
- TIFF_SETGET_UINT16 = 4,
- TIFF_SETGET_SINT16 = 5,
- TIFF_SETGET_UINT32 = 6,
- TIFF_SETGET_SINT32 = 7,
- TIFF_SETGET_UINT64 = 8,
- TIFF_SETGET_SINT64 = 9,
- TIFF_SETGET_FLOAT = 10,
- TIFF_SETGET_DOUBLE = 11,
- TIFF_SETGET_IFD8 = 12,
- TIFF_SETGET_INT = 13,
- TIFF_SETGET_UINT16_PAIR = 14,
- TIFF_SETGET_C0_ASCII = 15,
- TIFF_SETGET_C0_UINT8 = 16,
- TIFF_SETGET_C0_SINT8 = 17,
- TIFF_SETGET_C0_UINT16 = 18,
- TIFF_SETGET_C0_SINT16 = 19,
- TIFF_SETGET_C0_UINT32 = 20,
- TIFF_SETGET_C0_SINT32 = 21,
- TIFF_SETGET_C0_UINT64 = 22,
- TIFF_SETGET_C0_SINT64 = 23,
- TIFF_SETGET_C0_FLOAT = 24,
- TIFF_SETGET_C0_DOUBLE = 25,
- TIFF_SETGET_C0_IFD8 = 26,
- TIFF_SETGET_C16_ASCII = 27,
- TIFF_SETGET_C16_UINT8 = 28,
- TIFF_SETGET_C16_SINT8 = 29,
- TIFF_SETGET_C16_UINT16 = 30,
- TIFF_SETGET_C16_SINT16 = 31,
- TIFF_SETGET_C16_UINT32 = 32,
- TIFF_SETGET_C16_SINT32 = 33,
- TIFF_SETGET_C16_UINT64 = 34,
- TIFF_SETGET_C16_SINT64 = 35,
- TIFF_SETGET_C16_FLOAT = 36,
- TIFF_SETGET_C16_DOUBLE = 37,
- TIFF_SETGET_C16_IFD8 = 38,
- TIFF_SETGET_C32_ASCII = 39,
- TIFF_SETGET_C32_UINT8 = 40,
- TIFF_SETGET_C32_SINT8 = 41,
- TIFF_SETGET_C32_UINT16 = 42,
- TIFF_SETGET_C32_SINT16 = 43,
- TIFF_SETGET_C32_UINT32 = 44,
- TIFF_SETGET_C32_SINT32 = 45,
- TIFF_SETGET_C32_UINT64 = 46,
- TIFF_SETGET_C32_SINT64 = 47,
- TIFF_SETGET_C32_FLOAT = 48,
- TIFF_SETGET_C32_DOUBLE = 49,
- TIFF_SETGET_C32_IFD8 = 50,
- TIFF_SETGET_OTHER = 51
-} TIFFSetGetFieldType;
-
-#if defined(__cplusplus)
-extern "C"
-{
-#endif
-
- extern const TIFFFieldArray *_TIFFGetFields(void);
- extern const TIFFFieldArray *_TIFFGetExifFields(void);
- extern const TIFFFieldArray *_TIFFGetGpsFields(void);
- extern void _TIFFSetupFields(TIFF *tif, const TIFFFieldArray *infoarray);
- extern void _TIFFPrintFieldInfo(TIFF *, FILE *);
-
- extern int _TIFFFillStriles(TIFF *);
-
- typedef enum
- {
- tfiatImage,
- tfiatExif,
- tfiatGps, /* EXIF-GPS fields array type */
- tfiatOther
- } TIFFFieldArrayType;
-
- struct _TIFFFieldArray
- {
- TIFFFieldArrayType type; /* array type, will be used to determine if IFD
- is image and such */
- uint32_t allocated_size; /* 0 if array is constant, other if modified by
- future definition extension support */
- uint32_t count; /* number of elements in fields array */
- TIFFField *fields; /* actual field info */
- };
-
- struct _TIFFField
- {
- uint32_t field_tag; /* field's tag */
- short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */
- short field_writecount; /* write count/TIFF_VARIABLE */
- TIFFDataType field_type; /* type of associated data */
- uint32_t
- field_anonymous; /* if true, this is a unknown / anonymous tag */
- TIFFSetGetFieldType set_field_type; /* type to be passed to TIFFSetField
- and TIFFGetField*/
- TIFFSetGetFieldType get_field_type; /* not used */
- unsigned short field_bit; /* bit in fieldsset bit vector */
- unsigned char field_oktochange; /* if true, can change while writing */
- unsigned char field_passcount; /* if true, pass dir count on set */
- char *field_name; /* ASCII name */
- TIFFFieldArray *field_subfields; /* if field points to child ifds, child
- ifd field definition array */
- };
-
- extern int _TIFFMergeFields(TIFF *, const TIFFField[], uint32_t);
- extern const TIFFField *_TIFFFindOrRegisterField(TIFF *, uint32_t,
- TIFFDataType);
- extern TIFFField *_TIFFCreateAnonField(TIFF *, uint32_t, TIFFDataType);
- extern int _TIFFCheckFieldIsValidForCodec(TIFF *tif, ttag_t tag);
- extern int _TIFFCheckDirNumberAndOffset(TIFF *tif, tdir_t dirn,
- uint64_t diroff);
- extern int _TIFFGetDirNumberFromOffset(TIFF *tif, uint64_t diroff,
- tdir_t *dirn);
- extern int _TIFFGetOffsetFromDirNumber(TIFF *tif, tdir_t dirn,
- uint64_t *diroff);
- extern int _TIFFRemoveEntryFromDirectoryListByOffset(TIFF *tif,
- uint64_t diroff);
-
-#if defined(__cplusplus)
-}
-#endif
-#endif /* _TIFFDIR_ */
diff --git a/contrib/libs/libtiff/tif_dirinfo.c b/contrib/libs/libtiff/tif_dirinfo.c
deleted file mode 100644
index 432e6e1e44..0000000000
--- a/contrib/libs/libtiff/tif_dirinfo.c
+++ /dev/null
@@ -1,1363 +0,0 @@
-/*
- * Copyright (c) 1988-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-/*
- * TIFF Library.
- *
- * Core Directory Tag Support.
- */
-#include "tiffiop.h"
-#include <stdlib.h>
-
-/*
- * NOTE: THIS ARRAY IS ASSUMED TO BE SORTED BY TAG.
- *
- * NOTE: The second field (field_readcount) and third field (field_writecount)
- * sometimes use the values TIFF_VARIABLE (-1), TIFF_VARIABLE2 (-3)
- * and TIFF_SPP (-2). The macros should be used but would throw off
- * the formatting of the code, so please interpret the -1, -2 and -3
- * values accordingly.
- */
-
-/* const object should be initialized */
-#ifdef _MSC_VER
-#pragma warning(push)
-#pragma warning(disable : 4132)
-#endif
-static const TIFFFieldArray tiffFieldArray;
-static const TIFFFieldArray exifFieldArray;
-static const TIFFFieldArray gpsFieldArray;
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif
-/*--: Rational2Double: --
- * The Rational2Double upgraded libtiff functionality allows the definition and
- * achievement of true double-precision accuracy for TIFF tags of RATIONAL type
- * and field_bit=FIELD_CUSTOM using the set_field_type = TIFF_SETGET_DOUBLE.
- * Unfortunately, that changes the old implemented interface for TIFFGetField().
- * In order to keep the old TIFFGetField() interface behavior those tags have to
- * be redefined with set_field_type = TIFF_SETGET_FLOAT!
- *
- * Rational custom arrays are already defined as _Cxx_FLOAT, thus can stay.
- *
- */
-
-/* clang-format off */ /* for better readability of tag comments */
-static const TIFFField tiffFields[] = {
- {TIFFTAG_SUBFILETYPE, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_SUBFILETYPE, 1, 0, "SubfileType", NULL},
- {TIFFTAG_OSUBFILETYPE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 1, 0, "OldSubfileType", NULL},
- {TIFFTAG_IMAGEWIDTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_IMAGEDIMENSIONS, 0, 0, "ImageWidth", NULL},
- {TIFFTAG_IMAGELENGTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_IMAGEDIMENSIONS, 1, 0, "ImageLength", NULL},
- {TIFFTAG_BITSPERSAMPLE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_BITSPERSAMPLE, 0, 0, "BitsPerSample", NULL},
- {TIFFTAG_COMPRESSION, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_COMPRESSION, 0, 0, "Compression", NULL},
- {TIFFTAG_PHOTOMETRIC, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_PHOTOMETRIC, 0, 0, "PhotometricInterpretation", NULL},
- {TIFFTAG_THRESHHOLDING, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_THRESHHOLDING, 1, 0, "Threshholding", NULL},
- {TIFFTAG_CELLWIDTH, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CellWidth", NULL},
- {TIFFTAG_CELLLENGTH, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CellLength", NULL},
- {TIFFTAG_FILLORDER, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_FILLORDER, 0, 0, "FillOrder", NULL},
- {TIFFTAG_DOCUMENTNAME, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DocumentName", NULL},
- {TIFFTAG_IMAGEDESCRIPTION, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImageDescription", NULL},
- {TIFFTAG_MAKE, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Make", NULL},
- {TIFFTAG_MODEL, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Model", NULL},
- {TIFFTAG_STRIPOFFSETS, -1, -1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_STRIPOFFSETS, 0, 0, "StripOffsets", NULL},
- {TIFFTAG_ORIENTATION, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_ORIENTATION, 0, 0, "Orientation", NULL},
- {TIFFTAG_SAMPLESPERPIXEL, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_SAMPLESPERPIXEL, 0, 0, "SamplesPerPixel", NULL},
- {TIFFTAG_ROWSPERSTRIP, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_ROWSPERSTRIP, 0, 0, "RowsPerStrip", NULL},
- {TIFFTAG_STRIPBYTECOUNTS, -1, -1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_STRIPBYTECOUNTS, 0, 0, "StripByteCounts", NULL},
- {TIFFTAG_MINSAMPLEVALUE, -2, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_MINSAMPLEVALUE, 1, 0, "MinSampleValue", NULL},
- {TIFFTAG_MAXSAMPLEVALUE, -2, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_MAXSAMPLEVALUE, 1, 0, "MaxSampleValue", NULL},
- {TIFFTAG_XRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_RESOLUTION, 1, 0, "XResolution", NULL},
- {TIFFTAG_YRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_RESOLUTION, 1, 0, "YResolution", NULL},
- {TIFFTAG_PLANARCONFIG, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_PLANARCONFIG, 0, 0, "PlanarConfiguration", NULL},
- {TIFFTAG_PAGENAME, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "PageName", NULL},
- {TIFFTAG_XPOSITION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_POSITION, 1, 0, "XPosition", NULL},
- {TIFFTAG_YPOSITION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_POSITION, 1, 0, "YPosition", NULL},
- {TIFFTAG_FREEOFFSETS, -1, -1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 0, 0, "FreeOffsets", NULL},
- {TIFFTAG_FREEBYTECOUNTS, -1, -1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 0, 0, "FreeByteCounts", NULL},
- {TIFFTAG_GRAYRESPONSEUNIT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 1, 0, "GrayResponseUnit", NULL},
- {TIFFTAG_GRAYRESPONSECURVE, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 1, 0, "GrayResponseCurve", NULL},
- {TIFFTAG_RESOLUTIONUNIT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_RESOLUTIONUNIT, 1, 0, "ResolutionUnit", NULL},
- {TIFFTAG_PAGENUMBER, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_UINT16_PAIR, TIFF_SETGET_UNDEFINED, FIELD_PAGENUMBER, 1, 0, "PageNumber", NULL},
- {TIFFTAG_COLORRESPONSEUNIT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 1, 0, "ColorResponseUnit", NULL},
- {TIFFTAG_TRANSFERFUNCTION, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_OTHER, TIFF_SETGET_UNDEFINED, FIELD_TRANSFERFUNCTION, 1, 0, "TransferFunction", NULL},
- {TIFFTAG_SOFTWARE, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Software", NULL},
- {TIFFTAG_DATETIME, 20, 20, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DateTime", NULL},
- {TIFFTAG_ARTIST, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Artist", NULL},
- {TIFFTAG_HOSTCOMPUTER, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "HostComputer", NULL},
- {TIFFTAG_WHITEPOINT, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "WhitePoint", NULL},
- {TIFFTAG_PRIMARYCHROMATICITIES, 6, 6, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "PrimaryChromaticities", NULL},
- {TIFFTAG_COLORMAP, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_OTHER, TIFF_SETGET_UNDEFINED, FIELD_COLORMAP, 1, 0, "ColorMap", NULL},
- {TIFFTAG_HALFTONEHINTS, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_UINT16_PAIR, TIFF_SETGET_UNDEFINED, FIELD_HALFTONEHINTS, 1, 0, "HalftoneHints", NULL},
- {TIFFTAG_TILEWIDTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_TILEDIMENSIONS, 0, 0, "TileWidth", NULL},
- {TIFFTAG_TILELENGTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_TILEDIMENSIONS, 0, 0, "TileLength", NULL},
- {TIFFTAG_TILEOFFSETS, -1, 1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_STRIPOFFSETS, 0, 0, "TileOffsets", NULL},
- {TIFFTAG_TILEBYTECOUNTS, -1, 1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_STRIPBYTECOUNTS, 0, 0, "TileByteCounts", NULL},
- {TIFFTAG_SUBIFD, -1, -1, TIFF_IFD8, 0, TIFF_SETGET_C16_IFD8, TIFF_SETGET_UNDEFINED, FIELD_SUBIFD, 1, 1, "SubIFD", (TIFFFieldArray *)&tiffFieldArray},
- {TIFFTAG_INKSET, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "InkSet", NULL},
- {TIFFTAG_INKNAMES, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_C16_ASCII, TIFF_SETGET_UNDEFINED, FIELD_INKNAMES, 1, 1, "InkNames", NULL},
- {TIFFTAG_NUMBEROFINKS, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_NUMBEROFINKS, 1, 0, "NumberOfInks", NULL},
- {TIFFTAG_DOTRANGE, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_UINT16_PAIR, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "DotRange", NULL},
- {TIFFTAG_TARGETPRINTER, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "TargetPrinter", NULL},
- {TIFFTAG_EXTRASAMPLES, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_EXTRASAMPLES, 0, 1, "ExtraSamples", NULL},
- {TIFFTAG_SAMPLEFORMAT, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_SAMPLEFORMAT, 0, 0, "SampleFormat", NULL},
- {TIFFTAG_SMINSAMPLEVALUE, -2, -1, TIFF_ANY, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_SMINSAMPLEVALUE, 1, 0, "SMinSampleValue", NULL},
- {TIFFTAG_SMAXSAMPLEVALUE, -2, -1, TIFF_ANY, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_SMAXSAMPLEVALUE, 1, 0, "SMaxSampleValue", NULL},
- {TIFFTAG_CLIPPATH, -3, -3, TIFF_BYTE, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "ClipPath", NULL},
- {TIFFTAG_XCLIPPATHUNITS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "XClipPathUnits", NULL},
- {TIFFTAG_YCLIPPATHUNITS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "YClipPathUnits", NULL},
- {TIFFTAG_YCBCRCOEFFICIENTS, 3, 3, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "YCbCrCoefficients", NULL},
- {TIFFTAG_YCBCRSUBSAMPLING, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_UINT16_PAIR, TIFF_SETGET_UNDEFINED, FIELD_YCBCRSUBSAMPLING, 0, 0, "YCbCrSubsampling", NULL},
- {TIFFTAG_YCBCRPOSITIONING, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_YCBCRPOSITIONING, 0, 0, "YCbCrPositioning", NULL},
- {TIFFTAG_REFERENCEBLACKWHITE, 6, 6, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_REFBLACKWHITE, 1, 0, "ReferenceBlackWhite", NULL},
- {TIFFTAG_XMLPACKET, -3, -3, TIFF_BYTE, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "XMLPacket", NULL},
- /* begin SGI tags */
- {TIFFTAG_MATTEING, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_EXTRASAMPLES, 0, 0, "Matteing", NULL},
- {TIFFTAG_DATATYPE, -2, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_SAMPLEFORMAT, 0, 0, "DataType", NULL},
- {TIFFTAG_IMAGEDEPTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_IMAGEDEPTH, 0, 0, "ImageDepth", NULL},
- {TIFFTAG_TILEDEPTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_TILEDEPTH, 0, 0, "TileDepth", NULL},
- /* end SGI tags */
- /* begin Pixar tags */
- {TIFFTAG_PIXAR_IMAGEFULLWIDTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImageFullWidth", NULL},
- {TIFFTAG_PIXAR_IMAGEFULLLENGTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImageFullLength", NULL},
- {TIFFTAG_PIXAR_TEXTUREFORMAT, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "TextureFormat", NULL},
- {TIFFTAG_PIXAR_WRAPMODES, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "TextureWrapModes", NULL},
- {TIFFTAG_PIXAR_FOVCOT, 1, 1, TIFF_FLOAT, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FieldOfViewCotangent", NULL},
- {TIFFTAG_PIXAR_MATRIX_WORLDTOSCREEN, 16, 16, TIFF_FLOAT, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MatrixWorldToScreen", NULL},
- {TIFFTAG_PIXAR_MATRIX_WORLDTOCAMERA, 16, 16, TIFF_FLOAT, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MatrixWorldToCamera", NULL},
- {TIFFTAG_COPYRIGHT, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Copyright", NULL},
- /* end Pixar tags */
- {TIFFTAG_RICHTIFFIPTC, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "RichTIFFIPTC", NULL},
- {TIFFTAG_PHOTOSHOP, -3, -3, TIFF_BYTE, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "Photoshop", NULL},
- /*--: EXIFIFD and GPSIFD specified as TIFF_LONG by Aware-Systems and not TIFF_IFD8 as in original LibTiff. However, for IFD-like tags,
- * libtiff uses the data type TIFF_IFD8 in tiffFields[]-tag definition combined with a special handling procedure in order to write either
- * a 32-bit value and the TIFF_IFD type-id into ClassicTIFF files or a 64-bit value and the TIFF_IFD8 type-id into BigTIFF files. */
- {TIFFTAG_EXIFIFD, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_IFD8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EXIFIFDOffset", (TIFFFieldArray *)&exifFieldArray},
- {TIFFTAG_ICCPROFILE, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ICC Profile", NULL},
- {TIFFTAG_GPSIFD, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_IFD8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "GPSIFDOffset", (TIFFFieldArray *)&gpsFieldArray},
- {TIFFTAG_FAXRECVPARAMS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UINT32, FIELD_CUSTOM, TRUE, FALSE, "FaxRecvParams", NULL},
- {TIFFTAG_FAXSUBADDRESS, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_ASCII, FIELD_CUSTOM, TRUE, FALSE, "FaxSubAddress", NULL},
- {TIFFTAG_FAXRECVTIME, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UINT32, FIELD_CUSTOM, TRUE, FALSE, "FaxRecvTime", NULL},
- {TIFFTAG_FAXDCS, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_ASCII, FIELD_CUSTOM, TRUE, FALSE, "FaxDcs", NULL},
- {TIFFTAG_STONITS, 1, 1, TIFF_DOUBLE, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "StoNits", NULL},
- {TIFFTAG_IMAGESOURCEDATA, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "Adobe Photoshop Document Data Block", NULL},
- {TIFFTAG_INTEROPERABILITYIFD, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_IFD8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "InteroperabilityIFDOffset", NULL},
- /* begin DNG tags */
- {TIFFTAG_DNGVERSION, 4, 4, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DNGVersion", NULL},
- {TIFFTAG_DNGBACKWARDVERSION, 4, 4, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DNGBackwardVersion", NULL},
- {TIFFTAG_UNIQUECAMERAMODEL, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "UniqueCameraModel", NULL},
- {TIFFTAG_LOCALIZEDCAMERAMODEL, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "LocalizedCameraModel", NULL},
- {TIFFTAG_CFAPLANECOLOR, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "CFAPlaneColor", NULL},
- {TIFFTAG_CFALAYOUT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CFALayout", NULL},
- {TIFFTAG_LINEARIZATIONTABLE, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "LinearizationTable", NULL},
- {TIFFTAG_BLACKLEVELREPEATDIM, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_C0_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "BlackLevelRepeatDim", NULL},
- {TIFFTAG_BLACKLEVEL, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "BlackLevel", NULL},
- {TIFFTAG_BLACKLEVELDELTAH, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "BlackLevelDeltaH", NULL},
- {TIFFTAG_BLACKLEVELDELTAV, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "BlackLevelDeltaV", NULL},
- {TIFFTAG_WHITELEVEL, -1, -1, TIFF_LONG, 0, TIFF_SETGET_C16_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "WhiteLevel", NULL},
- {TIFFTAG_DEFAULTSCALE, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DefaultScale", NULL},
- {TIFFTAG_BESTQUALITYSCALE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "BestQualityScale", NULL},
- {TIFFTAG_DEFAULTCROPORIGIN, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DefaultCropOrigin", NULL},
- {TIFFTAG_DEFAULTCROPSIZE, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DefaultCropSize", NULL},
- {TIFFTAG_COLORMATRIX1, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ColorMatrix1", NULL},
- {TIFFTAG_COLORMATRIX2, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ColorMatrix2", NULL},
- {TIFFTAG_CAMERACALIBRATION1, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "CameraCalibration1", NULL},
- {TIFFTAG_CAMERACALIBRATION2, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "CameraCalibration2", NULL},
- {TIFFTAG_REDUCTIONMATRIX1, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ReductionMatrix1", NULL},
- {TIFFTAG_REDUCTIONMATRIX2, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ReductionMatrix2", NULL},
- {TIFFTAG_ANALOGBALANCE, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "AnalogBalance", NULL},
- {TIFFTAG_ASSHOTNEUTRAL, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "AsShotNeutral", NULL},
- {TIFFTAG_ASSHOTWHITEXY, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "AsShotWhiteXY", NULL},
- {TIFFTAG_BASELINEEXPOSURE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "BaselineExposure", NULL},
- {TIFFTAG_BASELINENOISE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "BaselineNoise", NULL},
- {TIFFTAG_BASELINESHARPNESS, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "BaselineSharpness", NULL},
- {TIFFTAG_BAYERGREENSPLIT, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "BayerGreenSplit", NULL},
- {TIFFTAG_LINEARRESPONSELIMIT, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "LinearResponseLimit", NULL},
- {TIFFTAG_CAMERASERIALNUMBER, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CameraSerialNumber", NULL},
- {TIFFTAG_LENSINFO, 4, 4, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "LensInfo", NULL},
- {TIFFTAG_CHROMABLURRADIUS, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ChromaBlurRadius", NULL},
- {TIFFTAG_ANTIALIASSTRENGTH, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "AntiAliasStrength", NULL},
- {TIFFTAG_SHADOWSCALE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ShadowScale", NULL},
- {TIFFTAG_DNGPRIVATEDATA, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "DNGPrivateData", NULL},
- {TIFFTAG_MAKERNOTESAFETY, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MakerNoteSafety", NULL},
- {TIFFTAG_CALIBRATIONILLUMINANT1, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CalibrationIlluminant1", NULL},
- {TIFFTAG_CALIBRATIONILLUMINANT2, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CalibrationIlluminant2", NULL},
- {TIFFTAG_RAWDATAUNIQUEID, 16, 16, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "RawDataUniqueID", NULL},
- {TIFFTAG_ORIGINALRAWFILENAME, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "OriginalRawFileName", NULL},
- {TIFFTAG_ORIGINALRAWFILEDATA, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "OriginalRawFileData", NULL},
- {TIFFTAG_ACTIVEAREA, 4, 4, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ActiveArea", NULL},
- {TIFFTAG_MASKEDAREAS, -1, -1, TIFF_LONG, 0, TIFF_SETGET_C16_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "MaskedAreas", NULL},
- {TIFFTAG_ASSHOTICCPROFILE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "AsShotICCProfile", NULL},
- {TIFFTAG_ASSHOTPREPROFILEMATRIX, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "AsShotPreProfileMatrix", NULL},
- {TIFFTAG_CURRENTICCPROFILE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "CurrentICCProfile", NULL},
- {TIFFTAG_CURRENTPREPROFILEMATRIX, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "CurrentPreProfileMatrix", NULL},
- {TIFFTAG_PERSAMPLE, 0, 0, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "PerSample", NULL},
-#if 0
- /* begin DNG 1.2.0.0 tags */
- {TIFFTAG_COLORIMETRICREFERENCE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ColorimetricReference", NULL},
- {TIFFTAG_CAMERACALIBRATIONSIGNATURE, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "CameraCalibrationSignature", NULL},
- {TIFFTAG_PROFILECALIBRATIONSIGNATURE, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ProfileCalibrationSignature", NULL},
- {TIFFTAG_EXTRACAMERAPROFILES, -1, -1, TIFF_IFD8, 0, TIFF_SETGET_C16_IFD8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ExtraCameraProfiles", NULL},
- {TIFFTAG_ASSHOTPROFILENAME, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "AsShotProfileName", NULL},
- {TIFFTAG_NOISEREDUCTIONAPPLIED, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "NoiseReductionApplied", NULL},
- {TIFFTAG_PROFILENAME, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ProfileName", NULL},
- {TIFFTAG_PROFILEHUESATMAPDIMS, 3, 3, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ProfileHueSatMapDims", NULL},
- {TIFFTAG_PROFILEHUESATMAPDATA1, -1, -1, TIFF_FLOAT, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ProfileHueSatMapData1", NULL},
- {TIFFTAG_PROFILEHUESATMAPDATA2, -1, -1, TIFF_FLOAT, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ProfileHueSatMapData2", NULL},
- {TIFFTAG_PROFILETONECURVE, -1, -1, TIFF_FLOAT, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ProfileToneCurve", NULL},
- {TIFFTAG_PROFILEEMBEDPOLICY, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ProfileEmbedPolicy", NULL},
- {TIFFTAG_PROFILECOPYRIGHT, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ProfileCopyright", NULL},
- {TIFFTAG_FORWARDMATRIX1, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ForwardMatrix1", NULL},
- {TIFFTAG_FORWARDMATRIX2, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ForwardMatrix2", NULL},
- {TIFFTAG_PREVIEWAPPLICATIONNAME, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "PreviewApplicationName", NULL},
- {TIFFTAG_PREVIEWAPPLICATIONVERSION, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "PreviewApplicationVersion", NULL},
- {TIFFTAG_PREVIEWSETTINGSNAME, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "PreviewSettingsName", NULL},
- {TIFFTAG_PREVIEWSETTINGSDIGEST, 16, 16, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "PreviewSettingsDigest", NULL},
- {TIFFTAG_PREVIEWCOLORSPACE, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "PreviewColorSpace", NULL},
- {TIFFTAG_PREVIEWDATETIME, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "PreviewDateTime", NULL},
- {TIFFTAG_RAWIMAGEDIGEST, 16, 16, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "RawImageDigest", NULL},
- {TIFFTAG_ORIGINALRAWFILEDIGEST, 16, 16, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "OriginalRawFileDigest", NULL},
- {TIFFTAG_SUBTILEBLOCKSIZE, 2, 2, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubTileBlockSize", NULL},
- {TIFFTAG_ROWINTERLEAVEFACTOR, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "RowInterleaveFactor", NULL},
- {TIFFTAG_PROFILELOOKTABLEDIMS, 3, 3, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ProfileLookTableDims", NULL},
- {TIFFTAG_PROFILELOOKTABLEDATA, -1, -1, TIFF_FLOAT, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ProfileLookTableData", NULL},
- /* begin DNG 1.3.0.0 tags */
- {TIFFTAG_OPCODELIST1, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "OpcodeList1", NULL},
- {TIFFTAG_OPCODELIST2, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "OpcodeList2", NULL},
- {TIFFTAG_OPCODELIST3, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "OpcodeList3", NULL},
- {TIFFTAG_NOISEPROFILE, -1, -1, TIFF_DOUBLE, 0, TIFF_SETGET_C16_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "NoiseProfile", NULL},
- /* begin DNG 1.4.0.0 tags */
- {TIFFTAG_DEFAULTUSERCROP, 4, 4, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DefaultUserCrop", NULL},
- {TIFFTAG_DEFAULTBLACKRENDER, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DefaultBlackRender", NULL},
- {TIFFTAG_BASELINEEXPOSUREOFFSET, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "BaselineExposureOffset", NULL},
- {TIFFTAG_PROFILELOOKTABLEENCODING, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ProfileLookTableEncoding", NULL},
- {TIFFTAG_PROFILEHUESATMAPENCODING, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ProfileHueSatMapEncoding", NULL},
- {TIFFTAG_ORIGINALDEFAULTFINALSIZE, 2, 2, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "OriginalDefaultFinalSize", NULL},
- {TIFFTAG_ORIGINALBESTQUALITYFINALSIZE, 2, 2, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "OriginalBestQualityFinalSize", NULL},
- {TIFFTAG_ORIGINALDEFAULTCROPSIZE, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "OriginalDefaultCropSize", NULL}, /* could also be rational */
- {TIFFTAG_NEWRAWIMAGEDIGEST, 16, 16, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "NewRawImageDigest", NULL},
- {TIFFTAG_RAWTOPREVIEWGAIN, 1, 1, TIFF_DOUBLE, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "RawToPreviewGain", NULL},
- /* begin DNG 1.5.0.0 tags */
- {TIFFTAG_DEPTHFORMAT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DepthFormat", NULL},
- {TIFFTAG_DEPTHNEAR, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DepthNear", NULL},
- {TIFFTAG_DEPTHFAR, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DepthFar", NULL},
- {TIFFTAG_DEPTHUNITS, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DepthUnits", NULL},
- {TIFFTAG_DEPTHMEASURETYPE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DepthMeasureType", NULL},
- {TIFFTAG_ENHANCEPARAMS, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EnhanceParams", NULL},
- /* begin DNG 1.6.0.0 tags */
- {TIFFTAG_PROFILEGAINTABLEMAP, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ProfileGainTableMap", NULL},
- {TIFFTAG_SEMANTICNAME, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SemanticName", NULL},
- {TIFFTAG_SEMANTICINSTANCEID, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SemanticInstanceID", NULL},
- {TIFFTAG_MASKSUBAREA, 4, 4, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MaskSubArea", NULL},
- {TIFFTAG_RGBTABLES, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "RGBTables", NULL},
- {TIFFTAG_CALIBRATIONILLUMINANT3, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CalibrationIlluminant3", NULL},
- {TIFFTAG_COLORMATRIX3, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ColorMatrix3", NULL},
- {TIFFTAG_CAMERACALIBRATION3, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "CameraCalibration3", NULL},
- {TIFFTAG_REDUCTIONMATRIX3, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ReductionMatrix3", NULL},
- {TIFFTAG_PROFILEHUESATMAPDATA3, -1, -1, TIFF_FLOAT, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ProfileHueSatMapData3", NULL},
- {TIFFTAG_FORWARDMATRIX3, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ForwardMatrix3", NULL},
- {TIFFTAG_ILLUMINANTDATA1, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "IlluminantData1", NULL},
- {TIFFTAG_ILLUMINANTDATA2, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "IlluminantData2", NULL},
- {TIFFTAG_ILLUMINANTDATA3, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "IlluminantData3", NULL},
- /* end DNG tags */
-#endif
- /* begin TIFF/EP tags */
- {TIFFTAG_EP_CFAREPEATPATTERNDIM, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_C0_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP CFARepeatPatternDim", NULL},
- {TIFFTAG_EP_CFAPATTERN, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP CFAPattern", NULL},
-#if 0
- /* TIFFTAG_EP_BATTERYLEVEL can be RATIONAL or ASCII.
- * LibTiff defines it as ASCII and converts RATIONAL to an ASCII string. */
- {TIFFTAG_EP_BATTERYLEVEL, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP BatteryLevel", NULL},
- {TIFFTAG_EP_INTERLACE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP Interlace", NULL},
- /* TIFFTAG_EP_IPTC_NAA and TIFFTAG_RICHTIFFIPTC share the same tag number (33723)
- * LibTIFF type is UNDEFINED or BYTE, but often times incorrectly specified as LONG, because TIFF/EP (ISO/DIS 12234-2) specifies type LONG or ASCII. */
- {TIFFTAG_EP_TIMEZONEOFFSET, -1, -1, TIFF_SSHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP TimeZoneOffset", NULL},
- {TIFFTAG_EP_SELFTIMERMODE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP SelfTimerMode", NULL},
- {TIFFTAG_EP_FLASHENERGY, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP FlashEnergy", NULL},
- {TIFFTAG_EP_SPATIALFREQUENCYRESPONSE, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP SpatialFrequencyResponse", NULL},
- {TIFFTAG_EP_NOISE, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP Noise", NULL},
- {TIFFTAG_EP_FOCALPLANEXRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP FocalPlaneXResolution", NULL},
- {TIFFTAG_EP_FOCALPLANEYRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP FocalPlaneYResolution", NULL},
- {TIFFTAG_EP_FOCALPLANERESOLUTIONUNIT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP FocalPlaneResolutionUnit", NULL},
- {TIFFTAG_EP_IMAGENUMBER, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP ImageNumber", NULL}, /* or SHORT */
- {TIFFTAG_EP_SECURITYCLASSIFICATION, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP SecurityClassification", NULL},
- {TIFFTAG_EP_IMAGEHISTORY, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP ImageHistory", NULL},
- {TIFFTAG_EP_EXPOSUREINDEX, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP ExposureIndex", NULL},
- {TIFFTAG_EP_STANDARDID, 4, 4, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP StandardId", NULL},
- {TIFFTAG_EP_SENSINGMETHOD, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP SensingMethod", NULL},
- /* TIFF/EP tags equivalent to EXIF tags, sometimes defined differently. */
- {TIFFTAG_EP_EXPOSURETIME, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP ExposureTime", NULL}, /*N=1 or 2 */
- {TIFFTAG_EP_FNUMBER, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP FNumber", NULL},
- {TIFFTAG_EP_EXPOSUREPROGRAM, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP ExposureProgram", NULL},
- {TIFFTAG_EP_SPECTRALSENSITIVITY, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP SpectralSensitivity", NULL},
- {TIFFTAG_EP_ISOSPEEDRATINGS, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP ISOSpeedRatings", NULL},
- {TIFFTAG_EP_OECF, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP OptoelectricConversionFactor", NULL},
- {TIFFTAG_EP_DATETIMEORIGINAL, 20, 20, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP DateTimeOriginal", NULL},
- {TIFFTAG_EP_COMPRESSEDBITSPERPIXEL, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP CompressedBitsPerPixel", NULL},
- {TIFFTAG_EP_SHUTTERSPEEDVALUE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP ShutterSpeedValue", NULL},
- {TIFFTAG_EP_APERTUREVALUE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP ApertureValue", NULL},
- {TIFFTAG_EP_BRIGHTNESSVALUE, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP BrightnessValue", NULL},
- {TIFFTAG_EP_EXPOSUREBIASVALUE, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP ExposureBiasValue", NULL}, /*N=1 or 2 */
- {TIFFTAG_EP_MAXAPERTUREVALUE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP MaxApertureValue", NULL},
- {TIFFTAG_EP_SUBJECTDISTANCE, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP SubjectDistance", NULL},
- {TIFFTAG_EP_METERINGMODE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP MeteringMode", NULL},
- {TIFFTAG_EP_LIGHTSOURCE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP LightSource", NULL},
- {TIFFTAG_EP_FLASH, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP Flash", NULL},
- {TIFFTAG_EP_FOCALLENGTH, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP FocalLength", NULL},
- {TIFFTAG_EP_SUBJECTLOCATION, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP SubjectLocation", NULL},
- /* end TIFF/EP tags */
-#endif
- /* begin TIFF/FX tags */
- {TIFFTAG_INDEXED, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Indexed", NULL},
- {TIFFTAG_GLOBALPARAMETERSIFD, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_IFD8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "GlobalParametersIFD", NULL},
- {TIFFTAG_PROFILETYPE, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ProfileType", NULL},
- {TIFFTAG_FAXPROFILE, 1, 1, TIFF_BYTE, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FaxProfile", NULL},
- {TIFFTAG_CODINGMETHODS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CodingMethods", NULL},
- {TIFFTAG_VERSIONYEAR, 4, 4, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "VersionYear", NULL},
- {TIFFTAG_MODENUMBER, 1, 1, TIFF_BYTE, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ModeNumber", NULL},
- {TIFFTAG_DECODE, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "Decode", NULL},
- {TIFFTAG_IMAGEBASECOLOR, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ImageBaseColor", NULL},
- {TIFFTAG_T82OPTIONS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "T82Options", NULL},
- {TIFFTAG_STRIPROWCOUNTS, -1, -1, TIFF_LONG, 0, TIFF_SETGET_C16_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "StripRowCounts", NULL},
- {TIFFTAG_IMAGELAYER, 2, 2, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImageLayer", NULL},
- /* end TIFF/FX tags */
- /* begin pseudo tags */
-};
-
-/*
- * EXIF tags (Version 2.31, July 2016 plus version 2.32 May 2019)
- */
-static const TIFFField exifFields[] = {
- {EXIFTAG_EXPOSURETIME, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureTime", NULL},
- {EXIFTAG_FNUMBER, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FNumber", NULL},
- {EXIFTAG_EXPOSUREPROGRAM, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureProgram", NULL},
- {EXIFTAG_SPECTRALSENSITIVITY, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SpectralSensitivity", NULL},
- /* After EXIF 2.2.1 ISOSpeedRatings is named PhotographicSensitivity. In addition, while "Count=Any", only 1 count should be used. */
- {EXIFTAG_ISOSPEEDRATINGS, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ISOSpeedRatings", NULL},
- {EXIFTAG_OECF, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "OptoelectricConversionFactor", NULL},
- {EXIFTAG_SENSITIVITYTYPE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SensitivityType", NULL},
- {EXIFTAG_STANDARDOUTPUTSENSITIVITY, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "StandardOutputSensitivity", NULL},
- {EXIFTAG_RECOMMENDEDEXPOSUREINDEX, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "RecommendedExposureIndex", NULL},
- {EXIFTAG_ISOSPEED, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ISOSpeed", NULL},
- {EXIFTAG_ISOSPEEDLATITUDEYYY, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ISOSpeedLatitudeyyy", NULL},
- {EXIFTAG_ISOSPEEDLATITUDEZZZ, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ISOSpeedLatitudezzz", NULL},
- {EXIFTAG_EXIFVERSION, 4, 4, TIFF_UNDEFINED, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExifVersion", NULL},
- {EXIFTAG_DATETIMEORIGINAL, 20, 20, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DateTimeOriginal", NULL},
- {EXIFTAG_DATETIMEDIGITIZED, 20, 20, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DateTimeDigitized", NULL},
- {EXIFTAG_OFFSETTIME, 7, 7, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "OffsetTime", NULL},
- {EXIFTAG_OFFSETTIMEORIGINAL, 7, 7, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "OffsetTimeOriginal", NULL},
- {EXIFTAG_OFFSETTIMEDIGITIZED, 7, 7, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "OffsetTimeDigitized", NULL},
- {EXIFTAG_COMPONENTSCONFIGURATION, 4, 4, TIFF_UNDEFINED, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ComponentsConfiguration", NULL},
- {EXIFTAG_COMPRESSEDBITSPERPIXEL, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CompressedBitsPerPixel", NULL},
- {EXIFTAG_SHUTTERSPEEDVALUE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ShutterSpeedValue", NULL},
- {EXIFTAG_APERTUREVALUE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ApertureValue", NULL},
- {EXIFTAG_BRIGHTNESSVALUE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "BrightnessValue", NULL},
- {EXIFTAG_EXPOSUREBIASVALUE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureBiasValue", NULL},
- {EXIFTAG_MAXAPERTUREVALUE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MaxApertureValue", NULL},
- /*--: EXIFTAG_SUBJECTDISTANCE: LibTiff returns value of "-1" if numerator equals 4294967295 (0xFFFFFFFF) to indicate infinite distance!
- * However, there are two other EXIF tags where numerator indicates a special value and six other cases where the denominator indicates special values,
- * which are not treated within LibTiff!! */
- {EXIFTAG_SUBJECTDISTANCE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubjectDistance", NULL},
- {EXIFTAG_METERINGMODE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MeteringMode", NULL},
- {EXIFTAG_LIGHTSOURCE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "LightSource", NULL},
- {EXIFTAG_FLASH, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Flash", NULL},
- {EXIFTAG_FOCALLENGTH, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalLength", NULL},
- {EXIFTAG_SUBJECTAREA, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "SubjectArea", NULL},
- {EXIFTAG_MAKERNOTE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "MakerNote", NULL},
- {EXIFTAG_USERCOMMENT, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "UserComment", NULL},
- {EXIFTAG_SUBSECTIME, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubSecTime", NULL},
- {EXIFTAG_SUBSECTIMEORIGINAL, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubSecTimeOriginal", NULL},
- {EXIFTAG_SUBSECTIMEDIGITIZED, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubSecTimeDigitized", NULL},
- {EXIFTAG_TEMPERATURE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Temperature", NULL},
- {EXIFTAG_HUMIDITY, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Humidity", NULL},
- {EXIFTAG_PRESSURE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Pressure", NULL},
- {EXIFTAG_WATERDEPTH, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "WaterDepth", NULL},
- {EXIFTAG_ACCELERATION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Acceleration", NULL},
- {EXIFTAG_CAMERAELEVATIONANGLE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CameraElevationAngle", NULL},
- {EXIFTAG_FLASHPIXVERSION, 4, 4, TIFF_UNDEFINED, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FlashpixVersion", NULL},
- {EXIFTAG_COLORSPACE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ColorSpace", NULL},
- {EXIFTAG_PIXELXDIMENSION, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "PixelXDimension", NULL},
- {EXIFTAG_PIXELYDIMENSION, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "PixelYDimension", NULL},
- {EXIFTAG_RELATEDSOUNDFILE, 13, 13, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "RelatedSoundFile", NULL},
- {EXIFTAG_FLASHENERGY, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FlashEnergy", NULL},
- {EXIFTAG_SPATIALFREQUENCYRESPONSE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "SpatialFrequencyResponse", NULL},
- {EXIFTAG_FOCALPLANEXRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalPlaneXResolution", NULL},
- {EXIFTAG_FOCALPLANEYRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalPlaneYResolution", NULL},
- {EXIFTAG_FOCALPLANERESOLUTIONUNIT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalPlaneResolutionUnit", NULL},
- {EXIFTAG_SUBJECTLOCATION, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_C0_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubjectLocation", NULL},
- {EXIFTAG_EXPOSUREINDEX, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureIndex", NULL},
- {EXIFTAG_SENSINGMETHOD, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SensingMethod", NULL},
- {EXIFTAG_FILESOURCE, 1, 1, TIFF_UNDEFINED, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FileSource", NULL},
- {EXIFTAG_SCENETYPE, 1, 1, TIFF_UNDEFINED, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SceneType", NULL},
- {EXIFTAG_CFAPATTERN, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "CFAPattern", NULL},
- {EXIFTAG_CUSTOMRENDERED, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CustomRendered", NULL},
- {EXIFTAG_EXPOSUREMODE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureMode", NULL},
- {EXIFTAG_WHITEBALANCE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "WhiteBalance", NULL},
- {EXIFTAG_DIGITALZOOMRATIO, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DigitalZoomRatio", NULL},
- {EXIFTAG_FOCALLENGTHIN35MMFILM, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalLengthIn35mmFilm", NULL},
- {EXIFTAG_SCENECAPTURETYPE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SceneCaptureType", NULL},
- {EXIFTAG_GAINCONTROL, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "GainControl", NULL},
- {EXIFTAG_CONTRAST, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Contrast", NULL},
- {EXIFTAG_SATURATION, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Saturation", NULL},
- {EXIFTAG_SHARPNESS, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Sharpness", NULL},
- {EXIFTAG_DEVICESETTINGDESCRIPTION, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "DeviceSettingDescription", NULL},
- {EXIFTAG_SUBJECTDISTANCERANGE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubjectDistanceRange", NULL},
- {EXIFTAG_IMAGEUNIQUEID, 33, 33, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImageUniqueID", NULL},
- {EXIFTAG_CAMERAOWNERNAME, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CameraOwnerName", NULL},
- {EXIFTAG_BODYSERIALNUMBER, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "BodySerialNumber", NULL},
- {EXIFTAG_LENSSPECIFICATION, 4, 4, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "LensSpecification", NULL},
- {EXIFTAG_LENSMAKE, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "LensMake", NULL},
- {EXIFTAG_LENSMODEL, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "LensModel", NULL},
- {EXIFTAG_LENSSERIALNUMBER, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "LensSerialNumber", NULL},
- {EXIFTAG_GAMMA, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Gamma", NULL},
- {EXIFTAG_COMPOSITEIMAGE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CompositeImage", NULL},
- {EXIFTAG_SOURCEIMAGENUMBEROFCOMPOSITEIMAGE, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_C0_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SourceImageNumberOfCompositeImage", NULL},
- {EXIFTAG_SOURCEEXPOSURETIMESOFCOMPOSITEIMAGE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1,
- "SourceExposureTimesOfCompositeImage", NULL}};
-/*
- * EXIF-GPS tags (Version 2.31, July 2016; nothing changed for version 2.32 May
- * 2019)
- */
-
-static const TIFFField gpsFields[] = {
- /* For the GPS tag definitions in gpsFields[] the standard definition for Rationals is TIFF_SETGET_DOUBLE and TIFF_SETGET_C0_FLOAT.
- *-- ATTENTION: After the upgrade with Rational2Double, the GPSTAG values can now be written and also read in double precision!
- * In order to achieve double precision for GPS tags: Standard definitions for GPSTAG is kept to TIFF_SETGET_DOUBLE
- * and TIFF_SETGET_C0_FLOAT is changed to TIFF_SETGET_C0_DOUBLE.
- */
- {GPSTAG_VERSIONID, 4, 4, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UINT8, FIELD_CUSTOM, 1, 0, "VersionID", NULL},
- {GPSTAG_LATITUDEREF, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "LatitudeRef", NULL},
- {GPSTAG_LATITUDE, 3, 3, TIFF_RATIONAL, 0, TIFF_SETGET_C0_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Latitude", NULL},
- {GPSTAG_LONGITUDEREF, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "LongitudeRef", NULL},
- {GPSTAG_LONGITUDE, 3, 3, TIFF_RATIONAL, 0, TIFF_SETGET_C0_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Longitude", NULL},
- {GPSTAG_ALTITUDEREF, 1, 1, TIFF_BYTE, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "AltitudeRef", NULL},
- {GPSTAG_ALTITUDE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Altitude", NULL},
- {GPSTAG_TIMESTAMP, 3, 3, TIFF_RATIONAL, 0, TIFF_SETGET_C0_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "TimeStamp", NULL},
- {GPSTAG_SATELLITES, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Satellites", NULL},
- {GPSTAG_STATUS, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Status", NULL},
- {GPSTAG_MEASUREMODE, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MeasureMode", NULL},
- {GPSTAG_DOP, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DOP", NULL},
- {GPSTAG_SPEEDREF, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SpeedRef", NULL},
- {GPSTAG_SPEED, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Speed", NULL},
- {GPSTAG_TRACKREF, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "TrackRef", NULL},
- {GPSTAG_TRACK, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Track", NULL},
- {GPSTAG_IMGDIRECTIONREF, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImgDirectionRef", NULL},
- {GPSTAG_IMGDIRECTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImgDirection", NULL},
- {GPSTAG_MAPDATUM, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MapDatum", NULL},
- {GPSTAG_DESTLATITUDEREF, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DestLatitudeRef", NULL},
- {GPSTAG_DESTLATITUDE, 3, 3, TIFF_RATIONAL, 0, TIFF_SETGET_C0_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DestLatitude", NULL},
- {GPSTAG_DESTLONGITUDEREF, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DestLongitudeRef", NULL},
- {GPSTAG_DESTLONGITUDE, 3, 3, TIFF_RATIONAL, 0, TIFF_SETGET_C0_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DestLongitude", NULL},
- {GPSTAG_DESTBEARINGREF, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DestBearingRef", NULL},
- {GPSTAG_DESTBEARING, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DestBearing", NULL},
- {GPSTAG_DESTDISTANCEREF, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DestDistanceRef", NULL},
- {GPSTAG_DESTDISTANCE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DestDistance", NULL},
- {GPSTAG_PROCESSINGMETHOD, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ProcessingMethod", NULL},
- {GPSTAG_AREAINFORMATION, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "AreaInformation", NULL},
- {GPSTAG_DATESTAMP, 11, 11, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DateStamp", NULL},
- {GPSTAG_DIFFERENTIAL, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Differential", NULL},
- {GPSTAG_GPSHPOSITIONINGERROR, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "HorizontalPositioningError", NULL}};
-/* clang-format on */ /* was off for better readability of tag comments */
-
-static const TIFFFieldArray tiffFieldArray = {
- tfiatImage, 0, TIFFArrayCount(tiffFields), (TIFFField *)tiffFields};
-static const TIFFFieldArray exifFieldArray = {
- tfiatExif, 0, TIFFArrayCount(exifFields), (TIFFField *)exifFields};
-static const TIFFFieldArray gpsFieldArray = {
- tfiatGps, 0, TIFFArrayCount(gpsFields), (TIFFField *)gpsFields};
-
-/*
- * We have our own local lfind() equivalent to avoid subtle differences
- * in types passed to lfind() on different systems.
- */
-
-static void *td_lfind(const void *key, const void *base, size_t *nmemb,
- size_t size, int (*compar)(const void *, const void *))
-{
- char *element, *end;
-
- end = (char *)base + *nmemb * size;
- for (element = (char *)base; element < end; element += size)
- if (!compar(key, element)) /* key found */
- return element;
-
- return NULL;
-}
-
-const TIFFFieldArray *_TIFFGetFields(void) { return (&tiffFieldArray); }
-
-const TIFFFieldArray *_TIFFGetExifFields(void) { return (&exifFieldArray); }
-
-const TIFFFieldArray *_TIFFGetGpsFields(void) { return (&gpsFieldArray); }
-
-void _TIFFSetupFields(TIFF *tif, const TIFFFieldArray *fieldarray)
-{
- if (tif->tif_fields && tif->tif_nfields > 0)
- {
- uint32_t i;
-
- for (i = 0; i < tif->tif_nfields; i++)
- {
- TIFFField *fld = tif->tif_fields[i];
- if (fld->field_name != NULL)
- {
- if (fld->field_bit == FIELD_CUSTOM && TIFFFieldIsAnonymous(fld))
- {
- _TIFFfreeExt(tif, fld->field_name);
- /* caution: tif_fields[i] must not be the beginning of a
- * fields-array. Otherwise the following tags are also freed
- * with the first free().
- */
- _TIFFfreeExt(tif, fld);
- }
- }
- }
-
- _TIFFfreeExt(tif, tif->tif_fields);
- tif->tif_fields = NULL;
- tif->tif_nfields = 0;
- }
- if (!_TIFFMergeFields(tif, fieldarray->fields, fieldarray->count))
- {
- TIFFErrorExtR(tif, "_TIFFSetupFields", "Setting up field info failed");
- }
-}
-
-static int tagCompare(const void *a, const void *b)
-{
- const TIFFField *ta = *(const TIFFField **)a;
- const TIFFField *tb = *(const TIFFField **)b;
- /* NB: be careful of return values for 16-bit platforms */
- if (ta->field_tag != tb->field_tag)
- return (int)ta->field_tag - (int)tb->field_tag;
- else
- return (ta->field_type == TIFF_ANY)
- ? 0
- : ((int)tb->field_type - (int)ta->field_type);
-}
-
-static int tagNameCompare(const void *a, const void *b)
-{
- const TIFFField *ta = *(const TIFFField **)a;
- const TIFFField *tb = *(const TIFFField **)b;
- int ret = strcmp(ta->field_name, tb->field_name);
-
- if (ret)
- return ret;
- else
- return (ta->field_type == TIFF_ANY)
- ? 0
- : ((int)tb->field_type - (int)ta->field_type);
-}
-
-int _TIFFMergeFields(TIFF *tif, const TIFFField info[], uint32_t n)
-{
- static const char module[] = "_TIFFMergeFields";
- static const char reason[] = "for fields array";
- /* TIFFField** tp; */
- uint32_t i;
-
- tif->tif_foundfield = NULL;
-
- if (tif->tif_fields && tif->tif_nfields > 0)
- {
- tif->tif_fields = (TIFFField **)_TIFFCheckRealloc(
- tif, tif->tif_fields, (tif->tif_nfields + n), sizeof(TIFFField *),
- reason);
- }
- else
- {
- tif->tif_fields =
- (TIFFField **)_TIFFCheckMalloc(tif, n, sizeof(TIFFField *), reason);
- }
- if (!tif->tif_fields)
- {
- TIFFErrorExtR(tif, module, "Failed to allocate fields array");
- return 0;
- }
-
- /* tp = tif->tif_fields + tif->tif_nfields; */
- for (i = 0; i < n; i++)
- {
- const TIFFField *fip = TIFFFindField(tif, info[i].field_tag, TIFF_ANY);
-
- /* only add definitions that aren't already present */
- if (!fip)
- {
- tif->tif_fields[tif->tif_nfields] = (TIFFField *)(info + i);
- tif->tif_nfields++;
- }
- }
-
- /* Sort the field info by tag number */
- qsort(tif->tif_fields, tif->tif_nfields, sizeof(TIFFField *), tagCompare);
-
- return n;
-}
-
-void _TIFFPrintFieldInfo(TIFF *tif, FILE *fd)
-{
- uint32_t i;
-
- fprintf(fd, "%s: \n", tif->tif_name);
- for (i = 0; i < tif->tif_nfields; i++)
- {
- const TIFFField *fip = tif->tif_fields[i];
- fprintf(fd, "field[%2d] %5lu, %2d, %2d, %d, %2d, %5s, %5s, %s\n",
- (int)i, (unsigned long)fip->field_tag, fip->field_readcount,
- fip->field_writecount, fip->field_type, fip->field_bit,
- fip->field_oktochange ? "TRUE" : "FALSE",
- fip->field_passcount ? "TRUE" : "FALSE", fip->field_name);
- }
-}
-
-/*
- * Return size of TIFFDataType within TIFF-file in bytes
- */
-int TIFFDataWidth(TIFFDataType type)
-{
- switch (type)
- {
- case 0: /* nothing */
- case TIFF_BYTE:
- case TIFF_ASCII:
- case TIFF_SBYTE:
- case TIFF_UNDEFINED:
- return 1;
- case TIFF_SHORT:
- case TIFF_SSHORT:
- return 2;
- case TIFF_LONG:
- case TIFF_SLONG:
- case TIFF_FLOAT:
- case TIFF_IFD:
- return 4;
- case TIFF_RATIONAL:
- case TIFF_SRATIONAL:
- case TIFF_DOUBLE:
- case TIFF_LONG8:
- case TIFF_SLONG8:
- case TIFF_IFD8:
- return 8;
- default:
- return 0; /* will return 0 for unknown types */
- }
-}
-
-/*
- * Return internal storage size of TIFFSetGetFieldType in bytes.
- * TIFFSetField() and TIFFGetField() have to provide the parameter accordingly.
- * Replaces internal functions _TIFFDataSize() and _TIFFSetGetFieldSize()
- * with now extern available function TIFFFieldSetGetSize().
- */
-int TIFFFieldSetGetSize(const TIFFField *fip)
-{
- /*
- * TIFFSetField() and TIFFGetField() must provide the parameter accordingly
- * to the definition of "set_field_type" of the tag definition in
- * dir_info.c. This function returns the data size for that purpose.
- *
- * Furthermore, this data size is also used for the internal storage,
- * even for TIFF_RATIONAL values for FIELD_CUSTOM, which are stored
- * internally as 4-byte float, but some of them should be stored internally
- * as 8-byte double, depending on the "set_field_type" _FLOAT_ or _DOUBLE_.
- */
- if (fip == NULL)
- return 0;
-
- switch (fip->set_field_type)
- {
- case TIFF_SETGET_UNDEFINED:
- case TIFF_SETGET_ASCII:
- case TIFF_SETGET_C0_ASCII:
- case TIFF_SETGET_C16_ASCII:
- case TIFF_SETGET_C32_ASCII:
- case TIFF_SETGET_OTHER:
- return 1;
- case TIFF_SETGET_UINT8:
- case TIFF_SETGET_SINT8:
- case TIFF_SETGET_C0_UINT8:
- case TIFF_SETGET_C0_SINT8:
- case TIFF_SETGET_C16_UINT8:
- case TIFF_SETGET_C16_SINT8:
- case TIFF_SETGET_C32_UINT8:
- case TIFF_SETGET_C32_SINT8:
- return 1;
- case TIFF_SETGET_UINT16:
- case TIFF_SETGET_SINT16:
- case TIFF_SETGET_C0_UINT16:
- case TIFF_SETGET_C0_SINT16:
- case TIFF_SETGET_C16_UINT16:
- case TIFF_SETGET_C16_SINT16:
- case TIFF_SETGET_C32_UINT16:
- case TIFF_SETGET_C32_SINT16:
- return 2;
- case TIFF_SETGET_INT:
- case TIFF_SETGET_UINT32:
- case TIFF_SETGET_SINT32:
- case TIFF_SETGET_FLOAT:
- case TIFF_SETGET_UINT16_PAIR:
- case TIFF_SETGET_C0_UINT32:
- case TIFF_SETGET_C0_SINT32:
- case TIFF_SETGET_C0_FLOAT:
- case TIFF_SETGET_C16_UINT32:
- case TIFF_SETGET_C16_SINT32:
- case TIFF_SETGET_C16_FLOAT:
- case TIFF_SETGET_C32_UINT32:
- case TIFF_SETGET_C32_SINT32:
- case TIFF_SETGET_C32_FLOAT:
- return 4;
- case TIFF_SETGET_UINT64:
- case TIFF_SETGET_SINT64:
- case TIFF_SETGET_DOUBLE:
- case TIFF_SETGET_IFD8:
- case TIFF_SETGET_C0_UINT64:
- case TIFF_SETGET_C0_SINT64:
- case TIFF_SETGET_C0_DOUBLE:
- case TIFF_SETGET_C0_IFD8:
- case TIFF_SETGET_C16_UINT64:
- case TIFF_SETGET_C16_SINT64:
- case TIFF_SETGET_C16_DOUBLE:
- case TIFF_SETGET_C16_IFD8:
- case TIFF_SETGET_C32_UINT64:
- case TIFF_SETGET_C32_SINT64:
- case TIFF_SETGET_C32_DOUBLE:
- case TIFF_SETGET_C32_IFD8:
- return 8;
- default:
- return 0;
- }
-} /*-- TIFFFieldSetGetSize() --- */
-
-/*
- * Return size of count parameter of TIFFSetField() and TIFFGetField()
- * and also if it is required: 0=none, 2=uint16_t, 4=uint32_t
- */
-int TIFFFieldSetGetCountSize(const TIFFField *fip)
-{
- if (fip == NULL)
- return 0;
-
- switch (fip->set_field_type)
- {
- case TIFF_SETGET_C16_ASCII:
- case TIFF_SETGET_C16_UINT8:
- case TIFF_SETGET_C16_SINT8:
- case TIFF_SETGET_C16_UINT16:
- case TIFF_SETGET_C16_SINT16:
- case TIFF_SETGET_C16_UINT32:
- case TIFF_SETGET_C16_SINT32:
- case TIFF_SETGET_C16_FLOAT:
- case TIFF_SETGET_C16_UINT64:
- case TIFF_SETGET_C16_SINT64:
- case TIFF_SETGET_C16_DOUBLE:
- case TIFF_SETGET_C16_IFD8:
- return 2;
- case TIFF_SETGET_C32_ASCII:
- case TIFF_SETGET_C32_UINT8:
- case TIFF_SETGET_C32_SINT8:
- case TIFF_SETGET_C32_UINT16:
- case TIFF_SETGET_C32_SINT16:
- case TIFF_SETGET_C32_UINT32:
- case TIFF_SETGET_C32_SINT32:
- case TIFF_SETGET_C32_FLOAT:
- case TIFF_SETGET_C32_UINT64:
- case TIFF_SETGET_C32_SINT64:
- case TIFF_SETGET_C32_DOUBLE:
- case TIFF_SETGET_C32_IFD8:
- return 4;
- default:
- return 0;
- }
-} /*-- TIFFFieldSetGetCountSize() --- */
-
-const TIFFField *TIFFFindField(TIFF *tif, uint32_t tag, TIFFDataType dt)
-{
- TIFFField key = {0, 0, 0, TIFF_NOTYPE, 0, 0, 0, 0, 0, 0, NULL, NULL};
- TIFFField *pkey = &key;
- const TIFFField **ret;
- if (tif->tif_foundfield && tif->tif_foundfield->field_tag == tag &&
- (dt == TIFF_ANY || dt == tif->tif_foundfield->field_type))
- return tif->tif_foundfield;
-
- /* If we are invoked with no field information, then just return. */
- if (!tif->tif_fields)
- return NULL;
-
- /* NB: use sorted search (e.g. binary search) */
-
- key.field_tag = tag;
- key.field_type = dt;
-
- ret = (const TIFFField **)bsearch(&pkey, tif->tif_fields, tif->tif_nfields,
- sizeof(TIFFField *), tagCompare);
- return tif->tif_foundfield = (ret ? *ret : NULL);
-}
-
-static const TIFFField *_TIFFFindFieldByName(TIFF *tif, const char *field_name,
- TIFFDataType dt)
-{
- TIFFField key = {0, 0, 0, TIFF_NOTYPE, 0, 0, 0, 0, 0, 0, NULL, NULL};
- TIFFField *pkey = &key;
- const TIFFField **ret;
- if (tif->tif_foundfield &&
- streq(tif->tif_foundfield->field_name, field_name) &&
- (dt == TIFF_ANY || dt == tif->tif_foundfield->field_type))
- return (tif->tif_foundfield);
-
- /* If we are invoked with no field information, then just return. */
- if (!tif->tif_fields)
- return NULL;
-
- /* NB: use linear search since list is sorted by key#, not name */
-
- key.field_name = (char *)field_name;
- key.field_type = dt;
-
- ret =
- (const TIFFField **)td_lfind(&pkey, tif->tif_fields, &tif->tif_nfields,
- sizeof(TIFFField *), tagNameCompare);
-
- return tif->tif_foundfield = (ret ? *ret : NULL);
-}
-
-const TIFFField *TIFFFieldWithTag(TIFF *tif, uint32_t tag)
-{
- const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY);
- if (!fip)
- {
- TIFFWarningExtR(tif, "TIFFFieldWithTag", "Warning, unknown tag 0x%x",
- (unsigned int)tag);
- }
- return (fip);
-}
-
-const TIFFField *TIFFFieldWithName(TIFF *tif, const char *field_name)
-{
- const TIFFField *fip = _TIFFFindFieldByName(tif, field_name, TIFF_ANY);
- if (!fip)
- {
- TIFFWarningExtR(tif, "TIFFFieldWithName", "Warning, unknown tag %s",
- field_name);
- }
- return (fip);
-}
-
-uint32_t TIFFFieldTag(const TIFFField *fip) { return fip->field_tag; }
-
-const char *TIFFFieldName(const TIFFField *fip) { return fip->field_name; }
-
-TIFFDataType TIFFFieldDataType(const TIFFField *fip) { return fip->field_type; }
-
-int TIFFFieldPassCount(const TIFFField *fip) { return fip->field_passcount; }
-
-int TIFFFieldReadCount(const TIFFField *fip) { return fip->field_readcount; }
-
-int TIFFFieldWriteCount(const TIFFField *fip) { return fip->field_writecount; }
-
-int TIFFFieldIsAnonymous(const TIFFField *fip) { return fip->field_anonymous; }
-
-const TIFFField *_TIFFFindOrRegisterField(TIFF *tif, uint32_t tag,
- TIFFDataType dt)
-
-{
- const TIFFField *fld;
-
- fld = TIFFFindField(tif, tag, dt);
- if (fld == NULL)
- {
- fld = _TIFFCreateAnonField(tif, tag, dt);
- if (fld == NULL || !_TIFFMergeFields(tif, fld, 1))
- return NULL;
- }
-
- return fld;
-}
-
-TIFFField *_TIFFCreateAnonField(TIFF *tif, uint32_t tag,
- TIFFDataType field_type)
-{
- TIFFField *fld;
- (void)tif;
-
- fld = (TIFFField *)_TIFFmallocExt(tif, sizeof(TIFFField));
- if (fld == NULL)
- return NULL;
- _TIFFmemset(fld, 0, sizeof(TIFFField));
-
- fld->field_tag = tag;
- fld->field_readcount = TIFF_VARIABLE2;
- fld->field_writecount = TIFF_VARIABLE2;
- fld->field_type = field_type;
- fld->field_anonymous =
- 1; /* indicate that this is an anonymous / unknown tag */
- switch (field_type)
- {
- case TIFF_BYTE:
- case TIFF_UNDEFINED:
- fld->set_field_type = TIFF_SETGET_C32_UINT8;
- fld->get_field_type = TIFF_SETGET_C32_UINT8;
- break;
- case TIFF_ASCII:
- fld->set_field_type = TIFF_SETGET_C32_ASCII;
- fld->get_field_type = TIFF_SETGET_C32_ASCII;
- break;
- case TIFF_SHORT:
- fld->set_field_type = TIFF_SETGET_C32_UINT16;
- fld->get_field_type = TIFF_SETGET_C32_UINT16;
- break;
- case TIFF_LONG:
- fld->set_field_type = TIFF_SETGET_C32_UINT32;
- fld->get_field_type = TIFF_SETGET_C32_UINT32;
- break;
- case TIFF_RATIONAL:
- case TIFF_SRATIONAL:
- case TIFF_FLOAT:
- fld->set_field_type = TIFF_SETGET_C32_FLOAT;
- fld->get_field_type = TIFF_SETGET_C32_FLOAT;
- break;
- case TIFF_SBYTE:
- fld->set_field_type = TIFF_SETGET_C32_SINT8;
- fld->get_field_type = TIFF_SETGET_C32_SINT8;
- break;
- case TIFF_SSHORT:
- fld->set_field_type = TIFF_SETGET_C32_SINT16;
- fld->get_field_type = TIFF_SETGET_C32_SINT16;
- break;
- case TIFF_SLONG:
- fld->set_field_type = TIFF_SETGET_C32_SINT32;
- fld->get_field_type = TIFF_SETGET_C32_SINT32;
- break;
- case TIFF_DOUBLE:
- fld->set_field_type = TIFF_SETGET_C32_DOUBLE;
- fld->get_field_type = TIFF_SETGET_C32_DOUBLE;
- break;
- case TIFF_IFD:
- case TIFF_IFD8:
- fld->set_field_type = TIFF_SETGET_C32_IFD8;
- fld->get_field_type = TIFF_SETGET_C32_IFD8;
- break;
- case TIFF_LONG8:
- fld->set_field_type = TIFF_SETGET_C32_UINT64;
- fld->get_field_type = TIFF_SETGET_C32_UINT64;
- break;
- case TIFF_SLONG8:
- fld->set_field_type = TIFF_SETGET_C32_SINT64;
- fld->get_field_type = TIFF_SETGET_C32_SINT64;
- break;
- default:
- fld->set_field_type = TIFF_SETGET_UNDEFINED;
- fld->get_field_type = TIFF_SETGET_UNDEFINED;
- break;
- }
- fld->field_bit = FIELD_CUSTOM;
- fld->field_oktochange = TRUE;
- fld->field_passcount = TRUE;
- fld->field_name = (char *)_TIFFmallocExt(tif, 32);
- if (fld->field_name == NULL)
- {
- _TIFFfreeExt(tif, fld);
- return NULL;
- }
- fld->field_subfields = NULL;
-
- /*
- * note that this name is a special sign to TIFFClose() and
- * _TIFFSetupFields() to free the field
- * Update:
- * This special sign is replaced by fld->field_anonymous flag.
- */
- (void)snprintf(fld->field_name, 32, "Tag %d", (int)tag);
-
- return fld;
-}
-
-/****************************************************************************
- * O B S O L E T E D I N T E R F A C E S
- *
- * Don't use this stuff in your applications, it may be removed in the future
- * libtiff versions.
- ****************************************************************************/
-
-static TIFFSetGetFieldType _TIFFSetGetType(TIFFDataType type, short count,
- unsigned char passcount)
-{
- if (type == TIFF_ASCII && count == TIFF_VARIABLE && passcount == 0)
- return TIFF_SETGET_ASCII;
-
- else if (count == 1 && passcount == 0)
- {
- switch (type)
- {
- case TIFF_BYTE:
- case TIFF_UNDEFINED:
- return TIFF_SETGET_UINT8;
- case TIFF_ASCII:
- return TIFF_SETGET_ASCII;
- case TIFF_SHORT:
- return TIFF_SETGET_UINT16;
- case TIFF_LONG:
- return TIFF_SETGET_UINT32;
- case TIFF_RATIONAL:
- case TIFF_SRATIONAL:
- case TIFF_FLOAT:
- return TIFF_SETGET_FLOAT;
- case TIFF_SBYTE:
- return TIFF_SETGET_SINT8;
- case TIFF_SSHORT:
- return TIFF_SETGET_SINT16;
- case TIFF_SLONG:
- return TIFF_SETGET_SINT32;
- case TIFF_DOUBLE:
- return TIFF_SETGET_DOUBLE;
- case TIFF_IFD:
- case TIFF_IFD8:
- return TIFF_SETGET_IFD8;
- case TIFF_LONG8:
- return TIFF_SETGET_UINT64;
- case TIFF_SLONG8:
- return TIFF_SETGET_SINT64;
- default:
- return TIFF_SETGET_UNDEFINED;
- }
- }
-
- else if (count >= 1 && passcount == 0)
- {
- switch (type)
- {
- case TIFF_BYTE:
- case TIFF_UNDEFINED:
- return TIFF_SETGET_C0_UINT8;
- case TIFF_ASCII:
- return TIFF_SETGET_C0_ASCII;
- case TIFF_SHORT:
- return TIFF_SETGET_C0_UINT16;
- case TIFF_LONG:
- return TIFF_SETGET_C0_UINT32;
- case TIFF_RATIONAL:
- case TIFF_SRATIONAL:
- case TIFF_FLOAT:
- return TIFF_SETGET_C0_FLOAT;
- case TIFF_SBYTE:
- return TIFF_SETGET_C0_SINT8;
- case TIFF_SSHORT:
- return TIFF_SETGET_C0_SINT16;
- case TIFF_SLONG:
- return TIFF_SETGET_C0_SINT32;
- case TIFF_DOUBLE:
- return TIFF_SETGET_C0_DOUBLE;
- case TIFF_IFD:
- case TIFF_IFD8:
- return TIFF_SETGET_C0_IFD8;
- case TIFF_LONG8:
- return TIFF_SETGET_C0_UINT64;
- case TIFF_SLONG8:
- return TIFF_SETGET_C0_SINT64;
- default:
- return TIFF_SETGET_UNDEFINED;
- }
- }
-
- else if (count == TIFF_VARIABLE && passcount == 1)
- {
- switch (type)
- {
- case TIFF_BYTE:
- case TIFF_UNDEFINED:
- return TIFF_SETGET_C16_UINT8;
- case TIFF_ASCII:
- return TIFF_SETGET_C16_ASCII;
- case TIFF_SHORT:
- return TIFF_SETGET_C16_UINT16;
- case TIFF_LONG:
- return TIFF_SETGET_C16_UINT32;
- case TIFF_RATIONAL:
- case TIFF_SRATIONAL:
- case TIFF_FLOAT:
- return TIFF_SETGET_C16_FLOAT;
- case TIFF_SBYTE:
- return TIFF_SETGET_C16_SINT8;
- case TIFF_SSHORT:
- return TIFF_SETGET_C16_SINT16;
- case TIFF_SLONG:
- return TIFF_SETGET_C16_SINT32;
- case TIFF_DOUBLE:
- return TIFF_SETGET_C16_DOUBLE;
- case TIFF_IFD:
- case TIFF_IFD8:
- return TIFF_SETGET_C16_IFD8;
- case TIFF_LONG8:
- return TIFF_SETGET_C16_UINT64;
- case TIFF_SLONG8:
- return TIFF_SETGET_C16_SINT64;
- default:
- return TIFF_SETGET_UNDEFINED;
- }
- }
-
- else if (count == TIFF_VARIABLE2 && passcount == 1)
- {
- switch (type)
- {
- case TIFF_BYTE:
- case TIFF_UNDEFINED:
- return TIFF_SETGET_C32_UINT8;
- case TIFF_ASCII:
- return TIFF_SETGET_C32_ASCII;
- case TIFF_SHORT:
- return TIFF_SETGET_C32_UINT16;
- case TIFF_LONG:
- return TIFF_SETGET_C32_UINT32;
- case TIFF_RATIONAL:
- case TIFF_SRATIONAL:
- case TIFF_FLOAT:
- return TIFF_SETGET_C32_FLOAT;
- case TIFF_SBYTE:
- return TIFF_SETGET_C32_SINT8;
- case TIFF_SSHORT:
- return TIFF_SETGET_C32_SINT16;
- case TIFF_SLONG:
- return TIFF_SETGET_C32_SINT32;
- case TIFF_DOUBLE:
- return TIFF_SETGET_C32_DOUBLE;
- case TIFF_IFD:
- case TIFF_IFD8:
- return TIFF_SETGET_C32_IFD8;
- case TIFF_LONG8:
- return TIFF_SETGET_C32_UINT64;
- case TIFF_SLONG8:
- return TIFF_SETGET_C32_SINT64;
- default:
- return TIFF_SETGET_UNDEFINED;
- }
- }
-
- return TIFF_SETGET_UNDEFINED;
-}
-
-int TIFFMergeFieldInfo(TIFF *tif, const TIFFFieldInfo info[], uint32_t n)
-{
- static const char module[] = "TIFFMergeFieldInfo";
- static const char reason[] = "for fields array";
- TIFFField *tp;
- size_t nfields;
- uint32_t i;
-
- if (tif->tif_nfieldscompat > 0)
- {
- tif->tif_fieldscompat = (TIFFFieldArray *)_TIFFCheckRealloc(
- tif, tif->tif_fieldscompat, tif->tif_nfieldscompat + 1,
- sizeof(TIFFFieldArray), reason);
- }
- else
- {
- tif->tif_fieldscompat = (TIFFFieldArray *)_TIFFCheckMalloc(
- tif, 1, sizeof(TIFFFieldArray), reason);
- }
- if (!tif->tif_fieldscompat)
- {
- TIFFErrorExtR(tif, module, "Failed to allocate fields array");
- return -1;
- }
- nfields = tif->tif_nfieldscompat++;
-
- tif->tif_fieldscompat[nfields].type = tfiatOther;
- tif->tif_fieldscompat[nfields].allocated_size = n;
- tif->tif_fieldscompat[nfields].count = n;
- tif->tif_fieldscompat[nfields].fields =
- (TIFFField *)_TIFFCheckMalloc(tif, n, sizeof(TIFFField), reason);
- if (!tif->tif_fieldscompat[nfields].fields)
- {
- TIFFErrorExtR(tif, module, "Failed to allocate fields array");
- return -1;
- }
-
- tp = tif->tif_fieldscompat[nfields].fields;
- for (i = 0; i < n; i++)
- {
- tp->field_tag = info[i].field_tag;
- if (info[i].field_readcount < TIFF_VARIABLE2 ||
- info[i].field_readcount == 0 ||
- info[i].field_writecount < TIFF_VARIABLE2 ||
- info[i].field_writecount == 0)
- {
- /* The fields (field_readcount) and (field_writecount) may use the
- * values TIFF_VARIABLE (-1), TIFF_SPP (-2), TIFF_VARIABLE2 (-3). */
- TIFFErrorExtR(tif, module,
- "The value of field_readcount and field_writecount "
- "must be greater than or equal to -3 and not zero.");
- return -1;
- }
- tp->field_readcount = info[i].field_readcount;
- tp->field_writecount = info[i].field_writecount;
- tp->field_type = info[i].field_type;
- tp->field_anonymous = 0;
- tp->set_field_type =
- _TIFFSetGetType(info[i].field_type, info[i].field_writecount,
- info[i].field_passcount);
- tp->get_field_type =
- _TIFFSetGetType(info[i].field_type, info[i].field_readcount,
- info[i].field_passcount);
- tp->field_bit = info[i].field_bit;
- tp->field_oktochange = info[i].field_oktochange;
- tp->field_passcount = info[i].field_passcount;
- if (info[i].field_name == NULL)
- {
- TIFFErrorExtR(tif, module,
- "Field_name of %d.th allocation tag %d is NULL", i,
- info[i].field_tag);
- return -1;
- }
- tp->field_name = info[i].field_name;
- tp->field_subfields = NULL;
- tp++;
- }
-
- if (!_TIFFMergeFields(tif, tif->tif_fieldscompat[nfields].fields, n))
- {
- TIFFErrorExtR(tif, module, "Setting up field info failed");
- return -1;
- }
-
- return 0;
-}
-
-int _TIFFCheckFieldIsValidForCodec(TIFF *tif, ttag_t tag)
-{
- /* Filter out non-codec specific tags */
- switch (tag)
- {
- /* Shared tags */
- case TIFFTAG_PREDICTOR:
- /* JPEG tags */
- case TIFFTAG_JPEGTABLES:
- /* OJPEG tags */
- case TIFFTAG_JPEGIFOFFSET:
- case TIFFTAG_JPEGIFBYTECOUNT:
- case TIFFTAG_JPEGQTABLES:
- case TIFFTAG_JPEGDCTABLES:
- case TIFFTAG_JPEGACTABLES:
- case TIFFTAG_JPEGPROC:
- case TIFFTAG_JPEGRESTARTINTERVAL:
- /* CCITT* */
- case TIFFTAG_BADFAXLINES:
- case TIFFTAG_CLEANFAXDATA:
- case TIFFTAG_CONSECUTIVEBADFAXLINES:
- case TIFFTAG_GROUP3OPTIONS:
- case TIFFTAG_GROUP4OPTIONS:
- /* LERC */
- case TIFFTAG_LERC_PARAMETERS:
- break;
- default:
- return 1;
- }
- if (!TIFFIsCODECConfigured(tif->tif_dir.td_compression))
- {
- return 0;
- }
- /* Check if codec specific tags are allowed for the current
- * compression scheme (codec) */
- switch (tif->tif_dir.td_compression)
- {
- case COMPRESSION_LZW:
- if (tag == TIFFTAG_PREDICTOR)
- return 1;
- break;
- case COMPRESSION_PACKBITS:
- /* No codec-specific tags */
- break;
- case COMPRESSION_THUNDERSCAN:
- /* No codec-specific tags */
- break;
- case COMPRESSION_NEXT:
- /* No codec-specific tags */
- break;
- case COMPRESSION_JPEG:
- if (tag == TIFFTAG_JPEGTABLES)
- return 1;
- break;
- case COMPRESSION_OJPEG:
- switch (tag)
- {
- case TIFFTAG_JPEGIFOFFSET:
- case TIFFTAG_JPEGIFBYTECOUNT:
- case TIFFTAG_JPEGQTABLES:
- case TIFFTAG_JPEGDCTABLES:
- case TIFFTAG_JPEGACTABLES:
- case TIFFTAG_JPEGPROC:
- case TIFFTAG_JPEGRESTARTINTERVAL:
- return 1;
- }
- break;
- case COMPRESSION_CCITTRLE:
- case COMPRESSION_CCITTRLEW:
- case COMPRESSION_CCITTFAX3:
- case COMPRESSION_CCITTFAX4:
- switch (tag)
- {
- case TIFFTAG_BADFAXLINES:
- case TIFFTAG_CLEANFAXDATA:
- case TIFFTAG_CONSECUTIVEBADFAXLINES:
- return 1;
- case TIFFTAG_GROUP3OPTIONS:
- if (tif->tif_dir.td_compression == COMPRESSION_CCITTFAX3)
- return 1;
- break;
- case TIFFTAG_GROUP4OPTIONS:
- if (tif->tif_dir.td_compression == COMPRESSION_CCITTFAX4)
- return 1;
- break;
- }
- break;
- case COMPRESSION_JBIG:
- /* No codec-specific tags */
- break;
- case COMPRESSION_DEFLATE:
- case COMPRESSION_ADOBE_DEFLATE:
- if (tag == TIFFTAG_PREDICTOR)
- return 1;
- break;
- case COMPRESSION_PIXARLOG:
- if (tag == TIFFTAG_PREDICTOR)
- return 1;
- break;
- case COMPRESSION_SGILOG:
- case COMPRESSION_SGILOG24:
- /* No codec-specific tags */
- break;
- case COMPRESSION_LZMA:
- if (tag == TIFFTAG_PREDICTOR)
- return 1;
- break;
- case COMPRESSION_ZSTD:
- if (tag == TIFFTAG_PREDICTOR)
- return 1;
- break;
- case COMPRESSION_LERC:
- if (tag == TIFFTAG_LERC_PARAMETERS)
- return 1;
- break;
- }
- return 0;
-}
diff --git a/contrib/libs/libtiff/tif_dirread.c b/contrib/libs/libtiff/tif_dirread.c
deleted file mode 100644
index e079f23ed5..0000000000
--- a/contrib/libs/libtiff/tif_dirread.c
+++ /dev/null
@@ -1,8431 +0,0 @@
-/*
- * Copyright (c) 1988-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-/*
- * TIFF Library.
- *
- * Directory Read Support Routines.
- */
-
-/* Suggested pending improvements:
- * - add a field 'field_info' to the TIFFDirEntry structure, and set that with
- * the pointer to the appropriate TIFFField structure early on in
- * TIFFReadDirectory, so as to eliminate current possibly repetitive lookup.
- */
-
-#include "tiffconf.h"
-#include "tiffiop.h"
-#include <float.h>
-#include <limits.h>
-#include <stdlib.h>
-#include <string.h>
-
-#define FAILED_FII ((uint32_t)-1)
-
-#ifdef HAVE_IEEEFP
-#define TIFFCvtIEEEFloatToNative(tif, n, fp)
-#define TIFFCvtIEEEDoubleToNative(tif, n, dp)
-#else
-extern void TIFFCvtIEEEFloatToNative(TIFF *, uint32_t, float *);
-extern void TIFFCvtIEEEDoubleToNative(TIFF *, uint32_t, double *);
-#endif
-
-enum TIFFReadDirEntryErr
-{
- TIFFReadDirEntryErrOk = 0,
- TIFFReadDirEntryErrCount = 1,
- TIFFReadDirEntryErrType = 2,
- TIFFReadDirEntryErrIo = 3,
- TIFFReadDirEntryErrRange = 4,
- TIFFReadDirEntryErrPsdif = 5,
- TIFFReadDirEntryErrSizesan = 6,
- TIFFReadDirEntryErrAlloc = 7,
-};
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryByte(TIFF *tif, TIFFDirEntry *direntry, uint8_t *value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntrySbyte(TIFF *tif, TIFFDirEntry *direntry, int8_t *value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryShort(TIFF *tif, TIFFDirEntry *direntry, uint16_t *value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntrySshort(TIFF *tif, TIFFDirEntry *direntry, int16_t *value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryLong(TIFF *tif, TIFFDirEntry *direntry, uint32_t *value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntrySlong(TIFF *tif, TIFFDirEntry *direntry, int32_t *value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryLong8(TIFF *tif, TIFFDirEntry *direntry, uint64_t *value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntrySlong8(TIFF *tif, TIFFDirEntry *direntry, int64_t *value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryFloat(TIFF *tif, TIFFDirEntry *direntry, float *value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryDouble(TIFF *tif, TIFFDirEntry *direntry, double *value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryIfd8(TIFF *tif, TIFFDirEntry *direntry, uint64_t *value);
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryArray(TIFF *tif, TIFFDirEntry *direntry, uint32_t *count,
- uint32_t desttypesize, void **value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryByteArray(TIFF *tif, TIFFDirEntry *direntry, uint8_t **value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntrySbyteArray(TIFF *tif, TIFFDirEntry *direntry, int8_t **value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryShortArray(TIFF *tif, TIFFDirEntry *direntry, uint16_t **value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntrySshortArray(TIFF *tif, TIFFDirEntry *direntry, int16_t **value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryLongArray(TIFF *tif, TIFFDirEntry *direntry, uint32_t **value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntrySlongArray(TIFF *tif, TIFFDirEntry *direntry, int32_t **value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryLong8Array(TIFF *tif, TIFFDirEntry *direntry, uint64_t **value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntrySlong8Array(TIFF *tif, TIFFDirEntry *direntry, int64_t **value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryFloatArray(TIFF *tif, TIFFDirEntry *direntry, float **value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryDoubleArray(TIFF *tif, TIFFDirEntry *direntry, double **value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryIfd8Array(TIFF *tif, TIFFDirEntry *direntry, uint64_t **value);
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryPersampleShort(TIFF *tif, TIFFDirEntry *direntry,
- uint16_t *value);
-
-static void TIFFReadDirEntryCheckedByte(TIFF *tif, TIFFDirEntry *direntry,
- uint8_t *value);
-static void TIFFReadDirEntryCheckedSbyte(TIFF *tif, TIFFDirEntry *direntry,
- int8_t *value);
-static void TIFFReadDirEntryCheckedShort(TIFF *tif, TIFFDirEntry *direntry,
- uint16_t *value);
-static void TIFFReadDirEntryCheckedSshort(TIFF *tif, TIFFDirEntry *direntry,
- int16_t *value);
-static void TIFFReadDirEntryCheckedLong(TIFF *tif, TIFFDirEntry *direntry,
- uint32_t *value);
-static void TIFFReadDirEntryCheckedSlong(TIFF *tif, TIFFDirEntry *direntry,
- int32_t *value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckedLong8(TIFF *tif, TIFFDirEntry *direntry,
- uint64_t *value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckedSlong8(TIFF *tif, TIFFDirEntry *direntry,
- int64_t *value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckedRational(TIFF *tif, TIFFDirEntry *direntry,
- double *value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckedSrational(TIFF *tif, TIFFDirEntry *direntry,
- double *value);
-static void TIFFReadDirEntryCheckedFloat(TIFF *tif, TIFFDirEntry *direntry,
- float *value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckedDouble(TIFF *tif, TIFFDirEntry *direntry, double *value);
-#if 0
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckedRationalDirect(TIFF *tif, TIFFDirEntry *direntry,
- TIFFRational_t *value);
-#endif
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeByteSbyte(int8_t value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeByteShort(uint16_t value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeByteSshort(int16_t value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeByteLong(uint32_t value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeByteSlong(int32_t value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeByteLong8(uint64_t value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeByteSlong8(int64_t value);
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeSbyteByte(uint8_t value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeSbyteShort(uint16_t value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeSbyteSshort(int16_t value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeSbyteLong(uint32_t value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeSbyteSlong(int32_t value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeSbyteLong8(uint64_t value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeSbyteSlong8(int64_t value);
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeShortSbyte(int8_t value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeShortSshort(int16_t value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeShortLong(uint32_t value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeShortSlong(int32_t value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeShortLong8(uint64_t value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeShortSlong8(int64_t value);
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeSshortShort(uint16_t value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeSshortLong(uint32_t value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeSshortSlong(int32_t value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeSshortLong8(uint64_t value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeSshortSlong8(int64_t value);
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeLongSbyte(int8_t value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeLongSshort(int16_t value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeLongSlong(int32_t value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeLongLong8(uint64_t value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeLongSlong8(int64_t value);
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeSlongLong(uint32_t value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeSlongLong8(uint64_t value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeSlongSlong8(int64_t value);
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeLong8Sbyte(int8_t value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeLong8Sshort(int16_t value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeLong8Slong(int32_t value);
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeLong8Slong8(int64_t value);
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeSlong8Long8(uint64_t value);
-
-static enum TIFFReadDirEntryErr TIFFReadDirEntryData(TIFF *tif, uint64_t offset,
- tmsize_t size, void *dest);
-static void TIFFReadDirEntryOutputErr(TIFF *tif, enum TIFFReadDirEntryErr err,
- const char *module, const char *tagname,
- int recover);
-
-static void TIFFReadDirectoryCheckOrder(TIFF *tif, TIFFDirEntry *dir,
- uint16_t dircount);
-static TIFFDirEntry *TIFFReadDirectoryFindEntry(TIFF *tif, TIFFDirEntry *dir,
- uint16_t dircount,
- uint16_t tagid);
-static void TIFFReadDirectoryFindFieldInfo(TIFF *tif, uint16_t tagid,
- uint32_t *fii);
-
-static int EstimateStripByteCounts(TIFF *tif, TIFFDirEntry *dir,
- uint16_t dircount);
-static void MissingRequired(TIFF *, const char *);
-static int CheckDirCount(TIFF *, TIFFDirEntry *, uint32_t);
-static uint16_t TIFFFetchDirectory(TIFF *tif, uint64_t diroff,
- TIFFDirEntry **pdir, uint64_t *nextdiroff);
-static int TIFFFetchNormalTag(TIFF *, TIFFDirEntry *, int recover);
-static int TIFFFetchStripThing(TIFF *tif, TIFFDirEntry *dir, uint32_t nstrips,
- uint64_t **lpp);
-static int TIFFFetchSubjectDistance(TIFF *, TIFFDirEntry *);
-static void ChopUpSingleUncompressedStrip(TIFF *);
-static void TryChopUpUncompressedBigTiff(TIFF *);
-static uint64_t TIFFReadUInt64(const uint8_t *value);
-static int _TIFFGetMaxColorChannels(uint16_t photometric);
-
-static int _TIFFFillStrilesInternal(TIFF *tif, int loadStripByteCount);
-
-typedef union _UInt64Aligned_t
-{
- double d;
- uint64_t l;
- uint32_t i[2];
- uint16_t s[4];
- uint8_t c[8];
-} UInt64Aligned_t;
-
-/*
- Unaligned safe copy of a uint64_t value from an octet array.
-*/
-static uint64_t TIFFReadUInt64(const uint8_t *value)
-{
- UInt64Aligned_t result;
-
- result.c[0] = value[0];
- result.c[1] = value[1];
- result.c[2] = value[2];
- result.c[3] = value[3];
- result.c[4] = value[4];
- result.c[5] = value[5];
- result.c[6] = value[6];
- result.c[7] = value[7];
-
- return result.l;
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryByte(TIFF *tif, TIFFDirEntry *direntry, uint8_t *value)
-{
- enum TIFFReadDirEntryErr err;
- if (direntry->tdir_count != 1)
- return (TIFFReadDirEntryErrCount);
- switch (direntry->tdir_type)
- {
- case TIFF_BYTE:
- case TIFF_UNDEFINED: /* Support to read TIFF_UNDEFINED with
- field_readcount==1 */
- TIFFReadDirEntryCheckedByte(tif, direntry, value);
- return (TIFFReadDirEntryErrOk);
- case TIFF_SBYTE:
- {
- int8_t m;
- TIFFReadDirEntryCheckedSbyte(tif, direntry, &m);
- err = TIFFReadDirEntryCheckRangeByteSbyte(m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (uint8_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SHORT:
- {
- uint16_t m;
- TIFFReadDirEntryCheckedShort(tif, direntry, &m);
- err = TIFFReadDirEntryCheckRangeByteShort(m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (uint8_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SSHORT:
- {
- int16_t m;
- TIFFReadDirEntryCheckedSshort(tif, direntry, &m);
- err = TIFFReadDirEntryCheckRangeByteSshort(m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (uint8_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_LONG:
- {
- uint32_t m;
- TIFFReadDirEntryCheckedLong(tif, direntry, &m);
- err = TIFFReadDirEntryCheckRangeByteLong(m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (uint8_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SLONG:
- {
- int32_t m;
- TIFFReadDirEntryCheckedSlong(tif, direntry, &m);
- err = TIFFReadDirEntryCheckRangeByteSlong(m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (uint8_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_LONG8:
- {
- uint64_t m;
- err = TIFFReadDirEntryCheckedLong8(tif, direntry, &m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- err = TIFFReadDirEntryCheckRangeByteLong8(m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (uint8_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SLONG8:
- {
- int64_t m;
- err = TIFFReadDirEntryCheckedSlong8(tif, direntry, &m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- err = TIFFReadDirEntryCheckRangeByteSlong8(m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (uint8_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- default:
- return (TIFFReadDirEntryErrType);
- }
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntrySbyte(TIFF *tif, TIFFDirEntry *direntry, int8_t *value)
-{
- enum TIFFReadDirEntryErr err;
- if (direntry->tdir_count != 1)
- return (TIFFReadDirEntryErrCount);
- switch (direntry->tdir_type)
- {
- case TIFF_BYTE:
- case TIFF_UNDEFINED: /* Support to read TIFF_UNDEFINED with
- field_readcount==1 */
- {
- uint8_t m;
- TIFFReadDirEntryCheckedByte(tif, direntry, &m);
- err = TIFFReadDirEntryCheckRangeSbyteByte(m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (int8_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SBYTE:
- {
- TIFFReadDirEntryCheckedSbyte(tif, direntry, value);
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SHORT:
- {
- uint16_t m;
- TIFFReadDirEntryCheckedShort(tif, direntry, &m);
- err = TIFFReadDirEntryCheckRangeSbyteShort(m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (int8_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SSHORT:
- {
- int16_t m;
- TIFFReadDirEntryCheckedSshort(tif, direntry, &m);
- err = TIFFReadDirEntryCheckRangeSbyteSshort(m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (int8_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_LONG:
- {
- uint32_t m;
- TIFFReadDirEntryCheckedLong(tif, direntry, &m);
- err = TIFFReadDirEntryCheckRangeSbyteLong(m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (int8_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SLONG:
- {
- int32_t m;
- TIFFReadDirEntryCheckedSlong(tif, direntry, &m);
- err = TIFFReadDirEntryCheckRangeSbyteSlong(m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (int8_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_LONG8:
- {
- uint64_t m;
- err = TIFFReadDirEntryCheckedLong8(tif, direntry, &m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- err = TIFFReadDirEntryCheckRangeSbyteLong8(m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (int8_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SLONG8:
- {
- int64_t m;
- err = TIFFReadDirEntryCheckedSlong8(tif, direntry, &m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- err = TIFFReadDirEntryCheckRangeSbyteSlong8(m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (int8_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- default:
- return (TIFFReadDirEntryErrType);
- }
-} /*-- TIFFReadDirEntrySbyte() --*/
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryShort(TIFF *tif, TIFFDirEntry *direntry, uint16_t *value)
-{
- enum TIFFReadDirEntryErr err;
- if (direntry->tdir_count != 1)
- return (TIFFReadDirEntryErrCount);
- switch (direntry->tdir_type)
- {
- case TIFF_BYTE:
- {
- uint8_t m;
- TIFFReadDirEntryCheckedByte(tif, direntry, &m);
- *value = (uint16_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SBYTE:
- {
- int8_t m;
- TIFFReadDirEntryCheckedSbyte(tif, direntry, &m);
- err = TIFFReadDirEntryCheckRangeShortSbyte(m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (uint16_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SHORT:
- TIFFReadDirEntryCheckedShort(tif, direntry, value);
- return (TIFFReadDirEntryErrOk);
- case TIFF_SSHORT:
- {
- int16_t m;
- TIFFReadDirEntryCheckedSshort(tif, direntry, &m);
- err = TIFFReadDirEntryCheckRangeShortSshort(m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (uint16_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_LONG:
- {
- uint32_t m;
- TIFFReadDirEntryCheckedLong(tif, direntry, &m);
- err = TIFFReadDirEntryCheckRangeShortLong(m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (uint16_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SLONG:
- {
- int32_t m;
- TIFFReadDirEntryCheckedSlong(tif, direntry, &m);
- err = TIFFReadDirEntryCheckRangeShortSlong(m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (uint16_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_LONG8:
- {
- uint64_t m;
- err = TIFFReadDirEntryCheckedLong8(tif, direntry, &m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- err = TIFFReadDirEntryCheckRangeShortLong8(m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (uint16_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SLONG8:
- {
- int64_t m;
- err = TIFFReadDirEntryCheckedSlong8(tif, direntry, &m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- err = TIFFReadDirEntryCheckRangeShortSlong8(m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (uint16_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- default:
- return (TIFFReadDirEntryErrType);
- }
-} /*-- TIFFReadDirEntryShort() --*/
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntrySshort(TIFF *tif, TIFFDirEntry *direntry, int16_t *value)
-{
- enum TIFFReadDirEntryErr err;
- if (direntry->tdir_count != 1)
- return (TIFFReadDirEntryErrCount);
- switch (direntry->tdir_type)
- {
- case TIFF_BYTE:
- {
- uint8_t m;
- TIFFReadDirEntryCheckedByte(tif, direntry, &m);
- *value = (int16_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SBYTE:
- {
- int8_t m;
- TIFFReadDirEntryCheckedSbyte(tif, direntry, &m);
- *value = (int16_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SHORT:
- {
- uint16_t m;
- TIFFReadDirEntryCheckedShort(tif, direntry, &m);
- err = TIFFReadDirEntryCheckRangeSshortShort(m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (uint16_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SSHORT:
- TIFFReadDirEntryCheckedSshort(tif, direntry, value);
- return (TIFFReadDirEntryErrOk);
- case TIFF_LONG:
- {
- uint32_t m;
- TIFFReadDirEntryCheckedLong(tif, direntry, &m);
- err = TIFFReadDirEntryCheckRangeSshortLong(m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (int16_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SLONG:
- {
- int32_t m;
- TIFFReadDirEntryCheckedSlong(tif, direntry, &m);
- err = TIFFReadDirEntryCheckRangeSshortSlong(m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (int16_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_LONG8:
- {
- uint64_t m;
- err = TIFFReadDirEntryCheckedLong8(tif, direntry, &m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- err = TIFFReadDirEntryCheckRangeSshortLong8(m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (int16_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SLONG8:
- {
- int64_t m;
- err = TIFFReadDirEntryCheckedSlong8(tif, direntry, &m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- err = TIFFReadDirEntryCheckRangeSshortSlong8(m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (int16_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- default:
- return (TIFFReadDirEntryErrType);
- }
-} /*-- TIFFReadDirEntrySshort() --*/
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryLong(TIFF *tif, TIFFDirEntry *direntry, uint32_t *value)
-{
- enum TIFFReadDirEntryErr err;
- if (direntry->tdir_count != 1)
- return (TIFFReadDirEntryErrCount);
- switch (direntry->tdir_type)
- {
- case TIFF_BYTE:
- {
- uint8_t m;
- TIFFReadDirEntryCheckedByte(tif, direntry, &m);
- *value = (uint32_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SBYTE:
- {
- int8_t m;
- TIFFReadDirEntryCheckedSbyte(tif, direntry, &m);
- err = TIFFReadDirEntryCheckRangeLongSbyte(m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (uint32_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SHORT:
- {
- uint16_t m;
- TIFFReadDirEntryCheckedShort(tif, direntry, &m);
- *value = (uint32_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SSHORT:
- {
- int16_t m;
- TIFFReadDirEntryCheckedSshort(tif, direntry, &m);
- err = TIFFReadDirEntryCheckRangeLongSshort(m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (uint32_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_LONG:
- TIFFReadDirEntryCheckedLong(tif, direntry, value);
- return (TIFFReadDirEntryErrOk);
- case TIFF_SLONG:
- {
- int32_t m;
- TIFFReadDirEntryCheckedSlong(tif, direntry, &m);
- err = TIFFReadDirEntryCheckRangeLongSlong(m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (uint32_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_LONG8:
- {
- uint64_t m;
- err = TIFFReadDirEntryCheckedLong8(tif, direntry, &m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- err = TIFFReadDirEntryCheckRangeLongLong8(m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (uint32_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SLONG8:
- {
- int64_t m;
- err = TIFFReadDirEntryCheckedSlong8(tif, direntry, &m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- err = TIFFReadDirEntryCheckRangeLongSlong8(m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (uint32_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- default:
- return (TIFFReadDirEntryErrType);
- }
-} /*-- TIFFReadDirEntryLong() --*/
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntrySlong(TIFF *tif, TIFFDirEntry *direntry, int32_t *value)
-{
- enum TIFFReadDirEntryErr err;
- if (direntry->tdir_count != 1)
- return (TIFFReadDirEntryErrCount);
- switch (direntry->tdir_type)
- {
- case TIFF_BYTE:
- {
- uint8_t m;
- TIFFReadDirEntryCheckedByte(tif, direntry, &m);
- *value = (int32_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SBYTE:
- {
- int8_t m;
- TIFFReadDirEntryCheckedSbyte(tif, direntry, &m);
- *value = (int32_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SHORT:
- {
- uint16_t m;
- TIFFReadDirEntryCheckedShort(tif, direntry, &m);
- *value = (int32_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SSHORT:
- {
- int16_t m;
- TIFFReadDirEntryCheckedSshort(tif, direntry, &m);
- *value = (int32_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_LONG:
- {
- uint32_t m;
- TIFFReadDirEntryCheckedLong(tif, direntry, &m);
- err = TIFFReadDirEntryCheckRangeSlongLong(m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (int32_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SLONG:
- TIFFReadDirEntryCheckedSlong(tif, direntry, value);
- return (TIFFReadDirEntryErrOk);
- case TIFF_LONG8:
- {
- uint64_t m;
- err = TIFFReadDirEntryCheckedLong8(tif, direntry, &m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- err = TIFFReadDirEntryCheckRangeSlongLong8(m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (int32_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SLONG8:
- {
- int64_t m;
- err = TIFFReadDirEntryCheckedSlong8(tif, direntry, &m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- err = TIFFReadDirEntryCheckRangeSlongSlong8(m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (int32_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- default:
- return (TIFFReadDirEntryErrType);
- }
-} /*-- TIFFReadDirEntrySlong() --*/
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryLong8(TIFF *tif, TIFFDirEntry *direntry, uint64_t *value)
-{
- enum TIFFReadDirEntryErr err;
- if (direntry->tdir_count != 1)
- return (TIFFReadDirEntryErrCount);
- switch (direntry->tdir_type)
- {
- case TIFF_BYTE:
- {
- uint8_t m;
- TIFFReadDirEntryCheckedByte(tif, direntry, &m);
- *value = (uint64_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SBYTE:
- {
- int8_t m;
- TIFFReadDirEntryCheckedSbyte(tif, direntry, &m);
- err = TIFFReadDirEntryCheckRangeLong8Sbyte(m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (uint64_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SHORT:
- {
- uint16_t m;
- TIFFReadDirEntryCheckedShort(tif, direntry, &m);
- *value = (uint64_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SSHORT:
- {
- int16_t m;
- TIFFReadDirEntryCheckedSshort(tif, direntry, &m);
- err = TIFFReadDirEntryCheckRangeLong8Sshort(m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (uint64_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_LONG:
- {
- uint32_t m;
- TIFFReadDirEntryCheckedLong(tif, direntry, &m);
- *value = (uint64_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SLONG:
- {
- int32_t m;
- TIFFReadDirEntryCheckedSlong(tif, direntry, &m);
- err = TIFFReadDirEntryCheckRangeLong8Slong(m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (uint64_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_LONG8:
- err = TIFFReadDirEntryCheckedLong8(tif, direntry, value);
- return (err);
- case TIFF_SLONG8:
- {
- int64_t m;
- err = TIFFReadDirEntryCheckedSlong8(tif, direntry, &m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- err = TIFFReadDirEntryCheckRangeLong8Slong8(m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (uint64_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- default:
- return (TIFFReadDirEntryErrType);
- }
-} /*-- TIFFReadDirEntryLong8() --*/
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntrySlong8(TIFF *tif, TIFFDirEntry *direntry, int64_t *value)
-{
- enum TIFFReadDirEntryErr err;
- if (direntry->tdir_count != 1)
- return (TIFFReadDirEntryErrCount);
- switch (direntry->tdir_type)
- {
- case TIFF_BYTE:
- {
- uint8_t m;
- TIFFReadDirEntryCheckedByte(tif, direntry, &m);
- *value = (int64_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SBYTE:
- {
- int8_t m;
- TIFFReadDirEntryCheckedSbyte(tif, direntry, &m);
- *value = (int64_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SHORT:
- {
- uint16_t m;
- TIFFReadDirEntryCheckedShort(tif, direntry, &m);
- *value = (int64_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SSHORT:
- {
- int16_t m;
- TIFFReadDirEntryCheckedSshort(tif, direntry, &m);
- *value = (int64_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_LONG:
- {
- uint32_t m;
- TIFFReadDirEntryCheckedLong(tif, direntry, &m);
- *value = (int64_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SLONG:
- {
- int32_t m;
- TIFFReadDirEntryCheckedSlong(tif, direntry, &m);
- *value = (int64_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_LONG8:
- {
- uint64_t m;
- err = TIFFReadDirEntryCheckedLong8(tif, direntry, &m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- err = TIFFReadDirEntryCheckRangeSlong8Long8(m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (int64_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SLONG8:
- err = TIFFReadDirEntryCheckedSlong8(tif, direntry, value);
- return (err);
- default:
- return (TIFFReadDirEntryErrType);
- }
-} /*-- TIFFReadDirEntrySlong8() --*/
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryFloat(TIFF *tif, TIFFDirEntry *direntry, float *value)
-{
- enum TIFFReadDirEntryErr err;
- if (direntry->tdir_count != 1)
- return (TIFFReadDirEntryErrCount);
- switch (direntry->tdir_type)
- {
- case TIFF_BYTE:
- {
- uint8_t m;
- TIFFReadDirEntryCheckedByte(tif, direntry, &m);
- *value = (float)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SBYTE:
- {
- int8_t m;
- TIFFReadDirEntryCheckedSbyte(tif, direntry, &m);
- *value = (float)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SHORT:
- {
- uint16_t m;
- TIFFReadDirEntryCheckedShort(tif, direntry, &m);
- *value = (float)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SSHORT:
- {
- int16_t m;
- TIFFReadDirEntryCheckedSshort(tif, direntry, &m);
- *value = (float)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_LONG:
- {
- uint32_t m;
- TIFFReadDirEntryCheckedLong(tif, direntry, &m);
- *value = (float)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SLONG:
- {
- int32_t m;
- TIFFReadDirEntryCheckedSlong(tif, direntry, &m);
- *value = (float)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_LONG8:
- {
- uint64_t m;
- err = TIFFReadDirEntryCheckedLong8(tif, direntry, &m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (float)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SLONG8:
- {
- int64_t m;
- err = TIFFReadDirEntryCheckedSlong8(tif, direntry, &m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (float)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_RATIONAL:
- {
- double m;
- err = TIFFReadDirEntryCheckedRational(tif, direntry, &m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (float)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SRATIONAL:
- {
- double m;
- err = TIFFReadDirEntryCheckedSrational(tif, direntry, &m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (float)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_FLOAT:
- TIFFReadDirEntryCheckedFloat(tif, direntry, value);
- return (TIFFReadDirEntryErrOk);
- case TIFF_DOUBLE:
- {
- double m;
- err = TIFFReadDirEntryCheckedDouble(tif, direntry, &m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- if ((m > FLT_MAX) || (m < -FLT_MAX))
- return (TIFFReadDirEntryErrRange);
- *value = (float)m;
- return (TIFFReadDirEntryErrOk);
- }
- default:
- return (TIFFReadDirEntryErrType);
- }
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryDouble(TIFF *tif, TIFFDirEntry *direntry, double *value)
-{
- enum TIFFReadDirEntryErr err;
- if (direntry->tdir_count != 1)
- return (TIFFReadDirEntryErrCount);
- switch (direntry->tdir_type)
- {
- case TIFF_BYTE:
- {
- uint8_t m;
- TIFFReadDirEntryCheckedByte(tif, direntry, &m);
- *value = (double)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SBYTE:
- {
- int8_t m;
- TIFFReadDirEntryCheckedSbyte(tif, direntry, &m);
- *value = (double)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SHORT:
- {
- uint16_t m;
- TIFFReadDirEntryCheckedShort(tif, direntry, &m);
- *value = (double)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SSHORT:
- {
- int16_t m;
- TIFFReadDirEntryCheckedSshort(tif, direntry, &m);
- *value = (double)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_LONG:
- {
- uint32_t m;
- TIFFReadDirEntryCheckedLong(tif, direntry, &m);
- *value = (double)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SLONG:
- {
- int32_t m;
- TIFFReadDirEntryCheckedSlong(tif, direntry, &m);
- *value = (double)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_LONG8:
- {
- uint64_t m;
- err = TIFFReadDirEntryCheckedLong8(tif, direntry, &m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (double)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SLONG8:
- {
- int64_t m;
- err = TIFFReadDirEntryCheckedSlong8(tif, direntry, &m);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- *value = (double)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_RATIONAL:
- err = TIFFReadDirEntryCheckedRational(tif, direntry, value);
- return (err);
- case TIFF_SRATIONAL:
- err = TIFFReadDirEntryCheckedSrational(tif, direntry, value);
- return (err);
- case TIFF_FLOAT:
- {
- float m;
- TIFFReadDirEntryCheckedFloat(tif, direntry, &m);
- *value = (double)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_DOUBLE:
- err = TIFFReadDirEntryCheckedDouble(tif, direntry, value);
- return (err);
- default:
- return (TIFFReadDirEntryErrType);
- }
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryIfd8(TIFF *tif, TIFFDirEntry *direntry, uint64_t *value)
-{
- enum TIFFReadDirEntryErr err;
- if (direntry->tdir_count != 1)
- return (TIFFReadDirEntryErrCount);
- switch (direntry->tdir_type)
- {
- case TIFF_LONG:
- case TIFF_IFD:
- {
- uint32_t m;
- TIFFReadDirEntryCheckedLong(tif, direntry, &m);
- *value = (uint64_t)m;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_LONG8:
- case TIFF_IFD8:
- err = TIFFReadDirEntryCheckedLong8(tif, direntry, value);
- return (err);
- default:
- return (TIFFReadDirEntryErrType);
- }
-}
-
-#define INITIAL_THRESHOLD (1024 * 1024)
-#define THRESHOLD_MULTIPLIER 10
-#define MAX_THRESHOLD \
- (THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * \
- INITIAL_THRESHOLD)
-
-static enum TIFFReadDirEntryErr TIFFReadDirEntryDataAndRealloc(TIFF *tif,
- uint64_t offset,
- tmsize_t size,
- void **pdest)
-{
-#if SIZEOF_SIZE_T == 8
- tmsize_t threshold = INITIAL_THRESHOLD;
-#endif
- tmsize_t already_read = 0;
-
- assert(!isMapped(tif));
-
- if (!SeekOK(tif, offset))
- return (TIFFReadDirEntryErrIo);
-
- /* On 64 bit processes, read first a maximum of 1 MB, then 10 MB, etc */
- /* so as to avoid allocating too much memory in case the file is too */
- /* short. We could ask for the file size, but this might be */
- /* expensive with some I/O layers (think of reading a gzipped file) */
- /* Restrict to 64 bit processes, so as to avoid reallocs() */
- /* on 32 bit processes where virtual memory is scarce. */
- while (already_read < size)
- {
- void *new_dest;
- tmsize_t bytes_read;
- tmsize_t to_read = size - already_read;
-#if SIZEOF_SIZE_T == 8
- if (to_read >= threshold && threshold < MAX_THRESHOLD)
- {
- to_read = threshold;
- threshold *= THRESHOLD_MULTIPLIER;
- }
-#endif
-
- new_dest =
- (uint8_t *)_TIFFreallocExt(tif, *pdest, already_read + to_read);
- if (new_dest == NULL)
- {
- TIFFErrorExtR(tif, tif->tif_name,
- "Failed to allocate memory for %s "
- "(%" TIFF_SSIZE_FORMAT
- " elements of %" TIFF_SSIZE_FORMAT " bytes each)",
- "TIFFReadDirEntryArray", (tmsize_t)1,
- already_read + to_read);
- return TIFFReadDirEntryErrAlloc;
- }
- *pdest = new_dest;
-
- bytes_read = TIFFReadFile(tif, (char *)*pdest + already_read, to_read);
- already_read += bytes_read;
- if (bytes_read != to_read)
- {
- return TIFFReadDirEntryErrIo;
- }
- }
- return TIFFReadDirEntryErrOk;
-}
-
-/* Caution: if raising that value, make sure int32 / uint32 overflows can't
- * occur elsewhere */
-#define MAX_SIZE_TAG_DATA 2147483647U
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryArrayWithLimit(TIFF *tif, TIFFDirEntry *direntry,
- uint32_t *count, uint32_t desttypesize,
- void **value, uint64_t maxcount)
-{
- int typesize;
- uint32_t datasize;
- void *data;
- uint64_t target_count64;
- int original_datasize_clamped;
- typesize = TIFFDataWidth(direntry->tdir_type);
-
- target_count64 =
- (direntry->tdir_count > maxcount) ? maxcount : direntry->tdir_count;
-
- if ((target_count64 == 0) || (typesize == 0))
- {
- *value = 0;
- return (TIFFReadDirEntryErrOk);
- }
- (void)desttypesize;
-
- /* We just want to know if the original tag size is more than 4 bytes
- * (classic TIFF) or 8 bytes (BigTIFF)
- */
- original_datasize_clamped =
- ((direntry->tdir_count > 10) ? 10 : (int)direntry->tdir_count) *
- typesize;
-
- /*
- * As a sanity check, make sure we have no more than a 2GB tag array
- * in either the current data type or the dest data type. This also
- * avoids problems with overflow of tmsize_t on 32bit systems.
- */
- if ((uint64_t)(MAX_SIZE_TAG_DATA / typesize) < target_count64)
- return (TIFFReadDirEntryErrSizesan);
- if ((uint64_t)(MAX_SIZE_TAG_DATA / desttypesize) < target_count64)
- return (TIFFReadDirEntryErrSizesan);
-
- *count = (uint32_t)target_count64;
- datasize = (*count) * typesize;
- assert((tmsize_t)datasize > 0);
-
- if (datasize > 100 * 1024 * 1024)
- {
- /* Before allocating a huge amount of memory for corrupted files, check
- * if size of requested memory is not greater than file size.
- */
- const uint64_t filesize = TIFFGetFileSize(tif);
- if (datasize > filesize)
- {
- TIFFWarningExtR(tif, "ReadDirEntryArray",
- "Requested memory size for tag %d (0x%x) %" PRIu32
- " is greater than filesize %" PRIu64
- ". Memory not allocated, tag not read",
- direntry->tdir_tag, direntry->tdir_tag, datasize,
- filesize);
- return (TIFFReadDirEntryErrAlloc);
- }
- }
-
- if (isMapped(tif) && datasize > (uint64_t)tif->tif_size)
- return TIFFReadDirEntryErrIo;
-
- if (!isMapped(tif) && (((tif->tif_flags & TIFF_BIGTIFF) && datasize > 8) ||
- (!(tif->tif_flags & TIFF_BIGTIFF) && datasize > 4)))
- {
- data = NULL;
- }
- else
- {
- data = _TIFFCheckMalloc(tif, *count, typesize, "ReadDirEntryArray");
- if (data == 0)
- return (TIFFReadDirEntryErrAlloc);
- }
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- {
- /* Only the condition on original_datasize_clamped. The second
- * one is implied, but Coverity Scan cannot see it. */
- if (original_datasize_clamped <= 4 && datasize <= 4)
- _TIFFmemcpy(data, &direntry->tdir_offset, datasize);
- else
- {
- enum TIFFReadDirEntryErr err;
- uint32_t offset = direntry->tdir_offset.toff_long;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong(&offset);
- if (isMapped(tif))
- err = TIFFReadDirEntryData(tif, (uint64_t)offset,
- (tmsize_t)datasize, data);
- else
- err = TIFFReadDirEntryDataAndRealloc(tif, (uint64_t)offset,
- (tmsize_t)datasize, &data);
- if (err != TIFFReadDirEntryErrOk)
- {
- _TIFFfreeExt(tif, data);
- return (err);
- }
- }
- }
- else
- {
- /* See above comment for the Classic TIFF case */
- if (original_datasize_clamped <= 8 && datasize <= 8)
- _TIFFmemcpy(data, &direntry->tdir_offset, datasize);
- else
- {
- enum TIFFReadDirEntryErr err;
- uint64_t offset = direntry->tdir_offset.toff_long8;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8(&offset);
- if (isMapped(tif))
- err = TIFFReadDirEntryData(tif, (uint64_t)offset,
- (tmsize_t)datasize, data);
- else
- err = TIFFReadDirEntryDataAndRealloc(tif, (uint64_t)offset,
- (tmsize_t)datasize, &data);
- if (err != TIFFReadDirEntryErrOk)
- {
- _TIFFfreeExt(tif, data);
- return (err);
- }
- }
- }
- *value = data;
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryArray(TIFF *tif, TIFFDirEntry *direntry, uint32_t *count,
- uint32_t desttypesize, void **value)
-{
- return TIFFReadDirEntryArrayWithLimit(tif, direntry, count, desttypesize,
- value, ~((uint64_t)0));
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryByteArray(TIFF *tif, TIFFDirEntry *direntry, uint8_t **value)
-{
- enum TIFFReadDirEntryErr err;
- uint32_t count;
- void *origdata;
- uint8_t *data;
- switch (direntry->tdir_type)
- {
- case TIFF_ASCII:
- case TIFF_UNDEFINED:
- case TIFF_BYTE:
- case TIFF_SBYTE:
- case TIFF_SHORT:
- case TIFF_SSHORT:
- case TIFF_LONG:
- case TIFF_SLONG:
- case TIFF_LONG8:
- case TIFF_SLONG8:
- break;
- default:
- return (TIFFReadDirEntryErrType);
- }
- err = TIFFReadDirEntryArray(tif, direntry, &count, 1, &origdata);
- if ((err != TIFFReadDirEntryErrOk) || (origdata == 0))
- {
- *value = 0;
- return (err);
- }
- switch (direntry->tdir_type)
- {
- case TIFF_ASCII:
- case TIFF_UNDEFINED:
- case TIFF_BYTE:
- *value = (uint8_t *)origdata;
- return (TIFFReadDirEntryErrOk);
- case TIFF_SBYTE:
- {
- int8_t *m;
- uint32_t n;
- m = (int8_t *)origdata;
- for (n = 0; n < count; n++)
- {
- err = TIFFReadDirEntryCheckRangeByteSbyte(*m);
- if (err != TIFFReadDirEntryErrOk)
- {
- _TIFFfreeExt(tif, origdata);
- return (err);
- }
- m++;
- }
- *value = (uint8_t *)origdata;
- return (TIFFReadDirEntryErrOk);
- }
- }
- data = (uint8_t *)_TIFFmallocExt(tif, count);
- if (data == 0)
- {
- _TIFFfreeExt(tif, origdata);
- return (TIFFReadDirEntryErrAlloc);
- }
- switch (direntry->tdir_type)
- {
- case TIFF_SHORT:
- {
- uint16_t *ma;
- uint8_t *mb;
- uint32_t n;
- ma = (uint16_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabShort(ma);
- err = TIFFReadDirEntryCheckRangeByteShort(*ma);
- if (err != TIFFReadDirEntryErrOk)
- break;
- *mb++ = (uint8_t)(*ma++);
- }
- }
- break;
- case TIFF_SSHORT:
- {
- int16_t *ma;
- uint8_t *mb;
- uint32_t n;
- ma = (int16_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabShort((uint16_t *)ma);
- err = TIFFReadDirEntryCheckRangeByteSshort(*ma);
- if (err != TIFFReadDirEntryErrOk)
- break;
- *mb++ = (uint8_t)(*ma++);
- }
- }
- break;
- case TIFF_LONG:
- {
- uint32_t *ma;
- uint8_t *mb;
- uint32_t n;
- ma = (uint32_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong(ma);
- err = TIFFReadDirEntryCheckRangeByteLong(*ma);
- if (err != TIFFReadDirEntryErrOk)
- break;
- *mb++ = (uint8_t)(*ma++);
- }
- }
- break;
- case TIFF_SLONG:
- {
- int32_t *ma;
- uint8_t *mb;
- uint32_t n;
- ma = (int32_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong((uint32_t *)ma);
- err = TIFFReadDirEntryCheckRangeByteSlong(*ma);
- if (err != TIFFReadDirEntryErrOk)
- break;
- *mb++ = (uint8_t)(*ma++);
- }
- }
- break;
- case TIFF_LONG8:
- {
- uint64_t *ma;
- uint8_t *mb;
- uint32_t n;
- ma = (uint64_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8(ma);
- err = TIFFReadDirEntryCheckRangeByteLong8(*ma);
- if (err != TIFFReadDirEntryErrOk)
- break;
- *mb++ = (uint8_t)(*ma++);
- }
- }
- break;
- case TIFF_SLONG8:
- {
- int64_t *ma;
- uint8_t *mb;
- uint32_t n;
- ma = (int64_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8((uint64_t *)ma);
- err = TIFFReadDirEntryCheckRangeByteSlong8(*ma);
- if (err != TIFFReadDirEntryErrOk)
- break;
- *mb++ = (uint8_t)(*ma++);
- }
- }
- break;
- }
- _TIFFfreeExt(tif, origdata);
- if (err != TIFFReadDirEntryErrOk)
- {
- _TIFFfreeExt(tif, data);
- return (err);
- }
- *value = data;
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntrySbyteArray(TIFF *tif, TIFFDirEntry *direntry, int8_t **value)
-{
- enum TIFFReadDirEntryErr err;
- uint32_t count;
- void *origdata;
- int8_t *data;
- switch (direntry->tdir_type)
- {
- case TIFF_UNDEFINED:
- case TIFF_BYTE:
- case TIFF_SBYTE:
- case TIFF_SHORT:
- case TIFF_SSHORT:
- case TIFF_LONG:
- case TIFF_SLONG:
- case TIFF_LONG8:
- case TIFF_SLONG8:
- break;
- default:
- return (TIFFReadDirEntryErrType);
- }
- err = TIFFReadDirEntryArray(tif, direntry, &count, 1, &origdata);
- if ((err != TIFFReadDirEntryErrOk) || (origdata == 0))
- {
- *value = 0;
- return (err);
- }
- switch (direntry->tdir_type)
- {
- case TIFF_UNDEFINED:
- case TIFF_BYTE:
- {
- uint8_t *m;
- uint32_t n;
- m = (uint8_t *)origdata;
- for (n = 0; n < count; n++)
- {
- err = TIFFReadDirEntryCheckRangeSbyteByte(*m);
- if (err != TIFFReadDirEntryErrOk)
- {
- _TIFFfreeExt(tif, origdata);
- return (err);
- }
- m++;
- }
- *value = (int8_t *)origdata;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SBYTE:
- *value = (int8_t *)origdata;
- return (TIFFReadDirEntryErrOk);
- }
- data = (int8_t *)_TIFFmallocExt(tif, count);
- if (data == 0)
- {
- _TIFFfreeExt(tif, origdata);
- return (TIFFReadDirEntryErrAlloc);
- }
- switch (direntry->tdir_type)
- {
- case TIFF_SHORT:
- {
- uint16_t *ma;
- int8_t *mb;
- uint32_t n;
- ma = (uint16_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabShort(ma);
- err = TIFFReadDirEntryCheckRangeSbyteShort(*ma);
- if (err != TIFFReadDirEntryErrOk)
- break;
- *mb++ = (int8_t)(*ma++);
- }
- }
- break;
- case TIFF_SSHORT:
- {
- int16_t *ma;
- int8_t *mb;
- uint32_t n;
- ma = (int16_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabShort((uint16_t *)ma);
- err = TIFFReadDirEntryCheckRangeSbyteSshort(*ma);
- if (err != TIFFReadDirEntryErrOk)
- break;
- *mb++ = (int8_t)(*ma++);
- }
- }
- break;
- case TIFF_LONG:
- {
- uint32_t *ma;
- int8_t *mb;
- uint32_t n;
- ma = (uint32_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong(ma);
- err = TIFFReadDirEntryCheckRangeSbyteLong(*ma);
- if (err != TIFFReadDirEntryErrOk)
- break;
- *mb++ = (int8_t)(*ma++);
- }
- }
- break;
- case TIFF_SLONG:
- {
- int32_t *ma;
- int8_t *mb;
- uint32_t n;
- ma = (int32_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong((uint32_t *)ma);
- err = TIFFReadDirEntryCheckRangeSbyteSlong(*ma);
- if (err != TIFFReadDirEntryErrOk)
- break;
- *mb++ = (int8_t)(*ma++);
- }
- }
- break;
- case TIFF_LONG8:
- {
- uint64_t *ma;
- int8_t *mb;
- uint32_t n;
- ma = (uint64_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8(ma);
- err = TIFFReadDirEntryCheckRangeSbyteLong8(*ma);
- if (err != TIFFReadDirEntryErrOk)
- break;
- *mb++ = (int8_t)(*ma++);
- }
- }
- break;
- case TIFF_SLONG8:
- {
- int64_t *ma;
- int8_t *mb;
- uint32_t n;
- ma = (int64_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8((uint64_t *)ma);
- err = TIFFReadDirEntryCheckRangeSbyteSlong8(*ma);
- if (err != TIFFReadDirEntryErrOk)
- break;
- *mb++ = (int8_t)(*ma++);
- }
- }
- break;
- }
- _TIFFfreeExt(tif, origdata);
- if (err != TIFFReadDirEntryErrOk)
- {
- _TIFFfreeExt(tif, data);
- return (err);
- }
- *value = data;
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryShortArray(TIFF *tif, TIFFDirEntry *direntry, uint16_t **value)
-{
- enum TIFFReadDirEntryErr err;
- uint32_t count;
- void *origdata;
- uint16_t *data;
- switch (direntry->tdir_type)
- {
- case TIFF_BYTE:
- case TIFF_SBYTE:
- case TIFF_SHORT:
- case TIFF_SSHORT:
- case TIFF_LONG:
- case TIFF_SLONG:
- case TIFF_LONG8:
- case TIFF_SLONG8:
- break;
- default:
- return (TIFFReadDirEntryErrType);
- }
- err = TIFFReadDirEntryArray(tif, direntry, &count, 2, &origdata);
- if ((err != TIFFReadDirEntryErrOk) || (origdata == 0))
- {
- *value = 0;
- return (err);
- }
- switch (direntry->tdir_type)
- {
- case TIFF_SHORT:
- *value = (uint16_t *)origdata;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabArrayOfShort(*value, count);
- return (TIFFReadDirEntryErrOk);
- case TIFF_SSHORT:
- {
- int16_t *m;
- uint32_t n;
- m = (int16_t *)origdata;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabShort((uint16_t *)m);
- err = TIFFReadDirEntryCheckRangeShortSshort(*m);
- if (err != TIFFReadDirEntryErrOk)
- {
- _TIFFfreeExt(tif, origdata);
- return (err);
- }
- m++;
- }
- *value = (uint16_t *)origdata;
- return (TIFFReadDirEntryErrOk);
- }
- }
- data = (uint16_t *)_TIFFmallocExt(tif, count * 2);
- if (data == 0)
- {
- _TIFFfreeExt(tif, origdata);
- return (TIFFReadDirEntryErrAlloc);
- }
- switch (direntry->tdir_type)
- {
- case TIFF_BYTE:
- {
- uint8_t *ma;
- uint16_t *mb;
- uint32_t n;
- ma = (uint8_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- *mb++ = (uint16_t)(*ma++);
- }
- break;
- case TIFF_SBYTE:
- {
- int8_t *ma;
- uint16_t *mb;
- uint32_t n;
- ma = (int8_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- err = TIFFReadDirEntryCheckRangeShortSbyte(*ma);
- if (err != TIFFReadDirEntryErrOk)
- break;
- *mb++ = (uint16_t)(*ma++);
- }
- }
- break;
- case TIFF_LONG:
- {
- uint32_t *ma;
- uint16_t *mb;
- uint32_t n;
- ma = (uint32_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong(ma);
- err = TIFFReadDirEntryCheckRangeShortLong(*ma);
- if (err != TIFFReadDirEntryErrOk)
- break;
- *mb++ = (uint16_t)(*ma++);
- }
- }
- break;
- case TIFF_SLONG:
- {
- int32_t *ma;
- uint16_t *mb;
- uint32_t n;
- ma = (int32_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong((uint32_t *)ma);
- err = TIFFReadDirEntryCheckRangeShortSlong(*ma);
- if (err != TIFFReadDirEntryErrOk)
- break;
- *mb++ = (uint16_t)(*ma++);
- }
- }
- break;
- case TIFF_LONG8:
- {
- uint64_t *ma;
- uint16_t *mb;
- uint32_t n;
- ma = (uint64_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8(ma);
- err = TIFFReadDirEntryCheckRangeShortLong8(*ma);
- if (err != TIFFReadDirEntryErrOk)
- break;
- *mb++ = (uint16_t)(*ma++);
- }
- }
- break;
- case TIFF_SLONG8:
- {
- int64_t *ma;
- uint16_t *mb;
- uint32_t n;
- ma = (int64_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8((uint64_t *)ma);
- err = TIFFReadDirEntryCheckRangeShortSlong8(*ma);
- if (err != TIFFReadDirEntryErrOk)
- break;
- *mb++ = (uint16_t)(*ma++);
- }
- }
- break;
- }
- _TIFFfreeExt(tif, origdata);
- if (err != TIFFReadDirEntryErrOk)
- {
- _TIFFfreeExt(tif, data);
- return (err);
- }
- *value = data;
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntrySshortArray(TIFF *tif, TIFFDirEntry *direntry, int16_t **value)
-{
- enum TIFFReadDirEntryErr err;
- uint32_t count;
- void *origdata;
- int16_t *data;
- switch (direntry->tdir_type)
- {
- case TIFF_BYTE:
- case TIFF_SBYTE:
- case TIFF_SHORT:
- case TIFF_SSHORT:
- case TIFF_LONG:
- case TIFF_SLONG:
- case TIFF_LONG8:
- case TIFF_SLONG8:
- break;
- default:
- return (TIFFReadDirEntryErrType);
- }
- err = TIFFReadDirEntryArray(tif, direntry, &count, 2, &origdata);
- if ((err != TIFFReadDirEntryErrOk) || (origdata == 0))
- {
- *value = 0;
- return (err);
- }
- switch (direntry->tdir_type)
- {
- case TIFF_SHORT:
- {
- uint16_t *m;
- uint32_t n;
- m = (uint16_t *)origdata;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabShort(m);
- err = TIFFReadDirEntryCheckRangeSshortShort(*m);
- if (err != TIFFReadDirEntryErrOk)
- {
- _TIFFfreeExt(tif, origdata);
- return (err);
- }
- m++;
- }
- *value = (int16_t *)origdata;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SSHORT:
- *value = (int16_t *)origdata;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabArrayOfShort((uint16_t *)(*value), count);
- return (TIFFReadDirEntryErrOk);
- }
- data = (int16_t *)_TIFFmallocExt(tif, count * 2);
- if (data == 0)
- {
- _TIFFfreeExt(tif, origdata);
- return (TIFFReadDirEntryErrAlloc);
- }
- switch (direntry->tdir_type)
- {
- case TIFF_BYTE:
- {
- uint8_t *ma;
- int16_t *mb;
- uint32_t n;
- ma = (uint8_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- *mb++ = (int16_t)(*ma++);
- }
- break;
- case TIFF_SBYTE:
- {
- int8_t *ma;
- int16_t *mb;
- uint32_t n;
- ma = (int8_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- *mb++ = (int16_t)(*ma++);
- }
- break;
- case TIFF_LONG:
- {
- uint32_t *ma;
- int16_t *mb;
- uint32_t n;
- ma = (uint32_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong(ma);
- err = TIFFReadDirEntryCheckRangeSshortLong(*ma);
- if (err != TIFFReadDirEntryErrOk)
- break;
- *mb++ = (int16_t)(*ma++);
- }
- }
- break;
- case TIFF_SLONG:
- {
- int32_t *ma;
- int16_t *mb;
- uint32_t n;
- ma = (int32_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong((uint32_t *)ma);
- err = TIFFReadDirEntryCheckRangeSshortSlong(*ma);
- if (err != TIFFReadDirEntryErrOk)
- break;
- *mb++ = (int16_t)(*ma++);
- }
- }
- break;
- case TIFF_LONG8:
- {
- uint64_t *ma;
- int16_t *mb;
- uint32_t n;
- ma = (uint64_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8(ma);
- err = TIFFReadDirEntryCheckRangeSshortLong8(*ma);
- if (err != TIFFReadDirEntryErrOk)
- break;
- *mb++ = (int16_t)(*ma++);
- }
- }
- break;
- case TIFF_SLONG8:
- {
- int64_t *ma;
- int16_t *mb;
- uint32_t n;
- ma = (int64_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8((uint64_t *)ma);
- err = TIFFReadDirEntryCheckRangeSshortSlong8(*ma);
- if (err != TIFFReadDirEntryErrOk)
- break;
- *mb++ = (int16_t)(*ma++);
- }
- }
- break;
- }
- _TIFFfreeExt(tif, origdata);
- if (err != TIFFReadDirEntryErrOk)
- {
- _TIFFfreeExt(tif, data);
- return (err);
- }
- *value = data;
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryLongArray(TIFF *tif, TIFFDirEntry *direntry, uint32_t **value)
-{
- enum TIFFReadDirEntryErr err;
- uint32_t count;
- void *origdata;
- uint32_t *data;
- switch (direntry->tdir_type)
- {
- case TIFF_BYTE:
- case TIFF_SBYTE:
- case TIFF_SHORT:
- case TIFF_SSHORT:
- case TIFF_LONG:
- case TIFF_SLONG:
- case TIFF_LONG8:
- case TIFF_SLONG8:
- break;
- default:
- return (TIFFReadDirEntryErrType);
- }
- err = TIFFReadDirEntryArray(tif, direntry, &count, 4, &origdata);
- if ((err != TIFFReadDirEntryErrOk) || (origdata == 0))
- {
- *value = 0;
- return (err);
- }
- switch (direntry->tdir_type)
- {
- case TIFF_LONG:
- *value = (uint32_t *)origdata;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabArrayOfLong(*value, count);
- return (TIFFReadDirEntryErrOk);
- case TIFF_SLONG:
- {
- int32_t *m;
- uint32_t n;
- m = (int32_t *)origdata;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong((uint32_t *)m);
- err = TIFFReadDirEntryCheckRangeLongSlong(*m);
- if (err != TIFFReadDirEntryErrOk)
- {
- _TIFFfreeExt(tif, origdata);
- return (err);
- }
- m++;
- }
- *value = (uint32_t *)origdata;
- return (TIFFReadDirEntryErrOk);
- }
- }
- data = (uint32_t *)_TIFFmallocExt(tif, count * 4);
- if (data == 0)
- {
- _TIFFfreeExt(tif, origdata);
- return (TIFFReadDirEntryErrAlloc);
- }
- switch (direntry->tdir_type)
- {
- case TIFF_BYTE:
- {
- uint8_t *ma;
- uint32_t *mb;
- uint32_t n;
- ma = (uint8_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- *mb++ = (uint32_t)(*ma++);
- }
- break;
- case TIFF_SBYTE:
- {
- int8_t *ma;
- uint32_t *mb;
- uint32_t n;
- ma = (int8_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- err = TIFFReadDirEntryCheckRangeLongSbyte(*ma);
- if (err != TIFFReadDirEntryErrOk)
- break;
- *mb++ = (uint32_t)(*ma++);
- }
- }
- break;
- case TIFF_SHORT:
- {
- uint16_t *ma;
- uint32_t *mb;
- uint32_t n;
- ma = (uint16_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabShort(ma);
- *mb++ = (uint32_t)(*ma++);
- }
- }
- break;
- case TIFF_SSHORT:
- {
- int16_t *ma;
- uint32_t *mb;
- uint32_t n;
- ma = (int16_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabShort((uint16_t *)ma);
- err = TIFFReadDirEntryCheckRangeLongSshort(*ma);
- if (err != TIFFReadDirEntryErrOk)
- break;
- *mb++ = (uint32_t)(*ma++);
- }
- }
- break;
- case TIFF_LONG8:
- {
- uint64_t *ma;
- uint32_t *mb;
- uint32_t n;
- ma = (uint64_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8(ma);
- err = TIFFReadDirEntryCheckRangeLongLong8(*ma);
- if (err != TIFFReadDirEntryErrOk)
- break;
- *mb++ = (uint32_t)(*ma++);
- }
- }
- break;
- case TIFF_SLONG8:
- {
- int64_t *ma;
- uint32_t *mb;
- uint32_t n;
- ma = (int64_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8((uint64_t *)ma);
- err = TIFFReadDirEntryCheckRangeLongSlong8(*ma);
- if (err != TIFFReadDirEntryErrOk)
- break;
- *mb++ = (uint32_t)(*ma++);
- }
- }
- break;
- }
- _TIFFfreeExt(tif, origdata);
- if (err != TIFFReadDirEntryErrOk)
- {
- _TIFFfreeExt(tif, data);
- return (err);
- }
- *value = data;
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntrySlongArray(TIFF *tif, TIFFDirEntry *direntry, int32_t **value)
-{
- enum TIFFReadDirEntryErr err;
- uint32_t count;
- void *origdata;
- int32_t *data;
- switch (direntry->tdir_type)
- {
- case TIFF_BYTE:
- case TIFF_SBYTE:
- case TIFF_SHORT:
- case TIFF_SSHORT:
- case TIFF_LONG:
- case TIFF_SLONG:
- case TIFF_LONG8:
- case TIFF_SLONG8:
- break;
- default:
- return (TIFFReadDirEntryErrType);
- }
- err = TIFFReadDirEntryArray(tif, direntry, &count, 4, &origdata);
- if ((err != TIFFReadDirEntryErrOk) || (origdata == 0))
- {
- *value = 0;
- return (err);
- }
- switch (direntry->tdir_type)
- {
- case TIFF_LONG:
- {
- uint32_t *m;
- uint32_t n;
- m = (uint32_t *)origdata;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong((uint32_t *)m);
- err = TIFFReadDirEntryCheckRangeSlongLong(*m);
- if (err != TIFFReadDirEntryErrOk)
- {
- _TIFFfreeExt(tif, origdata);
- return (err);
- }
- m++;
- }
- *value = (int32_t *)origdata;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SLONG:
- *value = (int32_t *)origdata;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabArrayOfLong((uint32_t *)(*value), count);
- return (TIFFReadDirEntryErrOk);
- }
- data = (int32_t *)_TIFFmallocExt(tif, count * 4);
- if (data == 0)
- {
- _TIFFfreeExt(tif, origdata);
- return (TIFFReadDirEntryErrAlloc);
- }
- switch (direntry->tdir_type)
- {
- case TIFF_BYTE:
- {
- uint8_t *ma;
- int32_t *mb;
- uint32_t n;
- ma = (uint8_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- *mb++ = (int32_t)(*ma++);
- }
- break;
- case TIFF_SBYTE:
- {
- int8_t *ma;
- int32_t *mb;
- uint32_t n;
- ma = (int8_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- *mb++ = (int32_t)(*ma++);
- }
- break;
- case TIFF_SHORT:
- {
- uint16_t *ma;
- int32_t *mb;
- uint32_t n;
- ma = (uint16_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabShort(ma);
- *mb++ = (int32_t)(*ma++);
- }
- }
- break;
- case TIFF_SSHORT:
- {
- int16_t *ma;
- int32_t *mb;
- uint32_t n;
- ma = (int16_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabShort((uint16_t *)ma);
- *mb++ = (int32_t)(*ma++);
- }
- }
- break;
- case TIFF_LONG8:
- {
- uint64_t *ma;
- int32_t *mb;
- uint32_t n;
- ma = (uint64_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8(ma);
- err = TIFFReadDirEntryCheckRangeSlongLong8(*ma);
- if (err != TIFFReadDirEntryErrOk)
- break;
- *mb++ = (int32_t)(*ma++);
- }
- }
- break;
- case TIFF_SLONG8:
- {
- int64_t *ma;
- int32_t *mb;
- uint32_t n;
- ma = (int64_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8((uint64_t *)ma);
- err = TIFFReadDirEntryCheckRangeSlongSlong8(*ma);
- if (err != TIFFReadDirEntryErrOk)
- break;
- *mb++ = (int32_t)(*ma++);
- }
- }
- break;
- }
- _TIFFfreeExt(tif, origdata);
- if (err != TIFFReadDirEntryErrOk)
- {
- _TIFFfreeExt(tif, data);
- return (err);
- }
- *value = data;
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryLong8ArrayWithLimit(TIFF *tif, TIFFDirEntry *direntry,
- uint64_t **value, uint64_t maxcount)
-{
- enum TIFFReadDirEntryErr err;
- uint32_t count;
- void *origdata;
- uint64_t *data;
- switch (direntry->tdir_type)
- {
- case TIFF_BYTE:
- case TIFF_SBYTE:
- case TIFF_SHORT:
- case TIFF_SSHORT:
- case TIFF_LONG:
- case TIFF_SLONG:
- case TIFF_LONG8:
- case TIFF_SLONG8:
- break;
- default:
- return (TIFFReadDirEntryErrType);
- }
- err = TIFFReadDirEntryArrayWithLimit(tif, direntry, &count, 8, &origdata,
- maxcount);
- if ((err != TIFFReadDirEntryErrOk) || (origdata == 0))
- {
- *value = 0;
- return (err);
- }
- switch (direntry->tdir_type)
- {
- case TIFF_LONG8:
- *value = (uint64_t *)origdata;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabArrayOfLong8(*value, count);
- return (TIFFReadDirEntryErrOk);
- case TIFF_SLONG8:
- {
- int64_t *m;
- uint32_t n;
- m = (int64_t *)origdata;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8((uint64_t *)m);
- err = TIFFReadDirEntryCheckRangeLong8Slong8(*m);
- if (err != TIFFReadDirEntryErrOk)
- {
- _TIFFfreeExt(tif, origdata);
- return (err);
- }
- m++;
- }
- *value = (uint64_t *)origdata;
- return (TIFFReadDirEntryErrOk);
- }
- }
- data = (uint64_t *)_TIFFmallocExt(tif, count * 8);
- if (data == 0)
- {
- _TIFFfreeExt(tif, origdata);
- return (TIFFReadDirEntryErrAlloc);
- }
- switch (direntry->tdir_type)
- {
- case TIFF_BYTE:
- {
- uint8_t *ma;
- uint64_t *mb;
- uint32_t n;
- ma = (uint8_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- *mb++ = (uint64_t)(*ma++);
- }
- break;
- case TIFF_SBYTE:
- {
- int8_t *ma;
- uint64_t *mb;
- uint32_t n;
- ma = (int8_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- err = TIFFReadDirEntryCheckRangeLong8Sbyte(*ma);
- if (err != TIFFReadDirEntryErrOk)
- break;
- *mb++ = (uint64_t)(*ma++);
- }
- }
- break;
- case TIFF_SHORT:
- {
- uint16_t *ma;
- uint64_t *mb;
- uint32_t n;
- ma = (uint16_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabShort(ma);
- *mb++ = (uint64_t)(*ma++);
- }
- }
- break;
- case TIFF_SSHORT:
- {
- int16_t *ma;
- uint64_t *mb;
- uint32_t n;
- ma = (int16_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabShort((uint16_t *)ma);
- err = TIFFReadDirEntryCheckRangeLong8Sshort(*ma);
- if (err != TIFFReadDirEntryErrOk)
- break;
- *mb++ = (uint64_t)(*ma++);
- }
- }
- break;
- case TIFF_LONG:
- {
- uint32_t *ma;
- uint64_t *mb;
- uint32_t n;
- ma = (uint32_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong(ma);
- *mb++ = (uint64_t)(*ma++);
- }
- }
- break;
- case TIFF_SLONG:
- {
- int32_t *ma;
- uint64_t *mb;
- uint32_t n;
- ma = (int32_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong((uint32_t *)ma);
- err = TIFFReadDirEntryCheckRangeLong8Slong(*ma);
- if (err != TIFFReadDirEntryErrOk)
- break;
- *mb++ = (uint64_t)(*ma++);
- }
- }
- break;
- }
- _TIFFfreeExt(tif, origdata);
- if (err != TIFFReadDirEntryErrOk)
- {
- _TIFFfreeExt(tif, data);
- return (err);
- }
- *value = data;
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryLong8Array(TIFF *tif, TIFFDirEntry *direntry, uint64_t **value)
-{
- return TIFFReadDirEntryLong8ArrayWithLimit(tif, direntry, value,
- ~((uint64_t)0));
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntrySlong8Array(TIFF *tif, TIFFDirEntry *direntry, int64_t **value)
-{
- enum TIFFReadDirEntryErr err;
- uint32_t count;
- void *origdata;
- int64_t *data;
- switch (direntry->tdir_type)
- {
- case TIFF_BYTE:
- case TIFF_SBYTE:
- case TIFF_SHORT:
- case TIFF_SSHORT:
- case TIFF_LONG:
- case TIFF_SLONG:
- case TIFF_LONG8:
- case TIFF_SLONG8:
- break;
- default:
- return (TIFFReadDirEntryErrType);
- }
- err = TIFFReadDirEntryArray(tif, direntry, &count, 8, &origdata);
- if ((err != TIFFReadDirEntryErrOk) || (origdata == 0))
- {
- *value = 0;
- return (err);
- }
- switch (direntry->tdir_type)
- {
- case TIFF_LONG8:
- {
- uint64_t *m;
- uint32_t n;
- m = (uint64_t *)origdata;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8(m);
- err = TIFFReadDirEntryCheckRangeSlong8Long8(*m);
- if (err != TIFFReadDirEntryErrOk)
- {
- _TIFFfreeExt(tif, origdata);
- return (err);
- }
- m++;
- }
- *value = (int64_t *)origdata;
- return (TIFFReadDirEntryErrOk);
- }
- case TIFF_SLONG8:
- *value = (int64_t *)origdata;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabArrayOfLong8((uint64_t *)(*value), count);
- return (TIFFReadDirEntryErrOk);
- }
- data = (int64_t *)_TIFFmallocExt(tif, count * 8);
- if (data == 0)
- {
- _TIFFfreeExt(tif, origdata);
- return (TIFFReadDirEntryErrAlloc);
- }
- switch (direntry->tdir_type)
- {
- case TIFF_BYTE:
- {
- uint8_t *ma;
- int64_t *mb;
- uint32_t n;
- ma = (uint8_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- *mb++ = (int64_t)(*ma++);
- }
- break;
- case TIFF_SBYTE:
- {
- int8_t *ma;
- int64_t *mb;
- uint32_t n;
- ma = (int8_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- *mb++ = (int64_t)(*ma++);
- }
- break;
- case TIFF_SHORT:
- {
- uint16_t *ma;
- int64_t *mb;
- uint32_t n;
- ma = (uint16_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabShort(ma);
- *mb++ = (int64_t)(*ma++);
- }
- }
- break;
- case TIFF_SSHORT:
- {
- int16_t *ma;
- int64_t *mb;
- uint32_t n;
- ma = (int16_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabShort((uint16_t *)ma);
- *mb++ = (int64_t)(*ma++);
- }
- }
- break;
- case TIFF_LONG:
- {
- uint32_t *ma;
- int64_t *mb;
- uint32_t n;
- ma = (uint32_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong(ma);
- *mb++ = (int64_t)(*ma++);
- }
- }
- break;
- case TIFF_SLONG:
- {
- int32_t *ma;
- int64_t *mb;
- uint32_t n;
- ma = (int32_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong((uint32_t *)ma);
- *mb++ = (int64_t)(*ma++);
- }
- }
- break;
- }
- _TIFFfreeExt(tif, origdata);
- *value = data;
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryFloatArray(TIFF *tif, TIFFDirEntry *direntry, float **value)
-{
- enum TIFFReadDirEntryErr err;
- uint32_t count;
- void *origdata;
- float *data;
- switch (direntry->tdir_type)
- {
- case TIFF_BYTE:
- case TIFF_SBYTE:
- case TIFF_SHORT:
- case TIFF_SSHORT:
- case TIFF_LONG:
- case TIFF_SLONG:
- case TIFF_LONG8:
- case TIFF_SLONG8:
- case TIFF_RATIONAL:
- case TIFF_SRATIONAL:
- case TIFF_FLOAT:
- case TIFF_DOUBLE:
- break;
- default:
- return (TIFFReadDirEntryErrType);
- }
- err = TIFFReadDirEntryArray(tif, direntry, &count, 4, &origdata);
- if ((err != TIFFReadDirEntryErrOk) || (origdata == 0))
- {
- *value = 0;
- return (err);
- }
- switch (direntry->tdir_type)
- {
- case TIFF_FLOAT:
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabArrayOfLong((uint32_t *)origdata, count);
- TIFFCvtIEEEDoubleToNative(tif, count, (float *)origdata);
- *value = (float *)origdata;
- return (TIFFReadDirEntryErrOk);
- }
- data = (float *)_TIFFmallocExt(tif, count * sizeof(float));
- if (data == 0)
- {
- _TIFFfreeExt(tif, origdata);
- return (TIFFReadDirEntryErrAlloc);
- }
- switch (direntry->tdir_type)
- {
- case TIFF_BYTE:
- {
- uint8_t *ma;
- float *mb;
- uint32_t n;
- ma = (uint8_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- *mb++ = (float)(*ma++);
- }
- break;
- case TIFF_SBYTE:
- {
- int8_t *ma;
- float *mb;
- uint32_t n;
- ma = (int8_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- *mb++ = (float)(*ma++);
- }
- break;
- case TIFF_SHORT:
- {
- uint16_t *ma;
- float *mb;
- uint32_t n;
- ma = (uint16_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabShort(ma);
- *mb++ = (float)(*ma++);
- }
- }
- break;
- case TIFF_SSHORT:
- {
- int16_t *ma;
- float *mb;
- uint32_t n;
- ma = (int16_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabShort((uint16_t *)ma);
- *mb++ = (float)(*ma++);
- }
- }
- break;
- case TIFF_LONG:
- {
- uint32_t *ma;
- float *mb;
- uint32_t n;
- ma = (uint32_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong(ma);
- *mb++ = (float)(*ma++);
- }
- }
- break;
- case TIFF_SLONG:
- {
- int32_t *ma;
- float *mb;
- uint32_t n;
- ma = (int32_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong((uint32_t *)ma);
- *mb++ = (float)(*ma++);
- }
- }
- break;
- case TIFF_LONG8:
- {
- uint64_t *ma;
- float *mb;
- uint32_t n;
- ma = (uint64_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8(ma);
- *mb++ = (float)(*ma++);
- }
- }
- break;
- case TIFF_SLONG8:
- {
- int64_t *ma;
- float *mb;
- uint32_t n;
- ma = (int64_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8((uint64_t *)ma);
- *mb++ = (float)(*ma++);
- }
- }
- break;
- case TIFF_RATIONAL:
- {
- uint32_t *ma;
- uint32_t maa;
- uint32_t mab;
- float *mb;
- uint32_t n;
- ma = (uint32_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong(ma);
- maa = *ma++;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong(ma);
- mab = *ma++;
- if (mab == 0)
- *mb++ = 0.0;
- else
- *mb++ = (float)maa / (float)mab;
- }
- }
- break;
- case TIFF_SRATIONAL:
- {
- uint32_t *ma;
- int32_t maa;
- uint32_t mab;
- float *mb;
- uint32_t n;
- ma = (uint32_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong(ma);
- maa = *(int32_t *)ma;
- ma++;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong(ma);
- mab = *ma++;
- if (mab == 0)
- *mb++ = 0.0;
- else
- *mb++ = (float)maa / (float)mab;
- }
- }
- break;
- case TIFF_DOUBLE:
- {
- double *ma;
- float *mb;
- uint32_t n;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabArrayOfLong8((uint64_t *)origdata, count);
- TIFFCvtIEEEDoubleToNative(tif, count, (double *)origdata);
- ma = (double *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- double val = *ma++;
- if (val > FLT_MAX)
- val = FLT_MAX;
- else if (val < -FLT_MAX)
- val = -FLT_MAX;
- *mb++ = (float)val;
- }
- }
- break;
- }
- _TIFFfreeExt(tif, origdata);
- *value = data;
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryDoubleArray(TIFF *tif, TIFFDirEntry *direntry, double **value)
-{
- enum TIFFReadDirEntryErr err;
- uint32_t count;
- void *origdata;
- double *data;
- switch (direntry->tdir_type)
- {
- case TIFF_BYTE:
- case TIFF_SBYTE:
- case TIFF_SHORT:
- case TIFF_SSHORT:
- case TIFF_LONG:
- case TIFF_SLONG:
- case TIFF_LONG8:
- case TIFF_SLONG8:
- case TIFF_RATIONAL:
- case TIFF_SRATIONAL:
- case TIFF_FLOAT:
- case TIFF_DOUBLE:
- break;
- default:
- return (TIFFReadDirEntryErrType);
- }
- err = TIFFReadDirEntryArray(tif, direntry, &count, 8, &origdata);
- if ((err != TIFFReadDirEntryErrOk) || (origdata == 0))
- {
- *value = 0;
- return (err);
- }
- switch (direntry->tdir_type)
- {
- case TIFF_DOUBLE:
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabArrayOfLong8((uint64_t *)origdata, count);
- TIFFCvtIEEEDoubleToNative(tif, count, (double *)origdata);
- *value = (double *)origdata;
- return (TIFFReadDirEntryErrOk);
- }
- data = (double *)_TIFFmallocExt(tif, count * sizeof(double));
- if (data == 0)
- {
- _TIFFfreeExt(tif, origdata);
- return (TIFFReadDirEntryErrAlloc);
- }
- switch (direntry->tdir_type)
- {
- case TIFF_BYTE:
- {
- uint8_t *ma;
- double *mb;
- uint32_t n;
- ma = (uint8_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- *mb++ = (double)(*ma++);
- }
- break;
- case TIFF_SBYTE:
- {
- int8_t *ma;
- double *mb;
- uint32_t n;
- ma = (int8_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- *mb++ = (double)(*ma++);
- }
- break;
- case TIFF_SHORT:
- {
- uint16_t *ma;
- double *mb;
- uint32_t n;
- ma = (uint16_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabShort(ma);
- *mb++ = (double)(*ma++);
- }
- }
- break;
- case TIFF_SSHORT:
- {
- int16_t *ma;
- double *mb;
- uint32_t n;
- ma = (int16_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabShort((uint16_t *)ma);
- *mb++ = (double)(*ma++);
- }
- }
- break;
- case TIFF_LONG:
- {
- uint32_t *ma;
- double *mb;
- uint32_t n;
- ma = (uint32_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong(ma);
- *mb++ = (double)(*ma++);
- }
- }
- break;
- case TIFF_SLONG:
- {
- int32_t *ma;
- double *mb;
- uint32_t n;
- ma = (int32_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong((uint32_t *)ma);
- *mb++ = (double)(*ma++);
- }
- }
- break;
- case TIFF_LONG8:
- {
- uint64_t *ma;
- double *mb;
- uint32_t n;
- ma = (uint64_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8(ma);
- *mb++ = (double)(*ma++);
- }
- }
- break;
- case TIFF_SLONG8:
- {
- int64_t *ma;
- double *mb;
- uint32_t n;
- ma = (int64_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8((uint64_t *)ma);
- *mb++ = (double)(*ma++);
- }
- }
- break;
- case TIFF_RATIONAL:
- {
- uint32_t *ma;
- uint32_t maa;
- uint32_t mab;
- double *mb;
- uint32_t n;
- ma = (uint32_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong(ma);
- maa = *ma++;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong(ma);
- mab = *ma++;
- if (mab == 0)
- *mb++ = 0.0;
- else
- *mb++ = (double)maa / (double)mab;
- }
- }
- break;
- case TIFF_SRATIONAL:
- {
- uint32_t *ma;
- int32_t maa;
- uint32_t mab;
- double *mb;
- uint32_t n;
- ma = (uint32_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong(ma);
- maa = *(int32_t *)ma;
- ma++;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong(ma);
- mab = *ma++;
- if (mab == 0)
- *mb++ = 0.0;
- else
- *mb++ = (double)maa / (double)mab;
- }
- }
- break;
- case TIFF_FLOAT:
- {
- float *ma;
- double *mb;
- uint32_t n;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabArrayOfLong((uint32_t *)origdata, count);
- TIFFCvtIEEEFloatToNative(tif, count, (float *)origdata);
- ma = (float *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- *mb++ = (double)(*ma++);
- }
- break;
- }
- _TIFFfreeExt(tif, origdata);
- *value = data;
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryIfd8Array(TIFF *tif, TIFFDirEntry *direntry, uint64_t **value)
-{
- enum TIFFReadDirEntryErr err;
- uint32_t count;
- void *origdata;
- uint64_t *data;
- switch (direntry->tdir_type)
- {
- case TIFF_LONG:
- case TIFF_LONG8:
- case TIFF_IFD:
- case TIFF_IFD8:
- break;
- default:
- return (TIFFReadDirEntryErrType);
- }
- err = TIFFReadDirEntryArray(tif, direntry, &count, 8, &origdata);
- if ((err != TIFFReadDirEntryErrOk) || (origdata == 0))
- {
- *value = 0;
- return (err);
- }
- switch (direntry->tdir_type)
- {
- case TIFF_LONG8:
- case TIFF_IFD8:
- *value = (uint64_t *)origdata;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabArrayOfLong8(*value, count);
- return (TIFFReadDirEntryErrOk);
- }
- data = (uint64_t *)_TIFFmallocExt(tif, count * 8);
- if (data == 0)
- {
- _TIFFfreeExt(tif, origdata);
- return (TIFFReadDirEntryErrAlloc);
- }
- switch (direntry->tdir_type)
- {
- case TIFF_LONG:
- case TIFF_IFD:
- {
- uint32_t *ma;
- uint64_t *mb;
- uint32_t n;
- ma = (uint32_t *)origdata;
- mb = data;
- for (n = 0; n < count; n++)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong(ma);
- *mb++ = (uint64_t)(*ma++);
- }
- }
- break;
- }
- _TIFFfreeExt(tif, origdata);
- *value = data;
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryPersampleShort(TIFF *tif, TIFFDirEntry *direntry,
- uint16_t *value)
-{
- enum TIFFReadDirEntryErr err;
- uint16_t *m;
- uint16_t *na;
- uint16_t nb;
- if (direntry->tdir_count < (uint64_t)tif->tif_dir.td_samplesperpixel)
- return (TIFFReadDirEntryErrCount);
- err = TIFFReadDirEntryShortArray(tif, direntry, &m);
- if (err != TIFFReadDirEntryErrOk || m == NULL)
- return (err);
- na = m;
- nb = tif->tif_dir.td_samplesperpixel;
- *value = *na++;
- nb--;
- while (nb > 0)
- {
- if (*na++ != *value)
- {
- err = TIFFReadDirEntryErrPsdif;
- break;
- }
- nb--;
- }
- _TIFFfreeExt(tif, m);
- return (err);
-}
-
-static void TIFFReadDirEntryCheckedByte(TIFF *tif, TIFFDirEntry *direntry,
- uint8_t *value)
-{
- (void)tif;
- *value = *(uint8_t *)(&direntry->tdir_offset);
-}
-
-static void TIFFReadDirEntryCheckedSbyte(TIFF *tif, TIFFDirEntry *direntry,
- int8_t *value)
-{
- (void)tif;
- *value = *(int8_t *)(&direntry->tdir_offset);
-}
-
-static void TIFFReadDirEntryCheckedShort(TIFF *tif, TIFFDirEntry *direntry,
- uint16_t *value)
-{
- *value = direntry->tdir_offset.toff_short;
- /* *value=*(uint16_t*)(&direntry->tdir_offset); */
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabShort(value);
-}
-
-static void TIFFReadDirEntryCheckedSshort(TIFF *tif, TIFFDirEntry *direntry,
- int16_t *value)
-{
- *value = *(int16_t *)(&direntry->tdir_offset);
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabShort((uint16_t *)value);
-}
-
-static void TIFFReadDirEntryCheckedLong(TIFF *tif, TIFFDirEntry *direntry,
- uint32_t *value)
-{
- *value = *(uint32_t *)(&direntry->tdir_offset);
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong(value);
-}
-
-static void TIFFReadDirEntryCheckedSlong(TIFF *tif, TIFFDirEntry *direntry,
- int32_t *value)
-{
- *value = *(int32_t *)(&direntry->tdir_offset);
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong((uint32_t *)value);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckedLong8(TIFF *tif, TIFFDirEntry *direntry, uint64_t *value)
-{
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- {
- enum TIFFReadDirEntryErr err;
- uint32_t offset = direntry->tdir_offset.toff_long;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong(&offset);
- err = TIFFReadDirEntryData(tif, offset, 8, value);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- }
- else
- *value = direntry->tdir_offset.toff_long8;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8(value);
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckedSlong8(TIFF *tif, TIFFDirEntry *direntry, int64_t *value)
-{
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- {
- enum TIFFReadDirEntryErr err;
- uint32_t offset = direntry->tdir_offset.toff_long;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong(&offset);
- err = TIFFReadDirEntryData(tif, offset, 8, value);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- }
- else
- *value = *(int64_t *)(&direntry->tdir_offset);
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8((uint64_t *)value);
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckedRational(TIFF *tif, TIFFDirEntry *direntry,
- double *value)
-{
- UInt64Aligned_t m;
-
- assert(sizeof(double) == 8);
- assert(sizeof(uint64_t) == 8);
- assert(sizeof(uint32_t) == 4);
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- {
- enum TIFFReadDirEntryErr err;
- uint32_t offset = direntry->tdir_offset.toff_long;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong(&offset);
- err = TIFFReadDirEntryData(tif, offset, 8, m.i);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- }
- else
- m.l = direntry->tdir_offset.toff_long8;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabArrayOfLong(m.i, 2);
- /* Not completely sure what we should do when m.i[1]==0, but some */
- /* sanitizers do not like division by 0.0: */
- /* http://bugzilla.maptools.org/show_bug.cgi?id=2644 */
- if (m.i[0] == 0 || m.i[1] == 0)
- *value = 0.0;
- else
- *value = (double)m.i[0] / (double)m.i[1];
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckedSrational(TIFF *tif, TIFFDirEntry *direntry,
- double *value)
-{
- UInt64Aligned_t m;
- assert(sizeof(double) == 8);
- assert(sizeof(uint64_t) == 8);
- assert(sizeof(int32_t) == 4);
- assert(sizeof(uint32_t) == 4);
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- {
- enum TIFFReadDirEntryErr err;
- uint32_t offset = direntry->tdir_offset.toff_long;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong(&offset);
- err = TIFFReadDirEntryData(tif, offset, 8, m.i);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- }
- else
- m.l = direntry->tdir_offset.toff_long8;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabArrayOfLong(m.i, 2);
- /* Not completely sure what we should do when m.i[1]==0, but some */
- /* sanitizers do not like division by 0.0: */
- /* http://bugzilla.maptools.org/show_bug.cgi?id=2644 */
- if ((int32_t)m.i[0] == 0 || m.i[1] == 0)
- *value = 0.0;
- else
- *value = (double)((int32_t)m.i[0]) / (double)m.i[1];
- return (TIFFReadDirEntryErrOk);
-}
-
-#if 0
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckedRationalDirect(TIFF *tif, TIFFDirEntry *direntry,
- TIFFRational_t *value)
-{ /*--: SetGetRATIONAL_directly:_CustomTag: Read rational (and signed rationals)
- directly --*/
- UInt64Aligned_t m;
-
- assert(sizeof(double) == 8);
- assert(sizeof(uint64_t) == 8);
- assert(sizeof(uint32_t) == 4);
-
- if (direntry->tdir_count != 1)
- return (TIFFReadDirEntryErrCount);
-
- if (direntry->tdir_type != TIFF_RATIONAL &&
- direntry->tdir_type != TIFF_SRATIONAL)
- return (TIFFReadDirEntryErrType);
-
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- {
- enum TIFFReadDirEntryErr err;
- uint32_t offset = direntry->tdir_offset.toff_long;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong(&offset);
- err = TIFFReadDirEntryData(tif, offset, 8, m.i);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- }
- else
- {
- m.l = direntry->tdir_offset.toff_long8;
- }
-
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabArrayOfLong(m.i, 2);
-
- value->uNum = m.i[0];
- value->uDenom = m.i[1];
- return (TIFFReadDirEntryErrOk);
-} /*-- TIFFReadDirEntryCheckedRationalDirect() --*/
-#endif
-
-static void TIFFReadDirEntryCheckedFloat(TIFF *tif, TIFFDirEntry *direntry,
- float *value)
-{
- union
- {
- float f;
- uint32_t i;
- } float_union;
- assert(sizeof(float) == 4);
- assert(sizeof(uint32_t) == 4);
- assert(sizeof(float_union) == 4);
- float_union.i = *(uint32_t *)(&direntry->tdir_offset);
- *value = float_union.f;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong((uint32_t *)value);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckedDouble(TIFF *tif, TIFFDirEntry *direntry, double *value)
-{
- assert(sizeof(double) == 8);
- assert(sizeof(uint64_t) == 8);
- assert(sizeof(UInt64Aligned_t) == 8);
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- {
- enum TIFFReadDirEntryErr err;
- uint32_t offset = direntry->tdir_offset.toff_long;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong(&offset);
- err = TIFFReadDirEntryData(tif, offset, 8, value);
- if (err != TIFFReadDirEntryErrOk)
- return (err);
- }
- else
- {
- UInt64Aligned_t uint64_union;
- uint64_union.l = direntry->tdir_offset.toff_long8;
- *value = uint64_union.d;
- }
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8((uint64_t *)value);
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeByteSbyte(int8_t value)
-{
- if (value < 0)
- return (TIFFReadDirEntryErrRange);
- else
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeByteShort(uint16_t value)
-{
- if (value > 0xFF)
- return (TIFFReadDirEntryErrRange);
- else
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeByteSshort(int16_t value)
-{
- if ((value < 0) || (value > 0xFF))
- return (TIFFReadDirEntryErrRange);
- else
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeByteLong(uint32_t value)
-{
- if (value > 0xFF)
- return (TIFFReadDirEntryErrRange);
- else
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeByteSlong(int32_t value)
-{
- if ((value < 0) || (value > 0xFF))
- return (TIFFReadDirEntryErrRange);
- else
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeByteLong8(uint64_t value)
-{
- if (value > 0xFF)
- return (TIFFReadDirEntryErrRange);
- else
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeByteSlong8(int64_t value)
-{
- if ((value < 0) || (value > 0xFF))
- return (TIFFReadDirEntryErrRange);
- else
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeSbyteByte(uint8_t value)
-{
- if (value > 0x7F)
- return (TIFFReadDirEntryErrRange);
- else
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeSbyteShort(uint16_t value)
-{
- if (value > 0x7F)
- return (TIFFReadDirEntryErrRange);
- else
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeSbyteSshort(int16_t value)
-{
- if ((value < -0x80) || (value > 0x7F))
- return (TIFFReadDirEntryErrRange);
- else
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeSbyteLong(uint32_t value)
-{
- if (value > 0x7F)
- return (TIFFReadDirEntryErrRange);
- else
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeSbyteSlong(int32_t value)
-{
- if ((value < -0x80) || (value > 0x7F))
- return (TIFFReadDirEntryErrRange);
- else
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeSbyteLong8(uint64_t value)
-{
- if (value > 0x7F)
- return (TIFFReadDirEntryErrRange);
- else
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeSbyteSlong8(int64_t value)
-{
- if ((value < -0x80) || (value > 0x7F))
- return (TIFFReadDirEntryErrRange);
- else
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeShortSbyte(int8_t value)
-{
- if (value < 0)
- return (TIFFReadDirEntryErrRange);
- else
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeShortSshort(int16_t value)
-{
- if (value < 0)
- return (TIFFReadDirEntryErrRange);
- else
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeShortLong(uint32_t value)
-{
- if (value > 0xFFFF)
- return (TIFFReadDirEntryErrRange);
- else
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeShortSlong(int32_t value)
-{
- if ((value < 0) || (value > 0xFFFF))
- return (TIFFReadDirEntryErrRange);
- else
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeShortLong8(uint64_t value)
-{
- if (value > 0xFFFF)
- return (TIFFReadDirEntryErrRange);
- else
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeShortSlong8(int64_t value)
-{
- if ((value < 0) || (value > 0xFFFF))
- return (TIFFReadDirEntryErrRange);
- else
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeSshortShort(uint16_t value)
-{
- if (value > 0x7FFF)
- return (TIFFReadDirEntryErrRange);
- else
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeSshortLong(uint32_t value)
-{
- if (value > 0x7FFF)
- return (TIFFReadDirEntryErrRange);
- else
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeSshortSlong(int32_t value)
-{
- if ((value < -0x8000) || (value > 0x7FFF))
- return (TIFFReadDirEntryErrRange);
- else
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeSshortLong8(uint64_t value)
-{
- if (value > 0x7FFF)
- return (TIFFReadDirEntryErrRange);
- else
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeSshortSlong8(int64_t value)
-{
- if ((value < -0x8000) || (value > 0x7FFF))
- return (TIFFReadDirEntryErrRange);
- else
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeLongSbyte(int8_t value)
-{
- if (value < 0)
- return (TIFFReadDirEntryErrRange);
- else
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeLongSshort(int16_t value)
-{
- if (value < 0)
- return (TIFFReadDirEntryErrRange);
- else
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeLongSlong(int32_t value)
-{
- if (value < 0)
- return (TIFFReadDirEntryErrRange);
- else
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeLongLong8(uint64_t value)
-{
- if (value > UINT32_MAX)
- return (TIFFReadDirEntryErrRange);
- else
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeLongSlong8(int64_t value)
-{
- if ((value < 0) || (value > (int64_t)UINT32_MAX))
- return (TIFFReadDirEntryErrRange);
- else
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeSlongLong(uint32_t value)
-{
- if (value > 0x7FFFFFFFUL)
- return (TIFFReadDirEntryErrRange);
- else
- return (TIFFReadDirEntryErrOk);
-}
-
-/* Check that the 8-byte unsigned value can fit in a 4-byte unsigned range */
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeSlongLong8(uint64_t value)
-{
- if (value > 0x7FFFFFFF)
- return (TIFFReadDirEntryErrRange);
- else
- return (TIFFReadDirEntryErrOk);
-}
-
-/* Check that the 8-byte signed value can fit in a 4-byte signed range */
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeSlongSlong8(int64_t value)
-{
- if ((value < 0 - ((int64_t)0x7FFFFFFF + 1)) || (value > 0x7FFFFFFF))
- return (TIFFReadDirEntryErrRange);
- else
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeLong8Sbyte(int8_t value)
-{
- if (value < 0)
- return (TIFFReadDirEntryErrRange);
- else
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeLong8Sshort(int16_t value)
-{
- if (value < 0)
- return (TIFFReadDirEntryErrRange);
- else
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeLong8Slong(int32_t value)
-{
- if (value < 0)
- return (TIFFReadDirEntryErrRange);
- else
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeLong8Slong8(int64_t value)
-{
- if (value < 0)
- return (TIFFReadDirEntryErrRange);
- else
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr
-TIFFReadDirEntryCheckRangeSlong8Long8(uint64_t value)
-{
- if (value > INT64_MAX)
- return (TIFFReadDirEntryErrRange);
- else
- return (TIFFReadDirEntryErrOk);
-}
-
-static enum TIFFReadDirEntryErr TIFFReadDirEntryData(TIFF *tif, uint64_t offset,
- tmsize_t size, void *dest)
-{
- assert(size > 0);
- if (!isMapped(tif))
- {
- if (!SeekOK(tif, offset))
- return (TIFFReadDirEntryErrIo);
- if (!ReadOK(tif, dest, size))
- return (TIFFReadDirEntryErrIo);
- }
- else
- {
- size_t ma, mb;
- ma = (size_t)offset;
- if ((uint64_t)ma != offset || ma > (~(size_t)0) - (size_t)size)
- {
- return TIFFReadDirEntryErrIo;
- }
- mb = ma + size;
- if (mb > (uint64_t)tif->tif_size)
- return (TIFFReadDirEntryErrIo);
- _TIFFmemcpy(dest, tif->tif_base + ma, size);
- }
- return (TIFFReadDirEntryErrOk);
-}
-
-static void TIFFReadDirEntryOutputErr(TIFF *tif, enum TIFFReadDirEntryErr err,
- const char *module, const char *tagname,
- int recover)
-{
- if (!recover)
- {
- switch (err)
- {
- case TIFFReadDirEntryErrCount:
- TIFFErrorExtR(tif, module, "Incorrect count for \"%s\"",
- tagname);
- break;
- case TIFFReadDirEntryErrType:
- TIFFErrorExtR(tif, module, "Incompatible type for \"%s\"",
- tagname);
- break;
- case TIFFReadDirEntryErrIo:
- TIFFErrorExtR(tif, module, "IO error during reading of \"%s\"",
- tagname);
- break;
- case TIFFReadDirEntryErrRange:
- TIFFErrorExtR(tif, module, "Incorrect value for \"%s\"",
- tagname);
- break;
- case TIFFReadDirEntryErrPsdif:
- TIFFErrorExtR(
- tif, module,
- "Cannot handle different values per sample for \"%s\"",
- tagname);
- break;
- case TIFFReadDirEntryErrSizesan:
- TIFFErrorExtR(tif, module,
- "Sanity check on size of \"%s\" value failed",
- tagname);
- break;
- case TIFFReadDirEntryErrAlloc:
- TIFFErrorExtR(tif, module, "Out of memory reading of \"%s\"",
- tagname);
- break;
- default:
- assert(0); /* we should never get here */
- break;
- }
- }
- else
- {
- switch (err)
- {
- case TIFFReadDirEntryErrCount:
- TIFFWarningExtR(tif, module,
- "Incorrect count for \"%s\"; tag ignored",
- tagname);
- break;
- case TIFFReadDirEntryErrType:
- TIFFWarningExtR(tif, module,
- "Incompatible type for \"%s\"; tag ignored",
- tagname);
- break;
- case TIFFReadDirEntryErrIo:
- TIFFWarningExtR(
- tif, module,
- "IO error during reading of \"%s\"; tag ignored", tagname);
- break;
- case TIFFReadDirEntryErrRange:
- TIFFWarningExtR(tif, module,
- "Incorrect value for \"%s\"; tag ignored",
- tagname);
- break;
- case TIFFReadDirEntryErrPsdif:
- TIFFWarningExtR(tif, module,
- "Cannot handle different values per sample for "
- "\"%s\"; tag ignored",
- tagname);
- break;
- case TIFFReadDirEntryErrSizesan:
- TIFFWarningExtR(
- tif, module,
- "Sanity check on size of \"%s\" value failed; tag ignored",
- tagname);
- break;
- case TIFFReadDirEntryErrAlloc:
- TIFFWarningExtR(tif, module,
- "Out of memory reading of \"%s\"; tag ignored",
- tagname);
- break;
- default:
- assert(0); /* we should never get here */
- break;
- }
- }
-}
-
-/*
- * Return the maximum number of color channels specified for a given photometric
- * type. 0 is returned if photometric type isn't supported or no default value
- * is defined by the specification.
- */
-static int _TIFFGetMaxColorChannels(uint16_t photometric)
-{
- switch (photometric)
- {
- case PHOTOMETRIC_PALETTE:
- case PHOTOMETRIC_MINISWHITE:
- case PHOTOMETRIC_MINISBLACK:
- return 1;
- case PHOTOMETRIC_YCBCR:
- case PHOTOMETRIC_RGB:
- case PHOTOMETRIC_CIELAB:
- case PHOTOMETRIC_LOGLUV:
- case PHOTOMETRIC_ITULAB:
- case PHOTOMETRIC_ICCLAB:
- return 3;
- case PHOTOMETRIC_SEPARATED:
- case PHOTOMETRIC_MASK:
- return 4;
- case PHOTOMETRIC_LOGL:
- case PHOTOMETRIC_CFA:
- default:
- return 0;
- }
-}
-
-static int ByteCountLooksBad(TIFF *tif)
-{
- /*
- * Assume we have wrong StripByteCount value (in case
- * of single strip) in following cases:
- * - it is equal to zero along with StripOffset;
- * - it is larger than file itself (in case of uncompressed
- * image);
- * - it is smaller than the size of the bytes per row
- * multiplied on the number of rows. The last case should
- * not be checked in the case of writing new image,
- * because we may do not know the exact strip size
- * until the whole image will be written and directory
- * dumped out.
- */
- uint64_t bytecount = TIFFGetStrileByteCount(tif, 0);
- uint64_t offset = TIFFGetStrileOffset(tif, 0);
- uint64_t filesize;
-
- if (offset == 0)
- return 0;
- if (bytecount == 0)
- return 1;
- if (tif->tif_dir.td_compression != COMPRESSION_NONE)
- return 0;
- filesize = TIFFGetFileSize(tif);
- if (offset <= filesize && bytecount > filesize - offset)
- return 1;
- if (tif->tif_mode == O_RDONLY)
- {
- uint64_t scanlinesize = TIFFScanlineSize64(tif);
- if (tif->tif_dir.td_imagelength > 0 &&
- scanlinesize > UINT64_MAX / tif->tif_dir.td_imagelength)
- {
- return 1;
- }
- if (bytecount < scanlinesize * tif->tif_dir.td_imagelength)
- return 1;
- }
- return 0;
-}
-
-/*
- * To evaluate the IFD data size when reading, save the offset and data size of
- * all data that does not fit into the IFD entries themselves.
- */
-static bool EvaluateIFDdatasizeReading(TIFF *tif, TIFFDirEntry *dp)
-{
- const uint64_t data_width = TIFFDataWidth(dp->tdir_type);
- if (data_width != 0 && dp->tdir_count > UINT64_MAX / data_width)
- {
- TIFFErrorExtR(tif, "EvaluateIFDdatasizeReading",
- "Too large IFD data size");
- return false;
- }
- const uint64_t datalength = dp->tdir_count * data_width;
- if (datalength > ((tif->tif_flags & TIFF_BIGTIFF) ? 0x8U : 0x4U))
- {
- if (tif->tif_dir.td_dirdatasize_read > UINT64_MAX - datalength)
- {
- TIFFErrorExtR(tif, "EvaluateIFDdatasizeReading",
- "Too large IFD data size");
- return false;
- }
- tif->tif_dir.td_dirdatasize_read += datalength;
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- {
- /* The offset of TIFFDirEntry are not swapped when read in. That has
- * to be done when used. */
- uint32_t offset = dp->tdir_offset.toff_long;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong(&offset);
- tif->tif_dir
- .td_dirdatasize_offsets[tif->tif_dir.td_dirdatasize_Noffsets]
- .offset = (uint64_t)offset;
- }
- else
- {
- tif->tif_dir
- .td_dirdatasize_offsets[tif->tif_dir.td_dirdatasize_Noffsets]
- .offset = dp->tdir_offset.toff_long8;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8(
- &tif->tif_dir
- .td_dirdatasize_offsets[tif->tif_dir
- .td_dirdatasize_Noffsets]
- .offset);
- }
- tif->tif_dir
- .td_dirdatasize_offsets[tif->tif_dir.td_dirdatasize_Noffsets]
- .length = datalength;
- tif->tif_dir.td_dirdatasize_Noffsets++;
- }
- return true;
-}
-
-/*
- * Compare function for qsort() sorting TIFFEntryOffsetAndLength array entries.
- */
-static int cmpTIFFEntryOffsetAndLength(const void *a, const void *b)
-{
- const TIFFEntryOffsetAndLength *ta = (const TIFFEntryOffsetAndLength *)a;
- const TIFFEntryOffsetAndLength *tb = (const TIFFEntryOffsetAndLength *)b;
- /* Compare offsets */
- if (ta->offset > tb->offset)
- return 1;
- else if (ta->offset < tb->offset)
- return -1;
- else
- return 0;
-}
-
-/*
- * Determine the IFD data size after reading an IFD from the file that can be
- * overwritten and saving it in tif_dir.td_dirdatasize_read. This data size
- * includes the IFD entries themselves as well as the data that does not fit
- * directly into the IFD entries but is located directly after the IFD entries
- * in the file.
- */
-static void CalcFinalIFDdatasizeReading(TIFF *tif, uint16_t dircount)
-{
- /* IFD data size is only needed if file-writing is enabled.
- * This also avoids the seek() to EOF to determine the file size, which
- * causes the stdin-streaming-friendly mode of libtiff for GDAL to fail. */
- if (tif->tif_mode == O_RDONLY)
- return;
-
- /* Sort TIFFEntryOffsetAndLength array in ascending order. */
- qsort(tif->tif_dir.td_dirdatasize_offsets,
- tif->tif_dir.td_dirdatasize_Noffsets,
- sizeof(TIFFEntryOffsetAndLength), cmpTIFFEntryOffsetAndLength);
-
- /* Get offset of end of IFD entry space. */
- uint64_t IFDendoffset;
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- IFDendoffset = tif->tif_diroff + 2 + dircount * 12 + 4;
- else
- IFDendoffset = tif->tif_diroff + 8 + dircount * 20 + 8;
-
- /* Check which offsets are right behind IFD entries. However, LibTIFF
- * increments the writing address for every external data to an even offset.
- * Thus gaps of 1 byte can occur. */
- uint64_t size = 0;
- uint64_t offset;
- uint32_t i;
- for (i = 0; i < tif->tif_dir.td_dirdatasize_Noffsets; i++)
- {
- offset = tif->tif_dir.td_dirdatasize_offsets[i].offset;
- if (offset == IFDendoffset)
- {
- size += tif->tif_dir.td_dirdatasize_offsets[i].length;
- IFDendoffset += tif->tif_dir.td_dirdatasize_offsets[i].length;
- }
- else if (offset == IFDendoffset + 1)
- {
- /* Add gap byte after previous IFD data set. */
- size += tif->tif_dir.td_dirdatasize_offsets[i].length + 1;
- IFDendoffset += tif->tif_dir.td_dirdatasize_offsets[i].length;
- }
- else
- {
- /* Further data is no more continuously after IFD */
- break;
- }
- }
- /* Check for gap byte of some easy cases. This should cover 90% of cases.
- * Otherwise, IFD will be re-written even it might be safely overwritten. */
- if (tif->tif_nextdiroff != 0)
- {
- if (tif->tif_nextdiroff == IFDendoffset + 1)
- size++;
- }
- else
- {
- /* Check for IFD data ends at EOF. Then IFD can always be safely
- * overwritten. */
- offset = TIFFSeekFile(tif, 0, SEEK_END);
- if (offset == IFDendoffset)
- {
- tif->tif_dir.td_dirdatasize_read = UINT64_MAX;
- return;
- }
- }
-
- /* Finally, add the size of the IFD tag entries themselves. */
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- tif->tif_dir.td_dirdatasize_read = 2 + dircount * 12 + 4 + size;
- else
- tif->tif_dir.td_dirdatasize_read = 8 + dircount * 20 + 8 + size;
-} /*-- CalcFinalIFDdatasizeReading() --*/
-
-/*
- * Read the next TIFF directory from a file and convert it to the internal
- * format. We read directories sequentially.
- */
-int TIFFReadDirectory(TIFF *tif)
-{
- static const char module[] = "TIFFReadDirectory";
- TIFFDirEntry *dir;
- uint16_t dircount;
- TIFFDirEntry *dp;
- uint16_t di;
- const TIFFField *fip;
- uint32_t fii = FAILED_FII;
- toff_t nextdiroff;
- int bitspersample_read = FALSE;
- int color_channels;
-
- if (tif->tif_nextdiroff == 0)
- {
- /* In this special case, tif_diroff needs also to be set to 0.
- * This is behind the last IFD, thus no checking or reading necessary.
- */
- tif->tif_diroff = tif->tif_nextdiroff;
- return 0;
- }
-
- nextdiroff = tif->tif_nextdiroff;
- /* tif_curdir++ and tif_nextdiroff should only be updated after SUCCESSFUL
- * reading of the directory. Otherwise, invalid IFD offsets could corrupt
- * the IFD list. */
- if (!_TIFFCheckDirNumberAndOffset(tif,
- tif->tif_curdir ==
- TIFF_NON_EXISTENT_DIR_NUMBER
- ? 0
- : tif->tif_curdir + 1,
- nextdiroff))
- {
- return 0; /* bad offset (IFD looping or more than TIFF_MAX_DIR_COUNT
- IFDs) */
- }
- dircount = TIFFFetchDirectory(tif, nextdiroff, &dir, &tif->tif_nextdiroff);
- if (!dircount)
- {
- TIFFErrorExtR(tif, module,
- "Failed to read directory at offset %" PRIu64,
- nextdiroff);
- return 0;
- }
- /* Set global values after a valid directory has been fetched.
- * tif_diroff is already set to nextdiroff in TIFFFetchDirectory() in the
- * beginning. */
- if (tif->tif_curdir == TIFF_NON_EXISTENT_DIR_NUMBER)
- tif->tif_curdir = 0;
- else
- tif->tif_curdir++;
-
- TIFFReadDirectoryCheckOrder(tif, dir, dircount);
-
- /*
- * Mark duplicates of any tag to be ignored (bugzilla 1994)
- * to avoid certain pathological problems.
- */
- {
- TIFFDirEntry *ma;
- uint16_t mb;
- for (ma = dir, mb = 0; mb < dircount; ma++, mb++)
- {
- TIFFDirEntry *na;
- uint16_t nb;
- for (na = ma + 1, nb = mb + 1; nb < dircount; na++, nb++)
- {
- if (ma->tdir_tag == na->tdir_tag)
- {
- na->tdir_ignore = TRUE;
- }
- }
- }
- }
-
- tif->tif_flags &= ~TIFF_BEENWRITING; /* reset before new dir */
- tif->tif_flags &= ~TIFF_BUF4WRITE; /* reset before new dir */
- tif->tif_flags &= ~TIFF_CHOPPEDUPARRAYS;
-
- /* free any old stuff and reinit */
- (*tif->tif_cleanup)(tif); /* cleanup any previous compression state */
- TIFFFreeDirectory(tif);
- TIFFDefaultDirectory(tif);
-
- /* After setup a fresh directory indicate that now active IFD is also
- * present on file, even if its entries could not be read successfully
- * below. */
- tif->tif_dir.td_iswrittentofile = TRUE;
-
- /* Allocate arrays for offset values outside IFD entry for IFD data size
- * checking. Note: Counter are reset within TIFFFreeDirectory(). */
- tif->tif_dir.td_dirdatasize_offsets =
- (TIFFEntryOffsetAndLength *)_TIFFmallocExt(
- tif, dircount * sizeof(TIFFEntryOffsetAndLength));
- if (tif->tif_dir.td_dirdatasize_offsets == NULL)
- {
- TIFFErrorExtR(
- tif, module,
- "Failed to allocate memory for counting IFD data size at reading");
- goto bad;
- }
- /*
- * Electronic Arts writes gray-scale TIFF files
- * without a PlanarConfiguration directory entry.
- * Thus we setup a default value here, even though
- * the TIFF spec says there is no default value.
- * After PlanarConfiguration is preset in TIFFDefaultDirectory()
- * the following setting is not needed, but does not harm either.
- */
- TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
- /*
- * Setup default value and then make a pass over
- * the fields to check type and tag information,
- * and to extract info required to size data
- * structures. A second pass is made afterwards
- * to read in everything not taken in the first pass.
- * But we must process the Compression tag first
- * in order to merge in codec-private tag definitions (otherwise
- * we may get complaints about unknown tags). However, the
- * Compression tag may be dependent on the SamplesPerPixel
- * tag value because older TIFF specs permitted Compression
- * to be written as a SamplesPerPixel-count tag entry.
- * Thus if we don't first figure out the correct SamplesPerPixel
- * tag value then we may end up ignoring the Compression tag
- * value because it has an incorrect count value (if the
- * true value of SamplesPerPixel is not 1).
- */
- dp =
- TIFFReadDirectoryFindEntry(tif, dir, dircount, TIFFTAG_SAMPLESPERPIXEL);
- if (dp)
- {
- if (!TIFFFetchNormalTag(tif, dp, 0))
- goto bad;
- dp->tdir_ignore = TRUE;
- }
- dp = TIFFReadDirectoryFindEntry(tif, dir, dircount, TIFFTAG_COMPRESSION);
- if (dp)
- {
- /*
- * The 5.0 spec says the Compression tag has one value, while
- * earlier specs say it has one value per sample. Because of
- * this, we accept the tag if one value is supplied with either
- * count.
- */
- uint16_t value;
- enum TIFFReadDirEntryErr err;
- err = TIFFReadDirEntryShort(tif, dp, &value);
- if (err == TIFFReadDirEntryErrCount)
- err = TIFFReadDirEntryPersampleShort(tif, dp, &value);
- if (err != TIFFReadDirEntryErrOk)
- {
- TIFFReadDirEntryOutputErr(tif, err, module, "Compression", 0);
- goto bad;
- }
- if (!TIFFSetField(tif, TIFFTAG_COMPRESSION, value))
- goto bad;
- dp->tdir_ignore = TRUE;
- }
- else
- {
- if (!TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE))
- goto bad;
- }
- /*
- * First real pass over the directory.
- */
- for (di = 0, dp = dir; di < dircount; di++, dp++)
- {
- if (!dp->tdir_ignore)
- {
- TIFFReadDirectoryFindFieldInfo(tif, dp->tdir_tag, &fii);
- if (fii == FAILED_FII)
- {
- TIFFWarningExtR(tif, module,
- "Unknown field with tag %" PRIu16 " (0x%" PRIx16
- ") encountered",
- dp->tdir_tag, dp->tdir_tag);
- /* the following knowingly leaks the
- anonymous field structure */
- const TIFFField *fld = _TIFFCreateAnonField(
- tif, dp->tdir_tag, (TIFFDataType)dp->tdir_type);
- if (fld == NULL || !_TIFFMergeFields(tif, fld, 1))
- {
- TIFFWarningExtR(
- tif, module,
- "Registering anonymous field with tag %" PRIu16
- " (0x%" PRIx16 ") failed",
- dp->tdir_tag, dp->tdir_tag);
- dp->tdir_ignore = TRUE;
- }
- else
- {
- TIFFReadDirectoryFindFieldInfo(tif, dp->tdir_tag, &fii);
- assert(fii != FAILED_FII);
- }
- }
- }
- if (!dp->tdir_ignore)
- {
- fip = tif->tif_fields[fii];
- if (fip->field_bit == FIELD_IGNORE)
- dp->tdir_ignore = TRUE;
- else
- {
- switch (dp->tdir_tag)
- {
- case TIFFTAG_STRIPOFFSETS:
- case TIFFTAG_STRIPBYTECOUNTS:
- case TIFFTAG_TILEOFFSETS:
- case TIFFTAG_TILEBYTECOUNTS:
- TIFFSetFieldBit(tif, fip->field_bit);
- break;
- case TIFFTAG_IMAGEWIDTH:
- case TIFFTAG_IMAGELENGTH:
- case TIFFTAG_IMAGEDEPTH:
- case TIFFTAG_TILELENGTH:
- case TIFFTAG_TILEWIDTH:
- case TIFFTAG_TILEDEPTH:
- case TIFFTAG_PLANARCONFIG:
- case TIFFTAG_ROWSPERSTRIP:
- case TIFFTAG_EXTRASAMPLES:
- if (!TIFFFetchNormalTag(tif, dp, 0))
- goto bad;
- dp->tdir_ignore = TRUE;
- break;
- default:
- if (!_TIFFCheckFieldIsValidForCodec(tif, dp->tdir_tag))
- dp->tdir_ignore = TRUE;
- break;
- }
- }
- }
- }
- /*
- * XXX: OJPEG hack.
- * If a) compression is OJPEG, b) planarconfig tag says it's separate,
- * c) strip offsets/bytecounts tag are both present and
- * d) both contain exactly one value, then we consistently find
- * that the buggy implementation of the buggy compression scheme
- * matches contig planarconfig best. So we 'fix-up' the tag here
- */
- if ((tif->tif_dir.td_compression == COMPRESSION_OJPEG) &&
- (tif->tif_dir.td_planarconfig == PLANARCONFIG_SEPARATE))
- {
- if (!_TIFFFillStriles(tif))
- goto bad;
- dp = TIFFReadDirectoryFindEntry(tif, dir, dircount,
- TIFFTAG_STRIPOFFSETS);
- if ((dp != 0) && (dp->tdir_count == 1))
- {
- dp = TIFFReadDirectoryFindEntry(tif, dir, dircount,
- TIFFTAG_STRIPBYTECOUNTS);
- if ((dp != 0) && (dp->tdir_count == 1))
- {
- tif->tif_dir.td_planarconfig = PLANARCONFIG_CONTIG;
- TIFFWarningExtR(tif, module,
- "Planarconfig tag value assumed incorrect, "
- "assuming data is contig instead of chunky");
- }
- }
- }
- /*
- * Allocate directory structure and setup defaults.
- */
- if (!TIFFFieldSet(tif, FIELD_IMAGEDIMENSIONS))
- {
- TIFFWarningExtR(tif, module, "TIFF directory is missing required ImageLength field");
- }
-
- /*
- * Second pass: extract other information.
- */
- for (di = 0, dp = dir; di < dircount; di++, dp++)
- {
- if (!dp->tdir_ignore)
- {
- switch (dp->tdir_tag)
- {
- case TIFFTAG_MINSAMPLEVALUE:
- case TIFFTAG_MAXSAMPLEVALUE:
- case TIFFTAG_BITSPERSAMPLE:
- case TIFFTAG_DATATYPE:
- case TIFFTAG_SAMPLEFORMAT:
- /*
- * The MinSampleValue, MaxSampleValue, BitsPerSample
- * DataType and SampleFormat tags are supposed to be
- * written as one value/sample, but some vendors
- * incorrectly write one value only -- so we accept
- * that as well (yuck). Other vendors write correct
- * value for NumberOfSamples, but incorrect one for
- * BitsPerSample and friends, and we will read this
- * too.
- */
- {
- uint16_t value;
- enum TIFFReadDirEntryErr err;
- err = TIFFReadDirEntryShort(tif, dp, &value);
- if (!EvaluateIFDdatasizeReading(tif, dp))
- goto bad;
- if (err == TIFFReadDirEntryErrCount)
- err =
- TIFFReadDirEntryPersampleShort(tif, dp, &value);
- if (err != TIFFReadDirEntryErrOk)
- {
- fip = TIFFFieldWithTag(tif, dp->tdir_tag);
- TIFFReadDirEntryOutputErr(
- tif, err, module,
- fip ? fip->field_name : "unknown tagname", 0);
- goto bad;
- }
- if (!TIFFSetField(tif, dp->tdir_tag, value))
- goto bad;
- if (dp->tdir_tag == TIFFTAG_BITSPERSAMPLE)
- bitspersample_read = TRUE;
- }
- break;
- case TIFFTAG_SMINSAMPLEVALUE:
- case TIFFTAG_SMAXSAMPLEVALUE:
- {
-
- double *data = NULL;
- enum TIFFReadDirEntryErr err;
- uint32_t saved_flags;
- int m;
- if (dp->tdir_count !=
- (uint64_t)tif->tif_dir.td_samplesperpixel)
- err = TIFFReadDirEntryErrCount;
- else
- err = TIFFReadDirEntryDoubleArray(tif, dp, &data);
- if (!EvaluateIFDdatasizeReading(tif, dp))
- goto bad;
- if (err != TIFFReadDirEntryErrOk)
- {
- fip = TIFFFieldWithTag(tif, dp->tdir_tag);
- TIFFReadDirEntryOutputErr(
- tif, err, module,
- fip ? fip->field_name : "unknown tagname", 0);
- goto bad;
- }
- saved_flags = tif->tif_flags;
- tif->tif_flags |= TIFF_PERSAMPLE;
- m = TIFFSetField(tif, dp->tdir_tag, data);
- tif->tif_flags = saved_flags;
- _TIFFfreeExt(tif, data);
- if (!m)
- goto bad;
- }
- break;
- case TIFFTAG_STRIPOFFSETS:
- case TIFFTAG_TILEOFFSETS:
- {
- switch (dp->tdir_type)
- {
- case TIFF_SHORT:
- case TIFF_LONG:
- case TIFF_LONG8:
- break;
- default:
- /* Warn except if directory typically created with
- * TIFFDeferStrileArrayWriting() */
- if (!(tif->tif_mode == O_RDWR &&
- dp->tdir_count == 0 && dp->tdir_type == 0 &&
- dp->tdir_offset.toff_long8 == 0))
- {
- fip = TIFFFieldWithTag(tif, dp->tdir_tag);
- TIFFWarningExtR(
- tif, module, "Invalid data type for tag %s",
- fip ? fip->field_name : "unknown tagname");
- }
- break;
- }
- _TIFFmemcpy(&(tif->tif_dir.td_stripoffset_entry), dp,
- sizeof(TIFFDirEntry));
- if (!EvaluateIFDdatasizeReading(tif, dp))
- goto bad;
- }
- break;
- case TIFFTAG_STRIPBYTECOUNTS:
- case TIFFTAG_TILEBYTECOUNTS:
- {
- switch (dp->tdir_type)
- {
- case TIFF_SHORT:
- case TIFF_LONG:
- case TIFF_LONG8:
- break;
- default:
- /* Warn except if directory typically created with
- * TIFFDeferStrileArrayWriting() */
- if (!(tif->tif_mode == O_RDWR &&
- dp->tdir_count == 0 && dp->tdir_type == 0 &&
- dp->tdir_offset.toff_long8 == 0))
- {
- fip = TIFFFieldWithTag(tif, dp->tdir_tag);
- TIFFWarningExtR(
- tif, module, "Invalid data type for tag %s",
- fip ? fip->field_name : "unknown tagname");
- }
- break;
- }
- _TIFFmemcpy(&(tif->tif_dir.td_stripbytecount_entry), dp,
- sizeof(TIFFDirEntry));
- if (!EvaluateIFDdatasizeReading(tif, dp))
- goto bad;
- }
- break;
- case TIFFTAG_COLORMAP:
- case TIFFTAG_TRANSFERFUNCTION:
- {
- enum TIFFReadDirEntryErr err;
- uint32_t countpersample;
- uint32_t countrequired;
- uint32_t incrementpersample;
- uint16_t *value = NULL;
- /* It would be dangerous to instantiate those tag values */
- /* since if td_bitspersample has not yet been read (due to
- */
- /* unordered tags), it could be read afterwards with a */
- /* values greater than the default one (1), which may cause
- */
- /* crashes in user code */
- if (!bitspersample_read)
- {
- fip = TIFFFieldWithTag(tif, dp->tdir_tag);
- TIFFWarningExtR(
- tif, module,
- "Ignoring %s since BitsPerSample tag not found",
- fip ? fip->field_name : "unknown tagname");
- continue;
- }
- /* ColorMap or TransferFunction for high bit */
- /* depths do not make much sense and could be */
- /* used as a denial of service vector */
- if (tif->tif_dir.td_bitspersample > 24)
- {
- fip = TIFFFieldWithTag(tif, dp->tdir_tag);
- TIFFWarningExtR(
- tif, module,
- "Ignoring %s because BitsPerSample=%" PRIu16 ">24",
- fip ? fip->field_name : "unknown tagname",
- tif->tif_dir.td_bitspersample);
- continue;
- }
- countpersample = (1U << tif->tif_dir.td_bitspersample);
- if ((dp->tdir_tag == TIFFTAG_TRANSFERFUNCTION) &&
- (dp->tdir_count == (uint64_t)countpersample))
- {
- countrequired = countpersample;
- incrementpersample = 0;
- }
- else
- {
- countrequired = 3 * countpersample;
- incrementpersample = countpersample;
- }
- if (dp->tdir_count != (uint64_t)countrequired)
- err = TIFFReadDirEntryErrCount;
- else
- err = TIFFReadDirEntryShortArray(tif, dp, &value);
- if (!EvaluateIFDdatasizeReading(tif, dp))
- goto bad;
- if (err != TIFFReadDirEntryErrOk)
- {
- fip = TIFFFieldWithTag(tif, dp->tdir_tag);
- TIFFReadDirEntryOutputErr(
- tif, err, module,
- fip ? fip->field_name : "unknown tagname", 1);
- }
- else
- {
- TIFFSetField(tif, dp->tdir_tag, value,
- value + incrementpersample,
- value + 2 * incrementpersample);
- _TIFFfreeExt(tif, value);
- }
- }
- break;
- /* BEGIN REV 4.0 COMPATIBILITY */
- case TIFFTAG_OSUBFILETYPE:
- {
- uint16_t valueo;
- uint32_t value;
- if (TIFFReadDirEntryShort(tif, dp, &valueo) ==
- TIFFReadDirEntryErrOk)
- {
- switch (valueo)
- {
- case OFILETYPE_REDUCEDIMAGE:
- value = FILETYPE_REDUCEDIMAGE;
- break;
- case OFILETYPE_PAGE:
- value = FILETYPE_PAGE;
- break;
- default:
- value = 0;
- break;
- }
- if (value != 0)
- TIFFSetField(tif, TIFFTAG_SUBFILETYPE, value);
- }
- }
- break;
- /* END REV 4.0 COMPATIBILITY */
-#if 0
- case TIFFTAG_EP_BATTERYLEVEL:
- /* TIFFTAG_EP_BATTERYLEVEL can be RATIONAL or ASCII.
- * LibTiff defines it as ASCII and converts RATIONAL to an
- * ASCII string. */
- switch (dp->tdir_type)
- {
- case TIFF_RATIONAL:
- {
- /* Read rational and convert to ASCII*/
- enum TIFFReadDirEntryErr err;
- TIFFRational_t rValue;
- err = TIFFReadDirEntryCheckedRationalDirect(
- tif, dp, &rValue);
- if (err != TIFFReadDirEntryErrOk)
- {
- fip = TIFFFieldWithTag(tif, dp->tdir_tag);
- TIFFReadDirEntryOutputErr(
- tif, err, module,
- fip ? fip->field_name : "unknown tagname",
- 1);
- }
- else
- {
- char szAux[32];
- snprintf(szAux, sizeof(szAux) - 1, "%d/%d",
- rValue.uNum, rValue.uDenom);
- TIFFSetField(tif, dp->tdir_tag, szAux);
- }
- }
- break;
- case TIFF_ASCII:
- (void)TIFFFetchNormalTag(tif, dp, TRUE);
- break;
- default:
- fip = TIFFFieldWithTag(tif, dp->tdir_tag);
- TIFFWarningExtR(tif, module,
- "Invalid data type for tag %s. "
- "ASCII or RATIONAL expected",
- fip ? fip->field_name
- : "unknown tagname");
- break;
- }
- break;
-#endif
- default:
- (void)TIFFFetchNormalTag(tif, dp, TRUE);
- break;
- } /* -- switch (dp->tdir_tag) -- */
- } /* -- if (!dp->tdir_ignore) */
- } /* -- for-loop -- */
-
- /* Evaluate final IFD data size. */
- CalcFinalIFDdatasizeReading(tif, dircount);
-
- /*
- * OJPEG hack:
- * - If a) compression is OJPEG, and b) photometric tag is missing,
- * then we consistently find that photometric should be YCbCr
- * - If a) compression is OJPEG, and b) photometric tag says it's RGB,
- * then we consistently find that the buggy implementation of the
- * buggy compression scheme matches photometric YCbCr instead.
- * - If a) compression is OJPEG, and b) bitspersample tag is missing,
- * then we consistently find bitspersample should be 8.
- * - If a) compression is OJPEG, b) samplesperpixel tag is missing,
- * and c) photometric is RGB or YCbCr, then we consistently find
- * samplesperpixel should be 3
- * - If a) compression is OJPEG, b) samplesperpixel tag is missing,
- * and c) photometric is MINISWHITE or MINISBLACK, then we consistently
- * find samplesperpixel should be 3
- */
- if (tif->tif_dir.td_compression == COMPRESSION_OJPEG)
- {
- if (!TIFFFieldSet(tif, FIELD_PHOTOMETRIC))
- {
- TIFFWarningExtR(
- tif, module,
- "Photometric tag is missing, assuming data is YCbCr");
- if (!TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_YCBCR))
- goto bad;
- }
- else if (tif->tif_dir.td_photometric == PHOTOMETRIC_RGB)
- {
- tif->tif_dir.td_photometric = PHOTOMETRIC_YCBCR;
- TIFFWarningExtR(tif, module,
- "Photometric tag value assumed incorrect, "
- "assuming data is YCbCr instead of RGB");
- }
- if (!TIFFFieldSet(tif, FIELD_BITSPERSAMPLE))
- {
- TIFFWarningExtR(
- tif, module,
- "BitsPerSample tag is missing, assuming 8 bits per sample");
- if (!TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8))
- goto bad;
- }
- if (!TIFFFieldSet(tif, FIELD_SAMPLESPERPIXEL))
- {
- if (tif->tif_dir.td_photometric == PHOTOMETRIC_RGB)
- {
- TIFFWarningExtR(tif, module,
- "SamplesPerPixel tag is missing, "
- "assuming correct SamplesPerPixel value is 3");
- if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 3))
- goto bad;
- }
- if (tif->tif_dir.td_photometric == PHOTOMETRIC_YCBCR)
- {
- TIFFWarningExtR(tif, module,
- "SamplesPerPixel tag is missing, "
- "applying correct SamplesPerPixel value of 3");
- if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 3))
- goto bad;
- }
- else if ((tif->tif_dir.td_photometric == PHOTOMETRIC_MINISWHITE) ||
- (tif->tif_dir.td_photometric == PHOTOMETRIC_MINISBLACK))
- {
- /*
- * SamplesPerPixel tag is missing, but is not required
- * by spec. Assume correct SamplesPerPixel value of 1.
- */
- if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1))
- goto bad;
- }
- }
- }
-
- /*
- * Setup appropriate structures (by strip or by tile)
- * We do that only after the above OJPEG hack which alters SamplesPerPixel
- * and thus influences the number of strips in the separate planarconfig.
- */
- if (!TIFFFieldSet(tif, FIELD_TILEDIMENSIONS))
- {
- tif->tif_dir.td_nstrips = TIFFNumberOfStrips(tif);
- tif->tif_dir.td_tilewidth = tif->tif_dir.td_imagewidth;
- tif->tif_dir.td_tilelength = tif->tif_dir.td_rowsperstrip;
- tif->tif_dir.td_tiledepth = tif->tif_dir.td_imagedepth;
- tif->tif_flags &= ~TIFF_ISTILED;
- }
- else
- {
- tif->tif_dir.td_nstrips = TIFFNumberOfTiles(tif);
- tif->tif_flags |= TIFF_ISTILED;
- }
- if (!tif->tif_dir.td_nstrips)
- {
- TIFFErrorExtR(tif, module, "Cannot handle zero number of %s",
- isTiled(tif) ? "tiles" : "strips");
- goto bad;
- }
- tif->tif_dir.td_stripsperimage = tif->tif_dir.td_nstrips;
- if (tif->tif_dir.td_planarconfig == PLANARCONFIG_SEPARATE)
- tif->tif_dir.td_stripsperimage /= tif->tif_dir.td_samplesperpixel;
- if (!TIFFFieldSet(tif, FIELD_STRIPOFFSETS))
- {
-#ifdef OJPEG_SUPPORT
- if ((tif->tif_dir.td_compression == COMPRESSION_OJPEG) &&
- (isTiled(tif) == 0) && (tif->tif_dir.td_nstrips == 1))
- {
- /*
- * XXX: OJPEG hack.
- * If a) compression is OJPEG, b) it's not a tiled TIFF,
- * and c) the number of strips is 1,
- * then we tolerate the absence of stripoffsets tag,
- * because, presumably, all required data is in the
- * JpegInterchangeFormat stream.
- */
- TIFFSetFieldBit(tif, FIELD_STRIPOFFSETS);
- }
- else
-#endif
- {
- MissingRequired(tif, isTiled(tif) ? "TileOffsets" : "StripOffsets");
- goto bad;
- }
- }
-
- if (tif->tif_mode == O_RDWR &&
- tif->tif_dir.td_stripoffset_entry.tdir_tag != 0 &&
- tif->tif_dir.td_stripoffset_entry.tdir_count == 0 &&
- tif->tif_dir.td_stripoffset_entry.tdir_type == 0 &&
- tif->tif_dir.td_stripoffset_entry.tdir_offset.toff_long8 == 0 &&
- tif->tif_dir.td_stripbytecount_entry.tdir_tag != 0 &&
- tif->tif_dir.td_stripbytecount_entry.tdir_count == 0 &&
- tif->tif_dir.td_stripbytecount_entry.tdir_type == 0 &&
- tif->tif_dir.td_stripbytecount_entry.tdir_offset.toff_long8 == 0)
- {
- /* Directory typically created with TIFFDeferStrileArrayWriting() */
- TIFFSetupStrips(tif);
- }
- else if (!(tif->tif_flags & TIFF_DEFERSTRILELOAD))
- {
- if (tif->tif_dir.td_stripoffset_entry.tdir_tag != 0)
- {
- if (!TIFFFetchStripThing(tif, &(tif->tif_dir.td_stripoffset_entry),
- tif->tif_dir.td_nstrips,
- &tif->tif_dir.td_stripoffset_p))
- {
- goto bad;
- }
- }
- if (tif->tif_dir.td_stripbytecount_entry.tdir_tag != 0)
- {
- if (!TIFFFetchStripThing(
- tif, &(tif->tif_dir.td_stripbytecount_entry),
- tif->tif_dir.td_nstrips, &tif->tif_dir.td_stripbytecount_p))
- {
- goto bad;
- }
- }
- }
-
- /*
- * Make sure all non-color channels are extrasamples.
- * If it's not the case, define them as such.
- */
- color_channels = _TIFFGetMaxColorChannels(tif->tif_dir.td_photometric);
- if (color_channels &&
- tif->tif_dir.td_samplesperpixel - tif->tif_dir.td_extrasamples >
- color_channels)
- {
- uint16_t old_extrasamples;
- uint16_t *new_sampleinfo;
-
- TIFFWarningExtR(
- tif, module,
- "Sum of Photometric type-related "
- "color channels and ExtraSamples doesn't match SamplesPerPixel. "
- "Defining non-color channels as ExtraSamples.");
-
- old_extrasamples = tif->tif_dir.td_extrasamples;
- tif->tif_dir.td_extrasamples =
- (uint16_t)(tif->tif_dir.td_samplesperpixel - color_channels);
-
- // sampleinfo should contain information relative to these new extra
- // samples
- new_sampleinfo = (uint16_t *)_TIFFcallocExt(
- tif, tif->tif_dir.td_extrasamples, sizeof(uint16_t));
- if (!new_sampleinfo)
- {
- TIFFErrorExtR(tif, module,
- "Failed to allocate memory for "
- "temporary new sampleinfo array "
- "(%" PRIu16 " 16 bit elements)",
- tif->tif_dir.td_extrasamples);
- goto bad;
- }
-
- if (old_extrasamples > 0)
- memcpy(new_sampleinfo, tif->tif_dir.td_sampleinfo,
- old_extrasamples * sizeof(uint16_t));
- _TIFFsetShortArrayExt(tif, &tif->tif_dir.td_sampleinfo, new_sampleinfo,
- tif->tif_dir.td_extrasamples);
- _TIFFfreeExt(tif, new_sampleinfo);
- }
-
- /*
- * Verify Palette image has a Colormap.
- */
- if (tif->tif_dir.td_photometric == PHOTOMETRIC_PALETTE &&
- !TIFFFieldSet(tif, FIELD_COLORMAP))
- {
- if (tif->tif_dir.td_bitspersample >= 8 &&
- tif->tif_dir.td_samplesperpixel == 3)
- tif->tif_dir.td_photometric = PHOTOMETRIC_RGB;
- else if (tif->tif_dir.td_bitspersample >= 8)
- tif->tif_dir.td_photometric = PHOTOMETRIC_MINISBLACK;
- else
- {
- MissingRequired(tif, "Colormap");
- goto bad;
- }
- }
- /*
- * OJPEG hack:
- * We do no further messing with strip/tile offsets/bytecounts in OJPEG
- * TIFFs
- */
- if (tif->tif_dir.td_compression != COMPRESSION_OJPEG)
- {
- /*
- * Attempt to deal with a missing StripByteCounts tag.
- */
- if (!TIFFFieldSet(tif, FIELD_STRIPBYTECOUNTS))
- {
- /*
- * Some manufacturers violate the spec by not giving
- * the size of the strips. In this case, assume there
- * is one uncompressed strip of data.
- */
- if ((tif->tif_dir.td_planarconfig == PLANARCONFIG_CONTIG &&
- tif->tif_dir.td_nstrips > 1) ||
- (tif->tif_dir.td_planarconfig == PLANARCONFIG_SEPARATE &&
- tif->tif_dir.td_nstrips !=
- (uint32_t)tif->tif_dir.td_samplesperpixel))
- {
- MissingRequired(tif, "StripByteCounts");
- goto bad;
- }
- TIFFWarningExtR(
- tif, module,
- "TIFF directory is missing required "
- "\"StripByteCounts\" field, calculating from imagelength");
- if (EstimateStripByteCounts(tif, dir, dircount) < 0)
- goto bad;
- }
- else if (tif->tif_dir.td_nstrips == 1 &&
- !(tif->tif_flags & TIFF_ISTILED) && ByteCountLooksBad(tif))
- {
- /*
- * XXX: Plexus (and others) sometimes give a value of
- * zero for a tag when they don't know what the
- * correct value is! Try and handle the simple case
- * of estimating the size of a one strip image.
- */
- TIFFWarningExtR(tif, module,
- "Bogus \"StripByteCounts\" field, ignoring and "
- "calculating from imagelength");
- if (EstimateStripByteCounts(tif, dir, dircount) < 0)
- goto bad;
- }
- else if (!(tif->tif_flags & TIFF_DEFERSTRILELOAD) &&
- tif->tif_dir.td_planarconfig == PLANARCONFIG_CONTIG &&
- tif->tif_dir.td_nstrips > 2 &&
- tif->tif_dir.td_compression == COMPRESSION_NONE &&
- TIFFGetStrileByteCount(tif, 0) !=
- TIFFGetStrileByteCount(tif, 1) &&
- TIFFGetStrileByteCount(tif, 0) != 0 &&
- TIFFGetStrileByteCount(tif, 1) != 0)
- {
- /*
- * XXX: Some vendors fill StripByteCount array with
- * absolutely wrong values (it can be equal to
- * StripOffset array, for example). Catch this case
- * here.
- *
- * We avoid this check if deferring strile loading
- * as it would always force us to load the strip/tile
- * information.
- */
- TIFFWarningExtR(tif, module,
- "Wrong \"StripByteCounts\" field, ignoring and "
- "calculating from imagelength");
- if (EstimateStripByteCounts(tif, dir, dircount) < 0)
- goto bad;
- }
- }
- if (dir)
- {
- _TIFFfreeExt(tif, dir);
- dir = NULL;
- }
- if (!TIFFFieldSet(tif, FIELD_MAXSAMPLEVALUE))
- {
- if (tif->tif_dir.td_bitspersample >= 16)
- tif->tif_dir.td_maxsamplevalue = 0xFFFF;
- else
- tif->tif_dir.td_maxsamplevalue =
- (uint16_t)((1L << tif->tif_dir.td_bitspersample) - 1);
- }
-
-#ifdef STRIPBYTECOUNTSORTED_UNUSED
- /*
- * XXX: We can optimize checking for the strip bounds using the sorted
- * bytecounts array. See also comments for TIFFAppendToStrip()
- * function in tif_write.c.
- */
- if (!(tif->tif_flags & TIFF_DEFERSTRILELOAD) && tif->tif_dir.td_nstrips > 1)
- {
- uint32_t strip;
-
- tif->tif_dir.td_stripbytecountsorted = 1;
- for (strip = 1; strip < tif->tif_dir.td_nstrips; strip++)
- {
- if (TIFFGetStrileOffset(tif, strip - 1) >
- TIFFGetStrileOffset(tif, strip))
- {
- tif->tif_dir.td_stripbytecountsorted = 0;
- break;
- }
- }
- }
-#endif
-
- /*
- * An opportunity for compression mode dependent tag fixup
- */
- (*tif->tif_fixuptags)(tif);
-
- /*
- * Some manufacturers make life difficult by writing
- * large amounts of uncompressed data as a single strip.
- * This is contrary to the recommendations of the spec.
- * The following makes an attempt at breaking such images
- * into strips closer to the recommended 8k bytes. A
- * side effect, however, is that the RowsPerStrip tag
- * value may be changed.
- */
- if ((tif->tif_dir.td_planarconfig == PLANARCONFIG_CONTIG) &&
- (tif->tif_dir.td_nstrips == 1) &&
- (tif->tif_dir.td_compression == COMPRESSION_NONE) &&
- ((tif->tif_flags & (TIFF_STRIPCHOP | TIFF_ISTILED)) == TIFF_STRIPCHOP))
- {
- ChopUpSingleUncompressedStrip(tif);
- }
-
- /* There are also uncompressed striped files with strips larger than */
- /* 2 GB, which make them unfriendly with a lot of code. If possible, */
- /* try to expose smaller "virtual" strips. */
- if (tif->tif_dir.td_planarconfig == PLANARCONFIG_CONTIG &&
- tif->tif_dir.td_compression == COMPRESSION_NONE &&
- (tif->tif_flags & (TIFF_STRIPCHOP | TIFF_ISTILED)) == TIFF_STRIPCHOP &&
- TIFFStripSize64(tif) > 0x7FFFFFFFUL)
- {
- TryChopUpUncompressedBigTiff(tif);
- }
-
- /*
- * Clear the dirty directory flag.
- */
- tif->tif_flags &= ~TIFF_DIRTYDIRECT;
- tif->tif_flags &= ~TIFF_DIRTYSTRIP;
-
- /*
- * Reinitialize i/o since we are starting on a new directory.
- */
- tif->tif_row = (uint32_t)-1;
- tif->tif_curstrip = (uint32_t)-1;
- tif->tif_col = (uint32_t)-1;
- tif->tif_curtile = (uint32_t)-1;
- tif->tif_tilesize = (tmsize_t)-1;
-
- tif->tif_scanlinesize = TIFFScanlineSize(tif);
- if (!tif->tif_scanlinesize)
- {
- TIFFWarningExtR(tif, module, "Cannot handle zero scanline size");
- }
-
- if (isTiled(tif))
- {
- tif->tif_tilesize = TIFFTileSize(tif);
- if (!tif->tif_tilesize)
- {
- TIFFWarningExtR(tif, module, "Cannot handle zero tile size");
- }
- }
- else
- {
- if (!TIFFStripSize(tif))
- {
- TIFFWarningExt(tif, module, "Cannot handle zero strip size");
- }
- }
- return (1);
-bad:
- if (dir)
- _TIFFfreeExt(tif, dir);
- return (0);
-} /*-- TIFFReadDirectory() --*/
-
-static void TIFFReadDirectoryCheckOrder(TIFF *tif, TIFFDirEntry *dir,
- uint16_t dircount)
-{
- static const char module[] = "TIFFReadDirectoryCheckOrder";
- uint32_t m;
- uint16_t n;
- TIFFDirEntry *o;
- m = 0;
- for (n = 0, o = dir; n < dircount; n++, o++)
- {
- if (o->tdir_tag < m)
- {
- TIFFWarningExtR(tif, module,
- "Invalid TIFF directory; tags are not sorted in "
- "ascending order");
- break;
- }
- m = o->tdir_tag + 1;
- }
-}
-
-static TIFFDirEntry *TIFFReadDirectoryFindEntry(TIFF *tif, TIFFDirEntry *dir,
- uint16_t dircount,
- uint16_t tagid)
-{
- TIFFDirEntry *m;
- uint16_t n;
- (void)tif;
- for (m = dir, n = 0; n < dircount; m++, n++)
- {
- if (m->tdir_tag == tagid)
- return (m);
- }
- return (0);
-}
-
-static void TIFFReadDirectoryFindFieldInfo(TIFF *tif, uint16_t tagid,
- uint32_t *fii)
-{
- int32_t ma, mb, mc;
- ma = -1;
- mc = (int32_t)tif->tif_nfields;
- while (1)
- {
- if (ma + 1 == mc)
- {
- *fii = FAILED_FII;
- return;
- }
- mb = (ma + mc) / 2;
- if (tif->tif_fields[mb]->field_tag == (uint32_t)tagid)
- break;
- if (tif->tif_fields[mb]->field_tag < (uint32_t)tagid)
- ma = mb;
- else
- mc = mb;
- }
- while (1)
- {
- if (mb == 0)
- break;
- if (tif->tif_fields[mb - 1]->field_tag != (uint32_t)tagid)
- break;
- mb--;
- }
- *fii = mb;
-}
-
-/*
- * Read custom directory from the arbitrary offset.
- * The code is very similar to TIFFReadDirectory().
- */
-int TIFFReadCustomDirectory(TIFF *tif, toff_t diroff,
- const TIFFFieldArray *infoarray)
-{
- static const char module[] = "TIFFReadCustomDirectory";
- TIFFDirEntry *dir;
- uint16_t dircount;
- TIFFDirEntry *dp;
- uint16_t di;
- const TIFFField *fip;
- uint32_t fii;
-
- dircount = TIFFFetchDirectory(tif, diroff, &dir, NULL);
- if (!dircount)
- {
- TIFFWarningExtR(tif, module,
- "Failed to read custom directory at offset %" PRIu64,
- diroff);
- return 0;
- }
- TIFFReadDirectoryCheckOrder(tif, dir, dircount);
-
- /*
- * Mark duplicates of any tag to be ignored (bugzilla 1994)
- * to avoid certain pathological problems.
- */
- {
- TIFFDirEntry *ma;
- uint16_t mb;
- for (ma = dir, mb = 0; mb < dircount; ma++, mb++)
- {
- TIFFDirEntry *na;
- uint16_t nb;
- for (na = ma + 1, nb = mb + 1; nb < dircount; na++, nb++)
- {
- if (ma->tdir_tag == na->tdir_tag)
- {
- na->tdir_ignore = TRUE;
- }
- }
- }
- }
-
- /* Free any old stuff and reinit. */
- (*tif->tif_cleanup)(tif); /* cleanup any previous compression state */
- TIFFFreeDirectory(tif);
- /* Even if custom directories do not need the default settings of a standard
- * IFD, the pointer to the TIFFSetField() and TIFFGetField() (i.e.
- * tif->tif_tagmethods.vsetfield and tif->tif_tagmethods.vgetfield) need to
- * be initialized, which is done in TIFFDefaultDirectory().
- * After that, the field array for the custom tags needs to be setup again.
- */
- TIFFDefaultDirectory(tif);
- _TIFFSetupFields(tif, infoarray);
-
- /* Allocate arrays for offset values outside IFD entry for IFD data size
- * checking. Note: Counter are reset within TIFFFreeDirectory(). */
- tif->tif_dir.td_dirdatasize_offsets =
- (TIFFEntryOffsetAndLength *)_TIFFmallocExt(
- tif, dircount * sizeof(TIFFEntryOffsetAndLength));
- if (tif->tif_dir.td_dirdatasize_offsets == NULL)
- {
- TIFFErrorExtR(
- tif, module,
- "Failed to allocate memory for counting IFD data size at reading");
- if (dir)
- _TIFFfreeExt(tif, dir);
- return 0;
- }
-
- for (di = 0, dp = dir; di < dircount; di++, dp++)
- {
- TIFFReadDirectoryFindFieldInfo(tif, dp->tdir_tag, &fii);
- if (fii == FAILED_FII)
- {
- TIFFWarningExtR(tif, module,
- "Unknown field with tag %" PRIu16 " (0x%" PRIx16
- ") encountered",
- dp->tdir_tag, dp->tdir_tag);
- const TIFFField *fld = _TIFFCreateAnonField(
- tif, dp->tdir_tag, (TIFFDataType)dp->tdir_type);
- if (fld == NULL || !_TIFFMergeFields(tif, fld, 1))
- {
- TIFFWarningExtR(tif, module,
- "Registering anonymous field with tag %" PRIu16
- " (0x%" PRIx16 ") failed",
- dp->tdir_tag, dp->tdir_tag);
- dp->tdir_ignore = TRUE;
- }
- else
- {
- TIFFReadDirectoryFindFieldInfo(tif, dp->tdir_tag, &fii);
- assert(fii != FAILED_FII);
- }
- }
- if (!dp->tdir_ignore)
- {
- fip = tif->tif_fields[fii];
- if (fip->field_bit == FIELD_IGNORE)
- dp->tdir_ignore = TRUE;
- else
- {
- /* check data type */
- while ((fip->field_type != TIFF_ANY) &&
- (fip->field_type != dp->tdir_type))
- {
- fii++;
- if ((fii == tif->tif_nfields) ||
- (tif->tif_fields[fii]->field_tag !=
- (uint32_t)dp->tdir_tag))
- {
- fii = 0xFFFF;
- break;
- }
- fip = tif->tif_fields[fii];
- }
- if (fii == 0xFFFF)
- {
- TIFFWarningExtR(tif, module,
- "Wrong data type %" PRIu16
- " for \"%s\"; tag ignored",
- dp->tdir_type, fip->field_name);
- dp->tdir_ignore = TRUE;
- }
- else
- {
- /* check count if known in advance */
- if ((fip->field_readcount != TIFF_VARIABLE) &&
- (fip->field_readcount != TIFF_VARIABLE2))
- {
- uint32_t expected;
- if (fip->field_readcount == TIFF_SPP)
- expected =
- (uint32_t)tif->tif_dir.td_samplesperpixel;
- else
- expected = (uint32_t)fip->field_readcount;
- if (!CheckDirCount(tif, dp, expected))
- dp->tdir_ignore = TRUE;
- }
- }
- }
- if (!dp->tdir_ignore)
- {
- switch (dp->tdir_tag)
- {
- case EXIFTAG_SUBJECTDISTANCE:
- if (!TIFFFieldIsAnonymous(fip))
- {
- /* should only be called on a Exif directory */
- /* when exifFields[] is active */
- (void)TIFFFetchSubjectDistance(tif, dp);
- }
- else
- {
- (void)TIFFFetchNormalTag(tif, dp, TRUE);
- }
- break;
- default:
- (void)TIFFFetchNormalTag(tif, dp, TRUE);
- break;
- }
- } /*-- if (!dp->tdir_ignore) */
- }
- }
- /* Evaluate final IFD data size. */
- CalcFinalIFDdatasizeReading(tif, dircount);
-
- /* To be able to return from SubIFD or custom-IFD to main-IFD */
- tif->tif_setdirectory_force_absolute = TRUE;
- if (dir)
- _TIFFfreeExt(tif, dir);
- return 1;
-}
-
-/*
- * EXIF is important special case of custom IFD, so we have a special
- * function to read it.
- */
-int TIFFReadEXIFDirectory(TIFF *tif, toff_t diroff)
-{
- return TIFFReadCustomDirectory(tif, diroff, _TIFFGetExifFields());
-}
-
-/*
- *--: EXIF-GPS custom directory reading as another special case of custom IFD.
- */
-int TIFFReadGPSDirectory(TIFF *tif, toff_t diroff)
-{
- return TIFFReadCustomDirectory(tif, diroff, _TIFFGetGpsFields());
-}
-
-static int EstimateStripByteCounts(TIFF *tif, TIFFDirEntry *dir,
- uint16_t dircount)
-{
- static const char module[] = "EstimateStripByteCounts";
-
- TIFFDirEntry *dp;
- TIFFDirectory *td = &tif->tif_dir;
- uint32_t strip;
-
- /* Do not try to load stripbytecount as we will compute it */
- if (!_TIFFFillStrilesInternal(tif, 0))
- return -1;
-
- const uint64_t allocsize = (uint64_t)td->td_nstrips * sizeof(uint64_t);
- uint64_t filesize = 0;
- if (allocsize > 100 * 1024 * 1024)
- {
- /* Before allocating a huge amount of memory for corrupted files, check
- * if size of requested memory is not greater than file size. */
- filesize = TIFFGetFileSize(tif);
- if (allocsize > filesize)
- {
- TIFFWarningExtR(
- tif, module,
- "Requested memory size for StripByteCounts of %" PRIu64
- " is greater than filesize %" PRIu64 ". Memory not allocated",
- allocsize, filesize);
- return -1;
- }
- }
-
- if (td->td_stripbytecount_p)
- _TIFFfreeExt(tif, td->td_stripbytecount_p);
- td->td_stripbytecount_p = (uint64_t *)_TIFFCheckMalloc(
- tif, td->td_nstrips, sizeof(uint64_t), "for \"StripByteCounts\" array");
- if (td->td_stripbytecount_p == NULL)
- return -1;
-
- if (td->td_compression != COMPRESSION_NONE)
- {
- uint64_t space;
- uint16_t n;
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- space = sizeof(TIFFHeaderClassic) + 2 + dircount * 12 + 4;
- else
- space = sizeof(TIFFHeaderBig) + 8 + dircount * 20 + 8;
- /* calculate amount of space used by indirect values */
- for (dp = dir, n = dircount; n > 0; n--, dp++)
- {
- uint32_t typewidth;
- uint64_t datasize;
- typewidth = TIFFDataWidth((TIFFDataType)dp->tdir_type);
- if (typewidth == 0)
- {
- TIFFErrorExtR(
- tif, module,
- "Cannot determine size of unknown tag type %" PRIu16,
- dp->tdir_type);
- return -1;
- }
- if (dp->tdir_count > UINT64_MAX / typewidth)
- return -1;
- datasize = (uint64_t)typewidth * dp->tdir_count;
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- {
- if (datasize <= 4)
- datasize = 0;
- }
- else
- {
- if (datasize <= 8)
- datasize = 0;
- }
- if (space > UINT64_MAX - datasize)
- return -1;
- space += datasize;
- }
- if (filesize == 0)
- filesize = TIFFGetFileSize(tif);
- if (filesize < space)
- /* we should perhaps return in error ? */
- space = filesize;
- else
- space = filesize - space;
- if (td->td_planarconfig == PLANARCONFIG_SEPARATE)
- space /= td->td_samplesperpixel;
- for (strip = 0; strip < td->td_nstrips; strip++)
- td->td_stripbytecount_p[strip] = space;
- /*
- * This gross hack handles the case were the offset to
- * the last strip is past the place where we think the strip
- * should begin. Since a strip of data must be contiguous,
- * it's safe to assume that we've overestimated the amount
- * of data in the strip and trim this number back accordingly.
- */
- strip--;
- if (td->td_stripoffset_p[strip] >
- UINT64_MAX - td->td_stripbytecount_p[strip])
- return -1;
- if (td->td_stripoffset_p[strip] + td->td_stripbytecount_p[strip] >
- filesize)
- {
- if (td->td_stripoffset_p[strip] >= filesize)
- {
- /* Not sure what we should in that case... */
- td->td_stripbytecount_p[strip] = 0;
- }
- else
- {
- td->td_stripbytecount_p[strip] =
- filesize - td->td_stripoffset_p[strip];
- }
- }
- }
- else if (isTiled(tif))
- {
- uint64_t bytespertile = TIFFTileSize64(tif);
-
- for (strip = 0; strip < td->td_nstrips; strip++)
- td->td_stripbytecount_p[strip] = bytespertile;
- }
- else
- {
- uint64_t rowbytes = TIFFScanlineSize64(tif);
- uint32_t rowsperstrip = td->td_imagelength / td->td_stripsperimage;
- for (strip = 0; strip < td->td_nstrips; strip++)
- {
- if (rowbytes > 0 && rowsperstrip > UINT64_MAX / rowbytes)
- return -1;
- td->td_stripbytecount_p[strip] = rowbytes * rowsperstrip;
- }
- }
- TIFFSetFieldBit(tif, FIELD_STRIPBYTECOUNTS);
- if (!TIFFFieldSet(tif, FIELD_ROWSPERSTRIP))
- td->td_rowsperstrip = td->td_imagelength;
- return 1;
-}
-
-static void MissingRequired(TIFF *tif, const char *tagname)
-{
- static const char module[] = "MissingRequired";
-
- TIFFWarningExtR(tif, module,
- "TIFF directory is missing required \"%s\" field", tagname);
-}
-
-static unsigned long hashFuncOffsetToNumber(const void *elt)
-{
- const TIFFOffsetAndDirNumber *offsetAndDirNumber =
- (const TIFFOffsetAndDirNumber *)elt;
- const uint32_t hash = (uint32_t)(offsetAndDirNumber->offset >> 32) ^
- ((uint32_t)offsetAndDirNumber->offset & 0xFFFFFFFFU);
- return hash;
-}
-
-static bool equalFuncOffsetToNumber(const void *elt1, const void *elt2)
-{
- const TIFFOffsetAndDirNumber *offsetAndDirNumber1 =
- (const TIFFOffsetAndDirNumber *)elt1;
- const TIFFOffsetAndDirNumber *offsetAndDirNumber2 =
- (const TIFFOffsetAndDirNumber *)elt2;
- return offsetAndDirNumber1->offset == offsetAndDirNumber2->offset;
-}
-
-static unsigned long hashFuncNumberToOffset(const void *elt)
-{
- const TIFFOffsetAndDirNumber *offsetAndDirNumber =
- (const TIFFOffsetAndDirNumber *)elt;
- return offsetAndDirNumber->dirNumber;
-}
-
-static bool equalFuncNumberToOffset(const void *elt1, const void *elt2)
-{
- const TIFFOffsetAndDirNumber *offsetAndDirNumber1 =
- (const TIFFOffsetAndDirNumber *)elt1;
- const TIFFOffsetAndDirNumber *offsetAndDirNumber2 =
- (const TIFFOffsetAndDirNumber *)elt2;
- return offsetAndDirNumber1->dirNumber == offsetAndDirNumber2->dirNumber;
-}
-
-/*
- * Check the directory number and offset against the list of already seen
- * directory numbers and offsets. This is a trick to prevent IFD looping.
- * The one can create TIFF file with looped directory pointers. We will
- * maintain a list of already seen directories and check every IFD offset
- * and its IFD number against that list. However, the offset of an IFD number
- * can change - e.g. when writing updates to file.
- * Returns 1 if all is ok; 0 if last directory or IFD loop is encountered,
- * or an error has occurred.
- */
-int _TIFFCheckDirNumberAndOffset(TIFF *tif, tdir_t dirn, uint64_t diroff)
-{
- if (diroff == 0) /* no more directories */
- return 0;
-
- if (tif->tif_map_dir_offset_to_number == NULL)
- {
- tif->tif_map_dir_offset_to_number = TIFFHashSetNew(
- hashFuncOffsetToNumber, equalFuncOffsetToNumber, free);
- if (tif->tif_map_dir_offset_to_number == NULL)
- {
- TIFFErrorExtR(tif, "_TIFFCheckDirNumberAndOffset",
- "Not enough memory");
- return 1;
- }
- }
-
- if (tif->tif_map_dir_number_to_offset == NULL)
- {
- /* No free callback for this map, as it shares the same items as
- * tif->tif_map_dir_offset_to_number. */
- tif->tif_map_dir_number_to_offset = TIFFHashSetNew(
- hashFuncNumberToOffset, equalFuncNumberToOffset, NULL);
- if (tif->tif_map_dir_number_to_offset == NULL)
- {
- TIFFErrorExtR(tif, "_TIFFCheckDirNumberAndOffset",
- "Not enough memory");
- return 1;
- }
- }
-
- /* Check if offset is already in the list:
- * - yes: check, if offset is at the same IFD number - if not, it is an IFD
- * loop
- * - no: add to list or update offset at that IFD number
- */
- TIFFOffsetAndDirNumber entry;
- entry.offset = diroff;
- entry.dirNumber = dirn;
-
- TIFFOffsetAndDirNumber *foundEntry =
- (TIFFOffsetAndDirNumber *)TIFFHashSetLookup(
- tif->tif_map_dir_offset_to_number, &entry);
- if (foundEntry)
- {
- if (foundEntry->dirNumber == dirn)
- {
- return 1;
- }
- else
- {
- TIFFWarningExtR(tif, "_TIFFCheckDirNumberAndOffset",
- "TIFF directory %d has IFD looping to directory %u "
- "at offset 0x%" PRIx64 " (%" PRIu64 ")",
- (int)dirn - 1, foundEntry->dirNumber, diroff,
- diroff);
- return 0;
- }
- }
-
- /* Check if offset of an IFD has been changed and update offset of that IFD
- * number. */
- foundEntry = (TIFFOffsetAndDirNumber *)TIFFHashSetLookup(
- tif->tif_map_dir_number_to_offset, &entry);
- if (foundEntry)
- {
- if (foundEntry->offset != diroff)
- {
- TIFFOffsetAndDirNumber entryOld;
- entryOld.offset = foundEntry->offset;
- entryOld.dirNumber = dirn;
- /* We must remove first from tif_map_dir_number_to_offset as the */
- /* entry is owned (and thus freed) by */
- /* tif_map_dir_offset_to_number */
- TIFFOffsetAndDirNumber *foundEntryOld =
- (TIFFOffsetAndDirNumber *)TIFFHashSetLookup(
- tif->tif_map_dir_number_to_offset, &entryOld);
- if (foundEntryOld)
- {
- TIFFHashSetRemove(tif->tif_map_dir_number_to_offset,
- foundEntryOld);
- }
- foundEntryOld = (TIFFOffsetAndDirNumber *)TIFFHashSetLookup(
- tif->tif_map_dir_offset_to_number, &entryOld);
- if (foundEntryOld)
- {
- TIFFHashSetRemove(tif->tif_map_dir_offset_to_number,
- foundEntryOld);
- }
-
- TIFFOffsetAndDirNumber *entryPtr = (TIFFOffsetAndDirNumber *)malloc(
- sizeof(TIFFOffsetAndDirNumber));
- if (entryPtr == NULL)
- {
- return 0;
- }
-
- /* Add IFD offset and dirn to IFD directory list */
- *entryPtr = entry;
-
- if (!TIFFHashSetInsert(tif->tif_map_dir_offset_to_number, entryPtr))
- {
- TIFFErrorExtR(
- tif, "_TIFFCheckDirNumberAndOffset",
- "Insertion in tif_map_dir_offset_to_number failed");
- return 0;
- }
- if (!TIFFHashSetInsert(tif->tif_map_dir_number_to_offset, entryPtr))
- {
- TIFFErrorExtR(
- tif, "_TIFFCheckDirNumberAndOffset",
- "Insertion in tif_map_dir_number_to_offset failed");
- return 0;
- }
- }
- return 1;
- }
-
- /* Arbitrary (hopefully big enough) limit */
- if (TIFFHashSetSize(tif->tif_map_dir_offset_to_number) >=
- TIFF_MAX_DIR_COUNT)
- {
- TIFFErrorExtR(tif, "_TIFFCheckDirNumberAndOffset",
- "Cannot handle more than %u TIFF directories",
- TIFF_MAX_DIR_COUNT);
- return 0;
- }
-
- TIFFOffsetAndDirNumber *entryPtr =
- (TIFFOffsetAndDirNumber *)malloc(sizeof(TIFFOffsetAndDirNumber));
- if (entryPtr == NULL)
- {
- TIFFErrorExtR(tif, "_TIFFCheckDirNumberAndOffset",
- "malloc(sizeof(TIFFOffsetAndDirNumber)) failed");
- return 0;
- }
-
- /* Add IFD offset and dirn to IFD directory list */
- *entryPtr = entry;
-
- if (!TIFFHashSetInsert(tif->tif_map_dir_offset_to_number, entryPtr))
- {
- TIFFErrorExtR(tif, "_TIFFCheckDirNumberAndOffset",
- "Insertion in tif_map_dir_offset_to_number failed");
- return 0;
- }
- if (!TIFFHashSetInsert(tif->tif_map_dir_number_to_offset, entryPtr))
- {
- TIFFErrorExtR(tif, "_TIFFCheckDirNumberAndOffset",
- "Insertion in tif_map_dir_number_to_offset failed");
- return 0;
- }
-
- return 1;
-} /* --- _TIFFCheckDirNumberAndOffset() ---*/
-
-/*
- * Retrieve the matching IFD directory number of a given IFD offset
- * from the list of directories already seen.
- * Returns 1 if the offset was in the list and the directory number
- * can be returned.
- * Otherwise returns 0 or if an error occurred.
- */
-int _TIFFGetDirNumberFromOffset(TIFF *tif, uint64_t diroff, tdir_t *dirn)
-{
- if (diroff == 0) /* no more directories */
- return 0;
-
- /* Check if offset is already in the list and return matching directory
- * number. Otherwise update IFD list using TIFFNumberOfDirectories() and
- * search again in IFD list.
- */
- if (tif->tif_map_dir_offset_to_number == NULL)
- return 0;
- TIFFOffsetAndDirNumber entry;
- entry.offset = diroff;
- entry.dirNumber = 0; /* not used */
-
- TIFFOffsetAndDirNumber *foundEntry =
- (TIFFOffsetAndDirNumber *)TIFFHashSetLookup(
- tif->tif_map_dir_offset_to_number, &entry);
- if (foundEntry)
- {
- *dirn = foundEntry->dirNumber;
- return 1;
- }
-
- /* This updates the directory list for all main-IFDs in the file. */
- TIFFNumberOfDirectories(tif);
-
- foundEntry = (TIFFOffsetAndDirNumber *)TIFFHashSetLookup(
- tif->tif_map_dir_offset_to_number, &entry);
- if (foundEntry)
- {
- *dirn = foundEntry->dirNumber;
- return 1;
- }
-
- return 0;
-} /*--- _TIFFGetDirNumberFromOffset() ---*/
-
-/*
- * Retrieve the matching IFD directory offset of a given IFD number
- * from the list of directories already seen.
- * Returns 1 if the offset was in the list of already seen IFDs and the
- * directory offset can be returned. The directory list is not updated.
- * Otherwise returns 0 or if an error occurred.
- */
-int _TIFFGetOffsetFromDirNumber(TIFF *tif, tdir_t dirn, uint64_t *diroff)
-{
-
- if (tif->tif_map_dir_number_to_offset == NULL)
- return 0;
- TIFFOffsetAndDirNumber entry;
- entry.offset = 0; /* not used */
- entry.dirNumber = dirn;
-
- TIFFOffsetAndDirNumber *foundEntry =
- (TIFFOffsetAndDirNumber *)TIFFHashSetLookup(
- tif->tif_map_dir_number_to_offset, &entry);
- if (foundEntry)
- {
- *diroff = foundEntry->offset;
- return 1;
- }
-
- return 0;
-} /*--- _TIFFGetOffsetFromDirNumber() ---*/
-
-/*
- * Remove an entry from the directory list of already seen directories
- * by directory offset.
- * If an entry is to be removed from the list, it is also okay if the entry
- * is not in the list or the list does not exist.
- */
-int _TIFFRemoveEntryFromDirectoryListByOffset(TIFF *tif, uint64_t diroff)
-{
- if (tif->tif_map_dir_offset_to_number == NULL)
- return 1;
-
- TIFFOffsetAndDirNumber entryOld;
- entryOld.offset = diroff;
- entryOld.dirNumber = 0;
- /* We must remove first from tif_map_dir_number_to_offset as the
- * entry is owned (and thus freed) by tif_map_dir_offset_to_number.
- * However, we need firstly to find the directory number from offset. */
-
- TIFFOffsetAndDirNumber *foundEntryOldOff =
- (TIFFOffsetAndDirNumber *)TIFFHashSetLookup(
- tif->tif_map_dir_offset_to_number, &entryOld);
- if (foundEntryOldOff)
- {
- entryOld.dirNumber = foundEntryOldOff->dirNumber;
- if (tif->tif_map_dir_number_to_offset != NULL)
- {
- TIFFOffsetAndDirNumber *foundEntryOldDir =
- (TIFFOffsetAndDirNumber *)TIFFHashSetLookup(
- tif->tif_map_dir_number_to_offset, &entryOld);
- if (foundEntryOldDir)
- {
- TIFFHashSetRemove(tif->tif_map_dir_number_to_offset,
- foundEntryOldDir);
- TIFFHashSetRemove(tif->tif_map_dir_offset_to_number,
- foundEntryOldOff);
- return 1;
- }
- }
- else
- {
- TIFFErrorExtR(tif, "_TIFFRemoveEntryFromDirectoryListByOffset",
- "Unexpectedly tif_map_dir_number_to_offset is "
- "missing but tif_map_dir_offset_to_number exists.");
- return 0;
- }
- }
- return 1;
-} /*--- _TIFFRemoveEntryFromDirectoryListByOffset() ---*/
-
-/*
- * Check the count field of a directory entry against a known value. The
- * caller is expected to skip/ignore the tag if there is a mismatch.
- */
-static int CheckDirCount(TIFF *tif, TIFFDirEntry *dir, uint32_t count)
-{
- if ((uint64_t)count > dir->tdir_count)
- {
- const TIFFField *fip = TIFFFieldWithTag(tif, dir->tdir_tag);
- TIFFWarningExtR(tif, tif->tif_name,
- "incorrect count for field \"%s\" (%" PRIu64
- ", expecting %" PRIu32 "); tag ignored",
- fip ? fip->field_name : "unknown tagname",
- dir->tdir_count, count);
- return (0);
- }
- else if ((uint64_t)count < dir->tdir_count)
- {
- const TIFFField *fip = TIFFFieldWithTag(tif, dir->tdir_tag);
- TIFFWarningExtR(tif, tif->tif_name,
- "incorrect count for field \"%s\" (%" PRIu64
- ", expecting %" PRIu32 "); tag trimmed",
- fip ? fip->field_name : "unknown tagname",
- dir->tdir_count, count);
- dir->tdir_count = count;
- return (1);
- }
- return (1);
-}
-
-/*
- * Read IFD structure from the specified offset. If the pointer to
- * nextdiroff variable has been specified, read it too. Function returns a
- * number of fields in the directory or 0 if failed.
- */
-static uint16_t TIFFFetchDirectory(TIFF *tif, uint64_t diroff,
- TIFFDirEntry **pdir, uint64_t *nextdiroff)
-{
- static const char module[] = "TIFFFetchDirectory";
-
- void *origdir;
- uint16_t dircount16;
- uint32_t dirsize;
- TIFFDirEntry *dir;
- uint8_t *ma;
- TIFFDirEntry *mb;
- uint16_t n;
-
- assert(pdir);
-
- tif->tif_diroff = diroff;
- if (nextdiroff)
- *nextdiroff = 0;
- if (!isMapped(tif))
- {
- if (!SeekOK(tif, tif->tif_diroff))
- {
- TIFFErrorExtR(tif, module,
- "%s: Seek error accessing TIFF directory",
- tif->tif_name);
- return 0;
- }
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- {
- if (!ReadOK(tif, &dircount16, sizeof(uint16_t)))
- {
- TIFFErrorExtR(tif, module,
- "%s: Can not read TIFF directory count",
- tif->tif_name);
- return 0;
- }
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabShort(&dircount16);
- if (dircount16 > 4096)
- {
- TIFFErrorExtR(tif, module,
- "Sanity check on directory count failed, this is "
- "probably not a valid IFD offset");
- return 0;
- }
- dirsize = 12;
- }
- else
- {
- uint64_t dircount64;
- if (!ReadOK(tif, &dircount64, sizeof(uint64_t)))
- {
- TIFFErrorExtR(tif, module,
- "%s: Can not read TIFF directory count",
- tif->tif_name);
- return 0;
- }
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8(&dircount64);
- if (dircount64 > 4096)
- {
- TIFFErrorExtR(tif, module,
- "Sanity check on directory count failed, this is "
- "probably not a valid IFD offset");
- return 0;
- }
- dircount16 = (uint16_t)dircount64;
- dirsize = 20;
- }
- origdir = _TIFFCheckMalloc(tif, dircount16, dirsize,
- "to read TIFF directory");
- if (origdir == NULL)
- return 0;
- if (!ReadOK(tif, origdir, (tmsize_t)(dircount16 * dirsize)))
- {
- TIFFErrorExtR(tif, module, "%.100s: Can not read TIFF directory",
- tif->tif_name);
- _TIFFfreeExt(tif, origdir);
- return 0;
- }
- /*
- * Read offset to next directory for sequential scans if
- * needed.
- */
- if (nextdiroff)
- {
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- {
- uint32_t nextdiroff32;
- if (!ReadOK(tif, &nextdiroff32, sizeof(uint32_t)))
- nextdiroff32 = 0;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong(&nextdiroff32);
- *nextdiroff = nextdiroff32;
- }
- else
- {
- if (!ReadOK(tif, nextdiroff, sizeof(uint64_t)))
- *nextdiroff = 0;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8(nextdiroff);
- }
- }
- }
- else
- {
- tmsize_t m;
- tmsize_t off;
- if (tif->tif_diroff > (uint64_t)INT64_MAX)
- {
- TIFFErrorExtR(tif, module, "Can not read TIFF directory count");
- return (0);
- }
- off = (tmsize_t)tif->tif_diroff;
-
- /*
- * Check for integer overflow when validating the dir_off,
- * otherwise a very high offset may cause an OOB read and
- * crash the client. Make two comparisons instead of
- *
- * off + sizeof(uint16_t) > tif->tif_size
- *
- * to avoid overflow.
- */
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- {
- m = off + sizeof(uint16_t);
- if ((m < off) || (m < (tmsize_t)sizeof(uint16_t)) ||
- (m > tif->tif_size))
- {
- TIFFErrorExtR(tif, module, "Can not read TIFF directory count");
- return 0;
- }
- else
- {
- _TIFFmemcpy(&dircount16, tif->tif_base + off, sizeof(uint16_t));
- }
- off += sizeof(uint16_t);
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabShort(&dircount16);
- if (dircount16 > 4096)
- {
- TIFFErrorExtR(tif, module,
- "Sanity check on directory count failed, this is "
- "probably not a valid IFD offset");
- return 0;
- }
- dirsize = 12;
- }
- else
- {
- uint64_t dircount64;
- m = off + sizeof(uint64_t);
- if ((m < off) || (m < (tmsize_t)sizeof(uint64_t)) ||
- (m > tif->tif_size))
- {
- TIFFErrorExtR(tif, module, "Can not read TIFF directory count");
- return 0;
- }
- else
- {
- _TIFFmemcpy(&dircount64, tif->tif_base + off, sizeof(uint64_t));
- }
- off += sizeof(uint64_t);
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8(&dircount64);
- if (dircount64 > 4096)
- {
- TIFFErrorExtR(tif, module,
- "Sanity check on directory count failed, this is "
- "probably not a valid IFD offset");
- return 0;
- }
- dircount16 = (uint16_t)dircount64;
- dirsize = 20;
- }
- if (dircount16 == 0)
- {
- TIFFWarningExtR(tif, module,
- "Sanity check on directory count failed, zero tag "
- "directories not supported");
- return 0;
- }
- /* Before allocating a huge amount of memory for corrupted files, check
- * if size of requested memory is not greater than file size. */
- uint64_t filesize = TIFFGetFileSize(tif);
- uint64_t allocsize = (uint64_t)dircount16 * dirsize;
- if (allocsize > filesize)
- {
- TIFFWarningExtR(
- tif, module,
- "Requested memory size for TIFF directory of %" PRIu64
- " is greater than filesize %" PRIu64
- ". Memory not allocated, TIFF directory not read",
- allocsize, filesize);
- return 0;
- }
- origdir = _TIFFCheckMalloc(tif, dircount16, dirsize,
- "to read TIFF directory");
- if (origdir == NULL)
- return 0;
- m = off + dircount16 * dirsize;
- if ((m < off) || (m < (tmsize_t)(dircount16 * dirsize)) ||
- (m > tif->tif_size))
- {
- TIFFErrorExtR(tif, module, "Can not read TIFF directory");
- _TIFFfreeExt(tif, origdir);
- return 0;
- }
- else
- {
- _TIFFmemcpy(origdir, tif->tif_base + off, dircount16 * dirsize);
- }
- if (nextdiroff)
- {
- off += dircount16 * dirsize;
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- {
- uint32_t nextdiroff32;
- m = off + sizeof(uint32_t);
- if ((m < off) || (m < (tmsize_t)sizeof(uint32_t)) ||
- (m > tif->tif_size))
- nextdiroff32 = 0;
- else
- _TIFFmemcpy(&nextdiroff32, tif->tif_base + off,
- sizeof(uint32_t));
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong(&nextdiroff32);
- *nextdiroff = nextdiroff32;
- }
- else
- {
- m = off + sizeof(uint64_t);
- if ((m < off) || (m < (tmsize_t)sizeof(uint64_t)) ||
- (m > tif->tif_size))
- *nextdiroff = 0;
- else
- _TIFFmemcpy(nextdiroff, tif->tif_base + off,
- sizeof(uint64_t));
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8(nextdiroff);
- }
- }
- }
- /* No check against filesize needed here because "dir" should have same size
- * than "origdir" checked above. */
- dir = (TIFFDirEntry *)_TIFFCheckMalloc(
- tif, dircount16, sizeof(TIFFDirEntry), "to read TIFF directory");
- if (dir == 0)
- {
- _TIFFfreeExt(tif, origdir);
- return 0;
- }
- ma = (uint8_t *)origdir;
- mb = dir;
- for (n = 0; n < dircount16; n++)
- {
- mb->tdir_ignore = FALSE;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabShort((uint16_t *)ma);
- mb->tdir_tag = *(uint16_t *)ma;
- ma += sizeof(uint16_t);
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabShort((uint16_t *)ma);
- mb->tdir_type = *(uint16_t *)ma;
- ma += sizeof(uint16_t);
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong((uint32_t *)ma);
- mb->tdir_count = (uint64_t)(*(uint32_t *)ma);
- ma += sizeof(uint32_t);
- mb->tdir_offset.toff_long8 = 0;
- *(uint32_t *)(&mb->tdir_offset) = *(uint32_t *)ma;
- ma += sizeof(uint32_t);
- }
- else
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8((uint64_t *)ma);
- mb->tdir_count = TIFFReadUInt64(ma);
- ma += sizeof(uint64_t);
- mb->tdir_offset.toff_long8 = TIFFReadUInt64(ma);
- ma += sizeof(uint64_t);
- }
- mb++;
- }
- _TIFFfreeExt(tif, origdir);
- *pdir = dir;
- return dircount16;
-}
-
-/*
- * Fetch a tag that is not handled by special case code.
- */
-static int TIFFFetchNormalTag(TIFF *tif, TIFFDirEntry *dp, int recover)
-{
- static const char module[] = "TIFFFetchNormalTag";
- enum TIFFReadDirEntryErr err;
- uint32_t fii;
- const TIFFField *fip = NULL;
- TIFFReadDirectoryFindFieldInfo(tif, dp->tdir_tag, &fii);
- if (fii == FAILED_FII)
- {
- TIFFErrorExtR(tif, "TIFFFetchNormalTag",
- "No definition found for tag %" PRIu16, dp->tdir_tag);
- return 0;
- }
- fip = tif->tif_fields[fii];
- assert(fip != NULL); /* should not happen */
- assert(fip->set_field_type !=
- TIFF_SETGET_OTHER); /* if so, we shouldn't arrive here but deal with
- this in specialized code */
- assert(fip->set_field_type !=
- TIFF_SETGET_INT); /* if so, we shouldn't arrive here as this is only
- the case for pseudo-tags */
- err = TIFFReadDirEntryErrOk;
- switch (fip->set_field_type)
- {
- case TIFF_SETGET_UNDEFINED:
- TIFFErrorExtR(
- tif, "TIFFFetchNormalTag",
- "Defined set_field_type of custom tag %u (%s) is "
- "TIFF_SETGET_UNDEFINED and thus tag is not read from file",
- fip->field_tag, fip->field_name);
- break;
- case TIFF_SETGET_ASCII:
- {
- uint8_t *data;
- assert(fip->field_passcount == 0);
- err = TIFFReadDirEntryByteArray(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- size_t mb = 0;
- int n;
- if (data != NULL)
- {
- if (dp->tdir_count > 0 && data[dp->tdir_count - 1] == 0)
- {
- /* optimization: if data is known to be 0 terminated, we
- * can use strlen() */
- mb = strlen((const char *)data);
- }
- else
- {
- /* general case. equivalent to non-portable */
- /* mb = strnlen((const char*)data,
- * (uint32_t)dp->tdir_count); */
- uint8_t *ma = data;
- while (mb < (uint32_t)dp->tdir_count)
- {
- if (*ma == 0)
- break;
- ma++;
- mb++;
- }
- }
- }
- if (!EvaluateIFDdatasizeReading(tif, dp))
- {
- if (data != NULL)
- _TIFFfreeExt(tif, data);
- return (0);
- }
- if (mb + 1 < (uint32_t)dp->tdir_count)
- TIFFWarningExtR(
- tif, module,
- "ASCII value for tag \"%s\" contains null byte in "
- "value; value incorrectly truncated during reading due "
- "to implementation limitations",
- fip->field_name);
- else if (mb + 1 > (uint32_t)dp->tdir_count)
- {
- TIFFWarningExtR(tif, module,
- "ASCII value for tag \"%s\" does not end "
- "in null byte. Forcing it to be null",
- fip->field_name);
- /* TIFFReadDirEntryArrayWithLimit() ensures this can't be
- * larger than MAX_SIZE_TAG_DATA */
- assert((uint32_t)dp->tdir_count + 1 == dp->tdir_count + 1);
- uint8_t *o =
- _TIFFmallocExt(tif, (uint32_t)dp->tdir_count + 1);
- if (o == NULL)
- {
- if (data != NULL)
- _TIFFfreeExt(tif, data);
- return (0);
- }
- if (dp->tdir_count > 0)
- {
- _TIFFmemcpy(o, data, (uint32_t)dp->tdir_count);
- }
- o[(uint32_t)dp->tdir_count] = 0;
- if (data != 0)
- _TIFFfreeExt(tif, data);
- data = o;
- }
- n = TIFFSetField(tif, dp->tdir_tag, data);
- if (data != 0)
- _TIFFfreeExt(tif, data);
- if (!n)
- return (0);
- }
- }
- break;
- case TIFF_SETGET_UINT8:
- {
- uint8_t data = 0;
- assert(fip->field_readcount == 1);
- assert(fip->field_passcount == 0);
- err = TIFFReadDirEntryByte(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!TIFFSetField(tif, dp->tdir_tag, data))
- return (0);
- }
- }
- break;
- case TIFF_SETGET_SINT8:
- {
- int8_t data = 0;
- assert(fip->field_readcount == 1);
- assert(fip->field_passcount == 0);
- err = TIFFReadDirEntrySbyte(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!TIFFSetField(tif, dp->tdir_tag, data))
- return (0);
- }
- }
- break;
- case TIFF_SETGET_UINT16:
- {
- uint16_t data;
- assert(fip->field_readcount == 1);
- assert(fip->field_passcount == 0);
- err = TIFFReadDirEntryShort(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!TIFFSetField(tif, dp->tdir_tag, data))
- return (0);
- }
- }
- break;
- case TIFF_SETGET_SINT16:
- {
- int16_t data;
- assert(fip->field_readcount == 1);
- assert(fip->field_passcount == 0);
- err = TIFFReadDirEntrySshort(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!TIFFSetField(tif, dp->tdir_tag, data))
- return (0);
- }
- }
- break;
- case TIFF_SETGET_UINT32:
- {
- uint32_t data;
- assert(fip->field_readcount == 1);
- assert(fip->field_passcount == 0);
- err = TIFFReadDirEntryLong(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!TIFFSetField(tif, dp->tdir_tag, data))
- return (0);
- }
- }
- break;
- case TIFF_SETGET_SINT32:
- {
- int32_t data;
- assert(fip->field_readcount == 1);
- assert(fip->field_passcount == 0);
- err = TIFFReadDirEntrySlong(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!TIFFSetField(tif, dp->tdir_tag, data))
- return (0);
- }
- }
- break;
- case TIFF_SETGET_UINT64:
- {
- uint64_t data;
- assert(fip->field_readcount == 1);
- assert(fip->field_passcount == 0);
- err = TIFFReadDirEntryLong8(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!EvaluateIFDdatasizeReading(tif, dp))
- return 0;
- if (!TIFFSetField(tif, dp->tdir_tag, data))
- return (0);
- }
- }
- break;
- case TIFF_SETGET_SINT64:
- {
- int64_t data;
- assert(fip->field_readcount == 1);
- assert(fip->field_passcount == 0);
- err = TIFFReadDirEntrySlong8(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!EvaluateIFDdatasizeReading(tif, dp))
- return 0;
- if (!TIFFSetField(tif, dp->tdir_tag, data))
- return (0);
- }
- }
- break;
- case TIFF_SETGET_FLOAT:
- {
- float data;
- assert(fip->field_readcount == 1);
- assert(fip->field_passcount == 0);
- err = TIFFReadDirEntryFloat(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!EvaluateIFDdatasizeReading(tif, dp))
- return 0;
- if (!TIFFSetField(tif, dp->tdir_tag, data))
- return (0);
- }
- }
- break;
- case TIFF_SETGET_DOUBLE:
- {
- double data;
- assert(fip->field_readcount == 1);
- assert(fip->field_passcount == 0);
- err = TIFFReadDirEntryDouble(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!EvaluateIFDdatasizeReading(tif, dp))
- return 0;
- if (!TIFFSetField(tif, dp->tdir_tag, data))
- return (0);
- }
- }
- break;
- case TIFF_SETGET_IFD8:
- {
- uint64_t data;
- assert(fip->field_readcount == 1);
- assert(fip->field_passcount == 0);
- err = TIFFReadDirEntryIfd8(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!EvaluateIFDdatasizeReading(tif, dp))
- return 0;
- if (!TIFFSetField(tif, dp->tdir_tag, data))
- return (0);
- }
- }
- break;
- case TIFF_SETGET_UINT16_PAIR:
- {
- uint16_t *data;
- assert(fip->field_readcount == 2);
- assert(fip->field_passcount == 0);
- if (dp->tdir_count != 2)
- {
- TIFFWarningExtR(tif, module,
- "incorrect count for field \"%s\", expected 2, "
- "got %" PRIu64,
- fip->field_name, dp->tdir_count);
- return (0);
- }
- err = TIFFReadDirEntryShortArray(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- int m;
- assert(data); /* avoid CLang static Analyzer false positive */
- m = TIFFSetField(tif, dp->tdir_tag, data[0], data[1]);
- _TIFFfreeExt(tif, data);
- if (!m)
- return (0);
- }
- }
- break;
- case TIFF_SETGET_C0_UINT8:
- {
- uint8_t *data;
- assert(fip->field_readcount >= 1);
- assert(fip->field_passcount == 0);
- if (dp->tdir_count != (uint64_t)fip->field_readcount)
- {
- TIFFWarningExtR(tif, module,
- "incorrect count for field \"%s\", expected "
- "%d, got %" PRIu64,
- fip->field_name, (int)fip->field_readcount,
- dp->tdir_count);
- return (0);
- }
- else
- {
- err = TIFFReadDirEntryByteArray(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!EvaluateIFDdatasizeReading(tif, dp))
- {
- if (data != 0)
- _TIFFfreeExt(tif, data);
- return 0;
- }
- int m;
- m = TIFFSetField(tif, dp->tdir_tag, data);
- if (data != 0)
- _TIFFfreeExt(tif, data);
- if (!m)
- return (0);
- }
- }
- }
- break;
- case TIFF_SETGET_C0_SINT8:
- {
- int8_t *data;
- assert(fip->field_readcount >= 1);
- assert(fip->field_passcount == 0);
- if (dp->tdir_count != (uint64_t)fip->field_readcount)
- {
- TIFFWarningExtR(tif, module,
- "incorrect count for field \"%s\", expected "
- "%d, got %" PRIu64,
- fip->field_name, (int)fip->field_readcount,
- dp->tdir_count);
- return (0);
- }
- else
- {
- err = TIFFReadDirEntrySbyteArray(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!EvaluateIFDdatasizeReading(tif, dp))
- {
- if (data != 0)
- _TIFFfreeExt(tif, data);
- return 0;
- }
- int m;
- m = TIFFSetField(tif, dp->tdir_tag, data);
- if (data != 0)
- _TIFFfreeExt(tif, data);
- if (!m)
- return (0);
- }
- }
- }
- break;
- case TIFF_SETGET_C0_UINT16:
- {
- uint16_t *data;
- assert(fip->field_readcount >= 1);
- assert(fip->field_passcount == 0);
- if (dp->tdir_count != (uint64_t)fip->field_readcount)
- {
- TIFFWarningExtR(tif, module,
- "incorrect count for field \"%s\", expected "
- "%d, got %" PRIu64,
- fip->field_name, (int)fip->field_readcount,
- dp->tdir_count);
- return (0);
- }
- else
- {
- err = TIFFReadDirEntryShortArray(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!EvaluateIFDdatasizeReading(tif, dp))
- {
- if (data != 0)
- _TIFFfreeExt(tif, data);
- return 0;
- }
- int m;
- m = TIFFSetField(tif, dp->tdir_tag, data);
- if (data != 0)
- _TIFFfreeExt(tif, data);
- if (!m)
- return (0);
- }
- }
- }
- break;
- case TIFF_SETGET_C0_SINT16:
- {
- int16_t *data;
- assert(fip->field_readcount >= 1);
- assert(fip->field_passcount == 0);
- if (dp->tdir_count != (uint64_t)fip->field_readcount)
- {
- TIFFWarningExtR(tif, module,
- "incorrect count for field \"%s\", expected "
- "%d, got %" PRIu64,
- fip->field_name, (int)fip->field_readcount,
- dp->tdir_count);
- return (0);
- }
- else
- {
- err = TIFFReadDirEntrySshortArray(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!EvaluateIFDdatasizeReading(tif, dp))
- {
- if (data != 0)
- _TIFFfreeExt(tif, data);
- return 0;
- }
- int m;
- m = TIFFSetField(tif, dp->tdir_tag, data);
- if (data != 0)
- _TIFFfreeExt(tif, data);
- if (!m)
- return (0);
- }
- }
- }
- break;
- case TIFF_SETGET_C0_UINT32:
- {
- uint32_t *data;
- assert(fip->field_readcount >= 1);
- assert(fip->field_passcount == 0);
- if (dp->tdir_count != (uint64_t)fip->field_readcount)
- {
- TIFFWarningExtR(tif, module,
- "incorrect count for field \"%s\", expected "
- "%d, got %" PRIu64,
- fip->field_name, (int)fip->field_readcount,
- dp->tdir_count);
- return (0);
- }
- else
- {
- err = TIFFReadDirEntryLongArray(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!EvaluateIFDdatasizeReading(tif, dp))
- {
- if (data != 0)
- _TIFFfreeExt(tif, data);
- return 0;
- }
- int m;
- m = TIFFSetField(tif, dp->tdir_tag, data);
- if (data != 0)
- _TIFFfreeExt(tif, data);
- if (!m)
- return (0);
- }
- }
- }
- break;
- case TIFF_SETGET_C0_SINT32:
- {
- int32_t *data;
- assert(fip->field_readcount >= 1);
- assert(fip->field_passcount == 0);
- if (dp->tdir_count != (uint64_t)fip->field_readcount)
- {
- TIFFWarningExtR(tif, module,
- "incorrect count for field \"%s\", expected "
- "%d, got %" PRIu64,
- fip->field_name, (int)fip->field_readcount,
- dp->tdir_count);
- return (0);
- }
- else
- {
- err = TIFFReadDirEntrySlongArray(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!EvaluateIFDdatasizeReading(tif, dp))
- {
- if (data != 0)
- _TIFFfreeExt(tif, data);
- return 0;
- }
- int m;
- m = TIFFSetField(tif, dp->tdir_tag, data);
- if (data != 0)
- _TIFFfreeExt(tif, data);
- if (!m)
- return (0);
- }
- }
- }
- break;
- case TIFF_SETGET_C0_UINT64:
- {
- uint64_t *data;
- assert(fip->field_readcount >= 1);
- assert(fip->field_passcount == 0);
- if (dp->tdir_count != (uint64_t)fip->field_readcount)
- {
- TIFFWarningExtR(tif, module,
- "incorrect count for field \"%s\", expected "
- "%d, got %" PRIu64,
- fip->field_name, (int)fip->field_readcount,
- dp->tdir_count);
- return (0);
- }
- else
- {
- err = TIFFReadDirEntryLong8Array(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!EvaluateIFDdatasizeReading(tif, dp))
- {
- if (data != 0)
- _TIFFfreeExt(tif, data);
- return 0;
- }
- int m;
- m = TIFFSetField(tif, dp->tdir_tag, data);
- if (data != 0)
- _TIFFfreeExt(tif, data);
- if (!m)
- return (0);
- }
- }
- }
- break;
- case TIFF_SETGET_C0_SINT64:
- {
- int64_t *data;
- assert(fip->field_readcount >= 1);
- assert(fip->field_passcount == 0);
- if (dp->tdir_count != (uint64_t)fip->field_readcount)
- {
- TIFFWarningExtR(tif, module,
- "incorrect count for field \"%s\", expected "
- "%d, got %" PRIu64,
- fip->field_name, (int)fip->field_readcount,
- dp->tdir_count);
- return (0);
- }
- else
- {
- err = TIFFReadDirEntrySlong8Array(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!EvaluateIFDdatasizeReading(tif, dp))
- {
- if (data != 0)
- _TIFFfreeExt(tif, data);
- return 0;
- }
- int m;
- m = TIFFSetField(tif, dp->tdir_tag, data);
- if (data != 0)
- _TIFFfreeExt(tif, data);
- if (!m)
- return (0);
- }
- }
- }
- break;
- case TIFF_SETGET_C0_FLOAT:
- {
- float *data;
- assert(fip->field_readcount >= 1);
- assert(fip->field_passcount == 0);
- if (dp->tdir_count != (uint64_t)fip->field_readcount)
- {
- TIFFWarningExtR(tif, module,
- "incorrect count for field \"%s\", expected "
- "%d, got %" PRIu64,
- fip->field_name, (int)fip->field_readcount,
- dp->tdir_count);
- return (0);
- }
- else
- {
- err = TIFFReadDirEntryFloatArray(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!EvaluateIFDdatasizeReading(tif, dp))
- {
- if (data != 0)
- _TIFFfreeExt(tif, data);
- return 0;
- }
- int m;
- m = TIFFSetField(tif, dp->tdir_tag, data);
- if (data != 0)
- _TIFFfreeExt(tif, data);
- if (!m)
- return (0);
- }
- }
- }
- break;
- /*--: Rational2Double: Extend for Double Arrays and Rational-Arrays read
- * into Double-Arrays. */
- case TIFF_SETGET_C0_DOUBLE:
- {
- double *data;
- assert(fip->field_readcount >= 1);
- assert(fip->field_passcount == 0);
- if (dp->tdir_count != (uint64_t)fip->field_readcount)
- {
- TIFFWarningExtR(tif, module,
- "incorrect count for field \"%s\", expected "
- "%d, got %" PRIu64,
- fip->field_name, (int)fip->field_readcount,
- dp->tdir_count);
- return (0);
- }
- else
- {
- err = TIFFReadDirEntryDoubleArray(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!EvaluateIFDdatasizeReading(tif, dp))
- {
- if (data != 0)
- _TIFFfreeExt(tif, data);
- return 0;
- }
- int m;
- m = TIFFSetField(tif, dp->tdir_tag, data);
- if (data != 0)
- _TIFFfreeExt(tif, data);
- if (!m)
- return (0);
- }
- }
- }
- break;
- case TIFF_SETGET_C16_ASCII:
- {
- uint8_t *data;
- assert(fip->field_readcount == TIFF_VARIABLE);
- assert(fip->field_passcount == 1);
- if (dp->tdir_count > 0xFFFF)
- err = TIFFReadDirEntryErrCount;
- else
- {
- err = TIFFReadDirEntryByteArray(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!EvaluateIFDdatasizeReading(tif, dp))
- {
- if (data != 0)
- _TIFFfreeExt(tif, data);
- return 0;
- }
- int m;
- if (data != 0 && dp->tdir_count > 0 &&
- data[dp->tdir_count - 1] != '\0')
- {
- TIFFWarningExtR(tif, module,
- "ASCII value for ASCII array tag "
- "\"%s\" does not end in null "
- "byte. Forcing it to be null",
- fip->field_name);
- /* Enlarge buffer and add terminating null. */
- uint8_t *o =
- _TIFFmallocExt(tif, (uint32_t)dp->tdir_count + 1);
- if (o == NULL)
- {
- if (data != NULL)
- _TIFFfreeExt(tif, data);
- return (0);
- }
- if (dp->tdir_count > 0)
- {
- _TIFFmemcpy(o, data, (uint32_t)dp->tdir_count);
- }
- o[(uint32_t)dp->tdir_count] = 0;
- dp->tdir_count++; /* Increment for added null. */
- if (data != 0)
- _TIFFfreeExt(tif, data);
- data = o;
- }
- m = TIFFSetField(tif, dp->tdir_tag,
- (uint16_t)(dp->tdir_count), data);
- if (data != 0)
- _TIFFfreeExt(tif, data);
- if (!m)
- return (0);
- }
- }
- }
- break;
- case TIFF_SETGET_C16_UINT8:
- {
- uint8_t *data;
- assert(fip->field_readcount == TIFF_VARIABLE);
- assert(fip->field_passcount == 1);
- if (dp->tdir_count > 0xFFFF)
- err = TIFFReadDirEntryErrCount;
- else
- {
- err = TIFFReadDirEntryByteArray(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!EvaluateIFDdatasizeReading(tif, dp))
- {
- if (data != 0)
- _TIFFfreeExt(tif, data);
- return 0;
- }
- int m;
- m = TIFFSetField(tif, dp->tdir_tag,
- (uint16_t)(dp->tdir_count), data);
- if (data != 0)
- _TIFFfreeExt(tif, data);
- if (!m)
- return (0);
- }
- }
- }
- break;
- case TIFF_SETGET_C16_SINT8:
- {
- int8_t *data;
- assert(fip->field_readcount == TIFF_VARIABLE);
- assert(fip->field_passcount == 1);
- if (dp->tdir_count > 0xFFFF)
- err = TIFFReadDirEntryErrCount;
- else
- {
- err = TIFFReadDirEntrySbyteArray(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!EvaluateIFDdatasizeReading(tif, dp))
- {
- if (data != 0)
- _TIFFfreeExt(tif, data);
- return 0;
- }
- int m;
- m = TIFFSetField(tif, dp->tdir_tag,
- (uint16_t)(dp->tdir_count), data);
- if (data != 0)
- _TIFFfreeExt(tif, data);
- if (!m)
- return (0);
- }
- }
- }
- break;
- case TIFF_SETGET_C16_UINT16:
- {
- uint16_t *data;
- assert(fip->field_readcount == TIFF_VARIABLE);
- assert(fip->field_passcount == 1);
- if (dp->tdir_count > 0xFFFF)
- err = TIFFReadDirEntryErrCount;
- else
- {
- err = TIFFReadDirEntryShortArray(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!EvaluateIFDdatasizeReading(tif, dp))
- {
- if (data != 0)
- _TIFFfreeExt(tif, data);
- return 0;
- }
- int m;
- m = TIFFSetField(tif, dp->tdir_tag,
- (uint16_t)(dp->tdir_count), data);
- if (data != 0)
- _TIFFfreeExt(tif, data);
- if (!m)
- return (0);
- }
- }
- }
- break;
- case TIFF_SETGET_C16_SINT16:
- {
- int16_t *data;
- assert(fip->field_readcount == TIFF_VARIABLE);
- assert(fip->field_passcount == 1);
- if (dp->tdir_count > 0xFFFF)
- err = TIFFReadDirEntryErrCount;
- else
- {
- err = TIFFReadDirEntrySshortArray(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!EvaluateIFDdatasizeReading(tif, dp))
- {
- if (data != 0)
- _TIFFfreeExt(tif, data);
- return 0;
- }
- int m;
- m = TIFFSetField(tif, dp->tdir_tag,
- (uint16_t)(dp->tdir_count), data);
- if (data != 0)
- _TIFFfreeExt(tif, data);
- if (!m)
- return (0);
- }
- }
- }
- break;
- case TIFF_SETGET_C16_UINT32:
- {
- uint32_t *data;
- assert(fip->field_readcount == TIFF_VARIABLE);
- assert(fip->field_passcount == 1);
- if (dp->tdir_count > 0xFFFF)
- err = TIFFReadDirEntryErrCount;
- else
- {
- err = TIFFReadDirEntryLongArray(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!EvaluateIFDdatasizeReading(tif, dp))
- {
- if (data != 0)
- _TIFFfreeExt(tif, data);
- return 0;
- }
- int m;
- m = TIFFSetField(tif, dp->tdir_tag,
- (uint16_t)(dp->tdir_count), data);
- if (data != 0)
- _TIFFfreeExt(tif, data);
- if (!m)
- return (0);
- }
- }
- }
- break;
- case TIFF_SETGET_C16_SINT32:
- {
- int32_t *data;
- assert(fip->field_readcount == TIFF_VARIABLE);
- assert(fip->field_passcount == 1);
- if (dp->tdir_count > 0xFFFF)
- err = TIFFReadDirEntryErrCount;
- else
- {
- err = TIFFReadDirEntrySlongArray(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!EvaluateIFDdatasizeReading(tif, dp))
- {
- if (data != 0)
- _TIFFfreeExt(tif, data);
- return 0;
- }
- int m;
- m = TIFFSetField(tif, dp->tdir_tag,
- (uint16_t)(dp->tdir_count), data);
- if (data != 0)
- _TIFFfreeExt(tif, data);
- if (!m)
- return (0);
- }
- }
- }
- break;
- case TIFF_SETGET_C16_UINT64:
- {
- uint64_t *data;
- assert(fip->field_readcount == TIFF_VARIABLE);
- assert(fip->field_passcount == 1);
- if (dp->tdir_count > 0xFFFF)
- err = TIFFReadDirEntryErrCount;
- else
- {
- err = TIFFReadDirEntryLong8Array(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!EvaluateIFDdatasizeReading(tif, dp))
- {
- if (data != 0)
- _TIFFfreeExt(tif, data);
- return 0;
- }
- int m;
- m = TIFFSetField(tif, dp->tdir_tag,
- (uint16_t)(dp->tdir_count), data);
- if (data != 0)
- _TIFFfreeExt(tif, data);
- if (!m)
- return (0);
- }
- }
- }
- break;
- case TIFF_SETGET_C16_SINT64:
- {
- int64_t *data;
- assert(fip->field_readcount == TIFF_VARIABLE);
- assert(fip->field_passcount == 1);
- if (dp->tdir_count > 0xFFFF)
- err = TIFFReadDirEntryErrCount;
- else
- {
- err = TIFFReadDirEntrySlong8Array(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!EvaluateIFDdatasizeReading(tif, dp))
- {
- if (data != 0)
- _TIFFfreeExt(tif, data);
- return 0;
- }
- int m;
- m = TIFFSetField(tif, dp->tdir_tag,
- (uint16_t)(dp->tdir_count), data);
- if (data != 0)
- _TIFFfreeExt(tif, data);
- if (!m)
- return (0);
- }
- }
- }
- break;
- case TIFF_SETGET_C16_FLOAT:
- {
- float *data;
- assert(fip->field_readcount == TIFF_VARIABLE);
- assert(fip->field_passcount == 1);
- if (dp->tdir_count > 0xFFFF)
- err = TIFFReadDirEntryErrCount;
- else
- {
- err = TIFFReadDirEntryFloatArray(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!EvaluateIFDdatasizeReading(tif, dp))
- {
- if (data != 0)
- _TIFFfreeExt(tif, data);
- return 0;
- }
- int m;
- m = TIFFSetField(tif, dp->tdir_tag,
- (uint16_t)(dp->tdir_count), data);
- if (data != 0)
- _TIFFfreeExt(tif, data);
- if (!m)
- return (0);
- }
- }
- }
- break;
- case TIFF_SETGET_C16_DOUBLE:
- {
- double *data;
- assert(fip->field_readcount == TIFF_VARIABLE);
- assert(fip->field_passcount == 1);
- if (dp->tdir_count > 0xFFFF)
- err = TIFFReadDirEntryErrCount;
- else
- {
- err = TIFFReadDirEntryDoubleArray(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!EvaluateIFDdatasizeReading(tif, dp))
- {
- if (data != 0)
- _TIFFfreeExt(tif, data);
- return 0;
- }
- int m;
- m = TIFFSetField(tif, dp->tdir_tag,
- (uint16_t)(dp->tdir_count), data);
- if (data != 0)
- _TIFFfreeExt(tif, data);
- if (!m)
- return (0);
- }
- }
- }
- break;
- case TIFF_SETGET_C16_IFD8:
- {
- uint64_t *data;
- assert(fip->field_readcount == TIFF_VARIABLE);
- assert(fip->field_passcount == 1);
- if (dp->tdir_count > 0xFFFF)
- err = TIFFReadDirEntryErrCount;
- else
- {
- err = TIFFReadDirEntryIfd8Array(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!EvaluateIFDdatasizeReading(tif, dp))
- {
- if (data != 0)
- _TIFFfreeExt(tif, data);
- return 0;
- }
- int m;
- m = TIFFSetField(tif, dp->tdir_tag,
- (uint16_t)(dp->tdir_count), data);
- if (data != 0)
- _TIFFfreeExt(tif, data);
- if (!m)
- return (0);
- }
- }
- }
- break;
- case TIFF_SETGET_C32_ASCII:
- {
- uint8_t *data;
- assert(fip->field_readcount == TIFF_VARIABLE2);
- assert(fip->field_passcount == 1);
- err = TIFFReadDirEntryByteArray(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!EvaluateIFDdatasizeReading(tif, dp))
- {
- if (data != 0)
- _TIFFfreeExt(tif, data);
- return 0;
- }
- int m;
- if (data != 0 && dp->tdir_count > 0 &&
- data[dp->tdir_count - 1] != '\0')
- {
- TIFFWarningExtR(
- tif, module,
- "ASCII value for ASCII array tag \"%s\" does not end "
- "in null byte. Forcing it to be null",
- fip->field_name);
- /* Enlarge buffer and add terminating null. */
- uint8_t *o =
- _TIFFmallocExt(tif, (uint32_t)dp->tdir_count + 1);
- if (o == NULL)
- {
- if (data != NULL)
- _TIFFfreeExt(tif, data);
- return (0);
- }
- if (dp->tdir_count > 0)
- {
- _TIFFmemcpy(o, data, (uint32_t)dp->tdir_count);
- }
- o[(uint32_t)dp->tdir_count] = 0;
- dp->tdir_count++; /* Increment for added null. */
- if (data != 0)
- _TIFFfreeExt(tif, data);
- data = o;
- }
- m = TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count),
- data);
- if (data != 0)
- _TIFFfreeExt(tif, data);
- if (!m)
- return (0);
- }
- }
- break;
- case TIFF_SETGET_C32_UINT8:
- {
- uint8_t *data;
- uint32_t count = 0;
- assert(fip->field_readcount == TIFF_VARIABLE2);
- assert(fip->field_passcount == 1);
- if (fip->field_tag == TIFFTAG_RICHTIFFIPTC &&
- dp->tdir_type == TIFF_LONG)
- {
- /* Adobe's software (wrongly) writes RichTIFFIPTC tag with
- * data type LONG instead of UNDEFINED. Work around this
- * frequently found issue */
- void *origdata;
- err = TIFFReadDirEntryArray(tif, dp, &count, 4, &origdata);
- if ((err != TIFFReadDirEntryErrOk) || (origdata == 0))
- {
- data = NULL;
- }
- else
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabArrayOfLong((uint32_t *)origdata, count);
- data = (uint8_t *)origdata;
- count = (uint32_t)(count * 4);
- }
- }
- else
- {
- err = TIFFReadDirEntryByteArray(tif, dp, &data);
- count = (uint32_t)(dp->tdir_count);
- }
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!EvaluateIFDdatasizeReading(tif, dp))
- {
- if (data != 0)
- _TIFFfreeExt(tif, data);
- return 0;
- }
- int m;
- m = TIFFSetField(tif, dp->tdir_tag, count, data);
- if (data != 0)
- _TIFFfreeExt(tif, data);
- if (!m)
- return (0);
- }
- }
- break;
- case TIFF_SETGET_C32_SINT8:
- {
- int8_t *data = NULL;
- assert(fip->field_readcount == TIFF_VARIABLE2);
- assert(fip->field_passcount == 1);
- err = TIFFReadDirEntrySbyteArray(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!EvaluateIFDdatasizeReading(tif, dp))
- {
- if (data != 0)
- _TIFFfreeExt(tif, data);
- return 0;
- }
- int m;
- m = TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count),
- data);
- if (data != 0)
- _TIFFfreeExt(tif, data);
- if (!m)
- return (0);
- }
- }
- break;
- case TIFF_SETGET_C32_UINT16:
- {
- uint16_t *data;
- assert(fip->field_readcount == TIFF_VARIABLE2);
- assert(fip->field_passcount == 1);
- err = TIFFReadDirEntryShortArray(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!EvaluateIFDdatasizeReading(tif, dp))
- {
- if (data != 0)
- _TIFFfreeExt(tif, data);
- return 0;
- }
- int m;
- m = TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count),
- data);
- if (data != 0)
- _TIFFfreeExt(tif, data);
- if (!m)
- return (0);
- }
- }
- break;
- case TIFF_SETGET_C32_SINT16:
- {
- int16_t *data = NULL;
- assert(fip->field_readcount == TIFF_VARIABLE2);
- assert(fip->field_passcount == 1);
- err = TIFFReadDirEntrySshortArray(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!EvaluateIFDdatasizeReading(tif, dp))
- {
- if (data != 0)
- _TIFFfreeExt(tif, data);
- return 0;
- }
- int m;
- m = TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count),
- data);
- if (data != 0)
- _TIFFfreeExt(tif, data);
- if (!m)
- return (0);
- }
- }
- break;
- case TIFF_SETGET_C32_UINT32:
- {
- uint32_t *data;
- assert(fip->field_readcount == TIFF_VARIABLE2);
- assert(fip->field_passcount == 1);
- err = TIFFReadDirEntryLongArray(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!EvaluateIFDdatasizeReading(tif, dp))
- {
- if (data != 0)
- _TIFFfreeExt(tif, data);
- return 0;
- }
- int m;
- m = TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count),
- data);
- if (data != 0)
- _TIFFfreeExt(tif, data);
- if (!m)
- return (0);
- }
- }
- break;
- case TIFF_SETGET_C32_SINT32:
- {
- int32_t *data = NULL;
- assert(fip->field_readcount == TIFF_VARIABLE2);
- assert(fip->field_passcount == 1);
- err = TIFFReadDirEntrySlongArray(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!EvaluateIFDdatasizeReading(tif, dp))
- {
- if (data != 0)
- _TIFFfreeExt(tif, data);
- return 0;
- }
- int m;
- m = TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count),
- data);
- if (data != 0)
- _TIFFfreeExt(tif, data);
- if (!m)
- return (0);
- }
- }
- break;
- case TIFF_SETGET_C32_UINT64:
- {
- uint64_t *data;
- assert(fip->field_readcount == TIFF_VARIABLE2);
- assert(fip->field_passcount == 1);
- err = TIFFReadDirEntryLong8Array(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!EvaluateIFDdatasizeReading(tif, dp))
- {
- if (data != 0)
- _TIFFfreeExt(tif, data);
- return 0;
- }
- int m;
- m = TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count),
- data);
- if (data != 0)
- _TIFFfreeExt(tif, data);
- if (!m)
- return (0);
- }
- }
- break;
- case TIFF_SETGET_C32_SINT64:
- {
- int64_t *data = NULL;
- assert(fip->field_readcount == TIFF_VARIABLE2);
- assert(fip->field_passcount == 1);
- err = TIFFReadDirEntrySlong8Array(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!EvaluateIFDdatasizeReading(tif, dp))
- {
- if (data != 0)
- _TIFFfreeExt(tif, data);
- return 0;
- }
- int m;
- m = TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count),
- data);
- if (data != 0)
- _TIFFfreeExt(tif, data);
- if (!m)
- return (0);
- }
- }
- break;
- case TIFF_SETGET_C32_FLOAT:
- {
- float *data;
- assert(fip->field_readcount == TIFF_VARIABLE2);
- assert(fip->field_passcount == 1);
- err = TIFFReadDirEntryFloatArray(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!EvaluateIFDdatasizeReading(tif, dp))
- {
- if (data != 0)
- _TIFFfreeExt(tif, data);
- return 0;
- }
- int m;
- m = TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count),
- data);
- if (data != 0)
- _TIFFfreeExt(tif, data);
- if (!m)
- return (0);
- }
- }
- break;
- case TIFF_SETGET_C32_DOUBLE:
- {
- double *data;
- assert(fip->field_readcount == TIFF_VARIABLE2);
- assert(fip->field_passcount == 1);
- err = TIFFReadDirEntryDoubleArray(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!EvaluateIFDdatasizeReading(tif, dp))
- {
- if (data != 0)
- _TIFFfreeExt(tif, data);
- return 0;
- }
- int m;
- m = TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count),
- data);
- if (data != 0)
- _TIFFfreeExt(tif, data);
- if (!m)
- return (0);
- }
- }
- break;
- case TIFF_SETGET_C32_IFD8:
- {
- uint64_t *data;
- assert(fip->field_readcount == TIFF_VARIABLE2);
- assert(fip->field_passcount == 1);
- err = TIFFReadDirEntryIfd8Array(tif, dp, &data);
- if (err == TIFFReadDirEntryErrOk)
- {
- if (!EvaluateIFDdatasizeReading(tif, dp))
- {
- if (data != 0)
- _TIFFfreeExt(tif, data);
- return 0;
- }
- int m;
- m = TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count),
- data);
- if (data != 0)
- _TIFFfreeExt(tif, data);
- if (!m)
- return (0);
- }
- }
- break;
- default:
- assert(0); /* we should never get here */
- break;
- }
- if (err != TIFFReadDirEntryErrOk)
- {
- TIFFReadDirEntryOutputErr(tif, err, module, fip->field_name, recover);
- return (0);
- }
- return (1);
-}
-
-/*
- * Fetch a set of offsets or lengths.
- * While this routine says "strips", in fact it's also used for tiles.
- */
-static int TIFFFetchStripThing(TIFF *tif, TIFFDirEntry *dir, uint32_t nstrips,
- uint64_t **lpp)
-{
- static const char module[] = "TIFFFetchStripThing";
- enum TIFFReadDirEntryErr err;
- uint64_t *data;
- err = TIFFReadDirEntryLong8ArrayWithLimit(tif, dir, &data, nstrips);
- if (err != TIFFReadDirEntryErrOk)
- {
- const TIFFField *fip = TIFFFieldWithTag(tif, dir->tdir_tag);
- TIFFReadDirEntryOutputErr(tif, err, module,
- fip ? fip->field_name : "unknown tagname", 0);
- return (0);
- }
- if (dir->tdir_count < (uint64_t)nstrips)
- {
- uint64_t *resizeddata;
- const TIFFField *fip = TIFFFieldWithTag(tif, dir->tdir_tag);
- const char *pszMax = getenv("LIBTIFF_STRILE_ARRAY_MAX_RESIZE_COUNT");
- uint32_t max_nstrips = 1000000;
- if (pszMax)
- max_nstrips = (uint32_t)atoi(pszMax);
- TIFFReadDirEntryOutputErr(tif, TIFFReadDirEntryErrCount, module,
- fip ? fip->field_name : "unknown tagname",
- (nstrips <= max_nstrips));
-
- if (nstrips > max_nstrips)
- {
- _TIFFfreeExt(tif, data);
- return (0);
- }
-
- const uint64_t allocsize = (uint64_t)nstrips * sizeof(uint64_t);
- if (allocsize > 100 * 1024 * 1024)
- {
- /* Before allocating a huge amount of memory for corrupted files,
- * check if size of requested memory is not greater than file size.
- */
- const uint64_t filesize = TIFFGetFileSize(tif);
- if (allocsize > filesize)
- {
- TIFFWarningExtR(
- tif, module,
- "Requested memory size for StripArray of %" PRIu64
- " is greater than filesize %" PRIu64
- ". Memory not allocated",
- allocsize, filesize);
- _TIFFfreeExt(tif, data);
- return (0);
- }
- }
- resizeddata = (uint64_t *)_TIFFCheckMalloc(
- tif, nstrips, sizeof(uint64_t), "for strip array");
- if (resizeddata == 0)
- {
- _TIFFfreeExt(tif, data);
- return (0);
- }
- if (dir->tdir_count)
- _TIFFmemcpy(resizeddata, data,
- (uint32_t)dir->tdir_count * sizeof(uint64_t));
- _TIFFmemset(resizeddata + (uint32_t)dir->tdir_count, 0,
- (nstrips - (uint32_t)dir->tdir_count) * sizeof(uint64_t));
- _TIFFfreeExt(tif, data);
- data = resizeddata;
- }
- *lpp = data;
- return (1);
-}
-
-/*
- * Fetch and set the SubjectDistance EXIF tag.
- */
-static int TIFFFetchSubjectDistance(TIFF *tif, TIFFDirEntry *dir)
-{
- static const char module[] = "TIFFFetchSubjectDistance";
- enum TIFFReadDirEntryErr err;
- UInt64Aligned_t m;
- m.l = 0;
- assert(sizeof(double) == 8);
- assert(sizeof(uint64_t) == 8);
- assert(sizeof(uint32_t) == 4);
- if (dir->tdir_count != 1)
- err = TIFFReadDirEntryErrCount;
- else if (dir->tdir_type != TIFF_RATIONAL)
- err = TIFFReadDirEntryErrType;
- else
- {
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- {
- uint32_t offset;
- offset = *(uint32_t *)(&dir->tdir_offset);
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong(&offset);
- err = TIFFReadDirEntryData(tif, offset, 8, m.i);
- }
- else
- {
- m.l = dir->tdir_offset.toff_long8;
- err = TIFFReadDirEntryErrOk;
- }
- }
- if (err == TIFFReadDirEntryErrOk)
- {
- double n;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabArrayOfLong(m.i, 2);
- if (m.i[0] == 0)
- n = 0.0;
- else if (m.i[0] == 0xFFFFFFFF || m.i[1] == 0)
- /*
- * XXX: Numerator 0xFFFFFFFF means that we have infinite
- * distance. Indicate that with a negative floating point
- * SubjectDistance value.
- */
- n = -1.0;
- else
- n = (double)m.i[0] / (double)m.i[1];
- return (TIFFSetField(tif, dir->tdir_tag, n));
- }
- else
- {
- TIFFReadDirEntryOutputErr(tif, err, module, "SubjectDistance", TRUE);
- return (0);
- }
-}
-
-static void allocChoppedUpStripArrays(TIFF *tif, uint32_t nstrips,
- uint64_t stripbytes,
- uint32_t rowsperstrip)
-{
- TIFFDirectory *td = &tif->tif_dir;
- uint64_t bytecount;
- uint64_t offset;
- uint64_t last_offset;
- uint64_t last_bytecount;
- uint32_t i;
- uint64_t *newcounts;
- uint64_t *newoffsets;
-
- offset = TIFFGetStrileOffset(tif, 0);
- last_offset = TIFFGetStrileOffset(tif, td->td_nstrips - 1);
- last_bytecount = TIFFGetStrileByteCount(tif, td->td_nstrips - 1);
- if (last_offset > UINT64_MAX - last_bytecount ||
- last_offset + last_bytecount < offset)
- {
- return;
- }
- bytecount = last_offset + last_bytecount - offset;
-
- /* Before allocating a huge amount of memory for corrupted files, check if
- * size of StripByteCount and StripOffset tags is not greater than
- * file size.
- */
- const uint64_t allocsize = (uint64_t)nstrips * sizeof(uint64_t) * 2;
- if (allocsize > 100 * 1024 * 1024)
- {
- const uint64_t filesize = TIFFGetFileSize(tif);
- if (allocsize > filesize)
- {
- TIFFWarningExtR(tif, "allocChoppedUpStripArrays",
- "Requested memory size for StripByteCount and "
- "StripOffsets %" PRIu64
- " is greater than filesize %" PRIu64
- ". Memory not allocated",
- allocsize, filesize);
- return;
- }
- }
-
- newcounts =
- (uint64_t *)_TIFFCheckMalloc(tif, nstrips, sizeof(uint64_t),
- "for chopped \"StripByteCounts\" array");
- newoffsets = (uint64_t *)_TIFFCheckMalloc(
- tif, nstrips, sizeof(uint64_t), "for chopped \"StripOffsets\" array");
- if (newcounts == NULL || newoffsets == NULL)
- {
- /*
- * Unable to allocate new strip information, give up and use
- * the original one strip information.
- */
- if (newcounts != NULL)
- _TIFFfreeExt(tif, newcounts);
- if (newoffsets != NULL)
- _TIFFfreeExt(tif, newoffsets);
- return;
- }
-
- /*
- * Fill the strip information arrays with new bytecounts and offsets
- * that reflect the broken-up format.
- */
- for (i = 0; i < nstrips; i++)
- {
- if (stripbytes > bytecount)
- stripbytes = bytecount;
- newcounts[i] = stripbytes;
- newoffsets[i] = stripbytes ? offset : 0;
- offset += stripbytes;
- bytecount -= stripbytes;
- }
-
- /*
- * Replace old single strip info with multi-strip info.
- */
- td->td_stripsperimage = td->td_nstrips = nstrips;
- TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rowsperstrip);
-
- _TIFFfreeExt(tif, td->td_stripbytecount_p);
- _TIFFfreeExt(tif, td->td_stripoffset_p);
- td->td_stripbytecount_p = newcounts;
- td->td_stripoffset_p = newoffsets;
-#ifdef STRIPBYTECOUNTSORTED_UNUSED
- td->td_stripbytecountsorted = 1;
-#endif
- tif->tif_flags |= TIFF_CHOPPEDUPARRAYS;
-}
-
-/*
- * Replace a single strip (tile) of uncompressed data by multiple strips
- * (tiles), each approximately STRIP_SIZE_DEFAULT bytes. This is useful for
- * dealing with large images or for dealing with machines with a limited
- * amount memory.
- */
-static void ChopUpSingleUncompressedStrip(TIFF *tif)
-{
- register TIFFDirectory *td = &tif->tif_dir;
- uint64_t bytecount;
- uint64_t offset;
- uint32_t rowblock;
- uint64_t rowblockbytes;
- uint64_t stripbytes;
- uint32_t nstrips;
- uint32_t rowsperstrip;
-
- bytecount = TIFFGetStrileByteCount(tif, 0);
- /* On a newly created file, just re-opened to be filled, we */
- /* don't want strip chop to trigger as it is going to cause issues */
- /* later ( StripOffsets and StripByteCounts improperly filled) . */
- if (bytecount == 0 && tif->tif_mode != O_RDONLY)
- return;
- offset = TIFFGetStrileByteCount(tif, 0);
- assert(td->td_planarconfig == PLANARCONFIG_CONTIG);
- if ((td->td_photometric == PHOTOMETRIC_YCBCR) && (!isUpSampled(tif)))
- rowblock = td->td_ycbcrsubsampling[1];
- else
- rowblock = 1;
- rowblockbytes = TIFFVTileSize64(tif, rowblock);
- /*
- * Make the rows hold at least one scanline, but fill specified amount
- * of data if possible.
- */
- if (rowblockbytes > STRIP_SIZE_DEFAULT)
- {
- stripbytes = rowblockbytes;
- rowsperstrip = rowblock;
- }
- else if (rowblockbytes > 0)
- {
- uint32_t rowblocksperstrip;
- rowblocksperstrip = (uint32_t)(STRIP_SIZE_DEFAULT / rowblockbytes);
- rowsperstrip = rowblocksperstrip * rowblock;
- stripbytes = rowblocksperstrip * rowblockbytes;
- }
- else
- return;
-
- /*
- * never increase the number of rows per strip
- */
- if (rowsperstrip >= td->td_rowsperstrip || rowsperstrip == 0)
- return;
- nstrips = TIFFhowmany_32(td->td_imagelength, rowsperstrip);
- if (nstrips == 0)
- return;
-
- /* If we are going to allocate a lot of memory, make sure that the */
- /* file is as big as needed */
- if (tif->tif_mode == O_RDONLY && nstrips > 1000000 &&
- (offset >= TIFFGetFileSize(tif) ||
- stripbytes > (TIFFGetFileSize(tif) - offset) / (nstrips - 1)))
- {
- return;
- }
-
- allocChoppedUpStripArrays(tif, nstrips, stripbytes, rowsperstrip);
-}
-
-/*
- * Replace a file with contiguous strips > 2 GB of uncompressed data by
- * multiple smaller strips. This is useful for
- * dealing with large images or for dealing with machines with a limited
- * amount memory.
- */
-static void TryChopUpUncompressedBigTiff(TIFF *tif)
-{
- TIFFDirectory *td = &tif->tif_dir;
- uint32_t rowblock;
- uint64_t rowblockbytes;
- uint32_t i;
- uint64_t stripsize;
- uint32_t rowblocksperstrip;
- uint32_t rowsperstrip;
- uint64_t stripbytes;
- uint32_t nstrips;
-
- stripsize = TIFFStripSize64(tif);
-
- assert(tif->tif_dir.td_planarconfig == PLANARCONFIG_CONTIG);
- assert(tif->tif_dir.td_compression == COMPRESSION_NONE);
- assert((tif->tif_flags & (TIFF_STRIPCHOP | TIFF_ISTILED)) ==
- TIFF_STRIPCHOP);
- assert(stripsize > 0x7FFFFFFFUL);
-
- /* On a newly created file, just re-opened to be filled, we */
- /* don't want strip chop to trigger as it is going to cause issues */
- /* later ( StripOffsets and StripByteCounts improperly filled) . */
- if (TIFFGetStrileByteCount(tif, 0) == 0 && tif->tif_mode != O_RDONLY)
- return;
-
- if ((td->td_photometric == PHOTOMETRIC_YCBCR) && (!isUpSampled(tif)))
- rowblock = td->td_ycbcrsubsampling[1];
- else
- rowblock = 1;
- rowblockbytes = TIFFVStripSize64(tif, rowblock);
- if (rowblockbytes == 0 || rowblockbytes > 0x7FFFFFFFUL)
- {
- /* In case of file with gigantic width */
- return;
- }
-
- /* Check that the strips are contiguous and of the expected size */
- for (i = 0; i < td->td_nstrips; i++)
- {
- if (i == td->td_nstrips - 1)
- {
- if (TIFFGetStrileByteCount(tif, i) <
- TIFFVStripSize64(tif,
- td->td_imagelength - i * td->td_rowsperstrip))
- {
- return;
- }
- }
- else
- {
- if (TIFFGetStrileByteCount(tif, i) != stripsize)
- {
- return;
- }
- if (i > 0 && TIFFGetStrileOffset(tif, i) !=
- TIFFGetStrileOffset(tif, i - 1) +
- TIFFGetStrileByteCount(tif, i - 1))
- {
- return;
- }
- }
- }
-
- /* Aim for 512 MB strips (that will still be manageable by 32 bit builds */
- rowblocksperstrip = (uint32_t)(512 * 1024 * 1024 / rowblockbytes);
- if (rowblocksperstrip == 0)
- rowblocksperstrip = 1;
- rowsperstrip = rowblocksperstrip * rowblock;
- stripbytes = rowblocksperstrip * rowblockbytes;
- assert(stripbytes <= 0x7FFFFFFFUL);
-
- if (rowsperstrip == 0)
- return;
- nstrips = TIFFhowmany_32(td->td_imagelength, rowsperstrip);
- if (nstrips == 0)
- return;
-
- /* If we are going to allocate a lot of memory, make sure that the */
- /* file is as big as needed */
- if (tif->tif_mode == O_RDONLY && nstrips > 1000000)
- {
- uint64_t last_offset = TIFFGetStrileOffset(tif, td->td_nstrips - 1);
- uint64_t filesize = TIFFGetFileSize(tif);
- uint64_t last_bytecount =
- TIFFGetStrileByteCount(tif, td->td_nstrips - 1);
- if (last_offset > filesize || last_bytecount > filesize - last_offset)
- {
- return;
- }
- }
-
- allocChoppedUpStripArrays(tif, nstrips, stripbytes, rowsperstrip);
-}
-
-TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW
-static uint64_t _TIFFUnsanitizedAddUInt64AndInt(uint64_t a, int b)
-{
- return a + b;
-}
-
-/* Read the value of [Strip|Tile]Offset or [Strip|Tile]ByteCount around
- * strip/tile of number strile. Also fetch the neighbouring values using a
- * 4096 byte page size.
- */
-static int _TIFFPartialReadStripArray(TIFF *tif, TIFFDirEntry *dirent,
- int strile, uint64_t *panVals)
-{
- static const char module[] = "_TIFFPartialReadStripArray";
-#define IO_CACHE_PAGE_SIZE 4096
-
- size_t sizeofval;
- const int bSwab = (tif->tif_flags & TIFF_SWAB) != 0;
- int sizeofvalint;
- uint64_t nBaseOffset;
- uint64_t nOffset;
- uint64_t nOffsetStartPage;
- uint64_t nOffsetEndPage;
- tmsize_t nToRead;
- tmsize_t nRead;
- uint64_t nLastStripOffset;
- int iStartBefore;
- int i;
- const uint32_t arraySize = tif->tif_dir.td_stripoffsetbyteallocsize;
- unsigned char buffer[2 * IO_CACHE_PAGE_SIZE];
-
- assert(dirent->tdir_count > 4);
-
- if (dirent->tdir_type == TIFF_SHORT)
- {
- sizeofval = sizeof(uint16_t);
- }
- else if (dirent->tdir_type == TIFF_LONG)
- {
- sizeofval = sizeof(uint32_t);
- }
- else if (dirent->tdir_type == TIFF_LONG8)
- {
- sizeofval = sizeof(uint64_t);
- }
- else if (dirent->tdir_type == TIFF_SLONG8)
- {
- /* Non conformant but used by some images as in */
- /* https://github.com/OSGeo/gdal/issues/2165 */
- sizeofval = sizeof(int64_t);
- }
- else
- {
- TIFFErrorExtR(tif, module,
- "Invalid type for [Strip|Tile][Offset/ByteCount] tag");
- panVals[strile] = 0;
- return 0;
- }
- sizeofvalint = (int)(sizeofval);
-
- if (tif->tif_flags & TIFF_BIGTIFF)
- {
- uint64_t offset = dirent->tdir_offset.toff_long8;
- if (bSwab)
- TIFFSwabLong8(&offset);
- nBaseOffset = offset;
- }
- else
- {
- uint32_t offset = dirent->tdir_offset.toff_long;
- if (bSwab)
- TIFFSwabLong(&offset);
- nBaseOffset = offset;
- }
- /* To avoid later unsigned integer overflows */
- if (nBaseOffset > (uint64_t)INT64_MAX)
- {
- TIFFErrorExtR(tif, module, "Cannot read offset/size for strile %d",
- strile);
- panVals[strile] = 0;
- return 0;
- }
- nOffset = nBaseOffset + sizeofval * strile;
- nOffsetStartPage = (nOffset / IO_CACHE_PAGE_SIZE) * IO_CACHE_PAGE_SIZE;
- nOffsetEndPage = nOffsetStartPage + IO_CACHE_PAGE_SIZE;
-
- if (nOffset + sizeofval > nOffsetEndPage)
- nOffsetEndPage += IO_CACHE_PAGE_SIZE;
-#undef IO_CACHE_PAGE_SIZE
-
- nLastStripOffset = nBaseOffset + arraySize * sizeofval;
- if (nLastStripOffset < nOffsetEndPage)
- nOffsetEndPage = nLastStripOffset;
- if (nOffsetStartPage >= nOffsetEndPage)
- {
- TIFFErrorExtR(tif, module, "Cannot read offset/size for strile %d",
- strile);
- panVals[strile] = 0;
- return 0;
- }
- if (!SeekOK(tif, nOffsetStartPage))
- {
- panVals[strile] = 0;
- return 0;
- }
-
- nToRead = (tmsize_t)(nOffsetEndPage - nOffsetStartPage);
- nRead = TIFFReadFile(tif, buffer, nToRead);
- if (nRead < nToRead)
- {
- TIFFErrorExtR(tif, module,
- "Cannot read offset/size for strile around ~%d", strile);
- return 0;
- }
- iStartBefore = -(int)((nOffset - nOffsetStartPage) / sizeofval);
- if (strile + iStartBefore < 0)
- iStartBefore = -strile;
- for (i = iStartBefore;
- (uint32_t)(strile + i) < arraySize &&
- _TIFFUnsanitizedAddUInt64AndInt(nOffset, (i + 1) * sizeofvalint) <=
- nOffsetEndPage;
- ++i)
- {
- if (dirent->tdir_type == TIFF_SHORT)
- {
- uint16_t val;
- memcpy(&val,
- buffer + (nOffset - nOffsetStartPage) + i * sizeofvalint,
- sizeof(val));
- if (bSwab)
- TIFFSwabShort(&val);
- panVals[strile + i] = val;
- }
- else if (dirent->tdir_type == TIFF_LONG)
- {
- uint32_t val;
- memcpy(&val,
- buffer + (nOffset - nOffsetStartPage) + i * sizeofvalint,
- sizeof(val));
- if (bSwab)
- TIFFSwabLong(&val);
- panVals[strile + i] = val;
- }
- else if (dirent->tdir_type == TIFF_LONG8)
- {
- uint64_t val;
- memcpy(&val,
- buffer + (nOffset - nOffsetStartPage) + i * sizeofvalint,
- sizeof(val));
- if (bSwab)
- TIFFSwabLong8(&val);
- panVals[strile + i] = val;
- }
- else /* if( dirent->tdir_type == TIFF_SLONG8 ) */
- {
- /* Non conformant data type */
- int64_t val;
- memcpy(&val,
- buffer + (nOffset - nOffsetStartPage) + i * sizeofvalint,
- sizeof(val));
- if (bSwab)
- TIFFSwabLong8((uint64_t *)&val);
- panVals[strile + i] = (uint64_t)val;
- }
- }
- return 1;
-}
-
-static int _TIFFFetchStrileValue(TIFF *tif, uint32_t strile,
- TIFFDirEntry *dirent, uint64_t **parray)
-{
- static const char module[] = "_TIFFFetchStrileValue";
- TIFFDirectory *td = &tif->tif_dir;
- if (strile >= dirent->tdir_count)
- {
- return 0;
- }
- if (strile >= td->td_stripoffsetbyteallocsize)
- {
- uint32_t nStripArrayAllocBefore = td->td_stripoffsetbyteallocsize;
- uint32_t nStripArrayAllocNew;
- uint64_t nArraySize64;
- size_t nArraySize;
- uint64_t *offsetArray;
- uint64_t *bytecountArray;
-
- if (strile > 1000000)
- {
- uint64_t filesize = TIFFGetFileSize(tif);
- /* Avoid excessive memory allocation attempt */
- /* For such a big blockid we need at least a TIFF_LONG per strile */
- /* for the offset array. */
- if (strile > filesize / sizeof(uint32_t))
- {
- TIFFErrorExtR(tif, module, "File too short");
- return 0;
- }
- }
-
- if (td->td_stripoffsetbyteallocsize == 0 &&
- td->td_nstrips < 1024 * 1024)
- {
- nStripArrayAllocNew = td->td_nstrips;
- }
- else
- {
-#define TIFF_MAX(a, b) (((a) > (b)) ? (a) : (b))
-#define TIFF_MIN(a, b) (((a) < (b)) ? (a) : (b))
- nStripArrayAllocNew = TIFF_MAX(strile + 1, 1024U * 512U);
- if (nStripArrayAllocNew < 0xFFFFFFFFU / 2)
- nStripArrayAllocNew *= 2;
- nStripArrayAllocNew = TIFF_MIN(nStripArrayAllocNew, td->td_nstrips);
- }
- assert(strile < nStripArrayAllocNew);
- nArraySize64 = (uint64_t)sizeof(uint64_t) * nStripArrayAllocNew;
- nArraySize = (size_t)(nArraySize64);
-#if SIZEOF_SIZE_T == 4
- if (nArraySize != nArraySize64)
- {
- TIFFErrorExtR(tif, module,
- "Cannot allocate strip offset and bytecount arrays");
- return 0;
- }
-#endif
- offsetArray = (uint64_t *)(_TIFFreallocExt(tif, td->td_stripoffset_p,
- nArraySize));
- bytecountArray = (uint64_t *)(_TIFFreallocExt(
- tif, td->td_stripbytecount_p, nArraySize));
- if (offsetArray)
- td->td_stripoffset_p = offsetArray;
- if (bytecountArray)
- td->td_stripbytecount_p = bytecountArray;
- if (offsetArray && bytecountArray)
- {
- td->td_stripoffsetbyteallocsize = nStripArrayAllocNew;
- /* Initialize new entries to ~0 / -1 */
- /* coverity[overrun-buffer-arg] */
- memset(td->td_stripoffset_p + nStripArrayAllocBefore, 0xFF,
- (td->td_stripoffsetbyteallocsize - nStripArrayAllocBefore) *
- sizeof(uint64_t));
- /* coverity[overrun-buffer-arg] */
- memset(td->td_stripbytecount_p + nStripArrayAllocBefore, 0xFF,
- (td->td_stripoffsetbyteallocsize - nStripArrayAllocBefore) *
- sizeof(uint64_t));
- }
- else
- {
- TIFFErrorExtR(tif, module,
- "Cannot allocate strip offset and bytecount arrays");
- _TIFFfreeExt(tif, td->td_stripoffset_p);
- td->td_stripoffset_p = NULL;
- _TIFFfreeExt(tif, td->td_stripbytecount_p);
- td->td_stripbytecount_p = NULL;
- td->td_stripoffsetbyteallocsize = 0;
- }
- }
- if (*parray == NULL || strile >= td->td_stripoffsetbyteallocsize)
- return 0;
-
- if (~((*parray)[strile]) == 0)
- {
- if (!_TIFFPartialReadStripArray(tif, dirent, strile, *parray))
- {
- (*parray)[strile] = 0;
- return 0;
- }
- }
-
- return 1;
-}
-
-static uint64_t _TIFFGetStrileOffsetOrByteCountValue(TIFF *tif, uint32_t strile,
- TIFFDirEntry *dirent,
- uint64_t **parray,
- int *pbErr)
-{
- TIFFDirectory *td = &tif->tif_dir;
- if (pbErr)
- *pbErr = 0;
- if ((tif->tif_flags & TIFF_DEFERSTRILELOAD) &&
- !(tif->tif_flags & TIFF_CHOPPEDUPARRAYS))
- {
- if (!(tif->tif_flags & TIFF_LAZYSTRILELOAD) ||
- /* If the values may fit in the toff_long/toff_long8 member */
- /* then use _TIFFFillStriles to simplify _TIFFFetchStrileValue */
- dirent->tdir_count <= 4)
- {
- if (!_TIFFFillStriles(tif))
- {
- if (pbErr)
- *pbErr = 1;
- /* Do not return, as we want this function to always */
- /* return the same value if called several times with */
- /* the same arguments */
- }
- }
- else
- {
- if (!_TIFFFetchStrileValue(tif, strile, dirent, parray))
- {
- if (pbErr)
- *pbErr = 1;
- return 0;
- }
- }
- }
- if (*parray == NULL || strile >= td->td_nstrips)
- {
- if (pbErr)
- *pbErr = 1;
- return 0;
- }
- return (*parray)[strile];
-}
-
-/* Return the value of the TileOffsets/StripOffsets array for the specified
- * tile/strile */
-uint64_t TIFFGetStrileOffset(TIFF *tif, uint32_t strile)
-{
- return TIFFGetStrileOffsetWithErr(tif, strile, NULL);
-}
-
-/* Return the value of the TileOffsets/StripOffsets array for the specified
- * tile/strile */
-uint64_t TIFFGetStrileOffsetWithErr(TIFF *tif, uint32_t strile, int *pbErr)
-{
- TIFFDirectory *td = &tif->tif_dir;
- return _TIFFGetStrileOffsetOrByteCountValue(tif, strile,
- &(td->td_stripoffset_entry),
- &(td->td_stripoffset_p), pbErr);
-}
-
-/* Return the value of the TileByteCounts/StripByteCounts array for the
- * specified tile/strile */
-uint64_t TIFFGetStrileByteCount(TIFF *tif, uint32_t strile)
-{
- return TIFFGetStrileByteCountWithErr(tif, strile, NULL);
-}
-
-/* Return the value of the TileByteCounts/StripByteCounts array for the
- * specified tile/strile */
-uint64_t TIFFGetStrileByteCountWithErr(TIFF *tif, uint32_t strile, int *pbErr)
-{
- TIFFDirectory *td = &tif->tif_dir;
- return _TIFFGetStrileOffsetOrByteCountValue(
- tif, strile, &(td->td_stripbytecount_entry), &(td->td_stripbytecount_p),
- pbErr);
-}
-
-int _TIFFFillStriles(TIFF *tif) { return _TIFFFillStrilesInternal(tif, 1); }
-
-static int _TIFFFillStrilesInternal(TIFF *tif, int loadStripByteCount)
-{
- register TIFFDirectory *td = &tif->tif_dir;
- int return_value = 1;
-
- /* Do not do anything if TIFF_DEFERSTRILELOAD is not set */
- if (!(tif->tif_flags & TIFF_DEFERSTRILELOAD) ||
- (tif->tif_flags & TIFF_CHOPPEDUPARRAYS) != 0)
- return 1;
-
- if (tif->tif_flags & TIFF_LAZYSTRILELOAD)
- {
- /* In case of lazy loading, reload completely the arrays */
- _TIFFfreeExt(tif, td->td_stripoffset_p);
- _TIFFfreeExt(tif, td->td_stripbytecount_p);
- td->td_stripoffset_p = NULL;
- td->td_stripbytecount_p = NULL;
- td->td_stripoffsetbyteallocsize = 0;
- tif->tif_flags &= ~TIFF_LAZYSTRILELOAD;
- }
-
- /* If stripoffset array is already loaded, exit with success */
- if (td->td_stripoffset_p != NULL)
- return 1;
-
- /* If tdir_count was canceled, then we already got there, but in error */
- if (td->td_stripoffset_entry.tdir_count == 0)
- return 0;
-
- if (!TIFFFetchStripThing(tif, &(td->td_stripoffset_entry), td->td_nstrips,
- &td->td_stripoffset_p))
- {
- return_value = 0;
- }
-
- if (loadStripByteCount &&
- !TIFFFetchStripThing(tif, &(td->td_stripbytecount_entry),
- td->td_nstrips, &td->td_stripbytecount_p))
- {
- return_value = 0;
- }
-
- _TIFFmemset(&(td->td_stripoffset_entry), 0, sizeof(TIFFDirEntry));
- _TIFFmemset(&(td->td_stripbytecount_entry), 0, sizeof(TIFFDirEntry));
-
-#ifdef STRIPBYTECOUNTSORTED_UNUSED
- if (tif->tif_dir.td_nstrips > 1 && return_value == 1)
- {
- uint32_t strip;
-
- tif->tif_dir.td_stripbytecountsorted = 1;
- for (strip = 1; strip < tif->tif_dir.td_nstrips; strip++)
- {
- if (tif->tif_dir.td_stripoffset_p[strip - 1] >
- tif->tif_dir.td_stripoffset_p[strip])
- {
- tif->tif_dir.td_stripbytecountsorted = 0;
- break;
- }
- }
- }
-#endif
-
- return return_value;
-}
diff --git a/contrib/libs/libtiff/tif_dirwrite.c b/contrib/libs/libtiff/tif_dirwrite.c
deleted file mode 100644
index facdeaf7b1..0000000000
--- a/contrib/libs/libtiff/tif_dirwrite.c
+++ /dev/null
@@ -1,3811 +0,0 @@
-/*
- * Copyright (c) 1988-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-/*
- * TIFF Library.
- *
- * Directory Write Support Routines.
- */
-#include "tiffiop.h"
-#include <float.h> /*--: for Rational2Double */
-#include <math.h> /*--: for Rational2Double */
-
-#ifdef HAVE_IEEEFP
-#define TIFFCvtNativeToIEEEFloat(tif, n, fp)
-#define TIFFCvtNativeToIEEEDouble(tif, n, dp)
-#else
-extern void TIFFCvtNativeToIEEEFloat(TIFF *tif, uint32_t n, float *fp);
-extern void TIFFCvtNativeToIEEEDouble(TIFF *tif, uint32_t n, double *dp);
-#endif
-
-static int TIFFWriteDirectorySec(TIFF *tif, int isimage, int imagedone,
- uint64_t *pdiroff);
-
-static int TIFFWriteDirectoryTagSampleformatArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir,
- uint16_t tag, uint32_t count,
- double *value);
-
-static int TIFFWriteDirectoryTagAscii(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t count, char *value);
-static int TIFFWriteDirectoryTagUndefinedArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t count, uint8_t *value);
-static int TIFFWriteDirectoryTagByteArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t count, uint8_t *value);
-static int TIFFWriteDirectoryTagSbyteArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t count, int8_t *value);
-static int TIFFWriteDirectoryTagShort(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint16_t value);
-static int TIFFWriteDirectoryTagShortArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t count, uint16_t *value);
-static int TIFFWriteDirectoryTagShortPerSample(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint16_t value);
-static int TIFFWriteDirectoryTagSshortArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t count, int16_t *value);
-static int TIFFWriteDirectoryTagLong(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t value);
-static int TIFFWriteDirectoryTagLongArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t count, uint32_t *value);
-static int TIFFWriteDirectoryTagSlongArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t count, int32_t *value);
-static int TIFFWriteDirectoryTagLong8Array(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t count, uint64_t *value);
-static int TIFFWriteDirectoryTagSlong8Array(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t count, int64_t *value);
-static int TIFFWriteDirectoryTagRational(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- double value);
-static int TIFFWriteDirectoryTagRationalArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t count, float *value);
-static int TIFFWriteDirectoryTagSrationalArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t count, float *value);
-static int TIFFWriteDirectoryTagFloatArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t count, float *value);
-static int TIFFWriteDirectoryTagDoubleArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t count, double *value);
-static int TIFFWriteDirectoryTagIfdArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t count, uint32_t *value);
-static int TIFFWriteDirectoryTagShortLong(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t value);
-static int TIFFWriteDirectoryTagLongLong8Array(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t count, uint64_t *value);
-static int TIFFWriteDirectoryTagIfdIfd8Array(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t count, uint64_t *value);
-static int TIFFWriteDirectoryTagColormap(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir);
-static int TIFFWriteDirectoryTagTransferfunction(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir);
-static int TIFFWriteDirectoryTagSubifd(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir);
-
-static int TIFFWriteDirectoryTagCheckedAscii(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t count, char *value);
-static int TIFFWriteDirectoryTagCheckedUndefinedArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir,
- uint16_t tag,
- uint32_t count,
- uint8_t *value);
-static int TIFFWriteDirectoryTagCheckedByteArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir,
- uint16_t tag, uint32_t count,
- uint8_t *value);
-static int TIFFWriteDirectoryTagCheckedSbyteArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir,
- uint16_t tag, uint32_t count,
- int8_t *value);
-static int TIFFWriteDirectoryTagCheckedShort(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint16_t value);
-static int TIFFWriteDirectoryTagCheckedShortArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir,
- uint16_t tag, uint32_t count,
- uint16_t *value);
-static int TIFFWriteDirectoryTagCheckedSshortArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir,
- uint16_t tag, uint32_t count,
- int16_t *value);
-static int TIFFWriteDirectoryTagCheckedLong(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t value);
-static int TIFFWriteDirectoryTagCheckedLongArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir,
- uint16_t tag, uint32_t count,
- uint32_t *value);
-static int TIFFWriteDirectoryTagCheckedSlongArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir,
- uint16_t tag, uint32_t count,
- int32_t *value);
-static int TIFFWriteDirectoryTagCheckedLong8Array(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir,
- uint16_t tag, uint32_t count,
- uint64_t *value);
-static int TIFFWriteDirectoryTagCheckedSlong8Array(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir,
- uint16_t tag, uint32_t count,
- int64_t *value);
-static int TIFFWriteDirectoryTagCheckedRational(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- double value);
-static int TIFFWriteDirectoryTagCheckedRationalArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir,
- uint16_t tag,
- uint32_t count,
- float *value);
-static int TIFFWriteDirectoryTagCheckedSrationalArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir,
- uint16_t tag,
- uint32_t count,
- float *value);
-
-/*--: Rational2Double: New functions to support true double-precision for custom
- * rational tag types. */
-static int TIFFWriteDirectoryTagRationalDoubleArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir,
- uint16_t tag,
- uint32_t count,
- double *value);
-static int TIFFWriteDirectoryTagSrationalDoubleArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir,
- uint16_t tag,
- uint32_t count,
- double *value);
-static int
-TIFFWriteDirectoryTagCheckedRationalDoubleArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t count, double *value);
-static int TIFFWriteDirectoryTagCheckedSrationalDoubleArray(
- TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count,
- double *value);
-static void DoubleToRational(double value, uint32_t *num, uint32_t *denom);
-static void DoubleToSrational(double value, int32_t *num, int32_t *denom);
-
-static int TIFFWriteDirectoryTagCheckedFloatArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir,
- uint16_t tag, uint32_t count,
- float *value);
-static int TIFFWriteDirectoryTagCheckedDoubleArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir,
- uint16_t tag, uint32_t count,
- double *value);
-static int TIFFWriteDirectoryTagCheckedIfdArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t count,
- uint32_t *value);
-static int TIFFWriteDirectoryTagCheckedIfd8Array(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir,
- uint16_t tag, uint32_t count,
- uint64_t *value);
-
-static int TIFFWriteDirectoryTagData(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint16_t datatype, uint32_t count,
- uint32_t datalength, void *data);
-
-static int TIFFLinkDirectory(TIFF *);
-
-/*
- * Write the contents of the current directory
- * to the specified file. This routine doesn't
- * handle overwriting a directory with auxiliary
- * storage that's been changed.
- */
-int TIFFWriteDirectory(TIFF *tif)
-{
- return TIFFWriteDirectorySec(tif, TRUE, TRUE, NULL);
-}
-
-/*
- * This is an advanced writing function that must be used in a particular
- * sequence, and generally together with TIFFForceStrileArrayWriting(),
- * to make its intended effect. Its aim is to modify the location
- * where the [Strip/Tile][Offsets/ByteCounts] arrays are located in the file.
- * More precisely, when TIFFWriteCheck() will be called, the tag entries for
- * those arrays will be written with type = count = offset = 0 as a temporary
- * value.
- *
- * Its effect is only valid for the current directory, and before
- * TIFFWriteDirectory() is first called, and will be reset when
- * changing directory.
- *
- * The typical sequence of calls is:
- * TIFFOpen()
- * [ TIFFCreateDirectory(tif) ]
- * Set fields with calls to TIFFSetField(tif, ...)
- * TIFFDeferStrileArrayWriting(tif)
- * TIFFWriteCheck(tif, ...)
- * TIFFWriteDirectory(tif)
- * ... potentially create other directories and come back to the above directory
- * TIFFForceStrileArrayWriting(tif): emit the arrays at the end of file
- *
- * Returns 1 in case of success, 0 otherwise.
- */
-int TIFFDeferStrileArrayWriting(TIFF *tif)
-{
- static const char module[] = "TIFFDeferStrileArrayWriting";
- if (tif->tif_mode == O_RDONLY)
- {
- TIFFErrorExtR(tif, tif->tif_name, "File opened in read-only mode");
- return 0;
- }
- if (tif->tif_diroff != 0)
- {
- TIFFErrorExtR(tif, module, "Directory has already been written");
- return 0;
- }
-
- tif->tif_dir.td_deferstrilearraywriting = TRUE;
- return 1;
-}
-
-/*
- * Similar to TIFFWriteDirectory(), writes the directory out
- * but leaves all data structures in memory so that it can be
- * written again. This will make a partially written TIFF file
- * readable before it is successfully completed/closed.
- */
-int TIFFCheckpointDirectory(TIFF *tif)
-{
- int rc;
- /* Setup the strips arrays, if they haven't already been. */
- if (tif->tif_dir.td_stripoffset_p == NULL)
- (void)TIFFSetupStrips(tif);
- rc = TIFFWriteDirectorySec(tif, TRUE, FALSE, NULL);
- (void)TIFFSetWriteOffset(tif, TIFFSeekFile(tif, 0, SEEK_END));
- return rc;
-}
-
-int TIFFWriteCustomDirectory(TIFF *tif, uint64_t *pdiroff)
-{
- return TIFFWriteDirectorySec(tif, FALSE, FALSE, pdiroff);
-}
-
-/*
- * Similar to TIFFWriteDirectorySec(), but if the directory has already
- * been written once, it is relocated to the end of the file, in case it
- * has changed in size. Note that this will result in the loss of the
- * previously used directory space.
- */
-
-static int TIFFRewriteDirectorySec(TIFF *tif, int isimage, int imagedone,
- uint64_t *pdiroff)
-{
- static const char module[] = "TIFFRewriteDirectory";
-
- /* We don't need to do anything special if it hasn't been written. */
- if (tif->tif_diroff == 0)
- return TIFFWriteDirectory(tif);
-
- /*
- * Find and zero the pointer to this directory, so that TIFFLinkDirectory
- * will cause it to be added after this directories current pre-link.
- */
- uint64_t torewritediroff = tif->tif_diroff;
-
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- {
- if (tif->tif_header.classic.tiff_diroff == tif->tif_diroff)
- {
- tif->tif_header.classic.tiff_diroff = 0;
- tif->tif_diroff = 0;
-
- TIFFSeekFile(tif, 4, SEEK_SET);
- if (!WriteOK(tif, &(tif->tif_header.classic.tiff_diroff), 4))
- {
- TIFFErrorExtR(tif, tif->tif_name, "Error updating TIFF header");
- return (0);
- }
- }
- else if (tif->tif_diroff > 0xFFFFFFFFU)
- {
- TIFFErrorExtR(tif, module,
- "tif->tif_diroff exceeds 32 bit range allowed for "
- "Classic TIFF");
- return (0);
- }
- else
- {
- uint32_t nextdir;
- nextdir = tif->tif_header.classic.tiff_diroff;
- while (1)
- {
- uint16_t dircount;
- uint32_t nextnextdir;
-
- if (!SeekOK(tif, nextdir) || !ReadOK(tif, &dircount, 2))
- {
- TIFFErrorExtR(tif, module,
- "Error fetching directory count");
- return (0);
- }
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabShort(&dircount);
- (void)TIFFSeekFile(tif, nextdir + 2 + dircount * 12, SEEK_SET);
- if (!ReadOK(tif, &nextnextdir, 4))
- {
- TIFFErrorExtR(tif, module, "Error fetching directory link");
- return (0);
- }
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong(&nextnextdir);
- if (nextnextdir == tif->tif_diroff)
- {
- uint32_t m;
- m = 0;
- (void)TIFFSeekFile(tif, nextdir + 2 + dircount * 12,
- SEEK_SET);
- if (!WriteOK(tif, &m, 4))
- {
- TIFFErrorExtR(tif, module,
- "Error writing directory link");
- return (0);
- }
- tif->tif_diroff = 0;
- /* Force a full-traversal to reach the zeroed pointer */
- tif->tif_lastdiroff = 0;
- break;
- }
- nextdir = nextnextdir;
- }
- }
- /* Remove skipped offset from IFD loop directory list. */
- _TIFFRemoveEntryFromDirectoryListByOffset(tif, torewritediroff);
- }
- else
- {
- if (tif->tif_header.big.tiff_diroff == tif->tif_diroff)
- {
- tif->tif_header.big.tiff_diroff = 0;
- tif->tif_diroff = 0;
-
- TIFFSeekFile(tif, 8, SEEK_SET);
- if (!WriteOK(tif, &(tif->tif_header.big.tiff_diroff), 8))
- {
- TIFFErrorExtR(tif, tif->tif_name, "Error updating TIFF header");
- return (0);
- }
- }
- else
- {
- uint64_t nextdir;
- nextdir = tif->tif_header.big.tiff_diroff;
- while (1)
- {
- uint64_t dircount64;
- uint16_t dircount;
- uint64_t nextnextdir;
-
- if (!SeekOK(tif, nextdir) || !ReadOK(tif, &dircount64, 8))
- {
- TIFFErrorExtR(tif, module,
- "Error fetching directory count");
- return (0);
- }
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8(&dircount64);
- if (dircount64 > 0xFFFF)
- {
- TIFFErrorExtR(tif, module,
- "Sanity check on tag count failed, likely "
- "corrupt TIFF");
- return (0);
- }
- dircount = (uint16_t)dircount64;
- (void)TIFFSeekFile(tif, nextdir + 8 + dircount * 20, SEEK_SET);
- if (!ReadOK(tif, &nextnextdir, 8))
- {
- TIFFErrorExtR(tif, module, "Error fetching directory link");
- return (0);
- }
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8(&nextnextdir);
- if (nextnextdir == tif->tif_diroff)
- {
- uint64_t m;
- m = 0;
- (void)TIFFSeekFile(tif, nextdir + 8 + dircount * 20,
- SEEK_SET);
- if (!WriteOK(tif, &m, 8))
- {
- TIFFErrorExtR(tif, module,
- "Error writing directory link");
- return (0);
- }
- tif->tif_diroff = 0;
- /* Force a full-traversal to reach the zeroed pointer */
- tif->tif_lastdiroff = 0;
- break;
- }
- nextdir = nextnextdir;
- }
- }
- /* Remove skipped offset from IFD loop directory list. */
- _TIFFRemoveEntryFromDirectoryListByOffset(tif, torewritediroff);
- }
-
- /*
- * Now use TIFFWriteDirectorySec() normally.
- */
- return TIFFWriteDirectorySec(tif, isimage, imagedone, pdiroff);
-} /*-- TIFFRewriteDirectorySec() --*/
-
-/*
- * Similar to TIFFWriteDirectory(), but if the directory has already
- * been written once, it is relocated to the end of the file, in case it
- * has changed in size. Note that this will result in the loss of the
- * previously used directory space.
- */
-int TIFFRewriteDirectory(TIFF *tif)
-{
- return TIFFRewriteDirectorySec(tif, TRUE, TRUE, NULL);
-}
-
-static int TIFFWriteDirectorySec(TIFF *tif, int isimage, int imagedone,
- uint64_t *pdiroff)
-{
- static const char module[] = "TIFFWriteDirectorySec";
- uint32_t ndir;
- TIFFDirEntry *dir;
- uint32_t dirsize;
- void *dirmem;
- uint32_t m;
- if (tif->tif_mode == O_RDONLY)
- return (1);
-
- _TIFFFillStriles(tif);
-
- /*
- * Clear write state so that subsequent images with
- * different characteristics get the right buffers
- * setup for them.
- */
- if (imagedone)
- {
- if (tif->tif_flags & TIFF_POSTENCODE)
- {
- tif->tif_flags &= ~TIFF_POSTENCODE;
- if (!(*tif->tif_postencode)(tif))
- {
- TIFFErrorExtR(tif, module,
- "Error post-encoding before directory write");
- return (0);
- }
- }
- (*tif->tif_close)(tif); /* shutdown encoder */
- /*
- * Flush any data that might have been written
- * by the compression close+cleanup routines. But
- * be careful not to write stuff if we didn't add data
- * in the previous steps as the "rawcc" data may well be
- * a previously read tile/strip in mixed read/write mode.
- */
- if (tif->tif_rawcc > 0 && (tif->tif_flags & TIFF_BEENWRITING) != 0)
- {
- if (!TIFFFlushData1(tif))
- {
- TIFFErrorExtR(tif, module,
- "Error flushing data before directory write");
- return (0);
- }
- }
- if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata)
- {
- _TIFFfreeExt(tif, tif->tif_rawdata);
- tif->tif_rawdata = NULL;
- tif->tif_rawcc = 0;
- tif->tif_rawdatasize = 0;
- tif->tif_rawdataoff = 0;
- tif->tif_rawdataloaded = 0;
- }
- tif->tif_flags &= ~(TIFF_BEENWRITING | TIFF_BUFFERSETUP);
- }
-
- if (TIFFFieldSet(tif, FIELD_COMPRESSION) &&
- (tif->tif_dir.td_compression == COMPRESSION_DEFLATE))
- {
- TIFFWarningExtR(tif, module,
- "Creating TIFF with legacy Deflate codec identifier, "
- "COMPRESSION_ADOBE_DEFLATE is more widely supported");
- }
- dir = NULL;
- dirmem = NULL;
- dirsize = 0;
- while (1)
- {
- /* The first loop only determines "ndir" and uses TIFFLinkDirectory() to
- * set the offset at which the IFD is to be written to the file.
- * The second loop writes IFD entries to the file. */
- ndir = 0;
- if (dir == NULL)
- tif->tif_dir.td_dirdatasize_write = 0;
- if (isimage)
- {
- if (TIFFFieldSet(tif, FIELD_IMAGEDIMENSIONS))
- {
- if (!TIFFWriteDirectoryTagShortLong(tif, &ndir, dir,
- TIFFTAG_IMAGEWIDTH,
- tif->tif_dir.td_imagewidth))
- goto bad;
- if (!TIFFWriteDirectoryTagShortLong(
- tif, &ndir, dir, TIFFTAG_IMAGELENGTH,
- tif->tif_dir.td_imagelength))
- goto bad;
- }
- if (TIFFFieldSet(tif, FIELD_TILEDIMENSIONS))
- {
- if (!TIFFWriteDirectoryTagShortLong(tif, &ndir, dir,
- TIFFTAG_TILEWIDTH,
- tif->tif_dir.td_tilewidth))
- goto bad;
- if (!TIFFWriteDirectoryTagShortLong(tif, &ndir, dir,
- TIFFTAG_TILELENGTH,
- tif->tif_dir.td_tilelength))
- goto bad;
- }
- if (TIFFFieldSet(tif, FIELD_RESOLUTION))
- {
- if (!TIFFWriteDirectoryTagRational(tif, &ndir, dir,
- TIFFTAG_XRESOLUTION,
- tif->tif_dir.td_xresolution))
- goto bad;
- if (!TIFFWriteDirectoryTagRational(tif, &ndir, dir,
- TIFFTAG_YRESOLUTION,
- tif->tif_dir.td_yresolution))
- goto bad;
- }
- if (TIFFFieldSet(tif, FIELD_POSITION))
- {
- if (!TIFFWriteDirectoryTagRational(tif, &ndir, dir,
- TIFFTAG_XPOSITION,
- tif->tif_dir.td_xposition))
- goto bad;
- if (!TIFFWriteDirectoryTagRational(tif, &ndir, dir,
- TIFFTAG_YPOSITION,
- tif->tif_dir.td_yposition))
- goto bad;
- }
- if (TIFFFieldSet(tif, FIELD_SUBFILETYPE))
- {
- if (!TIFFWriteDirectoryTagLong(tif, &ndir, dir,
- TIFFTAG_SUBFILETYPE,
- tif->tif_dir.td_subfiletype))
- goto bad;
- }
- if (TIFFFieldSet(tif, FIELD_BITSPERSAMPLE))
- {
- if (!TIFFWriteDirectoryTagShortPerSample(
- tif, &ndir, dir, TIFFTAG_BITSPERSAMPLE,
- tif->tif_dir.td_bitspersample))
- goto bad;
- }
- if (TIFFFieldSet(tif, FIELD_COMPRESSION))
- {
- if (!TIFFWriteDirectoryTagShort(tif, &ndir, dir,
- TIFFTAG_COMPRESSION,
- tif->tif_dir.td_compression))
- goto bad;
- }
- if (TIFFFieldSet(tif, FIELD_PHOTOMETRIC))
- {
- if (!TIFFWriteDirectoryTagShort(tif, &ndir, dir,
- TIFFTAG_PHOTOMETRIC,
- tif->tif_dir.td_photometric))
- goto bad;
- }
- if (TIFFFieldSet(tif, FIELD_THRESHHOLDING))
- {
- if (!TIFFWriteDirectoryTagShort(tif, &ndir, dir,
- TIFFTAG_THRESHHOLDING,
- tif->tif_dir.td_threshholding))
- goto bad;
- }
- if (TIFFFieldSet(tif, FIELD_FILLORDER))
- {
- if (!TIFFWriteDirectoryTagShort(tif, &ndir, dir,
- TIFFTAG_FILLORDER,
- tif->tif_dir.td_fillorder))
- goto bad;
- }
- if (TIFFFieldSet(tif, FIELD_ORIENTATION))
- {
- if (!TIFFWriteDirectoryTagShort(tif, &ndir, dir,
- TIFFTAG_ORIENTATION,
- tif->tif_dir.td_orientation))
- goto bad;
- }
- if (TIFFFieldSet(tif, FIELD_SAMPLESPERPIXEL))
- {
- if (!TIFFWriteDirectoryTagShort(
- tif, &ndir, dir, TIFFTAG_SAMPLESPERPIXEL,
- tif->tif_dir.td_samplesperpixel))
- goto bad;
- }
- if (TIFFFieldSet(tif, FIELD_ROWSPERSTRIP))
- {
- if (!TIFFWriteDirectoryTagShortLong(
- tif, &ndir, dir, TIFFTAG_ROWSPERSTRIP,
- tif->tif_dir.td_rowsperstrip))
- goto bad;
- }
- if (TIFFFieldSet(tif, FIELD_MINSAMPLEVALUE))
- {
- if (!TIFFWriteDirectoryTagShortPerSample(
- tif, &ndir, dir, TIFFTAG_MINSAMPLEVALUE,
- tif->tif_dir.td_minsamplevalue))
- goto bad;
- }
- if (TIFFFieldSet(tif, FIELD_MAXSAMPLEVALUE))
- {
- if (!TIFFWriteDirectoryTagShortPerSample(
- tif, &ndir, dir, TIFFTAG_MAXSAMPLEVALUE,
- tif->tif_dir.td_maxsamplevalue))
- goto bad;
- }
- if (TIFFFieldSet(tif, FIELD_PLANARCONFIG))
- {
- if (!TIFFWriteDirectoryTagShort(tif, &ndir, dir,
- TIFFTAG_PLANARCONFIG,
- tif->tif_dir.td_planarconfig))
- goto bad;
- }
- if (TIFFFieldSet(tif, FIELD_RESOLUTIONUNIT))
- {
- if (!TIFFWriteDirectoryTagShort(tif, &ndir, dir,
- TIFFTAG_RESOLUTIONUNIT,
- tif->tif_dir.td_resolutionunit))
- goto bad;
- }
- if (TIFFFieldSet(tif, FIELD_PAGENUMBER))
- {
- if (!TIFFWriteDirectoryTagShortArray(
- tif, &ndir, dir, TIFFTAG_PAGENUMBER, 2,
- &tif->tif_dir.td_pagenumber[0]))
- goto bad;
- }
- if (TIFFFieldSet(tif, FIELD_STRIPBYTECOUNTS))
- {
- if (!isTiled(tif))
- {
- if (!TIFFWriteDirectoryTagLongLong8Array(
- tif, &ndir, dir, TIFFTAG_STRIPBYTECOUNTS,
- tif->tif_dir.td_nstrips,
- tif->tif_dir.td_stripbytecount_p))
- goto bad;
- }
- else
- {
- if (!TIFFWriteDirectoryTagLongLong8Array(
- tif, &ndir, dir, TIFFTAG_TILEBYTECOUNTS,
- tif->tif_dir.td_nstrips,
- tif->tif_dir.td_stripbytecount_p))
- goto bad;
- }
- }
- if (TIFFFieldSet(tif, FIELD_STRIPOFFSETS))
- {
- if (!isTiled(tif))
- {
- /* td_stripoffset_p might be NULL in an odd OJPEG case. See
- * tif_dirread.c around line 3634.
- * XXX: OJPEG hack.
- * If a) compression is OJPEG, b) it's not a tiled TIFF,
- * and c) the number of strips is 1,
- * then we tolerate the absence of stripoffsets tag,
- * because, presumably, all required data is in the
- * JpegInterchangeFormat stream.
- * We can get here when using tiffset on such a file.
- * See http://bugzilla.maptools.org/show_bug.cgi?id=2500
- */
- if (tif->tif_dir.td_stripoffset_p != NULL &&
- !TIFFWriteDirectoryTagLongLong8Array(
- tif, &ndir, dir, TIFFTAG_STRIPOFFSETS,
- tif->tif_dir.td_nstrips,
- tif->tif_dir.td_stripoffset_p))
- goto bad;
- }
- else
- {
- if (!TIFFWriteDirectoryTagLongLong8Array(
- tif, &ndir, dir, TIFFTAG_TILEOFFSETS,
- tif->tif_dir.td_nstrips,
- tif->tif_dir.td_stripoffset_p))
- goto bad;
- }
- }
- if (TIFFFieldSet(tif, FIELD_COLORMAP))
- {
- if (!TIFFWriteDirectoryTagColormap(tif, &ndir, dir))
- goto bad;
- }
- if (TIFFFieldSet(tif, FIELD_EXTRASAMPLES))
- {
- if (tif->tif_dir.td_extrasamples)
- {
- uint16_t na;
- uint16_t *nb;
- TIFFGetFieldDefaulted(tif, TIFFTAG_EXTRASAMPLES, &na, &nb);
- if (!TIFFWriteDirectoryTagShortArray(
- tif, &ndir, dir, TIFFTAG_EXTRASAMPLES, na, nb))
- goto bad;
- }
- }
- if (TIFFFieldSet(tif, FIELD_SAMPLEFORMAT))
- {
- if (!TIFFWriteDirectoryTagShortPerSample(
- tif, &ndir, dir, TIFFTAG_SAMPLEFORMAT,
- tif->tif_dir.td_sampleformat))
- goto bad;
- }
- if (TIFFFieldSet(tif, FIELD_SMINSAMPLEVALUE))
- {
- if (!TIFFWriteDirectoryTagSampleformatArray(
- tif, &ndir, dir, TIFFTAG_SMINSAMPLEVALUE,
- tif->tif_dir.td_samplesperpixel,
- tif->tif_dir.td_sminsamplevalue))
- goto bad;
- }
- if (TIFFFieldSet(tif, FIELD_SMAXSAMPLEVALUE))
- {
- if (!TIFFWriteDirectoryTagSampleformatArray(
- tif, &ndir, dir, TIFFTAG_SMAXSAMPLEVALUE,
- tif->tif_dir.td_samplesperpixel,
- tif->tif_dir.td_smaxsamplevalue))
- goto bad;
- }
- if (TIFFFieldSet(tif, FIELD_IMAGEDEPTH))
- {
- if (!TIFFWriteDirectoryTagLong(tif, &ndir, dir,
- TIFFTAG_IMAGEDEPTH,
- tif->tif_dir.td_imagedepth))
- goto bad;
- }
- if (TIFFFieldSet(tif, FIELD_TILEDEPTH))
- {
- if (!TIFFWriteDirectoryTagLong(tif, &ndir, dir,
- TIFFTAG_TILEDEPTH,
- tif->tif_dir.td_tiledepth))
- goto bad;
- }
- if (TIFFFieldSet(tif, FIELD_HALFTONEHINTS))
- {
- if (!TIFFWriteDirectoryTagShortArray(
- tif, &ndir, dir, TIFFTAG_HALFTONEHINTS, 2,
- &tif->tif_dir.td_halftonehints[0]))
- goto bad;
- }
- if (TIFFFieldSet(tif, FIELD_YCBCRSUBSAMPLING))
- {
- if (!TIFFWriteDirectoryTagShortArray(
- tif, &ndir, dir, TIFFTAG_YCBCRSUBSAMPLING, 2,
- &tif->tif_dir.td_ycbcrsubsampling[0]))
- goto bad;
- }
- if (TIFFFieldSet(tif, FIELD_YCBCRPOSITIONING))
- {
- if (!TIFFWriteDirectoryTagShort(
- tif, &ndir, dir, TIFFTAG_YCBCRPOSITIONING,
- tif->tif_dir.td_ycbcrpositioning))
- goto bad;
- }
- if (TIFFFieldSet(tif, FIELD_REFBLACKWHITE))
- {
- if (!TIFFWriteDirectoryTagRationalArray(
- tif, &ndir, dir, TIFFTAG_REFERENCEBLACKWHITE, 6,
- tif->tif_dir.td_refblackwhite))
- goto bad;
- }
- if (TIFFFieldSet(tif, FIELD_TRANSFERFUNCTION))
- {
- if (!TIFFWriteDirectoryTagTransferfunction(tif, &ndir, dir))
- goto bad;
- }
- if (TIFFFieldSet(tif, FIELD_INKNAMES))
- {
- if (!TIFFWriteDirectoryTagAscii(
- tif, &ndir, dir, TIFFTAG_INKNAMES,
- tif->tif_dir.td_inknameslen, tif->tif_dir.td_inknames))
- goto bad;
- }
- if (TIFFFieldSet(tif, FIELD_NUMBEROFINKS))
- {
- if (!TIFFWriteDirectoryTagShort(tif, &ndir, dir,
- TIFFTAG_NUMBEROFINKS,
- tif->tif_dir.td_numberofinks))
- goto bad;
- }
- if (TIFFFieldSet(tif, FIELD_SUBIFD))
- {
- if (!TIFFWriteDirectoryTagSubifd(tif, &ndir, dir))
- goto bad;
- }
- {
- uint32_t n;
- for (n = 0; n < tif->tif_nfields; n++)
- {
- const TIFFField *o;
- o = tif->tif_fields[n];
- if ((o->field_bit >= FIELD_CODEC) &&
- (TIFFFieldSet(tif, o->field_bit)))
- {
- switch (o->set_field_type)
- {
- case TIFF_SETGET_ASCII:
- {
- uint32_t pa;
- char *pb;
- assert(o->field_type == TIFF_ASCII);
- assert(o->field_readcount == TIFF_VARIABLE);
- assert(o->field_passcount == 0);
- TIFFGetField(tif, o->field_tag, &pb);
- pa = (uint32_t)(strlen(pb));
- if (!TIFFWriteDirectoryTagAscii(
- tif, &ndir, dir, (uint16_t)o->field_tag,
- pa, pb))
- goto bad;
- }
- break;
- case TIFF_SETGET_UINT16:
- {
- uint16_t p;
- assert(o->field_type == TIFF_SHORT);
- assert(o->field_readcount == 1);
- assert(o->field_passcount == 0);
- TIFFGetField(tif, o->field_tag, &p);
- if (!TIFFWriteDirectoryTagShort(
- tif, &ndir, dir, (uint16_t)o->field_tag,
- p))
- goto bad;
- }
- break;
- case TIFF_SETGET_UINT32:
- {
- uint32_t p;
- assert(o->field_type == TIFF_LONG);
- assert(o->field_readcount == 1);
- assert(o->field_passcount == 0);
- TIFFGetField(tif, o->field_tag, &p);
- if (!TIFFWriteDirectoryTagLong(
- tif, &ndir, dir, (uint16_t)o->field_tag,
- p))
- goto bad;
- }
- break;
- case TIFF_SETGET_C32_UINT8:
- {
- uint32_t pa;
- void *pb;
- assert(o->field_type == TIFF_UNDEFINED);
- assert(o->field_readcount == TIFF_VARIABLE2);
- assert(o->field_passcount == 1);
- TIFFGetField(tif, o->field_tag, &pa, &pb);
- if (!TIFFWriteDirectoryTagUndefinedArray(
- tif, &ndir, dir, (uint16_t)o->field_tag,
- pa, pb))
- goto bad;
- }
- break;
- default:
- TIFFErrorExtR(
- tif, module,
- "Cannot write tag %" PRIu32 " (%s)",
- TIFFFieldTag(o),
- o->field_name ? o->field_name : "unknown");
- goto bad;
- }
- }
- }
- }
- }
- for (m = 0; m < (uint32_t)(tif->tif_dir.td_customValueCount); m++)
- {
- uint16_t tag =
- (uint16_t)tif->tif_dir.td_customValues[m].info->field_tag;
- uint32_t count = tif->tif_dir.td_customValues[m].count;
- switch (tif->tif_dir.td_customValues[m].info->field_type)
- {
- case TIFF_ASCII:
- if (!TIFFWriteDirectoryTagAscii(
- tif, &ndir, dir, tag, count,
- tif->tif_dir.td_customValues[m].value))
- goto bad;
- break;
- case TIFF_UNDEFINED:
- if (!TIFFWriteDirectoryTagUndefinedArray(
- tif, &ndir, dir, tag, count,
- tif->tif_dir.td_customValues[m].value))
- goto bad;
- break;
- case TIFF_BYTE:
- if (!TIFFWriteDirectoryTagByteArray(
- tif, &ndir, dir, tag, count,
- tif->tif_dir.td_customValues[m].value))
- goto bad;
- break;
- case TIFF_SBYTE:
- if (!TIFFWriteDirectoryTagSbyteArray(
- tif, &ndir, dir, tag, count,
- tif->tif_dir.td_customValues[m].value))
- goto bad;
- break;
- case TIFF_SHORT:
- if (!TIFFWriteDirectoryTagShortArray(
- tif, &ndir, dir, tag, count,
- tif->tif_dir.td_customValues[m].value))
- goto bad;
- break;
- case TIFF_SSHORT:
- if (!TIFFWriteDirectoryTagSshortArray(
- tif, &ndir, dir, tag, count,
- tif->tif_dir.td_customValues[m].value))
- goto bad;
- break;
- case TIFF_LONG:
- if (!TIFFWriteDirectoryTagLongArray(
- tif, &ndir, dir, tag, count,
- tif->tif_dir.td_customValues[m].value))
- goto bad;
- break;
- case TIFF_SLONG:
- if (!TIFFWriteDirectoryTagSlongArray(
- tif, &ndir, dir, tag, count,
- tif->tif_dir.td_customValues[m].value))
- goto bad;
- break;
- case TIFF_LONG8:
- if (!TIFFWriteDirectoryTagLong8Array(
- tif, &ndir, dir, tag, count,
- tif->tif_dir.td_customValues[m].value))
- goto bad;
- break;
- case TIFF_SLONG8:
- if (!TIFFWriteDirectoryTagSlong8Array(
- tif, &ndir, dir, tag, count,
- tif->tif_dir.td_customValues[m].value))
- goto bad;
- break;
- case TIFF_RATIONAL:
- {
- /*-- Rational2Double: For Rationals evaluate
- * "set_field_type" to determine internal storage size. */
- int tv_size;
- tv_size = TIFFFieldSetGetSize(
- tif->tif_dir.td_customValues[m].info);
- if (tv_size == 8)
- {
- if (!TIFFWriteDirectoryTagRationalDoubleArray(
- tif, &ndir, dir, tag, count,
- tif->tif_dir.td_customValues[m].value))
- goto bad;
- }
- else
- {
- /*-- default should be tv_size == 4 */
- if (!TIFFWriteDirectoryTagRationalArray(
- tif, &ndir, dir, tag, count,
- tif->tif_dir.td_customValues[m].value))
- goto bad;
- /*-- ToDo: After Testing, this should be removed and
- * tv_size==4 should be set as default. */
- if (tv_size != 4)
- {
- TIFFErrorExtR(tif,
- "TIFFLib: _TIFFWriteDirectorySec()",
- "Rational2Double: .set_field_type is "
- "not 4 but %d",
- tv_size);
- }
- }
- }
- break;
- case TIFF_SRATIONAL:
- {
- /*-- Rational2Double: For Rationals evaluate
- * "set_field_type" to determine internal storage size. */
- int tv_size;
- tv_size = TIFFFieldSetGetSize(
- tif->tif_dir.td_customValues[m].info);
- if (tv_size == 8)
- {
- if (!TIFFWriteDirectoryTagSrationalDoubleArray(
- tif, &ndir, dir, tag, count,
- tif->tif_dir.td_customValues[m].value))
- goto bad;
- }
- else
- {
- /*-- default should be tv_size == 4 */
- if (!TIFFWriteDirectoryTagSrationalArray(
- tif, &ndir, dir, tag, count,
- tif->tif_dir.td_customValues[m].value))
- goto bad;
- /*-- ToDo: After Testing, this should be removed and
- * tv_size==4 should be set as default. */
- if (tv_size != 4)
- {
- TIFFErrorExtR(tif,
- "TIFFLib: _TIFFWriteDirectorySec()",
- "Rational2Double: .set_field_type is "
- "not 4 but %d",
- tv_size);
- }
- }
- }
- break;
- case TIFF_FLOAT:
- if (!TIFFWriteDirectoryTagFloatArray(
- tif, &ndir, dir, tag, count,
- tif->tif_dir.td_customValues[m].value))
- goto bad;
- break;
- case TIFF_DOUBLE:
- if (!TIFFWriteDirectoryTagDoubleArray(
- tif, &ndir, dir, tag, count,
- tif->tif_dir.td_customValues[m].value))
- goto bad;
- break;
- case TIFF_IFD:
- if (!TIFFWriteDirectoryTagIfdArray(
- tif, &ndir, dir, tag, count,
- tif->tif_dir.td_customValues[m].value))
- goto bad;
- break;
- case TIFF_IFD8:
- if (!TIFFWriteDirectoryTagIfdIfd8Array(
- tif, &ndir, dir, tag, count,
- tif->tif_dir.td_customValues[m].value))
- goto bad;
- break;
- default:
- assert(0); /* we should never get here */
- break;
- }
- }
- /* "break" if IFD has been written above in second pass.*/
- if (dir != NULL)
- break;
-
- /* Evaluate IFD data size: Finally, add the size of the IFD tag entries
- * themselves. */
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- tif->tif_dir.td_dirdatasize_write += 2 + ndir * 12 + 4;
- else
- tif->tif_dir.td_dirdatasize_write += 8 + ndir * 20 + 8;
-
- /* Setup a new directory within first pass. */
- dir = _TIFFmallocExt(tif, ndir * sizeof(TIFFDirEntry));
- if (dir == NULL)
- {
- TIFFErrorExtR(tif, module, "Out of memory");
- goto bad;
- }
- if (isimage)
- {
- /* Check, weather the IFD to be written is new or an already written
- * IFD can be overwritten or needs to be re-written to a different
- * location in the file because the IFD is extended with additional
- * tags or the IFD data size is increased.
- * - tif_diroff == 0, if a new directory has to be linked.
- * - tif_diroff != 0, IFD has been re-read from file and will be
- * overwritten or re-written.
- */
- if (tif->tif_diroff == 0)
- {
- if (!TIFFLinkDirectory(tif))
- goto bad;
- }
- else if (tif->tif_dir.td_dirdatasize_write >
- tif->tif_dir.td_dirdatasize_read)
- {
- if (dir != NULL)
- {
- _TIFFfreeExt(tif, dir);
- dir = NULL;
- }
- if (!TIFFRewriteDirectorySec(tif, isimage, imagedone, pdiroff))
- goto bad;
- return (1);
- }
- }
- else
- {
- /* For !isimage, which means custom-IFD like EXIFIFD or
- * checkpointing an IFD, determine whether to overwrite or append at
- * the end of the file.
- */
- if (!((tif->tif_dir.td_dirdatasize_read > 0) &&
- (tif->tif_dir.td_dirdatasize_write <=
- tif->tif_dir.td_dirdatasize_read)))
- {
- /* Append at end of file and increment to an even offset. */
- tif->tif_diroff =
- (TIFFSeekFile(tif, 0, SEEK_END) + 1) & (~((toff_t)1));
- }
- }
- /* Return IFD offset */
- if (pdiroff != NULL)
- *pdiroff = tif->tif_diroff;
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- dirsize = 2 + ndir * 12 + 4;
- else
- dirsize = 8 + ndir * 20 + 8;
- /* Append IFD data stright after the IFD tag entries.
- * Data that does not fit into an IFD tag entry is written to the file
- * in the second pass of the while loop. That offset is stored in "dir".
- */
- tif->tif_dataoff = tif->tif_diroff + dirsize;
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- tif->tif_dataoff = (uint32_t)tif->tif_dataoff;
- if ((tif->tif_dataoff < tif->tif_diroff) ||
- (tif->tif_dataoff < (uint64_t)dirsize))
- {
- TIFFErrorExtR(tif, module, "Maximum TIFF file size exceeded");
- goto bad;
- }
- if (tif->tif_dataoff & 1)
- tif->tif_dataoff++;
- } /* while() */
- if (isimage)
- {
- /* For SubIFDs remember offset of SubIFD tag within main IFD.
- * However, might be already done in TIFFWriteDirectoryTagSubifd() if
- * there are more than one SubIFD. */
- if (TIFFFieldSet(tif, FIELD_SUBIFD) && (tif->tif_subifdoff == 0))
- {
- uint32_t na;
- TIFFDirEntry *nb;
- for (na = 0, nb = dir;; na++, nb++)
- {
- if (na == ndir)
- {
- TIFFErrorExtR(tif, module, "Cannot find SubIFD tag");
- goto bad;
- }
- if (nb->tdir_tag == TIFFTAG_SUBIFD)
- break;
- }
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- tif->tif_subifdoff = tif->tif_diroff + 2 + na * 12 + 8;
- else
- tif->tif_subifdoff = tif->tif_diroff + 8 + na * 20 + 12;
- }
- }
- /* Copy/swab IFD entries from "dir" into "dirmem",
- * which is then written to file. */
- dirmem = _TIFFmallocExt(tif, dirsize);
- if (dirmem == NULL)
- {
- TIFFErrorExtR(tif, module, "Out of memory");
- goto bad;
- }
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- {
- uint8_t *n;
- uint32_t nTmp;
- TIFFDirEntry *o;
- n = dirmem;
- *(uint16_t *)n = (uint16_t)ndir;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabShort((uint16_t *)n);
- n += 2;
- o = dir;
- for (m = 0; m < ndir; m++)
- {
- *(uint16_t *)n = o->tdir_tag;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabShort((uint16_t *)n);
- n += 2;
- *(uint16_t *)n = o->tdir_type;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabShort((uint16_t *)n);
- n += 2;
- nTmp = (uint32_t)o->tdir_count;
- _TIFFmemcpy(n, &nTmp, 4);
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong((uint32_t *)n);
- n += 4;
- /* This is correct. The data has been */
- /* swabbed previously in TIFFWriteDirectoryTagData */
- _TIFFmemcpy(n, &o->tdir_offset, 4);
- n += 4;
- o++;
- }
- nTmp = (uint32_t)tif->tif_nextdiroff;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong(&nTmp);
- _TIFFmemcpy(n, &nTmp, 4);
- }
- else
- {
- uint8_t *n;
- TIFFDirEntry *o;
- n = dirmem;
- *(uint64_t *)n = ndir;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8((uint64_t *)n);
- n += 8;
- o = dir;
- for (m = 0; m < ndir; m++)
- {
- *(uint16_t *)n = o->tdir_tag;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabShort((uint16_t *)n);
- n += 2;
- *(uint16_t *)n = o->tdir_type;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabShort((uint16_t *)n);
- n += 2;
- _TIFFmemcpy(n, &o->tdir_count, 8);
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8((uint64_t *)n);
- n += 8;
- _TIFFmemcpy(n, &o->tdir_offset, 8);
- n += 8;
- o++;
- }
- _TIFFmemcpy(n, &tif->tif_nextdiroff, 8);
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8((uint64_t *)n);
- }
- _TIFFfreeExt(tif, dir);
- dir = NULL;
- if (!SeekOK(tif, tif->tif_diroff))
- {
- TIFFErrorExtR(tif, module,
- "IO error writing directory at seek to offset");
- goto bad;
- }
- if (!WriteOK(tif, dirmem, (tmsize_t)dirsize))
- {
- TIFFErrorExtR(tif, module, "IO error writing directory");
- goto bad;
- }
- _TIFFfreeExt(tif, dirmem);
-
- /* Increment tif_curdir if IFD wasn't already written to file and no error
- * occurred during IFD writing above. */
- if (isimage && !tif->tif_dir.td_iswrittentofile)
- {
- if (!((tif->tif_flags & TIFF_INSUBIFD) &&
- !(TIFFFieldSet(tif, FIELD_SUBIFD))))
- {
- /*-- Normal main-IFD case --*/
- if (tif->tif_curdircount != TIFF_NON_EXISTENT_DIR_NUMBER)
- {
- tif->tif_curdir = tif->tif_curdircount;
- }
- else
- {
- /*ToDo SU: NEW_IFD_CURDIR_INCREMENTING: Delete this
- * unexpected case after some testing time. */
- /* Attention: tif->tif_curdircount is already set within
- * TIFFNumberOfDirectories() */
- tif->tif_curdircount = TIFFNumberOfDirectories(tif);
- tif->tif_curdir = tif->tif_curdircount;
- TIFFErrorExtR(
- tif, module,
- "tif_curdircount is TIFF_NON_EXISTENT_DIR_NUMBER, "
- "not expected !! Line %d",
- __LINE__);
- goto bad;
- }
- }
- else
- {
- /*-- SubIFD case -- */
- /* tif_curdir is always set to 0 for all SubIFDs. */
- tif->tif_curdir = 0;
- }
- }
- /* Increment tif_curdircount only if main-IFD of an image was not already
- * present on file. */
- /* Check in combination with (... && !(TIFFFieldSet(tif, FIELD_SUBIFD)))
- * is necessary here because TIFF_INSUBIFD was already set above for the
- * next SubIFD when this main-IFD (with FIELD_SUBIFD) is currently being
- * written. */
- if (isimage && !tif->tif_dir.td_iswrittentofile &&
- !((tif->tif_flags & TIFF_INSUBIFD) &&
- !(TIFFFieldSet(tif, FIELD_SUBIFD))))
- tif->tif_curdircount++;
-
- tif->tif_dir.td_iswrittentofile = TRUE;
-
- /* Reset SubIFD writing stage after last SubIFD has been written. */
- if (imagedone && (tif->tif_flags & TIFF_INSUBIFD) && tif->tif_nsubifd == 0)
- tif->tif_flags &= ~TIFF_INSUBIFD;
-
- /* Add or update this directory to the IFD list. */
- if (!_TIFFCheckDirNumberAndOffset(tif, tif->tif_curdir, tif->tif_diroff))
- {
- TIFFErrorExtR(tif, module,
- "Starting directory %u at offset 0x%" PRIx64 " (%" PRIu64
- ") might cause an IFD loop",
- tif->tif_curdir, tif->tif_diroff, tif->tif_diroff);
- }
-
- if (imagedone)
- {
- TIFFFreeDirectory(tif);
- tif->tif_flags &= ~TIFF_DIRTYDIRECT;
- tif->tif_flags &= ~TIFF_DIRTYSTRIP;
- (*tif->tif_cleanup)(tif);
- /* Reset directory-related state for subsequent directories. */
- TIFFCreateDirectory(tif);
- }
- else
- {
- /* IFD is only checkpointed to file (or a custom IFD like EXIF is
- * written), thus set IFD data size written to file. */
- tif->tif_dir.td_dirdatasize_read = tif->tif_dir.td_dirdatasize_write;
- }
- return (1);
-bad:
- if (dir != NULL)
- _TIFFfreeExt(tif, dir);
- if (dirmem != NULL)
- _TIFFfreeExt(tif, dirmem);
- return (0);
-}
-
-static int8_t TIFFClampDoubleToInt8(double val)
-{
- if (val > 127)
- return 127;
- if (val < -128 || val != val)
- return -128;
- return (int8_t)val;
-}
-
-static int16_t TIFFClampDoubleToInt16(double val)
-{
- if (val > 32767)
- return 32767;
- if (val < -32768 || val != val)
- return -32768;
- return (int16_t)val;
-}
-
-static int32_t TIFFClampDoubleToInt32(double val)
-{
- if (val > 0x7FFFFFFF)
- return 0x7FFFFFFF;
- if (val < -0x7FFFFFFF - 1 || val != val)
- return -0x7FFFFFFF - 1;
- return (int32_t)val;
-}
-
-static uint8_t TIFFClampDoubleToUInt8(double val)
-{
- if (val < 0)
- return 0;
- if (val > 255 || val != val)
- return 255;
- return (uint8_t)val;
-}
-
-static uint16_t TIFFClampDoubleToUInt16(double val)
-{
- if (val < 0)
- return 0;
- if (val > 65535 || val != val)
- return 65535;
- return (uint16_t)val;
-}
-
-static uint32_t TIFFClampDoubleToUInt32(double val)
-{
- if (val < 0)
- return 0;
- if (val > 0xFFFFFFFFU || val != val)
- return 0xFFFFFFFFU;
- return (uint32_t)val;
-}
-
-static int TIFFWriteDirectoryTagSampleformatArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir,
- uint16_t tag, uint32_t count,
- double *value)
-{
- static const char module[] = "TIFFWriteDirectoryTagSampleformatArray";
- void *conv;
- uint32_t i;
- int ok;
- conv = _TIFFmallocExt(tif, count * sizeof(double));
- if (conv == NULL)
- {
- TIFFErrorExtR(tif, module, "Out of memory");
- return (0);
- }
-
- switch (tif->tif_dir.td_sampleformat)
- {
- case SAMPLEFORMAT_IEEEFP:
- if (tif->tif_dir.td_bitspersample <= 32)
- {
- for (i = 0; i < count; ++i)
- ((float *)conv)[i] = _TIFFClampDoubleToFloat(value[i]);
- ok = TIFFWriteDirectoryTagFloatArray(tif, ndir, dir, tag, count,
- (float *)conv);
- }
- else
- {
- ok = TIFFWriteDirectoryTagDoubleArray(tif, ndir, dir, tag,
- count, value);
- }
- break;
- case SAMPLEFORMAT_INT:
- if (tif->tif_dir.td_bitspersample <= 8)
- {
- for (i = 0; i < count; ++i)
- ((int8_t *)conv)[i] = TIFFClampDoubleToInt8(value[i]);
- ok = TIFFWriteDirectoryTagSbyteArray(tif, ndir, dir, tag, count,
- (int8_t *)conv);
- }
- else if (tif->tif_dir.td_bitspersample <= 16)
- {
- for (i = 0; i < count; ++i)
- ((int16_t *)conv)[i] = TIFFClampDoubleToInt16(value[i]);
- ok = TIFFWriteDirectoryTagSshortArray(tif, ndir, dir, tag,
- count, (int16_t *)conv);
- }
- else
- {
- for (i = 0; i < count; ++i)
- ((int32_t *)conv)[i] = TIFFClampDoubleToInt32(value[i]);
- ok = TIFFWriteDirectoryTagSlongArray(tif, ndir, dir, tag, count,
- (int32_t *)conv);
- }
- break;
- case SAMPLEFORMAT_UINT:
- if (tif->tif_dir.td_bitspersample <= 8)
- {
- for (i = 0; i < count; ++i)
- ((uint8_t *)conv)[i] = TIFFClampDoubleToUInt8(value[i]);
- ok = TIFFWriteDirectoryTagByteArray(tif, ndir, dir, tag, count,
- (uint8_t *)conv);
- }
- else if (tif->tif_dir.td_bitspersample <= 16)
- {
- for (i = 0; i < count; ++i)
- ((uint16_t *)conv)[i] = TIFFClampDoubleToUInt16(value[i]);
- ok = TIFFWriteDirectoryTagShortArray(tif, ndir, dir, tag, count,
- (uint16_t *)conv);
- }
- else
- {
- for (i = 0; i < count; ++i)
- ((uint32_t *)conv)[i] = TIFFClampDoubleToUInt32(value[i]);
- ok = TIFFWriteDirectoryTagLongArray(tif, ndir, dir, tag, count,
- (uint32_t *)conv);
- }
- break;
- default:
- ok = 0;
- }
-
- _TIFFfreeExt(tif, conv);
- return (ok);
-}
-
-static int TIFFWriteDirectoryTagAscii(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t count, char *value)
-{
- return (
- TIFFWriteDirectoryTagCheckedAscii(tif, ndir, dir, tag, count, value));
-}
-
-static int TIFFWriteDirectoryTagUndefinedArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t count, uint8_t *value)
-{
- return (TIFFWriteDirectoryTagCheckedUndefinedArray(tif, ndir, dir, tag,
- count, value));
-}
-
-static int TIFFWriteDirectoryTagByteArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t count, uint8_t *value)
-{
- return (TIFFWriteDirectoryTagCheckedByteArray(tif, ndir, dir, tag, count,
- value));
-}
-
-static int TIFFWriteDirectoryTagSbyteArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t count, int8_t *value)
-{
- return (TIFFWriteDirectoryTagCheckedSbyteArray(tif, ndir, dir, tag, count,
- value));
-}
-
-static int TIFFWriteDirectoryTagShort(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint16_t value)
-{
- return (TIFFWriteDirectoryTagCheckedShort(tif, ndir, dir, tag, value));
-}
-
-static int TIFFWriteDirectoryTagShortArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t count, uint16_t *value)
-{
- return (TIFFWriteDirectoryTagCheckedShortArray(tif, ndir, dir, tag, count,
- value));
-}
-
-static int TIFFWriteDirectoryTagShortPerSample(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint16_t value)
-{
- static const char module[] = "TIFFWriteDirectoryTagShortPerSample";
- uint16_t *m;
- uint16_t *na;
- uint16_t nb;
- int o;
- if (dir == NULL)
- {
- /* only evaluate IFD data size and inc. ndir */
- return (TIFFWriteDirectoryTagCheckedShortArray(
- tif, ndir, dir, tag, tif->tif_dir.td_samplesperpixel, NULL));
- }
- m = _TIFFmallocExt(tif, tif->tif_dir.td_samplesperpixel * sizeof(uint16_t));
- if (m == NULL)
- {
- TIFFErrorExtR(tif, module, "Out of memory");
- return (0);
- }
- for (na = m, nb = 0; nb < tif->tif_dir.td_samplesperpixel; na++, nb++)
- *na = value;
- o = TIFFWriteDirectoryTagCheckedShortArray(
- tif, ndir, dir, tag, tif->tif_dir.td_samplesperpixel, m);
- _TIFFfreeExt(tif, m);
- return (o);
-}
-
-static int TIFFWriteDirectoryTagSshortArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t count, int16_t *value)
-{
- return (TIFFWriteDirectoryTagCheckedSshortArray(tif, ndir, dir, tag, count,
- value));
-}
-
-static int TIFFWriteDirectoryTagLong(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t value)
-{
- return (TIFFWriteDirectoryTagCheckedLong(tif, ndir, dir, tag, value));
-}
-
-static int TIFFWriteDirectoryTagLongArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t count, uint32_t *value)
-{
- return (TIFFWriteDirectoryTagCheckedLongArray(tif, ndir, dir, tag, count,
- value));
-}
-
-static int TIFFWriteDirectoryTagSlongArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t count, int32_t *value)
-{
- return (TIFFWriteDirectoryTagCheckedSlongArray(tif, ndir, dir, tag, count,
- value));
-}
-
-/************************************************************************/
-/* TIFFWriteDirectoryTagLong8Array() */
-/* */
-/* Write either Long8 or Long array depending on file type. */
-/************************************************************************/
-static int TIFFWriteDirectoryTagLong8Array(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t count, uint64_t *value)
-{
- static const char module[] = "TIFFWriteDirectoryTagLong8Array";
- uint64_t *ma;
- uint32_t mb;
- uint32_t *p;
- uint32_t *q;
- int o;
-
- /* is this just a counting pass? */
- if (dir == NULL)
- {
- /* only evaluate IFD data size and inc. ndir */
- return (TIFFWriteDirectoryTagCheckedLong8Array(tif, ndir, dir, tag,
- count, value));
- }
-
- /* We always write Long8 for BigTIFF, no checking needed. */
- if (tif->tif_flags & TIFF_BIGTIFF)
- return (TIFFWriteDirectoryTagCheckedLong8Array(tif, ndir, dir, tag,
- count, value));
-
- /*
- ** For classic tiff we want to verify everything is in range for long
- ** and convert to long format.
- */
- p = _TIFFmallocExt(tif, count * sizeof(uint32_t));
- if (p == NULL)
- {
- TIFFErrorExtR(tif, module, "Out of memory");
- return (0);
- }
-
- for (q = p, ma = value, mb = 0; mb < count; ma++, mb++, q++)
- {
- if (*ma > 0xFFFFFFFF)
- {
- TIFFErrorExtR(tif, module,
- "Attempt to write unsigned long value %" PRIu64
- " larger than 0xFFFFFFFF for tag %d in Classic TIFF "
- "file. TIFF file writing aborted",
- *ma, tag);
- _TIFFfreeExt(tif, p);
- return (0);
- }
- *q = (uint32_t)(*ma);
- }
-
- o = TIFFWriteDirectoryTagCheckedLongArray(tif, ndir, dir, tag, count, p);
- _TIFFfreeExt(tif, p);
-
- return (o);
-}
-
-/************************************************************************/
-/* TIFFWriteDirectoryTagSlong8Array() */
-/* */
-/* Write either SLong8 or SLong array depending on file type. */
-/************************************************************************/
-static int TIFFWriteDirectoryTagSlong8Array(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t count, int64_t *value)
-{
- static const char module[] = "TIFFWriteDirectoryTagSlong8Array";
- int64_t *ma;
- uint32_t mb;
- int32_t *p;
- int32_t *q;
- int o;
-
- /* is this just a counting pass? */
- if (dir == NULL)
- {
- /* only evaluate IFD data size and inc. ndir */
- return (TIFFWriteDirectoryTagCheckedSlong8Array(tif, ndir, dir, tag,
- count, value));
- }
- /* We always write SLong8 for BigTIFF, no checking needed. */
- if (tif->tif_flags & TIFF_BIGTIFF)
- return (TIFFWriteDirectoryTagCheckedSlong8Array(tif, ndir, dir, tag,
- count, value));
-
- /*
- ** For classic tiff we want to verify everything is in range for signed-long
- ** and convert to signed-long format.
- */
- p = _TIFFmallocExt(tif, count * sizeof(uint32_t));
- if (p == NULL)
- {
- TIFFErrorExtR(tif, module, "Out of memory");
- return (0);
- }
-
- for (q = p, ma = value, mb = 0; mb < count; ma++, mb++, q++)
- {
- if (*ma > (2147483647))
- {
- TIFFErrorExtR(tif, module,
- "Attempt to write signed long value %" PRIi64
- " larger than 0x7FFFFFFF (2147483647) for tag %d in "
- "Classic TIFF file. TIFF writing to file aborted",
- *ma, tag);
- _TIFFfreeExt(tif, p);
- return (0);
- }
- else if (*ma < (-2147483647 - 1))
- {
- TIFFErrorExtR(tif, module,
- "Attempt to write signed long value %" PRIi64
- " smaller than 0x80000000 (-2147483648) for tag %d "
- "in Classic TIFF file. TIFF writing to file aborted",
- *ma, tag);
- _TIFFfreeExt(tif, p);
- return (0);
- }
- *q = (int32_t)(*ma);
- }
-
- o = TIFFWriteDirectoryTagCheckedSlongArray(tif, ndir, dir, tag, count, p);
- _TIFFfreeExt(tif, p);
-
- return (o);
-}
-
-static int TIFFWriteDirectoryTagRational(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- double value)
-{
- return (TIFFWriteDirectoryTagCheckedRational(tif, ndir, dir, tag, value));
-}
-
-static int TIFFWriteDirectoryTagRationalArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t count, float *value)
-{
- return (TIFFWriteDirectoryTagCheckedRationalArray(tif, ndir, dir, tag,
- count, value));
-}
-
-static int TIFFWriteDirectoryTagSrationalArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t count, float *value)
-{
- return (TIFFWriteDirectoryTagCheckedSrationalArray(tif, ndir, dir, tag,
- count, value));
-}
-
-/*-- Rational2Double: additional write functions */
-static int TIFFWriteDirectoryTagRationalDoubleArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir,
- uint16_t tag,
- uint32_t count,
- double *value)
-{
- return (TIFFWriteDirectoryTagCheckedRationalDoubleArray(tif, ndir, dir, tag,
- count, value));
-}
-
-static int TIFFWriteDirectoryTagSrationalDoubleArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir,
- uint16_t tag,
- uint32_t count,
- double *value)
-{
- return (TIFFWriteDirectoryTagCheckedSrationalDoubleArray(
- tif, ndir, dir, tag, count, value));
-}
-
-static int TIFFWriteDirectoryTagFloatArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t count, float *value)
-{
- return (TIFFWriteDirectoryTagCheckedFloatArray(tif, ndir, dir, tag, count,
- value));
-}
-
-static int TIFFWriteDirectoryTagDoubleArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t count, double *value)
-{
- return (TIFFWriteDirectoryTagCheckedDoubleArray(tif, ndir, dir, tag, count,
- value));
-}
-
-static int TIFFWriteDirectoryTagIfdArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t count, uint32_t *value)
-{
- return (TIFFWriteDirectoryTagCheckedIfdArray(tif, ndir, dir, tag, count,
- value));
-}
-
-static int TIFFWriteDirectoryTagShortLong(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t value)
-{
- if (value <= 0xFFFF)
- return (TIFFWriteDirectoryTagCheckedShort(tif, ndir, dir, tag,
- (uint16_t)value));
- else
- return (TIFFWriteDirectoryTagCheckedLong(tif, ndir, dir, tag, value));
-}
-
-static int _WriteAsType(TIFF *tif, uint64_t strile_size,
- uint64_t uncompressed_threshold)
-{
- const uint16_t compression = tif->tif_dir.td_compression;
- if (compression == COMPRESSION_NONE)
- {
- return strile_size > uncompressed_threshold;
- }
- else if (compression == COMPRESSION_JPEG ||
- compression == COMPRESSION_LZW ||
- compression == COMPRESSION_ADOBE_DEFLATE ||
- compression == COMPRESSION_DEFLATE ||
- compression == COMPRESSION_LZMA ||
- compression == COMPRESSION_LERC ||
- compression == COMPRESSION_ZSTD ||
- compression == COMPRESSION_WEBP || compression == COMPRESSION_JXL)
- {
- /* For a few select compression types, we assume that in the worst */
- /* case the compressed size will be 10 times the uncompressed size. */
- /* This is overly pessismistic ! */
- return strile_size >= uncompressed_threshold / 10;
- }
- return 1;
-}
-
-static int WriteAsLong8(TIFF *tif, uint64_t strile_size)
-{
- return _WriteAsType(tif, strile_size, 0xFFFFFFFFU);
-}
-
-static int WriteAsLong4(TIFF *tif, uint64_t strile_size)
-{
- return _WriteAsType(tif, strile_size, 0xFFFFU);
-}
-
-/************************************************************************/
-/* TIFFWriteDirectoryTagLongLong8Array() */
-/* */
-/* Write out LONG8 array and write a SHORT/LONG/LONG8 depending */
-/* on strile size and Classic/BigTIFF mode. */
-/************************************************************************/
-
-static int TIFFWriteDirectoryTagLongLong8Array(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t count, uint64_t *value)
-{
- static const char module[] = "TIFFWriteDirectoryTagLongLong8Array";
- int o;
- int write_aslong4;
-
- if (tif->tif_dir.td_deferstrilearraywriting)
- {
- if (dir == NULL)
- {
- /* This is just a counting pass to count IFD entries.
- * For deferstrilearraywriting no extra bytes will be written
- * into IFD space. */
- (*ndir)++;
- return 1;
- }
- return TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_NOTYPE, 0, 0,
- NULL);
- }
-
- if (tif->tif_flags & TIFF_BIGTIFF)
- {
- int write_aslong8 = 1;
- /* In the case of ByteCounts array, we may be able to write them on LONG
- * if the strip/tilesize is not too big. Also do that for count > 1 in
- * the case someone would want to create a single-strip file with a
- * growing height, in which case using LONG8 will be safer. */
- if (count > 1 && tag == TIFFTAG_STRIPBYTECOUNTS)
- {
- write_aslong8 = WriteAsLong8(tif, TIFFStripSize64(tif));
- }
- else if (count > 1 && tag == TIFFTAG_TILEBYTECOUNTS)
- {
- write_aslong8 = WriteAsLong8(tif, TIFFTileSize64(tif));
- }
- if (write_aslong8)
- {
- return TIFFWriteDirectoryTagCheckedLong8Array(tif, ndir, dir, tag,
- count, value);
- }
- }
-
- write_aslong4 = 1;
- if (count > 1 && tag == TIFFTAG_STRIPBYTECOUNTS)
- {
- write_aslong4 = WriteAsLong4(tif, TIFFStripSize64(tif));
- }
- else if (count > 1 && tag == TIFFTAG_TILEBYTECOUNTS)
- {
- write_aslong4 = WriteAsLong4(tif, TIFFTileSize64(tif));
- }
- if (write_aslong4)
- {
- /*
- ** For classic tiff we want to verify everything is in range for LONG
- ** and convert to long format.
- */
-
- uint32_t *p = _TIFFmallocExt(tif, count * sizeof(uint32_t));
- uint32_t *q;
- uint64_t *ma;
- uint32_t mb;
-
- if (p == NULL)
- {
- TIFFErrorExtR(tif, module, "Out of memory");
- return (0);
- }
-
- for (q = p, ma = value, mb = 0; mb < count; ma++, mb++, q++)
- {
- if (*ma > 0xFFFFFFFF)
- {
- TIFFErrorExtR(tif, module,
- "Attempt to write value larger than 0xFFFFFFFF "
- "in LONG array.");
- _TIFFfreeExt(tif, p);
- return (0);
- }
- *q = (uint32_t)(*ma);
- }
-
- o = TIFFWriteDirectoryTagCheckedLongArray(tif, ndir, dir, tag, count,
- p);
- _TIFFfreeExt(tif, p);
- }
- else
- {
- uint16_t *p = _TIFFmallocExt(tif, count * sizeof(uint16_t));
- uint16_t *q;
- uint64_t *ma;
- uint32_t mb;
-
- if (p == NULL)
- {
- TIFFErrorExtR(tif, module, "Out of memory");
- return (0);
- }
-
- for (q = p, ma = value, mb = 0; mb < count; ma++, mb++, q++)
- {
- if (*ma > 0xFFFF)
- {
- /* Should not happen normally given the check we did before */
- TIFFErrorExtR(tif, module,
- "Attempt to write value larger than 0xFFFF in "
- "SHORT array.");
- _TIFFfreeExt(tif, p);
- return (0);
- }
- *q = (uint16_t)(*ma);
- }
-
- o = TIFFWriteDirectoryTagCheckedShortArray(tif, ndir, dir, tag, count,
- p);
- _TIFFfreeExt(tif, p);
- }
-
- return (o);
-}
-
-/************************************************************************/
-/* TIFFWriteDirectoryTagIfdIfd8Array() */
-/* */
-/* Write either IFD8 or IFD array depending on file type. */
-/************************************************************************/
-
-static int TIFFWriteDirectoryTagIfdIfd8Array(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t count, uint64_t *value)
-{
- static const char module[] = "TIFFWriteDirectoryTagIfdIfd8Array";
- uint64_t *ma;
- uint32_t mb;
- uint32_t *p;
- uint32_t *q;
- int o;
-
- /* We always write IFD8 for BigTIFF, no checking needed. */
- if (tif->tif_flags & TIFF_BIGTIFF)
- return TIFFWriteDirectoryTagCheckedIfd8Array(tif, ndir, dir, tag, count,
- value);
-
- /*
- ** For classic tiff we want to verify everything is in range for IFD
- ** and convert to long format.
- */
-
- p = _TIFFmallocExt(tif, count * sizeof(uint32_t));
- if (p == NULL)
- {
- TIFFErrorExtR(tif, module, "Out of memory");
- return (0);
- }
-
- for (q = p, ma = value, mb = 0; mb < count; ma++, mb++, q++)
- {
- if (*ma > 0xFFFFFFFF)
- {
- TIFFErrorExtR(tif, module,
- "Attempt to write value larger than 0xFFFFFFFF in "
- "Classic TIFF file.");
- _TIFFfreeExt(tif, p);
- return (0);
- }
- *q = (uint32_t)(*ma);
- }
-
- o = TIFFWriteDirectoryTagCheckedIfdArray(tif, ndir, dir, tag, count, p);
- _TIFFfreeExt(tif, p);
-
- return (o);
-}
-
-/*
- * Auxiliary function to determine the IFD data size to be written to the file.
- * The IFD data size is finally the size of the IFD tag entries plus the IFD
- * data that is written directly after the IFD tag entries.
- */
-static void EvaluateIFDdatasizeWrite(TIFF *tif, uint32_t count,
- uint32_t typesize, uint32_t *ndir)
-{
- uint64_t datalength = (uint64_t)count * typesize;
- if (datalength > ((tif->tif_flags & TIFF_BIGTIFF) ? 0x8U : 0x4U))
- {
- /* LibTIFF increments write address to an even offset, thus datalength
- * written is also incremented. */
- if (datalength & 1)
- datalength++;
- tif->tif_dir.td_dirdatasize_write += datalength;
- }
- (*ndir)++;
-}
-
-static int TIFFWriteDirectoryTagColormap(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir)
-{
- static const char module[] = "TIFFWriteDirectoryTagColormap";
- uint32_t m;
- uint16_t *n;
- int o;
- m = (1 << tif->tif_dir.td_bitspersample);
- if (dir == NULL) /* Just evaluate IFD data size and increment ndir. */
- {
- EvaluateIFDdatasizeWrite(tif, 3 * m, sizeof(uint16_t), ndir);
- return 1;
- }
-
- n = _TIFFmallocExt(tif, 3 * m * sizeof(uint16_t));
- if (n == NULL)
- {
- TIFFErrorExtR(tif, module, "Out of memory");
- return (0);
- }
- _TIFFmemcpy(&n[0], tif->tif_dir.td_colormap[0], m * sizeof(uint16_t));
- _TIFFmemcpy(&n[m], tif->tif_dir.td_colormap[1], m * sizeof(uint16_t));
- _TIFFmemcpy(&n[2 * m], tif->tif_dir.td_colormap[2], m * sizeof(uint16_t));
- o = TIFFWriteDirectoryTagCheckedShortArray(tif, ndir, dir, TIFFTAG_COLORMAP,
- 3 * m, n);
- _TIFFfreeExt(tif, n);
- return (o);
-}
-
-static int TIFFWriteDirectoryTagTransferfunction(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir)
-{
- static const char module[] = "TIFFWriteDirectoryTagTransferfunction";
- uint32_t m;
- uint16_t n;
- uint16_t *o;
- int p;
- /* TIFFTAG_TRANSFERFUNCTION expects (1 or 3) pointer to arrays with
- * (1 << BitsPerSample) * uint16_t values.
- */
- m = (1 << tif->tif_dir.td_bitspersample);
- /* clang-format off */
- n = (tif->tif_dir.td_samplesperpixel - tif->tif_dir.td_extrasamples) > 1 ? 3 : 1;
- /* clang-format on */
-
- /* Check for proper number of transferfunctions */
- for (int i = 0; i < n; i++)
- {
- if (tif->tif_dir.td_transferfunction[i] == NULL)
- {
- TIFFWarningExtR(tif, module,
- "Too few TransferFunctions provided. Tag "
- "not written to file");
- return (1); /* Not an error; only tag is not written. */
- }
- }
- /*
- * Check if the table can be written as a single column,
- * or if it must be written as 3 columns. Note that we
- * write a 3-column tag if there are 2 samples/pixel and
- * a single column of data won't suffice--hmm.
- */
- if (n == 3)
- {
- if (!_TIFFmemcmp(tif->tif_dir.td_transferfunction[0],
- tif->tif_dir.td_transferfunction[2],
- m * sizeof(uint16_t)) &&
- !_TIFFmemcmp(tif->tif_dir.td_transferfunction[0],
- tif->tif_dir.td_transferfunction[1],
- m * sizeof(uint16_t)))
- n = 1;
- }
- if (dir == NULL) /* Just evaluate IFD data size and increment ndir. */
- {
- EvaluateIFDdatasizeWrite(tif, n * m, 2, ndir);
- return 1;
- }
-
- o = _TIFFmallocExt(tif, n * m * sizeof(uint16_t));
- if (o == NULL)
- {
- TIFFErrorExtR(tif, module, "Out of memory");
- return (0);
- }
- _TIFFmemcpy(&o[0], tif->tif_dir.td_transferfunction[0],
- m * sizeof(uint16_t));
- if (n > 1)
- _TIFFmemcpy(&o[m], tif->tif_dir.td_transferfunction[1],
- m * sizeof(uint16_t));
- if (n > 2)
- _TIFFmemcpy(&o[2 * m], tif->tif_dir.td_transferfunction[2],
- m * sizeof(uint16_t));
- p = TIFFWriteDirectoryTagCheckedShortArray(
- tif, ndir, dir, TIFFTAG_TRANSFERFUNCTION, n * m, o);
- _TIFFfreeExt(tif, o);
- return (p);
-}
-
-static int TIFFWriteDirectoryTagSubifd(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir)
-{
- static const char module[] = "TIFFWriteDirectoryTagSubifd";
- uint64_t m;
- int n;
- if (tif->tif_dir.td_nsubifd == 0)
- return (1);
- m = tif->tif_dataoff;
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- {
- uint32_t *o;
- uint64_t *pa;
- uint32_t *pb;
- uint16_t p;
- o = _TIFFmallocExt(tif, tif->tif_dir.td_nsubifd * sizeof(uint32_t));
- if (o == NULL)
- {
- TIFFErrorExtR(tif, module, "Out of memory");
- return (0);
- }
- pa = tif->tif_dir.td_subifd;
- pb = o;
- for (p = 0; p < tif->tif_dir.td_nsubifd; p++)
- {
- assert(pa != 0);
-
- /* Could happen if an classicTIFF has a SubIFD of type LONG8 (which
- * is illegal) */
- if (*pa > 0xFFFFFFFFUL)
- {
- TIFFErrorExtR(tif, module, "Illegal value for SubIFD tag");
- _TIFFfreeExt(tif, o);
- return (0);
- }
- *pb++ = (uint32_t)(*pa++);
- }
- n = TIFFWriteDirectoryTagCheckedIfdArray(tif, ndir, dir, TIFFTAG_SUBIFD,
- tif->tif_dir.td_nsubifd, o);
- _TIFFfreeExt(tif, o);
- }
- else
- n = TIFFWriteDirectoryTagCheckedIfd8Array(
- tif, ndir, dir, TIFFTAG_SUBIFD, tif->tif_dir.td_nsubifd,
- tif->tif_dir.td_subifd);
-
- if (dir == NULL)
- /* Just have evaluated IFD data size and incremented ndir
- * above in sub-functions. */
- return (n);
-
- if (!n)
- return (0);
- /*
- * Total hack: if this directory includes a SubIFD
- * tag then force the next <n> directories to be
- * written as ``sub directories'' of this one. This
- * is used to write things like thumbnails and
- * image masks that one wants to keep out of the
- * normal directory linkage access mechanism.
- */
- tif->tif_flags |= TIFF_INSUBIFD;
- tif->tif_nsubifd = tif->tif_dir.td_nsubifd;
- if (tif->tif_dir.td_nsubifd == 1)
- tif->tif_subifdoff = 0;
- else
- tif->tif_subifdoff = m;
- return (1);
-}
-
-static int TIFFWriteDirectoryTagCheckedAscii(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t count, char *value)
-{
- assert(sizeof(char) == 1);
- if (dir == NULL) /* Just evaluate IFD data size and increment ndir. */
- {
- EvaluateIFDdatasizeWrite(tif, count, 1, ndir);
- return 1;
- }
- return (TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_ASCII, count,
- count, value));
-}
-
-static int TIFFWriteDirectoryTagCheckedUndefinedArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir,
- uint16_t tag,
- uint32_t count,
- uint8_t *value)
-{
- assert(sizeof(uint8_t) == 1);
- if (dir == NULL) /* Just evaluate IFD data size and increment ndir. */
- {
- EvaluateIFDdatasizeWrite(tif, count, 1, ndir);
- return 1;
- }
- return (TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_UNDEFINED,
- count, count, value));
-}
-
-static int TIFFWriteDirectoryTagCheckedByteArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir,
- uint16_t tag, uint32_t count,
- uint8_t *value)
-{
- assert(sizeof(uint8_t) == 1);
- if (dir == NULL) /* Just evaluate IFD data size and increment ndir. */
- {
- EvaluateIFDdatasizeWrite(tif, count, 1, ndir);
- return 1;
- }
- return (TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_BYTE, count,
- count, value));
-}
-
-static int TIFFWriteDirectoryTagCheckedSbyteArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir,
- uint16_t tag, uint32_t count,
- int8_t *value)
-{
- assert(sizeof(int8_t) == 1);
- if (dir == NULL) /* Just evaluate IFD data size and increment ndir. */
- {
- EvaluateIFDdatasizeWrite(tif, count, 1, ndir);
- return 1;
- }
- return (TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_SBYTE, count,
- count, value));
-}
-
-static int TIFFWriteDirectoryTagCheckedShort(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint16_t value)
-{
- uint16_t m;
- assert(sizeof(uint16_t) == 2);
- if (dir == NULL)
- {
- /* No additional data to IFD data size just increment ndir. */
- (*ndir)++;
- return 1;
- }
- m = value;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabShort(&m);
- return (
- TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_SHORT, 1, 2, &m));
-}
-
-static int TIFFWriteDirectoryTagCheckedShortArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir,
- uint16_t tag, uint32_t count,
- uint16_t *value)
-{
- assert(count < 0x80000000);
- assert(sizeof(uint16_t) == 2);
- if (dir == NULL) /* Just evaluate IFD data size and increment ndir. */
- {
- EvaluateIFDdatasizeWrite(tif, count, 2, ndir);
- return 1;
- }
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabArrayOfShort(value, count);
- return (TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_SHORT, count,
- count * 2, value));
-}
-
-static int TIFFWriteDirectoryTagCheckedSshortArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir,
- uint16_t tag, uint32_t count,
- int16_t *value)
-{
- assert(count < 0x80000000);
- assert(sizeof(int16_t) == 2);
- if (dir == NULL) /* Just evaluate IFD data size and increment ndir. */
- {
- EvaluateIFDdatasizeWrite(tif, count, 2, ndir);
- return 1;
- }
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabArrayOfShort((uint16_t *)value, count);
- return (TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_SSHORT, count,
- count * 2, value));
-}
-
-static int TIFFWriteDirectoryTagCheckedLong(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t value)
-{
- uint32_t m;
- assert(sizeof(uint32_t) == 4);
- if (dir == NULL)
- {
- /* No additional data to IFD data size just increment ndir. */
- (*ndir)++;
- return 1;
- }
- m = value;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong(&m);
- return (
- TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_LONG, 1, 4, &m));
-}
-
-static int TIFFWriteDirectoryTagCheckedLongArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir,
- uint16_t tag, uint32_t count,
- uint32_t *value)
-{
- assert(count < 0x40000000);
- assert(sizeof(uint32_t) == 4);
- if (dir == NULL) /* Just evaluate IFD data size and increment ndir. */
- {
- EvaluateIFDdatasizeWrite(tif, count, 4, ndir);
- return 1;
- }
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabArrayOfLong(value, count);
- return (TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_LONG, count,
- count * 4, value));
-}
-
-static int TIFFWriteDirectoryTagCheckedSlongArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir,
- uint16_t tag, uint32_t count,
- int32_t *value)
-{
- assert(count < 0x40000000);
- assert(sizeof(int32_t) == 4);
- if (dir == NULL) /* Just evaluate IFD data size and increment ndir. */
- {
- EvaluateIFDdatasizeWrite(tif, count, 4, ndir);
- return 1;
- }
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabArrayOfLong((uint32_t *)value, count);
- return (TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_SLONG, count,
- count * 4, value));
-}
-
-static int TIFFWriteDirectoryTagCheckedLong8Array(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir,
- uint16_t tag, uint32_t count,
- uint64_t *value)
-{
- assert(count < 0x20000000);
- assert(sizeof(uint64_t) == 8);
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- {
- TIFFErrorExtR(tif, "TIFFWriteDirectoryTagCheckedLong8Array",
- "LONG8 not allowed for ClassicTIFF");
- return (0);
- }
- if (dir == NULL) /* Just evaluate IFD data size and increment ndir. */
- {
- EvaluateIFDdatasizeWrite(tif, count, 8, ndir);
- return 1;
- }
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabArrayOfLong8(value, count);
- return (TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_LONG8, count,
- count * 8, value));
-}
-
-static int TIFFWriteDirectoryTagCheckedSlong8Array(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir,
- uint16_t tag, uint32_t count,
- int64_t *value)
-{
- assert(count < 0x20000000);
- assert(sizeof(int64_t) == 8);
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- {
- TIFFErrorExtR(tif, "TIFFWriteDirectoryTagCheckedSlong8Array",
- "SLONG8 not allowed for ClassicTIFF");
- return (0);
- }
- if (dir == NULL) /* Just evaluate IFD data size and increment ndir. */
- {
- EvaluateIFDdatasizeWrite(tif, count, 8, ndir);
- return 1;
- }
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabArrayOfLong8((uint64_t *)value, count);
- return (TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_SLONG8, count,
- count * 8, value));
-}
-
-static int TIFFWriteDirectoryTagCheckedRational(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- double value)
-{
- static const char module[] = "TIFFWriteDirectoryTagCheckedRational";
- uint32_t m[2];
- assert(sizeof(uint32_t) == 4);
- if (value < 0)
- {
- TIFFErrorExtR(tif, module, "Negative value is illegal");
- return 0;
- }
- else if (value != value)
- {
- TIFFErrorExtR(tif, module, "Not-a-number value is illegal");
- return 0;
- }
-
- if (dir == NULL) /* Just evaluate IFD data size and increment ndir. */
- {
- tif->tif_dir.td_dirdatasize_write +=
- (tif->tif_flags & TIFF_BIGTIFF) ? 0 : 0x8U;
- (*ndir)++;
- return 1;
- }
-
- DoubleToRational(value, &m[0], &m[1]);
-
- if (tif->tif_flags & TIFF_SWAB)
- {
- TIFFSwabLong(&m[0]);
- TIFFSwabLong(&m[1]);
- }
- return (TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_RATIONAL, 1, 8,
- &m[0]));
-}
-
-static int TIFFWriteDirectoryTagCheckedRationalArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir,
- uint16_t tag,
- uint32_t count,
- float *value)
-{
- static const char module[] = "TIFFWriteDirectoryTagCheckedRationalArray";
- uint32_t *m;
- float *na;
- uint32_t *nb;
- uint32_t nc;
- int o;
- assert(sizeof(uint32_t) == 4);
- if (dir == NULL) /* Just evaluate IFD data size and increment ndir. */
- {
- EvaluateIFDdatasizeWrite(tif, count * 2, sizeof(uint32_t), ndir);
- return 1;
- }
- m = _TIFFmallocExt(tif, count * 2 * sizeof(uint32_t));
- if (m == NULL)
- {
- TIFFErrorExtR(tif, module, "Out of memory");
- return (0);
- }
- for (na = value, nb = m, nc = 0; nc < count; na++, nb += 2, nc++)
- {
- DoubleToRational(*na, &nb[0], &nb[1]);
- }
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabArrayOfLong(m, count * 2);
- o = TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_RATIONAL, count,
- count * 8, &m[0]);
- _TIFFfreeExt(tif, m);
- return (o);
-}
-
-static int TIFFWriteDirectoryTagCheckedSrationalArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir,
- uint16_t tag,
- uint32_t count,
- float *value)
-{
- static const char module[] = "TIFFWriteDirectoryTagCheckedSrationalArray";
- int32_t *m;
- float *na;
- int32_t *nb;
- uint32_t nc;
- int o;
- assert(sizeof(int32_t) == 4);
- if (dir == NULL) /* Just evaluate IFD data size and increment ndir. */
- {
- EvaluateIFDdatasizeWrite(tif, count * 2, sizeof(int32_t), ndir);
- return 1;
- }
- m = _TIFFmallocExt(tif, count * 2 * sizeof(int32_t));
- if (m == NULL)
- {
- TIFFErrorExtR(tif, module, "Out of memory");
- return (0);
- }
- for (na = value, nb = m, nc = 0; nc < count; na++, nb += 2, nc++)
- {
- DoubleToSrational(*na, &nb[0], &nb[1]);
- }
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabArrayOfLong((uint32_t *)m, count * 2);
- o = TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_SRATIONAL, count,
- count * 8, &m[0]);
- _TIFFfreeExt(tif, m);
- return (o);
-}
-
-/*-- Rational2Double: additional write functions for double arrays */
-static int
-TIFFWriteDirectoryTagCheckedRationalDoubleArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t count, double *value)
-{
- static const char module[] =
- "TIFFWriteDirectoryTagCheckedRationalDoubleArray";
- uint32_t *m;
- double *na;
- uint32_t *nb;
- uint32_t nc;
- int o;
- assert(sizeof(uint32_t) == 4);
- if (dir == NULL) /* Just evaluate IFD data size and increment ndir. */
- {
- EvaluateIFDdatasizeWrite(tif, count * 2, sizeof(uint32_t), ndir);
- return 1;
- }
- m = _TIFFmallocExt(tif, count * 2 * sizeof(uint32_t));
- if (m == NULL)
- {
- TIFFErrorExtR(tif, module, "Out of memory");
- return (0);
- }
- for (na = value, nb = m, nc = 0; nc < count; na++, nb += 2, nc++)
- {
- DoubleToRational(*na, &nb[0], &nb[1]);
- }
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabArrayOfLong(m, count * 2);
- o = TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_RATIONAL, count,
- count * 8, &m[0]);
- _TIFFfreeExt(tif, m);
- return (o);
-} /*-- TIFFWriteDirectoryTagCheckedRationalDoubleArray() ------- */
-
-static int TIFFWriteDirectoryTagCheckedSrationalDoubleArray(
- TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count,
- double *value)
-{
- static const char module[] =
- "TIFFWriteDirectoryTagCheckedSrationalDoubleArray";
- int32_t *m;
- double *na;
- int32_t *nb;
- uint32_t nc;
- int o;
- assert(sizeof(int32_t) == 4);
- if (dir == NULL) /* Just evaluate IFD data size and increment ndir. */
- {
- EvaluateIFDdatasizeWrite(tif, count * 2, sizeof(int32_t), ndir);
- return 1;
- }
- m = _TIFFmallocExt(tif, count * 2 * sizeof(int32_t));
- if (m == NULL)
- {
- TIFFErrorExtR(tif, module, "Out of memory");
- return (0);
- }
- for (na = value, nb = m, nc = 0; nc < count; na++, nb += 2, nc++)
- {
- DoubleToSrational(*na, &nb[0], &nb[1]);
- }
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabArrayOfLong((uint32_t *)m, count * 2);
- o = TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_SRATIONAL, count,
- count * 8, &m[0]);
- _TIFFfreeExt(tif, m);
- return (o);
-} /*--- TIFFWriteDirectoryTagCheckedSrationalDoubleArray() -------- */
-
-/** ----- Rational2Double: Double To Rational Conversion
-----------------------------------------------------------
-* There is a mathematical theorem to convert real numbers into a rational
-(integer fraction) number.
-* This is called "continuous fraction" which uses the Euclidean algorithm to
-find the greatest common divisor (GCD).
-* (ref. e.g. https://de.wikipedia.org/wiki/Kettenbruch or
-https://en.wikipedia.org/wiki/Continued_fraction
-* https://en.wikipedia.org/wiki/Euclidean_algorithm)
-* The following functions implement the
-* - ToRationalEuclideanGCD() auxiliary function which mainly
-implements euclidean GCD
-* - DoubleToRational() conversion function for un-signed
-rationals
-* - DoubleToSrational() conversion function for signed rationals
-------------------------------------------------------------------------------------------------------------------*/
-
-/**---- ToRationalEuclideanGCD() -----------------------------------------
-* Calculates the rational fractional of a double input value
-* using the Euclidean algorithm to find the greatest common divisor (GCD)
-------------------------------------------------------------------------*/
-static void ToRationalEuclideanGCD(double value, int blnUseSignedRange,
- int blnUseSmallRange, uint64_t *ullNum,
- uint64_t *ullDenom)
-{
- /* Internally, the integer variables can be bigger than the external ones,
- * as long as the result will fit into the external variable size.
- */
- uint64_t numSum[3] = {0, 1, 0}, denomSum[3] = {1, 0, 0};
- uint64_t aux, bigNum, bigDenom;
- uint64_t returnLimit;
- int i;
- uint64_t nMax;
- double fMax;
- unsigned long maxDenom;
- /*-- nMax and fMax defines the initial accuracy of the starting fractional,
- * or better, the highest used integer numbers used within the starting
- * fractional (bigNum/bigDenom). There are two approaches, which can
- * accidentally lead to different accuracies just depending on the value.
- * Therefore, blnUseSmallRange steers this behavior.
- * For long long nMax = ((9223372036854775807-1)/2); for long nMax =
- * ((2147483647-1)/2);
- */
- if (blnUseSmallRange)
- {
- nMax = (uint64_t)((2147483647 - 1) / 2); /* for ULONG range */
- }
- else
- {
- nMax = ((9223372036854775807 - 1) / 2); /* for ULLONG range */
- }
- fMax = (double)nMax;
-
- /*-- For the Euclidean GCD define the denominator range, so that it stays
- * within size of unsigned long variables. maxDenom should be LONG_MAX for
- * negative values and ULONG_MAX for positive ones. Also the final returned
- * value of ullNum and ullDenom is limited according to signed- or
- * unsigned-range.
- */
- if (blnUseSignedRange)
- {
- maxDenom = 2147483647UL; /*LONG_MAX = 0x7FFFFFFFUL*/
- returnLimit = maxDenom;
- }
- else
- {
- maxDenom = 0xFFFFFFFFUL; /*ULONG_MAX = 0xFFFFFFFFUL*/
- returnLimit = maxDenom;
- }
-
- /*-- First generate a rational fraction (bigNum/bigDenom) which represents
- *the value as a rational number with the highest accuracy. Therefore,
- *uint64_t (uint64_t) is needed. This rational fraction is then reduced
- *using the Euclidean algorithm to find the greatest common divisor (GCD).
- * bigNum = big numinator of value without fraction (or cut residual
- *fraction) bigDenom = big denominator of value
- *-- Break-criteria so that uint64_t cast to "bigNum" introduces no error
- *and bigDenom has no overflow, and stop with enlargement of fraction when
- *the double-value of it reaches an integer number without fractional part.
- */
- bigDenom = 1;
- while ((value != floor(value)) && (value < fMax) && (bigDenom < nMax))
- {
- bigDenom <<= 1;
- value *= 2;
- }
- bigNum = (uint64_t)value;
-
- /*-- Start Euclidean algorithm to find the greatest common divisor (GCD) --
- */
-#define MAX_ITERATIONS 64
- for (i = 0; i < MAX_ITERATIONS; i++)
- {
- uint64_t val;
- /* if bigDenom is not zero, calculate integer part of fraction. */
- if (bigDenom == 0)
- {
- break;
- }
- val = bigNum / bigDenom;
-
- /* Set bigDenom to reminder of bigNum/bigDenom and bigNum to previous
- * denominator bigDenom. */
- aux = bigNum;
- bigNum = bigDenom;
- bigDenom = aux % bigDenom;
-
- /* calculate next denominator and check for its given maximum */
- aux = val;
- if (denomSum[1] * val + denomSum[0] >= maxDenom)
- {
- aux = (maxDenom - denomSum[0]) / denomSum[1];
- if (aux * 2 >= val || denomSum[1] >= maxDenom)
- i = (MAX_ITERATIONS +
- 1); /* exit but execute rest of for-loop */
- else
- break;
- }
- /* calculate next numerator to numSum2 and save previous one to numSum0;
- * numSum1 just copy of numSum2. */
- numSum[2] = aux * numSum[1] + numSum[0];
- numSum[0] = numSum[1];
- numSum[1] = numSum[2];
- /* calculate next denominator to denomSum2 and save previous one to
- * denomSum0; denomSum1 just copy of denomSum2. */
- denomSum[2] = aux * denomSum[1] + denomSum[0];
- denomSum[0] = denomSum[1];
- denomSum[1] = denomSum[2];
- }
-
- /*-- Check and adapt for final variable size and return values; reduces
- * internal accuracy; denominator is kept in ULONG-range with maxDenom -- */
- while (numSum[1] > returnLimit || denomSum[1] > returnLimit)
- {
- numSum[1] = numSum[1] / 2;
- denomSum[1] = denomSum[1] / 2;
- }
-
- /* return values */
- *ullNum = numSum[1];
- *ullDenom = denomSum[1];
-
-} /*-- ToRationalEuclideanGCD() -------------- */
-
-/**---- DoubleToRational() -----------------------------------------------
-* Calculates the rational fractional of a double input value
-* for UN-SIGNED rationals,
-* using the Euclidean algorithm to find the greatest common divisor (GCD)
-------------------------------------------------------------------------*/
-static void DoubleToRational(double value, uint32_t *num, uint32_t *denom)
-{
- /*---- UN-SIGNED RATIONAL ---- */
- double dblDiff, dblDiff2;
- uint64_t ullNum, ullDenom, ullNum2, ullDenom2;
-
- /*-- Check for negative values. If so it is an error. */
- /* Test written that way to catch NaN */
- if (!(value >= 0))
- {
- *num = *denom = 0;
- TIFFErrorExt(0, "TIFFLib: DoubleToRational()",
- " Negative Value for Unsigned Rational given.");
- return;
- }
-
- /*-- Check for too big numbers (> ULONG_MAX) -- */
- if (value > 0xFFFFFFFFUL)
- {
- *num = 0xFFFFFFFFU;
- *denom = 0;
- return;
- }
- /*-- Check for easy integer numbers -- */
- if (value == (uint32_t)(value))
- {
- *num = (uint32_t)value;
- *denom = 1;
- return;
- }
- /*-- Check for too small numbers for "unsigned long" type rationals -- */
- if (value < 1.0 / (double)0xFFFFFFFFUL)
- {
- *num = 0;
- *denom = 0xFFFFFFFFU;
- return;
- }
-
- /*-- There are two approaches using the Euclidean algorithm,
- * which can accidentally lead to different accuracies just depending on
- * the value. Try both and define which one was better.
- */
- ToRationalEuclideanGCD(value, FALSE, FALSE, &ullNum, &ullDenom);
- ToRationalEuclideanGCD(value, FALSE, TRUE, &ullNum2, &ullDenom2);
- /*-- Double-Check, that returned values fit into ULONG :*/
- if (ullNum > 0xFFFFFFFFUL || ullDenom > 0xFFFFFFFFUL ||
- ullNum2 > 0xFFFFFFFFUL || ullDenom2 > 0xFFFFFFFFUL)
- {
- TIFFErrorExt(0, "TIFFLib: DoubleToRational()",
- " Num or Denom exceeds ULONG: val=%14.6f, num=%12" PRIu64
- ", denom=%12" PRIu64 " | num2=%12" PRIu64
- ", denom2=%12" PRIu64 "",
- value, ullNum, ullDenom, ullNum2, ullDenom2);
- assert(0);
- }
-
- /* Check, which one has higher accuracy and take that. */
- dblDiff = fabs(value - ((double)ullNum / (double)ullDenom));
- dblDiff2 = fabs(value - ((double)ullNum2 / (double)ullDenom2));
- if (dblDiff < dblDiff2)
- {
- *num = (uint32_t)ullNum;
- *denom = (uint32_t)ullDenom;
- }
- else
- {
- *num = (uint32_t)ullNum2;
- *denom = (uint32_t)ullDenom2;
- }
-} /*-- DoubleToRational() -------------- */
-
-/**---- DoubleToSrational() -----------------------------------------------
-* Calculates the rational fractional of a double input value
-* for SIGNED rationals,
-* using the Euclidean algorithm to find the greatest common divisor (GCD)
-------------------------------------------------------------------------*/
-static void DoubleToSrational(double value, int32_t *num, int32_t *denom)
-{
- /*---- SIGNED RATIONAL ----*/
- int neg = 1;
- double dblDiff, dblDiff2;
- uint64_t ullNum, ullDenom, ullNum2, ullDenom2;
-
- /*-- Check for negative values and use then the positive one for internal
- * calculations, but take the sign into account before returning. */
- if (value < 0)
- {
- neg = -1;
- value = -value;
- }
-
- /*-- Check for too big numbers (> LONG_MAX) -- */
- if (value > 0x7FFFFFFFL)
- {
- *num = 0x7FFFFFFFL;
- *denom = 0;
- return;
- }
- /*-- Check for easy numbers -- */
- if (value == (int32_t)(value))
- {
- *num = (int32_t)(neg * value);
- *denom = 1;
- return;
- }
- /*-- Check for too small numbers for "long" type rationals -- */
- if (value < 1.0 / (double)0x7FFFFFFFL)
- {
- *num = 0;
- *denom = 0x7FFFFFFFL;
- return;
- }
-
- /*-- There are two approaches using the Euclidean algorithm,
- * which can accidentally lead to different accuracies just depending on
- * the value. Try both and define which one was better. Furthermore, set
- * behavior of ToRationalEuclideanGCD() to the range of signed-long.
- */
- ToRationalEuclideanGCD(value, TRUE, FALSE, &ullNum, &ullDenom);
- ToRationalEuclideanGCD(value, TRUE, TRUE, &ullNum2, &ullDenom2);
- /*-- Double-Check, that returned values fit into LONG :*/
- if (ullNum > 0x7FFFFFFFL || ullDenom > 0x7FFFFFFFL ||
- ullNum2 > 0x7FFFFFFFL || ullDenom2 > 0x7FFFFFFFL)
- {
- TIFFErrorExt(0, "TIFFLib: DoubleToSrational()",
- " Num or Denom exceeds LONG: val=%14.6f, num=%12" PRIu64
- ", denom=%12" PRIu64 " | num2=%12" PRIu64
- ", denom2=%12" PRIu64 "",
- neg * value, ullNum, ullDenom, ullNum2, ullDenom2);
- assert(0);
- }
-
- /* Check, which one has higher accuracy and take that. */
- dblDiff = fabs(value - ((double)ullNum / (double)ullDenom));
- dblDiff2 = fabs(value - ((double)ullNum2 / (double)ullDenom2));
- if (dblDiff < dblDiff2)
- {
- *num = (int32_t)(neg * (long)ullNum);
- *denom = (int32_t)ullDenom;
- }
- else
- {
- *num = (int32_t)(neg * (long)ullNum2);
- *denom = (int32_t)ullDenom2;
- }
-} /*-- DoubleToSrational() --------------*/
-
-static int TIFFWriteDirectoryTagCheckedFloatArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir,
- uint16_t tag, uint32_t count,
- float *value)
-{
- assert(count < 0x40000000);
- assert(sizeof(float) == 4);
- if (dir == NULL) /* Just evaluate IFD data size and increment ndir. */
- {
- EvaluateIFDdatasizeWrite(tif, count, 4, ndir);
- return 1;
- }
- TIFFCvtNativeToIEEEFloat(tif, count, &value);
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabArrayOfFloat(value, count);
- return (TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_FLOAT, count,
- count * 4, value));
-}
-
-static int TIFFWriteDirectoryTagCheckedDoubleArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir,
- uint16_t tag, uint32_t count,
- double *value)
-{
- assert(count < 0x20000000);
- assert(sizeof(double) == 8);
- if (dir == NULL) /* Just evaluate IFD data size and increment ndir. */
- {
- EvaluateIFDdatasizeWrite(tif, count, 8, ndir);
- return 1;
- }
- TIFFCvtNativeToIEEEDouble(tif, count, &value);
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabArrayOfDouble(value, count);
- return (TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_DOUBLE, count,
- count * 8, value));
-}
-
-static int TIFFWriteDirectoryTagCheckedIfdArray(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint32_t count, uint32_t *value)
-{
- assert(count < 0x40000000);
- assert(sizeof(uint32_t) == 4);
- if (dir == NULL) /* Just evaluate IFD data size and increment ndir. */
- {
- EvaluateIFDdatasizeWrite(tif, count, 4, ndir);
- return 1;
- }
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabArrayOfLong(value, count);
- return (TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_IFD, count,
- count * 4, value));
-}
-
-static int TIFFWriteDirectoryTagCheckedIfd8Array(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir,
- uint16_t tag, uint32_t count,
- uint64_t *value)
-{
- assert(count < 0x20000000);
- assert(sizeof(uint64_t) == 8);
- assert(tif->tif_flags & TIFF_BIGTIFF);
- if (dir == NULL) /* Just evaluate IFD data size and increment ndir. */
- {
- EvaluateIFDdatasizeWrite(tif, count, 8, ndir);
- return 1;
- }
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabArrayOfLong8(value, count);
- return (TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_IFD8, count,
- count * 8, value));
-}
-
-static int TIFFWriteDirectoryTagData(TIFF *tif, uint32_t *ndir,
- TIFFDirEntry *dir, uint16_t tag,
- uint16_t datatype, uint32_t count,
- uint32_t datalength, void *data)
-{
- static const char module[] = "TIFFWriteDirectoryTagData";
- uint32_t m;
- m = 0;
- while (m < (*ndir))
- {
- assert(dir[m].tdir_tag != tag);
- if (dir[m].tdir_tag > tag)
- break;
- m++;
- }
- if (m < (*ndir))
- {
- uint32_t n;
- for (n = *ndir; n > m; n--)
- dir[n] = dir[n - 1];
- }
- dir[m].tdir_tag = tag;
- dir[m].tdir_type = datatype;
- dir[m].tdir_count = count;
- dir[m].tdir_offset.toff_long8 = 0;
- if (datalength <= ((tif->tif_flags & TIFF_BIGTIFF) ? 0x8U : 0x4U))
- {
- if (data && datalength)
- {
- _TIFFmemcpy(&dir[m].tdir_offset, data, datalength);
- }
- }
- else
- {
- uint64_t na, nb;
- na = tif->tif_dataoff;
- nb = na + datalength;
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- nb = (uint32_t)nb;
- if ((nb < na) || (nb < datalength))
- {
- TIFFErrorExtR(tif, module, "Maximum TIFF file size exceeded");
- return (0);
- }
- if (!SeekOK(tif, na))
- {
- TIFFErrorExtR(tif, module, "IO error writing tag data");
- return (0);
- }
- if (datalength >= 0x80000000UL)
- {
- TIFFErrorExtR(tif, module,
- "libtiff does not allow writing more than 2147483647 "
- "bytes in a tag");
- return (0);
- }
- if (!WriteOK(tif, data, (tmsize_t)datalength))
- {
- TIFFErrorExtR(tif, module, "IO error writing tag data");
- return (0);
- }
- tif->tif_dataoff = nb;
- if (tif->tif_dataoff & 1)
- tif->tif_dataoff++;
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- {
- uint32_t o;
- o = (uint32_t)na;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong(&o);
- _TIFFmemcpy(&dir[m].tdir_offset, &o, 4);
- }
- else
- {
- dir[m].tdir_offset.toff_long8 = na;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8(&dir[m].tdir_offset.toff_long8);
- }
- }
- (*ndir)++;
- return (1);
-}
-
-/*
- * Link the current directory into the directory chain for the file.
- */
-static int TIFFLinkDirectory(TIFF *tif)
-{
- static const char module[] = "TIFFLinkDirectory";
-
- tif->tif_diroff = (TIFFSeekFile(tif, 0, SEEK_END) + 1) & (~((toff_t)1));
-
- /*
- * Handle SubIFDs
- */
- if (tif->tif_flags & TIFF_INSUBIFD)
- {
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- {
- uint32_t m;
- m = (uint32_t)tif->tif_diroff;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong(&m);
- (void)TIFFSeekFile(tif, tif->tif_subifdoff, SEEK_SET);
- if (!WriteOK(tif, &m, 4))
- {
- TIFFErrorExtR(tif, module,
- "Error writing SubIFD directory link");
- return (0);
- }
-
- /*
- * Advance to the next SubIFD or, if this is
- * the last one configured, reverting back to the
- * normal directory linkage is done in TIFFWriteDirectorySec()
- * by tif->tif_flags &= ~TIFF_INSUBIFD;.
- */
- if (--tif->tif_nsubifd)
- tif->tif_subifdoff += 4;
- return (1);
- }
- else
- {
- uint64_t m;
- m = tif->tif_diroff;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8(&m);
- (void)TIFFSeekFile(tif, tif->tif_subifdoff, SEEK_SET);
- if (!WriteOK(tif, &m, 8))
- {
- TIFFErrorExtR(tif, module,
- "Error writing SubIFD directory link");
- return (0);
- }
-
- /*
- * Advance to the next SubIFD or, if this is
- * the last one configured, reverting back to the
- * normal directory linkage is done in TIFFWriteDirectorySec()
- * by tif->tif_flags &= ~TIFF_INSUBIFD;.
- */
- if (--tif->tif_nsubifd)
- tif->tif_subifdoff += 8;
- return (1);
- }
- }
-
- /*
- * Handle main-IFDs
- */
- tdir_t ndir = 1; /* count current number of main-IFDs */
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- {
- uint32_t m;
- uint32_t nextdir;
- m = (uint32_t)(tif->tif_diroff);
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong(&m);
- if (tif->tif_header.classic.tiff_diroff == 0)
- {
- /*
- * First directory, overwrite offset in header.
- */
- tif->tif_header.classic.tiff_diroff = (uint32_t)tif->tif_diroff;
- tif->tif_lastdiroff = tif->tif_diroff;
- (void)TIFFSeekFile(tif, 4, SEEK_SET);
- if (!WriteOK(tif, &m, 4))
- {
- TIFFErrorExtR(tif, tif->tif_name, "Error writing TIFF header");
- return (0);
- }
- if (!tif->tif_dir.td_iswrittentofile)
- tif->tif_curdircount = 0;
- return (1);
- }
- /*
- * Not the first directory, search to the last and append.
- */
- tdir_t dirn = 0;
- if (tif->tif_lastdiroff != 0 &&
- _TIFFGetDirNumberFromOffset(tif, tif->tif_lastdiroff, &dirn))
- {
- /* Start searching from the lastely written IFD. Thus get its IFD
- * number. */
- nextdir = (uint32_t)tif->tif_lastdiroff;
- ndir = dirn + 1;
- }
- else
- {
- nextdir = tif->tif_header.classic.tiff_diroff;
- ndir = 1; /* start searching from the first IFD */
- }
-
- while (1)
- {
- uint16_t dircount;
- uint32_t nextnextdir;
-
- if (!SeekOK(tif, nextdir) || !ReadOK(tif, &dircount, 2))
- {
- TIFFErrorExtR(tif, module, "Error fetching directory count");
- return (0);
- }
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabShort(&dircount);
- (void)TIFFSeekFile(tif, nextdir + 2 + dircount * 12, SEEK_SET);
- if (!ReadOK(tif, &nextnextdir, 4))
- {
- TIFFErrorExtR(tif, module, "Error fetching directory link");
- return (0);
- }
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong(&nextnextdir);
- if (nextnextdir == 0)
- {
- (void)TIFFSeekFile(tif, nextdir + 2 + dircount * 12, SEEK_SET);
- if (!WriteOK(tif, &m, 4))
- {
- TIFFErrorExtR(tif, module, "Error writing directory link");
- return (0);
- }
- tif->tif_lastdiroff = tif->tif_diroff;
- break;
- }
- nextdir = nextnextdir;
- ndir++;
- }
- }
- else
- {
- /*- BigTIFF -*/
- uint64_t m;
- uint64_t nextdir;
- m = tif->tif_diroff;
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8(&m);
- if (tif->tif_header.big.tiff_diroff == 0)
- {
- /*
- * First directory, overwrite offset in header.
- */
- tif->tif_header.big.tiff_diroff = tif->tif_diroff;
- tif->tif_lastdiroff = tif->tif_diroff;
- (void)TIFFSeekFile(tif, 8, SEEK_SET);
- if (!WriteOK(tif, &m, 8))
- {
- TIFFErrorExtR(tif, tif->tif_name, "Error writing TIFF header");
- return (0);
- }
- if (!tif->tif_dir.td_iswrittentofile)
- tif->tif_curdircount = 0;
- return (1);
- }
- /*
- * Not the first directory, search to the last and append.
- */
- tdir_t dirn = 0;
- if (tif->tif_lastdiroff != 0 &&
- _TIFFGetDirNumberFromOffset(tif, tif->tif_lastdiroff, &dirn))
- {
- /* Start searching from the lastely written IFD. Thus get its IFD
- * number. */
- nextdir = tif->tif_lastdiroff;
- ndir = dirn + 1;
- }
- else
- {
- nextdir = tif->tif_header.big.tiff_diroff;
- ndir = 1; /* start searching from the first IFD */
- }
- while (1)
- {
- uint64_t dircount64;
- uint16_t dircount;
- uint64_t nextnextdir;
-
- if (!SeekOK(tif, nextdir) || !ReadOK(tif, &dircount64, 8))
- {
- TIFFErrorExtR(tif, module, "Error fetching directory count");
- return (0);
- }
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8(&dircount64);
- if (dircount64 > 0xFFFF)
- {
- TIFFErrorExtR(tif, module,
- "Sanity check on tag count failed, "
- "likely corrupt TIFF");
- return (0);
- }
- dircount = (uint16_t)dircount64;
- (void)TIFFSeekFile(tif, nextdir + 8 + dircount * 20, SEEK_SET);
- if (!ReadOK(tif, &nextnextdir, 8))
- {
- TIFFErrorExtR(tif, module, "Error fetching directory link");
- return (0);
- }
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8(&nextnextdir);
- if (nextnextdir == 0)
- {
- (void)TIFFSeekFile(tif, nextdir + 8 + dircount * 20, SEEK_SET);
- if (!WriteOK(tif, &m, 8))
- {
- TIFFErrorExtR(tif, module, "Error writing directory link");
- return (0);
- }
- tif->tif_lastdiroff = tif->tif_diroff;
- break;
- }
- nextdir = nextnextdir;
- ndir++;
- }
- }
- /* Offset of next IFD is written to file.
- * Update number of main-IFDs in file.
- * However, tif_curdircount shall count only newly written main-IFDs with
- * entries and not only number of linked offsets! Thus, tif_curdircount is
- * incremented at the end of TIFFWriteDirectorySec().
- * TIFF_NON_EXISTENT_DIR_NUMBER means 'dont know number of IFDs'
- * 0 means 'empty file opened for writing, but no IFD written yet' */
- if (!tif->tif_dir.td_iswrittentofile && !(tif->tif_flags & TIFF_INSUBIFD))
- {
- tif->tif_curdircount = ndir;
- }
- return (1);
-}
-
-/************************************************************************/
-/* TIFFRewriteField() */
-/* */
-/* Rewrite a field in the directory on disk without regard to */
-/* updating the TIFF directory structure in memory. Currently */
-/* only supported for field that already exist in the on-disk */
-/* directory. Mainly used for updating stripoffset / */
-/* stripbytecount values after the directory is already on */
-/* disk. */
-/* */
-/* Returns zero on failure, and one on success. */
-/************************************************************************/
-
-int _TIFFRewriteField(TIFF *tif, uint16_t tag, TIFFDataType in_datatype,
- tmsize_t count, void *data)
-{
- static const char module[] = "TIFFResetField";
- /* const TIFFField* fip = NULL; */
- uint16_t dircount;
- tmsize_t dirsize;
- uint8_t direntry_raw[20];
- uint16_t entry_tag = 0;
- uint16_t entry_type = 0;
- uint64_t entry_count = 0;
- uint64_t entry_offset = 0;
- int value_in_entry = 0;
- uint64_t read_offset;
- uint8_t *buf_to_write = NULL;
- TIFFDataType datatype;
-
- /* -------------------------------------------------------------------- */
- /* Find field definition. */
- /* -------------------------------------------------------------------- */
- /*fip =*/TIFFFindField(tif, tag, TIFF_ANY);
-
- /* -------------------------------------------------------------------- */
- /* Do some checking this is a straight forward case. */
- /* -------------------------------------------------------------------- */
- if (isMapped(tif))
- {
- TIFFErrorExtR(tif, module,
- "Memory mapped files not currently supported for "
- "this operation.");
- return 0;
- }
-
- if (tif->tif_diroff == 0)
- {
- TIFFErrorExtR(
- tif, module,
- "Attempt to reset field on directory not already on disk.");
- return 0;
- }
-
- /* -------------------------------------------------------------------- */
- /* Read the directory entry count. */
- /* -------------------------------------------------------------------- */
- if (!SeekOK(tif, tif->tif_diroff))
- {
- TIFFErrorExtR(tif, module, "%s: Seek error accessing TIFF directory",
- tif->tif_name);
- return 0;
- }
-
- read_offset = tif->tif_diroff;
-
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- {
- if (!ReadOK(tif, &dircount, sizeof(uint16_t)))
- {
- TIFFErrorExtR(tif, module, "%s: Can not read TIFF directory count",
- tif->tif_name);
- return 0;
- }
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabShort(&dircount);
- dirsize = 12;
- read_offset += 2;
- }
- else
- {
- uint64_t dircount64;
- if (!ReadOK(tif, &dircount64, sizeof(uint64_t)))
- {
- TIFFErrorExtR(tif, module, "%s: Can not read TIFF directory count",
- tif->tif_name);
- return 0;
- }
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8(&dircount64);
- dircount = (uint16_t)dircount64;
- dirsize = 20;
- read_offset += 8;
- }
-
- /* -------------------------------------------------------------------- */
- /* Read through directory to find target tag. */
- /* -------------------------------------------------------------------- */
- while (dircount > 0)
- {
- if (!ReadOK(tif, direntry_raw, dirsize))
- {
- TIFFErrorExtR(tif, module, "%s: Can not read TIFF directory entry.",
- tif->tif_name);
- return 0;
- }
-
- memcpy(&entry_tag, direntry_raw + 0, sizeof(uint16_t));
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabShort(&entry_tag);
-
- if (entry_tag == tag)
- break;
-
- read_offset += dirsize;
- }
-
- if (entry_tag != tag)
- {
- TIFFErrorExtR(tif, module, "%s: Could not find tag %" PRIu16 ".",
- tif->tif_name, tag);
- return 0;
- }
-
- /* -------------------------------------------------------------------- */
- /* Extract the type, count and offset for this entry. */
- /* -------------------------------------------------------------------- */
- memcpy(&entry_type, direntry_raw + 2, sizeof(uint16_t));
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabShort(&entry_type);
-
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- {
- uint32_t value;
-
- memcpy(&value, direntry_raw + 4, sizeof(uint32_t));
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong(&value);
- entry_count = value;
-
- memcpy(&value, direntry_raw + 8, sizeof(uint32_t));
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong(&value);
- entry_offset = value;
- }
- else
- {
- memcpy(&entry_count, direntry_raw + 4, sizeof(uint64_t));
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8(&entry_count);
-
- memcpy(&entry_offset, direntry_raw + 12, sizeof(uint64_t));
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8(&entry_offset);
- }
-
- /* -------------------------------------------------------------------- */
- /* When a dummy tag was written due to TIFFDeferStrileArrayWriting() */
- /* -------------------------------------------------------------------- */
- if (entry_offset == 0 && entry_count == 0 && entry_type == 0)
- {
- if (tag == TIFFTAG_TILEOFFSETS || tag == TIFFTAG_STRIPOFFSETS)
- {
- entry_type =
- (tif->tif_flags & TIFF_BIGTIFF) ? TIFF_LONG8 : TIFF_LONG;
- }
- else
- {
- int write_aslong8 = 1;
- if (count > 1 && tag == TIFFTAG_STRIPBYTECOUNTS)
- {
- write_aslong8 = WriteAsLong8(tif, TIFFStripSize64(tif));
- }
- else if (count > 1 && tag == TIFFTAG_TILEBYTECOUNTS)
- {
- write_aslong8 = WriteAsLong8(tif, TIFFTileSize64(tif));
- }
- if (write_aslong8)
- {
- entry_type = TIFF_LONG8;
- }
- else
- {
- int write_aslong4 = 1;
- if (count > 1 && tag == TIFFTAG_STRIPBYTECOUNTS)
- {
- write_aslong4 = WriteAsLong4(tif, TIFFStripSize64(tif));
- }
- else if (count > 1 && tag == TIFFTAG_TILEBYTECOUNTS)
- {
- write_aslong4 = WriteAsLong4(tif, TIFFTileSize64(tif));
- }
- if (write_aslong4)
- {
- entry_type = TIFF_LONG;
- }
- else
- {
- entry_type = TIFF_SHORT;
- }
- }
- }
- }
-
- /* -------------------------------------------------------------------- */
- /* What data type do we want to write this as? */
- /* -------------------------------------------------------------------- */
- if (TIFFDataWidth(in_datatype) == 8 && !(tif->tif_flags & TIFF_BIGTIFF))
- {
- if (in_datatype == TIFF_LONG8)
- datatype = entry_type == TIFF_SHORT ? TIFF_SHORT : TIFF_LONG;
- else if (in_datatype == TIFF_SLONG8)
- datatype = TIFF_SLONG;
- else if (in_datatype == TIFF_IFD8)
- datatype = TIFF_IFD;
- else
- datatype = in_datatype;
- }
- else
- {
- if (in_datatype == TIFF_LONG8 &&
- (entry_type == TIFF_SHORT || entry_type == TIFF_LONG ||
- entry_type == TIFF_LONG8))
- datatype = entry_type;
- else if (in_datatype == TIFF_SLONG8 &&
- (entry_type == TIFF_SLONG || entry_type == TIFF_SLONG8))
- datatype = entry_type;
- else if (in_datatype == TIFF_IFD8 &&
- (entry_type == TIFF_IFD || entry_type == TIFF_IFD8))
- datatype = entry_type;
- else
- datatype = in_datatype;
- }
-
- /* -------------------------------------------------------------------- */
- /* Prepare buffer of actual data to write. This includes */
- /* swabbing as needed. */
- /* -------------------------------------------------------------------- */
- buf_to_write = (uint8_t *)_TIFFCheckMalloc(
- tif, count, TIFFDataWidth(datatype), "for field buffer.");
- if (!buf_to_write)
- return 0;
-
- if (datatype == in_datatype)
- memcpy(buf_to_write, data, count * TIFFDataWidth(datatype));
- else if (datatype == TIFF_SLONG && in_datatype == TIFF_SLONG8)
- {
- tmsize_t i;
-
- for (i = 0; i < count; i++)
- {
- ((int32_t *)buf_to_write)[i] = (int32_t)((int64_t *)data)[i];
- if ((int64_t)((int32_t *)buf_to_write)[i] != ((int64_t *)data)[i])
- {
- _TIFFfreeExt(tif, buf_to_write);
- TIFFErrorExtR(tif, module,
- "Value exceeds 32bit range of output type.");
- return 0;
- }
- }
- }
- else if ((datatype == TIFF_LONG && in_datatype == TIFF_LONG8) ||
- (datatype == TIFF_IFD && in_datatype == TIFF_IFD8))
- {
- tmsize_t i;
-
- for (i = 0; i < count; i++)
- {
- ((uint32_t *)buf_to_write)[i] = (uint32_t)((uint64_t *)data)[i];
- if ((uint64_t)((uint32_t *)buf_to_write)[i] !=
- ((uint64_t *)data)[i])
- {
- _TIFFfreeExt(tif, buf_to_write);
- TIFFErrorExtR(tif, module,
- "Value exceeds 32bit range of output type.");
- return 0;
- }
- }
- }
- else if (datatype == TIFF_SHORT && in_datatype == TIFF_LONG8)
- {
- tmsize_t i;
-
- for (i = 0; i < count; i++)
- {
- ((uint16_t *)buf_to_write)[i] = (uint16_t)((uint64_t *)data)[i];
- if ((uint64_t)((uint16_t *)buf_to_write)[i] !=
- ((uint64_t *)data)[i])
- {
- _TIFFfreeExt(tif, buf_to_write);
- TIFFErrorExtR(tif, module,
- "Value exceeds 16bit range of output type.");
- return 0;
- }
- }
- }
- else
- {
- TIFFErrorExtR(tif, module, "Unhandled type conversion.");
- return 0;
- }
-
- if (TIFFDataWidth(datatype) > 1 && (tif->tif_flags & TIFF_SWAB))
- {
- if (TIFFDataWidth(datatype) == 2)
- TIFFSwabArrayOfShort((uint16_t *)buf_to_write, count);
- else if (TIFFDataWidth(datatype) == 4)
- TIFFSwabArrayOfLong((uint32_t *)buf_to_write, count);
- else if (TIFFDataWidth(datatype) == 8)
- TIFFSwabArrayOfLong8((uint64_t *)buf_to_write, count);
- }
-
- /* -------------------------------------------------------------------- */
- /* Is this a value that fits into the directory entry? */
- /* -------------------------------------------------------------------- */
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- {
- if (TIFFDataWidth(datatype) * count <= 4)
- {
- entry_offset = read_offset + 8;
- value_in_entry = 1;
- }
- }
- else
- {
- if (TIFFDataWidth(datatype) * count <= 8)
- {
- entry_offset = read_offset + 12;
- value_in_entry = 1;
- }
- }
-
- if ((tag == TIFFTAG_TILEOFFSETS || tag == TIFFTAG_STRIPOFFSETS) &&
- tif->tif_dir.td_stripoffset_entry.tdir_count == 0 &&
- tif->tif_dir.td_stripoffset_entry.tdir_type == 0 &&
- tif->tif_dir.td_stripoffset_entry.tdir_offset.toff_long8 == 0)
- {
- tif->tif_dir.td_stripoffset_entry.tdir_type = datatype;
- tif->tif_dir.td_stripoffset_entry.tdir_count = count;
- }
- else if ((tag == TIFFTAG_TILEBYTECOUNTS ||
- tag == TIFFTAG_STRIPBYTECOUNTS) &&
- tif->tif_dir.td_stripbytecount_entry.tdir_count == 0 &&
- tif->tif_dir.td_stripbytecount_entry.tdir_type == 0 &&
- tif->tif_dir.td_stripbytecount_entry.tdir_offset.toff_long8 == 0)
- {
- tif->tif_dir.td_stripbytecount_entry.tdir_type = datatype;
- tif->tif_dir.td_stripbytecount_entry.tdir_count = count;
- }
-
- /* -------------------------------------------------------------------- */
- /* If the tag type, and count match, then we just write it out */
- /* over the old values without altering the directory entry at */
- /* all. */
- /* -------------------------------------------------------------------- */
- if (entry_count == (uint64_t)count && entry_type == (uint16_t)datatype)
- {
- if (!SeekOK(tif, entry_offset))
- {
- _TIFFfreeExt(tif, buf_to_write);
- TIFFErrorExtR(tif, module,
- "%s: Seek error accessing TIFF directory",
- tif->tif_name);
- return 0;
- }
- if (!WriteOK(tif, buf_to_write, count * TIFFDataWidth(datatype)))
- {
- _TIFFfreeExt(tif, buf_to_write);
- TIFFErrorExtR(tif, module, "Error writing directory link");
- return (0);
- }
-
- _TIFFfreeExt(tif, buf_to_write);
- return 1;
- }
-
- /* -------------------------------------------------------------------- */
- /* Otherwise, we write the new tag data at the end of the file. */
- /* -------------------------------------------------------------------- */
- if (!value_in_entry)
- {
- entry_offset = TIFFSeekFile(tif, 0, SEEK_END);
-
- if (!WriteOK(tif, buf_to_write, count * TIFFDataWidth(datatype)))
- {
- _TIFFfreeExt(tif, buf_to_write);
- TIFFErrorExtR(tif, module, "Error writing directory link");
- return (0);
- }
- }
- else
- {
- if (count * TIFFDataWidth(datatype) == 4)
- {
- uint32_t value;
- memcpy(&value, buf_to_write, count * TIFFDataWidth(datatype));
- entry_offset = value;
- }
- else
- {
- memcpy(&entry_offset, buf_to_write,
- count * TIFFDataWidth(datatype));
- }
- }
-
- _TIFFfreeExt(tif, buf_to_write);
- buf_to_write = 0;
-
- /* -------------------------------------------------------------------- */
- /* Adjust the directory entry. */
- /* -------------------------------------------------------------------- */
- entry_type = datatype;
- entry_count = (uint64_t)count;
- memcpy(direntry_raw + 2, &entry_type, sizeof(uint16_t));
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabShort((uint16_t *)(direntry_raw + 2));
-
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- {
- uint32_t value;
-
- value = (uint32_t)entry_count;
- memcpy(direntry_raw + 4, &value, sizeof(uint32_t));
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong((uint32_t *)(direntry_raw + 4));
-
- value = (uint32_t)entry_offset;
- memcpy(direntry_raw + 8, &value, sizeof(uint32_t));
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong((uint32_t *)(direntry_raw + 8));
- }
- else
- {
- memcpy(direntry_raw + 4, &entry_count, sizeof(uint64_t));
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8((uint64_t *)(direntry_raw + 4));
-
- memcpy(direntry_raw + 12, &entry_offset, sizeof(uint64_t));
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong8((uint64_t *)(direntry_raw + 12));
- }
-
- /* -------------------------------------------------------------------- */
- /* Write the directory entry out to disk. */
- /* -------------------------------------------------------------------- */
- if (!SeekOK(tif, read_offset))
- {
- TIFFErrorExtR(tif, module, "%s: Seek error accessing TIFF directory",
- tif->tif_name);
- return 0;
- }
-
- if (!WriteOK(tif, direntry_raw, dirsize))
- {
- TIFFErrorExtR(tif, module, "%s: Can not write TIFF directory entry.",
- tif->tif_name);
- return 0;
- }
-
- return 1;
-}
diff --git a/contrib/libs/libtiff/tif_dumpmode.c b/contrib/libs/libtiff/tif_dumpmode.c
deleted file mode 100644
index 267d5d2d7a..0000000000
--- a/contrib/libs/libtiff/tif_dumpmode.c
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (c) 1988-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-/*
- * TIFF Library.
- *
- * "Null" Compression Algorithm Support.
- */
-#include "tiffiop.h"
-
-static int DumpFixupTags(TIFF *tif)
-{
- (void)tif;
- return (1);
-}
-
-/*
- * Encode a hunk of pixels.
- */
-static int DumpModeEncode(TIFF *tif, uint8_t *pp, tmsize_t cc, uint16_t s)
-{
- (void)s;
- while (cc > 0)
- {
- tmsize_t n;
-
- n = cc;
- if (tif->tif_rawcc + n > tif->tif_rawdatasize)
- n = tif->tif_rawdatasize - tif->tif_rawcc;
-
- assert(n > 0);
-
- /*
- * Avoid copy if client has setup raw
- * data buffer to avoid extra copy.
- */
- if (tif->tif_rawcp != pp)
- _TIFFmemcpy(tif->tif_rawcp, pp, n);
- tif->tif_rawcp += n;
- tif->tif_rawcc += n;
- pp += n;
- cc -= n;
- if (tif->tif_rawcc >= tif->tif_rawdatasize && !TIFFFlushData1(tif))
- return (0);
- }
- return (1);
-}
-
-/*
- * Decode a hunk of pixels.
- */
-static int DumpModeDecode(TIFF *tif, uint8_t *buf, tmsize_t cc, uint16_t s)
-{
- static const char module[] = "DumpModeDecode";
- (void)s;
- if (tif->tif_rawcc < cc)
- {
- TIFFErrorExtR(tif, module,
- "Not enough data for scanline %" PRIu32
- ", expected a request for at most %" TIFF_SSIZE_FORMAT
- " bytes, got a request for %" TIFF_SSIZE_FORMAT " bytes",
- tif->tif_row, tif->tif_rawcc, cc);
- return (0);
- }
- /*
- * Avoid copy if client has setup raw
- * data buffer to avoid extra copy.
- */
- if (tif->tif_rawcp != buf)
- _TIFFmemcpy(buf, tif->tif_rawcp, cc);
- tif->tif_rawcp += cc;
- tif->tif_rawcc -= cc;
- return (1);
-}
-
-/*
- * Seek forwards nrows in the current strip.
- */
-static int DumpModeSeek(TIFF *tif, uint32_t nrows)
-{
- tif->tif_rawcp += nrows * tif->tif_scanlinesize;
- tif->tif_rawcc -= nrows * tif->tif_scanlinesize;
- return (1);
-}
-
-/*
- * Initialize dump mode.
- */
-int TIFFInitDumpMode(TIFF *tif, int scheme)
-{
- (void)scheme;
- tif->tif_fixuptags = DumpFixupTags;
- tif->tif_decoderow = DumpModeDecode;
- tif->tif_decodestrip = DumpModeDecode;
- tif->tif_decodetile = DumpModeDecode;
- tif->tif_encoderow = DumpModeEncode;
- tif->tif_encodestrip = DumpModeEncode;
- tif->tif_encodetile = DumpModeEncode;
- tif->tif_seek = DumpModeSeek;
- return (1);
-}
diff --git a/contrib/libs/libtiff/tif_error.c b/contrib/libs/libtiff/tif_error.c
deleted file mode 100644
index ac0b9c373a..0000000000
--- a/contrib/libs/libtiff/tif_error.c
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (c) 1988-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-/*
- * TIFF Library.
- */
-#include "tiffiop.h"
-
-TIFFErrorHandlerExt _TIFFerrorHandlerExt = NULL;
-
-TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler handler)
-{
- TIFFErrorHandler prev = _TIFFerrorHandler;
- _TIFFerrorHandler = handler;
- return (prev);
-}
-
-TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt handler)
-{
- TIFFErrorHandlerExt prev = _TIFFerrorHandlerExt;
- _TIFFerrorHandlerExt = handler;
- return (prev);
-}
-
-void TIFFError(const char *module, const char *fmt, ...)
-{
- va_list ap;
- if (_TIFFerrorHandler)
- {
- va_start(ap, fmt);
- (*_TIFFerrorHandler)(module, fmt, ap);
- va_end(ap);
- }
- if (_TIFFerrorHandlerExt)
- {
- va_start(ap, fmt);
- (*_TIFFerrorHandlerExt)(0, module, fmt, ap);
- va_end(ap);
- }
-}
-
-void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt, ...)
-{
- va_list ap;
- if (_TIFFerrorHandler)
- {
- va_start(ap, fmt);
- (*_TIFFerrorHandler)(module, fmt, ap);
- va_end(ap);
- }
- if (_TIFFerrorHandlerExt)
- {
- va_start(ap, fmt);
- (*_TIFFerrorHandlerExt)(fd, module, fmt, ap);
- va_end(ap);
- }
-}
-
-void _TIFFErrorEarly(TIFFOpenOptions *opts, thandle_t clientdata,
- const char *module, const char *fmt, ...)
-{
- va_list ap;
- if (opts && opts->errorhandler)
- {
- va_start(ap, fmt);
- int stop = opts->errorhandler(NULL, opts->errorhandler_user_data,
- module, fmt, ap);
- va_end(ap);
- if (stop)
- return;
- }
- if (_TIFFerrorHandler)
- {
- va_start(ap, fmt);
- (*_TIFFerrorHandler)(module, fmt, ap);
- va_end(ap);
- }
- if (_TIFFerrorHandlerExt)
- {
- va_start(ap, fmt);
- (*_TIFFerrorHandlerExt)(clientdata, module, fmt, ap);
- va_end(ap);
- }
-}
-
-void TIFFErrorExtR(TIFF *tif, const char *module, const char *fmt, ...)
-{
- va_list ap;
- if (tif && tif->tif_errorhandler)
- {
- va_start(ap, fmt);
- int stop = (*tif->tif_errorhandler)(
- tif, tif->tif_errorhandler_user_data, module, fmt, ap);
- va_end(ap);
- if (stop)
- return;
- }
- if (_TIFFerrorHandler)
- {
- va_start(ap, fmt);
- (*_TIFFerrorHandler)(module, fmt, ap);
- va_end(ap);
- }
- if (_TIFFerrorHandlerExt)
- {
- va_start(ap, fmt);
- (*_TIFFerrorHandlerExt)(tif ? tif->tif_clientdata : NULL, module, fmt,
- ap);
- va_end(ap);
- }
-}
diff --git a/contrib/libs/libtiff/tif_extension.c b/contrib/libs/libtiff/tif_extension.c
deleted file mode 100644
index 1a09e987a5..0000000000
--- a/contrib/libs/libtiff/tif_extension.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (c) 1988-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-/*
- * TIFF Library.
- *
- * Various routines support external extension of the tag set, and other
- * application extension capabilities.
- */
-
-#include "tiffiop.h"
-
-int TIFFGetTagListCount(TIFF *tif)
-
-{
- TIFFDirectory *td = &tif->tif_dir;
-
- return td->td_customValueCount;
-}
-
-uint32_t TIFFGetTagListEntry(TIFF *tif, int tag_index)
-
-{
- TIFFDirectory *td = &tif->tif_dir;
-
- if (tag_index < 0 || tag_index >= td->td_customValueCount)
- return (uint32_t)(-1);
- else
- return td->td_customValues[tag_index].info->field_tag;
-}
-
-/*
-** This provides read/write access to the TIFFTagMethods within the TIFF
-** structure to application code without giving access to the private
-** TIFF structure.
-*/
-TIFFTagMethods *TIFFAccessTagMethods(TIFF *tif)
-
-{
- return &(tif->tif_tagmethods);
-}
-
-void *TIFFGetClientInfo(TIFF *tif, const char *name)
-
-{
- TIFFClientInfoLink *psLink = tif->tif_clientinfo;
-
- while (psLink != NULL && strcmp(psLink->name, name) != 0)
- psLink = psLink->next;
-
- if (psLink != NULL)
- return psLink->data;
- else
- return NULL;
-}
-
-void TIFFSetClientInfo(TIFF *tif, void *data, const char *name)
-
-{
- TIFFClientInfoLink *psLink = tif->tif_clientinfo;
-
- /*
- ** Do we have an existing link with this name? If so, just
- ** set it.
- */
- while (psLink != NULL && strcmp(psLink->name, name) != 0)
- psLink = psLink->next;
-
- if (psLink != NULL)
- {
- psLink->data = data;
- return;
- }
-
- /*
- ** Create a new link.
- */
-
- psLink =
- (TIFFClientInfoLink *)_TIFFmallocExt(tif, sizeof(TIFFClientInfoLink));
- assert(psLink != NULL);
- psLink->next = tif->tif_clientinfo;
- psLink->name = (char *)_TIFFmallocExt(tif, (tmsize_t)(strlen(name) + 1));
- assert(psLink->name != NULL);
- strcpy(psLink->name, name);
- psLink->data = data;
-
- tif->tif_clientinfo = psLink;
-}
diff --git a/contrib/libs/libtiff/tif_fax3.c b/contrib/libs/libtiff/tif_fax3.c
deleted file mode 100644
index 01a784730b..0000000000
--- a/contrib/libs/libtiff/tif_fax3.c
+++ /dev/null
@@ -1,1787 +0,0 @@
-/*
- * Copyright (c) 1990-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-#include "tiffiop.h"
-#ifdef CCITT_SUPPORT
-/*
- * TIFF Library.
- *
- * CCITT Group 3 (T.4) and Group 4 (T.6) Compression Support.
- *
- * This file contains support for decoding and encoding TIFF
- * compression algorithms 2, 3, 4, and 32771.
- *
- * Decoder support is derived, with permission, from the code
- * in Frank Cringle's viewfax program;
- * Copyright (C) 1990, 1995 Frank D. Cringle.
- */
-#include "tif_fax3.h"
-#define G3CODES
-#include "t4.h"
-#include <stdio.h>
-
-#ifndef EOF_REACHED_COUNT_THRESHOLD
-/* Arbitrary threshold to avoid corrupted single-strip files with extremely
- * large imageheight to cause apparently endless looping, such as in
- * https://gitlab.com/libtiff/libtiff/-/issues/583
- */
-#define EOF_REACHED_COUNT_THRESHOLD 8192
-#endif
-
-/*
- * Compression+decompression state blocks are
- * derived from this ``base state'' block.
- */
-typedef struct
-{
- int rw_mode; /* O_RDONLY for decode, else encode */
- int mode; /* operating mode */
- tmsize_t rowbytes; /* bytes in a decoded scanline */
- uint32_t rowpixels; /* pixels in a scanline */
-
- uint16_t cleanfaxdata; /* CleanFaxData tag */
- uint32_t badfaxrun; /* BadFaxRun tag */
- uint32_t badfaxlines; /* BadFaxLines tag */
- uint32_t groupoptions; /* Group 3/4 options tag */
-
- TIFFVGetMethod vgetparent; /* super-class method */
- TIFFVSetMethod vsetparent; /* super-class method */
- TIFFPrintMethod printdir; /* super-class method */
-} Fax3BaseState;
-#define Fax3State(tif) ((Fax3BaseState *)(tif)->tif_data)
-
-typedef enum
-{
- G3_1D,
- G3_2D
-} Ttag;
-typedef struct
-{
- Fax3BaseState b;
-
- /* Decoder state info */
- const unsigned char *bitmap; /* bit reversal table */
- uint32_t data; /* current i/o byte/word */
- int bit; /* current i/o bit in byte */
- int EOLcnt; /* count of EOL codes recognized */
- int eofReachedCount; /* number of times decode has been called with
- EOF already reached */
- TIFFFaxFillFunc fill; /* fill routine */
- uint32_t *runs; /* b&w runs for current/previous row */
- uint32_t nruns; /* size of the refruns / curruns arrays */
- uint32_t *refruns; /* runs for reference line */
- uint32_t *curruns; /* runs for current line */
-
- /* Encoder state info */
- Ttag tag; /* encoding state */
- unsigned char *refline; /* reference line for 2d decoding */
- int k; /* #rows left that can be 2d encoded */
- int maxk; /* max #rows that can be 2d encoded */
-
- int line;
-} Fax3CodecState;
-#define DecoderState(tif) ((Fax3CodecState *)Fax3State(tif))
-#define EncoderState(tif) ((Fax3CodecState *)Fax3State(tif))
-
-#define is2DEncoding(sp) (sp->b.groupoptions & GROUP3OPT_2DENCODING)
-#define isAligned(p, t) ((((size_t)(p)) & (sizeof(t) - 1)) == 0)
-
-/*
- * Group 3 and Group 4 Decoding.
- */
-
-/*
- * These macros glue the TIFF library state to
- * the state expected by Frank's decoder.
- */
-#define DECLARE_STATE(tif, sp, mod) \
- static const char module[] = mod; \
- Fax3CodecState *sp = DecoderState(tif); \
- int a0; /* reference element */ \
- int lastx = sp->b.rowpixels; /* last element in row */ \
- uint32_t BitAcc; /* bit accumulator */ \
- int BitsAvail; /* # valid bits in BitAcc */ \
- int RunLength; /* length of current run */ \
- unsigned char *cp; /* next byte of input data */ \
- unsigned char *ep; /* end of input data */ \
- uint32_t *pa; /* place to stuff next run */ \
- uint32_t *thisrun; /* current row's run array */ \
- int EOLcnt; /* # EOL codes recognized */ \
- const unsigned char *bitmap = sp->bitmap; /* input data bit reverser */ \
- const TIFFFaxTabEnt *TabEnt
-
-#define DECLARE_STATE_2D(tif, sp, mod) \
- DECLARE_STATE(tif, sp, mod); \
- int b1; /* next change on prev line */ \
- uint32_t \
- *pb /* next run in reference line */ /* \
- * Load any state that may be \
- * changed during decoding. \
- */
-#define CACHE_STATE(tif, sp) \
- do \
- { \
- BitAcc = sp->data; \
- BitsAvail = sp->bit; \
- EOLcnt = sp->EOLcnt; \
- cp = (unsigned char *)tif->tif_rawcp; \
- ep = cp + tif->tif_rawcc; \
- } while (0)
-/*
- * Save state possibly changed during decoding.
- */
-#define UNCACHE_STATE(tif, sp) \
- do \
- { \
- sp->bit = BitsAvail; \
- sp->data = BitAcc; \
- sp->EOLcnt = EOLcnt; \
- tif->tif_rawcc -= (tmsize_t)((uint8_t *)cp - tif->tif_rawcp); \
- tif->tif_rawcp = (uint8_t *)cp; \
- } while (0)
-
-/*
- * Setup state for decoding a strip.
- */
-static int Fax3PreDecode(TIFF *tif, uint16_t s)
-{
- Fax3CodecState *sp = DecoderState(tif);
-
- (void)s;
- assert(sp != NULL);
- sp->bit = 0; /* force initial read */
- sp->data = 0;
- sp->EOLcnt = 0; /* force initial scan for EOL */
- sp->eofReachedCount = 0;
- /*
- * Decoder assumes lsb-to-msb bit order. Note that we select
- * this here rather than in Fax3SetupState so that viewers can
- * hold the image open, fiddle with the FillOrder tag value,
- * and then re-decode the image. Otherwise they'd need to close
- * and open the image to get the state reset.
- */
- sp->bitmap =
- TIFFGetBitRevTable(tif->tif_dir.td_fillorder != FILLORDER_LSB2MSB);
- sp->curruns = sp->runs;
- if (sp->refruns)
- { /* init reference line to white */
- sp->refruns = sp->runs + sp->nruns;
- sp->refruns[0] = (uint32_t)sp->b.rowpixels;
- sp->refruns[1] = 0;
- }
- sp->line = 0;
- return (1);
-}
-
-/*
- * Routine for handling various errors/conditions.
- * Note how they are "glued into the decoder" by
- * overriding the definitions used by the decoder.
- */
-
-static void Fax3Unexpected(const char *module, TIFF *tif, uint32_t line,
- uint32_t a0)
-{
- TIFFErrorExtR(tif, module,
- "Bad code word at line %" PRIu32 " of %s %" PRIu32
- " (x %" PRIu32 ")",
- line, isTiled(tif) ? "tile" : "strip",
- (isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip), a0);
-}
-#define unexpected(table, a0) Fax3Unexpected(module, tif, sp->line, a0)
-
-static void Fax3Extension(const char *module, TIFF *tif, uint32_t line,
- uint32_t a0)
-{
- TIFFErrorExtR(tif, module,
- "Uncompressed data (not supported) at line %" PRIu32
- " of %s %" PRIu32 " (x %" PRIu32 ")",
- line, isTiled(tif) ? "tile" : "strip",
- (isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip), a0);
-}
-#define extension(a0) Fax3Extension(module, tif, sp->line, a0)
-
-static void Fax3BadLength(const char *module, TIFF *tif, uint32_t line,
- uint32_t a0, uint32_t lastx)
-{
- TIFFWarningExtR(tif, module,
- "%s at line %" PRIu32 " of %s %" PRIu32 " (got %" PRIu32
- ", expected %" PRIu32 ")",
- a0 < lastx ? "Premature EOL" : "Line length mismatch", line,
- isTiled(tif) ? "tile" : "strip",
- (isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip), a0,
- lastx);
-}
-#define badlength(a0, lastx) Fax3BadLength(module, tif, sp->line, a0, lastx)
-
-static void Fax3PrematureEOF(const char *module, TIFF *tif, uint32_t line,
- uint32_t a0)
-{
- TIFFWarningExtR(tif, module,
- "Premature EOF at line %" PRIu32 " of %s %" PRIu32
- " (x %" PRIu32 ")",
- line, isTiled(tif) ? "tile" : "strip",
- (isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip), a0);
-}
-#define prematureEOF(a0) \
- do \
- { \
- Fax3PrematureEOF(module, tif, sp->line, a0); \
- ++sp->eofReachedCount; \
- } while (0)
-
-#define Nop
-
-/**
- * Decode the requested amount of G3 1D-encoded data.
- * @param buf destination buffer
- * @param occ available bytes in destination buffer
- * @param s number of planes (ignored)
- * @returns 1 for success, -1 in case of error
- */
-static int Fax3Decode1D(TIFF *tif, uint8_t *buf, tmsize_t occ, uint16_t s)
-{
- DECLARE_STATE(tif, sp, "Fax3Decode1D");
- (void)s;
- if (occ % sp->b.rowbytes)
- {
- TIFFErrorExtR(tif, module, "Fractional scanlines cannot be read");
- return (-1);
- }
- if (sp->eofReachedCount >= EOF_REACHED_COUNT_THRESHOLD)
- {
- TIFFErrorExtR(
- tif, module,
- "End of file has already been reached %d times within that strip",
- sp->eofReachedCount);
- return (-1);
- }
- CACHE_STATE(tif, sp);
- thisrun = sp->curruns;
- while (occ > 0)
- {
- a0 = 0;
- RunLength = 0;
- pa = thisrun;
-#ifdef FAX3_DEBUG
- printf("\nBitAcc=%08" PRIX32 ", BitsAvail = %d\n", BitAcc, BitsAvail);
- printf("-------------------- %" PRIu32 "\n", tif->tif_row);
- fflush(stdout);
-#endif
- SYNC_EOL(EOF1D);
- EXPAND1D(EOF1Da);
- (*sp->fill)(buf, thisrun, pa, lastx);
- buf += sp->b.rowbytes;
- occ -= sp->b.rowbytes;
- sp->line++;
- continue;
- EOF1D: /* premature EOF */
- CLEANUP_RUNS();
- EOF1Da: /* premature EOF */
- (*sp->fill)(buf, thisrun, pa, lastx);
- UNCACHE_STATE(tif, sp);
- return (-1);
- }
- UNCACHE_STATE(tif, sp);
- return (1);
-}
-
-#define SWAP(t, a, b) \
- { \
- t x; \
- x = (a); \
- (a) = (b); \
- (b) = x; \
- }
-/*
- * Decode the requested amount of G3 2D-encoded data.
- */
-static int Fax3Decode2D(TIFF *tif, uint8_t *buf, tmsize_t occ, uint16_t s)
-{
- DECLARE_STATE_2D(tif, sp, "Fax3Decode2D");
- int is1D; /* current line is 1d/2d-encoded */
- (void)s;
- if (occ % sp->b.rowbytes)
- {
- TIFFErrorExtR(tif, module, "Fractional scanlines cannot be read");
- return (-1);
- }
- if (sp->eofReachedCount >= EOF_REACHED_COUNT_THRESHOLD)
- {
- TIFFErrorExtR(
- tif, module,
- "End of file has already been reached %d times within that strip",
- sp->eofReachedCount);
- return (-1);
- }
- CACHE_STATE(tif, sp);
- while (occ > 0)
- {
- a0 = 0;
- RunLength = 0;
- pa = thisrun = sp->curruns;
-#ifdef FAX3_DEBUG
- printf("\nBitAcc=%08" PRIX32 ", BitsAvail = %d EOLcnt = %d", BitAcc,
- BitsAvail, EOLcnt);
-#endif
- SYNC_EOL(EOF2D);
- NeedBits8(1, EOF2D);
- is1D = GetBits(1); /* 1D/2D-encoding tag bit */
- ClrBits(1);
-#ifdef FAX3_DEBUG
- printf(" %s\n-------------------- %" PRIu32 "\n", is1D ? "1D" : "2D",
- tif->tif_row);
- fflush(stdout);
-#endif
- pb = sp->refruns;
- b1 = *pb++;
- if (is1D)
- EXPAND1D(EOF2Da);
- else
- EXPAND2D(EOF2Da);
- (*sp->fill)(buf, thisrun, pa, lastx);
- if (pa < thisrun + sp->nruns)
- {
- SETVALUE(0); /* imaginary change for reference */
- }
- SWAP(uint32_t *, sp->curruns, sp->refruns);
- buf += sp->b.rowbytes;
- occ -= sp->b.rowbytes;
- sp->line++;
- continue;
- EOF2D: /* premature EOF */
- CLEANUP_RUNS();
- EOF2Da: /* premature EOF */
- (*sp->fill)(buf, thisrun, pa, lastx);
- UNCACHE_STATE(tif, sp);
- return (-1);
- }
- UNCACHE_STATE(tif, sp);
- return (1);
-}
-#undef SWAP
-
-#define FILL(n, cp) \
- for (int32_t ifill = 0; ifill < (n); ++ifill) \
- { \
- (cp)[ifill] = 0xff; \
- } \
- (cp) += (n);
-
-#define ZERO(n, cp) \
- for (int32_t izero = 0; izero < (n); ++izero) \
- { \
- (cp)[izero] = 0; \
- } \
- (cp) += (n);
-
-/*
- * Bit-fill a row according to the white/black
- * runs generated during G3/G4 decoding.
- */
-void _TIFFFax3fillruns(unsigned char *buf, uint32_t *runs, uint32_t *erun,
- uint32_t lastx)
-{
- static const unsigned char _fillmasks[] = {0x00, 0x80, 0xc0, 0xe0, 0xf0,
- 0xf8, 0xfc, 0xfe, 0xff};
- unsigned char *cp;
- uint32_t x, bx, run;
- int32_t n, nw;
- int64_t *lp;
-
- if ((erun - runs) & 1)
- *erun++ = 0;
- x = 0;
- for (; runs < erun; runs += 2)
- {
- run = runs[0];
- if (x + run > lastx || run > lastx)
- run = runs[0] = (uint32_t)(lastx - x);
- if (run)
- {
- cp = buf + (x >> 3);
- bx = x & 7;
- if (run > 8 - bx)
- {
- if (bx)
- { /* align to byte boundary */
- *cp++ &= 0xff << (8 - bx);
- run -= 8 - bx;
- }
- if ((n = run >> 3) != 0)
- { /* multiple bytes to fill */
- if ((n / sizeof(int64_t)) > 1)
- {
- /*
- * Align to int64_tword boundary and fill.
- */
- for (; n && !isAligned(cp, int64_t); n--)
- *cp++ = 0x00;
- lp = (int64_t *)cp;
- nw = (int32_t)(n / sizeof(int64_t));
- n -= nw * sizeof(int64_t);
- do
- {
- *lp++ = 0L;
- } while (--nw);
- cp = (unsigned char *)lp;
- }
- ZERO(n, cp);
- run &= 7;
- }
- if (run)
- cp[0] &= 0xff >> run;
- }
- else
- cp[0] &= ~(_fillmasks[run] >> bx);
- x += runs[0];
- }
- run = runs[1];
- if (x + run > lastx || run > lastx)
- run = runs[1] = lastx - x;
- if (run)
- {
- cp = buf + (x >> 3);
- bx = x & 7;
- if (run > 8 - bx)
- {
- if (bx)
- { /* align to byte boundary */
- *cp++ |= 0xff >> bx;
- run -= 8 - bx;
- }
- if ((n = run >> 3) != 0)
- { /* multiple bytes to fill */
- if ((n / sizeof(int64_t)) > 1)
- {
- /*
- * Align to int64_t boundary and fill.
- */
- for (; n && !isAligned(cp, int64_t); n--)
- *cp++ = 0xff;
- lp = (int64_t *)cp;
- nw = (int32_t)(n / sizeof(int64_t));
- n -= nw * sizeof(int64_t);
- do
- {
- *lp++ = -1L;
- } while (--nw);
- cp = (unsigned char *)lp;
- }
- FILL(n, cp);
- run &= 7;
- }
- /* Explicit 0xff masking to make icc -check=conversions happy */
- if (run)
- cp[0] = (unsigned char)((cp[0] | (0xff00 >> run)) & 0xff);
- }
- else
- cp[0] |= _fillmasks[run] >> bx;
- x += runs[1];
- }
- }
- assert(x == lastx);
-}
-#undef ZERO
-#undef FILL
-
-static int Fax3FixupTags(TIFF *tif)
-{
- (void)tif;
- return (1);
-}
-
-/*
- * Setup G3/G4-related compression/decompression state
- * before data is processed. This routine is called once
- * per image -- it sets up different state based on whether
- * or not decoding or encoding is being done and whether
- * 1D- or 2D-encoded data is involved.
- */
-static int Fax3SetupState(TIFF *tif)
-{
- static const char module[] = "Fax3SetupState";
- TIFFDirectory *td = &tif->tif_dir;
- Fax3BaseState *sp = Fax3State(tif);
- int needsRefLine;
- Fax3CodecState *dsp = (Fax3CodecState *)Fax3State(tif);
- tmsize_t rowbytes;
- uint32_t rowpixels;
-
- if (td->td_bitspersample != 1)
- {
- TIFFErrorExtR(tif, module,
- "Bits/sample must be 1 for Group 3/4 encoding/decoding");
- return (0);
- }
- /*
- * Calculate the scanline/tile widths.
- */
- if (isTiled(tif))
- {
- rowbytes = TIFFTileRowSize(tif);
- rowpixels = td->td_tilewidth;
- }
- else
- {
- rowbytes = TIFFScanlineSize(tif);
- rowpixels = td->td_imagewidth;
- }
- if ((int64_t)rowbytes < ((int64_t)rowpixels + 7) / 8)
- {
- TIFFErrorExtR(tif, module,
- "Inconsistent number of bytes per row : rowbytes=%" PRId64
- " rowpixels=%" PRIu32,
- (int64_t)rowbytes, rowpixels);
- return (0);
- }
- sp->rowbytes = rowbytes;
- sp->rowpixels = rowpixels;
- /*
- * Allocate any additional space required for decoding/encoding.
- */
- needsRefLine = ((sp->groupoptions & GROUP3OPT_2DENCODING) ||
- td->td_compression == COMPRESSION_CCITTFAX4);
-
- /*
- Assure that allocation computations do not overflow.
-
- TIFFroundup and TIFFSafeMultiply return zero on integer overflow
- */
- if (dsp->runs != NULL)
- {
- _TIFFfreeExt(tif, dsp->runs);
- dsp->runs = (uint32_t *)NULL;
- }
- dsp->nruns = TIFFroundup_32(rowpixels + 1, 32);
- if (needsRefLine)
- {
- dsp->nruns = TIFFSafeMultiply(uint32_t, dsp->nruns, 2);
- }
- if ((dsp->nruns == 0) || (TIFFSafeMultiply(uint32_t, dsp->nruns, 2) == 0))
- {
- TIFFErrorExtR(tif, tif->tif_name,
- "Row pixels integer overflow (rowpixels %" PRIu32 ")",
- rowpixels);
- return (0);
- }
- dsp->runs = (uint32_t *)_TIFFCheckMalloc(
- tif, TIFFSafeMultiply(uint32_t, dsp->nruns, 2), sizeof(uint32_t),
- "for Group 3/4 run arrays");
- if (dsp->runs == NULL)
- return (0);
- memset(dsp->runs, 0,
- TIFFSafeMultiply(uint32_t, dsp->nruns, 2) * sizeof(uint32_t));
- dsp->curruns = dsp->runs;
- if (needsRefLine)
- dsp->refruns = dsp->runs + dsp->nruns;
- else
- dsp->refruns = NULL;
- if (td->td_compression == COMPRESSION_CCITTFAX3 && is2DEncoding(dsp))
- { /* NB: default is 1D routine */
- tif->tif_decoderow = Fax3Decode2D;
- tif->tif_decodestrip = Fax3Decode2D;
- tif->tif_decodetile = Fax3Decode2D;
- }
-
- if (needsRefLine)
- { /* 2d encoding */
- Fax3CodecState *esp = EncoderState(tif);
- /*
- * 2d encoding requires a scanline
- * buffer for the ``reference line''; the
- * scanline against which delta encoding
- * is referenced. The reference line must
- * be initialized to be ``white'' (done elsewhere).
- */
- if (esp->refline != NULL)
- {
- _TIFFfreeExt(tif, esp->refline);
- }
- esp->refline = (unsigned char *)_TIFFmallocExt(tif, rowbytes);
- if (esp->refline == NULL)
- {
- TIFFErrorExtR(tif, module, "No space for Group 3/4 reference line");
- return (0);
- }
- }
- else /* 1d encoding */
- EncoderState(tif)->refline = NULL;
-
- return (1);
-}
-
-/*
- * CCITT Group 3 FAX Encoding.
- */
-
-#define Fax3FlushBits(tif, sp) \
- { \
- if ((tif)->tif_rawcc >= (tif)->tif_rawdatasize) \
- { \
- if (!TIFFFlushData1(tif)) \
- return 0; \
- } \
- *(tif)->tif_rawcp++ = (uint8_t)(sp)->data; \
- (tif)->tif_rawcc++; \
- (sp)->data = 0, (sp)->bit = 8; \
- }
-#define _FlushBits(tif) \
- { \
- if ((tif)->tif_rawcc >= (tif)->tif_rawdatasize) \
- { \
- if (!TIFFFlushData1(tif)) \
- return 0; \
- } \
- *(tif)->tif_rawcp++ = (uint8_t)data; \
- (tif)->tif_rawcc++; \
- data = 0, bit = 8; \
- }
-static const int _msbmask[9] = {0x00, 0x01, 0x03, 0x07, 0x0f,
- 0x1f, 0x3f, 0x7f, 0xff};
-#define _PutBits(tif, bits, length) \
- { \
- while (length > bit) \
- { \
- data |= bits >> (length - bit); \
- length -= bit; \
- _FlushBits(tif); \
- } \
- assert(length < 9); \
- data |= (bits & _msbmask[length]) << (bit - length); \
- bit -= length; \
- if (bit == 0) \
- _FlushBits(tif); \
- }
-
-/*
- * Write a variable-length bit-value to
- * the output stream. Values are
- * assumed to be at most 16 bits.
- */
-static int Fax3PutBits(TIFF *tif, unsigned int bits, unsigned int length)
-{
- Fax3CodecState *sp = EncoderState(tif);
- unsigned int bit = sp->bit;
- int data = sp->data;
-
- _PutBits(tif, bits, length);
-
- sp->data = data;
- sp->bit = bit;
- return 1;
-}
-
-/*
- * Write a code to the output stream.
- */
-#define putcode(tif, te) Fax3PutBits(tif, (te)->code, (te)->length)
-
-#ifdef FAX3_DEBUG
-#define DEBUG_COLOR(w) (tab == TIFFFaxWhiteCodes ? w "W" : w "B")
-#define DEBUG_PRINT(what, len) \
- { \
- int t; \
- printf("%08" PRIX32 "/%-2d: %s%5d\t", data, bit, DEBUG_COLOR(what), \
- len); \
- for (t = length - 1; t >= 0; t--) \
- putchar(code & (1 << t) ? '1' : '0'); \
- putchar('\n'); \
- }
-#endif
-
-/*
- * Write the sequence of codes that describes
- * the specified span of zero's or one's. The
- * appropriate table that holds the make-up and
- * terminating codes is supplied.
- */
-static int putspan(TIFF *tif, int32_t span, const tableentry *tab)
-{
- Fax3CodecState *sp = EncoderState(tif);
- unsigned int bit = sp->bit;
- int data = sp->data;
- unsigned int code, length;
-
- while (span >= 2624)
- {
- const tableentry *te = &tab[63 + (2560 >> 6)];
- code = te->code;
- length = te->length;
-#ifdef FAX3_DEBUG
- DEBUG_PRINT("MakeUp", te->runlen);
-#endif
- _PutBits(tif, code, length);
- span -= te->runlen;
- }
- if (span >= 64)
- {
- const tableentry *te = &tab[63 + (span >> 6)];
- assert(te->runlen == 64 * (span >> 6));
- code = te->code;
- length = te->length;
-#ifdef FAX3_DEBUG
- DEBUG_PRINT("MakeUp", te->runlen);
-#endif
- _PutBits(tif, code, length);
- span -= te->runlen;
- }
- code = tab[span].code;
- length = tab[span].length;
-#ifdef FAX3_DEBUG
- DEBUG_PRINT(" Term", tab[span].runlen);
-#endif
- _PutBits(tif, code, length);
-
- sp->data = data;
- sp->bit = bit;
-
- return 1;
-}
-
-/*
- * Write an EOL code to the output stream. The zero-fill
- * logic for byte-aligning encoded scanlines is handled
- * here. We also handle writing the tag bit for the next
- * scanline when doing 2d encoding.
- */
-static int Fax3PutEOL(TIFF *tif)
-{
- Fax3CodecState *sp = EncoderState(tif);
- unsigned int bit = sp->bit;
- int data = sp->data;
- unsigned int code, length, tparm;
-
- if (sp->b.groupoptions & GROUP3OPT_FILLBITS)
- {
- /*
- * Force bit alignment so EOL will terminate on
- * a byte boundary. That is, force the bit alignment
- * to 16-12 = 4 before putting out the EOL code.
- */
- int align = 8 - 4;
- if (align != sp->bit)
- {
- if (align > sp->bit)
- align = sp->bit + (8 - align);
- else
- align = sp->bit - align;
- tparm = align;
- _PutBits(tif, 0, tparm);
- }
- }
- code = EOL;
- length = 12;
- if (is2DEncoding(sp))
- {
- code = (code << 1) | (sp->tag == G3_1D);
- length++;
- }
- _PutBits(tif, code, length);
-
- sp->data = data;
- sp->bit = bit;
-
- return 1;
-}
-
-/*
- * Reset encoding state at the start of a strip.
- */
-static int Fax3PreEncode(TIFF *tif, uint16_t s)
-{
- Fax3CodecState *sp = EncoderState(tif);
-
- (void)s;
- assert(sp != NULL);
- sp->bit = 8;
- sp->data = 0;
- sp->tag = G3_1D;
- /*
- * This is necessary for Group 4; otherwise it isn't
- * needed because the first scanline of each strip ends
- * up being copied into the refline.
- */
- if (sp->refline)
- _TIFFmemset(sp->refline, 0x00, sp->b.rowbytes);
- if (is2DEncoding(sp))
- {
- float res = tif->tif_dir.td_yresolution;
- /*
- * The CCITT spec says that when doing 2d encoding, you
- * should only do it on K consecutive scanlines, where K
- * depends on the resolution of the image being encoded
- * (2 for <= 200 lpi, 4 for > 200 lpi). Since the directory
- * code initializes td_yresolution to 0, this code will
- * select a K of 2 unless the YResolution tag is set
- * appropriately. (Note also that we fudge a little here
- * and use 150 lpi to avoid problems with units conversion.)
- */
- if (tif->tif_dir.td_resolutionunit == RESUNIT_CENTIMETER)
- res *= 2.54f; /* convert to inches */
- sp->maxk = (res > 150 ? 4 : 2);
- sp->k = sp->maxk - 1;
- }
- else
- sp->k = sp->maxk = 0;
- sp->line = 0;
- return (1);
-}
-
-static const unsigned char zeroruns[256] = {
- 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, /* 0x00 - 0x0f */
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 0x10 - 0x1f */
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 0x20 - 0x2f */
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 0x30 - 0x3f */
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x40 - 0x4f */
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x50 - 0x5f */
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x60 - 0x6f */
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x70 - 0x7f */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x80 - 0x8f */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x90 - 0x9f */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xa0 - 0xaf */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xb0 - 0xbf */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xc0 - 0xcf */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xd0 - 0xdf */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xe0 - 0xef */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xf0 - 0xff */
-};
-static const unsigned char oneruns[256] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00 - 0x0f */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x10 - 0x1f */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x20 - 0x2f */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x30 - 0x3f */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x40 - 0x4f */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x50 - 0x5f */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60 - 0x6f */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x70 - 0x7f */
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x80 - 0x8f */
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x90 - 0x9f */
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0xa0 - 0xaf */
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0xb0 - 0xbf */
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 0xc0 - 0xcf */
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 0xd0 - 0xdf */
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 0xe0 - 0xef */
- 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 7, 8, /* 0xf0 - 0xff */
-};
-
-/*
- * Find a span of ones or zeros using the supplied
- * table. The ``base'' of the bit string is supplied
- * along with the start+end bit indices.
- */
-static inline int32_t find0span(unsigned char *bp, int32_t bs, int32_t be)
-{
- int32_t bits = be - bs;
- int32_t n, span;
-
- bp += bs >> 3;
- /*
- * Check partial byte on lhs.
- */
- if (bits > 0 && (n = (bs & 7)) != 0)
- {
- span = zeroruns[(*bp << n) & 0xff];
- if (span > 8 - n) /* table value too generous */
- span = 8 - n;
- if (span > bits) /* constrain span to bit range */
- span = bits;
- if (n + span < 8) /* doesn't extend to edge of byte */
- return (span);
- bits -= span;
- bp++;
- }
- else
- span = 0;
- if (bits >= (int32_t)(2 * 8 * sizeof(int64_t)))
- {
- int64_t *lp;
- /*
- * Align to int64_t boundary and check int64_t words.
- */
- while (!isAligned(bp, int64_t))
- {
- if (*bp != 0x00)
- return (span + zeroruns[*bp]);
- span += 8;
- bits -= 8;
- bp++;
- }
- lp = (int64_t *)bp;
- while ((bits >= (int32_t)(8 * sizeof(int64_t))) && (0 == *lp))
- {
- span += 8 * sizeof(int64_t);
- bits -= 8 * sizeof(int64_t);
- lp++;
- }
- bp = (unsigned char *)lp;
- }
- /*
- * Scan full bytes for all 0's.
- */
- while (bits >= 8)
- {
- if (*bp != 0x00) /* end of run */
- return (span + zeroruns[*bp]);
- span += 8;
- bits -= 8;
- bp++;
- }
- /*
- * Check partial byte on rhs.
- */
- if (bits > 0)
- {
- n = zeroruns[*bp];
- span += (n > bits ? bits : n);
- }
- return (span);
-}
-
-static inline int32_t find1span(unsigned char *bp, int32_t bs, int32_t be)
-{
- int32_t bits = be - bs;
- int32_t n, span;
-
- bp += bs >> 3;
- /*
- * Check partial byte on lhs.
- */
- if (bits > 0 && (n = (bs & 7)) != 0)
- {
- span = oneruns[(*bp << n) & 0xff];
- if (span > 8 - n) /* table value too generous */
- span = 8 - n;
- if (span > bits) /* constrain span to bit range */
- span = bits;
- if (n + span < 8) /* doesn't extend to edge of byte */
- return (span);
- bits -= span;
- bp++;
- }
- else
- span = 0;
- if (bits >= (int32_t)(2 * 8 * sizeof(int64_t)))
- {
- int64_t *lp;
- /*
- * Align to int64_t boundary and check int64_t words.
- */
- while (!isAligned(bp, int64_t))
- {
- if (*bp != 0xff)
- return (span + oneruns[*bp]);
- span += 8;
- bits -= 8;
- bp++;
- }
- lp = (int64_t *)bp;
- while ((bits >= (int32_t)(8 * sizeof(int64_t))) &&
- (~((uint64_t)0) == (uint64_t)*lp))
- {
- span += 8 * sizeof(int64_t);
- bits -= 8 * sizeof(int64_t);
- lp++;
- }
- bp = (unsigned char *)lp;
- }
- /*
- * Scan full bytes for all 1's.
- */
- while (bits >= 8)
- {
- if (*bp != 0xff) /* end of run */
- return (span + oneruns[*bp]);
- span += 8;
- bits -= 8;
- bp++;
- }
- /*
- * Check partial byte on rhs.
- */
- if (bits > 0)
- {
- n = oneruns[*bp];
- span += (n > bits ? bits : n);
- }
- return (span);
-}
-
-/*
- * Return the offset of the next bit in the range
- * [bs..be] that is different from the specified
- * color. The end, be, is returned if no such bit
- * exists.
- */
-#define finddiff(_cp, _bs, _be, _color) \
- (_bs + (_color ? find1span(_cp, _bs, _be) : find0span(_cp, _bs, _be)))
-/*
- * Like finddiff, but also check the starting bit
- * against the end in case start > end.
- */
-#define finddiff2(_cp, _bs, _be, _color) \
- (_bs < _be ? finddiff(_cp, _bs, _be, _color) : _be)
-
-/*
- * 1d-encode a row of pixels. The encoding is
- * a sequence of all-white or all-black spans
- * of pixels encoded with Huffman codes.
- */
-static int Fax3Encode1DRow(TIFF *tif, unsigned char *bp, uint32_t bits)
-{
- Fax3CodecState *sp = EncoderState(tif);
- int32_t span;
- uint32_t bs = 0;
-
- for (;;)
- {
- span = find0span(bp, bs, bits); /* white span */
- if (!putspan(tif, span, TIFFFaxWhiteCodes))
- return 0;
- bs += span;
- if (bs >= bits)
- break;
- span = find1span(bp, bs, bits); /* black span */
- if (!putspan(tif, span, TIFFFaxBlackCodes))
- return 0;
- bs += span;
- if (bs >= bits)
- break;
- }
- if (sp->b.mode & (FAXMODE_BYTEALIGN | FAXMODE_WORDALIGN))
- {
- if (sp->bit != 8) /* byte-align */
- Fax3FlushBits(tif, sp);
- if ((sp->b.mode & FAXMODE_WORDALIGN) &&
- !isAligned(tif->tif_rawcp, uint16_t))
- Fax3FlushBits(tif, sp);
- }
- return (1);
-}
-
-static const tableentry horizcode = {3, 0x1, 0}; /* 001 */
-static const tableentry passcode = {4, 0x1, 0}; /* 0001 */
-static const tableentry vcodes[7] = {
- {7, 0x03, 0}, /* 0000 011 */
- {6, 0x03, 0}, /* 0000 11 */
- {3, 0x03, 0}, /* 011 */
- {1, 0x1, 0}, /* 1 */
- {3, 0x2, 0}, /* 010 */
- {6, 0x02, 0}, /* 0000 10 */
- {7, 0x02, 0} /* 0000 010 */
-};
-
-/*
- * 2d-encode a row of pixels. Consult the CCITT
- * documentation for the algorithm.
- */
-static int Fax3Encode2DRow(TIFF *tif, unsigned char *bp, unsigned char *rp,
- uint32_t bits)
-{
-#define PIXEL(buf, ix) ((((buf)[(ix) >> 3]) >> (7 - ((ix)&7))) & 1)
- uint32_t a0 = 0;
- uint32_t a1 = (PIXEL(bp, 0) != 0 ? 0 : finddiff(bp, 0, bits, 0));
- uint32_t b1 = (PIXEL(rp, 0) != 0 ? 0 : finddiff(rp, 0, bits, 0));
- uint32_t a2, b2;
-
- for (;;)
- {
- b2 = finddiff2(rp, b1, bits, PIXEL(rp, b1));
- if (b2 >= a1)
- {
- /* Naive computation triggers
- * -fsanitize=undefined,unsigned-integer-overflow */
- /* although it is correct unless the difference between both is < 31
- * bit */
- /* int32_t d = b1 - a1; */
- int32_t d = (b1 >= a1 && b1 - a1 <= 3U) ? (int32_t)(b1 - a1)
- : (b1 < a1 && a1 - b1 <= 3U) ? -(int32_t)(a1 - b1)
- : 0x7FFFFFFF;
- if (!(-3 <= d && d <= 3))
- { /* horizontal mode */
- a2 = finddiff2(bp, a1, bits, PIXEL(bp, a1));
- if (!putcode(tif, &horizcode))
- return 0;
- if (a0 + a1 == 0 || PIXEL(bp, a0) == 0)
- {
- if (!putspan(tif, a1 - a0, TIFFFaxWhiteCodes))
- return 0;
- if (!putspan(tif, a2 - a1, TIFFFaxBlackCodes))
- return 0;
- }
- else
- {
- if (!putspan(tif, a1 - a0, TIFFFaxBlackCodes))
- return 0;
- if (!putspan(tif, a2 - a1, TIFFFaxWhiteCodes))
- return 0;
- }
- a0 = a2;
- }
- else
- { /* vertical mode */
- if (!putcode(tif, &vcodes[d + 3]))
- return 0;
- a0 = a1;
- }
- }
- else
- { /* pass mode */
- if (!putcode(tif, &passcode))
- return 0;
- a0 = b2;
- }
- if (a0 >= bits)
- break;
- a1 = finddiff(bp, a0, bits, PIXEL(bp, a0));
- b1 = finddiff(rp, a0, bits, !PIXEL(bp, a0));
- b1 = finddiff(rp, b1, bits, PIXEL(bp, a0));
- }
- return (1);
-#undef PIXEL
-}
-
-/*
- * Encode a buffer of pixels.
- */
-static int Fax3Encode(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s)
-{
- static const char module[] = "Fax3Encode";
- Fax3CodecState *sp = EncoderState(tif);
- (void)s;
- if (cc % sp->b.rowbytes)
- {
- TIFFErrorExtR(tif, module, "Fractional scanlines cannot be written");
- return (0);
- }
- while (cc > 0)
- {
- if ((sp->b.mode & FAXMODE_NOEOL) == 0)
- {
- if (!Fax3PutEOL(tif))
- return 0;
- }
- if (is2DEncoding(sp))
- {
- if (sp->tag == G3_1D)
- {
- if (!Fax3Encode1DRow(tif, bp, sp->b.rowpixels))
- return (0);
- sp->tag = G3_2D;
- }
- else
- {
- if (!Fax3Encode2DRow(tif, bp, sp->refline, sp->b.rowpixels))
- return (0);
- sp->k--;
- }
- if (sp->k == 0)
- {
- sp->tag = G3_1D;
- sp->k = sp->maxk - 1;
- }
- else
- _TIFFmemcpy(sp->refline, bp, sp->b.rowbytes);
- }
- else
- {
- if (!Fax3Encode1DRow(tif, bp, sp->b.rowpixels))
- return (0);
- }
- bp += sp->b.rowbytes;
- cc -= sp->b.rowbytes;
- }
- return (1);
-}
-
-static int Fax3PostEncode(TIFF *tif)
-{
- Fax3CodecState *sp = EncoderState(tif);
-
- if (sp->bit != 8)
- Fax3FlushBits(tif, sp);
- return (1);
-}
-
-static int _Fax3Close(TIFF *tif)
-{
- if ((Fax3State(tif)->mode & FAXMODE_NORTC) == 0 && tif->tif_rawcp)
- {
- Fax3CodecState *sp = EncoderState(tif);
- unsigned int code = EOL;
- unsigned int length = 12;
- int i;
-
- if (is2DEncoding(sp))
- {
- code = (code << 1) | (sp->tag == G3_1D);
- length++;
- }
- for (i = 0; i < 6; i++)
- Fax3PutBits(tif, code, length);
- Fax3FlushBits(tif, sp);
- }
- return 1;
-}
-
-static void Fax3Close(TIFF *tif) { _Fax3Close(tif); }
-
-static void Fax3Cleanup(TIFF *tif)
-{
- Fax3CodecState *sp = DecoderState(tif);
-
- assert(sp != 0);
-
- tif->tif_tagmethods.vgetfield = sp->b.vgetparent;
- tif->tif_tagmethods.vsetfield = sp->b.vsetparent;
- tif->tif_tagmethods.printdir = sp->b.printdir;
-
- if (sp->runs)
- _TIFFfreeExt(tif, sp->runs);
- if (sp->refline)
- _TIFFfreeExt(tif, sp->refline);
-
- _TIFFfreeExt(tif, tif->tif_data);
- tif->tif_data = NULL;
-
- _TIFFSetDefaultCompressionState(tif);
-}
-
-#define FIELD_BADFAXLINES (FIELD_CODEC + 0)
-#define FIELD_CLEANFAXDATA (FIELD_CODEC + 1)
-#define FIELD_BADFAXRUN (FIELD_CODEC + 2)
-
-#define FIELD_OPTIONS (FIELD_CODEC + 7)
-
-static const TIFFField faxFields[] = {
- {TIFFTAG_FAXMODE, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT, TIFF_SETGET_UNDEFINED,
- FIELD_PSEUDO, FALSE, FALSE, "FaxMode", NULL},
- {TIFFTAG_FAXFILLFUNC, 0, 0, TIFF_ANY, 0, TIFF_SETGET_OTHER,
- TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, FALSE, FALSE, "FaxFillFunc", NULL},
- {TIFFTAG_BADFAXLINES, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32,
- TIFF_SETGET_UINT32, FIELD_BADFAXLINES, TRUE, FALSE, "BadFaxLines", NULL},
- {TIFFTAG_CLEANFAXDATA, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16,
- TIFF_SETGET_UINT16, FIELD_CLEANFAXDATA, TRUE, FALSE, "CleanFaxData", NULL},
- {TIFFTAG_CONSECUTIVEBADFAXLINES, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32,
- TIFF_SETGET_UINT32, FIELD_BADFAXRUN, TRUE, FALSE, "ConsecutiveBadFaxLines",
- NULL}};
-static const TIFFField fax3Fields[] = {
- {TIFFTAG_GROUP3OPTIONS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32,
- TIFF_SETGET_UINT32, FIELD_OPTIONS, FALSE, FALSE, "Group3Options", NULL},
-};
-static const TIFFField fax4Fields[] = {
- {TIFFTAG_GROUP4OPTIONS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32,
- TIFF_SETGET_UINT32, FIELD_OPTIONS, FALSE, FALSE, "Group4Options", NULL},
-};
-
-static int Fax3VSetField(TIFF *tif, uint32_t tag, va_list ap)
-{
- Fax3BaseState *sp = Fax3State(tif);
- const TIFFField *fip;
-
- assert(sp != 0);
- assert(sp->vsetparent != 0);
-
- switch (tag)
- {
- case TIFFTAG_FAXMODE:
- sp->mode = (int)va_arg(ap, int);
- return 1; /* NB: pseudo tag */
- case TIFFTAG_FAXFILLFUNC:
- DecoderState(tif)->fill = va_arg(ap, TIFFFaxFillFunc);
- return 1; /* NB: pseudo tag */
- case TIFFTAG_GROUP3OPTIONS:
- /* XXX: avoid reading options if compression mismatches. */
- if (tif->tif_dir.td_compression == COMPRESSION_CCITTFAX3)
- sp->groupoptions = (uint32_t)va_arg(ap, uint32_t);
- break;
- case TIFFTAG_GROUP4OPTIONS:
- /* XXX: avoid reading options if compression mismatches. */
- if (tif->tif_dir.td_compression == COMPRESSION_CCITTFAX4)
- sp->groupoptions = (uint32_t)va_arg(ap, uint32_t);
- break;
- case TIFFTAG_BADFAXLINES:
- sp->badfaxlines = (uint32_t)va_arg(ap, uint32_t);
- break;
- case TIFFTAG_CLEANFAXDATA:
- sp->cleanfaxdata = (uint16_t)va_arg(ap, uint16_vap);
- break;
- case TIFFTAG_CONSECUTIVEBADFAXLINES:
- sp->badfaxrun = (uint32_t)va_arg(ap, uint32_t);
- break;
- default:
- return (*sp->vsetparent)(tif, tag, ap);
- }
-
- if ((fip = TIFFFieldWithTag(tif, tag)) != NULL)
- TIFFSetFieldBit(tif, fip->field_bit);
- else
- return 0;
-
- tif->tif_flags |= TIFF_DIRTYDIRECT;
- return 1;
-}
-
-static int Fax3VGetField(TIFF *tif, uint32_t tag, va_list ap)
-{
- Fax3BaseState *sp = Fax3State(tif);
-
- assert(sp != 0);
-
- switch (tag)
- {
- case TIFFTAG_FAXMODE:
- *va_arg(ap, int *) = sp->mode;
- break;
- case TIFFTAG_FAXFILLFUNC:
- *va_arg(ap, TIFFFaxFillFunc *) = DecoderState(tif)->fill;
- break;
- case TIFFTAG_GROUP3OPTIONS:
- case TIFFTAG_GROUP4OPTIONS:
- *va_arg(ap, uint32_t *) = sp->groupoptions;
- break;
- case TIFFTAG_BADFAXLINES:
- *va_arg(ap, uint32_t *) = sp->badfaxlines;
- break;
- case TIFFTAG_CLEANFAXDATA:
- *va_arg(ap, uint16_t *) = sp->cleanfaxdata;
- break;
- case TIFFTAG_CONSECUTIVEBADFAXLINES:
- *va_arg(ap, uint32_t *) = sp->badfaxrun;
- break;
- default:
- return (*sp->vgetparent)(tif, tag, ap);
- }
- return (1);
-}
-
-static void Fax3PrintDir(TIFF *tif, FILE *fd, long flags)
-{
- Fax3BaseState *sp = Fax3State(tif);
-
- assert(sp != 0);
-
- (void)flags;
- if (TIFFFieldSet(tif, FIELD_OPTIONS))
- {
- const char *sep = " ";
- if (tif->tif_dir.td_compression == COMPRESSION_CCITTFAX4)
- {
- fprintf(fd, " Group 4 Options:");
- if (sp->groupoptions & GROUP4OPT_UNCOMPRESSED)
- fprintf(fd, "%suncompressed data", sep);
- }
- else
- {
-
- fprintf(fd, " Group 3 Options:");
- if (sp->groupoptions & GROUP3OPT_2DENCODING)
- {
- fprintf(fd, "%s2-d encoding", sep);
- sep = "+";
- }
- if (sp->groupoptions & GROUP3OPT_FILLBITS)
- {
- fprintf(fd, "%sEOL padding", sep);
- sep = "+";
- }
- if (sp->groupoptions & GROUP3OPT_UNCOMPRESSED)
- fprintf(fd, "%suncompressed data", sep);
- }
- fprintf(fd, " (%" PRIu32 " = 0x%" PRIx32 ")\n", sp->groupoptions,
- sp->groupoptions);
- }
- if (TIFFFieldSet(tif, FIELD_CLEANFAXDATA))
- {
- fprintf(fd, " Fax Data:");
- switch (sp->cleanfaxdata)
- {
- case CLEANFAXDATA_CLEAN:
- fprintf(fd, " clean");
- break;
- case CLEANFAXDATA_REGENERATED:
- fprintf(fd, " receiver regenerated");
- break;
- case CLEANFAXDATA_UNCLEAN:
- fprintf(fd, " uncorrected errors");
- break;
- }
- fprintf(fd, " (%" PRIu16 " = 0x%" PRIx16 ")\n", sp->cleanfaxdata,
- sp->cleanfaxdata);
- }
- if (TIFFFieldSet(tif, FIELD_BADFAXLINES))
- fprintf(fd, " Bad Fax Lines: %" PRIu32 "\n", sp->badfaxlines);
- if (TIFFFieldSet(tif, FIELD_BADFAXRUN))
- fprintf(fd, " Consecutive Bad Fax Lines: %" PRIu32 "\n",
- sp->badfaxrun);
- if (sp->printdir)
- (*sp->printdir)(tif, fd, flags);
-}
-
-static int InitCCITTFax3(TIFF *tif)
-{
- static const char module[] = "InitCCITTFax3";
- Fax3BaseState *sp;
-
- /*
- * Merge codec-specific tag information.
- */
- if (!_TIFFMergeFields(tif, faxFields, TIFFArrayCount(faxFields)))
- {
- TIFFErrorExtR(tif, "InitCCITTFax3",
- "Merging common CCITT Fax codec-specific tags failed");
- return 0;
- }
-
- /*
- * Allocate state block so tag methods have storage to record values.
- */
- tif->tif_data = (uint8_t *)_TIFFmallocExt(tif, sizeof(Fax3CodecState));
-
- if (tif->tif_data == NULL)
- {
- TIFFErrorExtR(tif, module, "No space for state block");
- return (0);
- }
- _TIFFmemset(tif->tif_data, 0, sizeof(Fax3CodecState));
-
- sp = Fax3State(tif);
- sp->rw_mode = tif->tif_mode;
-
- /*
- * Override parent get/set field methods.
- */
- sp->vgetparent = tif->tif_tagmethods.vgetfield;
- tif->tif_tagmethods.vgetfield = Fax3VGetField; /* hook for codec tags */
- sp->vsetparent = tif->tif_tagmethods.vsetfield;
- tif->tif_tagmethods.vsetfield = Fax3VSetField; /* hook for codec tags */
- sp->printdir = tif->tif_tagmethods.printdir;
- tif->tif_tagmethods.printdir = Fax3PrintDir; /* hook for codec tags */
- sp->groupoptions = 0;
-
- if (sp->rw_mode == O_RDONLY) /* FIXME: improve for in place update */
- tif->tif_flags |= TIFF_NOBITREV; /* decoder does bit reversal */
- DecoderState(tif)->runs = NULL;
- TIFFSetField(tif, TIFFTAG_FAXFILLFUNC, _TIFFFax3fillruns);
- EncoderState(tif)->refline = NULL;
-
- /*
- * Install codec methods.
- */
- tif->tif_fixuptags = Fax3FixupTags;
- tif->tif_setupdecode = Fax3SetupState;
- tif->tif_predecode = Fax3PreDecode;
- tif->tif_decoderow = Fax3Decode1D;
- tif->tif_decodestrip = Fax3Decode1D;
- tif->tif_decodetile = Fax3Decode1D;
- tif->tif_setupencode = Fax3SetupState;
- tif->tif_preencode = Fax3PreEncode;
- tif->tif_postencode = Fax3PostEncode;
- tif->tif_encoderow = Fax3Encode;
- tif->tif_encodestrip = Fax3Encode;
- tif->tif_encodetile = Fax3Encode;
- tif->tif_close = Fax3Close;
- tif->tif_cleanup = Fax3Cleanup;
-
- return (1);
-}
-
-int TIFFInitCCITTFax3(TIFF *tif, int scheme)
-{
- (void)scheme;
- if (InitCCITTFax3(tif))
- {
- /*
- * Merge codec-specific tag information.
- */
- if (!_TIFFMergeFields(tif, fax3Fields, TIFFArrayCount(fax3Fields)))
- {
- TIFFErrorExtR(tif, "TIFFInitCCITTFax3",
- "Merging CCITT Fax 3 codec-specific tags failed");
- return 0;
- }
-
- /*
- * The default format is Class/F-style w/o RTC.
- */
- return TIFFSetField(tif, TIFFTAG_FAXMODE, FAXMODE_CLASSF);
- }
- else
- return 01;
-}
-
-/*
- * CCITT Group 4 (T.6) Facsimile-compatible
- * Compression Scheme Support.
- */
-
-#define SWAP(t, a, b) \
- { \
- t x; \
- x = (a); \
- (a) = (b); \
- (b) = x; \
- }
-/*
- * Decode the requested amount of G4-encoded data.
- */
-static int Fax4Decode(TIFF *tif, uint8_t *buf, tmsize_t occ, uint16_t s)
-{
- DECLARE_STATE_2D(tif, sp, "Fax4Decode");
- (void)s;
- if (occ % sp->b.rowbytes)
- {
- TIFFErrorExtR(tif, module, "Fractional scanlines cannot be read");
- return (-1);
- }
- if (sp->eofReachedCount >= EOF_REACHED_COUNT_THRESHOLD)
- {
- TIFFErrorExtR(
- tif, module,
- "End of file has already been reached %d times within that strip",
- sp->eofReachedCount);
- return (-1);
- }
- CACHE_STATE(tif, sp);
- int start = sp->line;
- while (occ > 0)
- {
- a0 = 0;
- RunLength = 0;
- pa = thisrun = sp->curruns;
- pb = sp->refruns;
- b1 = *pb++;
-#ifdef FAX3_DEBUG
- printf("\nBitAcc=%08" PRIX32 ", BitsAvail = %d\n", BitAcc, BitsAvail);
- printf("-------------------- %d\n", tif->tif_row);
- fflush(stdout);
-#endif
- EXPAND2D(EOFG4);
- if (EOLcnt)
- goto EOFG4;
- if (((lastx + 7) >> 3) > (int)occ) /* check for buffer overrun */
- {
- TIFFErrorExtR(tif, module,
- "Buffer overrun detected : %" TIFF_SSIZE_FORMAT
- " bytes available, %d bits needed",
- occ, lastx);
- return -1;
- }
- (*sp->fill)(buf, thisrun, pa, lastx);
- SETVALUE(0); /* imaginary change for reference */
- SWAP(uint32_t *, sp->curruns, sp->refruns);
- buf += sp->b.rowbytes;
- occ -= sp->b.rowbytes;
- sp->line++;
- continue;
- EOFG4:
- NeedBits16(13, BADG4);
- BADG4:
-#ifdef FAX3_DEBUG
- if (GetBits(13) != 0x1001)
- fputs("Bad EOFB\n", stderr);
-#endif
- ClrBits(13);
- if (((lastx + 7) >> 3) > (int)occ) /* check for buffer overrun */
- {
- TIFFErrorExtR(tif, module,
- "Buffer overrun detected : %" TIFF_SSIZE_FORMAT
- " bytes available, %d bits needed",
- occ, lastx);
- return -1;
- }
- (*sp->fill)(buf, thisrun, pa, lastx);
- UNCACHE_STATE(tif, sp);
- return (sp->line != start
- ? 1
- : -1); /* don't error on badly-terminated strips */
- }
- UNCACHE_STATE(tif, sp);
- return (1);
-}
-#undef SWAP
-
-/*
- * Encode the requested amount of data.
- */
-static int Fax4Encode(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s)
-{
- static const char module[] = "Fax4Encode";
- Fax3CodecState *sp = EncoderState(tif);
- (void)s;
- if (cc % sp->b.rowbytes)
- {
- TIFFErrorExtR(tif, module, "Fractional scanlines cannot be written");
- return (0);
- }
- while (cc > 0)
- {
- if (!Fax3Encode2DRow(tif, bp, sp->refline, sp->b.rowpixels))
- return (0);
- _TIFFmemcpy(sp->refline, bp, sp->b.rowbytes);
- bp += sp->b.rowbytes;
- cc -= sp->b.rowbytes;
- }
- return (1);
-}
-
-static int Fax4PostEncode(TIFF *tif)
-{
- Fax3CodecState *sp = EncoderState(tif);
-
- /* terminate strip w/ EOFB */
- Fax3PutBits(tif, EOL, 12);
- Fax3PutBits(tif, EOL, 12);
- if (sp->bit != 8)
- Fax3FlushBits(tif, sp);
- return (1);
-}
-
-int TIFFInitCCITTFax4(TIFF *tif, int scheme)
-{
- (void)scheme;
- if (InitCCITTFax3(tif))
- { /* reuse G3 support */
- /*
- * Merge codec-specific tag information.
- */
- if (!_TIFFMergeFields(tif, fax4Fields, TIFFArrayCount(fax4Fields)))
- {
- TIFFErrorExtR(tif, "TIFFInitCCITTFax4",
- "Merging CCITT Fax 4 codec-specific tags failed");
- return 0;
- }
-
- tif->tif_decoderow = Fax4Decode;
- tif->tif_decodestrip = Fax4Decode;
- tif->tif_decodetile = Fax4Decode;
- tif->tif_encoderow = Fax4Encode;
- tif->tif_encodestrip = Fax4Encode;
- tif->tif_encodetile = Fax4Encode;
- tif->tif_postencode = Fax4PostEncode;
- /*
- * Suppress RTC at the end of each strip.
- */
- return TIFFSetField(tif, TIFFTAG_FAXMODE, FAXMODE_NORTC);
- }
- else
- return (0);
-}
-
-/*
- * CCITT Group 3 1-D Modified Huffman RLE Compression Support.
- * (Compression algorithms 2 and 32771)
- */
-
-/*
- * Decode the requested amount of RLE-encoded data.
- */
-static int Fax3DecodeRLE(TIFF *tif, uint8_t *buf, tmsize_t occ, uint16_t s)
-{
- DECLARE_STATE(tif, sp, "Fax3DecodeRLE");
- int mode = sp->b.mode;
- (void)s;
- if (occ % sp->b.rowbytes)
- {
- TIFFErrorExtR(tif, module, "Fractional scanlines cannot be read");
- return (-1);
- }
- CACHE_STATE(tif, sp);
- thisrun = sp->curruns;
- while (occ > 0)
- {
- a0 = 0;
- RunLength = 0;
- pa = thisrun;
-#ifdef FAX3_DEBUG
- printf("\nBitAcc=%08" PRIX32 ", BitsAvail = %d\n", BitAcc, BitsAvail);
- printf("-------------------- %" PRIu32 "\n", tif->tif_row);
- fflush(stdout);
-#endif
- EXPAND1D(EOFRLE);
- (*sp->fill)(buf, thisrun, pa, lastx);
- /*
- * Cleanup at the end of the row.
- */
- if (mode & FAXMODE_BYTEALIGN)
- {
- int n = BitsAvail - (BitsAvail & ~7);
- ClrBits(n);
- }
- else if (mode & FAXMODE_WORDALIGN)
- {
- int n = BitsAvail - (BitsAvail & ~15);
- ClrBits(n);
- if (BitsAvail == 0 && !isAligned(cp, uint16_t))
- cp++;
- }
- buf += sp->b.rowbytes;
- occ -= sp->b.rowbytes;
- sp->line++;
- continue;
- EOFRLE: /* premature EOF */
- (*sp->fill)(buf, thisrun, pa, lastx);
- UNCACHE_STATE(tif, sp);
- return (-1);
- }
- UNCACHE_STATE(tif, sp);
- return (1);
-}
-
-int TIFFInitCCITTRLE(TIFF *tif, int scheme)
-{
- (void)scheme;
- if (InitCCITTFax3(tif))
- { /* reuse G3 support */
- tif->tif_decoderow = Fax3DecodeRLE;
- tif->tif_decodestrip = Fax3DecodeRLE;
- tif->tif_decodetile = Fax3DecodeRLE;
- /*
- * Suppress RTC+EOLs when encoding and byte-align data.
- */
- return TIFFSetField(tif, TIFFTAG_FAXMODE,
- FAXMODE_NORTC | FAXMODE_NOEOL | FAXMODE_BYTEALIGN);
- }
- else
- return (0);
-}
-
-int TIFFInitCCITTRLEW(TIFF *tif, int scheme)
-{
- (void)scheme;
- if (InitCCITTFax3(tif))
- { /* reuse G3 support */
- tif->tif_decoderow = Fax3DecodeRLE;
- tif->tif_decodestrip = Fax3DecodeRLE;
- tif->tif_decodetile = Fax3DecodeRLE;
- /*
- * Suppress RTC+EOLs when encoding and word-align data.
- */
- return TIFFSetField(tif, TIFFTAG_FAXMODE,
- FAXMODE_NORTC | FAXMODE_NOEOL | FAXMODE_WORDALIGN);
- }
- else
- return (0);
-}
-#endif /* CCITT_SUPPORT */
diff --git a/contrib/libs/libtiff/tif_fax3.h b/contrib/libs/libtiff/tif_fax3.h
deleted file mode 100644
index e095009bba..0000000000
--- a/contrib/libs/libtiff/tif_fax3.h
+++ /dev/null
@@ -1,648 +0,0 @@
-/*
- * Copyright (c) 1990-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-#ifndef _FAX3_
-#define _FAX3_
-/*
- * TIFF Library.
- *
- * CCITT Group 3 (T.4) and Group 4 (T.6) Decompression Support.
- *
- * Decoder support is derived, with permission, from the code
- * in Frank Cringle's viewfax program;
- * Copyright (C) 1990, 1995 Frank D. Cringle.
- */
-#include "tiff.h"
-
-/*
- * To override the default routine used to image decoded
- * spans one can use the pseudo tag TIFFTAG_FAXFILLFUNC.
- * The routine must have the type signature given below;
- * for example:
- *
- * fillruns(unsigned char* buf, uint32_t* runs, uint32_t* erun, uint32_t lastx)
- *
- * where buf is place to set the bits, runs is the array of b&w run
- * lengths (white then black), erun is the last run in the array, and
- * lastx is the width of the row in pixels. Fill routines can assume
- * the run array has room for at least lastx runs and can overwrite
- * data in the run array as needed (e.g. to append zero runs to bring
- * the count up to a nice multiple).
- */
-typedef void (*TIFFFaxFillFunc)(unsigned char *, uint32_t *, uint32_t *,
- uint32_t);
-
-/*
- * The default run filler; made external for other decoders.
- */
-#if defined(__cplusplus)
-extern "C"
-{
-#endif
- extern void _TIFFFax3fillruns(unsigned char *, uint32_t *, uint32_t *,
- uint32_t);
-#if defined(__cplusplus)
-}
-#endif
-
-/* finite state machine codes */
-#define S_Null 0
-#define S_Pass 1
-#define S_Horiz 2
-#define S_V0 3
-#define S_VR 4
-#define S_VL 5
-#define S_Ext 6
-#define S_TermW 7
-#define S_TermB 8
-#define S_MakeUpW 9
-#define S_MakeUpB 10
-#define S_MakeUp 11
-#define S_EOL 12
-
-/* WARNING: do not change the layout of this structure as the HylaFAX software
- */
-/* really depends on it. See http://bugzilla.maptools.org/show_bug.cgi?id=2636
- */
-typedef struct
-{ /* state table entry */
- unsigned char State; /* see above */
- unsigned char Width; /* width of code in bits */
- uint32_t Param; /* unsigned 32-bit run length in bits (holds on 16 bit
- actually, but cannot be changed. See above warning) */
-} TIFFFaxTabEnt;
-
-extern const TIFFFaxTabEnt TIFFFaxMainTable[];
-extern const TIFFFaxTabEnt TIFFFaxWhiteTable[];
-extern const TIFFFaxTabEnt TIFFFaxBlackTable[];
-
-/*
- * The following macros define the majority of the G3/G4 decoder
- * algorithm using the state tables defined elsewhere. To build
- * a decoder you need some setup code and some glue code. Note
- * that you may also need/want to change the way the NeedBits*
- * macros get input data if, for example, you know the data to be
- * decoded is properly aligned and oriented (doing so before running
- * the decoder can be a big performance win).
- *
- * Consult the decoder in the TIFF library for an idea of what you
- * need to define and setup to make use of these definitions.
- *
- * NB: to enable a debugging version of these macros define FAX3_DEBUG
- * before including this file. Trace output goes to stdout.
- */
-
-#ifndef EndOfData
-#define EndOfData() (cp >= ep)
-#endif
-/*
- * Need <=8 or <=16 bits of input data. Unlike viewfax we
- * cannot use/assume a word-aligned, properly bit swizzled
- * input data set because data may come from an arbitrarily
- * aligned, read-only source such as a memory-mapped file.
- * Note also that the viewfax decoder does not check for
- * running off the end of the input data buffer. This is
- * possible for G3-encoded data because it prescans the input
- * data to count EOL markers, but can cause problems for G4
- * data. In any event, we don't prescan and must watch for
- * running out of data since we can't permit the library to
- * scan past the end of the input data buffer.
- *
- * Finally, note that we must handle remaindered data at the end
- * of a strip specially. The coder asks for a fixed number of
- * bits when scanning for the next code. This may be more bits
- * than are actually present in the data stream. If we appear
- * to run out of data but still have some number of valid bits
- * remaining then we makeup the requested amount with zeros and
- * return successfully. If the returned data is incorrect then
- * we should be called again and get a premature EOF error;
- * otherwise we should get the right answer.
- */
-#ifndef NeedBits8
-#define NeedBits8(n, eoflab) \
- do \
- { \
- if (BitsAvail < (n)) \
- { \
- if (EndOfData()) \
- { \
- if (BitsAvail == 0) /* no valid bits */ \
- goto eoflab; \
- BitsAvail = (n); /* pad with zeros */ \
- } \
- else \
- { \
- BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail; \
- BitsAvail += 8; \
- } \
- } \
- } while (0)
-#endif
-#ifndef NeedBits16
-#define NeedBits16(n, eoflab) \
- do \
- { \
- if (BitsAvail < (n)) \
- { \
- if (EndOfData()) \
- { \
- if (BitsAvail == 0) /* no valid bits */ \
- goto eoflab; \
- BitsAvail = (n); /* pad with zeros */ \
- } \
- else \
- { \
- BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail; \
- if ((BitsAvail += 8) < (n)) \
- { \
- if (EndOfData()) \
- { \
- /* NB: we know BitsAvail is non-zero here */ \
- BitsAvail = (n); /* pad with zeros */ \
- } \
- else \
- { \
- BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail; \
- BitsAvail += 8; \
- } \
- } \
- } \
- } \
- } while (0)
-#endif
-#define GetBits(n) (BitAcc & ((1 << (n)) - 1))
-#define ClrBits(n) \
- do \
- { \
- BitsAvail -= (n); \
- BitAcc >>= (n); \
- } while (0)
-
-#ifdef FAX3_DEBUG
-static const char *StateNames[] = {
- "Null ", "Pass ", "Horiz ", "V0 ", "VR ", "VL ", "Ext ",
- "TermW ", "TermB ", "MakeUpW", "MakeUpB", "MakeUp ", "EOL ",
-};
-#define DEBUG_SHOW putchar(BitAcc & (1 << t) ? '1' : '0')
-#define LOOKUP8(wid, tab, eoflab) \
- do \
- { \
- int t; \
- NeedBits8(wid, eoflab); \
- TabEnt = tab + GetBits(wid); \
- printf("%08lX/%d: %s%5d\t", (long)BitAcc, BitsAvail, \
- StateNames[TabEnt->State], TabEnt->Param); \
- for (t = 0; t < TabEnt->Width; t++) \
- DEBUG_SHOW; \
- putchar('\n'); \
- fflush(stdout); \
- ClrBits(TabEnt->Width); \
- } while (0)
-#define LOOKUP16(wid, tab, eoflab) \
- do \
- { \
- int t; \
- NeedBits16(wid, eoflab); \
- TabEnt = tab + GetBits(wid); \
- printf("%08lX/%d: %s%5d\t", (long)BitAcc, BitsAvail, \
- StateNames[TabEnt->State], TabEnt->Param); \
- for (t = 0; t < TabEnt->Width; t++) \
- DEBUG_SHOW; \
- putchar('\n'); \
- fflush(stdout); \
- ClrBits(TabEnt->Width); \
- } while (0)
-
-#define SETVALUE(x) \
- do \
- { \
- *pa++ = RunLength + (x); \
- printf("SETVALUE: %d\t%d\n", RunLength + (x), a0); \
- a0 += x; \
- RunLength = 0; \
- } while (0)
-#else
-#define LOOKUP8(wid, tab, eoflab) \
- do \
- { \
- NeedBits8(wid, eoflab); \
- TabEnt = tab + GetBits(wid); \
- ClrBits(TabEnt->Width); \
- } while (0)
-#define LOOKUP16(wid, tab, eoflab) \
- do \
- { \
- NeedBits16(wid, eoflab); \
- TabEnt = tab + GetBits(wid); \
- ClrBits(TabEnt->Width); \
- } while (0)
-
-/*
- * Append a run to the run length array for the
- * current row and reset decoding state.
- */
-#define SETVALUE(x) \
- do \
- { \
- if (pa >= thisrun + sp->nruns) \
- { \
- TIFFErrorExtR(tif, module, "Buffer overflow at line %u of %s %u", \
- sp->line, isTiled(tif) ? "tile" : "strip", \
- isTiled(tif) ? tif->tif_curtile \
- : tif->tif_curstrip); \
- return (-1); \
- } \
- *pa++ = RunLength + (x); \
- a0 += (x); \
- RunLength = 0; \
- } while (0)
-#endif
-
-/*
- * Synchronize input decoding at the start of each
- * row by scanning for an EOL (if appropriate) and
- * skipping any trash data that might be present
- * after a decoding error. Note that the decoding
- * done elsewhere that recognizes an EOL only consumes
- * 11 consecutive zero bits. This means that if EOLcnt
- * is non-zero then we still need to scan for the final flag
- * bit that is part of the EOL code.
- */
-#define SYNC_EOL(eoflab) \
- do \
- { \
- if (EOLcnt == 0) \
- { \
- for (;;) \
- { \
- NeedBits16(11, eoflab); \
- if (GetBits(11) == 0) \
- break; \
- ClrBits(1); \
- } \
- } \
- for (;;) \
- { \
- NeedBits8(8, eoflab); \
- if (GetBits(8)) \
- break; \
- ClrBits(8); \
- } \
- while (GetBits(1) == 0) \
- ClrBits(1); \
- ClrBits(1); /* EOL bit */ \
- EOLcnt = 0; /* reset EOL counter/flag */ \
- } while (0)
-
-/*
- * Cleanup the array of runs after decoding a row.
- * We adjust final runs to insure the user buffer is not
- * overwritten and/or undecoded area is white filled.
- */
-#define CLEANUP_RUNS() \
- do \
- { \
- if (RunLength) \
- SETVALUE(0); \
- if (a0 != lastx) \
- { \
- badlength(a0, lastx); \
- while (a0 > lastx && pa > thisrun) \
- a0 -= *--pa; \
- if (a0 < lastx) \
- { \
- if (a0 < 0) \
- a0 = 0; \
- if ((pa - thisrun) & 1) \
- SETVALUE(0); \
- SETVALUE(lastx - a0); \
- } \
- else if (a0 > lastx) \
- { \
- SETVALUE(lastx); \
- SETVALUE(0); \
- } \
- } \
- } while (0)
-
-/*
- * Decode a line of 1D-encoded data.
- *
- * The line expanders are written as macros so that they can be reused
- * but still have direct access to the local variables of the "calling"
- * function.
- *
- * Note that unlike the original version we have to explicitly test for
- * a0 >= lastx after each black/white run is decoded. This is because
- * the original code depended on the input data being zero-padded to
- * insure the decoder recognized an EOL before running out of data.
- */
-#define EXPAND1D(eoflab) \
- do \
- { \
- for (;;) \
- { \
- for (;;) \
- { \
- LOOKUP16(12, TIFFFaxWhiteTable, eof1d); \
- switch (TabEnt->State) \
- { \
- case S_EOL: \
- EOLcnt = 1; \
- goto done1d; \
- case S_TermW: \
- SETVALUE(TabEnt->Param); \
- goto doneWhite1d; \
- case S_MakeUpW: \
- case S_MakeUp: \
- a0 += TabEnt->Param; \
- RunLength += TabEnt->Param; \
- break; \
- default: \
- unexpected("WhiteTable", a0); \
- goto done1d; \
- } \
- } \
- doneWhite1d: \
- if (a0 >= lastx) \
- goto done1d; \
- for (;;) \
- { \
- LOOKUP16(13, TIFFFaxBlackTable, eof1d); \
- switch (TabEnt->State) \
- { \
- case S_EOL: \
- EOLcnt = 1; \
- goto done1d; \
- case S_TermB: \
- SETVALUE(TabEnt->Param); \
- goto doneBlack1d; \
- case S_MakeUpB: \
- case S_MakeUp: \
- a0 += TabEnt->Param; \
- RunLength += TabEnt->Param; \
- break; \
- default: \
- unexpected("BlackTable", a0); \
- goto done1d; \
- } \
- } \
- doneBlack1d: \
- if (a0 >= lastx) \
- goto done1d; \
- if (*(pa - 1) == 0 && *(pa - 2) == 0) \
- pa -= 2; \
- } \
- eof1d: \
- prematureEOF(a0); \
- CLEANUP_RUNS(); \
- goto eoflab; \
- done1d: \
- CLEANUP_RUNS(); \
- } while (0)
-
-/*
- * Update the value of b1 using the array
- * of runs for the reference line.
- */
-#define CHECK_b1 \
- do \
- { \
- if (pa != thisrun) \
- while (b1 <= a0 && b1 < lastx) \
- { \
- if (pb + 1 >= sp->refruns + sp->nruns) \
- { \
- TIFFErrorExtR( \
- tif, module, "Buffer overflow at line %u of %s %u", \
- sp->line, isTiled(tif) ? "tile" : "strip", \
- isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip); \
- return (-1); \
- } \
- b1 += pb[0] + pb[1]; \
- pb += 2; \
- } \
- } while (0)
-
-/*
- * Expand a row of 2D-encoded data.
- */
-#define EXPAND2D(eoflab) \
- do \
- { \
- while (a0 < lastx) \
- { \
- if (pa >= thisrun + sp->nruns) \
- { \
- TIFFErrorExtR( \
- tif, module, "Buffer overflow at line %u of %s %u", \
- sp->line, isTiled(tif) ? "tile" : "strip", \
- isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip); \
- return (-1); \
- } \
- LOOKUP8(7, TIFFFaxMainTable, eof2d); \
- switch (TabEnt->State) \
- { \
- case S_Pass: \
- CHECK_b1; \
- if (pb + 1 >= sp->refruns + sp->nruns) \
- { \
- TIFFErrorExtR(tif, module, \
- "Buffer overflow at line %u of %s %u", \
- sp->line, \
- isTiled(tif) ? "tile" : "strip", \
- isTiled(tif) ? tif->tif_curtile \
- : tif->tif_curstrip); \
- return (-1); \
- } \
- b1 += *pb++; \
- RunLength += b1 - a0; \
- a0 = b1; \
- b1 += *pb++; \
- break; \
- case S_Horiz: \
- if ((pa - thisrun) & 1) \
- { \
- for (;;) \
- { /* black first */ \
- LOOKUP16(13, TIFFFaxBlackTable, eof2d); \
- switch (TabEnt->State) \
- { \
- case S_TermB: \
- SETVALUE(TabEnt->Param); \
- goto doneWhite2da; \
- case S_MakeUpB: \
- case S_MakeUp: \
- a0 += TabEnt->Param; \
- RunLength += TabEnt->Param; \
- break; \
- default: \
- goto badBlack2d; \
- } \
- } \
- doneWhite2da:; \
- for (;;) \
- { /* then white */ \
- LOOKUP16(12, TIFFFaxWhiteTable, eof2d); \
- switch (TabEnt->State) \
- { \
- case S_TermW: \
- SETVALUE(TabEnt->Param); \
- goto doneBlack2da; \
- case S_MakeUpW: \
- case S_MakeUp: \
- a0 += TabEnt->Param; \
- RunLength += TabEnt->Param; \
- break; \
- default: \
- goto badWhite2d; \
- } \
- } \
- doneBlack2da:; \
- } \
- else \
- { \
- for (;;) \
- { /* white first */ \
- LOOKUP16(12, TIFFFaxWhiteTable, eof2d); \
- switch (TabEnt->State) \
- { \
- case S_TermW: \
- SETVALUE(TabEnt->Param); \
- goto doneWhite2db; \
- case S_MakeUpW: \
- case S_MakeUp: \
- a0 += TabEnt->Param; \
- RunLength += TabEnt->Param; \
- break; \
- default: \
- goto badWhite2d; \
- } \
- } \
- doneWhite2db:; \
- for (;;) \
- { /* then black */ \
- LOOKUP16(13, TIFFFaxBlackTable, eof2d); \
- switch (TabEnt->State) \
- { \
- case S_TermB: \
- SETVALUE(TabEnt->Param); \
- goto doneBlack2db; \
- case S_MakeUpB: \
- case S_MakeUp: \
- a0 += TabEnt->Param; \
- RunLength += TabEnt->Param; \
- break; \
- default: \
- goto badBlack2d; \
- } \
- } \
- doneBlack2db:; \
- } \
- CHECK_b1; \
- break; \
- case S_V0: \
- CHECK_b1; \
- SETVALUE(b1 - a0); \
- if (pb >= sp->refruns + sp->nruns) \
- { \
- TIFFErrorExtR(tif, module, \
- "Buffer overflow at line %u of %s %u", \
- sp->line, \
- isTiled(tif) ? "tile" : "strip", \
- isTiled(tif) ? tif->tif_curtile \
- : tif->tif_curstrip); \
- return (-1); \
- } \
- b1 += *pb++; \
- break; \
- case S_VR: \
- CHECK_b1; \
- SETVALUE(b1 - a0 + TabEnt->Param); \
- if (pb >= sp->refruns + sp->nruns) \
- { \
- TIFFErrorExtR(tif, module, \
- "Buffer overflow at line %u of %s %u", \
- sp->line, \
- isTiled(tif) ? "tile" : "strip", \
- isTiled(tif) ? tif->tif_curtile \
- : tif->tif_curstrip); \
- return (-1); \
- } \
- b1 += *pb++; \
- break; \
- case S_VL: \
- CHECK_b1; \
- if (b1 < (int)(a0 + TabEnt->Param)) \
- { \
- unexpected("VL", a0); \
- goto eol2d; \
- } \
- SETVALUE(b1 - a0 - TabEnt->Param); \
- b1 -= *--pb; \
- break; \
- case S_Ext: \
- *pa++ = lastx - a0; \
- extension(a0); \
- goto eol2d; \
- case S_EOL: \
- *pa++ = lastx - a0; \
- NeedBits8(4, eof2d); \
- if (GetBits(4)) \
- unexpected("EOL", a0); \
- ClrBits(4); \
- EOLcnt = 1; \
- goto eol2d; \
- default: \
- badMain2d: \
- unexpected("MainTable", a0); \
- goto eol2d; \
- badBlack2d: \
- unexpected("BlackTable", a0); \
- goto eol2d; \
- badWhite2d: \
- unexpected("WhiteTable", a0); \
- goto eol2d; \
- eof2d: \
- prematureEOF(a0); \
- CLEANUP_RUNS(); \
- goto eoflab; \
- } \
- } \
- if (RunLength) \
- { \
- if (RunLength + a0 < lastx) \
- { \
- /* expect a final V0 */ \
- NeedBits8(1, eof2d); \
- if (!GetBits(1)) \
- goto badMain2d; \
- ClrBits(1); \
- } \
- SETVALUE(0); \
- } \
- eol2d: \
- CLEANUP_RUNS(); \
- } while (0)
-#endif /* _FAX3_ */
diff --git a/contrib/libs/libtiff/tif_fax3sm.c b/contrib/libs/libtiff/tif_fax3sm.c
deleted file mode 100644
index ba2fc532e8..0000000000
--- a/contrib/libs/libtiff/tif_fax3sm.c
+++ /dev/null
@@ -1,1261 +0,0 @@
-/* WARNING, this file was automatically generated by the
- mkg3states program */
-#include <stdint.h>
-#include "tiff.h"
-#include "tif_fax3.h"
- const TIFFFaxTabEnt TIFFFaxMainTable[128] = {
-{12,7,0},{3,1,0},{5,3,1},{3,1,0},{2,3,0},{3,1,0},{4,3,1},{3,1,0},{1,4,0},{3,1,0},
-{5,3,1},{3,1,0},{2,3,0},{3,1,0},{4,3,1},{3,1,0},{5,6,2},{3,1,0},{5,3,1},{3,1,0},
-{2,3,0},{3,1,0},{4,3,1},{3,1,0},{1,4,0},{3,1,0},{5,3,1},{3,1,0},{2,3,0},{3,1,0},
-{4,3,1},{3,1,0},{5,7,3},{3,1,0},{5,3,1},{3,1,0},{2,3,0},{3,1,0},{4,3,1},{3,1,0},
-{1,4,0},{3,1,0},{5,3,1},{3,1,0},{2,3,0},{3,1,0},{4,3,1},{3,1,0},{4,6,2},{3,1,0},
-{5,3,1},{3,1,0},{2,3,0},{3,1,0},{4,3,1},{3,1,0},{1,4,0},{3,1,0},{5,3,1},{3,1,0},
-{2,3,0},{3,1,0},{4,3,1},{3,1,0},{6,7,0},{3,1,0},{5,3,1},{3,1,0},{2,3,0},{3,1,0},
-{4,3,1},{3,1,0},{1,4,0},{3,1,0},{5,3,1},{3,1,0},{2,3,0},{3,1,0},{4,3,1},{3,1,0},
-{5,6,2},{3,1,0},{5,3,1},{3,1,0},{2,3,0},{3,1,0},{4,3,1},{3,1,0},{1,4,0},{3,1,0},
-{5,3,1},{3,1,0},{2,3,0},{3,1,0},{4,3,1},{3,1,0},{4,7,3},{3,1,0},{5,3,1},{3,1,0},
-{2,3,0},{3,1,0},{4,3,1},{3,1,0},{1,4,0},{3,1,0},{5,3,1},{3,1,0},{2,3,0},{3,1,0},
-{4,3,1},{3,1,0},{4,6,2},{3,1,0},{5,3,1},{3,1,0},{2,3,0},{3,1,0},{4,3,1},{3,1,0},
-{1,4,0},{3,1,0},{5,3,1},{3,1,0},{2,3,0},{3,1,0},{4,3,1},{3,1,0}
-};
- const TIFFFaxTabEnt TIFFFaxWhiteTable[4096] = {
-{12,11,0},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},
-{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},
-{7,8,39},{7,6,16},{9,8,576},{7,4,6},{7,7,19},{7,5,8},{7,8,55},{9,5,64},{7,5,10},{7,4,4},
-{7,4,2},{7,4,7},{7,8,45},{7,4,3},{7,5,11},{7,4,5},{7,8,53},{7,5,9},{9,8,448},{7,4,6},
-{7,8,35},{9,5,128},{7,8,51},{7,6,15},{7,8,63},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},
-{9,9,1472},{7,4,5},{7,8,43},{7,6,17},{9,9,1216},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},
-{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,29},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},
-{9,6,1664},{7,4,6},{7,8,33},{9,5,128},{7,8,49},{7,6,14},{7,8,61},{7,4,4},{7,4,2},{7,4,7},
-{7,8,47},{7,4,3},{7,8,59},{7,4,5},{7,8,41},{7,6,16},{9,9,960},{7,4,6},{7,8,31},{7,5,8},
-{7,8,57},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},
-{7,7,26},{7,5,9},{9,9,704},{7,4,6},{7,8,37},{9,5,128},{7,7,25},{7,6,15},{9,8,320},{7,4,4},
-{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},
-{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{11,11,1792},{7,4,3},
-{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},
-{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,40},{7,6,16},
-{9,9,832},{7,4,6},{7,7,19},{7,5,8},{7,8,56},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
-{7,8,46},{7,4,3},{7,5,11},{7,4,5},{7,8,54},{7,5,9},{9,8,512},{7,4,6},{7,8,36},{9,5,128},
-{7,8,52},{7,6,15},{7,8,0},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1600},{7,4,5},
-{7,8,44},{7,6,17},{9,9,1344},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},
-{7,4,2},{7,4,7},{7,8,30},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},
-{7,8,34},{9,5,128},{7,8,50},{7,6,14},{7,8,62},{7,4,4},{7,4,2},{7,4,7},{7,8,48},{7,4,3},
-{7,8,60},{7,4,5},{7,8,42},{7,6,16},{9,9,1088},{7,4,6},{7,8,32},{7,5,8},{7,8,58},{9,5,64},
-{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},
-{9,8,640},{7,4,6},{7,8,38},{9,5,128},{7,7,25},{7,6,15},{9,8,384},{7,4,4},{7,4,2},{7,4,7},
-{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},
-{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{0,0,0},{7,4,3},{7,5,11},{7,4,5},
-{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},
-{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,39},{7,6,16},{9,8,576},{7,4,6},
-{7,7,19},{7,5,8},{7,8,55},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,45},{7,4,3},
-{7,5,11},{7,4,5},{7,8,53},{7,5,9},{9,8,448},{7,4,6},{7,8,35},{9,5,128},{7,8,51},{7,6,15},
-{7,8,63},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1536},{7,4,5},{7,8,43},{7,6,17},
-{9,9,1280},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
-{7,8,29},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,33},{9,5,128},
-{7,8,49},{7,6,14},{7,8,61},{7,4,4},{7,4,2},{7,4,7},{7,8,47},{7,4,3},{7,8,59},{7,4,5},
-{7,8,41},{7,6,16},{9,9,1024},{7,4,6},{7,8,31},{7,5,8},{7,8,57},{9,5,64},{7,5,10},{7,4,4},
-{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,9,768},{7,4,6},
-{7,8,37},{9,5,128},{7,7,25},{7,6,15},{9,8,320},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},
-{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},
-{7,5,10},{7,4,4},{7,4,2},{7,4,7},{11,11,1856},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},
-{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},
-{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,40},{7,6,16},{9,9,896},{7,4,6},{7,7,19},{7,5,8},
-{7,8,56},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,46},{7,4,3},{7,5,11},{7,4,5},
-{7,8,54},{7,5,9},{9,8,512},{7,4,6},{7,8,36},{9,5,128},{7,8,52},{7,6,15},{7,8,0},{7,4,4},
-{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1728},{7,4,5},{7,8,44},{7,6,17},{9,9,1408},{7,4,6},
-{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,30},{7,4,3},
-{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,34},{9,5,128},{7,8,50},{7,6,14},
-{7,8,62},{7,4,4},{7,4,2},{7,4,7},{7,8,48},{7,4,3},{7,8,60},{7,4,5},{7,8,42},{7,6,16},
-{9,9,1152},{7,4,6},{7,8,32},{7,5,8},{7,8,58},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
-{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,8,640},{7,4,6},{7,8,38},{9,5,128},
-{7,7,25},{7,6,15},{9,8,384},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},
-{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},
-{7,4,2},{7,4,7},{0,0,0},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},
-{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},
-{7,7,27},{7,4,5},{7,8,39},{7,6,16},{9,8,576},{7,4,6},{7,7,19},{7,5,8},{7,8,55},{9,5,64},
-{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,45},{7,4,3},{7,5,11},{7,4,5},{7,8,53},{7,5,9},
-{9,8,448},{7,4,6},{7,8,35},{9,5,128},{7,8,51},{7,6,15},{7,8,63},{7,4,4},{7,4,2},{7,4,7},
-{7,6,13},{7,4,3},{9,9,1472},{7,4,5},{7,8,43},{7,6,17},{9,9,1216},{7,4,6},{7,6,1},{7,5,8},
-{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,29},{7,4,3},{7,5,11},{7,4,5},
-{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,33},{9,5,128},{7,8,49},{7,6,14},{7,8,61},{7,4,4},
-{7,4,2},{7,4,7},{7,8,47},{7,4,3},{7,8,59},{7,4,5},{7,8,41},{7,6,16},{9,9,960},{7,4,6},
-{7,8,31},{7,5,8},{7,8,57},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},
-{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,9,704},{7,4,6},{7,8,37},{9,5,128},{7,7,25},{7,6,15},
-{9,8,320},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},
-{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
-{11,12,2112},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},
-{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},
-{7,8,40},{7,6,16},{9,9,832},{7,4,6},{7,7,19},{7,5,8},{7,8,56},{9,5,64},{7,5,10},{7,4,4},
-{7,4,2},{7,4,7},{7,8,46},{7,4,3},{7,5,11},{7,4,5},{7,8,54},{7,5,9},{9,8,512},{7,4,6},
-{7,8,36},{9,5,128},{7,8,52},{7,6,15},{7,8,0},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},
-{9,9,1600},{7,4,5},{7,8,44},{7,6,17},{9,9,1344},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},
-{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,30},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},
-{9,6,1664},{7,4,6},{7,8,34},{9,5,128},{7,8,50},{7,6,14},{7,8,62},{7,4,4},{7,4,2},{7,4,7},
-{7,8,48},{7,4,3},{7,8,60},{7,4,5},{7,8,42},{7,6,16},{9,9,1088},{7,4,6},{7,8,32},{7,5,8},
-{7,8,58},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},
-{7,7,26},{7,5,9},{9,8,640},{7,4,6},{7,8,38},{9,5,128},{7,7,25},{7,6,15},{9,8,384},{7,4,4},
-{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},
-{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{0,0,0},{7,4,3},
-{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},
-{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,39},{7,6,16},
-{9,8,576},{7,4,6},{7,7,19},{7,5,8},{7,8,55},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
-{7,8,45},{7,4,3},{7,5,11},{7,4,5},{7,8,53},{7,5,9},{9,8,448},{7,4,6},{7,8,35},{9,5,128},
-{7,8,51},{7,6,15},{7,8,63},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1536},{7,4,5},
-{7,8,43},{7,6,17},{9,9,1280},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},
-{7,4,2},{7,4,7},{7,8,29},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},
-{7,8,33},{9,5,128},{7,8,49},{7,6,14},{7,8,61},{7,4,4},{7,4,2},{7,4,7},{7,8,47},{7,4,3},
-{7,8,59},{7,4,5},{7,8,41},{7,6,16},{9,9,1024},{7,4,6},{7,8,31},{7,5,8},{7,8,57},{9,5,64},
-{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},
-{9,9,768},{7,4,6},{7,8,37},{9,5,128},{7,7,25},{7,6,15},{9,8,320},{7,4,4},{7,4,2},{7,4,7},
-{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},
-{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{11,12,2368},{7,4,3},{7,5,11},{7,4,5},
-{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},
-{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,40},{7,6,16},{9,9,896},{7,4,6},
-{7,7,19},{7,5,8},{7,8,56},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,46},{7,4,3},
-{7,5,11},{7,4,5},{7,8,54},{7,5,9},{9,8,512},{7,4,6},{7,8,36},{9,5,128},{7,8,52},{7,6,15},
-{7,8,0},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1728},{7,4,5},{7,8,44},{7,6,17},
-{9,9,1408},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
-{7,8,30},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,34},{9,5,128},
-{7,8,50},{7,6,14},{7,8,62},{7,4,4},{7,4,2},{7,4,7},{7,8,48},{7,4,3},{7,8,60},{7,4,5},
-{7,8,42},{7,6,16},{9,9,1152},{7,4,6},{7,8,32},{7,5,8},{7,8,58},{9,5,64},{7,5,10},{7,4,4},
-{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,8,640},{7,4,6},
-{7,8,38},{9,5,128},{7,7,25},{7,6,15},{9,8,384},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},
-{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},
-{7,5,10},{7,4,4},{7,4,2},{7,4,7},{0,0,0},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},
-{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},
-{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,39},{7,6,16},{9,8,576},{7,4,6},{7,7,19},{7,5,8},
-{7,8,55},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,45},{7,4,3},{7,5,11},{7,4,5},
-{7,8,53},{7,5,9},{9,8,448},{7,4,6},{7,8,35},{9,5,128},{7,8,51},{7,6,15},{7,8,63},{7,4,4},
-{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1472},{7,4,5},{7,8,43},{7,6,17},{9,9,1216},{7,4,6},
-{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,29},{7,4,3},
-{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,33},{9,5,128},{7,8,49},{7,6,14},
-{7,8,61},{7,4,4},{7,4,2},{7,4,7},{7,8,47},{7,4,3},{7,8,59},{7,4,5},{7,8,41},{7,6,16},
-{9,9,960},{7,4,6},{7,8,31},{7,5,8},{7,8,57},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
-{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,9,704},{7,4,6},{7,8,37},{9,5,128},
-{7,7,25},{7,6,15},{9,8,320},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},
-{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},
-{7,4,2},{7,4,7},{11,12,1984},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},
-{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},
-{7,7,27},{7,4,5},{7,8,40},{7,6,16},{9,9,832},{7,4,6},{7,7,19},{7,5,8},{7,8,56},{9,5,64},
-{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,46},{7,4,3},{7,5,11},{7,4,5},{7,8,54},{7,5,9},
-{9,8,512},{7,4,6},{7,8,36},{9,5,128},{7,8,52},{7,6,15},{7,8,0},{7,4,4},{7,4,2},{7,4,7},
-{7,6,13},{7,4,3},{9,9,1600},{7,4,5},{7,8,44},{7,6,17},{9,9,1344},{7,4,6},{7,6,1},{7,5,8},
-{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,30},{7,4,3},{7,5,11},{7,4,5},
-{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,34},{9,5,128},{7,8,50},{7,6,14},{7,8,62},{7,4,4},
-{7,4,2},{7,4,7},{7,8,48},{7,4,3},{7,8,60},{7,4,5},{7,8,42},{7,6,16},{9,9,1088},{7,4,6},
-{7,8,32},{7,5,8},{7,8,58},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},
-{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,8,640},{7,4,6},{7,8,38},{9,5,128},{7,7,25},{7,6,15},
-{9,8,384},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},
-{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
-{0,0,0},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},
-{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},
-{7,8,39},{7,6,16},{9,8,576},{7,4,6},{7,7,19},{7,5,8},{7,8,55},{9,5,64},{7,5,10},{7,4,4},
-{7,4,2},{7,4,7},{7,8,45},{7,4,3},{7,5,11},{7,4,5},{7,8,53},{7,5,9},{9,8,448},{7,4,6},
-{7,8,35},{9,5,128},{7,8,51},{7,6,15},{7,8,63},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},
-{9,9,1536},{7,4,5},{7,8,43},{7,6,17},{9,9,1280},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},
-{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,29},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},
-{9,6,1664},{7,4,6},{7,8,33},{9,5,128},{7,8,49},{7,6,14},{7,8,61},{7,4,4},{7,4,2},{7,4,7},
-{7,8,47},{7,4,3},{7,8,59},{7,4,5},{7,8,41},{7,6,16},{9,9,1024},{7,4,6},{7,8,31},{7,5,8},
-{7,8,57},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},
-{7,7,26},{7,5,9},{9,9,768},{7,4,6},{7,8,37},{9,5,128},{7,7,25},{7,6,15},{9,8,320},{7,4,4},
-{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},
-{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{11,11,1920},{7,4,3},
-{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},
-{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,40},{7,6,16},
-{9,9,896},{7,4,6},{7,7,19},{7,5,8},{7,8,56},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
-{7,8,46},{7,4,3},{7,5,11},{7,4,5},{7,8,54},{7,5,9},{9,8,512},{7,4,6},{7,8,36},{9,5,128},
-{7,8,52},{7,6,15},{7,8,0},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1728},{7,4,5},
-{7,8,44},{7,6,17},{9,9,1408},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},
-{7,4,2},{7,4,7},{7,8,30},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},
-{7,8,34},{9,5,128},{7,8,50},{7,6,14},{7,8,62},{7,4,4},{7,4,2},{7,4,7},{7,8,48},{7,4,3},
-{7,8,60},{7,4,5},{7,8,42},{7,6,16},{9,9,1152},{7,4,6},{7,8,32},{7,5,8},{7,8,58},{9,5,64},
-{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},
-{9,8,640},{7,4,6},{7,8,38},{9,5,128},{7,7,25},{7,6,15},{9,8,384},{7,4,4},{7,4,2},{7,4,7},
-{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},
-{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{0,0,0},{7,4,3},{7,5,11},{7,4,5},
-{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},
-{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,39},{7,6,16},{9,8,576},{7,4,6},
-{7,7,19},{7,5,8},{7,8,55},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,45},{7,4,3},
-{7,5,11},{7,4,5},{7,8,53},{7,5,9},{9,8,448},{7,4,6},{7,8,35},{9,5,128},{7,8,51},{7,6,15},
-{7,8,63},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1472},{7,4,5},{7,8,43},{7,6,17},
-{9,9,1216},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
-{7,8,29},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,33},{9,5,128},
-{7,8,49},{7,6,14},{7,8,61},{7,4,4},{7,4,2},{7,4,7},{7,8,47},{7,4,3},{7,8,59},{7,4,5},
-{7,8,41},{7,6,16},{9,9,960},{7,4,6},{7,8,31},{7,5,8},{7,8,57},{9,5,64},{7,5,10},{7,4,4},
-{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,9,704},{7,4,6},
-{7,8,37},{9,5,128},{7,7,25},{7,6,15},{9,8,320},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},
-{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},
-{7,5,10},{7,4,4},{7,4,2},{7,4,7},{11,12,2240},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},
-{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},
-{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,40},{7,6,16},{9,9,832},{7,4,6},{7,7,19},{7,5,8},
-{7,8,56},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,46},{7,4,3},{7,5,11},{7,4,5},
-{7,8,54},{7,5,9},{9,8,512},{7,4,6},{7,8,36},{9,5,128},{7,8,52},{7,6,15},{7,8,0},{7,4,4},
-{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1600},{7,4,5},{7,8,44},{7,6,17},{9,9,1344},{7,4,6},
-{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,30},{7,4,3},
-{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,34},{9,5,128},{7,8,50},{7,6,14},
-{7,8,62},{7,4,4},{7,4,2},{7,4,7},{7,8,48},{7,4,3},{7,8,60},{7,4,5},{7,8,42},{7,6,16},
-{9,9,1088},{7,4,6},{7,8,32},{7,5,8},{7,8,58},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
-{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,8,640},{7,4,6},{7,8,38},{9,5,128},
-{7,7,25},{7,6,15},{9,8,384},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},
-{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},
-{7,4,2},{7,4,7},{0,0,0},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},
-{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},
-{7,7,27},{7,4,5},{7,8,39},{7,6,16},{9,8,576},{7,4,6},{7,7,19},{7,5,8},{7,8,55},{9,5,64},
-{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,45},{7,4,3},{7,5,11},{7,4,5},{7,8,53},{7,5,9},
-{9,8,448},{7,4,6},{7,8,35},{9,5,128},{7,8,51},{7,6,15},{7,8,63},{7,4,4},{7,4,2},{7,4,7},
-{7,6,13},{7,4,3},{9,9,1536},{7,4,5},{7,8,43},{7,6,17},{9,9,1280},{7,4,6},{7,6,1},{7,5,8},
-{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,29},{7,4,3},{7,5,11},{7,4,5},
-{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,33},{9,5,128},{7,8,49},{7,6,14},{7,8,61},{7,4,4},
-{7,4,2},{7,4,7},{7,8,47},{7,4,3},{7,8,59},{7,4,5},{7,8,41},{7,6,16},{9,9,1024},{7,4,6},
-{7,8,31},{7,5,8},{7,8,57},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},
-{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,9,768},{7,4,6},{7,8,37},{9,5,128},{7,7,25},{7,6,15},
-{9,8,320},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},
-{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
-{11,12,2496},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},
-{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},
-{7,8,40},{7,6,16},{9,9,896},{7,4,6},{7,7,19},{7,5,8},{7,8,56},{9,5,64},{7,5,10},{7,4,4},
-{7,4,2},{7,4,7},{7,8,46},{7,4,3},{7,5,11},{7,4,5},{7,8,54},{7,5,9},{9,8,512},{7,4,6},
-{7,8,36},{9,5,128},{7,8,52},{7,6,15},{7,8,0},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},
-{9,9,1728},{7,4,5},{7,8,44},{7,6,17},{9,9,1408},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},
-{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,30},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},
-{9,6,1664},{7,4,6},{7,8,34},{9,5,128},{7,8,50},{7,6,14},{7,8,62},{7,4,4},{7,4,2},{7,4,7},
-{7,8,48},{7,4,3},{7,8,60},{7,4,5},{7,8,42},{7,6,16},{9,9,1152},{7,4,6},{7,8,32},{7,5,8},
-{7,8,58},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},
-{7,7,26},{7,5,9},{9,8,640},{7,4,6},{7,8,38},{9,5,128},{7,7,25},{7,6,15},{9,8,384},{7,4,4},
-{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},
-{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{12,11,0},{7,4,3},
-{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},
-{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,39},{7,6,16},
-{9,8,576},{7,4,6},{7,7,19},{7,5,8},{7,8,55},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
-{7,8,45},{7,4,3},{7,5,11},{7,4,5},{7,8,53},{7,5,9},{9,8,448},{7,4,6},{7,8,35},{9,5,128},
-{7,8,51},{7,6,15},{7,8,63},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1472},{7,4,5},
-{7,8,43},{7,6,17},{9,9,1216},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},
-{7,4,2},{7,4,7},{7,8,29},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},
-{7,8,33},{9,5,128},{7,8,49},{7,6,14},{7,8,61},{7,4,4},{7,4,2},{7,4,7},{7,8,47},{7,4,3},
-{7,8,59},{7,4,5},{7,8,41},{7,6,16},{9,9,960},{7,4,6},{7,8,31},{7,5,8},{7,8,57},{9,5,64},
-{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},
-{9,9,704},{7,4,6},{7,8,37},{9,5,128},{7,7,25},{7,6,15},{9,8,320},{7,4,4},{7,4,2},{7,4,7},
-{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},
-{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{11,11,1792},{7,4,3},{7,5,11},{7,4,5},
-{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},
-{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,40},{7,6,16},{9,9,832},{7,4,6},
-{7,7,19},{7,5,8},{7,8,56},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,46},{7,4,3},
-{7,5,11},{7,4,5},{7,8,54},{7,5,9},{9,8,512},{7,4,6},{7,8,36},{9,5,128},{7,8,52},{7,6,15},
-{7,8,0},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1600},{7,4,5},{7,8,44},{7,6,17},
-{9,9,1344},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
-{7,8,30},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,34},{9,5,128},
-{7,8,50},{7,6,14},{7,8,62},{7,4,4},{7,4,2},{7,4,7},{7,8,48},{7,4,3},{7,8,60},{7,4,5},
-{7,8,42},{7,6,16},{9,9,1088},{7,4,6},{7,8,32},{7,5,8},{7,8,58},{9,5,64},{7,5,10},{7,4,4},
-{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,8,640},{7,4,6},
-{7,8,38},{9,5,128},{7,7,25},{7,6,15},{9,8,384},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},
-{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},
-{7,5,10},{7,4,4},{7,4,2},{7,4,7},{0,0,0},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},
-{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},
-{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,39},{7,6,16},{9,8,576},{7,4,6},{7,7,19},{7,5,8},
-{7,8,55},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,45},{7,4,3},{7,5,11},{7,4,5},
-{7,8,53},{7,5,9},{9,8,448},{7,4,6},{7,8,35},{9,5,128},{7,8,51},{7,6,15},{7,8,63},{7,4,4},
-{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1536},{7,4,5},{7,8,43},{7,6,17},{9,9,1280},{7,4,6},
-{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,29},{7,4,3},
-{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,33},{9,5,128},{7,8,49},{7,6,14},
-{7,8,61},{7,4,4},{7,4,2},{7,4,7},{7,8,47},{7,4,3},{7,8,59},{7,4,5},{7,8,41},{7,6,16},
-{9,9,1024},{7,4,6},{7,8,31},{7,5,8},{7,8,57},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
-{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,9,768},{7,4,6},{7,8,37},{9,5,128},
-{7,7,25},{7,6,15},{9,8,320},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},
-{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},
-{7,4,2},{7,4,7},{11,11,1856},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},
-{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},
-{7,7,27},{7,4,5},{7,8,40},{7,6,16},{9,9,896},{7,4,6},{7,7,19},{7,5,8},{7,8,56},{9,5,64},
-{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,46},{7,4,3},{7,5,11},{7,4,5},{7,8,54},{7,5,9},
-{9,8,512},{7,4,6},{7,8,36},{9,5,128},{7,8,52},{7,6,15},{7,8,0},{7,4,4},{7,4,2},{7,4,7},
-{7,6,13},{7,4,3},{9,9,1728},{7,4,5},{7,8,44},{7,6,17},{9,9,1408},{7,4,6},{7,6,1},{7,5,8},
-{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,30},{7,4,3},{7,5,11},{7,4,5},
-{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,34},{9,5,128},{7,8,50},{7,6,14},{7,8,62},{7,4,4},
-{7,4,2},{7,4,7},{7,8,48},{7,4,3},{7,8,60},{7,4,5},{7,8,42},{7,6,16},{9,9,1152},{7,4,6},
-{7,8,32},{7,5,8},{7,8,58},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},
-{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,8,640},{7,4,6},{7,8,38},{9,5,128},{7,7,25},{7,6,15},
-{9,8,384},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},
-{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
-{0,0,0},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},
-{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},
-{7,8,39},{7,6,16},{9,8,576},{7,4,6},{7,7,19},{7,5,8},{7,8,55},{9,5,64},{7,5,10},{7,4,4},
-{7,4,2},{7,4,7},{7,8,45},{7,4,3},{7,5,11},{7,4,5},{7,8,53},{7,5,9},{9,8,448},{7,4,6},
-{7,8,35},{9,5,128},{7,8,51},{7,6,15},{7,8,63},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},
-{9,9,1472},{7,4,5},{7,8,43},{7,6,17},{9,9,1216},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},
-{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,29},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},
-{9,6,1664},{7,4,6},{7,8,33},{9,5,128},{7,8,49},{7,6,14},{7,8,61},{7,4,4},{7,4,2},{7,4,7},
-{7,8,47},{7,4,3},{7,8,59},{7,4,5},{7,8,41},{7,6,16},{9,9,960},{7,4,6},{7,8,31},{7,5,8},
-{7,8,57},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},
-{7,7,26},{7,5,9},{9,9,704},{7,4,6},{7,8,37},{9,5,128},{7,7,25},{7,6,15},{9,8,320},{7,4,4},
-{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},
-{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{11,12,2176},{7,4,3},
-{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},
-{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,40},{7,6,16},
-{9,9,832},{7,4,6},{7,7,19},{7,5,8},{7,8,56},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
-{7,8,46},{7,4,3},{7,5,11},{7,4,5},{7,8,54},{7,5,9},{9,8,512},{7,4,6},{7,8,36},{9,5,128},
-{7,8,52},{7,6,15},{7,8,0},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1600},{7,4,5},
-{7,8,44},{7,6,17},{9,9,1344},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},
-{7,4,2},{7,4,7},{7,8,30},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},
-{7,8,34},{9,5,128},{7,8,50},{7,6,14},{7,8,62},{7,4,4},{7,4,2},{7,4,7},{7,8,48},{7,4,3},
-{7,8,60},{7,4,5},{7,8,42},{7,6,16},{9,9,1088},{7,4,6},{7,8,32},{7,5,8},{7,8,58},{9,5,64},
-{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},
-{9,8,640},{7,4,6},{7,8,38},{9,5,128},{7,7,25},{7,6,15},{9,8,384},{7,4,4},{7,4,2},{7,4,7},
-{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},
-{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{0,0,0},{7,4,3},{7,5,11},{7,4,5},
-{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},
-{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,39},{7,6,16},{9,8,576},{7,4,6},
-{7,7,19},{7,5,8},{7,8,55},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,45},{7,4,3},
-{7,5,11},{7,4,5},{7,8,53},{7,5,9},{9,8,448},{7,4,6},{7,8,35},{9,5,128},{7,8,51},{7,6,15},
-{7,8,63},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1536},{7,4,5},{7,8,43},{7,6,17},
-{9,9,1280},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
-{7,8,29},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,33},{9,5,128},
-{7,8,49},{7,6,14},{7,8,61},{7,4,4},{7,4,2},{7,4,7},{7,8,47},{7,4,3},{7,8,59},{7,4,5},
-{7,8,41},{7,6,16},{9,9,1024},{7,4,6},{7,8,31},{7,5,8},{7,8,57},{9,5,64},{7,5,10},{7,4,4},
-{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,9,768},{7,4,6},
-{7,8,37},{9,5,128},{7,7,25},{7,6,15},{9,8,320},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},
-{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},
-{7,5,10},{7,4,4},{7,4,2},{7,4,7},{11,12,2432},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},
-{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},
-{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,40},{7,6,16},{9,9,896},{7,4,6},{7,7,19},{7,5,8},
-{7,8,56},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,46},{7,4,3},{7,5,11},{7,4,5},
-{7,8,54},{7,5,9},{9,8,512},{7,4,6},{7,8,36},{9,5,128},{7,8,52},{7,6,15},{7,8,0},{7,4,4},
-{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1728},{7,4,5},{7,8,44},{7,6,17},{9,9,1408},{7,4,6},
-{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,30},{7,4,3},
-{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,34},{9,5,128},{7,8,50},{7,6,14},
-{7,8,62},{7,4,4},{7,4,2},{7,4,7},{7,8,48},{7,4,3},{7,8,60},{7,4,5},{7,8,42},{7,6,16},
-{9,9,1152},{7,4,6},{7,8,32},{7,5,8},{7,8,58},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
-{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,8,640},{7,4,6},{7,8,38},{9,5,128},
-{7,7,25},{7,6,15},{9,8,384},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},
-{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},
-{7,4,2},{7,4,7},{0,0,0},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},
-{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},
-{7,7,27},{7,4,5},{7,8,39},{7,6,16},{9,8,576},{7,4,6},{7,7,19},{7,5,8},{7,8,55},{9,5,64},
-{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,45},{7,4,3},{7,5,11},{7,4,5},{7,8,53},{7,5,9},
-{9,8,448},{7,4,6},{7,8,35},{9,5,128},{7,8,51},{7,6,15},{7,8,63},{7,4,4},{7,4,2},{7,4,7},
-{7,6,13},{7,4,3},{9,9,1472},{7,4,5},{7,8,43},{7,6,17},{9,9,1216},{7,4,6},{7,6,1},{7,5,8},
-{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,29},{7,4,3},{7,5,11},{7,4,5},
-{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,33},{9,5,128},{7,8,49},{7,6,14},{7,8,61},{7,4,4},
-{7,4,2},{7,4,7},{7,8,47},{7,4,3},{7,8,59},{7,4,5},{7,8,41},{7,6,16},{9,9,960},{7,4,6},
-{7,8,31},{7,5,8},{7,8,57},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},
-{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,9,704},{7,4,6},{7,8,37},{9,5,128},{7,7,25},{7,6,15},
-{9,8,320},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},
-{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
-{11,12,2048},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},
-{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},
-{7,8,40},{7,6,16},{9,9,832},{7,4,6},{7,7,19},{7,5,8},{7,8,56},{9,5,64},{7,5,10},{7,4,4},
-{7,4,2},{7,4,7},{7,8,46},{7,4,3},{7,5,11},{7,4,5},{7,8,54},{7,5,9},{9,8,512},{7,4,6},
-{7,8,36},{9,5,128},{7,8,52},{7,6,15},{7,8,0},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},
-{9,9,1600},{7,4,5},{7,8,44},{7,6,17},{9,9,1344},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},
-{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,30},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},
-{9,6,1664},{7,4,6},{7,8,34},{9,5,128},{7,8,50},{7,6,14},{7,8,62},{7,4,4},{7,4,2},{7,4,7},
-{7,8,48},{7,4,3},{7,8,60},{7,4,5},{7,8,42},{7,6,16},{9,9,1088},{7,4,6},{7,8,32},{7,5,8},
-{7,8,58},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},
-{7,7,26},{7,5,9},{9,8,640},{7,4,6},{7,8,38},{9,5,128},{7,7,25},{7,6,15},{9,8,384},{7,4,4},
-{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},
-{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{0,0,0},{7,4,3},
-{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},
-{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,39},{7,6,16},
-{9,8,576},{7,4,6},{7,7,19},{7,5,8},{7,8,55},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
-{7,8,45},{7,4,3},{7,5,11},{7,4,5},{7,8,53},{7,5,9},{9,8,448},{7,4,6},{7,8,35},{9,5,128},
-{7,8,51},{7,6,15},{7,8,63},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1536},{7,4,5},
-{7,8,43},{7,6,17},{9,9,1280},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},
-{7,4,2},{7,4,7},{7,8,29},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},
-{7,8,33},{9,5,128},{7,8,49},{7,6,14},{7,8,61},{7,4,4},{7,4,2},{7,4,7},{7,8,47},{7,4,3},
-{7,8,59},{7,4,5},{7,8,41},{7,6,16},{9,9,1024},{7,4,6},{7,8,31},{7,5,8},{7,8,57},{9,5,64},
-{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},
-{9,9,768},{7,4,6},{7,8,37},{9,5,128},{7,7,25},{7,6,15},{9,8,320},{7,4,4},{7,4,2},{7,4,7},
-{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},
-{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{11,11,1920},{7,4,3},{7,5,11},{7,4,5},
-{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},
-{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,40},{7,6,16},{9,9,896},{7,4,6},
-{7,7,19},{7,5,8},{7,8,56},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,46},{7,4,3},
-{7,5,11},{7,4,5},{7,8,54},{7,5,9},{9,8,512},{7,4,6},{7,8,36},{9,5,128},{7,8,52},{7,6,15},
-{7,8,0},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1728},{7,4,5},{7,8,44},{7,6,17},
-{9,9,1408},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
-{7,8,30},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,34},{9,5,128},
-{7,8,50},{7,6,14},{7,8,62},{7,4,4},{7,4,2},{7,4,7},{7,8,48},{7,4,3},{7,8,60},{7,4,5},
-{7,8,42},{7,6,16},{9,9,1152},{7,4,6},{7,8,32},{7,5,8},{7,8,58},{9,5,64},{7,5,10},{7,4,4},
-{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,8,640},{7,4,6},
-{7,8,38},{9,5,128},{7,7,25},{7,6,15},{9,8,384},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},
-{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},
-{7,5,10},{7,4,4},{7,4,2},{7,4,7},{0,0,0},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},
-{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},
-{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,39},{7,6,16},{9,8,576},{7,4,6},{7,7,19},{7,5,8},
-{7,8,55},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,45},{7,4,3},{7,5,11},{7,4,5},
-{7,8,53},{7,5,9},{9,8,448},{7,4,6},{7,8,35},{9,5,128},{7,8,51},{7,6,15},{7,8,63},{7,4,4},
-{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1472},{7,4,5},{7,8,43},{7,6,17},{9,9,1216},{7,4,6},
-{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,29},{7,4,3},
-{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,33},{9,5,128},{7,8,49},{7,6,14},
-{7,8,61},{7,4,4},{7,4,2},{7,4,7},{7,8,47},{7,4,3},{7,8,59},{7,4,5},{7,8,41},{7,6,16},
-{9,9,960},{7,4,6},{7,8,31},{7,5,8},{7,8,57},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
-{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,9,704},{7,4,6},{7,8,37},{9,5,128},
-{7,7,25},{7,6,15},{9,8,320},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},
-{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},
-{7,4,2},{7,4,7},{11,12,2304},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},
-{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},
-{7,7,27},{7,4,5},{7,8,40},{7,6,16},{9,9,832},{7,4,6},{7,7,19},{7,5,8},{7,8,56},{9,5,64},
-{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,46},{7,4,3},{7,5,11},{7,4,5},{7,8,54},{7,5,9},
-{9,8,512},{7,4,6},{7,8,36},{9,5,128},{7,8,52},{7,6,15},{7,8,0},{7,4,4},{7,4,2},{7,4,7},
-{7,6,13},{7,4,3},{9,9,1600},{7,4,5},{7,8,44},{7,6,17},{9,9,1344},{7,4,6},{7,6,1},{7,5,8},
-{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,30},{7,4,3},{7,5,11},{7,4,5},
-{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,34},{9,5,128},{7,8,50},{7,6,14},{7,8,62},{7,4,4},
-{7,4,2},{7,4,7},{7,8,48},{7,4,3},{7,8,60},{7,4,5},{7,8,42},{7,6,16},{9,9,1088},{7,4,6},
-{7,8,32},{7,5,8},{7,8,58},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},
-{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,8,640},{7,4,6},{7,8,38},{9,5,128},{7,7,25},{7,6,15},
-{9,8,384},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},
-{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
-{0,0,0},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},
-{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},
-{7,8,39},{7,6,16},{9,8,576},{7,4,6},{7,7,19},{7,5,8},{7,8,55},{9,5,64},{7,5,10},{7,4,4},
-{7,4,2},{7,4,7},{7,8,45},{7,4,3},{7,5,11},{7,4,5},{7,8,53},{7,5,9},{9,8,448},{7,4,6},
-{7,8,35},{9,5,128},{7,8,51},{7,6,15},{7,8,63},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},
-{9,9,1536},{7,4,5},{7,8,43},{7,6,17},{9,9,1280},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},
-{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,29},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},
-{9,6,1664},{7,4,6},{7,8,33},{9,5,128},{7,8,49},{7,6,14},{7,8,61},{7,4,4},{7,4,2},{7,4,7},
-{7,8,47},{7,4,3},{7,8,59},{7,4,5},{7,8,41},{7,6,16},{9,9,1024},{7,4,6},{7,8,31},{7,5,8},
-{7,8,57},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},
-{7,7,26},{7,5,9},{9,9,768},{7,4,6},{7,8,37},{9,5,128},{7,7,25},{7,6,15},{9,8,320},{7,4,4},
-{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},
-{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{11,12,2560},{7,4,3},
-{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},
-{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,40},{7,6,16},
-{9,9,896},{7,4,6},{7,7,19},{7,5,8},{7,8,56},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
-{7,8,46},{7,4,3},{7,5,11},{7,4,5},{7,8,54},{7,5,9},{9,8,512},{7,4,6},{7,8,36},{9,5,128},
-{7,8,52},{7,6,15},{7,8,0},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1728},{7,4,5},
-{7,8,44},{7,6,17},{9,9,1408},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},
-{7,4,2},{7,4,7},{7,8,30},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},
-{7,8,34},{9,5,128},{7,8,50},{7,6,14},{7,8,62},{7,4,4},{7,4,2},{7,4,7},{7,8,48},{7,4,3},
-{7,8,60},{7,4,5},{7,8,42},{7,6,16},{9,9,1152},{7,4,6},{7,8,32},{7,5,8},{7,8,58},{9,5,64},
-{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},
-{9,8,640},{7,4,6},{7,8,38},{9,5,128},{7,7,25},{7,6,15},{9,8,384},{7,4,4},{7,4,2},{7,4,7},
-{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},
-{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7}
-};
- const TIFFFaxTabEnt TIFFFaxBlackTable[8192] = {
-{12,11,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,9,15},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,18},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,17},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,11,1792},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,11,23},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,20},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,11,25},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,12,128},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,12,56},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,12,30},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,11,1856},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,57},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,11,21},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,54},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,9,15},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,52},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,48},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{11,12,2112},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,12,44},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,36},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,12,384},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,28},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,12,60},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,40},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,12,2368},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,16},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{10,10,64},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,9,15},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,18},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,10,17},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{11,12,1984},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,50},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,12,34},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,13,1664},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,26},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,13,1408},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,32},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,11,1920},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,12,61},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,42},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{10,13,1024},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,9,15},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{10,13,768},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,12,62},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,12,2240},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,46},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,12,38},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,13,512},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,11,19},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,24},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,22},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{11,12,2496},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,10,16},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,0},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,10,64},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{12,11,0},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,9,15},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,10,18},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,17},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,11,1792},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,23},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,20},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,11,25},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{10,12,192},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,13,1280},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,12,31},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{11,11,1856},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,58},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,11,21},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,13,896},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,9,15},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,13,640},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,49},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,12,2176},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,12,45},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,37},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{10,12,448},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,29},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{10,13,1536},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,12,41},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,12,2432},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,16},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,10,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,10,64},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,9,15},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,18},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,17},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{11,12,2048},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,12,51},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,35},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,12,320},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,27},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,12,59},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,33},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,11,1920},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,12,256},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,43},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{10,13,1152},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,9,15},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,55},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,12,63},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{11,12,2304},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,47},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,12,39},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,53},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,19},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,24},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,22},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,12,2560},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,10,16},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,0},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{10,10,64},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{12,11,0},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,9,15},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,10,18},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,10,17},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,11,1792},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,23},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,11,20},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,25},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{10,12,128},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,56},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,30},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{11,11,1856},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,12,57},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,21},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,54},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,9,15},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,12,52},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,48},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,12,2112},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,44},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,36},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{10,12,384},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,12,28},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,60},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,12,40},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{11,12,2368},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,16},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,10,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,10,64},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,9,15},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,18},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,17},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,12,1984},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,12,50},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,34},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{10,13,1728},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,26},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{10,13,1472},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,12,32},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,11,1920},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,61},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,12,42},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,13,1088},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,9,15},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,13,832},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,62},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{11,12,2240},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,12,46},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,38},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,13,576},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,19},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,11,24},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,22},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,12,2496},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,16},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{10,10,64},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{12,11,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,9,15},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,18},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,10,17},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{11,11,1792},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,23},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,11,20},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,25},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,12,192},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,13,1344},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,31},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,11,1856},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,12,58},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,21},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{10,13,960},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,9,15},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{10,13,704},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,12,49},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,12,2176},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,45},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,12,37},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,12,448},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,12,29},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,13,1600},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,41},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{11,12,2432},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,10,16},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,0},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,10,64},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,9,15},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,10,18},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,17},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,12,2048},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,51},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,35},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{10,12,320},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,12,27},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,59},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,12,33},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{11,11,1920},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,12,256},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,12,43},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,13,1216},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,9,15},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,55},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,63},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,12,2304},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,12,47},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,39},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,12,53},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,19},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,11,24},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,11,22},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,12,2560},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,16},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2},{8,10,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
-{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,10,64},{8,2,3},
-{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
-{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
-{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
-{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
-{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},
-{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
-{8,3,4},{8,2,2}
-};
-/*
- * Local Variables:
- * mode: c
- * c-basic-offset: 8
- * fill-column: 78
- * End:
- */
diff --git a/contrib/libs/libtiff/tif_flush.c b/contrib/libs/libtiff/tif_flush.c
deleted file mode 100644
index ff9c1e247a..0000000000
--- a/contrib/libs/libtiff/tif_flush.c
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright (c) 1988-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-/*
- * TIFF Library.
- */
-#include "tiffiop.h"
-
-int TIFFFlush(TIFF *tif)
-{
- if (tif->tif_mode == O_RDONLY)
- return 1;
-
- if (!TIFFFlushData(tif))
- return (0);
-
- /* In update (r+) mode we try to detect the case where
- only the strip/tile map has been altered, and we try to
- rewrite only that portion of the directory without
- making any other changes */
-
- if ((tif->tif_flags & TIFF_DIRTYSTRIP) &&
- !(tif->tif_flags & TIFF_DIRTYDIRECT) && tif->tif_mode == O_RDWR)
- {
- if (TIFFForceStrileArrayWriting(tif))
- return 1;
- }
-
- if ((tif->tif_flags & (TIFF_DIRTYDIRECT | TIFF_DIRTYSTRIP)) &&
- !TIFFRewriteDirectory(tif))
- return (0);
-
- return (1);
-}
-
-/*
- * This is an advanced writing function that must be used in a particular
- * sequence, and together with TIFFDeferStrileArrayWriting(),
- * to make its intended effect. Its aim is to force the writing of
- * the [Strip/Tile][Offsets/ByteCounts] arrays at the end of the file, when
- * they have not yet been rewritten.
- *
- * The typical sequence of calls is:
- * TIFFOpen()
- * [ TIFFCreateDirectory(tif) ]
- * Set fields with calls to TIFFSetField(tif, ...)
- * TIFFDeferStrileArrayWriting(tif)
- * TIFFWriteCheck(tif, ...)
- * TIFFWriteDirectory(tif)
- * ... potentially create other directories and come back to the above directory
- * TIFFForceStrileArrayWriting(tif)
- *
- * Returns 1 in case of success, 0 otherwise.
- */
-int TIFFForceStrileArrayWriting(TIFF *tif)
-{
- static const char module[] = "TIFFForceStrileArrayWriting";
- const int isTiled = TIFFIsTiled(tif);
-
- if (tif->tif_mode == O_RDONLY)
- {
- TIFFErrorExtR(tif, tif->tif_name, "File opened in read-only mode");
- return 0;
- }
- if (tif->tif_diroff == 0)
- {
- TIFFErrorExtR(tif, module, "Directory has not yet been written");
- return 0;
- }
- if ((tif->tif_flags & TIFF_DIRTYDIRECT) != 0)
- {
- TIFFErrorExtR(tif, module,
- "Directory has changes other than the strile arrays. "
- "TIFFRewriteDirectory() should be called instead");
- return 0;
- }
-
- if (!(tif->tif_flags & TIFF_DIRTYSTRIP))
- {
- if (!(tif->tif_dir.td_stripoffset_entry.tdir_tag != 0 &&
- tif->tif_dir.td_stripoffset_entry.tdir_count == 0 &&
- tif->tif_dir.td_stripoffset_entry.tdir_type == 0 &&
- tif->tif_dir.td_stripoffset_entry.tdir_offset.toff_long8 == 0 &&
- tif->tif_dir.td_stripbytecount_entry.tdir_tag != 0 &&
- tif->tif_dir.td_stripbytecount_entry.tdir_count == 0 &&
- tif->tif_dir.td_stripbytecount_entry.tdir_type == 0 &&
- tif->tif_dir.td_stripbytecount_entry.tdir_offset.toff_long8 == 0))
- {
- TIFFErrorExtR(tif, module,
- "Function not called together with "
- "TIFFDeferStrileArrayWriting()");
- return 0;
- }
-
- if (tif->tif_dir.td_stripoffset_p == NULL && !TIFFSetupStrips(tif))
- return 0;
- }
-
- if (_TIFFRewriteField(tif,
- isTiled ? TIFFTAG_TILEOFFSETS : TIFFTAG_STRIPOFFSETS,
- TIFF_LONG8, tif->tif_dir.td_nstrips,
- tif->tif_dir.td_stripoffset_p) &&
- _TIFFRewriteField(
- tif, isTiled ? TIFFTAG_TILEBYTECOUNTS : TIFFTAG_STRIPBYTECOUNTS,
- TIFF_LONG8, tif->tif_dir.td_nstrips,
- tif->tif_dir.td_stripbytecount_p))
- {
- tif->tif_flags &= ~TIFF_DIRTYSTRIP;
- tif->tif_flags &= ~TIFF_BEENWRITING;
- return 1;
- }
-
- return 0;
-}
-
-/*
- * Flush buffered data to the file.
- *
- * Frank Warmerdam'2000: I modified this to return 1 if TIFF_BEENWRITING
- * is not set, so that TIFFFlush() will proceed to write out the directory.
- * The documentation says returning 1 is an error indicator, but not having
- * been writing isn't exactly a an error. Hopefully this doesn't cause
- * problems for other people.
- */
-int TIFFFlushData(TIFF *tif)
-{
- if ((tif->tif_flags & TIFF_BEENWRITING) == 0)
- return (1);
- if (tif->tif_flags & TIFF_POSTENCODE)
- {
- tif->tif_flags &= ~TIFF_POSTENCODE;
- if (!(*tif->tif_postencode)(tif))
- return (0);
- }
- return (TIFFFlushData1(tif));
-}
diff --git a/contrib/libs/libtiff/tif_getimage.c b/contrib/libs/libtiff/tif_getimage.c
deleted file mode 100644
index 6c7b5031a1..0000000000
--- a/contrib/libs/libtiff/tif_getimage.c
+++ /dev/null
@@ -1,3412 +0,0 @@
-/*
- * Copyright (c) 1991-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-/*
- * TIFF Library
- *
- * Read and return a packed RGBA image.
- */
-#include "tiffiop.h"
-#include <limits.h>
-#include <stdio.h>
-
-static int gtTileContig(TIFFRGBAImage *, uint32_t *, uint32_t, uint32_t);
-static int gtTileSeparate(TIFFRGBAImage *, uint32_t *, uint32_t, uint32_t);
-static int gtStripContig(TIFFRGBAImage *, uint32_t *, uint32_t, uint32_t);
-static int gtStripSeparate(TIFFRGBAImage *, uint32_t *, uint32_t, uint32_t);
-static int PickContigCase(TIFFRGBAImage *);
-static int PickSeparateCase(TIFFRGBAImage *);
-
-static int BuildMapUaToAa(TIFFRGBAImage *img);
-static int BuildMapBitdepth16To8(TIFFRGBAImage *img);
-
-static const char photoTag[] = "PhotometricInterpretation";
-
-/*
- * Helper constants used in Orientation tag handling
- */
-#define FLIP_VERTICALLY 0x01
-#define FLIP_HORIZONTALLY 0x02
-
-#define EMSG_BUF_SIZE 1024
-
-/*
- * Color conversion constants. We will define display types here.
- */
-
-static const TIFFDisplay display_sRGB = {
- {/* XYZ -> luminance matrix */
- {3.2410F, -1.5374F, -0.4986F},
- {-0.9692F, 1.8760F, 0.0416F},
- {0.0556F, -0.2040F, 1.0570F}},
- 100.0F,
- 100.0F,
- 100.0F, /* Light o/p for reference white */
- 255,
- 255,
- 255, /* Pixel values for ref. white */
- 1.0F,
- 1.0F,
- 1.0F, /* Residual light o/p for black pixel */
- 2.4F,
- 2.4F,
- 2.4F, /* Gamma values for the three guns */
-};
-
-/*
- * Check the image to see if TIFFReadRGBAImage can deal with it.
- * 1/0 is returned according to whether or not the image can
- * be handled. If 0 is returned, emsg contains the reason
- * why it is being rejected.
- */
-int TIFFRGBAImageOK(TIFF *tif, char emsg[EMSG_BUF_SIZE])
-{
- TIFFDirectory *td = &tif->tif_dir;
- uint16_t photometric;
- int colorchannels;
-
- if (!tif->tif_decodestatus)
- {
- snprintf(emsg, EMSG_BUF_SIZE,
- "Sorry, requested compression method is not configured");
- return (0);
- }
- switch (td->td_bitspersample)
- {
- case 1:
- case 2:
- case 4:
- case 8:
- case 16:
- break;
- default:
- snprintf(emsg, EMSG_BUF_SIZE,
- "Sorry, can not handle images with %" PRIu16
- "-bit samples",
- td->td_bitspersample);
- return (0);
- }
- if (td->td_sampleformat == SAMPLEFORMAT_IEEEFP)
- {
- snprintf(
- emsg, EMSG_BUF_SIZE,
- "Sorry, can not handle images with IEEE floating-point samples");
- return (0);
- }
- colorchannels = td->td_samplesperpixel - td->td_extrasamples;
- if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &photometric))
- {
- switch (colorchannels)
- {
- case 1:
- photometric = PHOTOMETRIC_MINISBLACK;
- break;
- case 3:
- photometric = PHOTOMETRIC_RGB;
- break;
- default:
- snprintf(emsg, EMSG_BUF_SIZE, "Missing needed %s tag",
- photoTag);
- return (0);
- }
- }
- switch (photometric)
- {
- case PHOTOMETRIC_MINISWHITE:
- case PHOTOMETRIC_MINISBLACK:
- case PHOTOMETRIC_PALETTE:
- if (td->td_planarconfig == PLANARCONFIG_CONTIG &&
- td->td_samplesperpixel != 1 && td->td_bitspersample < 8)
- {
- snprintf(
- emsg, EMSG_BUF_SIZE,
- "Sorry, can not handle contiguous data with %s=%" PRIu16
- ", "
- "and %s=%" PRIu16 " and Bits/Sample=%" PRIu16 "",
- photoTag, photometric, "Samples/pixel",
- td->td_samplesperpixel, td->td_bitspersample);
- return (0);
- }
- /*
- * We should likely validate that any extra samples are either
- * to be ignored, or are alpha, and if alpha we should try to use
- * them. But for now we won't bother with this.
- */
- break;
- case PHOTOMETRIC_YCBCR:
- /*
- * TODO: if at all meaningful and useful, make more complete
- * support check here, or better still, refactor to let supporting
- * code decide whether there is support and what meaningful
- * error to return
- */
- break;
- case PHOTOMETRIC_RGB:
- if (colorchannels < 3)
- {
- snprintf(emsg, EMSG_BUF_SIZE,
- "Sorry, can not handle RGB image with %s=%d",
- "Color channels", colorchannels);
- return (0);
- }
- break;
- case PHOTOMETRIC_SEPARATED:
- {
- uint16_t inkset;
- TIFFGetFieldDefaulted(tif, TIFFTAG_INKSET, &inkset);
- if (inkset != INKSET_CMYK)
- {
- snprintf(emsg, EMSG_BUF_SIZE,
- "Sorry, can not handle separated image with %s=%d",
- "InkSet", inkset);
- return 0;
- }
- if (td->td_samplesperpixel < 4)
- {
- snprintf(
- emsg, EMSG_BUF_SIZE,
- "Sorry, can not handle separated image with %s=%" PRIu16,
- "Samples/pixel", td->td_samplesperpixel);
- return 0;
- }
- break;
- }
- case PHOTOMETRIC_LOGL:
- if (td->td_compression != COMPRESSION_SGILOG)
- {
- snprintf(emsg, EMSG_BUF_SIZE,
- "Sorry, LogL data must have %s=%d", "Compression",
- COMPRESSION_SGILOG);
- return (0);
- }
- break;
- case PHOTOMETRIC_LOGLUV:
- if (td->td_compression != COMPRESSION_SGILOG &&
- td->td_compression != COMPRESSION_SGILOG24)
- {
- snprintf(emsg, EMSG_BUF_SIZE,
- "Sorry, LogLuv data must have %s=%d or %d",
- "Compression", COMPRESSION_SGILOG,
- COMPRESSION_SGILOG24);
- return (0);
- }
- if (td->td_planarconfig != PLANARCONFIG_CONTIG)
- {
- snprintf(emsg, EMSG_BUF_SIZE,
- "Sorry, can not handle LogLuv images with %s=%" PRIu16,
- "Planarconfiguration", td->td_planarconfig);
- return (0);
- }
- if (td->td_samplesperpixel != 3 || colorchannels != 3)
- {
- snprintf(emsg, EMSG_BUF_SIZE,
- "Sorry, can not handle image with %s=%" PRIu16
- ", %s=%d",
- "Samples/pixel", td->td_samplesperpixel,
- "colorchannels", colorchannels);
- return 0;
- }
- break;
- case PHOTOMETRIC_CIELAB:
- if (td->td_samplesperpixel != 3 || colorchannels != 3 ||
- (td->td_bitspersample != 8 && td->td_bitspersample != 16))
- {
- snprintf(emsg, EMSG_BUF_SIZE,
- "Sorry, can not handle image with %s=%" PRIu16
- ", %s=%d and %s=%" PRIu16,
- "Samples/pixel", td->td_samplesperpixel,
- "colorchannels", colorchannels, "Bits/sample",
- td->td_bitspersample);
- return 0;
- }
- break;
- default:
- snprintf(emsg, EMSG_BUF_SIZE,
- "Sorry, can not handle image with %s=%" PRIu16, photoTag,
- photometric);
- return (0);
- }
- return (1);
-}
-
-void TIFFRGBAImageEnd(TIFFRGBAImage *img)
-{
- if (img->Map)
- {
- _TIFFfreeExt(img->tif, img->Map);
- img->Map = NULL;
- }
- if (img->BWmap)
- {
- _TIFFfreeExt(img->tif, img->BWmap);
- img->BWmap = NULL;
- }
- if (img->PALmap)
- {
- _TIFFfreeExt(img->tif, img->PALmap);
- img->PALmap = NULL;
- }
- if (img->ycbcr)
- {
- _TIFFfreeExt(img->tif, img->ycbcr);
- img->ycbcr = NULL;
- }
- if (img->cielab)
- {
- _TIFFfreeExt(img->tif, img->cielab);
- img->cielab = NULL;
- }
- if (img->UaToAa)
- {
- _TIFFfreeExt(img->tif, img->UaToAa);
- img->UaToAa = NULL;
- }
- if (img->Bitdepth16To8)
- {
- _TIFFfreeExt(img->tif, img->Bitdepth16To8);
- img->Bitdepth16To8 = NULL;
- }
-
- if (img->redcmap)
- {
- _TIFFfreeExt(img->tif, img->redcmap);
- _TIFFfreeExt(img->tif, img->greencmap);
- _TIFFfreeExt(img->tif, img->bluecmap);
- img->redcmap = img->greencmap = img->bluecmap = NULL;
- }
-}
-
-static int isCCITTCompression(TIFF *tif)
-{
- uint16_t compress;
- TIFFGetField(tif, TIFFTAG_COMPRESSION, &compress);
- return (compress == COMPRESSION_CCITTFAX3 ||
- compress == COMPRESSION_CCITTFAX4 ||
- compress == COMPRESSION_CCITTRLE ||
- compress == COMPRESSION_CCITTRLEW);
-}
-
-int TIFFRGBAImageBegin(TIFFRGBAImage *img, TIFF *tif, int stop,
- char emsg[EMSG_BUF_SIZE])
-{
- uint16_t *sampleinfo;
- uint16_t extrasamples;
- uint16_t planarconfig;
- uint16_t compress;
- int colorchannels;
- uint16_t *red_orig, *green_orig, *blue_orig;
- int n_color;
-
- if (!TIFFRGBAImageOK(tif, emsg))
- return 0;
-
- /* Initialize to normal values */
- img->row_offset = 0;
- img->col_offset = 0;
- img->redcmap = NULL;
- img->greencmap = NULL;
- img->bluecmap = NULL;
- img->Map = NULL;
- img->BWmap = NULL;
- img->PALmap = NULL;
- img->ycbcr = NULL;
- img->cielab = NULL;
- img->UaToAa = NULL;
- img->Bitdepth16To8 = NULL;
- img->req_orientation = ORIENTATION_BOTLEFT; /* It is the default */
-
- img->tif = tif;
- img->stoponerr = stop;
- TIFFGetFieldDefaulted(tif, TIFFTAG_BITSPERSAMPLE, &img->bitspersample);
- switch (img->bitspersample)
- {
- case 1:
- case 2:
- case 4:
- case 8:
- case 16:
- break;
- default:
- snprintf(emsg, EMSG_BUF_SIZE,
- "Sorry, can not handle images with %" PRIu16
- "-bit samples",
- img->bitspersample);
- goto fail_return;
- }
- img->alpha = 0;
- TIFFGetFieldDefaulted(tif, TIFFTAG_SAMPLESPERPIXEL, &img->samplesperpixel);
- TIFFGetFieldDefaulted(tif, TIFFTAG_EXTRASAMPLES, &extrasamples,
- &sampleinfo);
- if (extrasamples >= 1)
- {
- switch (sampleinfo[0])
- {
- case EXTRASAMPLE_UNSPECIFIED: /* Workaround for some images without
- */
- if (img->samplesperpixel >
- 3) /* correct info about alpha channel */
- img->alpha = EXTRASAMPLE_ASSOCALPHA;
- break;
- case EXTRASAMPLE_ASSOCALPHA: /* data is pre-multiplied */
- case EXTRASAMPLE_UNASSALPHA: /* data is not pre-multiplied */
- img->alpha = sampleinfo[0];
- break;
- }
- }
-
-#ifdef DEFAULT_EXTRASAMPLE_AS_ALPHA
- if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &img->photometric))
- img->photometric = PHOTOMETRIC_MINISWHITE;
-
- if (extrasamples == 0 && img->samplesperpixel == 4 &&
- img->photometric == PHOTOMETRIC_RGB)
- {
- img->alpha = EXTRASAMPLE_ASSOCALPHA;
- extrasamples = 1;
- }
-#endif
-
- colorchannels = img->samplesperpixel - extrasamples;
- TIFFGetFieldDefaulted(tif, TIFFTAG_COMPRESSION, &compress);
- TIFFGetFieldDefaulted(tif, TIFFTAG_PLANARCONFIG, &planarconfig);
- if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &img->photometric))
- {
- switch (colorchannels)
- {
- case 1:
- if (isCCITTCompression(tif))
- img->photometric = PHOTOMETRIC_MINISWHITE;
- else
- img->photometric = PHOTOMETRIC_MINISBLACK;
- break;
- case 3:
- img->photometric = PHOTOMETRIC_RGB;
- break;
- default:
- snprintf(emsg, EMSG_BUF_SIZE, "Missing needed %s tag",
- photoTag);
- goto fail_return;
- }
- }
- switch (img->photometric)
- {
- case PHOTOMETRIC_PALETTE:
- if (!TIFFGetField(tif, TIFFTAG_COLORMAP, &red_orig, &green_orig,
- &blue_orig))
- {
- snprintf(emsg, EMSG_BUF_SIZE,
- "Missing required \"Colormap\" tag");
- goto fail_return;
- }
-
- /* copy the colormaps so we can modify them */
- n_color = (1U << img->bitspersample);
- img->redcmap =
- (uint16_t *)_TIFFmallocExt(tif, sizeof(uint16_t) * n_color);
- img->greencmap =
- (uint16_t *)_TIFFmallocExt(tif, sizeof(uint16_t) * n_color);
- img->bluecmap =
- (uint16_t *)_TIFFmallocExt(tif, sizeof(uint16_t) * n_color);
- if (!img->redcmap || !img->greencmap || !img->bluecmap)
- {
- snprintf(emsg, EMSG_BUF_SIZE,
- "Out of memory for colormap copy");
- goto fail_return;
- }
-
- _TIFFmemcpy(img->redcmap, red_orig, n_color * 2);
- _TIFFmemcpy(img->greencmap, green_orig, n_color * 2);
- _TIFFmemcpy(img->bluecmap, blue_orig, n_color * 2);
-
- /* fall through... */
- case PHOTOMETRIC_MINISWHITE:
- case PHOTOMETRIC_MINISBLACK:
- if (planarconfig == PLANARCONFIG_CONTIG &&
- img->samplesperpixel != 1 && img->bitspersample < 8)
- {
- snprintf(
- emsg, EMSG_BUF_SIZE,
- "Sorry, can not handle contiguous data with %s=%" PRIu16
- ", "
- "and %s=%" PRIu16 " and Bits/Sample=%" PRIu16,
- photoTag, img->photometric, "Samples/pixel",
- img->samplesperpixel, img->bitspersample);
- goto fail_return;
- }
- break;
- case PHOTOMETRIC_YCBCR:
- /* It would probably be nice to have a reality check here. */
- if (planarconfig == PLANARCONFIG_CONTIG)
- /* can rely on libjpeg to convert to RGB */
- /* XXX should restore current state on exit */
- switch (compress)
- {
- case COMPRESSION_JPEG:
- /*
- * TODO: when complete tests verify complete
- * desubsampling and YCbCr handling, remove use of
- * TIFFTAG_JPEGCOLORMODE in favor of tif_getimage.c
- * native handling
- */
- TIFFSetField(tif, TIFFTAG_JPEGCOLORMODE,
- JPEGCOLORMODE_RGB);
- img->photometric = PHOTOMETRIC_RGB;
- break;
- default:
- /* do nothing */;
- break;
- }
- /*
- * TODO: if at all meaningful and useful, make more complete
- * support check here, or better still, refactor to let supporting
- * code decide whether there is support and what meaningful
- * error to return
- */
- break;
- case PHOTOMETRIC_RGB:
- if (colorchannels < 3)
- {
- snprintf(emsg, EMSG_BUF_SIZE,
- "Sorry, can not handle RGB image with %s=%d",
- "Color channels", colorchannels);
- goto fail_return;
- }
- break;
- case PHOTOMETRIC_SEPARATED:
- {
- uint16_t inkset;
- TIFFGetFieldDefaulted(tif, TIFFTAG_INKSET, &inkset);
- if (inkset != INKSET_CMYK)
- {
- snprintf(
- emsg, EMSG_BUF_SIZE,
- "Sorry, can not handle separated image with %s=%" PRIu16,
- "InkSet", inkset);
- goto fail_return;
- }
- if (img->samplesperpixel < 4)
- {
- snprintf(
- emsg, EMSG_BUF_SIZE,
- "Sorry, can not handle separated image with %s=%" PRIu16,
- "Samples/pixel", img->samplesperpixel);
- goto fail_return;
- }
- }
- break;
- case PHOTOMETRIC_LOGL:
- if (compress != COMPRESSION_SGILOG)
- {
- snprintf(emsg, EMSG_BUF_SIZE,
- "Sorry, LogL data must have %s=%d", "Compression",
- COMPRESSION_SGILOG);
- goto fail_return;
- }
- TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_8BIT);
- img->photometric = PHOTOMETRIC_MINISBLACK; /* little white lie */
- img->bitspersample = 8;
- break;
- case PHOTOMETRIC_LOGLUV:
- if (compress != COMPRESSION_SGILOG &&
- compress != COMPRESSION_SGILOG24)
- {
- snprintf(emsg, EMSG_BUF_SIZE,
- "Sorry, LogLuv data must have %s=%d or %d",
- "Compression", COMPRESSION_SGILOG,
- COMPRESSION_SGILOG24);
- goto fail_return;
- }
- if (planarconfig != PLANARCONFIG_CONTIG)
- {
- snprintf(emsg, EMSG_BUF_SIZE,
- "Sorry, can not handle LogLuv images with %s=%" PRIu16,
- "Planarconfiguration", planarconfig);
- return (0);
- }
- TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_8BIT);
- img->photometric = PHOTOMETRIC_RGB; /* little white lie */
- img->bitspersample = 8;
- break;
- case PHOTOMETRIC_CIELAB:
- break;
- default:
- snprintf(emsg, EMSG_BUF_SIZE,
- "Sorry, can not handle image with %s=%" PRIu16, photoTag,
- img->photometric);
- goto fail_return;
- }
- TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &img->width);
- TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &img->height);
- TIFFGetFieldDefaulted(tif, TIFFTAG_ORIENTATION, &img->orientation);
- img->isContig =
- !(planarconfig == PLANARCONFIG_SEPARATE && img->samplesperpixel > 1);
- if (img->isContig)
- {
- if (!PickContigCase(img))
- {
- snprintf(emsg, EMSG_BUF_SIZE, "Sorry, can not handle image");
- goto fail_return;
- }
- }
- else
- {
- if (!PickSeparateCase(img))
- {
- snprintf(emsg, EMSG_BUF_SIZE, "Sorry, can not handle image");
- goto fail_return;
- }
- }
- return 1;
-
-fail_return:
- TIFFRGBAImageEnd(img);
- return 0;
-}
-
-int TIFFRGBAImageGet(TIFFRGBAImage *img, uint32_t *raster, uint32_t w,
- uint32_t h)
-{
- if (img->get == NULL)
- {
- TIFFErrorExtR(img->tif, TIFFFileName(img->tif),
- "No \"get\" routine setup");
- return (0);
- }
- if (img->put.any == NULL)
- {
- TIFFErrorExtR(
- img->tif, TIFFFileName(img->tif),
- "No \"put\" routine setupl; probably can not handle image format");
- return (0);
- }
- return (*img->get)(img, raster, w, h);
-}
-
-/*
- * Read the specified image into an ABGR-format rastertaking in account
- * specified orientation.
- */
-int TIFFReadRGBAImageOriented(TIFF *tif, uint32_t rwidth, uint32_t rheight,
- uint32_t *raster, int orientation, int stop)
-{
- char emsg[EMSG_BUF_SIZE] = "";
- TIFFRGBAImage img;
- int ok;
-
- if (TIFFRGBAImageOK(tif, emsg) && TIFFRGBAImageBegin(&img, tif, stop, emsg))
- {
- img.req_orientation = (uint16_t)orientation;
- /* XXX verify rwidth and rheight against width and height */
- ok = TIFFRGBAImageGet(&img, raster + (rheight - img.height) * rwidth,
- rwidth, img.height);
- TIFFRGBAImageEnd(&img);
- }
- else
- {
- TIFFErrorExtR(tif, TIFFFileName(tif), "%s", emsg);
- ok = 0;
- }
- return (ok);
-}
-
-/*
- * Read the specified image into an ABGR-format raster. Use bottom left
- * origin for raster by default.
- */
-int TIFFReadRGBAImage(TIFF *tif, uint32_t rwidth, uint32_t rheight,
- uint32_t *raster, int stop)
-{
- return TIFFReadRGBAImageOriented(tif, rwidth, rheight, raster,
- ORIENTATION_BOTLEFT, stop);
-}
-
-static int setorientation(TIFFRGBAImage *img)
-{
- switch (img->orientation)
- {
- case ORIENTATION_TOPLEFT:
- case ORIENTATION_LEFTTOP:
- if (img->req_orientation == ORIENTATION_TOPRIGHT ||
- img->req_orientation == ORIENTATION_RIGHTTOP)
- return FLIP_HORIZONTALLY;
- else if (img->req_orientation == ORIENTATION_BOTRIGHT ||
- img->req_orientation == ORIENTATION_RIGHTBOT)
- return FLIP_HORIZONTALLY | FLIP_VERTICALLY;
- else if (img->req_orientation == ORIENTATION_BOTLEFT ||
- img->req_orientation == ORIENTATION_LEFTBOT)
- return FLIP_VERTICALLY;
- else
- return 0;
- case ORIENTATION_TOPRIGHT:
- case ORIENTATION_RIGHTTOP:
- if (img->req_orientation == ORIENTATION_TOPLEFT ||
- img->req_orientation == ORIENTATION_LEFTTOP)
- return FLIP_HORIZONTALLY;
- else if (img->req_orientation == ORIENTATION_BOTRIGHT ||
- img->req_orientation == ORIENTATION_RIGHTBOT)
- return FLIP_VERTICALLY;
- else if (img->req_orientation == ORIENTATION_BOTLEFT ||
- img->req_orientation == ORIENTATION_LEFTBOT)
- return FLIP_HORIZONTALLY | FLIP_VERTICALLY;
- else
- return 0;
- case ORIENTATION_BOTRIGHT:
- case ORIENTATION_RIGHTBOT:
- if (img->req_orientation == ORIENTATION_TOPLEFT ||
- img->req_orientation == ORIENTATION_LEFTTOP)
- return FLIP_HORIZONTALLY | FLIP_VERTICALLY;
- else if (img->req_orientation == ORIENTATION_TOPRIGHT ||
- img->req_orientation == ORIENTATION_RIGHTTOP)
- return FLIP_VERTICALLY;
- else if (img->req_orientation == ORIENTATION_BOTLEFT ||
- img->req_orientation == ORIENTATION_LEFTBOT)
- return FLIP_HORIZONTALLY;
- else
- return 0;
- case ORIENTATION_BOTLEFT:
- case ORIENTATION_LEFTBOT:
- if (img->req_orientation == ORIENTATION_TOPLEFT ||
- img->req_orientation == ORIENTATION_LEFTTOP)
- return FLIP_VERTICALLY;
- else if (img->req_orientation == ORIENTATION_TOPRIGHT ||
- img->req_orientation == ORIENTATION_RIGHTTOP)
- return FLIP_HORIZONTALLY | FLIP_VERTICALLY;
- else if (img->req_orientation == ORIENTATION_BOTRIGHT ||
- img->req_orientation == ORIENTATION_RIGHTBOT)
- return FLIP_HORIZONTALLY;
- else
- return 0;
- default: /* NOTREACHED */
- return 0;
- }
-}
-
-/*
- * Get an tile-organized image that has
- * PlanarConfiguration contiguous if SamplesPerPixel > 1
- * or
- * SamplesPerPixel == 1
- */
-static int gtTileContig(TIFFRGBAImage *img, uint32_t *raster, uint32_t w,
- uint32_t h)
-{
- TIFF *tif = img->tif;
- tileContigRoutine put = img->put.contig;
- uint32_t col, row, y, rowstoread;
- tmsize_t pos;
- uint32_t tw, th;
- unsigned char *buf = NULL;
- int32_t fromskew, toskew;
- uint32_t nrow;
- int ret = 1, flip;
- uint32_t this_tw, tocol;
- int32_t this_toskew, leftmost_toskew;
- int32_t leftmost_fromskew;
- uint32_t leftmost_tw;
- tmsize_t bufsize;
-
- bufsize = TIFFTileSize(tif);
- if (bufsize == 0)
- {
- TIFFErrorExtR(tif, TIFFFileName(tif), "%s", "No space for tile buffer");
- return (0);
- }
-
- TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw);
- TIFFGetField(tif, TIFFTAG_TILELENGTH, &th);
-
- flip = setorientation(img);
- if (flip & FLIP_VERTICALLY)
- {
- if ((tw + w) > INT_MAX)
- {
- TIFFErrorExtR(tif, TIFFFileName(tif), "%s",
- "unsupported tile size (too wide)");
- return (0);
- }
- y = h - 1;
- toskew = -(int32_t)(tw + w);
- }
- else
- {
- if (tw > (INT_MAX + w))
- {
- TIFFErrorExtR(tif, TIFFFileName(tif), "%s",
- "unsupported tile size (too wide)");
- return (0);
- }
- y = 0;
- toskew = -(int32_t)(tw - w);
- }
-
- if (tw == 0 || th == 0)
- {
- TIFFErrorExtR(tif, TIFFFileName(tif), "tile width or height is zero");
- return (0);
- }
-
- /*
- * Leftmost tile is clipped on left side if col_offset > 0.
- */
- leftmost_fromskew = img->col_offset % tw;
- leftmost_tw = tw - leftmost_fromskew;
- leftmost_toskew = toskew + leftmost_fromskew;
- for (row = 0; ret != 0 && row < h; row += nrow)
- {
- rowstoread = th - (row + img->row_offset) % th;
- nrow = (row + rowstoread > h ? h - row : rowstoread);
- fromskew = leftmost_fromskew;
- this_tw = leftmost_tw;
- this_toskew = leftmost_toskew;
- tocol = 0;
- col = img->col_offset;
- while (tocol < w)
- {
- if (_TIFFReadTileAndAllocBuffer(tif, (void **)&buf, bufsize, col,
- row + img->row_offset, 0,
- 0) == (tmsize_t)(-1) &&
- (buf == NULL || img->stoponerr))
- {
- ret = 0;
- break;
- }
- pos = ((row + img->row_offset) % th) * TIFFTileRowSize(tif) +
- ((tmsize_t)fromskew * img->samplesperpixel);
- if (tocol + this_tw > w)
- {
- /*
- * Rightmost tile is clipped on right side.
- */
- fromskew = tw - (w - tocol);
- this_tw = tw - fromskew;
- this_toskew = toskew + fromskew;
- }
- tmsize_t roffset = (tmsize_t)y * w + tocol;
- (*put)(img, raster + roffset, tocol, y, this_tw, nrow, fromskew,
- this_toskew, buf + pos);
- tocol += this_tw;
- col += this_tw;
- /*
- * After the leftmost tile, tiles are no longer clipped on left
- * side.
- */
- fromskew = 0;
- this_tw = tw;
- this_toskew = toskew;
- }
-
- y += ((flip & FLIP_VERTICALLY) ? -(int32_t)nrow : (int32_t)nrow);
- }
- _TIFFfreeExt(img->tif, buf);
-
- if (flip & FLIP_HORIZONTALLY)
- {
- uint32_t line;
-
- for (line = 0; line < h; line++)
- {
- uint32_t *left = raster + (line * w);
- uint32_t *right = left + w - 1;
-
- while (left < right)
- {
- uint32_t temp = *left;
- *left = *right;
- *right = temp;
- left++;
- right--;
- }
- }
- }
-
- return (ret);
-}
-
-/*
- * Get an tile-organized image that has
- * SamplesPerPixel > 1
- * PlanarConfiguration separated
- * We assume that all such images are RGB.
- */
-static int gtTileSeparate(TIFFRGBAImage *img, uint32_t *raster, uint32_t w,
- uint32_t h)
-{
- TIFF *tif = img->tif;
- tileSeparateRoutine put = img->put.separate;
- uint32_t col, row, y, rowstoread;
- tmsize_t pos;
- uint32_t tw, th;
- unsigned char *buf = NULL;
- unsigned char *p0 = NULL;
- unsigned char *p1 = NULL;
- unsigned char *p2 = NULL;
- unsigned char *pa = NULL;
- tmsize_t tilesize;
- tmsize_t bufsize;
- int32_t fromskew, toskew;
- int alpha = img->alpha;
- uint32_t nrow;
- int ret = 1, flip;
- uint16_t colorchannels;
- uint32_t this_tw, tocol;
- int32_t this_toskew, leftmost_toskew;
- int32_t leftmost_fromskew;
- uint32_t leftmost_tw;
-
- tilesize = TIFFTileSize(tif);
- bufsize =
- _TIFFMultiplySSize(tif, alpha ? 4 : 3, tilesize, "gtTileSeparate");
- if (bufsize == 0)
- {
- return (0);
- }
-
- TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw);
- TIFFGetField(tif, TIFFTAG_TILELENGTH, &th);
-
- flip = setorientation(img);
- if (flip & FLIP_VERTICALLY)
- {
- if ((tw + w) > INT_MAX)
- {
- TIFFErrorExtR(tif, TIFFFileName(tif), "%s",
- "unsupported tile size (too wide)");
- return (0);
- }
- y = h - 1;
- toskew = -(int32_t)(tw + w);
- }
- else
- {
- if (tw > (INT_MAX + w))
- {
- TIFFErrorExtR(tif, TIFFFileName(tif), "%s",
- "unsupported tile size (too wide)");
- return (0);
- }
- y = 0;
- toskew = -(int32_t)(tw - w);
- }
-
- switch (img->photometric)
- {
- case PHOTOMETRIC_MINISWHITE:
- case PHOTOMETRIC_MINISBLACK:
- case PHOTOMETRIC_PALETTE:
- colorchannels = 1;
- break;
-
- default:
- colorchannels = 3;
- break;
- }
-
- if (tw == 0 || th == 0)
- {
- TIFFErrorExtR(tif, TIFFFileName(tif), "tile width or height is zero");
- return (0);
- }
-
- /*
- * Leftmost tile is clipped on left side if col_offset > 0.
- */
- leftmost_fromskew = img->col_offset % tw;
- leftmost_tw = tw - leftmost_fromskew;
- leftmost_toskew = toskew + leftmost_fromskew;
- for (row = 0; ret != 0 && row < h; row += nrow)
- {
- rowstoread = th - (row + img->row_offset) % th;
- nrow = (row + rowstoread > h ? h - row : rowstoread);
- fromskew = leftmost_fromskew;
- this_tw = leftmost_tw;
- this_toskew = leftmost_toskew;
- tocol = 0;
- col = img->col_offset;
- while (tocol < w)
- {
- if (buf == NULL)
- {
- if (_TIFFReadTileAndAllocBuffer(tif, (void **)&buf, bufsize,
- col, row + img->row_offset, 0,
- 0) == (tmsize_t)(-1) &&
- (buf == NULL || img->stoponerr))
- {
- ret = 0;
- break;
- }
- p0 = buf;
- if (colorchannels == 1)
- {
- p2 = p1 = p0;
- pa = (alpha ? (p0 + 3 * tilesize) : NULL);
- }
- else
- {
- p1 = p0 + tilesize;
- p2 = p1 + tilesize;
- pa = (alpha ? (p2 + tilesize) : NULL);
- }
- }
- else if (TIFFReadTile(tif, p0, col, row + img->row_offset, 0, 0) ==
- (tmsize_t)(-1) &&
- img->stoponerr)
- {
- ret = 0;
- break;
- }
- if (colorchannels > 1 &&
- TIFFReadTile(tif, p1, col, row + img->row_offset, 0, 1) ==
- (tmsize_t)(-1) &&
- img->stoponerr)
- {
- ret = 0;
- break;
- }
- if (colorchannels > 1 &&
- TIFFReadTile(tif, p2, col, row + img->row_offset, 0, 2) ==
- (tmsize_t)(-1) &&
- img->stoponerr)
- {
- ret = 0;
- break;
- }
- if (alpha &&
- TIFFReadTile(tif, pa, col, row + img->row_offset, 0,
- colorchannels) == (tmsize_t)(-1) &&
- img->stoponerr)
- {
- ret = 0;
- break;
- }
-
- pos = ((row + img->row_offset) % th) * TIFFTileRowSize(tif) +
- ((tmsize_t)fromskew * img->samplesperpixel);
- if (tocol + this_tw > w)
- {
- /*
- * Rightmost tile is clipped on right side.
- */
- fromskew = tw - (w - tocol);
- this_tw = tw - fromskew;
- this_toskew = toskew + fromskew;
- }
- tmsize_t roffset = (tmsize_t)y * w + tocol;
- (*put)(img, raster + roffset, tocol, y, this_tw, nrow, fromskew,
- this_toskew, p0 + pos, p1 + pos, p2 + pos,
- (alpha ? (pa + pos) : NULL));
- tocol += this_tw;
- col += this_tw;
- /*
- * After the leftmost tile, tiles are no longer clipped on left
- * side.
- */
- fromskew = 0;
- this_tw = tw;
- this_toskew = toskew;
- }
-
- y += ((flip & FLIP_VERTICALLY) ? -(int32_t)nrow : (int32_t)nrow);
- }
-
- if (flip & FLIP_HORIZONTALLY)
- {
- uint32_t line;
-
- for (line = 0; line < h; line++)
- {
- uint32_t *left = raster + (line * w);
- uint32_t *right = left + w - 1;
-
- while (left < right)
- {
- uint32_t temp = *left;
- *left = *right;
- *right = temp;
- left++;
- right--;
- }
- }
- }
-
- _TIFFfreeExt(img->tif, buf);
- return (ret);
-}
-
-/*
- * Get a strip-organized image that has
- * PlanarConfiguration contiguous if SamplesPerPixel > 1
- * or
- * SamplesPerPixel == 1
- */
-static int gtStripContig(TIFFRGBAImage *img, uint32_t *raster, uint32_t w,
- uint32_t h)
-{
- TIFF *tif = img->tif;
- tileContigRoutine put = img->put.contig;
- uint32_t row, y, nrow, nrowsub, rowstoread;
- tmsize_t pos;
- unsigned char *buf = NULL;
- uint32_t rowsperstrip;
- uint16_t subsamplinghor, subsamplingver;
- uint32_t imagewidth = img->width;
- tmsize_t scanline;
- int32_t fromskew, toskew;
- int ret = 1, flip;
- tmsize_t maxstripsize;
-
- TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRSUBSAMPLING, &subsamplinghor,
- &subsamplingver);
- if (subsamplingver == 0)
- {
- TIFFErrorExtR(tif, TIFFFileName(tif),
- "Invalid vertical YCbCr subsampling");
- return (0);
- }
-
- maxstripsize = TIFFStripSize(tif);
-
- flip = setorientation(img);
- if (flip & FLIP_VERTICALLY)
- {
- if (w > INT_MAX)
- {
- TIFFErrorExtR(tif, TIFFFileName(tif), "Width overflow");
- return (0);
- }
- y = h - 1;
- toskew = -(int32_t)(w + w);
- }
- else
- {
- y = 0;
- toskew = -(int32_t)(w - w);
- }
-
- TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);
- if (rowsperstrip == 0)
- {
- TIFFErrorExtR(tif, TIFFFileName(tif), "rowsperstrip is zero");
- return (0);
- }
-
- scanline = TIFFScanlineSize(tif);
- fromskew = (w < imagewidth ? imagewidth - w : 0);
- for (row = 0; row < h; row += nrow)
- {
- uint32_t temp;
- rowstoread = rowsperstrip - (row + img->row_offset) % rowsperstrip;
- nrow = (row + rowstoread > h ? h - row : rowstoread);
- nrowsub = nrow;
- if ((nrowsub % subsamplingver) != 0)
- nrowsub += subsamplingver - nrowsub % subsamplingver;
- temp = (row + img->row_offset) % rowsperstrip + nrowsub;
- if (scanline > 0 && temp > (size_t)(TIFF_TMSIZE_T_MAX / scanline))
- {
- TIFFErrorExtR(tif, TIFFFileName(tif),
- "Integer overflow in gtStripContig");
- return 0;
- }
- if (_TIFFReadEncodedStripAndAllocBuffer(
- tif, TIFFComputeStrip(tif, row + img->row_offset, 0),
- (void **)(&buf), maxstripsize,
- temp * scanline) == (tmsize_t)(-1) &&
- (buf == NULL || img->stoponerr))
- {
- ret = 0;
- break;
- }
-
- pos = ((row + img->row_offset) % rowsperstrip) * scanline +
- ((tmsize_t)img->col_offset * img->samplesperpixel);
- tmsize_t roffset = (tmsize_t)y * w;
- (*put)(img, raster + roffset, 0, y, w, nrow, fromskew, toskew,
- buf + pos);
- y += ((flip & FLIP_VERTICALLY) ? -(int32_t)nrow : (int32_t)nrow);
- }
-
- if (flip & FLIP_HORIZONTALLY)
- {
- uint32_t line;
-
- for (line = 0; line < h; line++)
- {
- uint32_t *left = raster + (line * w);
- uint32_t *right = left + w - 1;
-
- while (left < right)
- {
- uint32_t temp = *left;
- *left = *right;
- *right = temp;
- left++;
- right--;
- }
- }
- }
-
- _TIFFfreeExt(img->tif, buf);
- return (ret);
-}
-
-/*
- * Get a strip-organized image with
- * SamplesPerPixel > 1
- * PlanarConfiguration separated
- * We assume that all such images are RGB.
- */
-static int gtStripSeparate(TIFFRGBAImage *img, uint32_t *raster, uint32_t w,
- uint32_t h)
-{
- TIFF *tif = img->tif;
- tileSeparateRoutine put = img->put.separate;
- unsigned char *buf = NULL;
- unsigned char *p0 = NULL, *p1 = NULL, *p2 = NULL, *pa = NULL;
- uint32_t row, y, nrow, rowstoread;
- tmsize_t pos;
- tmsize_t scanline;
- uint32_t rowsperstrip, offset_row;
- uint32_t imagewidth = img->width;
- tmsize_t stripsize;
- tmsize_t bufsize;
- int32_t fromskew, toskew;
- int alpha = img->alpha;
- int ret = 1, flip;
- uint16_t colorchannels;
-
- stripsize = TIFFStripSize(tif);
- bufsize =
- _TIFFMultiplySSize(tif, alpha ? 4 : 3, stripsize, "gtStripSeparate");
- if (bufsize == 0)
- {
- return (0);
- }
-
- flip = setorientation(img);
- if (flip & FLIP_VERTICALLY)
- {
- if (w > INT_MAX)
- {
- TIFFErrorExtR(tif, TIFFFileName(tif), "Width overflow");
- return (0);
- }
- y = h - 1;
- toskew = -(int32_t)(w + w);
- }
- else
- {
- y = 0;
- toskew = -(int32_t)(w - w);
- }
-
- switch (img->photometric)
- {
- case PHOTOMETRIC_MINISWHITE:
- case PHOTOMETRIC_MINISBLACK:
- case PHOTOMETRIC_PALETTE:
- colorchannels = 1;
- break;
-
- default:
- colorchannels = 3;
- break;
- }
-
- TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);
- if (rowsperstrip == 0)
- {
- TIFFErrorExtR(tif, TIFFFileName(tif), "rowsperstrip is zero");
- return (0);
- }
-
- scanline = TIFFScanlineSize(tif);
- fromskew = (w < imagewidth ? imagewidth - w : 0);
- for (row = 0; row < h; row += nrow)
- {
- uint32_t temp;
- rowstoread = rowsperstrip - (row + img->row_offset) % rowsperstrip;
- nrow = (row + rowstoread > h ? h - row : rowstoread);
- offset_row = row + img->row_offset;
- temp = (row + img->row_offset) % rowsperstrip + nrow;
- if (scanline > 0 && temp > (size_t)(TIFF_TMSIZE_T_MAX / scanline))
- {
- TIFFErrorExtR(tif, TIFFFileName(tif),
- "Integer overflow in gtStripSeparate");
- return 0;
- }
- if (buf == NULL)
- {
- if (_TIFFReadEncodedStripAndAllocBuffer(
- tif, TIFFComputeStrip(tif, offset_row, 0), (void **)&buf,
- bufsize, temp * scanline) == (tmsize_t)(-1) &&
- (buf == NULL || img->stoponerr))
- {
- ret = 0;
- break;
- }
- p0 = buf;
- if (colorchannels == 1)
- {
- p2 = p1 = p0;
- pa = (alpha ? (p0 + 3 * stripsize) : NULL);
- }
- else
- {
- p1 = p0 + stripsize;
- p2 = p1 + stripsize;
- pa = (alpha ? (p2 + stripsize) : NULL);
- }
- }
- else if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 0),
- p0, temp * scanline) == (tmsize_t)(-1) &&
- img->stoponerr)
- {
- ret = 0;
- break;
- }
- if (colorchannels > 1 &&
- TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 1), p1,
- temp * scanline) == (tmsize_t)(-1) &&
- img->stoponerr)
- {
- ret = 0;
- break;
- }
- if (colorchannels > 1 &&
- TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 2), p2,
- temp * scanline) == (tmsize_t)(-1) &&
- img->stoponerr)
- {
- ret = 0;
- break;
- }
- if (alpha)
- {
- if (TIFFReadEncodedStrip(
- tif, TIFFComputeStrip(tif, offset_row, colorchannels), pa,
- temp * scanline) == (tmsize_t)(-1) &&
- img->stoponerr)
- {
- ret = 0;
- break;
- }
- }
-
- pos = ((row + img->row_offset) % rowsperstrip) * scanline +
- ((tmsize_t)img->col_offset * img->samplesperpixel);
- tmsize_t roffset = (tmsize_t)y * w;
- (*put)(img, raster + roffset, 0, y, w, nrow, fromskew, toskew, p0 + pos,
- p1 + pos, p2 + pos, (alpha ? (pa + pos) : NULL));
- y += ((flip & FLIP_VERTICALLY) ? -(int32_t)nrow : (int32_t)nrow);
- }
-
- if (flip & FLIP_HORIZONTALLY)
- {
- uint32_t line;
-
- for (line = 0; line < h; line++)
- {
- uint32_t *left = raster + (line * w);
- uint32_t *right = left + w - 1;
-
- while (left < right)
- {
- uint32_t temp = *left;
- *left = *right;
- *right = temp;
- left++;
- right--;
- }
- }
- }
-
- _TIFFfreeExt(img->tif, buf);
- return (ret);
-}
-
-/*
- * The following routines move decoded data returned
- * from the TIFF library into rasters filled with packed
- * ABGR pixels (i.e. suitable for passing to lrecwrite.)
- *
- * The routines have been created according to the most
- * important cases and optimized. PickContigCase and
- * PickSeparateCase analyze the parameters and select
- * the appropriate "get" and "put" routine to use.
- */
-#define REPEAT8(op) \
- REPEAT4(op); \
- REPEAT4(op)
-#define REPEAT4(op) \
- REPEAT2(op); \
- REPEAT2(op)
-#define REPEAT2(op) \
- op; \
- op
-#define CASE8(x, op) \
- switch (x) \
- { \
- case 7: \
- op; /*-fallthrough*/ \
- case 6: \
- op; /*-fallthrough*/ \
- case 5: \
- op; /*-fallthrough*/ \
- case 4: \
- op; /*-fallthrough*/ \
- case 3: \
- op; /*-fallthrough*/ \
- case 2: \
- op; /*-fallthrough*/ \
- case 1: \
- op; \
- }
-#define CASE4(x, op) \
- switch (x) \
- { \
- case 3: \
- op; /*-fallthrough*/ \
- case 2: \
- op; /*-fallthrough*/ \
- case 1: \
- op; \
- }
-#define NOP
-
-#define UNROLL8(w, op1, op2) \
- { \
- uint32_t _x; \
- for (_x = w; _x >= 8; _x -= 8) \
- { \
- op1; \
- REPEAT8(op2); \
- } \
- if (_x > 0) \
- { \
- op1; \
- CASE8(_x, op2); \
- } \
- }
-#define UNROLL4(w, op1, op2) \
- { \
- uint32_t _x; \
- for (_x = w; _x >= 4; _x -= 4) \
- { \
- op1; \
- REPEAT4(op2); \
- } \
- if (_x > 0) \
- { \
- op1; \
- CASE4(_x, op2); \
- } \
- }
-#define UNROLL2(w, op1, op2) \
- { \
- uint32_t _x; \
- for (_x = w; _x >= 2; _x -= 2) \
- { \
- op1; \
- REPEAT2(op2); \
- } \
- if (_x) \
- { \
- op1; \
- op2; \
- } \
- }
-
-#define SKEW(r, g, b, skew) \
- { \
- r += skew; \
- g += skew; \
- b += skew; \
- }
-#define SKEW4(r, g, b, a, skew) \
- { \
- r += skew; \
- g += skew; \
- b += skew; \
- a += skew; \
- }
-
-#define A1 (((uint32_t)0xffL) << 24)
-#define PACK(r, g, b) \
- ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1)
-#define PACK4(r, g, b, a) \
- ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | \
- ((uint32_t)(a) << 24))
-#define W2B(v) (((v) >> 8) & 0xff)
-/* TODO: PACKW should have be made redundant in favor of Bitdepth16To8 LUT */
-#define PACKW(r, g, b) \
- ((uint32_t)W2B(r) | ((uint32_t)W2B(g) << 8) | ((uint32_t)W2B(b) << 16) | A1)
-#define PACKW4(r, g, b, a) \
- ((uint32_t)W2B(r) | ((uint32_t)W2B(g) << 8) | ((uint32_t)W2B(b) << 16) | \
- ((uint32_t)W2B(a) << 24))
-
-#define DECLAREContigPutFunc(name) \
- static void name(TIFFRGBAImage *img, uint32_t *cp, uint32_t x, uint32_t y, \
- uint32_t w, uint32_t h, int32_t fromskew, int32_t toskew, \
- unsigned char *pp)
-
-/*
- * 8-bit palette => colormap/RGB
- */
-DECLAREContigPutFunc(put8bitcmaptile)
-{
- uint32_t **PALmap = img->PALmap;
- int samplesperpixel = img->samplesperpixel;
-
- (void)y;
- for (; h > 0; --h)
- {
- for (x = w; x > 0; --x)
- {
- *cp++ = PALmap[*pp][0];
- pp += samplesperpixel;
- }
- cp += toskew;
- pp += fromskew;
- }
-}
-
-/*
- * 4-bit palette => colormap/RGB
- */
-DECLAREContigPutFunc(put4bitcmaptile)
-{
- uint32_t **PALmap = img->PALmap;
-
- (void)x;
- (void)y;
- fromskew /= 2;
- for (; h > 0; --h)
- {
- uint32_t *bw;
- UNROLL2(w, bw = PALmap[*pp++], *cp++ = *bw++);
- cp += toskew;
- pp += fromskew;
- }
-}
-
-/*
- * 2-bit palette => colormap/RGB
- */
-DECLAREContigPutFunc(put2bitcmaptile)
-{
- uint32_t **PALmap = img->PALmap;
-
- (void)x;
- (void)y;
- fromskew /= 4;
- for (; h > 0; --h)
- {
- uint32_t *bw;
- UNROLL4(w, bw = PALmap[*pp++], *cp++ = *bw++);
- cp += toskew;
- pp += fromskew;
- }
-}
-
-/*
- * 1-bit palette => colormap/RGB
- */
-DECLAREContigPutFunc(put1bitcmaptile)
-{
- uint32_t **PALmap = img->PALmap;
-
- (void)x;
- (void)y;
- fromskew /= 8;
- for (; h > 0; --h)
- {
- uint32_t *bw;
- UNROLL8(w, bw = PALmap[*pp++], *cp++ = *bw++);
- cp += toskew;
- pp += fromskew;
- }
-}
-
-/*
- * 8-bit greyscale => colormap/RGB
- */
-DECLAREContigPutFunc(putgreytile)
-{
- int samplesperpixel = img->samplesperpixel;
- uint32_t **BWmap = img->BWmap;
-
- (void)y;
- for (; h > 0; --h)
- {
- for (x = w; x > 0; --x)
- {
- *cp++ = BWmap[*pp][0];
- pp += samplesperpixel;
- }
- cp += toskew;
- pp += fromskew;
- }
-}
-
-/*
- * 8-bit greyscale with associated alpha => colormap/RGBA
- */
-DECLAREContigPutFunc(putagreytile)
-{
- int samplesperpixel = img->samplesperpixel;
- uint32_t **BWmap = img->BWmap;
-
- (void)y;
- for (; h > 0; --h)
- {
- for (x = w; x > 0; --x)
- {
- *cp++ = BWmap[*pp][0] & ((uint32_t) * (pp + 1) << 24 | ~A1);
- pp += samplesperpixel;
- }
- cp += toskew;
- pp += fromskew;
- }
-}
-
-/*
- * 16-bit greyscale => colormap/RGB
- */
-DECLAREContigPutFunc(put16bitbwtile)
-{
- int samplesperpixel = img->samplesperpixel;
- uint32_t **BWmap = img->BWmap;
-
- (void)y;
- for (; h > 0; --h)
- {
- uint16_t *wp = (uint16_t *)pp;
-
- for (x = w; x > 0; --x)
- {
- /* use high order byte of 16bit value */
-
- *cp++ = BWmap[*wp >> 8][0];
- pp += 2 * samplesperpixel;
- wp += samplesperpixel;
- }
- cp += toskew;
- pp += fromskew;
- }
-}
-
-/*
- * 1-bit bilevel => colormap/RGB
- */
-DECLAREContigPutFunc(put1bitbwtile)
-{
- uint32_t **BWmap = img->BWmap;
-
- (void)x;
- (void)y;
- fromskew /= 8;
- for (; h > 0; --h)
- {
- uint32_t *bw;
- UNROLL8(w, bw = BWmap[*pp++], *cp++ = *bw++);
- cp += toskew;
- pp += fromskew;
- }
-}
-
-/*
- * 2-bit greyscale => colormap/RGB
- */
-DECLAREContigPutFunc(put2bitbwtile)
-{
- uint32_t **BWmap = img->BWmap;
-
- (void)x;
- (void)y;
- fromskew /= 4;
- for (; h > 0; --h)
- {
- uint32_t *bw;
- UNROLL4(w, bw = BWmap[*pp++], *cp++ = *bw++);
- cp += toskew;
- pp += fromskew;
- }
-}
-
-/*
- * 4-bit greyscale => colormap/RGB
- */
-DECLAREContigPutFunc(put4bitbwtile)
-{
- uint32_t **BWmap = img->BWmap;
-
- (void)x;
- (void)y;
- fromskew /= 2;
- for (; h > 0; --h)
- {
- uint32_t *bw;
- UNROLL2(w, bw = BWmap[*pp++], *cp++ = *bw++);
- cp += toskew;
- pp += fromskew;
- }
-}
-
-/*
- * 8-bit packed samples, no Map => RGB
- */
-DECLAREContigPutFunc(putRGBcontig8bittile)
-{
- int samplesperpixel = img->samplesperpixel;
-
- (void)x;
- (void)y;
- fromskew *= samplesperpixel;
- for (; h > 0; --h)
- {
- UNROLL8(w, NOP, *cp++ = PACK(pp[0], pp[1], pp[2]);
- pp += samplesperpixel);
- cp += toskew;
- pp += fromskew;
- }
-}
-
-/*
- * 8-bit packed samples => RGBA w/ associated alpha
- * (known to have Map == NULL)
- */
-DECLAREContigPutFunc(putRGBAAcontig8bittile)
-{
- int samplesperpixel = img->samplesperpixel;
-
- (void)x;
- (void)y;
- fromskew *= samplesperpixel;
- for (; h > 0; --h)
- {
- UNROLL8(w, NOP, *cp++ = PACK4(pp[0], pp[1], pp[2], pp[3]);
- pp += samplesperpixel);
- cp += toskew;
- pp += fromskew;
- }
-}
-
-/*
- * 8-bit packed samples => RGBA w/ unassociated alpha
- * (known to have Map == NULL)
- */
-DECLAREContigPutFunc(putRGBUAcontig8bittile)
-{
- int samplesperpixel = img->samplesperpixel;
- (void)y;
- fromskew *= samplesperpixel;
- for (; h > 0; --h)
- {
- uint32_t r, g, b, a;
- uint8_t *m;
- for (x = w; x > 0; --x)
- {
- a = pp[3];
- m = img->UaToAa + ((size_t)a << 8);
- r = m[pp[0]];
- g = m[pp[1]];
- b = m[pp[2]];
- *cp++ = PACK4(r, g, b, a);
- pp += samplesperpixel;
- }
- cp += toskew;
- pp += fromskew;
- }
-}
-
-/*
- * 16-bit packed samples => RGB
- */
-DECLAREContigPutFunc(putRGBcontig16bittile)
-{
- int samplesperpixel = img->samplesperpixel;
- uint16_t *wp = (uint16_t *)pp;
- (void)y;
- fromskew *= samplesperpixel;
- for (; h > 0; --h)
- {
- for (x = w; x > 0; --x)
- {
- *cp++ = PACK(img->Bitdepth16To8[wp[0]], img->Bitdepth16To8[wp[1]],
- img->Bitdepth16To8[wp[2]]);
- wp += samplesperpixel;
- }
- cp += toskew;
- wp += fromskew;
- }
-}
-
-/*
- * 16-bit packed samples => RGBA w/ associated alpha
- * (known to have Map == NULL)
- */
-DECLAREContigPutFunc(putRGBAAcontig16bittile)
-{
- int samplesperpixel = img->samplesperpixel;
- uint16_t *wp = (uint16_t *)pp;
- (void)y;
- fromskew *= samplesperpixel;
- for (; h > 0; --h)
- {
- for (x = w; x > 0; --x)
- {
- *cp++ = PACK4(img->Bitdepth16To8[wp[0]], img->Bitdepth16To8[wp[1]],
- img->Bitdepth16To8[wp[2]], img->Bitdepth16To8[wp[3]]);
- wp += samplesperpixel;
- }
- cp += toskew;
- wp += fromskew;
- }
-}
-
-/*
- * 16-bit packed samples => RGBA w/ unassociated alpha
- * (known to have Map == NULL)
- */
-DECLAREContigPutFunc(putRGBUAcontig16bittile)
-{
- int samplesperpixel = img->samplesperpixel;
- uint16_t *wp = (uint16_t *)pp;
- (void)y;
- fromskew *= samplesperpixel;
- for (; h > 0; --h)
- {
- uint32_t r, g, b, a;
- uint8_t *m;
- for (x = w; x > 0; --x)
- {
- a = img->Bitdepth16To8[wp[3]];
- m = img->UaToAa + ((size_t)a << 8);
- r = m[img->Bitdepth16To8[wp[0]]];
- g = m[img->Bitdepth16To8[wp[1]]];
- b = m[img->Bitdepth16To8[wp[2]]];
- *cp++ = PACK4(r, g, b, a);
- wp += samplesperpixel;
- }
- cp += toskew;
- wp += fromskew;
- }
-}
-
-/*
- * 8-bit packed CMYK samples w/o Map => RGB
- *
- * NB: The conversion of CMYK->RGB is *very* crude.
- */
-DECLAREContigPutFunc(putRGBcontig8bitCMYKtile)
-{
- int samplesperpixel = img->samplesperpixel;
- uint16_t r, g, b, k;
-
- (void)x;
- (void)y;
- fromskew *= samplesperpixel;
- for (; h > 0; --h)
- {
- UNROLL8(w, NOP, k = 255 - pp[3]; r = (k * (255 - pp[0])) / 255;
- g = (k * (255 - pp[1])) / 255; b = (k * (255 - pp[2])) / 255;
- *cp++ = PACK(r, g, b); pp += samplesperpixel);
- cp += toskew;
- pp += fromskew;
- }
-}
-
-/*
- * 8-bit packed CMYK samples w/Map => RGB
- *
- * NB: The conversion of CMYK->RGB is *very* crude.
- */
-DECLAREContigPutFunc(putRGBcontig8bitCMYKMaptile)
-{
- int samplesperpixel = img->samplesperpixel;
- TIFFRGBValue *Map = img->Map;
- uint16_t r, g, b, k;
-
- (void)y;
- fromskew *= samplesperpixel;
- for (; h > 0; --h)
- {
- for (x = w; x > 0; --x)
- {
- k = 255 - pp[3];
- r = (k * (255 - pp[0])) / 255;
- g = (k * (255 - pp[1])) / 255;
- b = (k * (255 - pp[2])) / 255;
- *cp++ = PACK(Map[r], Map[g], Map[b]);
- pp += samplesperpixel;
- }
- pp += fromskew;
- cp += toskew;
- }
-}
-
-#define DECLARESepPutFunc(name) \
- static void name(TIFFRGBAImage *img, uint32_t *cp, uint32_t x, uint32_t y, \
- uint32_t w, uint32_t h, int32_t fromskew, int32_t toskew, \
- unsigned char *r, unsigned char *g, unsigned char *b, \
- unsigned char *a)
-
-/*
- * 8-bit unpacked samples => RGB
- */
-DECLARESepPutFunc(putRGBseparate8bittile)
-{
- (void)img;
- (void)x;
- (void)y;
- (void)a;
- for (; h > 0; --h)
- {
- UNROLL8(w, NOP, *cp++ = PACK(*r++, *g++, *b++));
- SKEW(r, g, b, fromskew);
- cp += toskew;
- }
-}
-
-/*
- * 8-bit unpacked samples => RGBA w/ associated alpha
- */
-DECLARESepPutFunc(putRGBAAseparate8bittile)
-{
- (void)img;
- (void)x;
- (void)y;
- for (; h > 0; --h)
- {
- UNROLL8(w, NOP, *cp++ = PACK4(*r++, *g++, *b++, *a++));
- SKEW4(r, g, b, a, fromskew);
- cp += toskew;
- }
-}
-
-/*
- * 8-bit unpacked CMYK samples => RGBA
- */
-DECLARESepPutFunc(putCMYKseparate8bittile)
-{
- (void)img;
- (void)y;
- for (; h > 0; --h)
- {
- uint32_t rv, gv, bv, kv;
- for (x = w; x > 0; --x)
- {
- kv = 255 - *a++;
- rv = (kv * (255 - *r++)) / 255;
- gv = (kv * (255 - *g++)) / 255;
- bv = (kv * (255 - *b++)) / 255;
- *cp++ = PACK4(rv, gv, bv, 255);
- }
- SKEW4(r, g, b, a, fromskew);
- cp += toskew;
- }
-}
-
-/*
- * 8-bit unpacked samples => RGBA w/ unassociated alpha
- */
-DECLARESepPutFunc(putRGBUAseparate8bittile)
-{
- (void)img;
- (void)y;
- for (; h > 0; --h)
- {
- uint32_t rv, gv, bv, av;
- uint8_t *m;
- for (x = w; x > 0; --x)
- {
- av = *a++;
- m = img->UaToAa + ((size_t)av << 8);
- rv = m[*r++];
- gv = m[*g++];
- bv = m[*b++];
- *cp++ = PACK4(rv, gv, bv, av);
- }
- SKEW4(r, g, b, a, fromskew);
- cp += toskew;
- }
-}
-
-/*
- * 16-bit unpacked samples => RGB
- */
-DECLARESepPutFunc(putRGBseparate16bittile)
-{
- uint16_t *wr = (uint16_t *)r;
- uint16_t *wg = (uint16_t *)g;
- uint16_t *wb = (uint16_t *)b;
- (void)img;
- (void)y;
- (void)a;
- for (; h > 0; --h)
- {
- for (x = 0; x < w; x++)
- *cp++ = PACK(img->Bitdepth16To8[*wr++], img->Bitdepth16To8[*wg++],
- img->Bitdepth16To8[*wb++]);
- SKEW(wr, wg, wb, fromskew);
- cp += toskew;
- }
-}
-
-/*
- * 16-bit unpacked samples => RGBA w/ associated alpha
- */
-DECLARESepPutFunc(putRGBAAseparate16bittile)
-{
- uint16_t *wr = (uint16_t *)r;
- uint16_t *wg = (uint16_t *)g;
- uint16_t *wb = (uint16_t *)b;
- uint16_t *wa = (uint16_t *)a;
- (void)img;
- (void)y;
- for (; h > 0; --h)
- {
- for (x = 0; x < w; x++)
- *cp++ = PACK4(img->Bitdepth16To8[*wr++], img->Bitdepth16To8[*wg++],
- img->Bitdepth16To8[*wb++], img->Bitdepth16To8[*wa++]);
- SKEW4(wr, wg, wb, wa, fromskew);
- cp += toskew;
- }
-}
-
-/*
- * 16-bit unpacked samples => RGBA w/ unassociated alpha
- */
-DECLARESepPutFunc(putRGBUAseparate16bittile)
-{
- uint16_t *wr = (uint16_t *)r;
- uint16_t *wg = (uint16_t *)g;
- uint16_t *wb = (uint16_t *)b;
- uint16_t *wa = (uint16_t *)a;
- (void)img;
- (void)y;
- for (; h > 0; --h)
- {
- uint32_t r2, g2, b2, a2;
- uint8_t *m;
- for (x = w; x > 0; --x)
- {
- a2 = img->Bitdepth16To8[*wa++];
- m = img->UaToAa + ((size_t)a2 << 8);
- r2 = m[img->Bitdepth16To8[*wr++]];
- g2 = m[img->Bitdepth16To8[*wg++]];
- b2 = m[img->Bitdepth16To8[*wb++]];
- *cp++ = PACK4(r2, g2, b2, a2);
- }
- SKEW4(wr, wg, wb, wa, fromskew);
- cp += toskew;
- }
-}
-
-/*
- * 8-bit packed CIE L*a*b 1976 samples => RGB
- */
-DECLAREContigPutFunc(putcontig8bitCIELab8)
-{
- float X, Y, Z;
- uint32_t r, g, b;
- (void)y;
- fromskew *= 3;
- for (; h > 0; --h)
- {
- for (x = w; x > 0; --x)
- {
- TIFFCIELabToXYZ(img->cielab, (unsigned char)pp[0],
- (signed char)pp[1], (signed char)pp[2], &X, &Y, &Z);
- TIFFXYZToRGB(img->cielab, X, Y, Z, &r, &g, &b);
- *cp++ = PACK(r, g, b);
- pp += 3;
- }
- cp += toskew;
- pp += fromskew;
- }
-}
-
-/*
- * 16-bit packed CIE L*a*b 1976 samples => RGB
- */
-DECLAREContigPutFunc(putcontig8bitCIELab16)
-{
- float X, Y, Z;
- uint32_t r, g, b;
- uint16_t *wp = (uint16_t *)pp;
- (void)y;
- fromskew *= 3;
- for (; h > 0; --h)
- {
- for (x = w; x > 0; --x)
- {
- TIFFCIELab16ToXYZ(img->cielab, (uint16_t)wp[0], (int16_t)wp[1],
- (int16_t)wp[2], &X, &Y, &Z);
- TIFFXYZToRGB(img->cielab, X, Y, Z, &r, &g, &b);
- *cp++ = PACK(r, g, b);
- wp += 3;
- }
- cp += toskew;
- wp += fromskew;
- }
-}
-
-/*
- * YCbCr -> RGB conversion and packing routines.
- */
-
-#define YCbCrtoRGB(dst, Y) \
- { \
- uint32_t r, g, b; \
- TIFFYCbCrtoRGB(img->ycbcr, (Y), Cb, Cr, &r, &g, &b); \
- dst = PACK(r, g, b); \
- }
-
-/*
- * 8-bit packed YCbCr samples w/ 4,4 subsampling => RGB
- */
-DECLAREContigPutFunc(putcontig8bitYCbCr44tile)
-{
- uint32_t *cp1 = cp + w + toskew;
- uint32_t *cp2 = cp1 + w + toskew;
- uint32_t *cp3 = cp2 + w + toskew;
- int32_t incr = 3 * w + 4 * toskew;
-
- (void)y;
- /* adjust fromskew */
- fromskew = (fromskew / 4) * (4 * 2 + 2);
- if ((h & 3) == 0 && (w & 3) == 0)
- {
- for (; h >= 4; h -= 4)
- {
- x = w >> 2;
- do
- {
- int32_t Cb = pp[16];
- int32_t Cr = pp[17];
-
- YCbCrtoRGB(cp[0], pp[0]);
- YCbCrtoRGB(cp[1], pp[1]);
- YCbCrtoRGB(cp[2], pp[2]);
- YCbCrtoRGB(cp[3], pp[3]);
- YCbCrtoRGB(cp1[0], pp[4]);
- YCbCrtoRGB(cp1[1], pp[5]);
- YCbCrtoRGB(cp1[2], pp[6]);
- YCbCrtoRGB(cp1[3], pp[7]);
- YCbCrtoRGB(cp2[0], pp[8]);
- YCbCrtoRGB(cp2[1], pp[9]);
- YCbCrtoRGB(cp2[2], pp[10]);
- YCbCrtoRGB(cp2[3], pp[11]);
- YCbCrtoRGB(cp3[0], pp[12]);
- YCbCrtoRGB(cp3[1], pp[13]);
- YCbCrtoRGB(cp3[2], pp[14]);
- YCbCrtoRGB(cp3[3], pp[15]);
-
- cp += 4;
- cp1 += 4;
- cp2 += 4;
- cp3 += 4;
- pp += 18;
- } while (--x);
- cp += incr;
- cp1 += incr;
- cp2 += incr;
- cp3 += incr;
- pp += fromskew;
- }
- }
- else
- {
- while (h > 0)
- {
- for (x = w; x > 0;)
- {
- int32_t Cb = pp[16];
- int32_t Cr = pp[17];
- switch (x)
- {
- default:
- switch (h)
- {
- default:
- YCbCrtoRGB(cp3[3], pp[15]); /* FALLTHROUGH */
- case 3:
- YCbCrtoRGB(cp2[3], pp[11]); /* FALLTHROUGH */
- case 2:
- YCbCrtoRGB(cp1[3], pp[7]); /* FALLTHROUGH */
- case 1:
- YCbCrtoRGB(cp[3], pp[3]); /* FALLTHROUGH */
- } /* FALLTHROUGH */
- case 3:
- switch (h)
- {
- default:
- YCbCrtoRGB(cp3[2], pp[14]); /* FALLTHROUGH */
- case 3:
- YCbCrtoRGB(cp2[2], pp[10]); /* FALLTHROUGH */
- case 2:
- YCbCrtoRGB(cp1[2], pp[6]); /* FALLTHROUGH */
- case 1:
- YCbCrtoRGB(cp[2], pp[2]); /* FALLTHROUGH */
- } /* FALLTHROUGH */
- case 2:
- switch (h)
- {
- default:
- YCbCrtoRGB(cp3[1], pp[13]); /* FALLTHROUGH */
- case 3:
- YCbCrtoRGB(cp2[1], pp[9]); /* FALLTHROUGH */
- case 2:
- YCbCrtoRGB(cp1[1], pp[5]); /* FALLTHROUGH */
- case 1:
- YCbCrtoRGB(cp[1], pp[1]); /* FALLTHROUGH */
- } /* FALLTHROUGH */
- case 1:
- switch (h)
- {
- default:
- YCbCrtoRGB(cp3[0], pp[12]); /* FALLTHROUGH */
- case 3:
- YCbCrtoRGB(cp2[0], pp[8]); /* FALLTHROUGH */
- case 2:
- YCbCrtoRGB(cp1[0], pp[4]); /* FALLTHROUGH */
- case 1:
- YCbCrtoRGB(cp[0], pp[0]); /* FALLTHROUGH */
- } /* FALLTHROUGH */
- }
- if (x < 4)
- {
- cp += x;
- cp1 += x;
- cp2 += x;
- cp3 += x;
- x = 0;
- }
- else
- {
- cp += 4;
- cp1 += 4;
- cp2 += 4;
- cp3 += 4;
- x -= 4;
- }
- pp += 18;
- }
- if (h <= 4)
- break;
- h -= 4;
- cp += incr;
- cp1 += incr;
- cp2 += incr;
- cp3 += incr;
- pp += fromskew;
- }
- }
-}
-
-/*
- * 8-bit packed YCbCr samples w/ 4,2 subsampling => RGB
- */
-DECLAREContigPutFunc(putcontig8bitYCbCr42tile)
-{
- uint32_t *cp1 = cp + w + toskew;
- int32_t incr = 2 * toskew + w;
-
- (void)y;
- fromskew = (fromskew / 4) * (4 * 2 + 2);
- if ((w & 3) == 0 && (h & 1) == 0)
- {
- for (; h >= 2; h -= 2)
- {
- x = w >> 2;
- do
- {
- int32_t Cb = pp[8];
- int32_t Cr = pp[9];
-
- YCbCrtoRGB(cp[0], pp[0]);
- YCbCrtoRGB(cp[1], pp[1]);
- YCbCrtoRGB(cp[2], pp[2]);
- YCbCrtoRGB(cp[3], pp[3]);
- YCbCrtoRGB(cp1[0], pp[4]);
- YCbCrtoRGB(cp1[1], pp[5]);
- YCbCrtoRGB(cp1[2], pp[6]);
- YCbCrtoRGB(cp1[3], pp[7]);
-
- cp += 4;
- cp1 += 4;
- pp += 10;
- } while (--x);
- cp += incr;
- cp1 += incr;
- pp += fromskew;
- }
- }
- else
- {
- while (h > 0)
- {
- for (x = w; x > 0;)
- {
- int32_t Cb = pp[8];
- int32_t Cr = pp[9];
- switch (x)
- {
- default:
- switch (h)
- {
- default:
- YCbCrtoRGB(cp1[3], pp[7]); /* FALLTHROUGH */
- case 1:
- YCbCrtoRGB(cp[3], pp[3]); /* FALLTHROUGH */
- } /* FALLTHROUGH */
- case 3:
- switch (h)
- {
- default:
- YCbCrtoRGB(cp1[2], pp[6]); /* FALLTHROUGH */
- case 1:
- YCbCrtoRGB(cp[2], pp[2]); /* FALLTHROUGH */
- } /* FALLTHROUGH */
- case 2:
- switch (h)
- {
- default:
- YCbCrtoRGB(cp1[1], pp[5]); /* FALLTHROUGH */
- case 1:
- YCbCrtoRGB(cp[1], pp[1]); /* FALLTHROUGH */
- } /* FALLTHROUGH */
- case 1:
- switch (h)
- {
- default:
- YCbCrtoRGB(cp1[0], pp[4]); /* FALLTHROUGH */
- case 1:
- YCbCrtoRGB(cp[0], pp[0]); /* FALLTHROUGH */
- } /* FALLTHROUGH */
- }
- if (x < 4)
- {
- cp += x;
- cp1 += x;
- x = 0;
- }
- else
- {
- cp += 4;
- cp1 += 4;
- x -= 4;
- }
- pp += 10;
- }
- if (h <= 2)
- break;
- h -= 2;
- cp += incr;
- cp1 += incr;
- pp += fromskew;
- }
- }
-}
-
-/*
- * 8-bit packed YCbCr samples w/ 4,1 subsampling => RGB
- */
-DECLAREContigPutFunc(putcontig8bitYCbCr41tile)
-{
- (void)y;
- fromskew = (fromskew / 4) * (4 * 1 + 2);
- do
- {
- x = w >> 2;
- while (x > 0)
- {
- int32_t Cb = pp[4];
- int32_t Cr = pp[5];
-
- YCbCrtoRGB(cp[0], pp[0]);
- YCbCrtoRGB(cp[1], pp[1]);
- YCbCrtoRGB(cp[2], pp[2]);
- YCbCrtoRGB(cp[3], pp[3]);
-
- cp += 4;
- pp += 6;
- x--;
- }
-
- if ((w & 3) != 0)
- {
- int32_t Cb = pp[4];
- int32_t Cr = pp[5];
-
- switch ((w & 3))
- {
- case 3:
- YCbCrtoRGB(cp[2], pp[2]); /*-fallthrough*/
- case 2:
- YCbCrtoRGB(cp[1], pp[1]); /*-fallthrough*/
- case 1:
- YCbCrtoRGB(cp[0], pp[0]); /*-fallthrough*/
- case 0:
- break;
- }
-
- cp += (w & 3);
- pp += 6;
- }
-
- cp += toskew;
- pp += fromskew;
- } while (--h);
-}
-
-/*
- * 8-bit packed YCbCr samples w/ 2,2 subsampling => RGB
- */
-DECLAREContigPutFunc(putcontig8bitYCbCr22tile)
-{
- uint32_t *cp2;
- int32_t incr = 2 * toskew + w;
- (void)y;
- fromskew = (fromskew / 2) * (2 * 2 + 2);
- cp2 = cp + w + toskew;
- while (h >= 2)
- {
- x = w;
- while (x >= 2)
- {
- uint32_t Cb = pp[4];
- uint32_t Cr = pp[5];
- YCbCrtoRGB(cp[0], pp[0]);
- YCbCrtoRGB(cp[1], pp[1]);
- YCbCrtoRGB(cp2[0], pp[2]);
- YCbCrtoRGB(cp2[1], pp[3]);
- cp += 2;
- cp2 += 2;
- pp += 6;
- x -= 2;
- }
- if (x == 1)
- {
- uint32_t Cb = pp[4];
- uint32_t Cr = pp[5];
- YCbCrtoRGB(cp[0], pp[0]);
- YCbCrtoRGB(cp2[0], pp[2]);
- cp++;
- cp2++;
- pp += 6;
- }
- cp += incr;
- cp2 += incr;
- pp += fromskew;
- h -= 2;
- }
- if (h == 1)
- {
- x = w;
- while (x >= 2)
- {
- uint32_t Cb = pp[4];
- uint32_t Cr = pp[5];
- YCbCrtoRGB(cp[0], pp[0]);
- YCbCrtoRGB(cp[1], pp[1]);
- cp += 2;
- cp2 += 2;
- pp += 6;
- x -= 2;
- }
- if (x == 1)
- {
- uint32_t Cb = pp[4];
- uint32_t Cr = pp[5];
- YCbCrtoRGB(cp[0], pp[0]);
- }
- }
-}
-
-/*
- * 8-bit packed YCbCr samples w/ 2,1 subsampling => RGB
- */
-DECLAREContigPutFunc(putcontig8bitYCbCr21tile)
-{
- (void)y;
- fromskew = (fromskew / 2) * (2 * 1 + 2);
- do
- {
- x = w >> 1;
- while (x > 0)
- {
- int32_t Cb = pp[2];
- int32_t Cr = pp[3];
-
- YCbCrtoRGB(cp[0], pp[0]);
- YCbCrtoRGB(cp[1], pp[1]);
-
- cp += 2;
- pp += 4;
- x--;
- }
-
- if ((w & 1) != 0)
- {
- int32_t Cb = pp[2];
- int32_t Cr = pp[3];
-
- YCbCrtoRGB(cp[0], pp[0]);
-
- cp += 1;
- pp += 4;
- }
-
- cp += toskew;
- pp += fromskew;
- } while (--h);
-}
-
-/*
- * 8-bit packed YCbCr samples w/ 1,2 subsampling => RGB
- */
-DECLAREContigPutFunc(putcontig8bitYCbCr12tile)
-{
- uint32_t *cp2;
- int32_t incr = 2 * toskew + w;
- (void)y;
- fromskew = (fromskew / 1) * (1 * 2 + 2);
- cp2 = cp + w + toskew;
- while (h >= 2)
- {
- x = w;
- do
- {
- uint32_t Cb = pp[2];
- uint32_t Cr = pp[3];
- YCbCrtoRGB(cp[0], pp[0]);
- YCbCrtoRGB(cp2[0], pp[1]);
- cp++;
- cp2++;
- pp += 4;
- } while (--x);
- cp += incr;
- cp2 += incr;
- pp += fromskew;
- h -= 2;
- }
- if (h == 1)
- {
- x = w;
- do
- {
- uint32_t Cb = pp[2];
- uint32_t Cr = pp[3];
- YCbCrtoRGB(cp[0], pp[0]);
- cp++;
- pp += 4;
- } while (--x);
- }
-}
-
-/*
- * 8-bit packed YCbCr samples w/ no subsampling => RGB
- */
-DECLAREContigPutFunc(putcontig8bitYCbCr11tile)
-{
- (void)y;
- fromskew = (fromskew / 1) * (1 * 1 + 2);
- do
- {
- x = w; /* was x = w>>1; patched 2000/09/25 warmerda@home.com */
- do
- {
- int32_t Cb = pp[1];
- int32_t Cr = pp[2];
-
- YCbCrtoRGB(*cp++, pp[0]);
-
- pp += 3;
- } while (--x);
- cp += toskew;
- pp += fromskew;
- } while (--h);
-}
-
-/*
- * 8-bit packed YCbCr samples w/ no subsampling => RGB
- */
-DECLARESepPutFunc(putseparate8bitYCbCr11tile)
-{
- (void)y;
- (void)a;
- /* TODO: naming of input vars is still off, change obfuscating declaration
- * inside define, or resolve obfuscation */
- for (; h > 0; --h)
- {
- x = w;
- do
- {
- uint32_t dr, dg, db;
- TIFFYCbCrtoRGB(img->ycbcr, *r++, *g++, *b++, &dr, &dg, &db);
- *cp++ = PACK(dr, dg, db);
- } while (--x);
- SKEW(r, g, b, fromskew);
- cp += toskew;
- }
-}
-#undef YCbCrtoRGB
-
-static int isInRefBlackWhiteRange(float f)
-{
- return f > (float)(-0x7FFFFFFF + 128) && f < (float)0x7FFFFFFF;
-}
-
-static int initYCbCrConversion(TIFFRGBAImage *img)
-{
- static const char module[] = "initYCbCrConversion";
-
- float *luma, *refBlackWhite;
-
- if (img->ycbcr == NULL)
- {
- img->ycbcr = (TIFFYCbCrToRGB *)_TIFFmallocExt(
- img->tif, TIFFroundup_32(sizeof(TIFFYCbCrToRGB), sizeof(long)) +
- 4 * 256 * sizeof(TIFFRGBValue) +
- 2 * 256 * sizeof(int) + 3 * 256 * sizeof(int32_t));
- if (img->ycbcr == NULL)
- {
- TIFFErrorExtR(img->tif, module,
- "No space for YCbCr->RGB conversion state");
- return (0);
- }
- }
-
- TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRCOEFFICIENTS, &luma);
- TIFFGetFieldDefaulted(img->tif, TIFFTAG_REFERENCEBLACKWHITE,
- &refBlackWhite);
-
- /* Do some validation to avoid later issues. Detect NaN for now */
- /* and also if lumaGreen is zero since we divide by it later */
- if (luma[0] != luma[0] || luma[1] != luma[1] || luma[1] == 0.0 ||
- luma[2] != luma[2])
- {
- TIFFErrorExtR(img->tif, module,
- "Invalid values for YCbCrCoefficients tag");
- return (0);
- }
-
- if (!isInRefBlackWhiteRange(refBlackWhite[0]) ||
- !isInRefBlackWhiteRange(refBlackWhite[1]) ||
- !isInRefBlackWhiteRange(refBlackWhite[2]) ||
- !isInRefBlackWhiteRange(refBlackWhite[3]) ||
- !isInRefBlackWhiteRange(refBlackWhite[4]) ||
- !isInRefBlackWhiteRange(refBlackWhite[5]))
- {
- TIFFErrorExtR(img->tif, module,
- "Invalid values for ReferenceBlackWhite tag");
- return (0);
- }
-
- if (TIFFYCbCrToRGBInit(img->ycbcr, luma, refBlackWhite) < 0)
- return (0);
- return (1);
-}
-
-static tileContigRoutine initCIELabConversion(TIFFRGBAImage *img)
-{
- static const char module[] = "initCIELabConversion";
-
- float *whitePoint;
- float refWhite[3];
-
- TIFFGetFieldDefaulted(img->tif, TIFFTAG_WHITEPOINT, &whitePoint);
- if (whitePoint[1] == 0.0f)
- {
- TIFFErrorExtR(img->tif, module, "Invalid value for WhitePoint tag.");
- return NULL;
- }
-
- if (!img->cielab)
- {
- img->cielab = (TIFFCIELabToRGB *)_TIFFmallocExt(
- img->tif, sizeof(TIFFCIELabToRGB));
- if (!img->cielab)
- {
- TIFFErrorExtR(img->tif, module,
- "No space for CIE L*a*b*->RGB conversion state.");
- return NULL;
- }
- }
-
- refWhite[1] = 100.0F;
- refWhite[0] = whitePoint[0] / whitePoint[1] * refWhite[1];
- refWhite[2] =
- (1.0F - whitePoint[0] - whitePoint[1]) / whitePoint[1] * refWhite[1];
- if (TIFFCIELabToRGBInit(img->cielab, &display_sRGB, refWhite) < 0)
- {
- TIFFErrorExtR(img->tif, module,
- "Failed to initialize CIE L*a*b*->RGB conversion state.");
- _TIFFfreeExt(img->tif, img->cielab);
- return NULL;
- }
-
- if (img->bitspersample == 8)
- return putcontig8bitCIELab8;
- else if (img->bitspersample == 16)
- return putcontig8bitCIELab16;
- return NULL;
-}
-
-/*
- * Greyscale images with less than 8 bits/sample are handled
- * with a table to avoid lots of shifts and masks. The table
- * is setup so that put*bwtile (below) can retrieve 8/bitspersample
- * pixel values simply by indexing into the table with one
- * number.
- */
-static int makebwmap(TIFFRGBAImage *img)
-{
- TIFFRGBValue *Map = img->Map;
- int bitspersample = img->bitspersample;
- int nsamples = 8 / bitspersample;
- int i;
- uint32_t *p;
-
- if (nsamples == 0)
- nsamples = 1;
-
- img->BWmap = (uint32_t **)_TIFFmallocExt(
- img->tif,
- 256 * sizeof(uint32_t *) + (256 * nsamples * sizeof(uint32_t)));
- if (img->BWmap == NULL)
- {
- TIFFErrorExtR(img->tif, TIFFFileName(img->tif),
- "No space for B&W mapping table");
- return (0);
- }
- p = (uint32_t *)(img->BWmap + 256);
- for (i = 0; i < 256; i++)
- {
- TIFFRGBValue c;
- img->BWmap[i] = p;
- switch (bitspersample)
- {
-#define GREY(x) \
- c = Map[x]; \
- *p++ = PACK(c, c, c);
- case 1:
- GREY(i >> 7);
- GREY((i >> 6) & 1);
- GREY((i >> 5) & 1);
- GREY((i >> 4) & 1);
- GREY((i >> 3) & 1);
- GREY((i >> 2) & 1);
- GREY((i >> 1) & 1);
- GREY(i & 1);
- break;
- case 2:
- GREY(i >> 6);
- GREY((i >> 4) & 3);
- GREY((i >> 2) & 3);
- GREY(i & 3);
- break;
- case 4:
- GREY(i >> 4);
- GREY(i & 0xf);
- break;
- case 8:
- case 16:
- GREY(i);
- break;
- }
-#undef GREY
- }
- return (1);
-}
-
-/*
- * Construct a mapping table to convert from the range
- * of the data samples to [0,255] --for display. This
- * process also handles inverting B&W images when needed.
- */
-static int setupMap(TIFFRGBAImage *img)
-{
- int32_t x, range;
-
- range = (int32_t)((1L << img->bitspersample) - 1);
-
- /* treat 16 bit the same as eight bit */
- if (img->bitspersample == 16)
- range = (int32_t)255;
-
- img->Map = (TIFFRGBValue *)_TIFFmallocExt(
- img->tif, (range + 1) * sizeof(TIFFRGBValue));
- if (img->Map == NULL)
- {
- TIFFErrorExtR(img->tif, TIFFFileName(img->tif),
- "No space for photometric conversion table");
- return (0);
- }
- if (img->photometric == PHOTOMETRIC_MINISWHITE)
- {
- for (x = 0; x <= range; x++)
- img->Map[x] = (TIFFRGBValue)(((range - x) * 255) / range);
- }
- else
- {
- for (x = 0; x <= range; x++)
- img->Map[x] = (TIFFRGBValue)((x * 255) / range);
- }
- if (img->bitspersample <= 16 &&
- (img->photometric == PHOTOMETRIC_MINISBLACK ||
- img->photometric == PHOTOMETRIC_MINISWHITE))
- {
- /*
- * Use photometric mapping table to construct
- * unpacking tables for samples <= 8 bits.
- */
- if (!makebwmap(img))
- return (0);
- /* no longer need Map, free it */
- _TIFFfreeExt(img->tif, img->Map);
- img->Map = NULL;
- }
- return (1);
-}
-
-static int checkcmap(TIFFRGBAImage *img)
-{
- uint16_t *r = img->redcmap;
- uint16_t *g = img->greencmap;
- uint16_t *b = img->bluecmap;
- long n = 1L << img->bitspersample;
-
- while (n-- > 0)
- if (*r++ >= 256 || *g++ >= 256 || *b++ >= 256)
- return (16);
- return (8);
-}
-
-static void cvtcmap(TIFFRGBAImage *img)
-{
- uint16_t *r = img->redcmap;
- uint16_t *g = img->greencmap;
- uint16_t *b = img->bluecmap;
- long i;
-
- for (i = (1L << img->bitspersample) - 1; i >= 0; i--)
- {
-#define CVT(x) ((uint16_t)((x) >> 8))
- r[i] = CVT(r[i]);
- g[i] = CVT(g[i]);
- b[i] = CVT(b[i]);
-#undef CVT
- }
-}
-
-/*
- * Palette images with <= 8 bits/sample are handled
- * with a table to avoid lots of shifts and masks. The table
- * is setup so that put*cmaptile (below) can retrieve 8/bitspersample
- * pixel values simply by indexing into the table with one
- * number.
- */
-static int makecmap(TIFFRGBAImage *img)
-{
- int bitspersample = img->bitspersample;
- int nsamples = 8 / bitspersample;
- uint16_t *r = img->redcmap;
- uint16_t *g = img->greencmap;
- uint16_t *b = img->bluecmap;
- uint32_t *p;
- int i;
-
- img->PALmap = (uint32_t **)_TIFFmallocExt(
- img->tif,
- 256 * sizeof(uint32_t *) + (256 * nsamples * sizeof(uint32_t)));
- if (img->PALmap == NULL)
- {
- TIFFErrorExtR(img->tif, TIFFFileName(img->tif),
- "No space for Palette mapping table");
- return (0);
- }
- p = (uint32_t *)(img->PALmap + 256);
- for (i = 0; i < 256; i++)
- {
- TIFFRGBValue c;
- img->PALmap[i] = p;
-#define CMAP(x) \
- c = (TIFFRGBValue)x; \
- *p++ = PACK(r[c] & 0xff, g[c] & 0xff, b[c] & 0xff);
- switch (bitspersample)
- {
- case 1:
- CMAP(i >> 7);
- CMAP((i >> 6) & 1);
- CMAP((i >> 5) & 1);
- CMAP((i >> 4) & 1);
- CMAP((i >> 3) & 1);
- CMAP((i >> 2) & 1);
- CMAP((i >> 1) & 1);
- CMAP(i & 1);
- break;
- case 2:
- CMAP(i >> 6);
- CMAP((i >> 4) & 3);
- CMAP((i >> 2) & 3);
- CMAP(i & 3);
- break;
- case 4:
- CMAP(i >> 4);
- CMAP(i & 0xf);
- break;
- case 8:
- CMAP(i);
- break;
- }
-#undef CMAP
- }
- return (1);
-}
-
-/*
- * Construct any mapping table used
- * by the associated put routine.
- */
-static int buildMap(TIFFRGBAImage *img)
-{
- switch (img->photometric)
- {
- case PHOTOMETRIC_RGB:
- case PHOTOMETRIC_YCBCR:
- case PHOTOMETRIC_SEPARATED:
- if (img->bitspersample == 8)
- break;
- /* fall through... */
- case PHOTOMETRIC_MINISBLACK:
- case PHOTOMETRIC_MINISWHITE:
- if (!setupMap(img))
- return (0);
- break;
- case PHOTOMETRIC_PALETTE:
- /*
- * Convert 16-bit colormap to 8-bit (unless it looks
- * like an old-style 8-bit colormap).
- */
- if (checkcmap(img) == 16)
- cvtcmap(img);
- else
- TIFFWarningExtR(img->tif, TIFFFileName(img->tif),
- "Assuming 8-bit colormap");
- /*
- * Use mapping table and colormap to construct
- * unpacking tables for samples < 8 bits.
- */
- if (img->bitspersample <= 8 && !makecmap(img))
- return (0);
- break;
- }
- return (1);
-}
-
-/*
- * Select the appropriate conversion routine for packed data.
- */
-static int PickContigCase(TIFFRGBAImage *img)
-{
- img->get = TIFFIsTiled(img->tif) ? gtTileContig : gtStripContig;
- img->put.contig = NULL;
- switch (img->photometric)
- {
- case PHOTOMETRIC_RGB:
- switch (img->bitspersample)
- {
- case 8:
- if (img->alpha == EXTRASAMPLE_ASSOCALPHA &&
- img->samplesperpixel >= 4)
- img->put.contig = putRGBAAcontig8bittile;
- else if (img->alpha == EXTRASAMPLE_UNASSALPHA &&
- img->samplesperpixel >= 4)
- {
- if (BuildMapUaToAa(img))
- img->put.contig = putRGBUAcontig8bittile;
- }
- else if (img->samplesperpixel >= 3)
- img->put.contig = putRGBcontig8bittile;
- break;
- case 16:
- if (img->alpha == EXTRASAMPLE_ASSOCALPHA &&
- img->samplesperpixel >= 4)
- {
- if (BuildMapBitdepth16To8(img))
- img->put.contig = putRGBAAcontig16bittile;
- }
- else if (img->alpha == EXTRASAMPLE_UNASSALPHA &&
- img->samplesperpixel >= 4)
- {
- if (BuildMapBitdepth16To8(img) && BuildMapUaToAa(img))
- img->put.contig = putRGBUAcontig16bittile;
- }
- else if (img->samplesperpixel >= 3)
- {
- if (BuildMapBitdepth16To8(img))
- img->put.contig = putRGBcontig16bittile;
- }
- break;
- }
- break;
- case PHOTOMETRIC_SEPARATED:
- if (img->samplesperpixel >= 4 && buildMap(img))
- {
- if (img->bitspersample == 8)
- {
- if (!img->Map)
- img->put.contig = putRGBcontig8bitCMYKtile;
- else
- img->put.contig = putRGBcontig8bitCMYKMaptile;
- }
- }
- break;
- case PHOTOMETRIC_PALETTE:
- if (buildMap(img))
- {
- switch (img->bitspersample)
- {
- case 8:
- img->put.contig = put8bitcmaptile;
- break;
- case 4:
- img->put.contig = put4bitcmaptile;
- break;
- case 2:
- img->put.contig = put2bitcmaptile;
- break;
- case 1:
- img->put.contig = put1bitcmaptile;
- break;
- }
- }
- break;
- case PHOTOMETRIC_MINISWHITE:
- case PHOTOMETRIC_MINISBLACK:
- if (buildMap(img))
- {
- switch (img->bitspersample)
- {
- case 16:
- img->put.contig = put16bitbwtile;
- break;
- case 8:
- if (img->alpha && img->samplesperpixel == 2)
- img->put.contig = putagreytile;
- else
- img->put.contig = putgreytile;
- break;
- case 4:
- img->put.contig = put4bitbwtile;
- break;
- case 2:
- img->put.contig = put2bitbwtile;
- break;
- case 1:
- img->put.contig = put1bitbwtile;
- break;
- }
- }
- break;
- case PHOTOMETRIC_YCBCR:
- if ((img->bitspersample == 8) && (img->samplesperpixel == 3))
- {
- if (initYCbCrConversion(img) != 0)
- {
- /*
- * The 6.0 spec says that subsampling must be
- * one of 1, 2, or 4, and that vertical subsampling
- * must always be <= horizontal subsampling; so
- * there are only a few possibilities and we just
- * enumerate the cases.
- * Joris: added support for the [1,2] case, nonetheless, to
- * accommodate some OJPEG files
- */
- uint16_t SubsamplingHor;
- uint16_t SubsamplingVer;
- TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRSUBSAMPLING,
- &SubsamplingHor, &SubsamplingVer);
- switch ((SubsamplingHor << 4) | SubsamplingVer)
- {
- case 0x44:
- img->put.contig = putcontig8bitYCbCr44tile;
- break;
- case 0x42:
- img->put.contig = putcontig8bitYCbCr42tile;
- break;
- case 0x41:
- img->put.contig = putcontig8bitYCbCr41tile;
- break;
- case 0x22:
- img->put.contig = putcontig8bitYCbCr22tile;
- break;
- case 0x21:
- img->put.contig = putcontig8bitYCbCr21tile;
- break;
- case 0x12:
- img->put.contig = putcontig8bitYCbCr12tile;
- break;
- case 0x11:
- img->put.contig = putcontig8bitYCbCr11tile;
- break;
- }
- }
- }
- break;
- case PHOTOMETRIC_CIELAB:
- if (img->samplesperpixel == 3 && buildMap(img))
- {
- if (img->bitspersample == 8 || img->bitspersample == 16)
- img->put.contig = initCIELabConversion(img);
- break;
- }
- }
- return ((img->get != NULL) && (img->put.contig != NULL));
-}
-
-/*
- * Select the appropriate conversion routine for unpacked data.
- *
- * NB: we assume that unpacked single channel data is directed
- * to the "packed routines.
- */
-static int PickSeparateCase(TIFFRGBAImage *img)
-{
- img->get = TIFFIsTiled(img->tif) ? gtTileSeparate : gtStripSeparate;
- img->put.separate = NULL;
- switch (img->photometric)
- {
- case PHOTOMETRIC_MINISWHITE:
- case PHOTOMETRIC_MINISBLACK:
- /* greyscale images processed pretty much as RGB by gtTileSeparate
- */
- case PHOTOMETRIC_RGB:
- switch (img->bitspersample)
- {
- case 8:
- if (img->alpha == EXTRASAMPLE_ASSOCALPHA)
- img->put.separate = putRGBAAseparate8bittile;
- else if (img->alpha == EXTRASAMPLE_UNASSALPHA)
- {
- if (BuildMapUaToAa(img))
- img->put.separate = putRGBUAseparate8bittile;
- }
- else
- img->put.separate = putRGBseparate8bittile;
- break;
- case 16:
- if (img->alpha == EXTRASAMPLE_ASSOCALPHA)
- {
- if (BuildMapBitdepth16To8(img))
- img->put.separate = putRGBAAseparate16bittile;
- }
- else if (img->alpha == EXTRASAMPLE_UNASSALPHA)
- {
- if (BuildMapBitdepth16To8(img) && BuildMapUaToAa(img))
- img->put.separate = putRGBUAseparate16bittile;
- }
- else
- {
- if (BuildMapBitdepth16To8(img))
- img->put.separate = putRGBseparate16bittile;
- }
- break;
- }
- break;
- case PHOTOMETRIC_SEPARATED:
- if (img->bitspersample == 8 && img->samplesperpixel == 4)
- {
- img->alpha =
- 1; // Not alpha, but seems like the only way to get 4th band
- img->put.separate = putCMYKseparate8bittile;
- }
- break;
- case PHOTOMETRIC_YCBCR:
- if ((img->bitspersample == 8) && (img->samplesperpixel == 3))
- {
- if (initYCbCrConversion(img) != 0)
- {
- uint16_t hs, vs;
- TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRSUBSAMPLING,
- &hs, &vs);
- switch ((hs << 4) | vs)
- {
- case 0x11:
- img->put.separate = putseparate8bitYCbCr11tile;
- break;
- /* TODO: add other cases here */
- }
- }
- }
- break;
- }
- return ((img->get != NULL) && (img->put.separate != NULL));
-}
-
-static int BuildMapUaToAa(TIFFRGBAImage *img)
-{
- static const char module[] = "BuildMapUaToAa";
- uint8_t *m;
- uint16_t na, nv;
- assert(img->UaToAa == NULL);
- img->UaToAa = _TIFFmallocExt(img->tif, 65536);
- if (img->UaToAa == NULL)
- {
- TIFFErrorExtR(img->tif, module, "Out of memory");
- return (0);
- }
- m = img->UaToAa;
- for (na = 0; na < 256; na++)
- {
- for (nv = 0; nv < 256; nv++)
- *m++ = (uint8_t)((nv * na + 127) / 255);
- }
- return (1);
-}
-
-static int BuildMapBitdepth16To8(TIFFRGBAImage *img)
-{
- static const char module[] = "BuildMapBitdepth16To8";
- uint8_t *m;
- uint32_t n;
- assert(img->Bitdepth16To8 == NULL);
- img->Bitdepth16To8 = _TIFFmallocExt(img->tif, 65536);
- if (img->Bitdepth16To8 == NULL)
- {
- TIFFErrorExtR(img->tif, module, "Out of memory");
- return (0);
- }
- m = img->Bitdepth16To8;
- for (n = 0; n < 65536; n++)
- *m++ = (uint8_t)((n + 128) / 257);
- return (1);
-}
-
-/*
- * Read a whole strip off data from the file, and convert to RGBA form.
- * If this is the last strip, then it will only contain the portion of
- * the strip that is actually within the image space. The result is
- * organized in bottom to top form.
- */
-
-int TIFFReadRGBAStrip(TIFF *tif, uint32_t row, uint32_t *raster)
-
-{
- return TIFFReadRGBAStripExt(tif, row, raster, 0);
-}
-
-int TIFFReadRGBAStripExt(TIFF *tif, uint32_t row, uint32_t *raster,
- int stop_on_error)
-
-{
- char emsg[EMSG_BUF_SIZE] = "";
- TIFFRGBAImage img;
- int ok;
- uint32_t rowsperstrip, rows_to_read;
-
- if (TIFFIsTiled(tif))
- {
- TIFFErrorExtR(tif, TIFFFileName(tif),
- "Can't use TIFFReadRGBAStrip() with tiled file.");
- return (0);
- }
-
- TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);
-
- if (rowsperstrip == 0)
- {
- TIFFErrorExtR(tif, TIFFFileName(tif), "rowsperstrip is zero");
- return (0);
- }
-
- if ((row % rowsperstrip) != 0)
- {
- TIFFErrorExtR(
- tif, TIFFFileName(tif),
- "Row passed to TIFFReadRGBAStrip() must be first in a strip.");
- return (0);
- }
-
- if (TIFFRGBAImageOK(tif, emsg) &&
- TIFFRGBAImageBegin(&img, tif, stop_on_error, emsg))
- {
- if (row >= img.height)
- {
- TIFFErrorExtR(tif, TIFFFileName(tif),
- "Invalid row passed to TIFFReadRGBAStrip().");
- TIFFRGBAImageEnd(&img);
- return (0);
- }
-
- img.row_offset = row;
- img.col_offset = 0;
-
- if (row + rowsperstrip > img.height)
- rows_to_read = img.height - row;
- else
- rows_to_read = rowsperstrip;
-
- ok = TIFFRGBAImageGet(&img, raster, img.width, rows_to_read);
-
- TIFFRGBAImageEnd(&img);
- }
- else
- {
- TIFFErrorExtR(tif, TIFFFileName(tif), "%s", emsg);
- ok = 0;
- }
-
- return (ok);
-}
-
-/*
- * Read a whole tile off data from the file, and convert to RGBA form.
- * The returned RGBA data is organized from bottom to top of tile,
- * and may include zeroed areas if the tile extends off the image.
- */
-
-int TIFFReadRGBATile(TIFF *tif, uint32_t col, uint32_t row, uint32_t *raster)
-
-{
- return TIFFReadRGBATileExt(tif, col, row, raster, 0);
-}
-
-int TIFFReadRGBATileExt(TIFF *tif, uint32_t col, uint32_t row, uint32_t *raster,
- int stop_on_error)
-{
- char emsg[EMSG_BUF_SIZE] = "";
- TIFFRGBAImage img;
- int ok;
- uint32_t tile_xsize, tile_ysize;
- uint32_t read_xsize, read_ysize;
- uint32_t i_row;
-
- /*
- * Verify that our request is legal - on a tile file, and on a
- * tile boundary.
- */
-
- if (!TIFFIsTiled(tif))
- {
- TIFFErrorExtR(tif, TIFFFileName(tif),
- "Can't use TIFFReadRGBATile() with striped file.");
- return (0);
- }
-
- TIFFGetFieldDefaulted(tif, TIFFTAG_TILEWIDTH, &tile_xsize);
- TIFFGetFieldDefaulted(tif, TIFFTAG_TILELENGTH, &tile_ysize);
- if (tile_xsize == 0 || tile_ysize == 0)
- {
- TIFFErrorExtR(tif, TIFFFileName(tif),
- "tile_xsize or tile_ysize is zero");
- return (0);
- }
-
- if ((col % tile_xsize) != 0 || (row % tile_ysize) != 0)
- {
- TIFFErrorExtR(tif, TIFFFileName(tif),
- "Row/col passed to TIFFReadRGBATile() must be top"
- "left corner of a tile.");
- return (0);
- }
-
- /*
- * Setup the RGBA reader.
- */
-
- if (!TIFFRGBAImageOK(tif, emsg) ||
- !TIFFRGBAImageBegin(&img, tif, stop_on_error, emsg))
- {
- TIFFErrorExtR(tif, TIFFFileName(tif), "%s", emsg);
- return (0);
- }
-
- if (col >= img.width || row >= img.height)
- {
- TIFFErrorExtR(tif, TIFFFileName(tif),
- "Invalid row/col passed to TIFFReadRGBATile().");
- TIFFRGBAImageEnd(&img);
- return (0);
- }
-
- /*
- * The TIFFRGBAImageGet() function doesn't allow us to get off the
- * edge of the image, even to fill an otherwise valid tile. So we
- * figure out how much we can read, and fix up the tile buffer to
- * a full tile configuration afterwards.
- */
-
- if (row + tile_ysize > img.height)
- read_ysize = img.height - row;
- else
- read_ysize = tile_ysize;
-
- if (col + tile_xsize > img.width)
- read_xsize = img.width - col;
- else
- read_xsize = tile_xsize;
-
- /*
- * Read the chunk of imagery.
- */
-
- img.row_offset = row;
- img.col_offset = col;
-
- ok = TIFFRGBAImageGet(&img, raster, read_xsize, read_ysize);
-
- TIFFRGBAImageEnd(&img);
-
- /*
- * If our read was incomplete we will need to fix up the tile by
- * shifting the data around as if a full tile of data is being returned.
- *
- * This is all the more complicated because the image is organized in
- * bottom to top format.
- */
-
- if (read_xsize == tile_xsize && read_ysize == tile_ysize)
- return (ok);
-
- for (i_row = 0; i_row < read_ysize; i_row++)
- {
- memmove(raster + (size_t)(tile_ysize - i_row - 1) * tile_xsize,
- raster + (size_t)(read_ysize - i_row - 1) * read_xsize,
- read_xsize * sizeof(uint32_t));
- _TIFFmemset(raster + (size_t)(tile_ysize - i_row - 1) * tile_xsize +
- read_xsize,
- 0, sizeof(uint32_t) * (tile_xsize - read_xsize));
- }
-
- for (i_row = read_ysize; i_row < tile_ysize; i_row++)
- {
- _TIFFmemset(raster + (size_t)(tile_ysize - i_row - 1) * tile_xsize, 0,
- sizeof(uint32_t) * tile_xsize);
- }
-
- return (ok);
-}
diff --git a/contrib/libs/libtiff/tif_hash_set.c b/contrib/libs/libtiff/tif_hash_set.c
deleted file mode 100644
index 81dea3fcf2..0000000000
--- a/contrib/libs/libtiff/tif_hash_set.c
+++ /dev/null
@@ -1,603 +0,0 @@
-/**********************************************************************
- *
- * Name: tif_hash_set.c
- * Purpose: Hash set functions.
- * Author: Even Rouault, <even dot rouault at spatialys.com>
- *
- **********************************************************************
- * Copyright (c) 2008-2009, Even Rouault <even dot rouault at spatialys.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- ****************************************************************************/
-
-#include "tif_config.h"
-
-#include "tif_hash_set.h"
-
-#include <assert.h>
-#include <stdbool.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-/** List element structure. */
-typedef struct _TIFFList TIFFList;
-
-/** List element structure. */
-struct _TIFFList
-{
- /*! Pointer to the data object. Should be allocated and freed by the
- * caller.
- * */
- void *pData;
- /*! Pointer to the next element in list. NULL, if current element is the
- * last one.
- */
- struct _TIFFList *psNext;
-};
-
-struct _TIFFHashSet
-{
- TIFFHashSetHashFunc fnHashFunc;
- TIFFHashSetEqualFunc fnEqualFunc;
- TIFFHashSetFreeEltFunc fnFreeEltFunc;
- TIFFList **tabList;
- int nSize;
- int nIndiceAllocatedSize;
- int nAllocatedSize;
- TIFFList *psRecyclingList;
- int nRecyclingListSize;
- bool bRehash;
-#ifdef HASH_DEBUG
- int nCollisions;
-#endif
-};
-
-static const int anPrimes[] = {
- 53, 97, 193, 389, 769, 1543, 3079,
- 6151, 12289, 24593, 49157, 98317, 196613, 393241,
- 786433, 1572869, 3145739, 6291469, 12582917, 25165843, 50331653,
- 100663319, 201326611, 402653189, 805306457, 1610612741};
-
-/************************************************************************/
-/* TIFFHashSetHashPointer() */
-/************************************************************************/
-
-/**
- * Hash function for an arbitrary pointer
- *
- * @param elt the arbitrary pointer to hash
- *
- * @return the hash value of the pointer
- */
-
-static unsigned long TIFFHashSetHashPointer(const void *elt)
-{
- return (unsigned long)(uintptr_t)((void *)(elt));
-}
-
-/************************************************************************/
-/* TIFFHashSetEqualPointer() */
-/************************************************************************/
-
-/**
- * Equality function for arbitrary pointers
- *
- * @param elt1 the first arbitrary pointer to compare
- * @param elt2 the second arbitrary pointer to compare
- *
- * @return true if the pointers are equal
- */
-
-static bool TIFFHashSetEqualPointer(const void *elt1, const void *elt2)
-{
- return elt1 == elt2;
-}
-
-/************************************************************************/
-/* TIFFHashSetNew() */
-/************************************************************************/
-
-/**
- * Creates a new hash set
- *
- * The hash function must return a hash value for the elements to insert.
- * If fnHashFunc is NULL, TIFFHashSetHashPointer will be used.
- *
- * The equal function must return if two elements are equal.
- * If fnEqualFunc is NULL, TIFFHashSetEqualPointer will be used.
- *
- * The free function is used to free elements inserted in the hash set,
- * when the hash set is destroyed, when elements are removed or replaced.
- * If fnFreeEltFunc is NULL, elements inserted into the hash set will not be
- * freed.
- *
- * @param fnHashFunc hash function. May be NULL.
- * @param fnEqualFunc equal function. May be NULL.
- * @param fnFreeEltFunc element free function. May be NULL.
- *
- * @return a new hash set
- */
-
-TIFFHashSet *TIFFHashSetNew(TIFFHashSetHashFunc fnHashFunc,
- TIFFHashSetEqualFunc fnEqualFunc,
- TIFFHashSetFreeEltFunc fnFreeEltFunc)
-{
- TIFFHashSet *set = (TIFFHashSet *)malloc(sizeof(TIFFHashSet));
- if (set == NULL)
- return NULL;
- set->fnHashFunc = fnHashFunc ? fnHashFunc : TIFFHashSetHashPointer;
- set->fnEqualFunc = fnEqualFunc ? fnEqualFunc : TIFFHashSetEqualPointer;
- set->fnFreeEltFunc = fnFreeEltFunc;
- set->nSize = 0;
- set->tabList = (TIFFList **)(calloc(53, sizeof(TIFFList *)));
- if (set->tabList == NULL)
- {
- free(set);
- return NULL;
- }
- set->nIndiceAllocatedSize = 0;
- set->nAllocatedSize = 53;
- set->psRecyclingList = NULL;
- set->nRecyclingListSize = 0;
- set->bRehash = false;
-#ifdef HASH_DEBUG
- set->nCollisions = 0;
-#endif
- return set;
-}
-
-/************************************************************************/
-/* TIFFHashSetSize() */
-/************************************************************************/
-
-/**
- * Returns the number of elements inserted in the hash set
- *
- * Note: this is not the internal size of the hash set
- *
- * @param set the hash set
- *
- * @return the number of elements in the hash set
- */
-
-int TIFFHashSetSize(const TIFFHashSet *set)
-{
- assert(set != NULL);
- return set->nSize;
-}
-
-/************************************************************************/
-/* TIFFHashSetGetNewListElt() */
-/************************************************************************/
-
-static TIFFList *TIFFHashSetGetNewListElt(TIFFHashSet *set)
-{
- if (set->psRecyclingList)
- {
- TIFFList *psRet = set->psRecyclingList;
- psRet->pData = NULL;
- set->nRecyclingListSize--;
- set->psRecyclingList = psRet->psNext;
- return psRet;
- }
-
- return (TIFFList *)malloc(sizeof(TIFFList));
-}
-
-/************************************************************************/
-/* TIFFHashSetReturnListElt() */
-/************************************************************************/
-
-static void TIFFHashSetReturnListElt(TIFFHashSet *set, TIFFList *psList)
-{
- if (set->nRecyclingListSize < 128)
- {
- psList->psNext = set->psRecyclingList;
- set->psRecyclingList = psList;
- set->nRecyclingListSize++;
- }
- else
- {
- free(psList);
- }
-}
-
-/************************************************************************/
-/* TIFFHashSetClearInternal() */
-/************************************************************************/
-
-static void TIFFHashSetClearInternal(TIFFHashSet *set, bool bFinalize)
-{
- assert(set != NULL);
- for (int i = 0; i < set->nAllocatedSize; i++)
- {
- TIFFList *cur = set->tabList[i];
- while (cur)
- {
- if (set->fnFreeEltFunc)
- set->fnFreeEltFunc(cur->pData);
- TIFFList *psNext = cur->psNext;
- if (bFinalize)
- free(cur);
- else
- TIFFHashSetReturnListElt(set, cur);
- cur = psNext;
- }
- set->tabList[i] = NULL;
- }
- set->bRehash = false;
-}
-
-/************************************************************************/
-/* TIFFListDestroy() */
-/************************************************************************/
-
-/**
- * Destroy a list. Caller responsible for freeing data objects contained in
- * list elements.
- *
- * @param psList pointer to list head.
- *
- */
-
-static void TIFFListDestroy(TIFFList *psList)
-{
- TIFFList *psCurrent = psList;
-
- while (psCurrent)
- {
- TIFFList *const psNext = psCurrent->psNext;
- free(psCurrent);
- psCurrent = psNext;
- }
-}
-
-/************************************************************************/
-/* TIFFHashSetDestroy() */
-/************************************************************************/
-
-/**
- * Destroys an allocated hash set.
- *
- * This function also frees the elements if a free function was
- * provided at the creation of the hash set.
- *
- * @param set the hash set
- */
-
-void TIFFHashSetDestroy(TIFFHashSet *set)
-{
- if (set)
- {
- TIFFHashSetClearInternal(set, true);
- free(set->tabList);
- TIFFListDestroy(set->psRecyclingList);
- free(set);
- }
-}
-
-#ifdef notused
-/************************************************************************/
-/* TIFFHashSetClear() */
-/************************************************************************/
-
-/**
- * Clear all elements from a hash set.
- *
- * This function also frees the elements if a free function was
- * provided at the creation of the hash set.
- *
- * @param set the hash set
- */
-
-void TIFFHashSetClear(TIFFHashSet *set)
-{
- TIFFHashSetClearInternal(set, false);
- set->nIndiceAllocatedSize = 0;
- set->nAllocatedSize = 53;
-#ifdef HASH_DEBUG
- set->nCollisions = 0;
-#endif
- set->nSize = 0;
-}
-
-/************************************************************************/
-/* TIFFHashSetForeach() */
-/************************************************************************/
-
-/**
- * Walk through the hash set and runs the provided function on all the
- * elements
- *
- * This function is provided the user_data argument of TIFFHashSetForeach.
- * It must return true to go on the walk through the hash set, or FALSE to
- * make it stop.
- *
- * Note : the structure of the hash set must *NOT* be modified during the
- * walk.
- *
- * @param set the hash set.
- * @param fnIterFunc the function called on each element.
- * @param user_data the user data provided to the function.
- */
-
-void TIFFHashSetForeach(TIFFHashSet *set, TIFFHashSetIterEltFunc fnIterFunc,
- void *user_data)
-{
- assert(set != NULL);
- if (!fnIterFunc)
- return;
-
- for (int i = 0; i < set->nAllocatedSize; i++)
- {
- TIFFList *cur = set->tabList[i];
- while (cur)
- {
- if (!fnIterFunc(cur->pData, user_data))
- return;
-
- cur = cur->psNext;
- }
- }
-}
-#endif
-
-/************************************************************************/
-/* TIFFHashSetRehash() */
-/************************************************************************/
-
-static bool TIFFHashSetRehash(TIFFHashSet *set)
-{
- int nNewAllocatedSize = anPrimes[set->nIndiceAllocatedSize];
- TIFFList **newTabList =
- (TIFFList **)(calloc(nNewAllocatedSize, sizeof(TIFFList *)));
- if (newTabList == NULL)
- return false;
-#ifdef HASH_DEBUG
- TIFFDebug("TIFFHASH",
- "hashSet=%p, nSize=%d, nCollisions=%d, "
- "fCollisionRate=%.02f",
- set, set->nSize, set->nCollisions,
- set->nCollisions * 100.0 / set->nSize);
- set->nCollisions = 0;
-#endif
- for (int i = 0; i < set->nAllocatedSize; i++)
- {
- TIFFList *cur = set->tabList[i];
- while (cur)
- {
- const unsigned long nNewHashVal =
- set->fnHashFunc(cur->pData) % nNewAllocatedSize;
-#ifdef HASH_DEBUG
- if (newTabList[nNewHashVal])
- set->nCollisions++;
-#endif
- TIFFList *psNext = cur->psNext;
- cur->psNext = newTabList[nNewHashVal];
- newTabList[nNewHashVal] = cur;
- cur = psNext;
- }
- }
- free(set->tabList);
- set->tabList = newTabList;
- set->nAllocatedSize = nNewAllocatedSize;
- set->bRehash = false;
- return true;
-}
-
-/************************************************************************/
-/* TIFFHashSetFindPtr() */
-/************************************************************************/
-
-static void **TIFFHashSetFindPtr(TIFFHashSet *set, const void *elt)
-{
- const unsigned long nHashVal = set->fnHashFunc(elt) % set->nAllocatedSize;
- TIFFList *cur = set->tabList[nHashVal];
- while (cur)
- {
- if (set->fnEqualFunc(cur->pData, elt))
- return &cur->pData;
- cur = cur->psNext;
- }
- return NULL;
-}
-
-/************************************************************************/
-/* TIFFHashSetInsert() */
-/************************************************************************/
-
-/**
- * Inserts an element into a hash set.
- *
- * If the element was already inserted in the hash set, the previous
- * element is replaced by the new element. If a free function was provided,
- * it is used to free the previously inserted element
- *
- * @param set the hash set
- * @param elt the new element to insert in the hash set
- *
- * @return true if success. If false is returned, elt has not been inserted,
- * but TIFFHashSetInsert() will have run the free function if provided.
- */
-
-bool TIFFHashSetInsert(TIFFHashSet *set, void *elt)
-{
- assert(set != NULL);
- void **pElt = TIFFHashSetFindPtr(set, elt);
- if (pElt)
- {
- if (set->fnFreeEltFunc)
- set->fnFreeEltFunc(*pElt);
-
- *pElt = elt;
- return true;
- }
-
- if (set->nSize >= 2 * set->nAllocatedSize / 3 ||
- (set->bRehash && set->nIndiceAllocatedSize > 0 &&
- set->nSize <= set->nAllocatedSize / 2))
- {
- set->nIndiceAllocatedSize++;
- if (!TIFFHashSetRehash(set))
- {
- set->nIndiceAllocatedSize--;
- if (set->fnFreeEltFunc)
- set->fnFreeEltFunc(elt);
- return false;
- }
- }
-
- const unsigned long nHashVal = set->fnHashFunc(elt) % set->nAllocatedSize;
-#ifdef HASH_DEBUG
- if (set->tabList[nHashVal])
- set->nCollisions++;
-#endif
-
- TIFFList *new_elt = TIFFHashSetGetNewListElt(set);
- if (new_elt == NULL)
- {
- if (set->fnFreeEltFunc)
- set->fnFreeEltFunc(elt);
- return false;
- }
- new_elt->pData = elt;
- new_elt->psNext = set->tabList[nHashVal];
- set->tabList[nHashVal] = new_elt;
- set->nSize++;
-
- return true;
-}
-
-/************************************************************************/
-/* TIFFHashSetLookup() */
-/************************************************************************/
-
-/**
- * Returns the element found in the hash set corresponding to the element to
- * look up The element must not be modified.
- *
- * @param set the hash set
- * @param elt the element to look up in the hash set
- *
- * @return the element found in the hash set or NULL
- */
-
-void *TIFFHashSetLookup(TIFFHashSet *set, const void *elt)
-{
- assert(set != NULL);
- void **pElt = TIFFHashSetFindPtr(set, elt);
- if (pElt)
- return *pElt;
-
- return NULL;
-}
-
-/************************************************************************/
-/* TIFFHashSetRemoveInternal() */
-/************************************************************************/
-
-static bool TIFFHashSetRemoveInternal(TIFFHashSet *set, const void *elt,
- bool bDeferRehash)
-{
- assert(set != NULL);
- if (set->nIndiceAllocatedSize > 0 && set->nSize <= set->nAllocatedSize / 2)
- {
- set->nIndiceAllocatedSize--;
- if (bDeferRehash)
- set->bRehash = true;
- else
- {
- if (!TIFFHashSetRehash(set))
- {
- set->nIndiceAllocatedSize++;
- return false;
- }
- }
- }
-
- int nHashVal = (int)(set->fnHashFunc(elt) % set->nAllocatedSize);
- TIFFList *cur = set->tabList[nHashVal];
- TIFFList *prev = NULL;
- while (cur)
- {
- if (set->fnEqualFunc(cur->pData, elt))
- {
- if (prev)
- prev->psNext = cur->psNext;
- else
- set->tabList[nHashVal] = cur->psNext;
-
- if (set->fnFreeEltFunc)
- set->fnFreeEltFunc(cur->pData);
-
- TIFFHashSetReturnListElt(set, cur);
-#ifdef HASH_DEBUG
- if (set->tabList[nHashVal])
- set->nCollisions--;
-#endif
- set->nSize--;
- return true;
- }
- prev = cur;
- cur = cur->psNext;
- }
- return false;
-}
-
-/************************************************************************/
-/* TIFFHashSetRemove() */
-/************************************************************************/
-
-/**
- * Removes an element from a hash set
- *
- * @param set the hash set
- * @param elt the new element to remove from the hash set
- *
- * @return true if the element was in the hash set
- */
-
-bool TIFFHashSetRemove(TIFFHashSet *set, const void *elt)
-{
- return TIFFHashSetRemoveInternal(set, elt, false);
-}
-
-#ifdef notused
-/************************************************************************/
-/* TIFFHashSetRemoveDeferRehash() */
-/************************************************************************/
-
-/**
- * Removes an element from a hash set.
- *
- * This will defer potential rehashing of the set to later calls to
- * TIFFHashSetInsert() or TIFFHashSetRemove().
- *
- * @param set the hash set
- * @param elt the new element to remove from the hash set
- *
- * @return true if the element was in the hash set
- */
-
-bool TIFFHashSetRemoveDeferRehash(TIFFHashSet *set, const void *elt)
-{
- return TIFFHashSetRemoveInternal(set, elt, true);
-}
-#endif
diff --git a/contrib/libs/libtiff/tif_hash_set.h b/contrib/libs/libtiff/tif_hash_set.h
deleted file mode 100644
index f60e2c675e..0000000000
--- a/contrib/libs/libtiff/tif_hash_set.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/**********************************************************************
- * $Id$
- *
- * Name: tif_hash_set.h
- * Project: TIFF - Common Portability Library
- * Purpose: Hash set functions.
- * Author: Even Rouault, <even dot rouault at spatialys.com>
- *
- **********************************************************************
- * Copyright (c) 2008-2009, Even Rouault <even dot rouault at spatialys.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- ****************************************************************************/
-
-#ifndef TIFF_HASH_SET_H_INCLUDED
-#define TIFF_HASH_SET_H_INCLUDED
-
-#include <stdbool.h>
-
-/**
- * \file tif_hash_set.h
- *
- * Hash set implementation.
- *
- * An hash set is a data structure that holds elements that are unique
- * according to a comparison function. Operations on the hash set, such as
- * insertion, removal or lookup, are supposed to be fast if an efficient
- * "hash" function is provided.
- */
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /* Types */
-
- /** Opaque type for a hash set */
- typedef struct _TIFFHashSet TIFFHashSet;
-
- /** TIFFHashSetHashFunc */
- typedef unsigned long (*TIFFHashSetHashFunc)(const void *elt);
-
- /** TIFFHashSetEqualFunc */
- typedef bool (*TIFFHashSetEqualFunc)(const void *elt1, const void *elt2);
-
- /** TIFFHashSetFreeEltFunc */
- typedef void (*TIFFHashSetFreeEltFunc)(void *elt);
-
- /* Functions */
-
- TIFFHashSet *TIFFHashSetNew(TIFFHashSetHashFunc fnHashFunc,
- TIFFHashSetEqualFunc fnEqualFunc,
- TIFFHashSetFreeEltFunc fnFreeEltFunc);
-
- void TIFFHashSetDestroy(TIFFHashSet *set);
-
- int TIFFHashSetSize(const TIFFHashSet *set);
-
-#ifdef notused
- void TIFFHashSetClear(TIFFHashSet *set);
-
- /** TIFFHashSetIterEltFunc */
- typedef int (*TIFFHashSetIterEltFunc)(void *elt, void *user_data);
-
- void TIFFHashSetForeach(TIFFHashSet *set, TIFFHashSetIterEltFunc fnIterFunc,
- void *user_data);
-#endif
-
- bool TIFFHashSetInsert(TIFFHashSet *set, void *elt);
-
- void *TIFFHashSetLookup(TIFFHashSet *set, const void *elt);
-
- bool TIFFHashSetRemove(TIFFHashSet *set, const void *elt);
-
-#ifdef notused
- bool TIFFHashSetRemoveDeferRehash(TIFFHashSet *set, const void *elt);
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* TIFF_HASH_SET_H_INCLUDED */
diff --git a/contrib/libs/libtiff/tif_jbig.c b/contrib/libs/libtiff/tif_jbig.c
deleted file mode 100644
index d0fae1f124..0000000000
--- a/contrib/libs/libtiff/tif_jbig.c
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * Copyright (c) 1988-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-/*
- * TIFF Library.
- *
- * JBIG Compression Algorithm Support.
- * Contributed by Lee Howard <faxguy@deanox.com>
- *
- */
-
-#include "tiffiop.h"
-
-#ifdef JBIG_SUPPORT
-#error #include "jbig.h"
-
-static int JBIGSetupDecode(TIFF *tif)
-{
- if (TIFFNumberOfStrips(tif) != 1)
- {
- TIFFErrorExtR(tif, "JBIG",
- "Multistrip images not supported in decoder");
- return 0;
- }
-
- return 1;
-}
-
-static int JBIGDecode(TIFF *tif, uint8_t *buffer, tmsize_t size, uint16_t s)
-{
- struct jbg_dec_state decoder;
- int decodeStatus = 0;
- unsigned char *pImage = NULL;
- unsigned long decodedSize;
- (void)s;
-
- if (isFillOrder(tif, tif->tif_dir.td_fillorder))
- {
- TIFFReverseBits(tif->tif_rawcp, tif->tif_rawcc);
- }
-
- jbg_dec_init(&decoder);
-
-#if defined(HAVE_JBG_NEWLEN)
- jbg_newlen(tif->tif_rawcp, (size_t)tif->tif_rawcc);
- /*
- * I do not check the return status of jbg_newlen because even if this
- * function fails it does not necessarily mean that decoding the image
- * will fail. It is generally only needed for received fax images
- * that do not contain the actual length of the image in the BIE
- * header. I do not log when an error occurs because that will cause
- * problems when converting JBIG encoded TIFF's to
- * PostScript. As long as the actual image length is contained in the
- * BIE header jbg_dec_in should succeed.
- */
-#endif /* HAVE_JBG_NEWLEN */
-
- decodeStatus = jbg_dec_in(&decoder, (unsigned char *)tif->tif_rawcp,
- (size_t)tif->tif_rawcc, NULL);
- if (JBG_EOK != decodeStatus)
- {
- /*
- * XXX: JBG_EN constant was defined in pre-2.0 releases of the
- * JBIG-KIT. Since the 2.0 the error reporting functions were
- * changed. We will handle both cases here.
- */
- TIFFErrorExtR(tif, "JBIG", "Error (%d) decoding: %s", decodeStatus,
-#if defined(JBG_EN)
- jbg_strerror(decodeStatus, JBG_EN)
-#else
- jbg_strerror(decodeStatus)
-#endif
- );
- memset(buffer, 0, (size_t)size);
- jbg_dec_free(&decoder);
- return 0;
- }
-
- decodedSize = jbg_dec_getsize(&decoder);
- if ((tmsize_t)decodedSize < size)
- {
- memset(buffer + decodedSize, 0, (size_t)(size - decodedSize));
- TIFFWarningExtR(tif, "JBIG",
- "Only decoded %lu bytes, whereas %" TIFF_SSIZE_FORMAT
- " requested",
- decodedSize, size);
- }
- else if ((tmsize_t)decodedSize > size)
- {
- TIFFErrorExtR(tif, "JBIG",
- "Decoded %lu bytes, whereas %" TIFF_SSIZE_FORMAT
- " were requested",
- decodedSize, size);
- jbg_dec_free(&decoder);
- return 0;
- }
- pImage = jbg_dec_getimage(&decoder, 0);
- _TIFFmemcpy(buffer, pImage, decodedSize);
- jbg_dec_free(&decoder);
-
- tif->tif_rawcp += tif->tif_rawcc;
- tif->tif_rawcc = 0;
-
- return 1;
-}
-
-static int JBIGSetupEncode(TIFF *tif)
-{
- if (TIFFNumberOfStrips(tif) != 1)
- {
- TIFFErrorExtR(tif, "JBIG",
- "Multistrip images not supported in encoder");
- return 0;
- }
-
- return 1;
-}
-
-static int JBIGCopyEncodedData(TIFF *tif, unsigned char *pp, size_t cc,
- uint16_t s)
-{
- (void)s;
- while (cc > 0)
- {
- tmsize_t n = (tmsize_t)cc;
-
- if (tif->tif_rawcc + n > tif->tif_rawdatasize)
- {
- n = tif->tif_rawdatasize - tif->tif_rawcc;
- }
-
- assert(n > 0);
- _TIFFmemcpy(tif->tif_rawcp, pp, n);
- tif->tif_rawcp += n;
- tif->tif_rawcc += n;
- pp += n;
- cc -= (size_t)n;
- if (tif->tif_rawcc >= tif->tif_rawdatasize && !TIFFFlushData1(tif))
- {
- return (-1);
- }
- }
-
- return (1);
-}
-
-static void JBIGOutputBie(unsigned char *buffer, size_t len, void *userData)
-{
- TIFF *tif = (TIFF *)userData;
-
- if (isFillOrder(tif, tif->tif_dir.td_fillorder))
- {
- TIFFReverseBits(buffer, (tmsize_t)len);
- }
-
- JBIGCopyEncodedData(tif, buffer, len, 0);
-}
-
-static int JBIGEncode(TIFF *tif, uint8_t *buffer, tmsize_t size, uint16_t s)
-{
- TIFFDirectory *dir = &tif->tif_dir;
- struct jbg_enc_state encoder;
-
- (void)size, (void)s;
-
- jbg_enc_init(&encoder, dir->td_imagewidth, dir->td_imagelength, 1, &buffer,
- JBIGOutputBie, tif);
- /*
- * jbg_enc_out does the "real" encoding. As data is encoded,
- * JBIGOutputBie is called, which writes the data to the directory.
- */
- jbg_enc_out(&encoder);
- jbg_enc_free(&encoder);
-
- return 1;
-}
-
-int TIFFInitJBIG(TIFF *tif, int scheme)
-{
- (void)scheme;
- assert(scheme == COMPRESSION_JBIG);
-
- /*
- * These flags are set so the JBIG Codec can control when to reverse
- * bits and when not to and to allow the jbig decoder and bit reverser
- * to write to memory when necessary.
- */
- tif->tif_flags |= TIFF_NOBITREV;
- tif->tif_flags &= ~TIFF_MAPPED;
- /* We may have read from a previous IFD and thus set TIFF_BUFFERMMAP and
- * cleared TIFF_MYBUFFER. It is necessary to restore them to their initial
- * value to be consistent with the state of a non-memory mapped file.
- */
- if (tif->tif_flags & TIFF_BUFFERMMAP)
- {
- tif->tif_rawdata = NULL;
- tif->tif_rawdatasize = 0;
- tif->tif_flags &= ~TIFF_BUFFERMMAP;
- tif->tif_flags |= TIFF_MYBUFFER;
- }
-
- /* Setup the function pointers for encode, decode, and cleanup. */
- tif->tif_setupdecode = JBIGSetupDecode;
- tif->tif_decodestrip = JBIGDecode;
-
- tif->tif_setupencode = JBIGSetupEncode;
- tif->tif_encodestrip = JBIGEncode;
-
- return 1;
-}
-
-#endif /* JBIG_SUPPORT */
diff --git a/contrib/libs/libtiff/tif_jpeg.c b/contrib/libs/libtiff/tif_jpeg.c
deleted file mode 100644
index 10aed54635..0000000000
--- a/contrib/libs/libtiff/tif_jpeg.c
+++ /dev/null
@@ -1,2898 +0,0 @@
-/*
- * Copyright (c) 1994-1997 Sam Leffler
- * Copyright (c) 1994-1997 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-#define WIN32_LEAN_AND_MEAN
-#define VC_EXTRALEAN
-
-#include "tiffiop.h"
-#include <stdlib.h>
-
-#ifdef JPEG_SUPPORT
-
-/*
- * TIFF Library
- *
- * JPEG Compression support per TIFF Technical Note #2
- * (*not* per the original TIFF 6.0 spec).
- *
- * This file is simply an interface to the libjpeg library written by
- * the Independent JPEG Group. You need release 5 or later of the IJG
- * code, which you can find on the Internet at ftp.uu.net:/graphics/jpeg/.
- *
- * Contributed by Tom Lane <tgl@sss.pgh.pa.us>.
- */
-#include <setjmp.h>
-
-/* Settings that are independent of libjpeg ABI. Used when reinitializing the */
-/* JPEGState from libjpegs 8 bit to libjpeg 12 bits, which have potentially */
-/* different ABI */
-typedef struct
-{
- TIFFVGetMethod vgetparent; /* super-class method */
- TIFFVSetMethod vsetparent; /* super-class method */
- TIFFPrintMethod printdir; /* super-class method */
- TIFFStripMethod defsparent; /* super-class method */
- TIFFTileMethod deftparent; /* super-class method */
-
- /* pseudo-tag fields */
- void *jpegtables; /* JPEGTables tag value, or NULL */
- uint32_t jpegtables_length; /* number of bytes in same */
- int jpegquality; /* Compression quality level */
- int jpegcolormode; /* Auto RGB<=>YCbCr convert? */
- int jpegtablesmode; /* What to put in JPEGTables */
-
- int ycbcrsampling_fetched;
- int max_allowed_scan_number;
- int has_warned_about_progressive_mode;
-} JPEGOtherSettings;
-
-int TIFFFillStrip(TIFF *tif, uint32_t strip);
-int TIFFFillTile(TIFF *tif, uint32_t tile);
-int TIFFReInitJPEG_12(TIFF *tif, const JPEGOtherSettings *otherSettings,
- int scheme, int is_encode);
-int TIFFJPEGIsFullStripRequired_12(TIFF *tif);
-
-#include "jerror.h"
-#include "jpeglib.h"
-
-/* Do optional compile-time version check */
-#if defined(EXPECTED_JPEG_LIB_VERSION) && !defined(LIBJPEG_12_PATH)
-#if EXPECTED_JPEG_LIB_VERSION != JPEG_LIB_VERSION
-#error EXPECTED_JPEG_LIB_VERSION != JPEG_LIB_VERSION
-#endif
-#endif
-
-/*
- * Do we want to do special processing suitable for when JSAMPLE is a
- * 16bit value?
- */
-
-/* HAVE_JPEGTURBO_DUAL_MODE_8_12 is defined for libjpeg-turbo >= 3.0 which
- * adds a dual-mode 8/12 bit API in the same library.
- */
-
-#if defined(HAVE_JPEGTURBO_DUAL_MODE_8_12)
-#define JPEG_DUAL_MODE_8_12
-/* Start by undefining BITS_IN_JSAMPLE which is always set to 8 in libjpeg-turbo
- * >= 3.0 Cf
- * https://github.com/libjpeg-turbo/libjpeg-turbo/commit/8b9bc4b9635a2a047fb23ebe70c9acd728d3f99b
- */
-#undef BITS_IN_JSAMPLE
-/* libjpeg-turbo >= 3.0 adds J12xxxx datatypes for the 12-bit mode. */
-#if defined(FROM_TIF_JPEG_12)
-#define BITS_IN_JSAMPLE 12
-#define TIFF_JSAMPLE J12SAMPLE
-#define TIFF_JSAMPARRAY J12SAMPARRAY
-#define TIFF_JSAMPIMAGE J12SAMPIMAGE
-#define TIFF_JSAMPROW J12SAMPROW
-#else
-#define BITS_IN_JSAMPLE 8
-#define TIFF_JSAMPLE JSAMPLE
-#define TIFF_JSAMPARRAY JSAMPARRAY
-#define TIFF_JSAMPIMAGE JSAMPIMAGE
-#define TIFF_JSAMPROW JSAMPROW
-#endif
-#else
-#define TIFF_JSAMPLE JSAMPLE
-#define TIFF_JSAMPARRAY JSAMPARRAY
-#define TIFF_JSAMPIMAGE JSAMPIMAGE
-#define TIFF_JSAMPROW JSAMPROW
-#endif
-
-#if defined(JPEG_LIB_MK1)
-#define JPEG_LIB_MK1_OR_12BIT 1
-#elif BITS_IN_JSAMPLE == 12
-#define JPEG_LIB_MK1_OR_12BIT 1
-#endif
-
-/*
- * We are using width_in_blocks which is supposed to be private to
- * libjpeg. Unfortunately, the libjpeg delivered with Cygwin has
- * renamed this member to width_in_data_units. Since the header has
- * also renamed a define, use that unique define name in order to
- * detect the problem header and adjust to suit.
- */
-#if defined(D_MAX_DATA_UNITS_IN_MCU)
-#define width_in_blocks width_in_data_units
-#endif
-
-/*
- * On some machines it may be worthwhile to use _setjmp or sigsetjmp
- * in place of plain setjmp. These macros will make it easier.
- */
-#define SETJMP(jbuf) setjmp(jbuf)
-#define LONGJMP(jbuf, code) longjmp(jbuf, code)
-#define JMP_BUF jmp_buf
-
-#ifndef TIFF_jpeg_destination_mgr_defined
-#define TIFF_jpeg_destination_mgr_defined
-typedef struct jpeg_destination_mgr jpeg_destination_mgr;
-#endif
-
-#ifndef TIFF_jpeg_source_mgr_defined
-#define TIFF_jpeg_source_mgr_defined
-typedef struct jpeg_source_mgr jpeg_source_mgr;
-#endif
-
-#ifndef TIFF_jpeg_error_mgr_defined
-#define TIFF_jpeg_error_mgr_defined
-typedef struct jpeg_error_mgr jpeg_error_mgr;
-#endif
-
-/*
- * State block for each open TIFF file using
- * libjpeg to do JPEG compression/decompression.
- *
- * libjpeg's visible state is either a jpeg_compress_struct
- * or jpeg_decompress_struct depending on which way we
- * are going. comm can be used to refer to the fields
- * which are common to both.
- *
- * NB: cinfo is required to be the first member of JPEGState,
- * so we can safely cast JPEGState* -> jpeg_xxx_struct*
- * and vice versa!
- */
-typedef struct
-{
- union
- {
- struct jpeg_compress_struct c;
- struct jpeg_decompress_struct d;
- struct jpeg_common_struct comm;
- } cinfo; /* NB: must be first */
- int cinfo_initialized;
-
- jpeg_error_mgr err; /* libjpeg error manager */
- JMP_BUF exit_jmpbuf; /* for catching libjpeg failures */
-
- struct jpeg_progress_mgr progress;
- /*
- * The following two members could be a union, but
- * they're small enough that it's not worth the effort.
- */
- jpeg_destination_mgr dest; /* data dest for compression */
- jpeg_source_mgr src; /* data source for decompression */
- /* private state */
- TIFF *tif; /* back link needed by some code */
- uint16_t photometric; /* copy of PhotometricInterpretation */
- uint16_t h_sampling; /* luminance sampling factors */
- uint16_t v_sampling;
- tmsize_t bytesperline; /* decompressed bytes per scanline */
- /* pointers to intermediate buffers when processing downsampled data */
- TIFF_JSAMPARRAY ds_buffer[MAX_COMPONENTS];
- int scancount; /* number of "scanlines" accumulated */
- int samplesperclump;
-
- JPEGOtherSettings otherSettings;
-} JPEGState;
-
-#define JState(tif) ((JPEGState *)(tif)->tif_data)
-
-static int JPEGDecode(TIFF *tif, uint8_t *buf, tmsize_t cc, uint16_t s);
-static int JPEGDecodeRaw(TIFF *tif, uint8_t *buf, tmsize_t cc, uint16_t s);
-static int JPEGEncode(TIFF *tif, uint8_t *buf, tmsize_t cc, uint16_t s);
-static int JPEGEncodeRaw(TIFF *tif, uint8_t *buf, tmsize_t cc, uint16_t s);
-static int JPEGInitializeLibJPEG(TIFF *tif, int decode);
-static int DecodeRowError(TIFF *tif, uint8_t *buf, tmsize_t cc, uint16_t s);
-
-#define FIELD_JPEGTABLES (FIELD_CODEC + 0)
-
-static const TIFFField jpegFields[] = {
- {TIFFTAG_JPEGTABLES, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8,
- TIFF_SETGET_C32_UINT8, FIELD_JPEGTABLES, FALSE, TRUE, "JPEGTables", NULL},
- {TIFFTAG_JPEGQUALITY, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT,
- TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "", NULL},
- {TIFFTAG_JPEGCOLORMODE, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT,
- TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, FALSE, FALSE, "", NULL},
- {TIFFTAG_JPEGTABLESMODE, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT,
- TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, FALSE, FALSE, "", NULL}};
-
-/*
- * libjpeg interface layer.
- *
- * We use setjmp/longjmp to return control to libtiff
- * when a fatal error is encountered within the JPEG
- * library. We also direct libjpeg error and warning
- * messages through the appropriate libtiff handlers.
- */
-
-/*
- * Error handling routines (these replace corresponding
- * IJG routines from jerror.c). These are used for both
- * compression and decompression.
- */
-static void TIFFjpeg_error_exit(j_common_ptr cinfo)
-{
- JPEGState *sp = (JPEGState *)cinfo; /* NB: cinfo assumed first */
- char buffer[JMSG_LENGTH_MAX];
-
- (*cinfo->err->format_message)(cinfo, buffer);
- TIFFErrorExtR(sp->tif, "JPEGLib", "%s",
- buffer); /* display the error message */
- jpeg_abort(cinfo); /* clean up libjpeg state */
- LONGJMP(sp->exit_jmpbuf, 1); /* return to libtiff caller */
-}
-
-/*
- * This routine is invoked only for warning messages,
- * since error_exit does its own thing and trace_level
- * is never set > 0.
- */
-static void TIFFjpeg_output_message(j_common_ptr cinfo)
-{
- char buffer[JMSG_LENGTH_MAX];
-
- (*cinfo->err->format_message)(cinfo, buffer);
- TIFFWarningExtR(((JPEGState *)cinfo)->tif, "JPEGLib", "%s", buffer);
-}
-
-/* Avoid the risk of denial-of-service on crafted JPEGs with an insane */
-/* number of scans. */
-/* See
- * http://www.libjpeg-turbo.org/pmwiki/uploads/About/TwoIssueswiththeJPEGStandard.pdf
- */
-static void TIFFjpeg_progress_monitor(j_common_ptr cinfo)
-{
- JPEGState *sp = (JPEGState *)cinfo; /* NB: cinfo assumed first */
- if (cinfo->is_decompressor)
- {
- const int scan_no = ((j_decompress_ptr)cinfo)->input_scan_number;
- if (scan_no >= sp->otherSettings.max_allowed_scan_number)
- {
- TIFFErrorExtR(
- ((JPEGState *)cinfo)->tif, "TIFFjpeg_progress_monitor",
- "Scan number %d exceeds maximum scans (%d). This limit "
- "can be raised through the "
- "LIBTIFF_JPEG_MAX_ALLOWED_SCAN_NUMBER "
- "environment variable.",
- scan_no, sp->otherSettings.max_allowed_scan_number);
-
- jpeg_abort(cinfo); /* clean up libjpeg state */
- LONGJMP(sp->exit_jmpbuf, 1); /* return to libtiff caller */
- }
- }
-}
-
-/*
- * Interface routines. This layer of routines exists
- * primarily to limit side-effects from using setjmp.
- * Also, normal/error returns are converted into return
- * values per libtiff practice.
- */
-#define CALLJPEG(sp, fail, op) (SETJMP((sp)->exit_jmpbuf) ? (fail) : (op))
-#define CALLVJPEG(sp, op) CALLJPEG(sp, 0, ((op), 1))
-
-static int TIFFjpeg_create_compress(JPEGState *sp)
-{
- /* initialize JPEG error handling */
- sp->cinfo.c.err = jpeg_std_error(&sp->err);
- sp->err.error_exit = TIFFjpeg_error_exit;
- sp->err.output_message = TIFFjpeg_output_message;
-
- /* set client_data to avoid UMR warning from tools like Purify */
- sp->cinfo.c.client_data = NULL;
-
- return CALLVJPEG(sp, jpeg_create_compress(&sp->cinfo.c));
-}
-
-static int TIFFjpeg_create_decompress(JPEGState *sp)
-{
- /* initialize JPEG error handling */
- sp->cinfo.d.err = jpeg_std_error(&sp->err);
- sp->err.error_exit = TIFFjpeg_error_exit;
- sp->err.output_message = TIFFjpeg_output_message;
-
- /* set client_data to avoid UMR warning from tools like Purify */
- sp->cinfo.d.client_data = NULL;
-
- return CALLVJPEG(sp, jpeg_create_decompress(&sp->cinfo.d));
-}
-
-static int TIFFjpeg_set_defaults(JPEGState *sp)
-{
- return CALLVJPEG(sp, jpeg_set_defaults(&sp->cinfo.c));
-}
-
-static int TIFFjpeg_set_colorspace(JPEGState *sp, J_COLOR_SPACE colorspace)
-{
- return CALLVJPEG(sp, jpeg_set_colorspace(&sp->cinfo.c, colorspace));
-}
-
-static int TIFFjpeg_set_quality(JPEGState *sp, int quality,
- boolean force_baseline)
-{
- return CALLVJPEG(sp,
- jpeg_set_quality(&sp->cinfo.c, quality, force_baseline));
-}
-
-static int TIFFjpeg_suppress_tables(JPEGState *sp, boolean suppress)
-{
- return CALLVJPEG(sp, jpeg_suppress_tables(&sp->cinfo.c, suppress));
-}
-
-static int TIFFjpeg_start_compress(JPEGState *sp, boolean write_all_tables)
-{
- return CALLVJPEG(sp, jpeg_start_compress(&sp->cinfo.c, write_all_tables));
-}
-
-static int TIFFjpeg_write_scanlines(JPEGState *sp, TIFF_JSAMPARRAY scanlines,
- int num_lines)
-{
-#if defined(HAVE_JPEGTURBO_DUAL_MODE_8_12) && BITS_IN_JSAMPLE == 12
- return CALLJPEG(sp, -1,
- (int)jpeg12_write_scanlines(&sp->cinfo.c, scanlines,
- (JDIMENSION)num_lines));
-#else
- return CALLJPEG(sp, -1,
- (int)jpeg_write_scanlines(&sp->cinfo.c, scanlines,
- (JDIMENSION)num_lines));
-#endif
-}
-
-static int TIFFjpeg_write_raw_data(JPEGState *sp, TIFF_JSAMPIMAGE data,
- int num_lines)
-{
-#if defined(HAVE_JPEGTURBO_DUAL_MODE_8_12) && BITS_IN_JSAMPLE == 12
- return CALLJPEG(
- sp, -1,
- (int)jpeg12_write_raw_data(&sp->cinfo.c, data, (JDIMENSION)num_lines));
-#else
- return CALLJPEG(
- sp, -1,
- (int)jpeg_write_raw_data(&sp->cinfo.c, data, (JDIMENSION)num_lines));
-#endif
-}
-
-static int TIFFjpeg_finish_compress(JPEGState *sp)
-{
- return CALLVJPEG(sp, jpeg_finish_compress(&sp->cinfo.c));
-}
-
-static int TIFFjpeg_write_tables(JPEGState *sp)
-{
- return CALLVJPEG(sp, jpeg_write_tables(&sp->cinfo.c));
-}
-
-static int TIFFjpeg_read_header(JPEGState *sp, boolean require_image)
-{
- return CALLJPEG(sp, -1, jpeg_read_header(&sp->cinfo.d, require_image));
-}
-
-static int TIFFjpeg_has_multiple_scans(JPEGState *sp)
-{
- return CALLJPEG(sp, 0, jpeg_has_multiple_scans(&sp->cinfo.d));
-}
-
-static int TIFFjpeg_start_decompress(JPEGState *sp)
-{
- const char *sz_max_allowed_scan_number;
- /* progress monitor */
- sp->cinfo.d.progress = &sp->progress;
- sp->progress.progress_monitor = TIFFjpeg_progress_monitor;
- sp->otherSettings.max_allowed_scan_number = 100;
- sz_max_allowed_scan_number = getenv("LIBTIFF_JPEG_MAX_ALLOWED_SCAN_NUMBER");
- if (sz_max_allowed_scan_number)
- sp->otherSettings.max_allowed_scan_number =
- atoi(sz_max_allowed_scan_number);
-
- return CALLVJPEG(sp, jpeg_start_decompress(&sp->cinfo.d));
-}
-
-static int TIFFjpeg_read_scanlines(JPEGState *sp, TIFF_JSAMPARRAY scanlines,
- int max_lines)
-{
-#if defined(HAVE_JPEGTURBO_DUAL_MODE_8_12) && BITS_IN_JSAMPLE == 12
- return CALLJPEG(sp, -1,
- (int)jpeg12_read_scanlines(&sp->cinfo.d, scanlines,
- (JDIMENSION)max_lines));
-#else
- return CALLJPEG(sp, -1,
- (int)jpeg_read_scanlines(&sp->cinfo.d, scanlines,
- (JDIMENSION)max_lines));
-#endif
-}
-
-static int TIFFjpeg_read_raw_data(JPEGState *sp, TIFF_JSAMPIMAGE data,
- int max_lines)
-{
-#if defined(HAVE_JPEGTURBO_DUAL_MODE_8_12) && BITS_IN_JSAMPLE == 12
- return CALLJPEG(
- sp, -1,
- (int)jpeg12_read_raw_data(&sp->cinfo.d, data, (JDIMENSION)max_lines));
-#else
- return CALLJPEG(
- sp, -1,
- (int)jpeg_read_raw_data(&sp->cinfo.d, data, (JDIMENSION)max_lines));
-#endif
-}
-
-static int TIFFjpeg_finish_decompress(JPEGState *sp)
-{
- return CALLJPEG(sp, -1, (int)jpeg_finish_decompress(&sp->cinfo.d));
-}
-
-static int TIFFjpeg_abort(JPEGState *sp)
-{
- return CALLVJPEG(sp, jpeg_abort(&sp->cinfo.comm));
-}
-
-static int TIFFjpeg_destroy(JPEGState *sp)
-{
- return CALLVJPEG(sp, jpeg_destroy(&sp->cinfo.comm));
-}
-
-static JSAMPARRAY TIFFjpeg_alloc_sarray(JPEGState *sp, int pool_id,
- JDIMENSION samplesperrow,
- JDIMENSION numrows)
-{
- return CALLJPEG(sp, (JSAMPARRAY)NULL,
- (*sp->cinfo.comm.mem->alloc_sarray)(
- &sp->cinfo.comm, pool_id, samplesperrow, numrows));
-}
-
-/*
- * JPEG library destination data manager.
- * These routines direct compressed data from libjpeg into the
- * libtiff output buffer.
- */
-
-static void std_init_destination(j_compress_ptr cinfo)
-{
- JPEGState *sp = (JPEGState *)cinfo;
- TIFF *tif = sp->tif;
-
- sp->dest.next_output_byte = (JOCTET *)tif->tif_rawdata;
- sp->dest.free_in_buffer = (size_t)tif->tif_rawdatasize;
-}
-
-static boolean std_empty_output_buffer(j_compress_ptr cinfo)
-{
- JPEGState *sp = (JPEGState *)cinfo;
- TIFF *tif = sp->tif;
-
- /* the entire buffer has been filled */
- tif->tif_rawcc = tif->tif_rawdatasize;
-
-#ifdef IPPJ_HUFF
- /*
- * The Intel IPP performance library does not necessarily fill up
- * the whole output buffer on each pass, so only dump out the parts
- * that have been filled.
- * http://trac.osgeo.org/gdal/wiki/JpegIPP
- */
- if (sp->dest.free_in_buffer >= 0)
- {
- tif->tif_rawcc = tif->tif_rawdatasize - sp->dest.free_in_buffer;
- }
-#endif
-
- if (!TIFFFlushData1(tif))
- return FALSE;
- sp->dest.next_output_byte = (JOCTET *)tif->tif_rawdata;
- sp->dest.free_in_buffer = (size_t)tif->tif_rawdatasize;
-
- return (TRUE);
-}
-
-static void std_term_destination(j_compress_ptr cinfo)
-{
- JPEGState *sp = (JPEGState *)cinfo;
- TIFF *tif = sp->tif;
-
- tif->tif_rawcp = (uint8_t *)sp->dest.next_output_byte;
- tif->tif_rawcc = tif->tif_rawdatasize - (tmsize_t)sp->dest.free_in_buffer;
- /* NB: libtiff does the final buffer flush */
-}
-
-static void TIFFjpeg_data_dest(JPEGState *sp, TIFF *tif)
-{
- (void)tif;
- sp->cinfo.c.dest = &sp->dest;
- sp->dest.init_destination = std_init_destination;
- sp->dest.empty_output_buffer = std_empty_output_buffer;
- sp->dest.term_destination = std_term_destination;
-}
-
-/*
- * Alternate destination manager for outputting to JPEGTables field.
- */
-
-static void tables_init_destination(j_compress_ptr cinfo)
-{
- JPEGState *sp = (JPEGState *)cinfo;
-
- /* while building, otherSettings.jpegtables_length is allocated buffer size
- */
- sp->dest.next_output_byte = (JOCTET *)sp->otherSettings.jpegtables;
- sp->dest.free_in_buffer = (size_t)sp->otherSettings.jpegtables_length;
-}
-
-static boolean tables_empty_output_buffer(j_compress_ptr cinfo)
-{
- JPEGState *sp = (JPEGState *)cinfo;
- void *newbuf;
-
- /* the entire buffer has been filled; enlarge it by 1000 bytes */
- newbuf =
- _TIFFreallocExt(sp->tif, (void *)sp->otherSettings.jpegtables,
- (tmsize_t)(sp->otherSettings.jpegtables_length + 1000));
- if (newbuf == NULL)
- ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 100);
- sp->dest.next_output_byte =
- (JOCTET *)newbuf + sp->otherSettings.jpegtables_length;
- sp->dest.free_in_buffer = (size_t)1000;
- sp->otherSettings.jpegtables = newbuf;
- sp->otherSettings.jpegtables_length += 1000;
- return (TRUE);
-}
-
-static void tables_term_destination(j_compress_ptr cinfo)
-{
- JPEGState *sp = (JPEGState *)cinfo;
-
- /* set tables length to number of bytes actually emitted */
- sp->otherSettings.jpegtables_length -= (uint32_t)sp->dest.free_in_buffer;
-}
-
-static int TIFFjpeg_tables_dest(JPEGState *sp, TIFF *tif)
-{
- (void)tif;
- /*
- * Allocate a working buffer for building tables.
- * Initial size is 1000 bytes, which is usually adequate.
- */
- if (sp->otherSettings.jpegtables)
- _TIFFfreeExt(tif, sp->otherSettings.jpegtables);
- sp->otherSettings.jpegtables_length = 1000;
- sp->otherSettings.jpegtables = (void *)_TIFFmallocExt(
- tif, (tmsize_t)sp->otherSettings.jpegtables_length);
- if (sp->otherSettings.jpegtables == NULL)
- {
- sp->otherSettings.jpegtables_length = 0;
- TIFFErrorExtR(sp->tif, "TIFFjpeg_tables_dest",
- "No space for JPEGTables");
- return (0);
- }
- sp->cinfo.c.dest = &sp->dest;
- sp->dest.init_destination = tables_init_destination;
- sp->dest.empty_output_buffer = tables_empty_output_buffer;
- sp->dest.term_destination = tables_term_destination;
- return (1);
-}
-
-/*
- * JPEG library source data manager.
- * These routines supply compressed data to libjpeg.
- */
-
-static void std_init_source(j_decompress_ptr cinfo)
-{
- JPEGState *sp = (JPEGState *)cinfo;
- TIFF *tif = sp->tif;
-
- sp->src.next_input_byte = (const JOCTET *)tif->tif_rawdata;
- sp->src.bytes_in_buffer = (size_t)tif->tif_rawcc;
-}
-
-static boolean std_fill_input_buffer(j_decompress_ptr cinfo)
-{
- JPEGState *sp = (JPEGState *)cinfo;
- static const JOCTET dummy_EOI[2] = {0xFF, JPEG_EOI};
-
-#ifdef IPPJ_HUFF
- /*
- * The Intel IPP performance library does not necessarily read the whole
- * input buffer in one pass, so it is possible to get here with data
- * yet to read.
- *
- * We just return without doing anything, until the entire buffer has
- * been read.
- * http://trac.osgeo.org/gdal/wiki/JpegIPP
- */
- if (sp->src.bytes_in_buffer > 0)
- {
- return (TRUE);
- }
-#endif
-
- /*
- * Normally the whole strip/tile is read and so we don't need to do
- * a fill. In the case of CHUNKY_STRIP_READ_SUPPORT we might not have
- * all the data, but the rawdata is refreshed between scanlines and
- * we push this into the io machinery in JPEGDecode().
- * http://trac.osgeo.org/gdal/ticket/3894
- */
-
- WARNMS(cinfo, JWRN_JPEG_EOF);
- /* insert a fake EOI marker */
- sp->src.next_input_byte = dummy_EOI;
- sp->src.bytes_in_buffer = 2;
- return (TRUE);
-}
-
-static void std_skip_input_data(j_decompress_ptr cinfo, long num_bytes)
-{
- JPEGState *sp = (JPEGState *)cinfo;
-
- if (num_bytes > 0)
- {
- if ((size_t)num_bytes > sp->src.bytes_in_buffer)
- {
- /* oops, buffer overrun */
- (void)std_fill_input_buffer(cinfo);
- }
- else
- {
- sp->src.next_input_byte += (size_t)num_bytes;
- sp->src.bytes_in_buffer -= (size_t)num_bytes;
- }
- }
-}
-
-static void std_term_source(j_decompress_ptr cinfo)
-{
- /* No work necessary here */
- (void)cinfo;
-}
-
-static void TIFFjpeg_data_src(JPEGState *sp)
-{
- sp->cinfo.d.src = &sp->src;
- sp->src.init_source = std_init_source;
- sp->src.fill_input_buffer = std_fill_input_buffer;
- sp->src.skip_input_data = std_skip_input_data;
- sp->src.resync_to_restart = jpeg_resync_to_restart;
- sp->src.term_source = std_term_source;
- sp->src.bytes_in_buffer = 0; /* for safety */
- sp->src.next_input_byte = NULL;
-}
-
-/*
- * Alternate source manager for reading from JPEGTables.
- * We can share all the code except for the init routine.
- */
-
-static void tables_init_source(j_decompress_ptr cinfo)
-{
- JPEGState *sp = (JPEGState *)cinfo;
-
- sp->src.next_input_byte = (const JOCTET *)sp->otherSettings.jpegtables;
- sp->src.bytes_in_buffer = (size_t)sp->otherSettings.jpegtables_length;
-}
-
-static void TIFFjpeg_tables_src(JPEGState *sp)
-{
- TIFFjpeg_data_src(sp);
- sp->src.init_source = tables_init_source;
-}
-
-/*
- * Allocate downsampled-data buffers needed for downsampled I/O.
- * We use values computed in jpeg_start_compress or jpeg_start_decompress.
- * We use libjpeg's allocator so that buffers will be released automatically
- * when done with strip/tile.
- * This is also a handy place to compute samplesperclump, bytesperline.
- */
-static int alloc_downsampled_buffers(TIFF *tif, jpeg_component_info *comp_info,
- int num_components)
-{
- JPEGState *sp = JState(tif);
- int ci;
- jpeg_component_info *compptr;
- TIFF_JSAMPARRAY buf;
- int samples_per_clump = 0;
-
- for (ci = 0, compptr = comp_info; ci < num_components; ci++, compptr++)
- {
- samples_per_clump += compptr->h_samp_factor * compptr->v_samp_factor;
- buf = (TIFF_JSAMPARRAY)TIFFjpeg_alloc_sarray(
- sp, JPOOL_IMAGE, compptr->width_in_blocks * DCTSIZE,
- (JDIMENSION)(compptr->v_samp_factor * DCTSIZE));
- if (buf == NULL)
- return (0);
- sp->ds_buffer[ci] = buf;
- }
- sp->samplesperclump = samples_per_clump;
- return (1);
-}
-
-/*
- * JPEG Decoding.
- */
-
-#ifdef CHECK_JPEG_YCBCR_SUBSAMPLING
-
-#define JPEG_MARKER_SOF0 0xC0
-#define JPEG_MARKER_SOF1 0xC1
-#define JPEG_MARKER_SOF2 0xC2
-#define JPEG_MARKER_SOF9 0xC9
-#define JPEG_MARKER_SOF10 0xCA
-#define JPEG_MARKER_DHT 0xC4
-#define JPEG_MARKER_SOI 0xD8
-#define JPEG_MARKER_SOS 0xDA
-#define JPEG_MARKER_DQT 0xDB
-#define JPEG_MARKER_DRI 0xDD
-#define JPEG_MARKER_APP0 0xE0
-#define JPEG_MARKER_COM 0xFE
-struct JPEGFixupTagsSubsamplingData
-{
- TIFF *tif;
- void *buffer;
- uint32_t buffersize;
- uint8_t *buffercurrentbyte;
- uint32_t bufferbytesleft;
- uint64_t fileoffset;
- uint64_t filebytesleft;
- uint8_t filepositioned;
-};
-static void JPEGFixupTagsSubsampling(TIFF *tif);
-static int
-JPEGFixupTagsSubsamplingSec(struct JPEGFixupTagsSubsamplingData *data);
-static int
-JPEGFixupTagsSubsamplingReadByte(struct JPEGFixupTagsSubsamplingData *data,
- uint8_t *result);
-static int
-JPEGFixupTagsSubsamplingReadWord(struct JPEGFixupTagsSubsamplingData *data,
- uint16_t *result);
-static void
-JPEGFixupTagsSubsamplingSkip(struct JPEGFixupTagsSubsamplingData *data,
- uint16_t skiplength);
-
-#endif
-
-static int JPEGFixupTags(TIFF *tif)
-{
-#ifdef CHECK_JPEG_YCBCR_SUBSAMPLING
- JPEGState *sp = JState(tif);
- if ((tif->tif_dir.td_photometric == PHOTOMETRIC_YCBCR) &&
- (tif->tif_dir.td_planarconfig == PLANARCONFIG_CONTIG) &&
- (tif->tif_dir.td_samplesperpixel == 3) &&
- !sp->otherSettings.ycbcrsampling_fetched)
- JPEGFixupTagsSubsampling(tif);
-#endif
-
- return (1);
-}
-
-#ifdef CHECK_JPEG_YCBCR_SUBSAMPLING
-
-static void JPEGFixupTagsSubsampling(TIFF *tif)
-{
- /*
- * Some JPEG-in-TIFF produces do not emit the YCBCRSUBSAMPLING values in
- * the TIFF tags, but still use non-default (2,2) values within the jpeg
- * data stream itself. In order for TIFF applications to work properly
- * - for instance to get the strip buffer size right - it is imperative
- * that the subsampling be available before we start reading the image
- * data normally. This function will attempt to analyze the first strip in
- * order to get the sampling values from the jpeg data stream.
- *
- * Note that JPEGPreDeocode() will produce a fairly loud warning when the
- * discovered sampling does not match the default sampling (2,2) or whatever
- * was actually in the tiff tags.
- *
- * See the bug in bugzilla for details:
- *
- * http://bugzilla.remotesensing.org/show_bug.cgi?id=168
- *
- * Frank Warmerdam, July 2002
- * Joris Van Damme, May 2007
- */
- static const char module[] = "JPEGFixupTagsSubsampling";
- struct JPEGFixupTagsSubsamplingData m;
- uint64_t fileoffset = TIFFGetStrileOffset(tif, 0);
-
- if (fileoffset == 0)
- {
- /* Do not even try to check if the first strip/tile does not
- yet exist, as occurs when GDAL has created a new NULL file
- for instance. */
- return;
- }
-
- m.tif = tif;
- m.buffersize = 2048;
- m.buffer = _TIFFmallocExt(tif, m.buffersize);
- if (m.buffer == NULL)
- {
- TIFFWarningExtR(tif, module,
- "Unable to allocate memory for auto-correcting of "
- "subsampling values; auto-correcting skipped");
- return;
- }
- m.buffercurrentbyte = NULL;
- m.bufferbytesleft = 0;
- m.fileoffset = fileoffset;
- m.filepositioned = 0;
- m.filebytesleft = TIFFGetStrileByteCount(tif, 0);
- if (!JPEGFixupTagsSubsamplingSec(&m))
- TIFFWarningExtR(
- tif, module,
- "Unable to auto-correct subsampling values, likely corrupt JPEG "
- "compressed data in first strip/tile; auto-correcting skipped");
- _TIFFfreeExt(tif, m.buffer);
-}
-
-static int
-JPEGFixupTagsSubsamplingSec(struct JPEGFixupTagsSubsamplingData *data)
-{
- static const char module[] = "JPEGFixupTagsSubsamplingSec";
- uint8_t m;
- while (1)
- {
- while (1)
- {
- if (!JPEGFixupTagsSubsamplingReadByte(data, &m))
- return (0);
- if (m == 255)
- break;
- }
- while (1)
- {
- if (!JPEGFixupTagsSubsamplingReadByte(data, &m))
- return (0);
- if (m != 255)
- break;
- }
- switch (m)
- {
- case JPEG_MARKER_SOI:
- /* this type of marker has no data and should be skipped */
- break;
- case JPEG_MARKER_COM:
- case JPEG_MARKER_APP0:
- case JPEG_MARKER_APP0 + 1:
- case JPEG_MARKER_APP0 + 2:
- case JPEG_MARKER_APP0 + 3:
- case JPEG_MARKER_APP0 + 4:
- case JPEG_MARKER_APP0 + 5:
- case JPEG_MARKER_APP0 + 6:
- case JPEG_MARKER_APP0 + 7:
- case JPEG_MARKER_APP0 + 8:
- case JPEG_MARKER_APP0 + 9:
- case JPEG_MARKER_APP0 + 10:
- case JPEG_MARKER_APP0 + 11:
- case JPEG_MARKER_APP0 + 12:
- case JPEG_MARKER_APP0 + 13:
- case JPEG_MARKER_APP0 + 14:
- case JPEG_MARKER_APP0 + 15:
- case JPEG_MARKER_DQT:
- case JPEG_MARKER_SOS:
- case JPEG_MARKER_DHT:
- case JPEG_MARKER_DRI:
- /* this type of marker has data, but it has no use to us and
- * should be skipped */
- {
- uint16_t n;
- if (!JPEGFixupTagsSubsamplingReadWord(data, &n))
- return (0);
- if (n < 2)
- return (0);
- n -= 2;
- if (n > 0)
- JPEGFixupTagsSubsamplingSkip(data, n);
- }
- break;
- case JPEG_MARKER_SOF0: /* Baseline sequential Huffman */
- case JPEG_MARKER_SOF1: /* Extended sequential Huffman */
- case JPEG_MARKER_SOF2: /* Progressive Huffman: normally not allowed
- by TechNote, but that doesn't hurt
- supporting it */
- case JPEG_MARKER_SOF9: /* Extended sequential arithmetic */
- case JPEG_MARKER_SOF10: /* Progressive arithmetic: normally not
- allowed by TechNote, but that doesn't
- hurt supporting it */
- /* this marker contains the subsampling factors we're scanning
- * for */
- {
- uint16_t n;
- uint16_t o;
- uint8_t p;
- uint8_t ph, pv;
- if (!JPEGFixupTagsSubsamplingReadWord(data, &n))
- return (0);
- if (n != 8 + data->tif->tif_dir.td_samplesperpixel * 3)
- return (0);
- JPEGFixupTagsSubsamplingSkip(data, 7);
- if (!JPEGFixupTagsSubsamplingReadByte(data, &p))
- return (0);
- ph = (p >> 4);
- pv = (p & 15);
- JPEGFixupTagsSubsamplingSkip(data, 1);
- for (o = 1; o < data->tif->tif_dir.td_samplesperpixel; o++)
- {
- JPEGFixupTagsSubsamplingSkip(data, 1);
- if (!JPEGFixupTagsSubsamplingReadByte(data, &p))
- return (0);
- if (p != 0x11)
- {
- TIFFWarningExtR(data->tif, module,
- "Subsampling values inside JPEG "
- "compressed data "
- "have no TIFF equivalent, "
- "auto-correction of TIFF "
- "subsampling values failed");
- return (1);
- }
- JPEGFixupTagsSubsamplingSkip(data, 1);
- }
- if (((ph != 1) && (ph != 2) && (ph != 4)) ||
- ((pv != 1) && (pv != 2) && (pv != 4)))
- {
- TIFFWarningExtR(data->tif, module,
- "Subsampling values inside JPEG "
- "compressed data have no TIFF "
- "equivalent, auto-correction of TIFF "
- "subsampling values failed");
- return (1);
- }
- if ((ph != data->tif->tif_dir.td_ycbcrsubsampling[0]) ||
- (pv != data->tif->tif_dir.td_ycbcrsubsampling[1]))
- {
- TIFFWarningExtR(
- data->tif, module,
- "Auto-corrected former TIFF subsampling values "
- "[%" PRIu16 ",%" PRIu16
- "] to match subsampling values inside JPEG "
- "compressed data [%" PRIu8 ",%" PRIu8 "]",
- data->tif->tif_dir.td_ycbcrsubsampling[0],
- data->tif->tif_dir.td_ycbcrsubsampling[1], ph, pv);
- data->tif->tif_dir.td_ycbcrsubsampling[0] = ph;
- data->tif->tif_dir.td_ycbcrsubsampling[1] = pv;
- }
- }
- return (1);
- default:
- return (0);
- }
- }
-}
-
-static int
-JPEGFixupTagsSubsamplingReadByte(struct JPEGFixupTagsSubsamplingData *data,
- uint8_t *result)
-{
- if (data->bufferbytesleft == 0)
- {
- uint32_t m;
- if (data->filebytesleft == 0)
- return (0);
- if (!data->filepositioned)
- {
- if (TIFFSeekFile(data->tif, data->fileoffset, SEEK_SET) ==
- (toff_t)-1)
- {
- return 0;
- }
- data->filepositioned = 1;
- }
- m = data->buffersize;
- if ((uint64_t)m > data->filebytesleft)
- m = (uint32_t)data->filebytesleft;
- assert(m < 0x80000000UL);
- if (TIFFReadFile(data->tif, data->buffer, (tmsize_t)m) != (tmsize_t)m)
- return (0);
- data->buffercurrentbyte = data->buffer;
- data->bufferbytesleft = m;
- data->fileoffset += m;
- data->filebytesleft -= m;
- }
- *result = *data->buffercurrentbyte;
- data->buffercurrentbyte++;
- data->bufferbytesleft--;
- return (1);
-}
-
-static int
-JPEGFixupTagsSubsamplingReadWord(struct JPEGFixupTagsSubsamplingData *data,
- uint16_t *result)
-{
- uint8_t ma;
- uint8_t mb;
- if (!JPEGFixupTagsSubsamplingReadByte(data, &ma))
- return (0);
- if (!JPEGFixupTagsSubsamplingReadByte(data, &mb))
- return (0);
- *result = (ma << 8) | mb;
- return (1);
-}
-
-static void
-JPEGFixupTagsSubsamplingSkip(struct JPEGFixupTagsSubsamplingData *data,
- uint16_t skiplength)
-{
- if ((uint32_t)skiplength <= data->bufferbytesleft)
- {
- data->buffercurrentbyte += skiplength;
- data->bufferbytesleft -= skiplength;
- }
- else
- {
- uint16_t m;
- m = (uint16_t)(skiplength - data->bufferbytesleft);
- if (m <= data->filebytesleft)
- {
- data->bufferbytesleft = 0;
- data->fileoffset += m;
- data->filebytesleft -= m;
- data->filepositioned = 0;
- }
- else
- {
- data->bufferbytesleft = 0;
- data->filebytesleft = 0;
- }
- }
-}
-
-#endif
-
-static int JPEGSetupDecode(TIFF *tif)
-{
- JPEGState *sp = JState(tif);
- TIFFDirectory *td = &tif->tif_dir;
-
-#if defined(JPEG_DUAL_MODE_8_12) && !defined(FROM_TIF_JPEG_12)
- if (tif->tif_dir.td_bitspersample == 12)
- {
- /* We pass a pointer to a copy of otherSettings, since */
- /* TIFFReInitJPEG_12() will clear sp */
- JPEGOtherSettings savedOtherSettings = sp->otherSettings;
- return TIFFReInitJPEG_12(tif, &savedOtherSettings, COMPRESSION_JPEG, 0);
- }
-#endif
-
- JPEGInitializeLibJPEG(tif, TRUE);
-
- assert(sp != NULL);
- assert(sp->cinfo.comm.is_decompressor);
-
- /* Read JPEGTables if it is present */
- if (TIFFFieldSet(tif, FIELD_JPEGTABLES))
- {
- TIFFjpeg_tables_src(sp);
- if (TIFFjpeg_read_header(sp, FALSE) != JPEG_HEADER_TABLES_ONLY)
- {
- TIFFErrorExtR(tif, "JPEGSetupDecode", "Bogus JPEGTables field");
- return (0);
- }
- }
-
- /* Grab parameters that are same for all strips/tiles */
- sp->photometric = td->td_photometric;
- switch (sp->photometric)
- {
- case PHOTOMETRIC_YCBCR:
- sp->h_sampling = td->td_ycbcrsubsampling[0];
- sp->v_sampling = td->td_ycbcrsubsampling[1];
- break;
- default:
- /* TIFF 6.0 forbids subsampling of all other color spaces */
- sp->h_sampling = 1;
- sp->v_sampling = 1;
- break;
- }
-
- /* Set up for reading normal data */
- TIFFjpeg_data_src(sp);
- tif->tif_postdecode = _TIFFNoPostDecode; /* override byte swapping */
- return (1);
-}
-
-/* Returns 1 if the full strip should be read, even when doing scanline per */
-/* scanline decoding. This happens when the JPEG stream uses multiple scans. */
-/* Currently only called in CHUNKY_STRIP_READ_SUPPORT mode through */
-/* scanline interface. */
-/* Only reads tif->tif_dir.td_bitspersample, tif->tif_rawdata and */
-/* tif->tif_rawcc members. */
-/* Can be called independently of the usual setup/predecode/decode states */
-int TIFFJPEGIsFullStripRequired(TIFF *tif)
-{
- int ret;
- JPEGState state;
-
-#if defined(JPEG_DUAL_MODE_8_12) && !defined(FROM_TIF_JPEG_12)
- if (tif->tif_dir.td_bitspersample == 12)
- return TIFFJPEGIsFullStripRequired_12(tif);
-#endif
-
- memset(&state, 0, sizeof(JPEGState));
- state.tif = tif;
-
- TIFFjpeg_create_decompress(&state);
-
- TIFFjpeg_data_src(&state);
-
- if (TIFFjpeg_read_header(&state, TRUE) != JPEG_HEADER_OK)
- {
- TIFFjpeg_destroy(&state);
- return (0);
- }
- ret = TIFFjpeg_has_multiple_scans(&state);
-
- TIFFjpeg_destroy(&state);
-
- return ret;
-}
-
-/*
- * Set up for decoding a strip or tile.
- */
-/*ARGSUSED*/ static int JPEGPreDecode(TIFF *tif, uint16_t s)
-{
- JPEGState *sp = JState(tif);
- TIFFDirectory *td = &tif->tif_dir;
- static const char module[] = "JPEGPreDecode";
- uint32_t segment_width, segment_height;
- int downsampled_output;
- int ci;
-
- assert(sp != NULL);
-
- if (sp->cinfo.comm.is_decompressor == 0)
- {
- tif->tif_setupdecode(tif);
- }
-
- assert(sp->cinfo.comm.is_decompressor);
- /*
- * Reset decoder state from any previous strip/tile,
- * in case application didn't read the whole strip.
- */
- if (!TIFFjpeg_abort(sp))
- return (0);
- /*
- * Read the header for this strip/tile.
- */
-
- if (TIFFjpeg_read_header(sp, TRUE) != JPEG_HEADER_OK)
- return (0);
-
- tif->tif_rawcp = (uint8_t *)sp->src.next_input_byte;
- tif->tif_rawcc = sp->src.bytes_in_buffer;
-
- /*
- * Check image parameters and set decompression parameters.
- */
- if (isTiled(tif))
- {
- segment_width = td->td_tilewidth;
- segment_height = td->td_tilelength;
- sp->bytesperline = TIFFTileRowSize(tif);
- }
- else
- {
- segment_width = td->td_imagewidth;
- segment_height = td->td_imagelength - tif->tif_row;
- if (segment_height > td->td_rowsperstrip)
- segment_height = td->td_rowsperstrip;
- sp->bytesperline = TIFFScanlineSize(tif);
- }
- if (td->td_planarconfig == PLANARCONFIG_SEPARATE && s > 0)
- {
- /*
- * For PC 2, scale down the expected strip/tile size
- * to match a downsampled component
- */
- if (sp->h_sampling == 0 || sp->v_sampling == 0)
- {
- TIFFErrorExtR(tif, module,
- "JPEG horizontal or vertical sampling is zero");
- return (0);
- }
- segment_width = TIFFhowmany_32(segment_width, sp->h_sampling);
- segment_height = TIFFhowmany_32(segment_height, sp->v_sampling);
- }
- if (sp->cinfo.d.image_width < segment_width ||
- sp->cinfo.d.image_height < segment_height)
- {
- TIFFWarningExtR(tif, module,
- "Improper JPEG strip/tile size, "
- "expected %" PRIu32 "x%" PRIu32 ", got %ux%u",
- segment_width, segment_height, sp->cinfo.d.image_width,
- sp->cinfo.d.image_height);
- }
- if (sp->cinfo.d.image_width == segment_width &&
- sp->cinfo.d.image_height > segment_height &&
- tif->tif_row + segment_height == td->td_imagelength && !isTiled(tif))
- {
- /* Some files have a last strip, that should be truncated, */
- /* but their JPEG codestream has still the maximum strip */
- /* height. Warn about this as this is non compliant, but */
- /* we can safely recover from that. */
- TIFFWarningExtR(tif, module,
- "JPEG strip size exceeds expected dimensions,"
- " expected %" PRIu32 "x%" PRIu32 ", got %ux%u",
- segment_width, segment_height, sp->cinfo.d.image_width,
- sp->cinfo.d.image_height);
- }
- else if (sp->cinfo.d.image_width > segment_width ||
- sp->cinfo.d.image_height > segment_height)
- {
- /*
- * This case could be dangerous, if the strip or tile size has
- * been reported as less than the amount of data jpeg will
- * return, some potential security issues arise. Catch this
- * case and error out.
- */
- TIFFErrorExtR(tif, module,
- "JPEG strip/tile size exceeds expected dimensions,"
- " expected %" PRIu32 "x%" PRIu32 ", got %ux%u",
- segment_width, segment_height, sp->cinfo.d.image_width,
- sp->cinfo.d.image_height);
- return (0);
- }
- if (sp->cinfo.d.num_components !=
- (td->td_planarconfig == PLANARCONFIG_CONTIG ? td->td_samplesperpixel
- : 1))
- {
- TIFFErrorExtR(tif, module, "Improper JPEG component count");
- return (0);
- }
-#ifdef JPEG_LIB_MK1
- if (12 != td->td_bitspersample && 8 != td->td_bitspersample)
- {
- TIFFErrorExtR(tif, module, "Improper JPEG data precision");
- return (0);
- }
- sp->cinfo.d.data_precision = td->td_bitspersample;
- sp->cinfo.d.bits_in_jsample = td->td_bitspersample;
-#else
- if (sp->cinfo.d.data_precision != td->td_bitspersample)
- {
- TIFFErrorExtR(tif, module, "Improper JPEG data precision");
- return (0);
- }
-#endif
-
- if (sp->cinfo.d.progressive_mode &&
- !sp->otherSettings.has_warned_about_progressive_mode)
- {
- TIFFWarningExtR(tif, module,
- "The JPEG strip/tile is encoded with progressive mode, "
- "which is normally not legal for JPEG-in-TIFF.\n"
- "libtiff should be able to decode it, but it might "
- "cause compatibility issues with other readers");
- sp->otherSettings.has_warned_about_progressive_mode = TRUE;
- }
-
- /* In some cases, libjpeg needs to allocate a lot of memory */
- /* http://www.libjpeg-turbo.org/pmwiki/uploads/About/TwoIssueswiththeJPEGStandard.pdf
- */
- if (TIFFjpeg_has_multiple_scans(sp))
- {
- /* In this case libjpeg will need to allocate memory or backing */
- /* store for all coefficients */
- /* See call to jinit_d_coef_controller() from master_selection() */
- /* in libjpeg */
-
- /* 1 MB for regular libjpeg usage */
- toff_t nRequiredMemory = 1024 * 1024;
-
- for (ci = 0; ci < sp->cinfo.d.num_components; ci++)
- {
- const jpeg_component_info *compptr = &(sp->cinfo.d.comp_info[ci]);
- if (compptr->h_samp_factor > 0 && compptr->v_samp_factor > 0)
- {
- nRequiredMemory +=
- (toff_t)(((compptr->width_in_blocks +
- compptr->h_samp_factor - 1) /
- compptr->h_samp_factor)) *
- ((compptr->height_in_blocks + compptr->v_samp_factor - 1) /
- compptr->v_samp_factor) *
- sizeof(JBLOCK);
- }
- }
-
- if (sp->cinfo.d.mem->max_memory_to_use > 0 &&
- nRequiredMemory > (toff_t)(sp->cinfo.d.mem->max_memory_to_use) &&
- getenv("LIBTIFF_ALLOW_LARGE_LIBJPEG_MEM_ALLOC") == NULL)
- {
- TIFFErrorExtR(
- tif, module,
- "Reading this image would require libjpeg to allocate "
- "at least %" PRIu64 " bytes. "
- "This is disabled since above the %ld threshold. "
- "You may override this restriction by defining the "
- "LIBTIFF_ALLOW_LARGE_LIBJPEG_MEM_ALLOC environment variable, "
- "or setting the JPEGMEM environment variable to a value "
- "greater "
- "or equal to '%" PRIu64 "M'",
- nRequiredMemory, sp->cinfo.d.mem->max_memory_to_use,
- (nRequiredMemory + 1000000u - 1u) / 1000000u);
- return 0;
- }
- }
-
- if (td->td_planarconfig == PLANARCONFIG_CONTIG)
- {
- /* Component 0 should have expected sampling factors */
- if (sp->cinfo.d.comp_info[0].h_samp_factor != sp->h_sampling ||
- sp->cinfo.d.comp_info[0].v_samp_factor != sp->v_sampling)
- {
- TIFFErrorExtR(tif, module,
- "Improper JPEG sampling factors %d,%d\n"
- "Apparently should be %" PRIu16 ",%" PRIu16 ".",
- sp->cinfo.d.comp_info[0].h_samp_factor,
- sp->cinfo.d.comp_info[0].v_samp_factor,
- sp->h_sampling, sp->v_sampling);
- return (0);
- }
- /* Rest should have sampling factors 1,1 */
- for (ci = 1; ci < sp->cinfo.d.num_components; ci++)
- {
- if (sp->cinfo.d.comp_info[ci].h_samp_factor != 1 ||
- sp->cinfo.d.comp_info[ci].v_samp_factor != 1)
- {
- TIFFErrorExtR(tif, module, "Improper JPEG sampling factors");
- return (0);
- }
- }
- }
- else
- {
- /* PC 2's single component should have sampling factors 1,1 */
- if (sp->cinfo.d.comp_info[0].h_samp_factor != 1 ||
- sp->cinfo.d.comp_info[0].v_samp_factor != 1)
- {
- TIFFErrorExtR(tif, module, "Improper JPEG sampling factors");
- return (0);
- }
- }
- downsampled_output = FALSE;
- if (td->td_planarconfig == PLANARCONFIG_CONTIG &&
- sp->photometric == PHOTOMETRIC_YCBCR &&
- sp->otherSettings.jpegcolormode == JPEGCOLORMODE_RGB)
- {
- /* Convert YCbCr to RGB */
- sp->cinfo.d.jpeg_color_space = JCS_YCbCr;
- sp->cinfo.d.out_color_space = JCS_RGB;
- }
- else
- {
- /* Suppress colorspace handling */
- sp->cinfo.d.jpeg_color_space = JCS_UNKNOWN;
- sp->cinfo.d.out_color_space = JCS_UNKNOWN;
- if (td->td_planarconfig == PLANARCONFIG_CONTIG &&
- (sp->h_sampling != 1 || sp->v_sampling != 1))
- downsampled_output = TRUE;
- /* XXX what about up-sampling? */
- }
- if (downsampled_output)
- {
- /* Need to use raw-data interface to libjpeg */
- sp->cinfo.d.raw_data_out = TRUE;
-#if JPEG_LIB_VERSION >= 70
- sp->cinfo.d.do_fancy_upsampling = FALSE;
-#endif /* JPEG_LIB_VERSION >= 70 */
- tif->tif_decoderow = DecodeRowError;
- tif->tif_decodestrip = JPEGDecodeRaw;
- tif->tif_decodetile = JPEGDecodeRaw;
- }
- else
- {
- /* Use normal interface to libjpeg */
- sp->cinfo.d.raw_data_out = FALSE;
- tif->tif_decoderow = JPEGDecode;
- tif->tif_decodestrip = JPEGDecode;
- tif->tif_decodetile = JPEGDecode;
- }
- /* Start JPEG decompressor */
- if (!TIFFjpeg_start_decompress(sp))
- return (0);
- /* Allocate downsampled-data buffers if needed */
- if (downsampled_output)
- {
- if (!alloc_downsampled_buffers(tif, sp->cinfo.d.comp_info,
- sp->cinfo.d.num_components))
- return (0);
- sp->scancount = DCTSIZE; /* mark buffer empty */
- }
- return (1);
-}
-
-/*
- * Decode a chunk of pixels.
- * "Standard" case: returned data is not downsampled.
- */
-#if !JPEG_LIB_MK1_OR_12BIT
-static int JPEGDecode(TIFF *tif, uint8_t *buf, tmsize_t cc, uint16_t s)
-{
- JPEGState *sp = JState(tif);
- tmsize_t nrows;
- (void)s;
-
- /*
- ** Update available information, buffer may have been refilled
- ** between decode requests
- */
- sp->src.next_input_byte = (const JOCTET *)tif->tif_rawcp;
- sp->src.bytes_in_buffer = (size_t)tif->tif_rawcc;
-
- if (sp->bytesperline == 0)
- {
- memset(buf, 0, (size_t)cc);
- return 0;
- }
-
- nrows = cc / sp->bytesperline;
- if (cc % sp->bytesperline)
- TIFFWarningExtR(tif, tif->tif_name, "fractional scanline not read");
-
- if (nrows > (tmsize_t)sp->cinfo.d.image_height)
- nrows = sp->cinfo.d.image_height;
-
- /* data is expected to be read in multiples of a scanline */
- if (nrows)
- {
- do
- {
- /*
- * In the libjpeg6b-9a 8bit case. We read directly into
- * the TIFF buffer.
- */
- JSAMPROW bufptr = (JSAMPROW)buf;
-
- if (TIFFjpeg_read_scanlines(sp, &bufptr, 1) != 1)
- {
- memset(buf, 0, (size_t)cc);
- return (0);
- }
-
- ++tif->tif_row;
- buf += sp->bytesperline;
- cc -= sp->bytesperline;
- } while (--nrows > 0);
- }
-
- /* Update information on consumed data */
- tif->tif_rawcp = (uint8_t *)sp->src.next_input_byte;
- tif->tif_rawcc = sp->src.bytes_in_buffer;
-
- /* Close down the decompressor if we've finished the strip or tile. */
- return sp->cinfo.d.output_scanline < sp->cinfo.d.output_height ||
- TIFFjpeg_finish_decompress(sp);
-}
-#endif /* !JPEG_LIB_MK1_OR_12BIT */
-
-#if JPEG_LIB_MK1_OR_12BIT
-/*ARGSUSED*/ static int JPEGDecode(TIFF *tif, uint8_t *buf, tmsize_t cc,
- uint16_t s)
-{
- JPEGState *sp = JState(tif);
- tmsize_t nrows;
- (void)s;
-
- /*
- ** Update available information, buffer may have been refilled
- ** between decode requests
- */
- sp->src.next_input_byte = (const JOCTET *)tif->tif_rawcp;
- sp->src.bytes_in_buffer = (size_t)tif->tif_rawcc;
-
- if (sp->bytesperline == 0)
- {
- memset(buf, 0, (size_t)cc);
- return 0;
- }
-
- nrows = cc / sp->bytesperline;
- if (cc % sp->bytesperline)
- TIFFWarningExtR(tif, tif->tif_name, "fractional scanline not read");
-
- if (nrows > (tmsize_t)sp->cinfo.d.image_height)
- nrows = sp->cinfo.d.image_height;
-
- /* data is expected to be read in multiples of a scanline */
- if (nrows)
- {
- TIFF_JSAMPROW line_work_buf = NULL;
-
- /*
- * For 6B, only use temporary buffer for 12 bit imagery.
- * For Mk1 always use it.
- */
- if (sp->cinfo.d.data_precision == 12)
- {
- line_work_buf = (TIFF_JSAMPROW)_TIFFmallocExt(
- tif, sizeof(short) * sp->cinfo.d.output_width *
- sp->cinfo.d.num_components);
- }
-
- do
- {
- if (line_work_buf != NULL)
- {
- /*
- * In the MK1 case, we always read into a 16bit
- * buffer, and then pack down to 12bit or 8bit.
- * In 6B case we only read into 16 bit buffer
- * for 12bit data, which we need to repack.
- */
- if (TIFFjpeg_read_scanlines(sp, &line_work_buf, 1) != 1)
- {
- memset(buf, 0, (size_t)cc);
- return (0);
- }
-
- if (sp->cinfo.d.data_precision == 12)
- {
- int value_pairs = (sp->cinfo.d.output_width *
- sp->cinfo.d.num_components) /
- 2;
- int iPair;
-
- for (iPair = 0; iPair < value_pairs; iPair++)
- {
- unsigned char *out_ptr =
- ((unsigned char *)buf) + iPair * 3;
- TIFF_JSAMPLE *in_ptr = line_work_buf + iPair * 2;
-
- out_ptr[0] = (unsigned char)((in_ptr[0] & 0xff0) >> 4);
- out_ptr[1] =
- (unsigned char)(((in_ptr[0] & 0xf) << 4) |
- ((in_ptr[1] & 0xf00) >> 8));
- out_ptr[2] = (unsigned char)(((in_ptr[1] & 0xff) >> 0));
- }
- }
- else if (sp->cinfo.d.data_precision == 8)
- {
- int value_count =
- (sp->cinfo.d.output_width * sp->cinfo.d.num_components);
- int iValue;
-
- for (iValue = 0; iValue < value_count; iValue++)
- {
- ((unsigned char *)buf)[iValue] =
- line_work_buf[iValue] & 0xff;
- }
- }
- }
-
- ++tif->tif_row;
- buf += sp->bytesperline;
- cc -= sp->bytesperline;
- } while (--nrows > 0);
-
- if (line_work_buf != NULL)
- _TIFFfreeExt(tif, line_work_buf);
- }
-
- /* Update information on consumed data */
- tif->tif_rawcp = (uint8_t *)sp->src.next_input_byte;
- tif->tif_rawcc = sp->src.bytes_in_buffer;
-
- /* Close down the decompressor if we've finished the strip or tile. */
- return sp->cinfo.d.output_scanline < sp->cinfo.d.output_height ||
- TIFFjpeg_finish_decompress(sp);
-}
-#endif /* JPEG_LIB_MK1_OR_12BIT */
-
-/*ARGSUSED*/ static int DecodeRowError(TIFF *tif, uint8_t *buf, tmsize_t cc,
- uint16_t s)
-
-{
- (void)buf;
- (void)cc;
- (void)s;
-
- TIFFErrorExtR(
- tif, "TIFFReadScanline",
- "scanline oriented access is not supported for downsampled JPEG "
- "compressed images, consider enabling TIFFTAG_JPEGCOLORMODE as "
- "JPEGCOLORMODE_RGB.");
- return 0;
-}
-
-/*
- * Decode a chunk of pixels.
- * Returned data is downsampled per sampling factors.
- */
-/*ARGSUSED*/ static int JPEGDecodeRaw(TIFF *tif, uint8_t *buf, tmsize_t cc,
- uint16_t s)
-{
- JPEGState *sp = JState(tif);
- tmsize_t nrows;
- TIFFDirectory *td = &tif->tif_dir;
- (void)s;
-
- nrows = sp->cinfo.d.image_height;
- /* For last strip, limit number of rows to its truncated height */
- /* even if the codestream height is larger (which is not compliant, */
- /* but that we tolerate) */
- if ((uint32_t)nrows > td->td_imagelength - tif->tif_row && !isTiled(tif))
- nrows = td->td_imagelength - tif->tif_row;
-
-#if defined(JPEG_LIB_MK1_OR_12BIT)
- unsigned short *tmpbuf = NULL;
-#endif
-
- /* data is expected to be read in multiples of a scanline */
- if (nrows != 0)
- {
-
- /* Cb,Cr both have sampling factors 1, so this is correct */
- JDIMENSION clumps_per_line = sp->cinfo.d.comp_info[1].downsampled_width;
- int samples_per_clump = sp->samplesperclump;
-
-#if defined(JPEG_LIB_MK1_OR_12BIT)
- tmpbuf = _TIFFmallocExt(tif, sizeof(unsigned short) *
- sp->cinfo.d.output_width *
- sp->cinfo.d.num_components);
- if (tmpbuf == NULL)
- {
- TIFFErrorExtR(tif, "JPEGDecodeRaw", "Out of memory");
- return 0;
- }
-#endif
-
- do
- {
- jpeg_component_info *compptr;
- int ci, clumpoffset;
-
- if (cc < sp->bytesperline)
- {
- TIFFErrorExtR(
- tif, "JPEGDecodeRaw",
- "application buffer not large enough for all data.");
- goto error;
- }
-
- /* Reload downsampled-data buffer if needed */
- if (sp->scancount >= DCTSIZE)
- {
- int n = sp->cinfo.d.max_v_samp_factor * DCTSIZE;
- if (TIFFjpeg_read_raw_data(sp, sp->ds_buffer, n) != n)
- goto error;
- sp->scancount = 0;
- }
- /*
- * Fastest way to unseparate data is to make one pass
- * over the scanline for each row of each component.
- */
- clumpoffset = 0; /* first sample in clump */
- for (ci = 0, compptr = sp->cinfo.d.comp_info;
- ci < sp->cinfo.d.num_components; ci++, compptr++)
- {
- int hsamp = compptr->h_samp_factor;
- int vsamp = compptr->v_samp_factor;
- int ypos;
-
- for (ypos = 0; ypos < vsamp; ypos++)
- {
- TIFF_JSAMPLE *inptr =
- sp->ds_buffer[ci][sp->scancount * vsamp + ypos];
- JDIMENSION nclump;
-#if defined(JPEG_LIB_MK1_OR_12BIT)
- TIFF_JSAMPLE *outptr = (TIFF_JSAMPLE *)tmpbuf + clumpoffset;
-#else
- TIFF_JSAMPLE *outptr = (TIFF_JSAMPLE *)buf + clumpoffset;
- if (cc < (tmsize_t)(clumpoffset +
- (tmsize_t)samples_per_clump *
- (clumps_per_line - 1) +
- hsamp))
- {
- TIFFErrorExtR(
- tif, "JPEGDecodeRaw",
- "application buffer not large enough for all data, "
- "possible subsampling issue");
- goto error;
- }
-#endif
-
- if (hsamp == 1)
- {
- /* fast path for at least Cb and Cr */
- for (nclump = clumps_per_line; nclump-- > 0;)
- {
- outptr[0] = *inptr++;
- outptr += samples_per_clump;
- }
- }
- else
- {
- int xpos;
-
- /* general case */
- for (nclump = clumps_per_line; nclump-- > 0;)
- {
- for (xpos = 0; xpos < hsamp; xpos++)
- outptr[xpos] = *inptr++;
- outptr += samples_per_clump;
- }
- }
- clumpoffset += hsamp;
- }
- }
-
-#if defined(JPEG_LIB_MK1_OR_12BIT)
- {
- if (sp->cinfo.d.data_precision == 8)
- {
- int i = 0;
- int len =
- sp->cinfo.d.output_width * sp->cinfo.d.num_components;
- for (i = 0; i < len; i++)
- {
- ((unsigned char *)buf)[i] = tmpbuf[i] & 0xff;
- }
- }
- else
- { /* 12-bit */
- int value_pairs = (sp->cinfo.d.output_width *
- sp->cinfo.d.num_components) /
- 2;
- int iPair;
- for (iPair = 0; iPair < value_pairs; iPair++)
- {
- unsigned char *out_ptr =
- ((unsigned char *)buf) + iPair * 3;
- JSAMPLE *in_ptr = (JSAMPLE *)(tmpbuf + iPair * 2);
- out_ptr[0] = (unsigned char)((in_ptr[0] & 0xff0) >> 4);
- out_ptr[1] =
- (unsigned char)(((in_ptr[0] & 0xf) << 4) |
- ((in_ptr[1] & 0xf00) >> 8));
- out_ptr[2] = (unsigned char)(((in_ptr[1] & 0xff) >> 0));
- }
- }
- }
-#endif
-
- sp->scancount++;
- tif->tif_row += sp->v_sampling;
-
- buf += sp->bytesperline;
- cc -= sp->bytesperline;
-
- nrows -= sp->v_sampling;
- } while (nrows > 0);
-
-#if defined(JPEG_LIB_MK1_OR_12BIT)
- _TIFFfreeExt(tif, tmpbuf);
-#endif
- }
-
- /* Close down the decompressor if done. */
- return sp->cinfo.d.output_scanline < sp->cinfo.d.output_height ||
- TIFFjpeg_finish_decompress(sp);
-
-error:
-#if defined(JPEG_LIB_MK1_OR_12BIT)
- _TIFFfreeExt(tif, tmpbuf);
-#endif
- return 0;
-}
-
-/*
- * JPEG Encoding.
- */
-
-static void unsuppress_quant_table(JPEGState *sp, int tblno)
-{
- JQUANT_TBL *qtbl;
-
- if ((qtbl = sp->cinfo.c.quant_tbl_ptrs[tblno]) != NULL)
- qtbl->sent_table = FALSE;
-}
-
-static void suppress_quant_table(JPEGState *sp, int tblno)
-{
- JQUANT_TBL *qtbl;
-
- if ((qtbl = sp->cinfo.c.quant_tbl_ptrs[tblno]) != NULL)
- qtbl->sent_table = TRUE;
-}
-
-static void unsuppress_huff_table(JPEGState *sp, int tblno)
-{
- JHUFF_TBL *htbl;
-
- if ((htbl = sp->cinfo.c.dc_huff_tbl_ptrs[tblno]) != NULL)
- htbl->sent_table = FALSE;
- if ((htbl = sp->cinfo.c.ac_huff_tbl_ptrs[tblno]) != NULL)
- htbl->sent_table = FALSE;
-}
-
-static void suppress_huff_table(JPEGState *sp, int tblno)
-{
- JHUFF_TBL *htbl;
-
- if ((htbl = sp->cinfo.c.dc_huff_tbl_ptrs[tblno]) != NULL)
- htbl->sent_table = TRUE;
- if ((htbl = sp->cinfo.c.ac_huff_tbl_ptrs[tblno]) != NULL)
- htbl->sent_table = TRUE;
-}
-
-static int prepare_JPEGTables(TIFF *tif)
-{
- JPEGState *sp = JState(tif);
-
- /* Initialize quant tables for current quality setting */
- if (!TIFFjpeg_set_quality(sp, sp->otherSettings.jpegquality, FALSE))
- return (0);
- /* Mark only the tables we want for output */
- /* NB: chrominance tables are currently used only with YCbCr */
- if (!TIFFjpeg_suppress_tables(sp, TRUE))
- return (0);
- if (sp->otherSettings.jpegtablesmode & JPEGTABLESMODE_QUANT)
- {
- unsuppress_quant_table(sp, 0);
- if (sp->photometric == PHOTOMETRIC_YCBCR)
- unsuppress_quant_table(sp, 1);
- }
- if (sp->otherSettings.jpegtablesmode & JPEGTABLESMODE_HUFF)
- {
- unsuppress_huff_table(sp, 0);
- if (sp->photometric == PHOTOMETRIC_YCBCR)
- unsuppress_huff_table(sp, 1);
- }
- /* Direct libjpeg output into otherSettings.jpegtables */
- if (!TIFFjpeg_tables_dest(sp, tif))
- return (0);
- /* Emit tables-only datastream */
- if (!TIFFjpeg_write_tables(sp))
- return (0);
-
- return (1);
-}
-
-#if defined(JPEG_LIB_VERSION_MAJOR) && \
- (JPEG_LIB_VERSION_MAJOR > 9 || \
- (JPEG_LIB_VERSION_MAJOR == 9 && JPEG_LIB_VERSION_MINOR >= 4))
-/* This is a modified version of std_huff_tables() from jcparam.c
- * in libjpeg-9d because it no longer initializes default Huffman
- * tables in jpeg_set_defaults(). */
-static void TIFF_std_huff_tables(j_compress_ptr cinfo)
-{
-
- if (cinfo->dc_huff_tbl_ptrs[0] == NULL)
- {
- (void)jpeg_std_huff_table((j_common_ptr)cinfo, TRUE, 0);
- }
- if (cinfo->ac_huff_tbl_ptrs[0] == NULL)
- {
- (void)jpeg_std_huff_table((j_common_ptr)cinfo, FALSE, 0);
- }
- if (cinfo->dc_huff_tbl_ptrs[1] == NULL)
- {
- (void)jpeg_std_huff_table((j_common_ptr)cinfo, TRUE, 1);
- }
- if (cinfo->ac_huff_tbl_ptrs[1] == NULL)
- {
- (void)jpeg_std_huff_table((j_common_ptr)cinfo, FALSE, 1);
- }
-}
-#endif
-
-static int JPEGSetupEncode(TIFF *tif)
-{
- JPEGState *sp = JState(tif);
- TIFFDirectory *td = &tif->tif_dir;
- static const char module[] = "JPEGSetupEncode";
-
-#if defined(JPEG_DUAL_MODE_8_12) && !defined(FROM_TIF_JPEG_12)
- if (tif->tif_dir.td_bitspersample == 12)
- {
- /* We pass a pointer to a copy of otherSettings, since */
- /* TIFFReInitJPEG_12() will clear sp */
- JPEGOtherSettings savedOtherSettings = sp->otherSettings;
- return TIFFReInitJPEG_12(tif, &savedOtherSettings, COMPRESSION_JPEG, 1);
- }
-#endif
-
- JPEGInitializeLibJPEG(tif, FALSE);
-
- assert(sp != NULL);
- assert(!sp->cinfo.comm.is_decompressor);
-
- sp->photometric = td->td_photometric;
-
- /*
- * Initialize all JPEG parameters to default values.
- * Note that jpeg_set_defaults needs legal values for
- * in_color_space and input_components.
- */
- if (td->td_planarconfig == PLANARCONFIG_CONTIG)
- {
- sp->cinfo.c.input_components = td->td_samplesperpixel;
- if (sp->photometric == PHOTOMETRIC_YCBCR)
- {
- if (sp->otherSettings.jpegcolormode == JPEGCOLORMODE_RGB)
- {
- sp->cinfo.c.in_color_space = JCS_RGB;
- }
- else
- {
- sp->cinfo.c.in_color_space = JCS_YCbCr;
- }
- }
- else
- {
- if ((td->td_photometric == PHOTOMETRIC_MINISWHITE ||
- td->td_photometric == PHOTOMETRIC_MINISBLACK) &&
- td->td_samplesperpixel == 1)
- sp->cinfo.c.in_color_space = JCS_GRAYSCALE;
- else if (td->td_photometric == PHOTOMETRIC_RGB &&
- td->td_samplesperpixel == 3)
- sp->cinfo.c.in_color_space = JCS_RGB;
- else if (td->td_photometric == PHOTOMETRIC_SEPARATED &&
- td->td_samplesperpixel == 4)
- sp->cinfo.c.in_color_space = JCS_CMYK;
- else
- sp->cinfo.c.in_color_space = JCS_UNKNOWN;
- }
- }
- else
- {
- sp->cinfo.c.input_components = 1;
- sp->cinfo.c.in_color_space = JCS_UNKNOWN;
- }
- if (!TIFFjpeg_set_defaults(sp))
- return (0);
-
- /* mozjpeg by default enables progressive JPEG, which is illegal in
- * JPEG-in-TIFF */
- /* So explicitly disable it. */
- if (sp->cinfo.c.num_scans != 0 &&
- (sp->otherSettings.jpegtablesmode & JPEGTABLESMODE_HUFF) != 0)
- {
- /* it has been found that mozjpeg could create corrupt strips/tiles */
- /* in non optimize_coding mode. */
- TIFFWarningExtR(
- tif, module,
- "mozjpeg library likely detected. Disable emission of "
- "Huffman tables in JpegTables tag, and use optimize_coding "
- "to avoid potential issues");
- sp->otherSettings.jpegtablesmode &= ~JPEGTABLESMODE_HUFF;
- }
- sp->cinfo.c.num_scans = 0;
- sp->cinfo.c.scan_info = NULL;
-
- /* Set per-file parameters */
- switch (sp->photometric)
- {
- case PHOTOMETRIC_YCBCR:
- sp->h_sampling = td->td_ycbcrsubsampling[0];
- sp->v_sampling = td->td_ycbcrsubsampling[1];
- if (sp->h_sampling == 0 || sp->v_sampling == 0)
- {
- TIFFErrorExtR(tif, module,
- "Invalig horizontal/vertical sampling value");
- return (0);
- }
- if (td->td_bitspersample > 16)
- {
- TIFFErrorExtR(tif, module,
- "BitsPerSample %" PRIu16 " not allowed for JPEG",
- td->td_bitspersample);
- return (0);
- }
-
- /*
- * A ReferenceBlackWhite field *must* be present since the
- * default value is inappropriate for YCbCr. Fill in the
- * proper value if application didn't set it.
- */
- {
- float *ref;
- if (!TIFFGetField(tif, TIFFTAG_REFERENCEBLACKWHITE, &ref))
- {
- float refbw[6];
- long top = 1L << td->td_bitspersample;
- refbw[0] = 0;
- refbw[1] = (float)(top - 1L);
- refbw[2] = (float)(top >> 1);
- refbw[3] = refbw[1];
- refbw[4] = refbw[2];
- refbw[5] = refbw[1];
- TIFFSetField(tif, TIFFTAG_REFERENCEBLACKWHITE, refbw);
- }
- }
- break;
- case PHOTOMETRIC_PALETTE: /* disallowed by Tech Note */
- case PHOTOMETRIC_MASK:
- TIFFErrorExtR(tif, module,
- "PhotometricInterpretation %" PRIu16
- " not allowed for JPEG",
- sp->photometric);
- return (0);
- default:
- /* TIFF 6.0 forbids subsampling of all other color spaces */
- sp->h_sampling = 1;
- sp->v_sampling = 1;
- break;
- }
-
- /* Verify miscellaneous parameters */
-
- /*
- * This would need work if libtiff ever supports different
- * depths for different components, or if libjpeg ever supports
- * run-time selection of depth. Neither is imminent.
- */
-#ifdef JPEG_LIB_MK1
- /* BITS_IN_JSAMPLE now permits 8 and 12 --- dgilbert */
- if (td->td_bitspersample != 8 && td->td_bitspersample != 12)
-#else
- if (td->td_bitspersample != BITS_IN_JSAMPLE)
-#endif
- {
- TIFFErrorExtR(tif, module,
- "BitsPerSample %" PRIu16 " not allowed for JPEG",
- td->td_bitspersample);
- return (0);
- }
- sp->cinfo.c.data_precision = td->td_bitspersample;
-#ifdef JPEG_LIB_MK1
- sp->cinfo.c.bits_in_jsample = td->td_bitspersample;
-#endif
- if (isTiled(tif))
- {
- if ((td->td_tilelength % (sp->v_sampling * DCTSIZE)) != 0)
- {
- TIFFErrorExtR(tif, module,
- "JPEG tile height must be multiple of %" PRIu32,
- (uint32_t)(sp->v_sampling * DCTSIZE));
- return (0);
- }
- if ((td->td_tilewidth % (sp->h_sampling * DCTSIZE)) != 0)
- {
- TIFFErrorExtR(tif, module,
- "JPEG tile width must be multiple of %" PRIu32,
- (uint32_t)(sp->h_sampling * DCTSIZE));
- return (0);
- }
- }
- else
- {
- if (td->td_rowsperstrip < td->td_imagelength &&
- (td->td_rowsperstrip % (sp->v_sampling * DCTSIZE)) != 0)
- {
- TIFFErrorExtR(tif, module,
- "RowsPerStrip must be multiple of %" PRIu32
- " for JPEG",
- (uint32_t)(sp->v_sampling * DCTSIZE));
- return (0);
- }
- }
-
- /* Create a JPEGTables field if appropriate */
- if (sp->otherSettings.jpegtablesmode &
- (JPEGTABLESMODE_QUANT | JPEGTABLESMODE_HUFF))
- {
- if (sp->otherSettings.jpegtables == NULL ||
- memcmp(sp->otherSettings.jpegtables, "\0\0\0\0\0\0\0\0\0", 8) == 0)
- {
-#if defined(JPEG_LIB_VERSION_MAJOR) && \
- (JPEG_LIB_VERSION_MAJOR > 9 || \
- (JPEG_LIB_VERSION_MAJOR == 9 && JPEG_LIB_VERSION_MINOR >= 4))
- if ((sp->otherSettings.jpegtablesmode & JPEGTABLESMODE_HUFF) != 0 &&
- (sp->cinfo.c.dc_huff_tbl_ptrs[0] == NULL ||
- sp->cinfo.c.dc_huff_tbl_ptrs[1] == NULL ||
- sp->cinfo.c.ac_huff_tbl_ptrs[0] == NULL ||
- sp->cinfo.c.ac_huff_tbl_ptrs[1] == NULL))
- {
- /* libjpeg-9d no longer initializes default Huffman tables in */
- /* jpeg_set_defaults() */
- TIFF_std_huff_tables(&sp->cinfo.c);
- }
-#endif
-
- if (!prepare_JPEGTables(tif))
- return (0);
- /* Mark the field present */
- /* Can't use TIFFSetField since BEENWRITING is already set! */
- tif->tif_flags |= TIFF_DIRTYDIRECT;
- TIFFSetFieldBit(tif, FIELD_JPEGTABLES);
- }
- }
- else
- {
- /* We do not support application-supplied JPEGTables, */
- /* so mark the field not present */
- TIFFClrFieldBit(tif, FIELD_JPEGTABLES);
- }
-
- /* Direct libjpeg output to libtiff's output buffer */
- TIFFjpeg_data_dest(sp, tif);
-
- return (1);
-}
-
-/*
- * Set encoding state at the start of a strip or tile.
- */
-static int JPEGPreEncode(TIFF *tif, uint16_t s)
-{
- JPEGState *sp = JState(tif);
- TIFFDirectory *td = &tif->tif_dir;
- static const char module[] = "JPEGPreEncode";
- uint32_t segment_width, segment_height;
- int downsampled_input;
-
- assert(sp != NULL);
-
- if (sp->cinfo.comm.is_decompressor == 1)
- {
- tif->tif_setupencode(tif);
- }
-
- assert(!sp->cinfo.comm.is_decompressor);
- /*
- * Set encoding parameters for this strip/tile.
- */
- if (isTiled(tif))
- {
- segment_width = td->td_tilewidth;
- segment_height = td->td_tilelength;
- sp->bytesperline = TIFFTileRowSize(tif);
- }
- else
- {
- segment_width = td->td_imagewidth;
- segment_height = td->td_imagelength - tif->tif_row;
- if (segment_height > td->td_rowsperstrip)
- segment_height = td->td_rowsperstrip;
- sp->bytesperline = TIFFScanlineSize(tif);
- }
- if (td->td_planarconfig == PLANARCONFIG_SEPARATE && s > 0)
- {
- /* for PC 2, scale down the strip/tile size
- * to match a downsampled component
- */
- if (sp->h_sampling == 0 || sp->v_sampling == 0)
- {
- TIFFErrorExtR(tif, module,
- "JPEG horizontal or vertical sampling is zero");
- return (0);
- }
- segment_width = TIFFhowmany_32(segment_width, sp->h_sampling);
- segment_height = TIFFhowmany_32(segment_height, sp->v_sampling);
- }
- if (segment_width > 65535 || segment_height > 65535)
- {
- TIFFErrorExtR(tif, module, "Strip/tile too large for JPEG");
- return (0);
- }
- sp->cinfo.c.image_width = segment_width;
- sp->cinfo.c.image_height = segment_height;
- downsampled_input = FALSE;
- if (td->td_planarconfig == PLANARCONFIG_CONTIG)
- {
- sp->cinfo.c.input_components = td->td_samplesperpixel;
- if (sp->photometric == PHOTOMETRIC_YCBCR)
- {
- if (sp->otherSettings.jpegcolormode != JPEGCOLORMODE_RGB)
- {
- if (sp->h_sampling != 1 || sp->v_sampling != 1)
- downsampled_input = TRUE;
- }
- if (!TIFFjpeg_set_colorspace(sp, JCS_YCbCr))
- return (0);
- /*
- * Set Y sampling factors;
- * we assume jpeg_set_colorspace() set the rest to 1
- */
- sp->cinfo.c.comp_info[0].h_samp_factor = sp->h_sampling;
- sp->cinfo.c.comp_info[0].v_samp_factor = sp->v_sampling;
- }
- else
- {
- if (!TIFFjpeg_set_colorspace(sp, sp->cinfo.c.in_color_space))
- return (0);
- /* jpeg_set_colorspace set all sampling factors to 1 */
- }
- }
- else
- {
- if (!TIFFjpeg_set_colorspace(sp, JCS_UNKNOWN))
- return (0);
- sp->cinfo.c.comp_info[0].component_id = s;
- /* jpeg_set_colorspace() set sampling factors to 1 */
- if (sp->photometric == PHOTOMETRIC_YCBCR && s > 0)
- {
- sp->cinfo.c.comp_info[0].quant_tbl_no = 1;
- sp->cinfo.c.comp_info[0].dc_tbl_no = 1;
- sp->cinfo.c.comp_info[0].ac_tbl_no = 1;
- }
- }
- /* ensure libjpeg won't write any extraneous markers */
- sp->cinfo.c.write_JFIF_header = FALSE;
- sp->cinfo.c.write_Adobe_marker = FALSE;
- /* set up table handling correctly */
- /* calling TIFFjpeg_set_quality() causes quantization tables to be flagged
- */
- /* as being to be emitted, which we don't want in the JPEGTABLESMODE_QUANT
- */
- /* mode, so we must manually suppress them. However TIFFjpeg_set_quality()
- */
- /* should really be called when dealing with files with directories with */
- /* mixed qualities. see http://trac.osgeo.org/gdal/ticket/3539 */
- if (!TIFFjpeg_set_quality(sp, sp->otherSettings.jpegquality, FALSE))
- return (0);
- if (sp->otherSettings.jpegtablesmode & JPEGTABLESMODE_QUANT)
- {
- suppress_quant_table(sp, 0);
- suppress_quant_table(sp, 1);
- }
- else
- {
- unsuppress_quant_table(sp, 0);
- unsuppress_quant_table(sp, 1);
- }
- if (sp->otherSettings.jpegtablesmode & JPEGTABLESMODE_HUFF)
- {
- /* Explicit suppression is only needed if we did not go through the */
- /* prepare_JPEGTables() code path, which may be the case if updating */
- /* an existing file */
- suppress_huff_table(sp, 0);
- suppress_huff_table(sp, 1);
- sp->cinfo.c.optimize_coding = FALSE;
- }
- else
- sp->cinfo.c.optimize_coding = TRUE;
- if (downsampled_input)
- {
- /* Need to use raw-data interface to libjpeg */
- sp->cinfo.c.raw_data_in = TRUE;
- tif->tif_encoderow = JPEGEncodeRaw;
- tif->tif_encodestrip = JPEGEncodeRaw;
- tif->tif_encodetile = JPEGEncodeRaw;
- }
- else
- {
- /* Use normal interface to libjpeg */
- sp->cinfo.c.raw_data_in = FALSE;
- tif->tif_encoderow = JPEGEncode;
- tif->tif_encodestrip = JPEGEncode;
- tif->tif_encodetile = JPEGEncode;
- }
- /* Start JPEG compressor */
- if (!TIFFjpeg_start_compress(sp, FALSE))
- return (0);
- /* Allocate downsampled-data buffers if needed */
- if (downsampled_input)
- {
- if (!alloc_downsampled_buffers(tif, sp->cinfo.c.comp_info,
- sp->cinfo.c.num_components))
- return (0);
- }
- sp->scancount = 0;
-
- return (1);
-}
-
-/*
- * Encode a chunk of pixels.
- * "Standard" case: incoming data is not downsampled.
- */
-static int JPEGEncode(TIFF *tif, uint8_t *buf, tmsize_t cc, uint16_t s)
-{
- JPEGState *sp = JState(tif);
- tmsize_t nrows;
- TIFF_JSAMPROW bufptr[1];
- short *line16 = NULL;
- int line16_count = 0;
-
- (void)s;
- assert(sp != NULL);
- /* data is expected to be supplied in multiples of a scanline */
- nrows = cc / sp->bytesperline;
- if (cc % sp->bytesperline)
- TIFFWarningExtR(tif, tif->tif_name, "fractional scanline discarded");
-
- /* The last strip will be limited to image size */
- if (!isTiled(tif) && tif->tif_row + nrows > tif->tif_dir.td_imagelength)
- nrows = tif->tif_dir.td_imagelength - tif->tif_row;
-
- if (sp->cinfo.c.data_precision == 12)
- {
- line16_count = (int)((sp->bytesperline * 2) / 3);
- line16 = (short *)_TIFFmallocExt(tif, sizeof(short) * line16_count);
- if (!line16)
- {
- TIFFErrorExtR(tif, "JPEGEncode", "Failed to allocate memory");
-
- return 0;
- }
- }
-
- while (nrows-- > 0)
- {
-
- if (sp->cinfo.c.data_precision == 12)
- {
-
- int value_pairs = line16_count / 2;
- int iPair;
-
- bufptr[0] = (TIFF_JSAMPROW)line16;
-
- for (iPair = 0; iPair < value_pairs; iPair++)
- {
- unsigned char *in_ptr = ((unsigned char *)buf) + iPair * 3;
- TIFF_JSAMPLE *out_ptr = (TIFF_JSAMPLE *)(line16 + iPair * 2);
-
- out_ptr[0] = (in_ptr[0] << 4) | ((in_ptr[1] & 0xf0) >> 4);
- out_ptr[1] = ((in_ptr[1] & 0x0f) << 8) | in_ptr[2];
- }
- }
- else
- {
- bufptr[0] = (TIFF_JSAMPROW)buf;
- }
- if (TIFFjpeg_write_scanlines(sp, bufptr, 1) != 1)
- return (0);
- if (nrows > 0)
- tif->tif_row++;
- buf += sp->bytesperline;
- }
-
- if (sp->cinfo.c.data_precision == 12)
- {
- _TIFFfreeExt(tif, line16);
- }
-
- return (1);
-}
-
-/*
- * Encode a chunk of pixels.
- * Incoming data is expected to be downsampled per sampling factors.
- */
-static int JPEGEncodeRaw(TIFF *tif, uint8_t *buf, tmsize_t cc, uint16_t s)
-{
- JPEGState *sp = JState(tif);
- TIFF_JSAMPLE *inptr;
- TIFF_JSAMPLE *outptr;
- tmsize_t nrows;
- JDIMENSION clumps_per_line, nclump;
- int clumpoffset, ci, xpos, ypos;
- jpeg_component_info *compptr;
- int samples_per_clump = sp->samplesperclump;
- tmsize_t bytesperclumpline;
-
- (void)s;
- assert(sp != NULL);
- /* data is expected to be supplied in multiples of a clumpline */
- /* a clumpline is equivalent to v_sampling desubsampled scanlines */
- /* TODO: the following calculation of bytesperclumpline, should substitute
- * calculation of sp->bytesperline, except that it is per v_sampling lines
- */
- bytesperclumpline =
- ((((tmsize_t)sp->cinfo.c.image_width + sp->h_sampling - 1) /
- sp->h_sampling) *
- ((tmsize_t)sp->h_sampling * sp->v_sampling + 2) *
- sp->cinfo.c.data_precision +
- 7) /
- 8;
-
- nrows = (cc / bytesperclumpline) * sp->v_sampling;
- if (cc % bytesperclumpline)
- TIFFWarningExtR(tif, tif->tif_name, "fractional scanline discarded");
-
- /* Cb,Cr both have sampling factors 1, so this is correct */
- clumps_per_line = sp->cinfo.c.comp_info[1].downsampled_width;
-
- while (nrows > 0)
- {
- /*
- * Fastest way to separate the data is to make one pass
- * over the scanline for each row of each component.
- */
- clumpoffset = 0; /* first sample in clump */
- for (ci = 0, compptr = sp->cinfo.c.comp_info;
- ci < sp->cinfo.c.num_components; ci++, compptr++)
- {
- int hsamp = compptr->h_samp_factor;
- int vsamp = compptr->v_samp_factor;
- int padding = (int)(compptr->width_in_blocks * DCTSIZE -
- clumps_per_line * hsamp);
- for (ypos = 0; ypos < vsamp; ypos++)
- {
- inptr = ((TIFF_JSAMPLE *)buf) + clumpoffset;
- outptr = sp->ds_buffer[ci][sp->scancount * vsamp + ypos];
- if (hsamp == 1)
- {
- /* fast path for at least Cb and Cr */
- for (nclump = clumps_per_line; nclump-- > 0;)
- {
- *outptr++ = inptr[0];
- inptr += samples_per_clump;
- }
- }
- else
- {
- /* general case */
- for (nclump = clumps_per_line; nclump-- > 0;)
- {
- for (xpos = 0; xpos < hsamp; xpos++)
- *outptr++ = inptr[xpos];
- inptr += samples_per_clump;
- }
- }
- /* pad each scanline as needed */
- for (xpos = 0; xpos < padding; xpos++)
- {
- *outptr = outptr[-1];
- outptr++;
- }
- clumpoffset += hsamp;
- }
- }
- sp->scancount++;
- if (sp->scancount >= DCTSIZE)
- {
- int n = sp->cinfo.c.max_v_samp_factor * DCTSIZE;
- if (TIFFjpeg_write_raw_data(sp, sp->ds_buffer, n) != n)
- return (0);
- sp->scancount = 0;
- }
- tif->tif_row += sp->v_sampling;
- buf += bytesperclumpline;
- nrows -= sp->v_sampling;
- }
- return (1);
-}
-
-/*
- * Finish up at the end of a strip or tile.
- */
-static int JPEGPostEncode(TIFF *tif)
-{
- JPEGState *sp = JState(tif);
-
- if (sp->scancount > 0)
- {
- /*
- * Need to emit a partial bufferload of downsampled data.
- * Pad the data vertically.
- */
- int ci, ypos, n;
- jpeg_component_info *compptr;
-
- for (ci = 0, compptr = sp->cinfo.c.comp_info;
- ci < sp->cinfo.c.num_components; ci++, compptr++)
- {
- int vsamp = compptr->v_samp_factor;
- tmsize_t row_width =
- compptr->width_in_blocks * DCTSIZE * sizeof(JSAMPLE);
- for (ypos = sp->scancount * vsamp; ypos < DCTSIZE * vsamp; ypos++)
- {
- _TIFFmemcpy((void *)sp->ds_buffer[ci][ypos],
- (void *)sp->ds_buffer[ci][ypos - 1], row_width);
- }
- }
- n = sp->cinfo.c.max_v_samp_factor * DCTSIZE;
- if (TIFFjpeg_write_raw_data(sp, sp->ds_buffer, n) != n)
- return (0);
- }
-
- return (TIFFjpeg_finish_compress(JState(tif)));
-}
-
-static void JPEGCleanup(TIFF *tif)
-{
- JPEGState *sp = JState(tif);
-
- assert(sp != 0);
-
- tif->tif_tagmethods.vgetfield = sp->otherSettings.vgetparent;
- tif->tif_tagmethods.vsetfield = sp->otherSettings.vsetparent;
- tif->tif_tagmethods.printdir = sp->otherSettings.printdir;
- if (sp->cinfo_initialized)
- TIFFjpeg_destroy(sp); /* release libjpeg resources */
- if (sp->otherSettings.jpegtables) /* tag value */
- _TIFFfreeExt(tif, sp->otherSettings.jpegtables);
- _TIFFfreeExt(tif, tif->tif_data); /* release local state */
- tif->tif_data = NULL;
-
- _TIFFSetDefaultCompressionState(tif);
-}
-
-static void JPEGResetUpsampled(TIFF *tif)
-{
- JPEGState *sp = JState(tif);
- TIFFDirectory *td = &tif->tif_dir;
-
- /*
- * Mark whether returned data is up-sampled or not so TIFFStripSize
- * and TIFFTileSize return values that reflect the true amount of
- * data.
- */
- tif->tif_flags &= ~TIFF_UPSAMPLED;
- if (td->td_planarconfig == PLANARCONFIG_CONTIG)
- {
- if (td->td_photometric == PHOTOMETRIC_YCBCR &&
- sp->otherSettings.jpegcolormode == JPEGCOLORMODE_RGB)
- {
- tif->tif_flags |= TIFF_UPSAMPLED;
- }
- else
- {
-#ifdef notdef
- if (td->td_ycbcrsubsampling[0] != 1 ||
- td->td_ycbcrsubsampling[1] != 1)
- ; /* XXX what about up-sampling? */
-#endif
- }
- }
-
- /*
- * Must recalculate cached tile size in case sampling state changed.
- * Should we really be doing this now if image size isn't set?
- */
- if (tif->tif_tilesize > 0)
- tif->tif_tilesize = isTiled(tif) ? TIFFTileSize(tif) : (tmsize_t)(-1);
- if (tif->tif_scanlinesize > 0)
- tif->tif_scanlinesize = TIFFScanlineSize(tif);
-}
-
-static int JPEGVSetField(TIFF *tif, uint32_t tag, va_list ap)
-{
- JPEGState *sp = JState(tif);
- const TIFFField *fip;
- uint32_t v32;
-
- assert(sp != NULL);
-
- switch (tag)
- {
- case TIFFTAG_JPEGTABLES:
- v32 = (uint32_t)va_arg(ap, uint32_t);
- if (v32 == 0)
- {
- /* XXX */
- return (0);
- }
- _TIFFsetByteArrayExt(tif, &sp->otherSettings.jpegtables,
- va_arg(ap, void *), v32);
- sp->otherSettings.jpegtables_length = v32;
- TIFFSetFieldBit(tif, FIELD_JPEGTABLES);
- break;
- case TIFFTAG_JPEGQUALITY:
- sp->otherSettings.jpegquality = (int)va_arg(ap, int);
- return (1); /* pseudo tag */
- case TIFFTAG_JPEGCOLORMODE:
- sp->otherSettings.jpegcolormode = (int)va_arg(ap, int);
- JPEGResetUpsampled(tif);
- return (1); /* pseudo tag */
- case TIFFTAG_PHOTOMETRIC:
- {
- int ret_value = (*sp->otherSettings.vsetparent)(tif, tag, ap);
- JPEGResetUpsampled(tif);
- return ret_value;
- }
- case TIFFTAG_JPEGTABLESMODE:
- sp->otherSettings.jpegtablesmode = (int)va_arg(ap, int);
- return (1); /* pseudo tag */
- case TIFFTAG_YCBCRSUBSAMPLING:
- /* mark the fact that we have a real ycbcrsubsampling! */
- sp->otherSettings.ycbcrsampling_fetched = 1;
- /* should we be recomputing upsampling info here? */
- return (*sp->otherSettings.vsetparent)(tif, tag, ap);
- default:
- return (*sp->otherSettings.vsetparent)(tif, tag, ap);
- }
-
- if ((fip = TIFFFieldWithTag(tif, tag)) != NULL)
- {
- TIFFSetFieldBit(tif, fip->field_bit);
- }
- else
- {
- return (0);
- }
-
- tif->tif_flags |= TIFF_DIRTYDIRECT;
- return (1);
-}
-
-static int JPEGVGetField(TIFF *tif, uint32_t tag, va_list ap)
-{
- JPEGState *sp = JState(tif);
-
- assert(sp != NULL);
-
- switch (tag)
- {
- case TIFFTAG_JPEGTABLES:
- *va_arg(ap, uint32_t *) = sp->otherSettings.jpegtables_length;
- *va_arg(ap, const void **) = sp->otherSettings.jpegtables;
- break;
- case TIFFTAG_JPEGQUALITY:
- *va_arg(ap, int *) = sp->otherSettings.jpegquality;
- break;
- case TIFFTAG_JPEGCOLORMODE:
- *va_arg(ap, int *) = sp->otherSettings.jpegcolormode;
- break;
- case TIFFTAG_JPEGTABLESMODE:
- *va_arg(ap, int *) = sp->otherSettings.jpegtablesmode;
- break;
- default:
- return (*sp->otherSettings.vgetparent)(tif, tag, ap);
- }
- return (1);
-}
-
-static void JPEGPrintDir(TIFF *tif, FILE *fd, long flags)
-{
- JPEGState *sp = JState(tif);
-
- assert(sp != NULL);
- (void)flags;
-
- if (sp != NULL)
- {
- if (TIFFFieldSet(tif, FIELD_JPEGTABLES))
- fprintf(fd, " JPEG Tables: (%" PRIu32 " bytes)\n",
- sp->otherSettings.jpegtables_length);
- if (sp->otherSettings.printdir)
- (*sp->otherSettings.printdir)(tif, fd, flags);
- }
-}
-
-static uint32_t JPEGDefaultStripSize(TIFF *tif, uint32_t s)
-{
- JPEGState *sp = JState(tif);
- TIFFDirectory *td = &tif->tif_dir;
-
- s = (*sp->otherSettings.defsparent)(tif, s);
- if (s < td->td_imagelength)
- s = TIFFroundup_32(s, td->td_ycbcrsubsampling[1] * DCTSIZE);
- return (s);
-}
-
-static void JPEGDefaultTileSize(TIFF *tif, uint32_t *tw, uint32_t *th)
-{
- JPEGState *sp = JState(tif);
- TIFFDirectory *td = &tif->tif_dir;
-
- (*sp->otherSettings.deftparent)(tif, tw, th);
- *tw = TIFFroundup_32(*tw, td->td_ycbcrsubsampling[0] * DCTSIZE);
- *th = TIFFroundup_32(*th, td->td_ycbcrsubsampling[1] * DCTSIZE);
-}
-
-/*
- * The JPEG library initialized used to be done in TIFFInitJPEG(), but
- * now that we allow a TIFF file to be opened in update mode it is necessary
- * to have some way of deciding whether compression or decompression is
- * desired other than looking at tif->tif_mode. We accomplish this by
- * examining {TILE/STRIP}BYTECOUNTS to see if there is a non-zero entry.
- * If so, we assume decompression is desired.
- *
- * This is tricky, because TIFFInitJPEG() is called while the directory is
- * being read, and generally speaking the BYTECOUNTS tag won't have been read
- * at that point. So we try to defer jpeg library initialization till we
- * do have that tag ... basically any access that might require the compressor
- * or decompressor that occurs after the reading of the directory.
- *
- * In an ideal world compressors or decompressors would be setup
- * at the point where a single tile or strip was accessed (for read or write)
- * so that stuff like update of missing tiles, or replacement of tiles could
- * be done. However, we aren't trying to crack that nut just yet ...
- *
- * NFW, Feb 3rd, 2003.
- */
-
-static int JPEGInitializeLibJPEG(TIFF *tif, int decompress)
-{
- JPEGState *sp = JState(tif);
-
- if (sp->cinfo_initialized)
- {
- if (!decompress && sp->cinfo.comm.is_decompressor)
- TIFFjpeg_destroy(sp);
- else if (decompress && !sp->cinfo.comm.is_decompressor)
- TIFFjpeg_destroy(sp);
- else
- return 1;
-
- sp->cinfo_initialized = 0;
- }
-
- /*
- * Initialize libjpeg.
- */
- if (decompress)
- {
- if (!TIFFjpeg_create_decompress(sp))
- return (0);
- }
- else
- {
- if (!TIFFjpeg_create_compress(sp))
- return (0);
-#ifndef TIFF_JPEG_MAX_MEMORY_TO_USE
-#define TIFF_JPEG_MAX_MEMORY_TO_USE (10 * 1024 * 1024)
-#endif
- /* libjpeg turbo 1.5.2 honours max_memory_to_use, but has no backing */
- /* store implementation, so better not set max_memory_to_use ourselves.
- */
- /* See https://github.com/libjpeg-turbo/libjpeg-turbo/issues/162 */
- if (sp->cinfo.c.mem->max_memory_to_use > 0)
- {
- /* This is to address bug related in ticket GDAL #1795. */
- if (getenv("JPEGMEM") == NULL)
- {
- /* Increase the max memory usable. This helps when creating
- * files */
- /* with "big" tile, without using libjpeg temporary files. */
- /* For example a 512x512 tile with 3 bands */
- /* requires 1.5 MB which is above libjpeg 1MB default */
- if (sp->cinfo.c.mem->max_memory_to_use <
- TIFF_JPEG_MAX_MEMORY_TO_USE)
- sp->cinfo.c.mem->max_memory_to_use =
- TIFF_JPEG_MAX_MEMORY_TO_USE;
- }
- }
- }
-
- sp->cinfo_initialized = TRUE;
-
- return 1;
-}
-
-/* Common to tif_jpeg.c and tif_jpeg_12.c */
-static void TIFFInitJPEGCommon(TIFF *tif)
-{
- JPEGState *sp;
-
- sp = JState(tif);
- sp->tif = tif; /* back link */
-
- /* Default values for codec-specific fields */
- sp->otherSettings.jpegtables = NULL;
- sp->otherSettings.jpegtables_length = 0;
- sp->otherSettings.jpegquality = 75; /* Default IJG quality */
- sp->otherSettings.jpegcolormode = JPEGCOLORMODE_RAW;
- sp->otherSettings.jpegtablesmode =
- JPEGTABLESMODE_QUANT | JPEGTABLESMODE_HUFF;
- sp->otherSettings.ycbcrsampling_fetched = 0;
-
- tif->tif_tagmethods.vgetfield = JPEGVGetField; /* hook for codec tags */
- tif->tif_tagmethods.vsetfield = JPEGVSetField; /* hook for codec tags */
- tif->tif_tagmethods.printdir = JPEGPrintDir; /* hook for codec tags */
-
- /*
- * Install codec methods.
- */
- tif->tif_fixuptags = JPEGFixupTags;
- tif->tif_setupdecode = JPEGSetupDecode;
- tif->tif_predecode = JPEGPreDecode;
- tif->tif_decoderow = JPEGDecode;
- tif->tif_decodestrip = JPEGDecode;
- tif->tif_decodetile = JPEGDecode;
- tif->tif_setupencode = JPEGSetupEncode;
- tif->tif_preencode = JPEGPreEncode;
- tif->tif_postencode = JPEGPostEncode;
- tif->tif_encoderow = JPEGEncode;
- tif->tif_encodestrip = JPEGEncode;
- tif->tif_encodetile = JPEGEncode;
- tif->tif_cleanup = JPEGCleanup;
-
- tif->tif_defstripsize = JPEGDefaultStripSize;
- tif->tif_deftilesize = JPEGDefaultTileSize;
- tif->tif_flags |= TIFF_NOBITREV; /* no bit reversal, please */
- sp->cinfo_initialized = FALSE;
-}
-
-int TIFFInitJPEG(TIFF *tif, int scheme)
-{
- JPEGState *sp;
-
- (void)scheme;
- assert(scheme == COMPRESSION_JPEG);
-
- /*
- * Merge codec-specific tag information.
- */
- if (!_TIFFMergeFields(tif, jpegFields, TIFFArrayCount(jpegFields)))
- {
- TIFFErrorExtR(tif, "TIFFInitJPEG",
- "Merging JPEG codec-specific tags failed");
- return 0;
- }
-
- /*
- * Allocate state block so tag methods have storage to record values.
- */
- tif->tif_data = (uint8_t *)_TIFFmallocExt(tif, sizeof(JPEGState));
-
- if (tif->tif_data == NULL)
- {
- TIFFErrorExtR(tif, "TIFFInitJPEG", "No space for JPEG state block");
- return 0;
- }
- _TIFFmemset(tif->tif_data, 0, sizeof(JPEGState));
-
- sp = JState(tif);
- /*
- * Override parent get/set field methods.
- */
- sp->otherSettings.vgetparent = tif->tif_tagmethods.vgetfield;
- sp->otherSettings.vsetparent = tif->tif_tagmethods.vsetfield;
- sp->otherSettings.printdir = tif->tif_tagmethods.printdir;
-
- sp->otherSettings.defsparent = tif->tif_defstripsize;
- sp->otherSettings.deftparent = tif->tif_deftilesize;
-
- TIFFInitJPEGCommon(tif);
-
- /*
- ** Create a JPEGTables field if no directory has yet been created.
- ** We do this just to ensure that sufficient space is reserved for
- ** the JPEGTables field. It will be properly created the right
- ** size later.
- */
- if (tif->tif_diroff == 0)
- {
-#define SIZE_OF_JPEGTABLES 2000
- /*
- The following line assumes incorrectly that all JPEG-in-TIFF files will
- have a JPEGTABLES tag generated and causes null-filled JPEGTABLES tags
- to be written when the JPEG data is placed with TIFFWriteRawStrip. The
- field bit should be set, anyway, later when actual JPEGTABLES header is
- generated, so removing it here hopefully is harmless.
- TIFFSetFieldBit(tif, FIELD_JPEGTABLES);
- */
- sp->otherSettings.jpegtables_length = SIZE_OF_JPEGTABLES;
- sp->otherSettings.jpegtables =
- (void *)_TIFFmallocExt(tif, sp->otherSettings.jpegtables_length);
- if (sp->otherSettings.jpegtables)
- {
- _TIFFmemset(sp->otherSettings.jpegtables, 0, SIZE_OF_JPEGTABLES);
- }
- else
- {
- TIFFErrorExtR(tif, "TIFFInitJPEG",
- "Failed to allocate memory for JPEG tables");
- return 0;
- }
-#undef SIZE_OF_JPEGTABLES
- }
- return 1;
-}
-#endif /* JPEG_SUPPORT */
diff --git a/contrib/libs/libtiff/tif_jpeg_12.c b/contrib/libs/libtiff/tif_jpeg_12.c
deleted file mode 100644
index a8db8beafb..0000000000
--- a/contrib/libs/libtiff/tif_jpeg_12.c
+++ /dev/null
@@ -1,63 +0,0 @@
-
-#include "tiffiop.h"
-
-#if defined(HAVE_JPEGTURBO_DUAL_MODE_8_12)
-#define JPEG_DUAL_MODE_8_12
-#endif
-
-#if defined(JPEG_DUAL_MODE_8_12)
-
-#define FROM_TIF_JPEG_12
-
-#ifdef TIFFInitJPEG
-#undef TIFFInitJPEG
-#endif
-#define TIFFInitJPEG TIFFInitJPEG_12
-
-#ifdef TIFFJPEGIsFullStripRequired
-#undef TIFFJPEGIsFullStripRequired
-#endif
-#define TIFFJPEGIsFullStripRequired TIFFJPEGIsFullStripRequired_12
-
-int TIFFInitJPEG_12(TIFF *tif, int scheme);
-
-#if !defined(HAVE_JPEGTURBO_DUAL_MODE_8_12)
-#error #include LIBJPEG_12_PATH
-#endif
-
-#include "tif_jpeg.c"
-
-int TIFFReInitJPEG_12(TIFF *tif, const JPEGOtherSettings *otherSettings,
- int scheme, int is_encode)
-{
- JPEGState *sp;
- uint8_t *new_tif_data;
-
- (void)scheme;
- assert(scheme == COMPRESSION_JPEG);
-
- new_tif_data =
- (uint8_t *)_TIFFreallocExt(tif, tif->tif_data, sizeof(JPEGState));
-
- if (new_tif_data == NULL)
- {
- TIFFErrorExtR(tif, "TIFFReInitJPEG_12",
- "No space for JPEG state block");
- return 0;
- }
-
- tif->tif_data = new_tif_data;
- _TIFFmemset(tif->tif_data, 0, sizeof(JPEGState));
-
- TIFFInitJPEGCommon(tif);
-
- sp = JState(tif);
- sp->otherSettings = *otherSettings;
-
- if (is_encode)
- return JPEGSetupEncode(tif);
- else
- return JPEGSetupDecode(tif);
-}
-
-#endif /* defined(JPEG_DUAL_MODE_8_12) */
diff --git a/contrib/libs/libtiff/tif_lerc.c b/contrib/libs/libtiff/tif_lerc.c
deleted file mode 100644
index 29be0110d2..0000000000
--- a/contrib/libs/libtiff/tif_lerc.c
+++ /dev/null
@@ -1,1541 +0,0 @@
-/*
- * Copyright (c) 2018, Even Rouault
- * Author: <even.rouault at spatialys.com>
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-#include "tiffiop.h"
-#ifdef LERC_SUPPORT
-/*
- * TIFF Library.
- *
- * LERC Compression Support
- *
- */
-
-#error #include "Lerc_c_api.h"
-#include "zlib.h"
-#ifdef ZSTD_SUPPORT
-#include "zstd.h"
-#endif
-
-#if LIBDEFLATE_SUPPORT
-#error #include "libdeflate.h"
-#endif
-#define LIBDEFLATE_MAX_COMPRESSION_LEVEL 12
-
-#include <assert.h>
-
-#define LSTATE_INIT_DECODE 0x01
-#define LSTATE_INIT_ENCODE 0x02
-
-#ifndef LERC_AT_LEAST_VERSION
-#define LERC_AT_LEAST_VERSION(maj, min, patch) 0
-#endif
-
-/*
- * State block for each open TIFF file using LERC compression/decompression.
- */
-typedef struct
-{
- double maxzerror; /* max z error */
- int lerc_version;
- int additional_compression;
- int zstd_compress_level; /* zstd */
- int zipquality; /* deflate */
- int state; /* state flags */
-
- uint32_t segment_width;
- uint32_t segment_height;
-
- unsigned int uncompressed_size;
- unsigned int uncompressed_alloc;
- uint8_t *uncompressed_buffer;
- unsigned int uncompressed_offset;
-
- uint8_t *uncompressed_buffer_multiband;
- unsigned int uncompressed_buffer_multiband_alloc;
-
- unsigned int mask_size;
- uint8_t *mask_buffer;
-
- unsigned int compressed_size;
- void *compressed_buffer;
-
-#if LIBDEFLATE_SUPPORT
- struct libdeflate_decompressor *libdeflate_dec;
- struct libdeflate_compressor *libdeflate_enc;
-#endif
-
- TIFFVGetMethod vgetparent; /* super-class method */
- TIFFVSetMethod vsetparent; /* super-class method */
-} LERCState;
-
-#define GetLERCState(tif) ((LERCState *)(tif)->tif_data)
-#define LERCDecoderState(tif) GetLERCState(tif)
-#define LERCEncoderState(tif) GetLERCState(tif)
-
-static int LERCEncode(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s);
-static int LERCDecode(TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s);
-
-static int LERCFixupTags(TIFF *tif)
-{
- (void)tif;
- return 1;
-}
-
-static int LERCSetupDecode(TIFF *tif)
-{
- LERCState *sp = LERCDecoderState(tif);
-
- assert(sp != NULL);
-
- /* if we were last encoding, terminate this mode */
- if (sp->state & LSTATE_INIT_ENCODE)
- {
- sp->state = 0;
- }
-
- sp->state |= LSTATE_INIT_DECODE;
- return 1;
-}
-
-static int GetLercDataType(TIFF *tif)
-{
- TIFFDirectory *td = &tif->tif_dir;
- static const char module[] = "GetLercDataType";
-
- if (td->td_sampleformat == SAMPLEFORMAT_INT && td->td_bitspersample == 8)
- {
- return 0;
- }
-
- if (td->td_sampleformat == SAMPLEFORMAT_UINT && td->td_bitspersample == 8)
- {
- return 1;
- }
-
- if (td->td_sampleformat == SAMPLEFORMAT_INT && td->td_bitspersample == 16)
- {
- return 2;
- }
-
- if (td->td_sampleformat == SAMPLEFORMAT_UINT && td->td_bitspersample == 16)
- {
- return 3;
- }
-
- if (td->td_sampleformat == SAMPLEFORMAT_INT && td->td_bitspersample == 32)
- {
- return 4;
- }
-
- if (td->td_sampleformat == SAMPLEFORMAT_UINT && td->td_bitspersample == 32)
- {
- return 5;
- }
-
- if (td->td_sampleformat == SAMPLEFORMAT_IEEEFP &&
- td->td_bitspersample == 32)
- {
- return 6;
- }
-
- if (td->td_sampleformat == SAMPLEFORMAT_IEEEFP &&
- td->td_bitspersample == 64)
- {
- return 7;
- }
-
- TIFFErrorExtR(
- tif, module,
- "Unsupported combination of SampleFormat and td_bitspersample");
- return -1;
-}
-
-static int SetupBuffers(TIFF *tif, LERCState *sp, const char *module)
-{
- TIFFDirectory *td = &tif->tif_dir;
- uint64_t new_size_64;
- uint64_t new_alloc_64;
- unsigned int new_size;
- unsigned int new_alloc;
-
- sp->uncompressed_offset = 0;
-
- if (isTiled(tif))
- {
- sp->segment_width = td->td_tilewidth;
- sp->segment_height = td->td_tilelength;
- }
- else
- {
- sp->segment_width = td->td_imagewidth;
- sp->segment_height = td->td_imagelength - tif->tif_row;
- if (sp->segment_height > td->td_rowsperstrip)
- sp->segment_height = td->td_rowsperstrip;
- }
-
- new_size_64 = (uint64_t)sp->segment_width * sp->segment_height *
- (td->td_bitspersample / 8);
- if (td->td_planarconfig == PLANARCONFIG_CONTIG)
- {
- new_size_64 *= td->td_samplesperpixel;
- }
-
- new_size = (unsigned int)new_size_64;
- sp->uncompressed_size = new_size;
-
- /* add some margin as we are going to use it also to store deflate/zstd
- * compressed data. We also need extra margin when writing very small
- * rasters with one mask per band. */
- new_alloc_64 = 256 + new_size_64 + new_size_64 / 3;
-#ifdef ZSTD_SUPPORT
- {
- size_t zstd_max = ZSTD_compressBound((size_t)new_size_64);
- if (new_alloc_64 < zstd_max)
- {
- new_alloc_64 = zstd_max;
- }
- }
-#endif
- new_alloc = (unsigned int)new_alloc_64;
- if (new_alloc != new_alloc_64)
- {
- TIFFErrorExtR(tif, module, "Too large uncompressed strip/tile");
- _TIFFfreeExt(tif, sp->uncompressed_buffer);
- sp->uncompressed_buffer = 0;
- sp->uncompressed_alloc = 0;
- return 0;
- }
-
- if (sp->uncompressed_alloc < new_alloc)
- {
- _TIFFfreeExt(tif, sp->uncompressed_buffer);
- sp->uncompressed_buffer = _TIFFmallocExt(tif, new_alloc);
- if (!sp->uncompressed_buffer)
- {
- TIFFErrorExtR(tif, module, "Cannot allocate buffer");
- _TIFFfreeExt(tif, sp->uncompressed_buffer);
- sp->uncompressed_buffer = 0;
- sp->uncompressed_alloc = 0;
- return 0;
- }
- sp->uncompressed_alloc = new_alloc;
- }
-
- if ((td->td_planarconfig == PLANARCONFIG_CONTIG &&
- td->td_extrasamples > 0 &&
- td->td_sampleinfo[td->td_extrasamples - 1] == EXTRASAMPLE_UNASSALPHA &&
- GetLercDataType(tif) == 1) ||
- (td->td_sampleformat == SAMPLEFORMAT_IEEEFP &&
- (td->td_bitspersample == 32 || td->td_bitspersample == 64)))
- {
- unsigned int mask_size = sp->segment_width * sp->segment_height;
-#if LERC_AT_LEAST_VERSION(3, 0, 0)
- if (td->td_sampleformat == SAMPLEFORMAT_IEEEFP &&
- td->td_planarconfig == PLANARCONFIG_CONTIG)
- {
- /* We may need one mask per band */
- mask_size *= td->td_samplesperpixel;
- }
-#endif
- if (sp->mask_size < mask_size)
- {
- void *mask_buffer =
- _TIFFreallocExt(tif, sp->mask_buffer, mask_size);
- if (mask_buffer == NULL)
- {
- TIFFErrorExtR(tif, module, "Cannot allocate buffer");
- sp->mask_size = 0;
- _TIFFfreeExt(tif, sp->uncompressed_buffer);
- sp->uncompressed_buffer = 0;
- sp->uncompressed_alloc = 0;
- return 0;
- }
- sp->mask_buffer = (uint8_t *)mask_buffer;
- sp->mask_size = mask_size;
- }
- }
-
- return 1;
-}
-
-/*
- * Setup state for decoding a strip.
- */
-static int LERCPreDecode(TIFF *tif, uint16_t s)
-{
- static const char module[] = "LERCPreDecode";
- lerc_status lerc_ret;
- TIFFDirectory *td = &tif->tif_dir;
- LERCState *sp = LERCDecoderState(tif);
- int lerc_data_type;
- unsigned int infoArray[9];
- unsigned nomask_bands = td->td_samplesperpixel;
- int ndims;
- int use_mask = 0;
- uint8_t *lerc_data = tif->tif_rawcp;
- unsigned int lerc_data_size = (unsigned int)tif->tif_rawcc;
-
- (void)s;
- assert(sp != NULL);
- if (sp->state != LSTATE_INIT_DECODE)
- tif->tif_setupdecode(tif);
-
- lerc_data_type = GetLercDataType(tif);
- if (lerc_data_type < 0)
- return 0;
-
- if (!SetupBuffers(tif, sp, module))
- return 0;
-
- if (sp->additional_compression != LERC_ADD_COMPRESSION_NONE)
- {
- if (sp->compressed_size < sp->uncompressed_alloc)
- {
- _TIFFfreeExt(tif, sp->compressed_buffer);
- sp->compressed_buffer = _TIFFmallocExt(tif, sp->uncompressed_alloc);
- if (!sp->compressed_buffer)
- {
- sp->compressed_size = 0;
- return 0;
- }
- sp->compressed_size = sp->uncompressed_alloc;
- }
- }
-
- if (sp->additional_compression == LERC_ADD_COMPRESSION_DEFLATE)
- {
-#if LIBDEFLATE_SUPPORT
- enum libdeflate_result res;
- size_t lerc_data_sizet = 0;
- if (sp->libdeflate_dec == NULL)
- {
- sp->libdeflate_dec = libdeflate_alloc_decompressor();
- if (sp->libdeflate_dec == NULL)
- {
- TIFFErrorExtR(tif, module, "Cannot allocate decompressor");
- return 0;
- }
- }
-
- res = libdeflate_zlib_decompress(
- sp->libdeflate_dec, tif->tif_rawcp, (size_t)tif->tif_rawcc,
- sp->compressed_buffer, sp->compressed_size, &lerc_data_sizet);
- if (res != LIBDEFLATE_SUCCESS)
- {
- TIFFErrorExtR(tif, module, "Decoding error at scanline %lu",
- (unsigned long)tif->tif_row);
- return 0;
- }
- assert(lerc_data_sizet == (unsigned int)lerc_data_sizet);
- lerc_data = sp->compressed_buffer;
- lerc_data_size = (unsigned int)lerc_data_sizet;
-#else
- z_stream strm;
- int zlib_ret;
-
- memset(&strm, 0, sizeof(strm));
- strm.zalloc = NULL;
- strm.zfree = NULL;
- strm.opaque = NULL;
- zlib_ret = inflateInit(&strm);
- if (zlib_ret != Z_OK)
- {
- TIFFErrorExtR(tif, module, "inflateInit() failed");
- inflateEnd(&strm);
- return 0;
- }
-
- strm.avail_in = (uInt)tif->tif_rawcc;
- strm.next_in = tif->tif_rawcp;
- strm.avail_out = sp->compressed_size;
- strm.next_out = sp->compressed_buffer;
- zlib_ret = inflate(&strm, Z_FINISH);
- if (zlib_ret != Z_STREAM_END && zlib_ret != Z_OK)
- {
- TIFFErrorExtR(tif, module, "inflate() failed");
- inflateEnd(&strm);
- return 0;
- }
- lerc_data = sp->compressed_buffer;
- lerc_data_size = sp->compressed_size - strm.avail_out;
- inflateEnd(&strm);
-#endif
- }
- else if (sp->additional_compression == LERC_ADD_COMPRESSION_ZSTD)
- {
-#ifdef ZSTD_SUPPORT
- size_t zstd_ret;
-
- zstd_ret = ZSTD_decompress(sp->compressed_buffer, sp->compressed_size,
- tif->tif_rawcp, tif->tif_rawcc);
- if (ZSTD_isError(zstd_ret))
- {
- TIFFErrorExtR(tif, module, "Error in ZSTD_decompress(): %s",
- ZSTD_getErrorName(zstd_ret));
- return 0;
- }
-
- lerc_data = sp->compressed_buffer;
- lerc_data_size = (unsigned int)zstd_ret;
-#else
- TIFFErrorExtR(tif, module, "ZSTD support missing");
- return 0;
-#endif
- }
- else if (sp->additional_compression != LERC_ADD_COMPRESSION_NONE)
- {
- TIFFErrorExtR(tif, module, "Unhandled additional compression");
- return 0;
- }
-
- lerc_ret =
- lerc_getBlobInfo(lerc_data, lerc_data_size, infoArray, NULL, 9, 0);
- if (lerc_ret != 0)
- {
- TIFFErrorExtR(tif, module, "lerc_getBlobInfo() failed");
- return 0;
- }
-
- /* If the configuration is compatible of a LERC mask, and that the */
- /* LERC info has dim == samplesperpixel - 1, then there is a LERC */
- /* mask. */
- if (td->td_planarconfig == PLANARCONFIG_CONTIG && td->td_extrasamples > 0 &&
- td->td_sampleinfo[td->td_extrasamples - 1] == EXTRASAMPLE_UNASSALPHA &&
- GetLercDataType(tif) == 1 &&
- infoArray[2] == td->td_samplesperpixel - 1U)
- {
- use_mask = 1;
- nomask_bands--;
- }
- else if (td->td_sampleformat == SAMPLEFORMAT_IEEEFP)
- {
- use_mask = 1;
- }
-
- ndims = td->td_planarconfig == PLANARCONFIG_CONTIG ? nomask_bands : 1;
-
- /* Info returned in infoArray is { version, dataType, nDim/nDepth, nCols,
- nRows, nBands, nValidPixels, blobSize,
- and starting with liblerc 3.0 nRequestedMasks } */
- if (infoArray[0] != (unsigned)sp->lerc_version)
- {
- TIFFWarningExtR(tif, module,
- "Unexpected version number: %d. Expected: %d",
- infoArray[0], sp->lerc_version);
- }
- if (infoArray[1] != (unsigned)lerc_data_type)
- {
- TIFFErrorExtR(tif, module, "Unexpected dataType: %d. Expected: %d",
- infoArray[1], lerc_data_type);
- return 0;
- }
-
- const unsigned nFoundDims = infoArray[2];
-#if LERC_AT_LEAST_VERSION(3, 0, 0)
- if (td->td_sampleformat == SAMPLEFORMAT_IEEEFP &&
- td->td_planarconfig == PLANARCONFIG_CONTIG &&
- td->td_samplesperpixel > 1)
- {
- if (nFoundDims != 1 && nFoundDims != (unsigned)ndims)
- {
- TIFFErrorExtR(tif, module, "Unexpected nDim: %d. Expected: 1 or %d",
- nFoundDims, ndims);
- return 0;
- }
- }
- else
-#endif
- if (nFoundDims != (unsigned)ndims)
- {
- TIFFErrorExtR(tif, module, "Unexpected nDim: %d. Expected: %d",
- nFoundDims, ndims);
- return 0;
- }
-
- if (infoArray[3] != sp->segment_width)
- {
- TIFFErrorExtR(tif, module, "Unexpected nCols: %d. Expected: %du",
- infoArray[3], sp->segment_width);
- return 0;
- }
- if (infoArray[4] != sp->segment_height)
- {
- TIFFErrorExtR(tif, module, "Unexpected nRows: %d. Expected: %u",
- infoArray[4], sp->segment_height);
- return 0;
- }
-
- const unsigned nFoundBands = infoArray[5];
- if (td->td_sampleformat == SAMPLEFORMAT_IEEEFP &&
- td->td_planarconfig == PLANARCONFIG_CONTIG &&
- td->td_samplesperpixel > 1 && nFoundDims == 1)
- {
-#if !LERC_AT_LEAST_VERSION(3, 0, 0)
- if (nFoundBands == td->td_samplesperpixel)
- {
- TIFFErrorExtR(
- tif, module,
- "Unexpected nBands: %d. This file may have been generated with "
- "a liblerc version >= 3.0, with one mask per band, and is not "
- "supported by this older version of liblerc",
- nFoundBands);
- return 0;
- }
-#endif
- if (nFoundBands != td->td_samplesperpixel)
- {
- TIFFErrorExtR(tif, module, "Unexpected nBands: %d. Expected: %d",
- nFoundBands, td->td_samplesperpixel);
- return 0;
- }
- }
- else if (nFoundBands != 1)
- {
- TIFFErrorExtR(tif, module, "Unexpected nBands: %d. Expected: %d",
- nFoundBands, 1);
- return 0;
- }
-
- if (infoArray[7] != lerc_data_size)
- {
- TIFFErrorExtR(tif, module, "Unexpected blobSize: %d. Expected: %u",
- infoArray[7], lerc_data_size);
- return 0;
- }
-
- int nRequestedMasks = use_mask ? 1 : 0;
-#if LERC_AT_LEAST_VERSION(3, 0, 0)
- const int nFoundMasks = infoArray[8];
- if (td->td_sampleformat == SAMPLEFORMAT_IEEEFP &&
- td->td_planarconfig == PLANARCONFIG_CONTIG &&
- td->td_samplesperpixel > 1 && nFoundDims == 1)
- {
- if (nFoundMasks != 0 && nFoundMasks != td->td_samplesperpixel)
- {
- TIFFErrorExtR(tif, module,
- "Unexpected nFoundMasks: %d. Expected: 0 or %d",
- nFoundMasks, td->td_samplesperpixel);
- return 0;
- }
- nRequestedMasks = nFoundMasks;
- }
- else
- {
- if (nFoundMasks != 0 && nFoundMasks != 1)
- {
- TIFFErrorExtR(tif, module,
- "Unexpected nFoundMasks: %d. Expected: 0 or 1",
- nFoundMasks);
- return 0;
- }
- }
- if (td->td_sampleformat == SAMPLEFORMAT_IEEEFP && nFoundMasks == 0)
- {
- nRequestedMasks = 0;
- use_mask = 0;
- }
-#endif
-
- const unsigned nb_pixels = sp->segment_width * sp->segment_height;
-
-#if LERC_AT_LEAST_VERSION(3, 0, 0)
- if (nRequestedMasks > 1)
- {
- unsigned int num_bytes_needed =
- nb_pixels * td->td_samplesperpixel * (td->td_bitspersample / 8);
- if (sp->uncompressed_buffer_multiband_alloc < num_bytes_needed)
- {
- _TIFFfreeExt(tif, sp->uncompressed_buffer_multiband);
- sp->uncompressed_buffer_multiband =
- _TIFFmallocExt(tif, num_bytes_needed);
- if (!sp->uncompressed_buffer_multiband)
- {
- sp->uncompressed_buffer_multiband_alloc = 0;
- return 0;
- }
- sp->uncompressed_buffer_multiband_alloc = num_bytes_needed;
- }
- lerc_ret = lerc_decode(lerc_data, lerc_data_size, nRequestedMasks,
- sp->mask_buffer, nFoundDims, sp->segment_width,
- sp->segment_height, nFoundBands, lerc_data_type,
- sp->uncompressed_buffer_multiband);
- }
- else
-#endif
- {
- lerc_ret =
- lerc_decode(lerc_data, lerc_data_size,
-#if LERC_AT_LEAST_VERSION(3, 0, 0)
- nRequestedMasks,
-#endif
- use_mask ? sp->mask_buffer : NULL, nFoundDims,
- sp->segment_width, sp->segment_height, nFoundBands,
- lerc_data_type, sp->uncompressed_buffer);
- }
- if (lerc_ret != 0)
- {
- TIFFErrorExtR(tif, module, "lerc_decode() failed");
- return 0;
- }
-
- /* Interleave alpha mask with other samples. */
- if (use_mask && GetLercDataType(tif) == 1)
- {
- unsigned src_stride =
- (td->td_samplesperpixel - 1) * (td->td_bitspersample / 8);
- unsigned dst_stride =
- td->td_samplesperpixel * (td->td_bitspersample / 8);
- unsigned i = sp->segment_width * sp->segment_height;
- /* Operate from end to begin to be able to move in place */
- while (i > 0 && i > nomask_bands)
- {
- i--;
- sp->uncompressed_buffer[i * dst_stride + td->td_samplesperpixel -
- 1] = 255 * sp->mask_buffer[i];
- memcpy(sp->uncompressed_buffer + i * dst_stride,
- sp->uncompressed_buffer + i * src_stride, src_stride);
- }
- /* First pixels must use memmove due to overlapping areas */
- while (i > 0)
- {
- i--;
- sp->uncompressed_buffer[i * dst_stride + td->td_samplesperpixel -
- 1] = 255 * sp->mask_buffer[i];
- memmove(sp->uncompressed_buffer + i * dst_stride,
- sp->uncompressed_buffer + i * src_stride, src_stride);
- }
- }
- else if (use_mask && td->td_sampleformat == SAMPLEFORMAT_IEEEFP)
- {
- unsigned i;
-#if WORDS_BIGENDIAN
- const unsigned char nan_bytes[] = {0x7f, 0xc0, 0, 0};
-#else
- const unsigned char nan_bytes[] = {0, 0, 0xc0, 0x7f};
-#endif
- float nan_float32;
- memcpy(&nan_float32, nan_bytes, 4);
-
- if (td->td_planarconfig == PLANARCONFIG_SEPARATE ||
- td->td_samplesperpixel == 1)
- {
- if (td->td_bitspersample == 32)
- {
- for (i = 0; i < nb_pixels; i++)
- {
- if (sp->mask_buffer[i] == 0)
- ((float *)sp->uncompressed_buffer)[i] = nan_float32;
- }
- }
- else
- {
- const double nan_float64 = nan_float32;
- for (i = 0; i < nb_pixels; i++)
- {
- if (sp->mask_buffer[i] == 0)
- ((double *)sp->uncompressed_buffer)[i] = nan_float64;
- }
- }
- }
- else if (nRequestedMasks == 1)
- {
- assert(nFoundDims == td->td_samplesperpixel);
- assert(nFoundBands == 1);
-
- unsigned k = 0;
- if (td->td_bitspersample == 32)
- {
- for (i = 0; i < nb_pixels; i++)
- {
- for (int j = 0; j < td->td_samplesperpixel; j++)
- {
- if (sp->mask_buffer[i] == 0)
- ((float *)sp->uncompressed_buffer)[k] = nan_float32;
- ++k;
- }
- }
- }
- else
- {
- const double nan_float64 = nan_float32;
- for (i = 0; i < nb_pixels; i++)
- {
- for (int j = 0; j < td->td_samplesperpixel; j++)
- {
- if (sp->mask_buffer[i] == 0)
- ((double *)sp->uncompressed_buffer)[k] =
- nan_float64;
- ++k;
- }
- }
- }
- }
-#if LERC_AT_LEAST_VERSION(3, 0, 0)
- else
- {
- assert(nRequestedMasks == td->td_samplesperpixel);
- assert(nFoundDims == 1);
- assert(nFoundBands == td->td_samplesperpixel);
-
- unsigned k = 0;
- if (td->td_bitspersample == 32)
- {
- for (i = 0; i < nb_pixels; i++)
- {
- for (int j = 0; j < td->td_samplesperpixel; j++)
- {
- if (sp->mask_buffer[i + j * nb_pixels] == 0)
- ((float *)sp->uncompressed_buffer)[k] = nan_float32;
- else
- ((float *)sp->uncompressed_buffer)[k] =
- ((float *)sp->uncompressed_buffer_multiband)
- [i + j * nb_pixels];
- ++k;
- }
- }
- }
- else
- {
- const double nan_float64 = nan_float32;
- for (i = 0; i < nb_pixels; i++)
- {
- for (int j = 0; j < td->td_samplesperpixel; j++)
- {
- if (sp->mask_buffer[i + j * nb_pixels] == 0)
- ((double *)sp->uncompressed_buffer)[k] =
- nan_float64;
- else
- ((double *)sp->uncompressed_buffer)[k] =
- ((double *)sp->uncompressed_buffer_multiband)
- [i + j * nb_pixels];
- ++k;
- }
- }
- }
- }
-#endif
- }
-
- return 1;
-}
-
-/*
- * Decode a strip, tile or scanline.
- */
-static int LERCDecode(TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s)
-{
- static const char module[] = "LERCDecode";
- LERCState *sp = LERCDecoderState(tif);
-
- (void)s;
- assert(sp != NULL);
- assert(sp->state == LSTATE_INIT_DECODE);
-
- if (sp->uncompressed_buffer == 0)
- {
- memset(op, 0, (size_t)occ);
- TIFFErrorExtR(tif, module, "Uncompressed buffer not allocated");
- return 0;
- }
-
- if ((uint64_t)sp->uncompressed_offset + (uint64_t)occ >
- sp->uncompressed_size)
- {
- memset(op, 0, (size_t)occ);
- TIFFErrorExtR(tif, module, "Too many bytes read");
- return 0;
- }
-
- memcpy(op, sp->uncompressed_buffer + sp->uncompressed_offset, occ);
- sp->uncompressed_offset += (unsigned)occ;
-
- return 1;
-}
-
-static int LERCSetupEncode(TIFF *tif)
-{
- LERCState *sp = LERCEncoderState(tif);
-
- assert(sp != NULL);
- if (sp->state & LSTATE_INIT_DECODE)
- {
- sp->state = 0;
- }
-
- sp->state |= LSTATE_INIT_ENCODE;
-
- return 1;
-}
-
-/*
- * Reset encoding state at the start of a strip.
- */
-static int LERCPreEncode(TIFF *tif, uint16_t s)
-{
- static const char module[] = "LERCPreEncode";
- LERCState *sp = LERCEncoderState(tif);
- int lerc_data_type;
-
- (void)s;
- assert(sp != NULL);
- if (sp->state != LSTATE_INIT_ENCODE)
- tif->tif_setupencode(tif);
-
- lerc_data_type = GetLercDataType(tif);
- if (lerc_data_type < 0)
- return 0;
-
- if (!SetupBuffers(tif, sp, module))
- return 0;
-
- return 1;
-}
-
-/*
- * Encode a chunk of pixels.
- */
-static int LERCEncode(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s)
-{
- static const char module[] = "LERCEncode";
- LERCState *sp = LERCEncoderState(tif);
-
- (void)s;
- assert(sp != NULL);
- assert(sp->state == LSTATE_INIT_ENCODE);
-
- if ((uint64_t)sp->uncompressed_offset + (uint64_t)cc >
- sp->uncompressed_size)
- {
- TIFFErrorExtR(tif, module, "Too many bytes written");
- return 0;
- }
-
- memcpy(sp->uncompressed_buffer + sp->uncompressed_offset, bp, cc);
- sp->uncompressed_offset += (unsigned)cc;
-
- return 1;
-}
-
-/*
- * Finish off an encoded strip by flushing it.
- */
-static int LERCPostEncode(TIFF *tif)
-{
- lerc_status lerc_ret;
- static const char module[] = "LERCPostEncode";
- LERCState *sp = LERCEncoderState(tif);
- unsigned int numBytesWritten = 0;
- TIFFDirectory *td = &tif->tif_dir;
- int use_mask = 0;
- unsigned dst_nbands = td->td_samplesperpixel;
-
- if (sp->uncompressed_offset != sp->uncompressed_size)
- {
- TIFFErrorExtR(tif, module, "Unexpected number of bytes in the buffer");
- return 0;
- }
-
- int mask_count = 1;
- const unsigned nb_pixels = sp->segment_width * sp->segment_height;
-
- /* Extract alpha mask (if containing only 0 and 255 values, */
- /* and compact array of regular bands */
- if (td->td_planarconfig == PLANARCONFIG_CONTIG && td->td_extrasamples > 0 &&
- td->td_sampleinfo[td->td_extrasamples - 1] == EXTRASAMPLE_UNASSALPHA &&
- GetLercDataType(tif) == 1)
- {
- const unsigned dst_stride =
- (td->td_samplesperpixel - 1) * (td->td_bitspersample / 8);
- const unsigned src_stride =
- td->td_samplesperpixel * (td->td_bitspersample / 8);
- unsigned i = 0;
-
- use_mask = 1;
- for (i = 0; i < nb_pixels; i++)
- {
- int v = sp->uncompressed_buffer[i * src_stride +
- td->td_samplesperpixel - 1];
- if (v != 0 && v != 255)
- {
- use_mask = 0;
- break;
- }
- }
-
- if (use_mask)
- {
- dst_nbands--;
- /* First pixels must use memmove due to overlapping areas */
- for (i = 0; i < dst_nbands && i < nb_pixels; i++)
- {
- memmove(sp->uncompressed_buffer + i * dst_stride,
- sp->uncompressed_buffer + i * src_stride, dst_stride);
- sp->mask_buffer[i] =
- sp->uncompressed_buffer[i * src_stride +
- td->td_samplesperpixel - 1];
- }
- for (; i < nb_pixels; i++)
- {
- memcpy(sp->uncompressed_buffer + i * dst_stride,
- sp->uncompressed_buffer + i * src_stride, dst_stride);
- sp->mask_buffer[i] =
- sp->uncompressed_buffer[i * src_stride +
- td->td_samplesperpixel - 1];
- }
- }
- }
- else if (td->td_sampleformat == SAMPLEFORMAT_IEEEFP &&
- (td->td_bitspersample == 32 || td->td_bitspersample == 64))
- {
- /* Check for NaN values */
- unsigned i;
- if (td->td_bitspersample == 32)
- {
- if (td->td_planarconfig == PLANARCONFIG_CONTIG && dst_nbands > 1)
- {
- unsigned k = 0;
- for (i = 0; i < nb_pixels; i++)
- {
- int count_nan = 0;
- for (int j = 0; j < td->td_samplesperpixel; ++j)
- {
- const float val = ((float *)sp->uncompressed_buffer)[k];
- ++k;
- if (val != val)
- {
- ++count_nan;
- }
- }
- if (count_nan > 0)
- {
- use_mask = 1;
- if (count_nan < td->td_samplesperpixel)
- {
- mask_count = td->td_samplesperpixel;
- break;
- }
- }
- }
- }
- else
- {
- for (i = 0; i < nb_pixels; i++)
- {
- const float val = ((float *)sp->uncompressed_buffer)[i];
- if (val != val)
- {
- use_mask = 1;
- break;
- }
- }
- }
- }
- else
- {
- if (td->td_planarconfig == PLANARCONFIG_CONTIG && dst_nbands > 1)
- {
- unsigned k = 0;
- for (i = 0; i < nb_pixels; i++)
- {
- int count_nan = 0;
- for (int j = 0; j < td->td_samplesperpixel; ++j)
- {
- const double val =
- ((double *)sp->uncompressed_buffer)[k];
- ++k;
- if (val != val)
- {
- ++count_nan;
- }
- }
- if (count_nan > 0)
- {
- use_mask = 1;
- if (count_nan < td->td_samplesperpixel)
- {
- mask_count = td->td_samplesperpixel;
- break;
- }
- }
- }
- }
- else
- {
- for (i = 0; i < nb_pixels; i++)
- {
- const double val = ((double *)sp->uncompressed_buffer)[i];
- if (val != val)
- {
- use_mask = 1;
- break;
- }
- }
- }
- }
-
- if (use_mask)
- {
- if (mask_count > 1)
- {
-#if LERC_AT_LEAST_VERSION(3, 0, 0)
- unsigned int num_bytes_needed =
- nb_pixels * dst_nbands * (td->td_bitspersample / 8);
- if (sp->uncompressed_buffer_multiband_alloc < num_bytes_needed)
- {
- _TIFFfreeExt(tif, sp->uncompressed_buffer_multiband);
- sp->uncompressed_buffer_multiband =
- _TIFFmallocExt(tif, num_bytes_needed);
- if (!sp->uncompressed_buffer_multiband)
- {
- sp->uncompressed_buffer_multiband_alloc = 0;
- return 0;
- }
- sp->uncompressed_buffer_multiband_alloc = num_bytes_needed;
- }
-
- unsigned k = 0;
- if (td->td_bitspersample == 32)
- {
- for (i = 0; i < nb_pixels; i++)
- {
- for (int j = 0; j < td->td_samplesperpixel; ++j)
- {
- const float val =
- ((float *)sp->uncompressed_buffer)[k];
- ((float *)sp->uncompressed_buffer_multiband)
- [i + j * nb_pixels] = val;
- ++k;
- sp->mask_buffer[i + j * nb_pixels] =
- (val == val) ? 255 : 0;
- }
- }
- }
- else
- {
- for (i = 0; i < nb_pixels; i++)
- {
- for (int j = 0; j < td->td_samplesperpixel; ++j)
- {
- const double val =
- ((double *)sp->uncompressed_buffer)[k];
- ((double *)sp->uncompressed_buffer_multiband)
- [i + j * nb_pixels] = val;
- ++k;
- sp->mask_buffer[i + j * nb_pixels] =
- (val == val) ? 255 : 0;
- }
- }
- }
-#else
- TIFFErrorExtR(tif, module,
- "lerc_encode() would need to create one mask per "
- "sample, but this requires liblerc >= 3.0");
- return 0;
-#endif
- }
- else if (td->td_planarconfig == PLANARCONFIG_CONTIG &&
- dst_nbands > 1)
- {
- if (td->td_bitspersample == 32)
- {
- for (i = 0; i < nb_pixels; i++)
- {
- const float val =
- ((float *)sp->uncompressed_buffer)[i * dst_nbands];
- sp->mask_buffer[i] = (val == val) ? 255 : 0;
- }
- }
- else
- {
- for (i = 0; i < nb_pixels; i++)
- {
- const double val =
- ((double *)sp->uncompressed_buffer)[i * dst_nbands];
- sp->mask_buffer[i] = (val == val) ? 255 : 0;
- }
- }
- }
- else
- {
- if (td->td_bitspersample == 32)
- {
- for (i = 0; i < nb_pixels; i++)
- {
- const float val = ((float *)sp->uncompressed_buffer)[i];
- sp->mask_buffer[i] = (val == val) ? 255 : 0;
- }
- }
- else
- {
- for (i = 0; i < nb_pixels; i++)
- {
- const double val =
- ((double *)sp->uncompressed_buffer)[i];
- sp->mask_buffer[i] = (val == val) ? 255 : 0;
- }
- }
- }
- }
- }
-
- unsigned int estimated_compressed_size = sp->uncompressed_alloc;
-#if LERC_AT_LEAST_VERSION(3, 0, 0)
- if (mask_count > 1)
- {
- estimated_compressed_size += nb_pixels * mask_count / 8;
- }
-#endif
-
- if (sp->compressed_size < estimated_compressed_size)
- {
- _TIFFfreeExt(tif, sp->compressed_buffer);
- sp->compressed_buffer = _TIFFmallocExt(tif, estimated_compressed_size);
- if (!sp->compressed_buffer)
- {
- sp->compressed_size = 0;
- return 0;
- }
- sp->compressed_size = estimated_compressed_size;
- }
-
-#if LERC_AT_LEAST_VERSION(3, 0, 0)
- if (mask_count > 1)
- {
- lerc_ret = lerc_encodeForVersion(
- sp->uncompressed_buffer_multiband, sp->lerc_version,
- GetLercDataType(tif), 1, sp->segment_width, sp->segment_height,
- dst_nbands, dst_nbands, sp->mask_buffer, sp->maxzerror,
- sp->compressed_buffer, sp->compressed_size, &numBytesWritten);
- }
- else
-#endif
- {
- lerc_ret = lerc_encodeForVersion(
- sp->uncompressed_buffer, sp->lerc_version, GetLercDataType(tif),
- td->td_planarconfig == PLANARCONFIG_CONTIG ? dst_nbands : 1,
- sp->segment_width, sp->segment_height, 1,
-#if LERC_AT_LEAST_VERSION(3, 0, 0)
- use_mask ? 1 : 0,
-#endif
- use_mask ? sp->mask_buffer : NULL, sp->maxzerror,
- sp->compressed_buffer, sp->compressed_size, &numBytesWritten);
- }
- if (lerc_ret != 0)
- {
- TIFFErrorExtR(tif, module, "lerc_encode() failed");
- return 0;
- }
- assert(numBytesWritten < estimated_compressed_size);
-
- if (sp->additional_compression == LERC_ADD_COMPRESSION_DEFLATE)
- {
-#if LIBDEFLATE_SUPPORT
- if (sp->libdeflate_enc == NULL)
- {
- /* To get results as good as zlib, we ask for an extra */
- /* level of compression */
- sp->libdeflate_enc = libdeflate_alloc_compressor(
- sp->zipquality == Z_DEFAULT_COMPRESSION ? 7
- : sp->zipquality >= 6 && sp->zipquality <= 9
- ? sp->zipquality + 1
- : sp->zipquality);
- if (sp->libdeflate_enc == NULL)
- {
- TIFFErrorExtR(tif, module, "Cannot allocate compressor");
- return 0;
- }
- }
-
- /* Should not happen normally */
- if (libdeflate_zlib_compress_bound(
- sp->libdeflate_enc, numBytesWritten) > sp->uncompressed_alloc)
- {
- TIFFErrorExtR(tif, module,
- "Output buffer for libdeflate too small");
- return 0;
- }
-
- tif->tif_rawcc = libdeflate_zlib_compress(
- sp->libdeflate_enc, sp->compressed_buffer, numBytesWritten,
- sp->uncompressed_buffer, sp->uncompressed_alloc);
-
- if (tif->tif_rawcc == 0)
- {
- TIFFErrorExtR(tif, module, "Encoder error at scanline %lu",
- (unsigned long)tif->tif_row);
- return 0;
- }
-#else
- z_stream strm;
- int zlib_ret;
- int cappedQuality = sp->zipquality;
- if (cappedQuality > Z_BEST_COMPRESSION)
- cappedQuality = Z_BEST_COMPRESSION;
-
- memset(&strm, 0, sizeof(strm));
- strm.zalloc = NULL;
- strm.zfree = NULL;
- strm.opaque = NULL;
- zlib_ret = deflateInit(&strm, cappedQuality);
- if (zlib_ret != Z_OK)
- {
- TIFFErrorExtR(tif, module, "deflateInit() failed");
- return 0;
- }
-
- strm.avail_in = numBytesWritten;
- strm.next_in = sp->compressed_buffer;
- strm.avail_out = sp->uncompressed_alloc;
- strm.next_out = sp->uncompressed_buffer;
- zlib_ret = deflate(&strm, Z_FINISH);
- if (zlib_ret == Z_STREAM_END)
- {
- tif->tif_rawcc = sp->uncompressed_alloc - strm.avail_out;
- }
- deflateEnd(&strm);
- if (zlib_ret != Z_STREAM_END)
- {
- TIFFErrorExtR(tif, module, "deflate() failed");
- return 0;
- }
-#endif
- {
- int ret;
- uint8_t *tif_rawdata_backup = tif->tif_rawdata;
- tif->tif_rawdata = sp->uncompressed_buffer;
- ret = TIFFFlushData1(tif);
- tif->tif_rawdata = tif_rawdata_backup;
- if (!ret)
- {
- return 0;
- }
- }
- }
- else if (sp->additional_compression == LERC_ADD_COMPRESSION_ZSTD)
- {
-#ifdef ZSTD_SUPPORT
- size_t zstd_ret = ZSTD_compress(
- sp->uncompressed_buffer, sp->uncompressed_alloc,
- sp->compressed_buffer, numBytesWritten, sp->zstd_compress_level);
- if (ZSTD_isError(zstd_ret))
- {
- TIFFErrorExtR(tif, module, "Error in ZSTD_compress(): %s",
- ZSTD_getErrorName(zstd_ret));
- return 0;
- }
-
- {
- int ret;
- uint8_t *tif_rawdata_backup = tif->tif_rawdata;
- tif->tif_rawdata = sp->uncompressed_buffer;
- tif->tif_rawcc = zstd_ret;
- ret = TIFFFlushData1(tif);
- tif->tif_rawdata = tif_rawdata_backup;
- if (!ret)
- {
- return 0;
- }
- }
-#else
- TIFFErrorExtR(tif, module, "ZSTD support missing");
- return 0;
-#endif
- }
- else if (sp->additional_compression != LERC_ADD_COMPRESSION_NONE)
- {
- TIFFErrorExtR(tif, module, "Unhandled additional compression");
- return 0;
- }
- else
- {
- int ret;
- uint8_t *tif_rawdata_backup = tif->tif_rawdata;
- tif->tif_rawdata = sp->compressed_buffer;
- tif->tif_rawcc = numBytesWritten;
- ret = TIFFFlushData1(tif);
- tif->tif_rawdata = tif_rawdata_backup;
- if (!ret)
- return 0;
- }
-
- return 1;
-}
-
-static void LERCCleanup(TIFF *tif)
-{
- LERCState *sp = GetLERCState(tif);
-
- assert(sp != 0);
-
- tif->tif_tagmethods.vgetfield = sp->vgetparent;
- tif->tif_tagmethods.vsetfield = sp->vsetparent;
-
- _TIFFfreeExt(tif, sp->uncompressed_buffer);
- _TIFFfreeExt(tif, sp->uncompressed_buffer_multiband);
- _TIFFfreeExt(tif, sp->compressed_buffer);
- _TIFFfreeExt(tif, sp->mask_buffer);
-
-#if LIBDEFLATE_SUPPORT
- if (sp->libdeflate_dec)
- libdeflate_free_decompressor(sp->libdeflate_dec);
- if (sp->libdeflate_enc)
- libdeflate_free_compressor(sp->libdeflate_enc);
-#endif
-
- _TIFFfreeExt(tif, sp);
- tif->tif_data = NULL;
-
- _TIFFSetDefaultCompressionState(tif);
-}
-
-static const TIFFField LERCFields[] = {
- {TIFFTAG_LERC_PARAMETERS, TIFF_VARIABLE2, TIFF_VARIABLE2, TIFF_LONG, 0,
- TIFF_SETGET_C32_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, FALSE, TRUE,
- "LercParameters", NULL},
- {TIFFTAG_LERC_MAXZERROR, 0, 0, TIFF_ANY, 0, TIFF_SETGET_DOUBLE,
- TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "LercMaximumError",
- NULL},
- {TIFFTAG_LERC_VERSION, 0, 0, TIFF_ANY, 0, TIFF_SETGET_UINT32,
- TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, FALSE, FALSE, "LercVersion", NULL},
- {TIFFTAG_LERC_ADD_COMPRESSION, 0, 0, TIFF_ANY, 0, TIFF_SETGET_UINT32,
- TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, FALSE, FALSE,
- "LercAdditionalCompression", NULL},
- {TIFFTAG_ZSTD_LEVEL, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT,
- TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE,
- "ZSTD zstd_compress_level", NULL},
- {TIFFTAG_ZIPQUALITY, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT,
- TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "", NULL},
-};
-
-static int LERCVSetFieldBase(TIFF *tif, uint32_t tag, ...)
-{
- LERCState *sp = GetLERCState(tif);
- int ret;
- va_list ap;
- va_start(ap, tag);
- ret = (*sp->vsetparent)(tif, tag, ap);
- va_end(ap);
- return ret;
-}
-
-static int LERCVSetField(TIFF *tif, uint32_t tag, va_list ap)
-{
- static const char module[] = "LERCVSetField";
- LERCState *sp = GetLERCState(tif);
-
- switch (tag)
- {
- case TIFFTAG_LERC_PARAMETERS:
- {
- uint32_t count = va_arg(ap, int);
- int *params = va_arg(ap, int *);
- if (count < 2)
- {
- TIFFErrorExtR(tif, module,
- "Invalid count for LercParameters: %u", count);
- return 0;
- }
- sp->lerc_version = params[0];
- sp->additional_compression = params[1];
- return LERCVSetFieldBase(tif, TIFFTAG_LERC_PARAMETERS, count,
- params);
- }
- case TIFFTAG_LERC_MAXZERROR:
- sp->maxzerror = va_arg(ap, double);
- return 1;
- case TIFFTAG_LERC_VERSION:
- {
- int params[2] = {0, 0};
- int version = va_arg(ap, int);
- if (version != LERC_VERSION_2_4)
- {
- TIFFErrorExtR(tif, module, "Invalid value for LercVersion: %d",
- version);
- return 0;
- }
- sp->lerc_version = version;
- params[0] = sp->lerc_version;
- params[1] = sp->additional_compression;
- return LERCVSetFieldBase(tif, TIFFTAG_LERC_PARAMETERS, 2, params);
- }
- case TIFFTAG_LERC_ADD_COMPRESSION:
- {
- int params[2] = {0, 0};
- int additional_compression = va_arg(ap, int);
-#ifndef ZSTD_SUPPORT
- if (additional_compression == LERC_ADD_COMPRESSION_ZSTD)
- {
- TIFFErrorExtR(tif, module,
- "LERC_ZSTD requested, but ZSTD not available");
- return 0;
- }
-#endif
- if (additional_compression != LERC_ADD_COMPRESSION_NONE &&
- additional_compression != LERC_ADD_COMPRESSION_DEFLATE &&
- additional_compression != LERC_ADD_COMPRESSION_ZSTD)
- {
- TIFFErrorExtR(tif, module,
- "Invalid value for LercAdditionalCompression: %d",
- additional_compression);
- return 0;
- }
- sp->additional_compression = additional_compression;
- params[0] = sp->lerc_version;
- params[1] = sp->additional_compression;
- return LERCVSetFieldBase(tif, TIFFTAG_LERC_PARAMETERS, 2, params);
- }
-#ifdef ZSTD_SUPPORT
- case TIFFTAG_ZSTD_LEVEL:
- {
- sp->zstd_compress_level = (int)va_arg(ap, int);
- if (sp->zstd_compress_level <= 0 ||
- sp->zstd_compress_level > ZSTD_maxCLevel())
- {
- TIFFWarningExtR(tif, module,
- "ZSTD_LEVEL should be between 1 and %d",
- ZSTD_maxCLevel());
- }
- return 1;
- }
-#endif
- case TIFFTAG_ZIPQUALITY:
- {
- sp->zipquality = (int)va_arg(ap, int);
- if (sp->zipquality < Z_DEFAULT_COMPRESSION ||
- sp->zipquality > LIBDEFLATE_MAX_COMPRESSION_LEVEL)
- {
- TIFFErrorExtR(
- tif, module,
- "Invalid ZipQuality value. Should be in [-1,%d] range",
- LIBDEFLATE_MAX_COMPRESSION_LEVEL);
- return 0;
- }
-
-#if LIBDEFLATE_SUPPORT
- if (sp->libdeflate_enc)
- {
- libdeflate_free_compressor(sp->libdeflate_enc);
- sp->libdeflate_enc = NULL;
- }
-#endif
-
- return (1);
- }
- default:
- return (*sp->vsetparent)(tif, tag, ap);
- }
- /*NOTREACHED*/
-}
-
-static int LERCVGetField(TIFF *tif, uint32_t tag, va_list ap)
-{
- LERCState *sp = GetLERCState(tif);
-
- switch (tag)
- {
- case TIFFTAG_LERC_MAXZERROR:
- *va_arg(ap, double *) = sp->maxzerror;
- break;
- case TIFFTAG_LERC_VERSION:
- *va_arg(ap, int *) = sp->lerc_version;
- break;
- case TIFFTAG_LERC_ADD_COMPRESSION:
- *va_arg(ap, int *) = sp->additional_compression;
- break;
- case TIFFTAG_ZSTD_LEVEL:
- *va_arg(ap, int *) = sp->zstd_compress_level;
- break;
- case TIFFTAG_ZIPQUALITY:
- *va_arg(ap, int *) = sp->zipquality;
- break;
- default:
- return (*sp->vgetparent)(tif, tag, ap);
- }
- return 1;
-}
-
-int TIFFInitLERC(TIFF *tif, int scheme)
-{
- static const char module[] = "TIFFInitLERC";
- LERCState *sp;
-
- (void)scheme;
- assert(scheme == COMPRESSION_LERC);
-
- /*
- * Merge codec-specific tag information.
- */
- if (!_TIFFMergeFields(tif, LERCFields, TIFFArrayCount(LERCFields)))
- {
- TIFFErrorExtR(tif, module, "Merging LERC codec-specific tags failed");
- return 0;
- }
-
- /*
- * Allocate state block so tag methods have storage to record values.
- */
- tif->tif_data = (uint8_t *)_TIFFcallocExt(tif, 1, sizeof(LERCState));
- if (tif->tif_data == NULL)
- goto bad;
- sp = GetLERCState(tif);
-
- /*
- * Override parent get/set field methods.
- */
- sp->vgetparent = tif->tif_tagmethods.vgetfield;
- tif->tif_tagmethods.vgetfield = LERCVGetField; /* hook for codec tags */
- sp->vsetparent = tif->tif_tagmethods.vsetfield;
- tif->tif_tagmethods.vsetfield = LERCVSetField; /* hook for codec tags */
-
- /*
- * Install codec methods.
- */
- tif->tif_fixuptags = LERCFixupTags;
- tif->tif_setupdecode = LERCSetupDecode;
- tif->tif_predecode = LERCPreDecode;
- tif->tif_decoderow = LERCDecode;
- tif->tif_decodestrip = LERCDecode;
- tif->tif_decodetile = LERCDecode;
- tif->tif_setupencode = LERCSetupEncode;
- tif->tif_preencode = LERCPreEncode;
- tif->tif_postencode = LERCPostEncode;
- tif->tif_encoderow = LERCEncode;
- tif->tif_encodestrip = LERCEncode;
- tif->tif_encodetile = LERCEncode;
- tif->tif_cleanup = LERCCleanup;
-
- /* Default values for codec-specific fields */
- TIFFSetField(tif, TIFFTAG_LERC_VERSION, LERC_VERSION_2_4);
- TIFFSetField(tif, TIFFTAG_LERC_ADD_COMPRESSION, LERC_ADD_COMPRESSION_NONE);
- sp->maxzerror = 0.0;
- sp->zstd_compress_level = 9; /* default comp. level */
- sp->zipquality = Z_DEFAULT_COMPRESSION; /* default comp. level */
- sp->state = 0;
-
- return 1;
-bad:
- TIFFErrorExtR(tif, module, "No space for LERC state block");
- return 0;
-}
-#endif /* LERC_SUPPORT */
diff --git a/contrib/libs/libtiff/tif_luv.c b/contrib/libs/libtiff/tif_luv.c
deleted file mode 100644
index d19653550c..0000000000
--- a/contrib/libs/libtiff/tif_luv.c
+++ /dev/null
@@ -1,1840 +0,0 @@
-/*
- * Copyright (c) 1997 Greg Ward Larson
- * Copyright (c) 1997 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler, Greg Larson and Silicon Graphics may not be used in any
- * advertising or publicity relating to the software without the specific,
- * prior written permission of Sam Leffler, Greg Larson and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER, GREG LARSON OR SILICON GRAPHICS BE LIABLE
- * FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-#include "tiffiop.h"
-#ifdef LOGLUV_SUPPORT
-
-/*
- * TIFF Library.
- * LogLuv compression support for high dynamic range images.
- *
- * Contributed by Greg Larson.
- *
- * LogLuv image support uses the TIFF library to store 16 or 10-bit
- * log luminance values with 8 bits each of u and v or a 14-bit index.
- *
- * The codec can take as input and produce as output 32-bit IEEE float values
- * as well as 16-bit integer values. A 16-bit luminance is interpreted
- * as a sign bit followed by a 15-bit integer that is converted
- * to and from a linear magnitude using the transformation:
- *
- * L = 2^( (Le+.5)/256 - 64 ) # real from 15-bit
- *
- * Le = floor( 256*(log2(L) + 64) ) # 15-bit from real
- *
- * The actual conversion to world luminance units in candelas per sq. meter
- * requires an additional multiplier, which is stored in the TIFFTAG_STONITS.
- * This value is usually set such that a reasonable exposure comes from
- * clamping decoded luminances above 1 to 1 in the displayed image.
- *
- * The 16-bit values for u and v may be converted to real values by dividing
- * each by 32768. (This allows for negative values, which aren't useful as
- * far as we know, but are left in case of future improvements in human
- * color vision.)
- *
- * Conversion from (u,v), which is actually the CIE (u',v') system for
- * you color scientists, is accomplished by the following transformation:
- *
- * u = 4*x / (-2*x + 12*y + 3)
- * v = 9*y / (-2*x + 12*y + 3)
- *
- * x = 9*u / (6*u - 16*v + 12)
- * y = 4*v / (6*u - 16*v + 12)
- *
- * This process is greatly simplified by passing 32-bit IEEE floats
- * for each of three CIE XYZ coordinates. The codec then takes care
- * of conversion to and from LogLuv, though the application is still
- * responsible for interpreting the TIFFTAG_STONITS calibration factor.
- *
- * By definition, a CIE XYZ vector of [1 1 1] corresponds to a neutral white
- * point of (x,y)=(1/3,1/3). However, most color systems assume some other
- * white point, such as D65, and an absolute color conversion to XYZ then
- * to another color space with a different white point may introduce an
- * unwanted color cast to the image. It is often desirable, therefore, to
- * perform a white point conversion that maps the input white to [1 1 1]
- * in XYZ, then record the original white point using the TIFFTAG_WHITEPOINT
- * tag value. A decoder that demands absolute color calibration may use
- * this white point tag to get back the original colors, but usually it
- * will be ignored and the new white point will be used instead that
- * matches the output color space.
- *
- * Pixel information is compressed into one of two basic encodings, depending
- * on the setting of the compression tag, which is one of COMPRESSION_SGILOG
- * or COMPRESSION_SGILOG24. For COMPRESSION_SGILOG, greyscale data is
- * stored as:
- *
- * 1 15
- * |-+---------------|
- *
- * COMPRESSION_SGILOG color data is stored as:
- *
- * 1 15 8 8
- * |-+---------------|--------+--------|
- * S Le ue ve
- *
- * For the 24-bit COMPRESSION_SGILOG24 color format, the data is stored as:
- *
- * 10 14
- * |----------|--------------|
- * Le' Ce
- *
- * There is no sign bit in the 24-bit case, and the (u,v) chromaticity is
- * encoded as an index for optimal color resolution. The 10 log bits are
- * defined by the following conversions:
- *
- * L = 2^((Le'+.5)/64 - 12) # real from 10-bit
- *
- * Le' = floor( 64*(log2(L) + 12) ) # 10-bit from real
- *
- * The 10 bits of the smaller format may be converted into the 15 bits of
- * the larger format by multiplying by 4 and adding 13314. Obviously,
- * a smaller range of magnitudes is covered (about 5 orders of magnitude
- * instead of 38), and the lack of a sign bit means that negative luminances
- * are not allowed. (Well, they aren't allowed in the real world, either,
- * but they are useful for certain types of image processing.)
- *
- * The desired user format is controlled by the setting the internal
- * pseudo tag TIFFTAG_SGILOGDATAFMT to one of:
- * SGILOGDATAFMT_FLOAT = IEEE 32-bit float XYZ values
- * SGILOGDATAFMT_16BIT = 16-bit integer encodings of logL, u and v
- * Raw data i/o is also possible using:
- * SGILOGDATAFMT_RAW = 32-bit unsigned integer with encoded pixel
- * In addition, the following decoding is provided for ease of display:
- * SGILOGDATAFMT_8BIT = 8-bit default RGB gamma-corrected values
- *
- * For grayscale images, we provide the following data formats:
- * SGILOGDATAFMT_FLOAT = IEEE 32-bit float Y values
- * SGILOGDATAFMT_16BIT = 16-bit integer w/ encoded luminance
- * SGILOGDATAFMT_8BIT = 8-bit gray monitor values
- *
- * Note that the COMPRESSION_SGILOG applies a simple run-length encoding
- * scheme by separating the logL, u and v bytes for each row and applying
- * a PackBits type of compression. Since the 24-bit encoding is not
- * adaptive, the 32-bit color format takes less space in many cases.
- *
- * Further control is provided over the conversion from higher-resolution
- * formats to final encoded values through the pseudo tag
- * TIFFTAG_SGILOGENCODE:
- * SGILOGENCODE_NODITHER = do not dither encoded values
- * SGILOGENCODE_RANDITHER = apply random dithering during encoding
- *
- * The default value of this tag is SGILOGENCODE_NODITHER for
- * COMPRESSION_SGILOG to maximize run-length encoding and
- * SGILOGENCODE_RANDITHER for COMPRESSION_SGILOG24 to turn
- * quantization errors into noise.
- */
-
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-/*
- * State block for each open TIFF
- * file using LogLuv compression/decompression.
- */
-typedef struct logLuvState LogLuvState;
-
-struct logLuvState
-{
- int encoder_state; /* 1 if encoder correctly initialized */
- int user_datafmt; /* user data format */
- int encode_meth; /* encoding method */
- int pixel_size; /* bytes per pixel */
-
- uint8_t *tbuf; /* translation buffer */
- tmsize_t tbuflen; /* buffer length */
- void (*tfunc)(LogLuvState *, uint8_t *, tmsize_t);
-
- TIFFVSetMethod vgetparent; /* super-class method */
- TIFFVSetMethod vsetparent; /* super-class method */
-};
-
-#define DecoderState(tif) ((LogLuvState *)(tif)->tif_data)
-#define EncoderState(tif) ((LogLuvState *)(tif)->tif_data)
-
-#define SGILOGDATAFMT_UNKNOWN -1
-
-#define MINRUN 4 /* minimum run length */
-
-/*
- * Decode a string of 16-bit gray pixels.
- */
-static int LogL16Decode(TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s)
-{
- static const char module[] = "LogL16Decode";
- LogLuvState *sp = DecoderState(tif);
- int shft;
- tmsize_t i;
- tmsize_t npixels;
- unsigned char *bp;
- int16_t *tp;
- int16_t b;
- tmsize_t cc;
- int rc;
-
- (void)s;
- assert(s == 0);
- assert(sp != NULL);
-
- npixels = occ / sp->pixel_size;
-
- if (sp->user_datafmt == SGILOGDATAFMT_16BIT)
- tp = (int16_t *)op;
- else
- {
- if (sp->tbuflen < npixels)
- {
- TIFFErrorExtR(tif, module, "Translation buffer too short");
- return (0);
- }
- tp = (int16_t *)sp->tbuf;
- }
- _TIFFmemset((void *)tp, 0, npixels * sizeof(tp[0]));
-
- bp = (unsigned char *)tif->tif_rawcp;
- cc = tif->tif_rawcc;
- /* get each byte string */
- for (shft = 8; shft >= 0; shft -= 8)
- {
- for (i = 0; i < npixels && cc > 0;)
- {
- if (*bp >= 128)
- { /* run */
- if (cc < 2)
- break;
- rc = *bp++ + (2 - 128);
- b = (int16_t)(*bp++ << shft);
- cc -= 2;
- while (rc-- && i < npixels)
- tp[i++] |= b;
- }
- else
- { /* non-run */
- rc = *bp++; /* nul is noop */
- while (--cc && rc-- && i < npixels)
- tp[i++] |= (int16_t)*bp++ << shft;
- }
- }
- if (i != npixels)
- {
- TIFFErrorExtR(tif, module,
- "Not enough data at row %" PRIu32
- " (short %" TIFF_SSIZE_FORMAT " pixels)",
- tif->tif_row, npixels - i);
- tif->tif_rawcp = (uint8_t *)bp;
- tif->tif_rawcc = cc;
- return (0);
- }
- }
- (*sp->tfunc)(sp, op, npixels);
- tif->tif_rawcp = (uint8_t *)bp;
- tif->tif_rawcc = cc;
- return (1);
-}
-
-/*
- * Decode a string of 24-bit pixels.
- */
-static int LogLuvDecode24(TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s)
-{
- static const char module[] = "LogLuvDecode24";
- LogLuvState *sp = DecoderState(tif);
- tmsize_t cc;
- tmsize_t i;
- tmsize_t npixels;
- unsigned char *bp;
- uint32_t *tp;
-
- (void)s;
- assert(s == 0);
- assert(sp != NULL);
-
- npixels = occ / sp->pixel_size;
-
- if (sp->user_datafmt == SGILOGDATAFMT_RAW)
- tp = (uint32_t *)op;
- else
- {
- if (sp->tbuflen < npixels)
- {
- TIFFErrorExtR(tif, module, "Translation buffer too short");
- return (0);
- }
- tp = (uint32_t *)sp->tbuf;
- }
- /* copy to array of uint32_t */
- bp = (unsigned char *)tif->tif_rawcp;
- cc = tif->tif_rawcc;
- for (i = 0; i < npixels && cc >= 3; i++)
- {
- tp[i] = bp[0] << 16 | bp[1] << 8 | bp[2];
- bp += 3;
- cc -= 3;
- }
- tif->tif_rawcp = (uint8_t *)bp;
- tif->tif_rawcc = cc;
- if (i != npixels)
- {
- TIFFErrorExtR(tif, module,
- "Not enough data at row %" PRIu32
- " (short %" TIFF_SSIZE_FORMAT " pixels)",
- tif->tif_row, npixels - i);
- return (0);
- }
- (*sp->tfunc)(sp, op, npixels);
- return (1);
-}
-
-/*
- * Decode a string of 32-bit pixels.
- */
-static int LogLuvDecode32(TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s)
-{
- static const char module[] = "LogLuvDecode32";
- LogLuvState *sp;
- int shft;
- tmsize_t i;
- tmsize_t npixels;
- unsigned char *bp;
- uint32_t *tp;
- uint32_t b;
- tmsize_t cc;
- int rc;
-
- (void)s;
- assert(s == 0);
- sp = DecoderState(tif);
- assert(sp != NULL);
-
- npixels = occ / sp->pixel_size;
-
- if (sp->user_datafmt == SGILOGDATAFMT_RAW)
- tp = (uint32_t *)op;
- else
- {
- if (sp->tbuflen < npixels)
- {
- TIFFErrorExtR(tif, module, "Translation buffer too short");
- return (0);
- }
- tp = (uint32_t *)sp->tbuf;
- }
- _TIFFmemset((void *)tp, 0, npixels * sizeof(tp[0]));
-
- bp = (unsigned char *)tif->tif_rawcp;
- cc = tif->tif_rawcc;
- /* get each byte string */
- for (shft = 24; shft >= 0; shft -= 8)
- {
- for (i = 0; i < npixels && cc > 0;)
- {
- if (*bp >= 128)
- { /* run */
- if (cc < 2)
- break;
- rc = *bp++ + (2 - 128);
- b = (uint32_t)*bp++ << shft;
- cc -= 2;
- while (rc-- && i < npixels)
- tp[i++] |= b;
- }
- else
- { /* non-run */
- rc = *bp++; /* nul is noop */
- while (--cc && rc-- && i < npixels)
- tp[i++] |= (uint32_t)*bp++ << shft;
- }
- }
- if (i != npixels)
- {
- TIFFErrorExtR(tif, module,
- "Not enough data at row %" PRIu32
- " (short %" TIFF_SSIZE_FORMAT " pixels)",
- tif->tif_row, npixels - i);
- tif->tif_rawcp = (uint8_t *)bp;
- tif->tif_rawcc = cc;
- return (0);
- }
- }
- (*sp->tfunc)(sp, op, npixels);
- tif->tif_rawcp = (uint8_t *)bp;
- tif->tif_rawcc = cc;
- return (1);
-}
-
-/*
- * Decode a strip of pixels. We break it into rows to
- * maintain synchrony with the encode algorithm, which
- * is row by row.
- */
-static int LogLuvDecodeStrip(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s)
-{
- tmsize_t rowlen = TIFFScanlineSize(tif);
-
- if (rowlen == 0)
- return 0;
-
- assert(cc % rowlen == 0);
- while (cc && (*tif->tif_decoderow)(tif, bp, rowlen, s))
- {
- bp += rowlen;
- cc -= rowlen;
- }
- return (cc == 0);
-}
-
-/*
- * Decode a tile of pixels. We break it into rows to
- * maintain synchrony with the encode algorithm, which
- * is row by row.
- */
-static int LogLuvDecodeTile(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s)
-{
- tmsize_t rowlen = TIFFTileRowSize(tif);
-
- if (rowlen == 0)
- return 0;
-
- assert(cc % rowlen == 0);
- while (cc && (*tif->tif_decoderow)(tif, bp, rowlen, s))
- {
- bp += rowlen;
- cc -= rowlen;
- }
- return (cc == 0);
-}
-
-/*
- * Encode a row of 16-bit pixels.
- */
-static int LogL16Encode(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s)
-{
- static const char module[] = "LogL16Encode";
- LogLuvState *sp = EncoderState(tif);
- int shft;
- tmsize_t i;
- tmsize_t j;
- tmsize_t npixels;
- uint8_t *op;
- int16_t *tp;
- int16_t b;
- tmsize_t occ;
- int rc = 0, mask;
- tmsize_t beg;
-
- (void)s;
- assert(s == 0);
- assert(sp != NULL);
- npixels = cc / sp->pixel_size;
-
- if (sp->user_datafmt == SGILOGDATAFMT_16BIT)
- tp = (int16_t *)bp;
- else
- {
- tp = (int16_t *)sp->tbuf;
- if (sp->tbuflen < npixels)
- {
- TIFFErrorExtR(tif, module, "Translation buffer too short");
- return (0);
- }
- (*sp->tfunc)(sp, bp, npixels);
- }
- /* compress each byte string */
- op = tif->tif_rawcp;
- occ = tif->tif_rawdatasize - tif->tif_rawcc;
- for (shft = 8; shft >= 0; shft -= 8)
- {
- for (i = 0; i < npixels; i += rc)
- {
- if (occ < 4)
- {
- tif->tif_rawcp = op;
- tif->tif_rawcc = tif->tif_rawdatasize - occ;
- if (!TIFFFlushData1(tif))
- return (0);
- op = tif->tif_rawcp;
- occ = tif->tif_rawdatasize - tif->tif_rawcc;
- }
- mask = 0xff << shft; /* find next run */
- for (beg = i; beg < npixels; beg += rc)
- {
- b = (int16_t)(tp[beg] & mask);
- rc = 1;
- while (rc < 127 + 2 && beg + rc < npixels &&
- (tp[beg + rc] & mask) == b)
- rc++;
- if (rc >= MINRUN)
- break; /* long enough */
- }
- if (beg - i > 1 && beg - i < MINRUN)
- {
- b = (int16_t)(tp[i] & mask); /*check short run */
- j = i + 1;
- while ((tp[j++] & mask) == b)
- if (j == beg)
- {
- *op++ = (uint8_t)(128 - 2 + j - i);
- *op++ = (uint8_t)(b >> shft);
- occ -= 2;
- i = beg;
- break;
- }
- }
- while (i < beg)
- { /* write out non-run */
- if ((j = beg - i) > 127)
- j = 127;
- if (occ < j + 3)
- {
- tif->tif_rawcp = op;
- tif->tif_rawcc = tif->tif_rawdatasize - occ;
- if (!TIFFFlushData1(tif))
- return (0);
- op = tif->tif_rawcp;
- occ = tif->tif_rawdatasize - tif->tif_rawcc;
- }
- *op++ = (uint8_t)j;
- occ--;
- while (j--)
- {
- *op++ = (uint8_t)(tp[i++] >> shft & 0xff);
- occ--;
- }
- }
- if (rc >= MINRUN)
- { /* write out run */
- *op++ = (uint8_t)(128 - 2 + rc);
- *op++ = (uint8_t)(tp[beg] >> shft & 0xff);
- occ -= 2;
- }
- else
- rc = 0;
- }
- }
- tif->tif_rawcp = op;
- tif->tif_rawcc = tif->tif_rawdatasize - occ;
-
- return (1);
-}
-
-/*
- * Encode a row of 24-bit pixels.
- */
-static int LogLuvEncode24(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s)
-{
- static const char module[] = "LogLuvEncode24";
- LogLuvState *sp = EncoderState(tif);
- tmsize_t i;
- tmsize_t npixels;
- tmsize_t occ;
- uint8_t *op;
- uint32_t *tp;
-
- (void)s;
- assert(s == 0);
- assert(sp != NULL);
- npixels = cc / sp->pixel_size;
-
- if (sp->user_datafmt == SGILOGDATAFMT_RAW)
- tp = (uint32_t *)bp;
- else
- {
- tp = (uint32_t *)sp->tbuf;
- if (sp->tbuflen < npixels)
- {
- TIFFErrorExtR(tif, module, "Translation buffer too short");
- return (0);
- }
- (*sp->tfunc)(sp, bp, npixels);
- }
- /* write out encoded pixels */
- op = tif->tif_rawcp;
- occ = tif->tif_rawdatasize - tif->tif_rawcc;
- for (i = npixels; i--;)
- {
- if (occ < 3)
- {
- tif->tif_rawcp = op;
- tif->tif_rawcc = tif->tif_rawdatasize - occ;
- if (!TIFFFlushData1(tif))
- return (0);
- op = tif->tif_rawcp;
- occ = tif->tif_rawdatasize - tif->tif_rawcc;
- }
- *op++ = (uint8_t)(*tp >> 16);
- *op++ = (uint8_t)(*tp >> 8 & 0xff);
- *op++ = (uint8_t)(*tp++ & 0xff);
- occ -= 3;
- }
- tif->tif_rawcp = op;
- tif->tif_rawcc = tif->tif_rawdatasize - occ;
-
- return (1);
-}
-
-/*
- * Encode a row of 32-bit pixels.
- */
-static int LogLuvEncode32(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s)
-{
- static const char module[] = "LogLuvEncode32";
- LogLuvState *sp = EncoderState(tif);
- int shft;
- tmsize_t i;
- tmsize_t j;
- tmsize_t npixels;
- uint8_t *op;
- uint32_t *tp;
- uint32_t b;
- tmsize_t occ;
- int rc = 0;
- tmsize_t beg;
-
- (void)s;
- assert(s == 0);
- assert(sp != NULL);
-
- npixels = cc / sp->pixel_size;
-
- if (sp->user_datafmt == SGILOGDATAFMT_RAW)
- tp = (uint32_t *)bp;
- else
- {
- tp = (uint32_t *)sp->tbuf;
- if (sp->tbuflen < npixels)
- {
- TIFFErrorExtR(tif, module, "Translation buffer too short");
- return (0);
- }
- (*sp->tfunc)(sp, bp, npixels);
- }
- /* compress each byte string */
- op = tif->tif_rawcp;
- occ = tif->tif_rawdatasize - tif->tif_rawcc;
- for (shft = 24; shft >= 0; shft -= 8)
- {
- const uint32_t mask = 0xffU << shft; /* find next run */
- for (i = 0; i < npixels; i += rc)
- {
- if (occ < 4)
- {
- tif->tif_rawcp = op;
- tif->tif_rawcc = tif->tif_rawdatasize - occ;
- if (!TIFFFlushData1(tif))
- return (0);
- op = tif->tif_rawcp;
- occ = tif->tif_rawdatasize - tif->tif_rawcc;
- }
- for (beg = i; beg < npixels; beg += rc)
- {
- b = tp[beg] & mask;
- rc = 1;
- while (rc < 127 + 2 && beg + rc < npixels &&
- (tp[beg + rc] & mask) == b)
- rc++;
- if (rc >= MINRUN)
- break; /* long enough */
- }
- if (beg - i > 1 && beg - i < MINRUN)
- {
- b = tp[i] & mask; /* check short run */
- j = i + 1;
- while ((tp[j++] & mask) == b)
- if (j == beg)
- {
- *op++ = (uint8_t)(128 - 2 + j - i);
- *op++ = (uint8_t)(b >> shft);
- occ -= 2;
- i = beg;
- break;
- }
- }
- while (i < beg)
- { /* write out non-run */
- if ((j = beg - i) > 127)
- j = 127;
- if (occ < j + 3)
- {
- tif->tif_rawcp = op;
- tif->tif_rawcc = tif->tif_rawdatasize - occ;
- if (!TIFFFlushData1(tif))
- return (0);
- op = tif->tif_rawcp;
- occ = tif->tif_rawdatasize - tif->tif_rawcc;
- }
- *op++ = (uint8_t)j;
- occ--;
- while (j--)
- {
- *op++ = (uint8_t)(tp[i++] >> shft & 0xff);
- occ--;
- }
- }
- if (rc >= MINRUN)
- { /* write out run */
- *op++ = (uint8_t)(128 - 2 + rc);
- *op++ = (uint8_t)(tp[beg] >> shft & 0xff);
- occ -= 2;
- }
- else
- rc = 0;
- }
- }
- tif->tif_rawcp = op;
- tif->tif_rawcc = tif->tif_rawdatasize - occ;
-
- return (1);
-}
-
-/*
- * Encode a strip of pixels. We break it into rows to
- * avoid encoding runs across row boundaries.
- */
-static int LogLuvEncodeStrip(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s)
-{
- tmsize_t rowlen = TIFFScanlineSize(tif);
-
- if (rowlen == 0)
- return 0;
-
- assert(cc % rowlen == 0);
- while (cc && (*tif->tif_encoderow)(tif, bp, rowlen, s) == 1)
- {
- bp += rowlen;
- cc -= rowlen;
- }
- return (cc == 0);
-}
-
-/*
- * Encode a tile of pixels. We break it into rows to
- * avoid encoding runs across row boundaries.
- */
-static int LogLuvEncodeTile(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s)
-{
- tmsize_t rowlen = TIFFTileRowSize(tif);
-
- if (rowlen == 0)
- return 0;
-
- assert(cc % rowlen == 0);
- while (cc && (*tif->tif_encoderow)(tif, bp, rowlen, s) == 1)
- {
- bp += rowlen;
- cc -= rowlen;
- }
- return (cc == 0);
-}
-
-/*
- * Encode/Decode functions for converting to and from user formats.
- */
-
-#include "uvcode.h"
-
-#ifndef UVSCALE
-#define U_NEU 0.210526316
-#define V_NEU 0.473684211
-#define UVSCALE 410.
-#endif
-
-#ifndef M_LN2
-#define M_LN2 0.69314718055994530942
-#endif
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-#undef log2 /* Conflict with C'99 function */
-#define log2(x) ((1. / M_LN2) * log(x))
-#undef exp2 /* Conflict with C'99 function */
-#define exp2(x) exp(M_LN2 *(x))
-
-static int tiff_itrunc(double x, int m)
-{
- if (m == SGILOGENCODE_NODITHER)
- return (int)x;
- /* Silence CoverityScan warning about bad crypto function */
- /* coverity[dont_call] */
- return (int)(x + rand() * (1. / RAND_MAX) - .5);
-}
-
-#if !LOGLUV_PUBLIC
-static
-#endif
- double
- LogL16toY(int p16) /* compute luminance from 16-bit LogL */
-{
- int Le = p16 & 0x7fff;
- double Y;
-
- if (!Le)
- return (0.);
- Y = exp(M_LN2 / 256. * (Le + .5) - M_LN2 * 64.);
- return (!(p16 & 0x8000) ? Y : -Y);
-}
-
-#if !LOGLUV_PUBLIC
-static
-#endif
- int
- LogL16fromY(double Y, int em) /* get 16-bit LogL from Y */
-{
- if (Y >= 1.8371976e19)
- return (0x7fff);
- if (Y <= -1.8371976e19)
- return (0xffff);
- if (Y > 5.4136769e-20)
- return tiff_itrunc(256. * (log2(Y) + 64.), em);
- if (Y < -5.4136769e-20)
- return (~0x7fff | tiff_itrunc(256. * (log2(-Y) + 64.), em));
- return (0);
-}
-
-static void L16toY(LogLuvState *sp, uint8_t *op, tmsize_t n)
-{
- int16_t *l16 = (int16_t *)sp->tbuf;
- float *yp = (float *)op;
-
- while (n-- > 0)
- *yp++ = (float)LogL16toY(*l16++);
-}
-
-static void L16toGry(LogLuvState *sp, uint8_t *op, tmsize_t n)
-{
- int16_t *l16 = (int16_t *)sp->tbuf;
- uint8_t *gp = (uint8_t *)op;
-
- while (n-- > 0)
- {
- double Y = LogL16toY(*l16++);
- *gp++ = (uint8_t)((Y <= 0.) ? 0
- : (Y >= 1.) ? 255
- : (int)(256. * sqrt(Y)));
- }
-}
-
-static void L16fromY(LogLuvState *sp, uint8_t *op, tmsize_t n)
-{
- int16_t *l16 = (int16_t *)sp->tbuf;
- float *yp = (float *)op;
-
- while (n-- > 0)
- *l16++ = (int16_t)(LogL16fromY(*yp++, sp->encode_meth));
-}
-
-#if !LOGLUV_PUBLIC
-static
-#endif
- void
- XYZtoRGB24(float *xyz, uint8_t *rgb)
-{
- double r, g, b;
- /* assume CCIR-709 primaries */
- r = 2.690 * xyz[0] + -1.276 * xyz[1] + -0.414 * xyz[2];
- g = -1.022 * xyz[0] + 1.978 * xyz[1] + 0.044 * xyz[2];
- b = 0.061 * xyz[0] + -0.224 * xyz[1] + 1.163 * xyz[2];
- /* assume 2.0 gamma for speed */
- /* could use integer sqrt approx., but this is probably faster */
- rgb[0] = (uint8_t)((r <= 0.) ? 0 : (r >= 1.) ? 255 : (int)(256. * sqrt(r)));
- rgb[1] = (uint8_t)((g <= 0.) ? 0 : (g >= 1.) ? 255 : (int)(256. * sqrt(g)));
- rgb[2] = (uint8_t)((b <= 0.) ? 0 : (b >= 1.) ? 255 : (int)(256. * sqrt(b)));
-}
-
-#if !LOGLUV_PUBLIC
-static
-#endif
- double
- LogL10toY(int p10) /* compute luminance from 10-bit LogL */
-{
- if (p10 == 0)
- return (0.);
- return (exp(M_LN2 / 64. * (p10 + .5) - M_LN2 * 12.));
-}
-
-#if !LOGLUV_PUBLIC
-static
-#endif
- int
- LogL10fromY(double Y, int em) /* get 10-bit LogL from Y */
-{
- if (Y >= 15.742)
- return (0x3ff);
- else if (Y <= .00024283)
- return (0);
- else
- return tiff_itrunc(64. * (log2(Y) + 12.), em);
-}
-
-#define NANGLES 100
-#define uv2ang(u, v) \
- ((NANGLES * .499999999 / M_PI) * atan2((v)-V_NEU, (u)-U_NEU) + .5 * NANGLES)
-
-static int oog_encode(double u, double v) /* encode out-of-gamut chroma */
-{
- static int oog_table[NANGLES];
- static int initialized = 0;
- register int i;
-
- if (!initialized)
- { /* set up perimeter table */
- double eps[NANGLES], ua, va, ang, epsa;
- int ui, vi, ustep;
- for (i = NANGLES; i--;)
- eps[i] = 2.;
- for (vi = UV_NVS; vi--;)
- {
- va = UV_VSTART + (vi + .5) * UV_SQSIZ;
- ustep = uv_row[vi].nus - 1;
- if (vi == UV_NVS - 1 || vi == 0 || ustep <= 0)
- ustep = 1;
- for (ui = uv_row[vi].nus - 1; ui >= 0; ui -= ustep)
- {
- ua = uv_row[vi].ustart + (ui + .5) * UV_SQSIZ;
- ang = uv2ang(ua, va);
- i = (int)ang;
- epsa = fabs(ang - (i + .5));
- if (epsa < eps[i])
- {
- oog_table[i] = uv_row[vi].ncum + ui;
- eps[i] = epsa;
- }
- }
- }
- for (i = NANGLES; i--;) /* fill any holes */
- if (eps[i] > 1.5)
- {
- int i1, i2;
- for (i1 = 1; i1 < NANGLES / 2; i1++)
- if (eps[(i + i1) % NANGLES] < 1.5)
- break;
- for (i2 = 1; i2 < NANGLES / 2; i2++)
- if (eps[(i + NANGLES - i2) % NANGLES] < 1.5)
- break;
- if (i1 < i2)
- oog_table[i] = oog_table[(i + i1) % NANGLES];
- else
- oog_table[i] = oog_table[(i + NANGLES - i2) % NANGLES];
- }
- initialized = 1;
- }
- i = (int)uv2ang(u, v); /* look up hue angle */
- return (oog_table[i]);
-}
-
-#undef uv2ang
-#undef NANGLES
-
-#if !LOGLUV_PUBLIC
-static
-#endif
- int
- uv_encode(double u, double v, int em) /* encode (u',v') coordinates */
-{
- unsigned int vi;
- int ui;
-
- /* check for NaN */
- if (u != u || v != v)
- {
- u = U_NEU;
- v = V_NEU;
- }
-
- if (v < UV_VSTART)
- return oog_encode(u, v);
- vi = tiff_itrunc((v - UV_VSTART) * (1. / UV_SQSIZ), em);
- if (vi >= UV_NVS)
- return oog_encode(u, v);
- if (u < uv_row[vi].ustart)
- return oog_encode(u, v);
- ui = tiff_itrunc((u - uv_row[vi].ustart) * (1. / UV_SQSIZ), em);
- if (ui >= uv_row[vi].nus)
- return oog_encode(u, v);
-
- return (uv_row[vi].ncum + ui);
-}
-
-#if !LOGLUV_PUBLIC
-static
-#endif
- int
- uv_decode(double *up, double *vp, int c) /* decode (u',v') index */
-{
- unsigned int upper, lower;
- int ui;
- unsigned int vi;
-
- if (c < 0 || c >= UV_NDIVS)
- return (-1);
- lower = 0; /* binary search */
- upper = UV_NVS;
- while (upper - lower > 1)
- {
- vi = (lower + upper) >> 1;
- ui = c - uv_row[vi].ncum;
- if (ui > 0)
- lower = vi;
- else if (ui < 0)
- upper = vi;
- else
- {
- lower = vi;
- break;
- }
- }
- vi = lower;
- ui = c - uv_row[vi].ncum;
- *up = uv_row[vi].ustart + (ui + .5) * UV_SQSIZ;
- *vp = UV_VSTART + (vi + .5) * UV_SQSIZ;
- return (0);
-}
-
-#if !LOGLUV_PUBLIC
-static
-#endif
- void
- LogLuv24toXYZ(uint32_t p, float *XYZ)
-{
- int Ce;
- double L, u, v, s, x, y;
- /* decode luminance */
- L = LogL10toY(p >> 14 & 0x3ff);
- if (L <= 0.)
- {
- XYZ[0] = XYZ[1] = XYZ[2] = 0.;
- return;
- }
- /* decode color */
- Ce = p & 0x3fff;
- if (uv_decode(&u, &v, Ce) < 0)
- {
- u = U_NEU;
- v = V_NEU;
- }
- s = 1. / (6. * u - 16. * v + 12.);
- x = 9. * u * s;
- y = 4. * v * s;
- /* convert to XYZ */
- XYZ[0] = (float)(x / y * L);
- XYZ[1] = (float)L;
- XYZ[2] = (float)((1. - x - y) / y * L);
-}
-
-#if !LOGLUV_PUBLIC
-static
-#endif
- uint32_t
- LogLuv24fromXYZ(float *XYZ, int em)
-{
- int Le, Ce;
- double u, v, s;
- /* encode luminance */
- Le = LogL10fromY(XYZ[1], em);
- /* encode color */
- s = XYZ[0] + 15. * XYZ[1] + 3. * XYZ[2];
- if (!Le || s <= 0.)
- {
- u = U_NEU;
- v = V_NEU;
- }
- else
- {
- u = 4. * XYZ[0] / s;
- v = 9. * XYZ[1] / s;
- }
- Ce = uv_encode(u, v, em);
- if (Ce < 0) /* never happens */
- Ce = uv_encode(U_NEU, V_NEU, SGILOGENCODE_NODITHER);
- /* combine encodings */
- return (Le << 14 | Ce);
-}
-
-static void Luv24toXYZ(LogLuvState *sp, uint8_t *op, tmsize_t n)
-{
- uint32_t *luv = (uint32_t *)sp->tbuf;
- float *xyz = (float *)op;
-
- while (n-- > 0)
- {
- LogLuv24toXYZ(*luv, xyz);
- xyz += 3;
- luv++;
- }
-}
-
-static void Luv24toLuv48(LogLuvState *sp, uint8_t *op, tmsize_t n)
-{
- uint32_t *luv = (uint32_t *)sp->tbuf;
- int16_t *luv3 = (int16_t *)op;
-
- while (n-- > 0)
- {
- double u, v;
-
- *luv3++ = (int16_t)((*luv >> 12 & 0xffd) + 13314);
- if (uv_decode(&u, &v, *luv & 0x3fff) < 0)
- {
- u = U_NEU;
- v = V_NEU;
- }
- *luv3++ = (int16_t)(u * (1L << 15));
- *luv3++ = (int16_t)(v * (1L << 15));
- luv++;
- }
-}
-
-static void Luv24toRGB(LogLuvState *sp, uint8_t *op, tmsize_t n)
-{
- uint32_t *luv = (uint32_t *)sp->tbuf;
- uint8_t *rgb = (uint8_t *)op;
-
- while (n-- > 0)
- {
- float xyz[3];
-
- LogLuv24toXYZ(*luv++, xyz);
- XYZtoRGB24(xyz, rgb);
- rgb += 3;
- }
-}
-
-static void Luv24fromXYZ(LogLuvState *sp, uint8_t *op, tmsize_t n)
-{
- uint32_t *luv = (uint32_t *)sp->tbuf;
- float *xyz = (float *)op;
-
- while (n-- > 0)
- {
- *luv++ = LogLuv24fromXYZ(xyz, sp->encode_meth);
- xyz += 3;
- }
-}
-
-static void Luv24fromLuv48(LogLuvState *sp, uint8_t *op, tmsize_t n)
-{
- uint32_t *luv = (uint32_t *)sp->tbuf;
- int16_t *luv3 = (int16_t *)op;
-
- while (n-- > 0)
- {
- int Le, Ce;
-
- if (luv3[0] <= 0)
- Le = 0;
- else if (luv3[0] >= (1 << 12) + 3314)
- Le = (1 << 10) - 1;
- else if (sp->encode_meth == SGILOGENCODE_NODITHER)
- Le = (luv3[0] - 3314) >> 2;
- else
- Le = tiff_itrunc(.25 * (luv3[0] - 3314.), sp->encode_meth);
-
- Ce = uv_encode((luv3[1] + .5) / (1 << 15), (luv3[2] + .5) / (1 << 15),
- sp->encode_meth);
- if (Ce < 0) /* never happens */
- Ce = uv_encode(U_NEU, V_NEU, SGILOGENCODE_NODITHER);
- *luv++ = (uint32_t)Le << 14 | Ce;
- luv3 += 3;
- }
-}
-
-#if !LOGLUV_PUBLIC
-static
-#endif
- void
- LogLuv32toXYZ(uint32_t p, float *XYZ)
-{
- double L, u, v, s, x, y;
- /* decode luminance */
- L = LogL16toY((int)p >> 16);
- if (L <= 0.)
- {
- XYZ[0] = XYZ[1] = XYZ[2] = 0.;
- return;
- }
- /* decode color */
- u = 1. / UVSCALE * ((p >> 8 & 0xff) + .5);
- v = 1. / UVSCALE * ((p & 0xff) + .5);
- s = 1. / (6. * u - 16. * v + 12.);
- x = 9. * u * s;
- y = 4. * v * s;
- /* convert to XYZ */
- XYZ[0] = (float)(x / y * L);
- XYZ[1] = (float)L;
- XYZ[2] = (float)((1. - x - y) / y * L);
-}
-
-#if !LOGLUV_PUBLIC
-static
-#endif
- uint32_t
- LogLuv32fromXYZ(float *XYZ, int em)
-{
- unsigned int Le, ue, ve;
- double u, v, s;
- /* encode luminance */
- Le = (unsigned int)LogL16fromY(XYZ[1], em);
- /* encode color */
- s = XYZ[0] + 15. * XYZ[1] + 3. * XYZ[2];
- if (!Le || s <= 0.)
- {
- u = U_NEU;
- v = V_NEU;
- }
- else
- {
- u = 4. * XYZ[0] / s;
- v = 9. * XYZ[1] / s;
- }
- if (u <= 0.)
- ue = 0;
- else
- ue = tiff_itrunc(UVSCALE * u, em);
- if (ue > 255)
- ue = 255;
- if (v <= 0.)
- ve = 0;
- else
- ve = tiff_itrunc(UVSCALE * v, em);
- if (ve > 255)
- ve = 255;
- /* combine encodings */
- return (Le << 16 | ue << 8 | ve);
-}
-
-static void Luv32toXYZ(LogLuvState *sp, uint8_t *op, tmsize_t n)
-{
- uint32_t *luv = (uint32_t *)sp->tbuf;
- float *xyz = (float *)op;
-
- while (n-- > 0)
- {
- LogLuv32toXYZ(*luv++, xyz);
- xyz += 3;
- }
-}
-
-static void Luv32toLuv48(LogLuvState *sp, uint8_t *op, tmsize_t n)
-{
- uint32_t *luv = (uint32_t *)sp->tbuf;
- int16_t *luv3 = (int16_t *)op;
-
- while (n-- > 0)
- {
- double u, v;
-
- *luv3++ = (int16_t)(*luv >> 16);
- u = 1. / UVSCALE * ((*luv >> 8 & 0xff) + .5);
- v = 1. / UVSCALE * ((*luv & 0xff) + .5);
- *luv3++ = (int16_t)(u * (1L << 15));
- *luv3++ = (int16_t)(v * (1L << 15));
- luv++;
- }
-}
-
-static void Luv32toRGB(LogLuvState *sp, uint8_t *op, tmsize_t n)
-{
- uint32_t *luv = (uint32_t *)sp->tbuf;
- uint8_t *rgb = (uint8_t *)op;
-
- while (n-- > 0)
- {
- float xyz[3];
-
- LogLuv32toXYZ(*luv++, xyz);
- XYZtoRGB24(xyz, rgb);
- rgb += 3;
- }
-}
-
-static void Luv32fromXYZ(LogLuvState *sp, uint8_t *op, tmsize_t n)
-{
- uint32_t *luv = (uint32_t *)sp->tbuf;
- float *xyz = (float *)op;
-
- while (n-- > 0)
- {
- *luv++ = LogLuv32fromXYZ(xyz, sp->encode_meth);
- xyz += 3;
- }
-}
-
-static void Luv32fromLuv48(LogLuvState *sp, uint8_t *op, tmsize_t n)
-{
- uint32_t *luv = (uint32_t *)sp->tbuf;
- int16_t *luv3 = (int16_t *)op;
-
- if (sp->encode_meth == SGILOGENCODE_NODITHER)
- {
- while (n-- > 0)
- {
- *luv++ = (uint32_t)luv3[0] << 16 |
- (luv3[1] * (uint32_t)(UVSCALE + .5) >> 7 & 0xff00) |
- (luv3[2] * (uint32_t)(UVSCALE + .5) >> 15 & 0xff);
- luv3 += 3;
- }
- return;
- }
- while (n-- > 0)
- {
- *luv++ =
- (uint32_t)luv3[0] << 16 |
- (tiff_itrunc(luv3[1] * (UVSCALE / (1 << 15)), sp->encode_meth)
- << 8 &
- 0xff00) |
- (tiff_itrunc(luv3[2] * (UVSCALE / (1 << 15)), sp->encode_meth) &
- 0xff);
- luv3 += 3;
- }
-}
-
-static void _logLuvNop(LogLuvState *sp, uint8_t *op, tmsize_t n)
-{
- (void)sp;
- (void)op;
- (void)n;
-}
-
-static int LogL16GuessDataFmt(TIFFDirectory *td)
-{
-#define PACK(s, b, f) (((b) << 6) | ((s) << 3) | (f))
- switch (
- PACK(td->td_samplesperpixel, td->td_bitspersample, td->td_sampleformat))
- {
- case PACK(1, 32, SAMPLEFORMAT_IEEEFP):
- return (SGILOGDATAFMT_FLOAT);
- case PACK(1, 16, SAMPLEFORMAT_VOID):
- case PACK(1, 16, SAMPLEFORMAT_INT):
- case PACK(1, 16, SAMPLEFORMAT_UINT):
- return (SGILOGDATAFMT_16BIT);
- case PACK(1, 8, SAMPLEFORMAT_VOID):
- case PACK(1, 8, SAMPLEFORMAT_UINT):
- return (SGILOGDATAFMT_8BIT);
- }
-#undef PACK
- return (SGILOGDATAFMT_UNKNOWN);
-}
-
-static tmsize_t multiply_ms(tmsize_t m1, tmsize_t m2)
-{
- return _TIFFMultiplySSize(NULL, m1, m2, NULL);
-}
-
-static int LogL16InitState(TIFF *tif)
-{
- static const char module[] = "LogL16InitState";
- TIFFDirectory *td = &tif->tif_dir;
- LogLuvState *sp = DecoderState(tif);
-
- assert(sp != NULL);
- assert(td->td_photometric == PHOTOMETRIC_LOGL);
-
- if (td->td_samplesperpixel != 1)
- {
- TIFFErrorExtR(tif, module,
- "Sorry, can not handle LogL image with %s=%" PRIu16,
- "Samples/pixel", td->td_samplesperpixel);
- return 0;
- }
-
- /* for some reason, we can't do this in TIFFInitLogL16 */
- if (sp->user_datafmt == SGILOGDATAFMT_UNKNOWN)
- sp->user_datafmt = LogL16GuessDataFmt(td);
- switch (sp->user_datafmt)
- {
- case SGILOGDATAFMT_FLOAT:
- sp->pixel_size = sizeof(float);
- break;
- case SGILOGDATAFMT_16BIT:
- sp->pixel_size = sizeof(int16_t);
- break;
- case SGILOGDATAFMT_8BIT:
- sp->pixel_size = sizeof(uint8_t);
- break;
- default:
- TIFFErrorExtR(tif, module,
- "No support for converting user data format to LogL");
- return (0);
- }
- if (isTiled(tif))
- sp->tbuflen = multiply_ms(td->td_tilewidth, td->td_tilelength);
- else if (td->td_rowsperstrip < td->td_imagelength)
- sp->tbuflen = multiply_ms(td->td_imagewidth, td->td_rowsperstrip);
- else
- sp->tbuflen = multiply_ms(td->td_imagewidth, td->td_imagelength);
- if (multiply_ms(sp->tbuflen, sizeof(int16_t)) == 0 ||
- (sp->tbuf = (uint8_t *)_TIFFmallocExt(
- tif, sp->tbuflen * sizeof(int16_t))) == NULL)
- {
- TIFFErrorExtR(tif, module, "No space for SGILog translation buffer");
- return (0);
- }
- return (1);
-}
-
-static int LogLuvGuessDataFmt(TIFFDirectory *td)
-{
- int guess;
-
- /*
- * If the user didn't tell us their datafmt,
- * take our best guess from the bitspersample.
- */
-#define PACK(a, b) (((a) << 3) | (b))
- switch (PACK(td->td_bitspersample, td->td_sampleformat))
- {
- case PACK(32, SAMPLEFORMAT_IEEEFP):
- guess = SGILOGDATAFMT_FLOAT;
- break;
- case PACK(32, SAMPLEFORMAT_VOID):
- case PACK(32, SAMPLEFORMAT_UINT):
- case PACK(32, SAMPLEFORMAT_INT):
- guess = SGILOGDATAFMT_RAW;
- break;
- case PACK(16, SAMPLEFORMAT_VOID):
- case PACK(16, SAMPLEFORMAT_INT):
- case PACK(16, SAMPLEFORMAT_UINT):
- guess = SGILOGDATAFMT_16BIT;
- break;
- case PACK(8, SAMPLEFORMAT_VOID):
- case PACK(8, SAMPLEFORMAT_UINT):
- guess = SGILOGDATAFMT_8BIT;
- break;
- default:
- guess = SGILOGDATAFMT_UNKNOWN;
- break;
-#undef PACK
- }
- /*
- * Double-check samples per pixel.
- */
- switch (td->td_samplesperpixel)
- {
- case 1:
- if (guess != SGILOGDATAFMT_RAW)
- guess = SGILOGDATAFMT_UNKNOWN;
- break;
- case 3:
- if (guess == SGILOGDATAFMT_RAW)
- guess = SGILOGDATAFMT_UNKNOWN;
- break;
- default:
- guess = SGILOGDATAFMT_UNKNOWN;
- break;
- }
- return (guess);
-}
-
-static int LogLuvInitState(TIFF *tif)
-{
- static const char module[] = "LogLuvInitState";
- TIFFDirectory *td = &tif->tif_dir;
- LogLuvState *sp = DecoderState(tif);
-
- assert(sp != NULL);
- assert(td->td_photometric == PHOTOMETRIC_LOGLUV);
-
- /* for some reason, we can't do this in TIFFInitLogLuv */
- if (td->td_planarconfig != PLANARCONFIG_CONTIG)
- {
- TIFFErrorExtR(tif, module,
- "SGILog compression cannot handle non-contiguous data");
- return (0);
- }
- if (sp->user_datafmt == SGILOGDATAFMT_UNKNOWN)
- sp->user_datafmt = LogLuvGuessDataFmt(td);
- switch (sp->user_datafmt)
- {
- case SGILOGDATAFMT_FLOAT:
- sp->pixel_size = 3 * sizeof(float);
- break;
- case SGILOGDATAFMT_16BIT:
- sp->pixel_size = 3 * sizeof(int16_t);
- break;
- case SGILOGDATAFMT_RAW:
- sp->pixel_size = sizeof(uint32_t);
- break;
- case SGILOGDATAFMT_8BIT:
- sp->pixel_size = 3 * sizeof(uint8_t);
- break;
- default:
- TIFFErrorExtR(
- tif, module,
- "No support for converting user data format to LogLuv");
- return (0);
- }
- if (isTiled(tif))
- sp->tbuflen = multiply_ms(td->td_tilewidth, td->td_tilelength);
- else if (td->td_rowsperstrip < td->td_imagelength)
- sp->tbuflen = multiply_ms(td->td_imagewidth, td->td_rowsperstrip);
- else
- sp->tbuflen = multiply_ms(td->td_imagewidth, td->td_imagelength);
- if (multiply_ms(sp->tbuflen, sizeof(uint32_t)) == 0 ||
- (sp->tbuf = (uint8_t *)_TIFFmallocExt(
- tif, sp->tbuflen * sizeof(uint32_t))) == NULL)
- {
- TIFFErrorExtR(tif, module, "No space for SGILog translation buffer");
- return (0);
- }
- return (1);
-}
-
-static int LogLuvFixupTags(TIFF *tif)
-{
- (void)tif;
- return (1);
-}
-
-static int LogLuvSetupDecode(TIFF *tif)
-{
- static const char module[] = "LogLuvSetupDecode";
- LogLuvState *sp = DecoderState(tif);
- TIFFDirectory *td = &tif->tif_dir;
-
- tif->tif_postdecode = _TIFFNoPostDecode;
- switch (td->td_photometric)
- {
- case PHOTOMETRIC_LOGLUV:
- if (!LogLuvInitState(tif))
- break;
- if (td->td_compression == COMPRESSION_SGILOG24)
- {
- tif->tif_decoderow = LogLuvDecode24;
- switch (sp->user_datafmt)
- {
- case SGILOGDATAFMT_FLOAT:
- sp->tfunc = Luv24toXYZ;
- break;
- case SGILOGDATAFMT_16BIT:
- sp->tfunc = Luv24toLuv48;
- break;
- case SGILOGDATAFMT_8BIT:
- sp->tfunc = Luv24toRGB;
- break;
- }
- }
- else
- {
- tif->tif_decoderow = LogLuvDecode32;
- switch (sp->user_datafmt)
- {
- case SGILOGDATAFMT_FLOAT:
- sp->tfunc = Luv32toXYZ;
- break;
- case SGILOGDATAFMT_16BIT:
- sp->tfunc = Luv32toLuv48;
- break;
- case SGILOGDATAFMT_8BIT:
- sp->tfunc = Luv32toRGB;
- break;
- }
- }
- return (1);
- case PHOTOMETRIC_LOGL:
- if (!LogL16InitState(tif))
- break;
- tif->tif_decoderow = LogL16Decode;
- switch (sp->user_datafmt)
- {
- case SGILOGDATAFMT_FLOAT:
- sp->tfunc = L16toY;
- break;
- case SGILOGDATAFMT_8BIT:
- sp->tfunc = L16toGry;
- break;
- }
- return (1);
- default:
- TIFFErrorExtR(tif, module,
- "Inappropriate photometric interpretation %" PRIu16
- " for SGILog compression; %s",
- td->td_photometric, "must be either LogLUV or LogL");
- break;
- }
- return (0);
-}
-
-static int LogLuvSetupEncode(TIFF *tif)
-{
- static const char module[] = "LogLuvSetupEncode";
- LogLuvState *sp = EncoderState(tif);
- TIFFDirectory *td = &tif->tif_dir;
-
- switch (td->td_photometric)
- {
- case PHOTOMETRIC_LOGLUV:
- if (!LogLuvInitState(tif))
- return (0);
- if (td->td_compression == COMPRESSION_SGILOG24)
- {
- tif->tif_encoderow = LogLuvEncode24;
- switch (sp->user_datafmt)
- {
- case SGILOGDATAFMT_FLOAT:
- sp->tfunc = Luv24fromXYZ;
- break;
- case SGILOGDATAFMT_16BIT:
- sp->tfunc = Luv24fromLuv48;
- break;
- case SGILOGDATAFMT_RAW:
- break;
- default:
- goto notsupported;
- }
- }
- else
- {
- tif->tif_encoderow = LogLuvEncode32;
- switch (sp->user_datafmt)
- {
- case SGILOGDATAFMT_FLOAT:
- sp->tfunc = Luv32fromXYZ;
- break;
- case SGILOGDATAFMT_16BIT:
- sp->tfunc = Luv32fromLuv48;
- break;
- case SGILOGDATAFMT_RAW:
- break;
- default:
- goto notsupported;
- }
- }
- break;
- case PHOTOMETRIC_LOGL:
- if (!LogL16InitState(tif))
- return (0);
- tif->tif_encoderow = LogL16Encode;
- switch (sp->user_datafmt)
- {
- case SGILOGDATAFMT_FLOAT:
- sp->tfunc = L16fromY;
- break;
- case SGILOGDATAFMT_16BIT:
- break;
- default:
- goto notsupported;
- }
- break;
- default:
- TIFFErrorExtR(tif, module,
- "Inappropriate photometric interpretation %" PRIu16
- " for SGILog compression; %s",
- td->td_photometric, "must be either LogLUV or LogL");
- return (0);
- }
- sp->encoder_state = 1;
- return (1);
-notsupported:
- TIFFErrorExtR(tif, module,
- "SGILog compression supported only for %s, or raw data",
- td->td_photometric == PHOTOMETRIC_LOGL ? "Y, L" : "XYZ, Luv");
- return (0);
-}
-
-static void LogLuvClose(TIFF *tif)
-{
- LogLuvState *sp = (LogLuvState *)tif->tif_data;
- TIFFDirectory *td = &tif->tif_dir;
-
- assert(sp != 0);
- /*
- * For consistency, we always want to write out the same
- * bitspersample and sampleformat for our TIFF file,
- * regardless of the data format being used by the application.
- * Since this routine is called after tags have been set but
- * before they have been recorded in the file, we reset them here.
- * Note: this is really a nasty approach. See PixarLogClose
- */
- if (sp->encoder_state)
- {
- /* See PixarLogClose. Might avoid issues with tags whose size depends
- * on those below, but not completely sure this is enough. */
- td->td_samplesperpixel =
- (td->td_photometric == PHOTOMETRIC_LOGL) ? 1 : 3;
- td->td_bitspersample = 16;
- td->td_sampleformat = SAMPLEFORMAT_INT;
- }
-}
-
-static void LogLuvCleanup(TIFF *tif)
-{
- LogLuvState *sp = (LogLuvState *)tif->tif_data;
-
- assert(sp != 0);
-
- tif->tif_tagmethods.vgetfield = sp->vgetparent;
- tif->tif_tagmethods.vsetfield = sp->vsetparent;
-
- if (sp->tbuf)
- _TIFFfreeExt(tif, sp->tbuf);
- _TIFFfreeExt(tif, sp);
- tif->tif_data = NULL;
-
- _TIFFSetDefaultCompressionState(tif);
-}
-
-static int LogLuvVSetField(TIFF *tif, uint32_t tag, va_list ap)
-{
- static const char module[] = "LogLuvVSetField";
- LogLuvState *sp = DecoderState(tif);
- int bps, fmt;
-
- switch (tag)
- {
- case TIFFTAG_SGILOGDATAFMT:
- sp->user_datafmt = (int)va_arg(ap, int);
- /*
- * Tweak the TIFF header so that the rest of libtiff knows what
- * size of data will be passed between app and library, and
- * assume that the app knows what it is doing and is not
- * confused by these header manipulations...
- */
- switch (sp->user_datafmt)
- {
- case SGILOGDATAFMT_FLOAT:
- bps = 32;
- fmt = SAMPLEFORMAT_IEEEFP;
- break;
- case SGILOGDATAFMT_16BIT:
- bps = 16;
- fmt = SAMPLEFORMAT_INT;
- break;
- case SGILOGDATAFMT_RAW:
- bps = 32;
- fmt = SAMPLEFORMAT_UINT;
- TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1);
- break;
- case SGILOGDATAFMT_8BIT:
- bps = 8;
- fmt = SAMPLEFORMAT_UINT;
- break;
- default:
- TIFFErrorExtR(
- tif, tif->tif_name,
- "Unknown data format %d for LogLuv compression",
- sp->user_datafmt);
- return (0);
- }
- TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bps);
- TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, fmt);
- /*
- * Must recalculate sizes should bits/sample change.
- */
- tif->tif_tilesize = isTiled(tif) ? TIFFTileSize(tif) : (tmsize_t)-1;
- tif->tif_scanlinesize = TIFFScanlineSize(tif);
- return (1);
- case TIFFTAG_SGILOGENCODE:
- sp->encode_meth = (int)va_arg(ap, int);
- if (sp->encode_meth != SGILOGENCODE_NODITHER &&
- sp->encode_meth != SGILOGENCODE_RANDITHER)
- {
- TIFFErrorExtR(tif, module,
- "Unknown encoding %d for LogLuv compression",
- sp->encode_meth);
- return (0);
- }
- return (1);
- default:
- return (*sp->vsetparent)(tif, tag, ap);
- }
-}
-
-static int LogLuvVGetField(TIFF *tif, uint32_t tag, va_list ap)
-{
- LogLuvState *sp = (LogLuvState *)tif->tif_data;
-
- switch (tag)
- {
- case TIFFTAG_SGILOGDATAFMT:
- *va_arg(ap, int *) = sp->user_datafmt;
- return (1);
- default:
- return (*sp->vgetparent)(tif, tag, ap);
- }
-}
-
-static const TIFFField LogLuvFields[] = {
- {TIFFTAG_SGILOGDATAFMT, 0, 0, TIFF_SHORT, 0, TIFF_SETGET_INT,
- TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "SGILogDataFmt", NULL},
- {TIFFTAG_SGILOGENCODE, 0, 0, TIFF_SHORT, 0, TIFF_SETGET_INT,
- TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "SGILogEncode", NULL}};
-
-int TIFFInitSGILog(TIFF *tif, int scheme)
-{
- static const char module[] = "TIFFInitSGILog";
- LogLuvState *sp;
-
- assert(scheme == COMPRESSION_SGILOG24 || scheme == COMPRESSION_SGILOG);
-
- /*
- * Merge codec-specific tag information.
- */
- if (!_TIFFMergeFields(tif, LogLuvFields, TIFFArrayCount(LogLuvFields)))
- {
- TIFFErrorExtR(tif, module, "Merging SGILog codec-specific tags failed");
- return 0;
- }
-
- /*
- * Allocate state block so tag methods have storage to record values.
- */
- tif->tif_data = (uint8_t *)_TIFFmallocExt(tif, sizeof(LogLuvState));
- if (tif->tif_data == NULL)
- goto bad;
- sp = (LogLuvState *)tif->tif_data;
- _TIFFmemset((void *)sp, 0, sizeof(*sp));
- sp->user_datafmt = SGILOGDATAFMT_UNKNOWN;
- sp->encode_meth = (scheme == COMPRESSION_SGILOG24) ? SGILOGENCODE_RANDITHER
- : SGILOGENCODE_NODITHER;
- sp->tfunc = _logLuvNop;
-
- /*
- * Install codec methods.
- * NB: tif_decoderow & tif_encoderow are filled
- * in at setup time.
- */
- tif->tif_fixuptags = LogLuvFixupTags;
- tif->tif_setupdecode = LogLuvSetupDecode;
- tif->tif_decodestrip = LogLuvDecodeStrip;
- tif->tif_decodetile = LogLuvDecodeTile;
- tif->tif_setupencode = LogLuvSetupEncode;
- tif->tif_encodestrip = LogLuvEncodeStrip;
- tif->tif_encodetile = LogLuvEncodeTile;
- tif->tif_close = LogLuvClose;
- tif->tif_cleanup = LogLuvCleanup;
-
- /*
- * Override parent get/set field methods.
- */
- sp->vgetparent = tif->tif_tagmethods.vgetfield;
- tif->tif_tagmethods.vgetfield = LogLuvVGetField; /* hook for codec tags */
- sp->vsetparent = tif->tif_tagmethods.vsetfield;
- tif->tif_tagmethods.vsetfield = LogLuvVSetField; /* hook for codec tags */
-
- return (1);
-bad:
- TIFFErrorExtR(tif, module, "%s: No space for LogLuv state block",
- tif->tif_name);
- return (0);
-}
-#endif /* LOGLUV_SUPPORT */
diff --git a/contrib/libs/libtiff/tif_lzma.c b/contrib/libs/libtiff/tif_lzma.c
deleted file mode 100644
index db1c8b6829..0000000000
--- a/contrib/libs/libtiff/tif_lzma.c
+++ /dev/null
@@ -1,542 +0,0 @@
-/*
- * Copyright (c) 2010, Andrey Kiselev <dron@ak4719.spb.edu>
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-#include "tiffiop.h"
-#ifdef LZMA_SUPPORT
-/*
- * TIFF Library.
- *
- * LZMA2 Compression Support
- *
- * You need an LZMA2 SDK to link with. See http://tukaani.org/xz/ for details.
- *
- * The codec is derived from ZLIB codec (tif_zip.c).
- */
-
-#include "lzma.h"
-#include "tif_predict.h"
-
-#include <stdio.h>
-
-/*
- * State block for each open TIFF file using LZMA2 compression/decompression.
- */
-typedef struct
-{
- TIFFPredictorState predict;
- int read_error; /* whether a read error has occurred, and which should cause
- further reads in the same strip/tile to be aborted */
- lzma_stream stream;
- lzma_filter filters[LZMA_FILTERS_MAX + 1];
- lzma_options_delta opt_delta; /* delta filter options */
- lzma_options_lzma opt_lzma; /* LZMA2 filter options */
- int preset; /* compression level */
- lzma_check check; /* type of the integrity check */
- int state; /* state flags */
-#define LSTATE_INIT_DECODE 0x01
-#define LSTATE_INIT_ENCODE 0x02
-
- TIFFVGetMethod vgetparent; /* super-class method */
- TIFFVSetMethod vsetparent; /* super-class method */
-} LZMAState;
-
-#define GetLZMAState(tif) ((LZMAState *)(tif)->tif_data)
-#define LZMADecoderState(tif) GetLZMAState(tif)
-#define LZMAEncoderState(tif) GetLZMAState(tif)
-
-static int LZMAEncode(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s);
-static int LZMADecode(TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s);
-
-static const char *LZMAStrerror(lzma_ret ret)
-{
- switch (ret)
- {
- case LZMA_OK:
- return "operation completed successfully";
- case LZMA_STREAM_END:
- return "end of stream was reached";
- case LZMA_NO_CHECK:
- return "input stream has no integrity check";
- case LZMA_UNSUPPORTED_CHECK:
- return "cannot calculate the integrity check";
- case LZMA_GET_CHECK:
- return "integrity check type is now available";
- case LZMA_MEM_ERROR:
- return "cannot allocate memory";
- case LZMA_MEMLIMIT_ERROR:
- return "memory usage limit was reached";
- case LZMA_FORMAT_ERROR:
- return "file format not recognized";
- case LZMA_OPTIONS_ERROR:
- return "invalid or unsupported options";
- case LZMA_DATA_ERROR:
- return "data is corrupt";
- case LZMA_BUF_ERROR:
- return "no progress is possible (stream is truncated or corrupt)";
- case LZMA_PROG_ERROR:
- return "programming error";
- default:
- return "unidentified liblzma error";
- }
-}
-
-static int LZMAFixupTags(TIFF *tif)
-{
- (void)tif;
- return 1;
-}
-
-static int LZMASetupDecode(TIFF *tif)
-{
- LZMAState *sp = LZMADecoderState(tif);
-
- assert(sp != NULL);
-
- /* if we were last encoding, terminate this mode */
- if (sp->state & LSTATE_INIT_ENCODE)
- {
- lzma_end(&sp->stream);
- sp->state = 0;
- }
-
- sp->state |= LSTATE_INIT_DECODE;
- return 1;
-}
-
-/*
- * Setup state for decoding a strip.
- */
-static int LZMAPreDecode(TIFF *tif, uint16_t s)
-{
- static const char module[] = "LZMAPreDecode";
- LZMAState *sp = LZMADecoderState(tif);
- lzma_ret ret;
-
- (void)s;
- assert(sp != NULL);
-
- if ((sp->state & LSTATE_INIT_DECODE) == 0)
- tif->tif_setupdecode(tif);
-
- sp->stream.next_in = tif->tif_rawdata;
- sp->stream.avail_in = (size_t)tif->tif_rawcc;
- if ((tmsize_t)sp->stream.avail_in != tif->tif_rawcc)
- {
- TIFFErrorExtR(tif, module,
- "Liblzma cannot deal with buffers this size");
- return 0;
- }
-
- /*
- * Disable memory limit when decoding. UINT64_MAX is a flag to disable
- * the limit, we are passing (uint64_t)-1 which should be the same.
- */
- ret = lzma_stream_decoder(&sp->stream, (uint64_t)-1, 0);
- if (ret != LZMA_OK)
- {
- TIFFErrorExtR(tif, module, "Error initializing the stream decoder, %s",
- LZMAStrerror(ret));
- return 0;
- }
-
- sp->read_error = 0;
-
- return 1;
-}
-
-static int LZMADecode(TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s)
-{
- static const char module[] = "LZMADecode";
- LZMAState *sp = LZMADecoderState(tif);
-
- (void)s;
- assert(sp != NULL);
- assert(sp->state == LSTATE_INIT_DECODE);
-
- if (sp->read_error)
- {
- memset(op, 0, (size_t)occ);
- TIFFErrorExtR(tif, module,
- "LZMADecode: Scanline %" PRIu32 " cannot be read due to "
- "previous error",
- tif->tif_row);
- return 0;
- }
-
- sp->stream.next_in = tif->tif_rawcp;
- sp->stream.avail_in = (size_t)tif->tif_rawcc;
-
- sp->stream.next_out = op;
- sp->stream.avail_out = (size_t)occ;
- if ((tmsize_t)sp->stream.avail_out != occ)
- {
- // read_error not set here as this is a usage issue that can be
- // recovered in a following call.
- memset(op, 0, (size_t)occ);
- TIFFErrorExtR(tif, module,
- "Liblzma cannot deal with buffers this size");
- return 0;
- }
-
- do
- {
- /*
- * Save the current stream state to properly recover from the
- * decoding errors later.
- */
- const uint8_t *next_in = sp->stream.next_in;
- size_t avail_in = sp->stream.avail_in;
-
- lzma_ret ret = lzma_code(&sp->stream, LZMA_RUN);
- if (ret == LZMA_STREAM_END)
- break;
- if (ret == LZMA_MEMLIMIT_ERROR)
- {
- lzma_ret r =
- lzma_stream_decoder(&sp->stream, lzma_memusage(&sp->stream), 0);
- if (r != LZMA_OK)
- {
- sp->read_error = 1;
- memset(op, 0, (size_t)occ);
- TIFFErrorExtR(tif, module,
- "Error initializing the stream decoder, %s",
- LZMAStrerror(r));
- break;
- }
- sp->stream.next_in = next_in;
- sp->stream.avail_in = avail_in;
- continue;
- }
- if (ret != LZMA_OK)
- {
- TIFFErrorExtR(tif, module,
- "Decoding error at scanline %" PRIu32 ", %s",
- tif->tif_row, LZMAStrerror(ret));
- break;
- }
- } while (sp->stream.avail_out > 0);
- if (sp->stream.avail_out != 0)
- {
- sp->read_error = 1;
- memset(sp->stream.next_out, 0, sp->stream.avail_out);
- TIFFErrorExtR(tif, module,
- "Not enough data at scanline %" PRIu32
- " (short %" TIFF_SIZE_FORMAT " bytes)",
- tif->tif_row, sp->stream.avail_out);
- return 0;
- }
-
- tif->tif_rawcp = (uint8_t *)sp->stream.next_in; /* cast away const */
- tif->tif_rawcc = sp->stream.avail_in;
-
- return 1;
-}
-
-static int LZMASetupEncode(TIFF *tif)
-{
- LZMAState *sp = LZMAEncoderState(tif);
-
- assert(sp != NULL);
- if (sp->state & LSTATE_INIT_DECODE)
- {
- lzma_end(&sp->stream);
- sp->state = 0;
- }
-
- sp->state |= LSTATE_INIT_ENCODE;
- return 1;
-}
-
-/*
- * Reset encoding state at the start of a strip.
- */
-static int LZMAPreEncode(TIFF *tif, uint16_t s)
-{
- static const char module[] = "LZMAPreEncode";
- LZMAState *sp = LZMAEncoderState(tif);
- lzma_ret ret;
-
- (void)s;
- assert(sp != NULL);
- if (sp->state != LSTATE_INIT_ENCODE)
- tif->tif_setupencode(tif);
-
- sp->stream.next_out = tif->tif_rawdata;
- sp->stream.avail_out = (size_t)tif->tif_rawdatasize;
- if ((tmsize_t)sp->stream.avail_out != tif->tif_rawdatasize)
- {
- TIFFErrorExtR(tif, module,
- "Liblzma cannot deal with buffers this size");
- return 0;
- }
- ret = lzma_stream_encoder(&sp->stream, sp->filters, sp->check);
- if (ret != LZMA_OK)
- {
- TIFFErrorExtR(tif, module, "Error in lzma_stream_encoder(): %s",
- LZMAStrerror(ret));
- return 0;
- }
- return 1;
-}
-
-/*
- * Encode a chunk of pixels.
- */
-static int LZMAEncode(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s)
-{
- static const char module[] = "LZMAEncode";
- LZMAState *sp = LZMAEncoderState(tif);
-
- assert(sp != NULL);
- assert(sp->state == LSTATE_INIT_ENCODE);
-
- (void)s;
- sp->stream.next_in = bp;
- sp->stream.avail_in = (size_t)cc;
- if ((tmsize_t)sp->stream.avail_in != cc)
- {
- TIFFErrorExtR(tif, module,
- "Liblzma cannot deal with buffers this size");
- return 0;
- }
- do
- {
- lzma_ret ret = lzma_code(&sp->stream, LZMA_RUN);
- if (ret != LZMA_OK)
- {
- TIFFErrorExtR(tif, module,
- "Encoding error at scanline %" PRIu32 ", %s",
- tif->tif_row, LZMAStrerror(ret));
- return 0;
- }
- if (sp->stream.avail_out == 0)
- {
- tif->tif_rawcc = tif->tif_rawdatasize;
- if (!TIFFFlushData1(tif))
- return 0;
- sp->stream.next_out = tif->tif_rawdata;
- sp->stream.avail_out =
- (size_t)
- tif->tif_rawdatasize; /* this is a safe typecast, as check
- is made already in LZMAPreEncode */
- }
- } while (sp->stream.avail_in > 0);
- return 1;
-}
-
-/*
- * Finish off an encoded strip by flushing the last
- * string and tacking on an End Of Information code.
- */
-static int LZMAPostEncode(TIFF *tif)
-{
- static const char module[] = "LZMAPostEncode";
- LZMAState *sp = LZMAEncoderState(tif);
- lzma_ret ret;
-
- sp->stream.avail_in = 0;
- do
- {
- ret = lzma_code(&sp->stream, LZMA_FINISH);
- switch (ret)
- {
- case LZMA_STREAM_END:
- case LZMA_OK:
- if ((tmsize_t)sp->stream.avail_out != tif->tif_rawdatasize)
- {
- tif->tif_rawcc =
- tif->tif_rawdatasize - sp->stream.avail_out;
- if (!TIFFFlushData1(tif))
- return 0;
- sp->stream.next_out = tif->tif_rawdata;
- sp->stream.avail_out =
- (size_t)
- tif->tif_rawdatasize; /* this is a safe typecast, as
- check is made already in
- ZIPPreEncode */
- }
- break;
- default:
- TIFFErrorExtR(tif, module, "Liblzma error: %s",
- LZMAStrerror(ret));
- return 0;
- }
- } while (ret != LZMA_STREAM_END);
- return 1;
-}
-
-static void LZMACleanup(TIFF *tif)
-{
- LZMAState *sp = GetLZMAState(tif);
-
- assert(sp != 0);
-
- (void)TIFFPredictorCleanup(tif);
-
- tif->tif_tagmethods.vgetfield = sp->vgetparent;
- tif->tif_tagmethods.vsetfield = sp->vsetparent;
-
- if (sp->state)
- {
- lzma_end(&sp->stream);
- sp->state = 0;
- }
- _TIFFfreeExt(tif, sp);
- tif->tif_data = NULL;
-
- _TIFFSetDefaultCompressionState(tif);
-}
-
-static int LZMAVSetField(TIFF *tif, uint32_t tag, va_list ap)
-{
- static const char module[] = "LZMAVSetField";
- LZMAState *sp = GetLZMAState(tif);
-
- switch (tag)
- {
- case TIFFTAG_LZMAPRESET:
- sp->preset = (int)va_arg(ap, int);
- lzma_lzma_preset(&sp->opt_lzma, sp->preset);
- if (sp->state & LSTATE_INIT_ENCODE)
- {
- lzma_ret ret =
- lzma_stream_encoder(&sp->stream, sp->filters, sp->check);
- if (ret != LZMA_OK)
- {
- TIFFErrorExtR(tif, module, "Liblzma error: %s",
- LZMAStrerror(ret));
- }
- }
- return 1;
- default:
- return (*sp->vsetparent)(tif, tag, ap);
- }
- /*NOTREACHED*/
-}
-
-static int LZMAVGetField(TIFF *tif, uint32_t tag, va_list ap)
-{
- LZMAState *sp = GetLZMAState(tif);
-
- switch (tag)
- {
- case TIFFTAG_LZMAPRESET:
- *va_arg(ap, int *) = sp->preset;
- break;
- default:
- return (*sp->vgetparent)(tif, tag, ap);
- }
- return 1;
-}
-
-static const TIFFField lzmaFields[] = {
- {TIFFTAG_LZMAPRESET, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT,
- TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE,
- "LZMA2 Compression Preset", NULL},
-};
-
-int TIFFInitLZMA(TIFF *tif, int scheme)
-{
- static const char module[] = "TIFFInitLZMA";
- LZMAState *sp;
- lzma_stream tmp_stream = LZMA_STREAM_INIT;
-
- (void)scheme;
- assert(scheme == COMPRESSION_LZMA);
-
- /*
- * Merge codec-specific tag information.
- */
- if (!_TIFFMergeFields(tif, lzmaFields, TIFFArrayCount(lzmaFields)))
- {
- TIFFErrorExtR(tif, module, "Merging LZMA2 codec-specific tags failed");
- return 0;
- }
-
- /*
- * Allocate state block so tag methods have storage to record values.
- */
- tif->tif_data = (uint8_t *)_TIFFmallocExt(tif, sizeof(LZMAState));
- if (tif->tif_data == NULL)
- goto bad;
- sp = GetLZMAState(tif);
- memcpy(&sp->stream, &tmp_stream, sizeof(lzma_stream));
-
- /*
- * Override parent get/set field methods.
- */
- sp->vgetparent = tif->tif_tagmethods.vgetfield;
- tif->tif_tagmethods.vgetfield = LZMAVGetField; /* hook for codec tags */
- sp->vsetparent = tif->tif_tagmethods.vsetfield;
- tif->tif_tagmethods.vsetfield = LZMAVSetField; /* hook for codec tags */
-
- /* Default values for codec-specific fields */
- sp->preset = LZMA_PRESET_DEFAULT; /* default comp. level */
- sp->check = LZMA_CHECK_NONE;
- sp->state = 0;
-
- /* Data filters. So far we are using delta and LZMA2 filters only. */
- sp->opt_delta.type = LZMA_DELTA_TYPE_BYTE;
- /*
- * The sample size in bytes seems to be reasonable distance for delta
- * filter.
- */
- sp->opt_delta.dist = (tif->tif_dir.td_bitspersample % 8)
- ? 1
- : tif->tif_dir.td_bitspersample / 8;
- sp->filters[0].id = LZMA_FILTER_DELTA;
- sp->filters[0].options = &sp->opt_delta;
-
- lzma_lzma_preset(&sp->opt_lzma, sp->preset);
- sp->filters[1].id = LZMA_FILTER_LZMA2;
- sp->filters[1].options = &sp->opt_lzma;
-
- sp->filters[2].id = LZMA_VLI_UNKNOWN;
- sp->filters[2].options = NULL;
-
- /*
- * Install codec methods.
- */
- tif->tif_fixuptags = LZMAFixupTags;
- tif->tif_setupdecode = LZMASetupDecode;
- tif->tif_predecode = LZMAPreDecode;
- tif->tif_decoderow = LZMADecode;
- tif->tif_decodestrip = LZMADecode;
- tif->tif_decodetile = LZMADecode;
- tif->tif_setupencode = LZMASetupEncode;
- tif->tif_preencode = LZMAPreEncode;
- tif->tif_postencode = LZMAPostEncode;
- tif->tif_encoderow = LZMAEncode;
- tif->tif_encodestrip = LZMAEncode;
- tif->tif_encodetile = LZMAEncode;
- tif->tif_cleanup = LZMACleanup;
- /*
- * Setup predictor setup.
- */
- (void)TIFFPredictorInit(tif);
- return 1;
-bad:
- TIFFErrorExtR(tif, module, "No space for LZMA2 state block");
- return 0;
-}
-#endif /* LZMA_SUPPORT */
diff --git a/contrib/libs/libtiff/tif_lzw.c b/contrib/libs/libtiff/tif_lzw.c
deleted file mode 100644
index 4baf78e50b..0000000000
--- a/contrib/libs/libtiff/tif_lzw.c
+++ /dev/null
@@ -1,1456 +0,0 @@
-/*
- * Copyright (c) 1988-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
- * Copyright (c) 2022 Even Rouault
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-#include "tiffiop.h"
-#ifdef LZW_SUPPORT
-/*
- * TIFF Library.
- * Rev 5.0 Lempel-Ziv & Welch Compression Support
- *
- * This code is derived from the compress program whose code is
- * derived from software contributed to Berkeley by James A. Woods,
- * derived from original work by Spencer Thomas and Joseph Orost.
- *
- * The original Berkeley copyright notice appears below in its entirety.
- */
-#include "tif_predict.h"
-
-#include <stdbool.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-/* Select the plausible largest natural integer type for the architecture */
-#define SIZEOF_WORDTYPE SIZEOF_SIZE_T
-typedef size_t WordType;
-
-/*
- * NB: The 5.0 spec describes a different algorithm than Aldus
- * implements. Specifically, Aldus does code length transitions
- * one code earlier than should be done (for real LZW).
- * Earlier versions of this library implemented the correct
- * LZW algorithm, but emitted codes in a bit order opposite
- * to the TIFF spec. Thus, to maintain compatibility w/ Aldus
- * we interpret MSB-LSB ordered codes to be images written w/
- * old versions of this library, but otherwise adhere to the
- * Aldus "off by one" algorithm.
- *
- * Future revisions to the TIFF spec are expected to "clarify this issue".
- */
-#define LZW_COMPAT /* include backwards compatibility code */
-
-#define MAXCODE(n) ((1L << (n)) - 1)
-/*
- * The TIFF spec specifies that encoded bit
- * strings range from 9 to 12 bits.
- */
-#define BITS_MIN 9 /* start with 9 bits */
-#define BITS_MAX 12 /* max of 12 bit strings */
-/* predefined codes */
-#define CODE_CLEAR 256 /* code to clear string table */
-#define CODE_EOI 257 /* end-of-information code */
-#define CODE_FIRST 258 /* first free code entry */
-#define CODE_MAX MAXCODE(BITS_MAX)
-#define HSIZE 9001L /* 91% occupancy */
-#define HSHIFT (13 - 8)
-#ifdef LZW_COMPAT
-/* NB: +1024 is for compatibility with old files */
-#define CSIZE (MAXCODE(BITS_MAX) + 1024L)
-#else
-#define CSIZE (MAXCODE(BITS_MAX) + 1L)
-#endif
-
-/*
- * State block for each open TIFF file using LZW
- * compression/decompression. Note that the predictor
- * state block must be first in this data structure.
- */
-typedef struct
-{
- TIFFPredictorState predict; /* predictor super class */
-
- unsigned short nbits; /* # of bits/code */
- unsigned short maxcode; /* maximum code for lzw_nbits */
- unsigned short free_ent; /* next free entry in hash table */
- WordType nextdata; /* next bits of i/o */
- long nextbits; /* # of valid bits in lzw_nextdata */
-
- int rw_mode; /* preserve rw_mode from init */
-} LZWBaseState;
-
-#define lzw_nbits base.nbits
-#define lzw_maxcode base.maxcode
-#define lzw_free_ent base.free_ent
-#define lzw_nextdata base.nextdata
-#define lzw_nextbits base.nextbits
-
-/*
- * Encoding-specific state.
- */
-typedef uint16_t hcode_t; /* codes fit in 16 bits */
-typedef struct
-{
- long hash;
- hcode_t code;
-} hash_t;
-
-/*
- * Decoding-specific state.
- */
-typedef struct code_ent
-{
- struct code_ent *next;
- unsigned short length; /* string len, including this token */
- /* firstchar should be placed immediately before value in this structure */
- unsigned char firstchar; /* first token of string */
- unsigned char value; /* data value */
- bool repeated;
-} code_t;
-
-typedef int (*decodeFunc)(TIFF *, uint8_t *, tmsize_t, uint16_t);
-
-typedef struct
-{
- LZWBaseState base;
-
- /* Decoding specific data */
- long dec_nbitsmask; /* lzw_nbits 1 bits, right adjusted */
- tmsize_t dec_restart; /* restart count */
- uint64_t dec_bitsleft; /* available bits in raw data */
- tmsize_t old_tif_rawcc; /* value of tif_rawcc at the end of the previous
- TIFLZWDecode() call */
- decodeFunc dec_decode; /* regular or backwards compatible */
- code_t *dec_codep; /* current recognized code */
- code_t *dec_oldcodep; /* previously recognized code */
- code_t *dec_free_entp; /* next free entry */
- code_t *dec_maxcodep; /* max available entry */
- code_t *dec_codetab; /* kept separate for small machines */
- int read_error; /* whether a read error has occurred, and which should cause
- further reads in the same strip/tile to be aborted */
-
- /* Encoding specific data */
- int enc_oldcode; /* last code encountered */
- tmsize_t enc_checkpoint; /* point at which to clear table */
-#define CHECK_GAP 10000 /* enc_ratio check interval */
- tmsize_t enc_ratio; /* current compression ratio */
- tmsize_t enc_incount; /* (input) data bytes encoded */
- tmsize_t enc_outcount; /* encoded (output) bytes */
- uint8_t *enc_rawlimit; /* bound on tif_rawdata buffer */
- hash_t *enc_hashtab; /* kept separate for small machines */
-} LZWCodecState;
-
-#define LZWState(tif) ((LZWBaseState *)(tif)->tif_data)
-#define LZWDecoderState(tif) ((LZWCodecState *)LZWState(tif))
-#define LZWEncoderState(tif) ((LZWCodecState *)LZWState(tif))
-
-static int LZWDecode(TIFF *tif, uint8_t *op0, tmsize_t occ0, uint16_t s);
-#ifdef LZW_COMPAT
-static int LZWDecodeCompat(TIFF *tif, uint8_t *op0, tmsize_t occ0, uint16_t s);
-#endif
-static void cl_hash(LZWCodecState *);
-
-/*
- * LZW Decoder.
- */
-
-static int LZWFixupTags(TIFF *tif)
-{
- (void)tif;
- return (1);
-}
-
-static int LZWSetupDecode(TIFF *tif)
-{
- static const char module[] = "LZWSetupDecode";
- LZWCodecState *sp = LZWDecoderState(tif);
- int code;
-
- if (sp == NULL)
- {
- /*
- * Allocate state block so tag methods have storage to record
- * values.
- */
- tif->tif_data = (uint8_t *)_TIFFmallocExt(tif, sizeof(LZWCodecState));
- if (tif->tif_data == NULL)
- {
- TIFFErrorExtR(tif, module, "No space for LZW state block");
- return (0);
- }
-
- sp = LZWDecoderState(tif);
- sp->dec_codetab = NULL;
- sp->dec_decode = NULL;
-
- /*
- * Setup predictor setup.
- */
- (void)TIFFPredictorInit(tif);
- }
-
- if (sp->dec_codetab == NULL)
- {
- sp->dec_codetab = (code_t *)_TIFFmallocExt(tif, CSIZE * sizeof(code_t));
- if (sp->dec_codetab == NULL)
- {
- TIFFErrorExtR(tif, module, "No space for LZW code table");
- return (0);
- }
- /*
- * Pre-load the table.
- */
- code = 255;
- do
- {
- sp->dec_codetab[code].firstchar = (unsigned char)code;
- sp->dec_codetab[code].value = (unsigned char)code;
- sp->dec_codetab[code].repeated = true;
- sp->dec_codetab[code].length = 1;
- sp->dec_codetab[code].next = NULL;
- } while (code--);
- /*
- * Zero-out the unused entries */
- /* Silence false positive */
- /* coverity[overrun-buffer-arg] */
- memset(&sp->dec_codetab[CODE_CLEAR], 0,
- (CODE_FIRST - CODE_CLEAR) * sizeof(code_t));
- }
- return (1);
-}
-
-/*
- * Setup state for decoding a strip.
- */
-static int LZWPreDecode(TIFF *tif, uint16_t s)
-{
- static const char module[] = "LZWPreDecode";
- LZWCodecState *sp = LZWDecoderState(tif);
-
- (void)s;
- assert(sp != NULL);
- if (sp->dec_codetab == NULL)
- {
- tif->tif_setupdecode(tif);
- if (sp->dec_codetab == NULL)
- return (0);
- }
-
- /*
- * Check for old bit-reversed codes.
- */
- if (tif->tif_rawcc >= 2 && tif->tif_rawdata[0] == 0 &&
- (tif->tif_rawdata[1] & 0x1))
- {
-#ifdef LZW_COMPAT
- if (!sp->dec_decode)
- {
- TIFFWarningExtR(tif, module, "Old-style LZW codes, convert file");
- /*
- * Override default decoding methods with
- * ones that deal with the old coding.
- * Otherwise the predictor versions set
- * above will call the compatibility routines
- * through the dec_decode method.
- */
- tif->tif_decoderow = LZWDecodeCompat;
- tif->tif_decodestrip = LZWDecodeCompat;
- tif->tif_decodetile = LZWDecodeCompat;
- /*
- * If doing horizontal differencing, must
- * re-setup the predictor logic since we
- * switched the basic decoder methods...
- */
- (*tif->tif_setupdecode)(tif);
- sp->dec_decode = LZWDecodeCompat;
- }
- sp->lzw_maxcode = MAXCODE(BITS_MIN);
-#else /* !LZW_COMPAT */
- if (!sp->dec_decode)
- {
- TIFFErrorExtR(tif, module, "Old-style LZW codes not supported");
- sp->dec_decode = LZWDecode;
- }
- return (0);
-#endif /* !LZW_COMPAT */
- }
- else
- {
- sp->lzw_maxcode = MAXCODE(BITS_MIN) - 1;
- sp->dec_decode = LZWDecode;
- }
- sp->lzw_nbits = BITS_MIN;
- sp->lzw_nextbits = 0;
- sp->lzw_nextdata = 0;
-
- sp->dec_restart = 0;
- sp->dec_nbitsmask = MAXCODE(BITS_MIN);
- sp->dec_bitsleft = 0;
- sp->old_tif_rawcc = 0;
- sp->dec_free_entp = sp->dec_codetab - 1; // + CODE_FIRST;
- /*
- * Zero entries that are not yet filled in. We do
- * this to guard against bogus input data that causes
- * us to index into undefined entries. If you can
- * come up with a way to safely bounds-check input codes
- * while decoding then you can remove this operation.
- */
- sp->dec_oldcodep = &sp->dec_codetab[0];
- sp->dec_maxcodep = &sp->dec_codetab[sp->dec_nbitsmask - 1];
- sp->read_error = 0;
- return (1);
-}
-
-/*
- * Decode a "hunk of data".
- */
-
-/* Get the next 32 or 64-bit from the input data */
-#ifdef WORDS_BIGENDIAN
-#define GetNextData(nextdata, bp) memcpy(&nextdata, bp, sizeof(nextdata))
-#elif SIZEOF_WORDTYPE == 8
-#if defined(_M_X64)
-#define GetNextData(nextdata, bp) nextdata = _byteswap_uint64(*(uint64_t *)(bp))
-#elif defined(__GNUC__)
-#define GetNextData(nextdata, bp) \
- memcpy(&nextdata, bp, sizeof(nextdata)); \
- nextdata = __builtin_bswap64(nextdata)
-#else
-#define GetNextData(nextdata, bp) \
- nextdata = (((uint64_t)bp[0]) << 56) | (((uint64_t)bp[1]) << 48) | \
- (((uint64_t)bp[2]) << 40) | (((uint64_t)bp[3]) << 32) | \
- (((uint64_t)bp[4]) << 24) | (((uint64_t)bp[5]) << 16) | \
- (((uint64_t)bp[6]) << 8) | (((uint64_t)bp[7]))
-#endif
-#elif SIZEOF_WORDTYPE == 4
-#if defined(_M_X86)
-#define GetNextData(nextdata, bp) \
- nextdata = _byteswap_ulong(*(unsigned long *)(bp))
-#elif defined(__GNUC__)
-#define GetNextData(nextdata, bp) \
- memcpy(&nextdata, bp, sizeof(nextdata)); \
- nextdata = __builtin_bswap32(nextdata)
-#else
-#define GetNextData(nextdata, bp) \
- nextdata = (((uint32_t)bp[0]) << 24) | (((uint32_t)bp[1]) << 16) | \
- (((uint32_t)bp[2]) << 8) | (((uint32_t)bp[3]))
-#endif
-#else
-#error "Unhandled SIZEOF_WORDTYPE"
-#endif
-
-#define GetNextCodeLZW() \
- do \
- { \
- nextbits -= nbits; \
- if (nextbits < 0) \
- { \
- if (dec_bitsleft >= 8 * SIZEOF_WORDTYPE) \
- { \
- unsigned codetmp = (unsigned)(nextdata << (-nextbits)); \
- GetNextData(nextdata, bp); \
- bp += SIZEOF_WORDTYPE; \
- nextbits += 8 * SIZEOF_WORDTYPE; \
- dec_bitsleft -= 8 * SIZEOF_WORDTYPE; \
- code = (WordType)((codetmp | (nextdata >> nextbits)) & \
- nbitsmask); \
- break; \
- } \
- else \
- { \
- if (dec_bitsleft < 8) \
- { \
- goto no_eoi; \
- } \
- nextdata = (nextdata << 8) | *(bp)++; \
- nextbits += 8; \
- dec_bitsleft -= 8; \
- if (nextbits < 0) \
- { \
- if (dec_bitsleft < 8) \
- { \
- goto no_eoi; \
- } \
- nextdata = (nextdata << 8) | *(bp)++; \
- nextbits += 8; \
- dec_bitsleft -= 8; \
- } \
- } \
- } \
- code = (WordType)((nextdata >> nextbits) & nbitsmask); \
- } while (0)
-
-static int LZWDecode(TIFF *tif, uint8_t *op0, tmsize_t occ0, uint16_t s)
-{
- static const char module[] = "LZWDecode";
- LZWCodecState *sp = LZWDecoderState(tif);
- uint8_t *op = (uint8_t *)op0;
- tmsize_t occ = occ0;
- uint8_t *bp;
- long nbits, nextbits, nbitsmask;
- WordType nextdata;
- code_t *free_entp, *maxcodep, *oldcodep;
-
- (void)s;
- assert(sp != NULL);
- assert(sp->dec_codetab != NULL);
-
- if (sp->read_error)
- {
- memset(op, 0, (size_t)occ);
- TIFFErrorExtR(tif, module,
- "LZWDecode: Scanline %" PRIu32 " cannot be read due to "
- "previous error",
- tif->tif_row);
- return 0;
- }
-
- /*
- * Restart interrupted output operation.
- */
- if (sp->dec_restart)
- {
- tmsize_t residue;
-
- code_t *codep = sp->dec_codep;
- residue = codep->length - sp->dec_restart;
- if (residue > occ)
- {
- /*
- * Residue from previous decode is sufficient
- * to satisfy decode request. Skip to the
- * start of the decoded string, place decoded
- * values in the output buffer, and return.
- */
- sp->dec_restart += occ;
- do
- {
- codep = codep->next;
- } while (--residue > occ && codep);
- if (codep)
- {
- uint8_t *tp = op + occ;
- do
- {
- *--tp = codep->value;
- codep = codep->next;
- } while (--occ && codep);
- }
- return (1);
- }
- /*
- * Residue satisfies only part of the decode request.
- */
- op += residue;
- occ -= residue;
- uint8_t *tp = op;
- do
- {
- *--tp = codep->value;
- codep = codep->next;
- } while (--residue && codep);
- sp->dec_restart = 0;
- }
-
- bp = (uint8_t *)tif->tif_rawcp;
- sp->dec_bitsleft += (((uint64_t)tif->tif_rawcc - sp->old_tif_rawcc) << 3);
- uint64_t dec_bitsleft = sp->dec_bitsleft;
- nbits = sp->lzw_nbits;
- nextdata = sp->lzw_nextdata;
- nextbits = sp->lzw_nextbits;
- nbitsmask = sp->dec_nbitsmask;
- oldcodep = sp->dec_oldcodep;
- free_entp = sp->dec_free_entp;
- maxcodep = sp->dec_maxcodep;
- code_t *const dec_codetab = sp->dec_codetab;
- code_t *codep;
-
- if (occ == 0)
- {
- goto after_loop;
- }
-
-begin:
-{
- WordType code;
- GetNextCodeLZW();
- codep = dec_codetab + code;
- if (code >= CODE_FIRST)
- goto code_above_or_equal_to_258;
- if (code < 256)
- goto code_below_256;
- if (code == CODE_EOI)
- goto after_loop;
- goto code_clear;
-
-code_below_256:
-{
- if (codep > free_entp)
- goto error_code;
- free_entp->next = oldcodep;
- free_entp->firstchar = oldcodep->firstchar;
- free_entp->length = oldcodep->length + 1;
- free_entp->value = (uint8_t)code;
- free_entp->repeated =
- (bool)(oldcodep->repeated & (oldcodep->value == code));
- if (++free_entp > maxcodep)
- {
- if (++nbits > BITS_MAX) /* should not happen for a conformant encoder */
- nbits = BITS_MAX;
- nbitsmask = MAXCODE(nbits);
- maxcodep = dec_codetab + nbitsmask - 1;
- if (free_entp >= &dec_codetab[CSIZE])
- {
- /* At that point, the next valid states are either EOI or a */
- /* CODE_CLEAR. If a regular code is read, at the next */
- /* attempt at registering a new entry, we will error out */
- /* due to setting free_entp before any valid code */
- free_entp = dec_codetab - 1;
- }
- }
- oldcodep = codep;
- *op++ = (uint8_t)code;
- occ--;
- if (occ == 0)
- goto after_loop;
- goto begin;
-}
-
-code_above_or_equal_to_258:
-{
- /*
- * Add the new entry to the code table.
- */
-
- if (codep >= free_entp)
- {
- if (codep != free_entp)
- goto error_code;
- free_entp->value = oldcodep->firstchar;
- }
- else
- {
- free_entp->value = codep->firstchar;
- }
- free_entp->repeated =
- (bool)(oldcodep->repeated & (oldcodep->value == free_entp->value));
- free_entp->next = oldcodep;
-
- free_entp->firstchar = oldcodep->firstchar;
- free_entp->length = oldcodep->length + 1;
- if (++free_entp > maxcodep)
- {
- if (++nbits > BITS_MAX) /* should not happen for a conformant encoder */
- nbits = BITS_MAX;
- nbitsmask = MAXCODE(nbits);
- maxcodep = dec_codetab + nbitsmask - 1;
- if (free_entp >= &dec_codetab[CSIZE])
- {
- /* At that point, the next valid states are either EOI or a */
- /* CODE_CLEAR. If a regular code is read, at the next */
- /* attempt at registering a new entry, we will error out */
- /* due to setting free_entp before any valid code */
- free_entp = dec_codetab - 1;
- }
- }
- oldcodep = codep;
-
- /*
- * Code maps to a string, copy string
- * value to output (written in reverse).
- */
- /* tiny bit faster on x86_64 to store in unsigned short than int */
- unsigned short len = codep->length;
-
- if (len < 3) /* equivalent to len == 2 given all other conditions */
- {
- if (occ <= 2)
- {
- if (occ == 2)
- {
- memcpy(op, &(codep->firstchar), 2);
- op += 2;
- occ -= 2;
- goto after_loop;
- }
- goto too_short_buffer;
- }
-
- memcpy(op, &(codep->firstchar), 2);
- op += 2;
- occ -= 2;
- goto begin; /* we can save the comparison occ > 0 */
- }
-
- if (len == 3)
- {
- if (occ <= 3)
- {
- if (occ == 3)
- {
- op[0] = codep->firstchar;
- op[1] = codep->next->value;
- op[2] = codep->value;
- op += 3;
- occ -= 3;
- goto after_loop;
- }
- goto too_short_buffer;
- }
-
- op[0] = codep->firstchar;
- op[1] = codep->next->value;
- op[2] = codep->value;
- op += 3;
- occ -= 3;
- goto begin; /* we can save the comparison occ > 0 */
- }
-
- if (len > occ)
- {
- goto too_short_buffer;
- }
-
- if (codep->repeated)
- {
- memset(op, codep->value, len);
- op += len;
- occ -= len;
- if (occ == 0)
- goto after_loop;
- goto begin;
- }
-
- uint8_t *tp = op + len;
-
- assert(len >= 4);
-
- *--tp = codep->value;
- codep = codep->next;
- *--tp = codep->value;
- codep = codep->next;
- *--tp = codep->value;
- codep = codep->next;
- *--tp = codep->value;
- if (tp > op)
- {
- do
- {
- codep = codep->next;
- *--tp = codep->value;
- } while (tp > op);
- }
-
- assert(occ >= len);
- op += len;
- occ -= len;
- if (occ == 0)
- goto after_loop;
- goto begin;
-}
-
-code_clear:
-{
- free_entp = dec_codetab + CODE_FIRST;
- nbits = BITS_MIN;
- nbitsmask = MAXCODE(BITS_MIN);
- maxcodep = dec_codetab + nbitsmask - 1;
- do
- {
- GetNextCodeLZW();
- } while (code == CODE_CLEAR); /* consecutive CODE_CLEAR codes */
- if (code == CODE_EOI)
- goto after_loop;
- if (code > CODE_EOI)
- {
- goto error_code;
- }
- *op++ = (uint8_t)code;
- occ--;
- oldcodep = dec_codetab + code;
- if (occ == 0)
- goto after_loop;
- goto begin;
-}
-}
-
-too_short_buffer:
-{
- /*
- * String is too long for decode buffer,
- * locate portion that will fit, copy to
- * the decode buffer, and setup restart
- * logic for the next decoding call.
- */
- sp->dec_codep = codep;
- do
- {
- codep = codep->next;
- } while (codep->length > occ);
-
- sp->dec_restart = occ;
- uint8_t *tp = op + occ;
- do
- {
- *--tp = codep->value;
- codep = codep->next;
- } while (--occ);
-}
-
-after_loop:
- tif->tif_rawcc -= (tmsize_t)((uint8_t *)bp - tif->tif_rawcp);
- tif->tif_rawcp = (uint8_t *)bp;
- sp->old_tif_rawcc = tif->tif_rawcc;
- sp->dec_bitsleft = dec_bitsleft;
- sp->lzw_nbits = (unsigned short)nbits;
- sp->lzw_nextdata = nextdata;
- sp->lzw_nextbits = nextbits;
- sp->dec_nbitsmask = nbitsmask;
- sp->dec_oldcodep = oldcodep;
- sp->dec_free_entp = free_entp;
- sp->dec_maxcodep = maxcodep;
-
- if (occ > 0)
- {
- memset(op, 0, (size_t)occ);
- TIFFErrorExtR(tif, module,
- "Not enough data at scanline %" PRIu32 " (short %" PRIu64
- " bytes)",
- tif->tif_row, (uint64_t)occ);
- return (0);
- }
- return (1);
-
-no_eoi:
- memset(op, 0, (size_t)occ);
- sp->read_error = 1;
- TIFFErrorExtR(tif, module,
- "LZWDecode: Strip %" PRIu32 " not terminated with EOI code",
- tif->tif_curstrip);
- return 0;
-error_code:
- memset(op, 0, (size_t)occ);
- sp->read_error = 1;
- TIFFErrorExtR(tif, tif->tif_name, "Using code not yet in table");
- return 0;
-}
-
-#ifdef LZW_COMPAT
-
-/*
- * This check shouldn't be necessary because each
- * strip is suppose to be terminated with CODE_EOI.
- */
-#define NextCode(_tif, _sp, _bp, _code, _get, dec_bitsleft) \
- { \
- if (dec_bitsleft < (uint64_t)nbits) \
- { \
- TIFFWarningExtR(_tif, module, \
- "LZWDecode: Strip %" PRIu32 \
- " not terminated with EOI code", \
- _tif->tif_curstrip); \
- _code = CODE_EOI; \
- } \
- else \
- { \
- _get(_sp, _bp, _code); \
- dec_bitsleft -= nbits; \
- } \
- }
-
-/*
- * Decode a "hunk of data" for old images.
- */
-#define GetNextCodeCompat(sp, bp, code) \
- { \
- nextdata |= (unsigned long)*(bp)++ << nextbits; \
- nextbits += 8; \
- if (nextbits < nbits) \
- { \
- nextdata |= (unsigned long)*(bp)++ << nextbits; \
- nextbits += 8; \
- } \
- code = (hcode_t)(nextdata & nbitsmask); \
- nextdata >>= nbits; \
- nextbits -= nbits; \
- }
-
-static int LZWDecodeCompat(TIFF *tif, uint8_t *op0, tmsize_t occ0, uint16_t s)
-{
- static const char module[] = "LZWDecodeCompat";
- LZWCodecState *sp = LZWDecoderState(tif);
- uint8_t *op = (uint8_t *)op0;
- tmsize_t occ = occ0;
- uint8_t *tp;
- uint8_t *bp;
- int code, nbits;
- int len;
- long nextbits, nbitsmask;
- WordType nextdata;
- code_t *codep, *free_entp, *maxcodep, *oldcodep;
-
- (void)s;
- assert(sp != NULL);
-
- /*
- * Restart interrupted output operation.
- */
- if (sp->dec_restart)
- {
- tmsize_t residue;
-
- codep = sp->dec_codep;
- residue = codep->length - sp->dec_restart;
- if (residue > occ)
- {
- /*
- * Residue from previous decode is sufficient
- * to satisfy decode request. Skip to the
- * start of the decoded string, place decoded
- * values in the output buffer, and return.
- */
- sp->dec_restart += occ;
- do
- {
- codep = codep->next;
- } while (--residue > occ);
- tp = op + occ;
- do
- {
- *--tp = codep->value;
- codep = codep->next;
- } while (--occ);
- return (1);
- }
- /*
- * Residue satisfies only part of the decode request.
- */
- op += residue;
- occ -= residue;
- tp = op;
- do
- {
- *--tp = codep->value;
- codep = codep->next;
- } while (--residue);
- sp->dec_restart = 0;
- }
-
- bp = (uint8_t *)tif->tif_rawcp;
-
- sp->dec_bitsleft += (((uint64_t)tif->tif_rawcc - sp->old_tif_rawcc) << 3);
- uint64_t dec_bitsleft = sp->dec_bitsleft;
-
- nbits = sp->lzw_nbits;
- nextdata = sp->lzw_nextdata;
- nextbits = sp->lzw_nextbits;
- nbitsmask = sp->dec_nbitsmask;
- oldcodep = sp->dec_oldcodep;
- free_entp = sp->dec_free_entp;
- maxcodep = sp->dec_maxcodep;
-
- while (occ > 0)
- {
- NextCode(tif, sp, bp, code, GetNextCodeCompat, dec_bitsleft);
- if (code == CODE_EOI)
- break;
- if (code == CODE_CLEAR)
- {
- do
- {
- free_entp = sp->dec_codetab + CODE_FIRST;
- _TIFFmemset(free_entp, 0,
- (CSIZE - CODE_FIRST) * sizeof(code_t));
- nbits = BITS_MIN;
- nbitsmask = MAXCODE(BITS_MIN);
- maxcodep = sp->dec_codetab + nbitsmask;
- NextCode(tif, sp, bp, code, GetNextCodeCompat, dec_bitsleft);
- } while (code == CODE_CLEAR); /* consecutive CODE_CLEAR codes */
- if (code == CODE_EOI)
- break;
- if (code > CODE_CLEAR)
- {
- TIFFErrorExtR(
- tif, tif->tif_name,
- "LZWDecode: Corrupted LZW table at scanline %" PRIu32,
- tif->tif_row);
- return (0);
- }
- *op++ = (uint8_t)code;
- occ--;
- oldcodep = sp->dec_codetab + code;
- continue;
- }
- codep = sp->dec_codetab + code;
-
- /*
- * Add the new entry to the code table.
- */
- if (free_entp < &sp->dec_codetab[0] ||
- free_entp >= &sp->dec_codetab[CSIZE])
- {
- TIFFErrorExtR(tif, module,
- "Corrupted LZW table at scanline %" PRIu32,
- tif->tif_row);
- return (0);
- }
-
- free_entp->next = oldcodep;
- if (free_entp->next < &sp->dec_codetab[0] ||
- free_entp->next >= &sp->dec_codetab[CSIZE])
- {
- TIFFErrorExtR(tif, module,
- "Corrupted LZW table at scanline %" PRIu32,
- tif->tif_row);
- return (0);
- }
- free_entp->firstchar = free_entp->next->firstchar;
- free_entp->length = free_entp->next->length + 1;
- free_entp->value =
- (codep < free_entp) ? codep->firstchar : free_entp->firstchar;
- if (++free_entp > maxcodep)
- {
- if (++nbits > BITS_MAX) /* should not happen */
- nbits = BITS_MAX;
- nbitsmask = MAXCODE(nbits);
- maxcodep = sp->dec_codetab + nbitsmask;
- }
- oldcodep = codep;
- if (code >= 256)
- {
- /*
- * Code maps to a string, copy string
- * value to output (written in reverse).
- */
- if (codep->length == 0)
- {
- TIFFErrorExtR(
- tif, module,
- "Wrong length of decoded "
- "string: data probably corrupted at scanline %" PRIu32,
- tif->tif_row);
- return (0);
- }
- if (codep->length > occ)
- {
- /*
- * String is too long for decode buffer,
- * locate portion that will fit, copy to
- * the decode buffer, and setup restart
- * logic for the next decoding call.
- */
- sp->dec_codep = codep;
- do
- {
- codep = codep->next;
- } while (codep->length > occ);
- sp->dec_restart = occ;
- tp = op + occ;
- do
- {
- *--tp = codep->value;
- codep = codep->next;
- } while (--occ);
- break;
- }
- len = codep->length;
- tp = op + len;
- do
- {
- *--tp = codep->value;
- codep = codep->next;
- } while (codep && tp > op);
- assert(occ >= len);
- op += len;
- occ -= len;
- }
- else
- {
- *op++ = (uint8_t)code;
- occ--;
- }
- }
-
- tif->tif_rawcc -= (tmsize_t)((uint8_t *)bp - tif->tif_rawcp);
- tif->tif_rawcp = (uint8_t *)bp;
-
- sp->old_tif_rawcc = tif->tif_rawcc;
- sp->dec_bitsleft = dec_bitsleft;
-
- sp->lzw_nbits = (unsigned short)nbits;
- sp->lzw_nextdata = nextdata;
- sp->lzw_nextbits = nextbits;
- sp->dec_nbitsmask = nbitsmask;
- sp->dec_oldcodep = oldcodep;
- sp->dec_free_entp = free_entp;
- sp->dec_maxcodep = maxcodep;
-
- if (occ > 0)
- {
- TIFFErrorExtR(tif, module,
- "Not enough data at scanline %" PRIu32 " (short %" PRIu64
- " bytes)",
- tif->tif_row, (uint64_t)occ);
- return (0);
- }
- return (1);
-}
-#endif /* LZW_COMPAT */
-
-/*
- * LZW Encoding.
- */
-
-static int LZWSetupEncode(TIFF *tif)
-{
- static const char module[] = "LZWSetupEncode";
- LZWCodecState *sp = LZWEncoderState(tif);
-
- assert(sp != NULL);
- sp->enc_hashtab = (hash_t *)_TIFFmallocExt(tif, HSIZE * sizeof(hash_t));
- if (sp->enc_hashtab == NULL)
- {
- TIFFErrorExtR(tif, module, "No space for LZW hash table");
- return (0);
- }
- return (1);
-}
-
-/*
- * Reset encoding state at the start of a strip.
- */
-static int LZWPreEncode(TIFF *tif, uint16_t s)
-{
- LZWCodecState *sp = LZWEncoderState(tif);
-
- (void)s;
- assert(sp != NULL);
-
- if (sp->enc_hashtab == NULL)
- {
- tif->tif_setupencode(tif);
- }
-
- sp->lzw_nbits = BITS_MIN;
- sp->lzw_maxcode = MAXCODE(BITS_MIN);
- sp->lzw_free_ent = CODE_FIRST;
- sp->lzw_nextbits = 0;
- sp->lzw_nextdata = 0;
- sp->enc_checkpoint = CHECK_GAP;
- sp->enc_ratio = 0;
- sp->enc_incount = 0;
- sp->enc_outcount = 0;
- /*
- * The 4 here insures there is space for 2 max-sized
- * codes in LZWEncode and LZWPostDecode.
- */
- sp->enc_rawlimit = tif->tif_rawdata + tif->tif_rawdatasize - 1 - 4;
- cl_hash(sp); /* clear hash table */
- sp->enc_oldcode = (hcode_t)-1; /* generates CODE_CLEAR in LZWEncode */
- return (1);
-}
-
-#define CALCRATIO(sp, rat) \
- { \
- if (incount > 0x007fffff) \
- { /* NB: shift will overflow */ \
- rat = outcount >> 8; \
- rat = (rat == 0 ? 0x7fffffff : incount / rat); \
- } \
- else \
- rat = (incount << 8) / outcount; \
- }
-
-/* Explicit 0xff masking to make icc -check=conversions happy */
-#define PutNextCode(op, c) \
- { \
- nextdata = (nextdata << nbits) | c; \
- nextbits += nbits; \
- *op++ = (unsigned char)((nextdata >> (nextbits - 8)) & 0xff); \
- nextbits -= 8; \
- if (nextbits >= 8) \
- { \
- *op++ = (unsigned char)((nextdata >> (nextbits - 8)) & 0xff); \
- nextbits -= 8; \
- } \
- outcount += nbits; \
- }
-
-/*
- * Encode a chunk of pixels.
- *
- * Uses an open addressing double hashing (no chaining) on the
- * prefix code/next character combination. We do a variant of
- * Knuth's algorithm D (vol. 3, sec. 6.4) along with G. Knott's
- * relatively-prime secondary probe. Here, the modular division
- * first probe is gives way to a faster exclusive-or manipulation.
- * Also do block compression with an adaptive reset, whereby the
- * code table is cleared when the compression ratio decreases,
- * but after the table fills. The variable-length output codes
- * are re-sized at this point, and a CODE_CLEAR is generated
- * for the decoder.
- */
-static int LZWEncode(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s)
-{
- register LZWCodecState *sp = LZWEncoderState(tif);
- register long fcode;
- register hash_t *hp;
- register int h, c;
- hcode_t ent;
- long disp;
- tmsize_t incount, outcount, checkpoint;
- WordType nextdata;
- long nextbits;
- int free_ent, maxcode, nbits;
- uint8_t *op;
- uint8_t *limit;
-
- (void)s;
- if (sp == NULL)
- return (0);
-
- assert(sp->enc_hashtab != NULL);
-
- /*
- * Load local state.
- */
- incount = sp->enc_incount;
- outcount = sp->enc_outcount;
- checkpoint = sp->enc_checkpoint;
- nextdata = sp->lzw_nextdata;
- nextbits = sp->lzw_nextbits;
- free_ent = sp->lzw_free_ent;
- maxcode = sp->lzw_maxcode;
- nbits = sp->lzw_nbits;
- op = tif->tif_rawcp;
- limit = sp->enc_rawlimit;
- ent = (hcode_t)sp->enc_oldcode;
-
- if (ent == (hcode_t)-1 && cc > 0)
- {
- /*
- * NB: This is safe because it can only happen
- * at the start of a strip where we know there
- * is space in the data buffer.
- */
- PutNextCode(op, CODE_CLEAR);
- ent = *bp++;
- cc--;
- incount++;
- }
- while (cc > 0)
- {
- c = *bp++;
- cc--;
- incount++;
- fcode = ((long)c << BITS_MAX) + ent;
- h = (c << HSHIFT) ^ ent; /* xor hashing */
-#ifdef _WINDOWS
- /*
- * Check hash index for an overflow.
- */
- if (h >= HSIZE)
- h -= HSIZE;
-#endif
- hp = &sp->enc_hashtab[h];
- if (hp->hash == fcode)
- {
- ent = hp->code;
- continue;
- }
- if (hp->hash >= 0)
- {
- /*
- * Primary hash failed, check secondary hash.
- */
- disp = HSIZE - h;
- if (h == 0)
- disp = 1;
- do
- {
- /*
- * Avoid pointer arithmetic because of
- * wraparound problems with segments.
- */
- if ((h -= disp) < 0)
- h += HSIZE;
- hp = &sp->enc_hashtab[h];
- if (hp->hash == fcode)
- {
- ent = hp->code;
- goto hit;
- }
- } while (hp->hash >= 0);
- }
- /*
- * New entry, emit code and add to table.
- */
- /*
- * Verify there is space in the buffer for the code
- * and any potential Clear code that might be emitted
- * below. The value of limit is setup so that there
- * are at least 4 bytes free--room for 2 codes.
- */
- if (op > limit)
- {
- tif->tif_rawcc = (tmsize_t)(op - tif->tif_rawdata);
- if (!TIFFFlushData1(tif))
- return 0;
- op = tif->tif_rawdata;
- }
- PutNextCode(op, ent);
- ent = (hcode_t)c;
- hp->code = (hcode_t)(free_ent++);
- hp->hash = fcode;
- if (free_ent == CODE_MAX - 1)
- {
- /* table is full, emit clear code and reset */
- cl_hash(sp);
- sp->enc_ratio = 0;
- incount = 0;
- outcount = 0;
- free_ent = CODE_FIRST;
- PutNextCode(op, CODE_CLEAR);
- nbits = BITS_MIN;
- maxcode = MAXCODE(BITS_MIN);
- }
- else
- {
- /*
- * If the next entry is going to be too big for
- * the code size, then increase it, if possible.
- */
- if (free_ent > maxcode)
- {
- nbits++;
- assert(nbits <= BITS_MAX);
- maxcode = (int)MAXCODE(nbits);
- }
- else if (incount >= checkpoint)
- {
- tmsize_t rat;
- /*
- * Check compression ratio and, if things seem
- * to be slipping, clear the hash table and
- * reset state. The compression ratio is a
- * 24+8-bit fractional number.
- */
- checkpoint = incount + CHECK_GAP;
- CALCRATIO(sp, rat);
- if (rat <= sp->enc_ratio)
- {
- cl_hash(sp);
- sp->enc_ratio = 0;
- incount = 0;
- outcount = 0;
- free_ent = CODE_FIRST;
- PutNextCode(op, CODE_CLEAR);
- nbits = BITS_MIN;
- maxcode = MAXCODE(BITS_MIN);
- }
- else
- sp->enc_ratio = rat;
- }
- }
- hit:;
- }
-
- /*
- * Restore global state.
- */
- sp->enc_incount = incount;
- sp->enc_outcount = outcount;
- sp->enc_checkpoint = checkpoint;
- sp->enc_oldcode = ent;
- sp->lzw_nextdata = nextdata;
- sp->lzw_nextbits = nextbits;
- sp->lzw_free_ent = (unsigned short)free_ent;
- sp->lzw_maxcode = (unsigned short)maxcode;
- sp->lzw_nbits = (unsigned short)nbits;
- tif->tif_rawcp = op;
- return (1);
-}
-
-/*
- * Finish off an encoded strip by flushing the last
- * string and tacking on an End Of Information code.
- */
-static int LZWPostEncode(TIFF *tif)
-{
- register LZWCodecState *sp = LZWEncoderState(tif);
- uint8_t *op = tif->tif_rawcp;
- long nextbits = sp->lzw_nextbits;
- WordType nextdata = sp->lzw_nextdata;
- tmsize_t outcount = sp->enc_outcount;
- int nbits = sp->lzw_nbits;
-
- if (op > sp->enc_rawlimit)
- {
- tif->tif_rawcc = (tmsize_t)(op - tif->tif_rawdata);
- if (!TIFFFlushData1(tif))
- return 0;
- op = tif->tif_rawdata;
- }
- if (sp->enc_oldcode != (hcode_t)-1)
- {
- int free_ent = sp->lzw_free_ent;
-
- PutNextCode(op, sp->enc_oldcode);
- sp->enc_oldcode = (hcode_t)-1;
- free_ent++;
-
- if (free_ent == CODE_MAX - 1)
- {
- /* table is full, emit clear code and reset */
- outcount = 0;
- PutNextCode(op, CODE_CLEAR);
- nbits = BITS_MIN;
- }
- else
- {
- /*
- * If the next entry is going to be too big for
- * the code size, then increase it, if possible.
- */
- if (free_ent > sp->lzw_maxcode)
- {
- nbits++;
- assert(nbits <= BITS_MAX);
- }
- }
- }
- PutNextCode(op, CODE_EOI);
- /* Explicit 0xff masking to make icc -check=conversions happy */
- if (nextbits > 0)
- *op++ = (unsigned char)((nextdata << (8 - nextbits)) & 0xff);
- tif->tif_rawcc = (tmsize_t)(op - tif->tif_rawdata);
- (void)outcount;
- return (1);
-}
-
-/*
- * Reset encoding hash table.
- */
-static void cl_hash(LZWCodecState *sp)
-{
- register hash_t *hp = &sp->enc_hashtab[HSIZE - 1];
- register long i = HSIZE - 8;
-
- do
- {
- i -= 8;
- hp[-7].hash = -1;
- hp[-6].hash = -1;
- hp[-5].hash = -1;
- hp[-4].hash = -1;
- hp[-3].hash = -1;
- hp[-2].hash = -1;
- hp[-1].hash = -1;
- hp[0].hash = -1;
- hp -= 8;
- } while (i >= 0);
- for (i += 8; i > 0; i--, hp--)
- hp->hash = -1;
-}
-
-static void LZWCleanup(TIFF *tif)
-{
- (void)TIFFPredictorCleanup(tif);
-
- assert(tif->tif_data != 0);
-
- if (LZWDecoderState(tif)->dec_codetab)
- _TIFFfreeExt(tif, LZWDecoderState(tif)->dec_codetab);
-
- if (LZWEncoderState(tif)->enc_hashtab)
- _TIFFfreeExt(tif, LZWEncoderState(tif)->enc_hashtab);
-
- _TIFFfreeExt(tif, tif->tif_data);
- tif->tif_data = NULL;
-
- _TIFFSetDefaultCompressionState(tif);
-}
-
-int TIFFInitLZW(TIFF *tif, int scheme)
-{
- static const char module[] = "TIFFInitLZW";
- (void)scheme;
- assert(scheme == COMPRESSION_LZW);
- /*
- * Allocate state block so tag methods have storage to record values.
- */
- tif->tif_data = (uint8_t *)_TIFFmallocExt(tif, sizeof(LZWCodecState));
- if (tif->tif_data == NULL)
- goto bad;
- LZWDecoderState(tif)->dec_codetab = NULL;
- LZWDecoderState(tif)->dec_decode = NULL;
- LZWEncoderState(tif)->enc_hashtab = NULL;
- LZWState(tif)->rw_mode = tif->tif_mode;
-
- /*
- * Install codec methods.
- */
- tif->tif_fixuptags = LZWFixupTags;
- tif->tif_setupdecode = LZWSetupDecode;
- tif->tif_predecode = LZWPreDecode;
- tif->tif_decoderow = LZWDecode;
- tif->tif_decodestrip = LZWDecode;
- tif->tif_decodetile = LZWDecode;
- tif->tif_setupencode = LZWSetupEncode;
- tif->tif_preencode = LZWPreEncode;
- tif->tif_postencode = LZWPostEncode;
- tif->tif_encoderow = LZWEncode;
- tif->tif_encodestrip = LZWEncode;
- tif->tif_encodetile = LZWEncode;
- tif->tif_cleanup = LZWCleanup;
- /*
- * Setup predictor setup.
- */
- (void)TIFFPredictorInit(tif);
- return (1);
-bad:
- TIFFErrorExtR(tif, module, "No space for LZW state block");
- return (0);
-}
-
-/*
- * Copyright (c) 1985, 1986 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * James A. Woods, derived from original work by Spencer Thomas
- * and Joseph Orost.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-#endif /* LZW_SUPPORT */
diff --git a/contrib/libs/libtiff/tif_next.c b/contrib/libs/libtiff/tif_next.c
deleted file mode 100644
index f000574ee7..0000000000
--- a/contrib/libs/libtiff/tif_next.c
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * Copyright (c) 1988-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-#include "tiffiop.h"
-#ifdef NEXT_SUPPORT
-/*
- * TIFF Library.
- *
- * NeXT 2-bit Grey Scale Compression Algorithm Support
- */
-
-#define SETPIXEL(op, v) \
- { \
- switch (npixels++ & 3) \
- { \
- case 0: \
- op[0] = (unsigned char)((v) << 6); \
- break; \
- case 1: \
- op[0] |= (v) << 4; \
- break; \
- case 2: \
- op[0] |= (v) << 2; \
- break; \
- case 3: \
- *op++ |= (v); \
- op_offset++; \
- break; \
- } \
- }
-
-#define LITERALROW 0x00
-#define LITERALSPAN 0x40
-#define WHITE ((1 << 2) - 1)
-
-static int NeXTDecode(TIFF *tif, uint8_t *buf, tmsize_t occ, uint16_t s)
-{
- static const char module[] = "NeXTDecode";
- unsigned char *bp, *op;
- tmsize_t cc;
- uint8_t *row;
- tmsize_t scanline, n;
-
- (void)s;
- /*
- * Each scanline is assumed to start off as all
- * white (we assume a PhotometricInterpretation
- * of ``min-is-black'').
- */
- for (op = (unsigned char *)buf, cc = occ; cc-- > 0;)
- *op++ = 0xff;
-
- bp = (unsigned char *)tif->tif_rawcp;
- cc = tif->tif_rawcc;
- scanline = tif->tif_scanlinesize;
- if (occ % scanline)
- {
- TIFFErrorExtR(tif, module, "Fractional scanlines cannot be read");
- return (0);
- }
- for (row = buf; cc > 0 && occ > 0; occ -= scanline, row += scanline)
- {
- n = *bp++;
- cc--;
- switch (n)
- {
- case LITERALROW:
- /*
- * The entire scanline is given as literal values.
- */
- if (cc < scanline)
- goto bad;
- _TIFFmemcpy(row, bp, scanline);
- bp += scanline;
- cc -= scanline;
- break;
- case LITERALSPAN:
- {
- tmsize_t off;
- /*
- * The scanline has a literal span that begins at some
- * offset.
- */
- if (cc < 4)
- goto bad;
- off = (bp[0] * 256) + bp[1];
- n = (bp[2] * 256) + bp[3];
- if (cc < 4 + n || off + n > scanline)
- goto bad;
- _TIFFmemcpy(row + off, bp + 4, n);
- bp += 4 + n;
- cc -= 4 + n;
- break;
- }
- default:
- {
- uint32_t npixels = 0, grey;
- tmsize_t op_offset = 0;
- uint32_t imagewidth = tif->tif_dir.td_imagewidth;
- if (isTiled(tif))
- imagewidth = tif->tif_dir.td_tilewidth;
-
- /*
- * The scanline is composed of a sequence of constant
- * color ``runs''. We shift into ``run mode'' and
- * interpret bytes as codes of the form
- * <color><npixels> until we've filled the scanline.
- */
- op = row;
- for (;;)
- {
- grey = (uint32_t)((n >> 6) & 0x3);
- n &= 0x3f;
- /*
- * Ensure the run does not exceed the scanline
- * bounds, potentially resulting in a security
- * issue.
- */
- while (n-- > 0 && npixels < imagewidth &&
- op_offset < scanline)
- SETPIXEL(op, grey);
- if (npixels >= imagewidth)
- break;
- if (op_offset >= scanline)
- {
- TIFFErrorExtR(tif, module,
- "Invalid data for scanline %" PRIu32,
- tif->tif_row);
- return (0);
- }
- if (cc == 0)
- goto bad;
- n = *bp++;
- cc--;
- }
- break;
- }
- }
- }
- tif->tif_rawcp = (uint8_t *)bp;
- tif->tif_rawcc = cc;
- return (1);
-bad:
- TIFFErrorExtR(tif, module, "Not enough data for scanline %" PRIu32,
- tif->tif_row);
- return (0);
-}
-
-static int NeXTPreDecode(TIFF *tif, uint16_t s)
-{
- static const char module[] = "NeXTPreDecode";
- TIFFDirectory *td = &tif->tif_dir;
- (void)s;
-
- if (td->td_bitspersample != 2)
- {
- TIFFErrorExtR(tif, module, "Unsupported BitsPerSample = %" PRIu16,
- td->td_bitspersample);
- return (0);
- }
- return (1);
-}
-
-int TIFFInitNeXT(TIFF *tif, int scheme)
-{
- (void)scheme;
- tif->tif_predecode = NeXTPreDecode;
- tif->tif_decoderow = NeXTDecode;
- tif->tif_decodestrip = NeXTDecode;
- tif->tif_decodetile = NeXTDecode;
- return (1);
-}
-#endif /* NEXT_SUPPORT */
diff --git a/contrib/libs/libtiff/tif_ojpeg.c b/contrib/libs/libtiff/tif_ojpeg.c
deleted file mode 100644
index f94d2a4e45..0000000000
--- a/contrib/libs/libtiff/tif_ojpeg.c
+++ /dev/null
@@ -1,2811 +0,0 @@
-/* WARNING: The type of JPEG encapsulation defined by the TIFF Version 6.0
- specification is now totally obsolete and deprecated for new applications and
- images. This file was was created solely in order to read unconverted images
- still present on some users' computer systems. It will never be extended
- to write such files. Writing new-style JPEG compressed TIFFs is implemented
- in tif_jpeg.c.
-
- The code is carefully crafted to robustly read all gathered JPEG-in-TIFF
- testfiles, and anticipate as much as possible all other... But still, it may
- fail on some. If you encounter problems, please report them on the TIFF
- mailing list and/or to Joris Van Damme <info@awaresystems.be>.
-
- Please read the file called "TIFF Technical Note #2" if you need to be
- convinced this compression scheme is bad and breaks TIFF. That document
- is linked to from the LibTiff site <http://www.remotesensing.org/libtiff/>
- and from AWare Systems' TIFF section
- <http://www.awaresystems.be/imaging/tiff.html>. It is also absorbed
- in Adobe's specification supplements, marked "draft" up to this day, but
- supported by the TIFF community.
-
- This file interfaces with Release 6B of the JPEG Library written by the
- Independent JPEG Group. Previous versions of this file required a hack inside
- the LibJpeg library. This version no longer requires that. Remember to
- remove the hack if you update from the old version.
-
- Copyright (c) Joris Van Damme <info@awaresystems.be>
- Copyright (c) AWare Systems <http://www.awaresystems.be/>
-
- The licence agreement for this file is the same as the rest of the LibTiff
- library.
-
- IN NO EVENT SHALL JORIS VAN DAMME OR AWARE SYSTEMS BE LIABLE FOR
- ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- OF THIS SOFTWARE.
-
- Joris Van Damme and/or AWare Systems may be available for custom
- development. If you like what you see, and need anything similar or related,
- contact <info@awaresystems.be>.
-*/
-
-/* What is what, and what is not?
-
- This decoder starts with an input stream, that is essentially the
- JpegInterchangeFormat stream, if any, followed by the strile data, if any.
- This stream is read in OJPEGReadByte and related functions.
-
- It analyzes the start of this stream, until it encounters non-marker data,
- i.e. compressed image data. Some of the header markers it sees have no actual
- content, like the SOI marker, and APP/COM markers that really shouldn't even
- be there. Some other markers do have content, and the valuable bits and
- pieces of information in these markers are saved, checking all to verify that
- the stream is more or less within expected bounds. This happens inside the
- OJPEGReadHeaderInfoSecStreamXxx functions.
-
- Some OJPEG imagery contains no valid JPEG header markers. This situation is
- picked up on if we've seen no SOF marker when we're at the start of the
- compressed image data. In this case, the tables are read from JpegXxxTables
- tags, and the other bits and pieces of information is initialized to its most
- basic value. This is implemented in the OJPEGReadHeaderInfoSecTablesXxx
- functions.
-
- When this is complete, a good and valid JPEG header can be assembled, and
- this is passed through to LibJpeg. When that's done, the remainder of the
- input stream, i.e. the compressed image data, can be passed through
- unchanged. This is done in OJPEGWriteStream functions.
-
- LibTiff rightly expects to know the subsampling values before decompression.
- Just like in new-style JPEG-in-TIFF, though, or even more so, actually, the
- YCbCrsubsampling tag is notoriously unreliable. To correct these tag values
- with the ones inside the JPEG stream, the first part of the input stream is
- pre-scanned in OJPEGSubsamplingCorrect, making no note of any other data,
- reporting no warnings or errors, up to the point where either these values
- are read, or it's clear they aren't there. This means that some of the data
- is read twice, but we feel speed in correcting these values is important
- enough to warrant this sacrifice. Although there is currently no define or
- other configuration mechanism to disable this behavior, the actual header
- scanning is build to robustly respond with error report if it should
- encounter an uncorrected mismatch of subsampling values. See
- OJPEGReadHeaderInfoSecStreamSof.
-
- The restart interval and restart markers are the most tricky part... The
- restart interval can be specified in a tag. It can also be set inside the
- input JPEG stream. It can be used inside the input JPEG stream. If reading
- from strile data, we've consistently discovered the need to insert restart
- markers in between the different striles, as is also probably the most likely
- interpretation of the original TIFF 6.0 specification. With all this setting
- of interval, and actual use of markers that is not predictable at the time of
- valid JPEG header assembly, the restart thing may turn out the Achilles heel
- of this implementation. Fortunately, most OJPEG writer vendors succeed in
- reading back what they write, which may be the reason why we've been able to
- discover ways that seem to work.
-
- Some special provision is made for planarconfig separate OJPEG files. These
- seem to consistently contain header info, a SOS marker, a plane, SOS marker,
- plane, SOS, and plane. This may or may not be a valid JPEG configuration, we
- don't know and don't care. We want LibTiff to be able to access the planes
- individually, without huge buffering inside LibJpeg, anyway. So we compose
- headers to feed to LibJpeg, in this case, that allow us to pass a single
- plane such that LibJpeg sees a valid single-channel JPEG stream. Locating
- subsequent SOS markers, and thus subsequent planes, is done inside
- OJPEGReadSecondarySos.
-
- The benefit of the scheme is... that it works, basically. We know of no other
- that does. It works without checking software tag, or otherwise going about
- things in an OJPEG flavor specific manner. Instead, it is a single scheme,
- that covers the cases with and without JpegInterchangeFormat, with and
- without striles, with part of the header in JpegInterchangeFormat and
- remainder in first strile, etc. It is forgiving and robust, may likely work
- with OJPEG flavors we've not seen yet, and makes most out of the data.
-
- Another nice side-effect is that a complete JPEG single valid stream is build
- if planarconfig is not separate (vast majority). We may one day use that to
- build converters to JPEG, and/or to new-style JPEG compression inside TIFF.
-
- A disadvantage is the lack of random access to the individual striles. This
- is the reason for much of the complicated restart-and-position stuff inside
- OJPEGPreDecode. Applications would do well accessing all striles in order, as
- this will result in a single sequential scan of the input stream, and no
- restarting of LibJpeg decoding session.
-*/
-
-#define WIN32_LEAN_AND_MEAN
-#define VC_EXTRALEAN
-
-#include "tiffiop.h"
-#ifdef OJPEG_SUPPORT
-
-/* Configuration defines here are:
- * JPEG_ENCAP_EXTERNAL: The normal way to call libjpeg, uses longjump. In some
- * environments, like eg LibTiffDelphi, this is not possible. For this reason,
- * the actual calls to libjpeg, with longjump stuff, are encapsulated in
- * dedicated functions. When JPEG_ENCAP_EXTERNAL is defined, these encapsulating
- * functions are declared external to this unit, and can be defined elsewhere to
- * use stuff other then longjump. The default mode, without JPEG_ENCAP_EXTERNAL,
- * implements the call encapsulators here, internally, with normal longjump.
- * SETJMP, LONGJMP, JMP_BUF: On some machines/environments a longjump equivalent
- * is conveniently available, but still it may be worthwhile to use _setjmp or
- * sigsetjmp in place of plain setjmp. These macros will make it easier. It is
- * useless to fiddle with these if you define JPEG_ENCAP_EXTERNAL. OJPEG_BUFFER:
- * Define the size of the desired buffer here. Should be small enough so as to
- * guarantee instant processing, optimal streaming and optimal use of processor
- * cache, but also big enough so as to not result in significant call overhead.
- * It should be at least a few bytes to accommodate some structures (this is
- * verified in asserts), but it would not be sensible to make it this small
- * anyway, and it should be at most 64K since it is indexed with uint16_t. We
- * recommend 2K. EGYPTIANWALK: You could also define EGYPTIANWALK here, but it
- * is not used anywhere and has absolutely no effect. That is why most people
- * insist the EGYPTIANWALK is a bit silly.
- */
-
-/* define LIBJPEG_ENCAP_EXTERNAL */
-#define SETJMP(jbuf) setjmp(jbuf)
-#define LONGJMP(jbuf, code) longjmp(jbuf, code)
-#define JMP_BUF jmp_buf
-#define OJPEG_BUFFER 2048
-/* define EGYPTIANWALK */
-
-#define JPEG_MARKER_SOF0 0xC0
-#define JPEG_MARKER_SOF1 0xC1
-#define JPEG_MARKER_SOF3 0xC3
-#define JPEG_MARKER_DHT 0xC4
-#define JPEG_MARKER_RST0 0XD0
-#define JPEG_MARKER_SOI 0xD8
-#define JPEG_MARKER_EOI 0xD9
-#define JPEG_MARKER_SOS 0xDA
-#define JPEG_MARKER_DQT 0xDB
-#define JPEG_MARKER_DRI 0xDD
-#define JPEG_MARKER_APP0 0xE0
-#define JPEG_MARKER_COM 0xFE
-
-#define FIELD_OJPEG_JPEGINTERCHANGEFORMAT (FIELD_CODEC + 0)
-#define FIELD_OJPEG_JPEGINTERCHANGEFORMATLENGTH (FIELD_CODEC + 1)
-#define FIELD_OJPEG_JPEGQTABLES (FIELD_CODEC + 2)
-#define FIELD_OJPEG_JPEGDCTABLES (FIELD_CODEC + 3)
-#define FIELD_OJPEG_JPEGACTABLES (FIELD_CODEC + 4)
-#define FIELD_OJPEG_JPEGPROC (FIELD_CODEC + 5)
-#define FIELD_OJPEG_JPEGRESTARTINTERVAL (FIELD_CODEC + 6)
-
-static const TIFFField ojpegFields[] = {
- {TIFFTAG_JPEGIFOFFSET, 1, 1, TIFF_LONG8, 0, TIFF_SETGET_UINT64,
- TIFF_SETGET_UNDEFINED, FIELD_OJPEG_JPEGINTERCHANGEFORMAT, TRUE, FALSE,
- "JpegInterchangeFormat", NULL},
- {TIFFTAG_JPEGIFBYTECOUNT, 1, 1, TIFF_LONG8, 0, TIFF_SETGET_UINT64,
- TIFF_SETGET_UNDEFINED, FIELD_OJPEG_JPEGINTERCHANGEFORMATLENGTH, TRUE,
- FALSE, "JpegInterchangeFormatLength", NULL},
- {TIFFTAG_JPEGQTABLES, TIFF_VARIABLE2, TIFF_VARIABLE2, TIFF_LONG8, 0,
- TIFF_SETGET_C32_UINT64, TIFF_SETGET_UNDEFINED, FIELD_OJPEG_JPEGQTABLES,
- FALSE, TRUE, "JpegQTables", NULL},
- {TIFFTAG_JPEGDCTABLES, TIFF_VARIABLE2, TIFF_VARIABLE2, TIFF_LONG8, 0,
- TIFF_SETGET_C32_UINT64, TIFF_SETGET_UNDEFINED, FIELD_OJPEG_JPEGDCTABLES,
- FALSE, TRUE, "JpegDcTables", NULL},
- {TIFFTAG_JPEGACTABLES, TIFF_VARIABLE2, TIFF_VARIABLE2, TIFF_LONG8, 0,
- TIFF_SETGET_C32_UINT64, TIFF_SETGET_UNDEFINED, FIELD_OJPEG_JPEGACTABLES,
- FALSE, TRUE, "JpegAcTables", NULL},
- {TIFFTAG_JPEGPROC, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16,
- TIFF_SETGET_UNDEFINED, FIELD_OJPEG_JPEGPROC, FALSE, FALSE, "JpegProc",
- NULL},
- {TIFFTAG_JPEGRESTARTINTERVAL, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16,
- TIFF_SETGET_UNDEFINED, FIELD_OJPEG_JPEGRESTARTINTERVAL, FALSE, FALSE,
- "JpegRestartInterval", NULL},
-};
-
-#ifndef LIBJPEG_ENCAP_EXTERNAL
-#include <setjmp.h>
-#endif
-
-#include "jerror.h"
-#include "jpeglib.h"
-
-#ifndef TIFF_jpeg_source_mgr_defined
-#define TIFF_jpeg_source_mgr_defined
-typedef struct jpeg_source_mgr jpeg_source_mgr;
-#endif
-
-#ifndef TIFF_jpeg_error_mgr_defined
-#define TIFF_jpeg_error_mgr_defined
-typedef struct jpeg_error_mgr jpeg_error_mgr;
-#endif
-
-typedef struct jpeg_common_struct jpeg_common_struct;
-typedef struct jpeg_decompress_struct jpeg_decompress_struct;
-
-typedef enum
-{
- osibsNotSetYet,
- osibsJpegInterchangeFormat,
- osibsStrile,
- osibsEof
-} OJPEGStateInBufferSource;
-
-typedef enum
-{
- ososSoi,
- ososQTable0,
- ososQTable1,
- ososQTable2,
- ososQTable3,
- ososDcTable0,
- ososDcTable1,
- ososDcTable2,
- ososDcTable3,
- ososAcTable0,
- ososAcTable1,
- ososAcTable2,
- ososAcTable3,
- ososDri,
- ososSof,
- ososSos,
- ososCompressed,
- ososRst,
- ososEoi
-} OJPEGStateOutState;
-
-typedef struct
-{
- TIFF *tif;
- int decoder_ok;
- int error_in_raw_data_decoding;
-#ifndef LIBJPEG_ENCAP_EXTERNAL
- JMP_BUF exit_jmpbuf;
-#endif
- TIFFVGetMethod vgetparent;
- TIFFVSetMethod vsetparent;
- TIFFPrintMethod printdir;
- uint64_t file_size;
- uint32_t image_width;
- uint32_t image_length;
- uint32_t strile_width;
- uint32_t strile_length;
- uint32_t strile_length_total;
- uint8_t samples_per_pixel;
- uint8_t plane_sample_offset;
- uint8_t samples_per_pixel_per_plane;
- uint64_t jpeg_interchange_format;
- uint64_t jpeg_interchange_format_length;
- uint8_t jpeg_proc;
- uint8_t subsamplingcorrect;
- uint8_t subsamplingcorrect_done;
- uint8_t subsampling_tag;
- uint8_t subsampling_hor;
- uint8_t subsampling_ver;
- uint8_t subsampling_force_desubsampling_inside_decompression;
- uint8_t qtable_offset_count;
- uint8_t dctable_offset_count;
- uint8_t actable_offset_count;
- uint64_t qtable_offset[3];
- uint64_t dctable_offset[3];
- uint64_t actable_offset[3];
- uint8_t *qtable[4];
- uint8_t *dctable[4];
- uint8_t *actable[4];
- uint16_t restart_interval;
- uint8_t restart_index;
- uint8_t sof_log;
- uint8_t sof_marker_id;
- uint32_t sof_x;
- uint32_t sof_y;
- uint8_t sof_c[3];
- uint8_t sof_hv[3];
- uint8_t sof_tq[3];
- uint8_t sos_cs[3];
- uint8_t sos_tda[3];
- struct
- {
- uint8_t log;
- OJPEGStateInBufferSource in_buffer_source;
- uint32_t in_buffer_next_strile;
- uint64_t in_buffer_file_pos;
- uint64_t in_buffer_file_togo;
- } sos_end[3];
- uint8_t readheader_done;
- uint8_t writeheader_done;
- uint16_t write_cursample;
- uint32_t write_curstrile;
- uint8_t libjpeg_session_active;
- uint8_t libjpeg_jpeg_query_style;
- jpeg_error_mgr libjpeg_jpeg_error_mgr;
- jpeg_decompress_struct libjpeg_jpeg_decompress_struct;
- jpeg_source_mgr libjpeg_jpeg_source_mgr;
- uint8_t subsampling_convert_log;
- uint32_t subsampling_convert_ylinelen;
- uint32_t subsampling_convert_ylines;
- uint32_t subsampling_convert_clinelen;
- uint32_t subsampling_convert_clines;
- uint32_t subsampling_convert_ybuflen;
- uint32_t subsampling_convert_cbuflen;
- uint32_t subsampling_convert_ycbcrbuflen;
- uint8_t *subsampling_convert_ycbcrbuf;
- uint8_t *subsampling_convert_ybuf;
- uint8_t *subsampling_convert_cbbuf;
- uint8_t *subsampling_convert_crbuf;
- uint32_t subsampling_convert_ycbcrimagelen;
- uint8_t **subsampling_convert_ycbcrimage;
- uint32_t subsampling_convert_clinelenout;
- uint32_t subsampling_convert_state;
- uint32_t bytes_per_line; /* if the codec outputs subsampled data, a 'line'
- in bytes_per_line */
- uint32_t lines_per_strile; /* and lines_per_strile means subsampling_ver
- desubsampled rows */
- OJPEGStateInBufferSource in_buffer_source;
- uint32_t in_buffer_next_strile;
- uint32_t in_buffer_strile_count;
- uint64_t in_buffer_file_pos;
- uint8_t in_buffer_file_pos_log;
- uint64_t in_buffer_file_togo;
- uint16_t in_buffer_togo;
- uint8_t *in_buffer_cur;
- uint8_t in_buffer[OJPEG_BUFFER];
- OJPEGStateOutState out_state;
- uint8_t out_buffer[OJPEG_BUFFER];
- uint8_t *skip_buffer;
-} OJPEGState;
-
-static int OJPEGVGetField(TIFF *tif, uint32_t tag, va_list ap);
-static int OJPEGVSetField(TIFF *tif, uint32_t tag, va_list ap);
-static void OJPEGPrintDir(TIFF *tif, FILE *fd, long flags);
-
-static int OJPEGFixupTags(TIFF *tif);
-static int OJPEGSetupDecode(TIFF *tif);
-static int OJPEGPreDecode(TIFF *tif, uint16_t s);
-static int OJPEGPreDecodeSkipRaw(TIFF *tif);
-static int OJPEGPreDecodeSkipScanlines(TIFF *tif);
-static int OJPEGDecode(TIFF *tif, uint8_t *buf, tmsize_t cc, uint16_t s);
-static int OJPEGDecodeRaw(TIFF *tif, uint8_t *buf, tmsize_t cc);
-static int OJPEGDecodeScanlines(TIFF *tif, uint8_t *buf, tmsize_t cc);
-static void OJPEGPostDecode(TIFF *tif, uint8_t *buf, tmsize_t cc);
-static int OJPEGSetupEncode(TIFF *tif);
-static int OJPEGPreEncode(TIFF *tif, uint16_t s);
-static int OJPEGEncode(TIFF *tif, uint8_t *buf, tmsize_t cc, uint16_t s);
-static int OJPEGPostEncode(TIFF *tif);
-static void OJPEGCleanup(TIFF *tif);
-
-static void OJPEGSubsamplingCorrect(TIFF *tif);
-static int OJPEGReadHeaderInfo(TIFF *tif);
-static int OJPEGReadSecondarySos(TIFF *tif, uint16_t s);
-static int OJPEGWriteHeaderInfo(TIFF *tif);
-static void OJPEGLibjpegSessionAbort(TIFF *tif);
-
-static int OJPEGReadHeaderInfoSec(TIFF *tif);
-static int OJPEGReadHeaderInfoSecStreamDri(TIFF *tif);
-static int OJPEGReadHeaderInfoSecStreamDqt(TIFF *tif);
-static int OJPEGReadHeaderInfoSecStreamDht(TIFF *tif);
-static int OJPEGReadHeaderInfoSecStreamSof(TIFF *tif, uint8_t marker_id);
-static int OJPEGReadHeaderInfoSecStreamSos(TIFF *tif);
-static int OJPEGReadHeaderInfoSecTablesQTable(TIFF *tif);
-static int OJPEGReadHeaderInfoSecTablesDcTable(TIFF *tif);
-static int OJPEGReadHeaderInfoSecTablesAcTable(TIFF *tif);
-
-static int OJPEGReadBufferFill(OJPEGState *sp);
-static int OJPEGReadByte(OJPEGState *sp, uint8_t *byte);
-static int OJPEGReadBytePeek(OJPEGState *sp, uint8_t *byte);
-static void OJPEGReadByteAdvance(OJPEGState *sp);
-static int OJPEGReadWord(OJPEGState *sp, uint16_t *word);
-static int OJPEGReadBlock(OJPEGState *sp, uint16_t len, void *mem);
-static void OJPEGReadSkip(OJPEGState *sp, uint16_t len);
-
-static int OJPEGWriteStream(TIFF *tif, void **mem, uint32_t *len);
-static void OJPEGWriteStreamSoi(TIFF *tif, void **mem, uint32_t *len);
-static void OJPEGWriteStreamQTable(TIFF *tif, uint8_t table_index, void **mem,
- uint32_t *len);
-static void OJPEGWriteStreamDcTable(TIFF *tif, uint8_t table_index, void **mem,
- uint32_t *len);
-static void OJPEGWriteStreamAcTable(TIFF *tif, uint8_t table_index, void **mem,
- uint32_t *len);
-static void OJPEGWriteStreamDri(TIFF *tif, void **mem, uint32_t *len);
-static void OJPEGWriteStreamSof(TIFF *tif, void **mem, uint32_t *len);
-static void OJPEGWriteStreamSos(TIFF *tif, void **mem, uint32_t *len);
-static int OJPEGWriteStreamCompressed(TIFF *tif, void **mem, uint32_t *len);
-static void OJPEGWriteStreamRst(TIFF *tif, void **mem, uint32_t *len);
-static void OJPEGWriteStreamEoi(TIFF *tif, void **mem, uint32_t *len);
-
-#ifdef LIBJPEG_ENCAP_EXTERNAL
-extern int jpeg_create_decompress_encap(OJPEGState *sp,
- jpeg_decompress_struct *cinfo);
-extern int jpeg_read_header_encap(OJPEGState *sp, jpeg_decompress_struct *cinfo,
- uint8_t require_image);
-extern int jpeg_start_decompress_encap(OJPEGState *sp,
- jpeg_decompress_struct *cinfo);
-extern int jpeg_read_scanlines_encap(OJPEGState *sp,
- jpeg_decompress_struct *cinfo,
- void *scanlines, uint32_t max_lines);
-extern int jpeg_read_raw_data_encap(OJPEGState *sp,
- jpeg_decompress_struct *cinfo, void *data,
- uint32_t max_lines);
-extern void jpeg_encap_unwind(TIFF *tif);
-#else
-static int jpeg_create_decompress_encap(OJPEGState *sp,
- jpeg_decompress_struct *j);
-static int jpeg_read_header_encap(OJPEGState *sp, jpeg_decompress_struct *cinfo,
- uint8_t require_image);
-static int jpeg_start_decompress_encap(OJPEGState *sp,
- jpeg_decompress_struct *cinfo);
-static int jpeg_read_scanlines_encap(OJPEGState *sp,
- jpeg_decompress_struct *cinfo,
- void *scanlines, uint32_t max_lines);
-static int jpeg_read_raw_data_encap(OJPEGState *sp,
- jpeg_decompress_struct *cinfo, void *data,
- uint32_t max_lines);
-static void jpeg_encap_unwind(TIFF *tif);
-#endif
-
-static void OJPEGLibjpegJpegErrorMgrOutputMessage(jpeg_common_struct *cinfo);
-static void OJPEGLibjpegJpegErrorMgrErrorExit(jpeg_common_struct *cinfo);
-static void OJPEGLibjpegJpegSourceMgrInitSource(jpeg_decompress_struct *cinfo);
-static boolean
-OJPEGLibjpegJpegSourceMgrFillInputBuffer(jpeg_decompress_struct *cinfo);
-static void
-OJPEGLibjpegJpegSourceMgrSkipInputData(jpeg_decompress_struct *cinfo,
- long num_bytes);
-static boolean
-OJPEGLibjpegJpegSourceMgrResyncToRestart(jpeg_decompress_struct *cinfo,
- int desired);
-static void OJPEGLibjpegJpegSourceMgrTermSource(jpeg_decompress_struct *cinfo);
-
-int TIFFInitOJPEG(TIFF *tif, int scheme)
-{
- static const char module[] = "TIFFInitOJPEG";
- OJPEGState *sp;
-
- (void)scheme;
- assert(scheme == COMPRESSION_OJPEG);
-
- /*
- * Merge codec-specific tag information.
- */
- if (!_TIFFMergeFields(tif, ojpegFields, TIFFArrayCount(ojpegFields)))
- {
- TIFFErrorExtR(tif, module,
- "Merging Old JPEG codec-specific tags failed");
- return 0;
- }
-
- /* state block */
- sp = _TIFFmallocExt(tif, sizeof(OJPEGState));
- if (sp == NULL)
- {
- TIFFErrorExtR(tif, module, "No space for OJPEG state block");
- return (0);
- }
- _TIFFmemset(sp, 0, sizeof(OJPEGState));
- sp->tif = tif;
- sp->jpeg_proc = 1;
- sp->subsampling_hor = 2;
- sp->subsampling_ver = 2;
- TIFFSetField(tif, TIFFTAG_YCBCRSUBSAMPLING, 2, 2);
- /* tif codec methods */
- tif->tif_fixuptags = OJPEGFixupTags;
- tif->tif_setupdecode = OJPEGSetupDecode;
- tif->tif_predecode = OJPEGPreDecode;
- tif->tif_postdecode = OJPEGPostDecode;
- tif->tif_decoderow = OJPEGDecode;
- tif->tif_decodestrip = OJPEGDecode;
- tif->tif_decodetile = OJPEGDecode;
- tif->tif_setupencode = OJPEGSetupEncode;
- tif->tif_preencode = OJPEGPreEncode;
- tif->tif_postencode = OJPEGPostEncode;
- tif->tif_encoderow = OJPEGEncode;
- tif->tif_encodestrip = OJPEGEncode;
- tif->tif_encodetile = OJPEGEncode;
- tif->tif_cleanup = OJPEGCleanup;
- tif->tif_data = (uint8_t *)sp;
- /* tif tag methods */
- sp->vgetparent = tif->tif_tagmethods.vgetfield;
- tif->tif_tagmethods.vgetfield = OJPEGVGetField;
- sp->vsetparent = tif->tif_tagmethods.vsetfield;
- tif->tif_tagmethods.vsetfield = OJPEGVSetField;
- sp->printdir = tif->tif_tagmethods.printdir;
- tif->tif_tagmethods.printdir = OJPEGPrintDir;
- /* Some OJPEG files don't have strip or tile offsets or bytecounts tags.
- Some others do, but have totally meaningless or corrupt values
- in these tags. In these cases, the JpegInterchangeFormat stream is
- reliable. In any case, this decoder reads the compressed data itself,
- from the most reliable locations, and we need to notify encapsulating
- LibTiff not to read raw strips or tiles for us. */
- tif->tif_flags |= TIFF_NOREADRAW;
- return (1);
-}
-
-static int OJPEGVGetField(TIFF *tif, uint32_t tag, va_list ap)
-{
- OJPEGState *sp = (OJPEGState *)tif->tif_data;
- switch (tag)
- {
- case TIFFTAG_JPEGIFOFFSET:
- *va_arg(ap, uint64_t *) = (uint64_t)sp->jpeg_interchange_format;
- break;
- case TIFFTAG_JPEGIFBYTECOUNT:
- *va_arg(ap, uint64_t *) =
- (uint64_t)sp->jpeg_interchange_format_length;
- break;
- case TIFFTAG_YCBCRSUBSAMPLING:
- if (sp->subsamplingcorrect_done == 0)
- OJPEGSubsamplingCorrect(tif);
- *va_arg(ap, uint16_t *) = (uint16_t)sp->subsampling_hor;
- *va_arg(ap, uint16_t *) = (uint16_t)sp->subsampling_ver;
- break;
- case TIFFTAG_JPEGQTABLES:
- *va_arg(ap, uint32_t *) = (uint32_t)sp->qtable_offset_count;
- *va_arg(ap, const void **) = (const void *)sp->qtable_offset;
- break;
- case TIFFTAG_JPEGDCTABLES:
- *va_arg(ap, uint32_t *) = (uint32_t)sp->dctable_offset_count;
- *va_arg(ap, const void **) = (const void *)sp->dctable_offset;
- break;
- case TIFFTAG_JPEGACTABLES:
- *va_arg(ap, uint32_t *) = (uint32_t)sp->actable_offset_count;
- *va_arg(ap, const void **) = (const void *)sp->actable_offset;
- break;
- case TIFFTAG_JPEGPROC:
- *va_arg(ap, uint16_t *) = (uint16_t)sp->jpeg_proc;
- break;
- case TIFFTAG_JPEGRESTARTINTERVAL:
- *va_arg(ap, uint16_t *) = sp->restart_interval;
- break;
- default:
- return (*sp->vgetparent)(tif, tag, ap);
- }
- return (1);
-}
-
-static int OJPEGVSetField(TIFF *tif, uint32_t tag, va_list ap)
-{
- static const char module[] = "OJPEGVSetField";
- OJPEGState *sp = (OJPEGState *)tif->tif_data;
- uint32_t ma;
- uint64_t *mb;
- uint32_t n;
- const TIFFField *fip;
-
- switch (tag)
- {
- case TIFFTAG_JPEGIFOFFSET:
- sp->jpeg_interchange_format = (uint64_t)va_arg(ap, uint64_t);
- break;
- case TIFFTAG_JPEGIFBYTECOUNT:
- sp->jpeg_interchange_format_length = (uint64_t)va_arg(ap, uint64_t);
- break;
- case TIFFTAG_YCBCRSUBSAMPLING:
- sp->subsampling_tag = 1;
- sp->subsampling_hor = (uint8_t)va_arg(ap, uint16_vap);
- sp->subsampling_ver = (uint8_t)va_arg(ap, uint16_vap);
- tif->tif_dir.td_ycbcrsubsampling[0] = sp->subsampling_hor;
- tif->tif_dir.td_ycbcrsubsampling[1] = sp->subsampling_ver;
- break;
- case TIFFTAG_JPEGQTABLES:
- ma = (uint32_t)va_arg(ap, uint32_t);
- if (ma != 0)
- {
- if (ma > 3)
- {
- TIFFErrorExtR(tif, module,
- "JpegQTables tag has incorrect count");
- return (0);
- }
- sp->qtable_offset_count = (uint8_t)ma;
- mb = (uint64_t *)va_arg(ap, uint64_t *);
- for (n = 0; n < ma; n++)
- sp->qtable_offset[n] = mb[n];
- }
- break;
- case TIFFTAG_JPEGDCTABLES:
- ma = (uint32_t)va_arg(ap, uint32_t);
- if (ma != 0)
- {
- if (ma > 3)
- {
- TIFFErrorExtR(tif, module,
- "JpegDcTables tag has incorrect count");
- return (0);
- }
- sp->dctable_offset_count = (uint8_t)ma;
- mb = (uint64_t *)va_arg(ap, uint64_t *);
- for (n = 0; n < ma; n++)
- sp->dctable_offset[n] = mb[n];
- }
- break;
- case TIFFTAG_JPEGACTABLES:
- ma = (uint32_t)va_arg(ap, uint32_t);
- if (ma != 0)
- {
- if (ma > 3)
- {
- TIFFErrorExtR(tif, module,
- "JpegAcTables tag has incorrect count");
- return (0);
- }
- sp->actable_offset_count = (uint8_t)ma;
- mb = (uint64_t *)va_arg(ap, uint64_t *);
- for (n = 0; n < ma; n++)
- sp->actable_offset[n] = mb[n];
- }
- break;
- case TIFFTAG_JPEGPROC:
- sp->jpeg_proc = (uint8_t)va_arg(ap, uint16_vap);
- break;
- case TIFFTAG_JPEGRESTARTINTERVAL:
- sp->restart_interval = (uint16_t)va_arg(ap, uint16_vap);
- break;
- default:
- return (*sp->vsetparent)(tif, tag, ap);
- }
- fip = TIFFFieldWithTag(tif, tag);
- if (fip == NULL) /* shouldn't happen */
- return (0);
- TIFFSetFieldBit(tif, fip->field_bit);
- tif->tif_flags |= TIFF_DIRTYDIRECT;
- return (1);
-}
-
-static void OJPEGPrintDir(TIFF *tif, FILE *fd, long flags)
-{
- OJPEGState *sp = (OJPEGState *)tif->tif_data;
- uint8_t m;
- (void)flags;
- assert(sp != NULL);
- if (TIFFFieldSet(tif, FIELD_OJPEG_JPEGINTERCHANGEFORMAT))
- fprintf(fd, " JpegInterchangeFormat: %" PRIu64 "\n",
- (uint64_t)sp->jpeg_interchange_format);
- if (TIFFFieldSet(tif, FIELD_OJPEG_JPEGINTERCHANGEFORMATLENGTH))
- fprintf(fd, " JpegInterchangeFormatLength: %" PRIu64 "\n",
- (uint64_t)sp->jpeg_interchange_format_length);
- if (TIFFFieldSet(tif, FIELD_OJPEG_JPEGQTABLES))
- {
- fprintf(fd, " JpegQTables:");
- for (m = 0; m < sp->qtable_offset_count; m++)
- fprintf(fd, " %" PRIu64, (uint64_t)sp->qtable_offset[m]);
- fprintf(fd, "\n");
- }
- if (TIFFFieldSet(tif, FIELD_OJPEG_JPEGDCTABLES))
- {
- fprintf(fd, " JpegDcTables:");
- for (m = 0; m < sp->dctable_offset_count; m++)
- fprintf(fd, " %" PRIu64, (uint64_t)sp->dctable_offset[m]);
- fprintf(fd, "\n");
- }
- if (TIFFFieldSet(tif, FIELD_OJPEG_JPEGACTABLES))
- {
- fprintf(fd, " JpegAcTables:");
- for (m = 0; m < sp->actable_offset_count; m++)
- fprintf(fd, " %" PRIu64, (uint64_t)sp->actable_offset[m]);
- fprintf(fd, "\n");
- }
- if (TIFFFieldSet(tif, FIELD_OJPEG_JPEGPROC))
- fprintf(fd, " JpegProc: %" PRIu8 "\n", sp->jpeg_proc);
- if (TIFFFieldSet(tif, FIELD_OJPEG_JPEGRESTARTINTERVAL))
- fprintf(fd, " JpegRestartInterval: %" PRIu16 "\n",
- sp->restart_interval);
- if (sp->printdir)
- (*sp->printdir)(tif, fd, flags);
-}
-
-static int OJPEGFixupTags(TIFF *tif)
-{
- (void)tif;
- return (1);
-}
-
-static int OJPEGSetupDecode(TIFF *tif)
-{
- static const char module[] = "OJPEGSetupDecode";
- TIFFWarningExtR(tif, module,
- "Deprecated and troublesome old-style JPEG compression "
- "mode, please convert to new-style JPEG compression and "
- "notify vendor of writing software");
- return (1);
-}
-
-static int OJPEGPreDecode(TIFF *tif, uint16_t s)
-{
- OJPEGState *sp = (OJPEGState *)tif->tif_data;
- uint32_t m;
- if (sp->subsamplingcorrect_done == 0)
- OJPEGSubsamplingCorrect(tif);
- if (sp->readheader_done == 0)
- {
- if (OJPEGReadHeaderInfo(tif) == 0)
- return (0);
- }
- if (sp->sos_end[s].log == 0)
- {
- if (OJPEGReadSecondarySos(tif, s) == 0)
- return (0);
- }
- if (isTiled(tif))
- m = tif->tif_curtile;
- else
- m = tif->tif_curstrip;
- if ((sp->writeheader_done != 0) &&
- ((sp->write_cursample != s) || (sp->write_curstrile > m)))
- {
- if (sp->libjpeg_session_active != 0)
- OJPEGLibjpegSessionAbort(tif);
- sp->writeheader_done = 0;
- }
- if (sp->writeheader_done == 0)
- {
- sp->plane_sample_offset = (uint8_t)s;
- sp->write_cursample = s;
- sp->write_curstrile = s * tif->tif_dir.td_stripsperimage;
- if ((sp->in_buffer_file_pos_log == 0) ||
- (sp->in_buffer_file_pos - sp->in_buffer_togo !=
- sp->sos_end[s].in_buffer_file_pos))
- {
- sp->in_buffer_source = sp->sos_end[s].in_buffer_source;
- sp->in_buffer_next_strile = sp->sos_end[s].in_buffer_next_strile;
- sp->in_buffer_file_pos = sp->sos_end[s].in_buffer_file_pos;
- sp->in_buffer_file_pos_log = 0;
- sp->in_buffer_file_togo = sp->sos_end[s].in_buffer_file_togo;
- sp->in_buffer_togo = 0;
- sp->in_buffer_cur = 0;
- }
- if (OJPEGWriteHeaderInfo(tif) == 0)
- return (0);
- }
-
- sp->subsampling_convert_state = 0;
-
- while (sp->write_curstrile < m)
- {
- if (sp->libjpeg_jpeg_query_style == 0)
- {
- if (OJPEGPreDecodeSkipRaw(tif) == 0)
- return (0);
- }
- else
- {
- if (OJPEGPreDecodeSkipScanlines(tif) == 0)
- return (0);
- }
- sp->write_curstrile++;
- }
- sp->decoder_ok = 1;
- return (1);
-}
-
-static int OJPEGPreDecodeSkipRaw(TIFF *tif)
-{
- OJPEGState *sp = (OJPEGState *)tif->tif_data;
- uint32_t m;
- m = sp->lines_per_strile;
- if (sp->subsampling_convert_state != 0)
- {
- if (sp->subsampling_convert_clines - sp->subsampling_convert_state >= m)
- {
- sp->subsampling_convert_state += m;
- if (sp->subsampling_convert_state == sp->subsampling_convert_clines)
- sp->subsampling_convert_state = 0;
- return (1);
- }
- m -= sp->subsampling_convert_clines - sp->subsampling_convert_state;
- sp->subsampling_convert_state = 0;
- sp->error_in_raw_data_decoding = 0;
- }
- while (m >= sp->subsampling_convert_clines)
- {
- if (jpeg_read_raw_data_encap(sp, &(sp->libjpeg_jpeg_decompress_struct),
- sp->subsampling_convert_ycbcrimage,
- sp->subsampling_ver * 8) == 0)
- return (0);
- m -= sp->subsampling_convert_clines;
- }
- if (m > 0)
- {
- if (jpeg_read_raw_data_encap(sp, &(sp->libjpeg_jpeg_decompress_struct),
- sp->subsampling_convert_ycbcrimage,
- sp->subsampling_ver * 8) == 0)
- return (0);
- sp->subsampling_convert_state = m;
- }
- return (1);
-}
-
-static int OJPEGPreDecodeSkipScanlines(TIFF *tif)
-{
- static const char module[] = "OJPEGPreDecodeSkipScanlines";
- OJPEGState *sp = (OJPEGState *)tif->tif_data;
- uint32_t m;
- if (sp->skip_buffer == NULL)
- {
- sp->skip_buffer = _TIFFmallocExt(tif, sp->bytes_per_line);
- if (sp->skip_buffer == NULL)
- {
- TIFFErrorExtR(tif, module, "Out of memory");
- return (0);
- }
- }
- for (m = 0; m < sp->lines_per_strile; m++)
- {
- if (jpeg_read_scanlines_encap(sp, &(sp->libjpeg_jpeg_decompress_struct),
- &sp->skip_buffer, 1) == 0)
- return (0);
- }
- return (1);
-}
-
-static int OJPEGDecode(TIFF *tif, uint8_t *buf, tmsize_t cc, uint16_t s)
-{
- static const char module[] = "OJPEGDecode";
- OJPEGState *sp = (OJPEGState *)tif->tif_data;
- (void)s;
- if (!sp->decoder_ok)
- {
- memset(buf, 0, (size_t)cc);
- TIFFErrorExtR(tif, module,
- "Cannot decode: decoder not correctly initialized");
- return 0;
- }
- if (sp->libjpeg_session_active == 0)
- {
- memset(buf, 0, (size_t)cc);
- /* This should normally not happen, except that it does when */
- /* using TIFFReadScanline() which calls OJPEGPostDecode() for */
- /* each scanline, which assumes that a whole strile was read */
- /* and may thus incorrectly consider it has read the whole image,
- * causing */
- /* OJPEGLibjpegSessionAbort() to be called prematurely. */
- /* Triggered by https://gitlab.com/libtiff/libtiff/-/issues/337 */
- TIFFErrorExtR(tif, module,
- "Cannot decode: libjpeg_session_active == 0");
- return 0;
- }
- if (sp->error_in_raw_data_decoding)
- {
- memset(buf, 0, (size_t)cc);
- return 0;
- }
- if (sp->libjpeg_jpeg_query_style == 0)
- {
- if (OJPEGDecodeRaw(tif, buf, cc) == 0)
- {
- memset(buf, 0, (size_t)cc);
- return (0);
- }
- }
- else
- {
- if (OJPEGDecodeScanlines(tif, buf, cc) == 0)
- {
- memset(buf, 0, (size_t)cc);
- return (0);
- }
- }
- return (1);
-}
-
-static int OJPEGDecodeRaw(TIFF *tif, uint8_t *buf, tmsize_t cc)
-{
- static const char module[] = "OJPEGDecodeRaw";
- OJPEGState *sp = (OJPEGState *)tif->tif_data;
- uint8_t *m;
- tmsize_t n;
- uint8_t *oy;
- uint8_t *ocb;
- uint8_t *ocr;
- uint8_t *p;
- uint32_t q;
- uint8_t *r;
- uint8_t sx, sy;
- if (cc % sp->bytes_per_line != 0)
- {
- TIFFErrorExtR(tif, module, "Fractional scanline not read");
- return (0);
- }
- assert(cc > 0);
- m = buf;
- n = cc;
- do
- {
- if (sp->subsampling_convert_state == 0)
- {
- if (jpeg_read_raw_data_encap(sp,
- &(sp->libjpeg_jpeg_decompress_struct),
- sp->subsampling_convert_ycbcrimage,
- sp->subsampling_ver * 8) == 0)
- {
- sp->error_in_raw_data_decoding = 1;
- return (0);
- }
- }
- oy = sp->subsampling_convert_ybuf +
- sp->subsampling_convert_state * sp->subsampling_ver *
- sp->subsampling_convert_ylinelen;
- ocb = sp->subsampling_convert_cbbuf +
- sp->subsampling_convert_state * sp->subsampling_convert_clinelen;
- ocr = sp->subsampling_convert_crbuf +
- sp->subsampling_convert_state * sp->subsampling_convert_clinelen;
- p = m;
- for (q = 0; q < sp->subsampling_convert_clinelenout; q++)
- {
- r = oy;
- for (sy = 0; sy < sp->subsampling_ver; sy++)
- {
- for (sx = 0; sx < sp->subsampling_hor; sx++)
- *p++ = *r++;
- r += sp->subsampling_convert_ylinelen - sp->subsampling_hor;
- }
- oy += sp->subsampling_hor;
- *p++ = *ocb++;
- *p++ = *ocr++;
- }
- sp->subsampling_convert_state++;
- if (sp->subsampling_convert_state == sp->subsampling_convert_clines)
- sp->subsampling_convert_state = 0;
- m += sp->bytes_per_line;
- n -= sp->bytes_per_line;
- } while (n > 0);
- return (1);
-}
-
-static int OJPEGDecodeScanlines(TIFF *tif, uint8_t *buf, tmsize_t cc)
-{
- static const char module[] = "OJPEGDecodeScanlines";
- OJPEGState *sp = (OJPEGState *)tif->tif_data;
- uint8_t *m;
- tmsize_t n;
- if (cc % sp->bytes_per_line != 0)
- {
- TIFFErrorExtR(tif, module, "Fractional scanline not read");
- return (0);
- }
- assert(cc > 0);
- m = buf;
- n = cc;
- do
- {
- if (jpeg_read_scanlines_encap(sp, &(sp->libjpeg_jpeg_decompress_struct),
- &m, 1) == 0)
- return (0);
- m += sp->bytes_per_line;
- n -= sp->bytes_per_line;
- } while (n > 0);
- return (1);
-}
-
-static void OJPEGPostDecode(TIFF *tif, uint8_t *buf, tmsize_t cc)
-{
- OJPEGState *sp = (OJPEGState *)tif->tif_data;
- (void)buf;
- (void)cc;
- /* This function somehow incorrectly assumes that a whole strile was read,
- */
- /* which is not true when TIFFReadScanline() is called, */
- /* and may thus incorrectly consider it has read the whole image, causing */
- /* OJPEGLibjpegSessionAbort() to be called prematurely. */
- /* So this logic should be fixed to take into account cc, or disable */
- /* the scan line reading interface. */
- /* Triggered by https://gitlab.com/libtiff/libtiff/-/issues/337 */
- sp->write_curstrile++;
- if (sp->write_curstrile % tif->tif_dir.td_stripsperimage == 0)
- {
- assert(sp->libjpeg_session_active != 0);
- OJPEGLibjpegSessionAbort(tif);
- sp->writeheader_done = 0;
- }
-}
-
-static int OJPEGSetupEncode(TIFF *tif)
-{
- static const char module[] = "OJPEGSetupEncode";
- TIFFErrorExtR(
- tif, module,
- "OJPEG encoding not supported; use new-style JPEG compression instead");
- return (0);
-}
-
-static int OJPEGPreEncode(TIFF *tif, uint16_t s)
-{
- static const char module[] = "OJPEGPreEncode";
- (void)s;
- TIFFErrorExtR(
- tif, module,
- "OJPEG encoding not supported; use new-style JPEG compression instead");
- return (0);
-}
-
-static int OJPEGEncode(TIFF *tif, uint8_t *buf, tmsize_t cc, uint16_t s)
-{
- static const char module[] = "OJPEGEncode";
- (void)buf;
- (void)cc;
- (void)s;
- TIFFErrorExtR(
- tif, module,
- "OJPEG encoding not supported; use new-style JPEG compression instead");
- return (0);
-}
-
-static int OJPEGPostEncode(TIFF *tif)
-{
- static const char module[] = "OJPEGPostEncode";
- TIFFErrorExtR(
- tif, module,
- "OJPEG encoding not supported; use new-style JPEG compression instead");
- return (0);
-}
-
-static void OJPEGCleanup(TIFF *tif)
-{
- OJPEGState *sp = (OJPEGState *)tif->tif_data;
- if (sp != 0)
- {
- tif->tif_tagmethods.vgetfield = sp->vgetparent;
- tif->tif_tagmethods.vsetfield = sp->vsetparent;
- tif->tif_tagmethods.printdir = sp->printdir;
- if (sp->qtable[0] != 0)
- _TIFFfreeExt(tif, sp->qtable[0]);
- if (sp->qtable[1] != 0)
- _TIFFfreeExt(tif, sp->qtable[1]);
- if (sp->qtable[2] != 0)
- _TIFFfreeExt(tif, sp->qtable[2]);
- if (sp->qtable[3] != 0)
- _TIFFfreeExt(tif, sp->qtable[3]);
- if (sp->dctable[0] != 0)
- _TIFFfreeExt(tif, sp->dctable[0]);
- if (sp->dctable[1] != 0)
- _TIFFfreeExt(tif, sp->dctable[1]);
- if (sp->dctable[2] != 0)
- _TIFFfreeExt(tif, sp->dctable[2]);
- if (sp->dctable[3] != 0)
- _TIFFfreeExt(tif, sp->dctable[3]);
- if (sp->actable[0] != 0)
- _TIFFfreeExt(tif, sp->actable[0]);
- if (sp->actable[1] != 0)
- _TIFFfreeExt(tif, sp->actable[1]);
- if (sp->actable[2] != 0)
- _TIFFfreeExt(tif, sp->actable[2]);
- if (sp->actable[3] != 0)
- _TIFFfreeExt(tif, sp->actable[3]);
- if (sp->libjpeg_session_active != 0)
- OJPEGLibjpegSessionAbort(tif);
- if (sp->subsampling_convert_ycbcrbuf != 0)
- _TIFFfreeExt(tif, sp->subsampling_convert_ycbcrbuf);
- if (sp->subsampling_convert_ycbcrimage != 0)
- _TIFFfreeExt(tif, sp->subsampling_convert_ycbcrimage);
- if (sp->skip_buffer != 0)
- _TIFFfreeExt(tif, sp->skip_buffer);
- _TIFFfreeExt(tif, sp);
- tif->tif_data = NULL;
- _TIFFSetDefaultCompressionState(tif);
- }
-}
-
-static void OJPEGSubsamplingCorrect(TIFF *tif)
-{
- static const char module[] = "OJPEGSubsamplingCorrect";
- OJPEGState *sp = (OJPEGState *)tif->tif_data;
- uint8_t mh;
- uint8_t mv;
-
- assert(sp->subsamplingcorrect_done == 0);
- if ((tif->tif_dir.td_samplesperpixel != 3) ||
- ((tif->tif_dir.td_photometric != PHOTOMETRIC_YCBCR) &&
- (tif->tif_dir.td_photometric != PHOTOMETRIC_ITULAB)))
- {
- if (sp->subsampling_tag != 0)
- TIFFWarningExtR(tif, module,
- "Subsampling tag not appropriate for this "
- "Photometric and/or SamplesPerPixel");
- sp->subsampling_hor = 1;
- sp->subsampling_ver = 1;
- sp->subsampling_force_desubsampling_inside_decompression = 0;
- }
- else
- {
- sp->subsamplingcorrect_done = 1;
- mh = sp->subsampling_hor;
- mv = sp->subsampling_ver;
- sp->subsamplingcorrect = 1;
- OJPEGReadHeaderInfoSec(tif);
- if (sp->subsampling_force_desubsampling_inside_decompression != 0)
- {
- sp->subsampling_hor = 1;
- sp->subsampling_ver = 1;
- }
- sp->subsamplingcorrect = 0;
- if (((sp->subsampling_hor != mh) || (sp->subsampling_ver != mv)) &&
- (sp->subsampling_force_desubsampling_inside_decompression == 0))
- {
- if (sp->subsampling_tag == 0)
- TIFFWarningExtR(
- tif, module,
- "Subsampling tag is not set, yet subsampling inside JPEG "
- "data [%" PRIu8 ",%" PRIu8
- "] does not match default values [2,2]; assuming "
- "subsampling inside JPEG data is correct",
- sp->subsampling_hor, sp->subsampling_ver);
- else
- TIFFWarningExtR(
- tif, module,
- "Subsampling inside JPEG data [%" PRIu8 ",%" PRIu8
- "] does not match subsampling tag values [%" PRIu8
- ",%" PRIu8
- "]; assuming subsampling inside JPEG data is correct",
- sp->subsampling_hor, sp->subsampling_ver, mh, mv);
- }
- if (sp->subsampling_force_desubsampling_inside_decompression != 0)
- {
- if (sp->subsampling_tag == 0)
- TIFFWarningExtR(
- tif, module,
- "Subsampling tag is not set, yet subsampling inside JPEG "
- "data does not match default values [2,2] (nor any other "
- "values allowed in TIFF); assuming subsampling inside JPEG "
- "data is correct and desubsampling inside JPEG "
- "decompression");
- else
- TIFFWarningExtR(
- tif, module,
- "Subsampling inside JPEG data does not match subsampling "
- "tag values [%" PRIu8 ",%" PRIu8
- "] (nor any other values allowed in TIFF); assuming "
- "subsampling inside JPEG data is correct and desubsampling "
- "inside JPEG decompression",
- mh, mv);
- }
- if (sp->subsampling_force_desubsampling_inside_decompression == 0)
- {
- if (sp->subsampling_hor < sp->subsampling_ver)
- TIFFWarningExtR(tif, module,
- "Subsampling values [%" PRIu8 ",%" PRIu8
- "] are not allowed in TIFF",
- sp->subsampling_hor, sp->subsampling_ver);
- }
- }
- sp->subsamplingcorrect_done = 1;
-}
-
-static int OJPEGReadHeaderInfo(TIFF *tif)
-{
- static const char module[] = "OJPEGReadHeaderInfo";
- OJPEGState *sp = (OJPEGState *)tif->tif_data;
- assert(sp->readheader_done == 0);
- sp->image_width = tif->tif_dir.td_imagewidth;
- sp->image_length = tif->tif_dir.td_imagelength;
- if (isTiled(tif))
- {
- sp->strile_width = tif->tif_dir.td_tilewidth;
- sp->strile_length = tif->tif_dir.td_tilelength;
- sp->strile_length_total =
- ((sp->image_length + sp->strile_length - 1) / sp->strile_length) *
- sp->strile_length;
- }
- else
- {
- sp->strile_width = sp->image_width;
- sp->strile_length = tif->tif_dir.td_rowsperstrip;
- if (sp->strile_length == (uint32_t)-1)
- sp->strile_length = sp->image_length;
- sp->strile_length_total = sp->image_length;
- }
- if (tif->tif_dir.td_samplesperpixel == 1)
- {
- sp->samples_per_pixel = 1;
- sp->plane_sample_offset = 0;
- sp->samples_per_pixel_per_plane = sp->samples_per_pixel;
- sp->subsampling_hor = 1;
- sp->subsampling_ver = 1;
- }
- else
- {
- if (tif->tif_dir.td_samplesperpixel != 3)
- {
- TIFFErrorExtR(tif, module,
- "SamplesPerPixel %" PRIu8
- " not supported for this compression scheme",
- sp->samples_per_pixel);
- return (0);
- }
- sp->samples_per_pixel = 3;
- sp->plane_sample_offset = 0;
- if (tif->tif_dir.td_planarconfig == PLANARCONFIG_CONTIG)
- sp->samples_per_pixel_per_plane = 3;
- else
- sp->samples_per_pixel_per_plane = 1;
- }
- if (sp->strile_length < sp->image_length)
- {
- if (((sp->subsampling_hor != 1) && (sp->subsampling_hor != 2) &&
- (sp->subsampling_hor != 4)) ||
- ((sp->subsampling_ver != 1) && (sp->subsampling_ver != 2) &&
- (sp->subsampling_ver != 4)))
- {
- TIFFErrorExtR(tif, module, "Invalid subsampling values");
- return (0);
- }
- if (sp->strile_length % (sp->subsampling_ver * 8) != 0)
- {
- TIFFErrorExtR(tif, module,
- "Incompatible vertical subsampling and image "
- "strip/tile length");
- return (0);
- }
- sp->restart_interval =
- (uint16_t)(((sp->strile_width + sp->subsampling_hor * 8 - 1) /
- (sp->subsampling_hor * 8)) *
- (sp->strile_length / (sp->subsampling_ver * 8)));
- }
- if (OJPEGReadHeaderInfoSec(tif) == 0)
- return (0);
- sp->sos_end[0].log = 1;
- sp->sos_end[0].in_buffer_source = sp->in_buffer_source;
- sp->sos_end[0].in_buffer_next_strile = sp->in_buffer_next_strile;
- sp->sos_end[0].in_buffer_file_pos =
- sp->in_buffer_file_pos - sp->in_buffer_togo;
- sp->sos_end[0].in_buffer_file_togo =
- sp->in_buffer_file_togo + sp->in_buffer_togo;
- sp->readheader_done = 1;
- return (1);
-}
-
-static int OJPEGReadSecondarySos(TIFF *tif, uint16_t s)
-{
- OJPEGState *sp = (OJPEGState *)tif->tif_data;
- uint8_t m;
- assert(s > 0);
- assert(s < 3);
- assert(sp->sos_end[0].log != 0);
- assert(sp->sos_end[s].log == 0);
- sp->plane_sample_offset = (uint8_t)(s - 1);
- while (sp->sos_end[sp->plane_sample_offset].log == 0)
- sp->plane_sample_offset--;
- sp->in_buffer_source =
- sp->sos_end[sp->plane_sample_offset].in_buffer_source;
- sp->in_buffer_next_strile =
- sp->sos_end[sp->plane_sample_offset].in_buffer_next_strile;
- sp->in_buffer_file_pos =
- sp->sos_end[sp->plane_sample_offset].in_buffer_file_pos;
- sp->in_buffer_file_pos_log = 0;
- sp->in_buffer_file_togo =
- sp->sos_end[sp->plane_sample_offset].in_buffer_file_togo;
- sp->in_buffer_togo = 0;
- sp->in_buffer_cur = 0;
- while (sp->plane_sample_offset < s)
- {
- do
- {
- if (OJPEGReadByte(sp, &m) == 0)
- return (0);
- if (m == 255)
- {
- do
- {
- if (OJPEGReadByte(sp, &m) == 0)
- return (0);
- if (m != 255)
- break;
- } while (1);
- if (m == JPEG_MARKER_SOS)
- break;
- }
- } while (1);
- sp->plane_sample_offset++;
- if (OJPEGReadHeaderInfoSecStreamSos(tif) == 0)
- return (0);
- sp->sos_end[sp->plane_sample_offset].log = 1;
- sp->sos_end[sp->plane_sample_offset].in_buffer_source =
- sp->in_buffer_source;
- sp->sos_end[sp->plane_sample_offset].in_buffer_next_strile =
- sp->in_buffer_next_strile;
- sp->sos_end[sp->plane_sample_offset].in_buffer_file_pos =
- sp->in_buffer_file_pos - sp->in_buffer_togo;
- sp->sos_end[sp->plane_sample_offset].in_buffer_file_togo =
- sp->in_buffer_file_togo + sp->in_buffer_togo;
- }
- return (1);
-}
-
-static int OJPEGWriteHeaderInfo(TIFF *tif)
-{
- static const char module[] = "OJPEGWriteHeaderInfo";
- OJPEGState *sp = (OJPEGState *)tif->tif_data;
- uint8_t **m;
- uint32_t n;
- /* if a previous attempt failed, don't try again */
- if (sp->libjpeg_session_active != 0)
- return 0;
- sp->out_state = ososSoi;
- sp->restart_index = 0;
- jpeg_std_error(&(sp->libjpeg_jpeg_error_mgr));
- sp->libjpeg_jpeg_error_mgr.output_message =
- OJPEGLibjpegJpegErrorMgrOutputMessage;
- sp->libjpeg_jpeg_error_mgr.error_exit = OJPEGLibjpegJpegErrorMgrErrorExit;
- sp->libjpeg_jpeg_decompress_struct.err = &(sp->libjpeg_jpeg_error_mgr);
- sp->libjpeg_jpeg_decompress_struct.client_data = (void *)tif;
- if (jpeg_create_decompress_encap(
- sp, &(sp->libjpeg_jpeg_decompress_struct)) == 0)
- return (0);
- sp->libjpeg_session_active = 1;
- sp->libjpeg_jpeg_source_mgr.bytes_in_buffer = 0;
- sp->libjpeg_jpeg_source_mgr.init_source =
- OJPEGLibjpegJpegSourceMgrInitSource;
- sp->libjpeg_jpeg_source_mgr.fill_input_buffer =
- OJPEGLibjpegJpegSourceMgrFillInputBuffer;
- sp->libjpeg_jpeg_source_mgr.skip_input_data =
- OJPEGLibjpegJpegSourceMgrSkipInputData;
- sp->libjpeg_jpeg_source_mgr.resync_to_restart =
- OJPEGLibjpegJpegSourceMgrResyncToRestart;
- sp->libjpeg_jpeg_source_mgr.term_source =
- OJPEGLibjpegJpegSourceMgrTermSource;
- sp->libjpeg_jpeg_decompress_struct.src = &(sp->libjpeg_jpeg_source_mgr);
- if (jpeg_read_header_encap(sp, &(sp->libjpeg_jpeg_decompress_struct), 1) ==
- 0)
- return (0);
- if ((sp->subsampling_force_desubsampling_inside_decompression == 0) &&
- (sp->samples_per_pixel_per_plane > 1))
- {
- sp->libjpeg_jpeg_decompress_struct.raw_data_out = 1;
-#if JPEG_LIB_VERSION >= 70
- sp->libjpeg_jpeg_decompress_struct.do_fancy_upsampling = FALSE;
-#endif
- sp->libjpeg_jpeg_query_style = 0;
- if (sp->subsampling_convert_log == 0)
- {
- assert(sp->subsampling_convert_ycbcrbuf == 0);
- assert(sp->subsampling_convert_ycbcrimage == 0);
- /* Check for division by zero. */
- if (sp->subsampling_hor == 0 || sp->subsampling_ver == 0)
- return (0);
- sp->subsampling_convert_ylinelen =
- ((sp->strile_width + sp->subsampling_hor * 8 - 1) /
- (sp->subsampling_hor * 8) * sp->subsampling_hor * 8);
- sp->subsampling_convert_ylines = sp->subsampling_ver * 8;
- sp->subsampling_convert_clinelen =
- sp->subsampling_convert_ylinelen / sp->subsampling_hor;
- sp->subsampling_convert_clines = 8;
- sp->subsampling_convert_ybuflen = sp->subsampling_convert_ylinelen *
- sp->subsampling_convert_ylines;
- sp->subsampling_convert_cbuflen = sp->subsampling_convert_clinelen *
- sp->subsampling_convert_clines;
- sp->subsampling_convert_ycbcrbuflen =
- sp->subsampling_convert_ybuflen +
- 2 * sp->subsampling_convert_cbuflen;
- /* The calloc is not normally necessary, except in some edge/broken
- * cases */
- /* for example for a tiled image of height 1 with a tile height of 1
- * and subsampling_hor=subsampling_ver=2 */
- /* In that case, libjpeg will only fill the 8 first lines of the 16
- * lines */
- /* See https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=16844
- */
- /* Even if this case is allowed (?), its handling is broken because
- * OJPEGPreDecode() should also likely */
- /* reset subsampling_convert_state to 0 when changing tile. */
- sp->subsampling_convert_ycbcrbuf =
- _TIFFcallocExt(tif, 1, sp->subsampling_convert_ycbcrbuflen);
- if (sp->subsampling_convert_ycbcrbuf == 0)
- {
- TIFFErrorExtR(tif, module, "Out of memory");
- return (0);
- }
- sp->subsampling_convert_ybuf = sp->subsampling_convert_ycbcrbuf;
- sp->subsampling_convert_cbbuf =
- sp->subsampling_convert_ybuf + sp->subsampling_convert_ybuflen;
- sp->subsampling_convert_crbuf =
- sp->subsampling_convert_cbbuf + sp->subsampling_convert_cbuflen;
- sp->subsampling_convert_ycbcrimagelen =
- 3 + sp->subsampling_convert_ylines +
- 2 * sp->subsampling_convert_clines;
- sp->subsampling_convert_ycbcrimage = _TIFFmallocExt(
- tif, sp->subsampling_convert_ycbcrimagelen * sizeof(uint8_t *));
- if (sp->subsampling_convert_ycbcrimage == 0)
- {
- TIFFErrorExtR(tif, module, "Out of memory");
- return (0);
- }
- m = sp->subsampling_convert_ycbcrimage;
- *m++ = (uint8_t *)(sp->subsampling_convert_ycbcrimage + 3);
- *m++ = (uint8_t *)(sp->subsampling_convert_ycbcrimage + 3 +
- sp->subsampling_convert_ylines);
- *m++ = (uint8_t *)(sp->subsampling_convert_ycbcrimage + 3 +
- sp->subsampling_convert_ylines +
- sp->subsampling_convert_clines);
- for (n = 0; n < sp->subsampling_convert_ylines; n++)
- *m++ = sp->subsampling_convert_ybuf +
- n * sp->subsampling_convert_ylinelen;
- for (n = 0; n < sp->subsampling_convert_clines; n++)
- *m++ = sp->subsampling_convert_cbbuf +
- n * sp->subsampling_convert_clinelen;
- for (n = 0; n < sp->subsampling_convert_clines; n++)
- *m++ = sp->subsampling_convert_crbuf +
- n * sp->subsampling_convert_clinelen;
- sp->subsampling_convert_clinelenout =
- sp->strile_width / sp->subsampling_hor +
- ((sp->strile_width % sp->subsampling_hor) != 0 ? 1 : 0);
- sp->subsampling_convert_state = 0;
- sp->error_in_raw_data_decoding = 0;
- sp->bytes_per_line =
- sp->subsampling_convert_clinelenout *
- (sp->subsampling_ver * sp->subsampling_hor + 2);
- sp->lines_per_strile =
- sp->strile_length / sp->subsampling_ver +
- ((sp->strile_length % sp->subsampling_ver) != 0 ? 1 : 0);
- sp->subsampling_convert_log = 1;
- }
- }
- else
- {
- sp->libjpeg_jpeg_decompress_struct.jpeg_color_space = JCS_UNKNOWN;
- sp->libjpeg_jpeg_decompress_struct.out_color_space = JCS_UNKNOWN;
- sp->libjpeg_jpeg_query_style = 1;
- sp->bytes_per_line = sp->samples_per_pixel_per_plane * sp->strile_width;
- sp->lines_per_strile = sp->strile_length;
- }
- if (jpeg_start_decompress_encap(sp,
- &(sp->libjpeg_jpeg_decompress_struct)) == 0)
- return (0);
- if (sp->libjpeg_jpeg_decompress_struct.image_width != sp->strile_width)
- {
- TIFFErrorExtR(tif, module,
- "jpeg_start_decompress() returned image_width = %u, "
- "expected %" PRIu32,
- sp->libjpeg_jpeg_decompress_struct.image_width,
- sp->strile_width);
- return 0;
- }
- if (sp->libjpeg_jpeg_decompress_struct.max_h_samp_factor !=
- sp->subsampling_hor ||
- sp->libjpeg_jpeg_decompress_struct.max_v_samp_factor !=
- sp->subsampling_ver)
- {
- TIFFErrorExtR(tif, module,
- "jpeg_start_decompress() returned max_h_samp_factor = %d "
- "and max_v_samp_factor = %d, expected %" PRIu8
- " and %" PRIu8,
- sp->libjpeg_jpeg_decompress_struct.max_h_samp_factor,
- sp->libjpeg_jpeg_decompress_struct.max_v_samp_factor,
- sp->subsampling_hor, sp->subsampling_ver);
- return 0;
- }
-
- sp->writeheader_done = 1;
- return (1);
-}
-
-static void OJPEGLibjpegSessionAbort(TIFF *tif)
-{
- OJPEGState *sp = (OJPEGState *)tif->tif_data;
- assert(sp->libjpeg_session_active != 0);
- jpeg_destroy((jpeg_common_struct *)(&(sp->libjpeg_jpeg_decompress_struct)));
- sp->libjpeg_session_active = 0;
-}
-
-static int OJPEGReadHeaderInfoSec(TIFF *tif)
-{
- static const char module[] = "OJPEGReadHeaderInfoSec";
- OJPEGState *sp = (OJPEGState *)tif->tif_data;
- uint8_t m;
- uint16_t n;
- uint8_t o;
- if (sp->file_size == 0)
- sp->file_size = TIFFGetFileSize(tif);
- if (sp->jpeg_interchange_format != 0)
- {
- if (sp->jpeg_interchange_format >= sp->file_size)
- {
- sp->jpeg_interchange_format = 0;
- sp->jpeg_interchange_format_length = 0;
- }
- else
- {
- if ((sp->jpeg_interchange_format_length == 0) ||
- (sp->jpeg_interchange_format >
- UINT64_MAX - sp->jpeg_interchange_format_length) ||
- (sp->jpeg_interchange_format +
- sp->jpeg_interchange_format_length >
- sp->file_size))
- sp->jpeg_interchange_format_length =
- sp->file_size - sp->jpeg_interchange_format;
- }
- }
- sp->in_buffer_source = osibsNotSetYet;
- sp->in_buffer_next_strile = 0;
- sp->in_buffer_strile_count = tif->tif_dir.td_nstrips;
- sp->in_buffer_file_togo = 0;
- sp->in_buffer_togo = 0;
- do
- {
- if (OJPEGReadBytePeek(sp, &m) == 0)
- return (0);
- if (m != 255)
- break;
- OJPEGReadByteAdvance(sp);
- do
- {
- if (OJPEGReadByte(sp, &m) == 0)
- return (0);
- } while (m == 255);
- switch (m)
- {
- case JPEG_MARKER_SOI:
- /* this type of marker has no data, and should be skipped */
- break;
- case JPEG_MARKER_COM:
- case JPEG_MARKER_APP0:
- case JPEG_MARKER_APP0 + 1:
- case JPEG_MARKER_APP0 + 2:
- case JPEG_MARKER_APP0 + 3:
- case JPEG_MARKER_APP0 + 4:
- case JPEG_MARKER_APP0 + 5:
- case JPEG_MARKER_APP0 + 6:
- case JPEG_MARKER_APP0 + 7:
- case JPEG_MARKER_APP0 + 8:
- case JPEG_MARKER_APP0 + 9:
- case JPEG_MARKER_APP0 + 10:
- case JPEG_MARKER_APP0 + 11:
- case JPEG_MARKER_APP0 + 12:
- case JPEG_MARKER_APP0 + 13:
- case JPEG_MARKER_APP0 + 14:
- case JPEG_MARKER_APP0 + 15:
- /* this type of marker has data, but it has no use to us (and no
- * place here) and should be skipped */
- if (OJPEGReadWord(sp, &n) == 0)
- return (0);
- if (n < 2)
- {
- if (sp->subsamplingcorrect == 0)
- TIFFErrorExtR(tif, module, "Corrupt JPEG data");
- return (0);
- }
- if (n > 2)
- OJPEGReadSkip(sp, n - 2);
- break;
- case JPEG_MARKER_DRI:
- if (OJPEGReadHeaderInfoSecStreamDri(tif) == 0)
- return (0);
- break;
- case JPEG_MARKER_DQT:
- if (OJPEGReadHeaderInfoSecStreamDqt(tif) == 0)
- return (0);
- break;
- case JPEG_MARKER_DHT:
- if (OJPEGReadHeaderInfoSecStreamDht(tif) == 0)
- return (0);
- break;
- case JPEG_MARKER_SOF0:
- case JPEG_MARKER_SOF1:
- case JPEG_MARKER_SOF3:
- if (OJPEGReadHeaderInfoSecStreamSof(tif, m) == 0)
- return (0);
- if (sp->subsamplingcorrect != 0)
- return (1);
- break;
- case JPEG_MARKER_SOS:
- if (sp->subsamplingcorrect != 0)
- return (1);
- assert(sp->plane_sample_offset == 0);
- if (OJPEGReadHeaderInfoSecStreamSos(tif) == 0)
- return (0);
- break;
- default:
- TIFFErrorExtR(tif, module,
- "Unknown marker type %" PRIu8 " in JPEG data", m);
- return (0);
- }
- } while (m != JPEG_MARKER_SOS);
- if (sp->subsamplingcorrect)
- return (1);
- if (sp->sof_log == 0)
- {
- if (OJPEGReadHeaderInfoSecTablesQTable(tif) == 0)
- return (0);
- sp->sof_marker_id = JPEG_MARKER_SOF0;
- for (o = 0; o < sp->samples_per_pixel; o++)
- sp->sof_c[o] = o;
- sp->sof_hv[0] = ((sp->subsampling_hor << 4) | sp->subsampling_ver);
- for (o = 1; o < sp->samples_per_pixel; o++)
- sp->sof_hv[o] = 17;
- sp->sof_x = sp->strile_width;
- sp->sof_y = sp->strile_length_total;
- sp->sof_log = 1;
- if (OJPEGReadHeaderInfoSecTablesDcTable(tif) == 0)
- return (0);
- if (OJPEGReadHeaderInfoSecTablesAcTable(tif) == 0)
- return (0);
- for (o = 1; o < sp->samples_per_pixel; o++)
- sp->sos_cs[o] = o;
- }
- return (1);
-}
-
-static int OJPEGReadHeaderInfoSecStreamDri(TIFF *tif)
-{
- /* This could easily cause trouble in some cases... but no such cases have
- occurred so far */
- static const char module[] = "OJPEGReadHeaderInfoSecStreamDri";
- OJPEGState *sp = (OJPEGState *)tif->tif_data;
- uint16_t m;
- if (OJPEGReadWord(sp, &m) == 0)
- return (0);
- if (m != 4)
- {
- TIFFErrorExtR(tif, module, "Corrupt DRI marker in JPEG data");
- return (0);
- }
- if (OJPEGReadWord(sp, &m) == 0)
- return (0);
- sp->restart_interval = m;
- return (1);
-}
-
-static int OJPEGReadHeaderInfoSecStreamDqt(TIFF *tif)
-{
- /* this is a table marker, and it is to be saved as a whole for exact
- * pushing on the jpeg stream later on */
- static const char module[] = "OJPEGReadHeaderInfoSecStreamDqt";
- OJPEGState *sp = (OJPEGState *)tif->tif_data;
- uint16_t m;
- uint32_t na;
- uint8_t *nb;
- uint8_t o;
- if (OJPEGReadWord(sp, &m) == 0)
- return (0);
- if (m <= 2)
- {
- if (sp->subsamplingcorrect == 0)
- TIFFErrorExtR(tif, module, "Corrupt DQT marker in JPEG data");
- return (0);
- }
- if (sp->subsamplingcorrect != 0)
- OJPEGReadSkip(sp, m - 2);
- else
- {
- m -= 2;
- do
- {
- if (m < 65)
- {
- TIFFErrorExtR(tif, module, "Corrupt DQT marker in JPEG data");
- return (0);
- }
- na = sizeof(uint32_t) + 69;
- nb = _TIFFmallocExt(tif, na);
- if (nb == 0)
- {
- TIFFErrorExtR(tif, module, "Out of memory");
- return (0);
- }
- *(uint32_t *)nb = na;
- nb[sizeof(uint32_t)] = 255;
- nb[sizeof(uint32_t) + 1] = JPEG_MARKER_DQT;
- nb[sizeof(uint32_t) + 2] = 0;
- nb[sizeof(uint32_t) + 3] = 67;
- if (OJPEGReadBlock(sp, 65, &nb[sizeof(uint32_t) + 4]) == 0)
- {
- _TIFFfreeExt(tif, nb);
- return (0);
- }
- o = nb[sizeof(uint32_t) + 4] & 15;
- if (3 < o)
- {
- TIFFErrorExtR(tif, module, "Corrupt DQT marker in JPEG data");
- _TIFFfreeExt(tif, nb);
- return (0);
- }
- if (sp->qtable[o] != 0)
- _TIFFfreeExt(tif, sp->qtable[o]);
- sp->qtable[o] = nb;
- m -= 65;
- } while (m > 0);
- }
- return (1);
-}
-
-static int OJPEGReadHeaderInfoSecStreamDht(TIFF *tif)
-{
- /* this is a table marker, and it is to be saved as a whole for exact
- * pushing on the jpeg stream later on */
- /* TODO: the following assumes there is only one table in this marker... but
- * i'm not quite sure that assumption is guaranteed correct */
- static const char module[] = "OJPEGReadHeaderInfoSecStreamDht";
- OJPEGState *sp = (OJPEGState *)tif->tif_data;
- uint16_t m;
- uint32_t na;
- uint8_t *nb;
- uint8_t o;
- if (OJPEGReadWord(sp, &m) == 0)
- return (0);
- if (m <= 2)
- {
- if (sp->subsamplingcorrect == 0)
- TIFFErrorExtR(tif, module, "Corrupt DHT marker in JPEG data");
- return (0);
- }
- if (sp->subsamplingcorrect != 0)
- {
- OJPEGReadSkip(sp, m - 2);
- }
- else
- {
- na = sizeof(uint32_t) + 2 + m;
- nb = _TIFFmallocExt(tif, na);
- if (nb == 0)
- {
- TIFFErrorExtR(tif, module, "Out of memory");
- return (0);
- }
- *(uint32_t *)nb = na;
- nb[sizeof(uint32_t)] = 255;
- nb[sizeof(uint32_t) + 1] = JPEG_MARKER_DHT;
- nb[sizeof(uint32_t) + 2] = (m >> 8);
- nb[sizeof(uint32_t) + 3] = (m & 255);
- if (OJPEGReadBlock(sp, m - 2, &nb[sizeof(uint32_t) + 4]) == 0)
- {
- _TIFFfreeExt(tif, nb);
- return (0);
- }
- o = nb[sizeof(uint32_t) + 4];
- if ((o & 240) == 0)
- {
- if (3 < o)
- {
- TIFFErrorExtR(tif, module, "Corrupt DHT marker in JPEG data");
- _TIFFfreeExt(tif, nb);
- return (0);
- }
- if (sp->dctable[o] != 0)
- _TIFFfreeExt(tif, sp->dctable[o]);
- sp->dctable[o] = nb;
- }
- else
- {
- if ((o & 240) != 16)
- {
- TIFFErrorExtR(tif, module, "Corrupt DHT marker in JPEG data");
- _TIFFfreeExt(tif, nb);
- return (0);
- }
- o &= 15;
- if (3 < o)
- {
- TIFFErrorExtR(tif, module, "Corrupt DHT marker in JPEG data");
- _TIFFfreeExt(tif, nb);
- return (0);
- }
- if (sp->actable[o] != 0)
- _TIFFfreeExt(tif, sp->actable[o]);
- sp->actable[o] = nb;
- }
- }
- return (1);
-}
-
-static int OJPEGReadHeaderInfoSecStreamSof(TIFF *tif, uint8_t marker_id)
-{
- /* this marker needs to be checked, and part of its data needs to be saved
- * for regeneration later on */
- static const char module[] = "OJPEGReadHeaderInfoSecStreamSof";
- OJPEGState *sp = (OJPEGState *)tif->tif_data;
- uint16_t m;
- uint16_t n;
- uint8_t o;
- uint16_t p;
- uint16_t q;
- if (sp->sof_log != 0)
- {
- TIFFErrorExtR(tif, module, "Corrupt JPEG data");
- return (0);
- }
- if (sp->subsamplingcorrect == 0)
- sp->sof_marker_id = marker_id;
- /* Lf: data length */
- if (OJPEGReadWord(sp, &m) == 0)
- return (0);
- if (m < 11)
- {
- if (sp->subsamplingcorrect == 0)
- TIFFErrorExtR(tif, module, "Corrupt SOF marker in JPEG data");
- return (0);
- }
- m -= 8;
- if (m % 3 != 0)
- {
- if (sp->subsamplingcorrect == 0)
- TIFFErrorExtR(tif, module, "Corrupt SOF marker in JPEG data");
- return (0);
- }
- n = m / 3;
- if (sp->subsamplingcorrect == 0)
- {
- if (n != sp->samples_per_pixel)
- {
- TIFFErrorExtR(
- tif, module,
- "JPEG compressed data indicates unexpected number of samples");
- return (0);
- }
- }
- /* P: Sample precision */
- if (OJPEGReadByte(sp, &o) == 0)
- return (0);
- if (o != 8)
- {
- if (sp->subsamplingcorrect == 0)
- TIFFErrorExtR(tif, module,
- "JPEG compressed data indicates unexpected number of "
- "bits per sample");
- return (0);
- }
- /* Y: Number of lines, X: Number of samples per line */
- if (sp->subsamplingcorrect)
- OJPEGReadSkip(sp, 4);
- else
- {
- /* Y: Number of lines */
- if (OJPEGReadWord(sp, &p) == 0)
- return (0);
- if (((uint32_t)p < sp->image_length) &&
- ((uint32_t)p < sp->strile_length_total))
- {
- TIFFErrorExtR(tif, module,
- "JPEG compressed data indicates unexpected height");
- return (0);
- }
- sp->sof_y = p;
- /* X: Number of samples per line */
- if (OJPEGReadWord(sp, &p) == 0)
- return (0);
- if (((uint32_t)p < sp->image_width) && ((uint32_t)p < sp->strile_width))
- {
- TIFFErrorExtR(tif, module,
- "JPEG compressed data indicates unexpected width");
- return (0);
- }
- if ((uint32_t)p > sp->strile_width)
- {
- TIFFErrorExtR(tif, module,
- "JPEG compressed data image width exceeds expected "
- "image width");
- return (0);
- }
- sp->sof_x = p;
- }
- /* Nf: Number of image components in frame */
- if (OJPEGReadByte(sp, &o) == 0)
- return (0);
- if (o != n)
- {
- if (sp->subsamplingcorrect == 0)
- TIFFErrorExtR(tif, module, "Corrupt SOF marker in JPEG data");
- return (0);
- }
- /* per component stuff */
- /* TODO: double-check that flow implies that n cannot be as big as to make
- * us overflow sof_c, sof_hv and sof_tq arrays */
- for (q = 0; q < n; q++)
- {
- /* C: Component identifier */
- if (OJPEGReadByte(sp, &o) == 0)
- return (0);
- if (sp->subsamplingcorrect == 0)
- sp->sof_c[q] = o;
- /* H: Horizontal sampling factor, and V: Vertical sampling factor */
- if (OJPEGReadByte(sp, &o) == 0)
- return (0);
- if (sp->subsamplingcorrect != 0)
- {
- if (q == 0)
- {
- sp->subsampling_hor = (o >> 4);
- sp->subsampling_ver = (o & 15);
- if (((sp->subsampling_hor != 1) && (sp->subsampling_hor != 2) &&
- (sp->subsampling_hor != 4)) ||
- ((sp->subsampling_ver != 1) && (sp->subsampling_ver != 2) &&
- (sp->subsampling_ver != 4)))
- sp->subsampling_force_desubsampling_inside_decompression =
- 1;
- }
- else
- {
- if (o != 17)
- sp->subsampling_force_desubsampling_inside_decompression =
- 1;
- }
- }
- else
- {
- sp->sof_hv[q] = o;
- if (sp->subsampling_force_desubsampling_inside_decompression == 0)
- {
- if (q == 0)
- {
- if (o != ((sp->subsampling_hor << 4) | sp->subsampling_ver))
- {
- TIFFErrorExtR(tif, module,
- "JPEG compressed data indicates "
- "unexpected subsampling values");
- return (0);
- }
- }
- else
- {
- if (o != 17)
- {
- TIFFErrorExtR(tif, module,
- "JPEG compressed data indicates "
- "unexpected subsampling values");
- return (0);
- }
- }
- }
- }
- /* Tq: Quantization table destination selector */
- if (OJPEGReadByte(sp, &o) == 0)
- return (0);
- if (sp->subsamplingcorrect == 0)
- sp->sof_tq[q] = o;
- }
- if (sp->subsamplingcorrect == 0)
- sp->sof_log = 1;
- return (1);
-}
-
-static int OJPEGReadHeaderInfoSecStreamSos(TIFF *tif)
-{
- /* this marker needs to be checked, and part of its data needs to be saved
- * for regeneration later on */
- static const char module[] = "OJPEGReadHeaderInfoSecStreamSos";
- OJPEGState *sp = (OJPEGState *)tif->tif_data;
- uint16_t m;
- uint8_t n;
- uint8_t o;
- assert(sp->subsamplingcorrect == 0);
- if (sp->sof_log == 0)
- {
- TIFFErrorExtR(tif, module, "Corrupt SOS marker in JPEG data");
- return (0);
- }
- /* Ls */
- if (OJPEGReadWord(sp, &m) == 0)
- return (0);
- if (m != 6 + sp->samples_per_pixel_per_plane * 2)
- {
- TIFFErrorExtR(tif, module, "Corrupt SOS marker in JPEG data");
- return (0);
- }
- /* Ns */
- if (OJPEGReadByte(sp, &n) == 0)
- return (0);
- if (n != sp->samples_per_pixel_per_plane)
- {
- TIFFErrorExtR(tif, module, "Corrupt SOS marker in JPEG data");
- return (0);
- }
- /* Cs, Td, and Ta */
- for (o = 0; o < sp->samples_per_pixel_per_plane; o++)
- {
- /* Cs */
- if (OJPEGReadByte(sp, &n) == 0)
- return (0);
- sp->sos_cs[sp->plane_sample_offset + o] = n;
- /* Td and Ta */
- if (OJPEGReadByte(sp, &n) == 0)
- return (0);
- sp->sos_tda[sp->plane_sample_offset + o] = n;
- }
- /* skip Ss, Se, Ah, en Al -> no check, as per Tom Lane recommendation, as
- * per LibJpeg source */
- OJPEGReadSkip(sp, 3);
- return (1);
-}
-
-static int OJPEGReadHeaderInfoSecTablesQTable(TIFF *tif)
-{
- static const char module[] = "OJPEGReadHeaderInfoSecTablesQTable";
- OJPEGState *sp = (OJPEGState *)tif->tif_data;
- uint8_t m;
- uint8_t n;
- uint32_t oa;
- uint8_t *ob;
- uint32_t p;
- if (sp->qtable_offset[0] == 0)
- {
- TIFFErrorExtR(tif, module, "Missing JPEG tables");
- return (0);
- }
- sp->in_buffer_file_pos_log = 0;
- for (m = 0; m < sp->samples_per_pixel; m++)
- {
- if ((sp->qtable_offset[m] != 0) &&
- ((m == 0) || (sp->qtable_offset[m] != sp->qtable_offset[m - 1])))
- {
- for (n = 0; n < m - 1; n++)
- {
- if (sp->qtable_offset[m] == sp->qtable_offset[n])
- {
- TIFFErrorExtR(tif, module, "Corrupt JpegQTables tag value");
- return (0);
- }
- }
- oa = sizeof(uint32_t) + 69;
- ob = _TIFFmallocExt(tif, oa);
- if (ob == 0)
- {
- TIFFErrorExtR(tif, module, "Out of memory");
- return (0);
- }
- *(uint32_t *)ob = oa;
- ob[sizeof(uint32_t)] = 255;
- ob[sizeof(uint32_t) + 1] = JPEG_MARKER_DQT;
- ob[sizeof(uint32_t) + 2] = 0;
- ob[sizeof(uint32_t) + 3] = 67;
- ob[sizeof(uint32_t) + 4] = m;
- TIFFSeekFile(tif, sp->qtable_offset[m], SEEK_SET);
- p = (uint32_t)TIFFReadFile(tif, &ob[sizeof(uint32_t) + 5], 64);
- if (p != 64)
- {
- _TIFFfreeExt(tif, ob);
- return (0);
- }
- if (sp->qtable[m] != 0)
- _TIFFfreeExt(tif, sp->qtable[m]);
- sp->qtable[m] = ob;
- sp->sof_tq[m] = m;
- }
- else
- sp->sof_tq[m] = sp->sof_tq[m - 1];
- }
- return (1);
-}
-
-static int OJPEGReadHeaderInfoSecTablesDcTable(TIFF *tif)
-{
- static const char module[] = "OJPEGReadHeaderInfoSecTablesDcTable";
- OJPEGState *sp = (OJPEGState *)tif->tif_data;
- uint8_t m;
- uint8_t n;
- uint8_t o[16];
- uint32_t p;
- uint32_t q;
- uint32_t ra;
- uint8_t *rb;
- if (sp->dctable_offset[0] == 0)
- {
- TIFFErrorExtR(tif, module, "Missing JPEG tables");
- return (0);
- }
- sp->in_buffer_file_pos_log = 0;
- for (m = 0; m < sp->samples_per_pixel; m++)
- {
- if ((sp->dctable_offset[m] != 0) &&
- ((m == 0) || (sp->dctable_offset[m] != sp->dctable_offset[m - 1])))
- {
- for (n = 0; n < m - 1; n++)
- {
- if (sp->dctable_offset[m] == sp->dctable_offset[n])
- {
- TIFFErrorExtR(tif, module,
- "Corrupt JpegDcTables tag value");
- return (0);
- }
- }
- TIFFSeekFile(tif, sp->dctable_offset[m], SEEK_SET);
- p = (uint32_t)TIFFReadFile(tif, o, 16);
- if (p != 16)
- return (0);
- q = 0;
- for (n = 0; n < 16; n++)
- q += o[n];
- ra = sizeof(uint32_t) + 21 + q;
- rb = _TIFFmallocExt(tif, ra);
- if (rb == 0)
- {
- TIFFErrorExtR(tif, module, "Out of memory");
- return (0);
- }
- *(uint32_t *)rb = ra;
- rb[sizeof(uint32_t)] = 255;
- rb[sizeof(uint32_t) + 1] = JPEG_MARKER_DHT;
- rb[sizeof(uint32_t) + 2] = (uint8_t)((19 + q) >> 8);
- rb[sizeof(uint32_t) + 3] = ((19 + q) & 255);
- rb[sizeof(uint32_t) + 4] = m;
- for (n = 0; n < 16; n++)
- rb[sizeof(uint32_t) + 5 + n] = o[n];
- p = (uint32_t)TIFFReadFile(tif, &(rb[sizeof(uint32_t) + 21]), q);
- if (p != q)
- {
- _TIFFfreeExt(tif, rb);
- return (0);
- }
- if (sp->dctable[m] != 0)
- _TIFFfreeExt(tif, sp->dctable[m]);
- sp->dctable[m] = rb;
- sp->sos_tda[m] = (m << 4);
- }
- else
- sp->sos_tda[m] = sp->sos_tda[m - 1];
- }
- return (1);
-}
-
-static int OJPEGReadHeaderInfoSecTablesAcTable(TIFF *tif)
-{
- static const char module[] = "OJPEGReadHeaderInfoSecTablesAcTable";
- OJPEGState *sp = (OJPEGState *)tif->tif_data;
- uint8_t m;
- uint8_t n;
- uint8_t o[16];
- uint32_t p;
- uint32_t q;
- uint32_t ra;
- uint8_t *rb;
- if (sp->actable_offset[0] == 0)
- {
- TIFFErrorExtR(tif, module, "Missing JPEG tables");
- return (0);
- }
- sp->in_buffer_file_pos_log = 0;
- for (m = 0; m < sp->samples_per_pixel; m++)
- {
- if ((sp->actable_offset[m] != 0) &&
- ((m == 0) || (sp->actable_offset[m] != sp->actable_offset[m - 1])))
- {
- for (n = 0; n < m - 1; n++)
- {
- if (sp->actable_offset[m] == sp->actable_offset[n])
- {
- TIFFErrorExtR(tif, module,
- "Corrupt JpegAcTables tag value");
- return (0);
- }
- }
- TIFFSeekFile(tif, sp->actable_offset[m], SEEK_SET);
- p = (uint32_t)TIFFReadFile(tif, o, 16);
- if (p != 16)
- return (0);
- q = 0;
- for (n = 0; n < 16; n++)
- q += o[n];
- ra = sizeof(uint32_t) + 21 + q;
- rb = _TIFFmallocExt(tif, ra);
- if (rb == 0)
- {
- TIFFErrorExtR(tif, module, "Out of memory");
- return (0);
- }
- *(uint32_t *)rb = ra;
- rb[sizeof(uint32_t)] = 255;
- rb[sizeof(uint32_t) + 1] = JPEG_MARKER_DHT;
- rb[sizeof(uint32_t) + 2] = (uint8_t)((19 + q) >> 8);
- rb[sizeof(uint32_t) + 3] = ((19 + q) & 255);
- rb[sizeof(uint32_t) + 4] = (16 | m);
- for (n = 0; n < 16; n++)
- rb[sizeof(uint32_t) + 5 + n] = o[n];
- p = (uint32_t)TIFFReadFile(tif, &(rb[sizeof(uint32_t) + 21]), q);
- if (p != q)
- {
- _TIFFfreeExt(tif, rb);
- return (0);
- }
- if (sp->actable[m] != 0)
- _TIFFfreeExt(tif, sp->actable[m]);
- sp->actable[m] = rb;
- sp->sos_tda[m] = (sp->sos_tda[m] | m);
- }
- else
- sp->sos_tda[m] = (sp->sos_tda[m] | (sp->sos_tda[m - 1] & 15));
- }
- return (1);
-}
-
-static int OJPEGReadBufferFill(OJPEGState *sp)
-{
- uint16_t m;
- tmsize_t n;
- /* TODO: double-check: when subsamplingcorrect is set, no call to
- * TIFFErrorExt or TIFFWarningExt should be made in any other case, seek or
- * read errors should be passed through */
- do
- {
- if (sp->in_buffer_file_togo != 0)
- {
- if (sp->in_buffer_file_pos_log == 0)
- {
- TIFFSeekFile(sp->tif, sp->in_buffer_file_pos, SEEK_SET);
- sp->in_buffer_file_pos_log = 1;
- }
- m = OJPEG_BUFFER;
- if ((uint64_t)m > sp->in_buffer_file_togo)
- m = (uint16_t)sp->in_buffer_file_togo;
- n = TIFFReadFile(sp->tif, sp->in_buffer, (tmsize_t)m);
- if (n == 0)
- return (0);
- assert(n > 0);
- assert(n <= OJPEG_BUFFER);
- assert(n < 65536);
- assert((uint64_t)n <= sp->in_buffer_file_togo);
- m = (uint16_t)n;
- sp->in_buffer_togo = m;
- sp->in_buffer_cur = sp->in_buffer;
- sp->in_buffer_file_togo -= m;
- sp->in_buffer_file_pos += m;
- break;
- }
- sp->in_buffer_file_pos_log = 0;
- switch (sp->in_buffer_source)
- {
- case osibsNotSetYet:
- if (sp->jpeg_interchange_format != 0)
- {
- sp->in_buffer_file_pos = sp->jpeg_interchange_format;
- sp->in_buffer_file_togo =
- sp->jpeg_interchange_format_length;
- }
- sp->in_buffer_source = osibsJpegInterchangeFormat;
- break;
- case osibsJpegInterchangeFormat:
- sp->in_buffer_source = osibsStrile;
- break;
- case osibsStrile:
- if (sp->in_buffer_next_strile == sp->in_buffer_strile_count)
- sp->in_buffer_source = osibsEof;
- else
- {
- int err = 0;
- sp->in_buffer_file_pos = TIFFGetStrileOffsetWithErr(
- sp->tif, sp->in_buffer_next_strile, &err);
- if (err)
- return 0;
- if (sp->in_buffer_file_pos != 0)
- {
- uint64_t bytecount = TIFFGetStrileByteCountWithErr(
- sp->tif, sp->in_buffer_next_strile, &err);
- if (err)
- return 0;
- if (sp->in_buffer_file_pos >= sp->file_size)
- sp->in_buffer_file_pos = 0;
- else if (bytecount == 0)
- sp->in_buffer_file_togo =
- sp->file_size - sp->in_buffer_file_pos;
- else
- {
- sp->in_buffer_file_togo = bytecount;
- if (sp->in_buffer_file_togo == 0)
- sp->in_buffer_file_pos = 0;
- else if (sp->in_buffer_file_pos >
- UINT64_MAX - sp->in_buffer_file_togo ||
- sp->in_buffer_file_pos +
- sp->in_buffer_file_togo >
- sp->file_size)
- sp->in_buffer_file_togo =
- sp->file_size - sp->in_buffer_file_pos;
- }
- }
- sp->in_buffer_next_strile++;
- }
- break;
- default:
- return (0);
- }
- } while (1);
- return (1);
-}
-
-static int OJPEGReadByte(OJPEGState *sp, uint8_t *byte)
-{
- if (sp->in_buffer_togo == 0)
- {
- if (OJPEGReadBufferFill(sp) == 0)
- return (0);
- assert(sp->in_buffer_togo > 0);
- }
- *byte = *(sp->in_buffer_cur);
- sp->in_buffer_cur++;
- sp->in_buffer_togo--;
- return (1);
-}
-
-static int OJPEGReadBytePeek(OJPEGState *sp, uint8_t *byte)
-{
- if (sp->in_buffer_togo == 0)
- {
- if (OJPEGReadBufferFill(sp) == 0)
- return (0);
- assert(sp->in_buffer_togo > 0);
- }
- *byte = *(sp->in_buffer_cur);
- return (1);
-}
-
-static void OJPEGReadByteAdvance(OJPEGState *sp)
-{
- assert(sp->in_buffer_togo > 0);
- sp->in_buffer_cur++;
- sp->in_buffer_togo--;
-}
-
-static int OJPEGReadWord(OJPEGState *sp, uint16_t *word)
-{
- uint8_t m;
- if (OJPEGReadByte(sp, &m) == 0)
- return (0);
- *word = (m << 8);
- if (OJPEGReadByte(sp, &m) == 0)
- return (0);
- *word |= m;
- return (1);
-}
-
-static int OJPEGReadBlock(OJPEGState *sp, uint16_t len, void *mem)
-{
- uint16_t mlen;
- uint8_t *mmem;
- uint16_t n;
- assert(len > 0);
- mlen = len;
- mmem = mem;
- do
- {
- if (sp->in_buffer_togo == 0)
- {
- if (OJPEGReadBufferFill(sp) == 0)
- return (0);
- assert(sp->in_buffer_togo > 0);
- }
- n = mlen;
- if (n > sp->in_buffer_togo)
- n = sp->in_buffer_togo;
- _TIFFmemcpy(mmem, sp->in_buffer_cur, n);
- sp->in_buffer_cur += n;
- sp->in_buffer_togo -= n;
- mlen -= n;
- mmem += n;
- } while (mlen > 0);
- return (1);
-}
-
-static void OJPEGReadSkip(OJPEGState *sp, uint16_t len)
-{
- uint16_t m;
- uint16_t n;
- m = len;
- n = m;
- if (n > sp->in_buffer_togo)
- n = sp->in_buffer_togo;
- sp->in_buffer_cur += n;
- sp->in_buffer_togo -= n;
- m -= n;
- if (m > 0)
- {
- assert(sp->in_buffer_togo == 0);
- n = m;
- if ((uint64_t)n > sp->in_buffer_file_togo)
- n = (uint16_t)sp->in_buffer_file_togo;
- sp->in_buffer_file_pos += n;
- sp->in_buffer_file_togo -= n;
- sp->in_buffer_file_pos_log = 0;
- /* we don't skip past jpeginterchangeformat/strile block...
- * if that is asked from us, we're dealing with totally bazurk
- * data anyway, and we've not seen this happening on any
- * testfile, so we might as well likely cause some other
- * meaningless error to be passed at some later time
- */
- }
-}
-
-static int OJPEGWriteStream(TIFF *tif, void **mem, uint32_t *len)
-{
- OJPEGState *sp = (OJPEGState *)tif->tif_data;
- *len = 0;
- do
- {
- assert(sp->out_state <= ososEoi);
- switch (sp->out_state)
- {
- case ososSoi:
- OJPEGWriteStreamSoi(tif, mem, len);
- break;
- case ososQTable0:
- OJPEGWriteStreamQTable(tif, 0, mem, len);
- break;
- case ososQTable1:
- OJPEGWriteStreamQTable(tif, 1, mem, len);
- break;
- case ososQTable2:
- OJPEGWriteStreamQTable(tif, 2, mem, len);
- break;
- case ososQTable3:
- OJPEGWriteStreamQTable(tif, 3, mem, len);
- break;
- case ososDcTable0:
- OJPEGWriteStreamDcTable(tif, 0, mem, len);
- break;
- case ososDcTable1:
- OJPEGWriteStreamDcTable(tif, 1, mem, len);
- break;
- case ososDcTable2:
- OJPEGWriteStreamDcTable(tif, 2, mem, len);
- break;
- case ososDcTable3:
- OJPEGWriteStreamDcTable(tif, 3, mem, len);
- break;
- case ososAcTable0:
- OJPEGWriteStreamAcTable(tif, 0, mem, len);
- break;
- case ososAcTable1:
- OJPEGWriteStreamAcTable(tif, 1, mem, len);
- break;
- case ososAcTable2:
- OJPEGWriteStreamAcTable(tif, 2, mem, len);
- break;
- case ososAcTable3:
- OJPEGWriteStreamAcTable(tif, 3, mem, len);
- break;
- case ososDri:
- OJPEGWriteStreamDri(tif, mem, len);
- break;
- case ososSof:
- OJPEGWriteStreamSof(tif, mem, len);
- break;
- case ososSos:
- OJPEGWriteStreamSos(tif, mem, len);
- break;
- case ososCompressed:
- if (OJPEGWriteStreamCompressed(tif, mem, len) == 0)
- return (0);
- break;
- case ososRst:
- OJPEGWriteStreamRst(tif, mem, len);
- break;
- case ososEoi:
- OJPEGWriteStreamEoi(tif, mem, len);
- break;
- }
- } while (*len == 0);
- return (1);
-}
-
-static void OJPEGWriteStreamSoi(TIFF *tif, void **mem, uint32_t *len)
-{
- OJPEGState *sp = (OJPEGState *)tif->tif_data;
- assert(OJPEG_BUFFER >= 2);
- sp->out_buffer[0] = 255;
- sp->out_buffer[1] = JPEG_MARKER_SOI;
- *len = 2;
- *mem = (void *)sp->out_buffer;
- sp->out_state++;
-}
-
-static void OJPEGWriteStreamQTable(TIFF *tif, uint8_t table_index, void **mem,
- uint32_t *len)
-{
- OJPEGState *sp = (OJPEGState *)tif->tif_data;
- if (sp->qtable[table_index] != 0)
- {
- *mem = (void *)(sp->qtable[table_index] + sizeof(uint32_t));
- *len = *((uint32_t *)sp->qtable[table_index]) - sizeof(uint32_t);
- }
- sp->out_state++;
-}
-
-static void OJPEGWriteStreamDcTable(TIFF *tif, uint8_t table_index, void **mem,
- uint32_t *len)
-{
- OJPEGState *sp = (OJPEGState *)tif->tif_data;
- if (sp->dctable[table_index] != 0)
- {
- *mem = (void *)(sp->dctable[table_index] + sizeof(uint32_t));
- *len = *((uint32_t *)sp->dctable[table_index]) - sizeof(uint32_t);
- }
- sp->out_state++;
-}
-
-static void OJPEGWriteStreamAcTable(TIFF *tif, uint8_t table_index, void **mem,
- uint32_t *len)
-{
- OJPEGState *sp = (OJPEGState *)tif->tif_data;
- if (sp->actable[table_index] != 0)
- {
- *mem = (void *)(sp->actable[table_index] + sizeof(uint32_t));
- *len = *((uint32_t *)sp->actable[table_index]) - sizeof(uint32_t);
- }
- sp->out_state++;
-}
-
-static void OJPEGWriteStreamDri(TIFF *tif, void **mem, uint32_t *len)
-{
- OJPEGState *sp = (OJPEGState *)tif->tif_data;
- assert(OJPEG_BUFFER >= 6);
- if (sp->restart_interval != 0)
- {
- sp->out_buffer[0] = 255;
- sp->out_buffer[1] = JPEG_MARKER_DRI;
- sp->out_buffer[2] = 0;
- sp->out_buffer[3] = 4;
- sp->out_buffer[4] = (sp->restart_interval >> 8);
- sp->out_buffer[5] = (sp->restart_interval & 255);
- *len = 6;
- *mem = (void *)sp->out_buffer;
- }
- sp->out_state++;
-}
-
-static void OJPEGWriteStreamSof(TIFF *tif, void **mem, uint32_t *len)
-{
- OJPEGState *sp = (OJPEGState *)tif->tif_data;
- uint8_t m;
- assert(OJPEG_BUFFER >= 2 + 8 + sp->samples_per_pixel_per_plane * 3);
- assert(255 >= 8 + sp->samples_per_pixel_per_plane * 3);
- sp->out_buffer[0] = 255;
- sp->out_buffer[1] = sp->sof_marker_id;
- /* Lf */
- sp->out_buffer[2] = 0;
- sp->out_buffer[3] = 8 + sp->samples_per_pixel_per_plane * 3;
- /* P */
- sp->out_buffer[4] = 8;
- /* Y */
- sp->out_buffer[5] = (uint8_t)(sp->sof_y >> 8);
- sp->out_buffer[6] = (sp->sof_y & 255);
- /* X */
- sp->out_buffer[7] = (uint8_t)(sp->sof_x >> 8);
- sp->out_buffer[8] = (sp->sof_x & 255);
- /* Nf */
- sp->out_buffer[9] = sp->samples_per_pixel_per_plane;
- for (m = 0; m < sp->samples_per_pixel_per_plane; m++)
- {
- /* C */
- sp->out_buffer[10 + m * 3] = sp->sof_c[sp->plane_sample_offset + m];
- /* H and V */
- sp->out_buffer[10 + m * 3 + 1] =
- sp->sof_hv[sp->plane_sample_offset + m];
- /* Tq */
- sp->out_buffer[10 + m * 3 + 2] =
- sp->sof_tq[sp->plane_sample_offset + m];
- }
- *len = 10 + sp->samples_per_pixel_per_plane * 3;
- *mem = (void *)sp->out_buffer;
- sp->out_state++;
-}
-
-static void OJPEGWriteStreamSos(TIFF *tif, void **mem, uint32_t *len)
-{
- OJPEGState *sp = (OJPEGState *)tif->tif_data;
- uint8_t m;
- assert(OJPEG_BUFFER >= 2 + 6 + sp->samples_per_pixel_per_plane * 2);
- assert(255 >= 6 + sp->samples_per_pixel_per_plane * 2);
- sp->out_buffer[0] = 255;
- sp->out_buffer[1] = JPEG_MARKER_SOS;
- /* Ls */
- sp->out_buffer[2] = 0;
- sp->out_buffer[3] = 6 + sp->samples_per_pixel_per_plane * 2;
- /* Ns */
- sp->out_buffer[4] = sp->samples_per_pixel_per_plane;
- for (m = 0; m < sp->samples_per_pixel_per_plane; m++)
- {
- /* Cs */
- sp->out_buffer[5 + m * 2] = sp->sos_cs[sp->plane_sample_offset + m];
- /* Td and Ta */
- sp->out_buffer[5 + m * 2 + 1] =
- sp->sos_tda[sp->plane_sample_offset + m];
- }
- /* Ss */
- sp->out_buffer[5 + sp->samples_per_pixel_per_plane * 2] = 0;
- /* Se */
- sp->out_buffer[5 + sp->samples_per_pixel_per_plane * 2 + 1] = 63;
- /* Ah and Al */
- sp->out_buffer[5 + sp->samples_per_pixel_per_plane * 2 + 2] = 0;
- *len = 8 + sp->samples_per_pixel_per_plane * 2;
- *mem = (void *)sp->out_buffer;
- sp->out_state++;
-}
-
-static int OJPEGWriteStreamCompressed(TIFF *tif, void **mem, uint32_t *len)
-{
- OJPEGState *sp = (OJPEGState *)tif->tif_data;
- if (sp->in_buffer_togo == 0)
- {
- if (OJPEGReadBufferFill(sp) == 0)
- return (0);
- assert(sp->in_buffer_togo > 0);
- }
- *len = sp->in_buffer_togo;
- *mem = (void *)sp->in_buffer_cur;
- sp->in_buffer_togo = 0;
- if (sp->in_buffer_file_togo == 0)
- {
- switch (sp->in_buffer_source)
- {
- case osibsStrile:
- if (sp->in_buffer_next_strile < sp->in_buffer_strile_count)
- sp->out_state = ososRst;
- else
- sp->out_state = ososEoi;
- break;
- case osibsEof:
- sp->out_state = ososEoi;
- break;
- default:
- break;
- }
- }
- return (1);
-}
-
-static void OJPEGWriteStreamRst(TIFF *tif, void **mem, uint32_t *len)
-{
- OJPEGState *sp = (OJPEGState *)tif->tif_data;
- assert(OJPEG_BUFFER >= 2);
- sp->out_buffer[0] = 255;
- sp->out_buffer[1] = JPEG_MARKER_RST0 + sp->restart_index;
- sp->restart_index++;
- if (sp->restart_index == 8)
- sp->restart_index = 0;
- *len = 2;
- *mem = (void *)sp->out_buffer;
- sp->out_state = ososCompressed;
-}
-
-static void OJPEGWriteStreamEoi(TIFF *tif, void **mem, uint32_t *len)
-{
- OJPEGState *sp = (OJPEGState *)tif->tif_data;
- assert(OJPEG_BUFFER >= 2);
- sp->out_buffer[0] = 255;
- sp->out_buffer[1] = JPEG_MARKER_EOI;
- *len = 2;
- *mem = (void *)sp->out_buffer;
-}
-
-#ifndef LIBJPEG_ENCAP_EXTERNAL
-static int jpeg_create_decompress_encap(OJPEGState *sp,
- jpeg_decompress_struct *cinfo)
-{
- if (SETJMP(sp->exit_jmpbuf))
- return 0;
- else
- {
- jpeg_create_decompress(cinfo);
- return 1;
- }
-}
-#endif
-
-#ifndef LIBJPEG_ENCAP_EXTERNAL
-static int jpeg_read_header_encap(OJPEGState *sp, jpeg_decompress_struct *cinfo,
- uint8_t require_image)
-{
- if (SETJMP(sp->exit_jmpbuf))
- return 0;
- else
- {
- jpeg_read_header(cinfo, require_image);
- return 1;
- }
-}
-#endif
-
-#ifndef LIBJPEG_ENCAP_EXTERNAL
-static int jpeg_start_decompress_encap(OJPEGState *sp,
- jpeg_decompress_struct *cinfo)
-{
- if (SETJMP(sp->exit_jmpbuf))
- return 0;
- else
- {
- jpeg_start_decompress(cinfo);
- return 1;
- }
-}
-#endif
-
-#ifndef LIBJPEG_ENCAP_EXTERNAL
-static int jpeg_read_scanlines_encap(OJPEGState *sp,
- jpeg_decompress_struct *cinfo,
- void *scanlines, uint32_t max_lines)
-{
- if (SETJMP(sp->exit_jmpbuf))
- return 0;
- else
- {
- jpeg_read_scanlines(cinfo, scanlines, max_lines);
- return 1;
- }
-}
-#endif
-
-#ifndef LIBJPEG_ENCAP_EXTERNAL
-static int jpeg_read_raw_data_encap(OJPEGState *sp,
- jpeg_decompress_struct *cinfo, void *data,
- uint32_t max_lines)
-{
- if (SETJMP(sp->exit_jmpbuf))
- return 0;
- else
- {
- jpeg_read_raw_data(cinfo, data, max_lines);
- return 1;
- }
-}
-#endif
-
-#ifndef LIBJPEG_ENCAP_EXTERNAL
-static void jpeg_encap_unwind(TIFF *tif)
-{
- OJPEGState *sp = (OJPEGState *)tif->tif_data;
- LONGJMP(sp->exit_jmpbuf, 1);
-}
-#endif
-
-static void OJPEGLibjpegJpegErrorMgrOutputMessage(jpeg_common_struct *cinfo)
-{
- char buffer[JMSG_LENGTH_MAX];
- (*cinfo->err->format_message)(cinfo, buffer);
- TIFFWarningExtR(((TIFF *)(cinfo->client_data)), "LibJpeg", "%s", buffer);
-}
-
-static void OJPEGLibjpegJpegErrorMgrErrorExit(jpeg_common_struct *cinfo)
-{
- char buffer[JMSG_LENGTH_MAX];
- (*cinfo->err->format_message)(cinfo, buffer);
- TIFFErrorExtR(((TIFF *)(cinfo->client_data)), "LibJpeg", "%s", buffer);
- jpeg_encap_unwind((TIFF *)(cinfo->client_data));
-}
-
-static void OJPEGLibjpegJpegSourceMgrInitSource(jpeg_decompress_struct *cinfo)
-{
- (void)cinfo;
-}
-
-static boolean
-OJPEGLibjpegJpegSourceMgrFillInputBuffer(jpeg_decompress_struct *cinfo)
-{
- TIFF *tif = (TIFF *)cinfo->client_data;
- OJPEGState *sp = (OJPEGState *)tif->tif_data;
- void *mem = 0;
- uint32_t len = 0U;
- if (OJPEGWriteStream(tif, &mem, &len) == 0)
- {
- TIFFErrorExtR(tif, "LibJpeg", "Premature end of JPEG data");
- jpeg_encap_unwind(tif);
- }
- sp->libjpeg_jpeg_source_mgr.bytes_in_buffer = len;
- sp->libjpeg_jpeg_source_mgr.next_input_byte = mem;
- return (1);
-}
-
-static void
-OJPEGLibjpegJpegSourceMgrSkipInputData(jpeg_decompress_struct *cinfo,
- long num_bytes)
-{
- TIFF *tif = (TIFF *)cinfo->client_data;
- (void)num_bytes;
- TIFFErrorExtR(tif, "LibJpeg", "Unexpected error");
- jpeg_encap_unwind(tif);
-}
-
-#ifdef _MSC_VER
-#pragma warning(push)
-#pragma warning(disable : 4702) /* unreachable code */
-#endif
-static boolean
-OJPEGLibjpegJpegSourceMgrResyncToRestart(jpeg_decompress_struct *cinfo,
- int desired)
-{
- TIFF *tif = (TIFF *)cinfo->client_data;
- (void)desired;
- TIFFErrorExtR(tif, "LibJpeg", "Unexpected error");
- jpeg_encap_unwind(tif);
- return (0);
-}
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif
-
-static void OJPEGLibjpegJpegSourceMgrTermSource(jpeg_decompress_struct *cinfo)
-{
- (void)cinfo;
-}
-
-#endif
diff --git a/contrib/libs/libtiff/tif_open.c b/contrib/libs/libtiff/tif_open.c
deleted file mode 100644
index 59a07bee02..0000000000
--- a/contrib/libs/libtiff/tif_open.c
+++ /dev/null
@@ -1,935 +0,0 @@
-/*
- * Copyright (c) 1988-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-/*
- * TIFF Library.
- */
-
-#ifdef TIFF_DO_NOT_USE_NON_EXT_ALLOC_FUNCTIONS
-#undef TIFF_DO_NOT_USE_NON_EXT_ALLOC_FUNCTIONS
-#endif
-
-#include "tiffiop.h"
-#include <assert.h>
-#include <limits.h>
-
-/*
- * Dummy functions to fill the omitted client procedures.
- */
-static int _tiffDummyMapProc(thandle_t fd, void **pbase, toff_t *psize)
-{
- (void)fd;
- (void)pbase;
- (void)psize;
- return (0);
-}
-
-static void _tiffDummyUnmapProc(thandle_t fd, void *base, toff_t size)
-{
- (void)fd;
- (void)base;
- (void)size;
-}
-
-int _TIFFgetMode(TIFFOpenOptions *opts, thandle_t clientdata, const char *mode,
- const char *module)
-{
- int m = -1;
-
- switch (mode[0])
- {
- case 'r':
- m = O_RDONLY;
- if (mode[1] == '+')
- m = O_RDWR;
- break;
- case 'w':
- case 'a':
- m = O_RDWR | O_CREAT;
- if (mode[0] == 'w')
- m |= O_TRUNC;
- break;
- default:
- _TIFFErrorEarly(opts, clientdata, module, "\"%s\": Bad mode", mode);
- break;
- }
- return (m);
-}
-
-TIFFOpenOptions *TIFFOpenOptionsAlloc()
-{
- TIFFOpenOptions *opts =
- (TIFFOpenOptions *)_TIFFcalloc(1, sizeof(TIFFOpenOptions));
- return opts;
-}
-
-void TIFFOpenOptionsFree(TIFFOpenOptions *opts) { _TIFFfree(opts); }
-
-/** Define a limit in bytes for a single memory allocation done by libtiff.
- * If max_single_mem_alloc is set to 0, which is the default, no other limit
- * that the underlying _TIFFmalloc() or
- * TIFFOpenOptionsSetMaxCumulatedMemAlloc() will be applied.
- */
-void TIFFOpenOptionsSetMaxSingleMemAlloc(TIFFOpenOptions *opts,
- tmsize_t max_single_mem_alloc)
-{
- opts->max_single_mem_alloc = max_single_mem_alloc;
-}
-
-/** Define a limit in bytes for the cumulated memory allocations done by libtiff
- * on a given TIFF handle.
- * If max_cumulated_mem_alloc is set to 0, which is the default, no other limit
- * that the underlying _TIFFmalloc() or
- * TIFFOpenOptionsSetMaxSingleMemAlloc() will be applied.
- */
-void TIFFOpenOptionsSetMaxCumulatedMemAlloc(TIFFOpenOptions *opts,
- tmsize_t max_cumulated_mem_alloc)
-{
- opts->max_cumulated_mem_alloc = max_cumulated_mem_alloc;
-}
-
-void TIFFOpenOptionsSetErrorHandlerExtR(TIFFOpenOptions *opts,
- TIFFErrorHandlerExtR handler,
- void *errorhandler_user_data)
-{
- opts->errorhandler = handler;
- opts->errorhandler_user_data = errorhandler_user_data;
-}
-
-void TIFFOpenOptionsSetWarningHandlerExtR(TIFFOpenOptions *opts,
- TIFFErrorHandlerExtR handler,
- void *warnhandler_user_data)
-{
- opts->warnhandler = handler;
- opts->warnhandler_user_data = warnhandler_user_data;
-}
-
-static void _TIFFEmitErrorAboveMaxSingleMemAlloc(TIFF *tif,
- const char *pszFunction,
- tmsize_t s)
-{
- TIFFErrorExtR(tif, pszFunction,
- "Memory allocation of %" PRIu64
- " bytes is beyond the %" PRIu64
- " byte limit defined in open options",
- (uint64_t)s, (uint64_t)tif->tif_max_single_mem_alloc);
-}
-
-static void _TIFFEmitErrorAboveMaxCumulatedMemAlloc(TIFF *tif,
- const char *pszFunction,
- tmsize_t s)
-{
- TIFFErrorExtR(tif, pszFunction,
- "Cumulated memory allocation of %" PRIu64 " + %" PRIu64
- " bytes is beyond the %" PRIu64
- " cumulated byte limit defined in open options",
- (uint64_t)tif->tif_cur_cumulated_mem_alloc, (uint64_t)s,
- (uint64_t)tif->tif_max_cumulated_mem_alloc);
-}
-
-/* When allocating memory, we write at the beginning of the buffer it size.
- * This allows us to keep track of the total memory allocated when we
- * malloc/calloc/realloc and free. In theory we need just SIZEOF_SIZE_T bytes
- * for that, but on x86_64, allocations of more than 16 bytes are aligned on
- * 16 bytes. Hence using 2 * SIZEOF_SIZE_T.
- * It is critical that _TIFFmallocExt/_TIFFcallocExt/_TIFFreallocExt are
- * paired with _TIFFfreeExt.
- * CMakeLists.txt defines TIFF_DO_NOT_USE_NON_EXT_ALLOC_FUNCTIONS, which in
- * turn disables the definition of the non Ext version in tiffio.h
- */
-#define LEADING_AREA_TO_STORE_ALLOC_SIZE (2 * SIZEOF_SIZE_T)
-
-/** malloc() version that takes into account memory-specific open options */
-void *_TIFFmallocExt(TIFF *tif, tmsize_t s)
-{
- if (tif != NULL && tif->tif_max_single_mem_alloc > 0 &&
- s > tif->tif_max_single_mem_alloc)
- {
- _TIFFEmitErrorAboveMaxSingleMemAlloc(tif, "_TIFFmallocExt", s);
- return NULL;
- }
- if (tif != NULL && tif->tif_max_cumulated_mem_alloc > 0)
- {
- if (s > tif->tif_max_cumulated_mem_alloc -
- tif->tif_cur_cumulated_mem_alloc ||
- s > TIFF_TMSIZE_T_MAX - LEADING_AREA_TO_STORE_ALLOC_SIZE)
- {
- _TIFFEmitErrorAboveMaxCumulatedMemAlloc(tif, "_TIFFmallocExt", s);
- return NULL;
- }
- void *ptr = _TIFFmalloc(LEADING_AREA_TO_STORE_ALLOC_SIZE + s);
- if (!ptr)
- return NULL;
- tif->tif_cur_cumulated_mem_alloc += s;
- memcpy(ptr, &s, sizeof(s));
- return (char *)ptr + LEADING_AREA_TO_STORE_ALLOC_SIZE;
- }
- return _TIFFmalloc(s);
-}
-
-/** calloc() version that takes into account memory-specific open options */
-void *_TIFFcallocExt(TIFF *tif, tmsize_t nmemb, tmsize_t siz)
-{
- if (nmemb <= 0 || siz <= 0 || nmemb > TIFF_TMSIZE_T_MAX / siz)
- return NULL;
- if (tif != NULL && tif->tif_max_single_mem_alloc > 0)
- {
- if (nmemb * siz > tif->tif_max_single_mem_alloc)
- {
- _TIFFEmitErrorAboveMaxSingleMemAlloc(tif, "_TIFFcallocExt",
- nmemb * siz);
- return NULL;
- }
- }
- if (tif != NULL && tif->tif_max_cumulated_mem_alloc > 0)
- {
- const tmsize_t s = nmemb * siz;
- if (s > tif->tif_max_cumulated_mem_alloc -
- tif->tif_cur_cumulated_mem_alloc ||
- s > TIFF_TMSIZE_T_MAX - LEADING_AREA_TO_STORE_ALLOC_SIZE)
- {
- _TIFFEmitErrorAboveMaxCumulatedMemAlloc(tif, "_TIFFcallocExt", s);
- return NULL;
- }
- void *ptr = _TIFFcalloc(LEADING_AREA_TO_STORE_ALLOC_SIZE + s, 1);
- if (!ptr)
- return NULL;
- tif->tif_cur_cumulated_mem_alloc += s;
- memcpy(ptr, &s, sizeof(s));
- return (char *)ptr + LEADING_AREA_TO_STORE_ALLOC_SIZE;
- }
- return _TIFFcalloc(nmemb, siz);
-}
-
-/** realloc() version that takes into account memory-specific open options */
-void *_TIFFreallocExt(TIFF *tif, void *p, tmsize_t s)
-{
- if (tif != NULL && tif->tif_max_single_mem_alloc > 0 &&
- s > tif->tif_max_single_mem_alloc)
- {
- _TIFFEmitErrorAboveMaxSingleMemAlloc(tif, "_TIFFreallocExt", s);
- return NULL;
- }
- if (tif != NULL && tif->tif_max_cumulated_mem_alloc > 0)
- {
- void *oldPtr = p;
- tmsize_t oldSize = 0;
- if (p)
- {
- oldPtr = (char *)p - LEADING_AREA_TO_STORE_ALLOC_SIZE;
- memcpy(&oldSize, oldPtr, sizeof(oldSize));
- assert(oldSize <= tif->tif_cur_cumulated_mem_alloc);
- }
- if (s > oldSize &&
- (s > tif->tif_max_cumulated_mem_alloc -
- (tif->tif_cur_cumulated_mem_alloc - oldSize) ||
- s > TIFF_TMSIZE_T_MAX - LEADING_AREA_TO_STORE_ALLOC_SIZE))
- {
- _TIFFEmitErrorAboveMaxCumulatedMemAlloc(tif, "_TIFFreallocExt",
- s - oldSize);
- return NULL;
- }
- void *newPtr =
- _TIFFrealloc(oldPtr, LEADING_AREA_TO_STORE_ALLOC_SIZE + s);
- if (newPtr == NULL)
- return NULL;
- tif->tif_cur_cumulated_mem_alloc -= oldSize;
- tif->tif_cur_cumulated_mem_alloc += s;
- memcpy(newPtr, &s, sizeof(s));
- return (char *)newPtr + LEADING_AREA_TO_STORE_ALLOC_SIZE;
- }
- return _TIFFrealloc(p, s);
-}
-
-/** free() version that takes into account memory-specific open options */
-void _TIFFfreeExt(TIFF *tif, void *p)
-{
- if (p != NULL && tif != NULL && tif->tif_max_cumulated_mem_alloc > 0)
- {
- void *oldPtr = (char *)p - LEADING_AREA_TO_STORE_ALLOC_SIZE;
- tmsize_t oldSize;
- memcpy(&oldSize, oldPtr, sizeof(oldSize));
- assert(oldSize <= tif->tif_cur_cumulated_mem_alloc);
- tif->tif_cur_cumulated_mem_alloc -= oldSize;
- p = oldPtr;
- }
- _TIFFfree(p);
-}
-
-TIFF *TIFFClientOpen(const char *name, const char *mode, thandle_t clientdata,
- TIFFReadWriteProc readproc, TIFFReadWriteProc writeproc,
- TIFFSeekProc seekproc, TIFFCloseProc closeproc,
- TIFFSizeProc sizeproc, TIFFMapFileProc mapproc,
- TIFFUnmapFileProc unmapproc)
-{
- return TIFFClientOpenExt(name, mode, clientdata, readproc, writeproc,
- seekproc, closeproc, sizeproc, mapproc, unmapproc,
- NULL);
-}
-
-TIFF *TIFFClientOpenExt(const char *name, const char *mode,
- thandle_t clientdata, TIFFReadWriteProc readproc,
- TIFFReadWriteProc writeproc, TIFFSeekProc seekproc,
- TIFFCloseProc closeproc, TIFFSizeProc sizeproc,
- TIFFMapFileProc mapproc, TIFFUnmapFileProc unmapproc,
- TIFFOpenOptions *opts)
-{
- static const char module[] = "TIFFClientOpenExt";
- TIFF *tif;
- int m;
- const char *cp;
-
- /* The following are configuration checks. They should be redundant, but
- * should not compile to any actual code in an optimised release build
- * anyway. If any of them fail, (makefile-based or other) configuration is
- * not correct */
- assert(sizeof(uint8_t) == 1);
- assert(sizeof(int8_t) == 1);
- assert(sizeof(uint16_t) == 2);
- assert(sizeof(int16_t) == 2);
- assert(sizeof(uint32_t) == 4);
- assert(sizeof(int32_t) == 4);
- assert(sizeof(uint64_t) == 8);
- assert(sizeof(int64_t) == 8);
- {
- union
- {
- uint8_t a8[2];
- uint16_t a16;
- } n;
- n.a8[0] = 1;
- n.a8[1] = 0;
- (void)n;
-#ifdef WORDS_BIGENDIAN
- assert(n.a16 == 256);
-#else
- assert(n.a16 == 1);
-#endif
- }
-
- m = _TIFFgetMode(opts, clientdata, mode, module);
- if (m == -1)
- goto bad2;
- tmsize_t size_to_alloc = (tmsize_t)(sizeof(TIFF) + strlen(name) + 1);
- if (opts && opts->max_single_mem_alloc > 0 &&
- size_to_alloc > opts->max_single_mem_alloc)
- {
- _TIFFErrorEarly(opts, clientdata, module,
- "%s: Memory allocation of %" PRIu64
- " bytes is beyond the %" PRIu64
- " byte limit defined in open options",
- name, (uint64_t)size_to_alloc,
- (uint64_t)opts->max_single_mem_alloc);
- goto bad2;
- }
- if (opts && opts->max_cumulated_mem_alloc > 0 &&
- size_to_alloc > opts->max_cumulated_mem_alloc)
- {
- _TIFFErrorEarly(opts, clientdata, module,
- "%s: Memory allocation of %" PRIu64
- " bytes is beyond the %" PRIu64
- " cumulated byte limit defined in open options",
- name, (uint64_t)size_to_alloc,
- (uint64_t)opts->max_cumulated_mem_alloc);
- goto bad2;
- }
- tif = (TIFF *)_TIFFmallocExt(NULL, size_to_alloc);
- if (tif == NULL)
- {
- _TIFFErrorEarly(opts, clientdata, module,
- "%s: Out of memory (TIFF structure)", name);
- goto bad2;
- }
- _TIFFmemset(tif, 0, sizeof(*tif));
- tif->tif_name = (char *)tif + sizeof(TIFF);
- strcpy(tif->tif_name, name);
- tif->tif_mode = m & ~(O_CREAT | O_TRUNC);
- tif->tif_curdir = TIFF_NON_EXISTENT_DIR_NUMBER; /* non-existent directory */
- tif->tif_curdircount = TIFF_NON_EXISTENT_DIR_NUMBER;
- tif->tif_curoff = 0;
- tif->tif_curstrip = (uint32_t)-1; /* invalid strip */
- tif->tif_row = (uint32_t)-1; /* read/write pre-increment */
- tif->tif_clientdata = clientdata;
- tif->tif_readproc = readproc;
- tif->tif_writeproc = writeproc;
- tif->tif_seekproc = seekproc;
- tif->tif_closeproc = closeproc;
- tif->tif_sizeproc = sizeproc;
- tif->tif_mapproc = mapproc ? mapproc : _tiffDummyMapProc;
- tif->tif_unmapproc = unmapproc ? unmapproc : _tiffDummyUnmapProc;
- if (opts)
- {
- tif->tif_errorhandler = opts->errorhandler;
- tif->tif_errorhandler_user_data = opts->errorhandler_user_data;
- tif->tif_warnhandler = opts->warnhandler;
- tif->tif_warnhandler_user_data = opts->warnhandler_user_data;
- tif->tif_max_single_mem_alloc = opts->max_single_mem_alloc;
- tif->tif_max_cumulated_mem_alloc = opts->max_cumulated_mem_alloc;
- }
-
- if (!readproc || !writeproc || !seekproc || !closeproc || !sizeproc)
- {
- TIFFErrorExtR(tif, module,
- "One of the client procedures is NULL pointer.");
- _TIFFfreeExt(NULL, tif);
- goto bad2;
- }
-
- _TIFFSetDefaultCompressionState(tif); /* setup default state */
- /*
- * Default is to return data MSB2LSB and enable the
- * use of memory-mapped files and strip chopping when
- * a file is opened read-only.
- */
- tif->tif_flags = FILLORDER_MSB2LSB;
- if (m == O_RDONLY)
- tif->tif_flags |= TIFF_MAPPED;
-
-#ifdef STRIPCHOP_DEFAULT
- if (m == O_RDONLY || m == O_RDWR)
- tif->tif_flags |= STRIPCHOP_DEFAULT;
-#endif
-
- /*
- * Process library-specific flags in the open mode string.
- * The following flags may be used to control intrinsic library
- * behavior that may or may not be desirable (usually for
- * compatibility with some application that claims to support
- * TIFF but only supports some brain dead idea of what the
- * vendor thinks TIFF is):
- *
- * 'l' use little-endian byte order for creating a file
- * 'b' use big-endian byte order for creating a file
- * 'L' read/write information using LSB2MSB bit order
- * 'B' read/write information using MSB2LSB bit order
- * 'H' read/write information using host bit order
- * 'M' enable use of memory-mapped files when supported
- * 'm' disable use of memory-mapped files
- * 'C' enable strip chopping support when reading
- * 'c' disable strip chopping support
- * 'h' read TIFF header only, do not load the first IFD
- * '4' ClassicTIFF for creating a file (default)
- * '8' BigTIFF for creating a file
- * 'D' enable use of deferred strip/tile offset/bytecount array loading.
- * 'O' on-demand loading of values instead of whole array loading (implies
- * D)
- *
- * The use of the 'l' and 'b' flags is strongly discouraged.
- * These flags are provided solely because numerous vendors,
- * typically on the PC, do not correctly support TIFF; they
- * only support the Intel little-endian byte order. This
- * support is not configured by default because it supports
- * the violation of the TIFF spec that says that readers *MUST*
- * support both byte orders. It is strongly recommended that
- * you not use this feature except to deal with busted apps
- * that write invalid TIFF. And even in those cases you should
- * bang on the vendors to fix their software.
- *
- * The 'L', 'B', and 'H' flags are intended for applications
- * that can optimize operations on data by using a particular
- * bit order. By default the library returns data in MSB2LSB
- * bit order for compatibility with older versions of this
- * library. Returning data in the bit order of the native CPU
- * makes the most sense but also requires applications to check
- * the value of the FillOrder tag; something they probably do
- * not do right now.
- *
- * The 'M' and 'm' flags are provided because some virtual memory
- * systems exhibit poor behavior when large images are mapped.
- * These options permit clients to control the use of memory-mapped
- * files on a per-file basis.
- *
- * The 'C' and 'c' flags are provided because the library support
- * for chopping up large strips into multiple smaller strips is not
- * application-transparent and as such can cause problems. The 'c'
- * option permits applications that only want to look at the tags,
- * for example, to get the unadulterated TIFF tag information.
- */
- for (cp = mode; *cp; cp++)
- switch (*cp)
- {
- case 'b':
-#ifndef WORDS_BIGENDIAN
- if (m & O_CREAT)
- tif->tif_flags |= TIFF_SWAB;
-#endif
- break;
- case 'l':
-#ifdef WORDS_BIGENDIAN
- if ((m & O_CREAT))
- tif->tif_flags |= TIFF_SWAB;
-#endif
- break;
- case 'B':
- tif->tif_flags =
- (tif->tif_flags & ~TIFF_FILLORDER) | FILLORDER_MSB2LSB;
- break;
- case 'L':
- tif->tif_flags =
- (tif->tif_flags & ~TIFF_FILLORDER) | FILLORDER_LSB2MSB;
- break;
- case 'H':
- TIFFWarningExtR(tif, name,
- "H(ost) mode is deprecated. Since "
- "libtiff 4.5.1, it is an alias of 'B' / "
- "FILLORDER_MSB2LSB.");
- tif->tif_flags =
- (tif->tif_flags & ~TIFF_FILLORDER) | FILLORDER_MSB2LSB;
- break;
- case 'M':
- if (m == O_RDONLY)
- tif->tif_flags |= TIFF_MAPPED;
- break;
- case 'm':
- if (m == O_RDONLY)
- tif->tif_flags &= ~TIFF_MAPPED;
- break;
- case 'C':
- if (m == O_RDONLY)
- tif->tif_flags |= TIFF_STRIPCHOP;
- break;
- case 'c':
- if (m == O_RDONLY)
- tif->tif_flags &= ~TIFF_STRIPCHOP;
- break;
- case 'h':
- tif->tif_flags |= TIFF_HEADERONLY;
- break;
- case '8':
- if (m & O_CREAT)
- tif->tif_flags |= TIFF_BIGTIFF;
- break;
- case 'D':
- tif->tif_flags |= TIFF_DEFERSTRILELOAD;
- break;
- case 'O':
- if (m == O_RDONLY)
- tif->tif_flags |=
- (TIFF_LAZYSTRILELOAD | TIFF_DEFERSTRILELOAD);
- break;
- }
-
-#ifdef DEFER_STRILE_LOAD
- /* Compatibility with old DEFER_STRILE_LOAD compilation flag */
- /* Probably unneeded, since to the best of my knowledge (E. Rouault) */
- /* GDAL was the only user of this, and will now use the new 'D' flag */
- tif->tif_flags |= TIFF_DEFERSTRILELOAD;
-#endif
-
- /*
- * Read in TIFF header.
- */
- if ((m & O_TRUNC) ||
- !ReadOK(tif, &tif->tif_header, sizeof(TIFFHeaderClassic)))
- {
- if (tif->tif_mode == O_RDONLY)
- {
- TIFFErrorExtR(tif, name, "Cannot read TIFF header");
- goto bad;
- }
- /*
- * Setup header and write.
- */
-#ifdef WORDS_BIGENDIAN
- tif->tif_header.common.tiff_magic =
- (tif->tif_flags & TIFF_SWAB) ? TIFF_LITTLEENDIAN : TIFF_BIGENDIAN;
-#else
- tif->tif_header.common.tiff_magic =
- (tif->tif_flags & TIFF_SWAB) ? TIFF_BIGENDIAN : TIFF_LITTLEENDIAN;
-#endif
- TIFFHeaderUnion tif_header_swapped;
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- {
- tif->tif_header.common.tiff_version = TIFF_VERSION_CLASSIC;
- tif->tif_header.classic.tiff_diroff = 0;
- tif->tif_header_size = sizeof(TIFFHeaderClassic);
- /* Swapped copy for writing */
- _TIFFmemcpy(&tif_header_swapped, &tif->tif_header,
- sizeof(TIFFHeaderUnion));
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabShort(&tif_header_swapped.common.tiff_version);
- }
- else
- {
- tif->tif_header.common.tiff_version = TIFF_VERSION_BIG;
- tif->tif_header.big.tiff_offsetsize = 8;
- tif->tif_header.big.tiff_unused = 0;
- tif->tif_header.big.tiff_diroff = 0;
- tif->tif_header_size = sizeof(TIFFHeaderBig);
- /* Swapped copy for writing */
- _TIFFmemcpy(&tif_header_swapped, &tif->tif_header,
- sizeof(TIFFHeaderUnion));
- if (tif->tif_flags & TIFF_SWAB)
- {
- TIFFSwabShort(&tif_header_swapped.common.tiff_version);
- TIFFSwabShort(&tif_header_swapped.big.tiff_offsetsize);
- }
- }
- /*
- * The doc for "fopen" for some STD_C_LIBs says that if you
- * open a file for modify ("+"), then you must fseek (or
- * fflush?) between any freads and fwrites. This is not
- * necessary on most systems, but has been shown to be needed
- * on Solaris.
- */
- TIFFSeekFile(tif, 0, SEEK_SET);
- if (!WriteOK(tif, &tif_header_swapped,
- (tmsize_t)(tif->tif_header_size)))
- {
- TIFFErrorExtR(tif, name, "Error writing TIFF header");
- goto bad;
- }
- /*
- * Setup default directory.
- */
- if (!TIFFDefaultDirectory(tif))
- goto bad;
- tif->tif_diroff = 0;
- tif->tif_lastdiroff = 0;
- tif->tif_setdirectory_force_absolute = FALSE;
- /* tif_curdircount = 0 means 'empty file opened for writing, but no IFD
- * written yet' */
- tif->tif_curdircount = 0;
- return (tif);
- }
-
- /*
- * Setup the byte order handling according to the opened file for reading.
- */
- if (tif->tif_header.common.tiff_magic != TIFF_BIGENDIAN &&
- tif->tif_header.common.tiff_magic != TIFF_LITTLEENDIAN
-#if MDI_SUPPORT
- &&
-#if HOST_BIGENDIAN
- tif->tif_header.common.tiff_magic != MDI_BIGENDIAN
-#else
- tif->tif_header.common.tiff_magic != MDI_LITTLEENDIAN
-#endif
- )
- {
- TIFFErrorExtR(tif, name,
- "Not a TIFF or MDI file, bad magic number %" PRIu16
- " (0x%" PRIx16 ")",
-#else
- )
- {
- TIFFErrorExtR(tif, name,
- "Not a TIFF file, bad magic number %" PRIu16
- " (0x%" PRIx16 ")",
-#endif
- tif->tif_header.common.tiff_magic,
- tif->tif_header.common.tiff_magic);
- goto bad;
- }
- if (tif->tif_header.common.tiff_magic == TIFF_BIGENDIAN)
- {
-#ifndef WORDS_BIGENDIAN
- tif->tif_flags |= TIFF_SWAB;
-#endif
- }
- else
- {
-#ifdef WORDS_BIGENDIAN
- tif->tif_flags |= TIFF_SWAB;
-#endif
- }
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabShort(&tif->tif_header.common.tiff_version);
- if ((tif->tif_header.common.tiff_version != TIFF_VERSION_CLASSIC) &&
- (tif->tif_header.common.tiff_version != TIFF_VERSION_BIG))
- {
- TIFFErrorExtR(tif, name,
- "Not a TIFF file, bad version number %" PRIu16
- " (0x%" PRIx16 ")",
- tif->tif_header.common.tiff_version,
- tif->tif_header.common.tiff_version);
- goto bad;
- }
- if (tif->tif_header.common.tiff_version == TIFF_VERSION_CLASSIC)
- {
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabLong(&tif->tif_header.classic.tiff_diroff);
- tif->tif_header_size = sizeof(TIFFHeaderClassic);
- }
- else
- {
- if (!ReadOK(tif,
- ((uint8_t *)(&tif->tif_header) + sizeof(TIFFHeaderClassic)),
- (sizeof(TIFFHeaderBig) - sizeof(TIFFHeaderClassic))))
- {
- TIFFErrorExtR(tif, name, "Cannot read TIFF header");
- goto bad;
- }
- if (tif->tif_flags & TIFF_SWAB)
- {
- TIFFSwabShort(&tif->tif_header.big.tiff_offsetsize);
- TIFFSwabLong8(&tif->tif_header.big.tiff_diroff);
- }
- if (tif->tif_header.big.tiff_offsetsize != 8)
- {
- TIFFErrorExtR(tif, name,
- "Not a TIFF file, bad BigTIFF offsetsize %" PRIu16
- " (0x%" PRIx16 ")",
- tif->tif_header.big.tiff_offsetsize,
- tif->tif_header.big.tiff_offsetsize);
- goto bad;
- }
- if (tif->tif_header.big.tiff_unused != 0)
- {
- TIFFErrorExtR(tif, name,
- "Not a TIFF file, bad BigTIFF unused %" PRIu16
- " (0x%" PRIx16 ")",
- tif->tif_header.big.tiff_unused,
- tif->tif_header.big.tiff_unused);
- goto bad;
- }
- tif->tif_header_size = sizeof(TIFFHeaderBig);
- tif->tif_flags |= TIFF_BIGTIFF;
- }
- tif->tif_flags |= TIFF_MYBUFFER;
- tif->tif_rawcp = tif->tif_rawdata = 0;
- tif->tif_rawdatasize = 0;
- tif->tif_rawdataoff = 0;
- tif->tif_rawdataloaded = 0;
-
- switch (mode[0])
- {
- case 'r':
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- tif->tif_nextdiroff = tif->tif_header.classic.tiff_diroff;
- else
- tif->tif_nextdiroff = tif->tif_header.big.tiff_diroff;
- /*
- * Try to use a memory-mapped file if the client
- * has not explicitly suppressed usage with the
- * 'm' flag in the open mode (see above).
- */
- if (tif->tif_flags & TIFF_MAPPED)
- {
- toff_t n;
- if (TIFFMapFileContents(tif, (void **)(&tif->tif_base), &n))
- {
- tif->tif_size = (tmsize_t)n;
- assert((toff_t)tif->tif_size == n);
- }
- else
- tif->tif_flags &= ~TIFF_MAPPED;
- }
- /*
- * Sometimes we do not want to read the first directory (for
- * example, it may be broken) and want to proceed to other
- * directories. I this case we use the TIFF_HEADERONLY flag to open
- * file and return immediately after reading TIFF header.
- * However, the pointer to TIFFSetField() and TIFFGetField()
- * (i.e. tif->tif_tagmethods.vsetfield and
- * tif->tif_tagmethods.vgetfield) need to be initialized, which is
- * done in TIFFDefaultDirectory().
- */
- if (tif->tif_flags & TIFF_HEADERONLY)
- {
- if (!TIFFDefaultDirectory(tif))
- goto bad;
- return (tif);
- }
-
- /*
- * Setup initial directory.
- */
- if (TIFFReadDirectory(tif))
- {
- return (tif);
- }
- break;
- case 'a':
- /*
- * New directories are automatically append
- * to the end of the directory chain when they
- * are written out (see TIFFWriteDirectory).
- */
- if (!TIFFDefaultDirectory(tif))
- goto bad;
- return (tif);
- }
-bad:
- tif->tif_mode = O_RDONLY; /* XXX avoid flush */
- TIFFCleanup(tif);
-bad2:
- return ((TIFF *)0);
-}
-
-/*
- * Query functions to access private data.
- */
-
-/*
- * Return open file's name.
- */
-const char *TIFFFileName(TIFF *tif) { return (tif->tif_name); }
-
-/*
- * Set the file name.
- */
-const char *TIFFSetFileName(TIFF *tif, const char *name)
-{
- const char *old_name = tif->tif_name;
- tif->tif_name = (char *)name;
- return (old_name);
-}
-
-/*
- * Return open file's I/O descriptor.
- */
-int TIFFFileno(TIFF *tif) { return (tif->tif_fd); }
-
-/*
- * Set open file's I/O descriptor, and return previous value.
- */
-int TIFFSetFileno(TIFF *tif, int fd)
-{
- int old_fd = tif->tif_fd;
- tif->tif_fd = fd;
- return old_fd;
-}
-
-/*
- * Return open file's clientdata.
- */
-thandle_t TIFFClientdata(TIFF *tif) { return (tif->tif_clientdata); }
-
-/*
- * Set open file's clientdata, and return previous value.
- */
-thandle_t TIFFSetClientdata(TIFF *tif, thandle_t newvalue)
-{
- thandle_t m = tif->tif_clientdata;
- tif->tif_clientdata = newvalue;
- return m;
-}
-
-/*
- * Return read/write mode.
- */
-int TIFFGetMode(TIFF *tif) { return (tif->tif_mode); }
-
-/*
- * Return read/write mode.
- */
-int TIFFSetMode(TIFF *tif, int mode)
-{
- int old_mode = tif->tif_mode;
- tif->tif_mode = mode;
- return (old_mode);
-}
-
-/*
- * Return nonzero if file is organized in
- * tiles; zero if organized as strips.
- */
-int TIFFIsTiled(TIFF *tif) { return (isTiled(tif)); }
-
-/*
- * Return current row being read/written.
- */
-uint32_t TIFFCurrentRow(TIFF *tif) { return (tif->tif_row); }
-
-/*
- * Return index of the current directory.
- */
-tdir_t TIFFCurrentDirectory(TIFF *tif) { return (tif->tif_curdir); }
-
-/*
- * Return current strip.
- */
-uint32_t TIFFCurrentStrip(TIFF *tif) { return (tif->tif_curstrip); }
-
-/*
- * Return current tile.
- */
-uint32_t TIFFCurrentTile(TIFF *tif) { return (tif->tif_curtile); }
-
-/*
- * Return nonzero if the file has byte-swapped data.
- */
-int TIFFIsByteSwapped(TIFF *tif) { return ((tif->tif_flags & TIFF_SWAB) != 0); }
-
-/*
- * Return nonzero if the data is returned up-sampled.
- */
-int TIFFIsUpSampled(TIFF *tif) { return (isUpSampled(tif)); }
-
-/*
- * Return nonzero if the data is returned in MSB-to-LSB bit order.
- */
-int TIFFIsMSB2LSB(TIFF *tif) { return (isFillOrder(tif, FILLORDER_MSB2LSB)); }
-
-/*
- * Return nonzero if given file was written in big-endian order.
- */
-int TIFFIsBigEndian(TIFF *tif)
-{
- return (tif->tif_header.common.tiff_magic == TIFF_BIGENDIAN);
-}
-
-/*
- * Return nonzero if given file is BigTIFF style.
- */
-int TIFFIsBigTIFF(TIFF *tif) { return ((tif->tif_flags & TIFF_BIGTIFF) != 0); }
-
-/*
- * Return pointer to file read method.
- */
-TIFFReadWriteProc TIFFGetReadProc(TIFF *tif) { return (tif->tif_readproc); }
-
-/*
- * Return pointer to file write method.
- */
-TIFFReadWriteProc TIFFGetWriteProc(TIFF *tif) { return (tif->tif_writeproc); }
-
-/*
- * Return pointer to file seek method.
- */
-TIFFSeekProc TIFFGetSeekProc(TIFF *tif) { return (tif->tif_seekproc); }
-
-/*
- * Return pointer to file close method.
- */
-TIFFCloseProc TIFFGetCloseProc(TIFF *tif) { return (tif->tif_closeproc); }
-
-/*
- * Return pointer to file size requesting method.
- */
-TIFFSizeProc TIFFGetSizeProc(TIFF *tif) { return (tif->tif_sizeproc); }
-
-/*
- * Return pointer to memory mapping method.
- */
-TIFFMapFileProc TIFFGetMapFileProc(TIFF *tif) { return (tif->tif_mapproc); }
-
-/*
- * Return pointer to memory unmapping method.
- */
-TIFFUnmapFileProc TIFFGetUnmapFileProc(TIFF *tif)
-{
- return (tif->tif_unmapproc);
-}
diff --git a/contrib/libs/libtiff/tif_packbits.c b/contrib/libs/libtiff/tif_packbits.c
deleted file mode 100644
index 1ae50cbd47..0000000000
--- a/contrib/libs/libtiff/tif_packbits.c
+++ /dev/null
@@ -1,324 +0,0 @@
-/*
- * Copyright (c) 1988-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-#include "tiffiop.h"
-#ifdef PACKBITS_SUPPORT
-/*
- * TIFF Library.
- *
- * PackBits Compression Algorithm Support
- */
-#include <stdio.h>
-
-static int PackBitsPreEncode(TIFF *tif, uint16_t s)
-{
- (void)s;
-
- tif->tif_data = (uint8_t *)_TIFFmallocExt(tif, sizeof(tmsize_t));
- if (tif->tif_data == NULL)
- return (0);
- /*
- * Calculate the scanline/tile-width size in bytes.
- */
- if (isTiled(tif))
- *(tmsize_t *)tif->tif_data = TIFFTileRowSize(tif);
- else
- *(tmsize_t *)tif->tif_data = TIFFScanlineSize(tif);
- return (1);
-}
-
-static int PackBitsPostEncode(TIFF *tif)
-{
- if (tif->tif_data)
- _TIFFfreeExt(tif, tif->tif_data);
- return (1);
-}
-
-/*
- * Encode a run of pixels.
- */
-static int PackBitsEncode(TIFF *tif, uint8_t *buf, tmsize_t cc, uint16_t s)
-{
- unsigned char *bp = (unsigned char *)buf;
- uint8_t *op;
- uint8_t *ep;
- uint8_t *lastliteral;
- long n, slop;
- int b;
- enum
- {
- BASE,
- LITERAL,
- RUN,
- LITERAL_RUN
- } state;
-
- (void)s;
- op = tif->tif_rawcp;
- ep = tif->tif_rawdata + tif->tif_rawdatasize;
- state = BASE;
- lastliteral = 0;
- while (cc > 0)
- {
- /*
- * Find the longest string of identical bytes.
- */
- b = *bp++;
- cc--;
- n = 1;
- for (; cc > 0 && b == *bp; cc--, bp++)
- n++;
- again:
- if (op + 2 >= ep)
- { /* insure space for new data */
- /*
- * Be careful about writing the last
- * literal. Must write up to that point
- * and then copy the remainder to the
- * front of the buffer.
- */
- if (state == LITERAL || state == LITERAL_RUN)
- {
- slop = (long)(op - lastliteral);
- tif->tif_rawcc += (tmsize_t)(lastliteral - tif->tif_rawcp);
- if (!TIFFFlushData1(tif))
- return (0);
- op = tif->tif_rawcp;
- while (slop-- > 0)
- *op++ = *lastliteral++;
- lastliteral = tif->tif_rawcp;
- }
- else
- {
- tif->tif_rawcc += (tmsize_t)(op - tif->tif_rawcp);
- if (!TIFFFlushData1(tif))
- return (0);
- op = tif->tif_rawcp;
- }
- }
- switch (state)
- {
- case BASE: /* initial state, set run/literal */
- if (n > 1)
- {
- state = RUN;
- if (n > 128)
- {
- *op++ = (uint8_t)-127;
- *op++ = (uint8_t)b;
- n -= 128;
- goto again;
- }
- *op++ = (uint8_t)(-(n - 1));
- *op++ = (uint8_t)b;
- }
- else
- {
- lastliteral = op;
- *op++ = 0;
- *op++ = (uint8_t)b;
- state = LITERAL;
- }
- break;
- case LITERAL: /* last object was literal string */
- if (n > 1)
- {
- state = LITERAL_RUN;
- if (n > 128)
- {
- *op++ = (uint8_t)-127;
- *op++ = (uint8_t)b;
- n -= 128;
- goto again;
- }
- *op++ = (uint8_t)(-(n - 1)); /* encode run */
- *op++ = (uint8_t)b;
- }
- else
- { /* extend literal */
- if (++(*lastliteral) == 127)
- state = BASE;
- *op++ = (uint8_t)b;
- }
- break;
- case RUN: /* last object was run */
- if (n > 1)
- {
- if (n > 128)
- {
- *op++ = (uint8_t)-127;
- *op++ = (uint8_t)b;
- n -= 128;
- goto again;
- }
- *op++ = (uint8_t)(-(n - 1));
- *op++ = (uint8_t)b;
- }
- else
- {
- lastliteral = op;
- *op++ = 0;
- *op++ = (uint8_t)b;
- state = LITERAL;
- }
- break;
- case LITERAL_RUN: /* literal followed by a run */
- /*
- * Check to see if previous run should
- * be converted to a literal, in which
- * case we convert literal-run-literal
- * to a single literal.
- */
- if (n == 1 && op[-2] == (uint8_t)-1 && *lastliteral < 126)
- {
- state = (((*lastliteral) += 2) == 127 ? BASE : LITERAL);
- op[-2] = op[-1]; /* replicate */
- }
- else
- state = RUN;
- goto again;
- }
- }
- tif->tif_rawcc += (tmsize_t)(op - tif->tif_rawcp);
- tif->tif_rawcp = op;
- return (1);
-}
-
-/*
- * Encode a rectangular chunk of pixels. We break it up
- * into row-sized pieces to insure that encoded runs do
- * not span rows. Otherwise, there can be problems with
- * the decoder if data is read, for example, by scanlines
- * when it was encoded by strips.
- */
-static int PackBitsEncodeChunk(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s)
-{
- tmsize_t rowsize = *(tmsize_t *)tif->tif_data;
-
- while (cc > 0)
- {
- tmsize_t chunk = rowsize;
-
- if (cc < chunk)
- chunk = cc;
-
- if (PackBitsEncode(tif, bp, chunk, s) < 0)
- return (-1);
- bp += chunk;
- cc -= chunk;
- }
- return (1);
-}
-
-static int PackBitsDecode(TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s)
-{
- static const char module[] = "PackBitsDecode";
- int8_t *bp;
- tmsize_t cc;
- long n;
- int b;
-
- (void)s;
- bp = (int8_t *)tif->tif_rawcp;
- cc = tif->tif_rawcc;
- while (cc > 0 && occ > 0)
- {
- n = (long)*bp++;
- cc--;
- if (n < 0)
- { /* replicate next byte -n+1 times */
- if (n == -128) /* nop */
- continue;
- n = -n + 1;
- if (occ < (tmsize_t)n)
- {
- TIFFWarningExtR(tif, module,
- "Discarding %" TIFF_SSIZE_FORMAT
- " bytes to avoid buffer overrun",
- (tmsize_t)n - occ);
- n = (long)occ;
- }
- if (cc == 0)
- {
- TIFFWarningExtR(
- tif, module,
- "Terminating PackBitsDecode due to lack of data.");
- break;
- }
- occ -= n;
- b = *bp++;
- cc--;
- while (n-- > 0)
- *op++ = (uint8_t)b;
- }
- else
- { /* copy next n+1 bytes literally */
- if (occ < (tmsize_t)(n + 1))
- {
- TIFFWarningExtR(tif, module,
- "Discarding %" TIFF_SSIZE_FORMAT
- " bytes to avoid buffer overrun",
- (tmsize_t)n - occ + 1);
- n = (long)occ - 1;
- }
- if (cc < (tmsize_t)(n + 1))
- {
- TIFFWarningExtR(
- tif, module,
- "Terminating PackBitsDecode due to lack of data.");
- break;
- }
- _TIFFmemcpy(op, bp, ++n);
- op += n;
- occ -= n;
- bp += n;
- cc -= n;
- }
- }
- tif->tif_rawcp = (uint8_t *)bp;
- tif->tif_rawcc = cc;
- if (occ > 0)
- {
- memset(op, 0, (size_t)occ);
- TIFFErrorExtR(tif, module, "Not enough data for scanline %" PRIu32,
- tif->tif_row);
- return (0);
- }
- return (1);
-}
-
-int TIFFInitPackBits(TIFF *tif, int scheme)
-{
- (void)scheme;
- tif->tif_decoderow = PackBitsDecode;
- tif->tif_decodestrip = PackBitsDecode;
- tif->tif_decodetile = PackBitsDecode;
- tif->tif_preencode = PackBitsPreEncode;
- tif->tif_postencode = PackBitsPostEncode;
- tif->tif_encoderow = PackBitsEncode;
- tif->tif_encodestrip = PackBitsEncodeChunk;
- tif->tif_encodetile = PackBitsEncodeChunk;
- return (1);
-}
-#endif /* PACKBITS_SUPPORT */
diff --git a/contrib/libs/libtiff/tif_pixarlog.c b/contrib/libs/libtiff/tif_pixarlog.c
deleted file mode 100644
index 56cf416a7f..0000000000
--- a/contrib/libs/libtiff/tif_pixarlog.c
+++ /dev/null
@@ -1,1677 +0,0 @@
-/*
- * Copyright (c) 1996-1997 Sam Leffler
- * Copyright (c) 1996 Pixar
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Pixar, Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Pixar, Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL PIXAR, SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-#include "tiffiop.h"
-#ifdef PIXARLOG_SUPPORT
-
-/*
- * TIFF Library.
- * PixarLog Compression Support
- *
- * Contributed by Dan McCoy.
- *
- * PixarLog film support uses the TIFF library to store companded
- * 11 bit values into a tiff file, which are compressed using the
- * zip compressor.
- *
- * The codec can take as input and produce as output 32-bit IEEE float values
- * as well as 16-bit or 8-bit unsigned integer values.
- *
- * On writing any of the above are converted into the internal
- * 11-bit log format. In the case of 8 and 16 bit values, the
- * input is assumed to be unsigned linear color values that represent
- * the range 0-1. In the case of IEEE values, the 0-1 range is assumed to
- * be the normal linear color range, in addition over 1 values are
- * accepted up to a value of about 25.0 to encode "hot" highlights and such.
- * The encoding is lossless for 8-bit values, slightly lossy for the
- * other bit depths. The actual color precision should be better
- * than the human eye can perceive with extra room to allow for
- * error introduced by further image computation. As with any quantized
- * color format, it is possible to perform image calculations which
- * expose the quantization error. This format should certainly be less
- * susceptible to such errors than standard 8-bit encodings, but more
- * susceptible than straight 16-bit or 32-bit encodings.
- *
- * On reading the internal format is converted to the desired output format.
- * The program can request which format it desires by setting the internal
- * pseudo tag TIFFTAG_PIXARLOGDATAFMT to one of these possible values:
- * PIXARLOGDATAFMT_FLOAT = provide IEEE float values.
- * PIXARLOGDATAFMT_16BIT = provide unsigned 16-bit integer values
- * PIXARLOGDATAFMT_8BIT = provide unsigned 8-bit integer values
- *
- * alternately PIXARLOGDATAFMT_8BITABGR provides unsigned 8-bit integer
- * values with the difference that if there are exactly three or four channels
- * (rgb or rgba) it swaps the channel order (bgr or abgr).
- *
- * PIXARLOGDATAFMT_11BITLOG provides the internal encoding directly
- * packed in 16-bit values. However no tools are supplied for interpreting
- * these values.
- *
- * "hot" (over 1.0) areas written in floating point get clamped to
- * 1.0 in the integer data types.
- *
- * When the file is closed after writing, the bit depth and sample format
- * are set always to appear as if 8-bit data has been written into it.
- * That way a naive program unaware of the particulars of the encoding
- * gets the format it is most likely able to handle.
- *
- * The codec does it's own horizontal differencing step on the coded
- * values so the libraries predictor stuff should be turned off.
- * The codec also handle byte swapping the encoded values as necessary
- * since the library does not have the information necessary
- * to know the bit depth of the raw unencoded buffer.
- *
- * NOTE: This decoder does not appear to update tif_rawcp, and tif_rawcc.
- * This can cause problems with the implementation of CHUNKY_STRIP_READ_SUPPORT
- * as noted in http://trac.osgeo.org/gdal/ticket/3894. FrankW - Jan'11
- */
-
-#include "tif_predict.h"
-#include "zlib.h"
-
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-/* Tables for converting to/from 11 bit coded values */
-
-#define TSIZE 2048 /* decode table size (11-bit tokens) */
-#define TSIZEP1 2049 /* Plus one for slop */
-#define ONE 1250 /* token value of 1.0 exactly */
-#define RATIO 1.004 /* nominal ratio for log part */
-
-#define CODE_MASK 0x7ff /* 11 bits. */
-
-static float Fltsize;
-static float LogK1, LogK2;
-
-#define REPEAT(n, op) \
- { \
- int i; \
- i = n; \
- do \
- { \
- i--; \
- op; \
- } while (i > 0); \
- }
-
-static void horizontalAccumulateF(uint16_t *wp, int n, int stride, float *op,
- float *ToLinearF)
-{
- register unsigned int cr, cg, cb, ca, mask;
- register float t0, t1, t2, t3;
-
- if (n >= stride)
- {
- mask = CODE_MASK;
- if (stride == 3)
- {
- t0 = ToLinearF[cr = (wp[0] & mask)];
- t1 = ToLinearF[cg = (wp[1] & mask)];
- t2 = ToLinearF[cb = (wp[2] & mask)];
- op[0] = t0;
- op[1] = t1;
- op[2] = t2;
- n -= 3;
- while (n > 0)
- {
- wp += 3;
- op += 3;
- n -= 3;
- t0 = ToLinearF[(cr += wp[0]) & mask];
- t1 = ToLinearF[(cg += wp[1]) & mask];
- t2 = ToLinearF[(cb += wp[2]) & mask];
- op[0] = t0;
- op[1] = t1;
- op[2] = t2;
- }
- }
- else if (stride == 4)
- {
- t0 = ToLinearF[cr = (wp[0] & mask)];
- t1 = ToLinearF[cg = (wp[1] & mask)];
- t2 = ToLinearF[cb = (wp[2] & mask)];
- t3 = ToLinearF[ca = (wp[3] & mask)];
- op[0] = t0;
- op[1] = t1;
- op[2] = t2;
- op[3] = t3;
- n -= 4;
- while (n > 0)
- {
- wp += 4;
- op += 4;
- n -= 4;
- t0 = ToLinearF[(cr += wp[0]) & mask];
- t1 = ToLinearF[(cg += wp[1]) & mask];
- t2 = ToLinearF[(cb += wp[2]) & mask];
- t3 = ToLinearF[(ca += wp[3]) & mask];
- op[0] = t0;
- op[1] = t1;
- op[2] = t2;
- op[3] = t3;
- }
- }
- else
- {
- REPEAT(stride, *op = ToLinearF[*wp & mask]; wp++; op++)
- n -= stride;
- while (n > 0)
- {
- REPEAT(stride, wp[stride] += *wp; *op = ToLinearF[*wp & mask];
- wp++; op++)
- n -= stride;
- }
- }
- }
-}
-
-static void horizontalAccumulate12(uint16_t *wp, int n, int stride, int16_t *op,
- float *ToLinearF)
-{
- register unsigned int cr, cg, cb, ca, mask;
- register float t0, t1, t2, t3;
-
-#define SCALE12 2048.0F
-#define CLAMP12(t) (((t) < 3071) ? (uint16_t)(t) : 3071)
-
- if (n >= stride)
- {
- mask = CODE_MASK;
- if (stride == 3)
- {
- t0 = ToLinearF[cr = (wp[0] & mask)] * SCALE12;
- t1 = ToLinearF[cg = (wp[1] & mask)] * SCALE12;
- t2 = ToLinearF[cb = (wp[2] & mask)] * SCALE12;
- op[0] = CLAMP12(t0);
- op[1] = CLAMP12(t1);
- op[2] = CLAMP12(t2);
- n -= 3;
- while (n > 0)
- {
- wp += 3;
- op += 3;
- n -= 3;
- t0 = ToLinearF[(cr += wp[0]) & mask] * SCALE12;
- t1 = ToLinearF[(cg += wp[1]) & mask] * SCALE12;
- t2 = ToLinearF[(cb += wp[2]) & mask] * SCALE12;
- op[0] = CLAMP12(t0);
- op[1] = CLAMP12(t1);
- op[2] = CLAMP12(t2);
- }
- }
- else if (stride == 4)
- {
- t0 = ToLinearF[cr = (wp[0] & mask)] * SCALE12;
- t1 = ToLinearF[cg = (wp[1] & mask)] * SCALE12;
- t2 = ToLinearF[cb = (wp[2] & mask)] * SCALE12;
- t3 = ToLinearF[ca = (wp[3] & mask)] * SCALE12;
- op[0] = CLAMP12(t0);
- op[1] = CLAMP12(t1);
- op[2] = CLAMP12(t2);
- op[3] = CLAMP12(t3);
- n -= 4;
- while (n > 0)
- {
- wp += 4;
- op += 4;
- n -= 4;
- t0 = ToLinearF[(cr += wp[0]) & mask] * SCALE12;
- t1 = ToLinearF[(cg += wp[1]) & mask] * SCALE12;
- t2 = ToLinearF[(cb += wp[2]) & mask] * SCALE12;
- t3 = ToLinearF[(ca += wp[3]) & mask] * SCALE12;
- op[0] = CLAMP12(t0);
- op[1] = CLAMP12(t1);
- op[2] = CLAMP12(t2);
- op[3] = CLAMP12(t3);
- }
- }
- else
- {
- REPEAT(stride, t0 = ToLinearF[*wp & mask] * SCALE12;
- *op = CLAMP12(t0); wp++; op++)
- n -= stride;
- while (n > 0)
- {
- REPEAT(stride, wp[stride] += *wp;
- t0 = ToLinearF[wp[stride] & mask] * SCALE12;
- *op = CLAMP12(t0); wp++; op++)
- n -= stride;
- }
- }
- }
-}
-
-static void horizontalAccumulate16(uint16_t *wp, int n, int stride,
- uint16_t *op, uint16_t *ToLinear16)
-{
- register unsigned int cr, cg, cb, ca, mask;
-
- if (n >= stride)
- {
- mask = CODE_MASK;
- if (stride == 3)
- {
- op[0] = ToLinear16[cr = (wp[0] & mask)];
- op[1] = ToLinear16[cg = (wp[1] & mask)];
- op[2] = ToLinear16[cb = (wp[2] & mask)];
- n -= 3;
- while (n > 0)
- {
- wp += 3;
- op += 3;
- n -= 3;
- op[0] = ToLinear16[(cr += wp[0]) & mask];
- op[1] = ToLinear16[(cg += wp[1]) & mask];
- op[2] = ToLinear16[(cb += wp[2]) & mask];
- }
- }
- else if (stride == 4)
- {
- op[0] = ToLinear16[cr = (wp[0] & mask)];
- op[1] = ToLinear16[cg = (wp[1] & mask)];
- op[2] = ToLinear16[cb = (wp[2] & mask)];
- op[3] = ToLinear16[ca = (wp[3] & mask)];
- n -= 4;
- while (n > 0)
- {
- wp += 4;
- op += 4;
- n -= 4;
- op[0] = ToLinear16[(cr += wp[0]) & mask];
- op[1] = ToLinear16[(cg += wp[1]) & mask];
- op[2] = ToLinear16[(cb += wp[2]) & mask];
- op[3] = ToLinear16[(ca += wp[3]) & mask];
- }
- }
- else
- {
- REPEAT(stride, *op = ToLinear16[*wp & mask]; wp++; op++)
- n -= stride;
- while (n > 0)
- {
- REPEAT(stride, wp[stride] += *wp; *op = ToLinear16[*wp & mask];
- wp++; op++)
- n -= stride;
- }
- }
- }
-}
-
-/*
- * Returns the log encoded 11-bit values with the horizontal
- * differencing undone.
- */
-static void horizontalAccumulate11(uint16_t *wp, int n, int stride,
- uint16_t *op)
-{
- register unsigned int cr, cg, cb, ca, mask;
-
- if (n >= stride)
- {
- mask = CODE_MASK;
- if (stride == 3)
- {
- op[0] = wp[0];
- op[1] = wp[1];
- op[2] = wp[2];
- cr = wp[0];
- cg = wp[1];
- cb = wp[2];
- n -= 3;
- while (n > 0)
- {
- wp += 3;
- op += 3;
- n -= 3;
- op[0] = (uint16_t)((cr += wp[0]) & mask);
- op[1] = (uint16_t)((cg += wp[1]) & mask);
- op[2] = (uint16_t)((cb += wp[2]) & mask);
- }
- }
- else if (stride == 4)
- {
- op[0] = wp[0];
- op[1] = wp[1];
- op[2] = wp[2];
- op[3] = wp[3];
- cr = wp[0];
- cg = wp[1];
- cb = wp[2];
- ca = wp[3];
- n -= 4;
- while (n > 0)
- {
- wp += 4;
- op += 4;
- n -= 4;
- op[0] = (uint16_t)((cr += wp[0]) & mask);
- op[1] = (uint16_t)((cg += wp[1]) & mask);
- op[2] = (uint16_t)((cb += wp[2]) & mask);
- op[3] = (uint16_t)((ca += wp[3]) & mask);
- }
- }
- else
- {
- REPEAT(stride, *op = *wp & mask; wp++; op++)
- n -= stride;
- while (n > 0)
- {
- REPEAT(stride, wp[stride] += *wp; *op = *wp & mask; wp++; op++)
- n -= stride;
- }
- }
- }
-}
-
-static void horizontalAccumulate8(uint16_t *wp, int n, int stride,
- unsigned char *op, unsigned char *ToLinear8)
-{
- register unsigned int cr, cg, cb, ca, mask;
-
- if (n >= stride)
- {
- mask = CODE_MASK;
- if (stride == 3)
- {
- op[0] = ToLinear8[cr = (wp[0] & mask)];
- op[1] = ToLinear8[cg = (wp[1] & mask)];
- op[2] = ToLinear8[cb = (wp[2] & mask)];
- n -= 3;
- while (n > 0)
- {
- n -= 3;
- wp += 3;
- op += 3;
- op[0] = ToLinear8[(cr += wp[0]) & mask];
- op[1] = ToLinear8[(cg += wp[1]) & mask];
- op[2] = ToLinear8[(cb += wp[2]) & mask];
- }
- }
- else if (stride == 4)
- {
- op[0] = ToLinear8[cr = (wp[0] & mask)];
- op[1] = ToLinear8[cg = (wp[1] & mask)];
- op[2] = ToLinear8[cb = (wp[2] & mask)];
- op[3] = ToLinear8[ca = (wp[3] & mask)];
- n -= 4;
- while (n > 0)
- {
- n -= 4;
- wp += 4;
- op += 4;
- op[0] = ToLinear8[(cr += wp[0]) & mask];
- op[1] = ToLinear8[(cg += wp[1]) & mask];
- op[2] = ToLinear8[(cb += wp[2]) & mask];
- op[3] = ToLinear8[(ca += wp[3]) & mask];
- }
- }
- else
- {
- REPEAT(stride, *op = ToLinear8[*wp & mask]; wp++; op++)
- n -= stride;
- while (n > 0)
- {
- REPEAT(stride, wp[stride] += *wp; *op = ToLinear8[*wp & mask];
- wp++; op++)
- n -= stride;
- }
- }
- }
-}
-
-static void horizontalAccumulate8abgr(uint16_t *wp, int n, int stride,
- unsigned char *op,
- unsigned char *ToLinear8)
-{
- register unsigned int cr, cg, cb, ca, mask;
- register unsigned char t0, t1, t2, t3;
-
- if (n >= stride)
- {
- mask = CODE_MASK;
- if (stride == 3)
- {
- op[0] = 0;
- t1 = ToLinear8[cb = (wp[2] & mask)];
- t2 = ToLinear8[cg = (wp[1] & mask)];
- t3 = ToLinear8[cr = (wp[0] & mask)];
- op[1] = t1;
- op[2] = t2;
- op[3] = t3;
- n -= 3;
- while (n > 0)
- {
- n -= 3;
- wp += 3;
- op += 4;
- op[0] = 0;
- t1 = ToLinear8[(cb += wp[2]) & mask];
- t2 = ToLinear8[(cg += wp[1]) & mask];
- t3 = ToLinear8[(cr += wp[0]) & mask];
- op[1] = t1;
- op[2] = t2;
- op[3] = t3;
- }
- }
- else if (stride == 4)
- {
- t0 = ToLinear8[ca = (wp[3] & mask)];
- t1 = ToLinear8[cb = (wp[2] & mask)];
- t2 = ToLinear8[cg = (wp[1] & mask)];
- t3 = ToLinear8[cr = (wp[0] & mask)];
- op[0] = t0;
- op[1] = t1;
- op[2] = t2;
- op[3] = t3;
- n -= 4;
- while (n > 0)
- {
- n -= 4;
- wp += 4;
- op += 4;
- t0 = ToLinear8[(ca += wp[3]) & mask];
- t1 = ToLinear8[(cb += wp[2]) & mask];
- t2 = ToLinear8[(cg += wp[1]) & mask];
- t3 = ToLinear8[(cr += wp[0]) & mask];
- op[0] = t0;
- op[1] = t1;
- op[2] = t2;
- op[3] = t3;
- }
- }
- else
- {
- REPEAT(stride, *op = ToLinear8[*wp & mask]; wp++; op++)
- n -= stride;
- while (n > 0)
- {
- REPEAT(stride, wp[stride] += *wp; *op = ToLinear8[*wp & mask];
- wp++; op++)
- n -= stride;
- }
- }
- }
-}
-
-/*
- * State block for each open TIFF
- * file using PixarLog compression/decompression.
- */
-typedef struct
-{
- TIFFPredictorState predict;
- z_stream stream;
- tmsize_t tbuf_size; /* only set/used on reading for now */
- uint16_t *tbuf;
- uint16_t stride;
- int state;
- int user_datafmt;
- int quality;
-#define PLSTATE_INIT 1
-
- TIFFVSetMethod vgetparent; /* super-class method */
- TIFFVSetMethod vsetparent; /* super-class method */
-
- float *ToLinearF;
- uint16_t *ToLinear16;
- unsigned char *ToLinear8;
- uint16_t *FromLT2;
- uint16_t *From14; /* Really for 16-bit data, but we shift down 2 */
- uint16_t *From8;
-
-} PixarLogState;
-
-static int PixarLogMakeTables(TIFF *tif, PixarLogState *sp)
-{
-
- /*
- * We make several tables here to convert between various external
- * representations (float, 16-bit, and 8-bit) and the internal
- * 11-bit companded representation. The 11-bit representation has two
- * distinct regions. A linear bottom end up through .018316 in steps
- * of about .000073, and a region of constant ratio up to about 25.
- * These floating point numbers are stored in the main table ToLinearF.
- * All other tables are derived from this one. The tables (and the
- * ratios) are continuous at the internal seam.
- */
-
- int nlin, lt2size;
- int i, j;
- double b, c, linstep, v;
- float *ToLinearF;
- uint16_t *ToLinear16;
- unsigned char *ToLinear8;
- uint16_t *FromLT2;
- uint16_t *From14; /* Really for 16-bit data, but we shift down 2 */
- uint16_t *From8;
-
- c = log(RATIO);
- nlin = (int)(1. / c); /* nlin must be an integer */
- c = 1. / nlin;
- b = exp(-c * ONE); /* multiplicative scale factor [b*exp(c*ONE) = 1] */
- linstep = b * c * exp(1.);
-
- LogK1 = (float)(1. / c); /* if (v >= 2) token = k1*log(v*k2) */
- LogK2 = (float)(1. / b);
- lt2size = (int)(2. / linstep) + 1;
- FromLT2 = (uint16_t *)_TIFFmallocExt(tif, lt2size * sizeof(uint16_t));
- From14 = (uint16_t *)_TIFFmallocExt(tif, 16384 * sizeof(uint16_t));
- From8 = (uint16_t *)_TIFFmallocExt(tif, 256 * sizeof(uint16_t));
- ToLinearF = (float *)_TIFFmallocExt(tif, TSIZEP1 * sizeof(float));
- ToLinear16 = (uint16_t *)_TIFFmallocExt(tif, TSIZEP1 * sizeof(uint16_t));
- ToLinear8 =
- (unsigned char *)_TIFFmallocExt(tif, TSIZEP1 * sizeof(unsigned char));
- if (FromLT2 == NULL || From14 == NULL || From8 == NULL ||
- ToLinearF == NULL || ToLinear16 == NULL || ToLinear8 == NULL)
- {
- if (FromLT2)
- _TIFFfreeExt(tif, FromLT2);
- if (From14)
- _TIFFfreeExt(tif, From14);
- if (From8)
- _TIFFfreeExt(tif, From8);
- if (ToLinearF)
- _TIFFfreeExt(tif, ToLinearF);
- if (ToLinear16)
- _TIFFfreeExt(tif, ToLinear16);
- if (ToLinear8)
- _TIFFfreeExt(tif, ToLinear8);
- sp->FromLT2 = NULL;
- sp->From14 = NULL;
- sp->From8 = NULL;
- sp->ToLinearF = NULL;
- sp->ToLinear16 = NULL;
- sp->ToLinear8 = NULL;
- return 0;
- }
-
- j = 0;
-
- for (i = 0; i < nlin; i++)
- {
- v = i * linstep;
- ToLinearF[j++] = (float)v;
- }
-
- for (i = nlin; i < TSIZE; i++)
- ToLinearF[j++] = (float)(b * exp(c * i));
-
- ToLinearF[2048] = ToLinearF[2047];
-
- for (i = 0; i < TSIZEP1; i++)
- {
- v = ToLinearF[i] * 65535.0 + 0.5;
- ToLinear16[i] = (v > 65535.0) ? 65535 : (uint16_t)v;
- v = ToLinearF[i] * 255.0 + 0.5;
- ToLinear8[i] = (v > 255.0) ? 255 : (unsigned char)v;
- }
-
- j = 0;
- for (i = 0; i < lt2size; i++)
- {
- if ((i * linstep) * (i * linstep) > ToLinearF[j] * ToLinearF[j + 1])
- j++;
- FromLT2[i] = (uint16_t)j;
- }
-
- /*
- * Since we lose info anyway on 16-bit data, we set up a 14-bit
- * table and shift 16-bit values down two bits on input.
- * saves a little table space.
- */
- j = 0;
- for (i = 0; i < 16384; i++)
- {
- while ((i / 16383.) * (i / 16383.) > ToLinearF[j] * ToLinearF[j + 1])
- j++;
- From14[i] = (uint16_t)j;
- }
-
- j = 0;
- for (i = 0; i < 256; i++)
- {
- while ((i / 255.) * (i / 255.) > ToLinearF[j] * ToLinearF[j + 1])
- j++;
- From8[i] = (uint16_t)j;
- }
-
- Fltsize = (float)(lt2size / 2);
-
- sp->ToLinearF = ToLinearF;
- sp->ToLinear16 = ToLinear16;
- sp->ToLinear8 = ToLinear8;
- sp->FromLT2 = FromLT2;
- sp->From14 = From14;
- sp->From8 = From8;
-
- return 1;
-}
-
-#define PixarLogDecoderState(tif) ((PixarLogState *)(tif)->tif_data)
-#define PixarLogEncoderState(tif) ((PixarLogState *)(tif)->tif_data)
-
-static int PixarLogEncode(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s);
-static int PixarLogDecode(TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s);
-
-#define PIXARLOGDATAFMT_UNKNOWN -1
-
-static int PixarLogGuessDataFmt(TIFFDirectory *td)
-{
- int guess = PIXARLOGDATAFMT_UNKNOWN;
- int format = td->td_sampleformat;
-
- /* If the user didn't tell us his datafmt,
- * take our best guess from the bitspersample.
- */
- switch (td->td_bitspersample)
- {
- case 32:
- if (format == SAMPLEFORMAT_IEEEFP)
- guess = PIXARLOGDATAFMT_FLOAT;
- break;
- case 16:
- if (format == SAMPLEFORMAT_VOID || format == SAMPLEFORMAT_UINT)
- guess = PIXARLOGDATAFMT_16BIT;
- break;
- case 12:
- if (format == SAMPLEFORMAT_VOID || format == SAMPLEFORMAT_INT)
- guess = PIXARLOGDATAFMT_12BITPICIO;
- break;
- case 11:
- if (format == SAMPLEFORMAT_VOID || format == SAMPLEFORMAT_UINT)
- guess = PIXARLOGDATAFMT_11BITLOG;
- break;
- case 8:
- if (format == SAMPLEFORMAT_VOID || format == SAMPLEFORMAT_UINT)
- guess = PIXARLOGDATAFMT_8BIT;
- break;
- }
-
- return guess;
-}
-
-static tmsize_t multiply_ms(tmsize_t m1, tmsize_t m2)
-{
- return _TIFFMultiplySSize(NULL, m1, m2, NULL);
-}
-
-static tmsize_t add_ms(tmsize_t m1, tmsize_t m2)
-{
- assert(m1 >= 0 && m2 >= 0);
- /* if either input is zero, assume overflow already occurred */
- if (m1 == 0 || m2 == 0)
- return 0;
- else if (m1 > TIFF_TMSIZE_T_MAX - m2)
- return 0;
-
- return m1 + m2;
-}
-
-static int PixarLogFixupTags(TIFF *tif)
-{
- (void)tif;
- return (1);
-}
-
-static int PixarLogSetupDecode(TIFF *tif)
-{
- static const char module[] = "PixarLogSetupDecode";
- TIFFDirectory *td = &tif->tif_dir;
- PixarLogState *sp = PixarLogDecoderState(tif);
- tmsize_t tbuf_size;
- uint32_t strip_height;
-
- assert(sp != NULL);
-
- /* This function can possibly be called several times by */
- /* PredictorSetupDecode() if this function succeeds but */
- /* PredictorSetup() fails */
- if ((sp->state & PLSTATE_INIT) != 0)
- return 1;
-
- strip_height = td->td_rowsperstrip;
- if (strip_height > td->td_imagelength)
- strip_height = td->td_imagelength;
-
- /* Make sure no byte swapping happens on the data
- * after decompression. */
- tif->tif_postdecode = _TIFFNoPostDecode;
-
- /* for some reason, we can't do this in TIFFInitPixarLog */
-
- sp->stride =
- (td->td_planarconfig == PLANARCONFIG_CONTIG ? td->td_samplesperpixel
- : 1);
- tbuf_size = multiply_ms(
- multiply_ms(multiply_ms(sp->stride, td->td_imagewidth), strip_height),
- sizeof(uint16_t));
- /* add one more stride in case input ends mid-stride */
- tbuf_size = add_ms(tbuf_size, sizeof(uint16_t) * sp->stride);
- if (tbuf_size == 0)
- return (0); /* TODO: this is an error return without error report
- through TIFFErrorExt */
- sp->tbuf = (uint16_t *)_TIFFmallocExt(tif, tbuf_size);
- if (sp->tbuf == NULL)
- return (0);
- sp->tbuf_size = tbuf_size;
- if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN)
- sp->user_datafmt = PixarLogGuessDataFmt(td);
- if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN)
- {
- _TIFFfreeExt(tif, sp->tbuf);
- sp->tbuf = NULL;
- sp->tbuf_size = 0;
- TIFFErrorExtR(tif, module,
- "PixarLog compression can't handle bits depth/data "
- "format combination (depth: %" PRIu16 ")",
- td->td_bitspersample);
- return (0);
- }
-
- if (inflateInit(&sp->stream) != Z_OK)
- {
- _TIFFfreeExt(tif, sp->tbuf);
- sp->tbuf = NULL;
- sp->tbuf_size = 0;
- TIFFErrorExtR(tif, module, "%s",
- sp->stream.msg ? sp->stream.msg : "(null)");
- return (0);
- }
- else
- {
- sp->state |= PLSTATE_INIT;
- return (1);
- }
-}
-
-/*
- * Setup state for decoding a strip.
- */
-static int PixarLogPreDecode(TIFF *tif, uint16_t s)
-{
- static const char module[] = "PixarLogPreDecode";
- PixarLogState *sp = PixarLogDecoderState(tif);
-
- (void)s;
- assert(sp != NULL);
- sp->stream.next_in = tif->tif_rawdata;
- assert(sizeof(sp->stream.avail_in) == 4); /* if this assert gets raised,
- we need to simplify this code to reflect a ZLib that is likely updated
- to deal with 8byte memory sizes, though this code will respond
- appropriately even before we simplify it */
- sp->stream.avail_in = (uInt)tif->tif_rawcc;
- if ((tmsize_t)sp->stream.avail_in != tif->tif_rawcc)
- {
- TIFFErrorExtR(tif, module, "ZLib cannot deal with buffers this size");
- return (0);
- }
- return (inflateReset(&sp->stream) == Z_OK);
-}
-
-static int PixarLogDecode(TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s)
-{
- static const char module[] = "PixarLogDecode";
- TIFFDirectory *td = &tif->tif_dir;
- PixarLogState *sp = PixarLogDecoderState(tif);
- tmsize_t i;
- tmsize_t nsamples;
- int llen;
- uint16_t *up;
-
- switch (sp->user_datafmt)
- {
- case PIXARLOGDATAFMT_FLOAT:
- nsamples = occ / sizeof(float); /* XXX float == 32 bits */
- break;
- case PIXARLOGDATAFMT_16BIT:
- case PIXARLOGDATAFMT_12BITPICIO:
- case PIXARLOGDATAFMT_11BITLOG:
- nsamples = occ / sizeof(uint16_t); /* XXX uint16_t == 16 bits */
- break;
- case PIXARLOGDATAFMT_8BIT:
- case PIXARLOGDATAFMT_8BITABGR:
- nsamples = occ;
- break;
- default:
- TIFFErrorExtR(tif, module,
- "%" PRIu16 " bit input not supported in PixarLog",
- td->td_bitspersample);
- memset(op, 0, (size_t)occ);
- return 0;
- }
-
- llen = sp->stride * td->td_imagewidth;
-
- (void)s;
- assert(sp != NULL);
-
- sp->stream.next_in = tif->tif_rawcp;
- sp->stream.avail_in = (uInt)tif->tif_rawcc;
-
- sp->stream.next_out = (unsigned char *)sp->tbuf;
- assert(sizeof(sp->stream.avail_out) == 4); /* if this assert gets raised,
- we need to simplify this code to reflect a ZLib that is likely updated
- to deal with 8byte memory sizes, though this code will respond
- appropriately even before we simplify it */
- sp->stream.avail_out = (uInt)(nsamples * sizeof(uint16_t));
- if (sp->stream.avail_out != nsamples * sizeof(uint16_t))
- {
- TIFFErrorExtR(tif, module, "ZLib cannot deal with buffers this size");
- memset(op, 0, (size_t)occ);
- return (0);
- }
- /* Check that we will not fill more than what was allocated */
- if ((tmsize_t)sp->stream.avail_out > sp->tbuf_size)
- {
- TIFFErrorExtR(tif, module, "sp->stream.avail_out > sp->tbuf_size");
- memset(op, 0, (size_t)occ);
- return (0);
- }
- do
- {
- int state = inflate(&sp->stream, Z_PARTIAL_FLUSH);
- if (state == Z_STREAM_END)
- {
- break; /* XXX */
- }
- if (state == Z_DATA_ERROR)
- {
- TIFFErrorExtR(
- tif, module, "Decoding error at scanline %" PRIu32 ", %s",
- tif->tif_row, sp->stream.msg ? sp->stream.msg : "(null)");
- memset(op, 0, (size_t)occ);
- return (0);
- }
- if (state != Z_OK)
- {
- TIFFErrorExtR(tif, module, "ZLib error: %s",
- sp->stream.msg ? sp->stream.msg : "(null)");
- memset(op, 0, (size_t)occ);
- return (0);
- }
- } while (sp->stream.avail_out > 0);
-
- /* hopefully, we got all the bytes we needed */
- if (sp->stream.avail_out != 0)
- {
- TIFFErrorExtR(tif, module,
- "Not enough data at scanline %" PRIu32
- " (short %u bytes)",
- tif->tif_row, sp->stream.avail_out);
- memset(op, 0, (size_t)occ);
- return (0);
- }
-
- tif->tif_rawcp = sp->stream.next_in;
- tif->tif_rawcc = sp->stream.avail_in;
-
- up = sp->tbuf;
- /* Swap bytes in the data if from a different endian machine. */
- if (tif->tif_flags & TIFF_SWAB)
- TIFFSwabArrayOfShort(up, nsamples);
-
- /*
- * if llen is not an exact multiple of nsamples, the decode operation
- * may overflow the output buffer, so truncate it enough to prevent
- * that but still salvage as much data as possible.
- */
- if (nsamples % llen)
- {
- TIFFWarningExtR(tif, module,
- "stride %d is not a multiple of sample count, "
- "%" TIFF_SSIZE_FORMAT ", data truncated.",
- llen, nsamples);
- nsamples -= nsamples % llen;
- }
-
- for (i = 0; i < nsamples; i += llen, up += llen)
- {
- switch (sp->user_datafmt)
- {
- case PIXARLOGDATAFMT_FLOAT:
- horizontalAccumulateF(up, llen, sp->stride, (float *)op,
- sp->ToLinearF);
- op += llen * sizeof(float);
- break;
- case PIXARLOGDATAFMT_16BIT:
- horizontalAccumulate16(up, llen, sp->stride, (uint16_t *)op,
- sp->ToLinear16);
- op += llen * sizeof(uint16_t);
- break;
- case PIXARLOGDATAFMT_12BITPICIO:
- horizontalAccumulate12(up, llen, sp->stride, (int16_t *)op,
- sp->ToLinearF);
- op += llen * sizeof(int16_t);
- break;
- case PIXARLOGDATAFMT_11BITLOG:
- horizontalAccumulate11(up, llen, sp->stride, (uint16_t *)op);
- op += llen * sizeof(uint16_t);
- break;
- case PIXARLOGDATAFMT_8BIT:
- horizontalAccumulate8(up, llen, sp->stride, (unsigned char *)op,
- sp->ToLinear8);
- op += llen * sizeof(unsigned char);
- break;
- case PIXARLOGDATAFMT_8BITABGR:
- horizontalAccumulate8abgr(up, llen, sp->stride,
- (unsigned char *)op, sp->ToLinear8);
- op += llen * sizeof(unsigned char);
- break;
- default:
- TIFFErrorExtR(tif, module, "Unsupported bits/sample: %" PRIu16,
- td->td_bitspersample);
- memset(op, 0, (size_t)occ);
- return (0);
- }
- }
-
- return (1);
-}
-
-static int PixarLogSetupEncode(TIFF *tif)
-{
- static const char module[] = "PixarLogSetupEncode";
- TIFFDirectory *td = &tif->tif_dir;
- PixarLogState *sp = PixarLogEncoderState(tif);
- tmsize_t tbuf_size;
-
- assert(sp != NULL);
-
- /* for some reason, we can't do this in TIFFInitPixarLog */
-
- sp->stride =
- (td->td_planarconfig == PLANARCONFIG_CONTIG ? td->td_samplesperpixel
- : 1);
- tbuf_size =
- multiply_ms(multiply_ms(multiply_ms(sp->stride, td->td_imagewidth),
- td->td_rowsperstrip),
- sizeof(uint16_t));
- if (tbuf_size == 0)
- return (0); /* TODO: this is an error return without error report
- through TIFFErrorExt */
- sp->tbuf = (uint16_t *)_TIFFmallocExt(tif, tbuf_size);
- if (sp->tbuf == NULL)
- return (0);
- if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN)
- sp->user_datafmt = PixarLogGuessDataFmt(td);
- if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN)
- {
- TIFFErrorExtR(tif, module,
- "PixarLog compression can't handle %" PRIu16
- " bit linear encodings",
- td->td_bitspersample);
- return (0);
- }
-
- if (deflateInit(&sp->stream, sp->quality) != Z_OK)
- {
- TIFFErrorExtR(tif, module, "%s",
- sp->stream.msg ? sp->stream.msg : "(null)");
- return (0);
- }
- else
- {
- sp->state |= PLSTATE_INIT;
- return (1);
- }
-}
-
-/*
- * Reset encoding state at the start of a strip.
- */
-static int PixarLogPreEncode(TIFF *tif, uint16_t s)
-{
- static const char module[] = "PixarLogPreEncode";
- PixarLogState *sp = PixarLogEncoderState(tif);
-
- (void)s;
- assert(sp != NULL);
- sp->stream.next_out = tif->tif_rawdata;
- assert(sizeof(sp->stream.avail_out) == 4); /* if this assert gets raised,
- we need to simplify this code to reflect a ZLib that is likely updated
- to deal with 8byte memory sizes, though this code will respond
- appropriately even before we simplify it */
- sp->stream.avail_out = (uInt)tif->tif_rawdatasize;
- if ((tmsize_t)sp->stream.avail_out != tif->tif_rawdatasize)
- {
- TIFFErrorExtR(tif, module, "ZLib cannot deal with buffers this size");
- return (0);
- }
- return (deflateReset(&sp->stream) == Z_OK);
-}
-
-static void horizontalDifferenceF(float *ip, int n, int stride, uint16_t *wp,
- uint16_t *FromLT2)
-{
- int32_t r1, g1, b1, a1, r2, g2, b2, a2, mask;
- float fltsize = Fltsize;
-
-#define CLAMP(v) \
- ((v < (float)0.) ? 0 \
- : (v < (float)2.) ? FromLT2[(int)(v * fltsize)] \
- : (v > (float)24.2) ? 2047 \
- : LogK1 * log(v * LogK2) + 0.5)
-
- mask = CODE_MASK;
- if (n >= stride)
- {
- if (stride == 3)
- {
- r2 = wp[0] = (uint16_t)CLAMP(ip[0]);
- g2 = wp[1] = (uint16_t)CLAMP(ip[1]);
- b2 = wp[2] = (uint16_t)CLAMP(ip[2]);
- n -= 3;
- while (n > 0)
- {
- n -= 3;
- wp += 3;
- ip += 3;
- r1 = (int32_t)CLAMP(ip[0]);
- wp[0] = (uint16_t)((r1 - r2) & mask);
- r2 = r1;
- g1 = (int32_t)CLAMP(ip[1]);
- wp[1] = (uint16_t)((g1 - g2) & mask);
- g2 = g1;
- b1 = (int32_t)CLAMP(ip[2]);
- wp[2] = (uint16_t)((b1 - b2) & mask);
- b2 = b1;
- }
- }
- else if (stride == 4)
- {
- r2 = wp[0] = (uint16_t)CLAMP(ip[0]);
- g2 = wp[1] = (uint16_t)CLAMP(ip[1]);
- b2 = wp[2] = (uint16_t)CLAMP(ip[2]);
- a2 = wp[3] = (uint16_t)CLAMP(ip[3]);
- n -= 4;
- while (n > 0)
- {
- n -= 4;
- wp += 4;
- ip += 4;
- r1 = (int32_t)CLAMP(ip[0]);
- wp[0] = (uint16_t)((r1 - r2) & mask);
- r2 = r1;
- g1 = (int32_t)CLAMP(ip[1]);
- wp[1] = (uint16_t)((g1 - g2) & mask);
- g2 = g1;
- b1 = (int32_t)CLAMP(ip[2]);
- wp[2] = (uint16_t)((b1 - b2) & mask);
- b2 = b1;
- a1 = (int32_t)CLAMP(ip[3]);
- wp[3] = (uint16_t)((a1 - a2) & mask);
- a2 = a1;
- }
- }
- else
- {
- REPEAT(stride, wp[0] = (uint16_t)CLAMP(ip[0]); wp++; ip++)
- n -= stride;
- while (n > 0)
- {
- REPEAT(stride,
- wp[0] = (uint16_t)(((int32_t)CLAMP(ip[0]) -
- (int32_t)CLAMP(ip[-stride])) &
- mask);
- wp++; ip++)
- n -= stride;
- }
- }
- }
-}
-
-static void horizontalDifference16(unsigned short *ip, int n, int stride,
- unsigned short *wp, uint16_t *From14)
-{
- register int r1, g1, b1, a1, r2, g2, b2, a2, mask;
-
-/* assumption is unsigned pixel values */
-#undef CLAMP
-#define CLAMP(v) From14[(v) >> 2]
-
- mask = CODE_MASK;
- if (n >= stride)
- {
- if (stride == 3)
- {
- r2 = wp[0] = CLAMP(ip[0]);
- g2 = wp[1] = CLAMP(ip[1]);
- b2 = wp[2] = CLAMP(ip[2]);
- n -= 3;
- while (n > 0)
- {
- n -= 3;
- wp += 3;
- ip += 3;
- r1 = CLAMP(ip[0]);
- wp[0] = (uint16_t)((r1 - r2) & mask);
- r2 = r1;
- g1 = CLAMP(ip[1]);
- wp[1] = (uint16_t)((g1 - g2) & mask);
- g2 = g1;
- b1 = CLAMP(ip[2]);
- wp[2] = (uint16_t)((b1 - b2) & mask);
- b2 = b1;
- }
- }
- else if (stride == 4)
- {
- r2 = wp[0] = CLAMP(ip[0]);
- g2 = wp[1] = CLAMP(ip[1]);
- b2 = wp[2] = CLAMP(ip[2]);
- a2 = wp[3] = CLAMP(ip[3]);
- n -= 4;
- while (n > 0)
- {
- n -= 4;
- wp += 4;
- ip += 4;
- r1 = CLAMP(ip[0]);
- wp[0] = (uint16_t)((r1 - r2) & mask);
- r2 = r1;
- g1 = CLAMP(ip[1]);
- wp[1] = (uint16_t)((g1 - g2) & mask);
- g2 = g1;
- b1 = CLAMP(ip[2]);
- wp[2] = (uint16_t)((b1 - b2) & mask);
- b2 = b1;
- a1 = CLAMP(ip[3]);
- wp[3] = (uint16_t)((a1 - a2) & mask);
- a2 = a1;
- }
- }
- else
- {
- REPEAT(stride, wp[0] = CLAMP(ip[0]); wp++; ip++)
- n -= stride;
- while (n > 0)
- {
- REPEAT(stride,
- wp[0] = (uint16_t)((CLAMP(ip[0]) - CLAMP(ip[-stride])) &
- mask);
- wp++; ip++)
- n -= stride;
- }
- }
- }
-}
-
-static void horizontalDifference8(unsigned char *ip, int n, int stride,
- unsigned short *wp, uint16_t *From8)
-{
- register int r1, g1, b1, a1, r2, g2, b2, a2, mask;
-
-#undef CLAMP
-#define CLAMP(v) (From8[(v)])
-
- mask = CODE_MASK;
- if (n >= stride)
- {
- if (stride == 3)
- {
- r2 = wp[0] = CLAMP(ip[0]);
- g2 = wp[1] = CLAMP(ip[1]);
- b2 = wp[2] = CLAMP(ip[2]);
- n -= 3;
- while (n > 0)
- {
- n -= 3;
- r1 = CLAMP(ip[3]);
- wp[3] = (uint16_t)((r1 - r2) & mask);
- r2 = r1;
- g1 = CLAMP(ip[4]);
- wp[4] = (uint16_t)((g1 - g2) & mask);
- g2 = g1;
- b1 = CLAMP(ip[5]);
- wp[5] = (uint16_t)((b1 - b2) & mask);
- b2 = b1;
- wp += 3;
- ip += 3;
- }
- }
- else if (stride == 4)
- {
- r2 = wp[0] = CLAMP(ip[0]);
- g2 = wp[1] = CLAMP(ip[1]);
- b2 = wp[2] = CLAMP(ip[2]);
- a2 = wp[3] = CLAMP(ip[3]);
- n -= 4;
- while (n > 0)
- {
- n -= 4;
- r1 = CLAMP(ip[4]);
- wp[4] = (uint16_t)((r1 - r2) & mask);
- r2 = r1;
- g1 = CLAMP(ip[5]);
- wp[5] = (uint16_t)((g1 - g2) & mask);
- g2 = g1;
- b1 = CLAMP(ip[6]);
- wp[6] = (uint16_t)((b1 - b2) & mask);
- b2 = b1;
- a1 = CLAMP(ip[7]);
- wp[7] = (uint16_t)((a1 - a2) & mask);
- a2 = a1;
- wp += 4;
- ip += 4;
- }
- }
- else
- {
- REPEAT(stride, wp[0] = CLAMP(ip[0]); wp++; ip++)
- n -= stride;
- while (n > 0)
- {
- REPEAT(stride,
- wp[0] = (uint16_t)((CLAMP(ip[0]) - CLAMP(ip[-stride])) &
- mask);
- wp++; ip++)
- n -= stride;
- }
- }
- }
-}
-
-/*
- * Encode a chunk of pixels.
- */
-static int PixarLogEncode(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s)
-{
- static const char module[] = "PixarLogEncode";
- TIFFDirectory *td = &tif->tif_dir;
- PixarLogState *sp = PixarLogEncoderState(tif);
- tmsize_t i;
- tmsize_t n;
- int llen;
- unsigned short *up;
-
- (void)s;
-
- switch (sp->user_datafmt)
- {
- case PIXARLOGDATAFMT_FLOAT:
- n = cc / sizeof(float); /* XXX float == 32 bits */
- break;
- case PIXARLOGDATAFMT_16BIT:
- case PIXARLOGDATAFMT_12BITPICIO:
- case PIXARLOGDATAFMT_11BITLOG:
- n = cc / sizeof(uint16_t); /* XXX uint16_t == 16 bits */
- break;
- case PIXARLOGDATAFMT_8BIT:
- case PIXARLOGDATAFMT_8BITABGR:
- n = cc;
- break;
- default:
- TIFFErrorExtR(tif, module,
- "%" PRIu16 " bit input not supported in PixarLog",
- td->td_bitspersample);
- return 0;
- }
-
- llen = sp->stride * td->td_imagewidth;
- /* Check against the number of elements (of size uint16_t) of sp->tbuf */
- if (n > ((tmsize_t)td->td_rowsperstrip * llen))
- {
- TIFFErrorExtR(tif, module, "Too many input bytes provided");
- return 0;
- }
-
- for (i = 0, up = sp->tbuf; i < n; i += llen, up += llen)
- {
- switch (sp->user_datafmt)
- {
- case PIXARLOGDATAFMT_FLOAT:
- horizontalDifferenceF((float *)bp, llen, sp->stride, up,
- sp->FromLT2);
- bp += llen * sizeof(float);
- break;
- case PIXARLOGDATAFMT_16BIT:
- horizontalDifference16((uint16_t *)bp, llen, sp->stride, up,
- sp->From14);
- bp += llen * sizeof(uint16_t);
- break;
- case PIXARLOGDATAFMT_8BIT:
- horizontalDifference8((unsigned char *)bp, llen, sp->stride, up,
- sp->From8);
- bp += llen * sizeof(unsigned char);
- break;
- default:
- TIFFErrorExtR(tif, module,
- "%" PRIu16 " bit input not supported in PixarLog",
- td->td_bitspersample);
- return 0;
- }
- }
-
- sp->stream.next_in = (unsigned char *)sp->tbuf;
- assert(sizeof(sp->stream.avail_in) == 4); /* if this assert gets raised,
- we need to simplify this code to reflect a ZLib that is likely updated
- to deal with 8byte memory sizes, though this code will respond
- appropriately even before we simplify it */
- sp->stream.avail_in = (uInt)(n * sizeof(uint16_t));
- if ((sp->stream.avail_in / sizeof(uint16_t)) != (uInt)n)
- {
- TIFFErrorExtR(tif, module, "ZLib cannot deal with buffers this size");
- return (0);
- }
-
- do
- {
- if (deflate(&sp->stream, Z_NO_FLUSH) != Z_OK)
- {
- TIFFErrorExtR(tif, module, "Encoder error: %s",
- sp->stream.msg ? sp->stream.msg : "(null)");
- return (0);
- }
- if (sp->stream.avail_out == 0)
- {
- tif->tif_rawcc = tif->tif_rawdatasize;
- if (!TIFFFlushData1(tif))
- return 0;
- sp->stream.next_out = tif->tif_rawdata;
- sp->stream.avail_out =
- (uInt)tif
- ->tif_rawdatasize; /* this is a safe typecast, as check is
- made already in PixarLogPreEncode */
- }
- } while (sp->stream.avail_in > 0);
- return (1);
-}
-
-/*
- * Finish off an encoded strip by flushing the last
- * string and tacking on an End Of Information code.
- */
-
-static int PixarLogPostEncode(TIFF *tif)
-{
- static const char module[] = "PixarLogPostEncode";
- PixarLogState *sp = PixarLogEncoderState(tif);
- int state;
-
- sp->stream.avail_in = 0;
-
- do
- {
- state = deflate(&sp->stream, Z_FINISH);
- switch (state)
- {
- case Z_STREAM_END:
- case Z_OK:
- if ((tmsize_t)sp->stream.avail_out != tif->tif_rawdatasize)
- {
- tif->tif_rawcc =
- tif->tif_rawdatasize - sp->stream.avail_out;
- if (!TIFFFlushData1(tif))
- return 0;
- sp->stream.next_out = tif->tif_rawdata;
- sp->stream.avail_out =
- (uInt)tif->tif_rawdatasize; /* this is a safe typecast,
- as check is made already
- in PixarLogPreEncode */
- }
- break;
- default:
- TIFFErrorExtR(tif, module, "ZLib error: %s",
- sp->stream.msg ? sp->stream.msg : "(null)");
- return (0);
- }
- } while (state != Z_STREAM_END);
- return (1);
-}
-
-static void PixarLogClose(TIFF *tif)
-{
- PixarLogState *sp = (PixarLogState *)tif->tif_data;
- TIFFDirectory *td = &tif->tif_dir;
-
- assert(sp != 0);
- /* In a really sneaky (and really incorrect, and untruthful, and
- * troublesome, and error-prone) maneuver that completely goes against
- * the spirit of TIFF, and breaks TIFF, on close, we covertly
- * modify both bitspersample and sampleformat in the directory to
- * indicate 8-bit linear. This way, the decode "just works" even for
- * readers that don't know about PixarLog, or how to set
- * the PIXARLOGDATFMT pseudo-tag.
- */
-
- if (sp->state & PLSTATE_INIT)
- {
- /* We test the state to avoid an issue such as in
- * http://bugzilla.maptools.org/show_bug.cgi?id=2604
- * What appends in that case is that the bitspersample is 1 and
- * a TransferFunction is set. The size of the TransferFunction
- * depends on 1<<bitspersample. So if we increase it, an access
- * out of the buffer will happen at directory flushing.
- * Another option would be to clear those targs.
- */
- td->td_bitspersample = 8;
- td->td_sampleformat = SAMPLEFORMAT_UINT;
- }
-}
-
-static void PixarLogCleanup(TIFF *tif)
-{
- PixarLogState *sp = (PixarLogState *)tif->tif_data;
-
- assert(sp != 0);
-
- (void)TIFFPredictorCleanup(tif);
-
- tif->tif_tagmethods.vgetfield = sp->vgetparent;
- tif->tif_tagmethods.vsetfield = sp->vsetparent;
-
- if (sp->FromLT2)
- _TIFFfreeExt(tif, sp->FromLT2);
- if (sp->From14)
- _TIFFfreeExt(tif, sp->From14);
- if (sp->From8)
- _TIFFfreeExt(tif, sp->From8);
- if (sp->ToLinearF)
- _TIFFfreeExt(tif, sp->ToLinearF);
- if (sp->ToLinear16)
- _TIFFfreeExt(tif, sp->ToLinear16);
- if (sp->ToLinear8)
- _TIFFfreeExt(tif, sp->ToLinear8);
- if (sp->state & PLSTATE_INIT)
- {
- if (tif->tif_mode == O_RDONLY)
- inflateEnd(&sp->stream);
- else
- deflateEnd(&sp->stream);
- }
- if (sp->tbuf)
- _TIFFfreeExt(tif, sp->tbuf);
- _TIFFfreeExt(tif, sp);
- tif->tif_data = NULL;
-
- _TIFFSetDefaultCompressionState(tif);
-}
-
-static int PixarLogVSetField(TIFF *tif, uint32_t tag, va_list ap)
-{
- static const char module[] = "PixarLogVSetField";
- PixarLogState *sp = (PixarLogState *)tif->tif_data;
- int result;
-
- switch (tag)
- {
- case TIFFTAG_PIXARLOGQUALITY:
- sp->quality = (int)va_arg(ap, int);
- if (tif->tif_mode != O_RDONLY && (sp->state & PLSTATE_INIT))
- {
- if (deflateParams(&sp->stream, sp->quality,
- Z_DEFAULT_STRATEGY) != Z_OK)
- {
- TIFFErrorExtR(tif, module, "ZLib error: %s",
- sp->stream.msg ? sp->stream.msg : "(null)");
- return (0);
- }
- }
- return (1);
- case TIFFTAG_PIXARLOGDATAFMT:
- sp->user_datafmt = (int)va_arg(ap, int);
- /* Tweak the TIFF header so that the rest of libtiff knows what
- * size of data will be passed between app and library, and
- * assume that the app knows what it is doing and is not
- * confused by these header manipulations...
- */
- switch (sp->user_datafmt)
- {
- case PIXARLOGDATAFMT_8BIT:
- case PIXARLOGDATAFMT_8BITABGR:
- TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8);
- TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT);
- break;
- case PIXARLOGDATAFMT_11BITLOG:
- TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 16);
- TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT);
- break;
- case PIXARLOGDATAFMT_12BITPICIO:
- TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 16);
- TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_INT);
- break;
- case PIXARLOGDATAFMT_16BIT:
- TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 16);
- TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT);
- break;
- case PIXARLOGDATAFMT_FLOAT:
- TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 32);
- TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT,
- SAMPLEFORMAT_IEEEFP);
- break;
- }
- /*
- * Must recalculate sizes should bits/sample change.
- */
- tif->tif_tilesize =
- isTiled(tif) ? TIFFTileSize(tif) : (tmsize_t)(-1);
- tif->tif_scanlinesize = TIFFScanlineSize(tif);
- result = 1; /* NB: pseudo tag */
- break;
- default:
- result = (*sp->vsetparent)(tif, tag, ap);
- }
- return (result);
-}
-
-static int PixarLogVGetField(TIFF *tif, uint32_t tag, va_list ap)
-{
- PixarLogState *sp = (PixarLogState *)tif->tif_data;
-
- switch (tag)
- {
- case TIFFTAG_PIXARLOGQUALITY:
- *va_arg(ap, int *) = sp->quality;
- break;
- case TIFFTAG_PIXARLOGDATAFMT:
- *va_arg(ap, int *) = sp->user_datafmt;
- break;
- default:
- return (*sp->vgetparent)(tif, tag, ap);
- }
- return (1);
-}
-
-static const TIFFField pixarlogFields[] = {
- {TIFFTAG_PIXARLOGDATAFMT, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT,
- TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, FALSE, FALSE, "", NULL},
- {TIFFTAG_PIXARLOGQUALITY, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT,
- TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, FALSE, FALSE, "", NULL}};
-
-int TIFFInitPixarLog(TIFF *tif, int scheme)
-{
- static const char module[] = "TIFFInitPixarLog";
-
- PixarLogState *sp;
-
- (void)scheme;
- assert(scheme == COMPRESSION_PIXARLOG);
-
- /*
- * Merge codec-specific tag information.
- */
- if (!_TIFFMergeFields(tif, pixarlogFields, TIFFArrayCount(pixarlogFields)))
- {
- TIFFErrorExtR(tif, module,
- "Merging PixarLog codec-specific tags failed");
- return 0;
- }
-
- /*
- * Allocate state block so tag methods have storage to record values.
- */
- tif->tif_data = (uint8_t *)_TIFFmallocExt(tif, sizeof(PixarLogState));
- if (tif->tif_data == NULL)
- goto bad;
- sp = (PixarLogState *)tif->tif_data;
- _TIFFmemset(sp, 0, sizeof(*sp));
- sp->stream.data_type = Z_BINARY;
- sp->user_datafmt = PIXARLOGDATAFMT_UNKNOWN;
-
- /*
- * Install codec methods.
- */
- tif->tif_fixuptags = PixarLogFixupTags;
- tif->tif_setupdecode = PixarLogSetupDecode;
- tif->tif_predecode = PixarLogPreDecode;
- tif->tif_decoderow = PixarLogDecode;
- tif->tif_decodestrip = PixarLogDecode;
- tif->tif_decodetile = PixarLogDecode;
- tif->tif_setupencode = PixarLogSetupEncode;
- tif->tif_preencode = PixarLogPreEncode;
- tif->tif_postencode = PixarLogPostEncode;
- tif->tif_encoderow = PixarLogEncode;
- tif->tif_encodestrip = PixarLogEncode;
- tif->tif_encodetile = PixarLogEncode;
- tif->tif_close = PixarLogClose;
- tif->tif_cleanup = PixarLogCleanup;
-
- /* Override SetField so we can handle our private pseudo-tag */
- sp->vgetparent = tif->tif_tagmethods.vgetfield;
- tif->tif_tagmethods.vgetfield = PixarLogVGetField; /* hook for codec tags */
- sp->vsetparent = tif->tif_tagmethods.vsetfield;
- tif->tif_tagmethods.vsetfield = PixarLogVSetField; /* hook for codec tags */
-
- /* Default values for codec-specific fields */
- sp->quality = Z_DEFAULT_COMPRESSION; /* default comp. level */
- sp->state = 0;
-
- /* we don't wish to use the predictor,
- * the default is none, which predictor value 1
- */
- (void)TIFFPredictorInit(tif);
-
- /*
- * build the companding tables
- */
- PixarLogMakeTables(tif, sp);
-
- return (1);
-bad:
- TIFFErrorExtR(tif, module, "No space for PixarLog state block");
- return (0);
-}
-#endif /* PIXARLOG_SUPPORT */
diff --git a/contrib/libs/libtiff/tif_predict.c b/contrib/libs/libtiff/tif_predict.c
deleted file mode 100644
index 386b5fe82a..0000000000
--- a/contrib/libs/libtiff/tif_predict.c
+++ /dev/null
@@ -1,1046 +0,0 @@
-/*
- * Copyright (c) 1988-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-/*
- * TIFF Library.
- *
- * Predictor Tag Support (used by multiple codecs).
- */
-#include "tif_predict.h"
-#include "tiffiop.h"
-
-#define PredictorState(tif) ((TIFFPredictorState *)(tif)->tif_data)
-
-static int horAcc8(TIFF *tif, uint8_t *cp0, tmsize_t cc);
-static int horAcc16(TIFF *tif, uint8_t *cp0, tmsize_t cc);
-static int horAcc32(TIFF *tif, uint8_t *cp0, tmsize_t cc);
-static int horAcc64(TIFF *tif, uint8_t *cp0, tmsize_t cc);
-static int swabHorAcc16(TIFF *tif, uint8_t *cp0, tmsize_t cc);
-static int swabHorAcc32(TIFF *tif, uint8_t *cp0, tmsize_t cc);
-static int swabHorAcc64(TIFF *tif, uint8_t *cp0, tmsize_t cc);
-static int horDiff8(TIFF *tif, uint8_t *cp0, tmsize_t cc);
-static int horDiff16(TIFF *tif, uint8_t *cp0, tmsize_t cc);
-static int horDiff32(TIFF *tif, uint8_t *cp0, tmsize_t cc);
-static int horDiff64(TIFF *tif, uint8_t *cp0, tmsize_t cc);
-static int swabHorDiff16(TIFF *tif, uint8_t *cp0, tmsize_t cc);
-static int swabHorDiff32(TIFF *tif, uint8_t *cp0, tmsize_t cc);
-static int swabHorDiff64(TIFF *tif, uint8_t *cp0, tmsize_t cc);
-static int fpAcc(TIFF *tif, uint8_t *cp0, tmsize_t cc);
-static int fpDiff(TIFF *tif, uint8_t *cp0, tmsize_t cc);
-static int PredictorDecodeRow(TIFF *tif, uint8_t *op0, tmsize_t occ0,
- uint16_t s);
-static int PredictorDecodeTile(TIFF *tif, uint8_t *op0, tmsize_t occ0,
- uint16_t s);
-static int PredictorEncodeRow(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s);
-static int PredictorEncodeTile(TIFF *tif, uint8_t *bp0, tmsize_t cc0,
- uint16_t s);
-
-static int PredictorSetup(TIFF *tif)
-{
- static const char module[] = "PredictorSetup";
-
- TIFFPredictorState *sp = PredictorState(tif);
- TIFFDirectory *td = &tif->tif_dir;
-
- switch (sp->predictor) /* no differencing */
- {
- case PREDICTOR_NONE:
- return 1;
- case PREDICTOR_HORIZONTAL:
- if (td->td_bitspersample != 8 && td->td_bitspersample != 16 &&
- td->td_bitspersample != 32 && td->td_bitspersample != 64)
- {
- TIFFErrorExtR(tif, module,
- "Horizontal differencing \"Predictor\" not "
- "supported with %" PRIu16 "-bit samples",
- td->td_bitspersample);
- return 0;
- }
- break;
- case PREDICTOR_FLOATINGPOINT:
- if (td->td_sampleformat != SAMPLEFORMAT_IEEEFP)
- {
- TIFFErrorExtR(
- tif, module,
- "Floating point \"Predictor\" not supported with %" PRIu16
- " data format",
- td->td_sampleformat);
- return 0;
- }
- if (td->td_bitspersample != 16 && td->td_bitspersample != 24 &&
- td->td_bitspersample != 32 && td->td_bitspersample != 64)
- { /* Should 64 be allowed? */
- TIFFErrorExtR(
- tif, module,
- "Floating point \"Predictor\" not supported with %" PRIu16
- "-bit samples",
- td->td_bitspersample);
- return 0;
- }
- break;
- default:
- TIFFErrorExtR(tif, module, "\"Predictor\" value %d not supported",
- sp->predictor);
- return 0;
- }
- sp->stride =
- (td->td_planarconfig == PLANARCONFIG_CONTIG ? td->td_samplesperpixel
- : 1);
- /*
- * Calculate the scanline/tile-width size in bytes.
- */
- if (isTiled(tif))
- sp->rowsize = TIFFTileRowSize(tif);
- else
- sp->rowsize = TIFFScanlineSize(tif);
- if (sp->rowsize == 0)
- return 0;
-
- return 1;
-}
-
-static int PredictorSetupDecode(TIFF *tif)
-{
- TIFFPredictorState *sp = PredictorState(tif);
- TIFFDirectory *td = &tif->tif_dir;
-
- /* Note: when PredictorSetup() fails, the effets of setupdecode() */
- /* will not be "canceled" so setupdecode() might be robust to */
- /* be called several times. */
- if (!(*sp->setupdecode)(tif) || !PredictorSetup(tif))
- return 0;
-
- if (sp->predictor == 2)
- {
- switch (td->td_bitspersample)
- {
- case 8:
- sp->decodepfunc = horAcc8;
- break;
- case 16:
- sp->decodepfunc = horAcc16;
- break;
- case 32:
- sp->decodepfunc = horAcc32;
- break;
- case 64:
- sp->decodepfunc = horAcc64;
- break;
- }
- /*
- * Override default decoding method with one that does the
- * predictor stuff.
- */
- if (tif->tif_decoderow != PredictorDecodeRow)
- {
- sp->decoderow = tif->tif_decoderow;
- tif->tif_decoderow = PredictorDecodeRow;
- sp->decodestrip = tif->tif_decodestrip;
- tif->tif_decodestrip = PredictorDecodeTile;
- sp->decodetile = tif->tif_decodetile;
- tif->tif_decodetile = PredictorDecodeTile;
- }
-
- /*
- * If the data is horizontally differenced 16-bit data that
- * requires byte-swapping, then it must be byte swapped before
- * the accumulation step. We do this with a special-purpose
- * routine and override the normal post decoding logic that
- * the library setup when the directory was read.
- */
- if (tif->tif_flags & TIFF_SWAB)
- {
- if (sp->decodepfunc == horAcc16)
- {
- sp->decodepfunc = swabHorAcc16;
- tif->tif_postdecode = _TIFFNoPostDecode;
- }
- else if (sp->decodepfunc == horAcc32)
- {
- sp->decodepfunc = swabHorAcc32;
- tif->tif_postdecode = _TIFFNoPostDecode;
- }
- else if (sp->decodepfunc == horAcc64)
- {
- sp->decodepfunc = swabHorAcc64;
- tif->tif_postdecode = _TIFFNoPostDecode;
- }
- }
- }
-
- else if (sp->predictor == 3)
- {
- sp->decodepfunc = fpAcc;
- /*
- * Override default decoding method with one that does the
- * predictor stuff.
- */
- if (tif->tif_decoderow != PredictorDecodeRow)
- {
- sp->decoderow = tif->tif_decoderow;
- tif->tif_decoderow = PredictorDecodeRow;
- sp->decodestrip = tif->tif_decodestrip;
- tif->tif_decodestrip = PredictorDecodeTile;
- sp->decodetile = tif->tif_decodetile;
- tif->tif_decodetile = PredictorDecodeTile;
- }
- /*
- * The data should not be swapped outside of the floating
- * point predictor, the accumulation routine should return
- * byres in the native order.
- */
- if (tif->tif_flags & TIFF_SWAB)
- {
- tif->tif_postdecode = _TIFFNoPostDecode;
- }
- /*
- * Allocate buffer to keep the decoded bytes before
- * rearranging in the right order
- */
- }
-
- return 1;
-}
-
-static int PredictorSetupEncode(TIFF *tif)
-{
- TIFFPredictorState *sp = PredictorState(tif);
- TIFFDirectory *td = &tif->tif_dir;
-
- if (!(*sp->setupencode)(tif) || !PredictorSetup(tif))
- return 0;
-
- if (sp->predictor == 2)
- {
- switch (td->td_bitspersample)
- {
- case 8:
- sp->encodepfunc = horDiff8;
- break;
- case 16:
- sp->encodepfunc = horDiff16;
- break;
- case 32:
- sp->encodepfunc = horDiff32;
- break;
- case 64:
- sp->encodepfunc = horDiff64;
- break;
- }
- /*
- * Override default encoding method with one that does the
- * predictor stuff.
- */
- if (tif->tif_encoderow != PredictorEncodeRow)
- {
- sp->encoderow = tif->tif_encoderow;
- tif->tif_encoderow = PredictorEncodeRow;
- sp->encodestrip = tif->tif_encodestrip;
- tif->tif_encodestrip = PredictorEncodeTile;
- sp->encodetile = tif->tif_encodetile;
- tif->tif_encodetile = PredictorEncodeTile;
- }
-
- /*
- * If the data is horizontally differenced 16-bit data that
- * requires byte-swapping, then it must be byte swapped after
- * the differentiation step. We do this with a special-purpose
- * routine and override the normal post decoding logic that
- * the library setup when the directory was read.
- */
- if (tif->tif_flags & TIFF_SWAB)
- {
- if (sp->encodepfunc == horDiff16)
- {
- sp->encodepfunc = swabHorDiff16;
- tif->tif_postdecode = _TIFFNoPostDecode;
- }
- else if (sp->encodepfunc == horDiff32)
- {
- sp->encodepfunc = swabHorDiff32;
- tif->tif_postdecode = _TIFFNoPostDecode;
- }
- else if (sp->encodepfunc == horDiff64)
- {
- sp->encodepfunc = swabHorDiff64;
- tif->tif_postdecode = _TIFFNoPostDecode;
- }
- }
- }
-
- else if (sp->predictor == 3)
- {
- sp->encodepfunc = fpDiff;
- /*
- * Override default encoding method with one that does the
- * predictor stuff.
- */
- if (tif->tif_encoderow != PredictorEncodeRow)
- {
- sp->encoderow = tif->tif_encoderow;
- tif->tif_encoderow = PredictorEncodeRow;
- sp->encodestrip = tif->tif_encodestrip;
- tif->tif_encodestrip = PredictorEncodeTile;
- sp->encodetile = tif->tif_encodetile;
- tif->tif_encodetile = PredictorEncodeTile;
- }
- }
-
- return 1;
-}
-
-#define REPEAT4(n, op) \
- switch (n) \
- { \
- default: \
- { \
- tmsize_t i; \
- for (i = n - 4; i > 0; i--) \
- { \
- op; \
- } \
- } /*-fallthrough*/ \
- case 4: \
- op; /*-fallthrough*/ \
- case 3: \
- op; /*-fallthrough*/ \
- case 2: \
- op; /*-fallthrough*/ \
- case 1: \
- op; /*-fallthrough*/ \
- case 0:; \
- }
-
-/* Remarks related to C standard compliance in all below functions : */
-/* - to avoid any undefined behavior, we only operate on unsigned types */
-/* since the behavior of "overflows" is defined (wrap over) */
-/* - when storing into the byte stream, we explicitly mask with 0xff so */
-/* as to make icc -check=conversions happy (not necessary by the standard) */
-
-TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW
-static int horAcc8(TIFF *tif, uint8_t *cp0, tmsize_t cc)
-{
- tmsize_t stride = PredictorState(tif)->stride;
-
- unsigned char *cp = (unsigned char *)cp0;
- if ((cc % stride) != 0)
- {
- TIFFErrorExtR(tif, "horAcc8", "%s", "(cc%stride)!=0");
- return 0;
- }
-
- if (cc > stride)
- {
- /*
- * Pipeline the most common cases.
- */
- if (stride == 3)
- {
- unsigned int cr = cp[0];
- unsigned int cg = cp[1];
- unsigned int cb = cp[2];
- tmsize_t i = stride;
- for (; i < cc; i += stride)
- {
- cp[i + 0] = (unsigned char)((cr += cp[i + 0]) & 0xff);
- cp[i + 1] = (unsigned char)((cg += cp[i + 1]) & 0xff);
- cp[i + 2] = (unsigned char)((cb += cp[i + 2]) & 0xff);
- }
- }
- else if (stride == 4)
- {
- unsigned int cr = cp[0];
- unsigned int cg = cp[1];
- unsigned int cb = cp[2];
- unsigned int ca = cp[3];
- tmsize_t i = stride;
- for (; i < cc; i += stride)
- {
- cp[i + 0] = (unsigned char)((cr += cp[i + 0]) & 0xff);
- cp[i + 1] = (unsigned char)((cg += cp[i + 1]) & 0xff);
- cp[i + 2] = (unsigned char)((cb += cp[i + 2]) & 0xff);
- cp[i + 3] = (unsigned char)((ca += cp[i + 3]) & 0xff);
- }
- }
- else
- {
- cc -= stride;
- do
- {
- REPEAT4(stride,
- cp[stride] = (unsigned char)((cp[stride] + *cp) & 0xff);
- cp++)
- cc -= stride;
- } while (cc > 0);
- }
- }
- return 1;
-}
-
-static int swabHorAcc16(TIFF *tif, uint8_t *cp0, tmsize_t cc)
-{
- uint16_t *wp = (uint16_t *)cp0;
- tmsize_t wc = cc / 2;
-
- TIFFSwabArrayOfShort(wp, wc);
- return horAcc16(tif, cp0, cc);
-}
-
-TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW
-static int horAcc16(TIFF *tif, uint8_t *cp0, tmsize_t cc)
-{
- tmsize_t stride = PredictorState(tif)->stride;
- uint16_t *wp = (uint16_t *)cp0;
- tmsize_t wc = cc / 2;
-
- if ((cc % (2 * stride)) != 0)
- {
- TIFFErrorExtR(tif, "horAcc16", "%s", "cc%(2*stride))!=0");
- return 0;
- }
-
- if (wc > stride)
- {
- wc -= stride;
- do
- {
- REPEAT4(stride, wp[stride] = (uint16_t)(((unsigned int)wp[stride] +
- (unsigned int)wp[0]) &
- 0xffff);
- wp++)
- wc -= stride;
- } while (wc > 0);
- }
- return 1;
-}
-
-static int swabHorAcc32(TIFF *tif, uint8_t *cp0, tmsize_t cc)
-{
- uint32_t *wp = (uint32_t *)cp0;
- tmsize_t wc = cc / 4;
-
- TIFFSwabArrayOfLong(wp, wc);
- return horAcc32(tif, cp0, cc);
-}
-
-TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW
-static int horAcc32(TIFF *tif, uint8_t *cp0, tmsize_t cc)
-{
- tmsize_t stride = PredictorState(tif)->stride;
- uint32_t *wp = (uint32_t *)cp0;
- tmsize_t wc = cc / 4;
-
- if ((cc % (4 * stride)) != 0)
- {
- TIFFErrorExtR(tif, "horAcc32", "%s", "cc%(4*stride))!=0");
- return 0;
- }
-
- if (wc > stride)
- {
- wc -= stride;
- do
- {
- REPEAT4(stride, wp[stride] += wp[0]; wp++)
- wc -= stride;
- } while (wc > 0);
- }
- return 1;
-}
-
-static int swabHorAcc64(TIFF *tif, uint8_t *cp0, tmsize_t cc)
-{
- uint64_t *wp = (uint64_t *)cp0;
- tmsize_t wc = cc / 8;
-
- TIFFSwabArrayOfLong8(wp, wc);
- return horAcc64(tif, cp0, cc);
-}
-
-TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW
-static int horAcc64(TIFF *tif, uint8_t *cp0, tmsize_t cc)
-{
- tmsize_t stride = PredictorState(tif)->stride;
- uint64_t *wp = (uint64_t *)cp0;
- tmsize_t wc = cc / 8;
-
- if ((cc % (8 * stride)) != 0)
- {
- TIFFErrorExtR(tif, "horAcc64", "%s", "cc%(8*stride))!=0");
- return 0;
- }
-
- if (wc > stride)
- {
- wc -= stride;
- do
- {
- REPEAT4(stride, wp[stride] += wp[0]; wp++)
- wc -= stride;
- } while (wc > 0);
- }
- return 1;
-}
-
-/*
- * Floating point predictor accumulation routine.
- */
-static int fpAcc(TIFF *tif, uint8_t *cp0, tmsize_t cc)
-{
- tmsize_t stride = PredictorState(tif)->stride;
- uint32_t bps = tif->tif_dir.td_bitspersample / 8;
- tmsize_t wc = cc / bps;
- tmsize_t count = cc;
- uint8_t *cp = (uint8_t *)cp0;
- uint8_t *tmp;
-
- if (cc % (bps * stride) != 0)
- {
- TIFFErrorExtR(tif, "fpAcc", "%s", "cc%(bps*stride))!=0");
- return 0;
- }
-
- tmp = (uint8_t *)_TIFFmallocExt(tif, cc);
- if (!tmp)
- return 0;
-
- while (count > stride)
- {
- REPEAT4(stride,
- cp[stride] = (unsigned char)((cp[stride] + cp[0]) & 0xff);
- cp++)
- count -= stride;
- }
-
- _TIFFmemcpy(tmp, cp0, cc);
- cp = (uint8_t *)cp0;
- for (count = 0; count < wc; count++)
- {
- uint32_t byte;
- for (byte = 0; byte < bps; byte++)
- {
-#if WORDS_BIGENDIAN
- cp[bps * count + byte] = tmp[byte * wc + count];
-#else
- cp[bps * count + byte] = tmp[(bps - byte - 1) * wc + count];
-#endif
- }
- }
- _TIFFfreeExt(tif, tmp);
- return 1;
-}
-
-/*
- * Decode a scanline and apply the predictor routine.
- */
-static int PredictorDecodeRow(TIFF *tif, uint8_t *op0, tmsize_t occ0,
- uint16_t s)
-{
- TIFFPredictorState *sp = PredictorState(tif);
-
- assert(sp != NULL);
- assert(sp->decoderow != NULL);
- assert(sp->decodepfunc != NULL);
-
- if ((*sp->decoderow)(tif, op0, occ0, s))
- {
- return (*sp->decodepfunc)(tif, op0, occ0);
- }
- else
- return 0;
-}
-
-/*
- * Decode a tile/strip and apply the predictor routine.
- * Note that horizontal differencing must be done on a
- * row-by-row basis. The width of a "row" has already
- * been calculated at pre-decode time according to the
- * strip/tile dimensions.
- */
-static int PredictorDecodeTile(TIFF *tif, uint8_t *op0, tmsize_t occ0,
- uint16_t s)
-{
- TIFFPredictorState *sp = PredictorState(tif);
-
- assert(sp != NULL);
- assert(sp->decodetile != NULL);
-
- if ((*sp->decodetile)(tif, op0, occ0, s))
- {
- tmsize_t rowsize = sp->rowsize;
- assert(rowsize > 0);
- if ((occ0 % rowsize) != 0)
- {
- TIFFErrorExtR(tif, "PredictorDecodeTile", "%s",
- "occ0%rowsize != 0");
- return 0;
- }
- assert(sp->decodepfunc != NULL);
- while (occ0 > 0)
- {
- if (!(*sp->decodepfunc)(tif, op0, rowsize))
- return 0;
- occ0 -= rowsize;
- op0 += rowsize;
- }
- return 1;
- }
- else
- return 0;
-}
-
-TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW
-static int horDiff8(TIFF *tif, uint8_t *cp0, tmsize_t cc)
-{
- TIFFPredictorState *sp = PredictorState(tif);
- tmsize_t stride = sp->stride;
- unsigned char *cp = (unsigned char *)cp0;
-
- if ((cc % stride) != 0)
- {
- TIFFErrorExtR(tif, "horDiff8", "%s", "(cc%stride)!=0");
- return 0;
- }
-
- if (cc > stride)
- {
- cc -= stride;
- /*
- * Pipeline the most common cases.
- */
- if (stride == 3)
- {
- unsigned int r1, g1, b1;
- unsigned int r2 = cp[0];
- unsigned int g2 = cp[1];
- unsigned int b2 = cp[2];
- do
- {
- r1 = cp[3];
- cp[3] = (unsigned char)((r1 - r2) & 0xff);
- r2 = r1;
- g1 = cp[4];
- cp[4] = (unsigned char)((g1 - g2) & 0xff);
- g2 = g1;
- b1 = cp[5];
- cp[5] = (unsigned char)((b1 - b2) & 0xff);
- b2 = b1;
- cp += 3;
- } while ((cc -= 3) > 0);
- }
- else if (stride == 4)
- {
- unsigned int r1, g1, b1, a1;
- unsigned int r2 = cp[0];
- unsigned int g2 = cp[1];
- unsigned int b2 = cp[2];
- unsigned int a2 = cp[3];
- do
- {
- r1 = cp[4];
- cp[4] = (unsigned char)((r1 - r2) & 0xff);
- r2 = r1;
- g1 = cp[5];
- cp[5] = (unsigned char)((g1 - g2) & 0xff);
- g2 = g1;
- b1 = cp[6];
- cp[6] = (unsigned char)((b1 - b2) & 0xff);
- b2 = b1;
- a1 = cp[7];
- cp[7] = (unsigned char)((a1 - a2) & 0xff);
- a2 = a1;
- cp += 4;
- } while ((cc -= 4) > 0);
- }
- else
- {
- cp += cc - 1;
- do
- {
- REPEAT4(stride,
- cp[stride] =
- (unsigned char)((cp[stride] - cp[0]) & 0xff);
- cp--)
- } while ((cc -= stride) > 0);
- }
- }
- return 1;
-}
-
-TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW
-static int horDiff16(TIFF *tif, uint8_t *cp0, tmsize_t cc)
-{
- TIFFPredictorState *sp = PredictorState(tif);
- tmsize_t stride = sp->stride;
- uint16_t *wp = (uint16_t *)cp0;
- tmsize_t wc = cc / 2;
-
- if ((cc % (2 * stride)) != 0)
- {
- TIFFErrorExtR(tif, "horDiff8", "%s", "(cc%(2*stride))!=0");
- return 0;
- }
-
- if (wc > stride)
- {
- wc -= stride;
- wp += wc - 1;
- do
- {
- REPEAT4(stride, wp[stride] = (uint16_t)(((unsigned int)wp[stride] -
- (unsigned int)wp[0]) &
- 0xffff);
- wp--)
- wc -= stride;
- } while (wc > 0);
- }
- return 1;
-}
-
-static int swabHorDiff16(TIFF *tif, uint8_t *cp0, tmsize_t cc)
-{
- uint16_t *wp = (uint16_t *)cp0;
- tmsize_t wc = cc / 2;
-
- if (!horDiff16(tif, cp0, cc))
- return 0;
-
- TIFFSwabArrayOfShort(wp, wc);
- return 1;
-}
-
-TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW
-static int horDiff32(TIFF *tif, uint8_t *cp0, tmsize_t cc)
-{
- TIFFPredictorState *sp = PredictorState(tif);
- tmsize_t stride = sp->stride;
- uint32_t *wp = (uint32_t *)cp0;
- tmsize_t wc = cc / 4;
-
- if ((cc % (4 * stride)) != 0)
- {
- TIFFErrorExtR(tif, "horDiff32", "%s", "(cc%(4*stride))!=0");
- return 0;
- }
-
- if (wc > stride)
- {
- wc -= stride;
- wp += wc - 1;
- do
- {
- REPEAT4(stride, wp[stride] -= wp[0]; wp--)
- wc -= stride;
- } while (wc > 0);
- }
- return 1;
-}
-
-static int swabHorDiff32(TIFF *tif, uint8_t *cp0, tmsize_t cc)
-{
- uint32_t *wp = (uint32_t *)cp0;
- tmsize_t wc = cc / 4;
-
- if (!horDiff32(tif, cp0, cc))
- return 0;
-
- TIFFSwabArrayOfLong(wp, wc);
- return 1;
-}
-
-TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW
-static int horDiff64(TIFF *tif, uint8_t *cp0, tmsize_t cc)
-{
- TIFFPredictorState *sp = PredictorState(tif);
- tmsize_t stride = sp->stride;
- uint64_t *wp = (uint64_t *)cp0;
- tmsize_t wc = cc / 8;
-
- if ((cc % (8 * stride)) != 0)
- {
- TIFFErrorExtR(tif, "horDiff64", "%s", "(cc%(8*stride))!=0");
- return 0;
- }
-
- if (wc > stride)
- {
- wc -= stride;
- wp += wc - 1;
- do
- {
- REPEAT4(stride, wp[stride] -= wp[0]; wp--)
- wc -= stride;
- } while (wc > 0);
- }
- return 1;
-}
-
-static int swabHorDiff64(TIFF *tif, uint8_t *cp0, tmsize_t cc)
-{
- uint64_t *wp = (uint64_t *)cp0;
- tmsize_t wc = cc / 8;
-
- if (!horDiff64(tif, cp0, cc))
- return 0;
-
- TIFFSwabArrayOfLong8(wp, wc);
- return 1;
-}
-
-/*
- * Floating point predictor differencing routine.
- */
-TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW
-static int fpDiff(TIFF *tif, uint8_t *cp0, tmsize_t cc)
-{
- tmsize_t stride = PredictorState(tif)->stride;
- uint32_t bps = tif->tif_dir.td_bitspersample / 8;
- tmsize_t wc = cc / bps;
- tmsize_t count;
- uint8_t *cp = (uint8_t *)cp0;
- uint8_t *tmp;
-
- if ((cc % (bps * stride)) != 0)
- {
- TIFFErrorExtR(tif, "fpDiff", "%s", "(cc%(bps*stride))!=0");
- return 0;
- }
-
- tmp = (uint8_t *)_TIFFmallocExt(tif, cc);
- if (!tmp)
- return 0;
-
- _TIFFmemcpy(tmp, cp0, cc);
- for (count = 0; count < wc; count++)
- {
- uint32_t byte;
- for (byte = 0; byte < bps; byte++)
- {
-#if WORDS_BIGENDIAN
- cp[byte * wc + count] = tmp[bps * count + byte];
-#else
- cp[(bps - byte - 1) * wc + count] = tmp[bps * count + byte];
-#endif
- }
- }
- _TIFFfreeExt(tif, tmp);
-
- cp = (uint8_t *)cp0;
- cp += cc - stride - 1;
- for (count = cc; count > stride; count -= stride)
- REPEAT4(stride,
- cp[stride] = (unsigned char)((cp[stride] - cp[0]) & 0xff);
- cp--)
- return 1;
-}
-
-static int PredictorEncodeRow(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s)
-{
- TIFFPredictorState *sp = PredictorState(tif);
-
- assert(sp != NULL);
- assert(sp->encodepfunc != NULL);
- assert(sp->encoderow != NULL);
-
- /* XXX horizontal differencing alters user's data XXX */
- if (!(*sp->encodepfunc)(tif, bp, cc))
- return 0;
- return (*sp->encoderow)(tif, bp, cc, s);
-}
-
-static int PredictorEncodeTile(TIFF *tif, uint8_t *bp0, tmsize_t cc0,
- uint16_t s)
-{
- static const char module[] = "PredictorEncodeTile";
- TIFFPredictorState *sp = PredictorState(tif);
- uint8_t *working_copy;
- tmsize_t cc = cc0, rowsize;
- unsigned char *bp;
- int result_code;
-
- assert(sp != NULL);
- assert(sp->encodepfunc != NULL);
- assert(sp->encodetile != NULL);
-
- /*
- * Do predictor manipulation in a working buffer to avoid altering
- * the callers buffer. http://trac.osgeo.org/gdal/ticket/1965
- */
- working_copy = (uint8_t *)_TIFFmallocExt(tif, cc0);
- if (working_copy == NULL)
- {
- TIFFErrorExtR(tif, module,
- "Out of memory allocating %" PRId64 " byte temp buffer.",
- (int64_t)cc0);
- return 0;
- }
- memcpy(working_copy, bp0, cc0);
- bp = working_copy;
-
- rowsize = sp->rowsize;
- assert(rowsize > 0);
- if ((cc0 % rowsize) != 0)
- {
- TIFFErrorExtR(tif, "PredictorEncodeTile", "%s", "(cc0%rowsize)!=0");
- _TIFFfreeExt(tif, working_copy);
- return 0;
- }
- while (cc > 0)
- {
- (*sp->encodepfunc)(tif, bp, rowsize);
- cc -= rowsize;
- bp += rowsize;
- }
- result_code = (*sp->encodetile)(tif, working_copy, cc0, s);
-
- _TIFFfreeExt(tif, working_copy);
-
- return result_code;
-}
-
-#define FIELD_PREDICTOR (FIELD_CODEC + 0) /* XXX */
-
-static const TIFFField predictFields[] = {
- {TIFFTAG_PREDICTOR, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16,
- TIFF_SETGET_UINT16, FIELD_PREDICTOR, FALSE, FALSE, "Predictor", NULL},
-};
-
-static int PredictorVSetField(TIFF *tif, uint32_t tag, va_list ap)
-{
- TIFFPredictorState *sp = PredictorState(tif);
-
- assert(sp != NULL);
- assert(sp->vsetparent != NULL);
-
- switch (tag)
- {
- case TIFFTAG_PREDICTOR:
- sp->predictor = (uint16_t)va_arg(ap, uint16_vap);
- TIFFSetFieldBit(tif, FIELD_PREDICTOR);
- break;
- default:
- return (*sp->vsetparent)(tif, tag, ap);
- }
- tif->tif_flags |= TIFF_DIRTYDIRECT;
- return 1;
-}
-
-static int PredictorVGetField(TIFF *tif, uint32_t tag, va_list ap)
-{
- TIFFPredictorState *sp = PredictorState(tif);
-
- assert(sp != NULL);
- assert(sp->vgetparent != NULL);
-
- switch (tag)
- {
- case TIFFTAG_PREDICTOR:
- *va_arg(ap, uint16_t *) = (uint16_t)sp->predictor;
- break;
- default:
- return (*sp->vgetparent)(tif, tag, ap);
- }
- return 1;
-}
-
-static void PredictorPrintDir(TIFF *tif, FILE *fd, long flags)
-{
- TIFFPredictorState *sp = PredictorState(tif);
-
- (void)flags;
- if (TIFFFieldSet(tif, FIELD_PREDICTOR))
- {
- fprintf(fd, " Predictor: ");
- switch (sp->predictor)
- {
- case 1:
- fprintf(fd, "none ");
- break;
- case 2:
- fprintf(fd, "horizontal differencing ");
- break;
- case 3:
- fprintf(fd, "floating point predictor ");
- break;
- }
- fprintf(fd, "%d (0x%x)\n", sp->predictor, sp->predictor);
- }
- if (sp->printdir)
- (*sp->printdir)(tif, fd, flags);
-}
-
-int TIFFPredictorInit(TIFF *tif)
-{
- TIFFPredictorState *sp = PredictorState(tif);
-
- assert(sp != 0);
-
- /*
- * Merge codec-specific tag information.
- */
- if (!_TIFFMergeFields(tif, predictFields, TIFFArrayCount(predictFields)))
- {
- TIFFErrorExtR(tif, "TIFFPredictorInit",
- "Merging Predictor codec-specific tags failed");
- return 0;
- }
-
- /*
- * Override parent get/set field methods.
- */
- sp->vgetparent = tif->tif_tagmethods.vgetfield;
- tif->tif_tagmethods.vgetfield =
- PredictorVGetField; /* hook for predictor tag */
- sp->vsetparent = tif->tif_tagmethods.vsetfield;
- tif->tif_tagmethods.vsetfield =
- PredictorVSetField; /* hook for predictor tag */
- sp->printdir = tif->tif_tagmethods.printdir;
- tif->tif_tagmethods.printdir =
- PredictorPrintDir; /* hook for predictor tag */
-
- sp->setupdecode = tif->tif_setupdecode;
- tif->tif_setupdecode = PredictorSetupDecode;
- sp->setupencode = tif->tif_setupencode;
- tif->tif_setupencode = PredictorSetupEncode;
-
- sp->predictor = 1; /* default value */
- sp->encodepfunc = NULL; /* no predictor routine */
- sp->decodepfunc = NULL; /* no predictor routine */
- return 1;
-}
-
-int TIFFPredictorCleanup(TIFF *tif)
-{
- TIFFPredictorState *sp = PredictorState(tif);
-
- assert(sp != 0);
-
- tif->tif_tagmethods.vgetfield = sp->vgetparent;
- tif->tif_tagmethods.vsetfield = sp->vsetparent;
- tif->tif_tagmethods.printdir = sp->printdir;
- tif->tif_setupdecode = sp->setupdecode;
- tif->tif_setupencode = sp->setupencode;
-
- return 1;
-}
diff --git a/contrib/libs/libtiff/tif_predict.h b/contrib/libs/libtiff/tif_predict.h
deleted file mode 100644
index de77328352..0000000000
--- a/contrib/libs/libtiff/tif_predict.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 1995-1997 Sam Leffler
- * Copyright (c) 1995-1997 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-#ifndef _TIFFPREDICT_
-#define _TIFFPREDICT_
-
-#include "tiffio.h"
-#include "tiffiop.h"
-
-/*
- * ``Library-private'' Support for the Predictor Tag
- */
-
-typedef int (*TIFFEncodeDecodeMethod)(TIFF *tif, uint8_t *buf, tmsize_t size);
-
-/*
- * Codecs that want to support the Predictor tag must place
- * this structure first in their private state block so that
- * the predictor code can cast tif_data to find its state.
- */
-typedef struct
-{
- int predictor; /* predictor tag value */
- tmsize_t stride; /* sample stride over data */
- tmsize_t rowsize; /* tile/strip row size */
-
- TIFFCodeMethod encoderow; /* parent codec encode/decode row */
- TIFFCodeMethod encodestrip; /* parent codec encode/decode strip */
- TIFFCodeMethod encodetile; /* parent codec encode/decode tile */
- TIFFEncodeDecodeMethod encodepfunc; /* horizontal differencer */
-
- TIFFCodeMethod decoderow; /* parent codec encode/decode row */
- TIFFCodeMethod decodestrip; /* parent codec encode/decode strip */
- TIFFCodeMethod decodetile; /* parent codec encode/decode tile */
- TIFFEncodeDecodeMethod decodepfunc; /* horizontal accumulator */
-
- TIFFVGetMethod vgetparent; /* super-class method */
- TIFFVSetMethod vsetparent; /* super-class method */
- TIFFPrintMethod printdir; /* super-class method */
- TIFFBoolMethod setupdecode; /* super-class method */
- TIFFBoolMethod setupencode; /* super-class method */
-} TIFFPredictorState;
-
-#if defined(__cplusplus)
-extern "C"
-{
-#endif
- extern int TIFFPredictorInit(TIFF *);
- extern int TIFFPredictorCleanup(TIFF *);
-#if defined(__cplusplus)
-}
-#endif
-#endif /* _TIFFPREDICT_ */
diff --git a/contrib/libs/libtiff/tif_print.c b/contrib/libs/libtiff/tif_print.c
deleted file mode 100644
index 2b7fd1765a..0000000000
--- a/contrib/libs/libtiff/tif_print.c
+++ /dev/null
@@ -1,755 +0,0 @@
-/*
- * Copyright (c) 1988-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-/*
- * TIFF Library.
- *
- * Directory Printing Support
- */
-#include "tiffiop.h"
-#include <stdio.h>
-
-#include <ctype.h>
-
-static void _TIFFprintAsciiBounded(FILE *fd, const char *cp, size_t max_chars);
-
-static const char *const photoNames[] = {
- "min-is-white", /* PHOTOMETRIC_MINISWHITE */
- "min-is-black", /* PHOTOMETRIC_MINISBLACK */
- "RGB color", /* PHOTOMETRIC_RGB */
- "palette color (RGB from colormap)", /* PHOTOMETRIC_PALETTE */
- "transparency mask", /* PHOTOMETRIC_MASK */
- "separated", /* PHOTOMETRIC_SEPARATED */
- "YCbCr", /* PHOTOMETRIC_YCBCR */
- "7 (0x7)",
- "CIE L*a*b*", /* PHOTOMETRIC_CIELAB */
- "ICC L*a*b*", /* PHOTOMETRIC_ICCLAB */
- "ITU L*a*b*" /* PHOTOMETRIC_ITULAB */
-};
-#define NPHOTONAMES (sizeof(photoNames) / sizeof(photoNames[0]))
-
-static const char *const orientNames[] = {
- "0 (0x0)",
- "row 0 top, col 0 lhs", /* ORIENTATION_TOPLEFT */
- "row 0 top, col 0 rhs", /* ORIENTATION_TOPRIGHT */
- "row 0 bottom, col 0 rhs", /* ORIENTATION_BOTRIGHT */
- "row 0 bottom, col 0 lhs", /* ORIENTATION_BOTLEFT */
- "row 0 lhs, col 0 top", /* ORIENTATION_LEFTTOP */
- "row 0 rhs, col 0 top", /* ORIENTATION_RIGHTTOP */
- "row 0 rhs, col 0 bottom", /* ORIENTATION_RIGHTBOT */
- "row 0 lhs, col 0 bottom", /* ORIENTATION_LEFTBOT */
-};
-#define NORIENTNAMES (sizeof(orientNames) / sizeof(orientNames[0]))
-
-static const struct tagname
-{
- uint16_t tag;
- const char *name;
-} tagnames[] = {
- {TIFFTAG_GDAL_METADATA, "GDAL Metadata"},
- {TIFFTAG_GDAL_NODATA, "GDAL NoDataValue"},
-};
-#define NTAGS (sizeof(tagnames) / sizeof(tagnames[0]))
-
-static void _TIFFPrintField(FILE *fd, const TIFFField *fip,
- uint32_t value_count, void *raw_data)
-{
- uint32_t j;
-
- /* Print a user-friendly name for tags of relatively common use, but */
- /* which aren't registered by libtiff itself. */
- const char *field_name = fip->field_name;
- if (TIFFFieldIsAnonymous(fip))
- {
- for (size_t i = 0; i < NTAGS; ++i)
- {
- if (fip->field_tag == tagnames[i].tag)
- {
- field_name = tagnames[i].name;
- break;
- }
- }
- }
- fprintf(fd, " %s: ", field_name);
-
- for (j = 0; j < value_count; j++)
- {
- if (fip->field_type == TIFF_BYTE)
- fprintf(fd, "%" PRIu8, ((uint8_t *)raw_data)[j]);
- else if (fip->field_type == TIFF_UNDEFINED)
- fprintf(fd, "0x%" PRIx8, ((uint8_t *)raw_data)[j]);
- else if (fip->field_type == TIFF_SBYTE)
- fprintf(fd, "%" PRId8, ((int8_t *)raw_data)[j]);
- else if (fip->field_type == TIFF_SHORT)
- fprintf(fd, "%" PRIu16, ((uint16_t *)raw_data)[j]);
- else if (fip->field_type == TIFF_SSHORT)
- fprintf(fd, "%" PRId16, ((int16_t *)raw_data)[j]);
- else if (fip->field_type == TIFF_LONG)
- fprintf(fd, "%" PRIu32, ((uint32_t *)raw_data)[j]);
- else if (fip->field_type == TIFF_SLONG)
- fprintf(fd, "%" PRId32, ((int32_t *)raw_data)[j]);
- else if (fip->field_type == TIFF_IFD)
- fprintf(fd, "0x%" PRIx32, ((uint32_t *)raw_data)[j]);
- else if (fip->field_type == TIFF_RATIONAL ||
- fip->field_type == TIFF_SRATIONAL)
- {
- int tv_size = TIFFFieldSetGetSize(fip);
- if (tv_size == 8)
- fprintf(fd, "%lf", ((double *)raw_data)[j]);
- else
- fprintf(fd, "%f", ((float *)raw_data)[j]);
- }
- else if (fip->field_type == TIFF_FLOAT)
- fprintf(fd, "%f", ((float *)raw_data)[j]);
- else if (fip->field_type == TIFF_LONG8)
- fprintf(fd, "%" PRIu64, ((uint64_t *)raw_data)[j]);
- else if (fip->field_type == TIFF_SLONG8)
- fprintf(fd, "%" PRId64, ((int64_t *)raw_data)[j]);
- else if (fip->field_type == TIFF_IFD8)
- fprintf(fd, "0x%" PRIx64, ((uint64_t *)raw_data)[j]);
- else if (fip->field_type == TIFF_DOUBLE)
- fprintf(fd, "%lf", ((double *)raw_data)[j]);
- else if (fip->field_type == TIFF_ASCII)
- {
- fprintf(fd, "%s", (char *)raw_data);
- break;
- }
- else
- {
- fprintf(fd, "<unsupported data type in TIFFPrint>");
- break;
- }
-
- if (j < value_count - 1)
- fprintf(fd, ",");
- }
-
- fprintf(fd, "\n");
-}
-
-static int _TIFFPrettyPrintField(TIFF *tif, const TIFFField *fip, FILE *fd,
- uint32_t tag, uint32_t value_count,
- void *raw_data)
-{
- (void)tif;
-
- /* do not try to pretty print auto-defined fields */
- if (TIFFFieldIsAnonymous(fip))
- {
- return 0;
- }
-
- switch (tag)
- {
- case TIFFTAG_INKSET:
- if (value_count == 2 && fip->field_type == TIFF_SHORT)
- {
- fprintf(fd, " Ink Set: ");
- switch (*((uint16_t *)raw_data))
- {
- case INKSET_CMYK:
- fprintf(fd, "CMYK\n");
- break;
- default:
- fprintf(fd, "%" PRIu16 " (0x%" PRIx16 ")\n",
- *((uint16_t *)raw_data),
- *((uint16_t *)raw_data));
- break;
- }
- return 1;
- }
- return 0;
-
- case TIFFTAG_DOTRANGE:
- if (value_count == 2 && fip->field_type == TIFF_SHORT)
- {
- fprintf(fd, " Dot Range: %" PRIu16 "-%" PRIu16 "\n",
- ((uint16_t *)raw_data)[0], ((uint16_t *)raw_data)[1]);
- return 1;
- }
- return 0;
-
- case TIFFTAG_WHITEPOINT:
- if (value_count == 2 && fip->field_type == TIFF_RATIONAL)
- {
- fprintf(fd, " White Point: %g-%g\n", ((float *)raw_data)[0],
- ((float *)raw_data)[1]);
- return 1;
- }
- return 0;
-
- case TIFFTAG_XMLPACKET:
- {
- uint32_t i;
-
- fprintf(fd, " XMLPacket (XMP Metadata):\n");
- for (i = 0; i < value_count; i++)
- fputc(((char *)raw_data)[i], fd);
- fprintf(fd, "\n");
- return 1;
- }
- case TIFFTAG_RICHTIFFIPTC:
- fprintf(fd, " RichTIFFIPTC Data: <present>, %" PRIu32 " bytes\n",
- value_count);
- return 1;
-
- case TIFFTAG_PHOTOSHOP:
- fprintf(fd, " Photoshop Data: <present>, %" PRIu32 " bytes\n",
- value_count);
- return 1;
-
- case TIFFTAG_ICCPROFILE:
- fprintf(fd, " ICC Profile: <present>, %" PRIu32 " bytes\n",
- value_count);
- return 1;
-
- case TIFFTAG_STONITS:
- if (value_count == 1 && fip->field_type == TIFF_DOUBLE)
- {
- fprintf(fd, " Sample to Nits conversion factor: %.4e\n",
- *((double *)raw_data));
- return 1;
- }
- return 0;
- }
-
- return 0;
-}
-
-/*
- * Print the contents of the current directory
- * to the specified stdio file stream.
- */
-void TIFFPrintDirectory(TIFF *tif, FILE *fd, long flags)
-{
- TIFFDirectory *td = &tif->tif_dir;
- char *sep;
- long l, n;
-
- fprintf(fd, "TIFF Directory at offset 0x%" PRIx64 " (%" PRIu64 ")\n",
- tif->tif_diroff, tif->tif_diroff);
- if (TIFFFieldSet(tif, FIELD_SUBFILETYPE))
- {
- fprintf(fd, " Subfile Type:");
- sep = " ";
- if (td->td_subfiletype & FILETYPE_REDUCEDIMAGE)
- {
- fprintf(fd, "%sreduced-resolution image", sep);
- sep = "/";
- }
- if (td->td_subfiletype & FILETYPE_PAGE)
- {
- fprintf(fd, "%smulti-page document", sep);
- sep = "/";
- }
- if (td->td_subfiletype & FILETYPE_MASK)
- fprintf(fd, "%stransparency mask", sep);
- fprintf(fd, " (%" PRIu32 " = 0x%" PRIx32 ")\n", td->td_subfiletype,
- td->td_subfiletype);
- }
- if (TIFFFieldSet(tif, FIELD_IMAGEDIMENSIONS))
- {
- fprintf(fd, " Image Width: %" PRIu32 " Image Length: %" PRIu32,
- td->td_imagewidth, td->td_imagelength);
- if (TIFFFieldSet(tif, FIELD_IMAGEDEPTH))
- fprintf(fd, " Image Depth: %" PRIu32, td->td_imagedepth);
- fprintf(fd, "\n");
- }
- if (TIFFFieldSet(tif, FIELD_TILEDIMENSIONS))
- {
- fprintf(fd, " Tile Width: %" PRIu32 " Tile Length: %" PRIu32,
- td->td_tilewidth, td->td_tilelength);
- if (TIFFFieldSet(tif, FIELD_TILEDEPTH))
- fprintf(fd, " Tile Depth: %" PRIu32, td->td_tiledepth);
- fprintf(fd, "\n");
- }
- if (TIFFFieldSet(tif, FIELD_RESOLUTION))
- {
- fprintf(fd, " Resolution: %g, %g", td->td_xresolution,
- td->td_yresolution);
- if (TIFFFieldSet(tif, FIELD_RESOLUTIONUNIT))
- {
- switch (td->td_resolutionunit)
- {
- case RESUNIT_NONE:
- fprintf(fd, " (unitless)");
- break;
- case RESUNIT_INCH:
- fprintf(fd, " pixels/inch");
- break;
- case RESUNIT_CENTIMETER:
- fprintf(fd, " pixels/cm");
- break;
- default:
- fprintf(fd, " (unit %" PRIu16 " = 0x%" PRIx16 ")",
- td->td_resolutionunit, td->td_resolutionunit);
- break;
- }
- }
- fprintf(fd, "\n");
- }
- if (TIFFFieldSet(tif, FIELD_POSITION))
- fprintf(fd, " Position: %g, %g\n", td->td_xposition, td->td_yposition);
- if (TIFFFieldSet(tif, FIELD_BITSPERSAMPLE))
- fprintf(fd, " Bits/Sample: %" PRIu16 "\n", td->td_bitspersample);
- if (TIFFFieldSet(tif, FIELD_SAMPLEFORMAT))
- {
- fprintf(fd, " Sample Format: ");
- switch (td->td_sampleformat)
- {
- case SAMPLEFORMAT_VOID:
- fprintf(fd, "void\n");
- break;
- case SAMPLEFORMAT_INT:
- fprintf(fd, "signed integer\n");
- break;
- case SAMPLEFORMAT_UINT:
- fprintf(fd, "unsigned integer\n");
- break;
- case SAMPLEFORMAT_IEEEFP:
- fprintf(fd, "IEEE floating point\n");
- break;
- case SAMPLEFORMAT_COMPLEXINT:
- fprintf(fd, "complex signed integer\n");
- break;
- case SAMPLEFORMAT_COMPLEXIEEEFP:
- fprintf(fd, "complex IEEE floating point\n");
- break;
- default:
- fprintf(fd, "%" PRIu16 " (0x%" PRIx16 ")\n",
- td->td_sampleformat, td->td_sampleformat);
- break;
- }
- }
- if (TIFFFieldSet(tif, FIELD_COMPRESSION))
- {
- const TIFFCodec *c = TIFFFindCODEC(td->td_compression);
- fprintf(fd, " Compression Scheme: ");
- if (c)
- fprintf(fd, "%s\n", c->name);
- else
- fprintf(fd, "%" PRIu16 " (0x%" PRIx16 ")\n", td->td_compression,
- td->td_compression);
- }
- if (TIFFFieldSet(tif, FIELD_PHOTOMETRIC))
- {
- fprintf(fd, " Photometric Interpretation: ");
- if (td->td_photometric < NPHOTONAMES)
- fprintf(fd, "%s\n", photoNames[td->td_photometric]);
- else
- {
- switch (td->td_photometric)
- {
- case PHOTOMETRIC_LOGL:
- fprintf(fd, "CIE Log2(L)\n");
- break;
- case PHOTOMETRIC_LOGLUV:
- fprintf(fd, "CIE Log2(L) (u',v')\n");
- break;
- default:
- fprintf(fd, "%" PRIu16 " (0x%" PRIx16 ")\n",
- td->td_photometric, td->td_photometric);
- break;
- }
- }
- }
- if (TIFFFieldSet(tif, FIELD_EXTRASAMPLES) && td->td_extrasamples)
- {
- uint16_t i;
- fprintf(fd, " Extra Samples: %" PRIu16 "<", td->td_extrasamples);
- sep = "";
- for (i = 0; i < td->td_extrasamples; i++)
- {
- switch (td->td_sampleinfo[i])
- {
- case EXTRASAMPLE_UNSPECIFIED:
- fprintf(fd, "%sunspecified", sep);
- break;
- case EXTRASAMPLE_ASSOCALPHA:
- fprintf(fd, "%sassoc-alpha", sep);
- break;
- case EXTRASAMPLE_UNASSALPHA:
- fprintf(fd, "%sunassoc-alpha", sep);
- break;
- default:
- fprintf(fd, "%s%" PRIu16 " (0x%" PRIx16 ")", sep,
- td->td_sampleinfo[i], td->td_sampleinfo[i]);
- break;
- }
- sep = ", ";
- }
- fprintf(fd, ">\n");
- }
- if (TIFFFieldSet(tif, FIELD_INKNAMES))
- {
- char *cp;
- uint16_t i;
- fprintf(fd, " Ink Names: ");
- i = td->td_samplesperpixel;
- sep = "";
- for (cp = td->td_inknames;
- i > 0 && cp < td->td_inknames + td->td_inknameslen;
- cp = strchr(cp, '\0') + 1, i--)
- {
- size_t max_chars = td->td_inknameslen - (cp - td->td_inknames);
- fputs(sep, fd);
- _TIFFprintAsciiBounded(fd, cp, max_chars);
- sep = ", ";
- }
- fputs("\n", fd);
- }
- if (TIFFFieldSet(tif, FIELD_NUMBEROFINKS))
- {
- fprintf(fd, " NumberOfInks: %d\n", td->td_numberofinks);
- }
- if (TIFFFieldSet(tif, FIELD_THRESHHOLDING))
- {
- fprintf(fd, " Thresholding: ");
- switch (td->td_threshholding)
- {
- case THRESHHOLD_BILEVEL:
- fprintf(fd, "bilevel art scan\n");
- break;
- case THRESHHOLD_HALFTONE:
- fprintf(fd, "halftone or dithered scan\n");
- break;
- case THRESHHOLD_ERRORDIFFUSE:
- fprintf(fd, "error diffused\n");
- break;
- default:
- fprintf(fd, "%" PRIu16 " (0x%" PRIx16 ")\n",
- td->td_threshholding, td->td_threshholding);
- break;
- }
- }
- if (TIFFFieldSet(tif, FIELD_FILLORDER))
- {
- fprintf(fd, " FillOrder: ");
- switch (td->td_fillorder)
- {
- case FILLORDER_MSB2LSB:
- fprintf(fd, "msb-to-lsb\n");
- break;
- case FILLORDER_LSB2MSB:
- fprintf(fd, "lsb-to-msb\n");
- break;
- default:
- fprintf(fd, "%" PRIu16 " (0x%" PRIx16 ")\n", td->td_fillorder,
- td->td_fillorder);
- break;
- }
- }
- if (TIFFFieldSet(tif, FIELD_YCBCRSUBSAMPLING))
- {
- fprintf(fd, " YCbCr Subsampling: %" PRIu16 ", %" PRIu16 "\n",
- td->td_ycbcrsubsampling[0], td->td_ycbcrsubsampling[1]);
- }
- if (TIFFFieldSet(tif, FIELD_YCBCRPOSITIONING))
- {
- fprintf(fd, " YCbCr Positioning: ");
- switch (td->td_ycbcrpositioning)
- {
- case YCBCRPOSITION_CENTERED:
- fprintf(fd, "centered\n");
- break;
- case YCBCRPOSITION_COSITED:
- fprintf(fd, "cosited\n");
- break;
- default:
- fprintf(fd, "%" PRIu16 " (0x%" PRIx16 ")\n",
- td->td_ycbcrpositioning, td->td_ycbcrpositioning);
- break;
- }
- }
- if (TIFFFieldSet(tif, FIELD_HALFTONEHINTS))
- fprintf(fd, " Halftone Hints: light %" PRIu16 " dark %" PRIu16 "\n",
- td->td_halftonehints[0], td->td_halftonehints[1]);
- if (TIFFFieldSet(tif, FIELD_ORIENTATION))
- {
- fprintf(fd, " Orientation: ");
- if (td->td_orientation < NORIENTNAMES)
- fprintf(fd, "%s\n", orientNames[td->td_orientation]);
- else
- fprintf(fd, "%" PRIu16 " (0x%" PRIx16 ")\n", td->td_orientation,
- td->td_orientation);
- }
- if (TIFFFieldSet(tif, FIELD_SAMPLESPERPIXEL))
- fprintf(fd, " Samples/Pixel: %" PRIx16 "\n", td->td_samplesperpixel);
- if (TIFFFieldSet(tif, FIELD_ROWSPERSTRIP))
- {
- fprintf(fd, " Rows/Strip: ");
- if (td->td_rowsperstrip == (uint32_t)-1)
- fprintf(fd, "(infinite)\n");
- else
- fprintf(fd, "%" PRIu32 "\n", td->td_rowsperstrip);
- }
- if (TIFFFieldSet(tif, FIELD_MINSAMPLEVALUE))
- fprintf(fd, " Min Sample Value: %" PRIu16 "\n", td->td_minsamplevalue);
- if (TIFFFieldSet(tif, FIELD_MAXSAMPLEVALUE))
- fprintf(fd, " Max Sample Value: %" PRIu16 "\n", td->td_maxsamplevalue);
- if (TIFFFieldSet(tif, FIELD_SMINSAMPLEVALUE))
- {
- int i;
- int count =
- (tif->tif_flags & TIFF_PERSAMPLE) ? td->td_samplesperpixel : 1;
- fprintf(fd, " SMin Sample Value:");
- for (i = 0; i < count; ++i)
- fprintf(fd, " %g", td->td_sminsamplevalue[i]);
- fprintf(fd, "\n");
- }
- if (TIFFFieldSet(tif, FIELD_SMAXSAMPLEVALUE))
- {
- int i;
- int count =
- (tif->tif_flags & TIFF_PERSAMPLE) ? td->td_samplesperpixel : 1;
- fprintf(fd, " SMax Sample Value:");
- for (i = 0; i < count; ++i)
- fprintf(fd, " %g", td->td_smaxsamplevalue[i]);
- fprintf(fd, "\n");
- }
- if (TIFFFieldSet(tif, FIELD_PLANARCONFIG))
- {
- fprintf(fd, " Planar Configuration: ");
- switch (td->td_planarconfig)
- {
- case PLANARCONFIG_CONTIG:
- fprintf(fd, "single image plane\n");
- break;
- case PLANARCONFIG_SEPARATE:
- fprintf(fd, "separate image planes\n");
- break;
- default:
- fprintf(fd, "%" PRIu16 " (0x%" PRIx16 ")\n",
- td->td_planarconfig, td->td_planarconfig);
- break;
- }
- }
- if (TIFFFieldSet(tif, FIELD_PAGENUMBER))
- fprintf(fd, " Page Number: %" PRIu16 "-%" PRIu16 "\n",
- td->td_pagenumber[0], td->td_pagenumber[1]);
- if (TIFFFieldSet(tif, FIELD_COLORMAP))
- {
- fprintf(fd, " Color Map: ");
- if (flags & TIFFPRINT_COLORMAP)
- {
- fprintf(fd, "\n");
- n = 1L << td->td_bitspersample;
- for (l = 0; l < n; l++)
- fprintf(fd, " %5ld: %5" PRIu16 " %5" PRIu16 " %5" PRIu16 "\n",
- l, td->td_colormap[0][l], td->td_colormap[1][l],
- td->td_colormap[2][l]);
- }
- else
- fprintf(fd, "(present)\n");
- }
- if (TIFFFieldSet(tif, FIELD_REFBLACKWHITE))
- {
- int i;
- fprintf(fd, " Reference Black/White:\n");
- for (i = 0; i < 3; i++)
- fprintf(fd, " %2d: %5g %5g\n", i,
- td->td_refblackwhite[2 * i + 0],
- td->td_refblackwhite[2 * i + 1]);
- }
- if (TIFFFieldSet(tif, FIELD_TRANSFERFUNCTION))
- {
- fprintf(fd, " Transfer Function: ");
- if (flags & TIFFPRINT_CURVES)
- {
- fprintf(fd, "\n");
- n = 1L << td->td_bitspersample;
- for (l = 0; l < n; l++)
- {
- uint16_t i;
- fprintf(fd, " %2ld: %5" PRIu16, l,
- td->td_transferfunction[0][l]);
- for (i = 1;
- i < td->td_samplesperpixel - td->td_extrasamples && i < 3;
- i++)
- fprintf(fd, " %5" PRIu16, td->td_transferfunction[i][l]);
- fputc('\n', fd);
- }
- }
- else
- fprintf(fd, "(present)\n");
- }
- if (TIFFFieldSet(tif, FIELD_SUBIFD) && (td->td_subifd))
- {
- uint16_t i;
- fprintf(fd, " SubIFD Offsets:");
- for (i = 0; i < td->td_nsubifd; i++)
- fprintf(fd, " %5" PRIu64, td->td_subifd[i]);
- fputc('\n', fd);
- }
-
- /*
- ** Custom tag support.
- */
- {
- int i;
- short count;
-
- count = (short)TIFFGetTagListCount(tif);
- for (i = 0; i < count; i++)
- {
- uint32_t tag = TIFFGetTagListEntry(tif, i);
- const TIFFField *fip;
- uint32_t value_count;
- int mem_alloc = 0;
- void *raw_data = NULL;
- uint16_t dotrange[2]; /* must be kept in that scope and not moved in
- the below TIFFTAG_DOTRANGE specific case */
-
- fip = TIFFFieldWithTag(tif, tag);
- if (fip == NULL)
- continue;
-
- if (fip->field_passcount)
- {
- if (fip->field_readcount == TIFF_VARIABLE2)
- {
- if (TIFFGetField(tif, tag, &value_count, &raw_data) != 1)
- continue;
- }
- else if (fip->field_readcount == TIFF_VARIABLE)
- {
- uint16_t small_value_count;
- if (TIFFGetField(tif, tag, &small_value_count, &raw_data) !=
- 1)
- continue;
- value_count = small_value_count;
- }
- else
- {
- assert(fip->field_readcount == TIFF_VARIABLE ||
- fip->field_readcount == TIFF_VARIABLE2);
- continue;
- }
- }
- else
- {
- if (fip->field_readcount == TIFF_VARIABLE ||
- fip->field_readcount == TIFF_VARIABLE2)
- value_count = 1;
- else if (fip->field_readcount == TIFF_SPP)
- value_count = td->td_samplesperpixel;
- else
- value_count = fip->field_readcount;
- if (fip->field_tag == TIFFTAG_DOTRANGE &&
- strcmp(fip->field_name, "DotRange") == 0)
- {
- /* TODO: This is an evil exception and should not have been
- handled this way ... likely best if we move it into
- the directory structure with an explicit field in
- libtiff 4.1 and assign it a FIELD_ value */
- raw_data = dotrange;
- TIFFGetField(tif, tag, dotrange + 0, dotrange + 1);
- }
- else if (fip->field_type == TIFF_ASCII ||
- fip->field_readcount == TIFF_VARIABLE ||
- fip->field_readcount == TIFF_VARIABLE2 ||
- fip->field_readcount == TIFF_SPP || value_count > 1)
- {
- if (TIFFGetField(tif, tag, &raw_data) != 1)
- continue;
- }
- else
- {
- /*--: Rational2Double: For Rationals evaluate
- * "set_field_type" to determine internal storage size. */
- int tv_size = TIFFFieldSetGetSize(fip);
- raw_data = _TIFFmallocExt(tif, tv_size * value_count);
- mem_alloc = 1;
- if (TIFFGetField(tif, tag, raw_data) != 1)
- {
- _TIFFfreeExt(tif, raw_data);
- continue;
- }
- }
- }
-
- /*
- * Catch the tags which needs to be specially handled
- * and pretty print them. If tag not handled in
- * _TIFFPrettyPrintField() fall down and print it as
- * any other tag.
- */
- if (raw_data != NULL &&
- !_TIFFPrettyPrintField(tif, fip, fd, tag, value_count,
- raw_data))
- _TIFFPrintField(fd, fip, value_count, raw_data);
-
- if (mem_alloc)
- _TIFFfreeExt(tif, raw_data);
- }
- }
-
- if (tif->tif_tagmethods.printdir)
- (*tif->tif_tagmethods.printdir)(tif, fd, flags);
-
- if ((flags & TIFFPRINT_STRIPS) && TIFFFieldSet(tif, FIELD_STRIPOFFSETS))
- {
- uint32_t s;
-
- fprintf(fd, " %" PRIu32 " %s:\n", td->td_nstrips,
- isTiled(tif) ? "Tiles" : "Strips");
- for (s = 0; s < td->td_nstrips; s++)
- fprintf(fd, " %3" PRIu32 ": [%8" PRIu64 ", %8" PRIu64 "]\n", s,
- TIFFGetStrileOffset(tif, s),
- TIFFGetStrileByteCount(tif, s));
- }
-}
-
-void _TIFFprintAscii(FILE *fd, const char *cp)
-{
- _TIFFprintAsciiBounded(fd, cp, strlen(cp));
-}
-
-static void _TIFFprintAsciiBounded(FILE *fd, const char *cp, size_t max_chars)
-{
- for (; max_chars > 0 && *cp != '\0'; cp++, max_chars--)
- {
- const char *tp;
-
- if (isprint((int)*cp))
- {
- fputc(*cp, fd);
- continue;
- }
- for (tp = "\tt\bb\rr\nn\vv"; *tp; tp++)
- if (*tp++ == *cp)
- break;
- if (*tp)
- fprintf(fd, "\\%c", *tp);
- else
- fprintf(fd, "\\%03o", *cp & 0xff);
- }
-}
-
-void _TIFFprintAsciiTag(FILE *fd, const char *name, const char *value)
-{
- fprintf(fd, " %s: \"", name);
- _TIFFprintAscii(fd, value);
- fprintf(fd, "\"\n");
-}
diff --git a/contrib/libs/libtiff/tif_read.c b/contrib/libs/libtiff/tif_read.c
deleted file mode 100644
index 7efab59c6a..0000000000
--- a/contrib/libs/libtiff/tif_read.c
+++ /dev/null
@@ -1,1663 +0,0 @@
-/*
- * Copyright (c) 1988-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-/*
- * TIFF Library.
- * Scanline-oriented Read Support
- */
-#include "tiffiop.h"
-#include <stdio.h>
-
-int TIFFFillStrip(TIFF *tif, uint32_t strip);
-int TIFFFillTile(TIFF *tif, uint32_t tile);
-static int TIFFStartStrip(TIFF *tif, uint32_t strip);
-static int TIFFStartTile(TIFF *tif, uint32_t tile);
-static int TIFFCheckRead(TIFF *, int);
-static tmsize_t TIFFReadRawStrip1(TIFF *tif, uint32_t strip, void *buf,
- tmsize_t size, const char *module);
-static tmsize_t TIFFReadRawTile1(TIFF *tif, uint32_t tile, void *buf,
- tmsize_t size, const char *module);
-
-#define NOSTRIP ((uint32_t)(-1)) /* undefined state */
-#define NOTILE ((uint32_t)(-1)) /* undefined state */
-
-#define INITIAL_THRESHOLD (1024 * 1024)
-#define THRESHOLD_MULTIPLIER 10
-#define MAX_THRESHOLD \
- (THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * \
- INITIAL_THRESHOLD)
-
-#define TIFF_INT64_MAX ((((int64_t)0x7FFFFFFF) << 32) | 0xFFFFFFFF)
-
-/* Read 'size' bytes in tif_rawdata buffer starting at offset 'rawdata_offset'
- * Returns 1 in case of success, 0 otherwise. */
-static int TIFFReadAndRealloc(TIFF *tif, tmsize_t size, tmsize_t rawdata_offset,
- int is_strip, uint32_t strip_or_tile,
- const char *module)
-{
-#if SIZEOF_SIZE_T == 8
- tmsize_t threshold = INITIAL_THRESHOLD;
-#endif
- tmsize_t already_read = 0;
-
-#if SIZEOF_SIZE_T != 8
- /* On 32 bit processes, if the request is large enough, check against */
- /* file size */
- if (size > 1000 * 1000 * 1000)
- {
- uint64_t filesize = TIFFGetFileSize(tif);
- if ((uint64_t)size >= filesize)
- {
- TIFFErrorExtR(tif, module,
- "Chunk size requested is larger than file size.");
- return 0;
- }
- }
-#endif
-
- /* On 64 bit processes, read first a maximum of 1 MB, then 10 MB, etc */
- /* so as to avoid allocating too much memory in case the file is too */
- /* short. We could ask for the file size, but this might be */
- /* expensive with some I/O layers (think of reading a gzipped file) */
- /* Restrict to 64 bit processes, so as to avoid reallocs() */
- /* on 32 bit processes where virtual memory is scarce. */
- while (already_read < size)
- {
- tmsize_t bytes_read;
- tmsize_t to_read = size - already_read;
-#if SIZEOF_SIZE_T == 8
- if (to_read >= threshold && threshold < MAX_THRESHOLD &&
- already_read + to_read + rawdata_offset > tif->tif_rawdatasize)
- {
- to_read = threshold;
- threshold *= THRESHOLD_MULTIPLIER;
- }
-#endif
- if (already_read + to_read + rawdata_offset > tif->tif_rawdatasize)
- {
- uint8_t *new_rawdata;
- assert((tif->tif_flags & TIFF_MYBUFFER) != 0);
- tif->tif_rawdatasize = (tmsize_t)TIFFroundup_64(
- (uint64_t)already_read + to_read + rawdata_offset, 1024);
- if (tif->tif_rawdatasize == 0)
- {
- TIFFErrorExtR(tif, module, "Invalid buffer size");
- return 0;
- }
- new_rawdata = (uint8_t *)_TIFFreallocExt(tif, tif->tif_rawdata,
- tif->tif_rawdatasize);
- if (new_rawdata == 0)
- {
- TIFFErrorExtR(tif, module,
- "No space for data buffer at scanline %" PRIu32,
- tif->tif_row);
- _TIFFfreeExt(tif, tif->tif_rawdata);
- tif->tif_rawdata = 0;
- tif->tif_rawdatasize = 0;
- return 0;
- }
- tif->tif_rawdata = new_rawdata;
- }
- if (tif->tif_rawdata == NULL)
- {
- /* should not happen in practice but helps CoverityScan */
- return 0;
- }
-
- bytes_read = TIFFReadFile(
- tif, tif->tif_rawdata + rawdata_offset + already_read, to_read);
- already_read += bytes_read;
- if (bytes_read != to_read)
- {
- memset(tif->tif_rawdata + rawdata_offset + already_read, 0,
- tif->tif_rawdatasize - rawdata_offset - already_read);
- if (is_strip)
- {
- TIFFErrorExtR(tif, module,
- "Read error at scanline %" PRIu32
- "; got %" TIFF_SSIZE_FORMAT " bytes, "
- "expected %" TIFF_SSIZE_FORMAT,
- tif->tif_row, already_read, size);
- }
- else
- {
- TIFFErrorExtR(tif, module,
- "Read error at row %" PRIu32 ", col %" PRIu32
- ", tile %" PRIu32 "; "
- "got %" TIFF_SSIZE_FORMAT
- " bytes, expected %" TIFF_SSIZE_FORMAT "",
- tif->tif_row, tif->tif_col, strip_or_tile,
- already_read, size);
- }
- return 0;
- }
- }
- return 1;
-}
-
-static int TIFFFillStripPartial(TIFF *tif, int strip, tmsize_t read_ahead,
- int restart)
-{
- static const char module[] = "TIFFFillStripPartial";
- register TIFFDirectory *td = &tif->tif_dir;
- tmsize_t unused_data;
- uint64_t read_offset;
- tmsize_t to_read;
- tmsize_t read_ahead_mod;
- /* tmsize_t bytecountm; */
-
- /*
- * Expand raw data buffer, if needed, to hold data
- * strip coming from file (perhaps should set upper
- * bound on the size of a buffer we'll use?).
- */
-
- /* bytecountm=(tmsize_t) TIFFGetStrileByteCount(tif, strip); */
-
- /* Not completely sure where the * 2 comes from, but probably for */
- /* an exponentional growth strategy of tif_rawdatasize */
- if (read_ahead < TIFF_TMSIZE_T_MAX / 2)
- read_ahead_mod = read_ahead * 2;
- else
- read_ahead_mod = read_ahead;
- if (read_ahead_mod > tif->tif_rawdatasize)
- {
- assert(restart);
-
- tif->tif_curstrip = NOSTRIP;
- if ((tif->tif_flags & TIFF_MYBUFFER) == 0)
- {
- TIFFErrorExtR(tif, module,
- "Data buffer too small to hold part of strip %d",
- strip);
- return (0);
- }
- }
-
- if (restart)
- {
- tif->tif_rawdataloaded = 0;
- tif->tif_rawdataoff = 0;
- }
-
- /*
- ** If we are reading more data, move any unused data to the
- ** start of the buffer.
- */
- if (tif->tif_rawdataloaded > 0)
- unused_data =
- tif->tif_rawdataloaded - (tif->tif_rawcp - tif->tif_rawdata);
- else
- unused_data = 0;
-
- if (unused_data > 0)
- {
- assert((tif->tif_flags & TIFF_BUFFERMMAP) == 0);
- memmove(tif->tif_rawdata, tif->tif_rawcp, unused_data);
- }
-
- /*
- ** Seek to the point in the file where more data should be read.
- */
- read_offset = TIFFGetStrileOffset(tif, strip) + tif->tif_rawdataoff +
- tif->tif_rawdataloaded;
-
- if (!SeekOK(tif, read_offset))
- {
- TIFFErrorExtR(tif, module,
- "Seek error at scanline %" PRIu32 ", strip %d",
- tif->tif_row, strip);
- return 0;
- }
-
- /*
- ** How much do we want to read?
- */
- if (read_ahead_mod > tif->tif_rawdatasize)
- to_read = read_ahead_mod - unused_data;
- else
- to_read = tif->tif_rawdatasize - unused_data;
- if ((uint64_t)to_read > TIFFGetStrileByteCount(tif, strip) -
- tif->tif_rawdataoff - tif->tif_rawdataloaded)
- {
- to_read = (tmsize_t)TIFFGetStrileByteCount(tif, strip) -
- tif->tif_rawdataoff - tif->tif_rawdataloaded;
- }
-
- assert((tif->tif_flags & TIFF_BUFFERMMAP) == 0);
- if (!TIFFReadAndRealloc(tif, to_read, unused_data, 1, /* is_strip */
- 0, /* strip_or_tile */
- module))
- {
- return 0;
- }
-
- tif->tif_rawdataoff =
- tif->tif_rawdataoff + tif->tif_rawdataloaded - unused_data;
- tif->tif_rawdataloaded = unused_data + to_read;
-
- tif->tif_rawcc = tif->tif_rawdataloaded;
- tif->tif_rawcp = tif->tif_rawdata;
-
- if (!isFillOrder(tif, td->td_fillorder) &&
- (tif->tif_flags & TIFF_NOBITREV) == 0)
- {
- assert((tif->tif_flags & TIFF_BUFFERMMAP) == 0);
- TIFFReverseBits(tif->tif_rawdata + unused_data, to_read);
- }
-
- /*
- ** When starting a strip from the beginning we need to
- ** restart the decoder.
- */
- if (restart)
- {
-
-#ifdef JPEG_SUPPORT
- /* A bit messy since breaks the codec abstraction. Ultimately */
- /* there should be a function pointer for that, but it seems */
- /* only JPEG is affected. */
- /* For JPEG, if there are multiple scans (can generally be known */
- /* with the read_ahead used), we need to read the whole strip */
- if (tif->tif_dir.td_compression == COMPRESSION_JPEG &&
- (uint64_t)tif->tif_rawcc < TIFFGetStrileByteCount(tif, strip))
- {
- if (TIFFJPEGIsFullStripRequired(tif))
- {
- return TIFFFillStrip(tif, strip);
- }
- }
-#endif
-
- return TIFFStartStrip(tif, strip);
- }
- else
- {
- return 1;
- }
-}
-
-/*
- * Seek to a random row+sample in a file.
- *
- * Only used by TIFFReadScanline, and is only used on
- * strip organized files. We do some tricky stuff to try
- * and avoid reading the whole compressed raw data for big
- * strips.
- */
-static int TIFFSeek(TIFF *tif, uint32_t row, uint16_t sample)
-{
- register TIFFDirectory *td = &tif->tif_dir;
- uint32_t strip;
- int whole_strip;
- tmsize_t read_ahead = 0;
-
- /*
- ** Establish what strip we are working from.
- */
- if (row >= td->td_imagelength)
- { /* out of range */
- TIFFErrorExtR(tif, tif->tif_name,
- "%" PRIu32 ": Row out of range, max %" PRIu32 "", row,
- td->td_imagelength);
- return (0);
- }
- if (td->td_planarconfig == PLANARCONFIG_SEPARATE)
- {
- if (sample >= td->td_samplesperpixel)
- {
- TIFFErrorExtR(tif, tif->tif_name,
- "%" PRIu16 ": Sample out of range, max %" PRIu16 "",
- sample, td->td_samplesperpixel);
- return (0);
- }
- strip = (uint32_t)sample * td->td_stripsperimage +
- row / td->td_rowsperstrip;
- }
- else
- strip = row / td->td_rowsperstrip;
-
- /*
- * Do we want to treat this strip as one whole chunk or
- * read it a few lines at a time?
- */
-#if defined(CHUNKY_STRIP_READ_SUPPORT)
- whole_strip = TIFFGetStrileByteCount(tif, strip) < 10 || isMapped(tif);
- if (td->td_compression == COMPRESSION_LERC ||
- td->td_compression == COMPRESSION_JBIG)
- {
- /* Ideally plugins should have a way to declare they don't support
- * chunk strip */
- whole_strip = 1;
- }
-#else
- whole_strip = 1;
-#endif
-
- if (!whole_strip)
- {
- /* 16 is for YCbCr mode where we may need to read 16 */
- /* lines at a time to get a decompressed line, and 5000 */
- /* is some constant value, for example for JPEG tables */
- if (tif->tif_scanlinesize < TIFF_TMSIZE_T_MAX / 16 &&
- tif->tif_scanlinesize * 16 < TIFF_TMSIZE_T_MAX - 5000)
- {
- read_ahead = tif->tif_scanlinesize * 16 + 5000;
- }
- else
- {
- read_ahead = tif->tif_scanlinesize;
- }
- }
-
- /*
- * If we haven't loaded this strip, do so now, possibly
- * only reading the first part.
- */
- if (strip != tif->tif_curstrip)
- { /* different strip, refill */
-
- if (whole_strip)
- {
- if (!TIFFFillStrip(tif, strip))
- return (0);
- }
- else
- {
- if (!TIFFFillStripPartial(tif, strip, read_ahead, 1))
- return 0;
- }
- }
-
- /*
- ** If we already have some data loaded, do we need to read some more?
- */
- else if (!whole_strip)
- {
- if (((tif->tif_rawdata + tif->tif_rawdataloaded) - tif->tif_rawcp) <
- read_ahead &&
- (uint64_t)tif->tif_rawdataoff + tif->tif_rawdataloaded <
- TIFFGetStrileByteCount(tif, strip))
- {
- if (!TIFFFillStripPartial(tif, strip, read_ahead, 0))
- return 0;
- }
- }
-
- if (row < tif->tif_row)
- {
- /*
- * Moving backwards within the same strip: backup
- * to the start and then decode forward (below).
- *
- * NB: If you're planning on lots of random access within a
- * strip, it's better to just read and decode the entire
- * strip, and then access the decoded data in a random fashion.
- */
-
- if (tif->tif_rawdataoff != 0)
- {
- if (!TIFFFillStripPartial(tif, strip, read_ahead, 1))
- return 0;
- }
- else
- {
- if (!TIFFStartStrip(tif, strip))
- return (0);
- }
- }
-
- if (row != tif->tif_row)
- {
- /*
- * Seek forward to the desired row.
- */
-
- /* TODO: Will this really work with partial buffers? */
-
- if (!(*tif->tif_seek)(tif, row - tif->tif_row))
- return (0);
- tif->tif_row = row;
- }
-
- return (1);
-}
-
-int TIFFReadScanline(TIFF *tif, void *buf, uint32_t row, uint16_t sample)
-{
- int e;
-
- if (!TIFFCheckRead(tif, 0))
- return (-1);
- if ((e = TIFFSeek(tif, row, sample)) != 0)
- {
- /*
- * Decompress desired row into user buffer.
- */
- e = (*tif->tif_decoderow)(tif, (uint8_t *)buf, tif->tif_scanlinesize,
- sample);
-
- /* we are now poised at the beginning of the next row */
- tif->tif_row = row + 1;
-
- if (e)
- (*tif->tif_postdecode)(tif, (uint8_t *)buf, tif->tif_scanlinesize);
- }
- else
- {
- memset(buf, 0, (size_t)tif->tif_scanlinesize);
- }
- return (e > 0 ? 1 : -1);
-}
-
-/*
- * Calculate the strip size according to the number of
- * rows in the strip (check for truncated last strip on any
- * of the separations).
- */
-static tmsize_t TIFFReadEncodedStripGetStripSize(TIFF *tif, uint32_t strip,
- uint16_t *pplane)
-{
- static const char module[] = "TIFFReadEncodedStrip";
- TIFFDirectory *td = &tif->tif_dir;
- uint32_t rowsperstrip;
- uint32_t stripsperplane;
- uint32_t stripinplane;
- uint32_t rows;
- tmsize_t stripsize;
- if (!TIFFCheckRead(tif, 0))
- return ((tmsize_t)(-1));
- if (strip >= td->td_nstrips)
- {
- TIFFErrorExtR(tif, module,
- "%" PRIu32 ": Strip out of range, max %" PRIu32, strip,
- td->td_nstrips);
- return ((tmsize_t)(-1));
- }
-
- rowsperstrip = td->td_rowsperstrip;
- if (rowsperstrip > td->td_imagelength)
- rowsperstrip = td->td_imagelength;
- if (rowsperstrip == 0)
- {
- TIFFErrorExtR(tif, module, "rowsperstrip is zero");
- return ((tmsize_t)(-1));
- }
- stripsperplane =
- TIFFhowmany_32_maxuint_compat(td->td_imagelength, rowsperstrip);
- stripinplane = (strip % stripsperplane);
- if (pplane)
- *pplane = (uint16_t)(strip / stripsperplane);
- rows = td->td_imagelength - stripinplane * rowsperstrip;
- if (rows > rowsperstrip)
- rows = rowsperstrip;
- stripsize = TIFFVStripSize(tif, rows);
- if (stripsize == 0)
- return ((tmsize_t)(-1));
- return stripsize;
-}
-
-/*
- * Read a strip of data and decompress the specified
- * amount into the user-supplied buffer.
- */
-tmsize_t TIFFReadEncodedStrip(TIFF *tif, uint32_t strip, void *buf,
- tmsize_t size)
-{
- static const char module[] = "TIFFReadEncodedStrip";
- TIFFDirectory *td = &tif->tif_dir;
- tmsize_t stripsize;
- uint16_t plane;
-
- stripsize = TIFFReadEncodedStripGetStripSize(tif, strip, &plane);
- if (stripsize == ((tmsize_t)(-1)))
- return ((tmsize_t)(-1));
-
- /* shortcut to avoid an extra memcpy() */
- if (td->td_compression == COMPRESSION_NONE && size != (tmsize_t)(-1) &&
- size >= stripsize && !isMapped(tif) &&
- ((tif->tif_flags & TIFF_NOREADRAW) == 0))
- {
- if (TIFFReadRawStrip1(tif, strip, buf, stripsize, module) != stripsize)
- return ((tmsize_t)(-1));
-
- if (!isFillOrder(tif, td->td_fillorder) &&
- (tif->tif_flags & TIFF_NOBITREV) == 0)
- TIFFReverseBits(buf, stripsize);
-
- (*tif->tif_postdecode)(tif, buf, stripsize);
- return (stripsize);
- }
-
- if ((size != (tmsize_t)(-1)) && (size < stripsize))
- stripsize = size;
- if (!TIFFFillStrip(tif, strip))
- {
- memset(buf, 0, (size_t)stripsize);
- return ((tmsize_t)(-1));
- }
- if ((*tif->tif_decodestrip)(tif, buf, stripsize, plane) <= 0)
- return ((tmsize_t)(-1));
- (*tif->tif_postdecode)(tif, buf, stripsize);
- return (stripsize);
-}
-
-/* Variant of TIFFReadEncodedStrip() that does
- * * if *buf == NULL, *buf = _TIFFmallocExt(tif, bufsizetoalloc) only after
- * TIFFFillStrip() has succeeded. This avoid excessive memory allocation in case
- * of truncated file.
- * * calls regular TIFFReadEncodedStrip() if *buf != NULL
- */
-tmsize_t _TIFFReadEncodedStripAndAllocBuffer(TIFF *tif, uint32_t strip,
- void **buf,
- tmsize_t bufsizetoalloc,
- tmsize_t size_to_read)
-{
- tmsize_t this_stripsize;
- uint16_t plane;
-
- if (*buf != NULL)
- {
- return TIFFReadEncodedStrip(tif, strip, *buf, size_to_read);
- }
-
- this_stripsize = TIFFReadEncodedStripGetStripSize(tif, strip, &plane);
- if (this_stripsize == ((tmsize_t)(-1)))
- return ((tmsize_t)(-1));
-
- if ((size_to_read != (tmsize_t)(-1)) && (size_to_read < this_stripsize))
- this_stripsize = size_to_read;
- if (!TIFFFillStrip(tif, strip))
- return ((tmsize_t)(-1));
-
- *buf = _TIFFmallocExt(tif, bufsizetoalloc);
- if (*buf == NULL)
- {
- TIFFErrorExtR(tif, TIFFFileName(tif), "No space for strip buffer");
- return ((tmsize_t)(-1));
- }
- _TIFFmemset(*buf, 0, bufsizetoalloc);
-
- if ((*tif->tif_decodestrip)(tif, *buf, this_stripsize, plane) <= 0)
- return ((tmsize_t)(-1));
- (*tif->tif_postdecode)(tif, *buf, this_stripsize);
- return (this_stripsize);
-}
-
-static tmsize_t TIFFReadRawStrip1(TIFF *tif, uint32_t strip, void *buf,
- tmsize_t size, const char *module)
-{
- assert((tif->tif_flags & TIFF_NOREADRAW) == 0);
- if (!isMapped(tif))
- {
- tmsize_t cc;
-
- if (!SeekOK(tif, TIFFGetStrileOffset(tif, strip)))
- {
- TIFFErrorExtR(tif, module,
- "Seek error at scanline %" PRIu32 ", strip %" PRIu32,
- tif->tif_row, strip);
- return ((tmsize_t)(-1));
- }
- cc = TIFFReadFile(tif, buf, size);
- if (cc != size)
- {
- TIFFErrorExtR(tif, module,
- "Read error at scanline %" PRIu32
- "; got %" TIFF_SSIZE_FORMAT
- " bytes, expected %" TIFF_SSIZE_FORMAT,
- tif->tif_row, cc, size);
- return ((tmsize_t)(-1));
- }
- }
- else
- {
- tmsize_t ma = 0;
- tmsize_t n;
- if ((TIFFGetStrileOffset(tif, strip) > (uint64_t)TIFF_TMSIZE_T_MAX) ||
- ((ma = (tmsize_t)TIFFGetStrileOffset(tif, strip)) > tif->tif_size))
- {
- n = 0;
- }
- else if (ma > TIFF_TMSIZE_T_MAX - size)
- {
- n = 0;
- }
- else
- {
- tmsize_t mb = ma + size;
- if (mb > tif->tif_size)
- n = tif->tif_size - ma;
- else
- n = size;
- }
- if (n != size)
- {
- TIFFErrorExtR(tif, module,
- "Read error at scanline %" PRIu32 ", strip %" PRIu32
- "; got %" TIFF_SSIZE_FORMAT
- " bytes, expected %" TIFF_SSIZE_FORMAT,
- tif->tif_row, strip, n, size);
- return ((tmsize_t)(-1));
- }
- _TIFFmemcpy(buf, tif->tif_base + ma, size);
- }
- return (size);
-}
-
-static tmsize_t TIFFReadRawStripOrTile2(TIFF *tif, uint32_t strip_or_tile,
- int is_strip, tmsize_t size,
- const char *module)
-{
- assert(!isMapped(tif));
- assert((tif->tif_flags & TIFF_NOREADRAW) == 0);
-
- if (!SeekOK(tif, TIFFGetStrileOffset(tif, strip_or_tile)))
- {
- if (is_strip)
- {
- TIFFErrorExtR(tif, module,
- "Seek error at scanline %" PRIu32 ", strip %" PRIu32,
- tif->tif_row, strip_or_tile);
- }
- else
- {
- TIFFErrorExtR(tif, module,
- "Seek error at row %" PRIu32 ", col %" PRIu32
- ", tile %" PRIu32,
- tif->tif_row, tif->tif_col, strip_or_tile);
- }
- return ((tmsize_t)(-1));
- }
-
- if (!TIFFReadAndRealloc(tif, size, 0, is_strip, strip_or_tile, module))
- {
- return ((tmsize_t)(-1));
- }
-
- return (size);
-}
-
-/*
- * Read a strip of data from the file.
- */
-tmsize_t TIFFReadRawStrip(TIFF *tif, uint32_t strip, void *buf, tmsize_t size)
-{
- static const char module[] = "TIFFReadRawStrip";
- TIFFDirectory *td = &tif->tif_dir;
- uint64_t bytecount64;
- tmsize_t bytecountm;
-
- if (!TIFFCheckRead(tif, 0))
- return ((tmsize_t)(-1));
- if (strip >= td->td_nstrips)
- {
- TIFFErrorExtR(tif, module,
- "%" PRIu32 ": Strip out of range, max %" PRIu32, strip,
- td->td_nstrips);
- return ((tmsize_t)(-1));
- }
- if (tif->tif_flags & TIFF_NOREADRAW)
- {
- TIFFErrorExtR(tif, module,
- "Compression scheme does not support access to raw "
- "uncompressed data");
- return ((tmsize_t)(-1));
- }
- bytecount64 = TIFFGetStrileByteCount(tif, strip);
- if (size != (tmsize_t)(-1) && (uint64_t)size <= bytecount64)
- bytecountm = size;
- else
- bytecountm = _TIFFCastUInt64ToSSize(tif, bytecount64, module);
- if (bytecountm == 0)
- {
- return ((tmsize_t)(-1));
- }
- return (TIFFReadRawStrip1(tif, strip, buf, bytecountm, module));
-}
-
-TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW
-static uint64_t NoSanitizeSubUInt64(uint64_t a, uint64_t b) { return a - b; }
-
-/*
- * Read the specified strip and setup for decoding. The data buffer is
- * expanded, as necessary, to hold the strip's data.
- */
-int TIFFFillStrip(TIFF *tif, uint32_t strip)
-{
- static const char module[] = "TIFFFillStrip";
- TIFFDirectory *td = &tif->tif_dir;
-
- if ((tif->tif_flags & TIFF_NOREADRAW) == 0)
- {
- uint64_t bytecount = TIFFGetStrileByteCount(tif, strip);
- if (bytecount == 0 || bytecount > (uint64_t)TIFF_INT64_MAX)
- {
- TIFFErrorExtR(tif, module,
- "Invalid strip byte count %" PRIu64
- ", strip %" PRIu32,
- bytecount, strip);
- return (0);
- }
-
- /* To avoid excessive memory allocations: */
- /* Byte count should normally not be larger than a number of */
- /* times the uncompressed size plus some margin */
- if (bytecount > 1024 * 1024)
- {
- /* 10 and 4096 are just values that could be adjusted. */
- /* Hopefully they are safe enough for all codecs */
- tmsize_t stripsize = TIFFStripSize(tif);
- if (stripsize != 0 && (bytecount - 4096) / 10 > (uint64_t)stripsize)
- {
- uint64_t newbytecount = (uint64_t)stripsize * 10 + 4096;
- TIFFErrorExtR(tif, module,
- "Too large strip byte count %" PRIu64
- ", strip %" PRIu32 ". Limiting to %" PRIu64,
- bytecount, strip, newbytecount);
- bytecount = newbytecount;
- }
- }
-
- if (isMapped(tif))
- {
- /*
- * We must check for overflow, potentially causing
- * an OOB read. Instead of simple
- *
- * TIFFGetStrileOffset(tif, strip)+bytecount > tif->tif_size
- *
- * comparison (which can overflow) we do the following
- * two comparisons:
- */
- if (bytecount > (uint64_t)tif->tif_size ||
- TIFFGetStrileOffset(tif, strip) >
- (uint64_t)tif->tif_size - bytecount)
- {
- /*
- * This error message might seem strange, but
- * it's what would happen if a read were done
- * instead.
- */
- TIFFErrorExtR(
- tif, module,
-
- "Read error on strip %" PRIu32 "; "
- "got %" PRIu64 " bytes, expected %" PRIu64,
- strip,
- NoSanitizeSubUInt64(tif->tif_size,
- TIFFGetStrileOffset(tif, strip)),
- bytecount);
- tif->tif_curstrip = NOSTRIP;
- return (0);
- }
- }
-
- if (isMapped(tif) && (isFillOrder(tif, td->td_fillorder) ||
- (tif->tif_flags & TIFF_NOBITREV)))
- {
- /*
- * The image is mapped into memory and we either don't
- * need to flip bits or the compression routine is
- * going to handle this operation itself. In this
- * case, avoid copying the raw data and instead just
- * reference the data from the memory mapped file
- * image. This assumes that the decompression
- * routines do not modify the contents of the raw data
- * buffer (if they try to, the application will get a
- * fault since the file is mapped read-only).
- */
- if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata)
- {
- _TIFFfreeExt(tif, tif->tif_rawdata);
- tif->tif_rawdata = NULL;
- tif->tif_rawdatasize = 0;
- }
- tif->tif_flags &= ~TIFF_MYBUFFER;
- tif->tif_rawdatasize = (tmsize_t)bytecount;
- tif->tif_rawdata =
- tif->tif_base + (tmsize_t)TIFFGetStrileOffset(tif, strip);
- tif->tif_rawdataoff = 0;
- tif->tif_rawdataloaded = (tmsize_t)bytecount;
-
- /*
- * When we have tif_rawdata reference directly into the memory
- * mapped file we need to be pretty careful about how we use the
- * rawdata. It is not a general purpose working buffer as it
- * normally otherwise is. So we keep track of this fact to avoid
- * using it improperly.
- */
- tif->tif_flags |= TIFF_BUFFERMMAP;
- }
- else
- {
- /*
- * Expand raw data buffer, if needed, to hold data
- * strip coming from file (perhaps should set upper
- * bound on the size of a buffer we'll use?).
- */
- tmsize_t bytecountm;
- bytecountm = (tmsize_t)bytecount;
- if ((uint64_t)bytecountm != bytecount)
- {
- TIFFErrorExtR(tif, module, "Integer overflow");
- return (0);
- }
- if (bytecountm > tif->tif_rawdatasize)
- {
- tif->tif_curstrip = NOSTRIP;
- if ((tif->tif_flags & TIFF_MYBUFFER) == 0)
- {
- TIFFErrorExtR(
- tif, module,
- "Data buffer too small to hold strip %" PRIu32, strip);
- return (0);
- }
- }
- if (tif->tif_flags & TIFF_BUFFERMMAP)
- {
- tif->tif_curstrip = NOSTRIP;
- tif->tif_rawdata = NULL;
- tif->tif_rawdatasize = 0;
- tif->tif_flags &= ~TIFF_BUFFERMMAP;
- }
-
- if (isMapped(tif))
- {
- if (bytecountm > tif->tif_rawdatasize &&
- !TIFFReadBufferSetup(tif, 0, bytecountm))
- {
- return (0);
- }
- if (TIFFReadRawStrip1(tif, strip, tif->tif_rawdata, bytecountm,
- module) != bytecountm)
- {
- return (0);
- }
- }
- else
- {
- if (TIFFReadRawStripOrTile2(tif, strip, 1, bytecountm,
- module) != bytecountm)
- {
- return (0);
- }
- }
-
- tif->tif_rawdataoff = 0;
- tif->tif_rawdataloaded = bytecountm;
-
- if (!isFillOrder(tif, td->td_fillorder) &&
- (tif->tif_flags & TIFF_NOBITREV) == 0)
- TIFFReverseBits(tif->tif_rawdata, bytecountm);
- }
- }
- return (TIFFStartStrip(tif, strip));
-}
-
-/*
- * Tile-oriented Read Support
- * Contributed by Nancy Cam (Silicon Graphics).
- */
-
-/*
- * Read and decompress a tile of data. The
- * tile is selected by the (x,y,z,s) coordinates.
- */
-tmsize_t TIFFReadTile(TIFF *tif, void *buf, uint32_t x, uint32_t y, uint32_t z,
- uint16_t s)
-{
- if (!TIFFCheckRead(tif, 1) || !TIFFCheckTile(tif, x, y, z, s))
- return ((tmsize_t)(-1));
- return (TIFFReadEncodedTile(tif, TIFFComputeTile(tif, x, y, z, s), buf,
- (tmsize_t)(-1)));
-}
-
-/*
- * Read a tile of data and decompress the specified
- * amount into the user-supplied buffer.
- */
-tmsize_t TIFFReadEncodedTile(TIFF *tif, uint32_t tile, void *buf, tmsize_t size)
-{
- static const char module[] = "TIFFReadEncodedTile";
- TIFFDirectory *td = &tif->tif_dir;
- tmsize_t tilesize = tif->tif_tilesize;
-
- if (!TIFFCheckRead(tif, 1))
- return ((tmsize_t)(-1));
- if (tile >= td->td_nstrips)
- {
- TIFFErrorExtR(tif, module,
- "%" PRIu32 ": Tile out of range, max %" PRIu32, tile,
- td->td_nstrips);
- return ((tmsize_t)(-1));
- }
-
- /* shortcut to avoid an extra memcpy() */
- if (td->td_compression == COMPRESSION_NONE && size != (tmsize_t)(-1) &&
- size >= tilesize && !isMapped(tif) &&
- ((tif->tif_flags & TIFF_NOREADRAW) == 0))
- {
- if (TIFFReadRawTile1(tif, tile, buf, tilesize, module) != tilesize)
- return ((tmsize_t)(-1));
-
- if (!isFillOrder(tif, td->td_fillorder) &&
- (tif->tif_flags & TIFF_NOBITREV) == 0)
- TIFFReverseBits(buf, tilesize);
-
- (*tif->tif_postdecode)(tif, buf, tilesize);
- return (tilesize);
- }
-
- if (size == (tmsize_t)(-1))
- size = tilesize;
- else if (size > tilesize)
- size = tilesize;
- if (!TIFFFillTile(tif, tile))
- {
- memset(buf, 0, (size_t)size);
- return ((tmsize_t)(-1));
- }
- else if ((*tif->tif_decodetile)(tif, (uint8_t *)buf, size,
- (uint16_t)(tile / td->td_stripsperimage)))
- {
- (*tif->tif_postdecode)(tif, (uint8_t *)buf, size);
- return (size);
- }
- else
- return ((tmsize_t)(-1));
-}
-
-/* Variant of TIFFReadTile() that does
- * * if *buf == NULL, *buf = _TIFFmallocExt(tif, bufsizetoalloc) only after
- * TIFFFillTile() has succeeded. This avoid excessive memory allocation in case
- * of truncated file.
- * * calls regular TIFFReadEncodedTile() if *buf != NULL
- */
-tmsize_t _TIFFReadTileAndAllocBuffer(TIFF *tif, void **buf,
- tmsize_t bufsizetoalloc, uint32_t x,
- uint32_t y, uint32_t z, uint16_t s)
-{
- if (!TIFFCheckRead(tif, 1) || !TIFFCheckTile(tif, x, y, z, s))
- return ((tmsize_t)(-1));
- return (_TIFFReadEncodedTileAndAllocBuffer(
- tif, TIFFComputeTile(tif, x, y, z, s), buf, bufsizetoalloc,
- (tmsize_t)(-1)));
-}
-
-/* Variant of TIFFReadEncodedTile() that does
- * * if *buf == NULL, *buf = _TIFFmallocExt(tif, bufsizetoalloc) only after
- * TIFFFillTile() has succeeded. This avoid excessive memory allocation in case
- * of truncated file.
- * * calls regular TIFFReadEncodedTile() if *buf != NULL
- */
-tmsize_t _TIFFReadEncodedTileAndAllocBuffer(TIFF *tif, uint32_t tile,
- void **buf, tmsize_t bufsizetoalloc,
- tmsize_t size_to_read)
-{
- static const char module[] = "_TIFFReadEncodedTileAndAllocBuffer";
- TIFFDirectory *td = &tif->tif_dir;
- tmsize_t tilesize = tif->tif_tilesize;
-
- if (*buf != NULL)
- {
- return TIFFReadEncodedTile(tif, tile, *buf, size_to_read);
- }
-
- if (!TIFFCheckRead(tif, 1))
- return ((tmsize_t)(-1));
- if (tile >= td->td_nstrips)
- {
- TIFFErrorExtR(tif, module,
- "%" PRIu32 ": Tile out of range, max %" PRIu32, tile,
- td->td_nstrips);
- return ((tmsize_t)(-1));
- }
-
- if (!TIFFFillTile(tif, tile))
- return ((tmsize_t)(-1));
-
- /* Sanity checks to avoid excessive memory allocation */
- /* Cf https://gitlab.com/libtiff/libtiff/-/issues/479 */
- if (td->td_compression == COMPRESSION_NONE)
- {
- if (tif->tif_rawdatasize != tilesize)
- {
- TIFFErrorExtR(tif, TIFFFileName(tif),
- "Invalid tile byte count for tile %u. "
- "Expected %" PRIu64 ", got %" PRIu64,
- tile, (uint64_t)tilesize,
- (uint64_t)tif->tif_rawdatasize);
- return ((tmsize_t)(-1));
- }
- }
- else
- {
- /* Max compression ratio experimentally determined. Might be fragile...
- * Only apply this heuristics to situations where the memory allocation
- * would be big, to avoid breaking nominal use cases.
- */
- const int maxCompressionRatio =
- td->td_compression == COMPRESSION_ZSTD ? 33000
- : td->td_compression == COMPRESSION_JXL
- ?
- /* Evaluated on a 8000x8000 tile */
- 25000 * (td->td_planarconfig == PLANARCONFIG_CONTIG
- ? td->td_samplesperpixel
- : 1)
- : td->td_compression == COMPRESSION_LZMA ? 7000 : 1000;
- if (bufsizetoalloc > 100 * 1000 * 1000 &&
- tif->tif_rawdatasize < tilesize / maxCompressionRatio)
- {
- TIFFErrorExtR(tif, TIFFFileName(tif),
- "Likely invalid tile byte count for tile %u. "
- "Uncompressed tile size is %" PRIu64 ", "
- "compressed one is %" PRIu64,
- tile, (uint64_t)tilesize,
- (uint64_t)tif->tif_rawdatasize);
- return ((tmsize_t)(-1));
- }
- }
-
- *buf = _TIFFmallocExt(tif, bufsizetoalloc);
- if (*buf == NULL)
- {
- TIFFErrorExtR(tif, TIFFFileName(tif), "No space for tile buffer");
- return ((tmsize_t)(-1));
- }
- _TIFFmemset(*buf, 0, bufsizetoalloc);
-
- if (size_to_read == (tmsize_t)(-1))
- size_to_read = tilesize;
- else if (size_to_read > tilesize)
- size_to_read = tilesize;
- if ((*tif->tif_decodetile)(tif, (uint8_t *)*buf, size_to_read,
- (uint16_t)(tile / td->td_stripsperimage)))
- {
- (*tif->tif_postdecode)(tif, (uint8_t *)*buf, size_to_read);
- return (size_to_read);
- }
- else
- return ((tmsize_t)(-1));
-}
-
-static tmsize_t TIFFReadRawTile1(TIFF *tif, uint32_t tile, void *buf,
- tmsize_t size, const char *module)
-{
- assert((tif->tif_flags & TIFF_NOREADRAW) == 0);
- if (!isMapped(tif))
- {
- tmsize_t cc;
-
- if (!SeekOK(tif, TIFFGetStrileOffset(tif, tile)))
- {
- TIFFErrorExtR(tif, module,
- "Seek error at row %" PRIu32 ", col %" PRIu32
- ", tile %" PRIu32,
- tif->tif_row, tif->tif_col, tile);
- return ((tmsize_t)(-1));
- }
- cc = TIFFReadFile(tif, buf, size);
- if (cc != size)
- {
- TIFFErrorExtR(tif, module,
- "Read error at row %" PRIu32 ", col %" PRIu32
- "; got %" TIFF_SSIZE_FORMAT
- " bytes, expected %" TIFF_SSIZE_FORMAT,
- tif->tif_row, tif->tif_col, cc, size);
- return ((tmsize_t)(-1));
- }
- }
- else
- {
- tmsize_t ma, mb;
- tmsize_t n;
- ma = (tmsize_t)TIFFGetStrileOffset(tif, tile);
- mb = ma + size;
- if ((TIFFGetStrileOffset(tif, tile) > (uint64_t)TIFF_TMSIZE_T_MAX) ||
- (ma > tif->tif_size))
- n = 0;
- else if ((mb < ma) || (mb < size) || (mb > tif->tif_size))
- n = tif->tif_size - ma;
- else
- n = size;
- if (n != size)
- {
- TIFFErrorExtR(tif, module,
- "Read error at row %" PRIu32 ", col %" PRIu32
- ", tile %" PRIu32 "; got %" TIFF_SSIZE_FORMAT
- " bytes, expected %" TIFF_SSIZE_FORMAT,
- tif->tif_row, tif->tif_col, tile, n, size);
- return ((tmsize_t)(-1));
- }
- _TIFFmemcpy(buf, tif->tif_base + ma, size);
- }
- return (size);
-}
-
-/*
- * Read a tile of data from the file.
- */
-tmsize_t TIFFReadRawTile(TIFF *tif, uint32_t tile, void *buf, tmsize_t size)
-{
- static const char module[] = "TIFFReadRawTile";
- TIFFDirectory *td = &tif->tif_dir;
- uint64_t bytecount64;
- tmsize_t bytecountm;
-
- if (!TIFFCheckRead(tif, 1))
- return ((tmsize_t)(-1));
- if (tile >= td->td_nstrips)
- {
- TIFFErrorExtR(tif, module,
- "%" PRIu32 ": Tile out of range, max %" PRIu32, tile,
- td->td_nstrips);
- return ((tmsize_t)(-1));
- }
- if (tif->tif_flags & TIFF_NOREADRAW)
- {
- TIFFErrorExtR(tif, module,
- "Compression scheme does not support access to raw "
- "uncompressed data");
- return ((tmsize_t)(-1));
- }
- bytecount64 = TIFFGetStrileByteCount(tif, tile);
- if (size != (tmsize_t)(-1) && (uint64_t)size <= bytecount64)
- bytecountm = size;
- else
- bytecountm = _TIFFCastUInt64ToSSize(tif, bytecount64, module);
- if (bytecountm == 0)
- {
- return ((tmsize_t)(-1));
- }
- return (TIFFReadRawTile1(tif, tile, buf, bytecountm, module));
-}
-
-/*
- * Read the specified tile and setup for decoding. The data buffer is
- * expanded, as necessary, to hold the tile's data.
- */
-int TIFFFillTile(TIFF *tif, uint32_t tile)
-{
- static const char module[] = "TIFFFillTile";
- TIFFDirectory *td = &tif->tif_dir;
-
- if ((tif->tif_flags & TIFF_NOREADRAW) == 0)
- {
- uint64_t bytecount = TIFFGetStrileByteCount(tif, tile);
- if (bytecount == 0 || bytecount > (uint64_t)TIFF_INT64_MAX)
- {
- TIFFErrorExtR(tif, module,
- "%" PRIu64 ": Invalid tile byte count, tile %" PRIu32,
- bytecount, tile);
- return (0);
- }
-
- /* To avoid excessive memory allocations: */
- /* Byte count should normally not be larger than a number of */
- /* times the uncompressed size plus some margin */
- if (bytecount > 1024 * 1024)
- {
- /* 10 and 4096 are just values that could be adjusted. */
- /* Hopefully they are safe enough for all codecs */
- tmsize_t stripsize = TIFFTileSize(tif);
- if (stripsize != 0 && (bytecount - 4096) / 10 > (uint64_t)stripsize)
- {
- uint64_t newbytecount = (uint64_t)stripsize * 10 + 4096;
- TIFFErrorExtR(tif, module,
- "Too large tile byte count %" PRIu64
- ", tile %" PRIu32 ". Limiting to %" PRIu64,
- bytecount, tile, newbytecount);
- bytecount = newbytecount;
- }
- }
-
- if (isMapped(tif))
- {
- /*
- * We must check for overflow, potentially causing
- * an OOB read. Instead of simple
- *
- * TIFFGetStrileOffset(tif, tile)+bytecount > tif->tif_size
- *
- * comparison (which can overflow) we do the following
- * two comparisons:
- */
- if (bytecount > (uint64_t)tif->tif_size ||
- TIFFGetStrileOffset(tif, tile) >
- (uint64_t)tif->tif_size - bytecount)
- {
- tif->tif_curtile = NOTILE;
- return (0);
- }
- }
-
- if (isMapped(tif) && (isFillOrder(tif, td->td_fillorder) ||
- (tif->tif_flags & TIFF_NOBITREV)))
- {
- /*
- * The image is mapped into memory and we either don't
- * need to flip bits or the compression routine is
- * going to handle this operation itself. In this
- * case, avoid copying the raw data and instead just
- * reference the data from the memory mapped file
- * image. This assumes that the decompression
- * routines do not modify the contents of the raw data
- * buffer (if they try to, the application will get a
- * fault since the file is mapped read-only).
- */
- if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata)
- {
- _TIFFfreeExt(tif, tif->tif_rawdata);
- tif->tif_rawdata = NULL;
- tif->tif_rawdatasize = 0;
- }
- tif->tif_flags &= ~TIFF_MYBUFFER;
-
- tif->tif_rawdatasize = (tmsize_t)bytecount;
- tif->tif_rawdata =
- tif->tif_base + (tmsize_t)TIFFGetStrileOffset(tif, tile);
- tif->tif_rawdataoff = 0;
- tif->tif_rawdataloaded = (tmsize_t)bytecount;
- tif->tif_flags |= TIFF_BUFFERMMAP;
- }
- else
- {
- /*
- * Expand raw data buffer, if needed, to hold data
- * tile coming from file (perhaps should set upper
- * bound on the size of a buffer we'll use?).
- */
- tmsize_t bytecountm;
- bytecountm = (tmsize_t)bytecount;
- if ((uint64_t)bytecountm != bytecount)
- {
- TIFFErrorExtR(tif, module, "Integer overflow");
- return (0);
- }
- if (bytecountm > tif->tif_rawdatasize)
- {
- tif->tif_curtile = NOTILE;
- if ((tif->tif_flags & TIFF_MYBUFFER) == 0)
- {
- TIFFErrorExtR(tif, module,
- "Data buffer too small to hold tile %" PRIu32,
- tile);
- return (0);
- }
- }
- if (tif->tif_flags & TIFF_BUFFERMMAP)
- {
- tif->tif_curtile = NOTILE;
- tif->tif_rawdata = NULL;
- tif->tif_rawdatasize = 0;
- tif->tif_flags &= ~TIFF_BUFFERMMAP;
- }
-
- if (isMapped(tif))
- {
- if (bytecountm > tif->tif_rawdatasize &&
- !TIFFReadBufferSetup(tif, 0, bytecountm))
- {
- return (0);
- }
- if (TIFFReadRawTile1(tif, tile, tif->tif_rawdata, bytecountm,
- module) != bytecountm)
- {
- return (0);
- }
- }
- else
- {
- if (TIFFReadRawStripOrTile2(tif, tile, 0, bytecountm, module) !=
- bytecountm)
- {
- return (0);
- }
- }
-
- tif->tif_rawdataoff = 0;
- tif->tif_rawdataloaded = bytecountm;
-
- if (tif->tif_rawdata != NULL &&
- !isFillOrder(tif, td->td_fillorder) &&
- (tif->tif_flags & TIFF_NOBITREV) == 0)
- TIFFReverseBits(tif->tif_rawdata, tif->tif_rawdataloaded);
- }
- }
- return (TIFFStartTile(tif, tile));
-}
-
-/*
- * Setup the raw data buffer in preparation for
- * reading a strip of raw data. If the buffer
- * is specified as zero, then a buffer of appropriate
- * size is allocated by the library. Otherwise,
- * the client must guarantee that the buffer is
- * large enough to hold any individual strip of
- * raw data.
- */
-int TIFFReadBufferSetup(TIFF *tif, void *bp, tmsize_t size)
-{
- static const char module[] = "TIFFReadBufferSetup";
-
- assert((tif->tif_flags & TIFF_NOREADRAW) == 0);
- tif->tif_flags &= ~TIFF_BUFFERMMAP;
-
- if (tif->tif_rawdata)
- {
- if (tif->tif_flags & TIFF_MYBUFFER)
- _TIFFfreeExt(tif, tif->tif_rawdata);
- tif->tif_rawdata = NULL;
- tif->tif_rawdatasize = 0;
- }
- if (bp)
- {
- tif->tif_rawdatasize = size;
- tif->tif_rawdata = (uint8_t *)bp;
- tif->tif_flags &= ~TIFF_MYBUFFER;
- }
- else
- {
- tif->tif_rawdatasize = (tmsize_t)TIFFroundup_64((uint64_t)size, 1024);
- if (tif->tif_rawdatasize == 0)
- {
- TIFFErrorExtR(tif, module, "Invalid buffer size");
- return (0);
- }
- /* Initialize to zero to avoid uninitialized buffers in case of */
- /* short reads (http://bugzilla.maptools.org/show_bug.cgi?id=2651) */
- tif->tif_rawdata =
- (uint8_t *)_TIFFcallocExt(tif, 1, tif->tif_rawdatasize);
- tif->tif_flags |= TIFF_MYBUFFER;
- }
- if (tif->tif_rawdata == NULL)
- {
- TIFFErrorExtR(tif, module,
- "No space for data buffer at scanline %" PRIu32,
- tif->tif_row);
- tif->tif_rawdatasize = 0;
- return (0);
- }
- return (1);
-}
-
-/*
- * Set state to appear as if a
- * strip has just been read in.
- */
-static int TIFFStartStrip(TIFF *tif, uint32_t strip)
-{
- TIFFDirectory *td = &tif->tif_dir;
-
- if ((tif->tif_flags & TIFF_CODERSETUP) == 0)
- {
- if (!(*tif->tif_setupdecode)(tif))
- return (0);
- tif->tif_flags |= TIFF_CODERSETUP;
- }
- tif->tif_curstrip = strip;
- tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip;
- tif->tif_flags &= ~TIFF_BUF4WRITE;
-
- if (tif->tif_flags & TIFF_NOREADRAW)
- {
- tif->tif_rawcp = NULL;
- tif->tif_rawcc = 0;
- }
- else
- {
- tif->tif_rawcp = tif->tif_rawdata;
- if (tif->tif_rawdataloaded > 0)
- tif->tif_rawcc = tif->tif_rawdataloaded;
- else
- tif->tif_rawcc = (tmsize_t)TIFFGetStrileByteCount(tif, strip);
- }
- if ((*tif->tif_predecode)(tif, (uint16_t)(strip / td->td_stripsperimage)) ==
- 0)
- {
- /* Needed for example for scanline access, if tif_predecode */
- /* fails, and we try to read the same strip again. Without invalidating
- */
- /* tif_curstrip, we'd call tif_decoderow() on a possibly invalid */
- /* codec state. */
- tif->tif_curstrip = NOSTRIP;
- return 0;
- }
- return 1;
-}
-
-/*
- * Set state to appear as if a
- * tile has just been read in.
- */
-static int TIFFStartTile(TIFF *tif, uint32_t tile)
-{
- static const char module[] = "TIFFStartTile";
- TIFFDirectory *td = &tif->tif_dir;
- uint32_t howmany32;
-
- if ((tif->tif_flags & TIFF_CODERSETUP) == 0)
- {
- if (!(*tif->tif_setupdecode)(tif))
- return (0);
- tif->tif_flags |= TIFF_CODERSETUP;
- }
- tif->tif_curtile = tile;
- if (td->td_tilewidth == 0)
- {
- TIFFErrorExtR(tif, module, "Zero tilewidth");
- return 0;
- }
- howmany32 = TIFFhowmany_32(td->td_imagewidth, td->td_tilewidth);
- if (howmany32 == 0)
- {
- TIFFErrorExtR(tif, module, "Zero tiles");
- return 0;
- }
- tif->tif_row = (tile % howmany32) * td->td_tilelength;
- howmany32 = TIFFhowmany_32(td->td_imagelength, td->td_tilelength);
- if (howmany32 == 0)
- {
- TIFFErrorExtR(tif, module, "Zero tiles");
- return 0;
- }
- tif->tif_col = (tile % howmany32) * td->td_tilewidth;
- tif->tif_flags &= ~TIFF_BUF4WRITE;
- if (tif->tif_flags & TIFF_NOREADRAW)
- {
- tif->tif_rawcp = NULL;
- tif->tif_rawcc = 0;
- }
- else
- {
- tif->tif_rawcp = tif->tif_rawdata;
- if (tif->tif_rawdataloaded > 0)
- tif->tif_rawcc = tif->tif_rawdataloaded;
- else
- tif->tif_rawcc = (tmsize_t)TIFFGetStrileByteCount(tif, tile);
- }
- return (
- (*tif->tif_predecode)(tif, (uint16_t)(tile / td->td_stripsperimage)));
-}
-
-static int TIFFCheckRead(TIFF *tif, int tiles)
-{
- if (tif->tif_mode == O_WRONLY)
- {
- TIFFErrorExtR(tif, tif->tif_name, "File not open for reading");
- return (0);
- }
- if (tiles ^ isTiled(tif))
- {
- TIFFErrorExtR(tif, tif->tif_name,
- tiles ? "Can not read tiles from a striped image"
- : "Can not read scanlines from a tiled image");
- return (0);
- }
- return (1);
-}
-
-/* Use the provided input buffer (inbuf, insize) and decompress it into
- * (outbuf, outsize).
- * This function replaces the use of
- * TIFFReadEncodedStrip()/TIFFReadEncodedTile() when the user can provide the
- * buffer for the input data, for example when he wants to avoid libtiff to read
- * the strile offset/count values from the [Strip|Tile][Offsets/ByteCounts]
- * array. inbuf content must be writable (if bit reversal is needed) Returns 1
- * in case of success, 0 otherwise.
- */
-int TIFFReadFromUserBuffer(TIFF *tif, uint32_t strile, void *inbuf,
- tmsize_t insize, void *outbuf, tmsize_t outsize)
-{
- static const char module[] = "TIFFReadFromUserBuffer";
- TIFFDirectory *td = &tif->tif_dir;
- int ret = 1;
- uint32_t old_tif_flags = tif->tif_flags;
- tmsize_t old_rawdatasize = tif->tif_rawdatasize;
- void *old_rawdata = tif->tif_rawdata;
-
- if (tif->tif_mode == O_WRONLY)
- {
- TIFFErrorExtR(tif, tif->tif_name, "File not open for reading");
- return 0;
- }
- if (tif->tif_flags & TIFF_NOREADRAW)
- {
- TIFFErrorExtR(tif, module,
- "Compression scheme does not support access to raw "
- "uncompressed data");
- return 0;
- }
-
- tif->tif_flags &= ~TIFF_MYBUFFER;
- tif->tif_flags |= TIFF_BUFFERMMAP;
- tif->tif_rawdatasize = insize;
- tif->tif_rawdata = inbuf;
- tif->tif_rawdataoff = 0;
- tif->tif_rawdataloaded = insize;
-
- if (!isFillOrder(tif, td->td_fillorder) &&
- (tif->tif_flags & TIFF_NOBITREV) == 0)
- {
- TIFFReverseBits(inbuf, insize);
- }
-
- if (TIFFIsTiled(tif))
- {
- if (!TIFFStartTile(tif, strile))
- {
- ret = 0;
- memset(outbuf, 0, (size_t)outsize);
- }
- else if (!(*tif->tif_decodetile)(
- tif, (uint8_t *)outbuf, outsize,
- (uint16_t)(strile / td->td_stripsperimage)))
- {
- ret = 0;
- }
- }
- else
- {
- uint32_t rowsperstrip = td->td_rowsperstrip;
- uint32_t stripsperplane;
- if (rowsperstrip > td->td_imagelength)
- rowsperstrip = td->td_imagelength;
- if (rowsperstrip == 0)
- {
- TIFFErrorExtR(tif, module, "rowsperstrip is zero");
- ret = 0;
- }
- else
- {
- stripsperplane =
- TIFFhowmany_32_maxuint_compat(td->td_imagelength, rowsperstrip);
- if (!TIFFStartStrip(tif, strile))
- {
- ret = 0;
- memset(outbuf, 0, (size_t)outsize);
- }
- else if (!(*tif->tif_decodestrip)(
- tif, (uint8_t *)outbuf, outsize,
- (uint16_t)(strile / stripsperplane)))
- {
- ret = 0;
- }
- }
- }
- if (ret)
- {
- (*tif->tif_postdecode)(tif, (uint8_t *)outbuf, outsize);
- }
-
- if (!isFillOrder(tif, td->td_fillorder) &&
- (tif->tif_flags & TIFF_NOBITREV) == 0)
- {
- TIFFReverseBits(inbuf, insize);
- }
-
- tif->tif_flags = (old_tif_flags & (TIFF_MYBUFFER | TIFF_BUFFERMMAP)) |
- (tif->tif_flags & ~(TIFF_MYBUFFER | TIFF_BUFFERMMAP));
- tif->tif_rawdatasize = old_rawdatasize;
- tif->tif_rawdata = old_rawdata;
- tif->tif_rawdataoff = 0;
- tif->tif_rawdataloaded = 0;
-
- return ret;
-}
-
-void _TIFFNoPostDecode(TIFF *tif, uint8_t *buf, tmsize_t cc)
-{
- (void)tif;
- (void)buf;
- (void)cc;
-}
-
-void _TIFFSwab16BitData(TIFF *tif, uint8_t *buf, tmsize_t cc)
-{
- (void)tif;
- assert((cc & 1) == 0);
- TIFFSwabArrayOfShort((uint16_t *)buf, cc / 2);
-}
-
-void _TIFFSwab24BitData(TIFF *tif, uint8_t *buf, tmsize_t cc)
-{
- (void)tif;
- assert((cc % 3) == 0);
- TIFFSwabArrayOfTriples((uint8_t *)buf, cc / 3);
-}
-
-void _TIFFSwab32BitData(TIFF *tif, uint8_t *buf, tmsize_t cc)
-{
- (void)tif;
- assert((cc & 3) == 0);
- TIFFSwabArrayOfLong((uint32_t *)buf, cc / 4);
-}
-
-void _TIFFSwab64BitData(TIFF *tif, uint8_t *buf, tmsize_t cc)
-{
- (void)tif;
- assert((cc & 7) == 0);
- TIFFSwabArrayOfDouble((double *)buf, cc / 8);
-}
diff --git a/contrib/libs/libtiff/tif_stream.cxx b/contrib/libs/libtiff/tif_stream.cxx
deleted file mode 100644
index 92ea273c56..0000000000
--- a/contrib/libs/libtiff/tif_stream.cxx
+++ /dev/null
@@ -1,404 +0,0 @@
-/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-/*
- * TIFF Library UNIX-specific Routines.
- */
-#include "tiffiop.h"
-#include <iostream>
-
-using namespace std;
-
-/*
- ISO C++ uses a 'std::streamsize' type to define counts. This makes
- it similar to, (but perhaps not the same as) size_t.
-
- The std::ios::pos_type is used to represent stream positions as used
- by tellg(), tellp(), seekg(), and seekp(). This makes it similar to
- (but perhaps not the same as) 'off_t'. The std::ios::streampos type
- is used for character streams, but is documented to not be an
- integral type anymore, so it should *not* be assigned to an integral
- type.
-
- The std::ios::off_type is used to specify relative offsets needed by
- the variants of seekg() and seekp() which accept a relative offset
- argument.
-
- Useful prototype knowledge:
-
- Obtain read position
- ios::pos_type basic_istream::tellg()
-
- Set read position
- basic_istream& basic_istream::seekg(ios::pos_type)
- basic_istream& basic_istream::seekg(ios::off_type, ios_base::seekdir)
-
- Read data
- basic_istream& istream::read(char *str, streamsize count)
-
- Number of characters read in last unformatted read
- streamsize istream::gcount();
-
- Obtain write position
- ios::pos_type basic_ostream::tellp()
-
- Set write position
- basic_ostream& basic_ostream::seekp(ios::pos_type)
- basic_ostream& basic_ostream::seekp(ios::off_type, ios_base::seekdir)
-
- Write data
- basic_ostream& ostream::write(const char *str, streamsize count)
-*/
-
-struct tiffis_data;
-struct tiffos_data;
-
-extern "C"
-{
-
- static tmsize_t _tiffosReadProc(thandle_t, void *, tmsize_t);
- static tmsize_t _tiffisReadProc(thandle_t fd, void *buf, tmsize_t size);
- static tmsize_t _tiffosWriteProc(thandle_t fd, void *buf, tmsize_t size);
- static tmsize_t _tiffisWriteProc(thandle_t, void *, tmsize_t);
- static uint64_t _tiffosSeekProc(thandle_t fd, uint64_t off, int whence);
- static uint64_t _tiffisSeekProc(thandle_t fd, uint64_t off, int whence);
- static uint64_t _tiffosSizeProc(thandle_t fd);
- static uint64_t _tiffisSizeProc(thandle_t fd);
- static int _tiffosCloseProc(thandle_t fd);
- static int _tiffisCloseProc(thandle_t fd);
- static int _tiffDummyMapProc(thandle_t, void **base, toff_t *size);
- static void _tiffDummyUnmapProc(thandle_t, void *base, toff_t size);
- static TIFF *_tiffStreamOpen(const char *name, const char *mode, void *fd);
-
- struct tiffis_data
- {
- istream *stream;
- ios::pos_type start_pos;
- };
-
- struct tiffos_data
- {
- ostream *stream;
- ios::pos_type start_pos;
- };
-
- static tmsize_t _tiffosReadProc(thandle_t, void *, tmsize_t) { return 0; }
-
- static tmsize_t _tiffisReadProc(thandle_t fd, void *buf, tmsize_t size)
- {
- tiffis_data *data = reinterpret_cast<tiffis_data *>(fd);
-
- // Verify that type does not overflow.
- streamsize request_size = size;
- if (static_cast<tmsize_t>(request_size) != size)
- return static_cast<tmsize_t>(-1);
-
- data->stream->read((char *)buf, request_size);
-
- return static_cast<tmsize_t>(data->stream->gcount());
- }
-
- static tmsize_t _tiffosWriteProc(thandle_t fd, void *buf, tmsize_t size)
- {
- tiffos_data *data = reinterpret_cast<tiffos_data *>(fd);
- ostream *os = data->stream;
- ios::pos_type pos = os->tellp();
-
- // Verify that type does not overflow.
- streamsize request_size = size;
- if (static_cast<tmsize_t>(request_size) != size)
- return static_cast<tmsize_t>(-1);
-
- os->write(reinterpret_cast<const char *>(buf), request_size);
-
- return static_cast<tmsize_t>(os->tellp() - pos);
- }
-
- static tmsize_t _tiffisWriteProc(thandle_t, void *, tmsize_t) { return 0; }
-
- static uint64_t _tiffosSeekProc(thandle_t fd, uint64_t off, int whence)
- {
- tiffos_data *data = reinterpret_cast<tiffos_data *>(fd);
- ostream *os = data->stream;
-
- // if the stream has already failed, don't do anything
- if (os->fail())
- return static_cast<uint64_t>(-1);
-
- switch (whence)
- {
- case SEEK_SET:
- {
- // Compute 64-bit offset
- uint64_t new_offset =
- static_cast<uint64_t>(data->start_pos) + off;
-
- // Verify that value does not overflow
- ios::off_type offset = static_cast<ios::off_type>(new_offset);
- if (static_cast<uint64_t>(offset) != new_offset)
- return static_cast<uint64_t>(-1);
-
- os->seekp(offset, ios::beg);
- break;
- }
- case SEEK_CUR:
- {
- // Verify that value does not overflow
- ios::off_type offset = static_cast<ios::off_type>(off);
- if (static_cast<uint64_t>(offset) != off)
- return static_cast<uint64_t>(-1);
-
- os->seekp(offset, ios::cur);
- break;
- }
- case SEEK_END:
- {
- // Verify that value does not overflow
- ios::off_type offset = static_cast<ios::off_type>(off);
- if (static_cast<uint64_t>(offset) != off)
- return static_cast<uint64_t>(-1);
-
- os->seekp(offset, ios::end);
- break;
- }
- }
-
- // Attempt to workaround problems with seeking past the end of the
- // stream. ofstream doesn't have a problem with this but
- // ostrstream/ostringstream does. In that situation, add intermediate
- // '\0' characters.
- if (os->fail())
- {
- ios::iostate old_state;
- ios::pos_type origin;
-
- old_state = os->rdstate();
- // reset the fail bit or else tellp() won't work below
- os->clear(os->rdstate() & ~ios::failbit);
- switch (whence)
- {
- case SEEK_SET:
- default:
- origin = data->start_pos;
- break;
- case SEEK_CUR:
- origin = os->tellp();
- break;
- case SEEK_END:
- os->seekp(0, ios::end);
- origin = os->tellp();
- break;
- }
- // restore original stream state
- os->clear(old_state);
-
- // only do something if desired seek position is valid
- if ((static_cast<uint64_t>(origin) + off) >
- static_cast<uint64_t>(data->start_pos))
- {
- uint64_t num_fill;
-
- // clear the fail bit
- os->clear(os->rdstate() & ~ios::failbit);
-
- // extend the stream to the expected size
- os->seekp(0, ios::end);
- num_fill = (static_cast<uint64_t>(origin)) + off - os->tellp();
- for (uint64_t i = 0; i < num_fill; i++)
- os->put('\0');
-
- // retry the seek
- os->seekp(static_cast<ios::off_type>(
- static_cast<uint64_t>(origin) + off),
- ios::beg);
- }
- }
-
- return static_cast<uint64_t>(os->tellp());
- }
-
- static uint64_t _tiffisSeekProc(thandle_t fd, uint64_t off, int whence)
- {
- tiffis_data *data = reinterpret_cast<tiffis_data *>(fd);
-
- switch (whence)
- {
- case SEEK_SET:
- {
- // Compute 64-bit offset
- uint64_t new_offset =
- static_cast<uint64_t>(data->start_pos) + off;
-
- // Verify that value does not overflow
- ios::off_type offset = static_cast<ios::off_type>(new_offset);
- if (static_cast<uint64_t>(offset) != new_offset)
- return static_cast<uint64_t>(-1);
-
- data->stream->seekg(offset, ios::beg);
- break;
- }
- case SEEK_CUR:
- {
- // Verify that value does not overflow
- ios::off_type offset = static_cast<ios::off_type>(off);
- if (static_cast<uint64_t>(offset) != off)
- return static_cast<uint64_t>(-1);
-
- data->stream->seekg(offset, ios::cur);
- break;
- }
- case SEEK_END:
- {
- // Verify that value does not overflow
- ios::off_type offset = static_cast<ios::off_type>(off);
- if (static_cast<uint64_t>(offset) != off)
- return static_cast<uint64_t>(-1);
-
- data->stream->seekg(offset, ios::end);
- break;
- }
- }
-
- return (uint64_t)(data->stream->tellg() - data->start_pos);
- }
-
- static uint64_t _tiffosSizeProc(thandle_t fd)
- {
- tiffos_data *data = reinterpret_cast<tiffos_data *>(fd);
- ostream *os = data->stream;
- ios::pos_type pos = os->tellp();
- ios::pos_type len;
-
- os->seekp(0, ios::end);
- len = os->tellp();
- os->seekp(pos);
-
- return (uint64_t)len;
- }
-
- static uint64_t _tiffisSizeProc(thandle_t fd)
- {
- tiffis_data *data = reinterpret_cast<tiffis_data *>(fd);
- ios::pos_type pos = data->stream->tellg();
- ios::pos_type len;
-
- data->stream->seekg(0, ios::end);
- len = data->stream->tellg();
- data->stream->seekg(pos);
-
- return (uint64_t)len;
- }
-
- static int _tiffosCloseProc(thandle_t fd)
- {
- // Our stream was not allocated by us, so it shouldn't be closed by us.
- delete reinterpret_cast<tiffos_data *>(fd);
- return 0;
- }
-
- static int _tiffisCloseProc(thandle_t fd)
- {
- // Our stream was not allocated by us, so it shouldn't be closed by us.
- delete reinterpret_cast<tiffis_data *>(fd);
- return 0;
- }
-
- static int _tiffDummyMapProc(thandle_t, void **base, toff_t *size)
- {
- (void)base;
- (void)size;
- return (0);
- }
-
- static void _tiffDummyUnmapProc(thandle_t, void *base, toff_t size)
- {
- (void)base;
- (void)size;
- }
-
- /*
- * Open a TIFF file descriptor for read/writing.
- */
- static TIFF *_tiffStreamOpen(const char *name, const char *mode, void *fd)
- {
- TIFF *tif;
-
- if (strchr(mode, 'w'))
- {
- tiffos_data *data = new tiffos_data;
- data->stream = reinterpret_cast<ostream *>(fd);
- data->start_pos = data->stream->tellp();
-
- // Open for writing.
- tif = TIFFClientOpen(
- name, mode, reinterpret_cast<thandle_t>(data), _tiffosReadProc,
- _tiffosWriteProc, _tiffosSeekProc, _tiffosCloseProc,
- _tiffosSizeProc, _tiffDummyMapProc, _tiffDummyUnmapProc);
- if (!tif)
- {
- delete data;
- }
- }
- else
- {
- tiffis_data *data = new tiffis_data;
- data->stream = reinterpret_cast<istream *>(fd);
- data->start_pos = data->stream->tellg();
- // Open for reading.
- tif = TIFFClientOpen(
- name, mode, reinterpret_cast<thandle_t>(data), _tiffisReadProc,
- _tiffisWriteProc, _tiffisSeekProc, _tiffisCloseProc,
- _tiffisSizeProc, _tiffDummyMapProc, _tiffDummyUnmapProc);
- if (!tif)
- {
- delete data;
- }
- }
-
- return (tif);
- }
-
-} /* extern "C" */
-
-TIFF *TIFFStreamOpen(const char *name, ostream *os)
-{
- // If os is either a ostrstream or ostringstream, and has no data
- // written to it yet, then tellp() will return -1 which will break us.
- // We workaround this by writing out a dummy character and
- // then seek back to the beginning.
- if (!os->fail() && static_cast<int>(os->tellp()) < 0)
- {
- *os << '\0';
- os->seekp(0);
- }
-
- // NB: We don't support mapped files with streams so add 'm'
- return _tiffStreamOpen(name, "wm", os);
-}
-
-TIFF *TIFFStreamOpen(const char *name, istream *is)
-{
- // NB: We don't support mapped files with streams so add 'm'
- return _tiffStreamOpen(name, "rm", is);
-}
diff --git a/contrib/libs/libtiff/tif_strip.c b/contrib/libs/libtiff/tif_strip.c
deleted file mode 100644
index 75b7b56266..0000000000
--- a/contrib/libs/libtiff/tif_strip.c
+++ /dev/null
@@ -1,380 +0,0 @@
-/*
- * Copyright (c) 1991-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-/*
- * TIFF Library.
- *
- * Strip-organized Image Support Routines.
- */
-#include "tiffiop.h"
-
-/*
- * Compute which strip a (row,sample) value is in.
- */
-uint32_t TIFFComputeStrip(TIFF *tif, uint32_t row, uint16_t sample)
-{
- static const char module[] = "TIFFComputeStrip";
- TIFFDirectory *td = &tif->tif_dir;
- uint32_t strip;
-
- if (td->td_rowsperstrip == 0)
- {
- TIFFErrorExtR(tif, module, "Cannot compute strip: RowsPerStrip is zero");
- return 0;
- }
- strip = row / td->td_rowsperstrip;
- if (td->td_planarconfig == PLANARCONFIG_SEPARATE)
- {
- if (sample >= td->td_samplesperpixel)
- {
- TIFFErrorExtR(tif, module, "%lu: Sample out of range, max %lu",
- (unsigned long)sample,
- (unsigned long)td->td_samplesperpixel);
- return (0);
- }
- strip += (uint32_t)sample * td->td_stripsperimage;
- }
- return (strip);
-}
-
-/*
- * Compute how many strips are in an image.
- */
-uint32_t TIFFNumberOfStrips(TIFF *tif)
-{
- TIFFDirectory *td = &tif->tif_dir;
- uint32_t nstrips;
-
- if (td->td_rowsperstrip == 0)
- {
- TIFFWarningExtR(tif, "TIFFNumberOfStrips", "RowsPerStrip is zero");
- return 0;
- }
- nstrips = (td->td_rowsperstrip == (uint32_t)-1
- ? 1
- : TIFFhowmany_32(td->td_imagelength, td->td_rowsperstrip));
- if (td->td_planarconfig == PLANARCONFIG_SEPARATE)
- nstrips =
- _TIFFMultiply32(tif, nstrips, (uint32_t)td->td_samplesperpixel,
- "TIFFNumberOfStrips");
- return (nstrips);
-}
-
-/*
- * Compute the # bytes in a variable height, row-aligned strip.
- */
-uint64_t TIFFVStripSize64(TIFF *tif, uint32_t nrows)
-{
- static const char module[] = "TIFFVStripSize64";
- TIFFDirectory *td = &tif->tif_dir;
- if (nrows == (uint32_t)(-1))
- nrows = td->td_imagelength;
- if ((td->td_planarconfig == PLANARCONFIG_CONTIG) &&
- (td->td_photometric == PHOTOMETRIC_YCBCR) && (!isUpSampled(tif)))
- {
- /*
- * Packed YCbCr data contain one Cb+Cr for every
- * HorizontalSampling*VerticalSampling Y values.
- * Must also roundup width and height when calculating
- * since images that are not a multiple of the
- * horizontal/vertical subsampling area include
- * YCbCr data for the extended image.
- */
- uint16_t ycbcrsubsampling[2];
- uint16_t samplingblock_samples;
- uint32_t samplingblocks_hor;
- uint32_t samplingblocks_ver;
- uint64_t samplingrow_samples;
- uint64_t samplingrow_size;
- if (td->td_samplesperpixel != 3)
- {
- TIFFErrorExtR(tif, module, "Invalid td_samplesperpixel value");
- return 0;
- }
- TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRSUBSAMPLING,
- ycbcrsubsampling + 0, ycbcrsubsampling + 1);
- if ((ycbcrsubsampling[0] != 1 && ycbcrsubsampling[0] != 2 &&
- ycbcrsubsampling[0] != 4) ||
- (ycbcrsubsampling[1] != 1 && ycbcrsubsampling[1] != 2 &&
- ycbcrsubsampling[1] != 4) ||
- (ycbcrsubsampling[0] == 0 || ycbcrsubsampling[1] == 0))
- {
- TIFFErrorExtR(tif, module, "Invalid YCbCr subsampling (%dx%d)",
- ycbcrsubsampling[0], ycbcrsubsampling[1]);
- return 0;
- }
- samplingblock_samples = ycbcrsubsampling[0] * ycbcrsubsampling[1] + 2;
- samplingblocks_hor =
- TIFFhowmany_32(td->td_imagewidth, ycbcrsubsampling[0]);
- samplingblocks_ver = TIFFhowmany_32(nrows, ycbcrsubsampling[1]);
- samplingrow_samples = _TIFFMultiply64(tif, samplingblocks_hor,
- samplingblock_samples, module);
- samplingrow_size = TIFFhowmany8_64(_TIFFMultiply64(
- tif, samplingrow_samples, td->td_bitspersample, module));
- return (
- _TIFFMultiply64(tif, samplingrow_size, samplingblocks_ver, module));
- }
- else
- return (_TIFFMultiply64(tif, nrows, TIFFScanlineSize64(tif), module));
-}
-tmsize_t TIFFVStripSize(TIFF *tif, uint32_t nrows)
-{
- static const char module[] = "TIFFVStripSize";
- uint64_t m;
- m = TIFFVStripSize64(tif, nrows);
- return _TIFFCastUInt64ToSSize(tif, m, module);
-}
-
-/*
- * Compute the # bytes in a raw strip.
- */
-uint64_t TIFFRawStripSize64(TIFF *tif, uint32_t strip)
-{
- static const char module[] = "TIFFRawStripSize64";
- uint64_t bytecount = TIFFGetStrileByteCount(tif, strip);
-
- if (bytecount == 0)
- {
- TIFFErrorExtR(tif, module,
- "%" PRIu64 ": Invalid strip byte count, strip %lu",
- (uint64_t)bytecount, (unsigned long)strip);
- bytecount = (uint64_t)-1;
- }
-
- return bytecount;
-}
-tmsize_t TIFFRawStripSize(TIFF *tif, uint32_t strip)
-{
- static const char module[] = "TIFFRawStripSize";
- uint64_t m;
- tmsize_t n;
- m = TIFFRawStripSize64(tif, strip);
- if (m == (uint64_t)(-1))
- n = (tmsize_t)(-1);
- else
- {
- n = (tmsize_t)m;
- if ((uint64_t)n != m)
- {
- TIFFErrorExtR(tif, module, "Integer overflow");
- n = 0;
- }
- }
- return (n);
-}
-
-/*
- * Compute the # bytes in a (row-aligned) strip.
- *
- * Note that if RowsPerStrip is larger than the
- * recorded ImageLength, then the strip size is
- * truncated to reflect the actual space required
- * to hold the strip.
- */
-uint64_t TIFFStripSize64(TIFF *tif)
-{
- TIFFDirectory *td = &tif->tif_dir;
- uint32_t rps = td->td_rowsperstrip;
- if (rps > td->td_imagelength)
- rps = td->td_imagelength;
- return (TIFFVStripSize64(tif, rps));
-}
-tmsize_t TIFFStripSize(TIFF *tif)
-{
- static const char module[] = "TIFFStripSize";
- uint64_t m;
- m = TIFFStripSize64(tif);
- return _TIFFCastUInt64ToSSize(tif, m, module);
-}
-
-/*
- * Compute a default strip size based on the image
- * characteristics and a requested value. If the
- * request is <1 then we choose a strip size according
- * to certain heuristics.
- */
-uint32_t TIFFDefaultStripSize(TIFF *tif, uint32_t request)
-{
- return (*tif->tif_defstripsize)(tif, request);
-}
-
-uint32_t _TIFFDefaultStripSize(TIFF *tif, uint32_t s)
-{
- if ((int32_t)s < 1)
- {
- /*
- * If RowsPerStrip is unspecified, try to break the
- * image up into strips that are approximately
- * STRIP_SIZE_DEFAULT bytes long.
- */
- uint64_t scanlinesize;
- uint64_t rows;
- scanlinesize = TIFFScanlineSize64(tif);
- if (scanlinesize == 0)
- scanlinesize = 1;
- rows = (uint64_t)STRIP_SIZE_DEFAULT / scanlinesize;
- if (rows == 0)
- rows = 1;
- else if (rows > 0xFFFFFFFF)
- rows = 0xFFFFFFFF;
- s = (uint32_t)rows;
- }
- return (s);
-}
-
-/*
- * Return the number of bytes to read/write in a call to
- * one of the scanline-oriented i/o routines. Note that
- * this number may be 1/samples-per-pixel if data is
- * stored as separate planes.
- * The ScanlineSize in case of YCbCrSubsampling is defined as the
- * strip size divided by the strip height, i.e. the size of a pack of vertical
- * subsampling lines divided by vertical subsampling. It should thus make
- * sense when multiplied by a multiple of vertical subsampling.
- */
-uint64_t TIFFScanlineSize64(TIFF *tif)
-{
- static const char module[] = "TIFFScanlineSize64";
- TIFFDirectory *td = &tif->tif_dir;
- uint64_t scanline_size;
- if (td->td_planarconfig == PLANARCONFIG_CONTIG)
- {
- if ((td->td_photometric == PHOTOMETRIC_YCBCR) &&
- (td->td_samplesperpixel == 3) && (!isUpSampled(tif)))
- {
- uint16_t ycbcrsubsampling[2];
- uint16_t samplingblock_samples;
- uint32_t samplingblocks_hor;
- uint64_t samplingrow_samples;
- uint64_t samplingrow_size;
- if (td->td_samplesperpixel != 3)
- {
- TIFFErrorExtR(tif, module, "Invalid td_samplesperpixel value");
- return 0;
- }
- TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRSUBSAMPLING,
- ycbcrsubsampling + 0, ycbcrsubsampling + 1);
- if (((ycbcrsubsampling[0] != 1) && (ycbcrsubsampling[0] != 2) &&
- (ycbcrsubsampling[0] != 4)) ||
- ((ycbcrsubsampling[1] != 1) && (ycbcrsubsampling[1] != 2) &&
- (ycbcrsubsampling[1] != 4)) ||
- ((ycbcrsubsampling[0] == 0) || (ycbcrsubsampling[1] == 0)))
- {
- TIFFErrorExtR(tif, module, "Invalid YCbCr subsampling");
- return 0;
- }
- samplingblock_samples =
- ycbcrsubsampling[0] * ycbcrsubsampling[1] + 2;
- samplingblocks_hor =
- TIFFhowmany_32(td->td_imagewidth, ycbcrsubsampling[0]);
- samplingrow_samples = _TIFFMultiply64(
- tif, samplingblocks_hor, samplingblock_samples, module);
- samplingrow_size =
- TIFFhowmany_64(_TIFFMultiply64(tif, samplingrow_samples,
- td->td_bitspersample, module),
- 8);
- scanline_size = (samplingrow_size / ycbcrsubsampling[1]);
- }
- else
- {
- uint64_t scanline_samples;
- uint32_t scanline_width = td->td_imagewidth;
-
-#if 0
- // Tries to fix https://gitlab.com/libtiff/libtiff/-/merge_requests/564
- // but causes regression when decoding legit files with tiffcp -c none
- // Cf https://gitlab.com/libtiff/libtiff/-/merge_requests/644
- if (td->td_photometric == PHOTOMETRIC_YCBCR)
- {
- uint16_t subsampling_hor;
- uint16_t ignored;
- TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRSUBSAMPLING,
- &subsampling_hor, &ignored);
- if (subsampling_hor > 1) // roundup width for YCbCr
- scanline_width =
- TIFFroundup_32(scanline_width, subsampling_hor);
- }
-#endif
-
- scanline_samples = _TIFFMultiply64(tif, scanline_width,
- td->td_samplesperpixel, module);
- scanline_size =
- TIFFhowmany_64(_TIFFMultiply64(tif, scanline_samples,
- td->td_bitspersample, module),
- 8);
- }
- }
- else
- {
- scanline_size =
- TIFFhowmany_64(_TIFFMultiply64(tif, td->td_imagewidth,
- td->td_bitspersample, module),
- 8);
- }
- if (scanline_size == 0)
- {
- TIFFWarningExtR(tif, module, "Computed scanline size is zero");
- return 0;
- }
- return (scanline_size);
-}
-tmsize_t TIFFScanlineSize(TIFF *tif)
-{
- static const char module[] = "TIFFScanlineSize";
- uint64_t m;
- m = TIFFScanlineSize64(tif);
- return _TIFFCastUInt64ToSSize(tif, m, module);
-}
-
-/*
- * Return the number of bytes required to store a complete
- * decoded and packed raster scanline (as opposed to the
- * I/O size returned by TIFFScanlineSize which may be less
- * if data is store as separate planes).
- */
-uint64_t TIFFRasterScanlineSize64(TIFF *tif)
-{
- static const char module[] = "TIFFRasterScanlineSize64";
- TIFFDirectory *td = &tif->tif_dir;
- uint64_t scanline;
-
- scanline =
- _TIFFMultiply64(tif, td->td_bitspersample, td->td_imagewidth, module);
- if (td->td_planarconfig == PLANARCONFIG_CONTIG)
- {
- scanline =
- _TIFFMultiply64(tif, scanline, td->td_samplesperpixel, module);
- return (TIFFhowmany8_64(scanline));
- }
- else
- return (_TIFFMultiply64(tif, TIFFhowmany8_64(scanline),
- td->td_samplesperpixel, module));
-}
-tmsize_t TIFFRasterScanlineSize(TIFF *tif)
-{
- static const char module[] = "TIFFRasterScanlineSize";
- uint64_t m;
- m = TIFFRasterScanlineSize64(tif);
- return _TIFFCastUInt64ToSSize(tif, m, module);
-}
diff --git a/contrib/libs/libtiff/tif_swab.c b/contrib/libs/libtiff/tif_swab.c
deleted file mode 100644
index 827b025ce7..0000000000
--- a/contrib/libs/libtiff/tif_swab.c
+++ /dev/null
@@ -1,329 +0,0 @@
-/*
- * Copyright (c) 1988-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-/*
- * TIFF Library Bit & Byte Swapping Support.
- *
- * XXX We assume short = 16-bits and long = 32-bits XXX
- */
-#include "tiffiop.h"
-
-#if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabShort)
-void TIFFSwabShort(uint16_t *wp)
-{
- register unsigned char *cp = (unsigned char *)wp;
- unsigned char t;
- assert(sizeof(uint16_t) == 2);
- t = cp[1];
- cp[1] = cp[0];
- cp[0] = t;
-}
-#endif
-
-#if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabLong)
-void TIFFSwabLong(uint32_t *lp)
-{
- register unsigned char *cp = (unsigned char *)lp;
- unsigned char t;
- assert(sizeof(uint32_t) == 4);
- t = cp[3];
- cp[3] = cp[0];
- cp[0] = t;
- t = cp[2];
- cp[2] = cp[1];
- cp[1] = t;
-}
-#endif
-
-#if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabLong8)
-void TIFFSwabLong8(uint64_t *lp)
-{
- register unsigned char *cp = (unsigned char *)lp;
- unsigned char t;
- assert(sizeof(uint64_t) == 8);
- t = cp[7];
- cp[7] = cp[0];
- cp[0] = t;
- t = cp[6];
- cp[6] = cp[1];
- cp[1] = t;
- t = cp[5];
- cp[5] = cp[2];
- cp[2] = t;
- t = cp[4];
- cp[4] = cp[3];
- cp[3] = t;
-}
-#endif
-
-#if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabArrayOfShort)
-void TIFFSwabArrayOfShort(register uint16_t *wp, tmsize_t n)
-{
- register unsigned char *cp;
- register unsigned char t;
- assert(sizeof(uint16_t) == 2);
- /* XXX unroll loop some */
- while (n-- > 0)
- {
- cp = (unsigned char *)wp;
- t = cp[1];
- cp[1] = cp[0];
- cp[0] = t;
- wp++;
- }
-}
-#endif
-
-#if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabArrayOfTriples)
-void TIFFSwabArrayOfTriples(register uint8_t *tp, tmsize_t n)
-{
- unsigned char *cp;
- unsigned char t;
-
- /* XXX unroll loop some */
- while (n-- > 0)
- {
- cp = (unsigned char *)tp;
- t = cp[2];
- cp[2] = cp[0];
- cp[0] = t;
- tp += 3;
- }
-}
-#endif
-
-#if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabArrayOfLong)
-void TIFFSwabArrayOfLong(register uint32_t *lp, tmsize_t n)
-{
- register unsigned char *cp;
- register unsigned char t;
- assert(sizeof(uint32_t) == 4);
- /* XXX unroll loop some */
- while (n-- > 0)
- {
- cp = (unsigned char *)lp;
- t = cp[3];
- cp[3] = cp[0];
- cp[0] = t;
- t = cp[2];
- cp[2] = cp[1];
- cp[1] = t;
- lp++;
- }
-}
-#endif
-
-#if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabArrayOfLong8)
-void TIFFSwabArrayOfLong8(register uint64_t *lp, tmsize_t n)
-{
- register unsigned char *cp;
- register unsigned char t;
- assert(sizeof(uint64_t) == 8);
- /* XXX unroll loop some */
- while (n-- > 0)
- {
- cp = (unsigned char *)lp;
- t = cp[7];
- cp[7] = cp[0];
- cp[0] = t;
- t = cp[6];
- cp[6] = cp[1];
- cp[1] = t;
- t = cp[5];
- cp[5] = cp[2];
- cp[2] = t;
- t = cp[4];
- cp[4] = cp[3];
- cp[3] = t;
- lp++;
- }
-}
-#endif
-
-#if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabFloat)
-void TIFFSwabFloat(float *fp)
-{
- register unsigned char *cp = (unsigned char *)fp;
- unsigned char t;
- assert(sizeof(float) == 4);
- t = cp[3];
- cp[3] = cp[0];
- cp[0] = t;
- t = cp[2];
- cp[2] = cp[1];
- cp[1] = t;
-}
-#endif
-
-#if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabArrayOfFloat)
-void TIFFSwabArrayOfFloat(register float *fp, tmsize_t n)
-{
- register unsigned char *cp;
- register unsigned char t;
- assert(sizeof(float) == 4);
- /* XXX unroll loop some */
- while (n-- > 0)
- {
- cp = (unsigned char *)fp;
- t = cp[3];
- cp[3] = cp[0];
- cp[0] = t;
- t = cp[2];
- cp[2] = cp[1];
- cp[1] = t;
- fp++;
- }
-}
-#endif
-
-#if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabDouble)
-void TIFFSwabDouble(double *dp)
-{
- register unsigned char *cp = (unsigned char *)dp;
- unsigned char t;
- assert(sizeof(double) == 8);
- t = cp[7];
- cp[7] = cp[0];
- cp[0] = t;
- t = cp[6];
- cp[6] = cp[1];
- cp[1] = t;
- t = cp[5];
- cp[5] = cp[2];
- cp[2] = t;
- t = cp[4];
- cp[4] = cp[3];
- cp[3] = t;
-}
-#endif
-
-#if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabArrayOfDouble)
-void TIFFSwabArrayOfDouble(double *dp, tmsize_t n)
-{
- register unsigned char *cp;
- register unsigned char t;
- assert(sizeof(double) == 8);
- /* XXX unroll loop some */
- while (n-- > 0)
- {
- cp = (unsigned char *)dp;
- t = cp[7];
- cp[7] = cp[0];
- cp[0] = t;
- t = cp[6];
- cp[6] = cp[1];
- cp[1] = t;
- t = cp[5];
- cp[5] = cp[2];
- cp[2] = t;
- t = cp[4];
- cp[4] = cp[3];
- cp[3] = t;
- dp++;
- }
-}
-#endif
-
-/*
- * Bit reversal tables. TIFFBitRevTable[<byte>] gives
- * the bit reversed value of <byte>. Used in various
- * places in the library when the FillOrder requires
- * bit reversal of byte values (e.g. CCITT Fax 3
- * encoding/decoding). TIFFNoBitRevTable is provided
- * for algorithms that want an equivalent table that
- * do not reverse bit values.
- */
-static const unsigned char TIFFBitRevTable[256] = {
- 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x10, 0x90, 0x50, 0xd0,
- 0x30, 0xb0, 0x70, 0xf0, 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
- 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, 0x04, 0x84, 0x44, 0xc4,
- 0x24, 0xa4, 0x64, 0xe4, 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
- 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, 0x1c, 0x9c, 0x5c, 0xdc,
- 0x3c, 0xbc, 0x7c, 0xfc, 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
- 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, 0x0a, 0x8a, 0x4a, 0xca,
- 0x2a, 0xaa, 0x6a, 0xea, 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
- 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, 0x16, 0x96, 0x56, 0xd6,
- 0x36, 0xb6, 0x76, 0xf6, 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
- 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, 0x01, 0x81, 0x41, 0xc1,
- 0x21, 0xa1, 0x61, 0xe1, 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
- 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, 0x19, 0x99, 0x59, 0xd9,
- 0x39, 0xb9, 0x79, 0xf9, 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
- 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, 0x0d, 0x8d, 0x4d, 0xcd,
- 0x2d, 0xad, 0x6d, 0xed, 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
- 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, 0x13, 0x93, 0x53, 0xd3,
- 0x33, 0xb3, 0x73, 0xf3, 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
- 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, 0x07, 0x87, 0x47, 0xc7,
- 0x27, 0xa7, 0x67, 0xe7, 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
- 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, 0x1f, 0x9f, 0x5f, 0xdf,
- 0x3f, 0xbf, 0x7f, 0xff};
-static const unsigned char TIFFNoBitRevTable[256] = {
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
- 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
- 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23,
- 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
- 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b,
- 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
- 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53,
- 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
- 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b,
- 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
- 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83,
- 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
- 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b,
- 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
- 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3,
- 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
- 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb,
- 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
- 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3,
- 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
- 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb,
- 0xfc, 0xfd, 0xfe, 0xff,
-};
-
-const unsigned char *TIFFGetBitRevTable(int reversed)
-{
- return (reversed ? TIFFBitRevTable : TIFFNoBitRevTable);
-}
-
-void TIFFReverseBits(uint8_t *cp, tmsize_t n)
-{
- for (; n > 8; n -= 8)
- {
- cp[0] = TIFFBitRevTable[cp[0]];
- cp[1] = TIFFBitRevTable[cp[1]];
- cp[2] = TIFFBitRevTable[cp[2]];
- cp[3] = TIFFBitRevTable[cp[3]];
- cp[4] = TIFFBitRevTable[cp[4]];
- cp[5] = TIFFBitRevTable[cp[5]];
- cp[6] = TIFFBitRevTable[cp[6]];
- cp[7] = TIFFBitRevTable[cp[7]];
- cp += 8;
- }
- while (n-- > 0)
- {
- *cp = TIFFBitRevTable[*cp];
- cp++;
- }
-}
diff --git a/contrib/libs/libtiff/tif_thunder.c b/contrib/libs/libtiff/tif_thunder.c
deleted file mode 100644
index bac0607dbe..0000000000
--- a/contrib/libs/libtiff/tif_thunder.c
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * Copyright (c) 1988-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-#include "tiffiop.h"
-#include <assert.h>
-#ifdef THUNDER_SUPPORT
-/*
- * TIFF Library.
- *
- * ThunderScan 4-bit Compression Algorithm Support
- */
-
-/*
- * ThunderScan uses an encoding scheme designed for
- * 4-bit pixel values. Data is encoded in bytes, with
- * each byte split into a 2-bit code word and a 6-bit
- * data value. The encoding gives raw data, runs of
- * pixels, or pixel values encoded as a delta from the
- * previous pixel value. For the latter, either 2-bit
- * or 3-bit delta values are used, with the deltas packed
- * into a single byte.
- */
-#define THUNDER_DATA 0x3f /* mask for 6-bit data */
-#define THUNDER_CODE 0xc0 /* mask for 2-bit code word */
-/* code values */
-#define THUNDER_RUN 0x00 /* run of pixels w/ encoded count */
-#define THUNDER_2BITDELTAS 0x40 /* 3 pixels w/ encoded 2-bit deltas */
-#define DELTA2_SKIP 2 /* skip code for 2-bit deltas */
-#define THUNDER_3BITDELTAS 0x80 /* 2 pixels w/ encoded 3-bit deltas */
-#define DELTA3_SKIP 4 /* skip code for 3-bit deltas */
-#define THUNDER_RAW 0xc0 /* raw data encoded */
-
-static const int twobitdeltas[4] = {0, 1, 0, -1};
-static const int threebitdeltas[8] = {0, 1, 2, 3, 0, -3, -2, -1};
-
-#define SETPIXEL(op, v) \
- { \
- lastpixel = (v)&0xf; \
- if (npixels < maxpixels) \
- { \
- if (npixels++ & 1) \
- *op++ |= lastpixel; \
- else \
- op[0] = (uint8_t)(lastpixel << 4); \
- } \
- }
-
-static int ThunderSetupDecode(TIFF *tif)
-{
- static const char module[] = "ThunderSetupDecode";
-
- if (tif->tif_dir.td_bitspersample != 4)
- {
- TIFFErrorExtR(tif, module,
- "Wrong bitspersample value (%d), Thunder decoder only "
- "supports 4bits per sample.",
- (int)tif->tif_dir.td_bitspersample);
- return 0;
- }
-
- return (1);
-}
-
-static int ThunderDecode(TIFF *tif, uint8_t *op0, tmsize_t maxpixels)
-{
- static const char module[] = "ThunderDecode";
- register unsigned char *bp;
- register tmsize_t cc;
- unsigned int lastpixel;
- tmsize_t npixels;
- uint8_t *op = op0;
-
- bp = (unsigned char *)tif->tif_rawcp;
- cc = tif->tif_rawcc;
- lastpixel = 0;
- npixels = 0;
- while (cc > 0 && npixels < maxpixels)
- {
- int n, delta;
-
- n = *bp++;
- cc--;
- switch (n & THUNDER_CODE)
- {
- case THUNDER_RUN: /* pixel run */
- /*
- * Replicate the last pixel n times,
- * where n is the lower-order 6 bits.
- */
- if (n == 0)
- break;
- if (npixels & 1)
- {
- op[0] |= lastpixel;
- lastpixel = *op++;
- npixels++;
- n--;
- }
- else
- lastpixel |= lastpixel << 4;
- npixels += n;
- if (npixels > maxpixels)
- break;
- for (; n > 0; n -= 2)
- *op++ = (uint8_t)lastpixel;
- if (n == -1)
- *--op &= 0xf0;
- lastpixel &= 0xf;
- break;
- case THUNDER_2BITDELTAS: /* 2-bit deltas */
- if ((delta = ((n >> 4) & 3)) != DELTA2_SKIP)
- SETPIXEL(op,
- (unsigned)((int)lastpixel + twobitdeltas[delta]));
- if ((delta = ((n >> 2) & 3)) != DELTA2_SKIP)
- SETPIXEL(op,
- (unsigned)((int)lastpixel + twobitdeltas[delta]));
- if ((delta = (n & 3)) != DELTA2_SKIP)
- SETPIXEL(op,
- (unsigned)((int)lastpixel + twobitdeltas[delta]));
- break;
- case THUNDER_3BITDELTAS: /* 3-bit deltas */
- if ((delta = ((n >> 3) & 7)) != DELTA3_SKIP)
- SETPIXEL(
- op, (unsigned)((int)lastpixel + threebitdeltas[delta]));
- if ((delta = (n & 7)) != DELTA3_SKIP)
- SETPIXEL(
- op, (unsigned)((int)lastpixel + threebitdeltas[delta]));
- break;
- case THUNDER_RAW: /* raw data */
- SETPIXEL(op, n);
- break;
- }
- }
- tif->tif_rawcp = (uint8_t *)bp;
- tif->tif_rawcc = cc;
- if (npixels != maxpixels)
- {
- uint8_t *op_end = op0 + (maxpixels + 1) / 2;
- memset(op, 0, (size_t)(op_end - op));
- TIFFErrorExtR(tif, module,
- "%s data at scanline %lu (%" PRIu64 " != %" PRIu64 ")",
- npixels < maxpixels ? "Not enough" : "Too much",
- (unsigned long)tif->tif_row, (uint64_t)npixels,
- (uint64_t)maxpixels);
- return (0);
- }
-
- return (1);
-}
-
-static int ThunderDecodeRow(TIFF *tif, uint8_t *buf, tmsize_t occ, uint16_t s)
-{
- static const char module[] = "ThunderDecodeRow";
- uint8_t *row = buf;
-
- (void)s;
- if (occ % tif->tif_scanlinesize)
- {
- TIFFErrorExtR(tif, module, "Fractional scanlines cannot be read");
- return (0);
- }
- while (occ > 0)
- {
- if (!ThunderDecode(tif, row, tif->tif_dir.td_imagewidth))
- return (0);
- occ -= tif->tif_scanlinesize;
- row += tif->tif_scanlinesize;
- }
- return (1);
-}
-
-int TIFFInitThunderScan(TIFF *tif, int scheme)
-{
- (void)scheme;
-
- tif->tif_setupdecode = ThunderSetupDecode;
- tif->tif_decoderow = ThunderDecodeRow;
- tif->tif_decodestrip = ThunderDecodeRow;
- return (1);
-}
-#endif /* THUNDER_SUPPORT */
diff --git a/contrib/libs/libtiff/tif_tile.c b/contrib/libs/libtiff/tif_tile.c
deleted file mode 100644
index f07032f731..0000000000
--- a/contrib/libs/libtiff/tif_tile.c
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- * Copyright (c) 1991-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-/*
- * TIFF Library.
- *
- * Tiled Image Support Routines.
- */
-#include "tiffiop.h"
-
-/*
- * Compute which tile an (x,y,z,s) value is in.
- */
-uint32_t TIFFComputeTile(TIFF *tif, uint32_t x, uint32_t y, uint32_t z,
- uint16_t s)
-{
- TIFFDirectory *td = &tif->tif_dir;
- uint32_t dx = td->td_tilewidth;
- uint32_t dy = td->td_tilelength;
- uint32_t dz = td->td_tiledepth;
- uint32_t tile = 1;
-
- if (td->td_imagedepth == 1)
- z = 0;
- if (dx == (uint32_t)-1)
- dx = td->td_imagewidth;
- if (dy == (uint32_t)-1)
- dy = td->td_imagelength;
- if (dz == (uint32_t)-1)
- dz = td->td_imagedepth;
- if (dx != 0 && dy != 0 && dz != 0)
- {
- uint32_t xpt = TIFFhowmany_32(td->td_imagewidth, dx);
- uint32_t ypt = TIFFhowmany_32(td->td_imagelength, dy);
- uint32_t zpt = TIFFhowmany_32(td->td_imagedepth, dz);
-
- if (td->td_planarconfig == PLANARCONFIG_SEPARATE)
- tile = (xpt * ypt * zpt) * s + (xpt * ypt) * (z / dz) +
- xpt * (y / dy) + x / dx;
- else
- tile = (xpt * ypt) * (z / dz) + xpt * (y / dy) + x / dx;
- }
- return (tile);
-}
-
-/*
- * Check an (x,y,z,s) coordinate
- * against the image bounds.
- */
-int TIFFCheckTile(TIFF *tif, uint32_t x, uint32_t y, uint32_t z, uint16_t s)
-{
- TIFFDirectory *td = &tif->tif_dir;
-
- if (x >= td->td_imagewidth)
- {
- TIFFErrorExtR(tif, tif->tif_name, "%lu: Col out of range, max %lu",
- (unsigned long)x, (unsigned long)(td->td_imagewidth - 1));
- return (0);
- }
- if (y >= td->td_imagelength)
- {
- TIFFErrorExtR(tif, tif->tif_name, "%lu: Row out of range, max %lu",
- (unsigned long)y,
- (unsigned long)(td->td_imagelength - 1));
- return (0);
- }
- if (z >= td->td_imagedepth)
- {
- TIFFErrorExtR(tif, tif->tif_name, "%lu: Depth out of range, max %lu",
- (unsigned long)z, (unsigned long)(td->td_imagedepth - 1));
- return (0);
- }
- if (td->td_planarconfig == PLANARCONFIG_SEPARATE &&
- s >= td->td_samplesperpixel)
- {
- TIFFErrorExtR(tif, tif->tif_name, "%lu: Sample out of range, max %lu",
- (unsigned long)s,
- (unsigned long)(td->td_samplesperpixel - 1));
- return (0);
- }
- return (1);
-}
-
-/*
- * Compute how many tiles are in an image.
- */
-uint32_t TIFFNumberOfTiles(TIFF *tif)
-{
- TIFFDirectory *td = &tif->tif_dir;
- uint32_t dx = td->td_tilewidth;
- uint32_t dy = td->td_tilelength;
- uint32_t dz = td->td_tiledepth;
- uint32_t ntiles;
-
- if (dx == (uint32_t)-1)
- dx = td->td_imagewidth;
- if (dy == (uint32_t)-1)
- dy = td->td_imagelength;
- if (dz == (uint32_t)-1)
- dz = td->td_imagedepth;
- ntiles =
- (dx == 0 || dy == 0 || dz == 0)
- ? 0
- : _TIFFMultiply32(
- tif,
- _TIFFMultiply32(tif, TIFFhowmany_32(td->td_imagewidth, dx),
- TIFFhowmany_32(td->td_imagelength, dy),
- "TIFFNumberOfTiles"),
- TIFFhowmany_32(td->td_imagedepth, dz), "TIFFNumberOfTiles");
- if (td->td_planarconfig == PLANARCONFIG_SEPARATE)
- ntiles = _TIFFMultiply32(tif, ntiles, td->td_samplesperpixel,
- "TIFFNumberOfTiles");
- return (ntiles);
-}
-
-/*
- * Compute the # bytes in each row of a tile.
- */
-uint64_t TIFFTileRowSize64(TIFF *tif)
-{
- static const char module[] = "TIFFTileRowSize64";
- TIFFDirectory *td = &tif->tif_dir;
- uint64_t rowsize;
- uint64_t tilerowsize;
-
- if (td->td_tilelength == 0)
- {
- TIFFErrorExtR(tif, module, "Tile length is zero");
- return 0;
- }
- if (td->td_tilewidth == 0)
- {
- TIFFErrorExtR(tif, module, "Tile width is zero");
- return (0);
- }
- rowsize = _TIFFMultiply64(tif, td->td_bitspersample, td->td_tilewidth,
- "TIFFTileRowSize");
- if (td->td_planarconfig == PLANARCONFIG_CONTIG)
- {
- if (td->td_samplesperpixel == 0)
- {
- TIFFErrorExtR(tif, module, "Samples per pixel is zero");
- return 0;
- }
- rowsize = _TIFFMultiply64(tif, rowsize, td->td_samplesperpixel,
- "TIFFTileRowSize");
- }
- tilerowsize = TIFFhowmany8_64(rowsize);
- if (tilerowsize == 0)
- {
- TIFFErrorExtR(tif, module, "Computed tile row size is zero");
- return 0;
- }
- return (tilerowsize);
-}
-tmsize_t TIFFTileRowSize(TIFF *tif)
-{
- static const char module[] = "TIFFTileRowSize";
- uint64_t m;
- m = TIFFTileRowSize64(tif);
- return _TIFFCastUInt64ToSSize(tif, m, module);
-}
-
-/*
- * Compute the # bytes in a variable length, row-aligned tile.
- */
-uint64_t TIFFVTileSize64(TIFF *tif, uint32_t nrows)
-{
- static const char module[] = "TIFFVTileSize64";
- TIFFDirectory *td = &tif->tif_dir;
- if (td->td_tilelength == 0 || td->td_tilewidth == 0 ||
- td->td_tiledepth == 0)
- return (0);
- if ((td->td_planarconfig == PLANARCONFIG_CONTIG) &&
- (td->td_photometric == PHOTOMETRIC_YCBCR) &&
- (td->td_samplesperpixel == 3) && (!isUpSampled(tif)))
- {
- /*
- * Packed YCbCr data contain one Cb+Cr for every
- * HorizontalSampling*VerticalSampling Y values.
- * Must also roundup width and height when calculating
- * since images that are not a multiple of the
- * horizontal/vertical subsampling area include
- * YCbCr data for the extended image.
- */
- uint16_t ycbcrsubsampling[2];
- uint16_t samplingblock_samples;
- uint32_t samplingblocks_hor;
- uint32_t samplingblocks_ver;
- uint64_t samplingrow_samples;
- uint64_t samplingrow_size;
- TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRSUBSAMPLING,
- ycbcrsubsampling + 0, ycbcrsubsampling + 1);
- if ((ycbcrsubsampling[0] != 1 && ycbcrsubsampling[0] != 2 &&
- ycbcrsubsampling[0] != 4) ||
- (ycbcrsubsampling[1] != 1 && ycbcrsubsampling[1] != 2 &&
- ycbcrsubsampling[1] != 4))
- {
- TIFFErrorExtR(tif, module, "Invalid YCbCr subsampling (%dx%d)",
- ycbcrsubsampling[0], ycbcrsubsampling[1]);
- return 0;
- }
- samplingblock_samples = ycbcrsubsampling[0] * ycbcrsubsampling[1] + 2;
- samplingblocks_hor =
- TIFFhowmany_32(td->td_tilewidth, ycbcrsubsampling[0]);
- samplingblocks_ver = TIFFhowmany_32(nrows, ycbcrsubsampling[1]);
- samplingrow_samples = _TIFFMultiply64(tif, samplingblocks_hor,
- samplingblock_samples, module);
- samplingrow_size = TIFFhowmany8_64(_TIFFMultiply64(
- tif, samplingrow_samples, td->td_bitspersample, module));
- return (
- _TIFFMultiply64(tif, samplingrow_size, samplingblocks_ver, module));
- }
- else
- return (_TIFFMultiply64(tif, nrows, TIFFTileRowSize64(tif), module));
-}
-tmsize_t TIFFVTileSize(TIFF *tif, uint32_t nrows)
-{
- static const char module[] = "TIFFVTileSize";
- uint64_t m;
- m = TIFFVTileSize64(tif, nrows);
- return _TIFFCastUInt64ToSSize(tif, m, module);
-}
-
-/*
- * Compute the # bytes in a row-aligned tile.
- */
-uint64_t TIFFTileSize64(TIFF *tif)
-{
- return (TIFFVTileSize64(tif, tif->tif_dir.td_tilelength));
-}
-tmsize_t TIFFTileSize(TIFF *tif)
-{
- static const char module[] = "TIFFTileSize";
- uint64_t m;
- m = TIFFTileSize64(tif);
- return _TIFFCastUInt64ToSSize(tif, m, module);
-}
-
-/*
- * Compute a default tile size based on the image
- * characteristics and a requested value. If a
- * request is <1 then we choose a size according
- * to certain heuristics.
- */
-void TIFFDefaultTileSize(TIFF *tif, uint32_t *tw, uint32_t *th)
-{
- (*tif->tif_deftilesize)(tif, tw, th);
-}
-
-void _TIFFDefaultTileSize(TIFF *tif, uint32_t *tw, uint32_t *th)
-{
- (void)tif;
- if (*(int32_t *)tw < 1)
- *tw = 256;
- if (*(int32_t *)th < 1)
- *th = 256;
- /* roundup to a multiple of 16 per the spec */
- if (*tw & 0xf)
- *tw = TIFFroundup_32(*tw, 16);
- if (*th & 0xf)
- *th = TIFFroundup_32(*th, 16);
-}
diff --git a/contrib/libs/libtiff/tif_unix.c b/contrib/libs/libtiff/tif_unix.c
deleted file mode 100644
index e65da872a3..0000000000
--- a/contrib/libs/libtiff/tif_unix.c
+++ /dev/null
@@ -1,378 +0,0 @@
-/*
- * Copyright (c) 1988-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-/*
- * TIFF Library UNIX-specific Routines. These are should also work with the
- * Windows Common RunTime Library.
- */
-
-#ifdef TIFF_DO_NOT_USE_NON_EXT_ALLOC_FUNCTIONS
-#undef TIFF_DO_NOT_USE_NON_EXT_ALLOC_FUNCTIONS
-#endif
-
-#include "tif_config.h"
-
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
-#include <errno.h>
-
-#include <stdarg.h>
-#include <stdlib.h>
-#include <sys/stat.h>
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
-#ifdef HAVE_IO_H
-#include <io.h>
-#endif
-
-#include "tiffiop.h"
-
-#define TIFF_IO_MAX 2147483647U
-
-typedef union fd_as_handle_union
-{
- int fd;
- thandle_t h;
-} fd_as_handle_union_t;
-
-static tmsize_t _tiffReadProc(thandle_t fd, void *buf, tmsize_t size)
-{
- fd_as_handle_union_t fdh;
- const size_t bytes_total = (size_t)size;
- size_t bytes_read;
- tmsize_t count = -1;
- if ((tmsize_t)bytes_total != size)
- {
- errno = EINVAL;
- return (tmsize_t)-1;
- }
- fdh.h = fd;
- for (bytes_read = 0; bytes_read < bytes_total; bytes_read += count)
- {
- char *buf_offset = (char *)buf + bytes_read;
- size_t io_size = bytes_total - bytes_read;
- if (io_size > TIFF_IO_MAX)
- io_size = TIFF_IO_MAX;
- /* Below is an obvious false positive of Coverity Scan */
- /* coverity[overflow_sink] */
- count = read(fdh.fd, buf_offset, (TIFFIOSize_t)io_size);
- if (count <= 0)
- break;
- }
- if (count < 0)
- return (tmsize_t)-1;
- return (tmsize_t)bytes_read;
-}
-
-static tmsize_t _tiffWriteProc(thandle_t fd, void *buf, tmsize_t size)
-{
- fd_as_handle_union_t fdh;
- const size_t bytes_total = (size_t)size;
- size_t bytes_written;
- tmsize_t count = -1;
- if ((tmsize_t)bytes_total != size)
- {
- errno = EINVAL;
- return (tmsize_t)-1;
- }
- fdh.h = fd;
- for (bytes_written = 0; bytes_written < bytes_total; bytes_written += count)
- {
- const char *buf_offset = (char *)buf + bytes_written;
- size_t io_size = bytes_total - bytes_written;
- if (io_size > TIFF_IO_MAX)
- io_size = TIFF_IO_MAX;
- /* Below is an obvious false positive of Coverity Scan */
- /* coverity[overflow_sink] */
- count = write(fdh.fd, buf_offset, (TIFFIOSize_t)io_size);
- if (count <= 0)
- break;
- }
- if (count < 0)
- return (tmsize_t)-1;
- return (tmsize_t)bytes_written;
- /* return ((tmsize_t) write(fdh.fd, buf, bytes_total)); */
-}
-
-static uint64_t _tiffSeekProc(thandle_t fd, uint64_t off, int whence)
-{
- fd_as_handle_union_t fdh;
- _TIFF_off_t off_io = (_TIFF_off_t)off;
- if ((uint64_t)off_io != off)
- {
- errno = EINVAL;
- return (uint64_t)-1; /* this is really gross */
- }
- fdh.h = fd;
- return ((uint64_t)_TIFF_lseek_f(fdh.fd, off_io, whence));
-}
-
-static int _tiffCloseProc(thandle_t fd)
-{
- fd_as_handle_union_t fdh;
- fdh.h = fd;
- return (close(fdh.fd));
-}
-
-static uint64_t _tiffSizeProc(thandle_t fd)
-{
- _TIFF_stat_s sb;
- fd_as_handle_union_t fdh;
- fdh.h = fd;
- if (_TIFF_fstat_f(fdh.fd, &sb) < 0)
- return (0);
- else
- return ((uint64_t)sb.st_size);
-}
-
-#ifdef HAVE_MMAP
-#include <sys/mman.h>
-
-static int _tiffMapProc(thandle_t fd, void **pbase, toff_t *psize)
-{
- uint64_t size64 = _tiffSizeProc(fd);
- tmsize_t sizem = (tmsize_t)size64;
- if (size64 && (uint64_t)sizem == size64)
- {
- fd_as_handle_union_t fdh;
- fdh.h = fd;
- *pbase =
- (void *)mmap(0, (size_t)sizem, PROT_READ, MAP_SHARED, fdh.fd, 0);
- if (*pbase != (void *)-1)
- {
- *psize = (tmsize_t)sizem;
- return (1);
- }
- }
- return (0);
-}
-
-static void _tiffUnmapProc(thandle_t fd, void *base, toff_t size)
-{
- (void)fd;
- (void)munmap(base, (off_t)size);
-}
-#else /* !HAVE_MMAP */
-static int _tiffMapProc(thandle_t fd, void **pbase, toff_t *psize)
-{
- (void)fd;
- (void)pbase;
- (void)psize;
- return (0);
-}
-
-static void _tiffUnmapProc(thandle_t fd, void *base, toff_t size)
-{
- (void)fd;
- (void)base;
- (void)size;
-}
-#endif /* !HAVE_MMAP */
-
-/*
- * Open a TIFF file descriptor for read/writing.
- */
-TIFF *TIFFFdOpen(int fd, const char *name, const char *mode)
-{
- return TIFFFdOpenExt(fd, name, mode, NULL);
-}
-
-TIFF *TIFFFdOpenExt(int fd, const char *name, const char *mode,
- TIFFOpenOptions *opts)
-{
- TIFF *tif;
-
- fd_as_handle_union_t fdh;
- fdh.fd = fd;
- tif = TIFFClientOpenExt(name, mode, fdh.h, _tiffReadProc, _tiffWriteProc,
- _tiffSeekProc, _tiffCloseProc, _tiffSizeProc,
- _tiffMapProc, _tiffUnmapProc, opts);
- if (tif)
- tif->tif_fd = fd;
- return (tif);
-}
-
-/*
- * Open a TIFF file for read/writing.
- */
-TIFF *TIFFOpen(const char *name, const char *mode)
-{
- return TIFFOpenExt(name, mode, NULL);
-}
-
-TIFF *TIFFOpenExt(const char *name, const char *mode, TIFFOpenOptions *opts)
-{
- static const char module[] = "TIFFOpen";
- int m, fd;
- TIFF *tif;
-
- m = _TIFFgetMode(opts, NULL, mode, module);
- if (m == -1)
- return ((TIFF *)0);
-
-/* for cygwin and mingw */
-#ifdef O_BINARY
- m |= O_BINARY;
-#endif
-
- fd = open(name, m, 0666);
- if (fd < 0)
- {
- if (errno > 0 && strerror(errno) != NULL)
- {
- _TIFFErrorEarly(opts, NULL, module, "%s: %s", name,
- strerror(errno));
- }
- else
- {
- _TIFFErrorEarly(opts, NULL, module, "%s: Cannot open", name);
- }
- return ((TIFF *)0);
- }
-
- tif = TIFFFdOpenExt((int)fd, name, mode, opts);
- if (!tif)
- close(fd);
- return tif;
-}
-
-#ifdef _WIN32
-#include <windows.h>
-/*
- * Open a TIFF file with a Unicode filename, for read/writing.
- */
-TIFF *TIFFOpenW(const wchar_t *name, const char *mode)
-{
- return TIFFOpenWExt(name, mode, NULL);
-}
-TIFF *TIFFOpenWExt(const wchar_t *name, const char *mode, TIFFOpenOptions *opts)
-{
- static const char module[] = "TIFFOpenW";
- int m, fd;
- int mbsize;
- char *mbname;
- TIFF *tif;
-
- m = _TIFFgetMode(opts, NULL, mode, module);
- if (m == -1)
- return ((TIFF *)0);
-
-/* for cygwin and mingw */
-#ifdef O_BINARY
- m |= O_BINARY;
-#endif
-
- fd = _wopen(name, m, 0666);
- if (fd < 0)
- {
- _TIFFErrorEarly(opts, NULL, module, "%ls: Cannot open", name);
- return ((TIFF *)0);
- }
-
- mbname = NULL;
- mbsize = WideCharToMultiByte(CP_ACP, 0, name, -1, NULL, 0, NULL, NULL);
- if (mbsize > 0)
- {
- mbname = _TIFFmalloc(mbsize);
- if (!mbname)
- {
- _TIFFErrorEarly(
- opts, NULL, module,
- "Can't allocate space for filename conversion buffer");
- return ((TIFF *)0);
- }
-
- WideCharToMultiByte(CP_ACP, 0, name, -1, mbname, mbsize, NULL, NULL);
- }
-
- tif = TIFFFdOpenExt((int)fd, (mbname != NULL) ? mbname : "<unknown>", mode,
- opts);
-
- _TIFFfree(mbname);
-
- if (!tif)
- close(fd);
- return tif;
-}
-#endif
-
-void *_TIFFmalloc(tmsize_t s)
-{
- if (s == 0)
- return ((void *)NULL);
-
- return (malloc((size_t)s));
-}
-
-void *_TIFFcalloc(tmsize_t nmemb, tmsize_t siz)
-{
- if (nmemb == 0 || siz == 0)
- return ((void *)NULL);
-
- return calloc((size_t)nmemb, (size_t)siz);
-}
-
-void _TIFFfree(void *p) { free(p); }
-
-void *_TIFFrealloc(void *p, tmsize_t s) { return (realloc(p, (size_t)s)); }
-
-void _TIFFmemset(void *p, int v, tmsize_t c) { memset(p, v, (size_t)c); }
-
-void _TIFFmemcpy(void *d, const void *s, tmsize_t c)
-{
- memcpy(d, s, (size_t)c);
-}
-
-int _TIFFmemcmp(const void *p1, const void *p2, tmsize_t c)
-{
- return (memcmp(p1, p2, (size_t)c));
-}
-
-static void unixWarningHandler(const char *module, const char *fmt, va_list ap)
-{
- if (module != NULL)
- fprintf(stderr, "%s: ", module);
- fprintf(stderr, "Warning, ");
- vfprintf(stderr, fmt, ap);
- fprintf(stderr, ".\n");
-}
-TIFFErrorHandler _TIFFwarningHandler = unixWarningHandler;
-
-static void unixErrorHandler(const char *module, const char *fmt, va_list ap)
-{
- if (module != NULL)
- fprintf(stderr, "%s: ", module);
- vfprintf(stderr, fmt, ap);
- fprintf(stderr, ".\n");
-}
-TIFFErrorHandler _TIFFerrorHandler = unixErrorHandler;
diff --git a/contrib/libs/libtiff/tif_version.c b/contrib/libs/libtiff/tif_version.c
deleted file mode 100644
index 0b6c9bc00a..0000000000
--- a/contrib/libs/libtiff/tif_version.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 1992-1997 Sam Leffler
- * Copyright (c) 1992-1997 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-#include "tiffiop.h"
-
-static const char TIFFVersion[] = TIFFLIB_VERSION_STR;
-
-const char *TIFFGetVersion(void) { return (TIFFVersion); }
diff --git a/contrib/libs/libtiff/tif_warning.c b/contrib/libs/libtiff/tif_warning.c
deleted file mode 100644
index 5468de55f2..0000000000
--- a/contrib/libs/libtiff/tif_warning.c
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (c) 1988-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-/*
- * TIFF Library.
- */
-#include "tiffiop.h"
-
-TIFFErrorHandlerExt _TIFFwarningHandlerExt = NULL;
-
-TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler handler)
-{
- TIFFErrorHandler prev = _TIFFwarningHandler;
- _TIFFwarningHandler = handler;
- return (prev);
-}
-
-TIFFErrorHandlerExt TIFFSetWarningHandlerExt(TIFFErrorHandlerExt handler)
-{
- TIFFErrorHandlerExt prev = _TIFFwarningHandlerExt;
- _TIFFwarningHandlerExt = handler;
- return (prev);
-}
-
-void TIFFWarning(const char *module, const char *fmt, ...)
-{
- va_list ap;
- if (_TIFFwarningHandler)
- {
- va_start(ap, fmt);
- (*_TIFFwarningHandler)(module, fmt, ap);
- va_end(ap);
- }
- if (_TIFFwarningHandlerExt)
- {
- va_start(ap, fmt);
- (*_TIFFwarningHandlerExt)(0, module, fmt, ap);
- va_end(ap);
- }
-}
-
-void TIFFWarningExt(thandle_t fd, const char *module, const char *fmt, ...)
-{
- va_list ap;
- if (_TIFFwarningHandler)
- {
- va_start(ap, fmt);
- (*_TIFFwarningHandler)(module, fmt, ap);
- va_end(ap);
- }
- if (_TIFFwarningHandlerExt)
- {
- va_start(ap, fmt);
- (*_TIFFwarningHandlerExt)(fd, module, fmt, ap);
- va_end(ap);
- }
-}
-
-void TIFFWarningExtR(TIFF *tif, const char *module, const char *fmt, ...)
-{
- va_list ap;
- if (tif && tif->tif_warnhandler)
- {
- va_start(ap, fmt);
- int stop = (*tif->tif_warnhandler)(tif, tif->tif_warnhandler_user_data,
- module, fmt, ap);
- va_end(ap);
- if (stop)
- return;
- }
- if (_TIFFwarningHandler)
- {
- va_start(ap, fmt);
- (*_TIFFwarningHandler)(module, fmt, ap);
- va_end(ap);
- }
- if (_TIFFwarningHandlerExt)
- {
- va_start(ap, fmt);
- (*_TIFFwarningHandlerExt)(tif ? tif->tif_clientdata : 0, module, fmt,
- ap);
- va_end(ap);
- }
-}
diff --git a/contrib/libs/libtiff/tif_webp.c b/contrib/libs/libtiff/tif_webp.c
deleted file mode 100644
index ccffef0703..0000000000
--- a/contrib/libs/libtiff/tif_webp.c
+++ /dev/null
@@ -1,919 +0,0 @@
-/*
- * Copyright (c) 2018, Mapbox
- * Author: <norman.barker at mapbox.com>
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-#include "tiffiop.h"
-#ifdef WEBP_SUPPORT
-/*
- * TIFF Library.
- *
- * WEBP Compression Support
- *
- */
-
-#include "webp/decode.h"
-#include "webp/encode.h"
-
-#include <stdbool.h>
-#include <stdio.h>
-
-#define LSTATE_INIT_DECODE 0x01
-#define LSTATE_INIT_ENCODE 0x02
-/*
- * State block for each open TIFF
- * file using WEBP compression/decompression.
- */
-typedef struct
-{
- uint16_t nSamples; /* number of samples per pixel */
-
- int read_error; /* whether a read error has occurred, and which should cause
- further reads in the same strip/tile to be aborted */
- int lossless; /* lossy/lossless compression */
- int lossless_exact; /* lossless exact mode. If TRUE, R,G,B values in areas
- with alpha = 0 will be preserved */
- int quality_level; /* compression level */
- WebPPicture sPicture; /* WebP Picture */
- WebPConfig sEncoderConfig; /* WebP encoder config */
- uint8_t *pBuffer; /* buffer to hold raw data on encoding */
- unsigned int buffer_offset; /* current offset into the buffer */
- unsigned int buffer_size;
-
- WebPIDecoder *psDecoder; /* WebPIDecoder */
- WebPDecBuffer sDecBuffer; /* Decoder buffer */
- int last_y; /* Last row decoded */
-
- int state; /* state flags */
-
- TIFFVGetMethod vgetparent; /* super-class method */
- TIFFVSetMethod vsetparent; /* super-class method */
-} WebPState;
-
-#define LState(tif) ((WebPState *)(tif)->tif_data)
-#define DecoderState(tif) LState(tif)
-#define EncoderState(tif) LState(tif)
-
-static int TWebPEncode(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s);
-static int TWebPDecode(TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s);
-
-static int TWebPDatasetWriter(const uint8_t *data, size_t data_size,
- const WebPPicture *const picture)
-{
- static const char module[] = "TWebPDatasetWriter";
- TIFF *tif = (TIFF *)(picture->custom_ptr);
-
- if ((tif->tif_rawcc + (tmsize_t)data_size) > tif->tif_rawdatasize)
- {
- TIFFErrorExtR(
- tif, module, "Buffer too small by %" TIFF_SIZE_FORMAT " bytes.",
- (size_t)(tif->tif_rawcc + data_size - tif->tif_rawdatasize));
- return 0;
- }
- else
- {
- _TIFFmemcpy(tif->tif_rawcp, data, data_size);
- tif->tif_rawcc += data_size;
- tif->tif_rawcp += data_size;
- return 1;
- }
-}
-
-/*
- * Encode a chunk of pixels.
- */
-static int TWebPEncode(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s)
-{
- static const char module[] = "TWebPEncode";
- WebPState *sp = EncoderState(tif);
- (void)s;
-
- assert(sp != NULL);
- assert(sp->state == LSTATE_INIT_ENCODE);
-
- if ((uint64_t)sp->buffer_offset + (uint64_t)cc > sp->buffer_size)
- {
- TIFFErrorExtR(tif, module, "Too many bytes to be written");
- return 0;
- }
-
- memcpy(sp->pBuffer + sp->buffer_offset, bp, cc);
- sp->buffer_offset += (unsigned)cc;
-
- return 1;
-}
-
-static int TWebPDecode(TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s)
-{
- static const char module[] = "WebPDecode";
- VP8StatusCode status = VP8_STATUS_OK;
- WebPState *sp = DecoderState(tif);
- uint32_t segment_width, segment_height;
- bool decode_whole_strile = false;
-
- (void)s;
-
- assert(sp != NULL);
- assert(sp->state == LSTATE_INIT_DECODE);
-
- if (sp->read_error)
- {
- memset(op, 0, (size_t)occ);
- TIFFErrorExtR(tif, module,
- "ZIPDecode: Scanline %" PRIu32 " cannot be read due to "
- "previous error",
- tif->tif_row);
- return 0;
- }
-
- if (sp->psDecoder == NULL)
- {
- TIFFDirectory *td = &tif->tif_dir;
- uint32_t buffer_size;
-
- if (isTiled(tif))
- {
- segment_width = td->td_tilewidth;
- segment_height = td->td_tilelength;
- }
- else
- {
- segment_width = td->td_imagewidth;
- segment_height = td->td_imagelength - tif->tif_row;
- if (segment_height > td->td_rowsperstrip)
- segment_height = td->td_rowsperstrip;
- }
-
- int webp_width, webp_height;
- if (!WebPGetInfo(tif->tif_rawcp,
- (uint64_t)tif->tif_rawcc > UINT32_MAX
- ? UINT32_MAX
- : (uint32_t)tif->tif_rawcc,
- &webp_width, &webp_height))
- {
- memset(op, 0, (size_t)occ);
- sp->read_error = 1;
- TIFFErrorExtR(tif, module, "WebPGetInfo() failed");
- return 0;
- }
- if ((uint32_t)webp_width != segment_width ||
- (uint32_t)webp_height != segment_height)
- {
- memset(op, 0, (size_t)occ);
- sp->read_error = 1;
- TIFFErrorExtR(
- tif, module, "WebP blob dimension is %dx%d. Expected %ux%u",
- webp_width, webp_height, segment_width, segment_height);
- return 0;
- }
-
-#if WEBP_DECODER_ABI_VERSION >= 0x0002
- WebPDecoderConfig config;
- if (!WebPInitDecoderConfig(&config))
- {
- memset(op, 0, (size_t)occ);
- sp->read_error = 1;
- TIFFErrorExtR(tif, module, "WebPInitDecoderConfig() failed");
- return 0;
- }
-
- const bool bWebPGetFeaturesOK =
- WebPGetFeatures(tif->tif_rawcp,
- (uint64_t)tif->tif_rawcc > UINT32_MAX
- ? UINT32_MAX
- : (uint32_t)tif->tif_rawcc,
- &config.input) == VP8_STATUS_OK;
-
- WebPFreeDecBuffer(&config.output);
-
- if (!bWebPGetFeaturesOK)
- {
- memset(op, 0, (size_t)occ);
- sp->read_error = 1;
- TIFFErrorExtR(tif, module, "WebPInitDecoderConfig() failed");
- return 0;
- }
-
- const int webp_bands = config.input.has_alpha ? 4 : 3;
- if (webp_bands != sp->nSamples &&
- /* We accept the situation where the WebP blob has only 3 bands,
- * whereas the raster is 4 bands. This can happen when the alpha
- * channel is fully opaque, and WebP decoding works fine in that
- * situation.
- */
- !(webp_bands == 3 && sp->nSamples == 4))
- {
- memset(op, 0, (size_t)occ);
- sp->read_error = 1;
- TIFFErrorExtR(tif, module,
- "WebP blob band count is %d. Expected %d", webp_bands,
- sp->nSamples);
- return 0;
- }
-#endif
-
- buffer_size = segment_width * segment_height * sp->nSamples;
- if (occ == (tmsize_t)buffer_size)
- {
- /* If decoding the whole strip/tile, we can directly use the */
- /* output buffer */
- decode_whole_strile = true;
- }
- else if (sp->pBuffer == NULL || buffer_size > sp->buffer_size)
- {
- if (sp->pBuffer != NULL)
- {
- _TIFFfreeExt(tif, sp->pBuffer);
- sp->pBuffer = NULL;
- }
-
- sp->pBuffer = _TIFFmallocExt(tif, buffer_size);
- if (!sp->pBuffer)
- {
- TIFFErrorExtR(tif, module, "Cannot allocate buffer");
- memset(op, 0, (size_t)occ);
- sp->read_error = 1;
- return 0;
- }
- sp->buffer_size = buffer_size;
- }
-
- sp->last_y = 0;
-
- WebPInitDecBuffer(&sp->sDecBuffer);
-
- sp->sDecBuffer.is_external_memory = 1;
- sp->sDecBuffer.width = segment_width;
- sp->sDecBuffer.height = segment_height;
- sp->sDecBuffer.u.RGBA.rgba = decode_whole_strile ? op : sp->pBuffer;
- sp->sDecBuffer.u.RGBA.stride = segment_width * sp->nSamples;
- sp->sDecBuffer.u.RGBA.size = buffer_size;
-
- if (sp->nSamples > 3)
- {
- sp->sDecBuffer.colorspace = MODE_RGBA;
- }
- else
- {
- sp->sDecBuffer.colorspace = MODE_RGB;
- }
-
- sp->psDecoder = WebPINewDecoder(&sp->sDecBuffer);
-
- if (sp->psDecoder == NULL)
- {
- memset(op, 0, (size_t)occ);
- sp->read_error = 1;
- TIFFErrorExtR(tif, module, "Unable to allocate WebP decoder.");
- return 0;
- }
- }
-
- if (occ % sp->sDecBuffer.u.RGBA.stride)
- {
- // read_error not set here as this is a usage issue that can be
- // recovered in a following call.
- memset(op, 0, (size_t)occ);
- /* Do not set read_error as could potentially be recovered */
- TIFFErrorExtR(tif, module, "Fractional scanlines cannot be read");
- return 0;
- }
-
- status = WebPIAppend(sp->psDecoder, tif->tif_rawcp, tif->tif_rawcc);
-
- if (status != VP8_STATUS_OK && status != VP8_STATUS_SUSPENDED)
- {
- if (status == VP8_STATUS_INVALID_PARAM)
- {
- TIFFErrorExtR(tif, module, "Invalid parameter used.");
- }
- else if (status == VP8_STATUS_OUT_OF_MEMORY)
- {
- TIFFErrorExtR(tif, module, "Out of memory.");
- }
- else
- {
- TIFFErrorExtR(tif, module, "Unrecognized error.");
- }
- memset(op, 0, (size_t)occ);
- sp->read_error = 1;
- return 0;
- }
- else
- {
- int current_y, stride;
- uint8_t *buf;
-
- /* Returns the RGB/A image decoded so far */
- buf = WebPIDecGetRGB(sp->psDecoder, &current_y, NULL, NULL, &stride);
-
- if ((buf != NULL) &&
- (occ <= (tmsize_t)stride * (current_y - sp->last_y)))
- {
- const int numberOfExpectedLines =
- (int)(occ / sp->sDecBuffer.u.RGBA.stride);
- if (decode_whole_strile)
- {
- if (current_y != numberOfExpectedLines)
- {
- memset(op, 0, (size_t)occ);
- sp->read_error = 1;
- TIFFErrorExtR(tif, module,
- "Unable to decode WebP data: less lines than "
- "expected.");
- return 0;
- }
- }
- else
- {
- memcpy(op, buf + (sp->last_y * stride), occ);
- }
-
- tif->tif_rawcp += tif->tif_rawcc;
- tif->tif_rawcc = 0;
- sp->last_y += numberOfExpectedLines;
-
- if (decode_whole_strile)
- {
- /* We can now free the decoder as we're completely done */
- if (sp->psDecoder != NULL)
- {
- WebPIDelete(sp->psDecoder);
- WebPFreeDecBuffer(&sp->sDecBuffer);
- sp->psDecoder = NULL;
- }
- }
- return 1;
- }
- else
- {
- memset(op, 0, (size_t)occ);
- sp->read_error = 1;
- TIFFErrorExtR(tif, module, "Unable to decode WebP data.");
- return 0;
- }
- }
-}
-
-static int TWebPFixupTags(TIFF *tif)
-{
- (void)tif;
- if (tif->tif_dir.td_planarconfig != PLANARCONFIG_CONTIG)
- {
- static const char module[] = "TWebPFixupTags";
- TIFFErrorExtR(tif, module,
- "TIFF WEBP requires data to be stored contiguously in "
- "RGB e.g. RGBRGBRGB "
-#if WEBP_ENCODER_ABI_VERSION >= 0x0100
- "or RGBARGBARGBA"
-#endif
- );
- return 0;
- }
- return 1;
-}
-
-static int TWebPSetupDecode(TIFF *tif)
-{
- static const char module[] = "WebPSetupDecode";
- uint16_t nBitsPerSample = tif->tif_dir.td_bitspersample;
- uint16_t sampleFormat = tif->tif_dir.td_sampleformat;
-
- WebPState *sp = DecoderState(tif);
- assert(sp != NULL);
-
- sp->nSamples = tif->tif_dir.td_samplesperpixel;
-
- /* check band count */
- if (sp->nSamples != 3
-#if WEBP_ENCODER_ABI_VERSION >= 0x0100
- && sp->nSamples != 4
-#endif
- )
- {
- TIFFErrorExtR(tif, module,
- "WEBP driver doesn't support %d bands. Must be 3 (RGB) "
-#if WEBP_ENCODER_ABI_VERSION >= 0x0100
- "or 4 (RGBA) "
-#endif
- "bands.",
- sp->nSamples);
- return 0;
- }
-
- /* check bits per sample and data type */
- if ((nBitsPerSample != 8) && (sampleFormat != 1))
- {
- TIFFErrorExtR(tif, module, "WEBP driver requires 8 bit unsigned data");
- return 0;
- }
-
- /* if we were last encoding, terminate this mode */
- if (sp->state & LSTATE_INIT_ENCODE)
- {
- WebPPictureFree(&sp->sPicture);
- if (sp->pBuffer != NULL)
- {
- _TIFFfreeExt(tif, sp->pBuffer);
- sp->pBuffer = NULL;
- }
- sp->buffer_offset = 0;
- sp->state = 0;
- }
-
- sp->state |= LSTATE_INIT_DECODE;
-
- return 1;
-}
-
-/*
- * Setup state for decoding a strip.
- */
-static int TWebPPreDecode(TIFF *tif, uint16_t s)
-{
- static const char module[] = "TWebPPreDecode";
- uint32_t segment_width, segment_height;
- WebPState *sp = DecoderState(tif);
- TIFFDirectory *td = &tif->tif_dir;
- (void)s;
- assert(sp != NULL);
-
- if (isTiled(tif))
- {
- segment_width = td->td_tilewidth;
- segment_height = td->td_tilelength;
- }
- else
- {
- segment_width = td->td_imagewidth;
- segment_height = td->td_imagelength - tif->tif_row;
- if (segment_height > td->td_rowsperstrip)
- segment_height = td->td_rowsperstrip;
- }
-
- if (segment_width > 16383 || segment_height > 16383)
- {
- TIFFErrorExtR(tif, module,
- "WEBP maximum image dimensions are 16383 x 16383.");
- return 0;
- }
-
- if ((sp->state & LSTATE_INIT_DECODE) == 0)
- tif->tif_setupdecode(tif);
-
- if (sp->psDecoder != NULL)
- {
- WebPIDelete(sp->psDecoder);
- WebPFreeDecBuffer(&sp->sDecBuffer);
- sp->psDecoder = NULL;
- }
-
- sp->read_error = 0;
-
- return 1;
-}
-
-static int TWebPSetupEncode(TIFF *tif)
-{
- static const char module[] = "WebPSetupEncode";
- uint16_t nBitsPerSample = tif->tif_dir.td_bitspersample;
- uint16_t sampleFormat = tif->tif_dir.td_sampleformat;
-
- WebPState *sp = EncoderState(tif);
- assert(sp != NULL);
-
- sp->nSamples = tif->tif_dir.td_samplesperpixel;
-
- /* check band count */
- if (sp->nSamples != 3
-#if WEBP_ENCODER_ABI_VERSION >= 0x0100
- && sp->nSamples != 4
-#endif
- )
- {
- TIFFErrorExtR(tif, module,
- "WEBP driver doesn't support %d bands. Must be 3 (RGB) "
-#if WEBP_ENCODER_ABI_VERSION >= 0x0100
- "or 4 (RGBA) "
-#endif
- "bands.",
- sp->nSamples);
- return 0;
- }
-
- /* check bits per sample and data type */
- if ((nBitsPerSample != 8) || (sampleFormat != SAMPLEFORMAT_UINT))
- {
- TIFFErrorExtR(tif, module, "WEBP driver requires 8 bit unsigned data");
- return 0;
- }
-
- if (sp->state & LSTATE_INIT_DECODE)
- {
- WebPIDelete(sp->psDecoder);
- WebPFreeDecBuffer(&sp->sDecBuffer);
- sp->psDecoder = NULL;
- sp->last_y = 0;
- sp->state = 0;
- }
-
- sp->state |= LSTATE_INIT_ENCODE;
-
- if (!WebPPictureInit(&sp->sPicture))
- {
- TIFFErrorExtR(tif, module, "Error initializing WebP picture.");
- return 0;
- }
-
- if (!WebPConfigInitInternal(&sp->sEncoderConfig, WEBP_PRESET_DEFAULT,
- (float)sp->quality_level,
- WEBP_ENCODER_ABI_VERSION))
- {
- TIFFErrorExtR(tif, module,
- "Error creating WebP encoder configuration.");
- return 0;
- }
-
-// WebPConfigInitInternal above sets lossless to false
-#if WEBP_ENCODER_ABI_VERSION >= 0x0100
- sp->sEncoderConfig.lossless = sp->lossless;
- if (sp->lossless)
- {
- sp->sPicture.use_argb = 1;
-#if WEBP_ENCODER_ABI_VERSION >= 0x0209
- sp->sEncoderConfig.exact = sp->lossless_exact;
-#endif
- }
-#endif
-
- if (!WebPValidateConfig(&sp->sEncoderConfig))
- {
- TIFFErrorExtR(tif, module, "Error with WebP encoder configuration.");
- return 0;
- }
-
- return 1;
-}
-
-/*
- * Reset encoding state at the start of a strip.
- */
-static int TWebPPreEncode(TIFF *tif, uint16_t s)
-{
- static const char module[] = "TWebPPreEncode";
- uint32_t segment_width, segment_height;
- WebPState *sp = EncoderState(tif);
- TIFFDirectory *td = &tif->tif_dir;
-
- (void)s;
-
- assert(sp != NULL);
- if (sp->state != LSTATE_INIT_ENCODE)
- tif->tif_setupencode(tif);
-
- /*
- * Set encoding parameters for this strip/tile.
- */
- if (isTiled(tif))
- {
- segment_width = td->td_tilewidth;
- segment_height = td->td_tilelength;
- }
- else
- {
- segment_width = td->td_imagewidth;
- segment_height = td->td_imagelength - tif->tif_row;
- if (segment_height > td->td_rowsperstrip)
- segment_height = td->td_rowsperstrip;
- }
-
- if (segment_width > 16383 || segment_height > 16383)
- {
- TIFFErrorExtR(tif, module,
- "WEBP maximum image dimensions are 16383 x 16383.");
- return 0;
- }
-
- /* set up buffer for raw data */
- /* given above check and that nSamples <= 4, buffer_size is <= 1 GB */
- sp->buffer_size = segment_width * segment_height * sp->nSamples;
-
- if (sp->pBuffer != NULL)
- {
- _TIFFfreeExt(tif, sp->pBuffer);
- sp->pBuffer = NULL;
- }
-
- sp->pBuffer = _TIFFmallocExt(tif, sp->buffer_size);
- if (!sp->pBuffer)
- {
- TIFFErrorExtR(tif, module, "Cannot allocate buffer");
- return 0;
- }
- sp->buffer_offset = 0;
-
- sp->sPicture.width = segment_width;
- sp->sPicture.height = segment_height;
- sp->sPicture.writer = TWebPDatasetWriter;
- sp->sPicture.custom_ptr = tif;
-
- return 1;
-}
-
-/*
- * Finish off an encoded strip by flushing it.
- */
-static int TWebPPostEncode(TIFF *tif)
-{
- static const char module[] = "WebPPostEncode";
- int64_t stride;
- WebPState *sp = EncoderState(tif);
- assert(sp != NULL);
-
- assert(sp->state == LSTATE_INIT_ENCODE);
-
- stride = (int64_t)sp->sPicture.width * sp->nSamples;
-
-#if WEBP_ENCODER_ABI_VERSION >= 0x0100
- if (sp->nSamples == 4)
- {
- if (!WebPPictureImportRGBA(&sp->sPicture, sp->pBuffer, (int)stride))
- {
- TIFFErrorExtR(tif, module, "WebPPictureImportRGBA() failed");
- return 0;
- }
- }
- else
-#endif
- if (!WebPPictureImportRGB(&sp->sPicture, sp->pBuffer, (int)stride))
- {
- TIFFErrorExtR(tif, module, "WebPPictureImportRGB() failed");
- return 0;
- }
-
- if (!WebPEncode(&sp->sEncoderConfig, &sp->sPicture))
- {
-
-#if WEBP_ENCODER_ABI_VERSION >= 0x0100
- const char *pszErrorMsg = NULL;
- switch (sp->sPicture.error_code)
- {
- case VP8_ENC_ERROR_OUT_OF_MEMORY:
- pszErrorMsg = "Out of memory";
- break;
- case VP8_ENC_ERROR_BITSTREAM_OUT_OF_MEMORY:
- pszErrorMsg = "Out of memory while flushing bits";
- break;
- case VP8_ENC_ERROR_NULL_PARAMETER:
- pszErrorMsg = "A pointer parameter is NULL";
- break;
- case VP8_ENC_ERROR_INVALID_CONFIGURATION:
- pszErrorMsg = "Configuration is invalid";
- break;
- case VP8_ENC_ERROR_BAD_DIMENSION:
- pszErrorMsg = "Picture has invalid width/height";
- break;
- case VP8_ENC_ERROR_PARTITION0_OVERFLOW:
- pszErrorMsg = "Partition is bigger than 512k. Try using less "
- "SEGMENTS, or increase PARTITION_LIMIT value";
- break;
- case VP8_ENC_ERROR_PARTITION_OVERFLOW:
- pszErrorMsg = "Partition is bigger than 16M";
- break;
- case VP8_ENC_ERROR_BAD_WRITE:
- pszErrorMsg = "Error while fludshing bytes";
- break;
- case VP8_ENC_ERROR_FILE_TOO_BIG:
- pszErrorMsg = "File is bigger than 4G";
- break;
- case VP8_ENC_ERROR_USER_ABORT:
- pszErrorMsg = "User interrupted";
- break;
- default:
- TIFFErrorExtR(tif, module,
- "WebPEncode returned an unknown error code: %d",
- sp->sPicture.error_code);
- pszErrorMsg = "Unknown WebP error type.";
- break;
- }
- TIFFErrorExtR(tif, module, "WebPEncode() failed : %s", pszErrorMsg);
-#else
- TIFFErrorExtR(tif, module, "Error in WebPEncode()");
-#endif
- return 0;
- }
-
- sp->sPicture.custom_ptr = NULL;
-
- if (!TIFFFlushData1(tif))
- {
- TIFFErrorExtR(tif, module, "Error flushing TIFF WebP encoder.");
- return 0;
- }
-
- return 1;
-}
-
-static void TWebPCleanup(TIFF *tif)
-{
- WebPState *sp = LState(tif);
-
- assert(sp != 0);
-
- tif->tif_tagmethods.vgetfield = sp->vgetparent;
- tif->tif_tagmethods.vsetfield = sp->vsetparent;
-
- if (sp->state & LSTATE_INIT_ENCODE)
- {
- WebPPictureFree(&sp->sPicture);
- }
-
- if (sp->psDecoder != NULL)
- {
- WebPIDelete(sp->psDecoder);
- WebPFreeDecBuffer(&sp->sDecBuffer);
- sp->psDecoder = NULL;
- sp->last_y = 0;
- }
-
- if (sp->pBuffer != NULL)
- {
- _TIFFfreeExt(tif, sp->pBuffer);
- sp->pBuffer = NULL;
- }
-
- _TIFFfreeExt(tif, tif->tif_data);
- tif->tif_data = NULL;
-
- _TIFFSetDefaultCompressionState(tif);
-}
-
-static int TWebPVSetField(TIFF *tif, uint32_t tag, va_list ap)
-{
- static const char module[] = "WebPVSetField";
- WebPState *sp = LState(tif);
-
- switch (tag)
- {
- case TIFFTAG_WEBP_LEVEL:
- sp->quality_level = (int)va_arg(ap, int);
- if (sp->quality_level <= 0 || sp->quality_level > 100.0f)
- {
- TIFFWarningExtR(tif, module,
- "WEBP_LEVEL should be between 1 and 100");
- }
- return 1;
- case TIFFTAG_WEBP_LOSSLESS:
-#if WEBP_ENCODER_ABI_VERSION >= 0x0100
- sp->lossless = va_arg(ap, int);
- if (sp->lossless)
- {
- sp->quality_level = 100;
- }
- return 1;
-#else
- TIFFErrorExtR(
- tif, module,
- "Need to upgrade WEBP driver, this version doesn't support "
- "lossless compression.");
- return 0;
-#endif
- case TIFFTAG_WEBP_LOSSLESS_EXACT:
-#if WEBP_ENCODER_ABI_VERSION >= 0x0209
- sp->lossless_exact = va_arg(ap, int);
- return 1;
-#else
- TIFFErrorExtR(
- tif, module,
- "Need to upgrade WEBP driver, this version doesn't support "
- "lossless compression.");
- return 0;
-#endif
- default:
- return (*sp->vsetparent)(tif, tag, ap);
- }
- /*NOTREACHED*/
-}
-
-static int TWebPVGetField(TIFF *tif, uint32_t tag, va_list ap)
-{
- WebPState *sp = LState(tif);
-
- switch (tag)
- {
- case TIFFTAG_WEBP_LEVEL:
- *va_arg(ap, int *) = sp->quality_level;
- break;
- case TIFFTAG_WEBP_LOSSLESS:
- *va_arg(ap, int *) = sp->lossless;
- break;
- case TIFFTAG_WEBP_LOSSLESS_EXACT:
- *va_arg(ap, int *) = sp->lossless_exact;
- break;
- default:
- return (*sp->vgetparent)(tif, tag, ap);
- }
- return 1;
-}
-
-static const TIFFField TWebPFields[] = {
- {TIFFTAG_WEBP_LEVEL, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT,
- TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "WEBP quality", NULL},
- {TIFFTAG_WEBP_LOSSLESS, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT,
- TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "WEBP lossless/lossy",
- NULL},
- {TIFFTAG_WEBP_LOSSLESS_EXACT, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT,
- TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "WEBP exact lossless",
- NULL},
-};
-
-int TIFFInitWebP(TIFF *tif, int scheme)
-{
- static const char module[] = "TIFFInitWebP";
- WebPState *sp;
-
- (void)scheme;
- assert(scheme == COMPRESSION_WEBP);
-
- /*
- * Merge codec-specific tag information.
- */
- if (!_TIFFMergeFields(tif, TWebPFields, TIFFArrayCount(TWebPFields)))
- {
- TIFFErrorExtR(tif, module, "Merging WebP codec-specific tags failed");
- return 0;
- }
-
- /*
- * Allocate state block so tag methods have storage to record values.
- */
- tif->tif_data = (uint8_t *)_TIFFmallocExt(tif, sizeof(WebPState));
- if (tif->tif_data == NULL)
- goto bad;
- sp = LState(tif);
-
- /*
- * Override parent get/set field methods.
- */
- sp->vgetparent = tif->tif_tagmethods.vgetfield;
- tif->tif_tagmethods.vgetfield = TWebPVGetField; /* hook for codec tags */
- sp->vsetparent = tif->tif_tagmethods.vsetfield;
- tif->tif_tagmethods.vsetfield = TWebPVSetField; /* hook for codec tags */
-
- /* Default values for codec-specific fields */
- sp->quality_level = 75; /* default comp. level */
- sp->lossless = 0; /* default to false */
- sp->lossless_exact = 1; /* exact lossless mode (if lossless enabled) */
- sp->state = 0;
- sp->nSamples = 0;
- sp->psDecoder = NULL;
- sp->last_y = 0;
-
- sp->buffer_offset = 0;
- sp->pBuffer = NULL;
-
- /*
- * Install codec methods.
- * Notes:
- * encoderow is not supported
- */
- tif->tif_fixuptags = TWebPFixupTags;
- tif->tif_setupdecode = TWebPSetupDecode;
- tif->tif_predecode = TWebPPreDecode;
- tif->tif_decoderow = TWebPDecode;
- tif->tif_decodestrip = TWebPDecode;
- tif->tif_decodetile = TWebPDecode;
- tif->tif_setupencode = TWebPSetupEncode;
- tif->tif_preencode = TWebPPreEncode;
- tif->tif_postencode = TWebPPostEncode;
- tif->tif_encoderow = TWebPEncode;
- tif->tif_encodestrip = TWebPEncode;
- tif->tif_encodetile = TWebPEncode;
- tif->tif_cleanup = TWebPCleanup;
-
- return 1;
-bad:
- TIFFErrorExtR(tif, module, "No space for WebP state block");
- return 0;
-}
-
-#endif /* WEBP_SUPPORT */
diff --git a/contrib/libs/libtiff/tif_win32.c b/contrib/libs/libtiff/tif_win32.c
deleted file mode 100644
index d64ba49f0e..0000000000
--- a/contrib/libs/libtiff/tif_win32.c
+++ /dev/null
@@ -1,446 +0,0 @@
-/*
- * Copyright (c) 1988-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-/*
- * TIFF Library Win32-specific Routines. Adapted from tif_unix.c 4/5/95 by
- * Scott Wagner (wagner@itek.com), Itek Graphix, Rochester, NY USA
- */
-
-#ifdef TIFF_DO_NOT_USE_NON_EXT_ALLOC_FUNCTIONS
-#undef TIFF_DO_NOT_USE_NON_EXT_ALLOC_FUNCTIONS
-#endif
-
-#include "tiffiop.h"
-#include <stdlib.h>
-
-#include <windows.h>
-
-/*
- CreateFileA/CreateFileW return type 'HANDLE' while TIFFFdOpen() takes 'int',
- which is formally incompatible and can even seemingly be of different size:
- HANDLE is 64 bit under Win64, while int is still 32 bits there.
-
- However, only the lower 32 bits of a HANDLE are significant under Win64 as,
- for interoperability reasons, they must have the same values in 32- and
- 64-bit programs running on the same system, see
-
- https://docs.microsoft.com/en-us/windows/win32/winprog64/interprocess-communication
-
- Because of this, it is safe to define the following trivial functions for
- casting between ints and HANDLEs, which are only really needed to avoid
- compiler warnings (and, perhaps, to make the code slightly more clear).
- Note that using the intermediate cast to "intptr_t" is crucial for warning
- avoidance, as this integer type has the same size as HANDLE in all builds.
-*/
-
-static inline thandle_t thandle_from_int(int ifd)
-{
- return (thandle_t)(intptr_t)ifd;
-}
-
-static inline int thandle_to_int(thandle_t fd) { return (int)(intptr_t)fd; }
-
-static tmsize_t _tiffReadProc(thandle_t fd, void *buf, tmsize_t size)
-{
- /* tmsize_t is 64bit on 64bit systems, but the WinAPI ReadFile takes
- * 32bit sizes, so we loop through the data in suitable 32bit sized
- * chunks */
- uint8_t *ma;
- uint64_t mb;
- DWORD n;
- DWORD o;
- tmsize_t p;
- ma = (uint8_t *)buf;
- mb = size;
- p = 0;
- while (mb > 0)
- {
- n = 0x80000000UL;
- if ((uint64_t)n > mb)
- n = (DWORD)mb;
- if (!ReadFile(fd, (LPVOID)ma, n, &o, NULL))
- return (0);
- ma += o;
- mb -= o;
- p += o;
- if (o != n)
- break;
- }
- return (p);
-}
-
-static tmsize_t _tiffWriteProc(thandle_t fd, void *buf, tmsize_t size)
-{
- /* tmsize_t is 64bit on 64bit systems, but the WinAPI WriteFile takes
- * 32bit sizes, so we loop through the data in suitable 32bit sized
- * chunks */
- uint8_t *ma;
- uint64_t mb;
- DWORD n;
- DWORD o;
- tmsize_t p;
- ma = (uint8_t *)buf;
- mb = size;
- p = 0;
- while (mb > 0)
- {
- n = 0x80000000UL;
- if ((uint64_t)n > mb)
- n = (DWORD)mb;
- if (!WriteFile(fd, (LPVOID)ma, n, &o, NULL))
- return (0);
- ma += o;
- mb -= o;
- p += o;
- if (o != n)
- break;
- }
- return (p);
-}
-
-static uint64_t _tiffSeekProc(thandle_t fd, uint64_t off, int whence)
-{
- LARGE_INTEGER offli;
- DWORD dwMoveMethod;
- offli.QuadPart = off;
- switch (whence)
- {
- case SEEK_SET:
- dwMoveMethod = FILE_BEGIN;
- break;
- case SEEK_CUR:
- dwMoveMethod = FILE_CURRENT;
- break;
- case SEEK_END:
- dwMoveMethod = FILE_END;
- break;
- default:
- dwMoveMethod = FILE_BEGIN;
- break;
- }
- offli.LowPart =
- SetFilePointer(fd, offli.LowPart, &offli.HighPart, dwMoveMethod);
- if ((offli.LowPart == INVALID_SET_FILE_POINTER) &&
- (GetLastError() != NO_ERROR))
- offli.QuadPart = 0;
- return (offli.QuadPart);
-}
-
-static int _tiffCloseProc(thandle_t fd) { return (CloseHandle(fd) ? 0 : -1); }
-
-static uint64_t _tiffSizeProc(thandle_t fd)
-{
- LARGE_INTEGER m;
- if (GetFileSizeEx(fd, &m))
- return (m.QuadPart);
- else
- return (0);
-}
-
-static int _tiffDummyMapProc(thandle_t fd, void **pbase, toff_t *psize)
-{
- (void)fd;
- (void)pbase;
- (void)psize;
- return (0);
-}
-
-/*
- * From "Hermann Josef Hill" <lhill@rhein-zeitung.de>:
- *
- * Windows uses both a handle and a pointer for file mapping,
- * but according to the SDK documentation and Richter's book
- * "Advanced Windows Programming" it is safe to free the handle
- * after obtaining the file mapping pointer
- *
- * This removes a nasty OS dependency and cures a problem
- * with Visual C++ 5.0
- */
-static int _tiffMapProc(thandle_t fd, void **pbase, toff_t *psize)
-{
- uint64_t size;
- tmsize_t sizem;
- HANDLE hMapFile;
-
- size = _tiffSizeProc(fd);
- sizem = (tmsize_t)size;
- if (!size || (uint64_t)sizem != size)
- return (0);
-
- /* By passing in 0 for the maximum file size, it specifies that we
- create a file mapping object for the full file size. */
- hMapFile = CreateFileMapping(fd, NULL, PAGE_READONLY, 0, 0, NULL);
- if (hMapFile == NULL)
- return (0);
- *pbase = MapViewOfFile(hMapFile, FILE_MAP_READ, 0, 0, 0);
- CloseHandle(hMapFile);
- if (*pbase == NULL)
- return (0);
- *psize = size;
- return (1);
-}
-
-static void _tiffDummyUnmapProc(thandle_t fd, void *base, toff_t size)
-{
- (void)fd;
- (void)base;
- (void)size;
-}
-
-static void _tiffUnmapProc(thandle_t fd, void *base, toff_t size)
-{
- (void)fd;
- (void)size;
- UnmapViewOfFile(base);
-}
-
-/*
- * Open a TIFF file descriptor for read/writing.
- * Note that TIFFFdOpen and TIFFOpen recognise the character 'u' in the mode
- * string, which forces the file to be opened unmapped.
- */
-TIFF *TIFFFdOpen(int ifd, const char *name, const char *mode)
-{
- return TIFFFdOpenExt(ifd, name, mode, NULL);
-}
-
-TIFF *TIFFFdOpenExt(int ifd, const char *name, const char *mode,
- TIFFOpenOptions *opts)
-{
- TIFF *tif;
- int fSuppressMap;
- int m;
-
- fSuppressMap = 0;
- for (m = 0; mode[m] != 0; m++)
- {
- if (mode[m] == 'u')
- {
- fSuppressMap = 1;
- break;
- }
- }
-
- tif = TIFFClientOpenExt(
- name, mode, thandle_from_int(ifd), _tiffReadProc, _tiffWriteProc,
- _tiffSeekProc, _tiffCloseProc, _tiffSizeProc,
- fSuppressMap ? _tiffDummyMapProc : _tiffMapProc,
- fSuppressMap ? _tiffDummyUnmapProc : _tiffUnmapProc, opts);
- if (tif)
- tif->tif_fd = ifd;
- return (tif);
-}
-
-#ifndef _WIN32_WCE
-
-/*
- * Open a TIFF file for read/writing.
- */
-TIFF *TIFFOpen(const char *name, const char *mode)
-{
- return TIFFOpenExt(name, mode, NULL);
-}
-
-TIFF *TIFFOpenExt(const char *name, const char *mode, TIFFOpenOptions *opts)
-{
- static const char module[] = "TIFFOpen";
- thandle_t fd;
- int m;
- DWORD dwMode;
- TIFF *tif;
-
- m = _TIFFgetMode(opts, NULL, mode, module);
-
- switch (m)
- {
- case O_RDONLY:
- dwMode = OPEN_EXISTING;
- break;
- case O_RDWR:
- dwMode = OPEN_EXISTING;
- break;
- case O_RDWR | O_CREAT:
- dwMode = OPEN_ALWAYS;
- break;
- case O_RDWR | O_TRUNC:
- dwMode = CREATE_ALWAYS;
- break;
- case O_RDWR | O_CREAT | O_TRUNC:
- dwMode = CREATE_ALWAYS;
- break;
- default:
- return ((TIFF *)0);
- }
-
- fd = (thandle_t)CreateFileA(
- name, (m == O_RDONLY) ? GENERIC_READ : (GENERIC_READ | GENERIC_WRITE),
- FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, dwMode,
- (m == O_RDONLY) ? FILE_ATTRIBUTE_READONLY : FILE_ATTRIBUTE_NORMAL,
- NULL);
- if (fd == INVALID_HANDLE_VALUE)
- {
- _TIFFErrorEarly(opts, NULL, module, "%s: Cannot open", name);
- return ((TIFF *)0);
- }
-
- tif = TIFFFdOpenExt(thandle_to_int(fd), name, mode, opts);
- if (!tif)
- CloseHandle(fd);
- return tif;
-}
-
-/*
- * Open a TIFF file with a Unicode filename, for read/writing.
- */
-TIFF *TIFFOpenW(const wchar_t *name, const char *mode)
-{
- return TIFFOpenWExt(name, mode, NULL);
-}
-
-TIFF *TIFFOpenWExt(const wchar_t *name, const char *mode, TIFFOpenOptions *opts)
-{
- static const char module[] = "TIFFOpenW";
- thandle_t fd;
- int m;
- DWORD dwMode;
- int mbsize;
- char *mbname;
- TIFF *tif;
-
- m = _TIFFgetMode(opts, NULL, mode, module);
-
- switch (m)
- {
- case O_RDONLY:
- dwMode = OPEN_EXISTING;
- break;
- case O_RDWR:
- dwMode = OPEN_EXISTING;
- break;
- case O_RDWR | O_CREAT:
- dwMode = OPEN_ALWAYS;
- break;
- case O_RDWR | O_TRUNC:
- dwMode = CREATE_ALWAYS;
- break;
- case O_RDWR | O_CREAT | O_TRUNC:
- dwMode = CREATE_ALWAYS;
- break;
- default:
- return ((TIFF *)0);
- }
-
- fd = (thandle_t)CreateFileW(
- name, (m == O_RDONLY) ? GENERIC_READ : (GENERIC_READ | GENERIC_WRITE),
- FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, dwMode,
- (m == O_RDONLY) ? FILE_ATTRIBUTE_READONLY : FILE_ATTRIBUTE_NORMAL,
- NULL);
- if (fd == INVALID_HANDLE_VALUE)
- {
- _TIFFErrorEarly(opts, NULL, module, "%S: Cannot open", name);
- return ((TIFF *)0);
- }
-
- mbname = NULL;
- mbsize = WideCharToMultiByte(CP_ACP, 0, name, -1, NULL, 0, NULL, NULL);
- if (mbsize > 0)
- {
- mbname = (char *)_TIFFmalloc(mbsize);
- if (!mbname)
- {
- _TIFFErrorEarly(
- opts, NULL, module,
- "Can't allocate space for filename conversion buffer");
- return ((TIFF *)0);
- }
-
- WideCharToMultiByte(CP_ACP, 0, name, -1, mbname, mbsize, NULL, NULL);
- }
-
- tif = TIFFFdOpenExt(thandle_to_int(fd),
- (mbname != NULL) ? mbname : "<unknown>", mode, opts);
- if (!tif)
- CloseHandle(fd);
-
- _TIFFfree(mbname);
-
- return tif;
-}
-
-#endif /* ndef _WIN32_WCE */
-
-void *_TIFFmalloc(tmsize_t s)
-{
- if (s == 0)
- return ((void *)NULL);
-
- return (malloc((size_t)s));
-}
-
-void *_TIFFcalloc(tmsize_t nmemb, tmsize_t siz)
-{
- if (nmemb == 0 || siz == 0)
- return ((void *)NULL);
-
- return calloc((size_t)nmemb, (size_t)siz);
-}
-
-void _TIFFfree(void *p) { free(p); }
-
-void *_TIFFrealloc(void *p, tmsize_t s) { return (realloc(p, (size_t)s)); }
-
-void _TIFFmemset(void *p, int v, tmsize_t c) { memset(p, v, (size_t)c); }
-
-void _TIFFmemcpy(void *d, const void *s, tmsize_t c)
-{
- memcpy(d, s, (size_t)c);
-}
-
-int _TIFFmemcmp(const void *p1, const void *p2, tmsize_t c)
-{
- return (memcmp(p1, p2, (size_t)c));
-}
-
-#ifndef _WIN32_WCE
-
-static void Win32WarningHandler(const char *module, const char *fmt, va_list ap)
-{
- if (module != NULL)
- fprintf(stderr, "%s: ", module);
- fprintf(stderr, "Warning, ");
- vfprintf(stderr, fmt, ap);
- fprintf(stderr, ".\n");
-}
-TIFFErrorHandler _TIFFwarningHandler = Win32WarningHandler;
-
-static void Win32ErrorHandler(const char *module, const char *fmt, va_list ap)
-{
- if (module != NULL)
- fprintf(stderr, "%s: ", module);
- vfprintf(stderr, fmt, ap);
- fprintf(stderr, ".\n");
-}
-TIFFErrorHandler _TIFFerrorHandler = Win32ErrorHandler;
-
-#endif /* ndef _WIN32_WCE */
diff --git a/contrib/libs/libtiff/tif_write.c b/contrib/libs/libtiff/tif_write.c
deleted file mode 100644
index 6631a782fd..0000000000
--- a/contrib/libs/libtiff/tif_write.c
+++ /dev/null
@@ -1,960 +0,0 @@
-/*
- * Copyright (c) 1988-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-/*
- * TIFF Library.
- *
- * Scanline-oriented Write Support
- */
-#include "tiffiop.h"
-#include <stdio.h>
-
-#define STRIPINCR 20 /* expansion factor on strip array */
-
-#define WRITECHECKSTRIPS(tif, module) \
- (((tif)->tif_flags & TIFF_BEENWRITING) || TIFFWriteCheck((tif), 0, module))
-#define WRITECHECKTILES(tif, module) \
- (((tif)->tif_flags & TIFF_BEENWRITING) || TIFFWriteCheck((tif), 1, module))
-#define BUFFERCHECK(tif) \
- ((((tif)->tif_flags & TIFF_BUFFERSETUP) && tif->tif_rawdata) || \
- TIFFWriteBufferSetup((tif), NULL, (tmsize_t)-1))
-
-static int TIFFGrowStrips(TIFF *tif, uint32_t delta, const char *module);
-static int TIFFAppendToStrip(TIFF *tif, uint32_t strip, uint8_t *data,
- tmsize_t cc);
-
-int TIFFWriteScanline(TIFF *tif, void *buf, uint32_t row, uint16_t sample)
-{
- static const char module[] = "TIFFWriteScanline";
- register TIFFDirectory *td;
- int status, imagegrew = 0;
- uint32_t strip;
-
- if (!WRITECHECKSTRIPS(tif, module))
- return (-1);
- /*
- * Handle delayed allocation of data buffer. This
- * permits it to be sized more intelligently (using
- * directory information).
- */
- if (!BUFFERCHECK(tif))
- return (-1);
- tif->tif_flags |= TIFF_BUF4WRITE; /* not strictly sure this is right*/
-
- td = &tif->tif_dir;
- /*
- * Extend image length if needed
- * (but only for PlanarConfig=1).
- */
- if (row >= td->td_imagelength)
- { /* extend image */
- if (td->td_planarconfig == PLANARCONFIG_SEPARATE)
- {
- TIFFErrorExtR(
- tif, module,
- "Can not change \"ImageLength\" when using separate planes");
- return (-1);
- }
- td->td_imagelength = row + 1;
- imagegrew = 1;
- }
- /*
- * Calculate strip and check for crossings.
- */
- if (td->td_planarconfig == PLANARCONFIG_SEPARATE)
- {
- if (sample >= td->td_samplesperpixel)
- {
- TIFFErrorExtR(tif, module, "%lu: Sample out of range, max %lu",
- (unsigned long)sample,
- (unsigned long)td->td_samplesperpixel);
- return (-1);
- }
- strip = sample * td->td_stripsperimage + row / td->td_rowsperstrip;
- }
- else
- strip = row / td->td_rowsperstrip;
- /*
- * Check strip array to make sure there's space. We don't support
- * dynamically growing files that have data organized in separate
- * bitplanes because it's too painful. In that case we require that
- * the imagelength be set properly before the first write (so that the
- * strips array will be fully allocated above).
- */
- if (strip >= td->td_nstrips && !TIFFGrowStrips(tif, 1, module))
- return (-1);
- if (strip != tif->tif_curstrip)
- {
- /*
- * Changing strips -- flush any data present.
- */
- if (!TIFFFlushData(tif))
- return (-1);
- tif->tif_curstrip = strip;
- /*
- * Watch out for a growing image. The value of strips/image
- * will initially be 1 (since it can't be deduced until the
- * imagelength is known).
- */
- if (strip >= td->td_stripsperimage && imagegrew)
- td->td_stripsperimage =
- TIFFhowmany_32(td->td_imagelength, td->td_rowsperstrip);
- if (td->td_stripsperimage == 0)
- {
- TIFFErrorExtR(tif, module, "Zero strips per image");
- return (-1);
- }
- tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip;
- if ((tif->tif_flags & TIFF_CODERSETUP) == 0)
- {
- if (!(*tif->tif_setupencode)(tif))
- return (-1);
- tif->tif_flags |= TIFF_CODERSETUP;
- }
-
- tif->tif_rawcc = 0;
- tif->tif_rawcp = tif->tif_rawdata;
-
- /* this informs TIFFAppendToStrip() we have changed strip */
- tif->tif_curoff = 0;
-
- if (!(*tif->tif_preencode)(tif, sample))
- return (-1);
- tif->tif_flags |= TIFF_POSTENCODE;
- }
- /*
- * Ensure the write is either sequential or at the
- * beginning of a strip (or that we can randomly
- * access the data -- i.e. no encoding).
- */
- if (row != tif->tif_row)
- {
- if (row < tif->tif_row)
- {
- /*
- * Moving backwards within the same strip:
- * backup to the start and then decode
- * forward (below).
- */
- tif->tif_row =
- (strip % td->td_stripsperimage) * td->td_rowsperstrip;
- tif->tif_rawcp = tif->tif_rawdata;
- }
- /*
- * Seek forward to the desired row.
- */
- if (!(*tif->tif_seek)(tif, row - tif->tif_row))
- return (-1);
- tif->tif_row = row;
- }
-
- /* swab if needed - note that source buffer will be altered */
- tif->tif_postdecode(tif, (uint8_t *)buf, tif->tif_scanlinesize);
-
- status = (*tif->tif_encoderow)(tif, (uint8_t *)buf, tif->tif_scanlinesize,
- sample);
-
- /* we are now poised at the beginning of the next row */
- tif->tif_row = row + 1;
- return (status);
-}
-
-/* Make sure that at the first attempt of rewriting a tile/strip, we will have
- */
-/* more bytes available in the output buffer than the previous byte count, */
-/* so that TIFFAppendToStrip() will detect the overflow when it is called the
- * first */
-/* time if the new compressed tile is bigger than the older one. (GDAL #4771) */
-static int _TIFFReserveLargeEnoughWriteBuffer(TIFF *tif, uint32_t strip_or_tile)
-{
- TIFFDirectory *td = &tif->tif_dir;
- if (td->td_stripbytecount_p[strip_or_tile] > 0)
- {
- /* The +1 is to ensure at least one extra bytes */
- /* The +4 is because the LZW encoder flushes 4 bytes before the limit */
- uint64_t safe_buffer_size =
- (uint64_t)(td->td_stripbytecount_p[strip_or_tile] + 1 + 4);
- if (tif->tif_rawdatasize <= (tmsize_t)safe_buffer_size)
- {
- if (!(TIFFWriteBufferSetup(
- tif, NULL,
- (tmsize_t)TIFFroundup_64(safe_buffer_size, 1024))))
- return 0;
- }
- }
- return 1;
-}
-
-/*
- * Encode the supplied data and write it to the
- * specified strip.
- *
- * NB: Image length must be setup before writing.
- */
-tmsize_t TIFFWriteEncodedStrip(TIFF *tif, uint32_t strip, void *data,
- tmsize_t cc)
-{
- static const char module[] = "TIFFWriteEncodedStrip";
- TIFFDirectory *td = &tif->tif_dir;
- uint16_t sample;
-
- if (!WRITECHECKSTRIPS(tif, module))
- return ((tmsize_t)-1);
- /*
- * Check strip array to make sure there's space.
- * We don't support dynamically growing files that
- * have data organized in separate bitplanes because
- * it's too painful. In that case we require that
- * the imagelength be set properly before the first
- * write (so that the strips array will be fully
- * allocated above).
- */
- if (strip >= td->td_nstrips)
- {
- if (td->td_planarconfig == PLANARCONFIG_SEPARATE)
- {
- TIFFErrorExtR(
- tif, module,
- "Can not grow image by strips when using separate planes");
- return ((tmsize_t)-1);
- }
- if (!TIFFGrowStrips(tif, 1, module))
- return ((tmsize_t)-1);
- td->td_stripsperimage =
- TIFFhowmany_32(td->td_imagelength, td->td_rowsperstrip);
- }
- /*
- * Handle delayed allocation of data buffer. This
- * permits it to be sized according to the directory
- * info.
- */
- if (!BUFFERCHECK(tif))
- return ((tmsize_t)-1);
-
- tif->tif_flags |= TIFF_BUF4WRITE;
-
- tif->tif_curstrip = strip;
-
- /* this informs TIFFAppendToStrip() we have changed or reset strip */
- tif->tif_curoff = 0;
-
- if (!_TIFFReserveLargeEnoughWriteBuffer(tif, strip))
- {
- return ((tmsize_t)(-1));
- }
-
- tif->tif_rawcc = 0;
- tif->tif_rawcp = tif->tif_rawdata;
-
- if (td->td_stripsperimage == 0)
- {
- TIFFErrorExtR(tif, module, "Zero strips per image");
- return ((tmsize_t)-1);
- }
-
- tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip;
- if ((tif->tif_flags & TIFF_CODERSETUP) == 0)
- {
- if (!(*tif->tif_setupencode)(tif))
- return ((tmsize_t)-1);
- tif->tif_flags |= TIFF_CODERSETUP;
- }
-
- tif->tif_flags &= ~TIFF_POSTENCODE;
-
- /* shortcut to avoid an extra memcpy() */
- if (td->td_compression == COMPRESSION_NONE)
- {
- /* swab if needed - note that source buffer will be altered */
- tif->tif_postdecode(tif, (uint8_t *)data, cc);
-
- if (!isFillOrder(tif, td->td_fillorder) &&
- (tif->tif_flags & TIFF_NOBITREV) == 0)
- TIFFReverseBits((uint8_t *)data, cc);
-
- if (cc > 0 && !TIFFAppendToStrip(tif, strip, (uint8_t *)data, cc))
- return ((tmsize_t)-1);
- return (cc);
- }
-
- sample = (uint16_t)(strip / td->td_stripsperimage);
- if (!(*tif->tif_preencode)(tif, sample))
- return ((tmsize_t)-1);
-
- /* swab if needed - note that source buffer will be altered */
- tif->tif_postdecode(tif, (uint8_t *)data, cc);
-
- if (!(*tif->tif_encodestrip)(tif, (uint8_t *)data, cc, sample))
- return ((tmsize_t)-1);
- if (!(*tif->tif_postencode)(tif))
- return ((tmsize_t)-1);
- if (!isFillOrder(tif, td->td_fillorder) &&
- (tif->tif_flags & TIFF_NOBITREV) == 0)
- TIFFReverseBits(tif->tif_rawdata, tif->tif_rawcc);
- if (tif->tif_rawcc > 0 &&
- !TIFFAppendToStrip(tif, strip, tif->tif_rawdata, tif->tif_rawcc))
- return ((tmsize_t)-1);
- tif->tif_rawcc = 0;
- tif->tif_rawcp = tif->tif_rawdata;
- return (cc);
-}
-
-/*
- * Write the supplied data to the specified strip.
- *
- * NB: Image length must be setup before writing.
- */
-tmsize_t TIFFWriteRawStrip(TIFF *tif, uint32_t strip, void *data, tmsize_t cc)
-{
- static const char module[] = "TIFFWriteRawStrip";
- TIFFDirectory *td = &tif->tif_dir;
-
- if (!WRITECHECKSTRIPS(tif, module))
- return ((tmsize_t)-1);
- /*
- * Check strip array to make sure there's space.
- * We don't support dynamically growing files that
- * have data organized in separate bitplanes because
- * it's too painful. In that case we require that
- * the imagelength be set properly before the first
- * write (so that the strips array will be fully
- * allocated above).
- */
- if (strip >= td->td_nstrips)
- {
- if (td->td_planarconfig == PLANARCONFIG_SEPARATE)
- {
- TIFFErrorExtR(
- tif, module,
- "Can not grow image by strips when using separate planes");
- return ((tmsize_t)-1);
- }
- /*
- * Watch out for a growing image. The value of
- * strips/image will initially be 1 (since it
- * can't be deduced until the imagelength is known).
- */
- if (strip >= td->td_stripsperimage)
- td->td_stripsperimage =
- TIFFhowmany_32(td->td_imagelength, td->td_rowsperstrip);
- if (!TIFFGrowStrips(tif, 1, module))
- return ((tmsize_t)-1);
- }
-
- if (tif->tif_curstrip != strip)
- {
- tif->tif_curstrip = strip;
-
- /* this informs TIFFAppendToStrip() we have changed or reset strip */
- tif->tif_curoff = 0;
- }
-
- if (td->td_stripsperimage == 0)
- {
- TIFFErrorExtR(tif, module, "Zero strips per image");
- return ((tmsize_t)-1);
- }
- tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip;
- return (TIFFAppendToStrip(tif, strip, (uint8_t *)data, cc) ? cc
- : (tmsize_t)-1);
-}
-
-/*
- * Write and compress a tile of data. The
- * tile is selected by the (x,y,z,s) coordinates.
- */
-tmsize_t TIFFWriteTile(TIFF *tif, void *buf, uint32_t x, uint32_t y, uint32_t z,
- uint16_t s)
-{
- if (!TIFFCheckTile(tif, x, y, z, s))
- return ((tmsize_t)(-1));
- /*
- * NB: A tile size of -1 is used instead of tif_tilesize knowing
- * that TIFFWriteEncodedTile will clamp this to the tile size.
- * This is done because the tile size may not be defined until
- * after the output buffer is setup in TIFFWriteBufferSetup.
- */
- return (TIFFWriteEncodedTile(tif, TIFFComputeTile(tif, x, y, z, s), buf,
- (tmsize_t)(-1)));
-}
-
-/*
- * Encode the supplied data and write it to the
- * specified tile. There must be space for the
- * data. The function clamps individual writes
- * to a tile to the tile size, but does not (and
- * can not) check that multiple writes to the same
- * tile do not write more than tile size data.
- *
- * NB: Image length must be setup before writing; this
- * interface does not support automatically growing
- * the image on each write (as TIFFWriteScanline does).
- */
-tmsize_t TIFFWriteEncodedTile(TIFF *tif, uint32_t tile, void *data, tmsize_t cc)
-{
- static const char module[] = "TIFFWriteEncodedTile";
- TIFFDirectory *td;
- uint16_t sample;
- uint32_t howmany32;
-
- if (!WRITECHECKTILES(tif, module))
- return ((tmsize_t)(-1));
- td = &tif->tif_dir;
- if (tile >= td->td_nstrips)
- {
- TIFFErrorExtR(tif, module, "Tile %lu out of range, max %lu",
- (unsigned long)tile, (unsigned long)td->td_nstrips);
- return ((tmsize_t)(-1));
- }
- /*
- * Handle delayed allocation of data buffer. This
- * permits it to be sized more intelligently (using
- * directory information).
- */
- if (!BUFFERCHECK(tif))
- return ((tmsize_t)(-1));
-
- tif->tif_flags |= TIFF_BUF4WRITE;
-
- tif->tif_curtile = tile;
-
- /* this informs TIFFAppendToStrip() we have changed or reset tile */
- tif->tif_curoff = 0;
-
- if (!_TIFFReserveLargeEnoughWriteBuffer(tif, tile))
- {
- return ((tmsize_t)(-1));
- }
-
- tif->tif_rawcc = 0;
- tif->tif_rawcp = tif->tif_rawdata;
-
- /*
- * Compute tiles per row & per column to compute
- * current row and column
- */
- howmany32 = TIFFhowmany_32(td->td_imagelength, td->td_tilelength);
- if (howmany32 == 0)
- {
- TIFFErrorExtR(tif, module, "Zero tiles");
- return ((tmsize_t)(-1));
- }
- tif->tif_row = (tile % howmany32) * td->td_tilelength;
- howmany32 = TIFFhowmany_32(td->td_imagewidth, td->td_tilewidth);
- if (howmany32 == 0)
- {
- TIFFErrorExtR(tif, module, "Zero tiles");
- return ((tmsize_t)(-1));
- }
- tif->tif_col = (tile % howmany32) * td->td_tilewidth;
-
- if ((tif->tif_flags & TIFF_CODERSETUP) == 0)
- {
- if (!(*tif->tif_setupencode)(tif))
- return ((tmsize_t)(-1));
- tif->tif_flags |= TIFF_CODERSETUP;
- }
- tif->tif_flags &= ~TIFF_POSTENCODE;
-
- /*
- * Clamp write amount to the tile size. This is mostly
- * done so that callers can pass in some large number
- * (e.g. -1) and have the tile size used instead.
- */
- if (cc < 1 || cc > tif->tif_tilesize)
- cc = tif->tif_tilesize;
-
- /* shortcut to avoid an extra memcpy() */
- if (td->td_compression == COMPRESSION_NONE)
- {
- /* swab if needed - note that source buffer will be altered */
- tif->tif_postdecode(tif, (uint8_t *)data, cc);
-
- if (!isFillOrder(tif, td->td_fillorder) &&
- (tif->tif_flags & TIFF_NOBITREV) == 0)
- TIFFReverseBits((uint8_t *)data, cc);
-
- if (cc > 0 && !TIFFAppendToStrip(tif, tile, (uint8_t *)data, cc))
- return ((tmsize_t)-1);
- return (cc);
- }
-
- sample = (uint16_t)(tile / td->td_stripsperimage);
- if (!(*tif->tif_preencode)(tif, sample))
- return ((tmsize_t)(-1));
- /* swab if needed - note that source buffer will be altered */
- tif->tif_postdecode(tif, (uint8_t *)data, cc);
-
- if (!(*tif->tif_encodetile)(tif, (uint8_t *)data, cc, sample))
- return ((tmsize_t)-1);
- if (!(*tif->tif_postencode)(tif))
- return ((tmsize_t)(-1));
- if (!isFillOrder(tif, td->td_fillorder) &&
- (tif->tif_flags & TIFF_NOBITREV) == 0)
- TIFFReverseBits((uint8_t *)tif->tif_rawdata, tif->tif_rawcc);
- if (tif->tif_rawcc > 0 &&
- !TIFFAppendToStrip(tif, tile, tif->tif_rawdata, tif->tif_rawcc))
- return ((tmsize_t)(-1));
- tif->tif_rawcc = 0;
- tif->tif_rawcp = tif->tif_rawdata;
- return (cc);
-}
-
-/*
- * Write the supplied data to the specified strip.
- * There must be space for the data; we don't check
- * if strips overlap!
- *
- * NB: Image length must be setup before writing; this
- * interface does not support automatically growing
- * the image on each write (as TIFFWriteScanline does).
- */
-tmsize_t TIFFWriteRawTile(TIFF *tif, uint32_t tile, void *data, tmsize_t cc)
-{
- static const char module[] = "TIFFWriteRawTile";
-
- if (!WRITECHECKTILES(tif, module))
- return ((tmsize_t)(-1));
- if (tile >= tif->tif_dir.td_nstrips)
- {
- TIFFErrorExtR(tif, module, "Tile %lu out of range, max %lu",
- (unsigned long)tile,
- (unsigned long)tif->tif_dir.td_nstrips);
- return ((tmsize_t)(-1));
- }
- return (TIFFAppendToStrip(tif, tile, (uint8_t *)data, cc) ? cc
- : (tmsize_t)(-1));
-}
-
-#define isUnspecified(tif, f) \
- (TIFFFieldSet(tif, f) && (tif)->tif_dir.td_imagelength == 0)
-
-int TIFFSetupStrips(TIFF *tif)
-{
- TIFFDirectory *td = &tif->tif_dir;
-
- if (isTiled(tif))
- td->td_stripsperimage = isUnspecified(tif, FIELD_TILEDIMENSIONS)
- ? td->td_samplesperpixel
- : TIFFNumberOfTiles(tif);
- else
- td->td_stripsperimage = isUnspecified(tif, FIELD_ROWSPERSTRIP)
- ? td->td_samplesperpixel
- : TIFFNumberOfStrips(tif);
- td->td_nstrips = td->td_stripsperimage;
- /* TIFFWriteDirectoryTagData has a limitation to 0x80000000U bytes */
- if (td->td_nstrips >=
- 0x80000000U / ((tif->tif_flags & TIFF_BIGTIFF) ? 0x8U : 0x4U))
- {
- TIFFErrorExtR(tif, "TIFFSetupStrips",
- "Too large Strip/Tile Offsets/ByteCounts arrays");
- return 0;
- }
- if (td->td_planarconfig == PLANARCONFIG_SEPARATE)
- td->td_stripsperimage /= td->td_samplesperpixel;
- td->td_stripoffset_p = (uint64_t *)_TIFFCheckMalloc(
- tif, td->td_nstrips, sizeof(uint64_t), "for \"StripOffsets\" array");
- td->td_stripbytecount_p = (uint64_t *)_TIFFCheckMalloc(
- tif, td->td_nstrips, sizeof(uint64_t), "for \"StripByteCounts\" array");
- if (td->td_stripoffset_p == NULL || td->td_stripbytecount_p == NULL)
- return (0);
- /*
- * Place data at the end-of-file
- * (by setting offsets to zero).
- */
- _TIFFmemset(td->td_stripoffset_p, 0, td->td_nstrips * sizeof(uint64_t));
- _TIFFmemset(td->td_stripbytecount_p, 0, td->td_nstrips * sizeof(uint64_t));
- TIFFSetFieldBit(tif, FIELD_STRIPOFFSETS);
- TIFFSetFieldBit(tif, FIELD_STRIPBYTECOUNTS);
- return (1);
-}
-#undef isUnspecified
-
-/*
- * Verify file is writable and that the directory
- * information is setup properly. In doing the latter
- * we also "freeze" the state of the directory so
- * that important information is not changed.
- */
-int TIFFWriteCheck(TIFF *tif, int tiles, const char *module)
-{
- if (tif->tif_mode == O_RDONLY)
- {
- TIFFErrorExtR(tif, module, "File not open for writing");
- return (0);
- }
- if (tiles ^ isTiled(tif))
- {
- TIFFErrorExtR(tif, module,
- tiles ? "Can not write tiles to a striped image"
- : "Can not write scanlines to a tiled image");
- return (0);
- }
-
- _TIFFFillStriles(tif);
-
- /*
- * On the first write verify all the required information
- * has been setup and initialize any data structures that
- * had to wait until directory information was set.
- * Note that a lot of our work is assumed to remain valid
- * because we disallow any of the important parameters
- * from changing after we start writing (i.e. once
- * TIFF_BEENWRITING is set, TIFFSetField will only allow
- * the image's length to be changed).
- */
- if (!TIFFFieldSet(tif, FIELD_IMAGEDIMENSIONS))
- {
- TIFFErrorExtR(tif, module,
- "Must set \"ImageWidth\" before writing data");
- return (0);
- }
- if (tif->tif_dir.td_stripoffset_p == NULL && !TIFFSetupStrips(tif))
- {
- tif->tif_dir.td_nstrips = 0;
- TIFFErrorExtR(tif, module, "No space for %s arrays",
- isTiled(tif) ? "tile" : "strip");
- return (0);
- }
- if (isTiled(tif))
- {
- tif->tif_tilesize = TIFFTileSize(tif);
- if (tif->tif_tilesize == 0)
- return (0);
- }
- else
- tif->tif_tilesize = (tmsize_t)(-1);
- tif->tif_scanlinesize = TIFFScanlineSize(tif);
- if (tif->tif_scanlinesize == 0)
- return (0);
- tif->tif_flags |= TIFF_BEENWRITING;
-
- if (tif->tif_dir.td_stripoffset_entry.tdir_tag != 0 &&
- tif->tif_dir.td_stripoffset_entry.tdir_count == 0 &&
- tif->tif_dir.td_stripoffset_entry.tdir_type == 0 &&
- tif->tif_dir.td_stripoffset_entry.tdir_offset.toff_long8 == 0 &&
- tif->tif_dir.td_stripbytecount_entry.tdir_tag != 0 &&
- tif->tif_dir.td_stripbytecount_entry.tdir_count == 0 &&
- tif->tif_dir.td_stripbytecount_entry.tdir_type == 0 &&
- tif->tif_dir.td_stripbytecount_entry.tdir_offset.toff_long8 == 0 &&
- !(tif->tif_flags & TIFF_DIRTYDIRECT))
- {
- TIFFForceStrileArrayWriting(tif);
- }
-
- return (1);
-}
-
-/*
- * Setup the raw data buffer used for encoding.
- */
-int TIFFWriteBufferSetup(TIFF *tif, void *bp, tmsize_t size)
-{
- static const char module[] = "TIFFWriteBufferSetup";
-
- if (tif->tif_rawdata)
- {
- if (tif->tif_flags & TIFF_MYBUFFER)
- {
- _TIFFfreeExt(tif, tif->tif_rawdata);
- tif->tif_flags &= ~TIFF_MYBUFFER;
- }
- tif->tif_rawdata = NULL;
- }
- if (size == (tmsize_t)(-1))
- {
- size = (isTiled(tif) ? tif->tif_tilesize : TIFFStripSize(tif));
-
- /* Adds 10% margin for cases where compression would expand a bit */
- if (size < TIFF_TMSIZE_T_MAX - size / 10)
- size += size / 10;
- /*
- * Make raw data buffer at least 8K
- */
- if (size < 8 * 1024)
- size = 8 * 1024;
- bp = NULL; /* NB: force malloc */
- }
- if (bp == NULL)
- {
- bp = _TIFFmallocExt(tif, size);
- if (bp == NULL)
- {
- TIFFErrorExtR(tif, module, "No space for output buffer");
- return (0);
- }
- tif->tif_flags |= TIFF_MYBUFFER;
- }
- else
- tif->tif_flags &= ~TIFF_MYBUFFER;
- tif->tif_rawdata = (uint8_t *)bp;
- tif->tif_rawdatasize = size;
- tif->tif_rawcc = 0;
- tif->tif_rawcp = tif->tif_rawdata;
- tif->tif_flags |= TIFF_BUFFERSETUP;
- return (1);
-}
-
-/*
- * Grow the strip data structures by delta strips.
- */
-static int TIFFGrowStrips(TIFF *tif, uint32_t delta, const char *module)
-{
- TIFFDirectory *td = &tif->tif_dir;
- uint64_t *new_stripoffset;
- uint64_t *new_stripbytecount;
-
- assert(td->td_planarconfig == PLANARCONFIG_CONTIG);
- new_stripoffset = (uint64_t *)_TIFFreallocExt(
- tif, td->td_stripoffset_p, (td->td_nstrips + delta) * sizeof(uint64_t));
- new_stripbytecount = (uint64_t *)_TIFFreallocExt(
- tif, td->td_stripbytecount_p,
- (td->td_nstrips + delta) * sizeof(uint64_t));
- if (new_stripoffset == NULL || new_stripbytecount == NULL)
- {
- if (new_stripoffset)
- _TIFFfreeExt(tif, new_stripoffset);
- if (new_stripbytecount)
- _TIFFfreeExt(tif, new_stripbytecount);
- td->td_nstrips = 0;
- TIFFErrorExtR(tif, module, "No space to expand strip arrays");
- return (0);
- }
- td->td_stripoffset_p = new_stripoffset;
- td->td_stripbytecount_p = new_stripbytecount;
- _TIFFmemset(td->td_stripoffset_p + td->td_nstrips, 0,
- delta * sizeof(uint64_t));
- _TIFFmemset(td->td_stripbytecount_p + td->td_nstrips, 0,
- delta * sizeof(uint64_t));
- td->td_nstrips += delta;
- tif->tif_flags |= TIFF_DIRTYDIRECT;
-
- return (1);
-}
-
-/*
- * Append the data to the specified strip.
- */
-static int TIFFAppendToStrip(TIFF *tif, uint32_t strip, uint8_t *data,
- tmsize_t cc)
-{
- static const char module[] = "TIFFAppendToStrip";
- TIFFDirectory *td = &tif->tif_dir;
- uint64_t m;
- int64_t old_byte_count = -1;
-
- if (tif->tif_curoff == 0)
- tif->tif_lastvalidoff = 0;
-
- if (td->td_stripoffset_p[strip] == 0 || tif->tif_curoff == 0)
- {
- assert(td->td_nstrips > 0);
-
- if (td->td_stripbytecount_p[strip] != 0 &&
- td->td_stripoffset_p[strip] != 0 &&
- td->td_stripbytecount_p[strip] >= (uint64_t)cc)
- {
- /*
- * There is already tile data on disk, and the new tile
- * data we have will fit in the same space. The only
- * aspect of this that is risky is that there could be
- * more data to append to this strip before we are done
- * depending on how we are getting called.
- */
- if (!SeekOK(tif, td->td_stripoffset_p[strip]))
- {
- TIFFErrorExtR(tif, module, "Seek error at scanline %lu",
- (unsigned long)tif->tif_row);
- return (0);
- }
-
- tif->tif_lastvalidoff =
- td->td_stripoffset_p[strip] + td->td_stripbytecount_p[strip];
- }
- else
- {
- /*
- * Seek to end of file, and set that as our location to
- * write this strip.
- */
- td->td_stripoffset_p[strip] = TIFFSeekFile(tif, 0, SEEK_END);
- tif->tif_flags |= TIFF_DIRTYSTRIP;
- }
-
- tif->tif_curoff = td->td_stripoffset_p[strip];
-
- /*
- * We are starting a fresh strip/tile, so set the size to zero.
- */
- old_byte_count = td->td_stripbytecount_p[strip];
- td->td_stripbytecount_p[strip] = 0;
- }
-
- m = tif->tif_curoff + cc;
- if (!(tif->tif_flags & TIFF_BIGTIFF))
- m = (uint32_t)m;
- if ((m < tif->tif_curoff) || (m < (uint64_t)cc))
- {
- TIFFErrorExtR(tif, module, "Maximum TIFF file size exceeded");
- return (0);
- }
-
- if (tif->tif_lastvalidoff != 0 && m > tif->tif_lastvalidoff &&
- td->td_stripbytecount_p[strip] > 0)
- {
- /* Ouch: we have detected that we are rewriting in place a strip/tile */
- /* with several calls to TIFFAppendToStrip(). The first call was with */
- /* a size smaller than the previous size of the strip/tile, so we */
- /* opted to rewrite in place, but a following call causes us to go */
- /* outsize of the strip/tile area, so we have to finally go for a */
- /* append-at-end-of-file strategy, and start by moving what we already
- */
- /* wrote. */
- tmsize_t tempSize;
- void *temp;
- uint64_t offsetRead;
- uint64_t offsetWrite;
- uint64_t toCopy = td->td_stripbytecount_p[strip];
-
- if (toCopy < 1024 * 1024)
- tempSize = (tmsize_t)toCopy;
- else
- tempSize = 1024 * 1024;
-
- offsetRead = td->td_stripoffset_p[strip];
- offsetWrite = TIFFSeekFile(tif, 0, SEEK_END);
-
- m = offsetWrite + toCopy + cc;
- if (!(tif->tif_flags & TIFF_BIGTIFF) && m != (uint32_t)m)
- {
- TIFFErrorExtR(tif, module, "Maximum TIFF file size exceeded");
- return (0);
- }
-
- temp = _TIFFmallocExt(tif, tempSize);
- if (temp == NULL)
- {
- TIFFErrorExtR(tif, module, "No space for output buffer");
- return (0);
- }
-
- tif->tif_flags |= TIFF_DIRTYSTRIP;
-
- td->td_stripoffset_p[strip] = offsetWrite;
- td->td_stripbytecount_p[strip] = 0;
-
- /* Move data written by previous calls to us at end of file */
- while (toCopy > 0)
- {
- if (!SeekOK(tif, offsetRead))
- {
- TIFFErrorExtR(tif, module, "Seek error");
- _TIFFfreeExt(tif, temp);
- return (0);
- }
- if (!ReadOK(tif, temp, tempSize))
- {
- TIFFErrorExtR(tif, module, "Cannot read");
- _TIFFfreeExt(tif, temp);
- return (0);
- }
- if (!SeekOK(tif, offsetWrite))
- {
- TIFFErrorExtR(tif, module, "Seek error");
- _TIFFfreeExt(tif, temp);
- return (0);
- }
- if (!WriteOK(tif, temp, tempSize))
- {
- TIFFErrorExtR(tif, module, "Cannot write");
- _TIFFfreeExt(tif, temp);
- return (0);
- }
- offsetRead += tempSize;
- offsetWrite += tempSize;
- td->td_stripbytecount_p[strip] += tempSize;
- toCopy -= tempSize;
- }
- _TIFFfreeExt(tif, temp);
-
- /* Append the data of this call */
- offsetWrite += cc;
- m = offsetWrite;
- }
-
- if (!WriteOK(tif, data, cc))
- {
- TIFFErrorExtR(tif, module, "Write error at scanline %lu",
- (unsigned long)tif->tif_row);
- return (0);
- }
- tif->tif_curoff = m;
- td->td_stripbytecount_p[strip] += cc;
-
- if ((int64_t)td->td_stripbytecount_p[strip] != old_byte_count)
- tif->tif_flags |= TIFF_DIRTYSTRIP;
-
- return (1);
-}
-
-/*
- * Internal version of TIFFFlushData that can be
- * called by ``encodestrip routines'' w/o concern
- * for infinite recursion.
- */
-int TIFFFlushData1(TIFF *tif)
-{
- if (tif->tif_rawcc > 0 && tif->tif_flags & TIFF_BUF4WRITE)
- {
- if (!isFillOrder(tif, tif->tif_dir.td_fillorder) &&
- (tif->tif_flags & TIFF_NOBITREV) == 0)
- TIFFReverseBits((uint8_t *)tif->tif_rawdata, tif->tif_rawcc);
- if (!TIFFAppendToStrip(
- tif, isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip,
- tif->tif_rawdata, tif->tif_rawcc))
- {
- /* We update those variables even in case of error since there's */
- /* code that doesn't really check the return code of this */
- /* function */
- tif->tif_rawcc = 0;
- tif->tif_rawcp = tif->tif_rawdata;
- return (0);
- }
- tif->tif_rawcc = 0;
- tif->tif_rawcp = tif->tif_rawdata;
- }
- return (1);
-}
-
-/*
- * Set the current write offset. This should only be
- * used to set the offset to a known previous location
- * (very carefully), or to 0 so that the next write gets
- * appended to the end of the file.
- */
-void TIFFSetWriteOffset(TIFF *tif, toff_t off)
-{
- tif->tif_curoff = off;
- tif->tif_lastvalidoff = 0;
-}
diff --git a/contrib/libs/libtiff/tif_zip.c b/contrib/libs/libtiff/tif_zip.c
deleted file mode 100644
index 9731dba263..0000000000
--- a/contrib/libs/libtiff/tif_zip.c
+++ /dev/null
@@ -1,756 +0,0 @@
-/*
- * Copyright (c) 1995-1997 Sam Leffler
- * Copyright (c) 1995-1997 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-#include "tiffiop.h"
-#ifdef ZIP_SUPPORT
-/*
- * TIFF Library.
- *
- * ZIP (aka Deflate) Compression Support
- *
- * This file is an interface to the zlib library written by
- * Jean-loup Gailly and Mark Adler. You must use version 1.0 or later
- * of the library.
- *
- * Optionally, libdeflate (https://github.com/ebiggers/libdeflate) may be used
- * to do the compression and decompression, but only for whole strips and tiles.
- * For scanline access, zlib will be sued as a fallback.
- */
-#include "tif_predict.h"
-#include "zlib.h"
-
-#if LIBDEFLATE_SUPPORT
-#error #include "libdeflate.h"
-#endif
-#define LIBDEFLATE_MAX_COMPRESSION_LEVEL 12
-
-#include <stdio.h>
-
-/*
- * Sigh, ZLIB_VERSION is defined as a string so there's no
- * way to do a proper check here. Instead we guess based
- * on the presence of #defines that were added between the
- * 0.95 and 1.0 distributions.
- */
-#if !defined(Z_NO_COMPRESSION) || !defined(Z_DEFLATED)
-#error "Antiquated ZLIB software; you must use version 1.0 or later"
-#endif
-
-#define SAFE_MSG(sp) ((sp)->stream.msg == NULL ? "" : (sp)->stream.msg)
-
-/*
- * State block for each open TIFF
- * file using ZIP compression/decompression.
- */
-typedef struct
-{
- TIFFPredictorState predict;
- z_stream stream;
- int read_error; /* whether a read error has occurred, and which should cause
- further reads in the same strip/tile to be aborted */
- int zipquality; /* compression level */
- int state; /* state flags */
- int subcodec; /* DEFLATE_SUBCODEC_ZLIB or DEFLATE_SUBCODEC_LIBDEFLATE */
-#if LIBDEFLATE_SUPPORT
- int libdeflate_state; /* -1 = until first time ZIPEncode() / ZIPDecode() is
- called, 0 = use zlib, 1 = use libdeflate */
- struct libdeflate_decompressor *libdeflate_dec;
- struct libdeflate_compressor *libdeflate_enc;
-#endif
-#define ZSTATE_INIT_DECODE 0x01
-#define ZSTATE_INIT_ENCODE 0x02
-
- TIFFVGetMethod vgetparent; /* super-class method */
- TIFFVSetMethod vsetparent; /* super-class method */
-} ZIPState;
-
-#define GetZIPState(tif) ((ZIPState *)(tif)->tif_data)
-#define ZIPDecoderState(tif) GetZIPState(tif)
-#define ZIPEncoderState(tif) GetZIPState(tif)
-
-static int ZIPEncode(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s);
-static int ZIPDecode(TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s);
-
-static int ZIPFixupTags(TIFF *tif)
-{
- (void)tif;
- return (1);
-}
-
-static int ZIPSetupDecode(TIFF *tif)
-{
- static const char module[] = "ZIPSetupDecode";
- ZIPState *sp = ZIPDecoderState(tif);
-
- assert(sp != NULL);
-
- /* if we were last encoding, terminate this mode */
- if (sp->state & ZSTATE_INIT_ENCODE)
- {
- deflateEnd(&sp->stream);
- sp->state = 0;
- }
-
- /* This function can possibly be called several times by */
- /* PredictorSetupDecode() if this function succeeds but */
- /* PredictorSetup() fails */
- if ((sp->state & ZSTATE_INIT_DECODE) == 0 &&
- inflateInit(&sp->stream) != Z_OK)
- {
- TIFFErrorExtR(tif, module, "%s", SAFE_MSG(sp));
- return (0);
- }
- else
- {
- sp->state |= ZSTATE_INIT_DECODE;
- return (1);
- }
-}
-
-/*
- * Setup state for decoding a strip.
- */
-static int ZIPPreDecode(TIFF *tif, uint16_t s)
-{
- ZIPState *sp = ZIPDecoderState(tif);
-
- (void)s;
- assert(sp != NULL);
-
- if ((sp->state & ZSTATE_INIT_DECODE) == 0)
- tif->tif_setupdecode(tif);
-
-#if LIBDEFLATE_SUPPORT
- sp->libdeflate_state = -1;
-#endif
- sp->stream.next_in = tif->tif_rawdata;
- assert(sizeof(sp->stream.avail_in) == 4); /* if this assert gets raised,
- we need to simplify this code to reflect a ZLib that is likely updated
- to deal with 8byte memory sizes, though this code will respond
- appropriately even before we simplify it */
- sp->stream.avail_in = (uint64_t)tif->tif_rawcc < 0xFFFFFFFFU
- ? (uInt)tif->tif_rawcc
- : 0xFFFFFFFFU;
- if (inflateReset(&sp->stream) == Z_OK)
- {
- sp->read_error = 0;
- return 1;
- }
- return 0;
-}
-
-static int ZIPDecode(TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s)
-{
- static const char module[] = "ZIPDecode";
- ZIPState *sp = ZIPDecoderState(tif);
-
- (void)s;
- assert(sp != NULL);
- assert(sp->state == ZSTATE_INIT_DECODE);
-
- if (sp->read_error)
- {
- memset(op, 0, (size_t)occ);
- TIFFErrorExtR(tif, module,
- "ZIPDecode: Scanline %" PRIu32 " cannot be read due to "
- "previous error",
- tif->tif_row);
- return 0;
- }
-
-#if LIBDEFLATE_SUPPORT
- if (sp->libdeflate_state == 1)
- return 0;
-
- /* If we have libdeflate support and we are asked to read a whole */
- /* strip/tile, then go for using it */
- do
- {
- TIFFDirectory *td = &tif->tif_dir;
-
- if (sp->libdeflate_state == 0)
- break;
- if (sp->subcodec == DEFLATE_SUBCODEC_ZLIB)
- break;
-
- /* Check if we are in the situation where we can use libdeflate */
- if (isTiled(tif))
- {
- if (TIFFTileSize64(tif) != (uint64_t)occ)
- break;
- }
- else
- {
- uint32_t strip_height = td->td_imagelength - tif->tif_row;
- if (strip_height > td->td_rowsperstrip)
- strip_height = td->td_rowsperstrip;
- if (TIFFVStripSize64(tif, strip_height) != (uint64_t)occ)
- break;
- }
-
- /* Check for overflow */
- if ((size_t)tif->tif_rawcc != (uint64_t)tif->tif_rawcc)
- break;
- if ((size_t)occ != (uint64_t)occ)
- break;
-
- /* Go for decompression using libdeflate */
- {
- enum libdeflate_result res;
- if (sp->libdeflate_dec == NULL)
- {
- sp->libdeflate_dec = libdeflate_alloc_decompressor();
- if (sp->libdeflate_dec == NULL)
- {
- break;
- }
- }
-
- sp->libdeflate_state = 1;
-
- res = libdeflate_zlib_decompress(sp->libdeflate_dec, tif->tif_rawcp,
- (size_t)tif->tif_rawcc, op,
- (size_t)occ, NULL);
-
- tif->tif_rawcp += tif->tif_rawcc;
- tif->tif_rawcc = 0;
-
- /* We accept LIBDEFLATE_INSUFFICIENT_SPACE has a return */
- /* There are odd files in the wild where the last strip, when */
- /* it is smaller in height than td_rowsperstrip, actually contains
- */
- /* data for td_rowsperstrip lines. Just ignore that silently. */
- if (res != LIBDEFLATE_SUCCESS &&
- res != LIBDEFLATE_INSUFFICIENT_SPACE)
- {
- memset(op, 0, (size_t)occ);
- TIFFErrorExtR(tif, module, "Decoding error at scanline %lu",
- (unsigned long)tif->tif_row);
- sp->read_error = 1;
- return 0;
- }
-
- return 1;
- }
- } while (0);
- sp->libdeflate_state = 0;
-#endif /* LIBDEFLATE_SUPPORT */
-
- sp->stream.next_in = tif->tif_rawcp;
-
- sp->stream.next_out = op;
- assert(sizeof(sp->stream.avail_out) == 4); /* if this assert gets raised,
- we need to simplify this code to reflect a ZLib that is likely updated
- to deal with 8byte memory sizes, though this code will respond
- appropriately even before we simplify it */
- do
- {
- int state;
- uInt avail_in_before = (uint64_t)tif->tif_rawcc <= 0xFFFFFFFFU
- ? (uInt)tif->tif_rawcc
- : 0xFFFFFFFFU;
- uInt avail_out_before =
- (uint64_t)occ < 0xFFFFFFFFU ? (uInt)occ : 0xFFFFFFFFU;
- sp->stream.avail_in = avail_in_before;
- sp->stream.avail_out = avail_out_before;
- /* coverity[overrun-buffer-arg] */
- state = inflate(&sp->stream, Z_PARTIAL_FLUSH);
- tif->tif_rawcc -= (avail_in_before - sp->stream.avail_in);
- occ -= (avail_out_before - sp->stream.avail_out);
- if (state == Z_STREAM_END)
- break;
- if (state == Z_DATA_ERROR)
- {
- memset(sp->stream.next_out, 0, sp->stream.avail_out);
- TIFFErrorExtR(tif, module, "Decoding error at scanline %lu, %s",
- (unsigned long)tif->tif_row, SAFE_MSG(sp));
- sp->read_error = 1;
- return (0);
- }
- if (state != Z_OK)
- {
- memset(sp->stream.next_out, 0, sp->stream.avail_out);
- TIFFErrorExtR(tif, module, "ZLib error: %s", SAFE_MSG(sp));
- sp->read_error = 1;
- return (0);
- }
- } while (occ > 0);
- if (occ != 0)
- {
- TIFFErrorExtR(tif, module,
- "Not enough data at scanline %lu (short %" PRIu64
- " bytes)",
- (unsigned long)tif->tif_row, (uint64_t)occ);
- memset(sp->stream.next_out, 0, sp->stream.avail_out);
- sp->read_error = 1;
- return (0);
- }
-
- tif->tif_rawcp = sp->stream.next_in;
-
- return (1);
-}
-
-static int ZIPSetupEncode(TIFF *tif)
-{
- static const char module[] = "ZIPSetupEncode";
- ZIPState *sp = ZIPEncoderState(tif);
- int cappedQuality;
-
- assert(sp != NULL);
- if (sp->state & ZSTATE_INIT_DECODE)
- {
- inflateEnd(&sp->stream);
- sp->state = 0;
- }
-
- cappedQuality = sp->zipquality;
- if (cappedQuality > Z_BEST_COMPRESSION)
- cappedQuality = Z_BEST_COMPRESSION;
-
- if (deflateInit(&sp->stream, cappedQuality) != Z_OK)
- {
- TIFFErrorExtR(tif, module, "%s", SAFE_MSG(sp));
- return (0);
- }
- else
- {
- sp->state |= ZSTATE_INIT_ENCODE;
- return (1);
- }
-}
-
-/*
- * Reset encoding state at the start of a strip.
- */
-static int ZIPPreEncode(TIFF *tif, uint16_t s)
-{
- ZIPState *sp = ZIPEncoderState(tif);
-
- (void)s;
- assert(sp != NULL);
- if (sp->state != ZSTATE_INIT_ENCODE)
- tif->tif_setupencode(tif);
-
-#if LIBDEFLATE_SUPPORT
- sp->libdeflate_state = -1;
-#endif
- sp->stream.next_out = tif->tif_rawdata;
- assert(sizeof(sp->stream.avail_out) == 4); /* if this assert gets raised,
- we need to simplify this code to reflect a ZLib that is likely updated
- to deal with 8byte memory sizes, though this code will respond
- appropriately even before we simplify it */
- sp->stream.avail_out = (uint64_t)tif->tif_rawdatasize <= 0xFFFFFFFFU
- ? (uInt)tif->tif_rawdatasize
- : 0xFFFFFFFFU;
- return (deflateReset(&sp->stream) == Z_OK);
-}
-
-/*
- * Encode a chunk of pixels.
- */
-static int ZIPEncode(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s)
-{
- static const char module[] = "ZIPEncode";
- ZIPState *sp = ZIPEncoderState(tif);
-
- assert(sp != NULL);
- assert(sp->state == ZSTATE_INIT_ENCODE);
-
- (void)s;
-
-#if LIBDEFLATE_SUPPORT
- if (sp->libdeflate_state == 1)
- return 0;
-
- /* If we have libdeflate support and we are asked to write a whole */
- /* strip/tile, then go for using it */
- do
- {
- TIFFDirectory *td = &tif->tif_dir;
-
- if (sp->libdeflate_state == 0)
- break;
- if (sp->subcodec == DEFLATE_SUBCODEC_ZLIB)
- break;
-
- /* Libdeflate does not support the 0-compression level */
- if (sp->zipquality == Z_NO_COMPRESSION)
- break;
-
- /* Check if we are in the situation where we can use libdeflate */
- if (isTiled(tif))
- {
- if (TIFFTileSize64(tif) != (uint64_t)cc)
- break;
- }
- else
- {
- uint32_t strip_height = td->td_imagelength - tif->tif_row;
- if (strip_height > td->td_rowsperstrip)
- strip_height = td->td_rowsperstrip;
- if (TIFFVStripSize64(tif, strip_height) != (uint64_t)cc)
- break;
- }
-
- /* Check for overflow */
- if ((size_t)tif->tif_rawdatasize != (uint64_t)tif->tif_rawdatasize)
- break;
- if ((size_t)cc != (uint64_t)cc)
- break;
-
- /* Go for compression using libdeflate */
- {
- size_t nCompressedBytes;
- if (sp->libdeflate_enc == NULL)
- {
- /* To get results as good as zlib, we asked for an extra */
- /* level of compression */
- sp->libdeflate_enc = libdeflate_alloc_compressor(
- sp->zipquality == Z_DEFAULT_COMPRESSION ? 7
- : sp->zipquality >= 6 && sp->zipquality <= 9
- ? sp->zipquality + 1
- : sp->zipquality);
- if (sp->libdeflate_enc == NULL)
- {
- TIFFErrorExtR(tif, module, "Cannot allocate compressor");
- break;
- }
- }
-
- /* Make sure the output buffer is large enough for the worse case.
- */
- /* In TIFFWriteBufferSetup(), when libtiff allocates the buffer */
- /* we've taken a 10% margin over the uncompressed size, which should
- */
- /* be large enough even for the the worse case scenario. */
- if (libdeflate_zlib_compress_bound(sp->libdeflate_enc, (size_t)cc) >
- (size_t)tif->tif_rawdatasize)
- {
- break;
- }
-
- sp->libdeflate_state = 1;
- nCompressedBytes = libdeflate_zlib_compress(
- sp->libdeflate_enc, bp, (size_t)cc, tif->tif_rawdata,
- (size_t)tif->tif_rawdatasize);
-
- if (nCompressedBytes == 0)
- {
- TIFFErrorExtR(tif, module, "Encoder error at scanline %lu",
- (unsigned long)tif->tif_row);
- return 0;
- }
-
- tif->tif_rawcc = nCompressedBytes;
-
- if (!TIFFFlushData1(tif))
- return 0;
-
- return 1;
- }
- } while (0);
- sp->libdeflate_state = 0;
-#endif /* LIBDEFLATE_SUPPORT */
-
- sp->stream.next_in = bp;
- assert(sizeof(sp->stream.avail_in) == 4); /* if this assert gets raised,
- we need to simplify this code to reflect a ZLib that is likely updated
- to deal with 8byte memory sizes, though this code will respond
- appropriately even before we simplify it */
- do
- {
- uInt avail_in_before =
- (uint64_t)cc <= 0xFFFFFFFFU ? (uInt)cc : 0xFFFFFFFFU;
- sp->stream.avail_in = avail_in_before;
- /* coverity[overrun-buffer-arg] */
- if (deflate(&sp->stream, Z_NO_FLUSH) != Z_OK)
- {
- TIFFErrorExtR(tif, module, "Encoder error: %s", SAFE_MSG(sp));
- return (0);
- }
- if (sp->stream.avail_out == 0)
- {
- tif->tif_rawcc = tif->tif_rawdatasize;
- if (!TIFFFlushData1(tif))
- return 0;
- sp->stream.next_out = tif->tif_rawdata;
- sp->stream.avail_out = (uint64_t)tif->tif_rawdatasize <= 0xFFFFFFFFU
- ? (uInt)tif->tif_rawdatasize
- : 0xFFFFFFFFU;
- }
- cc -= (avail_in_before - sp->stream.avail_in);
- } while (cc > 0);
- return (1);
-}
-
-/*
- * Finish off an encoded strip by flushing the last
- * string and tacking on an End Of Information code.
- */
-static int ZIPPostEncode(TIFF *tif)
-{
- static const char module[] = "ZIPPostEncode";
- ZIPState *sp = ZIPEncoderState(tif);
- int state;
-
-#if LIBDEFLATE_SUPPORT
- if (sp->libdeflate_state == 1)
- return 1;
-#endif
-
- sp->stream.avail_in = 0;
- do
- {
- state = deflate(&sp->stream, Z_FINISH);
- switch (state)
- {
- case Z_STREAM_END:
- case Z_OK:
- if ((tmsize_t)sp->stream.avail_out != tif->tif_rawdatasize)
- {
- tif->tif_rawcc =
- tif->tif_rawdatasize - sp->stream.avail_out;
- if (!TIFFFlushData1(tif))
- return 0;
- sp->stream.next_out = tif->tif_rawdata;
- sp->stream.avail_out =
- (uint64_t)tif->tif_rawdatasize <= 0xFFFFFFFFU
- ? (uInt)tif->tif_rawdatasize
- : 0xFFFFFFFFU;
- }
- break;
- default:
- TIFFErrorExtR(tif, module, "ZLib error: %s", SAFE_MSG(sp));
- return (0);
- }
- } while (state != Z_STREAM_END);
- return (1);
-}
-
-static void ZIPCleanup(TIFF *tif)
-{
- ZIPState *sp = GetZIPState(tif);
-
- assert(sp != 0);
-
- (void)TIFFPredictorCleanup(tif);
-
- tif->tif_tagmethods.vgetfield = sp->vgetparent;
- tif->tif_tagmethods.vsetfield = sp->vsetparent;
-
- if (sp->state & ZSTATE_INIT_ENCODE)
- {
- deflateEnd(&sp->stream);
- sp->state = 0;
- }
- else if (sp->state & ZSTATE_INIT_DECODE)
- {
- inflateEnd(&sp->stream);
- sp->state = 0;
- }
-
-#if LIBDEFLATE_SUPPORT
- if (sp->libdeflate_dec)
- libdeflate_free_decompressor(sp->libdeflate_dec);
- if (sp->libdeflate_enc)
- libdeflate_free_compressor(sp->libdeflate_enc);
-#endif
-
- _TIFFfreeExt(tif, sp);
- tif->tif_data = NULL;
-
- _TIFFSetDefaultCompressionState(tif);
-}
-
-static int ZIPVSetField(TIFF *tif, uint32_t tag, va_list ap)
-{
- static const char module[] = "ZIPVSetField";
- ZIPState *sp = GetZIPState(tif);
-
- switch (tag)
- {
- case TIFFTAG_ZIPQUALITY:
- sp->zipquality = (int)va_arg(ap, int);
- if (sp->zipquality < Z_DEFAULT_COMPRESSION ||
- sp->zipquality > LIBDEFLATE_MAX_COMPRESSION_LEVEL)
- {
- TIFFErrorExtR(
- tif, module,
- "Invalid ZipQuality value. Should be in [-1,%d] range",
- LIBDEFLATE_MAX_COMPRESSION_LEVEL);
- return 0;
- }
-
- if (sp->state & ZSTATE_INIT_ENCODE)
- {
- int cappedQuality = sp->zipquality;
- if (cappedQuality > Z_BEST_COMPRESSION)
- cappedQuality = Z_BEST_COMPRESSION;
- if (deflateParams(&sp->stream, cappedQuality,
- Z_DEFAULT_STRATEGY) != Z_OK)
- {
- TIFFErrorExtR(tif, module, "ZLib error: %s", SAFE_MSG(sp));
- return (0);
- }
- }
-
-#if LIBDEFLATE_SUPPORT
- if (sp->libdeflate_enc)
- {
- libdeflate_free_compressor(sp->libdeflate_enc);
- sp->libdeflate_enc = NULL;
- }
-#endif
-
- return (1);
-
- case TIFFTAG_DEFLATE_SUBCODEC:
- sp->subcodec = (int)va_arg(ap, int);
- if (sp->subcodec != DEFLATE_SUBCODEC_ZLIB &&
- sp->subcodec != DEFLATE_SUBCODEC_LIBDEFLATE)
- {
- TIFFErrorExtR(tif, module, "Invalid DeflateCodec value.");
- return 0;
- }
-#if !LIBDEFLATE_SUPPORT
- if (sp->subcodec == DEFLATE_SUBCODEC_LIBDEFLATE)
- {
- TIFFErrorExtR(tif, module,
- "DeflateCodec = DEFLATE_SUBCODEC_LIBDEFLATE "
- "unsupported in this build");
- return 0;
- }
-#endif
- return 1;
-
- default:
- return (*sp->vsetparent)(tif, tag, ap);
- }
- /*NOTREACHED*/
-}
-
-static int ZIPVGetField(TIFF *tif, uint32_t tag, va_list ap)
-{
- ZIPState *sp = GetZIPState(tif);
-
- switch (tag)
- {
- case TIFFTAG_ZIPQUALITY:
- *va_arg(ap, int *) = sp->zipquality;
- break;
-
- case TIFFTAG_DEFLATE_SUBCODEC:
- *va_arg(ap, int *) = sp->subcodec;
- break;
-
- default:
- return (*sp->vgetparent)(tif, tag, ap);
- }
- return (1);
-}
-
-static const TIFFField zipFields[] = {
- {TIFFTAG_ZIPQUALITY, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT,
- TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "", NULL},
- {TIFFTAG_DEFLATE_SUBCODEC, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT,
- TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "", NULL},
-};
-
-int TIFFInitZIP(TIFF *tif, int scheme)
-{
- static const char module[] = "TIFFInitZIP";
- ZIPState *sp;
-
- assert((scheme == COMPRESSION_DEFLATE) ||
- (scheme == COMPRESSION_ADOBE_DEFLATE));
-#ifdef NDEBUG
- (void)scheme;
-#endif
-
- /*
- * Merge codec-specific tag information.
- */
- if (!_TIFFMergeFields(tif, zipFields, TIFFArrayCount(zipFields)))
- {
- TIFFErrorExtR(tif, module,
- "Merging Deflate codec-specific tags failed");
- return 0;
- }
-
- /*
- * Allocate state block so tag methods have storage to record values.
- */
- tif->tif_data = (uint8_t *)_TIFFcallocExt(tif, sizeof(ZIPState), 1);
- if (tif->tif_data == NULL)
- goto bad;
- sp = GetZIPState(tif);
- sp->stream.zalloc = NULL;
- sp->stream.zfree = NULL;
- sp->stream.opaque = NULL;
- sp->stream.data_type = Z_BINARY;
-
- /*
- * Override parent get/set field methods.
- */
- sp->vgetparent = tif->tif_tagmethods.vgetfield;
- tif->tif_tagmethods.vgetfield = ZIPVGetField; /* hook for codec tags */
- sp->vsetparent = tif->tif_tagmethods.vsetfield;
- tif->tif_tagmethods.vsetfield = ZIPVSetField; /* hook for codec tags */
-
- /* Default values for codec-specific fields */
- sp->zipquality = Z_DEFAULT_COMPRESSION; /* default comp. level */
- sp->state = 0;
-#if LIBDEFLATE_SUPPORT
- sp->subcodec = DEFLATE_SUBCODEC_LIBDEFLATE;
-#else
- sp->subcodec = DEFLATE_SUBCODEC_ZLIB;
-#endif
-
- /*
- * Install codec methods.
- */
- tif->tif_fixuptags = ZIPFixupTags;
- tif->tif_setupdecode = ZIPSetupDecode;
- tif->tif_predecode = ZIPPreDecode;
- tif->tif_decoderow = ZIPDecode;
- tif->tif_decodestrip = ZIPDecode;
- tif->tif_decodetile = ZIPDecode;
- tif->tif_setupencode = ZIPSetupEncode;
- tif->tif_preencode = ZIPPreEncode;
- tif->tif_postencode = ZIPPostEncode;
- tif->tif_encoderow = ZIPEncode;
- tif->tif_encodestrip = ZIPEncode;
- tif->tif_encodetile = ZIPEncode;
- tif->tif_cleanup = ZIPCleanup;
- /*
- * Setup predictor setup.
- */
- (void)TIFFPredictorInit(tif);
- return (1);
-bad:
- TIFFErrorExtR(tif, module, "No space for ZIP state block");
- return (0);
-}
-#endif /* ZIP_SUPPORT */
diff --git a/contrib/libs/libtiff/tif_zstd.c b/contrib/libs/libtiff/tif_zstd.c
deleted file mode 100644
index fc73ce9cf5..0000000000
--- a/contrib/libs/libtiff/tif_zstd.c
+++ /dev/null
@@ -1,438 +0,0 @@
-/*
- * Copyright (c) 2017, Planet Labs
- * Author: <even.rouault at spatialys.com>
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-#include "tiffiop.h"
-#ifdef ZSTD_SUPPORT
-/*
- * TIFF Library.
- *
- * ZSTD Compression Support
- *
- */
-
-#include "tif_predict.h"
-#include "zstd.h"
-
-#include <stdio.h>
-
-/*
- * State block for each open TIFF file using ZSTD compression/decompression.
- */
-typedef struct
-{
- TIFFPredictorState predict;
- ZSTD_DStream *dstream;
- ZSTD_CStream *cstream;
- int compression_level; /* compression level */
- ZSTD_outBuffer out_buffer;
- int state; /* state flags */
-#define LSTATE_INIT_DECODE 0x01
-#define LSTATE_INIT_ENCODE 0x02
-
- TIFFVGetMethod vgetparent; /* super-class method */
- TIFFVSetMethod vsetparent; /* super-class method */
-} ZSTDState;
-
-#define GetZSTDState(tif) ((ZSTDState *)(tif)->tif_data)
-#define ZSTDDecoderState(tif) GetZSTDState(tif)
-#define ZSTDEncoderState(tif) GetZSTDState(tif)
-
-static int ZSTDEncode(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s);
-static int ZSTDDecode(TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s);
-
-static int ZSTDFixupTags(TIFF *tif)
-{
- (void)tif;
- return 1;
-}
-
-static int ZSTDSetupDecode(TIFF *tif)
-{
- ZSTDState *sp = ZSTDDecoderState(tif);
-
- assert(sp != NULL);
-
- /* if we were last encoding, terminate this mode */
- if (sp->state & LSTATE_INIT_ENCODE)
- {
- ZSTD_freeCStream(sp->cstream);
- sp->cstream = NULL;
- sp->state = 0;
- }
-
- sp->state |= LSTATE_INIT_DECODE;
- return 1;
-}
-
-/*
- * Setup state for decoding a strip.
- */
-static int ZSTDPreDecode(TIFF *tif, uint16_t s)
-{
- static const char module[] = "ZSTDPreDecode";
- ZSTDState *sp = ZSTDDecoderState(tif);
- size_t zstd_ret;
-
- (void)s;
- assert(sp != NULL);
-
- if ((sp->state & LSTATE_INIT_DECODE) == 0)
- tif->tif_setupdecode(tif);
-
- if (sp->dstream == NULL)
- {
- sp->dstream = ZSTD_createDStream();
- if (sp->dstream == NULL)
- {
- TIFFErrorExtR(tif, module, "Cannot allocate decompression stream");
- return 0;
- }
- }
-
- zstd_ret = ZSTD_initDStream(sp->dstream);
- if (ZSTD_isError(zstd_ret))
- {
- TIFFErrorExtR(tif, module, "Error in ZSTD_initDStream(): %s",
- ZSTD_getErrorName(zstd_ret));
- return 0;
- }
-
- return 1;
-}
-
-static int ZSTDDecode(TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s)
-{
- static const char module[] = "ZSTDDecode";
- ZSTDState *sp = ZSTDDecoderState(tif);
- ZSTD_inBuffer in_buffer;
- ZSTD_outBuffer out_buffer;
- size_t zstd_ret;
-
- (void)s;
- assert(sp != NULL);
- assert(sp->state == LSTATE_INIT_DECODE);
-
- in_buffer.src = tif->tif_rawcp;
- in_buffer.size = (size_t)tif->tif_rawcc;
- in_buffer.pos = 0;
-
- out_buffer.dst = op;
- out_buffer.size = (size_t)occ;
- out_buffer.pos = 0;
-
- do
- {
- zstd_ret = ZSTD_decompressStream(sp->dstream, &out_buffer, &in_buffer);
- if (ZSTD_isError(zstd_ret))
- {
- memset(op + out_buffer.pos, 0, out_buffer.size - out_buffer.pos);
- TIFFErrorExtR(tif, module, "Error in ZSTD_decompressStream(): %s",
- ZSTD_getErrorName(zstd_ret));
- return 0;
- }
- } while (zstd_ret != 0 && in_buffer.pos < in_buffer.size &&
- out_buffer.pos < out_buffer.size);
-
- if (out_buffer.pos < (size_t)occ)
- {
- memset(op + out_buffer.pos, 0, out_buffer.size - out_buffer.pos);
- TIFFErrorExtR(tif, module,
- "Not enough data at scanline %lu (short %lu bytes)",
- (unsigned long)tif->tif_row,
- (unsigned long)((size_t)occ - out_buffer.pos));
- return 0;
- }
-
- tif->tif_rawcp += in_buffer.pos;
- tif->tif_rawcc -= in_buffer.pos;
-
- return 1;
-}
-
-static int ZSTDSetupEncode(TIFF *tif)
-{
- ZSTDState *sp = ZSTDEncoderState(tif);
-
- assert(sp != NULL);
- if (sp->state & LSTATE_INIT_DECODE)
- {
- ZSTD_freeDStream(sp->dstream);
- sp->dstream = NULL;
- sp->state = 0;
- }
-
- sp->state |= LSTATE_INIT_ENCODE;
- return 1;
-}
-
-/*
- * Reset encoding state at the start of a strip.
- */
-static int ZSTDPreEncode(TIFF *tif, uint16_t s)
-{
- static const char module[] = "ZSTDPreEncode";
- ZSTDState *sp = ZSTDEncoderState(tif);
- size_t zstd_ret;
-
- (void)s;
- assert(sp != NULL);
- if (sp->state != LSTATE_INIT_ENCODE)
- tif->tif_setupencode(tif);
-
- if (sp->cstream == NULL)
- {
- sp->cstream = ZSTD_createCStream();
- if (sp->cstream == NULL)
- {
- TIFFErrorExtR(tif, module, "Cannot allocate compression stream");
- return 0;
- }
- }
-
- zstd_ret = ZSTD_initCStream(sp->cstream, sp->compression_level);
- if (ZSTD_isError(zstd_ret))
- {
- TIFFErrorExtR(tif, module, "Error in ZSTD_initCStream(): %s",
- ZSTD_getErrorName(zstd_ret));
- return 0;
- }
-
- sp->out_buffer.dst = tif->tif_rawdata;
- sp->out_buffer.size = (size_t)tif->tif_rawdatasize;
- sp->out_buffer.pos = 0;
-
- return 1;
-}
-
-/*
- * Encode a chunk of pixels.
- */
-static int ZSTDEncode(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s)
-{
- static const char module[] = "ZSTDEncode";
- ZSTDState *sp = ZSTDEncoderState(tif);
- ZSTD_inBuffer in_buffer;
- size_t zstd_ret;
-
- assert(sp != NULL);
- assert(sp->state == LSTATE_INIT_ENCODE);
-
- (void)s;
-
- in_buffer.src = bp;
- in_buffer.size = (size_t)cc;
- in_buffer.pos = 0;
-
- do
- {
- zstd_ret =
- ZSTD_compressStream(sp->cstream, &sp->out_buffer, &in_buffer);
- if (ZSTD_isError(zstd_ret))
- {
- TIFFErrorExtR(tif, module, "Error in ZSTD_compressStream(): %s",
- ZSTD_getErrorName(zstd_ret));
- return 0;
- }
- if (sp->out_buffer.pos == sp->out_buffer.size)
- {
- tif->tif_rawcc = tif->tif_rawdatasize;
- if (!TIFFFlushData1(tif))
- return 0;
- sp->out_buffer.dst = tif->tif_rawcp;
- sp->out_buffer.pos = 0;
- }
- } while (in_buffer.pos < in_buffer.size);
-
- return 1;
-}
-
-/*
- * Finish off an encoded strip by flushing it.
- */
-static int ZSTDPostEncode(TIFF *tif)
-{
- static const char module[] = "ZSTDPostEncode";
- ZSTDState *sp = ZSTDEncoderState(tif);
- size_t zstd_ret;
-
- do
- {
- zstd_ret = ZSTD_endStream(sp->cstream, &sp->out_buffer);
- if (ZSTD_isError(zstd_ret))
- {
- TIFFErrorExtR(tif, module, "Error in ZSTD_endStream(): %s",
- ZSTD_getErrorName(zstd_ret));
- return 0;
- }
- if (sp->out_buffer.pos > 0)
- {
- tif->tif_rawcc = sp->out_buffer.pos;
- if (!TIFFFlushData1(tif))
- return 0;
- sp->out_buffer.dst = tif->tif_rawcp;
- sp->out_buffer.pos = 0;
- }
- } while (zstd_ret != 0);
- return 1;
-}
-
-static void ZSTDCleanup(TIFF *tif)
-{
- ZSTDState *sp = GetZSTDState(tif);
-
- assert(sp != 0);
-
- (void)TIFFPredictorCleanup(tif);
-
- tif->tif_tagmethods.vgetfield = sp->vgetparent;
- tif->tif_tagmethods.vsetfield = sp->vsetparent;
-
- if (sp->dstream)
- {
- ZSTD_freeDStream(sp->dstream);
- sp->dstream = NULL;
- }
- if (sp->cstream)
- {
- ZSTD_freeCStream(sp->cstream);
- sp->cstream = NULL;
- }
- _TIFFfreeExt(tif, sp);
- tif->tif_data = NULL;
-
- _TIFFSetDefaultCompressionState(tif);
-}
-
-static int ZSTDVSetField(TIFF *tif, uint32_t tag, va_list ap)
-{
- static const char module[] = "ZSTDVSetField";
- ZSTDState *sp = GetZSTDState(tif);
-
- switch (tag)
- {
- case TIFFTAG_ZSTD_LEVEL:
- sp->compression_level = (int)va_arg(ap, int);
- if (sp->compression_level <= 0 ||
- sp->compression_level > ZSTD_maxCLevel())
- {
- TIFFWarningExtR(tif, module,
- "ZSTD_LEVEL should be between 1 and %d",
- ZSTD_maxCLevel());
- }
- return 1;
- default:
- return (*sp->vsetparent)(tif, tag, ap);
- }
- /*NOTREACHED*/
-}
-
-static int ZSTDVGetField(TIFF *tif, uint32_t tag, va_list ap)
-{
- ZSTDState *sp = GetZSTDState(tif);
-
- switch (tag)
- {
- case TIFFTAG_ZSTD_LEVEL:
- *va_arg(ap, int *) = sp->compression_level;
- break;
- default:
- return (*sp->vgetparent)(tif, tag, ap);
- }
- return 1;
-}
-
-static const TIFFField ZSTDFields[] = {
- {TIFFTAG_ZSTD_LEVEL, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT,
- TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "ZSTD compression_level",
- NULL},
-};
-
-int TIFFInitZSTD(TIFF *tif, int scheme)
-{
- static const char module[] = "TIFFInitZSTD";
- ZSTDState *sp;
-
- (void)scheme;
- assert(scheme == COMPRESSION_ZSTD);
-
- /*
- * Merge codec-specific tag information.
- */
- if (!_TIFFMergeFields(tif, ZSTDFields, TIFFArrayCount(ZSTDFields)))
- {
- TIFFErrorExtR(tif, module, "Merging ZSTD codec-specific tags failed");
- return 0;
- }
-
- /*
- * Allocate state block so tag methods have storage to record values.
- */
- tif->tif_data = (uint8_t *)_TIFFmallocExt(tif, sizeof(ZSTDState));
- if (tif->tif_data == NULL)
- goto bad;
- sp = GetZSTDState(tif);
-
- /*
- * Override parent get/set field methods.
- */
- sp->vgetparent = tif->tif_tagmethods.vgetfield;
- tif->tif_tagmethods.vgetfield = ZSTDVGetField; /* hook for codec tags */
- sp->vsetparent = tif->tif_tagmethods.vsetfield;
- tif->tif_tagmethods.vsetfield = ZSTDVSetField; /* hook for codec tags */
-
- /* Default values for codec-specific fields */
- sp->compression_level = 9; /* default comp. level */
- sp->state = 0;
- sp->dstream = 0;
- sp->cstream = 0;
- sp->out_buffer.dst = NULL;
- sp->out_buffer.size = 0;
- sp->out_buffer.pos = 0;
-
- /*
- * Install codec methods.
- */
- tif->tif_fixuptags = ZSTDFixupTags;
- tif->tif_setupdecode = ZSTDSetupDecode;
- tif->tif_predecode = ZSTDPreDecode;
- tif->tif_decoderow = ZSTDDecode;
- tif->tif_decodestrip = ZSTDDecode;
- tif->tif_decodetile = ZSTDDecode;
- tif->tif_setupencode = ZSTDSetupEncode;
- tif->tif_preencode = ZSTDPreEncode;
- tif->tif_postencode = ZSTDPostEncode;
- tif->tif_encoderow = ZSTDEncode;
- tif->tif_encodestrip = ZSTDEncode;
- tif->tif_encodetile = ZSTDEncode;
- tif->tif_cleanup = ZSTDCleanup;
- /*
- * Setup predictor setup.
- */
- (void)TIFFPredictorInit(tif);
- return 1;
-bad:
- TIFFErrorExtR(tif, module, "No space for ZSTD state block");
- return 0;
-}
-#endif /* ZSTD_SUPPORT */
diff --git a/contrib/libs/libtiff/tiff.h b/contrib/libs/libtiff/tiff.h
deleted file mode 100644
index d8da33dc38..0000000000
--- a/contrib/libs/libtiff/tiff.h
+++ /dev/null
@@ -1,899 +0,0 @@
-/*
- * Copyright (c) 1988-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-#ifndef _TIFF_
-#define _TIFF_
-
-#include "tiffconf.h"
-
-/*
- * Tag Image File Format (TIFF)
- *
- * Based on Rev 6.0 from:
- * Developer's Desk
- * Aldus Corporation
- * 411 First Ave. South
- * Suite 200
- * Seattle, WA 98104
- * 206-622-5500
- *
- * (http://partners.adobe.com/asn/developer/PDFS/TN/TIFF6.pdf)
- *
- * For BigTIFF design notes see the following links
- * http://www.remotesensing.org/libtiff/bigtiffdesign.html
- * http://www.awaresystems.be/imaging/tiff/bigtiff.html
- */
-
-#define TIFF_VERSION_CLASSIC 42
-#define TIFF_VERSION_BIG 43
-
-#define TIFF_BIGENDIAN 0x4d4d
-#define TIFF_LITTLEENDIAN 0x4949
-#define MDI_LITTLEENDIAN 0x5045
-#define MDI_BIGENDIAN 0x4550
-
-/*
- * Intrinsic data types required by the file format:
- *
- * 8-bit quantities int8_t/uint_8_t
- * 16-bit quantities int16_t/uint_16_t
- * 32-bit quantities int32_t/uint_32_t
- * 64-bit quantities int64_t/uint_64_t
- * strings unsigned char*
- */
-#ifdef __GNUC__
-#define TIFF_GCC_DEPRECATED __attribute__((deprecated))
-#else
-#define TIFF_GCC_DEPRECATED
-#endif
-#ifdef _MSC_VER
-#define TIFF_MSC_DEPRECATED \
- __declspec(deprecated("libtiff type deprecated; please use corresponding " \
- "C99 stdint.h type"))
-#else
-#define TIFF_MSC_DEPRECATED
-#endif
-
-#ifndef TIFF_DISABLE_DEPRECATED
-typedef TIFF_MSC_DEPRECATED int8_t int8 TIFF_GCC_DEPRECATED;
-typedef TIFF_MSC_DEPRECATED uint8_t uint8 TIFF_GCC_DEPRECATED;
-
-typedef TIFF_MSC_DEPRECATED int16_t int16 TIFF_GCC_DEPRECATED;
-typedef TIFF_MSC_DEPRECATED uint16_t uint16 TIFF_GCC_DEPRECATED;
-
-typedef TIFF_MSC_DEPRECATED int32_t int32 TIFF_GCC_DEPRECATED;
-typedef TIFF_MSC_DEPRECATED uint32_t uint32 TIFF_GCC_DEPRECATED;
-
-typedef TIFF_MSC_DEPRECATED int64_t int64 TIFF_GCC_DEPRECATED;
-typedef TIFF_MSC_DEPRECATED uint64_t uint64 TIFF_GCC_DEPRECATED;
-#endif /* TIFF_DISABLE_DEPRECATED */
-
-/*
- * Some types as promoted in a variable argument list
- * We use uint16_vap rather then directly using int, because this way
- * we document the type we actually want to pass through, conceptually,
- * rather then confusing the issue by merely stating the type it gets
- * promoted to
- */
-
-typedef int uint16_vap;
-
-/*
- * TIFF header.
- */
-typedef struct
-{
- uint16_t tiff_magic; /* magic number (defines byte order) */
- uint16_t tiff_version; /* TIFF version number */
-} TIFFHeaderCommon;
-typedef struct
-{
- uint16_t tiff_magic; /* magic number (defines byte order) */
- uint16_t tiff_version; /* TIFF version number */
- uint32_t tiff_diroff; /* byte offset to first directory */
-} TIFFHeaderClassic;
-typedef struct
-{
- uint16_t tiff_magic; /* magic number (defines byte order) */
- uint16_t tiff_version; /* TIFF version number */
- uint16_t tiff_offsetsize; /* size of offsets, should be 8 */
- uint16_t tiff_unused; /* unused word, should be 0 */
- uint64_t tiff_diroff; /* byte offset to first directory */
-} TIFFHeaderBig;
-
-/*
- * NB: In the comments below,
- * - items marked with a + are obsoleted by revision 5.0,
- * - items marked with a ! are introduced in revision 6.0.
- * - items marked with a % are introduced post revision 6.0.
- * - items marked with a $ are obsoleted by revision 6.0.
- * - items marked with a & are introduced by Adobe DNG specification.
- */
-
-/*
- * Tag data type information.
- *
- * Note: RATIONALs are the ratio of two 32-bit integer values.
- *--:
- * Note2: TIFF_IFD8 data type is used in tiffFields[]-tag definition in order to
- distinguish the write-handling of those tags between ClassicTIFF and BigTiff:
- For ClassicTIFF libtiff writes a 32-bit value and the TIFF_IFD
- type-id into the file For BigTIFF libtiff writes a 64-bit value and the
- TIFF_IFD8 type-id into the file
- */
-typedef enum
-{
- TIFF_NOTYPE = 0, /* placeholder */
- TIFF_BYTE = 1, /* 8-bit unsigned integer */
- TIFF_ASCII = 2, /* 8-bit bytes w/ last byte null */
- TIFF_SHORT = 3, /* 16-bit unsigned integer */
- TIFF_LONG = 4, /* 32-bit unsigned integer */
- TIFF_RATIONAL = 5, /* 64-bit unsigned fraction */
- TIFF_SBYTE = 6, /* !8-bit signed integer */
- TIFF_UNDEFINED = 7, /* !8-bit untyped data */
- TIFF_SSHORT = 8, /* !16-bit signed integer */
- TIFF_SLONG = 9, /* !32-bit signed integer */
- TIFF_SRATIONAL = 10, /* !64-bit signed fraction */
- TIFF_FLOAT = 11, /* !32-bit IEEE floating point */
- TIFF_DOUBLE = 12, /* !64-bit IEEE floating point */
- TIFF_IFD = 13, /* %32-bit unsigned integer (offset) */
- TIFF_LONG8 = 16, /* BigTIFF 64-bit unsigned integer */
- TIFF_SLONG8 = 17, /* BigTIFF 64-bit signed integer */
- TIFF_IFD8 = 18 /* BigTIFF 64-bit unsigned integer (offset) */
-} TIFFDataType;
-
-/*
- * TIFF Tag Definitions.
- */
-/* clang-format off */ /* for better readability of tag comments */
-#define TIFFTAG_SUBFILETYPE 254 /* subfile data descriptor */
-#define FILETYPE_REDUCEDIMAGE 0x1 /* reduced resolution version */
-#define FILETYPE_PAGE 0x2 /* one page of many */
-#define FILETYPE_MASK 0x4 /* transparency mask */
-#define TIFFTAG_OSUBFILETYPE 255 /* +kind of data in subfile */
-#define OFILETYPE_IMAGE 1 /* full resolution image data */
-#define OFILETYPE_REDUCEDIMAGE 2 /* reduced size image data */
-#define OFILETYPE_PAGE 3 /* one page of many */
-#define TIFFTAG_IMAGEWIDTH 256 /* image width in pixels */
-#define TIFFTAG_IMAGELENGTH 257 /* image height in pixels */
-#define TIFFTAG_BITSPERSAMPLE 258 /* bits per channel (sample) */
-#define TIFFTAG_COMPRESSION 259 /* data compression technique */
-#define COMPRESSION_NONE 1 /* dump mode */
-#define COMPRESSION_CCITTRLE 2 /* CCITT modified Huffman RLE */
-#define COMPRESSION_CCITTFAX3 3 /* CCITT Group 3 fax encoding */
-#define COMPRESSION_CCITT_T4 3 /* CCITT T.4 (TIFF 6 name) */
-#define COMPRESSION_CCITTFAX4 4 /* CCITT Group 4 fax encoding */
-#define COMPRESSION_CCITT_T6 4 /* CCITT T.6 (TIFF 6 name) */
-#define COMPRESSION_LZW 5 /* Lempel-Ziv & Welch */
-#define COMPRESSION_OJPEG 6 /* !6.0 JPEG */
-#define COMPRESSION_JPEG 7 /* %JPEG DCT compression */
-#define COMPRESSION_T85 9 /* !TIFF/FX T.85 JBIG compression */
-#define COMPRESSION_T43 10 /* !TIFF/FX T.43 colour by layered JBIG compression */
-#define COMPRESSION_NEXT 32766 /* NeXT 2-bit RLE */
-#define COMPRESSION_CCITTRLEW 32771 /* #1 w/ word alignment */
-#define COMPRESSION_PACKBITS 32773 /* Macintosh RLE */
-#define COMPRESSION_THUNDERSCAN 32809 /* ThunderScan RLE */
-/* codes 32895-32898 are reserved for ANSI IT8 TIFF/IT <dkelly@apago.com) */
-#define COMPRESSION_IT8CTPAD 32895 /* IT8 CT w/padding */
-#define COMPRESSION_IT8LW 32896 /* IT8 Linework RLE */
-#define COMPRESSION_IT8MP 32897 /* IT8 Monochrome picture */
-#define COMPRESSION_IT8BL 32898 /* IT8 Binary line art */
-/* compression codes 32908-32911 are reserved for Pixar */
-#define COMPRESSION_PIXARFILM 32908 /* Pixar companded 10bit LZW */
-#define COMPRESSION_PIXARLOG 32909 /* Pixar companded 11bit ZIP */
-#define COMPRESSION_DEFLATE 32946 /* Deflate compression, legacy tag */
-#define COMPRESSION_ADOBE_DEFLATE 8 /* Deflate compression, as recognized by Adobe */
-/* compression code 32947 is reserved for Oceana Matrix <dev@oceana.com> */
-#define COMPRESSION_DCS 32947 /* Kodak DCS encoding */
-#define COMPRESSION_JBIG 34661 /* ISO JBIG */
-#define COMPRESSION_SGILOG 34676 /* SGI Log Luminance RLE */
-#define COMPRESSION_SGILOG24 34677 /* SGI Log 24-bit packed */
-#define COMPRESSION_JP2000 34712 /* Leadtools JPEG2000 */
-#define COMPRESSION_LERC 34887 /* ESRI Lerc codec: https://github.com/Esri/lerc */
-/* compression codes 34887-34889 are reserved for ESRI */
-#define COMPRESSION_LZMA 34925 /* LZMA2 */
-#define COMPRESSION_ZSTD 50000 /* ZSTD: WARNING not registered in Adobe-maintained registry */
-#define COMPRESSION_WEBP 50001 /* WEBP: WARNING not registered in Adobe-maintained registry */
-#define COMPRESSION_JXL 50002 /* JPEGXL: WARNING not registered in Adobe-maintained registry */
-#define TIFFTAG_PHOTOMETRIC 262 /* photometric interpretation */
-#define PHOTOMETRIC_MINISWHITE 0 /* min value is white */
-#define PHOTOMETRIC_MINISBLACK 1 /* min value is black */
-#define PHOTOMETRIC_RGB 2 /* RGB color model */
-#define PHOTOMETRIC_PALETTE 3 /* color map indexed */
-#define PHOTOMETRIC_MASK 4 /* $holdout mask */
-#define PHOTOMETRIC_SEPARATED 5 /* !color separations */
-#define PHOTOMETRIC_YCBCR 6 /* !CCIR 601 */
-#define PHOTOMETRIC_CIELAB 8 /* !1976 CIE L*a*b* */
-#define PHOTOMETRIC_ICCLAB 9 /* ICC L*a*b* [Adobe TIFF Technote 4] */
-#define PHOTOMETRIC_ITULAB 10 /* ITU L*a*b* */
-#define PHOTOMETRIC_CFA 32803 /* color filter array */
-#define PHOTOMETRIC_LOGL 32844 /* CIE Log2(L) */
-#define PHOTOMETRIC_LOGLUV 32845 /* CIE Log2(L) (u',v') */
-#define TIFFTAG_THRESHHOLDING 263 /* +thresholding used on data */
-#define THRESHHOLD_BILEVEL 1 /* b&w art scan */
-#define THRESHHOLD_HALFTONE 2 /* or dithered scan */
-#define THRESHHOLD_ERRORDIFFUSE 3 /* usually floyd-steinberg */
-#define TIFFTAG_CELLWIDTH 264 /* +dithering matrix width */
-#define TIFFTAG_CELLLENGTH 265 /* +dithering matrix height */
-#define TIFFTAG_FILLORDER 266 /* data order within a byte */
-#define FILLORDER_MSB2LSB 1 /* most significant -> least */
-#define FILLORDER_LSB2MSB 2 /* least significant -> most */
-#define TIFFTAG_DOCUMENTNAME 269 /* name of doc. image is from */
-#define TIFFTAG_IMAGEDESCRIPTION 270 /* info about image */
-#define TIFFTAG_MAKE 271 /* scanner manufacturer name */
-#define TIFFTAG_MODEL 272 /* scanner model name/number */
-#define TIFFTAG_STRIPOFFSETS 273 /* offsets to data strips */
-#define TIFFTAG_ORIENTATION 274 /* +image orientation */
-#define ORIENTATION_TOPLEFT 1 /* row 0 top, col 0 lhs */
-#define ORIENTATION_TOPRIGHT 2 /* row 0 top, col 0 rhs */
-#define ORIENTATION_BOTRIGHT 3 /* row 0 bottom, col 0 rhs */
-#define ORIENTATION_BOTLEFT 4 /* row 0 bottom, col 0 lhs */
-#define ORIENTATION_LEFTTOP 5 /* row 0 lhs, col 0 top */
-#define ORIENTATION_RIGHTTOP 6 /* row 0 rhs, col 0 top */
-#define ORIENTATION_RIGHTBOT 7 /* row 0 rhs, col 0 bottom */
-#define ORIENTATION_LEFTBOT 8 /* row 0 lhs, col 0 bottom */
-#define TIFFTAG_SAMPLESPERPIXEL 277 /* samples per pixel */
-#define TIFFTAG_ROWSPERSTRIP 278 /* rows per strip of data */
-#define TIFFTAG_STRIPBYTECOUNTS 279 /* bytes counts for strips */
-#define TIFFTAG_MINSAMPLEVALUE 280 /* +minimum sample value */
-#define TIFFTAG_MAXSAMPLEVALUE 281 /* +maximum sample value */
-#define TIFFTAG_XRESOLUTION 282 /* pixels/resolution in x */
-#define TIFFTAG_YRESOLUTION 283 /* pixels/resolution in y */
-#define TIFFTAG_PLANARCONFIG 284 /* storage organization */
-#define PLANARCONFIG_CONTIG 1 /* single image plane */
-#define PLANARCONFIG_SEPARATE 2 /* separate planes of data */
-#define TIFFTAG_PAGENAME 285 /* page name image is from */
-#define TIFFTAG_XPOSITION 286 /* x page offset of image lhs */
-#define TIFFTAG_YPOSITION 287 /* y page offset of image lhs */
-#define TIFFTAG_FREEOFFSETS 288 /* +byte offset to free block */
-#define TIFFTAG_FREEBYTECOUNTS 289 /* +sizes of free blocks */
-#define TIFFTAG_GRAYRESPONSEUNIT 290 /* $gray scale curve accuracy */
-#define GRAYRESPONSEUNIT_10S 1 /* tenths of a unit */
-#define GRAYRESPONSEUNIT_100S 2 /* hundredths of a unit */
-#define GRAYRESPONSEUNIT_1000S 3 /* thousandths of a unit */
-#define GRAYRESPONSEUNIT_10000S 4 /* ten-thousandths of a unit */
-#define GRAYRESPONSEUNIT_100000S 5 /* hundred-thousandths */
-#define TIFFTAG_GRAYRESPONSECURVE 291 /* $gray scale response curve */
-#define TIFFTAG_GROUP3OPTIONS 292 /* 32 flag bits */
-#define TIFFTAG_T4OPTIONS 292 /* TIFF 6.0 proper name alias */
-#define GROUP3OPT_2DENCODING 0x1 /* 2-dimensional coding */
-#define GROUP3OPT_UNCOMPRESSED 0x2 /* data not compressed */
-#define GROUP3OPT_FILLBITS 0x4 /* fill to byte boundary */
-#define TIFFTAG_GROUP4OPTIONS 293 /* 32 flag bits */
-#define TIFFTAG_T6OPTIONS 293 /* TIFF 6.0 proper name */
-#define GROUP4OPT_UNCOMPRESSED 0x2 /* data not compressed */
-#define TIFFTAG_RESOLUTIONUNIT 296 /* units of resolutions */
-#define RESUNIT_NONE 1 /* no meaningful units */
-#define RESUNIT_INCH 2 /* english */
-#define RESUNIT_CENTIMETER 3 /* metric */
-#define TIFFTAG_PAGENUMBER 297 /* page numbers of multi-page */
-#define TIFFTAG_COLORRESPONSEUNIT 300 /* $color curve accuracy */
-#define COLORRESPONSEUNIT_10S 1 /* tenths of a unit */
-#define COLORRESPONSEUNIT_100S 2 /* hundredths of a unit */
-#define COLORRESPONSEUNIT_1000S 3 /* thousandths of a unit */
-#define COLORRESPONSEUNIT_10000S 4 /* ten-thousandths of a unit */
-#define COLORRESPONSEUNIT_100000S 5 /* hundred-thousandths */
-#define TIFFTAG_TRANSFERFUNCTION 301 /* !colorimetry info */
-#define TIFFTAG_SOFTWARE 305 /* name & release */
-#define TIFFTAG_DATETIME 306 /* creation date and time */
-#define TIFFTAG_ARTIST 315 /* creator of image */
-#define TIFFTAG_HOSTCOMPUTER 316 /* machine where created */
-#define TIFFTAG_PREDICTOR 317 /* prediction scheme w/ LZW */
-#define PREDICTOR_NONE 1 /* no prediction scheme used */
-#define PREDICTOR_HORIZONTAL 2 /* horizontal differencing */
-#define PREDICTOR_FLOATINGPOINT 3 /* floating point predictor */
-#define TIFFTAG_WHITEPOINT 318 /* image white point */
-#define TIFFTAG_PRIMARYCHROMATICITIES 319 /* !primary chromaticities */
-#define TIFFTAG_COLORMAP 320 /* RGB map for palette image */
-#define TIFFTAG_HALFTONEHINTS 321 /* !highlight+shadow info */
-#define TIFFTAG_TILEWIDTH 322 /* !tile width in pixels */
-#define TIFFTAG_TILELENGTH 323 /* !tile height in pixels */
-#define TIFFTAG_TILEOFFSETS 324 /* !offsets to data tiles */
-#define TIFFTAG_TILEBYTECOUNTS 325 /* !byte counts for tiles */
-#define TIFFTAG_BADFAXLINES 326 /* lines w/ wrong pixel count */
-#define TIFFTAG_CLEANFAXDATA 327 /* regenerated line info */
-#define CLEANFAXDATA_CLEAN 0 /* no errors detected */
-#define CLEANFAXDATA_REGENERATED 1 /* receiver regenerated lines */
-#define CLEANFAXDATA_UNCLEAN 2 /* uncorrected errors exist */
-#define TIFFTAG_CONSECUTIVEBADFAXLINES 328 /* max consecutive bad lines */
-#define TIFFTAG_SUBIFD 330 /* subimage descriptors */
-#define TIFFTAG_INKSET 332 /* !inks in separated image */
-#define INKSET_CMYK 1 /* !cyan-magenta-yellow-black color */
-#define INKSET_MULTIINK 2 /* !multi-ink or hi-fi color */
-#define TIFFTAG_INKNAMES 333 /* !ascii names of inks */
-#define TIFFTAG_NUMBEROFINKS 334 /* !number of inks */
-#define TIFFTAG_DOTRANGE 336 /* !0% and 100% dot codes */
-#define TIFFTAG_TARGETPRINTER 337 /* !separation target */
-#define TIFFTAG_EXTRASAMPLES 338 /* !info about extra samples */
-#define EXTRASAMPLE_UNSPECIFIED 0 /* !unspecified data */
-#define EXTRASAMPLE_ASSOCALPHA 1 /* !associated alpha data */
-#define EXTRASAMPLE_UNASSALPHA 2 /* !unassociated alpha data */
-#define TIFFTAG_SAMPLEFORMAT 339 /* !data sample format */
-#define SAMPLEFORMAT_UINT 1 /* !unsigned integer data */
-#define SAMPLEFORMAT_INT 2 /* !signed integer data */
-#define SAMPLEFORMAT_IEEEFP 3 /* !IEEE floating point data */
-#define SAMPLEFORMAT_VOID 4 /* !untyped data */
-#define SAMPLEFORMAT_COMPLEXINT 5 /* !complex signed int */
-#define SAMPLEFORMAT_COMPLEXIEEEFP 6 /* !complex ieee floating */
-#define TIFFTAG_SMINSAMPLEVALUE 340 /* !variable MinSampleValue */
-#define TIFFTAG_SMAXSAMPLEVALUE 341 /* !variable MaxSampleValue */
-#define TIFFTAG_CLIPPATH 343 /* %ClipPath [Adobe TIFF technote 2] */
-#define TIFFTAG_XCLIPPATHUNITS 344 /* %XClipPathUnits [Adobe TIFF technote 2] */
-#define TIFFTAG_YCLIPPATHUNITS 345 /* %YClipPathUnits [Adobe TIFF technote 2] */
-#define TIFFTAG_INDEXED 346 /* %Indexed [Adobe TIFF Technote 3] */
-#define TIFFTAG_JPEGTABLES 347 /* %JPEG table stream */
-#define TIFFTAG_OPIPROXY 351 /* %OPI Proxy [Adobe TIFF technote] */
-/* Tags 400-435 are from the TIFF/FX spec */
-#define TIFFTAG_GLOBALPARAMETERSIFD 400 /* ! */
-#define TIFFTAG_PROFILETYPE 401 /* ! */
-#define PROFILETYPE_UNSPECIFIED 0 /* ! */
-#define PROFILETYPE_G3_FAX 1 /* ! */
-#define TIFFTAG_FAXPROFILE 402 /* ! */
-#define FAXPROFILE_S 1 /* !TIFF/FX FAX profile S */
-#define FAXPROFILE_F 2 /* !TIFF/FX FAX profile F */
-#define FAXPROFILE_J 3 /* !TIFF/FX FAX profile J */
-#define FAXPROFILE_C 4 /* !TIFF/FX FAX profile C */
-#define FAXPROFILE_L 5 /* !TIFF/FX FAX profile L */
-#define FAXPROFILE_M 6 /* !TIFF/FX FAX profile LM */
-#define TIFFTAG_CODINGMETHODS 403 /* !TIFF/FX coding methods */
-#define CODINGMETHODS_T4_1D (1 << 1) /* !T.4 1D */
-#define CODINGMETHODS_T4_2D (1 << 2) /* !T.4 2D */
-#define CODINGMETHODS_T6 (1 << 3) /* !T.6 */
-#define CODINGMETHODS_T85 (1 << 4) /* !T.85 JBIG */
-#define CODINGMETHODS_T42 (1 << 5) /* !T.42 JPEG */
-#define CODINGMETHODS_T43 (1 << 6) /* !T.43 colour by layered JBIG */
-#define TIFFTAG_VERSIONYEAR 404 /* !TIFF/FX version year */
-#define TIFFTAG_MODENUMBER 405 /* !TIFF/FX mode number */
-#define TIFFTAG_DECODE 433 /* !TIFF/FX decode */
-#define TIFFTAG_IMAGEBASECOLOR 434 /* !TIFF/FX image base colour */
-#define TIFFTAG_T82OPTIONS 435 /* !TIFF/FX T.82 options */
-/*
- * Tags 512-521 are obsoleted by Technical Note #2 which specifies a
- * revised JPEG-in-TIFF scheme.
- */
-#define TIFFTAG_JPEGPROC 512 /* !JPEG processing algorithm */
-#define JPEGPROC_BASELINE 1 /* !baseline sequential */
-#define JPEGPROC_LOSSLESS 14 /* !Huffman coded lossless */
-#define TIFFTAG_JPEGIFOFFSET 513 /* !pointer to SOI marker */
-#define TIFFTAG_JPEGIFBYTECOUNT 514 /* !JFIF stream length */
-#define TIFFTAG_JPEGRESTARTINTERVAL 515 /* !restart interval length */
-#define TIFFTAG_JPEGLOSSLESSPREDICTORS 517 /* !lossless proc predictor */
-#define TIFFTAG_JPEGPOINTTRANSFORM 518 /* !lossless point transform */
-#define TIFFTAG_JPEGQTABLES 519 /* !Q matrix offsets */
-#define TIFFTAG_JPEGDCTABLES 520 /* !DCT table offsets */
-#define TIFFTAG_JPEGACTABLES 521 /* !AC coefficient offsets */
-#define TIFFTAG_YCBCRCOEFFICIENTS 529 /* !RGB -> YCbCr transform */
-#define TIFFTAG_YCBCRSUBSAMPLING 530 /* !YCbCr subsampling factors */
-#define TIFFTAG_YCBCRPOSITIONING 531 /* !subsample positioning */
-#define YCBCRPOSITION_CENTERED 1 /* !as in PostScript Level 2 */
-#define YCBCRPOSITION_COSITED 2 /* !as in CCIR 601-1 */
-#define TIFFTAG_REFERENCEBLACKWHITE 532 /* !colorimetry info */
-#define TIFFTAG_STRIPROWCOUNTS 559 /* !TIFF/FX strip row counts */
-#define TIFFTAG_XMLPACKET 700 /* %XML packet [Adobe XMP Specification, January 2004 */
-#define TIFFTAG_OPIIMAGEID 32781 /* %OPI ImageID [Adobe TIFF technote] */
-/* For eiStream Annotation Specification, Version 1.00.06 see
- * http://web.archive.org/web/20050309141348/http://www.kofile.com/support%20pro/faqs/annospec.htm */
-#define TIFFTAG_TIFFANNOTATIONDATA 32932
-/* tags 32952-32956 are private tags registered to Island Graphics */
-#define TIFFTAG_REFPTS 32953 /* image reference points */
-#define TIFFTAG_REGIONTACKPOINT 32954 /* region-xform tack point */
-#define TIFFTAG_REGIONWARPCORNERS 32955 /* warp quadrilateral */
-#define TIFFTAG_REGIONAFFINE 32956 /* affine transformation mat */
-/* tags 32995-32999 are private tags registered to SGI */
-#define TIFFTAG_MATTEING 32995 /* $use ExtraSamples */
-#define TIFFTAG_DATATYPE 32996 /* $use SampleFormat */
-#define TIFFTAG_IMAGEDEPTH 32997 /* z depth of image */
-#define TIFFTAG_TILEDEPTH 32998 /* z depth/data tile */
-/* tags 33300-33309 are private tags registered to Pixar */
-/*
- * TIFFTAG_PIXAR_IMAGEFULLWIDTH and TIFFTAG_PIXAR_IMAGEFULLLENGTH
- * are set when an image has been cropped out of a larger image.
- * They reflect the size of the original uncropped image.
- * The TIFFTAG_XPOSITION and TIFFTAG_YPOSITION can be used
- * to determine the position of the smaller image in the larger one.
- */
-#define TIFFTAG_PIXAR_IMAGEFULLWIDTH 33300 /* full image size in x */
-#define TIFFTAG_PIXAR_IMAGEFULLLENGTH 33301 /* full image size in y */
-/* Tags 33302-33306 are used to identify special image modes and data
- * used by Pixar's texture formats.
- */
-#define TIFFTAG_PIXAR_TEXTUREFORMAT 33302 /* texture map format */
-#define TIFFTAG_PIXAR_WRAPMODES 33303 /* s & t wrap modes */
-#define TIFFTAG_PIXAR_FOVCOT 33304 /* cotan(fov) for env. maps */
-#define TIFFTAG_PIXAR_MATRIX_WORLDTOSCREEN 33305
-#define TIFFTAG_PIXAR_MATRIX_WORLDTOCAMERA 33306
-/* tag 33405 is a private tag registered to Eastman Kodak */
-#define TIFFTAG_WRITERSERIALNUMBER 33405 /* device serial number */
-#define TIFFTAG_CFAREPEATPATTERNDIM 33421 /* (alias for TIFFTAG_EP_CFAREPEATPATTERNDIM)*/
-#define TIFFTAG_CFAPATTERN 33422 /* (alias for TIFFTAG_EP_CFAPATTERN) */
-#define TIFFTAG_BATTERYLEVEL 33423 /* (alias for TIFFTAG_EP_BATTERYLEVEL) */
-/* tag 33432 is listed in the 6.0 spec w/ unknown ownership */
-#define TIFFTAG_COPYRIGHT 33432 /* copyright string */
-/* Tags 33445-33452 are used for Molecular Dynamics GEL fileformat,
- * see http://research.stowers-institute.org/mcm/efg/ScientificSoftware/Utility/TiffTags/GEL-FileFormat.pdf
- * (2023: the above web site is unavailable but tags are explained briefly at
- * https://www.awaresystems.be/imaging/tiff/tifftags/docs/gel.html
- */
-#define TIFFTAG_MD_FILETAG 33445 /* Specifies the pixel data format encoding in the GEL file format. */
-#define TIFFTAG_MD_SCALEPIXEL 33446 /* scale factor */
-#define TIFFTAG_MD_COLORTABLE 33447 /* conversion from 16bit to 8bit */
-#define TIFFTAG_MD_LABNAME 33448 /* name of the lab that scanned this file. */
-#define TIFFTAG_MD_SAMPLEINFO 33449 /* information about the scanned GEL sample */
-#define TIFFTAG_MD_PREPDATE 33450 /* information about the date the sample was prepared YY/MM/DD */
-#define TIFFTAG_MD_PREPTIME 33451 /* information about the time the sample was prepared HH:MM*/
-#define TIFFTAG_MD_FILEUNITS 33452 /* Units for data in this file, as used in the GEL file format. */
-/* IPTC TAG from RichTIFF specifications */
-#define TIFFTAG_RICHTIFFIPTC 33723
-#define TIFFTAG_INGR_PACKET_DATA_TAG 33918 /* Intergraph Application specific storage. */
-#define TIFFTAG_INGR_FLAG_REGISTERS 33919 /* Intergraph Application specific flags. */
-#define TIFFTAG_IRASB_TRANSORMATION_MATRIX 33920 /* Originally part of Intergraph's GeoTIFF tags, but likely understood by IrasB only. */
-#define TIFFTAG_MODELTIEPOINTTAG 33922 /* GeoTIFF */
-/* 34016-34029 are reserved for ANSI IT8 TIFF/IT <dkelly@apago.com) */
-#define TIFFTAG_IT8SITE 34016 /* site name */
-#define TIFFTAG_IT8COLORSEQUENCE 34017 /* color seq. [RGB,CMYK,etc] */
-#define TIFFTAG_IT8HEADER 34018 /* DDES Header */
-#define TIFFTAG_IT8RASTERPADDING 34019 /* raster scanline padding */
-#define TIFFTAG_IT8BITSPERRUNLENGTH 34020 /* # of bits in short run */
-#define TIFFTAG_IT8BITSPEREXTENDEDRUNLENGTH 34021 /* # of bits in long run */
-#define TIFFTAG_IT8COLORTABLE 34022 /* LW colortable */
-#define TIFFTAG_IT8IMAGECOLORINDICATOR 34023 /* BP/BL image color switch */
-#define TIFFTAG_IT8BKGCOLORINDICATOR 34024 /* BP/BL bg color switch */
-#define TIFFTAG_IT8IMAGECOLORVALUE 34025 /* BP/BL image color value */
-#define TIFFTAG_IT8BKGCOLORVALUE 34026 /* BP/BL bg color value */
-#define TIFFTAG_IT8PIXELINTENSITYRANGE 34027 /* MP pixel intensity value */
-#define TIFFTAG_IT8TRANSPARENCYINDICATOR 34028 /* HC transparency switch */
-#define TIFFTAG_IT8COLORCHARACTERIZATION 34029 /* color character. table */
-#define TIFFTAG_IT8HCUSAGE 34030 /* HC usage indicator */
-#define TIFFTAG_IT8TRAPINDICATOR 34031 /* Trapping indicator (untrapped=0, trapped=1) */
-#define TIFFTAG_IT8CMYKEQUIVALENT 34032 /* CMYK color equivalents */
-/* tags 34232-34236 are private tags registered to Texas Instruments */
-#define TIFFTAG_FRAMECOUNT 34232 /* Sequence Frame Count */
-#define TIFFTAG_MODELTRANSFORMATIONTAG 34264 /* Used in interchangeable GeoTIFF files */
-/* tag 34377 is private tag registered to Adobe for PhotoShop */
-#define TIFFTAG_PHOTOSHOP 34377
-/* tags 34665, 34853 and 40965 are documented in EXIF specification */
-#define TIFFTAG_EXIFIFD 34665 /* Pointer to EXIF private directory */
-/* tag 34750 is a private tag registered to Adobe? */
-#define TIFFTAG_ICCPROFILE 34675 /* ICC profile data */
-#define TIFFTAG_IMAGELAYER 34732 /* !TIFF/FX image layer information */
-/* tag 34750 is a private tag registered to Pixel Magic */
-#define TIFFTAG_JBIGOPTIONS 34750 /* JBIG options */
-#define TIFFTAG_GPSIFD 34853 /* Pointer to EXIF GPS private directory */
-/* tags 34908-34914 are private tags registered to SGI */
-#define TIFFTAG_FAXRECVPARAMS 34908 /* encoded Class 2 ses. params */
-#define TIFFTAG_FAXSUBADDRESS 34909 /* received SubAddr string */
-#define TIFFTAG_FAXRECVTIME 34910 /* receive time (secs) */
-#define TIFFTAG_FAXDCS 34911 /* encoded fax ses. params, Table 2/T.30 */
-/* tags 37439-37443 are registered to SGI <gregl@sgi.com> */
-#define TIFFTAG_STONITS 37439 /* Sample value to Nits */
-/* tag 34929 is a private tag registered to FedEx */
-#define TIFFTAG_FEDEX_EDR 34929 /* unknown use */
-#define TIFFTAG_IMAGESOURCEDATA 37724 /* http://justsolve.archiveteam.org/wiki/PSD, http://www.adobe.com/devnet-apps/photoshop/fileformatashtml/ */
-#define TIFFTAG_INTEROPERABILITYIFD 40965 /* Pointer to EXIF Interoperability private directory */
-#define TIFFTAG_GDAL_METADATA 42112 /* Used by the GDAL library */
-#define TIFFTAG_GDAL_NODATA 42113 /* Used by the GDAL library */
-#define TIFFTAG_OCE_SCANJOB_DESCRIPTION 50215 /* Used in the Oce scanning process */
-#define TIFFTAG_OCE_APPLICATION_SELECTOR 50216 /* Used in the Oce scanning process. */
-#define TIFFTAG_OCE_IDENTIFICATION_NUMBER 50217
-#define TIFFTAG_OCE_IMAGELOGIC_CHARACTERISTICS 50218
-/* tags 50674 to 50677 are reserved for ESRI */
-#define TIFFTAG_LERC_PARAMETERS 50674 /* Stores LERC version and additional compression method */
-
-/* Adobe Digital Negative (DNG) format tags */
-#define TIFFTAG_DNGVERSION 50706 /* &DNG version number */
-#define TIFFTAG_DNGBACKWARDVERSION 50707 /* &DNG compatibility version */
-#define TIFFTAG_UNIQUECAMERAMODEL 50708 /* &name for the camera model */
-#define TIFFTAG_LOCALIZEDCAMERAMODEL 50709 /* &localized camera model name (UTF-8) */
-#define TIFFTAG_CFAPLANECOLOR 50710 /* &CFAPattern->LinearRaw space mapping */
-#define TIFFTAG_CFALAYOUT 50711 /* &spatial layout of the CFA */
-#define TIFFTAG_LINEARIZATIONTABLE 50712 /* &lookup table description */
-#define TIFFTAG_BLACKLEVELREPEATDIM 50713 /* &repeat pattern size for the BlackLevel tag */
-#define TIFFTAG_BLACKLEVEL 50714 /* &zero light encoding level */
-#define TIFFTAG_BLACKLEVELDELTAH 50715 /* &zero light encoding level differences (columns) */
-#define TIFFTAG_BLACKLEVELDELTAV 50716 /* &zero light encoding level differences (rows) */
-#define TIFFTAG_WHITELEVEL 50717 /* &fully saturated encoding level */
-#define TIFFTAG_DEFAULTSCALE 50718 /* &default scale factors */
-#define TIFFTAG_DEFAULTCROPORIGIN 50719 /* &origin of the final image area */
-#define TIFFTAG_DEFAULTCROPSIZE 50720 /* &size of the final image area */
-#define TIFFTAG_COLORMATRIX1 50721 /* &XYZ->reference color space transformation matrix 1 */
-#define TIFFTAG_COLORMATRIX2 50722 /* &XYZ->reference color space transformation matrix 2 */
-#define TIFFTAG_CAMERACALIBRATION1 50723 /* &calibration matrix 1 */
-#define TIFFTAG_CAMERACALIBRATION2 50724 /* &calibration matrix 2 */
-#define TIFFTAG_REDUCTIONMATRIX1 50725 /* &dimensionality reduction matrix 1 */
-#define TIFFTAG_REDUCTIONMATRIX2 50726 /* &dimensionality reduction matrix 2 */
-#define TIFFTAG_ANALOGBALANCE 50727 /* &gain applied the stored raw values*/
-#define TIFFTAG_ASSHOTNEUTRAL 50728 /* &selected white balance in linear reference space */
-#define TIFFTAG_ASSHOTWHITEXY 50729 /* &selected white balance in x-y chromaticity coordinates */
-#define TIFFTAG_BASELINEEXPOSURE 50730 /* &how much to move the zero point */
-#define TIFFTAG_BASELINENOISE 50731 /* &relative noise level */
-#define TIFFTAG_BASELINESHARPNESS 50732 /* &relative amount of sharpening */
-/* TIFFTAG_BAYERGREENSPLIT: &how closely the values of the green pixels in the blue/green rows
- * track the values of the green pixels in the red/green rows */
-#define TIFFTAG_BAYERGREENSPLIT 50733
-#define TIFFTAG_LINEARRESPONSELIMIT 50734 /* &non-linear encoding range */
-#define TIFFTAG_CAMERASERIALNUMBER 50735 /* &camera's serial number */
-#define TIFFTAG_LENSINFO 50736 /* info about the lens */
-#define TIFFTAG_CHROMABLURRADIUS 50737 /* &chroma blur radius */
-#define TIFFTAG_ANTIALIASSTRENGTH 50738 /* &relative strength of the camera's anti-alias filter */
-#define TIFFTAG_SHADOWSCALE 50739 /* &used by Adobe Camera Raw */
-#define TIFFTAG_DNGPRIVATEDATA 50740 /* &manufacturer's private data */
-#define TIFFTAG_MAKERNOTESAFETY 50741 /* &whether the EXIF MakerNote tag is safe to preserve along with the rest of the EXIF data */
-#define TIFFTAG_CALIBRATIONILLUMINANT1 50778 /* &illuminant 1 */
-#define TIFFTAG_CALIBRATIONILLUMINANT2 50779 /* &illuminant 2 */
-#define TIFFTAG_BESTQUALITYSCALE 50780 /* &best quality multiplier */
-#define TIFFTAG_RAWDATAUNIQUEID 50781 /* &unique identifier for the raw image data */
-#define TIFFTAG_ORIGINALRAWFILENAME 50827 /* &file name of the original raw file (UTF-8) */
-#define TIFFTAG_ORIGINALRAWFILEDATA 50828 /* &contents of the original raw file */
-#define TIFFTAG_ACTIVEAREA 50829 /* &active (non-masked) pixels of the sensor */
-#define TIFFTAG_MASKEDAREAS 50830 /* &list of coordinates of fully masked pixels */
-#define TIFFTAG_ASSHOTICCPROFILE 50831 /* &these two tags used to */
-#define TIFFTAG_ASSHOTPREPROFILEMATRIX 50832 /* map cameras's color space into ICC profile space */
-#define TIFFTAG_CURRENTICCPROFILE 50833 /* & */
-#define TIFFTAG_CURRENTPREPROFILEMATRIX 50834 /* & */
-
-/* DNG 1.2.0.0 */
-#define TIFFTAG_COLORIMETRICREFERENCE 50879 /* &colorimetric reference */
-#define TIFFTAG_CAMERACALIBRATIONSIGNATURE 50931 /* &camera calibration signature (UTF-8) */
-#define TIFFTAG_PROFILECALIBRATIONSIGNATURE 50932 /* &profile calibration signature (UTF-8) */
-/* TIFFTAG_EXTRACAMERAPROFILES 50933 &extra camera profiles : is already defined for GeoTIFF DGIWG */
-#define TIFFTAG_ASSHOTPROFILENAME 50934 /* &as shot profile name (UTF-8) */
-#define TIFFTAG_NOISEREDUCTIONAPPLIED 50935 /* &amount of applied noise reduction */
-#define TIFFTAG_PROFILENAME 50936 /* &camera profile name (UTF-8) */
-#define TIFFTAG_PROFILEHUESATMAPDIMS 50937 /* &dimensions of HSV mapping */
-#define TIFFTAG_PROFILEHUESATMAPDATA1 50938 /* &first HSV mapping table */
-#define TIFFTAG_PROFILEHUESATMAPDATA2 50939 /* &second HSV mapping table */
-#define TIFFTAG_PROFILETONECURVE 50940 /* &default tone curve */
-#define TIFFTAG_PROFILEEMBEDPOLICY 50941 /* &profile embedding policy */
-#define TIFFTAG_PROFILECOPYRIGHT 50942 /* &profile copyright information (UTF-8) */
-#define TIFFTAG_FORWARDMATRIX1 50964 /* &matrix for mapping white balanced camera colors to XYZ D50 */
-#define TIFFTAG_FORWARDMATRIX2 50965 /* &matrix for mapping white balanced camera colors to XYZ D50 */
-#define TIFFTAG_PREVIEWAPPLICATIONNAME 50966 /* &name of application that created preview (UTF-8) */
-#define TIFFTAG_PREVIEWAPPLICATIONVERSION 50967 /* &version of application that created preview (UTF-8) */
-#define TIFFTAG_PREVIEWSETTINGSNAME 50968 /* &name of conversion settings (UTF-8) */
-#define TIFFTAG_PREVIEWSETTINGSDIGEST 50969 /* &unique id of conversion settings */
-#define TIFFTAG_PREVIEWCOLORSPACE 50970 /* &preview color space */
-#define TIFFTAG_PREVIEWDATETIME 50971 /* &date/time preview was rendered */
-#define TIFFTAG_RAWIMAGEDIGEST 50972 /* &md5 of raw image data */
-#define TIFFTAG_ORIGINALRAWFILEDIGEST 50973 /* &md5 of the data stored in the OriginalRawFileData tag */
-#define TIFFTAG_SUBTILEBLOCKSIZE 50974 /* &subtile block size */
-#define TIFFTAG_ROWINTERLEAVEFACTOR 50975 /* &number of interleaved fields */
-#define TIFFTAG_PROFILELOOKTABLEDIMS 50981 /* &num of input samples in each dim of default "look" table */
-#define TIFFTAG_PROFILELOOKTABLEDATA 50982 /* &default "look" table for use as starting point */
-
-/* DNG 1.3.0.0 */
-#define TIFFTAG_OPCODELIST1 51008 /* &opcodes that should be applied to raw image after reading */
-#define TIFFTAG_OPCODELIST2 51009 /* &opcodes that should be applied after mapping to linear reference */
-#define TIFFTAG_OPCODELIST3 51022 /* &opcodes that should be applied after demosaicing */
-#define TIFFTAG_NOISEPROFILE 51041 /* &noise profile */
-
-/* DNG 1.4.0.0 */
-#define TIFFTAG_DEFAULTUSERCROP 51125 /* &default user crop rectangle in relative coords */
-#define TIFFTAG_DEFAULTBLACKRENDER 51110 /* &black rendering hint */
-#define TIFFTAG_BASELINEEXPOSUREOFFSET 51109 /* &baseline exposure offset */
-#define TIFFTAG_PROFILELOOKTABLEENCODING 51108 /* &3D LookTable indexing conversion */
-#define TIFFTAG_PROFILEHUESATMAPENCODING 51107 /* &3D HueSatMap indexing conversion */
-#define TIFFTAG_ORIGINALDEFAULTFINALSIZE 51089 /* &default final size of larger original file for this proxy */
-#define TIFFTAG_ORIGINALBESTQUALITYFINALSIZE 51090 /* &best quality final size of larger original file for this proxy */
-#define TIFFTAG_ORIGINALDEFAULTCROPSIZE 51091 /* &the default crop size of larger original file for this proxy */
-#define TIFFTAG_NEWRAWIMAGEDIGEST 51111 /* &modified MD5 digest of the raw image data */
-#define TIFFTAG_RAWTOPREVIEWGAIN 51112 /* &The gain between the main raw FD and the preview IFD containing this tag */
-
-/* DNG 1.5.0.0 */
-#define TIFFTAG_DEPTHFORMAT 51177 /* &encoding of the depth data in the file */
-#define TIFFTAG_DEPTHNEAR 51178 /* &distance from the camera represented by value 0 in the depth map */
-#define TIFFTAG_DEPTHFAR 51179 /* &distance from the camera represented by the maximum value in the depth map */
-#define TIFFTAG_DEPTHUNITS 51180 /* &measurement units for DepthNear and DepthFar */
-#define TIFFTAG_DEPTHMEASURETYPE 51181 /* &measurement geometry for the depth map */
-#define TIFFTAG_ENHANCEPARAMS 51182 /* &a string that documents how the enhanced image data was processed. */
-
-/* DNG 1.6.0.0 */
-#define TIFFTAG_PROFILEGAINTABLEMAP 52525 /* &spatially varying gain tables that can be applied as starting point */
-#define TIFFTAG_SEMANTICNAME 52526 /* &a string that identifies the semantic mask */
-#define TIFFTAG_SEMANTICINSTANCEID 52528 /* &a string that identifies a specific instance in a semantic mask */
-#define TIFFTAG_MASKSUBAREA 52536 /* &the crop rectangle of this IFD's mask, relative to the main image */
-#define TIFFTAG_RGBTABLES 52543 /* &color transforms to apply to masked image regions */
-#define TIFFTAG_CALIBRATIONILLUMINANT3 52529 /* &the illuminant used for the third set of color calibration tags */
-#define TIFFTAG_COLORMATRIX3 52531 /* &matrix to convert XYZ values to reference camera native color space under CalibrationIlluminant3 */
-#define TIFFTAG_CAMERACALIBRATION3 52530 /* &matrix to transform reference camera native space values to individual camera native space values under CalibrationIlluminant3 */
-#define TIFFTAG_REDUCTIONMATRIX3 52538 /* &dimensionality reduction matrix for use in color conversion to XYZ under CalibrationIlluminant3 */
-#define TIFFTAG_PROFILEHUESATMAPDATA3 52537 /* &the data for the third HSV table */
-#define TIFFTAG_FORWARDMATRIX3 52532 /* &matrix to map white balanced camera colors to XYZ D50 */
-#define TIFFTAG_ILLUMINANTDATA1 52533 /* &data for the first calibration illuminant */
-#define TIFFTAG_ILLUMINANTDATA2 52534 /* &data for the second calibration illuminant */
-#define TIFFTAG_ILLUMINANTDATA3 53535 /* &data for the third calibration illuminant */
-
-/* TIFF/EP */
-#define TIFFTAG_EP_CFAREPEATPATTERNDIM 33421 /* dimensions of CFA pattern */
-#define TIFFTAG_EP_CFAPATTERN 33422 /* color filter array pattern */
-#define TIFFTAG_EP_BATTERYLEVEL 33423 /* battery level (rational or ASCII) */
-#define TIFFTAG_EP_INTERLACE 34857 /* Number of multi-field images */
-/* TIFFTAG_EP_IPTC_NAA and TIFFTAG_RICHTIFFIPTC share the same tag number (33723)
- * LibTIFF type is UNDEFINED or BYTE, but often times incorrectly specified as LONG,
- * because TIFF/EP (ISO/DIS 12234-2) specifies type LONG or ASCII. */
-#define TIFFTAG_EP_IPTC_NAA 33723 /* Alias IPTC/NAA Newspaper Association RichTIFF */
-#define TIFFTAG_EP_TIMEZONEOFFSET 34858 /* Time zone offset relative to UTC */
-#define TIFFTAG_EP_SELFTIMERMODE 34859 /* Number of seconds capture was delayed from button press */
-#define TIFFTAG_EP_FLASHENERGY 37387 /* Flash energy, or range if there is uncertainty */
-#define TIFFTAG_EP_SPATIALFREQUENCYRESPONSE 37388 /* Spatial frequency response */
-#define TIFFTAG_EP_NOISE 37389 /* Camera noise measurement values */
-#define TIFFTAG_EP_FOCALPLANEXRESOLUTION 37390 /* Focal plane X resolution */
-#define TIFFTAG_EP_FOCALPLANEYRESOLUTION 37391 /* Focal plane Y resolution */
-#define TIFFTAG_EP_FOCALPLANERESOLUTIONUNIT 37392 /* Focal plane resolution unit */
-#define TIFFTAG_EP_IMAGENUMBER 37393 /* Number of image when several of burst shot stored in same TIFF/EP */
-#define TIFFTAG_EP_SECURITYCLASSIFICATION 37394 /* Security classification */
-#define TIFFTAG_EP_IMAGEHISTORY 37395 /* Record of what has been done to the image */
-#define TIFFTAG_EP_EXPOSUREINDEX 37397 /* Exposure index */
-#define TIFFTAG_EP_STANDARDID 37398 /* TIFF/EP standard version, n.n.n.n */
-#define TIFFTAG_EP_SENSINGMETHOD 37399 /* Type of image sensor */
-/*
- * TIFF/EP tags equivalent to EXIF tags
- * Note that TIFF-EP and EXIF use nearly the same metadata tag set, but TIFF-EP stores the tags in IFD 0,
- * while EXIF store the tags in a separate IFD. Either location is allowed by DNG, but the EXIF location is preferred.
- */
-#define TIFFTAG_EP_EXPOSURETIME 33434 /* Exposure time */
-#define TIFFTAG_EP_FNUMBER 33437 /* F number */
-#define TIFFTAG_EP_EXPOSUREPROGRAM 34850 /* Exposure program */
-#define TIFFTAG_EP_SPECTRALSENSITIVITY 34852 /* Spectral sensitivity */
-#define TIFFTAG_EP_ISOSPEEDRATINGS 34855 /* ISO speed rating */
-#define TIFFTAG_EP_OECF 34856 /* Optoelectric conversion factor */
-#define TIFFTAG_EP_DATETIMEORIGINAL 36867 /* Date and time of original data generation */
-#define TIFFTAG_EP_COMPRESSEDBITSPERPIXEL 37122 /* Image compression mode */
-#define TIFFTAG_EP_SHUTTERSPEEDVALUE 37377 /* Shutter speed */
-#define TIFFTAG_EP_APERTUREVALUE 37378 /* Aperture */
-#define TIFFTAG_EP_BRIGHTNESSVALUE 37379 /* Brightness */
-#define TIFFTAG_EP_EXPOSUREBIASVALUE 37380 /* Exposure bias */
-#define TIFFTAG_EP_MAXAPERTUREVALUE 37381 /* Maximum lens aperture */
-#define TIFFTAG_EP_SUBJECTDISTANCE 37382 /* Subject distance */
-#define TIFFTAG_EP_METERINGMODE 37383 /* Metering mode */
-#define TIFFTAG_EP_LIGHTSOURCE 37384 /* Light source */
-#define TIFFTAG_EP_FLASH 37385 /* Flash */
-#define TIFFTAG_EP_FOCALLENGTH 37386 /* Lens focal length */
-#define TIFFTAG_EP_SUBJECTLOCATION 37396 /* Subject location (area) */
-
-#define TIFFTAG_RPCCOEFFICIENT 50844 /* Define by GDAL for geospatial georeferencing through RPC: http://geotiff.maptools.org/rpc_prop.html */
-#define TIFFTAG_ALIAS_LAYER_METADATA 50784 /* Alias Sketchbook Pro layer usage description. */
-
-/* GeoTIFF DGIWG */
-#define TIFFTAG_TIFF_RSID 50908 /* https://www.awaresystems.be/imaging/tiff/tifftags/tiff_rsid.html */
-#define TIFFTAG_GEO_METADATA 50909 /* https://www.awaresystems.be/imaging/tiff/tifftags/geo_metadata.html */
-#define TIFFTAG_EXTRACAMERAPROFILES 50933 /* http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/products/photoshop/pdfs/dng_spec_1.4.0.0.pdf */
-
-/* tag 65535 is an undefined tag used by Eastman Kodak */
-#define TIFFTAG_DCSHUESHIFTVALUES 65535 /* hue shift correction data */
-
-/*
- * The following are ``pseudo tags'' that can be used to control
- * codec-specific functionality. These tags are not written to file.
- * Note that these values start at 0xffff+1 so that they'll never
- * collide with Aldus-assigned tags.
- *
- * If you want your private pseudo tags ``registered'' (i.e. added to
- * this file), please post a bug report via the tracking system at
- * http://www.remotesensing.org/libtiff/bugs.html with the appropriate
- * C definitions to add.
- */
-#define TIFFTAG_FAXMODE 65536 /* Group 3/4 format control */
-#define FAXMODE_CLASSIC 0x0000 /* default, include RTC */
-#define FAXMODE_NORTC 0x0001 /* no RTC at end of data */
-#define FAXMODE_NOEOL 0x0002 /* no EOL code at end of row */
-#define FAXMODE_BYTEALIGN 0x0004 /* byte align row */
-#define FAXMODE_WORDALIGN 0x0008 /* word align row */
-#define FAXMODE_CLASSF FAXMODE_NORTC /* TIFF Class F */
-#define TIFFTAG_JPEGQUALITY 65537 /* Compression quality level */
-/* Note: quality level is on the IJG 0-100 scale. Default value is 75 */
-#define TIFFTAG_JPEGCOLORMODE 65538 /* Auto RGB<=>YCbCr convert? */
-#define JPEGCOLORMODE_RAW 0x0000 /* no conversion (default) */
-#define JPEGCOLORMODE_RGB 0x0001 /* do auto conversion */
-#define TIFFTAG_JPEGTABLESMODE 65539 /* What to put in JPEGTables */
-#define JPEGTABLESMODE_QUANT 0x0001 /* include quantization tbls */
-#define JPEGTABLESMODE_HUFF 0x0002 /* include Huffman tbls */
-/* Note: default is JPEGTABLESMODE_QUANT | JPEGTABLESMODE_HUFF */
-#define TIFFTAG_FAXFILLFUNC 65540 /* G3/G4 fill function */
-#define TIFFTAG_PIXARLOGDATAFMT 65549 /* PixarLogCodec I/O data sz */
-#define PIXARLOGDATAFMT_8BIT 0 /* regular u_char samples */
-#define PIXARLOGDATAFMT_8BITABGR 1 /* ABGR-order u_chars */
-#define PIXARLOGDATAFMT_11BITLOG 2 /* 11-bit log-encoded (raw) */
-#define PIXARLOGDATAFMT_12BITPICIO 3 /* as per PICIO (1.0==2048) */
-#define PIXARLOGDATAFMT_16BIT 4 /* signed short samples */
-#define PIXARLOGDATAFMT_FLOAT 5 /* IEEE float samples */
-/* 65550-65556 are allocated to Oceana Matrix <dev@oceana.com> */
-#define TIFFTAG_DCSIMAGERTYPE 65550 /* imager model & filter */
-#define DCSIMAGERMODEL_M3 0 /* M3 chip (1280 x 1024) */
-#define DCSIMAGERMODEL_M5 1 /* M5 chip (1536 x 1024) */
-#define DCSIMAGERMODEL_M6 2 /* M6 chip (3072 x 2048) */
-#define DCSIMAGERFILTER_IR 0 /* infrared filter */
-#define DCSIMAGERFILTER_MONO 1 /* monochrome filter */
-#define DCSIMAGERFILTER_CFA 2 /* color filter array */
-#define DCSIMAGERFILTER_OTHER 3 /* other filter */
-#define TIFFTAG_DCSINTERPMODE 65551 /* interpolation mode */
-#define DCSINTERPMODE_NORMAL 0x0 /* whole image, default */
-#define DCSINTERPMODE_PREVIEW 0x1 /* preview of image (384x256) */
-#define TIFFTAG_DCSBALANCEARRAY 65552 /* color balance values */
-#define TIFFTAG_DCSCORRECTMATRIX 65553 /* color correction values */
-#define TIFFTAG_DCSGAMMA 65554 /* gamma value */
-#define TIFFTAG_DCSTOESHOULDERPTS 65555 /* toe & shoulder points */
-#define TIFFTAG_DCSCALIBRATIONFD 65556 /* calibration file desc */
-/* Note: quality level is on the ZLIB 1-9 scale. Default value is -1 */
-#define TIFFTAG_ZIPQUALITY 65557 /* compression quality level */
-#define TIFFTAG_PIXARLOGQUALITY 65558 /* PixarLog uses same scale */
-/* 65559 is allocated to Oceana Matrix <dev@oceana.com> */
-#define TIFFTAG_DCSCLIPRECTANGLE 65559 /* area of image to acquire */
-#define TIFFTAG_SGILOGDATAFMT 65560 /* SGILog user data format */
-#define SGILOGDATAFMT_FLOAT 0 /* IEEE float samples */
-#define SGILOGDATAFMT_16BIT 1 /* 16-bit samples */
-#define SGILOGDATAFMT_RAW 2 /* uninterpreted data */
-#define SGILOGDATAFMT_8BIT 3 /* 8-bit RGB monitor values */
-#define TIFFTAG_SGILOGENCODE 65561 /* SGILog data encoding control*/
-#define SGILOGENCODE_NODITHER 0 /* do not dither encoded values*/
-#define SGILOGENCODE_RANDITHER 1 /* randomly dither encd values */
-#define TIFFTAG_LZMAPRESET 65562 /* LZMA2 preset (compression level) */
-#define TIFFTAG_PERSAMPLE 65563 /* interface for per sample tags */
-#define PERSAMPLE_MERGED 0 /* present as a single value */
-#define PERSAMPLE_MULTI 1 /* present as multiple values */
-#define TIFFTAG_ZSTD_LEVEL 65564 /* ZSTD compression level */
-#define TIFFTAG_LERC_VERSION 65565 /* LERC version */
-#define LERC_VERSION_2_4 4
-#define TIFFTAG_LERC_ADD_COMPRESSION 65566 /* LERC additional compression */
-#define LERC_ADD_COMPRESSION_NONE 0
-#define LERC_ADD_COMPRESSION_DEFLATE 1
-#define LERC_ADD_COMPRESSION_ZSTD 2
-#define TIFFTAG_LERC_MAXZERROR 65567 /* LERC maximum error */
-#define TIFFTAG_WEBP_LEVEL 65568 /* WebP compression level */
-#define TIFFTAG_WEBP_LOSSLESS 65569 /* WebP lossless/lossy */
-#define TIFFTAG_WEBP_LOSSLESS_EXACT 65571 /* WebP lossless exact mode. Set-only mode. Default is 1. Can be set to 0 to increase compression rate, but R,G,B in areas where alpha = 0 will not be preserved */
-#define TIFFTAG_DEFLATE_SUBCODEC 65570 /* ZIP codec: to get/set the sub-codec to use. Will default to libdeflate when available */
-#define DEFLATE_SUBCODEC_ZLIB 0
-#define DEFLATE_SUBCODEC_LIBDEFLATE 1
-
-/*
- * EXIF tags
- */
-#define EXIFTAG_EXPOSURETIME 33434 /* Exposure time */
-#define EXIFTAG_FNUMBER 33437 /* F number */
-#define EXIFTAG_EXPOSUREPROGRAM 34850 /* Exposure program */
-#define EXIFTAG_SPECTRALSENSITIVITY 34852 /* Spectral sensitivity */
-/* After EXIF 2.2.1 ISOSpeedRatings is named PhotographicSensitivity.
- In addition, while "Count=Any", only 1 count should be used. */
-#define EXIFTAG_ISOSPEEDRATINGS 34855 /* ISO speed rating */
-#define EXIFTAG_PHOTOGRAPHICSENSITIVITY 34855 /* Photographic Sensitivity (new name for tag 34855) */
-#define EXIFTAG_OECF 34856 /* Optoelectric conversion factor */
-#define EXIFTAG_EXIFVERSION 36864 /* Exif version */
-#define EXIFTAG_DATETIMEORIGINAL 36867 /* Date and time of original data generation */
-#define EXIFTAG_DATETIMEDIGITIZED 36868 /* Date and time of digital data generation */
-#define EXIFTAG_COMPONENTSCONFIGURATION 37121 /* Meaning of each component */
-#define EXIFTAG_COMPRESSEDBITSPERPIXEL 37122 /* Image compression mode */
-#define EXIFTAG_SHUTTERSPEEDVALUE 37377 /* Shutter speed */
-#define EXIFTAG_APERTUREVALUE 37378 /* Aperture */
-#define EXIFTAG_BRIGHTNESSVALUE 37379 /* Brightness */
-#define EXIFTAG_EXPOSUREBIASVALUE 37380 /* Exposure bias */
-#define EXIFTAG_MAXAPERTUREVALUE 37381 /* Maximum lens aperture */
-#define EXIFTAG_SUBJECTDISTANCE 37382 /* Subject distance */
-#define EXIFTAG_METERINGMODE 37383 /* Metering mode */
-#define EXIFTAG_LIGHTSOURCE 37384 /* Light source */
-#define EXIFTAG_FLASH 37385 /* Flash */
-#define EXIFTAG_FOCALLENGTH 37386 /* Lens focal length */
-#define EXIFTAG_SUBJECTAREA 37396 /* Subject area */
-#define EXIFTAG_MAKERNOTE 37500 /* Manufacturer notes */
-#define EXIFTAG_USERCOMMENT 37510 /* User comments */
-#define EXIFTAG_SUBSECTIME 37520 /* DateTime subseconds */
-#define EXIFTAG_SUBSECTIMEORIGINAL 37521 /* DateTimeOriginal subseconds */
-#define EXIFTAG_SUBSECTIMEDIGITIZED 37522 /* DateTimeDigitized subseconds */
-#define EXIFTAG_FLASHPIXVERSION 40960 /* Supported Flashpix version */
-#define EXIFTAG_COLORSPACE 40961 /* Color space information */
-#define EXIFTAG_PIXELXDIMENSION 40962 /* Valid image width */
-#define EXIFTAG_PIXELYDIMENSION 40963 /* Valid image height */
-#define EXIFTAG_RELATEDSOUNDFILE 40964 /* Related audio file */
-#define EXIFTAG_FLASHENERGY 41483 /* Flash energy */
-#define EXIFTAG_SPATIALFREQUENCYRESPONSE 41484 /* Spatial frequency response */
-#define EXIFTAG_FOCALPLANEXRESOLUTION 41486 /* Focal plane X resolution */
-#define EXIFTAG_FOCALPLANEYRESOLUTION 41487 /* Focal plane Y resolution */
-#define EXIFTAG_FOCALPLANERESOLUTIONUNIT 41488 /* Focal plane resolution unit */
-#define EXIFTAG_SUBJECTLOCATION 41492 /* Subject location */
-#define EXIFTAG_EXPOSUREINDEX 41493 /* Exposure index */
-#define EXIFTAG_SENSINGMETHOD 41495 /* Sensing method */
-#define EXIFTAG_FILESOURCE 41728 /* File source */
-#define EXIFTAG_SCENETYPE 41729 /* Scene type */
-#define EXIFTAG_CFAPATTERN 41730 /* CFA pattern */
-#define EXIFTAG_CUSTOMRENDERED 41985 /* Custom image processing */
-#define EXIFTAG_EXPOSUREMODE 41986 /* Exposure mode */
-#define EXIFTAG_WHITEBALANCE 41987 /* White balance */
-#define EXIFTAG_DIGITALZOOMRATIO 41988 /* Digital zoom ratio */
-#define EXIFTAG_FOCALLENGTHIN35MMFILM 41989 /* Focal length in 35 mm film */
-#define EXIFTAG_SCENECAPTURETYPE 41990 /* Scene capture type */
-#define EXIFTAG_GAINCONTROL 41991 /* Gain control */
-#define EXIFTAG_CONTRAST 41992 /* Contrast */
-#define EXIFTAG_SATURATION 41993 /* Saturation */
-#define EXIFTAG_SHARPNESS 41994 /* Sharpness */
-#define EXIFTAG_DEVICESETTINGDESCRIPTION 41995 /* Device settings description */
-#define EXIFTAG_SUBJECTDISTANCERANGE 41996 /* Subject distance range */
-#define EXIFTAG_IMAGEUNIQUEID 42016 /* Unique image ID */
-
-/*--: New for EXIF-Version 2.32, May 2019 ... */
-#define EXIFTAG_SENSITIVITYTYPE 34864 /* The SensitivityType tag indicates which one of the parameters of ISO12232 is the PhotographicSensitivity tag. */
-#define EXIFTAG_STANDARDOUTPUTSENSITIVITY 34865 /* This tag indicates the standard output sensitivity value of a camera or input device defined in ISO 12232. */
-#define EXIFTAG_RECOMMENDEDEXPOSUREINDEX 34866 /* recommended exposure index */
-#define EXIFTAG_ISOSPEED 34867 /* ISO speed value */
-#define EXIFTAG_ISOSPEEDLATITUDEYYY 34868 /* ISO speed latitude yyy */
-#define EXIFTAG_ISOSPEEDLATITUDEZZZ 34869 /* ISO speed latitude zzz */
-#define EXIFTAG_OFFSETTIME 36880 /* offset from UTC of the time of DateTime tag. */
-#define EXIFTAG_OFFSETTIMEORIGINAL 36881 /* offset from UTC of the time of DateTimeOriginal tag. */
-#define EXIFTAG_OFFSETTIMEDIGITIZED 36882 /* offset from UTC of the time of DateTimeDigitized tag. */
-#define EXIFTAG_TEMPERATURE 37888 /* Temperature as the ambient situation at the shot in dergee Celsius */
-#define EXIFTAG_HUMIDITY 37889 /* Humidity as the ambient situation at the shot in percent */
-#define EXIFTAG_PRESSURE 37890 /* Pressure as the ambient situation at the shot hecto-Pascal (hPa) */
-#define EXIFTAG_WATERDEPTH 37891 /* WaterDepth as the ambient situation at the shot in meter (m) */
-#define EXIFTAG_ACCELERATION 37892 /* Acceleration (a scalar regardless of direction) as the ambientsituation at the shot in units of mGal (10-5 m/s^2) */
-/* EXIFTAG_CAMERAELEVATIONANGLE: Elevation/depression. angle of the orientation of the camera(imaging optical axis)
- * as the ambient situation at the shot in degree from -180deg to +180deg. */
-#define EXIFTAG_CAMERAELEVATIONANGLE 37893
-#define EXIFTAG_CAMERAOWNERNAME 42032 /* owner of a camera */
-#define EXIFTAG_BODYSERIALNUMBER 42033 /* serial number of the body of the camera */
-/* EXIFTAG_LENSSPECIFICATION: minimum focal length (in mm), maximum focal length (in mm),minimum F number in the minimum focal length,
- * and minimum F number in the maximum focal length, */
-#define EXIFTAG_LENSSPECIFICATION 42034
-#define EXIFTAG_LENSMAKE 42035 /* the lens manufacturer */
-#define EXIFTAG_LENSMODEL 42036 /* the lens model name and model number */
-#define EXIFTAG_LENSSERIALNUMBER 42037 /* the serial number of the interchangeable lens */
-#define EXIFTAG_GAMMA 42240 /* value of coefficient gamma */
-#define EXIFTAG_COMPOSITEIMAGE 42080 /* composite image */
-#define EXIFTAG_SOURCEIMAGENUMBEROFCOMPOSITEIMAGE 42081 /* source image number of composite image */
-#define EXIFTAG_SOURCEEXPOSURETIMESOFCOMPOSITEIMAGE 42082 /* source exposure times of composite image */
-
-/*
- * EXIF-GPS tags (Version 2.31, July 2016)
- */
-#define GPSTAG_VERSIONID 0 /* Indicates the version of GPSInfoIFD. */
-#define GPSTAG_LATITUDEREF 1 /* Indicates whether the latitude is north or south latitude. */
-#define GPSTAG_LATITUDE 2 /* Indicates the latitude. */
-#define GPSTAG_LONGITUDEREF 3 /* Indicates whether the longitude is east or west longitude. */
-#define GPSTAG_LONGITUDE 4 /* Indicates the longitude. */
-#define GPSTAG_ALTITUDEREF 5 /* Indicates the altitude used as the reference altitude. */
-#define GPSTAG_ALTITUDE 6 /* Indicates the altitude based on the reference in GPSAltitudeRef. */
-#define GPSTAG_TIMESTAMP 7 /*Indicates the time as UTC (Coordinated Universal Time). */
-#define GPSTAG_SATELLITES 8 /*Indicates the GPS satellites used for measurements. */
-#define GPSTAG_STATUS 9 /* Indicates the status of the GPS receiver when the image is recorded. */
-#define GPSTAG_MEASUREMODE 10 /* Indicates the GPS measurement mode. */
-#define GPSTAG_DOP 11 /* Indicates the GPS DOP (data degree of precision). */
-#define GPSTAG_SPEEDREF 12 /* Indicates the unit used to express the GPS receiver speed of movement. */
-#define GPSTAG_SPEED 13 /* Indicates the speed of GPS receiver movement. */
-#define GPSTAG_TRACKREF 14 /* Indicates the reference for giving the direction of GPS receiver movement. */
-#define GPSTAG_TRACK 15 /* Indicates the direction of GPS receiver movement. */
-#define GPSTAG_IMGDIRECTIONREF 16 /* Indicates the reference for giving the direction of the image when it is captured. */
-#define GPSTAG_IMGDIRECTION 17 /* Indicates the direction of the image when it was captured. */
-#define GPSTAG_MAPDATUM 18 /* Indicates the geodetic survey data used by the GPS receiver. (e.g. WGS-84) */
-#define GPSTAG_DESTLATITUDEREF 19 /* Indicates whether the latitude of the destination point is north or south latitude. */
-#define GPSTAG_DESTLATITUDE 20 /* Indicates the latitude of the destination point. */
-#define GPSTAG_DESTLONGITUDEREF 21 /* Indicates whether the longitude of the destination point is east or west longitude. */
-#define GPSTAG_DESTLONGITUDE 22 /* Indicates the longitude of the destination point. */
-#define GPSTAG_DESTBEARINGREF 23 /* Indicates the reference used for giving the bearing to the destination point. */
-#define GPSTAG_DESTBEARING 24 /* Indicates the bearing to the destination point. */
-#define GPSTAG_DESTDISTANCEREF 25 /* Indicates the unit used to express the distance to the destination point. */
-#define GPSTAG_DESTDISTANCE 26 /* Indicates the distance to the destination point. */
-#define GPSTAG_PROCESSINGMETHOD 27 /* A character string recording the name of the method used for location finding. */
-#define GPSTAG_AREAINFORMATION 28 /* A character string recording the name of the GPS area. */
-#define GPSTAG_DATESTAMP 29 /* A character string recording date and time information relative to UTC (Coordinated Universal Time). */
-#define GPSTAG_DIFFERENTIAL 30 /* Indicates whether differential correction is applied to the GPS receiver. */
-#define GPSTAG_GPSHPOSITIONINGERROR 31 /* Indicates horizontal positioning errors in meters. */
-
-#endif /* _TIFF_ */
diff --git a/contrib/libs/libtiff/tiffconf.h b/contrib/libs/libtiff/tiffconf.h
deleted file mode 100644
index 97d19e1abd..0000000000
--- a/contrib/libs/libtiff/tiffconf.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- Configuration defines for installed libtiff.
- This file maintained for backward compatibility. Do not use definitions
- from this file in your programs.
-*/
-
-/* clang-format off */
-/* clang-format disabled because CMake scripts are very sensitive to the
- * formatting of this file. configure_file variables of type "" are
- * modified by clang-format and won't be substituted.
- */
-
-#ifndef _TIFFCONF_
-#define _TIFFCONF_
-
-
-#include <stddef.h>
-#include <stdint.h>
-#include <inttypes.h>
-
-
-/* Signed 16-bit type */
-#define TIFF_INT16_T int16_t
-
-/* Signed 32-bit type */
-#define TIFF_INT32_T int32_t
-
-/* Signed 64-bit type */
-#define TIFF_INT64_T int64_t
-
-/* Signed 8-bit type */
-#define TIFF_INT8_T int8_t
-
-/* Unsigned 16-bit type */
-#define TIFF_UINT16_T uint16_t
-
-/* Unsigned 32-bit type */
-#define TIFF_UINT32_T uint32_t
-
-/* Unsigned 64-bit type */
-#define TIFF_UINT64_T uint64_t
-
-/* Unsigned 8-bit type */
-#define TIFF_UINT8_T uint8_t
-
-/* Signed size type */
-#define TIFF_SSIZE_T int64_t
-
-/* Compatibility stuff. */
-
-/* Define as 0 or 1 according to the floating point format supported by the
- machine */
-#define HAVE_IEEEFP 1
-
-/* The concept of HOST_FILLORDER is broken. Since libtiff 4.5.1
- * this macro will always be hardcoded to FILLORDER_LSB2MSB on all
- * architectures, to reflect past long behavior of doing so on x86 architecture.
- * Note however that the default FillOrder used by libtiff is FILLORDER_MSB2LSB,
- * as mandated per the TIFF specification.
- * The influence of HOST_FILLORDER is only when passing the 'H' mode in
- * TIFFOpen().
- * You should NOT rely on this macro to decide the CPU endianness!
- * This macro will be removed in libtiff 4.6
- */
-#define HOST_FILLORDER FILLORDER_LSB2MSB
-
-/* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian
- (Intel) */
-#define HOST_BIGENDIAN 0
-
-/* Support CCITT Group 3 & 4 algorithms */
-#define CCITT_SUPPORT 1
-
-/* Support JPEG compression (requires IJG JPEG library) */
-#define JPEG_SUPPORT 1
-
-/* Support JBIG compression (requires JBIG-KIT library) */
-/* #undef JBIG_SUPPORT */
-
-/* Support LERC compression */
-/* #undef LERC_SUPPORT */
-
-/* Support LogLuv high dynamic range encoding */
-#define LOGLUV_SUPPORT 1
-
-/* Support LZW algorithm */
-#define LZW_SUPPORT 1
-
-/* Support NeXT 2-bit RLE algorithm */
-#define NEXT_SUPPORT 1
-
-/* Support Old JPEG compresson (read contrib/ojpeg/README first! Compilation
- fails with unpatched IJG JPEG library) */
-#define OJPEG_SUPPORT 1
-
-/* Support Macintosh PackBits algorithm */
-#define PACKBITS_SUPPORT 1
-
-/* Support Pixar log-format algorithm (requires Zlib) */
-#define PIXARLOG_SUPPORT 1
-
-/* Support ThunderScan 4-bit RLE algorithm */
-#define THUNDER_SUPPORT 1
-
-/* Support Deflate compression */
-#define ZIP_SUPPORT 1
-
-/* Support libdeflate enhanced compression */
-/* #undef LIBDEFLATE_SUPPORT */
-
-/* Support strip chopping (whether or not to convert single-strip uncompressed
- images to multiple strips of ~8Kb to reduce memory usage) */
-#define STRIPCHOP_DEFAULT TIFF_STRIPCHOP
-
-/* Enable SubIFD tag (330) support */
-#define SUBIFD_SUPPORT 1
-
-/* Treat extra sample as alpha (default enabled). The RGBA interface will
- treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many
- packages produce RGBA files but don't mark the alpha properly. */
-#define DEFAULT_EXTRASAMPLE_AS_ALPHA 1
-
-/* Pick up YCbCr subsampling info from the JPEG data stream to support files
- lacking the tag (default enabled). */
-#define CHECK_JPEG_YCBCR_SUBSAMPLING 1
-
-/* Support MS MDI magic number files as TIFF */
-#define MDI_SUPPORT 1
-
-/*
- * Feature support definitions.
- * XXX: These macros are obsoleted. Don't use them in your apps!
- * Macros stays here for backward compatibility and should be always defined.
- */
-#define COLORIMETRY_SUPPORT
-#define YCBCR_SUPPORT
-#define CMYK_SUPPORT
-#define ICC_SUPPORT
-#define PHOTOSHOP_SUPPORT
-#define IPTC_SUPPORT
-
-#endif /* _TIFFCONF_ */
-
-/* clang-format on */
diff --git a/contrib/libs/libtiff/tiffio.h b/contrib/libs/libtiff/tiffio.h
deleted file mode 100644
index 225f3c1bfe..0000000000
--- a/contrib/libs/libtiff/tiffio.h
+++ /dev/null
@@ -1,653 +0,0 @@
-/*
- * Copyright (c) 1988-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-#ifndef _TIFFIO_
-#define _TIFFIO_
-
-/*
- * TIFF I/O Library Definitions.
- */
-#include "tiff.h"
-#include "tiffvers.h"
-
-/*
- * TIFF is defined as an incomplete type to hide the
- * library's internal data structures from clients.
- */
-typedef struct tiff TIFF;
-
-/*
- * The following typedefs define the intrinsic size of
- * data types used in the *exported* interfaces. These
- * definitions depend on the proper definition of types
- * in tiff.h. Note also that the varargs interface used
- * to pass tag types and values uses the types defined in
- * tiff.h directly.
- *
- * NB: ttag_t is unsigned int and not unsigned short because
- * ANSI C requires that the type before the ellipsis be a
- * promoted type (i.e. one of int, unsigned int, pointer,
- * or double) and because we defined pseudo-tags that are
- * outside the range of legal Aldus-assigned tags.
- * NB: tsize_t is signed and not unsigned because some functions
- * return -1.
- * NB: toff_t is not off_t for many reasons; TIFFs max out at
- * 32-bit file offsets, and BigTIFF maxes out at 64-bit
- * offsets being the most important, and to ensure use of
- * a consistently unsigned type across architectures.
- * Prior to libtiff 4.0, this was an unsigned 32 bit type.
- */
-/*
- * this is the machine addressing size type, only it's signed, so make it
- * int32_t on 32bit machines, int64_t on 64bit machines
- */
-typedef TIFF_SSIZE_T tmsize_t;
-#define TIFF_TMSIZE_T_MAX (tmsize_t)(SIZE_MAX >> 1)
-
-typedef uint64_t toff_t; /* file offset */
-/* the following are deprecated and should be replaced by their defining
- counterparts */
-typedef uint32_t ttag_t; /* directory tag */
-typedef uint32_t tdir_t; /* directory index */
-typedef uint16_t tsample_t; /* sample number */
-typedef uint32_t tstrile_t; /* strip or tile number */
-typedef tstrile_t tstrip_t; /* strip number */
-typedef tstrile_t ttile_t; /* tile number */
-typedef tmsize_t tsize_t; /* i/o size in bytes */
-typedef void *tdata_t; /* image data ref */
-
-/*
- * On windows you should define USE_WIN32_FILEIO if you are using tif_win32.c
- * or AVOID_WIN32_FILEIO if you are using something else (like tif_unix.c).
- *
- * By default tif_unix.c is assumed.
- */
-
-#if defined(_WIN32)
-#if !defined(__CYGWIN) && !defined(AVOID_WIN32_FILEIO) && \
- !defined(USE_WIN32_FILEIO)
-#define AVOID_WIN32_FILEIO
-#endif
-#endif
-
-#if defined(USE_WIN32_FILEIO)
-#define VC_EXTRALEAN
-#include <windows.h>
-#ifdef _WIN32
-DECLARE_HANDLE(thandle_t); /* Win32 file handle */
-#else
-typedef HFILE thandle_t; /* client data handle */
-#endif /* _WIN32 */
-#else
-typedef void *thandle_t; /* client data handle */
-#endif /* USE_WIN32_FILEIO */
-
-/*
- * Flags to pass to TIFFPrintDirectory to control
- * printing of data structures that are potentially
- * very large. Bit-or these flags to enable printing
- * multiple items.
- */
-#define TIFFPRINT_NONE 0x0 /* no extra info */
-#define TIFFPRINT_STRIPS 0x1 /* strips/tiles info */
-#define TIFFPRINT_CURVES 0x2 /* color/gray response curves */
-#define TIFFPRINT_COLORMAP 0x4 /* colormap */
-#define TIFFPRINT_JPEGQTABLES 0x100 /* JPEG Q matrices */
-#define TIFFPRINT_JPEGACTABLES 0x200 /* JPEG AC tables */
-#define TIFFPRINT_JPEGDCTABLES 0x200 /* JPEG DC tables */
-
-/*
- * Colour conversion stuff
- */
-
-/* reference white */
-#define D65_X0 (95.0470F)
-#define D65_Y0 (100.0F)
-#define D65_Z0 (108.8827F)
-
-#define D50_X0 (96.4250F)
-#define D50_Y0 (100.0F)
-#define D50_Z0 (82.4680F)
-
-/* Structure for holding information about a display device. */
-
-typedef unsigned char TIFFRGBValue; /* 8-bit samples */
-
-typedef struct
-{
- float d_mat[3][3]; /* XYZ -> luminance matrix */
- float d_YCR; /* Light o/p for reference white */
- float d_YCG;
- float d_YCB;
- uint32_t d_Vrwr; /* Pixel values for ref. white */
- uint32_t d_Vrwg;
- uint32_t d_Vrwb;
- float d_Y0R; /* Residual light for black pixel */
- float d_Y0G;
- float d_Y0B;
- float d_gammaR; /* Gamma values for the three guns */
- float d_gammaG;
- float d_gammaB;
-} TIFFDisplay;
-
-typedef struct
-{ /* YCbCr->RGB support */
- TIFFRGBValue *clamptab; /* range clamping table */
- int *Cr_r_tab;
- int *Cb_b_tab;
- int32_t *Cr_g_tab;
- int32_t *Cb_g_tab;
- int32_t *Y_tab;
-} TIFFYCbCrToRGB;
-
-typedef struct
-{ /* CIE Lab 1976->RGB support */
- int range; /* Size of conversion table */
-#define CIELABTORGB_TABLE_RANGE 1500
- float rstep, gstep, bstep;
- float X0, Y0, Z0; /* Reference white point */
- TIFFDisplay display;
- float Yr2r[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yr to r */
- float Yg2g[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yg to g */
- float Yb2b[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yb to b */
-} TIFFCIELabToRGB;
-
-/*
- * RGBA-style image support.
- */
-typedef struct _TIFFRGBAImage TIFFRGBAImage;
-/*
- * The image reading and conversion routines invoke
- * ``put routines'' to copy/image/whatever tiles of
- * raw image data. A default set of routines are
- * provided to convert/copy raw image data to 8-bit
- * packed ABGR format rasters. Applications can supply
- * alternate routines that unpack the data into a
- * different format or, for example, unpack the data
- * and draw the unpacked raster on the display.
- */
-typedef void (*tileContigRoutine)(TIFFRGBAImage *, uint32_t *, uint32_t,
- uint32_t, uint32_t, uint32_t, int32_t,
- int32_t, unsigned char *);
-typedef void (*tileSeparateRoutine)(TIFFRGBAImage *, uint32_t *, uint32_t,
- uint32_t, uint32_t, uint32_t, int32_t,
- int32_t, unsigned char *, unsigned char *,
- unsigned char *, unsigned char *);
-/*
- * RGBA-reader state.
- */
-struct _TIFFRGBAImage
-{
- TIFF *tif; /* image handle */
- int stoponerr; /* stop on read error */
- int isContig; /* data is packed/separate */
- int alpha; /* type of alpha data present */
- uint32_t width; /* image width */
- uint32_t height; /* image height */
- uint16_t bitspersample; /* image bits/sample */
- uint16_t samplesperpixel; /* image samples/pixel */
- uint16_t orientation; /* image orientation */
- uint16_t req_orientation; /* requested orientation */
- uint16_t photometric; /* image photometric interp */
- uint16_t *redcmap; /* colormap palette */
- uint16_t *greencmap;
- uint16_t *bluecmap;
- /* get image data routine */
- int (*get)(TIFFRGBAImage *, uint32_t *, uint32_t, uint32_t);
- /* put decoded strip/tile */
- union
- {
- void (*any)(TIFFRGBAImage *);
- tileContigRoutine contig;
- tileSeparateRoutine separate;
- } put;
- TIFFRGBValue *Map; /* sample mapping array */
- uint32_t **BWmap; /* black&white map */
- uint32_t **PALmap; /* palette image map */
- TIFFYCbCrToRGB *ycbcr; /* YCbCr conversion state */
- TIFFCIELabToRGB *cielab; /* CIE L*a*b conversion state */
-
- uint8_t *UaToAa; /* Unassociated alpha to associated alpha conversion LUT */
- uint8_t *Bitdepth16To8; /* LUT for conversion from 16bit to 8bit values */
-
- int row_offset;
- int col_offset;
-};
-
-/*
- * Macros for extracting components from the
- * packed ABGR form returned by TIFFReadRGBAImage.
- */
-#define TIFFGetR(abgr) ((abgr)&0xff)
-#define TIFFGetG(abgr) (((abgr) >> 8) & 0xff)
-#define TIFFGetB(abgr) (((abgr) >> 16) & 0xff)
-#define TIFFGetA(abgr) (((abgr) >> 24) & 0xff)
-
-/*
- * A CODEC is a software package that implements decoding,
- * encoding, or decoding+encoding of a compression algorithm.
- * The library provides a collection of builtin codecs.
- * More codecs may be registered through calls to the library
- * and/or the builtin implementations may be overridden.
- */
-typedef int (*TIFFInitMethod)(TIFF *, int);
-typedef struct
-{
- char *name;
- uint16_t scheme;
- TIFFInitMethod init;
-} TIFFCodec;
-
-typedef struct
-{
- uint32_t uNum;
- uint32_t uDenom;
-} TIFFRational_t;
-
-#include <stdarg.h>
-#include <stdio.h>
-
-/* share internal LogLuv conversion routines? */
-#ifndef LOGLUV_PUBLIC
-#define LOGLUV_PUBLIC 1
-#endif
-
-#if defined(__GNUC__) || defined(__clang__) || defined(__attribute__)
-#define TIFF_ATTRIBUTE(x) __attribute__(x)
-#else
-#define TIFF_ATTRIBUTE(x) /*nothing*/
-#endif
-
-#if defined(c_plusplus) || defined(__cplusplus)
-extern "C"
-{
-#endif
- typedef void (*TIFFErrorHandler)(const char *, const char *, va_list);
- typedef void (*TIFFErrorHandlerExt)(thandle_t, const char *, const char *,
- va_list);
- typedef int (*TIFFErrorHandlerExtR)(TIFF *, void *user_data, const char *,
- const char *, va_list);
- typedef tmsize_t (*TIFFReadWriteProc)(thandle_t, void *, tmsize_t);
- typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int);
- typedef int (*TIFFCloseProc)(thandle_t);
- typedef toff_t (*TIFFSizeProc)(thandle_t);
- typedef int (*TIFFMapFileProc)(thandle_t, void **base, toff_t *size);
- typedef void (*TIFFUnmapFileProc)(thandle_t, void *base, toff_t size);
- typedef void (*TIFFExtendProc)(TIFF *);
-
- extern const char *TIFFGetVersion(void);
-
- extern const TIFFCodec *TIFFFindCODEC(uint16_t);
- extern TIFFCodec *TIFFRegisterCODEC(uint16_t, const char *, TIFFInitMethod);
- extern void TIFFUnRegisterCODEC(TIFFCodec *);
- extern int TIFFIsCODECConfigured(uint16_t);
- extern TIFFCodec *TIFFGetConfiguredCODECs(void);
-
- /*
- * Auxiliary functions.
- */
-#ifndef TIFF_DO_NOT_USE_NON_EXT_ALLOC_FUNCTIONS
- extern void *_TIFFmalloc(tmsize_t s);
- extern void *_TIFFcalloc(tmsize_t nmemb, tmsize_t siz);
- extern void *_TIFFrealloc(void *p, tmsize_t s);
- extern void _TIFFfree(void *p);
-#endif
- extern void _TIFFmemset(void *p, int v, tmsize_t c);
- extern void _TIFFmemcpy(void *d, const void *s, tmsize_t c);
- extern int _TIFFmemcmp(const void *p1, const void *p2, tmsize_t c);
-
- /*
- ** Stuff, related to tag handling and creating custom tags.
- */
- extern int TIFFGetTagListCount(TIFF *);
- extern uint32_t TIFFGetTagListEntry(TIFF *, int tag_index);
-
-#define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */
-#define TIFF_VARIABLE -1 /* marker for variable length tags */
-#define TIFF_SPP -2 /* marker for SamplesPerPixel tags */
-#define TIFF_VARIABLE2 -3 /* marker for uint32_t var-length tags */
-
-#define FIELD_CUSTOM 65
-
- typedef struct _TIFFField TIFFField;
- typedef struct _TIFFFieldArray TIFFFieldArray;
-
- extern const TIFFField *TIFFFindField(TIFF *, uint32_t, TIFFDataType);
- extern const TIFFField *TIFFFieldWithTag(TIFF *, uint32_t);
- extern const TIFFField *TIFFFieldWithName(TIFF *, const char *);
-
- extern uint32_t TIFFFieldTag(const TIFFField *);
- extern const char *TIFFFieldName(const TIFFField *);
- extern TIFFDataType TIFFFieldDataType(const TIFFField *);
- extern int TIFFFieldPassCount(const TIFFField *);
- extern int TIFFFieldReadCount(const TIFFField *);
- extern int TIFFFieldWriteCount(const TIFFField *);
- extern int
- TIFFFieldSetGetSize(const TIFFField *); /* returns internal storage size of
- TIFFSetGetFieldType in bytes. */
- extern int TIFFFieldSetGetCountSize(
- const TIFFField *); /* returns size of count parameter 0=none,
- 2=uint16_t, 4=uint32_t */
- extern int TIFFFieldIsAnonymous(const TIFFField *);
-
- typedef int (*TIFFVSetMethod)(TIFF *, uint32_t, va_list);
- typedef int (*TIFFVGetMethod)(TIFF *, uint32_t, va_list);
- typedef void (*TIFFPrintMethod)(TIFF *, FILE *, long);
-
- typedef struct
- {
- TIFFVSetMethod vsetfield; /* tag set routine */
- TIFFVGetMethod vgetfield; /* tag get routine */
- TIFFPrintMethod printdir; /* directory print routine */
- } TIFFTagMethods;
-
- extern TIFFTagMethods *TIFFAccessTagMethods(TIFF *);
- extern void *TIFFGetClientInfo(TIFF *, const char *);
- extern void TIFFSetClientInfo(TIFF *, void *, const char *);
-
- extern void TIFFCleanup(TIFF *tif);
- extern void TIFFClose(TIFF *tif);
- extern int TIFFFlush(TIFF *tif);
- extern int TIFFFlushData(TIFF *tif);
- extern int TIFFGetField(TIFF *tif, uint32_t tag, ...);
- extern int TIFFVGetField(TIFF *tif, uint32_t tag, va_list ap);
- extern int TIFFGetFieldDefaulted(TIFF *tif, uint32_t tag, ...);
- extern int TIFFVGetFieldDefaulted(TIFF *tif, uint32_t tag, va_list ap);
- extern int TIFFReadDirectory(TIFF *tif);
- extern int TIFFReadCustomDirectory(TIFF *tif, toff_t diroff,
- const TIFFFieldArray *infoarray);
- extern int TIFFReadEXIFDirectory(TIFF *tif, toff_t diroff);
- extern int TIFFReadGPSDirectory(TIFF *tif, toff_t diroff);
- extern uint64_t TIFFScanlineSize64(TIFF *tif);
- extern tmsize_t TIFFScanlineSize(TIFF *tif);
- extern uint64_t TIFFRasterScanlineSize64(TIFF *tif);
- extern tmsize_t TIFFRasterScanlineSize(TIFF *tif);
- extern uint64_t TIFFStripSize64(TIFF *tif);
- extern tmsize_t TIFFStripSize(TIFF *tif);
- extern uint64_t TIFFRawStripSize64(TIFF *tif, uint32_t strip);
- extern tmsize_t TIFFRawStripSize(TIFF *tif, uint32_t strip);
- extern uint64_t TIFFVStripSize64(TIFF *tif, uint32_t nrows);
- extern tmsize_t TIFFVStripSize(TIFF *tif, uint32_t nrows);
- extern uint64_t TIFFTileRowSize64(TIFF *tif);
- extern tmsize_t TIFFTileRowSize(TIFF *tif);
- extern uint64_t TIFFTileSize64(TIFF *tif);
- extern tmsize_t TIFFTileSize(TIFF *tif);
- extern uint64_t TIFFVTileSize64(TIFF *tif, uint32_t nrows);
- extern tmsize_t TIFFVTileSize(TIFF *tif, uint32_t nrows);
- extern uint32_t TIFFDefaultStripSize(TIFF *tif, uint32_t request);
- extern void TIFFDefaultTileSize(TIFF *, uint32_t *, uint32_t *);
- extern int TIFFFileno(TIFF *);
- extern int TIFFSetFileno(TIFF *, int);
- extern thandle_t TIFFClientdata(TIFF *);
- extern thandle_t TIFFSetClientdata(TIFF *, thandle_t);
- extern int TIFFGetMode(TIFF *);
- extern int TIFFSetMode(TIFF *, int);
- extern int TIFFIsTiled(TIFF *);
- extern int TIFFIsByteSwapped(TIFF *);
- extern int TIFFIsUpSampled(TIFF *);
- extern int TIFFIsMSB2LSB(TIFF *);
- extern int TIFFIsBigEndian(TIFF *);
- extern int TIFFIsBigTIFF(TIFF *);
- extern TIFFReadWriteProc TIFFGetReadProc(TIFF *);
- extern TIFFReadWriteProc TIFFGetWriteProc(TIFF *);
- extern TIFFSeekProc TIFFGetSeekProc(TIFF *);
- extern TIFFCloseProc TIFFGetCloseProc(TIFF *);
- extern TIFFSizeProc TIFFGetSizeProc(TIFF *);
- extern TIFFMapFileProc TIFFGetMapFileProc(TIFF *);
- extern TIFFUnmapFileProc TIFFGetUnmapFileProc(TIFF *);
- extern uint32_t TIFFCurrentRow(TIFF *);
- extern tdir_t TIFFCurrentDirectory(TIFF *);
- extern tdir_t TIFFNumberOfDirectories(TIFF *);
- extern uint64_t TIFFCurrentDirOffset(TIFF *);
- extern uint32_t TIFFCurrentStrip(TIFF *);
- extern uint32_t TIFFCurrentTile(TIFF *tif);
- extern int TIFFReadBufferSetup(TIFF *tif, void *bp, tmsize_t size);
- extern int TIFFWriteBufferSetup(TIFF *tif, void *bp, tmsize_t size);
- extern int TIFFSetupStrips(TIFF *);
- extern int TIFFWriteCheck(TIFF *, int, const char *);
- extern void TIFFFreeDirectory(TIFF *);
- extern int TIFFCreateDirectory(TIFF *);
- extern int TIFFCreateCustomDirectory(TIFF *, const TIFFFieldArray *);
- extern int TIFFCreateEXIFDirectory(TIFF *);
- extern int TIFFCreateGPSDirectory(TIFF *);
- extern int TIFFLastDirectory(TIFF *);
- extern int TIFFSetDirectory(TIFF *, tdir_t);
- extern int TIFFSetSubDirectory(TIFF *, uint64_t);
- extern int TIFFUnlinkDirectory(TIFF *, tdir_t);
- extern int TIFFSetField(TIFF *, uint32_t, ...);
- extern int TIFFVSetField(TIFF *, uint32_t, va_list);
- extern int TIFFUnsetField(TIFF *, uint32_t);
- extern int TIFFWriteDirectory(TIFF *);
- extern int TIFFWriteCustomDirectory(TIFF *, uint64_t *);
- extern int TIFFCheckpointDirectory(TIFF *);
- extern int TIFFRewriteDirectory(TIFF *);
- extern int TIFFDeferStrileArrayWriting(TIFF *);
- extern int TIFFForceStrileArrayWriting(TIFF *);
-
-#if defined(c_plusplus) || defined(__cplusplus)
- extern void TIFFPrintDirectory(TIFF *, FILE *, long = 0);
- extern int TIFFReadScanline(TIFF *tif, void *buf, uint32_t row,
- uint16_t sample = 0);
- extern int TIFFWriteScanline(TIFF *tif, void *buf, uint32_t row,
- uint16_t sample = 0);
- extern int TIFFReadRGBAImage(TIFF *, uint32_t, uint32_t, uint32_t *,
- int = 0);
- extern int TIFFReadRGBAImageOriented(TIFF *, uint32_t, uint32_t, uint32_t *,
- int = ORIENTATION_BOTLEFT, int = 0);
-#else
-extern void TIFFPrintDirectory(TIFF *, FILE *, long);
-extern int TIFFReadScanline(TIFF *tif, void *buf, uint32_t row,
- uint16_t sample);
-extern int TIFFWriteScanline(TIFF *tif, void *buf, uint32_t row,
- uint16_t sample);
-extern int TIFFReadRGBAImage(TIFF *, uint32_t, uint32_t, uint32_t *, int);
-extern int TIFFReadRGBAImageOriented(TIFF *, uint32_t, uint32_t, uint32_t *,
- int, int);
-#endif
-
- extern int TIFFReadRGBAStrip(TIFF *, uint32_t, uint32_t *);
- extern int TIFFReadRGBATile(TIFF *, uint32_t, uint32_t, uint32_t *);
- extern int TIFFReadRGBAStripExt(TIFF *, uint32_t, uint32_t *,
- int stop_on_error);
- extern int TIFFReadRGBATileExt(TIFF *, uint32_t, uint32_t, uint32_t *,
- int stop_on_error);
- extern int TIFFRGBAImageOK(TIFF *, char[1024]);
- extern int TIFFRGBAImageBegin(TIFFRGBAImage *, TIFF *, int, char[1024]);
- extern int TIFFRGBAImageGet(TIFFRGBAImage *, uint32_t *, uint32_t,
- uint32_t);
- extern void TIFFRGBAImageEnd(TIFFRGBAImage *);
-
- extern const char *TIFFFileName(TIFF *);
- extern const char *TIFFSetFileName(TIFF *, const char *);
- extern void TIFFError(const char *, const char *, ...)
- TIFF_ATTRIBUTE((__format__(__printf__, 2, 3)));
- extern void TIFFErrorExt(thandle_t, const char *, const char *, ...)
- TIFF_ATTRIBUTE((__format__(__printf__, 3, 4)));
- extern void TIFFWarning(const char *, const char *, ...)
- TIFF_ATTRIBUTE((__format__(__printf__, 2, 3)));
- extern void TIFFWarningExt(thandle_t, const char *, const char *, ...)
- TIFF_ATTRIBUTE((__format__(__printf__, 3, 4)));
- extern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler);
- extern TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt);
- extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler);
- extern TIFFErrorHandlerExt TIFFSetWarningHandlerExt(TIFFErrorHandlerExt);
-
- extern void TIFFWarningExtR(TIFF *, const char *, const char *, ...)
- TIFF_ATTRIBUTE((__format__(__printf__, 3, 4)));
- extern void TIFFErrorExtR(TIFF *, const char *, const char *, ...)
- TIFF_ATTRIBUTE((__format__(__printf__, 3, 4)));
-
- typedef struct TIFFOpenOptions TIFFOpenOptions;
- extern TIFFOpenOptions *TIFFOpenOptionsAlloc(void);
- extern void TIFFOpenOptionsFree(TIFFOpenOptions *);
- extern void
- TIFFOpenOptionsSetMaxSingleMemAlloc(TIFFOpenOptions *opts,
- tmsize_t max_single_mem_alloc);
- extern void
- TIFFOpenOptionsSetMaxCumulatedMemAlloc(TIFFOpenOptions *opts,
- tmsize_t max_cumulated_mem_alloc);
- extern void
- TIFFOpenOptionsSetErrorHandlerExtR(TIFFOpenOptions *opts,
- TIFFErrorHandlerExtR handler,
- void *errorhandler_user_data);
- extern void
- TIFFOpenOptionsSetWarningHandlerExtR(TIFFOpenOptions *opts,
- TIFFErrorHandlerExtR handler,
- void *warnhandler_user_data);
-
- extern TIFF *TIFFOpen(const char *, const char *);
- extern TIFF *TIFFOpenExt(const char *, const char *, TIFFOpenOptions *opts);
-#ifdef _WIN32
- extern TIFF *TIFFOpenW(const wchar_t *, const char *);
- extern TIFF *TIFFOpenWExt(const wchar_t *, const char *,
- TIFFOpenOptions *opts);
-#endif /* _WIN32 */
- extern TIFF *TIFFFdOpen(int, const char *, const char *);
- extern TIFF *TIFFFdOpenExt(int, const char *, const char *,
- TIFFOpenOptions *opts);
- extern TIFF *TIFFClientOpen(const char *, const char *, thandle_t,
- TIFFReadWriteProc, TIFFReadWriteProc,
- TIFFSeekProc, TIFFCloseProc, TIFFSizeProc,
- TIFFMapFileProc, TIFFUnmapFileProc);
- extern TIFF *TIFFClientOpenExt(const char *, const char *, thandle_t,
- TIFFReadWriteProc, TIFFReadWriteProc,
- TIFFSeekProc, TIFFCloseProc, TIFFSizeProc,
- TIFFMapFileProc, TIFFUnmapFileProc,
- TIFFOpenOptions *opts);
- extern TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc);
- extern uint32_t TIFFComputeTile(TIFF *tif, uint32_t x, uint32_t y,
- uint32_t z, uint16_t s);
- extern int TIFFCheckTile(TIFF *tif, uint32_t x, uint32_t y, uint32_t z,
- uint16_t s);
- extern uint32_t TIFFNumberOfTiles(TIFF *);
- extern tmsize_t TIFFReadTile(TIFF *tif, void *buf, uint32_t x, uint32_t y,
- uint32_t z, uint16_t s);
- extern tmsize_t TIFFWriteTile(TIFF *tif, void *buf, uint32_t x, uint32_t y,
- uint32_t z, uint16_t s);
- extern uint32_t TIFFComputeStrip(TIFF *, uint32_t, uint16_t);
- extern uint32_t TIFFNumberOfStrips(TIFF *);
- extern tmsize_t TIFFReadEncodedStrip(TIFF *tif, uint32_t strip, void *buf,
- tmsize_t size);
- extern tmsize_t TIFFReadRawStrip(TIFF *tif, uint32_t strip, void *buf,
- tmsize_t size);
- extern tmsize_t TIFFReadEncodedTile(TIFF *tif, uint32_t tile, void *buf,
- tmsize_t size);
- extern tmsize_t TIFFReadRawTile(TIFF *tif, uint32_t tile, void *buf,
- tmsize_t size);
- extern int TIFFReadFromUserBuffer(TIFF *tif, uint32_t strile, void *inbuf,
- tmsize_t insize, void *outbuf,
- tmsize_t outsize);
- extern tmsize_t TIFFWriteEncodedStrip(TIFF *tif, uint32_t strip, void *data,
- tmsize_t cc);
- extern tmsize_t TIFFWriteRawStrip(TIFF *tif, uint32_t strip, void *data,
- tmsize_t cc);
- extern tmsize_t TIFFWriteEncodedTile(TIFF *tif, uint32_t tile, void *data,
- tmsize_t cc);
- extern tmsize_t TIFFWriteRawTile(TIFF *tif, uint32_t tile, void *data,
- tmsize_t cc);
- extern int TIFFDataWidth(
- TIFFDataType); /* table of tag datatype widths within TIFF file. */
- extern void TIFFSetWriteOffset(TIFF *tif, toff_t off);
- extern void TIFFSwabShort(uint16_t *);
- extern void TIFFSwabLong(uint32_t *);
- extern void TIFFSwabLong8(uint64_t *);
- extern void TIFFSwabFloat(float *);
- extern void TIFFSwabDouble(double *);
- extern void TIFFSwabArrayOfShort(uint16_t *wp, tmsize_t n);
- extern void TIFFSwabArrayOfTriples(uint8_t *tp, tmsize_t n);
- extern void TIFFSwabArrayOfLong(uint32_t *lp, tmsize_t n);
- extern void TIFFSwabArrayOfLong8(uint64_t *lp, tmsize_t n);
- extern void TIFFSwabArrayOfFloat(float *fp, tmsize_t n);
- extern void TIFFSwabArrayOfDouble(double *dp, tmsize_t n);
- extern void TIFFReverseBits(uint8_t *cp, tmsize_t n);
- extern const unsigned char *TIFFGetBitRevTable(int);
-
- extern uint64_t TIFFGetStrileOffset(TIFF *tif, uint32_t strile);
- extern uint64_t TIFFGetStrileByteCount(TIFF *tif, uint32_t strile);
- extern uint64_t TIFFGetStrileOffsetWithErr(TIFF *tif, uint32_t strile,
- int *pbErr);
- extern uint64_t TIFFGetStrileByteCountWithErr(TIFF *tif, uint32_t strile,
- int *pbErr);
-
-#ifdef LOGLUV_PUBLIC
-#define U_NEU 0.210526316
-#define V_NEU 0.473684211
-#define UVSCALE 410.
- extern double LogL16toY(int);
- extern double LogL10toY(int);
- extern void XYZtoRGB24(float *, uint8_t *);
- extern int uv_decode(double *, double *, int);
- extern void LogLuv24toXYZ(uint32_t, float *);
- extern void LogLuv32toXYZ(uint32_t, float *);
-#if defined(c_plusplus) || defined(__cplusplus)
- extern int LogL16fromY(double, int = SGILOGENCODE_NODITHER);
- extern int LogL10fromY(double, int = SGILOGENCODE_NODITHER);
- extern int uv_encode(double, double, int = SGILOGENCODE_NODITHER);
- extern uint32_t LogLuv24fromXYZ(float *, int = SGILOGENCODE_NODITHER);
- extern uint32_t LogLuv32fromXYZ(float *, int = SGILOGENCODE_NODITHER);
-#else
- extern int LogL16fromY(double, int);
- extern int LogL10fromY(double, int);
- extern int uv_encode(double, double, int);
- extern uint32_t LogLuv24fromXYZ(float *, int);
- extern uint32_t LogLuv32fromXYZ(float *, int);
-#endif
-#endif /* LOGLUV_PUBLIC */
-
- extern int TIFFCIELabToRGBInit(TIFFCIELabToRGB *, const TIFFDisplay *,
- float *);
- extern void TIFFCIELabToXYZ(TIFFCIELabToRGB *, uint32_t, int32_t, int32_t,
- float *, float *, float *);
- extern void TIFFXYZToRGB(TIFFCIELabToRGB *, float, float, float, uint32_t *,
- uint32_t *, uint32_t *);
-
- extern int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB *, float *, float *);
- extern void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *, uint32_t, int32_t, int32_t,
- uint32_t *, uint32_t *, uint32_t *);
-
- /****************************************************************************
- * O B S O L E T E D I N T E R F A C E S
- *
- * Don't use this stuff in your applications, it may be removed in the
- *future libtiff versions.
- ****************************************************************************/
- typedef struct
- {
- ttag_t field_tag; /* field's tag */
- short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */
- short field_writecount; /* write count/TIFF_VARIABLE */
- TIFFDataType field_type; /* type of associated data */
- unsigned short field_bit; /* bit in fieldsset bit vector */
- unsigned char field_oktochange; /* if true, can change while writing */
- unsigned char field_passcount; /* if true, pass dir count on set */
- char *field_name; /* ASCII name */
- } TIFFFieldInfo;
-
- extern int TIFFMergeFieldInfo(TIFF *, const TIFFFieldInfo[], uint32_t);
-
-#if defined(c_plusplus) || defined(__cplusplus)
-}
-#endif
-
-#endif /* _TIFFIO_ */
diff --git a/contrib/libs/libtiff/tiffio.hxx b/contrib/libs/libtiff/tiffio.hxx
deleted file mode 100644
index 6182449b13..0000000000
--- a/contrib/libs/libtiff/tiffio.hxx
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 1988-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-#ifndef _TIFFIO_HXX_
-#define _TIFFIO_HXX_
-
-/*
- * TIFF I/O library definitions which provide C++ streams API.
- */
-
-#include "tiff.h"
-#include "tiffio.h"
-#include <iostream>
-
-extern TIFF *TIFFStreamOpen(const char *, std::ostream *);
-extern TIFF *TIFFStreamOpen(const char *, std::istream *);
-
-#endif /* _TIFFIO_HXX_ */
diff --git a/contrib/libs/libtiff/tiffiop.h b/contrib/libs/libtiff/tiffiop.h
deleted file mode 100644
index c4348206df..0000000000
--- a/contrib/libs/libtiff/tiffiop.h
+++ /dev/null
@@ -1,545 +0,0 @@
-/*
- * Copyright (c) 1988-1997 Sam Leffler
- * Copyright (c) 1991-1997 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-#ifndef _TIFFIOP_
-#define _TIFFIOP_
-/*
- * ``Library-private'' definitions.
- */
-
-#include "tif_config.h"
-
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
-#include <string.h>
-
-#ifdef HAVE_ASSERT_H
-#include <assert.h>
-#else
-#define assert(x)
-#endif
-
-#include "tif_hash_set.h"
-#include "tiffio.h"
-
-#include "tif_dir.h"
-
-#include <limits.h>
-
-#ifndef STRIP_SIZE_DEFAULT
-#define STRIP_SIZE_DEFAULT 8192
-#endif
-
-#ifndef TIFF_MAX_DIR_COUNT
-#define TIFF_MAX_DIR_COUNT 1048576
-#endif
-
-#define TIFF_NON_EXISTENT_DIR_NUMBER UINT_MAX
-
-#define streq(a, b) (strcmp(a, b) == 0)
-#define strneq(a, b, n) (strncmp(a, b, n) == 0)
-
-#ifndef TRUE
-#define TRUE 1
-#define FALSE 0
-#endif
-
-typedef struct client_info
-{
- struct client_info *next;
- void *data;
- char *name;
-} TIFFClientInfoLink;
-
-/*
- * Typedefs for ``method pointers'' used internally.
- * these are deprecated and provided only for backwards compatibility.
- */
-typedef unsigned char tidataval_t; /* internal image data value type */
-typedef tidataval_t *tidata_t; /* reference to internal image data */
-
-typedef void (*TIFFVoidMethod)(TIFF *);
-typedef int (*TIFFBoolMethod)(TIFF *);
-typedef int (*TIFFPreMethod)(TIFF *, uint16_t);
-typedef int (*TIFFCodeMethod)(TIFF *tif, uint8_t *buf, tmsize_t size,
- uint16_t sample);
-typedef int (*TIFFSeekMethod)(TIFF *, uint32_t);
-typedef void (*TIFFPostMethod)(TIFF *tif, uint8_t *buf, tmsize_t size);
-typedef uint32_t (*TIFFStripMethod)(TIFF *, uint32_t);
-typedef void (*TIFFTileMethod)(TIFF *, uint32_t *, uint32_t *);
-
-struct TIFFOffsetAndDirNumber
-{
- uint64_t offset;
- tdir_t dirNumber;
-};
-typedef struct TIFFOffsetAndDirNumber TIFFOffsetAndDirNumber;
-
-typedef union
-{
- TIFFHeaderCommon common;
- TIFFHeaderClassic classic;
- TIFFHeaderBig big;
-} TIFFHeaderUnion;
-
-struct tiff
-{
- char *tif_name; /* name of open file */
- int tif_fd; /* open file descriptor */
- int tif_mode; /* open mode (O_*) */
- uint32_t tif_flags;
-#define TIFF_FILLORDER 0x00003U /* natural bit fill order for machine */
-#define TIFF_DIRTYHEADER 0x00004U /* header must be written on close */
-#define TIFF_DIRTYDIRECT 0x00008U /* current directory must be written */
-#define TIFF_BUFFERSETUP 0x00010U /* data buffers setup */
-#define TIFF_CODERSETUP 0x00020U /* encoder/decoder setup done */
-#define TIFF_BEENWRITING 0x00040U /* written 1+ scanlines to file */
-#define TIFF_SWAB 0x00080U /* byte swap file information */
-#define TIFF_NOBITREV 0x00100U /* inhibit bit reversal logic */
-#define TIFF_MYBUFFER 0x00200U /* my raw data buffer; free on close */
-#define TIFF_ISTILED 0x00400U /* file is tile, not strip- based */
-#define TIFF_MAPPED 0x00800U /* file is mapped into memory */
-#define TIFF_POSTENCODE 0x01000U /* need call to postencode routine */
-#define TIFF_INSUBIFD 0x02000U /* currently writing a subifd */
-#define TIFF_UPSAMPLED 0x04000U /* library is doing data up-sampling */
-#define TIFF_STRIPCHOP 0x08000U /* enable strip chopping support */
-#define TIFF_HEADERONLY \
- 0x10000U /* read header only, do not process the first directory */
-#define TIFF_NOREADRAW \
- 0x20000U /* skip reading of raw uncompressed image data */
-#define TIFF_INCUSTOMIFD 0x40000U /* currently writing a custom IFD */
-#define TIFF_BIGTIFF 0x80000U /* read/write bigtiff */
-#define TIFF_BUF4WRITE 0x100000U /* rawcc bytes are for writing */
-#define TIFF_DIRTYSTRIP 0x200000U /* stripoffsets/stripbytecount dirty*/
-#define TIFF_PERSAMPLE 0x400000U /* get/set per sample tags as arrays */
-#define TIFF_BUFFERMMAP \
- 0x800000U /* read buffer (tif_rawdata) points into mmap() memory */
-#define TIFF_DEFERSTRILELOAD \
- 0x1000000U /* defer strip/tile offset/bytecount array loading. */
-#define TIFF_LAZYSTRILELOAD \
- 0x2000000U /* lazy/ondemand loading of strip/tile offset/bytecount values. \
- Only used if TIFF_DEFERSTRILELOAD is set and in read-only \
- mode */
-#define TIFF_CHOPPEDUPARRAYS \
- 0x4000000U /* set when allocChoppedUpStripArrays() has modified strip \
- array */
- uint64_t tif_diroff; /* file offset of current directory */
- uint64_t tif_nextdiroff; /* file offset of following directory */
- uint64_t tif_lastdiroff; /* file offset of last directory written so far */
- TIFFHashSet *tif_map_dir_offset_to_number;
- TIFFHashSet *tif_map_dir_number_to_offset;
- int tif_setdirectory_force_absolute; /* switch between relative and absolute
- stepping in TIFFSetDirectory() */
- TIFFDirectory tif_dir; /* internal rep of current directory */
- TIFFDirectory
- tif_customdir; /* custom IFDs are separated from the main ones */
- TIFFHeaderUnion tif_header; /* file's header block Classic/BigTIFF union */
- uint16_t tif_header_size; /* file's header block and its length */
- uint32_t tif_row; /* current scanline */
-
- /* There are IFDs in the file and an "active" IFD in memory,
- * from which fields are "set" and "get".
- * tif_curdir is set to:
- * a) TIFF_NON_EXISTENT_DIR_NUMBER if there is no IFD in the file
- * or the state is unknown,
- * or the last read (i.e. TIFFFetchDirectory()) failed,
- * or a custom directory was written.
- * b) IFD index of last IFD written in the file. In this case the
- * active IFD is a new (empty) one and tif_diroff is zero.
- * If writing fails, tif_curdir is not changed.
- * c) IFD index of IFD read from file into memory (=active IFD),
- * even if IFD is corrupt and TIFFReadDirectory() returns 0.
- * Then tif_diroff contains the offset of the IFD in the file.
- * d) IFD index 0, whenever a custom directory or an unchained SubIFD
- * was read. */
- tdir_t tif_curdir; /* current directory (index) */
- /* tif_curdircount: number of directories (main-IFDs) in file:
- * - TIFF_NON_EXISTENT_DIR_NUMBER means 'dont know number of IFDs'.
- * - 0 means 'empty file opened for writing, but no IFD written yet' */
- tdir_t tif_curdircount;
- uint32_t tif_curstrip; /* current strip for read/write */
- uint64_t tif_curoff; /* current offset for read/write */
- uint64_t tif_lastvalidoff; /* last valid offset allowed for rewrite in
- place. Used only by TIFFAppendToStrip() */
- uint64_t tif_dataoff; /* current offset for writing dir (IFD) */
- /* SubIFD support */
- uint16_t tif_nsubifd; /* remaining subifds to write */
- uint64_t tif_subifdoff; /* offset for patching SubIFD link */
- /* tiling support */
- uint32_t tif_col; /* current column (offset by row too) */
- uint32_t tif_curtile; /* current tile for read/write */
- tmsize_t tif_tilesize; /* # of bytes in a tile */
- /* compression scheme hooks */
- int tif_decodestatus;
- TIFFBoolMethod tif_fixuptags; /* called in TIFFReadDirectory */
- TIFFBoolMethod tif_setupdecode; /* called once before predecode */
- TIFFPreMethod tif_predecode; /* pre- row/strip/tile decoding */
- TIFFBoolMethod tif_setupencode; /* called once before preencode */
- int tif_encodestatus;
- TIFFPreMethod tif_preencode; /* pre- row/strip/tile encoding */
- TIFFBoolMethod tif_postencode; /* post- row/strip/tile encoding */
- TIFFCodeMethod tif_decoderow; /* scanline decoding routine */
- TIFFCodeMethod tif_encoderow; /* scanline encoding routine */
- TIFFCodeMethod tif_decodestrip; /* strip decoding routine */
- TIFFCodeMethod tif_encodestrip; /* strip encoding routine */
- TIFFCodeMethod tif_decodetile; /* tile decoding routine */
- TIFFCodeMethod tif_encodetile; /* tile encoding routine */
- TIFFVoidMethod tif_close; /* cleanup-on-close routine */
- TIFFSeekMethod tif_seek; /* position within a strip routine */
- TIFFVoidMethod tif_cleanup; /* cleanup state routine */
- TIFFStripMethod tif_defstripsize; /* calculate/constrain strip size */
- TIFFTileMethod tif_deftilesize; /* calculate/constrain tile size */
- uint8_t *tif_data; /* compression scheme private data */
- /* input/output buffering */
- tmsize_t tif_scanlinesize; /* # of bytes in a scanline */
- tmsize_t tif_scanlineskew; /* scanline skew for reading strips */
- uint8_t *tif_rawdata; /* raw data buffer */
- tmsize_t tif_rawdatasize; /* # of bytes in raw data buffer */
- tmsize_t tif_rawdataoff; /* rawdata offset within strip */
- tmsize_t tif_rawdataloaded; /* amount of data in rawdata */
- uint8_t *tif_rawcp; /* current spot in raw buffer */
- tmsize_t tif_rawcc; /* bytes unread from raw buffer */
- /* memory-mapped file support */
- uint8_t *tif_base; /* base of mapped file */
- tmsize_t tif_size; /* size of mapped file region (bytes, thus tmsize_t) */
- TIFFMapFileProc tif_mapproc; /* map file method */
- TIFFUnmapFileProc tif_unmapproc; /* unmap file method */
- /* input/output callback methods */
- thandle_t tif_clientdata; /* callback parameter */
- TIFFReadWriteProc tif_readproc; /* read method */
- TIFFReadWriteProc tif_writeproc; /* write method */
- TIFFSeekProc tif_seekproc; /* lseek method */
- TIFFCloseProc tif_closeproc; /* close method */
- TIFFSizeProc tif_sizeproc; /* filesize method */
- /* post-decoding support */
- TIFFPostMethod tif_postdecode; /* post decoding routine */
- /* tag support */
- TIFFField **tif_fields; /* sorted table of registered tags */
- size_t tif_nfields; /* # entries in registered tag table */
- const TIFFField *tif_foundfield; /* cached pointer to already found tag */
- TIFFTagMethods tif_tagmethods; /* tag get/set/print routines */
- TIFFClientInfoLink *tif_clientinfo; /* extra client information. */
- /* Backward compatibility stuff. We need these two fields for
- * setting up an old tag extension scheme. */
- TIFFFieldArray *tif_fieldscompat;
- size_t tif_nfieldscompat;
- /* Error handler support */
- TIFFErrorHandlerExtR tif_errorhandler;
- void *tif_errorhandler_user_data;
- TIFFErrorHandlerExtR tif_warnhandler;
- void *tif_warnhandler_user_data;
- tmsize_t tif_max_single_mem_alloc; /* in bytes. 0 for unlimited */
- tmsize_t tif_max_cumulated_mem_alloc; /* in bytes. 0 for unlimited */
- tmsize_t tif_cur_cumulated_mem_alloc; /* in bytes */
-};
-
-struct TIFFOpenOptions
-{
- TIFFErrorHandlerExtR errorhandler; /* may be NULL */
- void *errorhandler_user_data; /* may be NULL */
- TIFFErrorHandlerExtR warnhandler; /* may be NULL */
- void *warnhandler_user_data; /* may be NULL */
- tmsize_t max_single_mem_alloc; /* in bytes. 0 for unlimited */
- tmsize_t max_cumulated_mem_alloc; /* in bytes. 0 for unlimited */
-};
-
-#define isPseudoTag(t) (t > 0xffff) /* is tag value normal or pseudo */
-
-#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
-#define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0)
-#define isFillOrder(tif, o) (((tif)->tif_flags & (o)) != 0)
-#define isUpSampled(tif) (((tif)->tif_flags & TIFF_UPSAMPLED) != 0)
-#define TIFFReadFile(tif, buf, size) \
- ((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size)))
-#define TIFFWriteFile(tif, buf, size) \
- ((*(tif)->tif_writeproc)((tif)->tif_clientdata, (buf), (size)))
-#define TIFFSeekFile(tif, off, whence) \
- ((*(tif)->tif_seekproc)((tif)->tif_clientdata, (off), (whence)))
-#define TIFFCloseFile(tif) ((*(tif)->tif_closeproc)((tif)->tif_clientdata))
-#define TIFFGetFileSize(tif) ((*(tif)->tif_sizeproc)((tif)->tif_clientdata))
-#define TIFFMapFileContents(tif, paddr, psize) \
- ((*(tif)->tif_mapproc)((tif)->tif_clientdata, (paddr), (psize)))
-#define TIFFUnmapFileContents(tif, addr, size) \
- ((*(tif)->tif_unmapproc)((tif)->tif_clientdata, (addr), (size)))
-
-/*
- * Default Read/Seek/Write definitions.
- */
-#ifndef ReadOK
-#define ReadOK(tif, buf, size) (TIFFReadFile((tif), (buf), (size)) == (size))
-#endif
-#ifndef SeekOK
-#define SeekOK(tif, off) _TIFFSeekOK(tif, off)
-#endif
-#ifndef WriteOK
-#define WriteOK(tif, buf, size) (TIFFWriteFile((tif), (buf), (size)) == (size))
-#endif
-
-/* NB: the uint32_t casts are to silence certain ANSI-C compilers */
-#define TIFFhowmany_32(x, y) \
- (((uint32_t)x < (0xffffffff - (uint32_t)(y - 1))) \
- ? ((((uint32_t)(x)) + (((uint32_t)(y)) - 1)) / ((uint32_t)(y))) \
- : 0U)
-/* Variant of TIFFhowmany_32() that doesn't return 0 if x close to MAXUINT. */
-/* Caution: TIFFhowmany_32_maxuint_compat(x,y)*y might overflow */
-#define TIFFhowmany_32_maxuint_compat(x, y) \
- (((uint32_t)(x) / (uint32_t)(y)) + \
- ((((uint32_t)(x) % (uint32_t)(y)) != 0) ? 1 : 0))
-#define TIFFhowmany8_32(x) \
- (((x)&0x07) ? ((uint32_t)(x) >> 3) + 1 : (uint32_t)(x) >> 3)
-#define TIFFroundup_32(x, y) (TIFFhowmany_32(x, y) * (y))
-#define TIFFhowmany_64(x, y) \
- ((((uint64_t)(x)) + (((uint64_t)(y)) - 1)) / ((uint64_t)(y)))
-#define TIFFhowmany8_64(x) \
- (((x)&0x07) ? ((uint64_t)(x) >> 3) + 1 : (uint64_t)(x) >> 3)
-#define TIFFroundup_64(x, y) (TIFFhowmany_64(x, y) * (y))
-
-/* Safe multiply which returns zero if there is an *unsigned* integer overflow.
- * This macro is not safe for *signed* integer types */
-#define TIFFSafeMultiply(t, v, m) \
- ((((t)(m) != (t)0) && (((t)(((v) * (m)) / (m))) == (t)(v))) \
- ? (t)((v) * (m)) \
- : (t)0)
-
-#define TIFFmax(A, B) ((A) > (B) ? (A) : (B))
-#define TIFFmin(A, B) ((A) < (B) ? (A) : (B))
-
-#define TIFFArrayCount(a) (sizeof(a) / sizeof((a)[0]))
-
-/*
- Support for large files.
-
- Windows read/write APIs support only 'unsigned int' rather than 'size_t'.
- Windows off_t is only 32-bit, even in 64-bit builds.
-*/
-#if defined(HAVE_FSEEKO)
-/*
- Use fseeko() and ftello() if they are available since they use
- 'off_t' rather than 'long'. It is wrong to use fseeko() and
- ftello() only on systems with special LFS support since some systems
- (e.g. FreeBSD) support a 64-bit off_t by default.
-
- For MinGW, __MSVCRT_VERSION__ must be at least 0x800 to expose these
- interfaces. The MinGW compiler must support the requested version. MinGW
- does not distribute the CRT (it is supplied by Microsoft) so the correct CRT
- must be available on the target computer in order for the program to run.
-*/
-#if defined(HAVE_FSEEKO)
-#define fseek(stream, offset, whence) fseeko(stream, offset, whence)
-#define ftell(stream, offset, whence) ftello(stream, offset, whence)
-#endif
-#endif
-#if defined(_WIN32) && \
- !(defined(__MSVCRT_VERSION__) && __MSVCRT_VERSION__ < 0x800)
-typedef unsigned int TIFFIOSize_t;
-#define _TIFF_lseek_f(fildes, offset, whence) \
- _lseeki64(fildes, /* __int64 */ offset, whence)
-/* #define _TIFF_tell_f(fildes) /\* __int64 *\/ _telli64(fildes) */
-#define _TIFF_fseek_f(stream, offset, whence) \
- _fseeki64(stream, /* __int64 */ offset, whence)
-#define _TIFF_fstat_f(fildes, stat_buff) \
- _fstati64(fildes, /* struct _stati64 */ stat_buff)
-/* #define _TIFF_ftell_f(stream) /\* __int64 *\/ _ftelli64(stream) */
-/* #define _TIFF_stat_f(path,stat_buff) _stati64(path,/\* struct _stati64 *\/
- * stat_buff) */
-#define _TIFF_stat_s struct _stati64
-#define _TIFF_off_t __int64
-#else
-typedef size_t TIFFIOSize_t;
-#define _TIFF_lseek_f(fildes, offset, whence) lseek(fildes, offset, whence)
-/* #define _TIFF_tell_f(fildes) (_TIFF_lseek_f(fildes,0,SEEK_CUR)) */
-#define _TIFF_fseek_f(stream, offset, whence) fseek(stream, offset, whence)
-#define _TIFF_fstat_f(fildes, stat_buff) fstat(fildes, stat_buff)
-/* #define _TIFF_ftell_f(stream) ftell(stream) */
-/* #define _TIFF_stat_f(path,stat_buff) stat(path,stat_buff) */
-#define _TIFF_stat_s struct stat
-#define _TIFF_off_t off_t
-#endif
-
-#if defined(__has_attribute) && defined(__clang__)
-#if __has_attribute(no_sanitize)
-#define TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW \
- __attribute__((no_sanitize("unsigned-integer-overflow")))
-#else
-#define TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW
-#endif
-#else
-#define TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW
-#endif
-
-#if defined(__cplusplus)
-extern "C"
-{
-#endif
- extern int _TIFFgetMode(TIFFOpenOptions *opts, thandle_t clientdata,
- const char *mode, const char *module);
- extern int _TIFFNoRowEncode(TIFF *tif, uint8_t *pp, tmsize_t cc,
- uint16_t s);
- extern int _TIFFNoStripEncode(TIFF *tif, uint8_t *pp, tmsize_t cc,
- uint16_t s);
- extern int _TIFFNoTileEncode(TIFF *, uint8_t *pp, tmsize_t cc, uint16_t s);
- extern int _TIFFNoRowDecode(TIFF *tif, uint8_t *pp, tmsize_t cc,
- uint16_t s);
- extern int _TIFFNoStripDecode(TIFF *tif, uint8_t *pp, tmsize_t cc,
- uint16_t s);
- extern int _TIFFNoTileDecode(TIFF *, uint8_t *pp, tmsize_t cc, uint16_t s);
- extern void _TIFFNoPostDecode(TIFF *tif, uint8_t *buf, tmsize_t cc);
- extern int _TIFFNoPreCode(TIFF *tif, uint16_t s);
- extern int _TIFFNoSeek(TIFF *tif, uint32_t off);
- extern void _TIFFSwab16BitData(TIFF *tif, uint8_t *buf, tmsize_t cc);
- extern void _TIFFSwab24BitData(TIFF *tif, uint8_t *buf, tmsize_t cc);
- extern void _TIFFSwab32BitData(TIFF *tif, uint8_t *buf, tmsize_t cc);
- extern void _TIFFSwab64BitData(TIFF *tif, uint8_t *buf, tmsize_t cc);
- extern int TIFFFlushData1(TIFF *tif);
- extern int TIFFDefaultDirectory(TIFF *tif);
- extern void _TIFFSetDefaultCompressionState(TIFF *tif);
- extern int _TIFFRewriteField(TIFF *, uint16_t, TIFFDataType, tmsize_t,
- void *);
- extern int TIFFSetCompressionScheme(TIFF *tif, int scheme);
- extern int TIFFSetDefaultCompressionState(TIFF *tif);
- extern uint32_t _TIFFDefaultStripSize(TIFF *tif, uint32_t s);
- extern void _TIFFDefaultTileSize(TIFF *tif, uint32_t *tw, uint32_t *th);
-
- extern void _TIFFsetByteArray(void **, const void *, uint32_t);
- extern void _TIFFsetByteArrayExt(TIFF *, void **, const void *, uint32_t);
- extern void _TIFFsetShortArray(uint16_t **, const uint16_t *, uint32_t);
- extern void _TIFFsetShortArrayExt(TIFF *, uint16_t **, const uint16_t *,
- uint32_t);
- extern void _TIFFsetLongArray(uint32_t **, const uint32_t *, uint32_t);
- extern void _TIFFsetLongArrayExt(TIFF *, uint32_t **, const uint32_t *,
- uint32_t);
- extern void _TIFFsetFloatArray(float **, const float *, uint32_t);
- extern void _TIFFsetFloatArrayExt(TIFF *, float **, const float *,
- uint32_t);
- extern void _TIFFsetDoubleArray(double **, const double *, uint32_t);
- extern void _TIFFsetDoubleArrayExt(TIFF *, double **, const double *,
- uint32_t);
-
- extern void _TIFFprintAscii(FILE *, const char *);
- extern void _TIFFprintAsciiTag(FILE *, const char *, const char *);
-
- extern TIFFErrorHandler _TIFFwarningHandler;
- extern TIFFErrorHandler _TIFFerrorHandler;
- extern TIFFErrorHandlerExt _TIFFwarningHandlerExt;
- extern TIFFErrorHandlerExt _TIFFerrorHandlerExt;
- void _TIFFErrorEarly(TIFFOpenOptions *opts, thandle_t clientdata,
- const char *module, const char *fmt, ...)
- TIFF_ATTRIBUTE((__format__(__printf__, 4, 5)));
-
- extern uint32_t _TIFFMultiply32(TIFF *, uint32_t, uint32_t, const char *);
- extern uint64_t _TIFFMultiply64(TIFF *, uint64_t, uint64_t, const char *);
- extern tmsize_t _TIFFMultiplySSize(TIFF *, tmsize_t, tmsize_t,
- const char *);
- extern tmsize_t _TIFFCastUInt64ToSSize(TIFF *, uint64_t, const char *);
- extern void *_TIFFCheckMalloc(TIFF *, tmsize_t, tmsize_t, const char *);
- extern void *_TIFFCheckRealloc(TIFF *, void *, tmsize_t, tmsize_t,
- const char *);
-
- extern float _TIFFClampDoubleToFloat(double);
- extern uint32_t _TIFFClampDoubleToUInt32(double);
-
- extern void _TIFFCleanupIFDOffsetAndNumberMaps(TIFF *tif);
-
- extern tmsize_t _TIFFReadEncodedStripAndAllocBuffer(TIFF *tif,
- uint32_t strip,
- void **buf,
- tmsize_t bufsizetoalloc,
- tmsize_t size_to_read);
- extern tmsize_t _TIFFReadEncodedTileAndAllocBuffer(TIFF *tif, uint32_t tile,
- void **buf,
- tmsize_t bufsizetoalloc,
- tmsize_t size_to_read);
- extern tmsize_t _TIFFReadTileAndAllocBuffer(TIFF *tif, void **buf,
- tmsize_t bufsizetoalloc,
- uint32_t x, uint32_t y,
- uint32_t z, uint16_t s);
- extern int _TIFFSeekOK(TIFF *tif, toff_t off);
-
- extern int TIFFInitDumpMode(TIFF *, int);
-#ifdef PACKBITS_SUPPORT
- extern int TIFFInitPackBits(TIFF *, int);
-#endif
-#ifdef CCITT_SUPPORT
- extern int TIFFInitCCITTRLE(TIFF *, int), TIFFInitCCITTRLEW(TIFF *, int);
- extern int TIFFInitCCITTFax3(TIFF *, int), TIFFInitCCITTFax4(TIFF *, int);
-#endif
-#ifdef THUNDER_SUPPORT
- extern int TIFFInitThunderScan(TIFF *, int);
-#endif
-#ifdef NEXT_SUPPORT
- extern int TIFFInitNeXT(TIFF *, int);
-#endif
-#ifdef LZW_SUPPORT
- extern int TIFFInitLZW(TIFF *, int);
-#endif
-#ifdef OJPEG_SUPPORT
- extern int TIFFInitOJPEG(TIFF *, int);
-#endif
-#ifdef JPEG_SUPPORT
- extern int TIFFInitJPEG(TIFF *, int);
- extern int TIFFJPEGIsFullStripRequired(TIFF *);
-#endif
-#ifdef JBIG_SUPPORT
- extern int TIFFInitJBIG(TIFF *, int);
-#endif
-#ifdef ZIP_SUPPORT
- extern int TIFFInitZIP(TIFF *, int);
-#endif
-#ifdef PIXARLOG_SUPPORT
- extern int TIFFInitPixarLog(TIFF *, int);
-#endif
-#ifdef LOGLUV_SUPPORT
- extern int TIFFInitSGILog(TIFF *, int);
-#endif
-#ifdef LERC_SUPPORT
- extern int TIFFInitLERC(TIFF *tif, int);
-#endif
-#ifdef LZMA_SUPPORT
- extern int TIFFInitLZMA(TIFF *, int);
-#endif
-#ifdef ZSTD_SUPPORT
- extern int TIFFInitZSTD(TIFF *, int);
-#endif
-#ifdef WEBP_SUPPORT
- extern int TIFFInitWebP(TIFF *, int);
-#endif
- extern const TIFFCodec _TIFFBuiltinCODECS[];
- extern void TIFFCIELab16ToXYZ(TIFFCIELabToRGB *, uint32_t l, int32_t a,
- int32_t b, float *, float *, float *);
-
- extern void *_TIFFmallocExt(TIFF *tif, tmsize_t s);
- extern void *_TIFFcallocExt(TIFF *tif, tmsize_t nmemb, tmsize_t siz);
- extern void *_TIFFreallocExt(TIFF *tif, void *p, tmsize_t s);
- extern void _TIFFfreeExt(TIFF *tif, void *p);
-
-#if defined(__cplusplus)
-}
-#endif
-#endif /* _TIFFIOP_ */
diff --git a/contrib/libs/libtiff/tiffvers.h b/contrib/libs/libtiff/tiffvers.h
deleted file mode 100644
index 9e886f133b..0000000000
--- a/contrib/libs/libtiff/tiffvers.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/* tiffvers.h version information is updated according to version information
- * in configure.ac */
-
-/* clang-format off */
-
-/* clang-format disabled because FindTIFF.cmake is very sensitive to the
- * formatting of below line being a single line.
- * Furthermore, configure_file variables of type "" are
- * modified by clang-format and won't be substituted by CMake.
- */
-#define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.7.0\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc."
-/*
- * This define can be used in code that requires
- * compilation-related definitions specific to a
- * version or versions of the library. Runtime
- * version checking should be done based on the
- * string returned by TIFFGetVersion.
- */
-#define TIFFLIB_VERSION 20240911
-
-/* The following defines have been added in 4.5.0 */
-#define TIFFLIB_MAJOR_VERSION 4
-#define TIFFLIB_MINOR_VERSION 7
-#define TIFFLIB_MICRO_VERSION 0
-#define TIFFLIB_VERSION_STR_MAJ_MIN_MIC "4.7.0"
-
-/* Macro added in 4.5.0. Returns TRUE if the current libtiff version is
- * greater or equal to major.minor.micro
- */
-#define TIFFLIB_AT_LEAST(major, minor, micro) \
- (TIFFLIB_MAJOR_VERSION > (major) || \
- (TIFFLIB_MAJOR_VERSION == (major) && TIFFLIB_MINOR_VERSION > (minor)) || \
- (TIFFLIB_MAJOR_VERSION == (major) && TIFFLIB_MINOR_VERSION == (minor) && \
- TIFFLIB_MICRO_VERSION >= (micro)))
-
-/* clang-format on */
diff --git a/contrib/libs/libtiff/uvcode.h b/contrib/libs/libtiff/uvcode.h
deleted file mode 100644
index fc87729244..0000000000
--- a/contrib/libs/libtiff/uvcode.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/* Version 1.0 generated April 7, 1997 by Greg Ward Larson, SGI */
-#define UV_SQSIZ (float)0.003500
-#define UV_NDIVS 16289
-#define UV_VSTART (float)0.016940
-#define UV_NVS 163
-static const struct
-{
- float ustart;
- short nus, ncum;
-} uv_row[UV_NVS] = {
- {(float)0.247663, 4, 0}, {(float)0.243779, 6, 4},
- {(float)0.241684, 7, 10}, {(float)0.237874, 9, 17},
- {(float)0.235906, 10, 26}, {(float)0.232153, 12, 36},
- {(float)0.228352, 14, 48}, {(float)0.226259, 15, 62},
- {(float)0.222371, 17, 77}, {(float)0.220410, 18, 94},
- {(float)0.214710, 21, 112}, {(float)0.212714, 22, 133},
- {(float)0.210721, 23, 155}, {(float)0.204976, 26, 178},
- {(float)0.202986, 27, 204}, {(float)0.199245, 29, 231},
- {(float)0.195525, 31, 260}, {(float)0.193560, 32, 291},
- {(float)0.189878, 34, 323}, {(float)0.186216, 36, 357},
- {(float)0.186216, 36, 393}, {(float)0.182592, 38, 429},
- {(float)0.179003, 40, 467}, {(float)0.175466, 42, 507},
- {(float)0.172001, 44, 549}, {(float)0.172001, 44, 593},
- {(float)0.168612, 46, 637}, {(float)0.168612, 46, 683},
- {(float)0.163575, 49, 729}, {(float)0.158642, 52, 778},
- {(float)0.158642, 52, 830}, {(float)0.158642, 52, 882},
- {(float)0.153815, 55, 934}, {(float)0.153815, 55, 989},
- {(float)0.149097, 58, 1044}, {(float)0.149097, 58, 1102},
- {(float)0.142746, 62, 1160}, {(float)0.142746, 62, 1222},
- {(float)0.142746, 62, 1284}, {(float)0.138270, 65, 1346},
- {(float)0.138270, 65, 1411}, {(float)0.138270, 65, 1476},
- {(float)0.132166, 69, 1541}, {(float)0.132166, 69, 1610},
- {(float)0.126204, 73, 1679}, {(float)0.126204, 73, 1752},
- {(float)0.126204, 73, 1825}, {(float)0.120381, 77, 1898},
- {(float)0.120381, 77, 1975}, {(float)0.120381, 77, 2052},
- {(float)0.120381, 77, 2129}, {(float)0.112962, 82, 2206},
- {(float)0.112962, 82, 2288}, {(float)0.112962, 82, 2370},
- {(float)0.107450, 86, 2452}, {(float)0.107450, 86, 2538},
- {(float)0.107450, 86, 2624}, {(float)0.107450, 86, 2710},
- {(float)0.100343, 91, 2796}, {(float)0.100343, 91, 2887},
- {(float)0.100343, 91, 2978}, {(float)0.095126, 95, 3069},
- {(float)0.095126, 95, 3164}, {(float)0.095126, 95, 3259},
- {(float)0.095126, 95, 3354}, {(float)0.088276, 100, 3449},
- {(float)0.088276, 100, 3549}, {(float)0.088276, 100, 3649},
- {(float)0.088276, 100, 3749}, {(float)0.081523, 105, 3849},
- {(float)0.081523, 105, 3954}, {(float)0.081523, 105, 4059},
- {(float)0.081523, 105, 4164}, {(float)0.074861, 110, 4269},
- {(float)0.074861, 110, 4379}, {(float)0.074861, 110, 4489},
- {(float)0.074861, 110, 4599}, {(float)0.068290, 115, 4709},
- {(float)0.068290, 115, 4824}, {(float)0.068290, 115, 4939},
- {(float)0.068290, 115, 5054}, {(float)0.063573, 119, 5169},
- {(float)0.063573, 119, 5288}, {(float)0.063573, 119, 5407},
- {(float)0.063573, 119, 5526}, {(float)0.057219, 124, 5645},
- {(float)0.057219, 124, 5769}, {(float)0.057219, 124, 5893},
- {(float)0.057219, 124, 6017}, {(float)0.050985, 129, 6141},
- {(float)0.050985, 129, 6270}, {(float)0.050985, 129, 6399},
- {(float)0.050985, 129, 6528}, {(float)0.050985, 129, 6657},
- {(float)0.044859, 134, 6786}, {(float)0.044859, 134, 6920},
- {(float)0.044859, 134, 7054}, {(float)0.044859, 134, 7188},
- {(float)0.040571, 138, 7322}, {(float)0.040571, 138, 7460},
- {(float)0.040571, 138, 7598}, {(float)0.040571, 138, 7736},
- {(float)0.036339, 142, 7874}, {(float)0.036339, 142, 8016},
- {(float)0.036339, 142, 8158}, {(float)0.036339, 142, 8300},
- {(float)0.032139, 146, 8442}, {(float)0.032139, 146, 8588},
- {(float)0.032139, 146, 8734}, {(float)0.032139, 146, 8880},
- {(float)0.027947, 150, 9026}, {(float)0.027947, 150, 9176},
- {(float)0.027947, 150, 9326}, {(float)0.023739, 154, 9476},
- {(float)0.023739, 154, 9630}, {(float)0.023739, 154, 9784},
- {(float)0.023739, 154, 9938}, {(float)0.019504, 158, 10092},
- {(float)0.019504, 158, 10250}, {(float)0.019504, 158, 10408},
- {(float)0.016976, 161, 10566}, {(float)0.016976, 161, 10727},
- {(float)0.016976, 161, 10888}, {(float)0.016976, 161, 11049},
- {(float)0.012639, 165, 11210}, {(float)0.012639, 165, 11375},
- {(float)0.012639, 165, 11540}, {(float)0.009991, 168, 11705},
- {(float)0.009991, 168, 11873}, {(float)0.009991, 168, 12041},
- {(float)0.009016, 170, 12209}, {(float)0.009016, 170, 12379},
- {(float)0.009016, 170, 12549}, {(float)0.006217, 173, 12719},
- {(float)0.006217, 173, 12892}, {(float)0.005097, 175, 13065},
- {(float)0.005097, 175, 13240}, {(float)0.005097, 175, 13415},
- {(float)0.003909, 177, 13590}, {(float)0.003909, 177, 13767},
- {(float)0.002340, 177, 13944}, {(float)0.002389, 170, 14121},
- {(float)0.001068, 164, 14291}, {(float)0.001653, 157, 14455},
- {(float)0.000717, 150, 14612}, {(float)0.001614, 143, 14762},
- {(float)0.000270, 136, 14905}, {(float)0.000484, 129, 15041},
- {(float)0.001103, 123, 15170}, {(float)0.001242, 115, 15293},
- {(float)0.001188, 109, 15408}, {(float)0.001011, 103, 15517},
- {(float)0.000709, 97, 15620}, {(float)0.000301, 89, 15717},
- {(float)0.002416, 82, 15806}, {(float)0.003251, 76, 15888},
- {(float)0.003246, 69, 15964}, {(float)0.004141, 62, 16033},
- {(float)0.005963, 55, 16095}, {(float)0.008839, 47, 16150},
- {(float)0.010490, 40, 16197}, {(float)0.016994, 31, 16237},
- {(float)0.023659, 21, 16268},
-};
diff --git a/contrib/libs/libtiff/ya.make b/contrib/libs/libtiff/ya.make
deleted file mode 100644
index ef90f0d937..0000000000
--- a/contrib/libs/libtiff/ya.make
+++ /dev/null
@@ -1,98 +0,0 @@
-# Generated by devtools/yamaker from nixpkgs 22.11.
-
-LIBRARY()
-
-LICENSE(
- BSD-3-Clause AND
- BSLA AND
- MIT AND
- libtiff
-)
-
-LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
-
-VERSION(4.7.0)
-
-ORIGINAL_SOURCE(https://gitlab.com/api/v4/projects/libtiff%2Flibtiff/repository/archive.tar.gz?sha=v4.7.0)
-
-PEERDIR(
- contrib/libs/libjpeg-turbo
- contrib/libs/libwebp
- contrib/libs/lzma
- contrib/libs/zlib
- contrib/libs/zstd
-)
-
-ADDINCL(
- GLOBAL contrib/libs/libtiff
- contrib/libs/libjpeg-turbo
- contrib/libs/libwebp
- contrib/libs/zstd/include
-)
-
-NO_COMPILER_WARNINGS()
-
-NO_UTIL()
-
-CFLAGS(
- -DALLOW_TIFF_NON_EXT_ALLOC_FUNCTIONS
- -DTIFF_DO_NOT_USE_NON_EXT_ALLOC_FUNCTIONS
-)
-
-SRCS(
- tif_aux.c
- tif_close.c
- tif_codec.c
- tif_color.c
- tif_compress.c
- tif_dir.c
- tif_dirinfo.c
- tif_dirread.c
- tif_dirwrite.c
- tif_dumpmode.c
- tif_error.c
- tif_extension.c
- tif_fax3.c
- tif_fax3sm.c
- tif_flush.c
- tif_getimage.c
- tif_hash_set.c
- tif_jbig.c
- tif_jpeg.c
- tif_jpeg_12.c
- tif_lerc.c
- tif_luv.c
- tif_lzma.c
- tif_lzw.c
- tif_next.c
- tif_ojpeg.c
- tif_open.c
- tif_packbits.c
- tif_pixarlog.c
- tif_predict.c
- tif_print.c
- tif_read.c
- tif_stream.cxx
- tif_strip.c
- tif_swab.c
- tif_thunder.c
- tif_tile.c
- tif_version.c
- tif_warning.c
- tif_webp.c
- tif_write.c
- tif_zip.c
- tif_zstd.c
-)
-
-IF (OS_WINDOWS)
- SRCS(
- tif_win32.c
- )
-ELSE()
- SRCS(
- tif_unix.c
- )
-ENDIF()
-
-END()
diff --git a/contrib/libs/libwebp/.yandex_meta/__init__.py b/contrib/libs/libwebp/.yandex_meta/__init__.py
deleted file mode 100644
index 8a6d0fd03f..0000000000
--- a/contrib/libs/libwebp/.yandex_meta/__init__.py
+++ /dev/null
@@ -1,44 +0,0 @@
-import os
-import os.path as P
-
-from devtools.yamaker.fileutil import re_sub_dir
-from devtools.yamaker.modules import Linkable, Switch
-from devtools.yamaker.project import GNUMakeNixProject
-
-
-def libwebp_post_install(self):
- # Update includes to supported stripped src.
- re_sub_dir(self.dstdir, '#include "src/', '#include "../')
- # Match current style of relative includes.
- for d in os.listdir(self.dstdir):
- absd = P.join(self.dstdir, d)
- if P.isdir(absd):
- re_sub_dir(absd, '#include "../' + d + "/", '#include "./')
- # Deduplicate SRCS.
- for s in "dsp/webpdsp", "utils/webputils":
- with self.yamakes[s] as m:
- m.PEERDIR.add(self.arcdir + "/" + s + "decode")
- m.SRCS -= self.yamakes[s + "decode"].SRCS
- # Support NEON on 32-bit Androids.
- self.yamakes["dsp/webpdspdecode"].after(
- "PEERDIR",
- Switch(
- OS_ANDROID=Linkable(
- PEERDIR=["contrib/libs/android_cpufeatures"],
- ADDINCL=["contrib/libs/android_cpufeatures"],
- )
- ),
- )
-
-
-libwebp = GNUMakeNixProject(
- arcdir="contrib/libs/libwebp",
- nixattr="libwebp",
- license="BSD-3-Clause",
- makeflags=["-C", "src"],
- install_subdir="src",
- copy_sources=["dsp/mips_macro.h", "dsp/msa_macro.h", "dsp/neon.h"],
- platform_dispatchers=["webp/config.h"],
- put={"webp": "."},
- post_install=libwebp_post_install,
-)
diff --git a/contrib/libs/libwebp/.yandex_meta/devtools.copyrights.report b/contrib/libs/libwebp/.yandex_meta/devtools.copyrights.report
deleted file mode 100644
index 377e5d7f72..0000000000
--- a/contrib/libs/libwebp/.yandex_meta/devtools.copyrights.report
+++ /dev/null
@@ -1,311 +0,0 @@
-# File format ($ symbol means the beginning of a line):
-#
-# $ # this message
-# $ # =======================
-# $ # comments (all commentaries should starts with some number of spaces and # symbol)
-# ${action} {license id} {license text hash}
-# $BELONGS ./ya/make/file/relative/path/1/ya.make ./ya/make/2/ya.make
-# ${all_file_action} filename
-# $ # user commentaries (many lines)
-# $ generated description - files with this license, license text... (some number of lines that starts with some number of spaces, do not modify)
-# ${action} {license spdx} {license text hash}
-# $BELONGS ./ya/make/file/relative/path/3/ya.make
-# ${all_file_action} filename
-# $ # user commentaries
-# $ generated description
-# $ ...
-#
-# You can modify action, all_file_action and add commentaries
-# Available actions:
-# keep - keep license in contrib and use in credits
-# skip - skip license
-# remove - remove all files with this license
-# rename - save license text/links into licenses texts file, but not store SPDX into LINCENSE macro. You should store correct license id into devtools.license.spdx.txt file
-#
-# {all file action} records will be generated when license text contains filename that exists on filesystem (in contrib directory)
-# We suppose that that files can contain some license info
-# Available all file actions:
-# FILE_IGNORE - ignore file (do nothing)
-# FILE_INCLUDE - include all file data into licenses text file
-# =======================
-
-KEEP COPYRIGHT_SERVICE_LABEL 05bdd09fb9fdb384a61f2eb54df462d6
-BELONGS enc/ya.make mux/ya.make ya.make
- License text:
- // Copyright 2016 Google Inc. All Rights Reserved.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- dsp/common_sse2.h [1:1]
- dsp/common_sse41.h [1:1]
- dsp/dec_msa.c [1:1]
- dsp/enc_msa.c [1:1]
- dsp/filters_msa.c [1:1]
- dsp/lossless_enc_msa.c [1:1]
- dsp/lossless_msa.c [1:1]
- dsp/msa_macro.h [1:1]
- dsp/rescaler_msa.c [1:1]
- dsp/upsampling_msa.c [1:1]
- enc/predictor_enc.c [1:1]
- mux/animi.h [1:1]
-
-KEEP COPYRIGHT_SERVICE_LABEL 20b71da944b9e6967071fc4782c1355f
-BELONGS ya.make
- License text:
- Copyright (c) 2010, Google Inc. All rights reserved.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- COPYING [1:1]
-
-KEEP COPYRIGHT_SERVICE_LABEL 6499e2ad737f62db5558c81fbd2749a7
-BELONGS enc/ya.make ya.make
- License text:
- // Copyright 2017 Google Inc. All Rights Reserved.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- dsp/alpha_processing_neon.c [1:1]
- dsp/filters_neon.c [1:1]
- dsp/ssim.c [1:1]
- dsp/ssim_sse2.c [1:1]
- dsp/yuv_neon.c [1:1]
- enc/backward_references_cost_enc.c [1:1]
-
-KEEP COPYRIGHT_SERVICE_LABEL 6518b015a67ef080ce14d2b770875d6a
-BELONGS enc/ya.make mux/ya.make ya.make
- License text:
- // Copyright 2014 Google Inc. All Rights Reserved.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- dsp/alpha_processing_mips_dsp_r2.c [1:1]
- dsp/alpha_processing_sse2.c [1:1]
- dsp/cost.c [1:1]
- dsp/cost_mips32.c [1:1]
- dsp/cost_mips_dsp_r2.c [1:1]
- dsp/dec_clip_tables.c [1:1]
- dsp/dec_mips32.c [1:1]
- dsp/dec_mips_dsp_r2.c [1:1]
- dsp/enc_mips32.c [1:1]
- dsp/enc_mips_dsp_r2.c [1:1]
- dsp/filters_mips_dsp_r2.c [1:1]
- dsp/lossless_mips_dsp_r2.c [1:1]
- dsp/lossless_neon.c [1:1]
- dsp/lossless_sse2.c [1:1]
- dsp/mips_macro.h [1:1]
- dsp/neon.h [1:1]
- dsp/rescaler.c [1:1]
- dsp/rescaler_mips32.c [1:1]
- dsp/rescaler_mips_dsp_r2.c [1:1]
- dsp/upsampling_mips_dsp_r2.c [1:1]
- dsp/yuv_mips32.c [1:1]
- dsp/yuv_mips_dsp_r2.c [1:1]
- dsp/yuv_sse2.c [1:1]
- dsp/yuv_sse41.c [1:1]
- enc/near_lossless_enc.c [1:1]
- enc/picture_csp_enc.c [1:1]
- enc/picture_psnr_enc.c [1:1]
- enc/picture_rescale_enc.c [1:1]
- enc/picture_tools_enc.c [1:1]
- mux/anim_encode.c [1:1]
- utils/bit_reader_inl_utils.h [1:1]
- utils/endian_inl_utils.h [1:1]
-
-KEEP COPYRIGHT_SERVICE_LABEL 7e1724b8402b7946ad8f2c8a92df19c3
-BELONGS dec/ya.make enc/ya.make mux/ya.make ya.make
- License text:
- // Copyright 2011 Google Inc. All Rights Reserved.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- dec/alpha_dec.c [1:1]
- dec/buffer_dec.c [1:1]
- dec/idec_dec.c [1:1]
- dec/io_dec.c [1:1]
- dec/webpi_dec.h [1:1]
- dsp/cpu.c [1:1]
- dsp/dec_sse2.c [1:1]
- dsp/dsp.h [1:1]
- dsp/enc.c [1:1]
- dsp/enc_sse2.c [1:1]
- dsp/filters.c [1:1]
- dsp/upsampling.c [1:1]
- dsp/upsampling_neon.c [1:1]
- dsp/upsampling_sse2.c [1:1]
- dsp/upsampling_sse41.c [1:1]
- enc/alpha_enc.c [1:1]
- enc/analysis_enc.c [1:1]
- enc/config_enc.c [1:1]
- enc/cost_enc.c [1:1]
- enc/cost_enc.h [1:1]
- enc/filter_enc.c [1:1]
- enc/frame_enc.c [1:1]
- enc/iterator_enc.c [1:1]
- enc/picture_enc.c [1:1]
- enc/quant_enc.c [1:1]
- enc/syntax_enc.c [1:1]
- enc/token_enc.c [1:1]
- enc/tree_enc.c [1:1]
- enc/vp8i_enc.h [1:1]
- enc/webp_enc.c [1:1]
- mux/muxedit.c [1:1]
- mux/muxi.h [1:1]
- mux/muxinternal.c [1:1]
- mux/muxread.c [1:1]
- utils/bit_writer_utils.c [1:1]
- utils/bit_writer_utils.h [1:1]
- utils/filters_utils.c [1:1]
- utils/filters_utils.h [1:1]
- utils/huffman_encode_utils.c [1:1]
- utils/huffman_encode_utils.h [1:1]
- utils/quant_levels_utils.c [1:1]
- utils/quant_levels_utils.h [1:1]
- utils/thread_utils.c [1:1]
- utils/thread_utils.h [1:1]
- webp/encode.h [1:1]
- webp/mux.h [1:1]
-
-KEEP COPYRIGHT_SERVICE_LABEL 904be6eceb61d466f53f25892be2624f
-BELONGS ya.make
- License text:
- // Copyright 2021 Google Inc. All Rights Reserved.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- dsp/lossless_sse41.c [1:1]
-
-KEEP COPYRIGHT_SERVICE_LABEL 9142ab2af90f5831171712f8d87bc7e3
-BELONGS ya.make
- License text:
- \# Copyright (c) 2021, Google Inc. All rights reserved.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- PRESUBMIT.py [1:1]
-
-KEEP COPYRIGHT_SERVICE_LABEL 97ff8757487be6d08b12d53768dd6984
-BELONGS dec/ya.make demux/ya.make enc/ya.make ya.make
- License text:
- // Copyright 2012 Google Inc. All Rights Reserved.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- dec/vp8l_dec.c [1:1]
- dec/vp8li_dec.h [1:1]
- demux/demux.c [1:1]
- dsp/dec_neon.c [1:1]
- dsp/enc_neon.c [1:1]
- dsp/lossless.c [1:1]
- dsp/lossless.h [1:1]
- dsp/lossless_common.h [1:1]
- enc/backward_references_enc.c [1:1]
- enc/backward_references_enc.h [1:1]
- enc/histogram_enc.c [1:1]
- enc/histogram_enc.h [1:1]
- enc/vp8l_enc.c [1:1]
- enc/vp8li_enc.h [1:1]
- utils/color_cache_utils.c [1:1]
- utils/color_cache_utils.h [1:1]
- utils/huffman_utils.c [1:1]
- utils/huffman_utils.h [1:1]
- utils/rescaler_utils.c [1:1]
- utils/rescaler_utils.h [1:1]
- utils/utils.c [1:1]
- utils/utils.h [1:1]
- webp/demux.h [1:1]
- webp/format_constants.h [1:1]
- webp/mux_types.h [1:1]
-
-KEEP COPYRIGHT_SERVICE_LABEL da7391eda27a4968d920cc73a32c9b20
-BELONGS dec/ya.make ya.make
- License text:
- // Copyright 2013 Google Inc. All Rights Reserved.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- dec/alphai_dec.h [1:1]
- dsp/alpha_processing.c [1:1]
- utils/quant_levels_dec_utils.c [1:1]
- utils/quant_levels_dec_utils.h [1:1]
- utils/random_utils.c [1:1]
- utils/random_utils.h [1:1]
-
-KEEP COPYRIGHT_SERVICE_LABEL ef839a7f29c4727d9902b9efada72a47
-BELONGS dec/ya.make ya.make
- License text:
- // Copyright 2010 Google Inc. All Rights Reserved.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- dec/frame_dec.c [1:1]
- dec/quant_dec.c [1:1]
- dec/tree_dec.c [1:1]
- dec/vp8_dec.c [1:1]
- dec/vp8_dec.h [1:1]
- dec/vp8i_dec.h [1:1]
- dec/webp_dec.c [1:1]
- dsp/dec.c [1:1]
- dsp/yuv.c [1:1]
- dsp/yuv.h [1:1]
- utils/bit_reader_utils.c [1:1]
- utils/bit_reader_utils.h [1:1]
- webp/decode.h [1:1]
- webp/types.h [1:1]
-
-KEEP COPYRIGHT_SERVICE_LABEL f4d2490c76552286e9c484abd3bea2b4
-BELONGS dec/ya.make demux/ya.make ya.make
- License text:
- // Copyright 2015 Google Inc. All Rights Reserved.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- dec/common_dec.h [1:1]
- demux/anim_decode.c [1:1]
- dsp/alpha_processing_sse41.c [1:1]
- dsp/cost_sse2.c [1:1]
- dsp/dec_sse41.c [1:1]
- dsp/enc_sse41.c [1:1]
- dsp/filters_sse2.c [1:1]
- dsp/lossless_enc.c [1:1]
- dsp/lossless_enc_mips32.c [1:1]
- dsp/lossless_enc_mips_dsp_r2.c [1:1]
- dsp/lossless_enc_neon.c [1:1]
- dsp/lossless_enc_sse2.c [1:1]
- dsp/lossless_enc_sse41.c [1:1]
- dsp/rescaler_neon.c [1:1]
- dsp/rescaler_sse2.c [1:1]
-
-KEEP COPYRIGHT_SERVICE_LABEL f94740292e5295c1a1432ff96e55c207
-BELONGS ya.make
- License text:
- // Copyright 2018 Google Inc. All Rights Reserved.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- dsp/cost_neon.c [1:1]
- dsp/quant.h [1:1]
diff --git a/contrib/libs/libwebp/.yandex_meta/devtools.licenses.report b/contrib/libs/libwebp/.yandex_meta/devtools.licenses.report
deleted file mode 100644
index adfac37888..0000000000
--- a/contrib/libs/libwebp/.yandex_meta/devtools.licenses.report
+++ /dev/null
@@ -1,427 +0,0 @@
-# File format ($ symbol means the beginning of a line):
-#
-# $ # this message
-# $ # =======================
-# $ # comments (all commentaries should starts with some number of spaces and # symbol)
-# ${action} {license spdx} {license text hash}
-# $BELONGS ./ya/make/file/relative/path/1/ya.make ./ya/make/2/ya.make
-# ${all_file_action} filename
-# $ # user commentaries (many lines)
-# $ generated description - files with this license, license text... (some number of lines that starts with some number of spaces, do not modify)
-# ${action} {license spdx} {license text hash}
-# $BELONGS ./ya/make/file/relative/path/3/ya.make
-# ${all_file_action} filename
-# $ # user commentaries
-# $ generated description
-# $ ...
-#
-# You can modify action, all_file_action and add commentaries
-# Available actions:
-# keep - keep license in contrib and use in credits
-# skip - skip license
-# remove - remove all files with this license
-# rename - save license text/links into licenses texts file, but not store SPDX into LINCENSE macro. You should store correct license id into devtools.license.spdx.txt file
-#
-# {all file action} records will be generated when license text contains filename that exists on filesystem (in contrib directory)
-# We suppose that that files can contain some license info
-# Available all file actions:
-# FILE_IGNORE - ignore file (do nothing)
-# FILE_INCLUDE - include all file data into licenses text file
-# =======================
-
-KEEP BSD-3-Clause WITH Google-Patent-License-Webm 3205496eac10f5e0953af633e99c42ad
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: LicenseRef-scancode-google-patent-license-webm
- Score : 100.00
- Match type : TEXT
- Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/google-patent-license-webm.LICENSE, https://www.webmproject.org/license/additional/
- Files with this license:
- PATENTS [1:23]
-
-KEEP BSD-3-Clause WITH Google-Patent-License-Webm 4659c9f7ff31f6efef096c70c7436641
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: BSD-3-Clause
- Score : 100.00
- Match type : TEXT
- Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
- Files with this license:
- PRESUBMIT.py [3:29]
-
-SKIP LicenseRef-scancode-generic-cla 5d780ffa423067f23c6a123ae33e7c18
-BELONGS ya.make
- # Not a license
- License text:
- \## Contributor License Agreement
- Scancode info:
- Original SPDX id: LicenseRef-scancode-generic-cla
- Score : 16.00
- Match type : NOTICE
- Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/generic-cla.LICENSE
- Files with this license:
- CONTRIBUTING.md [6:6]
-
-SKIP LicenseRef-scancode-generic-cla 979d7de2e3ff119ee2c22c7efbec766d
-BELONGS ya.make
- # Not a license
- License text:
- Contributions to this project must be accompanied by a Contributor License
- Agreement. You (or your employer) retain the copyright to your contribution;
- Scancode info:
- Original SPDX id: LicenseRef-scancode-generic-cla
- Score : 16.00
- Match type : NOTICE
- Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/generic-cla.LICENSE
- Files with this license:
- CONTRIBUTING.md [8:9]
-
-KEEP BSD-3-Clause WITH Google-Patent-License-Webm 997fb0147f973c443456b21b75e17217
-BELONGS dec/ya.make demux/ya.make enc/ya.make mux/ya.make ya.make
-FILE_INCLUDE AUTHORS found in files: dec/alpha_dec.c at line 7, dec/alphai_dec.h at line 7, dec/buffer_dec.c at line 7, dec/common_dec.h at line 7, dec/frame_dec.c at line 7, dec/idec_dec.c at line 7, dec/io_dec.c at line 7, dec/quant_dec.c at line 7, dec/tree_dec.c at line 7, dec/vp8_dec.c at line 7, dec/vp8_dec.h at line 7, dec/vp8i_dec.h at line 7, dec/vp8l_dec.c at line 7, dec/vp8li_dec.h at line 7, dec/webp_dec.c at line 7, dec/webpi_dec.h at line 7, demux/anim_decode.c at line 7, demux/demux.c at line 7, dsp/alpha_processing.c at line 7, dsp/alpha_processing_mips_dsp_r2.c at line 7, dsp/alpha_processing_neon.c at line 7, dsp/alpha_processing_sse2.c at line 7, dsp/alpha_processing_sse41.c at line 7, dsp/common_sse2.h at line 7, dsp/common_sse41.h at line 7, dsp/cost.c at line 7, dsp/cost_mips32.c at line 7, dsp/cost_mips_dsp_r2.c at line 7, dsp/cost_neon.c at line 7, dsp/cost_sse2.c at line 7, dsp/cpu.c at line 7, dsp/dec.c at line 7, dsp/dec_clip_tables.c at line 7, dsp/dec_mips32.c at line 7, dsp/dec_mips_dsp_r2.c at line 7, dsp/dec_msa.c at line 7, dsp/dec_neon.c at line 7, dsp/dec_sse2.c at line 7, dsp/dec_sse41.c at line 7, dsp/dsp.h at line 7, dsp/enc.c at line 7, dsp/enc_mips32.c at line 7, dsp/enc_mips_dsp_r2.c at line 7, dsp/enc_msa.c at line 7, dsp/enc_neon.c at line 7, dsp/enc_sse2.c at line 7, dsp/enc_sse41.c at line 7, dsp/filters.c at line 7, dsp/filters_mips_dsp_r2.c at line 7, dsp/filters_msa.c at line 7, dsp/filters_neon.c at line 7, dsp/filters_sse2.c at line 7, dsp/lossless.c at line 7, dsp/lossless.h at line 7, dsp/lossless_common.h at line 7, dsp/lossless_enc.c at line 7, dsp/lossless_enc_mips32.c at line 7, dsp/lossless_enc_mips_dsp_r2.c at line 7, dsp/lossless_enc_msa.c at line 7, dsp/lossless_enc_neon.c at line 7, dsp/lossless_enc_sse2.c at line 7, dsp/lossless_enc_sse41.c at line 7, dsp/lossless_mips_dsp_r2.c at line 7, dsp/lossless_msa.c at line 7, dsp/lossless_neon.c at line 7, dsp/lossless_sse2.c at line 7, dsp/lossless_sse41.c at line 7, dsp/mips_macro.h at line 7, dsp/msa_macro.h at line 7, dsp/neon.h at line 7, dsp/quant.h at line 7, dsp/rescaler.c at line 7, dsp/rescaler_mips32.c at line 7, dsp/rescaler_mips_dsp_r2.c at line 7, dsp/rescaler_msa.c at line 7, dsp/rescaler_neon.c at line 7, dsp/rescaler_sse2.c at line 7, dsp/ssim.c at line 7, dsp/ssim_sse2.c at line 7, dsp/upsampling.c at line 7, dsp/upsampling_mips_dsp_r2.c at line 7, dsp/upsampling_msa.c at line 7, dsp/upsampling_neon.c at line 7, dsp/upsampling_sse2.c at line 7, dsp/upsampling_sse41.c at line 7, dsp/yuv.c at line 7, dsp/yuv.h at line 7, dsp/yuv_mips32.c at line 7, dsp/yuv_mips_dsp_r2.c at line 7, dsp/yuv_neon.c at line 7, dsp/yuv_sse2.c at line 7, dsp/yuv_sse41.c at line 7, enc/alpha_enc.c at line 7, enc/analysis_enc.c at line 7, enc/backward_references_cost_enc.c at line 7, enc/backward_references_enc.c at line 7, enc/backward_references_enc.h at line 7, enc/config_enc.c at line 7, enc/cost_enc.c at line 7, enc/cost_enc.h at line 7, enc/filter_enc.c at line 7, enc/frame_enc.c at line 7, enc/histogram_enc.c at line 7, enc/histogram_enc.h at line 7, enc/iterator_enc.c at line 7, enc/near_lossless_enc.c at line 7, enc/picture_csp_enc.c at line 7, enc/picture_enc.c at line 7, enc/picture_psnr_enc.c at line 7, enc/picture_rescale_enc.c at line 7, enc/picture_tools_enc.c at line 7, enc/predictor_enc.c at line 7, enc/quant_enc.c at line 7, enc/syntax_enc.c at line 7, enc/token_enc.c at line 7, enc/tree_enc.c at line 7, enc/vp8i_enc.h at line 7, enc/vp8l_enc.c at line 7, enc/vp8li_enc.h at line 7, enc/webp_enc.c at line 7, mux/anim_encode.c at line 7, mux/animi.h at line 7, mux/muxedit.c at line 7, mux/muxi.h at line 7, mux/muxinternal.c at line 7, mux/muxread.c at line 7, utils/bit_reader_inl_utils.h at line 7, utils/bit_reader_utils.c at line 7, utils/bit_reader_utils.h at line 7, utils/bit_writer_utils.c at line 7, utils/bit_writer_utils.h at line 7, utils/color_cache_utils.c at line 7, utils/color_cache_utils.h at line 7, utils/endian_inl_utils.h at line 7, utils/filters_utils.c at line 7, utils/filters_utils.h at line 7, utils/huffman_encode_utils.c at line 7, utils/huffman_encode_utils.h at line 7, utils/huffman_utils.c at line 7, utils/huffman_utils.h at line 7, utils/quant_levels_dec_utils.c at line 7, utils/quant_levels_dec_utils.h at line 7, utils/quant_levels_utils.c at line 7, utils/quant_levels_utils.h at line 7, utils/random_utils.c at line 7, utils/random_utils.h at line 7, utils/rescaler_utils.c at line 7, utils/rescaler_utils.h at line 7, utils/thread_utils.c at line 7, utils/thread_utils.h at line 7, utils/utils.c at line 7, utils/utils.h at line 7, webp/decode.h at line 7, webp/demux.h at line 7, webp/encode.h at line 7, webp/format_constants.h at line 7, webp/mux.h at line 7, webp/mux_types.h at line 7, webp/types.h at line 7
-FILE_INCLUDE COPYING found in files: dec/alpha_dec.c at line 4, dec/alphai_dec.h at line 4, dec/buffer_dec.c at line 4, dec/common_dec.h at line 4, dec/frame_dec.c at line 4, dec/idec_dec.c at line 4, dec/io_dec.c at line 4, dec/quant_dec.c at line 4, dec/tree_dec.c at line 4, dec/vp8_dec.c at line 4, dec/vp8_dec.h at line 4, dec/vp8i_dec.h at line 4, dec/vp8l_dec.c at line 4, dec/vp8li_dec.h at line 4, dec/webp_dec.c at line 4, dec/webpi_dec.h at line 4, demux/anim_decode.c at line 4, demux/demux.c at line 4, dsp/alpha_processing.c at line 4, dsp/alpha_processing_mips_dsp_r2.c at line 4, dsp/alpha_processing_neon.c at line 4, dsp/alpha_processing_sse2.c at line 4, dsp/alpha_processing_sse41.c at line 4, dsp/common_sse2.h at line 4, dsp/common_sse41.h at line 4, dsp/cost.c at line 4, dsp/cost_mips32.c at line 4, dsp/cost_mips_dsp_r2.c at line 4, dsp/cost_neon.c at line 4, dsp/cost_sse2.c at line 4, dsp/cpu.c at line 4, dsp/dec.c at line 4, dsp/dec_clip_tables.c at line 4, dsp/dec_mips32.c at line 4, dsp/dec_mips_dsp_r2.c at line 4, dsp/dec_msa.c at line 4, dsp/dec_neon.c at line 4, dsp/dec_sse2.c at line 4, dsp/dec_sse41.c at line 4, dsp/dsp.h at line 4, dsp/enc.c at line 4, dsp/enc_mips32.c at line 4, dsp/enc_mips_dsp_r2.c at line 4, dsp/enc_msa.c at line 4, dsp/enc_neon.c at line 4, dsp/enc_sse2.c at line 4, dsp/enc_sse41.c at line 4, dsp/filters.c at line 4, dsp/filters_mips_dsp_r2.c at line 4, dsp/filters_msa.c at line 4, dsp/filters_neon.c at line 4, dsp/filters_sse2.c at line 4, dsp/lossless.c at line 4, dsp/lossless.h at line 4, dsp/lossless_common.h at line 4, dsp/lossless_enc.c at line 4, dsp/lossless_enc_mips32.c at line 4, dsp/lossless_enc_mips_dsp_r2.c at line 4, dsp/lossless_enc_msa.c at line 4, dsp/lossless_enc_neon.c at line 4, dsp/lossless_enc_sse2.c at line 4, dsp/lossless_enc_sse41.c at line 4, dsp/lossless_mips_dsp_r2.c at line 4, dsp/lossless_msa.c at line 4, dsp/lossless_neon.c at line 4, dsp/lossless_sse2.c at line 4, dsp/lossless_sse41.c at line 4, dsp/mips_macro.h at line 4, dsp/msa_macro.h at line 4, dsp/neon.h at line 4, dsp/quant.h at line 4, dsp/rescaler.c at line 4, dsp/rescaler_mips32.c at line 4, dsp/rescaler_mips_dsp_r2.c at line 4, dsp/rescaler_msa.c at line 4, dsp/rescaler_neon.c at line 4, dsp/rescaler_sse2.c at line 4, dsp/ssim.c at line 4, dsp/ssim_sse2.c at line 4, dsp/upsampling.c at line 4, dsp/upsampling_mips_dsp_r2.c at line 4, dsp/upsampling_msa.c at line 4, dsp/upsampling_neon.c at line 4, dsp/upsampling_sse2.c at line 4, dsp/upsampling_sse41.c at line 4, dsp/yuv.c at line 4, dsp/yuv.h at line 4, dsp/yuv_mips32.c at line 4, dsp/yuv_mips_dsp_r2.c at line 4, dsp/yuv_neon.c at line 4, dsp/yuv_sse2.c at line 4, dsp/yuv_sse41.c at line 4, enc/alpha_enc.c at line 4, enc/analysis_enc.c at line 4, enc/backward_references_cost_enc.c at line 4, enc/backward_references_enc.c at line 4, enc/backward_references_enc.h at line 4, enc/config_enc.c at line 4, enc/cost_enc.c at line 4, enc/cost_enc.h at line 4, enc/filter_enc.c at line 4, enc/frame_enc.c at line 4, enc/histogram_enc.c at line 4, enc/histogram_enc.h at line 4, enc/iterator_enc.c at line 4, enc/near_lossless_enc.c at line 4, enc/picture_csp_enc.c at line 4, enc/picture_enc.c at line 4, enc/picture_psnr_enc.c at line 4, enc/picture_rescale_enc.c at line 4, enc/picture_tools_enc.c at line 4, enc/predictor_enc.c at line 4, enc/quant_enc.c at line 4, enc/syntax_enc.c at line 4, enc/token_enc.c at line 4, enc/tree_enc.c at line 4, enc/vp8i_enc.h at line 4, enc/vp8l_enc.c at line 4, enc/vp8li_enc.h at line 4, enc/webp_enc.c at line 4, mux/anim_encode.c at line 4, mux/animi.h at line 4, mux/muxedit.c at line 4, mux/muxi.h at line 4, mux/muxinternal.c at line 4, mux/muxread.c at line 4, utils/bit_reader_inl_utils.h at line 4, utils/bit_reader_utils.c at line 4, utils/bit_reader_utils.h at line 4, utils/bit_writer_utils.c at line 4, utils/bit_writer_utils.h at line 4, utils/color_cache_utils.c at line 4, utils/color_cache_utils.h at line 4, utils/endian_inl_utils.h at line 4, utils/filters_utils.c at line 4, utils/filters_utils.h at line 4, utils/huffman_encode_utils.c at line 4, utils/huffman_encode_utils.h at line 4, utils/huffman_utils.c at line 4, utils/huffman_utils.h at line 4, utils/quant_levels_dec_utils.c at line 4, utils/quant_levels_dec_utils.h at line 4, utils/quant_levels_utils.c at line 4, utils/quant_levels_utils.h at line 4, utils/random_utils.c at line 4, utils/random_utils.h at line 4, utils/rescaler_utils.c at line 4, utils/rescaler_utils.h at line 4, utils/thread_utils.c at line 4, utils/thread_utils.h at line 4, utils/utils.c at line 4, utils/utils.h at line 4, webp/decode.h at line 4, webp/demux.h at line 4, webp/encode.h at line 4, webp/format_constants.h at line 4, webp/mux.h at line 4, webp/mux_types.h at line 4, webp/types.h at line 4
-FILE_INCLUDE PATENTS found in files: dec/alpha_dec.c at line 6, dec/alphai_dec.h at line 6, dec/buffer_dec.c at line 6, dec/common_dec.h at line 6, dec/frame_dec.c at line 6, dec/idec_dec.c at line 6, dec/io_dec.c at line 6, dec/quant_dec.c at line 6, dec/tree_dec.c at line 6, dec/vp8_dec.c at line 6, dec/vp8_dec.h at line 6, dec/vp8i_dec.h at line 6, dec/vp8l_dec.c at line 6, dec/vp8li_dec.h at line 6, dec/webp_dec.c at line 6, dec/webpi_dec.h at line 6, demux/anim_decode.c at line 6, demux/demux.c at line 6, dsp/alpha_processing.c at line 6, dsp/alpha_processing_mips_dsp_r2.c at line 6, dsp/alpha_processing_neon.c at line 6, dsp/alpha_processing_sse2.c at line 6, dsp/alpha_processing_sse41.c at line 6, dsp/common_sse2.h at line 6, dsp/common_sse41.h at line 6, dsp/cost.c at line 6, dsp/cost_mips32.c at line 6, dsp/cost_mips_dsp_r2.c at line 6, dsp/cost_neon.c at line 6, dsp/cost_sse2.c at line 6, dsp/cpu.c at line 6, dsp/dec.c at line 6, dsp/dec_clip_tables.c at line 6, dsp/dec_mips32.c at line 6, dsp/dec_mips_dsp_r2.c at line 6, dsp/dec_msa.c at line 6, dsp/dec_neon.c at line 6, dsp/dec_sse2.c at line 6, dsp/dec_sse41.c at line 6, dsp/dsp.h at line 6, dsp/enc.c at line 6, dsp/enc_mips32.c at line 6, dsp/enc_mips_dsp_r2.c at line 6, dsp/enc_msa.c at line 6, dsp/enc_neon.c at line 6, dsp/enc_sse2.c at line 6, dsp/enc_sse41.c at line 6, dsp/filters.c at line 6, dsp/filters_mips_dsp_r2.c at line 6, dsp/filters_msa.c at line 6, dsp/filters_neon.c at line 6, dsp/filters_sse2.c at line 6, dsp/lossless.c at line 6, dsp/lossless.h at line 6, dsp/lossless_common.h at line 6, dsp/lossless_enc.c at line 6, dsp/lossless_enc_mips32.c at line 6, dsp/lossless_enc_mips_dsp_r2.c at line 6, dsp/lossless_enc_msa.c at line 6, dsp/lossless_enc_neon.c at line 6, dsp/lossless_enc_sse2.c at line 6, dsp/lossless_enc_sse41.c at line 6, dsp/lossless_mips_dsp_r2.c at line 6, dsp/lossless_msa.c at line 6, dsp/lossless_neon.c at line 6, dsp/lossless_sse2.c at line 6, dsp/lossless_sse41.c at line 6, dsp/mips_macro.h at line 6, dsp/msa_macro.h at line 6, dsp/neon.h at line 6, dsp/quant.h at line 6, dsp/rescaler.c at line 6, dsp/rescaler_mips32.c at line 6, dsp/rescaler_mips_dsp_r2.c at line 6, dsp/rescaler_msa.c at line 6, dsp/rescaler_neon.c at line 6, dsp/rescaler_sse2.c at line 6, dsp/ssim.c at line 6, dsp/ssim_sse2.c at line 6, dsp/upsampling.c at line 6, dsp/upsampling_mips_dsp_r2.c at line 6, dsp/upsampling_msa.c at line 6, dsp/upsampling_neon.c at line 6, dsp/upsampling_sse2.c at line 6, dsp/upsampling_sse41.c at line 6, dsp/yuv.c at line 6, dsp/yuv.h at line 6, dsp/yuv_mips32.c at line 6, dsp/yuv_mips_dsp_r2.c at line 6, dsp/yuv_neon.c at line 6, dsp/yuv_sse2.c at line 6, dsp/yuv_sse41.c at line 6, enc/alpha_enc.c at line 6, enc/analysis_enc.c at line 6, enc/backward_references_cost_enc.c at line 6, enc/backward_references_enc.c at line 6, enc/backward_references_enc.h at line 6, enc/config_enc.c at line 6, enc/cost_enc.c at line 6, enc/cost_enc.h at line 6, enc/filter_enc.c at line 6, enc/frame_enc.c at line 6, enc/histogram_enc.c at line 6, enc/histogram_enc.h at line 6, enc/iterator_enc.c at line 6, enc/near_lossless_enc.c at line 6, enc/picture_csp_enc.c at line 6, enc/picture_enc.c at line 6, enc/picture_psnr_enc.c at line 6, enc/picture_rescale_enc.c at line 6, enc/picture_tools_enc.c at line 6, enc/predictor_enc.c at line 6, enc/quant_enc.c at line 6, enc/syntax_enc.c at line 6, enc/token_enc.c at line 6, enc/tree_enc.c at line 6, enc/vp8i_enc.h at line 6, enc/vp8l_enc.c at line 6, enc/vp8li_enc.h at line 6, enc/webp_enc.c at line 6, mux/anim_encode.c at line 6, mux/animi.h at line 6, mux/muxedit.c at line 6, mux/muxi.h at line 6, mux/muxinternal.c at line 6, mux/muxread.c at line 6, utils/bit_reader_inl_utils.h at line 6, utils/bit_reader_utils.c at line 6, utils/bit_reader_utils.h at line 6, utils/bit_writer_utils.c at line 6, utils/bit_writer_utils.h at line 6, utils/color_cache_utils.c at line 6, utils/color_cache_utils.h at line 6, utils/endian_inl_utils.h at line 6, utils/filters_utils.c at line 6, utils/filters_utils.h at line 6, utils/huffman_encode_utils.c at line 6, utils/huffman_encode_utils.h at line 6, utils/huffman_utils.c at line 6, utils/huffman_utils.h at line 6, utils/quant_levels_dec_utils.c at line 6, utils/quant_levels_dec_utils.h at line 6, utils/quant_levels_utils.c at line 6, utils/quant_levels_utils.h at line 6, utils/random_utils.c at line 6, utils/random_utils.h at line 6, utils/rescaler_utils.c at line 6, utils/rescaler_utils.h at line 6, utils/thread_utils.c at line 6, utils/thread_utils.h at line 6, utils/utils.c at line 6, utils/utils.h at line 6, webp/decode.h at line 6, webp/demux.h at line 6, webp/encode.h at line 6, webp/format_constants.h at line 6, webp/mux.h at line 6, webp/mux_types.h at line 6, webp/types.h at line 6
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: BSD-3-Clause
- Score : 90.00
- Match type : NOTICE
- Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
- Files with this license:
- dec/alpha_dec.c [3:7]
- dec/alphai_dec.h [3:7]
- dec/buffer_dec.c [3:7]
- dec/common_dec.h [3:7]
- dec/frame_dec.c [3:7]
- dec/idec_dec.c [3:7]
- dec/io_dec.c [3:7]
- dec/quant_dec.c [3:7]
- dec/tree_dec.c [3:7]
- dec/vp8_dec.c [3:7]
- dec/vp8_dec.h [3:7]
- dec/vp8i_dec.h [3:7]
- dec/vp8l_dec.c [3:7]
- dec/vp8li_dec.h [3:7]
- dec/webp_dec.c [3:7]
- dec/webpi_dec.h [3:7]
- demux/anim_decode.c [3:7]
- demux/demux.c [3:7]
- dsp/alpha_processing.c [3:7]
- dsp/alpha_processing_mips_dsp_r2.c [3:7]
- dsp/alpha_processing_neon.c [3:7]
- dsp/alpha_processing_sse2.c [3:7]
- dsp/alpha_processing_sse41.c [3:7]
- dsp/common_sse2.h [3:7]
- dsp/common_sse41.h [3:7]
- dsp/cost.c [3:7]
- dsp/cost_mips32.c [3:7]
- dsp/cost_mips_dsp_r2.c [3:7]
- dsp/cost_neon.c [3:7]
- dsp/cost_sse2.c [3:7]
- dsp/cpu.c [3:7]
- dsp/dec.c [3:7]
- dsp/dec_clip_tables.c [3:7]
- dsp/dec_mips32.c [3:7]
- dsp/dec_mips_dsp_r2.c [3:7]
- dsp/dec_msa.c [3:7]
- dsp/dec_neon.c [3:7]
- dsp/dec_sse2.c [3:7]
- dsp/dec_sse41.c [3:7]
- dsp/dsp.h [3:7]
- dsp/enc.c [3:7]
- dsp/enc_mips32.c [3:7]
- dsp/enc_mips_dsp_r2.c [3:7]
- dsp/enc_msa.c [3:7]
- dsp/enc_neon.c [3:7]
- dsp/enc_sse2.c [3:7]
- dsp/enc_sse41.c [3:7]
- dsp/filters.c [3:7]
- dsp/filters_mips_dsp_r2.c [3:7]
- dsp/filters_msa.c [3:7]
- dsp/filters_neon.c [3:7]
- dsp/filters_sse2.c [3:7]
- dsp/lossless.c [3:7]
- dsp/lossless.h [3:7]
- dsp/lossless_common.h [3:7]
- dsp/lossless_enc.c [3:7]
- dsp/lossless_enc_mips32.c [3:7]
- dsp/lossless_enc_mips_dsp_r2.c [3:7]
- dsp/lossless_enc_msa.c [3:7]
- dsp/lossless_enc_neon.c [3:7]
- dsp/lossless_enc_sse2.c [3:7]
- dsp/lossless_enc_sse41.c [3:7]
- dsp/lossless_mips_dsp_r2.c [3:7]
- dsp/lossless_msa.c [3:7]
- dsp/lossless_neon.c [3:7]
- dsp/lossless_sse2.c [3:7]
- dsp/lossless_sse41.c [3:7]
- dsp/mips_macro.h [3:7]
- dsp/msa_macro.h [3:7]
- dsp/neon.h [3:7]
- dsp/quant.h [3:7]
- dsp/rescaler.c [3:7]
- dsp/rescaler_mips32.c [3:7]
- dsp/rescaler_mips_dsp_r2.c [3:7]
- dsp/rescaler_msa.c [3:7]
- dsp/rescaler_neon.c [3:7]
- dsp/rescaler_sse2.c [3:7]
- dsp/ssim.c [3:7]
- dsp/ssim_sse2.c [3:7]
- dsp/upsampling.c [3:7]
- dsp/upsampling_mips_dsp_r2.c [3:7]
- dsp/upsampling_msa.c [3:7]
- dsp/upsampling_neon.c [3:7]
- dsp/upsampling_sse2.c [3:7]
- dsp/upsampling_sse41.c [3:7]
- dsp/yuv.c [3:7]
- dsp/yuv.h [3:7]
- dsp/yuv_mips32.c [3:7]
- dsp/yuv_mips_dsp_r2.c [3:7]
- dsp/yuv_neon.c [3:7]
- dsp/yuv_sse2.c [3:7]
- dsp/yuv_sse41.c [3:7]
- enc/alpha_enc.c [3:7]
- enc/analysis_enc.c [3:7]
- enc/backward_references_cost_enc.c [3:7]
- enc/backward_references_enc.c [3:7]
- enc/backward_references_enc.h [3:7]
- enc/config_enc.c [3:7]
- enc/cost_enc.c [3:7]
- enc/cost_enc.h [3:7]
- enc/filter_enc.c [3:7]
- enc/frame_enc.c [3:7]
- enc/histogram_enc.c [3:7]
- enc/histogram_enc.h [3:7]
- enc/iterator_enc.c [3:7]
- enc/near_lossless_enc.c [3:7]
- enc/picture_csp_enc.c [3:7]
- enc/picture_enc.c [3:7]
- enc/picture_psnr_enc.c [3:7]
- enc/picture_rescale_enc.c [3:7]
- enc/picture_tools_enc.c [3:7]
- enc/predictor_enc.c [3:7]
- enc/quant_enc.c [3:7]
- enc/syntax_enc.c [3:7]
- enc/token_enc.c [3:7]
- enc/tree_enc.c [3:7]
- enc/vp8i_enc.h [3:7]
- enc/vp8l_enc.c [3:7]
- enc/vp8li_enc.h [3:7]
- enc/webp_enc.c [3:7]
- mux/anim_encode.c [3:7]
- mux/animi.h [3:7]
- mux/muxedit.c [3:7]
- mux/muxi.h [3:7]
- mux/muxinternal.c [3:7]
- mux/muxread.c [3:7]
- utils/bit_reader_inl_utils.h [3:7]
- utils/bit_reader_utils.c [3:7]
- utils/bit_reader_utils.h [3:7]
- utils/bit_writer_utils.c [3:7]
- utils/bit_writer_utils.h [3:7]
- utils/color_cache_utils.c [3:7]
- utils/color_cache_utils.h [3:7]
- utils/endian_inl_utils.h [3:7]
- utils/filters_utils.c [3:7]
- utils/filters_utils.h [3:7]
- utils/huffman_encode_utils.c [3:7]
- utils/huffman_encode_utils.h [3:7]
- utils/huffman_utils.c [3:7]
- utils/huffman_utils.h [3:7]
- utils/quant_levels_dec_utils.c [3:7]
- utils/quant_levels_dec_utils.h [3:7]
- utils/quant_levels_utils.c [3:7]
- utils/quant_levels_utils.h [3:7]
- utils/random_utils.c [3:7]
- utils/random_utils.h [3:7]
- utils/rescaler_utils.c [3:7]
- utils/rescaler_utils.h [3:7]
- utils/thread_utils.c [3:7]
- utils/thread_utils.h [3:7]
- utils/utils.c [3:7]
- utils/utils.h [3:7]
- webp/decode.h [3:7]
- webp/demux.h [3:7]
- webp/encode.h [3:7]
- webp/format_constants.h [3:7]
- webp/mux.h [3:7]
- webp/mux_types.h [3:7]
- webp/types.h [3:7]
- Scancode info:
- Original SPDX id: LicenseRef-scancode-google-patent-license-webm
- Score : 90.00
- Match type : NOTICE
- Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/google-patent-license-webm.LICENSE, https://www.webmproject.org/license/additional/
- Files with this license:
- dec/alpha_dec.c [3:7]
- dec/alphai_dec.h [3:7]
- dec/buffer_dec.c [3:7]
- dec/common_dec.h [3:7]
- dec/frame_dec.c [3:7]
- dec/idec_dec.c [3:7]
- dec/io_dec.c [3:7]
- dec/quant_dec.c [3:7]
- dec/tree_dec.c [3:7]
- dec/vp8_dec.c [3:7]
- dec/vp8_dec.h [3:7]
- dec/vp8i_dec.h [3:7]
- dec/vp8l_dec.c [3:7]
- dec/vp8li_dec.h [3:7]
- dec/webp_dec.c [3:7]
- dec/webpi_dec.h [3:7]
- demux/anim_decode.c [3:7]
- demux/demux.c [3:7]
- dsp/alpha_processing.c [3:7]
- dsp/alpha_processing_mips_dsp_r2.c [3:7]
- dsp/alpha_processing_neon.c [3:7]
- dsp/alpha_processing_sse2.c [3:7]
- dsp/alpha_processing_sse41.c [3:7]
- dsp/common_sse2.h [3:7]
- dsp/common_sse41.h [3:7]
- dsp/cost.c [3:7]
- dsp/cost_mips32.c [3:7]
- dsp/cost_mips_dsp_r2.c [3:7]
- dsp/cost_neon.c [3:7]
- dsp/cost_sse2.c [3:7]
- dsp/cpu.c [3:7]
- dsp/dec.c [3:7]
- dsp/dec_clip_tables.c [3:7]
- dsp/dec_mips32.c [3:7]
- dsp/dec_mips_dsp_r2.c [3:7]
- dsp/dec_msa.c [3:7]
- dsp/dec_neon.c [3:7]
- dsp/dec_sse2.c [3:7]
- dsp/dec_sse41.c [3:7]
- dsp/dsp.h [3:7]
- dsp/enc.c [3:7]
- dsp/enc_mips32.c [3:7]
- dsp/enc_mips_dsp_r2.c [3:7]
- dsp/enc_msa.c [3:7]
- dsp/enc_neon.c [3:7]
- dsp/enc_sse2.c [3:7]
- dsp/enc_sse41.c [3:7]
- dsp/filters.c [3:7]
- dsp/filters_mips_dsp_r2.c [3:7]
- dsp/filters_msa.c [3:7]
- dsp/filters_neon.c [3:7]
- dsp/filters_sse2.c [3:7]
- dsp/lossless.c [3:7]
- dsp/lossless.h [3:7]
- dsp/lossless_common.h [3:7]
- dsp/lossless_enc.c [3:7]
- dsp/lossless_enc_mips32.c [3:7]
- dsp/lossless_enc_mips_dsp_r2.c [3:7]
- dsp/lossless_enc_msa.c [3:7]
- dsp/lossless_enc_neon.c [3:7]
- dsp/lossless_enc_sse2.c [3:7]
- dsp/lossless_enc_sse41.c [3:7]
- dsp/lossless_mips_dsp_r2.c [3:7]
- dsp/lossless_msa.c [3:7]
- dsp/lossless_neon.c [3:7]
- dsp/lossless_sse2.c [3:7]
- dsp/lossless_sse41.c [3:7]
- dsp/mips_macro.h [3:7]
- dsp/msa_macro.h [3:7]
- dsp/neon.h [3:7]
- dsp/quant.h [3:7]
- dsp/rescaler.c [3:7]
- dsp/rescaler_mips32.c [3:7]
- dsp/rescaler_mips_dsp_r2.c [3:7]
- dsp/rescaler_msa.c [3:7]
- dsp/rescaler_neon.c [3:7]
- dsp/rescaler_sse2.c [3:7]
- dsp/ssim.c [3:7]
- dsp/ssim_sse2.c [3:7]
- dsp/upsampling.c [3:7]
- dsp/upsampling_mips_dsp_r2.c [3:7]
- dsp/upsampling_msa.c [3:7]
- dsp/upsampling_neon.c [3:7]
- dsp/upsampling_sse2.c [3:7]
- dsp/upsampling_sse41.c [3:7]
- dsp/yuv.c [3:7]
- dsp/yuv.h [3:7]
- dsp/yuv_mips32.c [3:7]
- dsp/yuv_mips_dsp_r2.c [3:7]
- dsp/yuv_neon.c [3:7]
- dsp/yuv_sse2.c [3:7]
- dsp/yuv_sse41.c [3:7]
- enc/alpha_enc.c [3:7]
- enc/analysis_enc.c [3:7]
- enc/backward_references_cost_enc.c [3:7]
- enc/backward_references_enc.c [3:7]
- enc/backward_references_enc.h [3:7]
- enc/config_enc.c [3:7]
- enc/cost_enc.c [3:7]
- enc/cost_enc.h [3:7]
- enc/filter_enc.c [3:7]
- enc/frame_enc.c [3:7]
- enc/histogram_enc.c [3:7]
- enc/histogram_enc.h [3:7]
- enc/iterator_enc.c [3:7]
- enc/near_lossless_enc.c [3:7]
- enc/picture_csp_enc.c [3:7]
- enc/picture_enc.c [3:7]
- enc/picture_psnr_enc.c [3:7]
- enc/picture_rescale_enc.c [3:7]
- enc/picture_tools_enc.c [3:7]
- enc/predictor_enc.c [3:7]
- enc/quant_enc.c [3:7]
- enc/syntax_enc.c [3:7]
- enc/token_enc.c [3:7]
- enc/tree_enc.c [3:7]
- enc/vp8i_enc.h [3:7]
- enc/vp8l_enc.c [3:7]
- enc/vp8li_enc.h [3:7]
- enc/webp_enc.c [3:7]
- mux/anim_encode.c [3:7]
- mux/animi.h [3:7]
- mux/muxedit.c [3:7]
- mux/muxi.h [3:7]
- mux/muxinternal.c [3:7]
- mux/muxread.c [3:7]
- utils/bit_reader_inl_utils.h [3:7]
- utils/bit_reader_utils.c [3:7]
- utils/bit_reader_utils.h [3:7]
- utils/bit_writer_utils.c [3:7]
- utils/bit_writer_utils.h [3:7]
- utils/color_cache_utils.c [3:7]
- utils/color_cache_utils.h [3:7]
- utils/endian_inl_utils.h [3:7]
- utils/filters_utils.c [3:7]
- utils/filters_utils.h [3:7]
- utils/huffman_encode_utils.c [3:7]
- utils/huffman_encode_utils.h [3:7]
- utils/huffman_utils.c [3:7]
- utils/huffman_utils.h [3:7]
- utils/quant_levels_dec_utils.c [3:7]
- utils/quant_levels_dec_utils.h [3:7]
- utils/quant_levels_utils.c [3:7]
- utils/quant_levels_utils.h [3:7]
- utils/random_utils.c [3:7]
- utils/random_utils.h [3:7]
- utils/rescaler_utils.c [3:7]
- utils/rescaler_utils.h [3:7]
- utils/thread_utils.c [3:7]
- utils/thread_utils.h [3:7]
- utils/utils.c [3:7]
- utils/utils.h [3:7]
- webp/decode.h [3:7]
- webp/demux.h [3:7]
- webp/encode.h [3:7]
- webp/format_constants.h [3:7]
- webp/mux.h [3:7]
- webp/mux_types.h [3:7]
- webp/types.h [3:7]
-
-KEEP BSD-3-Clause WITH Google-Patent-License-Webm ea47335856939f47cbedd5b93b915254
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: BSD-3-Clause
- Score : 100.00
- Match type : TEXT
- Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
- Files with this license:
- COPYING [3:29]
diff --git a/contrib/libs/libwebp/.yandex_meta/licenses.list.txt b/contrib/libs/libwebp/.yandex_meta/licenses.list.txt
deleted file mode 100644
index 1d290455fa..0000000000
--- a/contrib/libs/libwebp/.yandex_meta/licenses.list.txt
+++ /dev/null
@@ -1,253 +0,0 @@
-====================BSD-3-Clause WITH Google-Patent-License-Webm====================
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-#
-# * Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in
-# the documentation and/or other materials provided with the
-# distribution.
-#
-# * Neither the name of Google nor the names of its contributors may
-# be used to endorse or promote products derived from this software
-# without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-====================BSD-3-Clause WITH Google-Patent-License-Webm====================
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-
-
-====================BSD-3-Clause WITH Google-Patent-License-Webm====================
-Additional IP Rights Grant (Patents)
-------------------------------------
-
-"These implementations" means the copyrightable works that implement the WebM
-codecs distributed by Google as part of the WebM Project.
-
-Google hereby grants to you a perpetual, worldwide, non-exclusive, no-charge,
-royalty-free, irrevocable (except as stated in this section) patent license to
-make, have made, use, offer to sell, sell, import, transfer, and otherwise
-run, modify and propagate the contents of these implementations of WebM, where
-such license applies only to those patent claims, both currently owned by
-Google and acquired in the future, licensable by Google that are necessarily
-infringed by these implementations of WebM. This grant does not include claims
-that would be infringed only as a consequence of further modification of these
-implementations. If you or your agent or exclusive licensee institute or order
-or agree to the institution of patent litigation or any other patent
-enforcement activity against any entity (including a cross-claim or
-counterclaim in a lawsuit) alleging that any of these implementations of WebM
-or any code incorporated within any of these implementations of WebM
-constitute direct or contributory patent infringement, or inducement of
-patent infringement, then any patent rights granted to you under this License
-for these implementations of WebM shall terminate as of the date such
-litigation is filed.
-
-====================BSD-3-Clause WITH Google-Patent-License-Webm====================
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
-
- * Neither the name of Google nor the names of its contributors may
- be used to endorse or promote products derived from this software
- without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-====================COPYRIGHT====================
-# Copyright (c) 2021, Google Inc. All rights reserved.
-
-
-====================COPYRIGHT====================
-// Copyright 2010 Google Inc. All Rights Reserved.
-
-
-====================COPYRIGHT====================
-// Copyright 2011 Google Inc. All Rights Reserved.
-
-
-====================COPYRIGHT====================
-// Copyright 2012 Google Inc. All Rights Reserved.
-
-
-====================COPYRIGHT====================
-// Copyright 2013 Google Inc. All Rights Reserved.
-
-
-====================COPYRIGHT====================
-// Copyright 2014 Google Inc. All Rights Reserved.
-
-
-====================COPYRIGHT====================
-// Copyright 2015 Google Inc. All Rights Reserved.
-
-
-====================COPYRIGHT====================
-// Copyright 2016 Google Inc. All Rights Reserved.
-
-
-====================COPYRIGHT====================
-// Copyright 2017 Google Inc. All Rights Reserved.
-
-
-====================COPYRIGHT====================
-// Copyright 2018 Google Inc. All Rights Reserved.
-
-
-====================COPYRIGHT====================
-// Copyright 2021 Google Inc. All Rights Reserved.
-
-
-====================COPYRIGHT====================
-Copyright (c) 2010, Google Inc. All rights reserved.
-
-
-====================File: AUTHORS====================
-Contributors:
-- Aidan O'Loan (aidanol at gmail dot com)
-- Alan Browning (browning at google dot com)
-- Charles Munger (clm at google dot com)
-- Cheng Yi (cyi at google dot com)
-- Christian Duvivier (cduvivier at google dot com)
-- Christopher Degawa (ccom at randomderp dot com)
-- Clement Courbet (courbet at google dot com)
-- Djordje Pesut (djordje dot pesut at imgtec dot com)
-- Hui Su (huisu at google dot com)
-- Ilya Kurdyukov (jpegqs at gmail dot com)
-- Ingvar Stepanyan (rreverser at google dot com)
-- James Zern (jzern at google dot com)
-- Jan Engelhardt (jengelh at medozas dot de)
-- Jehan (jehan at girinstud dot io)
-- Johann Koenig (johann dot koenig at duck dot com)
-- Jovan Zelincevic (jovan dot zelincevic at imgtec dot com)
-- Jyrki Alakuijala (jyrki at google dot com)
-- Konstantin Ivlev (tomskside at gmail dot com)
-- Lode Vandevenne (lode at google dot com)
-- Lou Quillio (louquillio at google dot com)
-- Mans Rullgard (mans at mansr dot com)
-- Marcin Kowalczyk (qrczak at google dot com)
-- Martin Olsson (mnemo at minimum dot se)
-- Mikołaj Zalewski (mikolajz at google dot com)
-- Mislav Bradac (mislavm at google dot com)
-- Nico Weber (thakis at chromium dot org)
-- Noel Chromium (noel at chromium dot org)
-- Oliver Wolff (oliver dot wolff at qt dot io)
-- Owen Rodley (orodley at google dot com)
-- Parag Salasakar (img dot mips1 at gmail dot com)
-- Pascal Massimino (pascal dot massimino at gmail dot com)
-- Paweł Hajdan, Jr (phajdan dot jr at chromium dot org)
-- Pierre Joye (pierre dot php at gmail dot com)
-- Roberto Alanis (alanisbaez at google dot com)
-- Sam Clegg (sbc at chromium dot org)
-- Scott Hancher (seh at google dot com)
-- Scott LaVarnway (slavarnway at google dot com)
-- Scott Talbot (s at chikachow dot org)
-- Slobodan Prijic (slobodan dot prijic at imgtec dot com)
-- Somnath Banerjee (somnath dot banerjee at gmail dot com)
-- Sriraman Tallam (tmsriram at google dot com)
-- Tamar Levy (tamar dot levy at intel dot com)
-- Timothy Gu (timothygu99 at gmail dot com)
-- Urvang Joshi (urvang at google dot com)
-- Vikas Arora (vikasa at google dot com)
-- Vincent Rabaud (vrabaud at google dot com)
-- Vlad Tsyrklevich (vtsyrklevich at chromium dot org)
-- Wan-Teh Chang (wtc at google dot com)
-- Yang Zhang (yang dot zhang at arm dot com)
-- Yannis Guyon (yguyon at google dot com)
-- Zhi An Ng (zhin at chromium dot org)
-
-
-====================File: COPYING====================
-Copyright (c) 2010, Google Inc. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
-
- * Neither the name of Google nor the names of its contributors may
- be used to endorse or promote products derived from this software
- without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-
-====================File: PATENTS====================
-Additional IP Rights Grant (Patents)
-------------------------------------
-
-"These implementations" means the copyrightable works that implement the WebM
-codecs distributed by Google as part of the WebM Project.
-
-Google hereby grants to you a perpetual, worldwide, non-exclusive, no-charge,
-royalty-free, irrevocable (except as stated in this section) patent license to
-make, have made, use, offer to sell, sell, import, transfer, and otherwise
-run, modify and propagate the contents of these implementations of WebM, where
-such license applies only to those patent claims, both currently owned by
-Google and acquired in the future, licensable by Google that are necessarily
-infringed by these implementations of WebM. This grant does not include claims
-that would be infringed only as a consequence of further modification of these
-implementations. If you or your agent or exclusive licensee institute or order
-or agree to the institution of patent litigation or any other patent
-enforcement activity against any entity (including a cross-claim or
-counterclaim in a lawsuit) alleging that any of these implementations of WebM
-or any code incorporated within any of these implementations of WebM
-constitute direct or contributory patent infringement, or inducement of
-patent infringement, then any patent rights granted to you under this License
-for these implementations of WebM shall terminate as of the date such
-litigation is filed.
diff --git a/contrib/libs/libwebp/.yandex_meta/override.nix b/contrib/libs/libwebp/.yandex_meta/override.nix
deleted file mode 100644
index d625d7d480..0000000000
--- a/contrib/libs/libwebp/.yandex_meta/override.nix
+++ /dev/null
@@ -1,12 +0,0 @@
-pkgs: attrs: with pkgs; with attrs; rec {
- version = "1.2.2";
-
- src = fetchFromGitHub {
- owner = "webmproject";
- repo = "libwebp";
- rev = "v${version}";
- hash = "sha256-WF2HZPS7mbotk+d1oLM/JC5l/FWfkrk+T3Z6EW9oYEI=";
- };
-
- patches = [];
-}
diff --git a/contrib/libs/libwebp/AUTHORS b/contrib/libs/libwebp/AUTHORS
deleted file mode 100644
index 8307c2099d..0000000000
--- a/contrib/libs/libwebp/AUTHORS
+++ /dev/null
@@ -1,52 +0,0 @@
-Contributors:
-- Aidan O'Loan (aidanol at gmail dot com)
-- Alan Browning (browning at google dot com)
-- Charles Munger (clm at google dot com)
-- Cheng Yi (cyi at google dot com)
-- Christian Duvivier (cduvivier at google dot com)
-- Christopher Degawa (ccom at randomderp dot com)
-- Clement Courbet (courbet at google dot com)
-- Djordje Pesut (djordje dot pesut at imgtec dot com)
-- Hui Su (huisu at google dot com)
-- Ilya Kurdyukov (jpegqs at gmail dot com)
-- Ingvar Stepanyan (rreverser at google dot com)
-- James Zern (jzern at google dot com)
-- Jan Engelhardt (jengelh at medozas dot de)
-- Jehan (jehan at girinstud dot io)
-- Johann Koenig (johann dot koenig at duck dot com)
-- Jovan Zelincevic (jovan dot zelincevic at imgtec dot com)
-- Jyrki Alakuijala (jyrki at google dot com)
-- Konstantin Ivlev (tomskside at gmail dot com)
-- Lode Vandevenne (lode at google dot com)
-- Lou Quillio (louquillio at google dot com)
-- Mans Rullgard (mans at mansr dot com)
-- Marcin Kowalczyk (qrczak at google dot com)
-- Martin Olsson (mnemo at minimum dot se)
-- Mikołaj Zalewski (mikolajz at google dot com)
-- Mislav Bradac (mislavm at google dot com)
-- Nico Weber (thakis at chromium dot org)
-- Noel Chromium (noel at chromium dot org)
-- Oliver Wolff (oliver dot wolff at qt dot io)
-- Owen Rodley (orodley at google dot com)
-- Parag Salasakar (img dot mips1 at gmail dot com)
-- Pascal Massimino (pascal dot massimino at gmail dot com)
-- Paweł Hajdan, Jr (phajdan dot jr at chromium dot org)
-- Pierre Joye (pierre dot php at gmail dot com)
-- Roberto Alanis (alanisbaez at google dot com)
-- Sam Clegg (sbc at chromium dot org)
-- Scott Hancher (seh at google dot com)
-- Scott LaVarnway (slavarnway at google dot com)
-- Scott Talbot (s at chikachow dot org)
-- Slobodan Prijic (slobodan dot prijic at imgtec dot com)
-- Somnath Banerjee (somnath dot banerjee at gmail dot com)
-- Sriraman Tallam (tmsriram at google dot com)
-- Tamar Levy (tamar dot levy at intel dot com)
-- Timothy Gu (timothygu99 at gmail dot com)
-- Urvang Joshi (urvang at google dot com)
-- Vikas Arora (vikasa at google dot com)
-- Vincent Rabaud (vrabaud at google dot com)
-- Vlad Tsyrklevich (vtsyrklevich at chromium dot org)
-- Wan-Teh Chang (wtc at google dot com)
-- Yang Zhang (yang dot zhang at arm dot com)
-- Yannis Guyon (yguyon at google dot com)
-- Zhi An Ng (zhin at chromium dot org)
diff --git a/contrib/libs/libwebp/CONTRIBUTING.md b/contrib/libs/libwebp/CONTRIBUTING.md
deleted file mode 100644
index 7a73a30317..0000000000
--- a/contrib/libs/libwebp/CONTRIBUTING.md
+++ /dev/null
@@ -1,29 +0,0 @@
-# How to Contribute
-
-We'd love to accept your patches and contributions to this project. There are
-just a few small guidelines you need to follow.
-
-## Contributor License Agreement
-
-Contributions to this project must be accompanied by a Contributor License
-Agreement. You (or your employer) retain the copyright to your contribution;
-this simply gives us permission to use and redistribute your contributions as
-part of the project. Head over to <https://cla.developers.google.com/> to see
-your current agreements on file or to sign a new one.
-
-You generally only need to submit a CLA once, so if you've already submitted one
-(even if it was for a different project), you probably don't need to do it
-again.
-
-## Code reviews
-
-All submissions, including submissions by project members, require review. We
-use a [Gerrit](https://www.gerritcodereview.com) instance hosted at
-https://chromium-review.googlesource.com for this purpose. See the
-[WebM Project page](https://www.webmproject.org/code/contribute/submitting-patches/)
-for additional details.
-
-## Community Guidelines
-
-This project follows
-[Google's Open Source Community Guidelines](https://opensource.google.com/conduct/).
diff --git a/contrib/libs/libwebp/COPYING b/contrib/libs/libwebp/COPYING
deleted file mode 100644
index 7a6f99547d..0000000000
--- a/contrib/libs/libwebp/COPYING
+++ /dev/null
@@ -1,30 +0,0 @@
-Copyright (c) 2010, Google Inc. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
-
- * Neither the name of Google nor the names of its contributors may
- be used to endorse or promote products derived from this software
- without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
diff --git a/contrib/libs/libwebp/ChangeLog b/contrib/libs/libwebp/ChangeLog
deleted file mode 100644
index 3411ea61a2..0000000000
--- a/contrib/libs/libwebp/ChangeLog
+++ /dev/null
@@ -1,4282 +0,0 @@
-6db8248c libwebp: Fix VP8EncTokenLoop() progress
-827a307f BMP enc: fix the transparency case
-286e7fce libwebp: do not destroy jpeg codec twice on error
-9195ea05 update ChangeLog (tag: v1.2.2-rc2)
-4acae017 update NEWS
-883f0633 man/img2webp.1: update date
-567e1f44 Reword img2webp synopsis command line
-f084244d anim_decode: fix alpha blending with big-endian
-b217b4ff webpinfo: fix fourcc comparison w/big-endian
-f035d2e4 update ChangeLog (tag: v1.2.2-rc1)
-7031946a update NEWS
-973390b6 bump version to 1.2.2
-abd6664f update AUTHORS
-5b7e7930 Merge "add missing USE_{MSA,NEON} checks in headers" into main
-02ca04c3 add missing USE_{MSA,NEON} checks in headers
-e94716e2 xcframeworkbuild.sh: place headers in a subdir
-c846efd8 patch-check: commit subject length check
-b6f756e8 update http links
-8f5cb4c1 update rfc links
-8ea81561 change VP8LPredictorFunc signature to avoid reading 'left'
-6b1d18c3 webpmux: fix the -bgcolor description
-3368d876 Merge "webpmux: add "-set bgcolor A,R,G,B"" into main
-f213abf6 webpinfo: print the number of warnings
-50c97c30 webpmux: add "-set bgcolor A,R,G,B"
-2c206aaf Remove CMakeLists.txt check in compile.sh
-96e3dfef Merge "infra/common.sh: add shard_should_run()" into main
-0e0f74b7 infra/common.sh: add shard_should_run()
-35b7436a Jenkins scripts port: update shell function comments
-21d24b4c webp-container-spec.txt: remove 'experimental' markers
-cdcf8902 Merge "Port Jenkins script: compile" into main
-dc683cde Jenkins scripts port: static analysis
-0858494e Port Jenkins script: compile
-c2cf6a93 Jenkins scripts port: android compilation
-df0e808f presubmit: Add pylint-2.7 and .pylintrc
-676c57db patch-check: shfmt
-7bb7f747 patch-check: Add shellcheck
-abcd1797 Reformat docstrings and imports
-edaf0895 Port Jenkins scripts: compile js
-b9622063 Set CheckPatchFormatted flags to fail on diffs
-e23cd548 dsp.h: enable NEON w/VS2019+ ARM64 targets
-3875c7de CMakeLists.txt: set minimum version to 3.7
-1a8f0d45 Have a hard-coded value for memset in TrellisQuantizeBlock.
-93480160 Speed up TrellisQuantizeBlock
-45eaacc9 Convert deprecated uint32 to uint32_t.
-42592af8 webp,cmake: Remove unnecessary include dirs
-e298e05f Add patch-check steps in PRESUBMIT.py
-29148919 Merge tag 'v1.2.1'
-9ce5843d update ChangeLog (tag: v1.2.1, origin/1.2.1)
-d9191588 fuzzer/*: normalize src/ includes
-c5bc3624 fuzzer/*: normalize src/ includes
-53b6f762 fix indent
-d2caaba4 fix indent
-731246ba update ChangeLog (tag: v1.2.1-rc2)
-d250f01d dsp/*: use WEBP_HAVE_* to determine Init availability
-1fe31625 dsp/*: use WEBP_HAVE_* to determine Init availability
-3a4d3ecd update NEWS
-b2bc8093 bump version to 1.2.1
-e542fc7a update AUTHORS
-e0241154 Merge "libwebp/CMake: Add <BUILD_INTERFACE> to webp incl" into main
-edea6444 libwebp/CMake: Add <BUILD_INTERFACE> to webp incl
-ece18e55 dsp.h: respect --disable-sse2/sse4.1/neon
-a89a3230 wicdec: support alpha from WebP WIC decoder
-26f4aa01 Merge "alpha_processing: fix visual studio warnings" into main
-8f594663 alpha_processing: fix visual studio warnings
-46d844e6 Merge "cpu.cmake: fix compiler flag detection w/3.17.0+" into main
-298d26ea Merge changes I593adf92,If20675e7,Ifac68eac into main
-a1e5dae0 alpha_processing*: use WEBP_RESTRICT qualifier
-327ef24f cpu.cmake: fix compiler flag detection w/3.17.0+
-f70819de configure: enable libwebpmux by default
-dc7e2b42 configure: add informational notices when disabling binaries
-9df23ddd configure: move lib flag checks before binaries
-a2e18f10 Merge "WebPConfig.config.in: correct WEBP_INCLUDE_DIRS" into main
-e1a8d4f3 Merge "bit_reader_inl_utils: uniformly apply WEBP_RESTRICT" into main
-4de35f43 rescaler.c: fix alignment
-0f13eec7 bit_reader_inl_utils: uniformly apply WEBP_RESTRICT
-277d3074 Fix size_t overflow in WebPRescalerInit
-97adbba5 WebPConfig.config.in: correct WEBP_INCLUDE_DIRS
-b60d4603 advanced_api_fuzzer: add extreme config value coverage
-72fe52f6 anim_encode.c,cosmetics: normalize indent
-116d235c anim_encode: Fix encoded_frames_[] overflow
-6f445b3e CMake: set CMP0072 to NEW
-b1cf887f define WEBP_RESTRICT for MSVC
-3e265136 Add WEBP_RESTRICT & use it in VP8BitReader
-f6d29247 vp8l_dec::ProcessRows: fix int overflow in multiply
-de3b4ba8 CMake: add WEBP_BUILD_LIBWEBPMUX
-7f09d3d1 CMakeLists.txt: rm libwebpmux dep from anim_{diff,dump}
-4edea4a6 Init{RGB,YUV}Rescaler: fix a few more int overflows
-c9e26bdb rescaler_utils: set max valid scaled w/h to INT_MAX/2
-28d488e6 utils.h: add SizeOverflow()
-695bdaa2 Export/EmitRescaledRowsRGBA: fix pointer offset int overflow
-685d073e Init{RGB,YUV}Rescaler: fix int overflows in multiplication
-d38bd0dd WebPFlipBuffer: fix integer overflow
-109ff0f1 utils: allow MALLOC_LIMIT to indicate a max
-a2fce867 WebPRescalerImportRowExpand_C: promote some vals before multiply
-776983d4 AllocateBuffer: fix int multiplication overflow check
-315abbd6 Merge "Revert "Do not use a palette for one color images.""
-eae815d0 Merge changes Ica3bbf75,I82f82954
-afbca5a1 Require Emscripten 2.0.18
-3320416b CMakeLists,emscripten: use EXPORTED_RUNTIME_METHODS
-29145ed6 Update README instructions for using Emscripten
-1f579139 cosmetics: remove use of 'sanity' / 'master'
-29b6129c WebPAnimEncoderNewInternal: remove some unnecessary inits
-b60869a1 Revert "Do not use a palette for one color images."
-6fb4cddc demux: move padded size calc post unpadded validation
-05b72d42 vp8l_enc.c: normalize index types
-b6513fba Do not use a palette for one color images.
-98bbe35b Fix multi-threading with palettes.
-b1674240 Add modified Zeng's method to palette sorting.
-88c90c45 add CONTRIBUTING.md
-6a9916d7 WebPRescalerInit: add missing int64_t promotion
-b6cf52d5 WebPIoInitFromOptions: treat use_scaling as a bool
-3b12b7f4 WebPIoInitFromOptions: treat use_cropping as a bool
-595fa13f add WebPCheckCropDimensions()
-8fdaecb0 Disable cross-color when palette is used.
-8933bac2 WebPIoInitFromOptions: respect incoming bypass_filtering val
-7d416ff0 webpdec,cosmetics: match error text to function call
-ec6cfeb5 Fix typo on WebPPictureAlloc() in README
-7e58a1a2 *.cmake: add license header
-5651a6b2 cmake: fix .so versioning
-25ae67b3 xcframeworkbuild.sh: add arm64 simulator target
-5d4ee4c3 cosmetics: remove use of the term 'dummy'
-01b38ee1 faster CollectColorXXXTransforms_SSE41
-652aa344 Merge "Use BitCtz for FastSLog2Slow_C"
-0320e1e3 add the missing default BitsCtz() code
-8886f620 Use BitCtz for FastSLog2Slow_C
-fae41617 faster CombinedShannonEntropy_SSE2
-5bd2704e Introduce the BitCtz() function.
-fee64287 Merge "wicdec,icc: treat unsupported op as non-fatal"
-33ddb894 lossless_sse{2,41}: remove some unneeded includes
-b27ea852 wicdec,icc: treat unsupported op as non-fatal
-b78494a9 Merge "Fix undefined signed shift."
-e79974cd Fix undefined signed shift.
-a8853394 SSE4.1 versions of BGRA to RGB/BGR color-space conversions
-a09a6472 SSE4.1 version of TransformColorInverse
-401da22b Merge "pngdec: check version before using png_get_chunk_malloc_max"
-26907822 pngdec: check version before using png_get_chunk_malloc_max
-06c1e72e Code cleanup
-8f0d41aa Merge changes Id135bbf4,I99e59797
-373eb170 gif2webp: don't store loop-count if there's only 1 frame
-759b9d5a cmake: add WEBP_USE_THREAD option
-926ce921 cmake: don't install binaries from extras/
-9c367bc6 WebPAnimDecoderNewInternal: validate bitstream before alloc
-47f64f6e filters_sse2: import Chromium change
-cc3577e9 fuzzer/*: use src/ based include paths
-004d77ff Merge tag 'v1.2.0'
-fedac6cc update ChangeLog (tag: v1.2.0-rc3, tag: v1.2.0)
-170a8712 Fix check_c_source_compiles with pthread.
-ceddb5fc Fix check_c_source_compiles with pthread.
-85995719 disable CombinedShannonEntropy_SSE2 on x86
-289757fe TiffDec: enforce stricter mem/dimension limit on tiles
-8af7436f Merge "{ios,xcframework}build.sh: make min version(s) more visible" into 1.2.0
-e56c3c5b pngdec: raise memory limit if needed
-8696147d pngdec: raise memory limit if needed
-13b8e9fe {ios,xcframework}build.sh: make min version(s) more visible
-a9225410 animdecoder_fuzzer: fix memory leak
-d6c2285d update gradle to 6.1.1
-8df77fb1 animdecoder_fuzzer: fix memory leak
-52ce6333 update NEWS
-28c49820 bump version to 1.2.0
-7363dff2 webp/encode.h: restore WEBP_ENCODER_ABI_VERSION to v1.1.0
-826aafa5 update AUTHORS
-63258823 animdecoder_fuzzer: validate canvas size
-9eb26381 CMake: remove duplicate "include(GNUInstallDirs)"
-2e7bed79 WebPPicture: clarify the ownership of user-owned data.
-cccf5e33 webpmux: add an '-set loop <value>' option
-c9a3f6a1 Merge changes Ie29f9867,I289c54c4
-319f56f1 iosbuild.sh: sync some aspects of xcframeworkbuild.sh
-e8e8db98 add xcframeworkbuild.sh
-ae545534 dsp.h: allow config.h to override MSVC SIMD autodetection
-fef789f3 Merge "cmake: fix per-file assembly flags"
-fc14fc03 Have C encoding predictors use decoding predictors.
-7656f0b3 README,cosmetics: fix a couple typos
-d2e245ea cmake: disable webp.js if WEBP_ENABLE_SIMD=1
-96099a79 cmake: fix per-file assembly flags
-5abb5582 Merge "cmake: fix compilation w/Xcode generator"
-8484a120 cmake: fix compilation w/Xcode generator
-d7bf01c9 Merge changes Ifcae0f38,Iee2d7401
-36c81ff6 WASM-SIMD: port 2 patches from rreverser@'s tree
-988b02ab Merge "Couple of fixes to allow SIMD on Emscripten"
-26faf770 wicdec: fail with animated images
-ab2d08a8 [cd]webp: document lack of animated webp support
-52273943 Couple of fixes to allow SIMD on Emscripten
-8870ba7f Fix skia bug #10952
-4b3c6953 Detect if StoreFrame read more than anmf_payload_size bytes
-17fd4ba8 webp/decode.h,cosmetics: normalize 'flip' comment
-411d3677 remove some unreachable break statements
-3700ffd7 WebPPictureHasTransparency: remove unreachable return
-83604bf3 {animencoder,enc_dec}_fuzzer: convert some abort()s to returns
-eb44119c Merge changes I8ae09473,I678c8b1e
-9f6055fc fuzz_utils.h: rename max() to Max()
-695788e7 fuzz_utils.h: make functions WEBP_INLINE
-906c1fcd make ImgIoUtilReadFile use WebPMalloc instead of malloc
-8cb7e536 rename demux_api_fuzzer.c -> mux_demux_api_fuzzer.c
-443db47d add animdecoder_fuzzer.cc
-36a6eea3 Merge "import fuzzers from oss-fuzz/chromium"
-ec5f12c1 Makefile.vc: remove deprecated /Gm option
-64425a08 picture_tools_enc: fix windows build warning
-bd94090a import fuzzers from oss-fuzz/chromium
-cf847cba use WEBP_DSP_INIT_FUNC for Init{GammaTables*,GetCoeffs}
-55a080e5 Add WebPReplaceTransparentPixels() in dsp
-84739717 GetBackgroundColorGIF: promote to uint32_t before << 24
-def64e92 cwebp: Fix -print_psnr for near_lossless
-cf2f88b3 Add palette and spatial for q >= 75 and -m 5
-f0110bae Add no-color cache configuration to the cruncher
-749a8b99 Better estimate of the cache cost.
-4f9f00cc Use spatial predictors on top of palette no matter what.
-7658c686 Add spatial prediction on top of palette in cruncher.
-133ff0e3 webp_js: force WASM=0 option explicitly
-e3c259a2 Fix integer overflow in EmitFancyRGB.
-b3ff0bde man/{gif2,img2}webp,webpmux: normalize some wording
-f9b30586 fix ABI breakage introduced by 6a0ff358
-1d58dcfc README.webp_js: update note about emscripten version
-44070266 README.webp_js: s/fastcomp/upstream/
-2565fa8f README.webp_js: update cmake command
-47309ef5 webp: WEBP_OFFSET_PTR()
-687ab00e DC{4,8,16}_NEON: replace vmovl w/vaddl
-1b92fe75 DC16_NEON,aarch64: use vaddlv
-53f3d8cf dec_neon,DC8_NEON: use vaddlv instead of movl+vaddv
-27d08240 Fix integer overflow in WebPAnimDecoderGetNext()
-69776e38 Merge "remove call to MBAnalyzeBestIntra4Mode for method >= 5"
-a99078c1 remove call to MBAnalyzeBestIntra4Mode for method >= 5
-22e404cc CMakeLists.txt: fix set(CACHE) argument order
-71690b52 fix MSVC warning
-6a0ff358 Enc: add a qmin / qmax range for quality factor
-0fa56f30 Merge tag 'v1.1.0'
-6cf504d0 PNM decoding: handle max_value != 255
-d7844e97 update ChangeLog (tag: v1.1.0-rc2, tag: v1.1.0, origin/1.1.0)
-7f006436 Makefile.vc: fix webp_quality.exe link
-cf047e83 Makefile.vc: fix webp_quality.exe link
-c074c653 update NEWS
-30f09551 bump version to 1.1.0
-a76694a1 update AUTHORS
-6e3ef7b3 extras: fix WEBP_SWAP_16BIT_CSP check
-47178dbd extras: add WebPUnmultiplyARGB() convenience function
-22cbae33 idec_dec: fix 0 offset of NULL pointer
-290dd0b4 muxread: fix 0 offset of NULL pointer
-0df474ac Merge "lossless_(enc_|)sse2: avoid offsetting a NULL pointer"
-c6b75a19 lossless_(enc_|)sse2: avoid offsetting a NULL pointer
-295e5e38 fix UBSAN warning
-e2575e05 DC8_NEON,aarch64: use vaddv
-b0e09e34 dec_neon: Fix build failure under some toolchains
-cf0e903c dsp/lossless: Fix non gcc ARM builds
-bb7bc40b Remove ubsan errors.
-78881b76 CMake: fix GLUT library link
-9f750f7a cmake: fix BUILD_SHARED_LIBS build on mac
-17850e74 libwebp: Remove char-subscripts warning in pnmdec.c
-2fa2552d Merge "Expose WebPMalloc() in addition to WebPFree()"
-a4df4aae Expose WebPMalloc() in addition to WebPFree()
-853ea3d8 imageio/tiff: Return error before allocating bad tile size
-af650c0b Fix a Wxor-used-as-pow false positive
-601ef17c libwebp.py: update to swig 3.0.12
-0e48d889 bugfix: last alpha rows were incorrectly decoded
-24d2ccb4 webp: Fix imageio ReadPNM() TUPLTYPE
-fab8f9cf cosmetics: normalize '*' association
-94138e0e update .gitignore
-0fe1a89d update ChangeLog (tag: v1.0.3-rc1, tag: v1.0.3)
-2ad0916d update NEWS
-1287362b bump version to 1.0.3
-7b968cc2 update AUTHORS
-9d6988f4 Fix the oscillating prediction problem at low quality
-312f74d0 makefile.unix: allow *_LIBS to be overridden w/EXTRA_LIBS
-92dbf237 filters_sse2,cosmetics: shorten some long lines
-a277d197 filters_sse2.c: quiet integer sanitizer warnings
-804540f1 Fix cpufeatures in CMake.
-bf00c15b Add CMake option for bittrace.
-a788b498 filters_sse2.c: quiet integer sanitizer warnings
-e6a92c5e filters.c: quiet integer sanitizer warnings
-ec1cc40a lossless.c: remove U32 -> S8 conversion warnings
-1106478f remove conversion U32 -> S8 warnings
-812a6b49 lossless_enc: fix some conversion warning
-4627c1c9 lossless_enc,TransformColorBlue: quiet uint32_t conv warning
-c84673a6 lossless_enc_sse{2,41}: quiet signed conv warnings
-776a7757 dec_sse2: quiet signed conv warnings
-bd39c063 Merge "thread_utils: release mutex before signaling"
-0550576f Merge "(alpha_processing,enc}_sse2: quiet signed conv warnings"
-6682f2c4 thread_utils: release mutex before signaling
-e78dea75 (alpha_processing,enc}_sse2: quiet signed conv warnings
-9acf18ba iosbuild.sh: add WebP{Demux,Mux}.framework
-b9be7e65 vwebp: remove the -fit option (and make it default)
-1394a2bb Merge "README.webp_js: update Emscripten.cmake note"
-dd3e7f8a README.webp_js: update Emscripten.cmake note
-32cf8801 predictor_enc,GetBestGreenRedToBlue: quiet implicit conv warnings
-e1c8acb5 Merge "vwebp: add a -fit option"
-cbd23dd5 vwebp: add a -fit option
-2e672351 bit_writer_utils,Flush: quiet implicit conversion warnings
-1326988d swig: update libwebp_python_wrap.c
-0e7f8548 update generated swig files
-17ed1438 Merge "PutLE{16,24}: quiet implicit conversion warnings"
-24686538 PutLE{16,24}: quiet implicit conversion warnings
-153bb3a0 fix some clang-7 warnings:
-ab2dc893 Rescaler: fix rounding error
-aa65f89a HistogramCombineStochastic: fix free of uninit value
-af0bac64 Merge "encode.h: mention 'exact' default in WebPEncodeLossless*"
-6d2e11ec encode.h: mention 'exact' default in WebPEncodeLossless*
-8c3f04fe AndroidCPUInfo: reorder terms in conditional
-fcfd9c71 BitTrace: if BITTRACE is > 0, record and print syntax bits used
-067031ea Speedups for unused Huffman groups.
-01ac46ba libwebp: Display "libjpeg error:" in imageio/jpegdec
-d9a662e1 WebPRescalerGetScaledDimensions: round scaled dimension up
-62eb3f08 libwebp: Fix missing '{' in README
-e05f785a Merge "unicode,INIT_WARGV: add missing cast"
-63c9a69f tag the VP8LHashPix() function for potential uint roll-over
-2b7214ab unicode,INIT_WARGV: add missing cast
-bf424b46 tag the GetPixPairHash64() function for potential uint roll-over
-7d05d6ca Have the color cache computation be u32-bit only.
-6bcf8769 Remove BINARYEN_METHOD in wasm settings.
-2b98df90 update ChangeLog (tag: v1.0.2-rc1, tag: v1.0.2)
-61e372b7 update NEWS
-7ae658a0 bump version to 1.0.2
-51c4907d update AUTHORS
-666bd6c6 man/cwebp.1: refine near-lossless text
-561cdce5 Clarify the doc about GetFeatures.
-aec2cf02 near_lossless: fix fuzzing-detected integer overflow
-928a75de webp: Fix VP8LBitWriterClone() bug
-5173d4ee neon IsFlat
-5b081219 IsFlat: inline when possible
-381b7b54 IsFlat: use int for thresh
-6ed15ea1 fix unprobable leak in webp_sdl.c
-22bbb24e Merge "IsFlat: return int"
-8b3fb238 Merge tag 'v1.0.1'
-f435de95 IsFlat: return int
-41521aed utils.h: only define WEBP_NEED_LOG_TABLE_8BIT when needed
-9f4d4a3f neon: GetResidualCost
-0fd7514b neon: SetResidualCoeffs
-f95a996c Simpler histogram clustering.
-e85d3313 update ChangeLog (tag: v1.0.1-rc2, tag: v1.0.1)
-fa8210e4 Fix pair update in stochastic entropy merging.
-fd198f73 add codereview.settings
-825389ac README.mux: add a reference to the AnimDecoder API
-3be698c3 CMake: fix webp_js compilation
-485ff86f Fix pair update in stochastic entropy merging.
-4cd0582d CMake: fix webp_js compilation
-4cbb4caf update NEWS
-f5a5918d bump version to 1.0.1
-d61385db Speed-up: Make sure we only initialize histograms when needed.
-6752904b Speed-up: Make sure we only initialize histograms when needed.
-0c570316 update AUTHORS
-301a2dda img2webp: add help note about arguments from a file
-f0abab92 Speedups for empty histograms.
-f2dfd925 Split HistogramAdd to only have the high level logic in C.
-06b7bc7d Fix compilation on windows and clang-cl+ninja.
-b6284d82 img2webp: add help note about arguments from a file
-decf6f6b Speedups for empty histograms.
-dea3e899 Split HistogramAdd to only have the high level logic in C.
-632798ae Merge "Fix compilation on windows and clang-cl+ninja."
-dc1a9518 Merge "libwebp: Unicode command tools on Windows"
-9cf9841b libwebp: Unicode command tools on Windows
-98179495 remove some minor TODOs
-a376e7b9 Fix compilation on windows and clang-cl+ninja.
-cbf82cc0 Remove AVX2 files.
-5030e902 Merge "TIFF decoder: remove unused KINV definition"
-ac543311 Remove a few more useless #defines
-123d3306 TIFF decoder: remove unused KINV definition
-ef1094b0 Merge "- install pkg-config files during the CMake build"
-b911fbc9 libwebp: Remove duplicate GIFDisplayError in anim_util
-eee00b66 - install pkg-config files during the CMake build
-ac3ec8c9 Merge "Clean-up the common sources in dsp."
-3e13da7b Clean-up the common sources in dsp.
-5c395f1d libwebp: cmake-format all
-e7a69729 libwebp: Add extras targets in CMakeLists.txt
-e52485d6 libwebp: Rename macros in webpmux.c
-92dc0f09 clean-up MakeInputImageCopy()
-39952de2 VP8IteratorImport: add missing 'const'
-382af7a2 clean-up WebPBlendAlpha
-14d020f6 libwebp: Use ExUtilGet*() in anim_diff
-0d92ff25 libwebp: remove useless variable in gif2webp
-556cb1b4 Merge "CMake: Set WEBP_BUILD_GIF2WEBP to off"
-da26ee49 CMake: Set WEBP_BUILD_GIF2WEBP to off
-b2a867c0 cwebp: Don't premultiply during -resize if -exact
-637141bc pngdec: fix build w/libpng < 1.4.x
-bc5092b1 pngdec: set memory functions
-50d8345a Fix CMake math library.
-6aa3e8aa Fix math library on Visual Studio.
-d71df4e2 Fix math library finding in CMake.
-de08d727 cosmetics: normalize include guard comment
-009562b4 vwebp: Fix bug when Dispose then NoBlend frames
-423f2579 Fix up CMake to create targets.
-907208f9 Wait for all threads to be done in DecodeRemaining.
-4649b3c4 vwebp: Add background color display option
-78ad57a3 Fix bad glClearColor parameters
-da96d8d9 Allow for a non-initialized alpha decompressor in DoRemap.
-2563db47 fix rescaling rounding inaccuracy
-211f37ee fix endian problems in pattern copy
-5f0f5c07 Make sure partition #0 is read before VP8 data in IDecode.
-de98732b fix GetColorf() bug
-4338cd36 misc fixes in libwebpmux
-e00af13e fix signatures after a9ceda7ff1
-a9ceda7f Speed-up chunk list operations.
-2281bbf6 Merge "Better handling of bogus Huffman codes."
-39cb9aad Better handling of bogus Huffman codes.
-89cc9d37 Merge "fix read-overflow while parsing VP8X chunk"
-95fd6507 fix read-overflow while parsing VP8X chunk
-9e729fe1 Fix VP8IoTeardownHook being called twice on worker sync failure
-29fb8562 Merge "muxread,anmf: fail on multiple image chunks"
-eb82ce76 muxread,anmf: fail on multiple image chunks
-1344a2e9 fix alpha-filtering crash when image width is larger than radius
-be738c6d muxread,ChunkVerifyAndAssign: validate chunk_size
-2c70ad76 muxread,CreateInternal: fix riff size checks
-569001f1 Fix for thread race heap-use-after-free
-c56a02d9 Android.mk: use LOCAL_EXPORT_C_INCLUDES w/public libs
-15795596 CMakeLists.txt,cosmetics: normalize if() formatting
-1a44c233 Merge "cmake: add support for webpmux"
-e9569ad7 Merge "configure,*am,cosmetics: s/WANT_/BUILD_/"
-35c7de6f cmake: add support for webpmux
-0f25e61c WebpToSDL(): fix the return value in case of error
-5d8985de configure,*am,cosmetics: s/WANT_/BUILD_/
-895fd28f Merge "man/Makefile.am: add img2webp.1"
-5cf3e2af man/Makefile.am: add img2webp.1
-2a9de5b9 Add build rules for anim_diff & anim_dump utils.
-71ed73cf fix invalid check for buffer size
-af0e4fbb gif2webp: fix transcode of loop count=65535
-dce5d764 Limit memory allocation when reading invalid Huffman codes.
-f9df0081 Merge "cmake: quiet glut deprecation warnings on OS X"
-dc39b16f webpmux.1: correct grammar
-c7aa1264 cwebp.c: fix a missing \n
-53aa51e9 Merge tag 'v1.0.0'
-698b8844 update ChangeLog (tag: v1.0.0)
-8d510751 webp-container-spec: correct frame duration=0 note
-e6b2164e vwebp: Copy Chrome's behavior w/frame duration == 0
-094b3b28 cmake: quiet glut deprecation warnings on OS X
-71c39a06 webp-container-spec: correct frame duration=0 note
-fd3d5756 vwebp: Copy Chrome's behavior w/frame duration == 0
-b0c966fb Build vwebp from CMake.
-d20b7707 update ChangeLog (tag: v1.0.0-rc3)
-0d5fad46 add WEBP_DSP_INIT / WEBP_DSP_INIT_FUNC
-d77bf512 add WEBP_DSP_INIT / WEBP_DSP_INIT_FUNC
-c1cb86af fix 16b overflow in SSE2
-e577feb7 makefile.unix: add DEBUG flag for compiling w/ debug-symbol
-99be34b3 cwebp,get_disto: fix bpp output
-e122e511 cwebp,get_disto: fix bpp output
-f5565ca8 cmake: Make sure we use near-lossless by default.
-d898dc14 fix bug in WebPImport565: alpha value was not set
-1c8f358d Fix CMake with WASM.
-a0215fb7 webp_js: fix webp_js demo html
-882784b0 update ChangeLog (tag: v1.0.0-rc2)
-2f930e08 Revert "Use proper targets for CMake."
-8165e8fb Use proper targets for CMake.
-3f157dd5 Remove some very hard TODOs.
-abb47760 Merge "Use proper targets for CMake."
-cd758a17 {de,}mux/Makefile.am: add missing headers
-e155dda0 Use proper targets for CMake.
-b892b8ba makefile.unix,dist: use ascii for text output
-64a57d05 add -version option to anim_dump,anim_diff and img2webp
-994be82d Merge "Remove some very hard TODOs."
-4033e1d7 Remove some very hard TODOs.
-fc1b8e3a webp_js: fix webp_js demo html
-15aa48d9 update ChangeLog (tag: v1.0.0-rc1)
-e607dabc update AUTHORS
-38410c08 [CFI] Remove function pointer casts
-978eec25 [CFI] Remove function pointer casts
-c57b2736 bump version to 1.0.0
-cba28853 update NEWS
-c909d531 Merge "remove some deprecation warning on MacOSX"
-217443c7 remove some deprecation warning on MacOSX
-b672bdfa configure: quiet glut deprecation warnings on OS X
-daa9fcaf configure: use sdl-config if available
-dd174cae Merge "imagedec: support metadata reading for WebP image decoding"
-641cedcc imagedec: support metadata reading for WebP image decoding
-065b2ce1 anim_diff: add a couple missing newlines in Help()
-c4cc1147 Merge "gif2webp: force low duration frames to 100ms"
-09333097 gif2webp: force low duration frames to 100ms
-e03f0ec3 sharp_yuv: use 14b fixed-point precision for gamma
-b2db361c image_enc,WebPWritePNG: move locals after setjmp
-74e82ec6 Merge "WebPPictureDistortion: fix big-endian results order"
-645d04ca Merge "cwebp,get_disto: report bpp"
-120f58c3 Merge "lossless*sse2: improve non-const 16-bit vector creation"
-a7fe9412 WebPPictureDistortion: fix big-endian results order
-e26fe066 cwebp,get_disto: report bpp
-9df64e28 Merge changes Id5b4a1a4,Ia20ce844
-8043504f lossless*sse2: improve non-const 16-bit vector creation
-1e3dfc48 Import: extract condition from loop
-3b07d327 Import,RGBA: fix for BigEndian import
-551948e4 Remove unused argument in VP8LBitsEntropy.
-3005237a ReadWebP: fix for big-endian
-499c395a Merge "anim_diff: expose the -max_diff option"
-f69dcd69 Merge "remove WEBP_EXPERIMENTAL_FEATURES"
-07d884d5 anim_diff: expose the -max_diff option
-f4dd9256 remove WEBP_EXPERIMENTAL_FEATURES
-94a8377b extract the command-line parsing helpers to example_util
-fc09e6e2 PNM decoder: prevent unsupported depth=2 PAM case.
-6de58603 MIPS64: Fix defined-but-not-used errors with WEBP_REDUCE_CSP
-cbde5728 gif2webp: add support for reading from stdin
-cf1c5054 Add an SSE4 version of some lossless color transforms.
-45a8b5eb Fix lint error with man page.
-cff38e8f Merge "PNG decoder: handle gAMA chunk"
-59cb1a48 Merge "enable dc error-diffusion always"
-78318b30 PNG decoder: handle gAMA chunk
-664c21dd Merge "remove some TODOs"
-815652de enable dc error-diffusion always
-aec45cec remove some TODOs
-5715dfce fix block-count[] increment in case of large image
-c2d04f3e enable DC error-diffusion always for multi-pass
-96bf07c5 use DC error diffusion for U/V at low-quality
-1c59020b fix missing sse41 targets in makefile.unix
-7a8e814b cosmetics: s/color_space/colorspace/
-05f6fe24 upsampling: rm asserts w/REDUCE_CSP+OMIT_C_CODE
-b4cf5597 Merge "Upsampling SSE2/SSE4 speedup."
-ccbeb32c Makefile.vc: add missing sse41 files
-55403a9a Upsampling SSE2/SSE4 speedup.
-807b53c4 Implement the upsampling/yuv functions in SSE41
-84101a81 Fix wasm WebP compilation
-8bebd2a3 fix warning on MSVC
-a7f93fe3 webpmux: allow reading argument from a file
-b69f18a7 gif2webp.1: fix -loop_compatibility layout
-72d530c0 Merge "fix lossless decoding w/WEBP_REDUCE_SIZE"
-296c7dc4 fix lossless decoding w/WEBP_REDUCE_SIZE
-0d5d029c Merge "ImgIoUtilReadFile: fix file leak upon error"
-ae568ce7 ImgIoUtilReadFile: fix file leak upon error
-796b5a8a Merge tag 'v0.6.1'
-6b7a95fd update ChangeLog (tag: v0.6.1)
-f66955de WEBP_REDUCE_CSP: restrict colorspace support
-1af0df76 Merge "WEBP_REDUCE_CSP: restrict colorspace support"
-6de20df0 WEBP_REDUCE_CSP: restrict colorspace support
-a289d8e7 update ChangeLog (tag: v0.6.1-rc2)
-c10a493c vwebp: disable double buffering on windows & mac
-0d4466c2 webp_to_sdl.c: fix file mode
-1b27bf8b WEBP_REDUCE_SIZE: disable all rescaler code
-126be109 webpinfo: add -version option
-0df22b9e WEBP_REDUCE_SIZE: disable all rescaler code
-9add62b5 bump version to 0.6.1
-d3e26144 update NEWS
-2edda639 README: add webpinfo section
-9ca568ef Merge "right-size some tables"
-31f1995c Merge "SSE2 implementation of HasAlphaXXX"
-a80c46bd SSE2 implementation of HasAlphaXXX
-083507f2 right-size some tables
-2e5785b2 anim_utils.c: remove warning when !defined(WEBP_HAVE_GIF)
-b299c47e add WEBP_REDUCE_SIZE
-f593d71a enc: disable pic->stats/extra_info w/WEBP_DISABLE_STATS
-541179a9 Merge "predictor_enc: fix build w/--disable-near-lossless"
-5755a7ec predictor_enc: fix build w/--disable-near-lossless
-eab5bab7 add WEBP_DISABLE_STATS
-8052c585 remove some petty TODOs from vwebp.
-c245343d move LOAD8x4 and STORE8x2 closer to their use location
-b9e734fd dec,cosmetics: normalize function naming style
-c188d546 dec: harmonize function suffixes
-28c5ac81 dec_sse41: harmonize function suffixes
-e65b72a3 Merge "introduce WebPHasAlpha8b and WebPHasAlpha32b"
-b94cee98 dec_sse2: remove HE8uv_SSE2
-44a0ee3f introduce WebPHasAlpha8b and WebPHasAlpha32b
-aebf59ac Merge "WebPPictureAllocARGB: align argb allocation"
-c184665e WebPPictureAllocARGB: align argb allocation
-3daf7509 WebPParseHeaders: remove obsolete animation TODO
-80285d97 cmake: avoid security warnings under msvc
-650eac55 cmake: don't set -Wall with MSVC
-c462cd00 Remove useless code.
-01a98217 Merge "remove WebPWorkerImpl declaration from the header"
-3c49fc47 Merge "thread_utils: fix potentially bad call to Execute"
-fde2782e thread_utils: fix potentially bad call to Execute
-2a270c1d remove WebPWorkerImpl declaration from the header
-f1f437cc remove mention of 'lossy-only parameters' from the doc
-3879074d Merge "WebPMemToUint32: remove ptr cast to int"
-04b029d2 WebPMemToUint32: remove ptr cast to int
-b7971d0e dsp: avoid defining _C functions w/NEON builds
-6ba98764 webpdec: correct alloc size check w/use_argb
-5cfb3b0f normalize include guards
-f433205e Merge changes Ia17c7dfc,I75423abb,Ia2f716b4,I161caa14,I4210081a, ...
-8d033b14 {dec,enc}_neon: harmonize function suffixes x2
-0295e981 upsampling_neon: harmonize function suffixes
-d572c4e5 yuv_neon: harmonize function suffixes
-ab9c2500 rescaler_neon: harmonize function suffixes
-93e0ce27 lossless_neon: harmonize function suffixes
-22fbc50e lossless_enc_neon: harmonize function suffixes
-447875b4 filters_neon,cosmetics: fix indent
-e51bdd43 remove unused VP8TokenToStats() function
-785da7ea enc_neon: harmonize function suffixes
-bc1a251f dec_neon: harmonize function suffixes
-61e535f1 dsp/lossless: workaround gcc-4.8 bug on arm
-68b2eab7 cwebp: fix alpha reporting w/lossless & metadata
-30042faa WebPDemuxGetI: add doc details around WebPFormatFeature
-0a17f471 Merge "WIP: list includes as descendants of the project dir"
-a4399721 WIP: list includes as descendants of the project dir
-08275708 Merge "Make sure we reach the full range for alpha blending."
-d361a6a7 yuv_sse2: harmonize function suffixes
-6921aa6f upsampling_sse2: harmonize function suffixes
-08c67d3e ssim_sse2: harmonize function suffixes
-582a1b57 rescaler_sse2: harmonize function suffixes
-2c1b18ba lossless_sse2: harmonize function suffixes
-0ac46e81 lossless_enc_sse2: harmonize function suffixes
-bc634d57 enc_sse2: harmonize function suffixes
-bcb7347c dec_sse2: harmonize function suffixes
-e14ad93c Make sure we reach the full range for alpha blending.
-7038ca8d demux,StoreFrame: restore hdr size check to min req
-fb3daad6 cpu: fix ssse3 check
-be590e06 Merge "Fix CMake redefinition for HAVE_CPU_FEATURES_H"
-35f736e1 Fix CMake redefinition for HAVE_CPU_FEATURES_H
-a5216efc Fix integer overflow warning.
-a9c8916b decode.h,WebPIDecGetRGB: clarify output ptr validity
-3c74c645 gif2webp: handle 1-frame case properly + fix anim_diff
-c7f295d3 Merge "gif2webp: introduce -loop_compatibility option"
-b4e04677 gif2webp: introduce -loop_compatibility option
-f78da3de add LOCAL_CLANG_PREREQ and avoid WORK_AROUND_GCC w/3.8+
-01c426f1 define WEBP_USE_INTRINSICS w/gcc-4.9+
-8635973d use sdl-config (if available) to determine the link flags
-e9459382 use CPPFLAGS before CFLAGS
-4a9d788e Merge "Android.mk,mips: fix clang build with r15"
-4fbdc9fb Android.mk,mips: fix clang build with r15
-a80fcc4a ifdef code not used by Chrome/Android.
-3993af12 Fix signed integer overflows.
-f66f94ef anim_dump: small tool to dump frames from animated WebP
-6eba857b Merge "rationalize the Makefile.am"
-c5e34fba function definition cleanup
-3822762a rationalize the Makefile.am
-501ef6e4 configure style fix: animdiff -> anim_diff
-f8bdc268 Merge "protect against NULL dump_folder[] value in ReadAnimatedImage()"
-23bfc652 protect against NULL dump_folder[] value in ReadAnimatedImage()
-8dc3d71b cosmetics,ReadAnimatedWebP: correct function comment
-5bd40066 Merge changes I66a64a0a,I4d2e520f
-7945575c cosmetics,webpinfo: remove an else after a return
-8729fa11 cosmetics,cwebp: remove an else after a return
-f324b7f9 cosmetics: normalize fn proto & decl param names
-869eb369 CMake cleanups.
-289e62a3 Remove declaration of unimplemented VP8ApplyNearLosslessPredict
-20a94186 pnmdec,PAM: validate depth before calculating bytes_per_px
-34130afe anim_encode: fix integer overflow
-42c79aa6 Merge "Encoder: harmonize function suffixes"
-b09307dc Encoder: harmonize function suffixes
-bed0456d Merge "SSIM: harmonize the function suffix"
-54f6a3cf lossless_sse2.c: fix some missed suffix changes
-088f1dcc SSIM: harmonize the function suffix
-86fc4dd9 webpdec: use ImgIoUtilCheckSizeArgumentsOverflow
-08ea9ecd imageio: add ability restrict max image size
-6f9daa4a jpegdec,ReadError: fix leaks on error
-a0f72a4f VP8LTransformColorFunc: drop an non-respected 'const' from the signature.
-8c934902 Merge "Lossess dec: harmonize the function suffixes"
-622242aa Lossess dec: harmonize the function suffixes
-1411f027 Lossless Enc: harmonize the function suffixes
-24ad2e3c add const to two variables
-46efe062 Merge "Allow the lossless cruncher to work for alpha."
-8c3f9a47 Speed-up LZ77.
-1aef4c71 Allow the lossless cruncher to work for alpha.
-b8821dbd Improve the box LZ77 speed.
-7beed280 add missing ()s to macro parameters
-6473d20b Merge "fix Android standalone toolchain build"
-dcefed95 Merge "build.gradle: fix arm64 build"
-0c83a8bc Merge "yuv: harmonize suffix naming"
-c6d1db4b fix Android standalone toolchain build
-663a6d9d unify the ALTERNATE_CODE flag usage
-73ea9f27 yuv: harmonize suffix naming
-c71b68ac build.gradle: fix arm64 build
-c4568b47 Rescaler: harmonize the suffix naming
-6cb13b05 Merge "alpha_processing: harmonize the naming suffixes to be _C()"
-83a3e69a Merge "simplify WEBP_EXTERN macro"
-7295fde2 Merge "filters: harmonize the suffixes naming to _SSE2(), _C(), etc."
-8e42ba4c simplify WEBP_EXTERN macro
-331ab34b cost*.c: harmonize the suffix namings
-b161f670 filters: harmonize the suffixes naming to _SSE2(), _C(), etc.
-dec5e4d3 alpha_processing: harmonize the naming suffixes to be _C()
-6878d427 fix memory leak in SDL_Init()
-461ae555 Merge "configure: fix warnings in sdl check"
-62486a22 configure: test for -Wundef
-92982609 dsp.h: fix -Wundef w/__mips_dsp_rev
-0265cede configure: fix warnings in sdl check
-88c73d8a backward_references_enc.h: fix WINDOW_SIZE_BITS check
-4ea49f6b rescaler_sse2.c: fix WEBP_RESCALER_FIX -> _RFIX typo
-1b526638 Clean-up some CMake
-87f57a4b Merge "cmake: fix gif lib detection when cross compiling"
-b34a9db1 cosmetics,dec_sse2: remove some redundant comments
-471c5755 cmake: fix gif lib detection when cross compiling
-c793417a cmake: disable gif2webp if gif lib isn't found
-dcbc1c88 cmake: split gif detection from IMG deps
-66ad84f0 Merge "muxread: remove unreachable code"
-50ec3ab7 muxread: remove unreachable code
-7d67a164 Lossy encoding: smoothen transparent areas to improve compression
-e50650c7 Merge "fix signature for DISABLE_TOKEN_BUFFER compilation"
-671d2567 fix signature for DISABLE_TOKEN_BUFFER compilation
-d6755580 cpu.cmake: use unique flag to test simd disable flags
-28914528 Merge "Remove the argb* files."
-8acb4942 Remove the argb* files.
-3b62347b README: correct cmake invocation note
-7ca0df13 Have the SSE2 version of PackARGB use common code.
-7b250459 Merge "Re-use the transformed image when trying several LZ77 in lossless."
-e132072f Re-use the transformed image when trying several LZ77 in lossless.
-5d7a50ef Get code to compile in C++.
-7b012987 configure: test for -Wparentheses-equality
-f0569adb Fix man pages for multi-threading.
-f1d5a397 multithread cruncher: only copy stats when picture->stats != NULL
-f8c2ac15 Multi-thread the lossless cruncher.
-a88c6522 Merge "Integrate a new LZ77 looking for matches in the neighborhood of a pixel only."
-8f6df1d0 Unroll Predictors 10, 11 and 12.
-355c3d1b Integrate a new LZ77 looking for matches in the neighborhood of a pixel only.
-a1779a01 Refactor LZ77 handling in preparation for a new method.
-67de68b5 Android.mk/build.gradle: fix mips build with clang from r14b
-f209a548 Use the plane code and not the distance when computing statistics.
-b903b80c Split cost-based backward references in its own file.
-498cad34 Cosmetic changes in backward reference.
-e4eb4587 lossless, VP8LTransformColor_C: make sure no overflow happens with colors.
-af6deaff webpinfo: handle alpha flag mismatch
-7caef29b Fix typo that creeped in.
-39e19f92 Merge "near lossless: fix unsigned int overflow warnings."
-9bbc0891 near lossless: fix unsigned int overflow warnings.
-e1118d62 Merge "cosmetics,FindClosestDiscretized: use uint in mask creation"
-186bc9b7 Merge "webpinfo: tolerate ALPH+VP8L"
-b5887297 cosmetics,FindClosestDiscretized: use uint in mask creation
-f1784aee near_lossless,FindClosestDiscretized: use unsigned ops
-0d20abb3 webpinfo: tolerate ALPH+VP8L
-972104b3 webpmux: tolerate false positive Alpha flag
-dd7e83cc tiffdec,ReadTIFF: ensure data_size is < tsize_t max
-d988eb7b tiffdec,MyRead: quiet -Wshorten-64-to-32 warning
-dabda707 webpinfo: add support to parse Alpha bitstream
-4c117643 webpinfo: correct background color output, BGRA->ARGB
-defc98d7 Doc: clarify the role of quality in WebPConfig.
-d78ff780 Merge "Fix code to compile with C++."
-c8f14093 Fix code to compile with C++.
-497dc6a7 pnmdec: sanitize invalid header output
-d78e5867 Merge "configure: test for -Wconstant-conversion"
-481e91eb Merge "pnmdec,PAM: set bytes_per_px based on depth when missing"
-93b12753 configure: test for -Wconstant-conversion
-645f0c53 pnmdec,PAM: set bytes_per_px based on depth when missing
-e9154605 Merge "vwebp: activate GLUT double-buffering"
-818d795b vwebp: activate GLUT double-buffering
-d63e6f4b Add a man page for webpinfo
-4d708435 Merge "NEON: implement ConvertRGB24ToY/BGR24/ARGB/RGBA32ToUV/ARGBToUV"
-faf42213 NEON: implement ConvertRGB24ToY/BGR24/ARGB/RGBA32ToUV/ARGBToUV
-b4d576fa Install man pages with CMake.
-cbc1b921 webpinfo: add features to parse bitstream header
-e644c556 Fix bad bit writer initialization.
-b62cdad2 Merge "Implement a cruncher for lossless at method 6."
-da3e4dfb use the exact constant for the gamma transfer function
-a9c701e0 Merge "tiffdec: fix EXTRASAMPLES check"
-adab8ce0 Implement a cruncher for lossless at method 6.
-1b92b237 Merge "Fix VP8ApplyNearLossless to respect const and stride."
-1923ff02 tiffdec: fix EXTRASAMPLES check
-97cce5ba tiffdec: only request EXTRASAMPLES w/> 3 samples/px
-0dcd85b6 Fix VP8ApplyNearLossless to respect const and stride.
-f7682189 yuv: rationalize the C/SSE2 function naming
-52245424 NEON implementation of some Sharp-YUV420 functions
-690efd82 Avoid several backward reference copies.
-4bb1f607 src/dec/vp8_dec.h, cosmetics: fix comments
-285748be cmake: build/install webpinfo
-78fd199c backward_references_enc.c: clear -Wshadow warnings
-ae836410 WebPLog2FloorC: clear -Wshadow warning
-d0b7404e Merge "WASM support"
-134e314f WASM support
-c08adb6f Merge "VP8LEnc: remove use of BitsLog2Ceiling()"
-28c37ebd VP8LEnc: remove use of BitsLog2Ceiling()
-2cb58ab2 webpinfo: output format as a human readable string
-bb175a93 Merge "rename some symbols clashing with MSVC headers"
-39eda658 Remove a duplicated pixel hash implementation.
-36b8274d rename some symbols clashing with MSVC headers
-274daf54 Add webpinfo tool.
-ec5036e4 add explicit reference to /usr/local/{lib,inc}
-18f0dfac Merge "fix TIFF encoder regarding rgbA/RGBA"
-4e2b0b50 Merge "webpdec.h: fix a doc typo"
-e2eeabff Merge "Install binaries, libraries and headers in CMake."
-836607e6 webpdec.h: fix a doc typo
-9273e441 fix TIFF encoder regarding rgbA/RGBA
-17e3c11f Add limited PAM decoding support
-5f624871 Install binaries, libraries and headers in CMake.
-976adac1 Merge "lossless incremental decoding: fix missing eos_ test"
-f8fad4fa lossless incremental decoding: fix missing eos_ test
-27415d41 Merge "vwebp_sdl: fix the makefile.unix"
-49566182 Merge "ImgIoUtilWriteFile(): use ImgIoUtilSetBinaryMode"
-6f75a51b Analyze the transform entropy on the whole image.
-a5e4e3af Use palette only if we can in entropy analysis.
-75a9c3c4 Improve compression by better entropy analysis.
-39cf6f4f vwebp_sdl: fix the makefile.unix
-699b0416 ImgIoUtilWriteFile(): use ImgIoUtilSetBinaryMode
-7d985bd1 Fix small entropy analysis bug.
-6e7caf06 Optimize the color cache size.
-833c9219 More efficient stochastic histogram merge.
-5183326b Refactor the greedy histogram merge.
-99f6f462 Merge "histogram_enc.c,MyRand: s/ul/u/ for unsigned constants"
-80a22186 ssim.c: remove dead include
-a128dfff histogram_enc.c,MyRand: s/ul/u/ for unsigned constants
-693bf74e move the SSIM calculation code in ssim.c / ssim_sse2.c
-10d791ca Merge "Fix the random generator in HistogramCombineStochastic."
-fa63a966 Fix the random generator in HistogramCombineStochastic.
-16be192f VP8LSetBitPos: remove the eos_ setting
-027151ca don't erase the surface before blitting.
-4105d565 disable WEBP_USE_XXX optimisations when EMSCRIPTEN is defined
-9ee32a75 Merge "WebP-JS: emscripten-based Javascript decoder"
-ca9f7b7d WebP-JS: emscripten-based Javascript decoder
-868aa690 Perform greedy histogram merge in a unified way.
-5b393f2d Merge "fix path typo for vwebp_sdl in Makefile.vc"
-e0012bea CMake: only use libwebpdecoder for building dwebp
-84c2a7b0 fix path typo for vwebp_sdl in Makefile.vc
-1b0e4abf Merge "Add a flag to disable SIMD optimizations."
-32263250 Add a flag to disable SIMD optimizations.
-b494fdec optimize the ARGB->ARGB Import to use memcpy
-f1536039 Merge "ReadWebP: decode directly into a pre-allocated buffer"
-e69ed291 ReadWebP: decode directly into a pre-allocated buffer
-57d8de8a Merge "vwebp_sdl: simple viewer based on SDL"
-5cfd4ebc LZ77 interval speedups. Faster, smaller, simpler.
-1e7ad88b PNM header decoder: add some basic numerical validation
-17c7890c Merge "Add a decoder only library for WebP in CMake."
-be733786 Merge "Add clang build fix for MSA"
-03cda0e4 Add a decoder only library for WebP in CMake.
-aa893914 Add clang build fix for MSA
-31a92e97 Merge "imageio: add limited PNM support for reading"
-dcf9d82a imageio: add limited PNM support for reading
-6524fcd6 vwebp_sdl: simple viewer based on SDL
-6cf24a24 get_disto: fix reference file read
-43d472aa Merge tag 'v0.6.0'
-50d1a848 update ChangeLog (tag: v0.6.0, origin/0.6.0)
-20a7fea0 extras/Makefile.am: fix libwebpextras.la reference
-415f3ffe update ChangeLog (tag: v0.6.0-rc3)
-3c6d1224 update NEWS
-ee4a4141 update AUTHORS
-32ed856f Fix "all|no frames are keyframes" settings.
-1c3190b6 Merge "Fix "all|no frames are keyframes" settings."
-f4dc56fd disable GradientUnfilter_NEON
-4f3e3bbd disable GradientUnfilter_NEON
-2dc0bdca Fix "all|no frames are keyframes" settings.
-0d8e0588 img2webp: treat -loop as a no-op w/single images
-b0450139 ReadImage(): restore size reporting
-0ad3b4ef update ChangeLog (tag: v0.6.0-rc2)
-6451709e img2webp,get_disto: fix image decode w/WIC builds
-92504d21 get_disto: make ReadPicture() return a bool
-c3e4b3a9 update NEWS
-3363eb6d man/img2webp.1: fix formatting warning
-4d1312f2 update NEWS
-36c42ea4 bump version to 0.6.0
-bb498a51 update AUTHORS
-84cef16f Makefile.vc: fix CFG=debug-dynamic build
-919f9e2f Merge "add .rc files for windows dll versioning"
-f1ae8af4 Merge ".gitignore: add img2webp"
-4689ce16 cwebp: add a -sharp_yuv option for 'sharp' RGB->YUV conversion
-79bf46f1 rename the pretentious SmartYUV into SharpYUV
-eb1dc89a silently expose use_delta_palette in the WebPConfig API
-c85b0dde .gitignore: add img2webp
-43d3f01a add .rc files for windows dll versioning
-668e1dd4 src/{dec,enc,utils}: give filenames a unique suffix
-0e6b7f33 Merge "iosbuild.sh: only add required headers to framework"
-29ed6f9a iosbuild.sh: only add required headers to framework
-71c53f1a NEON: speed-up strong filtering
-73f567ea Merge "get_disto: remove redundant reader check"
-9e14276f Merge "makefiles: prune get_disto & webp_quality deps"
-99965bac Merge "Makefile.vc: add get_disto.exe, webp_quality.exe"
-d4912238 get_disto: remove redundant reader check
-ea482409 makefiles: prune get_disto & webp_quality deps
-2ede5a19 Makefile.vc: add get_disto.exe, webp_quality.exe
-a345068a ARM: speed up bitreader by avoiding tables
-1dc82a6b Merge "introduce a generic GetCoeffs() function pointer"
-8074b89e introduce a generic GetCoeffs() function pointer
-749a45a5 Merge "NEON: implement alpha-filters (horizontal/vertical/gradient)"
-74c053b5 Merge "NEON: fix overflow in SSE NxN calculation"
-0a3aeff7 Merge "dsp: WebPExtractGreen function for alpha decompression"
-1de931c6 NEON: implement alpha-filters (horizontal/vertical/gradient)
-9b3aca40 NEON: fix overflow in SSE NxN calculation
-1c07a3c6 dsp: WebPExtractGreen function for alpha decompression
-9ed5e3e5 use pointers for WebPRescaler's in WebPDecParams
-db013a8d Merge "ARM: don't use USE_GENERIC_TREE"
-fcd4784d use a 8b table for C-version for clz()
-fbb5c473 ARM: don't use USE_GENERIC_TREE
-8fda5612 Merge "add a kSlowSSSE3 feature for CPUInfo"
-86bbd245 add a kSlowSSSE3 feature for CPUInfo
-7c2779e9 Get code to fully compile in C++.
-250c3586 Merge "When compiling as C++, avoid narrowing warnings."
-c0648ac2 When compiling as C++, avoid narrowing warnings.
-0d55f60c 40% faster ApplyAlphaMultiply_SSE2
-49d0280d NEON: implement several alpha-processing functions
-48b1e85f SSE2: 15% faster alpha-processing functions
-e3b8abbc fix warning from static analysis.
-28fe054e SSE2: 30% faster ApplyAlphaMultiply()
-f44acd25 Merge "Properly compute the optimal color cache size."
-527844fe Properly compute the optimal color cache size.
-be0ef639 fix a comment typo
-8874b162 Fix a non-deterministic color cache size computation.
-d712e20d Do not allow a color cache size bigger than the number of colors.
-ecff04f6 re-introduce some comments in Huffman Cost.
-259e9828 replace 'ptr + y * stride' by 'ptr += stride'
-00b08c88 Merge "NEON: 5% faster conversion to RGB565 and RGBA4444"
-0e7f4447 Merge "NEON: faster fancy upsampling"
-b016cb91 NEON: faster fancy upsampling
-1cb63801 Call the C function to finish off lossless SSE loops only when necessary.
-875fafc1 Implement BundleColorMap in SSE2.
-3674d49e Merge "remove Clang warnings with unused arch arguments."
-f04eb376 Merge tag 'v0.5.2'
-341d711c NEON: 5% faster conversion to RGB565 and RGBA4444
-abb54827 remove Clang warnings with unused arch arguments.
-ece9684f update ChangeLog (tag: v0.5.2-rc2, tag: v0.5.2, origin/0.5.2)
-aa7744ca anim_util: quiet implicit conv warnings in 32-bit
-d9120271 jpegdec: correct ContextFill signature
-24eb3940 Remove some errors when compiling the code as C++.
-a4a8e5f3 vwebp: clear canvas during resize w/o animation
-67c25ad5 vwebp: clear canvas during resize w/o animation
-a4bbe4b3 fix indentation
-31ca2a80 tiffdec: restore libtiff 3.9.x compatibility
-b2f77b57 update NEWS
-5ab6d9de AnimEncoder: avoid freeing uninitialized memory pointer.
-f29bf582 WebPAnimEncoder: If 'minimize_size' and 'allow_mixed' on, try lossy + lossless.
-3ebe1c00 AnimEncoder: avoid freeing uninitialized memory pointer.
-df780e0e fix a potential overflow with MALLOC_LIMIT
-58fc5078 Merge "PredictorSub: implement fully-SSE2 version"
-9cc42167 PredictorSub: implement fully-SSE2 version
-0aa1f35c remove dependency of imageio/ to stopwatch.h
-cb9ec84b Merge "remove the dependency to stop_watch.[ch] in imageio"
-dc0c01fb Merge "anim_util: quiet implicit conv warnings in 32-bit"
-827d3c50 Merge "fix a potential overflow with MALLOC_LIMIT"
-1e2e25b0 anim_util: quiet implicit conv warnings in 32-bit
-218460cd bump version to 0.5.2
-de7d654d update AUTHORS & .mailmap
-273367c1 Merge "dsp/lossless.c,cosmetics: fix indent"
-76bbcf2e fix a potential overflow with MALLOC_LIMIT
-8ac1abfe Merge "jpegdec: correct ContextFill signature"
-cb215aed remove the dependency to stop_watch.[ch] in imageio
-2423017a dsp/lossless.c,cosmetics: fix indent
-74a12b10 iosbuild.sh: add WebPDecoder.framework + encoder
-a9cc7621 Merge "iosbuild.sh: add WebPDecoder.framework + encoder"
-fbba5bc2 optimize predictor #1 in plain-C For some reason, gcc has hard time inlining this one...
-9ae0b3f6 Merge "SSE2: slightly (~2%) faster Predictor #1"
-c1f97bd7 SSE2: slightly (~2%) faster Predictor #1
-ea664b89 SSE2: 10% faster Predictor #11
-be7dcc08 AnimEncoder: Correctly skip a frame when sub-rectangle is empty.
-40885830 Fix assertions in WebPRescalerExportRow()
-1d5046d1 iosbuild.sh: add WebPDecoder.framework + encoder
-cec72014 jpegdec: correct ContextFill signature
-8f38c72e fix a typo in WebPPictureYUVAToARGB's doc
-33ca93f9 systematically call WebPDemuxReleaseIterator() on dec->prev_iter_
-76e19073 doc: use two's complement explicitly for uint8->int8 conversion
-f91ba963 Anim_encoder: correctly handle enc->prev_candidate_undecided_
-25d74e65 WebPPictureDistortion(): free() -> WebPSafeFree()
-03f1c008 mux/Makefile.am: add missing -lm
-58410cd6 fix bug in RefineUsingDistortion()
-e168af8c fix filtering auto-adjustment
-ed9dec41 fix doc and code snippet for WebPINewDecoder() doc
-3c49178f prevent 32b overflow for very large canvas_width / height
-9595f290 fix anim_util.c compilation when HAVE_GIF is not defined.
-7ec9552c Make gif transparent color to be transparent black
-b3fb8bb6 slightly faster Predictor #11 in NEON
-9871335f Add a CMake option for WEBP_SWAP_16BIT_CSP.
-0ae32226 Fix missing cpu-features for Android.
-ab4c8056 cpu.cmake: improve webp_check_compiler_flag output
-eec5fa3a Provide support for CMake on Android studio 2.2.
-004d5690 Split the main CMake file.
-4fe5d588 Android.mk: use -fvisibility=hidden
-bd63a31a vwebp: ensure setenv() is available in stdlib.h
-363a5681 vwebp: handle window resizing properly
-a0d2753f lower WEBP_MAX_ALLOCABLE_MEMORY default
-31fe11a5 fix infinite loop in case of PARTITION0 overflow
-532215dd Change the rule of picking UV mode in MBAnalyzeBestUVMode()
-9c75dbd3 cwebp.1: improve some grammar
-af2e05cb vwebp: Clear previous frame when a key triggers a redraw
-26ffa296 Add descriptions of default configuration in help info.
-7416280d Fix an unsigned integer overflow error in enc/cost.h
-13cf1d2e Do token recording and counting in a single loop
-eb9a4b97 Reset segment id if we decide not to update segment map
-42ebe3b7 configure: fix NEON flag detection under gcc 6
-76ebbfff NEON: implement predictor #13
-95b12a08 Merge "Revert Average3 and Average4"
-54ab2e75 Revert Average3 and Average4
-fe12330c 3-5% faster Predictor #5, #6, #7 and #10 for NEON
-fbfb3bef ~2% faster predictor #10 for NEON
-d4b7d801 lossless_sse2: use the local functions
-a5e3b225 Lossless decoder SSE2 improvements.
-58a1f124 ~2% faster predictor #12 in NEON.
-906c3b63 Merge "Implement lossless transforms in NEON."
-d23abe4e Implement lossless transforms in NEON.
-2e6cb6f3 Give more flexibility to the predictor generating macro.
-28e0bb70 Merge "Fix race condition in multi-threading initialization."
-64704530 Fix race condition in multi-threading initialization.
-bded7848 img2webp: fix default -lossless value and use pic.argb=1
-0e61a513 Merge "img2webp: convert a sequence of images to an animated webp"
-1cc79e92 AnimEncoder: Correctly skip a frame when sub-rectangle is empty.
-03f40955 img2webp: convert a sequence of images to an animated webp
-ea72cd60 add missing 'extern' keyword for predictor dcl
-67879e6d SSE implementation of decoding predictors.
-34aee990 Merge "vwebp: make 'd' key toggle the debugging of fragments"
-a41296ae Fix potentially uninitialized value.
-c85adb33 vwebp: make 'd' key toggle the debugging of fragments
-4239a148 Make the lossless predictors work on a batch of pixels.
-bc18ebad fix extra 'const's in signatures
-71e2f5ca Remove memcpy in lossless decoding.
-7474d46e Do not use a register array in SSE.
-67748b41 Improve latency of FTransform2.
-16951b19 Merge "Provide an SSE implementation of ConvertBGRAToRGB"
-6540cd0e Provide an SSE implementation of ConvertBGRAToRGB
-de568abf Android.mk: use -fvisibility=hidden
-3c2a61b0 remove some unneeded casts
-9ac063c3 add dsp functions for SmartYUV
-22efabdd Merge "smart_yuv: switch to planar instead of packed r/g/b processing"
-1d6e7bf3 smart_yuv: switch to planar instead of packed r/g/b processing
-0a3838ca fix bug in RefineUsingDistortion()
-c0699515 webpmux -duration: set default 'end' value equal to 'start'
-83cbfa09 Import: use relative pointer offsets
-a1ade40e PreprocessARGB: use relative pointer offsets
-fd4d090f ConvertWRGBToYUV: use relative pointer offsets
-9daad459 ImportYUVAFromRGBA: use relative pointer offsets
-f90c60d1 Merge "add a "-duration duration,start,end" option to webpmux"
-3f182d36 add a "-duration duration,start,end" option to webpmux
-342e15f0 Import: use relative pointer offsets
-1147ab4e PreprocessARGB: use relative pointer offsets
-e4cd4daf fix filtering auto-adjustment
-e7152856 fix doc and code snippet for WebPINewDecoder() doc
-de9fa507 ConvertWRGBToYUV: use relative pointer offsets
-deb1b831 ImportYUVAFromRGBA: use relative pointer offsets
-c284780f imageio_util: add ImgIoUtilCheckSizeArgumentsOverflow
-e375080d gifdec,Remap: avoid out of bounds colormap read
-c222a053 additional fix for stride type as size_t
-bb233617 fix potential overflow when width * height * 4 >= (1<<32)
-883d41fb gif2webp: fix crash with NULL extension data
-cac9a36a gifdec,Remap: avoid out of bounds colormap read
-4595e01f Revert "gifdec,Remap: avoid out of bounds colormap read"
-fb52d443 gifdec: make some constants unsigned
-f048d38d gifdec,Remap: avoid out of bounds colormap read
-31b1e343 fix SSIM metric ... by ignoring too-dark area
-2f51b614 introduce WebPPlaneDistortion to compute plane distortion
-0104d730 configure: fix NEON flag detection under gcc 6
-265abbe9 Merge "additional fix for stride type as size_t"
-f7601aa6 Merge "Introduce a generic WebPGetImageReader(type) function"
-ce873320 Introduce a generic WebPGetImageReader(type) function
-2a2773ea imageio/*dec,Read*: add input parameter checks
-9f5c8eca additional fix for stride type as size_t
-4eb5df28 remove unused stride fields from VP8Iterator
-11bc423a MIN_LENGTH cleanups.
-273d035a Merge "fix a typo in WebPPictureYUVAToARGB's doc"
-4db82a17 Merge "fix potential overflow when width * height * 4 >= (1<<32)"
-e2affacc fix potential overflow when width * height * 4 >= (1<<32)
-dc789ada fix a typo in WebPPictureYUVAToARGB's doc
-539f5a68 Fix non-included header in config.c.
-aaf2a6a6 systematically call WebPDemuxReleaseIterator() on dec->prev_iter_
-20ef9915 Merge "imageio_util: add ImgIoUtilCheckSizeArgumentsOverflow"
-bc86b7a8 imageio_util: add ImgIoUtilCheckSizeArgumentsOverflow
-806f6279 gif2webp: fix crash with NULL extension data
-68ae5b67 Add libwebp/src/mux/animi.h
-28ce3043 Remove some errors when compiling the code as C++.
-b34abcb8 Favor keeping the areas locally similar in spatial prediction mode selection
-ba843a92 fix some SSIM calculations
-51b71fd2 Merge "vwebp: ensure setenv() is available in stdlib.h"
-fb01743a get_disto: fix the r/g/b order for luma calculation
-bfab8947 vwebp: ensure setenv() is available in stdlib.h
-9310d192 vwebp: handle window resizing properly
-f79450ca Speedup ApplyMap.
-cfdda7c6 Merge "prevent 32b overflow for very large canvas_width / height"
-e36396ba Merge "get_disto: new option to compute SSIM map and convert to gray"
-18a9a0ab Add an API to import a color-mapped image.
-30d43706 Speed-up Combined entropy for palettized histograms.
-36aa087b get_disto: new option to compute SSIM map and convert to gray
-86a84b35 2x faster SSE2 implementation of SSIMGet
-b8384b53 lower WEBP_MAX_ALLOCABLE_MEMORY default
-1c364400 prevent 32b overflow for very large canvas_width / height
-eee0cce1 Merge "Small LZ77 speedups."
-5f1caf29 Small LZ77 speedups.
-1effde7b fix anim_util.c compilation when HAVE_GIF is not defined.
-a2fe9bf4 Speedup TrellisQuantizeBlock().
-573cce27 smartYUV improvements
-21e7537a fix infinite loop in case of PARTITION0 overflow
-053a1565 Merge "Change the rule of picking UV mode in MBAnalyzeBestUVMode()"
-1377ac2e Change the rule of picking UV mode in MBAnalyzeBestUVMode()
-7c1fb7d0 fix uint32_t initialization (0. -> 0)
-bfff0bf3 speed-up SSIM calculation
-64577de8 De-VP8L-ize GetEntropUnrefinedHelper.
-a7be7328 Merge "refactor the PSNR / SSIM calculation code"
-50c3d7da refactor the PSNR / SSIM calculation code
-d6228aed indentation fix after I7055d3ee3bd7ed5e78e94ae82cb858fa7db3ddc0
-dd538b19 Remove unused declaration.
-6cc48b17 Move some lossless logic out of dsp.
-78363e9e Merge "Remove a redundant call to InitLeft() in VP8IteratorReset()"
-ffd01929 Refactor VP8IteratorNext().
-c4f6d9c9 Remove a redundant call to InitLeft() in VP8IteratorReset()
-c27d8210 Merge "smartYUV: simplify main loop"
-07795296 smartYUV: simplify main loop
-c9b45863 Split off common lossless dsp inline functions.
-490ae5b1 smartYUV: improve initial state for faster convergence
-894232be smartYUV: fix and simplify the over-zealous stop criterion
-8de08483 Remove unused code in webpi.h
-41cab7fe imageio/Android.mk: correct imagedec dependencies
-82c91c70 Merge "libimageenc.a: extract image-saving code from dwebp"
-af1ad3e2 libimageenc.a: extract image-saving code from dwebp
-dd7309e3 Merge "doc: use two's complement explicitly for uint8->int8 conversion"
-6105777e Merge "add gif2webp to CMake"
-13ae011e doc: use two's complement explicitly for uint8->int8 conversion
-4bda0cfb add gif2webp to CMake
-6029c7fe Merge "remove mention of fragment, frgm, FRGM, etc."
-545c147f remove mention of fragment, frgm, FRGM, etc.
-5b46f7fc cwebp.1: improve some grammar
-9e478f80 dec/vp8l.c: add assertions in EmitRescaledRowsRGBA/YUVA
-43bd8958 Make gif transparent color to be transparent black
-0887fc2d Merge "get_disto: add a '-o file' option to save a diff map"
-0de48e18 get_disto: add a '-o file' option to save a diff map
-0a57ad0d cosmetics: WebPSafeAlloc -> WebPSafeMalloc
-0a4699bc Merge "WebPPictureDistortion(): free() -> WebPSafeFree()"
-29fedbf5 Anim_encoder: correctly handle enc->prev_candidate_undecided_
-32dead4e WebPPictureDistortion(): free() -> WebPSafeFree()
-85cd5d06 Smarter LZ77 for uniform regions.
-6585075f Change PixelsAreSimilar() to handle black pixels correctly.
-c0a27fd2 vwebp: Clear previous frame when a key triggers a redraw
-57a5e3b6 webp_quality should return '0' in case of success.
-7f1b897b Faster stochastic histogram merging.
-48c810b8 Merge "remove WEBP_FORCE_ALIGNED and use memcpy() instead."
-3884972e remove WEBP_FORCE_ALIGNED and use memcpy() instead.
-485cac1a switch libimagedec.a and libimageio_util.a to avoid undefined symbol
-005e15b1 Merge "{extras,mux}/Makefile.am: add missing -lm"
-6ab496ed fix some 'unsigned integer overflow' warnings in ubsan
-8a4ebc6a Revert "fix 'unsigned integer overflow' warnings in ubsan"
-9d4f209f Merge changes I25711dd5,I43188fab
-e44f5248 fix 'unsigned integer overflow' warnings in ubsan
-27b5d991 Fix assertions in WebPRescalerExportRow()
-74f6f9e7 Add descriptions of default configuration in help info.
-aaf2530c {extras,mux}/Makefile.am: add missing -lm
-1269dc7c Refactor VP8LColorCacheContains()
-40872fb2 dec_neon,NeedsHev: micro optimization
-7b54e26b Add a CMake option for WEBP_SWAP_16BIT_CSP.
-d2223d8d Fix missing cpu-features for Android.
-bf16a4b4 Merge "cpu.cmake: improve webp_check_compiler_flag output"
-ee1057e3 cpu.cmake: improve webp_check_compiler_flag output
-b551e587 cosmetics: add {}s on continued control statements
-d2e4484e dsp/Makefile.am: put msa source in correct lib
-c7f66c82 Merge "utils/thread.c,cosmetics: join a few lines"
-98d8f295 Merge "examples/Makefile.am,cosmetics: sort binary targets"
-39f4ffbc utils/thread.c,cosmetics: join a few lines
-a86ce2b1 Merge "extras/Makefile.am: don't install libwebpextras"
-6fa9fe24 extras/Makefile.am: don't install libwebpextras
-0b2c58a9 Fix an unsigned integer overflow error in enc/cost.h
-d7ce4a2e examples/Makefile.am,cosmetics: sort binary targets
-386e4ba2 Reset segment id if we decide not to update segment map
-7b87e848 Merge "Add MSA optimized YUV to RGB upsampling functions"
-d3ddacb6 Add MSA optimized YUV to RGB upsampling functions
-eb98d8d8 webp_quality: detect lossless format and features
-ebee57f4 move imageio/example_util.[hc] (back to) examples/
-99542bbf webpdec: s/ExUtil//
-da573cf4 imageio_util: s/ExUtil/ImgIoUtil/
-bdda5bd4 split example_util.h
-15ed462b .gitignore: add extras/{get_disto,webp_quality}
-7be57489 Merge "VP8EstimateQuality(): roughty estimate webp bitstream quality factor"
-57020525 Makefile.vc: add missing imageio target
-e8ab6a82 VP8EstimateQuality(): roughty estimate webp bitstream quality factor
-fee7b3d6 Merge "'extras/get_disto' example: compute PSNR between two files"
-1e7d4401 'extras/get_disto' example: compute PSNR between two files
-4cecab63 pngdec.c,jpegdec.[hc]: remove unnecessary includes
-259f0434 makefile.unix: normalize image decode lib name
-ed34c39b fix: examples/libexample_dec.a => imageio/libexample_dec.a
-33d8d0d4 Merge "move examples/{example_util,image_dec} to imageio/"
-c960b82e Merge "extras.h: correct include guard"
-fe3cd28a Merge ".gitignore: add .gradle, /build"
-45fbeba5 Merge "Do token recording and counting in a single loop"
-4f33c820 .gitignore: add .gradle, /build
-c379b55a move examples/{example_util,image_dec} to imageio/
-5108d9aa extras.h: correct include guard
-ad497fbc move src/extras to the top-level
-0c0fb832 Do token recording and counting in a single loop
-9ac74f92 Add MSA optimized rescaling functions
-cb19dbc1 Add MSA optimized color transform functions
-3f4042b5 WebPAnimEncoder: If 'minimize_size' and 'allow_mixed' on, try lossy + lossless.
-5e2eb89e cosmetics,dsp/*msa.c: associate '*' with the type
-5b60db5c FastMBAnalyze() for quick i16/i4 decision
-567e6977 Add MSA optimized CollectHistogram function
-c54ab8dd Add MSA optimized quantization functions
-ec6f68c5 Merge "Remove QuantizeBlockWHT() in enc.c"
-2a5c417c Apply the RLE heuristic to LZ77.
-91b59e88 Remove QuantizeBlockWHT() in enc.c
-fe572737 Add MSA optimized SSE functions
-6b53ca87 cosmetics,(dec|enc)_sse2.c: fix indent
-b15d00d9 Merge "Add MSA optimized encoder IntraChromaPreds function"
-afe3cec8 Add MSA optimized encoder IntraChromaPreds function
-fc8cad9f reduce the number of malloc/free cycles in huffman.c
-7b4b05e0 Add MSA optimized encoder Intra16Preds function
-c18787a0 Add MSA optimized encoder Intra4Preds function
-479d1908 webpmux: Also print compression info per frame.
-a80e8cfd Provide support for CMake on Android studio 2.2.
-6c628410 Split the main CMake file.
-bbb6ecd9 Merge "Add MSA optimized distortion functions"
-7915396f Add MSA optimized distortion functions
-652e944f Merge "build.gradle: remove tab"
-c0991a14 io,EmitRescaledAlphaYUV: factor out a common expr
-48bf5ed1 build.gradle: remove tab
-bfef6c9f Merge tag 'v0.5.1'
-3d97bb75 update ChangeLog (tag: v0.5.1, origin/0.5.1)
-deb54d91 Clarify the expected 'config' lifespan in WebPIDecode()
-435308e0 Add MSA optimized encoder transform functions
-dce64bfa Add MSA optimized alpha filter functions
-429120d0 Add MSA optimized color transform functions
-c7e2d245 update ChangeLog (tag: v0.5.1-rc5)
-55b2fede normalize the macros' "do {...} while (0)" constructs
-701c772e Add MSA optimized colorspace conversion functions
-c7eb06f7 Fix corner case in CostManagerInit.
-f918cb10 fix rescaling bug: alpha plane wasn't filled with 0xff
-ab7937a5 gif2webp: normalize the number of .'s in the help message
-3cdec847 vwebp: normalize the number of .'s in the help message
-bdf6241e cwebp: normalize the number of .'s in the help message
-06a38c7b fix rescaling bug: alpha plane wasn't filled with 0xff
-319e37be Improve lossless compression.
-6a197937 Add MSA optimized intra pred chroma functions
-447adbce 'our bug tracker' -> 'the bug tracker'
-97b9e644 normalize the number of .'s in the help message
-293d786f Added MSA optimized intra prediction 16x16 functions
-0afa0ce2 Added MSA optimized intra prediction 4x4 functions
-a6621bac Added MSA optimized simple edge filtering functions
-bb50bf42 pngdec,ReadFunc: throw an error on invalid read
-38063af1 decode.h,WebPGetInfo: normalize function comment
-1ebf193c Added MSA optimized chroma edge filtering functions
-9ad2352d Merge "Added MSA optimized edge filtering functions"
-60751096 Added MSA optimized edge filtering functions
-9e8e1b7b Inline GetResidual for speed.
-7d58d1b7 Speed-up uniform-region processing.
-8ec7032b simplify HistogramCombineEntropyBin()
-23e29cb1 Merge "Fix a boundary case in BackwardReferencesHashChainDistanceOnly." into 0.5.1
-472a049b remove bin_map[] allocation altogether
-0bb23b2c free -> WebPSafeFree()
-a977b4b5 Merge "rewrite the bin_map clustering to use less memory"
-3591ba66 rewrite the bin_map clustering to use less memory
-e6ac450c utils.[hc]: s/MAX_COLOR_COUNT/MAX_PALETTE_SIZE/
-e7b91772 Merge "DecodeImageData(): change the incorrect assert" into 0.5.1
-2abfa54f DecodeImageData(): change the incorrect assert
-5a48fcd8 Merge "configure: test for -Wfloat-conversion"
-0174d18d Fix a boundary case in BackwardReferencesHashChainDistanceOnly.
-6a9c262a Merge "Added MSA optimized transform functions"
-cfbcc5ec Make sure to consider small distances in LZ77.
-5e60c42a Added MSA optimized transform functions
-3dc28d76 configure: test for -Wfloat-conversion
-f2a0946a add some asserts to delimit the perimeter of CostManager's operation
-9a583c66 fix invalid-write bug for alpha-decoding
-f66512db make gradlew executable
-6fda58f1 backward_references: quiet double->int warning
-a48cc9d2 Merge "Fix a compression regression for images with long uniform regions." into 0.5.1
-cc2720c1 Merge "Revert an LZ77 boundary constant." into 0.5.1
-059aab4f Fix a compression regression for images with long uniform regions.
-b0c7e49e Check more backward matches with higher quality.
-a3611513 Revert an LZ77 boundary constant.
-8190374c README: fix typo
-7551db44 update NEWS
-0fb2269c bump version to 0.5.1
-f4537610 update AUTHORS & .mailmap
-3259571e Refactor GetColorPalette method.
-1df5e260 avoid using tmp histogram in PreparePair()
-7685123a fix comment typos
-a246b921 Speedup backward references.
-76d73f18 Merge "CostManager: introduce a free-list of ~10 intervals"
-eab39d81 CostManager: introduce a free-list of ~10 intervals
-4c59aac0 Merge "mips msa webp configuration"
-043c33f1 Merge "Improve speed and compression in backward reference for lossless."
-71be9b8c Merge "clarify variable names in HistogramRemap()"
-0ba7fd70 Improve speed and compression in backward reference for lossless.
-0481d42a CostManager: cache one interval and re-use it when possible
-41b7e6b5 Merge "histogram: fix bin calculation"
-96c3d624 histogram: fix bin calculation
-fe9e31ef clarify variable names in HistogramRemap()
-ce3c8247 disable near-lossless quantization if palette is used
-e11da081 mips msa webp configuration
-5f8f998d mux: Presence of unknown chunks should trigger VP8X chunk output.
-cadec0b1 Merge "Sync mips32 and dsp_r2 YUV->RGB code with C verison"
-d9637758 Compute the hash chain once and for all for lossless compression.
-50a48665 Sync mips32 and dsp_r2 YUV->RGB code with C verison
-eee788e2 Merge "introduce a common signature for all image reader function"
-d77b877c introduce a common signature for all image reader function
-ca8d9519 remove some obsolete TODOs
-ae2a7222 collect all decoding utilities from examples/ in libexampledec.a
-0b8ae852 Merge "Move DitherCombine8x8 to dsp/dec.c"
-77cad885 Merge "ReadWebP: avoid conversion to ARGB if final format is YUVA"
-ab8d6698 ReadWebP: avoid conversion to ARGB if final format is YUVA
-f8b7ce9e Merge "test pointer to NULL explicitly"
-5df6f214 test pointer to NULL explicitly
-77f21c9c Move DitherCombine8x8 to dsp/dec.c
-c9e6d865 Add gradle support
-c65f41e8 Revert "Add gradle support"
-bf731ede Add gradle support
-08333b85 WebPAnimEncoder: Detect when canvas is modified, restore only when needed.
-0209d7e6 Merge "speed-up MapToPalette() with binary search"
-fdd29a3d speed-up MapToPalette() with binary search
-cf4a651b Revert "Refactor GetColorPalette method."
-0a27aca3 Merge changes Idfa8ce83,I19adc9c4
-f25c4406 WebPAnimEncoder: Restore original canvas between multiple encodes.
-169004b1 Refactor GetColorPalette method.
-576362ab VP8LDoFillBitWindow: support big-endian in fast path
-ac49e4e4 bit_reader.c: s/VP8L_USE_UNALIGNED_LOAD/VP8L_USE_FAST_LOAD/
-d39ceb58 VP8LDoFillBitWindow: remove stale TODO
-2ec2de14 Merge "Speed-up BackwardReferencesHashChainDistanceOnly."
-3e023c17 Speed-up BackwardReferencesHashChainDistanceOnly.
-f2e1efbe Improve near lossless compression when a prediction filter is used.
-e15afbce dsp.h: fix ubsan macro name
-e53c9ccb dsp.h: add WEBP_UBSAN_IGNORE_UNSIGNED_OVERFLOW
-af81fdb7 utils.h: quiet -fsanitize=undefined warnings
-ea0be354 dsp.h: remove utils.h include
-cd276aec utils/*.c: ../utils/utils.h -> ./utils.h
-c8927131 utils/Makefile.am: add some missing headers
-ea24e026 Merge "dsp.h: add WEBP_UBSAN_IGNORE_UNDEF"
-369e264e dsp.h: add WEBP_UBSAN_IGNORE_UNDEF
-0d020a78 Merge "add runtime NEON detection"
-5ee2136a Merge "add VP8LAddPixels() to lossless.h"
-47435a61 add VP8LAddPixels() to lossless.h
-8fa6ac68 remove two ubsan warnings
-74fb56fb add runtime NEON detection
-4154a839 MIPS update to new Unfilter API
-c80b9fc8 Merge "cherry-pick decoder fix for 64-bit android devices"
-6235147e cherry-pick decoder fix for 64-bit android devices
-d41b8c43 configure: test for -Wformat-* w/-Wformat present
-5f95589f Fix WEBP_ALIGN in case the argument is a pointer to a type larger than a byte.
-2309fd5c replace num_parts_ by num_parts_minus_one_ (unsigned)
-9629f4bc SimplifySegments: quiet -Warray-bounds warning
-de47492e Merge "update the Unfilter API in dsp to process one row independently"
-2102ccd0 update the Unfilter API in dsp to process one row independently
-e3912d56 WebPAnimEncoder: Restore canvas before evaluating blending possibility.
-6e12e1e3 WebPAnimEncoder: Fix for single-frame optimization.
-602f344a Merge changes I1d03acac,Ifcb64219
-95ecccf6 only apply color-mapping for alpha on the cropped area
-47dd0708 anim_diff: Add an experimental option for max inter-frame diff.
-aa809cfe only allocate alpha_plane_ up to crop_bottom row
-31f2b8d8 WebPAnimEncoder: FlattenSimilarPixels(): look for similar
-774dfbdc perform alpha filtering within the decoding loop
-a4cae68d lossless decoding: only process decoded row up to last_row
-238cdcdb Only call WebPDequantizeLevels() on cropped area
-cf6c713a alpha: preparatory cleanup
-b95ac0a2 Merge "VP8GetHeaders(): initialize VP8Io with sane value for crop/scale dimensions"
-89231394 VP8GetHeaders(): initialize VP8Io with sane value for crop/scale dimensions
-5828e199 use_8b_decode -> use_8b_decode_
-8dca0247 fix bug in alpha.c that was triggering a memory error in incremental mode
-9a950c53 WebPAnimEncoder: Disable filtering when blending is used with lossy encoding.
-eb423903 WebPAnimEncoder: choose max diff for framerect based on quality.
-ff0a94be WebPAnimEncoder lossy: ignore small pixel differences for frame rectangles.
-f8040084 gif2webp: Remove the 'prev_to_prev_canvas' buffer.
-6d8c07d3 Merge "WebPDequantizeLevels(): use stride in CountLevels()"
-d96fe5e0 WebPDequantizeLevels(): use stride in CountLevels()
-ec1b2407 WebPPictureImport*: check output pointer
-c0768769 Merge "Revert "Re-enable encoding of alpha plane with color cache for next release.""
-41f14bcb WebPPictureImport*: check src pointer
-64eed387 Pass stride parameter to WebPDequantizeLevels()
-97934e24 Revert "Re-enable encoding of alpha plane with color cache for next release."
-e88c4ca0 fix -m 2 mode-cost evaluation (causing partition0 overflow)
-4562e83d Merge "add extra meaning to WebPDecBuffer::is_external_memory"
-abdb109f add extra meaning to WebPDecBuffer::is_external_memory
-875aec70 enc_neon,cosmetics: break long comment
-71e856cf GetMBSSIM,cosmetics: fix alignment
-a90edffb fix missing 'extern' for SSIM function in dsp/
-423ecaf4 move some SSIM-accumulation function for dsp/
-f08e6624 Merge "Fix FindClosestDiscretized in near lossless:"
-0d40cc5e enc_neon,Disto4x4: remove an unnecessary transpose
-e8feb20e Fix FindClosestDiscretized in near lossless:
-82006430 anim_util: quiet static analysis warning
-a6f23c49 Merge "AnimEncoder: Support progress hook and user data."
-a5193774 Merge "Near lossless feature: fix some comments."
-da98d31c AnimEncoder: Support progress hook and user data.
-33357131 Near lossless feature: fix some comments.
-0beed01a cosmetics: fix indent after 2f5e898
-6753f35c Merge "FTransformWHT optimization."
-6583bb1a Improve SSE4.1 implementation of TTransform.
-7561d0c3 FTransformWHT optimization.
-7ccdb734 fix indentation after patch #328220
-6ec0d2a9 clarify the logic of the error path when decoding fails.
-8aa352b2 Merge "Remove an unnecessary transposition in TTransform."
-db860884 Merge "remove useless #include"
-9960c316 Remove an unnecessary transposition in TTransform.
-6e36b511 Small speedup in FTransform.
-9dbd4aad Merge "fix C and SIMD flags completion."
-e60853ea Add missing common_sse2.h file to makefile.unix
-696eb2b0 fix C and SIMD flags completion.
-2b4fe33e Merge "fix multiple allocation for transform buffer"
-2f5e8986 fix multiple allocation for transform buffer
-bf2b4f11 Regroup common SSE code + optimization.
-4ed650a1 force "-pass 6" if -psnr or -size is used but -pass isn't.
-3ef1ce98 yuv_sse2: fix -Wconstant-conversion warning
-a7a03e9f Merge changes I4852d18f,I51ccb85d
-5e122bd6 gif2webp: set enc_options.verbose = 0 w/-quiet
-ab3c2583 anim_encode,DefaultEncoderOptions: init verbose
-8f0dee77 Merge "configure: fix builtin detection w/-Werror"
-4a7b85a9 cmake: fix builtin detection w/-Werror
-b74657fb configure: fix builtin detection w/-Werror
-3661b980 Add a CMakeLists.txt
-75f4af4d remove useless #include
-6c1d7631 avoid Yoda style for comparison
-8ce975ac SSE optimization for vector mismatch.
-7db53831 Merge tag 'v0.5.0'
-37f04949 update ChangeLog (tag: v0.5.0-rc1, tag: v0.5.0, origin/0.5.0)
-7e7b6ccc faster rgb565/rgb4444/argb output
-4c7f565f update NEWS
-1f62b6b2 update AUTHORS
-e224fdc8 update mailmap
-71100500 bump version to 0.5.0
-230a685e README: update help text, repo link
-d48e427b Merge "demux: accept raw bitstreams"
-99a01f4f Merge "Unify some entropy functions."
-4b025f10 Merge "configure: disable asserts by default"
-92cbddf8 Merge "fix PrintBlockInfo()"
-ca509a33 Unify some entropy functions.
-367bf903 fix PrintBlockInfo()
-b0547ff0 move back common constants for lossless_enc*.c into the .h
-fb4c7832 lossless: simpler alpha cleanup preprocessing
-ba7f4b68 Merge "anim_diff: add brief description of options"
-47ddd5a4 Move some codec logic out of ./dsp .
-b4106c44 anim_diff: add brief description of options
-357f455d yuv_sse2: fix 32-bit visual studio build
-b9d80fa4 configure: disable asserts by default
-7badd3da cosmetic fix: sizeof(type) -> sizeof(*var)
-80ce27d3 Speed up 24-bit packing / unpacking in YUV / RGB conversions.
-68eebcb0 remove a TODO about rotation
-2dee2966 remove few obsolete TODO about aligned loads in SSE2
-e0c0bb34 remove TODO about unused ref_lf_delta[]
-9cf1cc2b remove few TODO: * 256 -> RD_DISTO_MULT * don't use TDisto for UV mode picking
-79189645 Merge changes from topic 'demux-fragment-cleanup'
-47399f92 demux: remove GetFragment()
-d3cfb79a demux: remove dead fragment related TODO
-ab714b8a demux, Frame: remove is_fragment_ field
-b105921c yuv_sse2, cosmetics: fix indent
-466c92e8 demux,WebPIterator: remove fragment_num/num_fragments
-11714ff1 demux: remove WebPDemuxSelectFragment
-c0f7cc47 fix for bug #280: UMR in next->bits
-578beeb8 Merge "enc/Makefile.am: add missing headers"
-1a819f00 makefile.unix: make visibility=hidden the default
-d4f9c2ef enc/Makefile.am: add missing headers
-846caff4 configure: check for -fvisibility=hidden
-3f3ea2c5 demux: accept raw bitstreams
-d6dad5d0 man cwebp: add precision about exactness of the 'lossless' mode
-46bb1e34 Merge "gifdec: remove utils.h include"
-2b882e94 Merge "Makefile.vc: define WEBP_HAVE_GIF for gifdec.c"
-892b9238 Merge "man/*, AUTHORS: clarify origin of the tool"
-e5687a18 Merge "fix optimized build with -mcmodel=medium"
-e56e6859 Makefile.vc: define WEBP_HAVE_GIF for gifdec.c
-4077d944 gifdec: remove utils.h include
-b5e30dac man/*, AUTHORS: clarify origin of the tool
-b275e598 fix optimized build with -mcmodel=medium
-64da45a9 cosmetics, cwebp: fix indent
-038a060d Merge "add disto-based refinement for UV mode (if method = 1 or 2)"
-2835089d Provide an SSE2 implementation of CombinedShannonEntropy.
-e6c93519 add disto-based refinement for UV mode (if method = 1 or 2)
-04507dc9 Merge "fix undefined behaviour during shift, using a cast"
-793c5261 Merge "wicdec: add support for reading from stdin"
-d3d16397 Optimize the heap usage in HistogramCombineGreedy.
-202a710b fix undefined behaviour during shift, using a cast
-14d27a46 improve method #2 by merging DistoRefine() and SimpleQuantize()
-cb1ce996 Merge "10% faster table-less SSE2/NEON version of YUV->RGB conversion"
-ac761a37 10% faster table-less SSE2/NEON version of YUV->RGB conversion
-79fcf29a wicdec: add support for reading from stdin
-015f173f Merge "cwebp: add support for stdin input"
-a9947c32 cwebp: add support for stdin input
-7eb01ff3 Merge "Improved alpha cleanup for the webp encoder when prediction transform is used."
-fb8c9106 Merge "introduce WebPMemToUint32 and WebPUint32ToMem for memory access"
-bd91af20 Merge "bit_reader: remove aarch64 BITS TODO"
-6c702b81 Speed up hash chain initialization using memset.
-4c60f63c make ReadPNG and ReadJPEG take a filename instead of a FILE
-464ed10f bit_reader: remove aarch64 BITS TODO
-d478e589 Merge "configure: update issue tracker"
-69381113 Improved alpha cleanup for the webp encoder when prediction transform is used.
-2c08aac8 introduce WebPMemToUint32 and WebPUint32ToMem for memory access
-010ca3d1 Fix FindMatchLength with non-aligned buffers.
-a90e1e3f README: add prerequisites for an autoconf build
-458f0866 configure: update issue tracker
-33914595 vwebp: work around the transparent background with GLUT bug
-e4a7eed4 cosmetics: fix indent
-08375129 Merge "Make a separate case for low_effort in CopyImageWithPrediction"
-aa2eb2d4 Merge "cosmetics: fix indent"
-b7551e90 cosmetics: fix indent
-5bda52d4 Make a separate case for low_effort in CopyImageWithPrediction
-66fa598a Merge "configure: fix intrinsics build w/older gcc"
-5ae220be backward_references.c: Fixed compiler warning
-1556da09 Merge "configure: restore 2 warnings"
-71a17e58 configure: restore 2 warnings
-9eeabc07 configure: fix intrinsics build w/older gcc
-363babe2 Merge "fix some warning about unaligned 32b reads"
-a1411782 Optimization in hash chain comparison for 64 bit Arrays were compared 32 bits at a time, it is now done 64 bits at a time. Overall encoding speed-up is only of 0.2% on @skal's small PNG corpus. It is of 3% on my initial 1.3 Mp desktop screenshot image.
-829bd141 Combine Huffman cost and bit entropy into one loop
-a7a954c8 Merge "lossless: make prediction in encoder work per scanline"
-61b605b4 Merge "fix of undefined multiply (int32 overflow)"
-239421c5 lossless: make prediction in encoder work per scanline
-f5ca40e0 fix of undefined multiply (int32 overflow)
-5cd2ef4c Merge changes from topic 'win-threading-compat'
-76ce9187 Makefile.vc: enable WEBP_USE_THREAD for windows phone
-d2afe974 thread: use CreateThread for windows phone
-0fd0e12b thread: use WaitForSingleObjectEx if available
-63fadc9f thread: use InitializeCriticalSectionEx if available
-110ad583 thread: use native windows cond var if available
-912c9fdf dec/webp: use GetLE(24|32) from utils
-f1694481 utils/GetLE32: correct uint32 promotion
-158763de Merge "always call WebPInitSamplers(), don't try to be smart"
-3770f3bb Merge "cleanup the YFIX/TFIX difference by removing some code and #define"
-a40f60a9 Merge "3% speed improvement for lossless webp encoder for low effort mode:"
-ed1c2bc6 always call WebPInitSamplers(), don't try to be smart
-b8c44f1a 3% speed improvement for lossless webp encoder for low effort mode:
-997e1038 cleanup the YFIX/TFIX difference by removing some code and #define
-d73d1c8b Merge "Make discarding invisible RGB values (cleanup alpha) the default."
-1f9be97c Make discarding invisible RGB values (cleanup alpha) the default.
-f240117b Make dwebp listen more to the -quiet flag
-b37b0179 fix for issue #275: don't compare to out-of-bound pointers
-21735e06 speed-up trivial one-symbol decoding case for lossless
-397863bd Refactor CopyPlane() and CopyPixels() methods: put them in utils.
-6ecd72f8 Re-enable encoding of alpha plane with color cache for next release.
-1f7148a4 Merge "remove unused fields from WebPDecoderOptions and WebPBitstreamFeatures"
-6ae395fa Merge "use ExReadFile() for ReadYUV()"
-8076a00e gitignore list: add anim_diff.
-1c1702d8 use ExReadFile() for ReadYUV()
-775d3a37 remove unused fields from WebPDecoderOptions and WebPBitstreamFeatures
-c13245c7 AnimEncoder: Add a GetError() method.
-688b265d AnimDecoder API: Add a GetDemuxer() method.
-1aa4e3d6 WebPAnimDecoder: add an option to enable multi-threaded decoding.
-3584abca AnimDecoder: option to decode to common color modes.
-afd5a62c Merge "mux.h does NOT need to include encode.h"
-8550d443 Merge "migrate anim_diff tool from C++ to C89"
-96201e50 migrate anim_diff tool from C++ to C89
-945cfa3b mux.h does NOT need to include encode.h
-8da07e8d Merge "~2x faster SSE2 RGB24toY, BGR24toY, ARGBToY|UV"
-bfd3fc02 ~2x faster SSE2 RGB24toY, BGR24toY, ARGBToY|UV
-02432427 man/cwebp.1, cosmetics: escape '-'s
-96f5b423 man/cwebp: group lossy-only options
-52fdbdfe extract some RGB24 to Luma conversion function from enc/ to dsp/
-ab8c2300 add missing \n
-8304179a sync NEWS with 0.4.4
-5bd04a08 sync versions with 0.4.4
-8f1fcc15 Merge "Move ARGB->YUV functions from dec/vp8l.c to dsp/yuv.c"
-25bf2ce5 fix some warning about unaligned 32b reads
-922268fd s/TIFF/WebP
-fa8927ef Move ARGB->YUV functions from dec/vp8l.c to dsp/yuv.c
-9b373598 Merge "for ReadXXXX() image-readers, use the value of pic->use_argb"
-f7c507a5 Merge "remove unnecessary #include "yuv.h""
-7861578b for ReadXXXX() image-readers, use the value of pic->use_argb
-14e4043b remove unnecessary #include "yuv.h"
-469ba2cd vwebp: fix incorrect clipping w/NO_BLEND
-4b9186b2 update issue tracker url
-d64d376c change WEBP_ALIGN_CST value to 31
-f717b828 vp8l.c, cosmetics: fix indent after 95509f9
-927ccdc4 Merge "fix alignment of allocated memory in AllocateTransformBuffer"
-fea94b2b fix alignment of allocated memory in AllocateTransformBuffer
-5aa8d61f Merge "MIPS: rescaler code synced with C implementation"
-e7fb267d MIPS: rescaler code synced with C implementation
-93c86ed5 Merge "format_constants.h: MKFOURCC, correct cast"
-5d791d26 format_constants.h: MKFOURCC, correct cast
-65726cd3 dsp/lossless: Average2, make a constant unsigned
-d26d9def Use __has_builtin to check clang support
-12ec204e moved ALIGN_CST into util/utils.h and renamed WEBP_ALIGN_xxx
-a2640838 Merge "rescaler: ~20% faster SSE2 implementation for lossless ImportRowExpand"
-3fb600d5 Merge "wicdec: fix alpha detection w/64bpp BGRA/RGBA"
-67c547fd rescaler: ~20% faster SSE2 implementation for lossless ImportRowExpand
-99e3f812 Merge "large re-organization of the delta-palettization code"
-95509f99 large re-organization of the delta-palettization code
-74fb458b fix for weird msvc warning message
-ae49ad86 Merge "SSE2 implementation of ImportRowShrink"
-932fd4df SSE2 implementation of ImportRowShrink
-badfcbaa wicdec: fix alpha detection w/64bpp BGRA/RGBA
-35cafa6c Merge "iosbuild: fix linking with Xcode 7 / iOS SDK 9"
-b0c9d8af label rename: NO_CHANGE -> NoChange
-b4e731cd neon-implementation for rescaler code
-db1321a6 iosbuild: fix linking with Xcode 7 / iOS SDK 9
-6dfa5e3e rescaler: better handling of the fxy_scale=0 special case.
-55c05293 Revert "rescaler: better handling of the fxy_scale=0 special case."
-9f226bf8 rescaler: better handling of the fxy_scale=0 special case.
-f7b8f907 delta_palettization.*: add copyright
-c1e1b710 Changed delta palette to compress better
-0dd28267 Merge "Add delta_palettization feature to WebP"
-48f66b66 Add delta_palettization feature to WebP
-27933e2a anim_encoder: drop a frame if it has same pixels as the prev frame.
-df9f6ec8 Merge "webpmux/DisplayInfo: send non-error output to stdout"
-8af4993b Merge "rescaler_mips_dsp_r2: cosmetics, fix indent"
-2b9d2495 Merge "rescaler: cosmetics, join two lines"
-cc020a8c webpmux/DisplayInfo: send non-error output to stdout
-a288e746 configure: add -Wshorten-64-to-32
-c4c3cf2d pngdec: fix type conversion warnings
-bef8e97d webpmux: fix type conversion warning
-5a84460d rescaler_mips_dsp_r2: cosmetics, fix indent
-acde0aae rescaler: cosmetics, join two lines
-306ce4fd rescaler: move the 1x1 or 2x1 handling one level up
-cced974b remove _mm_set_epi64x(), which is too specific
-56668c9f fix warnings about uint64_t -> uint32_t conversion
-76a7dc39 rescaler: add some SSE2 code
-1df1d0ee rescaler: harmonize function protos
-9ba1894b rescaler: simplify ImportRow logic
-5ff0079e fix rescaler vertical interpolation
-cd82440e VP8LAllocateHistogramSet: align histogram[] entries
-a406b1dd Merge "fix memory over-allocation in lossless rescaler init"
-0fde33e3 add missing const in VP8InitFrame signature
-ac7d5e8d fix memory over-allocation in lossless rescaler init
-017f8ccc Loosen the buffer size checks for Y/U/V/A too.
-15ca5014 loosen the padding check on buffer size
-d623a870 dec_neon: add whitespace around stringizing operator
-29377d55 dsp/mips: cosmetics: add whitespace around XSTR macro
-eebaf97f dsp/mips: add whitespace around stringizing operator
-d39dc8f3 Create a WebPAnimDecoder API.
-03fb7522 gif2webp: print output file size
-14efabbf Android: limit use of cpufeatures
-7b83adbe preparatory cosmetics for Rescaler code fix and clean-up
-77fb41c2 dec/vp8l/DecodeAlphaData: remove redundant cast
-90fcfcd9 Insert less hash chain entries from the beginnings of long copies.
-bd55604d SSE2: add yuv444 converters, re-using yuv_sse2.c
-41a5d99d add a -quiet option to 'dwebp'
-80ab3edb Merge "README: update dwebp help output after 1e595fe"
-32b71b2e README: update dwebp help output after 1e595fe
-3ec11827 use the DispatchAlpha() call from dsp
-c5f00621 incorporate bzero() into WebPRescalerInit() instead of call site
-3ebcdd41 remove duplicate "#include <stdlib.h>"
-1e595fe1 dwebp: add -resize as a synonym for -scale
-24a96932 dec: allow 0 as a scaling dimension
-b9187242 utils/rescaler: add WebPRescalerGetScaledDimensions
-923e8eda Merge "update NEWS"
-020fd099 Merge "WebPPictureDistortion: support ARGB format for 'pic' when computing distortion."
-6a5292f6 update NEWS
-56a2e9f5 WebPPictureDistortion: support ARGB format for 'pic' when computing distortion.
-0ae582e4 configure: test and add -Wunreachable-code
-c2f9dc06 bit_writer: convert VP8L macro values to immediates
-b969f888 Reduce magic in palette reordering
-acb297e9 anim_diff: add a -raw_comparison flag
-155c1b22 Merge changes I76f4d6fe,I45434639
-717e4d5a mips32/mipsDSPr2: function ImportRow rebased
-7df93893 fix rescaling bug (uninitialized read, see bug #254).
-5cdcd561 lossless_enc_neon: add VP8LTransformColor
-a53c3369 lossless_neon: add VP8LTransformColorInverse
-99131e7f Merge changes I9fb25a89,Ibc648e9e
-c4556766 simplify the main loop for downscaling
-2a010f99 lossless_neon: remove predictors 5-13
-ca221bbc ll_enc_neon: enable VP8LSubtractGreenFromBlueAndRed
-585d93db Container spec: clarify ordering of ALPH chunk.
-01d61fd9 lossless: ~20 % speedup
-f722c8f0 lossless: Speed up ComputeCacheEntropy by 40 %
-1ceecdc8 add a VP8LColorCacheSet() method for color cache
-17eb6099 lossless: Allow copying from prev row in rle-mode.
-f3a7a5bf lossless: bit writer optimization
-d97b9ff7 Merge changes from topic 'lossless-enc-improvements'
-0250dfcc msvc: fix pointer type warning in BitsLog2Floor
-52931fd5 lossless: combine the Huffman code with extra bits
-c4855ca2 lossless: Inlining add literal
-8e9c94de lossless: simplify HashChainFindCopy heuristics
-888429f4 lossless: 0.5 % compression density improvement
-7b23b198 lossless: Add zeroes into the predicted histograms.
-85b44d8a lossless: encoding, don't compute unnecessary histo
-d92453f3 lossless: Remove about 25 % of the speed degradation
-2cce0317 Faster alpha coding for webp
-5e75642e lossless: rle mode not to accept lengths smaller than 4.
-84326e4a lossless: Less code for the entropy selection
-16ab951a lossless: 0.37 % compression density improvement
-822f113e add WebPFree() to the API
-0ae2c2e4 SSE2/SSE41: optimize SSE_16xN loops
-39216e59 cosmetics: fix indent after 32462a07
-559e54ca Merge "SSE2: slightly faster FTransformWHT"
-8ef9a63b SSE2: slightly faster FTransformWHT
-f27f7735 lossless_neon: enable VP8LAddGreenToBlueAndRed
-36e9c4bc SSE2: minor cosmetrics on in-loop filter code
-4741fac4 dsp/lossless_*sse2: remove some unnecessary inlines
-1819965e fix warning ("left shift of negative value") using a cast
-70170014 SSE2: speed-up some lossless-encoding functions
-abcb0128 Merge "SSE2: slightly faster (~5%) AddGreenToBlueAndRed()"
-2df5bd30 Merge "Speedup to HuffmanCostCombinedCount"
-9e356d6b SSE2: slightly faster (~5%) AddGreenToBlueAndRed()
-fc6c75a2 SSE2: 53% faster TransformColor[Inverse]
-49073da6 SSE2: 46% speed-up of TransformColor[Inverse]
-32462a07 Speedup to HuffmanCostCombinedCount
-f3d687e3 SSE4.1 implementation of some lossless encoding functions
-bfc300c7 SSE4.1 implementation of some alpha-processing functions
-7f9c98f2 Merge "sse2 in-loop: simplify SignedShift8b() a bit"
-ef314a5d dec_sse2/GetNotHEV: micro optimization
-a729cff9 sse2 in-loop: simplify SignedShift8b() a bit
-422ec9fb simplify Load8x4() a bit
-8df238ec Merge "remove some duplicate FlipSign()"
-751506c4 remove some duplicate FlipSign()
-65ef5afc Merge "lossless: 0.13% compression density gain"
-2beef2f2 lossless: 0.13% compression density gain
-3033f24c lossless: 0.06 % compression density improvement
-64960da9 dec_neon: add VE8uv / VE16
-14dbd87b dec_neon: add HE8uv / HE16
-ac768011 introduce FTransform2 to perform two transforms at a time.
-aa6065ae dec_neon: use vld1_dup(mem) rather than vdup(mem[0])
-8b63ac78 Merge "dec_neon: add TM16"
-f51be09e Merge "dec_neon/TrueMotion: simply left border load"
-dc48196b dec_neon: add TM16
-ea95b305 dec_neon/TrueMotion: simply left border load
-f262d612 speed-up SetResidualSSE2
-bf46d0ac fix mips2 build target
-929a0fdc enc_sse2/TTransform: simplify abs calculation
-17dbd058 enc_sse2/CollectHistogram: simplify abs calculation
-a6c15936 dec_neon: add DC16 intra predictors
-03b4f50d Makefile.vc: add anim_diff build support.
-1b989874 Merge changes I9cd84125,Iee7e387f,I7548be72
-acd7b5af Introduce a test tool anim_diff.
-f274a96c dsp/enc_sse2: add luma4 intra predictors
-040b11bd dsp/enc_sse2: add chroma intra predictors
-aee021bb dsp/enc_sse2: add luma16 intra predictors
-9e00a499 makefile.unix: remove superclean target
-cefc9c09 makefile.unix: clean up after extras target
-4c9af023 dec_neon: add DC8uvNoTopLeft
-dd55b873 Merge "doc/webp-container-spec: update repo browser link"
-f0486968 doc/webp-container-spec: update repo browser link
-9287761d Merge "GetResidualCostSSE2: simplify abs calculation"
-0e009366 dsp/cpu.c(x86): check maximum supported cpuid feature
-b243a4bc GetResidualCostSSE2: simplify abs calculation
-6d4602b8 Merge "fix typo: constitutes -> constitute"
-5fe1fe37 fix typo: constitutes -> constitute
-b83bd7c4 Merge "populate 'libwebpextras' with: import gray, rgb565 and rgb4444 functions"
-b0114a32 Merge "histogram.h: cosmetics: remove unnecessary includes"
-feab45ef gifdec: Move inclusion of webp/config.h to header.
-dbba67d1 histogram.h: cosmetics: remove unnecessary includes
-e978fec6 Merge "VP8LBitReader: fix remaining ubsan error with large shifts"
-d6fe5884 Merge "ReconstructRow: move some one-time inits out of the main loop"
-a21d647c ReconstructRow: move some one-time inits out of the main loop
-7a01c3c3 VP8LBitReader: fix remaining ubsan error with large shifts
-7fa67c9b change GetPixPairHash64() return type to uint32_t
-ec1fb9f8 Merge "dsp/enc.c: cosmetics: move DST() def closer to use"
-7073bfb3 Merge "split 64-mult hashing into two 32-bit multiplies"
-0768b252 dsp/enc.c: cosmetics: move DST() def closer to use
-6a48b8f0 Merge "fix MSVC size_t->int conversion warning"
-1db07cde Merge "anim_encode: cosmetics: fix alignment"
-e28271a3 anim_encode: cosmetics: fix alignment
-7fe357b8 split 64-mult hashing into two 32-bit multiplies
-af74c145 populate 'libwebpextras' with: import gray, rgb565 and rgb4444 functions
-61214134 remove VP8Residual::cost unused field
-e2544823 fix MSVC size_t->int conversion warning
-b69a6c35 vwebp: don't redefine snprintf with VS2015+
-0ac29c51 AnimEncoder API: Consistent use of trailing underscores in struct.
-d4845550 AnimEncoder API: Use timestamp instead of duration as input to Add().
-9904e365 dsp/dec_sse2: DC8uv / DC8uvNoLeft speedup
-7df20497 dsp/dec_sse2: DC16 / DC16NoLeft speedup
-8e515dfe Merge "makefile.unix: add some missing headers"
-db12250f cosmetics: vp8enci.h: break long line
-bf516a87 makefile.unix: add some missing headers
-b44eda3f dsp: add DSP_INIT_STUB
-03e76e96 clarify the comment about double-setting the status in SetError()
-9fecdd71 remove unused EmitRGB()
-43f010dd move ReconstructRow to top
-82d98020 add a dec/common.h header to collect common enc/dec #defines
-5d4744a2 Merge "enc_sse41: add Disto4x4 / Disto16x16"
-e38886a7 mux.h: Bump up ABI version
-46305ca6 configure: add --disable-<avx2|sse4.1|sse2>
-2fc8b658 CPPFLAGS->CFLAGS for detecting sse4.1 in preprocessor
-1a338fb3 enc_sse41: add Disto4x4 / Disto16x16
-94055503 encoding SSE4.1 stub for StoreHistogram + Quantize + SSE_16xN
-c64659e1 remove duplicate variables after the lossless{_enc}.c split
-67ba7c7a enc_sse2: call local FTransform in CollectHistogram
-18249799 dsp: s/VP8LSetHistogramData/VP8SetHistogramData/
-ede5e158 cosmetics: dsp/lossless.h: reorder prototypes
-553051f7 dsp/lossless: split enc/dec functions
-9064adc8 Merge "conditionally add -msse4.1 in Makefile.unix"
-cecf5096 dsp/yuv*.c: rework WEBP_USE_<arch> ifdef
-6584d398 dsp/upsampling*.c: rework WEBP_USE_<arch> ifdef
-80809422 dsp/rescaler*.c: rework WEBP_USE_<arch> ifdef
-1d93ddec dsp/lossless*.c: rework WEBP_USE_<arch> ifdef
-73805ff2 dsp/filters*.c: rework WEBP_USE_<arch> ifdef
-fbdcef24 dsp/enc*.c: rework WEBP_USE_<arch> ifdef
-66de69c1 dsp/dec*.c: rework WEBP_USE_<arch> ifdef
-48e4ffd1 dsp/cost*.c: rework WEBP_USE_<arch> ifdef
-29fd6f90 dsp/argb*.c: rework WEBP_USE_<arch> ifdef
-80ff3813 dsp/alpha*.c: rework WEBP_USE_<arch> ifdef
-bf09cf1e conditionally add -msse4.1 in Makefile.unix
-e9570dd9 stub for SSE4.1 support.
-4a95384b Merge "dsp: add sse4.1 detection"
-cabf4bd2 dsp: add sse4.1 detection
-4ecba1ab thread.h: rename interface param
-b8d706c8 Merge "sync versions with 0.4.3"
-ae64a711 Merge "add shell for libwebpextras"
-92a5da9c sync versions with 0.4.3
-9d4e2d16 Merge "~30% faster smart-yuv (-pre 4) with early-out criterion"
-b1bdbbab ~30% faster smart-yuv (-pre 4) with early-out criterion
-7efb9748 Merge "Disable NEON code on Native Client"
-ac4f5784 Disable NEON code on Native Client
-0873f85b AnimEncoder API: Support input frames in YUV(A) format.
-5c176d2d add shell for libwebpextras
-44bd9561 fix signature for VP8RecordCoeffTokens()
-c9b8ea0e small cosmetics on TokenBuffer.
-76394c09 Merge "MIPS: dspr2: added optimization for TrueMotion"
-0f773693 WebPPictureRescale: add a note about 0 width/height
-241bb5d9 MIPS: dspr2: added optimization for TrueMotion
-6cef0e4f examples/Android.mk: add webpmux_example target
-53c16ff0 Android.mk: add webpmux target
-21852a00 Android.mk: add webpdemux target
-8697a3bc Android.mk: add webpdecoder{,_static} targets
-4a670491 Android.mk: split source lists per-directory
-b5e79422 MIPS: dspr2: Added optimization for some convert functions
-0f595db6 MIPS: dspr2: Added optimization for some convert functions
-8a218b4a MIPS: [mips32|dspr2]: GetResidualCost rebased
-ef987500 Speedup method StoreImageToBitMask by 5%.
-602a00f9 fix iOS arm64 build with Xcode 6.3
-23820507 1-2% faster encoding by removing an indirection in GetResidualCost()
-eddb7e70 MIPS: dspr2: added otpimization for DC8uv, DC8uvNoTop and DC8uvNoLeft
-73ba2915 MIPS: dspr2: added optimization for functions RD4 and LD4
-c7129da5 Merge "4-5% faster encoding using SSE2 for GetResidualCost"
-94380d00 MIPS: dspr2: added optimizaton for functions VE4 and DC4
-2a407092 4-5% faster encoding using SSE2 for GetResidualCost
-17e19862 Merge "MIPS: dspr2: added optimization for simple filtering functions"
-3ec404c4 Merge "dsp: normalize WEBP_TSAN_IGNORE_FUNCTION usage"
-b969f5df dsp: normalize WEBP_TSAN_IGNORE_FUNCTION usage
-d7b8e711 MIPS: dspr2: added optimization for simple filtering functions
-235f774e Merge "MIPS: dspr2: Added optimization for function VP8LTransformColorInverse_C"
-42a8a628 MIPS: dspr2: Added optimization for function VP8LTransformColorInverse_C
-b442bef3 Merge "ApplyFiltersAndEncode: only copy lossless stats"
-b510fbfe doc/webp-container-spec: note MSB order for chunk diagrams
-9bc0f922 ApplyFiltersAndEncode: only copy lossless stats
-3030f115 Merge "dsp/mips: add some missing TSan annotations"
-dfcf4593 Merge "MIPS: dspr2: Added optimization for function VP8LAddGreenToBlueAndRed_C"
-55c75a25 dsp/mips: add some missing TSan annotations
-2cb879f0 MIPS: dspr2: Added optimization for function VP8LAddGreenToBlueAndRed_C
-e1556010 move some cost tables from enc/ to dsp/
-c3a03168 Merge "picture_csp: fix build w/USE_GAMMA_COMPRESSION undefined"
-39537d7c Merge "VP8LDspInitMIPSdspR2: add missing TSan annotation"
-1dd419ce picture_csp: fix build w/USE_GAMMA_COMPRESSION undefined
-43fd3543 VP8LDspInitMIPSdspR2: add missing TSan annotation
-c7233dfc Merge "VP8LDspInit: remove memcpy"
-0ec4da96 picture_csp::InitGammaTables*: add missing TSan annotations
-35579a49 VP8LDspInit: remove memcpy
-97f6aff8 VP8YUVInit: add missing TSan annotation
-f9016d66 dsp/enc::InitTables: add missing TSan annotation
-e3d9771a VP8EncDspCostInit*: add missing TSan annotations
-d97c143d Merge "doc/webp-container-spec: cosmetics"
-309b7908 MIPS: mips32: Added optimization for function SetResidualCoeffs
-a987faed MIPS: dspr2: added optimization for function GetResidualCost
-e7d3df23 doc/webp-container-spec: cosmetics
-be6635e9 Merge "VP8TBufferClear: remove some misleading const's"
-02971e72 Merge "VP8EmitTokens: remove unnecessary param void cast"
-3b77e5a7 VP8TBufferClear: remove some misleading const's
-aa139c8f VP8EmitTokens: remove unnecessary param void cast
-c24d8f14 cosmetics: upsampling_sse2: add const to some casts
-1829c42c cosmetics: lossless_sse2: add const to some casts
-183168f3 cosmetics: enc_sse2: add const to some casts
-860badca cosmetics: dec_sse2: add const to some casts
-0254db97 cosmetics: argb_sse2: add const to some casts
-1aadf856 cosmetics: alpha_processing_sse2: add const to some casts
-1579de3c vwebp: clear canvas at the beginning of each loop
-4b9fa5d0 Merge "webp-container-spec: clarify background clear on loop"
-4c82284d Updated the near-lossless level mapping.
-56039479 webp-container-spec: clarify background clear on loop
-19f0ba0e Implement true-motion prediction in SSE2
-774d4cb7 make VP8PredLuma16[] array non-const
-d7eabb80 Merge "MIPS: dspr2: Added optimization for function CollectHistogram"
-fe42739c Use integers for kmin/kmax for simplicity.
-b9df35f7 AnimEncode API: kmax=0 should imply all keyframes.
-6ce296da MIPS: dspr2: Added optimization for function CollectHistogram
-2c906c40 vwebp: remove unnecessary static Help() prototype
-be0fd1d5 Merge "dec/vp8: clear 'dither_' on skipped blocks"
-e96170fe Merge "vwebp/animation: display last frame on end-of-loop"
-0f017b56 vwebp/animation: display last frame on end-of-loop
-c86b40cc enc/near_lossless.c: fix alignment
-66935fb9 dec/vp8: clear 'dither_' on skipped blocks
-b7de7946 Merge "lossless_neon: enable subtract green for aarch64"
-77724f70 SSE2 version of GradientUnfilter
-416e1cea lossless_neon: enable subtract green for aarch64
-72831f6b Speedup AnalyzeAndInit for low effort compression.
-a6597483 Speedup Analyze methods for lossless compression.
-98c81386 Enable Near-lossless feature.
-c6b24543 AnimEncoder API: Fix for kmax=1 and default kmin case.
-022d2f88 add SSE2 variants for alpha filtering functions
-2db15a95 Temporarily disable encoding of alpha plane with color cache.
-1d575ccd Merge "Lossless decoding: Remove an unnecessary if condition."
-cafa1d88 Merge "Simplify backward refs calculation for low-effort."
-7afdaf84 Alpha coding: reorganize the filter/unfiltering code
-4d6d7285 Simplify backward refs calculation for low-effort.
-ec0d1be5 Cleaup Near-lossless code.
-9814ddb6 Remove the post-transform near-lossless heuristic.
-4509e32e Lossless decoding: Remove an unnecessary if condition.
-f2ebc4a8 Merge "Regression fix for lossless decoding"
-783a8cda Regression fix for lossless decoding
-9a062b8e AnimEncoder: Bugfix for kmin = 1 and kmax = 2.
-0f027a72 simplify smart RGB->YUV conversion code
-0d5b334e BackwardReferencesHashChainFollowChosenPath: remove unused variable
-f480d1a7 Fix to near lossless artefacts on palettized images.
-d4615d08 Merge changes Ia1686828,I399fda40
-cb4a18a7 rename HashChainInit into HashChainReset
-f079e487 use uint16_t for chosen_path[]
-da091212 MIPS: dspr2: Added optimization for function FTransformWHT
-b8c20135 Merge "wicdec: (msvs) quiet some /analyze warnings"
-9b228b54 wicdec: (msvs) quiet some /analyze warnings
-daeb276a Merge "MIPS: dspr2: Added optimization for MultARGBRow function"
-cc087424 Merge "dsp/cpu: (msvs) add include for __cpuidex"
-4a82aab5 Merge changes I87544e92,I0bb6cda5
-7a191398 dwebp/WritePNG: mark png variables volatile
-775dfad2 dwebp: include setjmp.h w/WEBP_HAVE_PNG
-47d26be7 dwebp: correct sign in format strings
-f0e0677b VP8LEncodeStream: add an assert
-c5f7747f VP8LColorCacheCopy: promote an int before shifting
-0de5f33e dsp/cpu: (msvs) add include for __cpuidex
-7d850f7b MIPS: dspr2: Added optimization for MultARGBRow function
-54875293 MIPS: dspr2: added optimization for function QuantizeBlock
-4fbe9cf2 dsp/cpu: (msvs) avoid immintrin.h on _M_ARM
-3fd59039 simplify/reorganize arguments for CollectColorBlueTransforms
-b9e356b9 Disable costly TraceBackwards for method=0.
-a7e7caa4 MIPS: dspr2: added optimization for function TransformColorRed
-2cb39180 Merge "MIPS: dspr2: added optimization for function TransformColorBlue"
-279e6613 Merge "dsp/cpu: add include for _xgetbv() w/MSVS"
-b6c0428e dsp/cpu: add include for _xgetbv() w/MSVS
-d1c4ffae gif2webp: Move GIF decoding related code to a support library.
-07c39559 Merge "AnimEncoder API: Add info in README.mux"
-7b161973 MIPS: dspr2: added optimization for function TransformColorBlue
-d7c4b02a cpu: fix AVX2 detection for gcc/clang targets
-9d299469 AnimEncoder API: Add info in README.mux
-d581ba40 follow-up: clean up WebPRescalerXXX dsp function
-f8740f0d dsp: s/USE_INTRINSICS/WEBP_USE_INTRINSICS/
-ce73abe0 Merge "introduce a separate WebPRescalerDspInit to initialize pointers"
-ab66beca introduce a separate WebPRescalerDspInit to initialize pointers
-205c7f26 fix handling of zero-sized partition #0 corner case
-cbcdd5ff Merge "move rescaler functions to rescaler* files in src/dsp/"
-bf586e88 Merge changes I230b3532,Idf3057a7
-6dc79dc2 Merge "anim_encode: fix type conversion warnings"
-11fce25a Merge "dec_neon: remove returns from void functions"
-c4e63f99 Makefile.vc: add gif2webp target
-4f43d38c enable NEON for Windows ARM builds
-3f6615ac Makefile.vc: add rudimentary Windows ARM support
-e7c5954c dec_neon: remove returns from void functions
-f79c163b anim_encode: fix type conversion warnings
-0f54f1ec Remove gif2webp_util which is no longer needed.
-cbcbedd0 move rescaler functions to rescaler* files in src/dsp/
-ac79ed19 webpmux: remove experimental fragment handling
-e8694d4d mux: remove experimental FRGM parsing
-9e92b6ea AnimEncoder API: Optimize single-frame animated images
-abbae279 Merge "Move over gif2webp to the new AnimEncoder API."
-a28c4b36 MIPS: move WORK_AROUND_GCC define to appropriate place
-012d2c60 MIPS: dspr2: added optimization for functions SSEAxB
-67720c8b Move over gif2webp to the new AnimEncoder API.
-9241ecf4 MIPS: dspr2: added optimization for function Average
-9422211d Merge "Tune BackwardReferencesLz77 for low_effort (m=0)."
-df40057b Merge "Speedup VP8LGetHistoImageSymbols for low effort (m=0) mode."
-ea08466d Tune BackwardReferencesLz77 for low_effort (m=0).
-b0b973c3 Speedup VP8LGetHistoImageSymbols for low effort (m=0) mode.
-c6d32927 argb_sse2: cosmetics
-67f601cd make the 'last_cpuinfo_used' variable names unique
-b9489861 AnimEncoder API: Init method for default options.
-856f8ec1 Merge "AnimEncoder API: Remove AnimEncoderFrameOptions."
-c537514d Merge "AnimEncoder API: GenerateCandidates bugfix."
-dc0ce039 Merge "AnimEncoder API: Compute change rectangle for first frame too."
-f00b639b Merge "AnimEncoder API: In Assemble(), always set animation parameters."
-29ed796c Merge "AnimEncoder lib cleanup: prev to prev canvas not needed."
-9f0dd6e5 Merge "WebPAnimEncoder API: Header and implementation"
-5e56bbe0 AnimEncoder API: Remove AnimEncoderFrameOptions.
-b902c3ea AnimEncoder API: GenerateCandidates bugfix.
-ef3c39bb AnimEncoder API: Compute change rectangle for first frame too.
-eec423ab AnimEncoder API: In Assemble(), always set animation parameters.
-ae1c046e AnimEncoder lib cleanup: prev to prev canvas not needed.
-4b997ae4 WebPAnimEncoder API: Header and implementation
-72208bec move argb_*.o build target to encoder list
-95920538 Merge "multi-thread fix: lock each entry points with a static var"
-4c1b300a Merge "SSE2 implementation of VP8PackARGB"
-fbcc2004 Merge "add -Wformat-nonliteral and -Wformat-security"
-80d950d9 add -Wformat-nonliteral and -Wformat-security
-04c20e75 Merge "MIPS: dspr2: added optimization for function Intra4Preds"
-a437694a multi-thread fix: lock each entry points with a static var
-ca7f60db SSE2 implementation of VP8PackARGB
-72d573f6 simplify the PackARGB signature
-4e2589ff demux: restore strict fragment flag check
-4ba8e074 Merge "webp-container-spec: remove references to fragments"
-e752f0a6 Merge "demux: remove experimental FRGM parsing"
-f8abb112 Merge changes I109ec4d9,I73fe7743
-ae2188a4 MIPS: dspr2: added optimization for function Intra4Preds
-1f4b8642 move VP8EncDspARGBInit() call closer to where it's needed
-14108d78 dec_neon: add DC8uvNoTop / DC8uvNoLeft
-d8340da7 dec_neon: add DC8uv
-a66e66c7 webp-container-spec: remove references to fragments
-7ce8788b MIPS: dspr2: added optimization for function MakeARGB32
-012e623d demux: remove experimental FRGM parsing
-87c3d531 method=0: Don't evaluate any predictor
-6f4fcb98 Merge "MIPS: dspr2: added optimization for function ImportRow"
-24284459 replace unneeded calls to HistogramCopy() by swaps
-bdf7b40c MIPS: dspr2: added optimization for function ImportRow
-e66a9225 Merge "MIPS: dspr2: added optimization for function ExportRowC"
-c279fec1 MIPS: dspr2: added optimization for function ExportRowC
-31a9cf64 Speedup WebP lossless compression for low effort (m=0) mode with following: - Disable Cross-Color transform. - Evaluate predictors #11 (paeth), #12 and #13 only.
-9275d91c MIPS: dspr2: added optimization for function TrueMotion
-26106d66 Merge "enc_neon: fix building with non-Xcode clang (iOS)"
-1c4e3efe unroll the kBands[] indirection to remove a dereference in GetCoeffs()
-a3946b89 enc_neon: fix building with non-Xcode clang (iOS)
-8ed9c00d Merge "simplify the Histogram struct, to only store max_value and last_nz"
-bad77571 simplify the Histogram struct, to only store max_value and last_nz
-3cca0dc7 MIPS: dspr2: Added optimization for DCMode function
-37e395fd MIPS: fix functions to use generic BPS istead of hardcoded value
-9475bef4 PickBestUV: fix VP8Copy16x8 invocation
-441f273f Merge changes I55f8da52,Id73a1e96
-4a279a68 cosmetics: add some missing != NULL comparisons
-66ad3725 factorize BPS definition in dsp.h and add VP8Copy16x8
-432e5b55 make ALIGN_xxx naming consistent
-57606047 encoder: switch BPS to 32 instead of 16
-1b66bbe9 MIPS: dspr2: added optimization for function TransformColor_C
-c6d0f9e7 histogram: cosmetics
-f399d307 Merge changes I6eac17e5,I32d2b514
-9de9074c dec_neon: add TM8uv
-8e517eca bit_reader/kVP8NewRange: range_t -> uint8_t
-e1857139 dsp: initialize VP8PredChroma8 in VP8DspInit()
-e0c809ad Move Entropy methods to lossless.c
-a96ccf8f iosbuild: add x64_64 simulator support
-a0df5510 Remove handling for WEBP_HINT_GRAPH
-413dfc0c Move static method definition before its usage.
-0f235665 Update BackwardRefsWithLocalCache.
-d69e36ec Remove TODOs from lossless encoder code.
-fdaac8e0 Optmize VP8LGetBackwardReferences LZ77 references.
-2f0e2ba8 MIPS: dspr2: added optimization for function Select
-a3e79a46 Merge "WebPEncode: Support encoding same pic twice (even if modified)"
-e4f4dddb WebPEncode: Support encoding same pic twice (even if modified)
-cbc3fbb4 Merge "Updated VP8LGetBackwardReferences and color cache."
-95a9bd85 Updated VP8LGetBackwardReferences and color cache.
-54f2c14c MIPS: dspr2: added optimization for function FTransform
-aa42f423 MIPS: dspr2: Added optimization for function VP8LSubtractGreenFromBlueAndRed
-11a25f75 Merge "FlattenSimilarBlocks should only be tried when blending is possible."
-5cccdadf FlattenSimilarBlocks should only be tried when blending is possible.
-95ca44a7 MIPS: dspr2: added optimization for Disto4x4
-4171b672 backward_references.c: reindent after c8581b0
-c8581b06 Optimize BackwardReferences for RLE encoding.
-5798eee6 MIPS: dspr2: unfilters bugfix (Ie7b7387478a6b5c3f08691628ae00f059cf6d899)
-4167a3f5 Optimize backwardreferences
-d18554c3 Merge "webp/types.h: use inline for clang++/-std=c++11"
-7489b0e7 gif2webp: Add '-min-size' option to get best compression.
-77bdddf0 Speed up BackwardReferences
-6638710b webp/types.h: use inline for clang++/-std=c++11
-abf04205 Enable entropy based merge histo for (q<100)
-572022a3 filters_mips_dsp_r2.c: disable unfilters
-a28e21b1 MIPS: dspr2: Added optimization for function ClampedAddSubtractFull
-18d5a1ef MIPS: dspr2: added optimization for function ClampedAddSubtractHalf
-829a8c19 MIPS: dspr2: added optimization for ITransform
-c94ed49e gif2webp: Use the default hint instead of WEBP_HINT_GRAPH.
-653ace55 Increase the MAX_COLOR_CACHE_BITS from 9 to 10.
-919220c7 Change the logic adjusting the Histogram bits.
-53b096c0 Merge "Fix bug in VP8LCalculateEstimateForCacheSize."
-e912bd55 Fix bug in VP8LCalculateEstimateForCacheSize.
-541d7839 Merge "dec_neon: add RD4 intra predictor"
-f8cd0672 Merge "Makefile.vc: add a 'legacy' RTLIBCFG option"
-22881c99 dec_neon: add RD4 intra predictor
-613d281e update NEWS
-1304eb34 Merge "dec_neon: DC4: use pair-wise adds for top row"
-34c20c06 Makefile.vc: add a 'legacy' RTLIBCFG option
-7083006b Merge "dsp/dec_{neon,sse2}: VE4: normalize variable names"
-0db9031c dsp/dec_{neon,sse2}: VE4: normalize variable names
-b5bc1530 dec_neon: DC4: use pair-wise adds for top row
-5b90d8fe Unify the API between VP8BitWriter and VP8LBitWriter
-f7ada560 Merge changes I2e06907b,Ia9ed4ca6,I782282ff
-5beb6bf0 Merge "dec_neon: add VE4 intra predictor"
-eba6ce06 dec_neon: add DC4 intra predictor
-79abfbd9 dec_neon: add TM4 intra predictor
-fe395f0e dec_neon: add LD4 intra predictor
-32de385e dec_neon: add VE4 intra predictor
-72395ba9 Merge "Modify CostModel to allocate optimal memory."
-65e5eb8a gif2webp: Support GIF_DISPOSE_RESTORE_PREVIOUS
-e4c829ef gif2webp: Handle frames with odd offsets + disposal to background.
-c2b5a039 Modify CostModel to allocate optimal memory.
-b7a33d7e implement VE4/HE4/RD4/... in SSE2
-97c76f1f make VP8PredLuma4[] non-const and initialize array in VP8DspInit()
-0ea8c6c2 Merge "PrintReg: output to stderr"
-d7ff2f97 Merge "stopwatch.h: fix includes"
-f85ec712 PrintReg: output to stderr
-54edbf65 stopwatch.h: fix includes
-139142e4 Optimize BackwardReferenceHashChainFollowPath.
-5f36b68d enc/backward_references.c: fix indent
-e0e9960d Merge "sync version numbers to 0.4.2 release"
-64ac5144 sync version numbers to 0.4.2 release
-c24f8954 Simplify and speedup Backward refs computation.
-d1c359ef fix shared object build with -fvisibility=hidden
-a4c3a31b WEBP_TSAN_IGNORE_FUNCTION: fix gcc compat warning
-f358eeb8 add code for testing random incremental decoding in dwebp
-80247291 mark some init function as being safe for thread_sanitizer.
-79b5bdbf bit_reader.h: cosmetics: fix a typo
-6c673681 Improved near-lossless mode.
-0ce27e71 enc_mips32: workaround gcc-4.9 bug
-aca1b98f enc/vp8l.c: fix indent
-ca005027 Evaluate non-palette compression for palette image
-c8a87bb6 AssignSegments: quiet -Warray-bounds warning
-32f67e30 Merge "enc_neon: initialize vectors w/vdup_n_u32"
-fabc65da 1-3% faster encoding optimizing SSE_NxN functions
-7534d716 enc_neon: initialize vectors w/vdup_n_u32
-5f813912 Merge "Fix return code of EncodeImageInternal()"
-e321abe4 Fix return code of EncodeImageInternal()
-f82cb06a optimize palette ordering
-f545feee don't set the alpha value for histogram index image
-2d9b0a44 add WebPDispatchAlphaToGreen() to dsp
-1bd4c2ad Merge "Change Entropy based Histogram Combine heuristic."
-e295b8f1 Merge "iosbuild: cleanup"
-1be4e760 Merge "iosbuild: output autoconf req. on failure"
-d5e498d4 Change Entropy based Histogram Combine heuristic.
-47a2d8e1 fix MSVC float->int conversion warning
-041956f6 iosbuild: cleanup
-767eb402 iosbuild: output autoconf req. on failure
-35ad48b8 HistoHeapInit: correct positions allocation size
-45d9635f lossless: entropy clustering for high qualities.
-dc37df8c fix type warning for VS9_x64
-9f7d9e6d iosbuild: make iOS 6 the minimum requirement
-fdd6528b Remove unused VP8LDecoder member variable
-ea3bba5a Merge "rewrite Disto4x4 in enc_neon.c with intrinsic"
-f060dfc4 add lossless incremental decoding support
-ab70794d rewrite Disto4x4 in enc_neon.c with intrinsic
-d4471637 MIPS: dspr2: added optimization for function FilterLoop24
-2aef54d4 Merge "prepare VP8LDecodeImage for incremental decode"
-aed0f5a2 Merge "MIPS: dspr2: added optimization for function FilterLoop26"
-28630685 prepare VP8LDecodeImage for incremental decode
-248f3aed remove br->error_ field
-49e15044 MIPS: dspr2: added optimization for function FilterLoop26
-38128cb9 iobuild.sh: only install .h files in Headers
-c792d412 Premultiply with alpha during U/V downsampling
-0cc811d7 gif2webp: Background color correction
-d7167ff7 Amend the lossless spec according to issue #205, #206 and #224
-b901416b Record the lossless size stats.
-cddd3340 Add a WebPExtractAlpha function to dsp
-0716a98e fix indent after I0204949917836f74c0eb4ba5a7f4052a4797833b
-f9ced95a Optimize lossless decoding for trivial(ARB) codes.
-924fcfd9 Merge "webpmux: simplify InitializeConfig()"
-c0a462ca webpmux: simplify InitializeConfig()
-6986bb5e webpmux: fix indent
-f89e1690 webpmux: fix exit status on numeric value parse error
-2172cb62 Merge "webpmux: fix loop_count range check"
-e3b343ec Merge "examples: warn on invalid numeric parameters"
-0e23c487 webpmux: fix loop_count range check
-6208338a Merge "fix loop bug in DispatchAlpha()"
-d51f3e40 gif2webp: Handle frames with missing graphic control extension
-690b491a fix loop bug in DispatchAlpha()
-96d43a87 examples: warn on invalid numeric parameters
-3101f537 MIPS: dspr2: added optimization for TransformOne
-a6bb9b17 SSE2 for inverse Mult(ARGB)Row and ApplyAlphaMultiply
-d84a8ffd Remove default initialization of decoder status.
-be70b86c configure: simplify libpng-config invocation
-e0a99321 Rectify bug in lossless incremental decoding.
-e2502a97 MIPS: dspr2: added optimization for TransformAC3
-24e1072a MIPS: dspr2: added optimization for TransformDC
-c0e84df8 Merge "Slightly faster lossless decoding (1%)"
-8dd28bb5 Slightly faster lossless decoding (1%)
-f0103595 MIPS: dspr2: added optimization for ColorIndexInverseTransforms
-d3242aee make VP8LSetBitPos() set br->eos_ flag
-a9decb55 Lossless decoding: fix eos_ flag condition
-3fea6a28 fix erroneous dec->status_ setting
-80b8099f MIPS: dspr2: add some specific mips code to commit I2c3f2b12f8df15b785fad5a9c56316e954ae0c53
-e5640625 Merge "further refine the COPY_PATTERN optim for DecodeAlpha"
-854509fe enc/histogram.c: reindent after f4059d0
-34421964 Merge "~3-5% faster encoding optimizing PickBestIntra*()"
-865069c1 further refine the COPY_PATTERN optim for DecodeAlpha
-a5956228 added C-level optimization for DecodeAlphaData function
-187d379d add a fallback to ALPHA_NO_COMPRESSION
-a48a2d76 ~3-5% faster encoding optimizing PickBestIntra*()
-a6140194 ExUtilReadFromStdin: (windows) open stdin in bin mode
-e80eab1f webpmux: (windows) open stdout in binary mode
-e9bfb116 cwebp: (windows) open stdout in binary mode
-5927e15b example_util: add ExUtilSetBinaryMode
-30f3b75b webpmux man page: Clarify some title, descriptions and examples
-77d4c7e3 address cosmetic comments from patch #71380
-f75dfbf2 Speed up Huffman decoding for lossless
-637b3888 dsp/lossless: workaround gcc-4.9 bug on arm
-8323a903 dsp.h: collect gcc/clang version test macros
-e6c4b52f move static initialization of WebPYUV444Converters[] to the Init function.
-49911d4d Merge "fix indentation"
-f4059d0c Code cleanup for HistogramRemap.
-e632b092 fix indentation
-f5c04d64 Merge "add a DispatchAlpha() for SSE2 that handles 8 pixels at a time"
-fc98edd9 add a DispatchAlpha() for SSE2 that handles 8 pixels at a time
-73d361dd introduce VP8EncQuantize2Blocks to quantize two blocks at a time
-0b21c30b MIPS: dspr2: added optimization for EmitAlphaRGB
-953acd56 enc_neon: enable QuantizeBlock for aarch64
-f4ae1437 MIPS: mips32: code rebase
-56977154 MIPS: dspr2: added optimizations for VP8YuvTo*
-2523aa73 SmartRGBYUV: fix odd-width problem with pixel replication
-ee52dc4e fix some MSVC64 warning about float conversion
-3fca851a cpu: check for _MSC_VER before using msvc inline asm
-e2a83d71 faster RGB->YUV conversion function (~7% speedup)
-de2d03e1 Merge "Add smart RGB->YUV conversion option -pre 4"
-3fc4c539 Add smart RGB->YUV conversion option -pre 4
-b4dc4069 MIPS: dspr2: added optimization for (un)filters
-137e6090 Merge "configure: add work around for gcc-4.9 aarch64 bug"
-b61c9cec MIPS: dspr2: Optimization of some simple point-sampling functions
-e2b8cec0 configure: add work around for gcc-4.9 aarch64 bug
-98c54107 MIPS: mips32r2: added optimization for BSwap32
-dab702b3 Update PATENTS to reflect s/VP8/WebM/g
-b564f7c7 Merge "MIPS: detect mips32r6 and disable mips32r1 code"
-b7e5a5c4 MIPS: detect mips32r6 and disable mips32r1 code
-63c2fc02 Correctly use the AC_CANONICAL_* macros
-bb07022b Merge "cosmetics"
-e300c9d8 cosmetics
-0e519eea Merge "cosmetics: remove some extraneous 'extern's"
-3ef0f08a Merge "vp8enci.h: cosmetics: fix '*' placement"
-4c6dde37 bit_writer: cosmetics: rename kFlush() -> Flush()
-f7b4c48b cosmetics: remove some extraneous 'extern's
-b47fb00a vp8enci.h: cosmetics: fix '*' placement
-b5a36cc9 add -near_lossless [0..100] experimental option
-0524d9e5 dsp: detect mips64 & disable mips32 code
-d3485d96 cwebp.1: fix quality description placement
-29a9fe22 Merge tag 'v0.4.1'
-8af27718 update ChangeLog (tag: v0.4.1, origin/0.4.1)
-e09e9ff6 Record & log the image pre-processing time.
-f59c0b4b iosbuild.sh: specify optimization flags
-8d34ea3e update ChangeLog (tag: v0.4.1-rc1)
-dbc3da66 makefile.unix: add vwebp.1 to the dist target
-89a7c83c update ChangeLog
-ffe67ee9 Merge "update NEWS for the next release" into 0.4.1
-2def1fe6 gif2webp: dust up the help message
-fb668d78 remove -noalphadither option from README/vwebp.1
-e49f693b update NEWS for the next release
-cd013580 Merge "update AUTHORS" into 0.4.1
-268d01eb update AUTHORS
-85213b9b bump version to 0.4.1
-695f80ae Merge "restore mux API compatibility" into 0.4.1
-862d296c restore mux API compatibility
-8f6f8c5d remove the !WEBP_REFERENCE_IMPLEMENTATION tweak in Put8x8uv
-d713a696 Merge changes If4debc15,I437a5d5f into 0.4.1
-c2fc52e4 restore encode API compatibility
-793368e8 restore decode API compatibility
-b8984f31 gif2webp: fix compile with giflib 5.1.0
-222f9b1a gif2webp: simplify giflib version checking
-d2cc61b7 Extend MakeARGB32() to accept Alpha channel.
-4595b62b Merge "use explicit size of kErrorMessages[] arrays"
-157de015 Merge "Actuate memory stats for PRINT_MEMORY_INFO"
-fbda2f49 JPEG decoder: delay conversion to YUV to WebPEncode() call
-0b747b1b use explicit size of kErrorMessages[] arrays
-3398d81a Actuate memory stats for PRINT_MEMORY_INFO
-6f3202be Merge "move WebPPictureInit to picture.c"
-6c347bbb move WebPPictureInit to picture.c
-fb3acf19 fix configure message for multi-thread
-40b086f7 configure: check for _beginthreadex
-1549d620 reorder the YUVA->ARGB and ARGB->YUVA functions correctly
-c6461bfd Merge "extract colorspace code from picture.c into picture_csp.c"
-736f2a17 extract colorspace code from picture.c into picture_csp.c
-645daa03 Merge "configure: check for -Wformat-security"
-abafed86 configure: check for -Wformat-security
-fbadb480 split monolithic picture.c into picture_{tools,psnr,rescale}.c
-c76f07ec dec_neon/TransformAC3: initialize vector w/vcreate
-bb4fc051 gif2webp: Allow single-frame animations
-46fd44c1 thread: remove harmless race on status_ in End()
-5a1a7264 Merge "configure: check for __builtin_bswapXX()"
-6781423b configure: check for __builtin_bswapXX()
-6450c48d configure: fix iOS builds
-6422e683 VP8LFillBitWindow: enable fast path for 32-bit builds
-4f7f52b2 VP8LFillBitWindow: respect WEBP_FORCE_ALIGNED
-e458badc endian_inl.h: implement htoleXX with BSwapXX
-f2664d1a endian_inl.h: add BSwap16
-6fbf5345 Merge "configure: add --enable-aligned"
-dc0f479d configure: add --enable-aligned
-9cc69e2b Merge "configure: support WIC + OpenGL under mingw64"
-257adfb0 remove experimental YUV444 YUV422 and YUV400 code
-10f4257c configure: support WIC + OpenGL under mingw64
-380cca4f configure.ac: add AC_C_BIGENDIAN
-ee70a901 endian_inl.h: add BSwap64
-47779d46 endian_inl.h: add BSwap32
-d5104b1f utils: add endian_inl.h
-58ab6224 Merge "make alpha-detection loop in IsKeyFrame() in good x/y order"
-9d562902 make alpha-detection loop in IsKeyFrame() in good x/y order
-516971b1 lossless: Remove unaligned read warning
-b8b596f6 Merge "configure.ac: add an autoconf version prerequisite"
-34b02f8c configure.ac: add an autoconf version prerequisite
-e59f5360 neon: normalize vdup_n_* usage
-6ee7160d Merge changes I0da7b3d3,Idad2f278,I4accc305
-abc02f24 Merge "fix (uncompiled) typo"
-bc03670f neon: add INIT_VECTOR4
-6c1c632b neon: add INIT_VECTOR3
-dc7687e5 neon: add INIT_VECTOR2
-4536e7c4 add WebPMuxSetCanvasSize() to the mux API
-824eab10 fix (uncompiled) typo
-1f3e5f1e remove unused 'shift' argument and QFIX2 define
-8e867051 Merge "VP8LoadNewBytes: use __builtin_bswap32 if available"
-1b6a2635 Merge "Fix handling of weird GIF with canvas dimension 0x0"
-1da3d461 VP8LoadNewBytes: use __builtin_bswap32 if available
-1582e402 Fix handling of weird GIF with canvas dimension 0x0
-b8811dac Merge "rename interface -> winterface"
-db8b8b5f Fix logic in the GIF LOOP-detection parsing
-25aaddc8 rename interface -> winterface
-5584d9d2 make WebPSetWorkerInterface() check its arguments
-a9ef7ef9 Merge "cosmetics: update thread.h comments"
-c6af9991 Merge "dust up the help message"
-0a8b8863 dust up the help message
-a9cf3191 cosmetics: update thread.h comments
-27bfeee4 QuantizeBlock SSE2 Optimization:
-2bc0dc3e Merge "webpmux: warn when odd frame offsets are used"
-3114ebe4 Merge changes Id8edd3c1,Id418eb96,Ide05e3be
-c0726634 webpmux: warn when odd frame offsets are used
-c5c6b408 Merge "add alpha dithering for lossy"
-d5146784 examples/Android.mk: add cwebp
-ca0fa7c7 Android.mk: move dwebp to examples/Android.mk
-73d8fca0 Android.mk: add ENABLE_SHARED flag
-6e93317f muxread: fix out of bounds read
-8b0f6a48 Makefile.vc: fix CFLAGS assignment w/HAVE_AVX2=1
-bbe32df1 add alpha dithering for lossy
-79020767 Merge "make error-code reporting consistent upon malloc failure"
-77bf4410 make error-code reporting consistent upon malloc failure
-7a93c000 **/Makefile.am: remove unused AM_CPPFLAGS
-24e30805 Add an interface abstraction to the WebP worker thread implementation
-d6cd6358 Merge "fix orig_rect==NULL case"
-2bfd1ffa fix orig_rect==NULL case
-059e21c1 Merge "configure: move config.h to src/webp/config.h"
-f05fe006 properly report back encoding error code in WebPFrameCacheAddFrame()
-32b31379 configure: move config.h to src/webp/config.h
-90090d99 Merge changes I7c675e51,I84f7d785
-ae7661b3 makefiles: define WEBP_HAVE_AVX2 when appropriate
-69fce2ea remove the special casing for res->first in VP8SetResidualCoeffs
-6e61a3a9 configure: test for -msse2
-b9d2efc6 rename upsampling_mips32.c to yuv_mips32.c
-bdfeebaa dsp/yuv: move sse2 functions to yuv_sse2.c
-46b32e86 Merge "configure: set WEBP_HAVE_AVX2 when available"
-88305db4 Merge "VP8RandomBits2: prevent signed int overflow"
-73fee88c VP8RandomBits2: prevent signed int overflow
-db4860b3 enc_sse2: prevent signed int overflow
-3fdaf4d2 Merge "real fix for longjmp warning"
-385e3340 real fix for longjmp warning
-230a0555 configure: set WEBP_HAVE_AVX2 when available
-a2ac8a42 restore original value_/range_ field order
-5e2ee56f Merge "remove libwebpdspdecode dep on libwebpdsp_avx2"
-61362db5 remove libwebpdspdecode dep on libwebpdsp_avx2
-42c447ae Merge "lossy bit-reader clean-up:"
-479ffd8b Merge "remove unused #include's"
-9754d39a Merge "strong filtering speed-up (~2-3% x86, ~1-2% for NEON)"
-158aff9b remove unused #include's
-09545eea lossy bit-reader clean-up:
-ea8b0a17 strong filtering speed-up (~2-3% x86, ~1-2% for NEON)
-6679f899 Optimize VP8SetResidualCoeffs.
-ac591cf2 fix for gcc-4.9 warnings about longjmp + local variables
-4dfa86b2 dsp/cpu: NaCl has no support for xgetbv
-4c398699 Merge "cwebp: fallback to native webp decode in WIC builds"
-33aa497e Merge "cwebp: add some missing newlines in longhelp output"
-c9b340a2 fix missing WebPInitAlphaProcessing call for premultiplied colorspace output
-57897bae Merge "lossless_neon: use vcreate_*() where appropriate"
-6aa4777b Merge "(enc|dec)_neon: use vcreate_*() where appropriate"
-0d346e41 Always reinit VP8TransformWHT instead of hard-coding
-7d039fc3 cwebp: fallback to native webp decode in WIC builds
-d471f424 cwebp: add some missing newlines in longhelp output
-bf0e0030 lossless_neon: use vcreate_*() where appropriate
-9251c2f6 (enc|dec)_neon: use vcreate_*() where appropriate
-399b916d lossy decoding: correct alpha-rescaling for YUVA format
-78c12ed8 Merge "Makefile.vc: add rudimentary avx2 support"
-dc5b122f try to remove the spurious warning for static analysis
-ddfefd62 Makefile.vc: add rudimentary avx2 support
-a8911643 Merge "simplify VP8LInitBitReader()"
-fdbcd44d simplify VP8LInitBitReader()
-7c004287 makefile.unix: add rudimentary avx2 support
-515e35cf Merge "add stub dsp/enc_avx2.c"
-a05dc140 SSE2: yuv->rgb speed-up for point-sampling
-178e9a69 add stub dsp/enc_avx2.c
-1b99c09c Merge "configure: add a test for -mavx2"
-fe728071 configure: add a test for -mavx2
-e46a247c cpu: fix check for __cpuidex availability
-176fda26 fix the bit-writer for lossless in 32bit mode
-541784c7 dsp.h: add a check for AVX2 / define WEBP_USE_AVX2
-bdb151ee dsp/cpu: add AVX2 detection
-ab9f2f86 Merge "revamp the point-sampling functions by processing a full plane"
-a2f8b289 revamp the point-sampling functions by processing a full plane
-ef076026 use decoder's DSP functions for autofilter
-2b5cb326 Merge "dsp/cpu: add AVX detection"
-df08e67e dsp/cpu: add AVX detection
-e2f405c9 Merge "clean-up and slight speed-up in-loop filtering SSE2"
-f60957bf clean-up and slight speed-up in-loop filtering SSE2
-9fc3ae46 .gitattributes: treat .ppm as binary
-3da924b5 Merge "dsp/WEBP_USE_NEON: test for __aarch64__"
-c7164490 Android.mk: always include *_neon.c in the build
-a577b23a dsp/WEBP_USE_NEON: test for __aarch64__
-54bfffca move RemapBitReader() from idec.c to bit_reader code
-34168ecb Merge "remove all unused layer code"
-f1e77173 remove all unused layer code
-b0757db7 Code cleanup for VP8LGetHistoImageSymbols.
-5fe628d3 make the token page size be variable instead of fixed 8192
-f948d08c memory debug: allow setting pre-defined malloc failure points
-ca3d746e use block-based allocation for backward refs storage, and free-lists
-1ba61b09 enable NEON intrinsics in aarch64 builds
-b9d2bb67 dsp/neon.h: coalesce intrinsics-related defines
-b5c75258 iosbuild: add support for iOSv7/aarch64
-9383afd5 Reduce number of memory allocations while decoding lossless.
-888e63ed Merge "dsp/lossless: prevent signed int overflow in left shift ops"
-8137f3ed Merge "instrument memory allocation routines for debugging"
-2aa18736 instrument memory allocation routines for debugging
-d3bcf72b Don't allocate VP8LHashChain, but treat like automatic object
-bd6b8619 dsp/lossless: prevent signed int overflow in left shift ops
-b7f19b83 Merge "dec/vp8l: prevent signed int overflow in left shift ops"
-29059d51 Merge "remove some uint64_t casts and use."
-e69a1df4 dec/vp8l: prevent signed int overflow in left shift ops
-cf5eb8ad remove some uint64_t casts and use.
-38e2db3e MIPS: MIPS32r1: Added optimization for HistogramAdd.
-e0609ade dwebp: fix exit code on webp load failure
-bbd358a8 Merge "example_util.h: avoid forward declaring enums"
-8955da21 example_util.h: avoid forward declaring enums
-6d6865f0 Added SSE2 variants for Average2/3/4
-b3a616b3 make HistogramAdd() a pointer in dsp
-c8bbb636 dec_neon: relocate some inline-asm defines
-4e393bb9 dec_neon: enable intrinsics-only functions
-ba99a922 dec_neon: use positive tests for USE_INTRINSICS
-69058ff8 Merge "example_util: add ExUtilDecodeWebPIncremental"
-a7828e8b dec_neon: make WORK_AROUND_GCC conditional on version
-3f3d717a Merge "enc_neon: enable intrinsics-only functions"
-de3cb6c8 Merge "move LOCAL_GCC_VERSION def to dsp.h"
-1b2fe14d example_util: add ExUtilDecodeWebPIncremental
-ca49e7ad Merge "enc_neon: move Transpose4x4 to dsp/neon.h"
-ad900abd Merge "fix warning about size_t -> int conversion"
-4825b436 fix warning about size_t -> int conversion
-42b35e08 enc_neon: enable intrinsics-only functions
-f937e012 move LOCAL_GCC_VERSION def to dsp.h
-5e1a17ef enc_neon: move Transpose4x4 to dsp/neon.h
-c7b92a5a dec_neon: (WORK_AROUND_GCC) delete unused Load4x8
-8e5f90b0 Merge "make ExUtilLoadWebP() accept NULL bitstream param."
-05d4c1b7 Merge "cwebp: add webpdec"
-ddeb6ac8 cwebp: add webpdec
-35d7d095 Merge "Reduce memory footprint for encoding WebP lossless."
-0b896101 Reduce memory footprint for encoding WebP lossless.
-f0b65c9a make ExUtilLoadWebP() accept NULL bitstream param.
-9c0a60cc Merge "dwebp: move webp decoding to example_util"
-1d62acf6 MIPS: MIPS32r1: Added optimization for HuffmanCost functions.
-4a0e7390 dwebp: move webp decoding to example_util
-c0220460 Merge "Bugfix: Incremental decode of lossy-alpha"
-8c7cd722 Bugfix: Incremental decode of lossy-alpha
-7955152d MIPS: fix error with number of registers.
-b1dabe37 Merge "Move the HuffmanCost() function to dsp lib"
-75b12006 Move the HuffmanCost() function to dsp lib
-2772b8bd MIPS: fix assembler error revealed by clang's debug build
-6653b601 enc_mips32: fix unused symbol warning in debug
-8dec1209 enc_mips32: disable ITransform(One) in debug builds
-98519dd5 enc_neon: convert Disto4x4 to intrinsics
-fe9317c9 cosmetics:
-953b0746 enc_neon: cosmetics
-a9fc697c Merge "WIP: extract the float-calculation of HuffmanCost from loop"
-3f84b521 Merge "replace some mult-long (vmull_u8) with mult-long-accumulate (vmlal_u8)"
-4ae0533f MIPS: MIPS32r1: Added optimizations for ExtraCost functions.
-b30a04cf WIP: extract the float-calculation of HuffmanCost from loop
-a8fe8ce2 Merge "NEON intrinsics version of CollectHistogram"
-95203d2d NEON intrinsics version of CollectHistogram
-7ca2e74b replace some mult-long (vmull_u8) with mult-long-accumulate (vmlal_u8)
-41c6efbd fix lossless_neon.c
-8ff96a02 NEON intrinsics version of FTransform
-0214f4a9 Merge "MIPS: MIPS32r1: Added optimizations for FastLog2"
-baabf1ea MIPS: MIPS32r1: Added optimizations for FastLog2
-3d49871d NEON functions for lossless coding
-3fe02915 MIPS: MIPS32r1: Added optimizations for SSE functions.
-c503b485 Merge "fix the gcc-4.6.0 bug by implementing alternative method"
-abe6f487 fix the gcc-4.6.0 bug by implementing alternative method
-5598bdec enc_mips32.c: fix file mode
-2b1b4d5a MIPS: MIPS32r1: Add optimization for GetResidualCost
-f0a1f3cd Merge "MIPS: MIPS32r1: Added optimization for FTransform"
-7231f610 MIPS: MIPS32r1: Added optimization for FTransform
-869eaf6c ~30% encoding speedup: use NEON for QuantizeBlock()
-f758af6b enc_neon: convert FTransformWHT to intrinsics
-7dad095b MIPS: MIPS32r1: Added optimization for Disto4x4 (TTransform)
-2298d5f3 MIPS: MIPS32r1: Added optimization for QuantizeBlock
-e88150c9 Merge "MIPS: MIPS32r1: Add optimization for ITransform"
-de693f25 lossless_neon: disable VP8LConvert* functions
-4143332b NEON intrinsics for encoding
-0ca2914b MIPS: MIPS32r1: Add optimization for ITransform
-71bca5ec dec_neon: use vst_lane instead of vget_lane
-bf061052 Intrinsics NEON version of TransformOne
-19c6f1ba Merge "dec_neon: use vld?_lane instead of vset?_lane"
-7a94c0cf upsampling_neon: drop NEON suffix from local functions
-d14669c8 upsampling_sse2: drop SSE2 suffix from local functions
-2ca42a4f enc_sse2: drop SSE2 suffix from local functions
-d038e619 dec_sse2: drop SSE2 suffix from local functions
-fa52d752 dec_neon: use vld?_lane instead of vset?_lane
-c520e77d cosmetic: fix long line
-4b0f2dae Merge "add intrinsics NEON code for chroma strong-filtering"
-e351ec07 add intrinsics NEON code for chroma strong-filtering
-aaf734b8 Merge "Add SSE2 version of forward cross-color transform"
-c90a902e Add SSE2 version of forward cross-color transform
-bc374ff3 Use histogram_bits to initalize transform_bits.
-2132992d Merge "Add strong filtering intrinsics (inner and outer edges)"
-5fbff3a6 Add strong filtering intrinsics (inner and outer edges)
-d4813f0c Add SSE2 function for Inverse Cross-color Transform
-26029568 dec_neon: add strong loopfilter intrinsics
-cca7d7ef Merge "add intrinsics version of SimpleHFilter16NEON()"
-1a05dfa7 windows: fix dll builds
-d6c50d8a Merge "add some colorspace conversion functions in NEON"
-4fd7c82e SSE2 variants of Subtract-Green: Rectify loop condition
-97e5fac3 add some colorspace conversion functions in NEON
-b9a7a45f add intrinsics version of SimpleHFilter16NEON()
-daccbf40 add light filtering NEON intrinsics
-af444608 fix typo in STORE_WHT
-6af6b8e1 Tune HistogramCombineBin for large images.
-af93bdd6 use WebPSafe[CM]alloc/WebPSafeFree instead of [cm]alloc/free
-51f406a5 lossless_sse2: relocate VP8LDspInitSSE2 proto
-0f4f721b separate SSE2 lossless functions into its own file
-514fc251 VP8LConvertFromBGRA: use conversion function pointers
-6d2f3527 dsp/dec: TransformDCUV: use VP8TransformDC
-defc8e1b Merge "fix out-of-bound read during alpha-plane decoding"
-fbed3643 Merge "dsp: reuse wht transform from dec in encoder"
-d8467084 Merge "Add SSE2 version of ARGB -> BGR/RGB/... conversion functions"
-207d03b4 fix out-of-bound read during alpha-plane decoding
-d1b33ad5 2-5% faster trellis with clang/MacOS (and ~2-3% on ARM)
-369c26dd Add SSE2 version of ARGB -> BGR/RGB/... conversion functions
-df230f27 dsp: reuse wht transform from dec in encoder
-80e218d4 Android.mk: fix build with APP_ABI=armeabi-v7a-hard
-59daf083 Merge "cosmetics:"
-53622008 cosmetics:
-3e7f34a3 AssignSegments: quiet array-bounds warning
-3c2ebf58 Merge "UpdateHistogramCost: avoid implicit double->float"
-cf821c82 UpdateHistogramCost: avoid implicit double->float
-312e638f Extend the search space for GetBestGreenRedToBlue
-1c58526f Fix few nits
-fef22704 Optimize and re-structure VP8LGetHistoImageSymbols
-068b14ac Optimize lossless decoding.
-5f0cfa80 Do a binary search to get the optimum cache bits.
-24ca3678 Merge "allow 'cwebp -o -' to emit output to stdout"
-e12f874e allow 'cwebp -o -' to emit output to stdout
-2bcad89b allow some more stdin/stout I/O
-84ed4b3a fix cwebp.1 typos after patch #69199
-65b99f1c add a -z option to cwebp, and WebPConfigLosslessPreset() function
-30176619 4-5% faster trellis by removing some unneeded calculations.
-687a58ec histogram.c: reindent after b33e8a0
-06d456f6 Merge "~3-4% faster lossless encoding"
-c60de260 ~3-4% faster lossless encoding
-42eb06fc Merge "few cosmetics after patch #69079"
-82af8264 few cosmetics after patch #69079
-b33e8a05 Refactor code for HistogramCombine.
-ca1bfff5 Merge "5-10% encoding speedup with faster trellis (-m 6)"
-5aeeb087 5-10% encoding speedup with faster trellis (-m 6)
-82ae1bf2 cosmetics: normalize VP8GetCPUInfo checks
-e3dd9243 Merge "Refactor GetBestPredictorForTile for future tuning."
-206cc1be Refactor GetBestPredictorForTile for future tuning.
-3cb84062 Merge "speed-up trellis quant (~5-10% overall speed-up)"
-b66f2227 Merge "lossy encoding: ~3% speed-up"
-4287d0d4 speed-up trellis quant (~5-10% overall speed-up)
-390c8b31 lossy encoding: ~3% speed-up
-9a463c4a Merge "dec_neon: convert TransformWHT to intrinsics"
-e8605e96 Merge "dec_neon: add ConvertU8ToS16"
-4aa3e412 MIPS: MIPS32r1: rescaler bugfix
-c16cd99a Speed up lossless encoder.
-9d6b5ff1 dec_neon: convert TransformWHT to intrinsics
-2ff0aae2 dec_neon: add ConvertU8ToS16
-77a8f919 fix compilation with USE_YUVj flag
-4acbec1b Merge changes I3b240ffb,Ia9370283,Ia2d28728
-2719bb7e dec_neon: TransformAC3: work on packed vectors
-b7b60ca1 dec_neon: add SaturateAndStore4x4
-b7685d73 Rescale: let ImportRow / ExportRow be pointer-to-function
-e02f16ef dec_neon.c: convert TransformDC to intrinsics
-9cba963f add missing file
-8992ddb7 use static clipping tables
-0235d5e4 1-2% faster quantization in SSE2
-b2fbc36c fix VC12-x64 warning
-6e37cb94 Merge "cosmetics: backward_references.c: reindent after a7d2ee3"
-a42ea974 cosmetics: backward_references.c: reindent after a7d2ee3
-6c327442 Merge "fix missing __BIG_ENDIAN__ definition on some platform"
-a8b6aad1 fix missing __BIG_ENDIAN__ definition on some platform
-fde2904b Increase initial buffer size for VP8L Bit Writer.
-a7d2ee39 Optimize cache estimate logic.
-7fb6095b Merge "dec_neon.c: add TransformAC3"
-bf182e83 VP8LBitWriter: use a bit-accumulator
-3f40b4a5 Merge "MIPS: MIPS32r1: clang macro warning resolved"
-1684f4ee WebP Decoder: Mark some truncated bitstreams as invalid
-acbedac4 MIPS: MIPS32r1: clang macro warning resolved
-228e4877 dec_neon.c: add TransformAC3
-393f89b7 Android.mk: avoid gcc-specific flags with clang
-32aeaf11 revamp VP8LColorSpaceTransform() a bit
-0c7cc4ca Merge "Don't dereference NULL, ensure HashChain fully initialized"
-391316fe Don't dereference NULL, ensure HashChain fully initialized
-926ff402 WEBP_SWAP_16BIT_CSP: remove code dup
-1d1cd3bb Fix decode bug for rgbA_4444/RGBA_4444 color-modes.
-939e70e7 update AUTHORS file
-8934a622 cosmetics: *_mips32.c
-dd438c9a MIPS: MIPS32r1: Optimization of some simple point-sampling functions. PATCH [6/6]
-53520911 Added support for calling sampling functions via pointers.
-d16c6974 MIPS: MIPS32r1: Optimization of filter functions. PATCH [5/6]
-04336fc7 MIPS: MIPS32r1: Optimization of function TransformOne. PATCH [4/6]
-92d8fc7d MIPS: MIPS32r1: Optimization of function WebPRescalerImportRow. PATCH [3/6]
-bbc23ff3 parse one row of intra modes altogether
-a2f608f9 Merge "MIPS: MIPS32r1: Optimization of function WebPRescalerExportRow. [2/6]"
-88230854 MIPS: MIPS32r1: Optimization of function WebPRescalerExportRow. [2/6]
-c5a5b028 decode mt+incremental: fix segfault in debug builds
-9882b2f9 always use fast-analysis for all methods.
-000adac0 Merge "autoconf: update ax_pthread.m4"
-2d2fc37d update .gitignore
-5bf4255a Merge "Make it possible to avoid automagic dependencies"
-c1cb1933 disable NEON for arm64 platform
-73a304e9 Make it possible to avoid automagic dependencies
-4d493f8d MIPS: MIPS32r1: Decoder bit reader function optimized. PATCH [1/6]
-c741183c make WebPCleanupTransparentArea work with argb picture
-5da18552 add a decoding option to flip image vertically
-00c3c4e1 Merge "add man/vwebp.1"
-2c6bb428 add man/vwebp.1
-ea59a8e9 Merge "Merge tag 'v0.4.0'"
-7574bed4 fix comments related to array sizes
-0b5a90fd dwebp.1: fix option formatting
-effcb0fd Merge tag 'v0.4.0'
-7c76255d autoconf: update ax_pthread.m4
-fff2a11b make -short work with -print_ssim, -print_psnr, etc.
-68e7901d update ChangeLog (tag: v0.4.0-rc1, tag: v0.4.0, origin/0.4.0)
-256e4333 update NEWS description with new general features
-29625340 Merge "gif2webp: don't use C99 %zu" into 0.4.0
-3b9f9dd0 gif2webp: don't use C99 %zu
-b5b2e3c7 cwebp: fix metadata output w/lossy+alpha
-ad26df1a makefile.unix: clean up libgif2webp_util.a
-c3b45570 update Changelog
-ca841121 Merge "bump version to 0.4.0" into 0.4.0
-8c524db8 bump version to 0.4.0
-eec2398c update AUTHORS & .mailmap
-b9bbf6a1 update NEWS for 0.4.0
-c72e0811 Merge "dec/webp.c: don't wait for data before reporting w/h"
-5ad65314 dec/frame.c: fix formatting
-f7fc4bc8 dec/webp.c: don't wait for data before reporting w/h
-66a32af5 Merge "NEON speed up"
-26d842eb NEON speed up
-f307f98b Merge "webpmux: let -- stop parameter parsing"
-fe051da7 Merge "README: add a section on gif2webp"
-6fd2bd62 Merge "manpage pedantry"
-4af19007 README: add a section on gif2webp
-6f36ade9 manpage pedantry
-f9016cb9 README: update dwebp options
-b4fa0a47 webpmux: let -- stop parameter parsing
-a9a20acf gif2webp: Add a multi-threaded encode option
-495bef41 fix bug in TrellisQuantize
-605a7127 simplify __cplusplus ifdef
-33109f99 Merge "drop: ifdef __cplusplus checks from C files"
-7f9de0b9 Merge changes I994a5587,I8467bb71,I13b50688,I1e2c9c7b
-5459030b gif2webp: let -- stop parameter parsing
-a4b0aa06 vwebp: let -- stop parameter parsing
-98af68fe cwebp: let -- stop parameter parsing
-a33831e2 dwebp: let -- stop parameter parsing
-36301249 add some checks on error paths
-ce4c7139 Merge "autoconf: add --disable-wic"
-5227d991 drop: ifdef __cplusplus checks from C files
-f6453559 dwebp.1: fix typo
-f91034f2 Merge "cwebp: print metadata stats when no output file is given"
-d4934553 gif2webp: Backward compatibility for giflib version <= 4.1.3
-4c617d32 gif2webp: Disable output of ICC profile by default
-73b731fb introduce a special quantization function for WHT
-41c0cc4b Make Forward WHT transform use 32bit fixed-point calculation
-a3359f5d Only compute quantization params once
-70490437 cwebp: print metadata stats when no output file is given
-d513bb62 * fix off-by-one zthresh calculation * remove the sharpening for non luma-AC coeffs * adjust the bias a little bit to compensate for this
-ad9dec0c Merge "cosmetics: dwebp: fix local function name format"
-f737f037 Merge "dwebp: remove a dead store"
-3c3a70da Merge "makefile.unix: install binaries in $(DESTDIR)/bin/"
-150b655f Merge "Android.mk: add some release compile flags"
-dbebd33b cosmetics: dwebp: fix local function name format
-27749951 dwebp: remove a dead store
-a01e04fe autoconf: add --disable-wic
-5009b227 makefile.unix: install binaries in $(DESTDIR)/bin/
-bab30fca Merge "fix -print_psnr / ssim options"
-ebef7fb3 fix -print_psnr / ssim options
-cb637855 Merge "fix bug due to overzealous check in WebPPictureYUVAToARGB()"
-8189885b Merge "EstimateBestFilter: use an int to iterate WEBP_FILTER_TYPE"
-4ad7d335 Android.mk: add some release compile flags
-c12e2369 cosmetics: fix a few typos
-6f104034 fix bug due to overzealous check in WebPPictureYUVAToARGB()
-3f6c35c6 EstimateBestFilter: use an int to iterate WEBP_FILTER_TYPE
-cc55790e Merge changes I8bb7a4dc,I2c180051,I021a014f,I8a224a62
-c536afb5 Merge "cosmetics: fix some typos"
-cbdd3e6e add a -dither dithering option to the decoder
-e8124012 Updated iosbuild.sh for XCode 5.x
-4931c329 cosmetics: fix some typos
-05aacf77 mux: add some missing casts
-617d9348 enc/vp8l: add a missing cast
-46db2865 idec: add some missing casts
-b524e336 ErrorStatusLossless: correct return type
-cb261f79 fix a descaling bug for vertical/horizontal U/V interpolation
-bcb3955c Merge changes I48968468,I181bc736
-73f52133 gif2webp: Add a mixed compression mode
-6198715e demux: split chunk parsing from ParseVP8X
-d2e3f4e6 demux: add a tail pointer for chunks
-87cffcc3 demux: cosmetics: s/has_frames/is_animation/
-e18e6677 demux: strictly enforce the animation flag
-c4f39f4a demux: cosmetics: remove a useless break
-61cb884d demux: (non-exp) fail if the fragmented flag is set
-ff379db3 few % speedup of lossless encoding
-df3649a2 remove all disabled code related to P-frames
-6d0cb3de Merge "gif2webp: kmin = 0 should suppress key-frame addition."
-36555983 gif2webp: kmin = 0 should suppress key-frame addition.
-7708e609 Merge "detect flatness in blocks and favor DC prediction"
-06b1503e Merge "add comment about the kLevelsFromDelta[][] LUT generation"
-5935259c add comment about the kLevelsFromDelta[][] LUT generation
-e3312ea6 detect flatness in blocks and favor DC prediction
-ebc9b1ee Merge "VPLBitReader bugfix: Catch error if bit_pos > LBITS too."
-96ad0e0a VPLBitReader bugfix: Catch error if bit_pos > LBITS too.
-a014e9c9 tune quantization biases toward higher precision
-1e898619 add helpful PrintBlockInfo() function
-596a6d73 make use of 'extern' consistent in function declarations
-c8d48c6e Merge "extract random utils to their own file util/random.[ch]"
-98aa33cf extract random utils to their own file util/random.[ch]
-432a723e Merge "swig: add basic go bindings"
-fab618b5 Merge "rename libwebp.i -> libwebp.swig"
-e4e7fcd6 swig: add basic go bindings
-d3408720 Merge "fast auto-determined filtering strength"
-f8bfd5cd fast auto-determined filtering strength
-ac0bf951 small clean-up in ExpandMatrix()
-1939607e rename libwebp.i -> libwebp.swig
-43148b6c filtering: precompute ilimit and hev_threshold
-18f992ec simplify f_inner calculation a little
-241d11f1 add missing const
-86c0031e add a 'format' field to WebPBitstreamFeatures
-dde91fde Demux: Correct the extended format validation
-5d6c5bd2 add entry for '-resize' option in cwebp's man
-7c098d18 Use some gamma-curve range compression when computing U/V average
-0b2b0504 Use deterministic random-dithering during RGB->YUV conversion
-8a2fa099 Add a second multi-thread method
-7d6f2da0 Merge "up to 20% faster multi-threaded decoding"
-266f63ea Merge "libwebp.jar: build w/Java 1.6 for Android compat"
-0532149c up to 20% faster multi-threaded decoding
-38efdc2e Simplify the gif2webp tool: move the optimization details to util
-de899516 libwebp.jar: build w/Java 1.6 for Android compat
-cb221552 Decode a full row of bitstream before reconstructing
-dca8a4d3 Merge "NEON/simple loopfilter: avoid q4-q7 registers"
-9e84d901 Merge "NEON/TransformWHT: avoid q4-q7 registers"
-fc10249b NEON/simple loopfilter: avoid q4-q7 registers
-2f09d63e NEON/TransformWHT: avoid q4-q7 registers
-77585a2b Merge "use a macrofunc for setting NzCoeffs bits"
-d155507c Merge "use HINT_GRAPH as image_hint for gif source"
-9c561646 Merge "only print GIF_DISPOSE_WARNING once"
-05879865 use HINT_GRAPH as image_hint for gif source
-0b28d7ab use a macrofunc for setting NzCoeffs bits
-f9bbc2a0 Special-case sparse transform
-00125196 gif2webp: detect and flatten uniformly similar blocks
-0deaf0fa only print GIF_DISPOSE_WARNING once
-6a8c0eb7 Merge "small optimization in segment-smoothing loop"
-f7146bc1 small optimization in segment-smoothing loop
-5a7533ce small gif2webp fix
-4df0c89e Merge changes Ic697660c,I27285521
-5b2e6bd3 Android.mk: add a dwebp target
-f910a84e Android.mk: update build flags
-63f9aba4 special-case WHT transform when there's only DC
-80911aef Merge "7-8% faster decoding by rewriting GetCoeffs()"
-606c4304 gif2webp: Improved compression for lossy animated WebP
-fb887f7f gif2webp: Different kmin/kmax defaults for lossy and lossless
-2a981366 7-8% faster decoding by rewriting GetCoeffs()
-92d47e4c improve VP8L signature detection by checking the version bits too
-5cd43e43 Add -incremental option to dwebp
-54b8e3f6 webpmux: DisplayInfo(): remove unnecessary error checks.
-40ae3520 fix memleak in WebPIDelete()
-d9662658 mux.h doc: WebPMuxGetFrame() can return WEBP_MUX_MEMORY_ERROR too.
-0e6747f8 webpmux -info: display dimensions and has_alpha per frame
-d78a82c4 Sanity check for underflow
-8498f4bf Merge "remove -Wshadow warnings"
-e89c6fc8 Avoid a potential memleak
-3ebe1757 Merge "break down the proba 4D-array into some handy structs"
-6a44550a break down the proba 4D-array into some handy structs
-2f5e8934 remove -Wshadow warnings
-bf3a29b3 Merge "add proper WEBP_HAVE_GIF and WEBP_HAVE_GL flags"
-2b0a7593 Merge "fix some warnings from static analysis"
-22dd07ce mux.h: Some doc corrections
-79ff0346 add proper WEBP_HAVE_GIF and WEBP_HAVE_GL flags
-d51f45f0 fix some warnings from static analysis
-d134307b fix conversion warning on MSVC
-d538cea8 gif2webp: Support a 'min' and 'max' key frame interval
-80b54e1c allow search with token buffer loop and fix PARTITION0 problem
-b7d4e042 add VP8EstimateTokenSize()
-10fddf53 enc/quant.c: silence a warning
-399cd456 Merge "fix compile error on ARM/gcc"
-9f24519e encoder: misc rate-related fixes
-c663bb21 Merge "simplify VP8IteratorSaveBoundary() arg passing"
-fa46b312 Demux.h: Correct a method name reference
-f8398c9d fix compile error on ARM/gcc
-f691f0e4 simplify VP8IteratorSaveBoundary() arg passing
-42542be8 up to 6% faster encoding with clang compiler
-93402f02 multi-threaded segment analysis
-7e2d6595 Merge "remove the PACK() bit-packing tricks"
-c13fecf9 remove the PACK() bit-packing tricks
-2fd091c9 Merge "use NULL for lf_stats_ testing, not bool"
-b11c9d62 dwebp: use default dct_method
-4bb8465f Merge "(de)mux.h: wrap pseudo-code in /* */"
-cfb56b17 make -pass option work with token buffers
-5416aab4 (de)mux.h: wrap pseudo-code in /* */
-35dba337 use NULL for lf_stats_ testing, not bool
-733a7faa enc->Iterator memory cleanup
-e81fac86 Add support for "no blend" in webpmux binary
-3b80bc48 gif2webp: Separate out each step into a method
-bef7e9cc Add doc precision about demux object keeping pointers to data.
-61405a14 dwebp: enable stdout output with WIC
-6eabb886 Merge "Animated WebP: add "do no blend" option to spec"
-be20decb fix compilation for BITS 24
-e58cc137 Merge "dwebp: s/unsigned char/uint8_t/"
-72501d43 dwebp: s/unsigned char/uint8_t/
-2c9633e8 Merge "gif2webp: Insert independent frames at regular intervals."
-f0d6a14b gif2webp: Insert independent frames at regular intervals.
-b25a6fbf yuv.h: fix indent
-ede3602e Merge "cosmetics: fix indent"
-3a65122a dwebp: fix stdout related output
-388a7249 cosmetics: fix indent
-4c7322c8 Merge "dsp: msvc compatibility"
-d50c7e32 Merge "5-7% faster SSE2 versions of YUV->RGB conversion functions"
-b8ab7847 Merge "simplify upsampler calls: only allow 'bottom' to be NULL"
-df6cebfa 5-7% faster SSE2 versions of YUV->RGB conversion functions
-ad6ac32d simplify upsampler calls: only allow 'bottom' to be NULL
-a5e8afaf output to stdout if file name is "-"
-f358450f dsp: msvc compatibility
-43a7c8eb Merge "cosmetics"
-4c5f19c1 Merge "bit_reader.h: cosmetics"
-f72fab70 cosmetics
-14dd5e78 fix const-ness
-b20aec49 Merge "Support for 'do not blend' option in vwebp"
-dcf65222 Support for 'do not blend' option in vwebp
-d5bad033 Animated WebP: add "do no blend" option to spec
-a2f5f73d Merge "Support for "Do not blend" in mux and demux libraries"
-e081f2f3 Pack code & extra_bits to Struct (VP8LPrefixCode).
-6284854b Support for "Do not blend" in mux and demux libraries
-f486aaa9 Merge "slightly faster ParseIntraMode"
-d1718632 slightly faster ParseIntraMode
-3ceca8ad bit_reader.h: cosmetics
-69257f70 Create LUT for PrefixEncode.
-988b7084 add WebPWorkerExecute() for convenient bypass
-06e24987 Merge "VP8EncIterator clean-up"
-de4d4ad5 VP8EncIterator clean-up
-7bbe9529 Merge "cosmetics: thread.c: drop a redundant comment"
-da411485 cosmetics: thread.c: drop a redundant comment
-feb4b6e6 thread.h: #ifdef when checking WEBP_USE_THREAD
-8924a3a7 thread.c: drop WebPWorker prefix from static funcs
-1aed8f2a Merge "fix indent"
-4038ed15 fix indent
-1693fd9b Demux: A new state WEBP_DEMUX_PARSE_ERROR
-8dcae8b3 fix rescaling-with-alpha inaccuracy
-11249abf Merge changes I9b4dc36c,I4e0eef4d
-52508a1f Mux: support parsing unknown chunks within a frame/fragment.
-05db0572 WebPMuxSetChunk: remove unused variable
-8ba1bf61 Stricter check for presence of alpha when writing lossless images
-a03c3516 Demux: WebPIterator now also denotes if the frame has alpha.
-6df743a3 Decoder: handle fragments case correctly too.
-faa4b07e Support for unknown chunks in mux library
-7d60bbc6 Speed up HashChainFindCopy function.
-66740140 Speedup Alpha plane encoding.
-b7346a1e 0.1 % speedup to decoding
-c606182e webp-container-spec: Tighten language added by last
-a34a5029 pngdec: output error messages from libpng
-e84c625d Merge "Detect canvas and image size mismatch in decoder."
-f626fe2e Detect canvas and image size mismatch in decoder.
-f5fbdee0 demux: stricter image bounds check
-30c8158a add extra assert in Huffman decode code
-8967b9f3 SSE2 for lossless decoding (critical) functions.
-699d80ea Jump-lookup for Huffman coding
-c34307ab fix some VS9 warnings about type conversion
-eeada35c pngdec: add missing include
-54b65108 gif2webp: If aligning to even offsets, extra pixels should be transparent
-0bcf5ce3 Merge "remove a malloc() in case we're using only FILTER_NONE for alpha"
-2c07143b remove a malloc() in case we're using only FILTER_NONE for alpha
-a4d5f59d Faster lossless decoding
-fd53bb75 Merge "alternate LUT-base reverse-bits code"
-d1c166ef Merge "Container spec: a clarification on background color."
-fdb91779 Rename a method
-5e967532 Container spec: a clarification on background color.
-30e77d0f Merge branch '0.3.0'
-1b631e29 alternate LUT-base reverse-bits code
-24cc307a ~20% faster lossless decoding
-313d853f Speedup for decoding lossless WebP photographs:
-24ee098a change the bytes_per_pixels_ field into more evocative use_8b_decode
-2a04b034 update ChangeLog (tag: v0.3.1-rc2, tag: v0.3.1)
-7288950b Regression fix for alpha channels using color cache:
-2e377b53 wicdec: silence a format warning
-ad9e42a6 muxedit: silence some uninitialized warnings
-3307c163 Don't set alpha-channel to 0xff for alpha->green uplift
-5130770c Merge "wicdec: silence a format warning"
-a37eff47 Regression fix for alpha channels using color cache:
-241cf99b Merge "muxedit: silence some uninitialized warnings"
-c8f9c84d Regression fix for alpha unfiltering:
-14cd5c6c muxedit: silence some uninitialized warnings
-a368db81 dec/vp8l: quiet vs9 x64 type conversion warning
-ffae9f31 wicdec: silence a format warning
-8cf0701e Alpha encoding: never filter in case of NO_COMPRESSION
-825e73b1 update ChangeLog (tag: v0.3.1-rc1)
-abf6f691 update NEWS
-5a92c1a5 bump version to 0.3.1
-86daf77c store top Y/U/V samples in packed fashion
-67bc353e Revert "add WebPBlendAlpha() function to blend colors against background"
-068db59e Intertwined decoding of alpha and RGB
-38cc0114 Simplify forward-WHT + SSE2 version
-3fa595a5 Support decoding upto given row in DECODE_DATA_FUNC
-520f005f DequantizeLevels(): Add 'row' and 'num_rows' args
-47374b82 Alpha unfilter for given set of rows
-f32097e0 probe input file and quick-check for WebP format.
-a2aed1d0 configure: improve gl/glut library test
-c7e89cbb update copyright text
-a00380d2 configure: remove use of AS_VAR_APPEND
-a94a88dd fix EXIF parsing in PNG
-a71e5d84 add doc precision for WebPPictureCopy() and WebPPictureView()
-8287012e remove datatype qualifier for vmnv
-e1908430 fix a memory leak in gif2webp
-0b18b9ee fix two minor memory leaks in webpmux
-db5095d5 remove some cruft from swig/libwebp.jar
-850e956f README: update swig notes
-bddd9b0a swig/python: add minimal documentation
-d573a8d5 swig: add python encode support
-6b931875 swig/java: reduce wrapper function code duplication
-6fe536f4 swig/java: rework uint8_t typemap
-a2ea4643 Fix the bug in ApplyPalette.
-7bb28d2a webp/lossless: fix big endian BGRA output
-f036d4bf Speed up ApplyPalette for ARGB pixels.
-8112c8cf remove some warnings:
-cc128e0b Further reduce memory to decode lossy+alpha images
-07db70d2 fix for big-endian
-eda8a7de gif2webp: Fix signed/unsigned comparison mismatch
-31f346fe Makefile.vc: fix libwebpdemux dll variable typo
-6c76d28e swig: add python (decode) support
-b4f5bb6c swig: cosmetics
-498d4dd6 WebP-Lossless encoding improvements.
-26e72442 swig: ifdef some Java specific code
-8ecec686 configure: add warning related flags
-e676b043 configure: add GLUT detection; build vwebp
-b0ffc437 Alpha decoding: significantly reduce memory usage
-20aa7a8d configure: add --enable-everything
-b8307cc0 configure.ac: add some helper macros
-980e7ae9 Remove the gcc compilation comments
-7f25ff99 gif2webp: Fix ICC and XMP support
-d8e53211 Add missing name to AUTHORS
-11edf5e2 Demux: Fix a potential memleak
-c7b92184 don't forward declare enums
-7a650c6a prevent signed int overflow in left shift ops
-31bea324 add precision about dynamic output reallocation with IDecoder
-c22877f7 Add incremental support for extended format files
-5051245f Makefile.vc: have 'all' target build everything
-8191deca Makefile.vc: flags cleanup
-b9d74735 Makefile.vc: drop /FD flag
-5568dbcf update gitignore
-f4c7b654 WebPEncode: An additional check. Start VP8EncLoop/VP8EncTokenLoop only if VP8EncStartAlpha succeeded.
-1fb04bec pngdec: Avoid a double-free.
-dcbb1ca5 add WebPBlendAlpha() function to blend colors against background
-bc9f5fbe configure.ac: add AM_PROG_AR for automake >= 1.12
-bf867bf2 Tuned cross_color parameter (step) for lower qual
-90e2ec5a Merge "probe input file and quick-check for WebP format."
-7180d7ff Merge "update copyright text"
-830f72b7 probe input file and quick-check for WebP format.
-2ccf58d6 configure: improve gl/glut library test
-d640614d update copyright text
-c2113ad4 Merge "configure: remove use of AS_VAR_APPEND"
-9326a56f configure: remove use of AS_VAR_APPEND
-ea63d619 fix a type warning on VS9 x86
-bec11092 fix EXIF parsing in PNG
-b6e65f3d Merge "fix warnings for vs9 x64"
-438946dc fix warnings for vs9 x64
-f4710e3b collect macroblock reconstruction data in VP8MBData struct
-23d28e21 add doc precision for WebPPictureCopy() and WebPPictureView()
-518f2cd7 cosmetics: gif2webp: fix indent
-af358e68 Merge "remove datatype qualifier for vmnv"
-3fe91635 remove datatype qualifier for vmnv
-764fdffa fix a memory leak in gif2webp
-3e59a74d fix two minor memory leaks in webpmux
-47b9862f Merge "README: update swig notes"
-325d15ff remove some cruft from swig/libwebp.jar
-4a7627c2 README: update swig notes
-5da81e33 Merge "swig/python: add minimal documentation"
-f39e08f2 Merge "swig: add python encode support"
-6ca4a3e3 Merge "swig/java: reduce wrapper function code duplication"
-8f8702b0 Merge "swig/java: rework uint8_t typemap"
-91413be2 reduce memory for VP8MB and remove bitfields use
-7413394e Fix the memory leak in ApplyFilters.
-2053c2cf simplify the alpha-filter testing loop
-825b64db swig/python: add minimal documentation
-14677e11 swig: add python encode support
-a5c297c8 swig/java: reduce wrapper function code duplication
-ad4a367d swig/java: rework uint8_t typemap
-0d25876b use uint8_t for inv_palette[]
-afa3450c Fix the bug in ApplyPalette.
-2d6ac422 Merge "webp/lossless: fix big endian BGRA output"
-2ca83968 webp/lossless: fix big endian BGRA output
-742110cc Speed up ApplyPalette for ARGB pixels.
-2451e47d misc code cleanup
-83db4043 Merge "swig: add python (decode) support"
-eeeea8b5 Merge "swig: cosmetics"
-d5f9b8f3 Merge "libwebp: fix vp8 encoder mem alloc offsetting"
-d8edd835 libwebp: fix vp8 encoder mem alloc offsetting
-8983b83e remove use of bit-fields in VP8FInfo
-87a4fca2 remove some warnings:
-ba8f74e2 Merge "fix for big-endian"
-a65067fa Merge "Further reduce memory to decode lossy+alpha images"
-64c84486 Further reduce memory to decode lossy+alpha images
-332130b9 Mux: make a few methods static
-44370617 fix for big-endian
-5199eab5 Merge "add uncompressed TIFF output support"
-a3aede97 add uncompressed TIFF output support
-f975b67f Merge "gif2webp: Fix signed/unsigned comparison mismatch"
-5fbc734b Merge "GetFeatures: Detect invalid VP8X/VP8/VP8L data"
-d5060c87 Merge "mux.h: A comment fix + some consistency fixes"
-352d0dee GetFeatures: Detect invalid VP8X/VP8/VP8L data
-3ef79fef Cosmetic: "width * height"
-043e1ae4 gif2webp: Fix signed/unsigned comparison mismatch
-5818cff7 mux.h: A comment fix + some consistency fixes
-1153f888 Merge "swig: ifdef some Java specific code"
-3eeedae1 Makefile.vc: fix libwebpdemux dll variable typo
-f980faf4 swig: add python (decode) support
-7f5f42bb swig: cosmetics
-8eae188a WebP-Lossless encoding improvements.
-c7247c4c swig: ifdef some Java specific code
-4cb234d5 Merge "Mux: make ValidateForSingleImage() method static"
-ed6f5308 Merge "Add GetCanvasSize() method to mux"
-1d530c9a Mux: make ValidateForSingleImage() method static
-bba4c2b2 configure: add warning related flags
-fffefd18 Add GetCanvasSize() method to mux
-732da8d0 Merge "configure: add GLUT detection; build vwebp"
-0e513f7a configure: add GLUT detection; build vwebp
-55d1c150 Merge "Alpha decoding: significantly reduce memory usage"
-13d99fb5 Merge "configure: add --enable-everything"
-2bf698fe Merge "configure.ac: add some helper macros"
-edccd194 Alpha decoding: significantly reduce memory usage
-3cafcc9a configure: add --enable-everything
-4ef14477 configure.ac: add some helper macros
-a4e1cdbb Remove the gcc compilation comments
-6393fe4b Cosmetic fixes
-9c4ce971 Simplify forward-WHT + SSE2 version
-878b9da5 fix missed optim
-00046171 VP8GetInfo(): Check for zero width or height.
-9bf31293 align VP8Encoder::nz_ allocation
-5da165cf fix CheckMode() signature
-0ece07dc Merge "explicitly pad bitfields to 32-bits"
-9dbc9d19 explicitly pad bitfields to 32-bits
-5369a80f Merge "prevent signed int overflow in left shift ops"
-70e39712 Merge "cosmetics: remove unnecessary ';'s"
-d3136ce2 Merge "don't forward declare enums"
-b26e5ad5 gif2webp: Fix ICC and XMP support
-46089b20 Add missing name to AUTHORS
-94328d64 Demux: Fix a potential memleak
-96e948d7 don't forward declare enums
-f4f90880 prevent signed int overflow in left shift ops
-0261545e cosmetics: remove unnecessary ';'s
-7ebdf110 Merge "Fix few missing comparisons to NULL"
-1579989e Fix few missing comparisons to NULL
-ea1b21cf Cleaned up VP8GetHeaders() so that it parses only frame header
-b66caee4 dwebp: add support for BMP output
-ff885bfe add precision about dynamic output reallocation with IDecoder
-79241d5a Merge "Makefile.vc: have 'all' target build everything"
-ac1c729b Merge "Makefile.vc: flags cleanup"
-118a055c Merge "Makefile.vc: drop /FD flag"
-ecad0109 Merge "update gitignore"
-a681b4f4 Rename PRE_VP8 state to WEBP_HEADER
-ead4d478 Add incremental support for extended format files
-69d0f926 Makefile.vc: have 'all' target build everything
-52967498 Makefile.vc: flags cleanup
-c61baf0c Makefile.vc: drop /FD flag
-3a15125d update gitignore
-5167ca47 Merge "WebPEncode: An additional check. Start VP8EncLoop/VP8EncTokenLoop only if VP8EncStartAlpha succeeded."
-67708d67 WebPEncode: An additional check. Start VP8EncLoop/VP8EncTokenLoop only if VP8EncStartAlpha succeeded.
-b68912af pngdec: Avoid a double-free.
-82abbe12 Merge "configure.ac: add AM_PROG_AR for automake >= 1.12"
-e7d9548c add WebPBlendAlpha() function to blend colors against background
-ed4dc717 configure.ac: add AM_PROG_AR for automake >= 1.12
-df4a406d Merge branch '0.3.0'
-1e0d4b8c Update ChangeLog (tag: v0.3.0-rc7, tag: v0.3.0)
-d52b405d Cosmetic fixes
-6cb4a618 misc style fix
-68111ab0 add missing YUVA->ARGB automatic conversion in WebPEncode()
-e9a7990b Cosmetic fixes
-403bfe82 Container spec: Clarify frame disposal
-2aaa423b Merge "add missing YUVA->ARGB automatic conversion in WebPEncode()"
-07d87bda add missing YUVA->ARGB automatic conversion in WebPEncode()
-142c4629 misc style fix
-3e7a13a0 Merge "Container spec: clarify the background color field" into 0.3.0
-14af7745 container doc: add a note about the 'ANMF' payload
-cc635efa Container spec: clarify the background color field
-e3e33949 container doc: move RIFF description to own section
-4299f398 libwebp/mux: fix double free
-33f9a692 Merge "demux: keep a frame tail pointer; used in AddFrame" into 0.3.0
-a2a7b959 use WebPDataCopy() instead of re-coding it.
-6f18f12f demux: keep a frame tail pointer; used in AddFrame
-e5af49e9 add doc precision about WebPParseHeaders() return codes
-db46daab Merge "Makefile.vc: fix dynamic builds" into 0.3.0
-53c77afc Merge "gif2webp: Bgcolor fix for a special case" into 0.3.0
-a5ebd143 gif2webp: Bgcolor fix for a special case
-6378f238 Merge "vwebp/animation: fix background dispose" into 0.3.0
-3c8eb9a8 fix bad saturation order in QuantizeBlock
-04c7a2ec vwebp/animation: fix background dispose
-81a50695 Makefile.vc: fix dynamic builds
-5f25c396 update ChangeLog (tag: v0.3.0-rc6)
-14d42af2 examples: don't use C99 %zu
-5ccf1fe5 update ChangeLog
-2560c243 update NEWS
-f43bafc3 Merge changes Iecccb09c,If5ee9fd2,I3e181ce4 into 0.3.0
-a788644f dwebp: warn when decoding animated webp's
-302efcdb Decode: return more meaningful error for animation
-ad452735 WebPBitstreamFeatures: add has_animation field
-783dfa49 disable FRGM decoding for good in libwebpmux
-4b956be0 Update ChangeLog
-ad8b86d7 update NEWS
-3e084f63 Merge "demux cosmetics: comments/rename internal function" into 0.3.0
-d3f8c621 Merge "move WebPFeatureFlags declaration" into 0.3.0
-7386fe50 Merge "libwebp{demux,mux}: install mux_types.h" into 0.3.0
-d6cd4e90 Merge "bump decode abi" into 0.3.0
-17f8da5c bump decode abi
-97684ae2 Merge "add doc precision about WebPDemuxPartial()" into 0.3.0
-f933fd2a move WebPFeatureFlags declaration
-289bc47b libwebp{demux,mux}: install mux_types.h
-224e8d46 add doc precision about WebPDemuxPartial()
-4c18e80c demux cosmetics: comments/rename internal function
-7cfd1bf1 update AUTHORS
-401f7b85 Merge "speed-up lossless (~3%) with ad-hoc histogram cost evaluation" into 0.3.0
-1fc8ffca Merge "makefile.unix: dist related changes" into 0.3.0
-8a89c6ed Merge changes I466c377f,Ib761ebd3,I694857fc into 0.3.0
-f4ffb2d5 speed-up lossless (~3%) with ad-hoc histogram cost evaluation
-723847d5 gif2webp: only write error messages to stderr
-701b9e2a makefile.unix: dist related changes
-bb85b437 Merge "update NEWS" into 0.3.0
-59423a24 gif2webp: fix crash on open failure with libgif5
-9acb17de gif2webp: silence a unused param warning
-7d9fdc23 Merge "README updates" into 0.3.0
-5621934e Merge "build: fix install race on shared headers" into 0.3.0
-70809d89 Merge "bump version to 0.3.0" into 0.3.0
-d851cd1d demux: make the parse a bit more strict
-28bb4107 update NEWS
-cef93882 bump version to 0.3.0
-9048494d build: fix install race on shared headers
-1e67e8ef README updates
-42b611a4 Merge "configure: drop experimental from mux/demux" into 0.3.0
-096a8e32 Merge "vwebp: add color profile support" into 0.3.0
-ddfee5dc vwebp: add color profile support
-0d6927d3 Merge "Mark fragment options as experimental in webpmux" into 0.3.0
-5dbd4030 Mark fragment options as experimental in webpmux
-a0a6648c configure: drop experimental from mux/demux
-ee65bad8 Merge "add support for BITS > 32" into 0.3.0
-744930db add support for BITS > 32
-7dd288f0 cwebp: fix build
-19a8dd01 Merge "Makefile.vc: add vwebp.exe target" into 0.3.0
-50eeddad Merge "examples: normalize icc related program arguments" into 0.3.0
-757f637f Merge "Makefile.vc: add libwebpdecoder target" into 0.3.0
-b65c4b7c Makefile.vc: add libwebpdecoder target
-f8db7b4a Merge "vwebp: replace doubles w/floats where appropriate" into 0.3.0
-d99aa56f Makefile.vc: add vwebp.exe target
-013023e7 vwebp: replace doubles w/floats where appropriate
-9b3db894 README.mux: add version reference
-7b6a26cf Merge "cwebp: output metadata statistics" into 0.3.0
-d8dc72a0 examples: normalize icc related program arguments
-7bfc9056 Merge "make alpha unfilter work in-place" into 0.3.0
-0037b2d2 Merge "add LUT-free reference code for YUV->RGB conversion." into 0.3.0
-166bf744 Merge "demux: disable fragment parsing" into 0.3.0
-126974b4 add LUT-free reference code for YUV->RGB conversion.
-0aef3ebd make alpha unfilter work in-place
-14ef5005 Merge "Remove 'status: experimental' from container spec" into 0.3.0
-d40c98e1 Merge "webpmux binary: tiny style fix" into 0.3.0
-0bc42689 cwebp: output metadata statistics
-bc039803 Merge "autoconf: normalize experimental define" into 0.3.0
-d1e21b13 Remove 'status: experimental' from container spec
-7681bb96 webpmux binary: tiny style fix
-a3dd3d0f avoid installing example_util.h
-252320e2 demux: disable fragment parsing
-537bde05 autoconf: normalize experimental define
-5e338e0b Merge changes I33e8a613,I8e8a7b44 into 0.3.0
-d9d0ea1b Merge changes If21e3ec7,I991fc30b into 0.3.0
-627f5ca6 automake: add reference to libwebp for mux/demux
-eef73d07 don't consolidate proba stats too often
-05ec4cc2 libwebp{,decoder}.pc: add pthread flags
-1bfcf5bf add libwebpmux.pc
-26ca843d add libwebpdemux.pc
-69e25906 Merge "Tune Lossless compression for lower qualities."
-0478b5d2 Tune Lossless compression for lower qualities.
-39f7586f add a mention of parallel alpha encoding in the NEWS
-5a21d967 Merge "1.5x-2x faster encoding for method 3 and up"
-9bfbdd14 1.5x-2x faster encoding for method 3 and up
-27dc741b Correct frame options order in README.mux
-be2fd173 Mux: fix a scenario with bad ANMF/FRGM size
-19eb012c Merge "Demux: Add option to get frame count using GetI()"
-7368b8cb Merge "WebPGetFeatures() out of if condition for clarity."
-f604c9a4 Merge "fix windows build"
-153f94e8 fix windows build
-847b4924 Merge "vwebp: use magenta for 'i'nfo display"
-25ea46bd Merge "vwebp: add keyboard shortcuts to help output"
-bea7ccaf vwebp: use magenta for 'i'nfo display
-8fab161a webpmux: correct -frame param order in help output
-03cc23d6 vwebp: add keyboard shortcuts to help output
-068eba8d Demux: Add option to get frame count using GetI()
-988b8f56 WebPGetFeatures() out of if condition for clarity.
-6933d910 Merge "gif2webp: Be lenient about background color index."
-4d0f7c55 Merge "WebPGetFeatures() behavior change:"
-fdeeb01d gif2webp: Be lenient about background color index.
-ad250320 Merge "multi-threaded alpha encoding for lossy"
-4e32d3e1 Merge "fix compilation of token.c"
-f817930a multi-threaded alpha encoding for lossy
-88050351 fix compilation of token.c
-fc816219 code using the actual values for num_parts_, not the ones from config
-72655350 Merge "move the config check from .c to .h"
-dd9e76f7 move the config check from .c to .h
-956b217a WebPGetFeatures() behavior change:
-df02e4ce WebPDemuxGetI behavior change:
-633c004d Merge "rebalance method tools (-m) for methods [0..4]"
-58ca6f65 rebalance method tools (-m) for methods [0..4]
-7648c3cc Merge "describe rd-opt levels introduce VP8RDLevel enum"
-67fb1003 Merge "autoconf: enable silent-rules by default"
-a5042a32 GetVersion() methods for mux and demux
-5189957e describe rd-opt levels introduce VP8RDLevel enum
-4e094ace autoconf: enable silent-rules by default
-b7eaa85d inline VP8LFastLog2() and VP8LFastSLog2 for small values
-5cf7792e split quant_levels.c into decoder and encoder version
-e5d3ffe2 Merge "Update code example in README.mux"
-ac5a9156 Update code example in README.mux
-38a91e99 Add example code snippet for demux API
-5f557f3c README.mux: add info about Demux API and vwebp
-c0ba0903 backward_references: avoid signed integer overflow
-943386db disable SSE2 for now
-9479fb7d lossless encoding speedup
-ec2030a8 merge two lines together
-b67956c0 Merge "Remove ReadOneBit() and ReadSymbolUnsafe()"
-1667bded Remove ReadOneBit() and ReadSymbolUnsafe()
-3151669b wicdec + dwebp cosmetics: normalize formatting
-92668da6 change default filtering parameters: * type is now 'strong' * strength is now '60'
-b7490f85 introduce WEBP_REFERENCE_IMPLEMENTATION compile option
-33838857 faster decoding (3%-6%)
-5c3e381b Merge "add a -jpeg_like option"
-c2311046 remove unused declaration of VP8Zigzag
-36152957 Merge "wicdec: add alpha support for paletted formats"
-c9f16490 wicdec: add alpha support for paletted formats
-1262f81e Merge "wicdec: silence some warnings"
-e7ea61eb wicdec: silence some warnings
-23c0f354 fix missing intptr_t->int cast for MSVC
-e895059a add a -jpeg_like option
-1f803f64 Merge "Tune alpha quality mapping to more reasonable values."
-1267d498 Tune alpha quality mapping to more reasonable values.
-043076e2 Merge "speed-up lossless in BackwardTrace"
-f3a44dcd remove one malloc from TraceBackwards()
-0fc1a3a0 speed-up lossless in BackwardTrace
-7c732e59 cwebp: centralize WebPCleanupTransparentArea()
-7381254e Merge "wicdec: add ICC profile extraction"
-e83ff7de wicdec: add ICC profile extraction
-146c6e3b Merge "cosmetics: pngdec: normalize default label location"
-a8f549d7 Merge "manpages: italicize option parameters"
-e118db83 Merge "encode.h: note the need to free() WebPMemoryWriter"
-1dfee6db cosmetics: pngdec: normalize default label location
-14c38200 manpages: italicize option parameters
-7defbfad encode.h: note the need to free() WebPMemoryWriter
-88d382a0 cwebp: cleanup after memory_writer
-12d6cecf fix extra space in dwebp.1 man
-b01681a9 Fix for demuxer frame iteration:
-56c12aa6 Demuxer creation fix:
-66c810bc add a -yuv option to dwebp (very similar to -pgm)
-841a3ba5 Merge "Remove -Wshadow warnings."
-8fd02527 Merge "upsampling_neon.c: fix build"
-6efed268 Remove -Wshadow warnings.
-60904aa6 Merge "allow WebPINewRGB/YUVA to be passed a NULL output buffer."
-b7adf376 allow WebPINewRGB/YUVA to be passed a NULL output buffer.
-27f8f742 upsampling_neon.c: fix build
-06b9cdf1 gitignore: add IOS related directories
-f112221e Merge "Fix more comments for iobuild.sh"
-fe4d25dd Fix more comments for iobuild.sh
-1de3e252 Merge "NEON optimised yuv to rgb conversion"
-090b708a NEON optimised yuv to rgb conversion
-daa06476 Merge "Add ios build script for building iOS library."
-79fe39e2 Add ios build script for building iOS library.
-126c035f remove some more -Wshadow warnings
-522e9d61 Merge "cwebp: enable '-metadata'"
-76ec5fa1 cwebp: enable '-metadata'
-aeb91a9d Merge "cosmetics: break a few long lines"
-be7c96b0 cosmetics: break a few long lines
-cff8ddb6 Merge "add libwebpdecoder.pc"
-93148ab8 Merge "libwebp.pc.in: detab"
-6477f955 Merge "Makefile.vc: normalize path separator"
-bed1ed7c add libwebpdecoder.pc
-46168b2d libwebp.pc.in: detab
-a941a346 Fixed few nits in the build files.
-dd7a49b2 Makefile.vc: normalize path separator
-9161be86 Merge "cwebp: extract WIC decoding to its own module"
-08e7c58e Merge "Provide an option to build decoder library."
-0aeba528 Provide an option to build decoder library.
-757ebcb1 catch malloc(0)/calloc(0) with an assert
-152ec3d2 Merge "handle malloc(0) and calloc(0) uniformly on all platforms"
-a452a555 cwebp: extract WIC decoding to its own module
-2b252a53 Merge "Provide option to swap bytes for 16 bit colormodes"
-94a48b4b Provide option to swap bytes for 16 bit colormodes
-42f8f934 handle malloc(0) and calloc(0) uniformly on all platforms
-8b2152c5 Merge "add an extra assert to check memory bounds"
-0d19fbff remove some -Wshadow warnings
-cd22f655 add an extra assert to check memory bounds
-8189feda Merge "Add details and reference about the YUV->RGB conversion"
-1d2702b1 Merge "Formatting fixes in lossless bitstream spec"
-8425aaee Formatting fixes in lossless bitstream spec
-a556cb1a Add details and reference about the YUV->RGB conversion
-d8f21e0b add link to SSIM description on Wikipedia
-18e9167e Merge "WebP-lossless spec clarifications:"
-98e25b9b Merge "cwebp: add -metadata option"
-f01c2a53 WebP-lossless spec clarifications:
-f4a97970 Merge "Disto4x4 and Disto16x16 in NEON"
-47b7b0ba Disto4x4 and Disto16x16 in NEON
-7eaee9f1 cwebp: add -metadata option
-36c52c2c tiffdec: use toff_t for exif ifd offset
-7c8111e4 Merge "cwebp/tiffdec: add TIFF metadata extraction"
-e6409adc Remove redundant include from dsp/lossless code.
-1ab5b3a7 Merge "configure: fix --with-gifincludedir"
-03c749eb configure: fix --with-gifincludedir
-8b650635 multiple libgif versions support for gif2webp
-476e293f gif2webp: Use DGifOpenFileName()
-b50f277b tiffdec: correct format string
-2b9048e3 Merge "tiffdec: check error returns for width/height"
-a1b5a9a3 Merge "cwebp/tiff: use the first image directory"
-079423f5 tiffdec: check error returns for width/height
-d62824af Merge "cwebp/jpegdec: add JPEG metadata extraction"
-03afaca4 Merge "cwebp: add PNG metadata extraction"
-2c724968 cwebp/jpegdec: add JPEG metadata extraction
-dba64d91 cwebp: add PNG metadata extraction
-1f075f89 Lossless spec corrections/rewording/clarifications
-2914ecfd cwebp/tiffdec: add TIFF metadata extraction
-d82a3e33 More corrections/clarifications in lossless spec:
-bd002557 cwebp/tiff: use the first image directory
-df7aa076 Merge "Cleanup around jpegdec"
-0f57dcc3 decoding speed-up (~1%)
-bcec339b Lossless bitstream clarification:
-6bf20874 add examples/metadata.c
-207f89c0 Merge "configure: add libwebpdemux status to summary"
-1bd287a6 Cleanup around jpegdec
-91455679 Merge "cosmetics: use '== 0' in size checks"
-d6b88b76 cosmetics: use '== 0' in size checks
-d3dace2f cosmetics: jpegdec
-2f69af73 configure: add libwebpdemux status to summary
-1c1c5646 cwebp: extract tiff decoding to its own module
-6a871d66 cwebp: extract jpeg decoding to its own module
-2ee228f9 cwebp: extract png decoding to its own module
-4679db00 Merge "cwebp: add metadata framework"
-63aba3ae cwebp: add metadata framework
-931bd516 lossless bitstream: block size bits correction
-e4fc4c1c lossless bitstream: block size bits correction
-d65ec678 fix build, move token.c to src/enc/
-657f5c91 move token buffer to its own file (token.c)
-c34a3758 introduce GetLargeValue() to slim-fast GetCoeffs().
-d5838cd5 faster non-transposing SSE2 4x4 FTransform
-f76191f9 speed up GetResidualCost()
-ba2aa0fd Add support for BITS=24 case
-2e7f6e8e makefile.unix: Dependency on libraries
-dca84219 Merge "Separate out mux and demux code and libraries:"
-23782f95 Separate out mux and demux code and libraries:
-bd56a01f configure: add summary output
-90e5e319 dwebp manual: point to webpmux, gif2webp.
-540790ca gif2webp.c: add a note about prerequisites
-d1edf697 cwebp man page: meaning of '-q' for lossy/lossless
-79efa1d0 Add man page for gif2webp utility
-2243e40c Merge "gif2webp build support with autoconf tools"
-c40efca1 gif2webp build support with autoconf tools
-6523e2d4 WebP Container:
-4da788da Merge "simplify the fwd transform"
-42c3b550 simplify the fwd transform
-41a6ced9 user GLfloat instead of float
-b5426119 fix indentation
-68f282f7 * handle offset in anim viewer 'vwebp' * fix gif2webp to handle disposal method and odd offset correctly
-118cb312 Merge "add SSE2 version of Sum of Square error for 16x16, 16x8 and 8x8 case"
-8a7c3cc8 Merge "Change the order of -frame argument to be more natural"
-99e0a707 Merge "Simplify the texture evaluation Disto4x4()"
-0f923c3f make the bundling work in a tmp buffer
-e5c3b3f5 Simplify the texture evaluation Disto4x4()
-48600084 Change the order of -frame argument to be more natural
-35bfd4c0 add SSE2 version of Sum of Square error for 16x16, 16x8 and 8x8 case
-a7305c2e Clarification for unknown chunks
-4c4398e2 Refine WebP Container Spec wrt unknown chunks.
-2ca642e0 Rectify WebPMuxGetFeatures:
-7caab1d8 Some cosmetic/comment fixes.
-60b2651a Merge "Write a GIF to WebP converter based on libgif."
-c7127a4d Merge "Add NEON version of FTransformWHT"
-11b27212 Write a GIF to WebP converter based on libgif.
-e9a15a37 ExUtilWriteFile() to write memory segment to file
-74356eb5 Add a simple cleanup step in mux assembly:
-51bb1e5d mux.h: correct WebPDemuxSelectFragment() prototype
-22a0fd9d Add NEON version of FTransformWHT
-fa30c863 Update mux code to match the spec wrt animation
-d9c5fbef by-pass Analysis pass in case segments=1
-d2ad4450 Merge changes Ibeccffc3,Id1585b16
-5c8be251 Merge "Chunk fourCCs for XMP/EXIF"
-a00a3daf Use 'frgm' instead of 'tile' in webpmux parameters
-81b8a741 Design change in ANMF and FRGM chunks:
-f903cbab Chunk fourCCs for XMP/EXIF
-812933d6 Tune performance of HistogramCombine
-52ad1979 Animation specification in container spec
-001b9302 Image fragment specification in container spec
-391f9db9 Ordering of description of bits in container spec
-d5735776 Metadata specification in container spec
-1c4609b1 Merge commit 'v0.2.1'
-0ca584cb Merge "Color profile specification in container spec"
-e8b41ad1 add NEON asm version for WHT inverse transform
-af6f0db2 Color profile specification in container spec
-a61a824b Merge "Add NULL check in chunk APIs"
-0e8b7eed fix WebPPictureView() unassigned strides
-75e5f17e ARM/NEON: 30% encoding speed-up
-02b43568 Add NULL check in chunk APIs
-a0770727 mux struct naming
-6c66dde8 Merge "Tune Lossless encoder"
-ab5ea217 Tune Lossless encoder
-74fefc8c Update ChangeLog (tag: v0.2.1, origin/0.2.0)
-92f8059c Rename some chunks:
-3bb4bbeb Merge "Mux API change:"
-d0c79f05 Mux API change:
-abc06044 Merge "update NEWS" into 0.2.0
-57cf313b update NEWS
-25f585c4 bump version to 0.2.1
-fed7c048 libwebp: validate chunk size in ParseOptionalChunks
-552cd9bc cwebp (windows): fix alpha image import on XP
-b14fea99 autoconf/libwebp: enable dll builds for mingw
-4a8fb272 [cd]webp: always output windows errors
-d6621580 fix double to float conversion warning
-72b96a69 cwebp: fix jpg encodes on XP
-734f762a VP8LAllocateHistogramSet: fix overflow in size calculation
-f9cb58fb GetHistoBits: fix integer overflow
-b30add20 EncodeImageInternal: fix uninitialized free
-3de58d77 fix the -g/O3 discrepancy for 32bit compile
-77aa7d50 fix the BITS=8 case
-e5970bda Make *InitSSE2() functions be empty on non-SSE2 platform
-ef5cc47e make *InitSSE2() functions be empty on non-SSE2 platform
-c4ea259d make VP8DspInitNEON() public
-8344eadf Merge "libwebp: validate chunk size in ParseOptionalChunks"
-4828bb93 Merge "cwebp (windows): fix alpha image import on XP"
-30763333 libwebp: validate chunk size in ParseOptionalChunks
-70481898 AccumulateLSIM: fix double -> float warnings
-eda8ee4b cwebp (windows): fix alpha image import on XP
-c6e98658 Merge "add EXPERIMENTAL code for YUV-JPEG colorspace"
-f0360b4f add EXPERIMENTAL code for YUV-JPEG colorspace
-f86e6abe add LSIM metric to WebPPictureDistortion()
-c3aa215a Speed up HistogramCombine for lower qualities.
-1765cb1c Merge "autoconf/libwebp: enable dll builds for mingw"
-a13562e8 autoconf/libwebp: enable dll builds for mingw
-9f469b57 typo: no_fancy -> no_fancy_upsampling
-1a27f2f8 Merge "fix double to float conversion warning"
-cf1e90de Merge "cwebp: fix jpg encodes on XP"
-f2b5d19b [cd]webp: always output windows errors
-e855208c fix double to float conversion warning
-ecd66f77 cwebp: fix jpg encodes on XP
-7b3eb372 Tune lossless compression to get better gains.
-ce8bff45 Merge "VP8LAllocateHistogramSet: fix overflow in size calculation"
-ab5b67a1 Merge "EncodeImageInternal: fix uninitialized free"
-7fee5d12 Merge "GetHistoBits: fix integer overflow"
-a6ae04d4 VP8LAllocateHistogramSet: fix overflow in size calculation
-80237c43 GetHistoBits: fix integer overflow
-8a997235 EncodeImageInternal: fix uninitialized free
-0b9e6829 minor cosmetics
-a792b913 fix the -g/O3 discrepancy for 32bit compile
-73ba4357 Merge "detect and merge similar segments"
-fee66275 detect and merge similar segments
-0c44f415 src/webp/*.h: don't forward declare enums in C++
-d7a5ac86 vwebp: use demux interface
-931e0ea1 Merge "replace 'typedef struct {} X;" by "typedef struct X X; struct X {};""
-8f216f7e remove cases of equal comparison for qsort()
-28d25c82 replace 'typedef struct {} X;" by "typedef struct X X; struct X {};"
-2afee60a speed up for ARM using 8bit for boolean decoder
-5725caba new segmentation algorithm
-2cf1f815 Merge "fix the BITS=8 case"
-12f78aec fix the BITS=8 case
-6920c71f fix MSVC warnings regarding implicit uint64 to uint32 conversions
-f6c096aa webpmux binary: Rename 'xmp' option to 'meta'
-ddfe871a webpmux help correction
-b7c55442 Merge "Make *InitSSE2() functions be empty on non-SSE2 platform"
-1c04a0d4 Common APIs for chunks metadata and color profile.
-2a3117a1 Merge "Create WebPMuxFrameInfo struct for Mux APIs"
-5c3a7231 Make *InitSSE2() functions be empty on non-SSE2 platform
-7c6e60f4 make *InitSSE2() functions be empty on non-SSE2 platform
-c7eb4576 make VP8DspInitNEON() public
-ab3234ae Create WebPMuxFrameInfo struct for Mux APIs
-e3990fd8 Alignment fixes
-e55fbd6d Merge branch '0.2.0'
-4238bc0a Update ChangeLog (tag: v0.2.0)
-c655380c dec/io.c: cosmetics
-fe1958f1 RGBA4444: harmonize lossless/lossy alpha values
-681cb30a fix RGBA4444 output w/fancy upsampling
-f06c1d8f Merge "Alignment fix" into 0.2.0
-f56e98fd Alignment fix
-6fe843ba avoid rgb-premultiply if there's only trivial alpha values
-528a11af fix the ARGB4444 premultiply arithmetic
-a0a48855 Lossless decoder fix for a special transform order
-62dd9bb2 Update encoding heuristic w.r.t palette colors.
-6f4272b0 remove unused ApplyInverseTransform()
-93bf0faa Update ChangeLog (tag: v0.2.0-rc1)
-5934fc59 update AUTHORS
-014a711d update NEWS
-43b0d610 add support for ARGB -> YUVA conversion for lossless decoder
-33705ca0 bump version to 0.2.0
-c40d7ef1 fix alpha-plane check + add extra checks
-a06f8023 MODE_YUVA: set alpha to opaque if the image has none
-52a87dd7 Merge "silence one more warning" into 0.2.0
-3b023093 silence one more warning
-f94b04f0 move some RGB->YUV functions to yuv.h
-4b71ba03 README: sync [cd]webp help output
-c9ae57f5 man/dwebp.1: add links to output file format details
-292ec5cc quiet a few 'uninitialized' warnings
-4af3f6c4 fix indentation
-9b261bf5 remove the last NOT_HAVE_LOG2 instances
-323dc4d9 remove use of log2(). Use VP8LFastLog2() instead.
-8c515d54 Merge "harness some malloc/calloc to use WebPSafeMalloc and WebPSafeCalloc" into 0.2.0
-d4b4bb02 Merge changes I46090628,I1a41b2ce into 0.2.0
-bff34ac1 harness some malloc/calloc to use WebPSafeMalloc and WebPSafeCalloc
-a3c063c7 Merge "extra size check for security" into 0.2.0
-5e796300 Merge "WebPEncode: clear stats at the start of encode" into 0.2.0
-f1edf62f Merge "rationalize use of color-cache" into 0.2.0
-c1933317 extra size check for security
-906be657 rationalize use of color-cache
-dd1c3873 Add image-hint for low-color images.
-4eb7aa64 Merge "WebPCheckMalloc() and WebPCheckCalloc():" into 0.2.0
-80cc7303 WebPCheckMalloc() and WebPCheckCalloc():
-183cba83 check VP8LBitWriterInit return
-cbfa9eec lossless: fix crash on user abort
-256afefa cwebp: exit immediately on version mismatch
-475d87d7 WebPEncode: clear stats at the start of encode
-a7cc7291 fix type and conversion warnings
-7d853d79 add stats for lossless
-d39177b7 make QuantizeLevels() store the sum of squared error
-5955cf5e replace x*155/100 by x*101581>>16
-7d732f90 make QuantizeLevels() store the sum of squared error
-e45a446a replace x*155/100 by x*101581>>16
-159b75d3 cwebp output size consistency:
-cbee59eb Merge commit 'v0.1.99'
-1889e9b6 dwebp: report -alpha option
-3bc3f7c0 Merge "dwebp: add PAM output support" into 0.2.0
-d919ed06 dwebp: add PAM output support
-85e215d3 README/manpages/configure: update website link
-c3a207b9 Update ChangeLog (tag: v0.1.99)
-d1fd7826 Merge "add extra precision about default values and behaviour" into 0.2.0
-efc826e0 add extra precision about default values and behaviour
-9f29635d header/doc clean up
-ff9fd1ba Makefile.vc: fix webpmux.exe *-dynamic builds
-8aacc7b0 remove INAM, ICOP, ... chunks from the test webp file.
-2fc13015 harmonize authors as "Name (mail@address)"
-4a9f37b7 Merge "update NEWS" into 0.2.0
-7415ae13 makefile.unix: provide examples/webpmux target
-ce82cedc update NEWS
-641e28e8 Merge "man/cwebp.1: wording, change the date" into 0.2.0
-c37c23e5 README: cosmetics
-3976dcd5 man/cwebp.1: wording, change the date
-3e5bbe1c Merge "rename 'use_argb_input' to 'use_argb'" into 0.2.0
-ce90847a Merge "add some padding bytes areas for later use" into 0.2.0
-2390dabc Merge "fixing the findings by Frederic Kayser to the bitstream spec" into 0.2.0
-02751591 add a very crude progress report for lossless
-a4b9b1c6 Remove some unused enum values.
-dd108176 rename 'use_argb_input' to 'use_argb'
-90516ae8 add some padding bytes areas for later use
-d03b2503 fixing the findings by Frederic Kayser to the bitstream spec
-ce156afc add missing ABI compatibility checks
-9d45416a Merge "Doc: container spec text tweaks" into 0.2.0
-4e2e0a8c Doc: container spec text tweaks
-f7f16a29 add ABI compatibility check
-2a775570 Merge "swig: add WebPEncodeLossless* wrappers" into 0.2.0
-a3ec6225 mux.h: remove '* const' from function parameters
-31426eba encode.h: remove '* const' from function parameters
-9838e5d5 decode.h: remove '* const' from function parameters
-4972302d swig: add WebPEncodeLossless* wrappers
-9ff00cae bump encoder/decoder versions
-c2416c9b add lossless quick encoding functions to the public API
-4c1f5d64 Merge "NEWS: mention decode_vp8.h is no longer installed" into 0.2.0
-6cb2277d NEWS: mention decode_vp8.h is no longer installed
-d5e5ad63 move decode_vp8.h from webp/ to dec/
-8d3b04a2 Merge "header clean-up" into 0.2.0
-02201c35 Merge "remove one malloc() by making color_cache non dynamic" into 0.2.0
-d708ec14 Merge "move MIN/MAX_HISTO_BITS to format_constants.h" into 0.2.0
-ab2da3e9 Merge "add a malloc() check" into 0.2.0
-2d571bd8 add a malloc() check
-7f0c178e remove one malloc() by making color_cache non dynamic
-6569cd7c Merge "VP8LFillBitWindow: use 64-bit path for msvc x64 builds" into 0.2.0
-23d34f31 header clean-up
-2a3ab6f9 move MIN/MAX_HISTO_BITS to format_constants.h
-985d3da6 Merge "shuffle variables in HashChainFindCopy" into 0.2.0
-cdf885c6 shuffle variables in HashChainFindCopy
-c3b014db Android.mk: add missing lossless files
-8c1cc6b5 makefile.unix dist: explicitly name installed includes
-7f4647ee Merge "clarify the colorspace naming and byte ordering of decoded samples" into 0.2.0
-cbf69724 clarify the colorspace naming and byte ordering of decoded samples
-857650c8 Mux: Add WebPDataInit() and remove WebPImageInfo
-ff771e77 don't install webp/decode_vp8.h
-596dff78 VP8LFillBitWindow: use 64-bit path for msvc x64 builds
-3ca7ce98 Merge "doc: remove non-finalized chunk references" into 0.2.0
-1efaa5a3 Merge "bump versions" into 0.2.0
-51fa13e1 Merge "README: update cwebp help output" into 0.2.0
-12f9aede README: update cwebp help output
-f0b5defb bump versions
-4c42a61b update AUTHORS
-6431a1ce doc: remove non-finalized chunk references
-8130c4cc Merge "build: remove libwebpmux from default targets/config"
-23b44438 Merge "configure: broaden test for libpng-config"
-85bff2cd Merge "doc: correct lossless prefix coding table & code"
-05108f6e Merge "More spec/code matching in mux:"
-6808e69d More spec/code matching in mux:
-bd2b46f5 Merge "doc/webp-container-spec: light cosmetics"
-20ead329 doc/webp-container-spec: light cosmetics
-1d40a8bc configure: add pthread detection
-b5e9067a fix some int <-> size_t mix for buffer sizes
-e41a7596 build: remove libwebpmux from default targets/config
-0fc2baae configure: broaden test for libpng-config
-45b8272c Merge "restore authorship to lossless bitstream doc"
-06ba0590 restore authorship to lossless bitstream doc
-44a09a3c add missing description of the alpha filtering methods
-63db87dd Merge "vwebp: add checkboard background for alpha display"
-a73b8978 vwebp: add checkboard background for alpha display
-939158ce Merge "vwebp: fix info display"
-b35c07d9 vwebp: fix info display
-48b39eb1 fix underflow for very short bitstreams
-7e622984 cosmetics: param alignment, manpage wording
-1bd7dd50 Merge changes I7b0afb0d,I7ecc9708
-ac69e63e Merge "Updated cwebp man's help for Alpha & Lossless."
-c0e8859d Get rid of image_info_ from WebPChunk struct.
-135ca69e WebP Container Spec:
-eb6f9b8a Updated cwebp man's help for Alpha & Lossless.
-0fa844fb cosmetic fixes on assert and 'const' where applicable
-7f22bd25 check limit of width * height is 32 bits
-16c46e83 autoconf/make: cosmetics: break long lines
-ab22a07a configure: add helper macro to define --with-*
-c17699b3 configure: add libtiff test
-0e09732c Merge "cwebp: fix crash with yuv input + lossless"
-88a510ff Merge "fix big-endian VP8LWriteBits"
-da99e3bf Merge "Makefile.vc: split mux into separate lib"
-7bda392b cwebp: fix crash with yuv input + lossless
-f56a369a fix big-endian VP8LWriteBits
-54169d6c Merge "cwebp: name InputFileFormat members consistently"
-e2feefa9 Makefile.vc: split mux into separate lib
-27caa5aa Merge "cwebp: add basic TIFF support"
-d8921dd4 cwebp: name InputFileFormat members consistently
-6f76d246 cwebp: add basic TIFF support
-4691407b Merge changes If39ab7f5,I3658b5ae
-cca7c7b8 Fixed nit: 10 -> 10.f
-5d09a244 WebPMuxCreate() error handling:
-777341c3 Fix a memleak in WebPMuxCreate()
-61c9d161 doc: correct lossless prefix coding table & code
-4c397579 Merge "mark VP8{,L}{GetInfo,CheckSignature} as WEBP_EXTERN"
-e4e36cc6 Merge "Mux: Allow only some frames/tiles to have alpha."
-ad2aad3c Merge "WebP Decoding error handling:"
-97649c8f Mux: Allow only some frames/tiles to have alpha.
-f864be3b Lower the quality settings for Alpha encoding.
-3ba81bbe WebP Decoding error handling:
-fcc69923 add automatic YUVA/ARGB conversion during WebPEncode()
-802e012a fix compilation in non-FANCY_UPSAMPLING mode
-e012dfd9 make width/height coding match the spec
-228d96a5 mark VP8{,L}{GetInfo,CheckSignature} as WEBP_EXTERN
-637a314f remove the now unused *KeepA variants
-d11f6fcc webpmux returns error strings rather than numbers
-fcec0593 makefile.unix: cwebp: fix OSX link
-6b811f1b Merge "doc: remove lossless pdf"
-c9634821 doc: remove lossless pdf
-b9ae4f0d cosmetics after mux changes b74ed6e, b494ad5
-b494ad50 Mux: only allow adding frame/tiles at the end.
-2c341b0e Merge "Added image characteristic hint for the codec."
-d373076a Added image characteristic hint for the codec.
-2ed2adb5 Merge "msvc: add intrinsic based BitsLog2Floor"
-e595e7c5 Merge "add demux.c to the makefiles"
-da47b5bd Merge "demux: add {Next,Prev}Chunk"
-e5f46742 add demux.c to the makefiles
-4708393c demux: add {Next,Prev}Chunk
-e8a0a821 demux: quiet msvc warnings
-7f8472a6 Update the WebP Container Spec.
-31b68fe6 cleanup WebPPicture struct and API
-9144a186 add overflow check before calling malloc()
-81720c91 consistency cosmetics
-2ebe8394 Merge "Add kramdown version information to README"
-71443084 enc/vp8l.c: fix build
-b7ac19fe Add kramdown version information to README
-efdcb667 Merge "Edit for consistency, usage and grammar."
-08220102 Enable alpha in vvwebp
-8de9a084 Merge "Mux API change:"
-b74ed6e7 Mux API change:
-233a589e take picture->argb_stride into account for lossless coding
-04e33f17 Edit for consistency, usage and grammar.
-a575b4bc Merge "cosmetics: add missing const"
-8d99b0f4 Merge "cosmetics: remove unimplemented function proto"
-69d02217 cosmetics: add missing const
-5b08318b cosmetics: remove unimplemented function proto
-b7fb0ed5 Log warning for unsupported options for lossless.
-e1f769fe msvc: add intrinsic based BitsLog2Floor
-8a69c7d8 Bug-fix: Clamp backward dist to 1.
-b5b6ac97 Merge "Bring the special writer 'WebPMemoryWriter' to public API"
-a6a1909f Merge "Fix floating point exception with cwebp -progress"
-f2cee067 Fix floating point exception with cwebp -progress
-91b7a8c7 Bring the special writer 'WebPMemoryWriter' to public API
-310e2972 support resize and crop for RGBA input
-a89835d3 Merge changes Ice662960,Ie8d7aa90,I2d996d5e,I01c04772
-ce614c0c Merge "dec/vp8: avoid setting decoder status twice"
-900285da dec/vp8: avoid setting decoder status twice
-8227adc8 Merge changes I6f02b0d0,I5cbc9c0a,I9dd9d4ed,Id684d2a1
-dcda59c1 Merge "demux: rename SetTile to SelectTile"
-622ef12e demux: rename SetTile to SelectTile
-81ebd375 Merge "demux: add {Next,Prev}Frame"
-02dd37a2 demux: add {Next,Prev}Frame
-4b79fa59 Merge "Limit the maximum size of huffman Image to 16MB."
-9aa34b34 Manually number "chapters," as chapter numbers are used in the narrative.
-2a4c6c29 Re-wrap at <= 72 columns
-a45adc19 Apply inline emphasis and monospacing, per gdoc / PDF
-91011206 Incorporate gdoc changes through 2012-06-08
-7a182487 Removed CodeRay syntax declarations ...
-b3ec18c5 Provide for code-block syntax highlighting.
-709d7702 Replace high ASCII artifacts (curly quotes, etc.).
-930e8abb Lossless WebP doc largely ported to markdown text.
-18cae37b msvc: silence some build warnings
-b3923084 Limit the maximum size of huffman Image to 16MB.
-f180df2a Merge "libwebp/demux: add Frame/Chunk iteration"
-2bbe1c9a Merge "Enable lossless encoder code"
-d0601b01 Merge changes I1d97a633,I81c59093
-78f3e345 Enable lossless encoder code
-d974a9cc Merge "libwebp/demux: add simple format parsing"
-26bf2232 Merge "libwebp: add WebPDemux stub functions"
-2f666688 Merge "modify WebPParseHeaders to allow reuse by GetFeatures"
-b402b1fb libwebp/demux: add Frame/Chunk iteration
-ad9ada3b libwebp/demux: add WebPDemuxGetI
-2f2d4d58 libwebp/demux: add extended format parsing
-962dcef6 libwebp/demux: add simple format parsing
-f8f94081 libwebp: add WebPDemux stub functions
-fb47bb5c Merge "NumNamedElements() should take an enum param."
-7c689805 Fix asserts in Palette and BackwardReference code.
-fbdcb7ea NumNamedElements() should take an enum param.
-fb4943bd modify WebPParseHeaders to allow reuse by GetFeatures
-3697b5ce write an ad-hoc EncodeImageInternal variant
-eaee9e79 Bug-Fix: Decode small (less than 32 bytes) images.
-0bceae48 Merge "cwebp: fix alpha reporting in stats output"
-0424b1ef Rebase default encoding settings.
-c71ff9e3 cwebp: fix alpha reporting in stats output
-e2ffe446 Merge "Stop indefinite recursion for Huffman Image."
-70eb2bd6 Stop indefinite recursion for Huffman Image.
-f3bab8eb Update vwebp
-6d5c797c Remove support for partial files in Mux.
-f1df5587 WebPMuxAssemble() returns WebPData*.
-814a0639 Rename 'Add' APIs to 'Set'.
-bbb0218f Update Mux psuedo-code examples.
-4fc4a47f Use WebPData in MUX set APIs
-c67bc979 Merge "add WebPPictureImportRGBX() and WebPPictureImportBGRX()"
-27519bc2 add WebPPictureImportRGBX() and WebPPictureImportBGRX()
-f80cd27e factorize code in Import()
-9b715026 histogram: add log2 wrapper
-8c34378f Merge "fix some implicit type conversion warnings"
-42f6df9d fix some implicit type conversion warnings
-250c16e3 Merge "doc: update lossless pdf"
-9d9daba4 Merge "add a PDF of the lossless spec"
-8fbb9188 prefer webp/types.h over stdint.h
-0ca170c2 doc: update lossless pdf
-0862ac6e add a PDF of the lossless spec
-437999fb introduce a generic WebPPictureHasTransparency() function
-d2b6c6c0 cosmetic fixes after Idaba281a
-b4e6645c Merge "add colorspace for premultiplied alpha"
-48f82757 add colorspace for premultiplied alpha
-069f903a Change in lossless bit-stream.
-5f7bb3f5 Merge "WebPReportProgress: use non-encoder specific params"
-f18281ff WebPReportProgress: use non-encoder specific params
-9ef32283 Add support for raw lossless bitstream in decoder.
-7cbee29a Fix bug: InitIo reseting fancy_upsampling flag.
-880fd98c vwebp: fix exit w/freeglut
-1875d926 trap two unchecked error conditions
-87b4a908 no need to have mux.h as noinst clause in enc/
-88f41ec6 doc: fix bit alignment in VP8X chunk
-52f5a4ef Merge "fix bug with lossy-alpha output stride"
-3bde22d7 fix bug with lossy-alpha output stride
-42d61b6d update the spec for the lossy-alpha compression methods.
-e75dc805 Move some more defines to format_constants.h
-c13f6632 Move consts to internal header format_constants.h
-7f2dfc92 use a bit-set transforms_seen_ instead of looping
-18da1f53 modulate alpha-compression effort according to config.method
-f5f2fff6 Merge "Alpha flag fix for lossless."
-c975c44e Alpha flag fix for lossless.
-4f067fb2 Merge "Android: only build dec_neon with NEON support"
-255c66b4 Android: only build dec_neon with NEON support
-8f9117a9 cosmetics: signature fixes
-39bf5d64 use header-less lossless bitstream for alpha channel
-75d7f3b2 Merge "make input data be 'const' for VP8LInverseTransform()"
-9a721c6d make input data be 'const' for VP8LInverseTransform()
-9fc64edc Disallow re-use of same transformation.
-98ec717f use a function pointer for ProcessRows()
-f7ae5e37 cosmetics: join line
-140b89a3 factor out buffer alloc in AllocateARGBBuffers()
-a107dfa8 Rectify WebPParseOptionalChunks().
-237eab67 Add two more color-spaces for lossless decoding.
-27f417ab fix orthographic typo
-489ec335 add VP8LEncodeStream() to compress lossless image stream
-fa8bc3db make WebPEncodingSetError() take a const picture
-638528cd bitstream update for lossy alpha compression
-d73e63a7 add DequantizeLevels() placeholder
-ec122e09 remove arch-dependent rand()
-d40e7653 fix alignment
-1dd6a8b6 Merge "remove tcoder, switch alpha-plane compression to lossless"
-3e863dda remove tcoder, switch alpha-plane compression to lossless
-8d77dc29 Add support for lossless in mux:
-831bd131 Make tile size a function of encoding method.
-778c5228 Merge "remove some variable shadowing"
-817c9dce Few more HuffmanTreeToken conversions.
-37a77a6b remove some variable shadowing
-89c07c96 Merge "normalize example header includes"
-4aff411f Merge "add example_util.[hc]"
-00b29e28 normalize example header includes
-061263a7 add example_util.[hc]
-c6882c49 merge all tree processing into a single VP8LProcessTree()
-9c7a3cf5 fix VP8LHistogramNumCodes to handle the case palette_code_bits == 0
-b5551d2e Merge "Added HuffmanTreeCode Struct for tree codes."
-8b85d01c Added HuffmanTreeCode Struct for tree codes.
-093f76d8 Merge "Allocate single memory in GetHuffBitLengthsAndCodes."
-41d80494 Allocate single memory in GetHuffBitLengthsAndCodes.
-1b04f6d2 Correct size in VP8L header.
-2924a5ae Makefile.vc: split object lists based on directory
-c8f24165 Merge "add assert(tokens)"
-43239947 add assert(tokens)
-9f547450 Catch an error in DecodeImageData().
-ac8e5e42 minor typo and style fix
-9f566d1d clean-up around Huffman-encode
-c579a710 Introduce CHUNK_SIZE_BYTES in muxi.h.
-14757f8a Make sure huffman trees always have valid symbols
-41050618 makefile.unix: add support for building vwebp
-48b37721 Merge "fixed signed/unsigned comparison warning"
-57f696da Merge "EncodeImageInternal: fix potential leak"
-d972cdf2 EncodeImageInternal: fix potential leak
-5cd12c3d fixed signed/unsigned comparison warning
-cdca30d0 Merge "cosmetics: shorten long line"
-e025fb55 cosmetics: shorten long line
-22671ed6 Merge "enc/vp8l: fix double free on error"
-e1b9b052 Merge "cosmetics: VP8LCreateHuffmanTree: fix indent"
-a8e725f8 enc/vp8l: fix double free on error
-27541fbd cosmetics: VP8LCreateHuffmanTree: fix indent
-1d38b258 cwebp/windows: use MAKE_REFGUID where appropriate
-817ef6e9 Merge "cwebp: fix WIC/Microsoft SDK compatibility issue"
-902d3e3b cwebp: fix WIC/Microsoft SDK compatibility issue
-89d803c4 Merge "Fix a crash due to wrong pointer-integer arithmetic."
-cb1bd741 Merge "Fix a crash in lossless decoder."
-de2fe202 Merge "Some cleanup in VP8LCreateHuffmanTree() (and related functions CompareHuffmanTrees() and SetBitDepths()): - Move 'tree_size' initialization and malloc for 'tree + tree_pool' outside the loop. - Some renames/tweaks for readability."
-ce69177a Fix a crash due to wrong pointer-integer arithmetic.
-e40a3684 Fix a crash in lossless decoder.
-3927ff3a remove unneeded error condition for WebPMuxNumNamedElements()
-2c140e11 Some cleanup in VP8LCreateHuffmanTree() (and related functions CompareHuffmanTrees() and SetBitDepths()): - Move 'tree_size' initialization and malloc for 'tree + tree_pool' outside the loop. - Some renames/tweaks for readability.
-861a5b7b add support for animation
-eb5c16cc Merge "Set correct encode size in encoder's stats."
-4abe04a2 fix the return value and handle missing input file case.
-2fafb855 Set correct encode size in encoder's stats.
-e7167a2b Provide one entry point for backward references.
-c4ccab64 Print relevant lossless encoding stats in cwebp.
-e3302cfd GetHuffBitLengthsAndCodes: reduce level of indirection
-b5f2a9ed enc/vp8l: fix uninitialized variable warning
-7885f8b2 makefile.unix: add lossless encoder files
-1261a4c8 Merge "cosmetics"
-3926b5be Merge "dsp/cpu.c: Android: fix crash on non-neon arm builds"
-834f937f dsp/cpu.c: Android: fix crash on non-neon arm builds
-126e1606 cosmetics
-e38602d2 Merge branch 'lossless_encoder'
-e8d3d6a0 split StoreHuffmanCode() into smaller functions
-d0d88990 more consolidation: introduce VP8LHistogramSet
-1a210ef1 big code clean-up and refactoring and optimization
-41b5c8ff Some cosmetics in histogram.c
-ada6ff77 Approximate FastLog between value range [256, 8192]
-ec123ca3 Forgot to update out_bit_costs to symbol_bit_costs at one instance.
-cf33ccd1 Evaluate output cluster's bit_costs once in HistogramRefine.
-781c01f4 Simple Huffman code changes.
-a2849bc5 Lossless decoder: remove an unneeded param in ReadHuffmanCodeLengths().
-b39e7487 Reducing emerging palette size from 11 to 9 bits.
-bfc73db4 Move GetHistImageSymbols to histogram.c
-889a5786 Improve predict vs no-predict heuristic.
-01f50663 code-moving and clean-up
-31035f3b reduce memory usage by allocating only one histo
-fbb501b8 Restrict histo_bits to ensure histo_image size is under 32MB
-8415ddf3 further simplification for the meta-Huffman coding
-e4917299 A quick pass of cleanup in backward reference code
-83332b3c Make transform bits a function of encode method (-m).
-72920caa introduce -lossless option, protected by USE_LOSSLESS_ENCODER
-c6ac4dfb Run TraceBackwards for higher qualities.
-412222c8 Make histo_bits and transform_bits function of quality.
-149b5098 Update lossless encoder strategy:
-0e6fa065 cache_bits passed to EncodeImageInternal()
-e38b40a9 Factorize code for clearing HtreeGroup.
-6f4a16ea Removing the indirection of meta-huffman tables.
-3d33ecd1 Some renaming/comments related to palette in lossless encoder.
-4d02d586 Lossless encoder: correction in Palette storage
-4a636235 fix a memleak in EncodeImageInternal()
-0993a611 Full and final fix for prediction transform
-afd2102f Fix cross-color transform in lossless encoder
-b96d8740 Need to write a '0' bit at the end of transforms.
-54dad7e5 Color cache size should be counted as 0 when cache bits = 0
-4f0c5caf Fix prediction transform in lossless encoder.
-36dabdad Fix memory leak in method EncodeImageInternal for histogram_image.
-352a4f49 Get rid of PackLiteralBitLengths()
-d673b6b9 Change the predictor function to pass left pixel
-b2f99465 Fix CopyTileWithPrediction()
-84547f54 Add EncodeImageInternal() method.
-6b38378a Guard the lossless encoder (in flux) under a flag
-09f7532c Fix few nits (const qualifiers)
-648be393 Added implementation for various lossless functions
-32714ce3 Add VP8L prefix to backward ref & histogram methods.
-fcba7be2 Fixed header file tag (WEBP_UTILS_HUFFMAN_ENCODE_H_)
-bc703746 Add backward_ref, histogram & huffman encode modules from lossless.
-fdccaadd Fixing nits
-227110c4 libwebp interface changes for lossless encoding.
-50679acf minor style fixes
-b38dfccf remove unneeded reference to NUM_LITERAL_CODES
-8979675b harmonize header description
-c04eb7be tcoder.c: define NOT_HAVE_LOG2 for MSVC builds
-9a214fa1 Merge "VP8[L]GetInfo: check input pointers"
-5c5be8ba VP8[L]GetInfo: check input pointers
-0c188fec Merge changes I431acdfe,I713659b7
-b3515c62 mux: drop 'chunk' from ChunkInfo member names
-aea7923c muxi.h: remove some unused defines
-01422492 update NEWS file for next release
-29e3f7ec Merge "dec: remove deprecated WebPINew()"
-4718e449 Merge "muxedit: a few more size_t changes"
-82654f96 Merge "muxedit: remove a few redundant NULL checks"
-02f27fbd dec: remove deprecated WebPINew()
-ccddb3fc muxedit: remove a few redundant NULL checks
-a6cdf710 muxedit: a few more size_t changes
-a3846892 Merge "mux: remove unused LIST_ID"
-11ae46ae alpha.c: quiet some size_t -> int conversion warnings
-dee46692 mux: remove unused LIST_ID
-03f1f493 mux: add version checked entry points
-6a0abdaa Merge "doc: tile/alpha corrections"
-c8139fbe Merge "few cosmetics"
-68338737 Merge "lossless: remove some size_t -> int conversions"
-5249e94a doc: tile/alpha corrections
-d96e722b huffman: quiet int64 -> int conversion warning
-532020f2 lossless: remove some size_t -> int conversions
-23be6edf few cosmetics
-1349edad Merge "configure: AC_ARG_* use AS_HELP_STRING"
-bfbcc60a configure: AC_ARG_* use AS_HELP_STRING
-1427ca8e Merge "Makefile.am: header file maintenance"
-087332e3 Merge "remove unused parameter 'round' from CalcProba()"
-9630e168 remove unused parameter 'round' from CalcProba()
-92092eaa Merge "bit_reader.h: correct include"
-a87fc3f6 Merge "mux: ensure # images = # tiles"
-53af99b1 Merge "mux: use size_t consistently"
-39a57dae Makefile.am: header file maintenance
-1bd0bd0d bit_reader.h: correct include
-326a3c6b mux: ensure # images = # tiles
-95667b8d mux: use size_t consistently
-231ec1fb Removing the indirection of meta-huffman tables.
-15ebcbaa check return pointer from MuxImageGetListFromId
-b0d6c4a7 Merge "configure: remove test for zlib.h"
-8cccac50 Merge "dsp/lossless: silence some build warnings"
-b08819a6 dsp/lossless: silence some build warnings
-7ae22521 Android.mk: SSE2 & NEON updates
-0a49e3f3 Merge "makefile.unix add missing header files"
-2e75a9a1 Merge "decode.h: use size_t consistently"
-fa13035e configure: remove test for zlib.h
-d3adc81d makefile.unix add missing header files
-262fe01b Merge "makefile.unix & Android.mk: cosmetics"
-4cce137e Merge "enc_sse2 add missing stdlib.h include"
-80256b85 enc_sse2 add missing stdlib.h include
-9b3d1f3a decode.h: use size_t consistently
-64083d3c Merge "Makefile.am: cosmetics"
-dceb8b4d Merge changes If1331d3c,I86fe3847
-0e33d7bf Merge "webp/decode.h: fix prototypes"
-fac0f12e rename BitReader to VP8LBitReader
-fbd82b5a types.h: centralize use of stddef.h
-2154835f Makefile.am: cosmetics
-1c92bd37 vp8io: use size_t for buffer size
-90ead710 fix some more uint32_t -> size_t typing
-cbe705c7 webp/decode.h: fix prototypes
-3f8ec1c2 makefile.unix & Android.mk: cosmetics
-217ec7f4 Remove tabs in configure.ac
-b3d35fc1 Merge "Android.mk & Makefile.vc: add new files"
-0df04b9e Android.mk & Makefile.vc: add new files
-e4f20c5b Merge "automake: replace 'silent-rules' w/AM_SILENT_RULES"
-8d254a09 cosmetics
-6860c2ea fix some uint32_t -> size_t typing
-4af1858a Fix a crash due to max symbol in a tree >= alphabet size
-6f01b830 split the VP8 and VP8L decoding properly
-f2623dbe enable lossless decoder
-b96efd7d add dec/vp8i.h changes from experimental
-19f6398e add dec/vp8l{i.h,.c} from experimental
-c4ae53c8 add utils/bit_reader.[hc] changes from experimental
-514d0089 add dsp/lossless.[hc] from experimental
-9c67291d add utils/huffman.[hc] from experimental
-337914a0 add utils/color_cache.[hc] from experimental
-b3bf8fe7 the read-overflow code-path wasn't reporting as an error
-1db888ba take colorspace into account when cropping
-61c2d51f move the rescaling code into its own file and make enc/ and dec/ use it.
-efc2016a Make rescaler methods generic
-3eacee81 Move rescaler methods out of io.c.
-a69b893d automake: replace 'silent-rules' w/AM_SILENT_RULES
-6f7bf645 issue 111: fix little-endian problem in bit-reader
-ed278e22 Removed unnecessary lookup
-cd8c3ba7 fix some warnings: down-cast and possibly-uninitialized variable
-0a7102ba ~1% improvement of alpha compression
-3bc1b141 Merge "Reformat container doc"
-dc17abdc mux: cosmetics
-cb5810df Merge "WebPMuxGetImage: allow image param to be NULL"
-506a4af2 mux: cosmetics
-135e8b19 WebPMuxGetImage: allow image param to be NULL
-de556b68 Merge "README.mux: reword some descriptions"
-0ee2aeb9 Makefile.vc: use batch mode rules
-d9acddc0 msvc: move {i,p}db creation to object directory
-237c9aa7 Merge "expose WebPFree function for DLL builds"
-b3e4054f silence msvc debug build warning
-45feb55d expose WebPFree function for DLL builds
-11316d84 README.mux: reword some descriptions
-4be52f4a factorize WebPMuxValidate
-14f6b9f6 mux: light cleanup
-5e96a5db add more param checks to WebPPictureDistortion()
-8abaf820 Merge "silence some type size related warnings"
-1601a39b silence some type size related warnings
-f3abe520 Merge "idec: simplify buffer size calculation"
-a9c5cd4c idec: simplify buffer size calculation
-7b06bd7f Merge "configure/automake: add silent-rules option"
-e9a7d145 Reformat container doc
-d4e5c7f3 configure/automake: add silent-rules option
-5081db78 configure/automake: no -version-info for convenience libs
-85b6ff68 Merge "idec: fix WebPIUpdate failure"
-7bb6a9cc idec: fix internal state corruption
-89cd1bb8 idec: fix WebPIUpdate failure
-01b63806 4-5% faster decoding, optimized byte loads in arithmetic decoder.
-631117ea Merge "cosmetics & warnings"
-a0b2736d cosmetics & warnings
-f73947f4 use 32bit for storing dequant coeffs, instead of 16b.
-b9600308 Merge "store prediction mode array as uint8_t[16], not int[16]."
-7b67881a store prediction mode array as uint8_t[16], not int[16].
-cab8d4dc Merge "NEON TransformOne"
-ba503fda NEON TransformOne
-9f740e3b Merge "gcc warning fix: remove the 'const' qualifier."
-f76d3587 gcc warning fix: remove the 'const' qualifier.
-e78478d6 Merge "webpmux: make more use of WebPData"
-f85bba3d Merge "manpages: add BUGS section"
-48a43bbf Merge "makefile.unix: variable cosmetics"
-c274dc96 makefile.unix: variable cosmetics
-1f7b8595 re-organize the error-handling in the main loop a bit
-1336fa71 Only recompute level_cost_[] when needed
-771ee449 manpages: add BUGS section
-0f7820e6 webpmux: make more use of WebPData
-974aaff3 examples: logging updates
-6c14aadd Merge "better token buffer code"
-f4054250 better token buffer code
-18d959fa Merge "mux: add WebPData type"
-eec4b877 mux: add WebPData type
-0de3096b use 16bit counters for recording proba counts
-7f23678d fix for LevelCost + little speed-up
-7107d544 further speed-up/cleanup of RecordCoeffs() and GetResidualCost()
-fd221040 Introduce Token buffer (unused for now)
-5fa148f4 Merge "speed-up GetResidualCost()"
-28a9d9b4 speed-up GetResidualCost()
-11e7dadd Merge "misc cosmetics"
-378086bd misc cosmetics
-d61479f9 add -print_psnr and -print_ssim options to cwebp.
-2e3e8b2e add a WebPCleanupTransparentArea() method
-552c1217 Merge "mux: plug some memory leaks on error"
-a2a81f7d Merge "fix Mach-O shared library build"
-b3482c43 Merge "fix gcc-4.0 apple 32-bit build"
-e4e3ec19 fix gcc-4.0 apple 32-bit build
-b0d2fecf mux: plug some memory leaks on error
-f0d2c7a7 pass of cosmetics
-b309a6f9 fix Mach-O shared library build
-241ddd38 doc: delete mux container pdf
-8b1ba272 doc: update VP8 decode guide link
-7e4371c5 WebPMuxCreate: fix unchecked malloc
-eb425586 Merge "have makefile.unix clean up src/webp/*~ too"
-a85c3631 Merge "correct EncodeAlpha documentation"
-a33842fd Merge "Update webp container spec with alpha filter options."
-8d6490da Incremental support for some of the mux APIs.
-b8375abd have makefile.unix clean up src/webp/*~ too
-b5855fc7 correct EncodeAlpha documentation
-dba37fea Update webp container spec with alpha filter options.
-2e74ec8b fix compile under MINGW
-716d1d7f fix suboptimal MAX_LEN cut-off limit
-57cab7b8 Harmonize the alpha-filter predictions at boundary
-3a989534 Merge "Fix bug for Alpha in RGBA_4444 color-mode."
-8ca2076d Introduce a 'fast' alpha mode
-221a06bb Fix bug for Alpha in RGBA_4444 color-mode.
-ad1e163a cosmetics: normalize copyright headers
-c77424d7 cosmetics: light include cleanup
-9d0e17c9 fix msvc build breakage after 252028a
-7c4c177c Some readability fixes for mux library
-d8a47e66 Merge "Add predictive filtering option for Alpha."
-252028aa Add predictive filtering option for Alpha.
-9b69be1c Merge "Simplify mux library code"
-a056170e Simplify mux library code
-992187a3 improve log2 test
-e852f832 update Android.mk file list
-a90cb2be reduce number of copies and mallocs in alpha plane enc/dec
-b1662b05 fix some more type conversion warnings w/MSVC
-223d8c60 fix some uint64_t -> int conversion warnings with MSC
-c1a0437b Merge "simplify checks for enabling SSE2 code"
-f06817aa simplify checks for enabling SSE2 code
-948d4fe9 silence a msvc build warning
-91179549 vwebp: msvc build tweaks
-7937b409 simple WebP viewer, based on OpenGL
-6aac1df1 add a bunch of missing 'extern "C"'
-421eb99d Merge "Remove assigned-but-not-used variable "br""
-91e27f45 better fitting names for upsampling functions
-a5d7ed5c Remove assigned-but-not-used variable "br"
-f62d2c94 remove unused 'has_alpha' from VP8GetInfo() signature
-08e86582 trap alpha-decoding error
-b361eca1 add cut-off to arith coder probability update.
-8666a93a Some bug-fixes for images with alpha.
-273a12a0 fix off-by-1 diff in case cropping and simple filtering
-2f741d1e webpmux: ReadImage: fix ptr free in error case
-721f3f48 fix alpha decode
-60942c8c fix the has_alpha_ order
-30971c9e Implement progress report (and user abort)
-eda520a9 cosmetics after 9523f2a
-38bd5bb5 Merge "Better alpha support in webpmux binary"
-ccbaebfe Merge "Updated the includes to relative paths."
-d71fbdcc fix small typo in error message array
-cdf97aa2 Better alpha support in webpmux binary
-885f25bc Updated the includes to relative paths.
-a0ec9aac Update WebP encoder (cwebp) to support Alpha.
-667b769a Fixed the include for types.h within mux.h
-9523f2a5 Add Alpha Encode support from WebPEncode.
-16612ddd Merge "Add Alpha Decode support from WebPDecode."
-d117a940 Add Alpha Decode support from WebPDecode.
-67228734 cosmetics after e1947a9
-e1947a92 Add Alpha encode/decode code.
-afc4c5d6 simplify code by introducing a CopyPlane() helper func
-113b3128 Merge "MUX API Updates"
-c398f595 MUX API Updates
-5acf04ef remove orphan source file
-059f03ef Merge "dec: validate colorspace before using as array index"
-70a03989 Merge "factorize some code"
-9b243b3d factorize some code
-372e2b46 Correct a bug in ReadPNG() with GRAY_ALPHA images
-469d6eb9 Merge "Makefile.am: remove redundant noinst_HEADERS"
-9fe3372f dec: validate colorspace before using as array index
-8962030f remove orphan source file
-ced3e3f4 Makefile.am: remove redundant noinst_HEADERS
-964387ed use WEBP_INLINE for inline function declarations
-90880a11 Merge "manpages: break long lines"
-b5910895 Merge "manpages: minor formatting updates"
-4c451e4a Merge "Rectify the Chunk parsing logic."
-04e84cf1 examples: slight cleanup
-099717ce manpages: break long lines
-1daf39bb manpages: minor formatting updates
-abd030b5 fix missing "(void)" in function signature
-f6a7d758 remove useless test
-f07b2138 Rectify the Chunk parsing logic.
-b8634f7d webpmux: fix lib link order
-42c2e682 Fix missing coma (on uncompiled code)
-d8329d41 Android.mk: add missing source files
-13a54df5 Merge "More aggressive copy-edit; add TODO; validate HTML5"
-868b96ae More aggressive copy-edit; add TODO; validate HTML5
-767afea2 configure: check for a symbol contained in libpng
-408b8918 Merge "Linewrap at 72 cols. Casual copy-edit."
-3ae318c7 Merge "Restore (most) emphasis; add emphasis to normative RFC 2119 terms (MUST, etc.)"
-918eb2d8 Merge "Basic container doc source clean-up; fix lists and pseudocode blocks."
-03bec9e0 Linewrap at 72 cols. Casual copy-edit.
-2678d819 Restore (most) emphasis; add emphasis to normative RFC 2119 terms (MUST, etc.)
-428674da Basic container doc source clean-up; fix lists and pseudocode blocks.
-6a77d928 Merge "Makefile.vc: cosmetics"
-28c38e8c Merge "Makefile.vc: condense directory creation rules"
-55be2cf8 Initial import of container spec document, from pdftotext transform.
-a82a788b Makefile.vc: cosmetics
-c8f41ce5 Makefile.vc: condense directory creation rules
-2b877cd0 Some fixes to Makefile.vc to support the src\mux directory.
-3eb969b3 Merge "Add Makefile.vc for Mux library & binary."
-e78e971e Add Makefile.vc for Mux library & binary.
-6aedde58 Add manual for WebPMux tool.
-8a360d0a Merge "Added WebPMux Binary."
-a4f32cae Added WebPMux Binary.
-f3bf4c76 Added Mux Container Spec & README for MUX-API.
-9f761cfa Changed function signature for WebPMuxCreate
-5f31b5ec Merge "Add Mux library for manipulating WebP container."
-2315785f Add Mux library for manipulating WebP container.
-7e198abb update ChangeLog (tag: v0.1.3)
-dfc9c1ea Harmonize the dates
-28ad70c5 Fix PNG decoding bug
-846e93c5 Update AUTHORS & add .mailmap
-563e52d6 cosmetics after '76036f5 Refactor decoder library'
-76036f54 Refactor decoder library
-377ef43c configure.ac: update AC_INIT params
-7a8d8762 use a user-visible MACRO for max width/height.
-d4e9f559 NEON decode support in WebP
-0ee683b5 update libtool version-info
-fdbe02c5 windows: match _cond_destroy logic w/return variable name
-206b686b README: correct advanced decode api pseudo-code
-6a32a0f5 make VP8BitReader a typedef, for better re-use
-b112e836 create a libwebputils under src/utils
-ee697d9f harmonize the include guards and #endif comments
-a1ec07a6 Fixing compiler error in non x86 arch.
-dcfa509a Fixed recursive inclusion of bit_writer.h and vp8enci.h.
-e06ac088 create a separate libwebpdsp under src/dsp
-ebeb412a use unsigned int for bitfields
-341cc56a make kNewRange a static array
-227a91e5 README: minor wording update
-05bd8e6a add man pages to dist
-812dfa1a bump up versions in preparations for 0.1.3
-a5b78c81 wrap alpha-related options under WEBP_EXPERIMENTAL_FEATURES flag
-34dc7907 regen ChangeLog for 0.1.3-rc2
-7c436630 Silence some (more) Visual Studio warnings.
-60306e8c add top-level gitattributes
-2aa6b80e Slience some Visual Studio warnings.
-4cbbb290 Merge "bump up version for next freeze"
-a3291674 bump up version for next freeze
-c7e86aba cosmetics: fix comment line lengths
-c9e037ab makefile.unix: add simple dist target
-87d58ce9 makefile.unix: rule maintenance
-d477de77 mend
-fac15ec7 Update NEWS & README for next release V0.1.3
-6215595c Merge "add a -partition_limit option to limit the number of bits used by intra4x4"
-3814b76c Merge "reorganize chunk-parsing code"
-900286e0 add a -partition_limit option to limit the number of bits used by intra4x4
-cd12b4b0 add the missing cost for I4/I16 mode selection
-dfcc2136 reorganize chunk-parsing code
-3cf20306 initialize pointers to function within VP8DspInit()
-d21b4795 Merge "windows: add decode threading support"
-473ae953 fix hang on thread creation failure
-fccca420 windows: add decode threading support
-a31f843a Use the exact PNG_INCLUDES/PNG_LIBS when testing for -lpng
-ad9b45f1 Merge "Makefile.vc: rule maintenance"
-565a2cab Makefile.vc: rule maintenance
-2d0da681 makefile.unix: disable Wvla by default
-fc7815d6 multi-thread decoding: ~25-30% faster
-acd8ba42 io->teardown() was not always called upon error
-c85527b1 Merge "Makefile.vc: add DLL configs"
-e1e9be35 cosmetics: spelling/grammar in README and lib headers
-b4d0ef8f Makefile.vc: add DLL configs
-998754a7 remove unused nb_i4_ and nb_i16_ fields.
-9f01ce3a rename WebPDecBuffer::memory -> private_memory
-fb5d659b fix an overflow bug in LUT calculation
-d646d5c7 swig: add WebPDecodeARGB
-78aeed40 add missing WebPDecodeARGBInto() and switch ARGB4444 to RGBA4444 as was intended
-cd7c5292 explicitly mark library functions as extern
-19db59f8 add support for RGB565, ARGB4444 and ARGB colorspace (decoder)
-c915fb2a encoder speed-up: hardcode special level values
-c558bdad Rename and improve the API to retrieve decoded area
-bf599d74 Merge "makefile.unix: disable -Wvla by default"
-c9ea03d7 SSE2 version of strong filtering
-993af3e2 makefile.unix: disable -Wvla by default
-3827e1bc Merge "examples: (windows/WIC) add alpha support"
-e291fae0 SSE2 functions for the fancy upsampler.
-a06bbe2e add WebPISetIOHooks() to set some custom hooks on the incremental decoder object.
-7643a6f2 Merge "makefile.unix: use uname to detect OSX environment"
-5142a0be export alpha channel (if present) when dumping to PGM format
-14d5731c makefile.unix: use uname to detect OSX environment
-08057062 examples: quiet warnings
-3cfe0888 examples: (windows/WIC) add alpha support
-13ed94b8 add compile warning for variable-length-array
-5a18eb1a Merge "add Advanced Decoding Interface"
-5c4f27f9 add missing \n
-f4c4e416 80 cols fix
-d2603105 add Advanced Decoding Interface
-bd2f65f6 sse2 version of the complex filter
-96ed9ce0 perform two idct transforms at a time when possible
-01af7b69 use aligned stored
-0e1d1fdf Merge "Makefile.vc: add experimental target"
-2a1292a6 Makefile.vc: add experimental target
-23bf351e Enable decode SSE2 for Visual Studio
-131a4b7b dec/dsp_sse2: fix visual studio compile
-00d9d680 swig: file reorganization
-7fc7e0d9 Merge "swig/java: basic encode support"
-3be57b16 fix MSVC compile for WEBP_EXPERIMENTAL_FEATURES
-40a7e347 dec/dsp: disable sse2 for Visual Studio builds
-e4d540c8 add SSE2 code for transform
-54f2170a swig/java: basic encode support
-c5d4584b call function pointers instead of C-version
-ea43f045 Merge "configure: mingw32 targets: test for WIC support"
-a11009d7 SSE2 version of simple in-loop filtering
-42548da9 shave one unneeded filter-cache line
-31f9dc6f configure: mingw32 targets: test for WIC support
-19559699 Merge "split expression in two."
-415dbe46 split expression in two.
-e29072a8 configure: test for zlib only w/--enable-experimental
-b2b0090b Simplify Visual Studio ifdefs
-ca7a2fd6 Add error reporting from encoding failures.
-6c9405db Merge "Makefile.vc: require CFG with clean target"
-0424ecd9 Makefile.vc: require CFG with clean target
-003417c7 Enable SSE2 for Visual Studio builds
-af10db4a little speed up for VP8BitUpdate()
-e71418f8 more MSVC files to ignore
-46d90363 cosmetics
-edf59ab3 typo fix
-72229f5f Add support for x64 and SSE2 builds under Windows.
-92e5c6e1 VP8GetInfo() + WebPResetDecParams()
-416b7a6b raise the fixed-point precision for the rescaler
-aa87e4e0 fix alignment
-eb66670c disable WEBP_EXPERIMENTAL_FEATURES
-c5ae7f65 typo fix: USE_ => WEBP_
-d041efae swig: add libwebp.jar/libwebp_java_wrap.c
-f6fb3877 add swig interface
-e9273902 align buffer for double too
-842c009b fix -strong option
-d0a70387 Merge "cosmetics"
-fc0a02e5 fix the dichotomy loop
-38369c03 cosmetics
-8dfc4c6f factorize and unify GetAlpha() between the C and SSE2 version
-6d0e66c2 prepare experimentation with yuv444 / 422
-79cc49f5 add a --enable-experimental option to './configure'
-d7575238 sse2 version of CollectHistogram()
-c1c728d6 add an extra #ifdef WEBP_EXPERIMENTAL_FEATURES to avoid 'unused variable' warning
-60c61d2d always call VP*EncDeleteAlpha() unconditionnally, for simplicity
-0f8c6384 simply don't call WriteExtensions() if WEBP_EXPERIMENTAL_FEATURES is not defined
-47c661d5 rename swap -> swap_rb
-10d55bbb move chunk[] declaration out of the for() loop
-517cec21 fix indentation
-f7d9e261 fix merge problems
-8fd42b3a add a stride 'a_stride' for the alpha plane
-b8dcbf2f fix alpha-plane copy and crop methods
-cdef89de fix some 'unused variable' warning
-fb29c262 SSE2 version of the fwd transform and the squared sum metric
-2ab4b72f EXPERIMENTAL: add support for alpha channel
-cfbf88a6 add SSE2 functions. ~2x faster encoding on average.
-e7ff3f9a merge two ITransforms together when applicable and change the TTransform to return the sum directly.
-ca554137 fix WebPIDecGetRGB() to accept any RGB(A) mode, not just MODE_RGB
-8aa50efd fix some 'man' typos
-d3f3bdda update ChangeLog (tag: v0.1.2)
-d7e9a69c update contributor list
-261abb8e add a 'superclean' section
-276ae825 Remove files not mean to be in git, and update .gitignore
-24868455 build: prepare libwebp.pc
-14ceb6e8 add "-version" description to man pages
-b247a3b2 Create the m4 directory, and also place .gitignore in there for libtool.
-cdd734c9 Resolve automake warnings
-c5fa726e build: add pkgconfig files
-b20aaca2 build: just use autoreconf, avoid calling tools manually
-4b0b0d66 cwebp: use modern functions
-efbc6c41 update Android.mk
-7777570b better version of ChangeLog
-fa70d2b7 update version number in the DOC
-f8db5d5d more C89-fixes
-0de013b3 fix typos
-650ffa3b add version getters for decoder and encoder
-be4867d2 doc for incremental decoding
-56732a1b add idec.obj in MSVC makefile
-208afb5e add c++ guards
-8bf76fe0 add incremental decoding
-1f288328 'inline' isn't defined in strict ansi c89
-8b77c632 move the quantization function to dsp.c
-b2c3575c add a 'last_y' field to WebPDecParams
-2654c3da correctly pass along the exact same status returned from ParsePartitions
-4704146a add missing precision in the man
-6d978a6c add error messages
-6463e6ab add some install instructions, and fix intel-mac flags
-05fb7bfc Merge ".gitignore: initial version"
-c33f0195 .gitignore: initial version
-e532b9ab Makefile: allow out of tree builds
-4c0da7aa enable sparse dc/ac transforms
-07dbb8d5 clarify the return logic
-5c69e1bb fix bigger-by-1 array
-7c5267e3 fix a (harmless) typo: non_zero_ -> non_zero_ac_
-bc752135 fix missing free()
-af3e2aaa remove trailing spaces
-13e50da6 make the bitreader preload at least 8bits, instead of post-load them (this makes initialization easier and will be helpful for incremental decoding). Modify ParsePartitions() to accommodate for truncated input.
-f4888f77 emit 9 - nb_bits trailing zeros instead of 8
-3db65255 separate block-parsing into a visible VP8DecodeMB()
-a871de02 add missing extern "C"
-b3ce8c52 remove a gcc warning about type pun by using a proper union'd type
-e1863715 update after addition of webpi.h
-3e856e2d Extract some useful functions around decoding buffer WebPDecParams.
-d5bc05a4 make the filtering process match libvpx and ffvp8
-dd60138d add man pages for cwebp(1) and dwebp(1)
-c4fa3644 fix header
-5b70b378 * add an option to bypass_filtering in VP8Io.
-b97a4003 simplify QuantizeBlock code a bit
-84b58ebb add more checks around picture allocation
-b65a3e10 remove absolute_delta_ field and syntax code
-0744e842 Dont' open output file until we're sure the input file is valid
-d5bd54c7 fix typo and buggy line
-f7a9549d Add a simple top-level makefile.unix for quick & easy build.
-5f36b944 update the doc for the -f option
-f61d14aa a WebP encoder converts PNG & JPEG to WebP
-81c96621 oops: forgotten call to Initialize() + move the error message to a more useful place
-87ffa005 typo: fix a missing 'R', was confusing.
-b04b857a * add decoding measurement using stopwatch.h (use -v option) * support PNG output through WIC on Win32
-746a4820 * make (*put)() hook return a bool for abort request. * add an enum for VP8Status() to make things clearer
-73c973e6 * strengthen riff/chunk size checks * don't consider odd-sized chunks being an error
-1dc4611a add support for PNG output (default) regularize include guards
-860641df fix a typo: sizeof(kYModeProbaInter0) => sizeof(kUVModeProbaInter0)
-3254fc52 fix some petty constness fix the ./configure file too
-504d3393 fix eof_ mis-initialization
-2bc0778f leftover Makefile.* from previous commit
-d2cf04e4 move Makefile.am one level below, to src/dec fix typos here and there dwebp is now an installed program
-ade92de8 typo: vp8.h -> decode_vp8.h
-d7241241 forgot to declare types.h to be installed
-6421a7a4 move the decoder sourcetree to a sub-location src/dec to make room for future libs sources
-a9b3eab6 correct layout name is IMC4.
-2330522c handle corner case of zero-dimensions
-280c3658 make VP8Init() handle short buffers (< 2 bytes) correctly
-b1c9e8b4 handle error cases more robustly
-0e94935c Merge "table-less version of clip_8b()"
-1e0a2d25 table-less version of clip_8b()
-e12109ee dwebp: change -yuv option to -raw change the layout to IMC2
-d72180a4 speed-up fancy upscaler
-9145f3bc reset eof_ at construction time
-a7ee0559 simplify the logic of GetCoeffs()
-f67b5939 lot of cosmetics
-ea27d7c6 fix endian problem on PowerPC
-beb0a1ba fix signature of VP8StoreBlock
-b128c5e2 Merge "fancy chroma upscaling"
-6a37a2aa fancy chroma upscaling
-ff565edc fix two numeric typos
-5a936a0a use uintptr_t for casting pointers to ints
-e14a0301 for cross_compiling=yes to prevent executing any binary
-83b545ee add vc9+ makefile
-296f6914 fix output loop for small height
-cbfbb5c3 convert to plain-C
-f09f96ee Fix declaration after statement warning
-5981ee55 Fix UV plane ac/dc quantizer transposition
-c8d15efa convert to ANSI-C
-c3f41cb4 Initial commit
diff --git a/contrib/libs/libwebp/NEWS b/contrib/libs/libwebp/NEWS
deleted file mode 100644
index 5b36c5cf30..0000000000
--- a/contrib/libs/libwebp/NEWS
+++ /dev/null
@@ -1,274 +0,0 @@
-- 1/11/2022: version 1.2.2
- This is a binary compatible release.
- * webpmux: add "-set bgcolor A,R,G,B"
- * add ARM64 NEON support for MSVC builds (#539)
- * fix duplicate include error in Xcode when using multiple XCFrameworks in a
- project (#542)
- * doc updates and bug fixes (#538, #544, #548, #550)
-
-- 7/20/2021: version 1.2.1
- This is a binary compatible release.
- * minor lossless encoder improvements and x86 color conversion speed up
- * add ARM64 simulator support to xcframeworkbuild.sh (#510)
- * further security related hardening in libwebp & examples
- (issues: #497, #508, #518)
- (chromium: #1196480, #1196773, #1196775, #1196777, #1196778, #1196850)
- (oss-fuzz: #28658, #28978)
- * toolchain updates and bug fixes (#498, #501, #502, #504, #505, #506, #509,
- #533)
- * use more inclusive language within the source (#507)
-
-- 12/23/2020: version 1.2.0
- * API changes:
- - libwebp:
- encode.h: add a qmin / qmax range for quality factor (cwebp adds -qrange)
- * lossless encoder improvements
- * SIMD support for Wasm builds
- * add xcframeworkbuild.sh, supports Mac Catalyst builds
- * import fuzzers from oss-fuzz & chromium (#409)
- * webpmux: add an '-set loop <value>' option (#494)
- * toolchain updates and bug fixes (#449, #463, #470, #475, #477, #478, #479,
- #488, #491)
-
-- 12/18/2019: version 1.1.0
- * API changes:
- - libwebp:
- WebPMalloc (issue #442)
- - extras:
- WebPUnmultiplyARGB
- * alpha decode fix (issue #439)
- * toolchain updates and bug fixes
- (chromium: #1026858, #1027136, #1027409, #1028620, #1028716, #995200)
- (oss-fuzz: #19430, #19447)
-
-- 7/4/2019: version 1.0.3
- This is a binary compatible release.
- * resize fixes for Nx1 sizes and the addition of non-opaque alpha values for
- odd sizes (issues #418, #434)
- * lossless encode/decode performance improvements
- * lossy compression performance improvement at low quality levels with flat
- content (issue #432)
- * python swig files updated to support python 3
- Tool updates:
- vwebp will now preserve the aspect ratio of images that exceed monitor
- resolution by scaling the image to fit (issue #433)
-
-- 1/14/2019: version 1.0.2
- This is a binary compatible release.
- * (Windows) unicode file support in the tools (linux and mac already had
- support, issue #398)
- * lossless encoder speedups
- * lossy encoder speedup on ARM
- * lossless multi-threaded security fix (chromium:917029)
-
-- 11/2/2018: version 1.0.1
- This is a binary compatible release.
- * lossless encoder speedups
- * big-endian fix for alpha decoding (issue #393)
- * gif2webp fix for loop count=65535 transcode (issue #382)
- * further security related hardening in libwebp & libwebpmux
- (issues #383, #385, #386, #387, #388, #391)
- (oss-fuzz #9099, #9100, #9105, #9106, #9111, #9112, #9119, #9123, #9170,
- #9178, #9179, #9183, #9186, #9191, #9364, #9417, #9496, #10349,
- #10423, #10634, #10700, #10838, #10922, #11021, #11088, #11152)
- * miscellaneous bug & build fixes (issues #381, #394, #396, #397, #400)
-
-- 4/2/2018: version 1.0.0
- This is a binary compatible release.
- * lossy encoder improvements to avoid chroma shifts in various circumstances
- (issues #308, #340)
- * big-endian fixes for decode, RGBA import and WebPPictureDistortion
- Tool updates:
- gifwebp, anim_diff - default duration behavior (<= 10ms) changed to match
- web browsers, transcoding tools (issue #379)
- img2webp, webpmux - allow options to be passed in via a file (issue #355)
-
-- 11/24/2017: version 0.6.1
- This is a binary compatible release.
- * lossless performance and compression improvements + a new 'cruncher' mode
- (-m 6 -q 100)
- * ARM performance improvements with clang (15-20% w/ndk r15c, issue #339)
- * webp-js: emscripten/webassembly based javascript decoder
- * miscellaneous bug & build fixes (issue #329, #332, #343, #353, #360, #361,
- #363)
- Tool updates / additions:
- added webpinfo - prints file format information (issue #330)
- gif2webp - loop behavior modified to match Chrome M63+ (crbug.com/649264);
- '-loop_compatibility' can be used for the old behavior
-
-- 1/26/2017: version 0.6.0
- * lossless performance and compression improvements
- * miscellaneous performance improvements (SSE2, NEON, MSA)
- * webpmux gained a -duration option allowing for frame timing modification
- * new img2webp utility allowing a sequence of images to be converted to
- animated webp
- * API changes:
- - libwebp:
- WebPPictureSharpARGBToYUVA
- WebPPlaneDistortion
- - libwebpmux / gif2webp:
- WebPAnimEncoderOptions: kmax <= 0 now disables keyframes, kmax == 1
- forces all keyframes. See mux.h and the gif2webp
- manpage for details.
-
-- 12/13/2016: version 0.5.2
- This is a binary compatible release.
- This release covers CVE-2016-8888 and CVE-2016-9085.
- * further security related hardening in the tools; fixes to
- gif2webp/AnimEncoder (issues #310, #314, #316, #322), cwebp/libwebp (issue
- #312)
- * full libwebp (encoder & decoder) iOS framework; libwebpdecoder
- WebP.framework renamed to WebPDecoder.framework (issue #307)
- * CMake support for Android Studio (2.2)
- * miscellaneous build related fixes (issue #306, #313)
- * miscellaneous documentation improvements (issue #225)
- * minor lossy encoder fixes and improvements
-
-- 6/14/2016: version 0.5.1
- This is a binary compatible release.
- * miscellaneous bug fixes (issues #280, #289)
- * reverted alpha plane encoding with color cache for compatibility with
- libwebp 0.4.0->0.4.3 (issues #291, #298)
- * lossless encoding performance improvements
- * memory reduction in both lossless encoding and decoding
- * force mux output to be in the extended format (VP8X) when undefined chunks
- are present (issue #294)
- * gradle, cmake build support
- * workaround for compiler bug causing 64-bit decode failures on android
- devices using clang-3.8 in the r11c NDK
- * various WebPAnimEncoder improvements
-
-- 12/17/2015: version 0.5.0
- * miscellaneous bug & build fixes (issues #234, #258, #274, #275, #278)
- * encoder & decoder speed-ups on x86/ARM/MIPS for lossy & lossless
- - note! YUV->RGB conversion was sped-up, but the results will be slightly
- different from previous releases
- * various lossless encoder improvements
- * gif2webp improvements, -min_size option added
- * tools fully support input from stdin and output to stdout (issue #168)
- * New WebPAnimEncoder API for creating animations
- * New WebPAnimDecoder API for decoding animations
- * other API changes:
- - libwebp:
- WebPPictureSmartARGBToYUVA() (-pre 4 in cwebp)
- WebPConfig::exact (-exact in cwebp; -alpha_cleanup is now the default)
- WebPConfig::near_lossless (-near_lossless in cwebp)
- WebPFree() (free'ing webp allocated memory in other languages)
- WebPConfigLosslessPreset()
- WebPMemoryWriterClear()
- - libwebpdemux: removed experimental fragment related fields and functions
- - libwebpmux: WebPMuxSetCanvasSize()
- * new libwebpextras library with some uncommon import functions:
- WebPImportGray/WebPImportRGB565/WebPImportRGB4444
-
-- 10/15/15: version 0.4.4
- This is a binary compatible release.
- * rescaling out-of-bounds read fix (issue #254)
- * various build fixes and improvements (issues #253, #259, #262, #267, #268)
- * container documentation update
- * gif2webp transparency fix (issue #245)
-
-- 3/3/15: version 0.4.3
- This is a binary compatible release.
- * Android / gcc / iOS / MSVS build fixes and improvements
- * lossless decode fix (issue #239 -- since 0.4.0)
- * documentation / vwebp updates for animation
- * multi-threading fix (issue #234)
-
-- 10/13/14: version 0.4.2
- This is a binary compatible release.
- * Android / gcc build fixes
- * (Windows) fix reading from stdin and writing to stdout
- * gif2webp: miscellaneous fixes
- * fix 'alpha-leak' with lossy compression (issue #220)
- * the lossless bitstream spec has been amended to reflect the current code
-
-- 7/24/14: version 0.4.1
- This is a binary compatible release.
- * AArch64 (arm64) & MIPS support/optimizations
- * NEON assembly additions:
- - ~25% faster lossy decode / encode (-m 4)
- - ~10% faster lossless decode
- - ~5-10% faster lossless encode (-m 3/4)
- * dwebp/vwebp can read from stdin
- * cwebp/gif2webp can write to stdout
- * cwebp can read webp files; useful if storing sources as webp lossless
-
-- 12/19/13: version 0.4.0
- * improved gif2webp tool
- * numerous fixes, compression improvement and speed-up
- * dither option added to decoder (dwebp -dither 50 ...)
- * improved multi-threaded modes (-mt option)
- * improved filtering strength determination
- * New function: WebPMuxGetCanvasSize
- * BMP and TIFF format output added to 'dwebp'
- * Significant memory reduction for decoding lossy images with alpha.
- * Intertwined decoding of RGB and alpha for a shorter
- time-to-first-decoded-pixel.
- * WebPIterator has a new member 'has_alpha' denoting whether the frame
- contains transparency.
- * Container spec amended with new 'blending method' for animation.
-
-- 6/13/13: version 0.3.1
- This is a binary compatible release.
- * Add incremental decoding support for images containing ALPH and ICCP chunks.
- * Python bindings via swig for the simple encode/decode interfaces similar to
- Java.
-
-- 3/20/13: version 0.3.0
- This is a binary compatible release.
- * WebPINewRGB/WebPINewYUVA accept being passed a NULL output buffer
- and will perform auto-allocation.
- * default filter option is now '-strong -f 60'
- * encoding speed-up for lossy methods 3 to 6
- * alpha encoding can be done in parallel to lossy using 'cwebp -mt ...'
- * color profile, metadata (XMP/EXIF) and animation support finalized in the
- container.
- * various NEON assembly additions
- Tool updates / additions:
- * gif2webp added
- * vwebp given color profile & animation support
- * cwebp can preserve color profile / metadata with '-metadata'
-
-- 10/30/12: version 0.2.1
- * Various security related fixes
- * cwebp.exe: fix import errors on Windows XP
- * enable DLL builds for mingw targets
-
-- 8/3/12: version 0.2.0
- * Add support for ARGB -> YUVA conversion for lossless decoder
- New functions: WebPINewYUVA, WebPIDecGetYUVA
- * Add stats for lossless and alpha encoding
- * Security related hardening: allocation and size checks
- * Add PAM output support to dwebp
-
-- 7/19/12: version 0.1.99
- * This is a pre-release of 0.2.0, not an rc to allow for further
- incompatible changes based on user feedback.
- * Alpha channel encode/decode support.
- * Lossless encoder/decoder.
- * Add TIFF input support to cwebp.
- Incompatible changes:
- * The encode ABI has been modified to support alpha encoding.
- * Deprecated function WebPINew() has been removed.
- * Decode function signatures have changed to consistently use size_t over
- int/uint32_t.
- * decode_vp8.h is no longer installed system-wide.
- * cwebp will encode the alpha channel if present.
-
-- 9/19/11: version 0.1.3
- * Advanced decoding APIs.
- * On-the-fly cropping and rescaling of images.
- * SSE2 instructions for decoding performance optimizations on x86 based
- platforms.
- * Support Multi-threaded decoding.
- * 40% improvement in Decoding performance.
- * Add support for RGB565, RGBA4444 & ARGB image colorspace.
- * Better handling of large picture encoding.
-
-- 3/25/11: version 0.1.2
- * Incremental decoding: picture can be decoded byte-by-byte if needs be.
- * lot of bug-fixes, consolidation and stabilization
-
-- 2/23/11: initial release of version 0.1, with the new encoder
-- 9/30/10: initial release version with only the lightweight decoder
diff --git a/contrib/libs/libwebp/PATENTS b/contrib/libs/libwebp/PATENTS
deleted file mode 100644
index caedf607e9..0000000000
--- a/contrib/libs/libwebp/PATENTS
+++ /dev/null
@@ -1,23 +0,0 @@
-Additional IP Rights Grant (Patents)
-------------------------------------
-
-"These implementations" means the copyrightable works that implement the WebM
-codecs distributed by Google as part of the WebM Project.
-
-Google hereby grants to you a perpetual, worldwide, non-exclusive, no-charge,
-royalty-free, irrevocable (except as stated in this section) patent license to
-make, have made, use, offer to sell, sell, import, transfer, and otherwise
-run, modify and propagate the contents of these implementations of WebM, where
-such license applies only to those patent claims, both currently owned by
-Google and acquired in the future, licensable by Google that are necessarily
-infringed by these implementations of WebM. This grant does not include claims
-that would be infringed only as a consequence of further modification of these
-implementations. If you or your agent or exclusive licensee institute or order
-or agree to the institution of patent litigation or any other patent
-enforcement activity against any entity (including a cross-claim or
-counterclaim in a lawsuit) alleging that any of these implementations of WebM
-or any code incorporated within any of these implementations of WebM
-constitute direct or contributory patent infringement, or inducement of
-patent infringement, then any patent rights granted to you under this License
-for these implementations of WebM shall terminate as of the date such
-litigation is filed.
diff --git a/contrib/libs/libwebp/PRESUBMIT.py b/contrib/libs/libwebp/PRESUBMIT.py
deleted file mode 100644
index 994473bc27..0000000000
--- a/contrib/libs/libwebp/PRESUBMIT.py
+++ /dev/null
@@ -1,214 +0,0 @@
-# Copyright (c) 2021, Google Inc. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-#
-# * Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in
-# the documentation and/or other materials provided with the
-# distribution.
-#
-# * Neither the name of Google nor the names of its contributors may
-# be used to endorse or promote products derived from this software
-# without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-"""Top-level presubmit script for libwebp.
-
-See https://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for
-details on the presubmit API built into depot_tools.
-"""
-
-import re
-import subprocess2
-
-USE_PYTHON3 = True
-_BASH_INDENTATION = "2"
-_GIT_COMMIT_SUBJECT_LENGTH = 65
-_INCLUDE_BASH_FILES_ONLY = [r".*\.sh$"]
-_INCLUDE_MAN_FILES_ONLY = [r"man/.+\.1$"]
-_LIBWEBP_MAX_LINE_LENGTH = 80
-
-
-def _CheckCommitSubjectLength(input_api, output_api):
- """Ensures commit's subject length is no longer than 65 chars."""
- name = "git-commit subject"
- cmd = ["git", "log", "-1", "--pretty=%s"]
- start = input_api.time.time()
- proc = subprocess2.Popen(
- cmd,
- stderr=subprocess2.PIPE,
- stdout=subprocess2.PIPE,
- universal_newlines=True)
-
- stdout, _ = proc.communicate()
- duration = input_api.time.time() - start
-
- if not re.match(r"^Revert",
- stdout) and (len(stdout) - 1) > _GIT_COMMIT_SUBJECT_LENGTH:
- failure_msg = (
- "The commit subject: %s is too long (%d chars)\n"
- "Try to keep this to 50 or less (up to 65 is permitted for "
- "non-reverts).\n"
- "https://www.git-scm.com/book/en/v2/Distributed-Git-Contributing-to-a-"
- "Project#_commit_guidelines") % (stdout, len(stdout) - 1)
- return output_api.PresubmitError("%s\n (%4.2fs) failed\n%s" %
- (name, duration, failure_msg))
-
- return output_api.PresubmitResult("%s\n (%4.2fs) success" % (name, duration))
-
-
-def _GetFilesToSkip(input_api):
- return list(input_api.DEFAULT_FILES_TO_SKIP) + [
- r"swig/.*\.py$",
- r"\.pylintrc$",
- ]
-
-
-def _RunManCmd(input_api, output_api, man_file):
- """man command wrapper."""
- cmd = ["man", "--warnings", "-EUTF-8", "-l", "-Tutf8", "-Z", man_file]
- name = "Check %s file." % man_file
- start = input_api.time.time()
- output, _ = subprocess2.communicate(
- cmd, stdout=None, stderr=subprocess2.PIPE, universal_newlines=True)
- duration = input_api.time.time() - start
- if output[1]:
- return output_api.PresubmitError("%s\n%s (%4.2fs) failed\n%s" %
- (name, " ".join(cmd), duration, output[1]))
- return output_api.PresubmitResult("%s\n%s (%4.2fs)\n" %
- (name, " ".join(cmd), duration))
-
-
-def _RunShellCheckCmd(input_api, output_api, bash_file):
- """shellcheck command wrapper."""
- cmd = ["shellcheck", "-x", "-oall", "-sbash", bash_file]
- name = "Check %s file." % bash_file
- start = input_api.time.time()
- output, rc = subprocess2.communicate(
- cmd, stdout=None, stderr=subprocess2.PIPE, universal_newlines=True)
- duration = input_api.time.time() - start
- if rc == 0:
- return output_api.PresubmitResult("%s\n%s (%4.2fs)\n" %
- (name, " ".join(cmd), duration))
- return output_api.PresubmitError("%s\n%s (%4.2fs) failed\n%s" %
- (name, " ".join(cmd), duration, output[1]))
-
-
-def _RunShfmtCheckCmd(input_api, output_api, bash_file):
- """shfmt command wrapper."""
- cmd = [
- "shfmt", "-i", _BASH_INDENTATION, "-bn", "-ci", "-sr", "-kp", "-d",
- bash_file
- ]
- name = "Check %s file." % bash_file
- start = input_api.time.time()
- output, rc = subprocess2.communicate(
- cmd, stdout=None, stderr=subprocess2.PIPE, universal_newlines=True)
- duration = input_api.time.time() - start
- if rc == 0:
- return output_api.PresubmitResult("%s\n%s (%4.2fs)\n" %
- (name, " ".join(cmd), duration))
- return output_api.PresubmitError("%s\n%s (%4.2fs) failed\n%s" %
- (name, " ".join(cmd), duration, output[1]))
-
-
-def _RunCmdOnCheckedFiles(input_api, output_api, run_cmd, files_to_check):
- """Ensure that libwebp/ files are clean."""
- file_filter = lambda x: input_api.FilterSourceFile(
- x, files_to_check=files_to_check, files_to_skip=None)
-
- affected_files = input_api.change.AffectedFiles(file_filter=file_filter)
- results = [
- run_cmd(input_api, output_api, f.AbsoluteLocalPath())
- for f in affected_files
- ]
- return results
-
-
-def _CommonChecks(input_api, output_api):
- """Ensures this patch does not have trailing spaces, extra EOLs,
- or long lines.
- """
- results = []
- results.extend(
- input_api.canned_checks.CheckChangeHasNoCrAndHasOnlyOneEol(
- input_api, output_api))
- results.extend(
- input_api.canned_checks.CheckChangeHasNoTabs(input_api, output_api))
- results.extend(
- input_api.canned_checks.CheckChangeHasNoStrayWhitespace(
- input_api, output_api))
- results.append(_CheckCommitSubjectLength(input_api, output_api))
-
- source_file_filter = lambda x: input_api.FilterSourceFile(
- x, files_to_skip=_GetFilesToSkip(input_api))
- results.extend(
- input_api.canned_checks.CheckLongLines(
- input_api,
- output_api,
- maxlen=_LIBWEBP_MAX_LINE_LENGTH,
- source_file_filter=source_file_filter))
-
- results.extend(
- input_api.canned_checks.CheckPatchFormatted(
- input_api,
- output_api,
- check_clang_format=False,
- check_python=True,
- result_factory=output_api.PresubmitError))
- results.extend(
- _RunCmdOnCheckedFiles(input_api, output_api, _RunManCmd,
- _INCLUDE_MAN_FILES_ONLY))
- # Run pylint.
- results.extend(
- input_api.canned_checks.RunPylint(
- input_api,
- output_api,
- files_to_skip=_GetFilesToSkip(input_api),
- pylintrc=".pylintrc",
- version="2.7"))
-
- # Binaries shellcheck and shfmt are not installed in depot_tools.
- # Installation is needed
- try:
- subprocess2.communicate(["shellcheck", "--version"])
- results.extend(
- _RunCmdOnCheckedFiles(input_api, output_api, _RunShellCheckCmd,
- _INCLUDE_BASH_FILES_ONLY))
- print("shfmt")
- subprocess2.communicate(["shfmt", "-version"])
- results.extend(
- _RunCmdOnCheckedFiles(input_api, output_api, _RunShfmtCheckCmd,
- _INCLUDE_BASH_FILES_ONLY))
- except OSError as os_error:
- results.append(
- output_api.PresubmitPromptWarning(
- "%s\nPlease install missing binaries locally." % os_error.args[0]))
- return results
-
-
-def CheckChangeOnUpload(input_api, output_api):
- results = []
- results.extend(_CommonChecks(input_api, output_api))
- return results
-
-
-def CheckChangeOnCommit(input_api, output_api):
- results = []
- results.extend(_CommonChecks(input_api, output_api))
- return results
diff --git a/contrib/libs/libwebp/README b/contrib/libs/libwebp/README
deleted file mode 100644
index f6eaf2c049..0000000000
--- a/contrib/libs/libwebp/README
+++ /dev/null
@@ -1,795 +0,0 @@
- __ __ ____ ____ ____
- / \\/ \/ _ \/ _ )/ _ \
- \ / __/ _ \ __/
- \__\__/\____/\_____/__/ ____ ___
- / _/ / \ \ / _ \/ _/
- / \_/ / / \ \ __/ \__
- \____/____/\_____/_____/____/v1.2.2
-
-Description:
-============
-
-WebP codec: library to encode and decode images in WebP format. This package
-contains the library that can be used in other programs to add WebP support,
-as well as the command line tools 'cwebp' and 'dwebp'.
-
-See https://developers.google.com/speed/webp
-
-The latest source tree is available at
-https://chromium.googlesource.com/webm/libwebp
-
-It is released under the same license as the WebM project.
-See https://www.webmproject.org/license/software/ or the
-"COPYING" file for details. An additional intellectual
-property rights grant can be found in the file PATENTS.
-
-Building:
-=========
-
-Windows build:
---------------
-
-By running:
-
- nmake /f Makefile.vc CFG=release-static RTLIBCFG=static OBJDIR=output
-
-the directory output\release-static\(x64|x86)\bin will contain the tools
-cwebp.exe and dwebp.exe. The directory output\release-static\(x64|x86)\lib will
-contain the libwebp static library.
-The target architecture (x86/x64) is detected by Makefile.vc from the Visual
-Studio compiler (cl.exe) available in the system path.
-
-Unix build using makefile.unix:
--------------------------------
-
-On platforms with GNU tools installed (gcc and make), running
-
- make -f makefile.unix
-
-will build the binaries examples/cwebp and examples/dwebp, along
-with the static library src/libwebp.a. No system-wide installation
-is supplied, as this is a simple alternative to the full installation
-system based on the autoconf tools (see below).
-Please refer to makefile.unix for additional details and customizations.
-
-Using autoconf tools:
----------------------
-Prerequisites:
-A compiler (e.g., gcc), make, autoconf, automake, libtool.
-On a Debian-like system the following should install everything you need for a
-minimal build:
-$ sudo apt-get install gcc make autoconf automake libtool
-
-When building from git sources, you will need to run autogen.sh to generate the
-configure script.
-
-./configure
-make
-make install
-
-should be all you need to have the following files
-
-/usr/local/include/webp/decode.h
-/usr/local/include/webp/encode.h
-/usr/local/include/webp/types.h
-/usr/local/lib/libwebp.*
-/usr/local/bin/cwebp
-/usr/local/bin/dwebp
-
-installed.
-
-Note: A decode-only library, libwebpdecoder, is available using the
-'--enable-libwebpdecoder' flag. The encode library is built separately and can
-be installed independently using a minor modification in the corresponding
-Makefile.am configure files (see comments there). See './configure --help' for
-more options.
-
-Building for MIPS Linux:
-------------------------
-MIPS Linux toolchain stable available releases can be found at:
-https://community.imgtec.com/developers/mips/tools/codescape-mips-sdk/available-releases/
-
-# Add toolchain to PATH
-export PATH=$PATH:/path/to/toolchain/bin
-
-# 32-bit build for mips32r5 (p5600)
-HOST=mips-mti-linux-gnu
-MIPS_CFLAGS="-O3 -mips32r5 -mabi=32 -mtune=p5600 -mmsa -mfp64 \
- -msched-weight -mload-store-pairs -fPIE"
-MIPS_LDFLAGS="-mips32r5 -mabi=32 -mmsa -mfp64 -pie"
-
-# 64-bit build for mips64r6 (i6400)
-HOST=mips-img-linux-gnu
-MIPS_CFLAGS="-O3 -mips64r6 -mabi=64 -mtune=i6400 -mmsa -mfp64 \
- -msched-weight -mload-store-pairs -fPIE"
-MIPS_LDFLAGS="-mips64r6 -mabi=64 -mmsa -mfp64 -pie"
-
-./configure --host=${HOST} --build=`config.guess` \
- CC="${HOST}-gcc -EL" \
- CFLAGS="$MIPS_CFLAGS" \
- LDFLAGS="$MIPS_LDFLAGS"
-make
-make install
-
-CMake:
-------
-With CMake, you can compile libwebp, cwebp, dwebp, gif2webp, img2webp, webpinfo
-and the JS bindings.
-
-Prerequisites:
-A compiler (e.g., gcc with autotools) and CMake.
-On a Debian-like system the following should install everything you need for a
-minimal build:
-$ sudo apt-get install build-essential cmake
-
-When building from git sources, you will need to run cmake to generate the
-makefiles.
-
-mkdir build && cd build && cmake ../
-make
-make install
-
-If you also want any of the executables, you will need to enable them through
-CMake, e.g.:
-
-cmake -DWEBP_BUILD_CWEBP=ON -DWEBP_BUILD_DWEBP=ON ../
-
-or through your favorite interface (like ccmake or cmake-qt-gui).
-
-Use option -DWEBP_UNICODE=ON for Unicode support on Windows (with chcp 65001).
-
-Finally, once installed, you can also use WebP in your CMake project by doing:
-
-find_package(WebP)
-
-which will define the CMake variables WebP_INCLUDE_DIRS and WebP_LIBRARIES.
-
-Gradle:
--------
-The support for Gradle is minimal: it only helps you compile libwebp, cwebp and
-dwebp and webpmux_example.
-
-Prerequisites:
-A compiler (e.g., gcc with autotools) and gradle.
-On a Debian-like system the following should install everything you need for a
-minimal build:
-$ sudo apt-get install build-essential gradle
-
-When building from git sources, you will need to run the Gradle wrapper with the
-appropriate target, e.g. :
-
-./gradlew buildAllExecutables
-
-SWIG bindings:
---------------
-
-To generate language bindings from swig/libwebp.swig at least swig-1.3
-(http://www.swig.org) is required.
-
-Currently the following functions are mapped:
-Decode:
- WebPGetDecoderVersion
- WebPGetInfo
- WebPDecodeRGBA
- WebPDecodeARGB
- WebPDecodeBGRA
- WebPDecodeBGR
- WebPDecodeRGB
-
-Encode:
- WebPGetEncoderVersion
- WebPEncodeRGBA
- WebPEncodeBGRA
- WebPEncodeRGB
- WebPEncodeBGR
- WebPEncodeLosslessRGBA
- WebPEncodeLosslessBGRA
- WebPEncodeLosslessRGB
- WebPEncodeLosslessBGR
-
-See swig/README for more detailed build instructions.
-
-Java bindings:
-
-To build the swig-generated JNI wrapper code at least JDK-1.5 (or equivalent)
-is necessary for enum support. The output is intended to be a shared object /
-DLL that can be loaded via System.loadLibrary("webp_jni").
-
-Python bindings:
-
-To build the swig-generated Python extension code at least Python 2.6 is
-required. Python < 2.6 may build with some minor changes to libwebp.swig or the
-generated code, but is untested.
-
-Encoding tool:
-==============
-
-The examples/ directory contains tools for encoding (cwebp) and
-decoding (dwebp) images.
-
-The easiest use should look like:
- cwebp input.png -q 80 -o output.webp
-which will convert the input file to a WebP file using a quality factor of 80
-on a 0->100 scale (0 being the lowest quality, 100 being the best. Default
-value is 75).
-You might want to try the -lossless flag too, which will compress the source
-(in RGBA format) without any loss. The -q quality parameter will in this case
-control the amount of processing time spent trying to make the output file as
-small as possible.
-
-A longer list of options is available using the -longhelp command line flag:
-
-> cwebp -longhelp
-Usage:
- cwebp [-preset <...>] [options] in_file [-o out_file]
-
-If input size (-s) for an image is not specified, it is
-assumed to be a PNG, JPEG, TIFF or WebP file.
-Note: Animated PNG and WebP files are not supported.
-
-Options:
- -h / -help ............. short help
- -H / -longhelp ......... long help
- -q <float> ............. quality factor (0:small..100:big), default=75
- -alpha_q <int> ......... transparency-compression quality (0..100),
- default=100
- -preset <string> ....... preset setting, one of:
- default, photo, picture,
- drawing, icon, text
- -preset must come first, as it overwrites other parameters
- -z <int> ............... activates lossless preset with given
- level in [0:fast, ..., 9:slowest]
-
- -m <int> ............... compression method (0=fast, 6=slowest), default=4
- -segments <int> ........ number of segments to use (1..4), default=4
- -size <int> ............ target size (in bytes)
- -psnr <float> .......... target PSNR (in dB. typically: 42)
-
- -s <int> <int> ......... input size (width x height) for YUV
- -sns <int> ............. spatial noise shaping (0:off, 100:max), default=50
- -f <int> ............... filter strength (0=off..100), default=60
- -sharpness <int> ....... filter sharpness (0:most .. 7:least sharp), default=0
- -strong ................ use strong filter instead of simple (default)
- -nostrong .............. use simple filter instead of strong
- -sharp_yuv ............. use sharper (and slower) RGB->YUV conversion
- -partition_limit <int> . limit quality to fit the 512k limit on
- the first partition (0=no degradation ... 100=full)
- -pass <int> ............ analysis pass number (1..10)
- -qrange <min> <max> .... specifies the permissible quality range
- (default: 0 100)
- -crop <x> <y> <w> <h> .. crop picture with the given rectangle
- -resize <w> <h> ........ resize picture (after any cropping)
- -mt .................... use multi-threading if available
- -low_memory ............ reduce memory usage (slower encoding)
- -map <int> ............. print map of extra info
- -print_psnr ............ prints averaged PSNR distortion
- -print_ssim ............ prints averaged SSIM distortion
- -print_lsim ............ prints local-similarity distortion
- -d <file.pgm> .......... dump the compressed output (PGM file)
- -alpha_method <int> .... transparency-compression method (0..1), default=1
- -alpha_filter <string> . predictive filtering for alpha plane,
- one of: none, fast (default) or best
- -exact ................. preserve RGB values in transparent area, default=off
- -blend_alpha <hex> ..... blend colors against background color
- expressed as RGB values written in
- hexadecimal, e.g. 0xc0e0d0 for red=0xc0
- green=0xe0 and blue=0xd0
- -noalpha ............... discard any transparency information
- -lossless .............. encode image losslessly, default=off
- -near_lossless <int> ... use near-lossless image
- preprocessing (0..100=off), default=100
- -hint <string> ......... specify image characteristics hint,
- one of: photo, picture or graph
-
- -metadata <string> ..... comma separated list of metadata to
- copy from the input to the output if present.
- Valid values: all, none (default), exif, icc, xmp
-
- -short ................. condense printed message
- -quiet ................. don't print anything
- -version ............... print version number and exit
- -noasm ................. disable all assembly optimizations
- -v ..................... verbose, e.g. print encoding/decoding times
- -progress .............. report encoding progress
-
-Experimental Options:
- -jpeg_like ............. roughly match expected JPEG size
- -af .................... auto-adjust filter strength
- -pre <int> ............. pre-processing filter
-
-
-The main options you might want to try in order to further tune the
-visual quality are:
- -preset
- -sns
- -f
- -m
-
-Namely:
- * 'preset' will set up a default encoding configuration targeting a
- particular type of input. It should appear first in the list of options,
- so that subsequent options can take effect on top of this preset.
- Default value is 'default'.
- * 'sns' will progressively turn on (when going from 0 to 100) some additional
- visual optimizations (like: segmentation map re-enforcement). This option
- will balance the bit allocation differently. It tries to take bits from the
- "easy" parts of the picture and use them in the "difficult" ones instead.
- Usually, raising the sns value (at fixed -q value) leads to larger files,
- but with better quality.
- Typical value is around '75'.
- * 'f' option directly links to the filtering strength used by the codec's
- in-loop processing. The higher the value, the smoother the
- highly-compressed area will look. This is particularly useful when aiming
- at very small files. Typical values are around 20-30. Note that using the
- option -strong/-nostrong will change the type of filtering. Use "-f 0" to
- turn filtering off.
- * 'm' controls the trade-off between encoding speed and quality. Default is 4.
- You can try -m 5 or -m 6 to explore more (time-consuming) encoding
- possibilities. A lower value will result in faster encoding at the expense
- of quality.
-
-Decoding tool:
-==============
-
-There is a decoding sample in examples/dwebp.c which will take
-a .webp file and decode it to a PNG image file (amongst other formats).
-This is simply to demonstrate the use of the API. You can verify the
-file test.webp decodes to exactly the same as test_ref.ppm by using:
-
- cd examples
- ./dwebp test.webp -ppm -o test.ppm
- diff test.ppm test_ref.ppm
-
-The full list of options is available using -h:
-
-> dwebp -h
-Usage: dwebp in_file [options] [-o out_file]
-
-Decodes the WebP image file to PNG format [Default].
-Note: Animated WebP files are not supported.
-
-Use following options to convert into alternate image formats:
- -pam ......... save the raw RGBA samples as a color PAM
- -ppm ......... save the raw RGB samples as a color PPM
- -bmp ......... save as uncompressed BMP format
- -tiff ........ save as uncompressed TIFF format
- -pgm ......... save the raw YUV samples as a grayscale PGM
- file with IMC4 layout
- -yuv ......... save the raw YUV samples in flat layout
-
- Other options are:
- -version ..... print version number and exit
- -nofancy ..... don't use the fancy YUV420 upscaler
- -nofilter .... disable in-loop filtering
- -nodither .... disable dithering
- -dither <d> .. dithering strength (in 0..100)
- -alpha_dither use alpha-plane dithering if needed
- -mt .......... use multi-threading
- -crop <x> <y> <w> <h> ... crop output with the given rectangle
- -resize <w> <h> ......... scale the output (*after* any cropping)
- -flip ........ flip the output vertically
- -alpha ....... only save the alpha plane
- -incremental . use incremental decoding (useful for tests)
- -h ........... this help message
- -v ........... verbose (e.g. print encoding/decoding times)
- -quiet ....... quiet mode, don't print anything
- -noasm ....... disable all assembly optimizations
-
-WebP file analysis tool:
-========================
-
-'webpinfo' can be used to print out the chunk level structure and bitstream
-header information of WebP files. It can also check if the files are of valid
-WebP format.
-
-Usage: webpinfo [options] in_files
-Note: there could be multiple input files;
- options must come before input files.
-Options:
- -version ........... Print version number and exit.
- -quiet ............. Do not show chunk parsing information.
- -diag .............. Show parsing error diagnosis.
- -summary ........... Show chunk stats summary.
- -bitstream_info .... Parse bitstream header.
-
-Visualization tool:
-===================
-
-There's a little self-serve visualization tool called 'vwebp' under the
-examples/ directory. It uses OpenGL to open a simple drawing window and show
-a decoded WebP file. It's not yet integrated in the automake build system, but
-you can try to manually compile it using the recommendations below.
-
-Usage: vwebp in_file [options]
-
-Decodes the WebP image file and visualize it using OpenGL
-Options are:
- -version ..... print version number and exit
- -noicc ....... don't use the icc profile if present
- -nofancy ..... don't use the fancy YUV420 upscaler
- -nofilter .... disable in-loop filtering
- -dither <int> dithering strength (0..100), default=50
- -noalphadither disable alpha plane dithering
- -usebgcolor .. display background color
- -mt .......... use multi-threading
- -info ........ print info
- -h ........... this help message
-
-Keyboard shortcuts:
- 'c' ................ toggle use of color profile
- 'b' ................ toggle background color display
- 'i' ................ overlay file information
- 'd' ................ disable blending & disposal (debug)
- 'q' / 'Q' / ESC .... quit
-
-Building:
----------
-
-Prerequisites:
-1) OpenGL & OpenGL Utility Toolkit (GLUT)
- Linux:
- $ sudo apt-get install freeglut3-dev mesa-common-dev
- Mac + Xcode:
- - These libraries should be available in the OpenGL / GLUT frameworks.
- Windows:
- http://freeglut.sourceforge.net/index.php#download
-
-2) (Optional) qcms (Quick Color Management System)
- i. Download qcms from Mozilla / Chromium:
- https://hg.mozilla.org/mozilla-central/file/0e7639e3bdfb/gfx/qcms
- https://source.chromium.org/chromium/chromium/src/+/main:third_party/qcms/;drc=d4a2f8e1ed461d8fc05ed88d1ae2dc94c9773825
- ii. Build and archive the source files as libqcms.a / qcms.lib
- iii. Update makefile.unix / Makefile.vc
- a) Define WEBP_HAVE_QCMS
- b) Update include / library paths to reference the qcms directory.
-
-Build using makefile.unix / Makefile.vc:
-$ make -f makefile.unix examples/vwebp
-> nmake /f Makefile.vc CFG=release-static \
- ../obj/x64/release-static/bin/vwebp.exe
-
-Animation creation tool:
-========================
-The utility 'img2webp' can turn a sequence of input images (PNG, JPEG, ...)
-into an animated WebP file. It offers fine control over duration, encoding
-modes, etc.
-
-Usage:
-
- img2webp [file_options] [[frame_options] frame_file]...
-
-File-level options (only used at the start of compression):
- -min_size ............ minimize size
- -loop <int> .......... loop count (default: 0, = infinite loop)
- -kmax <int> .......... maximum number of frame between key-frames
- (0=only keyframes)
- -kmin <int> .......... minimum number of frame between key-frames
- (0=disable key-frames altogether)
- -mixed ............... use mixed lossy/lossless automatic mode
- -v ................... verbose mode
- -h ................... this help
- -version ............. print version number and exit
-
-Per-frame options (only used for subsequent images input):
- -d <int> ............. frame duration in ms (default: 100)
- -lossless ........... use lossless mode (default)
- -lossy ... ........... use lossy mode
- -q <float> ........... quality
- -m <int> ............. method to use
-
-example: img2webp -loop 2 in0.png -lossy in1.jpg
- -d 80 in2.tiff -o out.webp
-
-Note: if a single file name is passed as the argument, the arguments will be
-tokenized from this file. The file name must not start with the character '-'.
-
-Animated GIF conversion:
-========================
-Animated GIF files can be converted to WebP files with animation using the
-gif2webp utility available under examples/. The files can then be viewed using
-vwebp.
-
-Usage:
- gif2webp [options] gif_file -o webp_file
-Options:
- -h / -help ............. this help
- -lossy ................. encode image using lossy compression
- -mixed ................. for each frame in the image, pick lossy
- or lossless compression heuristically
- -q <float> ............. quality factor (0:small..100:big)
- -m <int> ............... compression method (0=fast, 6=slowest)
- -min_size .............. minimize output size (default:off)
- lossless compression by default; can be
- combined with -q, -m, -lossy or -mixed
- options
- -kmin <int> ............ min distance between key frames
- -kmax <int> ............ max distance between key frames
- -f <int> ............... filter strength (0=off..100)
- -metadata <string> ..... comma separated list of metadata to
- copy from the input to the output if present
- Valid values: all, none, icc, xmp (default)
- -loop_compatibility .... use compatibility mode for Chrome
- version prior to M62 (inclusive)
- -mt .................... use multi-threading if available
-
- -version ............... print version number and exit
- -v ..................... verbose
- -quiet ................. don't print anything
-
-Building:
----------
-With the libgif development files installed, gif2webp can be built using
-makefile.unix:
-$ make -f makefile.unix examples/gif2webp
-
-or using autoconf:
-$ ./configure --enable-everything
-$ make
-
-Comparison of animated images:
-==============================
-Test utility anim_diff under examples/ can be used to compare two animated
-images (each can be GIF or WebP).
-
-Usage: anim_diff <image1> <image2> [options]
-
-Options:
- -dump_frames <folder> dump decoded frames in PAM format
- -min_psnr <float> ... minimum per-frame PSNR
- -raw_comparison ..... if this flag is not used, RGB is
- premultiplied before comparison
- -max_diff <int> ..... maximum allowed difference per channel
- between corresponding pixels in subsequent
- frames
- -h .................. this help
- -version ............ print version number and exit
-
-Building:
----------
-With the libgif development files and a C++ compiler installed, anim_diff can
-be built using makefile.unix:
-$ make -f makefile.unix examples/anim_diff
-
-or using autoconf:
-$ ./configure --enable-everything
-$ make
-
-Encoding API:
-=============
-
-The main encoding functions are available in the header src/webp/encode.h
-The ready-to-use ones are:
-size_t WebPEncodeRGB(const uint8_t* rgb, int width, int height, int stride,
- float quality_factor, uint8_t** output);
-size_t WebPEncodeBGR(const uint8_t* bgr, int width, int height, int stride,
- float quality_factor, uint8_t** output);
-size_t WebPEncodeRGBA(const uint8_t* rgba, int width, int height, int stride,
- float quality_factor, uint8_t** output);
-size_t WebPEncodeBGRA(const uint8_t* bgra, int width, int height, int stride,
- float quality_factor, uint8_t** output);
-
-They will convert raw RGB samples to a WebP data. The only control supplied
-is the quality factor.
-
-There are some variants for using the lossless format:
-
-size_t WebPEncodeLosslessRGB(const uint8_t* rgb, int width, int height,
- int stride, uint8_t** output);
-size_t WebPEncodeLosslessBGR(const uint8_t* bgr, int width, int height,
- int stride, uint8_t** output);
-size_t WebPEncodeLosslessRGBA(const uint8_t* rgba, int width, int height,
- int stride, uint8_t** output);
-size_t WebPEncodeLosslessBGRA(const uint8_t* bgra, int width, int height,
- int stride, uint8_t** output);
-
-Of course in this case, no quality factor is needed since the compression
-occurs without loss of the input values, at the expense of larger output sizes.
-
-Advanced encoding API:
-----------------------
-
-A more advanced API is based on the WebPConfig and WebPPicture structures.
-
-WebPConfig contains the encoding settings and is not tied to a particular
-picture.
-WebPPicture contains input data, on which some WebPConfig will be used for
-compression.
-The encoding flow looks like:
-
--------------------------------------- BEGIN PSEUDO EXAMPLE
-
-#include <webp/encode.h>
-
- // Setup a config, starting form a preset and tuning some additional
- // parameters
- WebPConfig config;
- if (!WebPConfigPreset(&config, WEBP_PRESET_PHOTO, quality_factor)) {
- return 0; // version error
- }
- // ... additional tuning
- config.sns_strength = 90;
- config.filter_sharpness = 6;
- config_error = WebPValidateConfig(&config); // not mandatory, but useful
-
- // Setup the input data
- WebPPicture pic;
- if (!WebPPictureInit(&pic)) {
- return 0; // version error
- }
- pic.width = width;
- pic.height = height;
- // allocated picture of dimension width x height
- if (!WebPPictureAlloc(&pic)) {
- return 0; // memory error
- }
- // at this point, 'pic' has been initialized as a container,
- // and can receive the Y/U/V samples.
- // Alternatively, one could use ready-made import functions like
- // WebPPictureImportRGB(), which will take care of memory allocation.
- // In any case, past this point, one will have to call
- // WebPPictureFree(&pic) to reclaim memory.
-
- // Set up a byte-output write method. WebPMemoryWriter, for instance.
- WebPMemoryWriter wrt;
- WebPMemoryWriterInit(&wrt); // initialize 'wrt'
-
- pic.writer = MyFileWriter;
- pic.custom_ptr = my_opaque_structure_to_make_MyFileWriter_work;
-
- // Compress!
- int ok = WebPEncode(&config, &pic); // ok = 0 => error occurred!
- WebPPictureFree(&pic); // must be called independently of the 'ok' result.
-
- // output data should have been handled by the writer at that point.
- // -> compressed data is the memory buffer described by wrt.mem / wrt.size
-
- // deallocate the memory used by compressed data
- WebPMemoryWriterClear(&wrt);
-
--------------------------------------- END PSEUDO EXAMPLE
-
-Decoding API:
-=============
-
-This is mainly just one function to call:
-
-#include "webp/decode.h"
-uint8_t* WebPDecodeRGB(const uint8_t* data, size_t data_size,
- int* width, int* height);
-
-Please have a look at the file src/webp/decode.h for the details.
-There are variants for decoding in BGR/RGBA/ARGB/BGRA order, along with
-decoding to raw Y'CbCr samples. One can also decode the image directly into a
-pre-allocated buffer.
-
-To detect a WebP file and gather the picture's dimensions, the function:
- int WebPGetInfo(const uint8_t* data, size_t data_size,
- int* width, int* height);
-is supplied. No decoding is involved when using it.
-
-Incremental decoding API:
-=========================
-
-In the case when data is being progressively transmitted, pictures can still
-be incrementally decoded using a slightly more complicated API. Decoder state
-is stored into an instance of the WebPIDecoder object. This object can be
-created with the purpose of decoding either RGB or Y'CbCr samples.
-For instance:
-
- WebPDecBuffer buffer;
- WebPInitDecBuffer(&buffer);
- buffer.colorspace = MODE_BGR;
- ...
- WebPIDecoder* idec = WebPINewDecoder(&buffer);
-
-As data is made progressively available, this incremental-decoder object
-can be used to decode the picture further. There are two (mutually exclusive)
-ways to pass freshly arrived data:
-
-either by appending the fresh bytes:
-
- WebPIAppend(idec, fresh_data, size_of_fresh_data);
-
-or by just mentioning the new size of the transmitted data:
-
- WebPIUpdate(idec, buffer, size_of_transmitted_buffer);
-
-Note that 'buffer' can be modified between each call to WebPIUpdate, in
-particular when the buffer is resized to accommodate larger data.
-
-These functions will return the decoding status: either VP8_STATUS_SUSPENDED if
-decoding is not finished yet or VP8_STATUS_OK when decoding is done. Any other
-status is an error condition.
-
-The 'idec' object must always be released (even upon an error condition) by
-calling: WebPDelete(idec).
-
-To retrieve partially decoded picture samples, one must use the corresponding
-method: WebPIDecGetRGB or WebPIDecGetYUVA.
-It will return the last displayable pixel row.
-
-Lastly, note that decoding can also be performed into a pre-allocated pixel
-buffer. This buffer must be passed when creating a WebPIDecoder, calling
-WebPINewRGB() or WebPINewYUVA().
-
-Please have a look at the src/webp/decode.h header for further details.
-
-Advanced Decoding API:
-======================
-
-WebP decoding supports an advanced API which provides on-the-fly cropping and
-rescaling, something of great usefulness on memory-constrained environments like
-mobile phones. Basically, the memory usage will scale with the output's size,
-not the input's, when one only needs a quick preview or a zoomed in portion of
-an otherwise too-large picture. Some CPU can be saved too, incidentally.
-
--------------------------------------- BEGIN PSEUDO EXAMPLE
- // A) Init a configuration object
- WebPDecoderConfig config;
- CHECK(WebPInitDecoderConfig(&config));
-
- // B) optional: retrieve the bitstream's features.
- CHECK(WebPGetFeatures(data, data_size, &config.input) == VP8_STATUS_OK);
-
- // C) Adjust 'config' options, if needed
- config.options.no_fancy_upsampling = 1;
- config.options.use_scaling = 1;
- config.options.scaled_width = scaledWidth();
- config.options.scaled_height = scaledHeight();
- // etc.
-
- // D) Specify 'config' output options for specifying output colorspace.
- // Optionally the external image decode buffer can also be specified.
- config.output.colorspace = MODE_BGRA;
- // Optionally, the config.output can be pointed to an external buffer as
- // well for decoding the image. This externally supplied memory buffer
- // should be big enough to store the decoded picture.
- config.output.u.RGBA.rgba = (uint8_t*) memory_buffer;
- config.output.u.RGBA.stride = scanline_stride;
- config.output.u.RGBA.size = total_size_of_the_memory_buffer;
- config.output.is_external_memory = 1;
-
- // E) Decode the WebP image. There are two variants w.r.t decoding image.
- // The first one (E.1) decodes the full image and the second one (E.2) is
- // used to incrementally decode the image using small input buffers.
- // Any one of these steps can be used to decode the WebP image.
-
- // E.1) Decode full image.
- CHECK(WebPDecode(data, data_size, &config) == VP8_STATUS_OK);
-
- // E.2) Decode image incrementally.
- WebPIDecoder* const idec = WebPIDecode(NULL, NULL, &config);
- CHECK(idec != NULL);
- while (bytes_remaining > 0) {
- VP8StatusCode status = WebPIAppend(idec, input, bytes_read);
- if (status == VP8_STATUS_OK || status == VP8_STATUS_SUSPENDED) {
- bytes_remaining -= bytes_read;
- } else {
- break;
- }
- }
- WebPIDelete(idec);
-
- // F) Decoded image is now in config.output (and config.output.u.RGBA).
- // It can be saved, displayed or otherwise processed.
-
- // G) Reclaim memory allocated in config's object. It's safe to call
- // this function even if the memory is external and wasn't allocated
- // by WebPDecode().
- WebPFreeDecBuffer(&config.output);
-
--------------------------------------- END PSEUDO EXAMPLE
-
-Bugs:
-=====
-
-Please report all bugs to the issue tracker:
- https://bugs.chromium.org/p/webp
-Patches welcome! See this page to get started:
- https://www.webmproject.org/code/contribute/submitting-patches/
-
-Discuss:
-========
-
-Email: webp-discuss@webmproject.org
-Web: https://groups.google.com/a/webmproject.org/group/webp-discuss
diff --git a/contrib/libs/libwebp/README.mux b/contrib/libs/libwebp/README.mux
deleted file mode 100644
index 6dbabe1ca3..0000000000
--- a/contrib/libs/libwebp/README.mux
+++ /dev/null
@@ -1,258 +0,0 @@
- __ __ ____ ____ ____ __ __ _ __ __
- / \\/ \/ _ \/ _ \/ _ \/ \ \/ \___/_ / _\
- \ / __/ _ \ __/ / / (_/ /__
- \__\__/\_____/_____/__/ \__//_/\_____/__/___/v1.2.2
-
-
-Description:
-============
-
-WebPMux: set of two libraries 'Mux' and 'Demux' for creation, extraction and
-manipulation of an extended format WebP file, which can have features like
-color profile, metadata and animation. Reference command-line tools 'webpmux'
-and 'vwebp' as well as the WebP container specification
-'doc/webp-container-spec.txt' are also provided in this package.
-
-WebP Mux tool:
-==============
-
-The examples/ directory contains a tool (webpmux) for manipulating WebP
-files. The webpmux tool can be used to create an extended format WebP file and
-also to extract or strip relevant data from such a file.
-
-A list of options is available using the -help command line flag:
-
-> webpmux -help
-Usage: webpmux -get GET_OPTIONS INPUT -o OUTPUT
- webpmux -set SET_OPTIONS INPUT -o OUTPUT
- webpmux -duration DURATION_OPTIONS [-duration ...]
- INPUT -o OUTPUT
- webpmux -strip STRIP_OPTIONS INPUT -o OUTPUT
- webpmux -frame FRAME_OPTIONS [-frame...] [-loop LOOP_COUNT]
- [-bgcolor BACKGROUND_COLOR] -o OUTPUT
- webpmux -info INPUT
- webpmux [-h|-help]
- webpmux -version
- webpmux argument_file_name
-
-GET_OPTIONS:
- Extract relevant data:
- icc get ICC profile
- exif get EXIF metadata
- xmp get XMP metadata
- frame n get nth frame
-
-SET_OPTIONS:
- Set color profile/metadata/parameters:
- loop LOOP_COUNT set the loop count
- bgcolor BACKGROUND_COLOR set the animation background color
- icc file.icc set ICC profile
- exif file.exif set EXIF metadata
- xmp file.xmp set XMP metadata
- where: 'file.icc' contains the ICC profile to be set,
- 'file.exif' contains the EXIF metadata to be set
- 'file.xmp' contains the XMP metadata to be set
-
-DURATION_OPTIONS:
- Set duration of selected frames:
- duration set duration for each frames
- duration,frame set duration of a particular frame
- duration,start,end set duration of frames in the
- interval [start,end])
- where: 'duration' is the duration in milliseconds
- 'start' is the start frame index
- 'end' is the inclusive end frame index
- The special 'end' value '0' means: last frame.
-
-STRIP_OPTIONS:
- Strip color profile/metadata:
- icc strip ICC profile
- exif strip EXIF metadata
- xmp strip XMP metadata
-
-FRAME_OPTIONS(i):
- Create animation:
- file_i +di+[xi+yi[+mi[bi]]]
- where: 'file_i' is the i'th animation frame (WebP format),
- 'di' is the pause duration before next frame,
- 'xi','yi' specify the image offset for this frame,
- 'mi' is the dispose method for this frame (0 or 1),
- 'bi' is the blending method for this frame (+b or -b)
-
-LOOP_COUNT:
- Number of times to repeat the animation.
- Valid range is 0 to 65535 [Default: 0 (infinite)].
-
-BACKGROUND_COLOR:
- Background color of the canvas.
- A,R,G,B
- where: 'A', 'R', 'G' and 'B' are integers in the range 0 to 255 specifying
- the Alpha, Red, Green and Blue component values respectively
- [Default: 255,255,255,255]
-
-INPUT & OUTPUT are in WebP format.
-
-Note: The nature of EXIF, XMP and ICC data is not checked and is assumed to be
-valid.
-
-Note: if a single file name is passed as the argument, the arguments will be
-tokenized from this file. The file name must not start with the character '-'.
-
-Visualization tool:
-===================
-
-The examples/ directory also contains a tool (vwebp) for viewing WebP files.
-It decodes the image and visualizes it using OpenGL. See the libwebp README
-for details on building and running this program.
-
-Mux API:
-========
-The Mux API contains methods for adding data to and reading data from WebP
-files. This API currently supports XMP/EXIF metadata, ICC profile and animation.
-Other features may be added in subsequent releases.
-
-Example#1 (pseudo code): Creating a WebPMux object with image data, color
-profile and XMP metadata.
-
- int copy_data = 0;
- WebPMux* mux = WebPMuxNew();
- // ... (Prepare image data).
- WebPMuxSetImage(mux, &image, copy_data);
- // ... (Prepare ICC profile data).
- WebPMuxSetChunk(mux, "ICCP", &icc_profile, copy_data);
- // ... (Prepare XMP metadata).
- WebPMuxSetChunk(mux, "XMP ", &xmp, copy_data);
- // Get data from mux in WebP RIFF format.
- WebPMuxAssemble(mux, &output_data);
- WebPMuxDelete(mux);
- // ... (Consume output_data; e.g. write output_data.bytes to file).
- WebPDataClear(&output_data);
-
-
-Example#2 (pseudo code): Get image and color profile data from a WebP file.
-
- int copy_data = 0;
- // ... (Read data from file).
- WebPMux* mux = WebPMuxCreate(&data, copy_data);
- WebPMuxGetFrame(mux, 1, &image);
- // ... (Consume image; e.g. call WebPDecode() to decode the data).
- WebPMuxGetChunk(mux, "ICCP", &icc_profile);
- // ... (Consume icc_profile).
- WebPMuxDelete(mux);
- free(data);
-
-
-For a detailed Mux API reference, please refer to the header file
-(src/webp/mux.h).
-
-Demux API:
-==========
-The Demux API enables extraction of images and extended format data from
-WebP files. This API currently supports reading of XMP/EXIF metadata, ICC
-profile and animated images. Other features may be added in subsequent
-releases.
-
-Code example: Demuxing WebP data to extract all the frames, ICC profile
-and EXIF/XMP metadata.
-
- WebPDemuxer* demux = WebPDemux(&webp_data);
- uint32_t width = WebPDemuxGetI(demux, WEBP_FF_CANVAS_WIDTH);
- uint32_t height = WebPDemuxGetI(demux, WEBP_FF_CANVAS_HEIGHT);
- // ... (Get information about the features present in the WebP file).
- uint32_t flags = WebPDemuxGetI(demux, WEBP_FF_FORMAT_FLAGS);
-
- // ... (Iterate over all frames).
- WebPIterator iter;
- if (WebPDemuxGetFrame(demux, 1, &iter)) {
- do {
- // ... (Consume 'iter'; e.g. Decode 'iter.fragment' with WebPDecode(),
- // ... and get other frame properties like width, height, offsets etc.
- // ... see 'struct WebPIterator' below for more info).
- } while (WebPDemuxNextFrame(&iter));
- WebPDemuxReleaseIterator(&iter);
- }
-
- // ... (Extract metadata).
- WebPChunkIterator chunk_iter;
- if (flags & ICCP_FLAG) WebPDemuxGetChunk(demux, "ICCP", 1, &chunk_iter);
- // ... (Consume the ICC profile in 'chunk_iter.chunk').
- WebPDemuxReleaseChunkIterator(&chunk_iter);
- if (flags & EXIF_FLAG) WebPDemuxGetChunk(demux, "EXIF", 1, &chunk_iter);
- // ... (Consume the EXIF metadata in 'chunk_iter.chunk').
- WebPDemuxReleaseChunkIterator(&chunk_iter);
- if (flags & XMP_FLAG) WebPDemuxGetChunk(demux, "XMP ", 1, &chunk_iter);
- // ... (Consume the XMP metadata in 'chunk_iter.chunk').
- WebPDemuxReleaseChunkIterator(&chunk_iter);
- WebPDemuxDelete(demux);
-
-
-For a detailed Demux API reference, please refer to the header file
-(src/webp/demux.h).
-
-AnimEncoder API:
-================
-The AnimEncoder API can be used to create animated WebP images.
-
-Code example:
-
- WebPAnimEncoderOptions enc_options;
- WebPAnimEncoderOptionsInit(&enc_options);
- // ... (Tune 'enc_options' as needed).
- WebPAnimEncoder* enc = WebPAnimEncoderNew(width, height, &enc_options);
- while(<there are more frames>) {
- WebPConfig config;
- WebPConfigInit(&config);
- // ... (Tune 'config' as needed).
- WebPAnimEncoderAdd(enc, frame, duration, &config);
- }
- WebPAnimEncoderAssemble(enc, webp_data);
- WebPAnimEncoderDelete(enc);
- // ... (Write the 'webp_data' to a file, or re-mux it further).
-
-
-For a detailed AnimEncoder API reference, please refer to the header file
-(src/webp/mux.h).
-
-AnimDecoder API:
-================
-This AnimDecoder API allows decoding (possibly) animated WebP images.
-
-Code Example:
-
- WebPAnimDecoderOptions dec_options;
- WebPAnimDecoderOptionsInit(&dec_options);
- // Tune 'dec_options' as needed.
- WebPAnimDecoder* dec = WebPAnimDecoderNew(webp_data, &dec_options);
- WebPAnimInfo anim_info;
- WebPAnimDecoderGetInfo(dec, &anim_info);
- for (uint32_t i = 0; i < anim_info.loop_count; ++i) {
- while (WebPAnimDecoderHasMoreFrames(dec)) {
- uint8_t* buf;
- int timestamp;
- WebPAnimDecoderGetNext(dec, &buf, &timestamp);
- // ... (Render 'buf' based on 'timestamp').
- // ... (Do NOT free 'buf', as it is owned by 'dec').
- }
- WebPAnimDecoderReset(dec);
- }
- const WebPDemuxer* demuxer = WebPAnimDecoderGetDemuxer(dec);
- // ... (Do something using 'demuxer'; e.g. get EXIF/XMP/ICC data).
- WebPAnimDecoderDelete(dec);
-
-For a detailed AnimDecoder API reference, please refer to the header file
-(src/webp/demux.h).
-
-
-Bugs:
-=====
-
-Please report all bugs to the issue tracker:
- https://bugs.chromium.org/p/webp
-Patches welcome! See this page to get started:
- https://www.webmproject.org/code/contribute/submitting-patches/
-
-Discuss:
-========
-
-Email: webp-discuss@webmproject.org
-Web: https://groups.google.com/a/webmproject.org/group/webp-discuss
diff --git a/contrib/libs/libwebp/README.webp_js b/contrib/libs/libwebp/README.webp_js
deleted file mode 100644
index 3d453a2004..0000000000
--- a/contrib/libs/libwebp/README.webp_js
+++ /dev/null
@@ -1,75 +0,0 @@
- __ __ ____ ____ ____ __ ____
- / \\/ \ _ \ _ \ _ \ (__)/ __\
- \ / __/ _ \ __/ _) \_ \
- \__\__/_____/____/_/ /____/____/
-
-Description:
-============
-
-This file describes the compilation of libwebp into a JavaScript decoder
-using Emscripten and CMake.
-
- - install the Emscripten SDK following the procedure described at:
- https://emscripten.org/docs/getting_started/downloads.html#installation-instructions-using-the-emsdk-recommended
- After installation, you should have some global variable positioned to the
- location of the SDK. In particular, $EMSDK should point to the
- top-level directory containing Emscripten tools.
-
- - configure the project 'WEBP_JS' with CMake using:
-
- cd webp_js && \
- emcmake cmake -DWEBP_BUILD_WEBP_JS=ON \
- ../
-
- - compile webp.js using 'emmake make'.
-
- - that's it! Upon completion, you should have the webp.js and
- webp.wasm files generated.
-
-The callable JavaScript function is WebPToSDL(), which decodes a raw WebP
-bitstream into a canvas. See webp_js/index.html for a simple usage sample
-(see below for instructions).
-
-Demo HTML page:
-===============
-
- The HTML page webp_js/index.html requires an HTTP server to serve the WebP
- image example. It's easy to just use Python for that.
-
-cd webp_js && python -m SimpleHTTPServer 8080
-
-and then navigate to http://localhost:8080 in your favorite browser.
-
-
-Web-Assembly (WASM) version:
-============================
-
- CMakeLists.txt is configured to build the WASM version when using
- the option WEBP_BUILD_WEBP_JS=ON. The compilation step will assemble
- the files 'webp_wasm.js', 'webp_wasm.wasm' in the webp_js/ directory.
- See webp_js/index_wasm.html for a simple demo page using the WASM version
- of the library.
-
- You will need a fairly recent version of Emscripten (at least 2.0.18,
- latest-upstream is recommended) and of your WASM-enabled browser to run this
- version.
-
-Caveat:
-=======
-
- - First decoding using the library is usually slower, due to just-in-time
- compilation.
-
- - Some versions of llvm produce the following compile error when SSE2 is
- enabled.
-
-"Unsupported: %516 = bitcast <8 x i16> %481 to i128
- LLVM ERROR: BitCast Instruction not yet supported for integer types larger than 64 bits"
-
- The corresponding Emscripten bug is at:
- https://github.com/kripken/emscripten/issues/3788
-
- Therefore, SSE2 optimization is currently disabled in CMakeLists.txt.
-
- - If WEBP_ENABLE_SIMD is set to 1 the JavaScript version (webp.js) will be
- disabled as wasm2js does not support SIMD.
diff --git a/contrib/libs/libwebp/dec/.yandex_meta/licenses.list.txt b/contrib/libs/libwebp/dec/.yandex_meta/licenses.list.txt
deleted file mode 100644
index 9217864401..0000000000
--- a/contrib/libs/libwebp/dec/.yandex_meta/licenses.list.txt
+++ /dev/null
@@ -1,140 +0,0 @@
-====================BSD-3-Clause WITH Google-Patent-License-Webm====================
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-
-
-====================COPYRIGHT====================
-// Copyright 2010 Google Inc. All Rights Reserved.
-
-
-====================COPYRIGHT====================
-// Copyright 2011 Google Inc. All Rights Reserved.
-
-
-====================COPYRIGHT====================
-// Copyright 2012 Google Inc. All Rights Reserved.
-
-
-====================COPYRIGHT====================
-// Copyright 2013 Google Inc. All Rights Reserved.
-
-
-====================COPYRIGHT====================
-// Copyright 2015 Google Inc. All Rights Reserved.
-
-
-====================File: AUTHORS====================
-Contributors:
-- Aidan O'Loan (aidanol at gmail dot com)
-- Alan Browning (browning at google dot com)
-- Charles Munger (clm at google dot com)
-- Cheng Yi (cyi at google dot com)
-- Christian Duvivier (cduvivier at google dot com)
-- Christopher Degawa (ccom at randomderp dot com)
-- Clement Courbet (courbet at google dot com)
-- Djordje Pesut (djordje dot pesut at imgtec dot com)
-- Hui Su (huisu at google dot com)
-- Ilya Kurdyukov (jpegqs at gmail dot com)
-- Ingvar Stepanyan (rreverser at google dot com)
-- James Zern (jzern at google dot com)
-- Jan Engelhardt (jengelh at medozas dot de)
-- Jehan (jehan at girinstud dot io)
-- Johann Koenig (johann dot koenig at duck dot com)
-- Jovan Zelincevic (jovan dot zelincevic at imgtec dot com)
-- Jyrki Alakuijala (jyrki at google dot com)
-- Konstantin Ivlev (tomskside at gmail dot com)
-- Lode Vandevenne (lode at google dot com)
-- Lou Quillio (louquillio at google dot com)
-- Mans Rullgard (mans at mansr dot com)
-- Marcin Kowalczyk (qrczak at google dot com)
-- Martin Olsson (mnemo at minimum dot se)
-- Mikołaj Zalewski (mikolajz at google dot com)
-- Mislav Bradac (mislavm at google dot com)
-- Nico Weber (thakis at chromium dot org)
-- Noel Chromium (noel at chromium dot org)
-- Oliver Wolff (oliver dot wolff at qt dot io)
-- Owen Rodley (orodley at google dot com)
-- Parag Salasakar (img dot mips1 at gmail dot com)
-- Pascal Massimino (pascal dot massimino at gmail dot com)
-- Paweł Hajdan, Jr (phajdan dot jr at chromium dot org)
-- Pierre Joye (pierre dot php at gmail dot com)
-- Roberto Alanis (alanisbaez at google dot com)
-- Sam Clegg (sbc at chromium dot org)
-- Scott Hancher (seh at google dot com)
-- Scott LaVarnway (slavarnway at google dot com)
-- Scott Talbot (s at chikachow dot org)
-- Slobodan Prijic (slobodan dot prijic at imgtec dot com)
-- Somnath Banerjee (somnath dot banerjee at gmail dot com)
-- Sriraman Tallam (tmsriram at google dot com)
-- Tamar Levy (tamar dot levy at intel dot com)
-- Timothy Gu (timothygu99 at gmail dot com)
-- Urvang Joshi (urvang at google dot com)
-- Vikas Arora (vikasa at google dot com)
-- Vincent Rabaud (vrabaud at google dot com)
-- Vlad Tsyrklevich (vtsyrklevich at chromium dot org)
-- Wan-Teh Chang (wtc at google dot com)
-- Yang Zhang (yang dot zhang at arm dot com)
-- Yannis Guyon (yguyon at google dot com)
-- Zhi An Ng (zhin at chromium dot org)
-
-
-====================File: COPYING====================
-Copyright (c) 2010, Google Inc. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
-
- * Neither the name of Google nor the names of its contributors may
- be used to endorse or promote products derived from this software
- without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-
-====================File: PATENTS====================
-Additional IP Rights Grant (Patents)
-------------------------------------
-
-"These implementations" means the copyrightable works that implement the WebM
-codecs distributed by Google as part of the WebM Project.
-
-Google hereby grants to you a perpetual, worldwide, non-exclusive, no-charge,
-royalty-free, irrevocable (except as stated in this section) patent license to
-make, have made, use, offer to sell, sell, import, transfer, and otherwise
-run, modify and propagate the contents of these implementations of WebM, where
-such license applies only to those patent claims, both currently owned by
-Google and acquired in the future, licensable by Google that are necessarily
-infringed by these implementations of WebM. This grant does not include claims
-that would be infringed only as a consequence of further modification of these
-implementations. If you or your agent or exclusive licensee institute or order
-or agree to the institution of patent litigation or any other patent
-enforcement activity against any entity (including a cross-claim or
-counterclaim in a lawsuit) alleging that any of these implementations of WebM
-or any code incorporated within any of these implementations of WebM
-constitute direct or contributory patent infringement, or inducement of
-patent infringement, then any patent rights granted to you under this License
-for these implementations of WebM shall terminate as of the date such
-litigation is filed.
diff --git a/contrib/libs/libwebp/dec/alpha_dec.c b/contrib/libs/libwebp/dec/alpha_dec.c
deleted file mode 100644
index 6af0050d36..0000000000
--- a/contrib/libs/libwebp/dec/alpha_dec.c
+++ /dev/null
@@ -1,232 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Alpha-plane decompression.
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include <stdlib.h>
-#include "./alphai_dec.h"
-#include "./vp8i_dec.h"
-#include "./vp8li_dec.h"
-#include "../dsp/dsp.h"
-#include "../utils/quant_levels_dec_utils.h"
-#include "../utils/utils.h"
-#include "../webp/format_constants.h"
-
-//------------------------------------------------------------------------------
-// ALPHDecoder object.
-
-// Allocates a new alpha decoder instance.
-static ALPHDecoder* ALPHNew(void) {
- ALPHDecoder* const dec = (ALPHDecoder*)WebPSafeCalloc(1ULL, sizeof(*dec));
- return dec;
-}
-
-// Clears and deallocates an alpha decoder instance.
-static void ALPHDelete(ALPHDecoder* const dec) {
- if (dec != NULL) {
- VP8LDelete(dec->vp8l_dec_);
- dec->vp8l_dec_ = NULL;
- WebPSafeFree(dec);
- }
-}
-
-//------------------------------------------------------------------------------
-// Decoding.
-
-// Initialize alpha decoding by parsing the alpha header and decoding the image
-// header for alpha data stored using lossless compression.
-// Returns false in case of error in alpha header (data too short, invalid
-// compression method or filter, error in lossless header data etc).
-static int ALPHInit(ALPHDecoder* const dec, const uint8_t* data,
- size_t data_size, const VP8Io* const src_io,
- uint8_t* output) {
- int ok = 0;
- const uint8_t* const alpha_data = data + ALPHA_HEADER_LEN;
- const size_t alpha_data_size = data_size - ALPHA_HEADER_LEN;
- int rsrv;
- VP8Io* const io = &dec->io_;
-
- assert(data != NULL && output != NULL && src_io != NULL);
-
- VP8FiltersInit();
- dec->output_ = output;
- dec->width_ = src_io->width;
- dec->height_ = src_io->height;
- assert(dec->width_ > 0 && dec->height_ > 0);
-
- if (data_size <= ALPHA_HEADER_LEN) {
- return 0;
- }
-
- dec->method_ = (data[0] >> 0) & 0x03;
- dec->filter_ = (WEBP_FILTER_TYPE)((data[0] >> 2) & 0x03);
- dec->pre_processing_ = (data[0] >> 4) & 0x03;
- rsrv = (data[0] >> 6) & 0x03;
- if (dec->method_ < ALPHA_NO_COMPRESSION ||
- dec->method_ > ALPHA_LOSSLESS_COMPRESSION ||
- dec->filter_ >= WEBP_FILTER_LAST ||
- dec->pre_processing_ > ALPHA_PREPROCESSED_LEVELS ||
- rsrv != 0) {
- return 0;
- }
-
- // Copy the necessary parameters from src_io to io
- VP8InitIo(io);
- WebPInitCustomIo(NULL, io);
- io->opaque = dec;
- io->width = src_io->width;
- io->height = src_io->height;
-
- io->use_cropping = src_io->use_cropping;
- io->crop_left = src_io->crop_left;
- io->crop_right = src_io->crop_right;
- io->crop_top = src_io->crop_top;
- io->crop_bottom = src_io->crop_bottom;
- // No need to copy the scaling parameters.
-
- if (dec->method_ == ALPHA_NO_COMPRESSION) {
- const size_t alpha_decoded_size = dec->width_ * dec->height_;
- ok = (alpha_data_size >= alpha_decoded_size);
- } else {
- assert(dec->method_ == ALPHA_LOSSLESS_COMPRESSION);
- ok = VP8LDecodeAlphaHeader(dec, alpha_data, alpha_data_size);
- }
-
- return ok;
-}
-
-// Decodes, unfilters and dequantizes *at least* 'num_rows' rows of alpha
-// starting from row number 'row'. It assumes that rows up to (row - 1) have
-// already been decoded.
-// Returns false in case of bitstream error.
-static int ALPHDecode(VP8Decoder* const dec, int row, int num_rows) {
- ALPHDecoder* const alph_dec = dec->alph_dec_;
- const int width = alph_dec->width_;
- const int height = alph_dec->io_.crop_bottom;
- if (alph_dec->method_ == ALPHA_NO_COMPRESSION) {
- int y;
- const uint8_t* prev_line = dec->alpha_prev_line_;
- const uint8_t* deltas = dec->alpha_data_ + ALPHA_HEADER_LEN + row * width;
- uint8_t* dst = dec->alpha_plane_ + row * width;
- assert(deltas <= &dec->alpha_data_[dec->alpha_data_size_]);
- if (alph_dec->filter_ != WEBP_FILTER_NONE) {
- assert(WebPUnfilters[alph_dec->filter_] != NULL);
- for (y = 0; y < num_rows; ++y) {
- WebPUnfilters[alph_dec->filter_](prev_line, deltas, dst, width);
- prev_line = dst;
- dst += width;
- deltas += width;
- }
- } else {
- for (y = 0; y < num_rows; ++y) {
- memcpy(dst, deltas, width * sizeof(*dst));
- prev_line = dst;
- dst += width;
- deltas += width;
- }
- }
- dec->alpha_prev_line_ = prev_line;
- } else { // alph_dec->method_ == ALPHA_LOSSLESS_COMPRESSION
- assert(alph_dec->vp8l_dec_ != NULL);
- if (!VP8LDecodeAlphaImageStream(alph_dec, row + num_rows)) {
- return 0;
- }
- }
-
- if (row + num_rows >= height) {
- dec->is_alpha_decoded_ = 1;
- }
- return 1;
-}
-
-static int AllocateAlphaPlane(VP8Decoder* const dec, const VP8Io* const io) {
- const int stride = io->width;
- const int height = io->crop_bottom;
- const uint64_t alpha_size = (uint64_t)stride * height;
- assert(dec->alpha_plane_mem_ == NULL);
- dec->alpha_plane_mem_ =
- (uint8_t*)WebPSafeMalloc(alpha_size, sizeof(*dec->alpha_plane_));
- if (dec->alpha_plane_mem_ == NULL) {
- return 0;
- }
- dec->alpha_plane_ = dec->alpha_plane_mem_;
- dec->alpha_prev_line_ = NULL;
- return 1;
-}
-
-void WebPDeallocateAlphaMemory(VP8Decoder* const dec) {
- assert(dec != NULL);
- WebPSafeFree(dec->alpha_plane_mem_);
- dec->alpha_plane_mem_ = NULL;
- dec->alpha_plane_ = NULL;
- ALPHDelete(dec->alph_dec_);
- dec->alph_dec_ = NULL;
-}
-
-//------------------------------------------------------------------------------
-// Main entry point.
-
-const uint8_t* VP8DecompressAlphaRows(VP8Decoder* const dec,
- const VP8Io* const io,
- int row, int num_rows) {
- const int width = io->width;
- const int height = io->crop_bottom;
-
- assert(dec != NULL && io != NULL);
-
- if (row < 0 || num_rows <= 0 || row + num_rows > height) {
- return NULL;
- }
-
- if (!dec->is_alpha_decoded_) {
- if (dec->alph_dec_ == NULL) { // Initialize decoder.
- dec->alph_dec_ = ALPHNew();
- if (dec->alph_dec_ == NULL) return NULL;
- if (!AllocateAlphaPlane(dec, io)) goto Error;
- if (!ALPHInit(dec->alph_dec_, dec->alpha_data_, dec->alpha_data_size_,
- io, dec->alpha_plane_)) {
- goto Error;
- }
- // if we allowed use of alpha dithering, check whether it's needed at all
- if (dec->alph_dec_->pre_processing_ != ALPHA_PREPROCESSED_LEVELS) {
- dec->alpha_dithering_ = 0; // disable dithering
- } else {
- num_rows = height - row; // decode everything in one pass
- }
- }
-
- assert(dec->alph_dec_ != NULL);
- assert(row + num_rows <= height);
- if (!ALPHDecode(dec, row, num_rows)) goto Error;
-
- if (dec->is_alpha_decoded_) { // finished?
- ALPHDelete(dec->alph_dec_);
- dec->alph_dec_ = NULL;
- if (dec->alpha_dithering_ > 0) {
- uint8_t* const alpha = dec->alpha_plane_ + io->crop_top * width
- + io->crop_left;
- if (!WebPDequantizeLevels(alpha,
- io->crop_right - io->crop_left,
- io->crop_bottom - io->crop_top,
- width, dec->alpha_dithering_)) {
- goto Error;
- }
- }
- }
- }
-
- // Return a pointer to the current decoded row.
- return dec->alpha_plane_ + row * width;
-
- Error:
- WebPDeallocateAlphaMemory(dec);
- return NULL;
-}
diff --git a/contrib/libs/libwebp/dec/alphai_dec.h b/contrib/libs/libwebp/dec/alphai_dec.h
deleted file mode 100644
index d55ce4ff7b..0000000000
--- a/contrib/libs/libwebp/dec/alphai_dec.h
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright 2013 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Alpha decoder: internal header.
-//
-// Author: Urvang (urvang@google.com)
-
-#ifndef WEBP_DEC_ALPHAI_DEC_H_
-#define WEBP_DEC_ALPHAI_DEC_H_
-
-#include "./webpi_dec.h"
-#include "../utils/filters_utils.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct VP8LDecoder; // Defined in dec/vp8li.h.
-
-typedef struct ALPHDecoder ALPHDecoder;
-struct ALPHDecoder {
- int width_;
- int height_;
- int method_;
- WEBP_FILTER_TYPE filter_;
- int pre_processing_;
- struct VP8LDecoder* vp8l_dec_;
- VP8Io io_;
- int use_8b_decode_; // Although alpha channel requires only 1 byte per
- // pixel, sometimes VP8LDecoder may need to allocate
- // 4 bytes per pixel internally during decode.
- uint8_t* output_;
- const uint8_t* prev_line_; // last output row (or NULL)
-};
-
-//------------------------------------------------------------------------------
-// internal functions. Not public.
-
-// Deallocate memory associated to dec->alpha_plane_ decoding
-void WebPDeallocateAlphaMemory(VP8Decoder* const dec);
-
-//------------------------------------------------------------------------------
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // WEBP_DEC_ALPHAI_DEC_H_
diff --git a/contrib/libs/libwebp/dec/buffer_dec.c b/contrib/libs/libwebp/dec/buffer_dec.c
deleted file mode 100644
index d6d720600c..0000000000
--- a/contrib/libs/libwebp/dec/buffer_dec.c
+++ /dev/null
@@ -1,310 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Everything about WebPDecBuffer
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include <stdlib.h>
-
-#include "./vp8i_dec.h"
-#include "./webpi_dec.h"
-#include "../utils/utils.h"
-
-//------------------------------------------------------------------------------
-// WebPDecBuffer
-
-// Number of bytes per pixel for the different color-spaces.
-static const uint8_t kModeBpp[MODE_LAST] = {
- 3, 4, 3, 4, 4, 2, 2,
- 4, 4, 4, 2, // pre-multiplied modes
- 1, 1 };
-
-// Check that webp_csp_mode is within the bounds of WEBP_CSP_MODE.
-// Convert to an integer to handle both the unsigned/signed enum cases
-// without the need for casting to remove type limit warnings.
-static int IsValidColorspace(int webp_csp_mode) {
- return (webp_csp_mode >= MODE_RGB && webp_csp_mode < MODE_LAST);
-}
-
-// strictly speaking, the very last (or first, if flipped) row
-// doesn't require padding.
-#define MIN_BUFFER_SIZE(WIDTH, HEIGHT, STRIDE) \
- ((uint64_t)(STRIDE) * ((HEIGHT) - 1) + (WIDTH))
-
-static VP8StatusCode CheckDecBuffer(const WebPDecBuffer* const buffer) {
- int ok = 1;
- const WEBP_CSP_MODE mode = buffer->colorspace;
- const int width = buffer->width;
- const int height = buffer->height;
- if (!IsValidColorspace(mode)) {
- ok = 0;
- } else if (!WebPIsRGBMode(mode)) { // YUV checks
- const WebPYUVABuffer* const buf = &buffer->u.YUVA;
- const int uv_width = (width + 1) / 2;
- const int uv_height = (height + 1) / 2;
- const int y_stride = abs(buf->y_stride);
- const int u_stride = abs(buf->u_stride);
- const int v_stride = abs(buf->v_stride);
- const int a_stride = abs(buf->a_stride);
- const uint64_t y_size = MIN_BUFFER_SIZE(width, height, y_stride);
- const uint64_t u_size = MIN_BUFFER_SIZE(uv_width, uv_height, u_stride);
- const uint64_t v_size = MIN_BUFFER_SIZE(uv_width, uv_height, v_stride);
- const uint64_t a_size = MIN_BUFFER_SIZE(width, height, a_stride);
- ok &= (y_size <= buf->y_size);
- ok &= (u_size <= buf->u_size);
- ok &= (v_size <= buf->v_size);
- ok &= (y_stride >= width);
- ok &= (u_stride >= uv_width);
- ok &= (v_stride >= uv_width);
- ok &= (buf->y != NULL);
- ok &= (buf->u != NULL);
- ok &= (buf->v != NULL);
- if (mode == MODE_YUVA) {
- ok &= (a_stride >= width);
- ok &= (a_size <= buf->a_size);
- ok &= (buf->a != NULL);
- }
- } else { // RGB checks
- const WebPRGBABuffer* const buf = &buffer->u.RGBA;
- const int stride = abs(buf->stride);
- const uint64_t size =
- MIN_BUFFER_SIZE(width * kModeBpp[mode], height, stride);
- ok &= (size <= buf->size);
- ok &= (stride >= width * kModeBpp[mode]);
- ok &= (buf->rgba != NULL);
- }
- return ok ? VP8_STATUS_OK : VP8_STATUS_INVALID_PARAM;
-}
-#undef MIN_BUFFER_SIZE
-
-static VP8StatusCode AllocateBuffer(WebPDecBuffer* const buffer) {
- const int w = buffer->width;
- const int h = buffer->height;
- const WEBP_CSP_MODE mode = buffer->colorspace;
-
- if (w <= 0 || h <= 0 || !IsValidColorspace(mode)) {
- return VP8_STATUS_INVALID_PARAM;
- }
-
- if (buffer->is_external_memory <= 0 && buffer->private_memory == NULL) {
- uint8_t* output;
- int uv_stride = 0, a_stride = 0;
- uint64_t uv_size = 0, a_size = 0, total_size;
- // We need memory and it hasn't been allocated yet.
- // => initialize output buffer, now that dimensions are known.
- int stride;
- uint64_t size;
-
- if ((uint64_t)w * kModeBpp[mode] >= (1ull << 31)) {
- return VP8_STATUS_INVALID_PARAM;
- }
- stride = w * kModeBpp[mode];
- size = (uint64_t)stride * h;
- if (!WebPIsRGBMode(mode)) {
- uv_stride = (w + 1) / 2;
- uv_size = (uint64_t)uv_stride * ((h + 1) / 2);
- if (mode == MODE_YUVA) {
- a_stride = w;
- a_size = (uint64_t)a_stride * h;
- }
- }
- total_size = size + 2 * uv_size + a_size;
-
- output = (uint8_t*)WebPSafeMalloc(total_size, sizeof(*output));
- if (output == NULL) {
- return VP8_STATUS_OUT_OF_MEMORY;
- }
- buffer->private_memory = output;
-
- if (!WebPIsRGBMode(mode)) { // YUVA initialization
- WebPYUVABuffer* const buf = &buffer->u.YUVA;
- buf->y = output;
- buf->y_stride = stride;
- buf->y_size = (size_t)size;
- buf->u = output + size;
- buf->u_stride = uv_stride;
- buf->u_size = (size_t)uv_size;
- buf->v = output + size + uv_size;
- buf->v_stride = uv_stride;
- buf->v_size = (size_t)uv_size;
- if (mode == MODE_YUVA) {
- buf->a = output + size + 2 * uv_size;
- }
- buf->a_size = (size_t)a_size;
- buf->a_stride = a_stride;
- } else { // RGBA initialization
- WebPRGBABuffer* const buf = &buffer->u.RGBA;
- buf->rgba = output;
- buf->stride = stride;
- buf->size = (size_t)size;
- }
- }
- return CheckDecBuffer(buffer);
-}
-
-VP8StatusCode WebPFlipBuffer(WebPDecBuffer* const buffer) {
- if (buffer == NULL) {
- return VP8_STATUS_INVALID_PARAM;
- }
- if (WebPIsRGBMode(buffer->colorspace)) {
- WebPRGBABuffer* const buf = &buffer->u.RGBA;
- buf->rgba += (int64_t)(buffer->height - 1) * buf->stride;
- buf->stride = -buf->stride;
- } else {
- WebPYUVABuffer* const buf = &buffer->u.YUVA;
- const int64_t H = buffer->height;
- buf->y += (H - 1) * buf->y_stride;
- buf->y_stride = -buf->y_stride;
- buf->u += ((H - 1) >> 1) * buf->u_stride;
- buf->u_stride = -buf->u_stride;
- buf->v += ((H - 1) >> 1) * buf->v_stride;
- buf->v_stride = -buf->v_stride;
- if (buf->a != NULL) {
- buf->a += (H - 1) * buf->a_stride;
- buf->a_stride = -buf->a_stride;
- }
- }
- return VP8_STATUS_OK;
-}
-
-VP8StatusCode WebPAllocateDecBuffer(int width, int height,
- const WebPDecoderOptions* const options,
- WebPDecBuffer* const buffer) {
- VP8StatusCode status;
- if (buffer == NULL || width <= 0 || height <= 0) {
- return VP8_STATUS_INVALID_PARAM;
- }
- if (options != NULL) { // First, apply options if there is any.
- if (options->use_cropping) {
- const int cw = options->crop_width;
- const int ch = options->crop_height;
- const int x = options->crop_left & ~1;
- const int y = options->crop_top & ~1;
- if (!WebPCheckCropDimensions(width, height, x, y, cw, ch)) {
- return VP8_STATUS_INVALID_PARAM; // out of frame boundary.
- }
- width = cw;
- height = ch;
- }
-
- if (options->use_scaling) {
-#if !defined(WEBP_REDUCE_SIZE)
- int scaled_width = options->scaled_width;
- int scaled_height = options->scaled_height;
- if (!WebPRescalerGetScaledDimensions(
- width, height, &scaled_width, &scaled_height)) {
- return VP8_STATUS_INVALID_PARAM;
- }
- width = scaled_width;
- height = scaled_height;
-#else
- return VP8_STATUS_INVALID_PARAM; // rescaling not supported
-#endif
- }
- }
- buffer->width = width;
- buffer->height = height;
-
- // Then, allocate buffer for real.
- status = AllocateBuffer(buffer);
- if (status != VP8_STATUS_OK) return status;
-
- // Use the stride trick if vertical flip is needed.
- if (options != NULL && options->flip) {
- status = WebPFlipBuffer(buffer);
- }
- return status;
-}
-
-//------------------------------------------------------------------------------
-// constructors / destructors
-
-int WebPInitDecBufferInternal(WebPDecBuffer* buffer, int version) {
- if (WEBP_ABI_IS_INCOMPATIBLE(version, WEBP_DECODER_ABI_VERSION)) {
- return 0; // version mismatch
- }
- if (buffer == NULL) return 0;
- memset(buffer, 0, sizeof(*buffer));
- return 1;
-}
-
-void WebPFreeDecBuffer(WebPDecBuffer* buffer) {
- if (buffer != NULL) {
- if (buffer->is_external_memory <= 0) {
- WebPSafeFree(buffer->private_memory);
- }
- buffer->private_memory = NULL;
- }
-}
-
-void WebPCopyDecBuffer(const WebPDecBuffer* const src,
- WebPDecBuffer* const dst) {
- if (src != NULL && dst != NULL) {
- *dst = *src;
- if (src->private_memory != NULL) {
- dst->is_external_memory = 1; // dst buffer doesn't own the memory.
- dst->private_memory = NULL;
- }
- }
-}
-
-// Copy and transfer ownership from src to dst (beware of parameter order!)
-void WebPGrabDecBuffer(WebPDecBuffer* const src, WebPDecBuffer* const dst) {
- if (src != NULL && dst != NULL) {
- *dst = *src;
- if (src->private_memory != NULL) {
- src->is_external_memory = 1; // src relinquishes ownership
- src->private_memory = NULL;
- }
- }
-}
-
-VP8StatusCode WebPCopyDecBufferPixels(const WebPDecBuffer* const src_buf,
- WebPDecBuffer* const dst_buf) {
- assert(src_buf != NULL && dst_buf != NULL);
- assert(src_buf->colorspace == dst_buf->colorspace);
-
- dst_buf->width = src_buf->width;
- dst_buf->height = src_buf->height;
- if (CheckDecBuffer(dst_buf) != VP8_STATUS_OK) {
- return VP8_STATUS_INVALID_PARAM;
- }
- if (WebPIsRGBMode(src_buf->colorspace)) {
- const WebPRGBABuffer* const src = &src_buf->u.RGBA;
- const WebPRGBABuffer* const dst = &dst_buf->u.RGBA;
- WebPCopyPlane(src->rgba, src->stride, dst->rgba, dst->stride,
- src_buf->width * kModeBpp[src_buf->colorspace],
- src_buf->height);
- } else {
- const WebPYUVABuffer* const src = &src_buf->u.YUVA;
- const WebPYUVABuffer* const dst = &dst_buf->u.YUVA;
- WebPCopyPlane(src->y, src->y_stride, dst->y, dst->y_stride,
- src_buf->width, src_buf->height);
- WebPCopyPlane(src->u, src->u_stride, dst->u, dst->u_stride,
- (src_buf->width + 1) / 2, (src_buf->height + 1) / 2);
- WebPCopyPlane(src->v, src->v_stride, dst->v, dst->v_stride,
- (src_buf->width + 1) / 2, (src_buf->height + 1) / 2);
- if (WebPIsAlphaMode(src_buf->colorspace)) {
- WebPCopyPlane(src->a, src->a_stride, dst->a, dst->a_stride,
- src_buf->width, src_buf->height);
- }
- }
- return VP8_STATUS_OK;
-}
-
-int WebPAvoidSlowMemory(const WebPDecBuffer* const output,
- const WebPBitstreamFeatures* const features) {
- assert(output != NULL);
- return (output->is_external_memory >= 2) &&
- WebPIsPremultipliedMode(output->colorspace) &&
- (features != NULL && features->has_alpha);
-}
-
-//------------------------------------------------------------------------------
diff --git a/contrib/libs/libwebp/dec/common_dec.h b/contrib/libs/libwebp/dec/common_dec.h
deleted file mode 100644
index b158550a80..0000000000
--- a/contrib/libs/libwebp/dec/common_dec.h
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright 2015 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Definitions and macros common to encoding and decoding
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#ifndef WEBP_DEC_COMMON_DEC_H_
-#define WEBP_DEC_COMMON_DEC_H_
-
-// intra prediction modes
-enum { B_DC_PRED = 0, // 4x4 modes
- B_TM_PRED = 1,
- B_VE_PRED = 2,
- B_HE_PRED = 3,
- B_RD_PRED = 4,
- B_VR_PRED = 5,
- B_LD_PRED = 6,
- B_VL_PRED = 7,
- B_HD_PRED = 8,
- B_HU_PRED = 9,
- NUM_BMODES = B_HU_PRED + 1 - B_DC_PRED, // = 10
-
- // Luma16 or UV modes
- DC_PRED = B_DC_PRED, V_PRED = B_VE_PRED,
- H_PRED = B_HE_PRED, TM_PRED = B_TM_PRED,
- B_PRED = NUM_BMODES, // refined I4x4 mode
- NUM_PRED_MODES = 4,
-
- // special modes
- B_DC_PRED_NOTOP = 4,
- B_DC_PRED_NOLEFT = 5,
- B_DC_PRED_NOTOPLEFT = 6,
- NUM_B_DC_MODES = 7 };
-
-enum { MB_FEATURE_TREE_PROBS = 3,
- NUM_MB_SEGMENTS = 4,
- NUM_REF_LF_DELTAS = 4,
- NUM_MODE_LF_DELTAS = 4, // I4x4, ZERO, *, SPLIT
- MAX_NUM_PARTITIONS = 8,
- // Probabilities
- NUM_TYPES = 4, // 0: i16-AC, 1: i16-DC, 2:chroma-AC, 3:i4-AC
- NUM_BANDS = 8,
- NUM_CTX = 3,
- NUM_PROBAS = 11
- };
-
-#endif // WEBP_DEC_COMMON_DEC_H_
diff --git a/contrib/libs/libwebp/dec/frame_dec.c b/contrib/libs/libwebp/dec/frame_dec.c
deleted file mode 100644
index 4c5709ccb9..0000000000
--- a/contrib/libs/libwebp/dec/frame_dec.c
+++ /dev/null
@@ -1,803 +0,0 @@
-// Copyright 2010 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Frame-reconstruction function. Memory allocation.
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include <stdlib.h>
-#include "./vp8i_dec.h"
-#include "../utils/utils.h"
-
-//------------------------------------------------------------------------------
-// Main reconstruction function.
-
-static const uint16_t kScan[16] = {
- 0 + 0 * BPS, 4 + 0 * BPS, 8 + 0 * BPS, 12 + 0 * BPS,
- 0 + 4 * BPS, 4 + 4 * BPS, 8 + 4 * BPS, 12 + 4 * BPS,
- 0 + 8 * BPS, 4 + 8 * BPS, 8 + 8 * BPS, 12 + 8 * BPS,
- 0 + 12 * BPS, 4 + 12 * BPS, 8 + 12 * BPS, 12 + 12 * BPS
-};
-
-static int CheckMode(int mb_x, int mb_y, int mode) {
- if (mode == B_DC_PRED) {
- if (mb_x == 0) {
- return (mb_y == 0) ? B_DC_PRED_NOTOPLEFT : B_DC_PRED_NOLEFT;
- } else {
- return (mb_y == 0) ? B_DC_PRED_NOTOP : B_DC_PRED;
- }
- }
- return mode;
-}
-
-static void Copy32b(uint8_t* const dst, const uint8_t* const src) {
- memcpy(dst, src, 4);
-}
-
-static WEBP_INLINE void DoTransform(uint32_t bits, const int16_t* const src,
- uint8_t* const dst) {
- switch (bits >> 30) {
- case 3:
- VP8Transform(src, dst, 0);
- break;
- case 2:
- VP8TransformAC3(src, dst);
- break;
- case 1:
- VP8TransformDC(src, dst);
- break;
- default:
- break;
- }
-}
-
-static void DoUVTransform(uint32_t bits, const int16_t* const src,
- uint8_t* const dst) {
- if (bits & 0xff) { // any non-zero coeff at all?
- if (bits & 0xaa) { // any non-zero AC coefficient?
- VP8TransformUV(src, dst); // note we don't use the AC3 variant for U/V
- } else {
- VP8TransformDCUV(src, dst);
- }
- }
-}
-
-static void ReconstructRow(const VP8Decoder* const dec,
- const VP8ThreadContext* ctx) {
- int j;
- int mb_x;
- const int mb_y = ctx->mb_y_;
- const int cache_id = ctx->id_;
- uint8_t* const y_dst = dec->yuv_b_ + Y_OFF;
- uint8_t* const u_dst = dec->yuv_b_ + U_OFF;
- uint8_t* const v_dst = dec->yuv_b_ + V_OFF;
-
- // Initialize left-most block.
- for (j = 0; j < 16; ++j) {
- y_dst[j * BPS - 1] = 129;
- }
- for (j = 0; j < 8; ++j) {
- u_dst[j * BPS - 1] = 129;
- v_dst[j * BPS - 1] = 129;
- }
-
- // Init top-left sample on left column too.
- if (mb_y > 0) {
- y_dst[-1 - BPS] = u_dst[-1 - BPS] = v_dst[-1 - BPS] = 129;
- } else {
- // we only need to do this init once at block (0,0).
- // Afterward, it remains valid for the whole topmost row.
- memset(y_dst - BPS - 1, 127, 16 + 4 + 1);
- memset(u_dst - BPS - 1, 127, 8 + 1);
- memset(v_dst - BPS - 1, 127, 8 + 1);
- }
-
- // Reconstruct one row.
- for (mb_x = 0; mb_x < dec->mb_w_; ++mb_x) {
- const VP8MBData* const block = ctx->mb_data_ + mb_x;
-
- // Rotate in the left samples from previously decoded block. We move four
- // pixels at a time for alignment reason, and because of in-loop filter.
- if (mb_x > 0) {
- for (j = -1; j < 16; ++j) {
- Copy32b(&y_dst[j * BPS - 4], &y_dst[j * BPS + 12]);
- }
- for (j = -1; j < 8; ++j) {
- Copy32b(&u_dst[j * BPS - 4], &u_dst[j * BPS + 4]);
- Copy32b(&v_dst[j * BPS - 4], &v_dst[j * BPS + 4]);
- }
- }
- {
- // bring top samples into the cache
- VP8TopSamples* const top_yuv = dec->yuv_t_ + mb_x;
- const int16_t* const coeffs = block->coeffs_;
- uint32_t bits = block->non_zero_y_;
- int n;
-
- if (mb_y > 0) {
- memcpy(y_dst - BPS, top_yuv[0].y, 16);
- memcpy(u_dst - BPS, top_yuv[0].u, 8);
- memcpy(v_dst - BPS, top_yuv[0].v, 8);
- }
-
- // predict and add residuals
- if (block->is_i4x4_) { // 4x4
- uint32_t* const top_right = (uint32_t*)(y_dst - BPS + 16);
-
- if (mb_y > 0) {
- if (mb_x >= dec->mb_w_ - 1) { // on rightmost border
- memset(top_right, top_yuv[0].y[15], sizeof(*top_right));
- } else {
- memcpy(top_right, top_yuv[1].y, sizeof(*top_right));
- }
- }
- // replicate the top-right pixels below
- top_right[BPS] = top_right[2 * BPS] = top_right[3 * BPS] = top_right[0];
-
- // predict and add residuals for all 4x4 blocks in turn.
- for (n = 0; n < 16; ++n, bits <<= 2) {
- uint8_t* const dst = y_dst + kScan[n];
- VP8PredLuma4[block->imodes_[n]](dst);
- DoTransform(bits, coeffs + n * 16, dst);
- }
- } else { // 16x16
- const int pred_func = CheckMode(mb_x, mb_y, block->imodes_[0]);
- VP8PredLuma16[pred_func](y_dst);
- if (bits != 0) {
- for (n = 0; n < 16; ++n, bits <<= 2) {
- DoTransform(bits, coeffs + n * 16, y_dst + kScan[n]);
- }
- }
- }
- {
- // Chroma
- const uint32_t bits_uv = block->non_zero_uv_;
- const int pred_func = CheckMode(mb_x, mb_y, block->uvmode_);
- VP8PredChroma8[pred_func](u_dst);
- VP8PredChroma8[pred_func](v_dst);
- DoUVTransform(bits_uv >> 0, coeffs + 16 * 16, u_dst);
- DoUVTransform(bits_uv >> 8, coeffs + 20 * 16, v_dst);
- }
-
- // stash away top samples for next block
- if (mb_y < dec->mb_h_ - 1) {
- memcpy(top_yuv[0].y, y_dst + 15 * BPS, 16);
- memcpy(top_yuv[0].u, u_dst + 7 * BPS, 8);
- memcpy(top_yuv[0].v, v_dst + 7 * BPS, 8);
- }
- }
- // Transfer reconstructed samples from yuv_b_ cache to final destination.
- {
- const int y_offset = cache_id * 16 * dec->cache_y_stride_;
- const int uv_offset = cache_id * 8 * dec->cache_uv_stride_;
- uint8_t* const y_out = dec->cache_y_ + mb_x * 16 + y_offset;
- uint8_t* const u_out = dec->cache_u_ + mb_x * 8 + uv_offset;
- uint8_t* const v_out = dec->cache_v_ + mb_x * 8 + uv_offset;
- for (j = 0; j < 16; ++j) {
- memcpy(y_out + j * dec->cache_y_stride_, y_dst + j * BPS, 16);
- }
- for (j = 0; j < 8; ++j) {
- memcpy(u_out + j * dec->cache_uv_stride_, u_dst + j * BPS, 8);
- memcpy(v_out + j * dec->cache_uv_stride_, v_dst + j * BPS, 8);
- }
- }
- }
-}
-
-//------------------------------------------------------------------------------
-// Filtering
-
-// kFilterExtraRows[] = How many extra lines are needed on the MB boundary
-// for caching, given a filtering level.
-// Simple filter: up to 2 luma samples are read and 1 is written.
-// Complex filter: up to 4 luma samples are read and 3 are written. Same for
-// U/V, so it's 8 samples total (because of the 2x upsampling).
-static const uint8_t kFilterExtraRows[3] = { 0, 2, 8 };
-
-static void DoFilter(const VP8Decoder* const dec, int mb_x, int mb_y) {
- const VP8ThreadContext* const ctx = &dec->thread_ctx_;
- const int cache_id = ctx->id_;
- const int y_bps = dec->cache_y_stride_;
- const VP8FInfo* const f_info = ctx->f_info_ + mb_x;
- uint8_t* const y_dst = dec->cache_y_ + cache_id * 16 * y_bps + mb_x * 16;
- const int ilevel = f_info->f_ilevel_;
- const int limit = f_info->f_limit_;
- if (limit == 0) {
- return;
- }
- assert(limit >= 3);
- if (dec->filter_type_ == 1) { // simple
- if (mb_x > 0) {
- VP8SimpleHFilter16(y_dst, y_bps, limit + 4);
- }
- if (f_info->f_inner_) {
- VP8SimpleHFilter16i(y_dst, y_bps, limit);
- }
- if (mb_y > 0) {
- VP8SimpleVFilter16(y_dst, y_bps, limit + 4);
- }
- if (f_info->f_inner_) {
- VP8SimpleVFilter16i(y_dst, y_bps, limit);
- }
- } else { // complex
- const int uv_bps = dec->cache_uv_stride_;
- uint8_t* const u_dst = dec->cache_u_ + cache_id * 8 * uv_bps + mb_x * 8;
- uint8_t* const v_dst = dec->cache_v_ + cache_id * 8 * uv_bps + mb_x * 8;
- const int hev_thresh = f_info->hev_thresh_;
- if (mb_x > 0) {
- VP8HFilter16(y_dst, y_bps, limit + 4, ilevel, hev_thresh);
- VP8HFilter8(u_dst, v_dst, uv_bps, limit + 4, ilevel, hev_thresh);
- }
- if (f_info->f_inner_) {
- VP8HFilter16i(y_dst, y_bps, limit, ilevel, hev_thresh);
- VP8HFilter8i(u_dst, v_dst, uv_bps, limit, ilevel, hev_thresh);
- }
- if (mb_y > 0) {
- VP8VFilter16(y_dst, y_bps, limit + 4, ilevel, hev_thresh);
- VP8VFilter8(u_dst, v_dst, uv_bps, limit + 4, ilevel, hev_thresh);
- }
- if (f_info->f_inner_) {
- VP8VFilter16i(y_dst, y_bps, limit, ilevel, hev_thresh);
- VP8VFilter8i(u_dst, v_dst, uv_bps, limit, ilevel, hev_thresh);
- }
- }
-}
-
-// Filter the decoded macroblock row (if needed)
-static void FilterRow(const VP8Decoder* const dec) {
- int mb_x;
- const int mb_y = dec->thread_ctx_.mb_y_;
- assert(dec->thread_ctx_.filter_row_);
- for (mb_x = dec->tl_mb_x_; mb_x < dec->br_mb_x_; ++mb_x) {
- DoFilter(dec, mb_x, mb_y);
- }
-}
-
-//------------------------------------------------------------------------------
-// Precompute the filtering strength for each segment and each i4x4/i16x16 mode.
-
-static void PrecomputeFilterStrengths(VP8Decoder* const dec) {
- if (dec->filter_type_ > 0) {
- int s;
- const VP8FilterHeader* const hdr = &dec->filter_hdr_;
- for (s = 0; s < NUM_MB_SEGMENTS; ++s) {
- int i4x4;
- // First, compute the initial level
- int base_level;
- if (dec->segment_hdr_.use_segment_) {
- base_level = dec->segment_hdr_.filter_strength_[s];
- if (!dec->segment_hdr_.absolute_delta_) {
- base_level += hdr->level_;
- }
- } else {
- base_level = hdr->level_;
- }
- for (i4x4 = 0; i4x4 <= 1; ++i4x4) {
- VP8FInfo* const info = &dec->fstrengths_[s][i4x4];
- int level = base_level;
- if (hdr->use_lf_delta_) {
- level += hdr->ref_lf_delta_[0];
- if (i4x4) {
- level += hdr->mode_lf_delta_[0];
- }
- }
- level = (level < 0) ? 0 : (level > 63) ? 63 : level;
- if (level > 0) {
- int ilevel = level;
- if (hdr->sharpness_ > 0) {
- if (hdr->sharpness_ > 4) {
- ilevel >>= 2;
- } else {
- ilevel >>= 1;
- }
- if (ilevel > 9 - hdr->sharpness_) {
- ilevel = 9 - hdr->sharpness_;
- }
- }
- if (ilevel < 1) ilevel = 1;
- info->f_ilevel_ = ilevel;
- info->f_limit_ = 2 * level + ilevel;
- info->hev_thresh_ = (level >= 40) ? 2 : (level >= 15) ? 1 : 0;
- } else {
- info->f_limit_ = 0; // no filtering
- }
- info->f_inner_ = i4x4;
- }
- }
- }
-}
-
-//------------------------------------------------------------------------------
-// Dithering
-
-// minimal amp that will provide a non-zero dithering effect
-#define MIN_DITHER_AMP 4
-
-#define DITHER_AMP_TAB_SIZE 12
-static const uint8_t kQuantToDitherAmp[DITHER_AMP_TAB_SIZE] = {
- // roughly, it's dqm->uv_mat_[1]
- 8, 7, 6, 4, 4, 2, 2, 2, 1, 1, 1, 1
-};
-
-void VP8InitDithering(const WebPDecoderOptions* const options,
- VP8Decoder* const dec) {
- assert(dec != NULL);
- if (options != NULL) {
- const int d = options->dithering_strength;
- const int max_amp = (1 << VP8_RANDOM_DITHER_FIX) - 1;
- const int f = (d < 0) ? 0 : (d > 100) ? max_amp : (d * max_amp / 100);
- if (f > 0) {
- int s;
- int all_amp = 0;
- for (s = 0; s < NUM_MB_SEGMENTS; ++s) {
- VP8QuantMatrix* const dqm = &dec->dqm_[s];
- if (dqm->uv_quant_ < DITHER_AMP_TAB_SIZE) {
- const int idx = (dqm->uv_quant_ < 0) ? 0 : dqm->uv_quant_;
- dqm->dither_ = (f * kQuantToDitherAmp[idx]) >> 3;
- }
- all_amp |= dqm->dither_;
- }
- if (all_amp != 0) {
- VP8InitRandom(&dec->dithering_rg_, 1.0f);
- dec->dither_ = 1;
- }
- }
- // potentially allow alpha dithering
- dec->alpha_dithering_ = options->alpha_dithering_strength;
- if (dec->alpha_dithering_ > 100) {
- dec->alpha_dithering_ = 100;
- } else if (dec->alpha_dithering_ < 0) {
- dec->alpha_dithering_ = 0;
- }
- }
-}
-
-// Convert to range: [-2,2] for dither=50, [-4,4] for dither=100
-static void Dither8x8(VP8Random* const rg, uint8_t* dst, int bps, int amp) {
- uint8_t dither[64];
- int i;
- for (i = 0; i < 8 * 8; ++i) {
- dither[i] = VP8RandomBits2(rg, VP8_DITHER_AMP_BITS + 1, amp);
- }
- VP8DitherCombine8x8(dither, dst, bps);
-}
-
-static void DitherRow(VP8Decoder* const dec) {
- int mb_x;
- assert(dec->dither_);
- for (mb_x = dec->tl_mb_x_; mb_x < dec->br_mb_x_; ++mb_x) {
- const VP8ThreadContext* const ctx = &dec->thread_ctx_;
- const VP8MBData* const data = ctx->mb_data_ + mb_x;
- const int cache_id = ctx->id_;
- const int uv_bps = dec->cache_uv_stride_;
- if (data->dither_ >= MIN_DITHER_AMP) {
- uint8_t* const u_dst = dec->cache_u_ + cache_id * 8 * uv_bps + mb_x * 8;
- uint8_t* const v_dst = dec->cache_v_ + cache_id * 8 * uv_bps + mb_x * 8;
- Dither8x8(&dec->dithering_rg_, u_dst, uv_bps, data->dither_);
- Dither8x8(&dec->dithering_rg_, v_dst, uv_bps, data->dither_);
- }
- }
-}
-
-//------------------------------------------------------------------------------
-// This function is called after a row of macroblocks is finished decoding.
-// It also takes into account the following restrictions:
-// * In case of in-loop filtering, we must hold off sending some of the bottom
-// pixels as they are yet unfiltered. They will be when the next macroblock
-// row is decoded. Meanwhile, we must preserve them by rotating them in the
-// cache area. This doesn't hold for the very bottom row of the uncropped
-// picture of course.
-// * we must clip the remaining pixels against the cropping area. The VP8Io
-// struct must have the following fields set correctly before calling put():
-
-#define MACROBLOCK_VPOS(mb_y) ((mb_y) * 16) // vertical position of a MB
-
-// Finalize and transmit a complete row. Return false in case of user-abort.
-static int FinishRow(void* arg1, void* arg2) {
- VP8Decoder* const dec = (VP8Decoder*)arg1;
- VP8Io* const io = (VP8Io*)arg2;
- int ok = 1;
- const VP8ThreadContext* const ctx = &dec->thread_ctx_;
- const int cache_id = ctx->id_;
- const int extra_y_rows = kFilterExtraRows[dec->filter_type_];
- const int ysize = extra_y_rows * dec->cache_y_stride_;
- const int uvsize = (extra_y_rows / 2) * dec->cache_uv_stride_;
- const int y_offset = cache_id * 16 * dec->cache_y_stride_;
- const int uv_offset = cache_id * 8 * dec->cache_uv_stride_;
- uint8_t* const ydst = dec->cache_y_ - ysize + y_offset;
- uint8_t* const udst = dec->cache_u_ - uvsize + uv_offset;
- uint8_t* const vdst = dec->cache_v_ - uvsize + uv_offset;
- const int mb_y = ctx->mb_y_;
- const int is_first_row = (mb_y == 0);
- const int is_last_row = (mb_y >= dec->br_mb_y_ - 1);
-
- if (dec->mt_method_ == 2) {
- ReconstructRow(dec, ctx);
- }
-
- if (ctx->filter_row_) {
- FilterRow(dec);
- }
-
- if (dec->dither_) {
- DitherRow(dec);
- }
-
- if (io->put != NULL) {
- int y_start = MACROBLOCK_VPOS(mb_y);
- int y_end = MACROBLOCK_VPOS(mb_y + 1);
- if (!is_first_row) {
- y_start -= extra_y_rows;
- io->y = ydst;
- io->u = udst;
- io->v = vdst;
- } else {
- io->y = dec->cache_y_ + y_offset;
- io->u = dec->cache_u_ + uv_offset;
- io->v = dec->cache_v_ + uv_offset;
- }
-
- if (!is_last_row) {
- y_end -= extra_y_rows;
- }
- if (y_end > io->crop_bottom) {
- y_end = io->crop_bottom; // make sure we don't overflow on last row.
- }
- // If dec->alpha_data_ is not NULL, we have some alpha plane present.
- io->a = NULL;
- if (dec->alpha_data_ != NULL && y_start < y_end) {
- io->a = VP8DecompressAlphaRows(dec, io, y_start, y_end - y_start);
- if (io->a == NULL) {
- return VP8SetError(dec, VP8_STATUS_BITSTREAM_ERROR,
- "Could not decode alpha data.");
- }
- }
- if (y_start < io->crop_top) {
- const int delta_y = io->crop_top - y_start;
- y_start = io->crop_top;
- assert(!(delta_y & 1));
- io->y += dec->cache_y_stride_ * delta_y;
- io->u += dec->cache_uv_stride_ * (delta_y >> 1);
- io->v += dec->cache_uv_stride_ * (delta_y >> 1);
- if (io->a != NULL) {
- io->a += io->width * delta_y;
- }
- }
- if (y_start < y_end) {
- io->y += io->crop_left;
- io->u += io->crop_left >> 1;
- io->v += io->crop_left >> 1;
- if (io->a != NULL) {
- io->a += io->crop_left;
- }
- io->mb_y = y_start - io->crop_top;
- io->mb_w = io->crop_right - io->crop_left;
- io->mb_h = y_end - y_start;
- ok = io->put(io);
- }
- }
- // rotate top samples if needed
- if (cache_id + 1 == dec->num_caches_) {
- if (!is_last_row) {
- memcpy(dec->cache_y_ - ysize, ydst + 16 * dec->cache_y_stride_, ysize);
- memcpy(dec->cache_u_ - uvsize, udst + 8 * dec->cache_uv_stride_, uvsize);
- memcpy(dec->cache_v_ - uvsize, vdst + 8 * dec->cache_uv_stride_, uvsize);
- }
- }
-
- return ok;
-}
-
-#undef MACROBLOCK_VPOS
-
-//------------------------------------------------------------------------------
-
-int VP8ProcessRow(VP8Decoder* const dec, VP8Io* const io) {
- int ok = 1;
- VP8ThreadContext* const ctx = &dec->thread_ctx_;
- const int filter_row =
- (dec->filter_type_ > 0) &&
- (dec->mb_y_ >= dec->tl_mb_y_) && (dec->mb_y_ <= dec->br_mb_y_);
- if (dec->mt_method_ == 0) {
- // ctx->id_ and ctx->f_info_ are already set
- ctx->mb_y_ = dec->mb_y_;
- ctx->filter_row_ = filter_row;
- ReconstructRow(dec, ctx);
- ok = FinishRow(dec, io);
- } else {
- WebPWorker* const worker = &dec->worker_;
- // Finish previous job *before* updating context
- ok &= WebPGetWorkerInterface()->Sync(worker);
- assert(worker->status_ == OK);
- if (ok) { // spawn a new deblocking/output job
- ctx->io_ = *io;
- ctx->id_ = dec->cache_id_;
- ctx->mb_y_ = dec->mb_y_;
- ctx->filter_row_ = filter_row;
- if (dec->mt_method_ == 2) { // swap macroblock data
- VP8MBData* const tmp = ctx->mb_data_;
- ctx->mb_data_ = dec->mb_data_;
- dec->mb_data_ = tmp;
- } else {
- // perform reconstruction directly in main thread
- ReconstructRow(dec, ctx);
- }
- if (filter_row) { // swap filter info
- VP8FInfo* const tmp = ctx->f_info_;
- ctx->f_info_ = dec->f_info_;
- dec->f_info_ = tmp;
- }
- // (reconstruct)+filter in parallel
- WebPGetWorkerInterface()->Launch(worker);
- if (++dec->cache_id_ == dec->num_caches_) {
- dec->cache_id_ = 0;
- }
- }
- }
- return ok;
-}
-
-//------------------------------------------------------------------------------
-// Finish setting up the decoding parameter once user's setup() is called.
-
-VP8StatusCode VP8EnterCritical(VP8Decoder* const dec, VP8Io* const io) {
- // Call setup() first. This may trigger additional decoding features on 'io'.
- // Note: Afterward, we must call teardown() no matter what.
- if (io->setup != NULL && !io->setup(io)) {
- VP8SetError(dec, VP8_STATUS_USER_ABORT, "Frame setup failed");
- return dec->status_;
- }
-
- // Disable filtering per user request
- if (io->bypass_filtering) {
- dec->filter_type_ = 0;
- }
-
- // Define the area where we can skip in-loop filtering, in case of cropping.
- //
- // 'Simple' filter reads two luma samples outside of the macroblock
- // and filters one. It doesn't filter the chroma samples. Hence, we can
- // avoid doing the in-loop filtering before crop_top/crop_left position.
- // For the 'Complex' filter, 3 samples are read and up to 3 are filtered.
- // Means: there's a dependency chain that goes all the way up to the
- // top-left corner of the picture (MB #0). We must filter all the previous
- // macroblocks.
- {
- const int extra_pixels = kFilterExtraRows[dec->filter_type_];
- if (dec->filter_type_ == 2) {
- // For complex filter, we need to preserve the dependency chain.
- dec->tl_mb_x_ = 0;
- dec->tl_mb_y_ = 0;
- } else {
- // For simple filter, we can filter only the cropped region.
- // We include 'extra_pixels' on the other side of the boundary, since
- // vertical or horizontal filtering of the previous macroblock can
- // modify some abutting pixels.
- dec->tl_mb_x_ = (io->crop_left - extra_pixels) >> 4;
- dec->tl_mb_y_ = (io->crop_top - extra_pixels) >> 4;
- if (dec->tl_mb_x_ < 0) dec->tl_mb_x_ = 0;
- if (dec->tl_mb_y_ < 0) dec->tl_mb_y_ = 0;
- }
- // We need some 'extra' pixels on the right/bottom.
- dec->br_mb_y_ = (io->crop_bottom + 15 + extra_pixels) >> 4;
- dec->br_mb_x_ = (io->crop_right + 15 + extra_pixels) >> 4;
- if (dec->br_mb_x_ > dec->mb_w_) {
- dec->br_mb_x_ = dec->mb_w_;
- }
- if (dec->br_mb_y_ > dec->mb_h_) {
- dec->br_mb_y_ = dec->mb_h_;
- }
- }
- PrecomputeFilterStrengths(dec);
- return VP8_STATUS_OK;
-}
-
-int VP8ExitCritical(VP8Decoder* const dec, VP8Io* const io) {
- int ok = 1;
- if (dec->mt_method_ > 0) {
- ok = WebPGetWorkerInterface()->Sync(&dec->worker_);
- }
-
- if (io->teardown != NULL) {
- io->teardown(io);
- }
- return ok;
-}
-
-//------------------------------------------------------------------------------
-// For multi-threaded decoding we need to use 3 rows of 16 pixels as delay line.
-//
-// Reason is: the deblocking filter cannot deblock the bottom horizontal edges
-// immediately, and needs to wait for first few rows of the next macroblock to
-// be decoded. Hence, deblocking is lagging behind by 4 or 8 pixels (depending
-// on strength).
-// With two threads, the vertical positions of the rows being decoded are:
-// Decode: [ 0..15][16..31][32..47][48..63][64..79][...
-// Deblock: [ 0..11][12..27][28..43][44..59][...
-// If we use two threads and two caches of 16 pixels, the sequence would be:
-// Decode: [ 0..15][16..31][ 0..15!!][16..31][ 0..15][...
-// Deblock: [ 0..11][12..27!!][-4..11][12..27][...
-// The problem occurs during row [12..15!!] that both the decoding and
-// deblocking threads are writing simultaneously.
-// With 3 cache lines, one get a safe write pattern:
-// Decode: [ 0..15][16..31][32..47][ 0..15][16..31][32..47][0..
-// Deblock: [ 0..11][12..27][28..43][-4..11][12..27][28...
-// Note that multi-threaded output _without_ deblocking can make use of two
-// cache lines of 16 pixels only, since there's no lagging behind. The decoding
-// and output process have non-concurrent writing:
-// Decode: [ 0..15][16..31][ 0..15][16..31][...
-// io->put: [ 0..15][16..31][ 0..15][...
-
-#define MT_CACHE_LINES 3
-#define ST_CACHE_LINES 1 // 1 cache row only for single-threaded case
-
-// Initialize multi/single-thread worker
-static int InitThreadContext(VP8Decoder* const dec) {
- dec->cache_id_ = 0;
- if (dec->mt_method_ > 0) {
- WebPWorker* const worker = &dec->worker_;
- if (!WebPGetWorkerInterface()->Reset(worker)) {
- return VP8SetError(dec, VP8_STATUS_OUT_OF_MEMORY,
- "thread initialization failed.");
- }
- worker->data1 = dec;
- worker->data2 = (void*)&dec->thread_ctx_.io_;
- worker->hook = FinishRow;
- dec->num_caches_ =
- (dec->filter_type_ > 0) ? MT_CACHE_LINES : MT_CACHE_LINES - 1;
- } else {
- dec->num_caches_ = ST_CACHE_LINES;
- }
- return 1;
-}
-
-int VP8GetThreadMethod(const WebPDecoderOptions* const options,
- const WebPHeaderStructure* const headers,
- int width, int height) {
- if (options == NULL || options->use_threads == 0) {
- return 0;
- }
- (void)headers;
- (void)width;
- (void)height;
- assert(headers == NULL || !headers->is_lossless);
-#if defined(WEBP_USE_THREAD)
- if (width >= MIN_WIDTH_FOR_THREADS) return 2;
-#endif
- return 0;
-}
-
-#undef MT_CACHE_LINES
-#undef ST_CACHE_LINES
-
-//------------------------------------------------------------------------------
-// Memory setup
-
-static int AllocateMemory(VP8Decoder* const dec) {
- const int num_caches = dec->num_caches_;
- const int mb_w = dec->mb_w_;
- // Note: we use 'size_t' when there's no overflow risk, uint64_t otherwise.
- const size_t intra_pred_mode_size = 4 * mb_w * sizeof(uint8_t);
- const size_t top_size = sizeof(VP8TopSamples) * mb_w;
- const size_t mb_info_size = (mb_w + 1) * sizeof(VP8MB);
- const size_t f_info_size =
- (dec->filter_type_ > 0) ?
- mb_w * (dec->mt_method_ > 0 ? 2 : 1) * sizeof(VP8FInfo)
- : 0;
- const size_t yuv_size = YUV_SIZE * sizeof(*dec->yuv_b_);
- const size_t mb_data_size =
- (dec->mt_method_ == 2 ? 2 : 1) * mb_w * sizeof(*dec->mb_data_);
- const size_t cache_height = (16 * num_caches
- + kFilterExtraRows[dec->filter_type_]) * 3 / 2;
- const size_t cache_size = top_size * cache_height;
- // alpha_size is the only one that scales as width x height.
- const uint64_t alpha_size = (dec->alpha_data_ != NULL) ?
- (uint64_t)dec->pic_hdr_.width_ * dec->pic_hdr_.height_ : 0ULL;
- const uint64_t needed = (uint64_t)intra_pred_mode_size
- + top_size + mb_info_size + f_info_size
- + yuv_size + mb_data_size
- + cache_size + alpha_size + WEBP_ALIGN_CST;
- uint8_t* mem;
-
- if (!CheckSizeOverflow(needed)) return 0; // check for overflow
- if (needed > dec->mem_size_) {
- WebPSafeFree(dec->mem_);
- dec->mem_size_ = 0;
- dec->mem_ = WebPSafeMalloc(needed, sizeof(uint8_t));
- if (dec->mem_ == NULL) {
- return VP8SetError(dec, VP8_STATUS_OUT_OF_MEMORY,
- "no memory during frame initialization.");
- }
- // down-cast is ok, thanks to WebPSafeMalloc() above.
- dec->mem_size_ = (size_t)needed;
- }
-
- mem = (uint8_t*)dec->mem_;
- dec->intra_t_ = mem;
- mem += intra_pred_mode_size;
-
- dec->yuv_t_ = (VP8TopSamples*)mem;
- mem += top_size;
-
- dec->mb_info_ = ((VP8MB*)mem) + 1;
- mem += mb_info_size;
-
- dec->f_info_ = f_info_size ? (VP8FInfo*)mem : NULL;
- mem += f_info_size;
- dec->thread_ctx_.id_ = 0;
- dec->thread_ctx_.f_info_ = dec->f_info_;
- if (dec->filter_type_ > 0 && dec->mt_method_ > 0) {
- // secondary cache line. The deblocking process need to make use of the
- // filtering strength from previous macroblock row, while the new ones
- // are being decoded in parallel. We'll just swap the pointers.
- dec->thread_ctx_.f_info_ += mb_w;
- }
-
- mem = (uint8_t*)WEBP_ALIGN(mem);
- assert((yuv_size & WEBP_ALIGN_CST) == 0);
- dec->yuv_b_ = mem;
- mem += yuv_size;
-
- dec->mb_data_ = (VP8MBData*)mem;
- dec->thread_ctx_.mb_data_ = (VP8MBData*)mem;
- if (dec->mt_method_ == 2) {
- dec->thread_ctx_.mb_data_ += mb_w;
- }
- mem += mb_data_size;
-
- dec->cache_y_stride_ = 16 * mb_w;
- dec->cache_uv_stride_ = 8 * mb_w;
- {
- const int extra_rows = kFilterExtraRows[dec->filter_type_];
- const int extra_y = extra_rows * dec->cache_y_stride_;
- const int extra_uv = (extra_rows / 2) * dec->cache_uv_stride_;
- dec->cache_y_ = mem + extra_y;
- dec->cache_u_ = dec->cache_y_
- + 16 * num_caches * dec->cache_y_stride_ + extra_uv;
- dec->cache_v_ = dec->cache_u_
- + 8 * num_caches * dec->cache_uv_stride_ + extra_uv;
- dec->cache_id_ = 0;
- }
- mem += cache_size;
-
- // alpha plane
- dec->alpha_plane_ = alpha_size ? mem : NULL;
- mem += alpha_size;
- assert(mem <= (uint8_t*)dec->mem_ + dec->mem_size_);
-
- // note: left/top-info is initialized once for all.
- memset(dec->mb_info_ - 1, 0, mb_info_size);
- VP8InitScanline(dec); // initialize left too.
-
- // initialize top
- memset(dec->intra_t_, B_DC_PRED, intra_pred_mode_size);
-
- return 1;
-}
-
-static void InitIo(VP8Decoder* const dec, VP8Io* io) {
- // prepare 'io'
- io->mb_y = 0;
- io->y = dec->cache_y_;
- io->u = dec->cache_u_;
- io->v = dec->cache_v_;
- io->y_stride = dec->cache_y_stride_;
- io->uv_stride = dec->cache_uv_stride_;
- io->a = NULL;
-}
-
-int VP8InitFrame(VP8Decoder* const dec, VP8Io* const io) {
- if (!InitThreadContext(dec)) return 0; // call first. Sets dec->num_caches_.
- if (!AllocateMemory(dec)) return 0;
- InitIo(dec, io);
- VP8DspInit(); // Init critical function pointers and look-up tables.
- return 1;
-}
-
-//------------------------------------------------------------------------------
diff --git a/contrib/libs/libwebp/dec/idec_dec.c b/contrib/libs/libwebp/dec/idec_dec.c
deleted file mode 100644
index 4f90df8b47..0000000000
--- a/contrib/libs/libwebp/dec/idec_dec.c
+++ /dev/null
@@ -1,908 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Incremental decoding
-//
-// Author: somnath@google.com (Somnath Banerjee)
-
-#include <assert.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include "./alphai_dec.h"
-#include "./webpi_dec.h"
-#include "./vp8i_dec.h"
-#include "../utils/utils.h"
-
-// In append mode, buffer allocations increase as multiples of this value.
-// Needs to be a power of 2.
-#define CHUNK_SIZE 4096
-#define MAX_MB_SIZE 4096
-
-//------------------------------------------------------------------------------
-// Data structures for memory and states
-
-// Decoding states. State normally flows as:
-// WEBP_HEADER->VP8_HEADER->VP8_PARTS0->VP8_DATA->DONE for a lossy image, and
-// WEBP_HEADER->VP8L_HEADER->VP8L_DATA->DONE for a lossless image.
-// If there is any error the decoder goes into state ERROR.
-typedef enum {
- STATE_WEBP_HEADER, // All the data before that of the VP8/VP8L chunk.
- STATE_VP8_HEADER, // The VP8 Frame header (within the VP8 chunk).
- STATE_VP8_PARTS0,
- STATE_VP8_DATA,
- STATE_VP8L_HEADER,
- STATE_VP8L_DATA,
- STATE_DONE,
- STATE_ERROR
-} DecState;
-
-// Operating state for the MemBuffer
-typedef enum {
- MEM_MODE_NONE = 0,
- MEM_MODE_APPEND,
- MEM_MODE_MAP
-} MemBufferMode;
-
-// storage for partition #0 and partial data (in a rolling fashion)
-typedef struct {
- MemBufferMode mode_; // Operation mode
- size_t start_; // start location of the data to be decoded
- size_t end_; // end location
- size_t buf_size_; // size of the allocated buffer
- uint8_t* buf_; // We don't own this buffer in case WebPIUpdate()
-
- size_t part0_size_; // size of partition #0
- const uint8_t* part0_buf_; // buffer to store partition #0
-} MemBuffer;
-
-struct WebPIDecoder {
- DecState state_; // current decoding state
- WebPDecParams params_; // Params to store output info
- int is_lossless_; // for down-casting 'dec_'.
- void* dec_; // either a VP8Decoder or a VP8LDecoder instance
- VP8Io io_;
-
- MemBuffer mem_; // input memory buffer.
- WebPDecBuffer output_; // output buffer (when no external one is supplied,
- // or if the external one has slow-memory)
- WebPDecBuffer* final_output_; // Slow-memory output to copy to eventually.
- size_t chunk_size_; // Compressed VP8/VP8L size extracted from Header.
-
- int last_mb_y_; // last row reached for intra-mode decoding
-};
-
-// MB context to restore in case VP8DecodeMB() fails
-typedef struct {
- VP8MB left_;
- VP8MB info_;
- VP8BitReader token_br_;
-} MBContext;
-
-//------------------------------------------------------------------------------
-// MemBuffer: incoming data handling
-
-static WEBP_INLINE size_t MemDataSize(const MemBuffer* mem) {
- return (mem->end_ - mem->start_);
-}
-
-// Check if we need to preserve the compressed alpha data, as it may not have
-// been decoded yet.
-static int NeedCompressedAlpha(const WebPIDecoder* const idec) {
- if (idec->state_ == STATE_WEBP_HEADER) {
- // We haven't parsed the headers yet, so we don't know whether the image is
- // lossy or lossless. This also means that we haven't parsed the ALPH chunk.
- return 0;
- }
- if (idec->is_lossless_) {
- return 0; // ALPH chunk is not present for lossless images.
- } else {
- const VP8Decoder* const dec = (VP8Decoder*)idec->dec_;
- assert(dec != NULL); // Must be true as idec->state_ != STATE_WEBP_HEADER.
- return (dec->alpha_data_ != NULL) && !dec->is_alpha_decoded_;
- }
-}
-
-static void DoRemap(WebPIDecoder* const idec, ptrdiff_t offset) {
- MemBuffer* const mem = &idec->mem_;
- const uint8_t* const new_base = mem->buf_ + mem->start_;
- // note: for VP8, setting up idec->io_ is only really needed at the beginning
- // of the decoding, till partition #0 is complete.
- idec->io_.data = new_base;
- idec->io_.data_size = MemDataSize(mem);
-
- if (idec->dec_ != NULL) {
- if (!idec->is_lossless_) {
- VP8Decoder* const dec = (VP8Decoder*)idec->dec_;
- const uint32_t last_part = dec->num_parts_minus_one_;
- if (offset != 0) {
- uint32_t p;
- for (p = 0; p <= last_part; ++p) {
- VP8RemapBitReader(dec->parts_ + p, offset);
- }
- // Remap partition #0 data pointer to new offset, but only in MAP
- // mode (in APPEND mode, partition #0 is copied into a fixed memory).
- if (mem->mode_ == MEM_MODE_MAP) {
- VP8RemapBitReader(&dec->br_, offset);
- }
- }
- {
- const uint8_t* const last_start = dec->parts_[last_part].buf_;
- VP8BitReaderSetBuffer(&dec->parts_[last_part], last_start,
- mem->buf_ + mem->end_ - last_start);
- }
- if (NeedCompressedAlpha(idec)) {
- ALPHDecoder* const alph_dec = dec->alph_dec_;
- dec->alpha_data_ += offset;
- if (alph_dec != NULL && alph_dec->vp8l_dec_ != NULL) {
- if (alph_dec->method_ == ALPHA_LOSSLESS_COMPRESSION) {
- VP8LDecoder* const alph_vp8l_dec = alph_dec->vp8l_dec_;
- assert(dec->alpha_data_size_ >= ALPHA_HEADER_LEN);
- VP8LBitReaderSetBuffer(&alph_vp8l_dec->br_,
- dec->alpha_data_ + ALPHA_HEADER_LEN,
- dec->alpha_data_size_ - ALPHA_HEADER_LEN);
- } else { // alph_dec->method_ == ALPHA_NO_COMPRESSION
- // Nothing special to do in this case.
- }
- }
- }
- } else { // Resize lossless bitreader
- VP8LDecoder* const dec = (VP8LDecoder*)idec->dec_;
- VP8LBitReaderSetBuffer(&dec->br_, new_base, MemDataSize(mem));
- }
- }
-}
-
-// Appends data to the end of MemBuffer->buf_. It expands the allocated memory
-// size if required and also updates VP8BitReader's if new memory is allocated.
-static int AppendToMemBuffer(WebPIDecoder* const idec,
- const uint8_t* const data, size_t data_size) {
- VP8Decoder* const dec = (VP8Decoder*)idec->dec_;
- MemBuffer* const mem = &idec->mem_;
- const int need_compressed_alpha = NeedCompressedAlpha(idec);
- const uint8_t* const old_start =
- (mem->buf_ == NULL) ? NULL : mem->buf_ + mem->start_;
- const uint8_t* const old_base =
- need_compressed_alpha ? dec->alpha_data_ : old_start;
- assert(mem->buf_ != NULL || mem->start_ == 0);
- assert(mem->mode_ == MEM_MODE_APPEND);
- if (data_size > MAX_CHUNK_PAYLOAD) {
- // security safeguard: trying to allocate more than what the format
- // allows for a chunk should be considered a smoke smell.
- return 0;
- }
-
- if (mem->end_ + data_size > mem->buf_size_) { // Need some free memory
- const size_t new_mem_start = old_start - old_base;
- const size_t current_size = MemDataSize(mem) + new_mem_start;
- const uint64_t new_size = (uint64_t)current_size + data_size;
- const uint64_t extra_size = (new_size + CHUNK_SIZE - 1) & ~(CHUNK_SIZE - 1);
- uint8_t* const new_buf =
- (uint8_t*)WebPSafeMalloc(extra_size, sizeof(*new_buf));
- if (new_buf == NULL) return 0;
- if (old_base != NULL) memcpy(new_buf, old_base, current_size);
- WebPSafeFree(mem->buf_);
- mem->buf_ = new_buf;
- mem->buf_size_ = (size_t)extra_size;
- mem->start_ = new_mem_start;
- mem->end_ = current_size;
- }
-
- assert(mem->buf_ != NULL);
- memcpy(mem->buf_ + mem->end_, data, data_size);
- mem->end_ += data_size;
- assert(mem->end_ <= mem->buf_size_);
-
- DoRemap(idec, mem->buf_ + mem->start_ - old_start);
- return 1;
-}
-
-static int RemapMemBuffer(WebPIDecoder* const idec,
- const uint8_t* const data, size_t data_size) {
- MemBuffer* const mem = &idec->mem_;
- const uint8_t* const old_buf = mem->buf_;
- const uint8_t* const old_start =
- (old_buf == NULL) ? NULL : old_buf + mem->start_;
- assert(old_buf != NULL || mem->start_ == 0);
- assert(mem->mode_ == MEM_MODE_MAP);
-
- if (data_size < mem->buf_size_) return 0; // can't remap to a shorter buffer!
-
- mem->buf_ = (uint8_t*)data;
- mem->end_ = mem->buf_size_ = data_size;
-
- DoRemap(idec, mem->buf_ + mem->start_ - old_start);
- return 1;
-}
-
-static void InitMemBuffer(MemBuffer* const mem) {
- mem->mode_ = MEM_MODE_NONE;
- mem->buf_ = NULL;
- mem->buf_size_ = 0;
- mem->part0_buf_ = NULL;
- mem->part0_size_ = 0;
-}
-
-static void ClearMemBuffer(MemBuffer* const mem) {
- assert(mem);
- if (mem->mode_ == MEM_MODE_APPEND) {
- WebPSafeFree(mem->buf_);
- WebPSafeFree((void*)mem->part0_buf_);
- }
-}
-
-static int CheckMemBufferMode(MemBuffer* const mem, MemBufferMode expected) {
- if (mem->mode_ == MEM_MODE_NONE) {
- mem->mode_ = expected; // switch to the expected mode
- } else if (mem->mode_ != expected) {
- return 0; // we mixed the modes => error
- }
- assert(mem->mode_ == expected); // mode is ok
- return 1;
-}
-
-// To be called last.
-static VP8StatusCode FinishDecoding(WebPIDecoder* const idec) {
- const WebPDecoderOptions* const options = idec->params_.options;
- WebPDecBuffer* const output = idec->params_.output;
-
- idec->state_ = STATE_DONE;
- if (options != NULL && options->flip) {
- const VP8StatusCode status = WebPFlipBuffer(output);
- if (status != VP8_STATUS_OK) return status;
- }
- if (idec->final_output_ != NULL) {
- WebPCopyDecBufferPixels(output, idec->final_output_); // do the slow-copy
- WebPFreeDecBuffer(&idec->output_);
- *output = *idec->final_output_;
- idec->final_output_ = NULL;
- }
- return VP8_STATUS_OK;
-}
-
-//------------------------------------------------------------------------------
-// Macroblock-decoding contexts
-
-static void SaveContext(const VP8Decoder* dec, const VP8BitReader* token_br,
- MBContext* const context) {
- context->left_ = dec->mb_info_[-1];
- context->info_ = dec->mb_info_[dec->mb_x_];
- context->token_br_ = *token_br;
-}
-
-static void RestoreContext(const MBContext* context, VP8Decoder* const dec,
- VP8BitReader* const token_br) {
- dec->mb_info_[-1] = context->left_;
- dec->mb_info_[dec->mb_x_] = context->info_;
- *token_br = context->token_br_;
-}
-
-//------------------------------------------------------------------------------
-
-static VP8StatusCode IDecError(WebPIDecoder* const idec, VP8StatusCode error) {
- if (idec->state_ == STATE_VP8_DATA) {
- // Synchronize the thread, clean-up and check for errors.
- VP8ExitCritical((VP8Decoder*)idec->dec_, &idec->io_);
- }
- idec->state_ = STATE_ERROR;
- return error;
-}
-
-static void ChangeState(WebPIDecoder* const idec, DecState new_state,
- size_t consumed_bytes) {
- MemBuffer* const mem = &idec->mem_;
- idec->state_ = new_state;
- mem->start_ += consumed_bytes;
- assert(mem->start_ <= mem->end_);
- idec->io_.data = mem->buf_ + mem->start_;
- idec->io_.data_size = MemDataSize(mem);
-}
-
-// Headers
-static VP8StatusCode DecodeWebPHeaders(WebPIDecoder* const idec) {
- MemBuffer* const mem = &idec->mem_;
- const uint8_t* data = mem->buf_ + mem->start_;
- size_t curr_size = MemDataSize(mem);
- VP8StatusCode status;
- WebPHeaderStructure headers;
-
- headers.data = data;
- headers.data_size = curr_size;
- headers.have_all_data = 0;
- status = WebPParseHeaders(&headers);
- if (status == VP8_STATUS_NOT_ENOUGH_DATA) {
- return VP8_STATUS_SUSPENDED; // We haven't found a VP8 chunk yet.
- } else if (status != VP8_STATUS_OK) {
- return IDecError(idec, status);
- }
-
- idec->chunk_size_ = headers.compressed_size;
- idec->is_lossless_ = headers.is_lossless;
- if (!idec->is_lossless_) {
- VP8Decoder* const dec = VP8New();
- if (dec == NULL) {
- return VP8_STATUS_OUT_OF_MEMORY;
- }
- idec->dec_ = dec;
- dec->alpha_data_ = headers.alpha_data;
- dec->alpha_data_size_ = headers.alpha_data_size;
- ChangeState(idec, STATE_VP8_HEADER, headers.offset);
- } else {
- VP8LDecoder* const dec = VP8LNew();
- if (dec == NULL) {
- return VP8_STATUS_OUT_OF_MEMORY;
- }
- idec->dec_ = dec;
- ChangeState(idec, STATE_VP8L_HEADER, headers.offset);
- }
- return VP8_STATUS_OK;
-}
-
-static VP8StatusCode DecodeVP8FrameHeader(WebPIDecoder* const idec) {
- const uint8_t* data = idec->mem_.buf_ + idec->mem_.start_;
- const size_t curr_size = MemDataSize(&idec->mem_);
- int width, height;
- uint32_t bits;
-
- if (curr_size < VP8_FRAME_HEADER_SIZE) {
- // Not enough data bytes to extract VP8 Frame Header.
- return VP8_STATUS_SUSPENDED;
- }
- if (!VP8GetInfo(data, curr_size, idec->chunk_size_, &width, &height)) {
- return IDecError(idec, VP8_STATUS_BITSTREAM_ERROR);
- }
-
- bits = data[0] | (data[1] << 8) | (data[2] << 16);
- idec->mem_.part0_size_ = (bits >> 5) + VP8_FRAME_HEADER_SIZE;
-
- idec->io_.data = data;
- idec->io_.data_size = curr_size;
- idec->state_ = STATE_VP8_PARTS0;
- return VP8_STATUS_OK;
-}
-
-// Partition #0
-static VP8StatusCode CopyParts0Data(WebPIDecoder* const idec) {
- VP8Decoder* const dec = (VP8Decoder*)idec->dec_;
- VP8BitReader* const br = &dec->br_;
- const size_t part_size = br->buf_end_ - br->buf_;
- MemBuffer* const mem = &idec->mem_;
- assert(!idec->is_lossless_);
- assert(mem->part0_buf_ == NULL);
- // the following is a format limitation, no need for runtime check:
- assert(part_size <= mem->part0_size_);
- if (part_size == 0) { // can't have zero-size partition #0
- return VP8_STATUS_BITSTREAM_ERROR;
- }
- if (mem->mode_ == MEM_MODE_APPEND) {
- // We copy and grab ownership of the partition #0 data.
- uint8_t* const part0_buf = (uint8_t*)WebPSafeMalloc(1ULL, part_size);
- if (part0_buf == NULL) {
- return VP8_STATUS_OUT_OF_MEMORY;
- }
- memcpy(part0_buf, br->buf_, part_size);
- mem->part0_buf_ = part0_buf;
- VP8BitReaderSetBuffer(br, part0_buf, part_size);
- } else {
- // Else: just keep pointers to the partition #0's data in dec_->br_.
- }
- mem->start_ += part_size;
- return VP8_STATUS_OK;
-}
-
-static VP8StatusCode DecodePartition0(WebPIDecoder* const idec) {
- VP8Decoder* const dec = (VP8Decoder*)idec->dec_;
- VP8Io* const io = &idec->io_;
- const WebPDecParams* const params = &idec->params_;
- WebPDecBuffer* const output = params->output;
-
- // Wait till we have enough data for the whole partition #0
- if (MemDataSize(&idec->mem_) < idec->mem_.part0_size_) {
- return VP8_STATUS_SUSPENDED;
- }
-
- if (!VP8GetHeaders(dec, io)) {
- const VP8StatusCode status = dec->status_;
- if (status == VP8_STATUS_SUSPENDED ||
- status == VP8_STATUS_NOT_ENOUGH_DATA) {
- // treating NOT_ENOUGH_DATA as SUSPENDED state
- return VP8_STATUS_SUSPENDED;
- }
- return IDecError(idec, status);
- }
-
- // Allocate/Verify output buffer now
- dec->status_ = WebPAllocateDecBuffer(io->width, io->height, params->options,
- output);
- if (dec->status_ != VP8_STATUS_OK) {
- return IDecError(idec, dec->status_);
- }
- // This change must be done before calling VP8InitFrame()
- dec->mt_method_ = VP8GetThreadMethod(params->options, NULL,
- io->width, io->height);
- VP8InitDithering(params->options, dec);
-
- dec->status_ = CopyParts0Data(idec);
- if (dec->status_ != VP8_STATUS_OK) {
- return IDecError(idec, dec->status_);
- }
-
- // Finish setting up the decoding parameters. Will call io->setup().
- if (VP8EnterCritical(dec, io) != VP8_STATUS_OK) {
- return IDecError(idec, dec->status_);
- }
-
- // Note: past this point, teardown() must always be called
- // in case of error.
- idec->state_ = STATE_VP8_DATA;
- // Allocate memory and prepare everything.
- if (!VP8InitFrame(dec, io)) {
- return IDecError(idec, dec->status_);
- }
- return VP8_STATUS_OK;
-}
-
-// Remaining partitions
-static VP8StatusCode DecodeRemaining(WebPIDecoder* const idec) {
- VP8Decoder* const dec = (VP8Decoder*)idec->dec_;
- VP8Io* const io = &idec->io_;
-
- // Make sure partition #0 has been read before, to set dec to ready_.
- if (!dec->ready_) {
- return IDecError(idec, VP8_STATUS_BITSTREAM_ERROR);
- }
- for (; dec->mb_y_ < dec->mb_h_; ++dec->mb_y_) {
- if (idec->last_mb_y_ != dec->mb_y_) {
- if (!VP8ParseIntraModeRow(&dec->br_, dec)) {
- // note: normally, error shouldn't occur since we already have the whole
- // partition0 available here in DecodeRemaining(). Reaching EOF while
- // reading intra modes really means a BITSTREAM_ERROR.
- return IDecError(idec, VP8_STATUS_BITSTREAM_ERROR);
- }
- idec->last_mb_y_ = dec->mb_y_;
- }
- for (; dec->mb_x_ < dec->mb_w_; ++dec->mb_x_) {
- VP8BitReader* const token_br =
- &dec->parts_[dec->mb_y_ & dec->num_parts_minus_one_];
- MBContext context;
- SaveContext(dec, token_br, &context);
- if (!VP8DecodeMB(dec, token_br)) {
- // We shouldn't fail when MAX_MB data was available
- if (dec->num_parts_minus_one_ == 0 &&
- MemDataSize(&idec->mem_) > MAX_MB_SIZE) {
- return IDecError(idec, VP8_STATUS_BITSTREAM_ERROR);
- }
- // Synchronize the threads.
- if (dec->mt_method_ > 0) {
- if (!WebPGetWorkerInterface()->Sync(&dec->worker_)) {
- return IDecError(idec, VP8_STATUS_BITSTREAM_ERROR);
- }
- }
- RestoreContext(&context, dec, token_br);
- return VP8_STATUS_SUSPENDED;
- }
- // Release buffer only if there is only one partition
- if (dec->num_parts_minus_one_ == 0) {
- idec->mem_.start_ = token_br->buf_ - idec->mem_.buf_;
- assert(idec->mem_.start_ <= idec->mem_.end_);
- }
- }
- VP8InitScanline(dec); // Prepare for next scanline
-
- // Reconstruct, filter and emit the row.
- if (!VP8ProcessRow(dec, io)) {
- return IDecError(idec, VP8_STATUS_USER_ABORT);
- }
- }
- // Synchronize the thread and check for errors.
- if (!VP8ExitCritical(dec, io)) {
- idec->state_ = STATE_ERROR; // prevent re-entry in IDecError
- return IDecError(idec, VP8_STATUS_USER_ABORT);
- }
- dec->ready_ = 0;
- return FinishDecoding(idec);
-}
-
-static VP8StatusCode ErrorStatusLossless(WebPIDecoder* const idec,
- VP8StatusCode status) {
- if (status == VP8_STATUS_SUSPENDED || status == VP8_STATUS_NOT_ENOUGH_DATA) {
- return VP8_STATUS_SUSPENDED;
- }
- return IDecError(idec, status);
-}
-
-static VP8StatusCode DecodeVP8LHeader(WebPIDecoder* const idec) {
- VP8Io* const io = &idec->io_;
- VP8LDecoder* const dec = (VP8LDecoder*)idec->dec_;
- const WebPDecParams* const params = &idec->params_;
- WebPDecBuffer* const output = params->output;
- size_t curr_size = MemDataSize(&idec->mem_);
- assert(idec->is_lossless_);
-
- // Wait until there's enough data for decoding header.
- if (curr_size < (idec->chunk_size_ >> 3)) {
- dec->status_ = VP8_STATUS_SUSPENDED;
- return ErrorStatusLossless(idec, dec->status_);
- }
-
- if (!VP8LDecodeHeader(dec, io)) {
- if (dec->status_ == VP8_STATUS_BITSTREAM_ERROR &&
- curr_size < idec->chunk_size_) {
- dec->status_ = VP8_STATUS_SUSPENDED;
- }
- return ErrorStatusLossless(idec, dec->status_);
- }
- // Allocate/verify output buffer now.
- dec->status_ = WebPAllocateDecBuffer(io->width, io->height, params->options,
- output);
- if (dec->status_ != VP8_STATUS_OK) {
- return IDecError(idec, dec->status_);
- }
-
- idec->state_ = STATE_VP8L_DATA;
- return VP8_STATUS_OK;
-}
-
-static VP8StatusCode DecodeVP8LData(WebPIDecoder* const idec) {
- VP8LDecoder* const dec = (VP8LDecoder*)idec->dec_;
- const size_t curr_size = MemDataSize(&idec->mem_);
- assert(idec->is_lossless_);
-
- // Switch to incremental decoding if we don't have all the bytes available.
- dec->incremental_ = (curr_size < idec->chunk_size_);
-
- if (!VP8LDecodeImage(dec)) {
- return ErrorStatusLossless(idec, dec->status_);
- }
- assert(dec->status_ == VP8_STATUS_OK || dec->status_ == VP8_STATUS_SUSPENDED);
- return (dec->status_ == VP8_STATUS_SUSPENDED) ? dec->status_
- : FinishDecoding(idec);
-}
-
- // Main decoding loop
-static VP8StatusCode IDecode(WebPIDecoder* idec) {
- VP8StatusCode status = VP8_STATUS_SUSPENDED;
-
- if (idec->state_ == STATE_WEBP_HEADER) {
- status = DecodeWebPHeaders(idec);
- } else {
- if (idec->dec_ == NULL) {
- return VP8_STATUS_SUSPENDED; // can't continue if we have no decoder.
- }
- }
- if (idec->state_ == STATE_VP8_HEADER) {
- status = DecodeVP8FrameHeader(idec);
- }
- if (idec->state_ == STATE_VP8_PARTS0) {
- status = DecodePartition0(idec);
- }
- if (idec->state_ == STATE_VP8_DATA) {
- const VP8Decoder* const dec = (VP8Decoder*)idec->dec_;
- if (dec == NULL) {
- return VP8_STATUS_SUSPENDED; // can't continue if we have no decoder.
- }
- status = DecodeRemaining(idec);
- }
- if (idec->state_ == STATE_VP8L_HEADER) {
- status = DecodeVP8LHeader(idec);
- }
- if (idec->state_ == STATE_VP8L_DATA) {
- status = DecodeVP8LData(idec);
- }
- return status;
-}
-
-//------------------------------------------------------------------------------
-// Internal constructor
-
-static WebPIDecoder* NewDecoder(WebPDecBuffer* const output_buffer,
- const WebPBitstreamFeatures* const features) {
- WebPIDecoder* idec = (WebPIDecoder*)WebPSafeCalloc(1ULL, sizeof(*idec));
- if (idec == NULL) {
- return NULL;
- }
-
- idec->state_ = STATE_WEBP_HEADER;
- idec->chunk_size_ = 0;
-
- idec->last_mb_y_ = -1;
-
- InitMemBuffer(&idec->mem_);
- WebPInitDecBuffer(&idec->output_);
- VP8InitIo(&idec->io_);
-
- WebPResetDecParams(&idec->params_);
- if (output_buffer == NULL || WebPAvoidSlowMemory(output_buffer, features)) {
- idec->params_.output = &idec->output_;
- idec->final_output_ = output_buffer;
- if (output_buffer != NULL) {
- idec->params_.output->colorspace = output_buffer->colorspace;
- }
- } else {
- idec->params_.output = output_buffer;
- idec->final_output_ = NULL;
- }
- WebPInitCustomIo(&idec->params_, &idec->io_); // Plug the I/O functions.
-
- return idec;
-}
-
-//------------------------------------------------------------------------------
-// Public functions
-
-WebPIDecoder* WebPINewDecoder(WebPDecBuffer* output_buffer) {
- return NewDecoder(output_buffer, NULL);
-}
-
-WebPIDecoder* WebPIDecode(const uint8_t* data, size_t data_size,
- WebPDecoderConfig* config) {
- WebPIDecoder* idec;
- WebPBitstreamFeatures tmp_features;
- WebPBitstreamFeatures* const features =
- (config == NULL) ? &tmp_features : &config->input;
- memset(&tmp_features, 0, sizeof(tmp_features));
-
- // Parse the bitstream's features, if requested:
- if (data != NULL && data_size > 0) {
- if (WebPGetFeatures(data, data_size, features) != VP8_STATUS_OK) {
- return NULL;
- }
- }
-
- // Create an instance of the incremental decoder
- idec = (config != NULL) ? NewDecoder(&config->output, features)
- : NewDecoder(NULL, features);
- if (idec == NULL) {
- return NULL;
- }
- // Finish initialization
- if (config != NULL) {
- idec->params_.options = &config->options;
- }
- return idec;
-}
-
-void WebPIDelete(WebPIDecoder* idec) {
- if (idec == NULL) return;
- if (idec->dec_ != NULL) {
- if (!idec->is_lossless_) {
- if (idec->state_ == STATE_VP8_DATA) {
- // Synchronize the thread, clean-up and check for errors.
- VP8ExitCritical((VP8Decoder*)idec->dec_, &idec->io_);
- }
- VP8Delete((VP8Decoder*)idec->dec_);
- } else {
- VP8LDelete((VP8LDecoder*)idec->dec_);
- }
- }
- ClearMemBuffer(&idec->mem_);
- WebPFreeDecBuffer(&idec->output_);
- WebPSafeFree(idec);
-}
-
-//------------------------------------------------------------------------------
-// Wrapper toward WebPINewDecoder
-
-WebPIDecoder* WebPINewRGB(WEBP_CSP_MODE csp, uint8_t* output_buffer,
- size_t output_buffer_size, int output_stride) {
- const int is_external_memory = (output_buffer != NULL) ? 1 : 0;
- WebPIDecoder* idec;
-
- if (csp >= MODE_YUV) return NULL;
- if (is_external_memory == 0) { // Overwrite parameters to sane values.
- output_buffer_size = 0;
- output_stride = 0;
- } else { // A buffer was passed. Validate the other params.
- if (output_stride == 0 || output_buffer_size == 0) {
- return NULL; // invalid parameter.
- }
- }
- idec = WebPINewDecoder(NULL);
- if (idec == NULL) return NULL;
- idec->output_.colorspace = csp;
- idec->output_.is_external_memory = is_external_memory;
- idec->output_.u.RGBA.rgba = output_buffer;
- idec->output_.u.RGBA.stride = output_stride;
- idec->output_.u.RGBA.size = output_buffer_size;
- return idec;
-}
-
-WebPIDecoder* WebPINewYUVA(uint8_t* luma, size_t luma_size, int luma_stride,
- uint8_t* u, size_t u_size, int u_stride,
- uint8_t* v, size_t v_size, int v_stride,
- uint8_t* a, size_t a_size, int a_stride) {
- const int is_external_memory = (luma != NULL) ? 1 : 0;
- WebPIDecoder* idec;
- WEBP_CSP_MODE colorspace;
-
- if (is_external_memory == 0) { // Overwrite parameters to sane values.
- luma_size = u_size = v_size = a_size = 0;
- luma_stride = u_stride = v_stride = a_stride = 0;
- u = v = a = NULL;
- colorspace = MODE_YUVA;
- } else { // A luma buffer was passed. Validate the other parameters.
- if (u == NULL || v == NULL) return NULL;
- if (luma_size == 0 || u_size == 0 || v_size == 0) return NULL;
- if (luma_stride == 0 || u_stride == 0 || v_stride == 0) return NULL;
- if (a != NULL) {
- if (a_size == 0 || a_stride == 0) return NULL;
- }
- colorspace = (a == NULL) ? MODE_YUV : MODE_YUVA;
- }
-
- idec = WebPINewDecoder(NULL);
- if (idec == NULL) return NULL;
-
- idec->output_.colorspace = colorspace;
- idec->output_.is_external_memory = is_external_memory;
- idec->output_.u.YUVA.y = luma;
- idec->output_.u.YUVA.y_stride = luma_stride;
- idec->output_.u.YUVA.y_size = luma_size;
- idec->output_.u.YUVA.u = u;
- idec->output_.u.YUVA.u_stride = u_stride;
- idec->output_.u.YUVA.u_size = u_size;
- idec->output_.u.YUVA.v = v;
- idec->output_.u.YUVA.v_stride = v_stride;
- idec->output_.u.YUVA.v_size = v_size;
- idec->output_.u.YUVA.a = a;
- idec->output_.u.YUVA.a_stride = a_stride;
- idec->output_.u.YUVA.a_size = a_size;
- return idec;
-}
-
-WebPIDecoder* WebPINewYUV(uint8_t* luma, size_t luma_size, int luma_stride,
- uint8_t* u, size_t u_size, int u_stride,
- uint8_t* v, size_t v_size, int v_stride) {
- return WebPINewYUVA(luma, luma_size, luma_stride,
- u, u_size, u_stride,
- v, v_size, v_stride,
- NULL, 0, 0);
-}
-
-//------------------------------------------------------------------------------
-
-static VP8StatusCode IDecCheckStatus(const WebPIDecoder* const idec) {
- assert(idec);
- if (idec->state_ == STATE_ERROR) {
- return VP8_STATUS_BITSTREAM_ERROR;
- }
- if (idec->state_ == STATE_DONE) {
- return VP8_STATUS_OK;
- }
- return VP8_STATUS_SUSPENDED;
-}
-
-VP8StatusCode WebPIAppend(WebPIDecoder* idec,
- const uint8_t* data, size_t data_size) {
- VP8StatusCode status;
- if (idec == NULL || data == NULL) {
- return VP8_STATUS_INVALID_PARAM;
- }
- status = IDecCheckStatus(idec);
- if (status != VP8_STATUS_SUSPENDED) {
- return status;
- }
- // Check mixed calls between RemapMemBuffer and AppendToMemBuffer.
- if (!CheckMemBufferMode(&idec->mem_, MEM_MODE_APPEND)) {
- return VP8_STATUS_INVALID_PARAM;
- }
- // Append data to memory buffer
- if (!AppendToMemBuffer(idec, data, data_size)) {
- return VP8_STATUS_OUT_OF_MEMORY;
- }
- return IDecode(idec);
-}
-
-VP8StatusCode WebPIUpdate(WebPIDecoder* idec,
- const uint8_t* data, size_t data_size) {
- VP8StatusCode status;
- if (idec == NULL || data == NULL) {
- return VP8_STATUS_INVALID_PARAM;
- }
- status = IDecCheckStatus(idec);
- if (status != VP8_STATUS_SUSPENDED) {
- return status;
- }
- // Check mixed calls between RemapMemBuffer and AppendToMemBuffer.
- if (!CheckMemBufferMode(&idec->mem_, MEM_MODE_MAP)) {
- return VP8_STATUS_INVALID_PARAM;
- }
- // Make the memory buffer point to the new buffer
- if (!RemapMemBuffer(idec, data, data_size)) {
- return VP8_STATUS_INVALID_PARAM;
- }
- return IDecode(idec);
-}
-
-//------------------------------------------------------------------------------
-
-static const WebPDecBuffer* GetOutputBuffer(const WebPIDecoder* const idec) {
- if (idec == NULL || idec->dec_ == NULL) {
- return NULL;
- }
- if (idec->state_ <= STATE_VP8_PARTS0) {
- return NULL;
- }
- if (idec->final_output_ != NULL) {
- return NULL; // not yet slow-copied
- }
- return idec->params_.output;
-}
-
-const WebPDecBuffer* WebPIDecodedArea(const WebPIDecoder* idec,
- int* left, int* top,
- int* width, int* height) {
- const WebPDecBuffer* const src = GetOutputBuffer(idec);
- if (left != NULL) *left = 0;
- if (top != NULL) *top = 0;
- if (src != NULL) {
- if (width != NULL) *width = src->width;
- if (height != NULL) *height = idec->params_.last_y;
- } else {
- if (width != NULL) *width = 0;
- if (height != NULL) *height = 0;
- }
- return src;
-}
-
-uint8_t* WebPIDecGetRGB(const WebPIDecoder* idec, int* last_y,
- int* width, int* height, int* stride) {
- const WebPDecBuffer* const src = GetOutputBuffer(idec);
- if (src == NULL) return NULL;
- if (src->colorspace >= MODE_YUV) {
- return NULL;
- }
-
- if (last_y != NULL) *last_y = idec->params_.last_y;
- if (width != NULL) *width = src->width;
- if (height != NULL) *height = src->height;
- if (stride != NULL) *stride = src->u.RGBA.stride;
-
- return src->u.RGBA.rgba;
-}
-
-uint8_t* WebPIDecGetYUVA(const WebPIDecoder* idec, int* last_y,
- uint8_t** u, uint8_t** v, uint8_t** a,
- int* width, int* height,
- int* stride, int* uv_stride, int* a_stride) {
- const WebPDecBuffer* const src = GetOutputBuffer(idec);
- if (src == NULL) return NULL;
- if (src->colorspace < MODE_YUV) {
- return NULL;
- }
-
- if (last_y != NULL) *last_y = idec->params_.last_y;
- if (u != NULL) *u = src->u.YUVA.u;
- if (v != NULL) *v = src->u.YUVA.v;
- if (a != NULL) *a = src->u.YUVA.a;
- if (width != NULL) *width = src->width;
- if (height != NULL) *height = src->height;
- if (stride != NULL) *stride = src->u.YUVA.y_stride;
- if (uv_stride != NULL) *uv_stride = src->u.YUVA.u_stride;
- if (a_stride != NULL) *a_stride = src->u.YUVA.a_stride;
-
- return src->u.YUVA.y;
-}
-
-int WebPISetIOHooks(WebPIDecoder* const idec,
- VP8IoPutHook put,
- VP8IoSetupHook setup,
- VP8IoTeardownHook teardown,
- void* user_data) {
- if (idec == NULL || idec->state_ > STATE_WEBP_HEADER) {
- return 0;
- }
-
- idec->io_.put = put;
- idec->io_.setup = setup;
- idec->io_.teardown = teardown;
- idec->io_.opaque = user_data;
-
- return 1;
-}
diff --git a/contrib/libs/libwebp/dec/io_dec.c b/contrib/libs/libwebp/dec/io_dec.c
deleted file mode 100644
index 50d55245fc..0000000000
--- a/contrib/libs/libwebp/dec/io_dec.c
+++ /dev/null
@@ -1,662 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// functions for sample output.
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include <assert.h>
-#include <stdlib.h>
-#include "./vp8i_dec.h"
-#include "./webpi_dec.h"
-#include "../dsp/dsp.h"
-#include "../dsp/yuv.h"
-#include "../utils/utils.h"
-
-//------------------------------------------------------------------------------
-// Main YUV<->RGB conversion functions
-
-static int EmitYUV(const VP8Io* const io, WebPDecParams* const p) {
- WebPDecBuffer* output = p->output;
- const WebPYUVABuffer* const buf = &output->u.YUVA;
- uint8_t* const y_dst = buf->y + (size_t)io->mb_y * buf->y_stride;
- uint8_t* const u_dst = buf->u + (size_t)(io->mb_y >> 1) * buf->u_stride;
- uint8_t* const v_dst = buf->v + (size_t)(io->mb_y >> 1) * buf->v_stride;
- const int mb_w = io->mb_w;
- const int mb_h = io->mb_h;
- const int uv_w = (mb_w + 1) / 2;
- const int uv_h = (mb_h + 1) / 2;
- WebPCopyPlane(io->y, io->y_stride, y_dst, buf->y_stride, mb_w, mb_h);
- WebPCopyPlane(io->u, io->uv_stride, u_dst, buf->u_stride, uv_w, uv_h);
- WebPCopyPlane(io->v, io->uv_stride, v_dst, buf->v_stride, uv_w, uv_h);
- return io->mb_h;
-}
-
-// Point-sampling U/V sampler.
-static int EmitSampledRGB(const VP8Io* const io, WebPDecParams* const p) {
- WebPDecBuffer* const output = p->output;
- WebPRGBABuffer* const buf = &output->u.RGBA;
- uint8_t* const dst = buf->rgba + (size_t)io->mb_y * buf->stride;
- WebPSamplerProcessPlane(io->y, io->y_stride,
- io->u, io->v, io->uv_stride,
- dst, buf->stride, io->mb_w, io->mb_h,
- WebPSamplers[output->colorspace]);
- return io->mb_h;
-}
-
-//------------------------------------------------------------------------------
-// Fancy upsampling
-
-#ifdef FANCY_UPSAMPLING
-static int EmitFancyRGB(const VP8Io* const io, WebPDecParams* const p) {
- int num_lines_out = io->mb_h; // a priori guess
- const WebPRGBABuffer* const buf = &p->output->u.RGBA;
- uint8_t* dst = buf->rgba + (size_t)io->mb_y * buf->stride;
- WebPUpsampleLinePairFunc upsample = WebPUpsamplers[p->output->colorspace];
- const uint8_t* cur_y = io->y;
- const uint8_t* cur_u = io->u;
- const uint8_t* cur_v = io->v;
- const uint8_t* top_u = p->tmp_u;
- const uint8_t* top_v = p->tmp_v;
- int y = io->mb_y;
- const int y_end = io->mb_y + io->mb_h;
- const int mb_w = io->mb_w;
- const int uv_w = (mb_w + 1) / 2;
-
- if (y == 0) {
- // First line is special cased. We mirror the u/v samples at boundary.
- upsample(cur_y, NULL, cur_u, cur_v, cur_u, cur_v, dst, NULL, mb_w);
- } else {
- // We can finish the left-over line from previous call.
- upsample(p->tmp_y, cur_y, top_u, top_v, cur_u, cur_v,
- dst - buf->stride, dst, mb_w);
- ++num_lines_out;
- }
- // Loop over each output pairs of row.
- for (; y + 2 < y_end; y += 2) {
- top_u = cur_u;
- top_v = cur_v;
- cur_u += io->uv_stride;
- cur_v += io->uv_stride;
- dst += 2 * buf->stride;
- cur_y += 2 * io->y_stride;
- upsample(cur_y - io->y_stride, cur_y,
- top_u, top_v, cur_u, cur_v,
- dst - buf->stride, dst, mb_w);
- }
- // move to last row
- cur_y += io->y_stride;
- if (io->crop_top + y_end < io->crop_bottom) {
- // Save the unfinished samples for next call (as we're not done yet).
- memcpy(p->tmp_y, cur_y, mb_w * sizeof(*p->tmp_y));
- memcpy(p->tmp_u, cur_u, uv_w * sizeof(*p->tmp_u));
- memcpy(p->tmp_v, cur_v, uv_w * sizeof(*p->tmp_v));
- // The fancy upsampler leaves a row unfinished behind
- // (except for the very last row)
- num_lines_out--;
- } else {
- // Process the very last row of even-sized picture
- if (!(y_end & 1)) {
- upsample(cur_y, NULL, cur_u, cur_v, cur_u, cur_v,
- dst + buf->stride, NULL, mb_w);
- }
- }
- return num_lines_out;
-}
-
-#endif /* FANCY_UPSAMPLING */
-
-//------------------------------------------------------------------------------
-
-static void FillAlphaPlane(uint8_t* dst, int w, int h, int stride) {
- int j;
- for (j = 0; j < h; ++j) {
- memset(dst, 0xff, w * sizeof(*dst));
- dst += stride;
- }
-}
-
-static int EmitAlphaYUV(const VP8Io* const io, WebPDecParams* const p,
- int expected_num_lines_out) {
- const uint8_t* alpha = io->a;
- const WebPYUVABuffer* const buf = &p->output->u.YUVA;
- const int mb_w = io->mb_w;
- const int mb_h = io->mb_h;
- uint8_t* dst = buf->a + (size_t)io->mb_y * buf->a_stride;
- int j;
- (void)expected_num_lines_out;
- assert(expected_num_lines_out == mb_h);
- if (alpha != NULL) {
- for (j = 0; j < mb_h; ++j) {
- memcpy(dst, alpha, mb_w * sizeof(*dst));
- alpha += io->width;
- dst += buf->a_stride;
- }
- } else if (buf->a != NULL) {
- // the user requested alpha, but there is none, set it to opaque.
- FillAlphaPlane(dst, mb_w, mb_h, buf->a_stride);
- }
- return 0;
-}
-
-static int GetAlphaSourceRow(const VP8Io* const io,
- const uint8_t** alpha, int* const num_rows) {
- int start_y = io->mb_y;
- *num_rows = io->mb_h;
-
- // Compensate for the 1-line delay of the fancy upscaler.
- // This is similar to EmitFancyRGB().
- if (io->fancy_upsampling) {
- if (start_y == 0) {
- // We don't process the last row yet. It'll be done during the next call.
- --*num_rows;
- } else {
- --start_y;
- // Fortunately, *alpha data is persistent, so we can go back
- // one row and finish alpha blending, now that the fancy upscaler
- // completed the YUV->RGB interpolation.
- *alpha -= io->width;
- }
- if (io->crop_top + io->mb_y + io->mb_h == io->crop_bottom) {
- // If it's the very last call, we process all the remaining rows!
- *num_rows = io->crop_bottom - io->crop_top - start_y;
- }
- }
- return start_y;
-}
-
-static int EmitAlphaRGB(const VP8Io* const io, WebPDecParams* const p,
- int expected_num_lines_out) {
- const uint8_t* alpha = io->a;
- if (alpha != NULL) {
- const int mb_w = io->mb_w;
- const WEBP_CSP_MODE colorspace = p->output->colorspace;
- const int alpha_first =
- (colorspace == MODE_ARGB || colorspace == MODE_Argb);
- const WebPRGBABuffer* const buf = &p->output->u.RGBA;
- int num_rows;
- const size_t start_y = GetAlphaSourceRow(io, &alpha, &num_rows);
- uint8_t* const base_rgba = buf->rgba + start_y * buf->stride;
- uint8_t* const dst = base_rgba + (alpha_first ? 0 : 3);
- const int has_alpha = WebPDispatchAlpha(alpha, io->width, mb_w,
- num_rows, dst, buf->stride);
- (void)expected_num_lines_out;
- assert(expected_num_lines_out == num_rows);
- // has_alpha is true if there's non-trivial alpha to premultiply with.
- if (has_alpha && WebPIsPremultipliedMode(colorspace)) {
- WebPApplyAlphaMultiply(base_rgba, alpha_first,
- mb_w, num_rows, buf->stride);
- }
- }
- return 0;
-}
-
-static int EmitAlphaRGBA4444(const VP8Io* const io, WebPDecParams* const p,
- int expected_num_lines_out) {
- const uint8_t* alpha = io->a;
- if (alpha != NULL) {
- const int mb_w = io->mb_w;
- const WEBP_CSP_MODE colorspace = p->output->colorspace;
- const WebPRGBABuffer* const buf = &p->output->u.RGBA;
- int num_rows;
- const size_t start_y = GetAlphaSourceRow(io, &alpha, &num_rows);
- uint8_t* const base_rgba = buf->rgba + start_y * buf->stride;
-#if (WEBP_SWAP_16BIT_CSP == 1)
- uint8_t* alpha_dst = base_rgba;
-#else
- uint8_t* alpha_dst = base_rgba + 1;
-#endif
- uint32_t alpha_mask = 0x0f;
- int i, j;
- for (j = 0; j < num_rows; ++j) {
- for (i = 0; i < mb_w; ++i) {
- // Fill in the alpha value (converted to 4 bits).
- const uint32_t alpha_value = alpha[i] >> 4;
- alpha_dst[2 * i] = (alpha_dst[2 * i] & 0xf0) | alpha_value;
- alpha_mask &= alpha_value;
- }
- alpha += io->width;
- alpha_dst += buf->stride;
- }
- (void)expected_num_lines_out;
- assert(expected_num_lines_out == num_rows);
- if (alpha_mask != 0x0f && WebPIsPremultipliedMode(colorspace)) {
- WebPApplyAlphaMultiply4444(base_rgba, mb_w, num_rows, buf->stride);
- }
- }
- return 0;
-}
-
-//------------------------------------------------------------------------------
-// YUV rescaling (no final RGB conversion needed)
-
-#if !defined(WEBP_REDUCE_SIZE)
-static int Rescale(const uint8_t* src, int src_stride,
- int new_lines, WebPRescaler* const wrk) {
- int num_lines_out = 0;
- while (new_lines > 0) { // import new contributions of source rows.
- const int lines_in = WebPRescalerImport(wrk, new_lines, src, src_stride);
- src += lines_in * src_stride;
- new_lines -= lines_in;
- num_lines_out += WebPRescalerExport(wrk); // emit output row(s)
- }
- return num_lines_out;
-}
-
-static int EmitRescaledYUV(const VP8Io* const io, WebPDecParams* const p) {
- const int mb_h = io->mb_h;
- const int uv_mb_h = (mb_h + 1) >> 1;
- WebPRescaler* const scaler = p->scaler_y;
- int num_lines_out = 0;
- if (WebPIsAlphaMode(p->output->colorspace) && io->a != NULL) {
- // Before rescaling, we premultiply the luma directly into the io->y
- // internal buffer. This is OK since these samples are not used for
- // intra-prediction (the top samples are saved in cache_y_/u_/v_).
- // But we need to cast the const away, though.
- WebPMultRows((uint8_t*)io->y, io->y_stride,
- io->a, io->width, io->mb_w, mb_h, 0);
- }
- num_lines_out = Rescale(io->y, io->y_stride, mb_h, scaler);
- Rescale(io->u, io->uv_stride, uv_mb_h, p->scaler_u);
- Rescale(io->v, io->uv_stride, uv_mb_h, p->scaler_v);
- return num_lines_out;
-}
-
-static int EmitRescaledAlphaYUV(const VP8Io* const io, WebPDecParams* const p,
- int expected_num_lines_out) {
- const WebPYUVABuffer* const buf = &p->output->u.YUVA;
- uint8_t* const dst_a = buf->a + (size_t)p->last_y * buf->a_stride;
- if (io->a != NULL) {
- uint8_t* const dst_y = buf->y + (size_t)p->last_y * buf->y_stride;
- const int num_lines_out = Rescale(io->a, io->width, io->mb_h, p->scaler_a);
- assert(expected_num_lines_out == num_lines_out);
- if (num_lines_out > 0) { // unmultiply the Y
- WebPMultRows(dst_y, buf->y_stride, dst_a, buf->a_stride,
- p->scaler_a->dst_width, num_lines_out, 1);
- }
- } else if (buf->a != NULL) {
- // the user requested alpha, but there is none, set it to opaque.
- assert(p->last_y + expected_num_lines_out <= io->scaled_height);
- FillAlphaPlane(dst_a, io->scaled_width, expected_num_lines_out,
- buf->a_stride);
- }
- return 0;
-}
-
-static int InitYUVRescaler(const VP8Io* const io, WebPDecParams* const p) {
- const int has_alpha = WebPIsAlphaMode(p->output->colorspace);
- const WebPYUVABuffer* const buf = &p->output->u.YUVA;
- const int out_width = io->scaled_width;
- const int out_height = io->scaled_height;
- const int uv_out_width = (out_width + 1) >> 1;
- const int uv_out_height = (out_height + 1) >> 1;
- const int uv_in_width = (io->mb_w + 1) >> 1;
- const int uv_in_height = (io->mb_h + 1) >> 1;
- // scratch memory for luma rescaler
- const size_t work_size = 2 * (size_t)out_width;
- const size_t uv_work_size = 2 * uv_out_width; // and for each u/v ones
- uint64_t total_size;
- size_t rescaler_size;
- rescaler_t* work;
- WebPRescaler* scalers;
- const int num_rescalers = has_alpha ? 4 : 3;
-
- total_size = ((uint64_t)work_size + 2 * uv_work_size) * sizeof(*work);
- if (has_alpha) {
- total_size += (uint64_t)work_size * sizeof(*work);
- }
- rescaler_size = num_rescalers * sizeof(*p->scaler_y) + WEBP_ALIGN_CST;
- total_size += rescaler_size;
- if (!CheckSizeOverflow(total_size)) {
- return 0;
- }
-
- p->memory = WebPSafeMalloc(1ULL, (size_t)total_size);
- if (p->memory == NULL) {
- return 0; // memory error
- }
- work = (rescaler_t*)p->memory;
-
- scalers = (WebPRescaler*)WEBP_ALIGN(
- (const uint8_t*)work + total_size - rescaler_size);
- p->scaler_y = &scalers[0];
- p->scaler_u = &scalers[1];
- p->scaler_v = &scalers[2];
- p->scaler_a = has_alpha ? &scalers[3] : NULL;
-
- if (!WebPRescalerInit(p->scaler_y, io->mb_w, io->mb_h,
- buf->y, out_width, out_height, buf->y_stride, 1,
- work) ||
- !WebPRescalerInit(p->scaler_u, uv_in_width, uv_in_height,
- buf->u, uv_out_width, uv_out_height, buf->u_stride, 1,
- work + work_size) ||
- !WebPRescalerInit(p->scaler_v, uv_in_width, uv_in_height,
- buf->v, uv_out_width, uv_out_height, buf->v_stride, 1,
- work + work_size + uv_work_size)) {
- return 0;
- }
- p->emit = EmitRescaledYUV;
-
- if (has_alpha) {
- if (!WebPRescalerInit(p->scaler_a, io->mb_w, io->mb_h,
- buf->a, out_width, out_height, buf->a_stride, 1,
- work + work_size + 2 * uv_work_size)) {
- return 0;
- }
- p->emit_alpha = EmitRescaledAlphaYUV;
- WebPInitAlphaProcessing();
- }
- return 1;
-}
-
-//------------------------------------------------------------------------------
-// RGBA rescaling
-
-static int ExportRGB(WebPDecParams* const p, int y_pos) {
- const WebPYUV444Converter convert =
- WebPYUV444Converters[p->output->colorspace];
- const WebPRGBABuffer* const buf = &p->output->u.RGBA;
- uint8_t* dst = buf->rgba + (size_t)y_pos * buf->stride;
- int num_lines_out = 0;
- // For RGB rescaling, because of the YUV420, current scan position
- // U/V can be +1/-1 line from the Y one. Hence the double test.
- while (WebPRescalerHasPendingOutput(p->scaler_y) &&
- WebPRescalerHasPendingOutput(p->scaler_u)) {
- assert(y_pos + num_lines_out < p->output->height);
- assert(p->scaler_u->y_accum == p->scaler_v->y_accum);
- WebPRescalerExportRow(p->scaler_y);
- WebPRescalerExportRow(p->scaler_u);
- WebPRescalerExportRow(p->scaler_v);
- convert(p->scaler_y->dst, p->scaler_u->dst, p->scaler_v->dst,
- dst, p->scaler_y->dst_width);
- dst += buf->stride;
- ++num_lines_out;
- }
- return num_lines_out;
-}
-
-static int EmitRescaledRGB(const VP8Io* const io, WebPDecParams* const p) {
- const int mb_h = io->mb_h;
- const int uv_mb_h = (mb_h + 1) >> 1;
- int j = 0, uv_j = 0;
- int num_lines_out = 0;
- while (j < mb_h) {
- const int y_lines_in =
- WebPRescalerImport(p->scaler_y, mb_h - j,
- io->y + (size_t)j * io->y_stride, io->y_stride);
- j += y_lines_in;
- if (WebPRescaleNeededLines(p->scaler_u, uv_mb_h - uv_j)) {
- const int u_lines_in = WebPRescalerImport(
- p->scaler_u, uv_mb_h - uv_j, io->u + (size_t)uv_j * io->uv_stride,
- io->uv_stride);
- const int v_lines_in = WebPRescalerImport(
- p->scaler_v, uv_mb_h - uv_j, io->v + (size_t)uv_j * io->uv_stride,
- io->uv_stride);
- (void)v_lines_in; // remove a gcc warning
- assert(u_lines_in == v_lines_in);
- uv_j += u_lines_in;
- }
- num_lines_out += ExportRGB(p, p->last_y + num_lines_out);
- }
- return num_lines_out;
-}
-
-static int ExportAlpha(WebPDecParams* const p, int y_pos, int max_lines_out) {
- const WebPRGBABuffer* const buf = &p->output->u.RGBA;
- uint8_t* const base_rgba = buf->rgba + (size_t)y_pos * buf->stride;
- const WEBP_CSP_MODE colorspace = p->output->colorspace;
- const int alpha_first =
- (colorspace == MODE_ARGB || colorspace == MODE_Argb);
- uint8_t* dst = base_rgba + (alpha_first ? 0 : 3);
- int num_lines_out = 0;
- const int is_premult_alpha = WebPIsPremultipliedMode(colorspace);
- uint32_t non_opaque = 0;
- const int width = p->scaler_a->dst_width;
-
- while (WebPRescalerHasPendingOutput(p->scaler_a) &&
- num_lines_out < max_lines_out) {
- assert(y_pos + num_lines_out < p->output->height);
- WebPRescalerExportRow(p->scaler_a);
- non_opaque |= WebPDispatchAlpha(p->scaler_a->dst, 0, width, 1, dst, 0);
- dst += buf->stride;
- ++num_lines_out;
- }
- if (is_premult_alpha && non_opaque) {
- WebPApplyAlphaMultiply(base_rgba, alpha_first,
- width, num_lines_out, buf->stride);
- }
- return num_lines_out;
-}
-
-static int ExportAlphaRGBA4444(WebPDecParams* const p, int y_pos,
- int max_lines_out) {
- const WebPRGBABuffer* const buf = &p->output->u.RGBA;
- uint8_t* const base_rgba = buf->rgba + (size_t)y_pos * buf->stride;
-#if (WEBP_SWAP_16BIT_CSP == 1)
- uint8_t* alpha_dst = base_rgba;
-#else
- uint8_t* alpha_dst = base_rgba + 1;
-#endif
- int num_lines_out = 0;
- const WEBP_CSP_MODE colorspace = p->output->colorspace;
- const int width = p->scaler_a->dst_width;
- const int is_premult_alpha = WebPIsPremultipliedMode(colorspace);
- uint32_t alpha_mask = 0x0f;
-
- while (WebPRescalerHasPendingOutput(p->scaler_a) &&
- num_lines_out < max_lines_out) {
- int i;
- assert(y_pos + num_lines_out < p->output->height);
- WebPRescalerExportRow(p->scaler_a);
- for (i = 0; i < width; ++i) {
- // Fill in the alpha value (converted to 4 bits).
- const uint32_t alpha_value = p->scaler_a->dst[i] >> 4;
- alpha_dst[2 * i] = (alpha_dst[2 * i] & 0xf0) | alpha_value;
- alpha_mask &= alpha_value;
- }
- alpha_dst += buf->stride;
- ++num_lines_out;
- }
- if (is_premult_alpha && alpha_mask != 0x0f) {
- WebPApplyAlphaMultiply4444(base_rgba, width, num_lines_out, buf->stride);
- }
- return num_lines_out;
-}
-
-static int EmitRescaledAlphaRGB(const VP8Io* const io, WebPDecParams* const p,
- int expected_num_out_lines) {
- if (io->a != NULL) {
- WebPRescaler* const scaler = p->scaler_a;
- int lines_left = expected_num_out_lines;
- const int y_end = p->last_y + lines_left;
- while (lines_left > 0) {
- const int64_t row_offset = (int64_t)scaler->src_y - io->mb_y;
- WebPRescalerImport(scaler, io->mb_h + io->mb_y - scaler->src_y,
- io->a + row_offset * io->width, io->width);
- lines_left -= p->emit_alpha_row(p, y_end - lines_left, lines_left);
- }
- }
- return 0;
-}
-
-static int InitRGBRescaler(const VP8Io* const io, WebPDecParams* const p) {
- const int has_alpha = WebPIsAlphaMode(p->output->colorspace);
- const int out_width = io->scaled_width;
- const int out_height = io->scaled_height;
- const int uv_in_width = (io->mb_w + 1) >> 1;
- const int uv_in_height = (io->mb_h + 1) >> 1;
- // scratch memory for one rescaler
- const size_t work_size = 2 * (size_t)out_width;
- rescaler_t* work; // rescalers work area
- uint8_t* tmp; // tmp storage for scaled YUV444 samples before RGB conversion
- uint64_t tmp_size1, tmp_size2, total_size;
- size_t rescaler_size;
- WebPRescaler* scalers;
- const int num_rescalers = has_alpha ? 4 : 3;
-
- tmp_size1 = (uint64_t)num_rescalers * work_size;
- tmp_size2 = (uint64_t)num_rescalers * out_width;
- total_size = tmp_size1 * sizeof(*work) + tmp_size2 * sizeof(*tmp);
- rescaler_size = num_rescalers * sizeof(*p->scaler_y) + WEBP_ALIGN_CST;
- total_size += rescaler_size;
- if (!CheckSizeOverflow(total_size)) {
- return 0;
- }
-
- p->memory = WebPSafeMalloc(1ULL, (size_t)total_size);
- if (p->memory == NULL) {
- return 0; // memory error
- }
- work = (rescaler_t*)p->memory;
- tmp = (uint8_t*)(work + tmp_size1);
-
- scalers = (WebPRescaler*)WEBP_ALIGN(
- (const uint8_t*)work + total_size - rescaler_size);
- p->scaler_y = &scalers[0];
- p->scaler_u = &scalers[1];
- p->scaler_v = &scalers[2];
- p->scaler_a = has_alpha ? &scalers[3] : NULL;
-
- if (!WebPRescalerInit(p->scaler_y, io->mb_w, io->mb_h,
- tmp + 0 * out_width, out_width, out_height, 0, 1,
- work + 0 * work_size) ||
- !WebPRescalerInit(p->scaler_u, uv_in_width, uv_in_height,
- tmp + 1 * out_width, out_width, out_height, 0, 1,
- work + 1 * work_size) ||
- !WebPRescalerInit(p->scaler_v, uv_in_width, uv_in_height,
- tmp + 2 * out_width, out_width, out_height, 0, 1,
- work + 2 * work_size)) {
- return 0;
- }
- p->emit = EmitRescaledRGB;
- WebPInitYUV444Converters();
-
- if (has_alpha) {
- if (!WebPRescalerInit(p->scaler_a, io->mb_w, io->mb_h,
- tmp + 3 * out_width, out_width, out_height, 0, 1,
- work + 3 * work_size)) {
- return 0;
- }
- p->emit_alpha = EmitRescaledAlphaRGB;
- if (p->output->colorspace == MODE_RGBA_4444 ||
- p->output->colorspace == MODE_rgbA_4444) {
- p->emit_alpha_row = ExportAlphaRGBA4444;
- } else {
- p->emit_alpha_row = ExportAlpha;
- }
- WebPInitAlphaProcessing();
- }
- return 1;
-}
-
-#endif // WEBP_REDUCE_SIZE
-
-//------------------------------------------------------------------------------
-// Default custom functions
-
-static int CustomSetup(VP8Io* io) {
- WebPDecParams* const p = (WebPDecParams*)io->opaque;
- const WEBP_CSP_MODE colorspace = p->output->colorspace;
- const int is_rgb = WebPIsRGBMode(colorspace);
- const int is_alpha = WebPIsAlphaMode(colorspace);
-
- p->memory = NULL;
- p->emit = NULL;
- p->emit_alpha = NULL;
- p->emit_alpha_row = NULL;
- if (!WebPIoInitFromOptions(p->options, io, is_alpha ? MODE_YUV : MODE_YUVA)) {
- return 0;
- }
- if (is_alpha && WebPIsPremultipliedMode(colorspace)) {
- WebPInitUpsamplers();
- }
- if (io->use_scaling) {
-#if !defined(WEBP_REDUCE_SIZE)
- const int ok = is_rgb ? InitRGBRescaler(io, p) : InitYUVRescaler(io, p);
- if (!ok) {
- return 0; // memory error
- }
-#else
- return 0; // rescaling support not compiled
-#endif
- } else {
- if (is_rgb) {
- WebPInitSamplers();
- p->emit = EmitSampledRGB; // default
- if (io->fancy_upsampling) {
-#ifdef FANCY_UPSAMPLING
- const int uv_width = (io->mb_w + 1) >> 1;
- p->memory = WebPSafeMalloc(1ULL, (size_t)(io->mb_w + 2 * uv_width));
- if (p->memory == NULL) {
- return 0; // memory error.
- }
- p->tmp_y = (uint8_t*)p->memory;
- p->tmp_u = p->tmp_y + io->mb_w;
- p->tmp_v = p->tmp_u + uv_width;
- p->emit = EmitFancyRGB;
- WebPInitUpsamplers();
-#endif
- }
- } else {
- p->emit = EmitYUV;
- }
- if (is_alpha) { // need transparency output
- p->emit_alpha =
- (colorspace == MODE_RGBA_4444 || colorspace == MODE_rgbA_4444) ?
- EmitAlphaRGBA4444
- : is_rgb ? EmitAlphaRGB
- : EmitAlphaYUV;
- if (is_rgb) {
- WebPInitAlphaProcessing();
- }
- }
- }
-
- return 1;
-}
-
-//------------------------------------------------------------------------------
-
-static int CustomPut(const VP8Io* io) {
- WebPDecParams* const p = (WebPDecParams*)io->opaque;
- const int mb_w = io->mb_w;
- const int mb_h = io->mb_h;
- int num_lines_out;
- assert(!(io->mb_y & 1));
-
- if (mb_w <= 0 || mb_h <= 0) {
- return 0;
- }
- num_lines_out = p->emit(io, p);
- if (p->emit_alpha != NULL) {
- p->emit_alpha(io, p, num_lines_out);
- }
- p->last_y += num_lines_out;
- return 1;
-}
-
-//------------------------------------------------------------------------------
-
-static void CustomTeardown(const VP8Io* io) {
- WebPDecParams* const p = (WebPDecParams*)io->opaque;
- WebPSafeFree(p->memory);
- p->memory = NULL;
-}
-
-//------------------------------------------------------------------------------
-// Main entry point
-
-void WebPInitCustomIo(WebPDecParams* const params, VP8Io* const io) {
- io->put = CustomPut;
- io->setup = CustomSetup;
- io->teardown = CustomTeardown;
- io->opaque = params;
-}
-
-//------------------------------------------------------------------------------
diff --git a/contrib/libs/libwebp/dec/quant_dec.c b/contrib/libs/libwebp/dec/quant_dec.c
deleted file mode 100644
index 37032ad799..0000000000
--- a/contrib/libs/libwebp/dec/quant_dec.c
+++ /dev/null
@@ -1,115 +0,0 @@
-// Copyright 2010 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Quantizer initialization
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include "./vp8i_dec.h"
-
-static WEBP_INLINE int clip(int v, int M) {
- return v < 0 ? 0 : v > M ? M : v;
-}
-
-// Paragraph 14.1
-static const uint8_t kDcTable[128] = {
- 4, 5, 6, 7, 8, 9, 10, 10,
- 11, 12, 13, 14, 15, 16, 17, 17,
- 18, 19, 20, 20, 21, 21, 22, 22,
- 23, 23, 24, 25, 25, 26, 27, 28,
- 29, 30, 31, 32, 33, 34, 35, 36,
- 37, 37, 38, 39, 40, 41, 42, 43,
- 44, 45, 46, 46, 47, 48, 49, 50,
- 51, 52, 53, 54, 55, 56, 57, 58,
- 59, 60, 61, 62, 63, 64, 65, 66,
- 67, 68, 69, 70, 71, 72, 73, 74,
- 75, 76, 76, 77, 78, 79, 80, 81,
- 82, 83, 84, 85, 86, 87, 88, 89,
- 91, 93, 95, 96, 98, 100, 101, 102,
- 104, 106, 108, 110, 112, 114, 116, 118,
- 122, 124, 126, 128, 130, 132, 134, 136,
- 138, 140, 143, 145, 148, 151, 154, 157
-};
-
-static const uint16_t kAcTable[128] = {
- 4, 5, 6, 7, 8, 9, 10, 11,
- 12, 13, 14, 15, 16, 17, 18, 19,
- 20, 21, 22, 23, 24, 25, 26, 27,
- 28, 29, 30, 31, 32, 33, 34, 35,
- 36, 37, 38, 39, 40, 41, 42, 43,
- 44, 45, 46, 47, 48, 49, 50, 51,
- 52, 53, 54, 55, 56, 57, 58, 60,
- 62, 64, 66, 68, 70, 72, 74, 76,
- 78, 80, 82, 84, 86, 88, 90, 92,
- 94, 96, 98, 100, 102, 104, 106, 108,
- 110, 112, 114, 116, 119, 122, 125, 128,
- 131, 134, 137, 140, 143, 146, 149, 152,
- 155, 158, 161, 164, 167, 170, 173, 177,
- 181, 185, 189, 193, 197, 201, 205, 209,
- 213, 217, 221, 225, 229, 234, 239, 245,
- 249, 254, 259, 264, 269, 274, 279, 284
-};
-
-//------------------------------------------------------------------------------
-// Paragraph 9.6
-
-void VP8ParseQuant(VP8Decoder* const dec) {
- VP8BitReader* const br = &dec->br_;
- const int base_q0 = VP8GetValue(br, 7, "global-header");
- const int dqy1_dc = VP8Get(br, "global-header") ?
- VP8GetSignedValue(br, 4, "global-header") : 0;
- const int dqy2_dc = VP8Get(br, "global-header") ?
- VP8GetSignedValue(br, 4, "global-header") : 0;
- const int dqy2_ac = VP8Get(br, "global-header") ?
- VP8GetSignedValue(br, 4, "global-header") : 0;
- const int dquv_dc = VP8Get(br, "global-header") ?
- VP8GetSignedValue(br, 4, "global-header") : 0;
- const int dquv_ac = VP8Get(br, "global-header") ?
- VP8GetSignedValue(br, 4, "global-header") : 0;
-
- const VP8SegmentHeader* const hdr = &dec->segment_hdr_;
- int i;
-
- for (i = 0; i < NUM_MB_SEGMENTS; ++i) {
- int q;
- if (hdr->use_segment_) {
- q = hdr->quantizer_[i];
- if (!hdr->absolute_delta_) {
- q += base_q0;
- }
- } else {
- if (i > 0) {
- dec->dqm_[i] = dec->dqm_[0];
- continue;
- } else {
- q = base_q0;
- }
- }
- {
- VP8QuantMatrix* const m = &dec->dqm_[i];
- m->y1_mat_[0] = kDcTable[clip(q + dqy1_dc, 127)];
- m->y1_mat_[1] = kAcTable[clip(q + 0, 127)];
-
- m->y2_mat_[0] = kDcTable[clip(q + dqy2_dc, 127)] * 2;
- // For all x in [0..284], x*155/100 is bitwise equal to (x*101581) >> 16.
- // The smallest precision for that is '(x*6349) >> 12' but 16 is a good
- // word size.
- m->y2_mat_[1] = (kAcTable[clip(q + dqy2_ac, 127)] * 101581) >> 16;
- if (m->y2_mat_[1] < 8) m->y2_mat_[1] = 8;
-
- m->uv_mat_[0] = kDcTable[clip(q + dquv_dc, 117)];
- m->uv_mat_[1] = kAcTable[clip(q + dquv_ac, 127)];
-
- m->uv_quant_ = q + dquv_ac; // for dithering strength evaluation
- }
- }
-}
-
-//------------------------------------------------------------------------------
-
diff --git a/contrib/libs/libwebp/dec/tree_dec.c b/contrib/libs/libwebp/dec/tree_dec.c
deleted file mode 100644
index 7d609c2a28..0000000000
--- a/contrib/libs/libwebp/dec/tree_dec.c
+++ /dev/null
@@ -1,537 +0,0 @@
-// Copyright 2010 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Coding trees and probas
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include "./vp8i_dec.h"
-#include "../utils/bit_reader_inl_utils.h"
-
-#if !defined(USE_GENERIC_TREE)
-#if !defined(__arm__) && !defined(_M_ARM) && !defined(__aarch64__)
-// using a table is ~1-2% slower on ARM. Prefer the coded-tree approach then.
-#define USE_GENERIC_TREE 1 // ALTERNATE_CODE
-#else
-#define USE_GENERIC_TREE 0
-#endif
-#endif // USE_GENERIC_TREE
-
-#if (USE_GENERIC_TREE == 1)
-static const int8_t kYModesIntra4[18] = {
- -B_DC_PRED, 1,
- -B_TM_PRED, 2,
- -B_VE_PRED, 3,
- 4, 6,
- -B_HE_PRED, 5,
- -B_RD_PRED, -B_VR_PRED,
- -B_LD_PRED, 7,
- -B_VL_PRED, 8,
- -B_HD_PRED, -B_HU_PRED
-};
-#endif
-
-//------------------------------------------------------------------------------
-// Default probabilities
-
-// Paragraph 13.5
-static const uint8_t
- CoeffsProba0[NUM_TYPES][NUM_BANDS][NUM_CTX][NUM_PROBAS] = {
- { { { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 }
- },
- { { 253, 136, 254, 255, 228, 219, 128, 128, 128, 128, 128 },
- { 189, 129, 242, 255, 227, 213, 255, 219, 128, 128, 128 },
- { 106, 126, 227, 252, 214, 209, 255, 255, 128, 128, 128 }
- },
- { { 1, 98, 248, 255, 236, 226, 255, 255, 128, 128, 128 },
- { 181, 133, 238, 254, 221, 234, 255, 154, 128, 128, 128 },
- { 78, 134, 202, 247, 198, 180, 255, 219, 128, 128, 128 },
- },
- { { 1, 185, 249, 255, 243, 255, 128, 128, 128, 128, 128 },
- { 184, 150, 247, 255, 236, 224, 128, 128, 128, 128, 128 },
- { 77, 110, 216, 255, 236, 230, 128, 128, 128, 128, 128 },
- },
- { { 1, 101, 251, 255, 241, 255, 128, 128, 128, 128, 128 },
- { 170, 139, 241, 252, 236, 209, 255, 255, 128, 128, 128 },
- { 37, 116, 196, 243, 228, 255, 255, 255, 128, 128, 128 }
- },
- { { 1, 204, 254, 255, 245, 255, 128, 128, 128, 128, 128 },
- { 207, 160, 250, 255, 238, 128, 128, 128, 128, 128, 128 },
- { 102, 103, 231, 255, 211, 171, 128, 128, 128, 128, 128 }
- },
- { { 1, 152, 252, 255, 240, 255, 128, 128, 128, 128, 128 },
- { 177, 135, 243, 255, 234, 225, 128, 128, 128, 128, 128 },
- { 80, 129, 211, 255, 194, 224, 128, 128, 128, 128, 128 }
- },
- { { 1, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 246, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 255, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 }
- }
- },
- { { { 198, 35, 237, 223, 193, 187, 162, 160, 145, 155, 62 },
- { 131, 45, 198, 221, 172, 176, 220, 157, 252, 221, 1 },
- { 68, 47, 146, 208, 149, 167, 221, 162, 255, 223, 128 }
- },
- { { 1, 149, 241, 255, 221, 224, 255, 255, 128, 128, 128 },
- { 184, 141, 234, 253, 222, 220, 255, 199, 128, 128, 128 },
- { 81, 99, 181, 242, 176, 190, 249, 202, 255, 255, 128 }
- },
- { { 1, 129, 232, 253, 214, 197, 242, 196, 255, 255, 128 },
- { 99, 121, 210, 250, 201, 198, 255, 202, 128, 128, 128 },
- { 23, 91, 163, 242, 170, 187, 247, 210, 255, 255, 128 }
- },
- { { 1, 200, 246, 255, 234, 255, 128, 128, 128, 128, 128 },
- { 109, 178, 241, 255, 231, 245, 255, 255, 128, 128, 128 },
- { 44, 130, 201, 253, 205, 192, 255, 255, 128, 128, 128 }
- },
- { { 1, 132, 239, 251, 219, 209, 255, 165, 128, 128, 128 },
- { 94, 136, 225, 251, 218, 190, 255, 255, 128, 128, 128 },
- { 22, 100, 174, 245, 186, 161, 255, 199, 128, 128, 128 }
- },
- { { 1, 182, 249, 255, 232, 235, 128, 128, 128, 128, 128 },
- { 124, 143, 241, 255, 227, 234, 128, 128, 128, 128, 128 },
- { 35, 77, 181, 251, 193, 211, 255, 205, 128, 128, 128 }
- },
- { { 1, 157, 247, 255, 236, 231, 255, 255, 128, 128, 128 },
- { 121, 141, 235, 255, 225, 227, 255, 255, 128, 128, 128 },
- { 45, 99, 188, 251, 195, 217, 255, 224, 128, 128, 128 }
- },
- { { 1, 1, 251, 255, 213, 255, 128, 128, 128, 128, 128 },
- { 203, 1, 248, 255, 255, 128, 128, 128, 128, 128, 128 },
- { 137, 1, 177, 255, 224, 255, 128, 128, 128, 128, 128 }
- }
- },
- { { { 253, 9, 248, 251, 207, 208, 255, 192, 128, 128, 128 },
- { 175, 13, 224, 243, 193, 185, 249, 198, 255, 255, 128 },
- { 73, 17, 171, 221, 161, 179, 236, 167, 255, 234, 128 }
- },
- { { 1, 95, 247, 253, 212, 183, 255, 255, 128, 128, 128 },
- { 239, 90, 244, 250, 211, 209, 255, 255, 128, 128, 128 },
- { 155, 77, 195, 248, 188, 195, 255, 255, 128, 128, 128 }
- },
- { { 1, 24, 239, 251, 218, 219, 255, 205, 128, 128, 128 },
- { 201, 51, 219, 255, 196, 186, 128, 128, 128, 128, 128 },
- { 69, 46, 190, 239, 201, 218, 255, 228, 128, 128, 128 }
- },
- { { 1, 191, 251, 255, 255, 128, 128, 128, 128, 128, 128 },
- { 223, 165, 249, 255, 213, 255, 128, 128, 128, 128, 128 },
- { 141, 124, 248, 255, 255, 128, 128, 128, 128, 128, 128 }
- },
- { { 1, 16, 248, 255, 255, 128, 128, 128, 128, 128, 128 },
- { 190, 36, 230, 255, 236, 255, 128, 128, 128, 128, 128 },
- { 149, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 }
- },
- { { 1, 226, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 247, 192, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 240, 128, 255, 128, 128, 128, 128, 128, 128, 128, 128 }
- },
- { { 1, 134, 252, 255, 255, 128, 128, 128, 128, 128, 128 },
- { 213, 62, 250, 255, 255, 128, 128, 128, 128, 128, 128 },
- { 55, 93, 255, 128, 128, 128, 128, 128, 128, 128, 128 }
- },
- { { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 }
- }
- },
- { { { 202, 24, 213, 235, 186, 191, 220, 160, 240, 175, 255 },
- { 126, 38, 182, 232, 169, 184, 228, 174, 255, 187, 128 },
- { 61, 46, 138, 219, 151, 178, 240, 170, 255, 216, 128 }
- },
- { { 1, 112, 230, 250, 199, 191, 247, 159, 255, 255, 128 },
- { 166, 109, 228, 252, 211, 215, 255, 174, 128, 128, 128 },
- { 39, 77, 162, 232, 172, 180, 245, 178, 255, 255, 128 }
- },
- { { 1, 52, 220, 246, 198, 199, 249, 220, 255, 255, 128 },
- { 124, 74, 191, 243, 183, 193, 250, 221, 255, 255, 128 },
- { 24, 71, 130, 219, 154, 170, 243, 182, 255, 255, 128 }
- },
- { { 1, 182, 225, 249, 219, 240, 255, 224, 128, 128, 128 },
- { 149, 150, 226, 252, 216, 205, 255, 171, 128, 128, 128 },
- { 28, 108, 170, 242, 183, 194, 254, 223, 255, 255, 128 }
- },
- { { 1, 81, 230, 252, 204, 203, 255, 192, 128, 128, 128 },
- { 123, 102, 209, 247, 188, 196, 255, 233, 128, 128, 128 },
- { 20, 95, 153, 243, 164, 173, 255, 203, 128, 128, 128 }
- },
- { { 1, 222, 248, 255, 216, 213, 128, 128, 128, 128, 128 },
- { 168, 175, 246, 252, 235, 205, 255, 255, 128, 128, 128 },
- { 47, 116, 215, 255, 211, 212, 255, 255, 128, 128, 128 }
- },
- { { 1, 121, 236, 253, 212, 214, 255, 255, 128, 128, 128 },
- { 141, 84, 213, 252, 201, 202, 255, 219, 128, 128, 128 },
- { 42, 80, 160, 240, 162, 185, 255, 205, 128, 128, 128 }
- },
- { { 1, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 244, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 238, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 }
- }
- }
-};
-
-// Paragraph 11.5
-static const uint8_t kBModesProba[NUM_BMODES][NUM_BMODES][NUM_BMODES - 1] = {
- { { 231, 120, 48, 89, 115, 113, 120, 152, 112 },
- { 152, 179, 64, 126, 170, 118, 46, 70, 95 },
- { 175, 69, 143, 80, 85, 82, 72, 155, 103 },
- { 56, 58, 10, 171, 218, 189, 17, 13, 152 },
- { 114, 26, 17, 163, 44, 195, 21, 10, 173 },
- { 121, 24, 80, 195, 26, 62, 44, 64, 85 },
- { 144, 71, 10, 38, 171, 213, 144, 34, 26 },
- { 170, 46, 55, 19, 136, 160, 33, 206, 71 },
- { 63, 20, 8, 114, 114, 208, 12, 9, 226 },
- { 81, 40, 11, 96, 182, 84, 29, 16, 36 } },
- { { 134, 183, 89, 137, 98, 101, 106, 165, 148 },
- { 72, 187, 100, 130, 157, 111, 32, 75, 80 },
- { 66, 102, 167, 99, 74, 62, 40, 234, 128 },
- { 41, 53, 9, 178, 241, 141, 26, 8, 107 },
- { 74, 43, 26, 146, 73, 166, 49, 23, 157 },
- { 65, 38, 105, 160, 51, 52, 31, 115, 128 },
- { 104, 79, 12, 27, 217, 255, 87, 17, 7 },
- { 87, 68, 71, 44, 114, 51, 15, 186, 23 },
- { 47, 41, 14, 110, 182, 183, 21, 17, 194 },
- { 66, 45, 25, 102, 197, 189, 23, 18, 22 } },
- { { 88, 88, 147, 150, 42, 46, 45, 196, 205 },
- { 43, 97, 183, 117, 85, 38, 35, 179, 61 },
- { 39, 53, 200, 87, 26, 21, 43, 232, 171 },
- { 56, 34, 51, 104, 114, 102, 29, 93, 77 },
- { 39, 28, 85, 171, 58, 165, 90, 98, 64 },
- { 34, 22, 116, 206, 23, 34, 43, 166, 73 },
- { 107, 54, 32, 26, 51, 1, 81, 43, 31 },
- { 68, 25, 106, 22, 64, 171, 36, 225, 114 },
- { 34, 19, 21, 102, 132, 188, 16, 76, 124 },
- { 62, 18, 78, 95, 85, 57, 50, 48, 51 } },
- { { 193, 101, 35, 159, 215, 111, 89, 46, 111 },
- { 60, 148, 31, 172, 219, 228, 21, 18, 111 },
- { 112, 113, 77, 85, 179, 255, 38, 120, 114 },
- { 40, 42, 1, 196, 245, 209, 10, 25, 109 },
- { 88, 43, 29, 140, 166, 213, 37, 43, 154 },
- { 61, 63, 30, 155, 67, 45, 68, 1, 209 },
- { 100, 80, 8, 43, 154, 1, 51, 26, 71 },
- { 142, 78, 78, 16, 255, 128, 34, 197, 171 },
- { 41, 40, 5, 102, 211, 183, 4, 1, 221 },
- { 51, 50, 17, 168, 209, 192, 23, 25, 82 } },
- { { 138, 31, 36, 171, 27, 166, 38, 44, 229 },
- { 67, 87, 58, 169, 82, 115, 26, 59, 179 },
- { 63, 59, 90, 180, 59, 166, 93, 73, 154 },
- { 40, 40, 21, 116, 143, 209, 34, 39, 175 },
- { 47, 15, 16, 183, 34, 223, 49, 45, 183 },
- { 46, 17, 33, 183, 6, 98, 15, 32, 183 },
- { 57, 46, 22, 24, 128, 1, 54, 17, 37 },
- { 65, 32, 73, 115, 28, 128, 23, 128, 205 },
- { 40, 3, 9, 115, 51, 192, 18, 6, 223 },
- { 87, 37, 9, 115, 59, 77, 64, 21, 47 } },
- { { 104, 55, 44, 218, 9, 54, 53, 130, 226 },
- { 64, 90, 70, 205, 40, 41, 23, 26, 57 },
- { 54, 57, 112, 184, 5, 41, 38, 166, 213 },
- { 30, 34, 26, 133, 152, 116, 10, 32, 134 },
- { 39, 19, 53, 221, 26, 114, 32, 73, 255 },
- { 31, 9, 65, 234, 2, 15, 1, 118, 73 },
- { 75, 32, 12, 51, 192, 255, 160, 43, 51 },
- { 88, 31, 35, 67, 102, 85, 55, 186, 85 },
- { 56, 21, 23, 111, 59, 205, 45, 37, 192 },
- { 55, 38, 70, 124, 73, 102, 1, 34, 98 } },
- { { 125, 98, 42, 88, 104, 85, 117, 175, 82 },
- { 95, 84, 53, 89, 128, 100, 113, 101, 45 },
- { 75, 79, 123, 47, 51, 128, 81, 171, 1 },
- { 57, 17, 5, 71, 102, 57, 53, 41, 49 },
- { 38, 33, 13, 121, 57, 73, 26, 1, 85 },
- { 41, 10, 67, 138, 77, 110, 90, 47, 114 },
- { 115, 21, 2, 10, 102, 255, 166, 23, 6 },
- { 101, 29, 16, 10, 85, 128, 101, 196, 26 },
- { 57, 18, 10, 102, 102, 213, 34, 20, 43 },
- { 117, 20, 15, 36, 163, 128, 68, 1, 26 } },
- { { 102, 61, 71, 37, 34, 53, 31, 243, 192 },
- { 69, 60, 71, 38, 73, 119, 28, 222, 37 },
- { 68, 45, 128, 34, 1, 47, 11, 245, 171 },
- { 62, 17, 19, 70, 146, 85, 55, 62, 70 },
- { 37, 43, 37, 154, 100, 163, 85, 160, 1 },
- { 63, 9, 92, 136, 28, 64, 32, 201, 85 },
- { 75, 15, 9, 9, 64, 255, 184, 119, 16 },
- { 86, 6, 28, 5, 64, 255, 25, 248, 1 },
- { 56, 8, 17, 132, 137, 255, 55, 116, 128 },
- { 58, 15, 20, 82, 135, 57, 26, 121, 40 } },
- { { 164, 50, 31, 137, 154, 133, 25, 35, 218 },
- { 51, 103, 44, 131, 131, 123, 31, 6, 158 },
- { 86, 40, 64, 135, 148, 224, 45, 183, 128 },
- { 22, 26, 17, 131, 240, 154, 14, 1, 209 },
- { 45, 16, 21, 91, 64, 222, 7, 1, 197 },
- { 56, 21, 39, 155, 60, 138, 23, 102, 213 },
- { 83, 12, 13, 54, 192, 255, 68, 47, 28 },
- { 85, 26, 85, 85, 128, 128, 32, 146, 171 },
- { 18, 11, 7, 63, 144, 171, 4, 4, 246 },
- { 35, 27, 10, 146, 174, 171, 12, 26, 128 } },
- { { 190, 80, 35, 99, 180, 80, 126, 54, 45 },
- { 85, 126, 47, 87, 176, 51, 41, 20, 32 },
- { 101, 75, 128, 139, 118, 146, 116, 128, 85 },
- { 56, 41, 15, 176, 236, 85, 37, 9, 62 },
- { 71, 30, 17, 119, 118, 255, 17, 18, 138 },
- { 101, 38, 60, 138, 55, 70, 43, 26, 142 },
- { 146, 36, 19, 30, 171, 255, 97, 27, 20 },
- { 138, 45, 61, 62, 219, 1, 81, 188, 64 },
- { 32, 41, 20, 117, 151, 142, 20, 21, 163 },
- { 112, 19, 12, 61, 195, 128, 48, 4, 24 } }
-};
-
-void VP8ResetProba(VP8Proba* const proba) {
- memset(proba->segments_, 255u, sizeof(proba->segments_));
- // proba->bands_[][] is initialized later
-}
-
-static void ParseIntraMode(VP8BitReader* const br,
- VP8Decoder* const dec, int mb_x) {
- uint8_t* const top = dec->intra_t_ + 4 * mb_x;
- uint8_t* const left = dec->intra_l_;
- VP8MBData* const block = dec->mb_data_ + mb_x;
-
- // Note: we don't save segment map (yet), as we don't expect
- // to decode more than 1 keyframe.
- if (dec->segment_hdr_.update_map_) {
- // Hardcoded tree parsing
- block->segment_ = !VP8GetBit(br, dec->proba_.segments_[0], "segments")
- ? VP8GetBit(br, dec->proba_.segments_[1], "segments")
- : VP8GetBit(br, dec->proba_.segments_[2], "segments") + 2;
- } else {
- block->segment_ = 0; // default for intra
- }
- if (dec->use_skip_proba_) block->skip_ = VP8GetBit(br, dec->skip_p_, "skip");
-
- block->is_i4x4_ = !VP8GetBit(br, 145, "block-size");
- if (!block->is_i4x4_) {
- // Hardcoded 16x16 intra-mode decision tree.
- const int ymode =
- VP8GetBit(br, 156, "pred-modes") ?
- (VP8GetBit(br, 128, "pred-modes") ? TM_PRED : H_PRED) :
- (VP8GetBit(br, 163, "pred-modes") ? V_PRED : DC_PRED);
- block->imodes_[0] = ymode;
- memset(top, ymode, 4 * sizeof(*top));
- memset(left, ymode, 4 * sizeof(*left));
- } else {
- uint8_t* modes = block->imodes_;
- int y;
- for (y = 0; y < 4; ++y) {
- int ymode = left[y];
- int x;
- for (x = 0; x < 4; ++x) {
- const uint8_t* const prob = kBModesProba[top[x]][ymode];
-#if (USE_GENERIC_TREE == 1)
- // Generic tree-parsing
- int i = kYModesIntra4[VP8GetBit(br, prob[0], "pred-modes")];
- while (i > 0) {
- i = kYModesIntra4[2 * i + VP8GetBit(br, prob[i], "pred-modes")];
- }
- ymode = -i;
-#else
- // Hardcoded tree parsing
- ymode = !VP8GetBit(br, prob[0], "pred-modes") ? B_DC_PRED :
- !VP8GetBit(br, prob[1], "pred-modes") ? B_TM_PRED :
- !VP8GetBit(br, prob[2], "pred-modes") ? B_VE_PRED :
- !VP8GetBit(br, prob[3], "pred-modes") ?
- (!VP8GetBit(br, prob[4], "pred-modes") ? B_HE_PRED :
- (!VP8GetBit(br, prob[5], "pred-modes") ? B_RD_PRED
- : B_VR_PRED)) :
- (!VP8GetBit(br, prob[6], "pred-modes") ? B_LD_PRED :
- (!VP8GetBit(br, prob[7], "pred-modes") ? B_VL_PRED :
- (!VP8GetBit(br, prob[8], "pred-modes") ? B_HD_PRED
- : B_HU_PRED))
- );
-#endif // USE_GENERIC_TREE
- top[x] = ymode;
- }
- memcpy(modes, top, 4 * sizeof(*top));
- modes += 4;
- left[y] = ymode;
- }
- }
- // Hardcoded UVMode decision tree
- block->uvmode_ = !VP8GetBit(br, 142, "pred-modes-uv") ? DC_PRED
- : !VP8GetBit(br, 114, "pred-modes-uv") ? V_PRED
- : VP8GetBit(br, 183, "pred-modes-uv") ? TM_PRED : H_PRED;
-}
-
-int VP8ParseIntraModeRow(VP8BitReader* const br, VP8Decoder* const dec) {
- int mb_x;
- for (mb_x = 0; mb_x < dec->mb_w_; ++mb_x) {
- ParseIntraMode(br, dec, mb_x);
- }
- return !dec->br_.eof_;
-}
-
-//------------------------------------------------------------------------------
-// Paragraph 13
-
-static const uint8_t
- CoeffsUpdateProba[NUM_TYPES][NUM_BANDS][NUM_CTX][NUM_PROBAS] = {
- { { { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 176, 246, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 223, 241, 252, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 249, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 244, 252, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 234, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 253, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 246, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 239, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 254, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 248, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 251, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 251, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 254, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 254, 253, 255, 254, 255, 255, 255, 255, 255, 255 },
- { 250, 255, 254, 255, 254, 255, 255, 255, 255, 255, 255 },
- { 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }
- }
- },
- { { { 217, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 225, 252, 241, 253, 255, 255, 254, 255, 255, 255, 255 },
- { 234, 250, 241, 250, 253, 255, 253, 254, 255, 255, 255 }
- },
- { { 255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 223, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 238, 253, 254, 254, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 248, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 249, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 253, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 247, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 252, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 253, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 254, 253, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 250, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }
- }
- },
- { { { 186, 251, 250, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 234, 251, 244, 254, 255, 255, 255, 255, 255, 255, 255 },
- { 251, 251, 243, 253, 254, 255, 254, 255, 255, 255, 255 }
- },
- { { 255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 236, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 251, 253, 253, 254, 254, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 254, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 254, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }
- }
- },
- { { { 248, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 250, 254, 252, 254, 255, 255, 255, 255, 255, 255, 255 },
- { 248, 254, 249, 253, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 246, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 252, 254, 251, 254, 254, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 254, 252, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 248, 254, 253, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 253, 255, 254, 254, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 251, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 245, 251, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 253, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 251, 253, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 252, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 252, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 249, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 255, 253, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 250, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }
- }
- }
-};
-
-// Paragraph 9.9
-
-static const uint8_t kBands[16 + 1] = {
- 0, 1, 2, 3, 6, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7,
- 0 // extra entry as sentinel
-};
-
-void VP8ParseProba(VP8BitReader* const br, VP8Decoder* const dec) {
- VP8Proba* const proba = &dec->proba_;
- int t, b, c, p;
- for (t = 0; t < NUM_TYPES; ++t) {
- for (b = 0; b < NUM_BANDS; ++b) {
- for (c = 0; c < NUM_CTX; ++c) {
- for (p = 0; p < NUM_PROBAS; ++p) {
- const int v =
- VP8GetBit(br, CoeffsUpdateProba[t][b][c][p], "global-header") ?
- VP8GetValue(br, 8, "global-header") :
- CoeffsProba0[t][b][c][p];
- proba->bands_[t][b].probas_[c][p] = v;
- }
- }
- }
- for (b = 0; b < 16 + 1; ++b) {
- proba->bands_ptr_[t][b] = &proba->bands_[t][kBands[b]];
- }
- }
- dec->use_skip_proba_ = VP8Get(br, "global-header");
- if (dec->use_skip_proba_) {
- dec->skip_p_ = VP8GetValue(br, 8, "global-header");
- }
-}
diff --git a/contrib/libs/libwebp/dec/vp8_dec.c b/contrib/libs/libwebp/dec/vp8_dec.c
deleted file mode 100644
index 00aa049665..0000000000
--- a/contrib/libs/libwebp/dec/vp8_dec.c
+++ /dev/null
@@ -1,722 +0,0 @@
-// Copyright 2010 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// main entry for the decoder
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include <stdlib.h>
-
-#include "./alphai_dec.h"
-#include "./vp8i_dec.h"
-#include "./vp8li_dec.h"
-#include "./webpi_dec.h"
-#include "../utils/bit_reader_inl_utils.h"
-#include "../utils/utils.h"
-
-//------------------------------------------------------------------------------
-
-int WebPGetDecoderVersion(void) {
- return (DEC_MAJ_VERSION << 16) | (DEC_MIN_VERSION << 8) | DEC_REV_VERSION;
-}
-
-//------------------------------------------------------------------------------
-// Signature and pointer-to-function for GetCoeffs() variants below.
-
-typedef int (*GetCoeffsFunc)(VP8BitReader* const br,
- const VP8BandProbas* const prob[],
- int ctx, const quant_t dq, int n, int16_t* out);
-static volatile GetCoeffsFunc GetCoeffs = NULL;
-
-static void InitGetCoeffs(void);
-
-//------------------------------------------------------------------------------
-// VP8Decoder
-
-static void SetOk(VP8Decoder* const dec) {
- dec->status_ = VP8_STATUS_OK;
- dec->error_msg_ = "OK";
-}
-
-int VP8InitIoInternal(VP8Io* const io, int version) {
- if (WEBP_ABI_IS_INCOMPATIBLE(version, WEBP_DECODER_ABI_VERSION)) {
- return 0; // mismatch error
- }
- if (io != NULL) {
- memset(io, 0, sizeof(*io));
- }
- return 1;
-}
-
-VP8Decoder* VP8New(void) {
- VP8Decoder* const dec = (VP8Decoder*)WebPSafeCalloc(1ULL, sizeof(*dec));
- if (dec != NULL) {
- SetOk(dec);
- WebPGetWorkerInterface()->Init(&dec->worker_);
- dec->ready_ = 0;
- dec->num_parts_minus_one_ = 0;
- InitGetCoeffs();
- }
- return dec;
-}
-
-VP8StatusCode VP8Status(VP8Decoder* const dec) {
- if (!dec) return VP8_STATUS_INVALID_PARAM;
- return dec->status_;
-}
-
-const char* VP8StatusMessage(VP8Decoder* const dec) {
- if (dec == NULL) return "no object";
- if (!dec->error_msg_) return "OK";
- return dec->error_msg_;
-}
-
-void VP8Delete(VP8Decoder* const dec) {
- if (dec != NULL) {
- VP8Clear(dec);
- WebPSafeFree(dec);
- }
-}
-
-int VP8SetError(VP8Decoder* const dec,
- VP8StatusCode error, const char* const msg) {
- // The oldest error reported takes precedence over the new one.
- if (dec->status_ == VP8_STATUS_OK) {
- dec->status_ = error;
- dec->error_msg_ = msg;
- dec->ready_ = 0;
- }
- return 0;
-}
-
-//------------------------------------------------------------------------------
-
-int VP8CheckSignature(const uint8_t* const data, size_t data_size) {
- return (data_size >= 3 &&
- data[0] == 0x9d && data[1] == 0x01 && data[2] == 0x2a);
-}
-
-int VP8GetInfo(const uint8_t* data, size_t data_size, size_t chunk_size,
- int* const width, int* const height) {
- if (data == NULL || data_size < VP8_FRAME_HEADER_SIZE) {
- return 0; // not enough data
- }
- // check signature
- if (!VP8CheckSignature(data + 3, data_size - 3)) {
- return 0; // Wrong signature.
- } else {
- const uint32_t bits = data[0] | (data[1] << 8) | (data[2] << 16);
- const int key_frame = !(bits & 1);
- const int w = ((data[7] << 8) | data[6]) & 0x3fff;
- const int h = ((data[9] << 8) | data[8]) & 0x3fff;
-
- if (!key_frame) { // Not a keyframe.
- return 0;
- }
-
- if (((bits >> 1) & 7) > 3) {
- return 0; // unknown profile
- }
- if (!((bits >> 4) & 1)) {
- return 0; // first frame is invisible!
- }
- if (((bits >> 5)) >= chunk_size) { // partition_length
- return 0; // inconsistent size information.
- }
- if (w == 0 || h == 0) {
- return 0; // We don't support both width and height to be zero.
- }
-
- if (width) {
- *width = w;
- }
- if (height) {
- *height = h;
- }
-
- return 1;
- }
-}
-
-//------------------------------------------------------------------------------
-// Header parsing
-
-static void ResetSegmentHeader(VP8SegmentHeader* const hdr) {
- assert(hdr != NULL);
- hdr->use_segment_ = 0;
- hdr->update_map_ = 0;
- hdr->absolute_delta_ = 1;
- memset(hdr->quantizer_, 0, sizeof(hdr->quantizer_));
- memset(hdr->filter_strength_, 0, sizeof(hdr->filter_strength_));
-}
-
-// Paragraph 9.3
-static int ParseSegmentHeader(VP8BitReader* br,
- VP8SegmentHeader* hdr, VP8Proba* proba) {
- assert(br != NULL);
- assert(hdr != NULL);
- hdr->use_segment_ = VP8Get(br, "global-header");
- if (hdr->use_segment_) {
- hdr->update_map_ = VP8Get(br, "global-header");
- if (VP8Get(br, "global-header")) { // update data
- int s;
- hdr->absolute_delta_ = VP8Get(br, "global-header");
- for (s = 0; s < NUM_MB_SEGMENTS; ++s) {
- hdr->quantizer_[s] = VP8Get(br, "global-header") ?
- VP8GetSignedValue(br, 7, "global-header") : 0;
- }
- for (s = 0; s < NUM_MB_SEGMENTS; ++s) {
- hdr->filter_strength_[s] = VP8Get(br, "global-header") ?
- VP8GetSignedValue(br, 6, "global-header") : 0;
- }
- }
- if (hdr->update_map_) {
- int s;
- for (s = 0; s < MB_FEATURE_TREE_PROBS; ++s) {
- proba->segments_[s] = VP8Get(br, "global-header") ?
- VP8GetValue(br, 8, "global-header") : 255u;
- }
- }
- } else {
- hdr->update_map_ = 0;
- }
- return !br->eof_;
-}
-
-// Paragraph 9.5
-// This function returns VP8_STATUS_SUSPENDED if we don't have all the
-// necessary data in 'buf'.
-// This case is not necessarily an error (for incremental decoding).
-// Still, no bitreader is ever initialized to make it possible to read
-// unavailable memory.
-// If we don't even have the partitions' sizes, than VP8_STATUS_NOT_ENOUGH_DATA
-// is returned, and this is an unrecoverable error.
-// If the partitions were positioned ok, VP8_STATUS_OK is returned.
-static VP8StatusCode ParsePartitions(VP8Decoder* const dec,
- const uint8_t* buf, size_t size) {
- VP8BitReader* const br = &dec->br_;
- const uint8_t* sz = buf;
- const uint8_t* buf_end = buf + size;
- const uint8_t* part_start;
- size_t size_left = size;
- size_t last_part;
- size_t p;
-
- dec->num_parts_minus_one_ = (1 << VP8GetValue(br, 2, "global-header")) - 1;
- last_part = dec->num_parts_minus_one_;
- if (size < 3 * last_part) {
- // we can't even read the sizes with sz[]! That's a failure.
- return VP8_STATUS_NOT_ENOUGH_DATA;
- }
- part_start = buf + last_part * 3;
- size_left -= last_part * 3;
- for (p = 0; p < last_part; ++p) {
- size_t psize = sz[0] | (sz[1] << 8) | (sz[2] << 16);
- if (psize > size_left) psize = size_left;
- VP8InitBitReader(dec->parts_ + p, part_start, psize);
- part_start += psize;
- size_left -= psize;
- sz += 3;
- }
- VP8InitBitReader(dec->parts_ + last_part, part_start, size_left);
- return (part_start < buf_end) ? VP8_STATUS_OK :
- VP8_STATUS_SUSPENDED; // Init is ok, but there's not enough data
-}
-
-// Paragraph 9.4
-static int ParseFilterHeader(VP8BitReader* br, VP8Decoder* const dec) {
- VP8FilterHeader* const hdr = &dec->filter_hdr_;
- hdr->simple_ = VP8Get(br, "global-header");
- hdr->level_ = VP8GetValue(br, 6, "global-header");
- hdr->sharpness_ = VP8GetValue(br, 3, "global-header");
- hdr->use_lf_delta_ = VP8Get(br, "global-header");
- if (hdr->use_lf_delta_) {
- if (VP8Get(br, "global-header")) { // update lf-delta?
- int i;
- for (i = 0; i < NUM_REF_LF_DELTAS; ++i) {
- if (VP8Get(br, "global-header")) {
- hdr->ref_lf_delta_[i] = VP8GetSignedValue(br, 6, "global-header");
- }
- }
- for (i = 0; i < NUM_MODE_LF_DELTAS; ++i) {
- if (VP8Get(br, "global-header")) {
- hdr->mode_lf_delta_[i] = VP8GetSignedValue(br, 6, "global-header");
- }
- }
- }
- }
- dec->filter_type_ = (hdr->level_ == 0) ? 0 : hdr->simple_ ? 1 : 2;
- return !br->eof_;
-}
-
-// Topmost call
-int VP8GetHeaders(VP8Decoder* const dec, VP8Io* const io) {
- const uint8_t* buf;
- size_t buf_size;
- VP8FrameHeader* frm_hdr;
- VP8PictureHeader* pic_hdr;
- VP8BitReader* br;
- VP8StatusCode status;
-
- if (dec == NULL) {
- return 0;
- }
- SetOk(dec);
- if (io == NULL) {
- return VP8SetError(dec, VP8_STATUS_INVALID_PARAM,
- "null VP8Io passed to VP8GetHeaders()");
- }
- buf = io->data;
- buf_size = io->data_size;
- if (buf_size < 4) {
- return VP8SetError(dec, VP8_STATUS_NOT_ENOUGH_DATA,
- "Truncated header.");
- }
-
- // Paragraph 9.1
- {
- const uint32_t bits = buf[0] | (buf[1] << 8) | (buf[2] << 16);
- frm_hdr = &dec->frm_hdr_;
- frm_hdr->key_frame_ = !(bits & 1);
- frm_hdr->profile_ = (bits >> 1) & 7;
- frm_hdr->show_ = (bits >> 4) & 1;
- frm_hdr->partition_length_ = (bits >> 5);
- if (frm_hdr->profile_ > 3) {
- return VP8SetError(dec, VP8_STATUS_BITSTREAM_ERROR,
- "Incorrect keyframe parameters.");
- }
- if (!frm_hdr->show_) {
- return VP8SetError(dec, VP8_STATUS_UNSUPPORTED_FEATURE,
- "Frame not displayable.");
- }
- buf += 3;
- buf_size -= 3;
- }
-
- pic_hdr = &dec->pic_hdr_;
- if (frm_hdr->key_frame_) {
- // Paragraph 9.2
- if (buf_size < 7) {
- return VP8SetError(dec, VP8_STATUS_NOT_ENOUGH_DATA,
- "cannot parse picture header");
- }
- if (!VP8CheckSignature(buf, buf_size)) {
- return VP8SetError(dec, VP8_STATUS_BITSTREAM_ERROR,
- "Bad code word");
- }
- pic_hdr->width_ = ((buf[4] << 8) | buf[3]) & 0x3fff;
- pic_hdr->xscale_ = buf[4] >> 6; // ratio: 1, 5/4 5/3 or 2
- pic_hdr->height_ = ((buf[6] << 8) | buf[5]) & 0x3fff;
- pic_hdr->yscale_ = buf[6] >> 6;
- buf += 7;
- buf_size -= 7;
-
- dec->mb_w_ = (pic_hdr->width_ + 15) >> 4;
- dec->mb_h_ = (pic_hdr->height_ + 15) >> 4;
-
- // Setup default output area (can be later modified during io->setup())
- io->width = pic_hdr->width_;
- io->height = pic_hdr->height_;
- // IMPORTANT! use some sane dimensions in crop_* and scaled_* fields.
- // So they can be used interchangeably without always testing for
- // 'use_cropping'.
- io->use_cropping = 0;
- io->crop_top = 0;
- io->crop_left = 0;
- io->crop_right = io->width;
- io->crop_bottom = io->height;
- io->use_scaling = 0;
- io->scaled_width = io->width;
- io->scaled_height = io->height;
-
- io->mb_w = io->width; // for soundness
- io->mb_h = io->height; // ditto
-
- VP8ResetProba(&dec->proba_);
- ResetSegmentHeader(&dec->segment_hdr_);
- }
-
- // Check if we have all the partition #0 available, and initialize dec->br_
- // to read this partition (and this partition only).
- if (frm_hdr->partition_length_ > buf_size) {
- return VP8SetError(dec, VP8_STATUS_NOT_ENOUGH_DATA,
- "bad partition length");
- }
-
- br = &dec->br_;
- VP8InitBitReader(br, buf, frm_hdr->partition_length_);
- buf += frm_hdr->partition_length_;
- buf_size -= frm_hdr->partition_length_;
-
- if (frm_hdr->key_frame_) {
- pic_hdr->colorspace_ = VP8Get(br, "global-header");
- pic_hdr->clamp_type_ = VP8Get(br, "global-header");
- }
- if (!ParseSegmentHeader(br, &dec->segment_hdr_, &dec->proba_)) {
- return VP8SetError(dec, VP8_STATUS_BITSTREAM_ERROR,
- "cannot parse segment header");
- }
- // Filter specs
- if (!ParseFilterHeader(br, dec)) {
- return VP8SetError(dec, VP8_STATUS_BITSTREAM_ERROR,
- "cannot parse filter header");
- }
- status = ParsePartitions(dec, buf, buf_size);
- if (status != VP8_STATUS_OK) {
- return VP8SetError(dec, status, "cannot parse partitions");
- }
-
- // quantizer change
- VP8ParseQuant(dec);
-
- // Frame buffer marking
- if (!frm_hdr->key_frame_) {
- return VP8SetError(dec, VP8_STATUS_UNSUPPORTED_FEATURE,
- "Not a key frame.");
- }
-
- VP8Get(br, "global-header"); // ignore the value of update_proba_
-
- VP8ParseProba(br, dec);
-
- // sanitized state
- dec->ready_ = 1;
- return 1;
-}
-
-//------------------------------------------------------------------------------
-// Residual decoding (Paragraph 13.2 / 13.3)
-
-static const uint8_t kCat3[] = { 173, 148, 140, 0 };
-static const uint8_t kCat4[] = { 176, 155, 140, 135, 0 };
-static const uint8_t kCat5[] = { 180, 157, 141, 134, 130, 0 };
-static const uint8_t kCat6[] =
- { 254, 254, 243, 230, 196, 177, 153, 140, 133, 130, 129, 0 };
-static const uint8_t* const kCat3456[] = { kCat3, kCat4, kCat5, kCat6 };
-static const uint8_t kZigzag[16] = {
- 0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15
-};
-
-// See section 13-2: https://datatracker.ietf.org/doc/html/rfc6386#section-13.2
-static int GetLargeValue(VP8BitReader* const br, const uint8_t* const p) {
- int v;
- if (!VP8GetBit(br, p[3], "coeffs")) {
- if (!VP8GetBit(br, p[4], "coeffs")) {
- v = 2;
- } else {
- v = 3 + VP8GetBit(br, p[5], "coeffs");
- }
- } else {
- if (!VP8GetBit(br, p[6], "coeffs")) {
- if (!VP8GetBit(br, p[7], "coeffs")) {
- v = 5 + VP8GetBit(br, 159, "coeffs");
- } else {
- v = 7 + 2 * VP8GetBit(br, 165, "coeffs");
- v += VP8GetBit(br, 145, "coeffs");
- }
- } else {
- const uint8_t* tab;
- const int bit1 = VP8GetBit(br, p[8], "coeffs");
- const int bit0 = VP8GetBit(br, p[9 + bit1], "coeffs");
- const int cat = 2 * bit1 + bit0;
- v = 0;
- for (tab = kCat3456[cat]; *tab; ++tab) {
- v += v + VP8GetBit(br, *tab, "coeffs");
- }
- v += 3 + (8 << cat);
- }
- }
- return v;
-}
-
-// Returns the position of the last non-zero coeff plus one
-static int GetCoeffsFast(VP8BitReader* const br,
- const VP8BandProbas* const prob[],
- int ctx, const quant_t dq, int n, int16_t* out) {
- const uint8_t* p = prob[n]->probas_[ctx];
- for (; n < 16; ++n) {
- if (!VP8GetBit(br, p[0], "coeffs")) {
- return n; // previous coeff was last non-zero coeff
- }
- while (!VP8GetBit(br, p[1], "coeffs")) { // sequence of zero coeffs
- p = prob[++n]->probas_[0];
- if (n == 16) return 16;
- }
- { // non zero coeff
- const VP8ProbaArray* const p_ctx = &prob[n + 1]->probas_[0];
- int v;
- if (!VP8GetBit(br, p[2], "coeffs")) {
- v = 1;
- p = p_ctx[1];
- } else {
- v = GetLargeValue(br, p);
- p = p_ctx[2];
- }
- out[kZigzag[n]] = VP8GetSigned(br, v, "coeffs") * dq[n > 0];
- }
- }
- return 16;
-}
-
-// This version of GetCoeffs() uses VP8GetBitAlt() which is an alternate version
-// of VP8GetBitAlt() targeting specific platforms.
-static int GetCoeffsAlt(VP8BitReader* const br,
- const VP8BandProbas* const prob[],
- int ctx, const quant_t dq, int n, int16_t* out) {
- const uint8_t* p = prob[n]->probas_[ctx];
- for (; n < 16; ++n) {
- if (!VP8GetBitAlt(br, p[0], "coeffs")) {
- return n; // previous coeff was last non-zero coeff
- }
- while (!VP8GetBitAlt(br, p[1], "coeffs")) { // sequence of zero coeffs
- p = prob[++n]->probas_[0];
- if (n == 16) return 16;
- }
- { // non zero coeff
- const VP8ProbaArray* const p_ctx = &prob[n + 1]->probas_[0];
- int v;
- if (!VP8GetBitAlt(br, p[2], "coeffs")) {
- v = 1;
- p = p_ctx[1];
- } else {
- v = GetLargeValue(br, p);
- p = p_ctx[2];
- }
- out[kZigzag[n]] = VP8GetSigned(br, v, "coeffs") * dq[n > 0];
- }
- }
- return 16;
-}
-
-WEBP_DSP_INIT_FUNC(InitGetCoeffs) {
- if (VP8GetCPUInfo != NULL && VP8GetCPUInfo(kSlowSSSE3)) {
- GetCoeffs = GetCoeffsAlt;
- } else {
- GetCoeffs = GetCoeffsFast;
- }
-}
-
-static WEBP_INLINE uint32_t NzCodeBits(uint32_t nz_coeffs, int nz, int dc_nz) {
- nz_coeffs <<= 2;
- nz_coeffs |= (nz > 3) ? 3 : (nz > 1) ? 2 : dc_nz;
- return nz_coeffs;
-}
-
-static int ParseResiduals(VP8Decoder* const dec,
- VP8MB* const mb, VP8BitReader* const token_br) {
- const VP8BandProbas* (* const bands)[16 + 1] = dec->proba_.bands_ptr_;
- const VP8BandProbas* const * ac_proba;
- VP8MBData* const block = dec->mb_data_ + dec->mb_x_;
- const VP8QuantMatrix* const q = &dec->dqm_[block->segment_];
- int16_t* dst = block->coeffs_;
- VP8MB* const left_mb = dec->mb_info_ - 1;
- uint8_t tnz, lnz;
- uint32_t non_zero_y = 0;
- uint32_t non_zero_uv = 0;
- int x, y, ch;
- uint32_t out_t_nz, out_l_nz;
- int first;
-
- memset(dst, 0, 384 * sizeof(*dst));
- if (!block->is_i4x4_) { // parse DC
- int16_t dc[16] = { 0 };
- const int ctx = mb->nz_dc_ + left_mb->nz_dc_;
- const int nz = GetCoeffs(token_br, bands[1], ctx, q->y2_mat_, 0, dc);
- mb->nz_dc_ = left_mb->nz_dc_ = (nz > 0);
- if (nz > 1) { // more than just the DC -> perform the full transform
- VP8TransformWHT(dc, dst);
- } else { // only DC is non-zero -> inlined simplified transform
- int i;
- const int dc0 = (dc[0] + 3) >> 3;
- for (i = 0; i < 16 * 16; i += 16) dst[i] = dc0;
- }
- first = 1;
- ac_proba = bands[0];
- } else {
- first = 0;
- ac_proba = bands[3];
- }
-
- tnz = mb->nz_ & 0x0f;
- lnz = left_mb->nz_ & 0x0f;
- for (y = 0; y < 4; ++y) {
- int l = lnz & 1;
- uint32_t nz_coeffs = 0;
- for (x = 0; x < 4; ++x) {
- const int ctx = l + (tnz & 1);
- const int nz = GetCoeffs(token_br, ac_proba, ctx, q->y1_mat_, first, dst);
- l = (nz > first);
- tnz = (tnz >> 1) | (l << 7);
- nz_coeffs = NzCodeBits(nz_coeffs, nz, dst[0] != 0);
- dst += 16;
- }
- tnz >>= 4;
- lnz = (lnz >> 1) | (l << 7);
- non_zero_y = (non_zero_y << 8) | nz_coeffs;
- }
- out_t_nz = tnz;
- out_l_nz = lnz >> 4;
-
- for (ch = 0; ch < 4; ch += 2) {
- uint32_t nz_coeffs = 0;
- tnz = mb->nz_ >> (4 + ch);
- lnz = left_mb->nz_ >> (4 + ch);
- for (y = 0; y < 2; ++y) {
- int l = lnz & 1;
- for (x = 0; x < 2; ++x) {
- const int ctx = l + (tnz & 1);
- const int nz = GetCoeffs(token_br, bands[2], ctx, q->uv_mat_, 0, dst);
- l = (nz > 0);
- tnz = (tnz >> 1) | (l << 3);
- nz_coeffs = NzCodeBits(nz_coeffs, nz, dst[0] != 0);
- dst += 16;
- }
- tnz >>= 2;
- lnz = (lnz >> 1) | (l << 5);
- }
- // Note: we don't really need the per-4x4 details for U/V blocks.
- non_zero_uv |= nz_coeffs << (4 * ch);
- out_t_nz |= (tnz << 4) << ch;
- out_l_nz |= (lnz & 0xf0) << ch;
- }
- mb->nz_ = out_t_nz;
- left_mb->nz_ = out_l_nz;
-
- block->non_zero_y_ = non_zero_y;
- block->non_zero_uv_ = non_zero_uv;
-
- // We look at the mode-code of each block and check if some blocks have less
- // than three non-zero coeffs (code < 2). This is to avoid dithering flat and
- // empty blocks.
- block->dither_ = (non_zero_uv & 0xaaaa) ? 0 : q->dither_;
-
- return !(non_zero_y | non_zero_uv); // will be used for further optimization
-}
-
-//------------------------------------------------------------------------------
-// Main loop
-
-int VP8DecodeMB(VP8Decoder* const dec, VP8BitReader* const token_br) {
- VP8MB* const left = dec->mb_info_ - 1;
- VP8MB* const mb = dec->mb_info_ + dec->mb_x_;
- VP8MBData* const block = dec->mb_data_ + dec->mb_x_;
- int skip = dec->use_skip_proba_ ? block->skip_ : 0;
-
- if (!skip) {
- skip = ParseResiduals(dec, mb, token_br);
- } else {
- left->nz_ = mb->nz_ = 0;
- if (!block->is_i4x4_) {
- left->nz_dc_ = mb->nz_dc_ = 0;
- }
- block->non_zero_y_ = 0;
- block->non_zero_uv_ = 0;
- block->dither_ = 0;
- }
-
- if (dec->filter_type_ > 0) { // store filter info
- VP8FInfo* const finfo = dec->f_info_ + dec->mb_x_;
- *finfo = dec->fstrengths_[block->segment_][block->is_i4x4_];
- finfo->f_inner_ |= !skip;
- }
-
- return !token_br->eof_;
-}
-
-void VP8InitScanline(VP8Decoder* const dec) {
- VP8MB* const left = dec->mb_info_ - 1;
- left->nz_ = 0;
- left->nz_dc_ = 0;
- memset(dec->intra_l_, B_DC_PRED, sizeof(dec->intra_l_));
- dec->mb_x_ = 0;
-}
-
-static int ParseFrame(VP8Decoder* const dec, VP8Io* io) {
- for (dec->mb_y_ = 0; dec->mb_y_ < dec->br_mb_y_; ++dec->mb_y_) {
- // Parse bitstream for this row.
- VP8BitReader* const token_br =
- &dec->parts_[dec->mb_y_ & dec->num_parts_minus_one_];
- if (!VP8ParseIntraModeRow(&dec->br_, dec)) {
- return VP8SetError(dec, VP8_STATUS_NOT_ENOUGH_DATA,
- "Premature end-of-partition0 encountered.");
- }
- for (; dec->mb_x_ < dec->mb_w_; ++dec->mb_x_) {
- if (!VP8DecodeMB(dec, token_br)) {
- return VP8SetError(dec, VP8_STATUS_NOT_ENOUGH_DATA,
- "Premature end-of-file encountered.");
- }
- }
- VP8InitScanline(dec); // Prepare for next scanline
-
- // Reconstruct, filter and emit the row.
- if (!VP8ProcessRow(dec, io)) {
- return VP8SetError(dec, VP8_STATUS_USER_ABORT, "Output aborted.");
- }
- }
- if (dec->mt_method_ > 0) {
- if (!WebPGetWorkerInterface()->Sync(&dec->worker_)) return 0;
- }
-
- return 1;
-}
-
-// Main entry point
-int VP8Decode(VP8Decoder* const dec, VP8Io* const io) {
- int ok = 0;
- if (dec == NULL) {
- return 0;
- }
- if (io == NULL) {
- return VP8SetError(dec, VP8_STATUS_INVALID_PARAM,
- "NULL VP8Io parameter in VP8Decode().");
- }
-
- if (!dec->ready_) {
- if (!VP8GetHeaders(dec, io)) {
- return 0;
- }
- }
- assert(dec->ready_);
-
- // Finish setting up the decoding parameter. Will call io->setup().
- ok = (VP8EnterCritical(dec, io) == VP8_STATUS_OK);
- if (ok) { // good to go.
- // Will allocate memory and prepare everything.
- if (ok) ok = VP8InitFrame(dec, io);
-
- // Main decoding loop
- if (ok) ok = ParseFrame(dec, io);
-
- // Exit.
- ok &= VP8ExitCritical(dec, io);
- }
-
- if (!ok) {
- VP8Clear(dec);
- return 0;
- }
-
- dec->ready_ = 0;
- return ok;
-}
-
-void VP8Clear(VP8Decoder* const dec) {
- if (dec == NULL) {
- return;
- }
- WebPGetWorkerInterface()->End(&dec->worker_);
- WebPDeallocateAlphaMemory(dec);
- WebPSafeFree(dec->mem_);
- dec->mem_ = NULL;
- dec->mem_size_ = 0;
- memset(&dec->br_, 0, sizeof(dec->br_));
- dec->ready_ = 0;
-}
-
-//------------------------------------------------------------------------------
diff --git a/contrib/libs/libwebp/dec/vp8_dec.h b/contrib/libs/libwebp/dec/vp8_dec.h
deleted file mode 100644
index 03f4415fb5..0000000000
--- a/contrib/libs/libwebp/dec/vp8_dec.h
+++ /dev/null
@@ -1,185 +0,0 @@
-// Copyright 2010 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Low-level API for VP8 decoder
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#ifndef WEBP_DEC_VP8_DEC_H_
-#define WEBP_DEC_VP8_DEC_H_
-
-#include "../webp/decode.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-//------------------------------------------------------------------------------
-// Lower-level API
-//
-// These functions provide fine-grained control of the decoding process.
-// The call flow should resemble:
-//
-// VP8Io io;
-// VP8InitIo(&io);
-// io.data = data;
-// io.data_size = size;
-// /* customize io's functions (setup()/put()/teardown()) if needed. */
-//
-// VP8Decoder* dec = VP8New();
-// int ok = VP8Decode(dec, &io);
-// if (!ok) printf("Error: %s\n", VP8StatusMessage(dec));
-// VP8Delete(dec);
-// return ok;
-
-// Input / Output
-typedef struct VP8Io VP8Io;
-typedef int (*VP8IoPutHook)(const VP8Io* io);
-typedef int (*VP8IoSetupHook)(VP8Io* io);
-typedef void (*VP8IoTeardownHook)(const VP8Io* io);
-
-struct VP8Io {
- // set by VP8GetHeaders()
- int width, height; // picture dimensions, in pixels (invariable).
- // These are the original, uncropped dimensions.
- // The actual area passed to put() is stored
- // in mb_w / mb_h fields.
-
- // set before calling put()
- int mb_y; // position of the current rows (in pixels)
- int mb_w; // number of columns in the sample
- int mb_h; // number of rows in the sample
- const uint8_t* y, *u, *v; // rows to copy (in yuv420 format)
- int y_stride; // row stride for luma
- int uv_stride; // row stride for chroma
-
- void* opaque; // user data
-
- // called when fresh samples are available. Currently, samples are in
- // YUV420 format, and can be up to width x 24 in size (depending on the
- // in-loop filtering level, e.g.). Should return false in case of error
- // or abort request. The actual size of the area to update is mb_w x mb_h
- // in size, taking cropping into account.
- VP8IoPutHook put;
-
- // called just before starting to decode the blocks.
- // Must return false in case of setup error, true otherwise. If false is
- // returned, teardown() will NOT be called. But if the setup succeeded
- // and true is returned, then teardown() will always be called afterward.
- VP8IoSetupHook setup;
-
- // Called just after block decoding is finished (or when an error occurred
- // during put()). Is NOT called if setup() failed.
- VP8IoTeardownHook teardown;
-
- // this is a recommendation for the user-side yuv->rgb converter. This flag
- // is set when calling setup() hook and can be overwritten by it. It then
- // can be taken into consideration during the put() method.
- int fancy_upsampling;
-
- // Input buffer.
- size_t data_size;
- const uint8_t* data;
-
- // If true, in-loop filtering will not be performed even if present in the
- // bitstream. Switching off filtering may speed up decoding at the expense
- // of more visible blocking. Note that output will also be non-compliant
- // with the VP8 specifications.
- int bypass_filtering;
-
- // Cropping parameters.
- int use_cropping;
- int crop_left, crop_right, crop_top, crop_bottom;
-
- // Scaling parameters.
- int use_scaling;
- int scaled_width, scaled_height;
-
- // If non NULL, pointer to the alpha data (if present) corresponding to the
- // start of the current row (That is: it is pre-offset by mb_y and takes
- // cropping into account).
- const uint8_t* a;
-};
-
-// Internal, version-checked, entry point
-int VP8InitIoInternal(VP8Io* const, int);
-
-// Set the custom IO function pointers and user-data. The setter for IO hooks
-// should be called before initiating incremental decoding. Returns true if
-// WebPIDecoder object is successfully modified, false otherwise.
-int WebPISetIOHooks(WebPIDecoder* const idec,
- VP8IoPutHook put,
- VP8IoSetupHook setup,
- VP8IoTeardownHook teardown,
- void* user_data);
-
-// Main decoding object. This is an opaque structure.
-typedef struct VP8Decoder VP8Decoder;
-
-// Create a new decoder object.
-VP8Decoder* VP8New(void);
-
-// Must be called to make sure 'io' is initialized properly.
-// Returns false in case of version mismatch. Upon such failure, no other
-// decoding function should be called (VP8Decode, VP8GetHeaders, ...)
-static WEBP_INLINE int VP8InitIo(VP8Io* const io) {
- return VP8InitIoInternal(io, WEBP_DECODER_ABI_VERSION);
-}
-
-// Decode the VP8 frame header. Returns true if ok.
-// Note: 'io->data' must be pointing to the start of the VP8 frame header.
-int VP8GetHeaders(VP8Decoder* const dec, VP8Io* const io);
-
-// Decode a picture. Will call VP8GetHeaders() if it wasn't done already.
-// Returns false in case of error.
-int VP8Decode(VP8Decoder* const dec, VP8Io* const io);
-
-// Return current status of the decoder:
-VP8StatusCode VP8Status(VP8Decoder* const dec);
-
-// return readable string corresponding to the last status.
-const char* VP8StatusMessage(VP8Decoder* const dec);
-
-// Resets the decoder in its initial state, reclaiming memory.
-// Not a mandatory call between calls to VP8Decode().
-void VP8Clear(VP8Decoder* const dec);
-
-// Destroy the decoder object.
-void VP8Delete(VP8Decoder* const dec);
-
-//------------------------------------------------------------------------------
-// Miscellaneous VP8/VP8L bitstream probing functions.
-
-// Returns true if the next 3 bytes in data contain the VP8 signature.
-WEBP_EXTERN int VP8CheckSignature(const uint8_t* const data, size_t data_size);
-
-// Validates the VP8 data-header and retrieves basic header information viz
-// width and height. Returns 0 in case of formatting error. *width/*height
-// can be passed NULL.
-WEBP_EXTERN int VP8GetInfo(
- const uint8_t* data,
- size_t data_size, // data available so far
- size_t chunk_size, // total data size expected in the chunk
- int* const width, int* const height);
-
-// Returns true if the next byte(s) in data is a VP8L signature.
-WEBP_EXTERN int VP8LCheckSignature(const uint8_t* const data, size_t size);
-
-// Validates the VP8L data-header and retrieves basic header information viz
-// width, height and alpha. Returns 0 in case of formatting error.
-// width/height/has_alpha can be passed NULL.
-WEBP_EXTERN int VP8LGetInfo(
- const uint8_t* data, size_t data_size, // data available so far
- int* const width, int* const height, int* const has_alpha);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // WEBP_DEC_VP8_DEC_H_
diff --git a/contrib/libs/libwebp/dec/vp8i_dec.h b/contrib/libs/libwebp/dec/vp8i_dec.h
deleted file mode 100644
index 303eb4be42..0000000000
--- a/contrib/libs/libwebp/dec/vp8i_dec.h
+++ /dev/null
@@ -1,319 +0,0 @@
-// Copyright 2010 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// VP8 decoder: internal header.
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#ifndef WEBP_DEC_VP8I_DEC_H_
-#define WEBP_DEC_VP8I_DEC_H_
-
-#include <string.h> // for memcpy()
-#include "./common_dec.h"
-#include "./vp8li_dec.h"
-#include "../utils/bit_reader_utils.h"
-#include "../utils/random_utils.h"
-#include "../utils/thread_utils.h"
-#include "../dsp/dsp.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-//------------------------------------------------------------------------------
-// Various defines and enums
-
-// version numbers
-#define DEC_MAJ_VERSION 1
-#define DEC_MIN_VERSION 2
-#define DEC_REV_VERSION 2
-
-// YUV-cache parameters. Cache is 32-bytes wide (= one cacheline).
-// Constraints are: We need to store one 16x16 block of luma samples (y),
-// and two 8x8 chroma blocks (u/v). These are better be 16-bytes aligned,
-// in order to be SIMD-friendly. We also need to store the top, left and
-// top-left samples (from previously decoded blocks), along with four
-// extra top-right samples for luma (intra4x4 prediction only).
-// One possible layout is, using 32 * (17 + 9) bytes:
-//
-// .+------ <- only 1 pixel high
-// .|yyyyt.
-// .|yyyyt.
-// .|yyyyt.
-// .|yyyy..
-// .+--.+-- <- only 1 pixel high
-// .|uu.|vv
-// .|uu.|vv
-//
-// Every character is a 4x4 block, with legend:
-// '.' = unused
-// 'y' = y-samples 'u' = u-samples 'v' = u-samples
-// '|' = left sample, '-' = top sample, '+' = top-left sample
-// 't' = extra top-right sample for 4x4 modes
-#define YUV_SIZE (BPS * 17 + BPS * 9)
-#define Y_OFF (BPS * 1 + 8)
-#define U_OFF (Y_OFF + BPS * 16 + BPS)
-#define V_OFF (U_OFF + 16)
-
-// minimal width under which lossy multi-threading is always disabled
-#define MIN_WIDTH_FOR_THREADS 512
-
-//------------------------------------------------------------------------------
-// Headers
-
-typedef struct {
- uint8_t key_frame_;
- uint8_t profile_;
- uint8_t show_;
- uint32_t partition_length_;
-} VP8FrameHeader;
-
-typedef struct {
- uint16_t width_;
- uint16_t height_;
- uint8_t xscale_;
- uint8_t yscale_;
- uint8_t colorspace_; // 0 = YCbCr
- uint8_t clamp_type_;
-} VP8PictureHeader;
-
-// segment features
-typedef struct {
- int use_segment_;
- int update_map_; // whether to update the segment map or not
- int absolute_delta_; // absolute or delta values for quantizer and filter
- int8_t quantizer_[NUM_MB_SEGMENTS]; // quantization changes
- int8_t filter_strength_[NUM_MB_SEGMENTS]; // filter strength for segments
-} VP8SegmentHeader;
-
-// probas associated to one of the contexts
-typedef uint8_t VP8ProbaArray[NUM_PROBAS];
-
-typedef struct { // all the probas associated to one band
- VP8ProbaArray probas_[NUM_CTX];
-} VP8BandProbas;
-
-// Struct collecting all frame-persistent probabilities.
-typedef struct {
- uint8_t segments_[MB_FEATURE_TREE_PROBS];
- // Type: 0:Intra16-AC 1:Intra16-DC 2:Chroma 3:Intra4
- VP8BandProbas bands_[NUM_TYPES][NUM_BANDS];
- const VP8BandProbas* bands_ptr_[NUM_TYPES][16 + 1];
-} VP8Proba;
-
-// Filter parameters
-typedef struct {
- int simple_; // 0=complex, 1=simple
- int level_; // [0..63]
- int sharpness_; // [0..7]
- int use_lf_delta_;
- int ref_lf_delta_[NUM_REF_LF_DELTAS];
- int mode_lf_delta_[NUM_MODE_LF_DELTAS];
-} VP8FilterHeader;
-
-//------------------------------------------------------------------------------
-// Informations about the macroblocks.
-
-typedef struct { // filter specs
- uint8_t f_limit_; // filter limit in [3..189], or 0 if no filtering
- uint8_t f_ilevel_; // inner limit in [1..63]
- uint8_t f_inner_; // do inner filtering?
- uint8_t hev_thresh_; // high edge variance threshold in [0..2]
-} VP8FInfo;
-
-typedef struct { // Top/Left Contexts used for syntax-parsing
- uint8_t nz_; // non-zero AC/DC coeffs (4bit for luma + 4bit for chroma)
- uint8_t nz_dc_; // non-zero DC coeff (1bit)
-} VP8MB;
-
-// Dequantization matrices
-typedef int quant_t[2]; // [DC / AC]. Can be 'uint16_t[2]' too (~slower).
-typedef struct {
- quant_t y1_mat_, y2_mat_, uv_mat_;
-
- int uv_quant_; // U/V quantizer value
- int dither_; // dithering amplitude (0 = off, max=255)
-} VP8QuantMatrix;
-
-// Data needed to reconstruct a macroblock
-typedef struct {
- int16_t coeffs_[384]; // 384 coeffs = (16+4+4) * 4*4
- uint8_t is_i4x4_; // true if intra4x4
- uint8_t imodes_[16]; // one 16x16 mode (#0) or sixteen 4x4 modes
- uint8_t uvmode_; // chroma prediction mode
- // bit-wise info about the content of each sub-4x4 blocks (in decoding order).
- // Each of the 4x4 blocks for y/u/v is associated with a 2b code according to:
- // code=0 -> no coefficient
- // code=1 -> only DC
- // code=2 -> first three coefficients are non-zero
- // code=3 -> more than three coefficients are non-zero
- // This allows to call specialized transform functions.
- uint32_t non_zero_y_;
- uint32_t non_zero_uv_;
- uint8_t dither_; // local dithering strength (deduced from non_zero_*)
- uint8_t skip_;
- uint8_t segment_;
-} VP8MBData;
-
-// Persistent information needed by the parallel processing
-typedef struct {
- int id_; // cache row to process (in [0..2])
- int mb_y_; // macroblock position of the row
- int filter_row_; // true if row-filtering is needed
- VP8FInfo* f_info_; // filter strengths (swapped with dec->f_info_)
- VP8MBData* mb_data_; // reconstruction data (swapped with dec->mb_data_)
- VP8Io io_; // copy of the VP8Io to pass to put()
-} VP8ThreadContext;
-
-// Saved top samples, per macroblock. Fits into a cache-line.
-typedef struct {
- uint8_t y[16], u[8], v[8];
-} VP8TopSamples;
-
-//------------------------------------------------------------------------------
-// VP8Decoder: the main opaque structure handed over to user
-
-struct VP8Decoder {
- VP8StatusCode status_;
- int ready_; // true if ready to decode a picture with VP8Decode()
- const char* error_msg_; // set when status_ is not OK.
-
- // Main data source
- VP8BitReader br_;
-
- // headers
- VP8FrameHeader frm_hdr_;
- VP8PictureHeader pic_hdr_;
- VP8FilterHeader filter_hdr_;
- VP8SegmentHeader segment_hdr_;
-
- // Worker
- WebPWorker worker_;
- int mt_method_; // multi-thread method: 0=off, 1=[parse+recon][filter]
- // 2=[parse][recon+filter]
- int cache_id_; // current cache row
- int num_caches_; // number of cached rows of 16 pixels (1, 2 or 3)
- VP8ThreadContext thread_ctx_; // Thread context
-
- // dimension, in macroblock units.
- int mb_w_, mb_h_;
-
- // Macroblock to process/filter, depending on cropping and filter_type.
- int tl_mb_x_, tl_mb_y_; // top-left MB that must be in-loop filtered
- int br_mb_x_, br_mb_y_; // last bottom-right MB that must be decoded
-
- // number of partitions minus one.
- uint32_t num_parts_minus_one_;
- // per-partition boolean decoders.
- VP8BitReader parts_[MAX_NUM_PARTITIONS];
-
- // Dithering strength, deduced from decoding options
- int dither_; // whether to use dithering or not
- VP8Random dithering_rg_; // random generator for dithering
-
- // dequantization (one set of DC/AC dequant factor per segment)
- VP8QuantMatrix dqm_[NUM_MB_SEGMENTS];
-
- // probabilities
- VP8Proba proba_;
- int use_skip_proba_;
- uint8_t skip_p_;
-
- // Boundary data cache and persistent buffers.
- uint8_t* intra_t_; // top intra modes values: 4 * mb_w_
- uint8_t intra_l_[4]; // left intra modes values
-
- VP8TopSamples* yuv_t_; // top y/u/v samples
-
- VP8MB* mb_info_; // contextual macroblock info (mb_w_ + 1)
- VP8FInfo* f_info_; // filter strength info
- uint8_t* yuv_b_; // main block for Y/U/V (size = YUV_SIZE)
-
- uint8_t* cache_y_; // macroblock row for storing unfiltered samples
- uint8_t* cache_u_;
- uint8_t* cache_v_;
- int cache_y_stride_;
- int cache_uv_stride_;
-
- // main memory chunk for the above data. Persistent.
- void* mem_;
- size_t mem_size_;
-
- // Per macroblock non-persistent infos.
- int mb_x_, mb_y_; // current position, in macroblock units
- VP8MBData* mb_data_; // parsed reconstruction data
-
- // Filtering side-info
- int filter_type_; // 0=off, 1=simple, 2=complex
- VP8FInfo fstrengths_[NUM_MB_SEGMENTS][2]; // precalculated per-segment/type
-
- // Alpha
- struct ALPHDecoder* alph_dec_; // alpha-plane decoder object
- const uint8_t* alpha_data_; // compressed alpha data (if present)
- size_t alpha_data_size_;
- int is_alpha_decoded_; // true if alpha_data_ is decoded in alpha_plane_
- uint8_t* alpha_plane_mem_; // memory allocated for alpha_plane_
- uint8_t* alpha_plane_; // output. Persistent, contains the whole data.
- const uint8_t* alpha_prev_line_; // last decoded alpha row (or NULL)
- int alpha_dithering_; // derived from decoding options (0=off, 100=full)
-};
-
-//------------------------------------------------------------------------------
-// internal functions. Not public.
-
-// in vp8.c
-int VP8SetError(VP8Decoder* const dec,
- VP8StatusCode error, const char* const msg);
-
-// in tree.c
-void VP8ResetProba(VP8Proba* const proba);
-void VP8ParseProba(VP8BitReader* const br, VP8Decoder* const dec);
-// parses one row of intra mode data in partition 0, returns !eof
-int VP8ParseIntraModeRow(VP8BitReader* const br, VP8Decoder* const dec);
-
-// in quant.c
-void VP8ParseQuant(VP8Decoder* const dec);
-
-// in frame.c
-int VP8InitFrame(VP8Decoder* const dec, VP8Io* const io);
-// Call io->setup() and finish setting up scan parameters.
-// After this call returns, one must always call VP8ExitCritical() with the
-// same parameters. Both functions should be used in pair. Returns VP8_STATUS_OK
-// if ok, otherwise sets and returns the error status on *dec.
-VP8StatusCode VP8EnterCritical(VP8Decoder* const dec, VP8Io* const io);
-// Must always be called in pair with VP8EnterCritical().
-// Returns false in case of error.
-int VP8ExitCritical(VP8Decoder* const dec, VP8Io* const io);
-// Return the multi-threading method to use (0=off), depending
-// on options and bitstream size. Only for lossy decoding.
-int VP8GetThreadMethod(const WebPDecoderOptions* const options,
- const WebPHeaderStructure* const headers,
- int width, int height);
-// Initialize dithering post-process if needed.
-void VP8InitDithering(const WebPDecoderOptions* const options,
- VP8Decoder* const dec);
-// Process the last decoded row (filtering + output).
-int VP8ProcessRow(VP8Decoder* const dec, VP8Io* const io);
-// To be called at the start of a new scanline, to initialize predictors.
-void VP8InitScanline(VP8Decoder* const dec);
-// Decode one macroblock. Returns false if there is not enough data.
-int VP8DecodeMB(VP8Decoder* const dec, VP8BitReader* const token_br);
-
-// in alpha.c
-const uint8_t* VP8DecompressAlphaRows(VP8Decoder* const dec,
- const VP8Io* const io,
- int row, int num_rows);
-
-//------------------------------------------------------------------------------
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // WEBP_DEC_VP8I_DEC_H_
diff --git a/contrib/libs/libwebp/dec/vp8l_dec.c b/contrib/libs/libwebp/dec/vp8l_dec.c
deleted file mode 100644
index 1689b2d71a..0000000000
--- a/contrib/libs/libwebp/dec/vp8l_dec.c
+++ /dev/null
@@ -1,1742 +0,0 @@
-// Copyright 2012 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// main entry for the decoder
-//
-// Authors: Vikas Arora (vikaas.arora@gmail.com)
-// Jyrki Alakuijala (jyrki@google.com)
-
-#include <stdlib.h>
-
-#include "./alphai_dec.h"
-#include "./vp8li_dec.h"
-#include "../dsp/dsp.h"
-#include "../dsp/lossless.h"
-#include "../dsp/lossless_common.h"
-#include "../dsp/yuv.h"
-#include "../utils/endian_inl_utils.h"
-#include "../utils/huffman_utils.h"
-#include "../utils/utils.h"
-
-#define NUM_ARGB_CACHE_ROWS 16
-
-static const int kCodeLengthLiterals = 16;
-static const int kCodeLengthRepeatCode = 16;
-static const uint8_t kCodeLengthExtraBits[3] = { 2, 3, 7 };
-static const uint8_t kCodeLengthRepeatOffsets[3] = { 3, 3, 11 };
-
-// -----------------------------------------------------------------------------
-// Five Huffman codes are used at each meta code:
-// 1. green + length prefix codes + color cache codes,
-// 2. alpha,
-// 3. red,
-// 4. blue, and,
-// 5. distance prefix codes.
-typedef enum {
- GREEN = 0,
- RED = 1,
- BLUE = 2,
- ALPHA = 3,
- DIST = 4
-} HuffIndex;
-
-static const uint16_t kAlphabetSize[HUFFMAN_CODES_PER_META_CODE] = {
- NUM_LITERAL_CODES + NUM_LENGTH_CODES,
- NUM_LITERAL_CODES, NUM_LITERAL_CODES, NUM_LITERAL_CODES,
- NUM_DISTANCE_CODES
-};
-
-static const uint8_t kLiteralMap[HUFFMAN_CODES_PER_META_CODE] = {
- 0, 1, 1, 1, 0
-};
-
-#define NUM_CODE_LENGTH_CODES 19
-static const uint8_t kCodeLengthCodeOrder[NUM_CODE_LENGTH_CODES] = {
- 17, 18, 0, 1, 2, 3, 4, 5, 16, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
-};
-
-#define CODE_TO_PLANE_CODES 120
-static const uint8_t kCodeToPlane[CODE_TO_PLANE_CODES] = {
- 0x18, 0x07, 0x17, 0x19, 0x28, 0x06, 0x27, 0x29, 0x16, 0x1a,
- 0x26, 0x2a, 0x38, 0x05, 0x37, 0x39, 0x15, 0x1b, 0x36, 0x3a,
- 0x25, 0x2b, 0x48, 0x04, 0x47, 0x49, 0x14, 0x1c, 0x35, 0x3b,
- 0x46, 0x4a, 0x24, 0x2c, 0x58, 0x45, 0x4b, 0x34, 0x3c, 0x03,
- 0x57, 0x59, 0x13, 0x1d, 0x56, 0x5a, 0x23, 0x2d, 0x44, 0x4c,
- 0x55, 0x5b, 0x33, 0x3d, 0x68, 0x02, 0x67, 0x69, 0x12, 0x1e,
- 0x66, 0x6a, 0x22, 0x2e, 0x54, 0x5c, 0x43, 0x4d, 0x65, 0x6b,
- 0x32, 0x3e, 0x78, 0x01, 0x77, 0x79, 0x53, 0x5d, 0x11, 0x1f,
- 0x64, 0x6c, 0x42, 0x4e, 0x76, 0x7a, 0x21, 0x2f, 0x75, 0x7b,
- 0x31, 0x3f, 0x63, 0x6d, 0x52, 0x5e, 0x00, 0x74, 0x7c, 0x41,
- 0x4f, 0x10, 0x20, 0x62, 0x6e, 0x30, 0x73, 0x7d, 0x51, 0x5f,
- 0x40, 0x72, 0x7e, 0x61, 0x6f, 0x50, 0x71, 0x7f, 0x60, 0x70
-};
-
-// Memory needed for lookup tables of one Huffman tree group. Red, blue, alpha
-// and distance alphabets are constant (256 for red, blue and alpha, 40 for
-// distance) and lookup table sizes for them in worst case are 630 and 410
-// respectively. Size of green alphabet depends on color cache size and is equal
-// to 256 (green component values) + 24 (length prefix values)
-// + color_cache_size (between 0 and 2048).
-// All values computed for 8-bit first level lookup with Mark Adler's tool:
-// https://github.com/madler/zlib/blob/v1.2.5/examples/enough.c
-#define FIXED_TABLE_SIZE (630 * 3 + 410)
-static const uint16_t kTableSize[12] = {
- FIXED_TABLE_SIZE + 654,
- FIXED_TABLE_SIZE + 656,
- FIXED_TABLE_SIZE + 658,
- FIXED_TABLE_SIZE + 662,
- FIXED_TABLE_SIZE + 670,
- FIXED_TABLE_SIZE + 686,
- FIXED_TABLE_SIZE + 718,
- FIXED_TABLE_SIZE + 782,
- FIXED_TABLE_SIZE + 912,
- FIXED_TABLE_SIZE + 1168,
- FIXED_TABLE_SIZE + 1680,
- FIXED_TABLE_SIZE + 2704
-};
-
-static int DecodeImageStream(int xsize, int ysize,
- int is_level0,
- VP8LDecoder* const dec,
- uint32_t** const decoded_data);
-
-//------------------------------------------------------------------------------
-
-int VP8LCheckSignature(const uint8_t* const data, size_t size) {
- return (size >= VP8L_FRAME_HEADER_SIZE &&
- data[0] == VP8L_MAGIC_BYTE &&
- (data[4] >> 5) == 0); // version
-}
-
-static int ReadImageInfo(VP8LBitReader* const br,
- int* const width, int* const height,
- int* const has_alpha) {
- if (VP8LReadBits(br, 8) != VP8L_MAGIC_BYTE) return 0;
- *width = VP8LReadBits(br, VP8L_IMAGE_SIZE_BITS) + 1;
- *height = VP8LReadBits(br, VP8L_IMAGE_SIZE_BITS) + 1;
- *has_alpha = VP8LReadBits(br, 1);
- if (VP8LReadBits(br, VP8L_VERSION_BITS) != 0) return 0;
- return !br->eos_;
-}
-
-int VP8LGetInfo(const uint8_t* data, size_t data_size,
- int* const width, int* const height, int* const has_alpha) {
- if (data == NULL || data_size < VP8L_FRAME_HEADER_SIZE) {
- return 0; // not enough data
- } else if (!VP8LCheckSignature(data, data_size)) {
- return 0; // bad signature
- } else {
- int w, h, a;
- VP8LBitReader br;
- VP8LInitBitReader(&br, data, data_size);
- if (!ReadImageInfo(&br, &w, &h, &a)) {
- return 0;
- }
- if (width != NULL) *width = w;
- if (height != NULL) *height = h;
- if (has_alpha != NULL) *has_alpha = a;
- return 1;
- }
-}
-
-//------------------------------------------------------------------------------
-
-static WEBP_INLINE int GetCopyDistance(int distance_symbol,
- VP8LBitReader* const br) {
- int extra_bits, offset;
- if (distance_symbol < 4) {
- return distance_symbol + 1;
- }
- extra_bits = (distance_symbol - 2) >> 1;
- offset = (2 + (distance_symbol & 1)) << extra_bits;
- return offset + VP8LReadBits(br, extra_bits) + 1;
-}
-
-static WEBP_INLINE int GetCopyLength(int length_symbol,
- VP8LBitReader* const br) {
- // Length and distance prefixes are encoded the same way.
- return GetCopyDistance(length_symbol, br);
-}
-
-static WEBP_INLINE int PlaneCodeToDistance(int xsize, int plane_code) {
- if (plane_code > CODE_TO_PLANE_CODES) {
- return plane_code - CODE_TO_PLANE_CODES;
- } else {
- const int dist_code = kCodeToPlane[plane_code - 1];
- const int yoffset = dist_code >> 4;
- const int xoffset = 8 - (dist_code & 0xf);
- const int dist = yoffset * xsize + xoffset;
- return (dist >= 1) ? dist : 1; // dist<1 can happen if xsize is very small
- }
-}
-
-//------------------------------------------------------------------------------
-// Decodes the next Huffman code from bit-stream.
-// FillBitWindow(br) needs to be called at minimum every second call
-// to ReadSymbol, in order to pre-fetch enough bits.
-static WEBP_INLINE int ReadSymbol(const HuffmanCode* table,
- VP8LBitReader* const br) {
- int nbits;
- uint32_t val = VP8LPrefetchBits(br);
- table += val & HUFFMAN_TABLE_MASK;
- nbits = table->bits - HUFFMAN_TABLE_BITS;
- if (nbits > 0) {
- VP8LSetBitPos(br, br->bit_pos_ + HUFFMAN_TABLE_BITS);
- val = VP8LPrefetchBits(br);
- table += table->value;
- table += val & ((1 << nbits) - 1);
- }
- VP8LSetBitPos(br, br->bit_pos_ + table->bits);
- return table->value;
-}
-
-// Reads packed symbol depending on GREEN channel
-#define BITS_SPECIAL_MARKER 0x100 // something large enough (and a bit-mask)
-#define PACKED_NON_LITERAL_CODE 0 // must be < NUM_LITERAL_CODES
-static WEBP_INLINE int ReadPackedSymbols(const HTreeGroup* group,
- VP8LBitReader* const br,
- uint32_t* const dst) {
- const uint32_t val = VP8LPrefetchBits(br) & (HUFFMAN_PACKED_TABLE_SIZE - 1);
- const HuffmanCode32 code = group->packed_table[val];
- assert(group->use_packed_table);
- if (code.bits < BITS_SPECIAL_MARKER) {
- VP8LSetBitPos(br, br->bit_pos_ + code.bits);
- *dst = code.value;
- return PACKED_NON_LITERAL_CODE;
- } else {
- VP8LSetBitPos(br, br->bit_pos_ + code.bits - BITS_SPECIAL_MARKER);
- assert(code.value >= NUM_LITERAL_CODES);
- return code.value;
- }
-}
-
-static int AccumulateHCode(HuffmanCode hcode, int shift,
- HuffmanCode32* const huff) {
- huff->bits += hcode.bits;
- huff->value |= (uint32_t)hcode.value << shift;
- assert(huff->bits <= HUFFMAN_TABLE_BITS);
- return hcode.bits;
-}
-
-static void BuildPackedTable(HTreeGroup* const htree_group) {
- uint32_t code;
- for (code = 0; code < HUFFMAN_PACKED_TABLE_SIZE; ++code) {
- uint32_t bits = code;
- HuffmanCode32* const huff = &htree_group->packed_table[bits];
- HuffmanCode hcode = htree_group->htrees[GREEN][bits];
- if (hcode.value >= NUM_LITERAL_CODES) {
- huff->bits = hcode.bits + BITS_SPECIAL_MARKER;
- huff->value = hcode.value;
- } else {
- huff->bits = 0;
- huff->value = 0;
- bits >>= AccumulateHCode(hcode, 8, huff);
- bits >>= AccumulateHCode(htree_group->htrees[RED][bits], 16, huff);
- bits >>= AccumulateHCode(htree_group->htrees[BLUE][bits], 0, huff);
- bits >>= AccumulateHCode(htree_group->htrees[ALPHA][bits], 24, huff);
- (void)bits;
- }
- }
-}
-
-static int ReadHuffmanCodeLengths(
- VP8LDecoder* const dec, const int* const code_length_code_lengths,
- int num_symbols, int* const code_lengths) {
- int ok = 0;
- VP8LBitReader* const br = &dec->br_;
- int symbol;
- int max_symbol;
- int prev_code_len = DEFAULT_CODE_LENGTH;
- HuffmanCode table[1 << LENGTHS_TABLE_BITS];
-
- if (!VP8LBuildHuffmanTable(table, LENGTHS_TABLE_BITS,
- code_length_code_lengths,
- NUM_CODE_LENGTH_CODES)) {
- goto End;
- }
-
- if (VP8LReadBits(br, 1)) { // use length
- const int length_nbits = 2 + 2 * VP8LReadBits(br, 3);
- max_symbol = 2 + VP8LReadBits(br, length_nbits);
- if (max_symbol > num_symbols) {
- goto End;
- }
- } else {
- max_symbol = num_symbols;
- }
-
- symbol = 0;
- while (symbol < num_symbols) {
- const HuffmanCode* p;
- int code_len;
- if (max_symbol-- == 0) break;
- VP8LFillBitWindow(br);
- p = &table[VP8LPrefetchBits(br) & LENGTHS_TABLE_MASK];
- VP8LSetBitPos(br, br->bit_pos_ + p->bits);
- code_len = p->value;
- if (code_len < kCodeLengthLiterals) {
- code_lengths[symbol++] = code_len;
- if (code_len != 0) prev_code_len = code_len;
- } else {
- const int use_prev = (code_len == kCodeLengthRepeatCode);
- const int slot = code_len - kCodeLengthLiterals;
- const int extra_bits = kCodeLengthExtraBits[slot];
- const int repeat_offset = kCodeLengthRepeatOffsets[slot];
- int repeat = VP8LReadBits(br, extra_bits) + repeat_offset;
- if (symbol + repeat > num_symbols) {
- goto End;
- } else {
- const int length = use_prev ? prev_code_len : 0;
- while (repeat-- > 0) code_lengths[symbol++] = length;
- }
- }
- }
- ok = 1;
-
- End:
- if (!ok) dec->status_ = VP8_STATUS_BITSTREAM_ERROR;
- return ok;
-}
-
-// 'code_lengths' is pre-allocated temporary buffer, used for creating Huffman
-// tree.
-static int ReadHuffmanCode(int alphabet_size, VP8LDecoder* const dec,
- int* const code_lengths, HuffmanCode* const table) {
- int ok = 0;
- int size = 0;
- VP8LBitReader* const br = &dec->br_;
- const int simple_code = VP8LReadBits(br, 1);
-
- memset(code_lengths, 0, alphabet_size * sizeof(*code_lengths));
-
- if (simple_code) { // Read symbols, codes & code lengths directly.
- const int num_symbols = VP8LReadBits(br, 1) + 1;
- const int first_symbol_len_code = VP8LReadBits(br, 1);
- // The first code is either 1 bit or 8 bit code.
- int symbol = VP8LReadBits(br, (first_symbol_len_code == 0) ? 1 : 8);
- code_lengths[symbol] = 1;
- // The second code (if present), is always 8 bit long.
- if (num_symbols == 2) {
- symbol = VP8LReadBits(br, 8);
- code_lengths[symbol] = 1;
- }
- ok = 1;
- } else { // Decode Huffman-coded code lengths.
- int i;
- int code_length_code_lengths[NUM_CODE_LENGTH_CODES] = { 0 };
- const int num_codes = VP8LReadBits(br, 4) + 4;
- if (num_codes > NUM_CODE_LENGTH_CODES) {
- dec->status_ = VP8_STATUS_BITSTREAM_ERROR;
- return 0;
- }
-
- for (i = 0; i < num_codes; ++i) {
- code_length_code_lengths[kCodeLengthCodeOrder[i]] = VP8LReadBits(br, 3);
- }
- ok = ReadHuffmanCodeLengths(dec, code_length_code_lengths, alphabet_size,
- code_lengths);
- }
-
- ok = ok && !br->eos_;
- if (ok) {
- size = VP8LBuildHuffmanTable(table, HUFFMAN_TABLE_BITS,
- code_lengths, alphabet_size);
- }
- if (!ok || size == 0) {
- dec->status_ = VP8_STATUS_BITSTREAM_ERROR;
- return 0;
- }
- return size;
-}
-
-static int ReadHuffmanCodes(VP8LDecoder* const dec, int xsize, int ysize,
- int color_cache_bits, int allow_recursion) {
- int i, j;
- VP8LBitReader* const br = &dec->br_;
- VP8LMetadata* const hdr = &dec->hdr_;
- uint32_t* huffman_image = NULL;
- HTreeGroup* htree_groups = NULL;
- HuffmanCode* huffman_tables = NULL;
- HuffmanCode* huffman_table = NULL;
- int num_htree_groups = 1;
- int num_htree_groups_max = 1;
- int max_alphabet_size = 0;
- int* code_lengths = NULL;
- const int table_size = kTableSize[color_cache_bits];
- int* mapping = NULL;
- int ok = 0;
-
- if (allow_recursion && VP8LReadBits(br, 1)) {
- // use meta Huffman codes.
- const int huffman_precision = VP8LReadBits(br, 3) + 2;
- const int huffman_xsize = VP8LSubSampleSize(xsize, huffman_precision);
- const int huffman_ysize = VP8LSubSampleSize(ysize, huffman_precision);
- const int huffman_pixs = huffman_xsize * huffman_ysize;
- if (!DecodeImageStream(huffman_xsize, huffman_ysize, 0, dec,
- &huffman_image)) {
- goto Error;
- }
- hdr->huffman_subsample_bits_ = huffman_precision;
- for (i = 0; i < huffman_pixs; ++i) {
- // The huffman data is stored in red and green bytes.
- const int group = (huffman_image[i] >> 8) & 0xffff;
- huffman_image[i] = group;
- if (group >= num_htree_groups_max) {
- num_htree_groups_max = group + 1;
- }
- }
- // Check the validity of num_htree_groups_max. If it seems too big, use a
- // smaller value for later. This will prevent big memory allocations to end
- // up with a bad bitstream anyway.
- // The value of 1000 is totally arbitrary. We know that num_htree_groups_max
- // is smaller than (1 << 16) and should be smaller than the number of pixels
- // (though the format allows it to be bigger).
- if (num_htree_groups_max > 1000 || num_htree_groups_max > xsize * ysize) {
- // Create a mapping from the used indices to the minimal set of used
- // values [0, num_htree_groups)
- mapping = (int*)WebPSafeMalloc(num_htree_groups_max, sizeof(*mapping));
- if (mapping == NULL) {
- dec->status_ = VP8_STATUS_OUT_OF_MEMORY;
- goto Error;
- }
- // -1 means a value is unmapped, and therefore unused in the Huffman
- // image.
- memset(mapping, 0xff, num_htree_groups_max * sizeof(*mapping));
- for (num_htree_groups = 0, i = 0; i < huffman_pixs; ++i) {
- // Get the current mapping for the group and remap the Huffman image.
- int* const mapped_group = &mapping[huffman_image[i]];
- if (*mapped_group == -1) *mapped_group = num_htree_groups++;
- huffman_image[i] = *mapped_group;
- }
- } else {
- num_htree_groups = num_htree_groups_max;
- }
- }
-
- if (br->eos_) goto Error;
-
- // Find maximum alphabet size for the htree group.
- for (j = 0; j < HUFFMAN_CODES_PER_META_CODE; ++j) {
- int alphabet_size = kAlphabetSize[j];
- if (j == 0 && color_cache_bits > 0) {
- alphabet_size += 1 << color_cache_bits;
- }
- if (max_alphabet_size < alphabet_size) {
- max_alphabet_size = alphabet_size;
- }
- }
-
- code_lengths = (int*)WebPSafeCalloc((uint64_t)max_alphabet_size,
- sizeof(*code_lengths));
- huffman_tables = (HuffmanCode*)WebPSafeMalloc(num_htree_groups * table_size,
- sizeof(*huffman_tables));
- htree_groups = VP8LHtreeGroupsNew(num_htree_groups);
-
- if (htree_groups == NULL || code_lengths == NULL || huffman_tables == NULL) {
- dec->status_ = VP8_STATUS_OUT_OF_MEMORY;
- goto Error;
- }
-
- huffman_table = huffman_tables;
- for (i = 0; i < num_htree_groups_max; ++i) {
- // If the index "i" is unused in the Huffman image, just make sure the
- // coefficients are valid but do not store them.
- if (mapping != NULL && mapping[i] == -1) {
- for (j = 0; j < HUFFMAN_CODES_PER_META_CODE; ++j) {
- int alphabet_size = kAlphabetSize[j];
- if (j == 0 && color_cache_bits > 0) {
- alphabet_size += (1 << color_cache_bits);
- }
- // Passing in NULL so that nothing gets filled.
- if (!ReadHuffmanCode(alphabet_size, dec, code_lengths, NULL)) {
- goto Error;
- }
- }
- } else {
- HTreeGroup* const htree_group =
- &htree_groups[(mapping == NULL) ? i : mapping[i]];
- HuffmanCode** const htrees = htree_group->htrees;
- int size;
- int total_size = 0;
- int is_trivial_literal = 1;
- int max_bits = 0;
- for (j = 0; j < HUFFMAN_CODES_PER_META_CODE; ++j) {
- int alphabet_size = kAlphabetSize[j];
- htrees[j] = huffman_table;
- if (j == 0 && color_cache_bits > 0) {
- alphabet_size += (1 << color_cache_bits);
- }
- size = ReadHuffmanCode(alphabet_size, dec, code_lengths, huffman_table);
- if (size == 0) {
- goto Error;
- }
- if (is_trivial_literal && kLiteralMap[j] == 1) {
- is_trivial_literal = (huffman_table->bits == 0);
- }
- total_size += huffman_table->bits;
- huffman_table += size;
- if (j <= ALPHA) {
- int local_max_bits = code_lengths[0];
- int k;
- for (k = 1; k < alphabet_size; ++k) {
- if (code_lengths[k] > local_max_bits) {
- local_max_bits = code_lengths[k];
- }
- }
- max_bits += local_max_bits;
- }
- }
- htree_group->is_trivial_literal = is_trivial_literal;
- htree_group->is_trivial_code = 0;
- if (is_trivial_literal) {
- const int red = htrees[RED][0].value;
- const int blue = htrees[BLUE][0].value;
- const int alpha = htrees[ALPHA][0].value;
- htree_group->literal_arb = ((uint32_t)alpha << 24) | (red << 16) | blue;
- if (total_size == 0 && htrees[GREEN][0].value < NUM_LITERAL_CODES) {
- htree_group->is_trivial_code = 1;
- htree_group->literal_arb |= htrees[GREEN][0].value << 8;
- }
- }
- htree_group->use_packed_table =
- !htree_group->is_trivial_code && (max_bits < HUFFMAN_PACKED_BITS);
- if (htree_group->use_packed_table) BuildPackedTable(htree_group);
- }
- }
- ok = 1;
-
- // All OK. Finalize pointers.
- hdr->huffman_image_ = huffman_image;
- hdr->num_htree_groups_ = num_htree_groups;
- hdr->htree_groups_ = htree_groups;
- hdr->huffman_tables_ = huffman_tables;
-
- Error:
- WebPSafeFree(code_lengths);
- WebPSafeFree(mapping);
- if (!ok) {
- WebPSafeFree(huffman_image);
- WebPSafeFree(huffman_tables);
- VP8LHtreeGroupsFree(htree_groups);
- }
- return ok;
-}
-
-//------------------------------------------------------------------------------
-// Scaling.
-
-#if !defined(WEBP_REDUCE_SIZE)
-static int AllocateAndInitRescaler(VP8LDecoder* const dec, VP8Io* const io) {
- const int num_channels = 4;
- const int in_width = io->mb_w;
- const int out_width = io->scaled_width;
- const int in_height = io->mb_h;
- const int out_height = io->scaled_height;
- const uint64_t work_size = 2 * num_channels * (uint64_t)out_width;
- rescaler_t* work; // Rescaler work area.
- const uint64_t scaled_data_size = (uint64_t)out_width;
- uint32_t* scaled_data; // Temporary storage for scaled BGRA data.
- const uint64_t memory_size = sizeof(*dec->rescaler) +
- work_size * sizeof(*work) +
- scaled_data_size * sizeof(*scaled_data);
- uint8_t* memory = (uint8_t*)WebPSafeMalloc(memory_size, sizeof(*memory));
- if (memory == NULL) {
- dec->status_ = VP8_STATUS_OUT_OF_MEMORY;
- return 0;
- }
- assert(dec->rescaler_memory == NULL);
- dec->rescaler_memory = memory;
-
- dec->rescaler = (WebPRescaler*)memory;
- memory += sizeof(*dec->rescaler);
- work = (rescaler_t*)memory;
- memory += work_size * sizeof(*work);
- scaled_data = (uint32_t*)memory;
-
- if (!WebPRescalerInit(dec->rescaler, in_width, in_height,
- (uint8_t*)scaled_data, out_width, out_height,
- 0, num_channels, work)) {
- return 0;
- }
- return 1;
-}
-#endif // WEBP_REDUCE_SIZE
-
-//------------------------------------------------------------------------------
-// Export to ARGB
-
-#if !defined(WEBP_REDUCE_SIZE)
-
-// We have special "export" function since we need to convert from BGRA
-static int Export(WebPRescaler* const rescaler, WEBP_CSP_MODE colorspace,
- int rgba_stride, uint8_t* const rgba) {
- uint32_t* const src = (uint32_t*)rescaler->dst;
- uint8_t* dst = rgba;
- const int dst_width = rescaler->dst_width;
- int num_lines_out = 0;
- while (WebPRescalerHasPendingOutput(rescaler)) {
- WebPRescalerExportRow(rescaler);
- WebPMultARGBRow(src, dst_width, 1);
- VP8LConvertFromBGRA(src, dst_width, colorspace, dst);
- dst += rgba_stride;
- ++num_lines_out;
- }
- return num_lines_out;
-}
-
-// Emit scaled rows.
-static int EmitRescaledRowsRGBA(const VP8LDecoder* const dec,
- uint8_t* in, int in_stride, int mb_h,
- uint8_t* const out, int out_stride) {
- const WEBP_CSP_MODE colorspace = dec->output_->colorspace;
- int num_lines_in = 0;
- int num_lines_out = 0;
- while (num_lines_in < mb_h) {
- uint8_t* const row_in = in + (uint64_t)num_lines_in * in_stride;
- uint8_t* const row_out = out + (uint64_t)num_lines_out * out_stride;
- const int lines_left = mb_h - num_lines_in;
- const int needed_lines = WebPRescaleNeededLines(dec->rescaler, lines_left);
- int lines_imported;
- assert(needed_lines > 0 && needed_lines <= lines_left);
- WebPMultARGBRows(row_in, in_stride,
- dec->rescaler->src_width, needed_lines, 0);
- lines_imported =
- WebPRescalerImport(dec->rescaler, lines_left, row_in, in_stride);
- assert(lines_imported == needed_lines);
- num_lines_in += lines_imported;
- num_lines_out += Export(dec->rescaler, colorspace, out_stride, row_out);
- }
- return num_lines_out;
-}
-
-#endif // WEBP_REDUCE_SIZE
-
-// Emit rows without any scaling.
-static int EmitRows(WEBP_CSP_MODE colorspace,
- const uint8_t* row_in, int in_stride,
- int mb_w, int mb_h,
- uint8_t* const out, int out_stride) {
- int lines = mb_h;
- uint8_t* row_out = out;
- while (lines-- > 0) {
- VP8LConvertFromBGRA((const uint32_t*)row_in, mb_w, colorspace, row_out);
- row_in += in_stride;
- row_out += out_stride;
- }
- return mb_h; // Num rows out == num rows in.
-}
-
-//------------------------------------------------------------------------------
-// Export to YUVA
-
-static void ConvertToYUVA(const uint32_t* const src, int width, int y_pos,
- const WebPDecBuffer* const output) {
- const WebPYUVABuffer* const buf = &output->u.YUVA;
-
- // first, the luma plane
- WebPConvertARGBToY(src, buf->y + y_pos * buf->y_stride, width);
-
- // then U/V planes
- {
- uint8_t* const u = buf->u + (y_pos >> 1) * buf->u_stride;
- uint8_t* const v = buf->v + (y_pos >> 1) * buf->v_stride;
- // even lines: store values
- // odd lines: average with previous values
- WebPConvertARGBToUV(src, u, v, width, !(y_pos & 1));
- }
- // Lastly, store alpha if needed.
- if (buf->a != NULL) {
- uint8_t* const a = buf->a + y_pos * buf->a_stride;
-#if defined(WORDS_BIGENDIAN)
- WebPExtractAlpha((uint8_t*)src + 0, 0, width, 1, a, 0);
-#else
- WebPExtractAlpha((uint8_t*)src + 3, 0, width, 1, a, 0);
-#endif
- }
-}
-
-static int ExportYUVA(const VP8LDecoder* const dec, int y_pos) {
- WebPRescaler* const rescaler = dec->rescaler;
- uint32_t* const src = (uint32_t*)rescaler->dst;
- const int dst_width = rescaler->dst_width;
- int num_lines_out = 0;
- while (WebPRescalerHasPendingOutput(rescaler)) {
- WebPRescalerExportRow(rescaler);
- WebPMultARGBRow(src, dst_width, 1);
- ConvertToYUVA(src, dst_width, y_pos, dec->output_);
- ++y_pos;
- ++num_lines_out;
- }
- return num_lines_out;
-}
-
-static int EmitRescaledRowsYUVA(const VP8LDecoder* const dec,
- uint8_t* in, int in_stride, int mb_h) {
- int num_lines_in = 0;
- int y_pos = dec->last_out_row_;
- while (num_lines_in < mb_h) {
- const int lines_left = mb_h - num_lines_in;
- const int needed_lines = WebPRescaleNeededLines(dec->rescaler, lines_left);
- int lines_imported;
- WebPMultARGBRows(in, in_stride, dec->rescaler->src_width, needed_lines, 0);
- lines_imported =
- WebPRescalerImport(dec->rescaler, lines_left, in, in_stride);
- assert(lines_imported == needed_lines);
- num_lines_in += lines_imported;
- in += needed_lines * in_stride;
- y_pos += ExportYUVA(dec, y_pos);
- }
- return y_pos;
-}
-
-static int EmitRowsYUVA(const VP8LDecoder* const dec,
- const uint8_t* in, int in_stride,
- int mb_w, int num_rows) {
- int y_pos = dec->last_out_row_;
- while (num_rows-- > 0) {
- ConvertToYUVA((const uint32_t*)in, mb_w, y_pos, dec->output_);
- in += in_stride;
- ++y_pos;
- }
- return y_pos;
-}
-
-//------------------------------------------------------------------------------
-// Cropping.
-
-// Sets io->mb_y, io->mb_h & io->mb_w according to start row, end row and
-// crop options. Also updates the input data pointer, so that it points to the
-// start of the cropped window. Note that pixels are in ARGB format even if
-// 'in_data' is uint8_t*.
-// Returns true if the crop window is not empty.
-static int SetCropWindow(VP8Io* const io, int y_start, int y_end,
- uint8_t** const in_data, int pixel_stride) {
- assert(y_start < y_end);
- assert(io->crop_left < io->crop_right);
- if (y_end > io->crop_bottom) {
- y_end = io->crop_bottom; // make sure we don't overflow on last row.
- }
- if (y_start < io->crop_top) {
- const int delta = io->crop_top - y_start;
- y_start = io->crop_top;
- *in_data += delta * pixel_stride;
- }
- if (y_start >= y_end) return 0; // Crop window is empty.
-
- *in_data += io->crop_left * sizeof(uint32_t);
-
- io->mb_y = y_start - io->crop_top;
- io->mb_w = io->crop_right - io->crop_left;
- io->mb_h = y_end - y_start;
- return 1; // Non-empty crop window.
-}
-
-//------------------------------------------------------------------------------
-
-static WEBP_INLINE int GetMetaIndex(
- const uint32_t* const image, int xsize, int bits, int x, int y) {
- if (bits == 0) return 0;
- return image[xsize * (y >> bits) + (x >> bits)];
-}
-
-static WEBP_INLINE HTreeGroup* GetHtreeGroupForPos(VP8LMetadata* const hdr,
- int x, int y) {
- const int meta_index = GetMetaIndex(hdr->huffman_image_, hdr->huffman_xsize_,
- hdr->huffman_subsample_bits_, x, y);
- assert(meta_index < hdr->num_htree_groups_);
- return hdr->htree_groups_ + meta_index;
-}
-
-//------------------------------------------------------------------------------
-// Main loop, with custom row-processing function
-
-typedef void (*ProcessRowsFunc)(VP8LDecoder* const dec, int row);
-
-static void ApplyInverseTransforms(VP8LDecoder* const dec,
- int start_row, int num_rows,
- const uint32_t* const rows) {
- int n = dec->next_transform_;
- const int cache_pixs = dec->width_ * num_rows;
- const int end_row = start_row + num_rows;
- const uint32_t* rows_in = rows;
- uint32_t* const rows_out = dec->argb_cache_;
-
- // Inverse transforms.
- while (n-- > 0) {
- VP8LTransform* const transform = &dec->transforms_[n];
- VP8LInverseTransform(transform, start_row, end_row, rows_in, rows_out);
- rows_in = rows_out;
- }
- if (rows_in != rows_out) {
- // No transform called, hence just copy.
- memcpy(rows_out, rows_in, cache_pixs * sizeof(*rows_out));
- }
-}
-
-// Processes (transforms, scales & color-converts) the rows decoded after the
-// last call.
-static void ProcessRows(VP8LDecoder* const dec, int row) {
- const uint32_t* const rows = dec->pixels_ + dec->width_ * dec->last_row_;
- const int num_rows = row - dec->last_row_;
-
- assert(row <= dec->io_->crop_bottom);
- // We can't process more than NUM_ARGB_CACHE_ROWS at a time (that's the size
- // of argb_cache_), but we currently don't need more than that.
- assert(num_rows <= NUM_ARGB_CACHE_ROWS);
- if (num_rows > 0) { // Emit output.
- VP8Io* const io = dec->io_;
- uint8_t* rows_data = (uint8_t*)dec->argb_cache_;
- const int in_stride = io->width * sizeof(uint32_t); // in unit of RGBA
- ApplyInverseTransforms(dec, dec->last_row_, num_rows, rows);
- if (!SetCropWindow(io, dec->last_row_, row, &rows_data, in_stride)) {
- // Nothing to output (this time).
- } else {
- const WebPDecBuffer* const output = dec->output_;
- if (WebPIsRGBMode(output->colorspace)) { // convert to RGBA
- const WebPRGBABuffer* const buf = &output->u.RGBA;
- uint8_t* const rgba =
- buf->rgba + (int64_t)dec->last_out_row_ * buf->stride;
- const int num_rows_out =
-#if !defined(WEBP_REDUCE_SIZE)
- io->use_scaling ?
- EmitRescaledRowsRGBA(dec, rows_data, in_stride, io->mb_h,
- rgba, buf->stride) :
-#endif // WEBP_REDUCE_SIZE
- EmitRows(output->colorspace, rows_data, in_stride,
- io->mb_w, io->mb_h, rgba, buf->stride);
- // Update 'last_out_row_'.
- dec->last_out_row_ += num_rows_out;
- } else { // convert to YUVA
- dec->last_out_row_ = io->use_scaling ?
- EmitRescaledRowsYUVA(dec, rows_data, in_stride, io->mb_h) :
- EmitRowsYUVA(dec, rows_data, in_stride, io->mb_w, io->mb_h);
- }
- assert(dec->last_out_row_ <= output->height);
- }
- }
-
- // Update 'last_row_'.
- dec->last_row_ = row;
- assert(dec->last_row_ <= dec->height_);
-}
-
-// Row-processing for the special case when alpha data contains only one
-// transform (color indexing), and trivial non-green literals.
-static int Is8bOptimizable(const VP8LMetadata* const hdr) {
- int i;
- if (hdr->color_cache_size_ > 0) return 0;
- // When the Huffman tree contains only one symbol, we can skip the
- // call to ReadSymbol() for red/blue/alpha channels.
- for (i = 0; i < hdr->num_htree_groups_; ++i) {
- HuffmanCode** const htrees = hdr->htree_groups_[i].htrees;
- if (htrees[RED][0].bits > 0) return 0;
- if (htrees[BLUE][0].bits > 0) return 0;
- if (htrees[ALPHA][0].bits > 0) return 0;
- }
- return 1;
-}
-
-static void AlphaApplyFilter(ALPHDecoder* const alph_dec,
- int first_row, int last_row,
- uint8_t* out, int stride) {
- if (alph_dec->filter_ != WEBP_FILTER_NONE) {
- int y;
- const uint8_t* prev_line = alph_dec->prev_line_;
- assert(WebPUnfilters[alph_dec->filter_] != NULL);
- for (y = first_row; y < last_row; ++y) {
- WebPUnfilters[alph_dec->filter_](prev_line, out, out, stride);
- prev_line = out;
- out += stride;
- }
- alph_dec->prev_line_ = prev_line;
- }
-}
-
-static void ExtractPalettedAlphaRows(VP8LDecoder* const dec, int last_row) {
- // For vertical and gradient filtering, we need to decode the part above the
- // crop_top row, in order to have the correct spatial predictors.
- ALPHDecoder* const alph_dec = (ALPHDecoder*)dec->io_->opaque;
- const int top_row =
- (alph_dec->filter_ == WEBP_FILTER_NONE ||
- alph_dec->filter_ == WEBP_FILTER_HORIZONTAL) ? dec->io_->crop_top
- : dec->last_row_;
- const int first_row = (dec->last_row_ < top_row) ? top_row : dec->last_row_;
- assert(last_row <= dec->io_->crop_bottom);
- if (last_row > first_row) {
- // Special method for paletted alpha data. We only process the cropped area.
- const int width = dec->io_->width;
- uint8_t* out = alph_dec->output_ + width * first_row;
- const uint8_t* const in =
- (uint8_t*)dec->pixels_ + dec->width_ * first_row;
- VP8LTransform* const transform = &dec->transforms_[0];
- assert(dec->next_transform_ == 1);
- assert(transform->type_ == COLOR_INDEXING_TRANSFORM);
- VP8LColorIndexInverseTransformAlpha(transform, first_row, last_row,
- in, out);
- AlphaApplyFilter(alph_dec, first_row, last_row, out, width);
- }
- dec->last_row_ = dec->last_out_row_ = last_row;
-}
-
-//------------------------------------------------------------------------------
-// Helper functions for fast pattern copy (8b and 32b)
-
-// cyclic rotation of pattern word
-static WEBP_INLINE uint32_t Rotate8b(uint32_t V) {
-#if defined(WORDS_BIGENDIAN)
- return ((V & 0xff000000u) >> 24) | (V << 8);
-#else
- return ((V & 0xffu) << 24) | (V >> 8);
-#endif
-}
-
-// copy 1, 2 or 4-bytes pattern
-static WEBP_INLINE void CopySmallPattern8b(const uint8_t* src, uint8_t* dst,
- int length, uint32_t pattern) {
- int i;
- // align 'dst' to 4-bytes boundary. Adjust the pattern along the way.
- while ((uintptr_t)dst & 3) {
- *dst++ = *src++;
- pattern = Rotate8b(pattern);
- --length;
- }
- // Copy the pattern 4 bytes at a time.
- for (i = 0; i < (length >> 2); ++i) {
- ((uint32_t*)dst)[i] = pattern;
- }
- // Finish with left-overs. 'pattern' is still correctly positioned,
- // so no Rotate8b() call is needed.
- for (i <<= 2; i < length; ++i) {
- dst[i] = src[i];
- }
-}
-
-static WEBP_INLINE void CopyBlock8b(uint8_t* const dst, int dist, int length) {
- const uint8_t* src = dst - dist;
- if (length >= 8) {
- uint32_t pattern = 0;
- switch (dist) {
- case 1:
- pattern = src[0];
-#if defined(__arm__) || defined(_M_ARM) // arm doesn't like multiply that much
- pattern |= pattern << 8;
- pattern |= pattern << 16;
-#elif defined(WEBP_USE_MIPS_DSP_R2)
- __asm__ volatile ("replv.qb %0, %0" : "+r"(pattern));
-#else
- pattern = 0x01010101u * pattern;
-#endif
- break;
- case 2:
-#if !defined(WORDS_BIGENDIAN)
- memcpy(&pattern, src, sizeof(uint16_t));
-#else
- pattern = ((uint32_t)src[0] << 8) | src[1];
-#endif
-#if defined(__arm__) || defined(_M_ARM)
- pattern |= pattern << 16;
-#elif defined(WEBP_USE_MIPS_DSP_R2)
- __asm__ volatile ("replv.ph %0, %0" : "+r"(pattern));
-#else
- pattern = 0x00010001u * pattern;
-#endif
- break;
- case 4:
- memcpy(&pattern, src, sizeof(uint32_t));
- break;
- default:
- goto Copy;
- }
- CopySmallPattern8b(src, dst, length, pattern);
- return;
- }
- Copy:
- if (dist >= length) { // no overlap -> use memcpy()
- memcpy(dst, src, length * sizeof(*dst));
- } else {
- int i;
- for (i = 0; i < length; ++i) dst[i] = src[i];
- }
-}
-
-// copy pattern of 1 or 2 uint32_t's
-static WEBP_INLINE void CopySmallPattern32b(const uint32_t* src,
- uint32_t* dst,
- int length, uint64_t pattern) {
- int i;
- if ((uintptr_t)dst & 4) { // Align 'dst' to 8-bytes boundary.
- *dst++ = *src++;
- pattern = (pattern >> 32) | (pattern << 32);
- --length;
- }
- assert(0 == ((uintptr_t)dst & 7));
- for (i = 0; i < (length >> 1); ++i) {
- ((uint64_t*)dst)[i] = pattern; // Copy the pattern 8 bytes at a time.
- }
- if (length & 1) { // Finish with left-over.
- dst[i << 1] = src[i << 1];
- }
-}
-
-static WEBP_INLINE void CopyBlock32b(uint32_t* const dst,
- int dist, int length) {
- const uint32_t* const src = dst - dist;
- if (dist <= 2 && length >= 4 && ((uintptr_t)dst & 3) == 0) {
- uint64_t pattern;
- if (dist == 1) {
- pattern = (uint64_t)src[0];
- pattern |= pattern << 32;
- } else {
- memcpy(&pattern, src, sizeof(pattern));
- }
- CopySmallPattern32b(src, dst, length, pattern);
- } else if (dist >= length) { // no overlap
- memcpy(dst, src, length * sizeof(*dst));
- } else {
- int i;
- for (i = 0; i < length; ++i) dst[i] = src[i];
- }
-}
-
-//------------------------------------------------------------------------------
-
-static int DecodeAlphaData(VP8LDecoder* const dec, uint8_t* const data,
- int width, int height, int last_row) {
- int ok = 1;
- int row = dec->last_pixel_ / width;
- int col = dec->last_pixel_ % width;
- VP8LBitReader* const br = &dec->br_;
- VP8LMetadata* const hdr = &dec->hdr_;
- int pos = dec->last_pixel_; // current position
- const int end = width * height; // End of data
- const int last = width * last_row; // Last pixel to decode
- const int len_code_limit = NUM_LITERAL_CODES + NUM_LENGTH_CODES;
- const int mask = hdr->huffman_mask_;
- const HTreeGroup* htree_group =
- (pos < last) ? GetHtreeGroupForPos(hdr, col, row) : NULL;
- assert(pos <= end);
- assert(last_row <= height);
- assert(Is8bOptimizable(hdr));
-
- while (!br->eos_ && pos < last) {
- int code;
- // Only update when changing tile.
- if ((col & mask) == 0) {
- htree_group = GetHtreeGroupForPos(hdr, col, row);
- }
- assert(htree_group != NULL);
- VP8LFillBitWindow(br);
- code = ReadSymbol(htree_group->htrees[GREEN], br);
- if (code < NUM_LITERAL_CODES) { // Literal
- data[pos] = code;
- ++pos;
- ++col;
- if (col >= width) {
- col = 0;
- ++row;
- if (row <= last_row && (row % NUM_ARGB_CACHE_ROWS == 0)) {
- ExtractPalettedAlphaRows(dec, row);
- }
- }
- } else if (code < len_code_limit) { // Backward reference
- int dist_code, dist;
- const int length_sym = code - NUM_LITERAL_CODES;
- const int length = GetCopyLength(length_sym, br);
- const int dist_symbol = ReadSymbol(htree_group->htrees[DIST], br);
- VP8LFillBitWindow(br);
- dist_code = GetCopyDistance(dist_symbol, br);
- dist = PlaneCodeToDistance(width, dist_code);
- if (pos >= dist && end - pos >= length) {
- CopyBlock8b(data + pos, dist, length);
- } else {
- ok = 0;
- goto End;
- }
- pos += length;
- col += length;
- while (col >= width) {
- col -= width;
- ++row;
- if (row <= last_row && (row % NUM_ARGB_CACHE_ROWS == 0)) {
- ExtractPalettedAlphaRows(dec, row);
- }
- }
- if (pos < last && (col & mask)) {
- htree_group = GetHtreeGroupForPos(hdr, col, row);
- }
- } else { // Not reached
- ok = 0;
- goto End;
- }
- br->eos_ = VP8LIsEndOfStream(br);
- }
- // Process the remaining rows corresponding to last row-block.
- ExtractPalettedAlphaRows(dec, row > last_row ? last_row : row);
-
- End:
- br->eos_ = VP8LIsEndOfStream(br);
- if (!ok || (br->eos_ && pos < end)) {
- ok = 0;
- dec->status_ = br->eos_ ? VP8_STATUS_SUSPENDED
- : VP8_STATUS_BITSTREAM_ERROR;
- } else {
- dec->last_pixel_ = pos;
- }
- return ok;
-}
-
-static void SaveState(VP8LDecoder* const dec, int last_pixel) {
- assert(dec->incremental_);
- dec->saved_br_ = dec->br_;
- dec->saved_last_pixel_ = last_pixel;
- if (dec->hdr_.color_cache_size_ > 0) {
- VP8LColorCacheCopy(&dec->hdr_.color_cache_, &dec->hdr_.saved_color_cache_);
- }
-}
-
-static void RestoreState(VP8LDecoder* const dec) {
- assert(dec->br_.eos_);
- dec->status_ = VP8_STATUS_SUSPENDED;
- dec->br_ = dec->saved_br_;
- dec->last_pixel_ = dec->saved_last_pixel_;
- if (dec->hdr_.color_cache_size_ > 0) {
- VP8LColorCacheCopy(&dec->hdr_.saved_color_cache_, &dec->hdr_.color_cache_);
- }
-}
-
-#define SYNC_EVERY_N_ROWS 8 // minimum number of rows between check-points
-static int DecodeImageData(VP8LDecoder* const dec, uint32_t* const data,
- int width, int height, int last_row,
- ProcessRowsFunc process_func) {
- int row = dec->last_pixel_ / width;
- int col = dec->last_pixel_ % width;
- VP8LBitReader* const br = &dec->br_;
- VP8LMetadata* const hdr = &dec->hdr_;
- uint32_t* src = data + dec->last_pixel_;
- uint32_t* last_cached = src;
- uint32_t* const src_end = data + width * height; // End of data
- uint32_t* const src_last = data + width * last_row; // Last pixel to decode
- const int len_code_limit = NUM_LITERAL_CODES + NUM_LENGTH_CODES;
- const int color_cache_limit = len_code_limit + hdr->color_cache_size_;
- int next_sync_row = dec->incremental_ ? row : 1 << 24;
- VP8LColorCache* const color_cache =
- (hdr->color_cache_size_ > 0) ? &hdr->color_cache_ : NULL;
- const int mask = hdr->huffman_mask_;
- const HTreeGroup* htree_group =
- (src < src_last) ? GetHtreeGroupForPos(hdr, col, row) : NULL;
- assert(dec->last_row_ < last_row);
- assert(src_last <= src_end);
-
- while (src < src_last) {
- int code;
- if (row >= next_sync_row) {
- SaveState(dec, (int)(src - data));
- next_sync_row = row + SYNC_EVERY_N_ROWS;
- }
- // Only update when changing tile. Note we could use this test:
- // if "((((prev_col ^ col) | prev_row ^ row)) > mask)" -> tile changed
- // but that's actually slower and needs storing the previous col/row.
- if ((col & mask) == 0) {
- htree_group = GetHtreeGroupForPos(hdr, col, row);
- }
- assert(htree_group != NULL);
- if (htree_group->is_trivial_code) {
- *src = htree_group->literal_arb;
- goto AdvanceByOne;
- }
- VP8LFillBitWindow(br);
- if (htree_group->use_packed_table) {
- code = ReadPackedSymbols(htree_group, br, src);
- if (VP8LIsEndOfStream(br)) break;
- if (code == PACKED_NON_LITERAL_CODE) goto AdvanceByOne;
- } else {
- code = ReadSymbol(htree_group->htrees[GREEN], br);
- }
- if (VP8LIsEndOfStream(br)) break;
- if (code < NUM_LITERAL_CODES) { // Literal
- if (htree_group->is_trivial_literal) {
- *src = htree_group->literal_arb | (code << 8);
- } else {
- int red, blue, alpha;
- red = ReadSymbol(htree_group->htrees[RED], br);
- VP8LFillBitWindow(br);
- blue = ReadSymbol(htree_group->htrees[BLUE], br);
- alpha = ReadSymbol(htree_group->htrees[ALPHA], br);
- if (VP8LIsEndOfStream(br)) break;
- *src = ((uint32_t)alpha << 24) | (red << 16) | (code << 8) | blue;
- }
- AdvanceByOne:
- ++src;
- ++col;
- if (col >= width) {
- col = 0;
- ++row;
- if (process_func != NULL) {
- if (row <= last_row && (row % NUM_ARGB_CACHE_ROWS == 0)) {
- process_func(dec, row);
- }
- }
- if (color_cache != NULL) {
- while (last_cached < src) {
- VP8LColorCacheInsert(color_cache, *last_cached++);
- }
- }
- }
- } else if (code < len_code_limit) { // Backward reference
- int dist_code, dist;
- const int length_sym = code - NUM_LITERAL_CODES;
- const int length = GetCopyLength(length_sym, br);
- const int dist_symbol = ReadSymbol(htree_group->htrees[DIST], br);
- VP8LFillBitWindow(br);
- dist_code = GetCopyDistance(dist_symbol, br);
- dist = PlaneCodeToDistance(width, dist_code);
-
- if (VP8LIsEndOfStream(br)) break;
- if (src - data < (ptrdiff_t)dist || src_end - src < (ptrdiff_t)length) {
- goto Error;
- } else {
- CopyBlock32b(src, dist, length);
- }
- src += length;
- col += length;
- while (col >= width) {
- col -= width;
- ++row;
- if (process_func != NULL) {
- if (row <= last_row && (row % NUM_ARGB_CACHE_ROWS == 0)) {
- process_func(dec, row);
- }
- }
- }
- // Because of the check done above (before 'src' was incremented by
- // 'length'), the following holds true.
- assert(src <= src_end);
- if (col & mask) htree_group = GetHtreeGroupForPos(hdr, col, row);
- if (color_cache != NULL) {
- while (last_cached < src) {
- VP8LColorCacheInsert(color_cache, *last_cached++);
- }
- }
- } else if (code < color_cache_limit) { // Color cache
- const int key = code - len_code_limit;
- assert(color_cache != NULL);
- while (last_cached < src) {
- VP8LColorCacheInsert(color_cache, *last_cached++);
- }
- *src = VP8LColorCacheLookup(color_cache, key);
- goto AdvanceByOne;
- } else { // Not reached
- goto Error;
- }
- }
-
- br->eos_ = VP8LIsEndOfStream(br);
- if (dec->incremental_ && br->eos_ && src < src_end) {
- RestoreState(dec);
- } else if (!br->eos_) {
- // Process the remaining rows corresponding to last row-block.
- if (process_func != NULL) {
- process_func(dec, row > last_row ? last_row : row);
- }
- dec->status_ = VP8_STATUS_OK;
- dec->last_pixel_ = (int)(src - data); // end-of-scan marker
- } else {
- // if not incremental, and we are past the end of buffer (eos_=1), then this
- // is a real bitstream error.
- goto Error;
- }
- return 1;
-
- Error:
- dec->status_ = VP8_STATUS_BITSTREAM_ERROR;
- return 0;
-}
-
-// -----------------------------------------------------------------------------
-// VP8LTransform
-
-static void ClearTransform(VP8LTransform* const transform) {
- WebPSafeFree(transform->data_);
- transform->data_ = NULL;
-}
-
-// For security reason, we need to remap the color map to span
-// the total possible bundled values, and not just the num_colors.
-static int ExpandColorMap(int num_colors, VP8LTransform* const transform) {
- int i;
- const int final_num_colors = 1 << (8 >> transform->bits_);
- uint32_t* const new_color_map =
- (uint32_t*)WebPSafeMalloc((uint64_t)final_num_colors,
- sizeof(*new_color_map));
- if (new_color_map == NULL) {
- return 0;
- } else {
- uint8_t* const data = (uint8_t*)transform->data_;
- uint8_t* const new_data = (uint8_t*)new_color_map;
- new_color_map[0] = transform->data_[0];
- for (i = 4; i < 4 * num_colors; ++i) {
- // Equivalent to AddPixelEq(), on a byte-basis.
- new_data[i] = (data[i] + new_data[i - 4]) & 0xff;
- }
- for (; i < 4 * final_num_colors; ++i) {
- new_data[i] = 0; // black tail.
- }
- WebPSafeFree(transform->data_);
- transform->data_ = new_color_map;
- }
- return 1;
-}
-
-static int ReadTransform(int* const xsize, int const* ysize,
- VP8LDecoder* const dec) {
- int ok = 1;
- VP8LBitReader* const br = &dec->br_;
- VP8LTransform* transform = &dec->transforms_[dec->next_transform_];
- const VP8LImageTransformType type =
- (VP8LImageTransformType)VP8LReadBits(br, 2);
-
- // Each transform type can only be present once in the stream.
- if (dec->transforms_seen_ & (1U << type)) {
- return 0; // Already there, let's not accept the second same transform.
- }
- dec->transforms_seen_ |= (1U << type);
-
- transform->type_ = type;
- transform->xsize_ = *xsize;
- transform->ysize_ = *ysize;
- transform->data_ = NULL;
- ++dec->next_transform_;
- assert(dec->next_transform_ <= NUM_TRANSFORMS);
-
- switch (type) {
- case PREDICTOR_TRANSFORM:
- case CROSS_COLOR_TRANSFORM:
- transform->bits_ = VP8LReadBits(br, 3) + 2;
- ok = DecodeImageStream(VP8LSubSampleSize(transform->xsize_,
- transform->bits_),
- VP8LSubSampleSize(transform->ysize_,
- transform->bits_),
- 0, dec, &transform->data_);
- break;
- case COLOR_INDEXING_TRANSFORM: {
- const int num_colors = VP8LReadBits(br, 8) + 1;
- const int bits = (num_colors > 16) ? 0
- : (num_colors > 4) ? 1
- : (num_colors > 2) ? 2
- : 3;
- *xsize = VP8LSubSampleSize(transform->xsize_, bits);
- transform->bits_ = bits;
- ok = DecodeImageStream(num_colors, 1, 0, dec, &transform->data_);
- ok = ok && ExpandColorMap(num_colors, transform);
- break;
- }
- case SUBTRACT_GREEN:
- break;
- default:
- assert(0); // can't happen
- break;
- }
-
- return ok;
-}
-
-// -----------------------------------------------------------------------------
-// VP8LMetadata
-
-static void InitMetadata(VP8LMetadata* const hdr) {
- assert(hdr != NULL);
- memset(hdr, 0, sizeof(*hdr));
-}
-
-static void ClearMetadata(VP8LMetadata* const hdr) {
- assert(hdr != NULL);
-
- WebPSafeFree(hdr->huffman_image_);
- WebPSafeFree(hdr->huffman_tables_);
- VP8LHtreeGroupsFree(hdr->htree_groups_);
- VP8LColorCacheClear(&hdr->color_cache_);
- VP8LColorCacheClear(&hdr->saved_color_cache_);
- InitMetadata(hdr);
-}
-
-// -----------------------------------------------------------------------------
-// VP8LDecoder
-
-VP8LDecoder* VP8LNew(void) {
- VP8LDecoder* const dec = (VP8LDecoder*)WebPSafeCalloc(1ULL, sizeof(*dec));
- if (dec == NULL) return NULL;
- dec->status_ = VP8_STATUS_OK;
- dec->state_ = READ_DIM;
-
- VP8LDspInit(); // Init critical function pointers.
-
- return dec;
-}
-
-void VP8LClear(VP8LDecoder* const dec) {
- int i;
- if (dec == NULL) return;
- ClearMetadata(&dec->hdr_);
-
- WebPSafeFree(dec->pixels_);
- dec->pixels_ = NULL;
- for (i = 0; i < dec->next_transform_; ++i) {
- ClearTransform(&dec->transforms_[i]);
- }
- dec->next_transform_ = 0;
- dec->transforms_seen_ = 0;
-
- WebPSafeFree(dec->rescaler_memory);
- dec->rescaler_memory = NULL;
-
- dec->output_ = NULL; // leave no trace behind
-}
-
-void VP8LDelete(VP8LDecoder* const dec) {
- if (dec != NULL) {
- VP8LClear(dec);
- WebPSafeFree(dec);
- }
-}
-
-static void UpdateDecoder(VP8LDecoder* const dec, int width, int height) {
- VP8LMetadata* const hdr = &dec->hdr_;
- const int num_bits = hdr->huffman_subsample_bits_;
- dec->width_ = width;
- dec->height_ = height;
-
- hdr->huffman_xsize_ = VP8LSubSampleSize(width, num_bits);
- hdr->huffman_mask_ = (num_bits == 0) ? ~0 : (1 << num_bits) - 1;
-}
-
-static int DecodeImageStream(int xsize, int ysize,
- int is_level0,
- VP8LDecoder* const dec,
- uint32_t** const decoded_data) {
- int ok = 1;
- int transform_xsize = xsize;
- int transform_ysize = ysize;
- VP8LBitReader* const br = &dec->br_;
- VP8LMetadata* const hdr = &dec->hdr_;
- uint32_t* data = NULL;
- int color_cache_bits = 0;
-
- // Read the transforms (may recurse).
- if (is_level0) {
- while (ok && VP8LReadBits(br, 1)) {
- ok = ReadTransform(&transform_xsize, &transform_ysize, dec);
- }
- }
-
- // Color cache
- if (ok && VP8LReadBits(br, 1)) {
- color_cache_bits = VP8LReadBits(br, 4);
- ok = (color_cache_bits >= 1 && color_cache_bits <= MAX_CACHE_BITS);
- if (!ok) {
- dec->status_ = VP8_STATUS_BITSTREAM_ERROR;
- goto End;
- }
- }
-
- // Read the Huffman codes (may recurse).
- ok = ok && ReadHuffmanCodes(dec, transform_xsize, transform_ysize,
- color_cache_bits, is_level0);
- if (!ok) {
- dec->status_ = VP8_STATUS_BITSTREAM_ERROR;
- goto End;
- }
-
- // Finish setting up the color-cache
- if (color_cache_bits > 0) {
- hdr->color_cache_size_ = 1 << color_cache_bits;
- if (!VP8LColorCacheInit(&hdr->color_cache_, color_cache_bits)) {
- dec->status_ = VP8_STATUS_OUT_OF_MEMORY;
- ok = 0;
- goto End;
- }
- } else {
- hdr->color_cache_size_ = 0;
- }
- UpdateDecoder(dec, transform_xsize, transform_ysize);
-
- if (is_level0) { // level 0 complete
- dec->state_ = READ_HDR;
- goto End;
- }
-
- {
- const uint64_t total_size = (uint64_t)transform_xsize * transform_ysize;
- data = (uint32_t*)WebPSafeMalloc(total_size, sizeof(*data));
- if (data == NULL) {
- dec->status_ = VP8_STATUS_OUT_OF_MEMORY;
- ok = 0;
- goto End;
- }
- }
-
- // Use the Huffman trees to decode the LZ77 encoded data.
- ok = DecodeImageData(dec, data, transform_xsize, transform_ysize,
- transform_ysize, NULL);
- ok = ok && !br->eos_;
-
- End:
- if (!ok) {
- WebPSafeFree(data);
- ClearMetadata(hdr);
- } else {
- if (decoded_data != NULL) {
- *decoded_data = data;
- } else {
- // We allocate image data in this function only for transforms. At level 0
- // (that is: not the transforms), we shouldn't have allocated anything.
- assert(data == NULL);
- assert(is_level0);
- }
- dec->last_pixel_ = 0; // Reset for future DECODE_DATA_FUNC() calls.
- if (!is_level0) ClearMetadata(hdr); // Clean up temporary data behind.
- }
- return ok;
-}
-
-//------------------------------------------------------------------------------
-// Allocate internal buffers dec->pixels_ and dec->argb_cache_.
-static int AllocateInternalBuffers32b(VP8LDecoder* const dec, int final_width) {
- const uint64_t num_pixels = (uint64_t)dec->width_ * dec->height_;
- // Scratch buffer corresponding to top-prediction row for transforming the
- // first row in the row-blocks. Not needed for paletted alpha.
- const uint64_t cache_top_pixels = (uint16_t)final_width;
- // Scratch buffer for temporary BGRA storage. Not needed for paletted alpha.
- const uint64_t cache_pixels = (uint64_t)final_width * NUM_ARGB_CACHE_ROWS;
- const uint64_t total_num_pixels =
- num_pixels + cache_top_pixels + cache_pixels;
-
- assert(dec->width_ <= final_width);
- dec->pixels_ = (uint32_t*)WebPSafeMalloc(total_num_pixels, sizeof(uint32_t));
- if (dec->pixels_ == NULL) {
- dec->argb_cache_ = NULL; // for soundness
- dec->status_ = VP8_STATUS_OUT_OF_MEMORY;
- return 0;
- }
- dec->argb_cache_ = dec->pixels_ + num_pixels + cache_top_pixels;
- return 1;
-}
-
-static int AllocateInternalBuffers8b(VP8LDecoder* const dec) {
- const uint64_t total_num_pixels = (uint64_t)dec->width_ * dec->height_;
- dec->argb_cache_ = NULL; // for soundness
- dec->pixels_ = (uint32_t*)WebPSafeMalloc(total_num_pixels, sizeof(uint8_t));
- if (dec->pixels_ == NULL) {
- dec->status_ = VP8_STATUS_OUT_OF_MEMORY;
- return 0;
- }
- return 1;
-}
-
-//------------------------------------------------------------------------------
-
-// Special row-processing that only stores the alpha data.
-static void ExtractAlphaRows(VP8LDecoder* const dec, int last_row) {
- int cur_row = dec->last_row_;
- int num_rows = last_row - cur_row;
- const uint32_t* in = dec->pixels_ + dec->width_ * cur_row;
-
- assert(last_row <= dec->io_->crop_bottom);
- while (num_rows > 0) {
- const int num_rows_to_process =
- (num_rows > NUM_ARGB_CACHE_ROWS) ? NUM_ARGB_CACHE_ROWS : num_rows;
- // Extract alpha (which is stored in the green plane).
- ALPHDecoder* const alph_dec = (ALPHDecoder*)dec->io_->opaque;
- uint8_t* const output = alph_dec->output_;
- const int width = dec->io_->width; // the final width (!= dec->width_)
- const int cache_pixs = width * num_rows_to_process;
- uint8_t* const dst = output + width * cur_row;
- const uint32_t* const src = dec->argb_cache_;
- ApplyInverseTransforms(dec, cur_row, num_rows_to_process, in);
- WebPExtractGreen(src, dst, cache_pixs);
- AlphaApplyFilter(alph_dec,
- cur_row, cur_row + num_rows_to_process, dst, width);
- num_rows -= num_rows_to_process;
- in += num_rows_to_process * dec->width_;
- cur_row += num_rows_to_process;
- }
- assert(cur_row == last_row);
- dec->last_row_ = dec->last_out_row_ = last_row;
-}
-
-int VP8LDecodeAlphaHeader(ALPHDecoder* const alph_dec,
- const uint8_t* const data, size_t data_size) {
- int ok = 0;
- VP8LDecoder* dec = VP8LNew();
-
- if (dec == NULL) return 0;
-
- assert(alph_dec != NULL);
-
- dec->width_ = alph_dec->width_;
- dec->height_ = alph_dec->height_;
- dec->io_ = &alph_dec->io_;
- dec->io_->opaque = alph_dec;
- dec->io_->width = alph_dec->width_;
- dec->io_->height = alph_dec->height_;
-
- dec->status_ = VP8_STATUS_OK;
- VP8LInitBitReader(&dec->br_, data, data_size);
-
- if (!DecodeImageStream(alph_dec->width_, alph_dec->height_, 1, dec, NULL)) {
- goto Err;
- }
-
- // Special case: if alpha data uses only the color indexing transform and
- // doesn't use color cache (a frequent case), we will use DecodeAlphaData()
- // method that only needs allocation of 1 byte per pixel (alpha channel).
- if (dec->next_transform_ == 1 &&
- dec->transforms_[0].type_ == COLOR_INDEXING_TRANSFORM &&
- Is8bOptimizable(&dec->hdr_)) {
- alph_dec->use_8b_decode_ = 1;
- ok = AllocateInternalBuffers8b(dec);
- } else {
- // Allocate internal buffers (note that dec->width_ may have changed here).
- alph_dec->use_8b_decode_ = 0;
- ok = AllocateInternalBuffers32b(dec, alph_dec->width_);
- }
-
- if (!ok) goto Err;
-
- // Only set here, once we are sure it is valid (to avoid thread races).
- alph_dec->vp8l_dec_ = dec;
- return 1;
-
- Err:
- VP8LDelete(dec);
- return 0;
-}
-
-int VP8LDecodeAlphaImageStream(ALPHDecoder* const alph_dec, int last_row) {
- VP8LDecoder* const dec = alph_dec->vp8l_dec_;
- assert(dec != NULL);
- assert(last_row <= dec->height_);
-
- if (dec->last_row_ >= last_row) {
- return 1; // done
- }
-
- if (!alph_dec->use_8b_decode_) WebPInitAlphaProcessing();
-
- // Decode (with special row processing).
- return alph_dec->use_8b_decode_ ?
- DecodeAlphaData(dec, (uint8_t*)dec->pixels_, dec->width_, dec->height_,
- last_row) :
- DecodeImageData(dec, dec->pixels_, dec->width_, dec->height_,
- last_row, ExtractAlphaRows);
-}
-
-//------------------------------------------------------------------------------
-
-int VP8LDecodeHeader(VP8LDecoder* const dec, VP8Io* const io) {
- int width, height, has_alpha;
-
- if (dec == NULL) return 0;
- if (io == NULL) {
- dec->status_ = VP8_STATUS_INVALID_PARAM;
- return 0;
- }
-
- dec->io_ = io;
- dec->status_ = VP8_STATUS_OK;
- VP8LInitBitReader(&dec->br_, io->data, io->data_size);
- if (!ReadImageInfo(&dec->br_, &width, &height, &has_alpha)) {
- dec->status_ = VP8_STATUS_BITSTREAM_ERROR;
- goto Error;
- }
- dec->state_ = READ_DIM;
- io->width = width;
- io->height = height;
-
- if (!DecodeImageStream(width, height, 1, dec, NULL)) goto Error;
- return 1;
-
- Error:
- VP8LClear(dec);
- assert(dec->status_ != VP8_STATUS_OK);
- return 0;
-}
-
-int VP8LDecodeImage(VP8LDecoder* const dec) {
- VP8Io* io = NULL;
- WebPDecParams* params = NULL;
-
- if (dec == NULL) return 0;
-
- assert(dec->hdr_.huffman_tables_ != NULL);
- assert(dec->hdr_.htree_groups_ != NULL);
- assert(dec->hdr_.num_htree_groups_ > 0);
-
- io = dec->io_;
- assert(io != NULL);
- params = (WebPDecParams*)io->opaque;
- assert(params != NULL);
-
- // Initialization.
- if (dec->state_ != READ_DATA) {
- dec->output_ = params->output;
- assert(dec->output_ != NULL);
-
- if (!WebPIoInitFromOptions(params->options, io, MODE_BGRA)) {
- dec->status_ = VP8_STATUS_INVALID_PARAM;
- goto Err;
- }
-
- if (!AllocateInternalBuffers32b(dec, io->width)) goto Err;
-
-#if !defined(WEBP_REDUCE_SIZE)
- if (io->use_scaling && !AllocateAndInitRescaler(dec, io)) goto Err;
-#else
- if (io->use_scaling) {
- dec->status_ = VP8_STATUS_INVALID_PARAM;
- goto Err;
- }
-#endif
- if (io->use_scaling || WebPIsPremultipliedMode(dec->output_->colorspace)) {
- // need the alpha-multiply functions for premultiplied output or rescaling
- WebPInitAlphaProcessing();
- }
-
- if (!WebPIsRGBMode(dec->output_->colorspace)) {
- WebPInitConvertARGBToYUV();
- if (dec->output_->u.YUVA.a != NULL) WebPInitAlphaProcessing();
- }
- if (dec->incremental_) {
- if (dec->hdr_.color_cache_size_ > 0 &&
- dec->hdr_.saved_color_cache_.colors_ == NULL) {
- if (!VP8LColorCacheInit(&dec->hdr_.saved_color_cache_,
- dec->hdr_.color_cache_.hash_bits_)) {
- dec->status_ = VP8_STATUS_OUT_OF_MEMORY;
- goto Err;
- }
- }
- }
- dec->state_ = READ_DATA;
- }
-
- // Decode.
- if (!DecodeImageData(dec, dec->pixels_, dec->width_, dec->height_,
- io->crop_bottom, ProcessRows)) {
- goto Err;
- }
-
- params->last_y = dec->last_out_row_;
- return 1;
-
- Err:
- VP8LClear(dec);
- assert(dec->status_ != VP8_STATUS_OK);
- return 0;
-}
-
-//------------------------------------------------------------------------------
diff --git a/contrib/libs/libwebp/dec/vp8li_dec.h b/contrib/libs/libwebp/dec/vp8li_dec.h
deleted file mode 100644
index bfd61c6a33..0000000000
--- a/contrib/libs/libwebp/dec/vp8li_dec.h
+++ /dev/null
@@ -1,135 +0,0 @@
-// Copyright 2012 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Lossless decoder: internal header.
-//
-// Author: Skal (pascal.massimino@gmail.com)
-// Vikas Arora(vikaas.arora@gmail.com)
-
-#ifndef WEBP_DEC_VP8LI_DEC_H_
-#define WEBP_DEC_VP8LI_DEC_H_
-
-#include <string.h> // for memcpy()
-#include "./webpi_dec.h"
-#include "../utils/bit_reader_utils.h"
-#include "../utils/color_cache_utils.h"
-#include "../utils/huffman_utils.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum {
- READ_DATA = 0,
- READ_HDR = 1,
- READ_DIM = 2
-} VP8LDecodeState;
-
-typedef struct VP8LTransform VP8LTransform;
-struct VP8LTransform {
- VP8LImageTransformType type_; // transform type.
- int bits_; // subsampling bits defining transform window.
- int xsize_; // transform window X index.
- int ysize_; // transform window Y index.
- uint32_t* data_; // transform data.
-};
-
-typedef struct {
- int color_cache_size_;
- VP8LColorCache color_cache_;
- VP8LColorCache saved_color_cache_; // for incremental
-
- int huffman_mask_;
- int huffman_subsample_bits_;
- int huffman_xsize_;
- uint32_t* huffman_image_;
- int num_htree_groups_;
- HTreeGroup* htree_groups_;
- HuffmanCode* huffman_tables_;
-} VP8LMetadata;
-
-typedef struct VP8LDecoder VP8LDecoder;
-struct VP8LDecoder {
- VP8StatusCode status_;
- VP8LDecodeState state_;
- VP8Io* io_;
-
- const WebPDecBuffer* output_; // shortcut to io->opaque->output
-
- uint32_t* pixels_; // Internal data: either uint8_t* for alpha
- // or uint32_t* for BGRA.
- uint32_t* argb_cache_; // Scratch buffer for temporary BGRA storage.
-
- VP8LBitReader br_;
- int incremental_; // if true, incremental decoding is expected
- VP8LBitReader saved_br_; // note: could be local variables too
- int saved_last_pixel_;
-
- int width_;
- int height_;
- int last_row_; // last input row decoded so far.
- int last_pixel_; // last pixel decoded so far. However, it may
- // not be transformed, scaled and
- // color-converted yet.
- int last_out_row_; // last row output so far.
-
- VP8LMetadata hdr_;
-
- int next_transform_;
- VP8LTransform transforms_[NUM_TRANSFORMS];
- // or'd bitset storing the transforms types.
- uint32_t transforms_seen_;
-
- uint8_t* rescaler_memory; // Working memory for rescaling work.
- WebPRescaler* rescaler; // Common rescaler for all channels.
-};
-
-//------------------------------------------------------------------------------
-// internal functions. Not public.
-
-struct ALPHDecoder; // Defined in dec/alphai.h.
-
-// in vp8l.c
-
-// Decodes image header for alpha data stored using lossless compression.
-// Returns false in case of error.
-int VP8LDecodeAlphaHeader(struct ALPHDecoder* const alph_dec,
- const uint8_t* const data, size_t data_size);
-
-// Decodes *at least* 'last_row' rows of alpha. If some of the initial rows are
-// already decoded in previous call(s), it will resume decoding from where it
-// was paused.
-// Returns false in case of bitstream error.
-int VP8LDecodeAlphaImageStream(struct ALPHDecoder* const alph_dec,
- int last_row);
-
-// Allocates and initialize a new lossless decoder instance.
-VP8LDecoder* VP8LNew(void);
-
-// Decodes the image header. Returns false in case of error.
-int VP8LDecodeHeader(VP8LDecoder* const dec, VP8Io* const io);
-
-// Decodes an image. It's required to decode the lossless header before calling
-// this function. Returns false in case of error, with updated dec->status_.
-int VP8LDecodeImage(VP8LDecoder* const dec);
-
-// Resets the decoder in its initial state, reclaiming memory.
-// Preserves the dec->status_ value.
-void VP8LClear(VP8LDecoder* const dec);
-
-// Clears and deallocate a lossless decoder instance.
-void VP8LDelete(VP8LDecoder* const dec);
-
-//------------------------------------------------------------------------------
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // WEBP_DEC_VP8LI_DEC_H_
diff --git a/contrib/libs/libwebp/dec/webp_dec.c b/contrib/libs/libwebp/dec/webp_dec.c
deleted file mode 100644
index 9376c75a9b..0000000000
--- a/contrib/libs/libwebp/dec/webp_dec.c
+++ /dev/null
@@ -1,852 +0,0 @@
-// Copyright 2010 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Main decoding functions for WEBP images.
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include <stdlib.h>
-
-#include "./vp8i_dec.h"
-#include "./vp8li_dec.h"
-#include "./webpi_dec.h"
-#include "../utils/utils.h"
-#include "../webp/mux_types.h" // ALPHA_FLAG
-
-//------------------------------------------------------------------------------
-// RIFF layout is:
-// Offset tag
-// 0...3 "RIFF" 4-byte tag
-// 4...7 size of image data (including metadata) starting at offset 8
-// 8...11 "WEBP" our form-type signature
-// The RIFF container (12 bytes) is followed by appropriate chunks:
-// 12..15 "VP8 ": 4-bytes tags, signaling the use of VP8 video format
-// 16..19 size of the raw VP8 image data, starting at offset 20
-// 20.... the VP8 bytes
-// Or,
-// 12..15 "VP8L": 4-bytes tags, signaling the use of VP8L lossless format
-// 16..19 size of the raw VP8L image data, starting at offset 20
-// 20.... the VP8L bytes
-// Or,
-// 12..15 "VP8X": 4-bytes tags, describing the extended-VP8 chunk.
-// 16..19 size of the VP8X chunk starting at offset 20.
-// 20..23 VP8X flags bit-map corresponding to the chunk-types present.
-// 24..26 Width of the Canvas Image.
-// 27..29 Height of the Canvas Image.
-// There can be extra chunks after the "VP8X" chunk (ICCP, ANMF, VP8, VP8L,
-// XMP, EXIF ...)
-// All sizes are in little-endian order.
-// Note: chunk data size must be padded to multiple of 2 when written.
-
-// Validates the RIFF container (if detected) and skips over it.
-// If a RIFF container is detected, returns:
-// VP8_STATUS_BITSTREAM_ERROR for invalid header,
-// VP8_STATUS_NOT_ENOUGH_DATA for truncated data if have_all_data is true,
-// and VP8_STATUS_OK otherwise.
-// In case there are not enough bytes (partial RIFF container), return 0 for
-// *riff_size. Else return the RIFF size extracted from the header.
-static VP8StatusCode ParseRIFF(const uint8_t** const data,
- size_t* const data_size, int have_all_data,
- size_t* const riff_size) {
- assert(data != NULL);
- assert(data_size != NULL);
- assert(riff_size != NULL);
-
- *riff_size = 0; // Default: no RIFF present.
- if (*data_size >= RIFF_HEADER_SIZE && !memcmp(*data, "RIFF", TAG_SIZE)) {
- if (memcmp(*data + 8, "WEBP", TAG_SIZE)) {
- return VP8_STATUS_BITSTREAM_ERROR; // Wrong image file signature.
- } else {
- const uint32_t size = GetLE32(*data + TAG_SIZE);
- // Check that we have at least one chunk (i.e "WEBP" + "VP8?nnnn").
- if (size < TAG_SIZE + CHUNK_HEADER_SIZE) {
- return VP8_STATUS_BITSTREAM_ERROR;
- }
- if (size > MAX_CHUNK_PAYLOAD) {
- return VP8_STATUS_BITSTREAM_ERROR;
- }
- if (have_all_data && (size > *data_size - CHUNK_HEADER_SIZE)) {
- return VP8_STATUS_NOT_ENOUGH_DATA; // Truncated bitstream.
- }
- // We have a RIFF container. Skip it.
- *riff_size = size;
- *data += RIFF_HEADER_SIZE;
- *data_size -= RIFF_HEADER_SIZE;
- }
- }
- return VP8_STATUS_OK;
-}
-
-// Validates the VP8X header and skips over it.
-// Returns VP8_STATUS_BITSTREAM_ERROR for invalid VP8X header,
-// VP8_STATUS_NOT_ENOUGH_DATA in case of insufficient data, and
-// VP8_STATUS_OK otherwise.
-// If a VP8X chunk is found, found_vp8x is set to true and *width_ptr,
-// *height_ptr and *flags_ptr are set to the corresponding values extracted
-// from the VP8X chunk.
-static VP8StatusCode ParseVP8X(const uint8_t** const data,
- size_t* const data_size,
- int* const found_vp8x,
- int* const width_ptr, int* const height_ptr,
- uint32_t* const flags_ptr) {
- const uint32_t vp8x_size = CHUNK_HEADER_SIZE + VP8X_CHUNK_SIZE;
- assert(data != NULL);
- assert(data_size != NULL);
- assert(found_vp8x != NULL);
-
- *found_vp8x = 0;
-
- if (*data_size < CHUNK_HEADER_SIZE) {
- return VP8_STATUS_NOT_ENOUGH_DATA; // Insufficient data.
- }
-
- if (!memcmp(*data, "VP8X", TAG_SIZE)) {
- int width, height;
- uint32_t flags;
- const uint32_t chunk_size = GetLE32(*data + TAG_SIZE);
- if (chunk_size != VP8X_CHUNK_SIZE) {
- return VP8_STATUS_BITSTREAM_ERROR; // Wrong chunk size.
- }
-
- // Verify if enough data is available to validate the VP8X chunk.
- if (*data_size < vp8x_size) {
- return VP8_STATUS_NOT_ENOUGH_DATA; // Insufficient data.
- }
- flags = GetLE32(*data + 8);
- width = 1 + GetLE24(*data + 12);
- height = 1 + GetLE24(*data + 15);
- if (width * (uint64_t)height >= MAX_IMAGE_AREA) {
- return VP8_STATUS_BITSTREAM_ERROR; // image is too large
- }
-
- if (flags_ptr != NULL) *flags_ptr = flags;
- if (width_ptr != NULL) *width_ptr = width;
- if (height_ptr != NULL) *height_ptr = height;
- // Skip over VP8X header bytes.
- *data += vp8x_size;
- *data_size -= vp8x_size;
- *found_vp8x = 1;
- }
- return VP8_STATUS_OK;
-}
-
-// Skips to the next VP8/VP8L chunk header in the data given the size of the
-// RIFF chunk 'riff_size'.
-// Returns VP8_STATUS_BITSTREAM_ERROR if any invalid chunk size is encountered,
-// VP8_STATUS_NOT_ENOUGH_DATA in case of insufficient data, and
-// VP8_STATUS_OK otherwise.
-// If an alpha chunk is found, *alpha_data and *alpha_size are set
-// appropriately.
-static VP8StatusCode ParseOptionalChunks(const uint8_t** const data,
- size_t* const data_size,
- size_t const riff_size,
- const uint8_t** const alpha_data,
- size_t* const alpha_size) {
- const uint8_t* buf;
- size_t buf_size;
- uint32_t total_size = TAG_SIZE + // "WEBP".
- CHUNK_HEADER_SIZE + // "VP8Xnnnn".
- VP8X_CHUNK_SIZE; // data.
- assert(data != NULL);
- assert(data_size != NULL);
- buf = *data;
- buf_size = *data_size;
-
- assert(alpha_data != NULL);
- assert(alpha_size != NULL);
- *alpha_data = NULL;
- *alpha_size = 0;
-
- while (1) {
- uint32_t chunk_size;
- uint32_t disk_chunk_size; // chunk_size with padding
-
- *data = buf;
- *data_size = buf_size;
-
- if (buf_size < CHUNK_HEADER_SIZE) { // Insufficient data.
- return VP8_STATUS_NOT_ENOUGH_DATA;
- }
-
- chunk_size = GetLE32(buf + TAG_SIZE);
- if (chunk_size > MAX_CHUNK_PAYLOAD) {
- return VP8_STATUS_BITSTREAM_ERROR; // Not a valid chunk size.
- }
- // For odd-sized chunk-payload, there's one byte padding at the end.
- disk_chunk_size = (CHUNK_HEADER_SIZE + chunk_size + 1) & ~1;
- total_size += disk_chunk_size;
-
- // Check that total bytes skipped so far does not exceed riff_size.
- if (riff_size > 0 && (total_size > riff_size)) {
- return VP8_STATUS_BITSTREAM_ERROR; // Not a valid chunk size.
- }
-
- // Start of a (possibly incomplete) VP8/VP8L chunk implies that we have
- // parsed all the optional chunks.
- // Note: This check must occur before the check 'buf_size < disk_chunk_size'
- // below to allow incomplete VP8/VP8L chunks.
- if (!memcmp(buf, "VP8 ", TAG_SIZE) ||
- !memcmp(buf, "VP8L", TAG_SIZE)) {
- return VP8_STATUS_OK;
- }
-
- if (buf_size < disk_chunk_size) { // Insufficient data.
- return VP8_STATUS_NOT_ENOUGH_DATA;
- }
-
- if (!memcmp(buf, "ALPH", TAG_SIZE)) { // A valid ALPH header.
- *alpha_data = buf + CHUNK_HEADER_SIZE;
- *alpha_size = chunk_size;
- }
-
- // We have a full and valid chunk; skip it.
- buf += disk_chunk_size;
- buf_size -= disk_chunk_size;
- }
-}
-
-// Validates the VP8/VP8L Header ("VP8 nnnn" or "VP8L nnnn") and skips over it.
-// Returns VP8_STATUS_BITSTREAM_ERROR for invalid (chunk larger than
-// riff_size) VP8/VP8L header,
-// VP8_STATUS_NOT_ENOUGH_DATA in case of insufficient data, and
-// VP8_STATUS_OK otherwise.
-// If a VP8/VP8L chunk is found, *chunk_size is set to the total number of bytes
-// extracted from the VP8/VP8L chunk header.
-// The flag '*is_lossless' is set to 1 in case of VP8L chunk / raw VP8L data.
-static VP8StatusCode ParseVP8Header(const uint8_t** const data_ptr,
- size_t* const data_size, int have_all_data,
- size_t riff_size, size_t* const chunk_size,
- int* const is_lossless) {
- const uint8_t* const data = *data_ptr;
- const int is_vp8 = !memcmp(data, "VP8 ", TAG_SIZE);
- const int is_vp8l = !memcmp(data, "VP8L", TAG_SIZE);
- const uint32_t minimal_size =
- TAG_SIZE + CHUNK_HEADER_SIZE; // "WEBP" + "VP8 nnnn" OR
- // "WEBP" + "VP8Lnnnn"
- assert(data != NULL);
- assert(data_size != NULL);
- assert(chunk_size != NULL);
- assert(is_lossless != NULL);
-
- if (*data_size < CHUNK_HEADER_SIZE) {
- return VP8_STATUS_NOT_ENOUGH_DATA; // Insufficient data.
- }
-
- if (is_vp8 || is_vp8l) {
- // Bitstream contains VP8/VP8L header.
- const uint32_t size = GetLE32(data + TAG_SIZE);
- if ((riff_size >= minimal_size) && (size > riff_size - minimal_size)) {
- return VP8_STATUS_BITSTREAM_ERROR; // Inconsistent size information.
- }
- if (have_all_data && (size > *data_size - CHUNK_HEADER_SIZE)) {
- return VP8_STATUS_NOT_ENOUGH_DATA; // Truncated bitstream.
- }
- // Skip over CHUNK_HEADER_SIZE bytes from VP8/VP8L Header.
- *chunk_size = size;
- *data_ptr += CHUNK_HEADER_SIZE;
- *data_size -= CHUNK_HEADER_SIZE;
- *is_lossless = is_vp8l;
- } else {
- // Raw VP8/VP8L bitstream (no header).
- *is_lossless = VP8LCheckSignature(data, *data_size);
- *chunk_size = *data_size;
- }
-
- return VP8_STATUS_OK;
-}
-
-//------------------------------------------------------------------------------
-
-// Fetch '*width', '*height', '*has_alpha' and fill out 'headers' based on
-// 'data'. All the output parameters may be NULL. If 'headers' is NULL only the
-// minimal amount will be read to fetch the remaining parameters.
-// If 'headers' is non-NULL this function will attempt to locate both alpha
-// data (with or without a VP8X chunk) and the bitstream chunk (VP8/VP8L).
-// Note: The following chunk sequences (before the raw VP8/VP8L data) are
-// considered valid by this function:
-// RIFF + VP8(L)
-// RIFF + VP8X + (optional chunks) + VP8(L)
-// ALPH + VP8 <-- Not a valid WebP format: only allowed for internal purpose.
-// VP8(L) <-- Not a valid WebP format: only allowed for internal purpose.
-static VP8StatusCode ParseHeadersInternal(const uint8_t* data,
- size_t data_size,
- int* const width,
- int* const height,
- int* const has_alpha,
- int* const has_animation,
- int* const format,
- WebPHeaderStructure* const headers) {
- int canvas_width = 0;
- int canvas_height = 0;
- int image_width = 0;
- int image_height = 0;
- int found_riff = 0;
- int found_vp8x = 0;
- int animation_present = 0;
- const int have_all_data = (headers != NULL) ? headers->have_all_data : 0;
-
- VP8StatusCode status;
- WebPHeaderStructure hdrs;
-
- if (data == NULL || data_size < RIFF_HEADER_SIZE) {
- return VP8_STATUS_NOT_ENOUGH_DATA;
- }
- memset(&hdrs, 0, sizeof(hdrs));
- hdrs.data = data;
- hdrs.data_size = data_size;
-
- // Skip over RIFF header.
- status = ParseRIFF(&data, &data_size, have_all_data, &hdrs.riff_size);
- if (status != VP8_STATUS_OK) {
- return status; // Wrong RIFF header / insufficient data.
- }
- found_riff = (hdrs.riff_size > 0);
-
- // Skip over VP8X.
- {
- uint32_t flags = 0;
- status = ParseVP8X(&data, &data_size, &found_vp8x,
- &canvas_width, &canvas_height, &flags);
- if (status != VP8_STATUS_OK) {
- return status; // Wrong VP8X / insufficient data.
- }
- animation_present = !!(flags & ANIMATION_FLAG);
- if (!found_riff && found_vp8x) {
- // Note: This restriction may be removed in the future, if it becomes
- // necessary to send VP8X chunk to the decoder.
- return VP8_STATUS_BITSTREAM_ERROR;
- }
- if (has_alpha != NULL) *has_alpha = !!(flags & ALPHA_FLAG);
- if (has_animation != NULL) *has_animation = animation_present;
- if (format != NULL) *format = 0; // default = undefined
-
- image_width = canvas_width;
- image_height = canvas_height;
- if (found_vp8x && animation_present && headers == NULL) {
- status = VP8_STATUS_OK;
- goto ReturnWidthHeight; // Just return features from VP8X header.
- }
- }
-
- if (data_size < TAG_SIZE) {
- status = VP8_STATUS_NOT_ENOUGH_DATA;
- goto ReturnWidthHeight;
- }
-
- // Skip over optional chunks if data started with "RIFF + VP8X" or "ALPH".
- if ((found_riff && found_vp8x) ||
- (!found_riff && !found_vp8x && !memcmp(data, "ALPH", TAG_SIZE))) {
- status = ParseOptionalChunks(&data, &data_size, hdrs.riff_size,
- &hdrs.alpha_data, &hdrs.alpha_data_size);
- if (status != VP8_STATUS_OK) {
- goto ReturnWidthHeight; // Invalid chunk size / insufficient data.
- }
- }
-
- // Skip over VP8/VP8L header.
- status = ParseVP8Header(&data, &data_size, have_all_data, hdrs.riff_size,
- &hdrs.compressed_size, &hdrs.is_lossless);
- if (status != VP8_STATUS_OK) {
- goto ReturnWidthHeight; // Wrong VP8/VP8L chunk-header / insufficient data.
- }
- if (hdrs.compressed_size > MAX_CHUNK_PAYLOAD) {
- return VP8_STATUS_BITSTREAM_ERROR;
- }
-
- if (format != NULL && !animation_present) {
- *format = hdrs.is_lossless ? 2 : 1;
- }
-
- if (!hdrs.is_lossless) {
- if (data_size < VP8_FRAME_HEADER_SIZE) {
- status = VP8_STATUS_NOT_ENOUGH_DATA;
- goto ReturnWidthHeight;
- }
- // Validates raw VP8 data.
- if (!VP8GetInfo(data, data_size, (uint32_t)hdrs.compressed_size,
- &image_width, &image_height)) {
- return VP8_STATUS_BITSTREAM_ERROR;
- }
- } else {
- if (data_size < VP8L_FRAME_HEADER_SIZE) {
- status = VP8_STATUS_NOT_ENOUGH_DATA;
- goto ReturnWidthHeight;
- }
- // Validates raw VP8L data.
- if (!VP8LGetInfo(data, data_size, &image_width, &image_height, has_alpha)) {
- return VP8_STATUS_BITSTREAM_ERROR;
- }
- }
- // Validates image size coherency.
- if (found_vp8x) {
- if (canvas_width != image_width || canvas_height != image_height) {
- return VP8_STATUS_BITSTREAM_ERROR;
- }
- }
- if (headers != NULL) {
- *headers = hdrs;
- headers->offset = data - headers->data;
- assert((uint64_t)(data - headers->data) < MAX_CHUNK_PAYLOAD);
- assert(headers->offset == headers->data_size - data_size);
- }
- ReturnWidthHeight:
- if (status == VP8_STATUS_OK ||
- (status == VP8_STATUS_NOT_ENOUGH_DATA && found_vp8x && headers == NULL)) {
- if (has_alpha != NULL) {
- // If the data did not contain a VP8X/VP8L chunk the only definitive way
- // to set this is by looking for alpha data (from an ALPH chunk).
- *has_alpha |= (hdrs.alpha_data != NULL);
- }
- if (width != NULL) *width = image_width;
- if (height != NULL) *height = image_height;
- return VP8_STATUS_OK;
- } else {
- return status;
- }
-}
-
-VP8StatusCode WebPParseHeaders(WebPHeaderStructure* const headers) {
- // status is marked volatile as a workaround for a clang-3.8 (aarch64) bug
- volatile VP8StatusCode status;
- int has_animation = 0;
- assert(headers != NULL);
- // fill out headers, ignore width/height/has_alpha.
- status = ParseHeadersInternal(headers->data, headers->data_size,
- NULL, NULL, NULL, &has_animation,
- NULL, headers);
- if (status == VP8_STATUS_OK || status == VP8_STATUS_NOT_ENOUGH_DATA) {
- // The WebPDemux API + libwebp can be used to decode individual
- // uncomposited frames or the WebPAnimDecoder can be used to fully
- // reconstruct them (see webp/demux.h).
- if (has_animation) {
- status = VP8_STATUS_UNSUPPORTED_FEATURE;
- }
- }
- return status;
-}
-
-//------------------------------------------------------------------------------
-// WebPDecParams
-
-void WebPResetDecParams(WebPDecParams* const params) {
- if (params != NULL) {
- memset(params, 0, sizeof(*params));
- }
-}
-
-//------------------------------------------------------------------------------
-// "Into" decoding variants
-
-// Main flow
-static VP8StatusCode DecodeInto(const uint8_t* const data, size_t data_size,
- WebPDecParams* const params) {
- VP8StatusCode status;
- VP8Io io;
- WebPHeaderStructure headers;
-
- headers.data = data;
- headers.data_size = data_size;
- headers.have_all_data = 1;
- status = WebPParseHeaders(&headers); // Process Pre-VP8 chunks.
- if (status != VP8_STATUS_OK) {
- return status;
- }
-
- assert(params != NULL);
- VP8InitIo(&io);
- io.data = headers.data + headers.offset;
- io.data_size = headers.data_size - headers.offset;
- WebPInitCustomIo(params, &io); // Plug the I/O functions.
-
- if (!headers.is_lossless) {
- VP8Decoder* const dec = VP8New();
- if (dec == NULL) {
- return VP8_STATUS_OUT_OF_MEMORY;
- }
- dec->alpha_data_ = headers.alpha_data;
- dec->alpha_data_size_ = headers.alpha_data_size;
-
- // Decode bitstream header, update io->width/io->height.
- if (!VP8GetHeaders(dec, &io)) {
- status = dec->status_; // An error occurred. Grab error status.
- } else {
- // Allocate/check output buffers.
- status = WebPAllocateDecBuffer(io.width, io.height, params->options,
- params->output);
- if (status == VP8_STATUS_OK) { // Decode
- // This change must be done before calling VP8Decode()
- dec->mt_method_ = VP8GetThreadMethod(params->options, &headers,
- io.width, io.height);
- VP8InitDithering(params->options, dec);
- if (!VP8Decode(dec, &io)) {
- status = dec->status_;
- }
- }
- }
- VP8Delete(dec);
- } else {
- VP8LDecoder* const dec = VP8LNew();
- if (dec == NULL) {
- return VP8_STATUS_OUT_OF_MEMORY;
- }
- if (!VP8LDecodeHeader(dec, &io)) {
- status = dec->status_; // An error occurred. Grab error status.
- } else {
- // Allocate/check output buffers.
- status = WebPAllocateDecBuffer(io.width, io.height, params->options,
- params->output);
- if (status == VP8_STATUS_OK) { // Decode
- if (!VP8LDecodeImage(dec)) {
- status = dec->status_;
- }
- }
- }
- VP8LDelete(dec);
- }
-
- if (status != VP8_STATUS_OK) {
- WebPFreeDecBuffer(params->output);
- } else {
- if (params->options != NULL && params->options->flip) {
- // This restores the original stride values if options->flip was used
- // during the call to WebPAllocateDecBuffer above.
- status = WebPFlipBuffer(params->output);
- }
- }
- return status;
-}
-
-// Helpers
-static uint8_t* DecodeIntoRGBABuffer(WEBP_CSP_MODE colorspace,
- const uint8_t* const data,
- size_t data_size,
- uint8_t* const rgba,
- int stride, size_t size) {
- WebPDecParams params;
- WebPDecBuffer buf;
- if (rgba == NULL) {
- return NULL;
- }
- WebPInitDecBuffer(&buf);
- WebPResetDecParams(&params);
- params.output = &buf;
- buf.colorspace = colorspace;
- buf.u.RGBA.rgba = rgba;
- buf.u.RGBA.stride = stride;
- buf.u.RGBA.size = size;
- buf.is_external_memory = 1;
- if (DecodeInto(data, data_size, &params) != VP8_STATUS_OK) {
- return NULL;
- }
- return rgba;
-}
-
-uint8_t* WebPDecodeRGBInto(const uint8_t* data, size_t data_size,
- uint8_t* output, size_t size, int stride) {
- return DecodeIntoRGBABuffer(MODE_RGB, data, data_size, output, stride, size);
-}
-
-uint8_t* WebPDecodeRGBAInto(const uint8_t* data, size_t data_size,
- uint8_t* output, size_t size, int stride) {
- return DecodeIntoRGBABuffer(MODE_RGBA, data, data_size, output, stride, size);
-}
-
-uint8_t* WebPDecodeARGBInto(const uint8_t* data, size_t data_size,
- uint8_t* output, size_t size, int stride) {
- return DecodeIntoRGBABuffer(MODE_ARGB, data, data_size, output, stride, size);
-}
-
-uint8_t* WebPDecodeBGRInto(const uint8_t* data, size_t data_size,
- uint8_t* output, size_t size, int stride) {
- return DecodeIntoRGBABuffer(MODE_BGR, data, data_size, output, stride, size);
-}
-
-uint8_t* WebPDecodeBGRAInto(const uint8_t* data, size_t data_size,
- uint8_t* output, size_t size, int stride) {
- return DecodeIntoRGBABuffer(MODE_BGRA, data, data_size, output, stride, size);
-}
-
-uint8_t* WebPDecodeYUVInto(const uint8_t* data, size_t data_size,
- uint8_t* luma, size_t luma_size, int luma_stride,
- uint8_t* u, size_t u_size, int u_stride,
- uint8_t* v, size_t v_size, int v_stride) {
- WebPDecParams params;
- WebPDecBuffer output;
- if (luma == NULL) return NULL;
- WebPInitDecBuffer(&output);
- WebPResetDecParams(&params);
- params.output = &output;
- output.colorspace = MODE_YUV;
- output.u.YUVA.y = luma;
- output.u.YUVA.y_stride = luma_stride;
- output.u.YUVA.y_size = luma_size;
- output.u.YUVA.u = u;
- output.u.YUVA.u_stride = u_stride;
- output.u.YUVA.u_size = u_size;
- output.u.YUVA.v = v;
- output.u.YUVA.v_stride = v_stride;
- output.u.YUVA.v_size = v_size;
- output.is_external_memory = 1;
- if (DecodeInto(data, data_size, &params) != VP8_STATUS_OK) {
- return NULL;
- }
- return luma;
-}
-
-//------------------------------------------------------------------------------
-
-static uint8_t* Decode(WEBP_CSP_MODE mode, const uint8_t* const data,
- size_t data_size, int* const width, int* const height,
- WebPDecBuffer* const keep_info) {
- WebPDecParams params;
- WebPDecBuffer output;
-
- WebPInitDecBuffer(&output);
- WebPResetDecParams(&params);
- params.output = &output;
- output.colorspace = mode;
-
- // Retrieve (and report back) the required dimensions from bitstream.
- if (!WebPGetInfo(data, data_size, &output.width, &output.height)) {
- return NULL;
- }
- if (width != NULL) *width = output.width;
- if (height != NULL) *height = output.height;
-
- // Decode
- if (DecodeInto(data, data_size, &params) != VP8_STATUS_OK) {
- return NULL;
- }
- if (keep_info != NULL) { // keep track of the side-info
- WebPCopyDecBuffer(&output, keep_info);
- }
- // return decoded samples (don't clear 'output'!)
- return WebPIsRGBMode(mode) ? output.u.RGBA.rgba : output.u.YUVA.y;
-}
-
-uint8_t* WebPDecodeRGB(const uint8_t* data, size_t data_size,
- int* width, int* height) {
- return Decode(MODE_RGB, data, data_size, width, height, NULL);
-}
-
-uint8_t* WebPDecodeRGBA(const uint8_t* data, size_t data_size,
- int* width, int* height) {
- return Decode(MODE_RGBA, data, data_size, width, height, NULL);
-}
-
-uint8_t* WebPDecodeARGB(const uint8_t* data, size_t data_size,
- int* width, int* height) {
- return Decode(MODE_ARGB, data, data_size, width, height, NULL);
-}
-
-uint8_t* WebPDecodeBGR(const uint8_t* data, size_t data_size,
- int* width, int* height) {
- return Decode(MODE_BGR, data, data_size, width, height, NULL);
-}
-
-uint8_t* WebPDecodeBGRA(const uint8_t* data, size_t data_size,
- int* width, int* height) {
- return Decode(MODE_BGRA, data, data_size, width, height, NULL);
-}
-
-uint8_t* WebPDecodeYUV(const uint8_t* data, size_t data_size,
- int* width, int* height, uint8_t** u, uint8_t** v,
- int* stride, int* uv_stride) {
- WebPDecBuffer output; // only to preserve the side-infos
- uint8_t* const out = Decode(MODE_YUV, data, data_size,
- width, height, &output);
-
- if (out != NULL) {
- const WebPYUVABuffer* const buf = &output.u.YUVA;
- *u = buf->u;
- *v = buf->v;
- *stride = buf->y_stride;
- *uv_stride = buf->u_stride;
- assert(buf->u_stride == buf->v_stride);
- }
- return out;
-}
-
-static void DefaultFeatures(WebPBitstreamFeatures* const features) {
- assert(features != NULL);
- memset(features, 0, sizeof(*features));
-}
-
-static VP8StatusCode GetFeatures(const uint8_t* const data, size_t data_size,
- WebPBitstreamFeatures* const features) {
- if (features == NULL || data == NULL) {
- return VP8_STATUS_INVALID_PARAM;
- }
- DefaultFeatures(features);
-
- // Only parse enough of the data to retrieve the features.
- return ParseHeadersInternal(data, data_size,
- &features->width, &features->height,
- &features->has_alpha, &features->has_animation,
- &features->format, NULL);
-}
-
-//------------------------------------------------------------------------------
-// WebPGetInfo()
-
-int WebPGetInfo(const uint8_t* data, size_t data_size,
- int* width, int* height) {
- WebPBitstreamFeatures features;
-
- if (GetFeatures(data, data_size, &features) != VP8_STATUS_OK) {
- return 0;
- }
-
- if (width != NULL) {
- *width = features.width;
- }
- if (height != NULL) {
- *height = features.height;
- }
-
- return 1;
-}
-
-//------------------------------------------------------------------------------
-// Advance decoding API
-
-int WebPInitDecoderConfigInternal(WebPDecoderConfig* config,
- int version) {
- if (WEBP_ABI_IS_INCOMPATIBLE(version, WEBP_DECODER_ABI_VERSION)) {
- return 0; // version mismatch
- }
- if (config == NULL) {
- return 0;
- }
- memset(config, 0, sizeof(*config));
- DefaultFeatures(&config->input);
- WebPInitDecBuffer(&config->output);
- return 1;
-}
-
-VP8StatusCode WebPGetFeaturesInternal(const uint8_t* data, size_t data_size,
- WebPBitstreamFeatures* features,
- int version) {
- if (WEBP_ABI_IS_INCOMPATIBLE(version, WEBP_DECODER_ABI_VERSION)) {
- return VP8_STATUS_INVALID_PARAM; // version mismatch
- }
- if (features == NULL) {
- return VP8_STATUS_INVALID_PARAM;
- }
- return GetFeatures(data, data_size, features);
-}
-
-VP8StatusCode WebPDecode(const uint8_t* data, size_t data_size,
- WebPDecoderConfig* config) {
- WebPDecParams params;
- VP8StatusCode status;
-
- if (config == NULL) {
- return VP8_STATUS_INVALID_PARAM;
- }
-
- status = GetFeatures(data, data_size, &config->input);
- if (status != VP8_STATUS_OK) {
- if (status == VP8_STATUS_NOT_ENOUGH_DATA) {
- return VP8_STATUS_BITSTREAM_ERROR; // Not-enough-data treated as error.
- }
- return status;
- }
-
- WebPResetDecParams(&params);
- params.options = &config->options;
- params.output = &config->output;
- if (WebPAvoidSlowMemory(params.output, &config->input)) {
- // decoding to slow memory: use a temporary in-mem buffer to decode into.
- WebPDecBuffer in_mem_buffer;
- WebPInitDecBuffer(&in_mem_buffer);
- in_mem_buffer.colorspace = config->output.colorspace;
- in_mem_buffer.width = config->input.width;
- in_mem_buffer.height = config->input.height;
- params.output = &in_mem_buffer;
- status = DecodeInto(data, data_size, &params);
- if (status == VP8_STATUS_OK) { // do the slow-copy
- status = WebPCopyDecBufferPixels(&in_mem_buffer, &config->output);
- }
- WebPFreeDecBuffer(&in_mem_buffer);
- } else {
- status = DecodeInto(data, data_size, &params);
- }
-
- return status;
-}
-
-//------------------------------------------------------------------------------
-// Cropping and rescaling.
-
-int WebPCheckCropDimensions(int image_width, int image_height,
- int x, int y, int w, int h) {
- return !(x < 0 || y < 0 || w <= 0 || h <= 0 ||
- x >= image_width || w > image_width || w > image_width - x ||
- y >= image_height || h > image_height || h > image_height - y);
-}
-
-int WebPIoInitFromOptions(const WebPDecoderOptions* const options,
- VP8Io* const io, WEBP_CSP_MODE src_colorspace) {
- const int W = io->width;
- const int H = io->height;
- int x = 0, y = 0, w = W, h = H;
-
- // Cropping
- io->use_cropping = (options != NULL) && options->use_cropping;
- if (io->use_cropping) {
- w = options->crop_width;
- h = options->crop_height;
- x = options->crop_left;
- y = options->crop_top;
- if (!WebPIsRGBMode(src_colorspace)) { // only snap for YUV420
- x &= ~1;
- y &= ~1;
- }
- if (!WebPCheckCropDimensions(W, H, x, y, w, h)) {
- return 0; // out of frame boundary error
- }
- }
- io->crop_left = x;
- io->crop_top = y;
- io->crop_right = x + w;
- io->crop_bottom = y + h;
- io->mb_w = w;
- io->mb_h = h;
-
- // Scaling
- io->use_scaling = (options != NULL) && options->use_scaling;
- if (io->use_scaling) {
- int scaled_width = options->scaled_width;
- int scaled_height = options->scaled_height;
- if (!WebPRescalerGetScaledDimensions(w, h, &scaled_width, &scaled_height)) {
- return 0;
- }
- io->scaled_width = scaled_width;
- io->scaled_height = scaled_height;
- }
-
- // Filter
- io->bypass_filtering = (options != NULL) && options->bypass_filtering;
-
- // Fancy upsampler
-#ifdef FANCY_UPSAMPLING
- io->fancy_upsampling = (options == NULL) || (!options->no_fancy_upsampling);
-#endif
-
- if (io->use_scaling) {
- // disable filter (only for large downscaling ratio).
- io->bypass_filtering |= (io->scaled_width < W * 3 / 4) &&
- (io->scaled_height < H * 3 / 4);
- io->fancy_upsampling = 0;
- }
- return 1;
-}
-
-//------------------------------------------------------------------------------
diff --git a/contrib/libs/libwebp/dec/webpi_dec.h b/contrib/libs/libwebp/dec/webpi_dec.h
deleted file mode 100644
index e7778a9f8c..0000000000
--- a/contrib/libs/libwebp/dec/webpi_dec.h
+++ /dev/null
@@ -1,137 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Internal header: WebP decoding parameters and custom IO on buffer
-//
-// Author: somnath@google.com (Somnath Banerjee)
-
-#ifndef WEBP_DEC_WEBPI_DEC_H_
-#define WEBP_DEC_WEBPI_DEC_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "../utils/rescaler_utils.h"
-#include "./vp8_dec.h"
-
-//------------------------------------------------------------------------------
-// WebPDecParams: Decoding output parameters. Transient internal object.
-
-typedef struct WebPDecParams WebPDecParams;
-typedef int (*OutputFunc)(const VP8Io* const io, WebPDecParams* const p);
-typedef int (*OutputAlphaFunc)(const VP8Io* const io, WebPDecParams* const p,
- int expected_num_out_lines);
-typedef int (*OutputRowFunc)(WebPDecParams* const p, int y_pos,
- int max_out_lines);
-
-struct WebPDecParams {
- WebPDecBuffer* output; // output buffer.
- uint8_t* tmp_y, *tmp_u, *tmp_v; // cache for the fancy upsampler
- // or used for tmp rescaling
-
- int last_y; // coordinate of the line that was last output
- const WebPDecoderOptions* options; // if not NULL, use alt decoding features
-
- WebPRescaler* scaler_y, *scaler_u, *scaler_v, *scaler_a; // rescalers
- void* memory; // overall scratch memory for the output work.
-
- OutputFunc emit; // output RGB or YUV samples
- OutputAlphaFunc emit_alpha; // output alpha channel
- OutputRowFunc emit_alpha_row; // output one line of rescaled alpha values
-};
-
-// Should be called first, before any use of the WebPDecParams object.
-void WebPResetDecParams(WebPDecParams* const params);
-
-//------------------------------------------------------------------------------
-// Header parsing helpers
-
-// Structure storing a description of the RIFF headers.
-typedef struct {
- const uint8_t* data; // input buffer
- size_t data_size; // input buffer size
- int have_all_data; // true if all data is known to be available
- size_t offset; // offset to main data chunk (VP8 or VP8L)
- const uint8_t* alpha_data; // points to alpha chunk (if present)
- size_t alpha_data_size; // alpha chunk size
- size_t compressed_size; // VP8/VP8L compressed data size
- size_t riff_size; // size of the riff payload (or 0 if absent)
- int is_lossless; // true if a VP8L chunk is present
-} WebPHeaderStructure;
-
-// Skips over all valid chunks prior to the first VP8/VP8L frame header.
-// Returns: VP8_STATUS_OK, VP8_STATUS_BITSTREAM_ERROR (invalid header/chunk),
-// VP8_STATUS_NOT_ENOUGH_DATA (partial input) or VP8_STATUS_UNSUPPORTED_FEATURE
-// in the case of non-decodable features (animation for instance).
-// In 'headers', compressed_size, offset, alpha_data, alpha_size, and lossless
-// fields are updated appropriately upon success.
-VP8StatusCode WebPParseHeaders(WebPHeaderStructure* const headers);
-
-//------------------------------------------------------------------------------
-// Misc utils
-
-// Returns true if crop dimensions are within image bounds.
-int WebPCheckCropDimensions(int image_width, int image_height,
- int x, int y, int w, int h);
-
-// Initializes VP8Io with custom setup, io and teardown functions. The default
-// hooks will use the supplied 'params' as io->opaque handle.
-void WebPInitCustomIo(WebPDecParams* const params, VP8Io* const io);
-
-// Setup crop_xxx fields, mb_w and mb_h in io. 'src_colorspace' refers
-// to the *compressed* format, not the output one.
-int WebPIoInitFromOptions(const WebPDecoderOptions* const options,
- VP8Io* const io, WEBP_CSP_MODE src_colorspace);
-
-//------------------------------------------------------------------------------
-// Internal functions regarding WebPDecBuffer memory (in buffer.c).
-// Don't really need to be externally visible for now.
-
-// Prepare 'buffer' with the requested initial dimensions width/height.
-// If no external storage is supplied, initializes buffer by allocating output
-// memory and setting up the stride information. Validate the parameters. Return
-// an error code in case of problem (no memory, or invalid stride / size /
-// dimension / etc.). If *options is not NULL, also verify that the options'
-// parameters are valid and apply them to the width/height dimensions of the
-// output buffer. This takes cropping / scaling / rotation into account.
-// Also incorporates the options->flip flag to flip the buffer parameters if
-// needed.
-VP8StatusCode WebPAllocateDecBuffer(int width, int height,
- const WebPDecoderOptions* const options,
- WebPDecBuffer* const buffer);
-
-// Flip buffer vertically by negating the various strides.
-VP8StatusCode WebPFlipBuffer(WebPDecBuffer* const buffer);
-
-// Copy 'src' into 'dst' buffer, making sure 'dst' is not marked as owner of the
-// memory (still held by 'src'). No pixels are copied.
-void WebPCopyDecBuffer(const WebPDecBuffer* const src,
- WebPDecBuffer* const dst);
-
-// Copy and transfer ownership from src to dst (beware of parameter order!)
-void WebPGrabDecBuffer(WebPDecBuffer* const src, WebPDecBuffer* const dst);
-
-// Copy pixels from 'src' into a *preallocated* 'dst' buffer. Returns
-// VP8_STATUS_INVALID_PARAM if the 'dst' is not set up correctly for the copy.
-VP8StatusCode WebPCopyDecBufferPixels(const WebPDecBuffer* const src,
- WebPDecBuffer* const dst);
-
-// Returns true if decoding will be slow with the current configuration
-// and bitstream features.
-int WebPAvoidSlowMemory(const WebPDecBuffer* const output,
- const WebPBitstreamFeatures* const features);
-
-//------------------------------------------------------------------------------
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // WEBP_DEC_WEBPI_DEC_H_
diff --git a/contrib/libs/libwebp/dec/ya.make b/contrib/libs/libwebp/dec/ya.make
deleted file mode 100644
index 479e8fa579..0000000000
--- a/contrib/libs/libwebp/dec/ya.make
+++ /dev/null
@@ -1,37 +0,0 @@
-# Generated by devtools/yamaker.
-
-LIBRARY()
-
-VERSION(1.2.2)
-
-LICENSE(BSD-3-Clause WITH Google-Patent-License-Webm)
-
-LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
-
-ADDINCL(
- contrib/libs/libwebp/dec
- contrib/libs/libwebp/webp
-)
-
-NO_COMPILER_WARNINGS()
-
-NO_RUNTIME()
-
-CFLAGS(
- -DHAVE_CONFIG_H
-)
-
-SRCS(
- alpha_dec.c
- buffer_dec.c
- frame_dec.c
- idec_dec.c
- io_dec.c
- quant_dec.c
- tree_dec.c
- vp8_dec.c
- vp8l_dec.c
- webp_dec.c
-)
-
-END()
diff --git a/contrib/libs/libwebp/demux/.yandex_meta/licenses.list.txt b/contrib/libs/libwebp/demux/.yandex_meta/licenses.list.txt
deleted file mode 100644
index f9eea8228c..0000000000
--- a/contrib/libs/libwebp/demux/.yandex_meta/licenses.list.txt
+++ /dev/null
@@ -1,128 +0,0 @@
-====================BSD-3-Clause WITH Google-Patent-License-Webm====================
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-
-
-====================COPYRIGHT====================
-// Copyright 2012 Google Inc. All Rights Reserved.
-
-
-====================COPYRIGHT====================
-// Copyright 2015 Google Inc. All Rights Reserved.
-
-
-====================File: AUTHORS====================
-Contributors:
-- Aidan O'Loan (aidanol at gmail dot com)
-- Alan Browning (browning at google dot com)
-- Charles Munger (clm at google dot com)
-- Cheng Yi (cyi at google dot com)
-- Christian Duvivier (cduvivier at google dot com)
-- Christopher Degawa (ccom at randomderp dot com)
-- Clement Courbet (courbet at google dot com)
-- Djordje Pesut (djordje dot pesut at imgtec dot com)
-- Hui Su (huisu at google dot com)
-- Ilya Kurdyukov (jpegqs at gmail dot com)
-- Ingvar Stepanyan (rreverser at google dot com)
-- James Zern (jzern at google dot com)
-- Jan Engelhardt (jengelh at medozas dot de)
-- Jehan (jehan at girinstud dot io)
-- Johann Koenig (johann dot koenig at duck dot com)
-- Jovan Zelincevic (jovan dot zelincevic at imgtec dot com)
-- Jyrki Alakuijala (jyrki at google dot com)
-- Konstantin Ivlev (tomskside at gmail dot com)
-- Lode Vandevenne (lode at google dot com)
-- Lou Quillio (louquillio at google dot com)
-- Mans Rullgard (mans at mansr dot com)
-- Marcin Kowalczyk (qrczak at google dot com)
-- Martin Olsson (mnemo at minimum dot se)
-- Mikołaj Zalewski (mikolajz at google dot com)
-- Mislav Bradac (mislavm at google dot com)
-- Nico Weber (thakis at chromium dot org)
-- Noel Chromium (noel at chromium dot org)
-- Oliver Wolff (oliver dot wolff at qt dot io)
-- Owen Rodley (orodley at google dot com)
-- Parag Salasakar (img dot mips1 at gmail dot com)
-- Pascal Massimino (pascal dot massimino at gmail dot com)
-- Paweł Hajdan, Jr (phajdan dot jr at chromium dot org)
-- Pierre Joye (pierre dot php at gmail dot com)
-- Roberto Alanis (alanisbaez at google dot com)
-- Sam Clegg (sbc at chromium dot org)
-- Scott Hancher (seh at google dot com)
-- Scott LaVarnway (slavarnway at google dot com)
-- Scott Talbot (s at chikachow dot org)
-- Slobodan Prijic (slobodan dot prijic at imgtec dot com)
-- Somnath Banerjee (somnath dot banerjee at gmail dot com)
-- Sriraman Tallam (tmsriram at google dot com)
-- Tamar Levy (tamar dot levy at intel dot com)
-- Timothy Gu (timothygu99 at gmail dot com)
-- Urvang Joshi (urvang at google dot com)
-- Vikas Arora (vikasa at google dot com)
-- Vincent Rabaud (vrabaud at google dot com)
-- Vlad Tsyrklevich (vtsyrklevich at chromium dot org)
-- Wan-Teh Chang (wtc at google dot com)
-- Yang Zhang (yang dot zhang at arm dot com)
-- Yannis Guyon (yguyon at google dot com)
-- Zhi An Ng (zhin at chromium dot org)
-
-
-====================File: COPYING====================
-Copyright (c) 2010, Google Inc. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
-
- * Neither the name of Google nor the names of its contributors may
- be used to endorse or promote products derived from this software
- without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-
-====================File: PATENTS====================
-Additional IP Rights Grant (Patents)
-------------------------------------
-
-"These implementations" means the copyrightable works that implement the WebM
-codecs distributed by Google as part of the WebM Project.
-
-Google hereby grants to you a perpetual, worldwide, non-exclusive, no-charge,
-royalty-free, irrevocable (except as stated in this section) patent license to
-make, have made, use, offer to sell, sell, import, transfer, and otherwise
-run, modify and propagate the contents of these implementations of WebM, where
-such license applies only to those patent claims, both currently owned by
-Google and acquired in the future, licensable by Google that are necessarily
-infringed by these implementations of WebM. This grant does not include claims
-that would be infringed only as a consequence of further modification of these
-implementations. If you or your agent or exclusive licensee institute or order
-or agree to the institution of patent litigation or any other patent
-enforcement activity against any entity (including a cross-claim or
-counterclaim in a lawsuit) alleging that any of these implementations of WebM
-or any code incorporated within any of these implementations of WebM
-constitute direct or contributory patent infringement, or inducement of
-patent infringement, then any patent rights granted to you under this License
-for these implementations of WebM shall terminate as of the date such
-litigation is filed.
diff --git a/contrib/libs/libwebp/demux/anim_decode.c b/contrib/libs/libwebp/demux/anim_decode.c
deleted file mode 100644
index 520711c293..0000000000
--- a/contrib/libs/libwebp/demux/anim_decode.c
+++ /dev/null
@@ -1,473 +0,0 @@
-// Copyright 2015 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// AnimDecoder implementation.
-//
-
-#ifdef HAVE_CONFIG_H
-#include "../webp/config.h"
-#endif
-
-#include <assert.h>
-#include <string.h>
-
-#include "../utils/utils.h"
-#include "../webp/decode.h"
-#include "../webp/demux.h"
-
-#define NUM_CHANNELS 4
-
-// Channel extraction from a uint32_t representation of a uint8_t RGBA/BGRA
-// buffer.
-#ifdef WORDS_BIGENDIAN
-#define CHANNEL_SHIFT(i) (24 - (i) * 8)
-#else
-#define CHANNEL_SHIFT(i) ((i) * 8)
-#endif
-
-typedef void (*BlendRowFunc)(uint32_t* const, const uint32_t* const, int);
-static void BlendPixelRowNonPremult(uint32_t* const src,
- const uint32_t* const dst, int num_pixels);
-static void BlendPixelRowPremult(uint32_t* const src, const uint32_t* const dst,
- int num_pixels);
-
-struct WebPAnimDecoder {
- WebPDemuxer* demux_; // Demuxer created from given WebP bitstream.
- WebPDecoderConfig config_; // Decoder config.
- // Note: we use a pointer to a function blending multiple pixels at a time to
- // allow possible inlining of per-pixel blending function.
- BlendRowFunc blend_func_; // Pointer to the chose blend row function.
- WebPAnimInfo info_; // Global info about the animation.
- uint8_t* curr_frame_; // Current canvas (not disposed).
- uint8_t* prev_frame_disposed_; // Previous canvas (properly disposed).
- int prev_frame_timestamp_; // Previous frame timestamp (milliseconds).
- WebPIterator prev_iter_; // Iterator object for previous frame.
- int prev_frame_was_keyframe_; // True if previous frame was a keyframe.
- int next_frame_; // Index of the next frame to be decoded
- // (starting from 1).
-};
-
-static void DefaultDecoderOptions(WebPAnimDecoderOptions* const dec_options) {
- dec_options->color_mode = MODE_RGBA;
- dec_options->use_threads = 0;
-}
-
-int WebPAnimDecoderOptionsInitInternal(WebPAnimDecoderOptions* dec_options,
- int abi_version) {
- if (dec_options == NULL ||
- WEBP_ABI_IS_INCOMPATIBLE(abi_version, WEBP_DEMUX_ABI_VERSION)) {
- return 0;
- }
- DefaultDecoderOptions(dec_options);
- return 1;
-}
-
-static int ApplyDecoderOptions(const WebPAnimDecoderOptions* const dec_options,
- WebPAnimDecoder* const dec) {
- WEBP_CSP_MODE mode;
- WebPDecoderConfig* config = &dec->config_;
- assert(dec_options != NULL);
-
- mode = dec_options->color_mode;
- if (mode != MODE_RGBA && mode != MODE_BGRA &&
- mode != MODE_rgbA && mode != MODE_bgrA) {
- return 0;
- }
- dec->blend_func_ = (mode == MODE_RGBA || mode == MODE_BGRA)
- ? &BlendPixelRowNonPremult
- : &BlendPixelRowPremult;
- WebPInitDecoderConfig(config);
- config->output.colorspace = mode;
- config->output.is_external_memory = 1;
- config->options.use_threads = dec_options->use_threads;
- // Note: config->output.u.RGBA is set at the time of decoding each frame.
- return 1;
-}
-
-WebPAnimDecoder* WebPAnimDecoderNewInternal(
- const WebPData* webp_data, const WebPAnimDecoderOptions* dec_options,
- int abi_version) {
- WebPAnimDecoderOptions options;
- WebPAnimDecoder* dec = NULL;
- WebPBitstreamFeatures features;
- if (webp_data == NULL ||
- WEBP_ABI_IS_INCOMPATIBLE(abi_version, WEBP_DEMUX_ABI_VERSION)) {
- return NULL;
- }
-
- // Validate the bitstream before doing expensive allocations. The demuxer may
- // be more tolerant than the decoder.
- if (WebPGetFeatures(webp_data->bytes, webp_data->size, &features) !=
- VP8_STATUS_OK) {
- return NULL;
- }
-
- // Note: calloc() so that the pointer members are initialized to NULL.
- dec = (WebPAnimDecoder*)WebPSafeCalloc(1ULL, sizeof(*dec));
- if (dec == NULL) goto Error;
-
- if (dec_options != NULL) {
- options = *dec_options;
- } else {
- DefaultDecoderOptions(&options);
- }
- if (!ApplyDecoderOptions(&options, dec)) goto Error;
-
- dec->demux_ = WebPDemux(webp_data);
- if (dec->demux_ == NULL) goto Error;
-
- dec->info_.canvas_width = WebPDemuxGetI(dec->demux_, WEBP_FF_CANVAS_WIDTH);
- dec->info_.canvas_height = WebPDemuxGetI(dec->demux_, WEBP_FF_CANVAS_HEIGHT);
- dec->info_.loop_count = WebPDemuxGetI(dec->demux_, WEBP_FF_LOOP_COUNT);
- dec->info_.bgcolor = WebPDemuxGetI(dec->demux_, WEBP_FF_BACKGROUND_COLOR);
- dec->info_.frame_count = WebPDemuxGetI(dec->demux_, WEBP_FF_FRAME_COUNT);
-
- // Note: calloc() because we fill frame with zeroes as well.
- dec->curr_frame_ = (uint8_t*)WebPSafeCalloc(
- dec->info_.canvas_width * NUM_CHANNELS, dec->info_.canvas_height);
- if (dec->curr_frame_ == NULL) goto Error;
- dec->prev_frame_disposed_ = (uint8_t*)WebPSafeCalloc(
- dec->info_.canvas_width * NUM_CHANNELS, dec->info_.canvas_height);
- if (dec->prev_frame_disposed_ == NULL) goto Error;
-
- WebPAnimDecoderReset(dec);
- return dec;
-
- Error:
- WebPAnimDecoderDelete(dec);
- return NULL;
-}
-
-int WebPAnimDecoderGetInfo(const WebPAnimDecoder* dec, WebPAnimInfo* info) {
- if (dec == NULL || info == NULL) return 0;
- *info = dec->info_;
- return 1;
-}
-
-// Returns true if the frame covers the full canvas.
-static int IsFullFrame(int width, int height, int canvas_width,
- int canvas_height) {
- return (width == canvas_width && height == canvas_height);
-}
-
-// Clear the canvas to transparent.
-static int ZeroFillCanvas(uint8_t* buf, uint32_t canvas_width,
- uint32_t canvas_height) {
- const uint64_t size =
- (uint64_t)canvas_width * canvas_height * NUM_CHANNELS * sizeof(*buf);
- if (!CheckSizeOverflow(size)) return 0;
- memset(buf, 0, (size_t)size);
- return 1;
-}
-
-// Clear given frame rectangle to transparent.
-static void ZeroFillFrameRect(uint8_t* buf, int buf_stride, int x_offset,
- int y_offset, int width, int height) {
- int j;
- assert(width * NUM_CHANNELS <= buf_stride);
- buf += y_offset * buf_stride + x_offset * NUM_CHANNELS;
- for (j = 0; j < height; ++j) {
- memset(buf, 0, width * NUM_CHANNELS);
- buf += buf_stride;
- }
-}
-
-// Copy width * height pixels from 'src' to 'dst'.
-static int CopyCanvas(const uint8_t* src, uint8_t* dst,
- uint32_t width, uint32_t height) {
- const uint64_t size = (uint64_t)width * height * NUM_CHANNELS;
- if (!CheckSizeOverflow(size)) return 0;
- assert(src != NULL && dst != NULL);
- memcpy(dst, src, (size_t)size);
- return 1;
-}
-
-// Returns true if the current frame is a key-frame.
-static int IsKeyFrame(const WebPIterator* const curr,
- const WebPIterator* const prev,
- int prev_frame_was_key_frame,
- int canvas_width, int canvas_height) {
- if (curr->frame_num == 1) {
- return 1;
- } else if ((!curr->has_alpha || curr->blend_method == WEBP_MUX_NO_BLEND) &&
- IsFullFrame(curr->width, curr->height,
- canvas_width, canvas_height)) {
- return 1;
- } else {
- return (prev->dispose_method == WEBP_MUX_DISPOSE_BACKGROUND) &&
- (IsFullFrame(prev->width, prev->height, canvas_width,
- canvas_height) ||
- prev_frame_was_key_frame);
- }
-}
-
-
-// Blend a single channel of 'src' over 'dst', given their alpha channel values.
-// 'src' and 'dst' are assumed to be NOT pre-multiplied by alpha.
-static uint8_t BlendChannelNonPremult(uint32_t src, uint8_t src_a,
- uint32_t dst, uint8_t dst_a,
- uint32_t scale, int shift) {
- const uint8_t src_channel = (src >> shift) & 0xff;
- const uint8_t dst_channel = (dst >> shift) & 0xff;
- const uint32_t blend_unscaled = src_channel * src_a + dst_channel * dst_a;
- assert(blend_unscaled < (1ULL << 32) / scale);
- return (blend_unscaled * scale) >> CHANNEL_SHIFT(3);
-}
-
-// Blend 'src' over 'dst' assuming they are NOT pre-multiplied by alpha.
-static uint32_t BlendPixelNonPremult(uint32_t src, uint32_t dst) {
- const uint8_t src_a = (src >> CHANNEL_SHIFT(3)) & 0xff;
-
- if (src_a == 0) {
- return dst;
- } else {
- const uint8_t dst_a = (dst >> CHANNEL_SHIFT(3)) & 0xff;
- // This is the approximate integer arithmetic for the actual formula:
- // dst_factor_a = (dst_a * (255 - src_a)) / 255.
- const uint8_t dst_factor_a = (dst_a * (256 - src_a)) >> 8;
- const uint8_t blend_a = src_a + dst_factor_a;
- const uint32_t scale = (1UL << 24) / blend_a;
-
- const uint8_t blend_r = BlendChannelNonPremult(
- src, src_a, dst, dst_factor_a, scale, CHANNEL_SHIFT(0));
- const uint8_t blend_g = BlendChannelNonPremult(
- src, src_a, dst, dst_factor_a, scale, CHANNEL_SHIFT(1));
- const uint8_t blend_b = BlendChannelNonPremult(
- src, src_a, dst, dst_factor_a, scale, CHANNEL_SHIFT(2));
- assert(src_a + dst_factor_a < 256);
-
- return ((uint32_t)blend_r << CHANNEL_SHIFT(0)) |
- ((uint32_t)blend_g << CHANNEL_SHIFT(1)) |
- ((uint32_t)blend_b << CHANNEL_SHIFT(2)) |
- ((uint32_t)blend_a << CHANNEL_SHIFT(3));
- }
-}
-
-// Blend 'num_pixels' in 'src' over 'dst' assuming they are NOT pre-multiplied
-// by alpha.
-static void BlendPixelRowNonPremult(uint32_t* const src,
- const uint32_t* const dst, int num_pixels) {
- int i;
- for (i = 0; i < num_pixels; ++i) {
- const uint8_t src_alpha = (src[i] >> CHANNEL_SHIFT(3)) & 0xff;
- if (src_alpha != 0xff) {
- src[i] = BlendPixelNonPremult(src[i], dst[i]);
- }
- }
-}
-
-// Individually multiply each channel in 'pix' by 'scale'.
-static WEBP_INLINE uint32_t ChannelwiseMultiply(uint32_t pix, uint32_t scale) {
- uint32_t mask = 0x00FF00FF;
- uint32_t rb = ((pix & mask) * scale) >> 8;
- uint32_t ag = ((pix >> 8) & mask) * scale;
- return (rb & mask) | (ag & ~mask);
-}
-
-// Blend 'src' over 'dst' assuming they are pre-multiplied by alpha.
-static uint32_t BlendPixelPremult(uint32_t src, uint32_t dst) {
- const uint8_t src_a = (src >> CHANNEL_SHIFT(3)) & 0xff;
- return src + ChannelwiseMultiply(dst, 256 - src_a);
-}
-
-// Blend 'num_pixels' in 'src' over 'dst' assuming they are pre-multiplied by
-// alpha.
-static void BlendPixelRowPremult(uint32_t* const src, const uint32_t* const dst,
- int num_pixels) {
- int i;
- for (i = 0; i < num_pixels; ++i) {
- const uint8_t src_alpha = (src[i] >> CHANNEL_SHIFT(3)) & 0xff;
- if (src_alpha != 0xff) {
- src[i] = BlendPixelPremult(src[i], dst[i]);
- }
- }
-}
-
-// Returns two ranges (<left, width> pairs) at row 'canvas_y', that belong to
-// 'src' but not 'dst'. A point range is empty if the corresponding width is 0.
-static void FindBlendRangeAtRow(const WebPIterator* const src,
- const WebPIterator* const dst, int canvas_y,
- int* const left1, int* const width1,
- int* const left2, int* const width2) {
- const int src_max_x = src->x_offset + src->width;
- const int dst_max_x = dst->x_offset + dst->width;
- const int dst_max_y = dst->y_offset + dst->height;
- assert(canvas_y >= src->y_offset && canvas_y < (src->y_offset + src->height));
- *left1 = -1;
- *width1 = 0;
- *left2 = -1;
- *width2 = 0;
-
- if (canvas_y < dst->y_offset || canvas_y >= dst_max_y ||
- src->x_offset >= dst_max_x || src_max_x <= dst->x_offset) {
- *left1 = src->x_offset;
- *width1 = src->width;
- return;
- }
-
- if (src->x_offset < dst->x_offset) {
- *left1 = src->x_offset;
- *width1 = dst->x_offset - src->x_offset;
- }
-
- if (src_max_x > dst_max_x) {
- *left2 = dst_max_x;
- *width2 = src_max_x - dst_max_x;
- }
-}
-
-int WebPAnimDecoderGetNext(WebPAnimDecoder* dec,
- uint8_t** buf_ptr, int* timestamp_ptr) {
- WebPIterator iter;
- uint32_t width;
- uint32_t height;
- int is_key_frame;
- int timestamp;
- BlendRowFunc blend_row;
-
- if (dec == NULL || buf_ptr == NULL || timestamp_ptr == NULL) return 0;
- if (!WebPAnimDecoderHasMoreFrames(dec)) return 0;
-
- width = dec->info_.canvas_width;
- height = dec->info_.canvas_height;
- blend_row = dec->blend_func_;
-
- // Get compressed frame.
- if (!WebPDemuxGetFrame(dec->demux_, dec->next_frame_, &iter)) {
- return 0;
- }
- timestamp = dec->prev_frame_timestamp_ + iter.duration;
-
- // Initialize.
- is_key_frame = IsKeyFrame(&iter, &dec->prev_iter_,
- dec->prev_frame_was_keyframe_, width, height);
- if (is_key_frame) {
- if (!ZeroFillCanvas(dec->curr_frame_, width, height)) {
- goto Error;
- }
- } else {
- if (!CopyCanvas(dec->prev_frame_disposed_, dec->curr_frame_,
- width, height)) {
- goto Error;
- }
- }
-
- // Decode.
- {
- const uint8_t* in = iter.fragment.bytes;
- const size_t in_size = iter.fragment.size;
- const uint32_t stride = width * NUM_CHANNELS; // at most 25 + 2 bits
- const uint64_t out_offset = (uint64_t)iter.y_offset * stride +
- (uint64_t)iter.x_offset * NUM_CHANNELS; // 53b
- const uint64_t size = (uint64_t)iter.height * stride; // at most 25 + 27b
- WebPDecoderConfig* const config = &dec->config_;
- WebPRGBABuffer* const buf = &config->output.u.RGBA;
- if ((size_t)size != size) goto Error;
- buf->stride = (int)stride;
- buf->size = (size_t)size;
- buf->rgba = dec->curr_frame_ + out_offset;
-
- if (WebPDecode(in, in_size, config) != VP8_STATUS_OK) {
- goto Error;
- }
- }
-
- // During the decoding of current frame, we may have set some pixels to be
- // transparent (i.e. alpha < 255). However, the value of each of these
- // pixels should have been determined by blending it against the value of
- // that pixel in the previous frame if blending method of is WEBP_MUX_BLEND.
- if (iter.frame_num > 1 && iter.blend_method == WEBP_MUX_BLEND &&
- !is_key_frame) {
- if (dec->prev_iter_.dispose_method == WEBP_MUX_DISPOSE_NONE) {
- int y;
- // Blend transparent pixels with pixels in previous canvas.
- for (y = 0; y < iter.height; ++y) {
- const size_t offset =
- (iter.y_offset + y) * width + iter.x_offset;
- blend_row((uint32_t*)dec->curr_frame_ + offset,
- (uint32_t*)dec->prev_frame_disposed_ + offset, iter.width);
- }
- } else {
- int y;
- assert(dec->prev_iter_.dispose_method == WEBP_MUX_DISPOSE_BACKGROUND);
- // We need to blend a transparent pixel with its value just after
- // initialization. That is, blend it with:
- // * Fully transparent pixel if it belongs to prevRect <-- No-op.
- // * The pixel in the previous canvas otherwise <-- Need alpha-blending.
- for (y = 0; y < iter.height; ++y) {
- const int canvas_y = iter.y_offset + y;
- int left1, width1, left2, width2;
- FindBlendRangeAtRow(&iter, &dec->prev_iter_, canvas_y, &left1, &width1,
- &left2, &width2);
- if (width1 > 0) {
- const size_t offset1 = canvas_y * width + left1;
- blend_row((uint32_t*)dec->curr_frame_ + offset1,
- (uint32_t*)dec->prev_frame_disposed_ + offset1, width1);
- }
- if (width2 > 0) {
- const size_t offset2 = canvas_y * width + left2;
- blend_row((uint32_t*)dec->curr_frame_ + offset2,
- (uint32_t*)dec->prev_frame_disposed_ + offset2, width2);
- }
- }
- }
- }
-
- // Update info of the previous frame and dispose it for the next iteration.
- dec->prev_frame_timestamp_ = timestamp;
- WebPDemuxReleaseIterator(&dec->prev_iter_);
- dec->prev_iter_ = iter;
- dec->prev_frame_was_keyframe_ = is_key_frame;
- CopyCanvas(dec->curr_frame_, dec->prev_frame_disposed_, width, height);
- if (dec->prev_iter_.dispose_method == WEBP_MUX_DISPOSE_BACKGROUND) {
- ZeroFillFrameRect(dec->prev_frame_disposed_, width * NUM_CHANNELS,
- dec->prev_iter_.x_offset, dec->prev_iter_.y_offset,
- dec->prev_iter_.width, dec->prev_iter_.height);
- }
- ++dec->next_frame_;
-
- // All OK, fill in the values.
- *buf_ptr = dec->curr_frame_;
- *timestamp_ptr = timestamp;
- return 1;
-
- Error:
- WebPDemuxReleaseIterator(&iter);
- return 0;
-}
-
-int WebPAnimDecoderHasMoreFrames(const WebPAnimDecoder* dec) {
- if (dec == NULL) return 0;
- return (dec->next_frame_ <= (int)dec->info_.frame_count);
-}
-
-void WebPAnimDecoderReset(WebPAnimDecoder* dec) {
- if (dec != NULL) {
- dec->prev_frame_timestamp_ = 0;
- WebPDemuxReleaseIterator(&dec->prev_iter_);
- memset(&dec->prev_iter_, 0, sizeof(dec->prev_iter_));
- dec->prev_frame_was_keyframe_ = 0;
- dec->next_frame_ = 1;
- }
-}
-
-const WebPDemuxer* WebPAnimDecoderGetDemuxer(const WebPAnimDecoder* dec) {
- if (dec == NULL) return NULL;
- return dec->demux_;
-}
-
-void WebPAnimDecoderDelete(WebPAnimDecoder* dec) {
- if (dec != NULL) {
- WebPDemuxReleaseIterator(&dec->prev_iter_);
- WebPDemuxDelete(dec->demux_);
- WebPSafeFree(dec->curr_frame_);
- WebPSafeFree(dec->prev_frame_disposed_);
- WebPSafeFree(dec);
- }
-}
diff --git a/contrib/libs/libwebp/demux/demux.c b/contrib/libs/libwebp/demux/demux.c
deleted file mode 100644
index 13953b1c54..0000000000
--- a/contrib/libs/libwebp/demux/demux.c
+++ /dev/null
@@ -1,978 +0,0 @@
-// Copyright 2012 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// WebP container demux.
-//
-
-#ifdef HAVE_CONFIG_H
-#include "../webp/config.h"
-#endif
-
-#include <assert.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "../utils/utils.h"
-#include "../webp/decode.h" // WebPGetFeatures
-#include "../webp/demux.h"
-#include "../webp/format_constants.h"
-
-#define DMUX_MAJ_VERSION 1
-#define DMUX_MIN_VERSION 2
-#define DMUX_REV_VERSION 2
-
-typedef struct {
- size_t start_; // start location of the data
- size_t end_; // end location
- size_t riff_end_; // riff chunk end location, can be > end_.
- size_t buf_size_; // size of the buffer
- const uint8_t* buf_;
-} MemBuffer;
-
-typedef struct {
- size_t offset_;
- size_t size_;
-} ChunkData;
-
-typedef struct Frame {
- int x_offset_, y_offset_;
- int width_, height_;
- int has_alpha_;
- int duration_;
- WebPMuxAnimDispose dispose_method_;
- WebPMuxAnimBlend blend_method_;
- int frame_num_;
- int complete_; // img_components_ contains a full image.
- ChunkData img_components_[2]; // 0=VP8{,L} 1=ALPH
- struct Frame* next_;
-} Frame;
-
-typedef struct Chunk {
- ChunkData data_;
- struct Chunk* next_;
-} Chunk;
-
-struct WebPDemuxer {
- MemBuffer mem_;
- WebPDemuxState state_;
- int is_ext_format_;
- uint32_t feature_flags_;
- int canvas_width_, canvas_height_;
- int loop_count_;
- uint32_t bgcolor_;
- int num_frames_;
- Frame* frames_;
- Frame** frames_tail_;
- Chunk* chunks_; // non-image chunks
- Chunk** chunks_tail_;
-};
-
-typedef enum {
- PARSE_OK,
- PARSE_NEED_MORE_DATA,
- PARSE_ERROR
-} ParseStatus;
-
-typedef struct ChunkParser {
- uint8_t id[4];
- ParseStatus (*parse)(WebPDemuxer* const dmux);
- int (*valid)(const WebPDemuxer* const dmux);
-} ChunkParser;
-
-static ParseStatus ParseSingleImage(WebPDemuxer* const dmux);
-static ParseStatus ParseVP8X(WebPDemuxer* const dmux);
-static int IsValidSimpleFormat(const WebPDemuxer* const dmux);
-static int IsValidExtendedFormat(const WebPDemuxer* const dmux);
-
-static const ChunkParser kMasterChunks[] = {
- { { 'V', 'P', '8', ' ' }, ParseSingleImage, IsValidSimpleFormat },
- { { 'V', 'P', '8', 'L' }, ParseSingleImage, IsValidSimpleFormat },
- { { 'V', 'P', '8', 'X' }, ParseVP8X, IsValidExtendedFormat },
- { { '0', '0', '0', '0' }, NULL, NULL },
-};
-
-//------------------------------------------------------------------------------
-
-int WebPGetDemuxVersion(void) {
- return (DMUX_MAJ_VERSION << 16) | (DMUX_MIN_VERSION << 8) | DMUX_REV_VERSION;
-}
-
-// -----------------------------------------------------------------------------
-// MemBuffer
-
-static int RemapMemBuffer(MemBuffer* const mem,
- const uint8_t* data, size_t size) {
- if (size < mem->buf_size_) return 0; // can't remap to a shorter buffer!
-
- mem->buf_ = data;
- mem->end_ = mem->buf_size_ = size;
- return 1;
-}
-
-static int InitMemBuffer(MemBuffer* const mem,
- const uint8_t* data, size_t size) {
- memset(mem, 0, sizeof(*mem));
- return RemapMemBuffer(mem, data, size);
-}
-
-// Return the remaining data size available in 'mem'.
-static WEBP_INLINE size_t MemDataSize(const MemBuffer* const mem) {
- return (mem->end_ - mem->start_);
-}
-
-// Return true if 'size' exceeds the end of the RIFF chunk.
-static WEBP_INLINE int SizeIsInvalid(const MemBuffer* const mem, size_t size) {
- return (size > mem->riff_end_ - mem->start_);
-}
-
-static WEBP_INLINE void Skip(MemBuffer* const mem, size_t size) {
- mem->start_ += size;
-}
-
-static WEBP_INLINE void Rewind(MemBuffer* const mem, size_t size) {
- mem->start_ -= size;
-}
-
-static WEBP_INLINE const uint8_t* GetBuffer(MemBuffer* const mem) {
- return mem->buf_ + mem->start_;
-}
-
-// Read from 'mem' and skip the read bytes.
-static WEBP_INLINE uint8_t ReadByte(MemBuffer* const mem) {
- const uint8_t byte = mem->buf_[mem->start_];
- Skip(mem, 1);
- return byte;
-}
-
-static WEBP_INLINE int ReadLE16s(MemBuffer* const mem) {
- const uint8_t* const data = mem->buf_ + mem->start_;
- const int val = GetLE16(data);
- Skip(mem, 2);
- return val;
-}
-
-static WEBP_INLINE int ReadLE24s(MemBuffer* const mem) {
- const uint8_t* const data = mem->buf_ + mem->start_;
- const int val = GetLE24(data);
- Skip(mem, 3);
- return val;
-}
-
-static WEBP_INLINE uint32_t ReadLE32(MemBuffer* const mem) {
- const uint8_t* const data = mem->buf_ + mem->start_;
- const uint32_t val = GetLE32(data);
- Skip(mem, 4);
- return val;
-}
-
-// -----------------------------------------------------------------------------
-// Secondary chunk parsing
-
-static void AddChunk(WebPDemuxer* const dmux, Chunk* const chunk) {
- *dmux->chunks_tail_ = chunk;
- chunk->next_ = NULL;
- dmux->chunks_tail_ = &chunk->next_;
-}
-
-// Add a frame to the end of the list, ensuring the last frame is complete.
-// Returns true on success, false otherwise.
-static int AddFrame(WebPDemuxer* const dmux, Frame* const frame) {
- const Frame* const last_frame = *dmux->frames_tail_;
- if (last_frame != NULL && !last_frame->complete_) return 0;
-
- *dmux->frames_tail_ = frame;
- frame->next_ = NULL;
- dmux->frames_tail_ = &frame->next_;
- return 1;
-}
-
-static void SetFrameInfo(size_t start_offset, size_t size,
- int frame_num, int complete,
- const WebPBitstreamFeatures* const features,
- Frame* const frame) {
- frame->img_components_[0].offset_ = start_offset;
- frame->img_components_[0].size_ = size;
- frame->width_ = features->width;
- frame->height_ = features->height;
- frame->has_alpha_ |= features->has_alpha;
- frame->frame_num_ = frame_num;
- frame->complete_ = complete;
-}
-
-// Store image bearing chunks to 'frame'. 'min_size' is an optional size
-// requirement, it may be zero.
-static ParseStatus StoreFrame(int frame_num, uint32_t min_size,
- MemBuffer* const mem, Frame* const frame) {
- int alpha_chunks = 0;
- int image_chunks = 0;
- int done = (MemDataSize(mem) < CHUNK_HEADER_SIZE ||
- MemDataSize(mem) < min_size);
- ParseStatus status = PARSE_OK;
-
- if (done) return PARSE_NEED_MORE_DATA;
-
- do {
- const size_t chunk_start_offset = mem->start_;
- const uint32_t fourcc = ReadLE32(mem);
- const uint32_t payload_size = ReadLE32(mem);
- uint32_t payload_size_padded;
- size_t payload_available;
- size_t chunk_size;
-
- if (payload_size > MAX_CHUNK_PAYLOAD) return PARSE_ERROR;
-
- payload_size_padded = payload_size + (payload_size & 1);
- payload_available = (payload_size_padded > MemDataSize(mem))
- ? MemDataSize(mem) : payload_size_padded;
- chunk_size = CHUNK_HEADER_SIZE + payload_available;
- if (SizeIsInvalid(mem, payload_size_padded)) return PARSE_ERROR;
- if (payload_size_padded > MemDataSize(mem)) status = PARSE_NEED_MORE_DATA;
-
- switch (fourcc) {
- case MKFOURCC('A', 'L', 'P', 'H'):
- if (alpha_chunks == 0) {
- ++alpha_chunks;
- frame->img_components_[1].offset_ = chunk_start_offset;
- frame->img_components_[1].size_ = chunk_size;
- frame->has_alpha_ = 1;
- frame->frame_num_ = frame_num;
- Skip(mem, payload_available);
- } else {
- goto Done;
- }
- break;
- case MKFOURCC('V', 'P', '8', 'L'):
- if (alpha_chunks > 0) return PARSE_ERROR; // VP8L has its own alpha
- // fall through
- case MKFOURCC('V', 'P', '8', ' '):
- if (image_chunks == 0) {
- // Extract the bitstream features, tolerating failures when the data
- // is incomplete.
- WebPBitstreamFeatures features;
- const VP8StatusCode vp8_status =
- WebPGetFeatures(mem->buf_ + chunk_start_offset, chunk_size,
- &features);
- if (status == PARSE_NEED_MORE_DATA &&
- vp8_status == VP8_STATUS_NOT_ENOUGH_DATA) {
- return PARSE_NEED_MORE_DATA;
- } else if (vp8_status != VP8_STATUS_OK) {
- // We have enough data, and yet WebPGetFeatures() failed.
- return PARSE_ERROR;
- }
- ++image_chunks;
- SetFrameInfo(chunk_start_offset, chunk_size, frame_num,
- status == PARSE_OK, &features, frame);
- Skip(mem, payload_available);
- } else {
- goto Done;
- }
- break;
- Done:
- default:
- // Restore fourcc/size when moving up one level in parsing.
- Rewind(mem, CHUNK_HEADER_SIZE);
- done = 1;
- break;
- }
-
- if (mem->start_ == mem->riff_end_) {
- done = 1;
- } else if (MemDataSize(mem) < CHUNK_HEADER_SIZE) {
- status = PARSE_NEED_MORE_DATA;
- }
- } while (!done && status == PARSE_OK);
-
- return status;
-}
-
-// Creates a new Frame if 'actual_size' is within bounds and 'mem' contains
-// enough data ('min_size') to parse the payload.
-// Returns PARSE_OK on success with *frame pointing to the new Frame.
-// Returns PARSE_NEED_MORE_DATA with insufficient data, PARSE_ERROR otherwise.
-static ParseStatus NewFrame(const MemBuffer* const mem,
- uint32_t min_size, uint32_t actual_size,
- Frame** frame) {
- if (SizeIsInvalid(mem, min_size)) return PARSE_ERROR;
- if (actual_size < min_size) return PARSE_ERROR;
- if (MemDataSize(mem) < min_size) return PARSE_NEED_MORE_DATA;
-
- *frame = (Frame*)WebPSafeCalloc(1ULL, sizeof(**frame));
- return (*frame == NULL) ? PARSE_ERROR : PARSE_OK;
-}
-
-// Parse a 'ANMF' chunk and any image bearing chunks that immediately follow.
-// 'frame_chunk_size' is the previously validated, padded chunk size.
-static ParseStatus ParseAnimationFrame(
- WebPDemuxer* const dmux, uint32_t frame_chunk_size) {
- const int is_animation = !!(dmux->feature_flags_ & ANIMATION_FLAG);
- const uint32_t anmf_payload_size = frame_chunk_size - ANMF_CHUNK_SIZE;
- int added_frame = 0;
- int bits;
- MemBuffer* const mem = &dmux->mem_;
- Frame* frame;
- size_t start_offset;
- ParseStatus status =
- NewFrame(mem, ANMF_CHUNK_SIZE, frame_chunk_size, &frame);
- if (status != PARSE_OK) return status;
-
- frame->x_offset_ = 2 * ReadLE24s(mem);
- frame->y_offset_ = 2 * ReadLE24s(mem);
- frame->width_ = 1 + ReadLE24s(mem);
- frame->height_ = 1 + ReadLE24s(mem);
- frame->duration_ = ReadLE24s(mem);
- bits = ReadByte(mem);
- frame->dispose_method_ =
- (bits & 1) ? WEBP_MUX_DISPOSE_BACKGROUND : WEBP_MUX_DISPOSE_NONE;
- frame->blend_method_ = (bits & 2) ? WEBP_MUX_NO_BLEND : WEBP_MUX_BLEND;
- if (frame->width_ * (uint64_t)frame->height_ >= MAX_IMAGE_AREA) {
- WebPSafeFree(frame);
- return PARSE_ERROR;
- }
-
- // Store a frame only if the animation flag is set there is some data for
- // this frame is available.
- start_offset = mem->start_;
- status = StoreFrame(dmux->num_frames_ + 1, anmf_payload_size, mem, frame);
- if (status != PARSE_ERROR && mem->start_ - start_offset > anmf_payload_size) {
- status = PARSE_ERROR;
- }
- if (status != PARSE_ERROR && is_animation && frame->frame_num_ > 0) {
- added_frame = AddFrame(dmux, frame);
- if (added_frame) {
- ++dmux->num_frames_;
- } else {
- status = PARSE_ERROR;
- }
- }
-
- if (!added_frame) WebPSafeFree(frame);
- return status;
-}
-
-// General chunk storage, starting with the header at 'start_offset', allowing
-// the user to request the payload via a fourcc string. 'size' includes the
-// header and the unpadded payload size.
-// Returns true on success, false otherwise.
-static int StoreChunk(WebPDemuxer* const dmux,
- size_t start_offset, uint32_t size) {
- Chunk* const chunk = (Chunk*)WebPSafeCalloc(1ULL, sizeof(*chunk));
- if (chunk == NULL) return 0;
-
- chunk->data_.offset_ = start_offset;
- chunk->data_.size_ = size;
- AddChunk(dmux, chunk);
- return 1;
-}
-
-// -----------------------------------------------------------------------------
-// Primary chunk parsing
-
-static ParseStatus ReadHeader(MemBuffer* const mem) {
- const size_t min_size = RIFF_HEADER_SIZE + CHUNK_HEADER_SIZE;
- uint32_t riff_size;
-
- // Basic file level validation.
- if (MemDataSize(mem) < min_size) return PARSE_NEED_MORE_DATA;
- if (memcmp(GetBuffer(mem), "RIFF", CHUNK_SIZE_BYTES) ||
- memcmp(GetBuffer(mem) + CHUNK_HEADER_SIZE, "WEBP", CHUNK_SIZE_BYTES)) {
- return PARSE_ERROR;
- }
-
- riff_size = GetLE32(GetBuffer(mem) + TAG_SIZE);
- if (riff_size < CHUNK_HEADER_SIZE) return PARSE_ERROR;
- if (riff_size > MAX_CHUNK_PAYLOAD) return PARSE_ERROR;
-
- // There's no point in reading past the end of the RIFF chunk
- mem->riff_end_ = riff_size + CHUNK_HEADER_SIZE;
- if (mem->buf_size_ > mem->riff_end_) {
- mem->buf_size_ = mem->end_ = mem->riff_end_;
- }
-
- Skip(mem, RIFF_HEADER_SIZE);
- return PARSE_OK;
-}
-
-static ParseStatus ParseSingleImage(WebPDemuxer* const dmux) {
- const size_t min_size = CHUNK_HEADER_SIZE;
- MemBuffer* const mem = &dmux->mem_;
- Frame* frame;
- ParseStatus status;
- int image_added = 0;
-
- if (dmux->frames_ != NULL) return PARSE_ERROR;
- if (SizeIsInvalid(mem, min_size)) return PARSE_ERROR;
- if (MemDataSize(mem) < min_size) return PARSE_NEED_MORE_DATA;
-
- frame = (Frame*)WebPSafeCalloc(1ULL, sizeof(*frame));
- if (frame == NULL) return PARSE_ERROR;
-
- // For the single image case we allow parsing of a partial frame, so no
- // minimum size is imposed here.
- status = StoreFrame(1, 0, &dmux->mem_, frame);
- if (status != PARSE_ERROR) {
- const int has_alpha = !!(dmux->feature_flags_ & ALPHA_FLAG);
- // Clear any alpha when the alpha flag is missing.
- if (!has_alpha && frame->img_components_[1].size_ > 0) {
- frame->img_components_[1].offset_ = 0;
- frame->img_components_[1].size_ = 0;
- frame->has_alpha_ = 0;
- }
-
- // Use the frame width/height as the canvas values for non-vp8x files.
- // Also, set ALPHA_FLAG if this is a lossless image with alpha.
- if (!dmux->is_ext_format_ && frame->width_ > 0 && frame->height_ > 0) {
- dmux->state_ = WEBP_DEMUX_PARSED_HEADER;
- dmux->canvas_width_ = frame->width_;
- dmux->canvas_height_ = frame->height_;
- dmux->feature_flags_ |= frame->has_alpha_ ? ALPHA_FLAG : 0;
- }
- if (!AddFrame(dmux, frame)) {
- status = PARSE_ERROR; // last frame was left incomplete
- } else {
- image_added = 1;
- dmux->num_frames_ = 1;
- }
- }
-
- if (!image_added) WebPSafeFree(frame);
- return status;
-}
-
-static ParseStatus ParseVP8XChunks(WebPDemuxer* const dmux) {
- const int is_animation = !!(dmux->feature_flags_ & ANIMATION_FLAG);
- MemBuffer* const mem = &dmux->mem_;
- int anim_chunks = 0;
- ParseStatus status = PARSE_OK;
-
- do {
- int store_chunk = 1;
- const size_t chunk_start_offset = mem->start_;
- const uint32_t fourcc = ReadLE32(mem);
- const uint32_t chunk_size = ReadLE32(mem);
- uint32_t chunk_size_padded;
-
- if (chunk_size > MAX_CHUNK_PAYLOAD) return PARSE_ERROR;
-
- chunk_size_padded = chunk_size + (chunk_size & 1);
- if (SizeIsInvalid(mem, chunk_size_padded)) return PARSE_ERROR;
-
- switch (fourcc) {
- case MKFOURCC('V', 'P', '8', 'X'): {
- return PARSE_ERROR;
- }
- case MKFOURCC('A', 'L', 'P', 'H'):
- case MKFOURCC('V', 'P', '8', ' '):
- case MKFOURCC('V', 'P', '8', 'L'): {
- // check that this isn't an animation (all frames should be in an ANMF).
- if (anim_chunks > 0 || is_animation) return PARSE_ERROR;
-
- Rewind(mem, CHUNK_HEADER_SIZE);
- status = ParseSingleImage(dmux);
- break;
- }
- case MKFOURCC('A', 'N', 'I', 'M'): {
- if (chunk_size_padded < ANIM_CHUNK_SIZE) return PARSE_ERROR;
-
- if (MemDataSize(mem) < chunk_size_padded) {
- status = PARSE_NEED_MORE_DATA;
- } else if (anim_chunks == 0) {
- ++anim_chunks;
- dmux->bgcolor_ = ReadLE32(mem);
- dmux->loop_count_ = ReadLE16s(mem);
- Skip(mem, chunk_size_padded - ANIM_CHUNK_SIZE);
- } else {
- store_chunk = 0;
- goto Skip;
- }
- break;
- }
- case MKFOURCC('A', 'N', 'M', 'F'): {
- if (anim_chunks == 0) return PARSE_ERROR; // 'ANIM' precedes frames.
- status = ParseAnimationFrame(dmux, chunk_size_padded);
- break;
- }
- case MKFOURCC('I', 'C', 'C', 'P'): {
- store_chunk = !!(dmux->feature_flags_ & ICCP_FLAG);
- goto Skip;
- }
- case MKFOURCC('E', 'X', 'I', 'F'): {
- store_chunk = !!(dmux->feature_flags_ & EXIF_FLAG);
- goto Skip;
- }
- case MKFOURCC('X', 'M', 'P', ' '): {
- store_chunk = !!(dmux->feature_flags_ & XMP_FLAG);
- goto Skip;
- }
- Skip:
- default: {
- if (chunk_size_padded <= MemDataSize(mem)) {
- if (store_chunk) {
- // Store only the chunk header and unpadded size as only the payload
- // will be returned to the user.
- if (!StoreChunk(dmux, chunk_start_offset,
- CHUNK_HEADER_SIZE + chunk_size)) {
- return PARSE_ERROR;
- }
- }
- Skip(mem, chunk_size_padded);
- } else {
- status = PARSE_NEED_MORE_DATA;
- }
- }
- }
-
- if (mem->start_ == mem->riff_end_) {
- break;
- } else if (MemDataSize(mem) < CHUNK_HEADER_SIZE) {
- status = PARSE_NEED_MORE_DATA;
- }
- } while (status == PARSE_OK);
-
- return status;
-}
-
-static ParseStatus ParseVP8X(WebPDemuxer* const dmux) {
- MemBuffer* const mem = &dmux->mem_;
- uint32_t vp8x_size;
-
- if (MemDataSize(mem) < CHUNK_HEADER_SIZE) return PARSE_NEED_MORE_DATA;
-
- dmux->is_ext_format_ = 1;
- Skip(mem, TAG_SIZE); // VP8X
- vp8x_size = ReadLE32(mem);
- if (vp8x_size > MAX_CHUNK_PAYLOAD) return PARSE_ERROR;
- if (vp8x_size < VP8X_CHUNK_SIZE) return PARSE_ERROR;
- vp8x_size += vp8x_size & 1;
- if (SizeIsInvalid(mem, vp8x_size)) return PARSE_ERROR;
- if (MemDataSize(mem) < vp8x_size) return PARSE_NEED_MORE_DATA;
-
- dmux->feature_flags_ = ReadByte(mem);
- Skip(mem, 3); // Reserved.
- dmux->canvas_width_ = 1 + ReadLE24s(mem);
- dmux->canvas_height_ = 1 + ReadLE24s(mem);
- if (dmux->canvas_width_ * (uint64_t)dmux->canvas_height_ >= MAX_IMAGE_AREA) {
- return PARSE_ERROR; // image final dimension is too large
- }
- Skip(mem, vp8x_size - VP8X_CHUNK_SIZE); // skip any trailing data.
- dmux->state_ = WEBP_DEMUX_PARSED_HEADER;
-
- if (SizeIsInvalid(mem, CHUNK_HEADER_SIZE)) return PARSE_ERROR;
- if (MemDataSize(mem) < CHUNK_HEADER_SIZE) return PARSE_NEED_MORE_DATA;
-
- return ParseVP8XChunks(dmux);
-}
-
-// -----------------------------------------------------------------------------
-// Format validation
-
-static int IsValidSimpleFormat(const WebPDemuxer* const dmux) {
- const Frame* const frame = dmux->frames_;
- if (dmux->state_ == WEBP_DEMUX_PARSING_HEADER) return 1;
-
- if (dmux->canvas_width_ <= 0 || dmux->canvas_height_ <= 0) return 0;
- if (dmux->state_ == WEBP_DEMUX_DONE && frame == NULL) return 0;
-
- if (frame->width_ <= 0 || frame->height_ <= 0) return 0;
- return 1;
-}
-
-// If 'exact' is true, check that the image resolution matches the canvas.
-// If 'exact' is false, check that the x/y offsets do not exceed the canvas.
-static int CheckFrameBounds(const Frame* const frame, int exact,
- int canvas_width, int canvas_height) {
- if (exact) {
- if (frame->x_offset_ != 0 || frame->y_offset_ != 0) {
- return 0;
- }
- if (frame->width_ != canvas_width || frame->height_ != canvas_height) {
- return 0;
- }
- } else {
- if (frame->x_offset_ < 0 || frame->y_offset_ < 0) return 0;
- if (frame->width_ + frame->x_offset_ > canvas_width) return 0;
- if (frame->height_ + frame->y_offset_ > canvas_height) return 0;
- }
- return 1;
-}
-
-static int IsValidExtendedFormat(const WebPDemuxer* const dmux) {
- const int is_animation = !!(dmux->feature_flags_ & ANIMATION_FLAG);
- const Frame* f = dmux->frames_;
-
- if (dmux->state_ == WEBP_DEMUX_PARSING_HEADER) return 1;
-
- if (dmux->canvas_width_ <= 0 || dmux->canvas_height_ <= 0) return 0;
- if (dmux->loop_count_ < 0) return 0;
- if (dmux->state_ == WEBP_DEMUX_DONE && dmux->frames_ == NULL) return 0;
- if (dmux->feature_flags_ & ~ALL_VALID_FLAGS) return 0; // invalid bitstream
-
- while (f != NULL) {
- const int cur_frame_set = f->frame_num_;
- int frame_count = 0;
-
- // Check frame properties.
- for (; f != NULL && f->frame_num_ == cur_frame_set; f = f->next_) {
- const ChunkData* const image = f->img_components_;
- const ChunkData* const alpha = f->img_components_ + 1;
-
- if (!is_animation && f->frame_num_ > 1) return 0;
-
- if (f->complete_) {
- if (alpha->size_ == 0 && image->size_ == 0) return 0;
- // Ensure alpha precedes image bitstream.
- if (alpha->size_ > 0 && alpha->offset_ > image->offset_) {
- return 0;
- }
-
- if (f->width_ <= 0 || f->height_ <= 0) return 0;
- } else {
- // There shouldn't be a partial frame in a complete file.
- if (dmux->state_ == WEBP_DEMUX_DONE) return 0;
-
- // Ensure alpha precedes image bitstream.
- if (alpha->size_ > 0 && image->size_ > 0 &&
- alpha->offset_ > image->offset_) {
- return 0;
- }
- // There shouldn't be any frames after an incomplete one.
- if (f->next_ != NULL) return 0;
- }
-
- if (f->width_ > 0 && f->height_ > 0 &&
- !CheckFrameBounds(f, !is_animation,
- dmux->canvas_width_, dmux->canvas_height_)) {
- return 0;
- }
-
- ++frame_count;
- }
- }
- return 1;
-}
-
-// -----------------------------------------------------------------------------
-// WebPDemuxer object
-
-static void InitDemux(WebPDemuxer* const dmux, const MemBuffer* const mem) {
- dmux->state_ = WEBP_DEMUX_PARSING_HEADER;
- dmux->loop_count_ = 1;
- dmux->bgcolor_ = 0xFFFFFFFF; // White background by default.
- dmux->canvas_width_ = -1;
- dmux->canvas_height_ = -1;
- dmux->frames_tail_ = &dmux->frames_;
- dmux->chunks_tail_ = &dmux->chunks_;
- dmux->mem_ = *mem;
-}
-
-static ParseStatus CreateRawImageDemuxer(MemBuffer* const mem,
- WebPDemuxer** demuxer) {
- WebPBitstreamFeatures features;
- const VP8StatusCode status =
- WebPGetFeatures(mem->buf_, mem->buf_size_, &features);
- *demuxer = NULL;
- if (status != VP8_STATUS_OK) {
- return (status == VP8_STATUS_NOT_ENOUGH_DATA) ? PARSE_NEED_MORE_DATA
- : PARSE_ERROR;
- }
-
- {
- WebPDemuxer* const dmux = (WebPDemuxer*)WebPSafeCalloc(1ULL, sizeof(*dmux));
- Frame* const frame = (Frame*)WebPSafeCalloc(1ULL, sizeof(*frame));
- if (dmux == NULL || frame == NULL) goto Error;
- InitDemux(dmux, mem);
- SetFrameInfo(0, mem->buf_size_, 1 /*frame_num*/, 1 /*complete*/, &features,
- frame);
- if (!AddFrame(dmux, frame)) goto Error;
- dmux->state_ = WEBP_DEMUX_DONE;
- dmux->canvas_width_ = frame->width_;
- dmux->canvas_height_ = frame->height_;
- dmux->feature_flags_ |= frame->has_alpha_ ? ALPHA_FLAG : 0;
- dmux->num_frames_ = 1;
- assert(IsValidSimpleFormat(dmux));
- *demuxer = dmux;
- return PARSE_OK;
-
- Error:
- WebPSafeFree(dmux);
- WebPSafeFree(frame);
- return PARSE_ERROR;
- }
-}
-
-WebPDemuxer* WebPDemuxInternal(const WebPData* data, int allow_partial,
- WebPDemuxState* state, int version) {
- const ChunkParser* parser;
- int partial;
- ParseStatus status = PARSE_ERROR;
- MemBuffer mem;
- WebPDemuxer* dmux;
-
- if (state != NULL) *state = WEBP_DEMUX_PARSE_ERROR;
-
- if (WEBP_ABI_IS_INCOMPATIBLE(version, WEBP_DEMUX_ABI_VERSION)) return NULL;
- if (data == NULL || data->bytes == NULL || data->size == 0) return NULL;
-
- if (!InitMemBuffer(&mem, data->bytes, data->size)) return NULL;
- status = ReadHeader(&mem);
- if (status != PARSE_OK) {
- // If parsing of the webp file header fails attempt to handle a raw
- // VP8/VP8L frame. Note 'allow_partial' is ignored in this case.
- if (status == PARSE_ERROR) {
- status = CreateRawImageDemuxer(&mem, &dmux);
- if (status == PARSE_OK) {
- if (state != NULL) *state = WEBP_DEMUX_DONE;
- return dmux;
- }
- }
- if (state != NULL) {
- *state = (status == PARSE_NEED_MORE_DATA) ? WEBP_DEMUX_PARSING_HEADER
- : WEBP_DEMUX_PARSE_ERROR;
- }
- return NULL;
- }
-
- partial = (mem.buf_size_ < mem.riff_end_);
- if (!allow_partial && partial) return NULL;
-
- dmux = (WebPDemuxer*)WebPSafeCalloc(1ULL, sizeof(*dmux));
- if (dmux == NULL) return NULL;
- InitDemux(dmux, &mem);
-
- status = PARSE_ERROR;
- for (parser = kMasterChunks; parser->parse != NULL; ++parser) {
- if (!memcmp(parser->id, GetBuffer(&dmux->mem_), TAG_SIZE)) {
- status = parser->parse(dmux);
- if (status == PARSE_OK) dmux->state_ = WEBP_DEMUX_DONE;
- if (status == PARSE_NEED_MORE_DATA && !partial) status = PARSE_ERROR;
- if (status != PARSE_ERROR && !parser->valid(dmux)) status = PARSE_ERROR;
- if (status == PARSE_ERROR) dmux->state_ = WEBP_DEMUX_PARSE_ERROR;
- break;
- }
- }
- if (state != NULL) *state = dmux->state_;
-
- if (status == PARSE_ERROR) {
- WebPDemuxDelete(dmux);
- return NULL;
- }
- return dmux;
-}
-
-void WebPDemuxDelete(WebPDemuxer* dmux) {
- Chunk* c;
- Frame* f;
- if (dmux == NULL) return;
-
- for (f = dmux->frames_; f != NULL;) {
- Frame* const cur_frame = f;
- f = f->next_;
- WebPSafeFree(cur_frame);
- }
- for (c = dmux->chunks_; c != NULL;) {
- Chunk* const cur_chunk = c;
- c = c->next_;
- WebPSafeFree(cur_chunk);
- }
- WebPSafeFree(dmux);
-}
-
-// -----------------------------------------------------------------------------
-
-uint32_t WebPDemuxGetI(const WebPDemuxer* dmux, WebPFormatFeature feature) {
- if (dmux == NULL) return 0;
-
- switch (feature) {
- case WEBP_FF_FORMAT_FLAGS: return dmux->feature_flags_;
- case WEBP_FF_CANVAS_WIDTH: return (uint32_t)dmux->canvas_width_;
- case WEBP_FF_CANVAS_HEIGHT: return (uint32_t)dmux->canvas_height_;
- case WEBP_FF_LOOP_COUNT: return (uint32_t)dmux->loop_count_;
- case WEBP_FF_BACKGROUND_COLOR: return dmux->bgcolor_;
- case WEBP_FF_FRAME_COUNT: return (uint32_t)dmux->num_frames_;
- }
- return 0;
-}
-
-// -----------------------------------------------------------------------------
-// Frame iteration
-
-static const Frame* GetFrame(const WebPDemuxer* const dmux, int frame_num) {
- const Frame* f;
- for (f = dmux->frames_; f != NULL; f = f->next_) {
- if (frame_num == f->frame_num_) break;
- }
- return f;
-}
-
-static const uint8_t* GetFramePayload(const uint8_t* const mem_buf,
- const Frame* const frame,
- size_t* const data_size) {
- *data_size = 0;
- if (frame != NULL) {
- const ChunkData* const image = frame->img_components_;
- const ChunkData* const alpha = frame->img_components_ + 1;
- size_t start_offset = image->offset_;
- *data_size = image->size_;
-
- // if alpha exists it precedes image, update the size allowing for
- // intervening chunks.
- if (alpha->size_ > 0) {
- const size_t inter_size = (image->offset_ > 0)
- ? image->offset_ - (alpha->offset_ + alpha->size_)
- : 0;
- start_offset = alpha->offset_;
- *data_size += alpha->size_ + inter_size;
- }
- return mem_buf + start_offset;
- }
- return NULL;
-}
-
-// Create a whole 'frame' from VP8 (+ alpha) or lossless.
-static int SynthesizeFrame(const WebPDemuxer* const dmux,
- const Frame* const frame,
- WebPIterator* const iter) {
- const uint8_t* const mem_buf = dmux->mem_.buf_;
- size_t payload_size = 0;
- const uint8_t* const payload = GetFramePayload(mem_buf, frame, &payload_size);
- if (payload == NULL) return 0;
- assert(frame != NULL);
-
- iter->frame_num = frame->frame_num_;
- iter->num_frames = dmux->num_frames_;
- iter->x_offset = frame->x_offset_;
- iter->y_offset = frame->y_offset_;
- iter->width = frame->width_;
- iter->height = frame->height_;
- iter->has_alpha = frame->has_alpha_;
- iter->duration = frame->duration_;
- iter->dispose_method = frame->dispose_method_;
- iter->blend_method = frame->blend_method_;
- iter->complete = frame->complete_;
- iter->fragment.bytes = payload;
- iter->fragment.size = payload_size;
- return 1;
-}
-
-static int SetFrame(int frame_num, WebPIterator* const iter) {
- const Frame* frame;
- const WebPDemuxer* const dmux = (WebPDemuxer*)iter->private_;
- if (dmux == NULL || frame_num < 0) return 0;
- if (frame_num > dmux->num_frames_) return 0;
- if (frame_num == 0) frame_num = dmux->num_frames_;
-
- frame = GetFrame(dmux, frame_num);
- if (frame == NULL) return 0;
-
- return SynthesizeFrame(dmux, frame, iter);
-}
-
-int WebPDemuxGetFrame(const WebPDemuxer* dmux, int frame, WebPIterator* iter) {
- if (iter == NULL) return 0;
-
- memset(iter, 0, sizeof(*iter));
- iter->private_ = (void*)dmux;
- return SetFrame(frame, iter);
-}
-
-int WebPDemuxNextFrame(WebPIterator* iter) {
- if (iter == NULL) return 0;
- return SetFrame(iter->frame_num + 1, iter);
-}
-
-int WebPDemuxPrevFrame(WebPIterator* iter) {
- if (iter == NULL) return 0;
- if (iter->frame_num <= 1) return 0;
- return SetFrame(iter->frame_num - 1, iter);
-}
-
-void WebPDemuxReleaseIterator(WebPIterator* iter) {
- (void)iter;
-}
-
-// -----------------------------------------------------------------------------
-// Chunk iteration
-
-static int ChunkCount(const WebPDemuxer* const dmux, const char fourcc[4]) {
- const uint8_t* const mem_buf = dmux->mem_.buf_;
- const Chunk* c;
- int count = 0;
- for (c = dmux->chunks_; c != NULL; c = c->next_) {
- const uint8_t* const header = mem_buf + c->data_.offset_;
- if (!memcmp(header, fourcc, TAG_SIZE)) ++count;
- }
- return count;
-}
-
-static const Chunk* GetChunk(const WebPDemuxer* const dmux,
- const char fourcc[4], int chunk_num) {
- const uint8_t* const mem_buf = dmux->mem_.buf_;
- const Chunk* c;
- int count = 0;
- for (c = dmux->chunks_; c != NULL; c = c->next_) {
- const uint8_t* const header = mem_buf + c->data_.offset_;
- if (!memcmp(header, fourcc, TAG_SIZE)) ++count;
- if (count == chunk_num) break;
- }
- return c;
-}
-
-static int SetChunk(const char fourcc[4], int chunk_num,
- WebPChunkIterator* const iter) {
- const WebPDemuxer* const dmux = (WebPDemuxer*)iter->private_;
- int count;
-
- if (dmux == NULL || fourcc == NULL || chunk_num < 0) return 0;
- count = ChunkCount(dmux, fourcc);
- if (count == 0) return 0;
- if (chunk_num == 0) chunk_num = count;
-
- if (chunk_num <= count) {
- const uint8_t* const mem_buf = dmux->mem_.buf_;
- const Chunk* const chunk = GetChunk(dmux, fourcc, chunk_num);
- iter->chunk.bytes = mem_buf + chunk->data_.offset_ + CHUNK_HEADER_SIZE;
- iter->chunk.size = chunk->data_.size_ - CHUNK_HEADER_SIZE;
- iter->num_chunks = count;
- iter->chunk_num = chunk_num;
- return 1;
- }
- return 0;
-}
-
-int WebPDemuxGetChunk(const WebPDemuxer* dmux,
- const char fourcc[4], int chunk_num,
- WebPChunkIterator* iter) {
- if (iter == NULL) return 0;
-
- memset(iter, 0, sizeof(*iter));
- iter->private_ = (void*)dmux;
- return SetChunk(fourcc, chunk_num, iter);
-}
-
-int WebPDemuxNextChunk(WebPChunkIterator* iter) {
- if (iter != NULL) {
- const char* const fourcc =
- (const char*)iter->chunk.bytes - CHUNK_HEADER_SIZE;
- return SetChunk(fourcc, iter->chunk_num + 1, iter);
- }
- return 0;
-}
-
-int WebPDemuxPrevChunk(WebPChunkIterator* iter) {
- if (iter != NULL && iter->chunk_num > 1) {
- const char* const fourcc =
- (const char*)iter->chunk.bytes - CHUNK_HEADER_SIZE;
- return SetChunk(fourcc, iter->chunk_num - 1, iter);
- }
- return 0;
-}
-
-void WebPDemuxReleaseChunkIterator(WebPChunkIterator* iter) {
- (void)iter;
-}
-
diff --git a/contrib/libs/libwebp/demux/ya.make b/contrib/libs/libwebp/demux/ya.make
deleted file mode 100644
index a547658bb9..0000000000
--- a/contrib/libs/libwebp/demux/ya.make
+++ /dev/null
@@ -1,33 +0,0 @@
-# Generated by devtools/yamaker.
-
-LIBRARY()
-
-VERSION(1.2.2)
-
-LICENSE(BSD-3-Clause WITH Google-Patent-License-Webm)
-
-LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
-
-PEERDIR(
- contrib/libs/libwebp
-)
-
-ADDINCL(
- contrib/libs/libwebp/demux
- contrib/libs/libwebp/webp
-)
-
-NO_COMPILER_WARNINGS()
-
-NO_RUNTIME()
-
-CFLAGS(
- -DHAVE_CONFIG_H
-)
-
-SRCS(
- anim_decode.c
- demux.c
-)
-
-END()
diff --git a/contrib/libs/libwebp/dsp/alpha_processing.c b/contrib/libs/libwebp/dsp/alpha_processing.c
deleted file mode 100644
index 2d82a6d788..0000000000
--- a/contrib/libs/libwebp/dsp/alpha_processing.c
+++ /dev/null
@@ -1,495 +0,0 @@
-// Copyright 2013 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Utilities for processing transparent channel.
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include <assert.h>
-#include "./dsp.h"
-
-// Tables can be faster on some platform but incur some extra binary size (~2k).
-#if !defined(USE_TABLES_FOR_ALPHA_MULT)
-#define USE_TABLES_FOR_ALPHA_MULT 0 // ALTERNATE_CODE
-#endif
-
-
-// -----------------------------------------------------------------------------
-
-#define MFIX 24 // 24bit fixed-point arithmetic
-#define HALF ((1u << MFIX) >> 1)
-#define KINV_255 ((1u << MFIX) / 255u)
-
-static uint32_t Mult(uint8_t x, uint32_t mult) {
- const uint32_t v = (x * mult + HALF) >> MFIX;
- assert(v <= 255); // <- 24bit precision is enough to ensure that.
- return v;
-}
-
-#if (USE_TABLES_FOR_ALPHA_MULT == 1)
-
-static const uint32_t kMultTables[2][256] = {
- { // (255u << MFIX) / alpha
- 0x00000000, 0xff000000, 0x7f800000, 0x55000000, 0x3fc00000, 0x33000000,
- 0x2a800000, 0x246db6db, 0x1fe00000, 0x1c555555, 0x19800000, 0x172e8ba2,
- 0x15400000, 0x139d89d8, 0x1236db6d, 0x11000000, 0x0ff00000, 0x0f000000,
- 0x0e2aaaaa, 0x0d6bca1a, 0x0cc00000, 0x0c249249, 0x0b9745d1, 0x0b1642c8,
- 0x0aa00000, 0x0a333333, 0x09cec4ec, 0x0971c71c, 0x091b6db6, 0x08cb08d3,
- 0x08800000, 0x0839ce73, 0x07f80000, 0x07ba2e8b, 0x07800000, 0x07492492,
- 0x07155555, 0x06e45306, 0x06b5e50d, 0x0689d89d, 0x06600000, 0x063831f3,
- 0x06124924, 0x05ee23b8, 0x05cba2e8, 0x05aaaaaa, 0x058b2164, 0x056cefa8,
- 0x05500000, 0x05343eb1, 0x05199999, 0x05000000, 0x04e76276, 0x04cfb2b7,
- 0x04b8e38e, 0x04a2e8ba, 0x048db6db, 0x0479435e, 0x04658469, 0x045270d0,
- 0x04400000, 0x042e29f7, 0x041ce739, 0x040c30c3, 0x03fc0000, 0x03ec4ec4,
- 0x03dd1745, 0x03ce540f, 0x03c00000, 0x03b21642, 0x03a49249, 0x03976fc6,
- 0x038aaaaa, 0x037e3f1f, 0x03722983, 0x03666666, 0x035af286, 0x034fcace,
- 0x0344ec4e, 0x033a5440, 0x03300000, 0x0325ed09, 0x031c18f9, 0x0312818a,
- 0x03092492, 0x03000000, 0x02f711dc, 0x02ee5846, 0x02e5d174, 0x02dd7baf,
- 0x02d55555, 0x02cd5cd5, 0x02c590b2, 0x02bdef7b, 0x02b677d4, 0x02af286b,
- 0x02a80000, 0x02a0fd5c, 0x029a1f58, 0x029364d9, 0x028ccccc, 0x0286562d,
- 0x02800000, 0x0279c952, 0x0273b13b, 0x026db6db, 0x0267d95b, 0x026217ec,
- 0x025c71c7, 0x0256e62a, 0x0251745d, 0x024c1bac, 0x0246db6d, 0x0241b2f9,
- 0x023ca1af, 0x0237a6f4, 0x0232c234, 0x022df2df, 0x02293868, 0x02249249,
- 0x02200000, 0x021b810e, 0x021714fb, 0x0212bb51, 0x020e739c, 0x020a3d70,
- 0x02061861, 0x02020408, 0x01fe0000, 0x01fa0be8, 0x01f62762, 0x01f25213,
- 0x01ee8ba2, 0x01ead3ba, 0x01e72a07, 0x01e38e38, 0x01e00000, 0x01dc7f10,
- 0x01d90b21, 0x01d5a3e9, 0x01d24924, 0x01cefa8d, 0x01cbb7e3, 0x01c880e5,
- 0x01c55555, 0x01c234f7, 0x01bf1f8f, 0x01bc14e5, 0x01b914c1, 0x01b61eed,
- 0x01b33333, 0x01b05160, 0x01ad7943, 0x01aaaaaa, 0x01a7e567, 0x01a5294a,
- 0x01a27627, 0x019fcbd2, 0x019d2a20, 0x019a90e7, 0x01980000, 0x01957741,
- 0x0192f684, 0x01907da4, 0x018e0c7c, 0x018ba2e8, 0x018940c5, 0x0186e5f0,
- 0x01849249, 0x018245ae, 0x01800000, 0x017dc11f, 0x017b88ee, 0x0179574e,
- 0x01772c23, 0x01750750, 0x0172e8ba, 0x0170d045, 0x016ebdd7, 0x016cb157,
- 0x016aaaaa, 0x0168a9b9, 0x0166ae6a, 0x0164b8a7, 0x0162c859, 0x0160dd67,
- 0x015ef7bd, 0x015d1745, 0x015b3bea, 0x01596596, 0x01579435, 0x0155c7b4,
- 0x01540000, 0x01523d03, 0x01507eae, 0x014ec4ec, 0x014d0fac, 0x014b5edc,
- 0x0149b26c, 0x01480a4a, 0x01466666, 0x0144c6af, 0x01432b16, 0x0141938b,
- 0x01400000, 0x013e7063, 0x013ce4a9, 0x013b5cc0, 0x0139d89d, 0x01385830,
- 0x0136db6d, 0x01356246, 0x0133ecad, 0x01327a97, 0x01310bf6, 0x012fa0be,
- 0x012e38e3, 0x012cd459, 0x012b7315, 0x012a150a, 0x0128ba2e, 0x01276276,
- 0x01260dd6, 0x0124bc44, 0x01236db6, 0x01222222, 0x0120d97c, 0x011f93bc,
- 0x011e50d7, 0x011d10c4, 0x011bd37a, 0x011a98ef, 0x0119611a, 0x01182bf2,
- 0x0116f96f, 0x0115c988, 0x01149c34, 0x0113716a, 0x01124924, 0x01112358,
- 0x01100000, 0x010edf12, 0x010dc087, 0x010ca458, 0x010b8a7d, 0x010a72f0,
- 0x01095da8, 0x01084a9f, 0x010739ce, 0x01062b2e, 0x01051eb8, 0x01041465,
- 0x01030c30, 0x01020612, 0x01010204, 0x01000000 },
- { // alpha * KINV_255
- 0x00000000, 0x00010101, 0x00020202, 0x00030303, 0x00040404, 0x00050505,
- 0x00060606, 0x00070707, 0x00080808, 0x00090909, 0x000a0a0a, 0x000b0b0b,
- 0x000c0c0c, 0x000d0d0d, 0x000e0e0e, 0x000f0f0f, 0x00101010, 0x00111111,
- 0x00121212, 0x00131313, 0x00141414, 0x00151515, 0x00161616, 0x00171717,
- 0x00181818, 0x00191919, 0x001a1a1a, 0x001b1b1b, 0x001c1c1c, 0x001d1d1d,
- 0x001e1e1e, 0x001f1f1f, 0x00202020, 0x00212121, 0x00222222, 0x00232323,
- 0x00242424, 0x00252525, 0x00262626, 0x00272727, 0x00282828, 0x00292929,
- 0x002a2a2a, 0x002b2b2b, 0x002c2c2c, 0x002d2d2d, 0x002e2e2e, 0x002f2f2f,
- 0x00303030, 0x00313131, 0x00323232, 0x00333333, 0x00343434, 0x00353535,
- 0x00363636, 0x00373737, 0x00383838, 0x00393939, 0x003a3a3a, 0x003b3b3b,
- 0x003c3c3c, 0x003d3d3d, 0x003e3e3e, 0x003f3f3f, 0x00404040, 0x00414141,
- 0x00424242, 0x00434343, 0x00444444, 0x00454545, 0x00464646, 0x00474747,
- 0x00484848, 0x00494949, 0x004a4a4a, 0x004b4b4b, 0x004c4c4c, 0x004d4d4d,
- 0x004e4e4e, 0x004f4f4f, 0x00505050, 0x00515151, 0x00525252, 0x00535353,
- 0x00545454, 0x00555555, 0x00565656, 0x00575757, 0x00585858, 0x00595959,
- 0x005a5a5a, 0x005b5b5b, 0x005c5c5c, 0x005d5d5d, 0x005e5e5e, 0x005f5f5f,
- 0x00606060, 0x00616161, 0x00626262, 0x00636363, 0x00646464, 0x00656565,
- 0x00666666, 0x00676767, 0x00686868, 0x00696969, 0x006a6a6a, 0x006b6b6b,
- 0x006c6c6c, 0x006d6d6d, 0x006e6e6e, 0x006f6f6f, 0x00707070, 0x00717171,
- 0x00727272, 0x00737373, 0x00747474, 0x00757575, 0x00767676, 0x00777777,
- 0x00787878, 0x00797979, 0x007a7a7a, 0x007b7b7b, 0x007c7c7c, 0x007d7d7d,
- 0x007e7e7e, 0x007f7f7f, 0x00808080, 0x00818181, 0x00828282, 0x00838383,
- 0x00848484, 0x00858585, 0x00868686, 0x00878787, 0x00888888, 0x00898989,
- 0x008a8a8a, 0x008b8b8b, 0x008c8c8c, 0x008d8d8d, 0x008e8e8e, 0x008f8f8f,
- 0x00909090, 0x00919191, 0x00929292, 0x00939393, 0x00949494, 0x00959595,
- 0x00969696, 0x00979797, 0x00989898, 0x00999999, 0x009a9a9a, 0x009b9b9b,
- 0x009c9c9c, 0x009d9d9d, 0x009e9e9e, 0x009f9f9f, 0x00a0a0a0, 0x00a1a1a1,
- 0x00a2a2a2, 0x00a3a3a3, 0x00a4a4a4, 0x00a5a5a5, 0x00a6a6a6, 0x00a7a7a7,
- 0x00a8a8a8, 0x00a9a9a9, 0x00aaaaaa, 0x00ababab, 0x00acacac, 0x00adadad,
- 0x00aeaeae, 0x00afafaf, 0x00b0b0b0, 0x00b1b1b1, 0x00b2b2b2, 0x00b3b3b3,
- 0x00b4b4b4, 0x00b5b5b5, 0x00b6b6b6, 0x00b7b7b7, 0x00b8b8b8, 0x00b9b9b9,
- 0x00bababa, 0x00bbbbbb, 0x00bcbcbc, 0x00bdbdbd, 0x00bebebe, 0x00bfbfbf,
- 0x00c0c0c0, 0x00c1c1c1, 0x00c2c2c2, 0x00c3c3c3, 0x00c4c4c4, 0x00c5c5c5,
- 0x00c6c6c6, 0x00c7c7c7, 0x00c8c8c8, 0x00c9c9c9, 0x00cacaca, 0x00cbcbcb,
- 0x00cccccc, 0x00cdcdcd, 0x00cecece, 0x00cfcfcf, 0x00d0d0d0, 0x00d1d1d1,
- 0x00d2d2d2, 0x00d3d3d3, 0x00d4d4d4, 0x00d5d5d5, 0x00d6d6d6, 0x00d7d7d7,
- 0x00d8d8d8, 0x00d9d9d9, 0x00dadada, 0x00dbdbdb, 0x00dcdcdc, 0x00dddddd,
- 0x00dedede, 0x00dfdfdf, 0x00e0e0e0, 0x00e1e1e1, 0x00e2e2e2, 0x00e3e3e3,
- 0x00e4e4e4, 0x00e5e5e5, 0x00e6e6e6, 0x00e7e7e7, 0x00e8e8e8, 0x00e9e9e9,
- 0x00eaeaea, 0x00ebebeb, 0x00ececec, 0x00ededed, 0x00eeeeee, 0x00efefef,
- 0x00f0f0f0, 0x00f1f1f1, 0x00f2f2f2, 0x00f3f3f3, 0x00f4f4f4, 0x00f5f5f5,
- 0x00f6f6f6, 0x00f7f7f7, 0x00f8f8f8, 0x00f9f9f9, 0x00fafafa, 0x00fbfbfb,
- 0x00fcfcfc, 0x00fdfdfd, 0x00fefefe, 0x00ffffff }
-};
-
-static WEBP_INLINE uint32_t GetScale(uint32_t a, int inverse) {
- return kMultTables[!inverse][a];
-}
-
-#else
-
-static WEBP_INLINE uint32_t GetScale(uint32_t a, int inverse) {
- return inverse ? (255u << MFIX) / a : a * KINV_255;
-}
-
-#endif // USE_TABLES_FOR_ALPHA_MULT
-
-void WebPMultARGBRow_C(uint32_t* const ptr, int width, int inverse) {
- int x;
- for (x = 0; x < width; ++x) {
- const uint32_t argb = ptr[x];
- if (argb < 0xff000000u) { // alpha < 255
- if (argb <= 0x00ffffffu) { // alpha == 0
- ptr[x] = 0;
- } else {
- const uint32_t alpha = (argb >> 24) & 0xff;
- const uint32_t scale = GetScale(alpha, inverse);
- uint32_t out = argb & 0xff000000u;
- out |= Mult(argb >> 0, scale) << 0;
- out |= Mult(argb >> 8, scale) << 8;
- out |= Mult(argb >> 16, scale) << 16;
- ptr[x] = out;
- }
- }
- }
-}
-
-void WebPMultRow_C(uint8_t* WEBP_RESTRICT const ptr,
- const uint8_t* WEBP_RESTRICT const alpha,
- int width, int inverse) {
- int x;
- for (x = 0; x < width; ++x) {
- const uint32_t a = alpha[x];
- if (a != 255) {
- if (a == 0) {
- ptr[x] = 0;
- } else {
- const uint32_t scale = GetScale(a, inverse);
- ptr[x] = Mult(ptr[x], scale);
- }
- }
- }
-}
-
-#undef KINV_255
-#undef HALF
-#undef MFIX
-
-void (*WebPMultARGBRow)(uint32_t* const ptr, int width, int inverse);
-void (*WebPMultRow)(uint8_t* WEBP_RESTRICT const ptr,
- const uint8_t* WEBP_RESTRICT const alpha,
- int width, int inverse);
-
-//------------------------------------------------------------------------------
-// Generic per-plane calls
-
-void WebPMultARGBRows(uint8_t* ptr, int stride, int width, int num_rows,
- int inverse) {
- int n;
- for (n = 0; n < num_rows; ++n) {
- WebPMultARGBRow((uint32_t*)ptr, width, inverse);
- ptr += stride;
- }
-}
-
-void WebPMultRows(uint8_t* WEBP_RESTRICT ptr, int stride,
- const uint8_t* WEBP_RESTRICT alpha, int alpha_stride,
- int width, int num_rows, int inverse) {
- int n;
- for (n = 0; n < num_rows; ++n) {
- WebPMultRow(ptr, alpha, width, inverse);
- ptr += stride;
- alpha += alpha_stride;
- }
-}
-
-//------------------------------------------------------------------------------
-// Premultiplied modes
-
-// non dithered-modes
-
-// (x * a * 32897) >> 23 is bit-wise equivalent to (int)(x * a / 255.)
-// for all 8bit x or a. For bit-wise equivalence to (int)(x * a / 255. + .5),
-// one can use instead: (x * a * 65793 + (1 << 23)) >> 24
-#if 1 // (int)(x * a / 255.)
-#define MULTIPLIER(a) ((a) * 32897U)
-#define PREMULTIPLY(x, m) (((x) * (m)) >> 23)
-#else // (int)(x * a / 255. + .5)
-#define MULTIPLIER(a) ((a) * 65793U)
-#define PREMULTIPLY(x, m) (((x) * (m) + (1U << 23)) >> 24)
-#endif
-
-#if !WEBP_NEON_OMIT_C_CODE
-static void ApplyAlphaMultiply_C(uint8_t* rgba, int alpha_first,
- int w, int h, int stride) {
- while (h-- > 0) {
- uint8_t* const rgb = rgba + (alpha_first ? 1 : 0);
- const uint8_t* const alpha = rgba + (alpha_first ? 0 : 3);
- int i;
- for (i = 0; i < w; ++i) {
- const uint32_t a = alpha[4 * i];
- if (a != 0xff) {
- const uint32_t mult = MULTIPLIER(a);
- rgb[4 * i + 0] = PREMULTIPLY(rgb[4 * i + 0], mult);
- rgb[4 * i + 1] = PREMULTIPLY(rgb[4 * i + 1], mult);
- rgb[4 * i + 2] = PREMULTIPLY(rgb[4 * i + 2], mult);
- }
- }
- rgba += stride;
- }
-}
-#endif // !WEBP_NEON_OMIT_C_CODE
-#undef MULTIPLIER
-#undef PREMULTIPLY
-
-// rgbA4444
-
-#define MULTIPLIER(a) ((a) * 0x1111) // 0x1111 ~= (1 << 16) / 15
-
-static WEBP_INLINE uint8_t dither_hi(uint8_t x) {
- return (x & 0xf0) | (x >> 4);
-}
-
-static WEBP_INLINE uint8_t dither_lo(uint8_t x) {
- return (x & 0x0f) | (x << 4);
-}
-
-static WEBP_INLINE uint8_t multiply(uint8_t x, uint32_t m) {
- return (x * m) >> 16;
-}
-
-static WEBP_INLINE void ApplyAlphaMultiply4444_C(uint8_t* rgba4444,
- int w, int h, int stride,
- int rg_byte_pos /* 0 or 1 */) {
- while (h-- > 0) {
- int i;
- for (i = 0; i < w; ++i) {
- const uint32_t rg = rgba4444[2 * i + rg_byte_pos];
- const uint32_t ba = rgba4444[2 * i + (rg_byte_pos ^ 1)];
- const uint8_t a = ba & 0x0f;
- const uint32_t mult = MULTIPLIER(a);
- const uint8_t r = multiply(dither_hi(rg), mult);
- const uint8_t g = multiply(dither_lo(rg), mult);
- const uint8_t b = multiply(dither_hi(ba), mult);
- rgba4444[2 * i + rg_byte_pos] = (r & 0xf0) | ((g >> 4) & 0x0f);
- rgba4444[2 * i + (rg_byte_pos ^ 1)] = (b & 0xf0) | a;
- }
- rgba4444 += stride;
- }
-}
-#undef MULTIPLIER
-
-static void ApplyAlphaMultiply_16b_C(uint8_t* rgba4444,
- int w, int h, int stride) {
-#if (WEBP_SWAP_16BIT_CSP == 1)
- ApplyAlphaMultiply4444_C(rgba4444, w, h, stride, 1);
-#else
- ApplyAlphaMultiply4444_C(rgba4444, w, h, stride, 0);
-#endif
-}
-
-#if !WEBP_NEON_OMIT_C_CODE
-static int DispatchAlpha_C(const uint8_t* WEBP_RESTRICT alpha, int alpha_stride,
- int width, int height,
- uint8_t* WEBP_RESTRICT dst, int dst_stride) {
- uint32_t alpha_mask = 0xff;
- int i, j;
-
- for (j = 0; j < height; ++j) {
- for (i = 0; i < width; ++i) {
- const uint32_t alpha_value = alpha[i];
- dst[4 * i] = alpha_value;
- alpha_mask &= alpha_value;
- }
- alpha += alpha_stride;
- dst += dst_stride;
- }
-
- return (alpha_mask != 0xff);
-}
-
-static void DispatchAlphaToGreen_C(const uint8_t* WEBP_RESTRICT alpha,
- int alpha_stride, int width, int height,
- uint32_t* WEBP_RESTRICT dst,
- int dst_stride) {
- int i, j;
- for (j = 0; j < height; ++j) {
- for (i = 0; i < width; ++i) {
- dst[i] = alpha[i] << 8; // leave A/R/B channels zero'd.
- }
- alpha += alpha_stride;
- dst += dst_stride;
- }
-}
-
-static int ExtractAlpha_C(const uint8_t* WEBP_RESTRICT argb, int argb_stride,
- int width, int height,
- uint8_t* WEBP_RESTRICT alpha, int alpha_stride) {
- uint8_t alpha_mask = 0xff;
- int i, j;
-
- for (j = 0; j < height; ++j) {
- for (i = 0; i < width; ++i) {
- const uint8_t alpha_value = argb[4 * i];
- alpha[i] = alpha_value;
- alpha_mask &= alpha_value;
- }
- argb += argb_stride;
- alpha += alpha_stride;
- }
- return (alpha_mask == 0xff);
-}
-
-static void ExtractGreen_C(const uint32_t* WEBP_RESTRICT argb,
- uint8_t* WEBP_RESTRICT alpha, int size) {
- int i;
- for (i = 0; i < size; ++i) alpha[i] = argb[i] >> 8;
-}
-#endif // !WEBP_NEON_OMIT_C_CODE
-
-//------------------------------------------------------------------------------
-
-static int HasAlpha8b_C(const uint8_t* src, int length) {
- while (length-- > 0) if (*src++ != 0xff) return 1;
- return 0;
-}
-
-static int HasAlpha32b_C(const uint8_t* src, int length) {
- int x;
- for (x = 0; length-- > 0; x += 4) if (src[x] != 0xff) return 1;
- return 0;
-}
-
-static void AlphaReplace_C(uint32_t* src, int length, uint32_t color) {
- int x;
- for (x = 0; x < length; ++x) if ((src[x] >> 24) == 0) src[x] = color;
-}
-
-//------------------------------------------------------------------------------
-// Simple channel manipulations.
-
-static WEBP_INLINE uint32_t MakeARGB32(int a, int r, int g, int b) {
- return (((uint32_t)a << 24) | (r << 16) | (g << 8) | b);
-}
-
-#ifdef WORDS_BIGENDIAN
-static void PackARGB_C(const uint8_t* WEBP_RESTRICT a,
- const uint8_t* WEBP_RESTRICT r,
- const uint8_t* WEBP_RESTRICT g,
- const uint8_t* WEBP_RESTRICT b,
- int len, uint32_t* WEBP_RESTRICT out) {
- int i;
- for (i = 0; i < len; ++i) {
- out[i] = MakeARGB32(a[4 * i], r[4 * i], g[4 * i], b[4 * i]);
- }
-}
-#endif
-
-static void PackRGB_C(const uint8_t* WEBP_RESTRICT r,
- const uint8_t* WEBP_RESTRICT g,
- const uint8_t* WEBP_RESTRICT b,
- int len, int step, uint32_t* WEBP_RESTRICT out) {
- int i, offset = 0;
- for (i = 0; i < len; ++i) {
- out[i] = MakeARGB32(0xff, r[offset], g[offset], b[offset]);
- offset += step;
- }
-}
-
-void (*WebPApplyAlphaMultiply)(uint8_t*, int, int, int, int);
-void (*WebPApplyAlphaMultiply4444)(uint8_t*, int, int, int);
-int (*WebPDispatchAlpha)(const uint8_t* WEBP_RESTRICT, int, int, int,
- uint8_t* WEBP_RESTRICT, int);
-void (*WebPDispatchAlphaToGreen)(const uint8_t* WEBP_RESTRICT, int, int, int,
- uint32_t* WEBP_RESTRICT, int);
-int (*WebPExtractAlpha)(const uint8_t* WEBP_RESTRICT, int, int, int,
- uint8_t* WEBP_RESTRICT, int);
-void (*WebPExtractGreen)(const uint32_t* WEBP_RESTRICT argb,
- uint8_t* WEBP_RESTRICT alpha, int size);
-#ifdef WORDS_BIGENDIAN
-void (*WebPPackARGB)(const uint8_t* a, const uint8_t* r, const uint8_t* g,
- const uint8_t* b, int, uint32_t*);
-#endif
-void (*WebPPackRGB)(const uint8_t* WEBP_RESTRICT r,
- const uint8_t* WEBP_RESTRICT g,
- const uint8_t* WEBP_RESTRICT b,
- int len, int step, uint32_t* WEBP_RESTRICT out);
-
-int (*WebPHasAlpha8b)(const uint8_t* src, int length);
-int (*WebPHasAlpha32b)(const uint8_t* src, int length);
-void (*WebPAlphaReplace)(uint32_t* src, int length, uint32_t color);
-
-//------------------------------------------------------------------------------
-// Init function
-
-extern void WebPInitAlphaProcessingMIPSdspR2(void);
-extern void WebPInitAlphaProcessingSSE2(void);
-extern void WebPInitAlphaProcessingSSE41(void);
-extern void WebPInitAlphaProcessingNEON(void);
-
-WEBP_DSP_INIT_FUNC(WebPInitAlphaProcessing) {
- WebPMultARGBRow = WebPMultARGBRow_C;
- WebPMultRow = WebPMultRow_C;
- WebPApplyAlphaMultiply4444 = ApplyAlphaMultiply_16b_C;
-
-#ifdef WORDS_BIGENDIAN
- WebPPackARGB = PackARGB_C;
-#endif
- WebPPackRGB = PackRGB_C;
-#if !WEBP_NEON_OMIT_C_CODE
- WebPApplyAlphaMultiply = ApplyAlphaMultiply_C;
- WebPDispatchAlpha = DispatchAlpha_C;
- WebPDispatchAlphaToGreen = DispatchAlphaToGreen_C;
- WebPExtractAlpha = ExtractAlpha_C;
- WebPExtractGreen = ExtractGreen_C;
-#endif
-
- WebPHasAlpha8b = HasAlpha8b_C;
- WebPHasAlpha32b = HasAlpha32b_C;
- WebPAlphaReplace = AlphaReplace_C;
-
- // If defined, use CPUInfo() to overwrite some pointers with faster versions.
- if (VP8GetCPUInfo != NULL) {
-#if defined(WEBP_HAVE_SSE2)
- if (VP8GetCPUInfo(kSSE2)) {
- WebPInitAlphaProcessingSSE2();
-#if defined(WEBP_HAVE_SSE41)
- if (VP8GetCPUInfo(kSSE4_1)) {
- WebPInitAlphaProcessingSSE41();
- }
-#endif
- }
-#endif
-#if defined(WEBP_USE_MIPS_DSP_R2)
- if (VP8GetCPUInfo(kMIPSdspR2)) {
- WebPInitAlphaProcessingMIPSdspR2();
- }
-#endif
- }
-
-#if defined(WEBP_HAVE_NEON)
- if (WEBP_NEON_OMIT_C_CODE ||
- (VP8GetCPUInfo != NULL && VP8GetCPUInfo(kNEON))) {
- WebPInitAlphaProcessingNEON();
- }
-#endif
-
- assert(WebPMultARGBRow != NULL);
- assert(WebPMultRow != NULL);
- assert(WebPApplyAlphaMultiply != NULL);
- assert(WebPApplyAlphaMultiply4444 != NULL);
- assert(WebPDispatchAlpha != NULL);
- assert(WebPDispatchAlphaToGreen != NULL);
- assert(WebPExtractAlpha != NULL);
- assert(WebPExtractGreen != NULL);
-#ifdef WORDS_BIGENDIAN
- assert(WebPPackARGB != NULL);
-#endif
- assert(WebPPackRGB != NULL);
- assert(WebPHasAlpha8b != NULL);
- assert(WebPHasAlpha32b != NULL);
- assert(WebPAlphaReplace != NULL);
-}
diff --git a/contrib/libs/libwebp/dsp/alpha_processing_mips_dsp_r2.c b/contrib/libs/libwebp/dsp/alpha_processing_mips_dsp_r2.c
deleted file mode 100644
index baf298f03a..0000000000
--- a/contrib/libs/libwebp/dsp/alpha_processing_mips_dsp_r2.c
+++ /dev/null
@@ -1,228 +0,0 @@
-// Copyright 2014 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Utilities for processing transparent channel.
-//
-// Author(s): Branimir Vasic (branimir.vasic@imgtec.com)
-// Djordje Pesut (djordje.pesut@imgtec.com)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_MIPS_DSP_R2)
-
-static int DispatchAlpha_MIPSdspR2(const uint8_t* alpha, int alpha_stride,
- int width, int height,
- uint8_t* dst, int dst_stride) {
- uint32_t alpha_mask = 0xffffffff;
- int i, j, temp0;
-
- for (j = 0; j < height; ++j) {
- uint8_t* pdst = dst;
- const uint8_t* palpha = alpha;
- for (i = 0; i < (width >> 2); ++i) {
- int temp1, temp2, temp3;
-
- __asm__ volatile (
- "ulw %[temp0], 0(%[palpha]) \n\t"
- "addiu %[palpha], %[palpha], 4 \n\t"
- "addiu %[pdst], %[pdst], 16 \n\t"
- "srl %[temp1], %[temp0], 8 \n\t"
- "srl %[temp2], %[temp0], 16 \n\t"
- "srl %[temp3], %[temp0], 24 \n\t"
- "and %[alpha_mask], %[alpha_mask], %[temp0] \n\t"
- "sb %[temp0], -16(%[pdst]) \n\t"
- "sb %[temp1], -12(%[pdst]) \n\t"
- "sb %[temp2], -8(%[pdst]) \n\t"
- "sb %[temp3], -4(%[pdst]) \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [palpha]"+r"(palpha), [pdst]"+r"(pdst),
- [alpha_mask]"+r"(alpha_mask)
- :
- : "memory"
- );
- }
-
- for (i = 0; i < (width & 3); ++i) {
- __asm__ volatile (
- "lbu %[temp0], 0(%[palpha]) \n\t"
- "addiu %[palpha], %[palpha], 1 \n\t"
- "sb %[temp0], 0(%[pdst]) \n\t"
- "and %[alpha_mask], %[alpha_mask], %[temp0] \n\t"
- "addiu %[pdst], %[pdst], 4 \n\t"
- : [temp0]"=&r"(temp0), [palpha]"+r"(palpha), [pdst]"+r"(pdst),
- [alpha_mask]"+r"(alpha_mask)
- :
- : "memory"
- );
- }
- alpha += alpha_stride;
- dst += dst_stride;
- }
-
- __asm__ volatile (
- "ext %[temp0], %[alpha_mask], 0, 16 \n\t"
- "srl %[alpha_mask], %[alpha_mask], 16 \n\t"
- "and %[alpha_mask], %[alpha_mask], %[temp0] \n\t"
- "ext %[temp0], %[alpha_mask], 0, 8 \n\t"
- "srl %[alpha_mask], %[alpha_mask], 8 \n\t"
- "and %[alpha_mask], %[alpha_mask], %[temp0] \n\t"
- : [temp0]"=&r"(temp0), [alpha_mask]"+r"(alpha_mask)
- :
- );
-
- return (alpha_mask != 0xff);
-}
-
-static void MultARGBRow_MIPSdspR2(uint32_t* const ptr, int width,
- int inverse) {
- int x;
- const uint32_t c_00ffffff = 0x00ffffffu;
- const uint32_t c_ff000000 = 0xff000000u;
- const uint32_t c_8000000 = 0x00800000u;
- const uint32_t c_8000080 = 0x00800080u;
- for (x = 0; x < width; ++x) {
- const uint32_t argb = ptr[x];
- if (argb < 0xff000000u) { // alpha < 255
- if (argb <= 0x00ffffffu) { // alpha == 0
- ptr[x] = 0;
- } else {
- int temp0, temp1, temp2, temp3, alpha;
- __asm__ volatile (
- "srl %[alpha], %[argb], 24 \n\t"
- "replv.qb %[temp0], %[alpha] \n\t"
- "and %[temp0], %[temp0], %[c_00ffffff] \n\t"
- "beqz %[inverse], 0f \n\t"
- "divu $zero, %[c_ff000000], %[alpha] \n\t"
- "mflo %[temp0] \n\t"
- "0: \n\t"
- "andi %[temp1], %[argb], 0xff \n\t"
- "ext %[temp2], %[argb], 8, 8 \n\t"
- "ext %[temp3], %[argb], 16, 8 \n\t"
- "mul %[temp1], %[temp1], %[temp0] \n\t"
- "mul %[temp2], %[temp2], %[temp0] \n\t"
- "mul %[temp3], %[temp3], %[temp0] \n\t"
- "precrq.ph.w %[temp1], %[temp2], %[temp1] \n\t"
- "addu %[temp3], %[temp3], %[c_8000000] \n\t"
- "addu %[temp1], %[temp1], %[c_8000080] \n\t"
- "precrq.ph.w %[temp3], %[argb], %[temp3] \n\t"
- "precrq.qb.ph %[temp1], %[temp3], %[temp1] \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [alpha]"=&r"(alpha)
- : [inverse]"r"(inverse), [c_00ffffff]"r"(c_00ffffff),
- [c_8000000]"r"(c_8000000), [c_8000080]"r"(c_8000080),
- [c_ff000000]"r"(c_ff000000), [argb]"r"(argb)
- : "memory", "hi", "lo"
- );
- ptr[x] = temp1;
- }
- }
- }
-}
-
-#ifdef WORDS_BIGENDIAN
-static void PackARGB_MIPSdspR2(const uint8_t* a, const uint8_t* r,
- const uint8_t* g, const uint8_t* b, int len,
- uint32_t* out) {
- int temp0, temp1, temp2, temp3, offset;
- const int rest = len & 1;
- const uint32_t* const loop_end = out + len - rest;
- const int step = 4;
- __asm__ volatile (
- "xor %[offset], %[offset], %[offset] \n\t"
- "beq %[loop_end], %[out], 0f \n\t"
- "2: \n\t"
- "lbux %[temp0], %[offset](%[a]) \n\t"
- "lbux %[temp1], %[offset](%[r]) \n\t"
- "lbux %[temp2], %[offset](%[g]) \n\t"
- "lbux %[temp3], %[offset](%[b]) \n\t"
- "ins %[temp1], %[temp0], 16, 16 \n\t"
- "ins %[temp3], %[temp2], 16, 16 \n\t"
- "addiu %[out], %[out], 4 \n\t"
- "precr.qb.ph %[temp0], %[temp1], %[temp3] \n\t"
- "sw %[temp0], -4(%[out]) \n\t"
- "addu %[offset], %[offset], %[step] \n\t"
- "bne %[loop_end], %[out], 2b \n\t"
- "0: \n\t"
- "beq %[rest], $zero, 1f \n\t"
- "lbux %[temp0], %[offset](%[a]) \n\t"
- "lbux %[temp1], %[offset](%[r]) \n\t"
- "lbux %[temp2], %[offset](%[g]) \n\t"
- "lbux %[temp3], %[offset](%[b]) \n\t"
- "ins %[temp1], %[temp0], 16, 16 \n\t"
- "ins %[temp3], %[temp2], 16, 16 \n\t"
- "precr.qb.ph %[temp0], %[temp1], %[temp3] \n\t"
- "sw %[temp0], 0(%[out]) \n\t"
- "1: \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [offset]"=&r"(offset), [out]"+&r"(out)
- : [a]"r"(a), [r]"r"(r), [g]"r"(g), [b]"r"(b), [step]"r"(step),
- [loop_end]"r"(loop_end), [rest]"r"(rest)
- : "memory"
- );
-}
-#endif // WORDS_BIGENDIAN
-
-static void PackRGB_MIPSdspR2(const uint8_t* r, const uint8_t* g,
- const uint8_t* b, int len, int step,
- uint32_t* out) {
- int temp0, temp1, temp2, offset;
- const int rest = len & 1;
- const int a = 0xff;
- const uint32_t* const loop_end = out + len - rest;
- __asm__ volatile (
- "xor %[offset], %[offset], %[offset] \n\t"
- "beq %[loop_end], %[out], 0f \n\t"
- "2: \n\t"
- "lbux %[temp0], %[offset](%[r]) \n\t"
- "lbux %[temp1], %[offset](%[g]) \n\t"
- "lbux %[temp2], %[offset](%[b]) \n\t"
- "ins %[temp0], %[a], 16, 16 \n\t"
- "ins %[temp2], %[temp1], 16, 16 \n\t"
- "addiu %[out], %[out], 4 \n\t"
- "precr.qb.ph %[temp0], %[temp0], %[temp2] \n\t"
- "sw %[temp0], -4(%[out]) \n\t"
- "addu %[offset], %[offset], %[step] \n\t"
- "bne %[loop_end], %[out], 2b \n\t"
- "0: \n\t"
- "beq %[rest], $zero, 1f \n\t"
- "lbux %[temp0], %[offset](%[r]) \n\t"
- "lbux %[temp1], %[offset](%[g]) \n\t"
- "lbux %[temp2], %[offset](%[b]) \n\t"
- "ins %[temp0], %[a], 16, 16 \n\t"
- "ins %[temp2], %[temp1], 16, 16 \n\t"
- "precr.qb.ph %[temp0], %[temp0], %[temp2] \n\t"
- "sw %[temp0], 0(%[out]) \n\t"
- "1: \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [offset]"=&r"(offset), [out]"+&r"(out)
- : [a]"r"(a), [r]"r"(r), [g]"r"(g), [b]"r"(b), [step]"r"(step),
- [loop_end]"r"(loop_end), [rest]"r"(rest)
- : "memory"
- );
-}
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void WebPInitAlphaProcessingMIPSdspR2(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void WebPInitAlphaProcessingMIPSdspR2(void) {
- WebPDispatchAlpha = DispatchAlpha_MIPSdspR2;
- WebPMultARGBRow = MultARGBRow_MIPSdspR2;
-#ifdef WORDS_BIGENDIAN
- WebPPackARGB = PackARGB_MIPSdspR2;
-#endif
- WebPPackRGB = PackRGB_MIPSdspR2;
-}
-
-#else // !WEBP_USE_MIPS_DSP_R2
-
-WEBP_DSP_INIT_STUB(WebPInitAlphaProcessingMIPSdspR2)
-
-#endif // WEBP_USE_MIPS_DSP_R2
diff --git a/contrib/libs/libwebp/dsp/alpha_processing_neon.c b/contrib/libs/libwebp/dsp/alpha_processing_neon.c
deleted file mode 100644
index d180a10301..0000000000
--- a/contrib/libs/libwebp/dsp/alpha_processing_neon.c
+++ /dev/null
@@ -1,192 +0,0 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Utilities for processing transparent channel, NEON version.
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_NEON)
-
-#include "./neon.h"
-
-//------------------------------------------------------------------------------
-
-#define MULTIPLIER(a) ((a) * 0x8081)
-#define PREMULTIPLY(x, m) (((x) * (m)) >> 23)
-
-#define MULTIPLY_BY_ALPHA(V, ALPHA, OTHER) do { \
- const uint8x8_t alpha = (V).val[(ALPHA)]; \
- const uint16x8_t r1 = vmull_u8((V).val[1], alpha); \
- const uint16x8_t g1 = vmull_u8((V).val[2], alpha); \
- const uint16x8_t b1 = vmull_u8((V).val[(OTHER)], alpha); \
- /* we use: v / 255 = (v + 1 + (v >> 8)) >> 8 */ \
- const uint16x8_t r2 = vsraq_n_u16(r1, r1, 8); \
- const uint16x8_t g2 = vsraq_n_u16(g1, g1, 8); \
- const uint16x8_t b2 = vsraq_n_u16(b1, b1, 8); \
- const uint16x8_t r3 = vaddq_u16(r2, kOne); \
- const uint16x8_t g3 = vaddq_u16(g2, kOne); \
- const uint16x8_t b3 = vaddq_u16(b2, kOne); \
- (V).val[1] = vshrn_n_u16(r3, 8); \
- (V).val[2] = vshrn_n_u16(g3, 8); \
- (V).val[(OTHER)] = vshrn_n_u16(b3, 8); \
-} while (0)
-
-static void ApplyAlphaMultiply_NEON(uint8_t* rgba, int alpha_first,
- int w, int h, int stride) {
- const uint16x8_t kOne = vdupq_n_u16(1u);
- while (h-- > 0) {
- uint32_t* const rgbx = (uint32_t*)rgba;
- int i = 0;
- if (alpha_first) {
- for (; i + 8 <= w; i += 8) {
- // load aaaa...|rrrr...|gggg...|bbbb...
- uint8x8x4_t RGBX = vld4_u8((const uint8_t*)(rgbx + i));
- MULTIPLY_BY_ALPHA(RGBX, 0, 3);
- vst4_u8((uint8_t*)(rgbx + i), RGBX);
- }
- } else {
- for (; i + 8 <= w; i += 8) {
- uint8x8x4_t RGBX = vld4_u8((const uint8_t*)(rgbx + i));
- MULTIPLY_BY_ALPHA(RGBX, 3, 0);
- vst4_u8((uint8_t*)(rgbx + i), RGBX);
- }
- }
- // Finish with left-overs.
- for (; i < w; ++i) {
- uint8_t* const rgb = rgba + (alpha_first ? 1 : 0);
- const uint8_t* const alpha = rgba + (alpha_first ? 0 : 3);
- const uint32_t a = alpha[4 * i];
- if (a != 0xff) {
- const uint32_t mult = MULTIPLIER(a);
- rgb[4 * i + 0] = PREMULTIPLY(rgb[4 * i + 0], mult);
- rgb[4 * i + 1] = PREMULTIPLY(rgb[4 * i + 1], mult);
- rgb[4 * i + 2] = PREMULTIPLY(rgb[4 * i + 2], mult);
- }
- }
- rgba += stride;
- }
-}
-#undef MULTIPLY_BY_ALPHA
-#undef MULTIPLIER
-#undef PREMULTIPLY
-
-//------------------------------------------------------------------------------
-
-static int DispatchAlpha_NEON(const uint8_t* WEBP_RESTRICT alpha,
- int alpha_stride, int width, int height,
- uint8_t* WEBP_RESTRICT dst, int dst_stride) {
- uint32_t alpha_mask = 0xffffffffu;
- uint8x8_t mask8 = vdup_n_u8(0xff);
- uint32_t tmp[2];
- int i, j;
- for (j = 0; j < height; ++j) {
- // We don't know if alpha is first or last in dst[] (depending on rgbA/Argb
- // mode). So we must be sure dst[4*i + 8 - 1] is writable for the store.
- // Hence the test with 'width - 1' instead of just 'width'.
- for (i = 0; i + 8 <= width - 1; i += 8) {
- uint8x8x4_t rgbX = vld4_u8((const uint8_t*)(dst + 4 * i));
- const uint8x8_t alphas = vld1_u8(alpha + i);
- rgbX.val[0] = alphas;
- vst4_u8((uint8_t*)(dst + 4 * i), rgbX);
- mask8 = vand_u8(mask8, alphas);
- }
- for (; i < width; ++i) {
- const uint32_t alpha_value = alpha[i];
- dst[4 * i] = alpha_value;
- alpha_mask &= alpha_value;
- }
- alpha += alpha_stride;
- dst += dst_stride;
- }
- vst1_u8((uint8_t*)tmp, mask8);
- alpha_mask &= tmp[0];
- alpha_mask &= tmp[1];
- return (alpha_mask != 0xffffffffu);
-}
-
-static void DispatchAlphaToGreen_NEON(const uint8_t* WEBP_RESTRICT alpha,
- int alpha_stride, int width, int height,
- uint32_t* WEBP_RESTRICT dst,
- int dst_stride) {
- int i, j;
- uint8x8x4_t greens; // leave A/R/B channels zero'd.
- greens.val[0] = vdup_n_u8(0);
- greens.val[2] = vdup_n_u8(0);
- greens.val[3] = vdup_n_u8(0);
- for (j = 0; j < height; ++j) {
- for (i = 0; i + 8 <= width; i += 8) {
- greens.val[1] = vld1_u8(alpha + i);
- vst4_u8((uint8_t*)(dst + i), greens);
- }
- for (; i < width; ++i) dst[i] = alpha[i] << 8;
- alpha += alpha_stride;
- dst += dst_stride;
- }
-}
-
-static int ExtractAlpha_NEON(const uint8_t* WEBP_RESTRICT argb, int argb_stride,
- int width, int height,
- uint8_t* WEBP_RESTRICT alpha, int alpha_stride) {
- uint32_t alpha_mask = 0xffffffffu;
- uint8x8_t mask8 = vdup_n_u8(0xff);
- uint32_t tmp[2];
- int i, j;
- for (j = 0; j < height; ++j) {
- // We don't know if alpha is first or last in dst[] (depending on rgbA/Argb
- // mode). So we must be sure dst[4*i + 8 - 1] is writable for the store.
- // Hence the test with 'width - 1' instead of just 'width'.
- for (i = 0; i + 8 <= width - 1; i += 8) {
- const uint8x8x4_t rgbX = vld4_u8((const uint8_t*)(argb + 4 * i));
- const uint8x8_t alphas = rgbX.val[0];
- vst1_u8((uint8_t*)(alpha + i), alphas);
- mask8 = vand_u8(mask8, alphas);
- }
- for (; i < width; ++i) {
- alpha[i] = argb[4 * i];
- alpha_mask &= alpha[i];
- }
- argb += argb_stride;
- alpha += alpha_stride;
- }
- vst1_u8((uint8_t*)tmp, mask8);
- alpha_mask &= tmp[0];
- alpha_mask &= tmp[1];
- return (alpha_mask == 0xffffffffu);
-}
-
-static void ExtractGreen_NEON(const uint32_t* WEBP_RESTRICT argb,
- uint8_t* WEBP_RESTRICT alpha, int size) {
- int i;
- for (i = 0; i + 16 <= size; i += 16) {
- const uint8x16x4_t rgbX = vld4q_u8((const uint8_t*)(argb + i));
- const uint8x16_t greens = rgbX.val[1];
- vst1q_u8(alpha + i, greens);
- }
- for (; i < size; ++i) alpha[i] = (argb[i] >> 8) & 0xff;
-}
-
-//------------------------------------------------------------------------------
-
-extern void WebPInitAlphaProcessingNEON(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void WebPInitAlphaProcessingNEON(void) {
- WebPApplyAlphaMultiply = ApplyAlphaMultiply_NEON;
- WebPDispatchAlpha = DispatchAlpha_NEON;
- WebPDispatchAlphaToGreen = DispatchAlphaToGreen_NEON;
- WebPExtractAlpha = ExtractAlpha_NEON;
- WebPExtractGreen = ExtractGreen_NEON;
-}
-
-#else // !WEBP_USE_NEON
-
-WEBP_DSP_INIT_STUB(WebPInitAlphaProcessingNEON)
-
-#endif // WEBP_USE_NEON
diff --git a/contrib/libs/libwebp/dsp/alpha_processing_sse2.c b/contrib/libs/libwebp/dsp/alpha_processing_sse2.c
deleted file mode 100644
index a3de73d449..0000000000
--- a/contrib/libs/libwebp/dsp/alpha_processing_sse2.c
+++ /dev/null
@@ -1,367 +0,0 @@
-// Copyright 2014 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Utilities for processing transparent channel.
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_SSE2)
-#include <emmintrin.h>
-
-//------------------------------------------------------------------------------
-
-static int DispatchAlpha_SSE2(const uint8_t* WEBP_RESTRICT alpha,
- int alpha_stride, int width, int height,
- uint8_t* WEBP_RESTRICT dst, int dst_stride) {
- // alpha_and stores an 'and' operation of all the alpha[] values. The final
- // value is not 0xff if any of the alpha[] is not equal to 0xff.
- uint32_t alpha_and = 0xff;
- int i, j;
- const __m128i zero = _mm_setzero_si128();
- const __m128i rgb_mask = _mm_set1_epi32(0xffffff00u); // to preserve RGB
- const __m128i all_0xff = _mm_set_epi32(0, 0, ~0u, ~0u);
- __m128i all_alphas = all_0xff;
-
- // We must be able to access 3 extra bytes after the last written byte
- // 'dst[4 * width - 4]', because we don't know if alpha is the first or the
- // last byte of the quadruplet.
- const int limit = (width - 1) & ~7;
-
- for (j = 0; j < height; ++j) {
- __m128i* out = (__m128i*)dst;
- for (i = 0; i < limit; i += 8) {
- // load 8 alpha bytes
- const __m128i a0 = _mm_loadl_epi64((const __m128i*)&alpha[i]);
- const __m128i a1 = _mm_unpacklo_epi8(a0, zero);
- const __m128i a2_lo = _mm_unpacklo_epi16(a1, zero);
- const __m128i a2_hi = _mm_unpackhi_epi16(a1, zero);
- // load 8 dst pixels (32 bytes)
- const __m128i b0_lo = _mm_loadu_si128(out + 0);
- const __m128i b0_hi = _mm_loadu_si128(out + 1);
- // mask dst alpha values
- const __m128i b1_lo = _mm_and_si128(b0_lo, rgb_mask);
- const __m128i b1_hi = _mm_and_si128(b0_hi, rgb_mask);
- // combine
- const __m128i b2_lo = _mm_or_si128(b1_lo, a2_lo);
- const __m128i b2_hi = _mm_or_si128(b1_hi, a2_hi);
- // store
- _mm_storeu_si128(out + 0, b2_lo);
- _mm_storeu_si128(out + 1, b2_hi);
- // accumulate eight alpha 'and' in parallel
- all_alphas = _mm_and_si128(all_alphas, a0);
- out += 2;
- }
- for (; i < width; ++i) {
- const uint32_t alpha_value = alpha[i];
- dst[4 * i] = alpha_value;
- alpha_and &= alpha_value;
- }
- alpha += alpha_stride;
- dst += dst_stride;
- }
- // Combine the eight alpha 'and' into a 8-bit mask.
- alpha_and &= _mm_movemask_epi8(_mm_cmpeq_epi8(all_alphas, all_0xff));
- return (alpha_and != 0xff);
-}
-
-static void DispatchAlphaToGreen_SSE2(const uint8_t* WEBP_RESTRICT alpha,
- int alpha_stride, int width, int height,
- uint32_t* WEBP_RESTRICT dst,
- int dst_stride) {
- int i, j;
- const __m128i zero = _mm_setzero_si128();
- const int limit = width & ~15;
- for (j = 0; j < height; ++j) {
- for (i = 0; i < limit; i += 16) { // process 16 alpha bytes
- const __m128i a0 = _mm_loadu_si128((const __m128i*)&alpha[i]);
- const __m128i a1 = _mm_unpacklo_epi8(zero, a0); // note the 'zero' first!
- const __m128i b1 = _mm_unpackhi_epi8(zero, a0);
- const __m128i a2_lo = _mm_unpacklo_epi16(a1, zero);
- const __m128i b2_lo = _mm_unpacklo_epi16(b1, zero);
- const __m128i a2_hi = _mm_unpackhi_epi16(a1, zero);
- const __m128i b2_hi = _mm_unpackhi_epi16(b1, zero);
- _mm_storeu_si128((__m128i*)&dst[i + 0], a2_lo);
- _mm_storeu_si128((__m128i*)&dst[i + 4], a2_hi);
- _mm_storeu_si128((__m128i*)&dst[i + 8], b2_lo);
- _mm_storeu_si128((__m128i*)&dst[i + 12], b2_hi);
- }
- for (; i < width; ++i) dst[i] = alpha[i] << 8;
- alpha += alpha_stride;
- dst += dst_stride;
- }
-}
-
-static int ExtractAlpha_SSE2(const uint8_t* WEBP_RESTRICT argb, int argb_stride,
- int width, int height,
- uint8_t* WEBP_RESTRICT alpha, int alpha_stride) {
- // alpha_and stores an 'and' operation of all the alpha[] values. The final
- // value is not 0xff if any of the alpha[] is not equal to 0xff.
- uint32_t alpha_and = 0xff;
- int i, j;
- const __m128i a_mask = _mm_set1_epi32(0xffu); // to preserve alpha
- const __m128i all_0xff = _mm_set_epi32(0, 0, ~0u, ~0u);
- __m128i all_alphas = all_0xff;
-
- // We must be able to access 3 extra bytes after the last written byte
- // 'src[4 * width - 4]', because we don't know if alpha is the first or the
- // last byte of the quadruplet.
- const int limit = (width - 1) & ~7;
-
- for (j = 0; j < height; ++j) {
- const __m128i* src = (const __m128i*)argb;
- for (i = 0; i < limit; i += 8) {
- // load 32 argb bytes
- const __m128i a0 = _mm_loadu_si128(src + 0);
- const __m128i a1 = _mm_loadu_si128(src + 1);
- const __m128i b0 = _mm_and_si128(a0, a_mask);
- const __m128i b1 = _mm_and_si128(a1, a_mask);
- const __m128i c0 = _mm_packs_epi32(b0, b1);
- const __m128i d0 = _mm_packus_epi16(c0, c0);
- // store
- _mm_storel_epi64((__m128i*)&alpha[i], d0);
- // accumulate eight alpha 'and' in parallel
- all_alphas = _mm_and_si128(all_alphas, d0);
- src += 2;
- }
- for (; i < width; ++i) {
- const uint32_t alpha_value = argb[4 * i];
- alpha[i] = alpha_value;
- alpha_and &= alpha_value;
- }
- argb += argb_stride;
- alpha += alpha_stride;
- }
- // Combine the eight alpha 'and' into a 8-bit mask.
- alpha_and &= _mm_movemask_epi8(_mm_cmpeq_epi8(all_alphas, all_0xff));
- return (alpha_and == 0xff);
-}
-
-//------------------------------------------------------------------------------
-// Non-dither premultiplied modes
-
-#define MULTIPLIER(a) ((a) * 0x8081)
-#define PREMULTIPLY(x, m) (((x) * (m)) >> 23)
-
-// We can't use a 'const int' for the SHUFFLE value, because it has to be an
-// immediate in the _mm_shufflexx_epi16() instruction. We really need a macro.
-// We use: v / 255 = (v * 0x8081) >> 23, where v = alpha * {r,g,b} is a 16bit
-// value.
-#define APPLY_ALPHA(RGBX, SHUFFLE) do { \
- const __m128i argb0 = _mm_loadu_si128((const __m128i*)&(RGBX)); \
- const __m128i argb1_lo = _mm_unpacklo_epi8(argb0, zero); \
- const __m128i argb1_hi = _mm_unpackhi_epi8(argb0, zero); \
- const __m128i alpha0_lo = _mm_or_si128(argb1_lo, kMask); \
- const __m128i alpha0_hi = _mm_or_si128(argb1_hi, kMask); \
- const __m128i alpha1_lo = _mm_shufflelo_epi16(alpha0_lo, SHUFFLE); \
- const __m128i alpha1_hi = _mm_shufflelo_epi16(alpha0_hi, SHUFFLE); \
- const __m128i alpha2_lo = _mm_shufflehi_epi16(alpha1_lo, SHUFFLE); \
- const __m128i alpha2_hi = _mm_shufflehi_epi16(alpha1_hi, SHUFFLE); \
- /* alpha2 = [ff a0 a0 a0][ff a1 a1 a1] */ \
- const __m128i A0_lo = _mm_mullo_epi16(alpha2_lo, argb1_lo); \
- const __m128i A0_hi = _mm_mullo_epi16(alpha2_hi, argb1_hi); \
- const __m128i A1_lo = _mm_mulhi_epu16(A0_lo, kMult); \
- const __m128i A1_hi = _mm_mulhi_epu16(A0_hi, kMult); \
- const __m128i A2_lo = _mm_srli_epi16(A1_lo, 7); \
- const __m128i A2_hi = _mm_srli_epi16(A1_hi, 7); \
- const __m128i A3 = _mm_packus_epi16(A2_lo, A2_hi); \
- _mm_storeu_si128((__m128i*)&(RGBX), A3); \
-} while (0)
-
-static void ApplyAlphaMultiply_SSE2(uint8_t* rgba, int alpha_first,
- int w, int h, int stride) {
- const __m128i zero = _mm_setzero_si128();
- const __m128i kMult = _mm_set1_epi16(0x8081u);
- const __m128i kMask = _mm_set_epi16(0, 0xff, 0xff, 0, 0, 0xff, 0xff, 0);
- const int kSpan = 4;
- while (h-- > 0) {
- uint32_t* const rgbx = (uint32_t*)rgba;
- int i;
- if (!alpha_first) {
- for (i = 0; i + kSpan <= w; i += kSpan) {
- APPLY_ALPHA(rgbx[i], _MM_SHUFFLE(2, 3, 3, 3));
- }
- } else {
- for (i = 0; i + kSpan <= w; i += kSpan) {
- APPLY_ALPHA(rgbx[i], _MM_SHUFFLE(0, 0, 0, 1));
- }
- }
- // Finish with left-overs.
- for (; i < w; ++i) {
- uint8_t* const rgb = rgba + (alpha_first ? 1 : 0);
- const uint8_t* const alpha = rgba + (alpha_first ? 0 : 3);
- const uint32_t a = alpha[4 * i];
- if (a != 0xff) {
- const uint32_t mult = MULTIPLIER(a);
- rgb[4 * i + 0] = PREMULTIPLY(rgb[4 * i + 0], mult);
- rgb[4 * i + 1] = PREMULTIPLY(rgb[4 * i + 1], mult);
- rgb[4 * i + 2] = PREMULTIPLY(rgb[4 * i + 2], mult);
- }
- }
- rgba += stride;
- }
-}
-#undef MULTIPLIER
-#undef PREMULTIPLY
-
-//------------------------------------------------------------------------------
-// Alpha detection
-
-static int HasAlpha8b_SSE2(const uint8_t* src, int length) {
- const __m128i all_0xff = _mm_set1_epi8((char)0xff);
- int i = 0;
- for (; i + 16 <= length; i += 16) {
- const __m128i v = _mm_loadu_si128((const __m128i*)(src + i));
- const __m128i bits = _mm_cmpeq_epi8(v, all_0xff);
- const int mask = _mm_movemask_epi8(bits);
- if (mask != 0xffff) return 1;
- }
- for (; i < length; ++i) if (src[i] != 0xff) return 1;
- return 0;
-}
-
-static int HasAlpha32b_SSE2(const uint8_t* src, int length) {
- const __m128i alpha_mask = _mm_set1_epi32(0xff);
- const __m128i all_0xff = _mm_set1_epi8((char)0xff);
- int i = 0;
- // We don't know if we can access the last 3 bytes after the last alpha
- // value 'src[4 * length - 4]' (because we don't know if alpha is the first
- // or the last byte of the quadruplet). Hence the '-3' protection below.
- length = length * 4 - 3; // size in bytes
- for (; i + 64 <= length; i += 64) {
- const __m128i a0 = _mm_loadu_si128((const __m128i*)(src + i + 0));
- const __m128i a1 = _mm_loadu_si128((const __m128i*)(src + i + 16));
- const __m128i a2 = _mm_loadu_si128((const __m128i*)(src + i + 32));
- const __m128i a3 = _mm_loadu_si128((const __m128i*)(src + i + 48));
- const __m128i b0 = _mm_and_si128(a0, alpha_mask);
- const __m128i b1 = _mm_and_si128(a1, alpha_mask);
- const __m128i b2 = _mm_and_si128(a2, alpha_mask);
- const __m128i b3 = _mm_and_si128(a3, alpha_mask);
- const __m128i c0 = _mm_packs_epi32(b0, b1);
- const __m128i c1 = _mm_packs_epi32(b2, b3);
- const __m128i d = _mm_packus_epi16(c0, c1);
- const __m128i bits = _mm_cmpeq_epi8(d, all_0xff);
- const int mask = _mm_movemask_epi8(bits);
- if (mask != 0xffff) return 1;
- }
- for (; i + 32 <= length; i += 32) {
- const __m128i a0 = _mm_loadu_si128((const __m128i*)(src + i + 0));
- const __m128i a1 = _mm_loadu_si128((const __m128i*)(src + i + 16));
- const __m128i b0 = _mm_and_si128(a0, alpha_mask);
- const __m128i b1 = _mm_and_si128(a1, alpha_mask);
- const __m128i c = _mm_packs_epi32(b0, b1);
- const __m128i d = _mm_packus_epi16(c, c);
- const __m128i bits = _mm_cmpeq_epi8(d, all_0xff);
- const int mask = _mm_movemask_epi8(bits);
- if (mask != 0xffff) return 1;
- }
- for (; i <= length; i += 4) if (src[i] != 0xff) return 1;
- return 0;
-}
-
-static void AlphaReplace_SSE2(uint32_t* src, int length, uint32_t color) {
- const __m128i m_color = _mm_set1_epi32(color);
- const __m128i zero = _mm_setzero_si128();
- int i = 0;
- for (; i + 8 <= length; i += 8) {
- const __m128i a0 = _mm_loadu_si128((const __m128i*)(src + i + 0));
- const __m128i a1 = _mm_loadu_si128((const __m128i*)(src + i + 4));
- const __m128i b0 = _mm_srai_epi32(a0, 24);
- const __m128i b1 = _mm_srai_epi32(a1, 24);
- const __m128i c0 = _mm_cmpeq_epi32(b0, zero);
- const __m128i c1 = _mm_cmpeq_epi32(b1, zero);
- const __m128i d0 = _mm_and_si128(c0, m_color);
- const __m128i d1 = _mm_and_si128(c1, m_color);
- const __m128i e0 = _mm_andnot_si128(c0, a0);
- const __m128i e1 = _mm_andnot_si128(c1, a1);
- _mm_storeu_si128((__m128i*)(src + i + 0), _mm_or_si128(d0, e0));
- _mm_storeu_si128((__m128i*)(src + i + 4), _mm_or_si128(d1, e1));
- }
- for (; i < length; ++i) if ((src[i] >> 24) == 0) src[i] = color;
-}
-
-// -----------------------------------------------------------------------------
-// Apply alpha value to rows
-
-static void MultARGBRow_SSE2(uint32_t* const ptr, int width, int inverse) {
- int x = 0;
- if (!inverse) {
- const int kSpan = 2;
- const __m128i zero = _mm_setzero_si128();
- const __m128i k128 = _mm_set1_epi16(128);
- const __m128i kMult = _mm_set1_epi16(0x0101);
- const __m128i kMask = _mm_set_epi16(0, 0xff, 0, 0, 0, 0xff, 0, 0);
- for (x = 0; x + kSpan <= width; x += kSpan) {
- // To compute 'result = (int)(a * x / 255. + .5)', we use:
- // tmp = a * v + 128, result = (tmp * 0x0101u) >> 16
- const __m128i A0 = _mm_loadl_epi64((const __m128i*)&ptr[x]);
- const __m128i A1 = _mm_unpacklo_epi8(A0, zero);
- const __m128i A2 = _mm_or_si128(A1, kMask);
- const __m128i A3 = _mm_shufflelo_epi16(A2, _MM_SHUFFLE(2, 3, 3, 3));
- const __m128i A4 = _mm_shufflehi_epi16(A3, _MM_SHUFFLE(2, 3, 3, 3));
- // here, A4 = [ff a0 a0 a0][ff a1 a1 a1]
- const __m128i A5 = _mm_mullo_epi16(A4, A1);
- const __m128i A6 = _mm_add_epi16(A5, k128);
- const __m128i A7 = _mm_mulhi_epu16(A6, kMult);
- const __m128i A10 = _mm_packus_epi16(A7, zero);
- _mm_storel_epi64((__m128i*)&ptr[x], A10);
- }
- }
- width -= x;
- if (width > 0) WebPMultARGBRow_C(ptr + x, width, inverse);
-}
-
-static void MultRow_SSE2(uint8_t* WEBP_RESTRICT const ptr,
- const uint8_t* WEBP_RESTRICT const alpha,
- int width, int inverse) {
- int x = 0;
- if (!inverse) {
- const __m128i zero = _mm_setzero_si128();
- const __m128i k128 = _mm_set1_epi16(128);
- const __m128i kMult = _mm_set1_epi16(0x0101);
- for (x = 0; x + 8 <= width; x += 8) {
- const __m128i v0 = _mm_loadl_epi64((__m128i*)&ptr[x]);
- const __m128i a0 = _mm_loadl_epi64((const __m128i*)&alpha[x]);
- const __m128i v1 = _mm_unpacklo_epi8(v0, zero);
- const __m128i a1 = _mm_unpacklo_epi8(a0, zero);
- const __m128i v2 = _mm_mullo_epi16(v1, a1);
- const __m128i v3 = _mm_add_epi16(v2, k128);
- const __m128i v4 = _mm_mulhi_epu16(v3, kMult);
- const __m128i v5 = _mm_packus_epi16(v4, zero);
- _mm_storel_epi64((__m128i*)&ptr[x], v5);
- }
- }
- width -= x;
- if (width > 0) WebPMultRow_C(ptr + x, alpha + x, width, inverse);
-}
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void WebPInitAlphaProcessingSSE2(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void WebPInitAlphaProcessingSSE2(void) {
- WebPMultARGBRow = MultARGBRow_SSE2;
- WebPMultRow = MultRow_SSE2;
- WebPApplyAlphaMultiply = ApplyAlphaMultiply_SSE2;
- WebPDispatchAlpha = DispatchAlpha_SSE2;
- WebPDispatchAlphaToGreen = DispatchAlphaToGreen_SSE2;
- WebPExtractAlpha = ExtractAlpha_SSE2;
-
- WebPHasAlpha8b = HasAlpha8b_SSE2;
- WebPHasAlpha32b = HasAlpha32b_SSE2;
- WebPAlphaReplace = AlphaReplace_SSE2;
-}
-
-#else // !WEBP_USE_SSE2
-
-WEBP_DSP_INIT_STUB(WebPInitAlphaProcessingSSE2)
-
-#endif // WEBP_USE_SSE2
diff --git a/contrib/libs/libwebp/dsp/alpha_processing_sse41.c b/contrib/libs/libwebp/dsp/alpha_processing_sse41.c
deleted file mode 100644
index 4f1e7cafbe..0000000000
--- a/contrib/libs/libwebp/dsp/alpha_processing_sse41.c
+++ /dev/null
@@ -1,92 +0,0 @@
-// Copyright 2015 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Utilities for processing transparent channel, SSE4.1 variant.
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_SSE41)
-
-#include <smmintrin.h>
-
-//------------------------------------------------------------------------------
-
-static int ExtractAlpha_SSE41(const uint8_t* WEBP_RESTRICT argb,
- int argb_stride, int width, int height,
- uint8_t* WEBP_RESTRICT alpha, int alpha_stride) {
- // alpha_and stores an 'and' operation of all the alpha[] values. The final
- // value is not 0xff if any of the alpha[] is not equal to 0xff.
- uint32_t alpha_and = 0xff;
- int i, j;
- const __m128i all_0xff = _mm_set1_epi32(~0u);
- __m128i all_alphas = all_0xff;
-
- // We must be able to access 3 extra bytes after the last written byte
- // 'src[4 * width - 4]', because we don't know if alpha is the first or the
- // last byte of the quadruplet.
- const int limit = (width - 1) & ~15;
- const __m128i kCstAlpha0 = _mm_set_epi8(-1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, 12, 8, 4, 0);
- const __m128i kCstAlpha1 = _mm_set_epi8(-1, -1, -1, -1, -1, -1, -1, -1,
- 12, 8, 4, 0, -1, -1, -1, -1);
- const __m128i kCstAlpha2 = _mm_set_epi8(-1, -1, -1, -1, 12, 8, 4, 0,
- -1, -1, -1, -1, -1, -1, -1, -1);
- const __m128i kCstAlpha3 = _mm_set_epi8(12, 8, 4, 0, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1);
- for (j = 0; j < height; ++j) {
- const __m128i* src = (const __m128i*)argb;
- for (i = 0; i < limit; i += 16) {
- // load 64 argb bytes
- const __m128i a0 = _mm_loadu_si128(src + 0);
- const __m128i a1 = _mm_loadu_si128(src + 1);
- const __m128i a2 = _mm_loadu_si128(src + 2);
- const __m128i a3 = _mm_loadu_si128(src + 3);
- const __m128i b0 = _mm_shuffle_epi8(a0, kCstAlpha0);
- const __m128i b1 = _mm_shuffle_epi8(a1, kCstAlpha1);
- const __m128i b2 = _mm_shuffle_epi8(a2, kCstAlpha2);
- const __m128i b3 = _mm_shuffle_epi8(a3, kCstAlpha3);
- const __m128i c0 = _mm_or_si128(b0, b1);
- const __m128i c1 = _mm_or_si128(b2, b3);
- const __m128i d0 = _mm_or_si128(c0, c1);
- // store
- _mm_storeu_si128((__m128i*)&alpha[i], d0);
- // accumulate sixteen alpha 'and' in parallel
- all_alphas = _mm_and_si128(all_alphas, d0);
- src += 4;
- }
- for (; i < width; ++i) {
- const uint32_t alpha_value = argb[4 * i];
- alpha[i] = alpha_value;
- alpha_and &= alpha_value;
- }
- argb += argb_stride;
- alpha += alpha_stride;
- }
- // Combine the sixteen alpha 'and' into an 8-bit mask.
- alpha_and |= 0xff00u; // pretend the upper bits [8..15] were tested ok.
- alpha_and &= _mm_movemask_epi8(_mm_cmpeq_epi8(all_alphas, all_0xff));
- return (alpha_and == 0xffffu);
-}
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void WebPInitAlphaProcessingSSE41(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void WebPInitAlphaProcessingSSE41(void) {
- WebPExtractAlpha = ExtractAlpha_SSE41;
-}
-
-#else // !WEBP_USE_SSE41
-
-WEBP_DSP_INIT_STUB(WebPInitAlphaProcessingSSE41)
-
-#endif // WEBP_USE_SSE41
diff --git a/contrib/libs/libwebp/dsp/common_sse2.h b/contrib/libs/libwebp/dsp/common_sse2.h
deleted file mode 100644
index e9f1ebff44..0000000000
--- a/contrib/libs/libwebp/dsp/common_sse2.h
+++ /dev/null
@@ -1,194 +0,0 @@
-// Copyright 2016 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// SSE2 code common to several files.
-//
-// Author: Vincent Rabaud (vrabaud@google.com)
-
-#ifndef WEBP_DSP_COMMON_SSE2_H_
-#define WEBP_DSP_COMMON_SSE2_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if defined(WEBP_USE_SSE2)
-
-#include <emmintrin.h>
-
-//------------------------------------------------------------------------------
-// Quite useful macro for debugging. Left here for convenience.
-
-#if 0
-#include <stdio.h>
-static WEBP_INLINE void PrintReg(const __m128i r, const char* const name,
- int size) {
- int n;
- union {
- __m128i r;
- uint8_t i8[16];
- uint16_t i16[8];
- uint32_t i32[4];
- uint64_t i64[2];
- } tmp;
- tmp.r = r;
- fprintf(stderr, "%s\t: ", name);
- if (size == 8) {
- for (n = 0; n < 16; ++n) fprintf(stderr, "%.2x ", tmp.i8[n]);
- } else if (size == 16) {
- for (n = 0; n < 8; ++n) fprintf(stderr, "%.4x ", tmp.i16[n]);
- } else if (size == 32) {
- for (n = 0; n < 4; ++n) fprintf(stderr, "%.8x ", tmp.i32[n]);
- } else {
- for (n = 0; n < 2; ++n) fprintf(stderr, "%.16lx ", tmp.i64[n]);
- }
- fprintf(stderr, "\n");
-}
-#endif
-
-//------------------------------------------------------------------------------
-// Math functions.
-
-// Return the sum of all the 8b in the register.
-static WEBP_INLINE int VP8HorizontalAdd8b(const __m128i* const a) {
- const __m128i zero = _mm_setzero_si128();
- const __m128i sad8x2 = _mm_sad_epu8(*a, zero);
- // sum the two sads: sad8x2[0:1] + sad8x2[8:9]
- const __m128i sum = _mm_add_epi32(sad8x2, _mm_shuffle_epi32(sad8x2, 2));
- return _mm_cvtsi128_si32(sum);
-}
-
-// Transpose two 4x4 16b matrices horizontally stored in registers.
-static WEBP_INLINE void VP8Transpose_2_4x4_16b(
- const __m128i* const in0, const __m128i* const in1,
- const __m128i* const in2, const __m128i* const in3, __m128i* const out0,
- __m128i* const out1, __m128i* const out2, __m128i* const out3) {
- // Transpose the two 4x4.
- // a00 a01 a02 a03 b00 b01 b02 b03
- // a10 a11 a12 a13 b10 b11 b12 b13
- // a20 a21 a22 a23 b20 b21 b22 b23
- // a30 a31 a32 a33 b30 b31 b32 b33
- const __m128i transpose0_0 = _mm_unpacklo_epi16(*in0, *in1);
- const __m128i transpose0_1 = _mm_unpacklo_epi16(*in2, *in3);
- const __m128i transpose0_2 = _mm_unpackhi_epi16(*in0, *in1);
- const __m128i transpose0_3 = _mm_unpackhi_epi16(*in2, *in3);
- // a00 a10 a01 a11 a02 a12 a03 a13
- // a20 a30 a21 a31 a22 a32 a23 a33
- // b00 b10 b01 b11 b02 b12 b03 b13
- // b20 b30 b21 b31 b22 b32 b23 b33
- const __m128i transpose1_0 = _mm_unpacklo_epi32(transpose0_0, transpose0_1);
- const __m128i transpose1_1 = _mm_unpacklo_epi32(transpose0_2, transpose0_3);
- const __m128i transpose1_2 = _mm_unpackhi_epi32(transpose0_0, transpose0_1);
- const __m128i transpose1_3 = _mm_unpackhi_epi32(transpose0_2, transpose0_3);
- // a00 a10 a20 a30 a01 a11 a21 a31
- // b00 b10 b20 b30 b01 b11 b21 b31
- // a02 a12 a22 a32 a03 a13 a23 a33
- // b02 b12 a22 b32 b03 b13 b23 b33
- *out0 = _mm_unpacklo_epi64(transpose1_0, transpose1_1);
- *out1 = _mm_unpackhi_epi64(transpose1_0, transpose1_1);
- *out2 = _mm_unpacklo_epi64(transpose1_2, transpose1_3);
- *out3 = _mm_unpackhi_epi64(transpose1_2, transpose1_3);
- // a00 a10 a20 a30 b00 b10 b20 b30
- // a01 a11 a21 a31 b01 b11 b21 b31
- // a02 a12 a22 a32 b02 b12 b22 b32
- // a03 a13 a23 a33 b03 b13 b23 b33
-}
-
-//------------------------------------------------------------------------------
-// Channel mixing.
-
-// Function used several times in VP8PlanarTo24b.
-// It samples the in buffer as follows: one every two unsigned char is stored
-// at the beginning of the buffer, while the other half is stored at the end.
-#define VP8PlanarTo24bHelper(IN, OUT) \
- do { \
- const __m128i v_mask = _mm_set1_epi16(0x00ff); \
- /* Take one every two upper 8b values.*/ \
- (OUT##0) = _mm_packus_epi16(_mm_and_si128((IN##0), v_mask), \
- _mm_and_si128((IN##1), v_mask)); \
- (OUT##1) = _mm_packus_epi16(_mm_and_si128((IN##2), v_mask), \
- _mm_and_si128((IN##3), v_mask)); \
- (OUT##2) = _mm_packus_epi16(_mm_and_si128((IN##4), v_mask), \
- _mm_and_si128((IN##5), v_mask)); \
- /* Take one every two lower 8b values.*/ \
- (OUT##3) = _mm_packus_epi16(_mm_srli_epi16((IN##0), 8), \
- _mm_srli_epi16((IN##1), 8)); \
- (OUT##4) = _mm_packus_epi16(_mm_srli_epi16((IN##2), 8), \
- _mm_srli_epi16((IN##3), 8)); \
- (OUT##5) = _mm_packus_epi16(_mm_srli_epi16((IN##4), 8), \
- _mm_srli_epi16((IN##5), 8)); \
- } while (0)
-
-// Pack the planar buffers
-// rrrr... rrrr... gggg... gggg... bbbb... bbbb....
-// triplet by triplet in the output buffer rgb as rgbrgbrgbrgb ...
-static WEBP_INLINE void VP8PlanarTo24b_SSE2(
- __m128i* const in0, __m128i* const in1, __m128i* const in2,
- __m128i* const in3, __m128i* const in4, __m128i* const in5) {
- // The input is 6 registers of sixteen 8b but for the sake of explanation,
- // let's take 6 registers of four 8b values.
- // To pack, we will keep taking one every two 8b integer and move it
- // around as follows:
- // Input:
- // r0r1r2r3 | r4r5r6r7 | g0g1g2g3 | g4g5g6g7 | b0b1b2b3 | b4b5b6b7
- // Split the 6 registers in two sets of 3 registers: the first set as the even
- // 8b bytes, the second the odd ones:
- // r0r2r4r6 | g0g2g4g6 | b0b2b4b6 | r1r3r5r7 | g1g3g5g7 | b1b3b5b7
- // Repeat the same permutations twice more:
- // r0r4g0g4 | b0b4r1r5 | g1g5b1b5 | r2r6g2g6 | b2b6r3r7 | g3g7b3b7
- // r0g0b0r1 | g1b1r2g2 | b2r3g3b3 | r4g4b4r5 | g5b5r6g6 | b6r7g7b7
- __m128i tmp0, tmp1, tmp2, tmp3, tmp4, tmp5;
- VP8PlanarTo24bHelper(*in, tmp);
- VP8PlanarTo24bHelper(tmp, *in);
- VP8PlanarTo24bHelper(*in, tmp);
- // We need to do it two more times than the example as we have sixteen bytes.
- {
- __m128i out0, out1, out2, out3, out4, out5;
- VP8PlanarTo24bHelper(tmp, out);
- VP8PlanarTo24bHelper(out, *in);
- }
-}
-
-#undef VP8PlanarTo24bHelper
-
-// Convert four packed four-channel buffers like argbargbargbargb... into the
-// split channels aaaaa ... rrrr ... gggg .... bbbbb ......
-static WEBP_INLINE void VP8L32bToPlanar_SSE2(__m128i* const in0,
- __m128i* const in1,
- __m128i* const in2,
- __m128i* const in3) {
- // Column-wise transpose.
- const __m128i A0 = _mm_unpacklo_epi8(*in0, *in1);
- const __m128i A1 = _mm_unpackhi_epi8(*in0, *in1);
- const __m128i A2 = _mm_unpacklo_epi8(*in2, *in3);
- const __m128i A3 = _mm_unpackhi_epi8(*in2, *in3);
- const __m128i B0 = _mm_unpacklo_epi8(A0, A1);
- const __m128i B1 = _mm_unpackhi_epi8(A0, A1);
- const __m128i B2 = _mm_unpacklo_epi8(A2, A3);
- const __m128i B3 = _mm_unpackhi_epi8(A2, A3);
- // C0 = g7 g6 ... g1 g0 | b7 b6 ... b1 b0
- // C1 = a7 a6 ... a1 a0 | r7 r6 ... r1 r0
- const __m128i C0 = _mm_unpacklo_epi8(B0, B1);
- const __m128i C1 = _mm_unpackhi_epi8(B0, B1);
- const __m128i C2 = _mm_unpacklo_epi8(B2, B3);
- const __m128i C3 = _mm_unpackhi_epi8(B2, B3);
- // Gather the channels.
- *in0 = _mm_unpackhi_epi64(C1, C3);
- *in1 = _mm_unpacklo_epi64(C1, C3);
- *in2 = _mm_unpackhi_epi64(C0, C2);
- *in3 = _mm_unpacklo_epi64(C0, C2);
-}
-
-#endif // WEBP_USE_SSE2
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // WEBP_DSP_COMMON_SSE2_H_
diff --git a/contrib/libs/libwebp/dsp/common_sse41.h b/contrib/libs/libwebp/dsp/common_sse41.h
deleted file mode 100644
index 2f173c024a..0000000000
--- a/contrib/libs/libwebp/dsp/common_sse41.h
+++ /dev/null
@@ -1,132 +0,0 @@
-// Copyright 2016 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// SSE4 code common to several files.
-//
-// Author: Vincent Rabaud (vrabaud@google.com)
-
-#ifndef WEBP_DSP_COMMON_SSE41_H_
-#define WEBP_DSP_COMMON_SSE41_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if defined(WEBP_USE_SSE41)
-#include <smmintrin.h>
-
-//------------------------------------------------------------------------------
-// Channel mixing.
-// Shuffles the input buffer as A0 0 0 A1 0 0 A2 ...
-#define WEBP_SSE41_SHUFF(OUT, IN0, IN1) \
- OUT##0 = _mm_shuffle_epi8(*IN0, shuff0); \
- OUT##1 = _mm_shuffle_epi8(*IN0, shuff1); \
- OUT##2 = _mm_shuffle_epi8(*IN0, shuff2); \
- OUT##3 = _mm_shuffle_epi8(*IN1, shuff0); \
- OUT##4 = _mm_shuffle_epi8(*IN1, shuff1); \
- OUT##5 = _mm_shuffle_epi8(*IN1, shuff2);
-
-// Pack the planar buffers
-// rrrr... rrrr... gggg... gggg... bbbb... bbbb....
-// triplet by triplet in the output buffer rgb as rgbrgbrgbrgb ...
-static WEBP_INLINE void VP8PlanarTo24b_SSE41(
- __m128i* const in0, __m128i* const in1, __m128i* const in2,
- __m128i* const in3, __m128i* const in4, __m128i* const in5) {
- __m128i R0, R1, R2, R3, R4, R5;
- __m128i G0, G1, G2, G3, G4, G5;
- __m128i B0, B1, B2, B3, B4, B5;
-
- // Process R.
- {
- const __m128i shuff0 = _mm_set_epi8(
- 5, -1, -1, 4, -1, -1, 3, -1, -1, 2, -1, -1, 1, -1, -1, 0);
- const __m128i shuff1 = _mm_set_epi8(
- -1, 10, -1, -1, 9, -1, -1, 8, -1, -1, 7, -1, -1, 6, -1, -1);
- const __m128i shuff2 = _mm_set_epi8(
- -1, -1, 15, -1, -1, 14, -1, -1, 13, -1, -1, 12, -1, -1, 11, -1);
- WEBP_SSE41_SHUFF(R, in0, in1)
- }
-
- // Process G.
- {
- // Same as before, just shifted to the left by one and including the right
- // padding.
- const __m128i shuff0 = _mm_set_epi8(
- -1, -1, 4, -1, -1, 3, -1, -1, 2, -1, -1, 1, -1, -1, 0, -1);
- const __m128i shuff1 = _mm_set_epi8(
- 10, -1, -1, 9, -1, -1, 8, -1, -1, 7, -1, -1, 6, -1, -1, 5);
- const __m128i shuff2 = _mm_set_epi8(
- -1, 15, -1, -1, 14, -1, -1, 13, -1, -1, 12, -1, -1, 11, -1, -1);
- WEBP_SSE41_SHUFF(G, in2, in3)
- }
-
- // Process B.
- {
- const __m128i shuff0 = _mm_set_epi8(
- -1, 4, -1, -1, 3, -1, -1, 2, -1, -1, 1, -1, -1, 0, -1, -1);
- const __m128i shuff1 = _mm_set_epi8(
- -1, -1, 9, -1, -1, 8, -1, -1, 7, -1, -1, 6, -1, -1, 5, -1);
- const __m128i shuff2 = _mm_set_epi8(
- 15, -1, -1, 14, -1, -1, 13, -1, -1, 12, -1, -1, 11, -1, -1, 10);
- WEBP_SSE41_SHUFF(B, in4, in5)
- }
-
- // OR the different channels.
- {
- const __m128i RG0 = _mm_or_si128(R0, G0);
- const __m128i RG1 = _mm_or_si128(R1, G1);
- const __m128i RG2 = _mm_or_si128(R2, G2);
- const __m128i RG3 = _mm_or_si128(R3, G3);
- const __m128i RG4 = _mm_or_si128(R4, G4);
- const __m128i RG5 = _mm_or_si128(R5, G5);
- *in0 = _mm_or_si128(RG0, B0);
- *in1 = _mm_or_si128(RG1, B1);
- *in2 = _mm_or_si128(RG2, B2);
- *in3 = _mm_or_si128(RG3, B3);
- *in4 = _mm_or_si128(RG4, B4);
- *in5 = _mm_or_si128(RG5, B5);
- }
-}
-
-#undef WEBP_SSE41_SHUFF
-
-// Convert four packed four-channel buffers like argbargbargbargb... into the
-// split channels aaaaa ... rrrr ... gggg .... bbbbb ......
-static WEBP_INLINE void VP8L32bToPlanar_SSE41(__m128i* const in0,
- __m128i* const in1,
- __m128i* const in2,
- __m128i* const in3) {
- // aaaarrrrggggbbbb
- const __m128i shuff0 =
- _mm_set_epi8(15, 11, 7, 3, 14, 10, 6, 2, 13, 9, 5, 1, 12, 8, 4, 0);
- const __m128i A0 = _mm_shuffle_epi8(*in0, shuff0);
- const __m128i A1 = _mm_shuffle_epi8(*in1, shuff0);
- const __m128i A2 = _mm_shuffle_epi8(*in2, shuff0);
- const __m128i A3 = _mm_shuffle_epi8(*in3, shuff0);
- // A0A1R0R1
- // G0G1B0B1
- // A2A3R2R3
- // G0G1B0B1
- const __m128i B0 = _mm_unpacklo_epi32(A0, A1);
- const __m128i B1 = _mm_unpackhi_epi32(A0, A1);
- const __m128i B2 = _mm_unpacklo_epi32(A2, A3);
- const __m128i B3 = _mm_unpackhi_epi32(A2, A3);
- *in3 = _mm_unpacklo_epi64(B0, B2);
- *in2 = _mm_unpackhi_epi64(B0, B2);
- *in1 = _mm_unpacklo_epi64(B1, B3);
- *in0 = _mm_unpackhi_epi64(B1, B3);
-}
-
-#endif // WEBP_USE_SSE41
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // WEBP_DSP_COMMON_SSE41_H_
diff --git a/contrib/libs/libwebp/dsp/cost.c b/contrib/libs/libwebp/dsp/cost.c
deleted file mode 100644
index 8f03454b77..0000000000
--- a/contrib/libs/libwebp/dsp/cost.c
+++ /dev/null
@@ -1,411 +0,0 @@
-// Copyright 2014 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include "./dsp.h"
-#include "../enc/cost_enc.h"
-
-//------------------------------------------------------------------------------
-// Boolean-cost cost table
-
-const uint16_t VP8EntropyCost[256] = {
- 1792, 1792, 1792, 1536, 1536, 1408, 1366, 1280, 1280, 1216,
- 1178, 1152, 1110, 1076, 1061, 1024, 1024, 992, 968, 951,
- 939, 911, 896, 878, 871, 854, 838, 820, 811, 794,
- 786, 768, 768, 752, 740, 732, 720, 709, 704, 690,
- 683, 672, 666, 655, 647, 640, 631, 622, 615, 607,
- 598, 592, 586, 576, 572, 564, 559, 555, 547, 541,
- 534, 528, 522, 512, 512, 504, 500, 494, 488, 483,
- 477, 473, 467, 461, 458, 452, 448, 443, 438, 434,
- 427, 424, 419, 415, 410, 406, 403, 399, 394, 390,
- 384, 384, 377, 374, 370, 366, 362, 359, 355, 351,
- 347, 342, 342, 336, 333, 330, 326, 323, 320, 316,
- 312, 308, 305, 302, 299, 296, 293, 288, 287, 283,
- 280, 277, 274, 272, 268, 266, 262, 256, 256, 256,
- 251, 248, 245, 242, 240, 237, 234, 232, 228, 226,
- 223, 221, 218, 216, 214, 211, 208, 205, 203, 201,
- 198, 196, 192, 191, 188, 187, 183, 181, 179, 176,
- 175, 171, 171, 168, 165, 163, 160, 159, 156, 154,
- 152, 150, 148, 146, 144, 142, 139, 138, 135, 133,
- 131, 128, 128, 125, 123, 121, 119, 117, 115, 113,
- 111, 110, 107, 105, 103, 102, 100, 98, 96, 94,
- 92, 91, 89, 86, 86, 83, 82, 80, 77, 76,
- 74, 73, 71, 69, 67, 66, 64, 63, 61, 59,
- 57, 55, 54, 52, 51, 49, 47, 46, 44, 43,
- 41, 40, 38, 36, 35, 33, 32, 30, 29, 27,
- 25, 24, 22, 21, 19, 18, 16, 15, 13, 12,
- 10, 9, 7, 6, 4, 3
-};
-
-//------------------------------------------------------------------------------
-// Level cost tables
-
-// fixed costs for coding levels, deduce from the coding tree.
-// This is only the part that doesn't depend on the probability state.
-const uint16_t VP8LevelFixedCosts[MAX_LEVEL + 1] = {
- 0, 256, 256, 256, 256, 432, 618, 630,
- 731, 640, 640, 828, 901, 948, 1021, 1101,
- 1174, 1221, 1294, 1042, 1085, 1115, 1158, 1202,
- 1245, 1275, 1318, 1337, 1380, 1410, 1453, 1497,
- 1540, 1570, 1613, 1280, 1295, 1317, 1332, 1358,
- 1373, 1395, 1410, 1454, 1469, 1491, 1506, 1532,
- 1547, 1569, 1584, 1601, 1616, 1638, 1653, 1679,
- 1694, 1716, 1731, 1775, 1790, 1812, 1827, 1853,
- 1868, 1890, 1905, 1727, 1733, 1742, 1748, 1759,
- 1765, 1774, 1780, 1800, 1806, 1815, 1821, 1832,
- 1838, 1847, 1853, 1878, 1884, 1893, 1899, 1910,
- 1916, 1925, 1931, 1951, 1957, 1966, 1972, 1983,
- 1989, 1998, 2004, 2027, 2033, 2042, 2048, 2059,
- 2065, 2074, 2080, 2100, 2106, 2115, 2121, 2132,
- 2138, 2147, 2153, 2178, 2184, 2193, 2199, 2210,
- 2216, 2225, 2231, 2251, 2257, 2266, 2272, 2283,
- 2289, 2298, 2304, 2168, 2174, 2183, 2189, 2200,
- 2206, 2215, 2221, 2241, 2247, 2256, 2262, 2273,
- 2279, 2288, 2294, 2319, 2325, 2334, 2340, 2351,
- 2357, 2366, 2372, 2392, 2398, 2407, 2413, 2424,
- 2430, 2439, 2445, 2468, 2474, 2483, 2489, 2500,
- 2506, 2515, 2521, 2541, 2547, 2556, 2562, 2573,
- 2579, 2588, 2594, 2619, 2625, 2634, 2640, 2651,
- 2657, 2666, 2672, 2692, 2698, 2707, 2713, 2724,
- 2730, 2739, 2745, 2540, 2546, 2555, 2561, 2572,
- 2578, 2587, 2593, 2613, 2619, 2628, 2634, 2645,
- 2651, 2660, 2666, 2691, 2697, 2706, 2712, 2723,
- 2729, 2738, 2744, 2764, 2770, 2779, 2785, 2796,
- 2802, 2811, 2817, 2840, 2846, 2855, 2861, 2872,
- 2878, 2887, 2893, 2913, 2919, 2928, 2934, 2945,
- 2951, 2960, 2966, 2991, 2997, 3006, 3012, 3023,
- 3029, 3038, 3044, 3064, 3070, 3079, 3085, 3096,
- 3102, 3111, 3117, 2981, 2987, 2996, 3002, 3013,
- 3019, 3028, 3034, 3054, 3060, 3069, 3075, 3086,
- 3092, 3101, 3107, 3132, 3138, 3147, 3153, 3164,
- 3170, 3179, 3185, 3205, 3211, 3220, 3226, 3237,
- 3243, 3252, 3258, 3281, 3287, 3296, 3302, 3313,
- 3319, 3328, 3334, 3354, 3360, 3369, 3375, 3386,
- 3392, 3401, 3407, 3432, 3438, 3447, 3453, 3464,
- 3470, 3479, 3485, 3505, 3511, 3520, 3526, 3537,
- 3543, 3552, 3558, 2816, 2822, 2831, 2837, 2848,
- 2854, 2863, 2869, 2889, 2895, 2904, 2910, 2921,
- 2927, 2936, 2942, 2967, 2973, 2982, 2988, 2999,
- 3005, 3014, 3020, 3040, 3046, 3055, 3061, 3072,
- 3078, 3087, 3093, 3116, 3122, 3131, 3137, 3148,
- 3154, 3163, 3169, 3189, 3195, 3204, 3210, 3221,
- 3227, 3236, 3242, 3267, 3273, 3282, 3288, 3299,
- 3305, 3314, 3320, 3340, 3346, 3355, 3361, 3372,
- 3378, 3387, 3393, 3257, 3263, 3272, 3278, 3289,
- 3295, 3304, 3310, 3330, 3336, 3345, 3351, 3362,
- 3368, 3377, 3383, 3408, 3414, 3423, 3429, 3440,
- 3446, 3455, 3461, 3481, 3487, 3496, 3502, 3513,
- 3519, 3528, 3534, 3557, 3563, 3572, 3578, 3589,
- 3595, 3604, 3610, 3630, 3636, 3645, 3651, 3662,
- 3668, 3677, 3683, 3708, 3714, 3723, 3729, 3740,
- 3746, 3755, 3761, 3781, 3787, 3796, 3802, 3813,
- 3819, 3828, 3834, 3629, 3635, 3644, 3650, 3661,
- 3667, 3676, 3682, 3702, 3708, 3717, 3723, 3734,
- 3740, 3749, 3755, 3780, 3786, 3795, 3801, 3812,
- 3818, 3827, 3833, 3853, 3859, 3868, 3874, 3885,
- 3891, 3900, 3906, 3929, 3935, 3944, 3950, 3961,
- 3967, 3976, 3982, 4002, 4008, 4017, 4023, 4034,
- 4040, 4049, 4055, 4080, 4086, 4095, 4101, 4112,
- 4118, 4127, 4133, 4153, 4159, 4168, 4174, 4185,
- 4191, 4200, 4206, 4070, 4076, 4085, 4091, 4102,
- 4108, 4117, 4123, 4143, 4149, 4158, 4164, 4175,
- 4181, 4190, 4196, 4221, 4227, 4236, 4242, 4253,
- 4259, 4268, 4274, 4294, 4300, 4309, 4315, 4326,
- 4332, 4341, 4347, 4370, 4376, 4385, 4391, 4402,
- 4408, 4417, 4423, 4443, 4449, 4458, 4464, 4475,
- 4481, 4490, 4496, 4521, 4527, 4536, 4542, 4553,
- 4559, 4568, 4574, 4594, 4600, 4609, 4615, 4626,
- 4632, 4641, 4647, 3515, 3521, 3530, 3536, 3547,
- 3553, 3562, 3568, 3588, 3594, 3603, 3609, 3620,
- 3626, 3635, 3641, 3666, 3672, 3681, 3687, 3698,
- 3704, 3713, 3719, 3739, 3745, 3754, 3760, 3771,
- 3777, 3786, 3792, 3815, 3821, 3830, 3836, 3847,
- 3853, 3862, 3868, 3888, 3894, 3903, 3909, 3920,
- 3926, 3935, 3941, 3966, 3972, 3981, 3987, 3998,
- 4004, 4013, 4019, 4039, 4045, 4054, 4060, 4071,
- 4077, 4086, 4092, 3956, 3962, 3971, 3977, 3988,
- 3994, 4003, 4009, 4029, 4035, 4044, 4050, 4061,
- 4067, 4076, 4082, 4107, 4113, 4122, 4128, 4139,
- 4145, 4154, 4160, 4180, 4186, 4195, 4201, 4212,
- 4218, 4227, 4233, 4256, 4262, 4271, 4277, 4288,
- 4294, 4303, 4309, 4329, 4335, 4344, 4350, 4361,
- 4367, 4376, 4382, 4407, 4413, 4422, 4428, 4439,
- 4445, 4454, 4460, 4480, 4486, 4495, 4501, 4512,
- 4518, 4527, 4533, 4328, 4334, 4343, 4349, 4360,
- 4366, 4375, 4381, 4401, 4407, 4416, 4422, 4433,
- 4439, 4448, 4454, 4479, 4485, 4494, 4500, 4511,
- 4517, 4526, 4532, 4552, 4558, 4567, 4573, 4584,
- 4590, 4599, 4605, 4628, 4634, 4643, 4649, 4660,
- 4666, 4675, 4681, 4701, 4707, 4716, 4722, 4733,
- 4739, 4748, 4754, 4779, 4785, 4794, 4800, 4811,
- 4817, 4826, 4832, 4852, 4858, 4867, 4873, 4884,
- 4890, 4899, 4905, 4769, 4775, 4784, 4790, 4801,
- 4807, 4816, 4822, 4842, 4848, 4857, 4863, 4874,
- 4880, 4889, 4895, 4920, 4926, 4935, 4941, 4952,
- 4958, 4967, 4973, 4993, 4999, 5008, 5014, 5025,
- 5031, 5040, 5046, 5069, 5075, 5084, 5090, 5101,
- 5107, 5116, 5122, 5142, 5148, 5157, 5163, 5174,
- 5180, 5189, 5195, 5220, 5226, 5235, 5241, 5252,
- 5258, 5267, 5273, 5293, 5299, 5308, 5314, 5325,
- 5331, 5340, 5346, 4604, 4610, 4619, 4625, 4636,
- 4642, 4651, 4657, 4677, 4683, 4692, 4698, 4709,
- 4715, 4724, 4730, 4755, 4761, 4770, 4776, 4787,
- 4793, 4802, 4808, 4828, 4834, 4843, 4849, 4860,
- 4866, 4875, 4881, 4904, 4910, 4919, 4925, 4936,
- 4942, 4951, 4957, 4977, 4983, 4992, 4998, 5009,
- 5015, 5024, 5030, 5055, 5061, 5070, 5076, 5087,
- 5093, 5102, 5108, 5128, 5134, 5143, 5149, 5160,
- 5166, 5175, 5181, 5045, 5051, 5060, 5066, 5077,
- 5083, 5092, 5098, 5118, 5124, 5133, 5139, 5150,
- 5156, 5165, 5171, 5196, 5202, 5211, 5217, 5228,
- 5234, 5243, 5249, 5269, 5275, 5284, 5290, 5301,
- 5307, 5316, 5322, 5345, 5351, 5360, 5366, 5377,
- 5383, 5392, 5398, 5418, 5424, 5433, 5439, 5450,
- 5456, 5465, 5471, 5496, 5502, 5511, 5517, 5528,
- 5534, 5543, 5549, 5569, 5575, 5584, 5590, 5601,
- 5607, 5616, 5622, 5417, 5423, 5432, 5438, 5449,
- 5455, 5464, 5470, 5490, 5496, 5505, 5511, 5522,
- 5528, 5537, 5543, 5568, 5574, 5583, 5589, 5600,
- 5606, 5615, 5621, 5641, 5647, 5656, 5662, 5673,
- 5679, 5688, 5694, 5717, 5723, 5732, 5738, 5749,
- 5755, 5764, 5770, 5790, 5796, 5805, 5811, 5822,
- 5828, 5837, 5843, 5868, 5874, 5883, 5889, 5900,
- 5906, 5915, 5921, 5941, 5947, 5956, 5962, 5973,
- 5979, 5988, 5994, 5858, 5864, 5873, 5879, 5890,
- 5896, 5905, 5911, 5931, 5937, 5946, 5952, 5963,
- 5969, 5978, 5984, 6009, 6015, 6024, 6030, 6041,
- 6047, 6056, 6062, 6082, 6088, 6097, 6103, 6114,
- 6120, 6129, 6135, 6158, 6164, 6173, 6179, 6190,
- 6196, 6205, 6211, 6231, 6237, 6246, 6252, 6263,
- 6269, 6278, 6284, 6309, 6315, 6324, 6330, 6341,
- 6347, 6356, 6362, 6382, 6388, 6397, 6403, 6414,
- 6420, 6429, 6435, 3515, 3521, 3530, 3536, 3547,
- 3553, 3562, 3568, 3588, 3594, 3603, 3609, 3620,
- 3626, 3635, 3641, 3666, 3672, 3681, 3687, 3698,
- 3704, 3713, 3719, 3739, 3745, 3754, 3760, 3771,
- 3777, 3786, 3792, 3815, 3821, 3830, 3836, 3847,
- 3853, 3862, 3868, 3888, 3894, 3903, 3909, 3920,
- 3926, 3935, 3941, 3966, 3972, 3981, 3987, 3998,
- 4004, 4013, 4019, 4039, 4045, 4054, 4060, 4071,
- 4077, 4086, 4092, 3956, 3962, 3971, 3977, 3988,
- 3994, 4003, 4009, 4029, 4035, 4044, 4050, 4061,
- 4067, 4076, 4082, 4107, 4113, 4122, 4128, 4139,
- 4145, 4154, 4160, 4180, 4186, 4195, 4201, 4212,
- 4218, 4227, 4233, 4256, 4262, 4271, 4277, 4288,
- 4294, 4303, 4309, 4329, 4335, 4344, 4350, 4361,
- 4367, 4376, 4382, 4407, 4413, 4422, 4428, 4439,
- 4445, 4454, 4460, 4480, 4486, 4495, 4501, 4512,
- 4518, 4527, 4533, 4328, 4334, 4343, 4349, 4360,
- 4366, 4375, 4381, 4401, 4407, 4416, 4422, 4433,
- 4439, 4448, 4454, 4479, 4485, 4494, 4500, 4511,
- 4517, 4526, 4532, 4552, 4558, 4567, 4573, 4584,
- 4590, 4599, 4605, 4628, 4634, 4643, 4649, 4660,
- 4666, 4675, 4681, 4701, 4707, 4716, 4722, 4733,
- 4739, 4748, 4754, 4779, 4785, 4794, 4800, 4811,
- 4817, 4826, 4832, 4852, 4858, 4867, 4873, 4884,
- 4890, 4899, 4905, 4769, 4775, 4784, 4790, 4801,
- 4807, 4816, 4822, 4842, 4848, 4857, 4863, 4874,
- 4880, 4889, 4895, 4920, 4926, 4935, 4941, 4952,
- 4958, 4967, 4973, 4993, 4999, 5008, 5014, 5025,
- 5031, 5040, 5046, 5069, 5075, 5084, 5090, 5101,
- 5107, 5116, 5122, 5142, 5148, 5157, 5163, 5174,
- 5180, 5189, 5195, 5220, 5226, 5235, 5241, 5252,
- 5258, 5267, 5273, 5293, 5299, 5308, 5314, 5325,
- 5331, 5340, 5346, 4604, 4610, 4619, 4625, 4636,
- 4642, 4651, 4657, 4677, 4683, 4692, 4698, 4709,
- 4715, 4724, 4730, 4755, 4761, 4770, 4776, 4787,
- 4793, 4802, 4808, 4828, 4834, 4843, 4849, 4860,
- 4866, 4875, 4881, 4904, 4910, 4919, 4925, 4936,
- 4942, 4951, 4957, 4977, 4983, 4992, 4998, 5009,
- 5015, 5024, 5030, 5055, 5061, 5070, 5076, 5087,
- 5093, 5102, 5108, 5128, 5134, 5143, 5149, 5160,
- 5166, 5175, 5181, 5045, 5051, 5060, 5066, 5077,
- 5083, 5092, 5098, 5118, 5124, 5133, 5139, 5150,
- 5156, 5165, 5171, 5196, 5202, 5211, 5217, 5228,
- 5234, 5243, 5249, 5269, 5275, 5284, 5290, 5301,
- 5307, 5316, 5322, 5345, 5351, 5360, 5366, 5377,
- 5383, 5392, 5398, 5418, 5424, 5433, 5439, 5450,
- 5456, 5465, 5471, 5496, 5502, 5511, 5517, 5528,
- 5534, 5543, 5549, 5569, 5575, 5584, 5590, 5601,
- 5607, 5616, 5622, 5417, 5423, 5432, 5438, 5449,
- 5455, 5464, 5470, 5490, 5496, 5505, 5511, 5522,
- 5528, 5537, 5543, 5568, 5574, 5583, 5589, 5600,
- 5606, 5615, 5621, 5641, 5647, 5656, 5662, 5673,
- 5679, 5688, 5694, 5717, 5723, 5732, 5738, 5749,
- 5755, 5764, 5770, 5790, 5796, 5805, 5811, 5822,
- 5828, 5837, 5843, 5868, 5874, 5883, 5889, 5900,
- 5906, 5915, 5921, 5941, 5947, 5956, 5962, 5973,
- 5979, 5988, 5994, 5858, 5864, 5873, 5879, 5890,
- 5896, 5905, 5911, 5931, 5937, 5946, 5952, 5963,
- 5969, 5978, 5984, 6009, 6015, 6024, 6030, 6041,
- 6047, 6056, 6062, 6082, 6088, 6097, 6103, 6114,
- 6120, 6129, 6135, 6158, 6164, 6173, 6179, 6190,
- 6196, 6205, 6211, 6231, 6237, 6246, 6252, 6263,
- 6269, 6278, 6284, 6309, 6315, 6324, 6330, 6341,
- 6347, 6356, 6362, 6382, 6388, 6397, 6403, 6414,
- 6420, 6429, 6435, 5303, 5309, 5318, 5324, 5335,
- 5341, 5350, 5356, 5376, 5382, 5391, 5397, 5408,
- 5414, 5423, 5429, 5454, 5460, 5469, 5475, 5486,
- 5492, 5501, 5507, 5527, 5533, 5542, 5548, 5559,
- 5565, 5574, 5580, 5603, 5609, 5618, 5624, 5635,
- 5641, 5650, 5656, 5676, 5682, 5691, 5697, 5708,
- 5714, 5723, 5729, 5754, 5760, 5769, 5775, 5786,
- 5792, 5801, 5807, 5827, 5833, 5842, 5848, 5859,
- 5865, 5874, 5880, 5744, 5750, 5759, 5765, 5776,
- 5782, 5791, 5797, 5817, 5823, 5832, 5838, 5849,
- 5855, 5864, 5870, 5895, 5901, 5910, 5916, 5927,
- 5933, 5942, 5948, 5968, 5974, 5983, 5989, 6000,
- 6006, 6015, 6021, 6044, 6050, 6059, 6065, 6076,
- 6082, 6091, 6097, 6117, 6123, 6132, 6138, 6149,
- 6155, 6164, 6170, 6195, 6201, 6210, 6216, 6227,
- 6233, 6242, 6248, 6268, 6274, 6283, 6289, 6300,
- 6306, 6315, 6321, 6116, 6122, 6131, 6137, 6148,
- 6154, 6163, 6169, 6189, 6195, 6204, 6210, 6221,
- 6227, 6236, 6242, 6267, 6273, 6282, 6288, 6299,
- 6305, 6314, 6320, 6340, 6346, 6355, 6361, 6372,
- 6378, 6387, 6393, 6416, 6422, 6431, 6437, 6448,
- 6454, 6463, 6469, 6489, 6495, 6504, 6510, 6521,
- 6527, 6536, 6542, 6567, 6573, 6582, 6588, 6599,
- 6605, 6614, 6620, 6640, 6646, 6655, 6661, 6672,
- 6678, 6687, 6693, 6557, 6563, 6572, 6578, 6589,
- 6595, 6604, 6610, 6630, 6636, 6645, 6651, 6662,
- 6668, 6677, 6683, 6708, 6714, 6723, 6729, 6740,
- 6746, 6755, 6761, 6781, 6787, 6796, 6802, 6813,
- 6819, 6828, 6834, 6857, 6863, 6872, 6878, 6889,
- 6895, 6904, 6910, 6930, 6936, 6945, 6951, 6962,
- 6968, 6977, 6983, 7008, 7014, 7023, 7029, 7040,
- 7046, 7055, 7061, 7081, 7087, 7096, 7102, 7113,
- 7119, 7128, 7134, 6392, 6398, 6407, 6413, 6424,
- 6430, 6439, 6445, 6465, 6471, 6480, 6486, 6497,
- 6503, 6512, 6518, 6543, 6549, 6558, 6564, 6575,
- 6581, 6590, 6596, 6616, 6622, 6631, 6637, 6648,
- 6654, 6663, 6669, 6692, 6698, 6707, 6713, 6724,
- 6730, 6739, 6745, 6765, 6771, 6780, 6786, 6797,
- 6803, 6812, 6818, 6843, 6849, 6858, 6864, 6875,
- 6881, 6890, 6896, 6916, 6922, 6931, 6937, 6948,
- 6954, 6963, 6969, 6833, 6839, 6848, 6854, 6865,
- 6871, 6880, 6886, 6906, 6912, 6921, 6927, 6938,
- 6944, 6953, 6959, 6984, 6990, 6999, 7005, 7016,
- 7022, 7031, 7037, 7057, 7063, 7072, 7078, 7089,
- 7095, 7104, 7110, 7133, 7139, 7148, 7154, 7165,
- 7171, 7180, 7186, 7206, 7212, 7221, 7227, 7238,
- 7244, 7253, 7259, 7284, 7290, 7299, 7305, 7316,
- 7322, 7331, 7337, 7357, 7363, 7372, 7378, 7389,
- 7395, 7404, 7410, 7205, 7211, 7220, 7226, 7237,
- 7243, 7252, 7258, 7278, 7284, 7293, 7299, 7310,
- 7316, 7325, 7331, 7356, 7362, 7371, 7377, 7388,
- 7394, 7403, 7409, 7429, 7435, 7444, 7450, 7461,
- 7467, 7476, 7482, 7505, 7511, 7520, 7526, 7537,
- 7543, 7552, 7558, 7578, 7584, 7593, 7599, 7610,
- 7616, 7625, 7631, 7656, 7662, 7671, 7677, 7688,
- 7694, 7703, 7709, 7729, 7735, 7744, 7750, 7761
-};
-
-//------------------------------------------------------------------------------
-// Tables for level coding
-
-const uint8_t VP8EncBands[16 + 1] = {
- 0, 1, 2, 3, 6, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7,
- 0 // sentinel
-};
-
-//------------------------------------------------------------------------------
-// Mode costs
-
-static int GetResidualCost_C(int ctx0, const VP8Residual* const res) {
- int n = res->first;
- // should be prob[VP8EncBands[n]], but it's equivalent for n=0 or 1
- const int p0 = res->prob[n][ctx0][0];
- CostArrayPtr const costs = res->costs;
- const uint16_t* t = costs[n][ctx0];
- // bit_cost(1, p0) is already incorporated in t[] tables, but only if ctx != 0
- // (as required by the syntax). For ctx0 == 0, we need to add it here or it'll
- // be missing during the loop.
- int cost = (ctx0 == 0) ? VP8BitCost(1, p0) : 0;
-
- if (res->last < 0) {
- return VP8BitCost(0, p0);
- }
- for (; n < res->last; ++n) {
- const int v = abs(res->coeffs[n]);
- const int ctx = (v >= 2) ? 2 : v;
- cost += VP8LevelCost(t, v);
- t = costs[n + 1][ctx];
- }
- // Last coefficient is always non-zero
- {
- const int v = abs(res->coeffs[n]);
- assert(v != 0);
- cost += VP8LevelCost(t, v);
- if (n < 15) {
- const int b = VP8EncBands[n + 1];
- const int ctx = (v == 1) ? 1 : 2;
- const int last_p0 = res->prob[b][ctx][0];
- cost += VP8BitCost(0, last_p0);
- }
- }
- return cost;
-}
-
-static void SetResidualCoeffs_C(const int16_t* const coeffs,
- VP8Residual* const res) {
- int n;
- res->last = -1;
- assert(res->first == 0 || coeffs[0] == 0);
- for (n = 15; n >= 0; --n) {
- if (coeffs[n]) {
- res->last = n;
- break;
- }
- }
- res->coeffs = coeffs;
-}
-
-//------------------------------------------------------------------------------
-// init function
-
-VP8GetResidualCostFunc VP8GetResidualCost;
-VP8SetResidualCoeffsFunc VP8SetResidualCoeffs;
-
-extern void VP8EncDspCostInitMIPS32(void);
-extern void VP8EncDspCostInitMIPSdspR2(void);
-extern void VP8EncDspCostInitSSE2(void);
-extern void VP8EncDspCostInitNEON(void);
-
-WEBP_DSP_INIT_FUNC(VP8EncDspCostInit) {
- VP8GetResidualCost = GetResidualCost_C;
- VP8SetResidualCoeffs = SetResidualCoeffs_C;
-
- // If defined, use CPUInfo() to overwrite some pointers with faster versions.
- if (VP8GetCPUInfo != NULL) {
-#if defined(WEBP_USE_MIPS32)
- if (VP8GetCPUInfo(kMIPS32)) {
- VP8EncDspCostInitMIPS32();
- }
-#endif
-#if defined(WEBP_USE_MIPS_DSP_R2)
- if (VP8GetCPUInfo(kMIPSdspR2)) {
- VP8EncDspCostInitMIPSdspR2();
- }
-#endif
-#if defined(WEBP_HAVE_SSE2)
- if (VP8GetCPUInfo(kSSE2)) {
- VP8EncDspCostInitSSE2();
- }
-#endif
-#if defined(WEBP_HAVE_NEON)
- if (VP8GetCPUInfo(kNEON)) {
- VP8EncDspCostInitNEON();
- }
-#endif
- }
-}
-
-//------------------------------------------------------------------------------
diff --git a/contrib/libs/libwebp/dsp/cost_mips32.c b/contrib/libs/libwebp/dsp/cost_mips32.c
deleted file mode 100644
index 9bc40b8447..0000000000
--- a/contrib/libs/libwebp/dsp/cost_mips32.c
+++ /dev/null
@@ -1,154 +0,0 @@
-// Copyright 2014 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Author: Djordje Pesut (djordje.pesut@imgtec.com)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_MIPS32)
-
-#include "../enc/cost_enc.h"
-
-static int GetResidualCost_MIPS32(int ctx0, const VP8Residual* const res) {
- int temp0, temp1;
- int v_reg, ctx_reg;
- int n = res->first;
- // should be prob[VP8EncBands[n]], but it's equivalent for n=0 or 1
- int p0 = res->prob[n][ctx0][0];
- CostArrayPtr const costs = res->costs;
- const uint16_t* t = costs[n][ctx0];
- // bit_cost(1, p0) is already incorporated in t[] tables, but only if ctx != 0
- // (as required by the syntax). For ctx0 == 0, we need to add it here or it'll
- // be missing during the loop.
- int cost = (ctx0 == 0) ? VP8BitCost(1, p0) : 0;
- const int16_t* res_coeffs = res->coeffs;
- const int res_last = res->last;
- const int const_max_level = MAX_VARIABLE_LEVEL;
- const int const_2 = 2;
- const uint16_t** p_costs = &costs[n][0];
- const size_t inc_p_costs = NUM_CTX * sizeof(*p_costs);
-
- if (res->last < 0) {
- return VP8BitCost(0, p0);
- }
-
- __asm__ volatile (
- ".set push \n\t"
- ".set noreorder \n\t"
- "subu %[temp1], %[res_last], %[n] \n\t"
- "sll %[temp0], %[n], 1 \n\t"
- "blez %[temp1], 2f \n\t"
- " addu %[res_coeffs], %[res_coeffs], %[temp0] \n\t"
- "1: \n\t"
- "lh %[v_reg], 0(%[res_coeffs]) \n\t"
- "addiu %[n], %[n], 1 \n\t"
- "negu %[temp0], %[v_reg] \n\t"
- "slti %[temp1], %[v_reg], 0 \n\t"
- "movn %[v_reg], %[temp0], %[temp1] \n\t"
- "sltiu %[temp0], %[v_reg], 2 \n\t"
- "move %[ctx_reg], %[v_reg] \n\t"
- "movz %[ctx_reg], %[const_2], %[temp0] \n\t"
- "sll %[temp1], %[v_reg], 1 \n\t"
- "addu %[temp1], %[temp1], %[VP8LevelFixedCosts] \n\t"
- "lhu %[temp1], 0(%[temp1]) \n\t"
- "slt %[temp0], %[v_reg], %[const_max_level] \n\t"
- "movz %[v_reg], %[const_max_level], %[temp0] \n\t"
- "addu %[cost], %[cost], %[temp1] \n\t"
- "sll %[v_reg], %[v_reg], 1 \n\t"
- "sll %[ctx_reg], %[ctx_reg], 2 \n\t"
- "addu %[v_reg], %[v_reg], %[t] \n\t"
- "lhu %[temp0], 0(%[v_reg]) \n\t"
- "addu %[p_costs], %[p_costs], %[inc_p_costs] \n\t"
- "addu %[t], %[p_costs], %[ctx_reg] \n\t"
- "addu %[cost], %[cost], %[temp0] \n\t"
- "addiu %[res_coeffs], %[res_coeffs], 2 \n\t"
- "bne %[n], %[res_last], 1b \n\t"
- " lw %[t], 0(%[t]) \n\t"
- "2: \n\t"
- ".set pop \n\t"
- : [cost]"+&r"(cost), [t]"+&r"(t), [n]"+&r"(n), [v_reg]"=&r"(v_reg),
- [ctx_reg]"=&r"(ctx_reg), [p_costs]"+&r"(p_costs), [temp0]"=&r"(temp0),
- [temp1]"=&r"(temp1), [res_coeffs]"+&r"(res_coeffs)
- : [const_2]"r"(const_2), [const_max_level]"r"(const_max_level),
- [VP8LevelFixedCosts]"r"(VP8LevelFixedCosts), [res_last]"r"(res_last),
- [inc_p_costs]"r"(inc_p_costs)
- : "memory"
- );
-
- // Last coefficient is always non-zero
- {
- const int v = abs(res->coeffs[n]);
- assert(v != 0);
- cost += VP8LevelCost(t, v);
- if (n < 15) {
- const int b = VP8EncBands[n + 1];
- const int ctx = (v == 1) ? 1 : 2;
- const int last_p0 = res->prob[b][ctx][0];
- cost += VP8BitCost(0, last_p0);
- }
- }
- return cost;
-}
-
-static void SetResidualCoeffs_MIPS32(const int16_t* const coeffs,
- VP8Residual* const res) {
- const int16_t* p_coeffs = (int16_t*)coeffs;
- int temp0, temp1, temp2, n, n1;
- assert(res->first == 0 || coeffs[0] == 0);
-
- __asm__ volatile (
- ".set push \n\t"
- ".set noreorder \n\t"
- "addiu %[p_coeffs], %[p_coeffs], 28 \n\t"
- "li %[n], 15 \n\t"
- "li %[temp2], -1 \n\t"
- "0: \n\t"
- "ulw %[temp0], 0(%[p_coeffs]) \n\t"
- "beqz %[temp0], 1f \n\t"
-#if defined(WORDS_BIGENDIAN)
- " sll %[temp1], %[temp0], 16 \n\t"
-#else
- " srl %[temp1], %[temp0], 16 \n\t"
-#endif
- "addiu %[n1], %[n], -1 \n\t"
- "movz %[temp0], %[n1], %[temp1] \n\t"
- "movn %[temp0], %[n], %[temp1] \n\t"
- "j 2f \n\t"
- " addiu %[temp2], %[temp0], 0 \n\t"
- "1: \n\t"
- "addiu %[n], %[n], -2 \n\t"
- "bgtz %[n], 0b \n\t"
- " addiu %[p_coeffs], %[p_coeffs], -4 \n\t"
- "2: \n\t"
- ".set pop \n\t"
- : [p_coeffs]"+&r"(p_coeffs), [temp0]"=&r"(temp0),
- [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [n]"=&r"(n), [n1]"=&r"(n1)
- :
- : "memory"
- );
- res->last = temp2;
- res->coeffs = coeffs;
-}
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void VP8EncDspCostInitMIPS32(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void VP8EncDspCostInitMIPS32(void) {
- VP8GetResidualCost = GetResidualCost_MIPS32;
- VP8SetResidualCoeffs = SetResidualCoeffs_MIPS32;
-}
-
-#else // !WEBP_USE_MIPS32
-
-WEBP_DSP_INIT_STUB(VP8EncDspCostInitMIPS32)
-
-#endif // WEBP_USE_MIPS32
diff --git a/contrib/libs/libwebp/dsp/cost_mips_dsp_r2.c b/contrib/libs/libwebp/dsp/cost_mips_dsp_r2.c
deleted file mode 100644
index 6c38f94655..0000000000
--- a/contrib/libs/libwebp/dsp/cost_mips_dsp_r2.c
+++ /dev/null
@@ -1,107 +0,0 @@
-// Copyright 2014 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Author: Djordje Pesut (djordje.pesut@imgtec.com)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_MIPS_DSP_R2)
-
-#include "../enc/cost_enc.h"
-
-static int GetResidualCost_MIPSdspR2(int ctx0, const VP8Residual* const res) {
- int temp0, temp1;
- int v_reg, ctx_reg;
- int n = res->first;
- // should be prob[VP8EncBands[n]], but it's equivalent for n=0 or 1
- int p0 = res->prob[n][ctx0][0];
- CostArrayPtr const costs = res->costs;
- const uint16_t* t = costs[n][ctx0];
- // bit_cost(1, p0) is already incorporated in t[] tables, but only if ctx != 0
- // (as required by the syntax). For ctx0 == 0, we need to add it here or it'll
- // be missing during the loop.
- int cost = (ctx0 == 0) ? VP8BitCost(1, p0) : 0;
- const int16_t* res_coeffs = res->coeffs;
- const int res_last = res->last;
- const int const_max_level = MAX_VARIABLE_LEVEL;
- const int const_2 = 2;
- const uint16_t** p_costs = &costs[n][0];
- const size_t inc_p_costs = NUM_CTX * sizeof(*p_costs);
-
- if (res->last < 0) {
- return VP8BitCost(0, p0);
- }
-
- __asm__ volatile (
- ".set push \n\t"
- ".set noreorder \n\t"
- "subu %[temp1], %[res_last], %[n] \n\t"
- "blez %[temp1], 2f \n\t"
- " nop \n\t"
- "1: \n\t"
- "sll %[temp0], %[n], 1 \n\t"
- "lhx %[v_reg], %[temp0](%[res_coeffs]) \n\t"
- "addiu %[n], %[n], 1 \n\t"
- "absq_s.w %[v_reg], %[v_reg] \n\t"
- "sltiu %[temp0], %[v_reg], 2 \n\t"
- "move %[ctx_reg], %[v_reg] \n\t"
- "movz %[ctx_reg], %[const_2], %[temp0] \n\t"
- "sll %[temp1], %[v_reg], 1 \n\t"
- "lhx %[temp1], %[temp1](%[VP8LevelFixedCosts]) \n\t"
- "slt %[temp0], %[v_reg], %[const_max_level] \n\t"
- "movz %[v_reg], %[const_max_level], %[temp0] \n\t"
- "addu %[cost], %[cost], %[temp1] \n\t"
- "sll %[v_reg], %[v_reg], 1 \n\t"
- "sll %[ctx_reg], %[ctx_reg], 2 \n\t"
- "lhx %[temp0], %[v_reg](%[t]) \n\t"
- "addu %[p_costs], %[p_costs], %[inc_p_costs] \n\t"
- "addu %[t], %[p_costs], %[ctx_reg] \n\t"
- "addu %[cost], %[cost], %[temp0] \n\t"
- "bne %[n], %[res_last], 1b \n\t"
- " lw %[t], 0(%[t]) \n\t"
- "2: \n\t"
- ".set pop \n\t"
- : [cost]"+&r"(cost), [t]"+&r"(t), [n]"+&r"(n), [v_reg]"=&r"(v_reg),
- [ctx_reg]"=&r"(ctx_reg), [p_costs]"+&r"(p_costs), [temp0]"=&r"(temp0),
- [temp1]"=&r"(temp1)
- : [const_2]"r"(const_2), [const_max_level]"r"(const_max_level),
- [VP8LevelFixedCosts]"r"(VP8LevelFixedCosts), [res_last]"r"(res_last),
- [res_coeffs]"r"(res_coeffs), [inc_p_costs]"r"(inc_p_costs)
- : "memory"
- );
-
- // Last coefficient is always non-zero
- {
- const int v = abs(res->coeffs[n]);
- assert(v != 0);
- cost += VP8LevelCost(t, v);
- if (n < 15) {
- const int b = VP8EncBands[n + 1];
- const int ctx = (v == 1) ? 1 : 2;
- const int last_p0 = res->prob[b][ctx][0];
- cost += VP8BitCost(0, last_p0);
- }
- }
- return cost;
-}
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void VP8EncDspCostInitMIPSdspR2(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void VP8EncDspCostInitMIPSdspR2(void) {
- VP8GetResidualCost = GetResidualCost_MIPSdspR2;
-}
-
-#else // !WEBP_USE_MIPS_DSP_R2
-
-WEBP_DSP_INIT_STUB(VP8EncDspCostInitMIPSdspR2)
-
-#endif // WEBP_USE_MIPS_DSP_R2
diff --git a/contrib/libs/libwebp/dsp/cost_neon.c b/contrib/libs/libwebp/dsp/cost_neon.c
deleted file mode 100644
index 2a99a080aa..0000000000
--- a/contrib/libs/libwebp/dsp/cost_neon.c
+++ /dev/null
@@ -1,122 +0,0 @@
-// Copyright 2018 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// ARM NEON version of cost functions
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_NEON)
-
-#include "./neon.h"
-#include "../enc/cost_enc.h"
-
-static const uint8_t position[16] = { 1, 2, 3, 4, 5, 6, 7, 8,
- 9, 10, 11, 12, 13, 14, 15, 16 };
-
-static void SetResidualCoeffs_NEON(const int16_t* const coeffs,
- VP8Residual* const res) {
- const int16x8_t minus_one = vdupq_n_s16(-1);
- const int16x8_t coeffs_0 = vld1q_s16(coeffs);
- const int16x8_t coeffs_1 = vld1q_s16(coeffs + 8);
- const uint16x8_t eob_0 = vtstq_s16(coeffs_0, minus_one);
- const uint16x8_t eob_1 = vtstq_s16(coeffs_1, minus_one);
- const uint8x16_t eob = vcombine_u8(vqmovn_u16(eob_0), vqmovn_u16(eob_1));
- const uint8x16_t masked = vandq_u8(eob, vld1q_u8(position));
-
-#ifdef __aarch64__
- res->last = vmaxvq_u8(masked) - 1;
-#else
- const uint8x8_t eob_8x8 = vmax_u8(vget_low_u8(masked), vget_high_u8(masked));
- const uint16x8_t eob_16x8 = vmovl_u8(eob_8x8);
- const uint16x4_t eob_16x4 =
- vmax_u16(vget_low_u16(eob_16x8), vget_high_u16(eob_16x8));
- const uint32x4_t eob_32x4 = vmovl_u16(eob_16x4);
- uint32x2_t eob_32x2 =
- vmax_u32(vget_low_u32(eob_32x4), vget_high_u32(eob_32x4));
- eob_32x2 = vpmax_u32(eob_32x2, eob_32x2);
-
- vst1_lane_s32(&res->last, vreinterpret_s32_u32(eob_32x2), 0);
- --res->last;
-#endif // __aarch64__
-
- res->coeffs = coeffs;
-}
-
-static int GetResidualCost_NEON(int ctx0, const VP8Residual* const res) {
- uint8_t levels[16], ctxs[16];
- uint16_t abs_levels[16];
- int n = res->first;
- // should be prob[VP8EncBands[n]], but it's equivalent for n=0 or 1
- const int p0 = res->prob[n][ctx0][0];
- CostArrayPtr const costs = res->costs;
- const uint16_t* t = costs[n][ctx0];
- // bit_cost(1, p0) is already incorporated in t[] tables, but only if ctx != 0
- // (as required by the syntax). For ctx0 == 0, we need to add it here or it'll
- // be missing during the loop.
- int cost = (ctx0 == 0) ? VP8BitCost(1, p0) : 0;
-
- if (res->last < 0) {
- return VP8BitCost(0, p0);
- }
-
- { // precompute clamped levels and contexts, packed to 8b.
- const uint8x16_t kCst2 = vdupq_n_u8(2);
- const uint8x16_t kCst67 = vdupq_n_u8(MAX_VARIABLE_LEVEL);
- const int16x8_t c0 = vld1q_s16(res->coeffs);
- const int16x8_t c1 = vld1q_s16(res->coeffs + 8);
- const uint16x8_t E0 = vreinterpretq_u16_s16(vabsq_s16(c0));
- const uint16x8_t E1 = vreinterpretq_u16_s16(vabsq_s16(c1));
- const uint8x16_t F = vcombine_u8(vqmovn_u16(E0), vqmovn_u16(E1));
- const uint8x16_t G = vminq_u8(F, kCst2); // context = 0,1,2
- const uint8x16_t H = vminq_u8(F, kCst67); // clamp_level in [0..67]
-
- vst1q_u8(ctxs, G);
- vst1q_u8(levels, H);
-
- vst1q_u16(abs_levels, E0);
- vst1q_u16(abs_levels + 8, E1);
- }
- for (; n < res->last; ++n) {
- const int ctx = ctxs[n];
- const int level = levels[n];
- const int flevel = abs_levels[n]; // full level
- cost += VP8LevelFixedCosts[flevel] + t[level]; // simplified VP8LevelCost()
- t = costs[n + 1][ctx];
- }
- // Last coefficient is always non-zero
- {
- const int level = levels[n];
- const int flevel = abs_levels[n];
- assert(flevel != 0);
- cost += VP8LevelFixedCosts[flevel] + t[level];
- if (n < 15) {
- const int b = VP8EncBands[n + 1];
- const int ctx = ctxs[n];
- const int last_p0 = res->prob[b][ctx][0];
- cost += VP8BitCost(0, last_p0);
- }
- }
- return cost;
-}
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void VP8EncDspCostInitNEON(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void VP8EncDspCostInitNEON(void) {
- VP8SetResidualCoeffs = SetResidualCoeffs_NEON;
- VP8GetResidualCost = GetResidualCost_NEON;
-}
-
-#else // !WEBP_USE_NEON
-
-WEBP_DSP_INIT_STUB(VP8EncDspCostInitNEON)
-
-#endif // WEBP_USE_NEON
diff --git a/contrib/libs/libwebp/dsp/cost_sse2.c b/contrib/libs/libwebp/dsp/cost_sse2.c
deleted file mode 100644
index 83683732af..0000000000
--- a/contrib/libs/libwebp/dsp/cost_sse2.c
+++ /dev/null
@@ -1,119 +0,0 @@
-// Copyright 2015 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// SSE2 version of cost functions
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_SSE2)
-#include <emmintrin.h>
-
-#include "../enc/cost_enc.h"
-#include "../enc/vp8i_enc.h"
-#include "../utils/utils.h"
-
-//------------------------------------------------------------------------------
-
-static void SetResidualCoeffs_SSE2(const int16_t* const coeffs,
- VP8Residual* const res) {
- const __m128i c0 = _mm_loadu_si128((const __m128i*)(coeffs + 0));
- const __m128i c1 = _mm_loadu_si128((const __m128i*)(coeffs + 8));
- // Use SSE2 to compare 16 values with a single instruction.
- const __m128i zero = _mm_setzero_si128();
- const __m128i m0 = _mm_packs_epi16(c0, c1);
- const __m128i m1 = _mm_cmpeq_epi8(m0, zero);
- // Get the comparison results as a bitmask into 16bits. Negate the mask to get
- // the position of entries that are not equal to zero. We don't need to mask
- // out least significant bits according to res->first, since coeffs[0] is 0
- // if res->first > 0.
- const uint32_t mask = 0x0000ffffu ^ (uint32_t)_mm_movemask_epi8(m1);
- // The position of the most significant non-zero bit indicates the position of
- // the last non-zero value.
- assert(res->first == 0 || coeffs[0] == 0);
- res->last = mask ? BitsLog2Floor(mask) : -1;
- res->coeffs = coeffs;
-}
-
-static int GetResidualCost_SSE2(int ctx0, const VP8Residual* const res) {
- uint8_t levels[16], ctxs[16];
- uint16_t abs_levels[16];
- int n = res->first;
- // should be prob[VP8EncBands[n]], but it's equivalent for n=0 or 1
- const int p0 = res->prob[n][ctx0][0];
- CostArrayPtr const costs = res->costs;
- const uint16_t* t = costs[n][ctx0];
- // bit_cost(1, p0) is already incorporated in t[] tables, but only if ctx != 0
- // (as required by the syntax). For ctx0 == 0, we need to add it here or it'll
- // be missing during the loop.
- int cost = (ctx0 == 0) ? VP8BitCost(1, p0) : 0;
-
- if (res->last < 0) {
- return VP8BitCost(0, p0);
- }
-
- { // precompute clamped levels and contexts, packed to 8b.
- const __m128i zero = _mm_setzero_si128();
- const __m128i kCst2 = _mm_set1_epi8(2);
- const __m128i kCst67 = _mm_set1_epi8(MAX_VARIABLE_LEVEL);
- const __m128i c0 = _mm_loadu_si128((const __m128i*)&res->coeffs[0]);
- const __m128i c1 = _mm_loadu_si128((const __m128i*)&res->coeffs[8]);
- const __m128i D0 = _mm_sub_epi16(zero, c0);
- const __m128i D1 = _mm_sub_epi16(zero, c1);
- const __m128i E0 = _mm_max_epi16(c0, D0); // abs(v), 16b
- const __m128i E1 = _mm_max_epi16(c1, D1);
- const __m128i F = _mm_packs_epi16(E0, E1);
- const __m128i G = _mm_min_epu8(F, kCst2); // context = 0,1,2
- const __m128i H = _mm_min_epu8(F, kCst67); // clamp_level in [0..67]
-
- _mm_storeu_si128((__m128i*)&ctxs[0], G);
- _mm_storeu_si128((__m128i*)&levels[0], H);
-
- _mm_storeu_si128((__m128i*)&abs_levels[0], E0);
- _mm_storeu_si128((__m128i*)&abs_levels[8], E1);
- }
- for (; n < res->last; ++n) {
- const int ctx = ctxs[n];
- const int level = levels[n];
- const int flevel = abs_levels[n]; // full level
- cost += VP8LevelFixedCosts[flevel] + t[level]; // simplified VP8LevelCost()
- t = costs[n + 1][ctx];
- }
- // Last coefficient is always non-zero
- {
- const int level = levels[n];
- const int flevel = abs_levels[n];
- assert(flevel != 0);
- cost += VP8LevelFixedCosts[flevel] + t[level];
- if (n < 15) {
- const int b = VP8EncBands[n + 1];
- const int ctx = ctxs[n];
- const int last_p0 = res->prob[b][ctx][0];
- cost += VP8BitCost(0, last_p0);
- }
- }
- return cost;
-}
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void VP8EncDspCostInitSSE2(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void VP8EncDspCostInitSSE2(void) {
- VP8SetResidualCoeffs = SetResidualCoeffs_SSE2;
- VP8GetResidualCost = GetResidualCost_SSE2;
-}
-
-#else // !WEBP_USE_SSE2
-
-WEBP_DSP_INIT_STUB(VP8EncDspCostInitSSE2)
-
-#endif // WEBP_USE_SSE2
diff --git a/contrib/libs/libwebp/dsp/cpu.c b/contrib/libs/libwebp/dsp/cpu.c
deleted file mode 100644
index a41aeae6d7..0000000000
--- a/contrib/libs/libwebp/dsp/cpu.c
+++ /dev/null
@@ -1,253 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// CPU detection
-//
-// Author: Christian Duvivier (cduvivier@google.com)
-
-#include "./dsp.h"
-
-#if defined(WEBP_HAVE_NEON_RTCD)
-#include <stdio.h>
-#include <string.h>
-#endif
-
-#if defined(WEBP_ANDROID_NEON)
-#include <cpu-features.h>
-#endif
-
-//------------------------------------------------------------------------------
-// SSE2 detection.
-//
-
-// apple/darwin gcc-4.0.1 defines __PIC__, but not __pic__ with -fPIC.
-#if (defined(__pic__) || defined(__PIC__)) && defined(__i386__)
-static WEBP_INLINE void GetCPUInfo(int cpu_info[4], int info_type) {
- __asm__ volatile (
- "mov %%ebx, %%edi\n"
- "cpuid\n"
- "xchg %%edi, %%ebx\n"
- : "=a"(cpu_info[0]), "=D"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3])
- : "a"(info_type), "c"(0));
-}
-#elif defined(__x86_64__) && \
- (defined(__code_model_medium__) || defined(__code_model_large__)) && \
- defined(__PIC__)
-static WEBP_INLINE void GetCPUInfo(int cpu_info[4], int info_type) {
- __asm__ volatile (
- "xchg{q}\t{%%rbx}, %q1\n"
- "cpuid\n"
- "xchg{q}\t{%%rbx}, %q1\n"
- : "=a"(cpu_info[0]), "=&r"(cpu_info[1]), "=c"(cpu_info[2]),
- "=d"(cpu_info[3])
- : "a"(info_type), "c"(0));
-}
-#elif defined(__i386__) || defined(__x86_64__)
-static WEBP_INLINE void GetCPUInfo(int cpu_info[4], int info_type) {
- __asm__ volatile (
- "cpuid\n"
- : "=a"(cpu_info[0]), "=b"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3])
- : "a"(info_type), "c"(0));
-}
-#elif defined(_MSC_VER) && (defined(_M_X64) || defined(_M_IX86))
-
-#if defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 150030729 // >= VS2008 SP1
-#include <intrin.h>
-#define GetCPUInfo(info, type) __cpuidex(info, type, 0) // set ecx=0
-#define WEBP_HAVE_MSC_CPUID
-#elif _MSC_VER > 1310
-#include <intrin.h>
-#define GetCPUInfo __cpuid
-#define WEBP_HAVE_MSC_CPUID
-#endif
-
-#endif
-
-// NaCl has no support for xgetbv or the raw opcode.
-#if !defined(__native_client__) && (defined(__i386__) || defined(__x86_64__))
-static WEBP_INLINE uint64_t xgetbv(void) {
- const uint32_t ecx = 0;
- uint32_t eax, edx;
- // Use the raw opcode for xgetbv for compatibility with older toolchains.
- __asm__ volatile (
- ".byte 0x0f, 0x01, 0xd0\n"
- : "=a"(eax), "=d"(edx) : "c" (ecx));
- return ((uint64_t)edx << 32) | eax;
-}
-#elif (defined(_M_X64) || defined(_M_IX86)) && \
- defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 160040219 // >= VS2010 SP1
-#include <immintrin.h>
-#define xgetbv() _xgetbv(0)
-#elif defined(_MSC_VER) && defined(_M_IX86)
-static WEBP_INLINE uint64_t xgetbv(void) {
- uint32_t eax_, edx_;
- __asm {
- xor ecx, ecx // ecx = 0
- // Use the raw opcode for xgetbv for compatibility with older toolchains.
- __asm _emit 0x0f __asm _emit 0x01 __asm _emit 0xd0
- mov eax_, eax
- mov edx_, edx
- }
- return ((uint64_t)edx_ << 32) | eax_;
-}
-#else
-#define xgetbv() 0U // no AVX for older x64 or unrecognized toolchains.
-#endif
-
-#if defined(__i386__) || defined(__x86_64__) || defined(WEBP_HAVE_MSC_CPUID)
-
-// helper function for run-time detection of slow SSSE3 platforms
-static int CheckSlowModel(int info) {
- // Table listing display models with longer latencies for the bsr instruction
- // (ie 2 cycles vs 10/16 cycles) and some SSSE3 instructions like pshufb.
- // Refer to Intel 64 and IA-32 Architectures Optimization Reference Manual.
- static const uint8_t kSlowModels[] = {
- 0x37, 0x4a, 0x4d, // Silvermont Microarchitecture
- 0x1c, 0x26, 0x27 // Atom Microarchitecture
- };
- const uint32_t model = ((info & 0xf0000) >> 12) | ((info >> 4) & 0xf);
- const uint32_t family = (info >> 8) & 0xf;
- if (family == 0x06) {
- size_t i;
- for (i = 0; i < sizeof(kSlowModels) / sizeof(kSlowModels[0]); ++i) {
- if (model == kSlowModels[i]) return 1;
- }
- }
- return 0;
-}
-
-static int x86CPUInfo(CPUFeature feature) {
- int max_cpuid_value;
- int cpu_info[4];
- int is_intel = 0;
-
- // get the highest feature value cpuid supports
- GetCPUInfo(cpu_info, 0);
- max_cpuid_value = cpu_info[0];
- if (max_cpuid_value < 1) {
- return 0;
- } else {
- const int VENDOR_ID_INTEL_EBX = 0x756e6547; // uneG
- const int VENDOR_ID_INTEL_EDX = 0x49656e69; // Ieni
- const int VENDOR_ID_INTEL_ECX = 0x6c65746e; // letn
- is_intel = (cpu_info[1] == VENDOR_ID_INTEL_EBX &&
- cpu_info[2] == VENDOR_ID_INTEL_ECX &&
- cpu_info[3] == VENDOR_ID_INTEL_EDX); // genuine Intel?
- }
-
- GetCPUInfo(cpu_info, 1);
- if (feature == kSSE2) {
- return !!(cpu_info[3] & (1 << 26));
- }
- if (feature == kSSE3) {
- return !!(cpu_info[2] & (1 << 0));
- }
- if (feature == kSlowSSSE3) {
- if (is_intel && (cpu_info[2] & (1 << 9))) { // SSSE3?
- return CheckSlowModel(cpu_info[0]);
- }
- return 0;
- }
-
- if (feature == kSSE4_1) {
- return !!(cpu_info[2] & (1 << 19));
- }
- if (feature == kAVX) {
- // bits 27 (OSXSAVE) & 28 (256-bit AVX)
- if ((cpu_info[2] & 0x18000000) == 0x18000000) {
- // XMM state and YMM state enabled by the OS.
- return (xgetbv() & 0x6) == 0x6;
- }
- }
- if (feature == kAVX2) {
- if (x86CPUInfo(kAVX) && max_cpuid_value >= 7) {
- GetCPUInfo(cpu_info, 7);
- return !!(cpu_info[1] & (1 << 5));
- }
- }
- return 0;
-}
-VP8CPUInfo VP8GetCPUInfo = x86CPUInfo;
-#elif defined(WEBP_ANDROID_NEON) // NB: needs to be before generic NEON test.
-static int AndroidCPUInfo(CPUFeature feature) {
- const AndroidCpuFamily cpu_family = android_getCpuFamily();
- const uint64_t cpu_features = android_getCpuFeatures();
- if (feature == kNEON) {
- return cpu_family == ANDROID_CPU_FAMILY_ARM &&
- (cpu_features & ANDROID_CPU_ARM_FEATURE_NEON) != 0;
- }
- return 0;
-}
-VP8CPUInfo VP8GetCPUInfo = AndroidCPUInfo;
-#elif defined(EMSCRIPTEN) // also needs to be before generic NEON test
-// Use compile flags as an indicator of SIMD support instead of a runtime check.
-static int wasmCPUInfo(CPUFeature feature) {
- switch (feature) {
-#ifdef WEBP_HAVE_SSE2
- case kSSE2:
- return 1;
-#endif
-#ifdef WEBP_HAVE_SSE41
- case kSSE3:
- case kSlowSSSE3:
- case kSSE4_1:
- return 1;
-#endif
-#ifdef WEBP_HAVE_NEON
- case kNEON:
- return 1;
-#endif
- default:
- break;
- }
- return 0;
-}
-VP8CPUInfo VP8GetCPUInfo = wasmCPUInfo;
-#elif defined(WEBP_HAVE_NEON)
-// In most cases this function doesn't check for NEON support (it's assumed by
-// the configuration), but enables turning off NEON at runtime, for testing
-// purposes, by setting VP8DecGetCPUInfo = NULL.
-static int armCPUInfo(CPUFeature feature) {
- if (feature != kNEON) return 0;
-#if defined(__linux__) && defined(WEBP_HAVE_NEON_RTCD)
- {
- int has_neon = 0;
- char line[200];
- FILE* const cpuinfo = fopen("/proc/cpuinfo", "r");
- if (cpuinfo == NULL) return 0;
- while (fgets(line, sizeof(line), cpuinfo)) {
- if (!strncmp(line, "Features", 8)) {
- if (strstr(line, " neon ") != NULL) {
- has_neon = 1;
- break;
- }
- }
- }
- fclose(cpuinfo);
- return has_neon;
- }
-#else
- return 1;
-#endif
-}
-VP8CPUInfo VP8GetCPUInfo = armCPUInfo;
-#elif defined(WEBP_USE_MIPS32) || defined(WEBP_USE_MIPS_DSP_R2) || \
- defined(WEBP_USE_MSA)
-static int mipsCPUInfo(CPUFeature feature) {
- if ((feature == kMIPS32) || (feature == kMIPSdspR2) || (feature == kMSA)) {
- return 1;
- } else {
- return 0;
- }
-
-}
-VP8CPUInfo VP8GetCPUInfo = mipsCPUInfo;
-#else
-VP8CPUInfo VP8GetCPUInfo = NULL;
-#endif
diff --git a/contrib/libs/libwebp/dsp/dec.c b/contrib/libs/libwebp/dsp/dec.c
deleted file mode 100644
index 2c1faa1023..0000000000
--- a/contrib/libs/libwebp/dsp/dec.c
+++ /dev/null
@@ -1,887 +0,0 @@
-// Copyright 2010 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Speed-critical decoding functions, default plain-C implementations.
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include <assert.h>
-
-#include "./dsp.h"
-#include "../dec/vp8i_dec.h"
-#include "../utils/utils.h"
-
-//------------------------------------------------------------------------------
-
-static WEBP_INLINE uint8_t clip_8b(int v) {
- return (!(v & ~0xff)) ? v : (v < 0) ? 0 : 255;
-}
-
-//------------------------------------------------------------------------------
-// Transforms (Paragraph 14.4)
-
-#define STORE(x, y, v) \
- dst[(x) + (y) * BPS] = clip_8b(dst[(x) + (y) * BPS] + ((v) >> 3))
-
-#define STORE2(y, dc, d, c) do { \
- const int DC = (dc); \
- STORE(0, y, DC + (d)); \
- STORE(1, y, DC + (c)); \
- STORE(2, y, DC - (c)); \
- STORE(3, y, DC - (d)); \
-} while (0)
-
-#define MUL1(a) ((((a) * 20091) >> 16) + (a))
-#define MUL2(a) (((a) * 35468) >> 16)
-
-#if !WEBP_NEON_OMIT_C_CODE
-static void TransformOne_C(const int16_t* in, uint8_t* dst) {
- int C[4 * 4], *tmp;
- int i;
- tmp = C;
- for (i = 0; i < 4; ++i) { // vertical pass
- const int a = in[0] + in[8]; // [-4096, 4094]
- const int b = in[0] - in[8]; // [-4095, 4095]
- const int c = MUL2(in[4]) - MUL1(in[12]); // [-3783, 3783]
- const int d = MUL1(in[4]) + MUL2(in[12]); // [-3785, 3781]
- tmp[0] = a + d; // [-7881, 7875]
- tmp[1] = b + c; // [-7878, 7878]
- tmp[2] = b - c; // [-7878, 7878]
- tmp[3] = a - d; // [-7877, 7879]
- tmp += 4;
- in++;
- }
- // Each pass is expanding the dynamic range by ~3.85 (upper bound).
- // The exact value is (2. + (20091 + 35468) / 65536).
- // After the second pass, maximum interval is [-3794, 3794], assuming
- // an input in [-2048, 2047] interval. We then need to add a dst value
- // in the [0, 255] range.
- // In the worst case scenario, the input to clip_8b() can be as large as
- // [-60713, 60968].
- tmp = C;
- for (i = 0; i < 4; ++i) { // horizontal pass
- const int dc = tmp[0] + 4;
- const int a = dc + tmp[8];
- const int b = dc - tmp[8];
- const int c = MUL2(tmp[4]) - MUL1(tmp[12]);
- const int d = MUL1(tmp[4]) + MUL2(tmp[12]);
- STORE(0, 0, a + d);
- STORE(1, 0, b + c);
- STORE(2, 0, b - c);
- STORE(3, 0, a - d);
- tmp++;
- dst += BPS;
- }
-}
-
-// Simplified transform when only in[0], in[1] and in[4] are non-zero
-static void TransformAC3_C(const int16_t* in, uint8_t* dst) {
- const int a = in[0] + 4;
- const int c4 = MUL2(in[4]);
- const int d4 = MUL1(in[4]);
- const int c1 = MUL2(in[1]);
- const int d1 = MUL1(in[1]);
- STORE2(0, a + d4, d1, c1);
- STORE2(1, a + c4, d1, c1);
- STORE2(2, a - c4, d1, c1);
- STORE2(3, a - d4, d1, c1);
-}
-#undef MUL1
-#undef MUL2
-#undef STORE2
-
-static void TransformTwo_C(const int16_t* in, uint8_t* dst, int do_two) {
- TransformOne_C(in, dst);
- if (do_two) {
- TransformOne_C(in + 16, dst + 4);
- }
-}
-#endif // !WEBP_NEON_OMIT_C_CODE
-
-static void TransformUV_C(const int16_t* in, uint8_t* dst) {
- VP8Transform(in + 0 * 16, dst, 1);
- VP8Transform(in + 2 * 16, dst + 4 * BPS, 1);
-}
-
-#if !WEBP_NEON_OMIT_C_CODE
-static void TransformDC_C(const int16_t* in, uint8_t* dst) {
- const int DC = in[0] + 4;
- int i, j;
- for (j = 0; j < 4; ++j) {
- for (i = 0; i < 4; ++i) {
- STORE(i, j, DC);
- }
- }
-}
-#endif // !WEBP_NEON_OMIT_C_CODE
-
-static void TransformDCUV_C(const int16_t* in, uint8_t* dst) {
- if (in[0 * 16]) VP8TransformDC(in + 0 * 16, dst);
- if (in[1 * 16]) VP8TransformDC(in + 1 * 16, dst + 4);
- if (in[2 * 16]) VP8TransformDC(in + 2 * 16, dst + 4 * BPS);
- if (in[3 * 16]) VP8TransformDC(in + 3 * 16, dst + 4 * BPS + 4);
-}
-
-#undef STORE
-
-//------------------------------------------------------------------------------
-// Paragraph 14.3
-
-#if !WEBP_NEON_OMIT_C_CODE
-static void TransformWHT_C(const int16_t* in, int16_t* out) {
- int tmp[16];
- int i;
- for (i = 0; i < 4; ++i) {
- const int a0 = in[0 + i] + in[12 + i];
- const int a1 = in[4 + i] + in[ 8 + i];
- const int a2 = in[4 + i] - in[ 8 + i];
- const int a3 = in[0 + i] - in[12 + i];
- tmp[0 + i] = a0 + a1;
- tmp[8 + i] = a0 - a1;
- tmp[4 + i] = a3 + a2;
- tmp[12 + i] = a3 - a2;
- }
- for (i = 0; i < 4; ++i) {
- const int dc = tmp[0 + i * 4] + 3; // w/ rounder
- const int a0 = dc + tmp[3 + i * 4];
- const int a1 = tmp[1 + i * 4] + tmp[2 + i * 4];
- const int a2 = tmp[1 + i * 4] - tmp[2 + i * 4];
- const int a3 = dc - tmp[3 + i * 4];
- out[ 0] = (a0 + a1) >> 3;
- out[16] = (a3 + a2) >> 3;
- out[32] = (a0 - a1) >> 3;
- out[48] = (a3 - a2) >> 3;
- out += 64;
- }
-}
-#endif // !WEBP_NEON_OMIT_C_CODE
-
-void (*VP8TransformWHT)(const int16_t* in, int16_t* out);
-
-//------------------------------------------------------------------------------
-// Intra predictions
-
-#define DST(x, y) dst[(x) + (y) * BPS]
-
-#if !WEBP_NEON_OMIT_C_CODE
-static WEBP_INLINE void TrueMotion(uint8_t* dst, int size) {
- const uint8_t* top = dst - BPS;
- const uint8_t* const clip0 = VP8kclip1 - top[-1];
- int y;
- for (y = 0; y < size; ++y) {
- const uint8_t* const clip = clip0 + dst[-1];
- int x;
- for (x = 0; x < size; ++x) {
- dst[x] = clip[top[x]];
- }
- dst += BPS;
- }
-}
-static void TM4_C(uint8_t* dst) { TrueMotion(dst, 4); }
-static void TM8uv_C(uint8_t* dst) { TrueMotion(dst, 8); }
-static void TM16_C(uint8_t* dst) { TrueMotion(dst, 16); }
-
-//------------------------------------------------------------------------------
-// 16x16
-
-static void VE16_C(uint8_t* dst) { // vertical
- int j;
- for (j = 0; j < 16; ++j) {
- memcpy(dst + j * BPS, dst - BPS, 16);
- }
-}
-
-static void HE16_C(uint8_t* dst) { // horizontal
- int j;
- for (j = 16; j > 0; --j) {
- memset(dst, dst[-1], 16);
- dst += BPS;
- }
-}
-
-static WEBP_INLINE void Put16(int v, uint8_t* dst) {
- int j;
- for (j = 0; j < 16; ++j) {
- memset(dst + j * BPS, v, 16);
- }
-}
-
-static void DC16_C(uint8_t* dst) { // DC
- int DC = 16;
- int j;
- for (j = 0; j < 16; ++j) {
- DC += dst[-1 + j * BPS] + dst[j - BPS];
- }
- Put16(DC >> 5, dst);
-}
-
-static void DC16NoTop_C(uint8_t* dst) { // DC with top samples not available
- int DC = 8;
- int j;
- for (j = 0; j < 16; ++j) {
- DC += dst[-1 + j * BPS];
- }
- Put16(DC >> 4, dst);
-}
-
-static void DC16NoLeft_C(uint8_t* dst) { // DC with left samples not available
- int DC = 8;
- int i;
- for (i = 0; i < 16; ++i) {
- DC += dst[i - BPS];
- }
- Put16(DC >> 4, dst);
-}
-
-static void DC16NoTopLeft_C(uint8_t* dst) { // DC with no top and left samples
- Put16(0x80, dst);
-}
-#endif // !WEBP_NEON_OMIT_C_CODE
-
-VP8PredFunc VP8PredLuma16[NUM_B_DC_MODES];
-
-//------------------------------------------------------------------------------
-// 4x4
-
-#define AVG3(a, b, c) ((uint8_t)(((a) + 2 * (b) + (c) + 2) >> 2))
-#define AVG2(a, b) (((a) + (b) + 1) >> 1)
-
-#if !WEBP_NEON_OMIT_C_CODE
-static void VE4_C(uint8_t* dst) { // vertical
- const uint8_t* top = dst - BPS;
- const uint8_t vals[4] = {
- AVG3(top[-1], top[0], top[1]),
- AVG3(top[ 0], top[1], top[2]),
- AVG3(top[ 1], top[2], top[3]),
- AVG3(top[ 2], top[3], top[4])
- };
- int i;
- for (i = 0; i < 4; ++i) {
- memcpy(dst + i * BPS, vals, sizeof(vals));
- }
-}
-#endif // !WEBP_NEON_OMIT_C_CODE
-
-static void HE4_C(uint8_t* dst) { // horizontal
- const int A = dst[-1 - BPS];
- const int B = dst[-1];
- const int C = dst[-1 + BPS];
- const int D = dst[-1 + 2 * BPS];
- const int E = dst[-1 + 3 * BPS];
- WebPUint32ToMem(dst + 0 * BPS, 0x01010101U * AVG3(A, B, C));
- WebPUint32ToMem(dst + 1 * BPS, 0x01010101U * AVG3(B, C, D));
- WebPUint32ToMem(dst + 2 * BPS, 0x01010101U * AVG3(C, D, E));
- WebPUint32ToMem(dst + 3 * BPS, 0x01010101U * AVG3(D, E, E));
-}
-
-#if !WEBP_NEON_OMIT_C_CODE
-static void DC4_C(uint8_t* dst) { // DC
- uint32_t dc = 4;
- int i;
- for (i = 0; i < 4; ++i) dc += dst[i - BPS] + dst[-1 + i * BPS];
- dc >>= 3;
- for (i = 0; i < 4; ++i) memset(dst + i * BPS, dc, 4);
-}
-
-static void RD4_C(uint8_t* dst) { // Down-right
- const int I = dst[-1 + 0 * BPS];
- const int J = dst[-1 + 1 * BPS];
- const int K = dst[-1 + 2 * BPS];
- const int L = dst[-1 + 3 * BPS];
- const int X = dst[-1 - BPS];
- const int A = dst[0 - BPS];
- const int B = dst[1 - BPS];
- const int C = dst[2 - BPS];
- const int D = dst[3 - BPS];
- DST(0, 3) = AVG3(J, K, L);
- DST(1, 3) = DST(0, 2) = AVG3(I, J, K);
- DST(2, 3) = DST(1, 2) = DST(0, 1) = AVG3(X, I, J);
- DST(3, 3) = DST(2, 2) = DST(1, 1) = DST(0, 0) = AVG3(A, X, I);
- DST(3, 2) = DST(2, 1) = DST(1, 0) = AVG3(B, A, X);
- DST(3, 1) = DST(2, 0) = AVG3(C, B, A);
- DST(3, 0) = AVG3(D, C, B);
-}
-
-static void LD4_C(uint8_t* dst) { // Down-Left
- const int A = dst[0 - BPS];
- const int B = dst[1 - BPS];
- const int C = dst[2 - BPS];
- const int D = dst[3 - BPS];
- const int E = dst[4 - BPS];
- const int F = dst[5 - BPS];
- const int G = dst[6 - BPS];
- const int H = dst[7 - BPS];
- DST(0, 0) = AVG3(A, B, C);
- DST(1, 0) = DST(0, 1) = AVG3(B, C, D);
- DST(2, 0) = DST(1, 1) = DST(0, 2) = AVG3(C, D, E);
- DST(3, 0) = DST(2, 1) = DST(1, 2) = DST(0, 3) = AVG3(D, E, F);
- DST(3, 1) = DST(2, 2) = DST(1, 3) = AVG3(E, F, G);
- DST(3, 2) = DST(2, 3) = AVG3(F, G, H);
- DST(3, 3) = AVG3(G, H, H);
-}
-#endif // !WEBP_NEON_OMIT_C_CODE
-
-static void VR4_C(uint8_t* dst) { // Vertical-Right
- const int I = dst[-1 + 0 * BPS];
- const int J = dst[-1 + 1 * BPS];
- const int K = dst[-1 + 2 * BPS];
- const int X = dst[-1 - BPS];
- const int A = dst[0 - BPS];
- const int B = dst[1 - BPS];
- const int C = dst[2 - BPS];
- const int D = dst[3 - BPS];
- DST(0, 0) = DST(1, 2) = AVG2(X, A);
- DST(1, 0) = DST(2, 2) = AVG2(A, B);
- DST(2, 0) = DST(3, 2) = AVG2(B, C);
- DST(3, 0) = AVG2(C, D);
-
- DST(0, 3) = AVG3(K, J, I);
- DST(0, 2) = AVG3(J, I, X);
- DST(0, 1) = DST(1, 3) = AVG3(I, X, A);
- DST(1, 1) = DST(2, 3) = AVG3(X, A, B);
- DST(2, 1) = DST(3, 3) = AVG3(A, B, C);
- DST(3, 1) = AVG3(B, C, D);
-}
-
-static void VL4_C(uint8_t* dst) { // Vertical-Left
- const int A = dst[0 - BPS];
- const int B = dst[1 - BPS];
- const int C = dst[2 - BPS];
- const int D = dst[3 - BPS];
- const int E = dst[4 - BPS];
- const int F = dst[5 - BPS];
- const int G = dst[6 - BPS];
- const int H = dst[7 - BPS];
- DST(0, 0) = AVG2(A, B);
- DST(1, 0) = DST(0, 2) = AVG2(B, C);
- DST(2, 0) = DST(1, 2) = AVG2(C, D);
- DST(3, 0) = DST(2, 2) = AVG2(D, E);
-
- DST(0, 1) = AVG3(A, B, C);
- DST(1, 1) = DST(0, 3) = AVG3(B, C, D);
- DST(2, 1) = DST(1, 3) = AVG3(C, D, E);
- DST(3, 1) = DST(2, 3) = AVG3(D, E, F);
- DST(3, 2) = AVG3(E, F, G);
- DST(3, 3) = AVG3(F, G, H);
-}
-
-static void HU4_C(uint8_t* dst) { // Horizontal-Up
- const int I = dst[-1 + 0 * BPS];
- const int J = dst[-1 + 1 * BPS];
- const int K = dst[-1 + 2 * BPS];
- const int L = dst[-1 + 3 * BPS];
- DST(0, 0) = AVG2(I, J);
- DST(2, 0) = DST(0, 1) = AVG2(J, K);
- DST(2, 1) = DST(0, 2) = AVG2(K, L);
- DST(1, 0) = AVG3(I, J, K);
- DST(3, 0) = DST(1, 1) = AVG3(J, K, L);
- DST(3, 1) = DST(1, 2) = AVG3(K, L, L);
- DST(3, 2) = DST(2, 2) =
- DST(0, 3) = DST(1, 3) = DST(2, 3) = DST(3, 3) = L;
-}
-
-static void HD4_C(uint8_t* dst) { // Horizontal-Down
- const int I = dst[-1 + 0 * BPS];
- const int J = dst[-1 + 1 * BPS];
- const int K = dst[-1 + 2 * BPS];
- const int L = dst[-1 + 3 * BPS];
- const int X = dst[-1 - BPS];
- const int A = dst[0 - BPS];
- const int B = dst[1 - BPS];
- const int C = dst[2 - BPS];
-
- DST(0, 0) = DST(2, 1) = AVG2(I, X);
- DST(0, 1) = DST(2, 2) = AVG2(J, I);
- DST(0, 2) = DST(2, 3) = AVG2(K, J);
- DST(0, 3) = AVG2(L, K);
-
- DST(3, 0) = AVG3(A, B, C);
- DST(2, 0) = AVG3(X, A, B);
- DST(1, 0) = DST(3, 1) = AVG3(I, X, A);
- DST(1, 1) = DST(3, 2) = AVG3(J, I, X);
- DST(1, 2) = DST(3, 3) = AVG3(K, J, I);
- DST(1, 3) = AVG3(L, K, J);
-}
-
-#undef DST
-#undef AVG3
-#undef AVG2
-
-VP8PredFunc VP8PredLuma4[NUM_BMODES];
-
-//------------------------------------------------------------------------------
-// Chroma
-
-#if !WEBP_NEON_OMIT_C_CODE
-static void VE8uv_C(uint8_t* dst) { // vertical
- int j;
- for (j = 0; j < 8; ++j) {
- memcpy(dst + j * BPS, dst - BPS, 8);
- }
-}
-
-static void HE8uv_C(uint8_t* dst) { // horizontal
- int j;
- for (j = 0; j < 8; ++j) {
- memset(dst, dst[-1], 8);
- dst += BPS;
- }
-}
-
-// helper for chroma-DC predictions
-static WEBP_INLINE void Put8x8uv(uint8_t value, uint8_t* dst) {
- int j;
- for (j = 0; j < 8; ++j) {
- memset(dst + j * BPS, value, 8);
- }
-}
-
-static void DC8uv_C(uint8_t* dst) { // DC
- int dc0 = 8;
- int i;
- for (i = 0; i < 8; ++i) {
- dc0 += dst[i - BPS] + dst[-1 + i * BPS];
- }
- Put8x8uv(dc0 >> 4, dst);
-}
-
-static void DC8uvNoLeft_C(uint8_t* dst) { // DC with no left samples
- int dc0 = 4;
- int i;
- for (i = 0; i < 8; ++i) {
- dc0 += dst[i - BPS];
- }
- Put8x8uv(dc0 >> 3, dst);
-}
-
-static void DC8uvNoTop_C(uint8_t* dst) { // DC with no top samples
- int dc0 = 4;
- int i;
- for (i = 0; i < 8; ++i) {
- dc0 += dst[-1 + i * BPS];
- }
- Put8x8uv(dc0 >> 3, dst);
-}
-
-static void DC8uvNoTopLeft_C(uint8_t* dst) { // DC with nothing
- Put8x8uv(0x80, dst);
-}
-#endif // !WEBP_NEON_OMIT_C_CODE
-
-VP8PredFunc VP8PredChroma8[NUM_B_DC_MODES];
-
-//------------------------------------------------------------------------------
-// Edge filtering functions
-
-#if !WEBP_NEON_OMIT_C_CODE || WEBP_NEON_WORK_AROUND_GCC
-// 4 pixels in, 2 pixels out
-static WEBP_INLINE void DoFilter2_C(uint8_t* p, int step) {
- const int p1 = p[-2*step], p0 = p[-step], q0 = p[0], q1 = p[step];
- const int a = 3 * (q0 - p0) + VP8ksclip1[p1 - q1]; // in [-893,892]
- const int a1 = VP8ksclip2[(a + 4) >> 3]; // in [-16,15]
- const int a2 = VP8ksclip2[(a + 3) >> 3];
- p[-step] = VP8kclip1[p0 + a2];
- p[ 0] = VP8kclip1[q0 - a1];
-}
-
-// 4 pixels in, 4 pixels out
-static WEBP_INLINE void DoFilter4_C(uint8_t* p, int step) {
- const int p1 = p[-2*step], p0 = p[-step], q0 = p[0], q1 = p[step];
- const int a = 3 * (q0 - p0);
- const int a1 = VP8ksclip2[(a + 4) >> 3];
- const int a2 = VP8ksclip2[(a + 3) >> 3];
- const int a3 = (a1 + 1) >> 1;
- p[-2*step] = VP8kclip1[p1 + a3];
- p[- step] = VP8kclip1[p0 + a2];
- p[ 0] = VP8kclip1[q0 - a1];
- p[ step] = VP8kclip1[q1 - a3];
-}
-
-// 6 pixels in, 6 pixels out
-static WEBP_INLINE void DoFilter6_C(uint8_t* p, int step) {
- const int p2 = p[-3*step], p1 = p[-2*step], p0 = p[-step];
- const int q0 = p[0], q1 = p[step], q2 = p[2*step];
- const int a = VP8ksclip1[3 * (q0 - p0) + VP8ksclip1[p1 - q1]];
- // a is in [-128,127], a1 in [-27,27], a2 in [-18,18] and a3 in [-9,9]
- const int a1 = (27 * a + 63) >> 7; // eq. to ((3 * a + 7) * 9) >> 7
- const int a2 = (18 * a + 63) >> 7; // eq. to ((2 * a + 7) * 9) >> 7
- const int a3 = (9 * a + 63) >> 7; // eq. to ((1 * a + 7) * 9) >> 7
- p[-3*step] = VP8kclip1[p2 + a3];
- p[-2*step] = VP8kclip1[p1 + a2];
- p[- step] = VP8kclip1[p0 + a1];
- p[ 0] = VP8kclip1[q0 - a1];
- p[ step] = VP8kclip1[q1 - a2];
- p[ 2*step] = VP8kclip1[q2 - a3];
-}
-
-static WEBP_INLINE int Hev(const uint8_t* p, int step, int thresh) {
- const int p1 = p[-2*step], p0 = p[-step], q0 = p[0], q1 = p[step];
- return (VP8kabs0[p1 - p0] > thresh) || (VP8kabs0[q1 - q0] > thresh);
-}
-#endif // !WEBP_NEON_OMIT_C_CODE || WEBP_NEON_WORK_AROUND_GCC
-
-#if !WEBP_NEON_OMIT_C_CODE
-static WEBP_INLINE int NeedsFilter_C(const uint8_t* p, int step, int t) {
- const int p1 = p[-2 * step], p0 = p[-step], q0 = p[0], q1 = p[step];
- return ((4 * VP8kabs0[p0 - q0] + VP8kabs0[p1 - q1]) <= t);
-}
-#endif // !WEBP_NEON_OMIT_C_CODE
-
-#if !WEBP_NEON_OMIT_C_CODE || WEBP_NEON_WORK_AROUND_GCC
-static WEBP_INLINE int NeedsFilter2_C(const uint8_t* p,
- int step, int t, int it) {
- const int p3 = p[-4 * step], p2 = p[-3 * step], p1 = p[-2 * step];
- const int p0 = p[-step], q0 = p[0];
- const int q1 = p[step], q2 = p[2 * step], q3 = p[3 * step];
- if ((4 * VP8kabs0[p0 - q0] + VP8kabs0[p1 - q1]) > t) return 0;
- return VP8kabs0[p3 - p2] <= it && VP8kabs0[p2 - p1] <= it &&
- VP8kabs0[p1 - p0] <= it && VP8kabs0[q3 - q2] <= it &&
- VP8kabs0[q2 - q1] <= it && VP8kabs0[q1 - q0] <= it;
-}
-#endif // !WEBP_NEON_OMIT_C_CODE || WEBP_NEON_WORK_AROUND_GCC
-
-//------------------------------------------------------------------------------
-// Simple In-loop filtering (Paragraph 15.2)
-
-#if !WEBP_NEON_OMIT_C_CODE
-static void SimpleVFilter16_C(uint8_t* p, int stride, int thresh) {
- int i;
- const int thresh2 = 2 * thresh + 1;
- for (i = 0; i < 16; ++i) {
- if (NeedsFilter_C(p + i, stride, thresh2)) {
- DoFilter2_C(p + i, stride);
- }
- }
-}
-
-static void SimpleHFilter16_C(uint8_t* p, int stride, int thresh) {
- int i;
- const int thresh2 = 2 * thresh + 1;
- for (i = 0; i < 16; ++i) {
- if (NeedsFilter_C(p + i * stride, 1, thresh2)) {
- DoFilter2_C(p + i * stride, 1);
- }
- }
-}
-
-static void SimpleVFilter16i_C(uint8_t* p, int stride, int thresh) {
- int k;
- for (k = 3; k > 0; --k) {
- p += 4 * stride;
- SimpleVFilter16_C(p, stride, thresh);
- }
-}
-
-static void SimpleHFilter16i_C(uint8_t* p, int stride, int thresh) {
- int k;
- for (k = 3; k > 0; --k) {
- p += 4;
- SimpleHFilter16_C(p, stride, thresh);
- }
-}
-#endif // !WEBP_NEON_OMIT_C_CODE
-
-//------------------------------------------------------------------------------
-// Complex In-loop filtering (Paragraph 15.3)
-
-#if !WEBP_NEON_OMIT_C_CODE || WEBP_NEON_WORK_AROUND_GCC
-static WEBP_INLINE void FilterLoop26_C(uint8_t* p,
- int hstride, int vstride, int size,
- int thresh, int ithresh,
- int hev_thresh) {
- const int thresh2 = 2 * thresh + 1;
- while (size-- > 0) {
- if (NeedsFilter2_C(p, hstride, thresh2, ithresh)) {
- if (Hev(p, hstride, hev_thresh)) {
- DoFilter2_C(p, hstride);
- } else {
- DoFilter6_C(p, hstride);
- }
- }
- p += vstride;
- }
-}
-
-static WEBP_INLINE void FilterLoop24_C(uint8_t* p,
- int hstride, int vstride, int size,
- int thresh, int ithresh,
- int hev_thresh) {
- const int thresh2 = 2 * thresh + 1;
- while (size-- > 0) {
- if (NeedsFilter2_C(p, hstride, thresh2, ithresh)) {
- if (Hev(p, hstride, hev_thresh)) {
- DoFilter2_C(p, hstride);
- } else {
- DoFilter4_C(p, hstride);
- }
- }
- p += vstride;
- }
-}
-#endif // !WEBP_NEON_OMIT_C_CODE || WEBP_NEON_WORK_AROUND_GCC
-
-#if !WEBP_NEON_OMIT_C_CODE
-// on macroblock edges
-static void VFilter16_C(uint8_t* p, int stride,
- int thresh, int ithresh, int hev_thresh) {
- FilterLoop26_C(p, stride, 1, 16, thresh, ithresh, hev_thresh);
-}
-
-static void HFilter16_C(uint8_t* p, int stride,
- int thresh, int ithresh, int hev_thresh) {
- FilterLoop26_C(p, 1, stride, 16, thresh, ithresh, hev_thresh);
-}
-
-// on three inner edges
-static void VFilter16i_C(uint8_t* p, int stride,
- int thresh, int ithresh, int hev_thresh) {
- int k;
- for (k = 3; k > 0; --k) {
- p += 4 * stride;
- FilterLoop24_C(p, stride, 1, 16, thresh, ithresh, hev_thresh);
- }
-}
-#endif // !WEBP_NEON_OMIT_C_CODE
-
-#if !WEBP_NEON_OMIT_C_CODE || WEBP_NEON_WORK_AROUND_GCC
-static void HFilter16i_C(uint8_t* p, int stride,
- int thresh, int ithresh, int hev_thresh) {
- int k;
- for (k = 3; k > 0; --k) {
- p += 4;
- FilterLoop24_C(p, 1, stride, 16, thresh, ithresh, hev_thresh);
- }
-}
-#endif // !WEBP_NEON_OMIT_C_CODE || WEBP_NEON_WORK_AROUND_GCC
-
-#if !WEBP_NEON_OMIT_C_CODE
-// 8-pixels wide variant, for chroma filtering
-static void VFilter8_C(uint8_t* u, uint8_t* v, int stride,
- int thresh, int ithresh, int hev_thresh) {
- FilterLoop26_C(u, stride, 1, 8, thresh, ithresh, hev_thresh);
- FilterLoop26_C(v, stride, 1, 8, thresh, ithresh, hev_thresh);
-}
-#endif // !WEBP_NEON_OMIT_C_CODE
-
-#if !WEBP_NEON_OMIT_C_CODE || WEBP_NEON_WORK_AROUND_GCC
-static void HFilter8_C(uint8_t* u, uint8_t* v, int stride,
- int thresh, int ithresh, int hev_thresh) {
- FilterLoop26_C(u, 1, stride, 8, thresh, ithresh, hev_thresh);
- FilterLoop26_C(v, 1, stride, 8, thresh, ithresh, hev_thresh);
-}
-#endif // !WEBP_NEON_OMIT_C_CODE || WEBP_NEON_WORK_AROUND_GCC
-
-#if !WEBP_NEON_OMIT_C_CODE
-static void VFilter8i_C(uint8_t* u, uint8_t* v, int stride,
- int thresh, int ithresh, int hev_thresh) {
- FilterLoop24_C(u + 4 * stride, stride, 1, 8, thresh, ithresh, hev_thresh);
- FilterLoop24_C(v + 4 * stride, stride, 1, 8, thresh, ithresh, hev_thresh);
-}
-#endif // !WEBP_NEON_OMIT_C_CODE
-
-#if !WEBP_NEON_OMIT_C_CODE || WEBP_NEON_WORK_AROUND_GCC
-static void HFilter8i_C(uint8_t* u, uint8_t* v, int stride,
- int thresh, int ithresh, int hev_thresh) {
- FilterLoop24_C(u + 4, 1, stride, 8, thresh, ithresh, hev_thresh);
- FilterLoop24_C(v + 4, 1, stride, 8, thresh, ithresh, hev_thresh);
-}
-#endif // !WEBP_NEON_OMIT_C_CODE || WEBP_NEON_WORK_AROUND_GCC
-
-//------------------------------------------------------------------------------
-
-static void DitherCombine8x8_C(const uint8_t* dither, uint8_t* dst,
- int dst_stride) {
- int i, j;
- for (j = 0; j < 8; ++j) {
- for (i = 0; i < 8; ++i) {
- const int delta0 = dither[i] - VP8_DITHER_AMP_CENTER;
- const int delta1 =
- (delta0 + VP8_DITHER_DESCALE_ROUNDER) >> VP8_DITHER_DESCALE;
- dst[i] = clip_8b((int)dst[i] + delta1);
- }
- dst += dst_stride;
- dither += 8;
- }
-}
-
-//------------------------------------------------------------------------------
-
-VP8DecIdct2 VP8Transform;
-VP8DecIdct VP8TransformAC3;
-VP8DecIdct VP8TransformUV;
-VP8DecIdct VP8TransformDC;
-VP8DecIdct VP8TransformDCUV;
-
-VP8LumaFilterFunc VP8VFilter16;
-VP8LumaFilterFunc VP8HFilter16;
-VP8ChromaFilterFunc VP8VFilter8;
-VP8ChromaFilterFunc VP8HFilter8;
-VP8LumaFilterFunc VP8VFilter16i;
-VP8LumaFilterFunc VP8HFilter16i;
-VP8ChromaFilterFunc VP8VFilter8i;
-VP8ChromaFilterFunc VP8HFilter8i;
-VP8SimpleFilterFunc VP8SimpleVFilter16;
-VP8SimpleFilterFunc VP8SimpleHFilter16;
-VP8SimpleFilterFunc VP8SimpleVFilter16i;
-VP8SimpleFilterFunc VP8SimpleHFilter16i;
-
-void (*VP8DitherCombine8x8)(const uint8_t* dither, uint8_t* dst,
- int dst_stride);
-
-extern void VP8DspInitSSE2(void);
-extern void VP8DspInitSSE41(void);
-extern void VP8DspInitNEON(void);
-extern void VP8DspInitMIPS32(void);
-extern void VP8DspInitMIPSdspR2(void);
-extern void VP8DspInitMSA(void);
-
-WEBP_DSP_INIT_FUNC(VP8DspInit) {
- VP8InitClipTables();
-
-#if !WEBP_NEON_OMIT_C_CODE
- VP8TransformWHT = TransformWHT_C;
- VP8Transform = TransformTwo_C;
- VP8TransformDC = TransformDC_C;
- VP8TransformAC3 = TransformAC3_C;
-#endif
- VP8TransformUV = TransformUV_C;
- VP8TransformDCUV = TransformDCUV_C;
-
-#if !WEBP_NEON_OMIT_C_CODE
- VP8VFilter16 = VFilter16_C;
- VP8VFilter16i = VFilter16i_C;
- VP8HFilter16 = HFilter16_C;
- VP8VFilter8 = VFilter8_C;
- VP8VFilter8i = VFilter8i_C;
- VP8SimpleVFilter16 = SimpleVFilter16_C;
- VP8SimpleHFilter16 = SimpleHFilter16_C;
- VP8SimpleVFilter16i = SimpleVFilter16i_C;
- VP8SimpleHFilter16i = SimpleHFilter16i_C;
-#endif
-
-#if !WEBP_NEON_OMIT_C_CODE || WEBP_NEON_WORK_AROUND_GCC
- VP8HFilter16i = HFilter16i_C;
- VP8HFilter8 = HFilter8_C;
- VP8HFilter8i = HFilter8i_C;
-#endif
-
-#if !WEBP_NEON_OMIT_C_CODE
- VP8PredLuma4[0] = DC4_C;
- VP8PredLuma4[1] = TM4_C;
- VP8PredLuma4[2] = VE4_C;
- VP8PredLuma4[4] = RD4_C;
- VP8PredLuma4[6] = LD4_C;
-#endif
-
- VP8PredLuma4[3] = HE4_C;
- VP8PredLuma4[5] = VR4_C;
- VP8PredLuma4[7] = VL4_C;
- VP8PredLuma4[8] = HD4_C;
- VP8PredLuma4[9] = HU4_C;
-
-#if !WEBP_NEON_OMIT_C_CODE
- VP8PredLuma16[0] = DC16_C;
- VP8PredLuma16[1] = TM16_C;
- VP8PredLuma16[2] = VE16_C;
- VP8PredLuma16[3] = HE16_C;
- VP8PredLuma16[4] = DC16NoTop_C;
- VP8PredLuma16[5] = DC16NoLeft_C;
- VP8PredLuma16[6] = DC16NoTopLeft_C;
-
- VP8PredChroma8[0] = DC8uv_C;
- VP8PredChroma8[1] = TM8uv_C;
- VP8PredChroma8[2] = VE8uv_C;
- VP8PredChroma8[3] = HE8uv_C;
- VP8PredChroma8[4] = DC8uvNoTop_C;
- VP8PredChroma8[5] = DC8uvNoLeft_C;
- VP8PredChroma8[6] = DC8uvNoTopLeft_C;
-#endif
-
- VP8DitherCombine8x8 = DitherCombine8x8_C;
-
- // If defined, use CPUInfo() to overwrite some pointers with faster versions.
- if (VP8GetCPUInfo != NULL) {
-#if defined(WEBP_HAVE_SSE2)
- if (VP8GetCPUInfo(kSSE2)) {
- VP8DspInitSSE2();
-#if defined(WEBP_HAVE_SSE41)
- if (VP8GetCPUInfo(kSSE4_1)) {
- VP8DspInitSSE41();
- }
-#endif
- }
-#endif
-#if defined(WEBP_USE_MIPS32)
- if (VP8GetCPUInfo(kMIPS32)) {
- VP8DspInitMIPS32();
- }
-#endif
-#if defined(WEBP_USE_MIPS_DSP_R2)
- if (VP8GetCPUInfo(kMIPSdspR2)) {
- VP8DspInitMIPSdspR2();
- }
-#endif
-#if defined(WEBP_USE_MSA)
- if (VP8GetCPUInfo(kMSA)) {
- VP8DspInitMSA();
- }
-#endif
- }
-
-#if defined(WEBP_HAVE_NEON)
- if (WEBP_NEON_OMIT_C_CODE ||
- (VP8GetCPUInfo != NULL && VP8GetCPUInfo(kNEON))) {
- VP8DspInitNEON();
- }
-#endif
-
- assert(VP8TransformWHT != NULL);
- assert(VP8Transform != NULL);
- assert(VP8TransformDC != NULL);
- assert(VP8TransformAC3 != NULL);
- assert(VP8TransformUV != NULL);
- assert(VP8TransformDCUV != NULL);
- assert(VP8VFilter16 != NULL);
- assert(VP8HFilter16 != NULL);
- assert(VP8VFilter8 != NULL);
- assert(VP8HFilter8 != NULL);
- assert(VP8VFilter16i != NULL);
- assert(VP8HFilter16i != NULL);
- assert(VP8VFilter8i != NULL);
- assert(VP8HFilter8i != NULL);
- assert(VP8SimpleVFilter16 != NULL);
- assert(VP8SimpleHFilter16 != NULL);
- assert(VP8SimpleVFilter16i != NULL);
- assert(VP8SimpleHFilter16i != NULL);
- assert(VP8PredLuma4[0] != NULL);
- assert(VP8PredLuma4[1] != NULL);
- assert(VP8PredLuma4[2] != NULL);
- assert(VP8PredLuma4[3] != NULL);
- assert(VP8PredLuma4[4] != NULL);
- assert(VP8PredLuma4[5] != NULL);
- assert(VP8PredLuma4[6] != NULL);
- assert(VP8PredLuma4[7] != NULL);
- assert(VP8PredLuma4[8] != NULL);
- assert(VP8PredLuma4[9] != NULL);
- assert(VP8PredLuma16[0] != NULL);
- assert(VP8PredLuma16[1] != NULL);
- assert(VP8PredLuma16[2] != NULL);
- assert(VP8PredLuma16[3] != NULL);
- assert(VP8PredLuma16[4] != NULL);
- assert(VP8PredLuma16[5] != NULL);
- assert(VP8PredLuma16[6] != NULL);
- assert(VP8PredChroma8[0] != NULL);
- assert(VP8PredChroma8[1] != NULL);
- assert(VP8PredChroma8[2] != NULL);
- assert(VP8PredChroma8[3] != NULL);
- assert(VP8PredChroma8[4] != NULL);
- assert(VP8PredChroma8[5] != NULL);
- assert(VP8PredChroma8[6] != NULL);
- assert(VP8DitherCombine8x8 != NULL);
-}
diff --git a/contrib/libs/libwebp/dsp/dec_clip_tables.c b/contrib/libs/libwebp/dsp/dec_clip_tables.c
deleted file mode 100644
index beb051a31a..0000000000
--- a/contrib/libs/libwebp/dsp/dec_clip_tables.c
+++ /dev/null
@@ -1,369 +0,0 @@
-// Copyright 2014 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Clipping tables for filtering
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include "./dsp.h"
-
-// define to 0 to have run-time table initialization
-#if !defined(USE_STATIC_TABLES)
-#define USE_STATIC_TABLES 1 // ALTERNATE_CODE
-#endif
-
-#if (USE_STATIC_TABLES == 1)
-
-static const uint8_t abs0[255 + 255 + 1] = {
- 0xff, 0xfe, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8, 0xf7, 0xf6, 0xf5, 0xf4,
- 0xf3, 0xf2, 0xf1, 0xf0, 0xef, 0xee, 0xed, 0xec, 0xeb, 0xea, 0xe9, 0xe8,
- 0xe7, 0xe6, 0xe5, 0xe4, 0xe3, 0xe2, 0xe1, 0xe0, 0xdf, 0xde, 0xdd, 0xdc,
- 0xdb, 0xda, 0xd9, 0xd8, 0xd7, 0xd6, 0xd5, 0xd4, 0xd3, 0xd2, 0xd1, 0xd0,
- 0xcf, 0xce, 0xcd, 0xcc, 0xcb, 0xca, 0xc9, 0xc8, 0xc7, 0xc6, 0xc5, 0xc4,
- 0xc3, 0xc2, 0xc1, 0xc0, 0xbf, 0xbe, 0xbd, 0xbc, 0xbb, 0xba, 0xb9, 0xb8,
- 0xb7, 0xb6, 0xb5, 0xb4, 0xb3, 0xb2, 0xb1, 0xb0, 0xaf, 0xae, 0xad, 0xac,
- 0xab, 0xaa, 0xa9, 0xa8, 0xa7, 0xa6, 0xa5, 0xa4, 0xa3, 0xa2, 0xa1, 0xa0,
- 0x9f, 0x9e, 0x9d, 0x9c, 0x9b, 0x9a, 0x99, 0x98, 0x97, 0x96, 0x95, 0x94,
- 0x93, 0x92, 0x91, 0x90, 0x8f, 0x8e, 0x8d, 0x8c, 0x8b, 0x8a, 0x89, 0x88,
- 0x87, 0x86, 0x85, 0x84, 0x83, 0x82, 0x81, 0x80, 0x7f, 0x7e, 0x7d, 0x7c,
- 0x7b, 0x7a, 0x79, 0x78, 0x77, 0x76, 0x75, 0x74, 0x73, 0x72, 0x71, 0x70,
- 0x6f, 0x6e, 0x6d, 0x6c, 0x6b, 0x6a, 0x69, 0x68, 0x67, 0x66, 0x65, 0x64,
- 0x63, 0x62, 0x61, 0x60, 0x5f, 0x5e, 0x5d, 0x5c, 0x5b, 0x5a, 0x59, 0x58,
- 0x57, 0x56, 0x55, 0x54, 0x53, 0x52, 0x51, 0x50, 0x4f, 0x4e, 0x4d, 0x4c,
- 0x4b, 0x4a, 0x49, 0x48, 0x47, 0x46, 0x45, 0x44, 0x43, 0x42, 0x41, 0x40,
- 0x3f, 0x3e, 0x3d, 0x3c, 0x3b, 0x3a, 0x39, 0x38, 0x37, 0x36, 0x35, 0x34,
- 0x33, 0x32, 0x31, 0x30, 0x2f, 0x2e, 0x2d, 0x2c, 0x2b, 0x2a, 0x29, 0x28,
- 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21, 0x20, 0x1f, 0x1e, 0x1d, 0x1c,
- 0x1b, 0x1a, 0x19, 0x18, 0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x10,
- 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08, 0x07, 0x06, 0x05, 0x04,
- 0x03, 0x02, 0x01, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
- 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14,
- 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
- 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c,
- 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
- 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44,
- 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
- 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c,
- 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
- 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74,
- 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80,
- 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c,
- 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98,
- 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4,
- 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0,
- 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc,
- 0xbd, 0xbe, 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8,
- 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4,
- 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0,
- 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec,
- 0xed, 0xee, 0xef, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
- 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
-};
-
-static const uint8_t sclip1[1020 + 1020 + 1] = {
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
- 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93,
- 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
- 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab,
- 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
- 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc1, 0xc2, 0xc3,
- 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
- 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb,
- 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
- 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, 0xf1, 0xf2, 0xf3,
- 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
- 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
- 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23,
- 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
- 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b,
- 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
- 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53,
- 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
- 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b,
- 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
- 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
- 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f
-};
-
-static const uint8_t sclip2[112 + 112 + 1] = {
- 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
- 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
- 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
- 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
- 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
- 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
- 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
- 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
- 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb,
- 0xfc, 0xfd, 0xfe, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
- 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
- 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
- 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
- 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
- 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
- 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
- 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
- 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f
-};
-
-static const uint8_t clip1[255 + 511 + 1] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
- 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14,
- 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
- 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c,
- 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
- 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44,
- 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
- 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c,
- 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
- 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74,
- 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80,
- 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c,
- 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98,
- 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4,
- 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0,
- 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc,
- 0xbd, 0xbe, 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8,
- 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4,
- 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0,
- 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec,
- 0xed, 0xee, 0xef, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
- 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
-};
-
-#else
-
-// uninitialized tables
-static uint8_t abs0[255 + 255 + 1];
-static int8_t sclip1[1020 + 1020 + 1];
-static int8_t sclip2[112 + 112 + 1];
-static uint8_t clip1[255 + 511 + 1];
-
-// We declare this variable 'volatile' to prevent instruction reordering
-// and make sure it's set to true _last_ (so as to be thread-safe)
-static volatile int tables_ok = 0;
-
-#endif // USE_STATIC_TABLES
-
-const int8_t* const VP8ksclip1 = (const int8_t*)&sclip1[1020];
-const int8_t* const VP8ksclip2 = (const int8_t*)&sclip2[112];
-const uint8_t* const VP8kclip1 = &clip1[255];
-const uint8_t* const VP8kabs0 = &abs0[255];
-
-WEBP_TSAN_IGNORE_FUNCTION void VP8InitClipTables(void) {
-#if (USE_STATIC_TABLES == 0)
- int i;
- if (!tables_ok) {
- for (i = -255; i <= 255; ++i) {
- abs0[255 + i] = (i < 0) ? -i : i;
- }
- for (i = -1020; i <= 1020; ++i) {
- sclip1[1020 + i] = (i < -128) ? -128 : (i > 127) ? 127 : i;
- }
- for (i = -112; i <= 112; ++i) {
- sclip2[112 + i] = (i < -16) ? -16 : (i > 15) ? 15 : i;
- }
- for (i = -255; i <= 255 + 255; ++i) {
- clip1[255 + i] = (i < 0) ? 0 : (i > 255) ? 255 : i;
- }
- tables_ok = 1;
- }
-#endif // USE_STATIC_TABLES
-}
diff --git a/contrib/libs/libwebp/dsp/dec_mips32.c b/contrib/libs/libwebp/dsp/dec_mips32.c
deleted file mode 100644
index 4e9ef42605..0000000000
--- a/contrib/libs/libwebp/dsp/dec_mips32.c
+++ /dev/null
@@ -1,587 +0,0 @@
-// Copyright 2014 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// MIPS version of dsp functions
-//
-// Author(s): Djordje Pesut (djordje.pesut@imgtec.com)
-// Jovan Zelincevic (jovan.zelincevic@imgtec.com)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_MIPS32)
-
-#include "./mips_macro.h"
-
-static const int kC1 = 20091 + (1 << 16);
-static const int kC2 = 35468;
-
-static WEBP_INLINE int abs_mips32(int x) {
- const int sign = x >> 31;
- return (x ^ sign) - sign;
-}
-
-// 4 pixels in, 2 pixels out
-static WEBP_INLINE void do_filter2(uint8_t* p, int step) {
- const int p1 = p[-2 * step], p0 = p[-step], q0 = p[0], q1 = p[step];
- const int a = 3 * (q0 - p0) + VP8ksclip1[p1 - q1];
- const int a1 = VP8ksclip2[(a + 4) >> 3];
- const int a2 = VP8ksclip2[(a + 3) >> 3];
- p[-step] = VP8kclip1[p0 + a2];
- p[ 0] = VP8kclip1[q0 - a1];
-}
-
-// 4 pixels in, 4 pixels out
-static WEBP_INLINE void do_filter4(uint8_t* p, int step) {
- const int p1 = p[-2 * step], p0 = p[-step], q0 = p[0], q1 = p[step];
- const int a = 3 * (q0 - p0);
- const int a1 = VP8ksclip2[(a + 4) >> 3];
- const int a2 = VP8ksclip2[(a + 3) >> 3];
- const int a3 = (a1 + 1) >> 1;
- p[-2 * step] = VP8kclip1[p1 + a3];
- p[- step] = VP8kclip1[p0 + a2];
- p[ 0] = VP8kclip1[q0 - a1];
- p[ step] = VP8kclip1[q1 - a3];
-}
-
-// 6 pixels in, 6 pixels out
-static WEBP_INLINE void do_filter6(uint8_t* p, int step) {
- const int p2 = p[-3 * step], p1 = p[-2 * step], p0 = p[-step];
- const int q0 = p[0], q1 = p[step], q2 = p[2 * step];
- const int a = VP8ksclip1[3 * (q0 - p0) + VP8ksclip1[p1 - q1]];
- // a is in [-128,127], a1 in [-27,27], a2 in [-18,18] and a3 in [-9,9]
- const int a1 = (27 * a + 63) >> 7; // eq. to ((3 * a + 7) * 9) >> 7
- const int a2 = (18 * a + 63) >> 7; // eq. to ((2 * a + 7) * 9) >> 7
- const int a3 = (9 * a + 63) >> 7; // eq. to ((1 * a + 7) * 9) >> 7
- p[-3 * step] = VP8kclip1[p2 + a3];
- p[-2 * step] = VP8kclip1[p1 + a2];
- p[- step] = VP8kclip1[p0 + a1];
- p[ 0] = VP8kclip1[q0 - a1];
- p[ step] = VP8kclip1[q1 - a2];
- p[ 2 * step] = VP8kclip1[q2 - a3];
-}
-
-static WEBP_INLINE int hev(const uint8_t* p, int step, int thresh) {
- const int p1 = p[-2 * step], p0 = p[-step], q0 = p[0], q1 = p[step];
- return (abs_mips32(p1 - p0) > thresh) || (abs_mips32(q1 - q0) > thresh);
-}
-
-static WEBP_INLINE int needs_filter(const uint8_t* p, int step, int t) {
- const int p1 = p[-2 * step], p0 = p[-step], q0 = p[0], q1 = p[step];
- return ((4 * abs_mips32(p0 - q0) + abs_mips32(p1 - q1)) <= t);
-}
-
-static WEBP_INLINE int needs_filter2(const uint8_t* p,
- int step, int t, int it) {
- const int p3 = p[-4 * step], p2 = p[-3 * step];
- const int p1 = p[-2 * step], p0 = p[-step];
- const int q0 = p[0], q1 = p[step], q2 = p[2 * step], q3 = p[3 * step];
- if ((4 * abs_mips32(p0 - q0) + abs_mips32(p1 - q1)) > t) {
- return 0;
- }
- return abs_mips32(p3 - p2) <= it && abs_mips32(p2 - p1) <= it &&
- abs_mips32(p1 - p0) <= it && abs_mips32(q3 - q2) <= it &&
- abs_mips32(q2 - q1) <= it && abs_mips32(q1 - q0) <= it;
-}
-
-static WEBP_INLINE void FilterLoop26(uint8_t* p,
- int hstride, int vstride, int size,
- int thresh, int ithresh, int hev_thresh) {
- const int thresh2 = 2 * thresh + 1;
- while (size-- > 0) {
- if (needs_filter2(p, hstride, thresh2, ithresh)) {
- if (hev(p, hstride, hev_thresh)) {
- do_filter2(p, hstride);
- } else {
- do_filter6(p, hstride);
- }
- }
- p += vstride;
- }
-}
-
-static WEBP_INLINE void FilterLoop24(uint8_t* p,
- int hstride, int vstride, int size,
- int thresh, int ithresh, int hev_thresh) {
- const int thresh2 = 2 * thresh + 1;
- while (size-- > 0) {
- if (needs_filter2(p, hstride, thresh2, ithresh)) {
- if (hev(p, hstride, hev_thresh)) {
- do_filter2(p, hstride);
- } else {
- do_filter4(p, hstride);
- }
- }
- p += vstride;
- }
-}
-
-// on macroblock edges
-static void VFilter16(uint8_t* p, int stride,
- int thresh, int ithresh, int hev_thresh) {
- FilterLoop26(p, stride, 1, 16, thresh, ithresh, hev_thresh);
-}
-
-static void HFilter16(uint8_t* p, int stride,
- int thresh, int ithresh, int hev_thresh) {
- FilterLoop26(p, 1, stride, 16, thresh, ithresh, hev_thresh);
-}
-
-// 8-pixels wide variant, for chroma filtering
-static void VFilter8(uint8_t* u, uint8_t* v, int stride,
- int thresh, int ithresh, int hev_thresh) {
- FilterLoop26(u, stride, 1, 8, thresh, ithresh, hev_thresh);
- FilterLoop26(v, stride, 1, 8, thresh, ithresh, hev_thresh);
-}
-
-static void HFilter8(uint8_t* u, uint8_t* v, int stride,
- int thresh, int ithresh, int hev_thresh) {
- FilterLoop26(u, 1, stride, 8, thresh, ithresh, hev_thresh);
- FilterLoop26(v, 1, stride, 8, thresh, ithresh, hev_thresh);
-}
-
-static void VFilter8i(uint8_t* u, uint8_t* v, int stride,
- int thresh, int ithresh, int hev_thresh) {
- FilterLoop24(u + 4 * stride, stride, 1, 8, thresh, ithresh, hev_thresh);
- FilterLoop24(v + 4 * stride, stride, 1, 8, thresh, ithresh, hev_thresh);
-}
-
-static void HFilter8i(uint8_t* u, uint8_t* v, int stride,
- int thresh, int ithresh, int hev_thresh) {
- FilterLoop24(u + 4, 1, stride, 8, thresh, ithresh, hev_thresh);
- FilterLoop24(v + 4, 1, stride, 8, thresh, ithresh, hev_thresh);
-}
-
-// on three inner edges
-static void VFilter16i(uint8_t* p, int stride,
- int thresh, int ithresh, int hev_thresh) {
- int k;
- for (k = 3; k > 0; --k) {
- p += 4 * stride;
- FilterLoop24(p, stride, 1, 16, thresh, ithresh, hev_thresh);
- }
-}
-
-static void HFilter16i(uint8_t* p, int stride,
- int thresh, int ithresh, int hev_thresh) {
- int k;
- for (k = 3; k > 0; --k) {
- p += 4;
- FilterLoop24(p, 1, stride, 16, thresh, ithresh, hev_thresh);
- }
-}
-
-//------------------------------------------------------------------------------
-// Simple In-loop filtering (Paragraph 15.2)
-
-static void SimpleVFilter16(uint8_t* p, int stride, int thresh) {
- int i;
- const int thresh2 = 2 * thresh + 1;
- for (i = 0; i < 16; ++i) {
- if (needs_filter(p + i, stride, thresh2)) {
- do_filter2(p + i, stride);
- }
- }
-}
-
-static void SimpleHFilter16(uint8_t* p, int stride, int thresh) {
- int i;
- const int thresh2 = 2 * thresh + 1;
- for (i = 0; i < 16; ++i) {
- if (needs_filter(p + i * stride, 1, thresh2)) {
- do_filter2(p + i * stride, 1);
- }
- }
-}
-
-static void SimpleVFilter16i(uint8_t* p, int stride, int thresh) {
- int k;
- for (k = 3; k > 0; --k) {
- p += 4 * stride;
- SimpleVFilter16(p, stride, thresh);
- }
-}
-
-static void SimpleHFilter16i(uint8_t* p, int stride, int thresh) {
- int k;
- for (k = 3; k > 0; --k) {
- p += 4;
- SimpleHFilter16(p, stride, thresh);
- }
-}
-
-static void TransformOne(const int16_t* in, uint8_t* dst) {
- int temp0, temp1, temp2, temp3, temp4;
- int temp5, temp6, temp7, temp8, temp9;
- int temp10, temp11, temp12, temp13, temp14;
- int temp15, temp16, temp17, temp18;
- int16_t* p_in = (int16_t*)in;
-
- // loops unrolled and merged to avoid usage of tmp buffer
- // and to reduce number of stalls. MUL macro is written
- // in assembler and inlined
- __asm__ volatile(
- "lh %[temp0], 0(%[in]) \n\t"
- "lh %[temp8], 16(%[in]) \n\t"
- "lh %[temp4], 8(%[in]) \n\t"
- "lh %[temp12], 24(%[in]) \n\t"
- "addu %[temp16], %[temp0], %[temp8] \n\t"
- "subu %[temp0], %[temp0], %[temp8] \n\t"
- "mul %[temp8], %[temp4], %[kC2] \n\t"
- "mul %[temp17], %[temp12], %[kC1] \n\t"
- "mul %[temp4], %[temp4], %[kC1] \n\t"
- "mul %[temp12], %[temp12], %[kC2] \n\t"
- "lh %[temp1], 2(%[in]) \n\t"
- "lh %[temp5], 10(%[in]) \n\t"
- "lh %[temp9], 18(%[in]) \n\t"
- "lh %[temp13], 26(%[in]) \n\t"
- "sra %[temp8], %[temp8], 16 \n\t"
- "sra %[temp17], %[temp17], 16 \n\t"
- "sra %[temp4], %[temp4], 16 \n\t"
- "sra %[temp12], %[temp12], 16 \n\t"
- "lh %[temp2], 4(%[in]) \n\t"
- "lh %[temp6], 12(%[in]) \n\t"
- "lh %[temp10], 20(%[in]) \n\t"
- "lh %[temp14], 28(%[in]) \n\t"
- "subu %[temp17], %[temp8], %[temp17] \n\t"
- "addu %[temp4], %[temp4], %[temp12] \n\t"
- "addu %[temp8], %[temp16], %[temp4] \n\t"
- "subu %[temp4], %[temp16], %[temp4] \n\t"
- "addu %[temp16], %[temp1], %[temp9] \n\t"
- "subu %[temp1], %[temp1], %[temp9] \n\t"
- "lh %[temp3], 6(%[in]) \n\t"
- "lh %[temp7], 14(%[in]) \n\t"
- "lh %[temp11], 22(%[in]) \n\t"
- "lh %[temp15], 30(%[in]) \n\t"
- "addu %[temp12], %[temp0], %[temp17] \n\t"
- "subu %[temp0], %[temp0], %[temp17] \n\t"
- "mul %[temp9], %[temp5], %[kC2] \n\t"
- "mul %[temp17], %[temp13], %[kC1] \n\t"
- "mul %[temp5], %[temp5], %[kC1] \n\t"
- "mul %[temp13], %[temp13], %[kC2] \n\t"
- "sra %[temp9], %[temp9], 16 \n\t"
- "sra %[temp17], %[temp17], 16 \n\t"
- "subu %[temp17], %[temp9], %[temp17] \n\t"
- "sra %[temp5], %[temp5], 16 \n\t"
- "sra %[temp13], %[temp13], 16 \n\t"
- "addu %[temp5], %[temp5], %[temp13] \n\t"
- "addu %[temp13], %[temp1], %[temp17] \n\t"
- "subu %[temp1], %[temp1], %[temp17] \n\t"
- "mul %[temp17], %[temp14], %[kC1] \n\t"
- "mul %[temp14], %[temp14], %[kC2] \n\t"
- "addu %[temp9], %[temp16], %[temp5] \n\t"
- "subu %[temp5], %[temp16], %[temp5] \n\t"
- "addu %[temp16], %[temp2], %[temp10] \n\t"
- "subu %[temp2], %[temp2], %[temp10] \n\t"
- "mul %[temp10], %[temp6], %[kC2] \n\t"
- "mul %[temp6], %[temp6], %[kC1] \n\t"
- "sra %[temp17], %[temp17], 16 \n\t"
- "sra %[temp14], %[temp14], 16 \n\t"
- "sra %[temp10], %[temp10], 16 \n\t"
- "sra %[temp6], %[temp6], 16 \n\t"
- "subu %[temp17], %[temp10], %[temp17] \n\t"
- "addu %[temp6], %[temp6], %[temp14] \n\t"
- "addu %[temp10], %[temp16], %[temp6] \n\t"
- "subu %[temp6], %[temp16], %[temp6] \n\t"
- "addu %[temp14], %[temp2], %[temp17] \n\t"
- "subu %[temp2], %[temp2], %[temp17] \n\t"
- "mul %[temp17], %[temp15], %[kC1] \n\t"
- "mul %[temp15], %[temp15], %[kC2] \n\t"
- "addu %[temp16], %[temp3], %[temp11] \n\t"
- "subu %[temp3], %[temp3], %[temp11] \n\t"
- "mul %[temp11], %[temp7], %[kC2] \n\t"
- "mul %[temp7], %[temp7], %[kC1] \n\t"
- "addiu %[temp8], %[temp8], 4 \n\t"
- "addiu %[temp12], %[temp12], 4 \n\t"
- "addiu %[temp0], %[temp0], 4 \n\t"
- "addiu %[temp4], %[temp4], 4 \n\t"
- "sra %[temp17], %[temp17], 16 \n\t"
- "sra %[temp15], %[temp15], 16 \n\t"
- "sra %[temp11], %[temp11], 16 \n\t"
- "sra %[temp7], %[temp7], 16 \n\t"
- "subu %[temp17], %[temp11], %[temp17] \n\t"
- "addu %[temp7], %[temp7], %[temp15] \n\t"
- "addu %[temp15], %[temp3], %[temp17] \n\t"
- "subu %[temp3], %[temp3], %[temp17] \n\t"
- "addu %[temp11], %[temp16], %[temp7] \n\t"
- "subu %[temp7], %[temp16], %[temp7] \n\t"
- "addu %[temp16], %[temp8], %[temp10] \n\t"
- "subu %[temp8], %[temp8], %[temp10] \n\t"
- "mul %[temp10], %[temp9], %[kC2] \n\t"
- "mul %[temp17], %[temp11], %[kC1] \n\t"
- "mul %[temp9], %[temp9], %[kC1] \n\t"
- "mul %[temp11], %[temp11], %[kC2] \n\t"
- "sra %[temp10], %[temp10], 16 \n\t"
- "sra %[temp17], %[temp17], 16 \n\t"
- "sra %[temp9], %[temp9], 16 \n\t"
- "sra %[temp11], %[temp11], 16 \n\t"
- "subu %[temp17], %[temp10], %[temp17] \n\t"
- "addu %[temp11], %[temp9], %[temp11] \n\t"
- "addu %[temp10], %[temp12], %[temp14] \n\t"
- "subu %[temp12], %[temp12], %[temp14] \n\t"
- "mul %[temp14], %[temp13], %[kC2] \n\t"
- "mul %[temp9], %[temp15], %[kC1] \n\t"
- "mul %[temp13], %[temp13], %[kC1] \n\t"
- "mul %[temp15], %[temp15], %[kC2] \n\t"
- "sra %[temp14], %[temp14], 16 \n\t"
- "sra %[temp9], %[temp9], 16 \n\t"
- "sra %[temp13], %[temp13], 16 \n\t"
- "sra %[temp15], %[temp15], 16 \n\t"
- "subu %[temp9], %[temp14], %[temp9] \n\t"
- "addu %[temp15], %[temp13], %[temp15] \n\t"
- "addu %[temp14], %[temp0], %[temp2] \n\t"
- "subu %[temp0], %[temp0], %[temp2] \n\t"
- "mul %[temp2], %[temp1], %[kC2] \n\t"
- "mul %[temp13], %[temp3], %[kC1] \n\t"
- "mul %[temp1], %[temp1], %[kC1] \n\t"
- "mul %[temp3], %[temp3], %[kC2] \n\t"
- "sra %[temp2], %[temp2], 16 \n\t"
- "sra %[temp13], %[temp13], 16 \n\t"
- "sra %[temp1], %[temp1], 16 \n\t"
- "sra %[temp3], %[temp3], 16 \n\t"
- "subu %[temp13], %[temp2], %[temp13] \n\t"
- "addu %[temp3], %[temp1], %[temp3] \n\t"
- "addu %[temp2], %[temp4], %[temp6] \n\t"
- "subu %[temp4], %[temp4], %[temp6] \n\t"
- "mul %[temp6], %[temp5], %[kC2] \n\t"
- "mul %[temp1], %[temp7], %[kC1] \n\t"
- "mul %[temp5], %[temp5], %[kC1] \n\t"
- "mul %[temp7], %[temp7], %[kC2] \n\t"
- "sra %[temp6], %[temp6], 16 \n\t"
- "sra %[temp1], %[temp1], 16 \n\t"
- "sra %[temp5], %[temp5], 16 \n\t"
- "sra %[temp7], %[temp7], 16 \n\t"
- "subu %[temp1], %[temp6], %[temp1] \n\t"
- "addu %[temp7], %[temp5], %[temp7] \n\t"
- "addu %[temp5], %[temp16], %[temp11] \n\t"
- "subu %[temp16], %[temp16], %[temp11] \n\t"
- "addu %[temp11], %[temp8], %[temp17] \n\t"
- "subu %[temp8], %[temp8], %[temp17] \n\t"
- "sra %[temp5], %[temp5], 3 \n\t"
- "sra %[temp16], %[temp16], 3 \n\t"
- "sra %[temp11], %[temp11], 3 \n\t"
- "sra %[temp8], %[temp8], 3 \n\t"
- "addu %[temp17], %[temp10], %[temp15] \n\t"
- "subu %[temp10], %[temp10], %[temp15] \n\t"
- "addu %[temp15], %[temp12], %[temp9] \n\t"
- "subu %[temp12], %[temp12], %[temp9] \n\t"
- "sra %[temp17], %[temp17], 3 \n\t"
- "sra %[temp10], %[temp10], 3 \n\t"
- "sra %[temp15], %[temp15], 3 \n\t"
- "sra %[temp12], %[temp12], 3 \n\t"
- "addu %[temp9], %[temp14], %[temp3] \n\t"
- "subu %[temp14], %[temp14], %[temp3] \n\t"
- "addu %[temp3], %[temp0], %[temp13] \n\t"
- "subu %[temp0], %[temp0], %[temp13] \n\t"
- "sra %[temp9], %[temp9], 3 \n\t"
- "sra %[temp14], %[temp14], 3 \n\t"
- "sra %[temp3], %[temp3], 3 \n\t"
- "sra %[temp0], %[temp0], 3 \n\t"
- "addu %[temp13], %[temp2], %[temp7] \n\t"
- "subu %[temp2], %[temp2], %[temp7] \n\t"
- "addu %[temp7], %[temp4], %[temp1] \n\t"
- "subu %[temp4], %[temp4], %[temp1] \n\t"
- "sra %[temp13], %[temp13], 3 \n\t"
- "sra %[temp2], %[temp2], 3 \n\t"
- "sra %[temp7], %[temp7], 3 \n\t"
- "sra %[temp4], %[temp4], 3 \n\t"
- "addiu %[temp6], $zero, 255 \n\t"
- "lbu %[temp1], 0+0*" XSTR(BPS) "(%[dst]) \n\t"
- "addu %[temp1], %[temp1], %[temp5] \n\t"
- "sra %[temp5], %[temp1], 8 \n\t"
- "sra %[temp18], %[temp1], 31 \n\t"
- "beqz %[temp5], 1f \n\t"
- "xor %[temp1], %[temp1], %[temp1] \n\t"
- "movz %[temp1], %[temp6], %[temp18] \n\t"
- "1: \n\t"
- "lbu %[temp18], 1+0*" XSTR(BPS) "(%[dst]) \n\t"
- "sb %[temp1], 0+0*" XSTR(BPS) "(%[dst]) \n\t"
- "addu %[temp18], %[temp18], %[temp11] \n\t"
- "sra %[temp11], %[temp18], 8 \n\t"
- "sra %[temp1], %[temp18], 31 \n\t"
- "beqz %[temp11], 2f \n\t"
- "xor %[temp18], %[temp18], %[temp18] \n\t"
- "movz %[temp18], %[temp6], %[temp1] \n\t"
- "2: \n\t"
- "lbu %[temp1], 2+0*" XSTR(BPS) "(%[dst]) \n\t"
- "sb %[temp18], 1+0*" XSTR(BPS) "(%[dst]) \n\t"
- "addu %[temp1], %[temp1], %[temp8] \n\t"
- "sra %[temp8], %[temp1], 8 \n\t"
- "sra %[temp18], %[temp1], 31 \n\t"
- "beqz %[temp8], 3f \n\t"
- "xor %[temp1], %[temp1], %[temp1] \n\t"
- "movz %[temp1], %[temp6], %[temp18] \n\t"
- "3: \n\t"
- "lbu %[temp18], 3+0*" XSTR(BPS) "(%[dst]) \n\t"
- "sb %[temp1], 2+0*" XSTR(BPS) "(%[dst]) \n\t"
- "addu %[temp18], %[temp18], %[temp16] \n\t"
- "sra %[temp16], %[temp18], 8 \n\t"
- "sra %[temp1], %[temp18], 31 \n\t"
- "beqz %[temp16], 4f \n\t"
- "xor %[temp18], %[temp18], %[temp18] \n\t"
- "movz %[temp18], %[temp6], %[temp1] \n\t"
- "4: \n\t"
- "sb %[temp18], 3+0*" XSTR(BPS) "(%[dst]) \n\t"
- "lbu %[temp5], 0+1*" XSTR(BPS) "(%[dst]) \n\t"
- "lbu %[temp8], 1+1*" XSTR(BPS) "(%[dst]) \n\t"
- "lbu %[temp11], 2+1*" XSTR(BPS) "(%[dst]) \n\t"
- "lbu %[temp16], 3+1*" XSTR(BPS) "(%[dst]) \n\t"
- "addu %[temp5], %[temp5], %[temp17] \n\t"
- "addu %[temp8], %[temp8], %[temp15] \n\t"
- "addu %[temp11], %[temp11], %[temp12] \n\t"
- "addu %[temp16], %[temp16], %[temp10] \n\t"
- "sra %[temp18], %[temp5], 8 \n\t"
- "sra %[temp1], %[temp5], 31 \n\t"
- "beqz %[temp18], 5f \n\t"
- "xor %[temp5], %[temp5], %[temp5] \n\t"
- "movz %[temp5], %[temp6], %[temp1] \n\t"
- "5: \n\t"
- "sra %[temp18], %[temp8], 8 \n\t"
- "sra %[temp1], %[temp8], 31 \n\t"
- "beqz %[temp18], 6f \n\t"
- "xor %[temp8], %[temp8], %[temp8] \n\t"
- "movz %[temp8], %[temp6], %[temp1] \n\t"
- "6: \n\t"
- "sra %[temp18], %[temp11], 8 \n\t"
- "sra %[temp1], %[temp11], 31 \n\t"
- "sra %[temp17], %[temp16], 8 \n\t"
- "sra %[temp15], %[temp16], 31 \n\t"
- "beqz %[temp18], 7f \n\t"
- "xor %[temp11], %[temp11], %[temp11] \n\t"
- "movz %[temp11], %[temp6], %[temp1] \n\t"
- "7: \n\t"
- "beqz %[temp17], 8f \n\t"
- "xor %[temp16], %[temp16], %[temp16] \n\t"
- "movz %[temp16], %[temp6], %[temp15] \n\t"
- "8: \n\t"
- "sb %[temp5], 0+1*" XSTR(BPS) "(%[dst]) \n\t"
- "sb %[temp8], 1+1*" XSTR(BPS) "(%[dst]) \n\t"
- "sb %[temp11], 2+1*" XSTR(BPS) "(%[dst]) \n\t"
- "sb %[temp16], 3+1*" XSTR(BPS) "(%[dst]) \n\t"
- "lbu %[temp5], 0+2*" XSTR(BPS) "(%[dst]) \n\t"
- "lbu %[temp8], 1+2*" XSTR(BPS) "(%[dst]) \n\t"
- "lbu %[temp11], 2+2*" XSTR(BPS) "(%[dst]) \n\t"
- "lbu %[temp16], 3+2*" XSTR(BPS) "(%[dst]) \n\t"
- "addu %[temp5], %[temp5], %[temp9] \n\t"
- "addu %[temp8], %[temp8], %[temp3] \n\t"
- "addu %[temp11], %[temp11], %[temp0] \n\t"
- "addu %[temp16], %[temp16], %[temp14] \n\t"
- "sra %[temp18], %[temp5], 8 \n\t"
- "sra %[temp1], %[temp5], 31 \n\t"
- "sra %[temp17], %[temp8], 8 \n\t"
- "sra %[temp15], %[temp8], 31 \n\t"
- "sra %[temp12], %[temp11], 8 \n\t"
- "sra %[temp10], %[temp11], 31 \n\t"
- "sra %[temp9], %[temp16], 8 \n\t"
- "sra %[temp3], %[temp16], 31 \n\t"
- "beqz %[temp18], 9f \n\t"
- "xor %[temp5], %[temp5], %[temp5] \n\t"
- "movz %[temp5], %[temp6], %[temp1] \n\t"
- "9: \n\t"
- "beqz %[temp17], 10f \n\t"
- "xor %[temp8], %[temp8], %[temp8] \n\t"
- "movz %[temp8], %[temp6], %[temp15] \n\t"
- "10: \n\t"
- "beqz %[temp12], 11f \n\t"
- "xor %[temp11], %[temp11], %[temp11] \n\t"
- "movz %[temp11], %[temp6], %[temp10] \n\t"
- "11: \n\t"
- "beqz %[temp9], 12f \n\t"
- "xor %[temp16], %[temp16], %[temp16] \n\t"
- "movz %[temp16], %[temp6], %[temp3] \n\t"
- "12: \n\t"
- "sb %[temp5], 0+2*" XSTR(BPS) "(%[dst]) \n\t"
- "sb %[temp8], 1+2*" XSTR(BPS) "(%[dst]) \n\t"
- "sb %[temp11], 2+2*" XSTR(BPS) "(%[dst]) \n\t"
- "sb %[temp16], 3+2*" XSTR(BPS) "(%[dst]) \n\t"
- "lbu %[temp5], 0+3*" XSTR(BPS) "(%[dst]) \n\t"
- "lbu %[temp8], 1+3*" XSTR(BPS) "(%[dst]) \n\t"
- "lbu %[temp11], 2+3*" XSTR(BPS) "(%[dst]) \n\t"
- "lbu %[temp16], 3+3*" XSTR(BPS) "(%[dst]) \n\t"
- "addu %[temp5], %[temp5], %[temp13] \n\t"
- "addu %[temp8], %[temp8], %[temp7] \n\t"
- "addu %[temp11], %[temp11], %[temp4] \n\t"
- "addu %[temp16], %[temp16], %[temp2] \n\t"
- "sra %[temp18], %[temp5], 8 \n\t"
- "sra %[temp1], %[temp5], 31 \n\t"
- "sra %[temp17], %[temp8], 8 \n\t"
- "sra %[temp15], %[temp8], 31 \n\t"
- "sra %[temp12], %[temp11], 8 \n\t"
- "sra %[temp10], %[temp11], 31 \n\t"
- "sra %[temp9], %[temp16], 8 \n\t"
- "sra %[temp3], %[temp16], 31 \n\t"
- "beqz %[temp18], 13f \n\t"
- "xor %[temp5], %[temp5], %[temp5] \n\t"
- "movz %[temp5], %[temp6], %[temp1] \n\t"
- "13: \n\t"
- "beqz %[temp17], 14f \n\t"
- "xor %[temp8], %[temp8], %[temp8] \n\t"
- "movz %[temp8], %[temp6], %[temp15] \n\t"
- "14: \n\t"
- "beqz %[temp12], 15f \n\t"
- "xor %[temp11], %[temp11], %[temp11] \n\t"
- "movz %[temp11], %[temp6], %[temp10] \n\t"
- "15: \n\t"
- "beqz %[temp9], 16f \n\t"
- "xor %[temp16], %[temp16], %[temp16] \n\t"
- "movz %[temp16], %[temp6], %[temp3] \n\t"
- "16: \n\t"
- "sb %[temp5], 0+3*" XSTR(BPS) "(%[dst]) \n\t"
- "sb %[temp8], 1+3*" XSTR(BPS) "(%[dst]) \n\t"
- "sb %[temp11], 2+3*" XSTR(BPS) "(%[dst]) \n\t"
- "sb %[temp16], 3+3*" XSTR(BPS) "(%[dst]) \n\t"
-
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [temp4]"=&r"(temp4), [temp5]"=&r"(temp5),
- [temp6]"=&r"(temp6), [temp7]"=&r"(temp7), [temp8]"=&r"(temp8),
- [temp9]"=&r"(temp9), [temp10]"=&r"(temp10), [temp11]"=&r"(temp11),
- [temp12]"=&r"(temp12), [temp13]"=&r"(temp13), [temp14]"=&r"(temp14),
- [temp15]"=&r"(temp15), [temp16]"=&r"(temp16), [temp17]"=&r"(temp17),
- [temp18]"=&r"(temp18)
- : [in]"r"(p_in), [kC1]"r"(kC1), [kC2]"r"(kC2), [dst]"r"(dst)
- : "memory", "hi", "lo"
- );
-}
-
-static void TransformTwo(const int16_t* in, uint8_t* dst, int do_two) {
- TransformOne(in, dst);
- if (do_two) {
- TransformOne(in + 16, dst + 4);
- }
-}
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void VP8DspInitMIPS32(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void VP8DspInitMIPS32(void) {
- VP8InitClipTables();
-
- VP8Transform = TransformTwo;
-
- VP8VFilter16 = VFilter16;
- VP8HFilter16 = HFilter16;
- VP8VFilter8 = VFilter8;
- VP8HFilter8 = HFilter8;
- VP8VFilter16i = VFilter16i;
- VP8HFilter16i = HFilter16i;
- VP8VFilter8i = VFilter8i;
- VP8HFilter8i = HFilter8i;
-
- VP8SimpleVFilter16 = SimpleVFilter16;
- VP8SimpleHFilter16 = SimpleHFilter16;
- VP8SimpleVFilter16i = SimpleVFilter16i;
- VP8SimpleHFilter16i = SimpleHFilter16i;
-}
-
-#else // !WEBP_USE_MIPS32
-
-WEBP_DSP_INIT_STUB(VP8DspInitMIPS32)
-
-#endif // WEBP_USE_MIPS32
diff --git a/contrib/libs/libwebp/dsp/dec_mips_dsp_r2.c b/contrib/libs/libwebp/dsp/dec_mips_dsp_r2.c
deleted file mode 100644
index db5c657228..0000000000
--- a/contrib/libs/libwebp/dsp/dec_mips_dsp_r2.c
+++ /dev/null
@@ -1,994 +0,0 @@
-// Copyright 2014 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// MIPS version of dsp functions
-//
-// Author(s): Djordje Pesut (djordje.pesut@imgtec.com)
-// Jovan Zelincevic (jovan.zelincevic@imgtec.com)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_MIPS_DSP_R2)
-
-#include "./mips_macro.h"
-
-static const int kC1 = 20091 + (1 << 16);
-static const int kC2 = 35468;
-
-#define MUL(a, b) (((a) * (b)) >> 16)
-
-static void TransformDC(const int16_t* in, uint8_t* dst) {
- int temp1, temp2, temp3, temp4, temp5, temp6, temp7, temp8, temp9, temp10;
-
- __asm__ volatile (
- LOAD_WITH_OFFSET_X4(temp1, temp2, temp3, temp4, dst,
- 0, 0, 0, 0,
- 0, 1, 2, 3,
- BPS)
- "lh %[temp5], 0(%[in]) \n\t"
- "addiu %[temp5], %[temp5], 4 \n\t"
- "ins %[temp5], %[temp5], 16, 16 \n\t"
- "shra.ph %[temp5], %[temp5], 3 \n\t"
- CONVERT_2_BYTES_TO_HALF(temp6, temp7, temp8, temp9, temp10, temp1, temp2,
- temp3, temp1, temp2, temp3, temp4)
- STORE_SAT_SUM_X2(temp6, temp7, temp8, temp9, temp10, temp1, temp2, temp3,
- temp5, temp5, temp5, temp5, temp5, temp5, temp5, temp5,
- dst, 0, 1, 2, 3, BPS)
-
- OUTPUT_EARLY_CLOBBER_REGS_10()
- : [in]"r"(in), [dst]"r"(dst)
- : "memory"
- );
-}
-
-static void TransformAC3(const int16_t* in, uint8_t* dst) {
- const int a = in[0] + 4;
- int c4 = MUL(in[4], kC2);
- const int d4 = MUL(in[4], kC1);
- const int c1 = MUL(in[1], kC2);
- const int d1 = MUL(in[1], kC1);
- int temp1, temp2, temp3, temp4, temp5, temp6, temp7, temp8, temp9;
- int temp10, temp11, temp12, temp13, temp14, temp15, temp16, temp17, temp18;
-
- __asm__ volatile (
- "ins %[c4], %[d4], 16, 16 \n\t"
- "replv.ph %[temp1], %[a] \n\t"
- "replv.ph %[temp4], %[d1] \n\t"
- ADD_SUB_HALVES(temp2, temp3, temp1, c4)
- "replv.ph %[temp5], %[c1] \n\t"
- SHIFT_R_SUM_X2(temp1, temp6, temp7, temp8, temp2, temp9, temp10, temp4,
- temp2, temp2, temp3, temp3, temp4, temp5, temp4, temp5)
- LOAD_WITH_OFFSET_X4(temp3, temp5, temp11, temp12, dst,
- 0, 0, 0, 0,
- 0, 1, 2, 3,
- BPS)
- CONVERT_2_BYTES_TO_HALF(temp13, temp14, temp3, temp15, temp5, temp16,
- temp11, temp17, temp3, temp5, temp11, temp12)
- PACK_2_HALVES_TO_WORD(temp12, temp18, temp7, temp6, temp1, temp8, temp2,
- temp4, temp7, temp6, temp10, temp9)
- STORE_SAT_SUM_X2(temp13, temp14, temp3, temp15, temp5, temp16, temp11,
- temp17, temp12, temp18, temp1, temp8, temp2, temp4,
- temp7, temp6, dst, 0, 1, 2, 3, BPS)
-
- OUTPUT_EARLY_CLOBBER_REGS_18(),
- [c4]"+&r"(c4)
- : [dst]"r"(dst), [a]"r"(a), [d1]"r"(d1), [d4]"r"(d4), [c1]"r"(c1)
- : "memory"
- );
-}
-
-static void TransformOne(const int16_t* in, uint8_t* dst) {
- int temp1, temp2, temp3, temp4, temp5, temp6, temp7, temp8, temp9;
- int temp10, temp11, temp12, temp13, temp14, temp15, temp16, temp17, temp18;
-
- __asm__ volatile (
- "ulw %[temp1], 0(%[in]) \n\t"
- "ulw %[temp2], 16(%[in]) \n\t"
- LOAD_IN_X2(temp5, temp6, 24, 26)
- ADD_SUB_HALVES(temp3, temp4, temp1, temp2)
- LOAD_IN_X2(temp1, temp2, 8, 10)
- MUL_SHIFT_SUM(temp7, temp8, temp9, temp10, temp11, temp12, temp13, temp14,
- temp10, temp8, temp9, temp7, temp1, temp2, temp5, temp6,
- temp13, temp11, temp14, temp12)
- INSERT_HALF_X2(temp8, temp7, temp10, temp9)
- "ulw %[temp17], 4(%[in]) \n\t"
- "ulw %[temp18], 20(%[in]) \n\t"
- ADD_SUB_HALVES(temp1, temp2, temp3, temp8)
- ADD_SUB_HALVES(temp5, temp6, temp4, temp7)
- ADD_SUB_HALVES(temp7, temp8, temp17, temp18)
- LOAD_IN_X2(temp17, temp18, 12, 14)
- LOAD_IN_X2(temp9, temp10, 28, 30)
- MUL_SHIFT_SUM(temp11, temp12, temp13, temp14, temp15, temp16, temp4, temp17,
- temp12, temp14, temp11, temp13, temp17, temp18, temp9, temp10,
- temp15, temp4, temp16, temp17)
- INSERT_HALF_X2(temp11, temp12, temp13, temp14)
- ADD_SUB_HALVES(temp17, temp8, temp8, temp11)
- ADD_SUB_HALVES(temp3, temp4, temp7, temp12)
-
- // horizontal
- SRA_16(temp9, temp10, temp11, temp12, temp1, temp2, temp5, temp6)
- INSERT_HALF_X2(temp1, temp6, temp5, temp2)
- SRA_16(temp13, temp14, temp15, temp16, temp3, temp4, temp17, temp8)
- "repl.ph %[temp2], 0x4 \n\t"
- INSERT_HALF_X2(temp3, temp8, temp17, temp4)
- "addq.ph %[temp1], %[temp1], %[temp2] \n\t"
- "addq.ph %[temp6], %[temp6], %[temp2] \n\t"
- ADD_SUB_HALVES(temp2, temp4, temp1, temp3)
- ADD_SUB_HALVES(temp5, temp7, temp6, temp8)
- MUL_SHIFT_SUM(temp1, temp3, temp6, temp8, temp9, temp13, temp17, temp18,
- temp3, temp13, temp1, temp9, temp9, temp13, temp11, temp15,
- temp6, temp17, temp8, temp18)
- MUL_SHIFT_SUM(temp6, temp8, temp18, temp17, temp11, temp15, temp12, temp16,
- temp8, temp15, temp6, temp11, temp12, temp16, temp10, temp14,
- temp18, temp12, temp17, temp16)
- INSERT_HALF_X2(temp1, temp3, temp9, temp13)
- INSERT_HALF_X2(temp6, temp8, temp11, temp15)
- SHIFT_R_SUM_X2(temp9, temp10, temp11, temp12, temp13, temp14, temp15,
- temp16, temp2, temp4, temp5, temp7, temp3, temp1, temp8,
- temp6)
- PACK_2_HALVES_TO_WORD(temp1, temp2, temp3, temp4, temp9, temp12, temp13,
- temp16, temp11, temp10, temp15, temp14)
- LOAD_WITH_OFFSET_X4(temp10, temp11, temp14, temp15, dst,
- 0, 0, 0, 0,
- 0, 1, 2, 3,
- BPS)
- CONVERT_2_BYTES_TO_HALF(temp5, temp6, temp7, temp8, temp17, temp18, temp10,
- temp11, temp10, temp11, temp14, temp15)
- STORE_SAT_SUM_X2(temp5, temp6, temp7, temp8, temp17, temp18, temp10, temp11,
- temp9, temp12, temp1, temp2, temp13, temp16, temp3, temp4,
- dst, 0, 1, 2, 3, BPS)
-
- OUTPUT_EARLY_CLOBBER_REGS_18()
- : [dst]"r"(dst), [in]"r"(in), [kC1]"r"(kC1), [kC2]"r"(kC2)
- : "memory", "hi", "lo"
- );
-}
-
-static void TransformTwo(const int16_t* in, uint8_t* dst, int do_two) {
- TransformOne(in, dst);
- if (do_two) {
- TransformOne(in + 16, dst + 4);
- }
-}
-
-static WEBP_INLINE void FilterLoop26(uint8_t* p,
- int hstride, int vstride, int size,
- int thresh, int ithresh, int hev_thresh) {
- const int thresh2 = 2 * thresh + 1;
- int temp1, temp2, temp3, temp4, temp5, temp6, temp7, temp8, temp9;
- int temp10, temp11, temp12, temp13, temp14, temp15;
-
- __asm__ volatile (
- ".set push \n\t"
- ".set noreorder \n\t"
- "1: \n\t"
- "negu %[temp1], %[hstride] \n\t"
- "addiu %[size], %[size], -1 \n\t"
- "sll %[temp2], %[hstride], 1 \n\t"
- "sll %[temp3], %[temp1], 1 \n\t"
- "addu %[temp4], %[temp2], %[hstride] \n\t"
- "addu %[temp5], %[temp3], %[temp1] \n\t"
- "lbu %[temp7], 0(%[p]) \n\t"
- "sll %[temp6], %[temp3], 1 \n\t"
- "lbux %[temp8], %[temp5](%[p]) \n\t"
- "lbux %[temp9], %[temp3](%[p]) \n\t"
- "lbux %[temp10], %[temp1](%[p]) \n\t"
- "lbux %[temp11], %[temp6](%[p]) \n\t"
- "lbux %[temp12], %[hstride](%[p]) \n\t"
- "lbux %[temp13], %[temp2](%[p]) \n\t"
- "lbux %[temp14], %[temp4](%[p]) \n\t"
- "subu %[temp1], %[temp10], %[temp7] \n\t"
- "subu %[temp2], %[temp9], %[temp12] \n\t"
- "absq_s.w %[temp3], %[temp1] \n\t"
- "absq_s.w %[temp4], %[temp2] \n\t"
- "negu %[temp1], %[temp1] \n\t"
- "sll %[temp3], %[temp3], 2 \n\t"
- "addu %[temp15], %[temp3], %[temp4] \n\t"
- "subu %[temp3], %[temp15], %[thresh2] \n\t"
- "sll %[temp6], %[temp1], 1 \n\t"
- "bgtz %[temp3], 3f \n\t"
- " subu %[temp4], %[temp11], %[temp8] \n\t"
- "absq_s.w %[temp4], %[temp4] \n\t"
- "shll_s.w %[temp2], %[temp2], 24 \n\t"
- "subu %[temp4], %[temp4], %[ithresh] \n\t"
- "bgtz %[temp4], 3f \n\t"
- " subu %[temp3], %[temp8], %[temp9] \n\t"
- "absq_s.w %[temp3], %[temp3] \n\t"
- "subu %[temp3], %[temp3], %[ithresh] \n\t"
- "bgtz %[temp3], 3f \n\t"
- " subu %[temp5], %[temp9], %[temp10] \n\t"
- "absq_s.w %[temp3], %[temp5] \n\t"
- "absq_s.w %[temp5], %[temp5] \n\t"
- "subu %[temp3], %[temp3], %[ithresh] \n\t"
- "bgtz %[temp3], 3f \n\t"
- " subu %[temp3], %[temp14], %[temp13] \n\t"
- "absq_s.w %[temp3], %[temp3] \n\t"
- "slt %[temp5], %[hev_thresh], %[temp5] \n\t"
- "subu %[temp3], %[temp3], %[ithresh] \n\t"
- "bgtz %[temp3], 3f \n\t"
- " subu %[temp3], %[temp13], %[temp12] \n\t"
- "absq_s.w %[temp3], %[temp3] \n\t"
- "sra %[temp4], %[temp2], 24 \n\t"
- "subu %[temp3], %[temp3], %[ithresh] \n\t"
- "bgtz %[temp3], 3f \n\t"
- " subu %[temp15], %[temp12], %[temp7] \n\t"
- "absq_s.w %[temp3], %[temp15] \n\t"
- "absq_s.w %[temp15], %[temp15] \n\t"
- "subu %[temp3], %[temp3], %[ithresh] \n\t"
- "bgtz %[temp3], 3f \n\t"
- " slt %[temp15], %[hev_thresh], %[temp15] \n\t"
- "addu %[temp3], %[temp6], %[temp1] \n\t"
- "or %[temp2], %[temp5], %[temp15] \n\t"
- "addu %[temp5], %[temp4], %[temp3] \n\t"
- "beqz %[temp2], 4f \n\t"
- " shra_r.w %[temp1], %[temp5], 3 \n\t"
- "addiu %[temp2], %[temp5], 3 \n\t"
- "sra %[temp2], %[temp2], 3 \n\t"
- "shll_s.w %[temp1], %[temp1], 27 \n\t"
- "shll_s.w %[temp2], %[temp2], 27 \n\t"
- "subu %[temp3], %[p], %[hstride] \n\t"
- "sra %[temp1], %[temp1], 27 \n\t"
- "sra %[temp2], %[temp2], 27 \n\t"
- "subu %[temp1], %[temp7], %[temp1] \n\t"
- "addu %[temp2], %[temp10], %[temp2] \n\t"
- "lbux %[temp2], %[temp2](%[VP8kclip1]) \n\t"
- "lbux %[temp1], %[temp1](%[VP8kclip1]) \n\t"
- "sb %[temp2], 0(%[temp3]) \n\t"
- "j 3f \n\t"
- " sb %[temp1], 0(%[p]) \n\t"
- "4: \n\t"
- "shll_s.w %[temp5], %[temp5], 24 \n\t"
- "subu %[temp14], %[p], %[hstride] \n\t"
- "subu %[temp11], %[temp14], %[hstride] \n\t"
- "sra %[temp6], %[temp5], 24 \n\t"
- "sll %[temp1], %[temp6], 3 \n\t"
- "subu %[temp15], %[temp11], %[hstride] \n\t"
- "addu %[temp2], %[temp6], %[temp1] \n\t"
- "sll %[temp3], %[temp2], 1 \n\t"
- "addu %[temp4], %[temp3], %[temp2] \n\t"
- "addiu %[temp2], %[temp2], 63 \n\t"
- "addiu %[temp3], %[temp3], 63 \n\t"
- "addiu %[temp4], %[temp4], 63 \n\t"
- "sra %[temp2], %[temp2], 7 \n\t"
- "sra %[temp3], %[temp3], 7 \n\t"
- "sra %[temp4], %[temp4], 7 \n\t"
- "addu %[temp1], %[temp8], %[temp2] \n\t"
- "addu %[temp5], %[temp9], %[temp3] \n\t"
- "addu %[temp6], %[temp10], %[temp4] \n\t"
- "subu %[temp8], %[temp7], %[temp4] \n\t"
- "subu %[temp7], %[temp12], %[temp3] \n\t"
- "addu %[temp10], %[p], %[hstride] \n\t"
- "subu %[temp9], %[temp13], %[temp2] \n\t"
- "addu %[temp12], %[temp10], %[hstride] \n\t"
- "lbux %[temp2], %[temp1](%[VP8kclip1]) \n\t"
- "lbux %[temp3], %[temp5](%[VP8kclip1]) \n\t"
- "lbux %[temp4], %[temp6](%[VP8kclip1]) \n\t"
- "lbux %[temp5], %[temp8](%[VP8kclip1]) \n\t"
- "lbux %[temp6], %[temp7](%[VP8kclip1]) \n\t"
- "lbux %[temp8], %[temp9](%[VP8kclip1]) \n\t"
- "sb %[temp2], 0(%[temp15]) \n\t"
- "sb %[temp3], 0(%[temp11]) \n\t"
- "sb %[temp4], 0(%[temp14]) \n\t"
- "sb %[temp5], 0(%[p]) \n\t"
- "sb %[temp6], 0(%[temp10]) \n\t"
- "sb %[temp8], 0(%[temp12]) \n\t"
- "3: \n\t"
- "bgtz %[size], 1b \n\t"
- " addu %[p], %[p], %[vstride] \n\t"
- ".set pop \n\t"
- : [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),[temp3]"=&r"(temp3),
- [temp4]"=&r"(temp4), [temp5]"=&r"(temp5), [temp6]"=&r"(temp6),
- [temp7]"=&r"(temp7),[temp8]"=&r"(temp8),[temp9]"=&r"(temp9),
- [temp10]"=&r"(temp10),[temp11]"=&r"(temp11),[temp12]"=&r"(temp12),
- [temp13]"=&r"(temp13),[temp14]"=&r"(temp14),[temp15]"=&r"(temp15),
- [size]"+&r"(size), [p]"+&r"(p)
- : [hstride]"r"(hstride), [thresh2]"r"(thresh2),
- [ithresh]"r"(ithresh),[vstride]"r"(vstride), [hev_thresh]"r"(hev_thresh),
- [VP8kclip1]"r"(VP8kclip1)
- : "memory"
- );
-}
-
-static WEBP_INLINE void FilterLoop24(uint8_t* p,
- int hstride, int vstride, int size,
- int thresh, int ithresh, int hev_thresh) {
- int p0, q0, p1, q1, p2, q2, p3, q3;
- int step1, step2, temp1, temp2, temp3, temp4;
- uint8_t* pTemp0;
- uint8_t* pTemp1;
- const int thresh2 = 2 * thresh + 1;
-
- __asm__ volatile (
- ".set push \n\t"
- ".set noreorder \n\t"
- "bltz %[size], 3f \n\t"
- " nop \n\t"
- "2: \n\t"
- "negu %[step1], %[hstride] \n\t"
- "lbu %[q0], 0(%[p]) \n\t"
- "lbux %[p0], %[step1](%[p]) \n\t"
- "subu %[step1], %[step1], %[hstride] \n\t"
- "lbux %[q1], %[hstride](%[p]) \n\t"
- "subu %[temp1], %[p0], %[q0] \n\t"
- "lbux %[p1], %[step1](%[p]) \n\t"
- "addu %[step2], %[hstride], %[hstride] \n\t"
- "absq_s.w %[temp2], %[temp1] \n\t"
- "subu %[temp3], %[p1], %[q1] \n\t"
- "absq_s.w %[temp4], %[temp3] \n\t"
- "sll %[temp2], %[temp2], 2 \n\t"
- "addu %[temp2], %[temp2], %[temp4] \n\t"
- "subu %[temp4], %[temp2], %[thresh2] \n\t"
- "subu %[step1], %[step1], %[hstride] \n\t"
- "bgtz %[temp4], 0f \n\t"
- " lbux %[p2], %[step1](%[p]) \n\t"
- "subu %[step1], %[step1], %[hstride] \n\t"
- "lbux %[q2], %[step2](%[p]) \n\t"
- "lbux %[p3], %[step1](%[p]) \n\t"
- "subu %[temp4], %[p2], %[p1] \n\t"
- "addu %[step2], %[step2], %[hstride] \n\t"
- "subu %[temp2], %[p3], %[p2] \n\t"
- "absq_s.w %[temp4], %[temp4] \n\t"
- "absq_s.w %[temp2], %[temp2] \n\t"
- "lbux %[q3], %[step2](%[p]) \n\t"
- "subu %[temp4], %[temp4], %[ithresh] \n\t"
- "negu %[temp1], %[temp1] \n\t"
- "bgtz %[temp4], 0f \n\t"
- " subu %[temp2], %[temp2], %[ithresh] \n\t"
- "subu %[p3], %[p1], %[p0] \n\t"
- "bgtz %[temp2], 0f \n\t"
- " absq_s.w %[p3], %[p3] \n\t"
- "subu %[temp4], %[q3], %[q2] \n\t"
- "subu %[pTemp0], %[p], %[hstride] \n\t"
- "absq_s.w %[temp4], %[temp4] \n\t"
- "subu %[temp2], %[p3], %[ithresh] \n\t"
- "sll %[step1], %[temp1], 1 \n\t"
- "bgtz %[temp2], 0f \n\t"
- " subu %[temp4], %[temp4], %[ithresh] \n\t"
- "subu %[temp2], %[q2], %[q1] \n\t"
- "bgtz %[temp4], 0f \n\t"
- " absq_s.w %[temp2], %[temp2] \n\t"
- "subu %[q3], %[q1], %[q0] \n\t"
- "absq_s.w %[q3], %[q3] \n\t"
- "subu %[temp2], %[temp2], %[ithresh] \n\t"
- "addu %[temp1], %[temp1], %[step1] \n\t"
- "bgtz %[temp2], 0f \n\t"
- " subu %[temp4], %[q3], %[ithresh] \n\t"
- "slt %[p3], %[hev_thresh], %[p3] \n\t"
- "bgtz %[temp4], 0f \n\t"
- " slt %[q3], %[hev_thresh], %[q3] \n\t"
- "or %[q3], %[q3], %[p3] \n\t"
- "bgtz %[q3], 1f \n\t"
- " shra_r.w %[temp2], %[temp1], 3 \n\t"
- "addiu %[temp1], %[temp1], 3 \n\t"
- "sra %[temp1], %[temp1], 3 \n\t"
- "shll_s.w %[temp2], %[temp2], 27 \n\t"
- "shll_s.w %[temp1], %[temp1], 27 \n\t"
- "addu %[pTemp1], %[p], %[hstride] \n\t"
- "sra %[temp2], %[temp2], 27 \n\t"
- "sra %[temp1], %[temp1], 27 \n\t"
- "addiu %[step1], %[temp2], 1 \n\t"
- "sra %[step1], %[step1], 1 \n\t"
- "addu %[p0], %[p0], %[temp1] \n\t"
- "addu %[p1], %[p1], %[step1] \n\t"
- "subu %[q0], %[q0], %[temp2] \n\t"
- "subu %[q1], %[q1], %[step1] \n\t"
- "lbux %[temp2], %[p0](%[VP8kclip1]) \n\t"
- "lbux %[temp3], %[q0](%[VP8kclip1]) \n\t"
- "lbux %[temp4], %[q1](%[VP8kclip1]) \n\t"
- "sb %[temp2], 0(%[pTemp0]) \n\t"
- "lbux %[temp1], %[p1](%[VP8kclip1]) \n\t"
- "subu %[pTemp0], %[pTemp0], %[hstride] \n\t"
- "sb %[temp3], 0(%[p]) \n\t"
- "sb %[temp4], 0(%[pTemp1]) \n\t"
- "j 0f \n\t"
- " sb %[temp1], 0(%[pTemp0]) \n\t"
- "1: \n\t"
- "shll_s.w %[temp3], %[temp3], 24 \n\t"
- "sra %[temp3], %[temp3], 24 \n\t"
- "addu %[temp1], %[temp1], %[temp3] \n\t"
- "shra_r.w %[temp2], %[temp1], 3 \n\t"
- "addiu %[temp1], %[temp1], 3 \n\t"
- "shll_s.w %[temp2], %[temp2], 27 \n\t"
- "sra %[temp1], %[temp1], 3 \n\t"
- "shll_s.w %[temp1], %[temp1], 27 \n\t"
- "sra %[temp2], %[temp2], 27 \n\t"
- "sra %[temp1], %[temp1], 27 \n\t"
- "addu %[p0], %[p0], %[temp1] \n\t"
- "subu %[q0], %[q0], %[temp2] \n\t"
- "lbux %[temp1], %[p0](%[VP8kclip1]) \n\t"
- "lbux %[temp2], %[q0](%[VP8kclip1]) \n\t"
- "sb %[temp2], 0(%[p]) \n\t"
- "sb %[temp1], 0(%[pTemp0]) \n\t"
- "0: \n\t"
- "subu %[size], %[size], 1 \n\t"
- "bgtz %[size], 2b \n\t"
- " addu %[p], %[p], %[vstride] \n\t"
- "3: \n\t"
- ".set pop \n\t"
- : [p0]"=&r"(p0), [q0]"=&r"(q0), [p1]"=&r"(p1), [q1]"=&r"(q1),
- [p2]"=&r"(p2), [q2]"=&r"(q2), [p3]"=&r"(p3), [q3]"=&r"(q3),
- [step2]"=&r"(step2), [step1]"=&r"(step1), [temp1]"=&r"(temp1),
- [temp2]"=&r"(temp2), [temp3]"=&r"(temp3), [temp4]"=&r"(temp4),
- [pTemp0]"=&r"(pTemp0), [pTemp1]"=&r"(pTemp1), [p]"+&r"(p),
- [size]"+&r"(size)
- : [vstride]"r"(vstride), [ithresh]"r"(ithresh),
- [hev_thresh]"r"(hev_thresh), [hstride]"r"(hstride),
- [VP8kclip1]"r"(VP8kclip1), [thresh2]"r"(thresh2)
- : "memory"
- );
-}
-
-// on macroblock edges
-static void VFilter16(uint8_t* p, int stride,
- int thresh, int ithresh, int hev_thresh) {
- FilterLoop26(p, stride, 1, 16, thresh, ithresh, hev_thresh);
-}
-
-static void HFilter16(uint8_t* p, int stride,
- int thresh, int ithresh, int hev_thresh) {
- FilterLoop26(p, 1, stride, 16, thresh, ithresh, hev_thresh);
-}
-
-// 8-pixels wide variant, for chroma filtering
-static void VFilter8(uint8_t* u, uint8_t* v, int stride,
- int thresh, int ithresh, int hev_thresh) {
- FilterLoop26(u, stride, 1, 8, thresh, ithresh, hev_thresh);
- FilterLoop26(v, stride, 1, 8, thresh, ithresh, hev_thresh);
-}
-
-static void HFilter8(uint8_t* u, uint8_t* v, int stride,
- int thresh, int ithresh, int hev_thresh) {
- FilterLoop26(u, 1, stride, 8, thresh, ithresh, hev_thresh);
- FilterLoop26(v, 1, stride, 8, thresh, ithresh, hev_thresh);
-}
-
-// on three inner edges
-static void VFilter16i(uint8_t* p, int stride,
- int thresh, int ithresh, int hev_thresh) {
- int k;
- for (k = 3; k > 0; --k) {
- p += 4 * stride;
- FilterLoop24(p, stride, 1, 16, thresh, ithresh, hev_thresh);
- }
-}
-
-static void HFilter16i(uint8_t* p, int stride,
- int thresh, int ithresh, int hev_thresh) {
- int k;
- for (k = 3; k > 0; --k) {
- p += 4;
- FilterLoop24(p, 1, stride, 16, thresh, ithresh, hev_thresh);
- }
-}
-
-static void VFilter8i(uint8_t* u, uint8_t* v, int stride,
- int thresh, int ithresh, int hev_thresh) {
- FilterLoop24(u + 4 * stride, stride, 1, 8, thresh, ithresh, hev_thresh);
- FilterLoop24(v + 4 * stride, stride, 1, 8, thresh, ithresh, hev_thresh);
-}
-
-static void HFilter8i(uint8_t* u, uint8_t* v, int stride,
- int thresh, int ithresh, int hev_thresh) {
- FilterLoop24(u + 4, 1, stride, 8, thresh, ithresh, hev_thresh);
- FilterLoop24(v + 4, 1, stride, 8, thresh, ithresh, hev_thresh);
-}
-
-#undef MUL
-
-//------------------------------------------------------------------------------
-// Simple In-loop filtering (Paragraph 15.2)
-
-static void SimpleVFilter16(uint8_t* p, int stride, int thresh) {
- int i;
- const int thresh2 = 2 * thresh + 1;
- int temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7, temp8;
- uint8_t* p1 = p - stride;
- __asm__ volatile (
- ".set push \n\t"
- ".set noreorder \n\t"
- "li %[i], 16 \n\t"
- "0: \n\t"
- "negu %[temp4], %[stride] \n\t"
- "sll %[temp5], %[temp4], 1 \n\t"
- "lbu %[temp2], 0(%[p]) \n\t"
- "lbux %[temp3], %[stride](%[p]) \n\t"
- "lbux %[temp1], %[temp4](%[p]) \n\t"
- "lbux %[temp0], %[temp5](%[p]) \n\t"
- "subu %[temp7], %[temp1], %[temp2] \n\t"
- "subu %[temp6], %[temp0], %[temp3] \n\t"
- "absq_s.w %[temp4], %[temp7] \n\t"
- "absq_s.w %[temp5], %[temp6] \n\t"
- "sll %[temp4], %[temp4], 2 \n\t"
- "subu %[temp5], %[temp5], %[thresh2] \n\t"
- "addu %[temp5], %[temp4], %[temp5] \n\t"
- "negu %[temp8], %[temp7] \n\t"
- "bgtz %[temp5], 1f \n\t"
- " addiu %[i], %[i], -1 \n\t"
- "sll %[temp4], %[temp8], 1 \n\t"
- "shll_s.w %[temp5], %[temp6], 24 \n\t"
- "addu %[temp3], %[temp4], %[temp8] \n\t"
- "sra %[temp5], %[temp5], 24 \n\t"
- "addu %[temp3], %[temp3], %[temp5] \n\t"
- "addiu %[temp7], %[temp3], 3 \n\t"
- "sra %[temp7], %[temp7], 3 \n\t"
- "shra_r.w %[temp8], %[temp3], 3 \n\t"
- "shll_s.w %[temp0], %[temp7], 27 \n\t"
- "shll_s.w %[temp4], %[temp8], 27 \n\t"
- "sra %[temp0], %[temp0], 27 \n\t"
- "sra %[temp4], %[temp4], 27 \n\t"
- "addu %[temp7], %[temp1], %[temp0] \n\t"
- "subu %[temp2], %[temp2], %[temp4] \n\t"
- "lbux %[temp3], %[temp7](%[VP8kclip1]) \n\t"
- "lbux %[temp4], %[temp2](%[VP8kclip1]) \n\t"
- "sb %[temp3], 0(%[p1]) \n\t"
- "sb %[temp4], 0(%[p]) \n\t"
- "1: \n\t"
- "addiu %[p1], %[p1], 1 \n\t"
- "bgtz %[i], 0b \n\t"
- " addiu %[p], %[p], 1 \n\t"
- " .set pop \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [temp4]"=&r"(temp4), [temp5]"=&r"(temp5),
- [temp6]"=&r"(temp6), [temp7]"=&r"(temp7), [temp8]"=&r"(temp8),
- [p]"+&r"(p), [i]"=&r"(i), [p1]"+&r"(p1)
- : [stride]"r"(stride), [VP8kclip1]"r"(VP8kclip1), [thresh2]"r"(thresh2)
- : "memory"
- );
-}
-
-// TEMP0 = SRC[A + A1 * BPS]
-// TEMP1 = SRC[B + B1 * BPS]
-// TEMP2 = SRC[C + C1 * BPS]
-// TEMP3 = SRC[D + D1 * BPS]
-#define LOAD_4_BYTES(TEMP0, TEMP1, TEMP2, TEMP3, \
- A, A1, B, B1, C, C1, D, D1, SRC) \
- "lbu %[" #TEMP0 "], " #A "+" #A1 "*" XSTR(BPS) "(%[" #SRC "]) \n\t" \
- "lbu %[" #TEMP1 "], " #B "+" #B1 "*" XSTR(BPS) "(%[" #SRC "]) \n\t" \
- "lbu %[" #TEMP2 "], " #C "+" #C1 "*" XSTR(BPS) "(%[" #SRC "]) \n\t" \
- "lbu %[" #TEMP3 "], " #D "+" #D1 "*" XSTR(BPS) "(%[" #SRC "]) \n\t" \
-
-static void SimpleHFilter16(uint8_t* p, int stride, int thresh) {
- int i;
- const int thresh2 = 2 * thresh + 1;
- int temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7, temp8;
- __asm__ volatile (
- ".set push \n\t"
- ".set noreorder \n\t"
- "li %[i], 16 \n\t"
- "0: \n\t"
- LOAD_4_BYTES(temp0, temp1, temp2, temp3, -2, 0, -1, 0, 0, 0, 1, 0, p)
- "subu %[temp7], %[temp1], %[temp2] \n\t"
- "subu %[temp6], %[temp0], %[temp3] \n\t"
- "absq_s.w %[temp4], %[temp7] \n\t"
- "absq_s.w %[temp5], %[temp6] \n\t"
- "sll %[temp4], %[temp4], 2 \n\t"
- "addu %[temp5], %[temp4], %[temp5] \n\t"
- "subu %[temp5], %[temp5], %[thresh2] \n\t"
- "negu %[temp8], %[temp7] \n\t"
- "bgtz %[temp5], 1f \n\t"
- " addiu %[i], %[i], -1 \n\t"
- "sll %[temp4], %[temp8], 1 \n\t"
- "shll_s.w %[temp5], %[temp6], 24 \n\t"
- "addu %[temp3], %[temp4], %[temp8] \n\t"
- "sra %[temp5], %[temp5], 24 \n\t"
- "addu %[temp3], %[temp3], %[temp5] \n\t"
- "addiu %[temp7], %[temp3], 3 \n\t"
- "sra %[temp7], %[temp7], 3 \n\t"
- "shra_r.w %[temp8], %[temp3], 3 \n\t"
- "shll_s.w %[temp0], %[temp7], 27 \n\t"
- "shll_s.w %[temp4], %[temp8], 27 \n\t"
- "sra %[temp0], %[temp0], 27 \n\t"
- "sra %[temp4], %[temp4], 27 \n\t"
- "addu %[temp7], %[temp1], %[temp0] \n\t"
- "subu %[temp2], %[temp2], %[temp4] \n\t"
- "lbux %[temp3], %[temp7](%[VP8kclip1]) \n\t"
- "lbux %[temp4], %[temp2](%[VP8kclip1]) \n\t"
- "sb %[temp3], -1(%[p]) \n\t"
- "sb %[temp4], 0(%[p]) \n\t"
- "1: \n\t"
- "bgtz %[i], 0b \n\t"
- " addu %[p], %[p], %[stride] \n\t"
- ".set pop \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [temp4]"=&r"(temp4), [temp5]"=&r"(temp5),
- [temp6]"=&r"(temp6), [temp7]"=&r"(temp7), [temp8]"=&r"(temp8),
- [p]"+&r"(p), [i]"=&r"(i)
- : [stride]"r"(stride), [VP8kclip1]"r"(VP8kclip1), [thresh2]"r"(thresh2)
- : "memory"
- );
-}
-
-static void SimpleVFilter16i(uint8_t* p, int stride, int thresh) {
- int k;
- for (k = 3; k > 0; --k) {
- p += 4 * stride;
- SimpleVFilter16(p, stride, thresh);
- }
-}
-
-static void SimpleHFilter16i(uint8_t* p, int stride, int thresh) {
- int k;
- for (k = 3; k > 0; --k) {
- p += 4;
- SimpleHFilter16(p, stride, thresh);
- }
-}
-
-// DST[A * BPS] = TEMP0
-// DST[B + C * BPS] = TEMP1
-#define STORE_8_BYTES(TEMP0, TEMP1, A, B, C, DST) \
- "usw %[" #TEMP0 "], " #A "*" XSTR(BPS) "(%[" #DST "]) \n\t" \
- "usw %[" #TEMP1 "], " #B "+" #C "*" XSTR(BPS) "(%[" #DST "]) \n\t"
-
-static void VE4(uint8_t* dst) { // vertical
- const uint8_t* top = dst - BPS;
- int temp0, temp1, temp2, temp3, temp4, temp5, temp6;
- __asm__ volatile (
- "ulw %[temp0], -1(%[top]) \n\t"
- "ulh %[temp1], 3(%[top]) \n\t"
- "preceu.ph.qbr %[temp2], %[temp0] \n\t"
- "preceu.ph.qbl %[temp3], %[temp0] \n\t"
- "preceu.ph.qbr %[temp4], %[temp1] \n\t"
- "packrl.ph %[temp5], %[temp3], %[temp2] \n\t"
- "packrl.ph %[temp6], %[temp4], %[temp3] \n\t"
- "shll.ph %[temp5], %[temp5], 1 \n\t"
- "shll.ph %[temp6], %[temp6], 1 \n\t"
- "addq.ph %[temp2], %[temp5], %[temp2] \n\t"
- "addq.ph %[temp6], %[temp6], %[temp4] \n\t"
- "addq.ph %[temp2], %[temp2], %[temp3] \n\t"
- "addq.ph %[temp6], %[temp6], %[temp3] \n\t"
- "shra_r.ph %[temp2], %[temp2], 2 \n\t"
- "shra_r.ph %[temp6], %[temp6], 2 \n\t"
- "precr.qb.ph %[temp4], %[temp6], %[temp2] \n\t"
- STORE_8_BYTES(temp4, temp4, 0, 0, 1, dst)
- STORE_8_BYTES(temp4, temp4, 2, 0, 3, dst)
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [temp4]"=&r"(temp4), [temp5]"=&r"(temp5),
- [temp6]"=&r"(temp6)
- : [top]"r"(top), [dst]"r"(dst)
- : "memory"
- );
-}
-
-static void DC4(uint8_t* dst) { // DC
- int temp0, temp1, temp2, temp3, temp4;
- __asm__ volatile (
- "ulw %[temp0], -1*" XSTR(BPS) "(%[dst]) \n\t"
- LOAD_4_BYTES(temp1, temp2, temp3, temp4, -1, 0, -1, 1, -1, 2, -1, 3, dst)
- "ins %[temp1], %[temp2], 8, 8 \n\t"
- "ins %[temp1], %[temp3], 16, 8 \n\t"
- "ins %[temp1], %[temp4], 24, 8 \n\t"
- "raddu.w.qb %[temp0], %[temp0] \n\t"
- "raddu.w.qb %[temp1], %[temp1] \n\t"
- "addu %[temp0], %[temp0], %[temp1] \n\t"
- "shra_r.w %[temp0], %[temp0], 3 \n\t"
- "replv.qb %[temp0], %[temp0] \n\t"
- STORE_8_BYTES(temp0, temp0, 0, 0, 1, dst)
- STORE_8_BYTES(temp0, temp0, 2, 0, 3, dst)
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [temp4]"=&r"(temp4)
- : [dst]"r"(dst)
- : "memory"
- );
-}
-
-static void RD4(uint8_t* dst) { // Down-right
- int temp0, temp1, temp2, temp3, temp4;
- int temp5, temp6, temp7, temp8;
- __asm__ volatile (
- LOAD_4_BYTES(temp0, temp1, temp2, temp3, -1, 0, -1, 1, -1, 2, -1, 3, dst)
- "ulw %[temp7], -1-" XSTR(BPS) "(%[dst]) \n\t"
- "ins %[temp1], %[temp0], 16, 16 \n\t"
- "preceu.ph.qbr %[temp5], %[temp7] \n\t"
- "ins %[temp2], %[temp1], 16, 16 \n\t"
- "preceu.ph.qbl %[temp4], %[temp7] \n\t"
- "ins %[temp3], %[temp2], 16, 16 \n\t"
- "shll.ph %[temp2], %[temp2], 1 \n\t"
- "addq.ph %[temp3], %[temp3], %[temp1] \n\t"
- "packrl.ph %[temp6], %[temp5], %[temp1] \n\t"
- "addq.ph %[temp3], %[temp3], %[temp2] \n\t"
- "addq.ph %[temp1], %[temp1], %[temp5] \n\t"
- "shll.ph %[temp6], %[temp6], 1 \n\t"
- "addq.ph %[temp1], %[temp1], %[temp6] \n\t"
- "packrl.ph %[temp0], %[temp4], %[temp5] \n\t"
- "addq.ph %[temp8], %[temp5], %[temp4] \n\t"
- "shra_r.ph %[temp3], %[temp3], 2 \n\t"
- "shll.ph %[temp0], %[temp0], 1 \n\t"
- "shra_r.ph %[temp1], %[temp1], 2 \n\t"
- "addq.ph %[temp8], %[temp0], %[temp8] \n\t"
- "lbu %[temp5], 3-" XSTR(BPS) "(%[dst]) \n\t"
- "precrq.ph.w %[temp7], %[temp7], %[temp7] \n\t"
- "shra_r.ph %[temp8], %[temp8], 2 \n\t"
- "ins %[temp7], %[temp5], 0, 8 \n\t"
- "precr.qb.ph %[temp2], %[temp1], %[temp3] \n\t"
- "raddu.w.qb %[temp4], %[temp7] \n\t"
- "precr.qb.ph %[temp6], %[temp8], %[temp1] \n\t"
- "shra_r.w %[temp4], %[temp4], 2 \n\t"
- STORE_8_BYTES(temp2, temp6, 3, 0, 1, dst)
- "prepend %[temp2], %[temp8], 8 \n\t"
- "prepend %[temp6], %[temp4], 8 \n\t"
- STORE_8_BYTES(temp2, temp6, 2, 0, 0, dst)
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [temp4]"=&r"(temp4), [temp5]"=&r"(temp5),
- [temp6]"=&r"(temp6), [temp7]"=&r"(temp7), [temp8]"=&r"(temp8)
- : [dst]"r"(dst)
- : "memory"
- );
-}
-
-// TEMP0 = SRC[A * BPS]
-// TEMP1 = SRC[B + C * BPS]
-#define LOAD_8_BYTES(TEMP0, TEMP1, A, B, C, SRC) \
- "ulw %[" #TEMP0 "], " #A "*" XSTR(BPS) "(%[" #SRC "]) \n\t" \
- "ulw %[" #TEMP1 "], " #B "+" #C "*" XSTR(BPS) "(%[" #SRC "]) \n\t"
-
-static void LD4(uint8_t* dst) { // Down-Left
- int temp0, temp1, temp2, temp3, temp4;
- int temp5, temp6, temp7, temp8, temp9;
- __asm__ volatile (
- LOAD_8_BYTES(temp0, temp1, -1, 4, -1, dst)
- "preceu.ph.qbl %[temp2], %[temp0] \n\t"
- "preceu.ph.qbr %[temp3], %[temp0] \n\t"
- "preceu.ph.qbr %[temp4], %[temp1] \n\t"
- "preceu.ph.qbl %[temp5], %[temp1] \n\t"
- "packrl.ph %[temp6], %[temp2], %[temp3] \n\t"
- "packrl.ph %[temp7], %[temp4], %[temp2] \n\t"
- "packrl.ph %[temp8], %[temp5], %[temp4] \n\t"
- "shll.ph %[temp6], %[temp6], 1 \n\t"
- "addq.ph %[temp9], %[temp2], %[temp6] \n\t"
- "shll.ph %[temp7], %[temp7], 1 \n\t"
- "addq.ph %[temp9], %[temp9], %[temp3] \n\t"
- "shll.ph %[temp8], %[temp8], 1 \n\t"
- "shra_r.ph %[temp9], %[temp9], 2 \n\t"
- "addq.ph %[temp3], %[temp4], %[temp7] \n\t"
- "addq.ph %[temp0], %[temp5], %[temp8] \n\t"
- "addq.ph %[temp3], %[temp3], %[temp2] \n\t"
- "addq.ph %[temp0], %[temp0], %[temp4] \n\t"
- "shra_r.ph %[temp3], %[temp3], 2 \n\t"
- "shra_r.ph %[temp0], %[temp0], 2 \n\t"
- "srl %[temp1], %[temp1], 24 \n\t"
- "sll %[temp1], %[temp1], 1 \n\t"
- "raddu.w.qb %[temp5], %[temp5] \n\t"
- "precr.qb.ph %[temp9], %[temp3], %[temp9] \n\t"
- "precr.qb.ph %[temp3], %[temp0], %[temp3] \n\t"
- "addu %[temp1], %[temp1], %[temp5] \n\t"
- "shra_r.w %[temp1], %[temp1], 2 \n\t"
- STORE_8_BYTES(temp9, temp3, 0, 0, 2, dst)
- "prepend %[temp9], %[temp0], 8 \n\t"
- "prepend %[temp3], %[temp1], 8 \n\t"
- STORE_8_BYTES(temp9, temp3, 1, 0, 3, dst)
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [temp4]"=&r"(temp4), [temp5]"=&r"(temp5),
- [temp6]"=&r"(temp6), [temp7]"=&r"(temp7), [temp8]"=&r"(temp8),
- [temp9]"=&r"(temp9)
- : [dst]"r"(dst)
- : "memory"
- );
-}
-
-//------------------------------------------------------------------------------
-// Chroma
-
-static void DC8uv(uint8_t* dst) { // DC
- int temp0, temp1, temp2, temp3, temp4;
- int temp5, temp6, temp7, temp8, temp9;
- __asm__ volatile (
- LOAD_8_BYTES(temp0, temp1, -1, 4, -1, dst)
- LOAD_4_BYTES(temp2, temp3, temp4, temp5, -1, 0, -1, 1, -1, 2, -1, 3, dst)
- LOAD_4_BYTES(temp6, temp7, temp8, temp9, -1, 4, -1, 5, -1, 6, -1, 7, dst)
- "raddu.w.qb %[temp0], %[temp0] \n\t"
- "raddu.w.qb %[temp1], %[temp1] \n\t"
- "addu %[temp2], %[temp2], %[temp3] \n\t"
- "addu %[temp4], %[temp4], %[temp5] \n\t"
- "addu %[temp6], %[temp6], %[temp7] \n\t"
- "addu %[temp8], %[temp8], %[temp9] \n\t"
- "addu %[temp0], %[temp0], %[temp1] \n\t"
- "addu %[temp2], %[temp2], %[temp4] \n\t"
- "addu %[temp6], %[temp6], %[temp8] \n\t"
- "addu %[temp0], %[temp0], %[temp2] \n\t"
- "addu %[temp0], %[temp0], %[temp6] \n\t"
- "shra_r.w %[temp0], %[temp0], 4 \n\t"
- "replv.qb %[temp0], %[temp0] \n\t"
- STORE_8_BYTES(temp0, temp0, 0, 4, 0, dst)
- STORE_8_BYTES(temp0, temp0, 1, 4, 1, dst)
- STORE_8_BYTES(temp0, temp0, 2, 4, 2, dst)
- STORE_8_BYTES(temp0, temp0, 3, 4, 3, dst)
- STORE_8_BYTES(temp0, temp0, 4, 4, 4, dst)
- STORE_8_BYTES(temp0, temp0, 5, 4, 5, dst)
- STORE_8_BYTES(temp0, temp0, 6, 4, 6, dst)
- STORE_8_BYTES(temp0, temp0, 7, 4, 7, dst)
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [temp4]"=&r"(temp4), [temp5]"=&r"(temp5),
- [temp6]"=&r"(temp6), [temp7]"=&r"(temp7), [temp8]"=&r"(temp8),
- [temp9]"=&r"(temp9)
- : [dst]"r"(dst)
- : "memory"
- );
-}
-
-static void DC8uvNoLeft(uint8_t* dst) { // DC with no left samples
- int temp0, temp1;
- __asm__ volatile (
- LOAD_8_BYTES(temp0, temp1, -1, 4, -1, dst)
- "raddu.w.qb %[temp0], %[temp0] \n\t"
- "raddu.w.qb %[temp1], %[temp1] \n\t"
- "addu %[temp0], %[temp0], %[temp1] \n\t"
- "shra_r.w %[temp0], %[temp0], 3 \n\t"
- "replv.qb %[temp0], %[temp0] \n\t"
- STORE_8_BYTES(temp0, temp0, 0, 4, 0, dst)
- STORE_8_BYTES(temp0, temp0, 1, 4, 1, dst)
- STORE_8_BYTES(temp0, temp0, 2, 4, 2, dst)
- STORE_8_BYTES(temp0, temp0, 3, 4, 3, dst)
- STORE_8_BYTES(temp0, temp0, 4, 4, 4, dst)
- STORE_8_BYTES(temp0, temp0, 5, 4, 5, dst)
- STORE_8_BYTES(temp0, temp0, 6, 4, 6, dst)
- STORE_8_BYTES(temp0, temp0, 7, 4, 7, dst)
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1)
- : [dst]"r"(dst)
- : "memory"
- );
-}
-
-static void DC8uvNoTop(uint8_t* dst) { // DC with no top samples
- int temp0, temp1, temp2, temp3, temp4;
- int temp5, temp6, temp7, temp8;
- __asm__ volatile (
- LOAD_4_BYTES(temp2, temp3, temp4, temp5, -1, 0, -1, 1, -1, 2, -1, 3, dst)
- LOAD_4_BYTES(temp6, temp7, temp8, temp1, -1, 4, -1, 5, -1, 6, -1, 7, dst)
- "addu %[temp2], %[temp2], %[temp3] \n\t"
- "addu %[temp4], %[temp4], %[temp5] \n\t"
- "addu %[temp6], %[temp6], %[temp7] \n\t"
- "addu %[temp8], %[temp8], %[temp1] \n\t"
- "addu %[temp2], %[temp2], %[temp4] \n\t"
- "addu %[temp6], %[temp6], %[temp8] \n\t"
- "addu %[temp0], %[temp6], %[temp2] \n\t"
- "shra_r.w %[temp0], %[temp0], 3 \n\t"
- "replv.qb %[temp0], %[temp0] \n\t"
- STORE_8_BYTES(temp0, temp0, 0, 4, 0, dst)
- STORE_8_BYTES(temp0, temp0, 1, 4, 1, dst)
- STORE_8_BYTES(temp0, temp0, 2, 4, 2, dst)
- STORE_8_BYTES(temp0, temp0, 3, 4, 3, dst)
- STORE_8_BYTES(temp0, temp0, 4, 4, 4, dst)
- STORE_8_BYTES(temp0, temp0, 5, 4, 5, dst)
- STORE_8_BYTES(temp0, temp0, 6, 4, 6, dst)
- STORE_8_BYTES(temp0, temp0, 7, 4, 7, dst)
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [temp4]"=&r"(temp4), [temp5]"=&r"(temp5),
- [temp6]"=&r"(temp6), [temp7]"=&r"(temp7), [temp8]"=&r"(temp8)
- : [dst]"r"(dst)
- : "memory"
- );
-}
-
-#undef LOAD_8_BYTES
-#undef STORE_8_BYTES
-#undef LOAD_4_BYTES
-
-#define CLIPPING(SIZE) \
- "preceu.ph.qbl %[temp2], %[temp0] \n\t" \
- "preceu.ph.qbr %[temp0], %[temp0] \n\t" \
-".if " #SIZE " == 8 \n\t" \
- "preceu.ph.qbl %[temp3], %[temp1] \n\t" \
- "preceu.ph.qbr %[temp1], %[temp1] \n\t" \
-".endif \n\t" \
- "addu.ph %[temp2], %[temp2], %[dst_1] \n\t" \
- "addu.ph %[temp0], %[temp0], %[dst_1] \n\t" \
-".if " #SIZE " == 8 \n\t" \
- "addu.ph %[temp3], %[temp3], %[dst_1] \n\t" \
- "addu.ph %[temp1], %[temp1], %[dst_1] \n\t" \
-".endif \n\t" \
- "shll_s.ph %[temp2], %[temp2], 7 \n\t" \
- "shll_s.ph %[temp0], %[temp0], 7 \n\t" \
-".if " #SIZE " == 8 \n\t" \
- "shll_s.ph %[temp3], %[temp3], 7 \n\t" \
- "shll_s.ph %[temp1], %[temp1], 7 \n\t" \
-".endif \n\t" \
- "precrqu_s.qb.ph %[temp0], %[temp2], %[temp0] \n\t" \
-".if " #SIZE " == 8 \n\t" \
- "precrqu_s.qb.ph %[temp1], %[temp3], %[temp1] \n\t" \
-".endif \n\t"
-
-
-#define CLIP_8B_TO_DST(DST, TOP, SIZE) do { \
- int dst_1 = ((int)(DST)[-1] << 16) + (DST)[-1]; \
- int temp0, temp1, temp2, temp3; \
- __asm__ volatile ( \
- ".if " #SIZE " < 8 \n\t" \
- "ulw %[temp0], 0(%[top]) \n\t" \
- "subu.ph %[dst_1], %[dst_1], %[top_1] \n\t" \
- CLIPPING(4) \
- "usw %[temp0], 0(%[dst]) \n\t" \
- ".else \n\t" \
- "ulw %[temp0], 0(%[top]) \n\t" \
- "ulw %[temp1], 4(%[top]) \n\t" \
- "subu.ph %[dst_1], %[dst_1], %[top_1] \n\t" \
- CLIPPING(8) \
- "usw %[temp0], 0(%[dst]) \n\t" \
- "usw %[temp1], 4(%[dst]) \n\t" \
- ".if " #SIZE " == 16 \n\t" \
- "ulw %[temp0], 8(%[top]) \n\t" \
- "ulw %[temp1], 12(%[top]) \n\t" \
- CLIPPING(8) \
- "usw %[temp0], 8(%[dst]) \n\t" \
- "usw %[temp1], 12(%[dst]) \n\t" \
- ".endif \n\t" \
- ".endif \n\t" \
- : [dst_1]"+&r"(dst_1), [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), \
- [temp2]"=&r"(temp2), [temp3]"=&r"(temp3) \
- : [top_1]"r"(top_1), [top]"r"((TOP)), [dst]"r"((DST)) \
- : "memory" \
- ); \
-} while (0)
-
-#define CLIP_TO_DST(DST, SIZE) do { \
- int y; \
- const uint8_t* top = (DST) - BPS; \
- const int top_1 = ((int)top[-1] << 16) + top[-1]; \
- for (y = 0; y < (SIZE); ++y) { \
- CLIP_8B_TO_DST((DST), top, (SIZE)); \
- (DST) += BPS; \
- } \
-} while (0)
-
-#define TRUE_MOTION(DST, SIZE) \
-static void TrueMotion##SIZE(uint8_t* (DST)) { \
- CLIP_TO_DST((DST), (SIZE)); \
-}
-
-TRUE_MOTION(dst, 4)
-TRUE_MOTION(dst, 8)
-TRUE_MOTION(dst, 16)
-
-#undef TRUE_MOTION
-#undef CLIP_TO_DST
-#undef CLIP_8B_TO_DST
-#undef CLIPPING
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void VP8DspInitMIPSdspR2(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void VP8DspInitMIPSdspR2(void) {
- VP8TransformDC = TransformDC;
- VP8TransformAC3 = TransformAC3;
- VP8Transform = TransformTwo;
-
- VP8VFilter16 = VFilter16;
- VP8HFilter16 = HFilter16;
- VP8VFilter8 = VFilter8;
- VP8HFilter8 = HFilter8;
- VP8VFilter16i = VFilter16i;
- VP8HFilter16i = HFilter16i;
- VP8VFilter8i = VFilter8i;
- VP8HFilter8i = HFilter8i;
- VP8SimpleVFilter16 = SimpleVFilter16;
- VP8SimpleHFilter16 = SimpleHFilter16;
- VP8SimpleVFilter16i = SimpleVFilter16i;
- VP8SimpleHFilter16i = SimpleHFilter16i;
-
- VP8PredLuma4[0] = DC4;
- VP8PredLuma4[1] = TrueMotion4;
- VP8PredLuma4[2] = VE4;
- VP8PredLuma4[4] = RD4;
- VP8PredLuma4[6] = LD4;
-
- VP8PredChroma8[0] = DC8uv;
- VP8PredChroma8[1] = TrueMotion8;
- VP8PredChroma8[4] = DC8uvNoTop;
- VP8PredChroma8[5] = DC8uvNoLeft;
-
- VP8PredLuma16[1] = TrueMotion16;
-}
-
-#else // !WEBP_USE_MIPS_DSP_R2
-
-WEBP_DSP_INIT_STUB(VP8DspInitMIPSdspR2)
-
-#endif // WEBP_USE_MIPS_DSP_R2
diff --git a/contrib/libs/libwebp/dsp/dec_msa.c b/contrib/libs/libwebp/dsp/dec_msa.c
deleted file mode 100644
index cc1e285086..0000000000
--- a/contrib/libs/libwebp/dsp/dec_msa.c
+++ /dev/null
@@ -1,1020 +0,0 @@
-// Copyright 2016 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// MSA version of dsp functions
-//
-// Author(s): Prashant Patil (prashant.patil@imgtec.com)
-
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_MSA)
-
-#include "./msa_macro.h"
-
-//------------------------------------------------------------------------------
-// Transforms
-
-#define IDCT_1D_W(in0, in1, in2, in3, out0, out1, out2, out3) { \
- v4i32 a1_m, b1_m, c1_m, d1_m; \
- v4i32 c_tmp1_m, c_tmp2_m, d_tmp1_m, d_tmp2_m; \
- const v4i32 cospi8sqrt2minus1 = __msa_fill_w(20091); \
- const v4i32 sinpi8sqrt2 = __msa_fill_w(35468); \
- \
- a1_m = in0 + in2; \
- b1_m = in0 - in2; \
- c_tmp1_m = (in1 * sinpi8sqrt2) >> 16; \
- c_tmp2_m = in3 + ((in3 * cospi8sqrt2minus1) >> 16); \
- c1_m = c_tmp1_m - c_tmp2_m; \
- d_tmp1_m = in1 + ((in1 * cospi8sqrt2minus1) >> 16); \
- d_tmp2_m = (in3 * sinpi8sqrt2) >> 16; \
- d1_m = d_tmp1_m + d_tmp2_m; \
- BUTTERFLY_4(a1_m, b1_m, c1_m, d1_m, out0, out1, out2, out3); \
-}
-#define MULT1(a) ((((a) * 20091) >> 16) + (a))
-#define MULT2(a) (((a) * 35468) >> 16)
-
-static void TransformOne(const int16_t* in, uint8_t* dst) {
- v8i16 input0, input1;
- v4i32 in0, in1, in2, in3, hz0, hz1, hz2, hz3, vt0, vt1, vt2, vt3;
- v4i32 res0, res1, res2, res3;
- const v16i8 zero = { 0 };
- v16i8 dest0, dest1, dest2, dest3;
-
- LD_SH2(in, 8, input0, input1);
- UNPCK_SH_SW(input0, in0, in1);
- UNPCK_SH_SW(input1, in2, in3);
- IDCT_1D_W(in0, in1, in2, in3, hz0, hz1, hz2, hz3);
- TRANSPOSE4x4_SW_SW(hz0, hz1, hz2, hz3, hz0, hz1, hz2, hz3);
- IDCT_1D_W(hz0, hz1, hz2, hz3, vt0, vt1, vt2, vt3);
- SRARI_W4_SW(vt0, vt1, vt2, vt3, 3);
- TRANSPOSE4x4_SW_SW(vt0, vt1, vt2, vt3, vt0, vt1, vt2, vt3);
- LD_SB4(dst, BPS, dest0, dest1, dest2, dest3);
- ILVR_B4_SW(zero, dest0, zero, dest1, zero, dest2, zero, dest3,
- res0, res1, res2, res3);
- ILVR_H4_SW(zero, res0, zero, res1, zero, res2, zero, res3,
- res0, res1, res2, res3);
- ADD4(res0, vt0, res1, vt1, res2, vt2, res3, vt3, res0, res1, res2, res3);
- CLIP_SW4_0_255(res0, res1, res2, res3);
- PCKEV_B2_SW(res0, res1, res2, res3, vt0, vt1);
- res0 = (v4i32)__msa_pckev_b((v16i8)vt0, (v16i8)vt1);
- ST4x4_UB(res0, res0, 3, 2, 1, 0, dst, BPS);
-}
-
-static void TransformTwo(const int16_t* in, uint8_t* dst, int do_two) {
- TransformOne(in, dst);
- if (do_two) {
- TransformOne(in + 16, dst + 4);
- }
-}
-
-static void TransformWHT(const int16_t* in, int16_t* out) {
- v8i16 input0, input1;
- const v8i16 mask0 = { 0, 1, 2, 3, 8, 9, 10, 11 };
- const v8i16 mask1 = { 4, 5, 6, 7, 12, 13, 14, 15 };
- const v8i16 mask2 = { 0, 4, 8, 12, 1, 5, 9, 13 };
- const v8i16 mask3 = { 3, 7, 11, 15, 2, 6, 10, 14 };
- v8i16 tmp0, tmp1, tmp2, tmp3;
- v8i16 out0, out1;
-
- LD_SH2(in, 8, input0, input1);
- input1 = SLDI_SH(input1, input1, 8);
- tmp0 = input0 + input1;
- tmp1 = input0 - input1;
- VSHF_H2_SH(tmp0, tmp1, tmp0, tmp1, mask0, mask1, tmp2, tmp3);
- out0 = tmp2 + tmp3;
- out1 = tmp2 - tmp3;
- VSHF_H2_SH(out0, out1, out0, out1, mask2, mask3, input0, input1);
- tmp0 = input0 + input1;
- tmp1 = input0 - input1;
- VSHF_H2_SH(tmp0, tmp1, tmp0, tmp1, mask0, mask1, tmp2, tmp3);
- tmp0 = tmp2 + tmp3;
- tmp1 = tmp2 - tmp3;
- ADDVI_H2_SH(tmp0, 3, tmp1, 3, out0, out1);
- SRAI_H2_SH(out0, out1, 3);
- out[0] = __msa_copy_s_h(out0, 0);
- out[16] = __msa_copy_s_h(out0, 4);
- out[32] = __msa_copy_s_h(out1, 0);
- out[48] = __msa_copy_s_h(out1, 4);
- out[64] = __msa_copy_s_h(out0, 1);
- out[80] = __msa_copy_s_h(out0, 5);
- out[96] = __msa_copy_s_h(out1, 1);
- out[112] = __msa_copy_s_h(out1, 5);
- out[128] = __msa_copy_s_h(out0, 2);
- out[144] = __msa_copy_s_h(out0, 6);
- out[160] = __msa_copy_s_h(out1, 2);
- out[176] = __msa_copy_s_h(out1, 6);
- out[192] = __msa_copy_s_h(out0, 3);
- out[208] = __msa_copy_s_h(out0, 7);
- out[224] = __msa_copy_s_h(out1, 3);
- out[240] = __msa_copy_s_h(out1, 7);
-}
-
-static void TransformDC(const int16_t* in, uint8_t* dst) {
- const int DC = (in[0] + 4) >> 3;
- const v8i16 tmp0 = __msa_fill_h(DC);
- ADDBLK_ST4x4_UB(tmp0, tmp0, tmp0, tmp0, dst, BPS);
-}
-
-static void TransformAC3(const int16_t* in, uint8_t* dst) {
- const int a = in[0] + 4;
- const int c4 = MULT2(in[4]);
- const int d4 = MULT1(in[4]);
- const int in2 = MULT2(in[1]);
- const int in3 = MULT1(in[1]);
- v4i32 tmp0 = { 0 };
- v4i32 out0 = __msa_fill_w(a + d4);
- v4i32 out1 = __msa_fill_w(a + c4);
- v4i32 out2 = __msa_fill_w(a - c4);
- v4i32 out3 = __msa_fill_w(a - d4);
- v4i32 res0, res1, res2, res3;
- const v4i32 zero = { 0 };
- v16u8 dest0, dest1, dest2, dest3;
-
- INSERT_W4_SW(in3, in2, -in2, -in3, tmp0);
- ADD4(out0, tmp0, out1, tmp0, out2, tmp0, out3, tmp0,
- out0, out1, out2, out3);
- SRAI_W4_SW(out0, out1, out2, out3, 3);
- LD_UB4(dst, BPS, dest0, dest1, dest2, dest3);
- ILVR_B4_SW(zero, dest0, zero, dest1, zero, dest2, zero, dest3,
- res0, res1, res2, res3);
- ILVR_H4_SW(zero, res0, zero, res1, zero, res2, zero, res3,
- res0, res1, res2, res3);
- ADD4(res0, out0, res1, out1, res2, out2, res3, out3, res0, res1, res2, res3);
- CLIP_SW4_0_255(res0, res1, res2, res3);
- PCKEV_B2_SW(res0, res1, res2, res3, out0, out1);
- res0 = (v4i32)__msa_pckev_b((v16i8)out0, (v16i8)out1);
- ST4x4_UB(res0, res0, 3, 2, 1, 0, dst, BPS);
-}
-
-//------------------------------------------------------------------------------
-// Edge filtering functions
-
-#define FLIP_SIGN2(in0, in1, out0, out1) { \
- out0 = (v16i8)__msa_xori_b(in0, 0x80); \
- out1 = (v16i8)__msa_xori_b(in1, 0x80); \
-}
-
-#define FLIP_SIGN4(in0, in1, in2, in3, out0, out1, out2, out3) { \
- FLIP_SIGN2(in0, in1, out0, out1); \
- FLIP_SIGN2(in2, in3, out2, out3); \
-}
-
-#define FILT_VAL(q0_m, p0_m, mask, filt) do { \
- v16i8 q0_sub_p0; \
- q0_sub_p0 = __msa_subs_s_b(q0_m, p0_m); \
- filt = __msa_adds_s_b(filt, q0_sub_p0); \
- filt = __msa_adds_s_b(filt, q0_sub_p0); \
- filt = __msa_adds_s_b(filt, q0_sub_p0); \
- filt = filt & mask; \
-} while (0)
-
-#define FILT2(q_m, p_m, q, p) do { \
- u_r = SRAI_H(temp1, 7); \
- u_r = __msa_sat_s_h(u_r, 7); \
- u_l = SRAI_H(temp3, 7); \
- u_l = __msa_sat_s_h(u_l, 7); \
- u = __msa_pckev_b((v16i8)u_l, (v16i8)u_r); \
- q_m = __msa_subs_s_b(q_m, u); \
- p_m = __msa_adds_s_b(p_m, u); \
- q = __msa_xori_b((v16u8)q_m, 0x80); \
- p = __msa_xori_b((v16u8)p_m, 0x80); \
-} while (0)
-
-#define LPF_FILTER4_4W(p1, p0, q0, q1, mask, hev) do { \
- v16i8 p1_m, p0_m, q0_m, q1_m; \
- v16i8 filt, t1, t2; \
- const v16i8 cnst4b = __msa_ldi_b(4); \
- const v16i8 cnst3b = __msa_ldi_b(3); \
- \
- FLIP_SIGN4(p1, p0, q0, q1, p1_m, p0_m, q0_m, q1_m); \
- filt = __msa_subs_s_b(p1_m, q1_m); \
- filt = filt & hev; \
- FILT_VAL(q0_m, p0_m, mask, filt); \
- t1 = __msa_adds_s_b(filt, cnst4b); \
- t1 = SRAI_B(t1, 3); \
- t2 = __msa_adds_s_b(filt, cnst3b); \
- t2 = SRAI_B(t2, 3); \
- q0_m = __msa_subs_s_b(q0_m, t1); \
- q0 = __msa_xori_b((v16u8)q0_m, 0x80); \
- p0_m = __msa_adds_s_b(p0_m, t2); \
- p0 = __msa_xori_b((v16u8)p0_m, 0x80); \
- filt = __msa_srari_b(t1, 1); \
- hev = __msa_xori_b(hev, 0xff); \
- filt = filt & hev; \
- q1_m = __msa_subs_s_b(q1_m, filt); \
- q1 = __msa_xori_b((v16u8)q1_m, 0x80); \
- p1_m = __msa_adds_s_b(p1_m, filt); \
- p1 = __msa_xori_b((v16u8)p1_m, 0x80); \
-} while (0)
-
-#define LPF_MBFILTER(p2, p1, p0, q0, q1, q2, mask, hev) do { \
- v16i8 p2_m, p1_m, p0_m, q2_m, q1_m, q0_m; \
- v16i8 u, filt, t1, t2, filt_sign; \
- v8i16 filt_r, filt_l, u_r, u_l; \
- v8i16 temp0, temp1, temp2, temp3; \
- const v16i8 cnst4b = __msa_ldi_b(4); \
- const v16i8 cnst3b = __msa_ldi_b(3); \
- const v8i16 cnst9h = __msa_ldi_h(9); \
- const v8i16 cnst63h = __msa_ldi_h(63); \
- \
- FLIP_SIGN4(p1, p0, q0, q1, p1_m, p0_m, q0_m, q1_m); \
- filt = __msa_subs_s_b(p1_m, q1_m); \
- FILT_VAL(q0_m, p0_m, mask, filt); \
- FLIP_SIGN2(p2, q2, p2_m, q2_m); \
- t2 = filt & hev; \
- /* filt_val &= ~hev */ \
- hev = __msa_xori_b(hev, 0xff); \
- filt = filt & hev; \
- t1 = __msa_adds_s_b(t2, cnst4b); \
- t1 = SRAI_B(t1, 3); \
- t2 = __msa_adds_s_b(t2, cnst3b); \
- t2 = SRAI_B(t2, 3); \
- q0_m = __msa_subs_s_b(q0_m, t1); \
- p0_m = __msa_adds_s_b(p0_m, t2); \
- filt_sign = __msa_clti_s_b(filt, 0); \
- ILVRL_B2_SH(filt_sign, filt, filt_r, filt_l); \
- /* update q2/p2 */ \
- temp0 = filt_r * cnst9h; \
- temp1 = temp0 + cnst63h; \
- temp2 = filt_l * cnst9h; \
- temp3 = temp2 + cnst63h; \
- FILT2(q2_m, p2_m, q2, p2); \
- /* update q1/p1 */ \
- temp1 = temp1 + temp0; \
- temp3 = temp3 + temp2; \
- FILT2(q1_m, p1_m, q1, p1); \
- /* update q0/p0 */ \
- temp1 = temp1 + temp0; \
- temp3 = temp3 + temp2; \
- FILT2(q0_m, p0_m, q0, p0); \
-} while (0)
-
-#define LPF_MASK_HEV(p3_in, p2_in, p1_in, p0_in, \
- q0_in, q1_in, q2_in, q3_in, \
- limit_in, b_limit_in, thresh_in, \
- hev_out, mask_out) do { \
- v16u8 p3_asub_p2_m, p2_asub_p1_m, p1_asub_p0_m, q1_asub_q0_m; \
- v16u8 p1_asub_q1_m, p0_asub_q0_m, q3_asub_q2_m, q2_asub_q1_m; \
- v16u8 flat_out; \
- \
- /* absolute subtraction of pixel values */ \
- p3_asub_p2_m = __msa_asub_u_b(p3_in, p2_in); \
- p2_asub_p1_m = __msa_asub_u_b(p2_in, p1_in); \
- p1_asub_p0_m = __msa_asub_u_b(p1_in, p0_in); \
- q1_asub_q0_m = __msa_asub_u_b(q1_in, q0_in); \
- q2_asub_q1_m = __msa_asub_u_b(q2_in, q1_in); \
- q3_asub_q2_m = __msa_asub_u_b(q3_in, q2_in); \
- p0_asub_q0_m = __msa_asub_u_b(p0_in, q0_in); \
- p1_asub_q1_m = __msa_asub_u_b(p1_in, q1_in); \
- /* calculation of hev */ \
- flat_out = __msa_max_u_b(p1_asub_p0_m, q1_asub_q0_m); \
- hev_out = (thresh_in < flat_out); \
- /* calculation of mask */ \
- p0_asub_q0_m = __msa_adds_u_b(p0_asub_q0_m, p0_asub_q0_m); \
- p1_asub_q1_m = SRAI_B(p1_asub_q1_m, 1); \
- p0_asub_q0_m = __msa_adds_u_b(p0_asub_q0_m, p1_asub_q1_m); \
- mask_out = (b_limit_in < p0_asub_q0_m); \
- mask_out = __msa_max_u_b(flat_out, mask_out); \
- p3_asub_p2_m = __msa_max_u_b(p3_asub_p2_m, p2_asub_p1_m); \
- mask_out = __msa_max_u_b(p3_asub_p2_m, mask_out); \
- q2_asub_q1_m = __msa_max_u_b(q2_asub_q1_m, q3_asub_q2_m); \
- mask_out = __msa_max_u_b(q2_asub_q1_m, mask_out); \
- mask_out = (limit_in < mask_out); \
- mask_out = __msa_xori_b(mask_out, 0xff); \
-} while (0)
-
-#define ST6x1_UB(in0, in0_idx, in1, in1_idx, pdst, stride) do { \
- const uint16_t tmp0_h = __msa_copy_s_h((v8i16)in1, in1_idx); \
- const uint32_t tmp0_w = __msa_copy_s_w((v4i32)in0, in0_idx); \
- SW(tmp0_w, pdst); \
- SH(tmp0_h, pdst + stride); \
-} while (0)
-
-#define ST6x4_UB(in0, start_in0_idx, in1, start_in1_idx, pdst, stride) do { \
- uint8_t* ptmp1 = (uint8_t*)pdst; \
- ST6x1_UB(in0, start_in0_idx, in1, start_in1_idx, ptmp1, 4); \
- ptmp1 += stride; \
- ST6x1_UB(in0, start_in0_idx + 1, in1, start_in1_idx + 1, ptmp1, 4); \
- ptmp1 += stride; \
- ST6x1_UB(in0, start_in0_idx + 2, in1, start_in1_idx + 2, ptmp1, 4); \
- ptmp1 += stride; \
- ST6x1_UB(in0, start_in0_idx + 3, in1, start_in1_idx + 3, ptmp1, 4); \
-} while (0)
-
-#define LPF_SIMPLE_FILT(p1_in, p0_in, q0_in, q1_in, mask) do { \
- v16i8 p1_m, p0_m, q0_m, q1_m, filt, filt1, filt2; \
- const v16i8 cnst4b = __msa_ldi_b(4); \
- const v16i8 cnst3b = __msa_ldi_b(3); \
- \
- FLIP_SIGN4(p1_in, p0_in, q0_in, q1_in, p1_m, p0_m, q0_m, q1_m); \
- filt = __msa_subs_s_b(p1_m, q1_m); \
- FILT_VAL(q0_m, p0_m, mask, filt); \
- filt1 = __msa_adds_s_b(filt, cnst4b); \
- filt1 = SRAI_B(filt1, 3); \
- filt2 = __msa_adds_s_b(filt, cnst3b); \
- filt2 = SRAI_B(filt2, 3); \
- q0_m = __msa_subs_s_b(q0_m, filt1); \
- p0_m = __msa_adds_s_b(p0_m, filt2); \
- q0_in = __msa_xori_b((v16u8)q0_m, 0x80); \
- p0_in = __msa_xori_b((v16u8)p0_m, 0x80); \
-} while (0)
-
-#define LPF_SIMPLE_MASK(p1, p0, q0, q1, b_limit, mask) do { \
- v16u8 p1_a_sub_q1, p0_a_sub_q0; \
- \
- p0_a_sub_q0 = __msa_asub_u_b(p0, q0); \
- p1_a_sub_q1 = __msa_asub_u_b(p1, q1); \
- p1_a_sub_q1 = (v16u8)__msa_srli_b((v16i8)p1_a_sub_q1, 1); \
- p0_a_sub_q0 = __msa_adds_u_b(p0_a_sub_q0, p0_a_sub_q0); \
- mask = __msa_adds_u_b(p0_a_sub_q0, p1_a_sub_q1); \
- mask = (mask <= b_limit); \
-} while (0)
-
-static void VFilter16(uint8_t* src, int stride,
- int b_limit_in, int limit_in, int thresh_in) {
- uint8_t* ptemp = src - 4 * stride;
- v16u8 p3, p2, p1, p0, q3, q2, q1, q0;
- v16u8 mask, hev;
- const v16u8 thresh = (v16u8)__msa_fill_b(thresh_in);
- const v16u8 limit = (v16u8)__msa_fill_b(limit_in);
- const v16u8 b_limit = (v16u8)__msa_fill_b(b_limit_in);
-
- LD_UB8(ptemp, stride, p3, p2, p1, p0, q0, q1, q2, q3);
- LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh,
- hev, mask);
- LPF_MBFILTER(p2, p1, p0, q0, q1, q2, mask, hev);
- ptemp = src - 3 * stride;
- ST_UB4(p2, p1, p0, q0, ptemp, stride);
- ptemp += (4 * stride);
- ST_UB2(q1, q2, ptemp, stride);
-}
-
-static void HFilter16(uint8_t* src, int stride,
- int b_limit_in, int limit_in, int thresh_in) {
- uint8_t* ptmp = src - 4;
- v16u8 p3, p2, p1, p0, q3, q2, q1, q0;
- v16u8 mask, hev;
- v16u8 row0, row1, row2, row3, row4, row5, row6, row7, row8;
- v16u8 row9, row10, row11, row12, row13, row14, row15;
- v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
- const v16u8 b_limit = (v16u8)__msa_fill_b(b_limit_in);
- const v16u8 limit = (v16u8)__msa_fill_b(limit_in);
- const v16u8 thresh = (v16u8)__msa_fill_b(thresh_in);
-
- LD_UB8(ptmp, stride, row0, row1, row2, row3, row4, row5, row6, row7);
- ptmp += (8 * stride);
- LD_UB8(ptmp, stride, row8, row9, row10, row11, row12, row13, row14, row15);
- TRANSPOSE16x8_UB_UB(row0, row1, row2, row3, row4, row5, row6, row7,
- row8, row9, row10, row11, row12, row13, row14, row15,
- p3, p2, p1, p0, q0, q1, q2, q3);
- LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh,
- hev, mask);
- LPF_MBFILTER(p2, p1, p0, q0, q1, q2, mask, hev);
- ILVR_B2_SH(p1, p2, q0, p0, tmp0, tmp1);
- ILVRL_H2_SH(tmp1, tmp0, tmp3, tmp4);
- ILVL_B2_SH(p1, p2, q0, p0, tmp0, tmp1);
- ILVRL_H2_SH(tmp1, tmp0, tmp6, tmp7);
- ILVRL_B2_SH(q2, q1, tmp2, tmp5);
- ptmp = src - 3;
- ST6x1_UB(tmp3, 0, tmp2, 0, ptmp, 4);
- ptmp += stride;
- ST6x1_UB(tmp3, 1, tmp2, 1, ptmp, 4);
- ptmp += stride;
- ST6x1_UB(tmp3, 2, tmp2, 2, ptmp, 4);
- ptmp += stride;
- ST6x1_UB(tmp3, 3, tmp2, 3, ptmp, 4);
- ptmp += stride;
- ST6x1_UB(tmp4, 0, tmp2, 4, ptmp, 4);
- ptmp += stride;
- ST6x1_UB(tmp4, 1, tmp2, 5, ptmp, 4);
- ptmp += stride;
- ST6x1_UB(tmp4, 2, tmp2, 6, ptmp, 4);
- ptmp += stride;
- ST6x1_UB(tmp4, 3, tmp2, 7, ptmp, 4);
- ptmp += stride;
- ST6x1_UB(tmp6, 0, tmp5, 0, ptmp, 4);
- ptmp += stride;
- ST6x1_UB(tmp6, 1, tmp5, 1, ptmp, 4);
- ptmp += stride;
- ST6x1_UB(tmp6, 2, tmp5, 2, ptmp, 4);
- ptmp += stride;
- ST6x1_UB(tmp6, 3, tmp5, 3, ptmp, 4);
- ptmp += stride;
- ST6x1_UB(tmp7, 0, tmp5, 4, ptmp, 4);
- ptmp += stride;
- ST6x1_UB(tmp7, 1, tmp5, 5, ptmp, 4);
- ptmp += stride;
- ST6x1_UB(tmp7, 2, tmp5, 6, ptmp, 4);
- ptmp += stride;
- ST6x1_UB(tmp7, 3, tmp5, 7, ptmp, 4);
-}
-
-// on three inner edges
-static void VFilterHorEdge16i(uint8_t* src, int stride,
- int b_limit, int limit, int thresh) {
- v16u8 mask, hev;
- v16u8 p3, p2, p1, p0, q3, q2, q1, q0;
- const v16u8 thresh0 = (v16u8)__msa_fill_b(thresh);
- const v16u8 b_limit0 = (v16u8)__msa_fill_b(b_limit);
- const v16u8 limit0 = (v16u8)__msa_fill_b(limit);
-
- LD_UB8((src - 4 * stride), stride, p3, p2, p1, p0, q0, q1, q2, q3);
- LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit0, b_limit0, thresh0,
- hev, mask);
- LPF_FILTER4_4W(p1, p0, q0, q1, mask, hev);
- ST_UB4(p1, p0, q0, q1, (src - 2 * stride), stride);
-}
-
-static void VFilter16i(uint8_t* src_y, int stride,
- int b_limit, int limit, int thresh) {
- VFilterHorEdge16i(src_y + 4 * stride, stride, b_limit, limit, thresh);
- VFilterHorEdge16i(src_y + 8 * stride, stride, b_limit, limit, thresh);
- VFilterHorEdge16i(src_y + 12 * stride, stride, b_limit, limit, thresh);
-}
-
-static void HFilterVertEdge16i(uint8_t* src, int stride,
- int b_limit, int limit, int thresh) {
- v16u8 mask, hev;
- v16u8 p3, p2, p1, p0, q3, q2, q1, q0;
- v16u8 row0, row1, row2, row3, row4, row5, row6, row7;
- v16u8 row8, row9, row10, row11, row12, row13, row14, row15;
- v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5;
- const v16u8 thresh0 = (v16u8)__msa_fill_b(thresh);
- const v16u8 b_limit0 = (v16u8)__msa_fill_b(b_limit);
- const v16u8 limit0 = (v16u8)__msa_fill_b(limit);
-
- LD_UB8(src - 4, stride, row0, row1, row2, row3, row4, row5, row6, row7);
- LD_UB8(src - 4 + (8 * stride), stride,
- row8, row9, row10, row11, row12, row13, row14, row15);
- TRANSPOSE16x8_UB_UB(row0, row1, row2, row3, row4, row5, row6, row7,
- row8, row9, row10, row11, row12, row13, row14, row15,
- p3, p2, p1, p0, q0, q1, q2, q3);
- LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit0, b_limit0, thresh0,
- hev, mask);
- LPF_FILTER4_4W(p1, p0, q0, q1, mask, hev);
- ILVR_B2_SH(p0, p1, q1, q0, tmp0, tmp1);
- ILVRL_H2_SH(tmp1, tmp0, tmp2, tmp3);
- ILVL_B2_SH(p0, p1, q1, q0, tmp0, tmp1);
- ILVRL_H2_SH(tmp1, tmp0, tmp4, tmp5);
- src -= 2;
- ST4x8_UB(tmp2, tmp3, src, stride);
- src += (8 * stride);
- ST4x8_UB(tmp4, tmp5, src, stride);
-}
-
-static void HFilter16i(uint8_t* src_y, int stride,
- int b_limit, int limit, int thresh) {
- HFilterVertEdge16i(src_y + 4, stride, b_limit, limit, thresh);
- HFilterVertEdge16i(src_y + 8, stride, b_limit, limit, thresh);
- HFilterVertEdge16i(src_y + 12, stride, b_limit, limit, thresh);
-}
-
-// 8-pixels wide variants, for chroma filtering
-static void VFilter8(uint8_t* src_u, uint8_t* src_v, int stride,
- int b_limit_in, int limit_in, int thresh_in) {
- uint8_t* ptmp_src_u = src_u - 4 * stride;
- uint8_t* ptmp_src_v = src_v - 4 * stride;
- uint64_t p2_d, p1_d, p0_d, q0_d, q1_d, q2_d;
- v16u8 p3, p2, p1, p0, q3, q2, q1, q0, mask, hev;
- v16u8 p3_u, p2_u, p1_u, p0_u, q3_u, q2_u, q1_u, q0_u;
- v16u8 p3_v, p2_v, p1_v, p0_v, q3_v, q2_v, q1_v, q0_v;
- const v16u8 b_limit = (v16u8)__msa_fill_b(b_limit_in);
- const v16u8 limit = (v16u8)__msa_fill_b(limit_in);
- const v16u8 thresh = (v16u8)__msa_fill_b(thresh_in);
-
- LD_UB8(ptmp_src_u, stride, p3_u, p2_u, p1_u, p0_u, q0_u, q1_u, q2_u, q3_u);
- LD_UB8(ptmp_src_v, stride, p3_v, p2_v, p1_v, p0_v, q0_v, q1_v, q2_v, q3_v);
- ILVR_D4_UB(p3_v, p3_u, p2_v, p2_u, p1_v, p1_u, p0_v, p0_u, p3, p2, p1, p0);
- ILVR_D4_UB(q0_v, q0_u, q1_v, q1_u, q2_v, q2_u, q3_v, q3_u, q0, q1, q2, q3);
- LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh,
- hev, mask);
- LPF_MBFILTER(p2, p1, p0, q0, q1, q2, mask, hev);
- p2_d = __msa_copy_s_d((v2i64)p2, 0);
- p1_d = __msa_copy_s_d((v2i64)p1, 0);
- p0_d = __msa_copy_s_d((v2i64)p0, 0);
- q0_d = __msa_copy_s_d((v2i64)q0, 0);
- q1_d = __msa_copy_s_d((v2i64)q1, 0);
- q2_d = __msa_copy_s_d((v2i64)q2, 0);
- ptmp_src_u += stride;
- SD4(p2_d, p1_d, p0_d, q0_d, ptmp_src_u, stride);
- ptmp_src_u += (4 * stride);
- SD(q1_d, ptmp_src_u);
- ptmp_src_u += stride;
- SD(q2_d, ptmp_src_u);
- p2_d = __msa_copy_s_d((v2i64)p2, 1);
- p1_d = __msa_copy_s_d((v2i64)p1, 1);
- p0_d = __msa_copy_s_d((v2i64)p0, 1);
- q0_d = __msa_copy_s_d((v2i64)q0, 1);
- q1_d = __msa_copy_s_d((v2i64)q1, 1);
- q2_d = __msa_copy_s_d((v2i64)q2, 1);
- ptmp_src_v += stride;
- SD4(p2_d, p1_d, p0_d, q0_d, ptmp_src_v, stride);
- ptmp_src_v += (4 * stride);
- SD(q1_d, ptmp_src_v);
- ptmp_src_v += stride;
- SD(q2_d, ptmp_src_v);
-}
-
-static void HFilter8(uint8_t* src_u, uint8_t* src_v, int stride,
- int b_limit_in, int limit_in, int thresh_in) {
- uint8_t* ptmp_src_u = src_u - 4;
- uint8_t* ptmp_src_v = src_v - 4;
- v16u8 p3, p2, p1, p0, q3, q2, q1, q0, mask, hev;
- v16u8 row0, row1, row2, row3, row4, row5, row6, row7, row8;
- v16u8 row9, row10, row11, row12, row13, row14, row15;
- v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
- const v16u8 b_limit = (v16u8)__msa_fill_b(b_limit_in);
- const v16u8 limit = (v16u8)__msa_fill_b(limit_in);
- const v16u8 thresh = (v16u8)__msa_fill_b(thresh_in);
-
- LD_UB8(ptmp_src_u, stride, row0, row1, row2, row3, row4, row5, row6, row7);
- LD_UB8(ptmp_src_v, stride,
- row8, row9, row10, row11, row12, row13, row14, row15);
- TRANSPOSE16x8_UB_UB(row0, row1, row2, row3, row4, row5, row6, row7,
- row8, row9, row10, row11, row12, row13, row14, row15,
- p3, p2, p1, p0, q0, q1, q2, q3);
- LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh,
- hev, mask);
- LPF_MBFILTER(p2, p1, p0, q0, q1, q2, mask, hev);
- ILVR_B2_SH(p1, p2, q0, p0, tmp0, tmp1);
- ILVRL_H2_SH(tmp1, tmp0, tmp3, tmp4);
- ILVL_B2_SH(p1, p2, q0, p0, tmp0, tmp1);
- ILVRL_H2_SH(tmp1, tmp0, tmp6, tmp7);
- ILVRL_B2_SH(q2, q1, tmp2, tmp5);
- ptmp_src_u += 1;
- ST6x4_UB(tmp3, 0, tmp2, 0, ptmp_src_u, stride);
- ptmp_src_u += 4 * stride;
- ST6x4_UB(tmp4, 0, tmp2, 4, ptmp_src_u, stride);
- ptmp_src_v += 1;
- ST6x4_UB(tmp6, 0, tmp5, 0, ptmp_src_v, stride);
- ptmp_src_v += 4 * stride;
- ST6x4_UB(tmp7, 0, tmp5, 4, ptmp_src_v, stride);
-}
-
-static void VFilter8i(uint8_t* src_u, uint8_t* src_v, int stride,
- int b_limit_in, int limit_in, int thresh_in) {
- uint64_t p1_d, p0_d, q0_d, q1_d;
- v16u8 p3, p2, p1, p0, q3, q2, q1, q0, mask, hev;
- v16u8 p3_u, p2_u, p1_u, p0_u, q3_u, q2_u, q1_u, q0_u;
- v16u8 p3_v, p2_v, p1_v, p0_v, q3_v, q2_v, q1_v, q0_v;
- const v16u8 thresh = (v16u8)__msa_fill_b(thresh_in);
- const v16u8 limit = (v16u8)__msa_fill_b(limit_in);
- const v16u8 b_limit = (v16u8)__msa_fill_b(b_limit_in);
-
- LD_UB8(src_u, stride, p3_u, p2_u, p1_u, p0_u, q0_u, q1_u, q2_u, q3_u);
- src_u += (5 * stride);
- LD_UB8(src_v, stride, p3_v, p2_v, p1_v, p0_v, q0_v, q1_v, q2_v, q3_v);
- src_v += (5 * stride);
- ILVR_D4_UB(p3_v, p3_u, p2_v, p2_u, p1_v, p1_u, p0_v, p0_u, p3, p2, p1, p0);
- ILVR_D4_UB(q0_v, q0_u, q1_v, q1_u, q2_v, q2_u, q3_v, q3_u, q0, q1, q2, q3);
- LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh,
- hev, mask);
- LPF_FILTER4_4W(p1, p0, q0, q1, mask, hev);
- p1_d = __msa_copy_s_d((v2i64)p1, 0);
- p0_d = __msa_copy_s_d((v2i64)p0, 0);
- q0_d = __msa_copy_s_d((v2i64)q0, 0);
- q1_d = __msa_copy_s_d((v2i64)q1, 0);
- SD4(q1_d, q0_d, p0_d, p1_d, src_u, -stride);
- p1_d = __msa_copy_s_d((v2i64)p1, 1);
- p0_d = __msa_copy_s_d((v2i64)p0, 1);
- q0_d = __msa_copy_s_d((v2i64)q0, 1);
- q1_d = __msa_copy_s_d((v2i64)q1, 1);
- SD4(q1_d, q0_d, p0_d, p1_d, src_v, -stride);
-}
-
-static void HFilter8i(uint8_t* src_u, uint8_t* src_v, int stride,
- int b_limit_in, int limit_in, int thresh_in) {
- v16u8 p3, p2, p1, p0, q3, q2, q1, q0, mask, hev;
- v16u8 row0, row1, row2, row3, row4, row5, row6, row7, row8;
- v16u8 row9, row10, row11, row12, row13, row14, row15;
- v4i32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5;
- const v16u8 thresh = (v16u8)__msa_fill_b(thresh_in);
- const v16u8 limit = (v16u8)__msa_fill_b(limit_in);
- const v16u8 b_limit = (v16u8)__msa_fill_b(b_limit_in);
-
- LD_UB8(src_u, stride, row0, row1, row2, row3, row4, row5, row6, row7);
- LD_UB8(src_v, stride,
- row8, row9, row10, row11, row12, row13, row14, row15);
- TRANSPOSE16x8_UB_UB(row0, row1, row2, row3, row4, row5, row6, row7,
- row8, row9, row10, row11, row12, row13, row14, row15,
- p3, p2, p1, p0, q0, q1, q2, q3);
- LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh,
- hev, mask);
- LPF_FILTER4_4W(p1, p0, q0, q1, mask, hev);
- ILVR_B2_SW(p0, p1, q1, q0, tmp0, tmp1);
- ILVRL_H2_SW(tmp1, tmp0, tmp2, tmp3);
- ILVL_B2_SW(p0, p1, q1, q0, tmp0, tmp1);
- ILVRL_H2_SW(tmp1, tmp0, tmp4, tmp5);
- src_u += 2;
- ST4x4_UB(tmp2, tmp2, 0, 1, 2, 3, src_u, stride);
- src_u += 4 * stride;
- ST4x4_UB(tmp3, tmp3, 0, 1, 2, 3, src_u, stride);
- src_v += 2;
- ST4x4_UB(tmp4, tmp4, 0, 1, 2, 3, src_v, stride);
- src_v += 4 * stride;
- ST4x4_UB(tmp5, tmp5, 0, 1, 2, 3, src_v, stride);
-}
-
-static void SimpleVFilter16(uint8_t* src, int stride, int b_limit_in) {
- v16u8 p1, p0, q1, q0, mask;
- const v16u8 b_limit = (v16u8)__msa_fill_b(b_limit_in);
-
- LD_UB4(src - 2 * stride, stride, p1, p0, q0, q1);
- LPF_SIMPLE_MASK(p1, p0, q0, q1, b_limit, mask);
- LPF_SIMPLE_FILT(p1, p0, q0, q1, mask);
- ST_UB2(p0, q0, src - stride, stride);
-}
-
-static void SimpleHFilter16(uint8_t* src, int stride, int b_limit_in) {
- v16u8 p1, p0, q1, q0, mask, row0, row1, row2, row3, row4, row5, row6, row7;
- v16u8 row8, row9, row10, row11, row12, row13, row14, row15;
- v8i16 tmp0, tmp1;
- const v16u8 b_limit = (v16u8)__msa_fill_b(b_limit_in);
- uint8_t* ptemp_src = src - 2;
-
- LD_UB8(ptemp_src, stride, row0, row1, row2, row3, row4, row5, row6, row7);
- LD_UB8(ptemp_src + 8 * stride, stride,
- row8, row9, row10, row11, row12, row13, row14, row15);
- TRANSPOSE16x4_UB_UB(row0, row1, row2, row3, row4, row5, row6, row7,
- row8, row9, row10, row11, row12, row13, row14, row15,
- p1, p0, q0, q1);
- LPF_SIMPLE_MASK(p1, p0, q0, q1, b_limit, mask);
- LPF_SIMPLE_FILT(p1, p0, q0, q1, mask);
- ILVRL_B2_SH(q0, p0, tmp1, tmp0);
- ptemp_src += 1;
- ST2x4_UB(tmp1, 0, ptemp_src, stride);
- ptemp_src += 4 * stride;
- ST2x4_UB(tmp1, 4, ptemp_src, stride);
- ptemp_src += 4 * stride;
- ST2x4_UB(tmp0, 0, ptemp_src, stride);
- ptemp_src += 4 * stride;
- ST2x4_UB(tmp0, 4, ptemp_src, stride);
- ptemp_src += 4 * stride;
-}
-
-static void SimpleVFilter16i(uint8_t* src_y, int stride, int b_limit_in) {
- SimpleVFilter16(src_y + 4 * stride, stride, b_limit_in);
- SimpleVFilter16(src_y + 8 * stride, stride, b_limit_in);
- SimpleVFilter16(src_y + 12 * stride, stride, b_limit_in);
-}
-
-static void SimpleHFilter16i(uint8_t* src_y, int stride, int b_limit_in) {
- SimpleHFilter16(src_y + 4, stride, b_limit_in);
- SimpleHFilter16(src_y + 8, stride, b_limit_in);
- SimpleHFilter16(src_y + 12, stride, b_limit_in);
-}
-
-//------------------------------------------------------------------------------
-// Intra predictions
-//------------------------------------------------------------------------------
-
-// 4x4
-
-static void DC4(uint8_t* dst) { // DC
- uint32_t dc = 4;
- int i;
- for (i = 0; i < 4; ++i) dc += dst[i - BPS] + dst[-1 + i * BPS];
- dc >>= 3;
- dc = dc | (dc << 8) | (dc << 16) | (dc << 24);
- SW4(dc, dc, dc, dc, dst, BPS);
-}
-
-static void TM4(uint8_t* dst) {
- const uint8_t* const ptemp = dst - BPS - 1;
- v8i16 T, d, r0, r1, r2, r3;
- const v16i8 zero = { 0 };
- const v8i16 TL = (v8i16)__msa_fill_h(ptemp[0 * BPS]);
- const v8i16 L0 = (v8i16)__msa_fill_h(ptemp[1 * BPS]);
- const v8i16 L1 = (v8i16)__msa_fill_h(ptemp[2 * BPS]);
- const v8i16 L2 = (v8i16)__msa_fill_h(ptemp[3 * BPS]);
- const v8i16 L3 = (v8i16)__msa_fill_h(ptemp[4 * BPS]);
- const v16u8 T1 = LD_UB(ptemp + 1);
-
- T = (v8i16)__msa_ilvr_b(zero, (v16i8)T1);
- d = T - TL;
- ADD4(d, L0, d, L1, d, L2, d, L3, r0, r1, r2, r3);
- CLIP_SH4_0_255(r0, r1, r2, r3);
- PCKEV_ST4x4_UB(r0, r1, r2, r3, dst, BPS);
-}
-
-static void VE4(uint8_t* dst) { // vertical
- const uint8_t* const ptop = dst - BPS - 1;
- const uint32_t val0 = LW(ptop + 0);
- const uint32_t val1 = LW(ptop + 4);
- uint32_t out;
- v16u8 A = { 0 }, B, C, AC, B2, R;
-
- INSERT_W2_UB(val0, val1, A);
- B = SLDI_UB(A, A, 1);
- C = SLDI_UB(A, A, 2);
- AC = __msa_ave_u_b(A, C);
- B2 = __msa_ave_u_b(B, B);
- R = __msa_aver_u_b(AC, B2);
- out = __msa_copy_s_w((v4i32)R, 0);
- SW4(out, out, out, out, dst, BPS);
-}
-
-static void RD4(uint8_t* dst) { // Down-right
- const uint8_t* const ptop = dst - 1 - BPS;
- uint32_t val0 = LW(ptop + 0);
- uint32_t val1 = LW(ptop + 4);
- uint32_t val2, val3;
- v16u8 A, B, C, AC, B2, R, A1 = { 0 };
-
- INSERT_W2_UB(val0, val1, A1);
- A = SLDI_UB(A1, A1, 12);
- A = (v16u8)__msa_insert_b((v16i8)A, 3, ptop[1 * BPS]);
- A = (v16u8)__msa_insert_b((v16i8)A, 2, ptop[2 * BPS]);
- A = (v16u8)__msa_insert_b((v16i8)A, 1, ptop[3 * BPS]);
- A = (v16u8)__msa_insert_b((v16i8)A, 0, ptop[4 * BPS]);
- B = SLDI_UB(A, A, 1);
- C = SLDI_UB(A, A, 2);
- AC = __msa_ave_u_b(A, C);
- B2 = __msa_ave_u_b(B, B);
- R = __msa_aver_u_b(AC, B2);
- val3 = __msa_copy_s_w((v4i32)R, 0);
- R = SLDI_UB(R, R, 1);
- val2 = __msa_copy_s_w((v4i32)R, 0);
- R = SLDI_UB(R, R, 1);
- val1 = __msa_copy_s_w((v4i32)R, 0);
- R = SLDI_UB(R, R, 1);
- val0 = __msa_copy_s_w((v4i32)R, 0);
- SW4(val0, val1, val2, val3, dst, BPS);
-}
-
-static void LD4(uint8_t* dst) { // Down-Left
- const uint8_t* const ptop = dst - BPS;
- uint32_t val0 = LW(ptop + 0);
- uint32_t val1 = LW(ptop + 4);
- uint32_t val2, val3;
- v16u8 A = { 0 }, B, C, AC, B2, R;
-
- INSERT_W2_UB(val0, val1, A);
- B = SLDI_UB(A, A, 1);
- C = SLDI_UB(A, A, 2);
- C = (v16u8)__msa_insert_b((v16i8)C, 6, ptop[7]);
- AC = __msa_ave_u_b(A, C);
- B2 = __msa_ave_u_b(B, B);
- R = __msa_aver_u_b(AC, B2);
- val0 = __msa_copy_s_w((v4i32)R, 0);
- R = SLDI_UB(R, R, 1);
- val1 = __msa_copy_s_w((v4i32)R, 0);
- R = SLDI_UB(R, R, 1);
- val2 = __msa_copy_s_w((v4i32)R, 0);
- R = SLDI_UB(R, R, 1);
- val3 = __msa_copy_s_w((v4i32)R, 0);
- SW4(val0, val1, val2, val3, dst, BPS);
-}
-
-// 16x16
-
-static void DC16(uint8_t* dst) { // DC
- uint32_t dc = 16;
- int i;
- const v16u8 rtop = LD_UB(dst - BPS);
- const v8u16 dctop = __msa_hadd_u_h(rtop, rtop);
- v16u8 out;
-
- for (i = 0; i < 16; ++i) {
- dc += dst[-1 + i * BPS];
- }
- dc += HADD_UH_U32(dctop);
- out = (v16u8)__msa_fill_b(dc >> 5);
- ST_UB8(out, out, out, out, out, out, out, out, dst, BPS);
- ST_UB8(out, out, out, out, out, out, out, out, dst + 8 * BPS, BPS);
-}
-
-static void TM16(uint8_t* dst) {
- int j;
- v8i16 d1, d2;
- const v16i8 zero = { 0 };
- const v8i16 TL = (v8i16)__msa_fill_h(dst[-1 - BPS]);
- const v16i8 T = LD_SB(dst - BPS);
-
- ILVRL_B2_SH(zero, T, d1, d2);
- SUB2(d1, TL, d2, TL, d1, d2);
- for (j = 0; j < 16; j += 4) {
- v16i8 t0, t1, t2, t3;
- v8i16 r0, r1, r2, r3, r4, r5, r6, r7;
- const v8i16 L0 = (v8i16)__msa_fill_h(dst[-1 + 0 * BPS]);
- const v8i16 L1 = (v8i16)__msa_fill_h(dst[-1 + 1 * BPS]);
- const v8i16 L2 = (v8i16)__msa_fill_h(dst[-1 + 2 * BPS]);
- const v8i16 L3 = (v8i16)__msa_fill_h(dst[-1 + 3 * BPS]);
- ADD4(d1, L0, d1, L1, d1, L2, d1, L3, r0, r1, r2, r3);
- ADD4(d2, L0, d2, L1, d2, L2, d2, L3, r4, r5, r6, r7);
- CLIP_SH4_0_255(r0, r1, r2, r3);
- CLIP_SH4_0_255(r4, r5, r6, r7);
- PCKEV_B4_SB(r4, r0, r5, r1, r6, r2, r7, r3, t0, t1, t2, t3);
- ST_SB4(t0, t1, t2, t3, dst, BPS);
- dst += 4 * BPS;
- }
-}
-
-static void VE16(uint8_t* dst) { // vertical
- const v16u8 rtop = LD_UB(dst - BPS);
- ST_UB8(rtop, rtop, rtop, rtop, rtop, rtop, rtop, rtop, dst, BPS);
- ST_UB8(rtop, rtop, rtop, rtop, rtop, rtop, rtop, rtop, dst + 8 * BPS, BPS);
-}
-
-static void HE16(uint8_t* dst) { // horizontal
- int j;
- for (j = 16; j > 0; j -= 4) {
- const v16u8 L0 = (v16u8)__msa_fill_b(dst[-1 + 0 * BPS]);
- const v16u8 L1 = (v16u8)__msa_fill_b(dst[-1 + 1 * BPS]);
- const v16u8 L2 = (v16u8)__msa_fill_b(dst[-1 + 2 * BPS]);
- const v16u8 L3 = (v16u8)__msa_fill_b(dst[-1 + 3 * BPS]);
- ST_UB4(L0, L1, L2, L3, dst, BPS);
- dst += 4 * BPS;
- }
-}
-
-static void DC16NoTop(uint8_t* dst) { // DC with top samples not available
- int j;
- uint32_t dc = 8;
- v16u8 out;
-
- for (j = 0; j < 16; ++j) {
- dc += dst[-1 + j * BPS];
- }
- out = (v16u8)__msa_fill_b(dc >> 4);
- ST_UB8(out, out, out, out, out, out, out, out, dst, BPS);
- ST_UB8(out, out, out, out, out, out, out, out, dst + 8 * BPS, BPS);
-}
-
-static void DC16NoLeft(uint8_t* dst) { // DC with left samples not available
- uint32_t dc = 8;
- const v16u8 rtop = LD_UB(dst - BPS);
- const v8u16 dctop = __msa_hadd_u_h(rtop, rtop);
- v16u8 out;
-
- dc += HADD_UH_U32(dctop);
- out = (v16u8)__msa_fill_b(dc >> 4);
- ST_UB8(out, out, out, out, out, out, out, out, dst, BPS);
- ST_UB8(out, out, out, out, out, out, out, out, dst + 8 * BPS, BPS);
-}
-
-static void DC16NoTopLeft(uint8_t* dst) { // DC with nothing
- const v16u8 out = (v16u8)__msa_fill_b(0x80);
- ST_UB8(out, out, out, out, out, out, out, out, dst, BPS);
- ST_UB8(out, out, out, out, out, out, out, out, dst + 8 * BPS, BPS);
-}
-
-// Chroma
-
-#define STORE8x8(out, dst) do { \
- SD4(out, out, out, out, dst + 0 * BPS, BPS); \
- SD4(out, out, out, out, dst + 4 * BPS, BPS); \
-} while (0)
-
-static void DC8uv(uint8_t* dst) { // DC
- uint32_t dc = 8;
- int i;
- uint64_t out;
- const v16u8 rtop = LD_UB(dst - BPS);
- const v8u16 temp0 = __msa_hadd_u_h(rtop, rtop);
- const v4u32 temp1 = __msa_hadd_u_w(temp0, temp0);
- const v2u64 temp2 = __msa_hadd_u_d(temp1, temp1);
- v16u8 dctemp;
-
- for (i = 0; i < 8; ++i) {
- dc += dst[-1 + i * BPS];
- }
- dc += __msa_copy_s_w((v4i32)temp2, 0);
- dctemp = (v16u8)__msa_fill_b(dc >> 4);
- out = __msa_copy_s_d((v2i64)dctemp, 0);
- STORE8x8(out, dst);
-}
-
-static void TM8uv(uint8_t* dst) {
- int j;
- const v16i8 T1 = LD_SB(dst - BPS);
- const v16i8 zero = { 0 };
- const v8i16 T = (v8i16)__msa_ilvr_b(zero, T1);
- const v8i16 TL = (v8i16)__msa_fill_h(dst[-1 - BPS]);
- const v8i16 d = T - TL;
-
- for (j = 0; j < 8; j += 4) {
- v16i8 t0, t1;
- v8i16 r0 = (v8i16)__msa_fill_h(dst[-1 + 0 * BPS]);
- v8i16 r1 = (v8i16)__msa_fill_h(dst[-1 + 1 * BPS]);
- v8i16 r2 = (v8i16)__msa_fill_h(dst[-1 + 2 * BPS]);
- v8i16 r3 = (v8i16)__msa_fill_h(dst[-1 + 3 * BPS]);
- ADD4(d, r0, d, r1, d, r2, d, r3, r0, r1, r2, r3);
- CLIP_SH4_0_255(r0, r1, r2, r3);
- PCKEV_B2_SB(r1, r0, r3, r2, t0, t1);
- ST4x4_UB(t0, t1, 0, 2, 0, 2, dst, BPS);
- ST4x4_UB(t0, t1, 1, 3, 1, 3, dst + 4, BPS);
- dst += 4 * BPS;
- }
-}
-
-static void VE8uv(uint8_t* dst) { // vertical
- const v16u8 rtop = LD_UB(dst - BPS);
- const uint64_t out = __msa_copy_s_d((v2i64)rtop, 0);
- STORE8x8(out, dst);
-}
-
-static void HE8uv(uint8_t* dst) { // horizontal
- int j;
- for (j = 0; j < 8; j += 4) {
- const v16u8 L0 = (v16u8)__msa_fill_b(dst[-1 + 0 * BPS]);
- const v16u8 L1 = (v16u8)__msa_fill_b(dst[-1 + 1 * BPS]);
- const v16u8 L2 = (v16u8)__msa_fill_b(dst[-1 + 2 * BPS]);
- const v16u8 L3 = (v16u8)__msa_fill_b(dst[-1 + 3 * BPS]);
- const uint64_t out0 = __msa_copy_s_d((v2i64)L0, 0);
- const uint64_t out1 = __msa_copy_s_d((v2i64)L1, 0);
- const uint64_t out2 = __msa_copy_s_d((v2i64)L2, 0);
- const uint64_t out3 = __msa_copy_s_d((v2i64)L3, 0);
- SD4(out0, out1, out2, out3, dst, BPS);
- dst += 4 * BPS;
- }
-}
-
-static void DC8uvNoLeft(uint8_t* dst) { // DC with no left samples
- const uint32_t dc = 4;
- const v16u8 rtop = LD_UB(dst - BPS);
- const v8u16 temp0 = __msa_hadd_u_h(rtop, rtop);
- const v4u32 temp1 = __msa_hadd_u_w(temp0, temp0);
- const v2u64 temp2 = __msa_hadd_u_d(temp1, temp1);
- const uint32_t sum_m = __msa_copy_s_w((v4i32)temp2, 0);
- const v16u8 dcval = (v16u8)__msa_fill_b((dc + sum_m) >> 3);
- const uint64_t out = __msa_copy_s_d((v2i64)dcval, 0);
- STORE8x8(out, dst);
-}
-
-static void DC8uvNoTop(uint8_t* dst) { // DC with no top samples
- uint32_t dc = 4;
- int i;
- uint64_t out;
- v16u8 dctemp;
-
- for (i = 0; i < 8; ++i) {
- dc += dst[-1 + i * BPS];
- }
- dctemp = (v16u8)__msa_fill_b(dc >> 3);
- out = __msa_copy_s_d((v2i64)dctemp, 0);
- STORE8x8(out, dst);
-}
-
-static void DC8uvNoTopLeft(uint8_t* dst) { // DC with nothing
- const uint64_t out = 0x8080808080808080ULL;
- STORE8x8(out, dst);
-}
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void VP8DspInitMSA(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void VP8DspInitMSA(void) {
- VP8TransformWHT = TransformWHT;
- VP8Transform = TransformTwo;
- VP8TransformDC = TransformDC;
- VP8TransformAC3 = TransformAC3;
-
- VP8VFilter16 = VFilter16;
- VP8HFilter16 = HFilter16;
- VP8VFilter16i = VFilter16i;
- VP8HFilter16i = HFilter16i;
- VP8VFilter8 = VFilter8;
- VP8HFilter8 = HFilter8;
- VP8VFilter8i = VFilter8i;
- VP8HFilter8i = HFilter8i;
- VP8SimpleVFilter16 = SimpleVFilter16;
- VP8SimpleHFilter16 = SimpleHFilter16;
- VP8SimpleVFilter16i = SimpleVFilter16i;
- VP8SimpleHFilter16i = SimpleHFilter16i;
-
- VP8PredLuma4[0] = DC4;
- VP8PredLuma4[1] = TM4;
- VP8PredLuma4[2] = VE4;
- VP8PredLuma4[4] = RD4;
- VP8PredLuma4[6] = LD4;
- VP8PredLuma16[0] = DC16;
- VP8PredLuma16[1] = TM16;
- VP8PredLuma16[2] = VE16;
- VP8PredLuma16[3] = HE16;
- VP8PredLuma16[4] = DC16NoTop;
- VP8PredLuma16[5] = DC16NoLeft;
- VP8PredLuma16[6] = DC16NoTopLeft;
- VP8PredChroma8[0] = DC8uv;
- VP8PredChroma8[1] = TM8uv;
- VP8PredChroma8[2] = VE8uv;
- VP8PredChroma8[3] = HE8uv;
- VP8PredChroma8[4] = DC8uvNoTop;
- VP8PredChroma8[5] = DC8uvNoLeft;
- VP8PredChroma8[6] = DC8uvNoTopLeft;
-}
-
-#else // !WEBP_USE_MSA
-
-WEBP_DSP_INIT_STUB(VP8DspInitMSA)
-
-#endif // WEBP_USE_MSA
diff --git a/contrib/libs/libwebp/dsp/dec_neon.c b/contrib/libs/libwebp/dsp/dec_neon.c
deleted file mode 100644
index 61f81271ec..0000000000
--- a/contrib/libs/libwebp/dsp/dec_neon.c
+++ /dev/null
@@ -1,1663 +0,0 @@
-// Copyright 2012 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// ARM NEON version of dsp functions and loop filtering.
-//
-// Authors: Somnath Banerjee (somnath@google.com)
-// Johann Koenig (johannkoenig@google.com)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_NEON)
-
-#include "./neon.h"
-#include "../dec/vp8i_dec.h"
-
-//------------------------------------------------------------------------------
-// NxM Loading functions
-
-#if !defined(WORK_AROUND_GCC)
-
-// This intrinsics version makes gcc-4.6.3 crash during Load4x??() compilation
-// (register alloc, probably). The variants somewhat mitigate the problem, but
-// not quite. HFilter16i() remains problematic.
-static WEBP_INLINE uint8x8x4_t Load4x8_NEON(const uint8_t* const src,
- int stride) {
- const uint8x8_t zero = vdup_n_u8(0);
- uint8x8x4_t out;
- INIT_VECTOR4(out, zero, zero, zero, zero);
- out = vld4_lane_u8(src + 0 * stride, out, 0);
- out = vld4_lane_u8(src + 1 * stride, out, 1);
- out = vld4_lane_u8(src + 2 * stride, out, 2);
- out = vld4_lane_u8(src + 3 * stride, out, 3);
- out = vld4_lane_u8(src + 4 * stride, out, 4);
- out = vld4_lane_u8(src + 5 * stride, out, 5);
- out = vld4_lane_u8(src + 6 * stride, out, 6);
- out = vld4_lane_u8(src + 7 * stride, out, 7);
- return out;
-}
-
-static WEBP_INLINE void Load4x16_NEON(const uint8_t* const src, int stride,
- uint8x16_t* const p1,
- uint8x16_t* const p0,
- uint8x16_t* const q0,
- uint8x16_t* const q1) {
- // row0 = p1[0..7]|p0[0..7]|q0[0..7]|q1[0..7]
- // row8 = p1[8..15]|p0[8..15]|q0[8..15]|q1[8..15]
- const uint8x8x4_t row0 = Load4x8_NEON(src - 2 + 0 * stride, stride);
- const uint8x8x4_t row8 = Load4x8_NEON(src - 2 + 8 * stride, stride);
- *p1 = vcombine_u8(row0.val[0], row8.val[0]);
- *p0 = vcombine_u8(row0.val[1], row8.val[1]);
- *q0 = vcombine_u8(row0.val[2], row8.val[2]);
- *q1 = vcombine_u8(row0.val[3], row8.val[3]);
-}
-
-#else // WORK_AROUND_GCC
-
-#define LOADQ_LANE_32b(VALUE, LANE) do { \
- (VALUE) = vld1q_lane_u32((const uint32_t*)src, (VALUE), (LANE)); \
- src += stride; \
-} while (0)
-
-static WEBP_INLINE void Load4x16_NEON(const uint8_t* src, int stride,
- uint8x16_t* const p1,
- uint8x16_t* const p0,
- uint8x16_t* const q0,
- uint8x16_t* const q1) {
- const uint32x4_t zero = vdupq_n_u32(0);
- uint32x4x4_t in;
- INIT_VECTOR4(in, zero, zero, zero, zero);
- src -= 2;
- LOADQ_LANE_32b(in.val[0], 0);
- LOADQ_LANE_32b(in.val[1], 0);
- LOADQ_LANE_32b(in.val[2], 0);
- LOADQ_LANE_32b(in.val[3], 0);
- LOADQ_LANE_32b(in.val[0], 1);
- LOADQ_LANE_32b(in.val[1], 1);
- LOADQ_LANE_32b(in.val[2], 1);
- LOADQ_LANE_32b(in.val[3], 1);
- LOADQ_LANE_32b(in.val[0], 2);
- LOADQ_LANE_32b(in.val[1], 2);
- LOADQ_LANE_32b(in.val[2], 2);
- LOADQ_LANE_32b(in.val[3], 2);
- LOADQ_LANE_32b(in.val[0], 3);
- LOADQ_LANE_32b(in.val[1], 3);
- LOADQ_LANE_32b(in.val[2], 3);
- LOADQ_LANE_32b(in.val[3], 3);
- // Transpose four 4x4 parts:
- {
- const uint8x16x2_t row01 = vtrnq_u8(vreinterpretq_u8_u32(in.val[0]),
- vreinterpretq_u8_u32(in.val[1]));
- const uint8x16x2_t row23 = vtrnq_u8(vreinterpretq_u8_u32(in.val[2]),
- vreinterpretq_u8_u32(in.val[3]));
- const uint16x8x2_t row02 = vtrnq_u16(vreinterpretq_u16_u8(row01.val[0]),
- vreinterpretq_u16_u8(row23.val[0]));
- const uint16x8x2_t row13 = vtrnq_u16(vreinterpretq_u16_u8(row01.val[1]),
- vreinterpretq_u16_u8(row23.val[1]));
- *p1 = vreinterpretq_u8_u16(row02.val[0]);
- *p0 = vreinterpretq_u8_u16(row13.val[0]);
- *q0 = vreinterpretq_u8_u16(row02.val[1]);
- *q1 = vreinterpretq_u8_u16(row13.val[1]);
- }
-}
-#undef LOADQ_LANE_32b
-
-#endif // !WORK_AROUND_GCC
-
-static WEBP_INLINE void Load8x16_NEON(
- const uint8_t* const src, int stride,
- uint8x16_t* const p3, uint8x16_t* const p2, uint8x16_t* const p1,
- uint8x16_t* const p0, uint8x16_t* const q0, uint8x16_t* const q1,
- uint8x16_t* const q2, uint8x16_t* const q3) {
- Load4x16_NEON(src - 2, stride, p3, p2, p1, p0);
- Load4x16_NEON(src + 2, stride, q0, q1, q2, q3);
-}
-
-static WEBP_INLINE void Load16x4_NEON(const uint8_t* const src, int stride,
- uint8x16_t* const p1,
- uint8x16_t* const p0,
- uint8x16_t* const q0,
- uint8x16_t* const q1) {
- *p1 = vld1q_u8(src - 2 * stride);
- *p0 = vld1q_u8(src - 1 * stride);
- *q0 = vld1q_u8(src + 0 * stride);
- *q1 = vld1q_u8(src + 1 * stride);
-}
-
-static WEBP_INLINE void Load16x8_NEON(
- const uint8_t* const src, int stride,
- uint8x16_t* const p3, uint8x16_t* const p2, uint8x16_t* const p1,
- uint8x16_t* const p0, uint8x16_t* const q0, uint8x16_t* const q1,
- uint8x16_t* const q2, uint8x16_t* const q3) {
- Load16x4_NEON(src - 2 * stride, stride, p3, p2, p1, p0);
- Load16x4_NEON(src + 2 * stride, stride, q0, q1, q2, q3);
-}
-
-static WEBP_INLINE void Load8x8x2_NEON(
- const uint8_t* const u, const uint8_t* const v, int stride,
- uint8x16_t* const p3, uint8x16_t* const p2, uint8x16_t* const p1,
- uint8x16_t* const p0, uint8x16_t* const q0, uint8x16_t* const q1,
- uint8x16_t* const q2, uint8x16_t* const q3) {
- // We pack the 8x8 u-samples in the lower half of the uint8x16_t destination
- // and the v-samples on the higher half.
- *p3 = vcombine_u8(vld1_u8(u - 4 * stride), vld1_u8(v - 4 * stride));
- *p2 = vcombine_u8(vld1_u8(u - 3 * stride), vld1_u8(v - 3 * stride));
- *p1 = vcombine_u8(vld1_u8(u - 2 * stride), vld1_u8(v - 2 * stride));
- *p0 = vcombine_u8(vld1_u8(u - 1 * stride), vld1_u8(v - 1 * stride));
- *q0 = vcombine_u8(vld1_u8(u + 0 * stride), vld1_u8(v + 0 * stride));
- *q1 = vcombine_u8(vld1_u8(u + 1 * stride), vld1_u8(v + 1 * stride));
- *q2 = vcombine_u8(vld1_u8(u + 2 * stride), vld1_u8(v + 2 * stride));
- *q3 = vcombine_u8(vld1_u8(u + 3 * stride), vld1_u8(v + 3 * stride));
-}
-
-#if !defined(WORK_AROUND_GCC)
-
-#define LOAD_UV_8(ROW) \
- vcombine_u8(vld1_u8(u - 4 + (ROW) * stride), vld1_u8(v - 4 + (ROW) * stride))
-
-static WEBP_INLINE void Load8x8x2T_NEON(
- const uint8_t* const u, const uint8_t* const v, int stride,
- uint8x16_t* const p3, uint8x16_t* const p2, uint8x16_t* const p1,
- uint8x16_t* const p0, uint8x16_t* const q0, uint8x16_t* const q1,
- uint8x16_t* const q2, uint8x16_t* const q3) {
- // We pack the 8x8 u-samples in the lower half of the uint8x16_t destination
- // and the v-samples on the higher half.
- const uint8x16_t row0 = LOAD_UV_8(0);
- const uint8x16_t row1 = LOAD_UV_8(1);
- const uint8x16_t row2 = LOAD_UV_8(2);
- const uint8x16_t row3 = LOAD_UV_8(3);
- const uint8x16_t row4 = LOAD_UV_8(4);
- const uint8x16_t row5 = LOAD_UV_8(5);
- const uint8x16_t row6 = LOAD_UV_8(6);
- const uint8x16_t row7 = LOAD_UV_8(7);
- // Perform two side-by-side 8x8 transposes
- // u00 u01 u02 u03 u04 u05 u06 u07 | v00 v01 v02 v03 v04 v05 v06 v07
- // u10 u11 u12 u13 u14 u15 u16 u17 | v10 v11 v12 ...
- // u20 u21 u22 u23 u24 u25 u26 u27 | v20 v21 ...
- // u30 u31 u32 u33 u34 u35 u36 u37 | ...
- // u40 u41 u42 u43 u44 u45 u46 u47 | ...
- // u50 u51 u52 u53 u54 u55 u56 u57 | ...
- // u60 u61 u62 u63 u64 u65 u66 u67 | v60 ...
- // u70 u71 u72 u73 u74 u75 u76 u77 | v70 v71 v72 ...
- const uint8x16x2_t row01 = vtrnq_u8(row0, row1); // u00 u10 u02 u12 ...
- // u01 u11 u03 u13 ...
- const uint8x16x2_t row23 = vtrnq_u8(row2, row3); // u20 u30 u22 u32 ...
- // u21 u31 u23 u33 ...
- const uint8x16x2_t row45 = vtrnq_u8(row4, row5); // ...
- const uint8x16x2_t row67 = vtrnq_u8(row6, row7); // ...
- const uint16x8x2_t row02 = vtrnq_u16(vreinterpretq_u16_u8(row01.val[0]),
- vreinterpretq_u16_u8(row23.val[0]));
- const uint16x8x2_t row13 = vtrnq_u16(vreinterpretq_u16_u8(row01.val[1]),
- vreinterpretq_u16_u8(row23.val[1]));
- const uint16x8x2_t row46 = vtrnq_u16(vreinterpretq_u16_u8(row45.val[0]),
- vreinterpretq_u16_u8(row67.val[0]));
- const uint16x8x2_t row57 = vtrnq_u16(vreinterpretq_u16_u8(row45.val[1]),
- vreinterpretq_u16_u8(row67.val[1]));
- const uint32x4x2_t row04 = vtrnq_u32(vreinterpretq_u32_u16(row02.val[0]),
- vreinterpretq_u32_u16(row46.val[0]));
- const uint32x4x2_t row26 = vtrnq_u32(vreinterpretq_u32_u16(row02.val[1]),
- vreinterpretq_u32_u16(row46.val[1]));
- const uint32x4x2_t row15 = vtrnq_u32(vreinterpretq_u32_u16(row13.val[0]),
- vreinterpretq_u32_u16(row57.val[0]));
- const uint32x4x2_t row37 = vtrnq_u32(vreinterpretq_u32_u16(row13.val[1]),
- vreinterpretq_u32_u16(row57.val[1]));
- *p3 = vreinterpretq_u8_u32(row04.val[0]);
- *p2 = vreinterpretq_u8_u32(row15.val[0]);
- *p1 = vreinterpretq_u8_u32(row26.val[0]);
- *p0 = vreinterpretq_u8_u32(row37.val[0]);
- *q0 = vreinterpretq_u8_u32(row04.val[1]);
- *q1 = vreinterpretq_u8_u32(row15.val[1]);
- *q2 = vreinterpretq_u8_u32(row26.val[1]);
- *q3 = vreinterpretq_u8_u32(row37.val[1]);
-}
-#undef LOAD_UV_8
-
-#endif // !WORK_AROUND_GCC
-
-static WEBP_INLINE void Store2x8_NEON(const uint8x8x2_t v,
- uint8_t* const dst, int stride) {
- vst2_lane_u8(dst + 0 * stride, v, 0);
- vst2_lane_u8(dst + 1 * stride, v, 1);
- vst2_lane_u8(dst + 2 * stride, v, 2);
- vst2_lane_u8(dst + 3 * stride, v, 3);
- vst2_lane_u8(dst + 4 * stride, v, 4);
- vst2_lane_u8(dst + 5 * stride, v, 5);
- vst2_lane_u8(dst + 6 * stride, v, 6);
- vst2_lane_u8(dst + 7 * stride, v, 7);
-}
-
-static WEBP_INLINE void Store2x16_NEON(const uint8x16_t p0, const uint8x16_t q0,
- uint8_t* const dst, int stride) {
- uint8x8x2_t lo, hi;
- lo.val[0] = vget_low_u8(p0);
- lo.val[1] = vget_low_u8(q0);
- hi.val[0] = vget_high_u8(p0);
- hi.val[1] = vget_high_u8(q0);
- Store2x8_NEON(lo, dst - 1 + 0 * stride, stride);
- Store2x8_NEON(hi, dst - 1 + 8 * stride, stride);
-}
-
-#if !defined(WORK_AROUND_GCC)
-static WEBP_INLINE void Store4x8_NEON(const uint8x8x4_t v,
- uint8_t* const dst, int stride) {
- vst4_lane_u8(dst + 0 * stride, v, 0);
- vst4_lane_u8(dst + 1 * stride, v, 1);
- vst4_lane_u8(dst + 2 * stride, v, 2);
- vst4_lane_u8(dst + 3 * stride, v, 3);
- vst4_lane_u8(dst + 4 * stride, v, 4);
- vst4_lane_u8(dst + 5 * stride, v, 5);
- vst4_lane_u8(dst + 6 * stride, v, 6);
- vst4_lane_u8(dst + 7 * stride, v, 7);
-}
-
-static WEBP_INLINE void Store4x16_NEON(const uint8x16_t p1, const uint8x16_t p0,
- const uint8x16_t q0, const uint8x16_t q1,
- uint8_t* const dst, int stride) {
- uint8x8x4_t lo, hi;
- INIT_VECTOR4(lo,
- vget_low_u8(p1), vget_low_u8(p0),
- vget_low_u8(q0), vget_low_u8(q1));
- INIT_VECTOR4(hi,
- vget_high_u8(p1), vget_high_u8(p0),
- vget_high_u8(q0), vget_high_u8(q1));
- Store4x8_NEON(lo, dst - 2 + 0 * stride, stride);
- Store4x8_NEON(hi, dst - 2 + 8 * stride, stride);
-}
-#endif // !WORK_AROUND_GCC
-
-static WEBP_INLINE void Store16x2_NEON(const uint8x16_t p0, const uint8x16_t q0,
- uint8_t* const dst, int stride) {
- vst1q_u8(dst - stride, p0);
- vst1q_u8(dst, q0);
-}
-
-static WEBP_INLINE void Store16x4_NEON(const uint8x16_t p1, const uint8x16_t p0,
- const uint8x16_t q0, const uint8x16_t q1,
- uint8_t* const dst, int stride) {
- Store16x2_NEON(p1, p0, dst - stride, stride);
- Store16x2_NEON(q0, q1, dst + stride, stride);
-}
-
-static WEBP_INLINE void Store8x2x2_NEON(const uint8x16_t p0,
- const uint8x16_t q0,
- uint8_t* const u, uint8_t* const v,
- int stride) {
- // p0 and q0 contain the u+v samples packed in low/high halves.
- vst1_u8(u - stride, vget_low_u8(p0));
- vst1_u8(u, vget_low_u8(q0));
- vst1_u8(v - stride, vget_high_u8(p0));
- vst1_u8(v, vget_high_u8(q0));
-}
-
-static WEBP_INLINE void Store8x4x2_NEON(const uint8x16_t p1,
- const uint8x16_t p0,
- const uint8x16_t q0,
- const uint8x16_t q1,
- uint8_t* const u, uint8_t* const v,
- int stride) {
- // The p1...q1 registers contain the u+v samples packed in low/high halves.
- Store8x2x2_NEON(p1, p0, u - stride, v - stride, stride);
- Store8x2x2_NEON(q0, q1, u + stride, v + stride, stride);
-}
-
-#if !defined(WORK_AROUND_GCC)
-
-#define STORE6_LANE(DST, VAL0, VAL1, LANE) do { \
- vst3_lane_u8((DST) - 3, (VAL0), (LANE)); \
- vst3_lane_u8((DST) + 0, (VAL1), (LANE)); \
- (DST) += stride; \
-} while (0)
-
-static WEBP_INLINE void Store6x8x2_NEON(
- const uint8x16_t p2, const uint8x16_t p1, const uint8x16_t p0,
- const uint8x16_t q0, const uint8x16_t q1, const uint8x16_t q2,
- uint8_t* u, uint8_t* v, int stride) {
- uint8x8x3_t u0, u1, v0, v1;
- INIT_VECTOR3(u0, vget_low_u8(p2), vget_low_u8(p1), vget_low_u8(p0));
- INIT_VECTOR3(u1, vget_low_u8(q0), vget_low_u8(q1), vget_low_u8(q2));
- INIT_VECTOR3(v0, vget_high_u8(p2), vget_high_u8(p1), vget_high_u8(p0));
- INIT_VECTOR3(v1, vget_high_u8(q0), vget_high_u8(q1), vget_high_u8(q2));
- STORE6_LANE(u, u0, u1, 0);
- STORE6_LANE(u, u0, u1, 1);
- STORE6_LANE(u, u0, u1, 2);
- STORE6_LANE(u, u0, u1, 3);
- STORE6_LANE(u, u0, u1, 4);
- STORE6_LANE(u, u0, u1, 5);
- STORE6_LANE(u, u0, u1, 6);
- STORE6_LANE(u, u0, u1, 7);
- STORE6_LANE(v, v0, v1, 0);
- STORE6_LANE(v, v0, v1, 1);
- STORE6_LANE(v, v0, v1, 2);
- STORE6_LANE(v, v0, v1, 3);
- STORE6_LANE(v, v0, v1, 4);
- STORE6_LANE(v, v0, v1, 5);
- STORE6_LANE(v, v0, v1, 6);
- STORE6_LANE(v, v0, v1, 7);
-}
-#undef STORE6_LANE
-
-static WEBP_INLINE void Store4x8x2_NEON(const uint8x16_t p1,
- const uint8x16_t p0,
- const uint8x16_t q0,
- const uint8x16_t q1,
- uint8_t* const u, uint8_t* const v,
- int stride) {
- uint8x8x4_t u0, v0;
- INIT_VECTOR4(u0,
- vget_low_u8(p1), vget_low_u8(p0),
- vget_low_u8(q0), vget_low_u8(q1));
- INIT_VECTOR4(v0,
- vget_high_u8(p1), vget_high_u8(p0),
- vget_high_u8(q0), vget_high_u8(q1));
- vst4_lane_u8(u - 2 + 0 * stride, u0, 0);
- vst4_lane_u8(u - 2 + 1 * stride, u0, 1);
- vst4_lane_u8(u - 2 + 2 * stride, u0, 2);
- vst4_lane_u8(u - 2 + 3 * stride, u0, 3);
- vst4_lane_u8(u - 2 + 4 * stride, u0, 4);
- vst4_lane_u8(u - 2 + 5 * stride, u0, 5);
- vst4_lane_u8(u - 2 + 6 * stride, u0, 6);
- vst4_lane_u8(u - 2 + 7 * stride, u0, 7);
- vst4_lane_u8(v - 2 + 0 * stride, v0, 0);
- vst4_lane_u8(v - 2 + 1 * stride, v0, 1);
- vst4_lane_u8(v - 2 + 2 * stride, v0, 2);
- vst4_lane_u8(v - 2 + 3 * stride, v0, 3);
- vst4_lane_u8(v - 2 + 4 * stride, v0, 4);
- vst4_lane_u8(v - 2 + 5 * stride, v0, 5);
- vst4_lane_u8(v - 2 + 6 * stride, v0, 6);
- vst4_lane_u8(v - 2 + 7 * stride, v0, 7);
-}
-
-#endif // !WORK_AROUND_GCC
-
-// Zero extend 'v' to an int16x8_t.
-static WEBP_INLINE int16x8_t ConvertU8ToS16_NEON(uint8x8_t v) {
- return vreinterpretq_s16_u16(vmovl_u8(v));
-}
-
-// Performs unsigned 8b saturation on 'dst01' and 'dst23' storing the result
-// to the corresponding rows of 'dst'.
-static WEBP_INLINE void SaturateAndStore4x4_NEON(uint8_t* const dst,
- const int16x8_t dst01,
- const int16x8_t dst23) {
- // Unsigned saturate to 8b.
- const uint8x8_t dst01_u8 = vqmovun_s16(dst01);
- const uint8x8_t dst23_u8 = vqmovun_s16(dst23);
-
- // Store the results.
- vst1_lane_u32((uint32_t*)(dst + 0 * BPS), vreinterpret_u32_u8(dst01_u8), 0);
- vst1_lane_u32((uint32_t*)(dst + 1 * BPS), vreinterpret_u32_u8(dst01_u8), 1);
- vst1_lane_u32((uint32_t*)(dst + 2 * BPS), vreinterpret_u32_u8(dst23_u8), 0);
- vst1_lane_u32((uint32_t*)(dst + 3 * BPS), vreinterpret_u32_u8(dst23_u8), 1);
-}
-
-static WEBP_INLINE void Add4x4_NEON(const int16x8_t row01,
- const int16x8_t row23,
- uint8_t* const dst) {
- uint32x2_t dst01 = vdup_n_u32(0);
- uint32x2_t dst23 = vdup_n_u32(0);
-
- // Load the source pixels.
- dst01 = vld1_lane_u32((uint32_t*)(dst + 0 * BPS), dst01, 0);
- dst23 = vld1_lane_u32((uint32_t*)(dst + 2 * BPS), dst23, 0);
- dst01 = vld1_lane_u32((uint32_t*)(dst + 1 * BPS), dst01, 1);
- dst23 = vld1_lane_u32((uint32_t*)(dst + 3 * BPS), dst23, 1);
-
- {
- // Convert to 16b.
- const int16x8_t dst01_s16 = ConvertU8ToS16_NEON(vreinterpret_u8_u32(dst01));
- const int16x8_t dst23_s16 = ConvertU8ToS16_NEON(vreinterpret_u8_u32(dst23));
-
- // Descale with rounding.
- const int16x8_t out01 = vrsraq_n_s16(dst01_s16, row01, 3);
- const int16x8_t out23 = vrsraq_n_s16(dst23_s16, row23, 3);
- // Add the inverse transform.
- SaturateAndStore4x4_NEON(dst, out01, out23);
- }
-}
-
-//-----------------------------------------------------------------------------
-// Simple In-loop filtering (Paragraph 15.2)
-
-static uint8x16_t NeedsFilter_NEON(const uint8x16_t p1, const uint8x16_t p0,
- const uint8x16_t q0, const uint8x16_t q1,
- int thresh) {
- const uint8x16_t thresh_v = vdupq_n_u8((uint8_t)thresh);
- const uint8x16_t a_p0_q0 = vabdq_u8(p0, q0); // abs(p0-q0)
- const uint8x16_t a_p1_q1 = vabdq_u8(p1, q1); // abs(p1-q1)
- const uint8x16_t a_p0_q0_2 = vqaddq_u8(a_p0_q0, a_p0_q0); // 2 * abs(p0-q0)
- const uint8x16_t a_p1_q1_2 = vshrq_n_u8(a_p1_q1, 1); // abs(p1-q1) / 2
- const uint8x16_t sum = vqaddq_u8(a_p0_q0_2, a_p1_q1_2);
- const uint8x16_t mask = vcgeq_u8(thresh_v, sum);
- return mask;
-}
-
-static int8x16_t FlipSign_NEON(const uint8x16_t v) {
- const uint8x16_t sign_bit = vdupq_n_u8(0x80);
- return vreinterpretq_s8_u8(veorq_u8(v, sign_bit));
-}
-
-static uint8x16_t FlipSignBack_NEON(const int8x16_t v) {
- const int8x16_t sign_bit = vdupq_n_s8(0x80);
- return vreinterpretq_u8_s8(veorq_s8(v, sign_bit));
-}
-
-static int8x16_t GetBaseDelta_NEON(const int8x16_t p1, const int8x16_t p0,
- const int8x16_t q0, const int8x16_t q1) {
- const int8x16_t q0_p0 = vqsubq_s8(q0, p0); // (q0-p0)
- const int8x16_t p1_q1 = vqsubq_s8(p1, q1); // (p1-q1)
- const int8x16_t s1 = vqaddq_s8(p1_q1, q0_p0); // (p1-q1) + 1 * (q0 - p0)
- const int8x16_t s2 = vqaddq_s8(q0_p0, s1); // (p1-q1) + 2 * (q0 - p0)
- const int8x16_t s3 = vqaddq_s8(q0_p0, s2); // (p1-q1) + 3 * (q0 - p0)
- return s3;
-}
-
-static int8x16_t GetBaseDelta0_NEON(const int8x16_t p0, const int8x16_t q0) {
- const int8x16_t q0_p0 = vqsubq_s8(q0, p0); // (q0-p0)
- const int8x16_t s1 = vqaddq_s8(q0_p0, q0_p0); // 2 * (q0 - p0)
- const int8x16_t s2 = vqaddq_s8(q0_p0, s1); // 3 * (q0 - p0)
- return s2;
-}
-
-//------------------------------------------------------------------------------
-
-static void ApplyFilter2NoFlip_NEON(const int8x16_t p0s, const int8x16_t q0s,
- const int8x16_t delta,
- int8x16_t* const op0,
- int8x16_t* const oq0) {
- const int8x16_t kCst3 = vdupq_n_s8(0x03);
- const int8x16_t kCst4 = vdupq_n_s8(0x04);
- const int8x16_t delta_p3 = vqaddq_s8(delta, kCst3);
- const int8x16_t delta_p4 = vqaddq_s8(delta, kCst4);
- const int8x16_t delta3 = vshrq_n_s8(delta_p3, 3);
- const int8x16_t delta4 = vshrq_n_s8(delta_p4, 3);
- *op0 = vqaddq_s8(p0s, delta3);
- *oq0 = vqsubq_s8(q0s, delta4);
-}
-
-#if defined(WEBP_USE_INTRINSICS)
-
-static void ApplyFilter2_NEON(const int8x16_t p0s, const int8x16_t q0s,
- const int8x16_t delta,
- uint8x16_t* const op0, uint8x16_t* const oq0) {
- const int8x16_t kCst3 = vdupq_n_s8(0x03);
- const int8x16_t kCst4 = vdupq_n_s8(0x04);
- const int8x16_t delta_p3 = vqaddq_s8(delta, kCst3);
- const int8x16_t delta_p4 = vqaddq_s8(delta, kCst4);
- const int8x16_t delta3 = vshrq_n_s8(delta_p3, 3);
- const int8x16_t delta4 = vshrq_n_s8(delta_p4, 3);
- const int8x16_t sp0 = vqaddq_s8(p0s, delta3);
- const int8x16_t sq0 = vqsubq_s8(q0s, delta4);
- *op0 = FlipSignBack_NEON(sp0);
- *oq0 = FlipSignBack_NEON(sq0);
-}
-
-static void DoFilter2_NEON(const uint8x16_t p1, const uint8x16_t p0,
- const uint8x16_t q0, const uint8x16_t q1,
- const uint8x16_t mask,
- uint8x16_t* const op0, uint8x16_t* const oq0) {
- const int8x16_t p1s = FlipSign_NEON(p1);
- const int8x16_t p0s = FlipSign_NEON(p0);
- const int8x16_t q0s = FlipSign_NEON(q0);
- const int8x16_t q1s = FlipSign_NEON(q1);
- const int8x16_t delta0 = GetBaseDelta_NEON(p1s, p0s, q0s, q1s);
- const int8x16_t delta1 = vandq_s8(delta0, vreinterpretq_s8_u8(mask));
- ApplyFilter2_NEON(p0s, q0s, delta1, op0, oq0);
-}
-
-static void SimpleVFilter16_NEON(uint8_t* p, int stride, int thresh) {
- uint8x16_t p1, p0, q0, q1, op0, oq0;
- Load16x4_NEON(p, stride, &p1, &p0, &q0, &q1);
- {
- const uint8x16_t mask = NeedsFilter_NEON(p1, p0, q0, q1, thresh);
- DoFilter2_NEON(p1, p0, q0, q1, mask, &op0, &oq0);
- }
- Store16x2_NEON(op0, oq0, p, stride);
-}
-
-static void SimpleHFilter16_NEON(uint8_t* p, int stride, int thresh) {
- uint8x16_t p1, p0, q0, q1, oq0, op0;
- Load4x16_NEON(p, stride, &p1, &p0, &q0, &q1);
- {
- const uint8x16_t mask = NeedsFilter_NEON(p1, p0, q0, q1, thresh);
- DoFilter2_NEON(p1, p0, q0, q1, mask, &op0, &oq0);
- }
- Store2x16_NEON(op0, oq0, p, stride);
-}
-
-#else
-
-// Load/Store vertical edge
-#define LOAD8x4(c1, c2, c3, c4, b1, b2, stride) \
- "vld4.8 {" #c1 "[0]," #c2 "[0]," #c3 "[0]," #c4 "[0]}," #b1 "," #stride "\n" \
- "vld4.8 {" #c1 "[1]," #c2 "[1]," #c3 "[1]," #c4 "[1]}," #b2 "," #stride "\n" \
- "vld4.8 {" #c1 "[2]," #c2 "[2]," #c3 "[2]," #c4 "[2]}," #b1 "," #stride "\n" \
- "vld4.8 {" #c1 "[3]," #c2 "[3]," #c3 "[3]," #c4 "[3]}," #b2 "," #stride "\n" \
- "vld4.8 {" #c1 "[4]," #c2 "[4]," #c3 "[4]," #c4 "[4]}," #b1 "," #stride "\n" \
- "vld4.8 {" #c1 "[5]," #c2 "[5]," #c3 "[5]," #c4 "[5]}," #b2 "," #stride "\n" \
- "vld4.8 {" #c1 "[6]," #c2 "[6]," #c3 "[6]," #c4 "[6]}," #b1 "," #stride "\n" \
- "vld4.8 {" #c1 "[7]," #c2 "[7]," #c3 "[7]," #c4 "[7]}," #b2 "," #stride "\n"
-
-#define STORE8x2(c1, c2, p, stride) \
- "vst2.8 {" #c1 "[0], " #c2 "[0]}," #p "," #stride " \n" \
- "vst2.8 {" #c1 "[1], " #c2 "[1]}," #p "," #stride " \n" \
- "vst2.8 {" #c1 "[2], " #c2 "[2]}," #p "," #stride " \n" \
- "vst2.8 {" #c1 "[3], " #c2 "[3]}," #p "," #stride " \n" \
- "vst2.8 {" #c1 "[4], " #c2 "[4]}," #p "," #stride " \n" \
- "vst2.8 {" #c1 "[5], " #c2 "[5]}," #p "," #stride " \n" \
- "vst2.8 {" #c1 "[6], " #c2 "[6]}," #p "," #stride " \n" \
- "vst2.8 {" #c1 "[7], " #c2 "[7]}," #p "," #stride " \n"
-
-#define QRegs "q0", "q1", "q2", "q3", \
- "q8", "q9", "q10", "q11", "q12", "q13", "q14", "q15"
-
-#define FLIP_SIGN_BIT2(a, b, s) \
- "veor " #a "," #a "," #s " \n" \
- "veor " #b "," #b "," #s " \n" \
-
-#define FLIP_SIGN_BIT4(a, b, c, d, s) \
- FLIP_SIGN_BIT2(a, b, s) \
- FLIP_SIGN_BIT2(c, d, s) \
-
-#define NEEDS_FILTER(p1, p0, q0, q1, thresh, mask) \
- "vabd.u8 q15," #p0 "," #q0 " \n" /* abs(p0 - q0) */ \
- "vabd.u8 q14," #p1 "," #q1 " \n" /* abs(p1 - q1) */ \
- "vqadd.u8 q15, q15, q15 \n" /* abs(p0 - q0) * 2 */ \
- "vshr.u8 q14, q14, #1 \n" /* abs(p1 - q1) / 2 */ \
- "vqadd.u8 q15, q15, q14 \n" /* abs(p0 - q0) * 2 + abs(p1 - q1) / 2 */ \
- "vdup.8 q14, " #thresh " \n" \
- "vcge.u8 " #mask ", q14, q15 \n" /* mask <= thresh */
-
-#define GET_BASE_DELTA(p1, p0, q0, q1, o) \
- "vqsub.s8 q15," #q0 "," #p0 " \n" /* (q0 - p0) */ \
- "vqsub.s8 " #o "," #p1 "," #q1 " \n" /* (p1 - q1) */ \
- "vqadd.s8 " #o "," #o ", q15 \n" /* (p1 - q1) + 1 * (p0 - q0) */ \
- "vqadd.s8 " #o "," #o ", q15 \n" /* (p1 - q1) + 2 * (p0 - q0) */ \
- "vqadd.s8 " #o "," #o ", q15 \n" /* (p1 - q1) + 3 * (p0 - q0) */
-
-#define DO_SIMPLE_FILTER(p0, q0, fl) \
- "vmov.i8 q15, #0x03 \n" \
- "vqadd.s8 q15, q15, " #fl " \n" /* filter1 = filter + 3 */ \
- "vshr.s8 q15, q15, #3 \n" /* filter1 >> 3 */ \
- "vqadd.s8 " #p0 "," #p0 ", q15 \n" /* p0 += filter1 */ \
- \
- "vmov.i8 q15, #0x04 \n" \
- "vqadd.s8 q15, q15, " #fl " \n" /* filter1 = filter + 4 */ \
- "vshr.s8 q15, q15, #3 \n" /* filter2 >> 3 */ \
- "vqsub.s8 " #q0 "," #q0 ", q15 \n" /* q0 -= filter2 */
-
-// Applies filter on 2 pixels (p0 and q0)
-#define DO_FILTER2(p1, p0, q0, q1, thresh) \
- NEEDS_FILTER(p1, p0, q0, q1, thresh, q9) /* filter mask in q9 */ \
- "vmov.i8 q10, #0x80 \n" /* sign bit */ \
- FLIP_SIGN_BIT4(p1, p0, q0, q1, q10) /* convert to signed value */ \
- GET_BASE_DELTA(p1, p0, q0, q1, q11) /* get filter level */ \
- "vand q9, q9, q11 \n" /* apply filter mask */ \
- DO_SIMPLE_FILTER(p0, q0, q9) /* apply filter */ \
- FLIP_SIGN_BIT2(p0, q0, q10)
-
-static void SimpleVFilter16_NEON(uint8_t* p, int stride, int thresh) {
- __asm__ volatile (
- "sub %[p], %[p], %[stride], lsl #1 \n" // p -= 2 * stride
-
- "vld1.u8 {q1}, [%[p]], %[stride] \n" // p1
- "vld1.u8 {q2}, [%[p]], %[stride] \n" // p0
- "vld1.u8 {q3}, [%[p]], %[stride] \n" // q0
- "vld1.u8 {q12}, [%[p]] \n" // q1
-
- DO_FILTER2(q1, q2, q3, q12, %[thresh])
-
- "sub %[p], %[p], %[stride], lsl #1 \n" // p -= 2 * stride
-
- "vst1.u8 {q2}, [%[p]], %[stride] \n" // store op0
- "vst1.u8 {q3}, [%[p]] \n" // store oq0
- : [p] "+r"(p)
- : [stride] "r"(stride), [thresh] "r"(thresh)
- : "memory", QRegs
- );
-}
-
-static void SimpleHFilter16_NEON(uint8_t* p, int stride, int thresh) {
- __asm__ volatile (
- "sub r4, %[p], #2 \n" // base1 = p - 2
- "lsl r6, %[stride], #1 \n" // r6 = 2 * stride
- "add r5, r4, %[stride] \n" // base2 = base1 + stride
-
- LOAD8x4(d2, d3, d4, d5, [r4], [r5], r6)
- LOAD8x4(d24, d25, d26, d27, [r4], [r5], r6)
- "vswp d3, d24 \n" // p1:q1 p0:q3
- "vswp d5, d26 \n" // q0:q2 q1:q4
- "vswp q2, q12 \n" // p1:q1 p0:q2 q0:q3 q1:q4
-
- DO_FILTER2(q1, q2, q12, q13, %[thresh])
-
- "sub %[p], %[p], #1 \n" // p - 1
-
- "vswp d5, d24 \n"
- STORE8x2(d4, d5, [%[p]], %[stride])
- STORE8x2(d24, d25, [%[p]], %[stride])
-
- : [p] "+r"(p)
- : [stride] "r"(stride), [thresh] "r"(thresh)
- : "memory", "r4", "r5", "r6", QRegs
- );
-}
-
-#undef LOAD8x4
-#undef STORE8x2
-
-#endif // WEBP_USE_INTRINSICS
-
-static void SimpleVFilter16i_NEON(uint8_t* p, int stride, int thresh) {
- uint32_t k;
- for (k = 3; k != 0; --k) {
- p += 4 * stride;
- SimpleVFilter16_NEON(p, stride, thresh);
- }
-}
-
-static void SimpleHFilter16i_NEON(uint8_t* p, int stride, int thresh) {
- uint32_t k;
- for (k = 3; k != 0; --k) {
- p += 4;
- SimpleHFilter16_NEON(p, stride, thresh);
- }
-}
-
-//------------------------------------------------------------------------------
-// Complex In-loop filtering (Paragraph 15.3)
-
-static uint8x16_t NeedsHev_NEON(const uint8x16_t p1, const uint8x16_t p0,
- const uint8x16_t q0, const uint8x16_t q1,
- int hev_thresh) {
- const uint8x16_t hev_thresh_v = vdupq_n_u8((uint8_t)hev_thresh);
- const uint8x16_t a_p1_p0 = vabdq_u8(p1, p0); // abs(p1 - p0)
- const uint8x16_t a_q1_q0 = vabdq_u8(q1, q0); // abs(q1 - q0)
- const uint8x16_t a_max = vmaxq_u8(a_p1_p0, a_q1_q0);
- const uint8x16_t mask = vcgtq_u8(a_max, hev_thresh_v);
- return mask;
-}
-
-static uint8x16_t NeedsFilter2_NEON(const uint8x16_t p3, const uint8x16_t p2,
- const uint8x16_t p1, const uint8x16_t p0,
- const uint8x16_t q0, const uint8x16_t q1,
- const uint8x16_t q2, const uint8x16_t q3,
- int ithresh, int thresh) {
- const uint8x16_t ithresh_v = vdupq_n_u8((uint8_t)ithresh);
- const uint8x16_t a_p3_p2 = vabdq_u8(p3, p2); // abs(p3 - p2)
- const uint8x16_t a_p2_p1 = vabdq_u8(p2, p1); // abs(p2 - p1)
- const uint8x16_t a_p1_p0 = vabdq_u8(p1, p0); // abs(p1 - p0)
- const uint8x16_t a_q3_q2 = vabdq_u8(q3, q2); // abs(q3 - q2)
- const uint8x16_t a_q2_q1 = vabdq_u8(q2, q1); // abs(q2 - q1)
- const uint8x16_t a_q1_q0 = vabdq_u8(q1, q0); // abs(q1 - q0)
- const uint8x16_t max1 = vmaxq_u8(a_p3_p2, a_p2_p1);
- const uint8x16_t max2 = vmaxq_u8(a_p1_p0, a_q3_q2);
- const uint8x16_t max3 = vmaxq_u8(a_q2_q1, a_q1_q0);
- const uint8x16_t max12 = vmaxq_u8(max1, max2);
- const uint8x16_t max123 = vmaxq_u8(max12, max3);
- const uint8x16_t mask2 = vcgeq_u8(ithresh_v, max123);
- const uint8x16_t mask1 = NeedsFilter_NEON(p1, p0, q0, q1, thresh);
- const uint8x16_t mask = vandq_u8(mask1, mask2);
- return mask;
-}
-
-// 4-points filter
-
-static void ApplyFilter4_NEON(
- const int8x16_t p1, const int8x16_t p0,
- const int8x16_t q0, const int8x16_t q1,
- const int8x16_t delta0,
- uint8x16_t* const op1, uint8x16_t* const op0,
- uint8x16_t* const oq0, uint8x16_t* const oq1) {
- const int8x16_t kCst3 = vdupq_n_s8(0x03);
- const int8x16_t kCst4 = vdupq_n_s8(0x04);
- const int8x16_t delta1 = vqaddq_s8(delta0, kCst4);
- const int8x16_t delta2 = vqaddq_s8(delta0, kCst3);
- const int8x16_t a1 = vshrq_n_s8(delta1, 3);
- const int8x16_t a2 = vshrq_n_s8(delta2, 3);
- const int8x16_t a3 = vrshrq_n_s8(a1, 1); // a3 = (a1 + 1) >> 1
- *op0 = FlipSignBack_NEON(vqaddq_s8(p0, a2)); // clip(p0 + a2)
- *oq0 = FlipSignBack_NEON(vqsubq_s8(q0, a1)); // clip(q0 - a1)
- *op1 = FlipSignBack_NEON(vqaddq_s8(p1, a3)); // clip(p1 + a3)
- *oq1 = FlipSignBack_NEON(vqsubq_s8(q1, a3)); // clip(q1 - a3)
-}
-
-static void DoFilter4_NEON(
- const uint8x16_t p1, const uint8x16_t p0,
- const uint8x16_t q0, const uint8x16_t q1,
- const uint8x16_t mask, const uint8x16_t hev_mask,
- uint8x16_t* const op1, uint8x16_t* const op0,
- uint8x16_t* const oq0, uint8x16_t* const oq1) {
- // This is a fused version of DoFilter2() calling ApplyFilter2 directly
- const int8x16_t p1s = FlipSign_NEON(p1);
- int8x16_t p0s = FlipSign_NEON(p0);
- int8x16_t q0s = FlipSign_NEON(q0);
- const int8x16_t q1s = FlipSign_NEON(q1);
- const uint8x16_t simple_lf_mask = vandq_u8(mask, hev_mask);
-
- // do_filter2 part (simple loopfilter on pixels with hev)
- {
- const int8x16_t delta = GetBaseDelta_NEON(p1s, p0s, q0s, q1s);
- const int8x16_t simple_lf_delta =
- vandq_s8(delta, vreinterpretq_s8_u8(simple_lf_mask));
- ApplyFilter2NoFlip_NEON(p0s, q0s, simple_lf_delta, &p0s, &q0s);
- }
-
- // do_filter4 part (complex loopfilter on pixels without hev)
- {
- const int8x16_t delta0 = GetBaseDelta0_NEON(p0s, q0s);
- // we use: (mask & hev_mask) ^ mask = mask & !hev_mask
- const uint8x16_t complex_lf_mask = veorq_u8(simple_lf_mask, mask);
- const int8x16_t complex_lf_delta =
- vandq_s8(delta0, vreinterpretq_s8_u8(complex_lf_mask));
- ApplyFilter4_NEON(p1s, p0s, q0s, q1s, complex_lf_delta, op1, op0, oq0, oq1);
- }
-}
-
-// 6-points filter
-
-static void ApplyFilter6_NEON(
- const int8x16_t p2, const int8x16_t p1, const int8x16_t p0,
- const int8x16_t q0, const int8x16_t q1, const int8x16_t q2,
- const int8x16_t delta,
- uint8x16_t* const op2, uint8x16_t* const op1, uint8x16_t* const op0,
- uint8x16_t* const oq0, uint8x16_t* const oq1, uint8x16_t* const oq2) {
- // We have to compute: X = (9*a+63) >> 7, Y = (18*a+63)>>7, Z = (27*a+63) >> 7
- // Turns out, there's a common sub-expression S=9 * a - 1 that can be used
- // with the special vqrshrn_n_s16 rounding-shift-and-narrow instruction:
- // X = (S + 64) >> 7, Y = (S + 32) >> 6, Z = (18 * a + S + 64) >> 7
- const int8x8_t delta_lo = vget_low_s8(delta);
- const int8x8_t delta_hi = vget_high_s8(delta);
- const int8x8_t kCst9 = vdup_n_s8(9);
- const int16x8_t kCstm1 = vdupq_n_s16(-1);
- const int8x8_t kCst18 = vdup_n_s8(18);
- const int16x8_t S_lo = vmlal_s8(kCstm1, kCst9, delta_lo); // S = 9 * a - 1
- const int16x8_t S_hi = vmlal_s8(kCstm1, kCst9, delta_hi);
- const int16x8_t Z_lo = vmlal_s8(S_lo, kCst18, delta_lo); // S + 18 * a
- const int16x8_t Z_hi = vmlal_s8(S_hi, kCst18, delta_hi);
- const int8x8_t a3_lo = vqrshrn_n_s16(S_lo, 7); // (9 * a + 63) >> 7
- const int8x8_t a3_hi = vqrshrn_n_s16(S_hi, 7);
- const int8x8_t a2_lo = vqrshrn_n_s16(S_lo, 6); // (9 * a + 31) >> 6
- const int8x8_t a2_hi = vqrshrn_n_s16(S_hi, 6);
- const int8x8_t a1_lo = vqrshrn_n_s16(Z_lo, 7); // (27 * a + 63) >> 7
- const int8x8_t a1_hi = vqrshrn_n_s16(Z_hi, 7);
- const int8x16_t a1 = vcombine_s8(a1_lo, a1_hi);
- const int8x16_t a2 = vcombine_s8(a2_lo, a2_hi);
- const int8x16_t a3 = vcombine_s8(a3_lo, a3_hi);
-
- *op0 = FlipSignBack_NEON(vqaddq_s8(p0, a1)); // clip(p0 + a1)
- *oq0 = FlipSignBack_NEON(vqsubq_s8(q0, a1)); // clip(q0 - q1)
- *oq1 = FlipSignBack_NEON(vqsubq_s8(q1, a2)); // clip(q1 - a2)
- *op1 = FlipSignBack_NEON(vqaddq_s8(p1, a2)); // clip(p1 + a2)
- *oq2 = FlipSignBack_NEON(vqsubq_s8(q2, a3)); // clip(q2 - a3)
- *op2 = FlipSignBack_NEON(vqaddq_s8(p2, a3)); // clip(p2 + a3)
-}
-
-static void DoFilter6_NEON(
- const uint8x16_t p2, const uint8x16_t p1, const uint8x16_t p0,
- const uint8x16_t q0, const uint8x16_t q1, const uint8x16_t q2,
- const uint8x16_t mask, const uint8x16_t hev_mask,
- uint8x16_t* const op2, uint8x16_t* const op1, uint8x16_t* const op0,
- uint8x16_t* const oq0, uint8x16_t* const oq1, uint8x16_t* const oq2) {
- // This is a fused version of DoFilter2() calling ApplyFilter2 directly
- const int8x16_t p2s = FlipSign_NEON(p2);
- const int8x16_t p1s = FlipSign_NEON(p1);
- int8x16_t p0s = FlipSign_NEON(p0);
- int8x16_t q0s = FlipSign_NEON(q0);
- const int8x16_t q1s = FlipSign_NEON(q1);
- const int8x16_t q2s = FlipSign_NEON(q2);
- const uint8x16_t simple_lf_mask = vandq_u8(mask, hev_mask);
- const int8x16_t delta0 = GetBaseDelta_NEON(p1s, p0s, q0s, q1s);
-
- // do_filter2 part (simple loopfilter on pixels with hev)
- {
- const int8x16_t simple_lf_delta =
- vandq_s8(delta0, vreinterpretq_s8_u8(simple_lf_mask));
- ApplyFilter2NoFlip_NEON(p0s, q0s, simple_lf_delta, &p0s, &q0s);
- }
-
- // do_filter6 part (complex loopfilter on pixels without hev)
- {
- // we use: (mask & hev_mask) ^ mask = mask & !hev_mask
- const uint8x16_t complex_lf_mask = veorq_u8(simple_lf_mask, mask);
- const int8x16_t complex_lf_delta =
- vandq_s8(delta0, vreinterpretq_s8_u8(complex_lf_mask));
- ApplyFilter6_NEON(p2s, p1s, p0s, q0s, q1s, q2s, complex_lf_delta,
- op2, op1, op0, oq0, oq1, oq2);
- }
-}
-
-// on macroblock edges
-
-static void VFilter16_NEON(uint8_t* p, int stride,
- int thresh, int ithresh, int hev_thresh) {
- uint8x16_t p3, p2, p1, p0, q0, q1, q2, q3;
- Load16x8_NEON(p, stride, &p3, &p2, &p1, &p0, &q0, &q1, &q2, &q3);
- {
- const uint8x16_t mask = NeedsFilter2_NEON(p3, p2, p1, p0, q0, q1, q2, q3,
- ithresh, thresh);
- const uint8x16_t hev_mask = NeedsHev_NEON(p1, p0, q0, q1, hev_thresh);
- uint8x16_t op2, op1, op0, oq0, oq1, oq2;
- DoFilter6_NEON(p2, p1, p0, q0, q1, q2, mask, hev_mask,
- &op2, &op1, &op0, &oq0, &oq1, &oq2);
- Store16x2_NEON(op2, op1, p - 2 * stride, stride);
- Store16x2_NEON(op0, oq0, p + 0 * stride, stride);
- Store16x2_NEON(oq1, oq2, p + 2 * stride, stride);
- }
-}
-
-static void HFilter16_NEON(uint8_t* p, int stride,
- int thresh, int ithresh, int hev_thresh) {
- uint8x16_t p3, p2, p1, p0, q0, q1, q2, q3;
- Load8x16_NEON(p, stride, &p3, &p2, &p1, &p0, &q0, &q1, &q2, &q3);
- {
- const uint8x16_t mask = NeedsFilter2_NEON(p3, p2, p1, p0, q0, q1, q2, q3,
- ithresh, thresh);
- const uint8x16_t hev_mask = NeedsHev_NEON(p1, p0, q0, q1, hev_thresh);
- uint8x16_t op2, op1, op0, oq0, oq1, oq2;
- DoFilter6_NEON(p2, p1, p0, q0, q1, q2, mask, hev_mask,
- &op2, &op1, &op0, &oq0, &oq1, &oq2);
- Store2x16_NEON(op2, op1, p - 2, stride);
- Store2x16_NEON(op0, oq0, p + 0, stride);
- Store2x16_NEON(oq1, oq2, p + 2, stride);
- }
-}
-
-// on three inner edges
-static void VFilter16i_NEON(uint8_t* p, int stride,
- int thresh, int ithresh, int hev_thresh) {
- uint32_t k;
- uint8x16_t p3, p2, p1, p0;
- Load16x4_NEON(p + 2 * stride, stride, &p3, &p2, &p1, &p0);
- for (k = 3; k != 0; --k) {
- uint8x16_t q0, q1, q2, q3;
- p += 4 * stride;
- Load16x4_NEON(p + 2 * stride, stride, &q0, &q1, &q2, &q3);
- {
- const uint8x16_t mask =
- NeedsFilter2_NEON(p3, p2, p1, p0, q0, q1, q2, q3, ithresh, thresh);
- const uint8x16_t hev_mask = NeedsHev_NEON(p1, p0, q0, q1, hev_thresh);
- // p3 and p2 are not just temporary variables here: they will be
- // re-used for next span. And q2/q3 will become p1/p0 accordingly.
- DoFilter4_NEON(p1, p0, q0, q1, mask, hev_mask, &p1, &p0, &p3, &p2);
- Store16x4_NEON(p1, p0, p3, p2, p, stride);
- p1 = q2;
- p0 = q3;
- }
- }
-}
-
-#if !defined(WORK_AROUND_GCC)
-static void HFilter16i_NEON(uint8_t* p, int stride,
- int thresh, int ithresh, int hev_thresh) {
- uint32_t k;
- uint8x16_t p3, p2, p1, p0;
- Load4x16_NEON(p + 2, stride, &p3, &p2, &p1, &p0);
- for (k = 3; k != 0; --k) {
- uint8x16_t q0, q1, q2, q3;
- p += 4;
- Load4x16_NEON(p + 2, stride, &q0, &q1, &q2, &q3);
- {
- const uint8x16_t mask =
- NeedsFilter2_NEON(p3, p2, p1, p0, q0, q1, q2, q3, ithresh, thresh);
- const uint8x16_t hev_mask = NeedsHev_NEON(p1, p0, q0, q1, hev_thresh);
- DoFilter4_NEON(p1, p0, q0, q1, mask, hev_mask, &p1, &p0, &p3, &p2);
- Store4x16_NEON(p1, p0, p3, p2, p, stride);
- p1 = q2;
- p0 = q3;
- }
- }
-}
-#endif // !WORK_AROUND_GCC
-
-// 8-pixels wide variant, for chroma filtering
-static void VFilter8_NEON(uint8_t* u, uint8_t* v, int stride,
- int thresh, int ithresh, int hev_thresh) {
- uint8x16_t p3, p2, p1, p0, q0, q1, q2, q3;
- Load8x8x2_NEON(u, v, stride, &p3, &p2, &p1, &p0, &q0, &q1, &q2, &q3);
- {
- const uint8x16_t mask = NeedsFilter2_NEON(p3, p2, p1, p0, q0, q1, q2, q3,
- ithresh, thresh);
- const uint8x16_t hev_mask = NeedsHev_NEON(p1, p0, q0, q1, hev_thresh);
- uint8x16_t op2, op1, op0, oq0, oq1, oq2;
- DoFilter6_NEON(p2, p1, p0, q0, q1, q2, mask, hev_mask,
- &op2, &op1, &op0, &oq0, &oq1, &oq2);
- Store8x2x2_NEON(op2, op1, u - 2 * stride, v - 2 * stride, stride);
- Store8x2x2_NEON(op0, oq0, u + 0 * stride, v + 0 * stride, stride);
- Store8x2x2_NEON(oq1, oq2, u + 2 * stride, v + 2 * stride, stride);
- }
-}
-static void VFilter8i_NEON(uint8_t* u, uint8_t* v, int stride,
- int thresh, int ithresh, int hev_thresh) {
- uint8x16_t p3, p2, p1, p0, q0, q1, q2, q3;
- u += 4 * stride;
- v += 4 * stride;
- Load8x8x2_NEON(u, v, stride, &p3, &p2, &p1, &p0, &q0, &q1, &q2, &q3);
- {
- const uint8x16_t mask = NeedsFilter2_NEON(p3, p2, p1, p0, q0, q1, q2, q3,
- ithresh, thresh);
- const uint8x16_t hev_mask = NeedsHev_NEON(p1, p0, q0, q1, hev_thresh);
- uint8x16_t op1, op0, oq0, oq1;
- DoFilter4_NEON(p1, p0, q0, q1, mask, hev_mask, &op1, &op0, &oq0, &oq1);
- Store8x4x2_NEON(op1, op0, oq0, oq1, u, v, stride);
- }
-}
-
-#if !defined(WORK_AROUND_GCC)
-static void HFilter8_NEON(uint8_t* u, uint8_t* v, int stride,
- int thresh, int ithresh, int hev_thresh) {
- uint8x16_t p3, p2, p1, p0, q0, q1, q2, q3;
- Load8x8x2T_NEON(u, v, stride, &p3, &p2, &p1, &p0, &q0, &q1, &q2, &q3);
- {
- const uint8x16_t mask = NeedsFilter2_NEON(p3, p2, p1, p0, q0, q1, q2, q3,
- ithresh, thresh);
- const uint8x16_t hev_mask = NeedsHev_NEON(p1, p0, q0, q1, hev_thresh);
- uint8x16_t op2, op1, op0, oq0, oq1, oq2;
- DoFilter6_NEON(p2, p1, p0, q0, q1, q2, mask, hev_mask,
- &op2, &op1, &op0, &oq0, &oq1, &oq2);
- Store6x8x2_NEON(op2, op1, op0, oq0, oq1, oq2, u, v, stride);
- }
-}
-
-static void HFilter8i_NEON(uint8_t* u, uint8_t* v, int stride,
- int thresh, int ithresh, int hev_thresh) {
- uint8x16_t p3, p2, p1, p0, q0, q1, q2, q3;
- u += 4;
- v += 4;
- Load8x8x2T_NEON(u, v, stride, &p3, &p2, &p1, &p0, &q0, &q1, &q2, &q3);
- {
- const uint8x16_t mask = NeedsFilter2_NEON(p3, p2, p1, p0, q0, q1, q2, q3,
- ithresh, thresh);
- const uint8x16_t hev_mask = NeedsHev_NEON(p1, p0, q0, q1, hev_thresh);
- uint8x16_t op1, op0, oq0, oq1;
- DoFilter4_NEON(p1, p0, q0, q1, mask, hev_mask, &op1, &op0, &oq0, &oq1);
- Store4x8x2_NEON(op1, op0, oq0, oq1, u, v, stride);
- }
-}
-#endif // !WORK_AROUND_GCC
-
-//-----------------------------------------------------------------------------
-// Inverse transforms (Paragraph 14.4)
-
-// Technically these are unsigned but vqdmulh is only available in signed.
-// vqdmulh returns high half (effectively >> 16) but also doubles the value,
-// changing the >> 16 to >> 15 and requiring an additional >> 1.
-// We use this to our advantage with kC2. The canonical value is 35468.
-// However, the high bit is set so treating it as signed will give incorrect
-// results. We avoid this by down shifting by 1 here to clear the highest bit.
-// Combined with the doubling effect of vqdmulh we get >> 16.
-// This can not be applied to kC1 because the lowest bit is set. Down shifting
-// the constant would reduce precision.
-
-// libwebp uses a trick to avoid some extra addition that libvpx does.
-// Instead of:
-// temp2 = ip[12] + ((ip[12] * cospi8sqrt2minus1) >> 16);
-// libwebp adds 1 << 16 to cospi8sqrt2minus1 (kC1). However, this causes the
-// same issue with kC1 and vqdmulh that we work around by down shifting kC2
-
-static const int16_t kC1 = 20091;
-static const int16_t kC2 = 17734; // half of kC2, actually. See comment above.
-
-#if defined(WEBP_USE_INTRINSICS)
-static WEBP_INLINE void Transpose8x2_NEON(const int16x8_t in0,
- const int16x8_t in1,
- int16x8x2_t* const out) {
- // a0 a1 a2 a3 | b0 b1 b2 b3 => a0 b0 c0 d0 | a1 b1 c1 d1
- // c0 c1 c2 c3 | d0 d1 d2 d3 a2 b2 c2 d2 | a3 b3 c3 d3
- const int16x8x2_t tmp0 = vzipq_s16(in0, in1); // a0 c0 a1 c1 a2 c2 ...
- // b0 d0 b1 d1 b2 d2 ...
- *out = vzipq_s16(tmp0.val[0], tmp0.val[1]);
-}
-
-static WEBP_INLINE void TransformPass_NEON(int16x8x2_t* const rows) {
- // {rows} = in0 | in4
- // in8 | in12
- // B1 = in4 | in12
- const int16x8_t B1 =
- vcombine_s16(vget_high_s16(rows->val[0]), vget_high_s16(rows->val[1]));
- // C0 = kC1 * in4 | kC1 * in12
- // C1 = kC2 * in4 | kC2 * in12
- const int16x8_t C0 = vsraq_n_s16(B1, vqdmulhq_n_s16(B1, kC1), 1);
- const int16x8_t C1 = vqdmulhq_n_s16(B1, kC2);
- const int16x4_t a = vqadd_s16(vget_low_s16(rows->val[0]),
- vget_low_s16(rows->val[1])); // in0 + in8
- const int16x4_t b = vqsub_s16(vget_low_s16(rows->val[0]),
- vget_low_s16(rows->val[1])); // in0 - in8
- // c = kC2 * in4 - kC1 * in12
- // d = kC1 * in4 + kC2 * in12
- const int16x4_t c = vqsub_s16(vget_low_s16(C1), vget_high_s16(C0));
- const int16x4_t d = vqadd_s16(vget_low_s16(C0), vget_high_s16(C1));
- const int16x8_t D0 = vcombine_s16(a, b); // D0 = a | b
- const int16x8_t D1 = vcombine_s16(d, c); // D1 = d | c
- const int16x8_t E0 = vqaddq_s16(D0, D1); // a+d | b+c
- const int16x8_t E_tmp = vqsubq_s16(D0, D1); // a-d | b-c
- const int16x8_t E1 = vcombine_s16(vget_high_s16(E_tmp), vget_low_s16(E_tmp));
- Transpose8x2_NEON(E0, E1, rows);
-}
-
-static void TransformOne_NEON(const int16_t* in, uint8_t* dst) {
- int16x8x2_t rows;
- INIT_VECTOR2(rows, vld1q_s16(in + 0), vld1q_s16(in + 8));
- TransformPass_NEON(&rows);
- TransformPass_NEON(&rows);
- Add4x4_NEON(rows.val[0], rows.val[1], dst);
-}
-
-#else
-
-static void TransformOne_NEON(const int16_t* in, uint8_t* dst) {
- const int kBPS = BPS;
- // kC1, kC2. Padded because vld1.16 loads 8 bytes
- const int16_t constants[4] = { kC1, kC2, 0, 0 };
- /* Adapted from libvpx: vp8/common/arm/neon/shortidct4x4llm_neon.asm */
- __asm__ volatile (
- "vld1.16 {q1, q2}, [%[in]] \n"
- "vld1.16 {d0}, [%[constants]] \n"
-
- /* d2: in[0]
- * d3: in[8]
- * d4: in[4]
- * d5: in[12]
- */
- "vswp d3, d4 \n"
-
- /* q8 = {in[4], in[12]} * kC1 * 2 >> 16
- * q9 = {in[4], in[12]} * kC2 >> 16
- */
- "vqdmulh.s16 q8, q2, d0[0] \n"
- "vqdmulh.s16 q9, q2, d0[1] \n"
-
- /* d22 = a = in[0] + in[8]
- * d23 = b = in[0] - in[8]
- */
- "vqadd.s16 d22, d2, d3 \n"
- "vqsub.s16 d23, d2, d3 \n"
-
- /* The multiplication should be x * kC1 >> 16
- * However, with vqdmulh we get x * kC1 * 2 >> 16
- * (multiply, double, return high half)
- * We avoided this in kC2 by pre-shifting the constant.
- * q8 = in[4]/[12] * kC1 >> 16
- */
- "vshr.s16 q8, q8, #1 \n"
-
- /* Add {in[4], in[12]} back after the multiplication. This is handled by
- * adding 1 << 16 to kC1 in the libwebp C code.
- */
- "vqadd.s16 q8, q2, q8 \n"
-
- /* d20 = c = in[4]*kC2 - in[12]*kC1
- * d21 = d = in[4]*kC1 + in[12]*kC2
- */
- "vqsub.s16 d20, d18, d17 \n"
- "vqadd.s16 d21, d19, d16 \n"
-
- /* d2 = tmp[0] = a + d
- * d3 = tmp[1] = b + c
- * d4 = tmp[2] = b - c
- * d5 = tmp[3] = a - d
- */
- "vqadd.s16 d2, d22, d21 \n"
- "vqadd.s16 d3, d23, d20 \n"
- "vqsub.s16 d4, d23, d20 \n"
- "vqsub.s16 d5, d22, d21 \n"
-
- "vzip.16 q1, q2 \n"
- "vzip.16 q1, q2 \n"
-
- "vswp d3, d4 \n"
-
- /* q8 = {tmp[4], tmp[12]} * kC1 * 2 >> 16
- * q9 = {tmp[4], tmp[12]} * kC2 >> 16
- */
- "vqdmulh.s16 q8, q2, d0[0] \n"
- "vqdmulh.s16 q9, q2, d0[1] \n"
-
- /* d22 = a = tmp[0] + tmp[8]
- * d23 = b = tmp[0] - tmp[8]
- */
- "vqadd.s16 d22, d2, d3 \n"
- "vqsub.s16 d23, d2, d3 \n"
-
- /* See long winded explanations prior */
- "vshr.s16 q8, q8, #1 \n"
- "vqadd.s16 q8, q2, q8 \n"
-
- /* d20 = c = in[4]*kC2 - in[12]*kC1
- * d21 = d = in[4]*kC1 + in[12]*kC2
- */
- "vqsub.s16 d20, d18, d17 \n"
- "vqadd.s16 d21, d19, d16 \n"
-
- /* d2 = tmp[0] = a + d
- * d3 = tmp[1] = b + c
- * d4 = tmp[2] = b - c
- * d5 = tmp[3] = a - d
- */
- "vqadd.s16 d2, d22, d21 \n"
- "vqadd.s16 d3, d23, d20 \n"
- "vqsub.s16 d4, d23, d20 \n"
- "vqsub.s16 d5, d22, d21 \n"
-
- "vld1.32 d6[0], [%[dst]], %[kBPS] \n"
- "vld1.32 d6[1], [%[dst]], %[kBPS] \n"
- "vld1.32 d7[0], [%[dst]], %[kBPS] \n"
- "vld1.32 d7[1], [%[dst]], %[kBPS] \n"
-
- "sub %[dst], %[dst], %[kBPS], lsl #2 \n"
-
- /* (val) + 4 >> 3 */
- "vrshr.s16 d2, d2, #3 \n"
- "vrshr.s16 d3, d3, #3 \n"
- "vrshr.s16 d4, d4, #3 \n"
- "vrshr.s16 d5, d5, #3 \n"
-
- "vzip.16 q1, q2 \n"
- "vzip.16 q1, q2 \n"
-
- /* Must accumulate before saturating */
- "vmovl.u8 q8, d6 \n"
- "vmovl.u8 q9, d7 \n"
-
- "vqadd.s16 q1, q1, q8 \n"
- "vqadd.s16 q2, q2, q9 \n"
-
- "vqmovun.s16 d0, q1 \n"
- "vqmovun.s16 d1, q2 \n"
-
- "vst1.32 d0[0], [%[dst]], %[kBPS] \n"
- "vst1.32 d0[1], [%[dst]], %[kBPS] \n"
- "vst1.32 d1[0], [%[dst]], %[kBPS] \n"
- "vst1.32 d1[1], [%[dst]] \n"
-
- : [in] "+r"(in), [dst] "+r"(dst) /* modified registers */
- : [kBPS] "r"(kBPS), [constants] "r"(constants) /* constants */
- : "memory", "q0", "q1", "q2", "q8", "q9", "q10", "q11" /* clobbered */
- );
-}
-
-#endif // WEBP_USE_INTRINSICS
-
-static void TransformTwo_NEON(const int16_t* in, uint8_t* dst, int do_two) {
- TransformOne_NEON(in, dst);
- if (do_two) {
- TransformOne_NEON(in + 16, dst + 4);
- }
-}
-
-static void TransformDC_NEON(const int16_t* in, uint8_t* dst) {
- const int16x8_t DC = vdupq_n_s16(in[0]);
- Add4x4_NEON(DC, DC, dst);
-}
-
-//------------------------------------------------------------------------------
-
-#define STORE_WHT(dst, col, rows) do { \
- *dst = vgetq_lane_s32(rows.val[0], col); (dst) += 16; \
- *dst = vgetq_lane_s32(rows.val[1], col); (dst) += 16; \
- *dst = vgetq_lane_s32(rows.val[2], col); (dst) += 16; \
- *dst = vgetq_lane_s32(rows.val[3], col); (dst) += 16; \
-} while (0)
-
-static void TransformWHT_NEON(const int16_t* in, int16_t* out) {
- int32x4x4_t tmp;
-
- {
- // Load the source.
- const int16x4_t in00_03 = vld1_s16(in + 0);
- const int16x4_t in04_07 = vld1_s16(in + 4);
- const int16x4_t in08_11 = vld1_s16(in + 8);
- const int16x4_t in12_15 = vld1_s16(in + 12);
- const int32x4_t a0 = vaddl_s16(in00_03, in12_15); // in[0..3] + in[12..15]
- const int32x4_t a1 = vaddl_s16(in04_07, in08_11); // in[4..7] + in[8..11]
- const int32x4_t a2 = vsubl_s16(in04_07, in08_11); // in[4..7] - in[8..11]
- const int32x4_t a3 = vsubl_s16(in00_03, in12_15); // in[0..3] - in[12..15]
- tmp.val[0] = vaddq_s32(a0, a1);
- tmp.val[1] = vaddq_s32(a3, a2);
- tmp.val[2] = vsubq_s32(a0, a1);
- tmp.val[3] = vsubq_s32(a3, a2);
- // Arrange the temporary results column-wise.
- tmp = Transpose4x4_NEON(tmp);
- }
-
- {
- const int32x4_t kCst3 = vdupq_n_s32(3);
- const int32x4_t dc = vaddq_s32(tmp.val[0], kCst3); // add rounder
- const int32x4_t a0 = vaddq_s32(dc, tmp.val[3]);
- const int32x4_t a1 = vaddq_s32(tmp.val[1], tmp.val[2]);
- const int32x4_t a2 = vsubq_s32(tmp.val[1], tmp.val[2]);
- const int32x4_t a3 = vsubq_s32(dc, tmp.val[3]);
-
- tmp.val[0] = vaddq_s32(a0, a1);
- tmp.val[1] = vaddq_s32(a3, a2);
- tmp.val[2] = vsubq_s32(a0, a1);
- tmp.val[3] = vsubq_s32(a3, a2);
-
- // right shift the results by 3.
- tmp.val[0] = vshrq_n_s32(tmp.val[0], 3);
- tmp.val[1] = vshrq_n_s32(tmp.val[1], 3);
- tmp.val[2] = vshrq_n_s32(tmp.val[2], 3);
- tmp.val[3] = vshrq_n_s32(tmp.val[3], 3);
-
- STORE_WHT(out, 0, tmp);
- STORE_WHT(out, 1, tmp);
- STORE_WHT(out, 2, tmp);
- STORE_WHT(out, 3, tmp);
- }
-}
-
-#undef STORE_WHT
-
-//------------------------------------------------------------------------------
-
-#define MUL(a, b) (((a) * (b)) >> 16)
-static void TransformAC3_NEON(const int16_t* in, uint8_t* dst) {
- static const int kC1_full = 20091 + (1 << 16);
- static const int kC2_full = 35468;
- const int16x4_t A = vld1_dup_s16(in);
- const int16x4_t c4 = vdup_n_s16(MUL(in[4], kC2_full));
- const int16x4_t d4 = vdup_n_s16(MUL(in[4], kC1_full));
- const int c1 = MUL(in[1], kC2_full);
- const int d1 = MUL(in[1], kC1_full);
- const uint64_t cd = (uint64_t)( d1 & 0xffff) << 0 |
- (uint64_t)( c1 & 0xffff) << 16 |
- (uint64_t)(-c1 & 0xffff) << 32 |
- (uint64_t)(-d1 & 0xffff) << 48;
- const int16x4_t CD = vcreate_s16(cd);
- const int16x4_t B = vqadd_s16(A, CD);
- const int16x8_t m0_m1 = vcombine_s16(vqadd_s16(B, d4), vqadd_s16(B, c4));
- const int16x8_t m2_m3 = vcombine_s16(vqsub_s16(B, c4), vqsub_s16(B, d4));
- Add4x4_NEON(m0_m1, m2_m3, dst);
-}
-#undef MUL
-
-//------------------------------------------------------------------------------
-// 4x4
-
-static void DC4_NEON(uint8_t* dst) { // DC
- const uint8x8_t A = vld1_u8(dst - BPS); // top row
- const uint16x4_t p0 = vpaddl_u8(A); // cascading summation of the top
- const uint16x4_t p1 = vpadd_u16(p0, p0);
- const uint8x8_t L0 = vld1_u8(dst + 0 * BPS - 1);
- const uint8x8_t L1 = vld1_u8(dst + 1 * BPS - 1);
- const uint8x8_t L2 = vld1_u8(dst + 2 * BPS - 1);
- const uint8x8_t L3 = vld1_u8(dst + 3 * BPS - 1);
- const uint16x8_t s0 = vaddl_u8(L0, L1);
- const uint16x8_t s1 = vaddl_u8(L2, L3);
- const uint16x8_t s01 = vaddq_u16(s0, s1);
- const uint16x8_t sum = vaddq_u16(s01, vcombine_u16(p1, p1));
- const uint8x8_t dc0 = vrshrn_n_u16(sum, 3); // (sum + 4) >> 3
- const uint8x8_t dc = vdup_lane_u8(dc0, 0);
- int i;
- for (i = 0; i < 4; ++i) {
- vst1_lane_u32((uint32_t*)(dst + i * BPS), vreinterpret_u32_u8(dc), 0);
- }
-}
-
-// TrueMotion (4x4 + 8x8)
-static WEBP_INLINE void TrueMotion_NEON(uint8_t* dst, int size) {
- const uint8x8_t TL = vld1_dup_u8(dst - BPS - 1); // top-left pixel 'A[-1]'
- const uint8x8_t T = vld1_u8(dst - BPS); // top row 'A[0..3]'
- const int16x8_t d = vreinterpretq_s16_u16(vsubl_u8(T, TL)); // A[c] - A[-1]
- int y;
- for (y = 0; y < size; y += 4) {
- // left edge
- const int16x8_t L0 = ConvertU8ToS16_NEON(vld1_dup_u8(dst + 0 * BPS - 1));
- const int16x8_t L1 = ConvertU8ToS16_NEON(vld1_dup_u8(dst + 1 * BPS - 1));
- const int16x8_t L2 = ConvertU8ToS16_NEON(vld1_dup_u8(dst + 2 * BPS - 1));
- const int16x8_t L3 = ConvertU8ToS16_NEON(vld1_dup_u8(dst + 3 * BPS - 1));
- const int16x8_t r0 = vaddq_s16(L0, d); // L[r] + A[c] - A[-1]
- const int16x8_t r1 = vaddq_s16(L1, d);
- const int16x8_t r2 = vaddq_s16(L2, d);
- const int16x8_t r3 = vaddq_s16(L3, d);
- // Saturate and store the result.
- const uint32x2_t r0_u32 = vreinterpret_u32_u8(vqmovun_s16(r0));
- const uint32x2_t r1_u32 = vreinterpret_u32_u8(vqmovun_s16(r1));
- const uint32x2_t r2_u32 = vreinterpret_u32_u8(vqmovun_s16(r2));
- const uint32x2_t r3_u32 = vreinterpret_u32_u8(vqmovun_s16(r3));
- if (size == 4) {
- vst1_lane_u32((uint32_t*)(dst + 0 * BPS), r0_u32, 0);
- vst1_lane_u32((uint32_t*)(dst + 1 * BPS), r1_u32, 0);
- vst1_lane_u32((uint32_t*)(dst + 2 * BPS), r2_u32, 0);
- vst1_lane_u32((uint32_t*)(dst + 3 * BPS), r3_u32, 0);
- } else {
- vst1_u32((uint32_t*)(dst + 0 * BPS), r0_u32);
- vst1_u32((uint32_t*)(dst + 1 * BPS), r1_u32);
- vst1_u32((uint32_t*)(dst + 2 * BPS), r2_u32);
- vst1_u32((uint32_t*)(dst + 3 * BPS), r3_u32);
- }
- dst += 4 * BPS;
- }
-}
-
-static void TM4_NEON(uint8_t* dst) { TrueMotion_NEON(dst, 4); }
-
-static void VE4_NEON(uint8_t* dst) { // vertical
- // NB: avoid vld1_u64 here as an alignment hint may be added -> SIGBUS.
- const uint64x1_t A0 = vreinterpret_u64_u8(vld1_u8(dst - BPS - 1)); // top row
- const uint64x1_t A1 = vshr_n_u64(A0, 8);
- const uint64x1_t A2 = vshr_n_u64(A0, 16);
- const uint8x8_t ABCDEFGH = vreinterpret_u8_u64(A0);
- const uint8x8_t BCDEFGH0 = vreinterpret_u8_u64(A1);
- const uint8x8_t CDEFGH00 = vreinterpret_u8_u64(A2);
- const uint8x8_t b = vhadd_u8(ABCDEFGH, CDEFGH00);
- const uint8x8_t avg = vrhadd_u8(b, BCDEFGH0);
- int i;
- for (i = 0; i < 4; ++i) {
- vst1_lane_u32((uint32_t*)(dst + i * BPS), vreinterpret_u32_u8(avg), 0);
- }
-}
-
-static void RD4_NEON(uint8_t* dst) { // Down-right
- const uint8x8_t XABCD_u8 = vld1_u8(dst - BPS - 1);
- const uint64x1_t XABCD = vreinterpret_u64_u8(XABCD_u8);
- const uint64x1_t ____XABC = vshl_n_u64(XABCD, 32);
- const uint32_t I = dst[-1 + 0 * BPS];
- const uint32_t J = dst[-1 + 1 * BPS];
- const uint32_t K = dst[-1 + 2 * BPS];
- const uint32_t L = dst[-1 + 3 * BPS];
- const uint64x1_t LKJI____ =
- vcreate_u64((uint64_t)L | (K << 8) | (J << 16) | (I << 24));
- const uint64x1_t LKJIXABC = vorr_u64(LKJI____, ____XABC);
- const uint8x8_t KJIXABC_ = vreinterpret_u8_u64(vshr_n_u64(LKJIXABC, 8));
- const uint8x8_t JIXABC__ = vreinterpret_u8_u64(vshr_n_u64(LKJIXABC, 16));
- const uint8_t D = vget_lane_u8(XABCD_u8, 4);
- const uint8x8_t JIXABCD_ = vset_lane_u8(D, JIXABC__, 6);
- const uint8x8_t LKJIXABC_u8 = vreinterpret_u8_u64(LKJIXABC);
- const uint8x8_t avg1 = vhadd_u8(JIXABCD_, LKJIXABC_u8);
- const uint8x8_t avg2 = vrhadd_u8(avg1, KJIXABC_);
- const uint64x1_t avg2_u64 = vreinterpret_u64_u8(avg2);
- const uint32x2_t r3 = vreinterpret_u32_u8(avg2);
- const uint32x2_t r2 = vreinterpret_u32_u64(vshr_n_u64(avg2_u64, 8));
- const uint32x2_t r1 = vreinterpret_u32_u64(vshr_n_u64(avg2_u64, 16));
- const uint32x2_t r0 = vreinterpret_u32_u64(vshr_n_u64(avg2_u64, 24));
- vst1_lane_u32((uint32_t*)(dst + 0 * BPS), r0, 0);
- vst1_lane_u32((uint32_t*)(dst + 1 * BPS), r1, 0);
- vst1_lane_u32((uint32_t*)(dst + 2 * BPS), r2, 0);
- vst1_lane_u32((uint32_t*)(dst + 3 * BPS), r3, 0);
-}
-
-static void LD4_NEON(uint8_t* dst) { // Down-left
- // Note using the same shift trick as VE4() is slower here.
- const uint8x8_t ABCDEFGH = vld1_u8(dst - BPS + 0);
- const uint8x8_t BCDEFGH0 = vld1_u8(dst - BPS + 1);
- const uint8x8_t CDEFGH00 = vld1_u8(dst - BPS + 2);
- const uint8x8_t CDEFGHH0 = vset_lane_u8(dst[-BPS + 7], CDEFGH00, 6);
- const uint8x8_t avg1 = vhadd_u8(ABCDEFGH, CDEFGHH0);
- const uint8x8_t avg2 = vrhadd_u8(avg1, BCDEFGH0);
- const uint64x1_t avg2_u64 = vreinterpret_u64_u8(avg2);
- const uint32x2_t r0 = vreinterpret_u32_u8(avg2);
- const uint32x2_t r1 = vreinterpret_u32_u64(vshr_n_u64(avg2_u64, 8));
- const uint32x2_t r2 = vreinterpret_u32_u64(vshr_n_u64(avg2_u64, 16));
- const uint32x2_t r3 = vreinterpret_u32_u64(vshr_n_u64(avg2_u64, 24));
- vst1_lane_u32((uint32_t*)(dst + 0 * BPS), r0, 0);
- vst1_lane_u32((uint32_t*)(dst + 1 * BPS), r1, 0);
- vst1_lane_u32((uint32_t*)(dst + 2 * BPS), r2, 0);
- vst1_lane_u32((uint32_t*)(dst + 3 * BPS), r3, 0);
-}
-
-//------------------------------------------------------------------------------
-// Chroma
-
-static void VE8uv_NEON(uint8_t* dst) { // vertical
- const uint8x8_t top = vld1_u8(dst - BPS);
- int j;
- for (j = 0; j < 8; ++j) {
- vst1_u8(dst + j * BPS, top);
- }
-}
-
-static void HE8uv_NEON(uint8_t* dst) { // horizontal
- int j;
- for (j = 0; j < 8; ++j) {
- const uint8x8_t left = vld1_dup_u8(dst - 1);
- vst1_u8(dst, left);
- dst += BPS;
- }
-}
-
-static WEBP_INLINE void DC8_NEON(uint8_t* dst, int do_top, int do_left) {
- uint16x8_t sum_top;
- uint16x8_t sum_left;
- uint8x8_t dc0;
-
- if (do_top) {
- const uint8x8_t A = vld1_u8(dst - BPS); // top row
-#if defined(__aarch64__)
- const uint16_t p2 = vaddlv_u8(A);
- sum_top = vdupq_n_u16(p2);
-#else
- const uint16x4_t p0 = vpaddl_u8(A); // cascading summation of the top
- const uint16x4_t p1 = vpadd_u16(p0, p0);
- const uint16x4_t p2 = vpadd_u16(p1, p1);
- sum_top = vcombine_u16(p2, p2);
-#endif
- }
-
- if (do_left) {
- const uint8x8_t L0 = vld1_u8(dst + 0 * BPS - 1);
- const uint8x8_t L1 = vld1_u8(dst + 1 * BPS - 1);
- const uint8x8_t L2 = vld1_u8(dst + 2 * BPS - 1);
- const uint8x8_t L3 = vld1_u8(dst + 3 * BPS - 1);
- const uint8x8_t L4 = vld1_u8(dst + 4 * BPS - 1);
- const uint8x8_t L5 = vld1_u8(dst + 5 * BPS - 1);
- const uint8x8_t L6 = vld1_u8(dst + 6 * BPS - 1);
- const uint8x8_t L7 = vld1_u8(dst + 7 * BPS - 1);
- const uint16x8_t s0 = vaddl_u8(L0, L1);
- const uint16x8_t s1 = vaddl_u8(L2, L3);
- const uint16x8_t s2 = vaddl_u8(L4, L5);
- const uint16x8_t s3 = vaddl_u8(L6, L7);
- const uint16x8_t s01 = vaddq_u16(s0, s1);
- const uint16x8_t s23 = vaddq_u16(s2, s3);
- sum_left = vaddq_u16(s01, s23);
- }
-
- if (do_top && do_left) {
- const uint16x8_t sum = vaddq_u16(sum_left, sum_top);
- dc0 = vrshrn_n_u16(sum, 4);
- } else if (do_top) {
- dc0 = vrshrn_n_u16(sum_top, 3);
- } else if (do_left) {
- dc0 = vrshrn_n_u16(sum_left, 3);
- } else {
- dc0 = vdup_n_u8(0x80);
- }
-
- {
- const uint8x8_t dc = vdup_lane_u8(dc0, 0);
- int i;
- for (i = 0; i < 8; ++i) {
- vst1_u32((uint32_t*)(dst + i * BPS), vreinterpret_u32_u8(dc));
- }
- }
-}
-
-static void DC8uv_NEON(uint8_t* dst) { DC8_NEON(dst, 1, 1); }
-static void DC8uvNoTop_NEON(uint8_t* dst) { DC8_NEON(dst, 0, 1); }
-static void DC8uvNoLeft_NEON(uint8_t* dst) { DC8_NEON(dst, 1, 0); }
-static void DC8uvNoTopLeft_NEON(uint8_t* dst) { DC8_NEON(dst, 0, 0); }
-
-static void TM8uv_NEON(uint8_t* dst) { TrueMotion_NEON(dst, 8); }
-
-//------------------------------------------------------------------------------
-// 16x16
-
-static void VE16_NEON(uint8_t* dst) { // vertical
- const uint8x16_t top = vld1q_u8(dst - BPS);
- int j;
- for (j = 0; j < 16; ++j) {
- vst1q_u8(dst + j * BPS, top);
- }
-}
-
-static void HE16_NEON(uint8_t* dst) { // horizontal
- int j;
- for (j = 0; j < 16; ++j) {
- const uint8x16_t left = vld1q_dup_u8(dst - 1);
- vst1q_u8(dst, left);
- dst += BPS;
- }
-}
-
-static WEBP_INLINE void DC16_NEON(uint8_t* dst, int do_top, int do_left) {
- uint16x8_t sum_top;
- uint16x8_t sum_left;
- uint8x8_t dc0;
-
- if (do_top) {
- const uint8x16_t A = vld1q_u8(dst - BPS); // top row
-#if defined(__aarch64__)
- const uint16_t p3 = vaddlvq_u8(A);
- sum_top = vdupq_n_u16(p3);
-#else
- const uint16x8_t p0 = vpaddlq_u8(A); // cascading summation of the top
- const uint16x4_t p1 = vadd_u16(vget_low_u16(p0), vget_high_u16(p0));
- const uint16x4_t p2 = vpadd_u16(p1, p1);
- const uint16x4_t p3 = vpadd_u16(p2, p2);
- sum_top = vcombine_u16(p3, p3);
-#endif
- }
-
- if (do_left) {
- int i;
- sum_left = vdupq_n_u16(0);
- for (i = 0; i < 16; i += 8) {
- const uint8x8_t L0 = vld1_u8(dst + (i + 0) * BPS - 1);
- const uint8x8_t L1 = vld1_u8(dst + (i + 1) * BPS - 1);
- const uint8x8_t L2 = vld1_u8(dst + (i + 2) * BPS - 1);
- const uint8x8_t L3 = vld1_u8(dst + (i + 3) * BPS - 1);
- const uint8x8_t L4 = vld1_u8(dst + (i + 4) * BPS - 1);
- const uint8x8_t L5 = vld1_u8(dst + (i + 5) * BPS - 1);
- const uint8x8_t L6 = vld1_u8(dst + (i + 6) * BPS - 1);
- const uint8x8_t L7 = vld1_u8(dst + (i + 7) * BPS - 1);
- const uint16x8_t s0 = vaddl_u8(L0, L1);
- const uint16x8_t s1 = vaddl_u8(L2, L3);
- const uint16x8_t s2 = vaddl_u8(L4, L5);
- const uint16x8_t s3 = vaddl_u8(L6, L7);
- const uint16x8_t s01 = vaddq_u16(s0, s1);
- const uint16x8_t s23 = vaddq_u16(s2, s3);
- const uint16x8_t sum = vaddq_u16(s01, s23);
- sum_left = vaddq_u16(sum_left, sum);
- }
- }
-
- if (do_top && do_left) {
- const uint16x8_t sum = vaddq_u16(sum_left, sum_top);
- dc0 = vrshrn_n_u16(sum, 5);
- } else if (do_top) {
- dc0 = vrshrn_n_u16(sum_top, 4);
- } else if (do_left) {
- dc0 = vrshrn_n_u16(sum_left, 4);
- } else {
- dc0 = vdup_n_u8(0x80);
- }
-
- {
- const uint8x16_t dc = vdupq_lane_u8(dc0, 0);
- int i;
- for (i = 0; i < 16; ++i) {
- vst1q_u8(dst + i * BPS, dc);
- }
- }
-}
-
-static void DC16TopLeft_NEON(uint8_t* dst) { DC16_NEON(dst, 1, 1); }
-static void DC16NoTop_NEON(uint8_t* dst) { DC16_NEON(dst, 0, 1); }
-static void DC16NoLeft_NEON(uint8_t* dst) { DC16_NEON(dst, 1, 0); }
-static void DC16NoTopLeft_NEON(uint8_t* dst) { DC16_NEON(dst, 0, 0); }
-
-static void TM16_NEON(uint8_t* dst) {
- const uint8x8_t TL = vld1_dup_u8(dst - BPS - 1); // top-left pixel 'A[-1]'
- const uint8x16_t T = vld1q_u8(dst - BPS); // top row 'A[0..15]'
- // A[c] - A[-1]
- const int16x8_t d_lo = vreinterpretq_s16_u16(vsubl_u8(vget_low_u8(T), TL));
- const int16x8_t d_hi = vreinterpretq_s16_u16(vsubl_u8(vget_high_u8(T), TL));
- int y;
- for (y = 0; y < 16; y += 4) {
- // left edge
- const int16x8_t L0 = ConvertU8ToS16_NEON(vld1_dup_u8(dst + 0 * BPS - 1));
- const int16x8_t L1 = ConvertU8ToS16_NEON(vld1_dup_u8(dst + 1 * BPS - 1));
- const int16x8_t L2 = ConvertU8ToS16_NEON(vld1_dup_u8(dst + 2 * BPS - 1));
- const int16x8_t L3 = ConvertU8ToS16_NEON(vld1_dup_u8(dst + 3 * BPS - 1));
- const int16x8_t r0_lo = vaddq_s16(L0, d_lo); // L[r] + A[c] - A[-1]
- const int16x8_t r1_lo = vaddq_s16(L1, d_lo);
- const int16x8_t r2_lo = vaddq_s16(L2, d_lo);
- const int16x8_t r3_lo = vaddq_s16(L3, d_lo);
- const int16x8_t r0_hi = vaddq_s16(L0, d_hi);
- const int16x8_t r1_hi = vaddq_s16(L1, d_hi);
- const int16x8_t r2_hi = vaddq_s16(L2, d_hi);
- const int16x8_t r3_hi = vaddq_s16(L3, d_hi);
- // Saturate and store the result.
- const uint8x16_t row0 = vcombine_u8(vqmovun_s16(r0_lo), vqmovun_s16(r0_hi));
- const uint8x16_t row1 = vcombine_u8(vqmovun_s16(r1_lo), vqmovun_s16(r1_hi));
- const uint8x16_t row2 = vcombine_u8(vqmovun_s16(r2_lo), vqmovun_s16(r2_hi));
- const uint8x16_t row3 = vcombine_u8(vqmovun_s16(r3_lo), vqmovun_s16(r3_hi));
- vst1q_u8(dst + 0 * BPS, row0);
- vst1q_u8(dst + 1 * BPS, row1);
- vst1q_u8(dst + 2 * BPS, row2);
- vst1q_u8(dst + 3 * BPS, row3);
- dst += 4 * BPS;
- }
-}
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void VP8DspInitNEON(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void VP8DspInitNEON(void) {
- VP8Transform = TransformTwo_NEON;
- VP8TransformAC3 = TransformAC3_NEON;
- VP8TransformDC = TransformDC_NEON;
- VP8TransformWHT = TransformWHT_NEON;
-
- VP8VFilter16 = VFilter16_NEON;
- VP8VFilter16i = VFilter16i_NEON;
- VP8HFilter16 = HFilter16_NEON;
-#if !defined(WORK_AROUND_GCC)
- VP8HFilter16i = HFilter16i_NEON;
-#endif
- VP8VFilter8 = VFilter8_NEON;
- VP8VFilter8i = VFilter8i_NEON;
-#if !defined(WORK_AROUND_GCC)
- VP8HFilter8 = HFilter8_NEON;
- VP8HFilter8i = HFilter8i_NEON;
-#endif
- VP8SimpleVFilter16 = SimpleVFilter16_NEON;
- VP8SimpleHFilter16 = SimpleHFilter16_NEON;
- VP8SimpleVFilter16i = SimpleVFilter16i_NEON;
- VP8SimpleHFilter16i = SimpleHFilter16i_NEON;
-
- VP8PredLuma4[0] = DC4_NEON;
- VP8PredLuma4[1] = TM4_NEON;
- VP8PredLuma4[2] = VE4_NEON;
- VP8PredLuma4[4] = RD4_NEON;
- VP8PredLuma4[6] = LD4_NEON;
-
- VP8PredLuma16[0] = DC16TopLeft_NEON;
- VP8PredLuma16[1] = TM16_NEON;
- VP8PredLuma16[2] = VE16_NEON;
- VP8PredLuma16[3] = HE16_NEON;
- VP8PredLuma16[4] = DC16NoTop_NEON;
- VP8PredLuma16[5] = DC16NoLeft_NEON;
- VP8PredLuma16[6] = DC16NoTopLeft_NEON;
-
- VP8PredChroma8[0] = DC8uv_NEON;
- VP8PredChroma8[1] = TM8uv_NEON;
- VP8PredChroma8[2] = VE8uv_NEON;
- VP8PredChroma8[3] = HE8uv_NEON;
- VP8PredChroma8[4] = DC8uvNoTop_NEON;
- VP8PredChroma8[5] = DC8uvNoLeft_NEON;
- VP8PredChroma8[6] = DC8uvNoTopLeft_NEON;
-}
-
-#else // !WEBP_USE_NEON
-
-WEBP_DSP_INIT_STUB(VP8DspInitNEON)
-
-#endif // WEBP_USE_NEON
diff --git a/contrib/libs/libwebp/dsp/dec_sse2.c b/contrib/libs/libwebp/dsp/dec_sse2.c
deleted file mode 100644
index 5704156851..0000000000
--- a/contrib/libs/libwebp/dsp/dec_sse2.c
+++ /dev/null
@@ -1,1227 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// SSE2 version of some decoding functions (idct, loop filtering).
-//
-// Author: somnath@google.com (Somnath Banerjee)
-// cduvivier@google.com (Christian Duvivier)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_SSE2)
-
-// The 3-coeff sparse transform in SSE2 is not really faster than the plain-C
-// one it seems => disable it by default. Uncomment the following to enable:
-#if !defined(USE_TRANSFORM_AC3)
-#define USE_TRANSFORM_AC3 0 // ALTERNATE_CODE
-#endif
-
-#include <emmintrin.h>
-#include "./common_sse2.h"
-#include "../dec/vp8i_dec.h"
-#include "../utils/utils.h"
-
-//------------------------------------------------------------------------------
-// Transforms (Paragraph 14.4)
-
-static void Transform_SSE2(const int16_t* in, uint8_t* dst, int do_two) {
- // This implementation makes use of 16-bit fixed point versions of two
- // multiply constants:
- // K1 = sqrt(2) * cos (pi/8) ~= 85627 / 2^16
- // K2 = sqrt(2) * sin (pi/8) ~= 35468 / 2^16
- //
- // To be able to use signed 16-bit integers, we use the following trick to
- // have constants within range:
- // - Associated constants are obtained by subtracting the 16-bit fixed point
- // version of one:
- // k = K - (1 << 16) => K = k + (1 << 16)
- // K1 = 85267 => k1 = 20091
- // K2 = 35468 => k2 = -30068
- // - The multiplication of a variable by a constant become the sum of the
- // variable and the multiplication of that variable by the associated
- // constant:
- // (x * K) >> 16 = (x * (k + (1 << 16))) >> 16 = ((x * k ) >> 16) + x
- const __m128i k1 = _mm_set1_epi16(20091);
- const __m128i k2 = _mm_set1_epi16(-30068);
- __m128i T0, T1, T2, T3;
-
- // Load and concatenate the transform coefficients (we'll do two transforms
- // in parallel). In the case of only one transform, the second half of the
- // vectors will just contain random value we'll never use nor store.
- __m128i in0, in1, in2, in3;
- {
- in0 = _mm_loadl_epi64((const __m128i*)&in[0]);
- in1 = _mm_loadl_epi64((const __m128i*)&in[4]);
- in2 = _mm_loadl_epi64((const __m128i*)&in[8]);
- in3 = _mm_loadl_epi64((const __m128i*)&in[12]);
- // a00 a10 a20 a30 x x x x
- // a01 a11 a21 a31 x x x x
- // a02 a12 a22 a32 x x x x
- // a03 a13 a23 a33 x x x x
- if (do_two) {
- const __m128i inB0 = _mm_loadl_epi64((const __m128i*)&in[16]);
- const __m128i inB1 = _mm_loadl_epi64((const __m128i*)&in[20]);
- const __m128i inB2 = _mm_loadl_epi64((const __m128i*)&in[24]);
- const __m128i inB3 = _mm_loadl_epi64((const __m128i*)&in[28]);
- in0 = _mm_unpacklo_epi64(in0, inB0);
- in1 = _mm_unpacklo_epi64(in1, inB1);
- in2 = _mm_unpacklo_epi64(in2, inB2);
- in3 = _mm_unpacklo_epi64(in3, inB3);
- // a00 a10 a20 a30 b00 b10 b20 b30
- // a01 a11 a21 a31 b01 b11 b21 b31
- // a02 a12 a22 a32 b02 b12 b22 b32
- // a03 a13 a23 a33 b03 b13 b23 b33
- }
- }
-
- // Vertical pass and subsequent transpose.
- {
- // First pass, c and d calculations are longer because of the "trick"
- // multiplications.
- const __m128i a = _mm_add_epi16(in0, in2);
- const __m128i b = _mm_sub_epi16(in0, in2);
- // c = MUL(in1, K2) - MUL(in3, K1) = MUL(in1, k2) - MUL(in3, k1) + in1 - in3
- const __m128i c1 = _mm_mulhi_epi16(in1, k2);
- const __m128i c2 = _mm_mulhi_epi16(in3, k1);
- const __m128i c3 = _mm_sub_epi16(in1, in3);
- const __m128i c4 = _mm_sub_epi16(c1, c2);
- const __m128i c = _mm_add_epi16(c3, c4);
- // d = MUL(in1, K1) + MUL(in3, K2) = MUL(in1, k1) + MUL(in3, k2) + in1 + in3
- const __m128i d1 = _mm_mulhi_epi16(in1, k1);
- const __m128i d2 = _mm_mulhi_epi16(in3, k2);
- const __m128i d3 = _mm_add_epi16(in1, in3);
- const __m128i d4 = _mm_add_epi16(d1, d2);
- const __m128i d = _mm_add_epi16(d3, d4);
-
- // Second pass.
- const __m128i tmp0 = _mm_add_epi16(a, d);
- const __m128i tmp1 = _mm_add_epi16(b, c);
- const __m128i tmp2 = _mm_sub_epi16(b, c);
- const __m128i tmp3 = _mm_sub_epi16(a, d);
-
- // Transpose the two 4x4.
- VP8Transpose_2_4x4_16b(&tmp0, &tmp1, &tmp2, &tmp3, &T0, &T1, &T2, &T3);
- }
-
- // Horizontal pass and subsequent transpose.
- {
- // First pass, c and d calculations are longer because of the "trick"
- // multiplications.
- const __m128i four = _mm_set1_epi16(4);
- const __m128i dc = _mm_add_epi16(T0, four);
- const __m128i a = _mm_add_epi16(dc, T2);
- const __m128i b = _mm_sub_epi16(dc, T2);
- // c = MUL(T1, K2) - MUL(T3, K1) = MUL(T1, k2) - MUL(T3, k1) + T1 - T3
- const __m128i c1 = _mm_mulhi_epi16(T1, k2);
- const __m128i c2 = _mm_mulhi_epi16(T3, k1);
- const __m128i c3 = _mm_sub_epi16(T1, T3);
- const __m128i c4 = _mm_sub_epi16(c1, c2);
- const __m128i c = _mm_add_epi16(c3, c4);
- // d = MUL(T1, K1) + MUL(T3, K2) = MUL(T1, k1) + MUL(T3, k2) + T1 + T3
- const __m128i d1 = _mm_mulhi_epi16(T1, k1);
- const __m128i d2 = _mm_mulhi_epi16(T3, k2);
- const __m128i d3 = _mm_add_epi16(T1, T3);
- const __m128i d4 = _mm_add_epi16(d1, d2);
- const __m128i d = _mm_add_epi16(d3, d4);
-
- // Second pass.
- const __m128i tmp0 = _mm_add_epi16(a, d);
- const __m128i tmp1 = _mm_add_epi16(b, c);
- const __m128i tmp2 = _mm_sub_epi16(b, c);
- const __m128i tmp3 = _mm_sub_epi16(a, d);
- const __m128i shifted0 = _mm_srai_epi16(tmp0, 3);
- const __m128i shifted1 = _mm_srai_epi16(tmp1, 3);
- const __m128i shifted2 = _mm_srai_epi16(tmp2, 3);
- const __m128i shifted3 = _mm_srai_epi16(tmp3, 3);
-
- // Transpose the two 4x4.
- VP8Transpose_2_4x4_16b(&shifted0, &shifted1, &shifted2, &shifted3, &T0, &T1,
- &T2, &T3);
- }
-
- // Add inverse transform to 'dst' and store.
- {
- const __m128i zero = _mm_setzero_si128();
- // Load the reference(s).
- __m128i dst0, dst1, dst2, dst3;
- if (do_two) {
- // Load eight bytes/pixels per line.
- dst0 = _mm_loadl_epi64((__m128i*)(dst + 0 * BPS));
- dst1 = _mm_loadl_epi64((__m128i*)(dst + 1 * BPS));
- dst2 = _mm_loadl_epi64((__m128i*)(dst + 2 * BPS));
- dst3 = _mm_loadl_epi64((__m128i*)(dst + 3 * BPS));
- } else {
- // Load four bytes/pixels per line.
- dst0 = _mm_cvtsi32_si128(WebPMemToUint32(dst + 0 * BPS));
- dst1 = _mm_cvtsi32_si128(WebPMemToUint32(dst + 1 * BPS));
- dst2 = _mm_cvtsi32_si128(WebPMemToUint32(dst + 2 * BPS));
- dst3 = _mm_cvtsi32_si128(WebPMemToUint32(dst + 3 * BPS));
- }
- // Convert to 16b.
- dst0 = _mm_unpacklo_epi8(dst0, zero);
- dst1 = _mm_unpacklo_epi8(dst1, zero);
- dst2 = _mm_unpacklo_epi8(dst2, zero);
- dst3 = _mm_unpacklo_epi8(dst3, zero);
- // Add the inverse transform(s).
- dst0 = _mm_add_epi16(dst0, T0);
- dst1 = _mm_add_epi16(dst1, T1);
- dst2 = _mm_add_epi16(dst2, T2);
- dst3 = _mm_add_epi16(dst3, T3);
- // Unsigned saturate to 8b.
- dst0 = _mm_packus_epi16(dst0, dst0);
- dst1 = _mm_packus_epi16(dst1, dst1);
- dst2 = _mm_packus_epi16(dst2, dst2);
- dst3 = _mm_packus_epi16(dst3, dst3);
- // Store the results.
- if (do_two) {
- // Store eight bytes/pixels per line.
- _mm_storel_epi64((__m128i*)(dst + 0 * BPS), dst0);
- _mm_storel_epi64((__m128i*)(dst + 1 * BPS), dst1);
- _mm_storel_epi64((__m128i*)(dst + 2 * BPS), dst2);
- _mm_storel_epi64((__m128i*)(dst + 3 * BPS), dst3);
- } else {
- // Store four bytes/pixels per line.
- WebPUint32ToMem(dst + 0 * BPS, _mm_cvtsi128_si32(dst0));
- WebPUint32ToMem(dst + 1 * BPS, _mm_cvtsi128_si32(dst1));
- WebPUint32ToMem(dst + 2 * BPS, _mm_cvtsi128_si32(dst2));
- WebPUint32ToMem(dst + 3 * BPS, _mm_cvtsi128_si32(dst3));
- }
- }
-}
-
-#if (USE_TRANSFORM_AC3 == 1)
-#define MUL(a, b) (((a) * (b)) >> 16)
-static void TransformAC3(const int16_t* in, uint8_t* dst) {
- static const int kC1 = 20091 + (1 << 16);
- static const int kC2 = 35468;
- const __m128i A = _mm_set1_epi16(in[0] + 4);
- const __m128i c4 = _mm_set1_epi16(MUL(in[4], kC2));
- const __m128i d4 = _mm_set1_epi16(MUL(in[4], kC1));
- const int c1 = MUL(in[1], kC2);
- const int d1 = MUL(in[1], kC1);
- const __m128i CD = _mm_set_epi16(0, 0, 0, 0, -d1, -c1, c1, d1);
- const __m128i B = _mm_adds_epi16(A, CD);
- const __m128i m0 = _mm_adds_epi16(B, d4);
- const __m128i m1 = _mm_adds_epi16(B, c4);
- const __m128i m2 = _mm_subs_epi16(B, c4);
- const __m128i m3 = _mm_subs_epi16(B, d4);
- const __m128i zero = _mm_setzero_si128();
- // Load the source pixels.
- __m128i dst0 = _mm_cvtsi32_si128(WebPMemToUint32(dst + 0 * BPS));
- __m128i dst1 = _mm_cvtsi32_si128(WebPMemToUint32(dst + 1 * BPS));
- __m128i dst2 = _mm_cvtsi32_si128(WebPMemToUint32(dst + 2 * BPS));
- __m128i dst3 = _mm_cvtsi32_si128(WebPMemToUint32(dst + 3 * BPS));
- // Convert to 16b.
- dst0 = _mm_unpacklo_epi8(dst0, zero);
- dst1 = _mm_unpacklo_epi8(dst1, zero);
- dst2 = _mm_unpacklo_epi8(dst2, zero);
- dst3 = _mm_unpacklo_epi8(dst3, zero);
- // Add the inverse transform.
- dst0 = _mm_adds_epi16(dst0, _mm_srai_epi16(m0, 3));
- dst1 = _mm_adds_epi16(dst1, _mm_srai_epi16(m1, 3));
- dst2 = _mm_adds_epi16(dst2, _mm_srai_epi16(m2, 3));
- dst3 = _mm_adds_epi16(dst3, _mm_srai_epi16(m3, 3));
- // Unsigned saturate to 8b.
- dst0 = _mm_packus_epi16(dst0, dst0);
- dst1 = _mm_packus_epi16(dst1, dst1);
- dst2 = _mm_packus_epi16(dst2, dst2);
- dst3 = _mm_packus_epi16(dst3, dst3);
- // Store the results.
- WebPUint32ToMem(dst + 0 * BPS, _mm_cvtsi128_si32(dst0));
- WebPUint32ToMem(dst + 1 * BPS, _mm_cvtsi128_si32(dst1));
- WebPUint32ToMem(dst + 2 * BPS, _mm_cvtsi128_si32(dst2));
- WebPUint32ToMem(dst + 3 * BPS, _mm_cvtsi128_si32(dst3));
-}
-#undef MUL
-#endif // USE_TRANSFORM_AC3
-
-//------------------------------------------------------------------------------
-// Loop Filter (Paragraph 15)
-
-// Compute abs(p - q) = subs(p - q) OR subs(q - p)
-#define MM_ABS(p, q) _mm_or_si128( \
- _mm_subs_epu8((q), (p)), \
- _mm_subs_epu8((p), (q)))
-
-// Shift each byte of "x" by 3 bits while preserving by the sign bit.
-static WEBP_INLINE void SignedShift8b_SSE2(__m128i* const x) {
- const __m128i zero = _mm_setzero_si128();
- const __m128i lo_0 = _mm_unpacklo_epi8(zero, *x);
- const __m128i hi_0 = _mm_unpackhi_epi8(zero, *x);
- const __m128i lo_1 = _mm_srai_epi16(lo_0, 3 + 8);
- const __m128i hi_1 = _mm_srai_epi16(hi_0, 3 + 8);
- *x = _mm_packs_epi16(lo_1, hi_1);
-}
-
-#define FLIP_SIGN_BIT2(a, b) { \
- (a) = _mm_xor_si128(a, sign_bit); \
- (b) = _mm_xor_si128(b, sign_bit); \
-}
-
-#define FLIP_SIGN_BIT4(a, b, c, d) { \
- FLIP_SIGN_BIT2(a, b); \
- FLIP_SIGN_BIT2(c, d); \
-}
-
-// input/output is uint8_t
-static WEBP_INLINE void GetNotHEV_SSE2(const __m128i* const p1,
- const __m128i* const p0,
- const __m128i* const q0,
- const __m128i* const q1,
- int hev_thresh, __m128i* const not_hev) {
- const __m128i zero = _mm_setzero_si128();
- const __m128i t_1 = MM_ABS(*p1, *p0);
- const __m128i t_2 = MM_ABS(*q1, *q0);
-
- const __m128i h = _mm_set1_epi8(hev_thresh);
- const __m128i t_max = _mm_max_epu8(t_1, t_2);
-
- const __m128i t_max_h = _mm_subs_epu8(t_max, h);
- *not_hev = _mm_cmpeq_epi8(t_max_h, zero); // not_hev <= t1 && not_hev <= t2
-}
-
-// input pixels are int8_t
-static WEBP_INLINE void GetBaseDelta_SSE2(const __m128i* const p1,
- const __m128i* const p0,
- const __m128i* const q0,
- const __m128i* const q1,
- __m128i* const delta) {
- // beware of addition order, for saturation!
- const __m128i p1_q1 = _mm_subs_epi8(*p1, *q1); // p1 - q1
- const __m128i q0_p0 = _mm_subs_epi8(*q0, *p0); // q0 - p0
- const __m128i s1 = _mm_adds_epi8(p1_q1, q0_p0); // p1 - q1 + 1 * (q0 - p0)
- const __m128i s2 = _mm_adds_epi8(q0_p0, s1); // p1 - q1 + 2 * (q0 - p0)
- const __m128i s3 = _mm_adds_epi8(q0_p0, s2); // p1 - q1 + 3 * (q0 - p0)
- *delta = s3;
-}
-
-// input and output are int8_t
-static WEBP_INLINE void DoSimpleFilter_SSE2(__m128i* const p0,
- __m128i* const q0,
- const __m128i* const fl) {
- const __m128i k3 = _mm_set1_epi8(3);
- const __m128i k4 = _mm_set1_epi8(4);
- __m128i v3 = _mm_adds_epi8(*fl, k3);
- __m128i v4 = _mm_adds_epi8(*fl, k4);
-
- SignedShift8b_SSE2(&v4); // v4 >> 3
- SignedShift8b_SSE2(&v3); // v3 >> 3
- *q0 = _mm_subs_epi8(*q0, v4); // q0 -= v4
- *p0 = _mm_adds_epi8(*p0, v3); // p0 += v3
-}
-
-// Updates values of 2 pixels at MB edge during complex filtering.
-// Update operations:
-// q = q - delta and p = p + delta; where delta = [(a_hi >> 7), (a_lo >> 7)]
-// Pixels 'pi' and 'qi' are int8_t on input, uint8_t on output (sign flip).
-static WEBP_INLINE void Update2Pixels_SSE2(__m128i* const pi, __m128i* const qi,
- const __m128i* const a0_lo,
- const __m128i* const a0_hi) {
- const __m128i a1_lo = _mm_srai_epi16(*a0_lo, 7);
- const __m128i a1_hi = _mm_srai_epi16(*a0_hi, 7);
- const __m128i delta = _mm_packs_epi16(a1_lo, a1_hi);
- const __m128i sign_bit = _mm_set1_epi8((char)0x80);
- *pi = _mm_adds_epi8(*pi, delta);
- *qi = _mm_subs_epi8(*qi, delta);
- FLIP_SIGN_BIT2(*pi, *qi);
-}
-
-// input pixels are uint8_t
-static WEBP_INLINE void NeedsFilter_SSE2(const __m128i* const p1,
- const __m128i* const p0,
- const __m128i* const q0,
- const __m128i* const q1,
- int thresh, __m128i* const mask) {
- const __m128i m_thresh = _mm_set1_epi8((char)thresh);
- const __m128i t1 = MM_ABS(*p1, *q1); // abs(p1 - q1)
- const __m128i kFE = _mm_set1_epi8((char)0xFE);
- const __m128i t2 = _mm_and_si128(t1, kFE); // set lsb of each byte to zero
- const __m128i t3 = _mm_srli_epi16(t2, 1); // abs(p1 - q1) / 2
-
- const __m128i t4 = MM_ABS(*p0, *q0); // abs(p0 - q0)
- const __m128i t5 = _mm_adds_epu8(t4, t4); // abs(p0 - q0) * 2
- const __m128i t6 = _mm_adds_epu8(t5, t3); // abs(p0-q0)*2 + abs(p1-q1)/2
-
- const __m128i t7 = _mm_subs_epu8(t6, m_thresh); // mask <= m_thresh
- *mask = _mm_cmpeq_epi8(t7, _mm_setzero_si128());
-}
-
-//------------------------------------------------------------------------------
-// Edge filtering functions
-
-// Applies filter on 2 pixels (p0 and q0)
-static WEBP_INLINE void DoFilter2_SSE2(__m128i* const p1, __m128i* const p0,
- __m128i* const q0, __m128i* const q1,
- int thresh) {
- __m128i a, mask;
- const __m128i sign_bit = _mm_set1_epi8((char)0x80);
- // convert p1/q1 to int8_t (for GetBaseDelta_SSE2)
- const __m128i p1s = _mm_xor_si128(*p1, sign_bit);
- const __m128i q1s = _mm_xor_si128(*q1, sign_bit);
-
- NeedsFilter_SSE2(p1, p0, q0, q1, thresh, &mask);
-
- FLIP_SIGN_BIT2(*p0, *q0);
- GetBaseDelta_SSE2(&p1s, p0, q0, &q1s, &a);
- a = _mm_and_si128(a, mask); // mask filter values we don't care about
- DoSimpleFilter_SSE2(p0, q0, &a);
- FLIP_SIGN_BIT2(*p0, *q0);
-}
-
-// Applies filter on 4 pixels (p1, p0, q0 and q1)
-static WEBP_INLINE void DoFilter4_SSE2(__m128i* const p1, __m128i* const p0,
- __m128i* const q0, __m128i* const q1,
- const __m128i* const mask,
- int hev_thresh) {
- const __m128i zero = _mm_setzero_si128();
- const __m128i sign_bit = _mm_set1_epi8((char)0x80);
- const __m128i k64 = _mm_set1_epi8(64);
- const __m128i k3 = _mm_set1_epi8(3);
- const __m128i k4 = _mm_set1_epi8(4);
- __m128i not_hev;
- __m128i t1, t2, t3;
-
- // compute hev mask
- GetNotHEV_SSE2(p1, p0, q0, q1, hev_thresh, &not_hev);
-
- // convert to signed values
- FLIP_SIGN_BIT4(*p1, *p0, *q0, *q1);
-
- t1 = _mm_subs_epi8(*p1, *q1); // p1 - q1
- t1 = _mm_andnot_si128(not_hev, t1); // hev(p1 - q1)
- t2 = _mm_subs_epi8(*q0, *p0); // q0 - p0
- t1 = _mm_adds_epi8(t1, t2); // hev(p1 - q1) + 1 * (q0 - p0)
- t1 = _mm_adds_epi8(t1, t2); // hev(p1 - q1) + 2 * (q0 - p0)
- t1 = _mm_adds_epi8(t1, t2); // hev(p1 - q1) + 3 * (q0 - p0)
- t1 = _mm_and_si128(t1, *mask); // mask filter values we don't care about
-
- t2 = _mm_adds_epi8(t1, k3); // 3 * (q0 - p0) + hev(p1 - q1) + 3
- t3 = _mm_adds_epi8(t1, k4); // 3 * (q0 - p0) + hev(p1 - q1) + 4
- SignedShift8b_SSE2(&t2); // (3 * (q0 - p0) + hev(p1 - q1) + 3) >> 3
- SignedShift8b_SSE2(&t3); // (3 * (q0 - p0) + hev(p1 - q1) + 4) >> 3
- *p0 = _mm_adds_epi8(*p0, t2); // p0 += t2
- *q0 = _mm_subs_epi8(*q0, t3); // q0 -= t3
- FLIP_SIGN_BIT2(*p0, *q0);
-
- // this is equivalent to signed (a + 1) >> 1 calculation
- t2 = _mm_add_epi8(t3, sign_bit);
- t3 = _mm_avg_epu8(t2, zero);
- t3 = _mm_sub_epi8(t3, k64);
-
- t3 = _mm_and_si128(not_hev, t3); // if !hev
- *q1 = _mm_subs_epi8(*q1, t3); // q1 -= t3
- *p1 = _mm_adds_epi8(*p1, t3); // p1 += t3
- FLIP_SIGN_BIT2(*p1, *q1);
-}
-
-// Applies filter on 6 pixels (p2, p1, p0, q0, q1 and q2)
-static WEBP_INLINE void DoFilter6_SSE2(__m128i* const p2, __m128i* const p1,
- __m128i* const p0, __m128i* const q0,
- __m128i* const q1, __m128i* const q2,
- const __m128i* const mask,
- int hev_thresh) {
- const __m128i zero = _mm_setzero_si128();
- const __m128i sign_bit = _mm_set1_epi8((char)0x80);
- __m128i a, not_hev;
-
- // compute hev mask
- GetNotHEV_SSE2(p1, p0, q0, q1, hev_thresh, &not_hev);
-
- FLIP_SIGN_BIT4(*p1, *p0, *q0, *q1);
- FLIP_SIGN_BIT2(*p2, *q2);
- GetBaseDelta_SSE2(p1, p0, q0, q1, &a);
-
- { // do simple filter on pixels with hev
- const __m128i m = _mm_andnot_si128(not_hev, *mask);
- const __m128i f = _mm_and_si128(a, m);
- DoSimpleFilter_SSE2(p0, q0, &f);
- }
-
- { // do strong filter on pixels with not hev
- const __m128i k9 = _mm_set1_epi16(0x0900);
- const __m128i k63 = _mm_set1_epi16(63);
-
- const __m128i m = _mm_and_si128(not_hev, *mask);
- const __m128i f = _mm_and_si128(a, m);
-
- const __m128i f_lo = _mm_unpacklo_epi8(zero, f);
- const __m128i f_hi = _mm_unpackhi_epi8(zero, f);
-
- const __m128i f9_lo = _mm_mulhi_epi16(f_lo, k9); // Filter (lo) * 9
- const __m128i f9_hi = _mm_mulhi_epi16(f_hi, k9); // Filter (hi) * 9
-
- const __m128i a2_lo = _mm_add_epi16(f9_lo, k63); // Filter * 9 + 63
- const __m128i a2_hi = _mm_add_epi16(f9_hi, k63); // Filter * 9 + 63
-
- const __m128i a1_lo = _mm_add_epi16(a2_lo, f9_lo); // Filter * 18 + 63
- const __m128i a1_hi = _mm_add_epi16(a2_hi, f9_hi); // Filter * 18 + 63
-
- const __m128i a0_lo = _mm_add_epi16(a1_lo, f9_lo); // Filter * 27 + 63
- const __m128i a0_hi = _mm_add_epi16(a1_hi, f9_hi); // Filter * 27 + 63
-
- Update2Pixels_SSE2(p2, q2, &a2_lo, &a2_hi);
- Update2Pixels_SSE2(p1, q1, &a1_lo, &a1_hi);
- Update2Pixels_SSE2(p0, q0, &a0_lo, &a0_hi);
- }
-}
-
-// reads 8 rows across a vertical edge.
-static WEBP_INLINE void Load8x4_SSE2(const uint8_t* const b, int stride,
- __m128i* const p, __m128i* const q) {
- // A0 = 63 62 61 60 23 22 21 20 43 42 41 40 03 02 01 00
- // A1 = 73 72 71 70 33 32 31 30 53 52 51 50 13 12 11 10
- const __m128i A0 = _mm_set_epi32(
- WebPMemToUint32(&b[6 * stride]), WebPMemToUint32(&b[2 * stride]),
- WebPMemToUint32(&b[4 * stride]), WebPMemToUint32(&b[0 * stride]));
- const __m128i A1 = _mm_set_epi32(
- WebPMemToUint32(&b[7 * stride]), WebPMemToUint32(&b[3 * stride]),
- WebPMemToUint32(&b[5 * stride]), WebPMemToUint32(&b[1 * stride]));
-
- // B0 = 53 43 52 42 51 41 50 40 13 03 12 02 11 01 10 00
- // B1 = 73 63 72 62 71 61 70 60 33 23 32 22 31 21 30 20
- const __m128i B0 = _mm_unpacklo_epi8(A0, A1);
- const __m128i B1 = _mm_unpackhi_epi8(A0, A1);
-
- // C0 = 33 23 13 03 32 22 12 02 31 21 11 01 30 20 10 00
- // C1 = 73 63 53 43 72 62 52 42 71 61 51 41 70 60 50 40
- const __m128i C0 = _mm_unpacklo_epi16(B0, B1);
- const __m128i C1 = _mm_unpackhi_epi16(B0, B1);
-
- // *p = 71 61 51 41 31 21 11 01 70 60 50 40 30 20 10 00
- // *q = 73 63 53 43 33 23 13 03 72 62 52 42 32 22 12 02
- *p = _mm_unpacklo_epi32(C0, C1);
- *q = _mm_unpackhi_epi32(C0, C1);
-}
-
-static WEBP_INLINE void Load16x4_SSE2(const uint8_t* const r0,
- const uint8_t* const r8,
- int stride,
- __m128i* const p1, __m128i* const p0,
- __m128i* const q0, __m128i* const q1) {
- // Assume the pixels around the edge (|) are numbered as follows
- // 00 01 | 02 03
- // 10 11 | 12 13
- // ... | ...
- // e0 e1 | e2 e3
- // f0 f1 | f2 f3
- //
- // r0 is pointing to the 0th row (00)
- // r8 is pointing to the 8th row (80)
-
- // Load
- // p1 = 71 61 51 41 31 21 11 01 70 60 50 40 30 20 10 00
- // q0 = 73 63 53 43 33 23 13 03 72 62 52 42 32 22 12 02
- // p0 = f1 e1 d1 c1 b1 a1 91 81 f0 e0 d0 c0 b0 a0 90 80
- // q1 = f3 e3 d3 c3 b3 a3 93 83 f2 e2 d2 c2 b2 a2 92 82
- Load8x4_SSE2(r0, stride, p1, q0);
- Load8x4_SSE2(r8, stride, p0, q1);
-
- {
- // p1 = f0 e0 d0 c0 b0 a0 90 80 70 60 50 40 30 20 10 00
- // p0 = f1 e1 d1 c1 b1 a1 91 81 71 61 51 41 31 21 11 01
- // q0 = f2 e2 d2 c2 b2 a2 92 82 72 62 52 42 32 22 12 02
- // q1 = f3 e3 d3 c3 b3 a3 93 83 73 63 53 43 33 23 13 03
- const __m128i t1 = *p1;
- const __m128i t2 = *q0;
- *p1 = _mm_unpacklo_epi64(t1, *p0);
- *p0 = _mm_unpackhi_epi64(t1, *p0);
- *q0 = _mm_unpacklo_epi64(t2, *q1);
- *q1 = _mm_unpackhi_epi64(t2, *q1);
- }
-}
-
-static WEBP_INLINE void Store4x4_SSE2(__m128i* const x,
- uint8_t* dst, int stride) {
- int i;
- for (i = 0; i < 4; ++i, dst += stride) {
- WebPUint32ToMem(dst, _mm_cvtsi128_si32(*x));
- *x = _mm_srli_si128(*x, 4);
- }
-}
-
-// Transpose back and store
-static WEBP_INLINE void Store16x4_SSE2(const __m128i* const p1,
- const __m128i* const p0,
- const __m128i* const q0,
- const __m128i* const q1,
- uint8_t* r0, uint8_t* r8,
- int stride) {
- __m128i t1, p1_s, p0_s, q0_s, q1_s;
-
- // p0 = 71 70 61 60 51 50 41 40 31 30 21 20 11 10 01 00
- // p1 = f1 f0 e1 e0 d1 d0 c1 c0 b1 b0 a1 a0 91 90 81 80
- t1 = *p0;
- p0_s = _mm_unpacklo_epi8(*p1, t1);
- p1_s = _mm_unpackhi_epi8(*p1, t1);
-
- // q0 = 73 72 63 62 53 52 43 42 33 32 23 22 13 12 03 02
- // q1 = f3 f2 e3 e2 d3 d2 c3 c2 b3 b2 a3 a2 93 92 83 82
- t1 = *q0;
- q0_s = _mm_unpacklo_epi8(t1, *q1);
- q1_s = _mm_unpackhi_epi8(t1, *q1);
-
- // p0 = 33 32 31 30 23 22 21 20 13 12 11 10 03 02 01 00
- // q0 = 73 72 71 70 63 62 61 60 53 52 51 50 43 42 41 40
- t1 = p0_s;
- p0_s = _mm_unpacklo_epi16(t1, q0_s);
- q0_s = _mm_unpackhi_epi16(t1, q0_s);
-
- // p1 = b3 b2 b1 b0 a3 a2 a1 a0 93 92 91 90 83 82 81 80
- // q1 = f3 f2 f1 f0 e3 e2 e1 e0 d3 d2 d1 d0 c3 c2 c1 c0
- t1 = p1_s;
- p1_s = _mm_unpacklo_epi16(t1, q1_s);
- q1_s = _mm_unpackhi_epi16(t1, q1_s);
-
- Store4x4_SSE2(&p0_s, r0, stride);
- r0 += 4 * stride;
- Store4x4_SSE2(&q0_s, r0, stride);
-
- Store4x4_SSE2(&p1_s, r8, stride);
- r8 += 4 * stride;
- Store4x4_SSE2(&q1_s, r8, stride);
-}
-
-//------------------------------------------------------------------------------
-// Simple In-loop filtering (Paragraph 15.2)
-
-static void SimpleVFilter16_SSE2(uint8_t* p, int stride, int thresh) {
- // Load
- __m128i p1 = _mm_loadu_si128((__m128i*)&p[-2 * stride]);
- __m128i p0 = _mm_loadu_si128((__m128i*)&p[-stride]);
- __m128i q0 = _mm_loadu_si128((__m128i*)&p[0]);
- __m128i q1 = _mm_loadu_si128((__m128i*)&p[stride]);
-
- DoFilter2_SSE2(&p1, &p0, &q0, &q1, thresh);
-
- // Store
- _mm_storeu_si128((__m128i*)&p[-stride], p0);
- _mm_storeu_si128((__m128i*)&p[0], q0);
-}
-
-static void SimpleHFilter16_SSE2(uint8_t* p, int stride, int thresh) {
- __m128i p1, p0, q0, q1;
-
- p -= 2; // beginning of p1
-
- Load16x4_SSE2(p, p + 8 * stride, stride, &p1, &p0, &q0, &q1);
- DoFilter2_SSE2(&p1, &p0, &q0, &q1, thresh);
- Store16x4_SSE2(&p1, &p0, &q0, &q1, p, p + 8 * stride, stride);
-}
-
-static void SimpleVFilter16i_SSE2(uint8_t* p, int stride, int thresh) {
- int k;
- for (k = 3; k > 0; --k) {
- p += 4 * stride;
- SimpleVFilter16_SSE2(p, stride, thresh);
- }
-}
-
-static void SimpleHFilter16i_SSE2(uint8_t* p, int stride, int thresh) {
- int k;
- for (k = 3; k > 0; --k) {
- p += 4;
- SimpleHFilter16_SSE2(p, stride, thresh);
- }
-}
-
-//------------------------------------------------------------------------------
-// Complex In-loop filtering (Paragraph 15.3)
-
-#define MAX_DIFF1(p3, p2, p1, p0, m) do { \
- (m) = MM_ABS(p1, p0); \
- (m) = _mm_max_epu8(m, MM_ABS(p3, p2)); \
- (m) = _mm_max_epu8(m, MM_ABS(p2, p1)); \
-} while (0)
-
-#define MAX_DIFF2(p3, p2, p1, p0, m) do { \
- (m) = _mm_max_epu8(m, MM_ABS(p1, p0)); \
- (m) = _mm_max_epu8(m, MM_ABS(p3, p2)); \
- (m) = _mm_max_epu8(m, MM_ABS(p2, p1)); \
-} while (0)
-
-#define LOAD_H_EDGES4(p, stride, e1, e2, e3, e4) { \
- (e1) = _mm_loadu_si128((__m128i*)&(p)[0 * (stride)]); \
- (e2) = _mm_loadu_si128((__m128i*)&(p)[1 * (stride)]); \
- (e3) = _mm_loadu_si128((__m128i*)&(p)[2 * (stride)]); \
- (e4) = _mm_loadu_si128((__m128i*)&(p)[3 * (stride)]); \
-}
-
-#define LOADUV_H_EDGE(p, u, v, stride) do { \
- const __m128i U = _mm_loadl_epi64((__m128i*)&(u)[(stride)]); \
- const __m128i V = _mm_loadl_epi64((__m128i*)&(v)[(stride)]); \
- (p) = _mm_unpacklo_epi64(U, V); \
-} while (0)
-
-#define LOADUV_H_EDGES4(u, v, stride, e1, e2, e3, e4) { \
- LOADUV_H_EDGE(e1, u, v, 0 * (stride)); \
- LOADUV_H_EDGE(e2, u, v, 1 * (stride)); \
- LOADUV_H_EDGE(e3, u, v, 2 * (stride)); \
- LOADUV_H_EDGE(e4, u, v, 3 * (stride)); \
-}
-
-#define STOREUV(p, u, v, stride) { \
- _mm_storel_epi64((__m128i*)&(u)[(stride)], p); \
- (p) = _mm_srli_si128(p, 8); \
- _mm_storel_epi64((__m128i*)&(v)[(stride)], p); \
-}
-
-static WEBP_INLINE void ComplexMask_SSE2(const __m128i* const p1,
- const __m128i* const p0,
- const __m128i* const q0,
- const __m128i* const q1,
- int thresh, int ithresh,
- __m128i* const mask) {
- const __m128i it = _mm_set1_epi8(ithresh);
- const __m128i diff = _mm_subs_epu8(*mask, it);
- const __m128i thresh_mask = _mm_cmpeq_epi8(diff, _mm_setzero_si128());
- __m128i filter_mask;
- NeedsFilter_SSE2(p1, p0, q0, q1, thresh, &filter_mask);
- *mask = _mm_and_si128(thresh_mask, filter_mask);
-}
-
-// on macroblock edges
-static void VFilter16_SSE2(uint8_t* p, int stride,
- int thresh, int ithresh, int hev_thresh) {
- __m128i t1;
- __m128i mask;
- __m128i p2, p1, p0, q0, q1, q2;
-
- // Load p3, p2, p1, p0
- LOAD_H_EDGES4(p - 4 * stride, stride, t1, p2, p1, p0);
- MAX_DIFF1(t1, p2, p1, p0, mask);
-
- // Load q0, q1, q2, q3
- LOAD_H_EDGES4(p, stride, q0, q1, q2, t1);
- MAX_DIFF2(t1, q2, q1, q0, mask);
-
- ComplexMask_SSE2(&p1, &p0, &q0, &q1, thresh, ithresh, &mask);
- DoFilter6_SSE2(&p2, &p1, &p0, &q0, &q1, &q2, &mask, hev_thresh);
-
- // Store
- _mm_storeu_si128((__m128i*)&p[-3 * stride], p2);
- _mm_storeu_si128((__m128i*)&p[-2 * stride], p1);
- _mm_storeu_si128((__m128i*)&p[-1 * stride], p0);
- _mm_storeu_si128((__m128i*)&p[+0 * stride], q0);
- _mm_storeu_si128((__m128i*)&p[+1 * stride], q1);
- _mm_storeu_si128((__m128i*)&p[+2 * stride], q2);
-}
-
-static void HFilter16_SSE2(uint8_t* p, int stride,
- int thresh, int ithresh, int hev_thresh) {
- __m128i mask;
- __m128i p3, p2, p1, p0, q0, q1, q2, q3;
-
- uint8_t* const b = p - 4;
- Load16x4_SSE2(b, b + 8 * stride, stride, &p3, &p2, &p1, &p0);
- MAX_DIFF1(p3, p2, p1, p0, mask);
-
- Load16x4_SSE2(p, p + 8 * stride, stride, &q0, &q1, &q2, &q3);
- MAX_DIFF2(q3, q2, q1, q0, mask);
-
- ComplexMask_SSE2(&p1, &p0, &q0, &q1, thresh, ithresh, &mask);
- DoFilter6_SSE2(&p2, &p1, &p0, &q0, &q1, &q2, &mask, hev_thresh);
-
- Store16x4_SSE2(&p3, &p2, &p1, &p0, b, b + 8 * stride, stride);
- Store16x4_SSE2(&q0, &q1, &q2, &q3, p, p + 8 * stride, stride);
-}
-
-// on three inner edges
-static void VFilter16i_SSE2(uint8_t* p, int stride,
- int thresh, int ithresh, int hev_thresh) {
- int k;
- __m128i p3, p2, p1, p0; // loop invariants
-
- LOAD_H_EDGES4(p, stride, p3, p2, p1, p0); // prologue
-
- for (k = 3; k > 0; --k) {
- __m128i mask, tmp1, tmp2;
- uint8_t* const b = p + 2 * stride; // beginning of p1
- p += 4 * stride;
-
- MAX_DIFF1(p3, p2, p1, p0, mask); // compute partial mask
- LOAD_H_EDGES4(p, stride, p3, p2, tmp1, tmp2);
- MAX_DIFF2(p3, p2, tmp1, tmp2, mask);
-
- // p3 and p2 are not just temporary variables here: they will be
- // re-used for next span. And q2/q3 will become p1/p0 accordingly.
- ComplexMask_SSE2(&p1, &p0, &p3, &p2, thresh, ithresh, &mask);
- DoFilter4_SSE2(&p1, &p0, &p3, &p2, &mask, hev_thresh);
-
- // Store
- _mm_storeu_si128((__m128i*)&b[0 * stride], p1);
- _mm_storeu_si128((__m128i*)&b[1 * stride], p0);
- _mm_storeu_si128((__m128i*)&b[2 * stride], p3);
- _mm_storeu_si128((__m128i*)&b[3 * stride], p2);
-
- // rotate samples
- p1 = tmp1;
- p0 = tmp2;
- }
-}
-
-static void HFilter16i_SSE2(uint8_t* p, int stride,
- int thresh, int ithresh, int hev_thresh) {
- int k;
- __m128i p3, p2, p1, p0; // loop invariants
-
- Load16x4_SSE2(p, p + 8 * stride, stride, &p3, &p2, &p1, &p0); // prologue
-
- for (k = 3; k > 0; --k) {
- __m128i mask, tmp1, tmp2;
- uint8_t* const b = p + 2; // beginning of p1
-
- p += 4; // beginning of q0 (and next span)
-
- MAX_DIFF1(p3, p2, p1, p0, mask); // compute partial mask
- Load16x4_SSE2(p, p + 8 * stride, stride, &p3, &p2, &tmp1, &tmp2);
- MAX_DIFF2(p3, p2, tmp1, tmp2, mask);
-
- ComplexMask_SSE2(&p1, &p0, &p3, &p2, thresh, ithresh, &mask);
- DoFilter4_SSE2(&p1, &p0, &p3, &p2, &mask, hev_thresh);
-
- Store16x4_SSE2(&p1, &p0, &p3, &p2, b, b + 8 * stride, stride);
-
- // rotate samples
- p1 = tmp1;
- p0 = tmp2;
- }
-}
-
-// 8-pixels wide variant, for chroma filtering
-static void VFilter8_SSE2(uint8_t* u, uint8_t* v, int stride,
- int thresh, int ithresh, int hev_thresh) {
- __m128i mask;
- __m128i t1, p2, p1, p0, q0, q1, q2;
-
- // Load p3, p2, p1, p0
- LOADUV_H_EDGES4(u - 4 * stride, v - 4 * stride, stride, t1, p2, p1, p0);
- MAX_DIFF1(t1, p2, p1, p0, mask);
-
- // Load q0, q1, q2, q3
- LOADUV_H_EDGES4(u, v, stride, q0, q1, q2, t1);
- MAX_DIFF2(t1, q2, q1, q0, mask);
-
- ComplexMask_SSE2(&p1, &p0, &q0, &q1, thresh, ithresh, &mask);
- DoFilter6_SSE2(&p2, &p1, &p0, &q0, &q1, &q2, &mask, hev_thresh);
-
- // Store
- STOREUV(p2, u, v, -3 * stride);
- STOREUV(p1, u, v, -2 * stride);
- STOREUV(p0, u, v, -1 * stride);
- STOREUV(q0, u, v, 0 * stride);
- STOREUV(q1, u, v, 1 * stride);
- STOREUV(q2, u, v, 2 * stride);
-}
-
-static void HFilter8_SSE2(uint8_t* u, uint8_t* v, int stride,
- int thresh, int ithresh, int hev_thresh) {
- __m128i mask;
- __m128i p3, p2, p1, p0, q0, q1, q2, q3;
-
- uint8_t* const tu = u - 4;
- uint8_t* const tv = v - 4;
- Load16x4_SSE2(tu, tv, stride, &p3, &p2, &p1, &p0);
- MAX_DIFF1(p3, p2, p1, p0, mask);
-
- Load16x4_SSE2(u, v, stride, &q0, &q1, &q2, &q3);
- MAX_DIFF2(q3, q2, q1, q0, mask);
-
- ComplexMask_SSE2(&p1, &p0, &q0, &q1, thresh, ithresh, &mask);
- DoFilter6_SSE2(&p2, &p1, &p0, &q0, &q1, &q2, &mask, hev_thresh);
-
- Store16x4_SSE2(&p3, &p2, &p1, &p0, tu, tv, stride);
- Store16x4_SSE2(&q0, &q1, &q2, &q3, u, v, stride);
-}
-
-static void VFilter8i_SSE2(uint8_t* u, uint8_t* v, int stride,
- int thresh, int ithresh, int hev_thresh) {
- __m128i mask;
- __m128i t1, t2, p1, p0, q0, q1;
-
- // Load p3, p2, p1, p0
- LOADUV_H_EDGES4(u, v, stride, t2, t1, p1, p0);
- MAX_DIFF1(t2, t1, p1, p0, mask);
-
- u += 4 * stride;
- v += 4 * stride;
-
- // Load q0, q1, q2, q3
- LOADUV_H_EDGES4(u, v, stride, q0, q1, t1, t2);
- MAX_DIFF2(t2, t1, q1, q0, mask);
-
- ComplexMask_SSE2(&p1, &p0, &q0, &q1, thresh, ithresh, &mask);
- DoFilter4_SSE2(&p1, &p0, &q0, &q1, &mask, hev_thresh);
-
- // Store
- STOREUV(p1, u, v, -2 * stride);
- STOREUV(p0, u, v, -1 * stride);
- STOREUV(q0, u, v, 0 * stride);
- STOREUV(q1, u, v, 1 * stride);
-}
-
-static void HFilter8i_SSE2(uint8_t* u, uint8_t* v, int stride,
- int thresh, int ithresh, int hev_thresh) {
- __m128i mask;
- __m128i t1, t2, p1, p0, q0, q1;
- Load16x4_SSE2(u, v, stride, &t2, &t1, &p1, &p0); // p3, p2, p1, p0
- MAX_DIFF1(t2, t1, p1, p0, mask);
-
- u += 4; // beginning of q0
- v += 4;
- Load16x4_SSE2(u, v, stride, &q0, &q1, &t1, &t2); // q0, q1, q2, q3
- MAX_DIFF2(t2, t1, q1, q0, mask);
-
- ComplexMask_SSE2(&p1, &p0, &q0, &q1, thresh, ithresh, &mask);
- DoFilter4_SSE2(&p1, &p0, &q0, &q1, &mask, hev_thresh);
-
- u -= 2; // beginning of p1
- v -= 2;
- Store16x4_SSE2(&p1, &p0, &q0, &q1, u, v, stride);
-}
-
-//------------------------------------------------------------------------------
-// 4x4 predictions
-
-#define DST(x, y) dst[(x) + (y) * BPS]
-#define AVG3(a, b, c) (((a) + 2 * (b) + (c) + 2) >> 2)
-
-// We use the following 8b-arithmetic tricks:
-// (a + 2 * b + c + 2) >> 2 = (AC + b + 1) >> 1
-// where: AC = (a + c) >> 1 = [(a + c + 1) >> 1] - [(a^c) & 1]
-// and:
-// (a + 2 * b + c + 2) >> 2 = (AB + BC + 1) >> 1 - (ab|bc)&lsb
-// where: AC = (a + b + 1) >> 1, BC = (b + c + 1) >> 1
-// and ab = a ^ b, bc = b ^ c, lsb = (AC^BC)&1
-
-static void VE4_SSE2(uint8_t* dst) { // vertical
- const __m128i one = _mm_set1_epi8(1);
- const __m128i ABCDEFGH = _mm_loadl_epi64((__m128i*)(dst - BPS - 1));
- const __m128i BCDEFGH0 = _mm_srli_si128(ABCDEFGH, 1);
- const __m128i CDEFGH00 = _mm_srli_si128(ABCDEFGH, 2);
- const __m128i a = _mm_avg_epu8(ABCDEFGH, CDEFGH00);
- const __m128i lsb = _mm_and_si128(_mm_xor_si128(ABCDEFGH, CDEFGH00), one);
- const __m128i b = _mm_subs_epu8(a, lsb);
- const __m128i avg = _mm_avg_epu8(b, BCDEFGH0);
- const uint32_t vals = _mm_cvtsi128_si32(avg);
- int i;
- for (i = 0; i < 4; ++i) {
- WebPUint32ToMem(dst + i * BPS, vals);
- }
-}
-
-static void LD4_SSE2(uint8_t* dst) { // Down-Left
- const __m128i one = _mm_set1_epi8(1);
- const __m128i ABCDEFGH = _mm_loadl_epi64((__m128i*)(dst - BPS));
- const __m128i BCDEFGH0 = _mm_srli_si128(ABCDEFGH, 1);
- const __m128i CDEFGH00 = _mm_srli_si128(ABCDEFGH, 2);
- const __m128i CDEFGHH0 = _mm_insert_epi16(CDEFGH00, dst[-BPS + 7], 3);
- const __m128i avg1 = _mm_avg_epu8(ABCDEFGH, CDEFGHH0);
- const __m128i lsb = _mm_and_si128(_mm_xor_si128(ABCDEFGH, CDEFGHH0), one);
- const __m128i avg2 = _mm_subs_epu8(avg1, lsb);
- const __m128i abcdefg = _mm_avg_epu8(avg2, BCDEFGH0);
- WebPUint32ToMem(dst + 0 * BPS, _mm_cvtsi128_si32( abcdefg ));
- WebPUint32ToMem(dst + 1 * BPS, _mm_cvtsi128_si32(_mm_srli_si128(abcdefg, 1)));
- WebPUint32ToMem(dst + 2 * BPS, _mm_cvtsi128_si32(_mm_srli_si128(abcdefg, 2)));
- WebPUint32ToMem(dst + 3 * BPS, _mm_cvtsi128_si32(_mm_srli_si128(abcdefg, 3)));
-}
-
-static void VR4_SSE2(uint8_t* dst) { // Vertical-Right
- const __m128i one = _mm_set1_epi8(1);
- const int I = dst[-1 + 0 * BPS];
- const int J = dst[-1 + 1 * BPS];
- const int K = dst[-1 + 2 * BPS];
- const int X = dst[-1 - BPS];
- const __m128i XABCD = _mm_loadl_epi64((__m128i*)(dst - BPS - 1));
- const __m128i ABCD0 = _mm_srli_si128(XABCD, 1);
- const __m128i abcd = _mm_avg_epu8(XABCD, ABCD0);
- const __m128i _XABCD = _mm_slli_si128(XABCD, 1);
- const __m128i IXABCD = _mm_insert_epi16(_XABCD, (short)(I | (X << 8)), 0);
- const __m128i avg1 = _mm_avg_epu8(IXABCD, ABCD0);
- const __m128i lsb = _mm_and_si128(_mm_xor_si128(IXABCD, ABCD0), one);
- const __m128i avg2 = _mm_subs_epu8(avg1, lsb);
- const __m128i efgh = _mm_avg_epu8(avg2, XABCD);
- WebPUint32ToMem(dst + 0 * BPS, _mm_cvtsi128_si32( abcd ));
- WebPUint32ToMem(dst + 1 * BPS, _mm_cvtsi128_si32( efgh ));
- WebPUint32ToMem(dst + 2 * BPS, _mm_cvtsi128_si32(_mm_slli_si128(abcd, 1)));
- WebPUint32ToMem(dst + 3 * BPS, _mm_cvtsi128_si32(_mm_slli_si128(efgh, 1)));
-
- // these two are hard to implement in SSE2, so we keep the C-version:
- DST(0, 2) = AVG3(J, I, X);
- DST(0, 3) = AVG3(K, J, I);
-}
-
-static void VL4_SSE2(uint8_t* dst) { // Vertical-Left
- const __m128i one = _mm_set1_epi8(1);
- const __m128i ABCDEFGH = _mm_loadl_epi64((__m128i*)(dst - BPS));
- const __m128i BCDEFGH_ = _mm_srli_si128(ABCDEFGH, 1);
- const __m128i CDEFGH__ = _mm_srli_si128(ABCDEFGH, 2);
- const __m128i avg1 = _mm_avg_epu8(ABCDEFGH, BCDEFGH_);
- const __m128i avg2 = _mm_avg_epu8(CDEFGH__, BCDEFGH_);
- const __m128i avg3 = _mm_avg_epu8(avg1, avg2);
- const __m128i lsb1 = _mm_and_si128(_mm_xor_si128(avg1, avg2), one);
- const __m128i ab = _mm_xor_si128(ABCDEFGH, BCDEFGH_);
- const __m128i bc = _mm_xor_si128(CDEFGH__, BCDEFGH_);
- const __m128i abbc = _mm_or_si128(ab, bc);
- const __m128i lsb2 = _mm_and_si128(abbc, lsb1);
- const __m128i avg4 = _mm_subs_epu8(avg3, lsb2);
- const uint32_t extra_out = _mm_cvtsi128_si32(_mm_srli_si128(avg4, 4));
- WebPUint32ToMem(dst + 0 * BPS, _mm_cvtsi128_si32( avg1 ));
- WebPUint32ToMem(dst + 1 * BPS, _mm_cvtsi128_si32( avg4 ));
- WebPUint32ToMem(dst + 2 * BPS, _mm_cvtsi128_si32(_mm_srli_si128(avg1, 1)));
- WebPUint32ToMem(dst + 3 * BPS, _mm_cvtsi128_si32(_mm_srli_si128(avg4, 1)));
-
- // these two are hard to get and irregular
- DST(3, 2) = (extra_out >> 0) & 0xff;
- DST(3, 3) = (extra_out >> 8) & 0xff;
-}
-
-static void RD4_SSE2(uint8_t* dst) { // Down-right
- const __m128i one = _mm_set1_epi8(1);
- const __m128i XABCD = _mm_loadl_epi64((__m128i*)(dst - BPS - 1));
- const __m128i ____XABCD = _mm_slli_si128(XABCD, 4);
- const uint32_t I = dst[-1 + 0 * BPS];
- const uint32_t J = dst[-1 + 1 * BPS];
- const uint32_t K = dst[-1 + 2 * BPS];
- const uint32_t L = dst[-1 + 3 * BPS];
- const __m128i LKJI_____ =
- _mm_cvtsi32_si128(L | (K << 8) | (J << 16) | (I << 24));
- const __m128i LKJIXABCD = _mm_or_si128(LKJI_____, ____XABCD);
- const __m128i KJIXABCD_ = _mm_srli_si128(LKJIXABCD, 1);
- const __m128i JIXABCD__ = _mm_srli_si128(LKJIXABCD, 2);
- const __m128i avg1 = _mm_avg_epu8(JIXABCD__, LKJIXABCD);
- const __m128i lsb = _mm_and_si128(_mm_xor_si128(JIXABCD__, LKJIXABCD), one);
- const __m128i avg2 = _mm_subs_epu8(avg1, lsb);
- const __m128i abcdefg = _mm_avg_epu8(avg2, KJIXABCD_);
- WebPUint32ToMem(dst + 3 * BPS, _mm_cvtsi128_si32( abcdefg ));
- WebPUint32ToMem(dst + 2 * BPS, _mm_cvtsi128_si32(_mm_srli_si128(abcdefg, 1)));
- WebPUint32ToMem(dst + 1 * BPS, _mm_cvtsi128_si32(_mm_srli_si128(abcdefg, 2)));
- WebPUint32ToMem(dst + 0 * BPS, _mm_cvtsi128_si32(_mm_srli_si128(abcdefg, 3)));
-}
-
-#undef DST
-#undef AVG3
-
-//------------------------------------------------------------------------------
-// Luma 16x16
-
-static WEBP_INLINE void TrueMotion_SSE2(uint8_t* dst, int size) {
- const uint8_t* top = dst - BPS;
- const __m128i zero = _mm_setzero_si128();
- int y;
- if (size == 4) {
- const __m128i top_values = _mm_cvtsi32_si128(WebPMemToUint32(top));
- const __m128i top_base = _mm_unpacklo_epi8(top_values, zero);
- for (y = 0; y < 4; ++y, dst += BPS) {
- const int val = dst[-1] - top[-1];
- const __m128i base = _mm_set1_epi16(val);
- const __m128i out = _mm_packus_epi16(_mm_add_epi16(base, top_base), zero);
- WebPUint32ToMem(dst, _mm_cvtsi128_si32(out));
- }
- } else if (size == 8) {
- const __m128i top_values = _mm_loadl_epi64((const __m128i*)top);
- const __m128i top_base = _mm_unpacklo_epi8(top_values, zero);
- for (y = 0; y < 8; ++y, dst += BPS) {
- const int val = dst[-1] - top[-1];
- const __m128i base = _mm_set1_epi16(val);
- const __m128i out = _mm_packus_epi16(_mm_add_epi16(base, top_base), zero);
- _mm_storel_epi64((__m128i*)dst, out);
- }
- } else {
- const __m128i top_values = _mm_loadu_si128((const __m128i*)top);
- const __m128i top_base_0 = _mm_unpacklo_epi8(top_values, zero);
- const __m128i top_base_1 = _mm_unpackhi_epi8(top_values, zero);
- for (y = 0; y < 16; ++y, dst += BPS) {
- const int val = dst[-1] - top[-1];
- const __m128i base = _mm_set1_epi16(val);
- const __m128i out_0 = _mm_add_epi16(base, top_base_0);
- const __m128i out_1 = _mm_add_epi16(base, top_base_1);
- const __m128i out = _mm_packus_epi16(out_0, out_1);
- _mm_storeu_si128((__m128i*)dst, out);
- }
- }
-}
-
-static void TM4_SSE2(uint8_t* dst) { TrueMotion_SSE2(dst, 4); }
-static void TM8uv_SSE2(uint8_t* dst) { TrueMotion_SSE2(dst, 8); }
-static void TM16_SSE2(uint8_t* dst) { TrueMotion_SSE2(dst, 16); }
-
-static void VE16_SSE2(uint8_t* dst) {
- const __m128i top = _mm_loadu_si128((const __m128i*)(dst - BPS));
- int j;
- for (j = 0; j < 16; ++j) {
- _mm_storeu_si128((__m128i*)(dst + j * BPS), top);
- }
-}
-
-static void HE16_SSE2(uint8_t* dst) { // horizontal
- int j;
- for (j = 16; j > 0; --j) {
- const __m128i values = _mm_set1_epi8(dst[-1]);
- _mm_storeu_si128((__m128i*)dst, values);
- dst += BPS;
- }
-}
-
-static WEBP_INLINE void Put16_SSE2(uint8_t v, uint8_t* dst) {
- int j;
- const __m128i values = _mm_set1_epi8(v);
- for (j = 0; j < 16; ++j) {
- _mm_storeu_si128((__m128i*)(dst + j * BPS), values);
- }
-}
-
-static void DC16_SSE2(uint8_t* dst) { // DC
- const __m128i zero = _mm_setzero_si128();
- const __m128i top = _mm_loadu_si128((const __m128i*)(dst - BPS));
- const __m128i sad8x2 = _mm_sad_epu8(top, zero);
- // sum the two sads: sad8x2[0:1] + sad8x2[8:9]
- const __m128i sum = _mm_add_epi16(sad8x2, _mm_shuffle_epi32(sad8x2, 2));
- int left = 0;
- int j;
- for (j = 0; j < 16; ++j) {
- left += dst[-1 + j * BPS];
- }
- {
- const int DC = _mm_cvtsi128_si32(sum) + left + 16;
- Put16_SSE2(DC >> 5, dst);
- }
-}
-
-static void DC16NoTop_SSE2(uint8_t* dst) { // DC with top samples unavailable
- int DC = 8;
- int j;
- for (j = 0; j < 16; ++j) {
- DC += dst[-1 + j * BPS];
- }
- Put16_SSE2(DC >> 4, dst);
-}
-
-static void DC16NoLeft_SSE2(uint8_t* dst) { // DC with left samples unavailable
- const __m128i zero = _mm_setzero_si128();
- const __m128i top = _mm_loadu_si128((const __m128i*)(dst - BPS));
- const __m128i sad8x2 = _mm_sad_epu8(top, zero);
- // sum the two sads: sad8x2[0:1] + sad8x2[8:9]
- const __m128i sum = _mm_add_epi16(sad8x2, _mm_shuffle_epi32(sad8x2, 2));
- const int DC = _mm_cvtsi128_si32(sum) + 8;
- Put16_SSE2(DC >> 4, dst);
-}
-
-static void DC16NoTopLeft_SSE2(uint8_t* dst) { // DC with no top & left samples
- Put16_SSE2(0x80, dst);
-}
-
-//------------------------------------------------------------------------------
-// Chroma
-
-static void VE8uv_SSE2(uint8_t* dst) { // vertical
- int j;
- const __m128i top = _mm_loadl_epi64((const __m128i*)(dst - BPS));
- for (j = 0; j < 8; ++j) {
- _mm_storel_epi64((__m128i*)(dst + j * BPS), top);
- }
-}
-
-// helper for chroma-DC predictions
-static WEBP_INLINE void Put8x8uv_SSE2(uint8_t v, uint8_t* dst) {
- int j;
- const __m128i values = _mm_set1_epi8(v);
- for (j = 0; j < 8; ++j) {
- _mm_storel_epi64((__m128i*)(dst + j * BPS), values);
- }
-}
-
-static void DC8uv_SSE2(uint8_t* dst) { // DC
- const __m128i zero = _mm_setzero_si128();
- const __m128i top = _mm_loadl_epi64((const __m128i*)(dst - BPS));
- const __m128i sum = _mm_sad_epu8(top, zero);
- int left = 0;
- int j;
- for (j = 0; j < 8; ++j) {
- left += dst[-1 + j * BPS];
- }
- {
- const int DC = _mm_cvtsi128_si32(sum) + left + 8;
- Put8x8uv_SSE2(DC >> 4, dst);
- }
-}
-
-static void DC8uvNoLeft_SSE2(uint8_t* dst) { // DC with no left samples
- const __m128i zero = _mm_setzero_si128();
- const __m128i top = _mm_loadl_epi64((const __m128i*)(dst - BPS));
- const __m128i sum = _mm_sad_epu8(top, zero);
- const int DC = _mm_cvtsi128_si32(sum) + 4;
- Put8x8uv_SSE2(DC >> 3, dst);
-}
-
-static void DC8uvNoTop_SSE2(uint8_t* dst) { // DC with no top samples
- int dc0 = 4;
- int i;
- for (i = 0; i < 8; ++i) {
- dc0 += dst[-1 + i * BPS];
- }
- Put8x8uv_SSE2(dc0 >> 3, dst);
-}
-
-static void DC8uvNoTopLeft_SSE2(uint8_t* dst) { // DC with nothing
- Put8x8uv_SSE2(0x80, dst);
-}
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void VP8DspInitSSE2(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void VP8DspInitSSE2(void) {
- VP8Transform = Transform_SSE2;
-#if (USE_TRANSFORM_AC3 == 1)
- VP8TransformAC3 = TransformAC3_SSE2;
-#endif
-
- VP8VFilter16 = VFilter16_SSE2;
- VP8HFilter16 = HFilter16_SSE2;
- VP8VFilter8 = VFilter8_SSE2;
- VP8HFilter8 = HFilter8_SSE2;
- VP8VFilter16i = VFilter16i_SSE2;
- VP8HFilter16i = HFilter16i_SSE2;
- VP8VFilter8i = VFilter8i_SSE2;
- VP8HFilter8i = HFilter8i_SSE2;
-
- VP8SimpleVFilter16 = SimpleVFilter16_SSE2;
- VP8SimpleHFilter16 = SimpleHFilter16_SSE2;
- VP8SimpleVFilter16i = SimpleVFilter16i_SSE2;
- VP8SimpleHFilter16i = SimpleHFilter16i_SSE2;
-
- VP8PredLuma4[1] = TM4_SSE2;
- VP8PredLuma4[2] = VE4_SSE2;
- VP8PredLuma4[4] = RD4_SSE2;
- VP8PredLuma4[5] = VR4_SSE2;
- VP8PredLuma4[6] = LD4_SSE2;
- VP8PredLuma4[7] = VL4_SSE2;
-
- VP8PredLuma16[0] = DC16_SSE2;
- VP8PredLuma16[1] = TM16_SSE2;
- VP8PredLuma16[2] = VE16_SSE2;
- VP8PredLuma16[3] = HE16_SSE2;
- VP8PredLuma16[4] = DC16NoTop_SSE2;
- VP8PredLuma16[5] = DC16NoLeft_SSE2;
- VP8PredLuma16[6] = DC16NoTopLeft_SSE2;
-
- VP8PredChroma8[0] = DC8uv_SSE2;
- VP8PredChroma8[1] = TM8uv_SSE2;
- VP8PredChroma8[2] = VE8uv_SSE2;
- VP8PredChroma8[4] = DC8uvNoTop_SSE2;
- VP8PredChroma8[5] = DC8uvNoLeft_SSE2;
- VP8PredChroma8[6] = DC8uvNoTopLeft_SSE2;
-}
-
-#else // !WEBP_USE_SSE2
-
-WEBP_DSP_INIT_STUB(VP8DspInitSSE2)
-
-#endif // WEBP_USE_SSE2
diff --git a/contrib/libs/libwebp/dsp/dec_sse41.c b/contrib/libs/libwebp/dsp/dec_sse41.c
deleted file mode 100644
index bcb35a359b..0000000000
--- a/contrib/libs/libwebp/dsp/dec_sse41.c
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright 2015 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// SSE4 version of some decoding functions.
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_SSE41)
-
-#include <smmintrin.h>
-#include "../dec/vp8i_dec.h"
-#include "../utils/utils.h"
-
-static void HE16_SSE41(uint8_t* dst) { // horizontal
- int j;
- const __m128i kShuffle3 = _mm_set1_epi8(3);
- for (j = 16; j > 0; --j) {
- const __m128i in = _mm_cvtsi32_si128(WebPMemToUint32(dst - 4));
- const __m128i values = _mm_shuffle_epi8(in, kShuffle3);
- _mm_storeu_si128((__m128i*)dst, values);
- dst += BPS;
- }
-}
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void VP8DspInitSSE41(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void VP8DspInitSSE41(void) {
- VP8PredLuma16[3] = HE16_SSE41;
-}
-
-#else // !WEBP_USE_SSE41
-
-WEBP_DSP_INIT_STUB(VP8DspInitSSE41)
-
-#endif // WEBP_USE_SSE41
diff --git a/contrib/libs/libwebp/dsp/dsp.h b/contrib/libs/libwebp/dsp/dsp.h
deleted file mode 100644
index ce1679ea53..0000000000
--- a/contrib/libs/libwebp/dsp/dsp.h
+++ /dev/null
@@ -1,731 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Speed-critical functions.
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#ifndef WEBP_DSP_DSP_H_
-#define WEBP_DSP_DSP_H_
-
-#ifdef HAVE_CONFIG_H
-#include "../webp/config.h"
-#endif
-
-#include "../webp/types.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define BPS 32 // this is the common stride for enc/dec
-
-//------------------------------------------------------------------------------
-// WEBP_RESTRICT
-
-// Declares a pointer with the restrict type qualifier if available.
-// This allows code to hint to the compiler that only this pointer references a
-// particular object or memory region within the scope of the block in which it
-// is declared. This may allow for improved optimizations due to the lack of
-// pointer aliasing. See also:
-// https://en.cppreference.com/w/c/language/restrict
-#if defined(__GNUC__)
-#define WEBP_RESTRICT __restrict__
-#elif defined(_MSC_VER)
-#define WEBP_RESTRICT __restrict
-#else
-#define WEBP_RESTRICT
-#endif
-
-//------------------------------------------------------------------------------
-// CPU detection
-
-#if defined(__GNUC__)
-# define LOCAL_GCC_VERSION ((__GNUC__ << 8) | __GNUC_MINOR__)
-# define LOCAL_GCC_PREREQ(maj, min) \
- (LOCAL_GCC_VERSION >= (((maj) << 8) | (min)))
-#else
-# define LOCAL_GCC_VERSION 0
-# define LOCAL_GCC_PREREQ(maj, min) 0
-#endif
-
-#if defined(__clang__)
-# define LOCAL_CLANG_VERSION ((__clang_major__ << 8) | __clang_minor__)
-# define LOCAL_CLANG_PREREQ(maj, min) \
- (LOCAL_CLANG_VERSION >= (((maj) << 8) | (min)))
-#else
-# define LOCAL_CLANG_VERSION 0
-# define LOCAL_CLANG_PREREQ(maj, min) 0
-#endif
-
-#ifndef __has_builtin
-# define __has_builtin(x) 0
-#endif
-
-#if !defined(HAVE_CONFIG_H)
-#if defined(_MSC_VER) && _MSC_VER > 1310 && \
- (defined(_M_X64) || defined(_M_IX86))
-#define WEBP_MSC_SSE2 // Visual C++ SSE2 targets
-#endif
-
-#if defined(_MSC_VER) && _MSC_VER >= 1500 && \
- (defined(_M_X64) || defined(_M_IX86))
-#define WEBP_MSC_SSE41 // Visual C++ SSE4.1 targets
-#endif
-#endif
-
-// WEBP_HAVE_* are used to indicate the presence of the instruction set in dsp
-// files without intrinsics, allowing the corresponding Init() to be called.
-// Files containing intrinsics will need to be built targeting the instruction
-// set so should succeed on one of the earlier tests.
-#if (defined(__SSE2__) || defined(WEBP_MSC_SSE2)) && \
- (!defined(HAVE_CONFIG_H) || defined(WEBP_HAVE_SSE2))
-#define WEBP_USE_SSE2
-#endif
-
-#if defined(WEBP_USE_SSE2) && !defined(WEBP_HAVE_SSE2)
-#define WEBP_HAVE_SSE2
-#endif
-
-#if (defined(__SSE4_1__) || defined(WEBP_MSC_SSE41)) && \
- (!defined(HAVE_CONFIG_H) || defined(WEBP_HAVE_SSE41))
-#define WEBP_USE_SSE41
-#endif
-
-#if defined(WEBP_USE_SSE41) && !defined(WEBP_HAVE_SSE41)
-#define WEBP_HAVE_SSE41
-#endif
-
-#undef WEBP_MSC_SSE41
-#undef WEBP_MSC_SSE2
-
-// The intrinsics currently cause compiler errors with arm-nacl-gcc and the
-// inline assembly would need to be modified for use with Native Client.
-#if ((defined(__ARM_NEON__) || defined(__aarch64__)) && \
- (!defined(HAVE_CONFIG_H) || defined(WEBP_HAVE_NEON))) && \
- !defined(__native_client__)
-#define WEBP_USE_NEON
-#endif
-
-#if !defined(WEBP_USE_NEON) && defined(__ANDROID__) && \
- defined(__ARM_ARCH_7A__) && defined(HAVE_CPU_FEATURES_H)
-#define WEBP_ANDROID_NEON // Android targets that may have NEON
-#define WEBP_USE_NEON
-#endif
-
-// Note: ARM64 is supported in Visual Studio 2017, but requires the direct
-// inclusion of arm64_neon.h; Visual Studio 2019 includes this file in
-// arm_neon.h.
-#if defined(_MSC_VER) && \
- ((_MSC_VER >= 1700 && defined(_M_ARM)) || \
- (_MSC_VER >= 1920 && defined(_M_ARM64)))
-#define WEBP_USE_NEON
-#define WEBP_USE_INTRINSICS
-#endif
-
-#if defined(WEBP_USE_NEON) && !defined(WEBP_HAVE_NEON)
-#define WEBP_HAVE_NEON
-#endif
-
-#if defined(__mips__) && !defined(__mips64) && \
- defined(__mips_isa_rev) && (__mips_isa_rev >= 1) && (__mips_isa_rev < 6)
-#define WEBP_USE_MIPS32
-#if (__mips_isa_rev >= 2)
-#define WEBP_USE_MIPS32_R2
-#if defined(__mips_dspr2) || (defined(__mips_dsp_rev) && __mips_dsp_rev >= 2)
-#define WEBP_USE_MIPS_DSP_R2
-#endif
-#endif
-#endif
-
-#if defined(__mips_msa) && defined(__mips_isa_rev) && (__mips_isa_rev >= 5)
-#define WEBP_USE_MSA
-#endif
-
-#ifndef WEBP_DSP_OMIT_C_CODE
-#define WEBP_DSP_OMIT_C_CODE 1
-#endif
-
-#if defined(WEBP_USE_NEON) && WEBP_DSP_OMIT_C_CODE
-#define WEBP_NEON_OMIT_C_CODE 1
-#else
-#define WEBP_NEON_OMIT_C_CODE 0
-#endif
-
-#if !(LOCAL_CLANG_PREREQ(3,8) || LOCAL_GCC_PREREQ(4,8) || defined(__aarch64__))
-#define WEBP_NEON_WORK_AROUND_GCC 1
-#else
-#define WEBP_NEON_WORK_AROUND_GCC 0
-#endif
-
-// This macro prevents thread_sanitizer from reporting known concurrent writes.
-#define WEBP_TSAN_IGNORE_FUNCTION
-#if defined(__has_feature)
-#if __has_feature(thread_sanitizer)
-#undef WEBP_TSAN_IGNORE_FUNCTION
-#define WEBP_TSAN_IGNORE_FUNCTION __attribute__((no_sanitize_thread))
-#endif
-#endif
-
-#if defined(WEBP_USE_THREAD) && !defined(_WIN32)
-#include <pthread.h> // NOLINT
-
-#define WEBP_DSP_INIT(func) do { \
- static volatile VP8CPUInfo func ## _last_cpuinfo_used = \
- (VP8CPUInfo)&func ## _last_cpuinfo_used; \
- static pthread_mutex_t func ## _lock = PTHREAD_MUTEX_INITIALIZER; \
- if (pthread_mutex_lock(&func ## _lock)) break; \
- if (func ## _last_cpuinfo_used != VP8GetCPUInfo) func(); \
- func ## _last_cpuinfo_used = VP8GetCPUInfo; \
- (void)pthread_mutex_unlock(&func ## _lock); \
-} while (0)
-#else // !(defined(WEBP_USE_THREAD) && !defined(_WIN32))
-#define WEBP_DSP_INIT(func) do { \
- static volatile VP8CPUInfo func ## _last_cpuinfo_used = \
- (VP8CPUInfo)&func ## _last_cpuinfo_used; \
- if (func ## _last_cpuinfo_used == VP8GetCPUInfo) break; \
- func(); \
- func ## _last_cpuinfo_used = VP8GetCPUInfo; \
-} while (0)
-#endif // defined(WEBP_USE_THREAD) && !defined(_WIN32)
-
-// Defines an Init + helper function that control multiple initialization of
-// function pointers / tables.
-/* Usage:
- WEBP_DSP_INIT_FUNC(InitFunc) {
- ...function body
- }
-*/
-#define WEBP_DSP_INIT_FUNC(name) \
- static WEBP_TSAN_IGNORE_FUNCTION void name ## _body(void); \
- WEBP_TSAN_IGNORE_FUNCTION void name(void) { \
- WEBP_DSP_INIT(name ## _body); \
- } \
- static WEBP_TSAN_IGNORE_FUNCTION void name ## _body(void)
-
-#define WEBP_UBSAN_IGNORE_UNDEF
-#define WEBP_UBSAN_IGNORE_UNSIGNED_OVERFLOW
-#if defined(__clang__) && defined(__has_attribute)
-#if __has_attribute(no_sanitize)
-// This macro prevents the undefined behavior sanitizer from reporting
-// failures. This is only meant to silence unaligned loads on platforms that
-// are known to support them.
-#undef WEBP_UBSAN_IGNORE_UNDEF
-#define WEBP_UBSAN_IGNORE_UNDEF \
- __attribute__((no_sanitize("undefined")))
-
-// This macro prevents the undefined behavior sanitizer from reporting
-// failures related to unsigned integer overflows. This is only meant to
-// silence cases where this well defined behavior is expected.
-#undef WEBP_UBSAN_IGNORE_UNSIGNED_OVERFLOW
-#define WEBP_UBSAN_IGNORE_UNSIGNED_OVERFLOW \
- __attribute__((no_sanitize("unsigned-integer-overflow")))
-#endif
-#endif
-
-// If 'ptr' is NULL, returns NULL. Otherwise returns 'ptr + off'.
-// Prevents undefined behavior sanitizer nullptr-with-nonzero-offset warning.
-#if !defined(WEBP_OFFSET_PTR)
-#define WEBP_OFFSET_PTR(ptr, off) (((ptr) == NULL) ? NULL : ((ptr) + (off)))
-#endif
-
-// Regularize the definition of WEBP_SWAP_16BIT_CSP (backward compatibility)
-#if !defined(WEBP_SWAP_16BIT_CSP)
-#define WEBP_SWAP_16BIT_CSP 0
-#endif
-
-// some endian fix (e.g.: mips-gcc doesn't define __BIG_ENDIAN__)
-#if !defined(WORDS_BIGENDIAN) && \
- (defined(__BIG_ENDIAN__) || defined(_M_PPC) || \
- (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)))
-#define WORDS_BIGENDIAN
-#endif
-
-typedef enum {
- kSSE2,
- kSSE3,
- kSlowSSSE3, // special feature for slow SSSE3 architectures
- kSSE4_1,
- kAVX,
- kAVX2,
- kNEON,
- kMIPS32,
- kMIPSdspR2,
- kMSA
-} CPUFeature;
-// returns true if the CPU supports the feature.
-typedef int (*VP8CPUInfo)(CPUFeature feature);
-WEBP_EXTERN VP8CPUInfo VP8GetCPUInfo;
-
-//------------------------------------------------------------------------------
-// Init stub generator
-
-// Defines an init function stub to ensure each module exposes a symbol,
-// avoiding a compiler warning.
-#define WEBP_DSP_INIT_STUB(func) \
- extern void func(void); \
- void func(void) {}
-
-//------------------------------------------------------------------------------
-// Encoding
-
-// Transforms
-// VP8Idct: Does one of two inverse transforms. If do_two is set, the transforms
-// will be done for (ref, in, dst) and (ref + 4, in + 16, dst + 4).
-typedef void (*VP8Idct)(const uint8_t* ref, const int16_t* in, uint8_t* dst,
- int do_two);
-typedef void (*VP8Fdct)(const uint8_t* src, const uint8_t* ref, int16_t* out);
-typedef void (*VP8WHT)(const int16_t* in, int16_t* out);
-extern VP8Idct VP8ITransform;
-extern VP8Fdct VP8FTransform;
-extern VP8Fdct VP8FTransform2; // performs two transforms at a time
-extern VP8WHT VP8FTransformWHT;
-// Predictions
-// *dst is the destination block. *top and *left can be NULL.
-typedef void (*VP8IntraPreds)(uint8_t* dst, const uint8_t* left,
- const uint8_t* top);
-typedef void (*VP8Intra4Preds)(uint8_t* dst, const uint8_t* top);
-extern VP8Intra4Preds VP8EncPredLuma4;
-extern VP8IntraPreds VP8EncPredLuma16;
-extern VP8IntraPreds VP8EncPredChroma8;
-
-typedef int (*VP8Metric)(const uint8_t* pix, const uint8_t* ref);
-extern VP8Metric VP8SSE16x16, VP8SSE16x8, VP8SSE8x8, VP8SSE4x4;
-typedef int (*VP8WMetric)(const uint8_t* pix, const uint8_t* ref,
- const uint16_t* const weights);
-// The weights for VP8TDisto4x4 and VP8TDisto16x16 contain a row-major
-// 4 by 4 symmetric matrix.
-extern VP8WMetric VP8TDisto4x4, VP8TDisto16x16;
-
-// Compute the average (DC) of four 4x4 blocks.
-// Each sub-4x4 block #i sum is stored in dc[i].
-typedef void (*VP8MeanMetric)(const uint8_t* ref, uint32_t dc[4]);
-extern VP8MeanMetric VP8Mean16x4;
-
-typedef void (*VP8BlockCopy)(const uint8_t* src, uint8_t* dst);
-extern VP8BlockCopy VP8Copy4x4;
-extern VP8BlockCopy VP8Copy16x8;
-// Quantization
-struct VP8Matrix; // forward declaration
-typedef int (*VP8QuantizeBlock)(int16_t in[16], int16_t out[16],
- const struct VP8Matrix* const mtx);
-// Same as VP8QuantizeBlock, but quantizes two consecutive blocks.
-typedef int (*VP8Quantize2Blocks)(int16_t in[32], int16_t out[32],
- const struct VP8Matrix* const mtx);
-
-extern VP8QuantizeBlock VP8EncQuantizeBlock;
-extern VP8Quantize2Blocks VP8EncQuantize2Blocks;
-
-// specific to 2nd transform:
-typedef int (*VP8QuantizeBlockWHT)(int16_t in[16], int16_t out[16],
- const struct VP8Matrix* const mtx);
-extern VP8QuantizeBlockWHT VP8EncQuantizeBlockWHT;
-
-extern const int VP8DspScan[16 + 4 + 4];
-
-// Collect histogram for susceptibility calculation.
-#define MAX_COEFF_THRESH 31 // size of histogram used by CollectHistogram.
-typedef struct {
- // We only need to store max_value and last_non_zero, not the distribution.
- int max_value;
- int last_non_zero;
-} VP8Histogram;
-typedef void (*VP8CHisto)(const uint8_t* ref, const uint8_t* pred,
- int start_block, int end_block,
- VP8Histogram* const histo);
-extern VP8CHisto VP8CollectHistogram;
-// General-purpose util function to help VP8CollectHistogram().
-void VP8SetHistogramData(const int distribution[MAX_COEFF_THRESH + 1],
- VP8Histogram* const histo);
-
-// must be called before using any of the above
-void VP8EncDspInit(void);
-
-//------------------------------------------------------------------------------
-// cost functions (encoding)
-
-extern const uint16_t VP8EntropyCost[256]; // 8bit fixed-point log(p)
-// approximate cost per level:
-extern const uint16_t VP8LevelFixedCosts[2047 /*MAX_LEVEL*/ + 1];
-extern const uint8_t VP8EncBands[16 + 1];
-
-struct VP8Residual;
-typedef void (*VP8SetResidualCoeffsFunc)(const int16_t* const coeffs,
- struct VP8Residual* const res);
-extern VP8SetResidualCoeffsFunc VP8SetResidualCoeffs;
-
-// Cost calculation function.
-typedef int (*VP8GetResidualCostFunc)(int ctx0,
- const struct VP8Residual* const res);
-extern VP8GetResidualCostFunc VP8GetResidualCost;
-
-// must be called before anything using the above
-void VP8EncDspCostInit(void);
-
-//------------------------------------------------------------------------------
-// SSIM / PSNR utils
-
-// struct for accumulating statistical moments
-typedef struct {
- uint32_t w; // sum(w_i) : sum of weights
- uint32_t xm, ym; // sum(w_i * x_i), sum(w_i * y_i)
- uint32_t xxm, xym, yym; // sum(w_i * x_i * x_i), etc.
-} VP8DistoStats;
-
-// Compute the final SSIM value
-// The non-clipped version assumes stats->w = (2 * VP8_SSIM_KERNEL + 1)^2.
-double VP8SSIMFromStats(const VP8DistoStats* const stats);
-double VP8SSIMFromStatsClipped(const VP8DistoStats* const stats);
-
-#define VP8_SSIM_KERNEL 3 // total size of the kernel: 2 * VP8_SSIM_KERNEL + 1
-typedef double (*VP8SSIMGetClippedFunc)(const uint8_t* src1, int stride1,
- const uint8_t* src2, int stride2,
- int xo, int yo, // center position
- int W, int H); // plane dimension
-
-#if !defined(WEBP_REDUCE_SIZE)
-// This version is called with the guarantee that you can load 8 bytes and
-// 8 rows at offset src1 and src2
-typedef double (*VP8SSIMGetFunc)(const uint8_t* src1, int stride1,
- const uint8_t* src2, int stride2);
-
-extern VP8SSIMGetFunc VP8SSIMGet; // unclipped / unchecked
-extern VP8SSIMGetClippedFunc VP8SSIMGetClipped; // with clipping
-#endif
-
-#if !defined(WEBP_DISABLE_STATS)
-typedef uint32_t (*VP8AccumulateSSEFunc)(const uint8_t* src1,
- const uint8_t* src2, int len);
-extern VP8AccumulateSSEFunc VP8AccumulateSSE;
-#endif
-
-// must be called before using any of the above directly
-void VP8SSIMDspInit(void);
-
-//------------------------------------------------------------------------------
-// Decoding
-
-typedef void (*VP8DecIdct)(const int16_t* coeffs, uint8_t* dst);
-// when doing two transforms, coeffs is actually int16_t[2][16].
-typedef void (*VP8DecIdct2)(const int16_t* coeffs, uint8_t* dst, int do_two);
-extern VP8DecIdct2 VP8Transform;
-extern VP8DecIdct VP8TransformAC3;
-extern VP8DecIdct VP8TransformUV;
-extern VP8DecIdct VP8TransformDC;
-extern VP8DecIdct VP8TransformDCUV;
-extern VP8WHT VP8TransformWHT;
-
-// *dst is the destination block, with stride BPS. Boundary samples are
-// assumed accessible when needed.
-typedef void (*VP8PredFunc)(uint8_t* dst);
-extern VP8PredFunc VP8PredLuma16[/* NUM_B_DC_MODES */];
-extern VP8PredFunc VP8PredChroma8[/* NUM_B_DC_MODES */];
-extern VP8PredFunc VP8PredLuma4[/* NUM_BMODES */];
-
-// clipping tables (for filtering)
-extern const int8_t* const VP8ksclip1; // clips [-1020, 1020] to [-128, 127]
-extern const int8_t* const VP8ksclip2; // clips [-112, 112] to [-16, 15]
-extern const uint8_t* const VP8kclip1; // clips [-255,511] to [0,255]
-extern const uint8_t* const VP8kabs0; // abs(x) for x in [-255,255]
-// must be called first
-void VP8InitClipTables(void);
-
-// simple filter (only for luma)
-typedef void (*VP8SimpleFilterFunc)(uint8_t* p, int stride, int thresh);
-extern VP8SimpleFilterFunc VP8SimpleVFilter16;
-extern VP8SimpleFilterFunc VP8SimpleHFilter16;
-extern VP8SimpleFilterFunc VP8SimpleVFilter16i; // filter 3 inner edges
-extern VP8SimpleFilterFunc VP8SimpleHFilter16i;
-
-// regular filter (on both macroblock edges and inner edges)
-typedef void (*VP8LumaFilterFunc)(uint8_t* luma, int stride,
- int thresh, int ithresh, int hev_t);
-typedef void (*VP8ChromaFilterFunc)(uint8_t* u, uint8_t* v, int stride,
- int thresh, int ithresh, int hev_t);
-// on outer edge
-extern VP8LumaFilterFunc VP8VFilter16;
-extern VP8LumaFilterFunc VP8HFilter16;
-extern VP8ChromaFilterFunc VP8VFilter8;
-extern VP8ChromaFilterFunc VP8HFilter8;
-
-// on inner edge
-extern VP8LumaFilterFunc VP8VFilter16i; // filtering 3 inner edges altogether
-extern VP8LumaFilterFunc VP8HFilter16i;
-extern VP8ChromaFilterFunc VP8VFilter8i; // filtering u and v altogether
-extern VP8ChromaFilterFunc VP8HFilter8i;
-
-// Dithering. Combines dithering values (centered around 128) with dst[],
-// according to: dst[] = clip(dst[] + (((dither[]-128) + 8) >> 4)
-#define VP8_DITHER_DESCALE 4
-#define VP8_DITHER_DESCALE_ROUNDER (1 << (VP8_DITHER_DESCALE - 1))
-#define VP8_DITHER_AMP_BITS 7
-#define VP8_DITHER_AMP_CENTER (1 << VP8_DITHER_AMP_BITS)
-extern void (*VP8DitherCombine8x8)(const uint8_t* dither, uint8_t* dst,
- int dst_stride);
-
-// must be called before anything using the above
-void VP8DspInit(void);
-
-//------------------------------------------------------------------------------
-// WebP I/O
-
-#define FANCY_UPSAMPLING // undefined to remove fancy upsampling support
-
-// Convert a pair of y/u/v lines together to the output rgb/a colorspace.
-// bottom_y can be NULL if only one line of output is needed (at top/bottom).
-typedef void (*WebPUpsampleLinePairFunc)(
- const uint8_t* top_y, const uint8_t* bottom_y,
- const uint8_t* top_u, const uint8_t* top_v,
- const uint8_t* cur_u, const uint8_t* cur_v,
- uint8_t* top_dst, uint8_t* bottom_dst, int len);
-
-#ifdef FANCY_UPSAMPLING
-
-// Fancy upsampling functions to convert YUV to RGB(A) modes
-extern WebPUpsampleLinePairFunc WebPUpsamplers[/* MODE_LAST */];
-
-#endif // FANCY_UPSAMPLING
-
-// Per-row point-sampling methods.
-typedef void (*WebPSamplerRowFunc)(const uint8_t* y,
- const uint8_t* u, const uint8_t* v,
- uint8_t* dst, int len);
-// Generic function to apply 'WebPSamplerRowFunc' to the whole plane:
-void WebPSamplerProcessPlane(const uint8_t* y, int y_stride,
- const uint8_t* u, const uint8_t* v, int uv_stride,
- uint8_t* dst, int dst_stride,
- int width, int height, WebPSamplerRowFunc func);
-
-// Sampling functions to convert rows of YUV to RGB(A)
-extern WebPSamplerRowFunc WebPSamplers[/* MODE_LAST */];
-
-// General function for converting two lines of ARGB or RGBA.
-// 'alpha_is_last' should be true if 0xff000000 is stored in memory as
-// as 0x00, 0x00, 0x00, 0xff (little endian).
-WebPUpsampleLinePairFunc WebPGetLinePairConverter(int alpha_is_last);
-
-// YUV444->RGB converters
-typedef void (*WebPYUV444Converter)(const uint8_t* y,
- const uint8_t* u, const uint8_t* v,
- uint8_t* dst, int len);
-
-extern WebPYUV444Converter WebPYUV444Converters[/* MODE_LAST */];
-
-// Must be called before using the WebPUpsamplers[] (and for premultiplied
-// colorspaces like rgbA, rgbA4444, etc)
-void WebPInitUpsamplers(void);
-// Must be called before using WebPSamplers[]
-void WebPInitSamplers(void);
-// Must be called before using WebPYUV444Converters[]
-void WebPInitYUV444Converters(void);
-
-//------------------------------------------------------------------------------
-// ARGB -> YUV converters
-
-// Convert ARGB samples to luma Y.
-extern void (*WebPConvertARGBToY)(const uint32_t* argb, uint8_t* y, int width);
-// Convert ARGB samples to U/V with downsampling. do_store should be '1' for
-// even lines and '0' for odd ones. 'src_width' is the original width, not
-// the U/V one.
-extern void (*WebPConvertARGBToUV)(const uint32_t* argb, uint8_t* u, uint8_t* v,
- int src_width, int do_store);
-
-// Convert a row of accumulated (four-values) of rgba32 toward U/V
-extern void (*WebPConvertRGBA32ToUV)(const uint16_t* rgb,
- uint8_t* u, uint8_t* v, int width);
-
-// Convert RGB or BGR to Y
-extern void (*WebPConvertRGB24ToY)(const uint8_t* rgb, uint8_t* y, int width);
-extern void (*WebPConvertBGR24ToY)(const uint8_t* bgr, uint8_t* y, int width);
-
-// used for plain-C fallback.
-extern void WebPConvertARGBToUV_C(const uint32_t* argb, uint8_t* u, uint8_t* v,
- int src_width, int do_store);
-extern void WebPConvertRGBA32ToUV_C(const uint16_t* rgb,
- uint8_t* u, uint8_t* v, int width);
-
-// utilities for accurate RGB->YUV conversion
-extern uint64_t (*WebPSharpYUVUpdateY)(const uint16_t* src, const uint16_t* ref,
- uint16_t* dst, int len);
-extern void (*WebPSharpYUVUpdateRGB)(const int16_t* src, const int16_t* ref,
- int16_t* dst, int len);
-extern void (*WebPSharpYUVFilterRow)(const int16_t* A, const int16_t* B,
- int len,
- const uint16_t* best_y, uint16_t* out);
-
-// Must be called before using the above.
-void WebPInitConvertARGBToYUV(void);
-
-//------------------------------------------------------------------------------
-// Rescaler
-
-struct WebPRescaler;
-
-// Import a row of data and save its contribution in the rescaler.
-// 'channel' denotes the channel number to be imported. 'Expand' corresponds to
-// the wrk->x_expand case. Otherwise, 'Shrink' is to be used.
-typedef void (*WebPRescalerImportRowFunc)(struct WebPRescaler* const wrk,
- const uint8_t* src);
-
-extern WebPRescalerImportRowFunc WebPRescalerImportRowExpand;
-extern WebPRescalerImportRowFunc WebPRescalerImportRowShrink;
-
-// Export one row (starting at x_out position) from rescaler.
-// 'Expand' corresponds to the wrk->y_expand case.
-// Otherwise 'Shrink' is to be used
-typedef void (*WebPRescalerExportRowFunc)(struct WebPRescaler* const wrk);
-extern WebPRescalerExportRowFunc WebPRescalerExportRowExpand;
-extern WebPRescalerExportRowFunc WebPRescalerExportRowShrink;
-
-// Plain-C implementation, as fall-back.
-extern void WebPRescalerImportRowExpand_C(struct WebPRescaler* const wrk,
- const uint8_t* src);
-extern void WebPRescalerImportRowShrink_C(struct WebPRescaler* const wrk,
- const uint8_t* src);
-extern void WebPRescalerExportRowExpand_C(struct WebPRescaler* const wrk);
-extern void WebPRescalerExportRowShrink_C(struct WebPRescaler* const wrk);
-
-// Main entry calls:
-extern void WebPRescalerImportRow(struct WebPRescaler* const wrk,
- const uint8_t* src);
-// Export one row (starting at x_out position) from rescaler.
-extern void WebPRescalerExportRow(struct WebPRescaler* const wrk);
-
-// Must be called first before using the above.
-void WebPRescalerDspInit(void);
-
-//------------------------------------------------------------------------------
-// Utilities for processing transparent channel.
-
-// Apply alpha pre-multiply on an rgba, bgra or argb plane of size w * h.
-// alpha_first should be 0 for argb, 1 for rgba or bgra (where alpha is last).
-extern void (*WebPApplyAlphaMultiply)(
- uint8_t* rgba, int alpha_first, int w, int h, int stride);
-
-// Same, buf specifically for RGBA4444 format
-extern void (*WebPApplyAlphaMultiply4444)(
- uint8_t* rgba4444, int w, int h, int stride);
-
-// Dispatch the values from alpha[] plane to the ARGB destination 'dst'.
-// Returns true if alpha[] plane has non-trivial values different from 0xff.
-extern int (*WebPDispatchAlpha)(const uint8_t* WEBP_RESTRICT alpha,
- int alpha_stride, int width, int height,
- uint8_t* WEBP_RESTRICT dst, int dst_stride);
-
-// Transfer packed 8b alpha[] values to green channel in dst[], zero'ing the
-// A/R/B values. 'dst_stride' is the stride for dst[] in uint32_t units.
-extern void (*WebPDispatchAlphaToGreen)(const uint8_t* WEBP_RESTRICT alpha,
- int alpha_stride, int width, int height,
- uint32_t* WEBP_RESTRICT dst,
- int dst_stride);
-
-// Extract the alpha values from 32b values in argb[] and pack them into alpha[]
-// (this is the opposite of WebPDispatchAlpha).
-// Returns true if there's only trivial 0xff alpha values.
-extern int (*WebPExtractAlpha)(const uint8_t* WEBP_RESTRICT argb,
- int argb_stride, int width, int height,
- uint8_t* WEBP_RESTRICT alpha,
- int alpha_stride);
-
-// Extract the green values from 32b values in argb[] and pack them into alpha[]
-// (this is the opposite of WebPDispatchAlphaToGreen).
-extern void (*WebPExtractGreen)(const uint32_t* WEBP_RESTRICT argb,
- uint8_t* WEBP_RESTRICT alpha, int size);
-
-// Pre-Multiply operation transforms x into x * A / 255 (where x=Y,R,G or B).
-// Un-Multiply operation transforms x into x * 255 / A.
-
-// Pre-Multiply or Un-Multiply (if 'inverse' is true) argb values in a row.
-extern void (*WebPMultARGBRow)(uint32_t* const ptr, int width, int inverse);
-
-// Same a WebPMultARGBRow(), but for several rows.
-void WebPMultARGBRows(uint8_t* ptr, int stride, int width, int num_rows,
- int inverse);
-
-// Same for a row of single values, with side alpha values.
-extern void (*WebPMultRow)(uint8_t* WEBP_RESTRICT const ptr,
- const uint8_t* WEBP_RESTRICT const alpha,
- int width, int inverse);
-
-// Same a WebPMultRow(), but for several 'num_rows' rows.
-void WebPMultRows(uint8_t* WEBP_RESTRICT ptr, int stride,
- const uint8_t* WEBP_RESTRICT alpha, int alpha_stride,
- int width, int num_rows, int inverse);
-
-// Plain-C versions, used as fallback by some implementations.
-void WebPMultRow_C(uint8_t* WEBP_RESTRICT const ptr,
- const uint8_t* WEBP_RESTRICT const alpha,
- int width, int inverse);
-void WebPMultARGBRow_C(uint32_t* const ptr, int width, int inverse);
-
-#ifdef WORDS_BIGENDIAN
-// ARGB packing function: a/r/g/b input is rgba or bgra order.
-extern void (*WebPPackARGB)(const uint8_t* WEBP_RESTRICT a,
- const uint8_t* WEBP_RESTRICT r,
- const uint8_t* WEBP_RESTRICT g,
- const uint8_t* WEBP_RESTRICT b,
- int len, uint32_t* WEBP_RESTRICT out);
-#endif
-
-// RGB packing function. 'step' can be 3 or 4. r/g/b input is rgb or bgr order.
-extern void (*WebPPackRGB)(const uint8_t* WEBP_RESTRICT r,
- const uint8_t* WEBP_RESTRICT g,
- const uint8_t* WEBP_RESTRICT b,
- int len, int step, uint32_t* WEBP_RESTRICT out);
-
-// This function returns true if src[i] contains a value different from 0xff.
-extern int (*WebPHasAlpha8b)(const uint8_t* src, int length);
-// This function returns true if src[4*i] contains a value different from 0xff.
-extern int (*WebPHasAlpha32b)(const uint8_t* src, int length);
-// replaces transparent values in src[] by 'color'.
-extern void (*WebPAlphaReplace)(uint32_t* src, int length, uint32_t color);
-
-// To be called first before using the above.
-void WebPInitAlphaProcessing(void);
-
-//------------------------------------------------------------------------------
-// Filter functions
-
-typedef enum { // Filter types.
- WEBP_FILTER_NONE = 0,
- WEBP_FILTER_HORIZONTAL,
- WEBP_FILTER_VERTICAL,
- WEBP_FILTER_GRADIENT,
- WEBP_FILTER_LAST = WEBP_FILTER_GRADIENT + 1, // end marker
- WEBP_FILTER_BEST, // meta-types
- WEBP_FILTER_FAST
-} WEBP_FILTER_TYPE;
-
-typedef void (*WebPFilterFunc)(const uint8_t* in, int width, int height,
- int stride, uint8_t* out);
-// In-place un-filtering.
-// Warning! 'prev_line' pointer can be equal to 'cur_line' or 'preds'.
-typedef void (*WebPUnfilterFunc)(const uint8_t* prev_line, const uint8_t* preds,
- uint8_t* cur_line, int width);
-
-// Filter the given data using the given predictor.
-// 'in' corresponds to a 2-dimensional pixel array of size (stride * height)
-// in raster order.
-// 'stride' is number of bytes per scan line (with possible padding).
-// 'out' should be pre-allocated.
-extern WebPFilterFunc WebPFilters[WEBP_FILTER_LAST];
-
-// In-place reconstruct the original data from the given filtered data.
-// The reconstruction will be done for 'num_rows' rows starting from 'row'
-// (assuming rows upto 'row - 1' are already reconstructed).
-extern WebPUnfilterFunc WebPUnfilters[WEBP_FILTER_LAST];
-
-// To be called first before using the above.
-void VP8FiltersInit(void);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // WEBP_DSP_DSP_H_
diff --git a/contrib/libs/libwebp/dsp/enc.c b/contrib/libs/libwebp/dsp/enc.c
deleted file mode 100644
index 1035ae392d..0000000000
--- a/contrib/libs/libwebp/dsp/enc.c
+++ /dev/null
@@ -1,830 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Speed-critical encoding functions.
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include <assert.h>
-#include <stdlib.h> // for abs()
-
-#include "./dsp.h"
-#include "../enc/vp8i_enc.h"
-
-static WEBP_INLINE uint8_t clip_8b(int v) {
- return (!(v & ~0xff)) ? v : (v < 0) ? 0 : 255;
-}
-
-#if !WEBP_NEON_OMIT_C_CODE
-static WEBP_INLINE int clip_max(int v, int max) {
- return (v > max) ? max : v;
-}
-#endif // !WEBP_NEON_OMIT_C_CODE
-
-//------------------------------------------------------------------------------
-// Compute susceptibility based on DCT-coeff histograms:
-// the higher, the "easier" the macroblock is to compress.
-
-const int VP8DspScan[16 + 4 + 4] = {
- // Luma
- 0 + 0 * BPS, 4 + 0 * BPS, 8 + 0 * BPS, 12 + 0 * BPS,
- 0 + 4 * BPS, 4 + 4 * BPS, 8 + 4 * BPS, 12 + 4 * BPS,
- 0 + 8 * BPS, 4 + 8 * BPS, 8 + 8 * BPS, 12 + 8 * BPS,
- 0 + 12 * BPS, 4 + 12 * BPS, 8 + 12 * BPS, 12 + 12 * BPS,
-
- 0 + 0 * BPS, 4 + 0 * BPS, 0 + 4 * BPS, 4 + 4 * BPS, // U
- 8 + 0 * BPS, 12 + 0 * BPS, 8 + 4 * BPS, 12 + 4 * BPS // V
-};
-
-// general-purpose util function
-void VP8SetHistogramData(const int distribution[MAX_COEFF_THRESH + 1],
- VP8Histogram* const histo) {
- int max_value = 0, last_non_zero = 1;
- int k;
- for (k = 0; k <= MAX_COEFF_THRESH; ++k) {
- const int value = distribution[k];
- if (value > 0) {
- if (value > max_value) max_value = value;
- last_non_zero = k;
- }
- }
- histo->max_value = max_value;
- histo->last_non_zero = last_non_zero;
-}
-
-#if !WEBP_NEON_OMIT_C_CODE
-static void CollectHistogram_C(const uint8_t* ref, const uint8_t* pred,
- int start_block, int end_block,
- VP8Histogram* const histo) {
- int j;
- int distribution[MAX_COEFF_THRESH + 1] = { 0 };
- for (j = start_block; j < end_block; ++j) {
- int k;
- int16_t out[16];
-
- VP8FTransform(ref + VP8DspScan[j], pred + VP8DspScan[j], out);
-
- // Convert coefficients to bin.
- for (k = 0; k < 16; ++k) {
- const int v = abs(out[k]) >> 3;
- const int clipped_value = clip_max(v, MAX_COEFF_THRESH);
- ++distribution[clipped_value];
- }
- }
- VP8SetHistogramData(distribution, histo);
-}
-#endif // !WEBP_NEON_OMIT_C_CODE
-
-//------------------------------------------------------------------------------
-// run-time tables (~4k)
-
-static uint8_t clip1[255 + 510 + 1]; // clips [-255,510] to [0,255]
-
-// We declare this variable 'volatile' to prevent instruction reordering
-// and make sure it's set to true _last_ (so as to be thread-safe)
-static volatile int tables_ok = 0;
-
-static WEBP_TSAN_IGNORE_FUNCTION void InitTables(void) {
- if (!tables_ok) {
- int i;
- for (i = -255; i <= 255 + 255; ++i) {
- clip1[255 + i] = clip_8b(i);
- }
- tables_ok = 1;
- }
-}
-
-
-//------------------------------------------------------------------------------
-// Transforms (Paragraph 14.4)
-
-#if !WEBP_NEON_OMIT_C_CODE
-
-#define STORE(x, y, v) \
- dst[(x) + (y) * BPS] = clip_8b(ref[(x) + (y) * BPS] + ((v) >> 3))
-
-static const int kC1 = 20091 + (1 << 16);
-static const int kC2 = 35468;
-#define MUL(a, b) (((a) * (b)) >> 16)
-
-static WEBP_INLINE void ITransformOne(const uint8_t* ref, const int16_t* in,
- uint8_t* dst) {
- int C[4 * 4], *tmp;
- int i;
- tmp = C;
- for (i = 0; i < 4; ++i) { // vertical pass
- const int a = in[0] + in[8];
- const int b = in[0] - in[8];
- const int c = MUL(in[4], kC2) - MUL(in[12], kC1);
- const int d = MUL(in[4], kC1) + MUL(in[12], kC2);
- tmp[0] = a + d;
- tmp[1] = b + c;
- tmp[2] = b - c;
- tmp[3] = a - d;
- tmp += 4;
- in++;
- }
-
- tmp = C;
- for (i = 0; i < 4; ++i) { // horizontal pass
- const int dc = tmp[0] + 4;
- const int a = dc + tmp[8];
- const int b = dc - tmp[8];
- const int c = MUL(tmp[4], kC2) - MUL(tmp[12], kC1);
- const int d = MUL(tmp[4], kC1) + MUL(tmp[12], kC2);
- STORE(0, i, a + d);
- STORE(1, i, b + c);
- STORE(2, i, b - c);
- STORE(3, i, a - d);
- tmp++;
- }
-}
-
-static void ITransform_C(const uint8_t* ref, const int16_t* in, uint8_t* dst,
- int do_two) {
- ITransformOne(ref, in, dst);
- if (do_two) {
- ITransformOne(ref + 4, in + 16, dst + 4);
- }
-}
-
-static void FTransform_C(const uint8_t* src, const uint8_t* ref, int16_t* out) {
- int i;
- int tmp[16];
- for (i = 0; i < 4; ++i, src += BPS, ref += BPS) {
- const int d0 = src[0] - ref[0]; // 9bit dynamic range ([-255,255])
- const int d1 = src[1] - ref[1];
- const int d2 = src[2] - ref[2];
- const int d3 = src[3] - ref[3];
- const int a0 = (d0 + d3); // 10b [-510,510]
- const int a1 = (d1 + d2);
- const int a2 = (d1 - d2);
- const int a3 = (d0 - d3);
- tmp[0 + i * 4] = (a0 + a1) * 8; // 14b [-8160,8160]
- tmp[1 + i * 4] = (a2 * 2217 + a3 * 5352 + 1812) >> 9; // [-7536,7542]
- tmp[2 + i * 4] = (a0 - a1) * 8;
- tmp[3 + i * 4] = (a3 * 2217 - a2 * 5352 + 937) >> 9;
- }
- for (i = 0; i < 4; ++i) {
- const int a0 = (tmp[0 + i] + tmp[12 + i]); // 15b
- const int a1 = (tmp[4 + i] + tmp[ 8 + i]);
- const int a2 = (tmp[4 + i] - tmp[ 8 + i]);
- const int a3 = (tmp[0 + i] - tmp[12 + i]);
- out[0 + i] = (a0 + a1 + 7) >> 4; // 12b
- out[4 + i] = ((a2 * 2217 + a3 * 5352 + 12000) >> 16) + (a3 != 0);
- out[8 + i] = (a0 - a1 + 7) >> 4;
- out[12+ i] = ((a3 * 2217 - a2 * 5352 + 51000) >> 16);
- }
-}
-#endif // !WEBP_NEON_OMIT_C_CODE
-
-static void FTransform2_C(const uint8_t* src, const uint8_t* ref,
- int16_t* out) {
- VP8FTransform(src, ref, out);
- VP8FTransform(src + 4, ref + 4, out + 16);
-}
-
-#if !WEBP_NEON_OMIT_C_CODE
-static void FTransformWHT_C(const int16_t* in, int16_t* out) {
- // input is 12b signed
- int32_t tmp[16];
- int i;
- for (i = 0; i < 4; ++i, in += 64) {
- const int a0 = (in[0 * 16] + in[2 * 16]); // 13b
- const int a1 = (in[1 * 16] + in[3 * 16]);
- const int a2 = (in[1 * 16] - in[3 * 16]);
- const int a3 = (in[0 * 16] - in[2 * 16]);
- tmp[0 + i * 4] = a0 + a1; // 14b
- tmp[1 + i * 4] = a3 + a2;
- tmp[2 + i * 4] = a3 - a2;
- tmp[3 + i * 4] = a0 - a1;
- }
- for (i = 0; i < 4; ++i) {
- const int a0 = (tmp[0 + i] + tmp[8 + i]); // 15b
- const int a1 = (tmp[4 + i] + tmp[12+ i]);
- const int a2 = (tmp[4 + i] - tmp[12+ i]);
- const int a3 = (tmp[0 + i] - tmp[8 + i]);
- const int b0 = a0 + a1; // 16b
- const int b1 = a3 + a2;
- const int b2 = a3 - a2;
- const int b3 = a0 - a1;
- out[ 0 + i] = b0 >> 1; // 15b
- out[ 4 + i] = b1 >> 1;
- out[ 8 + i] = b2 >> 1;
- out[12 + i] = b3 >> 1;
- }
-}
-#endif // !WEBP_NEON_OMIT_C_CODE
-
-#undef MUL
-#undef STORE
-
-//------------------------------------------------------------------------------
-// Intra predictions
-
-static WEBP_INLINE void Fill(uint8_t* dst, int value, int size) {
- int j;
- for (j = 0; j < size; ++j) {
- memset(dst + j * BPS, value, size);
- }
-}
-
-static WEBP_INLINE void VerticalPred(uint8_t* dst,
- const uint8_t* top, int size) {
- int j;
- if (top != NULL) {
- for (j = 0; j < size; ++j) memcpy(dst + j * BPS, top, size);
- } else {
- Fill(dst, 127, size);
- }
-}
-
-static WEBP_INLINE void HorizontalPred(uint8_t* dst,
- const uint8_t* left, int size) {
- if (left != NULL) {
- int j;
- for (j = 0; j < size; ++j) {
- memset(dst + j * BPS, left[j], size);
- }
- } else {
- Fill(dst, 129, size);
- }
-}
-
-static WEBP_INLINE void TrueMotion(uint8_t* dst, const uint8_t* left,
- const uint8_t* top, int size) {
- int y;
- if (left != NULL) {
- if (top != NULL) {
- const uint8_t* const clip = clip1 + 255 - left[-1];
- for (y = 0; y < size; ++y) {
- const uint8_t* const clip_table = clip + left[y];
- int x;
- for (x = 0; x < size; ++x) {
- dst[x] = clip_table[top[x]];
- }
- dst += BPS;
- }
- } else {
- HorizontalPred(dst, left, size);
- }
- } else {
- // true motion without left samples (hence: with default 129 value)
- // is equivalent to VE prediction where you just copy the top samples.
- // Note that if top samples are not available, the default value is
- // then 129, and not 127 as in the VerticalPred case.
- if (top != NULL) {
- VerticalPred(dst, top, size);
- } else {
- Fill(dst, 129, size);
- }
- }
-}
-
-static WEBP_INLINE void DCMode(uint8_t* dst, const uint8_t* left,
- const uint8_t* top,
- int size, int round, int shift) {
- int DC = 0;
- int j;
- if (top != NULL) {
- for (j = 0; j < size; ++j) DC += top[j];
- if (left != NULL) { // top and left present
- for (j = 0; j < size; ++j) DC += left[j];
- } else { // top, but no left
- DC += DC;
- }
- DC = (DC + round) >> shift;
- } else if (left != NULL) { // left but no top
- for (j = 0; j < size; ++j) DC += left[j];
- DC += DC;
- DC = (DC + round) >> shift;
- } else { // no top, no left, nothing.
- DC = 0x80;
- }
- Fill(dst, DC, size);
-}
-
-//------------------------------------------------------------------------------
-// Chroma 8x8 prediction (paragraph 12.2)
-
-static void IntraChromaPreds_C(uint8_t* dst, const uint8_t* left,
- const uint8_t* top) {
- // U block
- DCMode(C8DC8 + dst, left, top, 8, 8, 4);
- VerticalPred(C8VE8 + dst, top, 8);
- HorizontalPred(C8HE8 + dst, left, 8);
- TrueMotion(C8TM8 + dst, left, top, 8);
- // V block
- dst += 8;
- if (top != NULL) top += 8;
- if (left != NULL) left += 16;
- DCMode(C8DC8 + dst, left, top, 8, 8, 4);
- VerticalPred(C8VE8 + dst, top, 8);
- HorizontalPred(C8HE8 + dst, left, 8);
- TrueMotion(C8TM8 + dst, left, top, 8);
-}
-
-//------------------------------------------------------------------------------
-// luma 16x16 prediction (paragraph 12.3)
-
-static void Intra16Preds_C(uint8_t* dst,
- const uint8_t* left, const uint8_t* top) {
- DCMode(I16DC16 + dst, left, top, 16, 16, 5);
- VerticalPred(I16VE16 + dst, top, 16);
- HorizontalPred(I16HE16 + dst, left, 16);
- TrueMotion(I16TM16 + dst, left, top, 16);
-}
-
-//------------------------------------------------------------------------------
-// luma 4x4 prediction
-
-#define DST(x, y) dst[(x) + (y) * BPS]
-#define AVG3(a, b, c) ((uint8_t)(((a) + 2 * (b) + (c) + 2) >> 2))
-#define AVG2(a, b) (((a) + (b) + 1) >> 1)
-
-static void VE4(uint8_t* dst, const uint8_t* top) { // vertical
- const uint8_t vals[4] = {
- AVG3(top[-1], top[0], top[1]),
- AVG3(top[ 0], top[1], top[2]),
- AVG3(top[ 1], top[2], top[3]),
- AVG3(top[ 2], top[3], top[4])
- };
- int i;
- for (i = 0; i < 4; ++i) {
- memcpy(dst + i * BPS, vals, 4);
- }
-}
-
-static void HE4(uint8_t* dst, const uint8_t* top) { // horizontal
- const int X = top[-1];
- const int I = top[-2];
- const int J = top[-3];
- const int K = top[-4];
- const int L = top[-5];
- WebPUint32ToMem(dst + 0 * BPS, 0x01010101U * AVG3(X, I, J));
- WebPUint32ToMem(dst + 1 * BPS, 0x01010101U * AVG3(I, J, K));
- WebPUint32ToMem(dst + 2 * BPS, 0x01010101U * AVG3(J, K, L));
- WebPUint32ToMem(dst + 3 * BPS, 0x01010101U * AVG3(K, L, L));
-}
-
-static void DC4(uint8_t* dst, const uint8_t* top) {
- uint32_t dc = 4;
- int i;
- for (i = 0; i < 4; ++i) dc += top[i] + top[-5 + i];
- Fill(dst, dc >> 3, 4);
-}
-
-static void RD4(uint8_t* dst, const uint8_t* top) {
- const int X = top[-1];
- const int I = top[-2];
- const int J = top[-3];
- const int K = top[-4];
- const int L = top[-5];
- const int A = top[0];
- const int B = top[1];
- const int C = top[2];
- const int D = top[3];
- DST(0, 3) = AVG3(J, K, L);
- DST(0, 2) = DST(1, 3) = AVG3(I, J, K);
- DST(0, 1) = DST(1, 2) = DST(2, 3) = AVG3(X, I, J);
- DST(0, 0) = DST(1, 1) = DST(2, 2) = DST(3, 3) = AVG3(A, X, I);
- DST(1, 0) = DST(2, 1) = DST(3, 2) = AVG3(B, A, X);
- DST(2, 0) = DST(3, 1) = AVG3(C, B, A);
- DST(3, 0) = AVG3(D, C, B);
-}
-
-static void LD4(uint8_t* dst, const uint8_t* top) {
- const int A = top[0];
- const int B = top[1];
- const int C = top[2];
- const int D = top[3];
- const int E = top[4];
- const int F = top[5];
- const int G = top[6];
- const int H = top[7];
- DST(0, 0) = AVG3(A, B, C);
- DST(1, 0) = DST(0, 1) = AVG3(B, C, D);
- DST(2, 0) = DST(1, 1) = DST(0, 2) = AVG3(C, D, E);
- DST(3, 0) = DST(2, 1) = DST(1, 2) = DST(0, 3) = AVG3(D, E, F);
- DST(3, 1) = DST(2, 2) = DST(1, 3) = AVG3(E, F, G);
- DST(3, 2) = DST(2, 3) = AVG3(F, G, H);
- DST(3, 3) = AVG3(G, H, H);
-}
-
-static void VR4(uint8_t* dst, const uint8_t* top) {
- const int X = top[-1];
- const int I = top[-2];
- const int J = top[-3];
- const int K = top[-4];
- const int A = top[0];
- const int B = top[1];
- const int C = top[2];
- const int D = top[3];
- DST(0, 0) = DST(1, 2) = AVG2(X, A);
- DST(1, 0) = DST(2, 2) = AVG2(A, B);
- DST(2, 0) = DST(3, 2) = AVG2(B, C);
- DST(3, 0) = AVG2(C, D);
-
- DST(0, 3) = AVG3(K, J, I);
- DST(0, 2) = AVG3(J, I, X);
- DST(0, 1) = DST(1, 3) = AVG3(I, X, A);
- DST(1, 1) = DST(2, 3) = AVG3(X, A, B);
- DST(2, 1) = DST(3, 3) = AVG3(A, B, C);
- DST(3, 1) = AVG3(B, C, D);
-}
-
-static void VL4(uint8_t* dst, const uint8_t* top) {
- const int A = top[0];
- const int B = top[1];
- const int C = top[2];
- const int D = top[3];
- const int E = top[4];
- const int F = top[5];
- const int G = top[6];
- const int H = top[7];
- DST(0, 0) = AVG2(A, B);
- DST(1, 0) = DST(0, 2) = AVG2(B, C);
- DST(2, 0) = DST(1, 2) = AVG2(C, D);
- DST(3, 0) = DST(2, 2) = AVG2(D, E);
-
- DST(0, 1) = AVG3(A, B, C);
- DST(1, 1) = DST(0, 3) = AVG3(B, C, D);
- DST(2, 1) = DST(1, 3) = AVG3(C, D, E);
- DST(3, 1) = DST(2, 3) = AVG3(D, E, F);
- DST(3, 2) = AVG3(E, F, G);
- DST(3, 3) = AVG3(F, G, H);
-}
-
-static void HU4(uint8_t* dst, const uint8_t* top) {
- const int I = top[-2];
- const int J = top[-3];
- const int K = top[-4];
- const int L = top[-5];
- DST(0, 0) = AVG2(I, J);
- DST(2, 0) = DST(0, 1) = AVG2(J, K);
- DST(2, 1) = DST(0, 2) = AVG2(K, L);
- DST(1, 0) = AVG3(I, J, K);
- DST(3, 0) = DST(1, 1) = AVG3(J, K, L);
- DST(3, 1) = DST(1, 2) = AVG3(K, L, L);
- DST(3, 2) = DST(2, 2) =
- DST(0, 3) = DST(1, 3) = DST(2, 3) = DST(3, 3) = L;
-}
-
-static void HD4(uint8_t* dst, const uint8_t* top) {
- const int X = top[-1];
- const int I = top[-2];
- const int J = top[-3];
- const int K = top[-4];
- const int L = top[-5];
- const int A = top[0];
- const int B = top[1];
- const int C = top[2];
-
- DST(0, 0) = DST(2, 1) = AVG2(I, X);
- DST(0, 1) = DST(2, 2) = AVG2(J, I);
- DST(0, 2) = DST(2, 3) = AVG2(K, J);
- DST(0, 3) = AVG2(L, K);
-
- DST(3, 0) = AVG3(A, B, C);
- DST(2, 0) = AVG3(X, A, B);
- DST(1, 0) = DST(3, 1) = AVG3(I, X, A);
- DST(1, 1) = DST(3, 2) = AVG3(J, I, X);
- DST(1, 2) = DST(3, 3) = AVG3(K, J, I);
- DST(1, 3) = AVG3(L, K, J);
-}
-
-static void TM4(uint8_t* dst, const uint8_t* top) {
- int x, y;
- const uint8_t* const clip = clip1 + 255 - top[-1];
- for (y = 0; y < 4; ++y) {
- const uint8_t* const clip_table = clip + top[-2 - y];
- for (x = 0; x < 4; ++x) {
- dst[x] = clip_table[top[x]];
- }
- dst += BPS;
- }
-}
-
-#undef DST
-#undef AVG3
-#undef AVG2
-
-// Left samples are top[-5 .. -2], top_left is top[-1], top are
-// located at top[0..3], and top right is top[4..7]
-static void Intra4Preds_C(uint8_t* dst, const uint8_t* top) {
- DC4(I4DC4 + dst, top);
- TM4(I4TM4 + dst, top);
- VE4(I4VE4 + dst, top);
- HE4(I4HE4 + dst, top);
- RD4(I4RD4 + dst, top);
- VR4(I4VR4 + dst, top);
- LD4(I4LD4 + dst, top);
- VL4(I4VL4 + dst, top);
- HD4(I4HD4 + dst, top);
- HU4(I4HU4 + dst, top);
-}
-
-//------------------------------------------------------------------------------
-// Metric
-
-#if !WEBP_NEON_OMIT_C_CODE
-static WEBP_INLINE int GetSSE(const uint8_t* a, const uint8_t* b,
- int w, int h) {
- int count = 0;
- int y, x;
- for (y = 0; y < h; ++y) {
- for (x = 0; x < w; ++x) {
- const int diff = (int)a[x] - b[x];
- count += diff * diff;
- }
- a += BPS;
- b += BPS;
- }
- return count;
-}
-
-static int SSE16x16_C(const uint8_t* a, const uint8_t* b) {
- return GetSSE(a, b, 16, 16);
-}
-static int SSE16x8_C(const uint8_t* a, const uint8_t* b) {
- return GetSSE(a, b, 16, 8);
-}
-static int SSE8x8_C(const uint8_t* a, const uint8_t* b) {
- return GetSSE(a, b, 8, 8);
-}
-static int SSE4x4_C(const uint8_t* a, const uint8_t* b) {
- return GetSSE(a, b, 4, 4);
-}
-#endif // !WEBP_NEON_OMIT_C_CODE
-
-static void Mean16x4_C(const uint8_t* ref, uint32_t dc[4]) {
- int k, x, y;
- for (k = 0; k < 4; ++k) {
- uint32_t avg = 0;
- for (y = 0; y < 4; ++y) {
- for (x = 0; x < 4; ++x) {
- avg += ref[x + y * BPS];
- }
- }
- dc[k] = avg;
- ref += 4; // go to next 4x4 block.
- }
-}
-
-//------------------------------------------------------------------------------
-// Texture distortion
-//
-// We try to match the spectral content (weighted) between source and
-// reconstructed samples.
-
-#if !WEBP_NEON_OMIT_C_CODE
-// Hadamard transform
-// Returns the weighted sum of the absolute value of transformed coefficients.
-// w[] contains a row-major 4 by 4 symmetric matrix.
-static int TTransform(const uint8_t* in, const uint16_t* w) {
- int sum = 0;
- int tmp[16];
- int i;
- // horizontal pass
- for (i = 0; i < 4; ++i, in += BPS) {
- const int a0 = in[0] + in[2];
- const int a1 = in[1] + in[3];
- const int a2 = in[1] - in[3];
- const int a3 = in[0] - in[2];
- tmp[0 + i * 4] = a0 + a1;
- tmp[1 + i * 4] = a3 + a2;
- tmp[2 + i * 4] = a3 - a2;
- tmp[3 + i * 4] = a0 - a1;
- }
- // vertical pass
- for (i = 0; i < 4; ++i, ++w) {
- const int a0 = tmp[0 + i] + tmp[8 + i];
- const int a1 = tmp[4 + i] + tmp[12+ i];
- const int a2 = tmp[4 + i] - tmp[12+ i];
- const int a3 = tmp[0 + i] - tmp[8 + i];
- const int b0 = a0 + a1;
- const int b1 = a3 + a2;
- const int b2 = a3 - a2;
- const int b3 = a0 - a1;
-
- sum += w[ 0] * abs(b0);
- sum += w[ 4] * abs(b1);
- sum += w[ 8] * abs(b2);
- sum += w[12] * abs(b3);
- }
- return sum;
-}
-
-static int Disto4x4_C(const uint8_t* const a, const uint8_t* const b,
- const uint16_t* const w) {
- const int sum1 = TTransform(a, w);
- const int sum2 = TTransform(b, w);
- return abs(sum2 - sum1) >> 5;
-}
-
-static int Disto16x16_C(const uint8_t* const a, const uint8_t* const b,
- const uint16_t* const w) {
- int D = 0;
- int x, y;
- for (y = 0; y < 16 * BPS; y += 4 * BPS) {
- for (x = 0; x < 16; x += 4) {
- D += Disto4x4_C(a + x + y, b + x + y, w);
- }
- }
- return D;
-}
-#endif // !WEBP_NEON_OMIT_C_CODE
-
-//------------------------------------------------------------------------------
-// Quantization
-//
-
-static const uint8_t kZigzag[16] = {
- 0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15
-};
-
-// Simple quantization
-static int QuantizeBlock_C(int16_t in[16], int16_t out[16],
- const VP8Matrix* const mtx) {
- int last = -1;
- int n;
- for (n = 0; n < 16; ++n) {
- const int j = kZigzag[n];
- const int sign = (in[j] < 0);
- const uint32_t coeff = (sign ? -in[j] : in[j]) + mtx->sharpen_[j];
- if (coeff > mtx->zthresh_[j]) {
- const uint32_t Q = mtx->q_[j];
- const uint32_t iQ = mtx->iq_[j];
- const uint32_t B = mtx->bias_[j];
- int level = QUANTDIV(coeff, iQ, B);
- if (level > MAX_LEVEL) level = MAX_LEVEL;
- if (sign) level = -level;
- in[j] = level * (int)Q;
- out[n] = level;
- if (level) last = n;
- } else {
- out[n] = 0;
- in[j] = 0;
- }
- }
- return (last >= 0);
-}
-
-#if !WEBP_NEON_OMIT_C_CODE || WEBP_NEON_WORK_AROUND_GCC
-static int Quantize2Blocks_C(int16_t in[32], int16_t out[32],
- const VP8Matrix* const mtx) {
- int nz;
- nz = VP8EncQuantizeBlock(in + 0 * 16, out + 0 * 16, mtx) << 0;
- nz |= VP8EncQuantizeBlock(in + 1 * 16, out + 1 * 16, mtx) << 1;
- return nz;
-}
-#endif // !WEBP_NEON_OMIT_C_CODE || WEBP_NEON_WORK_AROUND_GCC
-
-//------------------------------------------------------------------------------
-// Block copy
-
-static WEBP_INLINE void Copy(const uint8_t* src, uint8_t* dst, int w, int h) {
- int y;
- for (y = 0; y < h; ++y) {
- memcpy(dst, src, w);
- src += BPS;
- dst += BPS;
- }
-}
-
-static void Copy4x4_C(const uint8_t* src, uint8_t* dst) {
- Copy(src, dst, 4, 4);
-}
-
-static void Copy16x8_C(const uint8_t* src, uint8_t* dst) {
- Copy(src, dst, 16, 8);
-}
-
-//------------------------------------------------------------------------------
-// Initialization
-
-// Speed-critical function pointers. We have to initialize them to the default
-// implementations within VP8EncDspInit().
-VP8CHisto VP8CollectHistogram;
-VP8Idct VP8ITransform;
-VP8Fdct VP8FTransform;
-VP8Fdct VP8FTransform2;
-VP8WHT VP8FTransformWHT;
-VP8Intra4Preds VP8EncPredLuma4;
-VP8IntraPreds VP8EncPredLuma16;
-VP8IntraPreds VP8EncPredChroma8;
-VP8Metric VP8SSE16x16;
-VP8Metric VP8SSE8x8;
-VP8Metric VP8SSE16x8;
-VP8Metric VP8SSE4x4;
-VP8WMetric VP8TDisto4x4;
-VP8WMetric VP8TDisto16x16;
-VP8MeanMetric VP8Mean16x4;
-VP8QuantizeBlock VP8EncQuantizeBlock;
-VP8Quantize2Blocks VP8EncQuantize2Blocks;
-VP8QuantizeBlockWHT VP8EncQuantizeBlockWHT;
-VP8BlockCopy VP8Copy4x4;
-VP8BlockCopy VP8Copy16x8;
-
-extern void VP8EncDspInitSSE2(void);
-extern void VP8EncDspInitSSE41(void);
-extern void VP8EncDspInitNEON(void);
-extern void VP8EncDspInitMIPS32(void);
-extern void VP8EncDspInitMIPSdspR2(void);
-extern void VP8EncDspInitMSA(void);
-
-WEBP_DSP_INIT_FUNC(VP8EncDspInit) {
- VP8DspInit(); // common inverse transforms
- InitTables();
-
- // default C implementations
-#if !WEBP_NEON_OMIT_C_CODE
- VP8ITransform = ITransform_C;
- VP8FTransform = FTransform_C;
- VP8FTransformWHT = FTransformWHT_C;
- VP8TDisto4x4 = Disto4x4_C;
- VP8TDisto16x16 = Disto16x16_C;
- VP8CollectHistogram = CollectHistogram_C;
- VP8SSE16x16 = SSE16x16_C;
- VP8SSE16x8 = SSE16x8_C;
- VP8SSE8x8 = SSE8x8_C;
- VP8SSE4x4 = SSE4x4_C;
-#endif
-
-#if !WEBP_NEON_OMIT_C_CODE || WEBP_NEON_WORK_AROUND_GCC
- VP8EncQuantizeBlock = QuantizeBlock_C;
- VP8EncQuantize2Blocks = Quantize2Blocks_C;
-#endif
-
- VP8FTransform2 = FTransform2_C;
- VP8EncPredLuma4 = Intra4Preds_C;
- VP8EncPredLuma16 = Intra16Preds_C;
- VP8EncPredChroma8 = IntraChromaPreds_C;
- VP8Mean16x4 = Mean16x4_C;
- VP8EncQuantizeBlockWHT = QuantizeBlock_C;
- VP8Copy4x4 = Copy4x4_C;
- VP8Copy16x8 = Copy16x8_C;
-
- // If defined, use CPUInfo() to overwrite some pointers with faster versions.
- if (VP8GetCPUInfo != NULL) {
-#if defined(WEBP_HAVE_SSE2)
- if (VP8GetCPUInfo(kSSE2)) {
- VP8EncDspInitSSE2();
-#if defined(WEBP_HAVE_SSE41)
- if (VP8GetCPUInfo(kSSE4_1)) {
- VP8EncDspInitSSE41();
- }
-#endif
- }
-#endif
-#if defined(WEBP_USE_MIPS32)
- if (VP8GetCPUInfo(kMIPS32)) {
- VP8EncDspInitMIPS32();
- }
-#endif
-#if defined(WEBP_USE_MIPS_DSP_R2)
- if (VP8GetCPUInfo(kMIPSdspR2)) {
- VP8EncDspInitMIPSdspR2();
- }
-#endif
-#if defined(WEBP_USE_MSA)
- if (VP8GetCPUInfo(kMSA)) {
- VP8EncDspInitMSA();
- }
-#endif
- }
-
-#if defined(WEBP_HAVE_NEON)
- if (WEBP_NEON_OMIT_C_CODE ||
- (VP8GetCPUInfo != NULL && VP8GetCPUInfo(kNEON))) {
- VP8EncDspInitNEON();
- }
-#endif
-
- assert(VP8ITransform != NULL);
- assert(VP8FTransform != NULL);
- assert(VP8FTransformWHT != NULL);
- assert(VP8TDisto4x4 != NULL);
- assert(VP8TDisto16x16 != NULL);
- assert(VP8CollectHistogram != NULL);
- assert(VP8SSE16x16 != NULL);
- assert(VP8SSE16x8 != NULL);
- assert(VP8SSE8x8 != NULL);
- assert(VP8SSE4x4 != NULL);
- assert(VP8EncQuantizeBlock != NULL);
- assert(VP8EncQuantize2Blocks != NULL);
- assert(VP8FTransform2 != NULL);
- assert(VP8EncPredLuma4 != NULL);
- assert(VP8EncPredLuma16 != NULL);
- assert(VP8EncPredChroma8 != NULL);
- assert(VP8Mean16x4 != NULL);
- assert(VP8EncQuantizeBlockWHT != NULL);
- assert(VP8Copy4x4 != NULL);
- assert(VP8Copy16x8 != NULL);
-}
diff --git a/contrib/libs/libwebp/dsp/enc_mips32.c b/contrib/libs/libwebp/dsp/enc_mips32.c
deleted file mode 100644
index ad7d79bba0..0000000000
--- a/contrib/libs/libwebp/dsp/enc_mips32.c
+++ /dev/null
@@ -1,677 +0,0 @@
-// Copyright 2014 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// MIPS version of speed-critical encoding functions.
-//
-// Author(s): Djordje Pesut (djordje.pesut@imgtec.com)
-// Jovan Zelincevic (jovan.zelincevic@imgtec.com)
-// Slobodan Prijic (slobodan.prijic@imgtec.com)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_MIPS32)
-
-#include "./mips_macro.h"
-#include "../enc/vp8i_enc.h"
-#include "../enc/cost_enc.h"
-
-static const int kC1 = 20091 + (1 << 16);
-static const int kC2 = 35468;
-
-// macro for one vertical pass in ITransformOne
-// MUL macro inlined
-// temp0..temp15 holds tmp[0]..tmp[15]
-// A..D - offsets in bytes to load from in buffer
-// TEMP0..TEMP3 - registers for corresponding tmp elements
-// TEMP4..TEMP5 - temporary registers
-#define VERTICAL_PASS(A, B, C, D, TEMP4, TEMP0, TEMP1, TEMP2, TEMP3) \
- "lh %[temp16], " #A "(%[temp20]) \n\t" \
- "lh %[temp18], " #B "(%[temp20]) \n\t" \
- "lh %[temp17], " #C "(%[temp20]) \n\t" \
- "lh %[temp19], " #D "(%[temp20]) \n\t" \
- "addu %[" #TEMP4 "], %[temp16], %[temp18] \n\t" \
- "subu %[temp16], %[temp16], %[temp18] \n\t" \
- "mul %[" #TEMP0 "], %[temp17], %[kC2] \n\t" \
- "mul %[temp18], %[temp19], %[kC1] \n\t" \
- "mul %[temp17], %[temp17], %[kC1] \n\t" \
- "mul %[temp19], %[temp19], %[kC2] \n\t" \
- "sra %[" #TEMP0 "], %[" #TEMP0 "], 16 \n\n" \
- "sra %[temp18], %[temp18], 16 \n\n" \
- "sra %[temp17], %[temp17], 16 \n\n" \
- "sra %[temp19], %[temp19], 16 \n\n" \
- "subu %[" #TEMP2 "], %[" #TEMP0 "], %[temp18] \n\t" \
- "addu %[" #TEMP3 "], %[temp17], %[temp19] \n\t" \
- "addu %[" #TEMP0 "], %[" #TEMP4 "], %[" #TEMP3 "] \n\t" \
- "addu %[" #TEMP1 "], %[temp16], %[" #TEMP2 "] \n\t" \
- "subu %[" #TEMP2 "], %[temp16], %[" #TEMP2 "] \n\t" \
- "subu %[" #TEMP3 "], %[" #TEMP4 "], %[" #TEMP3 "] \n\t"
-
-// macro for one horizontal pass in ITransformOne
-// MUL and STORE macros inlined
-// a = clip_8b(a) is replaced with: a = max(a, 0); a = min(a, 255)
-// temp0..temp15 holds tmp[0]..tmp[15]
-// A - offset in bytes to load from ref and store to dst buffer
-// TEMP0, TEMP4, TEMP8 and TEMP12 - registers for corresponding tmp elements
-#define HORIZONTAL_PASS(A, TEMP0, TEMP4, TEMP8, TEMP12) \
- "addiu %[" #TEMP0 "], %[" #TEMP0 "], 4 \n\t" \
- "addu %[temp16], %[" #TEMP0 "], %[" #TEMP8 "] \n\t" \
- "subu %[temp17], %[" #TEMP0 "], %[" #TEMP8 "] \n\t" \
- "mul %[" #TEMP0 "], %[" #TEMP4 "], %[kC2] \n\t" \
- "mul %[" #TEMP8 "], %[" #TEMP12 "], %[kC1] \n\t" \
- "mul %[" #TEMP4 "], %[" #TEMP4 "], %[kC1] \n\t" \
- "mul %[" #TEMP12 "], %[" #TEMP12 "], %[kC2] \n\t" \
- "sra %[" #TEMP0 "], %[" #TEMP0 "], 16 \n\t" \
- "sra %[" #TEMP8 "], %[" #TEMP8 "], 16 \n\t" \
- "sra %[" #TEMP4 "], %[" #TEMP4 "], 16 \n\t" \
- "sra %[" #TEMP12 "], %[" #TEMP12 "], 16 \n\t" \
- "subu %[temp18], %[" #TEMP0 "], %[" #TEMP8 "] \n\t" \
- "addu %[temp19], %[" #TEMP4 "], %[" #TEMP12 "] \n\t" \
- "addu %[" #TEMP0 "], %[temp16], %[temp19] \n\t" \
- "addu %[" #TEMP4 "], %[temp17], %[temp18] \n\t" \
- "subu %[" #TEMP8 "], %[temp17], %[temp18] \n\t" \
- "subu %[" #TEMP12 "], %[temp16], %[temp19] \n\t" \
- "lw %[temp20], 0(%[args]) \n\t" \
- "sra %[" #TEMP0 "], %[" #TEMP0 "], 3 \n\t" \
- "sra %[" #TEMP4 "], %[" #TEMP4 "], 3 \n\t" \
- "sra %[" #TEMP8 "], %[" #TEMP8 "], 3 \n\t" \
- "sra %[" #TEMP12 "], %[" #TEMP12 "], 3 \n\t" \
- "lbu %[temp16], 0+" XSTR(BPS) "*" #A "(%[temp20]) \n\t" \
- "lbu %[temp17], 1+" XSTR(BPS) "*" #A "(%[temp20]) \n\t" \
- "lbu %[temp18], 2+" XSTR(BPS) "*" #A "(%[temp20]) \n\t" \
- "lbu %[temp19], 3+" XSTR(BPS) "*" #A "(%[temp20]) \n\t" \
- "addu %[" #TEMP0 "], %[temp16], %[" #TEMP0 "] \n\t" \
- "addu %[" #TEMP4 "], %[temp17], %[" #TEMP4 "] \n\t" \
- "addu %[" #TEMP8 "], %[temp18], %[" #TEMP8 "] \n\t" \
- "addu %[" #TEMP12 "], %[temp19], %[" #TEMP12 "] \n\t" \
- "slt %[temp16], %[" #TEMP0 "], $zero \n\t" \
- "slt %[temp17], %[" #TEMP4 "], $zero \n\t" \
- "slt %[temp18], %[" #TEMP8 "], $zero \n\t" \
- "slt %[temp19], %[" #TEMP12 "], $zero \n\t" \
- "movn %[" #TEMP0 "], $zero, %[temp16] \n\t" \
- "movn %[" #TEMP4 "], $zero, %[temp17] \n\t" \
- "movn %[" #TEMP8 "], $zero, %[temp18] \n\t" \
- "movn %[" #TEMP12 "], $zero, %[temp19] \n\t" \
- "addiu %[temp20], $zero, 255 \n\t" \
- "slt %[temp16], %[" #TEMP0 "], %[temp20] \n\t" \
- "slt %[temp17], %[" #TEMP4 "], %[temp20] \n\t" \
- "slt %[temp18], %[" #TEMP8 "], %[temp20] \n\t" \
- "slt %[temp19], %[" #TEMP12 "], %[temp20] \n\t" \
- "movz %[" #TEMP0 "], %[temp20], %[temp16] \n\t" \
- "movz %[" #TEMP4 "], %[temp20], %[temp17] \n\t" \
- "lw %[temp16], 8(%[args]) \n\t" \
- "movz %[" #TEMP8 "], %[temp20], %[temp18] \n\t" \
- "movz %[" #TEMP12 "], %[temp20], %[temp19] \n\t" \
- "sb %[" #TEMP0 "], 0+" XSTR(BPS) "*" #A "(%[temp16]) \n\t" \
- "sb %[" #TEMP4 "], 1+" XSTR(BPS) "*" #A "(%[temp16]) \n\t" \
- "sb %[" #TEMP8 "], 2+" XSTR(BPS) "*" #A "(%[temp16]) \n\t" \
- "sb %[" #TEMP12 "], 3+" XSTR(BPS) "*" #A "(%[temp16]) \n\t"
-
-// Does one or two inverse transforms.
-static WEBP_INLINE void ITransformOne_MIPS32(const uint8_t* ref,
- const int16_t* in,
- uint8_t* dst) {
- int temp0, temp1, temp2, temp3, temp4, temp5, temp6;
- int temp7, temp8, temp9, temp10, temp11, temp12, temp13;
- int temp14, temp15, temp16, temp17, temp18, temp19, temp20;
- const int* args[3] = {(const int*)ref, (const int*)in, (const int*)dst};
-
- __asm__ volatile(
- "lw %[temp20], 4(%[args]) \n\t"
- VERTICAL_PASS(0, 16, 8, 24, temp4, temp0, temp1, temp2, temp3)
- VERTICAL_PASS(2, 18, 10, 26, temp8, temp4, temp5, temp6, temp7)
- VERTICAL_PASS(4, 20, 12, 28, temp12, temp8, temp9, temp10, temp11)
- VERTICAL_PASS(6, 22, 14, 30, temp20, temp12, temp13, temp14, temp15)
-
- HORIZONTAL_PASS(0, temp0, temp4, temp8, temp12)
- HORIZONTAL_PASS(1, temp1, temp5, temp9, temp13)
- HORIZONTAL_PASS(2, temp2, temp6, temp10, temp14)
- HORIZONTAL_PASS(3, temp3, temp7, temp11, temp15)
-
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [temp4]"=&r"(temp4), [temp5]"=&r"(temp5),
- [temp6]"=&r"(temp6), [temp7]"=&r"(temp7), [temp8]"=&r"(temp8),
- [temp9]"=&r"(temp9), [temp10]"=&r"(temp10), [temp11]"=&r"(temp11),
- [temp12]"=&r"(temp12), [temp13]"=&r"(temp13), [temp14]"=&r"(temp14),
- [temp15]"=&r"(temp15), [temp16]"=&r"(temp16), [temp17]"=&r"(temp17),
- [temp18]"=&r"(temp18), [temp19]"=&r"(temp19), [temp20]"=&r"(temp20)
- : [args]"r"(args), [kC1]"r"(kC1), [kC2]"r"(kC2)
- : "memory", "hi", "lo"
- );
-}
-
-static void ITransform_MIPS32(const uint8_t* ref, const int16_t* in,
- uint8_t* dst, int do_two) {
- ITransformOne_MIPS32(ref, in, dst);
- if (do_two) {
- ITransformOne_MIPS32(ref + 4, in + 16, dst + 4);
- }
-}
-
-#undef VERTICAL_PASS
-#undef HORIZONTAL_PASS
-
-// macro for one pass through for loop in QuantizeBlock
-// QUANTDIV macro inlined
-// J - offset in bytes (kZigzag[n] * 2)
-// K - offset in bytes (kZigzag[n] * 4)
-// N - offset in bytes (n * 2)
-#define QUANTIZE_ONE(J, K, N) \
- "lh %[temp0], " #J "(%[ppin]) \n\t" \
- "lhu %[temp1], " #J "(%[ppsharpen]) \n\t" \
- "lw %[temp2], " #K "(%[ppzthresh]) \n\t" \
- "sra %[sign], %[temp0], 15 \n\t" \
- "xor %[coeff], %[temp0], %[sign] \n\t" \
- "subu %[coeff], %[coeff], %[sign] \n\t" \
- "addu %[coeff], %[coeff], %[temp1] \n\t" \
- "slt %[temp4], %[temp2], %[coeff] \n\t" \
- "addiu %[temp5], $zero, 0 \n\t" \
- "addiu %[level], $zero, 0 \n\t" \
- "beqz %[temp4], 2f \n\t" \
- "lhu %[temp1], " #J "(%[ppiq]) \n\t" \
- "lw %[temp2], " #K "(%[ppbias]) \n\t" \
- "lhu %[temp3], " #J "(%[ppq]) \n\t" \
- "mul %[level], %[coeff], %[temp1] \n\t" \
- "addu %[level], %[level], %[temp2] \n\t" \
- "sra %[level], %[level], 17 \n\t" \
- "slt %[temp4], %[max_level], %[level] \n\t" \
- "movn %[level], %[max_level], %[temp4] \n\t" \
- "xor %[level], %[level], %[sign] \n\t" \
- "subu %[level], %[level], %[sign] \n\t" \
- "mul %[temp5], %[level], %[temp3] \n\t" \
-"2: \n\t" \
- "sh %[temp5], " #J "(%[ppin]) \n\t" \
- "sh %[level], " #N "(%[pout]) \n\t"
-
-static int QuantizeBlock_MIPS32(int16_t in[16], int16_t out[16],
- const VP8Matrix* const mtx) {
- int temp0, temp1, temp2, temp3, temp4, temp5;
- int sign, coeff, level, i;
- int max_level = MAX_LEVEL;
-
- int16_t* ppin = &in[0];
- int16_t* pout = &out[0];
- const uint16_t* ppsharpen = &mtx->sharpen_[0];
- const uint32_t* ppzthresh = &mtx->zthresh_[0];
- const uint16_t* ppq = &mtx->q_[0];
- const uint16_t* ppiq = &mtx->iq_[0];
- const uint32_t* ppbias = &mtx->bias_[0];
-
- __asm__ volatile(
- QUANTIZE_ONE( 0, 0, 0)
- QUANTIZE_ONE( 2, 4, 2)
- QUANTIZE_ONE( 8, 16, 4)
- QUANTIZE_ONE(16, 32, 6)
- QUANTIZE_ONE(10, 20, 8)
- QUANTIZE_ONE( 4, 8, 10)
- QUANTIZE_ONE( 6, 12, 12)
- QUANTIZE_ONE(12, 24, 14)
- QUANTIZE_ONE(18, 36, 16)
- QUANTIZE_ONE(24, 48, 18)
- QUANTIZE_ONE(26, 52, 20)
- QUANTIZE_ONE(20, 40, 22)
- QUANTIZE_ONE(14, 28, 24)
- QUANTIZE_ONE(22, 44, 26)
- QUANTIZE_ONE(28, 56, 28)
- QUANTIZE_ONE(30, 60, 30)
-
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1),
- [temp2]"=&r"(temp2), [temp3]"=&r"(temp3),
- [temp4]"=&r"(temp4), [temp5]"=&r"(temp5),
- [sign]"=&r"(sign), [coeff]"=&r"(coeff),
- [level]"=&r"(level)
- : [pout]"r"(pout), [ppin]"r"(ppin),
- [ppiq]"r"(ppiq), [max_level]"r"(max_level),
- [ppbias]"r"(ppbias), [ppzthresh]"r"(ppzthresh),
- [ppsharpen]"r"(ppsharpen), [ppq]"r"(ppq)
- : "memory", "hi", "lo"
- );
-
- // moved out from macro to increase possibility for earlier breaking
- for (i = 15; i >= 0; i--) {
- if (out[i]) return 1;
- }
- return 0;
-}
-
-static int Quantize2Blocks_MIPS32(int16_t in[32], int16_t out[32],
- const VP8Matrix* const mtx) {
- int nz;
- nz = QuantizeBlock_MIPS32(in + 0 * 16, out + 0 * 16, mtx) << 0;
- nz |= QuantizeBlock_MIPS32(in + 1 * 16, out + 1 * 16, mtx) << 1;
- return nz;
-}
-
-#undef QUANTIZE_ONE
-
-// macro for one horizontal pass in Disto4x4 (TTransform)
-// two calls of function TTransform are merged into single one
-// A - offset in bytes to load from a and b buffers
-// E..H - offsets in bytes to store first results to tmp buffer
-// E1..H1 - offsets in bytes to store second results to tmp buffer
-#define HORIZONTAL_PASS(A, E, F, G, H, E1, F1, G1, H1) \
- "lbu %[temp0], 0+" XSTR(BPS) "*" #A "(%[a]) \n\t" \
- "lbu %[temp1], 1+" XSTR(BPS) "*" #A "(%[a]) \n\t" \
- "lbu %[temp2], 2+" XSTR(BPS) "*" #A "(%[a]) \n\t" \
- "lbu %[temp3], 3+" XSTR(BPS) "*" #A "(%[a]) \n\t" \
- "lbu %[temp4], 0+" XSTR(BPS) "*" #A "(%[b]) \n\t" \
- "lbu %[temp5], 1+" XSTR(BPS) "*" #A "(%[b]) \n\t" \
- "lbu %[temp6], 2+" XSTR(BPS) "*" #A "(%[b]) \n\t" \
- "lbu %[temp7], 3+" XSTR(BPS) "*" #A "(%[b]) \n\t" \
- "addu %[temp8], %[temp0], %[temp2] \n\t" \
- "subu %[temp0], %[temp0], %[temp2] \n\t" \
- "addu %[temp2], %[temp1], %[temp3] \n\t" \
- "subu %[temp1], %[temp1], %[temp3] \n\t" \
- "addu %[temp3], %[temp4], %[temp6] \n\t" \
- "subu %[temp4], %[temp4], %[temp6] \n\t" \
- "addu %[temp6], %[temp5], %[temp7] \n\t" \
- "subu %[temp5], %[temp5], %[temp7] \n\t" \
- "addu %[temp7], %[temp8], %[temp2] \n\t" \
- "subu %[temp2], %[temp8], %[temp2] \n\t" \
- "addu %[temp8], %[temp0], %[temp1] \n\t" \
- "subu %[temp0], %[temp0], %[temp1] \n\t" \
- "addu %[temp1], %[temp3], %[temp6] \n\t" \
- "subu %[temp3], %[temp3], %[temp6] \n\t" \
- "addu %[temp6], %[temp4], %[temp5] \n\t" \
- "subu %[temp4], %[temp4], %[temp5] \n\t" \
- "sw %[temp7], " #E "(%[tmp]) \n\t" \
- "sw %[temp2], " #H "(%[tmp]) \n\t" \
- "sw %[temp8], " #F "(%[tmp]) \n\t" \
- "sw %[temp0], " #G "(%[tmp]) \n\t" \
- "sw %[temp1], " #E1 "(%[tmp]) \n\t" \
- "sw %[temp3], " #H1 "(%[tmp]) \n\t" \
- "sw %[temp6], " #F1 "(%[tmp]) \n\t" \
- "sw %[temp4], " #G1 "(%[tmp]) \n\t"
-
-// macro for one vertical pass in Disto4x4 (TTransform)
-// two calls of function TTransform are merged into single one
-// since only one accu is available in mips32r1 instruction set
-// first is done second call of function TTransform and after
-// that first one.
-// const int sum1 = TTransform(a, w);
-// const int sum2 = TTransform(b, w);
-// return abs(sum2 - sum1) >> 5;
-// (sum2 - sum1) is calculated with madds (sub2) and msubs (sub1)
-// A..D - offsets in bytes to load first results from tmp buffer
-// A1..D1 - offsets in bytes to load second results from tmp buffer
-// E..H - offsets in bytes to load from w buffer
-#define VERTICAL_PASS(A, B, C, D, A1, B1, C1, D1, E, F, G, H) \
- "lw %[temp0], " #A1 "(%[tmp]) \n\t" \
- "lw %[temp1], " #C1 "(%[tmp]) \n\t" \
- "lw %[temp2], " #B1 "(%[tmp]) \n\t" \
- "lw %[temp3], " #D1 "(%[tmp]) \n\t" \
- "addu %[temp8], %[temp0], %[temp1] \n\t" \
- "subu %[temp0], %[temp0], %[temp1] \n\t" \
- "addu %[temp1], %[temp2], %[temp3] \n\t" \
- "subu %[temp2], %[temp2], %[temp3] \n\t" \
- "addu %[temp3], %[temp8], %[temp1] \n\t" \
- "subu %[temp8], %[temp8], %[temp1] \n\t" \
- "addu %[temp1], %[temp0], %[temp2] \n\t" \
- "subu %[temp0], %[temp0], %[temp2] \n\t" \
- "sra %[temp4], %[temp3], 31 \n\t" \
- "sra %[temp5], %[temp1], 31 \n\t" \
- "sra %[temp6], %[temp0], 31 \n\t" \
- "sra %[temp7], %[temp8], 31 \n\t" \
- "xor %[temp3], %[temp3], %[temp4] \n\t" \
- "xor %[temp1], %[temp1], %[temp5] \n\t" \
- "xor %[temp0], %[temp0], %[temp6] \n\t" \
- "xor %[temp8], %[temp8], %[temp7] \n\t" \
- "subu %[temp3], %[temp3], %[temp4] \n\t" \
- "subu %[temp1], %[temp1], %[temp5] \n\t" \
- "subu %[temp0], %[temp0], %[temp6] \n\t" \
- "subu %[temp8], %[temp8], %[temp7] \n\t" \
- "lhu %[temp4], " #E "(%[w]) \n\t" \
- "lhu %[temp5], " #F "(%[w]) \n\t" \
- "lhu %[temp6], " #G "(%[w]) \n\t" \
- "lhu %[temp7], " #H "(%[w]) \n\t" \
- "madd %[temp4], %[temp3] \n\t" \
- "madd %[temp5], %[temp1] \n\t" \
- "madd %[temp6], %[temp0] \n\t" \
- "madd %[temp7], %[temp8] \n\t" \
- "lw %[temp0], " #A "(%[tmp]) \n\t" \
- "lw %[temp1], " #C "(%[tmp]) \n\t" \
- "lw %[temp2], " #B "(%[tmp]) \n\t" \
- "lw %[temp3], " #D "(%[tmp]) \n\t" \
- "addu %[temp8], %[temp0], %[temp1] \n\t" \
- "subu %[temp0], %[temp0], %[temp1] \n\t" \
- "addu %[temp1], %[temp2], %[temp3] \n\t" \
- "subu %[temp2], %[temp2], %[temp3] \n\t" \
- "addu %[temp3], %[temp8], %[temp1] \n\t" \
- "subu %[temp1], %[temp8], %[temp1] \n\t" \
- "addu %[temp8], %[temp0], %[temp2] \n\t" \
- "subu %[temp0], %[temp0], %[temp2] \n\t" \
- "sra %[temp2], %[temp3], 31 \n\t" \
- "xor %[temp3], %[temp3], %[temp2] \n\t" \
- "subu %[temp3], %[temp3], %[temp2] \n\t" \
- "msub %[temp4], %[temp3] \n\t" \
- "sra %[temp2], %[temp8], 31 \n\t" \
- "sra %[temp3], %[temp0], 31 \n\t" \
- "sra %[temp4], %[temp1], 31 \n\t" \
- "xor %[temp8], %[temp8], %[temp2] \n\t" \
- "xor %[temp0], %[temp0], %[temp3] \n\t" \
- "xor %[temp1], %[temp1], %[temp4] \n\t" \
- "subu %[temp8], %[temp8], %[temp2] \n\t" \
- "subu %[temp0], %[temp0], %[temp3] \n\t" \
- "subu %[temp1], %[temp1], %[temp4] \n\t" \
- "msub %[temp5], %[temp8] \n\t" \
- "msub %[temp6], %[temp0] \n\t" \
- "msub %[temp7], %[temp1] \n\t"
-
-static int Disto4x4_MIPS32(const uint8_t* const a, const uint8_t* const b,
- const uint16_t* const w) {
- int tmp[32];
- int temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7, temp8;
-
- __asm__ volatile(
- HORIZONTAL_PASS(0, 0, 4, 8, 12, 64, 68, 72, 76)
- HORIZONTAL_PASS(1, 16, 20, 24, 28, 80, 84, 88, 92)
- HORIZONTAL_PASS(2, 32, 36, 40, 44, 96, 100, 104, 108)
- HORIZONTAL_PASS(3, 48, 52, 56, 60, 112, 116, 120, 124)
- "mthi $zero \n\t"
- "mtlo $zero \n\t"
- VERTICAL_PASS( 0, 16, 32, 48, 64, 80, 96, 112, 0, 8, 16, 24)
- VERTICAL_PASS( 4, 20, 36, 52, 68, 84, 100, 116, 2, 10, 18, 26)
- VERTICAL_PASS( 8, 24, 40, 56, 72, 88, 104, 120, 4, 12, 20, 28)
- VERTICAL_PASS(12, 28, 44, 60, 76, 92, 108, 124, 6, 14, 22, 30)
- "mflo %[temp0] \n\t"
- "sra %[temp1], %[temp0], 31 \n\t"
- "xor %[temp0], %[temp0], %[temp1] \n\t"
- "subu %[temp0], %[temp0], %[temp1] \n\t"
- "sra %[temp0], %[temp0], 5 \n\t"
-
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [temp4]"=&r"(temp4), [temp5]"=&r"(temp5),
- [temp6]"=&r"(temp6), [temp7]"=&r"(temp7), [temp8]"=&r"(temp8)
- : [a]"r"(a), [b]"r"(b), [w]"r"(w), [tmp]"r"(tmp)
- : "memory", "hi", "lo"
- );
-
- return temp0;
-}
-
-#undef VERTICAL_PASS
-#undef HORIZONTAL_PASS
-
-static int Disto16x16_MIPS32(const uint8_t* const a, const uint8_t* const b,
- const uint16_t* const w) {
- int D = 0;
- int x, y;
- for (y = 0; y < 16 * BPS; y += 4 * BPS) {
- for (x = 0; x < 16; x += 4) {
- D += Disto4x4_MIPS32(a + x + y, b + x + y, w);
- }
- }
- return D;
-}
-
-// macro for one horizontal pass in FTransform
-// temp0..temp15 holds tmp[0]..tmp[15]
-// A - offset in bytes to load from src and ref buffers
-// TEMP0..TEMP3 - registers for corresponding tmp elements
-#define HORIZONTAL_PASS(A, TEMP0, TEMP1, TEMP2, TEMP3) \
- "lw %[" #TEMP1 "], 0(%[args]) \n\t" \
- "lw %[" #TEMP2 "], 4(%[args]) \n\t" \
- "lbu %[temp16], 0+" XSTR(BPS) "*" #A "(%[" #TEMP1 "]) \n\t" \
- "lbu %[temp17], 0+" XSTR(BPS) "*" #A "(%[" #TEMP2 "]) \n\t" \
- "lbu %[temp18], 1+" XSTR(BPS) "*" #A "(%[" #TEMP1 "]) \n\t" \
- "lbu %[temp19], 1+" XSTR(BPS) "*" #A "(%[" #TEMP2 "]) \n\t" \
- "subu %[temp20], %[temp16], %[temp17] \n\t" \
- "lbu %[temp16], 2+" XSTR(BPS) "*" #A "(%[" #TEMP1 "]) \n\t" \
- "lbu %[temp17], 2+" XSTR(BPS) "*" #A "(%[" #TEMP2 "]) \n\t" \
- "subu %[" #TEMP0 "], %[temp18], %[temp19] \n\t" \
- "lbu %[temp18], 3+" XSTR(BPS) "*" #A "(%[" #TEMP1 "]) \n\t" \
- "lbu %[temp19], 3+" XSTR(BPS) "*" #A "(%[" #TEMP2 "]) \n\t" \
- "subu %[" #TEMP1 "], %[temp16], %[temp17] \n\t" \
- "subu %[" #TEMP2 "], %[temp18], %[temp19] \n\t" \
- "addu %[" #TEMP3 "], %[temp20], %[" #TEMP2 "] \n\t" \
- "subu %[" #TEMP2 "], %[temp20], %[" #TEMP2 "] \n\t" \
- "addu %[temp20], %[" #TEMP0 "], %[" #TEMP1 "] \n\t" \
- "subu %[" #TEMP0 "], %[" #TEMP0 "], %[" #TEMP1 "] \n\t" \
- "mul %[temp16], %[" #TEMP2 "], %[c5352] \n\t" \
- "mul %[temp17], %[" #TEMP2 "], %[c2217] \n\t" \
- "mul %[temp18], %[" #TEMP0 "], %[c5352] \n\t" \
- "mul %[temp19], %[" #TEMP0 "], %[c2217] \n\t" \
- "addu %[" #TEMP1 "], %[" #TEMP3 "], %[temp20] \n\t" \
- "subu %[temp20], %[" #TEMP3 "], %[temp20] \n\t" \
- "sll %[" #TEMP0 "], %[" #TEMP1 "], 3 \n\t" \
- "sll %[" #TEMP2 "], %[temp20], 3 \n\t" \
- "addiu %[temp16], %[temp16], 1812 \n\t" \
- "addiu %[temp17], %[temp17], 937 \n\t" \
- "addu %[temp16], %[temp16], %[temp19] \n\t" \
- "subu %[temp17], %[temp17], %[temp18] \n\t" \
- "sra %[" #TEMP1 "], %[temp16], 9 \n\t" \
- "sra %[" #TEMP3 "], %[temp17], 9 \n\t"
-
-// macro for one vertical pass in FTransform
-// temp0..temp15 holds tmp[0]..tmp[15]
-// A..D - offsets in bytes to store to out buffer
-// TEMP0, TEMP4, TEMP8 and TEMP12 - registers for corresponding tmp elements
-#define VERTICAL_PASS(A, B, C, D, TEMP0, TEMP4, TEMP8, TEMP12) \
- "addu %[temp16], %[" #TEMP0 "], %[" #TEMP12 "] \n\t" \
- "subu %[temp19], %[" #TEMP0 "], %[" #TEMP12 "] \n\t" \
- "addu %[temp17], %[" #TEMP4 "], %[" #TEMP8 "] \n\t" \
- "subu %[temp18], %[" #TEMP4 "], %[" #TEMP8 "] \n\t" \
- "mul %[" #TEMP8 "], %[temp19], %[c2217] \n\t" \
- "mul %[" #TEMP12 "], %[temp18], %[c2217] \n\t" \
- "mul %[" #TEMP4 "], %[temp19], %[c5352] \n\t" \
- "mul %[temp18], %[temp18], %[c5352] \n\t" \
- "addiu %[temp16], %[temp16], 7 \n\t" \
- "addu %[" #TEMP0 "], %[temp16], %[temp17] \n\t" \
- "sra %[" #TEMP0 "], %[" #TEMP0 "], 4 \n\t" \
- "addu %[" #TEMP12 "], %[" #TEMP12 "], %[" #TEMP4 "] \n\t" \
- "subu %[" #TEMP4 "], %[temp16], %[temp17] \n\t" \
- "sra %[" #TEMP4 "], %[" #TEMP4 "], 4 \n\t" \
- "addiu %[" #TEMP8 "], %[" #TEMP8 "], 30000 \n\t" \
- "addiu %[" #TEMP12 "], %[" #TEMP12 "], 12000 \n\t" \
- "addiu %[" #TEMP8 "], %[" #TEMP8 "], 21000 \n\t" \
- "subu %[" #TEMP8 "], %[" #TEMP8 "], %[temp18] \n\t" \
- "sra %[" #TEMP12 "], %[" #TEMP12 "], 16 \n\t" \
- "sra %[" #TEMP8 "], %[" #TEMP8 "], 16 \n\t" \
- "addiu %[temp16], %[" #TEMP12 "], 1 \n\t" \
- "movn %[" #TEMP12 "], %[temp16], %[temp19] \n\t" \
- "sh %[" #TEMP0 "], " #A "(%[temp20]) \n\t" \
- "sh %[" #TEMP4 "], " #C "(%[temp20]) \n\t" \
- "sh %[" #TEMP8 "], " #D "(%[temp20]) \n\t" \
- "sh %[" #TEMP12 "], " #B "(%[temp20]) \n\t"
-
-static void FTransform_MIPS32(const uint8_t* src, const uint8_t* ref,
- int16_t* out) {
- int temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7, temp8;
- int temp9, temp10, temp11, temp12, temp13, temp14, temp15, temp16;
- int temp17, temp18, temp19, temp20;
- const int c2217 = 2217;
- const int c5352 = 5352;
- const int* const args[3] =
- { (const int*)src, (const int*)ref, (const int*)out };
-
- __asm__ volatile(
- HORIZONTAL_PASS(0, temp0, temp1, temp2, temp3)
- HORIZONTAL_PASS(1, temp4, temp5, temp6, temp7)
- HORIZONTAL_PASS(2, temp8, temp9, temp10, temp11)
- HORIZONTAL_PASS(3, temp12, temp13, temp14, temp15)
- "lw %[temp20], 8(%[args]) \n\t"
- VERTICAL_PASS(0, 8, 16, 24, temp0, temp4, temp8, temp12)
- VERTICAL_PASS(2, 10, 18, 26, temp1, temp5, temp9, temp13)
- VERTICAL_PASS(4, 12, 20, 28, temp2, temp6, temp10, temp14)
- VERTICAL_PASS(6, 14, 22, 30, temp3, temp7, temp11, temp15)
-
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [temp4]"=&r"(temp4), [temp5]"=&r"(temp5),
- [temp6]"=&r"(temp6), [temp7]"=&r"(temp7), [temp8]"=&r"(temp8),
- [temp9]"=&r"(temp9), [temp10]"=&r"(temp10), [temp11]"=&r"(temp11),
- [temp12]"=&r"(temp12), [temp13]"=&r"(temp13), [temp14]"=&r"(temp14),
- [temp15]"=&r"(temp15), [temp16]"=&r"(temp16), [temp17]"=&r"(temp17),
- [temp18]"=&r"(temp18), [temp19]"=&r"(temp19), [temp20]"=&r"(temp20)
- : [args]"r"(args), [c2217]"r"(c2217), [c5352]"r"(c5352)
- : "memory", "hi", "lo"
- );
-}
-
-#undef VERTICAL_PASS
-#undef HORIZONTAL_PASS
-
-#if !defined(WORK_AROUND_GCC)
-
-#define GET_SSE_INNER(A, B, C, D) \
- "lbu %[temp0], " #A "(%[a]) \n\t" \
- "lbu %[temp1], " #A "(%[b]) \n\t" \
- "lbu %[temp2], " #B "(%[a]) \n\t" \
- "lbu %[temp3], " #B "(%[b]) \n\t" \
- "lbu %[temp4], " #C "(%[a]) \n\t" \
- "lbu %[temp5], " #C "(%[b]) \n\t" \
- "lbu %[temp6], " #D "(%[a]) \n\t" \
- "lbu %[temp7], " #D "(%[b]) \n\t" \
- "subu %[temp0], %[temp0], %[temp1] \n\t" \
- "subu %[temp2], %[temp2], %[temp3] \n\t" \
- "subu %[temp4], %[temp4], %[temp5] \n\t" \
- "subu %[temp6], %[temp6], %[temp7] \n\t" \
- "madd %[temp0], %[temp0] \n\t" \
- "madd %[temp2], %[temp2] \n\t" \
- "madd %[temp4], %[temp4] \n\t" \
- "madd %[temp6], %[temp6] \n\t"
-
-#define GET_SSE(A, B, C, D) \
- GET_SSE_INNER(A, A + 1, A + 2, A + 3) \
- GET_SSE_INNER(B, B + 1, B + 2, B + 3) \
- GET_SSE_INNER(C, C + 1, C + 2, C + 3) \
- GET_SSE_INNER(D, D + 1, D + 2, D + 3)
-
-static int SSE16x16_MIPS32(const uint8_t* a, const uint8_t* b) {
- int count;
- int temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7;
-
- __asm__ volatile(
- "mult $zero, $zero \n\t"
-
- GET_SSE( 0 * BPS, 4 + 0 * BPS, 8 + 0 * BPS, 12 + 0 * BPS)
- GET_SSE( 1 * BPS, 4 + 1 * BPS, 8 + 1 * BPS, 12 + 1 * BPS)
- GET_SSE( 2 * BPS, 4 + 2 * BPS, 8 + 2 * BPS, 12 + 2 * BPS)
- GET_SSE( 3 * BPS, 4 + 3 * BPS, 8 + 3 * BPS, 12 + 3 * BPS)
- GET_SSE( 4 * BPS, 4 + 4 * BPS, 8 + 4 * BPS, 12 + 4 * BPS)
- GET_SSE( 5 * BPS, 4 + 5 * BPS, 8 + 5 * BPS, 12 + 5 * BPS)
- GET_SSE( 6 * BPS, 4 + 6 * BPS, 8 + 6 * BPS, 12 + 6 * BPS)
- GET_SSE( 7 * BPS, 4 + 7 * BPS, 8 + 7 * BPS, 12 + 7 * BPS)
- GET_SSE( 8 * BPS, 4 + 8 * BPS, 8 + 8 * BPS, 12 + 8 * BPS)
- GET_SSE( 9 * BPS, 4 + 9 * BPS, 8 + 9 * BPS, 12 + 9 * BPS)
- GET_SSE(10 * BPS, 4 + 10 * BPS, 8 + 10 * BPS, 12 + 10 * BPS)
- GET_SSE(11 * BPS, 4 + 11 * BPS, 8 + 11 * BPS, 12 + 11 * BPS)
- GET_SSE(12 * BPS, 4 + 12 * BPS, 8 + 12 * BPS, 12 + 12 * BPS)
- GET_SSE(13 * BPS, 4 + 13 * BPS, 8 + 13 * BPS, 12 + 13 * BPS)
- GET_SSE(14 * BPS, 4 + 14 * BPS, 8 + 14 * BPS, 12 + 14 * BPS)
- GET_SSE(15 * BPS, 4 + 15 * BPS, 8 + 15 * BPS, 12 + 15 * BPS)
-
- "mflo %[count] \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [temp4]"=&r"(temp4), [temp5]"=&r"(temp5),
- [temp6]"=&r"(temp6), [temp7]"=&r"(temp7), [count]"=&r"(count)
- : [a]"r"(a), [b]"r"(b)
- : "memory", "hi", "lo"
- );
- return count;
-}
-
-static int SSE16x8_MIPS32(const uint8_t* a, const uint8_t* b) {
- int count;
- int temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7;
-
- __asm__ volatile(
- "mult $zero, $zero \n\t"
-
- GET_SSE( 0 * BPS, 4 + 0 * BPS, 8 + 0 * BPS, 12 + 0 * BPS)
- GET_SSE( 1 * BPS, 4 + 1 * BPS, 8 + 1 * BPS, 12 + 1 * BPS)
- GET_SSE( 2 * BPS, 4 + 2 * BPS, 8 + 2 * BPS, 12 + 2 * BPS)
- GET_SSE( 3 * BPS, 4 + 3 * BPS, 8 + 3 * BPS, 12 + 3 * BPS)
- GET_SSE( 4 * BPS, 4 + 4 * BPS, 8 + 4 * BPS, 12 + 4 * BPS)
- GET_SSE( 5 * BPS, 4 + 5 * BPS, 8 + 5 * BPS, 12 + 5 * BPS)
- GET_SSE( 6 * BPS, 4 + 6 * BPS, 8 + 6 * BPS, 12 + 6 * BPS)
- GET_SSE( 7 * BPS, 4 + 7 * BPS, 8 + 7 * BPS, 12 + 7 * BPS)
-
- "mflo %[count] \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [temp4]"=&r"(temp4), [temp5]"=&r"(temp5),
- [temp6]"=&r"(temp6), [temp7]"=&r"(temp7), [count]"=&r"(count)
- : [a]"r"(a), [b]"r"(b)
- : "memory", "hi", "lo"
- );
- return count;
-}
-
-static int SSE8x8_MIPS32(const uint8_t* a, const uint8_t* b) {
- int count;
- int temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7;
-
- __asm__ volatile(
- "mult $zero, $zero \n\t"
-
- GET_SSE(0 * BPS, 4 + 0 * BPS, 1 * BPS, 4 + 1 * BPS)
- GET_SSE(2 * BPS, 4 + 2 * BPS, 3 * BPS, 4 + 3 * BPS)
- GET_SSE(4 * BPS, 4 + 4 * BPS, 5 * BPS, 4 + 5 * BPS)
- GET_SSE(6 * BPS, 4 + 6 * BPS, 7 * BPS, 4 + 7 * BPS)
-
- "mflo %[count] \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [temp4]"=&r"(temp4), [temp5]"=&r"(temp5),
- [temp6]"=&r"(temp6), [temp7]"=&r"(temp7), [count]"=&r"(count)
- : [a]"r"(a), [b]"r"(b)
- : "memory", "hi", "lo"
- );
- return count;
-}
-
-static int SSE4x4_MIPS32(const uint8_t* a, const uint8_t* b) {
- int count;
- int temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7;
-
- __asm__ volatile(
- "mult $zero, $zero \n\t"
-
- GET_SSE(0 * BPS, 1 * BPS, 2 * BPS, 3 * BPS)
-
- "mflo %[count] \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [temp4]"=&r"(temp4), [temp5]"=&r"(temp5),
- [temp6]"=&r"(temp6), [temp7]"=&r"(temp7), [count]"=&r"(count)
- : [a]"r"(a), [b]"r"(b)
- : "memory", "hi", "lo"
- );
- return count;
-}
-
-#undef GET_SSE
-#undef GET_SSE_INNER
-
-#endif // !WORK_AROUND_GCC
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void VP8EncDspInitMIPS32(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void VP8EncDspInitMIPS32(void) {
- VP8ITransform = ITransform_MIPS32;
- VP8FTransform = FTransform_MIPS32;
-
- VP8EncQuantizeBlock = QuantizeBlock_MIPS32;
- VP8EncQuantize2Blocks = Quantize2Blocks_MIPS32;
-
- VP8TDisto4x4 = Disto4x4_MIPS32;
- VP8TDisto16x16 = Disto16x16_MIPS32;
-
-#if !defined(WORK_AROUND_GCC)
- VP8SSE16x16 = SSE16x16_MIPS32;
- VP8SSE8x8 = SSE8x8_MIPS32;
- VP8SSE16x8 = SSE16x8_MIPS32;
- VP8SSE4x4 = SSE4x4_MIPS32;
-#endif
-}
-
-#else // !WEBP_USE_MIPS32
-
-WEBP_DSP_INIT_STUB(VP8EncDspInitMIPS32)
-
-#endif // WEBP_USE_MIPS32
diff --git a/contrib/libs/libwebp/dsp/enc_mips_dsp_r2.c b/contrib/libs/libwebp/dsp/enc_mips_dsp_r2.c
deleted file mode 100644
index 3ee2eceeef..0000000000
--- a/contrib/libs/libwebp/dsp/enc_mips_dsp_r2.c
+++ /dev/null
@@ -1,1517 +0,0 @@
-// Copyright 2014 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// MIPS version of speed-critical encoding functions.
-//
-// Author(s): Darko Laus (darko.laus@imgtec.com)
-// Mirko Raus (mirko.raus@imgtec.com)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_MIPS_DSP_R2)
-
-#include "./mips_macro.h"
-#include "../enc/cost_enc.h"
-#include "../enc/vp8i_enc.h"
-
-static const int kC1 = 20091 + (1 << 16);
-static const int kC2 = 35468;
-
-// O - output
-// I - input (macro doesn't change it)
-#define ADD_SUB_HALVES_X4(O0, O1, O2, O3, O4, O5, O6, O7, \
- I0, I1, I2, I3, I4, I5, I6, I7) \
- "addq.ph %[" #O0 "], %[" #I0 "], %[" #I1 "] \n\t" \
- "subq.ph %[" #O1 "], %[" #I0 "], %[" #I1 "] \n\t" \
- "addq.ph %[" #O2 "], %[" #I2 "], %[" #I3 "] \n\t" \
- "subq.ph %[" #O3 "], %[" #I2 "], %[" #I3 "] \n\t" \
- "addq.ph %[" #O4 "], %[" #I4 "], %[" #I5 "] \n\t" \
- "subq.ph %[" #O5 "], %[" #I4 "], %[" #I5 "] \n\t" \
- "addq.ph %[" #O6 "], %[" #I6 "], %[" #I7 "] \n\t" \
- "subq.ph %[" #O7 "], %[" #I6 "], %[" #I7 "] \n\t"
-
-// IO - input/output
-#define ABS_X8(IO0, IO1, IO2, IO3, IO4, IO5, IO6, IO7) \
- "absq_s.ph %[" #IO0 "], %[" #IO0 "] \n\t" \
- "absq_s.ph %[" #IO1 "], %[" #IO1 "] \n\t" \
- "absq_s.ph %[" #IO2 "], %[" #IO2 "] \n\t" \
- "absq_s.ph %[" #IO3 "], %[" #IO3 "] \n\t" \
- "absq_s.ph %[" #IO4 "], %[" #IO4 "] \n\t" \
- "absq_s.ph %[" #IO5 "], %[" #IO5 "] \n\t" \
- "absq_s.ph %[" #IO6 "], %[" #IO6 "] \n\t" \
- "absq_s.ph %[" #IO7 "], %[" #IO7 "] \n\t"
-
-// dpa.w.ph $ac0 temp0 ,temp1
-// $ac += temp0[31..16] * temp1[31..16] + temp0[15..0] * temp1[15..0]
-// dpax.w.ph $ac0 temp0 ,temp1
-// $ac += temp0[31..16] * temp1[15..0] + temp0[15..0] * temp1[31..16]
-// O - output
-// I - input (macro doesn't change it)
-#define MUL_HALF(O0, I0, I1, I2, I3, I4, I5, I6, I7, \
- I8, I9, I10, I11, I12, I13, I14, I15) \
- "mult $ac0, $zero, $zero \n\t" \
- "dpa.w.ph $ac0, %[" #I2 "], %[" #I0 "] \n\t" \
- "dpax.w.ph $ac0, %[" #I5 "], %[" #I6 "] \n\t" \
- "dpa.w.ph $ac0, %[" #I8 "], %[" #I9 "] \n\t" \
- "dpax.w.ph $ac0, %[" #I11 "], %[" #I4 "] \n\t" \
- "dpa.w.ph $ac0, %[" #I12 "], %[" #I7 "] \n\t" \
- "dpax.w.ph $ac0, %[" #I13 "], %[" #I1 "] \n\t" \
- "dpa.w.ph $ac0, %[" #I14 "], %[" #I3 "] \n\t" \
- "dpax.w.ph $ac0, %[" #I15 "], %[" #I10 "] \n\t" \
- "mflo %[" #O0 "], $ac0 \n\t"
-
-#define OUTPUT_EARLY_CLOBBER_REGS_17() \
- OUTPUT_EARLY_CLOBBER_REGS_10(), \
- [temp11]"=&r"(temp11), [temp12]"=&r"(temp12), [temp13]"=&r"(temp13), \
- [temp14]"=&r"(temp14), [temp15]"=&r"(temp15), [temp16]"=&r"(temp16), \
- [temp17]"=&r"(temp17)
-
-// macro for one horizontal pass in FTransform
-// temp0..temp15 holds tmp[0]..tmp[15]
-// A - offset in bytes to load from src and ref buffers
-// TEMP0..TEMP3 - registers for corresponding tmp elements
-#define HORIZONTAL_PASS(A, TEMP0, TEMP1, TEMP2, TEMP3) \
- "lw %[" #TEMP0 "], 0(%[args]) \n\t" \
- "lw %[" #TEMP1 "], 4(%[args]) \n\t" \
- "lw %[" #TEMP2 "], " XSTR(BPS) "*" #A "(%[" #TEMP0 "]) \n\t" \
- "lw %[" #TEMP3 "], " XSTR(BPS) "*" #A "(%[" #TEMP1 "]) \n\t" \
- "preceu.ph.qbl %[" #TEMP0 "], %[" #TEMP2 "] \n\t" \
- "preceu.ph.qbl %[" #TEMP1 "], %[" #TEMP3 "] \n\t" \
- "preceu.ph.qbr %[" #TEMP2 "], %[" #TEMP2 "] \n\t" \
- "preceu.ph.qbr %[" #TEMP3 "], %[" #TEMP3 "] \n\t" \
- "subq.ph %[" #TEMP0 "], %[" #TEMP0 "], %[" #TEMP1 "] \n\t" \
- "subq.ph %[" #TEMP2 "], %[" #TEMP2 "], %[" #TEMP3 "] \n\t" \
- "rotr %[" #TEMP0 "], %[" #TEMP0 "], 16 \n\t" \
- "addq.ph %[" #TEMP1 "], %[" #TEMP2 "], %[" #TEMP0 "] \n\t" \
- "subq.ph %[" #TEMP3 "], %[" #TEMP2 "], %[" #TEMP0 "] \n\t" \
- "seh %[" #TEMP0 "], %[" #TEMP1 "] \n\t" \
- "sra %[temp16], %[" #TEMP1 "], 16 \n\t" \
- "seh %[temp19], %[" #TEMP3 "] \n\t" \
- "sra %[" #TEMP3 "], %[" #TEMP3 "], 16 \n\t" \
- "subu %[" #TEMP2 "], %[" #TEMP0 "], %[temp16] \n\t" \
- "addu %[" #TEMP0 "], %[" #TEMP0 "], %[temp16] \n\t" \
- "mul %[temp17], %[temp19], %[c2217] \n\t" \
- "mul %[temp18], %[" #TEMP3 "], %[c5352] \n\t" \
- "mul %[" #TEMP1 "], %[temp19], %[c5352] \n\t" \
- "mul %[temp16], %[" #TEMP3 "], %[c2217] \n\t" \
- "sll %[" #TEMP2 "], %[" #TEMP2 "], 3 \n\t" \
- "sll %[" #TEMP0 "], %[" #TEMP0 "], 3 \n\t" \
- "subu %[" #TEMP3 "], %[temp17], %[temp18] \n\t" \
- "addu %[" #TEMP1 "], %[temp16], %[" #TEMP1 "] \n\t" \
- "addiu %[" #TEMP3 "], %[" #TEMP3 "], 937 \n\t" \
- "addiu %[" #TEMP1 "], %[" #TEMP1 "], 1812 \n\t" \
- "sra %[" #TEMP3 "], %[" #TEMP3 "], 9 \n\t" \
- "sra %[" #TEMP1 "], %[" #TEMP1 "], 9 \n\t"
-
-// macro for one vertical pass in FTransform
-// temp0..temp15 holds tmp[0]..tmp[15]
-// A..D - offsets in bytes to store to out buffer
-// TEMP0, TEMP4, TEMP8 and TEMP12 - registers for corresponding tmp elements
-#define VERTICAL_PASS(A, B, C, D, TEMP0, TEMP4, TEMP8, TEMP12) \
- "addu %[temp16], %[" #TEMP0 "], %[" #TEMP12 "] \n\t" \
- "subu %[temp19], %[" #TEMP0 "], %[" #TEMP12 "] \n\t" \
- "addu %[temp17], %[" #TEMP4 "], %[" #TEMP8 "] \n\t" \
- "subu %[temp18], %[" #TEMP4 "], %[" #TEMP8 "] \n\t" \
- "mul %[" #TEMP8 "], %[temp19], %[c2217] \n\t" \
- "mul %[" #TEMP12 "], %[temp18], %[c2217] \n\t" \
- "mul %[" #TEMP4 "], %[temp19], %[c5352] \n\t" \
- "mul %[temp18], %[temp18], %[c5352] \n\t" \
- "addiu %[temp16], %[temp16], 7 \n\t" \
- "addu %[" #TEMP0 "], %[temp16], %[temp17] \n\t" \
- "sra %[" #TEMP0 "], %[" #TEMP0 "], 4 \n\t" \
- "addu %[" #TEMP12 "], %[" #TEMP12 "], %[" #TEMP4 "] \n\t" \
- "subu %[" #TEMP4 "], %[temp16], %[temp17] \n\t" \
- "sra %[" #TEMP4 "], %[" #TEMP4 "], 4 \n\t" \
- "addiu %[" #TEMP8 "], %[" #TEMP8 "], 30000 \n\t" \
- "addiu %[" #TEMP12 "], %[" #TEMP12 "], 12000 \n\t" \
- "addiu %[" #TEMP8 "], %[" #TEMP8 "], 21000 \n\t" \
- "subu %[" #TEMP8 "], %[" #TEMP8 "], %[temp18] \n\t" \
- "sra %[" #TEMP12 "], %[" #TEMP12 "], 16 \n\t" \
- "sra %[" #TEMP8 "], %[" #TEMP8 "], 16 \n\t" \
- "addiu %[temp16], %[" #TEMP12 "], 1 \n\t" \
- "movn %[" #TEMP12 "], %[temp16], %[temp19] \n\t" \
- "sh %[" #TEMP0 "], " #A "(%[temp20]) \n\t" \
- "sh %[" #TEMP4 "], " #C "(%[temp20]) \n\t" \
- "sh %[" #TEMP8 "], " #D "(%[temp20]) \n\t" \
- "sh %[" #TEMP12 "], " #B "(%[temp20]) \n\t"
-
-static void FTransform_MIPSdspR2(const uint8_t* src, const uint8_t* ref,
- int16_t* out) {
- const int c2217 = 2217;
- const int c5352 = 5352;
- int temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7, temp8;
- int temp9, temp10, temp11, temp12, temp13, temp14, temp15, temp16;
- int temp17, temp18, temp19, temp20;
- const int* const args[3] =
- { (const int*)src, (const int*)ref, (const int*)out };
-
- __asm__ volatile (
- HORIZONTAL_PASS(0, temp0, temp1, temp2, temp3)
- HORIZONTAL_PASS(1, temp4, temp5, temp6, temp7)
- HORIZONTAL_PASS(2, temp8, temp9, temp10, temp11)
- HORIZONTAL_PASS(3, temp12, temp13, temp14, temp15)
- "lw %[temp20], 8(%[args]) \n\t"
- VERTICAL_PASS(0, 8, 16, 24, temp0, temp4, temp8, temp12)
- VERTICAL_PASS(2, 10, 18, 26, temp1, temp5, temp9, temp13)
- VERTICAL_PASS(4, 12, 20, 28, temp2, temp6, temp10, temp14)
- VERTICAL_PASS(6, 14, 22, 30, temp3, temp7, temp11, temp15)
- OUTPUT_EARLY_CLOBBER_REGS_18(),
- [temp0]"=&r"(temp0), [temp19]"=&r"(temp19), [temp20]"=&r"(temp20)
- : [args]"r"(args), [c2217]"r"(c2217), [c5352]"r"(c5352)
- : "memory", "hi", "lo"
- );
-}
-
-#undef VERTICAL_PASS
-#undef HORIZONTAL_PASS
-
-static WEBP_INLINE void ITransformOne(const uint8_t* ref, const int16_t* in,
- uint8_t* dst) {
- int temp1, temp2, temp3, temp4, temp5, temp6, temp7, temp8, temp9;
- int temp10, temp11, temp12, temp13, temp14, temp15, temp16, temp17, temp18;
-
- __asm__ volatile (
- "ulw %[temp1], 0(%[in]) \n\t"
- "ulw %[temp2], 16(%[in]) \n\t"
- LOAD_IN_X2(temp5, temp6, 24, 26)
- ADD_SUB_HALVES(temp3, temp4, temp1, temp2)
- LOAD_IN_X2(temp1, temp2, 8, 10)
- MUL_SHIFT_SUM(temp7, temp8, temp9, temp10, temp11, temp12, temp13, temp14,
- temp10, temp8, temp9, temp7, temp1, temp2, temp5, temp6,
- temp13, temp11, temp14, temp12)
- INSERT_HALF_X2(temp8, temp7, temp10, temp9)
- "ulw %[temp17], 4(%[in]) \n\t"
- "ulw %[temp18], 20(%[in]) \n\t"
- ADD_SUB_HALVES(temp1, temp2, temp3, temp8)
- ADD_SUB_HALVES(temp5, temp6, temp4, temp7)
- ADD_SUB_HALVES(temp7, temp8, temp17, temp18)
- LOAD_IN_X2(temp17, temp18, 12, 14)
- LOAD_IN_X2(temp9, temp10, 28, 30)
- MUL_SHIFT_SUM(temp11, temp12, temp13, temp14, temp15, temp16, temp4, temp17,
- temp12, temp14, temp11, temp13, temp17, temp18, temp9, temp10,
- temp15, temp4, temp16, temp17)
- INSERT_HALF_X2(temp11, temp12, temp13, temp14)
- ADD_SUB_HALVES(temp17, temp8, temp8, temp11)
- ADD_SUB_HALVES(temp3, temp4, temp7, temp12)
-
- // horizontal
- SRA_16(temp9, temp10, temp11, temp12, temp1, temp2, temp5, temp6)
- INSERT_HALF_X2(temp1, temp6, temp5, temp2)
- SRA_16(temp13, temp14, temp15, temp16, temp3, temp4, temp17, temp8)
- "repl.ph %[temp2], 0x4 \n\t"
- INSERT_HALF_X2(temp3, temp8, temp17, temp4)
- "addq.ph %[temp1], %[temp1], %[temp2] \n\t"
- "addq.ph %[temp6], %[temp6], %[temp2] \n\t"
- ADD_SUB_HALVES(temp2, temp4, temp1, temp3)
- ADD_SUB_HALVES(temp5, temp7, temp6, temp8)
- MUL_SHIFT_SUM(temp1, temp3, temp6, temp8, temp9, temp13, temp17, temp18,
- temp3, temp13, temp1, temp9, temp9, temp13, temp11, temp15,
- temp6, temp17, temp8, temp18)
- MUL_SHIFT_SUM(temp6, temp8, temp18, temp17, temp11, temp15, temp12, temp16,
- temp8, temp15, temp6, temp11, temp12, temp16, temp10, temp14,
- temp18, temp12, temp17, temp16)
- INSERT_HALF_X2(temp1, temp3, temp9, temp13)
- INSERT_HALF_X2(temp6, temp8, temp11, temp15)
- SHIFT_R_SUM_X2(temp9, temp10, temp11, temp12, temp13, temp14, temp15,
- temp16, temp2, temp4, temp5, temp7, temp3, temp1, temp8,
- temp6)
- PACK_2_HALVES_TO_WORD(temp1, temp2, temp3, temp4, temp9, temp12, temp13,
- temp16, temp11, temp10, temp15, temp14)
- LOAD_WITH_OFFSET_X4(temp10, temp11, temp14, temp15, ref,
- 0, 0, 0, 0,
- 0, 1, 2, 3,
- BPS)
- CONVERT_2_BYTES_TO_HALF(temp5, temp6, temp7, temp8, temp17, temp18, temp10,
- temp11, temp10, temp11, temp14, temp15)
- STORE_SAT_SUM_X2(temp5, temp6, temp7, temp8, temp17, temp18, temp10, temp11,
- temp9, temp12, temp1, temp2, temp13, temp16, temp3, temp4,
- dst, 0, 1, 2, 3, BPS)
-
- OUTPUT_EARLY_CLOBBER_REGS_18()
- : [dst]"r"(dst), [in]"r"(in), [kC1]"r"(kC1), [kC2]"r"(kC2), [ref]"r"(ref)
- : "memory", "hi", "lo"
- );
-}
-
-static void ITransform_MIPSdspR2(const uint8_t* ref, const int16_t* in,
- uint8_t* dst, int do_two) {
- ITransformOne(ref, in, dst);
- if (do_two) {
- ITransformOne(ref + 4, in + 16, dst + 4);
- }
-}
-
-static int Disto4x4_MIPSdspR2(const uint8_t* const a, const uint8_t* const b,
- const uint16_t* const w) {
- int temp1, temp2, temp3, temp4, temp5, temp6, temp7, temp8, temp9;
- int temp10, temp11, temp12, temp13, temp14, temp15, temp16, temp17;
-
- __asm__ volatile (
- LOAD_WITH_OFFSET_X4(temp1, temp2, temp3, temp4, a,
- 0, 0, 0, 0,
- 0, 1, 2, 3,
- BPS)
- CONVERT_2_BYTES_TO_HALF(temp5, temp6, temp7, temp8, temp9,temp10, temp11,
- temp12, temp1, temp2, temp3, temp4)
- ADD_SUB_HALVES_X4(temp1, temp2, temp3, temp4, temp5, temp6, temp7, temp8,
- temp5, temp6, temp7, temp8, temp9, temp10, temp11, temp12)
- PACK_2_HALVES_TO_WORD(temp9, temp10, temp11, temp12, temp1, temp3, temp5,
- temp7, temp2, temp4, temp6, temp8)
- ADD_SUB_HALVES_X4(temp2, temp4, temp6, temp8, temp9, temp1, temp3, temp10,
- temp1, temp9, temp3, temp10, temp5, temp11, temp7, temp12)
- ADD_SUB_HALVES_X4(temp5, temp11, temp7, temp2, temp9, temp3, temp6, temp12,
- temp2, temp9, temp6, temp3, temp4, temp1, temp8, temp10)
- ADD_SUB_HALVES_X4(temp1, temp4, temp10, temp8, temp7, temp11, temp5, temp2,
- temp5, temp7, temp11, temp2, temp9, temp6, temp3, temp12)
- ABS_X8(temp1, temp4, temp10, temp8, temp7, temp11, temp5, temp2)
- LOAD_WITH_OFFSET_X4(temp3, temp6, temp9, temp12, w,
- 0, 4, 8, 12,
- 0, 0, 0, 0,
- 0)
- LOAD_WITH_OFFSET_X4(temp13, temp14, temp15, temp16, w,
- 0, 4, 8, 12,
- 1, 1, 1, 1,
- 16)
- MUL_HALF(temp17, temp1, temp2, temp3, temp4, temp5, temp6, temp7, temp8,
- temp9, temp10, temp11, temp12, temp13, temp14, temp15, temp16)
- LOAD_WITH_OFFSET_X4(temp1, temp2, temp3, temp4, b,
- 0, 0, 0, 0,
- 0, 1, 2, 3,
- BPS)
- CONVERT_2_BYTES_TO_HALF(temp5,temp6, temp7, temp8, temp9,temp10, temp11,
- temp12, temp1, temp2, temp3, temp4)
- ADD_SUB_HALVES_X4(temp1, temp2, temp3, temp4, temp5, temp6, temp7, temp8,
- temp5, temp6, temp7, temp8, temp9, temp10, temp11, temp12)
- PACK_2_HALVES_TO_WORD(temp9, temp10, temp11, temp12, temp1, temp3, temp5,
- temp7, temp2, temp4, temp6, temp8)
- ADD_SUB_HALVES_X4(temp2, temp4, temp6, temp8, temp9, temp1, temp3, temp10,
- temp1, temp9, temp3, temp10, temp5, temp11, temp7, temp12)
- ADD_SUB_HALVES_X4(temp5, temp11, temp7, temp2, temp9, temp3, temp6, temp12,
- temp2, temp9, temp6, temp3, temp4, temp1, temp8, temp10)
- ADD_SUB_HALVES_X4(temp1, temp4, temp10, temp8, temp7, temp11, temp5, temp2,
- temp5, temp7, temp11, temp2, temp9, temp6, temp3, temp12)
- ABS_X8(temp1, temp4, temp10, temp8, temp7, temp11, temp5, temp2)
- LOAD_WITH_OFFSET_X4(temp3, temp6, temp9, temp12, w,
- 0, 4, 8, 12,
- 0, 0, 0, 0,
- 0)
- LOAD_WITH_OFFSET_X4(temp13, temp14, temp15, temp16, w,
- 0, 4, 8, 12,
- 1, 1, 1, 1,
- 16)
- MUL_HALF(temp3, temp1, temp2, temp3, temp4, temp5, temp6, temp7, temp8,
- temp9, temp10, temp11, temp12, temp13, temp14, temp15, temp16)
- OUTPUT_EARLY_CLOBBER_REGS_17()
- : [a]"r"(a), [b]"r"(b), [w]"r"(w)
- : "memory", "hi", "lo"
- );
- return abs(temp3 - temp17) >> 5;
-}
-
-static int Disto16x16_MIPSdspR2(const uint8_t* const a,
- const uint8_t* const b,
- const uint16_t* const w) {
- int D = 0;
- int x, y;
- for (y = 0; y < 16 * BPS; y += 4 * BPS) {
- for (x = 0; x < 16; x += 4) {
- D += Disto4x4_MIPSdspR2(a + x + y, b + x + y, w);
- }
- }
- return D;
-}
-
-//------------------------------------------------------------------------------
-// Intra predictions
-
-#define FILL_PART(J, SIZE) \
- "usw %[value], 0+" #J "*" XSTR(BPS) "(%[dst]) \n\t" \
- "usw %[value], 4+" #J "*" XSTR(BPS) "(%[dst]) \n\t" \
- ".if " #SIZE " == 16 \n\t" \
- "usw %[value], 8+" #J "*" XSTR(BPS) "(%[dst]) \n\t" \
- "usw %[value], 12+" #J "*" XSTR(BPS) "(%[dst]) \n\t" \
- ".endif \n\t"
-
-#define FILL_8_OR_16(DST, VALUE, SIZE) do { \
- int value = (VALUE); \
- __asm__ volatile ( \
- "replv.qb %[value], %[value] \n\t" \
- FILL_PART( 0, SIZE) \
- FILL_PART( 1, SIZE) \
- FILL_PART( 2, SIZE) \
- FILL_PART( 3, SIZE) \
- FILL_PART( 4, SIZE) \
- FILL_PART( 5, SIZE) \
- FILL_PART( 6, SIZE) \
- FILL_PART( 7, SIZE) \
- ".if " #SIZE " == 16 \n\t" \
- FILL_PART( 8, 16) \
- FILL_PART( 9, 16) \
- FILL_PART(10, 16) \
- FILL_PART(11, 16) \
- FILL_PART(12, 16) \
- FILL_PART(13, 16) \
- FILL_PART(14, 16) \
- FILL_PART(15, 16) \
- ".endif \n\t" \
- : [value]"+&r"(value) \
- : [dst]"r"((DST)) \
- : "memory" \
- ); \
-} while (0)
-
-#define VERTICAL_PRED(DST, TOP, SIZE) \
-static WEBP_INLINE void VerticalPred##SIZE(uint8_t* (DST), \
- const uint8_t* (TOP)) { \
- int j; \
- if ((TOP)) { \
- for (j = 0; j < (SIZE); ++j) memcpy((DST) + j * BPS, (TOP), (SIZE)); \
- } else { \
- FILL_8_OR_16((DST), 127, (SIZE)); \
- } \
-}
-
-VERTICAL_PRED(dst, top, 8)
-VERTICAL_PRED(dst, top, 16)
-
-#undef VERTICAL_PRED
-
-#define HORIZONTAL_PRED(DST, LEFT, SIZE) \
-static WEBP_INLINE void HorizontalPred##SIZE(uint8_t* (DST), \
- const uint8_t* (LEFT)) { \
- if (LEFT) { \
- int j; \
- for (j = 0; j < (SIZE); ++j) { \
- memset((DST) + j * BPS, (LEFT)[j], (SIZE)); \
- } \
- } else { \
- FILL_8_OR_16((DST), 129, (SIZE)); \
- } \
-}
-
-HORIZONTAL_PRED(dst, left, 8)
-HORIZONTAL_PRED(dst, left, 16)
-
-#undef HORIZONTAL_PRED
-
-#define CLIPPING() \
- "preceu.ph.qbl %[temp2], %[temp0] \n\t" \
- "preceu.ph.qbr %[temp0], %[temp0] \n\t" \
- "preceu.ph.qbl %[temp3], %[temp1] \n\t" \
- "preceu.ph.qbr %[temp1], %[temp1] \n\t" \
- "addu.ph %[temp2], %[temp2], %[leftY_1] \n\t" \
- "addu.ph %[temp0], %[temp0], %[leftY_1] \n\t" \
- "addu.ph %[temp3], %[temp3], %[leftY_1] \n\t" \
- "addu.ph %[temp1], %[temp1], %[leftY_1] \n\t" \
- "shll_s.ph %[temp2], %[temp2], 7 \n\t" \
- "shll_s.ph %[temp0], %[temp0], 7 \n\t" \
- "shll_s.ph %[temp3], %[temp3], 7 \n\t" \
- "shll_s.ph %[temp1], %[temp1], 7 \n\t" \
- "precrqu_s.qb.ph %[temp0], %[temp2], %[temp0] \n\t" \
- "precrqu_s.qb.ph %[temp1], %[temp3], %[temp1] \n\t"
-
-#define CLIP_8B_TO_DST(DST, LEFT, TOP, SIZE) do { \
- int leftY_1 = ((int)(LEFT)[y] << 16) + (LEFT)[y]; \
- int temp0, temp1, temp2, temp3; \
- __asm__ volatile ( \
- "replv.ph %[leftY_1], %[leftY_1] \n\t" \
- "ulw %[temp0], 0(%[top]) \n\t" \
- "ulw %[temp1], 4(%[top]) \n\t" \
- "subu.ph %[leftY_1], %[leftY_1], %[left_1] \n\t" \
- CLIPPING() \
- "usw %[temp0], 0(%[dst]) \n\t" \
- "usw %[temp1], 4(%[dst]) \n\t" \
- ".if " #SIZE " == 16 \n\t" \
- "ulw %[temp0], 8(%[top]) \n\t" \
- "ulw %[temp1], 12(%[top]) \n\t" \
- CLIPPING() \
- "usw %[temp0], 8(%[dst]) \n\t" \
- "usw %[temp1], 12(%[dst]) \n\t" \
- ".endif \n\t" \
- : [leftY_1]"+&r"(leftY_1), [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), \
- [temp2]"=&r"(temp2), [temp3]"=&r"(temp3) \
- : [left_1]"r"(left_1), [top]"r"((TOP)), [dst]"r"((DST)) \
- : "memory" \
- ); \
-} while (0)
-
-#define CLIP_TO_DST(DST, LEFT, TOP, SIZE) do { \
- int y; \
- const int left_1 = ((int)(LEFT)[-1] << 16) + (LEFT)[-1]; \
- for (y = 0; y < (SIZE); ++y) { \
- CLIP_8B_TO_DST((DST), (LEFT), (TOP), (SIZE)); \
- (DST) += BPS; \
- } \
-} while (0)
-
-#define TRUE_MOTION(DST, LEFT, TOP, SIZE) \
-static WEBP_INLINE void TrueMotion##SIZE(uint8_t* (DST), const uint8_t* (LEFT),\
- const uint8_t* (TOP)) { \
- if ((LEFT) != NULL) { \
- if ((TOP) != NULL) { \
- CLIP_TO_DST((DST), (LEFT), (TOP), (SIZE)); \
- } else { \
- HorizontalPred##SIZE((DST), (LEFT)); \
- } \
- } else { \
- /* true motion without left samples (hence: with default 129 value) */ \
- /* is equivalent to VE prediction where you just copy the top samples. */ \
- /* Note that if top samples are not available, the default value is */ \
- /* then 129, and not 127 as in the VerticalPred case. */ \
- if ((TOP) != NULL) { \
- VerticalPred##SIZE((DST), (TOP)); \
- } else { \
- FILL_8_OR_16((DST), 129, (SIZE)); \
- } \
- } \
-}
-
-TRUE_MOTION(dst, left, top, 8)
-TRUE_MOTION(dst, left, top, 16)
-
-#undef TRUE_MOTION
-#undef CLIP_TO_DST
-#undef CLIP_8B_TO_DST
-#undef CLIPPING
-
-static WEBP_INLINE void DCMode16(uint8_t* dst, const uint8_t* left,
- const uint8_t* top) {
- int DC, DC1;
- int temp0, temp1, temp2, temp3;
-
- __asm__ volatile(
- "beqz %[top], 2f \n\t"
- LOAD_WITH_OFFSET_X4(temp0, temp1, temp2, temp3, top,
- 0, 4, 8, 12,
- 0, 0, 0, 0,
- 0)
- "raddu.w.qb %[temp0], %[temp0] \n\t"
- "raddu.w.qb %[temp1], %[temp1] \n\t"
- "raddu.w.qb %[temp2], %[temp2] \n\t"
- "raddu.w.qb %[temp3], %[temp3] \n\t"
- "addu %[temp0], %[temp0], %[temp1] \n\t"
- "addu %[temp2], %[temp2], %[temp3] \n\t"
- "addu %[DC], %[temp0], %[temp2] \n\t"
- "move %[DC1], %[DC] \n\t"
- "beqz %[left], 1f \n\t"
- LOAD_WITH_OFFSET_X4(temp0, temp1, temp2, temp3, left,
- 0, 4, 8, 12,
- 0, 0, 0, 0,
- 0)
- "raddu.w.qb %[temp0], %[temp0] \n\t"
- "raddu.w.qb %[temp1], %[temp1] \n\t"
- "raddu.w.qb %[temp2], %[temp2] \n\t"
- "raddu.w.qb %[temp3], %[temp3] \n\t"
- "addu %[temp0], %[temp0], %[temp1] \n\t"
- "addu %[temp2], %[temp2], %[temp3] \n\t"
- "addu %[DC1], %[temp0], %[temp2] \n\t"
- "1: \n\t"
- "addu %[DC], %[DC], %[DC1] \n\t"
- "j 3f \n\t"
- "2: \n\t"
- "beqz %[left], 4f \n\t"
- LOAD_WITH_OFFSET_X4(temp0, temp1, temp2, temp3, left,
- 0, 4, 8, 12,
- 0, 0, 0, 0,
- 0)
- "raddu.w.qb %[temp0], %[temp0] \n\t"
- "raddu.w.qb %[temp1], %[temp1] \n\t"
- "raddu.w.qb %[temp2], %[temp2] \n\t"
- "raddu.w.qb %[temp3], %[temp3] \n\t"
- "addu %[temp0], %[temp0], %[temp1] \n\t"
- "addu %[temp2], %[temp2], %[temp3] \n\t"
- "addu %[DC], %[temp0], %[temp2] \n\t"
- "addu %[DC], %[DC], %[DC] \n\t"
- "3: \n\t"
- "shra_r.w %[DC], %[DC], 5 \n\t"
- "j 5f \n\t"
- "4: \n\t"
- "li %[DC], 0x80 \n\t"
- "5: \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [DC]"=&r"(DC),
- [temp2]"=&r"(temp2), [temp3]"=&r"(temp3), [DC1]"=&r"(DC1)
- : [left]"r"(left), [top]"r"(top)
- : "memory"
- );
-
- FILL_8_OR_16(dst, DC, 16);
-}
-
-static WEBP_INLINE void DCMode8(uint8_t* dst, const uint8_t* left,
- const uint8_t* top) {
- int DC, DC1;
- int temp0, temp1, temp2, temp3;
-
- __asm__ volatile(
- "beqz %[top], 2f \n\t"
- "ulw %[temp0], 0(%[top]) \n\t"
- "ulw %[temp1], 4(%[top]) \n\t"
- "raddu.w.qb %[temp0], %[temp0] \n\t"
- "raddu.w.qb %[temp1], %[temp1] \n\t"
- "addu %[DC], %[temp0], %[temp1] \n\t"
- "move %[DC1], %[DC] \n\t"
- "beqz %[left], 1f \n\t"
- "ulw %[temp2], 0(%[left]) \n\t"
- "ulw %[temp3], 4(%[left]) \n\t"
- "raddu.w.qb %[temp2], %[temp2] \n\t"
- "raddu.w.qb %[temp3], %[temp3] \n\t"
- "addu %[DC1], %[temp2], %[temp3] \n\t"
- "1: \n\t"
- "addu %[DC], %[DC], %[DC1] \n\t"
- "j 3f \n\t"
- "2: \n\t"
- "beqz %[left], 4f \n\t"
- "ulw %[temp2], 0(%[left]) \n\t"
- "ulw %[temp3], 4(%[left]) \n\t"
- "raddu.w.qb %[temp2], %[temp2] \n\t"
- "raddu.w.qb %[temp3], %[temp3] \n\t"
- "addu %[DC], %[temp2], %[temp3] \n\t"
- "addu %[DC], %[DC], %[DC] \n\t"
- "3: \n\t"
- "shra_r.w %[DC], %[DC], 4 \n\t"
- "j 5f \n\t"
- "4: \n\t"
- "li %[DC], 0x80 \n\t"
- "5: \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [DC]"=&r"(DC),
- [temp2]"=&r"(temp2), [temp3]"=&r"(temp3), [DC1]"=&r"(DC1)
- : [left]"r"(left), [top]"r"(top)
- : "memory"
- );
-
- FILL_8_OR_16(dst, DC, 8);
-}
-
-static void DC4(uint8_t* dst, const uint8_t* top) {
- int temp0, temp1;
- __asm__ volatile(
- "ulw %[temp0], 0(%[top]) \n\t"
- "ulw %[temp1], -5(%[top]) \n\t"
- "raddu.w.qb %[temp0], %[temp0] \n\t"
- "raddu.w.qb %[temp1], %[temp1] \n\t"
- "addu %[temp0], %[temp0], %[temp1] \n\t"
- "addiu %[temp0], %[temp0], 4 \n\t"
- "srl %[temp0], %[temp0], 3 \n\t"
- "replv.qb %[temp0], %[temp0] \n\t"
- "usw %[temp0], 0*" XSTR(BPS) "(%[dst]) \n\t"
- "usw %[temp0], 1*" XSTR(BPS) "(%[dst]) \n\t"
- "usw %[temp0], 2*" XSTR(BPS) "(%[dst]) \n\t"
- "usw %[temp0], 3*" XSTR(BPS) "(%[dst]) \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1)
- : [top]"r"(top), [dst]"r"(dst)
- : "memory"
- );
-}
-
-static void TM4(uint8_t* dst, const uint8_t* top) {
- int a10, a32, temp0, temp1, temp2, temp3, temp4, temp5;
- const int c35 = 0xff00ff;
- __asm__ volatile (
- "lbu %[temp1], 0(%[top]) \n\t"
- "lbu %[a10], 1(%[top]) \n\t"
- "lbu %[temp2], 2(%[top]) \n\t"
- "lbu %[a32], 3(%[top]) \n\t"
- "ulw %[temp0], -5(%[top]) \n\t"
- "lbu %[temp4], -1(%[top]) \n\t"
- "append %[a10], %[temp1], 16 \n\t"
- "append %[a32], %[temp2], 16 \n\t"
- "replv.ph %[temp4], %[temp4] \n\t"
- "shrl.ph %[temp1], %[temp0], 8 \n\t"
- "and %[temp0], %[temp0], %[c35] \n\t"
- "subu.ph %[temp1], %[temp1], %[temp4] \n\t"
- "subu.ph %[temp0], %[temp0], %[temp4] \n\t"
- "srl %[temp2], %[temp1], 16 \n\t"
- "srl %[temp3], %[temp0], 16 \n\t"
- "replv.ph %[temp2], %[temp2] \n\t"
- "replv.ph %[temp3], %[temp3] \n\t"
- "replv.ph %[temp4], %[temp1] \n\t"
- "replv.ph %[temp5], %[temp0] \n\t"
- "addu.ph %[temp0], %[temp3], %[a10] \n\t"
- "addu.ph %[temp1], %[temp3], %[a32] \n\t"
- "addu.ph %[temp3], %[temp2], %[a10] \n\t"
- "addu.ph %[temp2], %[temp2], %[a32] \n\t"
- "shll_s.ph %[temp0], %[temp0], 7 \n\t"
- "shll_s.ph %[temp1], %[temp1], 7 \n\t"
- "shll_s.ph %[temp3], %[temp3], 7 \n\t"
- "shll_s.ph %[temp2], %[temp2], 7 \n\t"
- "precrqu_s.qb.ph %[temp0], %[temp1], %[temp0] \n\t"
- "precrqu_s.qb.ph %[temp1], %[temp2], %[temp3] \n\t"
- "addu.ph %[temp2], %[temp5], %[a10] \n\t"
- "addu.ph %[temp3], %[temp5], %[a32] \n\t"
- "addu.ph %[temp5], %[temp4], %[a10] \n\t"
- "addu.ph %[temp4], %[temp4], %[a32] \n\t"
- "shll_s.ph %[temp2], %[temp2], 7 \n\t"
- "shll_s.ph %[temp3], %[temp3], 7 \n\t"
- "shll_s.ph %[temp4], %[temp4], 7 \n\t"
- "shll_s.ph %[temp5], %[temp5], 7 \n\t"
- "precrqu_s.qb.ph %[temp2], %[temp3], %[temp2] \n\t"
- "precrqu_s.qb.ph %[temp3], %[temp4], %[temp5] \n\t"
- "usw %[temp1], 0*" XSTR(BPS) "(%[dst]) \n\t"
- "usw %[temp0], 1*" XSTR(BPS) "(%[dst]) \n\t"
- "usw %[temp3], 2*" XSTR(BPS) "(%[dst]) \n\t"
- "usw %[temp2], 3*" XSTR(BPS) "(%[dst]) \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [temp4]"=&r"(temp4), [temp5]"=&r"(temp5),
- [a10]"=&r"(a10), [a32]"=&r"(a32)
- : [c35]"r"(c35), [top]"r"(top), [dst]"r"(dst)
- : "memory"
- );
-}
-
-static void VE4(uint8_t* dst, const uint8_t* top) {
- int temp0, temp1, temp2, temp3, temp4, temp5, temp6;
- __asm__ volatile(
- "ulw %[temp0], -1(%[top]) \n\t"
- "ulh %[temp1], 3(%[top]) \n\t"
- "preceu.ph.qbr %[temp2], %[temp0] \n\t"
- "preceu.ph.qbl %[temp3], %[temp0] \n\t"
- "preceu.ph.qbr %[temp4], %[temp1] \n\t"
- "packrl.ph %[temp5], %[temp3], %[temp2] \n\t"
- "packrl.ph %[temp6], %[temp4], %[temp3] \n\t"
- "shll.ph %[temp5], %[temp5], 1 \n\t"
- "shll.ph %[temp6], %[temp6], 1 \n\t"
- "addq.ph %[temp2], %[temp5], %[temp2] \n\t"
- "addq.ph %[temp6], %[temp6], %[temp4] \n\t"
- "addq.ph %[temp2], %[temp2], %[temp3] \n\t"
- "addq.ph %[temp6], %[temp6], %[temp3] \n\t"
- "shra_r.ph %[temp2], %[temp2], 2 \n\t"
- "shra_r.ph %[temp6], %[temp6], 2 \n\t"
- "precr.qb.ph %[temp4], %[temp6], %[temp2] \n\t"
- "usw %[temp4], 0*" XSTR(BPS) "(%[dst]) \n\t"
- "usw %[temp4], 1*" XSTR(BPS) "(%[dst]) \n\t"
- "usw %[temp4], 2*" XSTR(BPS) "(%[dst]) \n\t"
- "usw %[temp4], 3*" XSTR(BPS) "(%[dst]) \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [temp4]"=&r"(temp4), [temp5]"=&r"(temp5),
- [temp6]"=&r"(temp6)
- : [top]"r"(top), [dst]"r"(dst)
- : "memory"
- );
-}
-
-static void HE4(uint8_t* dst, const uint8_t* top) {
- int temp0, temp1, temp2, temp3, temp4, temp5, temp6;
- __asm__ volatile(
- "ulw %[temp0], -4(%[top]) \n\t"
- "lbu %[temp1], -5(%[top]) \n\t"
- "preceu.ph.qbr %[temp2], %[temp0] \n\t"
- "preceu.ph.qbl %[temp3], %[temp0] \n\t"
- "replv.ph %[temp4], %[temp1] \n\t"
- "packrl.ph %[temp5], %[temp3], %[temp2] \n\t"
- "packrl.ph %[temp6], %[temp2], %[temp4] \n\t"
- "shll.ph %[temp5], %[temp5], 1 \n\t"
- "shll.ph %[temp6], %[temp6], 1 \n\t"
- "addq.ph %[temp3], %[temp3], %[temp5] \n\t"
- "addq.ph %[temp3], %[temp3], %[temp2] \n\t"
- "addq.ph %[temp2], %[temp2], %[temp6] \n\t"
- "addq.ph %[temp2], %[temp2], %[temp4] \n\t"
- "shra_r.ph %[temp3], %[temp3], 2 \n\t"
- "shra_r.ph %[temp2], %[temp2], 2 \n\t"
- "replv.qb %[temp0], %[temp3] \n\t"
- "replv.qb %[temp1], %[temp2] \n\t"
- "srl %[temp3], %[temp3], 16 \n\t"
- "srl %[temp2], %[temp2], 16 \n\t"
- "replv.qb %[temp3], %[temp3] \n\t"
- "replv.qb %[temp2], %[temp2] \n\t"
- "usw %[temp3], 0*" XSTR(BPS) "(%[dst]) \n\t"
- "usw %[temp0], 1*" XSTR(BPS) "(%[dst]) \n\t"
- "usw %[temp2], 2*" XSTR(BPS) "(%[dst]) \n\t"
- "usw %[temp1], 3*" XSTR(BPS) "(%[dst]) \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [temp4]"=&r"(temp4), [temp5]"=&r"(temp5),
- [temp6]"=&r"(temp6)
- : [top]"r"(top), [dst]"r"(dst)
- : "memory"
- );
-}
-
-static void RD4(uint8_t* dst, const uint8_t* top) {
- int temp0, temp1, temp2, temp3, temp4, temp5;
- int temp6, temp7, temp8, temp9, temp10, temp11;
- __asm__ volatile(
- "ulw %[temp0], -5(%[top]) \n\t"
- "ulw %[temp1], -1(%[top]) \n\t"
- "preceu.ph.qbl %[temp2], %[temp0] \n\t"
- "preceu.ph.qbr %[temp3], %[temp0] \n\t"
- "preceu.ph.qbr %[temp4], %[temp1] \n\t"
- "preceu.ph.qbl %[temp5], %[temp1] \n\t"
- "packrl.ph %[temp6], %[temp2], %[temp3] \n\t"
- "packrl.ph %[temp7], %[temp4], %[temp2] \n\t"
- "packrl.ph %[temp8], %[temp5], %[temp4] \n\t"
- "shll.ph %[temp6], %[temp6], 1 \n\t"
- "addq.ph %[temp9], %[temp2], %[temp6] \n\t"
- "shll.ph %[temp7], %[temp7], 1 \n\t"
- "addq.ph %[temp9], %[temp9], %[temp3] \n\t"
- "shll.ph %[temp8], %[temp8], 1 \n\t"
- "shra_r.ph %[temp9], %[temp9], 2 \n\t"
- "addq.ph %[temp10], %[temp4], %[temp7] \n\t"
- "addq.ph %[temp11], %[temp5], %[temp8] \n\t"
- "addq.ph %[temp10], %[temp10], %[temp2] \n\t"
- "addq.ph %[temp11], %[temp11], %[temp4] \n\t"
- "shra_r.ph %[temp10], %[temp10], 2 \n\t"
- "shra_r.ph %[temp11], %[temp11], 2 \n\t"
- "lbu %[temp0], 3(%[top]) \n\t"
- "lbu %[temp1], 2(%[top]) \n\t"
- "lbu %[temp2], 1(%[top]) \n\t"
- "sll %[temp1], %[temp1], 1 \n\t"
- "addu %[temp0], %[temp0], %[temp1] \n\t"
- "addu %[temp0], %[temp0], %[temp2] \n\t"
- "precr.qb.ph %[temp9], %[temp10], %[temp9] \n\t"
- "shra_r.w %[temp0], %[temp0], 2 \n\t"
- "precr.qb.ph %[temp10], %[temp11], %[temp10] \n\t"
- "usw %[temp9], 3*" XSTR(BPS) "(%[dst]) \n\t"
- "usw %[temp10], 1*" XSTR(BPS) "(%[dst]) \n\t"
- "prepend %[temp9], %[temp11], 8 \n\t"
- "prepend %[temp10], %[temp0], 8 \n\t"
- "usw %[temp9], 2*" XSTR(BPS) "(%[dst]) \n\t"
- "usw %[temp10], 0*" XSTR(BPS) "(%[dst]) \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [temp4]"=&r"(temp4), [temp5]"=&r"(temp5),
- [temp6]"=&r"(temp6), [temp7]"=&r"(temp7), [temp8]"=&r"(temp8),
- [temp9]"=&r"(temp9), [temp10]"=&r"(temp10), [temp11]"=&r"(temp11)
- : [top]"r"(top), [dst]"r"(dst)
- : "memory"
- );
-}
-
-static void VR4(uint8_t* dst, const uint8_t* top) {
- int temp0, temp1, temp2, temp3, temp4;
- int temp5, temp6, temp7, temp8, temp9;
- __asm__ volatile (
- "ulw %[temp0], -4(%[top]) \n\t"
- "ulw %[temp1], 0(%[top]) \n\t"
- "preceu.ph.qbl %[temp2], %[temp0] \n\t"
- "preceu.ph.qbr %[temp0], %[temp0] \n\t"
- "preceu.ph.qbla %[temp3], %[temp1] \n\t"
- "preceu.ph.qbra %[temp1], %[temp1] \n\t"
- "packrl.ph %[temp7], %[temp3], %[temp2] \n\t"
- "addqh_r.ph %[temp4], %[temp1], %[temp3] \n\t"
- "move %[temp6], %[temp1] \n\t"
- "append %[temp1], %[temp2], 16 \n\t"
- "shll.ph %[temp9], %[temp6], 1 \n\t"
- "addqh_r.ph %[temp5], %[temp7], %[temp6] \n\t"
- "shll.ph %[temp8], %[temp7], 1 \n\t"
- "addu.ph %[temp3], %[temp7], %[temp3] \n\t"
- "addu.ph %[temp1], %[temp1], %[temp6] \n\t"
- "packrl.ph %[temp7], %[temp2], %[temp0] \n\t"
- "addu.ph %[temp6], %[temp0], %[temp2] \n\t"
- "addu.ph %[temp3], %[temp3], %[temp9] \n\t"
- "addu.ph %[temp1], %[temp1], %[temp8] \n\t"
- "shll.ph %[temp7], %[temp7], 1 \n\t"
- "shra_r.ph %[temp3], %[temp3], 2 \n\t"
- "shra_r.ph %[temp1], %[temp1], 2 \n\t"
- "addu.ph %[temp6], %[temp6], %[temp7] \n\t"
- "shra_r.ph %[temp6], %[temp6], 2 \n\t"
- "precrq.ph.w %[temp8], %[temp4], %[temp5] \n\t"
- "append %[temp4], %[temp5], 16 \n\t"
- "precrq.ph.w %[temp2], %[temp3], %[temp1] \n\t"
- "append %[temp3], %[temp1], 16 \n\t"
- "precr.qb.ph %[temp8], %[temp8], %[temp4] \n\t"
- "precr.qb.ph %[temp3], %[temp2], %[temp3] \n\t"
- "usw %[temp8], 0*" XSTR(BPS) "(%[dst]) \n\t"
- "usw %[temp3], 1*" XSTR(BPS) "(%[dst]) \n\t"
- "append %[temp3], %[temp6], 8 \n\t"
- "srl %[temp6], %[temp6], 16 \n\t"
- "append %[temp8], %[temp6], 8 \n\t"
- "usw %[temp3], 3*" XSTR(BPS) "(%[dst]) \n\t"
- "usw %[temp8], 2*" XSTR(BPS) "(%[dst]) \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [temp4]"=&r"(temp4), [temp5]"=&r"(temp5),
- [temp6]"=&r"(temp6), [temp7]"=&r"(temp7), [temp8]"=&r"(temp8),
- [temp9]"=&r"(temp9)
- : [top]"r"(top), [dst]"r"(dst)
- : "memory"
- );
-}
-
-static void LD4(uint8_t* dst, const uint8_t* top) {
- int temp0, temp1, temp2, temp3, temp4, temp5;
- int temp6, temp7, temp8, temp9, temp10, temp11;
- __asm__ volatile(
- "ulw %[temp0], 0(%[top]) \n\t"
- "ulw %[temp1], 4(%[top]) \n\t"
- "preceu.ph.qbl %[temp2], %[temp0] \n\t"
- "preceu.ph.qbr %[temp3], %[temp0] \n\t"
- "preceu.ph.qbr %[temp4], %[temp1] \n\t"
- "preceu.ph.qbl %[temp5], %[temp1] \n\t"
- "packrl.ph %[temp6], %[temp2], %[temp3] \n\t"
- "packrl.ph %[temp7], %[temp4], %[temp2] \n\t"
- "packrl.ph %[temp8], %[temp5], %[temp4] \n\t"
- "shll.ph %[temp6], %[temp6], 1 \n\t"
- "addq.ph %[temp9], %[temp2], %[temp6] \n\t"
- "shll.ph %[temp7], %[temp7], 1 \n\t"
- "addq.ph %[temp9], %[temp9], %[temp3] \n\t"
- "shll.ph %[temp8], %[temp8], 1 \n\t"
- "shra_r.ph %[temp9], %[temp9], 2 \n\t"
- "addq.ph %[temp10], %[temp4], %[temp7] \n\t"
- "addq.ph %[temp11], %[temp5], %[temp8] \n\t"
- "addq.ph %[temp10], %[temp10], %[temp2] \n\t"
- "addq.ph %[temp11], %[temp11], %[temp4] \n\t"
- "shra_r.ph %[temp10], %[temp10], 2 \n\t"
- "shra_r.ph %[temp11], %[temp11], 2 \n\t"
- "srl %[temp1], %[temp1], 24 \n\t"
- "sll %[temp1], %[temp1], 1 \n\t"
- "raddu.w.qb %[temp5], %[temp5] \n\t"
- "precr.qb.ph %[temp9], %[temp10], %[temp9] \n\t"
- "precr.qb.ph %[temp10], %[temp11], %[temp10] \n\t"
- "addu %[temp1], %[temp1], %[temp5] \n\t"
- "shra_r.w %[temp1], %[temp1], 2 \n\t"
- "usw %[temp9], 0*" XSTR(BPS) "(%[dst]) \n\t"
- "usw %[temp10], 2*" XSTR(BPS) "(%[dst]) \n\t"
- "prepend %[temp9], %[temp11], 8 \n\t"
- "prepend %[temp10], %[temp1], 8 \n\t"
- "usw %[temp9], 1*" XSTR(BPS) "(%[dst]) \n\t"
- "usw %[temp10], 3*" XSTR(BPS) "(%[dst]) \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [temp4]"=&r"(temp4), [temp5]"=&r"(temp5),
- [temp6]"=&r"(temp6), [temp7]"=&r"(temp7), [temp8]"=&r"(temp8),
- [temp9]"=&r"(temp9), [temp10]"=&r"(temp10), [temp11]"=&r"(temp11)
- : [top]"r"(top), [dst]"r"(dst)
- : "memory"
- );
-}
-
-static void VL4(uint8_t* dst, const uint8_t* top) {
- int temp0, temp1, temp2, temp3, temp4;
- int temp5, temp6, temp7, temp8, temp9;
- __asm__ volatile (
- "ulw %[temp0], 0(%[top]) \n\t"
- "ulw %[temp1], 4(%[top]) \n\t"
- "preceu.ph.qbla %[temp2], %[temp0] \n\t"
- "preceu.ph.qbra %[temp0], %[temp0] \n\t"
- "preceu.ph.qbl %[temp3], %[temp1] \n\t"
- "preceu.ph.qbr %[temp1], %[temp1] \n\t"
- "addqh_r.ph %[temp4], %[temp0], %[temp2] \n\t"
- "packrl.ph %[temp7], %[temp1], %[temp0] \n\t"
- "precrq.ph.w %[temp6], %[temp1], %[temp2] \n\t"
- "shll.ph %[temp9], %[temp2], 1 \n\t"
- "addqh_r.ph %[temp5], %[temp7], %[temp2] \n\t"
- "shll.ph %[temp8], %[temp7], 1 \n\t"
- "addu.ph %[temp2], %[temp2], %[temp6] \n\t"
- "addu.ph %[temp0], %[temp0], %[temp7] \n\t"
- "packrl.ph %[temp7], %[temp3], %[temp1] \n\t"
- "addu.ph %[temp6], %[temp1], %[temp3] \n\t"
- "addu.ph %[temp2], %[temp2], %[temp8] \n\t"
- "addu.ph %[temp0], %[temp0], %[temp9] \n\t"
- "shll.ph %[temp7], %[temp7], 1 \n\t"
- "shra_r.ph %[temp2], %[temp2], 2 \n\t"
- "shra_r.ph %[temp0], %[temp0], 2 \n\t"
- "addu.ph %[temp6], %[temp6], %[temp7] \n\t"
- "shra_r.ph %[temp6], %[temp6], 2 \n\t"
- "precrq.ph.w %[temp8], %[temp5], %[temp4] \n\t"
- "append %[temp5], %[temp4], 16 \n\t"
- "precrq.ph.w %[temp3], %[temp2], %[temp0] \n\t"
- "append %[temp2], %[temp0], 16 \n\t"
- "precr.qb.ph %[temp8], %[temp8], %[temp5] \n\t"
- "precr.qb.ph %[temp3], %[temp3], %[temp2] \n\t"
- "usw %[temp8], 0*" XSTR(BPS) "(%[dst]) \n\t"
- "prepend %[temp8], %[temp6], 8 \n\t"
- "usw %[temp3], 1*" XSTR(BPS) "(%[dst]) \n\t"
- "srl %[temp6], %[temp6], 16 \n\t"
- "prepend %[temp3], %[temp6], 8 \n\t"
- "usw %[temp8], 2*" XSTR(BPS) "(%[dst]) \n\t"
- "usw %[temp3], 3*" XSTR(BPS) "(%[dst]) \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [temp4]"=&r"(temp4), [temp5]"=&r"(temp5),
- [temp6]"=&r"(temp6), [temp7]"=&r"(temp7), [temp8]"=&r"(temp8),
- [temp9]"=&r"(temp9)
- : [top]"r"(top), [dst]"r"(dst)
- : "memory"
- );
-}
-
-static void HD4(uint8_t* dst, const uint8_t* top) {
- int temp0, temp1, temp2, temp3, temp4;
- int temp5, temp6, temp7, temp8, temp9;
- __asm__ volatile (
- "ulw %[temp0], -5(%[top]) \n\t"
- "ulw %[temp1], -1(%[top]) \n\t"
- "preceu.ph.qbla %[temp2], %[temp0] \n\t"
- "preceu.ph.qbra %[temp0], %[temp0] \n\t"
- "preceu.ph.qbl %[temp3], %[temp1] \n\t"
- "preceu.ph.qbr %[temp1], %[temp1] \n\t"
- "addqh_r.ph %[temp4], %[temp0], %[temp2] \n\t"
- "packrl.ph %[temp7], %[temp1], %[temp0] \n\t"
- "precrq.ph.w %[temp6], %[temp1], %[temp2] \n\t"
- "shll.ph %[temp9], %[temp2], 1 \n\t"
- "addqh_r.ph %[temp5], %[temp7], %[temp2] \n\t"
- "shll.ph %[temp8], %[temp7], 1 \n\t"
- "addu.ph %[temp2], %[temp2], %[temp6] \n\t"
- "addu.ph %[temp0], %[temp0], %[temp7] \n\t"
- "packrl.ph %[temp7], %[temp3], %[temp1] \n\t"
- "addu.ph %[temp6], %[temp1], %[temp3] \n\t"
- "addu.ph %[temp2], %[temp2], %[temp8] \n\t"
- "addu.ph %[temp0], %[temp0], %[temp9] \n\t"
- "shll.ph %[temp7], %[temp7], 1 \n\t"
- "shra_r.ph %[temp2], %[temp2], 2 \n\t"
- "shra_r.ph %[temp0], %[temp0], 2 \n\t"
- "addu.ph %[temp6], %[temp6], %[temp7] \n\t"
- "shra_r.ph %[temp6], %[temp6], 2 \n\t"
- "precrq.ph.w %[temp1], %[temp2], %[temp5] \n\t"
- "precrq.ph.w %[temp3], %[temp0], %[temp4] \n\t"
- "precr.qb.ph %[temp7], %[temp6], %[temp1] \n\t"
- "precr.qb.ph %[temp6], %[temp1], %[temp3] \n\t"
- "usw %[temp7], 0*" XSTR(BPS) "(%[dst]) \n\t"
- "usw %[temp6], 1*" XSTR(BPS) "(%[dst]) \n\t"
- "append %[temp2], %[temp5], 16 \n\t"
- "append %[temp0], %[temp4], 16 \n\t"
- "precr.qb.ph %[temp5], %[temp3], %[temp2] \n\t"
- "precr.qb.ph %[temp4], %[temp2], %[temp0] \n\t"
- "usw %[temp5], 2*" XSTR(BPS) "(%[dst]) \n\t"
- "usw %[temp4], 3*" XSTR(BPS) "(%[dst]) \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [temp4]"=&r"(temp4), [temp5]"=&r"(temp5),
- [temp6]"=&r"(temp6), [temp7]"=&r"(temp7), [temp8]"=&r"(temp8),
- [temp9]"=&r"(temp9)
- : [top]"r"(top), [dst]"r"(dst)
- : "memory"
- );
-}
-
-static void HU4(uint8_t* dst, const uint8_t* top) {
- int temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7;
- __asm__ volatile (
- "ulw %[temp0], -5(%[top]) \n\t"
- "preceu.ph.qbl %[temp1], %[temp0] \n\t"
- "preceu.ph.qbr %[temp2], %[temp0] \n\t"
- "packrl.ph %[temp3], %[temp1], %[temp2] \n\t"
- "replv.qb %[temp7], %[temp2] \n\t"
- "addqh_r.ph %[temp4], %[temp1], %[temp3] \n\t"
- "addqh_r.ph %[temp5], %[temp3], %[temp2] \n\t"
- "shll.ph %[temp6], %[temp3], 1 \n\t"
- "addu.ph %[temp3], %[temp2], %[temp3] \n\t"
- "addu.ph %[temp6], %[temp1], %[temp6] \n\t"
- "shll.ph %[temp0], %[temp2], 1 \n\t"
- "addu.ph %[temp6], %[temp6], %[temp2] \n\t"
- "addu.ph %[temp0], %[temp3], %[temp0] \n\t"
- "shra_r.ph %[temp6], %[temp6], 2 \n\t"
- "shra_r.ph %[temp0], %[temp0], 2 \n\t"
- "packrl.ph %[temp3], %[temp6], %[temp5] \n\t"
- "precrq.ph.w %[temp2], %[temp6], %[temp4] \n\t"
- "append %[temp0], %[temp5], 16 \n\t"
- "precr.qb.ph %[temp3], %[temp3], %[temp2] \n\t"
- "usw %[temp3], 0*" XSTR(BPS) "(%[dst]) \n\t"
- "precr.qb.ph %[temp1], %[temp7], %[temp0] \n\t"
- "usw %[temp7], 3*" XSTR(BPS) "(%[dst]) \n\t"
- "packrl.ph %[temp2], %[temp1], %[temp3] \n\t"
- "usw %[temp1], 2*" XSTR(BPS) "(%[dst]) \n\t"
- "usw %[temp2], 1*" XSTR(BPS) "(%[dst]) \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [temp4]"=&r"(temp4), [temp5]"=&r"(temp5),
- [temp6]"=&r"(temp6), [temp7]"=&r"(temp7)
- : [top]"r"(top), [dst]"r"(dst)
- : "memory"
- );
-}
-
-//------------------------------------------------------------------------------
-// Chroma 8x8 prediction (paragraph 12.2)
-
-static void IntraChromaPreds_MIPSdspR2(uint8_t* dst, const uint8_t* left,
- const uint8_t* top) {
- // U block
- DCMode8(C8DC8 + dst, left, top);
- VerticalPred8(C8VE8 + dst, top);
- HorizontalPred8(C8HE8 + dst, left);
- TrueMotion8(C8TM8 + dst, left, top);
- // V block
- dst += 8;
- if (top) top += 8;
- if (left) left += 16;
- DCMode8(C8DC8 + dst, left, top);
- VerticalPred8(C8VE8 + dst, top);
- HorizontalPred8(C8HE8 + dst, left);
- TrueMotion8(C8TM8 + dst, left, top);
-}
-
-//------------------------------------------------------------------------------
-// luma 16x16 prediction (paragraph 12.3)
-
-static void Intra16Preds_MIPSdspR2(uint8_t* dst,
- const uint8_t* left, const uint8_t* top) {
- DCMode16(I16DC16 + dst, left, top);
- VerticalPred16(I16VE16 + dst, top);
- HorizontalPred16(I16HE16 + dst, left);
- TrueMotion16(I16TM16 + dst, left, top);
-}
-
-// Left samples are top[-5 .. -2], top_left is top[-1], top are
-// located at top[0..3], and top right is top[4..7]
-static void Intra4Preds_MIPSdspR2(uint8_t* dst, const uint8_t* top) {
- DC4(I4DC4 + dst, top);
- TM4(I4TM4 + dst, top);
- VE4(I4VE4 + dst, top);
- HE4(I4HE4 + dst, top);
- RD4(I4RD4 + dst, top);
- VR4(I4VR4 + dst, top);
- LD4(I4LD4 + dst, top);
- VL4(I4VL4 + dst, top);
- HD4(I4HD4 + dst, top);
- HU4(I4HU4 + dst, top);
-}
-
-//------------------------------------------------------------------------------
-// Metric
-
-#if !defined(WORK_AROUND_GCC)
-
-#define GET_SSE_INNER(A) \
- "lw %[temp0], " #A "(%[a]) \n\t" \
- "lw %[temp1], " #A "(%[b]) \n\t" \
- "preceu.ph.qbr %[temp2], %[temp0] \n\t" \
- "preceu.ph.qbl %[temp0], %[temp0] \n\t" \
- "preceu.ph.qbr %[temp3], %[temp1] \n\t" \
- "preceu.ph.qbl %[temp1], %[temp1] \n\t" \
- "subq.ph %[temp2], %[temp2], %[temp3] \n\t" \
- "subq.ph %[temp0], %[temp0], %[temp1] \n\t" \
- "dpa.w.ph $ac0, %[temp2], %[temp2] \n\t" \
- "dpa.w.ph $ac0, %[temp0], %[temp0] \n\t"
-
-#define GET_SSE(A, B, C, D) \
- GET_SSE_INNER(A) \
- GET_SSE_INNER(B) \
- GET_SSE_INNER(C) \
- GET_SSE_INNER(D)
-
-static int SSE16x16_MIPSdspR2(const uint8_t* a, const uint8_t* b) {
- int count;
- int temp0, temp1, temp2, temp3;
- __asm__ volatile (
- "mult $zero, $zero \n\t"
- GET_SSE( 0 * BPS, 4 + 0 * BPS, 8 + 0 * BPS, 12 + 0 * BPS)
- GET_SSE( 1 * BPS, 4 + 1 * BPS, 8 + 1 * BPS, 12 + 1 * BPS)
- GET_SSE( 2 * BPS, 4 + 2 * BPS, 8 + 2 * BPS, 12 + 2 * BPS)
- GET_SSE( 3 * BPS, 4 + 3 * BPS, 8 + 3 * BPS, 12 + 3 * BPS)
- GET_SSE( 4 * BPS, 4 + 4 * BPS, 8 + 4 * BPS, 12 + 4 * BPS)
- GET_SSE( 5 * BPS, 4 + 5 * BPS, 8 + 5 * BPS, 12 + 5 * BPS)
- GET_SSE( 6 * BPS, 4 + 6 * BPS, 8 + 6 * BPS, 12 + 6 * BPS)
- GET_SSE( 7 * BPS, 4 + 7 * BPS, 8 + 7 * BPS, 12 + 7 * BPS)
- GET_SSE( 8 * BPS, 4 + 8 * BPS, 8 + 8 * BPS, 12 + 8 * BPS)
- GET_SSE( 9 * BPS, 4 + 9 * BPS, 8 + 9 * BPS, 12 + 9 * BPS)
- GET_SSE(10 * BPS, 4 + 10 * BPS, 8 + 10 * BPS, 12 + 10 * BPS)
- GET_SSE(11 * BPS, 4 + 11 * BPS, 8 + 11 * BPS, 12 + 11 * BPS)
- GET_SSE(12 * BPS, 4 + 12 * BPS, 8 + 12 * BPS, 12 + 12 * BPS)
- GET_SSE(13 * BPS, 4 + 13 * BPS, 8 + 13 * BPS, 12 + 13 * BPS)
- GET_SSE(14 * BPS, 4 + 14 * BPS, 8 + 14 * BPS, 12 + 14 * BPS)
- GET_SSE(15 * BPS, 4 + 15 * BPS, 8 + 15 * BPS, 12 + 15 * BPS)
- "mflo %[count] \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [count]"=&r"(count)
- : [a]"r"(a), [b]"r"(b)
- : "memory", "hi", "lo"
- );
- return count;
-}
-
-static int SSE16x8_MIPSdspR2(const uint8_t* a, const uint8_t* b) {
- int count;
- int temp0, temp1, temp2, temp3;
- __asm__ volatile (
- "mult $zero, $zero \n\t"
- GET_SSE( 0 * BPS, 4 + 0 * BPS, 8 + 0 * BPS, 12 + 0 * BPS)
- GET_SSE( 1 * BPS, 4 + 1 * BPS, 8 + 1 * BPS, 12 + 1 * BPS)
- GET_SSE( 2 * BPS, 4 + 2 * BPS, 8 + 2 * BPS, 12 + 2 * BPS)
- GET_SSE( 3 * BPS, 4 + 3 * BPS, 8 + 3 * BPS, 12 + 3 * BPS)
- GET_SSE( 4 * BPS, 4 + 4 * BPS, 8 + 4 * BPS, 12 + 4 * BPS)
- GET_SSE( 5 * BPS, 4 + 5 * BPS, 8 + 5 * BPS, 12 + 5 * BPS)
- GET_SSE( 6 * BPS, 4 + 6 * BPS, 8 + 6 * BPS, 12 + 6 * BPS)
- GET_SSE( 7 * BPS, 4 + 7 * BPS, 8 + 7 * BPS, 12 + 7 * BPS)
- "mflo %[count] \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [count]"=&r"(count)
- : [a]"r"(a), [b]"r"(b)
- : "memory", "hi", "lo"
- );
- return count;
-}
-
-static int SSE8x8_MIPSdspR2(const uint8_t* a, const uint8_t* b) {
- int count;
- int temp0, temp1, temp2, temp3;
- __asm__ volatile (
- "mult $zero, $zero \n\t"
- GET_SSE(0 * BPS, 4 + 0 * BPS, 1 * BPS, 4 + 1 * BPS)
- GET_SSE(2 * BPS, 4 + 2 * BPS, 3 * BPS, 4 + 3 * BPS)
- GET_SSE(4 * BPS, 4 + 4 * BPS, 5 * BPS, 4 + 5 * BPS)
- GET_SSE(6 * BPS, 4 + 6 * BPS, 7 * BPS, 4 + 7 * BPS)
- "mflo %[count] \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [count]"=&r"(count)
- : [a]"r"(a), [b]"r"(b)
- : "memory", "hi", "lo"
- );
- return count;
-}
-
-static int SSE4x4_MIPSdspR2(const uint8_t* a, const uint8_t* b) {
- int count;
- int temp0, temp1, temp2, temp3;
- __asm__ volatile (
- "mult $zero, $zero \n\t"
- GET_SSE(0 * BPS, 1 * BPS, 2 * BPS, 3 * BPS)
- "mflo %[count] \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [count]"=&r"(count)
- : [a]"r"(a), [b]"r"(b)
- : "memory", "hi", "lo"
- );
- return count;
-}
-
-#undef GET_SSE
-#undef GET_SSE_INNER
-
-#endif // !WORK_AROUND_GCC
-
-#undef FILL_8_OR_16
-#undef FILL_PART
-#undef OUTPUT_EARLY_CLOBBER_REGS_17
-#undef MUL_HALF
-#undef ABS_X8
-#undef ADD_SUB_HALVES_X4
-
-//------------------------------------------------------------------------------
-// Quantization
-//
-
-// macro for one pass through for loop in QuantizeBlock reading 2 values at time
-// QUANTDIV macro inlined
-// J - offset in bytes (kZigzag[n] * 2)
-// K - offset in bytes (kZigzag[n] * 4)
-// N - offset in bytes (n * 2)
-// N1 - offset in bytes ((n + 1) * 2)
-#define QUANTIZE_ONE(J, K, N, N1) \
- "ulw %[temp1], " #J "(%[ppin]) \n\t" \
- "ulw %[temp2], " #J "(%[ppsharpen]) \n\t" \
- "lhu %[temp3], " #K "(%[ppzthresh]) \n\t" \
- "lhu %[temp6], " #K "+4(%[ppzthresh]) \n\t" \
- "absq_s.ph %[temp4], %[temp1] \n\t" \
- "ins %[temp3], %[temp6], 16, 16 \n\t" \
- "addu.ph %[coeff], %[temp4], %[temp2] \n\t" \
- "shra.ph %[sign], %[temp1], 15 \n\t" \
- "li %[level], 0x10001 \n\t" \
- "cmp.lt.ph %[temp3], %[coeff] \n\t" \
- "lhu %[temp1], " #J "(%[ppiq]) \n\t" \
- "pick.ph %[temp5], %[level], $0 \n\t" \
- "lw %[temp2], " #K "(%[ppbias]) \n\t" \
- "beqz %[temp5], 0f \n\t" \
- "lhu %[temp3], " #J "(%[ppq]) \n\t" \
- "beq %[temp5], %[level], 1f \n\t" \
- "andi %[temp5], %[temp5], 0x1 \n\t" \
- "andi %[temp4], %[coeff], 0xffff \n\t" \
- "beqz %[temp5], 2f \n\t" \
- "mul %[level], %[temp4], %[temp1] \n\t" \
- "sh $0, " #J "+2(%[ppin]) \n\t" \
- "sh $0, " #N1 "(%[pout]) \n\t" \
- "addu %[level], %[level], %[temp2] \n\t" \
- "sra %[level], %[level], 17 \n\t" \
- "slt %[temp4], %[max_level], %[level] \n\t" \
- "movn %[level], %[max_level], %[temp4] \n\t" \
- "andi %[temp6], %[sign], 0xffff \n\t" \
- "xor %[level], %[level], %[temp6] \n\t" \
- "subu %[level], %[level], %[temp6] \n\t" \
- "mul %[temp5], %[level], %[temp3] \n\t" \
- "or %[ret], %[ret], %[level] \n\t" \
- "sh %[level], " #N "(%[pout]) \n\t" \
- "sh %[temp5], " #J "(%[ppin]) \n\t" \
- "j 3f \n\t" \
-"2: \n\t" \
- "lhu %[temp1], " #J "+2(%[ppiq]) \n\t" \
- "srl %[temp5], %[coeff], 16 \n\t" \
- "mul %[level], %[temp5], %[temp1] \n\t" \
- "lw %[temp2], " #K "+4(%[ppbias]) \n\t" \
- "lhu %[temp3], " #J "+2(%[ppq]) \n\t" \
- "addu %[level], %[level], %[temp2] \n\t" \
- "sra %[level], %[level], 17 \n\t" \
- "srl %[temp6], %[sign], 16 \n\t" \
- "slt %[temp4], %[max_level], %[level] \n\t" \
- "movn %[level], %[max_level], %[temp4] \n\t" \
- "xor %[level], %[level], %[temp6] \n\t" \
- "subu %[level], %[level], %[temp6] \n\t" \
- "mul %[temp5], %[level], %[temp3] \n\t" \
- "sh $0, " #J "(%[ppin]) \n\t" \
- "sh $0, " #N "(%[pout]) \n\t" \
- "or %[ret], %[ret], %[level] \n\t" \
- "sh %[temp5], " #J "+2(%[ppin]) \n\t" \
- "sh %[level], " #N1 "(%[pout]) \n\t" \
- "j 3f \n\t" \
-"1: \n\t" \
- "lhu %[temp1], " #J "(%[ppiq]) \n\t" \
- "lw %[temp2], " #K "(%[ppbias]) \n\t" \
- "ulw %[temp3], " #J "(%[ppq]) \n\t" \
- "andi %[temp5], %[coeff], 0xffff \n\t" \
- "srl %[temp0], %[coeff], 16 \n\t" \
- "lhu %[temp6], " #J "+2(%[ppiq]) \n\t" \
- "lw %[coeff], " #K "+4(%[ppbias]) \n\t" \
- "mul %[level], %[temp5], %[temp1] \n\t" \
- "mul %[temp4], %[temp0], %[temp6] \n\t" \
- "addu %[level], %[level], %[temp2] \n\t" \
- "addu %[temp4], %[temp4], %[coeff] \n\t" \
- "precrq.ph.w %[level], %[temp4], %[level] \n\t" \
- "shra.ph %[level], %[level], 1 \n\t" \
- "cmp.lt.ph %[max_level1],%[level] \n\t" \
- "pick.ph %[level], %[max_level], %[level] \n\t" \
- "xor %[level], %[level], %[sign] \n\t" \
- "subu.ph %[level], %[level], %[sign] \n\t" \
- "mul.ph %[temp3], %[level], %[temp3] \n\t" \
- "or %[ret], %[ret], %[level] \n\t" \
- "sh %[level], " #N "(%[pout]) \n\t" \
- "srl %[level], %[level], 16 \n\t" \
- "sh %[level], " #N1 "(%[pout]) \n\t" \
- "usw %[temp3], " #J "(%[ppin]) \n\t" \
- "j 3f \n\t" \
-"0: \n\t" \
- "sh $0, " #N "(%[pout]) \n\t" \
- "sh $0, " #N1 "(%[pout]) \n\t" \
- "usw $0, " #J "(%[ppin]) \n\t" \
-"3: \n\t"
-
-static int QuantizeBlock_MIPSdspR2(int16_t in[16], int16_t out[16],
- const VP8Matrix* const mtx) {
- int temp0, temp1, temp2, temp3, temp4, temp5,temp6;
- int sign, coeff, level;
- int max_level = MAX_LEVEL;
- int max_level1 = max_level << 16 | max_level;
- int ret = 0;
-
- int16_t* ppin = &in[0];
- int16_t* pout = &out[0];
- const uint16_t* ppsharpen = &mtx->sharpen_[0];
- const uint32_t* ppzthresh = &mtx->zthresh_[0];
- const uint16_t* ppq = &mtx->q_[0];
- const uint16_t* ppiq = &mtx->iq_[0];
- const uint32_t* ppbias = &mtx->bias_[0];
-
- __asm__ volatile (
- QUANTIZE_ONE( 0, 0, 0, 2)
- QUANTIZE_ONE( 4, 8, 10, 12)
- QUANTIZE_ONE( 8, 16, 4, 8)
- QUANTIZE_ONE(12, 24, 14, 24)
- QUANTIZE_ONE(16, 32, 6, 16)
- QUANTIZE_ONE(20, 40, 22, 26)
- QUANTIZE_ONE(24, 48, 18, 20)
- QUANTIZE_ONE(28, 56, 28, 30)
-
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1),
- [temp2]"=&r"(temp2), [temp3]"=&r"(temp3),
- [temp4]"=&r"(temp4), [temp5]"=&r"(temp5),
- [sign]"=&r"(sign), [coeff]"=&r"(coeff),
- [level]"=&r"(level), [temp6]"=&r"(temp6), [ret]"+&r"(ret)
- : [ppin]"r"(ppin), [pout]"r"(pout), [max_level1]"r"(max_level1),
- [ppiq]"r"(ppiq), [max_level]"r"(max_level),
- [ppbias]"r"(ppbias), [ppzthresh]"r"(ppzthresh),
- [ppsharpen]"r"(ppsharpen), [ppq]"r"(ppq)
- : "memory", "hi", "lo"
- );
-
- return (ret != 0);
-}
-
-static int Quantize2Blocks_MIPSdspR2(int16_t in[32], int16_t out[32],
- const VP8Matrix* const mtx) {
- int nz;
- nz = QuantizeBlock_MIPSdspR2(in + 0 * 16, out + 0 * 16, mtx) << 0;
- nz |= QuantizeBlock_MIPSdspR2(in + 1 * 16, out + 1 * 16, mtx) << 1;
- return nz;
-}
-
-#undef QUANTIZE_ONE
-
-// macro for one horizontal pass in FTransformWHT
-// temp0..temp7 holds tmp[0]..tmp[15]
-// A, B, C, D - offset in bytes to load from in buffer
-// TEMP0, TEMP1 - registers for corresponding tmp elements
-#define HORIZONTAL_PASS_WHT(A, B, C, D, TEMP0, TEMP1) \
- "lh %[" #TEMP0 "], " #A "(%[in]) \n\t" \
- "lh %[" #TEMP1 "], " #B "(%[in]) \n\t" \
- "lh %[temp8], " #C "(%[in]) \n\t" \
- "lh %[temp9], " #D "(%[in]) \n\t" \
- "ins %[" #TEMP1 "], %[" #TEMP0 "], 16, 16 \n\t" \
- "ins %[temp9], %[temp8], 16, 16 \n\t" \
- "subq.ph %[temp8], %[" #TEMP1 "], %[temp9] \n\t" \
- "addq.ph %[temp9], %[" #TEMP1 "], %[temp9] \n\t" \
- "precrq.ph.w %[" #TEMP0 "], %[temp8], %[temp9] \n\t" \
- "append %[temp8], %[temp9], 16 \n\t" \
- "subq.ph %[" #TEMP1 "], %[" #TEMP0 "], %[temp8] \n\t" \
- "addq.ph %[" #TEMP0 "], %[" #TEMP0 "], %[temp8] \n\t" \
- "rotr %[" #TEMP1 "], %[" #TEMP1 "], 16 \n\t"
-
-// macro for one vertical pass in FTransformWHT
-// temp0..temp7 holds tmp[0]..tmp[15]
-// A, B, C, D - offsets in bytes to store to out buffer
-// TEMP0, TEMP2, TEMP4 and TEMP6 - registers for corresponding tmp elements
-#define VERTICAL_PASS_WHT(A, B, C, D, TEMP0, TEMP2, TEMP4, TEMP6) \
- "addq.ph %[temp8], %[" #TEMP0 "], %[" #TEMP4 "] \n\t" \
- "addq.ph %[temp9], %[" #TEMP2 "], %[" #TEMP6 "] \n\t" \
- "subq.ph %[" #TEMP2 "], %[" #TEMP2 "], %[" #TEMP6 "] \n\t" \
- "subq.ph %[" #TEMP6 "], %[" #TEMP0 "], %[" #TEMP4 "] \n\t" \
- "addqh.ph %[" #TEMP0 "], %[temp8], %[temp9] \n\t" \
- "subqh.ph %[" #TEMP4 "], %[" #TEMP6 "], %[" #TEMP2 "] \n\t" \
- "addqh.ph %[" #TEMP2 "], %[" #TEMP2 "], %[" #TEMP6 "] \n\t" \
- "subqh.ph %[" #TEMP6 "], %[temp8], %[temp9] \n\t" \
- "usw %[" #TEMP0 "], " #A "(%[out]) \n\t" \
- "usw %[" #TEMP2 "], " #B "(%[out]) \n\t" \
- "usw %[" #TEMP4 "], " #C "(%[out]) \n\t" \
- "usw %[" #TEMP6 "], " #D "(%[out]) \n\t"
-
-static void FTransformWHT_MIPSdspR2(const int16_t* in, int16_t* out) {
- int temp0, temp1, temp2, temp3, temp4;
- int temp5, temp6, temp7, temp8, temp9;
-
- __asm__ volatile (
- HORIZONTAL_PASS_WHT( 0, 32, 64, 96, temp0, temp1)
- HORIZONTAL_PASS_WHT(128, 160, 192, 224, temp2, temp3)
- HORIZONTAL_PASS_WHT(256, 288, 320, 352, temp4, temp5)
- HORIZONTAL_PASS_WHT(384, 416, 448, 480, temp6, temp7)
- VERTICAL_PASS_WHT(0, 8, 16, 24, temp0, temp2, temp4, temp6)
- VERTICAL_PASS_WHT(4, 12, 20, 28, temp1, temp3, temp5, temp7)
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [temp4]"=&r"(temp4), [temp5]"=&r"(temp5),
- [temp6]"=&r"(temp6), [temp7]"=&r"(temp7), [temp8]"=&r"(temp8),
- [temp9]"=&r"(temp9)
- : [in]"r"(in), [out]"r"(out)
- : "memory"
- );
-}
-
-#undef VERTICAL_PASS_WHT
-#undef HORIZONTAL_PASS_WHT
-
-// macro for converting coefficients to bin
-// convert 8 coeffs at time
-// A, B, C, D - offsets in bytes to load from out buffer
-#define CONVERT_COEFFS_TO_BIN(A, B, C, D) \
- "ulw %[temp0], " #A "(%[out]) \n\t" \
- "ulw %[temp1], " #B "(%[out]) \n\t" \
- "ulw %[temp2], " #C "(%[out]) \n\t" \
- "ulw %[temp3], " #D "(%[out]) \n\t" \
- "absq_s.ph %[temp0], %[temp0] \n\t" \
- "absq_s.ph %[temp1], %[temp1] \n\t" \
- "absq_s.ph %[temp2], %[temp2] \n\t" \
- "absq_s.ph %[temp3], %[temp3] \n\t" \
- "shra.ph %[temp0], %[temp0], 3 \n\t" \
- "shra.ph %[temp1], %[temp1], 3 \n\t" \
- "shra.ph %[temp2], %[temp2], 3 \n\t" \
- "shra.ph %[temp3], %[temp3], 3 \n\t" \
- "shll_s.ph %[temp0], %[temp0], 10 \n\t" \
- "shll_s.ph %[temp1], %[temp1], 10 \n\t" \
- "shll_s.ph %[temp2], %[temp2], 10 \n\t" \
- "shll_s.ph %[temp3], %[temp3], 10 \n\t" \
- "shrl.ph %[temp0], %[temp0], 10 \n\t" \
- "shrl.ph %[temp1], %[temp1], 10 \n\t" \
- "shrl.ph %[temp2], %[temp2], 10 \n\t" \
- "shrl.ph %[temp3], %[temp3], 10 \n\t" \
- "shll.ph %[temp0], %[temp0], 2 \n\t" \
- "shll.ph %[temp1], %[temp1], 2 \n\t" \
- "shll.ph %[temp2], %[temp2], 2 \n\t" \
- "shll.ph %[temp3], %[temp3], 2 \n\t" \
- "ext %[temp4], %[temp0], 0, 16 \n\t" \
- "ext %[temp0], %[temp0], 16, 16 \n\t" \
- "addu %[temp4], %[temp4], %[dist] \n\t" \
- "addu %[temp0], %[temp0], %[dist] \n\t" \
- "ext %[temp5], %[temp1], 0, 16 \n\t" \
- "lw %[temp8], 0(%[temp4]) \n\t" \
- "ext %[temp1], %[temp1], 16, 16 \n\t" \
- "addu %[temp5], %[temp5], %[dist] \n\t" \
- "addiu %[temp8], %[temp8], 1 \n\t" \
- "sw %[temp8], 0(%[temp4]) \n\t" \
- "lw %[temp8], 0(%[temp0]) \n\t" \
- "addu %[temp1], %[temp1], %[dist] \n\t" \
- "ext %[temp6], %[temp2], 0, 16 \n\t" \
- "addiu %[temp8], %[temp8], 1 \n\t" \
- "sw %[temp8], 0(%[temp0]) \n\t" \
- "lw %[temp8], 0(%[temp5]) \n\t" \
- "ext %[temp2], %[temp2], 16, 16 \n\t" \
- "addu %[temp6], %[temp6], %[dist] \n\t" \
- "addiu %[temp8], %[temp8], 1 \n\t" \
- "sw %[temp8], 0(%[temp5]) \n\t" \
- "lw %[temp8], 0(%[temp1]) \n\t" \
- "addu %[temp2], %[temp2], %[dist] \n\t" \
- "ext %[temp7], %[temp3], 0, 16 \n\t" \
- "addiu %[temp8], %[temp8], 1 \n\t" \
- "sw %[temp8], 0(%[temp1]) \n\t" \
- "lw %[temp8], 0(%[temp6]) \n\t" \
- "ext %[temp3], %[temp3], 16, 16 \n\t" \
- "addu %[temp7], %[temp7], %[dist] \n\t" \
- "addiu %[temp8], %[temp8], 1 \n\t" \
- "sw %[temp8], 0(%[temp6]) \n\t" \
- "lw %[temp8], 0(%[temp2]) \n\t" \
- "addu %[temp3], %[temp3], %[dist] \n\t" \
- "addiu %[temp8], %[temp8], 1 \n\t" \
- "sw %[temp8], 0(%[temp2]) \n\t" \
- "lw %[temp8], 0(%[temp7]) \n\t" \
- "addiu %[temp8], %[temp8], 1 \n\t" \
- "sw %[temp8], 0(%[temp7]) \n\t" \
- "lw %[temp8], 0(%[temp3]) \n\t" \
- "addiu %[temp8], %[temp8], 1 \n\t" \
- "sw %[temp8], 0(%[temp3]) \n\t"
-
-static void CollectHistogram_MIPSdspR2(const uint8_t* ref, const uint8_t* pred,
- int start_block, int end_block,
- VP8Histogram* const histo) {
- int j;
- int distribution[MAX_COEFF_THRESH + 1] = { 0 };
- const int max_coeff = (MAX_COEFF_THRESH << 16) + MAX_COEFF_THRESH;
- for (j = start_block; j < end_block; ++j) {
- int16_t out[16];
- int temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7, temp8;
-
- VP8FTransform(ref + VP8DspScan[j], pred + VP8DspScan[j], out);
-
- // Convert coefficients to bin.
- __asm__ volatile (
- CONVERT_COEFFS_TO_BIN( 0, 4, 8, 12)
- CONVERT_COEFFS_TO_BIN(16, 20, 24, 28)
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [temp4]"=&r"(temp4), [temp5]"=&r"(temp5),
- [temp6]"=&r"(temp6), [temp7]"=&r"(temp7), [temp8]"=&r"(temp8)
- : [dist]"r"(distribution), [out]"r"(out), [max_coeff]"r"(max_coeff)
- : "memory"
- );
- }
- VP8SetHistogramData(distribution, histo);
-}
-
-#undef CONVERT_COEFFS_TO_BIN
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void VP8EncDspInitMIPSdspR2(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void VP8EncDspInitMIPSdspR2(void) {
- VP8FTransform = FTransform_MIPSdspR2;
- VP8FTransformWHT = FTransformWHT_MIPSdspR2;
- VP8ITransform = ITransform_MIPSdspR2;
-
- VP8TDisto4x4 = Disto4x4_MIPSdspR2;
- VP8TDisto16x16 = Disto16x16_MIPSdspR2;
-
- VP8EncPredLuma16 = Intra16Preds_MIPSdspR2;
- VP8EncPredChroma8 = IntraChromaPreds_MIPSdspR2;
- VP8EncPredLuma4 = Intra4Preds_MIPSdspR2;
-
-#if !defined(WORK_AROUND_GCC)
- VP8SSE16x16 = SSE16x16_MIPSdspR2;
- VP8SSE8x8 = SSE8x8_MIPSdspR2;
- VP8SSE16x8 = SSE16x8_MIPSdspR2;
- VP8SSE4x4 = SSE4x4_MIPSdspR2;
-#endif
-
- VP8EncQuantizeBlock = QuantizeBlock_MIPSdspR2;
- VP8EncQuantize2Blocks = Quantize2Blocks_MIPSdspR2;
-
- VP8CollectHistogram = CollectHistogram_MIPSdspR2;
-}
-
-#else // !WEBP_USE_MIPS_DSP_R2
-
-WEBP_DSP_INIT_STUB(VP8EncDspInitMIPSdspR2)
-
-#endif // WEBP_USE_MIPS_DSP_R2
diff --git a/contrib/libs/libwebp/dsp/enc_msa.c b/contrib/libs/libwebp/dsp/enc_msa.c
deleted file mode 100644
index eb80504229..0000000000
--- a/contrib/libs/libwebp/dsp/enc_msa.c
+++ /dev/null
@@ -1,896 +0,0 @@
-// Copyright 2016 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// MSA version of encoder dsp functions.
-//
-// Author: Prashant Patil (prashant.patil@imgtec.com)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_MSA)
-
-#include <stdlib.h>
-#include "./msa_macro.h"
-#include "../enc/vp8i_enc.h"
-
-//------------------------------------------------------------------------------
-// Transforms
-
-#define IDCT_1D_W(in0, in1, in2, in3, out0, out1, out2, out3) do { \
- v4i32 a1_m, b1_m, c1_m, d1_m; \
- const v4i32 cospi8sqrt2minus1 = __msa_fill_w(20091); \
- const v4i32 sinpi8sqrt2 = __msa_fill_w(35468); \
- v4i32 c_tmp1_m = in1 * sinpi8sqrt2; \
- v4i32 c_tmp2_m = in3 * cospi8sqrt2minus1; \
- v4i32 d_tmp1_m = in1 * cospi8sqrt2minus1; \
- v4i32 d_tmp2_m = in3 * sinpi8sqrt2; \
- \
- ADDSUB2(in0, in2, a1_m, b1_m); \
- SRAI_W2_SW(c_tmp1_m, c_tmp2_m, 16); \
- c_tmp2_m = c_tmp2_m + in3; \
- c1_m = c_tmp1_m - c_tmp2_m; \
- SRAI_W2_SW(d_tmp1_m, d_tmp2_m, 16); \
- d_tmp1_m = d_tmp1_m + in1; \
- d1_m = d_tmp1_m + d_tmp2_m; \
- BUTTERFLY_4(a1_m, b1_m, c1_m, d1_m, out0, out1, out2, out3); \
-} while (0)
-
-static WEBP_INLINE void ITransformOne(const uint8_t* ref, const int16_t* in,
- uint8_t* dst) {
- v8i16 input0, input1;
- v4i32 in0, in1, in2, in3, hz0, hz1, hz2, hz3, vt0, vt1, vt2, vt3;
- v4i32 res0, res1, res2, res3;
- v16i8 dest0, dest1, dest2, dest3;
- const v16i8 zero = { 0 };
-
- LD_SH2(in, 8, input0, input1);
- UNPCK_SH_SW(input0, in0, in1);
- UNPCK_SH_SW(input1, in2, in3);
- IDCT_1D_W(in0, in1, in2, in3, hz0, hz1, hz2, hz3);
- TRANSPOSE4x4_SW_SW(hz0, hz1, hz2, hz3, hz0, hz1, hz2, hz3);
- IDCT_1D_W(hz0, hz1, hz2, hz3, vt0, vt1, vt2, vt3);
- SRARI_W4_SW(vt0, vt1, vt2, vt3, 3);
- TRANSPOSE4x4_SW_SW(vt0, vt1, vt2, vt3, vt0, vt1, vt2, vt3);
- LD_SB4(ref, BPS, dest0, dest1, dest2, dest3);
- ILVR_B4_SW(zero, dest0, zero, dest1, zero, dest2, zero, dest3,
- res0, res1, res2, res3);
- ILVR_H4_SW(zero, res0, zero, res1, zero, res2, zero, res3,
- res0, res1, res2, res3);
- ADD4(res0, vt0, res1, vt1, res2, vt2, res3, vt3, res0, res1, res2, res3);
- CLIP_SW4_0_255(res0, res1, res2, res3);
- PCKEV_B2_SW(res0, res1, res2, res3, vt0, vt1);
- res0 = (v4i32)__msa_pckev_b((v16i8)vt0, (v16i8)vt1);
- ST4x4_UB(res0, res0, 3, 2, 1, 0, dst, BPS);
-}
-
-static void ITransform_MSA(const uint8_t* ref, const int16_t* in, uint8_t* dst,
- int do_two) {
- ITransformOne(ref, in, dst);
- if (do_two) {
- ITransformOne(ref + 4, in + 16, dst + 4);
- }
-}
-
-static void FTransform_MSA(const uint8_t* src, const uint8_t* ref,
- int16_t* out) {
- uint64_t out0, out1, out2, out3;
- uint32_t in0, in1, in2, in3;
- v4i32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5;
- v8i16 t0, t1, t2, t3;
- v16u8 srcl0, srcl1, src0 = { 0 }, src1 = { 0 };
- const v8i16 mask0 = { 0, 4, 8, 12, 1, 5, 9, 13 };
- const v8i16 mask1 = { 3, 7, 11, 15, 2, 6, 10, 14 };
- const v8i16 mask2 = { 4, 0, 5, 1, 6, 2, 7, 3 };
- const v8i16 mask3 = { 0, 4, 1, 5, 2, 6, 3, 7 };
- const v8i16 cnst0 = { 2217, -5352, 2217, -5352, 2217, -5352, 2217, -5352 };
- const v8i16 cnst1 = { 5352, 2217, 5352, 2217, 5352, 2217, 5352, 2217 };
-
- LW4(src, BPS, in0, in1, in2, in3);
- INSERT_W4_UB(in0, in1, in2, in3, src0);
- LW4(ref, BPS, in0, in1, in2, in3);
- INSERT_W4_UB(in0, in1, in2, in3, src1);
- ILVRL_B2_UB(src0, src1, srcl0, srcl1);
- HSUB_UB2_SH(srcl0, srcl1, t0, t1);
- VSHF_H2_SH(t0, t1, t0, t1, mask0, mask1, t2, t3);
- ADDSUB2(t2, t3, t0, t1);
- t0 = SRLI_H(t0, 3);
- VSHF_H2_SH(t0, t0, t1, t1, mask2, mask3, t3, t2);
- tmp0 = __msa_hadd_s_w(t3, t3);
- tmp2 = __msa_hsub_s_w(t3, t3);
- FILL_W2_SW(1812, 937, tmp1, tmp3);
- DPADD_SH2_SW(t2, t2, cnst0, cnst1, tmp3, tmp1);
- SRAI_W2_SW(tmp1, tmp3, 9);
- PCKEV_H2_SH(tmp1, tmp0, tmp3, tmp2, t0, t1);
- VSHF_H2_SH(t0, t1, t0, t1, mask0, mask1, t2, t3);
- ADDSUB2(t2, t3, t0, t1);
- VSHF_H2_SH(t0, t0, t1, t1, mask2, mask3, t3, t2);
- tmp0 = __msa_hadd_s_w(t3, t3);
- tmp2 = __msa_hsub_s_w(t3, t3);
- ADDVI_W2_SW(tmp0, 7, tmp2, 7, tmp0, tmp2);
- SRAI_W2_SW(tmp0, tmp2, 4);
- FILL_W2_SW(12000, 51000, tmp1, tmp3);
- DPADD_SH2_SW(t2, t2, cnst0, cnst1, tmp3, tmp1);
- SRAI_W2_SW(tmp1, tmp3, 16);
- UNPCK_R_SH_SW(t1, tmp4);
- tmp5 = __msa_ceqi_w(tmp4, 0);
- tmp4 = (v4i32)__msa_nor_v((v16u8)tmp5, (v16u8)tmp5);
- tmp5 = __msa_fill_w(1);
- tmp5 = (v4i32)__msa_and_v((v16u8)tmp5, (v16u8)tmp4);
- tmp1 += tmp5;
- PCKEV_H2_SH(tmp1, tmp0, tmp3, tmp2, t0, t1);
- out0 = __msa_copy_s_d((v2i64)t0, 0);
- out1 = __msa_copy_s_d((v2i64)t0, 1);
- out2 = __msa_copy_s_d((v2i64)t1, 0);
- out3 = __msa_copy_s_d((v2i64)t1, 1);
- SD4(out0, out1, out2, out3, out, 8);
-}
-
-static void FTransformWHT_MSA(const int16_t* in, int16_t* out) {
- v8i16 in0 = { 0 };
- v8i16 in1 = { 0 };
- v8i16 tmp0, tmp1, tmp2, tmp3;
- v8i16 out0, out1;
- const v8i16 mask0 = { 0, 1, 2, 3, 8, 9, 10, 11 };
- const v8i16 mask1 = { 4, 5, 6, 7, 12, 13, 14, 15 };
- const v8i16 mask2 = { 0, 4, 8, 12, 1, 5, 9, 13 };
- const v8i16 mask3 = { 3, 7, 11, 15, 2, 6, 10, 14 };
-
- in0 = __msa_insert_h(in0, 0, in[ 0]);
- in0 = __msa_insert_h(in0, 1, in[ 64]);
- in0 = __msa_insert_h(in0, 2, in[128]);
- in0 = __msa_insert_h(in0, 3, in[192]);
- in0 = __msa_insert_h(in0, 4, in[ 16]);
- in0 = __msa_insert_h(in0, 5, in[ 80]);
- in0 = __msa_insert_h(in0, 6, in[144]);
- in0 = __msa_insert_h(in0, 7, in[208]);
- in1 = __msa_insert_h(in1, 0, in[ 48]);
- in1 = __msa_insert_h(in1, 1, in[112]);
- in1 = __msa_insert_h(in1, 2, in[176]);
- in1 = __msa_insert_h(in1, 3, in[240]);
- in1 = __msa_insert_h(in1, 4, in[ 32]);
- in1 = __msa_insert_h(in1, 5, in[ 96]);
- in1 = __msa_insert_h(in1, 6, in[160]);
- in1 = __msa_insert_h(in1, 7, in[224]);
- ADDSUB2(in0, in1, tmp0, tmp1);
- VSHF_H2_SH(tmp0, tmp1, tmp0, tmp1, mask0, mask1, tmp2, tmp3);
- ADDSUB2(tmp2, tmp3, tmp0, tmp1);
- VSHF_H2_SH(tmp0, tmp1, tmp0, tmp1, mask2, mask3, in0, in1);
- ADDSUB2(in0, in1, tmp0, tmp1);
- VSHF_H2_SH(tmp0, tmp1, tmp0, tmp1, mask0, mask1, tmp2, tmp3);
- ADDSUB2(tmp2, tmp3, out0, out1);
- SRAI_H2_SH(out0, out1, 1);
- ST_SH2(out0, out1, out, 8);
-}
-
-static int TTransform_MSA(const uint8_t* in, const uint16_t* w) {
- int sum;
- uint32_t in0_m, in1_m, in2_m, in3_m;
- v16i8 src0 = { 0 };
- v8i16 in0, in1, tmp0, tmp1, tmp2, tmp3;
- v4i32 dst0, dst1;
- const v16i8 zero = { 0 };
- const v8i16 mask0 = { 0, 1, 2, 3, 8, 9, 10, 11 };
- const v8i16 mask1 = { 4, 5, 6, 7, 12, 13, 14, 15 };
- const v8i16 mask2 = { 0, 4, 8, 12, 1, 5, 9, 13 };
- const v8i16 mask3 = { 3, 7, 11, 15, 2, 6, 10, 14 };
-
- LW4(in, BPS, in0_m, in1_m, in2_m, in3_m);
- INSERT_W4_SB(in0_m, in1_m, in2_m, in3_m, src0);
- ILVRL_B2_SH(zero, src0, tmp0, tmp1);
- VSHF_H2_SH(tmp0, tmp1, tmp0, tmp1, mask2, mask3, in0, in1);
- ADDSUB2(in0, in1, tmp0, tmp1);
- VSHF_H2_SH(tmp0, tmp1, tmp0, tmp1, mask0, mask1, tmp2, tmp3);
- ADDSUB2(tmp2, tmp3, tmp0, tmp1);
- VSHF_H2_SH(tmp0, tmp1, tmp0, tmp1, mask2, mask3, in0, in1);
- ADDSUB2(in0, in1, tmp0, tmp1);
- VSHF_H2_SH(tmp0, tmp1, tmp0, tmp1, mask0, mask1, tmp2, tmp3);
- ADDSUB2(tmp2, tmp3, tmp0, tmp1);
- tmp0 = __msa_add_a_h(tmp0, (v8i16)zero);
- tmp1 = __msa_add_a_h(tmp1, (v8i16)zero);
- LD_SH2(w, 8, tmp2, tmp3);
- DOTP_SH2_SW(tmp0, tmp1, tmp2, tmp3, dst0, dst1);
- dst0 = dst0 + dst1;
- sum = HADD_SW_S32(dst0);
- return sum;
-}
-
-static int Disto4x4_MSA(const uint8_t* const a, const uint8_t* const b,
- const uint16_t* const w) {
- const int sum1 = TTransform_MSA(a, w);
- const int sum2 = TTransform_MSA(b, w);
- return abs(sum2 - sum1) >> 5;
-}
-
-static int Disto16x16_MSA(const uint8_t* const a, const uint8_t* const b,
- const uint16_t* const w) {
- int D = 0;
- int x, y;
- for (y = 0; y < 16 * BPS; y += 4 * BPS) {
- for (x = 0; x < 16; x += 4) {
- D += Disto4x4_MSA(a + x + y, b + x + y, w);
- }
- }
- return D;
-}
-
-//------------------------------------------------------------------------------
-// Histogram
-
-static void CollectHistogram_MSA(const uint8_t* ref, const uint8_t* pred,
- int start_block, int end_block,
- VP8Histogram* const histo) {
- int j;
- int distribution[MAX_COEFF_THRESH + 1] = { 0 };
- for (j = start_block; j < end_block; ++j) {
- int16_t out[16];
- VP8FTransform(ref + VP8DspScan[j], pred + VP8DspScan[j], out);
- {
- int k;
- v8i16 coeff0, coeff1;
- const v8i16 zero = { 0 };
- const v8i16 max_coeff_thr = __msa_ldi_h(MAX_COEFF_THRESH);
- LD_SH2(&out[0], 8, coeff0, coeff1);
- coeff0 = __msa_add_a_h(coeff0, zero);
- coeff1 = __msa_add_a_h(coeff1, zero);
- SRAI_H2_SH(coeff0, coeff1, 3);
- coeff0 = __msa_min_s_h(coeff0, max_coeff_thr);
- coeff1 = __msa_min_s_h(coeff1, max_coeff_thr);
- ST_SH2(coeff0, coeff1, &out[0], 8);
- for (k = 0; k < 16; ++k) {
- ++distribution[out[k]];
- }
- }
- }
- VP8SetHistogramData(distribution, histo);
-}
-
-//------------------------------------------------------------------------------
-// Intra predictions
-
-// luma 4x4 prediction
-
-#define DST(x, y) dst[(x) + (y) * BPS]
-#define AVG3(a, b, c) (((a) + 2 * (b) + (c) + 2) >> 2)
-#define AVG2(a, b) (((a) + (b) + 1) >> 1)
-
-static WEBP_INLINE void VE4(uint8_t* dst, const uint8_t* top) { // vertical
- const v16u8 A1 = { 0 };
- const uint64_t val_m = LD(top - 1);
- const v16u8 A = (v16u8)__msa_insert_d((v2i64)A1, 0, val_m);
- const v16u8 B = SLDI_UB(A, A, 1);
- const v16u8 C = SLDI_UB(A, A, 2);
- const v16u8 AC = __msa_ave_u_b(A, C);
- const v16u8 B2 = __msa_ave_u_b(B, B);
- const v16u8 R = __msa_aver_u_b(AC, B2);
- const uint32_t out = __msa_copy_s_w((v4i32)R, 0);
- SW4(out, out, out, out, dst, BPS);
-}
-
-static WEBP_INLINE void HE4(uint8_t* dst, const uint8_t* top) { // horizontal
- const int X = top[-1];
- const int I = top[-2];
- const int J = top[-3];
- const int K = top[-4];
- const int L = top[-5];
- WebPUint32ToMem(dst + 0 * BPS, 0x01010101U * AVG3(X, I, J));
- WebPUint32ToMem(dst + 1 * BPS, 0x01010101U * AVG3(I, J, K));
- WebPUint32ToMem(dst + 2 * BPS, 0x01010101U * AVG3(J, K, L));
- WebPUint32ToMem(dst + 3 * BPS, 0x01010101U * AVG3(K, L, L));
-}
-
-static WEBP_INLINE void DC4(uint8_t* dst, const uint8_t* top) {
- uint32_t dc = 4;
- int i;
- for (i = 0; i < 4; ++i) dc += top[i] + top[-5 + i];
- dc >>= 3;
- dc = dc | (dc << 8) | (dc << 16) | (dc << 24);
- SW4(dc, dc, dc, dc, dst, BPS);
-}
-
-static WEBP_INLINE void RD4(uint8_t* dst, const uint8_t* top) {
- const v16u8 A2 = { 0 };
- const uint64_t val_m = LD(top - 5);
- const v16u8 A1 = (v16u8)__msa_insert_d((v2i64)A2, 0, val_m);
- const v16u8 A = (v16u8)__msa_insert_b((v16i8)A1, 8, top[3]);
- const v16u8 B = SLDI_UB(A, A, 1);
- const v16u8 C = SLDI_UB(A, A, 2);
- const v16u8 AC = __msa_ave_u_b(A, C);
- const v16u8 B2 = __msa_ave_u_b(B, B);
- const v16u8 R0 = __msa_aver_u_b(AC, B2);
- const v16u8 R1 = SLDI_UB(R0, R0, 1);
- const v16u8 R2 = SLDI_UB(R1, R1, 1);
- const v16u8 R3 = SLDI_UB(R2, R2, 1);
- const uint32_t val0 = __msa_copy_s_w((v4i32)R0, 0);
- const uint32_t val1 = __msa_copy_s_w((v4i32)R1, 0);
- const uint32_t val2 = __msa_copy_s_w((v4i32)R2, 0);
- const uint32_t val3 = __msa_copy_s_w((v4i32)R3, 0);
- SW4(val3, val2, val1, val0, dst, BPS);
-}
-
-static WEBP_INLINE void LD4(uint8_t* dst, const uint8_t* top) {
- const v16u8 A1 = { 0 };
- const uint64_t val_m = LD(top);
- const v16u8 A = (v16u8)__msa_insert_d((v2i64)A1, 0, val_m);
- const v16u8 B = SLDI_UB(A, A, 1);
- const v16u8 C1 = SLDI_UB(A, A, 2);
- const v16u8 C = (v16u8)__msa_insert_b((v16i8)C1, 6, top[7]);
- const v16u8 AC = __msa_ave_u_b(A, C);
- const v16u8 B2 = __msa_ave_u_b(B, B);
- const v16u8 R0 = __msa_aver_u_b(AC, B2);
- const v16u8 R1 = SLDI_UB(R0, R0, 1);
- const v16u8 R2 = SLDI_UB(R1, R1, 1);
- const v16u8 R3 = SLDI_UB(R2, R2, 1);
- const uint32_t val0 = __msa_copy_s_w((v4i32)R0, 0);
- const uint32_t val1 = __msa_copy_s_w((v4i32)R1, 0);
- const uint32_t val2 = __msa_copy_s_w((v4i32)R2, 0);
- const uint32_t val3 = __msa_copy_s_w((v4i32)R3, 0);
- SW4(val0, val1, val2, val3, dst, BPS);
-}
-
-static WEBP_INLINE void VR4(uint8_t* dst, const uint8_t* top) {
- const int X = top[-1];
- const int I = top[-2];
- const int J = top[-3];
- const int K = top[-4];
- const int A = top[0];
- const int B = top[1];
- const int C = top[2];
- const int D = top[3];
- DST(0, 0) = DST(1, 2) = AVG2(X, A);
- DST(1, 0) = DST(2, 2) = AVG2(A, B);
- DST(2, 0) = DST(3, 2) = AVG2(B, C);
- DST(3, 0) = AVG2(C, D);
- DST(0, 3) = AVG3(K, J, I);
- DST(0, 2) = AVG3(J, I, X);
- DST(0, 1) = DST(1, 3) = AVG3(I, X, A);
- DST(1, 1) = DST(2, 3) = AVG3(X, A, B);
- DST(2, 1) = DST(3, 3) = AVG3(A, B, C);
- DST(3, 1) = AVG3(B, C, D);
-}
-
-static WEBP_INLINE void VL4(uint8_t* dst, const uint8_t* top) {
- const int A = top[0];
- const int B = top[1];
- const int C = top[2];
- const int D = top[3];
- const int E = top[4];
- const int F = top[5];
- const int G = top[6];
- const int H = top[7];
- DST(0, 0) = AVG2(A, B);
- DST(1, 0) = DST(0, 2) = AVG2(B, C);
- DST(2, 0) = DST(1, 2) = AVG2(C, D);
- DST(3, 0) = DST(2, 2) = AVG2(D, E);
- DST(0, 1) = AVG3(A, B, C);
- DST(1, 1) = DST(0, 3) = AVG3(B, C, D);
- DST(2, 1) = DST(1, 3) = AVG3(C, D, E);
- DST(3, 1) = DST(2, 3) = AVG3(D, E, F);
- DST(3, 2) = AVG3(E, F, G);
- DST(3, 3) = AVG3(F, G, H);
-}
-
-static WEBP_INLINE void HU4(uint8_t* dst, const uint8_t* top) {
- const int I = top[-2];
- const int J = top[-3];
- const int K = top[-4];
- const int L = top[-5];
- DST(0, 0) = AVG2(I, J);
- DST(2, 0) = DST(0, 1) = AVG2(J, K);
- DST(2, 1) = DST(0, 2) = AVG2(K, L);
- DST(1, 0) = AVG3(I, J, K);
- DST(3, 0) = DST(1, 1) = AVG3(J, K, L);
- DST(3, 1) = DST(1, 2) = AVG3(K, L, L);
- DST(3, 2) = DST(2, 2) =
- DST(0, 3) = DST(1, 3) = DST(2, 3) = DST(3, 3) = L;
-}
-
-static WEBP_INLINE void HD4(uint8_t* dst, const uint8_t* top) {
- const int X = top[-1];
- const int I = top[-2];
- const int J = top[-3];
- const int K = top[-4];
- const int L = top[-5];
- const int A = top[0];
- const int B = top[1];
- const int C = top[2];
- DST(0, 0) = DST(2, 1) = AVG2(I, X);
- DST(0, 1) = DST(2, 2) = AVG2(J, I);
- DST(0, 2) = DST(2, 3) = AVG2(K, J);
- DST(0, 3) = AVG2(L, K);
- DST(3, 0) = AVG3(A, B, C);
- DST(2, 0) = AVG3(X, A, B);
- DST(1, 0) = DST(3, 1) = AVG3(I, X, A);
- DST(1, 1) = DST(3, 2) = AVG3(J, I, X);
- DST(1, 2) = DST(3, 3) = AVG3(K, J, I);
- DST(1, 3) = AVG3(L, K, J);
-}
-
-static WEBP_INLINE void TM4(uint8_t* dst, const uint8_t* top) {
- const v16i8 zero = { 0 };
- const v8i16 TL = (v8i16)__msa_fill_h(top[-1]);
- const v8i16 L0 = (v8i16)__msa_fill_h(top[-2]);
- const v8i16 L1 = (v8i16)__msa_fill_h(top[-3]);
- const v8i16 L2 = (v8i16)__msa_fill_h(top[-4]);
- const v8i16 L3 = (v8i16)__msa_fill_h(top[-5]);
- const v16u8 T1 = LD_UB(top);
- const v8i16 T = (v8i16)__msa_ilvr_b(zero, (v16i8)T1);
- const v8i16 d = T - TL;
- v8i16 r0, r1, r2, r3;
- ADD4(d, L0, d, L1, d, L2, d, L3, r0, r1, r2, r3);
- CLIP_SH4_0_255(r0, r1, r2, r3);
- PCKEV_ST4x4_UB(r0, r1, r2, r3, dst, BPS);
-}
-
-#undef DST
-#undef AVG3
-#undef AVG2
-
-static void Intra4Preds_MSA(uint8_t* dst, const uint8_t* top) {
- DC4(I4DC4 + dst, top);
- TM4(I4TM4 + dst, top);
- VE4(I4VE4 + dst, top);
- HE4(I4HE4 + dst, top);
- RD4(I4RD4 + dst, top);
- VR4(I4VR4 + dst, top);
- LD4(I4LD4 + dst, top);
- VL4(I4VL4 + dst, top);
- HD4(I4HD4 + dst, top);
- HU4(I4HU4 + dst, top);
-}
-
-// luma 16x16 prediction
-
-#define STORE16x16(out, dst) do { \
- ST_UB8(out, out, out, out, out, out, out, out, dst + 0 * BPS, BPS); \
- ST_UB8(out, out, out, out, out, out, out, out, dst + 8 * BPS, BPS); \
-} while (0)
-
-static WEBP_INLINE void VerticalPred16x16(uint8_t* dst, const uint8_t* top) {
- if (top != NULL) {
- const v16u8 out = LD_UB(top);
- STORE16x16(out, dst);
- } else {
- const v16u8 out = (v16u8)__msa_fill_b(0x7f);
- STORE16x16(out, dst);
- }
-}
-
-static WEBP_INLINE void HorizontalPred16x16(uint8_t* dst,
- const uint8_t* left) {
- if (left != NULL) {
- int j;
- for (j = 0; j < 16; j += 4) {
- const v16u8 L0 = (v16u8)__msa_fill_b(left[0]);
- const v16u8 L1 = (v16u8)__msa_fill_b(left[1]);
- const v16u8 L2 = (v16u8)__msa_fill_b(left[2]);
- const v16u8 L3 = (v16u8)__msa_fill_b(left[3]);
- ST_UB4(L0, L1, L2, L3, dst, BPS);
- dst += 4 * BPS;
- left += 4;
- }
- } else {
- const v16u8 out = (v16u8)__msa_fill_b(0x81);
- STORE16x16(out, dst);
- }
-}
-
-static WEBP_INLINE void TrueMotion16x16(uint8_t* dst, const uint8_t* left,
- const uint8_t* top) {
- if (left != NULL) {
- if (top != NULL) {
- int j;
- v8i16 d1, d2;
- const v16i8 zero = { 0 };
- const v8i16 TL = (v8i16)__msa_fill_h(left[-1]);
- const v16u8 T = LD_UB(top);
- ILVRL_B2_SH(zero, T, d1, d2);
- SUB2(d1, TL, d2, TL, d1, d2);
- for (j = 0; j < 16; j += 4) {
- v16i8 t0, t1, t2, t3;
- v8i16 r0, r1, r2, r3, r4, r5, r6, r7;
- const v8i16 L0 = (v8i16)__msa_fill_h(left[j + 0]);
- const v8i16 L1 = (v8i16)__msa_fill_h(left[j + 1]);
- const v8i16 L2 = (v8i16)__msa_fill_h(left[j + 2]);
- const v8i16 L3 = (v8i16)__msa_fill_h(left[j + 3]);
- ADD4(d1, L0, d1, L1, d1, L2, d1, L3, r0, r1, r2, r3);
- ADD4(d2, L0, d2, L1, d2, L2, d2, L3, r4, r5, r6, r7);
- CLIP_SH4_0_255(r0, r1, r2, r3);
- CLIP_SH4_0_255(r4, r5, r6, r7);
- PCKEV_B4_SB(r4, r0, r5, r1, r6, r2, r7, r3, t0, t1, t2, t3);
- ST_SB4(t0, t1, t2, t3, dst, BPS);
- dst += 4 * BPS;
- }
- } else {
- HorizontalPred16x16(dst, left);
- }
- } else {
- if (top != NULL) {
- VerticalPred16x16(dst, top);
- } else {
- const v16u8 out = (v16u8)__msa_fill_b(0x81);
- STORE16x16(out, dst);
- }
- }
-}
-
-static WEBP_INLINE void DCMode16x16(uint8_t* dst, const uint8_t* left,
- const uint8_t* top) {
- int DC;
- v16u8 out;
- if (top != NULL && left != NULL) {
- const v16u8 rtop = LD_UB(top);
- const v8u16 dctop = __msa_hadd_u_h(rtop, rtop);
- const v16u8 rleft = LD_UB(left);
- const v8u16 dcleft = __msa_hadd_u_h(rleft, rleft);
- const v8u16 dctemp = dctop + dcleft;
- DC = HADD_UH_U32(dctemp);
- DC = (DC + 16) >> 5;
- } else if (left != NULL) { // left but no top
- const v16u8 rleft = LD_UB(left);
- const v8u16 dcleft = __msa_hadd_u_h(rleft, rleft);
- DC = HADD_UH_U32(dcleft);
- DC = (DC + DC + 16) >> 5;
- } else if (top != NULL) { // top but no left
- const v16u8 rtop = LD_UB(top);
- const v8u16 dctop = __msa_hadd_u_h(rtop, rtop);
- DC = HADD_UH_U32(dctop);
- DC = (DC + DC + 16) >> 5;
- } else { // no top, no left, nothing.
- DC = 0x80;
- }
- out = (v16u8)__msa_fill_b(DC);
- STORE16x16(out, dst);
-}
-
-static void Intra16Preds_MSA(uint8_t* dst,
- const uint8_t* left, const uint8_t* top) {
- DCMode16x16(I16DC16 + dst, left, top);
- VerticalPred16x16(I16VE16 + dst, top);
- HorizontalPred16x16(I16HE16 + dst, left);
- TrueMotion16x16(I16TM16 + dst, left, top);
-}
-
-// Chroma 8x8 prediction
-
-#define CALC_DC8(in, out) do { \
- const v8u16 temp0 = __msa_hadd_u_h(in, in); \
- const v4u32 temp1 = __msa_hadd_u_w(temp0, temp0); \
- const v2i64 temp2 = (v2i64)__msa_hadd_u_d(temp1, temp1); \
- const v2i64 temp3 = __msa_splati_d(temp2, 1); \
- const v2i64 temp4 = temp3 + temp2; \
- const v16i8 temp5 = (v16i8)__msa_srari_d(temp4, 4); \
- const v2i64 temp6 = (v2i64)__msa_splati_b(temp5, 0); \
- out = __msa_copy_s_d(temp6, 0); \
-} while (0)
-
-#define STORE8x8(out, dst) do { \
- SD4(out, out, out, out, dst + 0 * BPS, BPS); \
- SD4(out, out, out, out, dst + 4 * BPS, BPS); \
-} while (0)
-
-static WEBP_INLINE void VerticalPred8x8(uint8_t* dst, const uint8_t* top) {
- if (top != NULL) {
- const uint64_t out = LD(top);
- STORE8x8(out, dst);
- } else {
- const uint64_t out = 0x7f7f7f7f7f7f7f7fULL;
- STORE8x8(out, dst);
- }
-}
-
-static WEBP_INLINE void HorizontalPred8x8(uint8_t* dst, const uint8_t* left) {
- if (left != NULL) {
- int j;
- for (j = 0; j < 8; j += 4) {
- const v16u8 L0 = (v16u8)__msa_fill_b(left[0]);
- const v16u8 L1 = (v16u8)__msa_fill_b(left[1]);
- const v16u8 L2 = (v16u8)__msa_fill_b(left[2]);
- const v16u8 L3 = (v16u8)__msa_fill_b(left[3]);
- const uint64_t out0 = __msa_copy_s_d((v2i64)L0, 0);
- const uint64_t out1 = __msa_copy_s_d((v2i64)L1, 0);
- const uint64_t out2 = __msa_copy_s_d((v2i64)L2, 0);
- const uint64_t out3 = __msa_copy_s_d((v2i64)L3, 0);
- SD4(out0, out1, out2, out3, dst, BPS);
- dst += 4 * BPS;
- left += 4;
- }
- } else {
- const uint64_t out = 0x8181818181818181ULL;
- STORE8x8(out, dst);
- }
-}
-
-static WEBP_INLINE void TrueMotion8x8(uint8_t* dst, const uint8_t* left,
- const uint8_t* top) {
- if (left != NULL) {
- if (top != NULL) {
- int j;
- const v8i16 TL = (v8i16)__msa_fill_h(left[-1]);
- const v16u8 T1 = LD_UB(top);
- const v16i8 zero = { 0 };
- const v8i16 T = (v8i16)__msa_ilvr_b(zero, (v16i8)T1);
- const v8i16 d = T - TL;
- for (j = 0; j < 8; j += 4) {
- uint64_t out0, out1, out2, out3;
- v16i8 t0, t1;
- v8i16 r0 = (v8i16)__msa_fill_h(left[j + 0]);
- v8i16 r1 = (v8i16)__msa_fill_h(left[j + 1]);
- v8i16 r2 = (v8i16)__msa_fill_h(left[j + 2]);
- v8i16 r3 = (v8i16)__msa_fill_h(left[j + 3]);
- ADD4(d, r0, d, r1, d, r2, d, r3, r0, r1, r2, r3);
- CLIP_SH4_0_255(r0, r1, r2, r3);
- PCKEV_B2_SB(r1, r0, r3, r2, t0, t1);
- out0 = __msa_copy_s_d((v2i64)t0, 0);
- out1 = __msa_copy_s_d((v2i64)t0, 1);
- out2 = __msa_copy_s_d((v2i64)t1, 0);
- out3 = __msa_copy_s_d((v2i64)t1, 1);
- SD4(out0, out1, out2, out3, dst, BPS);
- dst += 4 * BPS;
- }
- } else {
- HorizontalPred8x8(dst, left);
- }
- } else {
- if (top != NULL) {
- VerticalPred8x8(dst, top);
- } else {
- const uint64_t out = 0x8181818181818181ULL;
- STORE8x8(out, dst);
- }
- }
-}
-
-static WEBP_INLINE void DCMode8x8(uint8_t* dst, const uint8_t* left,
- const uint8_t* top) {
- uint64_t out;
- v16u8 src = { 0 };
- if (top != NULL && left != NULL) {
- const uint64_t left_m = LD(left);
- const uint64_t top_m = LD(top);
- INSERT_D2_UB(left_m, top_m, src);
- CALC_DC8(src, out);
- } else if (left != NULL) { // left but no top
- const uint64_t left_m = LD(left);
- INSERT_D2_UB(left_m, left_m, src);
- CALC_DC8(src, out);
- } else if (top != NULL) { // top but no left
- const uint64_t top_m = LD(top);
- INSERT_D2_UB(top_m, top_m, src);
- CALC_DC8(src, out);
- } else { // no top, no left, nothing.
- src = (v16u8)__msa_fill_b(0x80);
- out = __msa_copy_s_d((v2i64)src, 0);
- }
- STORE8x8(out, dst);
-}
-
-static void IntraChromaPreds_MSA(uint8_t* dst, const uint8_t* left,
- const uint8_t* top) {
- // U block
- DCMode8x8(C8DC8 + dst, left, top);
- VerticalPred8x8(C8VE8 + dst, top);
- HorizontalPred8x8(C8HE8 + dst, left);
- TrueMotion8x8(C8TM8 + dst, left, top);
- // V block
- dst += 8;
- if (top != NULL) top += 8;
- if (left != NULL) left += 16;
- DCMode8x8(C8DC8 + dst, left, top);
- VerticalPred8x8(C8VE8 + dst, top);
- HorizontalPred8x8(C8HE8 + dst, left);
- TrueMotion8x8(C8TM8 + dst, left, top);
-}
-
-//------------------------------------------------------------------------------
-// Metric
-
-#define PACK_DOTP_UB4_SW(in0, in1, in2, in3, out0, out1, out2, out3) do { \
- v16u8 tmp0, tmp1; \
- v8i16 tmp2, tmp3; \
- ILVRL_B2_UB(in0, in1, tmp0, tmp1); \
- HSUB_UB2_SH(tmp0, tmp1, tmp2, tmp3); \
- DOTP_SH2_SW(tmp2, tmp3, tmp2, tmp3, out0, out1); \
- ILVRL_B2_UB(in2, in3, tmp0, tmp1); \
- HSUB_UB2_SH(tmp0, tmp1, tmp2, tmp3); \
- DOTP_SH2_SW(tmp2, tmp3, tmp2, tmp3, out2, out3); \
-} while (0)
-
-#define PACK_DPADD_UB4_SW(in0, in1, in2, in3, out0, out1, out2, out3) do { \
- v16u8 tmp0, tmp1; \
- v8i16 tmp2, tmp3; \
- ILVRL_B2_UB(in0, in1, tmp0, tmp1); \
- HSUB_UB2_SH(tmp0, tmp1, tmp2, tmp3); \
- DPADD_SH2_SW(tmp2, tmp3, tmp2, tmp3, out0, out1); \
- ILVRL_B2_UB(in2, in3, tmp0, tmp1); \
- HSUB_UB2_SH(tmp0, tmp1, tmp2, tmp3); \
- DPADD_SH2_SW(tmp2, tmp3, tmp2, tmp3, out2, out3); \
-} while (0)
-
-static int SSE16x16_MSA(const uint8_t* a, const uint8_t* b) {
- uint32_t sum;
- v16u8 src0, src1, src2, src3, src4, src5, src6, src7;
- v16u8 ref0, ref1, ref2, ref3, ref4, ref5, ref6, ref7;
- v4i32 out0, out1, out2, out3;
-
- LD_UB8(a, BPS, src0, src1, src2, src3, src4, src5, src6, src7);
- LD_UB8(b, BPS, ref0, ref1, ref2, ref3, ref4, ref5, ref6, ref7);
- PACK_DOTP_UB4_SW(src0, ref0, src1, ref1, out0, out1, out2, out3);
- PACK_DPADD_UB4_SW(src2, ref2, src3, ref3, out0, out1, out2, out3);
- PACK_DPADD_UB4_SW(src4, ref4, src5, ref5, out0, out1, out2, out3);
- PACK_DPADD_UB4_SW(src6, ref6, src7, ref7, out0, out1, out2, out3);
- a += 8 * BPS;
- b += 8 * BPS;
- LD_UB8(a, BPS, src0, src1, src2, src3, src4, src5, src6, src7);
- LD_UB8(b, BPS, ref0, ref1, ref2, ref3, ref4, ref5, ref6, ref7);
- PACK_DPADD_UB4_SW(src0, ref0, src1, ref1, out0, out1, out2, out3);
- PACK_DPADD_UB4_SW(src2, ref2, src3, ref3, out0, out1, out2, out3);
- PACK_DPADD_UB4_SW(src4, ref4, src5, ref5, out0, out1, out2, out3);
- PACK_DPADD_UB4_SW(src6, ref6, src7, ref7, out0, out1, out2, out3);
- out0 += out1;
- out2 += out3;
- out0 += out2;
- sum = HADD_SW_S32(out0);
- return sum;
-}
-
-static int SSE16x8_MSA(const uint8_t* a, const uint8_t* b) {
- uint32_t sum;
- v16u8 src0, src1, src2, src3, src4, src5, src6, src7;
- v16u8 ref0, ref1, ref2, ref3, ref4, ref5, ref6, ref7;
- v4i32 out0, out1, out2, out3;
-
- LD_UB8(a, BPS, src0, src1, src2, src3, src4, src5, src6, src7);
- LD_UB8(b, BPS, ref0, ref1, ref2, ref3, ref4, ref5, ref6, ref7);
- PACK_DOTP_UB4_SW(src0, ref0, src1, ref1, out0, out1, out2, out3);
- PACK_DPADD_UB4_SW(src2, ref2, src3, ref3, out0, out1, out2, out3);
- PACK_DPADD_UB4_SW(src4, ref4, src5, ref5, out0, out1, out2, out3);
- PACK_DPADD_UB4_SW(src6, ref6, src7, ref7, out0, out1, out2, out3);
- out0 += out1;
- out2 += out3;
- out0 += out2;
- sum = HADD_SW_S32(out0);
- return sum;
-}
-
-static int SSE8x8_MSA(const uint8_t* a, const uint8_t* b) {
- uint32_t sum;
- v16u8 src0, src1, src2, src3, src4, src5, src6, src7;
- v16u8 ref0, ref1, ref2, ref3, ref4, ref5, ref6, ref7;
- v16u8 t0, t1, t2, t3;
- v4i32 out0, out1, out2, out3;
-
- LD_UB8(a, BPS, src0, src1, src2, src3, src4, src5, src6, src7);
- LD_UB8(b, BPS, ref0, ref1, ref2, ref3, ref4, ref5, ref6, ref7);
- ILVR_B4_UB(src0, src1, src2, src3, ref0, ref1, ref2, ref3, t0, t1, t2, t3);
- PACK_DOTP_UB4_SW(t0, t2, t1, t3, out0, out1, out2, out3);
- ILVR_B4_UB(src4, src5, src6, src7, ref4, ref5, ref6, ref7, t0, t1, t2, t3);
- PACK_DPADD_UB4_SW(t0, t2, t1, t3, out0, out1, out2, out3);
- out0 += out1;
- out2 += out3;
- out0 += out2;
- sum = HADD_SW_S32(out0);
- return sum;
-}
-
-static int SSE4x4_MSA(const uint8_t* a, const uint8_t* b) {
- uint32_t sum = 0;
- uint32_t src0, src1, src2, src3, ref0, ref1, ref2, ref3;
- v16u8 src = { 0 }, ref = { 0 }, tmp0, tmp1;
- v8i16 diff0, diff1;
- v4i32 out0, out1;
-
- LW4(a, BPS, src0, src1, src2, src3);
- LW4(b, BPS, ref0, ref1, ref2, ref3);
- INSERT_W4_UB(src0, src1, src2, src3, src);
- INSERT_W4_UB(ref0, ref1, ref2, ref3, ref);
- ILVRL_B2_UB(src, ref, tmp0, tmp1);
- HSUB_UB2_SH(tmp0, tmp1, diff0, diff1);
- DOTP_SH2_SW(diff0, diff1, diff0, diff1, out0, out1);
- out0 += out1;
- sum = HADD_SW_S32(out0);
- return sum;
-}
-
-//------------------------------------------------------------------------------
-// Quantization
-
-static int QuantizeBlock_MSA(int16_t in[16], int16_t out[16],
- const VP8Matrix* const mtx) {
- int sum;
- v8i16 in0, in1, sh0, sh1, out0, out1;
- v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, sign0, sign1;
- v4i32 s0, s1, s2, s3, b0, b1, b2, b3, t0, t1, t2, t3;
- const v8i16 zero = { 0 };
- const v8i16 zigzag0 = { 0, 1, 4, 8, 5, 2, 3, 6 };
- const v8i16 zigzag1 = { 9, 12, 13, 10, 7, 11, 14, 15 };
- const v8i16 maxlevel = __msa_fill_h(MAX_LEVEL);
-
- LD_SH2(&in[0], 8, in0, in1);
- LD_SH2(&mtx->sharpen_[0], 8, sh0, sh1);
- tmp4 = __msa_add_a_h(in0, zero);
- tmp5 = __msa_add_a_h(in1, zero);
- ILVRL_H2_SH(sh0, tmp4, tmp0, tmp1);
- ILVRL_H2_SH(sh1, tmp5, tmp2, tmp3);
- HADD_SH4_SW(tmp0, tmp1, tmp2, tmp3, s0, s1, s2, s3);
- sign0 = (in0 < zero);
- sign1 = (in1 < zero); // sign
- LD_SH2(&mtx->iq_[0], 8, tmp0, tmp1); // iq
- ILVRL_H2_SW(zero, tmp0, t0, t1);
- ILVRL_H2_SW(zero, tmp1, t2, t3);
- LD_SW4(&mtx->bias_[0], 4, b0, b1, b2, b3); // bias
- MUL4(t0, s0, t1, s1, t2, s2, t3, s3, t0, t1, t2, t3);
- ADD4(b0, t0, b1, t1, b2, t2, b3, t3, b0, b1, b2, b3);
- SRAI_W4_SW(b0, b1, b2, b3, 17);
- PCKEV_H2_SH(b1, b0, b3, b2, tmp2, tmp3);
- tmp0 = (tmp2 > maxlevel);
- tmp1 = (tmp3 > maxlevel);
- tmp2 = (v8i16)__msa_bmnz_v((v16u8)tmp2, (v16u8)maxlevel, (v16u8)tmp0);
- tmp3 = (v8i16)__msa_bmnz_v((v16u8)tmp3, (v16u8)maxlevel, (v16u8)tmp1);
- SUB2(zero, tmp2, zero, tmp3, tmp0, tmp1);
- tmp2 = (v8i16)__msa_bmnz_v((v16u8)tmp2, (v16u8)tmp0, (v16u8)sign0);
- tmp3 = (v8i16)__msa_bmnz_v((v16u8)tmp3, (v16u8)tmp1, (v16u8)sign1);
- LD_SW4(&mtx->zthresh_[0], 4, t0, t1, t2, t3); // zthresh
- t0 = (s0 > t0);
- t1 = (s1 > t1);
- t2 = (s2 > t2);
- t3 = (s3 > t3);
- PCKEV_H2_SH(t1, t0, t3, t2, tmp0, tmp1);
- tmp4 = (v8i16)__msa_bmnz_v((v16u8)zero, (v16u8)tmp2, (v16u8)tmp0);
- tmp5 = (v8i16)__msa_bmnz_v((v16u8)zero, (v16u8)tmp3, (v16u8)tmp1);
- LD_SH2(&mtx->q_[0], 8, tmp0, tmp1);
- MUL2(tmp4, tmp0, tmp5, tmp1, in0, in1);
- VSHF_H2_SH(tmp4, tmp5, tmp4, tmp5, zigzag0, zigzag1, out0, out1);
- ST_SH2(in0, in1, &in[0], 8);
- ST_SH2(out0, out1, &out[0], 8);
- out0 = __msa_add_a_h(out0, out1);
- sum = HADD_SH_S32(out0);
- return (sum > 0);
-}
-
-static int Quantize2Blocks_MSA(int16_t in[32], int16_t out[32],
- const VP8Matrix* const mtx) {
- int nz;
- nz = VP8EncQuantizeBlock(in + 0 * 16, out + 0 * 16, mtx) << 0;
- nz |= VP8EncQuantizeBlock(in + 1 * 16, out + 1 * 16, mtx) << 1;
- return nz;
-}
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void VP8EncDspInitMSA(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void VP8EncDspInitMSA(void) {
- VP8ITransform = ITransform_MSA;
- VP8FTransform = FTransform_MSA;
- VP8FTransformWHT = FTransformWHT_MSA;
-
- VP8TDisto4x4 = Disto4x4_MSA;
- VP8TDisto16x16 = Disto16x16_MSA;
- VP8CollectHistogram = CollectHistogram_MSA;
-
- VP8EncPredLuma4 = Intra4Preds_MSA;
- VP8EncPredLuma16 = Intra16Preds_MSA;
- VP8EncPredChroma8 = IntraChromaPreds_MSA;
-
- VP8SSE16x16 = SSE16x16_MSA;
- VP8SSE16x8 = SSE16x8_MSA;
- VP8SSE8x8 = SSE8x8_MSA;
- VP8SSE4x4 = SSE4x4_MSA;
-
- VP8EncQuantizeBlock = QuantizeBlock_MSA;
- VP8EncQuantize2Blocks = Quantize2Blocks_MSA;
- VP8EncQuantizeBlockWHT = QuantizeBlock_MSA;
-}
-
-#else // !WEBP_USE_MSA
-
-WEBP_DSP_INIT_STUB(VP8EncDspInitMSA)
-
-#endif // WEBP_USE_MSA
diff --git a/contrib/libs/libwebp/dsp/enc_neon.c b/contrib/libs/libwebp/dsp/enc_neon.c
deleted file mode 100644
index fecb330225..0000000000
--- a/contrib/libs/libwebp/dsp/enc_neon.c
+++ /dev/null
@@ -1,938 +0,0 @@
-// Copyright 2012 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// ARM NEON version of speed-critical encoding functions.
-//
-// adapted from libvpx (https://www.webmproject.org/code/)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_NEON)
-
-#include <assert.h>
-
-#include "./neon.h"
-#include "../enc/vp8i_enc.h"
-
-//------------------------------------------------------------------------------
-// Transforms (Paragraph 14.4)
-
-// Inverse transform.
-// This code is pretty much the same as TransformOne in the dec_neon.c, except
-// for subtraction to *ref. See the comments there for algorithmic explanations.
-
-static const int16_t kC1 = 20091;
-static const int16_t kC2 = 17734; // half of kC2, actually. See comment above.
-
-// This code works but is *slower* than the inlined-asm version below
-// (with gcc-4.6). So we disable it for now. Later, it'll be conditional to
-// WEBP_USE_INTRINSICS define.
-// With gcc-4.8, it's a little faster speed than inlined-assembly.
-#if defined(WEBP_USE_INTRINSICS)
-
-// Treats 'v' as an uint8x8_t and zero extends to an int16x8_t.
-static WEBP_INLINE int16x8_t ConvertU8ToS16_NEON(uint32x2_t v) {
- return vreinterpretq_s16_u16(vmovl_u8(vreinterpret_u8_u32(v)));
-}
-
-// Performs unsigned 8b saturation on 'dst01' and 'dst23' storing the result
-// to the corresponding rows of 'dst'.
-static WEBP_INLINE void SaturateAndStore4x4_NEON(uint8_t* const dst,
- const int16x8_t dst01,
- const int16x8_t dst23) {
- // Unsigned saturate to 8b.
- const uint8x8_t dst01_u8 = vqmovun_s16(dst01);
- const uint8x8_t dst23_u8 = vqmovun_s16(dst23);
-
- // Store the results.
- vst1_lane_u32((uint32_t*)(dst + 0 * BPS), vreinterpret_u32_u8(dst01_u8), 0);
- vst1_lane_u32((uint32_t*)(dst + 1 * BPS), vreinterpret_u32_u8(dst01_u8), 1);
- vst1_lane_u32((uint32_t*)(dst + 2 * BPS), vreinterpret_u32_u8(dst23_u8), 0);
- vst1_lane_u32((uint32_t*)(dst + 3 * BPS), vreinterpret_u32_u8(dst23_u8), 1);
-}
-
-static WEBP_INLINE void Add4x4_NEON(const int16x8_t row01,
- const int16x8_t row23,
- const uint8_t* const ref,
- uint8_t* const dst) {
- uint32x2_t dst01 = vdup_n_u32(0);
- uint32x2_t dst23 = vdup_n_u32(0);
-
- // Load the source pixels.
- dst01 = vld1_lane_u32((uint32_t*)(ref + 0 * BPS), dst01, 0);
- dst23 = vld1_lane_u32((uint32_t*)(ref + 2 * BPS), dst23, 0);
- dst01 = vld1_lane_u32((uint32_t*)(ref + 1 * BPS), dst01, 1);
- dst23 = vld1_lane_u32((uint32_t*)(ref + 3 * BPS), dst23, 1);
-
- {
- // Convert to 16b.
- const int16x8_t dst01_s16 = ConvertU8ToS16_NEON(dst01);
- const int16x8_t dst23_s16 = ConvertU8ToS16_NEON(dst23);
-
- // Descale with rounding.
- const int16x8_t out01 = vrsraq_n_s16(dst01_s16, row01, 3);
- const int16x8_t out23 = vrsraq_n_s16(dst23_s16, row23, 3);
- // Add the inverse transform.
- SaturateAndStore4x4_NEON(dst, out01, out23);
- }
-}
-
-static WEBP_INLINE void Transpose8x2_NEON(const int16x8_t in0,
- const int16x8_t in1,
- int16x8x2_t* const out) {
- // a0 a1 a2 a3 | b0 b1 b2 b3 => a0 b0 c0 d0 | a1 b1 c1 d1
- // c0 c1 c2 c3 | d0 d1 d2 d3 a2 b2 c2 d2 | a3 b3 c3 d3
- const int16x8x2_t tmp0 = vzipq_s16(in0, in1); // a0 c0 a1 c1 a2 c2 ...
- // b0 d0 b1 d1 b2 d2 ...
- *out = vzipq_s16(tmp0.val[0], tmp0.val[1]);
-}
-
-static WEBP_INLINE void TransformPass_NEON(int16x8x2_t* const rows) {
- // {rows} = in0 | in4
- // in8 | in12
- // B1 = in4 | in12
- const int16x8_t B1 =
- vcombine_s16(vget_high_s16(rows->val[0]), vget_high_s16(rows->val[1]));
- // C0 = kC1 * in4 | kC1 * in12
- // C1 = kC2 * in4 | kC2 * in12
- const int16x8_t C0 = vsraq_n_s16(B1, vqdmulhq_n_s16(B1, kC1), 1);
- const int16x8_t C1 = vqdmulhq_n_s16(B1, kC2);
- const int16x4_t a = vqadd_s16(vget_low_s16(rows->val[0]),
- vget_low_s16(rows->val[1])); // in0 + in8
- const int16x4_t b = vqsub_s16(vget_low_s16(rows->val[0]),
- vget_low_s16(rows->val[1])); // in0 - in8
- // c = kC2 * in4 - kC1 * in12
- // d = kC1 * in4 + kC2 * in12
- const int16x4_t c = vqsub_s16(vget_low_s16(C1), vget_high_s16(C0));
- const int16x4_t d = vqadd_s16(vget_low_s16(C0), vget_high_s16(C1));
- const int16x8_t D0 = vcombine_s16(a, b); // D0 = a | b
- const int16x8_t D1 = vcombine_s16(d, c); // D1 = d | c
- const int16x8_t E0 = vqaddq_s16(D0, D1); // a+d | b+c
- const int16x8_t E_tmp = vqsubq_s16(D0, D1); // a-d | b-c
- const int16x8_t E1 = vcombine_s16(vget_high_s16(E_tmp), vget_low_s16(E_tmp));
- Transpose8x2_NEON(E0, E1, rows);
-}
-
-static void ITransformOne_NEON(const uint8_t* ref,
- const int16_t* in, uint8_t* dst) {
- int16x8x2_t rows;
- INIT_VECTOR2(rows, vld1q_s16(in + 0), vld1q_s16(in + 8));
- TransformPass_NEON(&rows);
- TransformPass_NEON(&rows);
- Add4x4_NEON(rows.val[0], rows.val[1], ref, dst);
-}
-
-#else
-
-static void ITransformOne_NEON(const uint8_t* ref,
- const int16_t* in, uint8_t* dst) {
- const int kBPS = BPS;
- const int16_t kC1C2[] = { kC1, kC2, 0, 0 };
-
- __asm__ volatile (
- "vld1.16 {q1, q2}, [%[in]] \n"
- "vld1.16 {d0}, [%[kC1C2]] \n"
-
- // d2: in[0]
- // d3: in[8]
- // d4: in[4]
- // d5: in[12]
- "vswp d3, d4 \n"
-
- // q8 = {in[4], in[12]} * kC1 * 2 >> 16
- // q9 = {in[4], in[12]} * kC2 >> 16
- "vqdmulh.s16 q8, q2, d0[0] \n"
- "vqdmulh.s16 q9, q2, d0[1] \n"
-
- // d22 = a = in[0] + in[8]
- // d23 = b = in[0] - in[8]
- "vqadd.s16 d22, d2, d3 \n"
- "vqsub.s16 d23, d2, d3 \n"
-
- // q8 = in[4]/[12] * kC1 >> 16
- "vshr.s16 q8, q8, #1 \n"
-
- // Add {in[4], in[12]} back after the multiplication.
- "vqadd.s16 q8, q2, q8 \n"
-
- // d20 = c = in[4]*kC2 - in[12]*kC1
- // d21 = d = in[4]*kC1 + in[12]*kC2
- "vqsub.s16 d20, d18, d17 \n"
- "vqadd.s16 d21, d19, d16 \n"
-
- // d2 = tmp[0] = a + d
- // d3 = tmp[1] = b + c
- // d4 = tmp[2] = b - c
- // d5 = tmp[3] = a - d
- "vqadd.s16 d2, d22, d21 \n"
- "vqadd.s16 d3, d23, d20 \n"
- "vqsub.s16 d4, d23, d20 \n"
- "vqsub.s16 d5, d22, d21 \n"
-
- "vzip.16 q1, q2 \n"
- "vzip.16 q1, q2 \n"
-
- "vswp d3, d4 \n"
-
- // q8 = {tmp[4], tmp[12]} * kC1 * 2 >> 16
- // q9 = {tmp[4], tmp[12]} * kC2 >> 16
- "vqdmulh.s16 q8, q2, d0[0] \n"
- "vqdmulh.s16 q9, q2, d0[1] \n"
-
- // d22 = a = tmp[0] + tmp[8]
- // d23 = b = tmp[0] - tmp[8]
- "vqadd.s16 d22, d2, d3 \n"
- "vqsub.s16 d23, d2, d3 \n"
-
- "vshr.s16 q8, q8, #1 \n"
- "vqadd.s16 q8, q2, q8 \n"
-
- // d20 = c = in[4]*kC2 - in[12]*kC1
- // d21 = d = in[4]*kC1 + in[12]*kC2
- "vqsub.s16 d20, d18, d17 \n"
- "vqadd.s16 d21, d19, d16 \n"
-
- // d2 = tmp[0] = a + d
- // d3 = tmp[1] = b + c
- // d4 = tmp[2] = b - c
- // d5 = tmp[3] = a - d
- "vqadd.s16 d2, d22, d21 \n"
- "vqadd.s16 d3, d23, d20 \n"
- "vqsub.s16 d4, d23, d20 \n"
- "vqsub.s16 d5, d22, d21 \n"
-
- "vld1.32 d6[0], [%[ref]], %[kBPS] \n"
- "vld1.32 d6[1], [%[ref]], %[kBPS] \n"
- "vld1.32 d7[0], [%[ref]], %[kBPS] \n"
- "vld1.32 d7[1], [%[ref]], %[kBPS] \n"
-
- "sub %[ref], %[ref], %[kBPS], lsl #2 \n"
-
- // (val) + 4 >> 3
- "vrshr.s16 d2, d2, #3 \n"
- "vrshr.s16 d3, d3, #3 \n"
- "vrshr.s16 d4, d4, #3 \n"
- "vrshr.s16 d5, d5, #3 \n"
-
- "vzip.16 q1, q2 \n"
- "vzip.16 q1, q2 \n"
-
- // Must accumulate before saturating
- "vmovl.u8 q8, d6 \n"
- "vmovl.u8 q9, d7 \n"
-
- "vqadd.s16 q1, q1, q8 \n"
- "vqadd.s16 q2, q2, q9 \n"
-
- "vqmovun.s16 d0, q1 \n"
- "vqmovun.s16 d1, q2 \n"
-
- "vst1.32 d0[0], [%[dst]], %[kBPS] \n"
- "vst1.32 d0[1], [%[dst]], %[kBPS] \n"
- "vst1.32 d1[0], [%[dst]], %[kBPS] \n"
- "vst1.32 d1[1], [%[dst]] \n"
-
- : [in] "+r"(in), [dst] "+r"(dst) // modified registers
- : [kBPS] "r"(kBPS), [kC1C2] "r"(kC1C2), [ref] "r"(ref) // constants
- : "memory", "q0", "q1", "q2", "q8", "q9", "q10", "q11" // clobbered
- );
-}
-
-#endif // WEBP_USE_INTRINSICS
-
-static void ITransform_NEON(const uint8_t* ref,
- const int16_t* in, uint8_t* dst, int do_two) {
- ITransformOne_NEON(ref, in, dst);
- if (do_two) {
- ITransformOne_NEON(ref + 4, in + 16, dst + 4);
- }
-}
-
-// Load all 4x4 pixels into a single uint8x16_t variable.
-static uint8x16_t Load4x4_NEON(const uint8_t* src) {
- uint32x4_t out = vdupq_n_u32(0);
- out = vld1q_lane_u32((const uint32_t*)(src + 0 * BPS), out, 0);
- out = vld1q_lane_u32((const uint32_t*)(src + 1 * BPS), out, 1);
- out = vld1q_lane_u32((const uint32_t*)(src + 2 * BPS), out, 2);
- out = vld1q_lane_u32((const uint32_t*)(src + 3 * BPS), out, 3);
- return vreinterpretq_u8_u32(out);
-}
-
-// Forward transform.
-
-#if defined(WEBP_USE_INTRINSICS)
-
-static WEBP_INLINE void Transpose4x4_S16_NEON(const int16x4_t A,
- const int16x4_t B,
- const int16x4_t C,
- const int16x4_t D,
- int16x8_t* const out01,
- int16x8_t* const out32) {
- const int16x4x2_t AB = vtrn_s16(A, B);
- const int16x4x2_t CD = vtrn_s16(C, D);
- const int32x2x2_t tmp02 = vtrn_s32(vreinterpret_s32_s16(AB.val[0]),
- vreinterpret_s32_s16(CD.val[0]));
- const int32x2x2_t tmp13 = vtrn_s32(vreinterpret_s32_s16(AB.val[1]),
- vreinterpret_s32_s16(CD.val[1]));
- *out01 = vreinterpretq_s16_s64(
- vcombine_s64(vreinterpret_s64_s32(tmp02.val[0]),
- vreinterpret_s64_s32(tmp13.val[0])));
- *out32 = vreinterpretq_s16_s64(
- vcombine_s64(vreinterpret_s64_s32(tmp13.val[1]),
- vreinterpret_s64_s32(tmp02.val[1])));
-}
-
-static WEBP_INLINE int16x8_t DiffU8ToS16_NEON(const uint8x8_t a,
- const uint8x8_t b) {
- return vreinterpretq_s16_u16(vsubl_u8(a, b));
-}
-
-static void FTransform_NEON(const uint8_t* src, const uint8_t* ref,
- int16_t* out) {
- int16x8_t d0d1, d3d2; // working 4x4 int16 variables
- {
- const uint8x16_t S0 = Load4x4_NEON(src);
- const uint8x16_t R0 = Load4x4_NEON(ref);
- const int16x8_t D0D1 = DiffU8ToS16_NEON(vget_low_u8(S0), vget_low_u8(R0));
- const int16x8_t D2D3 = DiffU8ToS16_NEON(vget_high_u8(S0), vget_high_u8(R0));
- const int16x4_t D0 = vget_low_s16(D0D1);
- const int16x4_t D1 = vget_high_s16(D0D1);
- const int16x4_t D2 = vget_low_s16(D2D3);
- const int16x4_t D3 = vget_high_s16(D2D3);
- Transpose4x4_S16_NEON(D0, D1, D2, D3, &d0d1, &d3d2);
- }
- { // 1rst pass
- const int32x4_t kCst937 = vdupq_n_s32(937);
- const int32x4_t kCst1812 = vdupq_n_s32(1812);
- const int16x8_t a0a1 = vaddq_s16(d0d1, d3d2); // d0+d3 | d1+d2 (=a0|a1)
- const int16x8_t a3a2 = vsubq_s16(d0d1, d3d2); // d0-d3 | d1-d2 (=a3|a2)
- const int16x8_t a0a1_2 = vshlq_n_s16(a0a1, 3);
- const int16x4_t tmp0 = vadd_s16(vget_low_s16(a0a1_2),
- vget_high_s16(a0a1_2));
- const int16x4_t tmp2 = vsub_s16(vget_low_s16(a0a1_2),
- vget_high_s16(a0a1_2));
- const int32x4_t a3_2217 = vmull_n_s16(vget_low_s16(a3a2), 2217);
- const int32x4_t a2_2217 = vmull_n_s16(vget_high_s16(a3a2), 2217);
- const int32x4_t a2_p_a3 = vmlal_n_s16(a2_2217, vget_low_s16(a3a2), 5352);
- const int32x4_t a3_m_a2 = vmlsl_n_s16(a3_2217, vget_high_s16(a3a2), 5352);
- const int16x4_t tmp1 = vshrn_n_s32(vaddq_s32(a2_p_a3, kCst1812), 9);
- const int16x4_t tmp3 = vshrn_n_s32(vaddq_s32(a3_m_a2, kCst937), 9);
- Transpose4x4_S16_NEON(tmp0, tmp1, tmp2, tmp3, &d0d1, &d3d2);
- }
- { // 2nd pass
- // the (1<<16) addition is for the replacement: a3!=0 <-> 1-(a3==0)
- const int32x4_t kCst12000 = vdupq_n_s32(12000 + (1 << 16));
- const int32x4_t kCst51000 = vdupq_n_s32(51000);
- const int16x8_t a0a1 = vaddq_s16(d0d1, d3d2); // d0+d3 | d1+d2 (=a0|a1)
- const int16x8_t a3a2 = vsubq_s16(d0d1, d3d2); // d0-d3 | d1-d2 (=a3|a2)
- const int16x4_t a0_k7 = vadd_s16(vget_low_s16(a0a1), vdup_n_s16(7));
- const int16x4_t out0 = vshr_n_s16(vadd_s16(a0_k7, vget_high_s16(a0a1)), 4);
- const int16x4_t out2 = vshr_n_s16(vsub_s16(a0_k7, vget_high_s16(a0a1)), 4);
- const int32x4_t a3_2217 = vmull_n_s16(vget_low_s16(a3a2), 2217);
- const int32x4_t a2_2217 = vmull_n_s16(vget_high_s16(a3a2), 2217);
- const int32x4_t a2_p_a3 = vmlal_n_s16(a2_2217, vget_low_s16(a3a2), 5352);
- const int32x4_t a3_m_a2 = vmlsl_n_s16(a3_2217, vget_high_s16(a3a2), 5352);
- const int16x4_t tmp1 = vaddhn_s32(a2_p_a3, kCst12000);
- const int16x4_t out3 = vaddhn_s32(a3_m_a2, kCst51000);
- const int16x4_t a3_eq_0 =
- vreinterpret_s16_u16(vceq_s16(vget_low_s16(a3a2), vdup_n_s16(0)));
- const int16x4_t out1 = vadd_s16(tmp1, a3_eq_0);
- vst1_s16(out + 0, out0);
- vst1_s16(out + 4, out1);
- vst1_s16(out + 8, out2);
- vst1_s16(out + 12, out3);
- }
-}
-
-#else
-
-// adapted from vp8/encoder/arm/neon/shortfdct_neon.asm
-static const int16_t kCoeff16[] = {
- 5352, 5352, 5352, 5352, 2217, 2217, 2217, 2217
-};
-static const int32_t kCoeff32[] = {
- 1812, 1812, 1812, 1812,
- 937, 937, 937, 937,
- 12000, 12000, 12000, 12000,
- 51000, 51000, 51000, 51000
-};
-
-static void FTransform_NEON(const uint8_t* src, const uint8_t* ref,
- int16_t* out) {
- const int kBPS = BPS;
- const uint8_t* src_ptr = src;
- const uint8_t* ref_ptr = ref;
- const int16_t* coeff16 = kCoeff16;
- const int32_t* coeff32 = kCoeff32;
-
- __asm__ volatile (
- // load src into q4, q5 in high half
- "vld1.8 {d8}, [%[src_ptr]], %[kBPS] \n"
- "vld1.8 {d10}, [%[src_ptr]], %[kBPS] \n"
- "vld1.8 {d9}, [%[src_ptr]], %[kBPS] \n"
- "vld1.8 {d11}, [%[src_ptr]] \n"
-
- // load ref into q6, q7 in high half
- "vld1.8 {d12}, [%[ref_ptr]], %[kBPS] \n"
- "vld1.8 {d14}, [%[ref_ptr]], %[kBPS] \n"
- "vld1.8 {d13}, [%[ref_ptr]], %[kBPS] \n"
- "vld1.8 {d15}, [%[ref_ptr]] \n"
-
- // Pack the high values in to q4 and q6
- "vtrn.32 q4, q5 \n"
- "vtrn.32 q6, q7 \n"
-
- // d[0-3] = src - ref
- "vsubl.u8 q0, d8, d12 \n"
- "vsubl.u8 q1, d9, d13 \n"
-
- // load coeff16 into q8(d16=5352, d17=2217)
- "vld1.16 {q8}, [%[coeff16]] \n"
-
- // load coeff32 high half into q9 = 1812, q10 = 937
- "vld1.32 {q9, q10}, [%[coeff32]]! \n"
-
- // load coeff32 low half into q11=12000, q12=51000
- "vld1.32 {q11,q12}, [%[coeff32]] \n"
-
- // part 1
- // Transpose. Register dN is the same as dN in C
- "vtrn.32 d0, d2 \n"
- "vtrn.32 d1, d3 \n"
- "vtrn.16 d0, d1 \n"
- "vtrn.16 d2, d3 \n"
-
- "vadd.s16 d4, d0, d3 \n" // a0 = d0 + d3
- "vadd.s16 d5, d1, d2 \n" // a1 = d1 + d2
- "vsub.s16 d6, d1, d2 \n" // a2 = d1 - d2
- "vsub.s16 d7, d0, d3 \n" // a3 = d0 - d3
-
- "vadd.s16 d0, d4, d5 \n" // a0 + a1
- "vshl.s16 d0, d0, #3 \n" // temp[0+i*4] = (a0+a1) << 3
- "vsub.s16 d2, d4, d5 \n" // a0 - a1
- "vshl.s16 d2, d2, #3 \n" // (temp[2+i*4] = (a0-a1) << 3
-
- "vmlal.s16 q9, d7, d16 \n" // a3*5352 + 1812
- "vmlal.s16 q10, d7, d17 \n" // a3*2217 + 937
- "vmlal.s16 q9, d6, d17 \n" // a2*2217 + a3*5352 + 1812
- "vmlsl.s16 q10, d6, d16 \n" // a3*2217 + 937 - a2*5352
-
- // temp[1+i*4] = (d2*2217 + d3*5352 + 1812) >> 9
- // temp[3+i*4] = (d3*2217 + 937 - d2*5352) >> 9
- "vshrn.s32 d1, q9, #9 \n"
- "vshrn.s32 d3, q10, #9 \n"
-
- // part 2
- // transpose d0=ip[0], d1=ip[4], d2=ip[8], d3=ip[12]
- "vtrn.32 d0, d2 \n"
- "vtrn.32 d1, d3 \n"
- "vtrn.16 d0, d1 \n"
- "vtrn.16 d2, d3 \n"
-
- "vmov.s16 d26, #7 \n"
-
- "vadd.s16 d4, d0, d3 \n" // a1 = ip[0] + ip[12]
- "vadd.s16 d5, d1, d2 \n" // b1 = ip[4] + ip[8]
- "vsub.s16 d6, d1, d2 \n" // c1 = ip[4] - ip[8]
- "vadd.s16 d4, d4, d26 \n" // a1 + 7
- "vsub.s16 d7, d0, d3 \n" // d1 = ip[0] - ip[12]
-
- "vadd.s16 d0, d4, d5 \n" // op[0] = a1 + b1 + 7
- "vsub.s16 d2, d4, d5 \n" // op[8] = a1 - b1 + 7
-
- "vmlal.s16 q11, d7, d16 \n" // d1*5352 + 12000
- "vmlal.s16 q12, d7, d17 \n" // d1*2217 + 51000
-
- "vceq.s16 d4, d7, #0 \n"
-
- "vshr.s16 d0, d0, #4 \n"
- "vshr.s16 d2, d2, #4 \n"
-
- "vmlal.s16 q11, d6, d17 \n" // c1*2217 + d1*5352 + 12000
- "vmlsl.s16 q12, d6, d16 \n" // d1*2217 - c1*5352 + 51000
-
- "vmvn d4, d4 \n" // !(d1 == 0)
- // op[4] = (c1*2217 + d1*5352 + 12000)>>16
- "vshrn.s32 d1, q11, #16 \n"
- // op[4] += (d1!=0)
- "vsub.s16 d1, d1, d4 \n"
- // op[12]= (d1*2217 - c1*5352 + 51000)>>16
- "vshrn.s32 d3, q12, #16 \n"
-
- // set result to out array
- "vst1.16 {q0, q1}, [%[out]] \n"
- : [src_ptr] "+r"(src_ptr), [ref_ptr] "+r"(ref_ptr),
- [coeff32] "+r"(coeff32) // modified registers
- : [kBPS] "r"(kBPS), [coeff16] "r"(coeff16),
- [out] "r"(out) // constants
- : "memory", "q0", "q1", "q2", "q3", "q4", "q5", "q6", "q7", "q8", "q9",
- "q10", "q11", "q12", "q13" // clobbered
- );
-}
-
-#endif
-
-#define LOAD_LANE_16b(VALUE, LANE) do { \
- (VALUE) = vld1_lane_s16(src, (VALUE), (LANE)); \
- src += stride; \
-} while (0)
-
-static void FTransformWHT_NEON(const int16_t* src, int16_t* out) {
- const int stride = 16;
- const int16x4_t zero = vdup_n_s16(0);
- int32x4x4_t tmp0;
- int16x4x4_t in;
- INIT_VECTOR4(in, zero, zero, zero, zero);
- LOAD_LANE_16b(in.val[0], 0);
- LOAD_LANE_16b(in.val[1], 0);
- LOAD_LANE_16b(in.val[2], 0);
- LOAD_LANE_16b(in.val[3], 0);
- LOAD_LANE_16b(in.val[0], 1);
- LOAD_LANE_16b(in.val[1], 1);
- LOAD_LANE_16b(in.val[2], 1);
- LOAD_LANE_16b(in.val[3], 1);
- LOAD_LANE_16b(in.val[0], 2);
- LOAD_LANE_16b(in.val[1], 2);
- LOAD_LANE_16b(in.val[2], 2);
- LOAD_LANE_16b(in.val[3], 2);
- LOAD_LANE_16b(in.val[0], 3);
- LOAD_LANE_16b(in.val[1], 3);
- LOAD_LANE_16b(in.val[2], 3);
- LOAD_LANE_16b(in.val[3], 3);
-
- {
- // a0 = in[0 * 16] + in[2 * 16]
- // a1 = in[1 * 16] + in[3 * 16]
- // a2 = in[1 * 16] - in[3 * 16]
- // a3 = in[0 * 16] - in[2 * 16]
- const int32x4_t a0 = vaddl_s16(in.val[0], in.val[2]);
- const int32x4_t a1 = vaddl_s16(in.val[1], in.val[3]);
- const int32x4_t a2 = vsubl_s16(in.val[1], in.val[3]);
- const int32x4_t a3 = vsubl_s16(in.val[0], in.val[2]);
- tmp0.val[0] = vaddq_s32(a0, a1);
- tmp0.val[1] = vaddq_s32(a3, a2);
- tmp0.val[2] = vsubq_s32(a3, a2);
- tmp0.val[3] = vsubq_s32(a0, a1);
- }
- {
- const int32x4x4_t tmp1 = Transpose4x4_NEON(tmp0);
- // a0 = tmp[0 + i] + tmp[ 8 + i]
- // a1 = tmp[4 + i] + tmp[12 + i]
- // a2 = tmp[4 + i] - tmp[12 + i]
- // a3 = tmp[0 + i] - tmp[ 8 + i]
- const int32x4_t a0 = vaddq_s32(tmp1.val[0], tmp1.val[2]);
- const int32x4_t a1 = vaddq_s32(tmp1.val[1], tmp1.val[3]);
- const int32x4_t a2 = vsubq_s32(tmp1.val[1], tmp1.val[3]);
- const int32x4_t a3 = vsubq_s32(tmp1.val[0], tmp1.val[2]);
- const int32x4_t b0 = vhaddq_s32(a0, a1); // (a0 + a1) >> 1
- const int32x4_t b1 = vhaddq_s32(a3, a2); // (a3 + a2) >> 1
- const int32x4_t b2 = vhsubq_s32(a3, a2); // (a3 - a2) >> 1
- const int32x4_t b3 = vhsubq_s32(a0, a1); // (a0 - a1) >> 1
- const int16x4_t out0 = vmovn_s32(b0);
- const int16x4_t out1 = vmovn_s32(b1);
- const int16x4_t out2 = vmovn_s32(b2);
- const int16x4_t out3 = vmovn_s32(b3);
-
- vst1_s16(out + 0, out0);
- vst1_s16(out + 4, out1);
- vst1_s16(out + 8, out2);
- vst1_s16(out + 12, out3);
- }
-}
-#undef LOAD_LANE_16b
-
-//------------------------------------------------------------------------------
-// Texture distortion
-//
-// We try to match the spectral content (weighted) between source and
-// reconstructed samples.
-
-// a 0123, b 0123
-// a 4567, b 4567
-// a 89ab, b 89ab
-// a cdef, b cdef
-//
-// transpose
-//
-// a 048c, b 048c
-// a 159d, b 159d
-// a 26ae, b 26ae
-// a 37bf, b 37bf
-//
-static WEBP_INLINE int16x8x4_t DistoTranspose4x4S16_NEON(int16x8x4_t q4_in) {
- const int16x8x2_t q2_tmp0 = vtrnq_s16(q4_in.val[0], q4_in.val[1]);
- const int16x8x2_t q2_tmp1 = vtrnq_s16(q4_in.val[2], q4_in.val[3]);
- const int32x4x2_t q2_tmp2 = vtrnq_s32(vreinterpretq_s32_s16(q2_tmp0.val[0]),
- vreinterpretq_s32_s16(q2_tmp1.val[0]));
- const int32x4x2_t q2_tmp3 = vtrnq_s32(vreinterpretq_s32_s16(q2_tmp0.val[1]),
- vreinterpretq_s32_s16(q2_tmp1.val[1]));
- q4_in.val[0] = vreinterpretq_s16_s32(q2_tmp2.val[0]);
- q4_in.val[2] = vreinterpretq_s16_s32(q2_tmp2.val[1]);
- q4_in.val[1] = vreinterpretq_s16_s32(q2_tmp3.val[0]);
- q4_in.val[3] = vreinterpretq_s16_s32(q2_tmp3.val[1]);
- return q4_in;
-}
-
-static WEBP_INLINE int16x8x4_t DistoHorizontalPass_NEON(
- const int16x8x4_t q4_in) {
- // {a0, a1} = {in[0] + in[2], in[1] + in[3]}
- // {a3, a2} = {in[0] - in[2], in[1] - in[3]}
- const int16x8_t q_a0 = vaddq_s16(q4_in.val[0], q4_in.val[2]);
- const int16x8_t q_a1 = vaddq_s16(q4_in.val[1], q4_in.val[3]);
- const int16x8_t q_a3 = vsubq_s16(q4_in.val[0], q4_in.val[2]);
- const int16x8_t q_a2 = vsubq_s16(q4_in.val[1], q4_in.val[3]);
- int16x8x4_t q4_out;
- // tmp[0] = a0 + a1
- // tmp[1] = a3 + a2
- // tmp[2] = a3 - a2
- // tmp[3] = a0 - a1
- INIT_VECTOR4(q4_out,
- vabsq_s16(vaddq_s16(q_a0, q_a1)),
- vabsq_s16(vaddq_s16(q_a3, q_a2)),
- vabdq_s16(q_a3, q_a2), vabdq_s16(q_a0, q_a1));
- return q4_out;
-}
-
-static WEBP_INLINE int16x8x4_t DistoVerticalPass_NEON(const uint8x8x4_t q4_in) {
- const int16x8_t q_a0 = vreinterpretq_s16_u16(vaddl_u8(q4_in.val[0],
- q4_in.val[2]));
- const int16x8_t q_a1 = vreinterpretq_s16_u16(vaddl_u8(q4_in.val[1],
- q4_in.val[3]));
- const int16x8_t q_a2 = vreinterpretq_s16_u16(vsubl_u8(q4_in.val[1],
- q4_in.val[3]));
- const int16x8_t q_a3 = vreinterpretq_s16_u16(vsubl_u8(q4_in.val[0],
- q4_in.val[2]));
- int16x8x4_t q4_out;
-
- INIT_VECTOR4(q4_out,
- vaddq_s16(q_a0, q_a1), vaddq_s16(q_a3, q_a2),
- vsubq_s16(q_a3, q_a2), vsubq_s16(q_a0, q_a1));
- return q4_out;
-}
-
-static WEBP_INLINE int16x4x4_t DistoLoadW_NEON(const uint16_t* w) {
- const uint16x8_t q_w07 = vld1q_u16(&w[0]);
- const uint16x8_t q_w8f = vld1q_u16(&w[8]);
- int16x4x4_t d4_w;
- INIT_VECTOR4(d4_w,
- vget_low_s16(vreinterpretq_s16_u16(q_w07)),
- vget_high_s16(vreinterpretq_s16_u16(q_w07)),
- vget_low_s16(vreinterpretq_s16_u16(q_w8f)),
- vget_high_s16(vreinterpretq_s16_u16(q_w8f)));
- return d4_w;
-}
-
-static WEBP_INLINE int32x2_t DistoSum_NEON(const int16x8x4_t q4_in,
- const int16x4x4_t d4_w) {
- int32x2_t d_sum;
- // sum += w[ 0] * abs(b0);
- // sum += w[ 4] * abs(b1);
- // sum += w[ 8] * abs(b2);
- // sum += w[12] * abs(b3);
- int32x4_t q_sum0 = vmull_s16(d4_w.val[0], vget_low_s16(q4_in.val[0]));
- int32x4_t q_sum1 = vmull_s16(d4_w.val[1], vget_low_s16(q4_in.val[1]));
- int32x4_t q_sum2 = vmull_s16(d4_w.val[2], vget_low_s16(q4_in.val[2]));
- int32x4_t q_sum3 = vmull_s16(d4_w.val[3], vget_low_s16(q4_in.val[3]));
- q_sum0 = vmlsl_s16(q_sum0, d4_w.val[0], vget_high_s16(q4_in.val[0]));
- q_sum1 = vmlsl_s16(q_sum1, d4_w.val[1], vget_high_s16(q4_in.val[1]));
- q_sum2 = vmlsl_s16(q_sum2, d4_w.val[2], vget_high_s16(q4_in.val[2]));
- q_sum3 = vmlsl_s16(q_sum3, d4_w.val[3], vget_high_s16(q4_in.val[3]));
-
- q_sum0 = vaddq_s32(q_sum0, q_sum1);
- q_sum2 = vaddq_s32(q_sum2, q_sum3);
- q_sum2 = vaddq_s32(q_sum0, q_sum2);
- d_sum = vpadd_s32(vget_low_s32(q_sum2), vget_high_s32(q_sum2));
- d_sum = vpadd_s32(d_sum, d_sum);
- return d_sum;
-}
-
-#define LOAD_LANE_32b(src, VALUE, LANE) \
- (VALUE) = vld1_lane_u32((const uint32_t*)(src), (VALUE), (LANE))
-
-// Hadamard transform
-// Returns the weighted sum of the absolute value of transformed coefficients.
-// w[] contains a row-major 4 by 4 symmetric matrix.
-static int Disto4x4_NEON(const uint8_t* const a, const uint8_t* const b,
- const uint16_t* const w) {
- uint32x2_t d_in_ab_0123 = vdup_n_u32(0);
- uint32x2_t d_in_ab_4567 = vdup_n_u32(0);
- uint32x2_t d_in_ab_89ab = vdup_n_u32(0);
- uint32x2_t d_in_ab_cdef = vdup_n_u32(0);
- uint8x8x4_t d4_in;
-
- // load data a, b
- LOAD_LANE_32b(a + 0 * BPS, d_in_ab_0123, 0);
- LOAD_LANE_32b(a + 1 * BPS, d_in_ab_4567, 0);
- LOAD_LANE_32b(a + 2 * BPS, d_in_ab_89ab, 0);
- LOAD_LANE_32b(a + 3 * BPS, d_in_ab_cdef, 0);
- LOAD_LANE_32b(b + 0 * BPS, d_in_ab_0123, 1);
- LOAD_LANE_32b(b + 1 * BPS, d_in_ab_4567, 1);
- LOAD_LANE_32b(b + 2 * BPS, d_in_ab_89ab, 1);
- LOAD_LANE_32b(b + 3 * BPS, d_in_ab_cdef, 1);
- INIT_VECTOR4(d4_in,
- vreinterpret_u8_u32(d_in_ab_0123),
- vreinterpret_u8_u32(d_in_ab_4567),
- vreinterpret_u8_u32(d_in_ab_89ab),
- vreinterpret_u8_u32(d_in_ab_cdef));
-
- {
- // Vertical pass first to avoid a transpose (vertical and horizontal passes
- // are commutative because w/kWeightY is symmetric) and subsequent
- // transpose.
- const int16x8x4_t q4_v = DistoVerticalPass_NEON(d4_in);
- const int16x4x4_t d4_w = DistoLoadW_NEON(w);
- // horizontal pass
- const int16x8x4_t q4_t = DistoTranspose4x4S16_NEON(q4_v);
- const int16x8x4_t q4_h = DistoHorizontalPass_NEON(q4_t);
- int32x2_t d_sum = DistoSum_NEON(q4_h, d4_w);
-
- // abs(sum2 - sum1) >> 5
- d_sum = vabs_s32(d_sum);
- d_sum = vshr_n_s32(d_sum, 5);
- return vget_lane_s32(d_sum, 0);
- }
-}
-#undef LOAD_LANE_32b
-
-static int Disto16x16_NEON(const uint8_t* const a, const uint8_t* const b,
- const uint16_t* const w) {
- int D = 0;
- int x, y;
- for (y = 0; y < 16 * BPS; y += 4 * BPS) {
- for (x = 0; x < 16; x += 4) {
- D += Disto4x4_NEON(a + x + y, b + x + y, w);
- }
- }
- return D;
-}
-
-//------------------------------------------------------------------------------
-
-static void CollectHistogram_NEON(const uint8_t* ref, const uint8_t* pred,
- int start_block, int end_block,
- VP8Histogram* const histo) {
- const uint16x8_t max_coeff_thresh = vdupq_n_u16(MAX_COEFF_THRESH);
- int j;
- int distribution[MAX_COEFF_THRESH + 1] = { 0 };
- for (j = start_block; j < end_block; ++j) {
- int16_t out[16];
- FTransform_NEON(ref + VP8DspScan[j], pred + VP8DspScan[j], out);
- {
- int k;
- const int16x8_t a0 = vld1q_s16(out + 0);
- const int16x8_t b0 = vld1q_s16(out + 8);
- const uint16x8_t a1 = vreinterpretq_u16_s16(vabsq_s16(a0));
- const uint16x8_t b1 = vreinterpretq_u16_s16(vabsq_s16(b0));
- const uint16x8_t a2 = vshrq_n_u16(a1, 3);
- const uint16x8_t b2 = vshrq_n_u16(b1, 3);
- const uint16x8_t a3 = vminq_u16(a2, max_coeff_thresh);
- const uint16x8_t b3 = vminq_u16(b2, max_coeff_thresh);
- vst1q_s16(out + 0, vreinterpretq_s16_u16(a3));
- vst1q_s16(out + 8, vreinterpretq_s16_u16(b3));
- // Convert coefficients to bin.
- for (k = 0; k < 16; ++k) {
- ++distribution[out[k]];
- }
- }
- }
- VP8SetHistogramData(distribution, histo);
-}
-
-//------------------------------------------------------------------------------
-
-static WEBP_INLINE void AccumulateSSE16_NEON(const uint8_t* const a,
- const uint8_t* const b,
- uint32x4_t* const sum) {
- const uint8x16_t a0 = vld1q_u8(a);
- const uint8x16_t b0 = vld1q_u8(b);
- const uint8x16_t abs_diff = vabdq_u8(a0, b0);
- const uint16x8_t prod1 = vmull_u8(vget_low_u8(abs_diff),
- vget_low_u8(abs_diff));
- const uint16x8_t prod2 = vmull_u8(vget_high_u8(abs_diff),
- vget_high_u8(abs_diff));
- /* pair-wise adds and widen */
- const uint32x4_t sum1 = vpaddlq_u16(prod1);
- const uint32x4_t sum2 = vpaddlq_u16(prod2);
- *sum = vaddq_u32(*sum, vaddq_u32(sum1, sum2));
-}
-
-// Horizontal sum of all four uint32_t values in 'sum'.
-static int SumToInt_NEON(uint32x4_t sum) {
- const uint64x2_t sum2 = vpaddlq_u32(sum);
- const uint64_t sum3 = vgetq_lane_u64(sum2, 0) + vgetq_lane_u64(sum2, 1);
- return (int)sum3;
-}
-
-static int SSE16x16_NEON(const uint8_t* a, const uint8_t* b) {
- uint32x4_t sum = vdupq_n_u32(0);
- int y;
- for (y = 0; y < 16; ++y) {
- AccumulateSSE16_NEON(a + y * BPS, b + y * BPS, &sum);
- }
- return SumToInt_NEON(sum);
-}
-
-static int SSE16x8_NEON(const uint8_t* a, const uint8_t* b) {
- uint32x4_t sum = vdupq_n_u32(0);
- int y;
- for (y = 0; y < 8; ++y) {
- AccumulateSSE16_NEON(a + y * BPS, b + y * BPS, &sum);
- }
- return SumToInt_NEON(sum);
-}
-
-static int SSE8x8_NEON(const uint8_t* a, const uint8_t* b) {
- uint32x4_t sum = vdupq_n_u32(0);
- int y;
- for (y = 0; y < 8; ++y) {
- const uint8x8_t a0 = vld1_u8(a + y * BPS);
- const uint8x8_t b0 = vld1_u8(b + y * BPS);
- const uint8x8_t abs_diff = vabd_u8(a0, b0);
- const uint16x8_t prod = vmull_u8(abs_diff, abs_diff);
- sum = vpadalq_u16(sum, prod);
- }
- return SumToInt_NEON(sum);
-}
-
-static int SSE4x4_NEON(const uint8_t* a, const uint8_t* b) {
- const uint8x16_t a0 = Load4x4_NEON(a);
- const uint8x16_t b0 = Load4x4_NEON(b);
- const uint8x16_t abs_diff = vabdq_u8(a0, b0);
- const uint16x8_t prod1 = vmull_u8(vget_low_u8(abs_diff),
- vget_low_u8(abs_diff));
- const uint16x8_t prod2 = vmull_u8(vget_high_u8(abs_diff),
- vget_high_u8(abs_diff));
- /* pair-wise adds and widen */
- const uint32x4_t sum1 = vpaddlq_u16(prod1);
- const uint32x4_t sum2 = vpaddlq_u16(prod2);
- return SumToInt_NEON(vaddq_u32(sum1, sum2));
-}
-
-//------------------------------------------------------------------------------
-
-// Compilation with gcc-4.6.x is problematic for now.
-#if !defined(WORK_AROUND_GCC)
-
-static int16x8_t Quantize_NEON(int16_t* const in,
- const VP8Matrix* const mtx, int offset) {
- const uint16x8_t sharp = vld1q_u16(&mtx->sharpen_[offset]);
- const uint16x8_t q = vld1q_u16(&mtx->q_[offset]);
- const uint16x8_t iq = vld1q_u16(&mtx->iq_[offset]);
- const uint32x4_t bias0 = vld1q_u32(&mtx->bias_[offset + 0]);
- const uint32x4_t bias1 = vld1q_u32(&mtx->bias_[offset + 4]);
-
- const int16x8_t a = vld1q_s16(in + offset); // in
- const uint16x8_t b = vreinterpretq_u16_s16(vabsq_s16(a)); // coeff = abs(in)
- const int16x8_t sign = vshrq_n_s16(a, 15); // sign
- const uint16x8_t c = vaddq_u16(b, sharp); // + sharpen
- const uint32x4_t m0 = vmull_u16(vget_low_u16(c), vget_low_u16(iq));
- const uint32x4_t m1 = vmull_u16(vget_high_u16(c), vget_high_u16(iq));
- const uint32x4_t m2 = vhaddq_u32(m0, bias0);
- const uint32x4_t m3 = vhaddq_u32(m1, bias1); // (coeff * iQ + bias) >> 1
- const uint16x8_t c0 = vcombine_u16(vshrn_n_u32(m2, 16),
- vshrn_n_u32(m3, 16)); // QFIX=17 = 16+1
- const uint16x8_t c1 = vminq_u16(c0, vdupq_n_u16(MAX_LEVEL));
- const int16x8_t c2 = veorq_s16(vreinterpretq_s16_u16(c1), sign);
- const int16x8_t c3 = vsubq_s16(c2, sign); // restore sign
- const int16x8_t c4 = vmulq_s16(c3, vreinterpretq_s16_u16(q));
- vst1q_s16(in + offset, c4);
- assert(QFIX == 17); // this function can't work as is if QFIX != 16+1
- return c3;
-}
-
-static const uint8_t kShuffles[4][8] = {
- { 0, 1, 2, 3, 8, 9, 16, 17 },
- { 10, 11, 4, 5, 6, 7, 12, 13 },
- { 18, 19, 24, 25, 26, 27, 20, 21 },
- { 14, 15, 22, 23, 28, 29, 30, 31 }
-};
-
-static int QuantizeBlock_NEON(int16_t in[16], int16_t out[16],
- const VP8Matrix* const mtx) {
- const int16x8_t out0 = Quantize_NEON(in, mtx, 0);
- const int16x8_t out1 = Quantize_NEON(in, mtx, 8);
- uint8x8x4_t shuffles;
- // vtbl?_u8 are marked unavailable for iOS arm64 with Xcode < 6.3, use
- // non-standard versions there.
-#if defined(__APPLE__) && defined(__aarch64__) && \
- defined(__apple_build_version__) && (__apple_build_version__< 6020037)
- uint8x16x2_t all_out;
- INIT_VECTOR2(all_out, vreinterpretq_u8_s16(out0), vreinterpretq_u8_s16(out1));
- INIT_VECTOR4(shuffles,
- vtbl2q_u8(all_out, vld1_u8(kShuffles[0])),
- vtbl2q_u8(all_out, vld1_u8(kShuffles[1])),
- vtbl2q_u8(all_out, vld1_u8(kShuffles[2])),
- vtbl2q_u8(all_out, vld1_u8(kShuffles[3])));
-#else
- uint8x8x4_t all_out;
- INIT_VECTOR4(all_out,
- vreinterpret_u8_s16(vget_low_s16(out0)),
- vreinterpret_u8_s16(vget_high_s16(out0)),
- vreinterpret_u8_s16(vget_low_s16(out1)),
- vreinterpret_u8_s16(vget_high_s16(out1)));
- INIT_VECTOR4(shuffles,
- vtbl4_u8(all_out, vld1_u8(kShuffles[0])),
- vtbl4_u8(all_out, vld1_u8(kShuffles[1])),
- vtbl4_u8(all_out, vld1_u8(kShuffles[2])),
- vtbl4_u8(all_out, vld1_u8(kShuffles[3])));
-#endif
- // Zigzag reordering
- vst1_u8((uint8_t*)(out + 0), shuffles.val[0]);
- vst1_u8((uint8_t*)(out + 4), shuffles.val[1]);
- vst1_u8((uint8_t*)(out + 8), shuffles.val[2]);
- vst1_u8((uint8_t*)(out + 12), shuffles.val[3]);
- // test zeros
- if (*(uint64_t*)(out + 0) != 0) return 1;
- if (*(uint64_t*)(out + 4) != 0) return 1;
- if (*(uint64_t*)(out + 8) != 0) return 1;
- if (*(uint64_t*)(out + 12) != 0) return 1;
- return 0;
-}
-
-static int Quantize2Blocks_NEON(int16_t in[32], int16_t out[32],
- const VP8Matrix* const mtx) {
- int nz;
- nz = QuantizeBlock_NEON(in + 0 * 16, out + 0 * 16, mtx) << 0;
- nz |= QuantizeBlock_NEON(in + 1 * 16, out + 1 * 16, mtx) << 1;
- return nz;
-}
-
-#endif // !WORK_AROUND_GCC
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void VP8EncDspInitNEON(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void VP8EncDspInitNEON(void) {
- VP8ITransform = ITransform_NEON;
- VP8FTransform = FTransform_NEON;
-
- VP8FTransformWHT = FTransformWHT_NEON;
-
- VP8TDisto4x4 = Disto4x4_NEON;
- VP8TDisto16x16 = Disto16x16_NEON;
- VP8CollectHistogram = CollectHistogram_NEON;
-
- VP8SSE16x16 = SSE16x16_NEON;
- VP8SSE16x8 = SSE16x8_NEON;
- VP8SSE8x8 = SSE8x8_NEON;
- VP8SSE4x4 = SSE4x4_NEON;
-
-#if !defined(WORK_AROUND_GCC)
- VP8EncQuantizeBlock = QuantizeBlock_NEON;
- VP8EncQuantize2Blocks = Quantize2Blocks_NEON;
-#endif
-}
-
-#else // !WEBP_USE_NEON
-
-WEBP_DSP_INIT_STUB(VP8EncDspInitNEON)
-
-#endif // WEBP_USE_NEON
diff --git a/contrib/libs/libwebp/dsp/enc_sse2.c b/contrib/libs/libwebp/dsp/enc_sse2.c
deleted file mode 100644
index 9d9af8b187..0000000000
--- a/contrib/libs/libwebp/dsp/enc_sse2.c
+++ /dev/null
@@ -1,1381 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// SSE2 version of speed-critical encoding functions.
-//
-// Author: Christian Duvivier (cduvivier@google.com)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_SSE2)
-#include <assert.h>
-#include <stdlib.h> // for abs()
-#include <emmintrin.h>
-
-#include "./common_sse2.h"
-#include "../enc/cost_enc.h"
-#include "../enc/vp8i_enc.h"
-
-//------------------------------------------------------------------------------
-// Transforms (Paragraph 14.4)
-
-// Does one or two inverse transforms.
-static void ITransform_SSE2(const uint8_t* ref, const int16_t* in, uint8_t* dst,
- int do_two) {
- // This implementation makes use of 16-bit fixed point versions of two
- // multiply constants:
- // K1 = sqrt(2) * cos (pi/8) ~= 85627 / 2^16
- // K2 = sqrt(2) * sin (pi/8) ~= 35468 / 2^16
- //
- // To be able to use signed 16-bit integers, we use the following trick to
- // have constants within range:
- // - Associated constants are obtained by subtracting the 16-bit fixed point
- // version of one:
- // k = K - (1 << 16) => K = k + (1 << 16)
- // K1 = 85267 => k1 = 20091
- // K2 = 35468 => k2 = -30068
- // - The multiplication of a variable by a constant become the sum of the
- // variable and the multiplication of that variable by the associated
- // constant:
- // (x * K) >> 16 = (x * (k + (1 << 16))) >> 16 = ((x * k ) >> 16) + x
- const __m128i k1 = _mm_set1_epi16(20091);
- const __m128i k2 = _mm_set1_epi16(-30068);
- __m128i T0, T1, T2, T3;
-
- // Load and concatenate the transform coefficients (we'll do two inverse
- // transforms in parallel). In the case of only one inverse transform, the
- // second half of the vectors will just contain random value we'll never
- // use nor store.
- __m128i in0, in1, in2, in3;
- {
- in0 = _mm_loadl_epi64((const __m128i*)&in[0]);
- in1 = _mm_loadl_epi64((const __m128i*)&in[4]);
- in2 = _mm_loadl_epi64((const __m128i*)&in[8]);
- in3 = _mm_loadl_epi64((const __m128i*)&in[12]);
- // a00 a10 a20 a30 x x x x
- // a01 a11 a21 a31 x x x x
- // a02 a12 a22 a32 x x x x
- // a03 a13 a23 a33 x x x x
- if (do_two) {
- const __m128i inB0 = _mm_loadl_epi64((const __m128i*)&in[16]);
- const __m128i inB1 = _mm_loadl_epi64((const __m128i*)&in[20]);
- const __m128i inB2 = _mm_loadl_epi64((const __m128i*)&in[24]);
- const __m128i inB3 = _mm_loadl_epi64((const __m128i*)&in[28]);
- in0 = _mm_unpacklo_epi64(in0, inB0);
- in1 = _mm_unpacklo_epi64(in1, inB1);
- in2 = _mm_unpacklo_epi64(in2, inB2);
- in3 = _mm_unpacklo_epi64(in3, inB3);
- // a00 a10 a20 a30 b00 b10 b20 b30
- // a01 a11 a21 a31 b01 b11 b21 b31
- // a02 a12 a22 a32 b02 b12 b22 b32
- // a03 a13 a23 a33 b03 b13 b23 b33
- }
- }
-
- // Vertical pass and subsequent transpose.
- {
- // First pass, c and d calculations are longer because of the "trick"
- // multiplications.
- const __m128i a = _mm_add_epi16(in0, in2);
- const __m128i b = _mm_sub_epi16(in0, in2);
- // c = MUL(in1, K2) - MUL(in3, K1) = MUL(in1, k2) - MUL(in3, k1) + in1 - in3
- const __m128i c1 = _mm_mulhi_epi16(in1, k2);
- const __m128i c2 = _mm_mulhi_epi16(in3, k1);
- const __m128i c3 = _mm_sub_epi16(in1, in3);
- const __m128i c4 = _mm_sub_epi16(c1, c2);
- const __m128i c = _mm_add_epi16(c3, c4);
- // d = MUL(in1, K1) + MUL(in3, K2) = MUL(in1, k1) + MUL(in3, k2) + in1 + in3
- const __m128i d1 = _mm_mulhi_epi16(in1, k1);
- const __m128i d2 = _mm_mulhi_epi16(in3, k2);
- const __m128i d3 = _mm_add_epi16(in1, in3);
- const __m128i d4 = _mm_add_epi16(d1, d2);
- const __m128i d = _mm_add_epi16(d3, d4);
-
- // Second pass.
- const __m128i tmp0 = _mm_add_epi16(a, d);
- const __m128i tmp1 = _mm_add_epi16(b, c);
- const __m128i tmp2 = _mm_sub_epi16(b, c);
- const __m128i tmp3 = _mm_sub_epi16(a, d);
-
- // Transpose the two 4x4.
- VP8Transpose_2_4x4_16b(&tmp0, &tmp1, &tmp2, &tmp3, &T0, &T1, &T2, &T3);
- }
-
- // Horizontal pass and subsequent transpose.
- {
- // First pass, c and d calculations are longer because of the "trick"
- // multiplications.
- const __m128i four = _mm_set1_epi16(4);
- const __m128i dc = _mm_add_epi16(T0, four);
- const __m128i a = _mm_add_epi16(dc, T2);
- const __m128i b = _mm_sub_epi16(dc, T2);
- // c = MUL(T1, K2) - MUL(T3, K1) = MUL(T1, k2) - MUL(T3, k1) + T1 - T3
- const __m128i c1 = _mm_mulhi_epi16(T1, k2);
- const __m128i c2 = _mm_mulhi_epi16(T3, k1);
- const __m128i c3 = _mm_sub_epi16(T1, T3);
- const __m128i c4 = _mm_sub_epi16(c1, c2);
- const __m128i c = _mm_add_epi16(c3, c4);
- // d = MUL(T1, K1) + MUL(T3, K2) = MUL(T1, k1) + MUL(T3, k2) + T1 + T3
- const __m128i d1 = _mm_mulhi_epi16(T1, k1);
- const __m128i d2 = _mm_mulhi_epi16(T3, k2);
- const __m128i d3 = _mm_add_epi16(T1, T3);
- const __m128i d4 = _mm_add_epi16(d1, d2);
- const __m128i d = _mm_add_epi16(d3, d4);
-
- // Second pass.
- const __m128i tmp0 = _mm_add_epi16(a, d);
- const __m128i tmp1 = _mm_add_epi16(b, c);
- const __m128i tmp2 = _mm_sub_epi16(b, c);
- const __m128i tmp3 = _mm_sub_epi16(a, d);
- const __m128i shifted0 = _mm_srai_epi16(tmp0, 3);
- const __m128i shifted1 = _mm_srai_epi16(tmp1, 3);
- const __m128i shifted2 = _mm_srai_epi16(tmp2, 3);
- const __m128i shifted3 = _mm_srai_epi16(tmp3, 3);
-
- // Transpose the two 4x4.
- VP8Transpose_2_4x4_16b(&shifted0, &shifted1, &shifted2, &shifted3, &T0, &T1,
- &T2, &T3);
- }
-
- // Add inverse transform to 'ref' and store.
- {
- const __m128i zero = _mm_setzero_si128();
- // Load the reference(s).
- __m128i ref0, ref1, ref2, ref3;
- if (do_two) {
- // Load eight bytes/pixels per line.
- ref0 = _mm_loadl_epi64((const __m128i*)&ref[0 * BPS]);
- ref1 = _mm_loadl_epi64((const __m128i*)&ref[1 * BPS]);
- ref2 = _mm_loadl_epi64((const __m128i*)&ref[2 * BPS]);
- ref3 = _mm_loadl_epi64((const __m128i*)&ref[3 * BPS]);
- } else {
- // Load four bytes/pixels per line.
- ref0 = _mm_cvtsi32_si128(WebPMemToUint32(&ref[0 * BPS]));
- ref1 = _mm_cvtsi32_si128(WebPMemToUint32(&ref[1 * BPS]));
- ref2 = _mm_cvtsi32_si128(WebPMemToUint32(&ref[2 * BPS]));
- ref3 = _mm_cvtsi32_si128(WebPMemToUint32(&ref[3 * BPS]));
- }
- // Convert to 16b.
- ref0 = _mm_unpacklo_epi8(ref0, zero);
- ref1 = _mm_unpacklo_epi8(ref1, zero);
- ref2 = _mm_unpacklo_epi8(ref2, zero);
- ref3 = _mm_unpacklo_epi8(ref3, zero);
- // Add the inverse transform(s).
- ref0 = _mm_add_epi16(ref0, T0);
- ref1 = _mm_add_epi16(ref1, T1);
- ref2 = _mm_add_epi16(ref2, T2);
- ref3 = _mm_add_epi16(ref3, T3);
- // Unsigned saturate to 8b.
- ref0 = _mm_packus_epi16(ref0, ref0);
- ref1 = _mm_packus_epi16(ref1, ref1);
- ref2 = _mm_packus_epi16(ref2, ref2);
- ref3 = _mm_packus_epi16(ref3, ref3);
- // Store the results.
- if (do_two) {
- // Store eight bytes/pixels per line.
- _mm_storel_epi64((__m128i*)&dst[0 * BPS], ref0);
- _mm_storel_epi64((__m128i*)&dst[1 * BPS], ref1);
- _mm_storel_epi64((__m128i*)&dst[2 * BPS], ref2);
- _mm_storel_epi64((__m128i*)&dst[3 * BPS], ref3);
- } else {
- // Store four bytes/pixels per line.
- WebPUint32ToMem(&dst[0 * BPS], _mm_cvtsi128_si32(ref0));
- WebPUint32ToMem(&dst[1 * BPS], _mm_cvtsi128_si32(ref1));
- WebPUint32ToMem(&dst[2 * BPS], _mm_cvtsi128_si32(ref2));
- WebPUint32ToMem(&dst[3 * BPS], _mm_cvtsi128_si32(ref3));
- }
- }
-}
-
-static void FTransformPass1_SSE2(const __m128i* const in01,
- const __m128i* const in23,
- __m128i* const out01,
- __m128i* const out32) {
- const __m128i k937 = _mm_set1_epi32(937);
- const __m128i k1812 = _mm_set1_epi32(1812);
-
- const __m128i k88p = _mm_set_epi16(8, 8, 8, 8, 8, 8, 8, 8);
- const __m128i k88m = _mm_set_epi16(-8, 8, -8, 8, -8, 8, -8, 8);
- const __m128i k5352_2217p = _mm_set_epi16(2217, 5352, 2217, 5352,
- 2217, 5352, 2217, 5352);
- const __m128i k5352_2217m = _mm_set_epi16(-5352, 2217, -5352, 2217,
- -5352, 2217, -5352, 2217);
-
- // *in01 = 00 01 10 11 02 03 12 13
- // *in23 = 20 21 30 31 22 23 32 33
- const __m128i shuf01_p = _mm_shufflehi_epi16(*in01, _MM_SHUFFLE(2, 3, 0, 1));
- const __m128i shuf23_p = _mm_shufflehi_epi16(*in23, _MM_SHUFFLE(2, 3, 0, 1));
- // 00 01 10 11 03 02 13 12
- // 20 21 30 31 23 22 33 32
- const __m128i s01 = _mm_unpacklo_epi64(shuf01_p, shuf23_p);
- const __m128i s32 = _mm_unpackhi_epi64(shuf01_p, shuf23_p);
- // 00 01 10 11 20 21 30 31
- // 03 02 13 12 23 22 33 32
- const __m128i a01 = _mm_add_epi16(s01, s32);
- const __m128i a32 = _mm_sub_epi16(s01, s32);
- // [d0 + d3 | d1 + d2 | ...] = [a0 a1 | a0' a1' | ... ]
- // [d0 - d3 | d1 - d2 | ...] = [a3 a2 | a3' a2' | ... ]
-
- const __m128i tmp0 = _mm_madd_epi16(a01, k88p); // [ (a0 + a1) << 3, ... ]
- const __m128i tmp2 = _mm_madd_epi16(a01, k88m); // [ (a0 - a1) << 3, ... ]
- const __m128i tmp1_1 = _mm_madd_epi16(a32, k5352_2217p);
- const __m128i tmp3_1 = _mm_madd_epi16(a32, k5352_2217m);
- const __m128i tmp1_2 = _mm_add_epi32(tmp1_1, k1812);
- const __m128i tmp3_2 = _mm_add_epi32(tmp3_1, k937);
- const __m128i tmp1 = _mm_srai_epi32(tmp1_2, 9);
- const __m128i tmp3 = _mm_srai_epi32(tmp3_2, 9);
- const __m128i s03 = _mm_packs_epi32(tmp0, tmp2);
- const __m128i s12 = _mm_packs_epi32(tmp1, tmp3);
- const __m128i s_lo = _mm_unpacklo_epi16(s03, s12); // 0 1 0 1 0 1...
- const __m128i s_hi = _mm_unpackhi_epi16(s03, s12); // 2 3 2 3 2 3
- const __m128i v23 = _mm_unpackhi_epi32(s_lo, s_hi);
- *out01 = _mm_unpacklo_epi32(s_lo, s_hi);
- *out32 = _mm_shuffle_epi32(v23, _MM_SHUFFLE(1, 0, 3, 2)); // 3 2 3 2 3 2..
-}
-
-static void FTransformPass2_SSE2(const __m128i* const v01,
- const __m128i* const v32,
- int16_t* out) {
- const __m128i zero = _mm_setzero_si128();
- const __m128i seven = _mm_set1_epi16(7);
- const __m128i k5352_2217 = _mm_set_epi16(5352, 2217, 5352, 2217,
- 5352, 2217, 5352, 2217);
- const __m128i k2217_5352 = _mm_set_epi16(2217, -5352, 2217, -5352,
- 2217, -5352, 2217, -5352);
- const __m128i k12000_plus_one = _mm_set1_epi32(12000 + (1 << 16));
- const __m128i k51000 = _mm_set1_epi32(51000);
-
- // Same operations are done on the (0,3) and (1,2) pairs.
- // a3 = v0 - v3
- // a2 = v1 - v2
- const __m128i a32 = _mm_sub_epi16(*v01, *v32);
- const __m128i a22 = _mm_unpackhi_epi64(a32, a32);
-
- const __m128i b23 = _mm_unpacklo_epi16(a22, a32);
- const __m128i c1 = _mm_madd_epi16(b23, k5352_2217);
- const __m128i c3 = _mm_madd_epi16(b23, k2217_5352);
- const __m128i d1 = _mm_add_epi32(c1, k12000_plus_one);
- const __m128i d3 = _mm_add_epi32(c3, k51000);
- const __m128i e1 = _mm_srai_epi32(d1, 16);
- const __m128i e3 = _mm_srai_epi32(d3, 16);
- // f1 = ((b3 * 5352 + b2 * 2217 + 12000) >> 16)
- // f3 = ((b3 * 2217 - b2 * 5352 + 51000) >> 16)
- const __m128i f1 = _mm_packs_epi32(e1, e1);
- const __m128i f3 = _mm_packs_epi32(e3, e3);
- // g1 = f1 + (a3 != 0);
- // The compare will return (0xffff, 0) for (==0, !=0). To turn that into the
- // desired (0, 1), we add one earlier through k12000_plus_one.
- // -> g1 = f1 + 1 - (a3 == 0)
- const __m128i g1 = _mm_add_epi16(f1, _mm_cmpeq_epi16(a32, zero));
-
- // a0 = v0 + v3
- // a1 = v1 + v2
- const __m128i a01 = _mm_add_epi16(*v01, *v32);
- const __m128i a01_plus_7 = _mm_add_epi16(a01, seven);
- const __m128i a11 = _mm_unpackhi_epi64(a01, a01);
- const __m128i c0 = _mm_add_epi16(a01_plus_7, a11);
- const __m128i c2 = _mm_sub_epi16(a01_plus_7, a11);
- // d0 = (a0 + a1 + 7) >> 4;
- // d2 = (a0 - a1 + 7) >> 4;
- const __m128i d0 = _mm_srai_epi16(c0, 4);
- const __m128i d2 = _mm_srai_epi16(c2, 4);
-
- const __m128i d0_g1 = _mm_unpacklo_epi64(d0, g1);
- const __m128i d2_f3 = _mm_unpacklo_epi64(d2, f3);
- _mm_storeu_si128((__m128i*)&out[0], d0_g1);
- _mm_storeu_si128((__m128i*)&out[8], d2_f3);
-}
-
-static void FTransform_SSE2(const uint8_t* src, const uint8_t* ref,
- int16_t* out) {
- const __m128i zero = _mm_setzero_si128();
- // Load src.
- const __m128i src0 = _mm_loadl_epi64((const __m128i*)&src[0 * BPS]);
- const __m128i src1 = _mm_loadl_epi64((const __m128i*)&src[1 * BPS]);
- const __m128i src2 = _mm_loadl_epi64((const __m128i*)&src[2 * BPS]);
- const __m128i src3 = _mm_loadl_epi64((const __m128i*)&src[3 * BPS]);
- // 00 01 02 03 *
- // 10 11 12 13 *
- // 20 21 22 23 *
- // 30 31 32 33 *
- // Shuffle.
- const __m128i src_0 = _mm_unpacklo_epi16(src0, src1);
- const __m128i src_1 = _mm_unpacklo_epi16(src2, src3);
- // 00 01 10 11 02 03 12 13 * * ...
- // 20 21 30 31 22 22 32 33 * * ...
-
- // Load ref.
- const __m128i ref0 = _mm_loadl_epi64((const __m128i*)&ref[0 * BPS]);
- const __m128i ref1 = _mm_loadl_epi64((const __m128i*)&ref[1 * BPS]);
- const __m128i ref2 = _mm_loadl_epi64((const __m128i*)&ref[2 * BPS]);
- const __m128i ref3 = _mm_loadl_epi64((const __m128i*)&ref[3 * BPS]);
- const __m128i ref_0 = _mm_unpacklo_epi16(ref0, ref1);
- const __m128i ref_1 = _mm_unpacklo_epi16(ref2, ref3);
-
- // Convert both to 16 bit.
- const __m128i src_0_16b = _mm_unpacklo_epi8(src_0, zero);
- const __m128i src_1_16b = _mm_unpacklo_epi8(src_1, zero);
- const __m128i ref_0_16b = _mm_unpacklo_epi8(ref_0, zero);
- const __m128i ref_1_16b = _mm_unpacklo_epi8(ref_1, zero);
-
- // Compute the difference.
- const __m128i row01 = _mm_sub_epi16(src_0_16b, ref_0_16b);
- const __m128i row23 = _mm_sub_epi16(src_1_16b, ref_1_16b);
- __m128i v01, v32;
-
- // First pass
- FTransformPass1_SSE2(&row01, &row23, &v01, &v32);
-
- // Second pass
- FTransformPass2_SSE2(&v01, &v32, out);
-}
-
-static void FTransform2_SSE2(const uint8_t* src, const uint8_t* ref,
- int16_t* out) {
- const __m128i zero = _mm_setzero_si128();
-
- // Load src and convert to 16b.
- const __m128i src0 = _mm_loadl_epi64((const __m128i*)&src[0 * BPS]);
- const __m128i src1 = _mm_loadl_epi64((const __m128i*)&src[1 * BPS]);
- const __m128i src2 = _mm_loadl_epi64((const __m128i*)&src[2 * BPS]);
- const __m128i src3 = _mm_loadl_epi64((const __m128i*)&src[3 * BPS]);
- const __m128i src_0 = _mm_unpacklo_epi8(src0, zero);
- const __m128i src_1 = _mm_unpacklo_epi8(src1, zero);
- const __m128i src_2 = _mm_unpacklo_epi8(src2, zero);
- const __m128i src_3 = _mm_unpacklo_epi8(src3, zero);
- // Load ref and convert to 16b.
- const __m128i ref0 = _mm_loadl_epi64((const __m128i*)&ref[0 * BPS]);
- const __m128i ref1 = _mm_loadl_epi64((const __m128i*)&ref[1 * BPS]);
- const __m128i ref2 = _mm_loadl_epi64((const __m128i*)&ref[2 * BPS]);
- const __m128i ref3 = _mm_loadl_epi64((const __m128i*)&ref[3 * BPS]);
- const __m128i ref_0 = _mm_unpacklo_epi8(ref0, zero);
- const __m128i ref_1 = _mm_unpacklo_epi8(ref1, zero);
- const __m128i ref_2 = _mm_unpacklo_epi8(ref2, zero);
- const __m128i ref_3 = _mm_unpacklo_epi8(ref3, zero);
- // Compute difference. -> 00 01 02 03 00' 01' 02' 03'
- const __m128i diff0 = _mm_sub_epi16(src_0, ref_0);
- const __m128i diff1 = _mm_sub_epi16(src_1, ref_1);
- const __m128i diff2 = _mm_sub_epi16(src_2, ref_2);
- const __m128i diff3 = _mm_sub_epi16(src_3, ref_3);
-
- // Unpack and shuffle
- // 00 01 02 03 0 0 0 0
- // 10 11 12 13 0 0 0 0
- // 20 21 22 23 0 0 0 0
- // 30 31 32 33 0 0 0 0
- const __m128i shuf01l = _mm_unpacklo_epi32(diff0, diff1);
- const __m128i shuf23l = _mm_unpacklo_epi32(diff2, diff3);
- const __m128i shuf01h = _mm_unpackhi_epi32(diff0, diff1);
- const __m128i shuf23h = _mm_unpackhi_epi32(diff2, diff3);
- __m128i v01l, v32l;
- __m128i v01h, v32h;
-
- // First pass
- FTransformPass1_SSE2(&shuf01l, &shuf23l, &v01l, &v32l);
- FTransformPass1_SSE2(&shuf01h, &shuf23h, &v01h, &v32h);
-
- // Second pass
- FTransformPass2_SSE2(&v01l, &v32l, out + 0);
- FTransformPass2_SSE2(&v01h, &v32h, out + 16);
-}
-
-static void FTransformWHTRow_SSE2(const int16_t* const in, __m128i* const out) {
- const __m128i kMult = _mm_set_epi16(-1, 1, -1, 1, 1, 1, 1, 1);
- const __m128i src0 = _mm_loadl_epi64((__m128i*)&in[0 * 16]);
- const __m128i src1 = _mm_loadl_epi64((__m128i*)&in[1 * 16]);
- const __m128i src2 = _mm_loadl_epi64((__m128i*)&in[2 * 16]);
- const __m128i src3 = _mm_loadl_epi64((__m128i*)&in[3 * 16]);
- const __m128i A01 = _mm_unpacklo_epi16(src0, src1); // A0 A1 | ...
- const __m128i A23 = _mm_unpacklo_epi16(src2, src3); // A2 A3 | ...
- const __m128i B0 = _mm_adds_epi16(A01, A23); // a0 | a1 | ...
- const __m128i B1 = _mm_subs_epi16(A01, A23); // a3 | a2 | ...
- const __m128i C0 = _mm_unpacklo_epi32(B0, B1); // a0 | a1 | a3 | a2 | ...
- const __m128i C1 = _mm_unpacklo_epi32(B1, B0); // a3 | a2 | a0 | a1 | ...
- const __m128i D = _mm_unpacklo_epi64(C0, C1); // a0 a1 a3 a2 a3 a2 a0 a1
- *out = _mm_madd_epi16(D, kMult);
-}
-
-static void FTransformWHT_SSE2(const int16_t* in, int16_t* out) {
- // Input is 12b signed.
- __m128i row0, row1, row2, row3;
- // Rows are 14b signed.
- FTransformWHTRow_SSE2(in + 0 * 64, &row0);
- FTransformWHTRow_SSE2(in + 1 * 64, &row1);
- FTransformWHTRow_SSE2(in + 2 * 64, &row2);
- FTransformWHTRow_SSE2(in + 3 * 64, &row3);
-
- {
- // The a* are 15b signed.
- const __m128i a0 = _mm_add_epi32(row0, row2);
- const __m128i a1 = _mm_add_epi32(row1, row3);
- const __m128i a2 = _mm_sub_epi32(row1, row3);
- const __m128i a3 = _mm_sub_epi32(row0, row2);
- const __m128i a0a3 = _mm_packs_epi32(a0, a3);
- const __m128i a1a2 = _mm_packs_epi32(a1, a2);
-
- // The b* are 16b signed.
- const __m128i b0b1 = _mm_add_epi16(a0a3, a1a2);
- const __m128i b3b2 = _mm_sub_epi16(a0a3, a1a2);
- const __m128i tmp_b2b3 = _mm_unpackhi_epi64(b3b2, b3b2);
- const __m128i b2b3 = _mm_unpacklo_epi64(tmp_b2b3, b3b2);
-
- _mm_storeu_si128((__m128i*)&out[0], _mm_srai_epi16(b0b1, 1));
- _mm_storeu_si128((__m128i*)&out[8], _mm_srai_epi16(b2b3, 1));
- }
-}
-
-//------------------------------------------------------------------------------
-// Compute susceptibility based on DCT-coeff histograms:
-// the higher, the "easier" the macroblock is to compress.
-
-static void CollectHistogram_SSE2(const uint8_t* ref, const uint8_t* pred,
- int start_block, int end_block,
- VP8Histogram* const histo) {
- const __m128i zero = _mm_setzero_si128();
- const __m128i max_coeff_thresh = _mm_set1_epi16(MAX_COEFF_THRESH);
- int j;
- int distribution[MAX_COEFF_THRESH + 1] = { 0 };
- for (j = start_block; j < end_block; ++j) {
- int16_t out[16];
- int k;
-
- FTransform_SSE2(ref + VP8DspScan[j], pred + VP8DspScan[j], out);
-
- // Convert coefficients to bin (within out[]).
- {
- // Load.
- const __m128i out0 = _mm_loadu_si128((__m128i*)&out[0]);
- const __m128i out1 = _mm_loadu_si128((__m128i*)&out[8]);
- const __m128i d0 = _mm_sub_epi16(zero, out0);
- const __m128i d1 = _mm_sub_epi16(zero, out1);
- const __m128i abs0 = _mm_max_epi16(out0, d0); // abs(v), 16b
- const __m128i abs1 = _mm_max_epi16(out1, d1);
- // v = abs(out) >> 3
- const __m128i v0 = _mm_srai_epi16(abs0, 3);
- const __m128i v1 = _mm_srai_epi16(abs1, 3);
- // bin = min(v, MAX_COEFF_THRESH)
- const __m128i bin0 = _mm_min_epi16(v0, max_coeff_thresh);
- const __m128i bin1 = _mm_min_epi16(v1, max_coeff_thresh);
- // Store.
- _mm_storeu_si128((__m128i*)&out[0], bin0);
- _mm_storeu_si128((__m128i*)&out[8], bin1);
- }
-
- // Convert coefficients to bin.
- for (k = 0; k < 16; ++k) {
- ++distribution[out[k]];
- }
- }
- VP8SetHistogramData(distribution, histo);
-}
-
-//------------------------------------------------------------------------------
-// Intra predictions
-
-// helper for chroma-DC predictions
-static WEBP_INLINE void Put8x8uv_SSE2(uint8_t v, uint8_t* dst) {
- int j;
- const __m128i values = _mm_set1_epi8(v);
- for (j = 0; j < 8; ++j) {
- _mm_storel_epi64((__m128i*)(dst + j * BPS), values);
- }
-}
-
-static WEBP_INLINE void Put16_SSE2(uint8_t v, uint8_t* dst) {
- int j;
- const __m128i values = _mm_set1_epi8(v);
- for (j = 0; j < 16; ++j) {
- _mm_store_si128((__m128i*)(dst + j * BPS), values);
- }
-}
-
-static WEBP_INLINE void Fill_SSE2(uint8_t* dst, int value, int size) {
- if (size == 4) {
- int j;
- for (j = 0; j < 4; ++j) {
- memset(dst + j * BPS, value, 4);
- }
- } else if (size == 8) {
- Put8x8uv_SSE2(value, dst);
- } else {
- Put16_SSE2(value, dst);
- }
-}
-
-static WEBP_INLINE void VE8uv_SSE2(uint8_t* dst, const uint8_t* top) {
- int j;
- const __m128i top_values = _mm_loadl_epi64((const __m128i*)top);
- for (j = 0; j < 8; ++j) {
- _mm_storel_epi64((__m128i*)(dst + j * BPS), top_values);
- }
-}
-
-static WEBP_INLINE void VE16_SSE2(uint8_t* dst, const uint8_t* top) {
- const __m128i top_values = _mm_load_si128((const __m128i*)top);
- int j;
- for (j = 0; j < 16; ++j) {
- _mm_store_si128((__m128i*)(dst + j * BPS), top_values);
- }
-}
-
-static WEBP_INLINE void VerticalPred_SSE2(uint8_t* dst,
- const uint8_t* top, int size) {
- if (top != NULL) {
- if (size == 8) {
- VE8uv_SSE2(dst, top);
- } else {
- VE16_SSE2(dst, top);
- }
- } else {
- Fill_SSE2(dst, 127, size);
- }
-}
-
-static WEBP_INLINE void HE8uv_SSE2(uint8_t* dst, const uint8_t* left) {
- int j;
- for (j = 0; j < 8; ++j) {
- const __m128i values = _mm_set1_epi8(left[j]);
- _mm_storel_epi64((__m128i*)dst, values);
- dst += BPS;
- }
-}
-
-static WEBP_INLINE void HE16_SSE2(uint8_t* dst, const uint8_t* left) {
- int j;
- for (j = 0; j < 16; ++j) {
- const __m128i values = _mm_set1_epi8(left[j]);
- _mm_store_si128((__m128i*)dst, values);
- dst += BPS;
- }
-}
-
-static WEBP_INLINE void HorizontalPred_SSE2(uint8_t* dst,
- const uint8_t* left, int size) {
- if (left != NULL) {
- if (size == 8) {
- HE8uv_SSE2(dst, left);
- } else {
- HE16_SSE2(dst, left);
- }
- } else {
- Fill_SSE2(dst, 129, size);
- }
-}
-
-static WEBP_INLINE void TM_SSE2(uint8_t* dst, const uint8_t* left,
- const uint8_t* top, int size) {
- const __m128i zero = _mm_setzero_si128();
- int y;
- if (size == 8) {
- const __m128i top_values = _mm_loadl_epi64((const __m128i*)top);
- const __m128i top_base = _mm_unpacklo_epi8(top_values, zero);
- for (y = 0; y < 8; ++y, dst += BPS) {
- const int val = left[y] - left[-1];
- const __m128i base = _mm_set1_epi16(val);
- const __m128i out = _mm_packus_epi16(_mm_add_epi16(base, top_base), zero);
- _mm_storel_epi64((__m128i*)dst, out);
- }
- } else {
- const __m128i top_values = _mm_load_si128((const __m128i*)top);
- const __m128i top_base_0 = _mm_unpacklo_epi8(top_values, zero);
- const __m128i top_base_1 = _mm_unpackhi_epi8(top_values, zero);
- for (y = 0; y < 16; ++y, dst += BPS) {
- const int val = left[y] - left[-1];
- const __m128i base = _mm_set1_epi16(val);
- const __m128i out_0 = _mm_add_epi16(base, top_base_0);
- const __m128i out_1 = _mm_add_epi16(base, top_base_1);
- const __m128i out = _mm_packus_epi16(out_0, out_1);
- _mm_store_si128((__m128i*)dst, out);
- }
- }
-}
-
-static WEBP_INLINE void TrueMotion_SSE2(uint8_t* dst, const uint8_t* left,
- const uint8_t* top, int size) {
- if (left != NULL) {
- if (top != NULL) {
- TM_SSE2(dst, left, top, size);
- } else {
- HorizontalPred_SSE2(dst, left, size);
- }
- } else {
- // true motion without left samples (hence: with default 129 value)
- // is equivalent to VE prediction where you just copy the top samples.
- // Note that if top samples are not available, the default value is
- // then 129, and not 127 as in the VerticalPred case.
- if (top != NULL) {
- VerticalPred_SSE2(dst, top, size);
- } else {
- Fill_SSE2(dst, 129, size);
- }
- }
-}
-
-static WEBP_INLINE void DC8uv_SSE2(uint8_t* dst, const uint8_t* left,
- const uint8_t* top) {
- const __m128i top_values = _mm_loadl_epi64((const __m128i*)top);
- const __m128i left_values = _mm_loadl_epi64((const __m128i*)left);
- const __m128i combined = _mm_unpacklo_epi64(top_values, left_values);
- const int DC = VP8HorizontalAdd8b(&combined) + 8;
- Put8x8uv_SSE2(DC >> 4, dst);
-}
-
-static WEBP_INLINE void DC8uvNoLeft_SSE2(uint8_t* dst, const uint8_t* top) {
- const __m128i zero = _mm_setzero_si128();
- const __m128i top_values = _mm_loadl_epi64((const __m128i*)top);
- const __m128i sum = _mm_sad_epu8(top_values, zero);
- const int DC = _mm_cvtsi128_si32(sum) + 4;
- Put8x8uv_SSE2(DC >> 3, dst);
-}
-
-static WEBP_INLINE void DC8uvNoTop_SSE2(uint8_t* dst, const uint8_t* left) {
- // 'left' is contiguous so we can reuse the top summation.
- DC8uvNoLeft_SSE2(dst, left);
-}
-
-static WEBP_INLINE void DC8uvNoTopLeft_SSE2(uint8_t* dst) {
- Put8x8uv_SSE2(0x80, dst);
-}
-
-static WEBP_INLINE void DC8uvMode_SSE2(uint8_t* dst, const uint8_t* left,
- const uint8_t* top) {
- if (top != NULL) {
- if (left != NULL) { // top and left present
- DC8uv_SSE2(dst, left, top);
- } else { // top, but no left
- DC8uvNoLeft_SSE2(dst, top);
- }
- } else if (left != NULL) { // left but no top
- DC8uvNoTop_SSE2(dst, left);
- } else { // no top, no left, nothing.
- DC8uvNoTopLeft_SSE2(dst);
- }
-}
-
-static WEBP_INLINE void DC16_SSE2(uint8_t* dst, const uint8_t* left,
- const uint8_t* top) {
- const __m128i top_row = _mm_load_si128((const __m128i*)top);
- const __m128i left_row = _mm_load_si128((const __m128i*)left);
- const int DC =
- VP8HorizontalAdd8b(&top_row) + VP8HorizontalAdd8b(&left_row) + 16;
- Put16_SSE2(DC >> 5, dst);
-}
-
-static WEBP_INLINE void DC16NoLeft_SSE2(uint8_t* dst, const uint8_t* top) {
- const __m128i top_row = _mm_load_si128((const __m128i*)top);
- const int DC = VP8HorizontalAdd8b(&top_row) + 8;
- Put16_SSE2(DC >> 4, dst);
-}
-
-static WEBP_INLINE void DC16NoTop_SSE2(uint8_t* dst, const uint8_t* left) {
- // 'left' is contiguous so we can reuse the top summation.
- DC16NoLeft_SSE2(dst, left);
-}
-
-static WEBP_INLINE void DC16NoTopLeft_SSE2(uint8_t* dst) {
- Put16_SSE2(0x80, dst);
-}
-
-static WEBP_INLINE void DC16Mode_SSE2(uint8_t* dst, const uint8_t* left,
- const uint8_t* top) {
- if (top != NULL) {
- if (left != NULL) { // top and left present
- DC16_SSE2(dst, left, top);
- } else { // top, but no left
- DC16NoLeft_SSE2(dst, top);
- }
- } else if (left != NULL) { // left but no top
- DC16NoTop_SSE2(dst, left);
- } else { // no top, no left, nothing.
- DC16NoTopLeft_SSE2(dst);
- }
-}
-
-//------------------------------------------------------------------------------
-// 4x4 predictions
-
-#define DST(x, y) dst[(x) + (y) * BPS]
-#define AVG3(a, b, c) (((a) + 2 * (b) + (c) + 2) >> 2)
-#define AVG2(a, b) (((a) + (b) + 1) >> 1)
-
-// We use the following 8b-arithmetic tricks:
-// (a + 2 * b + c + 2) >> 2 = (AC + b + 1) >> 1
-// where: AC = (a + c) >> 1 = [(a + c + 1) >> 1] - [(a^c) & 1]
-// and:
-// (a + 2 * b + c + 2) >> 2 = (AB + BC + 1) >> 1 - (ab|bc)&lsb
-// where: AC = (a + b + 1) >> 1, BC = (b + c + 1) >> 1
-// and ab = a ^ b, bc = b ^ c, lsb = (AC^BC)&1
-
-static WEBP_INLINE void VE4_SSE2(uint8_t* dst,
- const uint8_t* top) { // vertical
- const __m128i one = _mm_set1_epi8(1);
- const __m128i ABCDEFGH = _mm_loadl_epi64((__m128i*)(top - 1));
- const __m128i BCDEFGH0 = _mm_srli_si128(ABCDEFGH, 1);
- const __m128i CDEFGH00 = _mm_srli_si128(ABCDEFGH, 2);
- const __m128i a = _mm_avg_epu8(ABCDEFGH, CDEFGH00);
- const __m128i lsb = _mm_and_si128(_mm_xor_si128(ABCDEFGH, CDEFGH00), one);
- const __m128i b = _mm_subs_epu8(a, lsb);
- const __m128i avg = _mm_avg_epu8(b, BCDEFGH0);
- const uint32_t vals = _mm_cvtsi128_si32(avg);
- int i;
- for (i = 0; i < 4; ++i) {
- WebPUint32ToMem(dst + i * BPS, vals);
- }
-}
-
-static WEBP_INLINE void HE4_SSE2(uint8_t* dst,
- const uint8_t* top) { // horizontal
- const int X = top[-1];
- const int I = top[-2];
- const int J = top[-3];
- const int K = top[-4];
- const int L = top[-5];
- WebPUint32ToMem(dst + 0 * BPS, 0x01010101U * AVG3(X, I, J));
- WebPUint32ToMem(dst + 1 * BPS, 0x01010101U * AVG3(I, J, K));
- WebPUint32ToMem(dst + 2 * BPS, 0x01010101U * AVG3(J, K, L));
- WebPUint32ToMem(dst + 3 * BPS, 0x01010101U * AVG3(K, L, L));
-}
-
-static WEBP_INLINE void DC4_SSE2(uint8_t* dst, const uint8_t* top) {
- uint32_t dc = 4;
- int i;
- for (i = 0; i < 4; ++i) dc += top[i] + top[-5 + i];
- Fill_SSE2(dst, dc >> 3, 4);
-}
-
-static WEBP_INLINE void LD4_SSE2(uint8_t* dst,
- const uint8_t* top) { // Down-Left
- const __m128i one = _mm_set1_epi8(1);
- const __m128i ABCDEFGH = _mm_loadl_epi64((const __m128i*)top);
- const __m128i BCDEFGH0 = _mm_srli_si128(ABCDEFGH, 1);
- const __m128i CDEFGH00 = _mm_srli_si128(ABCDEFGH, 2);
- const __m128i CDEFGHH0 = _mm_insert_epi16(CDEFGH00, top[7], 3);
- const __m128i avg1 = _mm_avg_epu8(ABCDEFGH, CDEFGHH0);
- const __m128i lsb = _mm_and_si128(_mm_xor_si128(ABCDEFGH, CDEFGHH0), one);
- const __m128i avg2 = _mm_subs_epu8(avg1, lsb);
- const __m128i abcdefg = _mm_avg_epu8(avg2, BCDEFGH0);
- WebPUint32ToMem(dst + 0 * BPS, _mm_cvtsi128_si32( abcdefg ));
- WebPUint32ToMem(dst + 1 * BPS, _mm_cvtsi128_si32(_mm_srli_si128(abcdefg, 1)));
- WebPUint32ToMem(dst + 2 * BPS, _mm_cvtsi128_si32(_mm_srli_si128(abcdefg, 2)));
- WebPUint32ToMem(dst + 3 * BPS, _mm_cvtsi128_si32(_mm_srli_si128(abcdefg, 3)));
-}
-
-static WEBP_INLINE void VR4_SSE2(uint8_t* dst,
- const uint8_t* top) { // Vertical-Right
- const __m128i one = _mm_set1_epi8(1);
- const int I = top[-2];
- const int J = top[-3];
- const int K = top[-4];
- const int X = top[-1];
- const __m128i XABCD = _mm_loadl_epi64((const __m128i*)(top - 1));
- const __m128i ABCD0 = _mm_srli_si128(XABCD, 1);
- const __m128i abcd = _mm_avg_epu8(XABCD, ABCD0);
- const __m128i _XABCD = _mm_slli_si128(XABCD, 1);
- const __m128i IXABCD = _mm_insert_epi16(_XABCD, (short)(I | (X << 8)), 0);
- const __m128i avg1 = _mm_avg_epu8(IXABCD, ABCD0);
- const __m128i lsb = _mm_and_si128(_mm_xor_si128(IXABCD, ABCD0), one);
- const __m128i avg2 = _mm_subs_epu8(avg1, lsb);
- const __m128i efgh = _mm_avg_epu8(avg2, XABCD);
- WebPUint32ToMem(dst + 0 * BPS, _mm_cvtsi128_si32( abcd ));
- WebPUint32ToMem(dst + 1 * BPS, _mm_cvtsi128_si32( efgh ));
- WebPUint32ToMem(dst + 2 * BPS, _mm_cvtsi128_si32(_mm_slli_si128(abcd, 1)));
- WebPUint32ToMem(dst + 3 * BPS, _mm_cvtsi128_si32(_mm_slli_si128(efgh, 1)));
-
- // these two are hard to implement in SSE2, so we keep the C-version:
- DST(0, 2) = AVG3(J, I, X);
- DST(0, 3) = AVG3(K, J, I);
-}
-
-static WEBP_INLINE void VL4_SSE2(uint8_t* dst,
- const uint8_t* top) { // Vertical-Left
- const __m128i one = _mm_set1_epi8(1);
- const __m128i ABCDEFGH = _mm_loadl_epi64((const __m128i*)top);
- const __m128i BCDEFGH_ = _mm_srli_si128(ABCDEFGH, 1);
- const __m128i CDEFGH__ = _mm_srli_si128(ABCDEFGH, 2);
- const __m128i avg1 = _mm_avg_epu8(ABCDEFGH, BCDEFGH_);
- const __m128i avg2 = _mm_avg_epu8(CDEFGH__, BCDEFGH_);
- const __m128i avg3 = _mm_avg_epu8(avg1, avg2);
- const __m128i lsb1 = _mm_and_si128(_mm_xor_si128(avg1, avg2), one);
- const __m128i ab = _mm_xor_si128(ABCDEFGH, BCDEFGH_);
- const __m128i bc = _mm_xor_si128(CDEFGH__, BCDEFGH_);
- const __m128i abbc = _mm_or_si128(ab, bc);
- const __m128i lsb2 = _mm_and_si128(abbc, lsb1);
- const __m128i avg4 = _mm_subs_epu8(avg3, lsb2);
- const uint32_t extra_out = _mm_cvtsi128_si32(_mm_srli_si128(avg4, 4));
- WebPUint32ToMem(dst + 0 * BPS, _mm_cvtsi128_si32( avg1 ));
- WebPUint32ToMem(dst + 1 * BPS, _mm_cvtsi128_si32( avg4 ));
- WebPUint32ToMem(dst + 2 * BPS, _mm_cvtsi128_si32(_mm_srli_si128(avg1, 1)));
- WebPUint32ToMem(dst + 3 * BPS, _mm_cvtsi128_si32(_mm_srli_si128(avg4, 1)));
-
- // these two are hard to get and irregular
- DST(3, 2) = (extra_out >> 0) & 0xff;
- DST(3, 3) = (extra_out >> 8) & 0xff;
-}
-
-static WEBP_INLINE void RD4_SSE2(uint8_t* dst,
- const uint8_t* top) { // Down-right
- const __m128i one = _mm_set1_epi8(1);
- const __m128i LKJIXABC = _mm_loadl_epi64((const __m128i*)(top - 5));
- const __m128i LKJIXABCD = _mm_insert_epi16(LKJIXABC, top[3], 4);
- const __m128i KJIXABCD_ = _mm_srli_si128(LKJIXABCD, 1);
- const __m128i JIXABCD__ = _mm_srli_si128(LKJIXABCD, 2);
- const __m128i avg1 = _mm_avg_epu8(JIXABCD__, LKJIXABCD);
- const __m128i lsb = _mm_and_si128(_mm_xor_si128(JIXABCD__, LKJIXABCD), one);
- const __m128i avg2 = _mm_subs_epu8(avg1, lsb);
- const __m128i abcdefg = _mm_avg_epu8(avg2, KJIXABCD_);
- WebPUint32ToMem(dst + 3 * BPS, _mm_cvtsi128_si32( abcdefg ));
- WebPUint32ToMem(dst + 2 * BPS, _mm_cvtsi128_si32(_mm_srli_si128(abcdefg, 1)));
- WebPUint32ToMem(dst + 1 * BPS, _mm_cvtsi128_si32(_mm_srli_si128(abcdefg, 2)));
- WebPUint32ToMem(dst + 0 * BPS, _mm_cvtsi128_si32(_mm_srli_si128(abcdefg, 3)));
-}
-
-static WEBP_INLINE void HU4_SSE2(uint8_t* dst, const uint8_t* top) {
- const int I = top[-2];
- const int J = top[-3];
- const int K = top[-4];
- const int L = top[-5];
- DST(0, 0) = AVG2(I, J);
- DST(2, 0) = DST(0, 1) = AVG2(J, K);
- DST(2, 1) = DST(0, 2) = AVG2(K, L);
- DST(1, 0) = AVG3(I, J, K);
- DST(3, 0) = DST(1, 1) = AVG3(J, K, L);
- DST(3, 1) = DST(1, 2) = AVG3(K, L, L);
- DST(3, 2) = DST(2, 2) =
- DST(0, 3) = DST(1, 3) = DST(2, 3) = DST(3, 3) = L;
-}
-
-static WEBP_INLINE void HD4_SSE2(uint8_t* dst, const uint8_t* top) {
- const int X = top[-1];
- const int I = top[-2];
- const int J = top[-3];
- const int K = top[-4];
- const int L = top[-5];
- const int A = top[0];
- const int B = top[1];
- const int C = top[2];
-
- DST(0, 0) = DST(2, 1) = AVG2(I, X);
- DST(0, 1) = DST(2, 2) = AVG2(J, I);
- DST(0, 2) = DST(2, 3) = AVG2(K, J);
- DST(0, 3) = AVG2(L, K);
-
- DST(3, 0) = AVG3(A, B, C);
- DST(2, 0) = AVG3(X, A, B);
- DST(1, 0) = DST(3, 1) = AVG3(I, X, A);
- DST(1, 1) = DST(3, 2) = AVG3(J, I, X);
- DST(1, 2) = DST(3, 3) = AVG3(K, J, I);
- DST(1, 3) = AVG3(L, K, J);
-}
-
-static WEBP_INLINE void TM4_SSE2(uint8_t* dst, const uint8_t* top) {
- const __m128i zero = _mm_setzero_si128();
- const __m128i top_values = _mm_cvtsi32_si128(WebPMemToUint32(top));
- const __m128i top_base = _mm_unpacklo_epi8(top_values, zero);
- int y;
- for (y = 0; y < 4; ++y, dst += BPS) {
- const int val = top[-2 - y] - top[-1];
- const __m128i base = _mm_set1_epi16(val);
- const __m128i out = _mm_packus_epi16(_mm_add_epi16(base, top_base), zero);
- WebPUint32ToMem(dst, _mm_cvtsi128_si32(out));
- }
-}
-
-#undef DST
-#undef AVG3
-#undef AVG2
-
-//------------------------------------------------------------------------------
-// luma 4x4 prediction
-
-// Left samples are top[-5 .. -2], top_left is top[-1], top are
-// located at top[0..3], and top right is top[4..7]
-static void Intra4Preds_SSE2(uint8_t* dst, const uint8_t* top) {
- DC4_SSE2(I4DC4 + dst, top);
- TM4_SSE2(I4TM4 + dst, top);
- VE4_SSE2(I4VE4 + dst, top);
- HE4_SSE2(I4HE4 + dst, top);
- RD4_SSE2(I4RD4 + dst, top);
- VR4_SSE2(I4VR4 + dst, top);
- LD4_SSE2(I4LD4 + dst, top);
- VL4_SSE2(I4VL4 + dst, top);
- HD4_SSE2(I4HD4 + dst, top);
- HU4_SSE2(I4HU4 + dst, top);
-}
-
-//------------------------------------------------------------------------------
-// Chroma 8x8 prediction (paragraph 12.2)
-
-static void IntraChromaPreds_SSE2(uint8_t* dst, const uint8_t* left,
- const uint8_t* top) {
- // U block
- DC8uvMode_SSE2(C8DC8 + dst, left, top);
- VerticalPred_SSE2(C8VE8 + dst, top, 8);
- HorizontalPred_SSE2(C8HE8 + dst, left, 8);
- TrueMotion_SSE2(C8TM8 + dst, left, top, 8);
- // V block
- dst += 8;
- if (top != NULL) top += 8;
- if (left != NULL) left += 16;
- DC8uvMode_SSE2(C8DC8 + dst, left, top);
- VerticalPred_SSE2(C8VE8 + dst, top, 8);
- HorizontalPred_SSE2(C8HE8 + dst, left, 8);
- TrueMotion_SSE2(C8TM8 + dst, left, top, 8);
-}
-
-//------------------------------------------------------------------------------
-// luma 16x16 prediction (paragraph 12.3)
-
-static void Intra16Preds_SSE2(uint8_t* dst,
- const uint8_t* left, const uint8_t* top) {
- DC16Mode_SSE2(I16DC16 + dst, left, top);
- VerticalPred_SSE2(I16VE16 + dst, top, 16);
- HorizontalPred_SSE2(I16HE16 + dst, left, 16);
- TrueMotion_SSE2(I16TM16 + dst, left, top, 16);
-}
-
-//------------------------------------------------------------------------------
-// Metric
-
-static WEBP_INLINE void SubtractAndAccumulate_SSE2(const __m128i a,
- const __m128i b,
- __m128i* const sum) {
- // take abs(a-b) in 8b
- const __m128i a_b = _mm_subs_epu8(a, b);
- const __m128i b_a = _mm_subs_epu8(b, a);
- const __m128i abs_a_b = _mm_or_si128(a_b, b_a);
- // zero-extend to 16b
- const __m128i zero = _mm_setzero_si128();
- const __m128i C0 = _mm_unpacklo_epi8(abs_a_b, zero);
- const __m128i C1 = _mm_unpackhi_epi8(abs_a_b, zero);
- // multiply with self
- const __m128i sum1 = _mm_madd_epi16(C0, C0);
- const __m128i sum2 = _mm_madd_epi16(C1, C1);
- *sum = _mm_add_epi32(sum1, sum2);
-}
-
-static WEBP_INLINE int SSE_16xN_SSE2(const uint8_t* a, const uint8_t* b,
- int num_pairs) {
- __m128i sum = _mm_setzero_si128();
- int32_t tmp[4];
- int i;
-
- for (i = 0; i < num_pairs; ++i) {
- const __m128i a0 = _mm_loadu_si128((const __m128i*)&a[BPS * 0]);
- const __m128i b0 = _mm_loadu_si128((const __m128i*)&b[BPS * 0]);
- const __m128i a1 = _mm_loadu_si128((const __m128i*)&a[BPS * 1]);
- const __m128i b1 = _mm_loadu_si128((const __m128i*)&b[BPS * 1]);
- __m128i sum1, sum2;
- SubtractAndAccumulate_SSE2(a0, b0, &sum1);
- SubtractAndAccumulate_SSE2(a1, b1, &sum2);
- sum = _mm_add_epi32(sum, _mm_add_epi32(sum1, sum2));
- a += 2 * BPS;
- b += 2 * BPS;
- }
- _mm_storeu_si128((__m128i*)tmp, sum);
- return (tmp[3] + tmp[2] + tmp[1] + tmp[0]);
-}
-
-static int SSE16x16_SSE2(const uint8_t* a, const uint8_t* b) {
- return SSE_16xN_SSE2(a, b, 8);
-}
-
-static int SSE16x8_SSE2(const uint8_t* a, const uint8_t* b) {
- return SSE_16xN_SSE2(a, b, 4);
-}
-
-#define LOAD_8x16b(ptr) \
- _mm_unpacklo_epi8(_mm_loadl_epi64((const __m128i*)(ptr)), zero)
-
-static int SSE8x8_SSE2(const uint8_t* a, const uint8_t* b) {
- const __m128i zero = _mm_setzero_si128();
- int num_pairs = 4;
- __m128i sum = zero;
- int32_t tmp[4];
- while (num_pairs-- > 0) {
- const __m128i a0 = LOAD_8x16b(&a[BPS * 0]);
- const __m128i a1 = LOAD_8x16b(&a[BPS * 1]);
- const __m128i b0 = LOAD_8x16b(&b[BPS * 0]);
- const __m128i b1 = LOAD_8x16b(&b[BPS * 1]);
- // subtract
- const __m128i c0 = _mm_subs_epi16(a0, b0);
- const __m128i c1 = _mm_subs_epi16(a1, b1);
- // multiply/accumulate with self
- const __m128i d0 = _mm_madd_epi16(c0, c0);
- const __m128i d1 = _mm_madd_epi16(c1, c1);
- // collect
- const __m128i sum01 = _mm_add_epi32(d0, d1);
- sum = _mm_add_epi32(sum, sum01);
- a += 2 * BPS;
- b += 2 * BPS;
- }
- _mm_storeu_si128((__m128i*)tmp, sum);
- return (tmp[3] + tmp[2] + tmp[1] + tmp[0]);
-}
-#undef LOAD_8x16b
-
-static int SSE4x4_SSE2(const uint8_t* a, const uint8_t* b) {
- const __m128i zero = _mm_setzero_si128();
-
- // Load values. Note that we read 8 pixels instead of 4,
- // but the a/b buffers are over-allocated to that effect.
- const __m128i a0 = _mm_loadl_epi64((const __m128i*)&a[BPS * 0]);
- const __m128i a1 = _mm_loadl_epi64((const __m128i*)&a[BPS * 1]);
- const __m128i a2 = _mm_loadl_epi64((const __m128i*)&a[BPS * 2]);
- const __m128i a3 = _mm_loadl_epi64((const __m128i*)&a[BPS * 3]);
- const __m128i b0 = _mm_loadl_epi64((const __m128i*)&b[BPS * 0]);
- const __m128i b1 = _mm_loadl_epi64((const __m128i*)&b[BPS * 1]);
- const __m128i b2 = _mm_loadl_epi64((const __m128i*)&b[BPS * 2]);
- const __m128i b3 = _mm_loadl_epi64((const __m128i*)&b[BPS * 3]);
- // Combine pair of lines.
- const __m128i a01 = _mm_unpacklo_epi32(a0, a1);
- const __m128i a23 = _mm_unpacklo_epi32(a2, a3);
- const __m128i b01 = _mm_unpacklo_epi32(b0, b1);
- const __m128i b23 = _mm_unpacklo_epi32(b2, b3);
- // Convert to 16b.
- const __m128i a01s = _mm_unpacklo_epi8(a01, zero);
- const __m128i a23s = _mm_unpacklo_epi8(a23, zero);
- const __m128i b01s = _mm_unpacklo_epi8(b01, zero);
- const __m128i b23s = _mm_unpacklo_epi8(b23, zero);
- // subtract, square and accumulate
- const __m128i d0 = _mm_subs_epi16(a01s, b01s);
- const __m128i d1 = _mm_subs_epi16(a23s, b23s);
- const __m128i e0 = _mm_madd_epi16(d0, d0);
- const __m128i e1 = _mm_madd_epi16(d1, d1);
- const __m128i sum = _mm_add_epi32(e0, e1);
-
- int32_t tmp[4];
- _mm_storeu_si128((__m128i*)tmp, sum);
- return (tmp[3] + tmp[2] + tmp[1] + tmp[0]);
-}
-
-//------------------------------------------------------------------------------
-
-static void Mean16x4_SSE2(const uint8_t* ref, uint32_t dc[4]) {
- const __m128i mask = _mm_set1_epi16(0x00ff);
- const __m128i a0 = _mm_loadu_si128((const __m128i*)&ref[BPS * 0]);
- const __m128i a1 = _mm_loadu_si128((const __m128i*)&ref[BPS * 1]);
- const __m128i a2 = _mm_loadu_si128((const __m128i*)&ref[BPS * 2]);
- const __m128i a3 = _mm_loadu_si128((const __m128i*)&ref[BPS * 3]);
- const __m128i b0 = _mm_srli_epi16(a0, 8); // hi byte
- const __m128i b1 = _mm_srli_epi16(a1, 8);
- const __m128i b2 = _mm_srli_epi16(a2, 8);
- const __m128i b3 = _mm_srli_epi16(a3, 8);
- const __m128i c0 = _mm_and_si128(a0, mask); // lo byte
- const __m128i c1 = _mm_and_si128(a1, mask);
- const __m128i c2 = _mm_and_si128(a2, mask);
- const __m128i c3 = _mm_and_si128(a3, mask);
- const __m128i d0 = _mm_add_epi32(b0, c0);
- const __m128i d1 = _mm_add_epi32(b1, c1);
- const __m128i d2 = _mm_add_epi32(b2, c2);
- const __m128i d3 = _mm_add_epi32(b3, c3);
- const __m128i e0 = _mm_add_epi32(d0, d1);
- const __m128i e1 = _mm_add_epi32(d2, d3);
- const __m128i f0 = _mm_add_epi32(e0, e1);
- uint16_t tmp[8];
- _mm_storeu_si128((__m128i*)tmp, f0);
- dc[0] = tmp[0] + tmp[1];
- dc[1] = tmp[2] + tmp[3];
- dc[2] = tmp[4] + tmp[5];
- dc[3] = tmp[6] + tmp[7];
-}
-
-//------------------------------------------------------------------------------
-// Texture distortion
-//
-// We try to match the spectral content (weighted) between source and
-// reconstructed samples.
-
-// Hadamard transform
-// Returns the weighted sum of the absolute value of transformed coefficients.
-// w[] contains a row-major 4 by 4 symmetric matrix.
-static int TTransform_SSE2(const uint8_t* inA, const uint8_t* inB,
- const uint16_t* const w) {
- int32_t sum[4];
- __m128i tmp_0, tmp_1, tmp_2, tmp_3;
- const __m128i zero = _mm_setzero_si128();
-
- // Load and combine inputs.
- {
- const __m128i inA_0 = _mm_loadl_epi64((const __m128i*)&inA[BPS * 0]);
- const __m128i inA_1 = _mm_loadl_epi64((const __m128i*)&inA[BPS * 1]);
- const __m128i inA_2 = _mm_loadl_epi64((const __m128i*)&inA[BPS * 2]);
- const __m128i inA_3 = _mm_loadl_epi64((const __m128i*)&inA[BPS * 3]);
- const __m128i inB_0 = _mm_loadl_epi64((const __m128i*)&inB[BPS * 0]);
- const __m128i inB_1 = _mm_loadl_epi64((const __m128i*)&inB[BPS * 1]);
- const __m128i inB_2 = _mm_loadl_epi64((const __m128i*)&inB[BPS * 2]);
- const __m128i inB_3 = _mm_loadl_epi64((const __m128i*)&inB[BPS * 3]);
-
- // Combine inA and inB (we'll do two transforms in parallel).
- const __m128i inAB_0 = _mm_unpacklo_epi32(inA_0, inB_0);
- const __m128i inAB_1 = _mm_unpacklo_epi32(inA_1, inB_1);
- const __m128i inAB_2 = _mm_unpacklo_epi32(inA_2, inB_2);
- const __m128i inAB_3 = _mm_unpacklo_epi32(inA_3, inB_3);
- tmp_0 = _mm_unpacklo_epi8(inAB_0, zero);
- tmp_1 = _mm_unpacklo_epi8(inAB_1, zero);
- tmp_2 = _mm_unpacklo_epi8(inAB_2, zero);
- tmp_3 = _mm_unpacklo_epi8(inAB_3, zero);
- // a00 a01 a02 a03 b00 b01 b02 b03
- // a10 a11 a12 a13 b10 b11 b12 b13
- // a20 a21 a22 a23 b20 b21 b22 b23
- // a30 a31 a32 a33 b30 b31 b32 b33
- }
-
- // Vertical pass first to avoid a transpose (vertical and horizontal passes
- // are commutative because w/kWeightY is symmetric) and subsequent transpose.
- {
- // Calculate a and b (two 4x4 at once).
- const __m128i a0 = _mm_add_epi16(tmp_0, tmp_2);
- const __m128i a1 = _mm_add_epi16(tmp_1, tmp_3);
- const __m128i a2 = _mm_sub_epi16(tmp_1, tmp_3);
- const __m128i a3 = _mm_sub_epi16(tmp_0, tmp_2);
- const __m128i b0 = _mm_add_epi16(a0, a1);
- const __m128i b1 = _mm_add_epi16(a3, a2);
- const __m128i b2 = _mm_sub_epi16(a3, a2);
- const __m128i b3 = _mm_sub_epi16(a0, a1);
- // a00 a01 a02 a03 b00 b01 b02 b03
- // a10 a11 a12 a13 b10 b11 b12 b13
- // a20 a21 a22 a23 b20 b21 b22 b23
- // a30 a31 a32 a33 b30 b31 b32 b33
-
- // Transpose the two 4x4.
- VP8Transpose_2_4x4_16b(&b0, &b1, &b2, &b3, &tmp_0, &tmp_1, &tmp_2, &tmp_3);
- }
-
- // Horizontal pass and difference of weighted sums.
- {
- // Load all inputs.
- const __m128i w_0 = _mm_loadu_si128((const __m128i*)&w[0]);
- const __m128i w_8 = _mm_loadu_si128((const __m128i*)&w[8]);
-
- // Calculate a and b (two 4x4 at once).
- const __m128i a0 = _mm_add_epi16(tmp_0, tmp_2);
- const __m128i a1 = _mm_add_epi16(tmp_1, tmp_3);
- const __m128i a2 = _mm_sub_epi16(tmp_1, tmp_3);
- const __m128i a3 = _mm_sub_epi16(tmp_0, tmp_2);
- const __m128i b0 = _mm_add_epi16(a0, a1);
- const __m128i b1 = _mm_add_epi16(a3, a2);
- const __m128i b2 = _mm_sub_epi16(a3, a2);
- const __m128i b3 = _mm_sub_epi16(a0, a1);
-
- // Separate the transforms of inA and inB.
- __m128i A_b0 = _mm_unpacklo_epi64(b0, b1);
- __m128i A_b2 = _mm_unpacklo_epi64(b2, b3);
- __m128i B_b0 = _mm_unpackhi_epi64(b0, b1);
- __m128i B_b2 = _mm_unpackhi_epi64(b2, b3);
-
- {
- const __m128i d0 = _mm_sub_epi16(zero, A_b0);
- const __m128i d1 = _mm_sub_epi16(zero, A_b2);
- const __m128i d2 = _mm_sub_epi16(zero, B_b0);
- const __m128i d3 = _mm_sub_epi16(zero, B_b2);
- A_b0 = _mm_max_epi16(A_b0, d0); // abs(v), 16b
- A_b2 = _mm_max_epi16(A_b2, d1);
- B_b0 = _mm_max_epi16(B_b0, d2);
- B_b2 = _mm_max_epi16(B_b2, d3);
- }
-
- // weighted sums
- A_b0 = _mm_madd_epi16(A_b0, w_0);
- A_b2 = _mm_madd_epi16(A_b2, w_8);
- B_b0 = _mm_madd_epi16(B_b0, w_0);
- B_b2 = _mm_madd_epi16(B_b2, w_8);
- A_b0 = _mm_add_epi32(A_b0, A_b2);
- B_b0 = _mm_add_epi32(B_b0, B_b2);
-
- // difference of weighted sums
- A_b0 = _mm_sub_epi32(A_b0, B_b0);
- _mm_storeu_si128((__m128i*)&sum[0], A_b0);
- }
- return sum[0] + sum[1] + sum[2] + sum[3];
-}
-
-static int Disto4x4_SSE2(const uint8_t* const a, const uint8_t* const b,
- const uint16_t* const w) {
- const int diff_sum = TTransform_SSE2(a, b, w);
- return abs(diff_sum) >> 5;
-}
-
-static int Disto16x16_SSE2(const uint8_t* const a, const uint8_t* const b,
- const uint16_t* const w) {
- int D = 0;
- int x, y;
- for (y = 0; y < 16 * BPS; y += 4 * BPS) {
- for (x = 0; x < 16; x += 4) {
- D += Disto4x4_SSE2(a + x + y, b + x + y, w);
- }
- }
- return D;
-}
-
-//------------------------------------------------------------------------------
-// Quantization
-//
-
-static WEBP_INLINE int DoQuantizeBlock_SSE2(int16_t in[16], int16_t out[16],
- const uint16_t* const sharpen,
- const VP8Matrix* const mtx) {
- const __m128i max_coeff_2047 = _mm_set1_epi16(MAX_LEVEL);
- const __m128i zero = _mm_setzero_si128();
- __m128i coeff0, coeff8;
- __m128i out0, out8;
- __m128i packed_out;
-
- // Load all inputs.
- __m128i in0 = _mm_loadu_si128((__m128i*)&in[0]);
- __m128i in8 = _mm_loadu_si128((__m128i*)&in[8]);
- const __m128i iq0 = _mm_loadu_si128((const __m128i*)&mtx->iq_[0]);
- const __m128i iq8 = _mm_loadu_si128((const __m128i*)&mtx->iq_[8]);
- const __m128i q0 = _mm_loadu_si128((const __m128i*)&mtx->q_[0]);
- const __m128i q8 = _mm_loadu_si128((const __m128i*)&mtx->q_[8]);
-
- // extract sign(in) (0x0000 if positive, 0xffff if negative)
- const __m128i sign0 = _mm_cmpgt_epi16(zero, in0);
- const __m128i sign8 = _mm_cmpgt_epi16(zero, in8);
-
- // coeff = abs(in) = (in ^ sign) - sign
- coeff0 = _mm_xor_si128(in0, sign0);
- coeff8 = _mm_xor_si128(in8, sign8);
- coeff0 = _mm_sub_epi16(coeff0, sign0);
- coeff8 = _mm_sub_epi16(coeff8, sign8);
-
- // coeff = abs(in) + sharpen
- if (sharpen != NULL) {
- const __m128i sharpen0 = _mm_loadu_si128((const __m128i*)&sharpen[0]);
- const __m128i sharpen8 = _mm_loadu_si128((const __m128i*)&sharpen[8]);
- coeff0 = _mm_add_epi16(coeff0, sharpen0);
- coeff8 = _mm_add_epi16(coeff8, sharpen8);
- }
-
- // out = (coeff * iQ + B) >> QFIX
- {
- // doing calculations with 32b precision (QFIX=17)
- // out = (coeff * iQ)
- const __m128i coeff_iQ0H = _mm_mulhi_epu16(coeff0, iq0);
- const __m128i coeff_iQ0L = _mm_mullo_epi16(coeff0, iq0);
- const __m128i coeff_iQ8H = _mm_mulhi_epu16(coeff8, iq8);
- const __m128i coeff_iQ8L = _mm_mullo_epi16(coeff8, iq8);
- __m128i out_00 = _mm_unpacklo_epi16(coeff_iQ0L, coeff_iQ0H);
- __m128i out_04 = _mm_unpackhi_epi16(coeff_iQ0L, coeff_iQ0H);
- __m128i out_08 = _mm_unpacklo_epi16(coeff_iQ8L, coeff_iQ8H);
- __m128i out_12 = _mm_unpackhi_epi16(coeff_iQ8L, coeff_iQ8H);
- // out = (coeff * iQ + B)
- const __m128i bias_00 = _mm_loadu_si128((const __m128i*)&mtx->bias_[0]);
- const __m128i bias_04 = _mm_loadu_si128((const __m128i*)&mtx->bias_[4]);
- const __m128i bias_08 = _mm_loadu_si128((const __m128i*)&mtx->bias_[8]);
- const __m128i bias_12 = _mm_loadu_si128((const __m128i*)&mtx->bias_[12]);
- out_00 = _mm_add_epi32(out_00, bias_00);
- out_04 = _mm_add_epi32(out_04, bias_04);
- out_08 = _mm_add_epi32(out_08, bias_08);
- out_12 = _mm_add_epi32(out_12, bias_12);
- // out = QUANTDIV(coeff, iQ, B, QFIX)
- out_00 = _mm_srai_epi32(out_00, QFIX);
- out_04 = _mm_srai_epi32(out_04, QFIX);
- out_08 = _mm_srai_epi32(out_08, QFIX);
- out_12 = _mm_srai_epi32(out_12, QFIX);
-
- // pack result as 16b
- out0 = _mm_packs_epi32(out_00, out_04);
- out8 = _mm_packs_epi32(out_08, out_12);
-
- // if (coeff > 2047) coeff = 2047
- out0 = _mm_min_epi16(out0, max_coeff_2047);
- out8 = _mm_min_epi16(out8, max_coeff_2047);
- }
-
- // get sign back (if (sign[j]) out_n = -out_n)
- out0 = _mm_xor_si128(out0, sign0);
- out8 = _mm_xor_si128(out8, sign8);
- out0 = _mm_sub_epi16(out0, sign0);
- out8 = _mm_sub_epi16(out8, sign8);
-
- // in = out * Q
- in0 = _mm_mullo_epi16(out0, q0);
- in8 = _mm_mullo_epi16(out8, q8);
-
- _mm_storeu_si128((__m128i*)&in[0], in0);
- _mm_storeu_si128((__m128i*)&in[8], in8);
-
- // zigzag the output before storing it.
- //
- // The zigzag pattern can almost be reproduced with a small sequence of
- // shuffles. After it, we only need to swap the 7th (ending up in third
- // position instead of twelfth) and 8th values.
- {
- __m128i outZ0, outZ8;
- outZ0 = _mm_shufflehi_epi16(out0, _MM_SHUFFLE(2, 1, 3, 0));
- outZ0 = _mm_shuffle_epi32 (outZ0, _MM_SHUFFLE(3, 1, 2, 0));
- outZ0 = _mm_shufflehi_epi16(outZ0, _MM_SHUFFLE(3, 1, 0, 2));
- outZ8 = _mm_shufflelo_epi16(out8, _MM_SHUFFLE(3, 0, 2, 1));
- outZ8 = _mm_shuffle_epi32 (outZ8, _MM_SHUFFLE(3, 1, 2, 0));
- outZ8 = _mm_shufflelo_epi16(outZ8, _MM_SHUFFLE(1, 3, 2, 0));
- _mm_storeu_si128((__m128i*)&out[0], outZ0);
- _mm_storeu_si128((__m128i*)&out[8], outZ8);
- packed_out = _mm_packs_epi16(outZ0, outZ8);
- }
- {
- const int16_t outZ_12 = out[12];
- const int16_t outZ_3 = out[3];
- out[3] = outZ_12;
- out[12] = outZ_3;
- }
-
- // detect if all 'out' values are zeroes or not
- return (_mm_movemask_epi8(_mm_cmpeq_epi8(packed_out, zero)) != 0xffff);
-}
-
-static int QuantizeBlock_SSE2(int16_t in[16], int16_t out[16],
- const VP8Matrix* const mtx) {
- return DoQuantizeBlock_SSE2(in, out, &mtx->sharpen_[0], mtx);
-}
-
-static int QuantizeBlockWHT_SSE2(int16_t in[16], int16_t out[16],
- const VP8Matrix* const mtx) {
- return DoQuantizeBlock_SSE2(in, out, NULL, mtx);
-}
-
-static int Quantize2Blocks_SSE2(int16_t in[32], int16_t out[32],
- const VP8Matrix* const mtx) {
- int nz;
- const uint16_t* const sharpen = &mtx->sharpen_[0];
- nz = DoQuantizeBlock_SSE2(in + 0 * 16, out + 0 * 16, sharpen, mtx) << 0;
- nz |= DoQuantizeBlock_SSE2(in + 1 * 16, out + 1 * 16, sharpen, mtx) << 1;
- return nz;
-}
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void VP8EncDspInitSSE2(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void VP8EncDspInitSSE2(void) {
- VP8CollectHistogram = CollectHistogram_SSE2;
- VP8EncPredLuma16 = Intra16Preds_SSE2;
- VP8EncPredChroma8 = IntraChromaPreds_SSE2;
- VP8EncPredLuma4 = Intra4Preds_SSE2;
- VP8EncQuantizeBlock = QuantizeBlock_SSE2;
- VP8EncQuantize2Blocks = Quantize2Blocks_SSE2;
- VP8EncQuantizeBlockWHT = QuantizeBlockWHT_SSE2;
- VP8ITransform = ITransform_SSE2;
- VP8FTransform = FTransform_SSE2;
- VP8FTransform2 = FTransform2_SSE2;
- VP8FTransformWHT = FTransformWHT_SSE2;
- VP8SSE16x16 = SSE16x16_SSE2;
- VP8SSE16x8 = SSE16x8_SSE2;
- VP8SSE8x8 = SSE8x8_SSE2;
- VP8SSE4x4 = SSE4x4_SSE2;
- VP8TDisto4x4 = Disto4x4_SSE2;
- VP8TDisto16x16 = Disto16x16_SSE2;
- VP8Mean16x4 = Mean16x4_SSE2;
-}
-
-#else // !WEBP_USE_SSE2
-
-WEBP_DSP_INIT_STUB(VP8EncDspInitSSE2)
-
-#endif // WEBP_USE_SSE2
diff --git a/contrib/libs/libwebp/dsp/enc_sse41.c b/contrib/libs/libwebp/dsp/enc_sse41.c
deleted file mode 100644
index a3f4b6bec4..0000000000
--- a/contrib/libs/libwebp/dsp/enc_sse41.c
+++ /dev/null
@@ -1,339 +0,0 @@
-// Copyright 2015 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// SSE4 version of some encoding functions.
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_SSE41)
-#include <smmintrin.h>
-#include <stdlib.h> // for abs()
-
-#include "./common_sse2.h"
-#include "../enc/vp8i_enc.h"
-
-//------------------------------------------------------------------------------
-// Compute susceptibility based on DCT-coeff histograms.
-
-static void CollectHistogram_SSE41(const uint8_t* ref, const uint8_t* pred,
- int start_block, int end_block,
- VP8Histogram* const histo) {
- const __m128i max_coeff_thresh = _mm_set1_epi16(MAX_COEFF_THRESH);
- int j;
- int distribution[MAX_COEFF_THRESH + 1] = { 0 };
- for (j = start_block; j < end_block; ++j) {
- int16_t out[16];
- int k;
-
- VP8FTransform(ref + VP8DspScan[j], pred + VP8DspScan[j], out);
-
- // Convert coefficients to bin (within out[]).
- {
- // Load.
- const __m128i out0 = _mm_loadu_si128((__m128i*)&out[0]);
- const __m128i out1 = _mm_loadu_si128((__m128i*)&out[8]);
- // v = abs(out) >> 3
- const __m128i abs0 = _mm_abs_epi16(out0);
- const __m128i abs1 = _mm_abs_epi16(out1);
- const __m128i v0 = _mm_srai_epi16(abs0, 3);
- const __m128i v1 = _mm_srai_epi16(abs1, 3);
- // bin = min(v, MAX_COEFF_THRESH)
- const __m128i bin0 = _mm_min_epi16(v0, max_coeff_thresh);
- const __m128i bin1 = _mm_min_epi16(v1, max_coeff_thresh);
- // Store.
- _mm_storeu_si128((__m128i*)&out[0], bin0);
- _mm_storeu_si128((__m128i*)&out[8], bin1);
- }
-
- // Convert coefficients to bin.
- for (k = 0; k < 16; ++k) {
- ++distribution[out[k]];
- }
- }
- VP8SetHistogramData(distribution, histo);
-}
-
-//------------------------------------------------------------------------------
-// Texture distortion
-//
-// We try to match the spectral content (weighted) between source and
-// reconstructed samples.
-
-// Hadamard transform
-// Returns the weighted sum of the absolute value of transformed coefficients.
-// w[] contains a row-major 4 by 4 symmetric matrix.
-static int TTransform_SSE41(const uint8_t* inA, const uint8_t* inB,
- const uint16_t* const w) {
- int32_t sum[4];
- __m128i tmp_0, tmp_1, tmp_2, tmp_3;
-
- // Load and combine inputs.
- {
- const __m128i inA_0 = _mm_loadu_si128((const __m128i*)&inA[BPS * 0]);
- const __m128i inA_1 = _mm_loadu_si128((const __m128i*)&inA[BPS * 1]);
- const __m128i inA_2 = _mm_loadu_si128((const __m128i*)&inA[BPS * 2]);
- // In SSE4.1, with gcc 4.8 at least (maybe other versions),
- // _mm_loadu_si128 is faster than _mm_loadl_epi64. But for the last lump
- // of inA and inB, _mm_loadl_epi64 is still used not to have an out of
- // bound read.
- const __m128i inA_3 = _mm_loadl_epi64((const __m128i*)&inA[BPS * 3]);
- const __m128i inB_0 = _mm_loadu_si128((const __m128i*)&inB[BPS * 0]);
- const __m128i inB_1 = _mm_loadu_si128((const __m128i*)&inB[BPS * 1]);
- const __m128i inB_2 = _mm_loadu_si128((const __m128i*)&inB[BPS * 2]);
- const __m128i inB_3 = _mm_loadl_epi64((const __m128i*)&inB[BPS * 3]);
-
- // Combine inA and inB (we'll do two transforms in parallel).
- const __m128i inAB_0 = _mm_unpacklo_epi32(inA_0, inB_0);
- const __m128i inAB_1 = _mm_unpacklo_epi32(inA_1, inB_1);
- const __m128i inAB_2 = _mm_unpacklo_epi32(inA_2, inB_2);
- const __m128i inAB_3 = _mm_unpacklo_epi32(inA_3, inB_3);
- tmp_0 = _mm_cvtepu8_epi16(inAB_0);
- tmp_1 = _mm_cvtepu8_epi16(inAB_1);
- tmp_2 = _mm_cvtepu8_epi16(inAB_2);
- tmp_3 = _mm_cvtepu8_epi16(inAB_3);
- // a00 a01 a02 a03 b00 b01 b02 b03
- // a10 a11 a12 a13 b10 b11 b12 b13
- // a20 a21 a22 a23 b20 b21 b22 b23
- // a30 a31 a32 a33 b30 b31 b32 b33
- }
-
- // Vertical pass first to avoid a transpose (vertical and horizontal passes
- // are commutative because w/kWeightY is symmetric) and subsequent transpose.
- {
- // Calculate a and b (two 4x4 at once).
- const __m128i a0 = _mm_add_epi16(tmp_0, tmp_2);
- const __m128i a1 = _mm_add_epi16(tmp_1, tmp_3);
- const __m128i a2 = _mm_sub_epi16(tmp_1, tmp_3);
- const __m128i a3 = _mm_sub_epi16(tmp_0, tmp_2);
- const __m128i b0 = _mm_add_epi16(a0, a1);
- const __m128i b1 = _mm_add_epi16(a3, a2);
- const __m128i b2 = _mm_sub_epi16(a3, a2);
- const __m128i b3 = _mm_sub_epi16(a0, a1);
- // a00 a01 a02 a03 b00 b01 b02 b03
- // a10 a11 a12 a13 b10 b11 b12 b13
- // a20 a21 a22 a23 b20 b21 b22 b23
- // a30 a31 a32 a33 b30 b31 b32 b33
-
- // Transpose the two 4x4.
- VP8Transpose_2_4x4_16b(&b0, &b1, &b2, &b3, &tmp_0, &tmp_1, &tmp_2, &tmp_3);
- }
-
- // Horizontal pass and difference of weighted sums.
- {
- // Load all inputs.
- const __m128i w_0 = _mm_loadu_si128((const __m128i*)&w[0]);
- const __m128i w_8 = _mm_loadu_si128((const __m128i*)&w[8]);
-
- // Calculate a and b (two 4x4 at once).
- const __m128i a0 = _mm_add_epi16(tmp_0, tmp_2);
- const __m128i a1 = _mm_add_epi16(tmp_1, tmp_3);
- const __m128i a2 = _mm_sub_epi16(tmp_1, tmp_3);
- const __m128i a3 = _mm_sub_epi16(tmp_0, tmp_2);
- const __m128i b0 = _mm_add_epi16(a0, a1);
- const __m128i b1 = _mm_add_epi16(a3, a2);
- const __m128i b2 = _mm_sub_epi16(a3, a2);
- const __m128i b3 = _mm_sub_epi16(a0, a1);
-
- // Separate the transforms of inA and inB.
- __m128i A_b0 = _mm_unpacklo_epi64(b0, b1);
- __m128i A_b2 = _mm_unpacklo_epi64(b2, b3);
- __m128i B_b0 = _mm_unpackhi_epi64(b0, b1);
- __m128i B_b2 = _mm_unpackhi_epi64(b2, b3);
-
- A_b0 = _mm_abs_epi16(A_b0);
- A_b2 = _mm_abs_epi16(A_b2);
- B_b0 = _mm_abs_epi16(B_b0);
- B_b2 = _mm_abs_epi16(B_b2);
-
- // weighted sums
- A_b0 = _mm_madd_epi16(A_b0, w_0);
- A_b2 = _mm_madd_epi16(A_b2, w_8);
- B_b0 = _mm_madd_epi16(B_b0, w_0);
- B_b2 = _mm_madd_epi16(B_b2, w_8);
- A_b0 = _mm_add_epi32(A_b0, A_b2);
- B_b0 = _mm_add_epi32(B_b0, B_b2);
-
- // difference of weighted sums
- A_b2 = _mm_sub_epi32(A_b0, B_b0);
- _mm_storeu_si128((__m128i*)&sum[0], A_b2);
- }
- return sum[0] + sum[1] + sum[2] + sum[3];
-}
-
-static int Disto4x4_SSE41(const uint8_t* const a, const uint8_t* const b,
- const uint16_t* const w) {
- const int diff_sum = TTransform_SSE41(a, b, w);
- return abs(diff_sum) >> 5;
-}
-
-static int Disto16x16_SSE41(const uint8_t* const a, const uint8_t* const b,
- const uint16_t* const w) {
- int D = 0;
- int x, y;
- for (y = 0; y < 16 * BPS; y += 4 * BPS) {
- for (x = 0; x < 16; x += 4) {
- D += Disto4x4_SSE41(a + x + y, b + x + y, w);
- }
- }
- return D;
-}
-
-//------------------------------------------------------------------------------
-// Quantization
-//
-
-// Generates a pshufb constant for shuffling 16b words.
-#define PSHUFB_CST(A,B,C,D,E,F,G,H) \
- _mm_set_epi8(2 * (H) + 1, 2 * (H) + 0, 2 * (G) + 1, 2 * (G) + 0, \
- 2 * (F) + 1, 2 * (F) + 0, 2 * (E) + 1, 2 * (E) + 0, \
- 2 * (D) + 1, 2 * (D) + 0, 2 * (C) + 1, 2 * (C) + 0, \
- 2 * (B) + 1, 2 * (B) + 0, 2 * (A) + 1, 2 * (A) + 0)
-
-static WEBP_INLINE int DoQuantizeBlock_SSE41(int16_t in[16], int16_t out[16],
- const uint16_t* const sharpen,
- const VP8Matrix* const mtx) {
- const __m128i max_coeff_2047 = _mm_set1_epi16(MAX_LEVEL);
- const __m128i zero = _mm_setzero_si128();
- __m128i out0, out8;
- __m128i packed_out;
-
- // Load all inputs.
- __m128i in0 = _mm_loadu_si128((__m128i*)&in[0]);
- __m128i in8 = _mm_loadu_si128((__m128i*)&in[8]);
- const __m128i iq0 = _mm_loadu_si128((const __m128i*)&mtx->iq_[0]);
- const __m128i iq8 = _mm_loadu_si128((const __m128i*)&mtx->iq_[8]);
- const __m128i q0 = _mm_loadu_si128((const __m128i*)&mtx->q_[0]);
- const __m128i q8 = _mm_loadu_si128((const __m128i*)&mtx->q_[8]);
-
- // coeff = abs(in)
- __m128i coeff0 = _mm_abs_epi16(in0);
- __m128i coeff8 = _mm_abs_epi16(in8);
-
- // coeff = abs(in) + sharpen
- if (sharpen != NULL) {
- const __m128i sharpen0 = _mm_loadu_si128((const __m128i*)&sharpen[0]);
- const __m128i sharpen8 = _mm_loadu_si128((const __m128i*)&sharpen[8]);
- coeff0 = _mm_add_epi16(coeff0, sharpen0);
- coeff8 = _mm_add_epi16(coeff8, sharpen8);
- }
-
- // out = (coeff * iQ + B) >> QFIX
- {
- // doing calculations with 32b precision (QFIX=17)
- // out = (coeff * iQ)
- const __m128i coeff_iQ0H = _mm_mulhi_epu16(coeff0, iq0);
- const __m128i coeff_iQ0L = _mm_mullo_epi16(coeff0, iq0);
- const __m128i coeff_iQ8H = _mm_mulhi_epu16(coeff8, iq8);
- const __m128i coeff_iQ8L = _mm_mullo_epi16(coeff8, iq8);
- __m128i out_00 = _mm_unpacklo_epi16(coeff_iQ0L, coeff_iQ0H);
- __m128i out_04 = _mm_unpackhi_epi16(coeff_iQ0L, coeff_iQ0H);
- __m128i out_08 = _mm_unpacklo_epi16(coeff_iQ8L, coeff_iQ8H);
- __m128i out_12 = _mm_unpackhi_epi16(coeff_iQ8L, coeff_iQ8H);
- // out = (coeff * iQ + B)
- const __m128i bias_00 = _mm_loadu_si128((const __m128i*)&mtx->bias_[0]);
- const __m128i bias_04 = _mm_loadu_si128((const __m128i*)&mtx->bias_[4]);
- const __m128i bias_08 = _mm_loadu_si128((const __m128i*)&mtx->bias_[8]);
- const __m128i bias_12 = _mm_loadu_si128((const __m128i*)&mtx->bias_[12]);
- out_00 = _mm_add_epi32(out_00, bias_00);
- out_04 = _mm_add_epi32(out_04, bias_04);
- out_08 = _mm_add_epi32(out_08, bias_08);
- out_12 = _mm_add_epi32(out_12, bias_12);
- // out = QUANTDIV(coeff, iQ, B, QFIX)
- out_00 = _mm_srai_epi32(out_00, QFIX);
- out_04 = _mm_srai_epi32(out_04, QFIX);
- out_08 = _mm_srai_epi32(out_08, QFIX);
- out_12 = _mm_srai_epi32(out_12, QFIX);
-
- // pack result as 16b
- out0 = _mm_packs_epi32(out_00, out_04);
- out8 = _mm_packs_epi32(out_08, out_12);
-
- // if (coeff > 2047) coeff = 2047
- out0 = _mm_min_epi16(out0, max_coeff_2047);
- out8 = _mm_min_epi16(out8, max_coeff_2047);
- }
-
- // put sign back
- out0 = _mm_sign_epi16(out0, in0);
- out8 = _mm_sign_epi16(out8, in8);
-
- // in = out * Q
- in0 = _mm_mullo_epi16(out0, q0);
- in8 = _mm_mullo_epi16(out8, q8);
-
- _mm_storeu_si128((__m128i*)&in[0], in0);
- _mm_storeu_si128((__m128i*)&in[8], in8);
-
- // zigzag the output before storing it. The re-ordering is:
- // 0 1 2 3 4 5 6 7 | 8 9 10 11 12 13 14 15
- // -> 0 1 4[8]5 2 3 6 | 9 12 13 10 [7]11 14 15
- // There's only two misplaced entries ([8] and [7]) that are crossing the
- // reg's boundaries.
- // We use pshufb instead of pshuflo/pshufhi.
- {
- const __m128i kCst_lo = PSHUFB_CST(0, 1, 4, -1, 5, 2, 3, 6);
- const __m128i kCst_7 = PSHUFB_CST(-1, -1, -1, -1, 7, -1, -1, -1);
- const __m128i tmp_lo = _mm_shuffle_epi8(out0, kCst_lo);
- const __m128i tmp_7 = _mm_shuffle_epi8(out0, kCst_7); // extract #7
- const __m128i kCst_hi = PSHUFB_CST(1, 4, 5, 2, -1, 3, 6, 7);
- const __m128i kCst_8 = PSHUFB_CST(-1, -1, -1, 0, -1, -1, -1, -1);
- const __m128i tmp_hi = _mm_shuffle_epi8(out8, kCst_hi);
- const __m128i tmp_8 = _mm_shuffle_epi8(out8, kCst_8); // extract #8
- const __m128i out_z0 = _mm_or_si128(tmp_lo, tmp_8);
- const __m128i out_z8 = _mm_or_si128(tmp_hi, tmp_7);
- _mm_storeu_si128((__m128i*)&out[0], out_z0);
- _mm_storeu_si128((__m128i*)&out[8], out_z8);
- packed_out = _mm_packs_epi16(out_z0, out_z8);
- }
-
- // detect if all 'out' values are zeroes or not
- return (_mm_movemask_epi8(_mm_cmpeq_epi8(packed_out, zero)) != 0xffff);
-}
-
-#undef PSHUFB_CST
-
-static int QuantizeBlock_SSE41(int16_t in[16], int16_t out[16],
- const VP8Matrix* const mtx) {
- return DoQuantizeBlock_SSE41(in, out, &mtx->sharpen_[0], mtx);
-}
-
-static int QuantizeBlockWHT_SSE41(int16_t in[16], int16_t out[16],
- const VP8Matrix* const mtx) {
- return DoQuantizeBlock_SSE41(in, out, NULL, mtx);
-}
-
-static int Quantize2Blocks_SSE41(int16_t in[32], int16_t out[32],
- const VP8Matrix* const mtx) {
- int nz;
- const uint16_t* const sharpen = &mtx->sharpen_[0];
- nz = DoQuantizeBlock_SSE41(in + 0 * 16, out + 0 * 16, sharpen, mtx) << 0;
- nz |= DoQuantizeBlock_SSE41(in + 1 * 16, out + 1 * 16, sharpen, mtx) << 1;
- return nz;
-}
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void VP8EncDspInitSSE41(void);
-WEBP_TSAN_IGNORE_FUNCTION void VP8EncDspInitSSE41(void) {
- VP8CollectHistogram = CollectHistogram_SSE41;
- VP8EncQuantizeBlock = QuantizeBlock_SSE41;
- VP8EncQuantize2Blocks = Quantize2Blocks_SSE41;
- VP8EncQuantizeBlockWHT = QuantizeBlockWHT_SSE41;
- VP8TDisto4x4 = Disto4x4_SSE41;
- VP8TDisto16x16 = Disto16x16_SSE41;
-}
-
-#else // !WEBP_USE_SSE41
-
-WEBP_DSP_INIT_STUB(VP8EncDspInitSSE41)
-
-#endif // WEBP_USE_SSE41
diff --git a/contrib/libs/libwebp/dsp/filters.c b/contrib/libs/libwebp/dsp/filters.c
deleted file mode 100644
index 0ff4af8197..0000000000
--- a/contrib/libs/libwebp/dsp/filters.c
+++ /dev/null
@@ -1,287 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Spatial prediction using various filters
-//
-// Author: Urvang (urvang@google.com)
-
-#include "./dsp.h"
-#include <assert.h>
-#include <stdlib.h>
-#include <string.h>
-
-//------------------------------------------------------------------------------
-// Helpful macro.
-
-# define SANITY_CHECK(in, out) \
- assert((in) != NULL); \
- assert((out) != NULL); \
- assert(width > 0); \
- assert(height > 0); \
- assert(stride >= width); \
- assert(row >= 0 && num_rows > 0 && row + num_rows <= height); \
- (void)height; // Silence unused warning.
-
-#if !WEBP_NEON_OMIT_C_CODE
-static WEBP_INLINE void PredictLine_C(const uint8_t* src, const uint8_t* pred,
- uint8_t* dst, int length, int inverse) {
- int i;
- if (inverse) {
- for (i = 0; i < length; ++i) dst[i] = (uint8_t)(src[i] + pred[i]);
- } else {
- for (i = 0; i < length; ++i) dst[i] = (uint8_t)(src[i] - pred[i]);
- }
-}
-
-//------------------------------------------------------------------------------
-// Horizontal filter.
-
-static WEBP_INLINE void DoHorizontalFilter_C(const uint8_t* in,
- int width, int height, int stride,
- int row, int num_rows,
- int inverse, uint8_t* out) {
- const uint8_t* preds;
- const size_t start_offset = row * stride;
- const int last_row = row + num_rows;
- SANITY_CHECK(in, out);
- in += start_offset;
- out += start_offset;
- preds = inverse ? out : in;
-
- if (row == 0) {
- // Leftmost pixel is the same as input for topmost scanline.
- out[0] = in[0];
- PredictLine_C(in + 1, preds, out + 1, width - 1, inverse);
- row = 1;
- preds += stride;
- in += stride;
- out += stride;
- }
-
- // Filter line-by-line.
- while (row < last_row) {
- // Leftmost pixel is predicted from above.
- PredictLine_C(in, preds - stride, out, 1, inverse);
- PredictLine_C(in + 1, preds, out + 1, width - 1, inverse);
- ++row;
- preds += stride;
- in += stride;
- out += stride;
- }
-}
-
-//------------------------------------------------------------------------------
-// Vertical filter.
-
-static WEBP_INLINE void DoVerticalFilter_C(const uint8_t* in,
- int width, int height, int stride,
- int row, int num_rows,
- int inverse, uint8_t* out) {
- const uint8_t* preds;
- const size_t start_offset = row * stride;
- const int last_row = row + num_rows;
- SANITY_CHECK(in, out);
- in += start_offset;
- out += start_offset;
- preds = inverse ? out : in;
-
- if (row == 0) {
- // Very first top-left pixel is copied.
- out[0] = in[0];
- // Rest of top scan-line is left-predicted.
- PredictLine_C(in + 1, preds, out + 1, width - 1, inverse);
- row = 1;
- in += stride;
- out += stride;
- } else {
- // We are starting from in-between. Make sure 'preds' points to prev row.
- preds -= stride;
- }
-
- // Filter line-by-line.
- while (row < last_row) {
- PredictLine_C(in, preds, out, width, inverse);
- ++row;
- preds += stride;
- in += stride;
- out += stride;
- }
-}
-#endif // !WEBP_NEON_OMIT_C_CODE
-
-//------------------------------------------------------------------------------
-// Gradient filter.
-
-static WEBP_INLINE int GradientPredictor_C(uint8_t a, uint8_t b, uint8_t c) {
- const int g = a + b - c;
- return ((g & ~0xff) == 0) ? g : (g < 0) ? 0 : 255; // clip to 8bit
-}
-
-#if !WEBP_NEON_OMIT_C_CODE
-static WEBP_INLINE void DoGradientFilter_C(const uint8_t* in,
- int width, int height, int stride,
- int row, int num_rows,
- int inverse, uint8_t* out) {
- const uint8_t* preds;
- const size_t start_offset = row * stride;
- const int last_row = row + num_rows;
- SANITY_CHECK(in, out);
- in += start_offset;
- out += start_offset;
- preds = inverse ? out : in;
-
- // left prediction for top scan-line
- if (row == 0) {
- out[0] = in[0];
- PredictLine_C(in + 1, preds, out + 1, width - 1, inverse);
- row = 1;
- preds += stride;
- in += stride;
- out += stride;
- }
-
- // Filter line-by-line.
- while (row < last_row) {
- int w;
- // leftmost pixel: predict from above.
- PredictLine_C(in, preds - stride, out, 1, inverse);
- for (w = 1; w < width; ++w) {
- const int pred = GradientPredictor_C(preds[w - 1],
- preds[w - stride],
- preds[w - stride - 1]);
- out[w] = (uint8_t)(in[w] + (inverse ? pred : -pred));
- }
- ++row;
- preds += stride;
- in += stride;
- out += stride;
- }
-}
-#endif // !WEBP_NEON_OMIT_C_CODE
-
-#undef SANITY_CHECK
-
-//------------------------------------------------------------------------------
-
-#if !WEBP_NEON_OMIT_C_CODE
-static void HorizontalFilter_C(const uint8_t* data, int width, int height,
- int stride, uint8_t* filtered_data) {
- DoHorizontalFilter_C(data, width, height, stride, 0, height, 0,
- filtered_data);
-}
-
-static void VerticalFilter_C(const uint8_t* data, int width, int height,
- int stride, uint8_t* filtered_data) {
- DoVerticalFilter_C(data, width, height, stride, 0, height, 0, filtered_data);
-}
-
-static void GradientFilter_C(const uint8_t* data, int width, int height,
- int stride, uint8_t* filtered_data) {
- DoGradientFilter_C(data, width, height, stride, 0, height, 0, filtered_data);
-}
-#endif // !WEBP_NEON_OMIT_C_CODE
-
-//------------------------------------------------------------------------------
-
-static void HorizontalUnfilter_C(const uint8_t* prev, const uint8_t* in,
- uint8_t* out, int width) {
- uint8_t pred = (prev == NULL) ? 0 : prev[0];
- int i;
- for (i = 0; i < width; ++i) {
- out[i] = (uint8_t)(pred + in[i]);
- pred = out[i];
- }
-}
-
-#if !WEBP_NEON_OMIT_C_CODE
-static void VerticalUnfilter_C(const uint8_t* prev, const uint8_t* in,
- uint8_t* out, int width) {
- if (prev == NULL) {
- HorizontalUnfilter_C(NULL, in, out, width);
- } else {
- int i;
- for (i = 0; i < width; ++i) out[i] = (uint8_t)(prev[i] + in[i]);
- }
-}
-#endif // !WEBP_NEON_OMIT_C_CODE
-
-static void GradientUnfilter_C(const uint8_t* prev, const uint8_t* in,
- uint8_t* out, int width) {
- if (prev == NULL) {
- HorizontalUnfilter_C(NULL, in, out, width);
- } else {
- uint8_t top = prev[0], top_left = top, left = top;
- int i;
- for (i = 0; i < width; ++i) {
- top = prev[i]; // need to read this first, in case prev==out
- left = (uint8_t)(in[i] + GradientPredictor_C(left, top, top_left));
- top_left = top;
- out[i] = left;
- }
- }
-}
-
-//------------------------------------------------------------------------------
-// Init function
-
-WebPFilterFunc WebPFilters[WEBP_FILTER_LAST];
-WebPUnfilterFunc WebPUnfilters[WEBP_FILTER_LAST];
-
-extern void VP8FiltersInitMIPSdspR2(void);
-extern void VP8FiltersInitMSA(void);
-extern void VP8FiltersInitNEON(void);
-extern void VP8FiltersInitSSE2(void);
-
-WEBP_DSP_INIT_FUNC(VP8FiltersInit) {
- WebPUnfilters[WEBP_FILTER_NONE] = NULL;
-#if !WEBP_NEON_OMIT_C_CODE
- WebPUnfilters[WEBP_FILTER_HORIZONTAL] = HorizontalUnfilter_C;
- WebPUnfilters[WEBP_FILTER_VERTICAL] = VerticalUnfilter_C;
-#endif
- WebPUnfilters[WEBP_FILTER_GRADIENT] = GradientUnfilter_C;
-
- WebPFilters[WEBP_FILTER_NONE] = NULL;
-#if !WEBP_NEON_OMIT_C_CODE
- WebPFilters[WEBP_FILTER_HORIZONTAL] = HorizontalFilter_C;
- WebPFilters[WEBP_FILTER_VERTICAL] = VerticalFilter_C;
- WebPFilters[WEBP_FILTER_GRADIENT] = GradientFilter_C;
-#endif
-
- if (VP8GetCPUInfo != NULL) {
-#if defined(WEBP_HAVE_SSE2)
- if (VP8GetCPUInfo(kSSE2)) {
- VP8FiltersInitSSE2();
- }
-#endif
-#if defined(WEBP_USE_MIPS_DSP_R2)
- if (VP8GetCPUInfo(kMIPSdspR2)) {
- VP8FiltersInitMIPSdspR2();
- }
-#endif
-#if defined(WEBP_USE_MSA)
- if (VP8GetCPUInfo(kMSA)) {
- VP8FiltersInitMSA();
- }
-#endif
- }
-
-#if defined(WEBP_HAVE_NEON)
- if (WEBP_NEON_OMIT_C_CODE ||
- (VP8GetCPUInfo != NULL && VP8GetCPUInfo(kNEON))) {
- VP8FiltersInitNEON();
- }
-#endif
-
- assert(WebPUnfilters[WEBP_FILTER_HORIZONTAL] != NULL);
- assert(WebPUnfilters[WEBP_FILTER_VERTICAL] != NULL);
- assert(WebPUnfilters[WEBP_FILTER_GRADIENT] != NULL);
- assert(WebPFilters[WEBP_FILTER_HORIZONTAL] != NULL);
- assert(WebPFilters[WEBP_FILTER_VERTICAL] != NULL);
- assert(WebPFilters[WEBP_FILTER_GRADIENT] != NULL);
-}
diff --git a/contrib/libs/libwebp/dsp/filters_mips_dsp_r2.c b/contrib/libs/libwebp/dsp/filters_mips_dsp_r2.c
deleted file mode 100644
index ee6614881f..0000000000
--- a/contrib/libs/libwebp/dsp/filters_mips_dsp_r2.c
+++ /dev/null
@@ -1,402 +0,0 @@
-// Copyright 2014 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Spatial prediction using various filters
-//
-// Author(s): Branimir Vasic (branimir.vasic@imgtec.com)
-// Djordje Pesut (djordje.pesut@imgtec.com)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_MIPS_DSP_R2)
-
-#include "./dsp.h"
-#include <assert.h>
-#include <stdlib.h>
-#include <string.h>
-
-//------------------------------------------------------------------------------
-// Helpful macro.
-
-# define SANITY_CHECK(in, out) \
- assert(in != NULL); \
- assert(out != NULL); \
- assert(width > 0); \
- assert(height > 0); \
- assert(stride >= width); \
- assert(row >= 0 && num_rows > 0 && row + num_rows <= height); \
- (void)height; // Silence unused warning.
-
-#define DO_PREDICT_LINE(SRC, DST, LENGTH, INVERSE) do { \
- const uint8_t* psrc = (uint8_t*)(SRC); \
- uint8_t* pdst = (uint8_t*)(DST); \
- const int ilength = (int)(LENGTH); \
- int temp0, temp1, temp2, temp3, temp4, temp5, temp6; \
- __asm__ volatile ( \
- ".set push \n\t" \
- ".set noreorder \n\t" \
- "srl %[temp0], %[length], 2 \n\t" \
- "beqz %[temp0], 4f \n\t" \
- " andi %[temp6], %[length], 3 \n\t" \
- ".if " #INVERSE " \n\t" \
- "1: \n\t" \
- "lbu %[temp1], -1(%[dst]) \n\t" \
- "lbu %[temp2], 0(%[src]) \n\t" \
- "lbu %[temp3], 1(%[src]) \n\t" \
- "lbu %[temp4], 2(%[src]) \n\t" \
- "lbu %[temp5], 3(%[src]) \n\t" \
- "addu %[temp1], %[temp1], %[temp2] \n\t" \
- "addu %[temp2], %[temp1], %[temp3] \n\t" \
- "addu %[temp3], %[temp2], %[temp4] \n\t" \
- "addu %[temp4], %[temp3], %[temp5] \n\t" \
- "sb %[temp1], 0(%[dst]) \n\t" \
- "sb %[temp2], 1(%[dst]) \n\t" \
- "sb %[temp3], 2(%[dst]) \n\t" \
- "sb %[temp4], 3(%[dst]) \n\t" \
- "addiu %[src], %[src], 4 \n\t" \
- "addiu %[temp0], %[temp0], -1 \n\t" \
- "bnez %[temp0], 1b \n\t" \
- " addiu %[dst], %[dst], 4 \n\t" \
- ".else \n\t" \
- "1: \n\t" \
- "ulw %[temp1], -1(%[src]) \n\t" \
- "ulw %[temp2], 0(%[src]) \n\t" \
- "addiu %[src], %[src], 4 \n\t" \
- "addiu %[temp0], %[temp0], -1 \n\t" \
- "subu.qb %[temp3], %[temp2], %[temp1] \n\t" \
- "usw %[temp3], 0(%[dst]) \n\t" \
- "bnez %[temp0], 1b \n\t" \
- " addiu %[dst], %[dst], 4 \n\t" \
- ".endif \n\t" \
- "4: \n\t" \
- "beqz %[temp6], 3f \n\t" \
- " nop \n\t" \
- "2: \n\t" \
- "lbu %[temp2], 0(%[src]) \n\t" \
- ".if " #INVERSE " \n\t" \
- "lbu %[temp1], -1(%[dst]) \n\t" \
- "addu %[temp3], %[temp1], %[temp2] \n\t" \
- ".else \n\t" \
- "lbu %[temp1], -1(%[src]) \n\t" \
- "subu %[temp3], %[temp1], %[temp2] \n\t" \
- ".endif \n\t" \
- "addiu %[src], %[src], 1 \n\t" \
- "sb %[temp3], 0(%[dst]) \n\t" \
- "addiu %[temp6], %[temp6], -1 \n\t" \
- "bnez %[temp6], 2b \n\t" \
- " addiu %[dst], %[dst], 1 \n\t" \
- "3: \n\t" \
- ".set pop \n\t" \
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2), \
- [temp3]"=&r"(temp3), [temp4]"=&r"(temp4), [temp5]"=&r"(temp5), \
- [temp6]"=&r"(temp6), [dst]"+&r"(pdst), [src]"+&r"(psrc) \
- : [length]"r"(ilength) \
- : "memory" \
- ); \
- } while (0)
-
-static WEBP_INLINE void PredictLine_MIPSdspR2(const uint8_t* src, uint8_t* dst,
- int length) {
- DO_PREDICT_LINE(src, dst, length, 0);
-}
-
-#define DO_PREDICT_LINE_VERTICAL(SRC, PRED, DST, LENGTH, INVERSE) do { \
- const uint8_t* psrc = (uint8_t*)(SRC); \
- const uint8_t* ppred = (uint8_t*)(PRED); \
- uint8_t* pdst = (uint8_t*)(DST); \
- const int ilength = (int)(LENGTH); \
- int temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7; \
- __asm__ volatile ( \
- ".set push \n\t" \
- ".set noreorder \n\t" \
- "srl %[temp0], %[length], 0x3 \n\t" \
- "beqz %[temp0], 4f \n\t" \
- " andi %[temp7], %[length], 0x7 \n\t" \
- "1: \n\t" \
- "ulw %[temp1], 0(%[src]) \n\t" \
- "ulw %[temp2], 0(%[pred]) \n\t" \
- "ulw %[temp3], 4(%[src]) \n\t" \
- "ulw %[temp4], 4(%[pred]) \n\t" \
- "addiu %[src], %[src], 8 \n\t" \
- ".if " #INVERSE " \n\t" \
- "addu.qb %[temp5], %[temp1], %[temp2] \n\t" \
- "addu.qb %[temp6], %[temp3], %[temp4] \n\t" \
- ".else \n\t" \
- "subu.qb %[temp5], %[temp1], %[temp2] \n\t" \
- "subu.qb %[temp6], %[temp3], %[temp4] \n\t" \
- ".endif \n\t" \
- "addiu %[pred], %[pred], 8 \n\t" \
- "usw %[temp5], 0(%[dst]) \n\t" \
- "usw %[temp6], 4(%[dst]) \n\t" \
- "addiu %[temp0], %[temp0], -1 \n\t" \
- "bnez %[temp0], 1b \n\t" \
- " addiu %[dst], %[dst], 8 \n\t" \
- "4: \n\t" \
- "beqz %[temp7], 3f \n\t" \
- " nop \n\t" \
- "2: \n\t" \
- "lbu %[temp1], 0(%[src]) \n\t" \
- "lbu %[temp2], 0(%[pred]) \n\t" \
- "addiu %[src], %[src], 1 \n\t" \
- "addiu %[pred], %[pred], 1 \n\t" \
- ".if " #INVERSE " \n\t" \
- "addu %[temp3], %[temp1], %[temp2] \n\t" \
- ".else \n\t" \
- "subu %[temp3], %[temp1], %[temp2] \n\t" \
- ".endif \n\t" \
- "sb %[temp3], 0(%[dst]) \n\t" \
- "addiu %[temp7], %[temp7], -1 \n\t" \
- "bnez %[temp7], 2b \n\t" \
- " addiu %[dst], %[dst], 1 \n\t" \
- "3: \n\t" \
- ".set pop \n\t" \
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2), \
- [temp3]"=&r"(temp3), [temp4]"=&r"(temp4), [temp5]"=&r"(temp5), \
- [temp6]"=&r"(temp6), [temp7]"=&r"(temp7), [pred]"+&r"(ppred), \
- [dst]"+&r"(pdst), [src]"+&r"(psrc) \
- : [length]"r"(ilength) \
- : "memory" \
- ); \
- } while (0)
-
-#define PREDICT_LINE_ONE_PASS(SRC, PRED, DST) do { \
- int temp1, temp2, temp3; \
- __asm__ volatile ( \
- "lbu %[temp1], 0(%[src]) \n\t" \
- "lbu %[temp2], 0(%[pred]) \n\t" \
- "subu %[temp3], %[temp1], %[temp2] \n\t" \
- "sb %[temp3], 0(%[dst]) \n\t" \
- : [temp1]"=&r"(temp1), [temp2]"=&r"(temp2), [temp3]"=&r"(temp3) \
- : [pred]"r"((PRED)), [dst]"r"((DST)), [src]"r"((SRC)) \
- : "memory" \
- ); \
- } while (0)
-
-//------------------------------------------------------------------------------
-// Horizontal filter.
-
-#define FILTER_LINE_BY_LINE do { \
- while (row < last_row) { \
- PREDICT_LINE_ONE_PASS(in, preds - stride, out); \
- DO_PREDICT_LINE(in + 1, out + 1, width - 1, 0); \
- ++row; \
- preds += stride; \
- in += stride; \
- out += stride; \
- } \
- } while (0)
-
-static WEBP_INLINE void DoHorizontalFilter_MIPSdspR2(const uint8_t* in,
- int width, int height,
- int stride,
- int row, int num_rows,
- uint8_t* out) {
- const uint8_t* preds;
- const size_t start_offset = row * stride;
- const int last_row = row + num_rows;
- SANITY_CHECK(in, out);
- in += start_offset;
- out += start_offset;
- preds = in;
-
- if (row == 0) {
- // Leftmost pixel is the same as input for topmost scanline.
- out[0] = in[0];
- PredictLine_MIPSdspR2(in + 1, out + 1, width - 1);
- row = 1;
- preds += stride;
- in += stride;
- out += stride;
- }
-
- // Filter line-by-line.
- FILTER_LINE_BY_LINE;
-}
-#undef FILTER_LINE_BY_LINE
-
-static void HorizontalFilter_MIPSdspR2(const uint8_t* data,
- int width, int height,
- int stride, uint8_t* filtered_data) {
- DoHorizontalFilter_MIPSdspR2(data, width, height, stride, 0, height,
- filtered_data);
-}
-
-//------------------------------------------------------------------------------
-// Vertical filter.
-
-#define FILTER_LINE_BY_LINE do { \
- while (row < last_row) { \
- DO_PREDICT_LINE_VERTICAL(in, preds, out, width, 0); \
- ++row; \
- preds += stride; \
- in += stride; \
- out += stride; \
- } \
- } while (0)
-
-static WEBP_INLINE void DoVerticalFilter_MIPSdspR2(const uint8_t* in,
- int width, int height,
- int stride,
- int row, int num_rows,
- uint8_t* out) {
- const uint8_t* preds;
- const size_t start_offset = row * stride;
- const int last_row = row + num_rows;
- SANITY_CHECK(in, out);
- in += start_offset;
- out += start_offset;
- preds = in;
-
- if (row == 0) {
- // Very first top-left pixel is copied.
- out[0] = in[0];
- // Rest of top scan-line is left-predicted.
- PredictLine_MIPSdspR2(in + 1, out + 1, width - 1);
- row = 1;
- in += stride;
- out += stride;
- } else {
- // We are starting from in-between. Make sure 'preds' points to prev row.
- preds -= stride;
- }
-
- // Filter line-by-line.
- FILTER_LINE_BY_LINE;
-}
-#undef FILTER_LINE_BY_LINE
-
-static void VerticalFilter_MIPSdspR2(const uint8_t* data, int width, int height,
- int stride, uint8_t* filtered_data) {
- DoVerticalFilter_MIPSdspR2(data, width, height, stride, 0, height,
- filtered_data);
-}
-
-//------------------------------------------------------------------------------
-// Gradient filter.
-
-static int GradientPredictor_MIPSdspR2(uint8_t a, uint8_t b, uint8_t c) {
- int temp0;
- __asm__ volatile (
- "addu %[temp0], %[a], %[b] \n\t"
- "subu %[temp0], %[temp0], %[c] \n\t"
- "shll_s.w %[temp0], %[temp0], 23 \n\t"
- "precrqu_s.qb.ph %[temp0], %[temp0], $zero \n\t"
- "srl %[temp0], %[temp0], 24 \n\t"
- : [temp0]"=&r"(temp0)
- : [a]"r"(a),[b]"r"(b),[c]"r"(c)
- );
- return temp0;
-}
-
-#define FILTER_LINE_BY_LINE(PREDS, OPERATION) do { \
- while (row < last_row) { \
- int w; \
- PREDICT_LINE_ONE_PASS(in, PREDS - stride, out); \
- for (w = 1; w < width; ++w) { \
- const int pred = GradientPredictor_MIPSdspR2(PREDS[w - 1], \
- PREDS[w - stride], \
- PREDS[w - stride - 1]); \
- out[w] = in[w] OPERATION pred; \
- } \
- ++row; \
- in += stride; \
- out += stride; \
- } \
- } while (0)
-
-static void DoGradientFilter_MIPSdspR2(const uint8_t* in,
- int width, int height, int stride,
- int row, int num_rows, uint8_t* out) {
- const uint8_t* preds;
- const size_t start_offset = row * stride;
- const int last_row = row + num_rows;
- SANITY_CHECK(in, out);
- in += start_offset;
- out += start_offset;
- preds = in;
-
- // left prediction for top scan-line
- if (row == 0) {
- out[0] = in[0];
- PredictLine_MIPSdspR2(in + 1, out + 1, width - 1);
- row = 1;
- preds += stride;
- in += stride;
- out += stride;
- }
-
- // Filter line-by-line.
- FILTER_LINE_BY_LINE(in, -);
-}
-#undef FILTER_LINE_BY_LINE
-
-static void GradientFilter_MIPSdspR2(const uint8_t* data, int width, int height,
- int stride, uint8_t* filtered_data) {
- DoGradientFilter_MIPSdspR2(data, width, height, stride, 0, height,
- filtered_data);
-}
-
-//------------------------------------------------------------------------------
-
-static void HorizontalUnfilter_MIPSdspR2(const uint8_t* prev, const uint8_t* in,
- uint8_t* out, int width) {
- out[0] = in[0] + (prev == NULL ? 0 : prev[0]);
- DO_PREDICT_LINE(in + 1, out + 1, width - 1, 1);
-}
-
-static void VerticalUnfilter_MIPSdspR2(const uint8_t* prev, const uint8_t* in,
- uint8_t* out, int width) {
- if (prev == NULL) {
- HorizontalUnfilter_MIPSdspR2(NULL, in, out, width);
- } else {
- DO_PREDICT_LINE_VERTICAL(in, prev, out, width, 1);
- }
-}
-
-static void GradientUnfilter_MIPSdspR2(const uint8_t* prev, const uint8_t* in,
- uint8_t* out, int width) {
- if (prev == NULL) {
- HorizontalUnfilter_MIPSdspR2(NULL, in, out, width);
- } else {
- uint8_t top = prev[0], top_left = top, left = top;
- int i;
- for (i = 0; i < width; ++i) {
- top = prev[i]; // need to read this first, in case prev==dst
- left = in[i] + GradientPredictor_MIPSdspR2(left, top, top_left);
- top_left = top;
- out[i] = left;
- }
- }
-}
-
-#undef DO_PREDICT_LINE_VERTICAL
-#undef PREDICT_LINE_ONE_PASS
-#undef DO_PREDICT_LINE
-#undef SANITY_CHECK
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void VP8FiltersInitMIPSdspR2(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void VP8FiltersInitMIPSdspR2(void) {
- WebPUnfilters[WEBP_FILTER_HORIZONTAL] = HorizontalUnfilter_MIPSdspR2;
- WebPUnfilters[WEBP_FILTER_VERTICAL] = VerticalUnfilter_MIPSdspR2;
- WebPUnfilters[WEBP_FILTER_GRADIENT] = GradientUnfilter_MIPSdspR2;
-
- WebPFilters[WEBP_FILTER_HORIZONTAL] = HorizontalFilter_MIPSdspR2;
- WebPFilters[WEBP_FILTER_VERTICAL] = VerticalFilter_MIPSdspR2;
- WebPFilters[WEBP_FILTER_GRADIENT] = GradientFilter_MIPSdspR2;
-}
-
-#else // !WEBP_USE_MIPS_DSP_R2
-
-WEBP_DSP_INIT_STUB(VP8FiltersInitMIPSdspR2)
-
-#endif // WEBP_USE_MIPS_DSP_R2
diff --git a/contrib/libs/libwebp/dsp/filters_msa.c b/contrib/libs/libwebp/dsp/filters_msa.c
deleted file mode 100644
index 50fb0a603d..0000000000
--- a/contrib/libs/libwebp/dsp/filters_msa.c
+++ /dev/null
@@ -1,202 +0,0 @@
-// Copyright 2016 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// MSA variant of alpha filters
-//
-// Author: Prashant Patil (prashant.patil@imgtec.com)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_MSA)
-
-#include "./msa_macro.h"
-
-#include <assert.h>
-
-static WEBP_INLINE void PredictLineInverse0(const uint8_t* src,
- const uint8_t* pred,
- uint8_t* dst, int length) {
- v16u8 src0, pred0, dst0;
- assert(length >= 0);
- while (length >= 32) {
- v16u8 src1, pred1, dst1;
- LD_UB2(src, 16, src0, src1);
- LD_UB2(pred, 16, pred0, pred1);
- SUB2(src0, pred0, src1, pred1, dst0, dst1);
- ST_UB2(dst0, dst1, dst, 16);
- src += 32;
- pred += 32;
- dst += 32;
- length -= 32;
- }
- if (length > 0) {
- int i;
- if (length >= 16) {
- src0 = LD_UB(src);
- pred0 = LD_UB(pred);
- dst0 = src0 - pred0;
- ST_UB(dst0, dst);
- src += 16;
- pred += 16;
- dst += 16;
- length -= 16;
- }
- for (i = 0; i < length; i++) {
- dst[i] = src[i] - pred[i];
- }
- }
-}
-
-//------------------------------------------------------------------------------
-// Helpful macro.
-
-#define SANITY_CHECK(in, out) \
- assert(in != NULL); \
- assert(out != NULL); \
- assert(width > 0); \
- assert(height > 0); \
- assert(stride >= width);
-
-//------------------------------------------------------------------------------
-// Horrizontal filter
-
-static void HorizontalFilter_MSA(const uint8_t* data, int width, int height,
- int stride, uint8_t* filtered_data) {
- const uint8_t* preds = data;
- const uint8_t* in = data;
- uint8_t* out = filtered_data;
- int row = 1;
- SANITY_CHECK(in, out);
-
- // Leftmost pixel is the same as input for topmost scanline.
- out[0] = in[0];
- PredictLineInverse0(in + 1, preds, out + 1, width - 1);
- preds += stride;
- in += stride;
- out += stride;
- // Filter line-by-line.
- while (row < height) {
- // Leftmost pixel is predicted from above.
- PredictLineInverse0(in, preds - stride, out, 1);
- PredictLineInverse0(in + 1, preds, out + 1, width - 1);
- ++row;
- preds += stride;
- in += stride;
- out += stride;
- }
-}
-
-//------------------------------------------------------------------------------
-// Gradient filter
-
-static WEBP_INLINE void PredictLineGradient(const uint8_t* pinput,
- const uint8_t* ppred,
- uint8_t* poutput, int stride,
- int size) {
- int w;
- const v16i8 zero = { 0 };
- while (size >= 16) {
- v16u8 pred0, dst0;
- v8i16 a0, a1, b0, b1, c0, c1;
- const v16u8 tmp0 = LD_UB(ppred - 1);
- const v16u8 tmp1 = LD_UB(ppred - stride);
- const v16u8 tmp2 = LD_UB(ppred - stride - 1);
- const v16u8 src0 = LD_UB(pinput);
- ILVRL_B2_SH(zero, tmp0, a0, a1);
- ILVRL_B2_SH(zero, tmp1, b0, b1);
- ILVRL_B2_SH(zero, tmp2, c0, c1);
- ADD2(a0, b0, a1, b1, a0, a1);
- SUB2(a0, c0, a1, c1, a0, a1);
- CLIP_SH2_0_255(a0, a1);
- pred0 = (v16u8)__msa_pckev_b((v16i8)a1, (v16i8)a0);
- dst0 = src0 - pred0;
- ST_UB(dst0, poutput);
- ppred += 16;
- pinput += 16;
- poutput += 16;
- size -= 16;
- }
- for (w = 0; w < size; ++w) {
- const int pred = ppred[w - 1] + ppred[w - stride] - ppred[w - stride - 1];
- poutput[w] = pinput[w] - (pred < 0 ? 0 : pred > 255 ? 255 : pred);
- }
-}
-
-
-static void GradientFilter_MSA(const uint8_t* data, int width, int height,
- int stride, uint8_t* filtered_data) {
- const uint8_t* in = data;
- const uint8_t* preds = data;
- uint8_t* out = filtered_data;
- int row = 1;
- SANITY_CHECK(in, out);
-
- // left prediction for top scan-line
- out[0] = in[0];
- PredictLineInverse0(in + 1, preds, out + 1, width - 1);
- preds += stride;
- in += stride;
- out += stride;
- // Filter line-by-line.
- while (row < height) {
- out[0] = in[0] - preds[- stride];
- PredictLineGradient(preds + 1, in + 1, out + 1, stride, width - 1);
- ++row;
- preds += stride;
- in += stride;
- out += stride;
- }
-}
-
-//------------------------------------------------------------------------------
-// Vertical filter
-
-static void VerticalFilter_MSA(const uint8_t* data, int width, int height,
- int stride, uint8_t* filtered_data) {
- const uint8_t* in = data;
- const uint8_t* preds = data;
- uint8_t* out = filtered_data;
- int row = 1;
- SANITY_CHECK(in, out);
-
- // Very first top-left pixel is copied.
- out[0] = in[0];
- // Rest of top scan-line is left-predicted.
- PredictLineInverse0(in + 1, preds, out + 1, width - 1);
- in += stride;
- out += stride;
-
- // Filter line-by-line.
- while (row < height) {
- PredictLineInverse0(in, preds, out, width);
- ++row;
- preds += stride;
- in += stride;
- out += stride;
- }
-}
-
-#undef SANITY_CHECK
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void VP8FiltersInitMSA(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void VP8FiltersInitMSA(void) {
- WebPFilters[WEBP_FILTER_HORIZONTAL] = HorizontalFilter_MSA;
- WebPFilters[WEBP_FILTER_VERTICAL] = VerticalFilter_MSA;
- WebPFilters[WEBP_FILTER_GRADIENT] = GradientFilter_MSA;
-}
-
-#else // !WEBP_USE_MSA
-
-WEBP_DSP_INIT_STUB(VP8FiltersInitMSA)
-
-#endif // WEBP_USE_MSA
diff --git a/contrib/libs/libwebp/dsp/filters_neon.c b/contrib/libs/libwebp/dsp/filters_neon.c
deleted file mode 100644
index ae5ce0fb92..0000000000
--- a/contrib/libs/libwebp/dsp/filters_neon.c
+++ /dev/null
@@ -1,329 +0,0 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// NEON variant of alpha filters
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_NEON)
-
-#include <assert.h>
-#include "./neon.h"
-
-//------------------------------------------------------------------------------
-// Helpful macros.
-
-# define SANITY_CHECK(in, out) \
- assert(in != NULL); \
- assert(out != NULL); \
- assert(width > 0); \
- assert(height > 0); \
- assert(stride >= width); \
- assert(row >= 0 && num_rows > 0 && row + num_rows <= height); \
- (void)height; // Silence unused warning.
-
-// load eight u8 and widen to s16
-#define U8_TO_S16(A) vreinterpretq_s16_u16(vmovl_u8(A))
-#define LOAD_U8_TO_S16(A) U8_TO_S16(vld1_u8(A))
-
-// shift left or right by N byte, inserting zeros
-#define SHIFT_RIGHT_N_Q(A, N) vextq_u8((A), zero, (N))
-#define SHIFT_LEFT_N_Q(A, N) vextq_u8(zero, (A), (16 - (N)) % 16)
-
-// rotate left by N bytes
-#define ROTATE_LEFT_N(A, N) vext_u8((A), (A), (N))
-// rotate right by N bytes
-#define ROTATE_RIGHT_N(A, N) vext_u8((A), (A), (8 - (N)) % 8)
-
-static void PredictLine_NEON(const uint8_t* src, const uint8_t* pred,
- uint8_t* dst, int length) {
- int i;
- assert(length >= 0);
- for (i = 0; i + 16 <= length; i += 16) {
- const uint8x16_t A = vld1q_u8(&src[i]);
- const uint8x16_t B = vld1q_u8(&pred[i]);
- const uint8x16_t C = vsubq_u8(A, B);
- vst1q_u8(&dst[i], C);
- }
- for (; i < length; ++i) dst[i] = src[i] - pred[i];
-}
-
-// Special case for left-based prediction (when preds==dst-1 or preds==src-1).
-static void PredictLineLeft_NEON(const uint8_t* src, uint8_t* dst, int length) {
- PredictLine_NEON(src, src - 1, dst, length);
-}
-
-//------------------------------------------------------------------------------
-// Horizontal filter.
-
-static WEBP_INLINE void DoHorizontalFilter_NEON(const uint8_t* in,
- int width, int height,
- int stride,
- int row, int num_rows,
- uint8_t* out) {
- const size_t start_offset = row * stride;
- const int last_row = row + num_rows;
- SANITY_CHECK(in, out);
- in += start_offset;
- out += start_offset;
-
- if (row == 0) {
- // Leftmost pixel is the same as input for topmost scanline.
- out[0] = in[0];
- PredictLineLeft_NEON(in + 1, out + 1, width - 1);
- row = 1;
- in += stride;
- out += stride;
- }
-
- // Filter line-by-line.
- while (row < last_row) {
- // Leftmost pixel is predicted from above.
- out[0] = in[0] - in[-stride];
- PredictLineLeft_NEON(in + 1, out + 1, width - 1);
- ++row;
- in += stride;
- out += stride;
- }
-}
-
-static void HorizontalFilter_NEON(const uint8_t* data, int width, int height,
- int stride, uint8_t* filtered_data) {
- DoHorizontalFilter_NEON(data, width, height, stride, 0, height,
- filtered_data);
-}
-
-//------------------------------------------------------------------------------
-// Vertical filter.
-
-static WEBP_INLINE void DoVerticalFilter_NEON(const uint8_t* in,
- int width, int height, int stride,
- int row, int num_rows,
- uint8_t* out) {
- const size_t start_offset = row * stride;
- const int last_row = row + num_rows;
- SANITY_CHECK(in, out);
- in += start_offset;
- out += start_offset;
-
- if (row == 0) {
- // Very first top-left pixel is copied.
- out[0] = in[0];
- // Rest of top scan-line is left-predicted.
- PredictLineLeft_NEON(in + 1, out + 1, width - 1);
- row = 1;
- in += stride;
- out += stride;
- }
-
- // Filter line-by-line.
- while (row < last_row) {
- PredictLine_NEON(in, in - stride, out, width);
- ++row;
- in += stride;
- out += stride;
- }
-}
-
-static void VerticalFilter_NEON(const uint8_t* data, int width, int height,
- int stride, uint8_t* filtered_data) {
- DoVerticalFilter_NEON(data, width, height, stride, 0, height,
- filtered_data);
-}
-
-//------------------------------------------------------------------------------
-// Gradient filter.
-
-static WEBP_INLINE int GradientPredictor_C(uint8_t a, uint8_t b, uint8_t c) {
- const int g = a + b - c;
- return ((g & ~0xff) == 0) ? g : (g < 0) ? 0 : 255; // clip to 8bit
-}
-
-static void GradientPredictDirect_NEON(const uint8_t* const row,
- const uint8_t* const top,
- uint8_t* const out, int length) {
- int i;
- for (i = 0; i + 8 <= length; i += 8) {
- const uint8x8_t A = vld1_u8(&row[i - 1]);
- const uint8x8_t B = vld1_u8(&top[i + 0]);
- const int16x8_t C = vreinterpretq_s16_u16(vaddl_u8(A, B));
- const int16x8_t D = LOAD_U8_TO_S16(&top[i - 1]);
- const uint8x8_t E = vqmovun_s16(vsubq_s16(C, D));
- const uint8x8_t F = vld1_u8(&row[i + 0]);
- vst1_u8(&out[i], vsub_u8(F, E));
- }
- for (; i < length; ++i) {
- out[i] = row[i] - GradientPredictor_C(row[i - 1], top[i], top[i - 1]);
- }
-}
-
-static WEBP_INLINE void DoGradientFilter_NEON(const uint8_t* in,
- int width, int height,
- int stride,
- int row, int num_rows,
- uint8_t* out) {
- const size_t start_offset = row * stride;
- const int last_row = row + num_rows;
- SANITY_CHECK(in, out);
- in += start_offset;
- out += start_offset;
-
- // left prediction for top scan-line
- if (row == 0) {
- out[0] = in[0];
- PredictLineLeft_NEON(in + 1, out + 1, width - 1);
- row = 1;
- in += stride;
- out += stride;
- }
-
- // Filter line-by-line.
- while (row < last_row) {
- out[0] = in[0] - in[-stride];
- GradientPredictDirect_NEON(in + 1, in + 1 - stride, out + 1, width - 1);
- ++row;
- in += stride;
- out += stride;
- }
-}
-
-static void GradientFilter_NEON(const uint8_t* data, int width, int height,
- int stride, uint8_t* filtered_data) {
- DoGradientFilter_NEON(data, width, height, stride, 0, height,
- filtered_data);
-}
-
-#undef SANITY_CHECK
-
-//------------------------------------------------------------------------------
-// Inverse transforms
-
-static void HorizontalUnfilter_NEON(const uint8_t* prev, const uint8_t* in,
- uint8_t* out, int width) {
- int i;
- const uint8x16_t zero = vdupq_n_u8(0);
- uint8x16_t last;
- out[0] = in[0] + (prev == NULL ? 0 : prev[0]);
- if (width <= 1) return;
- last = vsetq_lane_u8(out[0], zero, 0);
- for (i = 1; i + 16 <= width; i += 16) {
- const uint8x16_t A0 = vld1q_u8(&in[i]);
- const uint8x16_t A1 = vaddq_u8(A0, last);
- const uint8x16_t A2 = SHIFT_LEFT_N_Q(A1, 1);
- const uint8x16_t A3 = vaddq_u8(A1, A2);
- const uint8x16_t A4 = SHIFT_LEFT_N_Q(A3, 2);
- const uint8x16_t A5 = vaddq_u8(A3, A4);
- const uint8x16_t A6 = SHIFT_LEFT_N_Q(A5, 4);
- const uint8x16_t A7 = vaddq_u8(A5, A6);
- const uint8x16_t A8 = SHIFT_LEFT_N_Q(A7, 8);
- const uint8x16_t A9 = vaddq_u8(A7, A8);
- vst1q_u8(&out[i], A9);
- last = SHIFT_RIGHT_N_Q(A9, 15);
- }
- for (; i < width; ++i) out[i] = in[i] + out[i - 1];
-}
-
-static void VerticalUnfilter_NEON(const uint8_t* prev, const uint8_t* in,
- uint8_t* out, int width) {
- if (prev == NULL) {
- HorizontalUnfilter_NEON(NULL, in, out, width);
- } else {
- int i;
- assert(width >= 0);
- for (i = 0; i + 16 <= width; i += 16) {
- const uint8x16_t A = vld1q_u8(&in[i]);
- const uint8x16_t B = vld1q_u8(&prev[i]);
- const uint8x16_t C = vaddq_u8(A, B);
- vst1q_u8(&out[i], C);
- }
- for (; i < width; ++i) out[i] = in[i] + prev[i];
- }
-}
-
-// GradientUnfilter_NEON is correct but slower than the C-version,
-// at least on ARM64. For armv7, it's a wash.
-// So best is to disable it for now, but keep the idea around...
-#if !defined(USE_GRADIENT_UNFILTER)
-#define USE_GRADIENT_UNFILTER 0 // ALTERNATE_CODE
-#endif
-
-#if (USE_GRADIENT_UNFILTER == 1)
-#define GRAD_PROCESS_LANE(L) do { \
- const uint8x8_t tmp1 = ROTATE_RIGHT_N(pred, 1); /* rotate predictor in */ \
- const int16x8_t tmp2 = vaddq_s16(BC, U8_TO_S16(tmp1)); \
- const uint8x8_t delta = vqmovun_s16(tmp2); \
- pred = vadd_u8(D, delta); \
- out = vext_u8(out, ROTATE_LEFT_N(pred, (L)), 1); \
-} while (0)
-
-static void GradientPredictInverse_NEON(const uint8_t* const in,
- const uint8_t* const top,
- uint8_t* const row, int length) {
- if (length > 0) {
- int i;
- uint8x8_t pred = vdup_n_u8(row[-1]); // left sample
- uint8x8_t out = vdup_n_u8(0);
- for (i = 0; i + 8 <= length; i += 8) {
- const int16x8_t B = LOAD_U8_TO_S16(&top[i + 0]);
- const int16x8_t C = LOAD_U8_TO_S16(&top[i - 1]);
- const int16x8_t BC = vsubq_s16(B, C); // unclipped gradient basis B - C
- const uint8x8_t D = vld1_u8(&in[i]); // base input
- GRAD_PROCESS_LANE(0);
- GRAD_PROCESS_LANE(1);
- GRAD_PROCESS_LANE(2);
- GRAD_PROCESS_LANE(3);
- GRAD_PROCESS_LANE(4);
- GRAD_PROCESS_LANE(5);
- GRAD_PROCESS_LANE(6);
- GRAD_PROCESS_LANE(7);
- vst1_u8(&row[i], out);
- }
- for (; i < length; ++i) {
- row[i] = in[i] + GradientPredictor_C(row[i - 1], top[i], top[i - 1]);
- }
- }
-}
-#undef GRAD_PROCESS_LANE
-
-static void GradientUnfilter_NEON(const uint8_t* prev, const uint8_t* in,
- uint8_t* out, int width) {
- if (prev == NULL) {
- HorizontalUnfilter_NEON(NULL, in, out, width);
- } else {
- out[0] = in[0] + prev[0]; // predict from above
- GradientPredictInverse_NEON(in + 1, prev + 1, out + 1, width - 1);
- }
-}
-
-#endif // USE_GRADIENT_UNFILTER
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void VP8FiltersInitNEON(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void VP8FiltersInitNEON(void) {
- WebPUnfilters[WEBP_FILTER_HORIZONTAL] = HorizontalUnfilter_NEON;
- WebPUnfilters[WEBP_FILTER_VERTICAL] = VerticalUnfilter_NEON;
-#if (USE_GRADIENT_UNFILTER == 1)
- WebPUnfilters[WEBP_FILTER_GRADIENT] = GradientUnfilter_NEON;
-#endif
-
- WebPFilters[WEBP_FILTER_HORIZONTAL] = HorizontalFilter_NEON;
- WebPFilters[WEBP_FILTER_VERTICAL] = VerticalFilter_NEON;
- WebPFilters[WEBP_FILTER_GRADIENT] = GradientFilter_NEON;
-}
-
-#else // !WEBP_USE_NEON
-
-WEBP_DSP_INIT_STUB(VP8FiltersInitNEON)
-
-#endif // WEBP_USE_NEON
diff --git a/contrib/libs/libwebp/dsp/filters_sse2.c b/contrib/libs/libwebp/dsp/filters_sse2.c
deleted file mode 100644
index e879838612..0000000000
--- a/contrib/libs/libwebp/dsp/filters_sse2.c
+++ /dev/null
@@ -1,340 +0,0 @@
-// Copyright 2015 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// SSE2 variant of alpha filters
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_SSE2)
-
-#include <assert.h>
-#include <emmintrin.h>
-#include <stdlib.h>
-#include <string.h>
-
-//------------------------------------------------------------------------------
-// Helpful macro.
-
-# define SANITY_CHECK(in, out) \
- assert((in) != NULL); \
- assert((out) != NULL); \
- assert(width > 0); \
- assert(height > 0); \
- assert(stride >= width); \
- assert(row >= 0 && num_rows > 0 && row + num_rows <= height); \
- (void)height; // Silence unused warning.
-
-static void PredictLineTop_SSE2(const uint8_t* src, const uint8_t* pred,
- uint8_t* dst, int length) {
- int i;
- const int max_pos = length & ~31;
- assert(length >= 0);
- for (i = 0; i < max_pos; i += 32) {
- const __m128i A0 = _mm_loadu_si128((const __m128i*)&src[i + 0]);
- const __m128i A1 = _mm_loadu_si128((const __m128i*)&src[i + 16]);
- const __m128i B0 = _mm_loadu_si128((const __m128i*)&pred[i + 0]);
- const __m128i B1 = _mm_loadu_si128((const __m128i*)&pred[i + 16]);
- const __m128i C0 = _mm_sub_epi8(A0, B0);
- const __m128i C1 = _mm_sub_epi8(A1, B1);
- _mm_storeu_si128((__m128i*)&dst[i + 0], C0);
- _mm_storeu_si128((__m128i*)&dst[i + 16], C1);
- }
- for (; i < length; ++i) dst[i] = src[i] - pred[i];
-}
-
-// Special case for left-based prediction (when preds==dst-1 or preds==src-1).
-static void PredictLineLeft_SSE2(const uint8_t* src, uint8_t* dst, int length) {
- int i;
- const int max_pos = length & ~31;
- assert(length >= 0);
- for (i = 0; i < max_pos; i += 32) {
- const __m128i A0 = _mm_loadu_si128((const __m128i*)(src + i + 0 ));
- const __m128i B0 = _mm_loadu_si128((const __m128i*)(src + i + 0 - 1));
- const __m128i A1 = _mm_loadu_si128((const __m128i*)(src + i + 16 ));
- const __m128i B1 = _mm_loadu_si128((const __m128i*)(src + i + 16 - 1));
- const __m128i C0 = _mm_sub_epi8(A0, B0);
- const __m128i C1 = _mm_sub_epi8(A1, B1);
- _mm_storeu_si128((__m128i*)(dst + i + 0), C0);
- _mm_storeu_si128((__m128i*)(dst + i + 16), C1);
- }
- for (; i < length; ++i) dst[i] = src[i] - src[i - 1];
-}
-
-//------------------------------------------------------------------------------
-// Horizontal filter.
-
-static WEBP_INLINE void DoHorizontalFilter_SSE2(const uint8_t* in,
- int width, int height,
- int stride,
- int row, int num_rows,
- uint8_t* out) {
- const size_t start_offset = row * stride;
- const int last_row = row + num_rows;
- SANITY_CHECK(in, out);
- in += start_offset;
- out += start_offset;
-
- if (row == 0) {
- // Leftmost pixel is the same as input for topmost scanline.
- out[0] = in[0];
- PredictLineLeft_SSE2(in + 1, out + 1, width - 1);
- row = 1;
- in += stride;
- out += stride;
- }
-
- // Filter line-by-line.
- while (row < last_row) {
- // Leftmost pixel is predicted from above.
- out[0] = in[0] - in[-stride];
- PredictLineLeft_SSE2(in + 1, out + 1, width - 1);
- ++row;
- in += stride;
- out += stride;
- }
-}
-
-//------------------------------------------------------------------------------
-// Vertical filter.
-
-static WEBP_INLINE void DoVerticalFilter_SSE2(const uint8_t* in,
- int width, int height, int stride,
- int row, int num_rows,
- uint8_t* out) {
- const size_t start_offset = row * stride;
- const int last_row = row + num_rows;
- SANITY_CHECK(in, out);
- in += start_offset;
- out += start_offset;
-
- if (row == 0) {
- // Very first top-left pixel is copied.
- out[0] = in[0];
- // Rest of top scan-line is left-predicted.
- PredictLineLeft_SSE2(in + 1, out + 1, width - 1);
- row = 1;
- in += stride;
- out += stride;
- }
-
- // Filter line-by-line.
- while (row < last_row) {
- PredictLineTop_SSE2(in, in - stride, out, width);
- ++row;
- in += stride;
- out += stride;
- }
-}
-
-//------------------------------------------------------------------------------
-// Gradient filter.
-
-static WEBP_INLINE int GradientPredictor_SSE2(uint8_t a, uint8_t b, uint8_t c) {
- const int g = a + b - c;
- return ((g & ~0xff) == 0) ? g : (g < 0) ? 0 : 255; // clip to 8bit
-}
-
-static void GradientPredictDirect_SSE2(const uint8_t* const row,
- const uint8_t* const top,
- uint8_t* const out, int length) {
- const int max_pos = length & ~7;
- int i;
- const __m128i zero = _mm_setzero_si128();
- for (i = 0; i < max_pos; i += 8) {
- const __m128i A0 = _mm_loadl_epi64((const __m128i*)&row[i - 1]);
- const __m128i B0 = _mm_loadl_epi64((const __m128i*)&top[i]);
- const __m128i C0 = _mm_loadl_epi64((const __m128i*)&top[i - 1]);
- const __m128i D = _mm_loadl_epi64((const __m128i*)&row[i]);
- const __m128i A1 = _mm_unpacklo_epi8(A0, zero);
- const __m128i B1 = _mm_unpacklo_epi8(B0, zero);
- const __m128i C1 = _mm_unpacklo_epi8(C0, zero);
- const __m128i E = _mm_add_epi16(A1, B1);
- const __m128i F = _mm_sub_epi16(E, C1);
- const __m128i G = _mm_packus_epi16(F, zero);
- const __m128i H = _mm_sub_epi8(D, G);
- _mm_storel_epi64((__m128i*)(out + i), H);
- }
- for (; i < length; ++i) {
- const int delta = GradientPredictor_SSE2(row[i - 1], top[i], top[i - 1]);
- out[i] = (uint8_t)(row[i] - delta);
- }
-}
-
-static WEBP_INLINE void DoGradientFilter_SSE2(const uint8_t* in,
- int width, int height, int stride,
- int row, int num_rows,
- uint8_t* out) {
- const size_t start_offset = row * stride;
- const int last_row = row + num_rows;
- SANITY_CHECK(in, out);
- in += start_offset;
- out += start_offset;
-
- // left prediction for top scan-line
- if (row == 0) {
- out[0] = in[0];
- PredictLineLeft_SSE2(in + 1, out + 1, width - 1);
- row = 1;
- in += stride;
- out += stride;
- }
-
- // Filter line-by-line.
- while (row < last_row) {
- out[0] = (uint8_t)(in[0] - in[-stride]);
- GradientPredictDirect_SSE2(in + 1, in + 1 - stride, out + 1, width - 1);
- ++row;
- in += stride;
- out += stride;
- }
-}
-
-#undef SANITY_CHECK
-
-//------------------------------------------------------------------------------
-
-static void HorizontalFilter_SSE2(const uint8_t* data, int width, int height,
- int stride, uint8_t* filtered_data) {
- DoHorizontalFilter_SSE2(data, width, height, stride, 0, height,
- filtered_data);
-}
-
-static void VerticalFilter_SSE2(const uint8_t* data, int width, int height,
- int stride, uint8_t* filtered_data) {
- DoVerticalFilter_SSE2(data, width, height, stride, 0, height, filtered_data);
-}
-
-static void GradientFilter_SSE2(const uint8_t* data, int width, int height,
- int stride, uint8_t* filtered_data) {
- DoGradientFilter_SSE2(data, width, height, stride, 0, height, filtered_data);
-}
-
-//------------------------------------------------------------------------------
-// Inverse transforms
-
-static void HorizontalUnfilter_SSE2(const uint8_t* prev, const uint8_t* in,
- uint8_t* out, int width) {
- int i;
- __m128i last;
- out[0] = (uint8_t)(in[0] + (prev == NULL ? 0 : prev[0]));
- if (width <= 1) return;
- last = _mm_set_epi32(0, 0, 0, out[0]);
- for (i = 1; i + 8 <= width; i += 8) {
- const __m128i A0 = _mm_loadl_epi64((const __m128i*)(in + i));
- const __m128i A1 = _mm_add_epi8(A0, last);
- const __m128i A2 = _mm_slli_si128(A1, 1);
- const __m128i A3 = _mm_add_epi8(A1, A2);
- const __m128i A4 = _mm_slli_si128(A3, 2);
- const __m128i A5 = _mm_add_epi8(A3, A4);
- const __m128i A6 = _mm_slli_si128(A5, 4);
- const __m128i A7 = _mm_add_epi8(A5, A6);
- _mm_storel_epi64((__m128i*)(out + i), A7);
- last = _mm_srli_epi64(A7, 56);
- }
- for (; i < width; ++i) out[i] = (uint8_t)(in[i] + out[i - 1]);
-}
-
-static void VerticalUnfilter_SSE2(const uint8_t* prev, const uint8_t* in,
- uint8_t* out, int width) {
- if (prev == NULL) {
- HorizontalUnfilter_SSE2(NULL, in, out, width);
- } else {
- int i;
- const int max_pos = width & ~31;
- assert(width >= 0);
- for (i = 0; i < max_pos; i += 32) {
- const __m128i A0 = _mm_loadu_si128((const __m128i*)&in[i + 0]);
- const __m128i A1 = _mm_loadu_si128((const __m128i*)&in[i + 16]);
- const __m128i B0 = _mm_loadu_si128((const __m128i*)&prev[i + 0]);
- const __m128i B1 = _mm_loadu_si128((const __m128i*)&prev[i + 16]);
- const __m128i C0 = _mm_add_epi8(A0, B0);
- const __m128i C1 = _mm_add_epi8(A1, B1);
- _mm_storeu_si128((__m128i*)&out[i + 0], C0);
- _mm_storeu_si128((__m128i*)&out[i + 16], C1);
- }
- for (; i < width; ++i) out[i] = (uint8_t)(in[i] + prev[i]);
- }
-}
-
-static void GradientPredictInverse_SSE2(const uint8_t* const in,
- const uint8_t* const top,
- uint8_t* const row, int length) {
- if (length > 0) {
- int i;
- const int max_pos = length & ~7;
- const __m128i zero = _mm_setzero_si128();
- __m128i A = _mm_set_epi32(0, 0, 0, row[-1]); // left sample
- for (i = 0; i < max_pos; i += 8) {
- const __m128i tmp0 = _mm_loadl_epi64((const __m128i*)&top[i]);
- const __m128i tmp1 = _mm_loadl_epi64((const __m128i*)&top[i - 1]);
- const __m128i B = _mm_unpacklo_epi8(tmp0, zero);
- const __m128i C = _mm_unpacklo_epi8(tmp1, zero);
- const __m128i D = _mm_loadl_epi64((const __m128i*)&in[i]); // base input
- const __m128i E = _mm_sub_epi16(B, C); // unclipped gradient basis B - C
- __m128i out = zero; // accumulator for output
- __m128i mask_hi = _mm_set_epi32(0, 0, 0, 0xff);
- int k = 8;
- while (1) {
- const __m128i tmp3 = _mm_add_epi16(A, E); // delta = A + B - C
- const __m128i tmp4 = _mm_packus_epi16(tmp3, zero); // saturate delta
- const __m128i tmp5 = _mm_add_epi8(tmp4, D); // add to in[]
- A = _mm_and_si128(tmp5, mask_hi); // 1-complement clip
- out = _mm_or_si128(out, A); // accumulate output
- if (--k == 0) break;
- A = _mm_slli_si128(A, 1); // rotate left sample
- mask_hi = _mm_slli_si128(mask_hi, 1); // rotate mask
- A = _mm_unpacklo_epi8(A, zero); // convert 8b->16b
- }
- A = _mm_srli_si128(A, 7); // prepare left sample for next iteration
- _mm_storel_epi64((__m128i*)&row[i], out);
- }
- for (; i < length; ++i) {
- const int delta = GradientPredictor_SSE2(row[i - 1], top[i], top[i - 1]);
- row[i] = (uint8_t)(in[i] + delta);
- }
- }
-}
-
-static void GradientUnfilter_SSE2(const uint8_t* prev, const uint8_t* in,
- uint8_t* out, int width) {
- if (prev == NULL) {
- HorizontalUnfilter_SSE2(NULL, in, out, width);
- } else {
- out[0] = (uint8_t)(in[0] + prev[0]); // predict from above
- GradientPredictInverse_SSE2(in + 1, prev + 1, out + 1, width - 1);
- }
-}
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void VP8FiltersInitSSE2(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void VP8FiltersInitSSE2(void) {
- WebPUnfilters[WEBP_FILTER_HORIZONTAL] = HorizontalUnfilter_SSE2;
-#if defined(CHROMIUM)
- // TODO(crbug.com/654974)
- (void)VerticalUnfilter_SSE2;
-#else
- WebPUnfilters[WEBP_FILTER_VERTICAL] = VerticalUnfilter_SSE2;
-#endif
- WebPUnfilters[WEBP_FILTER_GRADIENT] = GradientUnfilter_SSE2;
-
- WebPFilters[WEBP_FILTER_HORIZONTAL] = HorizontalFilter_SSE2;
- WebPFilters[WEBP_FILTER_VERTICAL] = VerticalFilter_SSE2;
- WebPFilters[WEBP_FILTER_GRADIENT] = GradientFilter_SSE2;
-}
-
-#else // !WEBP_USE_SSE2
-
-WEBP_DSP_INIT_STUB(VP8FiltersInitSSE2)
-
-#endif // WEBP_USE_SSE2
diff --git a/contrib/libs/libwebp/dsp/lossless.c b/contrib/libs/libwebp/dsp/lossless.c
deleted file mode 100644
index 85434ffc7d..0000000000
--- a/contrib/libs/libwebp/dsp/lossless.c
+++ /dev/null
@@ -1,680 +0,0 @@
-// Copyright 2012 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Image transforms and color space conversion methods for lossless decoder.
-//
-// Authors: Vikas Arora (vikaas.arora@gmail.com)
-// Jyrki Alakuijala (jyrki@google.com)
-// Urvang Joshi (urvang@google.com)
-
-#include "./dsp.h"
-
-#include <assert.h>
-#include <math.h>
-#include <stdlib.h>
-#include "../dec/vp8li_dec.h"
-#include "../utils/endian_inl_utils.h"
-#include "./lossless.h"
-#include "./lossless_common.h"
-
-//------------------------------------------------------------------------------
-// Image transforms.
-
-static WEBP_INLINE uint32_t Average2(uint32_t a0, uint32_t a1) {
- return (((a0 ^ a1) & 0xfefefefeu) >> 1) + (a0 & a1);
-}
-
-static WEBP_INLINE uint32_t Average3(uint32_t a0, uint32_t a1, uint32_t a2) {
- return Average2(Average2(a0, a2), a1);
-}
-
-static WEBP_INLINE uint32_t Average4(uint32_t a0, uint32_t a1,
- uint32_t a2, uint32_t a3) {
- return Average2(Average2(a0, a1), Average2(a2, a3));
-}
-
-static WEBP_INLINE uint32_t Clip255(uint32_t a) {
- if (a < 256) {
- return a;
- }
- // return 0, when a is a negative integer.
- // return 255, when a is positive.
- return ~a >> 24;
-}
-
-static WEBP_INLINE int AddSubtractComponentFull(int a, int b, int c) {
- return Clip255(a + b - c);
-}
-
-static WEBP_INLINE uint32_t ClampedAddSubtractFull(uint32_t c0, uint32_t c1,
- uint32_t c2) {
- const int a = AddSubtractComponentFull(c0 >> 24, c1 >> 24, c2 >> 24);
- const int r = AddSubtractComponentFull((c0 >> 16) & 0xff,
- (c1 >> 16) & 0xff,
- (c2 >> 16) & 0xff);
- const int g = AddSubtractComponentFull((c0 >> 8) & 0xff,
- (c1 >> 8) & 0xff,
- (c2 >> 8) & 0xff);
- const int b = AddSubtractComponentFull(c0 & 0xff, c1 & 0xff, c2 & 0xff);
- return ((uint32_t)a << 24) | (r << 16) | (g << 8) | b;
-}
-
-static WEBP_INLINE int AddSubtractComponentHalf(int a, int b) {
- return Clip255(a + (a - b) / 2);
-}
-
-static WEBP_INLINE uint32_t ClampedAddSubtractHalf(uint32_t c0, uint32_t c1,
- uint32_t c2) {
- const uint32_t ave = Average2(c0, c1);
- const int a = AddSubtractComponentHalf(ave >> 24, c2 >> 24);
- const int r = AddSubtractComponentHalf((ave >> 16) & 0xff, (c2 >> 16) & 0xff);
- const int g = AddSubtractComponentHalf((ave >> 8) & 0xff, (c2 >> 8) & 0xff);
- const int b = AddSubtractComponentHalf((ave >> 0) & 0xff, (c2 >> 0) & 0xff);
- return ((uint32_t)a << 24) | (r << 16) | (g << 8) | b;
-}
-
-// gcc <= 4.9 on ARM generates incorrect code in Select() when Sub3() is
-// inlined.
-#if defined(__arm__) && defined(__GNUC__) && LOCAL_GCC_VERSION <= 0x409
-# define LOCAL_INLINE __attribute__ ((noinline))
-#else
-# define LOCAL_INLINE WEBP_INLINE
-#endif
-
-static LOCAL_INLINE int Sub3(int a, int b, int c) {
- const int pb = b - c;
- const int pa = a - c;
- return abs(pb) - abs(pa);
-}
-
-#undef LOCAL_INLINE
-
-static WEBP_INLINE uint32_t Select(uint32_t a, uint32_t b, uint32_t c) {
- const int pa_minus_pb =
- Sub3((a >> 24) , (b >> 24) , (c >> 24) ) +
- Sub3((a >> 16) & 0xff, (b >> 16) & 0xff, (c >> 16) & 0xff) +
- Sub3((a >> 8) & 0xff, (b >> 8) & 0xff, (c >> 8) & 0xff) +
- Sub3((a ) & 0xff, (b ) & 0xff, (c ) & 0xff);
- return (pa_minus_pb <= 0) ? a : b;
-}
-
-//------------------------------------------------------------------------------
-// Predictors
-
-uint32_t VP8LPredictor0_C(const uint32_t* const left,
- const uint32_t* const top) {
- (void)top;
- (void)left;
- return ARGB_BLACK;
-}
-uint32_t VP8LPredictor1_C(const uint32_t* const left,
- const uint32_t* const top) {
- (void)top;
- return *left;
-}
-uint32_t VP8LPredictor2_C(const uint32_t* const left,
- const uint32_t* const top) {
- (void)left;
- return top[0];
-}
-uint32_t VP8LPredictor3_C(const uint32_t* const left,
- const uint32_t* const top) {
- (void)left;
- return top[1];
-}
-uint32_t VP8LPredictor4_C(const uint32_t* const left,
- const uint32_t* const top) {
- (void)left;
- return top[-1];
-}
-uint32_t VP8LPredictor5_C(const uint32_t* const left,
- const uint32_t* const top) {
- const uint32_t pred = Average3(*left, top[0], top[1]);
- return pred;
-}
-uint32_t VP8LPredictor6_C(const uint32_t* const left,
- const uint32_t* const top) {
- const uint32_t pred = Average2(*left, top[-1]);
- return pred;
-}
-uint32_t VP8LPredictor7_C(const uint32_t* const left,
- const uint32_t* const top) {
- const uint32_t pred = Average2(*left, top[0]);
- return pred;
-}
-uint32_t VP8LPredictor8_C(const uint32_t* const left,
- const uint32_t* const top) {
- const uint32_t pred = Average2(top[-1], top[0]);
- (void)left;
- return pred;
-}
-uint32_t VP8LPredictor9_C(const uint32_t* const left,
- const uint32_t* const top) {
- const uint32_t pred = Average2(top[0], top[1]);
- (void)left;
- return pred;
-}
-uint32_t VP8LPredictor10_C(const uint32_t* const left,
- const uint32_t* const top) {
- const uint32_t pred = Average4(*left, top[-1], top[0], top[1]);
- return pred;
-}
-uint32_t VP8LPredictor11_C(const uint32_t* const left,
- const uint32_t* const top) {
- const uint32_t pred = Select(top[0], *left, top[-1]);
- return pred;
-}
-uint32_t VP8LPredictor12_C(const uint32_t* const left,
- const uint32_t* const top) {
- const uint32_t pred = ClampedAddSubtractFull(*left, top[0], top[-1]);
- return pred;
-}
-uint32_t VP8LPredictor13_C(const uint32_t* const left,
- const uint32_t* const top) {
- const uint32_t pred = ClampedAddSubtractHalf(*left, top[0], top[-1]);
- return pred;
-}
-
-static void PredictorAdd0_C(const uint32_t* in, const uint32_t* upper,
- int num_pixels, uint32_t* out) {
- int x;
- (void)upper;
- for (x = 0; x < num_pixels; ++x) out[x] = VP8LAddPixels(in[x], ARGB_BLACK);
-}
-static void PredictorAdd1_C(const uint32_t* in, const uint32_t* upper,
- int num_pixels, uint32_t* out) {
- int i;
- uint32_t left = out[-1];
- (void)upper;
- for (i = 0; i < num_pixels; ++i) {
- out[i] = left = VP8LAddPixels(in[i], left);
- }
-}
-GENERATE_PREDICTOR_ADD(VP8LPredictor2_C, PredictorAdd2_C)
-GENERATE_PREDICTOR_ADD(VP8LPredictor3_C, PredictorAdd3_C)
-GENERATE_PREDICTOR_ADD(VP8LPredictor4_C, PredictorAdd4_C)
-GENERATE_PREDICTOR_ADD(VP8LPredictor5_C, PredictorAdd5_C)
-GENERATE_PREDICTOR_ADD(VP8LPredictor6_C, PredictorAdd6_C)
-GENERATE_PREDICTOR_ADD(VP8LPredictor7_C, PredictorAdd7_C)
-GENERATE_PREDICTOR_ADD(VP8LPredictor8_C, PredictorAdd8_C)
-GENERATE_PREDICTOR_ADD(VP8LPredictor9_C, PredictorAdd9_C)
-GENERATE_PREDICTOR_ADD(VP8LPredictor10_C, PredictorAdd10_C)
-GENERATE_PREDICTOR_ADD(VP8LPredictor11_C, PredictorAdd11_C)
-GENERATE_PREDICTOR_ADD(VP8LPredictor12_C, PredictorAdd12_C)
-GENERATE_PREDICTOR_ADD(VP8LPredictor13_C, PredictorAdd13_C)
-
-//------------------------------------------------------------------------------
-
-// Inverse prediction.
-static void PredictorInverseTransform_C(const VP8LTransform* const transform,
- int y_start, int y_end,
- const uint32_t* in, uint32_t* out) {
- const int width = transform->xsize_;
- if (y_start == 0) { // First Row follows the L (mode=1) mode.
- PredictorAdd0_C(in, NULL, 1, out);
- PredictorAdd1_C(in + 1, NULL, width - 1, out + 1);
- in += width;
- out += width;
- ++y_start;
- }
-
- {
- int y = y_start;
- const int tile_width = 1 << transform->bits_;
- const int mask = tile_width - 1;
- const int tiles_per_row = VP8LSubSampleSize(width, transform->bits_);
- const uint32_t* pred_mode_base =
- transform->data_ + (y >> transform->bits_) * tiles_per_row;
-
- while (y < y_end) {
- const uint32_t* pred_mode_src = pred_mode_base;
- int x = 1;
- // First pixel follows the T (mode=2) mode.
- PredictorAdd2_C(in, out - width, 1, out);
- // .. the rest:
- while (x < width) {
- const VP8LPredictorAddSubFunc pred_func =
- VP8LPredictorsAdd[((*pred_mode_src++) >> 8) & 0xf];
- int x_end = (x & ~mask) + tile_width;
- if (x_end > width) x_end = width;
- pred_func(in + x, out + x - width, x_end - x, out + x);
- x = x_end;
- }
- in += width;
- out += width;
- ++y;
- if ((y & mask) == 0) { // Use the same mask, since tiles are squares.
- pred_mode_base += tiles_per_row;
- }
- }
- }
-}
-
-// Add green to blue and red channels (i.e. perform the inverse transform of
-// 'subtract green').
-void VP8LAddGreenToBlueAndRed_C(const uint32_t* src, int num_pixels,
- uint32_t* dst) {
- int i;
- for (i = 0; i < num_pixels; ++i) {
- const uint32_t argb = src[i];
- const uint32_t green = ((argb >> 8) & 0xff);
- uint32_t red_blue = (argb & 0x00ff00ffu);
- red_blue += (green << 16) | green;
- red_blue &= 0x00ff00ffu;
- dst[i] = (argb & 0xff00ff00u) | red_blue;
- }
-}
-
-static WEBP_INLINE int ColorTransformDelta(int8_t color_pred,
- int8_t color) {
- return ((int)color_pred * color) >> 5;
-}
-
-static WEBP_INLINE void ColorCodeToMultipliers(uint32_t color_code,
- VP8LMultipliers* const m) {
- m->green_to_red_ = (color_code >> 0) & 0xff;
- m->green_to_blue_ = (color_code >> 8) & 0xff;
- m->red_to_blue_ = (color_code >> 16) & 0xff;
-}
-
-void VP8LTransformColorInverse_C(const VP8LMultipliers* const m,
- const uint32_t* src, int num_pixels,
- uint32_t* dst) {
- int i;
- for (i = 0; i < num_pixels; ++i) {
- const uint32_t argb = src[i];
- const int8_t green = (int8_t)(argb >> 8);
- const uint32_t red = argb >> 16;
- int new_red = red & 0xff;
- int new_blue = argb & 0xff;
- new_red += ColorTransformDelta(m->green_to_red_, green);
- new_red &= 0xff;
- new_blue += ColorTransformDelta(m->green_to_blue_, green);
- new_blue += ColorTransformDelta(m->red_to_blue_, (int8_t)new_red);
- new_blue &= 0xff;
- dst[i] = (argb & 0xff00ff00u) | (new_red << 16) | (new_blue);
- }
-}
-
-// Color space inverse transform.
-static void ColorSpaceInverseTransform_C(const VP8LTransform* const transform,
- int y_start, int y_end,
- const uint32_t* src, uint32_t* dst) {
- const int width = transform->xsize_;
- const int tile_width = 1 << transform->bits_;
- const int mask = tile_width - 1;
- const int safe_width = width & ~mask;
- const int remaining_width = width - safe_width;
- const int tiles_per_row = VP8LSubSampleSize(width, transform->bits_);
- int y = y_start;
- const uint32_t* pred_row =
- transform->data_ + (y >> transform->bits_) * tiles_per_row;
-
- while (y < y_end) {
- const uint32_t* pred = pred_row;
- VP8LMultipliers m = { 0, 0, 0 };
- const uint32_t* const src_safe_end = src + safe_width;
- const uint32_t* const src_end = src + width;
- while (src < src_safe_end) {
- ColorCodeToMultipliers(*pred++, &m);
- VP8LTransformColorInverse(&m, src, tile_width, dst);
- src += tile_width;
- dst += tile_width;
- }
- if (src < src_end) { // Left-overs using C-version.
- ColorCodeToMultipliers(*pred++, &m);
- VP8LTransformColorInverse(&m, src, remaining_width, dst);
- src += remaining_width;
- dst += remaining_width;
- }
- ++y;
- if ((y & mask) == 0) pred_row += tiles_per_row;
- }
-}
-
-// Separate out pixels packed together using pixel-bundling.
-// We define two methods for ARGB data (uint32_t) and alpha-only data (uint8_t).
-#define COLOR_INDEX_INVERSE(FUNC_NAME, F_NAME, STATIC_DECL, TYPE, BIT_SUFFIX, \
- GET_INDEX, GET_VALUE) \
-static void F_NAME(const TYPE* src, const uint32_t* const color_map, \
- TYPE* dst, int y_start, int y_end, int width) { \
- int y; \
- for (y = y_start; y < y_end; ++y) { \
- int x; \
- for (x = 0; x < width; ++x) { \
- *dst++ = GET_VALUE(color_map[GET_INDEX(*src++)]); \
- } \
- } \
-} \
-STATIC_DECL void FUNC_NAME(const VP8LTransform* const transform, \
- int y_start, int y_end, const TYPE* src, \
- TYPE* dst) { \
- int y; \
- const int bits_per_pixel = 8 >> transform->bits_; \
- const int width = transform->xsize_; \
- const uint32_t* const color_map = transform->data_; \
- if (bits_per_pixel < 8) { \
- const int pixels_per_byte = 1 << transform->bits_; \
- const int count_mask = pixels_per_byte - 1; \
- const uint32_t bit_mask = (1 << bits_per_pixel) - 1; \
- for (y = y_start; y < y_end; ++y) { \
- uint32_t packed_pixels = 0; \
- int x; \
- for (x = 0; x < width; ++x) { \
- /* We need to load fresh 'packed_pixels' once every */ \
- /* 'pixels_per_byte' increments of x. Fortunately, pixels_per_byte */ \
- /* is a power of 2, so can just use a mask for that, instead of */ \
- /* decrementing a counter. */ \
- if ((x & count_mask) == 0) packed_pixels = GET_INDEX(*src++); \
- *dst++ = GET_VALUE(color_map[packed_pixels & bit_mask]); \
- packed_pixels >>= bits_per_pixel; \
- } \
- } \
- } else { \
- VP8LMapColor##BIT_SUFFIX(src, color_map, dst, y_start, y_end, width); \
- } \
-}
-
-COLOR_INDEX_INVERSE(ColorIndexInverseTransform_C, MapARGB_C, static,
- uint32_t, 32b, VP8GetARGBIndex, VP8GetARGBValue)
-COLOR_INDEX_INVERSE(VP8LColorIndexInverseTransformAlpha, MapAlpha_C, ,
- uint8_t, 8b, VP8GetAlphaIndex, VP8GetAlphaValue)
-
-#undef COLOR_INDEX_INVERSE
-
-void VP8LInverseTransform(const VP8LTransform* const transform,
- int row_start, int row_end,
- const uint32_t* const in, uint32_t* const out) {
- const int width = transform->xsize_;
- assert(row_start < row_end);
- assert(row_end <= transform->ysize_);
- switch (transform->type_) {
- case SUBTRACT_GREEN:
- VP8LAddGreenToBlueAndRed(in, (row_end - row_start) * width, out);
- break;
- case PREDICTOR_TRANSFORM:
- PredictorInverseTransform_C(transform, row_start, row_end, in, out);
- if (row_end != transform->ysize_) {
- // The last predicted row in this iteration will be the top-pred row
- // for the first row in next iteration.
- memcpy(out - width, out + (row_end - row_start - 1) * width,
- width * sizeof(*out));
- }
- break;
- case CROSS_COLOR_TRANSFORM:
- ColorSpaceInverseTransform_C(transform, row_start, row_end, in, out);
- break;
- case COLOR_INDEXING_TRANSFORM:
- if (in == out && transform->bits_ > 0) {
- // Move packed pixels to the end of unpacked region, so that unpacking
- // can occur seamlessly.
- // Also, note that this is the only transform that applies on
- // the effective width of VP8LSubSampleSize(xsize_, bits_). All other
- // transforms work on effective width of xsize_.
- const int out_stride = (row_end - row_start) * width;
- const int in_stride = (row_end - row_start) *
- VP8LSubSampleSize(transform->xsize_, transform->bits_);
- uint32_t* const src = out + out_stride - in_stride;
- memmove(src, out, in_stride * sizeof(*src));
- ColorIndexInverseTransform_C(transform, row_start, row_end, src, out);
- } else {
- ColorIndexInverseTransform_C(transform, row_start, row_end, in, out);
- }
- break;
- }
-}
-
-//------------------------------------------------------------------------------
-// Color space conversion.
-
-static int is_big_endian(void) {
- static const union {
- uint16_t w;
- uint8_t b[2];
- } tmp = { 1 };
- return (tmp.b[0] != 1);
-}
-
-void VP8LConvertBGRAToRGB_C(const uint32_t* src,
- int num_pixels, uint8_t* dst) {
- const uint32_t* const src_end = src + num_pixels;
- while (src < src_end) {
- const uint32_t argb = *src++;
- *dst++ = (argb >> 16) & 0xff;
- *dst++ = (argb >> 8) & 0xff;
- *dst++ = (argb >> 0) & 0xff;
- }
-}
-
-void VP8LConvertBGRAToRGBA_C(const uint32_t* src,
- int num_pixels, uint8_t* dst) {
- const uint32_t* const src_end = src + num_pixels;
- while (src < src_end) {
- const uint32_t argb = *src++;
- *dst++ = (argb >> 16) & 0xff;
- *dst++ = (argb >> 8) & 0xff;
- *dst++ = (argb >> 0) & 0xff;
- *dst++ = (argb >> 24) & 0xff;
- }
-}
-
-void VP8LConvertBGRAToRGBA4444_C(const uint32_t* src,
- int num_pixels, uint8_t* dst) {
- const uint32_t* const src_end = src + num_pixels;
- while (src < src_end) {
- const uint32_t argb = *src++;
- const uint8_t rg = ((argb >> 16) & 0xf0) | ((argb >> 12) & 0xf);
- const uint8_t ba = ((argb >> 0) & 0xf0) | ((argb >> 28) & 0xf);
-#if (WEBP_SWAP_16BIT_CSP == 1)
- *dst++ = ba;
- *dst++ = rg;
-#else
- *dst++ = rg;
- *dst++ = ba;
-#endif
- }
-}
-
-void VP8LConvertBGRAToRGB565_C(const uint32_t* src,
- int num_pixels, uint8_t* dst) {
- const uint32_t* const src_end = src + num_pixels;
- while (src < src_end) {
- const uint32_t argb = *src++;
- const uint8_t rg = ((argb >> 16) & 0xf8) | ((argb >> 13) & 0x7);
- const uint8_t gb = ((argb >> 5) & 0xe0) | ((argb >> 3) & 0x1f);
-#if (WEBP_SWAP_16BIT_CSP == 1)
- *dst++ = gb;
- *dst++ = rg;
-#else
- *dst++ = rg;
- *dst++ = gb;
-#endif
- }
-}
-
-void VP8LConvertBGRAToBGR_C(const uint32_t* src,
- int num_pixels, uint8_t* dst) {
- const uint32_t* const src_end = src + num_pixels;
- while (src < src_end) {
- const uint32_t argb = *src++;
- *dst++ = (argb >> 0) & 0xff;
- *dst++ = (argb >> 8) & 0xff;
- *dst++ = (argb >> 16) & 0xff;
- }
-}
-
-static void CopyOrSwap(const uint32_t* src, int num_pixels, uint8_t* dst,
- int swap_on_big_endian) {
- if (is_big_endian() == swap_on_big_endian) {
- const uint32_t* const src_end = src + num_pixels;
- while (src < src_end) {
- const uint32_t argb = *src++;
- WebPUint32ToMem(dst, BSwap32(argb));
- dst += sizeof(argb);
- }
- } else {
- memcpy(dst, src, num_pixels * sizeof(*src));
- }
-}
-
-void VP8LConvertFromBGRA(const uint32_t* const in_data, int num_pixels,
- WEBP_CSP_MODE out_colorspace, uint8_t* const rgba) {
- switch (out_colorspace) {
- case MODE_RGB:
- VP8LConvertBGRAToRGB(in_data, num_pixels, rgba);
- break;
- case MODE_RGBA:
- VP8LConvertBGRAToRGBA(in_data, num_pixels, rgba);
- break;
- case MODE_rgbA:
- VP8LConvertBGRAToRGBA(in_data, num_pixels, rgba);
- WebPApplyAlphaMultiply(rgba, 0, num_pixels, 1, 0);
- break;
- case MODE_BGR:
- VP8LConvertBGRAToBGR(in_data, num_pixels, rgba);
- break;
- case MODE_BGRA:
- CopyOrSwap(in_data, num_pixels, rgba, 1);
- break;
- case MODE_bgrA:
- CopyOrSwap(in_data, num_pixels, rgba, 1);
- WebPApplyAlphaMultiply(rgba, 0, num_pixels, 1, 0);
- break;
- case MODE_ARGB:
- CopyOrSwap(in_data, num_pixels, rgba, 0);
- break;
- case MODE_Argb:
- CopyOrSwap(in_data, num_pixels, rgba, 0);
- WebPApplyAlphaMultiply(rgba, 1, num_pixels, 1, 0);
- break;
- case MODE_RGBA_4444:
- VP8LConvertBGRAToRGBA4444(in_data, num_pixels, rgba);
- break;
- case MODE_rgbA_4444:
- VP8LConvertBGRAToRGBA4444(in_data, num_pixels, rgba);
- WebPApplyAlphaMultiply4444(rgba, num_pixels, 1, 0);
- break;
- case MODE_RGB_565:
- VP8LConvertBGRAToRGB565(in_data, num_pixels, rgba);
- break;
- default:
- assert(0); // Code flow should not reach here.
- }
-}
-
-//------------------------------------------------------------------------------
-
-VP8LProcessDecBlueAndRedFunc VP8LAddGreenToBlueAndRed;
-VP8LPredictorAddSubFunc VP8LPredictorsAdd[16];
-VP8LPredictorFunc VP8LPredictors[16];
-
-// exposed plain-C implementations
-VP8LPredictorAddSubFunc VP8LPredictorsAdd_C[16];
-
-VP8LTransformColorInverseFunc VP8LTransformColorInverse;
-
-VP8LConvertFunc VP8LConvertBGRAToRGB;
-VP8LConvertFunc VP8LConvertBGRAToRGBA;
-VP8LConvertFunc VP8LConvertBGRAToRGBA4444;
-VP8LConvertFunc VP8LConvertBGRAToRGB565;
-VP8LConvertFunc VP8LConvertBGRAToBGR;
-
-VP8LMapARGBFunc VP8LMapColor32b;
-VP8LMapAlphaFunc VP8LMapColor8b;
-
-extern void VP8LDspInitSSE2(void);
-extern void VP8LDspInitSSE41(void);
-extern void VP8LDspInitNEON(void);
-extern void VP8LDspInitMIPSdspR2(void);
-extern void VP8LDspInitMSA(void);
-
-#define COPY_PREDICTOR_ARRAY(IN, OUT) do { \
- (OUT)[0] = IN##0_C; \
- (OUT)[1] = IN##1_C; \
- (OUT)[2] = IN##2_C; \
- (OUT)[3] = IN##3_C; \
- (OUT)[4] = IN##4_C; \
- (OUT)[5] = IN##5_C; \
- (OUT)[6] = IN##6_C; \
- (OUT)[7] = IN##7_C; \
- (OUT)[8] = IN##8_C; \
- (OUT)[9] = IN##9_C; \
- (OUT)[10] = IN##10_C; \
- (OUT)[11] = IN##11_C; \
- (OUT)[12] = IN##12_C; \
- (OUT)[13] = IN##13_C; \
- (OUT)[14] = IN##0_C; /* <- padding security sentinels*/ \
- (OUT)[15] = IN##0_C; \
-} while (0);
-
-WEBP_DSP_INIT_FUNC(VP8LDspInit) {
- COPY_PREDICTOR_ARRAY(VP8LPredictor, VP8LPredictors)
- COPY_PREDICTOR_ARRAY(PredictorAdd, VP8LPredictorsAdd)
- COPY_PREDICTOR_ARRAY(PredictorAdd, VP8LPredictorsAdd_C)
-
-#if !WEBP_NEON_OMIT_C_CODE
- VP8LAddGreenToBlueAndRed = VP8LAddGreenToBlueAndRed_C;
-
- VP8LTransformColorInverse = VP8LTransformColorInverse_C;
-
- VP8LConvertBGRAToRGBA = VP8LConvertBGRAToRGBA_C;
- VP8LConvertBGRAToRGB = VP8LConvertBGRAToRGB_C;
- VP8LConvertBGRAToBGR = VP8LConvertBGRAToBGR_C;
-#endif
-
- VP8LConvertBGRAToRGBA4444 = VP8LConvertBGRAToRGBA4444_C;
- VP8LConvertBGRAToRGB565 = VP8LConvertBGRAToRGB565_C;
-
- VP8LMapColor32b = MapARGB_C;
- VP8LMapColor8b = MapAlpha_C;
-
- // If defined, use CPUInfo() to overwrite some pointers with faster versions.
- if (VP8GetCPUInfo != NULL) {
-#if defined(WEBP_HAVE_SSE2)
- if (VP8GetCPUInfo(kSSE2)) {
- VP8LDspInitSSE2();
-#if defined(WEBP_HAVE_SSE41)
- if (VP8GetCPUInfo(kSSE4_1)) {
- VP8LDspInitSSE41();
- }
-#endif
- }
-#endif
-#if defined(WEBP_USE_MIPS_DSP_R2)
- if (VP8GetCPUInfo(kMIPSdspR2)) {
- VP8LDspInitMIPSdspR2();
- }
-#endif
-#if defined(WEBP_USE_MSA)
- if (VP8GetCPUInfo(kMSA)) {
- VP8LDspInitMSA();
- }
-#endif
- }
-
-#if defined(WEBP_HAVE_NEON)
- if (WEBP_NEON_OMIT_C_CODE ||
- (VP8GetCPUInfo != NULL && VP8GetCPUInfo(kNEON))) {
- VP8LDspInitNEON();
- }
-#endif
-
- assert(VP8LAddGreenToBlueAndRed != NULL);
- assert(VP8LTransformColorInverse != NULL);
- assert(VP8LConvertBGRAToRGBA != NULL);
- assert(VP8LConvertBGRAToRGB != NULL);
- assert(VP8LConvertBGRAToBGR != NULL);
- assert(VP8LConvertBGRAToRGBA4444 != NULL);
- assert(VP8LConvertBGRAToRGB565 != NULL);
- assert(VP8LMapColor32b != NULL);
- assert(VP8LMapColor8b != NULL);
-}
-#undef COPY_PREDICTOR_ARRAY
-
-//------------------------------------------------------------------------------
diff --git a/contrib/libs/libwebp/dsp/lossless.h b/contrib/libs/libwebp/dsp/lossless.h
deleted file mode 100644
index 0c129d2860..0000000000
--- a/contrib/libs/libwebp/dsp/lossless.h
+++ /dev/null
@@ -1,259 +0,0 @@
-// Copyright 2012 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Image transforms and color space conversion methods for lossless decoder.
-//
-// Authors: Vikas Arora (vikaas.arora@gmail.com)
-// Jyrki Alakuijala (jyrki@google.com)
-
-#ifndef WEBP_DSP_LOSSLESS_H_
-#define WEBP_DSP_LOSSLESS_H_
-
-#include "../webp/types.h"
-#include "../webp/decode.h"
-
-#include "../enc/histogram_enc.h"
-#include "../utils/utils.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-//------------------------------------------------------------------------------
-// Decoding
-
-typedef uint32_t (*VP8LPredictorFunc)(const uint32_t* const left,
- const uint32_t* const top);
-extern VP8LPredictorFunc VP8LPredictors[16];
-
-uint32_t VP8LPredictor0_C(const uint32_t* const left,
- const uint32_t* const top);
-uint32_t VP8LPredictor1_C(const uint32_t* const left,
- const uint32_t* const top);
-uint32_t VP8LPredictor2_C(const uint32_t* const left,
- const uint32_t* const top);
-uint32_t VP8LPredictor3_C(const uint32_t* const left,
- const uint32_t* const top);
-uint32_t VP8LPredictor4_C(const uint32_t* const left,
- const uint32_t* const top);
-uint32_t VP8LPredictor5_C(const uint32_t* const left,
- const uint32_t* const top);
-uint32_t VP8LPredictor6_C(const uint32_t* const left,
- const uint32_t* const top);
-uint32_t VP8LPredictor7_C(const uint32_t* const left,
- const uint32_t* const top);
-uint32_t VP8LPredictor8_C(const uint32_t* const left,
- const uint32_t* const top);
-uint32_t VP8LPredictor9_C(const uint32_t* const left,
- const uint32_t* const top);
-uint32_t VP8LPredictor10_C(const uint32_t* const left,
- const uint32_t* const top);
-uint32_t VP8LPredictor11_C(const uint32_t* const left,
- const uint32_t* const top);
-uint32_t VP8LPredictor12_C(const uint32_t* const left,
- const uint32_t* const top);
-uint32_t VP8LPredictor13_C(const uint32_t* const left,
- const uint32_t* const top);
-
-// These Add/Sub function expects upper[-1] and out[-1] to be readable.
-typedef void (*VP8LPredictorAddSubFunc)(const uint32_t* in,
- const uint32_t* upper, int num_pixels,
- uint32_t* out);
-extern VP8LPredictorAddSubFunc VP8LPredictorsAdd[16];
-extern VP8LPredictorAddSubFunc VP8LPredictorsAdd_C[16];
-
-typedef void (*VP8LProcessDecBlueAndRedFunc)(const uint32_t* src,
- int num_pixels, uint32_t* dst);
-extern VP8LProcessDecBlueAndRedFunc VP8LAddGreenToBlueAndRed;
-
-typedef struct {
- // Note: the members are uint8_t, so that any negative values are
- // automatically converted to "mod 256" values.
- uint8_t green_to_red_;
- uint8_t green_to_blue_;
- uint8_t red_to_blue_;
-} VP8LMultipliers;
-typedef void (*VP8LTransformColorInverseFunc)(const VP8LMultipliers* const m,
- const uint32_t* src,
- int num_pixels, uint32_t* dst);
-extern VP8LTransformColorInverseFunc VP8LTransformColorInverse;
-
-struct VP8LTransform; // Defined in dec/vp8li.h.
-
-// Performs inverse transform of data given transform information, start and end
-// rows. Transform will be applied to rows [row_start, row_end[.
-// The *in and *out pointers refer to source and destination data respectively
-// corresponding to the intermediate row (row_start).
-void VP8LInverseTransform(const struct VP8LTransform* const transform,
- int row_start, int row_end,
- const uint32_t* const in, uint32_t* const out);
-
-// Color space conversion.
-typedef void (*VP8LConvertFunc)(const uint32_t* src, int num_pixels,
- uint8_t* dst);
-extern VP8LConvertFunc VP8LConvertBGRAToRGB;
-extern VP8LConvertFunc VP8LConvertBGRAToRGBA;
-extern VP8LConvertFunc VP8LConvertBGRAToRGBA4444;
-extern VP8LConvertFunc VP8LConvertBGRAToRGB565;
-extern VP8LConvertFunc VP8LConvertBGRAToBGR;
-
-// Converts from BGRA to other color spaces.
-void VP8LConvertFromBGRA(const uint32_t* const in_data, int num_pixels,
- WEBP_CSP_MODE out_colorspace, uint8_t* const rgba);
-
-typedef void (*VP8LMapARGBFunc)(const uint32_t* src,
- const uint32_t* const color_map,
- uint32_t* dst, int y_start,
- int y_end, int width);
-typedef void (*VP8LMapAlphaFunc)(const uint8_t* src,
- const uint32_t* const color_map,
- uint8_t* dst, int y_start,
- int y_end, int width);
-
-extern VP8LMapARGBFunc VP8LMapColor32b;
-extern VP8LMapAlphaFunc VP8LMapColor8b;
-
-// Similar to the static method ColorIndexInverseTransform() that is part of
-// lossless.c, but used only for alpha decoding. It takes uint8_t (rather than
-// uint32_t) arguments for 'src' and 'dst'.
-void VP8LColorIndexInverseTransformAlpha(
- const struct VP8LTransform* const transform, int y_start, int y_end,
- const uint8_t* src, uint8_t* dst);
-
-// Expose some C-only fallback functions
-void VP8LTransformColorInverse_C(const VP8LMultipliers* const m,
- const uint32_t* src, int num_pixels,
- uint32_t* dst);
-
-void VP8LConvertBGRAToRGB_C(const uint32_t* src, int num_pixels, uint8_t* dst);
-void VP8LConvertBGRAToRGBA_C(const uint32_t* src, int num_pixels, uint8_t* dst);
-void VP8LConvertBGRAToRGBA4444_C(const uint32_t* src,
- int num_pixels, uint8_t* dst);
-void VP8LConvertBGRAToRGB565_C(const uint32_t* src,
- int num_pixels, uint8_t* dst);
-void VP8LConvertBGRAToBGR_C(const uint32_t* src, int num_pixels, uint8_t* dst);
-void VP8LAddGreenToBlueAndRed_C(const uint32_t* src, int num_pixels,
- uint32_t* dst);
-
-// Must be called before calling any of the above methods.
-void VP8LDspInit(void);
-
-//------------------------------------------------------------------------------
-// Encoding
-
-typedef void (*VP8LProcessEncBlueAndRedFunc)(uint32_t* dst, int num_pixels);
-extern VP8LProcessEncBlueAndRedFunc VP8LSubtractGreenFromBlueAndRed;
-typedef void (*VP8LTransformColorFunc)(const VP8LMultipliers* const m,
- uint32_t* dst, int num_pixels);
-extern VP8LTransformColorFunc VP8LTransformColor;
-typedef void (*VP8LCollectColorBlueTransformsFunc)(
- const uint32_t* argb, int stride,
- int tile_width, int tile_height,
- int green_to_blue, int red_to_blue, int histo[]);
-extern VP8LCollectColorBlueTransformsFunc VP8LCollectColorBlueTransforms;
-
-typedef void (*VP8LCollectColorRedTransformsFunc)(
- const uint32_t* argb, int stride,
- int tile_width, int tile_height,
- int green_to_red, int histo[]);
-extern VP8LCollectColorRedTransformsFunc VP8LCollectColorRedTransforms;
-
-// Expose some C-only fallback functions
-void VP8LTransformColor_C(const VP8LMultipliers* const m,
- uint32_t* data, int num_pixels);
-void VP8LSubtractGreenFromBlueAndRed_C(uint32_t* argb_data, int num_pixels);
-void VP8LCollectColorRedTransforms_C(const uint32_t* argb, int stride,
- int tile_width, int tile_height,
- int green_to_red, int histo[]);
-void VP8LCollectColorBlueTransforms_C(const uint32_t* argb, int stride,
- int tile_width, int tile_height,
- int green_to_blue, int red_to_blue,
- int histo[]);
-
-extern VP8LPredictorAddSubFunc VP8LPredictorsSub[16];
-extern VP8LPredictorAddSubFunc VP8LPredictorsSub_C[16];
-
-// -----------------------------------------------------------------------------
-// Huffman-cost related functions.
-
-typedef double (*VP8LCostFunc)(const uint32_t* population, int length);
-typedef double (*VP8LCostCombinedFunc)(const uint32_t* X, const uint32_t* Y,
- int length);
-typedef float (*VP8LCombinedShannonEntropyFunc)(const int X[256],
- const int Y[256]);
-
-extern VP8LCostFunc VP8LExtraCost;
-extern VP8LCostCombinedFunc VP8LExtraCostCombined;
-extern VP8LCombinedShannonEntropyFunc VP8LCombinedShannonEntropy;
-
-typedef struct { // small struct to hold counters
- int counts[2]; // index: 0=zero streak, 1=non-zero streak
- int streaks[2][2]; // [zero/non-zero][streak<3 / streak>=3]
-} VP8LStreaks;
-
-typedef struct { // small struct to hold bit entropy results
- double entropy; // entropy
- uint32_t sum; // sum of the population
- int nonzeros; // number of non-zero elements in the population
- uint32_t max_val; // maximum value in the population
- uint32_t nonzero_code; // index of the last non-zero in the population
-} VP8LBitEntropy;
-
-void VP8LBitEntropyInit(VP8LBitEntropy* const entropy);
-
-// Get the combined symbol bit entropy and Huffman cost stats for the
-// distributions 'X' and 'Y'. Those results can then be refined according to
-// codec specific heuristics.
-typedef void (*VP8LGetCombinedEntropyUnrefinedFunc)(
- const uint32_t X[], const uint32_t Y[], int length,
- VP8LBitEntropy* const bit_entropy, VP8LStreaks* const stats);
-extern VP8LGetCombinedEntropyUnrefinedFunc VP8LGetCombinedEntropyUnrefined;
-
-// Get the entropy for the distribution 'X'.
-typedef void (*VP8LGetEntropyUnrefinedFunc)(const uint32_t X[], int length,
- VP8LBitEntropy* const bit_entropy,
- VP8LStreaks* const stats);
-extern VP8LGetEntropyUnrefinedFunc VP8LGetEntropyUnrefined;
-
-void VP8LBitsEntropyUnrefined(const uint32_t* const array, int n,
- VP8LBitEntropy* const entropy);
-
-typedef void (*VP8LAddVectorFunc)(const uint32_t* a, const uint32_t* b,
- uint32_t* out, int size);
-extern VP8LAddVectorFunc VP8LAddVector;
-typedef void (*VP8LAddVectorEqFunc)(const uint32_t* a, uint32_t* out, int size);
-extern VP8LAddVectorEqFunc VP8LAddVectorEq;
-void VP8LHistogramAdd(const VP8LHistogram* const a,
- const VP8LHistogram* const b,
- VP8LHistogram* const out);
-
-// -----------------------------------------------------------------------------
-// PrefixEncode()
-
-typedef int (*VP8LVectorMismatchFunc)(const uint32_t* const array1,
- const uint32_t* const array2, int length);
-// Returns the first index where array1 and array2 are different.
-extern VP8LVectorMismatchFunc VP8LVectorMismatch;
-
-typedef void (*VP8LBundleColorMapFunc)(const uint8_t* const row, int width,
- int xbits, uint32_t* dst);
-extern VP8LBundleColorMapFunc VP8LBundleColorMap;
-void VP8LBundleColorMap_C(const uint8_t* const row, int width, int xbits,
- uint32_t* dst);
-
-// Must be called before calling any of the above methods.
-void VP8LEncDspInit(void);
-
-//------------------------------------------------------------------------------
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // WEBP_DSP_LOSSLESS_H_
diff --git a/contrib/libs/libwebp/dsp/lossless_common.h b/contrib/libs/libwebp/dsp/lossless_common.h
deleted file mode 100644
index 2b20637a28..0000000000
--- a/contrib/libs/libwebp/dsp/lossless_common.h
+++ /dev/null
@@ -1,191 +0,0 @@
-// Copyright 2012 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Image transforms and color space conversion methods for lossless decoder.
-//
-// Authors: Vikas Arora (vikaas.arora@gmail.com)
-// Jyrki Alakuijala (jyrki@google.com)
-// Vincent Rabaud (vrabaud@google.com)
-
-#ifndef WEBP_DSP_LOSSLESS_COMMON_H_
-#define WEBP_DSP_LOSSLESS_COMMON_H_
-
-#include "../webp/types.h"
-
-#include "../utils/utils.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-//------------------------------------------------------------------------------
-// Decoding
-
-// color mapping related functions.
-static WEBP_INLINE uint32_t VP8GetARGBIndex(uint32_t idx) {
- return (idx >> 8) & 0xff;
-}
-
-static WEBP_INLINE uint8_t VP8GetAlphaIndex(uint8_t idx) {
- return idx;
-}
-
-static WEBP_INLINE uint32_t VP8GetARGBValue(uint32_t val) {
- return val;
-}
-
-static WEBP_INLINE uint8_t VP8GetAlphaValue(uint32_t val) {
- return (val >> 8) & 0xff;
-}
-
-//------------------------------------------------------------------------------
-// Misc methods.
-
-// Computes sampled size of 'size' when sampling using 'sampling bits'.
-static WEBP_INLINE uint32_t VP8LSubSampleSize(uint32_t size,
- uint32_t sampling_bits) {
- return (size + (1 << sampling_bits) - 1) >> sampling_bits;
-}
-
-// Converts near lossless quality into max number of bits shaved off.
-static WEBP_INLINE int VP8LNearLosslessBits(int near_lossless_quality) {
- // 100 -> 0
- // 80..99 -> 1
- // 60..79 -> 2
- // 40..59 -> 3
- // 20..39 -> 4
- // 0..19 -> 5
- return 5 - near_lossless_quality / 20;
-}
-
-// -----------------------------------------------------------------------------
-// Faster logarithm for integers. Small values use a look-up table.
-
-// The threshold till approximate version of log_2 can be used.
-// Practically, we can get rid of the call to log() as the two values match to
-// very high degree (the ratio of these two is 0.99999x).
-// Keeping a high threshold for now.
-#define APPROX_LOG_WITH_CORRECTION_MAX 65536
-#define APPROX_LOG_MAX 4096
-#define LOG_2_RECIPROCAL 1.44269504088896338700465094007086
-#define LOG_LOOKUP_IDX_MAX 256
-extern const float kLog2Table[LOG_LOOKUP_IDX_MAX];
-extern const float kSLog2Table[LOG_LOOKUP_IDX_MAX];
-typedef float (*VP8LFastLog2SlowFunc)(uint32_t v);
-
-extern VP8LFastLog2SlowFunc VP8LFastLog2Slow;
-extern VP8LFastLog2SlowFunc VP8LFastSLog2Slow;
-
-static WEBP_INLINE float VP8LFastLog2(uint32_t v) {
- return (v < LOG_LOOKUP_IDX_MAX) ? kLog2Table[v] : VP8LFastLog2Slow(v);
-}
-// Fast calculation of v * log2(v) for integer input.
-static WEBP_INLINE float VP8LFastSLog2(uint32_t v) {
- return (v < LOG_LOOKUP_IDX_MAX) ? kSLog2Table[v] : VP8LFastSLog2Slow(v);
-}
-
-// -----------------------------------------------------------------------------
-// PrefixEncode()
-
-// Splitting of distance and length codes into prefixes and
-// extra bits. The prefixes are encoded with an entropy code
-// while the extra bits are stored just as normal bits.
-static WEBP_INLINE void VP8LPrefixEncodeBitsNoLUT(int distance, int* const code,
- int* const extra_bits) {
- const int highest_bit = BitsLog2Floor(--distance);
- const int second_highest_bit = (distance >> (highest_bit - 1)) & 1;
- *extra_bits = highest_bit - 1;
- *code = 2 * highest_bit + second_highest_bit;
-}
-
-static WEBP_INLINE void VP8LPrefixEncodeNoLUT(int distance, int* const code,
- int* const extra_bits,
- int* const extra_bits_value) {
- const int highest_bit = BitsLog2Floor(--distance);
- const int second_highest_bit = (distance >> (highest_bit - 1)) & 1;
- *extra_bits = highest_bit - 1;
- *extra_bits_value = distance & ((1 << *extra_bits) - 1);
- *code = 2 * highest_bit + second_highest_bit;
-}
-
-#define PREFIX_LOOKUP_IDX_MAX 512
-typedef struct {
- int8_t code_;
- int8_t extra_bits_;
-} VP8LPrefixCode;
-
-// These tables are derived using VP8LPrefixEncodeNoLUT.
-extern const VP8LPrefixCode kPrefixEncodeCode[PREFIX_LOOKUP_IDX_MAX];
-extern const uint8_t kPrefixEncodeExtraBitsValue[PREFIX_LOOKUP_IDX_MAX];
-static WEBP_INLINE void VP8LPrefixEncodeBits(int distance, int* const code,
- int* const extra_bits) {
- if (distance < PREFIX_LOOKUP_IDX_MAX) {
- const VP8LPrefixCode prefix_code = kPrefixEncodeCode[distance];
- *code = prefix_code.code_;
- *extra_bits = prefix_code.extra_bits_;
- } else {
- VP8LPrefixEncodeBitsNoLUT(distance, code, extra_bits);
- }
-}
-
-static WEBP_INLINE void VP8LPrefixEncode(int distance, int* const code,
- int* const extra_bits,
- int* const extra_bits_value) {
- if (distance < PREFIX_LOOKUP_IDX_MAX) {
- const VP8LPrefixCode prefix_code = kPrefixEncodeCode[distance];
- *code = prefix_code.code_;
- *extra_bits = prefix_code.extra_bits_;
- *extra_bits_value = kPrefixEncodeExtraBitsValue[distance];
- } else {
- VP8LPrefixEncodeNoLUT(distance, code, extra_bits, extra_bits_value);
- }
-}
-
-// Sum of each component, mod 256.
-static WEBP_UBSAN_IGNORE_UNSIGNED_OVERFLOW WEBP_INLINE
-uint32_t VP8LAddPixels(uint32_t a, uint32_t b) {
- const uint32_t alpha_and_green = (a & 0xff00ff00u) + (b & 0xff00ff00u);
- const uint32_t red_and_blue = (a & 0x00ff00ffu) + (b & 0x00ff00ffu);
- return (alpha_and_green & 0xff00ff00u) | (red_and_blue & 0x00ff00ffu);
-}
-
-// Difference of each component, mod 256.
-static WEBP_UBSAN_IGNORE_UNSIGNED_OVERFLOW WEBP_INLINE
-uint32_t VP8LSubPixels(uint32_t a, uint32_t b) {
- const uint32_t alpha_and_green =
- 0x00ff00ffu + (a & 0xff00ff00u) - (b & 0xff00ff00u);
- const uint32_t red_and_blue =
- 0xff00ff00u + (a & 0x00ff00ffu) - (b & 0x00ff00ffu);
- return (alpha_and_green & 0xff00ff00u) | (red_and_blue & 0x00ff00ffu);
-}
-
-//------------------------------------------------------------------------------
-// Transform-related functions use din both encoding and decoding.
-
-// Macros used to create a batch predictor that iteratively uses a
-// one-pixel predictor.
-
-// The predictor is added to the output pixel (which
-// is therefore considered as a residual) to get the final prediction.
-#define GENERATE_PREDICTOR_ADD(PREDICTOR, PREDICTOR_ADD) \
-static void PREDICTOR_ADD(const uint32_t* in, const uint32_t* upper, \
- int num_pixels, uint32_t* out) { \
- int x; \
- assert(upper != NULL); \
- for (x = 0; x < num_pixels; ++x) { \
- const uint32_t pred = (PREDICTOR)(&out[x - 1], upper + x); \
- out[x] = VP8LAddPixels(in[x], pred); \
- } \
-}
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // WEBP_DSP_LOSSLESS_COMMON_H_
diff --git a/contrib/libs/libwebp/dsp/lossless_enc.c b/contrib/libs/libwebp/dsp/lossless_enc.c
deleted file mode 100644
index 60a404076c..0000000000
--- a/contrib/libs/libwebp/dsp/lossless_enc.c
+++ /dev/null
@@ -1,948 +0,0 @@
-// Copyright 2015 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Image transform methods for lossless encoder.
-//
-// Authors: Vikas Arora (vikaas.arora@gmail.com)
-// Jyrki Alakuijala (jyrki@google.com)
-// Urvang Joshi (urvang@google.com)
-
-#include "./dsp.h"
-
-#include <assert.h>
-#include <math.h>
-#include <stdlib.h>
-#include "../dec/vp8li_dec.h"
-#include "../utils/endian_inl_utils.h"
-#include "./lossless.h"
-#include "./lossless_common.h"
-#include "./yuv.h"
-
-// lookup table for small values of log2(int)
-const float kLog2Table[LOG_LOOKUP_IDX_MAX] = {
- 0.0000000000000000f, 0.0000000000000000f,
- 1.0000000000000000f, 1.5849625007211560f,
- 2.0000000000000000f, 2.3219280948873621f,
- 2.5849625007211560f, 2.8073549220576041f,
- 3.0000000000000000f, 3.1699250014423121f,
- 3.3219280948873621f, 3.4594316186372973f,
- 3.5849625007211560f, 3.7004397181410921f,
- 3.8073549220576041f, 3.9068905956085187f,
- 4.0000000000000000f, 4.0874628412503390f,
- 4.1699250014423121f, 4.2479275134435852f,
- 4.3219280948873626f, 4.3923174227787606f,
- 4.4594316186372973f, 4.5235619560570130f,
- 4.5849625007211560f, 4.6438561897747243f,
- 4.7004397181410917f, 4.7548875021634682f,
- 4.8073549220576037f, 4.8579809951275718f,
- 4.9068905956085187f, 4.9541963103868749f,
- 5.0000000000000000f, 5.0443941193584533f,
- 5.0874628412503390f, 5.1292830169449663f,
- 5.1699250014423121f, 5.2094533656289501f,
- 5.2479275134435852f, 5.2854022188622487f,
- 5.3219280948873626f, 5.3575520046180837f,
- 5.3923174227787606f, 5.4262647547020979f,
- 5.4594316186372973f, 5.4918530963296747f,
- 5.5235619560570130f, 5.5545888516776376f,
- 5.5849625007211560f, 5.6147098441152083f,
- 5.6438561897747243f, 5.6724253419714951f,
- 5.7004397181410917f, 5.7279204545631987f,
- 5.7548875021634682f, 5.7813597135246599f,
- 5.8073549220576037f, 5.8328900141647412f,
- 5.8579809951275718f, 5.8826430493618415f,
- 5.9068905956085187f, 5.9307373375628866f,
- 5.9541963103868749f, 5.9772799234999167f,
- 6.0000000000000000f, 6.0223678130284543f,
- 6.0443941193584533f, 6.0660891904577720f,
- 6.0874628412503390f, 6.1085244567781691f,
- 6.1292830169449663f, 6.1497471195046822f,
- 6.1699250014423121f, 6.1898245588800175f,
- 6.2094533656289501f, 6.2288186904958804f,
- 6.2479275134435852f, 6.2667865406949010f,
- 6.2854022188622487f, 6.3037807481771030f,
- 6.3219280948873626f, 6.3398500028846243f,
- 6.3575520046180837f, 6.3750394313469245f,
- 6.3923174227787606f, 6.4093909361377017f,
- 6.4262647547020979f, 6.4429434958487279f,
- 6.4594316186372973f, 6.4757334309663976f,
- 6.4918530963296747f, 6.5077946401986963f,
- 6.5235619560570130f, 6.5391588111080309f,
- 6.5545888516776376f, 6.5698556083309478f,
- 6.5849625007211560f, 6.5999128421871278f,
- 6.6147098441152083f, 6.6293566200796094f,
- 6.6438561897747243f, 6.6582114827517946f,
- 6.6724253419714951f, 6.6865005271832185f,
- 6.7004397181410917f, 6.7142455176661224f,
- 6.7279204545631987f, 6.7414669864011464f,
- 6.7548875021634682f, 6.7681843247769259f,
- 6.7813597135246599f, 6.7944158663501061f,
- 6.8073549220576037f, 6.8201789624151878f,
- 6.8328900141647412f, 6.8454900509443747f,
- 6.8579809951275718f, 6.8703647195834047f,
- 6.8826430493618415f, 6.8948177633079437f,
- 6.9068905956085187f, 6.9188632372745946f,
- 6.9307373375628866f, 6.9425145053392398f,
- 6.9541963103868749f, 6.9657842846620869f,
- 6.9772799234999167f, 6.9886846867721654f,
- 7.0000000000000000f, 7.0112272554232539f,
- 7.0223678130284543f, 7.0334230015374501f,
- 7.0443941193584533f, 7.0552824355011898f,
- 7.0660891904577720f, 7.0768155970508308f,
- 7.0874628412503390f, 7.0980320829605263f,
- 7.1085244567781691f, 7.1189410727235076f,
- 7.1292830169449663f, 7.1395513523987936f,
- 7.1497471195046822f, 7.1598713367783890f,
- 7.1699250014423121f, 7.1799090900149344f,
- 7.1898245588800175f, 7.1996723448363644f,
- 7.2094533656289501f, 7.2191685204621611f,
- 7.2288186904958804f, 7.2384047393250785f,
- 7.2479275134435852f, 7.2573878426926521f,
- 7.2667865406949010f, 7.2761244052742375f,
- 7.2854022188622487f, 7.2946207488916270f,
- 7.3037807481771030f, 7.3128829552843557f,
- 7.3219280948873626f, 7.3309168781146167f,
- 7.3398500028846243f, 7.3487281542310771f,
- 7.3575520046180837f, 7.3663222142458160f,
- 7.3750394313469245f, 7.3837042924740519f,
- 7.3923174227787606f, 7.4008794362821843f,
- 7.4093909361377017f, 7.4178525148858982f,
- 7.4262647547020979f, 7.4346282276367245f,
- 7.4429434958487279f, 7.4512111118323289f,
- 7.4594316186372973f, 7.4676055500829976f,
- 7.4757334309663976f, 7.4838157772642563f,
- 7.4918530963296747f, 7.4998458870832056f,
- 7.5077946401986963f, 7.5156998382840427f,
- 7.5235619560570130f, 7.5313814605163118f,
- 7.5391588111080309f, 7.5468944598876364f,
- 7.5545888516776376f, 7.5622424242210728f,
- 7.5698556083309478f, 7.5774288280357486f,
- 7.5849625007211560f, 7.5924570372680806f,
- 7.5999128421871278f, 7.6073303137496104f,
- 7.6147098441152083f, 7.6220518194563764f,
- 7.6293566200796094f, 7.6366246205436487f,
- 7.6438561897747243f, 7.6510516911789281f,
- 7.6582114827517946f, 7.6653359171851764f,
- 7.6724253419714951f, 7.6794800995054464f,
- 7.6865005271832185f, 7.6934869574993252f,
- 7.7004397181410917f, 7.7073591320808825f,
- 7.7142455176661224f, 7.7210991887071855f,
- 7.7279204545631987f, 7.7347096202258383f,
- 7.7414669864011464f, 7.7481928495894605f,
- 7.7548875021634682f, 7.7615512324444795f,
- 7.7681843247769259f, 7.7747870596011736f,
- 7.7813597135246599f, 7.7879025593914317f,
- 7.7944158663501061f, 7.8008998999203047f,
- 7.8073549220576037f, 7.8137811912170374f,
- 7.8201789624151878f, 7.8265484872909150f,
- 7.8328900141647412f, 7.8392037880969436f,
- 7.8454900509443747f, 7.8517490414160571f,
- 7.8579809951275718f, 7.8641861446542797f,
- 7.8703647195834047f, 7.8765169465649993f,
- 7.8826430493618415f, 7.8887432488982591f,
- 7.8948177633079437f, 7.9008668079807486f,
- 7.9068905956085187f, 7.9128893362299619f,
- 7.9188632372745946f, 7.9248125036057812f,
- 7.9307373375628866f, 7.9366379390025709f,
- 7.9425145053392398f, 7.9483672315846778f,
- 7.9541963103868749f, 7.9600019320680805f,
- 7.9657842846620869f, 7.9715435539507719f,
- 7.9772799234999167f, 7.9829935746943103f,
- 7.9886846867721654f, 7.9943534368588577f
-};
-
-const float kSLog2Table[LOG_LOOKUP_IDX_MAX] = {
- 0.00000000f, 0.00000000f, 2.00000000f, 4.75488750f,
- 8.00000000f, 11.60964047f, 15.50977500f, 19.65148445f,
- 24.00000000f, 28.52932501f, 33.21928095f, 38.05374781f,
- 43.01955001f, 48.10571634f, 53.30296891f, 58.60335893f,
- 64.00000000f, 69.48686830f, 75.05865003f, 80.71062276f,
- 86.43856190f, 92.23866588f, 98.10749561f, 104.04192499f,
- 110.03910002f, 116.09640474f, 122.21143267f, 128.38196256f,
- 134.60593782f, 140.88144886f, 147.20671787f, 153.58008562f,
- 160.00000000f, 166.46500594f, 172.97373660f, 179.52490559f,
- 186.11730005f, 192.74977453f, 199.42124551f, 206.13068654f,
- 212.87712380f, 219.65963219f, 226.47733176f, 233.32938445f,
- 240.21499122f, 247.13338933f, 254.08384998f, 261.06567603f,
- 268.07820003f, 275.12078236f, 282.19280949f, 289.29369244f,
- 296.42286534f, 303.57978409f, 310.76392512f, 317.97478424f,
- 325.21187564f, 332.47473081f, 339.76289772f, 347.07593991f,
- 354.41343574f, 361.77497759f, 369.16017124f, 376.56863518f,
- 384.00000000f, 391.45390785f, 398.93001188f, 406.42797576f,
- 413.94747321f, 421.48818752f, 429.04981119f, 436.63204548f,
- 444.23460010f, 451.85719280f, 459.49954906f, 467.16140179f,
- 474.84249102f, 482.54256363f, 490.26137307f, 497.99867911f,
- 505.75424759f, 513.52785023f, 521.31926438f, 529.12827280f,
- 536.95466351f, 544.79822957f, 552.65876890f, 560.53608414f,
- 568.42998244f, 576.34027536f, 584.26677867f, 592.20931226f,
- 600.16769996f, 608.14176943f, 616.13135206f, 624.13628279f,
- 632.15640007f, 640.19154569f, 648.24156472f, 656.30630539f,
- 664.38561898f, 672.47935976f, 680.58738488f, 688.70955430f,
- 696.84573069f, 704.99577935f, 713.15956818f, 721.33696754f,
- 729.52785023f, 737.73209140f, 745.94956849f, 754.18016116f,
- 762.42375127f, 770.68022275f, 778.94946161f, 787.23135586f,
- 795.52579543f, 803.83267219f, 812.15187982f, 820.48331383f,
- 828.82687147f, 837.18245171f, 845.54995518f, 853.92928416f,
- 862.32034249f, 870.72303558f, 879.13727036f, 887.56295522f,
- 896.00000000f, 904.44831595f, 912.90781569f, 921.37841320f,
- 929.86002376f, 938.35256392f, 946.85595152f, 955.37010560f,
- 963.89494641f, 972.43039537f, 980.97637504f, 989.53280911f,
- 998.09962237f, 1006.67674069f, 1015.26409097f, 1023.86160116f,
- 1032.46920021f, 1041.08681805f, 1049.71438560f, 1058.35183469f,
- 1066.99909811f, 1075.65610955f, 1084.32280357f, 1092.99911564f,
- 1101.68498204f, 1110.38033993f, 1119.08512727f, 1127.79928282f,
- 1136.52274614f, 1145.25545758f, 1153.99735821f, 1162.74838989f,
- 1171.50849518f, 1180.27761738f, 1189.05570047f, 1197.84268914f,
- 1206.63852876f, 1215.44316535f, 1224.25654560f, 1233.07861684f,
- 1241.90932703f, 1250.74862473f, 1259.59645914f, 1268.45278005f,
- 1277.31753781f, 1286.19068338f, 1295.07216828f, 1303.96194457f,
- 1312.85996488f, 1321.76618236f, 1330.68055071f, 1339.60302413f,
- 1348.53355734f, 1357.47210556f, 1366.41862452f, 1375.37307041f,
- 1384.33539991f, 1393.30557020f, 1402.28353887f, 1411.26926400f,
- 1420.26270412f, 1429.26381818f, 1438.27256558f, 1447.28890615f,
- 1456.31280014f, 1465.34420819f, 1474.38309138f, 1483.42941118f,
- 1492.48312945f, 1501.54420843f, 1510.61261078f, 1519.68829949f,
- 1528.77123795f, 1537.86138993f, 1546.95871952f, 1556.06319119f,
- 1565.17476976f, 1574.29342040f, 1583.41910860f, 1592.55180020f,
- 1601.69146137f, 1610.83805860f, 1619.99155871f, 1629.15192882f,
- 1638.31913637f, 1647.49314911f, 1656.67393509f, 1665.86146266f,
- 1675.05570047f, 1684.25661744f, 1693.46418280f, 1702.67836605f,
- 1711.89913698f, 1721.12646563f, 1730.36032233f, 1739.60067768f,
- 1748.84750254f, 1758.10076802f, 1767.36044551f, 1776.62650662f,
- 1785.89892323f, 1795.17766747f, 1804.46271172f, 1813.75402857f,
- 1823.05159087f, 1832.35537170f, 1841.66534438f, 1850.98148244f,
- 1860.30375965f, 1869.63214999f, 1878.96662767f, 1888.30716711f,
- 1897.65374295f, 1907.00633003f, 1916.36490342f, 1925.72943838f,
- 1935.09991037f, 1944.47629506f, 1953.85856831f, 1963.24670620f,
- 1972.64068498f, 1982.04048108f, 1991.44607117f, 2000.85743204f,
- 2010.27454072f, 2019.69737440f, 2029.12591044f, 2038.56012640f
-};
-
-const VP8LPrefixCode kPrefixEncodeCode[PREFIX_LOOKUP_IDX_MAX] = {
- { 0, 0}, { 0, 0}, { 1, 0}, { 2, 0}, { 3, 0}, { 4, 1}, { 4, 1}, { 5, 1},
- { 5, 1}, { 6, 2}, { 6, 2}, { 6, 2}, { 6, 2}, { 7, 2}, { 7, 2}, { 7, 2},
- { 7, 2}, { 8, 3}, { 8, 3}, { 8, 3}, { 8, 3}, { 8, 3}, { 8, 3}, { 8, 3},
- { 8, 3}, { 9, 3}, { 9, 3}, { 9, 3}, { 9, 3}, { 9, 3}, { 9, 3}, { 9, 3},
- { 9, 3}, {10, 4}, {10, 4}, {10, 4}, {10, 4}, {10, 4}, {10, 4}, {10, 4},
- {10, 4}, {10, 4}, {10, 4}, {10, 4}, {10, 4}, {10, 4}, {10, 4}, {10, 4},
- {10, 4}, {11, 4}, {11, 4}, {11, 4}, {11, 4}, {11, 4}, {11, 4}, {11, 4},
- {11, 4}, {11, 4}, {11, 4}, {11, 4}, {11, 4}, {11, 4}, {11, 4}, {11, 4},
- {11, 4}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5},
- {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5},
- {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5},
- {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5},
- {12, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5},
- {13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5},
- {13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5},
- {13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5},
- {13, 5}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6},
- {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6},
- {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6},
- {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6},
- {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6},
- {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6},
- {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6},
- {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6},
- {14, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6},
- {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6},
- {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6},
- {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6},
- {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6},
- {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6},
- {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6},
- {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6},
- {15, 6}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},
- {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},
- {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},
- {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},
- {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},
- {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},
- {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},
- {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},
- {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},
- {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},
- {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},
- {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},
- {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},
- {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},
- {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},
- {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},
- {16, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},
- {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},
- {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},
- {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},
- {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},
- {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},
- {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},
- {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},
- {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},
- {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},
- {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},
- {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},
- {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},
- {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},
- {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},
- {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},
-};
-
-const uint8_t kPrefixEncodeExtraBitsValue[PREFIX_LOOKUP_IDX_MAX] = {
- 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 2, 3, 0, 1, 2, 3,
- 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
- 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
- 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
- 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
- 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
- 127,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
- 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
- 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
- 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
- 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126
-};
-
-static float FastSLog2Slow_C(uint32_t v) {
- assert(v >= LOG_LOOKUP_IDX_MAX);
- if (v < APPROX_LOG_WITH_CORRECTION_MAX) {
-#if !defined(WEBP_HAVE_SLOW_CLZ_CTZ)
- // use clz if available
- const int log_cnt = BitsLog2Floor(v) - 7;
- const uint32_t y = 1 << log_cnt;
- int correction = 0;
- const float v_f = (float)v;
- const uint32_t orig_v = v;
- v >>= log_cnt;
-#else
- int log_cnt = 0;
- uint32_t y = 1;
- int correction = 0;
- const float v_f = (float)v;
- const uint32_t orig_v = v;
- do {
- ++log_cnt;
- v = v >> 1;
- y = y << 1;
- } while (v >= LOG_LOOKUP_IDX_MAX);
-#endif
- // vf = (2^log_cnt) * Xf; where y = 2^log_cnt and Xf < 256
- // Xf = floor(Xf) * (1 + (v % y) / v)
- // log2(Xf) = log2(floor(Xf)) + log2(1 + (v % y) / v)
- // The correction factor: log(1 + d) ~ d; for very small d values, so
- // log2(1 + (v % y) / v) ~ LOG_2_RECIPROCAL * (v % y)/v
- // LOG_2_RECIPROCAL ~ 23/16
- correction = (23 * (orig_v & (y - 1))) >> 4;
- return v_f * (kLog2Table[v] + log_cnt) + correction;
- } else {
- return (float)(LOG_2_RECIPROCAL * v * log((double)v));
- }
-}
-
-static float FastLog2Slow_C(uint32_t v) {
- assert(v >= LOG_LOOKUP_IDX_MAX);
- if (v < APPROX_LOG_WITH_CORRECTION_MAX) {
-#if !defined(WEBP_HAVE_SLOW_CLZ_CTZ)
- // use clz if available
- const int log_cnt = BitsLog2Floor(v) - 7;
- const uint32_t y = 1 << log_cnt;
- const uint32_t orig_v = v;
- double log_2;
- v >>= log_cnt;
-#else
- int log_cnt = 0;
- uint32_t y = 1;
- const uint32_t orig_v = v;
- double log_2;
- do {
- ++log_cnt;
- v = v >> 1;
- y = y << 1;
- } while (v >= LOG_LOOKUP_IDX_MAX);
-#endif
- log_2 = kLog2Table[v] + log_cnt;
- if (orig_v >= APPROX_LOG_MAX) {
- // Since the division is still expensive, add this correction factor only
- // for large values of 'v'.
- const int correction = (23 * (orig_v & (y - 1))) >> 4;
- log_2 += (double)correction / orig_v;
- }
- return (float)log_2;
- } else {
- return (float)(LOG_2_RECIPROCAL * log((double)v));
- }
-}
-
-//------------------------------------------------------------------------------
-// Methods to calculate Entropy (Shannon).
-
-// Compute the combined Shanon's entropy for distribution {X} and {X+Y}
-static float CombinedShannonEntropy_C(const int X[256], const int Y[256]) {
- int i;
- double retval = 0.;
- int sumX = 0, sumXY = 0;
- for (i = 0; i < 256; ++i) {
- const int x = X[i];
- if (x != 0) {
- const int xy = x + Y[i];
- sumX += x;
- retval -= VP8LFastSLog2(x);
- sumXY += xy;
- retval -= VP8LFastSLog2(xy);
- } else if (Y[i] != 0) {
- sumXY += Y[i];
- retval -= VP8LFastSLog2(Y[i]);
- }
- }
- retval += VP8LFastSLog2(sumX) + VP8LFastSLog2(sumXY);
- return (float)retval;
-}
-
-void VP8LBitEntropyInit(VP8LBitEntropy* const entropy) {
- entropy->entropy = 0.;
- entropy->sum = 0;
- entropy->nonzeros = 0;
- entropy->max_val = 0;
- entropy->nonzero_code = VP8L_NON_TRIVIAL_SYM;
-}
-
-void VP8LBitsEntropyUnrefined(const uint32_t* const array, int n,
- VP8LBitEntropy* const entropy) {
- int i;
-
- VP8LBitEntropyInit(entropy);
-
- for (i = 0; i < n; ++i) {
- if (array[i] != 0) {
- entropy->sum += array[i];
- entropy->nonzero_code = i;
- ++entropy->nonzeros;
- entropy->entropy -= VP8LFastSLog2(array[i]);
- if (entropy->max_val < array[i]) {
- entropy->max_val = array[i];
- }
- }
- }
- entropy->entropy += VP8LFastSLog2(entropy->sum);
-}
-
-static WEBP_INLINE void GetEntropyUnrefinedHelper(
- uint32_t val, int i, uint32_t* const val_prev, int* const i_prev,
- VP8LBitEntropy* const bit_entropy, VP8LStreaks* const stats) {
- const int streak = i - *i_prev;
-
- // Gather info for the bit entropy.
- if (*val_prev != 0) {
- bit_entropy->sum += (*val_prev) * streak;
- bit_entropy->nonzeros += streak;
- bit_entropy->nonzero_code = *i_prev;
- bit_entropy->entropy -= VP8LFastSLog2(*val_prev) * streak;
- if (bit_entropy->max_val < *val_prev) {
- bit_entropy->max_val = *val_prev;
- }
- }
-
- // Gather info for the Huffman cost.
- stats->counts[*val_prev != 0] += (streak > 3);
- stats->streaks[*val_prev != 0][(streak > 3)] += streak;
-
- *val_prev = val;
- *i_prev = i;
-}
-
-static void GetEntropyUnrefined_C(const uint32_t X[], int length,
- VP8LBitEntropy* const bit_entropy,
- VP8LStreaks* const stats) {
- int i;
- int i_prev = 0;
- uint32_t x_prev = X[0];
-
- memset(stats, 0, sizeof(*stats));
- VP8LBitEntropyInit(bit_entropy);
-
- for (i = 1; i < length; ++i) {
- const uint32_t x = X[i];
- if (x != x_prev) {
- GetEntropyUnrefinedHelper(x, i, &x_prev, &i_prev, bit_entropy, stats);
- }
- }
- GetEntropyUnrefinedHelper(0, i, &x_prev, &i_prev, bit_entropy, stats);
-
- bit_entropy->entropy += VP8LFastSLog2(bit_entropy->sum);
-}
-
-static void GetCombinedEntropyUnrefined_C(const uint32_t X[],
- const uint32_t Y[],
- int length,
- VP8LBitEntropy* const bit_entropy,
- VP8LStreaks* const stats) {
- int i = 1;
- int i_prev = 0;
- uint32_t xy_prev = X[0] + Y[0];
-
- memset(stats, 0, sizeof(*stats));
- VP8LBitEntropyInit(bit_entropy);
-
- for (i = 1; i < length; ++i) {
- const uint32_t xy = X[i] + Y[i];
- if (xy != xy_prev) {
- GetEntropyUnrefinedHelper(xy, i, &xy_prev, &i_prev, bit_entropy, stats);
- }
- }
- GetEntropyUnrefinedHelper(0, i, &xy_prev, &i_prev, bit_entropy, stats);
-
- bit_entropy->entropy += VP8LFastSLog2(bit_entropy->sum);
-}
-
-//------------------------------------------------------------------------------
-
-void VP8LSubtractGreenFromBlueAndRed_C(uint32_t* argb_data, int num_pixels) {
- int i;
- for (i = 0; i < num_pixels; ++i) {
- const int argb = argb_data[i];
- const int green = (argb >> 8) & 0xff;
- const uint32_t new_r = (((argb >> 16) & 0xff) - green) & 0xff;
- const uint32_t new_b = (((argb >> 0) & 0xff) - green) & 0xff;
- argb_data[i] = (argb & 0xff00ff00u) | (new_r << 16) | new_b;
- }
-}
-
-static WEBP_INLINE int ColorTransformDelta(int8_t color_pred, int8_t color) {
- return ((int)color_pred * color) >> 5;
-}
-
-static WEBP_INLINE int8_t U32ToS8(uint32_t v) {
- return (int8_t)(v & 0xff);
-}
-
-void VP8LTransformColor_C(const VP8LMultipliers* const m, uint32_t* data,
- int num_pixels) {
- int i;
- for (i = 0; i < num_pixels; ++i) {
- const uint32_t argb = data[i];
- const int8_t green = U32ToS8(argb >> 8);
- const int8_t red = U32ToS8(argb >> 16);
- int new_red = red & 0xff;
- int new_blue = argb & 0xff;
- new_red -= ColorTransformDelta(m->green_to_red_, green);
- new_red &= 0xff;
- new_blue -= ColorTransformDelta(m->green_to_blue_, green);
- new_blue -= ColorTransformDelta(m->red_to_blue_, red);
- new_blue &= 0xff;
- data[i] = (argb & 0xff00ff00u) | (new_red << 16) | (new_blue);
- }
-}
-
-static WEBP_INLINE uint8_t TransformColorRed(uint8_t green_to_red,
- uint32_t argb) {
- const int8_t green = U32ToS8(argb >> 8);
- int new_red = argb >> 16;
- new_red -= ColorTransformDelta(green_to_red, green);
- return (new_red & 0xff);
-}
-
-static WEBP_INLINE uint8_t TransformColorBlue(uint8_t green_to_blue,
- uint8_t red_to_blue,
- uint32_t argb) {
- const int8_t green = U32ToS8(argb >> 8);
- const int8_t red = U32ToS8(argb >> 16);
- uint8_t new_blue = argb & 0xff;
- new_blue -= ColorTransformDelta(green_to_blue, green);
- new_blue -= ColorTransformDelta(red_to_blue, red);
- return (new_blue & 0xff);
-}
-
-void VP8LCollectColorRedTransforms_C(const uint32_t* argb, int stride,
- int tile_width, int tile_height,
- int green_to_red, int histo[]) {
- while (tile_height-- > 0) {
- int x;
- for (x = 0; x < tile_width; ++x) {
- ++histo[TransformColorRed((uint8_t)green_to_red, argb[x])];
- }
- argb += stride;
- }
-}
-
-void VP8LCollectColorBlueTransforms_C(const uint32_t* argb, int stride,
- int tile_width, int tile_height,
- int green_to_blue, int red_to_blue,
- int histo[]) {
- while (tile_height-- > 0) {
- int x;
- for (x = 0; x < tile_width; ++x) {
- ++histo[TransformColorBlue((uint8_t)green_to_blue, (uint8_t)red_to_blue,
- argb[x])];
- }
- argb += stride;
- }
-}
-
-//------------------------------------------------------------------------------
-
-static int VectorMismatch_C(const uint32_t* const array1,
- const uint32_t* const array2, int length) {
- int match_len = 0;
-
- while (match_len < length && array1[match_len] == array2[match_len]) {
- ++match_len;
- }
- return match_len;
-}
-
-// Bundles multiple (1, 2, 4 or 8) pixels into a single pixel.
-void VP8LBundleColorMap_C(const uint8_t* const row, int width, int xbits,
- uint32_t* dst) {
- int x;
- if (xbits > 0) {
- const int bit_depth = 1 << (3 - xbits);
- const int mask = (1 << xbits) - 1;
- uint32_t code = 0xff000000;
- for (x = 0; x < width; ++x) {
- const int xsub = x & mask;
- if (xsub == 0) {
- code = 0xff000000;
- }
- code |= row[x] << (8 + bit_depth * xsub);
- dst[x >> xbits] = code;
- }
- } else {
- for (x = 0; x < width; ++x) dst[x] = 0xff000000 | (row[x] << 8);
- }
-}
-
-//------------------------------------------------------------------------------
-
-static double ExtraCost_C(const uint32_t* population, int length) {
- int i;
- double cost = 0.;
- for (i = 2; i < length - 2; ++i) cost += (i >> 1) * population[i + 2];
- return cost;
-}
-
-static double ExtraCostCombined_C(const uint32_t* X, const uint32_t* Y,
- int length) {
- int i;
- double cost = 0.;
- for (i = 2; i < length - 2; ++i) {
- const int xy = X[i + 2] + Y[i + 2];
- cost += (i >> 1) * xy;
- }
- return cost;
-}
-
-//------------------------------------------------------------------------------
-
-static void AddVector_C(const uint32_t* a, const uint32_t* b, uint32_t* out,
- int size) {
- int i;
- for (i = 0; i < size; ++i) out[i] = a[i] + b[i];
-}
-
-static void AddVectorEq_C(const uint32_t* a, uint32_t* out, int size) {
- int i;
- for (i = 0; i < size; ++i) out[i] += a[i];
-}
-
-#define ADD(X, ARG, LEN) do { \
- if (a->is_used_[X]) { \
- if (b->is_used_[X]) { \
- VP8LAddVector(a->ARG, b->ARG, out->ARG, (LEN)); \
- } else { \
- memcpy(&out->ARG[0], &a->ARG[0], (LEN) * sizeof(out->ARG[0])); \
- } \
- } else if (b->is_used_[X]) { \
- memcpy(&out->ARG[0], &b->ARG[0], (LEN) * sizeof(out->ARG[0])); \
- } else { \
- memset(&out->ARG[0], 0, (LEN) * sizeof(out->ARG[0])); \
- } \
-} while (0)
-
-#define ADD_EQ(X, ARG, LEN) do { \
- if (a->is_used_[X]) { \
- if (out->is_used_[X]) { \
- VP8LAddVectorEq(a->ARG, out->ARG, (LEN)); \
- } else { \
- memcpy(&out->ARG[0], &a->ARG[0], (LEN) * sizeof(out->ARG[0])); \
- } \
- } \
-} while (0)
-
-void VP8LHistogramAdd(const VP8LHistogram* const a,
- const VP8LHistogram* const b, VP8LHistogram* const out) {
- int i;
- const int literal_size = VP8LHistogramNumCodes(a->palette_code_bits_);
- assert(a->palette_code_bits_ == b->palette_code_bits_);
-
- if (b != out) {
- ADD(0, literal_, literal_size);
- ADD(1, red_, NUM_LITERAL_CODES);
- ADD(2, blue_, NUM_LITERAL_CODES);
- ADD(3, alpha_, NUM_LITERAL_CODES);
- ADD(4, distance_, NUM_DISTANCE_CODES);
- for (i = 0; i < 5; ++i) {
- out->is_used_[i] = (a->is_used_[i] | b->is_used_[i]);
- }
- } else {
- ADD_EQ(0, literal_, literal_size);
- ADD_EQ(1, red_, NUM_LITERAL_CODES);
- ADD_EQ(2, blue_, NUM_LITERAL_CODES);
- ADD_EQ(3, alpha_, NUM_LITERAL_CODES);
- ADD_EQ(4, distance_, NUM_DISTANCE_CODES);
- for (i = 0; i < 5; ++i) out->is_used_[i] |= a->is_used_[i];
- }
-}
-#undef ADD
-#undef ADD_EQ
-
-//------------------------------------------------------------------------------
-// Image transforms.
-
-static void PredictorSub0_C(const uint32_t* in, const uint32_t* upper,
- int num_pixels, uint32_t* out) {
- int i;
- for (i = 0; i < num_pixels; ++i) out[i] = VP8LSubPixels(in[i], ARGB_BLACK);
- (void)upper;
-}
-
-static void PredictorSub1_C(const uint32_t* in, const uint32_t* upper,
- int num_pixels, uint32_t* out) {
- int i;
- for (i = 0; i < num_pixels; ++i) out[i] = VP8LSubPixels(in[i], in[i - 1]);
- (void)upper;
-}
-
-// It subtracts the prediction from the input pixel and stores the residual
-// in the output pixel.
-#define GENERATE_PREDICTOR_SUB(PREDICTOR_I) \
-static void PredictorSub##PREDICTOR_I##_C(const uint32_t* in, \
- const uint32_t* upper, \
- int num_pixels, uint32_t* out) { \
- int x; \
- assert(upper != NULL); \
- for (x = 0; x < num_pixels; ++x) { \
- const uint32_t pred = \
- VP8LPredictor##PREDICTOR_I##_C(&in[x - 1], upper + x); \
- out[x] = VP8LSubPixels(in[x], pred); \
- } \
-}
-
-GENERATE_PREDICTOR_SUB(2)
-GENERATE_PREDICTOR_SUB(3)
-GENERATE_PREDICTOR_SUB(4)
-GENERATE_PREDICTOR_SUB(5)
-GENERATE_PREDICTOR_SUB(6)
-GENERATE_PREDICTOR_SUB(7)
-GENERATE_PREDICTOR_SUB(8)
-GENERATE_PREDICTOR_SUB(9)
-GENERATE_PREDICTOR_SUB(10)
-GENERATE_PREDICTOR_SUB(11)
-GENERATE_PREDICTOR_SUB(12)
-GENERATE_PREDICTOR_SUB(13)
-
-//------------------------------------------------------------------------------
-
-VP8LProcessEncBlueAndRedFunc VP8LSubtractGreenFromBlueAndRed;
-
-VP8LTransformColorFunc VP8LTransformColor;
-
-VP8LCollectColorBlueTransformsFunc VP8LCollectColorBlueTransforms;
-VP8LCollectColorRedTransformsFunc VP8LCollectColorRedTransforms;
-
-VP8LFastLog2SlowFunc VP8LFastLog2Slow;
-VP8LFastLog2SlowFunc VP8LFastSLog2Slow;
-
-VP8LCostFunc VP8LExtraCost;
-VP8LCostCombinedFunc VP8LExtraCostCombined;
-VP8LCombinedShannonEntropyFunc VP8LCombinedShannonEntropy;
-
-VP8LGetEntropyUnrefinedFunc VP8LGetEntropyUnrefined;
-VP8LGetCombinedEntropyUnrefinedFunc VP8LGetCombinedEntropyUnrefined;
-
-VP8LAddVectorFunc VP8LAddVector;
-VP8LAddVectorEqFunc VP8LAddVectorEq;
-
-VP8LVectorMismatchFunc VP8LVectorMismatch;
-VP8LBundleColorMapFunc VP8LBundleColorMap;
-
-VP8LPredictorAddSubFunc VP8LPredictorsSub[16];
-VP8LPredictorAddSubFunc VP8LPredictorsSub_C[16];
-
-extern void VP8LEncDspInitSSE2(void);
-extern void VP8LEncDspInitSSE41(void);
-extern void VP8LEncDspInitNEON(void);
-extern void VP8LEncDspInitMIPS32(void);
-extern void VP8LEncDspInitMIPSdspR2(void);
-extern void VP8LEncDspInitMSA(void);
-
-WEBP_DSP_INIT_FUNC(VP8LEncDspInit) {
- VP8LDspInit();
-
-#if !WEBP_NEON_OMIT_C_CODE
- VP8LSubtractGreenFromBlueAndRed = VP8LSubtractGreenFromBlueAndRed_C;
-
- VP8LTransformColor = VP8LTransformColor_C;
-#endif
-
- VP8LCollectColorBlueTransforms = VP8LCollectColorBlueTransforms_C;
- VP8LCollectColorRedTransforms = VP8LCollectColorRedTransforms_C;
-
- VP8LFastLog2Slow = FastLog2Slow_C;
- VP8LFastSLog2Slow = FastSLog2Slow_C;
-
- VP8LExtraCost = ExtraCost_C;
- VP8LExtraCostCombined = ExtraCostCombined_C;
- VP8LCombinedShannonEntropy = CombinedShannonEntropy_C;
-
- VP8LGetEntropyUnrefined = GetEntropyUnrefined_C;
- VP8LGetCombinedEntropyUnrefined = GetCombinedEntropyUnrefined_C;
-
- VP8LAddVector = AddVector_C;
- VP8LAddVectorEq = AddVectorEq_C;
-
- VP8LVectorMismatch = VectorMismatch_C;
- VP8LBundleColorMap = VP8LBundleColorMap_C;
-
- VP8LPredictorsSub[0] = PredictorSub0_C;
- VP8LPredictorsSub[1] = PredictorSub1_C;
- VP8LPredictorsSub[2] = PredictorSub2_C;
- VP8LPredictorsSub[3] = PredictorSub3_C;
- VP8LPredictorsSub[4] = PredictorSub4_C;
- VP8LPredictorsSub[5] = PredictorSub5_C;
- VP8LPredictorsSub[6] = PredictorSub6_C;
- VP8LPredictorsSub[7] = PredictorSub7_C;
- VP8LPredictorsSub[8] = PredictorSub8_C;
- VP8LPredictorsSub[9] = PredictorSub9_C;
- VP8LPredictorsSub[10] = PredictorSub10_C;
- VP8LPredictorsSub[11] = PredictorSub11_C;
- VP8LPredictorsSub[12] = PredictorSub12_C;
- VP8LPredictorsSub[13] = PredictorSub13_C;
- VP8LPredictorsSub[14] = PredictorSub0_C; // <- padding security sentinels
- VP8LPredictorsSub[15] = PredictorSub0_C;
-
- VP8LPredictorsSub_C[0] = PredictorSub0_C;
- VP8LPredictorsSub_C[1] = PredictorSub1_C;
- VP8LPredictorsSub_C[2] = PredictorSub2_C;
- VP8LPredictorsSub_C[3] = PredictorSub3_C;
- VP8LPredictorsSub_C[4] = PredictorSub4_C;
- VP8LPredictorsSub_C[5] = PredictorSub5_C;
- VP8LPredictorsSub_C[6] = PredictorSub6_C;
- VP8LPredictorsSub_C[7] = PredictorSub7_C;
- VP8LPredictorsSub_C[8] = PredictorSub8_C;
- VP8LPredictorsSub_C[9] = PredictorSub9_C;
- VP8LPredictorsSub_C[10] = PredictorSub10_C;
- VP8LPredictorsSub_C[11] = PredictorSub11_C;
- VP8LPredictorsSub_C[12] = PredictorSub12_C;
- VP8LPredictorsSub_C[13] = PredictorSub13_C;
- VP8LPredictorsSub_C[14] = PredictorSub0_C; // <- padding security sentinels
- VP8LPredictorsSub_C[15] = PredictorSub0_C;
-
- // If defined, use CPUInfo() to overwrite some pointers with faster versions.
- if (VP8GetCPUInfo != NULL) {
-#if defined(WEBP_HAVE_SSE2)
- if (VP8GetCPUInfo(kSSE2)) {
- VP8LEncDspInitSSE2();
-#if defined(WEBP_HAVE_SSE41)
- if (VP8GetCPUInfo(kSSE4_1)) {
- VP8LEncDspInitSSE41();
- }
-#endif
- }
-#endif
-#if defined(WEBP_USE_MIPS32)
- if (VP8GetCPUInfo(kMIPS32)) {
- VP8LEncDspInitMIPS32();
- }
-#endif
-#if defined(WEBP_USE_MIPS_DSP_R2)
- if (VP8GetCPUInfo(kMIPSdspR2)) {
- VP8LEncDspInitMIPSdspR2();
- }
-#endif
-#if defined(WEBP_USE_MSA)
- if (VP8GetCPUInfo(kMSA)) {
- VP8LEncDspInitMSA();
- }
-#endif
- }
-
-#if defined(WEBP_HAVE_NEON)
- if (WEBP_NEON_OMIT_C_CODE ||
- (VP8GetCPUInfo != NULL && VP8GetCPUInfo(kNEON))) {
- VP8LEncDspInitNEON();
- }
-#endif
-
- assert(VP8LSubtractGreenFromBlueAndRed != NULL);
- assert(VP8LTransformColor != NULL);
- assert(VP8LCollectColorBlueTransforms != NULL);
- assert(VP8LCollectColorRedTransforms != NULL);
- assert(VP8LFastLog2Slow != NULL);
- assert(VP8LFastSLog2Slow != NULL);
- assert(VP8LExtraCost != NULL);
- assert(VP8LExtraCostCombined != NULL);
- assert(VP8LCombinedShannonEntropy != NULL);
- assert(VP8LGetEntropyUnrefined != NULL);
- assert(VP8LGetCombinedEntropyUnrefined != NULL);
- assert(VP8LAddVector != NULL);
- assert(VP8LAddVectorEq != NULL);
- assert(VP8LVectorMismatch != NULL);
- assert(VP8LBundleColorMap != NULL);
- assert(VP8LPredictorsSub[0] != NULL);
- assert(VP8LPredictorsSub[1] != NULL);
- assert(VP8LPredictorsSub[2] != NULL);
- assert(VP8LPredictorsSub[3] != NULL);
- assert(VP8LPredictorsSub[4] != NULL);
- assert(VP8LPredictorsSub[5] != NULL);
- assert(VP8LPredictorsSub[6] != NULL);
- assert(VP8LPredictorsSub[7] != NULL);
- assert(VP8LPredictorsSub[8] != NULL);
- assert(VP8LPredictorsSub[9] != NULL);
- assert(VP8LPredictorsSub[10] != NULL);
- assert(VP8LPredictorsSub[11] != NULL);
- assert(VP8LPredictorsSub[12] != NULL);
- assert(VP8LPredictorsSub[13] != NULL);
- assert(VP8LPredictorsSub[14] != NULL);
- assert(VP8LPredictorsSub[15] != NULL);
- assert(VP8LPredictorsSub_C[0] != NULL);
- assert(VP8LPredictorsSub_C[1] != NULL);
- assert(VP8LPredictorsSub_C[2] != NULL);
- assert(VP8LPredictorsSub_C[3] != NULL);
- assert(VP8LPredictorsSub_C[4] != NULL);
- assert(VP8LPredictorsSub_C[5] != NULL);
- assert(VP8LPredictorsSub_C[6] != NULL);
- assert(VP8LPredictorsSub_C[7] != NULL);
- assert(VP8LPredictorsSub_C[8] != NULL);
- assert(VP8LPredictorsSub_C[9] != NULL);
- assert(VP8LPredictorsSub_C[10] != NULL);
- assert(VP8LPredictorsSub_C[11] != NULL);
- assert(VP8LPredictorsSub_C[12] != NULL);
- assert(VP8LPredictorsSub_C[13] != NULL);
- assert(VP8LPredictorsSub_C[14] != NULL);
- assert(VP8LPredictorsSub_C[15] != NULL);
-}
-
-//------------------------------------------------------------------------------
diff --git a/contrib/libs/libwebp/dsp/lossless_enc_mips32.c b/contrib/libs/libwebp/dsp/lossless_enc_mips32.c
deleted file mode 100644
index 3257e040bf..0000000000
--- a/contrib/libs/libwebp/dsp/lossless_enc_mips32.c
+++ /dev/null
@@ -1,397 +0,0 @@
-// Copyright 2015 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// MIPS version of lossless functions
-//
-// Author(s): Djordje Pesut (djordje.pesut@imgtec.com)
-// Jovan Zelincevic (jovan.zelincevic@imgtec.com)
-
-#include "./dsp.h"
-#include "./lossless.h"
-#include "./lossless_common.h"
-
-#if defined(WEBP_USE_MIPS32)
-
-#include <assert.h>
-#include <math.h>
-#include <stdlib.h>
-#include <string.h>
-
-static float FastSLog2Slow_MIPS32(uint32_t v) {
- assert(v >= LOG_LOOKUP_IDX_MAX);
- if (v < APPROX_LOG_WITH_CORRECTION_MAX) {
- uint32_t log_cnt, y, correction;
- const int c24 = 24;
- const float v_f = (float)v;
- uint32_t temp;
-
- // Xf = 256 = 2^8
- // log_cnt is index of leading one in upper 24 bits
- __asm__ volatile(
- "clz %[log_cnt], %[v] \n\t"
- "addiu %[y], $zero, 1 \n\t"
- "subu %[log_cnt], %[c24], %[log_cnt] \n\t"
- "sllv %[y], %[y], %[log_cnt] \n\t"
- "srlv %[temp], %[v], %[log_cnt] \n\t"
- : [log_cnt]"=&r"(log_cnt), [y]"=&r"(y),
- [temp]"=r"(temp)
- : [c24]"r"(c24), [v]"r"(v)
- );
-
- // vf = (2^log_cnt) * Xf; where y = 2^log_cnt and Xf < 256
- // Xf = floor(Xf) * (1 + (v % y) / v)
- // log2(Xf) = log2(floor(Xf)) + log2(1 + (v % y) / v)
- // The correction factor: log(1 + d) ~ d; for very small d values, so
- // log2(1 + (v % y) / v) ~ LOG_2_RECIPROCAL * (v % y)/v
- // LOG_2_RECIPROCAL ~ 23/16
-
- // (v % y) = (v % 2^log_cnt) = v & (2^log_cnt - 1)
- correction = (23 * (v & (y - 1))) >> 4;
- return v_f * (kLog2Table[temp] + log_cnt) + correction;
- } else {
- return (float)(LOG_2_RECIPROCAL * v * log((double)v));
- }
-}
-
-static float FastLog2Slow_MIPS32(uint32_t v) {
- assert(v >= LOG_LOOKUP_IDX_MAX);
- if (v < APPROX_LOG_WITH_CORRECTION_MAX) {
- uint32_t log_cnt, y;
- const int c24 = 24;
- double log_2;
- uint32_t temp;
-
- __asm__ volatile(
- "clz %[log_cnt], %[v] \n\t"
- "addiu %[y], $zero, 1 \n\t"
- "subu %[log_cnt], %[c24], %[log_cnt] \n\t"
- "sllv %[y], %[y], %[log_cnt] \n\t"
- "srlv %[temp], %[v], %[log_cnt] \n\t"
- : [log_cnt]"=&r"(log_cnt), [y]"=&r"(y),
- [temp]"=r"(temp)
- : [c24]"r"(c24), [v]"r"(v)
- );
-
- log_2 = kLog2Table[temp] + log_cnt;
- if (v >= APPROX_LOG_MAX) {
- // Since the division is still expensive, add this correction factor only
- // for large values of 'v'.
-
- const uint32_t correction = (23 * (v & (y - 1))) >> 4;
- log_2 += (double)correction / v;
- }
- return (float)log_2;
- } else {
- return (float)(LOG_2_RECIPROCAL * log((double)v));
- }
-}
-
-// C version of this function:
-// int i = 0;
-// int64_t cost = 0;
-// const uint32_t* pop = &population[4];
-// const uint32_t* LoopEnd = &population[length];
-// while (pop != LoopEnd) {
-// ++i;
-// cost += i * *pop;
-// cost += i * *(pop + 1);
-// pop += 2;
-// }
-// return (double)cost;
-static double ExtraCost_MIPS32(const uint32_t* const population, int length) {
- int i, temp0, temp1;
- const uint32_t* pop = &population[4];
- const uint32_t* const LoopEnd = &population[length];
-
- __asm__ volatile(
- "mult $zero, $zero \n\t"
- "xor %[i], %[i], %[i] \n\t"
- "beq %[pop], %[LoopEnd], 2f \n\t"
- "1: \n\t"
- "lw %[temp0], 0(%[pop]) \n\t"
- "lw %[temp1], 4(%[pop]) \n\t"
- "addiu %[i], %[i], 1 \n\t"
- "addiu %[pop], %[pop], 8 \n\t"
- "madd %[i], %[temp0] \n\t"
- "madd %[i], %[temp1] \n\t"
- "bne %[pop], %[LoopEnd], 1b \n\t"
- "2: \n\t"
- "mfhi %[temp0] \n\t"
- "mflo %[temp1] \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1),
- [i]"=&r"(i), [pop]"+r"(pop)
- : [LoopEnd]"r"(LoopEnd)
- : "memory", "hi", "lo"
- );
-
- return (double)((int64_t)temp0 << 32 | temp1);
-}
-
-// C version of this function:
-// int i = 0;
-// int64_t cost = 0;
-// const uint32_t* pX = &X[4];
-// const uint32_t* pY = &Y[4];
-// const uint32_t* LoopEnd = &X[length];
-// while (pX != LoopEnd) {
-// const uint32_t xy0 = *pX + *pY;
-// const uint32_t xy1 = *(pX + 1) + *(pY + 1);
-// ++i;
-// cost += i * xy0;
-// cost += i * xy1;
-// pX += 2;
-// pY += 2;
-// }
-// return (double)cost;
-static double ExtraCostCombined_MIPS32(const uint32_t* const X,
- const uint32_t* const Y, int length) {
- int i, temp0, temp1, temp2, temp3;
- const uint32_t* pX = &X[4];
- const uint32_t* pY = &Y[4];
- const uint32_t* const LoopEnd = &X[length];
-
- __asm__ volatile(
- "mult $zero, $zero \n\t"
- "xor %[i], %[i], %[i] \n\t"
- "beq %[pX], %[LoopEnd], 2f \n\t"
- "1: \n\t"
- "lw %[temp0], 0(%[pX]) \n\t"
- "lw %[temp1], 0(%[pY]) \n\t"
- "lw %[temp2], 4(%[pX]) \n\t"
- "lw %[temp3], 4(%[pY]) \n\t"
- "addiu %[i], %[i], 1 \n\t"
- "addu %[temp0], %[temp0], %[temp1] \n\t"
- "addu %[temp2], %[temp2], %[temp3] \n\t"
- "addiu %[pX], %[pX], 8 \n\t"
- "addiu %[pY], %[pY], 8 \n\t"
- "madd %[i], %[temp0] \n\t"
- "madd %[i], %[temp2] \n\t"
- "bne %[pX], %[LoopEnd], 1b \n\t"
- "2: \n\t"
- "mfhi %[temp0] \n\t"
- "mflo %[temp1] \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1),
- [temp2]"=&r"(temp2), [temp3]"=&r"(temp3),
- [i]"=&r"(i), [pX]"+r"(pX), [pY]"+r"(pY)
- : [LoopEnd]"r"(LoopEnd)
- : "memory", "hi", "lo"
- );
-
- return (double)((int64_t)temp0 << 32 | temp1);
-}
-
-#define HUFFMAN_COST_PASS \
- __asm__ volatile( \
- "sll %[temp1], %[temp0], 3 \n\t" \
- "addiu %[temp3], %[streak], -3 \n\t" \
- "addu %[temp2], %[pstreaks], %[temp1] \n\t" \
- "blez %[temp3], 1f \n\t" \
- "srl %[temp1], %[temp1], 1 \n\t" \
- "addu %[temp3], %[pcnts], %[temp1] \n\t" \
- "lw %[temp0], 4(%[temp2]) \n\t" \
- "lw %[temp1], 0(%[temp3]) \n\t" \
- "addu %[temp0], %[temp0], %[streak] \n\t" \
- "addiu %[temp1], %[temp1], 1 \n\t" \
- "sw %[temp0], 4(%[temp2]) \n\t" \
- "sw %[temp1], 0(%[temp3]) \n\t" \
- "b 2f \n\t" \
- "1: \n\t" \
- "lw %[temp0], 0(%[temp2]) \n\t" \
- "addu %[temp0], %[temp0], %[streak] \n\t" \
- "sw %[temp0], 0(%[temp2]) \n\t" \
- "2: \n\t" \
- : [temp1]"=&r"(temp1), [temp2]"=&r"(temp2), \
- [temp3]"=&r"(temp3), [temp0]"+r"(temp0) \
- : [pstreaks]"r"(pstreaks), [pcnts]"r"(pcnts), \
- [streak]"r"(streak) \
- : "memory" \
- );
-
-// Returns the various RLE counts
-static WEBP_INLINE void GetEntropyUnrefinedHelper(
- uint32_t val, int i, uint32_t* const val_prev, int* const i_prev,
- VP8LBitEntropy* const bit_entropy, VP8LStreaks* const stats) {
- int* const pstreaks = &stats->streaks[0][0];
- int* const pcnts = &stats->counts[0];
- int temp0, temp1, temp2, temp3;
- const int streak = i - *i_prev;
-
- // Gather info for the bit entropy.
- if (*val_prev != 0) {
- bit_entropy->sum += (*val_prev) * streak;
- bit_entropy->nonzeros += streak;
- bit_entropy->nonzero_code = *i_prev;
- bit_entropy->entropy -= VP8LFastSLog2(*val_prev) * streak;
- if (bit_entropy->max_val < *val_prev) {
- bit_entropy->max_val = *val_prev;
- }
- }
-
- // Gather info for the Huffman cost.
- temp0 = (*val_prev != 0);
- HUFFMAN_COST_PASS
-
- *val_prev = val;
- *i_prev = i;
-}
-
-static void GetEntropyUnrefined_MIPS32(const uint32_t X[], int length,
- VP8LBitEntropy* const bit_entropy,
- VP8LStreaks* const stats) {
- int i;
- int i_prev = 0;
- uint32_t x_prev = X[0];
-
- memset(stats, 0, sizeof(*stats));
- VP8LBitEntropyInit(bit_entropy);
-
- for (i = 1; i < length; ++i) {
- const uint32_t x = X[i];
- if (x != x_prev) {
- GetEntropyUnrefinedHelper(x, i, &x_prev, &i_prev, bit_entropy, stats);
- }
- }
- GetEntropyUnrefinedHelper(0, i, &x_prev, &i_prev, bit_entropy, stats);
-
- bit_entropy->entropy += VP8LFastSLog2(bit_entropy->sum);
-}
-
-static void GetCombinedEntropyUnrefined_MIPS32(const uint32_t X[],
- const uint32_t Y[],
- int length,
- VP8LBitEntropy* const entropy,
- VP8LStreaks* const stats) {
- int i = 1;
- int i_prev = 0;
- uint32_t xy_prev = X[0] + Y[0];
-
- memset(stats, 0, sizeof(*stats));
- VP8LBitEntropyInit(entropy);
-
- for (i = 1; i < length; ++i) {
- const uint32_t xy = X[i] + Y[i];
- if (xy != xy_prev) {
- GetEntropyUnrefinedHelper(xy, i, &xy_prev, &i_prev, entropy, stats);
- }
- }
- GetEntropyUnrefinedHelper(0, i, &xy_prev, &i_prev, entropy, stats);
-
- entropy->entropy += VP8LFastSLog2(entropy->sum);
-}
-
-#define ASM_START \
- __asm__ volatile( \
- ".set push \n\t" \
- ".set at \n\t" \
- ".set macro \n\t" \
- "1: \n\t"
-
-// P2 = P0 + P1
-// A..D - offsets
-// E - temp variable to tell macro
-// if pointer should be incremented
-// literal_ and successive histograms could be unaligned
-// so we must use ulw and usw
-#define ADD_TO_OUT(A, B, C, D, E, P0, P1, P2) \
- "ulw %[temp0], " #A "(%[" #P0 "]) \n\t" \
- "ulw %[temp1], " #B "(%[" #P0 "]) \n\t" \
- "ulw %[temp2], " #C "(%[" #P0 "]) \n\t" \
- "ulw %[temp3], " #D "(%[" #P0 "]) \n\t" \
- "ulw %[temp4], " #A "(%[" #P1 "]) \n\t" \
- "ulw %[temp5], " #B "(%[" #P1 "]) \n\t" \
- "ulw %[temp6], " #C "(%[" #P1 "]) \n\t" \
- "ulw %[temp7], " #D "(%[" #P1 "]) \n\t" \
- "addu %[temp4], %[temp4], %[temp0] \n\t" \
- "addu %[temp5], %[temp5], %[temp1] \n\t" \
- "addu %[temp6], %[temp6], %[temp2] \n\t" \
- "addu %[temp7], %[temp7], %[temp3] \n\t" \
- "addiu %[" #P0 "], %[" #P0 "], 16 \n\t" \
- ".if " #E " == 1 \n\t" \
- "addiu %[" #P1 "], %[" #P1 "], 16 \n\t" \
- ".endif \n\t" \
- "usw %[temp4], " #A "(%[" #P2 "]) \n\t" \
- "usw %[temp5], " #B "(%[" #P2 "]) \n\t" \
- "usw %[temp6], " #C "(%[" #P2 "]) \n\t" \
- "usw %[temp7], " #D "(%[" #P2 "]) \n\t" \
- "addiu %[" #P2 "], %[" #P2 "], 16 \n\t" \
- "bne %[" #P0 "], %[LoopEnd], 1b \n\t" \
- ".set pop \n\t" \
-
-#define ASM_END_COMMON_0 \
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), \
- [temp2]"=&r"(temp2), [temp3]"=&r"(temp3), \
- [temp4]"=&r"(temp4), [temp5]"=&r"(temp5), \
- [temp6]"=&r"(temp6), [temp7]"=&r"(temp7), \
- [pa]"+r"(pa), [pout]"+r"(pout)
-
-#define ASM_END_COMMON_1 \
- : [LoopEnd]"r"(LoopEnd) \
- : "memory", "at" \
- );
-
-#define ASM_END_0 \
- ASM_END_COMMON_0 \
- , [pb]"+r"(pb) \
- ASM_END_COMMON_1
-
-#define ASM_END_1 \
- ASM_END_COMMON_0 \
- ASM_END_COMMON_1
-
-static void AddVector_MIPS32(const uint32_t* pa, const uint32_t* pb,
- uint32_t* pout, int size) {
- uint32_t temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7;
- const uint32_t end = ((size) / 4) * 4;
- const uint32_t* const LoopEnd = pa + end;
- int i;
- ASM_START
- ADD_TO_OUT(0, 4, 8, 12, 1, pa, pb, pout)
- ASM_END_0
- for (i = end; i < size; ++i) pout[i] = pa[i] + pb[i];
-}
-
-static void AddVectorEq_MIPS32(const uint32_t* pa, uint32_t* pout, int size) {
- uint32_t temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7;
- const uint32_t end = ((size) / 4) * 4;
- const uint32_t* const LoopEnd = pa + end;
- int i;
- ASM_START
- ADD_TO_OUT(0, 4, 8, 12, 0, pa, pout, pout)
- ASM_END_1
- for (i = end; i < size; ++i) pout[i] += pa[i];
-}
-
-#undef ASM_END_1
-#undef ASM_END_0
-#undef ASM_END_COMMON_1
-#undef ASM_END_COMMON_0
-#undef ADD_TO_OUT
-#undef ASM_START
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void VP8LEncDspInitMIPS32(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void VP8LEncDspInitMIPS32(void) {
- VP8LFastSLog2Slow = FastSLog2Slow_MIPS32;
- VP8LFastLog2Slow = FastLog2Slow_MIPS32;
- VP8LExtraCost = ExtraCost_MIPS32;
- VP8LExtraCostCombined = ExtraCostCombined_MIPS32;
- VP8LGetEntropyUnrefined = GetEntropyUnrefined_MIPS32;
- VP8LGetCombinedEntropyUnrefined = GetCombinedEntropyUnrefined_MIPS32;
- VP8LAddVector = AddVector_MIPS32;
- VP8LAddVectorEq = AddVectorEq_MIPS32;
-}
-
-#else // !WEBP_USE_MIPS32
-
-WEBP_DSP_INIT_STUB(VP8LEncDspInitMIPS32)
-
-#endif // WEBP_USE_MIPS32
diff --git a/contrib/libs/libwebp/dsp/lossless_enc_mips_dsp_r2.c b/contrib/libs/libwebp/dsp/lossless_enc_mips_dsp_r2.c
deleted file mode 100644
index d499875a51..0000000000
--- a/contrib/libs/libwebp/dsp/lossless_enc_mips_dsp_r2.c
+++ /dev/null
@@ -1,281 +0,0 @@
-// Copyright 2015 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Image transform methods for lossless encoder.
-//
-// Author(s): Djordje Pesut (djordje.pesut@imgtec.com)
-// Jovan Zelincevic (jovan.zelincevic@imgtec.com)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_MIPS_DSP_R2)
-
-#include "./lossless.h"
-
-static void SubtractGreenFromBlueAndRed_MIPSdspR2(uint32_t* argb_data,
- int num_pixels) {
- uint32_t temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7;
- uint32_t* const p_loop1_end = argb_data + (num_pixels & ~3);
- uint32_t* const p_loop2_end = p_loop1_end + (num_pixels & 3);
- __asm__ volatile (
- ".set push \n\t"
- ".set noreorder \n\t"
- "beq %[argb_data], %[p_loop1_end], 3f \n\t"
- " nop \n\t"
- "0: \n\t"
- "lw %[temp0], 0(%[argb_data]) \n\t"
- "lw %[temp1], 4(%[argb_data]) \n\t"
- "lw %[temp2], 8(%[argb_data]) \n\t"
- "lw %[temp3], 12(%[argb_data]) \n\t"
- "ext %[temp4], %[temp0], 8, 8 \n\t"
- "ext %[temp5], %[temp1], 8, 8 \n\t"
- "ext %[temp6], %[temp2], 8, 8 \n\t"
- "ext %[temp7], %[temp3], 8, 8 \n\t"
- "addiu %[argb_data], %[argb_data], 16 \n\t"
- "replv.ph %[temp4], %[temp4] \n\t"
- "replv.ph %[temp5], %[temp5] \n\t"
- "replv.ph %[temp6], %[temp6] \n\t"
- "replv.ph %[temp7], %[temp7] \n\t"
- "subu.qb %[temp0], %[temp0], %[temp4] \n\t"
- "subu.qb %[temp1], %[temp1], %[temp5] \n\t"
- "subu.qb %[temp2], %[temp2], %[temp6] \n\t"
- "subu.qb %[temp3], %[temp3], %[temp7] \n\t"
- "sw %[temp0], -16(%[argb_data]) \n\t"
- "sw %[temp1], -12(%[argb_data]) \n\t"
- "sw %[temp2], -8(%[argb_data]) \n\t"
- "bne %[argb_data], %[p_loop1_end], 0b \n\t"
- " sw %[temp3], -4(%[argb_data]) \n\t"
- "3: \n\t"
- "beq %[argb_data], %[p_loop2_end], 2f \n\t"
- " nop \n\t"
- "1: \n\t"
- "lw %[temp0], 0(%[argb_data]) \n\t"
- "addiu %[argb_data], %[argb_data], 4 \n\t"
- "ext %[temp4], %[temp0], 8, 8 \n\t"
- "replv.ph %[temp4], %[temp4] \n\t"
- "subu.qb %[temp0], %[temp0], %[temp4] \n\t"
- "bne %[argb_data], %[p_loop2_end], 1b \n\t"
- " sw %[temp0], -4(%[argb_data]) \n\t"
- "2: \n\t"
- ".set pop \n\t"
- : [argb_data]"+&r"(argb_data), [temp0]"=&r"(temp0),
- [temp1]"=&r"(temp1), [temp2]"=&r"(temp2), [temp3]"=&r"(temp3),
- [temp4]"=&r"(temp4), [temp5]"=&r"(temp5), [temp6]"=&r"(temp6),
- [temp7]"=&r"(temp7)
- : [p_loop1_end]"r"(p_loop1_end), [p_loop2_end]"r"(p_loop2_end)
- : "memory"
- );
-}
-
-static WEBP_INLINE uint32_t ColorTransformDelta(int8_t color_pred,
- int8_t color) {
- return (uint32_t)((int)(color_pred) * color) >> 5;
-}
-
-static void TransformColor_MIPSdspR2(const VP8LMultipliers* const m,
- uint32_t* data, int num_pixels) {
- int temp0, temp1, temp2, temp3, temp4, temp5;
- uint32_t argb, argb1, new_red, new_red1;
- const uint32_t G_to_R = m->green_to_red_;
- const uint32_t G_to_B = m->green_to_blue_;
- const uint32_t R_to_B = m->red_to_blue_;
- uint32_t* const p_loop_end = data + (num_pixels & ~1);
- __asm__ volatile (
- ".set push \n\t"
- ".set noreorder \n\t"
- "beq %[data], %[p_loop_end], 1f \n\t"
- " nop \n\t"
- "replv.ph %[temp0], %[G_to_R] \n\t"
- "replv.ph %[temp1], %[G_to_B] \n\t"
- "replv.ph %[temp2], %[R_to_B] \n\t"
- "shll.ph %[temp0], %[temp0], 8 \n\t"
- "shll.ph %[temp1], %[temp1], 8 \n\t"
- "shll.ph %[temp2], %[temp2], 8 \n\t"
- "shra.ph %[temp0], %[temp0], 8 \n\t"
- "shra.ph %[temp1], %[temp1], 8 \n\t"
- "shra.ph %[temp2], %[temp2], 8 \n\t"
- "0: \n\t"
- "lw %[argb], 0(%[data]) \n\t"
- "lw %[argb1], 4(%[data]) \n\t"
- "lhu %[new_red], 2(%[data]) \n\t"
- "lhu %[new_red1], 6(%[data]) \n\t"
- "precrq.qb.ph %[temp3], %[argb], %[argb1] \n\t"
- "precr.qb.ph %[temp4], %[argb], %[argb1] \n\t"
- "preceu.ph.qbra %[temp3], %[temp3] \n\t"
- "preceu.ph.qbla %[temp4], %[temp4] \n\t"
- "shll.ph %[temp3], %[temp3], 8 \n\t"
- "shll.ph %[temp4], %[temp4], 8 \n\t"
- "shra.ph %[temp3], %[temp3], 8 \n\t"
- "shra.ph %[temp4], %[temp4], 8 \n\t"
- "mul.ph %[temp5], %[temp3], %[temp0] \n\t"
- "mul.ph %[temp3], %[temp3], %[temp1] \n\t"
- "mul.ph %[temp4], %[temp4], %[temp2] \n\t"
- "addiu %[data], %[data], 8 \n\t"
- "ins %[new_red1], %[new_red], 16, 16 \n\t"
- "ins %[argb1], %[argb], 16, 16 \n\t"
- "shra.ph %[temp5], %[temp5], 5 \n\t"
- "shra.ph %[temp3], %[temp3], 5 \n\t"
- "shra.ph %[temp4], %[temp4], 5 \n\t"
- "subu.ph %[new_red1], %[new_red1], %[temp5] \n\t"
- "subu.ph %[argb1], %[argb1], %[temp3] \n\t"
- "preceu.ph.qbra %[temp5], %[new_red1] \n\t"
- "subu.ph %[argb1], %[argb1], %[temp4] \n\t"
- "preceu.ph.qbra %[temp3], %[argb1] \n\t"
- "sb %[temp5], -2(%[data]) \n\t"
- "sb %[temp3], -4(%[data]) \n\t"
- "sra %[temp5], %[temp5], 16 \n\t"
- "sra %[temp3], %[temp3], 16 \n\t"
- "sb %[temp5], -6(%[data]) \n\t"
- "bne %[data], %[p_loop_end], 0b \n\t"
- " sb %[temp3], -8(%[data]) \n\t"
- "1: \n\t"
- ".set pop \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [temp4]"=&r"(temp4), [temp5]"=&r"(temp5),
- [new_red1]"=&r"(new_red1), [new_red]"=&r"(new_red),
- [argb]"=&r"(argb), [argb1]"=&r"(argb1), [data]"+&r"(data)
- : [G_to_R]"r"(G_to_R), [R_to_B]"r"(R_to_B),
- [G_to_B]"r"(G_to_B), [p_loop_end]"r"(p_loop_end)
- : "memory", "hi", "lo"
- );
-
- if (num_pixels & 1) {
- const uint32_t argb_ = data[0];
- const uint32_t green = argb_ >> 8;
- const uint32_t red = argb_ >> 16;
- uint32_t new_blue = argb_;
- new_red = red;
- new_red -= ColorTransformDelta(m->green_to_red_, green);
- new_red &= 0xff;
- new_blue -= ColorTransformDelta(m->green_to_blue_, green);
- new_blue -= ColorTransformDelta(m->red_to_blue_, red);
- new_blue &= 0xff;
- data[0] = (argb_ & 0xff00ff00u) | (new_red << 16) | (new_blue);
- }
-}
-
-static WEBP_INLINE uint8_t TransformColorBlue(uint8_t green_to_blue,
- uint8_t red_to_blue,
- uint32_t argb) {
- const uint32_t green = argb >> 8;
- const uint32_t red = argb >> 16;
- uint8_t new_blue = argb;
- new_blue -= ColorTransformDelta(green_to_blue, green);
- new_blue -= ColorTransformDelta(red_to_blue, red);
- return (new_blue & 0xff);
-}
-
-static void CollectColorBlueTransforms_MIPSdspR2(const uint32_t* argb,
- int stride,
- int tile_width,
- int tile_height,
- int green_to_blue,
- int red_to_blue,
- int histo[]) {
- const int rtb = (red_to_blue << 16) | (red_to_blue & 0xffff);
- const int gtb = (green_to_blue << 16) | (green_to_blue & 0xffff);
- const uint32_t mask = 0xff00ffu;
- while (tile_height-- > 0) {
- int x;
- const uint32_t* p_argb = argb;
- argb += stride;
- for (x = 0; x < (tile_width >> 1); ++x) {
- int temp0, temp1, temp2, temp3, temp4, temp5, temp6;
- __asm__ volatile (
- "lw %[temp0], 0(%[p_argb]) \n\t"
- "lw %[temp1], 4(%[p_argb]) \n\t"
- "precr.qb.ph %[temp2], %[temp0], %[temp1] \n\t"
- "ins %[temp1], %[temp0], 16, 16 \n\t"
- "shra.ph %[temp2], %[temp2], 8 \n\t"
- "shra.ph %[temp3], %[temp1], 8 \n\t"
- "mul.ph %[temp5], %[temp2], %[rtb] \n\t"
- "mul.ph %[temp6], %[temp3], %[gtb] \n\t"
- "and %[temp4], %[temp1], %[mask] \n\t"
- "addiu %[p_argb], %[p_argb], 8 \n\t"
- "shra.ph %[temp5], %[temp5], 5 \n\t"
- "shra.ph %[temp6], %[temp6], 5 \n\t"
- "subu.qb %[temp2], %[temp4], %[temp5] \n\t"
- "subu.qb %[temp2], %[temp2], %[temp6] \n\t"
- : [p_argb]"+&r"(p_argb), [temp0]"=&r"(temp0), [temp1]"=&r"(temp1),
- [temp2]"=&r"(temp2), [temp3]"=&r"(temp3), [temp4]"=&r"(temp4),
- [temp5]"=&r"(temp5), [temp6]"=&r"(temp6)
- : [rtb]"r"(rtb), [gtb]"r"(gtb), [mask]"r"(mask)
- : "memory", "hi", "lo"
- );
- ++histo[(uint8_t)(temp2 >> 16)];
- ++histo[(uint8_t)temp2];
- }
- if (tile_width & 1) {
- ++histo[TransformColorBlue(green_to_blue, red_to_blue, *p_argb)];
- }
- }
-}
-
-static WEBP_INLINE uint8_t TransformColorRed(uint8_t green_to_red,
- uint32_t argb) {
- const uint32_t green = argb >> 8;
- uint32_t new_red = argb >> 16;
- new_red -= ColorTransformDelta(green_to_red, green);
- return (new_red & 0xff);
-}
-
-static void CollectColorRedTransforms_MIPSdspR2(const uint32_t* argb,
- int stride,
- int tile_width,
- int tile_height,
- int green_to_red,
- int histo[]) {
- const int gtr = (green_to_red << 16) | (green_to_red & 0xffff);
- while (tile_height-- > 0) {
- int x;
- const uint32_t* p_argb = argb;
- argb += stride;
- for (x = 0; x < (tile_width >> 1); ++x) {
- int temp0, temp1, temp2, temp3, temp4;
- __asm__ volatile (
- "lw %[temp0], 0(%[p_argb]) \n\t"
- "lw %[temp1], 4(%[p_argb]) \n\t"
- "precrq.ph.w %[temp4], %[temp0], %[temp1] \n\t"
- "ins %[temp1], %[temp0], 16, 16 \n\t"
- "shra.ph %[temp3], %[temp1], 8 \n\t"
- "mul.ph %[temp2], %[temp3], %[gtr] \n\t"
- "addiu %[p_argb], %[p_argb], 8 \n\t"
- "shra.ph %[temp2], %[temp2], 5 \n\t"
- "subu.qb %[temp2], %[temp4], %[temp2] \n\t"
- : [p_argb]"+&r"(p_argb), [temp0]"=&r"(temp0), [temp1]"=&r"(temp1),
- [temp2]"=&r"(temp2), [temp3]"=&r"(temp3), [temp4]"=&r"(temp4)
- : [gtr]"r"(gtr)
- : "memory", "hi", "lo"
- );
- ++histo[(uint8_t)(temp2 >> 16)];
- ++histo[(uint8_t)temp2];
- }
- if (tile_width & 1) {
- ++histo[TransformColorRed(green_to_red, *p_argb)];
- }
- }
-}
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void VP8LEncDspInitMIPSdspR2(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void VP8LEncDspInitMIPSdspR2(void) {
- VP8LSubtractGreenFromBlueAndRed = SubtractGreenFromBlueAndRed_MIPSdspR2;
- VP8LTransformColor = TransformColor_MIPSdspR2;
- VP8LCollectColorBlueTransforms = CollectColorBlueTransforms_MIPSdspR2;
- VP8LCollectColorRedTransforms = CollectColorRedTransforms_MIPSdspR2;
-}
-
-#else // !WEBP_USE_MIPS_DSP_R2
-
-WEBP_DSP_INIT_STUB(VP8LEncDspInitMIPSdspR2)
-
-#endif // WEBP_USE_MIPS_DSP_R2
diff --git a/contrib/libs/libwebp/dsp/lossless_enc_msa.c b/contrib/libs/libwebp/dsp/lossless_enc_msa.c
deleted file mode 100644
index d5b205816a..0000000000
--- a/contrib/libs/libwebp/dsp/lossless_enc_msa.c
+++ /dev/null
@@ -1,148 +0,0 @@
-// Copyright 2016 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// MSA variant of Image transform methods for lossless encoder.
-//
-// Authors: Prashant Patil (Prashant.Patil@imgtec.com)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_MSA)
-
-#include "./lossless.h"
-#include "./msa_macro.h"
-
-#define TRANSFORM_COLOR_8(src0, src1, dst0, dst1, c0, c1, mask0, mask1) do { \
- v8i16 g0, g1, t0, t1, t2, t3; \
- v4i32 t4, t5; \
- VSHF_B2_SH(src0, src0, src1, src1, mask0, mask0, g0, g1); \
- DOTP_SB2_SH(g0, g1, c0, c0, t0, t1); \
- SRAI_H2_SH(t0, t1, 5); \
- t0 = __msa_subv_h((v8i16)src0, t0); \
- t1 = __msa_subv_h((v8i16)src1, t1); \
- t4 = __msa_srli_w((v4i32)src0, 16); \
- t5 = __msa_srli_w((v4i32)src1, 16); \
- DOTP_SB2_SH(t4, t5, c1, c1, t2, t3); \
- SRAI_H2_SH(t2, t3, 5); \
- SUB2(t0, t2, t1, t3, t0, t1); \
- VSHF_B2_UB(src0, t0, src1, t1, mask1, mask1, dst0, dst1); \
-} while (0)
-
-#define TRANSFORM_COLOR_4(src, dst, c0, c1, mask0, mask1) do { \
- const v16i8 g0 = VSHF_SB(src, src, mask0); \
- v8i16 t0 = __msa_dotp_s_h(c0, g0); \
- v8i16 t1; \
- v4i32 t2; \
- t0 = SRAI_H(t0, 5); \
- t0 = __msa_subv_h((v8i16)src, t0); \
- t2 = __msa_srli_w((v4i32)src, 16); \
- t1 = __msa_dotp_s_h(c1, (v16i8)t2); \
- t1 = SRAI_H(t1, 5); \
- t0 = t0 - t1; \
- dst = VSHF_UB(src, t0, mask1); \
-} while (0)
-
-static void TransformColor_MSA(const VP8LMultipliers* const m, uint32_t* data,
- int num_pixels) {
- v16u8 src0, dst0;
- const v16i8 g2br = (v16i8)__msa_fill_w(m->green_to_blue_ |
- (m->green_to_red_ << 16));
- const v16i8 r2b = (v16i8)__msa_fill_w(m->red_to_blue_);
- const v16u8 mask0 = { 1, 255, 1, 255, 5, 255, 5, 255, 9, 255, 9, 255,
- 13, 255, 13, 255 };
- const v16u8 mask1 = { 16, 1, 18, 3, 20, 5, 22, 7, 24, 9, 26, 11,
- 28, 13, 30, 15 };
-
- while (num_pixels >= 8) {
- v16u8 src1, dst1;
- LD_UB2(data, 4, src0, src1);
- TRANSFORM_COLOR_8(src0, src1, dst0, dst1, g2br, r2b, mask0, mask1);
- ST_UB2(dst0, dst1, data, 4);
- data += 8;
- num_pixels -= 8;
- }
- if (num_pixels > 0) {
- if (num_pixels >= 4) {
- src0 = LD_UB(data);
- TRANSFORM_COLOR_4(src0, dst0, g2br, r2b, mask0, mask1);
- ST_UB(dst0, data);
- data += 4;
- num_pixels -= 4;
- }
- if (num_pixels > 0) {
- src0 = LD_UB(data);
- TRANSFORM_COLOR_4(src0, dst0, g2br, r2b, mask0, mask1);
- if (num_pixels == 3) {
- const uint64_t pix_d = __msa_copy_s_d((v2i64)dst0, 0);
- const uint32_t pix_w = __msa_copy_s_w((v4i32)dst0, 2);
- SD(pix_d, data + 0);
- SW(pix_w, data + 2);
- } else if (num_pixels == 2) {
- const uint64_t pix_d = __msa_copy_s_d((v2i64)dst0, 0);
- SD(pix_d, data);
- } else {
- const uint32_t pix_w = __msa_copy_s_w((v4i32)dst0, 0);
- SW(pix_w, data);
- }
- }
- }
-}
-
-static void SubtractGreenFromBlueAndRed_MSA(uint32_t* argb_data,
- int num_pixels) {
- int i;
- uint8_t* ptemp_data = (uint8_t*)argb_data;
- v16u8 src0, dst0, tmp0;
- const v16u8 mask = { 1, 255, 1, 255, 5, 255, 5, 255, 9, 255, 9, 255,
- 13, 255, 13, 255 };
-
- while (num_pixels >= 8) {
- v16u8 src1, dst1, tmp1;
- LD_UB2(ptemp_data, 16, src0, src1);
- VSHF_B2_UB(src0, src1, src1, src0, mask, mask, tmp0, tmp1);
- SUB2(src0, tmp0, src1, tmp1, dst0, dst1);
- ST_UB2(dst0, dst1, ptemp_data, 16);
- ptemp_data += 8 * 4;
- num_pixels -= 8;
- }
- if (num_pixels > 0) {
- if (num_pixels >= 4) {
- src0 = LD_UB(ptemp_data);
- tmp0 = VSHF_UB(src0, src0, mask);
- dst0 = src0 - tmp0;
- ST_UB(dst0, ptemp_data);
- ptemp_data += 4 * 4;
- num_pixels -= 4;
- }
- for (i = 0; i < num_pixels; i++) {
- const uint8_t b = ptemp_data[0];
- const uint8_t g = ptemp_data[1];
- const uint8_t r = ptemp_data[2];
- ptemp_data[0] = (b - g) & 0xff;
- ptemp_data[2] = (r - g) & 0xff;
- ptemp_data += 4;
- }
- }
-}
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void VP8LEncDspInitMSA(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void VP8LEncDspInitMSA(void) {
- VP8LSubtractGreenFromBlueAndRed = SubtractGreenFromBlueAndRed_MSA;
- VP8LTransformColor = TransformColor_MSA;
-}
-
-#else // !WEBP_USE_MSA
-
-WEBP_DSP_INIT_STUB(VP8LEncDspInitMSA)
-
-#endif // WEBP_USE_MSA
diff --git a/contrib/libs/libwebp/dsp/lossless_enc_neon.c b/contrib/libs/libwebp/dsp/lossless_enc_neon.c
deleted file mode 100644
index 07c772c1fa..0000000000
--- a/contrib/libs/libwebp/dsp/lossless_enc_neon.c
+++ /dev/null
@@ -1,144 +0,0 @@
-// Copyright 2015 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// NEON variant of methods for lossless encoder
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_NEON)
-
-#include <arm_neon.h>
-
-#include "./lossless.h"
-#include "./neon.h"
-
-//------------------------------------------------------------------------------
-// Subtract-Green Transform
-
-// vtbl?_u8 are marked unavailable for iOS arm64 with Xcode < 6.3, use
-// non-standard versions there.
-#if defined(__APPLE__) && defined(__aarch64__) && \
- defined(__apple_build_version__) && (__apple_build_version__< 6020037)
-#define USE_VTBLQ
-#endif
-
-#ifdef USE_VTBLQ
-// 255 = byte will be zeroed
-static const uint8_t kGreenShuffle[16] = {
- 1, 255, 1, 255, 5, 255, 5, 255, 9, 255, 9, 255, 13, 255, 13, 255
-};
-
-static WEBP_INLINE uint8x16_t DoGreenShuffle_NEON(const uint8x16_t argb,
- const uint8x16_t shuffle) {
- return vcombine_u8(vtbl1q_u8(argb, vget_low_u8(shuffle)),
- vtbl1q_u8(argb, vget_high_u8(shuffle)));
-}
-#else // !USE_VTBLQ
-// 255 = byte will be zeroed
-static const uint8_t kGreenShuffle[8] = { 1, 255, 1, 255, 5, 255, 5, 255 };
-
-static WEBP_INLINE uint8x16_t DoGreenShuffle_NEON(const uint8x16_t argb,
- const uint8x8_t shuffle) {
- return vcombine_u8(vtbl1_u8(vget_low_u8(argb), shuffle),
- vtbl1_u8(vget_high_u8(argb), shuffle));
-}
-#endif // USE_VTBLQ
-
-static void SubtractGreenFromBlueAndRed_NEON(uint32_t* argb_data,
- int num_pixels) {
- const uint32_t* const end = argb_data + (num_pixels & ~3);
-#ifdef USE_VTBLQ
- const uint8x16_t shuffle = vld1q_u8(kGreenShuffle);
-#else
- const uint8x8_t shuffle = vld1_u8(kGreenShuffle);
-#endif
- for (; argb_data < end; argb_data += 4) {
- const uint8x16_t argb = vld1q_u8((uint8_t*)argb_data);
- const uint8x16_t greens = DoGreenShuffle_NEON(argb, shuffle);
- vst1q_u8((uint8_t*)argb_data, vsubq_u8(argb, greens));
- }
- // fallthrough and finish off with plain-C
- VP8LSubtractGreenFromBlueAndRed_C(argb_data, num_pixels & 3);
-}
-
-//------------------------------------------------------------------------------
-// Color Transform
-
-static void TransformColor_NEON(const VP8LMultipliers* const m,
- uint32_t* argb_data, int num_pixels) {
- // sign-extended multiplying constants, pre-shifted by 6.
-#define CST(X) (((int16_t)(m->X << 8)) >> 6)
- const int16_t rb[8] = {
- CST(green_to_blue_), CST(green_to_red_),
- CST(green_to_blue_), CST(green_to_red_),
- CST(green_to_blue_), CST(green_to_red_),
- CST(green_to_blue_), CST(green_to_red_)
- };
- const int16x8_t mults_rb = vld1q_s16(rb);
- const int16_t b2[8] = {
- 0, CST(red_to_blue_), 0, CST(red_to_blue_),
- 0, CST(red_to_blue_), 0, CST(red_to_blue_),
- };
- const int16x8_t mults_b2 = vld1q_s16(b2);
-#undef CST
-#ifdef USE_VTBLQ
- static const uint8_t kg0g0[16] = {
- 255, 1, 255, 1, 255, 5, 255, 5, 255, 9, 255, 9, 255, 13, 255, 13
- };
- const uint8x16_t shuffle = vld1q_u8(kg0g0);
-#else
- static const uint8_t k0g0g[8] = { 255, 1, 255, 1, 255, 5, 255, 5 };
- const uint8x8_t shuffle = vld1_u8(k0g0g);
-#endif
- const uint32x4_t mask_rb = vdupq_n_u32(0x00ff00ffu); // red-blue masks
- int i;
- for (i = 0; i + 4 <= num_pixels; i += 4) {
- const uint8x16_t in = vld1q_u8((uint8_t*)(argb_data + i));
- // 0 g 0 g
- const uint8x16_t greens = DoGreenShuffle_NEON(in, shuffle);
- // x dr x db1
- const int16x8_t A = vqdmulhq_s16(vreinterpretq_s16_u8(greens), mults_rb);
- // r 0 b 0
- const int16x8_t B = vshlq_n_s16(vreinterpretq_s16_u8(in), 8);
- // x db2 0 0
- const int16x8_t C = vqdmulhq_s16(B, mults_b2);
- // 0 0 x db2
- const uint32x4_t D = vshrq_n_u32(vreinterpretq_u32_s16(C), 16);
- // x dr x db
- const int8x16_t E = vaddq_s8(vreinterpretq_s8_u32(D),
- vreinterpretq_s8_s16(A));
- // 0 dr 0 db
- const uint32x4_t F = vandq_u32(vreinterpretq_u32_s8(E), mask_rb);
- const int8x16_t out = vsubq_s8(vreinterpretq_s8_u8(in),
- vreinterpretq_s8_u32(F));
- vst1q_s8((int8_t*)(argb_data + i), out);
- }
- // fallthrough and finish off with plain-C
- VP8LTransformColor_C(m, argb_data + i, num_pixels - i);
-}
-
-#undef USE_VTBLQ
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void VP8LEncDspInitNEON(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void VP8LEncDspInitNEON(void) {
- VP8LSubtractGreenFromBlueAndRed = SubtractGreenFromBlueAndRed_NEON;
- VP8LTransformColor = TransformColor_NEON;
-}
-
-#else // !WEBP_USE_NEON
-
-WEBP_DSP_INIT_STUB(VP8LEncDspInitNEON)
-
-#endif // WEBP_USE_NEON
diff --git a/contrib/libs/libwebp/dsp/lossless_enc_sse2.c b/contrib/libs/libwebp/dsp/lossless_enc_sse2.c
deleted file mode 100644
index da75aa86bd..0000000000
--- a/contrib/libs/libwebp/dsp/lossless_enc_sse2.c
+++ /dev/null
@@ -1,669 +0,0 @@
-// Copyright 2015 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// SSE2 variant of methods for lossless encoder
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_SSE2)
-#include <assert.h>
-#include <emmintrin.h>
-#include "./lossless.h"
-#include "./common_sse2.h"
-#include "./lossless_common.h"
-
-// For sign-extended multiplying constants, pre-shifted by 5:
-#define CST_5b(X) (((int16_t)((uint16_t)(X) << 8)) >> 5)
-
-//------------------------------------------------------------------------------
-// Subtract-Green Transform
-
-static void SubtractGreenFromBlueAndRed_SSE2(uint32_t* argb_data,
- int num_pixels) {
- int i;
- for (i = 0; i + 4 <= num_pixels; i += 4) {
- const __m128i in = _mm_loadu_si128((__m128i*)&argb_data[i]); // argb
- const __m128i A = _mm_srli_epi16(in, 8); // 0 a 0 g
- const __m128i B = _mm_shufflelo_epi16(A, _MM_SHUFFLE(2, 2, 0, 0));
- const __m128i C = _mm_shufflehi_epi16(B, _MM_SHUFFLE(2, 2, 0, 0)); // 0g0g
- const __m128i out = _mm_sub_epi8(in, C);
- _mm_storeu_si128((__m128i*)&argb_data[i], out);
- }
- // fallthrough and finish off with plain-C
- if (i != num_pixels) {
- VP8LSubtractGreenFromBlueAndRed_C(argb_data + i, num_pixels - i);
- }
-}
-
-//------------------------------------------------------------------------------
-// Color Transform
-
-#define MK_CST_16(HI, LO) \
- _mm_set1_epi32((int)(((uint32_t)(HI) << 16) | ((LO) & 0xffff)))
-
-static void TransformColor_SSE2(const VP8LMultipliers* const m,
- uint32_t* argb_data, int num_pixels) {
- const __m128i mults_rb = MK_CST_16(CST_5b(m->green_to_red_),
- CST_5b(m->green_to_blue_));
- const __m128i mults_b2 = MK_CST_16(CST_5b(m->red_to_blue_), 0);
- const __m128i mask_ag = _mm_set1_epi32(0xff00ff00); // alpha-green masks
- const __m128i mask_rb = _mm_set1_epi32(0x00ff00ff); // red-blue masks
- int i;
- for (i = 0; i + 4 <= num_pixels; i += 4) {
- const __m128i in = _mm_loadu_si128((__m128i*)&argb_data[i]); // argb
- const __m128i A = _mm_and_si128(in, mask_ag); // a 0 g 0
- const __m128i B = _mm_shufflelo_epi16(A, _MM_SHUFFLE(2, 2, 0, 0));
- const __m128i C = _mm_shufflehi_epi16(B, _MM_SHUFFLE(2, 2, 0, 0)); // g0g0
- const __m128i D = _mm_mulhi_epi16(C, mults_rb); // x dr x db1
- const __m128i E = _mm_slli_epi16(in, 8); // r 0 b 0
- const __m128i F = _mm_mulhi_epi16(E, mults_b2); // x db2 0 0
- const __m128i G = _mm_srli_epi32(F, 16); // 0 0 x db2
- const __m128i H = _mm_add_epi8(G, D); // x dr x db
- const __m128i I = _mm_and_si128(H, mask_rb); // 0 dr 0 db
- const __m128i out = _mm_sub_epi8(in, I);
- _mm_storeu_si128((__m128i*)&argb_data[i], out);
- }
- // fallthrough and finish off with plain-C
- if (i != num_pixels) {
- VP8LTransformColor_C(m, argb_data + i, num_pixels - i);
- }
-}
-
-//------------------------------------------------------------------------------
-#define SPAN 8
-static void CollectColorBlueTransforms_SSE2(const uint32_t* argb, int stride,
- int tile_width, int tile_height,
- int green_to_blue, int red_to_blue,
- int histo[]) {
- const __m128i mults_r = MK_CST_16(CST_5b(red_to_blue), 0);
- const __m128i mults_g = MK_CST_16(0, CST_5b(green_to_blue));
- const __m128i mask_g = _mm_set1_epi32(0x00ff00); // green mask
- const __m128i mask_b = _mm_set1_epi32(0x0000ff); // blue mask
- int y;
- for (y = 0; y < tile_height; ++y) {
- const uint32_t* const src = argb + y * stride;
- int i, x;
- for (x = 0; x + SPAN <= tile_width; x += SPAN) {
- uint16_t values[SPAN];
- const __m128i in0 = _mm_loadu_si128((__m128i*)&src[x + 0]);
- const __m128i in1 = _mm_loadu_si128((__m128i*)&src[x + SPAN / 2]);
- const __m128i A0 = _mm_slli_epi16(in0, 8); // r 0 | b 0
- const __m128i A1 = _mm_slli_epi16(in1, 8);
- const __m128i B0 = _mm_and_si128(in0, mask_g); // 0 0 | g 0
- const __m128i B1 = _mm_and_si128(in1, mask_g);
- const __m128i C0 = _mm_mulhi_epi16(A0, mults_r); // x db | 0 0
- const __m128i C1 = _mm_mulhi_epi16(A1, mults_r);
- const __m128i D0 = _mm_mulhi_epi16(B0, mults_g); // 0 0 | x db
- const __m128i D1 = _mm_mulhi_epi16(B1, mults_g);
- const __m128i E0 = _mm_sub_epi8(in0, D0); // x x | x b'
- const __m128i E1 = _mm_sub_epi8(in1, D1);
- const __m128i F0 = _mm_srli_epi32(C0, 16); // 0 0 | x db
- const __m128i F1 = _mm_srli_epi32(C1, 16);
- const __m128i G0 = _mm_sub_epi8(E0, F0); // 0 0 | x b'
- const __m128i G1 = _mm_sub_epi8(E1, F1);
- const __m128i H0 = _mm_and_si128(G0, mask_b); // 0 0 | 0 b
- const __m128i H1 = _mm_and_si128(G1, mask_b);
- const __m128i I = _mm_packs_epi32(H0, H1); // 0 b' | 0 b'
- _mm_storeu_si128((__m128i*)values, I);
- for (i = 0; i < SPAN; ++i) ++histo[values[i]];
- }
- }
- {
- const int left_over = tile_width & (SPAN - 1);
- if (left_over > 0) {
- VP8LCollectColorBlueTransforms_C(argb + tile_width - left_over, stride,
- left_over, tile_height,
- green_to_blue, red_to_blue, histo);
- }
- }
-}
-
-static void CollectColorRedTransforms_SSE2(const uint32_t* argb, int stride,
- int tile_width, int tile_height,
- int green_to_red, int histo[]) {
- const __m128i mults_g = MK_CST_16(0, CST_5b(green_to_red));
- const __m128i mask_g = _mm_set1_epi32(0x00ff00); // green mask
- const __m128i mask = _mm_set1_epi32(0xff);
-
- int y;
- for (y = 0; y < tile_height; ++y) {
- const uint32_t* const src = argb + y * stride;
- int i, x;
- for (x = 0; x + SPAN <= tile_width; x += SPAN) {
- uint16_t values[SPAN];
- const __m128i in0 = _mm_loadu_si128((__m128i*)&src[x + 0]);
- const __m128i in1 = _mm_loadu_si128((__m128i*)&src[x + SPAN / 2]);
- const __m128i A0 = _mm_and_si128(in0, mask_g); // 0 0 | g 0
- const __m128i A1 = _mm_and_si128(in1, mask_g);
- const __m128i B0 = _mm_srli_epi32(in0, 16); // 0 0 | x r
- const __m128i B1 = _mm_srli_epi32(in1, 16);
- const __m128i C0 = _mm_mulhi_epi16(A0, mults_g); // 0 0 | x dr
- const __m128i C1 = _mm_mulhi_epi16(A1, mults_g);
- const __m128i E0 = _mm_sub_epi8(B0, C0); // x x | x r'
- const __m128i E1 = _mm_sub_epi8(B1, C1);
- const __m128i F0 = _mm_and_si128(E0, mask); // 0 0 | 0 r'
- const __m128i F1 = _mm_and_si128(E1, mask);
- const __m128i I = _mm_packs_epi32(F0, F1);
- _mm_storeu_si128((__m128i*)values, I);
- for (i = 0; i < SPAN; ++i) ++histo[values[i]];
- }
- }
- {
- const int left_over = tile_width & (SPAN - 1);
- if (left_over > 0) {
- VP8LCollectColorRedTransforms_C(argb + tile_width - left_over, stride,
- left_over, tile_height,
- green_to_red, histo);
- }
- }
-}
-#undef SPAN
-#undef MK_CST_16
-
-//------------------------------------------------------------------------------
-
-// Note we are adding uint32_t's as *signed* int32's (using _mm_add_epi32). But
-// that's ok since the histogram values are less than 1<<28 (max picture size).
-#define LINE_SIZE 16 // 8 or 16
-static void AddVector_SSE2(const uint32_t* a, const uint32_t* b, uint32_t* out,
- int size) {
- int i;
- for (i = 0; i + LINE_SIZE <= size; i += LINE_SIZE) {
- const __m128i a0 = _mm_loadu_si128((const __m128i*)&a[i + 0]);
- const __m128i a1 = _mm_loadu_si128((const __m128i*)&a[i + 4]);
-#if (LINE_SIZE == 16)
- const __m128i a2 = _mm_loadu_si128((const __m128i*)&a[i + 8]);
- const __m128i a3 = _mm_loadu_si128((const __m128i*)&a[i + 12]);
-#endif
- const __m128i b0 = _mm_loadu_si128((const __m128i*)&b[i + 0]);
- const __m128i b1 = _mm_loadu_si128((const __m128i*)&b[i + 4]);
-#if (LINE_SIZE == 16)
- const __m128i b2 = _mm_loadu_si128((const __m128i*)&b[i + 8]);
- const __m128i b3 = _mm_loadu_si128((const __m128i*)&b[i + 12]);
-#endif
- _mm_storeu_si128((__m128i*)&out[i + 0], _mm_add_epi32(a0, b0));
- _mm_storeu_si128((__m128i*)&out[i + 4], _mm_add_epi32(a1, b1));
-#if (LINE_SIZE == 16)
- _mm_storeu_si128((__m128i*)&out[i + 8], _mm_add_epi32(a2, b2));
- _mm_storeu_si128((__m128i*)&out[i + 12], _mm_add_epi32(a3, b3));
-#endif
- }
- for (; i < size; ++i) {
- out[i] = a[i] + b[i];
- }
-}
-
-static void AddVectorEq_SSE2(const uint32_t* a, uint32_t* out, int size) {
- int i;
- for (i = 0; i + LINE_SIZE <= size; i += LINE_SIZE) {
- const __m128i a0 = _mm_loadu_si128((const __m128i*)&a[i + 0]);
- const __m128i a1 = _mm_loadu_si128((const __m128i*)&a[i + 4]);
-#if (LINE_SIZE == 16)
- const __m128i a2 = _mm_loadu_si128((const __m128i*)&a[i + 8]);
- const __m128i a3 = _mm_loadu_si128((const __m128i*)&a[i + 12]);
-#endif
- const __m128i b0 = _mm_loadu_si128((const __m128i*)&out[i + 0]);
- const __m128i b1 = _mm_loadu_si128((const __m128i*)&out[i + 4]);
-#if (LINE_SIZE == 16)
- const __m128i b2 = _mm_loadu_si128((const __m128i*)&out[i + 8]);
- const __m128i b3 = _mm_loadu_si128((const __m128i*)&out[i + 12]);
-#endif
- _mm_storeu_si128((__m128i*)&out[i + 0], _mm_add_epi32(a0, b0));
- _mm_storeu_si128((__m128i*)&out[i + 4], _mm_add_epi32(a1, b1));
-#if (LINE_SIZE == 16)
- _mm_storeu_si128((__m128i*)&out[i + 8], _mm_add_epi32(a2, b2));
- _mm_storeu_si128((__m128i*)&out[i + 12], _mm_add_epi32(a3, b3));
-#endif
- }
- for (; i < size; ++i) {
- out[i] += a[i];
- }
-}
-#undef LINE_SIZE
-
-//------------------------------------------------------------------------------
-// Entropy
-
-// TODO(https://crbug.com/webp/499): this function produces different results
-// from the C code due to use of double/float resulting in output differences
-// when compared to -noasm.
-#if !(defined(WEBP_HAVE_SLOW_CLZ_CTZ) || defined(__i386__) || defined(_M_IX86))
-
-static float CombinedShannonEntropy_SSE2(const int X[256], const int Y[256]) {
- int i;
- double retval = 0.;
- int sumX = 0, sumXY = 0;
- const __m128i zero = _mm_setzero_si128();
-
- for (i = 0; i < 256; i += 16) {
- const __m128i x0 = _mm_loadu_si128((const __m128i*)(X + i + 0));
- const __m128i y0 = _mm_loadu_si128((const __m128i*)(Y + i + 0));
- const __m128i x1 = _mm_loadu_si128((const __m128i*)(X + i + 4));
- const __m128i y1 = _mm_loadu_si128((const __m128i*)(Y + i + 4));
- const __m128i x2 = _mm_loadu_si128((const __m128i*)(X + i + 8));
- const __m128i y2 = _mm_loadu_si128((const __m128i*)(Y + i + 8));
- const __m128i x3 = _mm_loadu_si128((const __m128i*)(X + i + 12));
- const __m128i y3 = _mm_loadu_si128((const __m128i*)(Y + i + 12));
- const __m128i x4 = _mm_packs_epi16(_mm_packs_epi32(x0, x1),
- _mm_packs_epi32(x2, x3));
- const __m128i y4 = _mm_packs_epi16(_mm_packs_epi32(y0, y1),
- _mm_packs_epi32(y2, y3));
- const int32_t mx = _mm_movemask_epi8(_mm_cmpgt_epi8(x4, zero));
- int32_t my = _mm_movemask_epi8(_mm_cmpgt_epi8(y4, zero)) | mx;
- while (my) {
- const int32_t j = BitsCtz(my);
- int xy;
- if ((mx >> j) & 1) {
- const int x = X[i + j];
- sumXY += x;
- retval -= VP8LFastSLog2(x);
- }
- xy = X[i + j] + Y[i + j];
- sumX += xy;
- retval -= VP8LFastSLog2(xy);
- my &= my - 1;
- }
- }
- retval += VP8LFastSLog2(sumX) + VP8LFastSLog2(sumXY);
- return (float)retval;
-}
-
-#else
-
-#define DONT_USE_COMBINED_SHANNON_ENTROPY_SSE2_FUNC // won't be faster
-
-#endif
-
-//------------------------------------------------------------------------------
-
-static int VectorMismatch_SSE2(const uint32_t* const array1,
- const uint32_t* const array2, int length) {
- int match_len;
-
- if (length >= 12) {
- __m128i A0 = _mm_loadu_si128((const __m128i*)&array1[0]);
- __m128i A1 = _mm_loadu_si128((const __m128i*)&array2[0]);
- match_len = 0;
- do {
- // Loop unrolling and early load both provide a speedup of 10% for the
- // current function. Also, max_limit can be MAX_LENGTH=4096 at most.
- const __m128i cmpA = _mm_cmpeq_epi32(A0, A1);
- const __m128i B0 =
- _mm_loadu_si128((const __m128i*)&array1[match_len + 4]);
- const __m128i B1 =
- _mm_loadu_si128((const __m128i*)&array2[match_len + 4]);
- if (_mm_movemask_epi8(cmpA) != 0xffff) break;
- match_len += 4;
-
- {
- const __m128i cmpB = _mm_cmpeq_epi32(B0, B1);
- A0 = _mm_loadu_si128((const __m128i*)&array1[match_len + 4]);
- A1 = _mm_loadu_si128((const __m128i*)&array2[match_len + 4]);
- if (_mm_movemask_epi8(cmpB) != 0xffff) break;
- match_len += 4;
- }
- } while (match_len + 12 < length);
- } else {
- match_len = 0;
- // Unroll the potential first two loops.
- if (length >= 4 &&
- _mm_movemask_epi8(_mm_cmpeq_epi32(
- _mm_loadu_si128((const __m128i*)&array1[0]),
- _mm_loadu_si128((const __m128i*)&array2[0]))) == 0xffff) {
- match_len = 4;
- if (length >= 8 &&
- _mm_movemask_epi8(_mm_cmpeq_epi32(
- _mm_loadu_si128((const __m128i*)&array1[4]),
- _mm_loadu_si128((const __m128i*)&array2[4]))) == 0xffff) {
- match_len = 8;
- }
- }
- }
-
- while (match_len < length && array1[match_len] == array2[match_len]) {
- ++match_len;
- }
- return match_len;
-}
-
-// Bundles multiple (1, 2, 4 or 8) pixels into a single pixel.
-static void BundleColorMap_SSE2(const uint8_t* const row, int width, int xbits,
- uint32_t* dst) {
- int x;
- assert(xbits >= 0);
- assert(xbits <= 3);
- switch (xbits) {
- case 0: {
- const __m128i ff = _mm_set1_epi16((short)0xff00);
- const __m128i zero = _mm_setzero_si128();
- // Store 0xff000000 | (row[x] << 8).
- for (x = 0; x + 16 <= width; x += 16, dst += 16) {
- const __m128i in = _mm_loadu_si128((const __m128i*)&row[x]);
- const __m128i in_lo = _mm_unpacklo_epi8(zero, in);
- const __m128i dst0 = _mm_unpacklo_epi16(in_lo, ff);
- const __m128i dst1 = _mm_unpackhi_epi16(in_lo, ff);
- const __m128i in_hi = _mm_unpackhi_epi8(zero, in);
- const __m128i dst2 = _mm_unpacklo_epi16(in_hi, ff);
- const __m128i dst3 = _mm_unpackhi_epi16(in_hi, ff);
- _mm_storeu_si128((__m128i*)&dst[0], dst0);
- _mm_storeu_si128((__m128i*)&dst[4], dst1);
- _mm_storeu_si128((__m128i*)&dst[8], dst2);
- _mm_storeu_si128((__m128i*)&dst[12], dst3);
- }
- break;
- }
- case 1: {
- const __m128i ff = _mm_set1_epi16((short)0xff00);
- const __m128i mul = _mm_set1_epi16(0x110);
- for (x = 0; x + 16 <= width; x += 16, dst += 8) {
- // 0a0b | (where a/b are 4 bits).
- const __m128i in = _mm_loadu_si128((const __m128i*)&row[x]);
- const __m128i tmp = _mm_mullo_epi16(in, mul); // aba0
- const __m128i pack = _mm_and_si128(tmp, ff); // ab00
- const __m128i dst0 = _mm_unpacklo_epi16(pack, ff);
- const __m128i dst1 = _mm_unpackhi_epi16(pack, ff);
- _mm_storeu_si128((__m128i*)&dst[0], dst0);
- _mm_storeu_si128((__m128i*)&dst[4], dst1);
- }
- break;
- }
- case 2: {
- const __m128i mask_or = _mm_set1_epi32(0xff000000);
- const __m128i mul_cst = _mm_set1_epi16(0x0104);
- const __m128i mask_mul = _mm_set1_epi16(0x0f00);
- for (x = 0; x + 16 <= width; x += 16, dst += 4) {
- // 000a000b000c000d | (where a/b/c/d are 2 bits).
- const __m128i in = _mm_loadu_si128((const __m128i*)&row[x]);
- const __m128i mul = _mm_mullo_epi16(in, mul_cst); // 00ab00b000cd00d0
- const __m128i tmp = _mm_and_si128(mul, mask_mul); // 00ab000000cd0000
- const __m128i shift = _mm_srli_epi32(tmp, 12); // 00000000ab000000
- const __m128i pack = _mm_or_si128(shift, tmp); // 00000000abcd0000
- // Convert to 0xff00**00.
- const __m128i res = _mm_or_si128(pack, mask_or);
- _mm_storeu_si128((__m128i*)dst, res);
- }
- break;
- }
- default: {
- assert(xbits == 3);
- for (x = 0; x + 16 <= width; x += 16, dst += 2) {
- // 0000000a00000000b... | (where a/b are 1 bit).
- const __m128i in = _mm_loadu_si128((const __m128i*)&row[x]);
- const __m128i shift = _mm_slli_epi64(in, 7);
- const uint32_t move = _mm_movemask_epi8(shift);
- dst[0] = 0xff000000 | ((move & 0xff) << 8);
- dst[1] = 0xff000000 | (move & 0xff00);
- }
- break;
- }
- }
- if (x != width) {
- VP8LBundleColorMap_C(row + x, width - x, xbits, dst);
- }
-}
-
-//------------------------------------------------------------------------------
-// Batch version of Predictor Transform subtraction
-
-static WEBP_INLINE void Average2_m128i(const __m128i* const a0,
- const __m128i* const a1,
- __m128i* const avg) {
- // (a + b) >> 1 = ((a + b + 1) >> 1) - ((a ^ b) & 1)
- const __m128i ones = _mm_set1_epi8(1);
- const __m128i avg1 = _mm_avg_epu8(*a0, *a1);
- const __m128i one = _mm_and_si128(_mm_xor_si128(*a0, *a1), ones);
- *avg = _mm_sub_epi8(avg1, one);
-}
-
-// Predictor0: ARGB_BLACK.
-static void PredictorSub0_SSE2(const uint32_t* in, const uint32_t* upper,
- int num_pixels, uint32_t* out) {
- int i;
- const __m128i black = _mm_set1_epi32(ARGB_BLACK);
- for (i = 0; i + 4 <= num_pixels; i += 4) {
- const __m128i src = _mm_loadu_si128((const __m128i*)&in[i]);
- const __m128i res = _mm_sub_epi8(src, black);
- _mm_storeu_si128((__m128i*)&out[i], res);
- }
- if (i != num_pixels) {
- VP8LPredictorsSub_C[0](in + i, NULL, num_pixels - i, out + i);
- }
- (void)upper;
-}
-
-#define GENERATE_PREDICTOR_1(X, IN) \
- static void PredictorSub##X##_SSE2(const uint32_t* const in, \
- const uint32_t* const upper, \
- int num_pixels, uint32_t* const out) { \
- int i; \
- for (i = 0; i + 4 <= num_pixels; i += 4) { \
- const __m128i src = _mm_loadu_si128((const __m128i*)&in[i]); \
- const __m128i pred = _mm_loadu_si128((const __m128i*)&(IN)); \
- const __m128i res = _mm_sub_epi8(src, pred); \
- _mm_storeu_si128((__m128i*)&out[i], res); \
- } \
- if (i != num_pixels) { \
- VP8LPredictorsSub_C[(X)](in + i, WEBP_OFFSET_PTR(upper, i), \
- num_pixels - i, out + i); \
- } \
- }
-
-GENERATE_PREDICTOR_1(1, in[i - 1]) // Predictor1: L
-GENERATE_PREDICTOR_1(2, upper[i]) // Predictor2: T
-GENERATE_PREDICTOR_1(3, upper[i + 1]) // Predictor3: TR
-GENERATE_PREDICTOR_1(4, upper[i - 1]) // Predictor4: TL
-#undef GENERATE_PREDICTOR_1
-
-// Predictor5: avg2(avg2(L, TR), T)
-static void PredictorSub5_SSE2(const uint32_t* in, const uint32_t* upper,
- int num_pixels, uint32_t* out) {
- int i;
- for (i = 0; i + 4 <= num_pixels; i += 4) {
- const __m128i L = _mm_loadu_si128((const __m128i*)&in[i - 1]);
- const __m128i T = _mm_loadu_si128((const __m128i*)&upper[i]);
- const __m128i TR = _mm_loadu_si128((const __m128i*)&upper[i + 1]);
- const __m128i src = _mm_loadu_si128((const __m128i*)&in[i]);
- __m128i avg, pred, res;
- Average2_m128i(&L, &TR, &avg);
- Average2_m128i(&avg, &T, &pred);
- res = _mm_sub_epi8(src, pred);
- _mm_storeu_si128((__m128i*)&out[i], res);
- }
- if (i != num_pixels) {
- VP8LPredictorsSub_C[5](in + i, upper + i, num_pixels - i, out + i);
- }
-}
-
-#define GENERATE_PREDICTOR_2(X, A, B) \
-static void PredictorSub##X##_SSE2(const uint32_t* in, const uint32_t* upper, \
- int num_pixels, uint32_t* out) { \
- int i; \
- for (i = 0; i + 4 <= num_pixels; i += 4) { \
- const __m128i tA = _mm_loadu_si128((const __m128i*)&(A)); \
- const __m128i tB = _mm_loadu_si128((const __m128i*)&(B)); \
- const __m128i src = _mm_loadu_si128((const __m128i*)&in[i]); \
- __m128i pred, res; \
- Average2_m128i(&tA, &tB, &pred); \
- res = _mm_sub_epi8(src, pred); \
- _mm_storeu_si128((__m128i*)&out[i], res); \
- } \
- if (i != num_pixels) { \
- VP8LPredictorsSub_C[(X)](in + i, upper + i, num_pixels - i, out + i); \
- } \
-}
-
-GENERATE_PREDICTOR_2(6, in[i - 1], upper[i - 1]) // Predictor6: avg(L, TL)
-GENERATE_PREDICTOR_2(7, in[i - 1], upper[i]) // Predictor7: avg(L, T)
-GENERATE_PREDICTOR_2(8, upper[i - 1], upper[i]) // Predictor8: avg(TL, T)
-GENERATE_PREDICTOR_2(9, upper[i], upper[i + 1]) // Predictor9: average(T, TR)
-#undef GENERATE_PREDICTOR_2
-
-// Predictor10: avg(avg(L,TL), avg(T, TR)).
-static void PredictorSub10_SSE2(const uint32_t* in, const uint32_t* upper,
- int num_pixels, uint32_t* out) {
- int i;
- for (i = 0; i + 4 <= num_pixels; i += 4) {
- const __m128i L = _mm_loadu_si128((const __m128i*)&in[i - 1]);
- const __m128i src = _mm_loadu_si128((const __m128i*)&in[i]);
- const __m128i TL = _mm_loadu_si128((const __m128i*)&upper[i - 1]);
- const __m128i T = _mm_loadu_si128((const __m128i*)&upper[i]);
- const __m128i TR = _mm_loadu_si128((const __m128i*)&upper[i + 1]);
- __m128i avgTTR, avgLTL, avg, res;
- Average2_m128i(&T, &TR, &avgTTR);
- Average2_m128i(&L, &TL, &avgLTL);
- Average2_m128i(&avgTTR, &avgLTL, &avg);
- res = _mm_sub_epi8(src, avg);
- _mm_storeu_si128((__m128i*)&out[i], res);
- }
- if (i != num_pixels) {
- VP8LPredictorsSub_C[10](in + i, upper + i, num_pixels - i, out + i);
- }
-}
-
-// Predictor11: select.
-static void GetSumAbsDiff32_SSE2(const __m128i* const A, const __m128i* const B,
- __m128i* const out) {
- // We can unpack with any value on the upper 32 bits, provided it's the same
- // on both operands (to that their sum of abs diff is zero). Here we use *A.
- const __m128i A_lo = _mm_unpacklo_epi32(*A, *A);
- const __m128i B_lo = _mm_unpacklo_epi32(*B, *A);
- const __m128i A_hi = _mm_unpackhi_epi32(*A, *A);
- const __m128i B_hi = _mm_unpackhi_epi32(*B, *A);
- const __m128i s_lo = _mm_sad_epu8(A_lo, B_lo);
- const __m128i s_hi = _mm_sad_epu8(A_hi, B_hi);
- *out = _mm_packs_epi32(s_lo, s_hi);
-}
-
-static void PredictorSub11_SSE2(const uint32_t* in, const uint32_t* upper,
- int num_pixels, uint32_t* out) {
- int i;
- for (i = 0; i + 4 <= num_pixels; i += 4) {
- const __m128i L = _mm_loadu_si128((const __m128i*)&in[i - 1]);
- const __m128i T = _mm_loadu_si128((const __m128i*)&upper[i]);
- const __m128i TL = _mm_loadu_si128((const __m128i*)&upper[i - 1]);
- const __m128i src = _mm_loadu_si128((const __m128i*)&in[i]);
- __m128i pa, pb;
- GetSumAbsDiff32_SSE2(&T, &TL, &pa); // pa = sum |T-TL|
- GetSumAbsDiff32_SSE2(&L, &TL, &pb); // pb = sum |L-TL|
- {
- const __m128i mask = _mm_cmpgt_epi32(pb, pa);
- const __m128i A = _mm_and_si128(mask, L);
- const __m128i B = _mm_andnot_si128(mask, T);
- const __m128i pred = _mm_or_si128(A, B); // pred = (L > T)? L : T
- const __m128i res = _mm_sub_epi8(src, pred);
- _mm_storeu_si128((__m128i*)&out[i], res);
- }
- }
- if (i != num_pixels) {
- VP8LPredictorsSub_C[11](in + i, upper + i, num_pixels - i, out + i);
- }
-}
-
-// Predictor12: ClampedSubSubtractFull.
-static void PredictorSub12_SSE2(const uint32_t* in, const uint32_t* upper,
- int num_pixels, uint32_t* out) {
- int i;
- const __m128i zero = _mm_setzero_si128();
- for (i = 0; i + 4 <= num_pixels; i += 4) {
- const __m128i src = _mm_loadu_si128((const __m128i*)&in[i]);
- const __m128i L = _mm_loadu_si128((const __m128i*)&in[i - 1]);
- const __m128i L_lo = _mm_unpacklo_epi8(L, zero);
- const __m128i L_hi = _mm_unpackhi_epi8(L, zero);
- const __m128i T = _mm_loadu_si128((const __m128i*)&upper[i]);
- const __m128i T_lo = _mm_unpacklo_epi8(T, zero);
- const __m128i T_hi = _mm_unpackhi_epi8(T, zero);
- const __m128i TL = _mm_loadu_si128((const __m128i*)&upper[i - 1]);
- const __m128i TL_lo = _mm_unpacklo_epi8(TL, zero);
- const __m128i TL_hi = _mm_unpackhi_epi8(TL, zero);
- const __m128i diff_lo = _mm_sub_epi16(T_lo, TL_lo);
- const __m128i diff_hi = _mm_sub_epi16(T_hi, TL_hi);
- const __m128i pred_lo = _mm_add_epi16(L_lo, diff_lo);
- const __m128i pred_hi = _mm_add_epi16(L_hi, diff_hi);
- const __m128i pred = _mm_packus_epi16(pred_lo, pred_hi);
- const __m128i res = _mm_sub_epi8(src, pred);
- _mm_storeu_si128((__m128i*)&out[i], res);
- }
- if (i != num_pixels) {
- VP8LPredictorsSub_C[12](in + i, upper + i, num_pixels - i, out + i);
- }
-}
-
-// Predictors13: ClampedAddSubtractHalf
-static void PredictorSub13_SSE2(const uint32_t* in, const uint32_t* upper,
- int num_pixels, uint32_t* out) {
- int i;
- const __m128i zero = _mm_setzero_si128();
- for (i = 0; i + 2 <= num_pixels; i += 2) {
- // we can only process two pixels at a time
- const __m128i L = _mm_loadl_epi64((const __m128i*)&in[i - 1]);
- const __m128i src = _mm_loadl_epi64((const __m128i*)&in[i]);
- const __m128i T = _mm_loadl_epi64((const __m128i*)&upper[i]);
- const __m128i TL = _mm_loadl_epi64((const __m128i*)&upper[i - 1]);
- const __m128i L_lo = _mm_unpacklo_epi8(L, zero);
- const __m128i T_lo = _mm_unpacklo_epi8(T, zero);
- const __m128i TL_lo = _mm_unpacklo_epi8(TL, zero);
- const __m128i sum = _mm_add_epi16(T_lo, L_lo);
- const __m128i avg = _mm_srli_epi16(sum, 1);
- const __m128i A1 = _mm_sub_epi16(avg, TL_lo);
- const __m128i bit_fix = _mm_cmpgt_epi16(TL_lo, avg);
- const __m128i A2 = _mm_sub_epi16(A1, bit_fix);
- const __m128i A3 = _mm_srai_epi16(A2, 1);
- const __m128i A4 = _mm_add_epi16(avg, A3);
- const __m128i pred = _mm_packus_epi16(A4, A4);
- const __m128i res = _mm_sub_epi8(src, pred);
- _mm_storel_epi64((__m128i*)&out[i], res);
- }
- if (i != num_pixels) {
- VP8LPredictorsSub_C[13](in + i, upper + i, num_pixels - i, out + i);
- }
-}
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void VP8LEncDspInitSSE2(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void VP8LEncDspInitSSE2(void) {
- VP8LSubtractGreenFromBlueAndRed = SubtractGreenFromBlueAndRed_SSE2;
- VP8LTransformColor = TransformColor_SSE2;
- VP8LCollectColorBlueTransforms = CollectColorBlueTransforms_SSE2;
- VP8LCollectColorRedTransforms = CollectColorRedTransforms_SSE2;
- VP8LAddVector = AddVector_SSE2;
- VP8LAddVectorEq = AddVectorEq_SSE2;
-#if !defined(DONT_USE_COMBINED_SHANNON_ENTROPY_SSE2_FUNC)
- VP8LCombinedShannonEntropy = CombinedShannonEntropy_SSE2;
-#endif
- VP8LVectorMismatch = VectorMismatch_SSE2;
- VP8LBundleColorMap = BundleColorMap_SSE2;
-
- VP8LPredictorsSub[0] = PredictorSub0_SSE2;
- VP8LPredictorsSub[1] = PredictorSub1_SSE2;
- VP8LPredictorsSub[2] = PredictorSub2_SSE2;
- VP8LPredictorsSub[3] = PredictorSub3_SSE2;
- VP8LPredictorsSub[4] = PredictorSub4_SSE2;
- VP8LPredictorsSub[5] = PredictorSub5_SSE2;
- VP8LPredictorsSub[6] = PredictorSub6_SSE2;
- VP8LPredictorsSub[7] = PredictorSub7_SSE2;
- VP8LPredictorsSub[8] = PredictorSub8_SSE2;
- VP8LPredictorsSub[9] = PredictorSub9_SSE2;
- VP8LPredictorsSub[10] = PredictorSub10_SSE2;
- VP8LPredictorsSub[11] = PredictorSub11_SSE2;
- VP8LPredictorsSub[12] = PredictorSub12_SSE2;
- VP8LPredictorsSub[13] = PredictorSub13_SSE2;
- VP8LPredictorsSub[14] = PredictorSub0_SSE2; // <- padding security sentinels
- VP8LPredictorsSub[15] = PredictorSub0_SSE2;
-}
-
-#else // !WEBP_USE_SSE2
-
-WEBP_DSP_INIT_STUB(VP8LEncDspInitSSE2)
-
-#endif // WEBP_USE_SSE2
diff --git a/contrib/libs/libwebp/dsp/lossless_enc_sse41.c b/contrib/libs/libwebp/dsp/lossless_enc_sse41.c
deleted file mode 100644
index 1fdc7b482a..0000000000
--- a/contrib/libs/libwebp/dsp/lossless_enc_sse41.c
+++ /dev/null
@@ -1,155 +0,0 @@
-// Copyright 2015 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// SSE4.1 variant of methods for lossless encoder
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_SSE41)
-#include <assert.h>
-#include <smmintrin.h>
-#include "./lossless.h"
-
-// For sign-extended multiplying constants, pre-shifted by 5:
-#define CST_5b(X) (((int16_t)((uint16_t)(X) << 8)) >> 5)
-
-//------------------------------------------------------------------------------
-// Subtract-Green Transform
-
-static void SubtractGreenFromBlueAndRed_SSE41(uint32_t* argb_data,
- int num_pixels) {
- int i;
- const __m128i kCstShuffle = _mm_set_epi8(-1, 13, -1, 13, -1, 9, -1, 9,
- -1, 5, -1, 5, -1, 1, -1, 1);
- for (i = 0; i + 4 <= num_pixels; i += 4) {
- const __m128i in = _mm_loadu_si128((__m128i*)&argb_data[i]);
- const __m128i in_0g0g = _mm_shuffle_epi8(in, kCstShuffle);
- const __m128i out = _mm_sub_epi8(in, in_0g0g);
- _mm_storeu_si128((__m128i*)&argb_data[i], out);
- }
- // fallthrough and finish off with plain-C
- if (i != num_pixels) {
- VP8LSubtractGreenFromBlueAndRed_C(argb_data + i, num_pixels - i);
- }
-}
-
-//------------------------------------------------------------------------------
-// Color Transform
-
-#define MK_CST_16(HI, LO) \
- _mm_set1_epi32((int)(((uint32_t)(HI) << 16) | ((LO) & 0xffff)))
-
-static void CollectColorBlueTransforms_SSE41(const uint32_t* argb, int stride,
- int tile_width, int tile_height,
- int green_to_blue, int red_to_blue,
- int histo[]) {
- const __m128i mult =
- MK_CST_16(CST_5b(red_to_blue) + 256,CST_5b(green_to_blue));
- const __m128i perm =
- _mm_setr_epi8(-1, 1, -1, 2, -1, 5, -1, 6, -1, 9, -1, 10, -1, 13, -1, 14);
- if (tile_width >= 4) {
- int y;
- for (y = 0; y < tile_height; ++y) {
- const uint32_t* const src = argb + y * stride;
- const __m128i A1 = _mm_loadu_si128((const __m128i*)src);
- const __m128i B1 = _mm_shuffle_epi8(A1, perm);
- const __m128i C1 = _mm_mulhi_epi16(B1, mult);
- const __m128i D1 = _mm_sub_epi16(A1, C1);
- __m128i E = _mm_add_epi16(_mm_srli_epi32(D1, 16), D1);
- int x;
- for (x = 4; x + 4 <= tile_width; x += 4) {
- const __m128i A2 = _mm_loadu_si128((const __m128i*)(src + x));
- __m128i B2, C2, D2;
- ++histo[_mm_extract_epi8(E, 0)];
- B2 = _mm_shuffle_epi8(A2, perm);
- ++histo[_mm_extract_epi8(E, 4)];
- C2 = _mm_mulhi_epi16(B2, mult);
- ++histo[_mm_extract_epi8(E, 8)];
- D2 = _mm_sub_epi16(A2, C2);
- ++histo[_mm_extract_epi8(E, 12)];
- E = _mm_add_epi16(_mm_srli_epi32(D2, 16), D2);
- }
- ++histo[_mm_extract_epi8(E, 0)];
- ++histo[_mm_extract_epi8(E, 4)];
- ++histo[_mm_extract_epi8(E, 8)];
- ++histo[_mm_extract_epi8(E, 12)];
- }
- }
- {
- const int left_over = tile_width & 3;
- if (left_over > 0) {
- VP8LCollectColorBlueTransforms_C(argb + tile_width - left_over, stride,
- left_over, tile_height,
- green_to_blue, red_to_blue, histo);
- }
- }
-}
-
-static void CollectColorRedTransforms_SSE41(const uint32_t* argb, int stride,
- int tile_width, int tile_height,
- int green_to_red, int histo[]) {
-
- const __m128i mult = MK_CST_16(0, CST_5b(green_to_red));
- const __m128i mask_g = _mm_set1_epi32(0x0000ff00);
- if (tile_width >= 4) {
- int y;
- for (y = 0; y < tile_height; ++y) {
- const uint32_t* const src = argb + y * stride;
- const __m128i A1 = _mm_loadu_si128((const __m128i*)src);
- const __m128i B1 = _mm_and_si128(A1, mask_g);
- const __m128i C1 = _mm_madd_epi16(B1, mult);
- __m128i D = _mm_sub_epi16(A1, C1);
- int x;
- for (x = 4; x + 4 <= tile_width; x += 4) {
- const __m128i A2 = _mm_loadu_si128((const __m128i*)(src + x));
- __m128i B2, C2;
- ++histo[_mm_extract_epi8(D, 2)];
- B2 = _mm_and_si128(A2, mask_g);
- ++histo[_mm_extract_epi8(D, 6)];
- C2 = _mm_madd_epi16(B2, mult);
- ++histo[_mm_extract_epi8(D, 10)];
- ++histo[_mm_extract_epi8(D, 14)];
- D = _mm_sub_epi16(A2, C2);
- }
- ++histo[_mm_extract_epi8(D, 2)];
- ++histo[_mm_extract_epi8(D, 6)];
- ++histo[_mm_extract_epi8(D, 10)];
- ++histo[_mm_extract_epi8(D, 14)];
- }
- }
- {
- const int left_over = tile_width & 3;
- if (left_over > 0) {
- VP8LCollectColorRedTransforms_C(argb + tile_width - left_over, stride,
- left_over, tile_height, green_to_red,
- histo);
- }
- }
-}
-
-#undef MK_CST_16
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void VP8LEncDspInitSSE41(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void VP8LEncDspInitSSE41(void) {
- VP8LSubtractGreenFromBlueAndRed = SubtractGreenFromBlueAndRed_SSE41;
- VP8LCollectColorBlueTransforms = CollectColorBlueTransforms_SSE41;
- VP8LCollectColorRedTransforms = CollectColorRedTransforms_SSE41;
-}
-
-#else // !WEBP_USE_SSE41
-
-WEBP_DSP_INIT_STUB(VP8LEncDspInitSSE41)
-
-#endif // WEBP_USE_SSE41
diff --git a/contrib/libs/libwebp/dsp/lossless_mips_dsp_r2.c b/contrib/libs/libwebp/dsp/lossless_mips_dsp_r2.c
deleted file mode 100644
index 7d1d9ed748..0000000000
--- a/contrib/libs/libwebp/dsp/lossless_mips_dsp_r2.c
+++ /dev/null
@@ -1,701 +0,0 @@
-// Copyright 2014 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Image transforms and color space conversion methods for lossless decoder.
-//
-// Author(s): Djordje Pesut (djordje.pesut@imgtec.com)
-// Jovan Zelincevic (jovan.zelincevic@imgtec.com)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_MIPS_DSP_R2)
-
-#include "./lossless.h"
-#include "./lossless_common.h"
-
-#define MAP_COLOR_FUNCS(FUNC_NAME, TYPE, GET_INDEX, GET_VALUE) \
-static void FUNC_NAME(const TYPE* src, \
- const uint32_t* const color_map, \
- TYPE* dst, int y_start, int y_end, \
- int width) { \
- int y; \
- for (y = y_start; y < y_end; ++y) { \
- int x; \
- for (x = 0; x < (width >> 2); ++x) { \
- int tmp1, tmp2, tmp3, tmp4; \
- __asm__ volatile ( \
- ".ifc " #TYPE ", uint8_t \n\t" \
- "lbu %[tmp1], 0(%[src]) \n\t" \
- "lbu %[tmp2], 1(%[src]) \n\t" \
- "lbu %[tmp3], 2(%[src]) \n\t" \
- "lbu %[tmp4], 3(%[src]) \n\t" \
- "addiu %[src], %[src], 4 \n\t" \
- ".endif \n\t" \
- ".ifc " #TYPE ", uint32_t \n\t" \
- "lw %[tmp1], 0(%[src]) \n\t" \
- "lw %[tmp2], 4(%[src]) \n\t" \
- "lw %[tmp3], 8(%[src]) \n\t" \
- "lw %[tmp4], 12(%[src]) \n\t" \
- "ext %[tmp1], %[tmp1], 8, 8 \n\t" \
- "ext %[tmp2], %[tmp2], 8, 8 \n\t" \
- "ext %[tmp3], %[tmp3], 8, 8 \n\t" \
- "ext %[tmp4], %[tmp4], 8, 8 \n\t" \
- "addiu %[src], %[src], 16 \n\t" \
- ".endif \n\t" \
- "sll %[tmp1], %[tmp1], 2 \n\t" \
- "sll %[tmp2], %[tmp2], 2 \n\t" \
- "sll %[tmp3], %[tmp3], 2 \n\t" \
- "sll %[tmp4], %[tmp4], 2 \n\t" \
- "lwx %[tmp1], %[tmp1](%[color_map]) \n\t" \
- "lwx %[tmp2], %[tmp2](%[color_map]) \n\t" \
- "lwx %[tmp3], %[tmp3](%[color_map]) \n\t" \
- "lwx %[tmp4], %[tmp4](%[color_map]) \n\t" \
- ".ifc " #TYPE ", uint8_t \n\t" \
- "ext %[tmp1], %[tmp1], 8, 8 \n\t" \
- "ext %[tmp2], %[tmp2], 8, 8 \n\t" \
- "ext %[tmp3], %[tmp3], 8, 8 \n\t" \
- "ext %[tmp4], %[tmp4], 8, 8 \n\t" \
- "sb %[tmp1], 0(%[dst]) \n\t" \
- "sb %[tmp2], 1(%[dst]) \n\t" \
- "sb %[tmp3], 2(%[dst]) \n\t" \
- "sb %[tmp4], 3(%[dst]) \n\t" \
- "addiu %[dst], %[dst], 4 \n\t" \
- ".endif \n\t" \
- ".ifc " #TYPE ", uint32_t \n\t" \
- "sw %[tmp1], 0(%[dst]) \n\t" \
- "sw %[tmp2], 4(%[dst]) \n\t" \
- "sw %[tmp3], 8(%[dst]) \n\t" \
- "sw %[tmp4], 12(%[dst]) \n\t" \
- "addiu %[dst], %[dst], 16 \n\t" \
- ".endif \n\t" \
- : [tmp1]"=&r"(tmp1), [tmp2]"=&r"(tmp2), [tmp3]"=&r"(tmp3), \
- [tmp4]"=&r"(tmp4), [src]"+&r"(src), [dst]"+r"(dst) \
- : [color_map]"r"(color_map) \
- : "memory" \
- ); \
- } \
- for (x = 0; x < (width & 3); ++x) { \
- *dst++ = GET_VALUE(color_map[GET_INDEX(*src++)]); \
- } \
- } \
-}
-
-MAP_COLOR_FUNCS(MapARGB_MIPSdspR2, uint32_t, VP8GetARGBIndex, VP8GetARGBValue)
-MAP_COLOR_FUNCS(MapAlpha_MIPSdspR2, uint8_t, VP8GetAlphaIndex, VP8GetAlphaValue)
-
-#undef MAP_COLOR_FUNCS
-
-static WEBP_INLINE uint32_t ClampedAddSubtractFull(uint32_t c0, uint32_t c1,
- uint32_t c2) {
- int temp0, temp1, temp2, temp3, temp4, temp5;
- __asm__ volatile (
- "preceu.ph.qbr %[temp1], %[c0] \n\t"
- "preceu.ph.qbl %[temp2], %[c0] \n\t"
- "preceu.ph.qbr %[temp3], %[c1] \n\t"
- "preceu.ph.qbl %[temp4], %[c1] \n\t"
- "preceu.ph.qbr %[temp5], %[c2] \n\t"
- "preceu.ph.qbl %[temp0], %[c2] \n\t"
- "subq.ph %[temp3], %[temp3], %[temp5] \n\t"
- "subq.ph %[temp4], %[temp4], %[temp0] \n\t"
- "addq.ph %[temp1], %[temp1], %[temp3] \n\t"
- "addq.ph %[temp2], %[temp2], %[temp4] \n\t"
- "shll_s.ph %[temp1], %[temp1], 7 \n\t"
- "shll_s.ph %[temp2], %[temp2], 7 \n\t"
- "precrqu_s.qb.ph %[temp2], %[temp2], %[temp1] \n\t"
- : [temp0]"=r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [temp4]"=&r"(temp4), [temp5]"=&r"(temp5)
- : [c0]"r"(c0), [c1]"r"(c1), [c2]"r"(c2)
- : "memory"
- );
- return temp2;
-}
-
-static WEBP_INLINE uint32_t ClampedAddSubtractHalf(uint32_t c0, uint32_t c1,
- uint32_t c2) {
- int temp0, temp1, temp2, temp3, temp4, temp5;
- __asm__ volatile (
- "adduh.qb %[temp5], %[c0], %[c1] \n\t"
- "preceu.ph.qbr %[temp3], %[c2] \n\t"
- "preceu.ph.qbr %[temp1], %[temp5] \n\t"
- "preceu.ph.qbl %[temp2], %[temp5] \n\t"
- "preceu.ph.qbl %[temp4], %[c2] \n\t"
- "subq.ph %[temp3], %[temp1], %[temp3] \n\t"
- "subq.ph %[temp4], %[temp2], %[temp4] \n\t"
- "shrl.ph %[temp5], %[temp3], 15 \n\t"
- "shrl.ph %[temp0], %[temp4], 15 \n\t"
- "addq.ph %[temp3], %[temp3], %[temp5] \n\t"
- "addq.ph %[temp4], %[temp0], %[temp4] \n\t"
- "shra.ph %[temp3], %[temp3], 1 \n\t"
- "shra.ph %[temp4], %[temp4], 1 \n\t"
- "addq.ph %[temp1], %[temp1], %[temp3] \n\t"
- "addq.ph %[temp2], %[temp2], %[temp4] \n\t"
- "shll_s.ph %[temp1], %[temp1], 7 \n\t"
- "shll_s.ph %[temp2], %[temp2], 7 \n\t"
- "precrqu_s.qb.ph %[temp1], %[temp2], %[temp1] \n\t"
- : [temp0]"=r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [temp4]"=r"(temp4), [temp5]"=&r"(temp5)
- : [c0]"r"(c0), [c1]"r"(c1), [c2]"r"(c2)
- : "memory"
- );
- return temp1;
-}
-
-static WEBP_INLINE uint32_t Select(uint32_t a, uint32_t b, uint32_t c) {
- int temp0, temp1, temp2, temp3, temp4, temp5;
- __asm__ volatile (
- "cmpgdu.lt.qb %[temp1], %[c], %[b] \n\t"
- "pick.qb %[temp1], %[b], %[c] \n\t"
- "pick.qb %[temp2], %[c], %[b] \n\t"
- "cmpgdu.lt.qb %[temp4], %[c], %[a] \n\t"
- "pick.qb %[temp4], %[a], %[c] \n\t"
- "pick.qb %[temp5], %[c], %[a] \n\t"
- "subu.qb %[temp3], %[temp1], %[temp2] \n\t"
- "subu.qb %[temp0], %[temp4], %[temp5] \n\t"
- "raddu.w.qb %[temp3], %[temp3] \n\t"
- "raddu.w.qb %[temp0], %[temp0] \n\t"
- "subu %[temp3], %[temp3], %[temp0] \n\t"
- "slti %[temp0], %[temp3], 0x1 \n\t"
- "movz %[a], %[b], %[temp0] \n\t"
- : [temp1]"=&r"(temp1), [temp2]"=&r"(temp2), [temp3]"=&r"(temp3),
- [temp4]"=&r"(temp4), [temp5]"=&r"(temp5), [temp0]"=&r"(temp0),
- [a]"+&r"(a)
- : [b]"r"(b), [c]"r"(c)
- );
- return a;
-}
-
-static WEBP_INLINE uint32_t Average2(uint32_t a0, uint32_t a1) {
- __asm__ volatile (
- "adduh.qb %[a0], %[a0], %[a1] \n\t"
- : [a0]"+r"(a0)
- : [a1]"r"(a1)
- );
- return a0;
-}
-
-static WEBP_INLINE uint32_t Average3(uint32_t a0, uint32_t a1, uint32_t a2) {
- return Average2(Average2(a0, a2), a1);
-}
-
-static WEBP_INLINE uint32_t Average4(uint32_t a0, uint32_t a1,
- uint32_t a2, uint32_t a3) {
- return Average2(Average2(a0, a1), Average2(a2, a3));
-}
-
-static uint32_t Predictor5_MIPSdspR2(const uint32_t* const left,
- const uint32_t* const top) {
- return Average3(*left, top[0], top[1]);
-}
-
-static uint32_t Predictor6_MIPSdspR2(const uint32_t* const left,
- const uint32_t* const top) {
- return Average2(*left, top[-1]);
-}
-
-static uint32_t Predictor7_MIPSdspR2(const uint32_t* const left,
- const uint32_t* const top) {
- return Average2(*left, top[0]);
-}
-
-static uint32_t Predictor8_MIPSdspR2(const uint32_t* const left,
- const uint32_t* const top) {
- (void)left;
- return Average2(top[-1], top[0]);
-}
-
-static uint32_t Predictor9_MIPSdspR2(const uint32_t* const left,
- const uint32_t* const top) {
- (void)left;
- return Average2(top[0], top[1]);
-}
-
-static uint32_t Predictor10_MIPSdspR2(const uint32_t* const left,
- const uint32_t* const top) {
- return Average4(*left, top[-1], top[0], top[1]);
-}
-
-static uint32_t Predictor11_MIPSdspR2(const uint32_t* const left,
- const uint32_t* const top) {
- return Select(top[0], *left, top[-1]);
-}
-
-static uint32_t Predictor12_MIPSdspR2(const uint32_t* const left,
- const uint32_t* const top) {
- return ClampedAddSubtractFull(*left, top[0], top[-1]);
-}
-
-static uint32_t Predictor13_MIPSdspR2(const uint32_t* const left,
- const uint32_t* const top) {
- return ClampedAddSubtractHalf(*left, top[0], top[-1]);
-}
-
-// Add green to blue and red channels (i.e. perform the inverse transform of
-// 'subtract green').
-static void AddGreenToBlueAndRed_MIPSdspR2(const uint32_t* src, int num_pixels,
- uint32_t* dst) {
- uint32_t temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7;
- const uint32_t* const p_loop1_end = src + (num_pixels & ~3);
- const uint32_t* const p_loop2_end = src + num_pixels;
- __asm__ volatile (
- ".set push \n\t"
- ".set noreorder \n\t"
- "beq %[src], %[p_loop1_end], 3f \n\t"
- " nop \n\t"
- "0: \n\t"
- "lw %[temp0], 0(%[src]) \n\t"
- "lw %[temp1], 4(%[src]) \n\t"
- "lw %[temp2], 8(%[src]) \n\t"
- "lw %[temp3], 12(%[src]) \n\t"
- "ext %[temp4], %[temp0], 8, 8 \n\t"
- "ext %[temp5], %[temp1], 8, 8 \n\t"
- "ext %[temp6], %[temp2], 8, 8 \n\t"
- "ext %[temp7], %[temp3], 8, 8 \n\t"
- "addiu %[src], %[src], 16 \n\t"
- "addiu %[dst], %[dst], 16 \n\t"
- "replv.ph %[temp4], %[temp4] \n\t"
- "replv.ph %[temp5], %[temp5] \n\t"
- "replv.ph %[temp6], %[temp6] \n\t"
- "replv.ph %[temp7], %[temp7] \n\t"
- "addu.qb %[temp0], %[temp0], %[temp4] \n\t"
- "addu.qb %[temp1], %[temp1], %[temp5] \n\t"
- "addu.qb %[temp2], %[temp2], %[temp6] \n\t"
- "addu.qb %[temp3], %[temp3], %[temp7] \n\t"
- "sw %[temp0], -16(%[dst]) \n\t"
- "sw %[temp1], -12(%[dst]) \n\t"
- "sw %[temp2], -8(%[dst]) \n\t"
- "bne %[src], %[p_loop1_end], 0b \n\t"
- " sw %[temp3], -4(%[dst]) \n\t"
- "3: \n\t"
- "beq %[src], %[p_loop2_end], 2f \n\t"
- " nop \n\t"
- "1: \n\t"
- "lw %[temp0], 0(%[src]) \n\t"
- "addiu %[src], %[src], 4 \n\t"
- "addiu %[dst], %[dst], 4 \n\t"
- "ext %[temp4], %[temp0], 8, 8 \n\t"
- "replv.ph %[temp4], %[temp4] \n\t"
- "addu.qb %[temp0], %[temp0], %[temp4] \n\t"
- "bne %[src], %[p_loop2_end], 1b \n\t"
- " sw %[temp0], -4(%[dst]) \n\t"
- "2: \n\t"
- ".set pop \n\t"
- : [dst]"+&r"(dst), [src]"+&r"(src), [temp0]"=&r"(temp0),
- [temp1]"=&r"(temp1), [temp2]"=&r"(temp2), [temp3]"=&r"(temp3),
- [temp4]"=&r"(temp4), [temp5]"=&r"(temp5), [temp6]"=&r"(temp6),
- [temp7]"=&r"(temp7)
- : [p_loop1_end]"r"(p_loop1_end), [p_loop2_end]"r"(p_loop2_end)
- : "memory"
- );
-}
-
-static void TransformColorInverse_MIPSdspR2(const VP8LMultipliers* const m,
- const uint32_t* src, int num_pixels,
- uint32_t* dst) {
- int temp0, temp1, temp2, temp3, temp4, temp5;
- uint32_t argb, argb1, new_red;
- const uint32_t G_to_R = m->green_to_red_;
- const uint32_t G_to_B = m->green_to_blue_;
- const uint32_t R_to_B = m->red_to_blue_;
- const uint32_t* const p_loop_end = src + (num_pixels & ~1);
- __asm__ volatile (
- ".set push \n\t"
- ".set noreorder \n\t"
- "beq %[src], %[p_loop_end], 1f \n\t"
- " nop \n\t"
- "replv.ph %[temp0], %[G_to_R] \n\t"
- "replv.ph %[temp1], %[G_to_B] \n\t"
- "replv.ph %[temp2], %[R_to_B] \n\t"
- "shll.ph %[temp0], %[temp0], 8 \n\t"
- "shll.ph %[temp1], %[temp1], 8 \n\t"
- "shll.ph %[temp2], %[temp2], 8 \n\t"
- "shra.ph %[temp0], %[temp0], 8 \n\t"
- "shra.ph %[temp1], %[temp1], 8 \n\t"
- "shra.ph %[temp2], %[temp2], 8 \n\t"
- "0: \n\t"
- "lw %[argb], 0(%[src]) \n\t"
- "lw %[argb1], 4(%[src]) \n\t"
- "sw %[argb], 0(%[dst]) \n\t"
- "sw %[argb1], 4(%[dst]) \n\t"
- "addiu %[src], %[src], 8 \n\t"
- "addiu %[dst], %[dst], 8 \n\t"
- "precrq.qb.ph %[temp3], %[argb], %[argb1] \n\t"
- "preceu.ph.qbra %[temp3], %[temp3] \n\t"
- "shll.ph %[temp3], %[temp3], 8 \n\t"
- "shra.ph %[temp3], %[temp3], 8 \n\t"
- "mul.ph %[temp5], %[temp3], %[temp0] \n\t"
- "mul.ph %[temp3], %[temp3], %[temp1] \n\t"
- "precrq.ph.w %[new_red], %[argb], %[argb1] \n\t"
- "ins %[argb1], %[argb], 16, 16 \n\t"
- "shra.ph %[temp5], %[temp5], 5 \n\t"
- "shra.ph %[temp3], %[temp3], 5 \n\t"
- "addu.ph %[new_red], %[new_red], %[temp5] \n\t"
- "addu.ph %[argb1], %[argb1], %[temp3] \n\t"
- "preceu.ph.qbra %[temp5], %[new_red] \n\t"
- "shll.ph %[temp4], %[temp5], 8 \n\t"
- "shra.ph %[temp4], %[temp4], 8 \n\t"
- "mul.ph %[temp4], %[temp4], %[temp2] \n\t"
- "sb %[temp5], -2(%[dst]) \n\t"
- "sra %[temp5], %[temp5], 16 \n\t"
- "shra.ph %[temp4], %[temp4], 5 \n\t"
- "addu.ph %[argb1], %[argb1], %[temp4] \n\t"
- "preceu.ph.qbra %[temp3], %[argb1] \n\t"
- "sb %[temp5], -6(%[dst]) \n\t"
- "sb %[temp3], -4(%[dst]) \n\t"
- "sra %[temp3], %[temp3], 16 \n\t"
- "bne %[src], %[p_loop_end], 0b \n\t"
- " sb %[temp3], -8(%[dst]) \n\t"
- "1: \n\t"
- ".set pop \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [temp4]"=&r"(temp4), [temp5]"=&r"(temp5),
- [new_red]"=&r"(new_red), [argb]"=&r"(argb),
- [argb1]"=&r"(argb1), [dst]"+&r"(dst), [src]"+&r"(src)
- : [G_to_R]"r"(G_to_R), [R_to_B]"r"(R_to_B),
- [G_to_B]"r"(G_to_B), [p_loop_end]"r"(p_loop_end)
- : "memory", "hi", "lo"
- );
-
- // Fall-back to C-version for left-overs.
- if (num_pixels & 1) VP8LTransformColorInverse_C(m, src, 1, dst);
-}
-
-static void ConvertBGRAToRGB_MIPSdspR2(const uint32_t* src,
- int num_pixels, uint8_t* dst) {
- int temp0, temp1, temp2, temp3;
- const uint32_t* const p_loop1_end = src + (num_pixels & ~3);
- const uint32_t* const p_loop2_end = src + num_pixels;
- __asm__ volatile (
- ".set push \n\t"
- ".set noreorder \n\t"
- "beq %[src], %[p_loop1_end], 3f \n\t"
- " nop \n\t"
- "0: \n\t"
- "lw %[temp3], 12(%[src]) \n\t"
- "lw %[temp2], 8(%[src]) \n\t"
- "lw %[temp1], 4(%[src]) \n\t"
- "lw %[temp0], 0(%[src]) \n\t"
- "ins %[temp3], %[temp2], 24, 8 \n\t"
- "sll %[temp2], %[temp2], 8 \n\t"
- "rotr %[temp3], %[temp3], 16 \n\t"
- "ins %[temp2], %[temp1], 0, 16 \n\t"
- "sll %[temp1], %[temp1], 8 \n\t"
- "wsbh %[temp3], %[temp3] \n\t"
- "balign %[temp0], %[temp1], 1 \n\t"
- "wsbh %[temp2], %[temp2] \n\t"
- "wsbh %[temp0], %[temp0] \n\t"
- "usw %[temp3], 8(%[dst]) \n\t"
- "rotr %[temp0], %[temp0], 16 \n\t"
- "usw %[temp2], 4(%[dst]) \n\t"
- "addiu %[src], %[src], 16 \n\t"
- "usw %[temp0], 0(%[dst]) \n\t"
- "bne %[src], %[p_loop1_end], 0b \n\t"
- " addiu %[dst], %[dst], 12 \n\t"
- "3: \n\t"
- "beq %[src], %[p_loop2_end], 2f \n\t"
- " nop \n\t"
- "1: \n\t"
- "lw %[temp0], 0(%[src]) \n\t"
- "addiu %[src], %[src], 4 \n\t"
- "wsbh %[temp1], %[temp0] \n\t"
- "addiu %[dst], %[dst], 3 \n\t"
- "ush %[temp1], -2(%[dst]) \n\t"
- "sra %[temp0], %[temp0], 16 \n\t"
- "bne %[src], %[p_loop2_end], 1b \n\t"
- " sb %[temp0], -3(%[dst]) \n\t"
- "2: \n\t"
- ".set pop \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [dst]"+&r"(dst), [src]"+&r"(src)
- : [p_loop1_end]"r"(p_loop1_end), [p_loop2_end]"r"(p_loop2_end)
- : "memory"
- );
-}
-
-static void ConvertBGRAToRGBA_MIPSdspR2(const uint32_t* src,
- int num_pixels, uint8_t* dst) {
- int temp0, temp1, temp2, temp3;
- const uint32_t* const p_loop1_end = src + (num_pixels & ~3);
- const uint32_t* const p_loop2_end = src + num_pixels;
- __asm__ volatile (
- ".set push \n\t"
- ".set noreorder \n\t"
- "beq %[src], %[p_loop1_end], 3f \n\t"
- " nop \n\t"
- "0: \n\t"
- "lw %[temp0], 0(%[src]) \n\t"
- "lw %[temp1], 4(%[src]) \n\t"
- "lw %[temp2], 8(%[src]) \n\t"
- "lw %[temp3], 12(%[src]) \n\t"
- "wsbh %[temp0], %[temp0] \n\t"
- "wsbh %[temp1], %[temp1] \n\t"
- "wsbh %[temp2], %[temp2] \n\t"
- "wsbh %[temp3], %[temp3] \n\t"
- "addiu %[src], %[src], 16 \n\t"
- "balign %[temp0], %[temp0], 1 \n\t"
- "balign %[temp1], %[temp1], 1 \n\t"
- "balign %[temp2], %[temp2], 1 \n\t"
- "balign %[temp3], %[temp3], 1 \n\t"
- "usw %[temp0], 0(%[dst]) \n\t"
- "usw %[temp1], 4(%[dst]) \n\t"
- "usw %[temp2], 8(%[dst]) \n\t"
- "usw %[temp3], 12(%[dst]) \n\t"
- "bne %[src], %[p_loop1_end], 0b \n\t"
- " addiu %[dst], %[dst], 16 \n\t"
- "3: \n\t"
- "beq %[src], %[p_loop2_end], 2f \n\t"
- " nop \n\t"
- "1: \n\t"
- "lw %[temp0], 0(%[src]) \n\t"
- "wsbh %[temp0], %[temp0] \n\t"
- "addiu %[src], %[src], 4 \n\t"
- "balign %[temp0], %[temp0], 1 \n\t"
- "usw %[temp0], 0(%[dst]) \n\t"
- "bne %[src], %[p_loop2_end], 1b \n\t"
- " addiu %[dst], %[dst], 4 \n\t"
- "2: \n\t"
- ".set pop \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [dst]"+&r"(dst), [src]"+&r"(src)
- : [p_loop1_end]"r"(p_loop1_end), [p_loop2_end]"r"(p_loop2_end)
- : "memory"
- );
-}
-
-static void ConvertBGRAToRGBA4444_MIPSdspR2(const uint32_t* src,
- int num_pixels, uint8_t* dst) {
- int temp0, temp1, temp2, temp3, temp4, temp5;
- const uint32_t* const p_loop1_end = src + (num_pixels & ~3);
- const uint32_t* const p_loop2_end = src + num_pixels;
- __asm__ volatile (
- ".set push \n\t"
- ".set noreorder \n\t"
- "beq %[src], %[p_loop1_end], 3f \n\t"
- " nop \n\t"
- "0: \n\t"
- "lw %[temp0], 0(%[src]) \n\t"
- "lw %[temp1], 4(%[src]) \n\t"
- "lw %[temp2], 8(%[src]) \n\t"
- "lw %[temp3], 12(%[src]) \n\t"
- "ext %[temp4], %[temp0], 28, 4 \n\t"
- "ext %[temp5], %[temp0], 12, 4 \n\t"
- "ins %[temp0], %[temp4], 0, 4 \n\t"
- "ext %[temp4], %[temp1], 28, 4 \n\t"
- "ins %[temp0], %[temp5], 16, 4 \n\t"
- "ext %[temp5], %[temp1], 12, 4 \n\t"
- "ins %[temp1], %[temp4], 0, 4 \n\t"
- "ext %[temp4], %[temp2], 28, 4 \n\t"
- "ins %[temp1], %[temp5], 16, 4 \n\t"
- "ext %[temp5], %[temp2], 12, 4 \n\t"
- "ins %[temp2], %[temp4], 0, 4 \n\t"
- "ext %[temp4], %[temp3], 28, 4 \n\t"
- "ins %[temp2], %[temp5], 16, 4 \n\t"
- "ext %[temp5], %[temp3], 12, 4 \n\t"
- "ins %[temp3], %[temp4], 0, 4 \n\t"
- "precr.qb.ph %[temp1], %[temp1], %[temp0] \n\t"
- "ins %[temp3], %[temp5], 16, 4 \n\t"
- "addiu %[src], %[src], 16 \n\t"
- "precr.qb.ph %[temp3], %[temp3], %[temp2] \n\t"
-#if (WEBP_SWAP_16BIT_CSP == 1)
- "usw %[temp1], 0(%[dst]) \n\t"
- "usw %[temp3], 4(%[dst]) \n\t"
-#else
- "wsbh %[temp1], %[temp1] \n\t"
- "wsbh %[temp3], %[temp3] \n\t"
- "usw %[temp1], 0(%[dst]) \n\t"
- "usw %[temp3], 4(%[dst]) \n\t"
-#endif
- "bne %[src], %[p_loop1_end], 0b \n\t"
- " addiu %[dst], %[dst], 8 \n\t"
- "3: \n\t"
- "beq %[src], %[p_loop2_end], 2f \n\t"
- " nop \n\t"
- "1: \n\t"
- "lw %[temp0], 0(%[src]) \n\t"
- "ext %[temp4], %[temp0], 28, 4 \n\t"
- "ext %[temp5], %[temp0], 12, 4 \n\t"
- "ins %[temp0], %[temp4], 0, 4 \n\t"
- "ins %[temp0], %[temp5], 16, 4 \n\t"
- "addiu %[src], %[src], 4 \n\t"
- "precr.qb.ph %[temp0], %[temp0], %[temp0] \n\t"
-#if (WEBP_SWAP_16BIT_CSP == 1)
- "ush %[temp0], 0(%[dst]) \n\t"
-#else
- "wsbh %[temp0], %[temp0] \n\t"
- "ush %[temp0], 0(%[dst]) \n\t"
-#endif
- "bne %[src], %[p_loop2_end], 1b \n\t"
- " addiu %[dst], %[dst], 2 \n\t"
- "2: \n\t"
- ".set pop \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [temp4]"=&r"(temp4), [temp5]"=&r"(temp5),
- [dst]"+&r"(dst), [src]"+&r"(src)
- : [p_loop1_end]"r"(p_loop1_end), [p_loop2_end]"r"(p_loop2_end)
- : "memory"
- );
-}
-
-static void ConvertBGRAToRGB565_MIPSdspR2(const uint32_t* src,
- int num_pixels, uint8_t* dst) {
- int temp0, temp1, temp2, temp3, temp4, temp5;
- const uint32_t* const p_loop1_end = src + (num_pixels & ~3);
- const uint32_t* const p_loop2_end = src + num_pixels;
- __asm__ volatile (
- ".set push \n\t"
- ".set noreorder \n\t"
- "beq %[src], %[p_loop1_end], 3f \n\t"
- " nop \n\t"
- "0: \n\t"
- "lw %[temp0], 0(%[src]) \n\t"
- "lw %[temp1], 4(%[src]) \n\t"
- "lw %[temp2], 8(%[src]) \n\t"
- "lw %[temp3], 12(%[src]) \n\t"
- "ext %[temp4], %[temp0], 8, 16 \n\t"
- "ext %[temp5], %[temp0], 5, 11 \n\t"
- "ext %[temp0], %[temp0], 3, 5 \n\t"
- "ins %[temp4], %[temp5], 0, 11 \n\t"
- "ext %[temp5], %[temp1], 5, 11 \n\t"
- "ins %[temp4], %[temp0], 0, 5 \n\t"
- "ext %[temp0], %[temp1], 8, 16 \n\t"
- "ext %[temp1], %[temp1], 3, 5 \n\t"
- "ins %[temp0], %[temp5], 0, 11 \n\t"
- "ext %[temp5], %[temp2], 5, 11 \n\t"
- "ins %[temp0], %[temp1], 0, 5 \n\t"
- "ext %[temp1], %[temp2], 8, 16 \n\t"
- "ext %[temp2], %[temp2], 3, 5 \n\t"
- "ins %[temp1], %[temp5], 0, 11 \n\t"
- "ext %[temp5], %[temp3], 5, 11 \n\t"
- "ins %[temp1], %[temp2], 0, 5 \n\t"
- "ext %[temp2], %[temp3], 8, 16 \n\t"
- "ext %[temp3], %[temp3], 3, 5 \n\t"
- "ins %[temp2], %[temp5], 0, 11 \n\t"
- "append %[temp0], %[temp4], 16 \n\t"
- "ins %[temp2], %[temp3], 0, 5 \n\t"
- "addiu %[src], %[src], 16 \n\t"
- "append %[temp2], %[temp1], 16 \n\t"
-#if (WEBP_SWAP_16BIT_CSP == 1)
- "usw %[temp0], 0(%[dst]) \n\t"
- "usw %[temp2], 4(%[dst]) \n\t"
-#else
- "wsbh %[temp0], %[temp0] \n\t"
- "wsbh %[temp2], %[temp2] \n\t"
- "usw %[temp0], 0(%[dst]) \n\t"
- "usw %[temp2], 4(%[dst]) \n\t"
-#endif
- "bne %[src], %[p_loop1_end], 0b \n\t"
- " addiu %[dst], %[dst], 8 \n\t"
- "3: \n\t"
- "beq %[src], %[p_loop2_end], 2f \n\t"
- " nop \n\t"
- "1: \n\t"
- "lw %[temp0], 0(%[src]) \n\t"
- "ext %[temp4], %[temp0], 8, 16 \n\t"
- "ext %[temp5], %[temp0], 5, 11 \n\t"
- "ext %[temp0], %[temp0], 3, 5 \n\t"
- "ins %[temp4], %[temp5], 0, 11 \n\t"
- "addiu %[src], %[src], 4 \n\t"
- "ins %[temp4], %[temp0], 0, 5 \n\t"
-#if (WEBP_SWAP_16BIT_CSP == 1)
- "ush %[temp4], 0(%[dst]) \n\t"
-#else
- "wsbh %[temp4], %[temp4] \n\t"
- "ush %[temp4], 0(%[dst]) \n\t"
-#endif
- "bne %[src], %[p_loop2_end], 1b \n\t"
- " addiu %[dst], %[dst], 2 \n\t"
- "2: \n\t"
- ".set pop \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [temp4]"=&r"(temp4), [temp5]"=&r"(temp5),
- [dst]"+&r"(dst), [src]"+&r"(src)
- : [p_loop1_end]"r"(p_loop1_end), [p_loop2_end]"r"(p_loop2_end)
- : "memory"
- );
-}
-
-static void ConvertBGRAToBGR_MIPSdspR2(const uint32_t* src,
- int num_pixels, uint8_t* dst) {
- int temp0, temp1, temp2, temp3;
- const uint32_t* const p_loop1_end = src + (num_pixels & ~3);
- const uint32_t* const p_loop2_end = src + num_pixels;
- __asm__ volatile (
- ".set push \n\t"
- ".set noreorder \n\t"
- "beq %[src], %[p_loop1_end], 3f \n\t"
- " nop \n\t"
- "0: \n\t"
- "lw %[temp0], 0(%[src]) \n\t"
- "lw %[temp1], 4(%[src]) \n\t"
- "lw %[temp2], 8(%[src]) \n\t"
- "lw %[temp3], 12(%[src]) \n\t"
- "ins %[temp0], %[temp1], 24, 8 \n\t"
- "sra %[temp1], %[temp1], 8 \n\t"
- "ins %[temp1], %[temp2], 16, 16 \n\t"
- "sll %[temp2], %[temp2], 8 \n\t"
- "balign %[temp3], %[temp2], 1 \n\t"
- "addiu %[src], %[src], 16 \n\t"
- "usw %[temp0], 0(%[dst]) \n\t"
- "usw %[temp1], 4(%[dst]) \n\t"
- "usw %[temp3], 8(%[dst]) \n\t"
- "bne %[src], %[p_loop1_end], 0b \n\t"
- " addiu %[dst], %[dst], 12 \n\t"
- "3: \n\t"
- "beq %[src], %[p_loop2_end], 2f \n\t"
- " nop \n\t"
- "1: \n\t"
- "lw %[temp0], 0(%[src]) \n\t"
- "addiu %[src], %[src], 4 \n\t"
- "addiu %[dst], %[dst], 3 \n\t"
- "ush %[temp0], -3(%[dst]) \n\t"
- "sra %[temp0], %[temp0], 16 \n\t"
- "bne %[src], %[p_loop2_end], 1b \n\t"
- " sb %[temp0], -1(%[dst]) \n\t"
- "2: \n\t"
- ".set pop \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
- [temp3]"=&r"(temp3), [dst]"+&r"(dst), [src]"+&r"(src)
- : [p_loop1_end]"r"(p_loop1_end), [p_loop2_end]"r"(p_loop2_end)
- : "memory"
- );
-}
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void VP8LDspInitMIPSdspR2(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void VP8LDspInitMIPSdspR2(void) {
- VP8LMapColor32b = MapARGB_MIPSdspR2;
- VP8LMapColor8b = MapAlpha_MIPSdspR2;
-
- VP8LPredictors[5] = Predictor5_MIPSdspR2;
- VP8LPredictors[6] = Predictor6_MIPSdspR2;
- VP8LPredictors[7] = Predictor7_MIPSdspR2;
- VP8LPredictors[8] = Predictor8_MIPSdspR2;
- VP8LPredictors[9] = Predictor9_MIPSdspR2;
- VP8LPredictors[10] = Predictor10_MIPSdspR2;
- VP8LPredictors[11] = Predictor11_MIPSdspR2;
- VP8LPredictors[12] = Predictor12_MIPSdspR2;
- VP8LPredictors[13] = Predictor13_MIPSdspR2;
-
- VP8LAddGreenToBlueAndRed = AddGreenToBlueAndRed_MIPSdspR2;
- VP8LTransformColorInverse = TransformColorInverse_MIPSdspR2;
-
- VP8LConvertBGRAToRGB = ConvertBGRAToRGB_MIPSdspR2;
- VP8LConvertBGRAToRGBA = ConvertBGRAToRGBA_MIPSdspR2;
- VP8LConvertBGRAToRGBA4444 = ConvertBGRAToRGBA4444_MIPSdspR2;
- VP8LConvertBGRAToRGB565 = ConvertBGRAToRGB565_MIPSdspR2;
- VP8LConvertBGRAToBGR = ConvertBGRAToBGR_MIPSdspR2;
-}
-
-#else // !WEBP_USE_MIPS_DSP_R2
-
-WEBP_DSP_INIT_STUB(VP8LDspInitMIPSdspR2)
-
-#endif // WEBP_USE_MIPS_DSP_R2
diff --git a/contrib/libs/libwebp/dsp/lossless_msa.c b/contrib/libs/libwebp/dsp/lossless_msa.c
deleted file mode 100644
index 3dd6c836b5..0000000000
--- a/contrib/libs/libwebp/dsp/lossless_msa.c
+++ /dev/null
@@ -1,356 +0,0 @@
-// Copyright 2016 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// MSA variant of methods for lossless decoder
-//
-// Author: Prashant Patil (prashant.patil@imgtec.com)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_MSA)
-
-#include "./lossless.h"
-#include "./msa_macro.h"
-
-//------------------------------------------------------------------------------
-// Colorspace conversion functions
-
-#define CONVERT16_BGRA_XXX(psrc, pdst, m0, m1, m2) do { \
- v16u8 src0, src1, src2, src3, dst0, dst1, dst2; \
- LD_UB4(psrc, 16, src0, src1, src2, src3); \
- VSHF_B2_UB(src0, src1, src1, src2, m0, m1, dst0, dst1); \
- dst2 = VSHF_UB(src2, src3, m2); \
- ST_UB2(dst0, dst1, pdst, 16); \
- ST_UB(dst2, pdst + 32); \
-} while (0)
-
-#define CONVERT12_BGRA_XXX(psrc, pdst, m0, m1, m2) do { \
- uint32_t pix_w; \
- v16u8 src0, src1, src2, dst0, dst1, dst2; \
- LD_UB3(psrc, 16, src0, src1, src2); \
- VSHF_B2_UB(src0, src1, src1, src2, m0, m1, dst0, dst1); \
- dst2 = VSHF_UB(src2, src2, m2); \
- ST_UB2(dst0, dst1, pdst, 16); \
- pix_w = __msa_copy_s_w((v4i32)dst2, 0); \
- SW(pix_w, pdst + 32); \
-} while (0)
-
-#define CONVERT8_BGRA_XXX(psrc, pdst, m0, m1) do { \
- uint64_t pix_d; \
- v16u8 src0, src1, src2 = { 0 }, dst0, dst1; \
- LD_UB2(psrc, 16, src0, src1); \
- VSHF_B2_UB(src0, src1, src1, src2, m0, m1, dst0, dst1); \
- ST_UB(dst0, pdst); \
- pix_d = __msa_copy_s_d((v2i64)dst1, 0); \
- SD(pix_d, pdst + 16); \
-} while (0)
-
-#define CONVERT4_BGRA_XXX(psrc, pdst, m) do { \
- const v16u8 src0 = LD_UB(psrc); \
- const v16u8 dst0 = VSHF_UB(src0, src0, m); \
- uint64_t pix_d = __msa_copy_s_d((v2i64)dst0, 0); \
- uint32_t pix_w = __msa_copy_s_w((v4i32)dst0, 2); \
- SD(pix_d, pdst + 0); \
- SW(pix_w, pdst + 8); \
-} while (0)
-
-#define CONVERT1_BGRA_BGR(psrc, pdst) do { \
- const int32_t b = (psrc)[0]; \
- const int32_t g = (psrc)[1]; \
- const int32_t r = (psrc)[2]; \
- (pdst)[0] = b; \
- (pdst)[1] = g; \
- (pdst)[2] = r; \
-} while (0)
-
-#define CONVERT1_BGRA_RGB(psrc, pdst) do { \
- const int32_t b = (psrc)[0]; \
- const int32_t g = (psrc)[1]; \
- const int32_t r = (psrc)[2]; \
- (pdst)[0] = r; \
- (pdst)[1] = g; \
- (pdst)[2] = b; \
-} while (0)
-
-#define TRANSFORM_COLOR_INVERSE_8(src0, src1, dst0, dst1, \
- c0, c1, mask0, mask1) do { \
- v8i16 g0, g1, t0, t1, t2, t3; \
- v4i32 t4, t5; \
- VSHF_B2_SH(src0, src0, src1, src1, mask0, mask0, g0, g1); \
- DOTP_SB2_SH(g0, g1, c0, c0, t0, t1); \
- SRAI_H2_SH(t0, t1, 5); \
- t0 = __msa_addv_h(t0, (v8i16)src0); \
- t1 = __msa_addv_h(t1, (v8i16)src1); \
- t4 = __msa_srli_w((v4i32)t0, 16); \
- t5 = __msa_srli_w((v4i32)t1, 16); \
- DOTP_SB2_SH(t4, t5, c1, c1, t2, t3); \
- SRAI_H2_SH(t2, t3, 5); \
- ADD2(t0, t2, t1, t3, t0, t1); \
- VSHF_B2_UB(src0, t0, src1, t1, mask1, mask1, dst0, dst1); \
-} while (0)
-
-#define TRANSFORM_COLOR_INVERSE_4(src, dst, c0, c1, mask0, mask1) do { \
- const v16i8 g0 = VSHF_SB(src, src, mask0); \
- v8i16 t0 = __msa_dotp_s_h(c0, g0); \
- v8i16 t1; \
- v4i32 t2; \
- t0 = SRAI_H(t0, 5); \
- t0 = __msa_addv_h(t0, (v8i16)src); \
- t2 = __msa_srli_w((v4i32)t0, 16); \
- t1 = __msa_dotp_s_h(c1, (v16i8)t2); \
- t1 = SRAI_H(t1, 5); \
- t0 = t0 + t1; \
- dst = VSHF_UB(src, t0, mask1); \
-} while (0)
-
-static void ConvertBGRAToRGBA_MSA(const uint32_t* src,
- int num_pixels, uint8_t* dst) {
- int i;
- const uint8_t* ptemp_src = (const uint8_t*)src;
- uint8_t* ptemp_dst = (uint8_t*)dst;
- v16u8 src0, dst0;
- const v16u8 mask = { 2, 1, 0, 3, 6, 5, 4, 7, 10, 9, 8, 11, 14, 13, 12, 15 };
-
- while (num_pixels >= 8) {
- v16u8 src1, dst1;
- LD_UB2(ptemp_src, 16, src0, src1);
- VSHF_B2_UB(src0, src0, src1, src1, mask, mask, dst0, dst1);
- ST_UB2(dst0, dst1, ptemp_dst, 16);
- ptemp_src += 32;
- ptemp_dst += 32;
- num_pixels -= 8;
- }
- if (num_pixels > 0) {
- if (num_pixels >= 4) {
- src0 = LD_UB(ptemp_src);
- dst0 = VSHF_UB(src0, src0, mask);
- ST_UB(dst0, ptemp_dst);
- ptemp_src += 16;
- ptemp_dst += 16;
- num_pixels -= 4;
- }
- for (i = 0; i < num_pixels; i++) {
- const uint8_t b = ptemp_src[2];
- const uint8_t g = ptemp_src[1];
- const uint8_t r = ptemp_src[0];
- const uint8_t a = ptemp_src[3];
- ptemp_dst[0] = b;
- ptemp_dst[1] = g;
- ptemp_dst[2] = r;
- ptemp_dst[3] = a;
- ptemp_src += 4;
- ptemp_dst += 4;
- }
- }
-}
-
-static void ConvertBGRAToBGR_MSA(const uint32_t* src,
- int num_pixels, uint8_t* dst) {
- const uint8_t* ptemp_src = (const uint8_t*)src;
- uint8_t* ptemp_dst = (uint8_t*)dst;
- const v16u8 mask0 = { 0, 1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14,
- 16, 17, 18, 20 };
- const v16u8 mask1 = { 5, 6, 8, 9, 10, 12, 13, 14, 16, 17, 18, 20,
- 21, 22, 24, 25 };
- const v16u8 mask2 = { 10, 12, 13, 14, 16, 17, 18, 20, 21, 22, 24, 25,
- 26, 28, 29, 30 };
-
- while (num_pixels >= 16) {
- CONVERT16_BGRA_XXX(ptemp_src, ptemp_dst, mask0, mask1, mask2);
- ptemp_src += 64;
- ptemp_dst += 48;
- num_pixels -= 16;
- }
- if (num_pixels > 0) {
- if (num_pixels >= 12) {
- CONVERT12_BGRA_XXX(ptemp_src, ptemp_dst, mask0, mask1, mask2);
- ptemp_src += 48;
- ptemp_dst += 36;
- num_pixels -= 12;
- } else if (num_pixels >= 8) {
- CONVERT8_BGRA_XXX(ptemp_src, ptemp_dst, mask0, mask1);
- ptemp_src += 32;
- ptemp_dst += 24;
- num_pixels -= 8;
- } else if (num_pixels >= 4) {
- CONVERT4_BGRA_XXX(ptemp_src, ptemp_dst, mask0);
- ptemp_src += 16;
- ptemp_dst += 12;
- num_pixels -= 4;
- }
- if (num_pixels == 3) {
- CONVERT1_BGRA_BGR(ptemp_src + 0, ptemp_dst + 0);
- CONVERT1_BGRA_BGR(ptemp_src + 4, ptemp_dst + 3);
- CONVERT1_BGRA_BGR(ptemp_src + 8, ptemp_dst + 6);
- } else if (num_pixels == 2) {
- CONVERT1_BGRA_BGR(ptemp_src + 0, ptemp_dst + 0);
- CONVERT1_BGRA_BGR(ptemp_src + 4, ptemp_dst + 3);
- } else if (num_pixels == 1) {
- CONVERT1_BGRA_BGR(ptemp_src, ptemp_dst);
- }
- }
-}
-
-static void ConvertBGRAToRGB_MSA(const uint32_t* src,
- int num_pixels, uint8_t* dst) {
- const uint8_t* ptemp_src = (const uint8_t*)src;
- uint8_t* ptemp_dst = (uint8_t*)dst;
- const v16u8 mask0 = { 2, 1, 0, 6, 5, 4, 10, 9, 8, 14, 13, 12,
- 18, 17, 16, 22 };
- const v16u8 mask1 = { 5, 4, 10, 9, 8, 14, 13, 12, 18, 17, 16, 22,
- 21, 20, 26, 25 };
- const v16u8 mask2 = { 8, 14, 13, 12, 18, 17, 16, 22, 21, 20, 26, 25,
- 24, 30, 29, 28 };
-
- while (num_pixels >= 16) {
- CONVERT16_BGRA_XXX(ptemp_src, ptemp_dst, mask0, mask1, mask2);
- ptemp_src += 64;
- ptemp_dst += 48;
- num_pixels -= 16;
- }
- if (num_pixels) {
- if (num_pixels >= 12) {
- CONVERT12_BGRA_XXX(ptemp_src, ptemp_dst, mask0, mask1, mask2);
- ptemp_src += 48;
- ptemp_dst += 36;
- num_pixels -= 12;
- } else if (num_pixels >= 8) {
- CONVERT8_BGRA_XXX(ptemp_src, ptemp_dst, mask0, mask1);
- ptemp_src += 32;
- ptemp_dst += 24;
- num_pixels -= 8;
- } else if (num_pixels >= 4) {
- CONVERT4_BGRA_XXX(ptemp_src, ptemp_dst, mask0);
- ptemp_src += 16;
- ptemp_dst += 12;
- num_pixels -= 4;
- }
- if (num_pixels == 3) {
- CONVERT1_BGRA_RGB(ptemp_src + 0, ptemp_dst + 0);
- CONVERT1_BGRA_RGB(ptemp_src + 4, ptemp_dst + 3);
- CONVERT1_BGRA_RGB(ptemp_src + 8, ptemp_dst + 6);
- } else if (num_pixels == 2) {
- CONVERT1_BGRA_RGB(ptemp_src + 0, ptemp_dst + 0);
- CONVERT1_BGRA_RGB(ptemp_src + 4, ptemp_dst + 3);
- } else if (num_pixels == 1) {
- CONVERT1_BGRA_RGB(ptemp_src, ptemp_dst);
- }
- }
-}
-
-static void AddGreenToBlueAndRed_MSA(const uint32_t* const src, int num_pixels,
- uint32_t* dst) {
- int i;
- const uint8_t* in = (const uint8_t*)src;
- uint8_t* out = (uint8_t*)dst;
- v16u8 src0, dst0, tmp0;
- const v16u8 mask = { 1, 255, 1, 255, 5, 255, 5, 255, 9, 255, 9, 255,
- 13, 255, 13, 255 };
-
- while (num_pixels >= 8) {
- v16u8 src1, dst1, tmp1;
- LD_UB2(in, 16, src0, src1);
- VSHF_B2_UB(src0, src1, src1, src0, mask, mask, tmp0, tmp1);
- ADD2(src0, tmp0, src1, tmp1, dst0, dst1);
- ST_UB2(dst0, dst1, out, 16);
- in += 32;
- out += 32;
- num_pixels -= 8;
- }
- if (num_pixels > 0) {
- if (num_pixels >= 4) {
- src0 = LD_UB(in);
- tmp0 = VSHF_UB(src0, src0, mask);
- dst0 = src0 + tmp0;
- ST_UB(dst0, out);
- in += 16;
- out += 16;
- num_pixels -= 4;
- }
- for (i = 0; i < num_pixels; i++) {
- const uint8_t b = in[0];
- const uint8_t g = in[1];
- const uint8_t r = in[2];
- out[0] = (b + g) & 0xff;
- out[1] = g;
- out[2] = (r + g) & 0xff;
- out[4] = in[4];
- out += 4;
- }
- }
-}
-
-static void TransformColorInverse_MSA(const VP8LMultipliers* const m,
- const uint32_t* src, int num_pixels,
- uint32_t* dst) {
- v16u8 src0, dst0;
- const v16i8 g2br = (v16i8)__msa_fill_w(m->green_to_blue_ |
- (m->green_to_red_ << 16));
- const v16i8 r2b = (v16i8)__msa_fill_w(m->red_to_blue_);
- const v16u8 mask0 = { 1, 255, 1, 255, 5, 255, 5, 255, 9, 255, 9, 255,
- 13, 255, 13, 255 };
- const v16u8 mask1 = { 16, 1, 18, 3, 20, 5, 22, 7, 24, 9, 26, 11,
- 28, 13, 30, 15 };
-
- while (num_pixels >= 8) {
- v16u8 src1, dst1;
- LD_UB2(src, 4, src0, src1);
- TRANSFORM_COLOR_INVERSE_8(src0, src1, dst0, dst1, g2br, r2b, mask0, mask1);
- ST_UB2(dst0, dst1, dst, 4);
- src += 8;
- dst += 8;
- num_pixels -= 8;
- }
- if (num_pixels > 0) {
- if (num_pixels >= 4) {
- src0 = LD_UB(src);
- TRANSFORM_COLOR_INVERSE_4(src0, dst0, g2br, r2b, mask0, mask1);
- ST_UB(dst0, dst);
- src += 4;
- dst += 4;
- num_pixels -= 4;
- }
- if (num_pixels > 0) {
- src0 = LD_UB(src);
- TRANSFORM_COLOR_INVERSE_4(src0, dst0, g2br, r2b, mask0, mask1);
- if (num_pixels == 3) {
- const uint64_t pix_d = __msa_copy_s_d((v2i64)dst0, 0);
- const uint32_t pix_w = __msa_copy_s_w((v4i32)dst0, 2);
- SD(pix_d, dst + 0);
- SW(pix_w, dst + 2);
- } else if (num_pixels == 2) {
- const uint64_t pix_d = __msa_copy_s_d((v2i64)dst0, 0);
- SD(pix_d, dst);
- } else {
- const uint32_t pix_w = __msa_copy_s_w((v4i32)dst0, 0);
- SW(pix_w, dst);
- }
- }
- }
-}
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void VP8LDspInitMSA(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void VP8LDspInitMSA(void) {
- VP8LConvertBGRAToRGBA = ConvertBGRAToRGBA_MSA;
- VP8LConvertBGRAToBGR = ConvertBGRAToBGR_MSA;
- VP8LConvertBGRAToRGB = ConvertBGRAToRGB_MSA;
-
- VP8LAddGreenToBlueAndRed = AddGreenToBlueAndRed_MSA;
- VP8LTransformColorInverse = TransformColorInverse_MSA;
-}
-
-#else // !WEBP_USE_MSA
-
-WEBP_DSP_INIT_STUB(VP8LDspInitMSA)
-
-#endif // WEBP_USE_MSA
diff --git a/contrib/libs/libwebp/dsp/lossless_neon.c b/contrib/libs/libwebp/dsp/lossless_neon.c
deleted file mode 100644
index 7a20298f1d..0000000000
--- a/contrib/libs/libwebp/dsp/lossless_neon.c
+++ /dev/null
@@ -1,645 +0,0 @@
-// Copyright 2014 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// NEON variant of methods for lossless decoder
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_NEON)
-
-#include <arm_neon.h>
-
-#include "./lossless.h"
-#include "./neon.h"
-
-//------------------------------------------------------------------------------
-// Colorspace conversion functions
-
-#if !defined(WORK_AROUND_GCC)
-// gcc 4.6.0 had some trouble (NDK-r9) with this code. We only use it for
-// gcc-4.8.x at least.
-static void ConvertBGRAToRGBA_NEON(const uint32_t* src,
- int num_pixels, uint8_t* dst) {
- const uint32_t* const end = src + (num_pixels & ~15);
- for (; src < end; src += 16) {
- uint8x16x4_t pixel = vld4q_u8((uint8_t*)src);
- // swap B and R. (VSWP d0,d2 has no intrinsics equivalent!)
- const uint8x16_t tmp = pixel.val[0];
- pixel.val[0] = pixel.val[2];
- pixel.val[2] = tmp;
- vst4q_u8(dst, pixel);
- dst += 64;
- }
- VP8LConvertBGRAToRGBA_C(src, num_pixels & 15, dst); // left-overs
-}
-
-static void ConvertBGRAToBGR_NEON(const uint32_t* src,
- int num_pixels, uint8_t* dst) {
- const uint32_t* const end = src + (num_pixels & ~15);
- for (; src < end; src += 16) {
- const uint8x16x4_t pixel = vld4q_u8((uint8_t*)src);
- const uint8x16x3_t tmp = { { pixel.val[0], pixel.val[1], pixel.val[2] } };
- vst3q_u8(dst, tmp);
- dst += 48;
- }
- VP8LConvertBGRAToBGR_C(src, num_pixels & 15, dst); // left-overs
-}
-
-static void ConvertBGRAToRGB_NEON(const uint32_t* src,
- int num_pixels, uint8_t* dst) {
- const uint32_t* const end = src + (num_pixels & ~15);
- for (; src < end; src += 16) {
- const uint8x16x4_t pixel = vld4q_u8((uint8_t*)src);
- const uint8x16x3_t tmp = { { pixel.val[2], pixel.val[1], pixel.val[0] } };
- vst3q_u8(dst, tmp);
- dst += 48;
- }
- VP8LConvertBGRAToRGB_C(src, num_pixels & 15, dst); // left-overs
-}
-
-#else // WORK_AROUND_GCC
-
-// gcc-4.6.0 fallback
-
-static const uint8_t kRGBAShuffle[8] = { 2, 1, 0, 3, 6, 5, 4, 7 };
-
-static void ConvertBGRAToRGBA_NEON(const uint32_t* src,
- int num_pixels, uint8_t* dst) {
- const uint32_t* const end = src + (num_pixels & ~1);
- const uint8x8_t shuffle = vld1_u8(kRGBAShuffle);
- for (; src < end; src += 2) {
- const uint8x8_t pixels = vld1_u8((uint8_t*)src);
- vst1_u8(dst, vtbl1_u8(pixels, shuffle));
- dst += 8;
- }
- VP8LConvertBGRAToRGBA_C(src, num_pixels & 1, dst); // left-overs
-}
-
-static const uint8_t kBGRShuffle[3][8] = {
- { 0, 1, 2, 4, 5, 6, 8, 9 },
- { 10, 12, 13, 14, 16, 17, 18, 20 },
- { 21, 22, 24, 25, 26, 28, 29, 30 }
-};
-
-static void ConvertBGRAToBGR_NEON(const uint32_t* src,
- int num_pixels, uint8_t* dst) {
- const uint32_t* const end = src + (num_pixels & ~7);
- const uint8x8_t shuffle0 = vld1_u8(kBGRShuffle[0]);
- const uint8x8_t shuffle1 = vld1_u8(kBGRShuffle[1]);
- const uint8x8_t shuffle2 = vld1_u8(kBGRShuffle[2]);
- for (; src < end; src += 8) {
- uint8x8x4_t pixels;
- INIT_VECTOR4(pixels,
- vld1_u8((const uint8_t*)(src + 0)),
- vld1_u8((const uint8_t*)(src + 2)),
- vld1_u8((const uint8_t*)(src + 4)),
- vld1_u8((const uint8_t*)(src + 6)));
- vst1_u8(dst + 0, vtbl4_u8(pixels, shuffle0));
- vst1_u8(dst + 8, vtbl4_u8(pixels, shuffle1));
- vst1_u8(dst + 16, vtbl4_u8(pixels, shuffle2));
- dst += 8 * 3;
- }
- VP8LConvertBGRAToBGR_C(src, num_pixels & 7, dst); // left-overs
-}
-
-static const uint8_t kRGBShuffle[3][8] = {
- { 2, 1, 0, 6, 5, 4, 10, 9 },
- { 8, 14, 13, 12, 18, 17, 16, 22 },
- { 21, 20, 26, 25, 24, 30, 29, 28 }
-};
-
-static void ConvertBGRAToRGB_NEON(const uint32_t* src,
- int num_pixels, uint8_t* dst) {
- const uint32_t* const end = src + (num_pixels & ~7);
- const uint8x8_t shuffle0 = vld1_u8(kRGBShuffle[0]);
- const uint8x8_t shuffle1 = vld1_u8(kRGBShuffle[1]);
- const uint8x8_t shuffle2 = vld1_u8(kRGBShuffle[2]);
- for (; src < end; src += 8) {
- uint8x8x4_t pixels;
- INIT_VECTOR4(pixels,
- vld1_u8((const uint8_t*)(src + 0)),
- vld1_u8((const uint8_t*)(src + 2)),
- vld1_u8((const uint8_t*)(src + 4)),
- vld1_u8((const uint8_t*)(src + 6)));
- vst1_u8(dst + 0, vtbl4_u8(pixels, shuffle0));
- vst1_u8(dst + 8, vtbl4_u8(pixels, shuffle1));
- vst1_u8(dst + 16, vtbl4_u8(pixels, shuffle2));
- dst += 8 * 3;
- }
- VP8LConvertBGRAToRGB_C(src, num_pixels & 7, dst); // left-overs
-}
-
-#endif // !WORK_AROUND_GCC
-
-//------------------------------------------------------------------------------
-// Predictor Transform
-
-#define LOAD_U32_AS_U8(IN) vreinterpret_u8_u32(vdup_n_u32((IN)))
-#define LOAD_U32P_AS_U8(IN) vreinterpret_u8_u32(vld1_u32((IN)))
-#define LOADQ_U32_AS_U8(IN) vreinterpretq_u8_u32(vdupq_n_u32((IN)))
-#define LOADQ_U32P_AS_U8(IN) vreinterpretq_u8_u32(vld1q_u32((IN)))
-#define GET_U8_AS_U32(IN) vget_lane_u32(vreinterpret_u32_u8((IN)), 0);
-#define GETQ_U8_AS_U32(IN) vgetq_lane_u32(vreinterpretq_u32_u8((IN)), 0);
-#define STOREQ_U8_AS_U32P(OUT, IN) vst1q_u32((OUT), vreinterpretq_u32_u8((IN)));
-#define ROTATE32_LEFT(L) vextq_u8((L), (L), 12) // D|C|B|A -> C|B|A|D
-
-static WEBP_INLINE uint8x8_t Average2_u8_NEON(uint32_t a0, uint32_t a1) {
- const uint8x8_t A0 = LOAD_U32_AS_U8(a0);
- const uint8x8_t A1 = LOAD_U32_AS_U8(a1);
- return vhadd_u8(A0, A1);
-}
-
-static WEBP_INLINE uint32_t ClampedAddSubtractHalf_NEON(uint32_t c0,
- uint32_t c1,
- uint32_t c2) {
- const uint8x8_t avg = Average2_u8_NEON(c0, c1);
- // Remove one to c2 when bigger than avg.
- const uint8x8_t C2 = LOAD_U32_AS_U8(c2);
- const uint8x8_t cmp = vcgt_u8(C2, avg);
- const uint8x8_t C2_1 = vadd_u8(C2, cmp);
- // Compute half of the difference between avg and c2.
- const int8x8_t diff_avg = vreinterpret_s8_u8(vhsub_u8(avg, C2_1));
- // Compute the sum with avg and saturate.
- const int16x8_t avg_16 = vreinterpretq_s16_u16(vmovl_u8(avg));
- const uint8x8_t res = vqmovun_s16(vaddw_s8(avg_16, diff_avg));
- const uint32_t output = GET_U8_AS_U32(res);
- return output;
-}
-
-static WEBP_INLINE uint32_t Average2_NEON(uint32_t a0, uint32_t a1) {
- const uint8x8_t avg_u8x8 = Average2_u8_NEON(a0, a1);
- const uint32_t avg = GET_U8_AS_U32(avg_u8x8);
- return avg;
-}
-
-static WEBP_INLINE uint32_t Average3_NEON(uint32_t a0, uint32_t a1,
- uint32_t a2) {
- const uint8x8_t avg0 = Average2_u8_NEON(a0, a2);
- const uint8x8_t A1 = LOAD_U32_AS_U8(a1);
- const uint32_t avg = GET_U8_AS_U32(vhadd_u8(avg0, A1));
- return avg;
-}
-
-static uint32_t Predictor5_NEON(const uint32_t* const left,
- const uint32_t* const top) {
- return Average3_NEON(*left, top[0], top[1]);
-}
-static uint32_t Predictor6_NEON(const uint32_t* const left,
- const uint32_t* const top) {
- return Average2_NEON(*left, top[-1]);
-}
-static uint32_t Predictor7_NEON(const uint32_t* const left,
- const uint32_t* const top) {
- return Average2_NEON(*left, top[0]);
-}
-static uint32_t Predictor13_NEON(const uint32_t* const left,
- const uint32_t* const top) {
- return ClampedAddSubtractHalf_NEON(*left, top[0], top[-1]);
-}
-
-// Batch versions of those functions.
-
-// Predictor0: ARGB_BLACK.
-static void PredictorAdd0_NEON(const uint32_t* in, const uint32_t* upper,
- int num_pixels, uint32_t* out) {
- int i;
- const uint8x16_t black = vreinterpretq_u8_u32(vdupq_n_u32(ARGB_BLACK));
- for (i = 0; i + 4 <= num_pixels; i += 4) {
- const uint8x16_t src = LOADQ_U32P_AS_U8(&in[i]);
- const uint8x16_t res = vaddq_u8(src, black);
- STOREQ_U8_AS_U32P(&out[i], res);
- }
- VP8LPredictorsAdd_C[0](in + i, upper + i, num_pixels - i, out + i);
-}
-
-// Predictor1: left.
-static void PredictorAdd1_NEON(const uint32_t* in, const uint32_t* upper,
- int num_pixels, uint32_t* out) {
- int i;
- const uint8x16_t zero = LOADQ_U32_AS_U8(0);
- for (i = 0; i + 4 <= num_pixels; i += 4) {
- // a | b | c | d
- const uint8x16_t src = LOADQ_U32P_AS_U8(&in[i]);
- // 0 | a | b | c
- const uint8x16_t shift0 = vextq_u8(zero, src, 12);
- // a | a + b | b + c | c + d
- const uint8x16_t sum0 = vaddq_u8(src, shift0);
- // 0 | 0 | a | a + b
- const uint8x16_t shift1 = vextq_u8(zero, sum0, 8);
- // a | a + b | a + b + c | a + b + c + d
- const uint8x16_t sum1 = vaddq_u8(sum0, shift1);
- const uint8x16_t prev = LOADQ_U32_AS_U8(out[i - 1]);
- const uint8x16_t res = vaddq_u8(sum1, prev);
- STOREQ_U8_AS_U32P(&out[i], res);
- }
- VP8LPredictorsAdd_C[1](in + i, upper + i, num_pixels - i, out + i);
-}
-
-// Macro that adds 32-bit integers from IN using mod 256 arithmetic
-// per 8 bit channel.
-#define GENERATE_PREDICTOR_1(X, IN) \
-static void PredictorAdd##X##_NEON(const uint32_t* in, \
- const uint32_t* upper, int num_pixels, \
- uint32_t* out) { \
- int i; \
- for (i = 0; i + 4 <= num_pixels; i += 4) { \
- const uint8x16_t src = LOADQ_U32P_AS_U8(&in[i]); \
- const uint8x16_t other = LOADQ_U32P_AS_U8(&(IN)); \
- const uint8x16_t res = vaddq_u8(src, other); \
- STOREQ_U8_AS_U32P(&out[i], res); \
- } \
- VP8LPredictorsAdd_C[(X)](in + i, upper + i, num_pixels - i, out + i); \
-}
-// Predictor2: Top.
-GENERATE_PREDICTOR_1(2, upper[i])
-// Predictor3: Top-right.
-GENERATE_PREDICTOR_1(3, upper[i + 1])
-// Predictor4: Top-left.
-GENERATE_PREDICTOR_1(4, upper[i - 1])
-#undef GENERATE_PREDICTOR_1
-
-// Predictor5: average(average(left, TR), T)
-#define DO_PRED5(LANE) do { \
- const uint8x16_t avgLTR = vhaddq_u8(L, TR); \
- const uint8x16_t avg = vhaddq_u8(avgLTR, T); \
- const uint8x16_t res = vaddq_u8(avg, src); \
- vst1q_lane_u32(&out[i + (LANE)], vreinterpretq_u32_u8(res), (LANE)); \
- L = ROTATE32_LEFT(res); \
-} while (0)
-
-static void PredictorAdd5_NEON(const uint32_t* in, const uint32_t* upper,
- int num_pixels, uint32_t* out) {
- int i;
- uint8x16_t L = LOADQ_U32_AS_U8(out[-1]);
- for (i = 0; i + 4 <= num_pixels; i += 4) {
- const uint8x16_t src = LOADQ_U32P_AS_U8(&in[i]);
- const uint8x16_t T = LOADQ_U32P_AS_U8(&upper[i + 0]);
- const uint8x16_t TR = LOADQ_U32P_AS_U8(&upper[i + 1]);
- DO_PRED5(0);
- DO_PRED5(1);
- DO_PRED5(2);
- DO_PRED5(3);
- }
- VP8LPredictorsAdd_C[5](in + i, upper + i, num_pixels - i, out + i);
-}
-#undef DO_PRED5
-
-#define DO_PRED67(LANE) do { \
- const uint8x16_t avg = vhaddq_u8(L, top); \
- const uint8x16_t res = vaddq_u8(avg, src); \
- vst1q_lane_u32(&out[i + (LANE)], vreinterpretq_u32_u8(res), (LANE)); \
- L = ROTATE32_LEFT(res); \
-} while (0)
-
-// Predictor6: average(left, TL)
-static void PredictorAdd6_NEON(const uint32_t* in, const uint32_t* upper,
- int num_pixels, uint32_t* out) {
- int i;
- uint8x16_t L = LOADQ_U32_AS_U8(out[-1]);
- for (i = 0; i + 4 <= num_pixels; i += 4) {
- const uint8x16_t src = LOADQ_U32P_AS_U8(&in[i]);
- const uint8x16_t top = LOADQ_U32P_AS_U8(&upper[i - 1]);
- DO_PRED67(0);
- DO_PRED67(1);
- DO_PRED67(2);
- DO_PRED67(3);
- }
- VP8LPredictorsAdd_C[6](in + i, upper + i, num_pixels - i, out + i);
-}
-
-// Predictor7: average(left, T)
-static void PredictorAdd7_NEON(const uint32_t* in, const uint32_t* upper,
- int num_pixels, uint32_t* out) {
- int i;
- uint8x16_t L = LOADQ_U32_AS_U8(out[-1]);
- for (i = 0; i + 4 <= num_pixels; i += 4) {
- const uint8x16_t src = LOADQ_U32P_AS_U8(&in[i]);
- const uint8x16_t top = LOADQ_U32P_AS_U8(&upper[i]);
- DO_PRED67(0);
- DO_PRED67(1);
- DO_PRED67(2);
- DO_PRED67(3);
- }
- VP8LPredictorsAdd_C[7](in + i, upper + i, num_pixels - i, out + i);
-}
-#undef DO_PRED67
-
-#define GENERATE_PREDICTOR_2(X, IN) \
-static void PredictorAdd##X##_NEON(const uint32_t* in, \
- const uint32_t* upper, int num_pixels, \
- uint32_t* out) { \
- int i; \
- for (i = 0; i + 4 <= num_pixels; i += 4) { \
- const uint8x16_t src = LOADQ_U32P_AS_U8(&in[i]); \
- const uint8x16_t Tother = LOADQ_U32P_AS_U8(&(IN)); \
- const uint8x16_t T = LOADQ_U32P_AS_U8(&upper[i]); \
- const uint8x16_t avg = vhaddq_u8(T, Tother); \
- const uint8x16_t res = vaddq_u8(avg, src); \
- STOREQ_U8_AS_U32P(&out[i], res); \
- } \
- VP8LPredictorsAdd_C[(X)](in + i, upper + i, num_pixels - i, out + i); \
-}
-// Predictor8: average TL T.
-GENERATE_PREDICTOR_2(8, upper[i - 1])
-// Predictor9: average T TR.
-GENERATE_PREDICTOR_2(9, upper[i + 1])
-#undef GENERATE_PREDICTOR_2
-
-// Predictor10: average of (average of (L,TL), average of (T, TR)).
-#define DO_PRED10(LANE) do { \
- const uint8x16_t avgLTL = vhaddq_u8(L, TL); \
- const uint8x16_t avg = vhaddq_u8(avgTTR, avgLTL); \
- const uint8x16_t res = vaddq_u8(avg, src); \
- vst1q_lane_u32(&out[i + (LANE)], vreinterpretq_u32_u8(res), (LANE)); \
- L = ROTATE32_LEFT(res); \
-} while (0)
-
-static void PredictorAdd10_NEON(const uint32_t* in, const uint32_t* upper,
- int num_pixels, uint32_t* out) {
- int i;
- uint8x16_t L = LOADQ_U32_AS_U8(out[-1]);
- for (i = 0; i + 4 <= num_pixels; i += 4) {
- const uint8x16_t src = LOADQ_U32P_AS_U8(&in[i]);
- const uint8x16_t TL = LOADQ_U32P_AS_U8(&upper[i - 1]);
- const uint8x16_t T = LOADQ_U32P_AS_U8(&upper[i]);
- const uint8x16_t TR = LOADQ_U32P_AS_U8(&upper[i + 1]);
- const uint8x16_t avgTTR = vhaddq_u8(T, TR);
- DO_PRED10(0);
- DO_PRED10(1);
- DO_PRED10(2);
- DO_PRED10(3);
- }
- VP8LPredictorsAdd_C[10](in + i, upper + i, num_pixels - i, out + i);
-}
-#undef DO_PRED10
-
-// Predictor11: select.
-#define DO_PRED11(LANE) do { \
- const uint8x16_t sumLin = vaddq_u8(L, src); /* in + L */ \
- const uint8x16_t pLTL = vabdq_u8(L, TL); /* |L - TL| */ \
- const uint16x8_t sum_LTL = vpaddlq_u8(pLTL); \
- const uint32x4_t pa = vpaddlq_u16(sum_LTL); \
- const uint32x4_t mask = vcleq_u32(pa, pb); \
- const uint8x16_t res = vbslq_u8(vreinterpretq_u8_u32(mask), sumTin, sumLin); \
- vst1q_lane_u32(&out[i + (LANE)], vreinterpretq_u32_u8(res), (LANE)); \
- L = ROTATE32_LEFT(res); \
-} while (0)
-
-static void PredictorAdd11_NEON(const uint32_t* in, const uint32_t* upper,
- int num_pixels, uint32_t* out) {
- int i;
- uint8x16_t L = LOADQ_U32_AS_U8(out[-1]);
- for (i = 0; i + 4 <= num_pixels; i += 4) {
- const uint8x16_t T = LOADQ_U32P_AS_U8(&upper[i]);
- const uint8x16_t TL = LOADQ_U32P_AS_U8(&upper[i - 1]);
- const uint8x16_t pTTL = vabdq_u8(T, TL); // |T - TL|
- const uint16x8_t sum_TTL = vpaddlq_u8(pTTL);
- const uint32x4_t pb = vpaddlq_u16(sum_TTL);
- const uint8x16_t src = LOADQ_U32P_AS_U8(&in[i]);
- const uint8x16_t sumTin = vaddq_u8(T, src); // in + T
- DO_PRED11(0);
- DO_PRED11(1);
- DO_PRED11(2);
- DO_PRED11(3);
- }
- VP8LPredictorsAdd_C[11](in + i, upper + i, num_pixels - i, out + i);
-}
-#undef DO_PRED11
-
-// Predictor12: ClampedAddSubtractFull.
-#define DO_PRED12(DIFF, LANE) do { \
- const uint8x8_t pred = \
- vqmovun_s16(vaddq_s16(vreinterpretq_s16_u16(L), (DIFF))); \
- const uint8x8_t res = \
- vadd_u8(pred, (LANE <= 1) ? vget_low_u8(src) : vget_high_u8(src)); \
- const uint16x8_t res16 = vmovl_u8(res); \
- vst1_lane_u32(&out[i + (LANE)], vreinterpret_u32_u8(res), (LANE) & 1); \
- /* rotate in the left predictor for next iteration */ \
- L = vextq_u16(res16, res16, 4); \
-} while (0)
-
-static void PredictorAdd12_NEON(const uint32_t* in, const uint32_t* upper,
- int num_pixels, uint32_t* out) {
- int i;
- uint16x8_t L = vmovl_u8(LOAD_U32_AS_U8(out[-1]));
- for (i = 0; i + 4 <= num_pixels; i += 4) {
- // load four pixels of source
- const uint8x16_t src = LOADQ_U32P_AS_U8(&in[i]);
- // precompute the difference T - TL once for all, stored as s16
- const uint8x16_t TL = LOADQ_U32P_AS_U8(&upper[i - 1]);
- const uint8x16_t T = LOADQ_U32P_AS_U8(&upper[i]);
- const int16x8_t diff_lo =
- vreinterpretq_s16_u16(vsubl_u8(vget_low_u8(T), vget_low_u8(TL)));
- const int16x8_t diff_hi =
- vreinterpretq_s16_u16(vsubl_u8(vget_high_u8(T), vget_high_u8(TL)));
- // loop over the four reconstructed pixels
- DO_PRED12(diff_lo, 0);
- DO_PRED12(diff_lo, 1);
- DO_PRED12(diff_hi, 2);
- DO_PRED12(diff_hi, 3);
- }
- VP8LPredictorsAdd_C[12](in + i, upper + i, num_pixels - i, out + i);
-}
-#undef DO_PRED12
-
-// Predictor13: ClampedAddSubtractHalf
-#define DO_PRED13(LANE, LOW_OR_HI) do { \
- const uint8x16_t avg = vhaddq_u8(L, T); \
- const uint8x16_t cmp = vcgtq_u8(TL, avg); \
- const uint8x16_t TL_1 = vaddq_u8(TL, cmp); \
- /* Compute half of the difference between avg and TL'. */ \
- const int8x8_t diff_avg = \
- vreinterpret_s8_u8(LOW_OR_HI(vhsubq_u8(avg, TL_1))); \
- /* Compute the sum with avg and saturate. */ \
- const int16x8_t avg_16 = vreinterpretq_s16_u16(vmovl_u8(LOW_OR_HI(avg))); \
- const uint8x8_t delta = vqmovun_s16(vaddw_s8(avg_16, diff_avg)); \
- const uint8x8_t res = vadd_u8(LOW_OR_HI(src), delta); \
- const uint8x16_t res2 = vcombine_u8(res, res); \
- vst1_lane_u32(&out[i + (LANE)], vreinterpret_u32_u8(res), (LANE) & 1); \
- L = ROTATE32_LEFT(res2); \
-} while (0)
-
-static void PredictorAdd13_NEON(const uint32_t* in, const uint32_t* upper,
- int num_pixels, uint32_t* out) {
- int i;
- uint8x16_t L = LOADQ_U32_AS_U8(out[-1]);
- for (i = 0; i + 4 <= num_pixels; i += 4) {
- const uint8x16_t src = LOADQ_U32P_AS_U8(&in[i]);
- const uint8x16_t T = LOADQ_U32P_AS_U8(&upper[i]);
- const uint8x16_t TL = LOADQ_U32P_AS_U8(&upper[i - 1]);
- DO_PRED13(0, vget_low_u8);
- DO_PRED13(1, vget_low_u8);
- DO_PRED13(2, vget_high_u8);
- DO_PRED13(3, vget_high_u8);
- }
- VP8LPredictorsAdd_C[13](in + i, upper + i, num_pixels - i, out + i);
-}
-#undef DO_PRED13
-
-#undef LOAD_U32_AS_U8
-#undef LOAD_U32P_AS_U8
-#undef LOADQ_U32_AS_U8
-#undef LOADQ_U32P_AS_U8
-#undef GET_U8_AS_U32
-#undef GETQ_U8_AS_U32
-#undef STOREQ_U8_AS_U32P
-#undef ROTATE32_LEFT
-
-//------------------------------------------------------------------------------
-// Subtract-Green Transform
-
-// vtbl?_u8 are marked unavailable for iOS arm64 with Xcode < 6.3, use
-// non-standard versions there.
-#if defined(__APPLE__) && defined(__aarch64__) && \
- defined(__apple_build_version__) && (__apple_build_version__< 6020037)
-#define USE_VTBLQ
-#endif
-
-#ifdef USE_VTBLQ
-// 255 = byte will be zeroed
-static const uint8_t kGreenShuffle[16] = {
- 1, 255, 1, 255, 5, 255, 5, 255, 9, 255, 9, 255, 13, 255, 13, 255
-};
-
-static WEBP_INLINE uint8x16_t DoGreenShuffle_NEON(const uint8x16_t argb,
- const uint8x16_t shuffle) {
- return vcombine_u8(vtbl1q_u8(argb, vget_low_u8(shuffle)),
- vtbl1q_u8(argb, vget_high_u8(shuffle)));
-}
-#else // !USE_VTBLQ
-// 255 = byte will be zeroed
-static const uint8_t kGreenShuffle[8] = { 1, 255, 1, 255, 5, 255, 5, 255 };
-
-static WEBP_INLINE uint8x16_t DoGreenShuffle_NEON(const uint8x16_t argb,
- const uint8x8_t shuffle) {
- return vcombine_u8(vtbl1_u8(vget_low_u8(argb), shuffle),
- vtbl1_u8(vget_high_u8(argb), shuffle));
-}
-#endif // USE_VTBLQ
-
-static void AddGreenToBlueAndRed_NEON(const uint32_t* src, int num_pixels,
- uint32_t* dst) {
- const uint32_t* const end = src + (num_pixels & ~3);
-#ifdef USE_VTBLQ
- const uint8x16_t shuffle = vld1q_u8(kGreenShuffle);
-#else
- const uint8x8_t shuffle = vld1_u8(kGreenShuffle);
-#endif
- for (; src < end; src += 4, dst += 4) {
- const uint8x16_t argb = vld1q_u8((const uint8_t*)src);
- const uint8x16_t greens = DoGreenShuffle_NEON(argb, shuffle);
- vst1q_u8((uint8_t*)dst, vaddq_u8(argb, greens));
- }
- // fallthrough and finish off with plain-C
- VP8LAddGreenToBlueAndRed_C(src, num_pixels & 3, dst);
-}
-
-//------------------------------------------------------------------------------
-// Color Transform
-
-static void TransformColorInverse_NEON(const VP8LMultipliers* const m,
- const uint32_t* const src,
- int num_pixels, uint32_t* dst) {
-// sign-extended multiplying constants, pre-shifted by 6.
-#define CST(X) (((int16_t)(m->X << 8)) >> 6)
- const int16_t rb[8] = {
- CST(green_to_blue_), CST(green_to_red_),
- CST(green_to_blue_), CST(green_to_red_),
- CST(green_to_blue_), CST(green_to_red_),
- CST(green_to_blue_), CST(green_to_red_)
- };
- const int16x8_t mults_rb = vld1q_s16(rb);
- const int16_t b2[8] = {
- 0, CST(red_to_blue_), 0, CST(red_to_blue_),
- 0, CST(red_to_blue_), 0, CST(red_to_blue_),
- };
- const int16x8_t mults_b2 = vld1q_s16(b2);
-#undef CST
-#ifdef USE_VTBLQ
- static const uint8_t kg0g0[16] = {
- 255, 1, 255, 1, 255, 5, 255, 5, 255, 9, 255, 9, 255, 13, 255, 13
- };
- const uint8x16_t shuffle = vld1q_u8(kg0g0);
-#else
- static const uint8_t k0g0g[8] = { 255, 1, 255, 1, 255, 5, 255, 5 };
- const uint8x8_t shuffle = vld1_u8(k0g0g);
-#endif
- const uint32x4_t mask_ag = vdupq_n_u32(0xff00ff00u);
- int i;
- for (i = 0; i + 4 <= num_pixels; i += 4) {
- const uint8x16_t in = vld1q_u8((const uint8_t*)(src + i));
- const uint32x4_t a0g0 = vandq_u32(vreinterpretq_u32_u8(in), mask_ag);
- // 0 g 0 g
- const uint8x16_t greens = DoGreenShuffle_NEON(in, shuffle);
- // x dr x db1
- const int16x8_t A = vqdmulhq_s16(vreinterpretq_s16_u8(greens), mults_rb);
- // x r' x b'
- const int8x16_t B = vaddq_s8(vreinterpretq_s8_u8(in),
- vreinterpretq_s8_s16(A));
- // r' 0 b' 0
- const int16x8_t C = vshlq_n_s16(vreinterpretq_s16_s8(B), 8);
- // x db2 0 0
- const int16x8_t D = vqdmulhq_s16(C, mults_b2);
- // 0 x db2 0
- const uint32x4_t E = vshrq_n_u32(vreinterpretq_u32_s16(D), 8);
- // r' x b'' 0
- const int8x16_t F = vaddq_s8(vreinterpretq_s8_u32(E),
- vreinterpretq_s8_s16(C));
- // 0 r' 0 b''
- const uint16x8_t G = vshrq_n_u16(vreinterpretq_u16_s8(F), 8);
- const uint32x4_t out = vorrq_u32(vreinterpretq_u32_u16(G), a0g0);
- vst1q_u32(dst + i, out);
- }
- // Fall-back to C-version for left-overs.
- VP8LTransformColorInverse_C(m, src + i, num_pixels - i, dst + i);
-}
-
-#undef USE_VTBLQ
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void VP8LDspInitNEON(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void VP8LDspInitNEON(void) {
- VP8LPredictors[5] = Predictor5_NEON;
- VP8LPredictors[6] = Predictor6_NEON;
- VP8LPredictors[7] = Predictor7_NEON;
- VP8LPredictors[13] = Predictor13_NEON;
-
- VP8LPredictorsAdd[0] = PredictorAdd0_NEON;
- VP8LPredictorsAdd[1] = PredictorAdd1_NEON;
- VP8LPredictorsAdd[2] = PredictorAdd2_NEON;
- VP8LPredictorsAdd[3] = PredictorAdd3_NEON;
- VP8LPredictorsAdd[4] = PredictorAdd4_NEON;
- VP8LPredictorsAdd[5] = PredictorAdd5_NEON;
- VP8LPredictorsAdd[6] = PredictorAdd6_NEON;
- VP8LPredictorsAdd[7] = PredictorAdd7_NEON;
- VP8LPredictorsAdd[8] = PredictorAdd8_NEON;
- VP8LPredictorsAdd[9] = PredictorAdd9_NEON;
- VP8LPredictorsAdd[10] = PredictorAdd10_NEON;
- VP8LPredictorsAdd[11] = PredictorAdd11_NEON;
- VP8LPredictorsAdd[12] = PredictorAdd12_NEON;
- VP8LPredictorsAdd[13] = PredictorAdd13_NEON;
-
- VP8LConvertBGRAToRGBA = ConvertBGRAToRGBA_NEON;
- VP8LConvertBGRAToBGR = ConvertBGRAToBGR_NEON;
- VP8LConvertBGRAToRGB = ConvertBGRAToRGB_NEON;
-
- VP8LAddGreenToBlueAndRed = AddGreenToBlueAndRed_NEON;
- VP8LTransformColorInverse = TransformColorInverse_NEON;
-}
-
-#else // !WEBP_USE_NEON
-
-WEBP_DSP_INIT_STUB(VP8LDspInitNEON)
-
-#endif // WEBP_USE_NEON
diff --git a/contrib/libs/libwebp/dsp/lossless_sse2.c b/contrib/libs/libwebp/dsp/lossless_sse2.c
deleted file mode 100644
index 6b67709a54..0000000000
--- a/contrib/libs/libwebp/dsp/lossless_sse2.c
+++ /dev/null
@@ -1,716 +0,0 @@
-// Copyright 2014 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// SSE2 variant of methods for lossless decoder
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_SSE2)
-
-#include "./common_sse2.h"
-#include "./lossless.h"
-#include "./lossless_common.h"
-#include <emmintrin.h>
-
-//------------------------------------------------------------------------------
-// Predictor Transform
-
-static WEBP_INLINE uint32_t ClampedAddSubtractFull_SSE2(uint32_t c0,
- uint32_t c1,
- uint32_t c2) {
- const __m128i zero = _mm_setzero_si128();
- const __m128i C0 = _mm_unpacklo_epi8(_mm_cvtsi32_si128(c0), zero);
- const __m128i C1 = _mm_unpacklo_epi8(_mm_cvtsi32_si128(c1), zero);
- const __m128i C2 = _mm_unpacklo_epi8(_mm_cvtsi32_si128(c2), zero);
- const __m128i V1 = _mm_add_epi16(C0, C1);
- const __m128i V2 = _mm_sub_epi16(V1, C2);
- const __m128i b = _mm_packus_epi16(V2, V2);
- const uint32_t output = _mm_cvtsi128_si32(b);
- return output;
-}
-
-static WEBP_INLINE uint32_t ClampedAddSubtractHalf_SSE2(uint32_t c0,
- uint32_t c1,
- uint32_t c2) {
- const __m128i zero = _mm_setzero_si128();
- const __m128i C0 = _mm_unpacklo_epi8(_mm_cvtsi32_si128(c0), zero);
- const __m128i C1 = _mm_unpacklo_epi8(_mm_cvtsi32_si128(c1), zero);
- const __m128i B0 = _mm_unpacklo_epi8(_mm_cvtsi32_si128(c2), zero);
- const __m128i avg = _mm_add_epi16(C1, C0);
- const __m128i A0 = _mm_srli_epi16(avg, 1);
- const __m128i A1 = _mm_sub_epi16(A0, B0);
- const __m128i BgtA = _mm_cmpgt_epi16(B0, A0);
- const __m128i A2 = _mm_sub_epi16(A1, BgtA);
- const __m128i A3 = _mm_srai_epi16(A2, 1);
- const __m128i A4 = _mm_add_epi16(A0, A3);
- const __m128i A5 = _mm_packus_epi16(A4, A4);
- const uint32_t output = _mm_cvtsi128_si32(A5);
- return output;
-}
-
-static WEBP_INLINE uint32_t Select_SSE2(uint32_t a, uint32_t b, uint32_t c) {
- int pa_minus_pb;
- const __m128i zero = _mm_setzero_si128();
- const __m128i A0 = _mm_cvtsi32_si128(a);
- const __m128i B0 = _mm_cvtsi32_si128(b);
- const __m128i C0 = _mm_cvtsi32_si128(c);
- const __m128i AC0 = _mm_subs_epu8(A0, C0);
- const __m128i CA0 = _mm_subs_epu8(C0, A0);
- const __m128i BC0 = _mm_subs_epu8(B0, C0);
- const __m128i CB0 = _mm_subs_epu8(C0, B0);
- const __m128i AC = _mm_or_si128(AC0, CA0);
- const __m128i BC = _mm_or_si128(BC0, CB0);
- const __m128i pa = _mm_unpacklo_epi8(AC, zero); // |a - c|
- const __m128i pb = _mm_unpacklo_epi8(BC, zero); // |b - c|
- const __m128i diff = _mm_sub_epi16(pb, pa);
- {
- int16_t out[8];
- _mm_storeu_si128((__m128i*)out, diff);
- pa_minus_pb = out[0] + out[1] + out[2] + out[3];
- }
- return (pa_minus_pb <= 0) ? a : b;
-}
-
-static WEBP_INLINE void Average2_m128i(const __m128i* const a0,
- const __m128i* const a1,
- __m128i* const avg) {
- // (a + b) >> 1 = ((a + b + 1) >> 1) - ((a ^ b) & 1)
- const __m128i ones = _mm_set1_epi8(1);
- const __m128i avg1 = _mm_avg_epu8(*a0, *a1);
- const __m128i one = _mm_and_si128(_mm_xor_si128(*a0, *a1), ones);
- *avg = _mm_sub_epi8(avg1, one);
-}
-
-static WEBP_INLINE void Average2_uint32_SSE2(const uint32_t a0,
- const uint32_t a1,
- __m128i* const avg) {
- // (a + b) >> 1 = ((a + b + 1) >> 1) - ((a ^ b) & 1)
- const __m128i ones = _mm_set1_epi8(1);
- const __m128i A0 = _mm_cvtsi32_si128(a0);
- const __m128i A1 = _mm_cvtsi32_si128(a1);
- const __m128i avg1 = _mm_avg_epu8(A0, A1);
- const __m128i one = _mm_and_si128(_mm_xor_si128(A0, A1), ones);
- *avg = _mm_sub_epi8(avg1, one);
-}
-
-static WEBP_INLINE __m128i Average2_uint32_16_SSE2(uint32_t a0, uint32_t a1) {
- const __m128i zero = _mm_setzero_si128();
- const __m128i A0 = _mm_unpacklo_epi8(_mm_cvtsi32_si128(a0), zero);
- const __m128i A1 = _mm_unpacklo_epi8(_mm_cvtsi32_si128(a1), zero);
- const __m128i sum = _mm_add_epi16(A1, A0);
- return _mm_srli_epi16(sum, 1);
-}
-
-static WEBP_INLINE uint32_t Average2_SSE2(uint32_t a0, uint32_t a1) {
- __m128i output;
- Average2_uint32_SSE2(a0, a1, &output);
- return _mm_cvtsi128_si32(output);
-}
-
-static WEBP_INLINE uint32_t Average3_SSE2(uint32_t a0, uint32_t a1,
- uint32_t a2) {
- const __m128i zero = _mm_setzero_si128();
- const __m128i avg1 = Average2_uint32_16_SSE2(a0, a2);
- const __m128i A1 = _mm_unpacklo_epi8(_mm_cvtsi32_si128(a1), zero);
- const __m128i sum = _mm_add_epi16(avg1, A1);
- const __m128i avg2 = _mm_srli_epi16(sum, 1);
- const __m128i A2 = _mm_packus_epi16(avg2, avg2);
- const uint32_t output = _mm_cvtsi128_si32(A2);
- return output;
-}
-
-static WEBP_INLINE uint32_t Average4_SSE2(uint32_t a0, uint32_t a1,
- uint32_t a2, uint32_t a3) {
- const __m128i avg1 = Average2_uint32_16_SSE2(a0, a1);
- const __m128i avg2 = Average2_uint32_16_SSE2(a2, a3);
- const __m128i sum = _mm_add_epi16(avg2, avg1);
- const __m128i avg3 = _mm_srli_epi16(sum, 1);
- const __m128i A0 = _mm_packus_epi16(avg3, avg3);
- const uint32_t output = _mm_cvtsi128_si32(A0);
- return output;
-}
-
-static uint32_t Predictor5_SSE2(const uint32_t* const left,
- const uint32_t* const top) {
- const uint32_t pred = Average3_SSE2(*left, top[0], top[1]);
- return pred;
-}
-static uint32_t Predictor6_SSE2(const uint32_t* const left,
- const uint32_t* const top) {
- const uint32_t pred = Average2_SSE2(*left, top[-1]);
- return pred;
-}
-static uint32_t Predictor7_SSE2(const uint32_t* const left,
- const uint32_t* const top) {
- const uint32_t pred = Average2_SSE2(*left, top[0]);
- return pred;
-}
-static uint32_t Predictor8_SSE2(const uint32_t* const left,
- const uint32_t* const top) {
- const uint32_t pred = Average2_SSE2(top[-1], top[0]);
- (void)left;
- return pred;
-}
-static uint32_t Predictor9_SSE2(const uint32_t* const left,
- const uint32_t* const top) {
- const uint32_t pred = Average2_SSE2(top[0], top[1]);
- (void)left;
- return pred;
-}
-static uint32_t Predictor10_SSE2(const uint32_t* const left,
- const uint32_t* const top) {
- const uint32_t pred = Average4_SSE2(*left, top[-1], top[0], top[1]);
- return pred;
-}
-static uint32_t Predictor11_SSE2(const uint32_t* const left,
- const uint32_t* const top) {
- const uint32_t pred = Select_SSE2(top[0], *left, top[-1]);
- return pred;
-}
-static uint32_t Predictor12_SSE2(const uint32_t* const left,
- const uint32_t* const top) {
- const uint32_t pred = ClampedAddSubtractFull_SSE2(*left, top[0], top[-1]);
- return pred;
-}
-static uint32_t Predictor13_SSE2(const uint32_t* const left,
- const uint32_t* const top) {
- const uint32_t pred = ClampedAddSubtractHalf_SSE2(*left, top[0], top[-1]);
- return pred;
-}
-
-// Batch versions of those functions.
-
-// Predictor0: ARGB_BLACK.
-static void PredictorAdd0_SSE2(const uint32_t* in, const uint32_t* upper,
- int num_pixels, uint32_t* out) {
- int i;
- const __m128i black = _mm_set1_epi32(ARGB_BLACK);
- for (i = 0; i + 4 <= num_pixels; i += 4) {
- const __m128i src = _mm_loadu_si128((const __m128i*)&in[i]);
- const __m128i res = _mm_add_epi8(src, black);
- _mm_storeu_si128((__m128i*)&out[i], res);
- }
- if (i != num_pixels) {
- VP8LPredictorsAdd_C[0](in + i, NULL, num_pixels - i, out + i);
- }
- (void)upper;
-}
-
-// Predictor1: left.
-static void PredictorAdd1_SSE2(const uint32_t* in, const uint32_t* upper,
- int num_pixels, uint32_t* out) {
- int i;
- __m128i prev = _mm_set1_epi32(out[-1]);
- for (i = 0; i + 4 <= num_pixels; i += 4) {
- // a | b | c | d
- const __m128i src = _mm_loadu_si128((const __m128i*)&in[i]);
- // 0 | a | b | c
- const __m128i shift0 = _mm_slli_si128(src, 4);
- // a | a + b | b + c | c + d
- const __m128i sum0 = _mm_add_epi8(src, shift0);
- // 0 | 0 | a | a + b
- const __m128i shift1 = _mm_slli_si128(sum0, 8);
- // a | a + b | a + b + c | a + b + c + d
- const __m128i sum1 = _mm_add_epi8(sum0, shift1);
- const __m128i res = _mm_add_epi8(sum1, prev);
- _mm_storeu_si128((__m128i*)&out[i], res);
- // replicate prev output on the four lanes
- prev = _mm_shuffle_epi32(res, (3 << 0) | (3 << 2) | (3 << 4) | (3 << 6));
- }
- if (i != num_pixels) {
- VP8LPredictorsAdd_C[1](in + i, upper + i, num_pixels - i, out + i);
- }
-}
-
-// Macro that adds 32-bit integers from IN using mod 256 arithmetic
-// per 8 bit channel.
-#define GENERATE_PREDICTOR_1(X, IN) \
-static void PredictorAdd##X##_SSE2(const uint32_t* in, const uint32_t* upper, \
- int num_pixels, uint32_t* out) { \
- int i; \
- for (i = 0; i + 4 <= num_pixels; i += 4) { \
- const __m128i src = _mm_loadu_si128((const __m128i*)&in[i]); \
- const __m128i other = _mm_loadu_si128((const __m128i*)&(IN)); \
- const __m128i res = _mm_add_epi8(src, other); \
- _mm_storeu_si128((__m128i*)&out[i], res); \
- } \
- if (i != num_pixels) { \
- VP8LPredictorsAdd_C[(X)](in + i, upper + i, num_pixels - i, out + i); \
- } \
-}
-
-// Predictor2: Top.
-GENERATE_PREDICTOR_1(2, upper[i])
-// Predictor3: Top-right.
-GENERATE_PREDICTOR_1(3, upper[i + 1])
-// Predictor4: Top-left.
-GENERATE_PREDICTOR_1(4, upper[i - 1])
-#undef GENERATE_PREDICTOR_1
-
-// Due to averages with integers, values cannot be accumulated in parallel for
-// predictors 5 to 7.
-GENERATE_PREDICTOR_ADD(Predictor5_SSE2, PredictorAdd5_SSE2)
-GENERATE_PREDICTOR_ADD(Predictor6_SSE2, PredictorAdd6_SSE2)
-GENERATE_PREDICTOR_ADD(Predictor7_SSE2, PredictorAdd7_SSE2)
-
-#define GENERATE_PREDICTOR_2(X, IN) \
-static void PredictorAdd##X##_SSE2(const uint32_t* in, const uint32_t* upper, \
- int num_pixels, uint32_t* out) { \
- int i; \
- for (i = 0; i + 4 <= num_pixels; i += 4) { \
- const __m128i Tother = _mm_loadu_si128((const __m128i*)&(IN)); \
- const __m128i T = _mm_loadu_si128((const __m128i*)&upper[i]); \
- const __m128i src = _mm_loadu_si128((const __m128i*)&in[i]); \
- __m128i avg, res; \
- Average2_m128i(&T, &Tother, &avg); \
- res = _mm_add_epi8(avg, src); \
- _mm_storeu_si128((__m128i*)&out[i], res); \
- } \
- if (i != num_pixels) { \
- VP8LPredictorsAdd_C[(X)](in + i, upper + i, num_pixels - i, out + i); \
- } \
-}
-// Predictor8: average TL T.
-GENERATE_PREDICTOR_2(8, upper[i - 1])
-// Predictor9: average T TR.
-GENERATE_PREDICTOR_2(9, upper[i + 1])
-#undef GENERATE_PREDICTOR_2
-
-// Predictor10: average of (average of (L,TL), average of (T, TR)).
-#define DO_PRED10(OUT) do { \
- __m128i avgLTL, avg; \
- Average2_m128i(&L, &TL, &avgLTL); \
- Average2_m128i(&avgTTR, &avgLTL, &avg); \
- L = _mm_add_epi8(avg, src); \
- out[i + (OUT)] = _mm_cvtsi128_si32(L); \
-} while (0)
-
-#define DO_PRED10_SHIFT do { \
- /* Rotate the pre-computed values for the next iteration.*/ \
- avgTTR = _mm_srli_si128(avgTTR, 4); \
- TL = _mm_srli_si128(TL, 4); \
- src = _mm_srli_si128(src, 4); \
-} while (0)
-
-static void PredictorAdd10_SSE2(const uint32_t* in, const uint32_t* upper,
- int num_pixels, uint32_t* out) {
- int i;
- __m128i L = _mm_cvtsi32_si128(out[-1]);
- for (i = 0; i + 4 <= num_pixels; i += 4) {
- __m128i src = _mm_loadu_si128((const __m128i*)&in[i]);
- __m128i TL = _mm_loadu_si128((const __m128i*)&upper[i - 1]);
- const __m128i T = _mm_loadu_si128((const __m128i*)&upper[i]);
- const __m128i TR = _mm_loadu_si128((const __m128i*)&upper[i + 1]);
- __m128i avgTTR;
- Average2_m128i(&T, &TR, &avgTTR);
- DO_PRED10(0);
- DO_PRED10_SHIFT;
- DO_PRED10(1);
- DO_PRED10_SHIFT;
- DO_PRED10(2);
- DO_PRED10_SHIFT;
- DO_PRED10(3);
- }
- if (i != num_pixels) {
- VP8LPredictorsAdd_C[10](in + i, upper + i, num_pixels - i, out + i);
- }
-}
-#undef DO_PRED10
-#undef DO_PRED10_SHIFT
-
-// Predictor11: select.
-#define DO_PRED11(OUT) do { \
- const __m128i L_lo = _mm_unpacklo_epi32(L, T); \
- const __m128i TL_lo = _mm_unpacklo_epi32(TL, T); \
- const __m128i pb = _mm_sad_epu8(L_lo, TL_lo); /* pb = sum |L-TL|*/ \
- const __m128i mask = _mm_cmpgt_epi32(pb, pa); \
- const __m128i A = _mm_and_si128(mask, L); \
- const __m128i B = _mm_andnot_si128(mask, T); \
- const __m128i pred = _mm_or_si128(A, B); /* pred = (pa > b)? L : T*/ \
- L = _mm_add_epi8(src, pred); \
- out[i + (OUT)] = _mm_cvtsi128_si32(L); \
-} while (0)
-
-#define DO_PRED11_SHIFT do { \
- /* Shift the pre-computed value for the next iteration.*/ \
- T = _mm_srli_si128(T, 4); \
- TL = _mm_srli_si128(TL, 4); \
- src = _mm_srli_si128(src, 4); \
- pa = _mm_srli_si128(pa, 4); \
-} while (0)
-
-static void PredictorAdd11_SSE2(const uint32_t* in, const uint32_t* upper,
- int num_pixels, uint32_t* out) {
- int i;
- __m128i pa;
- __m128i L = _mm_cvtsi32_si128(out[-1]);
- for (i = 0; i + 4 <= num_pixels; i += 4) {
- __m128i T = _mm_loadu_si128((const __m128i*)&upper[i]);
- __m128i TL = _mm_loadu_si128((const __m128i*)&upper[i - 1]);
- __m128i src = _mm_loadu_si128((const __m128i*)&in[i]);
- {
- // We can unpack with any value on the upper 32 bits, provided it's the
- // same on both operands (so that their sum of abs diff is zero). Here we
- // use T.
- const __m128i T_lo = _mm_unpacklo_epi32(T, T);
- const __m128i TL_lo = _mm_unpacklo_epi32(TL, T);
- const __m128i T_hi = _mm_unpackhi_epi32(T, T);
- const __m128i TL_hi = _mm_unpackhi_epi32(TL, T);
- const __m128i s_lo = _mm_sad_epu8(T_lo, TL_lo);
- const __m128i s_hi = _mm_sad_epu8(T_hi, TL_hi);
- pa = _mm_packs_epi32(s_lo, s_hi); // pa = sum |T-TL|
- }
- DO_PRED11(0);
- DO_PRED11_SHIFT;
- DO_PRED11(1);
- DO_PRED11_SHIFT;
- DO_PRED11(2);
- DO_PRED11_SHIFT;
- DO_PRED11(3);
- }
- if (i != num_pixels) {
- VP8LPredictorsAdd_C[11](in + i, upper + i, num_pixels - i, out + i);
- }
-}
-#undef DO_PRED11
-#undef DO_PRED11_SHIFT
-
-// Predictor12: ClampedAddSubtractFull.
-#define DO_PRED12(DIFF, LANE, OUT) do { \
- const __m128i all = _mm_add_epi16(L, (DIFF)); \
- const __m128i alls = _mm_packus_epi16(all, all); \
- const __m128i res = _mm_add_epi8(src, alls); \
- out[i + (OUT)] = _mm_cvtsi128_si32(res); \
- L = _mm_unpacklo_epi8(res, zero); \
-} while (0)
-
-#define DO_PRED12_SHIFT(DIFF, LANE) do { \
- /* Shift the pre-computed value for the next iteration.*/ \
- if ((LANE) == 0) (DIFF) = _mm_srli_si128((DIFF), 8); \
- src = _mm_srli_si128(src, 4); \
-} while (0)
-
-static void PredictorAdd12_SSE2(const uint32_t* in, const uint32_t* upper,
- int num_pixels, uint32_t* out) {
- int i;
- const __m128i zero = _mm_setzero_si128();
- const __m128i L8 = _mm_cvtsi32_si128(out[-1]);
- __m128i L = _mm_unpacklo_epi8(L8, zero);
- for (i = 0; i + 4 <= num_pixels; i += 4) {
- // Load 4 pixels at a time.
- __m128i src = _mm_loadu_si128((const __m128i*)&in[i]);
- const __m128i T = _mm_loadu_si128((const __m128i*)&upper[i]);
- const __m128i T_lo = _mm_unpacklo_epi8(T, zero);
- const __m128i T_hi = _mm_unpackhi_epi8(T, zero);
- const __m128i TL = _mm_loadu_si128((const __m128i*)&upper[i - 1]);
- const __m128i TL_lo = _mm_unpacklo_epi8(TL, zero);
- const __m128i TL_hi = _mm_unpackhi_epi8(TL, zero);
- __m128i diff_lo = _mm_sub_epi16(T_lo, TL_lo);
- __m128i diff_hi = _mm_sub_epi16(T_hi, TL_hi);
- DO_PRED12(diff_lo, 0, 0);
- DO_PRED12_SHIFT(diff_lo, 0);
- DO_PRED12(diff_lo, 1, 1);
- DO_PRED12_SHIFT(diff_lo, 1);
- DO_PRED12(diff_hi, 0, 2);
- DO_PRED12_SHIFT(diff_hi, 0);
- DO_PRED12(diff_hi, 1, 3);
- }
- if (i != num_pixels) {
- VP8LPredictorsAdd_C[12](in + i, upper + i, num_pixels - i, out + i);
- }
-}
-#undef DO_PRED12
-#undef DO_PRED12_SHIFT
-
-// Due to averages with integers, values cannot be accumulated in parallel for
-// predictors 13.
-GENERATE_PREDICTOR_ADD(Predictor13_SSE2, PredictorAdd13_SSE2)
-
-//------------------------------------------------------------------------------
-// Subtract-Green Transform
-
-static void AddGreenToBlueAndRed_SSE2(const uint32_t* const src, int num_pixels,
- uint32_t* dst) {
- int i;
- for (i = 0; i + 4 <= num_pixels; i += 4) {
- const __m128i in = _mm_loadu_si128((const __m128i*)&src[i]); // argb
- const __m128i A = _mm_srli_epi16(in, 8); // 0 a 0 g
- const __m128i B = _mm_shufflelo_epi16(A, _MM_SHUFFLE(2, 2, 0, 0));
- const __m128i C = _mm_shufflehi_epi16(B, _MM_SHUFFLE(2, 2, 0, 0)); // 0g0g
- const __m128i out = _mm_add_epi8(in, C);
- _mm_storeu_si128((__m128i*)&dst[i], out);
- }
- // fallthrough and finish off with plain-C
- if (i != num_pixels) {
- VP8LAddGreenToBlueAndRed_C(src + i, num_pixels - i, dst + i);
- }
-}
-
-//------------------------------------------------------------------------------
-// Color Transform
-
-static void TransformColorInverse_SSE2(const VP8LMultipliers* const m,
- const uint32_t* const src,
- int num_pixels, uint32_t* dst) {
-// sign-extended multiplying constants, pre-shifted by 5.
-#define CST(X) (((int16_t)(m->X << 8)) >> 5) // sign-extend
-#define MK_CST_16(HI, LO) \
- _mm_set1_epi32((int)(((uint32_t)(HI) << 16) | ((LO) & 0xffff)))
- const __m128i mults_rb = MK_CST_16(CST(green_to_red_), CST(green_to_blue_));
- const __m128i mults_b2 = MK_CST_16(CST(red_to_blue_), 0);
-#undef MK_CST_16
-#undef CST
- const __m128i mask_ag = _mm_set1_epi32(0xff00ff00); // alpha-green masks
- int i;
- for (i = 0; i + 4 <= num_pixels; i += 4) {
- const __m128i in = _mm_loadu_si128((const __m128i*)&src[i]); // argb
- const __m128i A = _mm_and_si128(in, mask_ag); // a 0 g 0
- const __m128i B = _mm_shufflelo_epi16(A, _MM_SHUFFLE(2, 2, 0, 0));
- const __m128i C = _mm_shufflehi_epi16(B, _MM_SHUFFLE(2, 2, 0, 0)); // g0g0
- const __m128i D = _mm_mulhi_epi16(C, mults_rb); // x dr x db1
- const __m128i E = _mm_add_epi8(in, D); // x r' x b'
- const __m128i F = _mm_slli_epi16(E, 8); // r' 0 b' 0
- const __m128i G = _mm_mulhi_epi16(F, mults_b2); // x db2 0 0
- const __m128i H = _mm_srli_epi32(G, 8); // 0 x db2 0
- const __m128i I = _mm_add_epi8(H, F); // r' x b'' 0
- const __m128i J = _mm_srli_epi16(I, 8); // 0 r' 0 b''
- const __m128i out = _mm_or_si128(J, A);
- _mm_storeu_si128((__m128i*)&dst[i], out);
- }
- // Fall-back to C-version for left-overs.
- if (i != num_pixels) {
- VP8LTransformColorInverse_C(m, src + i, num_pixels - i, dst + i);
- }
-}
-
-//------------------------------------------------------------------------------
-// Color-space conversion functions
-
-static void ConvertBGRAToRGB_SSE2(const uint32_t* src, int num_pixels,
- uint8_t* dst) {
- const __m128i* in = (const __m128i*)src;
- __m128i* out = (__m128i*)dst;
-
- while (num_pixels >= 32) {
- // Load the BGRA buffers.
- __m128i in0 = _mm_loadu_si128(in + 0);
- __m128i in1 = _mm_loadu_si128(in + 1);
- __m128i in2 = _mm_loadu_si128(in + 2);
- __m128i in3 = _mm_loadu_si128(in + 3);
- __m128i in4 = _mm_loadu_si128(in + 4);
- __m128i in5 = _mm_loadu_si128(in + 5);
- __m128i in6 = _mm_loadu_si128(in + 6);
- __m128i in7 = _mm_loadu_si128(in + 7);
- VP8L32bToPlanar_SSE2(&in0, &in1, &in2, &in3);
- VP8L32bToPlanar_SSE2(&in4, &in5, &in6, &in7);
- // At this points, in1/in5 contains red only, in2/in6 green only ...
- // Pack the colors in 24b RGB.
- VP8PlanarTo24b_SSE2(&in1, &in5, &in2, &in6, &in3, &in7);
- _mm_storeu_si128(out + 0, in1);
- _mm_storeu_si128(out + 1, in5);
- _mm_storeu_si128(out + 2, in2);
- _mm_storeu_si128(out + 3, in6);
- _mm_storeu_si128(out + 4, in3);
- _mm_storeu_si128(out + 5, in7);
- in += 8;
- out += 6;
- num_pixels -= 32;
- }
- // left-overs
- if (num_pixels > 0) {
- VP8LConvertBGRAToRGB_C((const uint32_t*)in, num_pixels, (uint8_t*)out);
- }
-}
-
-static void ConvertBGRAToRGBA_SSE2(const uint32_t* src,
- int num_pixels, uint8_t* dst) {
- const __m128i red_blue_mask = _mm_set1_epi32(0x00ff00ffu);
- const __m128i* in = (const __m128i*)src;
- __m128i* out = (__m128i*)dst;
- while (num_pixels >= 8) {
- const __m128i A1 = _mm_loadu_si128(in++);
- const __m128i A2 = _mm_loadu_si128(in++);
- const __m128i B1 = _mm_and_si128(A1, red_blue_mask); // R 0 B 0
- const __m128i B2 = _mm_and_si128(A2, red_blue_mask); // R 0 B 0
- const __m128i C1 = _mm_andnot_si128(red_blue_mask, A1); // 0 G 0 A
- const __m128i C2 = _mm_andnot_si128(red_blue_mask, A2); // 0 G 0 A
- const __m128i D1 = _mm_shufflelo_epi16(B1, _MM_SHUFFLE(2, 3, 0, 1));
- const __m128i D2 = _mm_shufflelo_epi16(B2, _MM_SHUFFLE(2, 3, 0, 1));
- const __m128i E1 = _mm_shufflehi_epi16(D1, _MM_SHUFFLE(2, 3, 0, 1));
- const __m128i E2 = _mm_shufflehi_epi16(D2, _MM_SHUFFLE(2, 3, 0, 1));
- const __m128i F1 = _mm_or_si128(E1, C1);
- const __m128i F2 = _mm_or_si128(E2, C2);
- _mm_storeu_si128(out++, F1);
- _mm_storeu_si128(out++, F2);
- num_pixels -= 8;
- }
- // left-overs
- if (num_pixels > 0) {
- VP8LConvertBGRAToRGBA_C((const uint32_t*)in, num_pixels, (uint8_t*)out);
- }
-}
-
-static void ConvertBGRAToRGBA4444_SSE2(const uint32_t* src,
- int num_pixels, uint8_t* dst) {
- const __m128i mask_0x0f = _mm_set1_epi8(0x0f);
- const __m128i mask_0xf0 = _mm_set1_epi8(0xf0);
- const __m128i* in = (const __m128i*)src;
- __m128i* out = (__m128i*)dst;
- while (num_pixels >= 8) {
- const __m128i bgra0 = _mm_loadu_si128(in++); // bgra0|bgra1|bgra2|bgra3
- const __m128i bgra4 = _mm_loadu_si128(in++); // bgra4|bgra5|bgra6|bgra7
- const __m128i v0l = _mm_unpacklo_epi8(bgra0, bgra4); // b0b4g0g4r0r4a0a4...
- const __m128i v0h = _mm_unpackhi_epi8(bgra0, bgra4); // b2b6g2g6r2r6a2a6...
- const __m128i v1l = _mm_unpacklo_epi8(v0l, v0h); // b0b2b4b6g0g2g4g6...
- const __m128i v1h = _mm_unpackhi_epi8(v0l, v0h); // b1b3b5b7g1g3g5g7...
- const __m128i v2l = _mm_unpacklo_epi8(v1l, v1h); // b0...b7 | g0...g7
- const __m128i v2h = _mm_unpackhi_epi8(v1l, v1h); // r0...r7 | a0...a7
- const __m128i ga0 = _mm_unpackhi_epi64(v2l, v2h); // g0...g7 | a0...a7
- const __m128i rb0 = _mm_unpacklo_epi64(v2h, v2l); // r0...r7 | b0...b7
- const __m128i ga1 = _mm_srli_epi16(ga0, 4); // g0-|g1-|...|a6-|a7-
- const __m128i rb1 = _mm_and_si128(rb0, mask_0xf0); // -r0|-r1|...|-b6|-a7
- const __m128i ga2 = _mm_and_si128(ga1, mask_0x0f); // g0-|g1-|...|a6-|a7-
- const __m128i rgba0 = _mm_or_si128(ga2, rb1); // rg0..rg7 | ba0..ba7
- const __m128i rgba1 = _mm_srli_si128(rgba0, 8); // ba0..ba7 | 0
-#if (WEBP_SWAP_16BIT_CSP == 1)
- const __m128i rgba = _mm_unpacklo_epi8(rgba1, rgba0); // barg0...barg7
-#else
- const __m128i rgba = _mm_unpacklo_epi8(rgba0, rgba1); // rgba0...rgba7
-#endif
- _mm_storeu_si128(out++, rgba);
- num_pixels -= 8;
- }
- // left-overs
- if (num_pixels > 0) {
- VP8LConvertBGRAToRGBA4444_C((const uint32_t*)in, num_pixels, (uint8_t*)out);
- }
-}
-
-static void ConvertBGRAToRGB565_SSE2(const uint32_t* src,
- int num_pixels, uint8_t* dst) {
- const __m128i mask_0xe0 = _mm_set1_epi8(0xe0);
- const __m128i mask_0xf8 = _mm_set1_epi8(0xf8);
- const __m128i mask_0x07 = _mm_set1_epi8(0x07);
- const __m128i* in = (const __m128i*)src;
- __m128i* out = (__m128i*)dst;
- while (num_pixels >= 8) {
- const __m128i bgra0 = _mm_loadu_si128(in++); // bgra0|bgra1|bgra2|bgra3
- const __m128i bgra4 = _mm_loadu_si128(in++); // bgra4|bgra5|bgra6|bgra7
- const __m128i v0l = _mm_unpacklo_epi8(bgra0, bgra4); // b0b4g0g4r0r4a0a4...
- const __m128i v0h = _mm_unpackhi_epi8(bgra0, bgra4); // b2b6g2g6r2r6a2a6...
- const __m128i v1l = _mm_unpacklo_epi8(v0l, v0h); // b0b2b4b6g0g2g4g6...
- const __m128i v1h = _mm_unpackhi_epi8(v0l, v0h); // b1b3b5b7g1g3g5g7...
- const __m128i v2l = _mm_unpacklo_epi8(v1l, v1h); // b0...b7 | g0...g7
- const __m128i v2h = _mm_unpackhi_epi8(v1l, v1h); // r0...r7 | a0...a7
- const __m128i ga0 = _mm_unpackhi_epi64(v2l, v2h); // g0...g7 | a0...a7
- const __m128i rb0 = _mm_unpacklo_epi64(v2h, v2l); // r0...r7 | b0...b7
- const __m128i rb1 = _mm_and_si128(rb0, mask_0xf8); // -r0..-r7|-b0..-b7
- const __m128i g_lo1 = _mm_srli_epi16(ga0, 5);
- const __m128i g_lo2 = _mm_and_si128(g_lo1, mask_0x07); // g0-...g7-|xx (3b)
- const __m128i g_hi1 = _mm_slli_epi16(ga0, 3);
- const __m128i g_hi2 = _mm_and_si128(g_hi1, mask_0xe0); // -g0...-g7|xx (3b)
- const __m128i b0 = _mm_srli_si128(rb1, 8); // -b0...-b7|0
- const __m128i rg1 = _mm_or_si128(rb1, g_lo2); // gr0...gr7|xx
- const __m128i b1 = _mm_srli_epi16(b0, 3);
- const __m128i gb1 = _mm_or_si128(b1, g_hi2); // bg0...bg7|xx
-#if (WEBP_SWAP_16BIT_CSP == 1)
- const __m128i rgba = _mm_unpacklo_epi8(gb1, rg1); // rggb0...rggb7
-#else
- const __m128i rgba = _mm_unpacklo_epi8(rg1, gb1); // bgrb0...bgrb7
-#endif
- _mm_storeu_si128(out++, rgba);
- num_pixels -= 8;
- }
- // left-overs
- if (num_pixels > 0) {
- VP8LConvertBGRAToRGB565_C((const uint32_t*)in, num_pixels, (uint8_t*)out);
- }
-}
-
-static void ConvertBGRAToBGR_SSE2(const uint32_t* src,
- int num_pixels, uint8_t* dst) {
- const __m128i mask_l = _mm_set_epi32(0, 0x00ffffff, 0, 0x00ffffff);
- const __m128i mask_h = _mm_set_epi32(0x00ffffff, 0, 0x00ffffff, 0);
- const __m128i* in = (const __m128i*)src;
- const uint8_t* const end = dst + num_pixels * 3;
- // the last storel_epi64 below writes 8 bytes starting at offset 18
- while (dst + 26 <= end) {
- const __m128i bgra0 = _mm_loadu_si128(in++); // bgra0|bgra1|bgra2|bgra3
- const __m128i bgra4 = _mm_loadu_si128(in++); // bgra4|bgra5|bgra6|bgra7
- const __m128i a0l = _mm_and_si128(bgra0, mask_l); // bgr0|0|bgr0|0
- const __m128i a4l = _mm_and_si128(bgra4, mask_l); // bgr0|0|bgr0|0
- const __m128i a0h = _mm_and_si128(bgra0, mask_h); // 0|bgr0|0|bgr0
- const __m128i a4h = _mm_and_si128(bgra4, mask_h); // 0|bgr0|0|bgr0
- const __m128i b0h = _mm_srli_epi64(a0h, 8); // 000b|gr00|000b|gr00
- const __m128i b4h = _mm_srli_epi64(a4h, 8); // 000b|gr00|000b|gr00
- const __m128i c0 = _mm_or_si128(a0l, b0h); // rgbrgb00|rgbrgb00
- const __m128i c4 = _mm_or_si128(a4l, b4h); // rgbrgb00|rgbrgb00
- const __m128i c2 = _mm_srli_si128(c0, 8);
- const __m128i c6 = _mm_srli_si128(c4, 8);
- _mm_storel_epi64((__m128i*)(dst + 0), c0);
- _mm_storel_epi64((__m128i*)(dst + 6), c2);
- _mm_storel_epi64((__m128i*)(dst + 12), c4);
- _mm_storel_epi64((__m128i*)(dst + 18), c6);
- dst += 24;
- num_pixels -= 8;
- }
- // left-overs
- if (num_pixels > 0) {
- VP8LConvertBGRAToBGR_C((const uint32_t*)in, num_pixels, dst);
- }
-}
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void VP8LDspInitSSE2(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void VP8LDspInitSSE2(void) {
- VP8LPredictors[5] = Predictor5_SSE2;
- VP8LPredictors[6] = Predictor6_SSE2;
- VP8LPredictors[7] = Predictor7_SSE2;
- VP8LPredictors[8] = Predictor8_SSE2;
- VP8LPredictors[9] = Predictor9_SSE2;
- VP8LPredictors[10] = Predictor10_SSE2;
- VP8LPredictors[11] = Predictor11_SSE2;
- VP8LPredictors[12] = Predictor12_SSE2;
- VP8LPredictors[13] = Predictor13_SSE2;
-
- VP8LPredictorsAdd[0] = PredictorAdd0_SSE2;
- VP8LPredictorsAdd[1] = PredictorAdd1_SSE2;
- VP8LPredictorsAdd[2] = PredictorAdd2_SSE2;
- VP8LPredictorsAdd[3] = PredictorAdd3_SSE2;
- VP8LPredictorsAdd[4] = PredictorAdd4_SSE2;
- VP8LPredictorsAdd[5] = PredictorAdd5_SSE2;
- VP8LPredictorsAdd[6] = PredictorAdd6_SSE2;
- VP8LPredictorsAdd[7] = PredictorAdd7_SSE2;
- VP8LPredictorsAdd[8] = PredictorAdd8_SSE2;
- VP8LPredictorsAdd[9] = PredictorAdd9_SSE2;
- VP8LPredictorsAdd[10] = PredictorAdd10_SSE2;
- VP8LPredictorsAdd[11] = PredictorAdd11_SSE2;
- VP8LPredictorsAdd[12] = PredictorAdd12_SSE2;
- VP8LPredictorsAdd[13] = PredictorAdd13_SSE2;
-
- VP8LAddGreenToBlueAndRed = AddGreenToBlueAndRed_SSE2;
- VP8LTransformColorInverse = TransformColorInverse_SSE2;
-
- VP8LConvertBGRAToRGB = ConvertBGRAToRGB_SSE2;
- VP8LConvertBGRAToRGBA = ConvertBGRAToRGBA_SSE2;
- VP8LConvertBGRAToRGBA4444 = ConvertBGRAToRGBA4444_SSE2;
- VP8LConvertBGRAToRGB565 = ConvertBGRAToRGB565_SSE2;
- VP8LConvertBGRAToBGR = ConvertBGRAToBGR_SSE2;
-}
-
-#else // !WEBP_USE_SSE2
-
-WEBP_DSP_INIT_STUB(VP8LDspInitSSE2)
-
-#endif // WEBP_USE_SSE2
diff --git a/contrib/libs/libwebp/dsp/lossless_sse41.c b/contrib/libs/libwebp/dsp/lossless_sse41.c
deleted file mode 100644
index 08049b7274..0000000000
--- a/contrib/libs/libwebp/dsp/lossless_sse41.c
+++ /dev/null
@@ -1,132 +0,0 @@
-// Copyright 2021 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// SSE41 variant of methods for lossless decoder
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_SSE41)
-
-#include "./common_sse41.h"
-#include "./lossless.h"
-#include "./lossless_common.h"
-
-//------------------------------------------------------------------------------
-// Color-space conversion functions
-
-static void TransformColorInverse_SSE41(const VP8LMultipliers* const m,
- const uint32_t* const src,
- int num_pixels, uint32_t* dst) {
-// sign-extended multiplying constants, pre-shifted by 5.
-#define CST(X) (((int16_t)(m->X << 8)) >> 5) // sign-extend
- const __m128i mults_rb = _mm_set1_epi32((uint32_t)CST(green_to_red_) << 16 |
- (CST(green_to_blue_) & 0xffff));
- const __m128i mults_b2 = _mm_set1_epi32(CST(red_to_blue_));
-#undef CST
- const __m128i mask_ag = _mm_set1_epi32(0xff00ff00);
- const __m128i perm1 = _mm_setr_epi8(-1, 1, -1, 1, -1, 5, -1, 5,
- -1, 9, -1, 9, -1, 13, -1, 13);
- const __m128i perm2 = _mm_setr_epi8(-1, 2, -1, -1, -1, 6, -1, -1,
- -1, 10, -1, -1, -1, 14, -1, -1);
- int i;
- for (i = 0; i + 4 <= num_pixels; i += 4) {
- const __m128i A = _mm_loadu_si128((const __m128i*)(src + i));
- const __m128i B = _mm_shuffle_epi8(A, perm1); // argb -> g0g0
- const __m128i C = _mm_mulhi_epi16(B, mults_rb);
- const __m128i D = _mm_add_epi8(A, C);
- const __m128i E = _mm_shuffle_epi8(D, perm2);
- const __m128i F = _mm_mulhi_epi16(E, mults_b2);
- const __m128i G = _mm_add_epi8(D, F);
- const __m128i out = _mm_blendv_epi8(G, A, mask_ag);
- _mm_storeu_si128((__m128i*)&dst[i], out);
- }
- // Fall-back to C-version for left-overs.
- if (i != num_pixels) {
- VP8LTransformColorInverse_C(m, src + i, num_pixels - i, dst + i);
- }
-}
-
-//------------------------------------------------------------------------------
-
-#define ARGB_TO_RGB_SSE41 do { \
- while (num_pixels >= 16) { \
- const __m128i in0 = _mm_loadu_si128(in + 0); \
- const __m128i in1 = _mm_loadu_si128(in + 1); \
- const __m128i in2 = _mm_loadu_si128(in + 2); \
- const __m128i in3 = _mm_loadu_si128(in + 3); \
- const __m128i a0 = _mm_shuffle_epi8(in0, perm0); \
- const __m128i a1 = _mm_shuffle_epi8(in1, perm1); \
- const __m128i a2 = _mm_shuffle_epi8(in2, perm2); \
- const __m128i a3 = _mm_shuffle_epi8(in3, perm3); \
- const __m128i b0 = _mm_blend_epi16(a0, a1, 0xc0); \
- const __m128i b1 = _mm_blend_epi16(a1, a2, 0xf0); \
- const __m128i b2 = _mm_blend_epi16(a2, a3, 0xfc); \
- _mm_storeu_si128(out + 0, b0); \
- _mm_storeu_si128(out + 1, b1); \
- _mm_storeu_si128(out + 2, b2); \
- in += 4; \
- out += 3; \
- num_pixels -= 16; \
- } \
-} while (0)
-
-static void ConvertBGRAToRGB_SSE41(const uint32_t* src, int num_pixels,
- uint8_t* dst) {
- const __m128i* in = (const __m128i*)src;
- __m128i* out = (__m128i*)dst;
- const __m128i perm0 = _mm_setr_epi8(2, 1, 0, 6, 5, 4, 10, 9,
- 8, 14, 13, 12, -1, -1, -1, -1);
- const __m128i perm1 = _mm_shuffle_epi32(perm0, 0x39);
- const __m128i perm2 = _mm_shuffle_epi32(perm0, 0x4e);
- const __m128i perm3 = _mm_shuffle_epi32(perm0, 0x93);
-
- ARGB_TO_RGB_SSE41;
-
- // left-overs
- if (num_pixels > 0) {
- VP8LConvertBGRAToRGB_C((const uint32_t*)in, num_pixels, (uint8_t*)out);
- }
-}
-
-static void ConvertBGRAToBGR_SSE41(const uint32_t* src,
- int num_pixels, uint8_t* dst) {
- const __m128i* in = (const __m128i*)src;
- __m128i* out = (__m128i*)dst;
- const __m128i perm0 = _mm_setr_epi8(0, 1, 2, 4, 5, 6, 8, 9, 10,
- 12, 13, 14, -1, -1, -1, -1);
- const __m128i perm1 = _mm_shuffle_epi32(perm0, 0x39);
- const __m128i perm2 = _mm_shuffle_epi32(perm0, 0x4e);
- const __m128i perm3 = _mm_shuffle_epi32(perm0, 0x93);
-
- ARGB_TO_RGB_SSE41;
-
- // left-overs
- if (num_pixels > 0) {
- VP8LConvertBGRAToBGR_C((const uint32_t*)in, num_pixels, (uint8_t*)out);
- }
-}
-
-#undef ARGB_TO_RGB_SSE41
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void VP8LDspInitSSE41(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void VP8LDspInitSSE41(void) {
- VP8LTransformColorInverse = TransformColorInverse_SSE41;
- VP8LConvertBGRAToRGB = ConvertBGRAToRGB_SSE41;
- VP8LConvertBGRAToBGR = ConvertBGRAToBGR_SSE41;
-}
-
-#else // !WEBP_USE_SSE41
-
-WEBP_DSP_INIT_STUB(VP8LDspInitSSE41)
-
-#endif // WEBP_USE_SSE41
diff --git a/contrib/libs/libwebp/dsp/mips_macro.h b/contrib/libs/libwebp/dsp/mips_macro.h
deleted file mode 100644
index 44aba9b71d..0000000000
--- a/contrib/libs/libwebp/dsp/mips_macro.h
+++ /dev/null
@@ -1,200 +0,0 @@
-// Copyright 2014 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// MIPS common macros
-
-#ifndef WEBP_DSP_MIPS_MACRO_H_
-#define WEBP_DSP_MIPS_MACRO_H_
-
-#if defined(__GNUC__) && defined(__ANDROID__) && LOCAL_GCC_VERSION == 0x409
-#define WORK_AROUND_GCC
-#endif
-
-#define STR(s) #s
-#define XSTR(s) STR(s)
-
-// O0[31..16 | 15..0] = I0[31..16 | 15..0] + I1[31..16 | 15..0]
-// O1[31..16 | 15..0] = I0[31..16 | 15..0] - I1[31..16 | 15..0]
-// O - output
-// I - input (macro doesn't change it)
-#define ADD_SUB_HALVES(O0, O1, \
- I0, I1) \
- "addq.ph %[" #O0 "], %[" #I0 "], %[" #I1 "] \n\t" \
- "subq.ph %[" #O1 "], %[" #I0 "], %[" #I1 "] \n\t"
-
-// O - output
-// I - input (macro doesn't change it)
-// I[0/1] - offset in bytes
-#define LOAD_IN_X2(O0, O1, \
- I0, I1) \
- "lh %[" #O0 "], " #I0 "(%[in]) \n\t" \
- "lh %[" #O1 "], " #I1 "(%[in]) \n\t"
-
-// I0 - location
-// I1..I9 - offsets in bytes
-#define LOAD_WITH_OFFSET_X4(O0, O1, O2, O3, \
- I0, I1, I2, I3, I4, I5, I6, I7, I8, I9) \
- "ulw %[" #O0 "], " #I1 "+" XSTR(I9) "*" #I5 "(%[" #I0 "]) \n\t" \
- "ulw %[" #O1 "], " #I2 "+" XSTR(I9) "*" #I6 "(%[" #I0 "]) \n\t" \
- "ulw %[" #O2 "], " #I3 "+" XSTR(I9) "*" #I7 "(%[" #I0 "]) \n\t" \
- "ulw %[" #O3 "], " #I4 "+" XSTR(I9) "*" #I8 "(%[" #I0 "]) \n\t"
-
-// O - output
-// IO - input/output
-// I - input (macro doesn't change it)
-#define MUL_SHIFT_SUM(O0, O1, O2, O3, O4, O5, O6, O7, \
- IO0, IO1, IO2, IO3, \
- I0, I1, I2, I3, I4, I5, I6, I7) \
- "mul %[" #O0 "], %[" #I0 "], %[kC2] \n\t" \
- "mul %[" #O1 "], %[" #I0 "], %[kC1] \n\t" \
- "mul %[" #O2 "], %[" #I1 "], %[kC2] \n\t" \
- "mul %[" #O3 "], %[" #I1 "], %[kC1] \n\t" \
- "mul %[" #O4 "], %[" #I2 "], %[kC2] \n\t" \
- "mul %[" #O5 "], %[" #I2 "], %[kC1] \n\t" \
- "mul %[" #O6 "], %[" #I3 "], %[kC2] \n\t" \
- "mul %[" #O7 "], %[" #I3 "], %[kC1] \n\t" \
- "sra %[" #O0 "], %[" #O0 "], 16 \n\t" \
- "sra %[" #O1 "], %[" #O1 "], 16 \n\t" \
- "sra %[" #O2 "], %[" #O2 "], 16 \n\t" \
- "sra %[" #O3 "], %[" #O3 "], 16 \n\t" \
- "sra %[" #O4 "], %[" #O4 "], 16 \n\t" \
- "sra %[" #O5 "], %[" #O5 "], 16 \n\t" \
- "sra %[" #O6 "], %[" #O6 "], 16 \n\t" \
- "sra %[" #O7 "], %[" #O7 "], 16 \n\t" \
- "addu %[" #IO0 "], %[" #IO0 "], %[" #I4 "] \n\t" \
- "addu %[" #IO1 "], %[" #IO1 "], %[" #I5 "] \n\t" \
- "subu %[" #IO2 "], %[" #IO2 "], %[" #I6 "] \n\t" \
- "subu %[" #IO3 "], %[" #IO3 "], %[" #I7 "] \n\t"
-
-// O - output
-// I - input (macro doesn't change it)
-#define INSERT_HALF_X2(O0, O1, \
- I0, I1) \
- "ins %[" #O0 "], %[" #I0 "], 16, 16 \n\t" \
- "ins %[" #O1 "], %[" #I1 "], 16, 16 \n\t"
-
-// O - output
-// I - input (macro doesn't change it)
-#define SRA_16(O0, O1, O2, O3, \
- I0, I1, I2, I3) \
- "sra %[" #O0 "], %[" #I0 "], 16 \n\t" \
- "sra %[" #O1 "], %[" #I1 "], 16 \n\t" \
- "sra %[" #O2 "], %[" #I2 "], 16 \n\t" \
- "sra %[" #O3 "], %[" #I3 "], 16 \n\t"
-
-// temp0[31..16 | 15..0] = temp8[31..16 | 15..0] + temp12[31..16 | 15..0]
-// temp1[31..16 | 15..0] = temp8[31..16 | 15..0] - temp12[31..16 | 15..0]
-// temp0[31..16 | 15..0] = temp0[31..16 >> 3 | 15..0 >> 3]
-// temp1[31..16 | 15..0] = temp1[31..16 >> 3 | 15..0 >> 3]
-// O - output
-// I - input (macro doesn't change it)
-#define SHIFT_R_SUM_X2(O0, O1, O2, O3, O4, O5, O6, O7, \
- I0, I1, I2, I3, I4, I5, I6, I7) \
- "addq.ph %[" #O0 "], %[" #I0 "], %[" #I4 "] \n\t" \
- "subq.ph %[" #O1 "], %[" #I0 "], %[" #I4 "] \n\t" \
- "addq.ph %[" #O2 "], %[" #I1 "], %[" #I5 "] \n\t" \
- "subq.ph %[" #O3 "], %[" #I1 "], %[" #I5 "] \n\t" \
- "addq.ph %[" #O4 "], %[" #I2 "], %[" #I6 "] \n\t" \
- "subq.ph %[" #O5 "], %[" #I2 "], %[" #I6 "] \n\t" \
- "addq.ph %[" #O6 "], %[" #I3 "], %[" #I7 "] \n\t" \
- "subq.ph %[" #O7 "], %[" #I3 "], %[" #I7 "] \n\t" \
- "shra.ph %[" #O0 "], %[" #O0 "], 3 \n\t" \
- "shra.ph %[" #O1 "], %[" #O1 "], 3 \n\t" \
- "shra.ph %[" #O2 "], %[" #O2 "], 3 \n\t" \
- "shra.ph %[" #O3 "], %[" #O3 "], 3 \n\t" \
- "shra.ph %[" #O4 "], %[" #O4 "], 3 \n\t" \
- "shra.ph %[" #O5 "], %[" #O5 "], 3 \n\t" \
- "shra.ph %[" #O6 "], %[" #O6 "], 3 \n\t" \
- "shra.ph %[" #O7 "], %[" #O7 "], 3 \n\t"
-
-// precrq.ph.w temp0, temp8, temp2
-// temp0 = temp8[31..16] | temp2[31..16]
-// ins temp2, temp8, 16, 16
-// temp2 = temp8[31..16] | temp2[15..0]
-// O - output
-// IO - input/output
-// I - input (macro doesn't change it)
-#define PACK_2_HALVES_TO_WORD(O0, O1, O2, O3, \
- IO0, IO1, IO2, IO3, \
- I0, I1, I2, I3) \
- "precrq.ph.w %[" #O0 "], %[" #I0 "], %[" #IO0 "] \n\t" \
- "precrq.ph.w %[" #O1 "], %[" #I1 "], %[" #IO1 "] \n\t" \
- "ins %[" #IO0 "], %[" #I0 "], 16, 16 \n\t" \
- "ins %[" #IO1 "], %[" #I1 "], 16, 16 \n\t" \
- "precrq.ph.w %[" #O2 "], %[" #I2 "], %[" #IO2 "] \n\t" \
- "precrq.ph.w %[" #O3 "], %[" #I3 "], %[" #IO3 "] \n\t" \
- "ins %[" #IO2 "], %[" #I2 "], 16, 16 \n\t" \
- "ins %[" #IO3 "], %[" #I3 "], 16, 16 \n\t"
-
-// preceu.ph.qbr temp0, temp8
-// temp0 = 0 | 0 | temp8[23..16] | temp8[7..0]
-// preceu.ph.qbl temp1, temp8
-// temp1 = temp8[23..16] | temp8[7..0] | 0 | 0
-// O - output
-// I - input (macro doesn't change it)
-#define CONVERT_2_BYTES_TO_HALF(O0, O1, O2, O3, O4, O5, O6, O7, \
- I0, I1, I2, I3) \
- "preceu.ph.qbr %[" #O0 "], %[" #I0 "] \n\t" \
- "preceu.ph.qbl %[" #O1 "], %[" #I0 "] \n\t" \
- "preceu.ph.qbr %[" #O2 "], %[" #I1 "] \n\t" \
- "preceu.ph.qbl %[" #O3 "], %[" #I1 "] \n\t" \
- "preceu.ph.qbr %[" #O4 "], %[" #I2 "] \n\t" \
- "preceu.ph.qbl %[" #O5 "], %[" #I2 "] \n\t" \
- "preceu.ph.qbr %[" #O6 "], %[" #I3 "] \n\t" \
- "preceu.ph.qbl %[" #O7 "], %[" #I3 "] \n\t"
-
-// temp0[31..16 | 15..0] = temp0[31..16 | 15..0] + temp8[31..16 | 15..0]
-// temp0[31..16 | 15..0] = temp0[31..16 <<(s) 7 | 15..0 <<(s) 7]
-// temp1..temp7 same as temp0
-// precrqu_s.qb.ph temp0, temp1, temp0:
-// temp0 = temp1[31..24] | temp1[15..8] | temp0[31..24] | temp0[15..8]
-// store temp0 to dst
-// IO - input/output
-// I - input (macro doesn't change it)
-#define STORE_SAT_SUM_X2(IO0, IO1, IO2, IO3, IO4, IO5, IO6, IO7, \
- I0, I1, I2, I3, I4, I5, I6, I7, \
- I8, I9, I10, I11, I12, I13) \
- "addq.ph %[" #IO0 "], %[" #IO0 "], %[" #I0 "] \n\t" \
- "addq.ph %[" #IO1 "], %[" #IO1 "], %[" #I1 "] \n\t" \
- "addq.ph %[" #IO2 "], %[" #IO2 "], %[" #I2 "] \n\t" \
- "addq.ph %[" #IO3 "], %[" #IO3 "], %[" #I3 "] \n\t" \
- "addq.ph %[" #IO4 "], %[" #IO4 "], %[" #I4 "] \n\t" \
- "addq.ph %[" #IO5 "], %[" #IO5 "], %[" #I5 "] \n\t" \
- "addq.ph %[" #IO6 "], %[" #IO6 "], %[" #I6 "] \n\t" \
- "addq.ph %[" #IO7 "], %[" #IO7 "], %[" #I7 "] \n\t" \
- "shll_s.ph %[" #IO0 "], %[" #IO0 "], 7 \n\t" \
- "shll_s.ph %[" #IO1 "], %[" #IO1 "], 7 \n\t" \
- "shll_s.ph %[" #IO2 "], %[" #IO2 "], 7 \n\t" \
- "shll_s.ph %[" #IO3 "], %[" #IO3 "], 7 \n\t" \
- "shll_s.ph %[" #IO4 "], %[" #IO4 "], 7 \n\t" \
- "shll_s.ph %[" #IO5 "], %[" #IO5 "], 7 \n\t" \
- "shll_s.ph %[" #IO6 "], %[" #IO6 "], 7 \n\t" \
- "shll_s.ph %[" #IO7 "], %[" #IO7 "], 7 \n\t" \
- "precrqu_s.qb.ph %[" #IO0 "], %[" #IO1 "], %[" #IO0 "] \n\t" \
- "precrqu_s.qb.ph %[" #IO2 "], %[" #IO3 "], %[" #IO2 "] \n\t" \
- "precrqu_s.qb.ph %[" #IO4 "], %[" #IO5 "], %[" #IO4 "] \n\t" \
- "precrqu_s.qb.ph %[" #IO6 "], %[" #IO7 "], %[" #IO6 "] \n\t" \
- "usw %[" #IO0 "], " XSTR(I13) "*" #I9 "(%[" #I8 "]) \n\t" \
- "usw %[" #IO2 "], " XSTR(I13) "*" #I10 "(%[" #I8 "]) \n\t" \
- "usw %[" #IO4 "], " XSTR(I13) "*" #I11 "(%[" #I8 "]) \n\t" \
- "usw %[" #IO6 "], " XSTR(I13) "*" #I12 "(%[" #I8 "]) \n\t"
-
-#define OUTPUT_EARLY_CLOBBER_REGS_10() \
- : [temp1]"=&r"(temp1), [temp2]"=&r"(temp2), [temp3]"=&r"(temp3), \
- [temp4]"=&r"(temp4), [temp5]"=&r"(temp5), [temp6]"=&r"(temp6), \
- [temp7]"=&r"(temp7), [temp8]"=&r"(temp8), [temp9]"=&r"(temp9), \
- [temp10]"=&r"(temp10)
-
-#define OUTPUT_EARLY_CLOBBER_REGS_18() \
- OUTPUT_EARLY_CLOBBER_REGS_10(), \
- [temp11]"=&r"(temp11), [temp12]"=&r"(temp12), [temp13]"=&r"(temp13), \
- [temp14]"=&r"(temp14), [temp15]"=&r"(temp15), [temp16]"=&r"(temp16), \
- [temp17]"=&r"(temp17), [temp18]"=&r"(temp18)
-
-#endif // WEBP_DSP_MIPS_MACRO_H_
diff --git a/contrib/libs/libwebp/dsp/msa_macro.h b/contrib/libs/libwebp/dsp/msa_macro.h
deleted file mode 100644
index 004dc3cbc6..0000000000
--- a/contrib/libs/libwebp/dsp/msa_macro.h
+++ /dev/null
@@ -1,1397 +0,0 @@
-// Copyright 2016 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// MSA common macros
-//
-// Author(s): Prashant Patil (prashant.patil@imgtec.com)
-
-#ifndef WEBP_DSP_MSA_MACRO_H_
-#define WEBP_DSP_MSA_MACRO_H_
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_MSA)
-
-#include <stdint.h>
-#include <msa.h>
-
-#if defined(__clang__)
- #define CLANG_BUILD
-#endif
-
-#ifdef CLANG_BUILD
- #define ALPHAVAL (-1)
- #define ADDVI_H(a, b) __msa_addvi_h((v8i16)a, b)
- #define ADDVI_W(a, b) __msa_addvi_w((v4i32)a, b)
- #define SRAI_B(a, b) __msa_srai_b((v16i8)a, b)
- #define SRAI_H(a, b) __msa_srai_h((v8i16)a, b)
- #define SRAI_W(a, b) __msa_srai_w((v4i32)a, b)
- #define SRLI_H(a, b) __msa_srli_h((v8i16)a, b)
- #define SLLI_B(a, b) __msa_slli_b((v4i32)a, b)
- #define ANDI_B(a, b) __msa_andi_b((v16u8)a, b)
- #define ORI_B(a, b) __msa_ori_b((v16u8)a, b)
-#else
- #define ALPHAVAL (0xff)
- #define ADDVI_H(a, b) (a + b)
- #define ADDVI_W(a, b) (a + b)
- #define SRAI_B(a, b) (a >> b)
- #define SRAI_H(a, b) (a >> b)
- #define SRAI_W(a, b) (a >> b)
- #define SRLI_H(a, b) (a << b)
- #define SLLI_B(a, b) (a << b)
- #define ANDI_B(a, b) (a & b)
- #define ORI_B(a, b) (a | b)
-#endif
-
-#define LD_B(RTYPE, psrc) *((RTYPE*)(psrc))
-#define LD_UB(...) LD_B(v16u8, __VA_ARGS__)
-#define LD_SB(...) LD_B(v16i8, __VA_ARGS__)
-
-#define LD_H(RTYPE, psrc) *((RTYPE*)(psrc))
-#define LD_UH(...) LD_H(v8u16, __VA_ARGS__)
-#define LD_SH(...) LD_H(v8i16, __VA_ARGS__)
-
-#define LD_W(RTYPE, psrc) *((RTYPE*)(psrc))
-#define LD_UW(...) LD_W(v4u32, __VA_ARGS__)
-#define LD_SW(...) LD_W(v4i32, __VA_ARGS__)
-
-#define ST_B(RTYPE, in, pdst) *((RTYPE*)(pdst)) = in
-#define ST_UB(...) ST_B(v16u8, __VA_ARGS__)
-#define ST_SB(...) ST_B(v16i8, __VA_ARGS__)
-
-#define ST_H(RTYPE, in, pdst) *((RTYPE*)(pdst)) = in
-#define ST_UH(...) ST_H(v8u16, __VA_ARGS__)
-#define ST_SH(...) ST_H(v8i16, __VA_ARGS__)
-
-#define ST_W(RTYPE, in, pdst) *((RTYPE*)(pdst)) = in
-#define ST_UW(...) ST_W(v4u32, __VA_ARGS__)
-#define ST_SW(...) ST_W(v4i32, __VA_ARGS__)
-
-#define MSA_LOAD_FUNC(TYPE, INSTR, FUNC_NAME) \
- static inline TYPE FUNC_NAME(const void* const psrc) { \
- const uint8_t* const psrc_m = (const uint8_t*)psrc; \
- TYPE val_m; \
- asm volatile ( \
- "" #INSTR " %[val_m], %[psrc_m] \n\t" \
- : [val_m] "=r" (val_m) \
- : [psrc_m] "m" (*psrc_m)); \
- return val_m; \
- }
-
-#define MSA_LOAD(psrc, FUNC_NAME) FUNC_NAME(psrc)
-
-#define MSA_STORE_FUNC(TYPE, INSTR, FUNC_NAME) \
- static inline void FUNC_NAME(TYPE val, void* const pdst) { \
- uint8_t* const pdst_m = (uint8_t*)pdst; \
- TYPE val_m = val; \
- asm volatile ( \
- " " #INSTR " %[val_m], %[pdst_m] \n\t" \
- : [pdst_m] "=m" (*pdst_m) \
- : [val_m] "r" (val_m)); \
- }
-
-#define MSA_STORE(val, pdst, FUNC_NAME) FUNC_NAME(val, pdst)
-
-#if (__mips_isa_rev >= 6)
- MSA_LOAD_FUNC(uint16_t, lh, msa_lh);
- #define LH(psrc) MSA_LOAD(psrc, msa_lh)
- MSA_LOAD_FUNC(uint32_t, lw, msa_lw);
- #define LW(psrc) MSA_LOAD(psrc, msa_lw)
- #if (__mips == 64)
- MSA_LOAD_FUNC(uint64_t, ld, msa_ld);
- #define LD(psrc) MSA_LOAD(psrc, msa_ld)
- #else // !(__mips == 64)
- #define LD(psrc) ((((uint64_t)MSA_LOAD(psrc + 4, msa_lw)) << 32) | \
- MSA_LOAD(psrc, msa_lw))
- #endif // (__mips == 64)
-
- MSA_STORE_FUNC(uint16_t, sh, msa_sh);
- #define SH(val, pdst) MSA_STORE(val, pdst, msa_sh)
- MSA_STORE_FUNC(uint32_t, sw, msa_sw);
- #define SW(val, pdst) MSA_STORE(val, pdst, msa_sw)
- MSA_STORE_FUNC(uint64_t, sd, msa_sd);
- #define SD(val, pdst) MSA_STORE(val, pdst, msa_sd)
-#else // !(__mips_isa_rev >= 6)
- MSA_LOAD_FUNC(uint16_t, ulh, msa_ulh);
- #define LH(psrc) MSA_LOAD(psrc, msa_ulh)
- MSA_LOAD_FUNC(uint32_t, ulw, msa_ulw);
- #define LW(psrc) MSA_LOAD(psrc, msa_ulw)
- #if (__mips == 64)
- MSA_LOAD_FUNC(uint64_t, uld, msa_uld);
- #define LD(psrc) MSA_LOAD(psrc, msa_uld)
- #else // !(__mips == 64)
- #define LD(psrc) ((((uint64_t)MSA_LOAD(psrc + 4, msa_ulw)) << 32) | \
- MSA_LOAD(psrc, msa_ulw))
- #endif // (__mips == 64)
-
- MSA_STORE_FUNC(uint16_t, ush, msa_ush);
- #define SH(val, pdst) MSA_STORE(val, pdst, msa_ush)
- MSA_STORE_FUNC(uint32_t, usw, msa_usw);
- #define SW(val, pdst) MSA_STORE(val, pdst, msa_usw)
- #define SD(val, pdst) do { \
- uint8_t* const pdst_sd_m = (uint8_t*)(pdst); \
- const uint32_t val0_m = (uint32_t)(val & 0x00000000FFFFFFFF); \
- const uint32_t val1_m = (uint32_t)((val >> 32) & 0x00000000FFFFFFFF); \
- SW(val0_m, pdst_sd_m); \
- SW(val1_m, pdst_sd_m + 4); \
- } while (0)
-#endif // (__mips_isa_rev >= 6)
-
-/* Description : Load 4 words with stride
- * Arguments : Inputs - psrc, stride
- * Outputs - out0, out1, out2, out3
- * Details : Load word in 'out0' from (psrc)
- * Load word in 'out1' from (psrc + stride)
- * Load word in 'out2' from (psrc + 2 * stride)
- * Load word in 'out3' from (psrc + 3 * stride)
- */
-#define LW4(psrc, stride, out0, out1, out2, out3) do { \
- const uint8_t* ptmp = (const uint8_t*)psrc; \
- out0 = LW(ptmp); \
- ptmp += stride; \
- out1 = LW(ptmp); \
- ptmp += stride; \
- out2 = LW(ptmp); \
- ptmp += stride; \
- out3 = LW(ptmp); \
-} while (0)
-
-/* Description : Store words with stride
- * Arguments : Inputs - in0, in1, in2, in3, pdst, stride
- * Details : Store word from 'in0' to (pdst)
- * Store word from 'in1' to (pdst + stride)
- * Store word from 'in2' to (pdst + 2 * stride)
- * Store word from 'in3' to (pdst + 3 * stride)
- */
-#define SW4(in0, in1, in2, in3, pdst, stride) do { \
- uint8_t* ptmp = (uint8_t*)pdst; \
- SW(in0, ptmp); \
- ptmp += stride; \
- SW(in1, ptmp); \
- ptmp += stride; \
- SW(in2, ptmp); \
- ptmp += stride; \
- SW(in3, ptmp); \
-} while (0)
-
-#define SW3(in0, in1, in2, pdst, stride) do { \
- uint8_t* ptmp = (uint8_t*)pdst; \
- SW(in0, ptmp); \
- ptmp += stride; \
- SW(in1, ptmp); \
- ptmp += stride; \
- SW(in2, ptmp); \
-} while (0)
-
-#define SW2(in0, in1, pdst, stride) do { \
- uint8_t* ptmp = (uint8_t*)pdst; \
- SW(in0, ptmp); \
- ptmp += stride; \
- SW(in1, ptmp); \
-} while (0)
-
-/* Description : Store 4 double words with stride
- * Arguments : Inputs - in0, in1, in2, in3, pdst, stride
- * Details : Store double word from 'in0' to (pdst)
- * Store double word from 'in1' to (pdst + stride)
- * Store double word from 'in2' to (pdst + 2 * stride)
- * Store double word from 'in3' to (pdst + 3 * stride)
- */
-#define SD4(in0, in1, in2, in3, pdst, stride) do { \
- uint8_t* ptmp = (uint8_t*)pdst; \
- SD(in0, ptmp); \
- ptmp += stride; \
- SD(in1, ptmp); \
- ptmp += stride; \
- SD(in2, ptmp); \
- ptmp += stride; \
- SD(in3, ptmp); \
-} while (0)
-
-/* Description : Load vectors with 16 byte elements with stride
- * Arguments : Inputs - psrc, stride
- * Outputs - out0, out1
- * Return Type - as per RTYPE
- * Details : Load 16 byte elements in 'out0' from (psrc)
- * Load 16 byte elements in 'out1' from (psrc + stride)
- */
-#define LD_B2(RTYPE, psrc, stride, out0, out1) do { \
- out0 = LD_B(RTYPE, psrc); \
- out1 = LD_B(RTYPE, psrc + stride); \
-} while (0)
-#define LD_UB2(...) LD_B2(v16u8, __VA_ARGS__)
-#define LD_SB2(...) LD_B2(v16i8, __VA_ARGS__)
-
-#define LD_B3(RTYPE, psrc, stride, out0, out1, out2) do { \
- LD_B2(RTYPE, psrc, stride, out0, out1); \
- out2 = LD_B(RTYPE, psrc + 2 * stride); \
-} while (0)
-#define LD_UB3(...) LD_B3(v16u8, __VA_ARGS__)
-#define LD_SB3(...) LD_B3(v16i8, __VA_ARGS__)
-
-#define LD_B4(RTYPE, psrc, stride, out0, out1, out2, out3) do { \
- LD_B2(RTYPE, psrc, stride, out0, out1); \
- LD_B2(RTYPE, psrc + 2 * stride , stride, out2, out3); \
-} while (0)
-#define LD_UB4(...) LD_B4(v16u8, __VA_ARGS__)
-#define LD_SB4(...) LD_B4(v16i8, __VA_ARGS__)
-
-#define LD_B8(RTYPE, psrc, stride, \
- out0, out1, out2, out3, out4, out5, out6, out7) do { \
- LD_B4(RTYPE, psrc, stride, out0, out1, out2, out3); \
- LD_B4(RTYPE, psrc + 4 * stride, stride, out4, out5, out6, out7); \
-} while (0)
-#define LD_UB8(...) LD_B8(v16u8, __VA_ARGS__)
-#define LD_SB8(...) LD_B8(v16i8, __VA_ARGS__)
-
-/* Description : Load vectors with 8 halfword elements with stride
- * Arguments : Inputs - psrc, stride
- * Outputs - out0, out1
- * Details : Load 8 halfword elements in 'out0' from (psrc)
- * Load 8 halfword elements in 'out1' from (psrc + stride)
- */
-#define LD_H2(RTYPE, psrc, stride, out0, out1) do { \
- out0 = LD_H(RTYPE, psrc); \
- out1 = LD_H(RTYPE, psrc + stride); \
-} while (0)
-#define LD_UH2(...) LD_H2(v8u16, __VA_ARGS__)
-#define LD_SH2(...) LD_H2(v8i16, __VA_ARGS__)
-
-/* Description : Load vectors with 4 word elements with stride
- * Arguments : Inputs - psrc, stride
- * Outputs - out0, out1, out2, out3
- * Details : Load 4 word elements in 'out0' from (psrc + 0 * stride)
- * Load 4 word elements in 'out1' from (psrc + 1 * stride)
- * Load 4 word elements in 'out2' from (psrc + 2 * stride)
- * Load 4 word elements in 'out3' from (psrc + 3 * stride)
- */
-#define LD_W2(RTYPE, psrc, stride, out0, out1) do { \
- out0 = LD_W(RTYPE, psrc); \
- out1 = LD_W(RTYPE, psrc + stride); \
-} while (0)
-#define LD_UW2(...) LD_W2(v4u32, __VA_ARGS__)
-#define LD_SW2(...) LD_W2(v4i32, __VA_ARGS__)
-
-#define LD_W3(RTYPE, psrc, stride, out0, out1, out2) do { \
- LD_W2(RTYPE, psrc, stride, out0, out1); \
- out2 = LD_W(RTYPE, psrc + 2 * stride); \
-} while (0)
-#define LD_UW3(...) LD_W3(v4u32, __VA_ARGS__)
-#define LD_SW3(...) LD_W3(v4i32, __VA_ARGS__)
-
-#define LD_W4(RTYPE, psrc, stride, out0, out1, out2, out3) do { \
- LD_W2(RTYPE, psrc, stride, out0, out1); \
- LD_W2(RTYPE, psrc + 2 * stride, stride, out2, out3); \
-} while (0)
-#define LD_UW4(...) LD_W4(v4u32, __VA_ARGS__)
-#define LD_SW4(...) LD_W4(v4i32, __VA_ARGS__)
-
-/* Description : Store vectors of 16 byte elements with stride
- * Arguments : Inputs - in0, in1, pdst, stride
- * Details : Store 16 byte elements from 'in0' to (pdst)
- * Store 16 byte elements from 'in1' to (pdst + stride)
- */
-#define ST_B2(RTYPE, in0, in1, pdst, stride) do { \
- ST_B(RTYPE, in0, pdst); \
- ST_B(RTYPE, in1, pdst + stride); \
-} while (0)
-#define ST_UB2(...) ST_B2(v16u8, __VA_ARGS__)
-#define ST_SB2(...) ST_B2(v16i8, __VA_ARGS__)
-
-#define ST_B4(RTYPE, in0, in1, in2, in3, pdst, stride) do { \
- ST_B2(RTYPE, in0, in1, pdst, stride); \
- ST_B2(RTYPE, in2, in3, pdst + 2 * stride, stride); \
-} while (0)
-#define ST_UB4(...) ST_B4(v16u8, __VA_ARGS__)
-#define ST_SB4(...) ST_B4(v16i8, __VA_ARGS__)
-
-#define ST_B8(RTYPE, in0, in1, in2, in3, in4, in5, in6, in7, \
- pdst, stride) do { \
- ST_B4(RTYPE, in0, in1, in2, in3, pdst, stride); \
- ST_B4(RTYPE, in4, in5, in6, in7, pdst + 4 * stride, stride); \
-} while (0)
-#define ST_UB8(...) ST_B8(v16u8, __VA_ARGS__)
-
-/* Description : Store vectors of 4 word elements with stride
- * Arguments : Inputs - in0, in1, in2, in3, pdst, stride
- * Details : Store 4 word elements from 'in0' to (pdst + 0 * stride)
- * Store 4 word elements from 'in1' to (pdst + 1 * stride)
- * Store 4 word elements from 'in2' to (pdst + 2 * stride)
- * Store 4 word elements from 'in3' to (pdst + 3 * stride)
- */
-#define ST_W2(RTYPE, in0, in1, pdst, stride) do { \
- ST_W(RTYPE, in0, pdst); \
- ST_W(RTYPE, in1, pdst + stride); \
-} while (0)
-#define ST_UW2(...) ST_W2(v4u32, __VA_ARGS__)
-#define ST_SW2(...) ST_W2(v4i32, __VA_ARGS__)
-
-#define ST_W3(RTYPE, in0, in1, in2, pdst, stride) do { \
- ST_W2(RTYPE, in0, in1, pdst, stride); \
- ST_W(RTYPE, in2, pdst + 2 * stride); \
-} while (0)
-#define ST_UW3(...) ST_W3(v4u32, __VA_ARGS__)
-#define ST_SW3(...) ST_W3(v4i32, __VA_ARGS__)
-
-#define ST_W4(RTYPE, in0, in1, in2, in3, pdst, stride) do { \
- ST_W2(RTYPE, in0, in1, pdst, stride); \
- ST_W2(RTYPE, in2, in3, pdst + 2 * stride, stride); \
-} while (0)
-#define ST_UW4(...) ST_W4(v4u32, __VA_ARGS__)
-#define ST_SW4(...) ST_W4(v4i32, __VA_ARGS__)
-
-/* Description : Store vectors of 8 halfword elements with stride
- * Arguments : Inputs - in0, in1, pdst, stride
- * Details : Store 8 halfword elements from 'in0' to (pdst)
- * Store 8 halfword elements from 'in1' to (pdst + stride)
- */
-#define ST_H2(RTYPE, in0, in1, pdst, stride) do { \
- ST_H(RTYPE, in0, pdst); \
- ST_H(RTYPE, in1, pdst + stride); \
-} while (0)
-#define ST_UH2(...) ST_H2(v8u16, __VA_ARGS__)
-#define ST_SH2(...) ST_H2(v8i16, __VA_ARGS__)
-
-/* Description : Store 2x4 byte block to destination memory from input vector
- * Arguments : Inputs - in, stidx, pdst, stride
- * Details : Index 'stidx' halfword element from 'in' vector is copied to
- * the GP register and stored to (pdst)
- * Index 'stidx+1' halfword element from 'in' vector is copied to
- * the GP register and stored to (pdst + stride)
- * Index 'stidx+2' halfword element from 'in' vector is copied to
- * the GP register and stored to (pdst + 2 * stride)
- * Index 'stidx+3' halfword element from 'in' vector is copied to
- * the GP register and stored to (pdst + 3 * stride)
- */
-#define ST2x4_UB(in, stidx, pdst, stride) do { \
- uint8_t* pblk_2x4_m = (uint8_t*)pdst; \
- const uint16_t out0_m = __msa_copy_s_h((v8i16)in, stidx); \
- const uint16_t out1_m = __msa_copy_s_h((v8i16)in, stidx + 1); \
- const uint16_t out2_m = __msa_copy_s_h((v8i16)in, stidx + 2); \
- const uint16_t out3_m = __msa_copy_s_h((v8i16)in, stidx + 3); \
- SH(out0_m, pblk_2x4_m); \
- pblk_2x4_m += stride; \
- SH(out1_m, pblk_2x4_m); \
- pblk_2x4_m += stride; \
- SH(out2_m, pblk_2x4_m); \
- pblk_2x4_m += stride; \
- SH(out3_m, pblk_2x4_m); \
-} while (0)
-
-/* Description : Store 4x4 byte block to destination memory from input vector
- * Arguments : Inputs - in0, in1, pdst, stride
- * Details : 'Idx0' word element from input vector 'in0' is copied to the
- * GP register and stored to (pdst)
- * 'Idx1' word element from input vector 'in0' is copied to the
- * GP register and stored to (pdst + stride)
- * 'Idx2' word element from input vector 'in0' is copied to the
- * GP register and stored to (pdst + 2 * stride)
- * 'Idx3' word element from input vector 'in0' is copied to the
- * GP register and stored to (pdst + 3 * stride)
- */
-#define ST4x4_UB(in0, in1, idx0, idx1, idx2, idx3, pdst, stride) do { \
- uint8_t* const pblk_4x4_m = (uint8_t*)pdst; \
- const uint32_t out0_m = __msa_copy_s_w((v4i32)in0, idx0); \
- const uint32_t out1_m = __msa_copy_s_w((v4i32)in0, idx1); \
- const uint32_t out2_m = __msa_copy_s_w((v4i32)in1, idx2); \
- const uint32_t out3_m = __msa_copy_s_w((v4i32)in1, idx3); \
- SW4(out0_m, out1_m, out2_m, out3_m, pblk_4x4_m, stride); \
-} while (0)
-
-#define ST4x8_UB(in0, in1, pdst, stride) do { \
- uint8_t* const pblk_4x8 = (uint8_t*)pdst; \
- ST4x4_UB(in0, in0, 0, 1, 2, 3, pblk_4x8, stride); \
- ST4x4_UB(in1, in1, 0, 1, 2, 3, pblk_4x8 + 4 * stride, stride); \
-} while (0)
-
-/* Description : Immediate number of elements to slide
- * Arguments : Inputs - in0, in1, slide_val
- * Outputs - out
- * Return Type - as per RTYPE
- * Details : Byte elements from 'in1' vector are slid into 'in0' by
- * value specified in the 'slide_val'
- */
-#define SLDI_B(RTYPE, in0, in1, slide_val) \
- (RTYPE)__msa_sldi_b((v16i8)in0, (v16i8)in1, slide_val) \
-
-#define SLDI_UB(...) SLDI_B(v16u8, __VA_ARGS__)
-#define SLDI_SB(...) SLDI_B(v16i8, __VA_ARGS__)
-#define SLDI_SH(...) SLDI_B(v8i16, __VA_ARGS__)
-
-/* Description : Shuffle byte vector elements as per mask vector
- * Arguments : Inputs - in0, in1, in2, in3, mask0, mask1
- * Outputs - out0, out1
- * Return Type - as per RTYPE
- * Details : Byte elements from 'in0' & 'in1' are copied selectively to
- * 'out0' as per control vector 'mask0'
- */
-#define VSHF_B(RTYPE, in0, in1, mask) \
- (RTYPE)__msa_vshf_b((v16i8)mask, (v16i8)in1, (v16i8)in0)
-
-#define VSHF_UB(...) VSHF_B(v16u8, __VA_ARGS__)
-#define VSHF_SB(...) VSHF_B(v16i8, __VA_ARGS__)
-#define VSHF_UH(...) VSHF_B(v8u16, __VA_ARGS__)
-#define VSHF_SH(...) VSHF_B(v8i16, __VA_ARGS__)
-
-#define VSHF_B2(RTYPE, in0, in1, in2, in3, mask0, mask1, out0, out1) do { \
- out0 = VSHF_B(RTYPE, in0, in1, mask0); \
- out1 = VSHF_B(RTYPE, in2, in3, mask1); \
-} while (0)
-#define VSHF_B2_UB(...) VSHF_B2(v16u8, __VA_ARGS__)
-#define VSHF_B2_SB(...) VSHF_B2(v16i8, __VA_ARGS__)
-#define VSHF_B2_UH(...) VSHF_B2(v8u16, __VA_ARGS__)
-#define VSHF_B2_SH(...) VSHF_B2(v8i16, __VA_ARGS__)
-
-/* Description : Shuffle halfword vector elements as per mask vector
- * Arguments : Inputs - in0, in1, in2, in3, mask0, mask1
- * Outputs - out0, out1
- * Return Type - as per RTYPE
- * Details : halfword elements from 'in0' & 'in1' are copied selectively to
- * 'out0' as per control vector 'mask0'
- */
-#define VSHF_H2(RTYPE, in0, in1, in2, in3, mask0, mask1, out0, out1) do { \
- out0 = (RTYPE)__msa_vshf_h((v8i16)mask0, (v8i16)in1, (v8i16)in0); \
- out1 = (RTYPE)__msa_vshf_h((v8i16)mask1, (v8i16)in3, (v8i16)in2); \
-} while (0)
-#define VSHF_H2_UH(...) VSHF_H2(v8u16, __VA_ARGS__)
-#define VSHF_H2_SH(...) VSHF_H2(v8i16, __VA_ARGS__)
-
-/* Description : Dot product of byte vector elements
- * Arguments : Inputs - mult0, mult1, cnst0, cnst1
- * Outputs - out0, out1
- * Return Type - as per RTYPE
- * Details : Signed byte elements from 'mult0' are multiplied with
- * signed byte elements from 'cnst0' producing a result
- * twice the size of input i.e. signed halfword.
- * The multiplication result of adjacent odd-even elements
- * are added together and written to the 'out0' vector
-*/
-#define DOTP_SB2(RTYPE, mult0, mult1, cnst0, cnst1, out0, out1) do { \
- out0 = (RTYPE)__msa_dotp_s_h((v16i8)mult0, (v16i8)cnst0); \
- out1 = (RTYPE)__msa_dotp_s_h((v16i8)mult1, (v16i8)cnst1); \
-} while (0)
-#define DOTP_SB2_SH(...) DOTP_SB2(v8i16, __VA_ARGS__)
-
-/* Description : Dot product of halfword vector elements
- * Arguments : Inputs - mult0, mult1, cnst0, cnst1
- * Outputs - out0, out1
- * Return Type - as per RTYPE
- * Details : Signed halfword elements from 'mult0' are multiplied with
- * signed halfword elements from 'cnst0' producing a result
- * twice the size of input i.e. signed word.
- * The multiplication result of adjacent odd-even elements
- * are added together and written to the 'out0' vector
- */
-#define DOTP_SH2(RTYPE, mult0, mult1, cnst0, cnst1, out0, out1) do { \
- out0 = (RTYPE)__msa_dotp_s_w((v8i16)mult0, (v8i16)cnst0); \
- out1 = (RTYPE)__msa_dotp_s_w((v8i16)mult1, (v8i16)cnst1); \
-} while (0)
-#define DOTP_SH2_SW(...) DOTP_SH2(v4i32, __VA_ARGS__)
-
-/* Description : Dot product of unsigned word vector elements
- * Arguments : Inputs - mult0, mult1, cnst0, cnst1
- * Outputs - out0, out1
- * Return Type - as per RTYPE
- * Details : Unsigned word elements from 'mult0' are multiplied with
- * unsigned word elements from 'cnst0' producing a result
- * twice the size of input i.e. unsigned double word.
- * The multiplication result of adjacent odd-even elements
- * are added together and written to the 'out0' vector
- */
-#define DOTP_UW2(RTYPE, mult0, mult1, cnst0, cnst1, out0, out1) do { \
- out0 = (RTYPE)__msa_dotp_u_d((v4u32)mult0, (v4u32)cnst0); \
- out1 = (RTYPE)__msa_dotp_u_d((v4u32)mult1, (v4u32)cnst1); \
-} while (0)
-#define DOTP_UW2_UD(...) DOTP_UW2(v2u64, __VA_ARGS__)
-
-/* Description : Dot product & addition of halfword vector elements
- * Arguments : Inputs - mult0, mult1, cnst0, cnst1
- * Outputs - out0, out1
- * Return Type - as per RTYPE
- * Details : Signed halfword elements from 'mult0' are multiplied with
- * signed halfword elements from 'cnst0' producing a result
- * twice the size of input i.e. signed word.
- * The multiplication result of adjacent odd-even elements
- * are added to the 'out0' vector
- */
-#define DPADD_SH2(RTYPE, mult0, mult1, cnst0, cnst1, out0, out1) do { \
- out0 = (RTYPE)__msa_dpadd_s_w((v4i32)out0, (v8i16)mult0, (v8i16)cnst0); \
- out1 = (RTYPE)__msa_dpadd_s_w((v4i32)out1, (v8i16)mult1, (v8i16)cnst1); \
-} while (0)
-#define DPADD_SH2_SW(...) DPADD_SH2(v4i32, __VA_ARGS__)
-
-/* Description : Clips all signed halfword elements of input vector
- * between 0 & 255
- * Arguments : Input/output - val
- * Return Type - signed halfword
- */
-#define CLIP_SH_0_255(val) do { \
- const v8i16 max_m = __msa_ldi_h(255); \
- val = __msa_maxi_s_h((v8i16)val, 0); \
- val = __msa_min_s_h(max_m, (v8i16)val); \
-} while (0)
-
-#define CLIP_SH2_0_255(in0, in1) do { \
- CLIP_SH_0_255(in0); \
- CLIP_SH_0_255(in1); \
-} while (0)
-
-#define CLIP_SH4_0_255(in0, in1, in2, in3) do { \
- CLIP_SH2_0_255(in0, in1); \
- CLIP_SH2_0_255(in2, in3); \
-} while (0)
-
-/* Description : Clips all unsigned halfword elements of input vector
- * between 0 & 255
- * Arguments : Input - in
- * Output - out_m
- * Return Type - unsigned halfword
- */
-#define CLIP_UH_0_255(in) do { \
- const v8u16 max_m = (v8u16)__msa_ldi_h(255); \
- in = __msa_maxi_u_h((v8u16) in, 0); \
- in = __msa_min_u_h((v8u16) max_m, (v8u16) in); \
-} while (0)
-
-#define CLIP_UH2_0_255(in0, in1) do { \
- CLIP_UH_0_255(in0); \
- CLIP_UH_0_255(in1); \
-} while (0)
-
-/* Description : Clips all signed word elements of input vector
- * between 0 & 255
- * Arguments : Input/output - val
- * Return Type - signed word
- */
-#define CLIP_SW_0_255(val) do { \
- const v4i32 max_m = __msa_ldi_w(255); \
- val = __msa_maxi_s_w((v4i32)val, 0); \
- val = __msa_min_s_w(max_m, (v4i32)val); \
-} while (0)
-
-#define CLIP_SW4_0_255(in0, in1, in2, in3) do { \
- CLIP_SW_0_255(in0); \
- CLIP_SW_0_255(in1); \
- CLIP_SW_0_255(in2); \
- CLIP_SW_0_255(in3); \
-} while (0)
-
-/* Description : Horizontal addition of 4 signed word elements of input vector
- * Arguments : Input - in (signed word vector)
- * Output - sum_m (i32 sum)
- * Return Type - signed word (GP)
- * Details : 4 signed word elements of 'in' vector are added together and
- * the resulting integer sum is returned
- */
-static WEBP_INLINE int32_t func_hadd_sw_s32(v4i32 in) {
- const v2i64 res0_m = __msa_hadd_s_d((v4i32)in, (v4i32)in);
- const v2i64 res1_m = __msa_splati_d(res0_m, 1);
- const v2i64 out = res0_m + res1_m;
- int32_t sum_m = __msa_copy_s_w((v4i32)out, 0);
- return sum_m;
-}
-#define HADD_SW_S32(in) func_hadd_sw_s32(in)
-
-/* Description : Horizontal addition of 8 signed halfword elements
- * Arguments : Input - in (signed halfword vector)
- * Output - sum_m (s32 sum)
- * Return Type - signed word
- * Details : 8 signed halfword elements of input vector are added
- * together and the resulting integer sum is returned
- */
-static WEBP_INLINE int32_t func_hadd_sh_s32(v8i16 in) {
- const v4i32 res = __msa_hadd_s_w(in, in);
- const v2i64 res0 = __msa_hadd_s_d(res, res);
- const v2i64 res1 = __msa_splati_d(res0, 1);
- const v2i64 res2 = res0 + res1;
- const int32_t sum_m = __msa_copy_s_w((v4i32)res2, 0);
- return sum_m;
-}
-#define HADD_SH_S32(in) func_hadd_sh_s32(in)
-
-/* Description : Horizontal addition of 8 unsigned halfword elements
- * Arguments : Input - in (unsigned halfword vector)
- * Output - sum_m (u32 sum)
- * Return Type - unsigned word
- * Details : 8 unsigned halfword elements of input vector are added
- * together and the resulting integer sum is returned
- */
-static WEBP_INLINE uint32_t func_hadd_uh_u32(v8u16 in) {
- uint32_t sum_m;
- const v4u32 res_m = __msa_hadd_u_w(in, in);
- v2u64 res0_m = __msa_hadd_u_d(res_m, res_m);
- v2u64 res1_m = (v2u64)__msa_splati_d((v2i64)res0_m, 1);
- res0_m = res0_m + res1_m;
- sum_m = __msa_copy_s_w((v4i32)res0_m, 0);
- return sum_m;
-}
-#define HADD_UH_U32(in) func_hadd_uh_u32(in)
-
-/* Description : Horizontal addition of signed half word vector elements
- Arguments : Inputs - in0, in1
- Outputs - out0, out1
- Return Type - as per RTYPE
- Details : Each signed odd half word element from 'in0' is added to
- even signed half word element from 'in0' (pairwise) and the
- halfword result is written in 'out0'
-*/
-#define HADD_SH2(RTYPE, in0, in1, out0, out1) do { \
- out0 = (RTYPE)__msa_hadd_s_w((v8i16)in0, (v8i16)in0); \
- out1 = (RTYPE)__msa_hadd_s_w((v8i16)in1, (v8i16)in1); \
-} while (0)
-#define HADD_SH2_SW(...) HADD_SH2(v4i32, __VA_ARGS__)
-
-#define HADD_SH4(RTYPE, in0, in1, in2, in3, out0, out1, out2, out3) do { \
- HADD_SH2(RTYPE, in0, in1, out0, out1); \
- HADD_SH2(RTYPE, in2, in3, out2, out3); \
-} while (0)
-#define HADD_SH4_SW(...) HADD_SH4(v4i32, __VA_ARGS__)
-
-/* Description : Horizontal subtraction of unsigned byte vector elements
- * Arguments : Inputs - in0, in1
- * Outputs - out0, out1
- * Return Type - as per RTYPE
- * Details : Each unsigned odd byte element from 'in0' is subtracted from
- * even unsigned byte element from 'in0' (pairwise) and the
- * halfword result is written to 'out0'
- */
-#define HSUB_UB2(RTYPE, in0, in1, out0, out1) do { \
- out0 = (RTYPE)__msa_hsub_u_h((v16u8)in0, (v16u8)in0); \
- out1 = (RTYPE)__msa_hsub_u_h((v16u8)in1, (v16u8)in1); \
-} while (0)
-#define HSUB_UB2_UH(...) HSUB_UB2(v8u16, __VA_ARGS__)
-#define HSUB_UB2_SH(...) HSUB_UB2(v8i16, __VA_ARGS__)
-#define HSUB_UB2_SW(...) HSUB_UB2(v4i32, __VA_ARGS__)
-
-/* Description : Set element n input vector to GPR value
- * Arguments : Inputs - in0, in1, in2, in3
- * Output - out
- * Return Type - as per RTYPE
- * Details : Set element 0 in vector 'out' to value specified in 'in0'
- */
-#define INSERT_W2(RTYPE, in0, in1, out) do { \
- out = (RTYPE)__msa_insert_w((v4i32)out, 0, in0); \
- out = (RTYPE)__msa_insert_w((v4i32)out, 1, in1); \
-} while (0)
-#define INSERT_W2_UB(...) INSERT_W2(v16u8, __VA_ARGS__)
-#define INSERT_W2_SB(...) INSERT_W2(v16i8, __VA_ARGS__)
-
-#define INSERT_W4(RTYPE, in0, in1, in2, in3, out) do { \
- out = (RTYPE)__msa_insert_w((v4i32)out, 0, in0); \
- out = (RTYPE)__msa_insert_w((v4i32)out, 1, in1); \
- out = (RTYPE)__msa_insert_w((v4i32)out, 2, in2); \
- out = (RTYPE)__msa_insert_w((v4i32)out, 3, in3); \
-} while (0)
-#define INSERT_W4_UB(...) INSERT_W4(v16u8, __VA_ARGS__)
-#define INSERT_W4_SB(...) INSERT_W4(v16i8, __VA_ARGS__)
-#define INSERT_W4_SW(...) INSERT_W4(v4i32, __VA_ARGS__)
-
-/* Description : Set element n of double word input vector to GPR value
- * Arguments : Inputs - in0, in1
- * Output - out
- * Return Type - as per RTYPE
- * Details : Set element 0 in vector 'out' to GPR value specified in 'in0'
- * Set element 1 in vector 'out' to GPR value specified in 'in1'
- */
-#define INSERT_D2(RTYPE, in0, in1, out) do { \
- out = (RTYPE)__msa_insert_d((v2i64)out, 0, in0); \
- out = (RTYPE)__msa_insert_d((v2i64)out, 1, in1); \
-} while (0)
-#define INSERT_D2_UB(...) INSERT_D2(v16u8, __VA_ARGS__)
-#define INSERT_D2_SB(...) INSERT_D2(v16i8, __VA_ARGS__)
-
-/* Description : Interleave even byte elements from vectors
- * Arguments : Inputs - in0, in1, in2, in3
- * Outputs - out0, out1
- * Return Type - as per RTYPE
- * Details : Even byte elements of 'in0' and 'in1' are interleaved
- * and written to 'out0'
- */
-#define ILVEV_B2(RTYPE, in0, in1, in2, in3, out0, out1) do { \
- out0 = (RTYPE)__msa_ilvev_b((v16i8)in1, (v16i8)in0); \
- out1 = (RTYPE)__msa_ilvev_b((v16i8)in3, (v16i8)in2); \
-} while (0)
-#define ILVEV_B2_UB(...) ILVEV_B2(v16u8, __VA_ARGS__)
-#define ILVEV_B2_SB(...) ILVEV_B2(v16i8, __VA_ARGS__)
-#define ILVEV_B2_UH(...) ILVEV_B2(v8u16, __VA_ARGS__)
-#define ILVEV_B2_SH(...) ILVEV_B2(v8i16, __VA_ARGS__)
-#define ILVEV_B2_SD(...) ILVEV_B2(v2i64, __VA_ARGS__)
-
-/* Description : Interleave odd byte elements from vectors
- * Arguments : Inputs - in0, in1, in2, in3
- * Outputs - out0, out1
- * Return Type - as per RTYPE
- * Details : Odd byte elements of 'in0' and 'in1' are interleaved
- * and written to 'out0'
- */
-#define ILVOD_B2(RTYPE, in0, in1, in2, in3, out0, out1) do { \
- out0 = (RTYPE)__msa_ilvod_b((v16i8)in1, (v16i8)in0); \
- out1 = (RTYPE)__msa_ilvod_b((v16i8)in3, (v16i8)in2); \
-} while (0)
-#define ILVOD_B2_UB(...) ILVOD_B2(v16u8, __VA_ARGS__)
-#define ILVOD_B2_SB(...) ILVOD_B2(v16i8, __VA_ARGS__)
-#define ILVOD_B2_UH(...) ILVOD_B2(v8u16, __VA_ARGS__)
-#define ILVOD_B2_SH(...) ILVOD_B2(v8i16, __VA_ARGS__)
-#define ILVOD_B2_SD(...) ILVOD_B2(v2i64, __VA_ARGS__)
-
-/* Description : Interleave even halfword elements from vectors
- * Arguments : Inputs - in0, in1, in2, in3
- * Outputs - out0, out1
- * Return Type - as per RTYPE
- * Details : Even halfword elements of 'in0' and 'in1' are interleaved
- * and written to 'out0'
- */
-#define ILVEV_H2(RTYPE, in0, in1, in2, in3, out0, out1) do { \
- out0 = (RTYPE)__msa_ilvev_h((v8i16)in1, (v8i16)in0); \
- out1 = (RTYPE)__msa_ilvev_h((v8i16)in3, (v8i16)in2); \
-} while (0)
-#define ILVEV_H2_UB(...) ILVEV_H2(v16u8, __VA_ARGS__)
-#define ILVEV_H2_UH(...) ILVEV_H2(v8u16, __VA_ARGS__)
-#define ILVEV_H2_SH(...) ILVEV_H2(v8i16, __VA_ARGS__)
-#define ILVEV_H2_SW(...) ILVEV_H2(v4i32, __VA_ARGS__)
-
-/* Description : Interleave odd halfword elements from vectors
- * Arguments : Inputs - in0, in1, in2, in3
- * Outputs - out0, out1
- * Return Type - as per RTYPE
- * Details : Odd halfword elements of 'in0' and 'in1' are interleaved
- * and written to 'out0'
- */
-#define ILVOD_H2(RTYPE, in0, in1, in2, in3, out0, out1) do { \
- out0 = (RTYPE)__msa_ilvod_h((v8i16)in1, (v8i16)in0); \
- out1 = (RTYPE)__msa_ilvod_h((v8i16)in3, (v8i16)in2); \
-} while (0)
-#define ILVOD_H2_UB(...) ILVOD_H2(v16u8, __VA_ARGS__)
-#define ILVOD_H2_UH(...) ILVOD_H2(v8u16, __VA_ARGS__)
-#define ILVOD_H2_SH(...) ILVOD_H2(v8i16, __VA_ARGS__)
-#define ILVOD_H2_SW(...) ILVOD_H2(v4i32, __VA_ARGS__)
-
-/* Description : Interleave even word elements from vectors
- * Arguments : Inputs - in0, in1, in2, in3
- * Outputs - out0, out1
- * Return Type - as per RTYPE
- * Details : Even word elements of 'in0' and 'in1' are interleaved
- * and written to 'out0'
- */
-#define ILVEV_W2(RTYPE, in0, in1, in2, in3, out0, out1) do { \
- out0 = (RTYPE)__msa_ilvev_w((v4i32)in1, (v4i32)in0); \
- out1 = (RTYPE)__msa_ilvev_w((v4i32)in3, (v4i32)in2); \
-} while (0)
-#define ILVEV_W2_UB(...) ILVEV_W2(v16u8, __VA_ARGS__)
-#define ILVEV_W2_SB(...) ILVEV_W2(v16i8, __VA_ARGS__)
-#define ILVEV_W2_UH(...) ILVEV_W2(v8u16, __VA_ARGS__)
-#define ILVEV_W2_SD(...) ILVEV_W2(v2i64, __VA_ARGS__)
-
-/* Description : Interleave even-odd word elements from vectors
- * Arguments : Inputs - in0, in1, in2, in3
- * Outputs - out0, out1
- * Return Type - as per RTYPE
- * Details : Even word elements of 'in0' and 'in1' are interleaved
- * and written to 'out0'
- * Odd word elements of 'in2' and 'in3' are interleaved
- * and written to 'out1'
- */
-#define ILVEVOD_W2(RTYPE, in0, in1, in2, in3, out0, out1) do { \
- out0 = (RTYPE)__msa_ilvev_w((v4i32)in1, (v4i32)in0); \
- out1 = (RTYPE)__msa_ilvod_w((v4i32)in3, (v4i32)in2); \
-} while (0)
-#define ILVEVOD_W2_UB(...) ILVEVOD_W2(v16u8, __VA_ARGS__)
-#define ILVEVOD_W2_UH(...) ILVEVOD_W2(v8u16, __VA_ARGS__)
-#define ILVEVOD_W2_SH(...) ILVEVOD_W2(v8i16, __VA_ARGS__)
-#define ILVEVOD_W2_SW(...) ILVEVOD_W2(v4i32, __VA_ARGS__)
-
-/* Description : Interleave even-odd half-word elements from vectors
- * Arguments : Inputs - in0, in1, in2, in3
- * Outputs - out0, out1
- * Return Type - as per RTYPE
- * Details : Even half-word elements of 'in0' and 'in1' are interleaved
- * and written to 'out0'
- * Odd half-word elements of 'in2' and 'in3' are interleaved
- * and written to 'out1'
- */
-#define ILVEVOD_H2(RTYPE, in0, in1, in2, in3, out0, out1) do { \
- out0 = (RTYPE)__msa_ilvev_h((v8i16)in1, (v8i16)in0); \
- out1 = (RTYPE)__msa_ilvod_h((v8i16)in3, (v8i16)in2); \
-} while (0)
-#define ILVEVOD_H2_UB(...) ILVEVOD_H2(v16u8, __VA_ARGS__)
-#define ILVEVOD_H2_UH(...) ILVEVOD_H2(v8u16, __VA_ARGS__)
-#define ILVEVOD_H2_SH(...) ILVEVOD_H2(v8i16, __VA_ARGS__)
-#define ILVEVOD_H2_SW(...) ILVEVOD_H2(v4i32, __VA_ARGS__)
-
-/* Description : Interleave even double word elements from vectors
- * Arguments : Inputs - in0, in1, in2, in3
- * Outputs - out0, out1
- * Return Type - as per RTYPE
- * Details : Even double word elements of 'in0' and 'in1' are interleaved
- * and written to 'out0'
- */
-#define ILVEV_D2(RTYPE, in0, in1, in2, in3, out0, out1) do { \
- out0 = (RTYPE)__msa_ilvev_d((v2i64)in1, (v2i64)in0); \
- out1 = (RTYPE)__msa_ilvev_d((v2i64)in3, (v2i64)in2); \
-} while (0)
-#define ILVEV_D2_UB(...) ILVEV_D2(v16u8, __VA_ARGS__)
-#define ILVEV_D2_SB(...) ILVEV_D2(v16i8, __VA_ARGS__)
-#define ILVEV_D2_SW(...) ILVEV_D2(v4i32, __VA_ARGS__)
-#define ILVEV_D2_SD(...) ILVEV_D2(v2i64, __VA_ARGS__)
-
-/* Description : Interleave left half of byte elements from vectors
- * Arguments : Inputs - in0, in1, in2, in3
- * Outputs - out0, out1
- * Return Type - as per RTYPE
- * Details : Left half of byte elements of 'in0' and 'in1' are interleaved
- * and written to 'out0'.
- */
-#define ILVL_B2(RTYPE, in0, in1, in2, in3, out0, out1) do { \
- out0 = (RTYPE)__msa_ilvl_b((v16i8)in0, (v16i8)in1); \
- out1 = (RTYPE)__msa_ilvl_b((v16i8)in2, (v16i8)in3); \
-} while (0)
-#define ILVL_B2_UB(...) ILVL_B2(v16u8, __VA_ARGS__)
-#define ILVL_B2_SB(...) ILVL_B2(v16i8, __VA_ARGS__)
-#define ILVL_B2_UH(...) ILVL_B2(v8u16, __VA_ARGS__)
-#define ILVL_B2_SH(...) ILVL_B2(v8i16, __VA_ARGS__)
-#define ILVL_B2_SW(...) ILVL_B2(v4i32, __VA_ARGS__)
-
-/* Description : Interleave right half of byte elements from vectors
- * Arguments : Inputs - in0, in1, in2, in3
- * Outputs - out0, out1
- * Return Type - as per RTYPE
- * Details : Right half of byte elements of 'in0' and 'in1' are interleaved
- * and written to out0.
- */
-#define ILVR_B2(RTYPE, in0, in1, in2, in3, out0, out1) do { \
- out0 = (RTYPE)__msa_ilvr_b((v16i8)in0, (v16i8)in1); \
- out1 = (RTYPE)__msa_ilvr_b((v16i8)in2, (v16i8)in3); \
-} while (0)
-#define ILVR_B2_UB(...) ILVR_B2(v16u8, __VA_ARGS__)
-#define ILVR_B2_SB(...) ILVR_B2(v16i8, __VA_ARGS__)
-#define ILVR_B2_UH(...) ILVR_B2(v8u16, __VA_ARGS__)
-#define ILVR_B2_SH(...) ILVR_B2(v8i16, __VA_ARGS__)
-#define ILVR_B2_SW(...) ILVR_B2(v4i32, __VA_ARGS__)
-
-#define ILVR_B4(RTYPE, in0, in1, in2, in3, in4, in5, in6, in7, \
- out0, out1, out2, out3) do { \
- ILVR_B2(RTYPE, in0, in1, in2, in3, out0, out1); \
- ILVR_B2(RTYPE, in4, in5, in6, in7, out2, out3); \
-} while (0)
-#define ILVR_B4_UB(...) ILVR_B4(v16u8, __VA_ARGS__)
-#define ILVR_B4_SB(...) ILVR_B4(v16i8, __VA_ARGS__)
-#define ILVR_B4_UH(...) ILVR_B4(v8u16, __VA_ARGS__)
-#define ILVR_B4_SH(...) ILVR_B4(v8i16, __VA_ARGS__)
-#define ILVR_B4_SW(...) ILVR_B4(v4i32, __VA_ARGS__)
-
-/* Description : Interleave right half of halfword elements from vectors
- * Arguments : Inputs - in0, in1, in2, in3
- * Outputs - out0, out1
- * Return Type - as per RTYPE
- * Details : Right half of halfword elements of 'in0' and 'in1' are
- * interleaved and written to 'out0'.
- */
-#define ILVR_H2(RTYPE, in0, in1, in2, in3, out0, out1) do { \
- out0 = (RTYPE)__msa_ilvr_h((v8i16)in0, (v8i16)in1); \
- out1 = (RTYPE)__msa_ilvr_h((v8i16)in2, (v8i16)in3); \
-} while (0)
-#define ILVR_H2_UB(...) ILVR_H2(v16u8, __VA_ARGS__)
-#define ILVR_H2_SH(...) ILVR_H2(v8i16, __VA_ARGS__)
-#define ILVR_H2_SW(...) ILVR_H2(v4i32, __VA_ARGS__)
-
-#define ILVR_H4(RTYPE, in0, in1, in2, in3, in4, in5, in6, in7, \
- out0, out1, out2, out3) do { \
- ILVR_H2(RTYPE, in0, in1, in2, in3, out0, out1); \
- ILVR_H2(RTYPE, in4, in5, in6, in7, out2, out3); \
-} while (0)
-#define ILVR_H4_UB(...) ILVR_H4(v16u8, __VA_ARGS__)
-#define ILVR_H4_SH(...) ILVR_H4(v8i16, __VA_ARGS__)
-#define ILVR_H4_SW(...) ILVR_H4(v4i32, __VA_ARGS__)
-
-/* Description : Interleave right half of double word elements from vectors
- * Arguments : Inputs - in0, in1, in2, in3
- * Outputs - out0, out1
- * Return Type - as per RTYPE
- * Details : Right half of double word elements of 'in0' and 'in1' are
- * interleaved and written to 'out0'.
- */
-#define ILVR_D2(RTYPE, in0, in1, in2, in3, out0, out1) do { \
- out0 = (RTYPE)__msa_ilvr_d((v2i64)in0, (v2i64)in1); \
- out1 = (RTYPE)__msa_ilvr_d((v2i64)in2, (v2i64)in3); \
-} while (0)
-#define ILVR_D2_UB(...) ILVR_D2(v16u8, __VA_ARGS__)
-#define ILVR_D2_SB(...) ILVR_D2(v16i8, __VA_ARGS__)
-#define ILVR_D2_SH(...) ILVR_D2(v8i16, __VA_ARGS__)
-
-#define ILVR_D4(RTYPE, in0, in1, in2, in3, in4, in5, in6, in7, \
- out0, out1, out2, out3) do { \
- ILVR_D2(RTYPE, in0, in1, in2, in3, out0, out1); \
- ILVR_D2(RTYPE, in4, in5, in6, in7, out2, out3); \
-} while (0)
-#define ILVR_D4_SB(...) ILVR_D4(v16i8, __VA_ARGS__)
-#define ILVR_D4_UB(...) ILVR_D4(v16u8, __VA_ARGS__)
-
-/* Description : Interleave both left and right half of input vectors
- * Arguments : Inputs - in0, in1
- * Outputs - out0, out1
- * Return Type - as per RTYPE
- * Details : Right half of byte elements from 'in0' and 'in1' are
- * interleaved and written to 'out0'
- */
-#define ILVRL_B2(RTYPE, in0, in1, out0, out1) do { \
- out0 = (RTYPE)__msa_ilvr_b((v16i8)in0, (v16i8)in1); \
- out1 = (RTYPE)__msa_ilvl_b((v16i8)in0, (v16i8)in1); \
-} while (0)
-#define ILVRL_B2_UB(...) ILVRL_B2(v16u8, __VA_ARGS__)
-#define ILVRL_B2_SB(...) ILVRL_B2(v16i8, __VA_ARGS__)
-#define ILVRL_B2_UH(...) ILVRL_B2(v8u16, __VA_ARGS__)
-#define ILVRL_B2_SH(...) ILVRL_B2(v8i16, __VA_ARGS__)
-#define ILVRL_B2_SW(...) ILVRL_B2(v4i32, __VA_ARGS__)
-
-#define ILVRL_H2(RTYPE, in0, in1, out0, out1) do { \
- out0 = (RTYPE)__msa_ilvr_h((v8i16)in0, (v8i16)in1); \
- out1 = (RTYPE)__msa_ilvl_h((v8i16)in0, (v8i16)in1); \
-} while (0)
-#define ILVRL_H2_UB(...) ILVRL_H2(v16u8, __VA_ARGS__)
-#define ILVRL_H2_SB(...) ILVRL_H2(v16i8, __VA_ARGS__)
-#define ILVRL_H2_SH(...) ILVRL_H2(v8i16, __VA_ARGS__)
-#define ILVRL_H2_SW(...) ILVRL_H2(v4i32, __VA_ARGS__)
-#define ILVRL_H2_UW(...) ILVRL_H2(v4u32, __VA_ARGS__)
-
-#define ILVRL_W2(RTYPE, in0, in1, out0, out1) do { \
- out0 = (RTYPE)__msa_ilvr_w((v4i32)in0, (v4i32)in1); \
- out1 = (RTYPE)__msa_ilvl_w((v4i32)in0, (v4i32)in1); \
-} while (0)
-#define ILVRL_W2_UB(...) ILVRL_W2(v16u8, __VA_ARGS__)
-#define ILVRL_W2_SH(...) ILVRL_W2(v8i16, __VA_ARGS__)
-#define ILVRL_W2_SW(...) ILVRL_W2(v4i32, __VA_ARGS__)
-#define ILVRL_W2_UW(...) ILVRL_W2(v4u32, __VA_ARGS__)
-
-/* Description : Pack even byte elements of vector pairs
- * Arguments : Inputs - in0, in1, in2, in3
- * Outputs - out0, out1
- * Return Type - as per RTYPE
- * Details : Even byte elements of 'in0' are copied to the left half of
- * 'out0' & even byte elements of 'in1' are copied to the right
- * half of 'out0'.
- */
-#define PCKEV_B2(RTYPE, in0, in1, in2, in3, out0, out1) do { \
- out0 = (RTYPE)__msa_pckev_b((v16i8)in0, (v16i8)in1); \
- out1 = (RTYPE)__msa_pckev_b((v16i8)in2, (v16i8)in3); \
-} while (0)
-#define PCKEV_B2_SB(...) PCKEV_B2(v16i8, __VA_ARGS__)
-#define PCKEV_B2_UB(...) PCKEV_B2(v16u8, __VA_ARGS__)
-#define PCKEV_B2_SH(...) PCKEV_B2(v8i16, __VA_ARGS__)
-#define PCKEV_B2_SW(...) PCKEV_B2(v4i32, __VA_ARGS__)
-
-#define PCKEV_B4(RTYPE, in0, in1, in2, in3, in4, in5, in6, in7, \
- out0, out1, out2, out3) do { \
- PCKEV_B2(RTYPE, in0, in1, in2, in3, out0, out1); \
- PCKEV_B2(RTYPE, in4, in5, in6, in7, out2, out3); \
-} while (0)
-#define PCKEV_B4_SB(...) PCKEV_B4(v16i8, __VA_ARGS__)
-#define PCKEV_B4_UB(...) PCKEV_B4(v16u8, __VA_ARGS__)
-#define PCKEV_B4_SH(...) PCKEV_B4(v8i16, __VA_ARGS__)
-#define PCKEV_B4_SW(...) PCKEV_B4(v4i32, __VA_ARGS__)
-
-/* Description : Pack even halfword elements of vector pairs
- * Arguments : Inputs - in0, in1, in2, in3
- * Outputs - out0, out1
- * Return Type - as per RTYPE
- * Details : Even halfword elements of 'in0' are copied to the left half of
- * 'out0' & even halfword elements of 'in1' are copied to the
- * right half of 'out0'.
- */
-#define PCKEV_H2(RTYPE, in0, in1, in2, in3, out0, out1) do { \
- out0 = (RTYPE)__msa_pckev_h((v8i16)in0, (v8i16)in1); \
- out1 = (RTYPE)__msa_pckev_h((v8i16)in2, (v8i16)in3); \
-} while (0)
-#define PCKEV_H2_UH(...) PCKEV_H2(v8u16, __VA_ARGS__)
-#define PCKEV_H2_SH(...) PCKEV_H2(v8i16, __VA_ARGS__)
-#define PCKEV_H2_SW(...) PCKEV_H2(v4i32, __VA_ARGS__)
-#define PCKEV_H2_UW(...) PCKEV_H2(v4u32, __VA_ARGS__)
-
-/* Description : Pack even word elements of vector pairs
- * Arguments : Inputs - in0, in1, in2, in3
- * Outputs - out0, out1
- * Return Type - as per RTYPE
- * Details : Even word elements of 'in0' are copied to the left half of
- * 'out0' & even word elements of 'in1' are copied to the
- * right half of 'out0'.
- */
-#define PCKEV_W2(RTYPE, in0, in1, in2, in3, out0, out1) do { \
- out0 = (RTYPE)__msa_pckev_w((v4i32)in0, (v4i32)in1); \
- out1 = (RTYPE)__msa_pckev_w((v4i32)in2, (v4i32)in3); \
-} while (0)
-#define PCKEV_W2_UH(...) PCKEV_W2(v8u16, __VA_ARGS__)
-#define PCKEV_W2_SH(...) PCKEV_W2(v8i16, __VA_ARGS__)
-#define PCKEV_W2_SW(...) PCKEV_W2(v4i32, __VA_ARGS__)
-#define PCKEV_W2_UW(...) PCKEV_W2(v4u32, __VA_ARGS__)
-
-/* Description : Pack odd halfword elements of vector pairs
- * Arguments : Inputs - in0, in1, in2, in3
- * Outputs - out0, out1
- * Return Type - as per RTYPE
- * Details : Odd halfword elements of 'in0' are copied to the left half of
- * 'out0' & odd halfword elements of 'in1' are copied to the
- * right half of 'out0'.
- */
-#define PCKOD_H2(RTYPE, in0, in1, in2, in3, out0, out1) do { \
- out0 = (RTYPE)__msa_pckod_h((v8i16)in0, (v8i16)in1); \
- out1 = (RTYPE)__msa_pckod_h((v8i16)in2, (v8i16)in3); \
-} while (0)
-#define PCKOD_H2_UH(...) PCKOD_H2(v8u16, __VA_ARGS__)
-#define PCKOD_H2_SH(...) PCKOD_H2(v8i16, __VA_ARGS__)
-#define PCKOD_H2_SW(...) PCKOD_H2(v4i32, __VA_ARGS__)
-#define PCKOD_H2_UW(...) PCKOD_H2(v4u32, __VA_ARGS__)
-
-/* Description : Arithmetic immediate shift right all elements of word vector
- * Arguments : Inputs - in0, in1, shift
- * Outputs - in place operation
- * Return Type - as per input vector RTYPE
- * Details : Each element of vector 'in0' is right shifted by 'shift' and
- * the result is written in-place. 'shift' is a GP variable.
- */
-#define SRAI_W2(RTYPE, in0, in1, shift_val) do { \
- in0 = (RTYPE)SRAI_W(in0, shift_val); \
- in1 = (RTYPE)SRAI_W(in1, shift_val); \
-} while (0)
-#define SRAI_W2_SW(...) SRAI_W2(v4i32, __VA_ARGS__)
-#define SRAI_W2_UW(...) SRAI_W2(v4u32, __VA_ARGS__)
-
-#define SRAI_W4(RTYPE, in0, in1, in2, in3, shift_val) do { \
- SRAI_W2(RTYPE, in0, in1, shift_val); \
- SRAI_W2(RTYPE, in2, in3, shift_val); \
-} while (0)
-#define SRAI_W4_SW(...) SRAI_W4(v4i32, __VA_ARGS__)
-#define SRAI_W4_UW(...) SRAI_W4(v4u32, __VA_ARGS__)
-
-/* Description : Arithmetic shift right all elements of half-word vector
- * Arguments : Inputs - in0, in1, shift
- * Outputs - in place operation
- * Return Type - as per input vector RTYPE
- * Details : Each element of vector 'in0' is right shifted by 'shift' and
- * the result is written in-place. 'shift' is a GP variable.
- */
-#define SRAI_H2(RTYPE, in0, in1, shift_val) do { \
- in0 = (RTYPE)SRAI_H(in0, shift_val); \
- in1 = (RTYPE)SRAI_H(in1, shift_val); \
-} while (0)
-#define SRAI_H2_SH(...) SRAI_H2(v8i16, __VA_ARGS__)
-#define SRAI_H2_UH(...) SRAI_H2(v8u16, __VA_ARGS__)
-
-/* Description : Arithmetic rounded shift right all elements of word vector
- * Arguments : Inputs - in0, in1, shift
- * Outputs - in place operation
- * Return Type - as per input vector RTYPE
- * Details : Each element of vector 'in0' is right shifted by 'shift' and
- * the result is written in-place. 'shift' is a GP variable.
- */
-#define SRARI_W2(RTYPE, in0, in1, shift) do { \
- in0 = (RTYPE)__msa_srari_w((v4i32)in0, shift); \
- in1 = (RTYPE)__msa_srari_w((v4i32)in1, shift); \
-} while (0)
-#define SRARI_W2_SW(...) SRARI_W2(v4i32, __VA_ARGS__)
-
-#define SRARI_W4(RTYPE, in0, in1, in2, in3, shift) do { \
- SRARI_W2(RTYPE, in0, in1, shift); \
- SRARI_W2(RTYPE, in2, in3, shift); \
-} while (0)
-#define SRARI_W4_SH(...) SRARI_W4(v8i16, __VA_ARGS__)
-#define SRARI_W4_UW(...) SRARI_W4(v4u32, __VA_ARGS__)
-#define SRARI_W4_SW(...) SRARI_W4(v4i32, __VA_ARGS__)
-
-/* Description : Shift right arithmetic rounded double words
- * Arguments : Inputs - in0, in1, shift
- * Outputs - in place operation
- * Return Type - as per RTYPE
- * Details : Each element of vector 'in0' is shifted right arithmetically by
- * the number of bits in the corresponding element in the vector
- * 'shift'. The last discarded bit is added to shifted value for
- * rounding and the result is written in-place.
- * 'shift' is a vector.
- */
-#define SRAR_D2(RTYPE, in0, in1, shift) do { \
- in0 = (RTYPE)__msa_srar_d((v2i64)in0, (v2i64)shift); \
- in1 = (RTYPE)__msa_srar_d((v2i64)in1, (v2i64)shift); \
-} while (0)
-#define SRAR_D2_SW(...) SRAR_D2(v4i32, __VA_ARGS__)
-#define SRAR_D2_SD(...) SRAR_D2(v2i64, __VA_ARGS__)
-#define SRAR_D2_UD(...) SRAR_D2(v2u64, __VA_ARGS__)
-
-#define SRAR_D4(RTYPE, in0, in1, in2, in3, shift) do { \
- SRAR_D2(RTYPE, in0, in1, shift); \
- SRAR_D2(RTYPE, in2, in3, shift); \
-} while (0)
-#define SRAR_D4_SD(...) SRAR_D4(v2i64, __VA_ARGS__)
-#define SRAR_D4_UD(...) SRAR_D4(v2u64, __VA_ARGS__)
-
-/* Description : Addition of 2 pairs of half-word vectors
- * Arguments : Inputs - in0, in1, in2, in3
- * Outputs - out0, out1
- * Details : Each element in 'in0' is added to 'in1' and result is written
- * to 'out0'.
- */
-#define ADDVI_H2(RTYPE, in0, in1, in2, in3, out0, out1) do { \
- out0 = (RTYPE)ADDVI_H(in0, in1); \
- out1 = (RTYPE)ADDVI_H(in2, in3); \
-} while (0)
-#define ADDVI_H2_SH(...) ADDVI_H2(v8i16, __VA_ARGS__)
-#define ADDVI_H2_UH(...) ADDVI_H2(v8u16, __VA_ARGS__)
-
-/* Description : Addition of 2 pairs of word vectors
- * Arguments : Inputs - in0, in1, in2, in3
- * Outputs - out0, out1
- * Details : Each element in 'in0' is added to 'in1' and result is written
- * to 'out0'.
- */
-#define ADDVI_W2(RTYPE, in0, in1, in2, in3, out0, out1) do { \
- out0 = (RTYPE)ADDVI_W(in0, in1); \
- out1 = (RTYPE)ADDVI_W(in2, in3); \
-} while (0)
-#define ADDVI_W2_SW(...) ADDVI_W2(v4i32, __VA_ARGS__)
-
-/* Description : Fill 2 pairs of word vectors with GP registers
- * Arguments : Inputs - in0, in1
- * Outputs - out0, out1
- * Details : GP register in0 is replicated in each word element of out0
- * GP register in1 is replicated in each word element of out1
- */
-#define FILL_W2(RTYPE, in0, in1, out0, out1) do { \
- out0 = (RTYPE)__msa_fill_w(in0); \
- out1 = (RTYPE)__msa_fill_w(in1); \
-} while (0)
-#define FILL_W2_SW(...) FILL_W2(v4i32, __VA_ARGS__)
-
-/* Description : Addition of 2 pairs of vectors
- * Arguments : Inputs - in0, in1, in2, in3
- * Outputs - out0, out1
- * Details : Each element in 'in0' is added to 'in1' and result is written
- * to 'out0'.
- */
-#define ADD2(in0, in1, in2, in3, out0, out1) do { \
- out0 = in0 + in1; \
- out1 = in2 + in3; \
-} while (0)
-
-#define ADD4(in0, in1, in2, in3, in4, in5, in6, in7, \
- out0, out1, out2, out3) do { \
- ADD2(in0, in1, in2, in3, out0, out1); \
- ADD2(in4, in5, in6, in7, out2, out3); \
-} while (0)
-
-/* Description : Subtraction of 2 pairs of vectors
- * Arguments : Inputs - in0, in1, in2, in3
- * Outputs - out0, out1
- * Details : Each element in 'in1' is subtracted from 'in0' and result is
- * written to 'out0'.
- */
-#define SUB2(in0, in1, in2, in3, out0, out1) do { \
- out0 = in0 - in1; \
- out1 = in2 - in3; \
-} while (0)
-
-#define SUB3(in0, in1, in2, in3, in4, in5, out0, out1, out2) do { \
- out0 = in0 - in1; \
- out1 = in2 - in3; \
- out2 = in4 - in5; \
-} while (0)
-
-#define SUB4(in0, in1, in2, in3, in4, in5, in6, in7, \
- out0, out1, out2, out3) do { \
- out0 = in0 - in1; \
- out1 = in2 - in3; \
- out2 = in4 - in5; \
- out3 = in6 - in7; \
-} while (0)
-
-/* Description : Addition - Subtraction of input vectors
- * Arguments : Inputs - in0, in1
- * Outputs - out0, out1
- * Details : Each element in 'in1' is added to 'in0' and result is
- * written to 'out0'.
- * Each element in 'in1' is subtracted from 'in0' and result is
- * written to 'out1'.
- */
-#define ADDSUB2(in0, in1, out0, out1) do { \
- out0 = in0 + in1; \
- out1 = in0 - in1; \
-} while (0)
-
-/* Description : Multiplication of pairs of vectors
- * Arguments : Inputs - in0, in1, in2, in3
- * Outputs - out0, out1
- * Details : Each element from 'in0' is multiplied with elements from 'in1'
- * and the result is written to 'out0'
- */
-#define MUL2(in0, in1, in2, in3, out0, out1) do { \
- out0 = in0 * in1; \
- out1 = in2 * in3; \
-} while (0)
-
-#define MUL4(in0, in1, in2, in3, in4, in5, in6, in7, \
- out0, out1, out2, out3) do { \
- MUL2(in0, in1, in2, in3, out0, out1); \
- MUL2(in4, in5, in6, in7, out2, out3); \
-} while (0)
-
-/* Description : Sign extend halfword elements from right half of the vector
- * Arguments : Input - in (halfword vector)
- * Output - out (sign extended word vector)
- * Return Type - signed word
- * Details : Sign bit of halfword elements from input vector 'in' is
- * extracted and interleaved with same vector 'in0' to generate
- * 4 word elements keeping sign intact
- */
-#define UNPCK_R_SH_SW(in, out) do { \
- const v8i16 sign_m = __msa_clti_s_h((v8i16)in, 0); \
- out = (v4i32)__msa_ilvr_h(sign_m, (v8i16)in); \
-} while (0)
-
-/* Description : Sign extend halfword elements from input vector and return
- * the result in pair of vectors
- * Arguments : Input - in (halfword vector)
- * Outputs - out0, out1 (sign extended word vectors)
- * Return Type - signed word
- * Details : Sign bit of halfword elements from input vector 'in' is
- * extracted and interleaved right with same vector 'in0' to
- * generate 4 signed word elements in 'out0'
- * Then interleaved left with same vector 'in0' to
- * generate 4 signed word elements in 'out1'
- */
-#define UNPCK_SH_SW(in, out0, out1) do { \
- const v8i16 tmp_m = __msa_clti_s_h((v8i16)in, 0); \
- ILVRL_H2_SW(tmp_m, in, out0, out1); \
-} while (0)
-
-/* Description : Butterfly of 4 input vectors
- * Arguments : Inputs - in0, in1, in2, in3
- * Outputs - out0, out1, out2, out3
- * Details : Butterfly operation
- */
-#define BUTTERFLY_4(in0, in1, in2, in3, out0, out1, out2, out3) do { \
- out0 = in0 + in3; \
- out1 = in1 + in2; \
- out2 = in1 - in2; \
- out3 = in0 - in3; \
-} while (0)
-
-/* Description : Transpose 16x4 block into 4x16 with byte elements in vectors
- * Arguments : Inputs - in0, in1, in2, in3, in4, in5, in6, in7,
- * in8, in9, in10, in11, in12, in13, in14, in15
- * Outputs - out0, out1, out2, out3
- * Return Type - unsigned byte
- */
-#define TRANSPOSE16x4_UB_UB(in0, in1, in2, in3, in4, in5, in6, in7, \
- in8, in9, in10, in11, in12, in13, in14, in15, \
- out0, out1, out2, out3) do { \
- v2i64 tmp0_m, tmp1_m, tmp2_m, tmp3_m, tmp4_m, tmp5_m; \
- ILVEV_W2_SD(in0, in4, in8, in12, tmp2_m, tmp3_m); \
- ILVEV_W2_SD(in1, in5, in9, in13, tmp0_m, tmp1_m); \
- ILVEV_D2_UB(tmp2_m, tmp3_m, tmp0_m, tmp1_m, out1, out3); \
- ILVEV_W2_SD(in2, in6, in10, in14, tmp4_m, tmp5_m); \
- ILVEV_W2_SD(in3, in7, in11, in15, tmp0_m, tmp1_m); \
- ILVEV_D2_SD(tmp4_m, tmp5_m, tmp0_m, tmp1_m, tmp2_m, tmp3_m); \
- ILVEV_B2_SD(out1, out3, tmp2_m, tmp3_m, tmp0_m, tmp1_m); \
- ILVEVOD_H2_UB(tmp0_m, tmp1_m, tmp0_m, tmp1_m, out0, out2); \
- ILVOD_B2_SD(out1, out3, tmp2_m, tmp3_m, tmp0_m, tmp1_m); \
- ILVEVOD_H2_UB(tmp0_m, tmp1_m, tmp0_m, tmp1_m, out1, out3); \
-} while (0)
-
-/* Description : Transpose 16x8 block into 8x16 with byte elements in vectors
- * Arguments : Inputs - in0, in1, in2, in3, in4, in5, in6, in7,
- * in8, in9, in10, in11, in12, in13, in14, in15
- * Outputs - out0, out1, out2, out3, out4, out5, out6, out7
- * Return Type - unsigned byte
- */
-#define TRANSPOSE16x8_UB_UB(in0, in1, in2, in3, in4, in5, in6, in7, \
- in8, in9, in10, in11, in12, in13, in14, in15, \
- out0, out1, out2, out3, out4, out5, \
- out6, out7) do { \
- v8i16 tmp0_m, tmp1_m, tmp4_m, tmp5_m, tmp6_m, tmp7_m; \
- v4i32 tmp2_m, tmp3_m; \
- ILVEV_D2_UB(in0, in8, in1, in9, out7, out6); \
- ILVEV_D2_UB(in2, in10, in3, in11, out5, out4); \
- ILVEV_D2_UB(in4, in12, in5, in13, out3, out2); \
- ILVEV_D2_UB(in6, in14, in7, in15, out1, out0); \
- ILVEV_B2_SH(out7, out6, out5, out4, tmp0_m, tmp1_m); \
- ILVOD_B2_SH(out7, out6, out5, out4, tmp4_m, tmp5_m); \
- ILVEV_B2_UB(out3, out2, out1, out0, out5, out7); \
- ILVOD_B2_SH(out3, out2, out1, out0, tmp6_m, tmp7_m); \
- ILVEV_H2_SW(tmp0_m, tmp1_m, out5, out7, tmp2_m, tmp3_m); \
- ILVEVOD_W2_UB(tmp2_m, tmp3_m, tmp2_m, tmp3_m, out0, out4); \
- ILVOD_H2_SW(tmp0_m, tmp1_m, out5, out7, tmp2_m, tmp3_m); \
- ILVEVOD_W2_UB(tmp2_m, tmp3_m, tmp2_m, tmp3_m, out2, out6); \
- ILVEV_H2_SW(tmp4_m, tmp5_m, tmp6_m, tmp7_m, tmp2_m, tmp3_m); \
- ILVEVOD_W2_UB(tmp2_m, tmp3_m, tmp2_m, tmp3_m, out1, out5); \
- ILVOD_H2_SW(tmp4_m, tmp5_m, tmp6_m, tmp7_m, tmp2_m, tmp3_m); \
- ILVEVOD_W2_UB(tmp2_m, tmp3_m, tmp2_m, tmp3_m, out3, out7); \
-} while (0)
-
-/* Description : Transpose 4x4 block with word elements in vectors
- * Arguments : Inputs - in0, in1, in2, in3
- * Outputs - out0, out1, out2, out3
- * Return Type - as per RTYPE
- */
-#define TRANSPOSE4x4_W(RTYPE, in0, in1, in2, in3, \
- out0, out1, out2, out3) do { \
- v4i32 s0_m, s1_m, s2_m, s3_m; \
- ILVRL_W2_SW(in1, in0, s0_m, s1_m); \
- ILVRL_W2_SW(in3, in2, s2_m, s3_m); \
- out0 = (RTYPE)__msa_ilvr_d((v2i64)s2_m, (v2i64)s0_m); \
- out1 = (RTYPE)__msa_ilvl_d((v2i64)s2_m, (v2i64)s0_m); \
- out2 = (RTYPE)__msa_ilvr_d((v2i64)s3_m, (v2i64)s1_m); \
- out3 = (RTYPE)__msa_ilvl_d((v2i64)s3_m, (v2i64)s1_m); \
-} while (0)
-#define TRANSPOSE4x4_SW_SW(...) TRANSPOSE4x4_W(v4i32, __VA_ARGS__)
-
-/* Description : Add block 4x4
- * Arguments : Inputs - in0, in1, in2, in3, pdst, stride
- * Details : Least significant 4 bytes from each input vector are added to
- * the destination bytes, clipped between 0-255 and stored.
- */
-#define ADDBLK_ST4x4_UB(in0, in1, in2, in3, pdst, stride) do { \
- uint32_t src0_m, src1_m, src2_m, src3_m; \
- v8i16 inp0_m, inp1_m, res0_m, res1_m; \
- v16i8 dst0_m = { 0 }; \
- v16i8 dst1_m = { 0 }; \
- const v16i8 zero_m = { 0 }; \
- ILVR_D2_SH(in1, in0, in3, in2, inp0_m, inp1_m); \
- LW4(pdst, stride, src0_m, src1_m, src2_m, src3_m); \
- INSERT_W2_SB(src0_m, src1_m, dst0_m); \
- INSERT_W2_SB(src2_m, src3_m, dst1_m); \
- ILVR_B2_SH(zero_m, dst0_m, zero_m, dst1_m, res0_m, res1_m); \
- ADD2(res0_m, inp0_m, res1_m, inp1_m, res0_m, res1_m); \
- CLIP_SH2_0_255(res0_m, res1_m); \
- PCKEV_B2_SB(res0_m, res0_m, res1_m, res1_m, dst0_m, dst1_m); \
- ST4x4_UB(dst0_m, dst1_m, 0, 1, 0, 1, pdst, stride); \
-} while (0)
-
-/* Description : Pack even byte elements, extract 0 & 2 index words from pair
- * of results and store 4 words in destination memory as per
- * stride
- * Arguments : Inputs - in0, in1, in2, in3, pdst, stride
- */
-#define PCKEV_ST4x4_UB(in0, in1, in2, in3, pdst, stride) do { \
- v16i8 tmp0_m, tmp1_m; \
- PCKEV_B2_SB(in1, in0, in3, in2, tmp0_m, tmp1_m); \
- ST4x4_UB(tmp0_m, tmp1_m, 0, 2, 0, 2, pdst, stride); \
-} while (0)
-
-/* Description : average with rounding (in0 + in1 + 1) / 2.
- * Arguments : Inputs - in0, in1, in2, in3,
- * Outputs - out0, out1
- * Return Type - as per RTYPE
- * Details : Each unsigned byte element from 'in0' vector is added with
- * each unsigned byte element from 'in1' vector. Then the average
- * with rounding is calculated and written to 'out0'
- */
-#define AVER_UB2(RTYPE, in0, in1, in2, in3, out0, out1) do { \
- out0 = (RTYPE)__msa_aver_u_b((v16u8)in0, (v16u8)in1); \
- out1 = (RTYPE)__msa_aver_u_b((v16u8)in2, (v16u8)in3); \
-} while (0)
-#define AVER_UB2_UB(...) AVER_UB2(v16u8, __VA_ARGS__)
-
-#endif // WEBP_USE_MSA
-#endif // WEBP_DSP_MSA_MACRO_H_
diff --git a/contrib/libs/libwebp/dsp/neon.h b/contrib/libs/libwebp/dsp/neon.h
deleted file mode 100644
index 7aee386490..0000000000
--- a/contrib/libs/libwebp/dsp/neon.h
+++ /dev/null
@@ -1,104 +0,0 @@
-// Copyright 2014 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// NEON common code.
-
-#ifndef WEBP_DSP_NEON_H_
-#define WEBP_DSP_NEON_H_
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_NEON)
-
-#include <arm_neon.h>
-
-// Right now, some intrinsics functions seem slower, so we disable them
-// everywhere except newer clang/gcc or aarch64 where the inline assembly is
-// incompatible.
-#if LOCAL_CLANG_PREREQ(3,8) || LOCAL_GCC_PREREQ(4,9) || defined(__aarch64__)
-#define WEBP_USE_INTRINSICS // use intrinsics when possible
-#endif
-
-#define INIT_VECTOR2(v, a, b) do { \
- v.val[0] = a; \
- v.val[1] = b; \
-} while (0)
-
-#define INIT_VECTOR3(v, a, b, c) do { \
- v.val[0] = a; \
- v.val[1] = b; \
- v.val[2] = c; \
-} while (0)
-
-#define INIT_VECTOR4(v, a, b, c, d) do { \
- v.val[0] = a; \
- v.val[1] = b; \
- v.val[2] = c; \
- v.val[3] = d; \
-} while (0)
-
-// if using intrinsics, this flag avoids some functions that make gcc-4.6.3
-// crash ("internal compiler error: in immed_double_const, at emit-rtl.").
-// (probably similar to gcc.gnu.org/bugzilla/show_bug.cgi?id=48183)
-#if !(LOCAL_CLANG_PREREQ(3,8) || LOCAL_GCC_PREREQ(4,8) || defined(__aarch64__))
-#define WORK_AROUND_GCC
-#endif
-
-static WEBP_INLINE int32x4x4_t Transpose4x4_NEON(const int32x4x4_t rows) {
- uint64x2x2_t row01, row23;
-
- row01.val[0] = vreinterpretq_u64_s32(rows.val[0]);
- row01.val[1] = vreinterpretq_u64_s32(rows.val[1]);
- row23.val[0] = vreinterpretq_u64_s32(rows.val[2]);
- row23.val[1] = vreinterpretq_u64_s32(rows.val[3]);
- // Transpose 64-bit values (there's no vswp equivalent)
- {
- const uint64x1_t row0h = vget_high_u64(row01.val[0]);
- const uint64x1_t row2l = vget_low_u64(row23.val[0]);
- const uint64x1_t row1h = vget_high_u64(row01.val[1]);
- const uint64x1_t row3l = vget_low_u64(row23.val[1]);
- row01.val[0] = vcombine_u64(vget_low_u64(row01.val[0]), row2l);
- row23.val[0] = vcombine_u64(row0h, vget_high_u64(row23.val[0]));
- row01.val[1] = vcombine_u64(vget_low_u64(row01.val[1]), row3l);
- row23.val[1] = vcombine_u64(row1h, vget_high_u64(row23.val[1]));
- }
- {
- const int32x4x2_t out01 = vtrnq_s32(vreinterpretq_s32_u64(row01.val[0]),
- vreinterpretq_s32_u64(row01.val[1]));
- const int32x4x2_t out23 = vtrnq_s32(vreinterpretq_s32_u64(row23.val[0]),
- vreinterpretq_s32_u64(row23.val[1]));
- int32x4x4_t out;
- out.val[0] = out01.val[0];
- out.val[1] = out01.val[1];
- out.val[2] = out23.val[0];
- out.val[3] = out23.val[1];
- return out;
- }
-}
-
-#if 0 // Useful debug macro.
-#include <stdio.h>
-#define PRINT_REG(REG, SIZE) do { \
- int i; \
- printf("%s \t[%d]: 0x", #REG, SIZE); \
- if (SIZE == 8) { \
- uint8_t _tmp[8]; \
- vst1_u8(_tmp, (REG)); \
- for (i = 0; i < 8; ++i) printf("%.2x ", _tmp[i]); \
- } else if (SIZE == 16) { \
- uint16_t _tmp[4]; \
- vst1_u16(_tmp, (REG)); \
- for (i = 0; i < 4; ++i) printf("%.4x ", _tmp[i]); \
- } \
- printf("\n"); \
-} while (0)
-#endif
-
-#endif // WEBP_USE_NEON
-#endif // WEBP_DSP_NEON_H_
diff --git a/contrib/libs/libwebp/dsp/quant.h b/contrib/libs/libwebp/dsp/quant.h
deleted file mode 100644
index 0674cf33e5..0000000000
--- a/contrib/libs/libwebp/dsp/quant.h
+++ /dev/null
@@ -1,85 +0,0 @@
-// Copyright 2018 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-
-#ifndef WEBP_DSP_QUANT_H_
-#define WEBP_DSP_QUANT_H_
-
-#include <string.h>
-
-#include "./dsp.h"
-#include "../webp/types.h"
-
-#if defined(WEBP_USE_NEON) && !defined(WEBP_ANDROID_NEON) && \
- !defined(WEBP_HAVE_NEON_RTCD)
-#include <arm_neon.h>
-
-#define IsFlat IsFlat_NEON
-
-static uint32x2_t horizontal_add_uint32x4(const uint32x4_t a) {
- const uint64x2_t b = vpaddlq_u32(a);
- return vadd_u32(vreinterpret_u32_u64(vget_low_u64(b)),
- vreinterpret_u32_u64(vget_high_u64(b)));
-}
-
-static WEBP_INLINE int IsFlat(const int16_t* levels, int num_blocks,
- int thresh) {
- const int16x8_t tst_ones = vdupq_n_s16(-1);
- uint32x4_t sum = vdupq_n_u32(0);
-
- for (int i = 0; i < num_blocks; ++i) {
- // Set DC to zero.
- const int16x8_t a_0 = vsetq_lane_s16(0, vld1q_s16(levels), 0);
- const int16x8_t a_1 = vld1q_s16(levels + 8);
-
- const uint16x8_t b_0 = vshrq_n_u16(vtstq_s16(a_0, tst_ones), 15);
- const uint16x8_t b_1 = vshrq_n_u16(vtstq_s16(a_1, tst_ones), 15);
-
- sum = vpadalq_u16(sum, b_0);
- sum = vpadalq_u16(sum, b_1);
-
- levels += 16;
- }
- return thresh >= (int32_t)vget_lane_u32(horizontal_add_uint32x4(sum), 0);
-}
-
-#else
-
-#define IsFlat IsFlat_C
-
-static WEBP_INLINE int IsFlat(const int16_t* levels, int num_blocks,
- int thresh) {
- int score = 0;
- while (num_blocks-- > 0) { // TODO(skal): refine positional scoring?
- int i;
- for (i = 1; i < 16; ++i) { // omit DC, we're only interested in AC
- score += (levels[i] != 0);
- if (score > thresh) return 0;
- }
- levels += 16;
- }
- return 1;
-}
-
-#endif // defined(WEBP_USE_NEON) && !defined(WEBP_ANDROID_NEON) &&
- // !defined(WEBP_HAVE_NEON_RTCD)
-
-static WEBP_INLINE int IsFlatSource16(const uint8_t* src) {
- const uint32_t v = src[0] * 0x01010101u;
- int i;
- for (i = 0; i < 16; ++i) {
- if (memcmp(src + 0, &v, 4) || memcmp(src + 4, &v, 4) ||
- memcmp(src + 8, &v, 4) || memcmp(src + 12, &v, 4)) {
- return 0;
- }
- src += BPS;
- }
- return 1;
-}
-
-#endif // WEBP_DSP_QUANT_H_
diff --git a/contrib/libs/libwebp/dsp/rescaler.c b/contrib/libs/libwebp/dsp/rescaler.c
deleted file mode 100644
index 736c1d1b9a..0000000000
--- a/contrib/libs/libwebp/dsp/rescaler.c
+++ /dev/null
@@ -1,251 +0,0 @@
-// Copyright 2014 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Rescaling functions
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include <assert.h>
-
-#include "./dsp.h"
-#include "../utils/rescaler_utils.h"
-
-//------------------------------------------------------------------------------
-// Implementations of critical functions ImportRow / ExportRow
-
-#define ROUNDER (WEBP_RESCALER_ONE >> 1)
-#define MULT_FIX(x, y) (((uint64_t)(x) * (y) + ROUNDER) >> WEBP_RESCALER_RFIX)
-#define MULT_FIX_FLOOR(x, y) (((uint64_t)(x) * (y)) >> WEBP_RESCALER_RFIX)
-
-//------------------------------------------------------------------------------
-// Row import
-
-void WebPRescalerImportRowExpand_C(WebPRescaler* const wrk,
- const uint8_t* src) {
- const int x_stride = wrk->num_channels;
- const int x_out_max = wrk->dst_width * wrk->num_channels;
- int channel;
- assert(!WebPRescalerInputDone(wrk));
- assert(wrk->x_expand);
- for (channel = 0; channel < x_stride; ++channel) {
- int x_in = channel;
- int x_out = channel;
- // simple bilinear interpolation
- int accum = wrk->x_add;
- rescaler_t left = (rescaler_t)src[x_in];
- rescaler_t right =
- (wrk->src_width > 1) ? (rescaler_t)src[x_in + x_stride] : left;
- x_in += x_stride;
- while (1) {
- wrk->frow[x_out] = right * wrk->x_add + (left - right) * accum;
- x_out += x_stride;
- if (x_out >= x_out_max) break;
- accum -= wrk->x_sub;
- if (accum < 0) {
- left = right;
- x_in += x_stride;
- assert(x_in < wrk->src_width * x_stride);
- right = (rescaler_t)src[x_in];
- accum += wrk->x_add;
- }
- }
- assert(wrk->x_sub == 0 /* <- special case for src_width=1 */ || accum == 0);
- }
-}
-
-void WebPRescalerImportRowShrink_C(WebPRescaler* const wrk,
- const uint8_t* src) {
- const int x_stride = wrk->num_channels;
- const int x_out_max = wrk->dst_width * wrk->num_channels;
- int channel;
- assert(!WebPRescalerInputDone(wrk));
- assert(!wrk->x_expand);
- for (channel = 0; channel < x_stride; ++channel) {
- int x_in = channel;
- int x_out = channel;
- uint32_t sum = 0;
- int accum = 0;
- while (x_out < x_out_max) {
- uint32_t base = 0;
- accum += wrk->x_add;
- while (accum > 0) {
- accum -= wrk->x_sub;
- assert(x_in < wrk->src_width * x_stride);
- base = src[x_in];
- sum += base;
- x_in += x_stride;
- }
- { // Emit next horizontal pixel.
- const rescaler_t frac = base * (-accum);
- wrk->frow[x_out] = sum * wrk->x_sub - frac;
- // fresh fractional start for next pixel
- sum = (int)MULT_FIX(frac, wrk->fx_scale);
- }
- x_out += x_stride;
- }
- assert(accum == 0);
- }
-}
-
-//------------------------------------------------------------------------------
-// Row export
-
-void WebPRescalerExportRowExpand_C(WebPRescaler* const wrk) {
- int x_out;
- uint8_t* const dst = wrk->dst;
- rescaler_t* const irow = wrk->irow;
- const int x_out_max = wrk->dst_width * wrk->num_channels;
- const rescaler_t* const frow = wrk->frow;
- assert(!WebPRescalerOutputDone(wrk));
- assert(wrk->y_accum <= 0);
- assert(wrk->y_expand);
- assert(wrk->y_sub != 0);
- if (wrk->y_accum == 0) {
- for (x_out = 0; x_out < x_out_max; ++x_out) {
- const uint32_t J = frow[x_out];
- const int v = (int)MULT_FIX(J, wrk->fy_scale);
- dst[x_out] = (v > 255) ? 255u : (uint8_t)v;
- }
- } else {
- const uint32_t B = WEBP_RESCALER_FRAC(-wrk->y_accum, wrk->y_sub);
- const uint32_t A = (uint32_t)(WEBP_RESCALER_ONE - B);
- for (x_out = 0; x_out < x_out_max; ++x_out) {
- const uint64_t I = (uint64_t)A * frow[x_out]
- + (uint64_t)B * irow[x_out];
- const uint32_t J = (uint32_t)((I + ROUNDER) >> WEBP_RESCALER_RFIX);
- const int v = (int)MULT_FIX(J, wrk->fy_scale);
- dst[x_out] = (v > 255) ? 255u : (uint8_t)v;
- }
- }
-}
-
-void WebPRescalerExportRowShrink_C(WebPRescaler* const wrk) {
- int x_out;
- uint8_t* const dst = wrk->dst;
- rescaler_t* const irow = wrk->irow;
- const int x_out_max = wrk->dst_width * wrk->num_channels;
- const rescaler_t* const frow = wrk->frow;
- const uint32_t yscale = wrk->fy_scale * (-wrk->y_accum);
- assert(!WebPRescalerOutputDone(wrk));
- assert(wrk->y_accum <= 0);
- assert(!wrk->y_expand);
- if (yscale) {
- for (x_out = 0; x_out < x_out_max; ++x_out) {
- const uint32_t frac = (uint32_t)MULT_FIX_FLOOR(frow[x_out], yscale);
- const int v = (int)MULT_FIX(irow[x_out] - frac, wrk->fxy_scale);
- dst[x_out] = (v > 255) ? 255u : (uint8_t)v;
- irow[x_out] = frac; // new fractional start
- }
- } else {
- for (x_out = 0; x_out < x_out_max; ++x_out) {
- const int v = (int)MULT_FIX(irow[x_out], wrk->fxy_scale);
- dst[x_out] = (v > 255) ? 255u : (uint8_t)v;
- irow[x_out] = 0;
- }
- }
-}
-
-#undef MULT_FIX_FLOOR
-#undef MULT_FIX
-#undef ROUNDER
-
-//------------------------------------------------------------------------------
-// Main entry calls
-
-void WebPRescalerImportRow(WebPRescaler* const wrk, const uint8_t* src) {
- assert(!WebPRescalerInputDone(wrk));
- if (!wrk->x_expand) {
- WebPRescalerImportRowShrink(wrk, src);
- } else {
- WebPRescalerImportRowExpand(wrk, src);
- }
-}
-
-void WebPRescalerExportRow(WebPRescaler* const wrk) {
- if (wrk->y_accum <= 0) {
- assert(!WebPRescalerOutputDone(wrk));
- if (wrk->y_expand) {
- WebPRescalerExportRowExpand(wrk);
- } else if (wrk->fxy_scale) {
- WebPRescalerExportRowShrink(wrk);
- } else { // special case
- int i;
- assert(wrk->src_height == wrk->dst_height && wrk->x_add == 1);
- assert(wrk->src_width == 1 && wrk->dst_width <= 2);
- for (i = 0; i < wrk->num_channels * wrk->dst_width; ++i) {
- wrk->dst[i] = wrk->irow[i];
- wrk->irow[i] = 0;
- }
- }
- wrk->y_accum += wrk->y_add;
- wrk->dst += wrk->dst_stride;
- ++wrk->dst_y;
- }
-}
-
-//------------------------------------------------------------------------------
-
-WebPRescalerImportRowFunc WebPRescalerImportRowExpand;
-WebPRescalerImportRowFunc WebPRescalerImportRowShrink;
-
-WebPRescalerExportRowFunc WebPRescalerExportRowExpand;
-WebPRescalerExportRowFunc WebPRescalerExportRowShrink;
-
-extern void WebPRescalerDspInitSSE2(void);
-extern void WebPRescalerDspInitMIPS32(void);
-extern void WebPRescalerDspInitMIPSdspR2(void);
-extern void WebPRescalerDspInitMSA(void);
-extern void WebPRescalerDspInitNEON(void);
-
-WEBP_DSP_INIT_FUNC(WebPRescalerDspInit) {
-#if !defined(WEBP_REDUCE_SIZE)
-#if !WEBP_NEON_OMIT_C_CODE
- WebPRescalerExportRowExpand = WebPRescalerExportRowExpand_C;
- WebPRescalerExportRowShrink = WebPRescalerExportRowShrink_C;
-#endif
-
- WebPRescalerImportRowExpand = WebPRescalerImportRowExpand_C;
- WebPRescalerImportRowShrink = WebPRescalerImportRowShrink_C;
-
- if (VP8GetCPUInfo != NULL) {
-#if defined(WEBP_HAVE_SSE2)
- if (VP8GetCPUInfo(kSSE2)) {
- WebPRescalerDspInitSSE2();
- }
-#endif
-#if defined(WEBP_USE_MIPS32)
- if (VP8GetCPUInfo(kMIPS32)) {
- WebPRescalerDspInitMIPS32();
- }
-#endif
-#if defined(WEBP_USE_MIPS_DSP_R2)
- if (VP8GetCPUInfo(kMIPSdspR2)) {
- WebPRescalerDspInitMIPSdspR2();
- }
-#endif
-#if defined(WEBP_USE_MSA)
- if (VP8GetCPUInfo(kMSA)) {
- WebPRescalerDspInitMSA();
- }
-#endif
- }
-
-#if defined(WEBP_HAVE_NEON)
- if (WEBP_NEON_OMIT_C_CODE ||
- (VP8GetCPUInfo != NULL && VP8GetCPUInfo(kNEON))) {
- WebPRescalerDspInitNEON();
- }
-#endif
-
- assert(WebPRescalerExportRowExpand != NULL);
- assert(WebPRescalerExportRowShrink != NULL);
- assert(WebPRescalerImportRowExpand != NULL);
- assert(WebPRescalerImportRowShrink != NULL);
-#endif // WEBP_REDUCE_SIZE
-}
diff --git a/contrib/libs/libwebp/dsp/rescaler_mips32.c b/contrib/libs/libwebp/dsp/rescaler_mips32.c
deleted file mode 100644
index 4c749faf59..0000000000
--- a/contrib/libs/libwebp/dsp/rescaler_mips32.c
+++ /dev/null
@@ -1,295 +0,0 @@
-// Copyright 2014 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// MIPS version of rescaling functions
-//
-// Author(s): Djordje Pesut (djordje.pesut@imgtec.com)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_MIPS32) && !defined(WEBP_REDUCE_SIZE)
-
-#include <assert.h>
-#include "../utils/rescaler_utils.h"
-
-//------------------------------------------------------------------------------
-// Row import
-
-static void ImportRowShrink_MIPS32(WebPRescaler* const wrk,
- const uint8_t* src) {
- const int x_stride = wrk->num_channels;
- const int x_out_max = wrk->dst_width * wrk->num_channels;
- const int fx_scale = wrk->fx_scale;
- const int x_add = wrk->x_add;
- const int x_sub = wrk->x_sub;
- const int x_stride1 = x_stride << 2;
- int channel;
- assert(!wrk->x_expand);
- assert(!WebPRescalerInputDone(wrk));
-
- for (channel = 0; channel < x_stride; ++channel) {
- const uint8_t* src1 = src + channel;
- rescaler_t* frow = wrk->frow + channel;
- int temp1, temp2, temp3;
- int base, frac, sum;
- int accum, accum1;
- int loop_c = x_out_max - channel;
-
- __asm__ volatile (
- "li %[temp1], 0x8000 \n\t"
- "li %[temp2], 0x10000 \n\t"
- "li %[sum], 0 \n\t"
- "li %[accum], 0 \n\t"
- "1: \n\t"
- "addu %[accum], %[accum], %[x_add] \n\t"
- "li %[base], 0 \n\t"
- "blez %[accum], 3f \n\t"
- "2: \n\t"
- "lbu %[base], 0(%[src1]) \n\t"
- "subu %[accum], %[accum], %[x_sub] \n\t"
- "addu %[src1], %[src1], %[x_stride] \n\t"
- "addu %[sum], %[sum], %[base] \n\t"
- "bgtz %[accum], 2b \n\t"
- "3: \n\t"
- "negu %[accum1], %[accum] \n\t"
- "mul %[frac], %[base], %[accum1] \n\t"
- "mul %[temp3], %[sum], %[x_sub] \n\t"
- "subu %[loop_c], %[loop_c], %[x_stride] \n\t"
- "mult %[temp1], %[temp2] \n\t"
- "maddu %[frac], %[fx_scale] \n\t"
- "mfhi %[sum] \n\t"
- "subu %[temp3], %[temp3], %[frac] \n\t"
- "sw %[temp3], 0(%[frow]) \n\t"
- "addu %[frow], %[frow], %[x_stride1] \n\t"
- "bgtz %[loop_c], 1b \n\t"
- : [accum]"=&r"(accum), [src1]"+r"(src1), [temp3]"=&r"(temp3),
- [sum]"=&r"(sum), [base]"=&r"(base), [frac]"=&r"(frac),
- [frow]"+r"(frow), [accum1]"=&r"(accum1),
- [temp2]"=&r"(temp2), [temp1]"=&r"(temp1)
- : [x_stride]"r"(x_stride), [fx_scale]"r"(fx_scale),
- [x_sub]"r"(x_sub), [x_add]"r"(x_add),
- [loop_c]"r"(loop_c), [x_stride1]"r"(x_stride1)
- : "memory", "hi", "lo"
- );
- assert(accum == 0);
- }
-}
-
-static void ImportRowExpand_MIPS32(WebPRescaler* const wrk,
- const uint8_t* src) {
- const int x_stride = wrk->num_channels;
- const int x_out_max = wrk->dst_width * wrk->num_channels;
- const int x_add = wrk->x_add;
- const int x_sub = wrk->x_sub;
- const int src_width = wrk->src_width;
- const int x_stride1 = x_stride << 2;
- int channel;
- assert(wrk->x_expand);
- assert(!WebPRescalerInputDone(wrk));
-
- for (channel = 0; channel < x_stride; ++channel) {
- const uint8_t* src1 = src + channel;
- rescaler_t* frow = wrk->frow + channel;
- int temp1, temp2, temp3, temp4;
- int frac;
- int accum;
- int x_out = channel;
-
- __asm__ volatile (
- "addiu %[temp3], %[src_width], -1 \n\t"
- "lbu %[temp2], 0(%[src1]) \n\t"
- "addu %[src1], %[src1], %[x_stride] \n\t"
- "bgtz %[temp3], 0f \n\t"
- "addiu %[temp1], %[temp2], 0 \n\t"
- "b 3f \n\t"
- "0: \n\t"
- "lbu %[temp1], 0(%[src1]) \n\t"
- "3: \n\t"
- "addiu %[accum], %[x_add], 0 \n\t"
- "1: \n\t"
- "subu %[temp3], %[temp2], %[temp1] \n\t"
- "mul %[temp3], %[temp3], %[accum] \n\t"
- "mul %[temp4], %[temp1], %[x_add] \n\t"
- "addu %[temp3], %[temp4], %[temp3] \n\t"
- "sw %[temp3], 0(%[frow]) \n\t"
- "addu %[frow], %[frow], %[x_stride1] \n\t"
- "addu %[x_out], %[x_out], %[x_stride] \n\t"
- "subu %[temp3], %[x_out], %[x_out_max] \n\t"
- "bgez %[temp3], 2f \n\t"
- "subu %[accum], %[accum], %[x_sub] \n\t"
- "bgez %[accum], 4f \n\t"
- "addiu %[temp2], %[temp1], 0 \n\t"
- "addu %[src1], %[src1], %[x_stride] \n\t"
- "lbu %[temp1], 0(%[src1]) \n\t"
- "addu %[accum], %[accum], %[x_add] \n\t"
- "4: \n\t"
- "b 1b \n\t"
- "2: \n\t"
- : [src1]"+r"(src1), [accum]"=&r"(accum), [temp1]"=&r"(temp1),
- [temp2]"=&r"(temp2), [temp3]"=&r"(temp3), [temp4]"=&r"(temp4),
- [x_out]"+r"(x_out), [frac]"=&r"(frac), [frow]"+r"(frow)
- : [x_stride]"r"(x_stride), [x_add]"r"(x_add), [x_sub]"r"(x_sub),
- [x_stride1]"r"(x_stride1), [src_width]"r"(src_width),
- [x_out_max]"r"(x_out_max)
- : "memory", "hi", "lo"
- );
- assert(wrk->x_sub == 0 /* <- special case for src_width=1 */ || accum == 0);
- }
-}
-
-//------------------------------------------------------------------------------
-// Row export
-
-static void ExportRowExpand_MIPS32(WebPRescaler* const wrk) {
- uint8_t* dst = wrk->dst;
- rescaler_t* irow = wrk->irow;
- const int x_out_max = wrk->dst_width * wrk->num_channels;
- const rescaler_t* frow = wrk->frow;
- int temp0, temp1, temp3, temp4, temp5, loop_end;
- const int temp2 = (int)wrk->fy_scale;
- const int temp6 = x_out_max << 2;
- assert(!WebPRescalerOutputDone(wrk));
- assert(wrk->y_accum <= 0);
- assert(wrk->y_expand);
- assert(wrk->y_sub != 0);
- if (wrk->y_accum == 0) {
- __asm__ volatile (
- "li %[temp3], 0x10000 \n\t"
- "li %[temp4], 0x8000 \n\t"
- "addu %[loop_end], %[frow], %[temp6] \n\t"
- "1: \n\t"
- "lw %[temp0], 0(%[frow]) \n\t"
- "addiu %[dst], %[dst], 1 \n\t"
- "addiu %[frow], %[frow], 4 \n\t"
- "mult %[temp3], %[temp4] \n\t"
- "maddu %[temp0], %[temp2] \n\t"
- "mfhi %[temp5] \n\t"
- "sb %[temp5], -1(%[dst]) \n\t"
- "bne %[frow], %[loop_end], 1b \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp3]"=&r"(temp3),
- [temp4]"=&r"(temp4), [temp5]"=&r"(temp5), [frow]"+r"(frow),
- [dst]"+r"(dst), [loop_end]"=&r"(loop_end)
- : [temp2]"r"(temp2), [temp6]"r"(temp6)
- : "memory", "hi", "lo"
- );
- } else {
- const uint32_t B = WEBP_RESCALER_FRAC(-wrk->y_accum, wrk->y_sub);
- const uint32_t A = (uint32_t)(WEBP_RESCALER_ONE - B);
- __asm__ volatile (
- "li %[temp3], 0x10000 \n\t"
- "li %[temp4], 0x8000 \n\t"
- "addu %[loop_end], %[frow], %[temp6] \n\t"
- "1: \n\t"
- "lw %[temp0], 0(%[frow]) \n\t"
- "lw %[temp1], 0(%[irow]) \n\t"
- "addiu %[dst], %[dst], 1 \n\t"
- "mult %[temp3], %[temp4] \n\t"
- "maddu %[A], %[temp0] \n\t"
- "maddu %[B], %[temp1] \n\t"
- "addiu %[frow], %[frow], 4 \n\t"
- "addiu %[irow], %[irow], 4 \n\t"
- "mfhi %[temp5] \n\t"
- "mult %[temp3], %[temp4] \n\t"
- "maddu %[temp5], %[temp2] \n\t"
- "mfhi %[temp5] \n\t"
- "sb %[temp5], -1(%[dst]) \n\t"
- "bne %[frow], %[loop_end], 1b \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp3]"=&r"(temp3),
- [temp4]"=&r"(temp4), [temp5]"=&r"(temp5), [frow]"+r"(frow),
- [irow]"+r"(irow), [dst]"+r"(dst), [loop_end]"=&r"(loop_end)
- : [temp2]"r"(temp2), [temp6]"r"(temp6), [A]"r"(A), [B]"r"(B)
- : "memory", "hi", "lo"
- );
- }
-}
-
-#if 0 // disabled for now. TODO(skal): make match the C-code
-static void ExportRowShrink_MIPS32(WebPRescaler* const wrk) {
- const int x_out_max = wrk->dst_width * wrk->num_channels;
- uint8_t* dst = wrk->dst;
- rescaler_t* irow = wrk->irow;
- const rescaler_t* frow = wrk->frow;
- const int yscale = wrk->fy_scale * (-wrk->y_accum);
- int temp0, temp1, temp3, temp4, temp5, loop_end;
- const int temp2 = (int)wrk->fxy_scale;
- const int temp6 = x_out_max << 2;
-
- assert(!WebPRescalerOutputDone(wrk));
- assert(wrk->y_accum <= 0);
- assert(!wrk->y_expand);
- assert(wrk->fxy_scale != 0);
- if (yscale) {
- __asm__ volatile (
- "li %[temp3], 0x10000 \n\t"
- "li %[temp4], 0x8000 \n\t"
- "addu %[loop_end], %[frow], %[temp6] \n\t"
- "1: \n\t"
- "lw %[temp0], 0(%[frow]) \n\t"
- "mult %[temp3], %[temp4] \n\t"
- "addiu %[frow], %[frow], 4 \n\t"
- "maddu %[temp0], %[yscale] \n\t"
- "mfhi %[temp1] \n\t"
- "lw %[temp0], 0(%[irow]) \n\t"
- "addiu %[dst], %[dst], 1 \n\t"
- "addiu %[irow], %[irow], 4 \n\t"
- "subu %[temp0], %[temp0], %[temp1] \n\t"
- "mult %[temp3], %[temp4] \n\t"
- "maddu %[temp0], %[temp2] \n\t"
- "mfhi %[temp5] \n\t"
- "sw %[temp1], -4(%[irow]) \n\t"
- "sb %[temp5], -1(%[dst]) \n\t"
- "bne %[frow], %[loop_end], 1b \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp3]"=&r"(temp3),
- [temp4]"=&r"(temp4), [temp5]"=&r"(temp5), [frow]"+r"(frow),
- [irow]"+r"(irow), [dst]"+r"(dst), [loop_end]"=&r"(loop_end)
- : [temp2]"r"(temp2), [yscale]"r"(yscale), [temp6]"r"(temp6)
- : "memory", "hi", "lo"
- );
- } else {
- __asm__ volatile (
- "li %[temp3], 0x10000 \n\t"
- "li %[temp4], 0x8000 \n\t"
- "addu %[loop_end], %[irow], %[temp6] \n\t"
- "1: \n\t"
- "lw %[temp0], 0(%[irow]) \n\t"
- "addiu %[dst], %[dst], 1 \n\t"
- "addiu %[irow], %[irow], 4 \n\t"
- "mult %[temp3], %[temp4] \n\t"
- "maddu %[temp0], %[temp2] \n\t"
- "mfhi %[temp5] \n\t"
- "sw $zero, -4(%[irow]) \n\t"
- "sb %[temp5], -1(%[dst]) \n\t"
- "bne %[irow], %[loop_end], 1b \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp3]"=&r"(temp3),
- [temp4]"=&r"(temp4), [temp5]"=&r"(temp5), [irow]"+r"(irow),
- [dst]"+r"(dst), [loop_end]"=&r"(loop_end)
- : [temp2]"r"(temp2), [temp6]"r"(temp6)
- : "memory", "hi", "lo"
- );
- }
-}
-#endif // 0
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void WebPRescalerDspInitMIPS32(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void WebPRescalerDspInitMIPS32(void) {
- WebPRescalerImportRowExpand = ImportRowExpand_MIPS32;
- WebPRescalerImportRowShrink = ImportRowShrink_MIPS32;
- WebPRescalerExportRowExpand = ExportRowExpand_MIPS32;
-// WebPRescalerExportRowShrink = ExportRowShrink_MIPS32;
-}
-
-#else // !WEBP_USE_MIPS32
-
-WEBP_DSP_INIT_STUB(WebPRescalerDspInitMIPS32)
-
-#endif // WEBP_USE_MIPS32
diff --git a/contrib/libs/libwebp/dsp/rescaler_mips_dsp_r2.c b/contrib/libs/libwebp/dsp/rescaler_mips_dsp_r2.c
deleted file mode 100644
index 6b9e63f090..0000000000
--- a/contrib/libs/libwebp/dsp/rescaler_mips_dsp_r2.c
+++ /dev/null
@@ -1,314 +0,0 @@
-// Copyright 2014 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// MIPS version of rescaling functions
-//
-// Author(s): Djordje Pesut (djordje.pesut@imgtec.com)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_MIPS_DSP_R2) && !defined(WEBP_REDUCE_SIZE)
-
-#include <assert.h>
-#include "../utils/rescaler_utils.h"
-
-#define ROUNDER (WEBP_RESCALER_ONE >> 1)
-#define MULT_FIX(x, y) (((uint64_t)(x) * (y) + ROUNDER) >> WEBP_RESCALER_RFIX)
-#define MULT_FIX_FLOOR(x, y) (((uint64_t)(x) * (y)) >> WEBP_RESCALER_RFIX)
-
-//------------------------------------------------------------------------------
-// Row export
-
-#if 0 // disabled for now. TODO(skal): make match the C-code
-static void ExportRowShrink_MIPSdspR2(WebPRescaler* const wrk) {
- int i;
- const int x_out_max = wrk->dst_width * wrk->num_channels;
- uint8_t* dst = wrk->dst;
- rescaler_t* irow = wrk->irow;
- const rescaler_t* frow = wrk->frow;
- const int yscale = wrk->fy_scale * (-wrk->y_accum);
- int temp0, temp1, temp2, temp3, temp4, temp5, loop_end;
- const int temp7 = (int)wrk->fxy_scale;
- const int temp6 = (x_out_max & ~0x3) << 2;
- assert(!WebPRescalerOutputDone(wrk));
- assert(wrk->y_accum <= 0);
- assert(!wrk->y_expand);
- assert(wrk->fxy_scale != 0);
- if (yscale) {
- if (x_out_max >= 4) {
- int temp8, temp9, temp10, temp11;
- __asm__ volatile (
- "li %[temp3], 0x10000 \n\t"
- "li %[temp4], 0x8000 \n\t"
- "addu %[loop_end], %[frow], %[temp6] \n\t"
- "1: \n\t"
- "lw %[temp0], 0(%[frow]) \n\t"
- "lw %[temp1], 4(%[frow]) \n\t"
- "lw %[temp2], 8(%[frow]) \n\t"
- "lw %[temp5], 12(%[frow]) \n\t"
- "mult $ac0, %[temp3], %[temp4] \n\t"
- "maddu $ac0, %[temp0], %[yscale] \n\t"
- "mult $ac1, %[temp3], %[temp4] \n\t"
- "maddu $ac1, %[temp1], %[yscale] \n\t"
- "mult $ac2, %[temp3], %[temp4] \n\t"
- "maddu $ac2, %[temp2], %[yscale] \n\t"
- "mult $ac3, %[temp3], %[temp4] \n\t"
- "maddu $ac3, %[temp5], %[yscale] \n\t"
- "addiu %[frow], %[frow], 16 \n\t"
- "mfhi %[temp0], $ac0 \n\t"
- "mfhi %[temp1], $ac1 \n\t"
- "mfhi %[temp2], $ac2 \n\t"
- "mfhi %[temp5], $ac3 \n\t"
- "lw %[temp8], 0(%[irow]) \n\t"
- "lw %[temp9], 4(%[irow]) \n\t"
- "lw %[temp10], 8(%[irow]) \n\t"
- "lw %[temp11], 12(%[irow]) \n\t"
- "addiu %[dst], %[dst], 4 \n\t"
- "addiu %[irow], %[irow], 16 \n\t"
- "subu %[temp8], %[temp8], %[temp0] \n\t"
- "subu %[temp9], %[temp9], %[temp1] \n\t"
- "subu %[temp10], %[temp10], %[temp2] \n\t"
- "subu %[temp11], %[temp11], %[temp5] \n\t"
- "mult $ac0, %[temp3], %[temp4] \n\t"
- "maddu $ac0, %[temp8], %[temp7] \n\t"
- "mult $ac1, %[temp3], %[temp4] \n\t"
- "maddu $ac1, %[temp9], %[temp7] \n\t"
- "mult $ac2, %[temp3], %[temp4] \n\t"
- "maddu $ac2, %[temp10], %[temp7] \n\t"
- "mult $ac3, %[temp3], %[temp4] \n\t"
- "maddu $ac3, %[temp11], %[temp7] \n\t"
- "mfhi %[temp8], $ac0 \n\t"
- "mfhi %[temp9], $ac1 \n\t"
- "mfhi %[temp10], $ac2 \n\t"
- "mfhi %[temp11], $ac3 \n\t"
- "sw %[temp0], -16(%[irow]) \n\t"
- "sw %[temp1], -12(%[irow]) \n\t"
- "sw %[temp2], -8(%[irow]) \n\t"
- "sw %[temp5], -4(%[irow]) \n\t"
- "sb %[temp8], -4(%[dst]) \n\t"
- "sb %[temp9], -3(%[dst]) \n\t"
- "sb %[temp10], -2(%[dst]) \n\t"
- "sb %[temp11], -1(%[dst]) \n\t"
- "bne %[frow], %[loop_end], 1b \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp3]"=&r"(temp3),
- [temp4]"=&r"(temp4), [temp5]"=&r"(temp5), [frow]"+r"(frow),
- [irow]"+r"(irow), [dst]"+r"(dst), [loop_end]"=&r"(loop_end),
- [temp8]"=&r"(temp8), [temp9]"=&r"(temp9), [temp10]"=&r"(temp10),
- [temp11]"=&r"(temp11), [temp2]"=&r"(temp2)
- : [temp7]"r"(temp7), [yscale]"r"(yscale), [temp6]"r"(temp6)
- : "memory", "hi", "lo", "$ac1hi", "$ac1lo",
- "$ac2hi", "$ac2lo", "$ac3hi", "$ac3lo"
- );
- }
- for (i = 0; i < (x_out_max & 0x3); ++i) {
- const uint32_t frac = (uint32_t)MULT_FIX_FLOOR(*frow++, yscale);
- const int v = (int)MULT_FIX(*irow - frac, wrk->fxy_scale);
- *dst++ = (v > 255) ? 255u : (uint8_t)v;
- *irow++ = frac; // new fractional start
- }
- } else {
- if (x_out_max >= 4) {
- __asm__ volatile (
- "li %[temp3], 0x10000 \n\t"
- "li %[temp4], 0x8000 \n\t"
- "addu %[loop_end], %[irow], %[temp6] \n\t"
- "1: \n\t"
- "lw %[temp0], 0(%[irow]) \n\t"
- "lw %[temp1], 4(%[irow]) \n\t"
- "lw %[temp2], 8(%[irow]) \n\t"
- "lw %[temp5], 12(%[irow]) \n\t"
- "addiu %[dst], %[dst], 4 \n\t"
- "addiu %[irow], %[irow], 16 \n\t"
- "mult $ac0, %[temp3], %[temp4] \n\t"
- "maddu $ac0, %[temp0], %[temp7] \n\t"
- "mult $ac1, %[temp3], %[temp4] \n\t"
- "maddu $ac1, %[temp1], %[temp7] \n\t"
- "mult $ac2, %[temp3], %[temp4] \n\t"
- "maddu $ac2, %[temp2], %[temp7] \n\t"
- "mult $ac3, %[temp3], %[temp4] \n\t"
- "maddu $ac3, %[temp5], %[temp7] \n\t"
- "mfhi %[temp0], $ac0 \n\t"
- "mfhi %[temp1], $ac1 \n\t"
- "mfhi %[temp2], $ac2 \n\t"
- "mfhi %[temp5], $ac3 \n\t"
- "sw $zero, -16(%[irow]) \n\t"
- "sw $zero, -12(%[irow]) \n\t"
- "sw $zero, -8(%[irow]) \n\t"
- "sw $zero, -4(%[irow]) \n\t"
- "sb %[temp0], -4(%[dst]) \n\t"
- "sb %[temp1], -3(%[dst]) \n\t"
- "sb %[temp2], -2(%[dst]) \n\t"
- "sb %[temp5], -1(%[dst]) \n\t"
- "bne %[irow], %[loop_end], 1b \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp3]"=&r"(temp3),
- [temp4]"=&r"(temp4), [temp5]"=&r"(temp5), [irow]"+r"(irow),
- [dst]"+r"(dst), [loop_end]"=&r"(loop_end), [temp2]"=&r"(temp2)
- : [temp7]"r"(temp7), [temp6]"r"(temp6)
- : "memory", "hi", "lo", "$ac1hi", "$ac1lo",
- "$ac2hi", "$ac2lo", "$ac3hi", "$ac3lo"
- );
- }
- for (i = 0; i < (x_out_max & 0x3); ++i) {
- const int v = (int)MULT_FIX_FLOOR(*irow, wrk->fxy_scale);
- *dst++ = (v > 255) ? 255u : (uint8_t)v;
- *irow++ = 0;
- }
- }
-}
-#endif // 0
-
-static void ExportRowExpand_MIPSdspR2(WebPRescaler* const wrk) {
- int i;
- uint8_t* dst = wrk->dst;
- rescaler_t* irow = wrk->irow;
- const int x_out_max = wrk->dst_width * wrk->num_channels;
- const rescaler_t* frow = wrk->frow;
- int temp0, temp1, temp2, temp3, temp4, temp5, loop_end;
- const int temp6 = (x_out_max & ~0x3) << 2;
- const int temp7 = (int)wrk->fy_scale;
- assert(!WebPRescalerOutputDone(wrk));
- assert(wrk->y_accum <= 0);
- assert(wrk->y_expand);
- assert(wrk->y_sub != 0);
- if (wrk->y_accum == 0) {
- if (x_out_max >= 4) {
- __asm__ volatile (
- "li %[temp4], 0x10000 \n\t"
- "li %[temp5], 0x8000 \n\t"
- "addu %[loop_end], %[frow], %[temp6] \n\t"
- "1: \n\t"
- "lw %[temp0], 0(%[frow]) \n\t"
- "lw %[temp1], 4(%[frow]) \n\t"
- "lw %[temp2], 8(%[frow]) \n\t"
- "lw %[temp3], 12(%[frow]) \n\t"
- "addiu %[dst], %[dst], 4 \n\t"
- "addiu %[frow], %[frow], 16 \n\t"
- "mult $ac0, %[temp4], %[temp5] \n\t"
- "maddu $ac0, %[temp0], %[temp7] \n\t"
- "mult $ac1, %[temp4], %[temp5] \n\t"
- "maddu $ac1, %[temp1], %[temp7] \n\t"
- "mult $ac2, %[temp4], %[temp5] \n\t"
- "maddu $ac2, %[temp2], %[temp7] \n\t"
- "mult $ac3, %[temp4], %[temp5] \n\t"
- "maddu $ac3, %[temp3], %[temp7] \n\t"
- "mfhi %[temp0], $ac0 \n\t"
- "mfhi %[temp1], $ac1 \n\t"
- "mfhi %[temp2], $ac2 \n\t"
- "mfhi %[temp3], $ac3 \n\t"
- "sb %[temp0], -4(%[dst]) \n\t"
- "sb %[temp1], -3(%[dst]) \n\t"
- "sb %[temp2], -2(%[dst]) \n\t"
- "sb %[temp3], -1(%[dst]) \n\t"
- "bne %[frow], %[loop_end], 1b \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp3]"=&r"(temp3),
- [temp4]"=&r"(temp4), [temp5]"=&r"(temp5), [frow]"+r"(frow),
- [dst]"+r"(dst), [loop_end]"=&r"(loop_end), [temp2]"=&r"(temp2)
- : [temp7]"r"(temp7), [temp6]"r"(temp6)
- : "memory", "hi", "lo", "$ac1hi", "$ac1lo",
- "$ac2hi", "$ac2lo", "$ac3hi", "$ac3lo"
- );
- }
- for (i = 0; i < (x_out_max & 0x3); ++i) {
- const uint32_t J = *frow++;
- const int v = (int)MULT_FIX(J, wrk->fy_scale);
- *dst++ = (v > 255) ? 255u : (uint8_t)v;
- }
- } else {
- const uint32_t B = WEBP_RESCALER_FRAC(-wrk->y_accum, wrk->y_sub);
- const uint32_t A = (uint32_t)(WEBP_RESCALER_ONE - B);
- if (x_out_max >= 4) {
- int temp8, temp9, temp10, temp11;
- __asm__ volatile (
- "li %[temp8], 0x10000 \n\t"
- "li %[temp9], 0x8000 \n\t"
- "addu %[loop_end], %[frow], %[temp6] \n\t"
- "1: \n\t"
- "lw %[temp0], 0(%[frow]) \n\t"
- "lw %[temp1], 4(%[frow]) \n\t"
- "lw %[temp2], 8(%[frow]) \n\t"
- "lw %[temp3], 12(%[frow]) \n\t"
- "lw %[temp4], 0(%[irow]) \n\t"
- "lw %[temp5], 4(%[irow]) \n\t"
- "lw %[temp10], 8(%[irow]) \n\t"
- "lw %[temp11], 12(%[irow]) \n\t"
- "addiu %[dst], %[dst], 4 \n\t"
- "mult $ac0, %[temp8], %[temp9] \n\t"
- "maddu $ac0, %[A], %[temp0] \n\t"
- "maddu $ac0, %[B], %[temp4] \n\t"
- "mult $ac1, %[temp8], %[temp9] \n\t"
- "maddu $ac1, %[A], %[temp1] \n\t"
- "maddu $ac1, %[B], %[temp5] \n\t"
- "mult $ac2, %[temp8], %[temp9] \n\t"
- "maddu $ac2, %[A], %[temp2] \n\t"
- "maddu $ac2, %[B], %[temp10] \n\t"
- "mult $ac3, %[temp8], %[temp9] \n\t"
- "maddu $ac3, %[A], %[temp3] \n\t"
- "maddu $ac3, %[B], %[temp11] \n\t"
- "addiu %[frow], %[frow], 16 \n\t"
- "addiu %[irow], %[irow], 16 \n\t"
- "mfhi %[temp0], $ac0 \n\t"
- "mfhi %[temp1], $ac1 \n\t"
- "mfhi %[temp2], $ac2 \n\t"
- "mfhi %[temp3], $ac3 \n\t"
- "mult $ac0, %[temp8], %[temp9] \n\t"
- "maddu $ac0, %[temp0], %[temp7] \n\t"
- "mult $ac1, %[temp8], %[temp9] \n\t"
- "maddu $ac1, %[temp1], %[temp7] \n\t"
- "mult $ac2, %[temp8], %[temp9] \n\t"
- "maddu $ac2, %[temp2], %[temp7] \n\t"
- "mult $ac3, %[temp8], %[temp9] \n\t"
- "maddu $ac3, %[temp3], %[temp7] \n\t"
- "mfhi %[temp0], $ac0 \n\t"
- "mfhi %[temp1], $ac1 \n\t"
- "mfhi %[temp2], $ac2 \n\t"
- "mfhi %[temp3], $ac3 \n\t"
- "sb %[temp0], -4(%[dst]) \n\t"
- "sb %[temp1], -3(%[dst]) \n\t"
- "sb %[temp2], -2(%[dst]) \n\t"
- "sb %[temp3], -1(%[dst]) \n\t"
- "bne %[frow], %[loop_end], 1b \n\t"
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp3]"=&r"(temp3),
- [temp4]"=&r"(temp4), [temp5]"=&r"(temp5), [frow]"+r"(frow),
- [irow]"+r"(irow), [dst]"+r"(dst), [loop_end]"=&r"(loop_end),
- [temp8]"=&r"(temp8), [temp9]"=&r"(temp9), [temp10]"=&r"(temp10),
- [temp11]"=&r"(temp11), [temp2]"=&r"(temp2)
- : [temp7]"r"(temp7), [temp6]"r"(temp6), [A]"r"(A), [B]"r"(B)
- : "memory", "hi", "lo", "$ac1hi", "$ac1lo",
- "$ac2hi", "$ac2lo", "$ac3hi", "$ac3lo"
- );
- }
- for (i = 0; i < (x_out_max & 0x3); ++i) {
- const uint64_t I = (uint64_t)A * *frow++
- + (uint64_t)B * *irow++;
- const uint32_t J = (uint32_t)((I + ROUNDER) >> WEBP_RESCALER_RFIX);
- const int v = (int)MULT_FIX(J, wrk->fy_scale);
- *dst++ = (v > 255) ? 255u : (uint8_t)v;
- }
- }
-}
-
-#undef MULT_FIX_FLOOR
-#undef MULT_FIX
-#undef ROUNDER
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void WebPRescalerDspInitMIPSdspR2(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void WebPRescalerDspInitMIPSdspR2(void) {
- WebPRescalerExportRowExpand = ExportRowExpand_MIPSdspR2;
-// WebPRescalerExportRowShrink = ExportRowShrink_MIPSdspR2;
-}
-
-#else // !WEBP_USE_MIPS_DSP_R2
-
-WEBP_DSP_INIT_STUB(WebPRescalerDspInitMIPSdspR2)
-
-#endif // WEBP_USE_MIPS_DSP_R2
diff --git a/contrib/libs/libwebp/dsp/rescaler_msa.c b/contrib/libs/libwebp/dsp/rescaler_msa.c
deleted file mode 100644
index af01ee6e40..0000000000
--- a/contrib/libs/libwebp/dsp/rescaler_msa.c
+++ /dev/null
@@ -1,443 +0,0 @@
-// Copyright 2016 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// MSA version of rescaling functions
-//
-// Author: Prashant Patil (prashant.patil@imgtec.com)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_MSA) && !defined(WEBP_REDUCE_SIZE)
-
-#include <assert.h>
-
-#include "../utils/rescaler_utils.h"
-#include "./msa_macro.h"
-
-#define ROUNDER (WEBP_RESCALER_ONE >> 1)
-#define MULT_FIX(x, y) (((uint64_t)(x) * (y) + ROUNDER) >> WEBP_RESCALER_RFIX)
-#define MULT_FIX_FLOOR(x, y) (((uint64_t)(x) * (y)) >> WEBP_RESCALER_RFIX)
-
-#define CALC_MULT_FIX_16(in0, in1, in2, in3, scale, shift, dst) do { \
- v4u32 tmp0, tmp1, tmp2, tmp3; \
- v16u8 t0, t1, t2, t3, t4, t5; \
- v2u64 out0, out1, out2, out3; \
- ILVRL_W2_UW(zero, in0, tmp0, tmp1); \
- ILVRL_W2_UW(zero, in1, tmp2, tmp3); \
- DOTP_UW2_UD(tmp0, tmp1, scale, scale, out0, out1); \
- DOTP_UW2_UD(tmp2, tmp3, scale, scale, out2, out3); \
- SRAR_D4_UD(out0, out1, out2, out3, shift); \
- PCKEV_B2_UB(out1, out0, out3, out2, t0, t1); \
- ILVRL_W2_UW(zero, in2, tmp0, tmp1); \
- ILVRL_W2_UW(zero, in3, tmp2, tmp3); \
- DOTP_UW2_UD(tmp0, tmp1, scale, scale, out0, out1); \
- DOTP_UW2_UD(tmp2, tmp3, scale, scale, out2, out3); \
- SRAR_D4_UD(out0, out1, out2, out3, shift); \
- PCKEV_B2_UB(out1, out0, out3, out2, t2, t3); \
- PCKEV_B2_UB(t1, t0, t3, t2, t4, t5); \
- dst = (v16u8)__msa_pckev_b((v16i8)t5, (v16i8)t4); \
-} while (0)
-
-#define CALC_MULT_FIX_4(in0, scale, shift, dst) do { \
- v4u32 tmp0, tmp1; \
- v16i8 t0, t1; \
- v2u64 out0, out1; \
- ILVRL_W2_UW(zero, in0, tmp0, tmp1); \
- DOTP_UW2_UD(tmp0, tmp1, scale, scale, out0, out1); \
- SRAR_D2_UD(out0, out1, shift); \
- t0 = __msa_pckev_b((v16i8)out1, (v16i8)out0); \
- t1 = __msa_pckev_b(t0, t0); \
- t0 = __msa_pckev_b(t1, t1); \
- dst = __msa_copy_s_w((v4i32)t0, 0); \
-} while (0)
-
-#define CALC_MULT_FIX1_16(in0, in1, in2, in3, fyscale, shift, \
- dst0, dst1, dst2, dst3) do { \
- v4u32 tmp0, tmp1, tmp2, tmp3; \
- v2u64 out0, out1, out2, out3; \
- ILVRL_W2_UW(zero, in0, tmp0, tmp1); \
- ILVRL_W2_UW(zero, in1, tmp2, tmp3); \
- DOTP_UW2_UD(tmp0, tmp1, fyscale, fyscale, out0, out1); \
- DOTP_UW2_UD(tmp2, tmp3, fyscale, fyscale, out2, out3); \
- SRAR_D4_UD(out0, out1, out2, out3, shift); \
- PCKEV_W2_UW(out1, out0, out3, out2, dst0, dst1); \
- ILVRL_W2_UW(zero, in2, tmp0, tmp1); \
- ILVRL_W2_UW(zero, in3, tmp2, tmp3); \
- DOTP_UW2_UD(tmp0, tmp1, fyscale, fyscale, out0, out1); \
- DOTP_UW2_UD(tmp2, tmp3, fyscale, fyscale, out2, out3); \
- SRAR_D4_UD(out0, out1, out2, out3, shift); \
- PCKEV_W2_UW(out1, out0, out3, out2, dst2, dst3); \
-} while (0)
-
-#define CALC_MULT_FIX1_4(in0, scale, shift, dst) do { \
- v4u32 tmp0, tmp1; \
- v2u64 out0, out1; \
- ILVRL_W2_UW(zero, in0, tmp0, tmp1); \
- DOTP_UW2_UD(tmp0, tmp1, scale, scale, out0, out1); \
- SRAR_D2_UD(out0, out1, shift); \
- dst = (v4u32)__msa_pckev_w((v4i32)out1, (v4i32)out0); \
-} while (0)
-
-#define CALC_MULT_FIX2_16(in0, in1, in2, in3, mult, scale, shift, \
- dst0, dst1) do { \
- v4u32 tmp0, tmp1, tmp2, tmp3; \
- v2u64 out0, out1, out2, out3; \
- ILVRL_W2_UW(in0, in2, tmp0, tmp1); \
- ILVRL_W2_UW(in1, in3, tmp2, tmp3); \
- DOTP_UW2_UD(tmp0, tmp1, mult, mult, out0, out1); \
- DOTP_UW2_UD(tmp2, tmp3, mult, mult, out2, out3); \
- SRAR_D4_UD(out0, out1, out2, out3, shift); \
- DOTP_UW2_UD(out0, out1, scale, scale, out0, out1); \
- DOTP_UW2_UD(out2, out3, scale, scale, out2, out3); \
- SRAR_D4_UD(out0, out1, out2, out3, shift); \
- PCKEV_B2_UB(out1, out0, out3, out2, dst0, dst1); \
-} while (0)
-
-#define CALC_MULT_FIX2_4(in0, in1, mult, scale, shift, dst) do { \
- v4u32 tmp0, tmp1; \
- v2u64 out0, out1; \
- v16i8 t0, t1; \
- ILVRL_W2_UW(in0, in1, tmp0, tmp1); \
- DOTP_UW2_UD(tmp0, tmp1, mult, mult, out0, out1); \
- SRAR_D2_UD(out0, out1, shift); \
- DOTP_UW2_UD(out0, out1, scale, scale, out0, out1); \
- SRAR_D2_UD(out0, out1, shift); \
- t0 = __msa_pckev_b((v16i8)out1, (v16i8)out0); \
- t1 = __msa_pckev_b(t0, t0); \
- t0 = __msa_pckev_b(t1, t1); \
- dst = __msa_copy_s_w((v4i32)t0, 0); \
-} while (0)
-
-static WEBP_INLINE void ExportRowExpand_0(const uint32_t* frow, uint8_t* dst,
- int length,
- WebPRescaler* const wrk) {
- const v4u32 scale = (v4u32)__msa_fill_w(wrk->fy_scale);
- const v4u32 shift = (v4u32)__msa_fill_w(WEBP_RESCALER_RFIX);
- const v4i32 zero = { 0 };
-
- while (length >= 16) {
- v4u32 src0, src1, src2, src3;
- v16u8 out;
- LD_UW4(frow, 4, src0, src1, src2, src3);
- CALC_MULT_FIX_16(src0, src1, src2, src3, scale, shift, out);
- ST_UB(out, dst);
- length -= 16;
- frow += 16;
- dst += 16;
- }
- if (length > 0) {
- int x_out;
- if (length >= 12) {
- uint32_t val0_m, val1_m, val2_m;
- v4u32 src0, src1, src2;
- LD_UW3(frow, 4, src0, src1, src2);
- CALC_MULT_FIX_4(src0, scale, shift, val0_m);
- CALC_MULT_FIX_4(src1, scale, shift, val1_m);
- CALC_MULT_FIX_4(src2, scale, shift, val2_m);
- SW3(val0_m, val1_m, val2_m, dst, 4);
- length -= 12;
- frow += 12;
- dst += 12;
- } else if (length >= 8) {
- uint32_t val0_m, val1_m;
- v4u32 src0, src1;
- LD_UW2(frow, 4, src0, src1);
- CALC_MULT_FIX_4(src0, scale, shift, val0_m);
- CALC_MULT_FIX_4(src1, scale, shift, val1_m);
- SW2(val0_m, val1_m, dst, 4);
- length -= 8;
- frow += 8;
- dst += 8;
- } else if (length >= 4) {
- uint32_t val0_m;
- const v4u32 src0 = LD_UW(frow);
- CALC_MULT_FIX_4(src0, scale, shift, val0_m);
- SW(val0_m, dst);
- length -= 4;
- frow += 4;
- dst += 4;
- }
- for (x_out = 0; x_out < length; ++x_out) {
- const uint32_t J = frow[x_out];
- const int v = (int)MULT_FIX(J, wrk->fy_scale);
- dst[x_out] = (v > 255) ? 255u : (uint8_t)v;
- }
- }
-}
-
-static WEBP_INLINE void ExportRowExpand_1(const uint32_t* frow, uint32_t* irow,
- uint8_t* dst, int length,
- WebPRescaler* const wrk) {
- const uint32_t B = WEBP_RESCALER_FRAC(-wrk->y_accum, wrk->y_sub);
- const uint32_t A = (uint32_t)(WEBP_RESCALER_ONE - B);
- const v4i32 B1 = __msa_fill_w(B);
- const v4i32 A1 = __msa_fill_w(A);
- const v4i32 AB = __msa_ilvr_w(A1, B1);
- const v4u32 scale = (v4u32)__msa_fill_w(wrk->fy_scale);
- const v4u32 shift = (v4u32)__msa_fill_w(WEBP_RESCALER_RFIX);
-
- while (length >= 16) {
- v4u32 frow0, frow1, frow2, frow3, irow0, irow1, irow2, irow3;
- v16u8 t0, t1, t2, t3, t4, t5;
- LD_UW4(frow, 4, frow0, frow1, frow2, frow3);
- LD_UW4(irow, 4, irow0, irow1, irow2, irow3);
- CALC_MULT_FIX2_16(frow0, frow1, irow0, irow1, AB, scale, shift, t0, t1);
- CALC_MULT_FIX2_16(frow2, frow3, irow2, irow3, AB, scale, shift, t2, t3);
- PCKEV_B2_UB(t1, t0, t3, t2, t4, t5);
- t0 = (v16u8)__msa_pckev_b((v16i8)t5, (v16i8)t4);
- ST_UB(t0, dst);
- frow += 16;
- irow += 16;
- dst += 16;
- length -= 16;
- }
- if (length > 0) {
- int x_out;
- if (length >= 12) {
- uint32_t val0_m, val1_m, val2_m;
- v4u32 frow0, frow1, frow2, irow0, irow1, irow2;
- LD_UW3(frow, 4, frow0, frow1, frow2);
- LD_UW3(irow, 4, irow0, irow1, irow2);
- CALC_MULT_FIX2_4(frow0, irow0, AB, scale, shift, val0_m);
- CALC_MULT_FIX2_4(frow1, irow1, AB, scale, shift, val1_m);
- CALC_MULT_FIX2_4(frow2, irow2, AB, scale, shift, val2_m);
- SW3(val0_m, val1_m, val2_m, dst, 4);
- frow += 12;
- irow += 12;
- dst += 12;
- length -= 12;
- } else if (length >= 8) {
- uint32_t val0_m, val1_m;
- v4u32 frow0, frow1, irow0, irow1;
- LD_UW2(frow, 4, frow0, frow1);
- LD_UW2(irow, 4, irow0, irow1);
- CALC_MULT_FIX2_4(frow0, irow0, AB, scale, shift, val0_m);
- CALC_MULT_FIX2_4(frow1, irow1, AB, scale, shift, val1_m);
- SW2(val0_m, val1_m, dst, 4);
- frow += 4;
- irow += 4;
- dst += 4;
- length -= 4;
- } else if (length >= 4) {
- uint32_t val0_m;
- const v4u32 frow0 = LD_UW(frow + 0);
- const v4u32 irow0 = LD_UW(irow + 0);
- CALC_MULT_FIX2_4(frow0, irow0, AB, scale, shift, val0_m);
- SW(val0_m, dst);
- frow += 4;
- irow += 4;
- dst += 4;
- length -= 4;
- }
- for (x_out = 0; x_out < length; ++x_out) {
- const uint64_t I = (uint64_t)A * frow[x_out]
- + (uint64_t)B * irow[x_out];
- const uint32_t J = (uint32_t)((I + ROUNDER) >> WEBP_RESCALER_RFIX);
- const int v = (int)MULT_FIX(J, wrk->fy_scale);
- dst[x_out] = (v > 255) ? 255u : (uint8_t)v;
- }
- }
-}
-
-static void RescalerExportRowExpand_MIPSdspR2(WebPRescaler* const wrk) {
- uint8_t* dst = wrk->dst;
- rescaler_t* irow = wrk->irow;
- const int x_out_max = wrk->dst_width * wrk->num_channels;
- const rescaler_t* frow = wrk->frow;
- assert(!WebPRescalerOutputDone(wrk));
- assert(wrk->y_accum <= 0);
- assert(wrk->y_expand);
- assert(wrk->y_sub != 0);
- if (wrk->y_accum == 0) {
- ExportRowExpand_0(frow, dst, x_out_max, wrk);
- } else {
- ExportRowExpand_1(frow, irow, dst, x_out_max, wrk);
- }
-}
-
-#if 0 // disabled for now. TODO(skal): make match the C-code
-static WEBP_INLINE void ExportRowShrink_0(const uint32_t* frow, uint32_t* irow,
- uint8_t* dst, int length,
- const uint32_t yscale,
- WebPRescaler* const wrk) {
- const v4u32 y_scale = (v4u32)__msa_fill_w(yscale);
- const v4u32 fxyscale = (v4u32)__msa_fill_w(wrk->fxy_scale);
- const v4u32 shiftval = (v4u32)__msa_fill_w(WEBP_RESCALER_RFIX);
- const v4i32 zero = { 0 };
-
- while (length >= 16) {
- v4u32 src0, src1, src2, src3, frac0, frac1, frac2, frac3;
- v16u8 out;
- LD_UW4(frow, 4, src0, src1, src2, src3);
- CALC_MULT_FIX1_16(src0, src1, src2, src3, y_scale, shiftval,
- frac0, frac1, frac2, frac3);
- LD_UW4(irow, 4, src0, src1, src2, src3);
- SUB4(src0, frac0, src1, frac1, src2, frac2, src3, frac3,
- src0, src1, src2, src3);
- CALC_MULT_FIX_16(src0, src1, src2, src3, fxyscale, shiftval, out);
- ST_UB(out, dst);
- ST_UW4(frac0, frac1, frac2, frac3, irow, 4);
- frow += 16;
- irow += 16;
- dst += 16;
- length -= 16;
- }
- if (length > 0) {
- int x_out;
- if (length >= 12) {
- uint32_t val0_m, val1_m, val2_m;
- v4u32 src0, src1, src2, frac0, frac1, frac2;
- LD_UW3(frow, 4, src0, src1, src2);
- CALC_MULT_FIX1_4(src0, y_scale, shiftval, frac0);
- CALC_MULT_FIX1_4(src1, y_scale, shiftval, frac1);
- CALC_MULT_FIX1_4(src2, y_scale, shiftval, frac2);
- LD_UW3(irow, 4, src0, src1, src2);
- SUB3(src0, frac0, src1, frac1, src2, frac2, src0, src1, src2);
- CALC_MULT_FIX_4(src0, fxyscale, shiftval, val0_m);
- CALC_MULT_FIX_4(src1, fxyscale, shiftval, val1_m);
- CALC_MULT_FIX_4(src2, fxyscale, shiftval, val2_m);
- SW3(val0_m, val1_m, val2_m, dst, 4);
- ST_UW3(frac0, frac1, frac2, irow, 4);
- frow += 12;
- irow += 12;
- dst += 12;
- length -= 12;
- } else if (length >= 8) {
- uint32_t val0_m, val1_m;
- v4u32 src0, src1, frac0, frac1;
- LD_UW2(frow, 4, src0, src1);
- CALC_MULT_FIX1_4(src0, y_scale, shiftval, frac0);
- CALC_MULT_FIX1_4(src1, y_scale, shiftval, frac1);
- LD_UW2(irow, 4, src0, src1);
- SUB2(src0, frac0, src1, frac1, src0, src1);
- CALC_MULT_FIX_4(src0, fxyscale, shiftval, val0_m);
- CALC_MULT_FIX_4(src1, fxyscale, shiftval, val1_m);
- SW2(val0_m, val1_m, dst, 4);
- ST_UW2(frac0, frac1, irow, 4);
- frow += 8;
- irow += 8;
- dst += 8;
- length -= 8;
- } else if (length >= 4) {
- uint32_t val0_m;
- v4u32 frac0;
- v4u32 src0 = LD_UW(frow);
- CALC_MULT_FIX1_4(src0, y_scale, shiftval, frac0);
- src0 = LD_UW(irow);
- src0 = src0 - frac0;
- CALC_MULT_FIX_4(src0, fxyscale, shiftval, val0_m);
- SW(val0_m, dst);
- ST_UW(frac0, irow);
- frow += 4;
- irow += 4;
- dst += 4;
- length -= 4;
- }
- for (x_out = 0; x_out < length; ++x_out) {
- const uint32_t frac = (uint32_t)MULT_FIX_FLOOR(frow[x_out], yscale);
- const int v = (int)MULT_FIX(irow[x_out] - frac, wrk->fxy_scale);
- dst[x_out] = (v > 255) ? 255u : (uint8_t)v;
- irow[x_out] = frac;
- }
- }
-}
-
-static WEBP_INLINE void ExportRowShrink_1(uint32_t* irow, uint8_t* dst,
- int length,
- WebPRescaler* const wrk) {
- const v4u32 scale = (v4u32)__msa_fill_w(wrk->fxy_scale);
- const v4u32 shift = (v4u32)__msa_fill_w(WEBP_RESCALER_RFIX);
- const v4i32 zero = { 0 };
-
- while (length >= 16) {
- v4u32 src0, src1, src2, src3;
- v16u8 dst0;
- LD_UW4(irow, 4, src0, src1, src2, src3);
- CALC_MULT_FIX_16(src0, src1, src2, src3, scale, shift, dst0);
- ST_UB(dst0, dst);
- ST_SW4(zero, zero, zero, zero, irow, 4);
- length -= 16;
- irow += 16;
- dst += 16;
- }
- if (length > 0) {
- int x_out;
- if (length >= 12) {
- uint32_t val0_m, val1_m, val2_m;
- v4u32 src0, src1, src2;
- LD_UW3(irow, 4, src0, src1, src2);
- CALC_MULT_FIX_4(src0, scale, shift, val0_m);
- CALC_MULT_FIX_4(src1, scale, shift, val1_m);
- CALC_MULT_FIX_4(src2, scale, shift, val2_m);
- SW3(val0_m, val1_m, val2_m, dst, 4);
- ST_SW3(zero, zero, zero, irow, 4);
- length -= 12;
- irow += 12;
- dst += 12;
- } else if (length >= 8) {
- uint32_t val0_m, val1_m;
- v4u32 src0, src1;
- LD_UW2(irow, 4, src0, src1);
- CALC_MULT_FIX_4(src0, scale, shift, val0_m);
- CALC_MULT_FIX_4(src1, scale, shift, val1_m);
- SW2(val0_m, val1_m, dst, 4);
- ST_SW2(zero, zero, irow, 4);
- length -= 8;
- irow += 8;
- dst += 8;
- } else if (length >= 4) {
- uint32_t val0_m;
- const v4u32 src0 = LD_UW(irow + 0);
- CALC_MULT_FIX_4(src0, scale, shift, val0_m);
- SW(val0_m, dst);
- ST_SW(zero, irow);
- length -= 4;
- irow += 4;
- dst += 4;
- }
- for (x_out = 0; x_out < length; ++x_out) {
- const int v = (int)MULT_FIX(irow[x_out], wrk->fxy_scale);
- dst[x_out] = (v > 255) ? 255u : (uint8_t)v;
- irow[x_out] = 0;
- }
- }
-}
-
-static void RescalerExportRowShrink_MIPSdspR2(WebPRescaler* const wrk) {
- uint8_t* dst = wrk->dst;
- rescaler_t* irow = wrk->irow;
- const int x_out_max = wrk->dst_width * wrk->num_channels;
- const rescaler_t* frow = wrk->frow;
- const uint32_t yscale = wrk->fy_scale * (-wrk->y_accum);
- assert(!WebPRescalerOutputDone(wrk));
- assert(wrk->y_accum <= 0);
- assert(!wrk->y_expand);
- if (yscale) {
- ExportRowShrink_0(frow, irow, dst, x_out_max, yscale, wrk);
- } else {
- ExportRowShrink_1(irow, dst, x_out_max, wrk);
- }
-}
-#endif // 0
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void WebPRescalerDspInitMSA(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void WebPRescalerDspInitMSA(void) {
- WebPRescalerExportRowExpand = RescalerExportRowExpand_MIPSdspR2;
-// WebPRescalerExportRowShrink = RescalerExportRowShrink_MIPSdspR2;
-}
-
-#else // !WEBP_USE_MSA
-
-WEBP_DSP_INIT_STUB(WebPRescalerDspInitMSA)
-
-#endif // WEBP_USE_MSA
diff --git a/contrib/libs/libwebp/dsp/rescaler_neon.c b/contrib/libs/libwebp/dsp/rescaler_neon.c
deleted file mode 100644
index b85133b851..0000000000
--- a/contrib/libs/libwebp/dsp/rescaler_neon.c
+++ /dev/null
@@ -1,192 +0,0 @@
-// Copyright 2015 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// NEON version of rescaling functions
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_NEON) && !defined(WEBP_REDUCE_SIZE)
-
-#include <arm_neon.h>
-#include <assert.h>
-#include "./neon.h"
-#include "../utils/rescaler_utils.h"
-
-#define ROUNDER (WEBP_RESCALER_ONE >> 1)
-#define MULT_FIX_C(x, y) (((uint64_t)(x) * (y) + ROUNDER) >> WEBP_RESCALER_RFIX)
-#define MULT_FIX_FLOOR_C(x, y) (((uint64_t)(x) * (y)) >> WEBP_RESCALER_RFIX)
-
-#define LOAD_32x4(SRC, DST) const uint32x4_t DST = vld1q_u32((SRC))
-#define LOAD_32x8(SRC, DST0, DST1) \
- LOAD_32x4(SRC + 0, DST0); \
- LOAD_32x4(SRC + 4, DST1)
-
-#define STORE_32x8(SRC0, SRC1, DST) do { \
- vst1q_u32((DST) + 0, SRC0); \
- vst1q_u32((DST) + 4, SRC1); \
-} while (0);
-
-#if (WEBP_RESCALER_RFIX == 32)
-#define MAKE_HALF_CST(C) vdupq_n_s32((int32_t)((C) >> 1))
-// note: B is actualy scale>>1. See MAKE_HALF_CST
-#define MULT_FIX(A, B) \
- vreinterpretq_u32_s32(vqrdmulhq_s32(vreinterpretq_s32_u32((A)), (B)))
-#define MULT_FIX_FLOOR(A, B) \
- vreinterpretq_u32_s32(vqdmulhq_s32(vreinterpretq_s32_u32((A)), (B)))
-#else
-#error "MULT_FIX/WEBP_RESCALER_RFIX need some more work"
-#endif
-
-static uint32x4_t Interpolate_NEON(const rescaler_t* const frow,
- const rescaler_t* const irow,
- uint32_t A, uint32_t B) {
- LOAD_32x4(frow, A0);
- LOAD_32x4(irow, B0);
- const uint64x2_t C0 = vmull_n_u32(vget_low_u32(A0), A);
- const uint64x2_t C1 = vmull_n_u32(vget_high_u32(A0), A);
- const uint64x2_t D0 = vmlal_n_u32(C0, vget_low_u32(B0), B);
- const uint64x2_t D1 = vmlal_n_u32(C1, vget_high_u32(B0), B);
- const uint32x4_t E = vcombine_u32(
- vrshrn_n_u64(D0, WEBP_RESCALER_RFIX),
- vrshrn_n_u64(D1, WEBP_RESCALER_RFIX));
- return E;
-}
-
-static void RescalerExportRowExpand_NEON(WebPRescaler* const wrk) {
- int x_out;
- uint8_t* const dst = wrk->dst;
- rescaler_t* const irow = wrk->irow;
- const int x_out_max = wrk->dst_width * wrk->num_channels;
- const int max_span = x_out_max & ~7;
- const rescaler_t* const frow = wrk->frow;
- const uint32_t fy_scale = wrk->fy_scale;
- const int32x4_t fy_scale_half = MAKE_HALF_CST(fy_scale);
- assert(!WebPRescalerOutputDone(wrk));
- assert(wrk->y_accum <= 0);
- assert(wrk->y_expand);
- assert(wrk->y_sub != 0);
- if (wrk->y_accum == 0) {
- for (x_out = 0; x_out < max_span; x_out += 8) {
- LOAD_32x4(frow + x_out + 0, A0);
- LOAD_32x4(frow + x_out + 4, A1);
- const uint32x4_t B0 = MULT_FIX(A0, fy_scale_half);
- const uint32x4_t B1 = MULT_FIX(A1, fy_scale_half);
- const uint16x4_t C0 = vmovn_u32(B0);
- const uint16x4_t C1 = vmovn_u32(B1);
- const uint8x8_t D = vqmovn_u16(vcombine_u16(C0, C1));
- vst1_u8(dst + x_out, D);
- }
- for (; x_out < x_out_max; ++x_out) {
- const uint32_t J = frow[x_out];
- const int v = (int)MULT_FIX_C(J, fy_scale);
- dst[x_out] = (v > 255) ? 255u : (uint8_t)v;
- }
- } else {
- const uint32_t B = WEBP_RESCALER_FRAC(-wrk->y_accum, wrk->y_sub);
- const uint32_t A = (uint32_t)(WEBP_RESCALER_ONE - B);
- for (x_out = 0; x_out < max_span; x_out += 8) {
- const uint32x4_t C0 =
- Interpolate_NEON(frow + x_out + 0, irow + x_out + 0, A, B);
- const uint32x4_t C1 =
- Interpolate_NEON(frow + x_out + 4, irow + x_out + 4, A, B);
- const uint32x4_t D0 = MULT_FIX(C0, fy_scale_half);
- const uint32x4_t D1 = MULT_FIX(C1, fy_scale_half);
- const uint16x4_t E0 = vmovn_u32(D0);
- const uint16x4_t E1 = vmovn_u32(D1);
- const uint8x8_t F = vqmovn_u16(vcombine_u16(E0, E1));
- vst1_u8(dst + x_out, F);
- }
- for (; x_out < x_out_max; ++x_out) {
- const uint64_t I = (uint64_t)A * frow[x_out]
- + (uint64_t)B * irow[x_out];
- const uint32_t J = (uint32_t)((I + ROUNDER) >> WEBP_RESCALER_RFIX);
- const int v = (int)MULT_FIX_C(J, fy_scale);
- dst[x_out] = (v > 255) ? 255u : (uint8_t)v;
- }
- }
-}
-
-static void RescalerExportRowShrink_NEON(WebPRescaler* const wrk) {
- int x_out;
- uint8_t* const dst = wrk->dst;
- rescaler_t* const irow = wrk->irow;
- const int x_out_max = wrk->dst_width * wrk->num_channels;
- const int max_span = x_out_max & ~7;
- const rescaler_t* const frow = wrk->frow;
- const uint32_t yscale = wrk->fy_scale * (-wrk->y_accum);
- const uint32_t fxy_scale = wrk->fxy_scale;
- const uint32x4_t zero = vdupq_n_u32(0);
- const int32x4_t yscale_half = MAKE_HALF_CST(yscale);
- const int32x4_t fxy_scale_half = MAKE_HALF_CST(fxy_scale);
- assert(!WebPRescalerOutputDone(wrk));
- assert(wrk->y_accum <= 0);
- assert(!wrk->y_expand);
- if (yscale) {
- for (x_out = 0; x_out < max_span; x_out += 8) {
- LOAD_32x8(frow + x_out, in0, in1);
- LOAD_32x8(irow + x_out, in2, in3);
- const uint32x4_t A0 = MULT_FIX_FLOOR(in0, yscale_half);
- const uint32x4_t A1 = MULT_FIX_FLOOR(in1, yscale_half);
- const uint32x4_t B0 = vqsubq_u32(in2, A0);
- const uint32x4_t B1 = vqsubq_u32(in3, A1);
- const uint32x4_t C0 = MULT_FIX(B0, fxy_scale_half);
- const uint32x4_t C1 = MULT_FIX(B1, fxy_scale_half);
- const uint16x4_t D0 = vmovn_u32(C0);
- const uint16x4_t D1 = vmovn_u32(C1);
- const uint8x8_t E = vqmovn_u16(vcombine_u16(D0, D1));
- vst1_u8(dst + x_out, E);
- STORE_32x8(A0, A1, irow + x_out);
- }
- for (; x_out < x_out_max; ++x_out) {
- const uint32_t frac = (uint32_t)MULT_FIX_FLOOR_C(frow[x_out], yscale);
- const int v = (int)MULT_FIX_C(irow[x_out] - frac, fxy_scale);
- dst[x_out] = (v > 255) ? 255u : (uint8_t)v;
- irow[x_out] = frac; // new fractional start
- }
- } else {
- for (x_out = 0; x_out < max_span; x_out += 8) {
- LOAD_32x8(irow + x_out, in0, in1);
- const uint32x4_t A0 = MULT_FIX(in0, fxy_scale_half);
- const uint32x4_t A1 = MULT_FIX(in1, fxy_scale_half);
- const uint16x4_t B0 = vmovn_u32(A0);
- const uint16x4_t B1 = vmovn_u32(A1);
- const uint8x8_t C = vqmovn_u16(vcombine_u16(B0, B1));
- vst1_u8(dst + x_out, C);
- STORE_32x8(zero, zero, irow + x_out);
- }
- for (; x_out < x_out_max; ++x_out) {
- const int v = (int)MULT_FIX_C(irow[x_out], fxy_scale);
- dst[x_out] = (v > 255) ? 255u : (uint8_t)v;
- irow[x_out] = 0;
- }
- }
-}
-
-#undef MULT_FIX_FLOOR_C
-#undef MULT_FIX_C
-#undef MULT_FIX_FLOOR
-#undef MULT_FIX
-#undef ROUNDER
-
-//------------------------------------------------------------------------------
-
-extern void WebPRescalerDspInitNEON(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void WebPRescalerDspInitNEON(void) {
- WebPRescalerExportRowExpand = RescalerExportRowExpand_NEON;
- WebPRescalerExportRowShrink = RescalerExportRowShrink_NEON;
-}
-
-#else // !WEBP_USE_NEON
-
-WEBP_DSP_INIT_STUB(WebPRescalerDspInitNEON)
-
-#endif // WEBP_USE_NEON
diff --git a/contrib/libs/libwebp/dsp/rescaler_sse2.c b/contrib/libs/libwebp/dsp/rescaler_sse2.c
deleted file mode 100644
index 875215b3ae..0000000000
--- a/contrib/libs/libwebp/dsp/rescaler_sse2.c
+++ /dev/null
@@ -1,366 +0,0 @@
-// Copyright 2015 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// SSE2 Rescaling functions
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_SSE2) && !defined(WEBP_REDUCE_SIZE)
-#include <emmintrin.h>
-
-#include <assert.h>
-#include "../utils/rescaler_utils.h"
-#include "../utils/utils.h"
-
-//------------------------------------------------------------------------------
-// Implementations of critical functions ImportRow / ExportRow
-
-#define ROUNDER (WEBP_RESCALER_ONE >> 1)
-#define MULT_FIX(x, y) (((uint64_t)(x) * (y) + ROUNDER) >> WEBP_RESCALER_RFIX)
-#define MULT_FIX_FLOOR(x, y) (((uint64_t)(x) * (y)) >> WEBP_RESCALER_RFIX)
-
-// input: 8 bytes ABCDEFGH -> output: A0E0B0F0C0G0D0H0
-static void LoadTwoPixels_SSE2(const uint8_t* const src, __m128i* out) {
- const __m128i zero = _mm_setzero_si128();
- const __m128i A = _mm_loadl_epi64((const __m128i*)(src)); // ABCDEFGH
- const __m128i B = _mm_unpacklo_epi8(A, zero); // A0B0C0D0E0F0G0H0
- const __m128i C = _mm_srli_si128(B, 8); // E0F0G0H0
- *out = _mm_unpacklo_epi16(B, C);
-}
-
-// input: 8 bytes ABCDEFGH -> output: A0B0C0D0E0F0G0H0
-static void LoadEightPixels_SSE2(const uint8_t* const src, __m128i* out) {
- const __m128i zero = _mm_setzero_si128();
- const __m128i A = _mm_loadl_epi64((const __m128i*)(src)); // ABCDEFGH
- *out = _mm_unpacklo_epi8(A, zero);
-}
-
-static void RescalerImportRowExpand_SSE2(WebPRescaler* const wrk,
- const uint8_t* src) {
- rescaler_t* frow = wrk->frow;
- const rescaler_t* const frow_end = frow + wrk->dst_width * wrk->num_channels;
- const int x_add = wrk->x_add;
- int accum = x_add;
- __m128i cur_pixels;
-
- // SSE2 implementation only works with 16b signed arithmetic at max.
- if (wrk->src_width < 8 || accum >= (1 << 15)) {
- WebPRescalerImportRowExpand_C(wrk, src);
- return;
- }
-
- assert(!WebPRescalerInputDone(wrk));
- assert(wrk->x_expand);
- if (wrk->num_channels == 4) {
- LoadTwoPixels_SSE2(src, &cur_pixels);
- src += 4;
- while (1) {
- const __m128i mult = _mm_set1_epi32(((x_add - accum) << 16) | accum);
- const __m128i out = _mm_madd_epi16(cur_pixels, mult);
- _mm_storeu_si128((__m128i*)frow, out);
- frow += 4;
- if (frow >= frow_end) break;
- accum -= wrk->x_sub;
- if (accum < 0) {
- LoadTwoPixels_SSE2(src, &cur_pixels);
- src += 4;
- accum += x_add;
- }
- }
- } else {
- int left;
- const uint8_t* const src_limit = src + wrk->src_width - 8;
- LoadEightPixels_SSE2(src, &cur_pixels);
- src += 7;
- left = 7;
- while (1) {
- const __m128i mult = _mm_cvtsi32_si128(((x_add - accum) << 16) | accum);
- const __m128i out = _mm_madd_epi16(cur_pixels, mult);
- assert(sizeof(*frow) == sizeof(uint32_t));
- WebPUint32ToMem((uint8_t*)frow, _mm_cvtsi128_si32(out));
- frow += 1;
- if (frow >= frow_end) break;
- accum -= wrk->x_sub;
- if (accum < 0) {
- if (--left) {
- cur_pixels = _mm_srli_si128(cur_pixels, 2);
- } else if (src <= src_limit) {
- LoadEightPixels_SSE2(src, &cur_pixels);
- src += 7;
- left = 7;
- } else { // tail
- cur_pixels = _mm_srli_si128(cur_pixels, 2);
- cur_pixels = _mm_insert_epi16(cur_pixels, src[1], 1);
- src += 1;
- left = 1;
- }
- accum += x_add;
- }
- }
- }
- assert(accum == 0);
-}
-
-static void RescalerImportRowShrink_SSE2(WebPRescaler* const wrk,
- const uint8_t* src) {
- const int x_sub = wrk->x_sub;
- int accum = 0;
- const __m128i zero = _mm_setzero_si128();
- const __m128i mult0 = _mm_set1_epi16(x_sub);
- const __m128i mult1 = _mm_set1_epi32(wrk->fx_scale);
- const __m128i rounder = _mm_set_epi32(0, ROUNDER, 0, ROUNDER);
- __m128i sum = zero;
- rescaler_t* frow = wrk->frow;
- const rescaler_t* const frow_end = wrk->frow + 4 * wrk->dst_width;
-
- if (wrk->num_channels != 4 || wrk->x_add > (x_sub << 7)) {
- WebPRescalerImportRowShrink_C(wrk, src);
- return;
- }
- assert(!WebPRescalerInputDone(wrk));
- assert(!wrk->x_expand);
-
- for (; frow < frow_end; frow += 4) {
- __m128i base = zero;
- accum += wrk->x_add;
- while (accum > 0) {
- const __m128i A = _mm_cvtsi32_si128(WebPMemToUint32(src));
- src += 4;
- base = _mm_unpacklo_epi8(A, zero);
- // To avoid overflow, we need: base * x_add / x_sub < 32768
- // => x_add < x_sub << 7. That's a 1/128 reduction ratio limit.
- sum = _mm_add_epi16(sum, base);
- accum -= x_sub;
- }
- { // Emit next horizontal pixel.
- const __m128i mult = _mm_set1_epi16(-accum);
- const __m128i frac0 = _mm_mullo_epi16(base, mult); // 16b x 16b -> 32b
- const __m128i frac1 = _mm_mulhi_epu16(base, mult);
- const __m128i frac = _mm_unpacklo_epi16(frac0, frac1); // frac is 32b
- const __m128i A0 = _mm_mullo_epi16(sum, mult0);
- const __m128i A1 = _mm_mulhi_epu16(sum, mult0);
- const __m128i B0 = _mm_unpacklo_epi16(A0, A1); // sum * x_sub
- const __m128i frow_out = _mm_sub_epi32(B0, frac); // sum * x_sub - frac
- const __m128i D0 = _mm_srli_epi64(frac, 32);
- const __m128i D1 = _mm_mul_epu32(frac, mult1); // 32b x 16b -> 64b
- const __m128i D2 = _mm_mul_epu32(D0, mult1);
- const __m128i E1 = _mm_add_epi64(D1, rounder);
- const __m128i E2 = _mm_add_epi64(D2, rounder);
- const __m128i F1 = _mm_shuffle_epi32(E1, 1 | (3 << 2));
- const __m128i F2 = _mm_shuffle_epi32(E2, 1 | (3 << 2));
- const __m128i G = _mm_unpacklo_epi32(F1, F2);
- sum = _mm_packs_epi32(G, zero);
- _mm_storeu_si128((__m128i*)frow, frow_out);
- }
- }
- assert(accum == 0);
-}
-
-//------------------------------------------------------------------------------
-// Row export
-
-// load *src as epi64, multiply by mult and store result in [out0 ... out3]
-static WEBP_INLINE void LoadDispatchAndMult_SSE2(const rescaler_t* const src,
- const __m128i* const mult,
- __m128i* const out0,
- __m128i* const out1,
- __m128i* const out2,
- __m128i* const out3) {
- const __m128i A0 = _mm_loadu_si128((const __m128i*)(src + 0));
- const __m128i A1 = _mm_loadu_si128((const __m128i*)(src + 4));
- const __m128i A2 = _mm_srli_epi64(A0, 32);
- const __m128i A3 = _mm_srli_epi64(A1, 32);
- if (mult != NULL) {
- *out0 = _mm_mul_epu32(A0, *mult);
- *out1 = _mm_mul_epu32(A1, *mult);
- *out2 = _mm_mul_epu32(A2, *mult);
- *out3 = _mm_mul_epu32(A3, *mult);
- } else {
- *out0 = A0;
- *out1 = A1;
- *out2 = A2;
- *out3 = A3;
- }
-}
-
-static WEBP_INLINE void ProcessRow_SSE2(const __m128i* const A0,
- const __m128i* const A1,
- const __m128i* const A2,
- const __m128i* const A3,
- const __m128i* const mult,
- uint8_t* const dst) {
- const __m128i rounder = _mm_set_epi32(0, ROUNDER, 0, ROUNDER);
- const __m128i mask = _mm_set_epi32(0xffffffffu, 0, 0xffffffffu, 0);
- const __m128i B0 = _mm_mul_epu32(*A0, *mult);
- const __m128i B1 = _mm_mul_epu32(*A1, *mult);
- const __m128i B2 = _mm_mul_epu32(*A2, *mult);
- const __m128i B3 = _mm_mul_epu32(*A3, *mult);
- const __m128i C0 = _mm_add_epi64(B0, rounder);
- const __m128i C1 = _mm_add_epi64(B1, rounder);
- const __m128i C2 = _mm_add_epi64(B2, rounder);
- const __m128i C3 = _mm_add_epi64(B3, rounder);
- const __m128i D0 = _mm_srli_epi64(C0, WEBP_RESCALER_RFIX);
- const __m128i D1 = _mm_srli_epi64(C1, WEBP_RESCALER_RFIX);
-#if (WEBP_RESCALER_RFIX < 32)
- const __m128i D2 =
- _mm_and_si128(_mm_slli_epi64(C2, 32 - WEBP_RESCALER_RFIX), mask);
- const __m128i D3 =
- _mm_and_si128(_mm_slli_epi64(C3, 32 - WEBP_RESCALER_RFIX), mask);
-#else
- const __m128i D2 = _mm_and_si128(C2, mask);
- const __m128i D3 = _mm_and_si128(C3, mask);
-#endif
- const __m128i E0 = _mm_or_si128(D0, D2);
- const __m128i E1 = _mm_or_si128(D1, D3);
- const __m128i F = _mm_packs_epi32(E0, E1);
- const __m128i G = _mm_packus_epi16(F, F);
- _mm_storel_epi64((__m128i*)dst, G);
-}
-
-static void RescalerExportRowExpand_SSE2(WebPRescaler* const wrk) {
- int x_out;
- uint8_t* const dst = wrk->dst;
- rescaler_t* const irow = wrk->irow;
- const int x_out_max = wrk->dst_width * wrk->num_channels;
- const rescaler_t* const frow = wrk->frow;
- const __m128i mult = _mm_set_epi32(0, wrk->fy_scale, 0, wrk->fy_scale);
-
- assert(!WebPRescalerOutputDone(wrk));
- assert(wrk->y_accum <= 0 && wrk->y_sub + wrk->y_accum >= 0);
- assert(wrk->y_expand);
- if (wrk->y_accum == 0) {
- for (x_out = 0; x_out + 8 <= x_out_max; x_out += 8) {
- __m128i A0, A1, A2, A3;
- LoadDispatchAndMult_SSE2(frow + x_out, NULL, &A0, &A1, &A2, &A3);
- ProcessRow_SSE2(&A0, &A1, &A2, &A3, &mult, dst + x_out);
- }
- for (; x_out < x_out_max; ++x_out) {
- const uint32_t J = frow[x_out];
- const int v = (int)MULT_FIX(J, wrk->fy_scale);
- dst[x_out] = (v > 255) ? 255u : (uint8_t)v;
- }
- } else {
- const uint32_t B = WEBP_RESCALER_FRAC(-wrk->y_accum, wrk->y_sub);
- const uint32_t A = (uint32_t)(WEBP_RESCALER_ONE - B);
- const __m128i mA = _mm_set_epi32(0, A, 0, A);
- const __m128i mB = _mm_set_epi32(0, B, 0, B);
- const __m128i rounder = _mm_set_epi32(0, ROUNDER, 0, ROUNDER);
- for (x_out = 0; x_out + 8 <= x_out_max; x_out += 8) {
- __m128i A0, A1, A2, A3, B0, B1, B2, B3;
- LoadDispatchAndMult_SSE2(frow + x_out, &mA, &A0, &A1, &A2, &A3);
- LoadDispatchAndMult_SSE2(irow + x_out, &mB, &B0, &B1, &B2, &B3);
- {
- const __m128i C0 = _mm_add_epi64(A0, B0);
- const __m128i C1 = _mm_add_epi64(A1, B1);
- const __m128i C2 = _mm_add_epi64(A2, B2);
- const __m128i C3 = _mm_add_epi64(A3, B3);
- const __m128i D0 = _mm_add_epi64(C0, rounder);
- const __m128i D1 = _mm_add_epi64(C1, rounder);
- const __m128i D2 = _mm_add_epi64(C2, rounder);
- const __m128i D3 = _mm_add_epi64(C3, rounder);
- const __m128i E0 = _mm_srli_epi64(D0, WEBP_RESCALER_RFIX);
- const __m128i E1 = _mm_srli_epi64(D1, WEBP_RESCALER_RFIX);
- const __m128i E2 = _mm_srli_epi64(D2, WEBP_RESCALER_RFIX);
- const __m128i E3 = _mm_srli_epi64(D3, WEBP_RESCALER_RFIX);
- ProcessRow_SSE2(&E0, &E1, &E2, &E3, &mult, dst + x_out);
- }
- }
- for (; x_out < x_out_max; ++x_out) {
- const uint64_t I = (uint64_t)A * frow[x_out]
- + (uint64_t)B * irow[x_out];
- const uint32_t J = (uint32_t)((I + ROUNDER) >> WEBP_RESCALER_RFIX);
- const int v = (int)MULT_FIX(J, wrk->fy_scale);
- dst[x_out] = (v > 255) ? 255u : (uint8_t)v;
- }
- }
-}
-
-static void RescalerExportRowShrink_SSE2(WebPRescaler* const wrk) {
- int x_out;
- uint8_t* const dst = wrk->dst;
- rescaler_t* const irow = wrk->irow;
- const int x_out_max = wrk->dst_width * wrk->num_channels;
- const rescaler_t* const frow = wrk->frow;
- const uint32_t yscale = wrk->fy_scale * (-wrk->y_accum);
- assert(!WebPRescalerOutputDone(wrk));
- assert(wrk->y_accum <= 0);
- assert(!wrk->y_expand);
- if (yscale) {
- const int scale_xy = wrk->fxy_scale;
- const __m128i mult_xy = _mm_set_epi32(0, scale_xy, 0, scale_xy);
- const __m128i mult_y = _mm_set_epi32(0, yscale, 0, yscale);
- for (x_out = 0; x_out + 8 <= x_out_max; x_out += 8) {
- __m128i A0, A1, A2, A3, B0, B1, B2, B3;
- LoadDispatchAndMult_SSE2(irow + x_out, NULL, &A0, &A1, &A2, &A3);
- LoadDispatchAndMult_SSE2(frow + x_out, &mult_y, &B0, &B1, &B2, &B3);
- {
- const __m128i D0 = _mm_srli_epi64(B0, WEBP_RESCALER_RFIX); // = frac
- const __m128i D1 = _mm_srli_epi64(B1, WEBP_RESCALER_RFIX);
- const __m128i D2 = _mm_srli_epi64(B2, WEBP_RESCALER_RFIX);
- const __m128i D3 = _mm_srli_epi64(B3, WEBP_RESCALER_RFIX);
- const __m128i E0 = _mm_sub_epi64(A0, D0); // irow[x] - frac
- const __m128i E1 = _mm_sub_epi64(A1, D1);
- const __m128i E2 = _mm_sub_epi64(A2, D2);
- const __m128i E3 = _mm_sub_epi64(A3, D3);
- const __m128i F2 = _mm_slli_epi64(D2, 32);
- const __m128i F3 = _mm_slli_epi64(D3, 32);
- const __m128i G0 = _mm_or_si128(D0, F2);
- const __m128i G1 = _mm_or_si128(D1, F3);
- _mm_storeu_si128((__m128i*)(irow + x_out + 0), G0);
- _mm_storeu_si128((__m128i*)(irow + x_out + 4), G1);
- ProcessRow_SSE2(&E0, &E1, &E2, &E3, &mult_xy, dst + x_out);
- }
- }
- for (; x_out < x_out_max; ++x_out) {
- const uint32_t frac = (int)MULT_FIX_FLOOR(frow[x_out], yscale);
- const int v = (int)MULT_FIX(irow[x_out] - frac, wrk->fxy_scale);
- dst[x_out] = (v > 255) ? 255u : (uint8_t)v;
- irow[x_out] = frac; // new fractional start
- }
- } else {
- const uint32_t scale = wrk->fxy_scale;
- const __m128i mult = _mm_set_epi32(0, scale, 0, scale);
- const __m128i zero = _mm_setzero_si128();
- for (x_out = 0; x_out + 8 <= x_out_max; x_out += 8) {
- __m128i A0, A1, A2, A3;
- LoadDispatchAndMult_SSE2(irow + x_out, NULL, &A0, &A1, &A2, &A3);
- _mm_storeu_si128((__m128i*)(irow + x_out + 0), zero);
- _mm_storeu_si128((__m128i*)(irow + x_out + 4), zero);
- ProcessRow_SSE2(&A0, &A1, &A2, &A3, &mult, dst + x_out);
- }
- for (; x_out < x_out_max; ++x_out) {
- const int v = (int)MULT_FIX(irow[x_out], scale);
- dst[x_out] = (v > 255) ? 255u : (uint8_t)v;
- irow[x_out] = 0;
- }
- }
-}
-
-#undef MULT_FIX_FLOOR
-#undef MULT_FIX
-#undef ROUNDER
-
-//------------------------------------------------------------------------------
-
-extern void WebPRescalerDspInitSSE2(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void WebPRescalerDspInitSSE2(void) {
- WebPRescalerImportRowExpand = RescalerImportRowExpand_SSE2;
- WebPRescalerImportRowShrink = RescalerImportRowShrink_SSE2;
- WebPRescalerExportRowExpand = RescalerExportRowExpand_SSE2;
- WebPRescalerExportRowShrink = RescalerExportRowShrink_SSE2;
-}
-
-#else // !WEBP_USE_SSE2
-
-WEBP_DSP_INIT_STUB(WebPRescalerDspInitSSE2)
-
-#endif // WEBP_USE_SSE2
diff --git a/contrib/libs/libwebp/dsp/ssim.c b/contrib/libs/libwebp/dsp/ssim.c
deleted file mode 100644
index 388190832c..0000000000
--- a/contrib/libs/libwebp/dsp/ssim.c
+++ /dev/null
@@ -1,159 +0,0 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// distortion calculation
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include <assert.h>
-#include <stdlib.h> // for abs()
-
-#include "./dsp.h"
-
-#if !defined(WEBP_REDUCE_SIZE)
-
-//------------------------------------------------------------------------------
-// SSIM / PSNR
-
-// hat-shaped filter. Sum of coefficients is equal to 16.
-static const uint32_t kWeight[2 * VP8_SSIM_KERNEL + 1] = {
- 1, 2, 3, 4, 3, 2, 1
-};
-static const uint32_t kWeightSum = 16 * 16; // sum{kWeight}^2
-
-static WEBP_INLINE double SSIMCalculation(
- const VP8DistoStats* const stats, uint32_t N /*num samples*/) {
- const uint32_t w2 = N * N;
- const uint32_t C1 = 20 * w2;
- const uint32_t C2 = 60 * w2;
- const uint32_t C3 = 8 * 8 * w2; // 'dark' limit ~= 6
- const uint64_t xmxm = (uint64_t)stats->xm * stats->xm;
- const uint64_t ymym = (uint64_t)stats->ym * stats->ym;
- if (xmxm + ymym >= C3) {
- const int64_t xmym = (int64_t)stats->xm * stats->ym;
- const int64_t sxy = (int64_t)stats->xym * N - xmym; // can be negative
- const uint64_t sxx = (uint64_t)stats->xxm * N - xmxm;
- const uint64_t syy = (uint64_t)stats->yym * N - ymym;
- // we descale by 8 to prevent overflow during the fnum/fden multiply.
- const uint64_t num_S = (2 * (uint64_t)(sxy < 0 ? 0 : sxy) + C2) >> 8;
- const uint64_t den_S = (sxx + syy + C2) >> 8;
- const uint64_t fnum = (2 * xmym + C1) * num_S;
- const uint64_t fden = (xmxm + ymym + C1) * den_S;
- const double r = (double)fnum / fden;
- assert(r >= 0. && r <= 1.0);
- return r;
- }
- return 1.; // area is too dark to contribute meaningfully
-}
-
-double VP8SSIMFromStats(const VP8DistoStats* const stats) {
- return SSIMCalculation(stats, kWeightSum);
-}
-
-double VP8SSIMFromStatsClipped(const VP8DistoStats* const stats) {
- return SSIMCalculation(stats, stats->w);
-}
-
-static double SSIMGetClipped_C(const uint8_t* src1, int stride1,
- const uint8_t* src2, int stride2,
- int xo, int yo, int W, int H) {
- VP8DistoStats stats = { 0, 0, 0, 0, 0, 0 };
- const int ymin = (yo - VP8_SSIM_KERNEL < 0) ? 0 : yo - VP8_SSIM_KERNEL;
- const int ymax = (yo + VP8_SSIM_KERNEL > H - 1) ? H - 1
- : yo + VP8_SSIM_KERNEL;
- const int xmin = (xo - VP8_SSIM_KERNEL < 0) ? 0 : xo - VP8_SSIM_KERNEL;
- const int xmax = (xo + VP8_SSIM_KERNEL > W - 1) ? W - 1
- : xo + VP8_SSIM_KERNEL;
- int x, y;
- src1 += ymin * stride1;
- src2 += ymin * stride2;
- for (y = ymin; y <= ymax; ++y, src1 += stride1, src2 += stride2) {
- for (x = xmin; x <= xmax; ++x) {
- const uint32_t w = kWeight[VP8_SSIM_KERNEL + x - xo]
- * kWeight[VP8_SSIM_KERNEL + y - yo];
- const uint32_t s1 = src1[x];
- const uint32_t s2 = src2[x];
- stats.w += w;
- stats.xm += w * s1;
- stats.ym += w * s2;
- stats.xxm += w * s1 * s1;
- stats.xym += w * s1 * s2;
- stats.yym += w * s2 * s2;
- }
- }
- return VP8SSIMFromStatsClipped(&stats);
-}
-
-static double SSIMGet_C(const uint8_t* src1, int stride1,
- const uint8_t* src2, int stride2) {
- VP8DistoStats stats = { 0, 0, 0, 0, 0, 0 };
- int x, y;
- for (y = 0; y <= 2 * VP8_SSIM_KERNEL; ++y, src1 += stride1, src2 += stride2) {
- for (x = 0; x <= 2 * VP8_SSIM_KERNEL; ++x) {
- const uint32_t w = kWeight[x] * kWeight[y];
- const uint32_t s1 = src1[x];
- const uint32_t s2 = src2[x];
- stats.xm += w * s1;
- stats.ym += w * s2;
- stats.xxm += w * s1 * s1;
- stats.xym += w * s1 * s2;
- stats.yym += w * s2 * s2;
- }
- }
- return VP8SSIMFromStats(&stats);
-}
-
-#endif // !defined(WEBP_REDUCE_SIZE)
-
-//------------------------------------------------------------------------------
-
-#if !defined(WEBP_DISABLE_STATS)
-static uint32_t AccumulateSSE_C(const uint8_t* src1,
- const uint8_t* src2, int len) {
- int i;
- uint32_t sse2 = 0;
- assert(len <= 65535); // to ensure that accumulation fits within uint32_t
- for (i = 0; i < len; ++i) {
- const int32_t diff = src1[i] - src2[i];
- sse2 += diff * diff;
- }
- return sse2;
-}
-#endif
-
-//------------------------------------------------------------------------------
-
-#if !defined(WEBP_REDUCE_SIZE)
-VP8SSIMGetFunc VP8SSIMGet;
-VP8SSIMGetClippedFunc VP8SSIMGetClipped;
-#endif
-#if !defined(WEBP_DISABLE_STATS)
-VP8AccumulateSSEFunc VP8AccumulateSSE;
-#endif
-
-extern void VP8SSIMDspInitSSE2(void);
-
-WEBP_DSP_INIT_FUNC(VP8SSIMDspInit) {
-#if !defined(WEBP_REDUCE_SIZE)
- VP8SSIMGetClipped = SSIMGetClipped_C;
- VP8SSIMGet = SSIMGet_C;
-#endif
-
-#if !defined(WEBP_DISABLE_STATS)
- VP8AccumulateSSE = AccumulateSSE_C;
-#endif
-
- if (VP8GetCPUInfo != NULL) {
-#if defined(WEBP_HAVE_SSE2)
- if (VP8GetCPUInfo(kSSE2)) {
- VP8SSIMDspInitSSE2();
- }
-#endif
- }
-}
diff --git a/contrib/libs/libwebp/dsp/ssim_sse2.c b/contrib/libs/libwebp/dsp/ssim_sse2.c
deleted file mode 100644
index f25efc1e50..0000000000
--- a/contrib/libs/libwebp/dsp/ssim_sse2.c
+++ /dev/null
@@ -1,165 +0,0 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// SSE2 version of distortion calculation
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_SSE2)
-
-#include <assert.h>
-#include <emmintrin.h>
-
-#include "./common_sse2.h"
-
-#if !defined(WEBP_DISABLE_STATS)
-
-// Helper function
-static WEBP_INLINE void SubtractAndSquare_SSE2(const __m128i a, const __m128i b,
- __m128i* const sum) {
- // take abs(a-b) in 8b
- const __m128i a_b = _mm_subs_epu8(a, b);
- const __m128i b_a = _mm_subs_epu8(b, a);
- const __m128i abs_a_b = _mm_or_si128(a_b, b_a);
- // zero-extend to 16b
- const __m128i zero = _mm_setzero_si128();
- const __m128i C0 = _mm_unpacklo_epi8(abs_a_b, zero);
- const __m128i C1 = _mm_unpackhi_epi8(abs_a_b, zero);
- // multiply with self
- const __m128i sum1 = _mm_madd_epi16(C0, C0);
- const __m128i sum2 = _mm_madd_epi16(C1, C1);
- *sum = _mm_add_epi32(sum1, sum2);
-}
-
-//------------------------------------------------------------------------------
-// SSIM / PSNR entry point
-
-static uint32_t AccumulateSSE_SSE2(const uint8_t* src1,
- const uint8_t* src2, int len) {
- int i = 0;
- uint32_t sse2 = 0;
- if (len >= 16) {
- const int limit = len - 32;
- int32_t tmp[4];
- __m128i sum1;
- __m128i sum = _mm_setzero_si128();
- __m128i a0 = _mm_loadu_si128((const __m128i*)&src1[i]);
- __m128i b0 = _mm_loadu_si128((const __m128i*)&src2[i]);
- i += 16;
- while (i <= limit) {
- const __m128i a1 = _mm_loadu_si128((const __m128i*)&src1[i]);
- const __m128i b1 = _mm_loadu_si128((const __m128i*)&src2[i]);
- __m128i sum2;
- i += 16;
- SubtractAndSquare_SSE2(a0, b0, &sum1);
- sum = _mm_add_epi32(sum, sum1);
- a0 = _mm_loadu_si128((const __m128i*)&src1[i]);
- b0 = _mm_loadu_si128((const __m128i*)&src2[i]);
- i += 16;
- SubtractAndSquare_SSE2(a1, b1, &sum2);
- sum = _mm_add_epi32(sum, sum2);
- }
- SubtractAndSquare_SSE2(a0, b0, &sum1);
- sum = _mm_add_epi32(sum, sum1);
- _mm_storeu_si128((__m128i*)tmp, sum);
- sse2 += (tmp[3] + tmp[2] + tmp[1] + tmp[0]);
- }
-
- for (; i < len; ++i) {
- const int32_t diff = src1[i] - src2[i];
- sse2 += diff * diff;
- }
- return sse2;
-}
-#endif // !defined(WEBP_DISABLE_STATS)
-
-#if !defined(WEBP_REDUCE_SIZE)
-
-static uint32_t HorizontalAdd16b_SSE2(const __m128i* const m) {
- uint16_t tmp[8];
- const __m128i a = _mm_srli_si128(*m, 8);
- const __m128i b = _mm_add_epi16(*m, a);
- _mm_storeu_si128((__m128i*)tmp, b);
- return (uint32_t)tmp[3] + tmp[2] + tmp[1] + tmp[0];
-}
-
-static uint32_t HorizontalAdd32b_SSE2(const __m128i* const m) {
- const __m128i a = _mm_srli_si128(*m, 8);
- const __m128i b = _mm_add_epi32(*m, a);
- const __m128i c = _mm_add_epi32(b, _mm_srli_si128(b, 4));
- return (uint32_t)_mm_cvtsi128_si32(c);
-}
-
-static const uint16_t kWeight[] = { 1, 2, 3, 4, 3, 2, 1, 0 };
-
-#define ACCUMULATE_ROW(WEIGHT) do { \
- /* compute row weight (Wx * Wy) */ \
- const __m128i Wy = _mm_set1_epi16((WEIGHT)); \
- const __m128i W = _mm_mullo_epi16(Wx, Wy); \
- /* process 8 bytes at a time (7 bytes, actually) */ \
- const __m128i a0 = _mm_loadl_epi64((const __m128i*)src1); \
- const __m128i b0 = _mm_loadl_epi64((const __m128i*)src2); \
- /* convert to 16b and multiply by weight */ \
- const __m128i a1 = _mm_unpacklo_epi8(a0, zero); \
- const __m128i b1 = _mm_unpacklo_epi8(b0, zero); \
- const __m128i wa1 = _mm_mullo_epi16(a1, W); \
- const __m128i wb1 = _mm_mullo_epi16(b1, W); \
- /* accumulate */ \
- xm = _mm_add_epi16(xm, wa1); \
- ym = _mm_add_epi16(ym, wb1); \
- xxm = _mm_add_epi32(xxm, _mm_madd_epi16(a1, wa1)); \
- xym = _mm_add_epi32(xym, _mm_madd_epi16(a1, wb1)); \
- yym = _mm_add_epi32(yym, _mm_madd_epi16(b1, wb1)); \
- src1 += stride1; \
- src2 += stride2; \
-} while (0)
-
-static double SSIMGet_SSE2(const uint8_t* src1, int stride1,
- const uint8_t* src2, int stride2) {
- VP8DistoStats stats;
- const __m128i zero = _mm_setzero_si128();
- __m128i xm = zero, ym = zero; // 16b accums
- __m128i xxm = zero, yym = zero, xym = zero; // 32b accum
- const __m128i Wx = _mm_loadu_si128((const __m128i*)kWeight);
- assert(2 * VP8_SSIM_KERNEL + 1 == 7);
- ACCUMULATE_ROW(1);
- ACCUMULATE_ROW(2);
- ACCUMULATE_ROW(3);
- ACCUMULATE_ROW(4);
- ACCUMULATE_ROW(3);
- ACCUMULATE_ROW(2);
- ACCUMULATE_ROW(1);
- stats.xm = HorizontalAdd16b_SSE2(&xm);
- stats.ym = HorizontalAdd16b_SSE2(&ym);
- stats.xxm = HorizontalAdd32b_SSE2(&xxm);
- stats.xym = HorizontalAdd32b_SSE2(&xym);
- stats.yym = HorizontalAdd32b_SSE2(&yym);
- return VP8SSIMFromStats(&stats);
-}
-
-#endif // !defined(WEBP_REDUCE_SIZE)
-
-extern void VP8SSIMDspInitSSE2(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void VP8SSIMDspInitSSE2(void) {
-#if !defined(WEBP_DISABLE_STATS)
- VP8AccumulateSSE = AccumulateSSE_SSE2;
-#endif
-#if !defined(WEBP_REDUCE_SIZE)
- VP8SSIMGet = SSIMGet_SSE2;
-#endif
-}
-
-#else // !WEBP_USE_SSE2
-
-WEBP_DSP_INIT_STUB(VP8SSIMDspInitSSE2)
-
-#endif // WEBP_USE_SSE2
diff --git a/contrib/libs/libwebp/dsp/upsampling.c b/contrib/libs/libwebp/dsp/upsampling.c
deleted file mode 100644
index a472853ded..0000000000
--- a/contrib/libs/libwebp/dsp/upsampling.c
+++ /dev/null
@@ -1,327 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// YUV to RGB upsampling functions.
-//
-// Author: somnath@google.com (Somnath Banerjee)
-
-#include "./dsp.h"
-#include "./yuv.h"
-
-#include <assert.h>
-
-//------------------------------------------------------------------------------
-// Fancy upsampler
-
-#ifdef FANCY_UPSAMPLING
-
-// Fancy upsampling functions to convert YUV to RGB
-WebPUpsampleLinePairFunc WebPUpsamplers[MODE_LAST];
-
-// Given samples laid out in a square as:
-// [a b]
-// [c d]
-// we interpolate u/v as:
-// ([9*a + 3*b + 3*c + d 3*a + 9*b + 3*c + d] + [8 8]) / 16
-// ([3*a + b + 9*c + 3*d a + 3*b + 3*c + 9*d] [8 8]) / 16
-
-// We process u and v together stashed into 32bit (16bit each).
-#define LOAD_UV(u, v) ((u) | ((v) << 16))
-
-#define UPSAMPLE_FUNC(FUNC_NAME, FUNC, XSTEP) \
-static void FUNC_NAME(const uint8_t* top_y, const uint8_t* bottom_y, \
- const uint8_t* top_u, const uint8_t* top_v, \
- const uint8_t* cur_u, const uint8_t* cur_v, \
- uint8_t* top_dst, uint8_t* bottom_dst, int len) { \
- int x; \
- const int last_pixel_pair = (len - 1) >> 1; \
- uint32_t tl_uv = LOAD_UV(top_u[0], top_v[0]); /* top-left sample */ \
- uint32_t l_uv = LOAD_UV(cur_u[0], cur_v[0]); /* left-sample */ \
- assert(top_y != NULL); \
- { \
- const uint32_t uv0 = (3 * tl_uv + l_uv + 0x00020002u) >> 2; \
- FUNC(top_y[0], uv0 & 0xff, (uv0 >> 16), top_dst); \
- } \
- if (bottom_y != NULL) { \
- const uint32_t uv0 = (3 * l_uv + tl_uv + 0x00020002u) >> 2; \
- FUNC(bottom_y[0], uv0 & 0xff, (uv0 >> 16), bottom_dst); \
- } \
- for (x = 1; x <= last_pixel_pair; ++x) { \
- const uint32_t t_uv = LOAD_UV(top_u[x], top_v[x]); /* top sample */ \
- const uint32_t uv = LOAD_UV(cur_u[x], cur_v[x]); /* sample */ \
- /* precompute invariant values associated with first and second diagonals*/\
- const uint32_t avg = tl_uv + t_uv + l_uv + uv + 0x00080008u; \
- const uint32_t diag_12 = (avg + 2 * (t_uv + l_uv)) >> 3; \
- const uint32_t diag_03 = (avg + 2 * (tl_uv + uv)) >> 3; \
- { \
- const uint32_t uv0 = (diag_12 + tl_uv) >> 1; \
- const uint32_t uv1 = (diag_03 + t_uv) >> 1; \
- FUNC(top_y[2 * x - 1], uv0 & 0xff, (uv0 >> 16), \
- top_dst + (2 * x - 1) * (XSTEP)); \
- FUNC(top_y[2 * x - 0], uv1 & 0xff, (uv1 >> 16), \
- top_dst + (2 * x - 0) * (XSTEP)); \
- } \
- if (bottom_y != NULL) { \
- const uint32_t uv0 = (diag_03 + l_uv) >> 1; \
- const uint32_t uv1 = (diag_12 + uv) >> 1; \
- FUNC(bottom_y[2 * x - 1], uv0 & 0xff, (uv0 >> 16), \
- bottom_dst + (2 * x - 1) * (XSTEP)); \
- FUNC(bottom_y[2 * x + 0], uv1 & 0xff, (uv1 >> 16), \
- bottom_dst + (2 * x + 0) * (XSTEP)); \
- } \
- tl_uv = t_uv; \
- l_uv = uv; \
- } \
- if (!(len & 1)) { \
- { \
- const uint32_t uv0 = (3 * tl_uv + l_uv + 0x00020002u) >> 2; \
- FUNC(top_y[len - 1], uv0 & 0xff, (uv0 >> 16), \
- top_dst + (len - 1) * (XSTEP)); \
- } \
- if (bottom_y != NULL) { \
- const uint32_t uv0 = (3 * l_uv + tl_uv + 0x00020002u) >> 2; \
- FUNC(bottom_y[len - 1], uv0 & 0xff, (uv0 >> 16), \
- bottom_dst + (len - 1) * (XSTEP)); \
- } \
- } \
-}
-
-// All variants implemented.
-#if !WEBP_NEON_OMIT_C_CODE
-UPSAMPLE_FUNC(UpsampleRgbaLinePair_C, VP8YuvToRgba, 4)
-UPSAMPLE_FUNC(UpsampleBgraLinePair_C, VP8YuvToBgra, 4)
-#if !defined(WEBP_REDUCE_CSP)
-UPSAMPLE_FUNC(UpsampleArgbLinePair_C, VP8YuvToArgb, 4)
-UPSAMPLE_FUNC(UpsampleRgbLinePair_C, VP8YuvToRgb, 3)
-UPSAMPLE_FUNC(UpsampleBgrLinePair_C, VP8YuvToBgr, 3)
-UPSAMPLE_FUNC(UpsampleRgba4444LinePair_C, VP8YuvToRgba4444, 2)
-UPSAMPLE_FUNC(UpsampleRgb565LinePair_C, VP8YuvToRgb565, 2)
-#else
-static void EmptyUpsampleFunc(const uint8_t* top_y, const uint8_t* bottom_y,
- const uint8_t* top_u, const uint8_t* top_v,
- const uint8_t* cur_u, const uint8_t* cur_v,
- uint8_t* top_dst, uint8_t* bottom_dst, int len) {
- (void)top_y;
- (void)bottom_y;
- (void)top_u;
- (void)top_v;
- (void)cur_u;
- (void)cur_v;
- (void)top_dst;
- (void)bottom_dst;
- (void)len;
- assert(0); // COLORSPACE SUPPORT NOT COMPILED
-}
-#define UpsampleArgbLinePair_C EmptyUpsampleFunc
-#define UpsampleRgbLinePair_C EmptyUpsampleFunc
-#define UpsampleBgrLinePair_C EmptyUpsampleFunc
-#define UpsampleRgba4444LinePair_C EmptyUpsampleFunc
-#define UpsampleRgb565LinePair_C EmptyUpsampleFunc
-#endif // WEBP_REDUCE_CSP
-
-#endif
-
-#undef LOAD_UV
-#undef UPSAMPLE_FUNC
-
-#endif // FANCY_UPSAMPLING
-
-//------------------------------------------------------------------------------
-
-#if !defined(FANCY_UPSAMPLING)
-#define DUAL_SAMPLE_FUNC(FUNC_NAME, FUNC) \
-static void FUNC_NAME(const uint8_t* top_y, const uint8_t* bot_y, \
- const uint8_t* top_u, const uint8_t* top_v, \
- const uint8_t* bot_u, const uint8_t* bot_v, \
- uint8_t* top_dst, uint8_t* bot_dst, int len) { \
- const int half_len = len >> 1; \
- int x; \
- assert(top_dst != NULL); \
- { \
- for (x = 0; x < half_len; ++x) { \
- FUNC(top_y[2 * x + 0], top_u[x], top_v[x], top_dst + 8 * x + 0); \
- FUNC(top_y[2 * x + 1], top_u[x], top_v[x], top_dst + 8 * x + 4); \
- } \
- if (len & 1) FUNC(top_y[2 * x + 0], top_u[x], top_v[x], top_dst + 8 * x); \
- } \
- if (bot_dst != NULL) { \
- for (x = 0; x < half_len; ++x) { \
- FUNC(bot_y[2 * x + 0], bot_u[x], bot_v[x], bot_dst + 8 * x + 0); \
- FUNC(bot_y[2 * x + 1], bot_u[x], bot_v[x], bot_dst + 8 * x + 4); \
- } \
- if (len & 1) FUNC(bot_y[2 * x + 0], bot_u[x], bot_v[x], bot_dst + 8 * x); \
- } \
-}
-
-DUAL_SAMPLE_FUNC(DualLineSamplerBGRA, VP8YuvToBgra)
-DUAL_SAMPLE_FUNC(DualLineSamplerARGB, VP8YuvToArgb)
-#undef DUAL_SAMPLE_FUNC
-
-#endif // !FANCY_UPSAMPLING
-
-WebPUpsampleLinePairFunc WebPGetLinePairConverter(int alpha_is_last) {
- WebPInitUpsamplers();
-#ifdef FANCY_UPSAMPLING
- return WebPUpsamplers[alpha_is_last ? MODE_BGRA : MODE_ARGB];
-#else
- return (alpha_is_last ? DualLineSamplerBGRA : DualLineSamplerARGB);
-#endif
-}
-
-//------------------------------------------------------------------------------
-// YUV444 converter
-
-#define YUV444_FUNC(FUNC_NAME, FUNC, XSTEP) \
-extern void FUNC_NAME(const uint8_t* y, const uint8_t* u, const uint8_t* v, \
- uint8_t* dst, int len); \
-void FUNC_NAME(const uint8_t* y, const uint8_t* u, const uint8_t* v, \
- uint8_t* dst, int len) { \
- int i; \
- for (i = 0; i < len; ++i) FUNC(y[i], u[i], v[i], &dst[i * (XSTEP)]); \
-}
-
-YUV444_FUNC(WebPYuv444ToRgba_C, VP8YuvToRgba, 4)
-YUV444_FUNC(WebPYuv444ToBgra_C, VP8YuvToBgra, 4)
-#if !defined(WEBP_REDUCE_CSP)
-YUV444_FUNC(WebPYuv444ToRgb_C, VP8YuvToRgb, 3)
-YUV444_FUNC(WebPYuv444ToBgr_C, VP8YuvToBgr, 3)
-YUV444_FUNC(WebPYuv444ToArgb_C, VP8YuvToArgb, 4)
-YUV444_FUNC(WebPYuv444ToRgba4444_C, VP8YuvToRgba4444, 2)
-YUV444_FUNC(WebPYuv444ToRgb565_C, VP8YuvToRgb565, 2)
-#else
-static void EmptyYuv444Func(const uint8_t* y,
- const uint8_t* u, const uint8_t* v,
- uint8_t* dst, int len) {
- (void)y;
- (void)u;
- (void)v;
- (void)dst;
- (void)len;
-}
-#define WebPYuv444ToRgb_C EmptyYuv444Func
-#define WebPYuv444ToBgr_C EmptyYuv444Func
-#define WebPYuv444ToArgb_C EmptyYuv444Func
-#define WebPYuv444ToRgba4444_C EmptyYuv444Func
-#define WebPYuv444ToRgb565_C EmptyYuv444Func
-#endif // WEBP_REDUCE_CSP
-
-#undef YUV444_FUNC
-
-WebPYUV444Converter WebPYUV444Converters[MODE_LAST];
-
-extern void WebPInitYUV444ConvertersMIPSdspR2(void);
-extern void WebPInitYUV444ConvertersSSE2(void);
-extern void WebPInitYUV444ConvertersSSE41(void);
-
-WEBP_DSP_INIT_FUNC(WebPInitYUV444Converters) {
- WebPYUV444Converters[MODE_RGBA] = WebPYuv444ToRgba_C;
- WebPYUV444Converters[MODE_BGRA] = WebPYuv444ToBgra_C;
- WebPYUV444Converters[MODE_RGB] = WebPYuv444ToRgb_C;
- WebPYUV444Converters[MODE_BGR] = WebPYuv444ToBgr_C;
- WebPYUV444Converters[MODE_ARGB] = WebPYuv444ToArgb_C;
- WebPYUV444Converters[MODE_RGBA_4444] = WebPYuv444ToRgba4444_C;
- WebPYUV444Converters[MODE_RGB_565] = WebPYuv444ToRgb565_C;
- WebPYUV444Converters[MODE_rgbA] = WebPYuv444ToRgba_C;
- WebPYUV444Converters[MODE_bgrA] = WebPYuv444ToBgra_C;
- WebPYUV444Converters[MODE_Argb] = WebPYuv444ToArgb_C;
- WebPYUV444Converters[MODE_rgbA_4444] = WebPYuv444ToRgba4444_C;
-
- if (VP8GetCPUInfo != NULL) {
-#if defined(WEBP_HAVE_SSE2)
- if (VP8GetCPUInfo(kSSE2)) {
- WebPInitYUV444ConvertersSSE2();
- }
-#endif
-#if defined(WEBP_HAVE_SSE41)
- if (VP8GetCPUInfo(kSSE4_1)) {
- WebPInitYUV444ConvertersSSE41();
- }
-#endif
-#if defined(WEBP_USE_MIPS_DSP_R2)
- if (VP8GetCPUInfo(kMIPSdspR2)) {
- WebPInitYUV444ConvertersMIPSdspR2();
- }
-#endif
- }
-}
-
-//------------------------------------------------------------------------------
-// Main calls
-
-extern void WebPInitUpsamplersSSE2(void);
-extern void WebPInitUpsamplersSSE41(void);
-extern void WebPInitUpsamplersNEON(void);
-extern void WebPInitUpsamplersMIPSdspR2(void);
-extern void WebPInitUpsamplersMSA(void);
-
-WEBP_DSP_INIT_FUNC(WebPInitUpsamplers) {
-#ifdef FANCY_UPSAMPLING
-#if !WEBP_NEON_OMIT_C_CODE
- WebPUpsamplers[MODE_RGBA] = UpsampleRgbaLinePair_C;
- WebPUpsamplers[MODE_BGRA] = UpsampleBgraLinePair_C;
- WebPUpsamplers[MODE_rgbA] = UpsampleRgbaLinePair_C;
- WebPUpsamplers[MODE_bgrA] = UpsampleBgraLinePair_C;
- WebPUpsamplers[MODE_RGB] = UpsampleRgbLinePair_C;
- WebPUpsamplers[MODE_BGR] = UpsampleBgrLinePair_C;
- WebPUpsamplers[MODE_ARGB] = UpsampleArgbLinePair_C;
- WebPUpsamplers[MODE_RGBA_4444] = UpsampleRgba4444LinePair_C;
- WebPUpsamplers[MODE_RGB_565] = UpsampleRgb565LinePair_C;
- WebPUpsamplers[MODE_Argb] = UpsampleArgbLinePair_C;
- WebPUpsamplers[MODE_rgbA_4444] = UpsampleRgba4444LinePair_C;
-#endif
-
- // If defined, use CPUInfo() to overwrite some pointers with faster versions.
- if (VP8GetCPUInfo != NULL) {
-#if defined(WEBP_HAVE_SSE2)
- if (VP8GetCPUInfo(kSSE2)) {
- WebPInitUpsamplersSSE2();
- }
-#endif
-#if defined(WEBP_HAVE_SSE41)
- if (VP8GetCPUInfo(kSSE4_1)) {
- WebPInitUpsamplersSSE41();
- }
-#endif
-#if defined(WEBP_USE_MIPS_DSP_R2)
- if (VP8GetCPUInfo(kMIPSdspR2)) {
- WebPInitUpsamplersMIPSdspR2();
- }
-#endif
-#if defined(WEBP_USE_MSA)
- if (VP8GetCPUInfo(kMSA)) {
- WebPInitUpsamplersMSA();
- }
-#endif
- }
-
-#if defined(WEBP_HAVE_NEON)
- if (WEBP_NEON_OMIT_C_CODE ||
- (VP8GetCPUInfo != NULL && VP8GetCPUInfo(kNEON))) {
- WebPInitUpsamplersNEON();
- }
-#endif
-
- assert(WebPUpsamplers[MODE_RGBA] != NULL);
- assert(WebPUpsamplers[MODE_BGRA] != NULL);
- assert(WebPUpsamplers[MODE_rgbA] != NULL);
- assert(WebPUpsamplers[MODE_bgrA] != NULL);
-#if !defined(WEBP_REDUCE_CSP) || !WEBP_NEON_OMIT_C_CODE
- assert(WebPUpsamplers[MODE_RGB] != NULL);
- assert(WebPUpsamplers[MODE_BGR] != NULL);
- assert(WebPUpsamplers[MODE_ARGB] != NULL);
- assert(WebPUpsamplers[MODE_RGBA_4444] != NULL);
- assert(WebPUpsamplers[MODE_RGB_565] != NULL);
- assert(WebPUpsamplers[MODE_Argb] != NULL);
- assert(WebPUpsamplers[MODE_rgbA_4444] != NULL);
-#endif
-
-#endif // FANCY_UPSAMPLING
-}
-
-//------------------------------------------------------------------------------
diff --git a/contrib/libs/libwebp/dsp/upsampling_mips_dsp_r2.c b/contrib/libs/libwebp/dsp/upsampling_mips_dsp_r2.c
deleted file mode 100644
index 36cb3d2f14..0000000000
--- a/contrib/libs/libwebp/dsp/upsampling_mips_dsp_r2.c
+++ /dev/null
@@ -1,291 +0,0 @@
-// Copyright 2014 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// YUV to RGB upsampling functions.
-//
-// Author(s): Branimir Vasic (branimir.vasic@imgtec.com)
-// Djordje Pesut (djordje.pesut@imgtec.com)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_MIPS_DSP_R2)
-
-#include <assert.h>
-#include "./yuv.h"
-
-#define YUV_TO_RGB(Y, U, V, R, G, B) do { \
- const int t1 = MultHi(Y, 19077); \
- const int t2 = MultHi(V, 13320); \
- R = MultHi(V, 26149); \
- G = MultHi(U, 6419); \
- B = MultHi(U, 33050); \
- R = t1 + R; \
- G = t1 - G; \
- B = t1 + B; \
- R = R - 14234; \
- G = G - t2 + 8708; \
- B = B - 17685; \
- __asm__ volatile ( \
- "shll_s.w %[" #R "], %[" #R "], 17 \n\t" \
- "shll_s.w %[" #G "], %[" #G "], 17 \n\t" \
- "shll_s.w %[" #B "], %[" #B "], 17 \n\t" \
- "precrqu_s.qb.ph %[" #R "], %[" #R "], $zero \n\t" \
- "precrqu_s.qb.ph %[" #G "], %[" #G "], $zero \n\t" \
- "precrqu_s.qb.ph %[" #B "], %[" #B "], $zero \n\t" \
- "srl %[" #R "], %[" #R "], 24 \n\t" \
- "srl %[" #G "], %[" #G "], 24 \n\t" \
- "srl %[" #B "], %[" #B "], 24 \n\t" \
- : [R]"+r"(R), [G]"+r"(G), [B]"+r"(B) \
- : \
- ); \
- } while (0)
-
-#if !defined(WEBP_REDUCE_CSP)
-static WEBP_INLINE void YuvToRgb(int y, int u, int v, uint8_t* const rgb) {
- int r, g, b;
- YUV_TO_RGB(y, u, v, r, g, b);
- rgb[0] = r;
- rgb[1] = g;
- rgb[2] = b;
-}
-static WEBP_INLINE void YuvToBgr(int y, int u, int v, uint8_t* const bgr) {
- int r, g, b;
- YUV_TO_RGB(y, u, v, r, g, b);
- bgr[0] = b;
- bgr[1] = g;
- bgr[2] = r;
-}
-static WEBP_INLINE void YuvToRgb565(int y, int u, int v, uint8_t* const rgb) {
- int r, g, b;
- YUV_TO_RGB(y, u, v, r, g, b);
- {
- const int rg = (r & 0xf8) | (g >> 5);
- const int gb = ((g << 3) & 0xe0) | (b >> 3);
-#if (WEBP_SWAP_16BIT_CSP == 1)
- rgb[0] = gb;
- rgb[1] = rg;
-#else
- rgb[0] = rg;
- rgb[1] = gb;
-#endif
- }
-}
-static WEBP_INLINE void YuvToRgba4444(int y, int u, int v,
- uint8_t* const argb) {
- int r, g, b;
- YUV_TO_RGB(y, u, v, r, g, b);
- {
- const int rg = (r & 0xf0) | (g >> 4);
- const int ba = (b & 0xf0) | 0x0f; // overwrite the lower 4 bits
-#if (WEBP_SWAP_16BIT_CSP == 1)
- argb[0] = ba;
- argb[1] = rg;
-#else
- argb[0] = rg;
- argb[1] = ba;
-#endif
- }
-}
-#endif // WEBP_REDUCE_CSP
-
-//-----------------------------------------------------------------------------
-// Alpha handling variants
-
-#if !defined(WEBP_REDUCE_CSP)
-static WEBP_INLINE void YuvToArgb(uint8_t y, uint8_t u, uint8_t v,
- uint8_t* const argb) {
- int r, g, b;
- YUV_TO_RGB(y, u, v, r, g, b);
- argb[0] = 0xff;
- argb[1] = r;
- argb[2] = g;
- argb[3] = b;
-}
-#endif // WEBP_REDUCE_CSP
-static WEBP_INLINE void YuvToBgra(uint8_t y, uint8_t u, uint8_t v,
- uint8_t* const bgra) {
- int r, g, b;
- YUV_TO_RGB(y, u, v, r, g, b);
- bgra[0] = b;
- bgra[1] = g;
- bgra[2] = r;
- bgra[3] = 0xff;
-}
-static WEBP_INLINE void YuvToRgba(uint8_t y, uint8_t u, uint8_t v,
- uint8_t* const rgba) {
- int r, g, b;
- YUV_TO_RGB(y, u, v, r, g, b);
- rgba[0] = r;
- rgba[1] = g;
- rgba[2] = b;
- rgba[3] = 0xff;
-}
-
-//------------------------------------------------------------------------------
-// Fancy upsampler
-
-#ifdef FANCY_UPSAMPLING
-
-// Given samples laid out in a square as:
-// [a b]
-// [c d]
-// we interpolate u/v as:
-// ([9*a + 3*b + 3*c + d 3*a + 9*b + 3*c + d] + [8 8]) / 16
-// ([3*a + b + 9*c + 3*d a + 3*b + 3*c + 9*d] [8 8]) / 16
-
-// We process u and v together stashed into 32bit (16bit each).
-#define LOAD_UV(u, v) ((u) | ((v) << 16))
-
-#define UPSAMPLE_FUNC(FUNC_NAME, FUNC, XSTEP) \
-static void FUNC_NAME(const uint8_t* top_y, const uint8_t* bottom_y, \
- const uint8_t* top_u, const uint8_t* top_v, \
- const uint8_t* cur_u, const uint8_t* cur_v, \
- uint8_t* top_dst, uint8_t* bottom_dst, int len) { \
- int x; \
- const int last_pixel_pair = (len - 1) >> 1; \
- uint32_t tl_uv = LOAD_UV(top_u[0], top_v[0]); /* top-left sample */ \
- uint32_t l_uv = LOAD_UV(cur_u[0], cur_v[0]); /* left-sample */ \
- assert(top_y != NULL); \
- { \
- const uint32_t uv0 = (3 * tl_uv + l_uv + 0x00020002u) >> 2; \
- FUNC(top_y[0], uv0 & 0xff, (uv0 >> 16), top_dst); \
- } \
- if (bottom_y != NULL) { \
- const uint32_t uv0 = (3 * l_uv + tl_uv + 0x00020002u) >> 2; \
- FUNC(bottom_y[0], uv0 & 0xff, (uv0 >> 16), bottom_dst); \
- } \
- for (x = 1; x <= last_pixel_pair; ++x) { \
- const uint32_t t_uv = LOAD_UV(top_u[x], top_v[x]); /* top sample */ \
- const uint32_t uv = LOAD_UV(cur_u[x], cur_v[x]); /* sample */ \
- /* precompute invariant values associated with first and second diagonals*/\
- const uint32_t avg = tl_uv + t_uv + l_uv + uv + 0x00080008u; \
- const uint32_t diag_12 = (avg + 2 * (t_uv + l_uv)) >> 3; \
- const uint32_t diag_03 = (avg + 2 * (tl_uv + uv)) >> 3; \
- { \
- const uint32_t uv0 = (diag_12 + tl_uv) >> 1; \
- const uint32_t uv1 = (diag_03 + t_uv) >> 1; \
- FUNC(top_y[2 * x - 1], uv0 & 0xff, (uv0 >> 16), \
- top_dst + (2 * x - 1) * XSTEP); \
- FUNC(top_y[2 * x - 0], uv1 & 0xff, (uv1 >> 16), \
- top_dst + (2 * x - 0) * XSTEP); \
- } \
- if (bottom_y != NULL) { \
- const uint32_t uv0 = (diag_03 + l_uv) >> 1; \
- const uint32_t uv1 = (diag_12 + uv) >> 1; \
- FUNC(bottom_y[2 * x - 1], uv0 & 0xff, (uv0 >> 16), \
- bottom_dst + (2 * x - 1) * XSTEP); \
- FUNC(bottom_y[2 * x + 0], uv1 & 0xff, (uv1 >> 16), \
- bottom_dst + (2 * x + 0) * XSTEP); \
- } \
- tl_uv = t_uv; \
- l_uv = uv; \
- } \
- if (!(len & 1)) { \
- { \
- const uint32_t uv0 = (3 * tl_uv + l_uv + 0x00020002u) >> 2; \
- FUNC(top_y[len - 1], uv0 & 0xff, (uv0 >> 16), \
- top_dst + (len - 1) * XSTEP); \
- } \
- if (bottom_y != NULL) { \
- const uint32_t uv0 = (3 * l_uv + tl_uv + 0x00020002u) >> 2; \
- FUNC(bottom_y[len - 1], uv0 & 0xff, (uv0 >> 16), \
- bottom_dst + (len - 1) * XSTEP); \
- } \
- } \
-}
-
-// All variants implemented.
-UPSAMPLE_FUNC(UpsampleRgbaLinePair, YuvToRgba, 4)
-UPSAMPLE_FUNC(UpsampleBgraLinePair, YuvToBgra, 4)
-#if !defined(WEBP_REDUCE_CSP)
-UPSAMPLE_FUNC(UpsampleRgbLinePair, YuvToRgb, 3)
-UPSAMPLE_FUNC(UpsampleBgrLinePair, YuvToBgr, 3)
-UPSAMPLE_FUNC(UpsampleArgbLinePair, YuvToArgb, 4)
-UPSAMPLE_FUNC(UpsampleRgba4444LinePair, YuvToRgba4444, 2)
-UPSAMPLE_FUNC(UpsampleRgb565LinePair, YuvToRgb565, 2)
-#endif // WEBP_REDUCE_CSP
-
-#undef LOAD_UV
-#undef UPSAMPLE_FUNC
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void WebPInitUpsamplersMIPSdspR2(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void WebPInitUpsamplersMIPSdspR2(void) {
- WebPUpsamplers[MODE_RGBA] = UpsampleRgbaLinePair;
- WebPUpsamplers[MODE_BGRA] = UpsampleBgraLinePair;
- WebPUpsamplers[MODE_rgbA] = UpsampleRgbaLinePair;
- WebPUpsamplers[MODE_bgrA] = UpsampleBgraLinePair;
-#if !defined(WEBP_REDUCE_CSP)
- WebPUpsamplers[MODE_RGB] = UpsampleRgbLinePair;
- WebPUpsamplers[MODE_BGR] = UpsampleBgrLinePair;
- WebPUpsamplers[MODE_ARGB] = UpsampleArgbLinePair;
- WebPUpsamplers[MODE_RGBA_4444] = UpsampleRgba4444LinePair;
- WebPUpsamplers[MODE_RGB_565] = UpsampleRgb565LinePair;
- WebPUpsamplers[MODE_Argb] = UpsampleArgbLinePair;
- WebPUpsamplers[MODE_rgbA_4444] = UpsampleRgba4444LinePair;
-#endif // WEBP_REDUCE_CSP
-}
-
-#endif // FANCY_UPSAMPLING
-
-//------------------------------------------------------------------------------
-// YUV444 converter
-
-#define YUV444_FUNC(FUNC_NAME, FUNC, XSTEP) \
-static void FUNC_NAME(const uint8_t* y, const uint8_t* u, const uint8_t* v, \
- uint8_t* dst, int len) { \
- int i; \
- for (i = 0; i < len; ++i) FUNC(y[i], u[i], v[i], &dst[i * XSTEP]); \
-}
-
-YUV444_FUNC(Yuv444ToRgba, YuvToRgba, 4)
-YUV444_FUNC(Yuv444ToBgra, YuvToBgra, 4)
-#if !defined(WEBP_REDUCE_CSP)
-YUV444_FUNC(Yuv444ToRgb, YuvToRgb, 3)
-YUV444_FUNC(Yuv444ToBgr, YuvToBgr, 3)
-YUV444_FUNC(Yuv444ToArgb, YuvToArgb, 4)
-YUV444_FUNC(Yuv444ToRgba4444, YuvToRgba4444, 2)
-YUV444_FUNC(Yuv444ToRgb565, YuvToRgb565, 2)
-#endif // WEBP_REDUCE_CSP
-
-#undef YUV444_FUNC
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void WebPInitYUV444ConvertersMIPSdspR2(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void WebPInitYUV444ConvertersMIPSdspR2(void) {
- WebPYUV444Converters[MODE_RGBA] = Yuv444ToRgba;
- WebPYUV444Converters[MODE_BGRA] = Yuv444ToBgra;
- WebPYUV444Converters[MODE_rgbA] = Yuv444ToRgba;
- WebPYUV444Converters[MODE_bgrA] = Yuv444ToBgra;
-#if !defined(WEBP_REDUCE_CSP)
- WebPYUV444Converters[MODE_RGB] = Yuv444ToRgb;
- WebPYUV444Converters[MODE_BGR] = Yuv444ToBgr;
- WebPYUV444Converters[MODE_ARGB] = Yuv444ToArgb;
- WebPYUV444Converters[MODE_RGBA_4444] = Yuv444ToRgba4444;
- WebPYUV444Converters[MODE_RGB_565] = Yuv444ToRgb565;
- WebPYUV444Converters[MODE_Argb] = Yuv444ToArgb;
- WebPYUV444Converters[MODE_rgbA_4444] = Yuv444ToRgba4444;
-#endif // WEBP_REDUCE_CSP
-}
-
-#else // !WEBP_USE_MIPS_DSP_R2
-
-WEBP_DSP_INIT_STUB(WebPInitYUV444ConvertersMIPSdspR2)
-
-#endif // WEBP_USE_MIPS_DSP_R2
-
-#if !(defined(FANCY_UPSAMPLING) && defined(WEBP_USE_MIPS_DSP_R2))
-WEBP_DSP_INIT_STUB(WebPInitUpsamplersMIPSdspR2)
-#endif
diff --git a/contrib/libs/libwebp/dsp/upsampling_msa.c b/contrib/libs/libwebp/dsp/upsampling_msa.c
deleted file mode 100644
index 8c253f4094..0000000000
--- a/contrib/libs/libwebp/dsp/upsampling_msa.c
+++ /dev/null
@@ -1,688 +0,0 @@
-// Copyright 2016 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// MSA version of YUV to RGB upsampling functions.
-//
-// Author: Prashant Patil (prashant.patil@imgtec.com)
-
-#include <string.h>
-#include "./dsp.h"
-
-#if defined(WEBP_USE_MSA)
-
-#include "./msa_macro.h"
-#include "./yuv.h"
-
-#ifdef FANCY_UPSAMPLING
-
-#define ILVR_UW2(in, out0, out1) do { \
- const v8i16 t0 = (v8i16)__msa_ilvr_b((v16i8)zero, (v16i8)in); \
- out0 = (v4u32)__msa_ilvr_h((v8i16)zero, t0); \
- out1 = (v4u32)__msa_ilvl_h((v8i16)zero, t0); \
-} while (0)
-
-#define ILVRL_UW4(in, out0, out1, out2, out3) do { \
- v16u8 t0, t1; \
- ILVRL_B2_UB(zero, in, t0, t1); \
- ILVRL_H2_UW(zero, t0, out0, out1); \
- ILVRL_H2_UW(zero, t1, out2, out3); \
-} while (0)
-
-#define MULTHI_16(in0, in1, in2, in3, cnst, out0, out1) do { \
- const v4i32 const0 = (v4i32)__msa_fill_w(cnst * 256); \
- v4u32 temp0, temp1, temp2, temp3; \
- MUL4(in0, const0, in1, const0, in2, const0, in3, const0, \
- temp0, temp1, temp2, temp3); \
- PCKOD_H2_UH(temp1, temp0, temp3, temp2, out0, out1); \
-} while (0)
-
-#define MULTHI_8(in0, in1, cnst, out0) do { \
- const v4i32 const0 = (v4i32)__msa_fill_w(cnst * 256); \
- v4u32 temp0, temp1; \
- MUL2(in0, const0, in1, const0, temp0, temp1); \
- out0 = (v8u16)__msa_pckod_h((v8i16)temp1, (v8i16)temp0); \
-} while (0)
-
-#define CALC_R16(y0, y1, v0, v1, dst) do { \
- const v8i16 const_a = (v8i16)__msa_fill_h(14234); \
- const v8i16 a0 = __msa_adds_s_h((v8i16)y0, (v8i16)v0); \
- const v8i16 a1 = __msa_adds_s_h((v8i16)y1, (v8i16)v1); \
- v8i16 b0 = __msa_subs_s_h(a0, const_a); \
- v8i16 b1 = __msa_subs_s_h(a1, const_a); \
- SRAI_H2_SH(b0, b1, 6); \
- CLIP_SH2_0_255(b0, b1); \
- dst = (v16u8)__msa_pckev_b((v16i8)b1, (v16i8)b0); \
-} while (0)
-
-#define CALC_R8(y0, v0, dst) do { \
- const v8i16 const_a = (v8i16)__msa_fill_h(14234); \
- const v8i16 a0 = __msa_adds_s_h((v8i16)y0, (v8i16)v0); \
- v8i16 b0 = __msa_subs_s_h(a0, const_a); \
- b0 = SRAI_H(b0, 6); \
- CLIP_SH_0_255(b0); \
- dst = (v16u8)__msa_pckev_b((v16i8)b0, (v16i8)b0); \
-} while (0)
-
-#define CALC_G16(y0, y1, u0, u1, v0, v1, dst) do { \
- const v8i16 const_a = (v8i16)__msa_fill_h(8708); \
- v8i16 a0 = __msa_subs_s_h((v8i16)y0, (v8i16)u0); \
- v8i16 a1 = __msa_subs_s_h((v8i16)y1, (v8i16)u1); \
- const v8i16 b0 = __msa_subs_s_h(a0, (v8i16)v0); \
- const v8i16 b1 = __msa_subs_s_h(a1, (v8i16)v1); \
- a0 = __msa_adds_s_h(b0, const_a); \
- a1 = __msa_adds_s_h(b1, const_a); \
- SRAI_H2_SH(a0, a1, 6); \
- CLIP_SH2_0_255(a0, a1); \
- dst = (v16u8)__msa_pckev_b((v16i8)a1, (v16i8)a0); \
-} while (0)
-
-#define CALC_G8(y0, u0, v0, dst) do { \
- const v8i16 const_a = (v8i16)__msa_fill_h(8708); \
- v8i16 a0 = __msa_subs_s_h((v8i16)y0, (v8i16)u0); \
- const v8i16 b0 = __msa_subs_s_h(a0, (v8i16)v0); \
- a0 = __msa_adds_s_h(b0, const_a); \
- a0 = SRAI_H(a0, 6); \
- CLIP_SH_0_255(a0); \
- dst = (v16u8)__msa_pckev_b((v16i8)a0, (v16i8)a0); \
-} while (0)
-
-#define CALC_B16(y0, y1, u0, u1, dst) do { \
- const v8u16 const_a = (v8u16)__msa_fill_h(17685); \
- const v8u16 a0 = __msa_adds_u_h((v8u16)y0, u0); \
- const v8u16 a1 = __msa_adds_u_h((v8u16)y1, u1); \
- v8u16 b0 = __msa_subs_u_h(a0, const_a); \
- v8u16 b1 = __msa_subs_u_h(a1, const_a); \
- SRAI_H2_UH(b0, b1, 6); \
- CLIP_UH2_0_255(b0, b1); \
- dst = (v16u8)__msa_pckev_b((v16i8)b1, (v16i8)b0); \
-} while (0)
-
-#define CALC_B8(y0, u0, dst) do { \
- const v8u16 const_a = (v8u16)__msa_fill_h(17685); \
- const v8u16 a0 = __msa_adds_u_h((v8u16)y0, u0); \
- v8u16 b0 = __msa_subs_u_h(a0, const_a); \
- b0 = SRAI_H(b0, 6); \
- CLIP_UH_0_255(b0); \
- dst = (v16u8)__msa_pckev_b((v16i8)b0, (v16i8)b0); \
-} while (0)
-
-#define CALC_RGB16(y, u, v, R, G, B) do { \
- const v16u8 zero = { 0 }; \
- v8u16 y0, y1, u0, u1, v0, v1; \
- v4u32 p0, p1, p2, p3; \
- const v16u8 in_y = LD_UB(y); \
- const v16u8 in_u = LD_UB(u); \
- const v16u8 in_v = LD_UB(v); \
- ILVRL_UW4(in_y, p0, p1, p2, p3); \
- MULTHI_16(p0, p1, p2, p3, 19077, y0, y1); \
- ILVRL_UW4(in_v, p0, p1, p2, p3); \
- MULTHI_16(p0, p1, p2, p3, 26149, v0, v1); \
- CALC_R16(y0, y1, v0, v1, R); \
- MULTHI_16(p0, p1, p2, p3, 13320, v0, v1); \
- ILVRL_UW4(in_u, p0, p1, p2, p3); \
- MULTHI_16(p0, p1, p2, p3, 6419, u0, u1); \
- CALC_G16(y0, y1, u0, u1, v0, v1, G); \
- MULTHI_16(p0, p1, p2, p3, 33050, u0, u1); \
- CALC_B16(y0, y1, u0, u1, B); \
-} while (0)
-
-#define CALC_RGB8(y, u, v, R, G, B) do { \
- const v16u8 zero = { 0 }; \
- v8u16 y0, u0, v0; \
- v4u32 p0, p1; \
- const v16u8 in_y = LD_UB(y); \
- const v16u8 in_u = LD_UB(u); \
- const v16u8 in_v = LD_UB(v); \
- ILVR_UW2(in_y, p0, p1); \
- MULTHI_8(p0, p1, 19077, y0); \
- ILVR_UW2(in_v, p0, p1); \
- MULTHI_8(p0, p1, 26149, v0); \
- CALC_R8(y0, v0, R); \
- MULTHI_8(p0, p1, 13320, v0); \
- ILVR_UW2(in_u, p0, p1); \
- MULTHI_8(p0, p1, 6419, u0); \
- CALC_G8(y0, u0, v0, G); \
- MULTHI_8(p0, p1, 33050, u0); \
- CALC_B8(y0, u0, B); \
-} while (0)
-
-#define STORE16_3(a0, a1, a2, dst) do { \
- const v16u8 mask0 = { 0, 1, 16, 2, 3, 17, 4, 5, 18, 6, 7, 19, \
- 8, 9, 20, 10 }; \
- const v16u8 mask1 = { 0, 21, 1, 2, 22, 3, 4, 23, 5, 6, 24, 7, \
- 8, 25, 9, 10 }; \
- const v16u8 mask2 = { 26, 0, 1, 27, 2, 3, 28, 4, 5, 29, 6, 7, \
- 30, 8, 9, 31 }; \
- v16u8 out0, out1, out2, tmp0, tmp1, tmp2; \
- ILVRL_B2_UB(a1, a0, tmp0, tmp1); \
- out0 = VSHF_UB(tmp0, a2, mask0); \
- tmp2 = SLDI_UB(tmp1, tmp0, 11); \
- out1 = VSHF_UB(tmp2, a2, mask1); \
- tmp2 = SLDI_UB(tmp1, tmp1, 6); \
- out2 = VSHF_UB(tmp2, a2, mask2); \
- ST_UB(out0, dst + 0); \
- ST_UB(out1, dst + 16); \
- ST_UB(out2, dst + 32); \
-} while (0)
-
-#define STORE8_3(a0, a1, a2, dst) do { \
- int64_t out_m; \
- const v16u8 mask0 = { 0, 1, 16, 2, 3, 17, 4, 5, 18, 6, 7, 19, \
- 8, 9, 20, 10 }; \
- const v16u8 mask1 = { 11, 21, 12, 13, 22, 14, 15, 23, \
- 255, 255, 255, 255, 255, 255, 255, 255 }; \
- const v16u8 tmp0 = (v16u8)__msa_ilvr_b((v16i8)a1, (v16i8)a0); \
- v16u8 out0, out1; \
- VSHF_B2_UB(tmp0, a2, tmp0, a2, mask0, mask1, out0, out1); \
- ST_UB(out0, dst); \
- out_m = __msa_copy_s_d((v2i64)out1, 0); \
- SD(out_m, dst + 16); \
-} while (0)
-
-#define STORE16_4(a0, a1, a2, a3, dst) do { \
- v16u8 tmp0, tmp1, tmp2, tmp3; \
- v16u8 out0, out1, out2, out3; \
- ILVRL_B2_UB(a1, a0, tmp0, tmp1); \
- ILVRL_B2_UB(a3, a2, tmp2, tmp3); \
- ILVRL_H2_UB(tmp2, tmp0, out0, out1); \
- ILVRL_H2_UB(tmp3, tmp1, out2, out3); \
- ST_UB(out0, dst + 0); \
- ST_UB(out1, dst + 16); \
- ST_UB(out2, dst + 32); \
- ST_UB(out3, dst + 48); \
-} while (0)
-
-#define STORE8_4(a0, a1, a2, a3, dst) do { \
- v16u8 tmp0, tmp1, tmp2, tmp3; \
- ILVR_B2_UB(a1, a0, a3, a2, tmp0, tmp1); \
- ILVRL_H2_UB(tmp1, tmp0, tmp2, tmp3); \
- ST_UB(tmp2, dst + 0); \
- ST_UB(tmp3, dst + 16); \
-} while (0)
-
-#define STORE2_16(a0, a1, dst) do { \
- v16u8 out0, out1; \
- ILVRL_B2_UB(a1, a0, out0, out1); \
- ST_UB(out0, dst + 0); \
- ST_UB(out1, dst + 16); \
-} while (0)
-
-#define STORE2_8(a0, a1, dst) do { \
- const v16u8 out0 = (v16u8)__msa_ilvr_b((v16i8)a1, (v16i8)a0); \
- ST_UB(out0, dst); \
-} while (0)
-
-#define CALC_RGBA4444(y, u, v, out0, out1, N, dst) do { \
- CALC_RGB##N(y, u, v, R, G, B); \
- tmp0 = ANDI_B(R, 0xf0); \
- tmp1 = SRAI_B(G, 4); \
- RG = tmp0 | tmp1; \
- tmp0 = ANDI_B(B, 0xf0); \
- BA = ORI_B(tmp0, 0x0f); \
- STORE2_##N(out0, out1, dst); \
-} while (0)
-
-#define CALC_RGB565(y, u, v, out0, out1, N, dst) do { \
- CALC_RGB##N(y, u, v, R, G, B); \
- tmp0 = ANDI_B(R, 0xf8); \
- tmp1 = SRAI_B(G, 5); \
- RG = tmp0 | tmp1; \
- tmp0 = SLLI_B(G, 3); \
- tmp1 = ANDI_B(tmp0, 0xe0); \
- tmp0 = SRAI_B(B, 3); \
- GB = tmp0 | tmp1; \
- STORE2_##N(out0, out1, dst); \
-} while (0)
-
-static WEBP_INLINE int Clip8(int v) {
- return v < 0 ? 0 : v > 255 ? 255 : v;
-}
-
-static void YuvToRgb(int y, int u, int v, uint8_t* const rgb) {
- const int y1 = MultHi(y, 19077);
- const int r1 = y1 + MultHi(v, 26149) - 14234;
- const int g1 = y1 - MultHi(u, 6419) - MultHi(v, 13320) + 8708;
- const int b1 = y1 + MultHi(u, 33050) - 17685;
- rgb[0] = Clip8(r1 >> 6);
- rgb[1] = Clip8(g1 >> 6);
- rgb[2] = Clip8(b1 >> 6);
-}
-
-static void YuvToBgr(int y, int u, int v, uint8_t* const bgr) {
- const int y1 = MultHi(y, 19077);
- const int r1 = y1 + MultHi(v, 26149) - 14234;
- const int g1 = y1 - MultHi(u, 6419) - MultHi(v, 13320) + 8708;
- const int b1 = y1 + MultHi(u, 33050) - 17685;
- bgr[0] = Clip8(b1 >> 6);
- bgr[1] = Clip8(g1 >> 6);
- bgr[2] = Clip8(r1 >> 6);
-}
-
-#if !defined(WEBP_REDUCE_CSP)
-static void YuvToRgb565(int y, int u, int v, uint8_t* const rgb) {
- const int y1 = MultHi(y, 19077);
- const int r1 = y1 + MultHi(v, 26149) - 14234;
- const int g1 = y1 - MultHi(u, 6419) - MultHi(v, 13320) + 8708;
- const int b1 = y1 + MultHi(u, 33050) - 17685;
- const int r = Clip8(r1 >> 6);
- const int g = Clip8(g1 >> 6);
- const int b = Clip8(b1 >> 6);
- const int rg = (r & 0xf8) | (g >> 5);
- const int gb = ((g << 3) & 0xe0) | (b >> 3);
-#if (WEBP_SWAP_16BIT_CSP == 1)
- rgb[0] = gb;
- rgb[1] = rg;
-#else
- rgb[0] = rg;
- rgb[1] = gb;
-#endif
-}
-
-static void YuvToRgba4444(int y, int u, int v, uint8_t* const argb) {
- const int y1 = MultHi(y, 19077);
- const int r1 = y1 + MultHi(v, 26149) - 14234;
- const int g1 = y1 - MultHi(u, 6419) - MultHi(v, 13320) + 8708;
- const int b1 = y1 + MultHi(u, 33050) - 17685;
- const int r = Clip8(r1 >> 6);
- const int g = Clip8(g1 >> 6);
- const int b = Clip8(b1 >> 6);
- const int rg = (r & 0xf0) | (g >> 4);
- const int ba = (b & 0xf0) | 0x0f; // overwrite the lower 4 bits
-#if (WEBP_SWAP_16BIT_CSP == 1)
- argb[0] = ba;
- argb[1] = rg;
-#else
- argb[0] = rg;
- argb[1] = ba;
-#endif
-}
-
-static void YuvToArgb(uint8_t y, uint8_t u, uint8_t v, uint8_t* const argb) {
- argb[0] = 0xff;
- YuvToRgb(y, u, v, argb + 1);
-}
-#endif // WEBP_REDUCE_CSP
-
-static void YuvToBgra(uint8_t y, uint8_t u, uint8_t v, uint8_t* const bgra) {
- YuvToBgr(y, u, v, bgra);
- bgra[3] = 0xff;
-}
-
-static void YuvToRgba(uint8_t y, uint8_t u, uint8_t v, uint8_t* const rgba) {
- YuvToRgb(y, u, v, rgba);
- rgba[3] = 0xff;
-}
-
-#if !defined(WEBP_REDUCE_CSP)
-static void YuvToRgbLine(const uint8_t* y, const uint8_t* u,
- const uint8_t* v, uint8_t* dst, int length) {
- v16u8 R, G, B;
- while (length >= 16) {
- CALC_RGB16(y, u, v, R, G, B);
- STORE16_3(R, G, B, dst);
- y += 16;
- u += 16;
- v += 16;
- dst += 16 * 3;
- length -= 16;
- }
- if (length > 8) {
- uint8_t temp[3 * 16] = { 0 };
- memcpy(temp, y, length * sizeof(*temp));
- CALC_RGB16(temp, u, v, R, G, B);
- STORE16_3(R, G, B, temp);
- memcpy(dst, temp, length * 3 * sizeof(*dst));
- } else if (length > 0) {
- uint8_t temp[3 * 8] = { 0 };
- memcpy(temp, y, length * sizeof(*temp));
- CALC_RGB8(temp, u, v, R, G, B);
- STORE8_3(R, G, B, temp);
- memcpy(dst, temp, length * 3 * sizeof(*dst));
- }
-}
-
-static void YuvToBgrLine(const uint8_t* y, const uint8_t* u,
- const uint8_t* v, uint8_t* dst, int length) {
- v16u8 R, G, B;
- while (length >= 16) {
- CALC_RGB16(y, u, v, R, G, B);
- STORE16_3(B, G, R, dst);
- y += 16;
- u += 16;
- v += 16;
- dst += 16 * 3;
- length -= 16;
- }
- if (length > 8) {
- uint8_t temp[3 * 16] = { 0 };
- memcpy(temp, y, length * sizeof(*temp));
- CALC_RGB16(temp, u, v, R, G, B);
- STORE16_3(B, G, R, temp);
- memcpy(dst, temp, length * 3 * sizeof(*dst));
- } else if (length > 0) {
- uint8_t temp[3 * 8] = { 0 };
- memcpy(temp, y, length * sizeof(*temp));
- CALC_RGB8(temp, u, v, R, G, B);
- STORE8_3(B, G, R, temp);
- memcpy(dst, temp, length * 3 * sizeof(*dst));
- }
-}
-#endif // WEBP_REDUCE_CSP
-
-static void YuvToRgbaLine(const uint8_t* y, const uint8_t* u,
- const uint8_t* v, uint8_t* dst, int length) {
- v16u8 R, G, B;
- const v16u8 A = (v16u8)__msa_ldi_b(ALPHAVAL);
- while (length >= 16) {
- CALC_RGB16(y, u, v, R, G, B);
- STORE16_4(R, G, B, A, dst);
- y += 16;
- u += 16;
- v += 16;
- dst += 16 * 4;
- length -= 16;
- }
- if (length > 8) {
- uint8_t temp[4 * 16] = { 0 };
- memcpy(temp, y, length * sizeof(*temp));
- CALC_RGB16(&temp[0], u, v, R, G, B);
- STORE16_4(R, G, B, A, temp);
- memcpy(dst, temp, length * 4 * sizeof(*dst));
- } else if (length > 0) {
- uint8_t temp[4 * 8] = { 0 };
- memcpy(temp, y, length * sizeof(*temp));
- CALC_RGB8(temp, u, v, R, G, B);
- STORE8_4(R, G, B, A, temp);
- memcpy(dst, temp, length * 4 * sizeof(*dst));
- }
-}
-
-static void YuvToBgraLine(const uint8_t* y, const uint8_t* u,
- const uint8_t* v, uint8_t* dst, int length) {
- v16u8 R, G, B;
- const v16u8 A = (v16u8)__msa_ldi_b(ALPHAVAL);
- while (length >= 16) {
- CALC_RGB16(y, u, v, R, G, B);
- STORE16_4(B, G, R, A, dst);
- y += 16;
- u += 16;
- v += 16;
- dst += 16 * 4;
- length -= 16;
- }
- if (length > 8) {
- uint8_t temp[4 * 16] = { 0 };
- memcpy(temp, y, length * sizeof(*temp));
- CALC_RGB16(temp, u, v, R, G, B);
- STORE16_4(B, G, R, A, temp);
- memcpy(dst, temp, length * 4 * sizeof(*dst));
- } else if (length > 0) {
- uint8_t temp[4 * 8] = { 0 };
- memcpy(temp, y, length * sizeof(*temp));
- CALC_RGB8(temp, u, v, R, G, B);
- STORE8_4(B, G, R, A, temp);
- memcpy(dst, temp, length * 4 * sizeof(*dst));
- }
-}
-
-#if !defined(WEBP_REDUCE_CSP)
-static void YuvToArgbLine(const uint8_t* y, const uint8_t* u,
- const uint8_t* v, uint8_t* dst, int length) {
- v16u8 R, G, B;
- const v16u8 A = (v16u8)__msa_ldi_b(ALPHAVAL);
- while (length >= 16) {
- CALC_RGB16(y, u, v, R, G, B);
- STORE16_4(A, R, G, B, dst);
- y += 16;
- u += 16;
- v += 16;
- dst += 16 * 4;
- length -= 16;
- }
- if (length > 8) {
- uint8_t temp[4 * 16] = { 0 };
- memcpy(temp, y, length * sizeof(*temp));
- CALC_RGB16(temp, u, v, R, G, B);
- STORE16_4(A, R, G, B, temp);
- memcpy(dst, temp, length * 4 * sizeof(*dst));
- } else if (length > 0) {
- uint8_t temp[4 * 8] = { 0 };
- memcpy(temp, y, length * sizeof(*temp));
- CALC_RGB8(temp, u, v, R, G, B);
- STORE8_4(A, R, G, B, temp);
- memcpy(dst, temp, length * 4 * sizeof(*dst));
- }
-}
-
-static void YuvToRgba4444Line(const uint8_t* y, const uint8_t* u,
- const uint8_t* v, uint8_t* dst, int length) {
- v16u8 R, G, B, RG, BA, tmp0, tmp1;
- while (length >= 16) {
-#if (WEBP_SWAP_16BIT_CSP == 1)
- CALC_RGBA4444(y, u, v, BA, RG, 16, dst);
-#else
- CALC_RGBA4444(y, u, v, RG, BA, 16, dst);
-#endif
- y += 16;
- u += 16;
- v += 16;
- dst += 16 * 2;
- length -= 16;
- }
- if (length > 8) {
- uint8_t temp[2 * 16] = { 0 };
- memcpy(temp, y, length * sizeof(*temp));
-#if (WEBP_SWAP_16BIT_CSP == 1)
- CALC_RGBA4444(temp, u, v, BA, RG, 16, temp);
-#else
- CALC_RGBA4444(temp, u, v, RG, BA, 16, temp);
-#endif
- memcpy(dst, temp, length * 2 * sizeof(*dst));
- } else if (length > 0) {
- uint8_t temp[2 * 8] = { 0 };
- memcpy(temp, y, length * sizeof(*temp));
-#if (WEBP_SWAP_16BIT_CSP == 1)
- CALC_RGBA4444(temp, u, v, BA, RG, 8, temp);
-#else
- CALC_RGBA4444(temp, u, v, RG, BA, 8, temp);
-#endif
- memcpy(dst, temp, length * 2 * sizeof(*dst));
- }
-}
-
-static void YuvToRgb565Line(const uint8_t* y, const uint8_t* u,
- const uint8_t* v, uint8_t* dst, int length) {
- v16u8 R, G, B, RG, GB, tmp0, tmp1;
- while (length >= 16) {
-#if (WEBP_SWAP_16BIT_CSP == 1)
- CALC_RGB565(y, u, v, GB, RG, 16, dst);
-#else
- CALC_RGB565(y, u, v, RG, GB, 16, dst);
-#endif
- y += 16;
- u += 16;
- v += 16;
- dst += 16 * 2;
- length -= 16;
- }
- if (length > 8) {
- uint8_t temp[2 * 16] = { 0 };
- memcpy(temp, y, length * sizeof(*temp));
-#if (WEBP_SWAP_16BIT_CSP == 1)
- CALC_RGB565(temp, u, v, GB, RG, 16, temp);
-#else
- CALC_RGB565(temp, u, v, RG, GB, 16, temp);
-#endif
- memcpy(dst, temp, length * 2 * sizeof(*dst));
- } else if (length > 0) {
- uint8_t temp[2 * 8] = { 0 };
- memcpy(temp, y, length * sizeof(*temp));
-#if (WEBP_SWAP_16BIT_CSP == 1)
- CALC_RGB565(temp, u, v, GB, RG, 8, temp);
-#else
- CALC_RGB565(temp, u, v, RG, GB, 8, temp);
-#endif
- memcpy(dst, temp, length * 2 * sizeof(*dst));
- }
-}
-#endif // WEBP_REDUCE_CSP
-
-#define UPSAMPLE_32PIXELS(a, b, c, d) do { \
- v16u8 s = __msa_aver_u_b(a, d); \
- v16u8 t = __msa_aver_u_b(b, c); \
- const v16u8 st = s ^ t; \
- v16u8 ad = a ^ d; \
- v16u8 bc = b ^ c; \
- v16u8 t0 = ad | bc; \
- v16u8 t1 = t0 | st; \
- v16u8 t2 = ANDI_B(t1, 1); \
- v16u8 t3 = __msa_aver_u_b(s, t); \
- const v16u8 k = t3 - t2; \
- v16u8 diag1, diag2; \
- AVER_UB2_UB(t, k, s, k, t0, t1); \
- bc = bc & st; \
- ad = ad & st; \
- t = t ^ k; \
- s = s ^ k; \
- t2 = bc | t; \
- t3 = ad | s; \
- t2 = ANDI_B(t2, 1); \
- t3 = ANDI_B(t3, 1); \
- SUB2(t0, t2, t1, t3, diag1, diag2); \
- AVER_UB2_UB(a, diag1, b, diag2, t0, t1); \
- ILVRL_B2_UB(t1, t0, a, b); \
- if (pbot_y != NULL) { \
- AVER_UB2_UB(c, diag2, d, diag1, t0, t1); \
- ILVRL_B2_UB(t1, t0, c, d); \
- } \
-} while (0)
-
-#define UPSAMPLE_FUNC(FUNC_NAME, FUNC, XSTEP) \
-static void FUNC_NAME(const uint8_t* top_y, const uint8_t* bot_y, \
- const uint8_t* top_u, const uint8_t* top_v, \
- const uint8_t* cur_u, const uint8_t* cur_v, \
- uint8_t* top_dst, uint8_t* bot_dst, int len) \
-{ \
- int size = (len - 1) >> 1; \
- uint8_t temp_u[64]; \
- uint8_t temp_v[64]; \
- const uint32_t tl_uv = ((top_u[0]) | ((top_v[0]) << 16)); \
- const uint32_t l_uv = ((cur_u[0]) | ((cur_v[0]) << 16)); \
- const uint32_t uv0 = (3 * tl_uv + l_uv + 0x00020002u) >> 2; \
- const uint8_t* ptop_y = &top_y[1]; \
- uint8_t* ptop_dst = top_dst + XSTEP; \
- const uint8_t* pbot_y = &bot_y[1]; \
- uint8_t* pbot_dst = bot_dst + XSTEP; \
- \
- FUNC(top_y[0], uv0 & 0xff, (uv0 >> 16), top_dst); \
- if (bot_y != NULL) { \
- const uint32_t uv1 = (3 * l_uv + tl_uv + 0x00020002u) >> 2; \
- FUNC(bot_y[0], uv1 & 0xff, (uv1 >> 16), bot_dst); \
- } \
- while (size >= 16) { \
- v16u8 tu0, tu1, tv0, tv1, cu0, cu1, cv0, cv1; \
- LD_UB2(top_u, 1, tu0, tu1); \
- LD_UB2(cur_u, 1, cu0, cu1); \
- LD_UB2(top_v, 1, tv0, tv1); \
- LD_UB2(cur_v, 1, cv0, cv1); \
- UPSAMPLE_32PIXELS(tu0, tu1, cu0, cu1); \
- UPSAMPLE_32PIXELS(tv0, tv1, cv0, cv1); \
- ST_UB4(tu0, tu1, cu0, cu1, &temp_u[0], 16); \
- ST_UB4(tv0, tv1, cv0, cv1, &temp_v[0], 16); \
- FUNC##Line(ptop_y, &temp_u[ 0], &temp_v[0], ptop_dst, 32); \
- if (bot_y != NULL) { \
- FUNC##Line(pbot_y, &temp_u[32], &temp_v[32], pbot_dst, 32); \
- } \
- ptop_y += 32; \
- pbot_y += 32; \
- ptop_dst += XSTEP * 32; \
- pbot_dst += XSTEP * 32; \
- top_u += 16; \
- top_v += 16; \
- cur_u += 16; \
- cur_v += 16; \
- size -= 16; \
- } \
- if (size > 0) { \
- v16u8 tu0, tu1, tv0, tv1, cu0, cu1, cv0, cv1; \
- memcpy(&temp_u[ 0], top_u, 17 * sizeof(uint8_t)); \
- memcpy(&temp_u[32], cur_u, 17 * sizeof(uint8_t)); \
- memcpy(&temp_v[ 0], top_v, 17 * sizeof(uint8_t)); \
- memcpy(&temp_v[32], cur_v, 17 * sizeof(uint8_t)); \
- LD_UB2(&temp_u[ 0], 1, tu0, tu1); \
- LD_UB2(&temp_u[32], 1, cu0, cu1); \
- LD_UB2(&temp_v[ 0], 1, tv0, tv1); \
- LD_UB2(&temp_v[32], 1, cv0, cv1); \
- UPSAMPLE_32PIXELS(tu0, tu1, cu0, cu1); \
- UPSAMPLE_32PIXELS(tv0, tv1, cv0, cv1); \
- ST_UB4(tu0, tu1, cu0, cu1, &temp_u[0], 16); \
- ST_UB4(tv0, tv1, cv0, cv1, &temp_v[0], 16); \
- FUNC##Line(ptop_y, &temp_u[ 0], &temp_v[0], ptop_dst, size * 2); \
- if (bot_y != NULL) { \
- FUNC##Line(pbot_y, &temp_u[32], &temp_v[32], pbot_dst, size * 2); \
- } \
- top_u += size; \
- top_v += size; \
- cur_u += size; \
- cur_v += size; \
- } \
- if (!(len & 1)) { \
- const uint32_t t0 = ((top_u[0]) | ((top_v[0]) << 16)); \
- const uint32_t c0 = ((cur_u[0]) | ((cur_v[0]) << 16)); \
- const uint32_t tmp0 = (3 * t0 + c0 + 0x00020002u) >> 2; \
- FUNC(top_y[len - 1], tmp0 & 0xff, (tmp0 >> 16), \
- top_dst + (len - 1) * XSTEP); \
- if (bot_y != NULL) { \
- const uint32_t tmp1 = (3 * c0 + t0 + 0x00020002u) >> 2; \
- FUNC(bot_y[len - 1], tmp1 & 0xff, (tmp1 >> 16), \
- bot_dst + (len - 1) * XSTEP); \
- } \
- } \
-}
-
-UPSAMPLE_FUNC(UpsampleRgbaLinePair, YuvToRgba, 4)
-UPSAMPLE_FUNC(UpsampleBgraLinePair, YuvToBgra, 4)
-#if !defined(WEBP_REDUCE_CSP)
-UPSAMPLE_FUNC(UpsampleRgbLinePair, YuvToRgb, 3)
-UPSAMPLE_FUNC(UpsampleBgrLinePair, YuvToBgr, 3)
-UPSAMPLE_FUNC(UpsampleArgbLinePair, YuvToArgb, 4)
-UPSAMPLE_FUNC(UpsampleRgba4444LinePair, YuvToRgba4444, 2)
-UPSAMPLE_FUNC(UpsampleRgb565LinePair, YuvToRgb565, 2)
-#endif // WEBP_REDUCE_CSP
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern WebPUpsampleLinePairFunc WebPUpsamplers[/* MODE_LAST */];
-
-extern void WebPInitUpsamplersMSA(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void WebPInitUpsamplersMSA(void) {
- WebPUpsamplers[MODE_RGBA] = UpsampleRgbaLinePair;
- WebPUpsamplers[MODE_BGRA] = UpsampleBgraLinePair;
- WebPUpsamplers[MODE_rgbA] = UpsampleRgbaLinePair;
- WebPUpsamplers[MODE_bgrA] = UpsampleBgraLinePair;
-#if !defined(WEBP_REDUCE_CSP)
- WebPUpsamplers[MODE_RGB] = UpsampleRgbLinePair;
- WebPUpsamplers[MODE_BGR] = UpsampleBgrLinePair;
- WebPUpsamplers[MODE_ARGB] = UpsampleArgbLinePair;
- WebPUpsamplers[MODE_Argb] = UpsampleArgbLinePair;
- WebPUpsamplers[MODE_RGB_565] = UpsampleRgb565LinePair;
- WebPUpsamplers[MODE_RGBA_4444] = UpsampleRgba4444LinePair;
- WebPUpsamplers[MODE_rgbA_4444] = UpsampleRgba4444LinePair;
-#endif // WEBP_REDUCE_CSP
-}
-
-#endif // FANCY_UPSAMPLING
-
-#endif // WEBP_USE_MSA
-
-#if !(defined(FANCY_UPSAMPLING) && defined(WEBP_USE_MSA))
-WEBP_DSP_INIT_STUB(WebPInitUpsamplersMSA)
-#endif
diff --git a/contrib/libs/libwebp/dsp/upsampling_neon.c b/contrib/libs/libwebp/dsp/upsampling_neon.c
deleted file mode 100644
index 5bd505b2c6..0000000000
--- a/contrib/libs/libwebp/dsp/upsampling_neon.c
+++ /dev/null
@@ -1,285 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// NEON version of YUV to RGB upsampling functions.
-//
-// Author: mans@mansr.com (Mans Rullgard)
-// Based on SSE code by: somnath@google.com (Somnath Banerjee)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_NEON)
-
-#include <assert.h>
-#include <arm_neon.h>
-#include <string.h>
-#include "./neon.h"
-#include "./yuv.h"
-
-#ifdef FANCY_UPSAMPLING
-
-//-----------------------------------------------------------------------------
-// U/V upsampling
-
-// Loads 9 pixels each from rows r1 and r2 and generates 16 pixels.
-#define UPSAMPLE_16PIXELS(r1, r2, out) do { \
- const uint8x8_t a = vld1_u8(r1 + 0); \
- const uint8x8_t b = vld1_u8(r1 + 1); \
- const uint8x8_t c = vld1_u8(r2 + 0); \
- const uint8x8_t d = vld1_u8(r2 + 1); \
- /* a + b + c + d */ \
- const uint16x8_t ad = vaddl_u8(a, d); \
- const uint16x8_t bc = vaddl_u8(b, c); \
- const uint16x8_t abcd = vaddq_u16(ad, bc); \
- /* 3a + b + c + 3d */ \
- const uint16x8_t al = vaddq_u16(abcd, vshlq_n_u16(ad, 1)); \
- /* a + 3b + 3c + d */ \
- const uint16x8_t bl = vaddq_u16(abcd, vshlq_n_u16(bc, 1)); \
- \
- const uint8x8_t diag2 = vshrn_n_u16(al, 3); \
- const uint8x8_t diag1 = vshrn_n_u16(bl, 3); \
- \
- const uint8x8_t A = vrhadd_u8(a, diag1); \
- const uint8x8_t B = vrhadd_u8(b, diag2); \
- const uint8x8_t C = vrhadd_u8(c, diag2); \
- const uint8x8_t D = vrhadd_u8(d, diag1); \
- \
- uint8x8x2_t A_B, C_D; \
- INIT_VECTOR2(A_B, A, B); \
- INIT_VECTOR2(C_D, C, D); \
- vst2_u8(out + 0, A_B); \
- vst2_u8(out + 32, C_D); \
-} while (0)
-
-// Turn the macro into a function for reducing code-size when non-critical
-static void Upsample16Pixels_NEON(const uint8_t* r1, const uint8_t* r2,
- uint8_t* out) {
- UPSAMPLE_16PIXELS(r1, r2, out);
-}
-
-#define UPSAMPLE_LAST_BLOCK(tb, bb, num_pixels, out) { \
- uint8_t r1[9], r2[9]; \
- memcpy(r1, (tb), (num_pixels)); \
- memcpy(r2, (bb), (num_pixels)); \
- /* replicate last byte */ \
- memset(r1 + (num_pixels), r1[(num_pixels) - 1], 9 - (num_pixels)); \
- memset(r2 + (num_pixels), r2[(num_pixels) - 1], 9 - (num_pixels)); \
- Upsample16Pixels_NEON(r1, r2, out); \
-}
-
-//-----------------------------------------------------------------------------
-// YUV->RGB conversion
-
-// note: we represent the 33050 large constant as 32768 + 282
-static const int16_t kCoeffs1[4] = { 19077, 26149, 6419, 13320 };
-
-#define v255 vdup_n_u8(255)
-
-#define STORE_Rgb(out, r, g, b) do { \
- uint8x8x3_t r_g_b; \
- INIT_VECTOR3(r_g_b, r, g, b); \
- vst3_u8(out, r_g_b); \
-} while (0)
-
-#define STORE_Bgr(out, r, g, b) do { \
- uint8x8x3_t b_g_r; \
- INIT_VECTOR3(b_g_r, b, g, r); \
- vst3_u8(out, b_g_r); \
-} while (0)
-
-#define STORE_Rgba(out, r, g, b) do { \
- uint8x8x4_t r_g_b_v255; \
- INIT_VECTOR4(r_g_b_v255, r, g, b, v255); \
- vst4_u8(out, r_g_b_v255); \
-} while (0)
-
-#define STORE_Bgra(out, r, g, b) do { \
- uint8x8x4_t b_g_r_v255; \
- INIT_VECTOR4(b_g_r_v255, b, g, r, v255); \
- vst4_u8(out, b_g_r_v255); \
-} while (0)
-
-#define STORE_Argb(out, r, g, b) do { \
- uint8x8x4_t v255_r_g_b; \
- INIT_VECTOR4(v255_r_g_b, v255, r, g, b); \
- vst4_u8(out, v255_r_g_b); \
-} while (0)
-
-#if !defined(WEBP_SWAP_16BIT_CSP)
-#define ZIP_U8(lo, hi) vzip_u8((lo), (hi))
-#else
-#define ZIP_U8(lo, hi) vzip_u8((hi), (lo))
-#endif
-
-#define STORE_Rgba4444(out, r, g, b) do { \
- const uint8x8_t rg = vsri_n_u8(r, g, 4); /* shift g, insert r */ \
- const uint8x8_t ba = vsri_n_u8(b, v255, 4); /* shift a, insert b */ \
- const uint8x8x2_t rgba4444 = ZIP_U8(rg, ba); \
- vst1q_u8(out, vcombine_u8(rgba4444.val[0], rgba4444.val[1])); \
-} while (0)
-
-#define STORE_Rgb565(out, r, g, b) do { \
- const uint8x8_t rg = vsri_n_u8(r, g, 5); /* shift g and insert r */ \
- const uint8x8_t g1 = vshl_n_u8(g, 3); /* pre-shift g: 3bits */ \
- const uint8x8_t gb = vsri_n_u8(g1, b, 3); /* shift b and insert g */ \
- const uint8x8x2_t rgb565 = ZIP_U8(rg, gb); \
- vst1q_u8(out, vcombine_u8(rgb565.val[0], rgb565.val[1])); \
-} while (0)
-
-#define CONVERT8(FMT, XSTEP, N, src_y, src_uv, out, cur_x) do { \
- int i; \
- for (i = 0; i < N; i += 8) { \
- const int off = ((cur_x) + i) * XSTEP; \
- const uint8x8_t y = vld1_u8((src_y) + (cur_x) + i); \
- const uint8x8_t u = vld1_u8((src_uv) + i + 0); \
- const uint8x8_t v = vld1_u8((src_uv) + i + 16); \
- const int16x8_t Y0 = vreinterpretq_s16_u16(vshll_n_u8(y, 7)); \
- const int16x8_t U0 = vreinterpretq_s16_u16(vshll_n_u8(u, 7)); \
- const int16x8_t V0 = vreinterpretq_s16_u16(vshll_n_u8(v, 7)); \
- const int16x8_t Y1 = vqdmulhq_lane_s16(Y0, coeff1, 0); \
- const int16x8_t R0 = vqdmulhq_lane_s16(V0, coeff1, 1); \
- const int16x8_t G0 = vqdmulhq_lane_s16(U0, coeff1, 2); \
- const int16x8_t G1 = vqdmulhq_lane_s16(V0, coeff1, 3); \
- const int16x8_t B0 = vqdmulhq_n_s16(U0, 282); \
- const int16x8_t R1 = vqaddq_s16(Y1, R_Rounder); \
- const int16x8_t G2 = vqaddq_s16(Y1, G_Rounder); \
- const int16x8_t B1 = vqaddq_s16(Y1, B_Rounder); \
- const int16x8_t R2 = vqaddq_s16(R0, R1); \
- const int16x8_t G3 = vqaddq_s16(G0, G1); \
- const int16x8_t B2 = vqaddq_s16(B0, B1); \
- const int16x8_t G4 = vqsubq_s16(G2, G3); \
- const int16x8_t B3 = vqaddq_s16(B2, U0); \
- const uint8x8_t R = vqshrun_n_s16(R2, YUV_FIX2); \
- const uint8x8_t G = vqshrun_n_s16(G4, YUV_FIX2); \
- const uint8x8_t B = vqshrun_n_s16(B3, YUV_FIX2); \
- STORE_ ## FMT(out + off, R, G, B); \
- } \
-} while (0)
-
-#define CONVERT1(FUNC, XSTEP, N, src_y, src_uv, rgb, cur_x) { \
- int i; \
- for (i = 0; i < N; i++) { \
- const int off = ((cur_x) + i) * XSTEP; \
- const int y = src_y[(cur_x) + i]; \
- const int u = (src_uv)[i]; \
- const int v = (src_uv)[i + 16]; \
- FUNC(y, u, v, rgb + off); \
- } \
-}
-
-#define CONVERT2RGB_8(FMT, XSTEP, top_y, bottom_y, uv, \
- top_dst, bottom_dst, cur_x, len) { \
- CONVERT8(FMT, XSTEP, len, top_y, uv, top_dst, cur_x); \
- if (bottom_y != NULL) { \
- CONVERT8(FMT, XSTEP, len, bottom_y, (uv) + 32, bottom_dst, cur_x); \
- } \
-}
-
-#define CONVERT2RGB_1(FUNC, XSTEP, top_y, bottom_y, uv, \
- top_dst, bottom_dst, cur_x, len) { \
- CONVERT1(FUNC, XSTEP, len, top_y, uv, top_dst, cur_x); \
- if (bottom_y != NULL) { \
- CONVERT1(FUNC, XSTEP, len, bottom_y, (uv) + 32, bottom_dst, cur_x); \
- } \
-}
-
-#define NEON_UPSAMPLE_FUNC(FUNC_NAME, FMT, XSTEP) \
-static void FUNC_NAME(const uint8_t* top_y, const uint8_t* bottom_y, \
- const uint8_t* top_u, const uint8_t* top_v, \
- const uint8_t* cur_u, const uint8_t* cur_v, \
- uint8_t* top_dst, uint8_t* bottom_dst, int len) { \
- int block; \
- /* 16 byte aligned array to cache reconstructed u and v */ \
- uint8_t uv_buf[2 * 32 + 15]; \
- uint8_t* const r_uv = (uint8_t*)((uintptr_t)(uv_buf + 15) & ~15); \
- const int uv_len = (len + 1) >> 1; \
- /* 9 pixels must be read-able for each block */ \
- const int num_blocks = (uv_len - 1) >> 3; \
- const int leftover = uv_len - num_blocks * 8; \
- const int last_pos = 1 + 16 * num_blocks; \
- \
- const int u_diag = ((top_u[0] + cur_u[0]) >> 1) + 1; \
- const int v_diag = ((top_v[0] + cur_v[0]) >> 1) + 1; \
- \
- const int16x4_t coeff1 = vld1_s16(kCoeffs1); \
- const int16x8_t R_Rounder = vdupq_n_s16(-14234); \
- const int16x8_t G_Rounder = vdupq_n_s16(8708); \
- const int16x8_t B_Rounder = vdupq_n_s16(-17685); \
- \
- /* Treat the first pixel in regular way */ \
- assert(top_y != NULL); \
- { \
- const int u0 = (top_u[0] + u_diag) >> 1; \
- const int v0 = (top_v[0] + v_diag) >> 1; \
- VP8YuvTo ## FMT(top_y[0], u0, v0, top_dst); \
- } \
- if (bottom_y != NULL) { \
- const int u0 = (cur_u[0] + u_diag) >> 1; \
- const int v0 = (cur_v[0] + v_diag) >> 1; \
- VP8YuvTo ## FMT(bottom_y[0], u0, v0, bottom_dst); \
- } \
- \
- for (block = 0; block < num_blocks; ++block) { \
- UPSAMPLE_16PIXELS(top_u, cur_u, r_uv); \
- UPSAMPLE_16PIXELS(top_v, cur_v, r_uv + 16); \
- CONVERT2RGB_8(FMT, XSTEP, top_y, bottom_y, r_uv, \
- top_dst, bottom_dst, 16 * block + 1, 16); \
- top_u += 8; \
- cur_u += 8; \
- top_v += 8; \
- cur_v += 8; \
- } \
- \
- UPSAMPLE_LAST_BLOCK(top_u, cur_u, leftover, r_uv); \
- UPSAMPLE_LAST_BLOCK(top_v, cur_v, leftover, r_uv + 16); \
- CONVERT2RGB_1(VP8YuvTo ## FMT, XSTEP, top_y, bottom_y, r_uv, \
- top_dst, bottom_dst, last_pos, len - last_pos); \
-}
-
-// NEON variants of the fancy upsampler.
-NEON_UPSAMPLE_FUNC(UpsampleRgbaLinePair_NEON, Rgba, 4)
-NEON_UPSAMPLE_FUNC(UpsampleBgraLinePair_NEON, Bgra, 4)
-#if !defined(WEBP_REDUCE_CSP)
-NEON_UPSAMPLE_FUNC(UpsampleRgbLinePair_NEON, Rgb, 3)
-NEON_UPSAMPLE_FUNC(UpsampleBgrLinePair_NEON, Bgr, 3)
-NEON_UPSAMPLE_FUNC(UpsampleArgbLinePair_NEON, Argb, 4)
-NEON_UPSAMPLE_FUNC(UpsampleRgba4444LinePair_NEON, Rgba4444, 2)
-NEON_UPSAMPLE_FUNC(UpsampleRgb565LinePair_NEON, Rgb565, 2)
-#endif // WEBP_REDUCE_CSP
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern WebPUpsampleLinePairFunc WebPUpsamplers[/* MODE_LAST */];
-
-extern void WebPInitUpsamplersNEON(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void WebPInitUpsamplersNEON(void) {
- WebPUpsamplers[MODE_RGBA] = UpsampleRgbaLinePair_NEON;
- WebPUpsamplers[MODE_BGRA] = UpsampleBgraLinePair_NEON;
- WebPUpsamplers[MODE_rgbA] = UpsampleRgbaLinePair_NEON;
- WebPUpsamplers[MODE_bgrA] = UpsampleBgraLinePair_NEON;
-#if !defined(WEBP_REDUCE_CSP)
- WebPUpsamplers[MODE_RGB] = UpsampleRgbLinePair_NEON;
- WebPUpsamplers[MODE_BGR] = UpsampleBgrLinePair_NEON;
- WebPUpsamplers[MODE_ARGB] = UpsampleArgbLinePair_NEON;
- WebPUpsamplers[MODE_Argb] = UpsampleArgbLinePair_NEON;
- WebPUpsamplers[MODE_RGB_565] = UpsampleRgb565LinePair_NEON;
- WebPUpsamplers[MODE_RGBA_4444] = UpsampleRgba4444LinePair_NEON;
- WebPUpsamplers[MODE_rgbA_4444] = UpsampleRgba4444LinePair_NEON;
-#endif // WEBP_REDUCE_CSP
-}
-
-#endif // FANCY_UPSAMPLING
-
-#endif // WEBP_USE_NEON
-
-#if !(defined(FANCY_UPSAMPLING) && defined(WEBP_USE_NEON))
-WEBP_DSP_INIT_STUB(WebPInitUpsamplersNEON)
-#endif
diff --git a/contrib/libs/libwebp/dsp/upsampling_sse2.c b/contrib/libs/libwebp/dsp/upsampling_sse2.c
deleted file mode 100644
index 927e451d10..0000000000
--- a/contrib/libs/libwebp/dsp/upsampling_sse2.c
+++ /dev/null
@@ -1,267 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// SSE2 version of YUV to RGB upsampling functions.
-//
-// Author: somnath@google.com (Somnath Banerjee)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_SSE2)
-
-#include <assert.h>
-#include <emmintrin.h>
-#include <string.h>
-#include "./yuv.h"
-
-#ifdef FANCY_UPSAMPLING
-
-// We compute (9*a + 3*b + 3*c + d + 8) / 16 as follows
-// u = (9*a + 3*b + 3*c + d + 8) / 16
-// = (a + (a + 3*b + 3*c + d) / 8 + 1) / 2
-// = (a + m + 1) / 2
-// where m = (a + 3*b + 3*c + d) / 8
-// = ((a + b + c + d) / 2 + b + c) / 4
-//
-// Let's say k = (a + b + c + d) / 4.
-// We can compute k as
-// k = (s + t + 1) / 2 - ((a^d) | (b^c) | (s^t)) & 1
-// where s = (a + d + 1) / 2 and t = (b + c + 1) / 2
-//
-// Then m can be written as
-// m = (k + t + 1) / 2 - (((b^c) & (s^t)) | (k^t)) & 1
-
-// Computes out = (k + in + 1) / 2 - ((ij & (s^t)) | (k^in)) & 1
-#define GET_M(ij, in, out) do { \
- const __m128i tmp0 = _mm_avg_epu8(k, (in)); /* (k + in + 1) / 2 */ \
- const __m128i tmp1 = _mm_and_si128((ij), st); /* (ij) & (s^t) */ \
- const __m128i tmp2 = _mm_xor_si128(k, (in)); /* (k^in) */ \
- const __m128i tmp3 = _mm_or_si128(tmp1, tmp2); /* ((ij) & (s^t)) | (k^in) */\
- const __m128i tmp4 = _mm_and_si128(tmp3, one); /* & 1 -> lsb_correction */ \
- (out) = _mm_sub_epi8(tmp0, tmp4); /* (k + in + 1) / 2 - lsb_correction */ \
-} while (0)
-
-// pack and store two alternating pixel rows
-#define PACK_AND_STORE(a, b, da, db, out) do { \
- const __m128i t_a = _mm_avg_epu8(a, da); /* (9a + 3b + 3c + d + 8) / 16 */ \
- const __m128i t_b = _mm_avg_epu8(b, db); /* (3a + 9b + c + 3d + 8) / 16 */ \
- const __m128i t_1 = _mm_unpacklo_epi8(t_a, t_b); \
- const __m128i t_2 = _mm_unpackhi_epi8(t_a, t_b); \
- _mm_store_si128(((__m128i*)(out)) + 0, t_1); \
- _mm_store_si128(((__m128i*)(out)) + 1, t_2); \
-} while (0)
-
-// Loads 17 pixels each from rows r1 and r2 and generates 32 pixels.
-#define UPSAMPLE_32PIXELS(r1, r2, out) { \
- const __m128i one = _mm_set1_epi8(1); \
- const __m128i a = _mm_loadu_si128((const __m128i*)&(r1)[0]); \
- const __m128i b = _mm_loadu_si128((const __m128i*)&(r1)[1]); \
- const __m128i c = _mm_loadu_si128((const __m128i*)&(r2)[0]); \
- const __m128i d = _mm_loadu_si128((const __m128i*)&(r2)[1]); \
- \
- const __m128i s = _mm_avg_epu8(a, d); /* s = (a + d + 1) / 2 */ \
- const __m128i t = _mm_avg_epu8(b, c); /* t = (b + c + 1) / 2 */ \
- const __m128i st = _mm_xor_si128(s, t); /* st = s^t */ \
- \
- const __m128i ad = _mm_xor_si128(a, d); /* ad = a^d */ \
- const __m128i bc = _mm_xor_si128(b, c); /* bc = b^c */ \
- \
- const __m128i t1 = _mm_or_si128(ad, bc); /* (a^d) | (b^c) */ \
- const __m128i t2 = _mm_or_si128(t1, st); /* (a^d) | (b^c) | (s^t) */ \
- const __m128i t3 = _mm_and_si128(t2, one); /* (a^d) | (b^c) | (s^t) & 1 */ \
- const __m128i t4 = _mm_avg_epu8(s, t); \
- const __m128i k = _mm_sub_epi8(t4, t3); /* k = (a + b + c + d) / 4 */ \
- __m128i diag1, diag2; \
- \
- GET_M(bc, t, diag1); /* diag1 = (a + 3b + 3c + d) / 8 */ \
- GET_M(ad, s, diag2); /* diag2 = (3a + b + c + 3d) / 8 */ \
- \
- /* pack the alternate pixels */ \
- PACK_AND_STORE(a, b, diag1, diag2, (out) + 0); /* store top */ \
- PACK_AND_STORE(c, d, diag2, diag1, (out) + 2 * 32); /* store bottom */ \
-}
-
-// Turn the macro into a function for reducing code-size when non-critical
-static void Upsample32Pixels_SSE2(const uint8_t r1[], const uint8_t r2[],
- uint8_t* const out) {
- UPSAMPLE_32PIXELS(r1, r2, out);
-}
-
-#define UPSAMPLE_LAST_BLOCK(tb, bb, num_pixels, out) { \
- uint8_t r1[17], r2[17]; \
- memcpy(r1, (tb), (num_pixels)); \
- memcpy(r2, (bb), (num_pixels)); \
- /* replicate last byte */ \
- memset(r1 + (num_pixels), r1[(num_pixels) - 1], 17 - (num_pixels)); \
- memset(r2 + (num_pixels), r2[(num_pixels) - 1], 17 - (num_pixels)); \
- /* using the shared function instead of the macro saves ~3k code size */ \
- Upsample32Pixels_SSE2(r1, r2, out); \
-}
-
-#define CONVERT2RGB_32(FUNC, XSTEP, top_y, bottom_y, \
- top_dst, bottom_dst, cur_x) do { \
- FUNC##32_SSE2((top_y) + (cur_x), r_u, r_v, (top_dst) + (cur_x) * (XSTEP)); \
- if ((bottom_y) != NULL) { \
- FUNC##32_SSE2((bottom_y) + (cur_x), r_u + 64, r_v + 64, \
- (bottom_dst) + (cur_x) * (XSTEP)); \
- } \
-} while (0)
-
-#define SSE2_UPSAMPLE_FUNC(FUNC_NAME, FUNC, XSTEP) \
-static void FUNC_NAME(const uint8_t* top_y, const uint8_t* bottom_y, \
- const uint8_t* top_u, const uint8_t* top_v, \
- const uint8_t* cur_u, const uint8_t* cur_v, \
- uint8_t* top_dst, uint8_t* bottom_dst, int len) { \
- int uv_pos, pos; \
- /* 16byte-aligned array to cache reconstructed u and v */ \
- uint8_t uv_buf[14 * 32 + 15] = { 0 }; \
- uint8_t* const r_u = (uint8_t*)((uintptr_t)(uv_buf + 15) & ~15); \
- uint8_t* const r_v = r_u + 32; \
- \
- assert(top_y != NULL); \
- { /* Treat the first pixel in regular way */ \
- const int u_diag = ((top_u[0] + cur_u[0]) >> 1) + 1; \
- const int v_diag = ((top_v[0] + cur_v[0]) >> 1) + 1; \
- const int u0_t = (top_u[0] + u_diag) >> 1; \
- const int v0_t = (top_v[0] + v_diag) >> 1; \
- FUNC(top_y[0], u0_t, v0_t, top_dst); \
- if (bottom_y != NULL) { \
- const int u0_b = (cur_u[0] + u_diag) >> 1; \
- const int v0_b = (cur_v[0] + v_diag) >> 1; \
- FUNC(bottom_y[0], u0_b, v0_b, bottom_dst); \
- } \
- } \
- /* For UPSAMPLE_32PIXELS, 17 u/v values must be read-able for each block */ \
- for (pos = 1, uv_pos = 0; pos + 32 + 1 <= len; pos += 32, uv_pos += 16) { \
- UPSAMPLE_32PIXELS(top_u + uv_pos, cur_u + uv_pos, r_u); \
- UPSAMPLE_32PIXELS(top_v + uv_pos, cur_v + uv_pos, r_v); \
- CONVERT2RGB_32(FUNC, XSTEP, top_y, bottom_y, top_dst, bottom_dst, pos); \
- } \
- if (len > 1) { \
- const int left_over = ((len + 1) >> 1) - (pos >> 1); \
- uint8_t* const tmp_top_dst = r_u + 4 * 32; \
- uint8_t* const tmp_bottom_dst = tmp_top_dst + 4 * 32; \
- uint8_t* const tmp_top = tmp_bottom_dst + 4 * 32; \
- uint8_t* const tmp_bottom = (bottom_y == NULL) ? NULL : tmp_top + 32; \
- assert(left_over > 0); \
- UPSAMPLE_LAST_BLOCK(top_u + uv_pos, cur_u + uv_pos, left_over, r_u); \
- UPSAMPLE_LAST_BLOCK(top_v + uv_pos, cur_v + uv_pos, left_over, r_v); \
- memcpy(tmp_top, top_y + pos, len - pos); \
- if (bottom_y != NULL) memcpy(tmp_bottom, bottom_y + pos, len - pos); \
- CONVERT2RGB_32(FUNC, XSTEP, tmp_top, tmp_bottom, tmp_top_dst, \
- tmp_bottom_dst, 0); \
- memcpy(top_dst + pos * (XSTEP), tmp_top_dst, (len - pos) * (XSTEP)); \
- if (bottom_y != NULL) { \
- memcpy(bottom_dst + pos * (XSTEP), tmp_bottom_dst, \
- (len - pos) * (XSTEP)); \
- } \
- } \
-}
-
-// SSE2 variants of the fancy upsampler.
-SSE2_UPSAMPLE_FUNC(UpsampleRgbaLinePair_SSE2, VP8YuvToRgba, 4)
-SSE2_UPSAMPLE_FUNC(UpsampleBgraLinePair_SSE2, VP8YuvToBgra, 4)
-
-#if !defined(WEBP_REDUCE_CSP)
-SSE2_UPSAMPLE_FUNC(UpsampleRgbLinePair_SSE2, VP8YuvToRgb, 3)
-SSE2_UPSAMPLE_FUNC(UpsampleBgrLinePair_SSE2, VP8YuvToBgr, 3)
-SSE2_UPSAMPLE_FUNC(UpsampleArgbLinePair_SSE2, VP8YuvToArgb, 4)
-SSE2_UPSAMPLE_FUNC(UpsampleRgba4444LinePair_SSE2, VP8YuvToRgba4444, 2)
-SSE2_UPSAMPLE_FUNC(UpsampleRgb565LinePair_SSE2, VP8YuvToRgb565, 2)
-#endif // WEBP_REDUCE_CSP
-
-#undef GET_M
-#undef PACK_AND_STORE
-#undef UPSAMPLE_32PIXELS
-#undef UPSAMPLE_LAST_BLOCK
-#undef CONVERT2RGB
-#undef CONVERT2RGB_32
-#undef SSE2_UPSAMPLE_FUNC
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern WebPUpsampleLinePairFunc WebPUpsamplers[/* MODE_LAST */];
-
-extern void WebPInitUpsamplersSSE2(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void WebPInitUpsamplersSSE2(void) {
- WebPUpsamplers[MODE_RGBA] = UpsampleRgbaLinePair_SSE2;
- WebPUpsamplers[MODE_BGRA] = UpsampleBgraLinePair_SSE2;
- WebPUpsamplers[MODE_rgbA] = UpsampleRgbaLinePair_SSE2;
- WebPUpsamplers[MODE_bgrA] = UpsampleBgraLinePair_SSE2;
-#if !defined(WEBP_REDUCE_CSP)
- WebPUpsamplers[MODE_RGB] = UpsampleRgbLinePair_SSE2;
- WebPUpsamplers[MODE_BGR] = UpsampleBgrLinePair_SSE2;
- WebPUpsamplers[MODE_ARGB] = UpsampleArgbLinePair_SSE2;
- WebPUpsamplers[MODE_Argb] = UpsampleArgbLinePair_SSE2;
- WebPUpsamplers[MODE_RGB_565] = UpsampleRgb565LinePair_SSE2;
- WebPUpsamplers[MODE_RGBA_4444] = UpsampleRgba4444LinePair_SSE2;
- WebPUpsamplers[MODE_rgbA_4444] = UpsampleRgba4444LinePair_SSE2;
-#endif // WEBP_REDUCE_CSP
-}
-
-#endif // FANCY_UPSAMPLING
-
-//------------------------------------------------------------------------------
-
-extern WebPYUV444Converter WebPYUV444Converters[/* MODE_LAST */];
-extern void WebPInitYUV444ConvertersSSE2(void);
-
-#define YUV444_FUNC(FUNC_NAME, CALL, CALL_C, XSTEP) \
-extern void CALL_C(const uint8_t* y, const uint8_t* u, const uint8_t* v, \
- uint8_t* dst, int len); \
-static void FUNC_NAME(const uint8_t* y, const uint8_t* u, const uint8_t* v, \
- uint8_t* dst, int len) { \
- int i; \
- const int max_len = len & ~31; \
- for (i = 0; i < max_len; i += 32) { \
- CALL(y + i, u + i, v + i, dst + i * (XSTEP)); \
- } \
- if (i < len) { /* C-fallback */ \
- CALL_C(y + i, u + i, v + i, dst + i * (XSTEP), len - i); \
- } \
-}
-
-YUV444_FUNC(Yuv444ToRgba_SSE2, VP8YuvToRgba32_SSE2, WebPYuv444ToRgba_C, 4);
-YUV444_FUNC(Yuv444ToBgra_SSE2, VP8YuvToBgra32_SSE2, WebPYuv444ToBgra_C, 4);
-#if !defined(WEBP_REDUCE_CSP)
-YUV444_FUNC(Yuv444ToRgb_SSE2, VP8YuvToRgb32_SSE2, WebPYuv444ToRgb_C, 3);
-YUV444_FUNC(Yuv444ToBgr_SSE2, VP8YuvToBgr32_SSE2, WebPYuv444ToBgr_C, 3);
-YUV444_FUNC(Yuv444ToArgb_SSE2, VP8YuvToArgb32_SSE2, WebPYuv444ToArgb_C, 4)
-YUV444_FUNC(Yuv444ToRgba4444_SSE2, VP8YuvToRgba444432_SSE2, \
- WebPYuv444ToRgba4444_C, 2)
-YUV444_FUNC(Yuv444ToRgb565_SSE2, VP8YuvToRgb56532_SSE2, WebPYuv444ToRgb565_C, 2)
-#endif // WEBP_REDUCE_CSP
-
-WEBP_TSAN_IGNORE_FUNCTION void WebPInitYUV444ConvertersSSE2(void) {
- WebPYUV444Converters[MODE_RGBA] = Yuv444ToRgba_SSE2;
- WebPYUV444Converters[MODE_BGRA] = Yuv444ToBgra_SSE2;
- WebPYUV444Converters[MODE_rgbA] = Yuv444ToRgba_SSE2;
- WebPYUV444Converters[MODE_bgrA] = Yuv444ToBgra_SSE2;
-#if !defined(WEBP_REDUCE_CSP)
- WebPYUV444Converters[MODE_RGB] = Yuv444ToRgb_SSE2;
- WebPYUV444Converters[MODE_BGR] = Yuv444ToBgr_SSE2;
- WebPYUV444Converters[MODE_ARGB] = Yuv444ToArgb_SSE2;
- WebPYUV444Converters[MODE_RGBA_4444] = Yuv444ToRgba4444_SSE2;
- WebPYUV444Converters[MODE_RGB_565] = Yuv444ToRgb565_SSE2;
- WebPYUV444Converters[MODE_Argb] = Yuv444ToArgb_SSE2;
- WebPYUV444Converters[MODE_rgbA_4444] = Yuv444ToRgba4444_SSE2;
-#endif // WEBP_REDUCE_CSP
-}
-
-#else
-
-WEBP_DSP_INIT_STUB(WebPInitYUV444ConvertersSSE2)
-
-#endif // WEBP_USE_SSE2
-
-#if !(defined(FANCY_UPSAMPLING) && defined(WEBP_USE_SSE2))
-WEBP_DSP_INIT_STUB(WebPInitUpsamplersSSE2)
-#endif
diff --git a/contrib/libs/libwebp/dsp/upsampling_sse41.c b/contrib/libs/libwebp/dsp/upsampling_sse41.c
deleted file mode 100644
index 4dd5dbe92f..0000000000
--- a/contrib/libs/libwebp/dsp/upsampling_sse41.c
+++ /dev/null
@@ -1,239 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// SSE41 version of YUV to RGB upsampling functions.
-//
-// Author: somnath@google.com (Somnath Banerjee)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_SSE41)
-
-#include <assert.h>
-#include <smmintrin.h>
-#include <string.h>
-#include "./yuv.h"
-
-#ifdef FANCY_UPSAMPLING
-
-#if !defined(WEBP_REDUCE_CSP)
-
-// We compute (9*a + 3*b + 3*c + d + 8) / 16 as follows
-// u = (9*a + 3*b + 3*c + d + 8) / 16
-// = (a + (a + 3*b + 3*c + d) / 8 + 1) / 2
-// = (a + m + 1) / 2
-// where m = (a + 3*b + 3*c + d) / 8
-// = ((a + b + c + d) / 2 + b + c) / 4
-//
-// Let's say k = (a + b + c + d) / 4.
-// We can compute k as
-// k = (s + t + 1) / 2 - ((a^d) | (b^c) | (s^t)) & 1
-// where s = (a + d + 1) / 2 and t = (b + c + 1) / 2
-//
-// Then m can be written as
-// m = (k + t + 1) / 2 - (((b^c) & (s^t)) | (k^t)) & 1
-
-// Computes out = (k + in + 1) / 2 - ((ij & (s^t)) | (k^in)) & 1
-#define GET_M(ij, in, out) do { \
- const __m128i tmp0 = _mm_avg_epu8(k, (in)); /* (k + in + 1) / 2 */ \
- const __m128i tmp1 = _mm_and_si128((ij), st); /* (ij) & (s^t) */ \
- const __m128i tmp2 = _mm_xor_si128(k, (in)); /* (k^in) */ \
- const __m128i tmp3 = _mm_or_si128(tmp1, tmp2); /* ((ij) & (s^t)) | (k^in) */\
- const __m128i tmp4 = _mm_and_si128(tmp3, one); /* & 1 -> lsb_correction */ \
- (out) = _mm_sub_epi8(tmp0, tmp4); /* (k + in + 1) / 2 - lsb_correction */ \
-} while (0)
-
-// pack and store two alternating pixel rows
-#define PACK_AND_STORE(a, b, da, db, out) do { \
- const __m128i t_a = _mm_avg_epu8(a, da); /* (9a + 3b + 3c + d + 8) / 16 */ \
- const __m128i t_b = _mm_avg_epu8(b, db); /* (3a + 9b + c + 3d + 8) / 16 */ \
- const __m128i t_1 = _mm_unpacklo_epi8(t_a, t_b); \
- const __m128i t_2 = _mm_unpackhi_epi8(t_a, t_b); \
- _mm_store_si128(((__m128i*)(out)) + 0, t_1); \
- _mm_store_si128(((__m128i*)(out)) + 1, t_2); \
-} while (0)
-
-// Loads 17 pixels each from rows r1 and r2 and generates 32 pixels.
-#define UPSAMPLE_32PIXELS(r1, r2, out) { \
- const __m128i one = _mm_set1_epi8(1); \
- const __m128i a = _mm_loadu_si128((const __m128i*)&(r1)[0]); \
- const __m128i b = _mm_loadu_si128((const __m128i*)&(r1)[1]); \
- const __m128i c = _mm_loadu_si128((const __m128i*)&(r2)[0]); \
- const __m128i d = _mm_loadu_si128((const __m128i*)&(r2)[1]); \
- \
- const __m128i s = _mm_avg_epu8(a, d); /* s = (a + d + 1) / 2 */ \
- const __m128i t = _mm_avg_epu8(b, c); /* t = (b + c + 1) / 2 */ \
- const __m128i st = _mm_xor_si128(s, t); /* st = s^t */ \
- \
- const __m128i ad = _mm_xor_si128(a, d); /* ad = a^d */ \
- const __m128i bc = _mm_xor_si128(b, c); /* bc = b^c */ \
- \
- const __m128i t1 = _mm_or_si128(ad, bc); /* (a^d) | (b^c) */ \
- const __m128i t2 = _mm_or_si128(t1, st); /* (a^d) | (b^c) | (s^t) */ \
- const __m128i t3 = _mm_and_si128(t2, one); /* (a^d) | (b^c) | (s^t) & 1 */ \
- const __m128i t4 = _mm_avg_epu8(s, t); \
- const __m128i k = _mm_sub_epi8(t4, t3); /* k = (a + b + c + d) / 4 */ \
- __m128i diag1, diag2; \
- \
- GET_M(bc, t, diag1); /* diag1 = (a + 3b + 3c + d) / 8 */ \
- GET_M(ad, s, diag2); /* diag2 = (3a + b + c + 3d) / 8 */ \
- \
- /* pack the alternate pixels */ \
- PACK_AND_STORE(a, b, diag1, diag2, (out) + 0); /* store top */ \
- PACK_AND_STORE(c, d, diag2, diag1, (out) + 2 * 32); /* store bottom */ \
-}
-
-// Turn the macro into a function for reducing code-size when non-critical
-static void Upsample32Pixels_SSE41(const uint8_t r1[], const uint8_t r2[],
- uint8_t* const out) {
- UPSAMPLE_32PIXELS(r1, r2, out);
-}
-
-#define UPSAMPLE_LAST_BLOCK(tb, bb, num_pixels, out) { \
- uint8_t r1[17], r2[17]; \
- memcpy(r1, (tb), (num_pixels)); \
- memcpy(r2, (bb), (num_pixels)); \
- /* replicate last byte */ \
- memset(r1 + (num_pixels), r1[(num_pixels) - 1], 17 - (num_pixels)); \
- memset(r2 + (num_pixels), r2[(num_pixels) - 1], 17 - (num_pixels)); \
- /* using the shared function instead of the macro saves ~3k code size */ \
- Upsample32Pixels_SSE41(r1, r2, out); \
-}
-
-#define CONVERT2RGB_32(FUNC, XSTEP, top_y, bottom_y, \
- top_dst, bottom_dst, cur_x) do { \
- FUNC##32_SSE41((top_y) + (cur_x), r_u, r_v, (top_dst) + (cur_x) * (XSTEP)); \
- if ((bottom_y) != NULL) { \
- FUNC##32_SSE41((bottom_y) + (cur_x), r_u + 64, r_v + 64, \
- (bottom_dst) + (cur_x) * (XSTEP)); \
- } \
-} while (0)
-
-#define SSE4_UPSAMPLE_FUNC(FUNC_NAME, FUNC, XSTEP) \
-static void FUNC_NAME(const uint8_t* top_y, const uint8_t* bottom_y, \
- const uint8_t* top_u, const uint8_t* top_v, \
- const uint8_t* cur_u, const uint8_t* cur_v, \
- uint8_t* top_dst, uint8_t* bottom_dst, int len) { \
- int uv_pos, pos; \
- /* 16byte-aligned array to cache reconstructed u and v */ \
- uint8_t uv_buf[14 * 32 + 15] = { 0 }; \
- uint8_t* const r_u = (uint8_t*)((uintptr_t)(uv_buf + 15) & ~15); \
- uint8_t* const r_v = r_u + 32; \
- \
- assert(top_y != NULL); \
- { /* Treat the first pixel in regular way */ \
- const int u_diag = ((top_u[0] + cur_u[0]) >> 1) + 1; \
- const int v_diag = ((top_v[0] + cur_v[0]) >> 1) + 1; \
- const int u0_t = (top_u[0] + u_diag) >> 1; \
- const int v0_t = (top_v[0] + v_diag) >> 1; \
- FUNC(top_y[0], u0_t, v0_t, top_dst); \
- if (bottom_y != NULL) { \
- const int u0_b = (cur_u[0] + u_diag) >> 1; \
- const int v0_b = (cur_v[0] + v_diag) >> 1; \
- FUNC(bottom_y[0], u0_b, v0_b, bottom_dst); \
- } \
- } \
- /* For UPSAMPLE_32PIXELS, 17 u/v values must be read-able for each block */ \
- for (pos = 1, uv_pos = 0; pos + 32 + 1 <= len; pos += 32, uv_pos += 16) { \
- UPSAMPLE_32PIXELS(top_u + uv_pos, cur_u + uv_pos, r_u); \
- UPSAMPLE_32PIXELS(top_v + uv_pos, cur_v + uv_pos, r_v); \
- CONVERT2RGB_32(FUNC, XSTEP, top_y, bottom_y, top_dst, bottom_dst, pos); \
- } \
- if (len > 1) { \
- const int left_over = ((len + 1) >> 1) - (pos >> 1); \
- uint8_t* const tmp_top_dst = r_u + 4 * 32; \
- uint8_t* const tmp_bottom_dst = tmp_top_dst + 4 * 32; \
- uint8_t* const tmp_top = tmp_bottom_dst + 4 * 32; \
- uint8_t* const tmp_bottom = (bottom_y == NULL) ? NULL : tmp_top + 32; \
- assert(left_over > 0); \
- UPSAMPLE_LAST_BLOCK(top_u + uv_pos, cur_u + uv_pos, left_over, r_u); \
- UPSAMPLE_LAST_BLOCK(top_v + uv_pos, cur_v + uv_pos, left_over, r_v); \
- memcpy(tmp_top, top_y + pos, len - pos); \
- if (bottom_y != NULL) memcpy(tmp_bottom, bottom_y + pos, len - pos); \
- CONVERT2RGB_32(FUNC, XSTEP, tmp_top, tmp_bottom, tmp_top_dst, \
- tmp_bottom_dst, 0); \
- memcpy(top_dst + pos * (XSTEP), tmp_top_dst, (len - pos) * (XSTEP)); \
- if (bottom_y != NULL) { \
- memcpy(bottom_dst + pos * (XSTEP), tmp_bottom_dst, \
- (len - pos) * (XSTEP)); \
- } \
- } \
-}
-
-// SSE4 variants of the fancy upsampler.
-SSE4_UPSAMPLE_FUNC(UpsampleRgbLinePair_SSE41, VP8YuvToRgb, 3)
-SSE4_UPSAMPLE_FUNC(UpsampleBgrLinePair_SSE41, VP8YuvToBgr, 3)
-
-#undef GET_M
-#undef PACK_AND_STORE
-#undef UPSAMPLE_32PIXELS
-#undef UPSAMPLE_LAST_BLOCK
-#undef CONVERT2RGB
-#undef CONVERT2RGB_32
-#undef SSE4_UPSAMPLE_FUNC
-
-#endif // WEBP_REDUCE_CSP
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern WebPUpsampleLinePairFunc WebPUpsamplers[/* MODE_LAST */];
-
-extern void WebPInitUpsamplersSSE41(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void WebPInitUpsamplersSSE41(void) {
-#if !defined(WEBP_REDUCE_CSP)
- WebPUpsamplers[MODE_RGB] = UpsampleRgbLinePair_SSE41;
- WebPUpsamplers[MODE_BGR] = UpsampleBgrLinePair_SSE41;
-#endif // WEBP_REDUCE_CSP
-}
-
-#endif // FANCY_UPSAMPLING
-
-//------------------------------------------------------------------------------
-
-extern WebPYUV444Converter WebPYUV444Converters[/* MODE_LAST */];
-extern void WebPInitYUV444ConvertersSSE41(void);
-
-#define YUV444_FUNC(FUNC_NAME, CALL, CALL_C, XSTEP) \
-extern void CALL_C(const uint8_t* y, const uint8_t* u, const uint8_t* v, \
- uint8_t* dst, int len); \
-static void FUNC_NAME(const uint8_t* y, const uint8_t* u, const uint8_t* v, \
- uint8_t* dst, int len) { \
- int i; \
- const int max_len = len & ~31; \
- for (i = 0; i < max_len; i += 32) { \
- CALL(y + i, u + i, v + i, dst + i * (XSTEP)); \
- } \
- if (i < len) { /* C-fallback */ \
- CALL_C(y + i, u + i, v + i, dst + i * (XSTEP), len - i); \
- } \
-}
-
-#if !defined(WEBP_REDUCE_CSP)
-YUV444_FUNC(Yuv444ToRgb_SSE41, VP8YuvToRgb32_SSE41, WebPYuv444ToRgb_C, 3);
-YUV444_FUNC(Yuv444ToBgr_SSE41, VP8YuvToBgr32_SSE41, WebPYuv444ToBgr_C, 3);
-#endif // WEBP_REDUCE_CSP
-
-WEBP_TSAN_IGNORE_FUNCTION void WebPInitYUV444ConvertersSSE41(void) {
-#if !defined(WEBP_REDUCE_CSP)
- WebPYUV444Converters[MODE_RGB] = Yuv444ToRgb_SSE41;
- WebPYUV444Converters[MODE_BGR] = Yuv444ToBgr_SSE41;
-#endif // WEBP_REDUCE_CSP
-}
-
-#else
-
-WEBP_DSP_INIT_STUB(WebPInitYUV444ConvertersSSE41)
-
-#endif // WEBP_USE_SSE41
-
-#if !(defined(FANCY_UPSAMPLING) && defined(WEBP_USE_SSE41))
-WEBP_DSP_INIT_STUB(WebPInitUpsamplersSSE41)
-#endif
diff --git a/contrib/libs/libwebp/dsp/webpdsp/ya.make b/contrib/libs/libwebp/dsp/webpdsp/ya.make
deleted file mode 100644
index 451e2bacaf..0000000000
--- a/contrib/libs/libwebp/dsp/webpdsp/ya.make
+++ /dev/null
@@ -1,43 +0,0 @@
-# Generated by devtools/yamaker.
-
-LIBRARY()
-
-WITHOUT_LICENSE_TEXTS()
-
-VERSION(1.2.2)
-
-LICENSE(BSD-3-Clause)
-
-PEERDIR(
- contrib/libs/libwebp/dsp/webpdsp_mips32
- contrib/libs/libwebp/dsp/webpdsp_mips_dsp_r2
- contrib/libs/libwebp/dsp/webpdsp_msa
- contrib/libs/libwebp/dsp/webpdsp_neon
- contrib/libs/libwebp/dsp/webpdsp_sse2
- contrib/libs/libwebp/dsp/webpdsp_sse41
- contrib/libs/libwebp/dsp/webpdspdecode
-)
-
-ADDINCL(
- contrib/libs/libwebp/dsp
- contrib/libs/libwebp/webp
-)
-
-NO_COMPILER_WARNINGS()
-
-NO_RUNTIME()
-
-CFLAGS(
- -DHAVE_CONFIG_H
-)
-
-SRCDIR(contrib/libs/libwebp/dsp)
-
-SRCS(
- cost.c
- enc.c
- lossless_enc.c
- ssim.c
-)
-
-END()
diff --git a/contrib/libs/libwebp/dsp/webpdsp_mips32/ya.make b/contrib/libs/libwebp/dsp/webpdsp_mips32/ya.make
deleted file mode 100644
index f4fa8d36ab..0000000000
--- a/contrib/libs/libwebp/dsp/webpdsp_mips32/ya.make
+++ /dev/null
@@ -1,36 +0,0 @@
-# Generated by devtools/yamaker.
-
-LIBRARY()
-
-WITHOUT_LICENSE_TEXTS()
-
-VERSION(1.2.2)
-
-LICENSE(BSD-3-Clause)
-
-PEERDIR(
- contrib/libs/libwebp/dsp/webpdspdecode_mips32
-)
-
-ADDINCL(
- contrib/libs/libwebp/dsp
- contrib/libs/libwebp/webp
-)
-
-NO_COMPILER_WARNINGS()
-
-NO_RUNTIME()
-
-CFLAGS(
- -DHAVE_CONFIG_H
-)
-
-SRCDIR(contrib/libs/libwebp/dsp)
-
-SRCS(
- cost_mips32.c
- enc_mips32.c
- lossless_enc_mips32.c
-)
-
-END()
diff --git a/contrib/libs/libwebp/dsp/webpdsp_mips_dsp_r2/ya.make b/contrib/libs/libwebp/dsp/webpdsp_mips_dsp_r2/ya.make
deleted file mode 100644
index 8866ff250d..0000000000
--- a/contrib/libs/libwebp/dsp/webpdsp_mips_dsp_r2/ya.make
+++ /dev/null
@@ -1,36 +0,0 @@
-# Generated by devtools/yamaker.
-
-LIBRARY()
-
-WITHOUT_LICENSE_TEXTS()
-
-VERSION(1.2.2)
-
-LICENSE(BSD-3-Clause)
-
-PEERDIR(
- contrib/libs/libwebp/dsp/webpdspdecode_mips_dsp_r2
-)
-
-ADDINCL(
- contrib/libs/libwebp/dsp
- contrib/libs/libwebp/webp
-)
-
-NO_COMPILER_WARNINGS()
-
-NO_RUNTIME()
-
-CFLAGS(
- -DHAVE_CONFIG_H
-)
-
-SRCDIR(contrib/libs/libwebp/dsp)
-
-SRCS(
- cost_mips_dsp_r2.c
- enc_mips_dsp_r2.c
- lossless_enc_mips_dsp_r2.c
-)
-
-END()
diff --git a/contrib/libs/libwebp/dsp/webpdsp_msa/ya.make b/contrib/libs/libwebp/dsp/webpdsp_msa/ya.make
deleted file mode 100644
index 8c6c48398d..0000000000
--- a/contrib/libs/libwebp/dsp/webpdsp_msa/ya.make
+++ /dev/null
@@ -1,35 +0,0 @@
-# Generated by devtools/yamaker.
-
-LIBRARY()
-
-WITHOUT_LICENSE_TEXTS()
-
-VERSION(1.2.2)
-
-LICENSE(BSD-3-Clause)
-
-PEERDIR(
- contrib/libs/libwebp/dsp/webpdspdecode_msa
-)
-
-ADDINCL(
- contrib/libs/libwebp/dsp
- contrib/libs/libwebp/webp
-)
-
-NO_COMPILER_WARNINGS()
-
-NO_RUNTIME()
-
-CFLAGS(
- -DHAVE_CONFIG_H
-)
-
-SRCDIR(contrib/libs/libwebp/dsp)
-
-SRCS(
- enc_msa.c
- lossless_enc_msa.c
-)
-
-END()
diff --git a/contrib/libs/libwebp/dsp/webpdsp_neon/ya.make b/contrib/libs/libwebp/dsp/webpdsp_neon/ya.make
deleted file mode 100644
index 89a3ecf3dc..0000000000
--- a/contrib/libs/libwebp/dsp/webpdsp_neon/ya.make
+++ /dev/null
@@ -1,36 +0,0 @@
-# Generated by devtools/yamaker.
-
-LIBRARY()
-
-WITHOUT_LICENSE_TEXTS()
-
-VERSION(1.2.2)
-
-LICENSE(BSD-3-Clause)
-
-PEERDIR(
- contrib/libs/libwebp/dsp/webpdspdecode_neon
-)
-
-ADDINCL(
- contrib/libs/libwebp/dsp
- contrib/libs/libwebp/webp
-)
-
-NO_COMPILER_WARNINGS()
-
-NO_RUNTIME()
-
-CFLAGS(
- -DHAVE_CONFIG_H
-)
-
-SRCDIR(contrib/libs/libwebp/dsp)
-
-SRCS(
- cost_neon.c
- enc_neon.c
- lossless_enc_neon.c
-)
-
-END()
diff --git a/contrib/libs/libwebp/dsp/webpdsp_sse2/ya.make b/contrib/libs/libwebp/dsp/webpdsp_sse2/ya.make
deleted file mode 100644
index 4ab25b5c0d..0000000000
--- a/contrib/libs/libwebp/dsp/webpdsp_sse2/ya.make
+++ /dev/null
@@ -1,37 +0,0 @@
-# Generated by devtools/yamaker.
-
-LIBRARY()
-
-WITHOUT_LICENSE_TEXTS()
-
-VERSION(1.2.2)
-
-LICENSE(BSD-3-Clause)
-
-PEERDIR(
- contrib/libs/libwebp/dsp/webpdspdecode_sse2
-)
-
-ADDINCL(
- contrib/libs/libwebp/dsp
- contrib/libs/libwebp/webp
-)
-
-NO_COMPILER_WARNINGS()
-
-NO_RUNTIME()
-
-CFLAGS(
- -DHAVE_CONFIG_H
-)
-
-SRCDIR(contrib/libs/libwebp/dsp)
-
-SRCS(
- cost_sse2.c
- enc_sse2.c
- lossless_enc_sse2.c
- ssim_sse2.c
-)
-
-END()
diff --git a/contrib/libs/libwebp/dsp/webpdsp_sse41/ya.make b/contrib/libs/libwebp/dsp/webpdsp_sse41/ya.make
deleted file mode 100644
index 5e18d783b5..0000000000
--- a/contrib/libs/libwebp/dsp/webpdsp_sse41/ya.make
+++ /dev/null
@@ -1,35 +0,0 @@
-# Generated by devtools/yamaker.
-
-LIBRARY()
-
-WITHOUT_LICENSE_TEXTS()
-
-VERSION(1.2.2)
-
-LICENSE(BSD-3-Clause)
-
-PEERDIR(
- contrib/libs/libwebp/dsp/webpdspdecode_sse41
-)
-
-ADDINCL(
- contrib/libs/libwebp/dsp
- contrib/libs/libwebp/webp
-)
-
-NO_COMPILER_WARNINGS()
-
-NO_RUNTIME()
-
-CFLAGS(
- -DHAVE_CONFIG_H
-)
-
-SRCDIR(contrib/libs/libwebp/dsp)
-
-SRCS(
- enc_sse41.c
- lossless_enc_sse41.c
-)
-
-END()
diff --git a/contrib/libs/libwebp/dsp/webpdspdecode/ya.make b/contrib/libs/libwebp/dsp/webpdspdecode/ya.make
deleted file mode 100644
index 7767111018..0000000000
--- a/contrib/libs/libwebp/dsp/webpdspdecode/ya.make
+++ /dev/null
@@ -1,56 +0,0 @@
-# Generated by devtools/yamaker.
-
-LIBRARY()
-
-WITHOUT_LICENSE_TEXTS()
-
-VERSION(1.2.2)
-
-LICENSE(BSD-3-Clause)
-
-PEERDIR(
- contrib/libs/libwebp/dsp/webpdspdecode_mips32
- contrib/libs/libwebp/dsp/webpdspdecode_mips_dsp_r2
- contrib/libs/libwebp/dsp/webpdspdecode_msa
- contrib/libs/libwebp/dsp/webpdspdecode_neon
- contrib/libs/libwebp/dsp/webpdspdecode_sse2
- contrib/libs/libwebp/dsp/webpdspdecode_sse41
-)
-
-IF (OS_ANDROID)
- PEERDIR(
- contrib/libs/android_cpufeatures
- )
- ADDINCL(
- contrib/libs/android_cpufeatures
- )
-ENDIF()
-
-ADDINCL(
- contrib/libs/libwebp/dsp
- contrib/libs/libwebp/webp
-)
-
-NO_COMPILER_WARNINGS()
-
-NO_RUNTIME()
-
-CFLAGS(
- -DHAVE_CONFIG_H
-)
-
-SRCDIR(contrib/libs/libwebp/dsp)
-
-SRCS(
- alpha_processing.c
- cpu.c
- dec.c
- dec_clip_tables.c
- filters.c
- lossless.c
- rescaler.c
- upsampling.c
- yuv.c
-)
-
-END()
diff --git a/contrib/libs/libwebp/dsp/webpdspdecode_mips32/ya.make b/contrib/libs/libwebp/dsp/webpdspdecode_mips32/ya.make
deleted file mode 100644
index e494d1f6a2..0000000000
--- a/contrib/libs/libwebp/dsp/webpdspdecode_mips32/ya.make
+++ /dev/null
@@ -1,32 +0,0 @@
-# Generated by devtools/yamaker.
-
-LIBRARY()
-
-WITHOUT_LICENSE_TEXTS()
-
-VERSION(1.2.2)
-
-LICENSE(BSD-3-Clause)
-
-ADDINCL(
- contrib/libs/libwebp/dsp
- contrib/libs/libwebp/webp
-)
-
-NO_COMPILER_WARNINGS()
-
-NO_RUNTIME()
-
-CFLAGS(
- -DHAVE_CONFIG_H
-)
-
-SRCDIR(contrib/libs/libwebp/dsp)
-
-SRCS(
- dec_mips32.c
- rescaler_mips32.c
- yuv_mips32.c
-)
-
-END()
diff --git a/contrib/libs/libwebp/dsp/webpdspdecode_mips_dsp_r2/ya.make b/contrib/libs/libwebp/dsp/webpdspdecode_mips_dsp_r2/ya.make
deleted file mode 100644
index 1761341be1..0000000000
--- a/contrib/libs/libwebp/dsp/webpdspdecode_mips_dsp_r2/ya.make
+++ /dev/null
@@ -1,36 +0,0 @@
-# Generated by devtools/yamaker.
-
-LIBRARY()
-
-WITHOUT_LICENSE_TEXTS()
-
-VERSION(1.2.2)
-
-LICENSE(BSD-3-Clause)
-
-ADDINCL(
- contrib/libs/libwebp/dsp
- contrib/libs/libwebp/webp
-)
-
-NO_COMPILER_WARNINGS()
-
-NO_RUNTIME()
-
-CFLAGS(
- -DHAVE_CONFIG_H
-)
-
-SRCDIR(contrib/libs/libwebp/dsp)
-
-SRCS(
- alpha_processing_mips_dsp_r2.c
- dec_mips_dsp_r2.c
- filters_mips_dsp_r2.c
- lossless_mips_dsp_r2.c
- rescaler_mips_dsp_r2.c
- upsampling_mips_dsp_r2.c
- yuv_mips_dsp_r2.c
-)
-
-END()
diff --git a/contrib/libs/libwebp/dsp/webpdspdecode_msa/ya.make b/contrib/libs/libwebp/dsp/webpdspdecode_msa/ya.make
deleted file mode 100644
index 7e68320b87..0000000000
--- a/contrib/libs/libwebp/dsp/webpdspdecode_msa/ya.make
+++ /dev/null
@@ -1,34 +0,0 @@
-# Generated by devtools/yamaker.
-
-LIBRARY()
-
-WITHOUT_LICENSE_TEXTS()
-
-VERSION(1.2.2)
-
-LICENSE(BSD-3-Clause)
-
-ADDINCL(
- contrib/libs/libwebp/dsp
- contrib/libs/libwebp/webp
-)
-
-NO_COMPILER_WARNINGS()
-
-NO_RUNTIME()
-
-CFLAGS(
- -DHAVE_CONFIG_H
-)
-
-SRCDIR(contrib/libs/libwebp/dsp)
-
-SRCS(
- dec_msa.c
- filters_msa.c
- lossless_msa.c
- rescaler_msa.c
- upsampling_msa.c
-)
-
-END()
diff --git a/contrib/libs/libwebp/dsp/webpdspdecode_neon/ya.make b/contrib/libs/libwebp/dsp/webpdspdecode_neon/ya.make
deleted file mode 100644
index c5f5bfd3b6..0000000000
--- a/contrib/libs/libwebp/dsp/webpdspdecode_neon/ya.make
+++ /dev/null
@@ -1,36 +0,0 @@
-# Generated by devtools/yamaker.
-
-LIBRARY()
-
-WITHOUT_LICENSE_TEXTS()
-
-VERSION(1.2.2)
-
-LICENSE(BSD-3-Clause)
-
-ADDINCL(
- contrib/libs/libwebp/dsp
- contrib/libs/libwebp/webp
-)
-
-NO_COMPILER_WARNINGS()
-
-NO_RUNTIME()
-
-CFLAGS(
- -DHAVE_CONFIG_H
-)
-
-SRCDIR(contrib/libs/libwebp/dsp)
-
-SRCS(
- alpha_processing_neon.c
- dec_neon.c
- filters_neon.c
- lossless_neon.c
- rescaler_neon.c
- upsampling_neon.c
- yuv_neon.c
-)
-
-END()
diff --git a/contrib/libs/libwebp/dsp/webpdspdecode_sse2/ya.make b/contrib/libs/libwebp/dsp/webpdspdecode_sse2/ya.make
deleted file mode 100644
index b7bf7c13c7..0000000000
--- a/contrib/libs/libwebp/dsp/webpdspdecode_sse2/ya.make
+++ /dev/null
@@ -1,36 +0,0 @@
-# Generated by devtools/yamaker.
-
-LIBRARY()
-
-WITHOUT_LICENSE_TEXTS()
-
-VERSION(1.2.2)
-
-LICENSE(BSD-3-Clause)
-
-ADDINCL(
- contrib/libs/libwebp/dsp
- contrib/libs/libwebp/webp
-)
-
-NO_COMPILER_WARNINGS()
-
-NO_RUNTIME()
-
-CFLAGS(
- -DHAVE_CONFIG_H
-)
-
-SRCDIR(contrib/libs/libwebp/dsp)
-
-SRCS(
- alpha_processing_sse2.c
- dec_sse2.c
- filters_sse2.c
- lossless_sse2.c
- rescaler_sse2.c
- upsampling_sse2.c
- yuv_sse2.c
-)
-
-END()
diff --git a/contrib/libs/libwebp/dsp/webpdspdecode_sse41/ya.make b/contrib/libs/libwebp/dsp/webpdspdecode_sse41/ya.make
deleted file mode 100644
index ca1a1e7c3a..0000000000
--- a/contrib/libs/libwebp/dsp/webpdspdecode_sse41/ya.make
+++ /dev/null
@@ -1,34 +0,0 @@
-# Generated by devtools/yamaker.
-
-LIBRARY()
-
-WITHOUT_LICENSE_TEXTS()
-
-VERSION(1.2.2)
-
-LICENSE(BSD-3-Clause)
-
-ADDINCL(
- contrib/libs/libwebp/dsp
- contrib/libs/libwebp/webp
-)
-
-NO_COMPILER_WARNINGS()
-
-NO_RUNTIME()
-
-CFLAGS(
- -DHAVE_CONFIG_H
-)
-
-SRCDIR(contrib/libs/libwebp/dsp)
-
-SRCS(
- alpha_processing_sse41.c
- dec_sse41.c
- lossless_sse41.c
- upsampling_sse41.c
- yuv_sse41.c
-)
-
-END()
diff --git a/contrib/libs/libwebp/dsp/yuv.c b/contrib/libs/libwebp/dsp/yuv.c
deleted file mode 100644
index 450490422b..0000000000
--- a/contrib/libs/libwebp/dsp/yuv.c
+++ /dev/null
@@ -1,308 +0,0 @@
-// Copyright 2010 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// YUV->RGB conversion functions
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include "./yuv.h"
-
-#include <assert.h>
-#include <stdlib.h>
-
-//-----------------------------------------------------------------------------
-// Plain-C version
-
-#define ROW_FUNC(FUNC_NAME, FUNC, XSTEP) \
-static void FUNC_NAME(const uint8_t* y, \
- const uint8_t* u, const uint8_t* v, \
- uint8_t* dst, int len) { \
- const uint8_t* const end = dst + (len & ~1) * (XSTEP); \
- while (dst != end) { \
- FUNC(y[0], u[0], v[0], dst); \
- FUNC(y[1], u[0], v[0], dst + (XSTEP)); \
- y += 2; \
- ++u; \
- ++v; \
- dst += 2 * (XSTEP); \
- } \
- if (len & 1) { \
- FUNC(y[0], u[0], v[0], dst); \
- } \
-} \
-
-// All variants implemented.
-ROW_FUNC(YuvToRgbRow, VP8YuvToRgb, 3)
-ROW_FUNC(YuvToBgrRow, VP8YuvToBgr, 3)
-ROW_FUNC(YuvToRgbaRow, VP8YuvToRgba, 4)
-ROW_FUNC(YuvToBgraRow, VP8YuvToBgra, 4)
-ROW_FUNC(YuvToArgbRow, VP8YuvToArgb, 4)
-ROW_FUNC(YuvToRgba4444Row, VP8YuvToRgba4444, 2)
-ROW_FUNC(YuvToRgb565Row, VP8YuvToRgb565, 2)
-
-#undef ROW_FUNC
-
-// Main call for processing a plane with a WebPSamplerRowFunc function:
-void WebPSamplerProcessPlane(const uint8_t* y, int y_stride,
- const uint8_t* u, const uint8_t* v, int uv_stride,
- uint8_t* dst, int dst_stride,
- int width, int height, WebPSamplerRowFunc func) {
- int j;
- for (j = 0; j < height; ++j) {
- func(y, u, v, dst, width);
- y += y_stride;
- if (j & 1) {
- u += uv_stride;
- v += uv_stride;
- }
- dst += dst_stride;
- }
-}
-
-//-----------------------------------------------------------------------------
-// Main call
-
-WebPSamplerRowFunc WebPSamplers[MODE_LAST];
-
-extern void WebPInitSamplersSSE2(void);
-extern void WebPInitSamplersSSE41(void);
-extern void WebPInitSamplersMIPS32(void);
-extern void WebPInitSamplersMIPSdspR2(void);
-
-WEBP_DSP_INIT_FUNC(WebPInitSamplers) {
- WebPSamplers[MODE_RGB] = YuvToRgbRow;
- WebPSamplers[MODE_RGBA] = YuvToRgbaRow;
- WebPSamplers[MODE_BGR] = YuvToBgrRow;
- WebPSamplers[MODE_BGRA] = YuvToBgraRow;
- WebPSamplers[MODE_ARGB] = YuvToArgbRow;
- WebPSamplers[MODE_RGBA_4444] = YuvToRgba4444Row;
- WebPSamplers[MODE_RGB_565] = YuvToRgb565Row;
- WebPSamplers[MODE_rgbA] = YuvToRgbaRow;
- WebPSamplers[MODE_bgrA] = YuvToBgraRow;
- WebPSamplers[MODE_Argb] = YuvToArgbRow;
- WebPSamplers[MODE_rgbA_4444] = YuvToRgba4444Row;
-
- // If defined, use CPUInfo() to overwrite some pointers with faster versions.
- if (VP8GetCPUInfo != NULL) {
-#if defined(WEBP_HAVE_SSE2)
- if (VP8GetCPUInfo(kSSE2)) {
- WebPInitSamplersSSE2();
- }
-#endif // WEBP_HAVE_SSE2
-#if defined(WEBP_HAVE_SSE41)
- if (VP8GetCPUInfo(kSSE4_1)) {
- WebPInitSamplersSSE41();
- }
-#endif // WEBP_HAVE_SSE41
-#if defined(WEBP_USE_MIPS32)
- if (VP8GetCPUInfo(kMIPS32)) {
- WebPInitSamplersMIPS32();
- }
-#endif // WEBP_USE_MIPS32
-#if defined(WEBP_USE_MIPS_DSP_R2)
- if (VP8GetCPUInfo(kMIPSdspR2)) {
- WebPInitSamplersMIPSdspR2();
- }
-#endif // WEBP_USE_MIPS_DSP_R2
- }
-}
-
-//-----------------------------------------------------------------------------
-// ARGB -> YUV converters
-
-static void ConvertARGBToY_C(const uint32_t* argb, uint8_t* y, int width) {
- int i;
- for (i = 0; i < width; ++i) {
- const uint32_t p = argb[i];
- y[i] = VP8RGBToY((p >> 16) & 0xff, (p >> 8) & 0xff, (p >> 0) & 0xff,
- YUV_HALF);
- }
-}
-
-void WebPConvertARGBToUV_C(const uint32_t* argb, uint8_t* u, uint8_t* v,
- int src_width, int do_store) {
- // No rounding. Last pixel is dealt with separately.
- const int uv_width = src_width >> 1;
- int i;
- for (i = 0; i < uv_width; ++i) {
- const uint32_t v0 = argb[2 * i + 0];
- const uint32_t v1 = argb[2 * i + 1];
- // VP8RGBToU/V expects four accumulated pixels. Hence we need to
- // scale r/g/b value by a factor 2. We just shift v0/v1 one bit less.
- const int r = ((v0 >> 15) & 0x1fe) + ((v1 >> 15) & 0x1fe);
- const int g = ((v0 >> 7) & 0x1fe) + ((v1 >> 7) & 0x1fe);
- const int b = ((v0 << 1) & 0x1fe) + ((v1 << 1) & 0x1fe);
- const int tmp_u = VP8RGBToU(r, g, b, YUV_HALF << 2);
- const int tmp_v = VP8RGBToV(r, g, b, YUV_HALF << 2);
- if (do_store) {
- u[i] = tmp_u;
- v[i] = tmp_v;
- } else {
- // Approximated average-of-four. But it's an acceptable diff.
- u[i] = (u[i] + tmp_u + 1) >> 1;
- v[i] = (v[i] + tmp_v + 1) >> 1;
- }
- }
- if (src_width & 1) { // last pixel
- const uint32_t v0 = argb[2 * i + 0];
- const int r = (v0 >> 14) & 0x3fc;
- const int g = (v0 >> 6) & 0x3fc;
- const int b = (v0 << 2) & 0x3fc;
- const int tmp_u = VP8RGBToU(r, g, b, YUV_HALF << 2);
- const int tmp_v = VP8RGBToV(r, g, b, YUV_HALF << 2);
- if (do_store) {
- u[i] = tmp_u;
- v[i] = tmp_v;
- } else {
- u[i] = (u[i] + tmp_u + 1) >> 1;
- v[i] = (v[i] + tmp_v + 1) >> 1;
- }
- }
-}
-
-//-----------------------------------------------------------------------------
-
-static void ConvertRGB24ToY_C(const uint8_t* rgb, uint8_t* y, int width) {
- int i;
- for (i = 0; i < width; ++i, rgb += 3) {
- y[i] = VP8RGBToY(rgb[0], rgb[1], rgb[2], YUV_HALF);
- }
-}
-
-static void ConvertBGR24ToY_C(const uint8_t* bgr, uint8_t* y, int width) {
- int i;
- for (i = 0; i < width; ++i, bgr += 3) {
- y[i] = VP8RGBToY(bgr[2], bgr[1], bgr[0], YUV_HALF);
- }
-}
-
-void WebPConvertRGBA32ToUV_C(const uint16_t* rgb,
- uint8_t* u, uint8_t* v, int width) {
- int i;
- for (i = 0; i < width; i += 1, rgb += 4) {
- const int r = rgb[0], g = rgb[1], b = rgb[2];
- u[i] = VP8RGBToU(r, g, b, YUV_HALF << 2);
- v[i] = VP8RGBToV(r, g, b, YUV_HALF << 2);
- }
-}
-
-//-----------------------------------------------------------------------------
-
-#if !WEBP_NEON_OMIT_C_CODE
-#define MAX_Y ((1 << 10) - 1) // 10b precision over 16b-arithmetic
-static uint16_t clip_y(int v) {
- return (v < 0) ? 0 : (v > MAX_Y) ? MAX_Y : (uint16_t)v;
-}
-
-static uint64_t SharpYUVUpdateY_C(const uint16_t* ref, const uint16_t* src,
- uint16_t* dst, int len) {
- uint64_t diff = 0;
- int i;
- for (i = 0; i < len; ++i) {
- const int diff_y = ref[i] - src[i];
- const int new_y = (int)dst[i] + diff_y;
- dst[i] = clip_y(new_y);
- diff += (uint64_t)abs(diff_y);
- }
- return diff;
-}
-
-static void SharpYUVUpdateRGB_C(const int16_t* ref, const int16_t* src,
- int16_t* dst, int len) {
- int i;
- for (i = 0; i < len; ++i) {
- const int diff_uv = ref[i] - src[i];
- dst[i] += diff_uv;
- }
-}
-
-static void SharpYUVFilterRow_C(const int16_t* A, const int16_t* B, int len,
- const uint16_t* best_y, uint16_t* out) {
- int i;
- for (i = 0; i < len; ++i, ++A, ++B) {
- const int v0 = (A[0] * 9 + A[1] * 3 + B[0] * 3 + B[1] + 8) >> 4;
- const int v1 = (A[1] * 9 + A[0] * 3 + B[1] * 3 + B[0] + 8) >> 4;
- out[2 * i + 0] = clip_y(best_y[2 * i + 0] + v0);
- out[2 * i + 1] = clip_y(best_y[2 * i + 1] + v1);
- }
-}
-#endif // !WEBP_NEON_OMIT_C_CODE
-
-#undef MAX_Y
-
-//-----------------------------------------------------------------------------
-
-void (*WebPConvertRGB24ToY)(const uint8_t* rgb, uint8_t* y, int width);
-void (*WebPConvertBGR24ToY)(const uint8_t* bgr, uint8_t* y, int width);
-void (*WebPConvertRGBA32ToUV)(const uint16_t* rgb,
- uint8_t* u, uint8_t* v, int width);
-
-void (*WebPConvertARGBToY)(const uint32_t* argb, uint8_t* y, int width);
-void (*WebPConvertARGBToUV)(const uint32_t* argb, uint8_t* u, uint8_t* v,
- int src_width, int do_store);
-
-uint64_t (*WebPSharpYUVUpdateY)(const uint16_t* ref, const uint16_t* src,
- uint16_t* dst, int len);
-void (*WebPSharpYUVUpdateRGB)(const int16_t* ref, const int16_t* src,
- int16_t* dst, int len);
-void (*WebPSharpYUVFilterRow)(const int16_t* A, const int16_t* B, int len,
- const uint16_t* best_y, uint16_t* out);
-
-extern void WebPInitConvertARGBToYUVSSE2(void);
-extern void WebPInitConvertARGBToYUVSSE41(void);
-extern void WebPInitConvertARGBToYUVNEON(void);
-extern void WebPInitSharpYUVSSE2(void);
-extern void WebPInitSharpYUVNEON(void);
-
-WEBP_DSP_INIT_FUNC(WebPInitConvertARGBToYUV) {
- WebPConvertARGBToY = ConvertARGBToY_C;
- WebPConvertARGBToUV = WebPConvertARGBToUV_C;
-
- WebPConvertRGB24ToY = ConvertRGB24ToY_C;
- WebPConvertBGR24ToY = ConvertBGR24ToY_C;
-
- WebPConvertRGBA32ToUV = WebPConvertRGBA32ToUV_C;
-
-#if !WEBP_NEON_OMIT_C_CODE
- WebPSharpYUVUpdateY = SharpYUVUpdateY_C;
- WebPSharpYUVUpdateRGB = SharpYUVUpdateRGB_C;
- WebPSharpYUVFilterRow = SharpYUVFilterRow_C;
-#endif
-
- if (VP8GetCPUInfo != NULL) {
-#if defined(WEBP_HAVE_SSE2)
- if (VP8GetCPUInfo(kSSE2)) {
- WebPInitConvertARGBToYUVSSE2();
- WebPInitSharpYUVSSE2();
- }
-#endif // WEBP_HAVE_SSE2
-#if defined(WEBP_HAVE_SSE41)
- if (VP8GetCPUInfo(kSSE4_1)) {
- WebPInitConvertARGBToYUVSSE41();
- }
-#endif // WEBP_HAVE_SSE41
- }
-
-#if defined(WEBP_HAVE_NEON)
- if (WEBP_NEON_OMIT_C_CODE ||
- (VP8GetCPUInfo != NULL && VP8GetCPUInfo(kNEON))) {
- WebPInitConvertARGBToYUVNEON();
- WebPInitSharpYUVNEON();
- }
-#endif // WEBP_HAVE_NEON
-
- assert(WebPConvertARGBToY != NULL);
- assert(WebPConvertARGBToUV != NULL);
- assert(WebPConvertRGB24ToY != NULL);
- assert(WebPConvertBGR24ToY != NULL);
- assert(WebPConvertRGBA32ToUV != NULL);
- assert(WebPSharpYUVUpdateY != NULL);
- assert(WebPSharpYUVUpdateRGB != NULL);
- assert(WebPSharpYUVFilterRow != NULL);
-}
diff --git a/contrib/libs/libwebp/dsp/yuv.h b/contrib/libs/libwebp/dsp/yuv.h
deleted file mode 100644
index 22da2f1f46..0000000000
--- a/contrib/libs/libwebp/dsp/yuv.h
+++ /dev/null
@@ -1,210 +0,0 @@
-// Copyright 2010 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// inline YUV<->RGB conversion function
-//
-// The exact naming is Y'CbCr, following the ITU-R BT.601 standard.
-// More information at: https://en.wikipedia.org/wiki/YCbCr
-// Y = 0.2569 * R + 0.5044 * G + 0.0979 * B + 16
-// U = -0.1483 * R - 0.2911 * G + 0.4394 * B + 128
-// V = 0.4394 * R - 0.3679 * G - 0.0715 * B + 128
-// We use 16bit fixed point operations for RGB->YUV conversion (YUV_FIX).
-//
-// For the Y'CbCr to RGB conversion, the BT.601 specification reads:
-// R = 1.164 * (Y-16) + 1.596 * (V-128)
-// G = 1.164 * (Y-16) - 0.813 * (V-128) - 0.391 * (U-128)
-// B = 1.164 * (Y-16) + 2.018 * (U-128)
-// where Y is in the [16,235] range, and U/V in the [16,240] range.
-//
-// The fixed-point implementation used here is:
-// R = (19077 . y + 26149 . v - 14234) >> 6
-// G = (19077 . y - 6419 . u - 13320 . v + 8708) >> 6
-// B = (19077 . y + 33050 . u - 17685) >> 6
-// where the '.' operator is the mulhi_epu16 variant:
-// a . b = ((a << 8) * b) >> 16
-// that preserves 8 bits of fractional precision before final descaling.
-
-// Author: Skal (pascal.massimino@gmail.com)
-
-#ifndef WEBP_DSP_YUV_H_
-#define WEBP_DSP_YUV_H_
-
-#include "./dsp.h"
-#include "../dec/vp8_dec.h"
-
-//------------------------------------------------------------------------------
-// YUV -> RGB conversion
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-enum {
- YUV_FIX = 16, // fixed-point precision for RGB->YUV
- YUV_HALF = 1 << (YUV_FIX - 1),
-
- YUV_FIX2 = 6, // fixed-point precision for YUV->RGB
- YUV_MASK2 = (256 << YUV_FIX2) - 1
-};
-
-//------------------------------------------------------------------------------
-// slower on x86 by ~7-8%, but bit-exact with the SSE2/NEON version
-
-static WEBP_INLINE int MultHi(int v, int coeff) { // _mm_mulhi_epu16 emulation
- return (v * coeff) >> 8;
-}
-
-static WEBP_INLINE int VP8Clip8(int v) {
- return ((v & ~YUV_MASK2) == 0) ? (v >> YUV_FIX2) : (v < 0) ? 0 : 255;
-}
-
-static WEBP_INLINE int VP8YUVToR(int y, int v) {
- return VP8Clip8(MultHi(y, 19077) + MultHi(v, 26149) - 14234);
-}
-
-static WEBP_INLINE int VP8YUVToG(int y, int u, int v) {
- return VP8Clip8(MultHi(y, 19077) - MultHi(u, 6419) - MultHi(v, 13320) + 8708);
-}
-
-static WEBP_INLINE int VP8YUVToB(int y, int u) {
- return VP8Clip8(MultHi(y, 19077) + MultHi(u, 33050) - 17685);
-}
-
-static WEBP_INLINE void VP8YuvToRgb(int y, int u, int v,
- uint8_t* const rgb) {
- rgb[0] = VP8YUVToR(y, v);
- rgb[1] = VP8YUVToG(y, u, v);
- rgb[2] = VP8YUVToB(y, u);
-}
-
-static WEBP_INLINE void VP8YuvToBgr(int y, int u, int v,
- uint8_t* const bgr) {
- bgr[0] = VP8YUVToB(y, u);
- bgr[1] = VP8YUVToG(y, u, v);
- bgr[2] = VP8YUVToR(y, v);
-}
-
-static WEBP_INLINE void VP8YuvToRgb565(int y, int u, int v,
- uint8_t* const rgb) {
- const int r = VP8YUVToR(y, v); // 5 usable bits
- const int g = VP8YUVToG(y, u, v); // 6 usable bits
- const int b = VP8YUVToB(y, u); // 5 usable bits
- const int rg = (r & 0xf8) | (g >> 5);
- const int gb = ((g << 3) & 0xe0) | (b >> 3);
-#if (WEBP_SWAP_16BIT_CSP == 1)
- rgb[0] = gb;
- rgb[1] = rg;
-#else
- rgb[0] = rg;
- rgb[1] = gb;
-#endif
-}
-
-static WEBP_INLINE void VP8YuvToRgba4444(int y, int u, int v,
- uint8_t* const argb) {
- const int r = VP8YUVToR(y, v); // 4 usable bits
- const int g = VP8YUVToG(y, u, v); // 4 usable bits
- const int b = VP8YUVToB(y, u); // 4 usable bits
- const int rg = (r & 0xf0) | (g >> 4);
- const int ba = (b & 0xf0) | 0x0f; // overwrite the lower 4 bits
-#if (WEBP_SWAP_16BIT_CSP == 1)
- argb[0] = ba;
- argb[1] = rg;
-#else
- argb[0] = rg;
- argb[1] = ba;
-#endif
-}
-
-//-----------------------------------------------------------------------------
-// Alpha handling variants
-
-static WEBP_INLINE void VP8YuvToArgb(uint8_t y, uint8_t u, uint8_t v,
- uint8_t* const argb) {
- argb[0] = 0xff;
- VP8YuvToRgb(y, u, v, argb + 1);
-}
-
-static WEBP_INLINE void VP8YuvToBgra(uint8_t y, uint8_t u, uint8_t v,
- uint8_t* const bgra) {
- VP8YuvToBgr(y, u, v, bgra);
- bgra[3] = 0xff;
-}
-
-static WEBP_INLINE void VP8YuvToRgba(uint8_t y, uint8_t u, uint8_t v,
- uint8_t* const rgba) {
- VP8YuvToRgb(y, u, v, rgba);
- rgba[3] = 0xff;
-}
-
-//-----------------------------------------------------------------------------
-// SSE2 extra functions (mostly for upsampling_sse2.c)
-
-#if defined(WEBP_USE_SSE2)
-
-// Process 32 pixels and store the result (16b, 24b or 32b per pixel) in *dst.
-void VP8YuvToRgba32_SSE2(const uint8_t* y, const uint8_t* u, const uint8_t* v,
- uint8_t* dst);
-void VP8YuvToRgb32_SSE2(const uint8_t* y, const uint8_t* u, const uint8_t* v,
- uint8_t* dst);
-void VP8YuvToBgra32_SSE2(const uint8_t* y, const uint8_t* u, const uint8_t* v,
- uint8_t* dst);
-void VP8YuvToBgr32_SSE2(const uint8_t* y, const uint8_t* u, const uint8_t* v,
- uint8_t* dst);
-void VP8YuvToArgb32_SSE2(const uint8_t* y, const uint8_t* u, const uint8_t* v,
- uint8_t* dst);
-void VP8YuvToRgba444432_SSE2(const uint8_t* y, const uint8_t* u,
- const uint8_t* v, uint8_t* dst);
-void VP8YuvToRgb56532_SSE2(const uint8_t* y, const uint8_t* u, const uint8_t* v,
- uint8_t* dst);
-
-#endif // WEBP_USE_SSE2
-
-//-----------------------------------------------------------------------------
-// SSE41 extra functions (mostly for upsampling_sse41.c)
-
-#if defined(WEBP_USE_SSE41)
-
-// Process 32 pixels and store the result (16b, 24b or 32b per pixel) in *dst.
-void VP8YuvToRgb32_SSE41(const uint8_t* y, const uint8_t* u, const uint8_t* v,
- uint8_t* dst);
-void VP8YuvToBgr32_SSE41(const uint8_t* y, const uint8_t* u, const uint8_t* v,
- uint8_t* dst);
-
-#endif // WEBP_USE_SSE41
-
-//------------------------------------------------------------------------------
-// RGB -> YUV conversion
-
-// Stub functions that can be called with various rounding values:
-static WEBP_INLINE int VP8ClipUV(int uv, int rounding) {
- uv = (uv + rounding + (128 << (YUV_FIX + 2))) >> (YUV_FIX + 2);
- return ((uv & ~0xff) == 0) ? uv : (uv < 0) ? 0 : 255;
-}
-
-static WEBP_INLINE int VP8RGBToY(int r, int g, int b, int rounding) {
- const int luma = 16839 * r + 33059 * g + 6420 * b;
- return (luma + rounding + (16 << YUV_FIX)) >> YUV_FIX; // no need to clip
-}
-
-static WEBP_INLINE int VP8RGBToU(int r, int g, int b, int rounding) {
- const int u = -9719 * r - 19081 * g + 28800 * b;
- return VP8ClipUV(u, rounding);
-}
-
-static WEBP_INLINE int VP8RGBToV(int r, int g, int b, int rounding) {
- const int v = +28800 * r - 24116 * g - 4684 * b;
- return VP8ClipUV(v, rounding);
-}
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // WEBP_DSP_YUV_H_
diff --git a/contrib/libs/libwebp/dsp/yuv_mips32.c b/contrib/libs/libwebp/dsp/yuv_mips32.c
deleted file mode 100644
index 9713cbb28c..0000000000
--- a/contrib/libs/libwebp/dsp/yuv_mips32.c
+++ /dev/null
@@ -1,103 +0,0 @@
-// Copyright 2014 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// MIPS version of YUV to RGB upsampling functions.
-//
-// Author(s): Djordje Pesut (djordje.pesut@imgtec.com)
-// Jovan Zelincevic (jovan.zelincevic@imgtec.com)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_MIPS32)
-
-#include "./yuv.h"
-
-//------------------------------------------------------------------------------
-// simple point-sampling
-
-#define ROW_FUNC(FUNC_NAME, XSTEP, R, G, B, A) \
-static void FUNC_NAME(const uint8_t* y, \
- const uint8_t* u, const uint8_t* v, \
- uint8_t* dst, int len) { \
- int i, r, g, b; \
- int temp0, temp1, temp2, temp3, temp4; \
- for (i = 0; i < (len >> 1); i++) { \
- temp1 = MultHi(v[0], 26149); \
- temp3 = MultHi(v[0], 13320); \
- temp2 = MultHi(u[0], 6419); \
- temp4 = MultHi(u[0], 33050); \
- temp0 = MultHi(y[0], 19077); \
- temp1 -= 14234; \
- temp3 -= 8708; \
- temp2 += temp3; \
- temp4 -= 17685; \
- r = VP8Clip8(temp0 + temp1); \
- g = VP8Clip8(temp0 - temp2); \
- b = VP8Clip8(temp0 + temp4); \
- temp0 = MultHi(y[1], 19077); \
- dst[R] = r; \
- dst[G] = g; \
- dst[B] = b; \
- if (A) dst[A] = 0xff; \
- r = VP8Clip8(temp0 + temp1); \
- g = VP8Clip8(temp0 - temp2); \
- b = VP8Clip8(temp0 + temp4); \
- dst[R + XSTEP] = r; \
- dst[G + XSTEP] = g; \
- dst[B + XSTEP] = b; \
- if (A) dst[A + XSTEP] = 0xff; \
- y += 2; \
- ++u; \
- ++v; \
- dst += 2 * XSTEP; \
- } \
- if (len & 1) { \
- temp1 = MultHi(v[0], 26149); \
- temp3 = MultHi(v[0], 13320); \
- temp2 = MultHi(u[0], 6419); \
- temp4 = MultHi(u[0], 33050); \
- temp0 = MultHi(y[0], 19077); \
- temp1 -= 14234; \
- temp3 -= 8708; \
- temp2 += temp3; \
- temp4 -= 17685; \
- r = VP8Clip8(temp0 + temp1); \
- g = VP8Clip8(temp0 - temp2); \
- b = VP8Clip8(temp0 + temp4); \
- dst[R] = r; \
- dst[G] = g; \
- dst[B] = b; \
- if (A) dst[A] = 0xff; \
- } \
-}
-
-ROW_FUNC(YuvToRgbRow_MIPS32, 3, 0, 1, 2, 0)
-ROW_FUNC(YuvToRgbaRow_MIPS32, 4, 0, 1, 2, 3)
-ROW_FUNC(YuvToBgrRow_MIPS32, 3, 2, 1, 0, 0)
-ROW_FUNC(YuvToBgraRow_MIPS32, 4, 2, 1, 0, 3)
-
-#undef ROW_FUNC
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void WebPInitSamplersMIPS32(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void WebPInitSamplersMIPS32(void) {
- WebPSamplers[MODE_RGB] = YuvToRgbRow_MIPS32;
- WebPSamplers[MODE_RGBA] = YuvToRgbaRow_MIPS32;
- WebPSamplers[MODE_BGR] = YuvToBgrRow_MIPS32;
- WebPSamplers[MODE_BGRA] = YuvToBgraRow_MIPS32;
-}
-
-#else // !WEBP_USE_MIPS32
-
-WEBP_DSP_INIT_STUB(WebPInitSamplersMIPS32)
-
-#endif // WEBP_USE_MIPS32
diff --git a/contrib/libs/libwebp/dsp/yuv_mips_dsp_r2.c b/contrib/libs/libwebp/dsp/yuv_mips_dsp_r2.c
deleted file mode 100644
index 87a490c3d4..0000000000
--- a/contrib/libs/libwebp/dsp/yuv_mips_dsp_r2.c
+++ /dev/null
@@ -1,134 +0,0 @@
-// Copyright 2014 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// MIPS DSPr2 version of YUV to RGB upsampling functions.
-//
-// Author(s): Branimir Vasic (branimir.vasic@imgtec.com)
-// Djordje Pesut (djordje.pesut@imgtec.com)
-
-#include "./dsp.h"
-
-#if defined(WEBP_USE_MIPS_DSP_R2)
-
-#include "./yuv.h"
-
-//------------------------------------------------------------------------------
-// simple point-sampling
-
-#define ROW_FUNC_PART_1() \
- "lbu %[temp3], 0(%[v]) \n\t" \
- "lbu %[temp4], 0(%[u]) \n\t" \
- "lbu %[temp0], 0(%[y]) \n\t" \
- "mul %[temp1], %[t_con_1], %[temp3] \n\t" \
- "mul %[temp3], %[t_con_2], %[temp3] \n\t" \
- "mul %[temp2], %[t_con_3], %[temp4] \n\t" \
- "mul %[temp4], %[t_con_4], %[temp4] \n\t" \
- "mul %[temp0], %[t_con_5], %[temp0] \n\t" \
- "subu %[temp1], %[temp1], %[t_con_6] \n\t" \
- "subu %[temp3], %[temp3], %[t_con_7] \n\t" \
- "addu %[temp2], %[temp2], %[temp3] \n\t" \
- "subu %[temp4], %[temp4], %[t_con_8] \n\t" \
-
-#define ROW_FUNC_PART_2(R, G, B, K) \
- "addu %[temp5], %[temp0], %[temp1] \n\t" \
- "subu %[temp6], %[temp0], %[temp2] \n\t" \
- "addu %[temp7], %[temp0], %[temp4] \n\t" \
-".if " #K " \n\t" \
- "lbu %[temp0], 1(%[y]) \n\t" \
-".endif \n\t" \
- "shll_s.w %[temp5], %[temp5], 17 \n\t" \
- "shll_s.w %[temp6], %[temp6], 17 \n\t" \
-".if " #K " \n\t" \
- "mul %[temp0], %[t_con_5], %[temp0] \n\t" \
-".endif \n\t" \
- "shll_s.w %[temp7], %[temp7], 17 \n\t" \
- "precrqu_s.qb.ph %[temp5], %[temp5], $zero \n\t" \
- "precrqu_s.qb.ph %[temp6], %[temp6], $zero \n\t" \
- "precrqu_s.qb.ph %[temp7], %[temp7], $zero \n\t" \
- "srl %[temp5], %[temp5], 24 \n\t" \
- "srl %[temp6], %[temp6], 24 \n\t" \
- "srl %[temp7], %[temp7], 24 \n\t" \
- "sb %[temp5], " #R "(%[dst]) \n\t" \
- "sb %[temp6], " #G "(%[dst]) \n\t" \
- "sb %[temp7], " #B "(%[dst]) \n\t" \
-
-#define ASM_CLOBBER_LIST() \
- : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2), \
- [temp3]"=&r"(temp3), [temp4]"=&r"(temp4), [temp5]"=&r"(temp5), \
- [temp6]"=&r"(temp6), [temp7]"=&r"(temp7) \
- : [t_con_1]"r"(t_con_1), [t_con_2]"r"(t_con_2), [t_con_3]"r"(t_con_3), \
- [t_con_4]"r"(t_con_4), [t_con_5]"r"(t_con_5), [t_con_6]"r"(t_con_6), \
- [u]"r"(u), [v]"r"(v), [y]"r"(y), [dst]"r"(dst), \
- [t_con_7]"r"(t_con_7), [t_con_8]"r"(t_con_8) \
- : "memory", "hi", "lo" \
-
-#define ROW_FUNC(FUNC_NAME, XSTEP, R, G, B, A) \
-static void FUNC_NAME(const uint8_t* y, \
- const uint8_t* u, const uint8_t* v, \
- uint8_t* dst, int len) { \
- int i; \
- uint32_t temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7; \
- const int t_con_1 = 26149; \
- const int t_con_2 = 13320; \
- const int t_con_3 = 6419; \
- const int t_con_4 = 33050; \
- const int t_con_5 = 19077; \
- const int t_con_6 = 14234; \
- const int t_con_7 = 8708; \
- const int t_con_8 = 17685; \
- for (i = 0; i < (len >> 1); i++) { \
- __asm__ volatile ( \
- ROW_FUNC_PART_1() \
- ROW_FUNC_PART_2(R, G, B, 1) \
- ROW_FUNC_PART_2(R + XSTEP, G + XSTEP, B + XSTEP, 0) \
- ASM_CLOBBER_LIST() \
- ); \
- if (A) dst[A] = dst[A + XSTEP] = 0xff; \
- y += 2; \
- ++u; \
- ++v; \
- dst += 2 * XSTEP; \
- } \
- if (len & 1) { \
- __asm__ volatile ( \
- ROW_FUNC_PART_1() \
- ROW_FUNC_PART_2(R, G, B, 0) \
- ASM_CLOBBER_LIST() \
- ); \
- if (A) dst[A] = 0xff; \
- } \
-}
-
-ROW_FUNC(YuvToRgbRow_MIPSdspR2, 3, 0, 1, 2, 0)
-ROW_FUNC(YuvToRgbaRow_MIPSdspR2, 4, 0, 1, 2, 3)
-ROW_FUNC(YuvToBgrRow_MIPSdspR2, 3, 2, 1, 0, 0)
-ROW_FUNC(YuvToBgraRow_MIPSdspR2, 4, 2, 1, 0, 3)
-
-#undef ROW_FUNC
-#undef ASM_CLOBBER_LIST
-#undef ROW_FUNC_PART_2
-#undef ROW_FUNC_PART_1
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void WebPInitSamplersMIPSdspR2(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void WebPInitSamplersMIPSdspR2(void) {
- WebPSamplers[MODE_RGB] = YuvToRgbRow_MIPSdspR2;
- WebPSamplers[MODE_RGBA] = YuvToRgbaRow_MIPSdspR2;
- WebPSamplers[MODE_BGR] = YuvToBgrRow_MIPSdspR2;
- WebPSamplers[MODE_BGRA] = YuvToBgraRow_MIPSdspR2;
-}
-
-#else // !WEBP_USE_MIPS_DSP_R2
-
-WEBP_DSP_INIT_STUB(WebPInitSamplersMIPSdspR2)
-
-#endif // WEBP_USE_MIPS_DSP_R2
diff --git a/contrib/libs/libwebp/dsp/yuv_neon.c b/contrib/libs/libwebp/dsp/yuv_neon.c
deleted file mode 100644
index e5209b0296..0000000000
--- a/contrib/libs/libwebp/dsp/yuv_neon.c
+++ /dev/null
@@ -1,288 +0,0 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// YUV->RGB conversion functions
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include "./yuv.h"
-
-#if defined(WEBP_USE_NEON)
-
-#include <assert.h>
-#include <stdlib.h>
-
-#include "./neon.h"
-
-//-----------------------------------------------------------------------------
-
-static uint8x8_t ConvertRGBToY_NEON(const uint8x8_t R,
- const uint8x8_t G,
- const uint8x8_t B) {
- const uint16x8_t r = vmovl_u8(R);
- const uint16x8_t g = vmovl_u8(G);
- const uint16x8_t b = vmovl_u8(B);
- const uint16x4_t r_lo = vget_low_u16(r);
- const uint16x4_t r_hi = vget_high_u16(r);
- const uint16x4_t g_lo = vget_low_u16(g);
- const uint16x4_t g_hi = vget_high_u16(g);
- const uint16x4_t b_lo = vget_low_u16(b);
- const uint16x4_t b_hi = vget_high_u16(b);
- const uint32x4_t tmp0_lo = vmull_n_u16( r_lo, 16839u);
- const uint32x4_t tmp0_hi = vmull_n_u16( r_hi, 16839u);
- const uint32x4_t tmp1_lo = vmlal_n_u16(tmp0_lo, g_lo, 33059u);
- const uint32x4_t tmp1_hi = vmlal_n_u16(tmp0_hi, g_hi, 33059u);
- const uint32x4_t tmp2_lo = vmlal_n_u16(tmp1_lo, b_lo, 6420u);
- const uint32x4_t tmp2_hi = vmlal_n_u16(tmp1_hi, b_hi, 6420u);
- const uint16x8_t Y1 = vcombine_u16(vrshrn_n_u32(tmp2_lo, 16),
- vrshrn_n_u32(tmp2_hi, 16));
- const uint16x8_t Y2 = vaddq_u16(Y1, vdupq_n_u16(16));
- return vqmovn_u16(Y2);
-}
-
-static void ConvertRGB24ToY_NEON(const uint8_t* rgb, uint8_t* y, int width) {
- int i;
- for (i = 0; i + 8 <= width; i += 8, rgb += 3 * 8) {
- const uint8x8x3_t RGB = vld3_u8(rgb);
- const uint8x8_t Y = ConvertRGBToY_NEON(RGB.val[0], RGB.val[1], RGB.val[2]);
- vst1_u8(y + i, Y);
- }
- for (; i < width; ++i, rgb += 3) { // left-over
- y[i] = VP8RGBToY(rgb[0], rgb[1], rgb[2], YUV_HALF);
- }
-}
-
-static void ConvertBGR24ToY_NEON(const uint8_t* bgr, uint8_t* y, int width) {
- int i;
- for (i = 0; i + 8 <= width; i += 8, bgr += 3 * 8) {
- const uint8x8x3_t BGR = vld3_u8(bgr);
- const uint8x8_t Y = ConvertRGBToY_NEON(BGR.val[2], BGR.val[1], BGR.val[0]);
- vst1_u8(y + i, Y);
- }
- for (; i < width; ++i, bgr += 3) { // left-over
- y[i] = VP8RGBToY(bgr[2], bgr[1], bgr[0], YUV_HALF);
- }
-}
-
-static void ConvertARGBToY_NEON(const uint32_t* argb, uint8_t* y, int width) {
- int i;
- for (i = 0; i + 8 <= width; i += 8) {
- const uint8x8x4_t RGB = vld4_u8((const uint8_t*)&argb[i]);
- const uint8x8_t Y = ConvertRGBToY_NEON(RGB.val[2], RGB.val[1], RGB.val[0]);
- vst1_u8(y + i, Y);
- }
- for (; i < width; ++i) { // left-over
- const uint32_t p = argb[i];
- y[i] = VP8RGBToY((p >> 16) & 0xff, (p >> 8) & 0xff, (p >> 0) & 0xff,
- YUV_HALF);
- }
-}
-
-//-----------------------------------------------------------------------------
-
-// computes: DST_s16 = [(C0 * r + C1 * g + C2 * b) >> 16] + CST
-#define MULTIPLY_16b_PREAMBLE(r, g, b) \
- const int16x4_t r_lo = vreinterpret_s16_u16(vget_low_u16(r)); \
- const int16x4_t r_hi = vreinterpret_s16_u16(vget_high_u16(r)); \
- const int16x4_t g_lo = vreinterpret_s16_u16(vget_low_u16(g)); \
- const int16x4_t g_hi = vreinterpret_s16_u16(vget_high_u16(g)); \
- const int16x4_t b_lo = vreinterpret_s16_u16(vget_low_u16(b)); \
- const int16x4_t b_hi = vreinterpret_s16_u16(vget_high_u16(b))
-
-#define MULTIPLY_16b(C0, C1, C2, CST, DST_s16) do { \
- const int32x4_t tmp0_lo = vmull_n_s16( r_lo, C0); \
- const int32x4_t tmp0_hi = vmull_n_s16( r_hi, C0); \
- const int32x4_t tmp1_lo = vmlal_n_s16(tmp0_lo, g_lo, C1); \
- const int32x4_t tmp1_hi = vmlal_n_s16(tmp0_hi, g_hi, C1); \
- const int32x4_t tmp2_lo = vmlal_n_s16(tmp1_lo, b_lo, C2); \
- const int32x4_t tmp2_hi = vmlal_n_s16(tmp1_hi, b_hi, C2); \
- const int16x8_t tmp3 = vcombine_s16(vshrn_n_s32(tmp2_lo, 16), \
- vshrn_n_s32(tmp2_hi, 16)); \
- DST_s16 = vaddq_s16(tmp3, vdupq_n_s16(CST)); \
-} while (0)
-
-// This needs to be a macro, since (128 << SHIFT) needs to be an immediate.
-#define CONVERT_RGB_TO_UV(r, g, b, SHIFT, U_DST, V_DST) do { \
- MULTIPLY_16b_PREAMBLE(r, g, b); \
- MULTIPLY_16b(-9719, -19081, 28800, 128 << SHIFT, U_DST); \
- MULTIPLY_16b(28800, -24116, -4684, 128 << SHIFT, V_DST); \
-} while (0)
-
-static void ConvertRGBA32ToUV_NEON(const uint16_t* rgb,
- uint8_t* u, uint8_t* v, int width) {
- int i;
- for (i = 0; i + 8 <= width; i += 8, rgb += 4 * 8) {
- const uint16x8x4_t RGB = vld4q_u16((const uint16_t*)rgb);
- int16x8_t U, V;
- CONVERT_RGB_TO_UV(RGB.val[0], RGB.val[1], RGB.val[2], 2, U, V);
- vst1_u8(u + i, vqrshrun_n_s16(U, 2));
- vst1_u8(v + i, vqrshrun_n_s16(V, 2));
- }
- for (; i < width; i += 1, rgb += 4) {
- const int r = rgb[0], g = rgb[1], b = rgb[2];
- u[i] = VP8RGBToU(r, g, b, YUV_HALF << 2);
- v[i] = VP8RGBToV(r, g, b, YUV_HALF << 2);
- }
-}
-
-static void ConvertARGBToUV_NEON(const uint32_t* argb, uint8_t* u, uint8_t* v,
- int src_width, int do_store) {
- int i;
- for (i = 0; i + 16 <= src_width; i += 16, u += 8, v += 8) {
- const uint8x16x4_t RGB = vld4q_u8((const uint8_t*)&argb[i]);
- const uint16x8_t R = vpaddlq_u8(RGB.val[2]); // pair-wise adds
- const uint16x8_t G = vpaddlq_u8(RGB.val[1]);
- const uint16x8_t B = vpaddlq_u8(RGB.val[0]);
- int16x8_t U_tmp, V_tmp;
- CONVERT_RGB_TO_UV(R, G, B, 1, U_tmp, V_tmp);
- {
- const uint8x8_t U = vqrshrun_n_s16(U_tmp, 1);
- const uint8x8_t V = vqrshrun_n_s16(V_tmp, 1);
- if (do_store) {
- vst1_u8(u, U);
- vst1_u8(v, V);
- } else {
- const uint8x8_t prev_u = vld1_u8(u);
- const uint8x8_t prev_v = vld1_u8(v);
- vst1_u8(u, vrhadd_u8(U, prev_u));
- vst1_u8(v, vrhadd_u8(V, prev_v));
- }
- }
- }
- if (i < src_width) { // left-over
- WebPConvertARGBToUV_C(argb + i, u, v, src_width - i, do_store);
- }
-}
-
-
-//------------------------------------------------------------------------------
-
-extern void WebPInitConvertARGBToYUVNEON(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void WebPInitConvertARGBToYUVNEON(void) {
- WebPConvertRGB24ToY = ConvertRGB24ToY_NEON;
- WebPConvertBGR24ToY = ConvertBGR24ToY_NEON;
- WebPConvertARGBToY = ConvertARGBToY_NEON;
- WebPConvertARGBToUV = ConvertARGBToUV_NEON;
- WebPConvertRGBA32ToUV = ConvertRGBA32ToUV_NEON;
-}
-
-//------------------------------------------------------------------------------
-
-#define MAX_Y ((1 << 10) - 1) // 10b precision over 16b-arithmetic
-static uint16_t clip_y_NEON(int v) {
- return (v < 0) ? 0 : (v > MAX_Y) ? MAX_Y : (uint16_t)v;
-}
-
-static uint64_t SharpYUVUpdateY_NEON(const uint16_t* ref, const uint16_t* src,
- uint16_t* dst, int len) {
- int i;
- const int16x8_t zero = vdupq_n_s16(0);
- const int16x8_t max = vdupq_n_s16(MAX_Y);
- uint64x2_t sum = vdupq_n_u64(0);
- uint64_t diff;
-
- for (i = 0; i + 8 <= len; i += 8) {
- const int16x8_t A = vreinterpretq_s16_u16(vld1q_u16(ref + i));
- const int16x8_t B = vreinterpretq_s16_u16(vld1q_u16(src + i));
- const int16x8_t C = vreinterpretq_s16_u16(vld1q_u16(dst + i));
- const int16x8_t D = vsubq_s16(A, B); // diff_y
- const int16x8_t F = vaddq_s16(C, D); // new_y
- const uint16x8_t H =
- vreinterpretq_u16_s16(vmaxq_s16(vminq_s16(F, max), zero));
- const int16x8_t I = vabsq_s16(D); // abs(diff_y)
- vst1q_u16(dst + i, H);
- sum = vpadalq_u32(sum, vpaddlq_u16(vreinterpretq_u16_s16(I)));
- }
- diff = vgetq_lane_u64(sum, 0) + vgetq_lane_u64(sum, 1);
- for (; i < len; ++i) {
- const int diff_y = ref[i] - src[i];
- const int new_y = (int)(dst[i]) + diff_y;
- dst[i] = clip_y_NEON(new_y);
- diff += (uint64_t)(abs(diff_y));
- }
- return diff;
-}
-
-static void SharpYUVUpdateRGB_NEON(const int16_t* ref, const int16_t* src,
- int16_t* dst, int len) {
- int i;
- for (i = 0; i + 8 <= len; i += 8) {
- const int16x8_t A = vld1q_s16(ref + i);
- const int16x8_t B = vld1q_s16(src + i);
- const int16x8_t C = vld1q_s16(dst + i);
- const int16x8_t D = vsubq_s16(A, B); // diff_uv
- const int16x8_t E = vaddq_s16(C, D); // new_uv
- vst1q_s16(dst + i, E);
- }
- for (; i < len; ++i) {
- const int diff_uv = ref[i] - src[i];
- dst[i] += diff_uv;
- }
-}
-
-static void SharpYUVFilterRow_NEON(const int16_t* A, const int16_t* B, int len,
- const uint16_t* best_y, uint16_t* out) {
- int i;
- const int16x8_t max = vdupq_n_s16(MAX_Y);
- const int16x8_t zero = vdupq_n_s16(0);
- for (i = 0; i + 8 <= len; i += 8) {
- const int16x8_t a0 = vld1q_s16(A + i + 0);
- const int16x8_t a1 = vld1q_s16(A + i + 1);
- const int16x8_t b0 = vld1q_s16(B + i + 0);
- const int16x8_t b1 = vld1q_s16(B + i + 1);
- const int16x8_t a0b1 = vaddq_s16(a0, b1);
- const int16x8_t a1b0 = vaddq_s16(a1, b0);
- const int16x8_t a0a1b0b1 = vaddq_s16(a0b1, a1b0); // A0+A1+B0+B1
- const int16x8_t a0b1_2 = vaddq_s16(a0b1, a0b1); // 2*(A0+B1)
- const int16x8_t a1b0_2 = vaddq_s16(a1b0, a1b0); // 2*(A1+B0)
- const int16x8_t c0 = vshrq_n_s16(vaddq_s16(a0b1_2, a0a1b0b1), 3);
- const int16x8_t c1 = vshrq_n_s16(vaddq_s16(a1b0_2, a0a1b0b1), 3);
- const int16x8_t d0 = vaddq_s16(c1, a0);
- const int16x8_t d1 = vaddq_s16(c0, a1);
- const int16x8_t e0 = vrshrq_n_s16(d0, 1);
- const int16x8_t e1 = vrshrq_n_s16(d1, 1);
- const int16x8x2_t f = vzipq_s16(e0, e1);
- const int16x8_t g0 = vreinterpretq_s16_u16(vld1q_u16(best_y + 2 * i + 0));
- const int16x8_t g1 = vreinterpretq_s16_u16(vld1q_u16(best_y + 2 * i + 8));
- const int16x8_t h0 = vaddq_s16(g0, f.val[0]);
- const int16x8_t h1 = vaddq_s16(g1, f.val[1]);
- const int16x8_t i0 = vmaxq_s16(vminq_s16(h0, max), zero);
- const int16x8_t i1 = vmaxq_s16(vminq_s16(h1, max), zero);
- vst1q_u16(out + 2 * i + 0, vreinterpretq_u16_s16(i0));
- vst1q_u16(out + 2 * i + 8, vreinterpretq_u16_s16(i1));
- }
- for (; i < len; ++i) {
- const int a0b1 = A[i + 0] + B[i + 1];
- const int a1b0 = A[i + 1] + B[i + 0];
- const int a0a1b0b1 = a0b1 + a1b0 + 8;
- const int v0 = (8 * A[i + 0] + 2 * a1b0 + a0a1b0b1) >> 4;
- const int v1 = (8 * A[i + 1] + 2 * a0b1 + a0a1b0b1) >> 4;
- out[2 * i + 0] = clip_y_NEON(best_y[2 * i + 0] + v0);
- out[2 * i + 1] = clip_y_NEON(best_y[2 * i + 1] + v1);
- }
-}
-#undef MAX_Y
-
-//------------------------------------------------------------------------------
-
-extern void WebPInitSharpYUVNEON(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void WebPInitSharpYUVNEON(void) {
- WebPSharpYUVUpdateY = SharpYUVUpdateY_NEON;
- WebPSharpYUVUpdateRGB = SharpYUVUpdateRGB_NEON;
- WebPSharpYUVFilterRow = SharpYUVFilterRow_NEON;
-}
-
-#else // !WEBP_USE_NEON
-
-WEBP_DSP_INIT_STUB(WebPInitConvertARGBToYUVNEON)
-WEBP_DSP_INIT_STUB(WebPInitSharpYUVNEON)
-
-#endif // WEBP_USE_NEON
diff --git a/contrib/libs/libwebp/dsp/yuv_sse2.c b/contrib/libs/libwebp/dsp/yuv_sse2.c
deleted file mode 100644
index 0758febeed..0000000000
--- a/contrib/libs/libwebp/dsp/yuv_sse2.c
+++ /dev/null
@@ -1,874 +0,0 @@
-// Copyright 2014 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// YUV->RGB conversion functions
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include "./yuv.h"
-
-#if defined(WEBP_USE_SSE2)
-
-#include "./common_sse2.h"
-#include <stdlib.h>
-#include <emmintrin.h>
-
-//-----------------------------------------------------------------------------
-// Convert spans of 32 pixels to various RGB formats for the fancy upsampler.
-
-// These constants are 14b fixed-point version of ITU-R BT.601 constants.
-// R = (19077 * y + 26149 * v - 14234) >> 6
-// G = (19077 * y - 6419 * u - 13320 * v + 8708) >> 6
-// B = (19077 * y + 33050 * u - 17685) >> 6
-static void ConvertYUV444ToRGB_SSE2(const __m128i* const Y0,
- const __m128i* const U0,
- const __m128i* const V0,
- __m128i* const R,
- __m128i* const G,
- __m128i* const B) {
- const __m128i k19077 = _mm_set1_epi16(19077);
- const __m128i k26149 = _mm_set1_epi16(26149);
- const __m128i k14234 = _mm_set1_epi16(14234);
- // 33050 doesn't fit in a signed short: only use this with unsigned arithmetic
- const __m128i k33050 = _mm_set1_epi16((short)33050);
- const __m128i k17685 = _mm_set1_epi16(17685);
- const __m128i k6419 = _mm_set1_epi16(6419);
- const __m128i k13320 = _mm_set1_epi16(13320);
- const __m128i k8708 = _mm_set1_epi16(8708);
-
- const __m128i Y1 = _mm_mulhi_epu16(*Y0, k19077);
-
- const __m128i R0 = _mm_mulhi_epu16(*V0, k26149);
- const __m128i R1 = _mm_sub_epi16(Y1, k14234);
- const __m128i R2 = _mm_add_epi16(R1, R0);
-
- const __m128i G0 = _mm_mulhi_epu16(*U0, k6419);
- const __m128i G1 = _mm_mulhi_epu16(*V0, k13320);
- const __m128i G2 = _mm_add_epi16(Y1, k8708);
- const __m128i G3 = _mm_add_epi16(G0, G1);
- const __m128i G4 = _mm_sub_epi16(G2, G3);
-
- // be careful with the saturated *unsigned* arithmetic here!
- const __m128i B0 = _mm_mulhi_epu16(*U0, k33050);
- const __m128i B1 = _mm_adds_epu16(B0, Y1);
- const __m128i B2 = _mm_subs_epu16(B1, k17685);
-
- // use logical shift for B2, which can be larger than 32767
- *R = _mm_srai_epi16(R2, 6); // range: [-14234, 30815]
- *G = _mm_srai_epi16(G4, 6); // range: [-10953, 27710]
- *B = _mm_srli_epi16(B2, 6); // range: [0, 34238]
-}
-
-// Load the bytes into the *upper* part of 16b words. That's "<< 8", basically.
-static WEBP_INLINE __m128i Load_HI_16_SSE2(const uint8_t* src) {
- const __m128i zero = _mm_setzero_si128();
- return _mm_unpacklo_epi8(zero, _mm_loadl_epi64((const __m128i*)src));
-}
-
-// Load and replicate the U/V samples
-static WEBP_INLINE __m128i Load_UV_HI_8_SSE2(const uint8_t* src) {
- const __m128i zero = _mm_setzero_si128();
- const __m128i tmp0 = _mm_cvtsi32_si128(*(const uint32_t*)src);
- const __m128i tmp1 = _mm_unpacklo_epi8(zero, tmp0);
- return _mm_unpacklo_epi16(tmp1, tmp1); // replicate samples
-}
-
-// Convert 32 samples of YUV444 to R/G/B
-static void YUV444ToRGB_SSE2(const uint8_t* const y,
- const uint8_t* const u,
- const uint8_t* const v,
- __m128i* const R, __m128i* const G,
- __m128i* const B) {
- const __m128i Y0 = Load_HI_16_SSE2(y), U0 = Load_HI_16_SSE2(u),
- V0 = Load_HI_16_SSE2(v);
- ConvertYUV444ToRGB_SSE2(&Y0, &U0, &V0, R, G, B);
-}
-
-// Convert 32 samples of YUV420 to R/G/B
-static void YUV420ToRGB_SSE2(const uint8_t* const y,
- const uint8_t* const u,
- const uint8_t* const v,
- __m128i* const R, __m128i* const G,
- __m128i* const B) {
- const __m128i Y0 = Load_HI_16_SSE2(y), U0 = Load_UV_HI_8_SSE2(u),
- V0 = Load_UV_HI_8_SSE2(v);
- ConvertYUV444ToRGB_SSE2(&Y0, &U0, &V0, R, G, B);
-}
-
-// Pack R/G/B/A results into 32b output.
-static WEBP_INLINE void PackAndStore4_SSE2(const __m128i* const R,
- const __m128i* const G,
- const __m128i* const B,
- const __m128i* const A,
- uint8_t* const dst) {
- const __m128i rb = _mm_packus_epi16(*R, *B);
- const __m128i ga = _mm_packus_epi16(*G, *A);
- const __m128i rg = _mm_unpacklo_epi8(rb, ga);
- const __m128i ba = _mm_unpackhi_epi8(rb, ga);
- const __m128i RGBA_lo = _mm_unpacklo_epi16(rg, ba);
- const __m128i RGBA_hi = _mm_unpackhi_epi16(rg, ba);
- _mm_storeu_si128((__m128i*)(dst + 0), RGBA_lo);
- _mm_storeu_si128((__m128i*)(dst + 16), RGBA_hi);
-}
-
-// Pack R/G/B/A results into 16b output.
-static WEBP_INLINE void PackAndStore4444_SSE2(const __m128i* const R,
- const __m128i* const G,
- const __m128i* const B,
- const __m128i* const A,
- uint8_t* const dst) {
-#if (WEBP_SWAP_16BIT_CSP == 0)
- const __m128i rg0 = _mm_packus_epi16(*R, *G);
- const __m128i ba0 = _mm_packus_epi16(*B, *A);
-#else
- const __m128i rg0 = _mm_packus_epi16(*B, *A);
- const __m128i ba0 = _mm_packus_epi16(*R, *G);
-#endif
- const __m128i mask_0xf0 = _mm_set1_epi8(0xf0);
- const __m128i rb1 = _mm_unpacklo_epi8(rg0, ba0); // rbrbrbrbrb...
- const __m128i ga1 = _mm_unpackhi_epi8(rg0, ba0); // gagagagaga...
- const __m128i rb2 = _mm_and_si128(rb1, mask_0xf0);
- const __m128i ga2 = _mm_srli_epi16(_mm_and_si128(ga1, mask_0xf0), 4);
- const __m128i rgba4444 = _mm_or_si128(rb2, ga2);
- _mm_storeu_si128((__m128i*)dst, rgba4444);
-}
-
-// Pack R/G/B results into 16b output.
-static WEBP_INLINE void PackAndStore565_SSE2(const __m128i* const R,
- const __m128i* const G,
- const __m128i* const B,
- uint8_t* const dst) {
- const __m128i r0 = _mm_packus_epi16(*R, *R);
- const __m128i g0 = _mm_packus_epi16(*G, *G);
- const __m128i b0 = _mm_packus_epi16(*B, *B);
- const __m128i r1 = _mm_and_si128(r0, _mm_set1_epi8(0xf8));
- const __m128i b1 = _mm_and_si128(_mm_srli_epi16(b0, 3), _mm_set1_epi8(0x1f));
- const __m128i g1 = _mm_srli_epi16(_mm_and_si128(g0, _mm_set1_epi8(0xe0)), 5);
- const __m128i g2 = _mm_slli_epi16(_mm_and_si128(g0, _mm_set1_epi8(0x1c)), 3);
- const __m128i rg = _mm_or_si128(r1, g1);
- const __m128i gb = _mm_or_si128(g2, b1);
-#if (WEBP_SWAP_16BIT_CSP == 0)
- const __m128i rgb565 = _mm_unpacklo_epi8(rg, gb);
-#else
- const __m128i rgb565 = _mm_unpacklo_epi8(gb, rg);
-#endif
- _mm_storeu_si128((__m128i*)dst, rgb565);
-}
-
-// Pack the planar buffers
-// rrrr... rrrr... gggg... gggg... bbbb... bbbb....
-// triplet by triplet in the output buffer rgb as rgbrgbrgbrgb ...
-static WEBP_INLINE void PlanarTo24b_SSE2(__m128i* const in0, __m128i* const in1,
- __m128i* const in2, __m128i* const in3,
- __m128i* const in4, __m128i* const in5,
- uint8_t* const rgb) {
- // The input is 6 registers of sixteen 8b but for the sake of explanation,
- // let's take 6 registers of four 8b values.
- // To pack, we will keep taking one every two 8b integer and move it
- // around as follows:
- // Input:
- // r0r1r2r3 | r4r5r6r7 | g0g1g2g3 | g4g5g6g7 | b0b1b2b3 | b4b5b6b7
- // Split the 6 registers in two sets of 3 registers: the first set as the even
- // 8b bytes, the second the odd ones:
- // r0r2r4r6 | g0g2g4g6 | b0b2b4b6 | r1r3r5r7 | g1g3g5g7 | b1b3b5b7
- // Repeat the same permutations twice more:
- // r0r4g0g4 | b0b4r1r5 | g1g5b1b5 | r2r6g2g6 | b2b6r3r7 | g3g7b3b7
- // r0g0b0r1 | g1b1r2g2 | b2r3g3b3 | r4g4b4r5 | g5b5r6g6 | b6r7g7b7
- VP8PlanarTo24b_SSE2(in0, in1, in2, in3, in4, in5);
-
- _mm_storeu_si128((__m128i*)(rgb + 0), *in0);
- _mm_storeu_si128((__m128i*)(rgb + 16), *in1);
- _mm_storeu_si128((__m128i*)(rgb + 32), *in2);
- _mm_storeu_si128((__m128i*)(rgb + 48), *in3);
- _mm_storeu_si128((__m128i*)(rgb + 64), *in4);
- _mm_storeu_si128((__m128i*)(rgb + 80), *in5);
-}
-
-void VP8YuvToRgba32_SSE2(const uint8_t* y, const uint8_t* u, const uint8_t* v,
- uint8_t* dst) {
- const __m128i kAlpha = _mm_set1_epi16(255);
- int n;
- for (n = 0; n < 32; n += 8, dst += 32) {
- __m128i R, G, B;
- YUV444ToRGB_SSE2(y + n, u + n, v + n, &R, &G, &B);
- PackAndStore4_SSE2(&R, &G, &B, &kAlpha, dst);
- }
-}
-
-void VP8YuvToBgra32_SSE2(const uint8_t* y, const uint8_t* u, const uint8_t* v,
- uint8_t* dst) {
- const __m128i kAlpha = _mm_set1_epi16(255);
- int n;
- for (n = 0; n < 32; n += 8, dst += 32) {
- __m128i R, G, B;
- YUV444ToRGB_SSE2(y + n, u + n, v + n, &R, &G, &B);
- PackAndStore4_SSE2(&B, &G, &R, &kAlpha, dst);
- }
-}
-
-void VP8YuvToArgb32_SSE2(const uint8_t* y, const uint8_t* u, const uint8_t* v,
- uint8_t* dst) {
- const __m128i kAlpha = _mm_set1_epi16(255);
- int n;
- for (n = 0; n < 32; n += 8, dst += 32) {
- __m128i R, G, B;
- YUV444ToRGB_SSE2(y + n, u + n, v + n, &R, &G, &B);
- PackAndStore4_SSE2(&kAlpha, &R, &G, &B, dst);
- }
-}
-
-void VP8YuvToRgba444432_SSE2(const uint8_t* y, const uint8_t* u,
- const uint8_t* v, uint8_t* dst) {
- const __m128i kAlpha = _mm_set1_epi16(255);
- int n;
- for (n = 0; n < 32; n += 8, dst += 16) {
- __m128i R, G, B;
- YUV444ToRGB_SSE2(y + n, u + n, v + n, &R, &G, &B);
- PackAndStore4444_SSE2(&R, &G, &B, &kAlpha, dst);
- }
-}
-
-void VP8YuvToRgb56532_SSE2(const uint8_t* y, const uint8_t* u, const uint8_t* v,
- uint8_t* dst) {
- int n;
- for (n = 0; n < 32; n += 8, dst += 16) {
- __m128i R, G, B;
- YUV444ToRGB_SSE2(y + n, u + n, v + n, &R, &G, &B);
- PackAndStore565_SSE2(&R, &G, &B, dst);
- }
-}
-
-void VP8YuvToRgb32_SSE2(const uint8_t* y, const uint8_t* u, const uint8_t* v,
- uint8_t* dst) {
- __m128i R0, R1, R2, R3, G0, G1, G2, G3, B0, B1, B2, B3;
- __m128i rgb0, rgb1, rgb2, rgb3, rgb4, rgb5;
-
- YUV444ToRGB_SSE2(y + 0, u + 0, v + 0, &R0, &G0, &B0);
- YUV444ToRGB_SSE2(y + 8, u + 8, v + 8, &R1, &G1, &B1);
- YUV444ToRGB_SSE2(y + 16, u + 16, v + 16, &R2, &G2, &B2);
- YUV444ToRGB_SSE2(y + 24, u + 24, v + 24, &R3, &G3, &B3);
-
- // Cast to 8b and store as RRRRGGGGBBBB.
- rgb0 = _mm_packus_epi16(R0, R1);
- rgb1 = _mm_packus_epi16(R2, R3);
- rgb2 = _mm_packus_epi16(G0, G1);
- rgb3 = _mm_packus_epi16(G2, G3);
- rgb4 = _mm_packus_epi16(B0, B1);
- rgb5 = _mm_packus_epi16(B2, B3);
-
- // Pack as RGBRGBRGBRGB.
- PlanarTo24b_SSE2(&rgb0, &rgb1, &rgb2, &rgb3, &rgb4, &rgb5, dst);
-}
-
-void VP8YuvToBgr32_SSE2(const uint8_t* y, const uint8_t* u, const uint8_t* v,
- uint8_t* dst) {
- __m128i R0, R1, R2, R3, G0, G1, G2, G3, B0, B1, B2, B3;
- __m128i bgr0, bgr1, bgr2, bgr3, bgr4, bgr5;
-
- YUV444ToRGB_SSE2(y + 0, u + 0, v + 0, &R0, &G0, &B0);
- YUV444ToRGB_SSE2(y + 8, u + 8, v + 8, &R1, &G1, &B1);
- YUV444ToRGB_SSE2(y + 16, u + 16, v + 16, &R2, &G2, &B2);
- YUV444ToRGB_SSE2(y + 24, u + 24, v + 24, &R3, &G3, &B3);
-
- // Cast to 8b and store as BBBBGGGGRRRR.
- bgr0 = _mm_packus_epi16(B0, B1);
- bgr1 = _mm_packus_epi16(B2, B3);
- bgr2 = _mm_packus_epi16(G0, G1);
- bgr3 = _mm_packus_epi16(G2, G3);
- bgr4 = _mm_packus_epi16(R0, R1);
- bgr5= _mm_packus_epi16(R2, R3);
-
- // Pack as BGRBGRBGRBGR.
- PlanarTo24b_SSE2(&bgr0, &bgr1, &bgr2, &bgr3, &bgr4, &bgr5, dst);
-}
-
-//-----------------------------------------------------------------------------
-// Arbitrary-length row conversion functions
-
-static void YuvToRgbaRow_SSE2(const uint8_t* y,
- const uint8_t* u, const uint8_t* v,
- uint8_t* dst, int len) {
- const __m128i kAlpha = _mm_set1_epi16(255);
- int n;
- for (n = 0; n + 8 <= len; n += 8, dst += 32) {
- __m128i R, G, B;
- YUV420ToRGB_SSE2(y, u, v, &R, &G, &B);
- PackAndStore4_SSE2(&R, &G, &B, &kAlpha, dst);
- y += 8;
- u += 4;
- v += 4;
- }
- for (; n < len; ++n) { // Finish off
- VP8YuvToRgba(y[0], u[0], v[0], dst);
- dst += 4;
- y += 1;
- u += (n & 1);
- v += (n & 1);
- }
-}
-
-static void YuvToBgraRow_SSE2(const uint8_t* y,
- const uint8_t* u, const uint8_t* v,
- uint8_t* dst, int len) {
- const __m128i kAlpha = _mm_set1_epi16(255);
- int n;
- for (n = 0; n + 8 <= len; n += 8, dst += 32) {
- __m128i R, G, B;
- YUV420ToRGB_SSE2(y, u, v, &R, &G, &B);
- PackAndStore4_SSE2(&B, &G, &R, &kAlpha, dst);
- y += 8;
- u += 4;
- v += 4;
- }
- for (; n < len; ++n) { // Finish off
- VP8YuvToBgra(y[0], u[0], v[0], dst);
- dst += 4;
- y += 1;
- u += (n & 1);
- v += (n & 1);
- }
-}
-
-static void YuvToArgbRow_SSE2(const uint8_t* y,
- const uint8_t* u, const uint8_t* v,
- uint8_t* dst, int len) {
- const __m128i kAlpha = _mm_set1_epi16(255);
- int n;
- for (n = 0; n + 8 <= len; n += 8, dst += 32) {
- __m128i R, G, B;
- YUV420ToRGB_SSE2(y, u, v, &R, &G, &B);
- PackAndStore4_SSE2(&kAlpha, &R, &G, &B, dst);
- y += 8;
- u += 4;
- v += 4;
- }
- for (; n < len; ++n) { // Finish off
- VP8YuvToArgb(y[0], u[0], v[0], dst);
- dst += 4;
- y += 1;
- u += (n & 1);
- v += (n & 1);
- }
-}
-
-static void YuvToRgbRow_SSE2(const uint8_t* y,
- const uint8_t* u, const uint8_t* v,
- uint8_t* dst, int len) {
- int n;
- for (n = 0; n + 32 <= len; n += 32, dst += 32 * 3) {
- __m128i R0, R1, R2, R3, G0, G1, G2, G3, B0, B1, B2, B3;
- __m128i rgb0, rgb1, rgb2, rgb3, rgb4, rgb5;
-
- YUV420ToRGB_SSE2(y + 0, u + 0, v + 0, &R0, &G0, &B0);
- YUV420ToRGB_SSE2(y + 8, u + 4, v + 4, &R1, &G1, &B1);
- YUV420ToRGB_SSE2(y + 16, u + 8, v + 8, &R2, &G2, &B2);
- YUV420ToRGB_SSE2(y + 24, u + 12, v + 12, &R3, &G3, &B3);
-
- // Cast to 8b and store as RRRRGGGGBBBB.
- rgb0 = _mm_packus_epi16(R0, R1);
- rgb1 = _mm_packus_epi16(R2, R3);
- rgb2 = _mm_packus_epi16(G0, G1);
- rgb3 = _mm_packus_epi16(G2, G3);
- rgb4 = _mm_packus_epi16(B0, B1);
- rgb5 = _mm_packus_epi16(B2, B3);
-
- // Pack as RGBRGBRGBRGB.
- PlanarTo24b_SSE2(&rgb0, &rgb1, &rgb2, &rgb3, &rgb4, &rgb5, dst);
-
- y += 32;
- u += 16;
- v += 16;
- }
- for (; n < len; ++n) { // Finish off
- VP8YuvToRgb(y[0], u[0], v[0], dst);
- dst += 3;
- y += 1;
- u += (n & 1);
- v += (n & 1);
- }
-}
-
-static void YuvToBgrRow_SSE2(const uint8_t* y,
- const uint8_t* u, const uint8_t* v,
- uint8_t* dst, int len) {
- int n;
- for (n = 0; n + 32 <= len; n += 32, dst += 32 * 3) {
- __m128i R0, R1, R2, R3, G0, G1, G2, G3, B0, B1, B2, B3;
- __m128i bgr0, bgr1, bgr2, bgr3, bgr4, bgr5;
-
- YUV420ToRGB_SSE2(y + 0, u + 0, v + 0, &R0, &G0, &B0);
- YUV420ToRGB_SSE2(y + 8, u + 4, v + 4, &R1, &G1, &B1);
- YUV420ToRGB_SSE2(y + 16, u + 8, v + 8, &R2, &G2, &B2);
- YUV420ToRGB_SSE2(y + 24, u + 12, v + 12, &R3, &G3, &B3);
-
- // Cast to 8b and store as BBBBGGGGRRRR.
- bgr0 = _mm_packus_epi16(B0, B1);
- bgr1 = _mm_packus_epi16(B2, B3);
- bgr2 = _mm_packus_epi16(G0, G1);
- bgr3 = _mm_packus_epi16(G2, G3);
- bgr4 = _mm_packus_epi16(R0, R1);
- bgr5 = _mm_packus_epi16(R2, R3);
-
- // Pack as BGRBGRBGRBGR.
- PlanarTo24b_SSE2(&bgr0, &bgr1, &bgr2, &bgr3, &bgr4, &bgr5, dst);
-
- y += 32;
- u += 16;
- v += 16;
- }
- for (; n < len; ++n) { // Finish off
- VP8YuvToBgr(y[0], u[0], v[0], dst);
- dst += 3;
- y += 1;
- u += (n & 1);
- v += (n & 1);
- }
-}
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void WebPInitSamplersSSE2(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void WebPInitSamplersSSE2(void) {
- WebPSamplers[MODE_RGB] = YuvToRgbRow_SSE2;
- WebPSamplers[MODE_RGBA] = YuvToRgbaRow_SSE2;
- WebPSamplers[MODE_BGR] = YuvToBgrRow_SSE2;
- WebPSamplers[MODE_BGRA] = YuvToBgraRow_SSE2;
- WebPSamplers[MODE_ARGB] = YuvToArgbRow_SSE2;
-}
-
-//------------------------------------------------------------------------------
-// RGB24/32 -> YUV converters
-
-// Load eight 16b-words from *src.
-#define LOAD_16(src) _mm_loadu_si128((const __m128i*)(src))
-// Store either 16b-words into *dst
-#define STORE_16(V, dst) _mm_storeu_si128((__m128i*)(dst), (V))
-
-// Function that inserts a value of the second half of the in buffer in between
-// every two char of the first half.
-static WEBP_INLINE void RGB24PackedToPlanarHelper_SSE2(
- const __m128i* const in /*in[6]*/, __m128i* const out /*out[6]*/) {
- out[0] = _mm_unpacklo_epi8(in[0], in[3]);
- out[1] = _mm_unpackhi_epi8(in[0], in[3]);
- out[2] = _mm_unpacklo_epi8(in[1], in[4]);
- out[3] = _mm_unpackhi_epi8(in[1], in[4]);
- out[4] = _mm_unpacklo_epi8(in[2], in[5]);
- out[5] = _mm_unpackhi_epi8(in[2], in[5]);
-}
-
-// Unpack the 8b input rgbrgbrgbrgb ... as contiguous registers:
-// rrrr... rrrr... gggg... gggg... bbbb... bbbb....
-// Similar to PlanarTo24bHelper(), but in reverse order.
-static WEBP_INLINE void RGB24PackedToPlanar_SSE2(
- const uint8_t* const rgb, __m128i* const out /*out[6]*/) {
- __m128i tmp[6];
- tmp[0] = _mm_loadu_si128((const __m128i*)(rgb + 0));
- tmp[1] = _mm_loadu_si128((const __m128i*)(rgb + 16));
- tmp[2] = _mm_loadu_si128((const __m128i*)(rgb + 32));
- tmp[3] = _mm_loadu_si128((const __m128i*)(rgb + 48));
- tmp[4] = _mm_loadu_si128((const __m128i*)(rgb + 64));
- tmp[5] = _mm_loadu_si128((const __m128i*)(rgb + 80));
-
- RGB24PackedToPlanarHelper_SSE2(tmp, out);
- RGB24PackedToPlanarHelper_SSE2(out, tmp);
- RGB24PackedToPlanarHelper_SSE2(tmp, out);
- RGB24PackedToPlanarHelper_SSE2(out, tmp);
- RGB24PackedToPlanarHelper_SSE2(tmp, out);
-}
-
-// Convert 8 packed ARGB to r[], g[], b[]
-static WEBP_INLINE void RGB32PackedToPlanar_SSE2(const uint32_t* const argb,
- __m128i* const rgb /*in[6]*/) {
- const __m128i zero = _mm_setzero_si128();
- __m128i a0 = LOAD_16(argb + 0);
- __m128i a1 = LOAD_16(argb + 4);
- __m128i a2 = LOAD_16(argb + 8);
- __m128i a3 = LOAD_16(argb + 12);
- VP8L32bToPlanar_SSE2(&a0, &a1, &a2, &a3);
- rgb[0] = _mm_unpacklo_epi8(a1, zero);
- rgb[1] = _mm_unpackhi_epi8(a1, zero);
- rgb[2] = _mm_unpacklo_epi8(a2, zero);
- rgb[3] = _mm_unpackhi_epi8(a2, zero);
- rgb[4] = _mm_unpacklo_epi8(a3, zero);
- rgb[5] = _mm_unpackhi_epi8(a3, zero);
-}
-
-// This macro computes (RG * MULT_RG + GB * MULT_GB + ROUNDER) >> DESCALE_FIX
-// It's a macro and not a function because we need to use immediate values with
-// srai_epi32, e.g.
-#define TRANSFORM(RG_LO, RG_HI, GB_LO, GB_HI, MULT_RG, MULT_GB, \
- ROUNDER, DESCALE_FIX, OUT) do { \
- const __m128i V0_lo = _mm_madd_epi16(RG_LO, MULT_RG); \
- const __m128i V0_hi = _mm_madd_epi16(RG_HI, MULT_RG); \
- const __m128i V1_lo = _mm_madd_epi16(GB_LO, MULT_GB); \
- const __m128i V1_hi = _mm_madd_epi16(GB_HI, MULT_GB); \
- const __m128i V2_lo = _mm_add_epi32(V0_lo, V1_lo); \
- const __m128i V2_hi = _mm_add_epi32(V0_hi, V1_hi); \
- const __m128i V3_lo = _mm_add_epi32(V2_lo, ROUNDER); \
- const __m128i V3_hi = _mm_add_epi32(V2_hi, ROUNDER); \
- const __m128i V5_lo = _mm_srai_epi32(V3_lo, DESCALE_FIX); \
- const __m128i V5_hi = _mm_srai_epi32(V3_hi, DESCALE_FIX); \
- (OUT) = _mm_packs_epi32(V5_lo, V5_hi); \
-} while (0)
-
-#define MK_CST_16(A, B) _mm_set_epi16((B), (A), (B), (A), (B), (A), (B), (A))
-static WEBP_INLINE void ConvertRGBToY_SSE2(const __m128i* const R,
- const __m128i* const G,
- const __m128i* const B,
- __m128i* const Y) {
- const __m128i kRG_y = MK_CST_16(16839, 33059 - 16384);
- const __m128i kGB_y = MK_CST_16(16384, 6420);
- const __m128i kHALF_Y = _mm_set1_epi32((16 << YUV_FIX) + YUV_HALF);
-
- const __m128i RG_lo = _mm_unpacklo_epi16(*R, *G);
- const __m128i RG_hi = _mm_unpackhi_epi16(*R, *G);
- const __m128i GB_lo = _mm_unpacklo_epi16(*G, *B);
- const __m128i GB_hi = _mm_unpackhi_epi16(*G, *B);
- TRANSFORM(RG_lo, RG_hi, GB_lo, GB_hi, kRG_y, kGB_y, kHALF_Y, YUV_FIX, *Y);
-}
-
-static WEBP_INLINE void ConvertRGBToUV_SSE2(const __m128i* const R,
- const __m128i* const G,
- const __m128i* const B,
- __m128i* const U,
- __m128i* const V) {
- const __m128i kRG_u = MK_CST_16(-9719, -19081);
- const __m128i kGB_u = MK_CST_16(0, 28800);
- const __m128i kRG_v = MK_CST_16(28800, 0);
- const __m128i kGB_v = MK_CST_16(-24116, -4684);
- const __m128i kHALF_UV = _mm_set1_epi32(((128 << YUV_FIX) + YUV_HALF) << 2);
-
- const __m128i RG_lo = _mm_unpacklo_epi16(*R, *G);
- const __m128i RG_hi = _mm_unpackhi_epi16(*R, *G);
- const __m128i GB_lo = _mm_unpacklo_epi16(*G, *B);
- const __m128i GB_hi = _mm_unpackhi_epi16(*G, *B);
- TRANSFORM(RG_lo, RG_hi, GB_lo, GB_hi, kRG_u, kGB_u,
- kHALF_UV, YUV_FIX + 2, *U);
- TRANSFORM(RG_lo, RG_hi, GB_lo, GB_hi, kRG_v, kGB_v,
- kHALF_UV, YUV_FIX + 2, *V);
-}
-
-#undef MK_CST_16
-#undef TRANSFORM
-
-static void ConvertRGB24ToY_SSE2(const uint8_t* rgb, uint8_t* y, int width) {
- const int max_width = width & ~31;
- int i;
- for (i = 0; i < max_width; rgb += 3 * 16 * 2) {
- __m128i rgb_plane[6];
- int j;
-
- RGB24PackedToPlanar_SSE2(rgb, rgb_plane);
-
- for (j = 0; j < 2; ++j, i += 16) {
- const __m128i zero = _mm_setzero_si128();
- __m128i r, g, b, Y0, Y1;
-
- // Convert to 16-bit Y.
- r = _mm_unpacklo_epi8(rgb_plane[0 + j], zero);
- g = _mm_unpacklo_epi8(rgb_plane[2 + j], zero);
- b = _mm_unpacklo_epi8(rgb_plane[4 + j], zero);
- ConvertRGBToY_SSE2(&r, &g, &b, &Y0);
-
- // Convert to 16-bit Y.
- r = _mm_unpackhi_epi8(rgb_plane[0 + j], zero);
- g = _mm_unpackhi_epi8(rgb_plane[2 + j], zero);
- b = _mm_unpackhi_epi8(rgb_plane[4 + j], zero);
- ConvertRGBToY_SSE2(&r, &g, &b, &Y1);
-
- // Cast to 8-bit and store.
- STORE_16(_mm_packus_epi16(Y0, Y1), y + i);
- }
- }
- for (; i < width; ++i, rgb += 3) { // left-over
- y[i] = VP8RGBToY(rgb[0], rgb[1], rgb[2], YUV_HALF);
- }
-}
-
-static void ConvertBGR24ToY_SSE2(const uint8_t* bgr, uint8_t* y, int width) {
- const int max_width = width & ~31;
- int i;
- for (i = 0; i < max_width; bgr += 3 * 16 * 2) {
- __m128i bgr_plane[6];
- int j;
-
- RGB24PackedToPlanar_SSE2(bgr, bgr_plane);
-
- for (j = 0; j < 2; ++j, i += 16) {
- const __m128i zero = _mm_setzero_si128();
- __m128i r, g, b, Y0, Y1;
-
- // Convert to 16-bit Y.
- b = _mm_unpacklo_epi8(bgr_plane[0 + j], zero);
- g = _mm_unpacklo_epi8(bgr_plane[2 + j], zero);
- r = _mm_unpacklo_epi8(bgr_plane[4 + j], zero);
- ConvertRGBToY_SSE2(&r, &g, &b, &Y0);
-
- // Convert to 16-bit Y.
- b = _mm_unpackhi_epi8(bgr_plane[0 + j], zero);
- g = _mm_unpackhi_epi8(bgr_plane[2 + j], zero);
- r = _mm_unpackhi_epi8(bgr_plane[4 + j], zero);
- ConvertRGBToY_SSE2(&r, &g, &b, &Y1);
-
- // Cast to 8-bit and store.
- STORE_16(_mm_packus_epi16(Y0, Y1), y + i);
- }
- }
- for (; i < width; ++i, bgr += 3) { // left-over
- y[i] = VP8RGBToY(bgr[2], bgr[1], bgr[0], YUV_HALF);
- }
-}
-
-static void ConvertARGBToY_SSE2(const uint32_t* argb, uint8_t* y, int width) {
- const int max_width = width & ~15;
- int i;
- for (i = 0; i < max_width; i += 16) {
- __m128i Y0, Y1, rgb[6];
- RGB32PackedToPlanar_SSE2(&argb[i], rgb);
- ConvertRGBToY_SSE2(&rgb[0], &rgb[2], &rgb[4], &Y0);
- ConvertRGBToY_SSE2(&rgb[1], &rgb[3], &rgb[5], &Y1);
- STORE_16(_mm_packus_epi16(Y0, Y1), y + i);
- }
- for (; i < width; ++i) { // left-over
- const uint32_t p = argb[i];
- y[i] = VP8RGBToY((p >> 16) & 0xff, (p >> 8) & 0xff, (p >> 0) & 0xff,
- YUV_HALF);
- }
-}
-
-// Horizontal add (doubled) of two 16b values, result is 16b.
-// in: A | B | C | D | ... -> out: 2*(A+B) | 2*(C+D) | ...
-static void HorizontalAddPack_SSE2(const __m128i* const A,
- const __m128i* const B,
- __m128i* const out) {
- const __m128i k2 = _mm_set1_epi16(2);
- const __m128i C = _mm_madd_epi16(*A, k2);
- const __m128i D = _mm_madd_epi16(*B, k2);
- *out = _mm_packs_epi32(C, D);
-}
-
-static void ConvertARGBToUV_SSE2(const uint32_t* argb,
- uint8_t* u, uint8_t* v,
- int src_width, int do_store) {
- const int max_width = src_width & ~31;
- int i;
- for (i = 0; i < max_width; i += 32, u += 16, v += 16) {
- __m128i rgb[6], U0, V0, U1, V1;
- RGB32PackedToPlanar_SSE2(&argb[i], rgb);
- HorizontalAddPack_SSE2(&rgb[0], &rgb[1], &rgb[0]);
- HorizontalAddPack_SSE2(&rgb[2], &rgb[3], &rgb[2]);
- HorizontalAddPack_SSE2(&rgb[4], &rgb[5], &rgb[4]);
- ConvertRGBToUV_SSE2(&rgb[0], &rgb[2], &rgb[4], &U0, &V0);
-
- RGB32PackedToPlanar_SSE2(&argb[i + 16], rgb);
- HorizontalAddPack_SSE2(&rgb[0], &rgb[1], &rgb[0]);
- HorizontalAddPack_SSE2(&rgb[2], &rgb[3], &rgb[2]);
- HorizontalAddPack_SSE2(&rgb[4], &rgb[5], &rgb[4]);
- ConvertRGBToUV_SSE2(&rgb[0], &rgb[2], &rgb[4], &U1, &V1);
-
- U0 = _mm_packus_epi16(U0, U1);
- V0 = _mm_packus_epi16(V0, V1);
- if (!do_store) {
- const __m128i prev_u = LOAD_16(u);
- const __m128i prev_v = LOAD_16(v);
- U0 = _mm_avg_epu8(U0, prev_u);
- V0 = _mm_avg_epu8(V0, prev_v);
- }
- STORE_16(U0, u);
- STORE_16(V0, v);
- }
- if (i < src_width) { // left-over
- WebPConvertARGBToUV_C(argb + i, u, v, src_width - i, do_store);
- }
-}
-
-// Convert 16 packed ARGB 16b-values to r[], g[], b[]
-static WEBP_INLINE void RGBA32PackedToPlanar_16b_SSE2(
- const uint16_t* const rgbx,
- __m128i* const r, __m128i* const g, __m128i* const b) {
- const __m128i in0 = LOAD_16(rgbx + 0); // r0 | g0 | b0 |x| r1 | g1 | b1 |x
- const __m128i in1 = LOAD_16(rgbx + 8); // r2 | g2 | b2 |x| r3 | g3 | b3 |x
- const __m128i in2 = LOAD_16(rgbx + 16); // r4 | ...
- const __m128i in3 = LOAD_16(rgbx + 24); // r6 | ...
- // column-wise transpose
- const __m128i A0 = _mm_unpacklo_epi16(in0, in1);
- const __m128i A1 = _mm_unpackhi_epi16(in0, in1);
- const __m128i A2 = _mm_unpacklo_epi16(in2, in3);
- const __m128i A3 = _mm_unpackhi_epi16(in2, in3);
- const __m128i B0 = _mm_unpacklo_epi16(A0, A1); // r0 r1 r2 r3 | g0 g1 ..
- const __m128i B1 = _mm_unpackhi_epi16(A0, A1); // b0 b1 b2 b3 | x x x x
- const __m128i B2 = _mm_unpacklo_epi16(A2, A3); // r4 r5 r6 r7 | g4 g5 ..
- const __m128i B3 = _mm_unpackhi_epi16(A2, A3); // b4 b5 b6 b7 | x x x x
- *r = _mm_unpacklo_epi64(B0, B2);
- *g = _mm_unpackhi_epi64(B0, B2);
- *b = _mm_unpacklo_epi64(B1, B3);
-}
-
-static void ConvertRGBA32ToUV_SSE2(const uint16_t* rgb,
- uint8_t* u, uint8_t* v, int width) {
- const int max_width = width & ~15;
- const uint16_t* const last_rgb = rgb + 4 * max_width;
- while (rgb < last_rgb) {
- __m128i r, g, b, U0, V0, U1, V1;
- RGBA32PackedToPlanar_16b_SSE2(rgb + 0, &r, &g, &b);
- ConvertRGBToUV_SSE2(&r, &g, &b, &U0, &V0);
- RGBA32PackedToPlanar_16b_SSE2(rgb + 32, &r, &g, &b);
- ConvertRGBToUV_SSE2(&r, &g, &b, &U1, &V1);
- STORE_16(_mm_packus_epi16(U0, U1), u);
- STORE_16(_mm_packus_epi16(V0, V1), v);
- u += 16;
- v += 16;
- rgb += 2 * 32;
- }
- if (max_width < width) { // left-over
- WebPConvertRGBA32ToUV_C(rgb, u, v, width - max_width);
- }
-}
-
-//------------------------------------------------------------------------------
-
-extern void WebPInitConvertARGBToYUVSSE2(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void WebPInitConvertARGBToYUVSSE2(void) {
- WebPConvertARGBToY = ConvertARGBToY_SSE2;
- WebPConvertARGBToUV = ConvertARGBToUV_SSE2;
-
- WebPConvertRGB24ToY = ConvertRGB24ToY_SSE2;
- WebPConvertBGR24ToY = ConvertBGR24ToY_SSE2;
-
- WebPConvertRGBA32ToUV = ConvertRGBA32ToUV_SSE2;
-}
-
-//------------------------------------------------------------------------------
-
-#define MAX_Y ((1 << 10) - 1) // 10b precision over 16b-arithmetic
-static uint16_t clip_y(int v) {
- return (v < 0) ? 0 : (v > MAX_Y) ? MAX_Y : (uint16_t)v;
-}
-
-static uint64_t SharpYUVUpdateY_SSE2(const uint16_t* ref, const uint16_t* src,
- uint16_t* dst, int len) {
- uint64_t diff = 0;
- uint32_t tmp[4];
- int i;
- const __m128i zero = _mm_setzero_si128();
- const __m128i max = _mm_set1_epi16(MAX_Y);
- const __m128i one = _mm_set1_epi16(1);
- __m128i sum = zero;
-
- for (i = 0; i + 8 <= len; i += 8) {
- const __m128i A = _mm_loadu_si128((const __m128i*)(ref + i));
- const __m128i B = _mm_loadu_si128((const __m128i*)(src + i));
- const __m128i C = _mm_loadu_si128((const __m128i*)(dst + i));
- const __m128i D = _mm_sub_epi16(A, B); // diff_y
- const __m128i E = _mm_cmpgt_epi16(zero, D); // sign (-1 or 0)
- const __m128i F = _mm_add_epi16(C, D); // new_y
- const __m128i G = _mm_or_si128(E, one); // -1 or 1
- const __m128i H = _mm_max_epi16(_mm_min_epi16(F, max), zero);
- const __m128i I = _mm_madd_epi16(D, G); // sum(abs(...))
- _mm_storeu_si128((__m128i*)(dst + i), H);
- sum = _mm_add_epi32(sum, I);
- }
- _mm_storeu_si128((__m128i*)tmp, sum);
- diff = tmp[3] + tmp[2] + tmp[1] + tmp[0];
- for (; i < len; ++i) {
- const int diff_y = ref[i] - src[i];
- const int new_y = (int)dst[i] + diff_y;
- dst[i] = clip_y(new_y);
- diff += (uint64_t)abs(diff_y);
- }
- return diff;
-}
-
-static void SharpYUVUpdateRGB_SSE2(const int16_t* ref, const int16_t* src,
- int16_t* dst, int len) {
- int i = 0;
- for (i = 0; i + 8 <= len; i += 8) {
- const __m128i A = _mm_loadu_si128((const __m128i*)(ref + i));
- const __m128i B = _mm_loadu_si128((const __m128i*)(src + i));
- const __m128i C = _mm_loadu_si128((const __m128i*)(dst + i));
- const __m128i D = _mm_sub_epi16(A, B); // diff_uv
- const __m128i E = _mm_add_epi16(C, D); // new_uv
- _mm_storeu_si128((__m128i*)(dst + i), E);
- }
- for (; i < len; ++i) {
- const int diff_uv = ref[i] - src[i];
- dst[i] += diff_uv;
- }
-}
-
-static void SharpYUVFilterRow_SSE2(const int16_t* A, const int16_t* B, int len,
- const uint16_t* best_y, uint16_t* out) {
- int i;
- const __m128i kCst8 = _mm_set1_epi16(8);
- const __m128i max = _mm_set1_epi16(MAX_Y);
- const __m128i zero = _mm_setzero_si128();
- for (i = 0; i + 8 <= len; i += 8) {
- const __m128i a0 = _mm_loadu_si128((const __m128i*)(A + i + 0));
- const __m128i a1 = _mm_loadu_si128((const __m128i*)(A + i + 1));
- const __m128i b0 = _mm_loadu_si128((const __m128i*)(B + i + 0));
- const __m128i b1 = _mm_loadu_si128((const __m128i*)(B + i + 1));
- const __m128i a0b1 = _mm_add_epi16(a0, b1);
- const __m128i a1b0 = _mm_add_epi16(a1, b0);
- const __m128i a0a1b0b1 = _mm_add_epi16(a0b1, a1b0); // A0+A1+B0+B1
- const __m128i a0a1b0b1_8 = _mm_add_epi16(a0a1b0b1, kCst8);
- const __m128i a0b1_2 = _mm_add_epi16(a0b1, a0b1); // 2*(A0+B1)
- const __m128i a1b0_2 = _mm_add_epi16(a1b0, a1b0); // 2*(A1+B0)
- const __m128i c0 = _mm_srai_epi16(_mm_add_epi16(a0b1_2, a0a1b0b1_8), 3);
- const __m128i c1 = _mm_srai_epi16(_mm_add_epi16(a1b0_2, a0a1b0b1_8), 3);
- const __m128i d0 = _mm_add_epi16(c1, a0);
- const __m128i d1 = _mm_add_epi16(c0, a1);
- const __m128i e0 = _mm_srai_epi16(d0, 1);
- const __m128i e1 = _mm_srai_epi16(d1, 1);
- const __m128i f0 = _mm_unpacklo_epi16(e0, e1);
- const __m128i f1 = _mm_unpackhi_epi16(e0, e1);
- const __m128i g0 = _mm_loadu_si128((const __m128i*)(best_y + 2 * i + 0));
- const __m128i g1 = _mm_loadu_si128((const __m128i*)(best_y + 2 * i + 8));
- const __m128i h0 = _mm_add_epi16(g0, f0);
- const __m128i h1 = _mm_add_epi16(g1, f1);
- const __m128i i0 = _mm_max_epi16(_mm_min_epi16(h0, max), zero);
- const __m128i i1 = _mm_max_epi16(_mm_min_epi16(h1, max), zero);
- _mm_storeu_si128((__m128i*)(out + 2 * i + 0), i0);
- _mm_storeu_si128((__m128i*)(out + 2 * i + 8), i1);
- }
- for (; i < len; ++i) {
- // (9 * A0 + 3 * A1 + 3 * B0 + B1 + 8) >> 4 =
- // = (8 * A0 + 2 * (A1 + B0) + (A0 + A1 + B0 + B1 + 8)) >> 4
- // We reuse the common sub-expressions.
- const int a0b1 = A[i + 0] + B[i + 1];
- const int a1b0 = A[i + 1] + B[i + 0];
- const int a0a1b0b1 = a0b1 + a1b0 + 8;
- const int v0 = (8 * A[i + 0] + 2 * a1b0 + a0a1b0b1) >> 4;
- const int v1 = (8 * A[i + 1] + 2 * a0b1 + a0a1b0b1) >> 4;
- out[2 * i + 0] = clip_y(best_y[2 * i + 0] + v0);
- out[2 * i + 1] = clip_y(best_y[2 * i + 1] + v1);
- }
-}
-
-#undef MAX_Y
-
-//------------------------------------------------------------------------------
-
-extern void WebPInitSharpYUVSSE2(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void WebPInitSharpYUVSSE2(void) {
- WebPSharpYUVUpdateY = SharpYUVUpdateY_SSE2;
- WebPSharpYUVUpdateRGB = SharpYUVUpdateRGB_SSE2;
- WebPSharpYUVFilterRow = SharpYUVFilterRow_SSE2;
-}
-
-#else // !WEBP_USE_SSE2
-
-WEBP_DSP_INIT_STUB(WebPInitSamplersSSE2)
-WEBP_DSP_INIT_STUB(WebPInitConvertARGBToYUVSSE2)
-WEBP_DSP_INIT_STUB(WebPInitSharpYUVSSE2)
-
-#endif // WEBP_USE_SSE2
diff --git a/contrib/libs/libwebp/dsp/yuv_sse41.c b/contrib/libs/libwebp/dsp/yuv_sse41.c
deleted file mode 100644
index 0140616b7e..0000000000
--- a/contrib/libs/libwebp/dsp/yuv_sse41.c
+++ /dev/null
@@ -1,613 +0,0 @@
-// Copyright 2014 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// YUV->RGB conversion functions
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include "./yuv.h"
-
-#if defined(WEBP_USE_SSE41)
-
-#include "./common_sse41.h"
-#include <stdlib.h>
-#include <smmintrin.h>
-
-//-----------------------------------------------------------------------------
-// Convert spans of 32 pixels to various RGB formats for the fancy upsampler.
-
-// These constants are 14b fixed-point version of ITU-R BT.601 constants.
-// R = (19077 * y + 26149 * v - 14234) >> 6
-// G = (19077 * y - 6419 * u - 13320 * v + 8708) >> 6
-// B = (19077 * y + 33050 * u - 17685) >> 6
-static void ConvertYUV444ToRGB_SSE41(const __m128i* const Y0,
- const __m128i* const U0,
- const __m128i* const V0,
- __m128i* const R,
- __m128i* const G,
- __m128i* const B) {
- const __m128i k19077 = _mm_set1_epi16(19077);
- const __m128i k26149 = _mm_set1_epi16(26149);
- const __m128i k14234 = _mm_set1_epi16(14234);
- // 33050 doesn't fit in a signed short: only use this with unsigned arithmetic
- const __m128i k33050 = _mm_set1_epi16((short)33050);
- const __m128i k17685 = _mm_set1_epi16(17685);
- const __m128i k6419 = _mm_set1_epi16(6419);
- const __m128i k13320 = _mm_set1_epi16(13320);
- const __m128i k8708 = _mm_set1_epi16(8708);
-
- const __m128i Y1 = _mm_mulhi_epu16(*Y0, k19077);
-
- const __m128i R0 = _mm_mulhi_epu16(*V0, k26149);
- const __m128i R1 = _mm_sub_epi16(Y1, k14234);
- const __m128i R2 = _mm_add_epi16(R1, R0);
-
- const __m128i G0 = _mm_mulhi_epu16(*U0, k6419);
- const __m128i G1 = _mm_mulhi_epu16(*V0, k13320);
- const __m128i G2 = _mm_add_epi16(Y1, k8708);
- const __m128i G3 = _mm_add_epi16(G0, G1);
- const __m128i G4 = _mm_sub_epi16(G2, G3);
-
- // be careful with the saturated *unsigned* arithmetic here!
- const __m128i B0 = _mm_mulhi_epu16(*U0, k33050);
- const __m128i B1 = _mm_adds_epu16(B0, Y1);
- const __m128i B2 = _mm_subs_epu16(B1, k17685);
-
- // use logical shift for B2, which can be larger than 32767
- *R = _mm_srai_epi16(R2, 6); // range: [-14234, 30815]
- *G = _mm_srai_epi16(G4, 6); // range: [-10953, 27710]
- *B = _mm_srli_epi16(B2, 6); // range: [0, 34238]
-}
-
-// Load the bytes into the *upper* part of 16b words. That's "<< 8", basically.
-static WEBP_INLINE __m128i Load_HI_16_SSE41(const uint8_t* src) {
- const __m128i zero = _mm_setzero_si128();
- return _mm_unpacklo_epi8(zero, _mm_loadl_epi64((const __m128i*)src));
-}
-
-// Load and replicate the U/V samples
-static WEBP_INLINE __m128i Load_UV_HI_8_SSE41(const uint8_t* src) {
- const __m128i zero = _mm_setzero_si128();
- const __m128i tmp0 = _mm_cvtsi32_si128(*(const uint32_t*)src);
- const __m128i tmp1 = _mm_unpacklo_epi8(zero, tmp0);
- return _mm_unpacklo_epi16(tmp1, tmp1); // replicate samples
-}
-
-// Convert 32 samples of YUV444 to R/G/B
-static void YUV444ToRGB_SSE41(const uint8_t* const y,
- const uint8_t* const u,
- const uint8_t* const v,
- __m128i* const R, __m128i* const G,
- __m128i* const B) {
- const __m128i Y0 = Load_HI_16_SSE41(y), U0 = Load_HI_16_SSE41(u),
- V0 = Load_HI_16_SSE41(v);
- ConvertYUV444ToRGB_SSE41(&Y0, &U0, &V0, R, G, B);
-}
-
-// Convert 32 samples of YUV420 to R/G/B
-static void YUV420ToRGB_SSE41(const uint8_t* const y,
- const uint8_t* const u,
- const uint8_t* const v,
- __m128i* const R, __m128i* const G,
- __m128i* const B) {
- const __m128i Y0 = Load_HI_16_SSE41(y), U0 = Load_UV_HI_8_SSE41(u),
- V0 = Load_UV_HI_8_SSE41(v);
- ConvertYUV444ToRGB_SSE41(&Y0, &U0, &V0, R, G, B);
-}
-
-// Pack the planar buffers
-// rrrr... rrrr... gggg... gggg... bbbb... bbbb....
-// triplet by triplet in the output buffer rgb as rgbrgbrgbrgb ...
-static WEBP_INLINE void PlanarTo24b_SSE41(
- __m128i* const in0, __m128i* const in1, __m128i* const in2,
- __m128i* const in3, __m128i* const in4, __m128i* const in5,
- uint8_t* const rgb) {
- // The input is 6 registers of sixteen 8b but for the sake of explanation,
- // let's take 6 registers of four 8b values.
- // To pack, we will keep taking one every two 8b integer and move it
- // around as follows:
- // Input:
- // r0r1r2r3 | r4r5r6r7 | g0g1g2g3 | g4g5g6g7 | b0b1b2b3 | b4b5b6b7
- // Split the 6 registers in two sets of 3 registers: the first set as the even
- // 8b bytes, the second the odd ones:
- // r0r2r4r6 | g0g2g4g6 | b0b2b4b6 | r1r3r5r7 | g1g3g5g7 | b1b3b5b7
- // Repeat the same permutations twice more:
- // r0r4g0g4 | b0b4r1r5 | g1g5b1b5 | r2r6g2g6 | b2b6r3r7 | g3g7b3b7
- // r0g0b0r1 | g1b1r2g2 | b2r3g3b3 | r4g4b4r5 | g5b5r6g6 | b6r7g7b7
- VP8PlanarTo24b_SSE41(in0, in1, in2, in3, in4, in5);
-
- _mm_storeu_si128((__m128i*)(rgb + 0), *in0);
- _mm_storeu_si128((__m128i*)(rgb + 16), *in1);
- _mm_storeu_si128((__m128i*)(rgb + 32), *in2);
- _mm_storeu_si128((__m128i*)(rgb + 48), *in3);
- _mm_storeu_si128((__m128i*)(rgb + 64), *in4);
- _mm_storeu_si128((__m128i*)(rgb + 80), *in5);
-}
-
-void VP8YuvToRgb32_SSE41(const uint8_t* y, const uint8_t* u, const uint8_t* v,
- uint8_t* dst) {
- __m128i R0, R1, R2, R3, G0, G1, G2, G3, B0, B1, B2, B3;
- __m128i rgb0, rgb1, rgb2, rgb3, rgb4, rgb5;
-
- YUV444ToRGB_SSE41(y + 0, u + 0, v + 0, &R0, &G0, &B0);
- YUV444ToRGB_SSE41(y + 8, u + 8, v + 8, &R1, &G1, &B1);
- YUV444ToRGB_SSE41(y + 16, u + 16, v + 16, &R2, &G2, &B2);
- YUV444ToRGB_SSE41(y + 24, u + 24, v + 24, &R3, &G3, &B3);
-
- // Cast to 8b and store as RRRRGGGGBBBB.
- rgb0 = _mm_packus_epi16(R0, R1);
- rgb1 = _mm_packus_epi16(R2, R3);
- rgb2 = _mm_packus_epi16(G0, G1);
- rgb3 = _mm_packus_epi16(G2, G3);
- rgb4 = _mm_packus_epi16(B0, B1);
- rgb5 = _mm_packus_epi16(B2, B3);
-
- // Pack as RGBRGBRGBRGB.
- PlanarTo24b_SSE41(&rgb0, &rgb1, &rgb2, &rgb3, &rgb4, &rgb5, dst);
-}
-
-void VP8YuvToBgr32_SSE41(const uint8_t* y, const uint8_t* u, const uint8_t* v,
- uint8_t* dst) {
- __m128i R0, R1, R2, R3, G0, G1, G2, G3, B0, B1, B2, B3;
- __m128i bgr0, bgr1, bgr2, bgr3, bgr4, bgr5;
-
- YUV444ToRGB_SSE41(y + 0, u + 0, v + 0, &R0, &G0, &B0);
- YUV444ToRGB_SSE41(y + 8, u + 8, v + 8, &R1, &G1, &B1);
- YUV444ToRGB_SSE41(y + 16, u + 16, v + 16, &R2, &G2, &B2);
- YUV444ToRGB_SSE41(y + 24, u + 24, v + 24, &R3, &G3, &B3);
-
- // Cast to 8b and store as BBBBGGGGRRRR.
- bgr0 = _mm_packus_epi16(B0, B1);
- bgr1 = _mm_packus_epi16(B2, B3);
- bgr2 = _mm_packus_epi16(G0, G1);
- bgr3 = _mm_packus_epi16(G2, G3);
- bgr4 = _mm_packus_epi16(R0, R1);
- bgr5= _mm_packus_epi16(R2, R3);
-
- // Pack as BGRBGRBGRBGR.
- PlanarTo24b_SSE41(&bgr0, &bgr1, &bgr2, &bgr3, &bgr4, &bgr5, dst);
-}
-
-//-----------------------------------------------------------------------------
-// Arbitrary-length row conversion functions
-
-static void YuvToRgbRow_SSE41(const uint8_t* y,
- const uint8_t* u, const uint8_t* v,
- uint8_t* dst, int len) {
- int n;
- for (n = 0; n + 32 <= len; n += 32, dst += 32 * 3) {
- __m128i R0, R1, R2, R3, G0, G1, G2, G3, B0, B1, B2, B3;
- __m128i rgb0, rgb1, rgb2, rgb3, rgb4, rgb5;
-
- YUV420ToRGB_SSE41(y + 0, u + 0, v + 0, &R0, &G0, &B0);
- YUV420ToRGB_SSE41(y + 8, u + 4, v + 4, &R1, &G1, &B1);
- YUV420ToRGB_SSE41(y + 16, u + 8, v + 8, &R2, &G2, &B2);
- YUV420ToRGB_SSE41(y + 24, u + 12, v + 12, &R3, &G3, &B3);
-
- // Cast to 8b and store as RRRRGGGGBBBB.
- rgb0 = _mm_packus_epi16(R0, R1);
- rgb1 = _mm_packus_epi16(R2, R3);
- rgb2 = _mm_packus_epi16(G0, G1);
- rgb3 = _mm_packus_epi16(G2, G3);
- rgb4 = _mm_packus_epi16(B0, B1);
- rgb5 = _mm_packus_epi16(B2, B3);
-
- // Pack as RGBRGBRGBRGB.
- PlanarTo24b_SSE41(&rgb0, &rgb1, &rgb2, &rgb3, &rgb4, &rgb5, dst);
-
- y += 32;
- u += 16;
- v += 16;
- }
- for (; n < len; ++n) { // Finish off
- VP8YuvToRgb(y[0], u[0], v[0], dst);
- dst += 3;
- y += 1;
- u += (n & 1);
- v += (n & 1);
- }
-}
-
-static void YuvToBgrRow_SSE41(const uint8_t* y,
- const uint8_t* u, const uint8_t* v,
- uint8_t* dst, int len) {
- int n;
- for (n = 0; n + 32 <= len; n += 32, dst += 32 * 3) {
- __m128i R0, R1, R2, R3, G0, G1, G2, G3, B0, B1, B2, B3;
- __m128i bgr0, bgr1, bgr2, bgr3, bgr4, bgr5;
-
- YUV420ToRGB_SSE41(y + 0, u + 0, v + 0, &R0, &G0, &B0);
- YUV420ToRGB_SSE41(y + 8, u + 4, v + 4, &R1, &G1, &B1);
- YUV420ToRGB_SSE41(y + 16, u + 8, v + 8, &R2, &G2, &B2);
- YUV420ToRGB_SSE41(y + 24, u + 12, v + 12, &R3, &G3, &B3);
-
- // Cast to 8b and store as BBBBGGGGRRRR.
- bgr0 = _mm_packus_epi16(B0, B1);
- bgr1 = _mm_packus_epi16(B2, B3);
- bgr2 = _mm_packus_epi16(G0, G1);
- bgr3 = _mm_packus_epi16(G2, G3);
- bgr4 = _mm_packus_epi16(R0, R1);
- bgr5 = _mm_packus_epi16(R2, R3);
-
- // Pack as BGRBGRBGRBGR.
- PlanarTo24b_SSE41(&bgr0, &bgr1, &bgr2, &bgr3, &bgr4, &bgr5, dst);
-
- y += 32;
- u += 16;
- v += 16;
- }
- for (; n < len; ++n) { // Finish off
- VP8YuvToBgr(y[0], u[0], v[0], dst);
- dst += 3;
- y += 1;
- u += (n & 1);
- v += (n & 1);
- }
-}
-
-//------------------------------------------------------------------------------
-// Entry point
-
-extern void WebPInitSamplersSSE41(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void WebPInitSamplersSSE41(void) {
- WebPSamplers[MODE_RGB] = YuvToRgbRow_SSE41;
- WebPSamplers[MODE_BGR] = YuvToBgrRow_SSE41;
-}
-
-//------------------------------------------------------------------------------
-// RGB24/32 -> YUV converters
-
-// Load eight 16b-words from *src.
-#define LOAD_16(src) _mm_loadu_si128((const __m128i*)(src))
-// Store either 16b-words into *dst
-#define STORE_16(V, dst) _mm_storeu_si128((__m128i*)(dst), (V))
-
-#define WEBP_SSE41_SHUFF(OUT) do { \
- const __m128i tmp0 = _mm_shuffle_epi8(A0, shuff0); \
- const __m128i tmp1 = _mm_shuffle_epi8(A1, shuff1); \
- const __m128i tmp2 = _mm_shuffle_epi8(A2, shuff2); \
- const __m128i tmp3 = _mm_shuffle_epi8(A3, shuff0); \
- const __m128i tmp4 = _mm_shuffle_epi8(A4, shuff1); \
- const __m128i tmp5 = _mm_shuffle_epi8(A5, shuff2); \
- \
- /* OR everything to get one channel */ \
- const __m128i tmp6 = _mm_or_si128(tmp0, tmp1); \
- const __m128i tmp7 = _mm_or_si128(tmp3, tmp4); \
- out[OUT + 0] = _mm_or_si128(tmp6, tmp2); \
- out[OUT + 1] = _mm_or_si128(tmp7, tmp5); \
-} while (0);
-
-// Unpack the 8b input rgbrgbrgbrgb ... as contiguous registers:
-// rrrr... rrrr... gggg... gggg... bbbb... bbbb....
-// Similar to PlanarTo24bHelper(), but in reverse order.
-static WEBP_INLINE void RGB24PackedToPlanar_SSE41(
- const uint8_t* const rgb, __m128i* const out /*out[6]*/) {
- const __m128i A0 = _mm_loadu_si128((const __m128i*)(rgb + 0));
- const __m128i A1 = _mm_loadu_si128((const __m128i*)(rgb + 16));
- const __m128i A2 = _mm_loadu_si128((const __m128i*)(rgb + 32));
- const __m128i A3 = _mm_loadu_si128((const __m128i*)(rgb + 48));
- const __m128i A4 = _mm_loadu_si128((const __m128i*)(rgb + 64));
- const __m128i A5 = _mm_loadu_si128((const __m128i*)(rgb + 80));
-
- // Compute RR.
- {
- const __m128i shuff0 = _mm_set_epi8(
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 15, 12, 9, 6, 3, 0);
- const __m128i shuff1 = _mm_set_epi8(
- -1, -1, -1, -1, -1, 14, 11, 8, 5, 2, -1, -1, -1, -1, -1, -1);
- const __m128i shuff2 = _mm_set_epi8(
- 13, 10, 7, 4, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
- WEBP_SSE41_SHUFF(0)
- }
- // Compute GG.
- {
- const __m128i shuff0 = _mm_set_epi8(
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 13, 10, 7, 4, 1);
- const __m128i shuff1 = _mm_set_epi8(
- -1, -1, -1, -1, -1, 15, 12, 9, 6, 3, 0, -1, -1, -1, -1, -1);
- const __m128i shuff2 = _mm_set_epi8(
- 14, 11, 8, 5, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
- WEBP_SSE41_SHUFF(2)
- }
- // Compute BB.
- {
- const __m128i shuff0 = _mm_set_epi8(
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 14, 11, 8, 5, 2);
- const __m128i shuff1 = _mm_set_epi8(
- -1, -1, -1, -1, -1, -1, 13, 10, 7, 4, 1, -1, -1, -1, -1, -1);
- const __m128i shuff2 = _mm_set_epi8(
- 15, 12, 9, 6, 3, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
- WEBP_SSE41_SHUFF(4)
- }
-}
-
-#undef WEBP_SSE41_SHUFF
-
-// Convert 8 packed ARGB to r[], g[], b[]
-static WEBP_INLINE void RGB32PackedToPlanar_SSE41(
- const uint32_t* const argb, __m128i* const rgb /*in[6]*/) {
- const __m128i zero = _mm_setzero_si128();
- __m128i a0 = LOAD_16(argb + 0);
- __m128i a1 = LOAD_16(argb + 4);
- __m128i a2 = LOAD_16(argb + 8);
- __m128i a3 = LOAD_16(argb + 12);
- VP8L32bToPlanar_SSE41(&a0, &a1, &a2, &a3);
- rgb[0] = _mm_unpacklo_epi8(a1, zero);
- rgb[1] = _mm_unpackhi_epi8(a1, zero);
- rgb[2] = _mm_unpacklo_epi8(a2, zero);
- rgb[3] = _mm_unpackhi_epi8(a2, zero);
- rgb[4] = _mm_unpacklo_epi8(a3, zero);
- rgb[5] = _mm_unpackhi_epi8(a3, zero);
-}
-
-// This macro computes (RG * MULT_RG + GB * MULT_GB + ROUNDER) >> DESCALE_FIX
-// It's a macro and not a function because we need to use immediate values with
-// srai_epi32, e.g.
-#define TRANSFORM(RG_LO, RG_HI, GB_LO, GB_HI, MULT_RG, MULT_GB, \
- ROUNDER, DESCALE_FIX, OUT) do { \
- const __m128i V0_lo = _mm_madd_epi16(RG_LO, MULT_RG); \
- const __m128i V0_hi = _mm_madd_epi16(RG_HI, MULT_RG); \
- const __m128i V1_lo = _mm_madd_epi16(GB_LO, MULT_GB); \
- const __m128i V1_hi = _mm_madd_epi16(GB_HI, MULT_GB); \
- const __m128i V2_lo = _mm_add_epi32(V0_lo, V1_lo); \
- const __m128i V2_hi = _mm_add_epi32(V0_hi, V1_hi); \
- const __m128i V3_lo = _mm_add_epi32(V2_lo, ROUNDER); \
- const __m128i V3_hi = _mm_add_epi32(V2_hi, ROUNDER); \
- const __m128i V5_lo = _mm_srai_epi32(V3_lo, DESCALE_FIX); \
- const __m128i V5_hi = _mm_srai_epi32(V3_hi, DESCALE_FIX); \
- (OUT) = _mm_packs_epi32(V5_lo, V5_hi); \
-} while (0)
-
-#define MK_CST_16(A, B) _mm_set_epi16((B), (A), (B), (A), (B), (A), (B), (A))
-static WEBP_INLINE void ConvertRGBToY_SSE41(const __m128i* const R,
- const __m128i* const G,
- const __m128i* const B,
- __m128i* const Y) {
- const __m128i kRG_y = MK_CST_16(16839, 33059 - 16384);
- const __m128i kGB_y = MK_CST_16(16384, 6420);
- const __m128i kHALF_Y = _mm_set1_epi32((16 << YUV_FIX) + YUV_HALF);
-
- const __m128i RG_lo = _mm_unpacklo_epi16(*R, *G);
- const __m128i RG_hi = _mm_unpackhi_epi16(*R, *G);
- const __m128i GB_lo = _mm_unpacklo_epi16(*G, *B);
- const __m128i GB_hi = _mm_unpackhi_epi16(*G, *B);
- TRANSFORM(RG_lo, RG_hi, GB_lo, GB_hi, kRG_y, kGB_y, kHALF_Y, YUV_FIX, *Y);
-}
-
-static WEBP_INLINE void ConvertRGBToUV_SSE41(const __m128i* const R,
- const __m128i* const G,
- const __m128i* const B,
- __m128i* const U,
- __m128i* const V) {
- const __m128i kRG_u = MK_CST_16(-9719, -19081);
- const __m128i kGB_u = MK_CST_16(0, 28800);
- const __m128i kRG_v = MK_CST_16(28800, 0);
- const __m128i kGB_v = MK_CST_16(-24116, -4684);
- const __m128i kHALF_UV = _mm_set1_epi32(((128 << YUV_FIX) + YUV_HALF) << 2);
-
- const __m128i RG_lo = _mm_unpacklo_epi16(*R, *G);
- const __m128i RG_hi = _mm_unpackhi_epi16(*R, *G);
- const __m128i GB_lo = _mm_unpacklo_epi16(*G, *B);
- const __m128i GB_hi = _mm_unpackhi_epi16(*G, *B);
- TRANSFORM(RG_lo, RG_hi, GB_lo, GB_hi, kRG_u, kGB_u,
- kHALF_UV, YUV_FIX + 2, *U);
- TRANSFORM(RG_lo, RG_hi, GB_lo, GB_hi, kRG_v, kGB_v,
- kHALF_UV, YUV_FIX + 2, *V);
-}
-
-#undef MK_CST_16
-#undef TRANSFORM
-
-static void ConvertRGB24ToY_SSE41(const uint8_t* rgb, uint8_t* y, int width) {
- const int max_width = width & ~31;
- int i;
- for (i = 0; i < max_width; rgb += 3 * 16 * 2) {
- __m128i rgb_plane[6];
- int j;
-
- RGB24PackedToPlanar_SSE41(rgb, rgb_plane);
-
- for (j = 0; j < 2; ++j, i += 16) {
- const __m128i zero = _mm_setzero_si128();
- __m128i r, g, b, Y0, Y1;
-
- // Convert to 16-bit Y.
- r = _mm_unpacklo_epi8(rgb_plane[0 + j], zero);
- g = _mm_unpacklo_epi8(rgb_plane[2 + j], zero);
- b = _mm_unpacklo_epi8(rgb_plane[4 + j], zero);
- ConvertRGBToY_SSE41(&r, &g, &b, &Y0);
-
- // Convert to 16-bit Y.
- r = _mm_unpackhi_epi8(rgb_plane[0 + j], zero);
- g = _mm_unpackhi_epi8(rgb_plane[2 + j], zero);
- b = _mm_unpackhi_epi8(rgb_plane[4 + j], zero);
- ConvertRGBToY_SSE41(&r, &g, &b, &Y1);
-
- // Cast to 8-bit and store.
- STORE_16(_mm_packus_epi16(Y0, Y1), y + i);
- }
- }
- for (; i < width; ++i, rgb += 3) { // left-over
- y[i] = VP8RGBToY(rgb[0], rgb[1], rgb[2], YUV_HALF);
- }
-}
-
-static void ConvertBGR24ToY_SSE41(const uint8_t* bgr, uint8_t* y, int width) {
- const int max_width = width & ~31;
- int i;
- for (i = 0; i < max_width; bgr += 3 * 16 * 2) {
- __m128i bgr_plane[6];
- int j;
-
- RGB24PackedToPlanar_SSE41(bgr, bgr_plane);
-
- for (j = 0; j < 2; ++j, i += 16) {
- const __m128i zero = _mm_setzero_si128();
- __m128i r, g, b, Y0, Y1;
-
- // Convert to 16-bit Y.
- b = _mm_unpacklo_epi8(bgr_plane[0 + j], zero);
- g = _mm_unpacklo_epi8(bgr_plane[2 + j], zero);
- r = _mm_unpacklo_epi8(bgr_plane[4 + j], zero);
- ConvertRGBToY_SSE41(&r, &g, &b, &Y0);
-
- // Convert to 16-bit Y.
- b = _mm_unpackhi_epi8(bgr_plane[0 + j], zero);
- g = _mm_unpackhi_epi8(bgr_plane[2 + j], zero);
- r = _mm_unpackhi_epi8(bgr_plane[4 + j], zero);
- ConvertRGBToY_SSE41(&r, &g, &b, &Y1);
-
- // Cast to 8-bit and store.
- STORE_16(_mm_packus_epi16(Y0, Y1), y + i);
- }
- }
- for (; i < width; ++i, bgr += 3) { // left-over
- y[i] = VP8RGBToY(bgr[2], bgr[1], bgr[0], YUV_HALF);
- }
-}
-
-static void ConvertARGBToY_SSE41(const uint32_t* argb, uint8_t* y, int width) {
- const int max_width = width & ~15;
- int i;
- for (i = 0; i < max_width; i += 16) {
- __m128i Y0, Y1, rgb[6];
- RGB32PackedToPlanar_SSE41(&argb[i], rgb);
- ConvertRGBToY_SSE41(&rgb[0], &rgb[2], &rgb[4], &Y0);
- ConvertRGBToY_SSE41(&rgb[1], &rgb[3], &rgb[5], &Y1);
- STORE_16(_mm_packus_epi16(Y0, Y1), y + i);
- }
- for (; i < width; ++i) { // left-over
- const uint32_t p = argb[i];
- y[i] = VP8RGBToY((p >> 16) & 0xff, (p >> 8) & 0xff, (p >> 0) & 0xff,
- YUV_HALF);
- }
-}
-
-// Horizontal add (doubled) of two 16b values, result is 16b.
-// in: A | B | C | D | ... -> out: 2*(A+B) | 2*(C+D) | ...
-static void HorizontalAddPack_SSE41(const __m128i* const A,
- const __m128i* const B,
- __m128i* const out) {
- const __m128i k2 = _mm_set1_epi16(2);
- const __m128i C = _mm_madd_epi16(*A, k2);
- const __m128i D = _mm_madd_epi16(*B, k2);
- *out = _mm_packs_epi32(C, D);
-}
-
-static void ConvertARGBToUV_SSE41(const uint32_t* argb,
- uint8_t* u, uint8_t* v,
- int src_width, int do_store) {
- const int max_width = src_width & ~31;
- int i;
- for (i = 0; i < max_width; i += 32, u += 16, v += 16) {
- __m128i rgb[6], U0, V0, U1, V1;
- RGB32PackedToPlanar_SSE41(&argb[i], rgb);
- HorizontalAddPack_SSE41(&rgb[0], &rgb[1], &rgb[0]);
- HorizontalAddPack_SSE41(&rgb[2], &rgb[3], &rgb[2]);
- HorizontalAddPack_SSE41(&rgb[4], &rgb[5], &rgb[4]);
- ConvertRGBToUV_SSE41(&rgb[0], &rgb[2], &rgb[4], &U0, &V0);
-
- RGB32PackedToPlanar_SSE41(&argb[i + 16], rgb);
- HorizontalAddPack_SSE41(&rgb[0], &rgb[1], &rgb[0]);
- HorizontalAddPack_SSE41(&rgb[2], &rgb[3], &rgb[2]);
- HorizontalAddPack_SSE41(&rgb[4], &rgb[5], &rgb[4]);
- ConvertRGBToUV_SSE41(&rgb[0], &rgb[2], &rgb[4], &U1, &V1);
-
- U0 = _mm_packus_epi16(U0, U1);
- V0 = _mm_packus_epi16(V0, V1);
- if (!do_store) {
- const __m128i prev_u = LOAD_16(u);
- const __m128i prev_v = LOAD_16(v);
- U0 = _mm_avg_epu8(U0, prev_u);
- V0 = _mm_avg_epu8(V0, prev_v);
- }
- STORE_16(U0, u);
- STORE_16(V0, v);
- }
- if (i < src_width) { // left-over
- WebPConvertARGBToUV_C(argb + i, u, v, src_width - i, do_store);
- }
-}
-
-// Convert 16 packed ARGB 16b-values to r[], g[], b[]
-static WEBP_INLINE void RGBA32PackedToPlanar_16b_SSE41(
- const uint16_t* const rgbx,
- __m128i* const r, __m128i* const g, __m128i* const b) {
- const __m128i in0 = LOAD_16(rgbx + 0); // r0 | g0 | b0 |x| r1 | g1 | b1 |x
- const __m128i in1 = LOAD_16(rgbx + 8); // r2 | g2 | b2 |x| r3 | g3 | b3 |x
- const __m128i in2 = LOAD_16(rgbx + 16); // r4 | ...
- const __m128i in3 = LOAD_16(rgbx + 24); // r6 | ...
- // aarrggbb as 16-bit.
- const __m128i shuff0 =
- _mm_set_epi8(-1, -1, -1, -1, 13, 12, 5, 4, 11, 10, 3, 2, 9, 8, 1, 0);
- const __m128i shuff1 =
- _mm_set_epi8(13, 12, 5, 4, -1, -1, -1, -1, 11, 10, 3, 2, 9, 8, 1, 0);
- const __m128i A0 = _mm_shuffle_epi8(in0, shuff0);
- const __m128i A1 = _mm_shuffle_epi8(in1, shuff1);
- const __m128i A2 = _mm_shuffle_epi8(in2, shuff0);
- const __m128i A3 = _mm_shuffle_epi8(in3, shuff1);
- // R0R1G0G1
- // B0B1****
- // R2R3G2G3
- // B2B3****
- // (OR is used to free port 5 for the unpack)
- const __m128i B0 = _mm_unpacklo_epi32(A0, A1);
- const __m128i B1 = _mm_or_si128(A0, A1);
- const __m128i B2 = _mm_unpacklo_epi32(A2, A3);
- const __m128i B3 = _mm_or_si128(A2, A3);
- // Gather the channels.
- *r = _mm_unpacklo_epi64(B0, B2);
- *g = _mm_unpackhi_epi64(B0, B2);
- *b = _mm_unpackhi_epi64(B1, B3);
-}
-
-static void ConvertRGBA32ToUV_SSE41(const uint16_t* rgb,
- uint8_t* u, uint8_t* v, int width) {
- const int max_width = width & ~15;
- const uint16_t* const last_rgb = rgb + 4 * max_width;
- while (rgb < last_rgb) {
- __m128i r, g, b, U0, V0, U1, V1;
- RGBA32PackedToPlanar_16b_SSE41(rgb + 0, &r, &g, &b);
- ConvertRGBToUV_SSE41(&r, &g, &b, &U0, &V0);
- RGBA32PackedToPlanar_16b_SSE41(rgb + 32, &r, &g, &b);
- ConvertRGBToUV_SSE41(&r, &g, &b, &U1, &V1);
- STORE_16(_mm_packus_epi16(U0, U1), u);
- STORE_16(_mm_packus_epi16(V0, V1), v);
- u += 16;
- v += 16;
- rgb += 2 * 32;
- }
- if (max_width < width) { // left-over
- WebPConvertRGBA32ToUV_C(rgb, u, v, width - max_width);
- }
-}
-
-//------------------------------------------------------------------------------
-
-extern void WebPInitConvertARGBToYUVSSE41(void);
-
-WEBP_TSAN_IGNORE_FUNCTION void WebPInitConvertARGBToYUVSSE41(void) {
- WebPConvertARGBToY = ConvertARGBToY_SSE41;
- WebPConvertARGBToUV = ConvertARGBToUV_SSE41;
-
- WebPConvertRGB24ToY = ConvertRGB24ToY_SSE41;
- WebPConvertBGR24ToY = ConvertBGR24ToY_SSE41;
-
- WebPConvertRGBA32ToUV = ConvertRGBA32ToUV_SSE41;
-}
-
-//------------------------------------------------------------------------------
-
-#else // !WEBP_USE_SSE41
-
-WEBP_DSP_INIT_STUB(WebPInitSamplersSSE41)
-WEBP_DSP_INIT_STUB(WebPInitConvertARGBToYUVSSE41)
-
-#endif // WEBP_USE_SSE41
diff --git a/contrib/libs/libwebp/enc/.yandex_meta/licenses.list.txt b/contrib/libs/libwebp/enc/.yandex_meta/licenses.list.txt
deleted file mode 100644
index 31fa7ac72e..0000000000
--- a/contrib/libs/libwebp/enc/.yandex_meta/licenses.list.txt
+++ /dev/null
@@ -1,140 +0,0 @@
-====================BSD-3-Clause WITH Google-Patent-License-Webm====================
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-
-
-====================COPYRIGHT====================
-// Copyright 2011 Google Inc. All Rights Reserved.
-
-
-====================COPYRIGHT====================
-// Copyright 2012 Google Inc. All Rights Reserved.
-
-
-====================COPYRIGHT====================
-// Copyright 2014 Google Inc. All Rights Reserved.
-
-
-====================COPYRIGHT====================
-// Copyright 2016 Google Inc. All Rights Reserved.
-
-
-====================COPYRIGHT====================
-// Copyright 2017 Google Inc. All Rights Reserved.
-
-
-====================File: AUTHORS====================
-Contributors:
-- Aidan O'Loan (aidanol at gmail dot com)
-- Alan Browning (browning at google dot com)
-- Charles Munger (clm at google dot com)
-- Cheng Yi (cyi at google dot com)
-- Christian Duvivier (cduvivier at google dot com)
-- Christopher Degawa (ccom at randomderp dot com)
-- Clement Courbet (courbet at google dot com)
-- Djordje Pesut (djordje dot pesut at imgtec dot com)
-- Hui Su (huisu at google dot com)
-- Ilya Kurdyukov (jpegqs at gmail dot com)
-- Ingvar Stepanyan (rreverser at google dot com)
-- James Zern (jzern at google dot com)
-- Jan Engelhardt (jengelh at medozas dot de)
-- Jehan (jehan at girinstud dot io)
-- Johann Koenig (johann dot koenig at duck dot com)
-- Jovan Zelincevic (jovan dot zelincevic at imgtec dot com)
-- Jyrki Alakuijala (jyrki at google dot com)
-- Konstantin Ivlev (tomskside at gmail dot com)
-- Lode Vandevenne (lode at google dot com)
-- Lou Quillio (louquillio at google dot com)
-- Mans Rullgard (mans at mansr dot com)
-- Marcin Kowalczyk (qrczak at google dot com)
-- Martin Olsson (mnemo at minimum dot se)
-- Mikołaj Zalewski (mikolajz at google dot com)
-- Mislav Bradac (mislavm at google dot com)
-- Nico Weber (thakis at chromium dot org)
-- Noel Chromium (noel at chromium dot org)
-- Oliver Wolff (oliver dot wolff at qt dot io)
-- Owen Rodley (orodley at google dot com)
-- Parag Salasakar (img dot mips1 at gmail dot com)
-- Pascal Massimino (pascal dot massimino at gmail dot com)
-- Paweł Hajdan, Jr (phajdan dot jr at chromium dot org)
-- Pierre Joye (pierre dot php at gmail dot com)
-- Roberto Alanis (alanisbaez at google dot com)
-- Sam Clegg (sbc at chromium dot org)
-- Scott Hancher (seh at google dot com)
-- Scott LaVarnway (slavarnway at google dot com)
-- Scott Talbot (s at chikachow dot org)
-- Slobodan Prijic (slobodan dot prijic at imgtec dot com)
-- Somnath Banerjee (somnath dot banerjee at gmail dot com)
-- Sriraman Tallam (tmsriram at google dot com)
-- Tamar Levy (tamar dot levy at intel dot com)
-- Timothy Gu (timothygu99 at gmail dot com)
-- Urvang Joshi (urvang at google dot com)
-- Vikas Arora (vikasa at google dot com)
-- Vincent Rabaud (vrabaud at google dot com)
-- Vlad Tsyrklevich (vtsyrklevich at chromium dot org)
-- Wan-Teh Chang (wtc at google dot com)
-- Yang Zhang (yang dot zhang at arm dot com)
-- Yannis Guyon (yguyon at google dot com)
-- Zhi An Ng (zhin at chromium dot org)
-
-
-====================File: COPYING====================
-Copyright (c) 2010, Google Inc. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
-
- * Neither the name of Google nor the names of its contributors may
- be used to endorse or promote products derived from this software
- without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-
-====================File: PATENTS====================
-Additional IP Rights Grant (Patents)
-------------------------------------
-
-"These implementations" means the copyrightable works that implement the WebM
-codecs distributed by Google as part of the WebM Project.
-
-Google hereby grants to you a perpetual, worldwide, non-exclusive, no-charge,
-royalty-free, irrevocable (except as stated in this section) patent license to
-make, have made, use, offer to sell, sell, import, transfer, and otherwise
-run, modify and propagate the contents of these implementations of WebM, where
-such license applies only to those patent claims, both currently owned by
-Google and acquired in the future, licensable by Google that are necessarily
-infringed by these implementations of WebM. This grant does not include claims
-that would be infringed only as a consequence of further modification of these
-implementations. If you or your agent or exclusive licensee institute or order
-or agree to the institution of patent litigation or any other patent
-enforcement activity against any entity (including a cross-claim or
-counterclaim in a lawsuit) alleging that any of these implementations of WebM
-or any code incorporated within any of these implementations of WebM
-constitute direct or contributory patent infringement, or inducement of
-patent infringement, then any patent rights granted to you under this License
-for these implementations of WebM shall terminate as of the date such
-litigation is filed.
diff --git a/contrib/libs/libwebp/enc/alpha_enc.c b/contrib/libs/libwebp/enc/alpha_enc.c
deleted file mode 100644
index 408719956a..0000000000
--- a/contrib/libs/libwebp/enc/alpha_enc.c
+++ /dev/null
@@ -1,443 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Alpha-plane compression.
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include <assert.h>
-#include <stdlib.h>
-
-#include "./vp8i_enc.h"
-#include "../dsp/dsp.h"
-#include "../utils/filters_utils.h"
-#include "../utils/quant_levels_utils.h"
-#include "../utils/utils.h"
-#include "../webp/format_constants.h"
-
-// -----------------------------------------------------------------------------
-// Encodes the given alpha data via specified compression method 'method'.
-// The pre-processing (quantization) is performed if 'quality' is less than 100.
-// For such cases, the encoding is lossy. The valid range is [0, 100] for
-// 'quality' and [0, 1] for 'method':
-// 'method = 0' - No compression;
-// 'method = 1' - Use lossless coder on the alpha plane only
-// 'filter' values [0, 4] correspond to prediction modes none, horizontal,
-// vertical & gradient filters. The prediction mode 4 will try all the
-// prediction modes 0 to 3 and pick the best one.
-// 'effort_level': specifies how much effort must be spent to try and reduce
-// the compressed output size. In range 0 (quick) to 6 (slow).
-//
-// 'output' corresponds to the buffer containing compressed alpha data.
-// This buffer is allocated by this method and caller should call
-// WebPSafeFree(*output) when done.
-// 'output_size' corresponds to size of this compressed alpha buffer.
-//
-// Returns 1 on successfully encoding the alpha and
-// 0 if either:
-// invalid quality or method, or
-// memory allocation for the compressed data fails.
-
-#include "./vp8li_enc.h"
-
-static int EncodeLossless(const uint8_t* const data, int width, int height,
- int effort_level, // in [0..6] range
- int use_quality_100, VP8LBitWriter* const bw,
- WebPAuxStats* const stats) {
- int ok = 0;
- WebPConfig config;
- WebPPicture picture;
-
- WebPPictureInit(&picture);
- picture.width = width;
- picture.height = height;
- picture.use_argb = 1;
- picture.stats = stats;
- if (!WebPPictureAlloc(&picture)) return 0;
-
- // Transfer the alpha values to the green channel.
- WebPDispatchAlphaToGreen(data, width, picture.width, picture.height,
- picture.argb, picture.argb_stride);
-
- WebPConfigInit(&config);
- config.lossless = 1;
- // Enable exact, or it would alter RGB values of transparent alpha, which is
- // normally OK but not here since we are not encoding the input image but an
- // internal encoding-related image containing necessary exact information in
- // RGB channels.
- config.exact = 1;
- config.method = effort_level; // impact is very small
- // Set a low default quality for encoding alpha. Ensure that Alpha quality at
- // lower methods (3 and below) is less than the threshold for triggering
- // costly 'BackwardReferencesTraceBackwards'.
- // If the alpha quality is set to 100 and the method to 6, allow for a high
- // lossless quality to trigger the cruncher.
- config.quality =
- (use_quality_100 && effort_level == 6) ? 100 : 8.f * effort_level;
- assert(config.quality >= 0 && config.quality <= 100.f);
-
- // TODO(urvang): Temporary fix to avoid generating images that trigger
- // a decoder bug related to alpha with color cache.
- // See: https://code.google.com/p/webp/issues/detail?id=239
- // Need to re-enable this later.
- ok = (VP8LEncodeStream(&config, &picture, bw, 0 /*use_cache*/) == VP8_ENC_OK);
- WebPPictureFree(&picture);
- ok = ok && !bw->error_;
- if (!ok) {
- VP8LBitWriterWipeOut(bw);
- return 0;
- }
- return 1;
-}
-
-// -----------------------------------------------------------------------------
-
-// Small struct to hold the result of a filter mode compression attempt.
-typedef struct {
- size_t score;
- VP8BitWriter bw;
- WebPAuxStats stats;
-} FilterTrial;
-
-// This function always returns an initialized 'bw' object, even upon error.
-static int EncodeAlphaInternal(const uint8_t* const data, int width, int height,
- int method, int filter, int reduce_levels,
- int effort_level, // in [0..6] range
- uint8_t* const tmp_alpha,
- FilterTrial* result) {
- int ok = 0;
- const uint8_t* alpha_src;
- WebPFilterFunc filter_func;
- uint8_t header;
- const size_t data_size = width * height;
- const uint8_t* output = NULL;
- size_t output_size = 0;
- VP8LBitWriter tmp_bw;
-
- assert((uint64_t)data_size == (uint64_t)width * height); // as per spec
- assert(filter >= 0 && filter < WEBP_FILTER_LAST);
- assert(method >= ALPHA_NO_COMPRESSION);
- assert(method <= ALPHA_LOSSLESS_COMPRESSION);
- assert(sizeof(header) == ALPHA_HEADER_LEN);
-
- filter_func = WebPFilters[filter];
- if (filter_func != NULL) {
- filter_func(data, width, height, width, tmp_alpha);
- alpha_src = tmp_alpha;
- } else {
- alpha_src = data;
- }
-
- if (method != ALPHA_NO_COMPRESSION) {
- ok = VP8LBitWriterInit(&tmp_bw, data_size >> 3);
- ok = ok && EncodeLossless(alpha_src, width, height, effort_level,
- !reduce_levels, &tmp_bw, &result->stats);
- if (ok) {
- output = VP8LBitWriterFinish(&tmp_bw);
- output_size = VP8LBitWriterNumBytes(&tmp_bw);
- if (output_size > data_size) {
- // compressed size is larger than source! Revert to uncompressed mode.
- method = ALPHA_NO_COMPRESSION;
- VP8LBitWriterWipeOut(&tmp_bw);
- }
- } else {
- VP8LBitWriterWipeOut(&tmp_bw);
- return 0;
- }
- }
-
- if (method == ALPHA_NO_COMPRESSION) {
- output = alpha_src;
- output_size = data_size;
- ok = 1;
- }
-
- // Emit final result.
- header = method | (filter << 2);
- if (reduce_levels) header |= ALPHA_PREPROCESSED_LEVELS << 4;
-
- VP8BitWriterInit(&result->bw, ALPHA_HEADER_LEN + output_size);
- ok = ok && VP8BitWriterAppend(&result->bw, &header, ALPHA_HEADER_LEN);
- ok = ok && VP8BitWriterAppend(&result->bw, output, output_size);
-
- if (method != ALPHA_NO_COMPRESSION) {
- VP8LBitWriterWipeOut(&tmp_bw);
- }
- ok = ok && !result->bw.error_;
- result->score = VP8BitWriterSize(&result->bw);
- return ok;
-}
-
-// -----------------------------------------------------------------------------
-
-static int GetNumColors(const uint8_t* data, int width, int height,
- int stride) {
- int j;
- int colors = 0;
- uint8_t color[256] = { 0 };
-
- for (j = 0; j < height; ++j) {
- int i;
- const uint8_t* const p = data + j * stride;
- for (i = 0; i < width; ++i) {
- color[p[i]] = 1;
- }
- }
- for (j = 0; j < 256; ++j) {
- if (color[j] > 0) ++colors;
- }
- return colors;
-}
-
-#define FILTER_TRY_NONE (1 << WEBP_FILTER_NONE)
-#define FILTER_TRY_ALL ((1 << WEBP_FILTER_LAST) - 1)
-
-// Given the input 'filter' option, return an OR'd bit-set of filters to try.
-static uint32_t GetFilterMap(const uint8_t* alpha, int width, int height,
- int filter, int effort_level) {
- uint32_t bit_map = 0U;
- if (filter == WEBP_FILTER_FAST) {
- // Quick estimate of the best candidate.
- int try_filter_none = (effort_level > 3);
- const int kMinColorsForFilterNone = 16;
- const int kMaxColorsForFilterNone = 192;
- const int num_colors = GetNumColors(alpha, width, height, width);
- // For low number of colors, NONE yields better compression.
- filter = (num_colors <= kMinColorsForFilterNone)
- ? WEBP_FILTER_NONE
- : WebPEstimateBestFilter(alpha, width, height, width);
- bit_map |= 1 << filter;
- // For large number of colors, try FILTER_NONE in addition to the best
- // filter as well.
- if (try_filter_none || num_colors > kMaxColorsForFilterNone) {
- bit_map |= FILTER_TRY_NONE;
- }
- } else if (filter == WEBP_FILTER_NONE) {
- bit_map = FILTER_TRY_NONE;
- } else { // WEBP_FILTER_BEST -> try all
- bit_map = FILTER_TRY_ALL;
- }
- return bit_map;
-}
-
-static void InitFilterTrial(FilterTrial* const score) {
- score->score = (size_t)~0U;
- VP8BitWriterInit(&score->bw, 0);
-}
-
-static int ApplyFiltersAndEncode(const uint8_t* alpha, int width, int height,
- size_t data_size, int method, int filter,
- int reduce_levels, int effort_level,
- uint8_t** const output,
- size_t* const output_size,
- WebPAuxStats* const stats) {
- int ok = 1;
- FilterTrial best;
- uint32_t try_map =
- GetFilterMap(alpha, width, height, filter, effort_level);
- InitFilterTrial(&best);
-
- if (try_map != FILTER_TRY_NONE) {
- uint8_t* filtered_alpha = (uint8_t*)WebPSafeMalloc(1ULL, data_size);
- if (filtered_alpha == NULL) return 0;
-
- for (filter = WEBP_FILTER_NONE; ok && try_map; ++filter, try_map >>= 1) {
- if (try_map & 1) {
- FilterTrial trial;
- ok = EncodeAlphaInternal(alpha, width, height, method, filter,
- reduce_levels, effort_level, filtered_alpha,
- &trial);
- if (ok && trial.score < best.score) {
- VP8BitWriterWipeOut(&best.bw);
- best = trial;
- } else {
- VP8BitWriterWipeOut(&trial.bw);
- }
- }
- }
- WebPSafeFree(filtered_alpha);
- } else {
- ok = EncodeAlphaInternal(alpha, width, height, method, WEBP_FILTER_NONE,
- reduce_levels, effort_level, NULL, &best);
- }
- if (ok) {
-#if !defined(WEBP_DISABLE_STATS)
- if (stats != NULL) {
- stats->lossless_features = best.stats.lossless_features;
- stats->histogram_bits = best.stats.histogram_bits;
- stats->transform_bits = best.stats.transform_bits;
- stats->cache_bits = best.stats.cache_bits;
- stats->palette_size = best.stats.palette_size;
- stats->lossless_size = best.stats.lossless_size;
- stats->lossless_hdr_size = best.stats.lossless_hdr_size;
- stats->lossless_data_size = best.stats.lossless_data_size;
- }
-#else
- (void)stats;
-#endif
- *output_size = VP8BitWriterSize(&best.bw);
- *output = VP8BitWriterBuf(&best.bw);
- } else {
- VP8BitWriterWipeOut(&best.bw);
- }
- return ok;
-}
-
-static int EncodeAlpha(VP8Encoder* const enc,
- int quality, int method, int filter,
- int effort_level,
- uint8_t** const output, size_t* const output_size) {
- const WebPPicture* const pic = enc->pic_;
- const int width = pic->width;
- const int height = pic->height;
-
- uint8_t* quant_alpha = NULL;
- const size_t data_size = width * height;
- uint64_t sse = 0;
- int ok = 1;
- const int reduce_levels = (quality < 100);
-
- // quick correctness checks
- assert((uint64_t)data_size == (uint64_t)width * height); // as per spec
- assert(enc != NULL && pic != NULL && pic->a != NULL);
- assert(output != NULL && output_size != NULL);
- assert(width > 0 && height > 0);
- assert(pic->a_stride >= width);
- assert(filter >= WEBP_FILTER_NONE && filter <= WEBP_FILTER_FAST);
-
- if (quality < 0 || quality > 100) {
- return 0;
- }
-
- if (method < ALPHA_NO_COMPRESSION || method > ALPHA_LOSSLESS_COMPRESSION) {
- return 0;
- }
-
- if (method == ALPHA_NO_COMPRESSION) {
- // Don't filter, as filtering will make no impact on compressed size.
- filter = WEBP_FILTER_NONE;
- }
-
- quant_alpha = (uint8_t*)WebPSafeMalloc(1ULL, data_size);
- if (quant_alpha == NULL) {
- return 0;
- }
-
- // Extract alpha data (width x height) from raw_data (stride x height).
- WebPCopyPlane(pic->a, pic->a_stride, quant_alpha, width, width, height);
-
- if (reduce_levels) { // No Quantization required for 'quality = 100'.
- // 16 alpha levels gives quite a low MSE w.r.t original alpha plane hence
- // mapped to moderate quality 70. Hence Quality:[0, 70] -> Levels:[2, 16]
- // and Quality:]70, 100] -> Levels:]16, 256].
- const int alpha_levels = (quality <= 70) ? (2 + quality / 5)
- : (16 + (quality - 70) * 8);
- ok = QuantizeLevels(quant_alpha, width, height, alpha_levels, &sse);
- }
-
- if (ok) {
- VP8FiltersInit();
- ok = ApplyFiltersAndEncode(quant_alpha, width, height, data_size, method,
- filter, reduce_levels, effort_level, output,
- output_size, pic->stats);
-#if !defined(WEBP_DISABLE_STATS)
- if (pic->stats != NULL) { // need stats?
- pic->stats->coded_size += (int)(*output_size);
- enc->sse_[3] = sse;
- }
-#endif
- }
-
- WebPSafeFree(quant_alpha);
- return ok;
-}
-
-//------------------------------------------------------------------------------
-// Main calls
-
-static int CompressAlphaJob(void* arg1, void* unused) {
- VP8Encoder* const enc = (VP8Encoder*)arg1;
- const WebPConfig* config = enc->config_;
- uint8_t* alpha_data = NULL;
- size_t alpha_size = 0;
- const int effort_level = config->method; // maps to [0..6]
- const WEBP_FILTER_TYPE filter =
- (config->alpha_filtering == 0) ? WEBP_FILTER_NONE :
- (config->alpha_filtering == 1) ? WEBP_FILTER_FAST :
- WEBP_FILTER_BEST;
- if (!EncodeAlpha(enc, config->alpha_quality, config->alpha_compression,
- filter, effort_level, &alpha_data, &alpha_size)) {
- return 0;
- }
- if (alpha_size != (uint32_t)alpha_size) { // Soundness check.
- WebPSafeFree(alpha_data);
- return 0;
- }
- enc->alpha_data_size_ = (uint32_t)alpha_size;
- enc->alpha_data_ = alpha_data;
- (void)unused;
- return 1;
-}
-
-void VP8EncInitAlpha(VP8Encoder* const enc) {
- WebPInitAlphaProcessing();
- enc->has_alpha_ = WebPPictureHasTransparency(enc->pic_);
- enc->alpha_data_ = NULL;
- enc->alpha_data_size_ = 0;
- if (enc->thread_level_ > 0) {
- WebPWorker* const worker = &enc->alpha_worker_;
- WebPGetWorkerInterface()->Init(worker);
- worker->data1 = enc;
- worker->data2 = NULL;
- worker->hook = CompressAlphaJob;
- }
-}
-
-int VP8EncStartAlpha(VP8Encoder* const enc) {
- if (enc->has_alpha_) {
- if (enc->thread_level_ > 0) {
- WebPWorker* const worker = &enc->alpha_worker_;
- // Makes sure worker is good to go.
- if (!WebPGetWorkerInterface()->Reset(worker)) {
- return 0;
- }
- WebPGetWorkerInterface()->Launch(worker);
- return 1;
- } else {
- return CompressAlphaJob(enc, NULL); // just do the job right away
- }
- }
- return 1;
-}
-
-int VP8EncFinishAlpha(VP8Encoder* const enc) {
- if (enc->has_alpha_) {
- if (enc->thread_level_ > 0) {
- WebPWorker* const worker = &enc->alpha_worker_;
- if (!WebPGetWorkerInterface()->Sync(worker)) return 0; // error
- }
- }
- return WebPReportProgress(enc->pic_, enc->percent_ + 20, &enc->percent_);
-}
-
-int VP8EncDeleteAlpha(VP8Encoder* const enc) {
- int ok = 1;
- if (enc->thread_level_ > 0) {
- WebPWorker* const worker = &enc->alpha_worker_;
- // finish anything left in flight
- ok = WebPGetWorkerInterface()->Sync(worker);
- // still need to end the worker, even if !ok
- WebPGetWorkerInterface()->End(worker);
- }
- WebPSafeFree(enc->alpha_data_);
- enc->alpha_data_ = NULL;
- enc->alpha_data_size_ = 0;
- enc->has_alpha_ = 0;
- return ok;
-}
diff --git a/contrib/libs/libwebp/enc/analysis_enc.c b/contrib/libs/libwebp/enc/analysis_enc.c
deleted file mode 100644
index d0814f7254..0000000000
--- a/contrib/libs/libwebp/enc/analysis_enc.c
+++ /dev/null
@@ -1,475 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Macroblock analysis
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-
-#include "./vp8i_enc.h"
-#include "./cost_enc.h"
-#include "../utils/utils.h"
-
-#define MAX_ITERS_K_MEANS 6
-
-//------------------------------------------------------------------------------
-// Smooth the segment map by replacing isolated block by the majority of its
-// neighbours.
-
-static void SmoothSegmentMap(VP8Encoder* const enc) {
- int n, x, y;
- const int w = enc->mb_w_;
- const int h = enc->mb_h_;
- const int majority_cnt_3_x_3_grid = 5;
- uint8_t* const tmp = (uint8_t*)WebPSafeMalloc(w * h, sizeof(*tmp));
- assert((uint64_t)(w * h) == (uint64_t)w * h); // no overflow, as per spec
-
- if (tmp == NULL) return;
- for (y = 1; y < h - 1; ++y) {
- for (x = 1; x < w - 1; ++x) {
- int cnt[NUM_MB_SEGMENTS] = { 0 };
- const VP8MBInfo* const mb = &enc->mb_info_[x + w * y];
- int majority_seg = mb->segment_;
- // Check the 8 neighbouring segment values.
- cnt[mb[-w - 1].segment_]++; // top-left
- cnt[mb[-w + 0].segment_]++; // top
- cnt[mb[-w + 1].segment_]++; // top-right
- cnt[mb[ - 1].segment_]++; // left
- cnt[mb[ + 1].segment_]++; // right
- cnt[mb[ w - 1].segment_]++; // bottom-left
- cnt[mb[ w + 0].segment_]++; // bottom
- cnt[mb[ w + 1].segment_]++; // bottom-right
- for (n = 0; n < NUM_MB_SEGMENTS; ++n) {
- if (cnt[n] >= majority_cnt_3_x_3_grid) {
- majority_seg = n;
- break;
- }
- }
- tmp[x + y * w] = majority_seg;
- }
- }
- for (y = 1; y < h - 1; ++y) {
- for (x = 1; x < w - 1; ++x) {
- VP8MBInfo* const mb = &enc->mb_info_[x + w * y];
- mb->segment_ = tmp[x + y * w];
- }
- }
- WebPSafeFree(tmp);
-}
-
-//------------------------------------------------------------------------------
-// set segment susceptibility alpha_ / beta_
-
-static WEBP_INLINE int clip(int v, int m, int M) {
- return (v < m) ? m : (v > M) ? M : v;
-}
-
-static void SetSegmentAlphas(VP8Encoder* const enc,
- const int centers[NUM_MB_SEGMENTS],
- int mid) {
- const int nb = enc->segment_hdr_.num_segments_;
- int min = centers[0], max = centers[0];
- int n;
-
- if (nb > 1) {
- for (n = 0; n < nb; ++n) {
- if (min > centers[n]) min = centers[n];
- if (max < centers[n]) max = centers[n];
- }
- }
- if (max == min) max = min + 1;
- assert(mid <= max && mid >= min);
- for (n = 0; n < nb; ++n) {
- const int alpha = 255 * (centers[n] - mid) / (max - min);
- const int beta = 255 * (centers[n] - min) / (max - min);
- enc->dqm_[n].alpha_ = clip(alpha, -127, 127);
- enc->dqm_[n].beta_ = clip(beta, 0, 255);
- }
-}
-
-//------------------------------------------------------------------------------
-// Compute susceptibility based on DCT-coeff histograms:
-// the higher, the "easier" the macroblock is to compress.
-
-#define MAX_ALPHA 255 // 8b of precision for susceptibilities.
-#define ALPHA_SCALE (2 * MAX_ALPHA) // scaling factor for alpha.
-#define DEFAULT_ALPHA (-1)
-#define IS_BETTER_ALPHA(alpha, best_alpha) ((alpha) > (best_alpha))
-
-static int FinalAlphaValue(int alpha) {
- alpha = MAX_ALPHA - alpha;
- return clip(alpha, 0, MAX_ALPHA);
-}
-
-static int GetAlpha(const VP8Histogram* const histo) {
- // 'alpha' will later be clipped to [0..MAX_ALPHA] range, clamping outer
- // values which happen to be mostly noise. This leaves the maximum precision
- // for handling the useful small values which contribute most.
- const int max_value = histo->max_value;
- const int last_non_zero = histo->last_non_zero;
- const int alpha =
- (max_value > 1) ? ALPHA_SCALE * last_non_zero / max_value : 0;
- return alpha;
-}
-
-static void InitHistogram(VP8Histogram* const histo) {
- histo->max_value = 0;
- histo->last_non_zero = 1;
-}
-
-//------------------------------------------------------------------------------
-// Simplified k-Means, to assign Nb segments based on alpha-histogram
-
-static void AssignSegments(VP8Encoder* const enc,
- const int alphas[MAX_ALPHA + 1]) {
- // 'num_segments_' is previously validated and <= NUM_MB_SEGMENTS, but an
- // explicit check is needed to avoid spurious warning about 'n + 1' exceeding
- // array bounds of 'centers' with some compilers (noticed with gcc-4.9).
- const int nb = (enc->segment_hdr_.num_segments_ < NUM_MB_SEGMENTS) ?
- enc->segment_hdr_.num_segments_ : NUM_MB_SEGMENTS;
- int centers[NUM_MB_SEGMENTS];
- int weighted_average = 0;
- int map[MAX_ALPHA + 1];
- int a, n, k;
- int min_a = 0, max_a = MAX_ALPHA, range_a;
- // 'int' type is ok for histo, and won't overflow
- int accum[NUM_MB_SEGMENTS], dist_accum[NUM_MB_SEGMENTS];
-
- assert(nb >= 1);
- assert(nb <= NUM_MB_SEGMENTS);
-
- // bracket the input
- for (n = 0; n <= MAX_ALPHA && alphas[n] == 0; ++n) {}
- min_a = n;
- for (n = MAX_ALPHA; n > min_a && alphas[n] == 0; --n) {}
- max_a = n;
- range_a = max_a - min_a;
-
- // Spread initial centers evenly
- for (k = 0, n = 1; k < nb; ++k, n += 2) {
- assert(n < 2 * nb);
- centers[k] = min_a + (n * range_a) / (2 * nb);
- }
-
- for (k = 0; k < MAX_ITERS_K_MEANS; ++k) { // few iters are enough
- int total_weight;
- int displaced;
- // Reset stats
- for (n = 0; n < nb; ++n) {
- accum[n] = 0;
- dist_accum[n] = 0;
- }
- // Assign nearest center for each 'a'
- n = 0; // track the nearest center for current 'a'
- for (a = min_a; a <= max_a; ++a) {
- if (alphas[a]) {
- while (n + 1 < nb && abs(a - centers[n + 1]) < abs(a - centers[n])) {
- n++;
- }
- map[a] = n;
- // accumulate contribution into best centroid
- dist_accum[n] += a * alphas[a];
- accum[n] += alphas[a];
- }
- }
- // All point are classified. Move the centroids to the
- // center of their respective cloud.
- displaced = 0;
- weighted_average = 0;
- total_weight = 0;
- for (n = 0; n < nb; ++n) {
- if (accum[n]) {
- const int new_center = (dist_accum[n] + accum[n] / 2) / accum[n];
- displaced += abs(centers[n] - new_center);
- centers[n] = new_center;
- weighted_average += new_center * accum[n];
- total_weight += accum[n];
- }
- }
- weighted_average = (weighted_average + total_weight / 2) / total_weight;
- if (displaced < 5) break; // no need to keep on looping...
- }
-
- // Map each original value to the closest centroid
- for (n = 0; n < enc->mb_w_ * enc->mb_h_; ++n) {
- VP8MBInfo* const mb = &enc->mb_info_[n];
- const int alpha = mb->alpha_;
- mb->segment_ = map[alpha];
- mb->alpha_ = centers[map[alpha]]; // for the record.
- }
-
- if (nb > 1) {
- const int smooth = (enc->config_->preprocessing & 1);
- if (smooth) SmoothSegmentMap(enc);
- }
-
- SetSegmentAlphas(enc, centers, weighted_average); // pick some alphas.
-}
-
-//------------------------------------------------------------------------------
-// Macroblock analysis: collect histogram for each mode, deduce the maximal
-// susceptibility and set best modes for this macroblock.
-// Segment assignment is done later.
-
-// Number of modes to inspect for alpha_ evaluation. We don't need to test all
-// the possible modes during the analysis phase: we risk falling into a local
-// optimum, or be subject to boundary effect
-#define MAX_INTRA16_MODE 2
-#define MAX_INTRA4_MODE 2
-#define MAX_UV_MODE 2
-
-static int MBAnalyzeBestIntra16Mode(VP8EncIterator* const it) {
- const int max_mode = MAX_INTRA16_MODE;
- int mode;
- int best_alpha = DEFAULT_ALPHA;
- int best_mode = 0;
-
- VP8MakeLuma16Preds(it);
- for (mode = 0; mode < max_mode; ++mode) {
- VP8Histogram histo;
- int alpha;
-
- InitHistogram(&histo);
- VP8CollectHistogram(it->yuv_in_ + Y_OFF_ENC,
- it->yuv_p_ + VP8I16ModeOffsets[mode],
- 0, 16, &histo);
- alpha = GetAlpha(&histo);
- if (IS_BETTER_ALPHA(alpha, best_alpha)) {
- best_alpha = alpha;
- best_mode = mode;
- }
- }
- VP8SetIntra16Mode(it, best_mode);
- return best_alpha;
-}
-
-static int FastMBAnalyze(VP8EncIterator* const it) {
- // Empirical cut-off value, should be around 16 (~=block size). We use the
- // [8-17] range and favor intra4 at high quality, intra16 for low quality.
- const int q = (int)it->enc_->config_->quality;
- const uint32_t kThreshold = 8 + (17 - 8) * q / 100;
- int k;
- uint32_t dc[16], m, m2;
- for (k = 0; k < 16; k += 4) {
- VP8Mean16x4(it->yuv_in_ + Y_OFF_ENC + k * BPS, &dc[k]);
- }
- for (m = 0, m2 = 0, k = 0; k < 16; ++k) {
- m += dc[k];
- m2 += dc[k] * dc[k];
- }
- if (kThreshold * m2 < m * m) {
- VP8SetIntra16Mode(it, 0); // DC16
- } else {
- const uint8_t modes[16] = { 0 }; // DC4
- VP8SetIntra4Mode(it, modes);
- }
- return 0;
-}
-
-static int MBAnalyzeBestUVMode(VP8EncIterator* const it) {
- int best_alpha = DEFAULT_ALPHA;
- int smallest_alpha = 0;
- int best_mode = 0;
- const int max_mode = MAX_UV_MODE;
- int mode;
-
- VP8MakeChroma8Preds(it);
- for (mode = 0; mode < max_mode; ++mode) {
- VP8Histogram histo;
- int alpha;
- InitHistogram(&histo);
- VP8CollectHistogram(it->yuv_in_ + U_OFF_ENC,
- it->yuv_p_ + VP8UVModeOffsets[mode],
- 16, 16 + 4 + 4, &histo);
- alpha = GetAlpha(&histo);
- if (IS_BETTER_ALPHA(alpha, best_alpha)) {
- best_alpha = alpha;
- }
- // The best prediction mode tends to be the one with the smallest alpha.
- if (mode == 0 || alpha < smallest_alpha) {
- smallest_alpha = alpha;
- best_mode = mode;
- }
- }
- VP8SetIntraUVMode(it, best_mode);
- return best_alpha;
-}
-
-static void MBAnalyze(VP8EncIterator* const it,
- int alphas[MAX_ALPHA + 1],
- int* const alpha, int* const uv_alpha) {
- const VP8Encoder* const enc = it->enc_;
- int best_alpha, best_uv_alpha;
-
- VP8SetIntra16Mode(it, 0); // default: Intra16, DC_PRED
- VP8SetSkip(it, 0); // not skipped
- VP8SetSegment(it, 0); // default segment, spec-wise.
-
- if (enc->method_ <= 1) {
- best_alpha = FastMBAnalyze(it);
- } else {
- best_alpha = MBAnalyzeBestIntra16Mode(it);
- }
- best_uv_alpha = MBAnalyzeBestUVMode(it);
-
- // Final susceptibility mix
- best_alpha = (3 * best_alpha + best_uv_alpha + 2) >> 2;
- best_alpha = FinalAlphaValue(best_alpha);
- alphas[best_alpha]++;
- it->mb_->alpha_ = best_alpha; // for later remapping.
-
- // Accumulate for later complexity analysis.
- *alpha += best_alpha; // mixed susceptibility (not just luma)
- *uv_alpha += best_uv_alpha;
-}
-
-static void DefaultMBInfo(VP8MBInfo* const mb) {
- mb->type_ = 1; // I16x16
- mb->uv_mode_ = 0;
- mb->skip_ = 0; // not skipped
- mb->segment_ = 0; // default segment
- mb->alpha_ = 0;
-}
-
-//------------------------------------------------------------------------------
-// Main analysis loop:
-// Collect all susceptibilities for each macroblock and record their
-// distribution in alphas[]. Segments is assigned a-posteriori, based on
-// this histogram.
-// We also pick an intra16 prediction mode, which shouldn't be considered
-// final except for fast-encode settings. We can also pick some intra4 modes
-// and decide intra4/intra16, but that's usually almost always a bad choice at
-// this stage.
-
-static void ResetAllMBInfo(VP8Encoder* const enc) {
- int n;
- for (n = 0; n < enc->mb_w_ * enc->mb_h_; ++n) {
- DefaultMBInfo(&enc->mb_info_[n]);
- }
- // Default susceptibilities.
- enc->dqm_[0].alpha_ = 0;
- enc->dqm_[0].beta_ = 0;
- // Note: we can't compute this alpha_ / uv_alpha_ -> set to default value.
- enc->alpha_ = 0;
- enc->uv_alpha_ = 0;
- WebPReportProgress(enc->pic_, enc->percent_ + 20, &enc->percent_);
-}
-
-// struct used to collect job result
-typedef struct {
- WebPWorker worker;
- int alphas[MAX_ALPHA + 1];
- int alpha, uv_alpha;
- VP8EncIterator it;
- int delta_progress;
-} SegmentJob;
-
-// main work call
-static int DoSegmentsJob(void* arg1, void* arg2) {
- SegmentJob* const job = (SegmentJob*)arg1;
- VP8EncIterator* const it = (VP8EncIterator*)arg2;
- int ok = 1;
- if (!VP8IteratorIsDone(it)) {
- uint8_t tmp[32 + WEBP_ALIGN_CST];
- uint8_t* const scratch = (uint8_t*)WEBP_ALIGN(tmp);
- do {
- // Let's pretend we have perfect lossless reconstruction.
- VP8IteratorImport(it, scratch);
- MBAnalyze(it, job->alphas, &job->alpha, &job->uv_alpha);
- ok = VP8IteratorProgress(it, job->delta_progress);
- } while (ok && VP8IteratorNext(it));
- }
- return ok;
-}
-
-static void MergeJobs(const SegmentJob* const src, SegmentJob* const dst) {
- int i;
- for (i = 0; i <= MAX_ALPHA; ++i) dst->alphas[i] += src->alphas[i];
- dst->alpha += src->alpha;
- dst->uv_alpha += src->uv_alpha;
-}
-
-// initialize the job struct with some tasks to perform
-static void InitSegmentJob(VP8Encoder* const enc, SegmentJob* const job,
- int start_row, int end_row) {
- WebPGetWorkerInterface()->Init(&job->worker);
- job->worker.data1 = job;
- job->worker.data2 = &job->it;
- job->worker.hook = DoSegmentsJob;
- VP8IteratorInit(enc, &job->it);
- VP8IteratorSetRow(&job->it, start_row);
- VP8IteratorSetCountDown(&job->it, (end_row - start_row) * enc->mb_w_);
- memset(job->alphas, 0, sizeof(job->alphas));
- job->alpha = 0;
- job->uv_alpha = 0;
- // only one of both jobs can record the progress, since we don't
- // expect the user's hook to be multi-thread safe
- job->delta_progress = (start_row == 0) ? 20 : 0;
-}
-
-// main entry point
-int VP8EncAnalyze(VP8Encoder* const enc) {
- int ok = 1;
- const int do_segments =
- enc->config_->emulate_jpeg_size || // We need the complexity evaluation.
- (enc->segment_hdr_.num_segments_ > 1) ||
- (enc->method_ <= 1); // for method 0 - 1, we need preds_[] to be filled.
- if (do_segments) {
- const int last_row = enc->mb_h_;
- // We give a little more than a half work to the main thread.
- const int split_row = (9 * last_row + 15) >> 4;
- const int total_mb = last_row * enc->mb_w_;
-#ifdef WEBP_USE_THREAD
- const int kMinSplitRow = 2; // minimal rows needed for mt to be worth it
- const int do_mt = (enc->thread_level_ > 0) && (split_row >= kMinSplitRow);
-#else
- const int do_mt = 0;
-#endif
- const WebPWorkerInterface* const worker_interface =
- WebPGetWorkerInterface();
- SegmentJob main_job;
- if (do_mt) {
- SegmentJob side_job;
- // Note the use of '&' instead of '&&' because we must call the functions
- // no matter what.
- InitSegmentJob(enc, &main_job, 0, split_row);
- InitSegmentJob(enc, &side_job, split_row, last_row);
- // we don't need to call Reset() on main_job.worker, since we're calling
- // WebPWorkerExecute() on it
- ok &= worker_interface->Reset(&side_job.worker);
- // launch the two jobs in parallel
- if (ok) {
- worker_interface->Launch(&side_job.worker);
- worker_interface->Execute(&main_job.worker);
- ok &= worker_interface->Sync(&side_job.worker);
- ok &= worker_interface->Sync(&main_job.worker);
- }
- worker_interface->End(&side_job.worker);
- if (ok) MergeJobs(&side_job, &main_job); // merge results together
- } else {
- // Even for single-thread case, we use the generic Worker tools.
- InitSegmentJob(enc, &main_job, 0, last_row);
- worker_interface->Execute(&main_job.worker);
- ok &= worker_interface->Sync(&main_job.worker);
- }
- worker_interface->End(&main_job.worker);
- if (ok) {
- enc->alpha_ = main_job.alpha / total_mb;
- enc->uv_alpha_ = main_job.uv_alpha / total_mb;
- AssignSegments(enc, main_job.alphas);
- }
- } else { // Use only one default segment.
- ResetAllMBInfo(enc);
- }
- return ok;
-}
-
diff --git a/contrib/libs/libwebp/enc/backward_references_cost_enc.c b/contrib/libs/libwebp/enc/backward_references_cost_enc.c
deleted file mode 100644
index 6daded7d86..0000000000
--- a/contrib/libs/libwebp/enc/backward_references_cost_enc.c
+++ /dev/null
@@ -1,790 +0,0 @@
-// Copyright 2017 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Improves a given set of backward references by analyzing its bit cost.
-// The algorithm is similar to the Zopfli compression algorithm but tailored to
-// images.
-//
-// Author: Vincent Rabaud (vrabaud@google.com)
-//
-
-#include <assert.h>
-
-#include "./backward_references_enc.h"
-#include "./histogram_enc.h"
-#include "../dsp/lossless_common.h"
-#include "../utils/color_cache_utils.h"
-#include "../utils/utils.h"
-
-#define VALUES_IN_BYTE 256
-
-extern void VP8LClearBackwardRefs(VP8LBackwardRefs* const refs);
-extern int VP8LDistanceToPlaneCode(int xsize, int dist);
-extern void VP8LBackwardRefsCursorAdd(VP8LBackwardRefs* const refs,
- const PixOrCopy v);
-
-typedef struct {
- double alpha_[VALUES_IN_BYTE];
- double red_[VALUES_IN_BYTE];
- double blue_[VALUES_IN_BYTE];
- double distance_[NUM_DISTANCE_CODES];
- double* literal_;
-} CostModel;
-
-static void ConvertPopulationCountTableToBitEstimates(
- int num_symbols, const uint32_t population_counts[], double output[]) {
- uint32_t sum = 0;
- int nonzeros = 0;
- int i;
- for (i = 0; i < num_symbols; ++i) {
- sum += population_counts[i];
- if (population_counts[i] > 0) {
- ++nonzeros;
- }
- }
- if (nonzeros <= 1) {
- memset(output, 0, num_symbols * sizeof(*output));
- } else {
- const double logsum = VP8LFastLog2(sum);
- for (i = 0; i < num_symbols; ++i) {
- output[i] = logsum - VP8LFastLog2(population_counts[i]);
- }
- }
-}
-
-static int CostModelBuild(CostModel* const m, int xsize, int cache_bits,
- const VP8LBackwardRefs* const refs) {
- int ok = 0;
- VP8LRefsCursor c = VP8LRefsCursorInit(refs);
- VP8LHistogram* const histo = VP8LAllocateHistogram(cache_bits);
- if (histo == NULL) goto Error;
-
- // The following code is similar to VP8LHistogramCreate but converts the
- // distance to plane code.
- VP8LHistogramInit(histo, cache_bits, /*init_arrays=*/ 1);
- while (VP8LRefsCursorOk(&c)) {
- VP8LHistogramAddSinglePixOrCopy(histo, c.cur_pos, VP8LDistanceToPlaneCode,
- xsize);
- VP8LRefsCursorNext(&c);
- }
-
- ConvertPopulationCountTableToBitEstimates(
- VP8LHistogramNumCodes(histo->palette_code_bits_),
- histo->literal_, m->literal_);
- ConvertPopulationCountTableToBitEstimates(
- VALUES_IN_BYTE, histo->red_, m->red_);
- ConvertPopulationCountTableToBitEstimates(
- VALUES_IN_BYTE, histo->blue_, m->blue_);
- ConvertPopulationCountTableToBitEstimates(
- VALUES_IN_BYTE, histo->alpha_, m->alpha_);
- ConvertPopulationCountTableToBitEstimates(
- NUM_DISTANCE_CODES, histo->distance_, m->distance_);
- ok = 1;
-
- Error:
- VP8LFreeHistogram(histo);
- return ok;
-}
-
-static WEBP_INLINE double GetLiteralCost(const CostModel* const m, uint32_t v) {
- return m->alpha_[v >> 24] +
- m->red_[(v >> 16) & 0xff] +
- m->literal_[(v >> 8) & 0xff] +
- m->blue_[v & 0xff];
-}
-
-static WEBP_INLINE double GetCacheCost(const CostModel* const m, uint32_t idx) {
- const int literal_idx = VALUES_IN_BYTE + NUM_LENGTH_CODES + idx;
- return m->literal_[literal_idx];
-}
-
-static WEBP_INLINE double GetLengthCost(const CostModel* const m,
- uint32_t length) {
- int code, extra_bits;
- VP8LPrefixEncodeBits(length, &code, &extra_bits);
- return m->literal_[VALUES_IN_BYTE + code] + extra_bits;
-}
-
-static WEBP_INLINE double GetDistanceCost(const CostModel* const m,
- uint32_t distance) {
- int code, extra_bits;
- VP8LPrefixEncodeBits(distance, &code, &extra_bits);
- return m->distance_[code] + extra_bits;
-}
-
-static WEBP_INLINE void AddSingleLiteralWithCostModel(
- const uint32_t* const argb, VP8LColorCache* const hashers,
- const CostModel* const cost_model, int idx, int use_color_cache,
- float prev_cost, float* const cost, uint16_t* const dist_array) {
- double cost_val = prev_cost;
- const uint32_t color = argb[idx];
- const int ix = use_color_cache ? VP8LColorCacheContains(hashers, color) : -1;
- if (ix >= 0) {
- // use_color_cache is true and hashers contains color
- const double mul0 = 0.68;
- cost_val += GetCacheCost(cost_model, ix) * mul0;
- } else {
- const double mul1 = 0.82;
- if (use_color_cache) VP8LColorCacheInsert(hashers, color);
- cost_val += GetLiteralCost(cost_model, color) * mul1;
- }
- if (cost[idx] > cost_val) {
- cost[idx] = (float)cost_val;
- dist_array[idx] = 1; // only one is inserted.
- }
-}
-
-// -----------------------------------------------------------------------------
-// CostManager and interval handling
-
-// Empirical value to avoid high memory consumption but good for performance.
-#define COST_CACHE_INTERVAL_SIZE_MAX 500
-
-// To perform backward reference every pixel at index index_ is considered and
-// the cost for the MAX_LENGTH following pixels computed. Those following pixels
-// at index index_ + k (k from 0 to MAX_LENGTH) have a cost of:
-// cost_ = distance cost at index + GetLengthCost(cost_model, k)
-// and the minimum value is kept. GetLengthCost(cost_model, k) is cached in an
-// array of size MAX_LENGTH.
-// Instead of performing MAX_LENGTH comparisons per pixel, we keep track of the
-// minimal values using intervals of constant cost.
-// An interval is defined by the index_ of the pixel that generated it and
-// is only useful in a range of indices from start_ to end_ (exclusive), i.e.
-// it contains the minimum value for pixels between start_ and end_.
-// Intervals are stored in a linked list and ordered by start_. When a new
-// interval has a better value, old intervals are split or removed. There are
-// therefore no overlapping intervals.
-typedef struct CostInterval CostInterval;
-struct CostInterval {
- float cost_;
- int start_;
- int end_;
- int index_;
- CostInterval* previous_;
- CostInterval* next_;
-};
-
-// The GetLengthCost(cost_model, k) are cached in a CostCacheInterval.
-typedef struct {
- double cost_;
- int start_;
- int end_; // Exclusive.
-} CostCacheInterval;
-
-// This structure is in charge of managing intervals and costs.
-// It caches the different CostCacheInterval, caches the different
-// GetLengthCost(cost_model, k) in cost_cache_ and the CostInterval's (whose
-// count_ is limited by COST_CACHE_INTERVAL_SIZE_MAX).
-#define COST_MANAGER_MAX_FREE_LIST 10
-typedef struct {
- CostInterval* head_;
- int count_; // The number of stored intervals.
- CostCacheInterval* cache_intervals_;
- size_t cache_intervals_size_;
- double cost_cache_[MAX_LENGTH]; // Contains the GetLengthCost(cost_model, k).
- float* costs_;
- uint16_t* dist_array_;
- // Most of the time, we only need few intervals -> use a free-list, to avoid
- // fragmentation with small allocs in most common cases.
- CostInterval intervals_[COST_MANAGER_MAX_FREE_LIST];
- CostInterval* free_intervals_;
- // These are regularly malloc'd remains. This list can't grow larger than than
- // size COST_CACHE_INTERVAL_SIZE_MAX - COST_MANAGER_MAX_FREE_LIST, note.
- CostInterval* recycled_intervals_;
-} CostManager;
-
-static void CostIntervalAddToFreeList(CostManager* const manager,
- CostInterval* const interval) {
- interval->next_ = manager->free_intervals_;
- manager->free_intervals_ = interval;
-}
-
-static int CostIntervalIsInFreeList(const CostManager* const manager,
- const CostInterval* const interval) {
- return (interval >= &manager->intervals_[0] &&
- interval <= &manager->intervals_[COST_MANAGER_MAX_FREE_LIST - 1]);
-}
-
-static void CostManagerInitFreeList(CostManager* const manager) {
- int i;
- manager->free_intervals_ = NULL;
- for (i = 0; i < COST_MANAGER_MAX_FREE_LIST; ++i) {
- CostIntervalAddToFreeList(manager, &manager->intervals_[i]);
- }
-}
-
-static void DeleteIntervalList(CostManager* const manager,
- const CostInterval* interval) {
- while (interval != NULL) {
- const CostInterval* const next = interval->next_;
- if (!CostIntervalIsInFreeList(manager, interval)) {
- WebPSafeFree((void*)interval);
- } // else: do nothing
- interval = next;
- }
-}
-
-static void CostManagerClear(CostManager* const manager) {
- if (manager == NULL) return;
-
- WebPSafeFree(manager->costs_);
- WebPSafeFree(manager->cache_intervals_);
-
- // Clear the interval lists.
- DeleteIntervalList(manager, manager->head_);
- manager->head_ = NULL;
- DeleteIntervalList(manager, manager->recycled_intervals_);
- manager->recycled_intervals_ = NULL;
-
- // Reset pointers, count_ and cache_intervals_size_.
- memset(manager, 0, sizeof(*manager));
- CostManagerInitFreeList(manager);
-}
-
-static int CostManagerInit(CostManager* const manager,
- uint16_t* const dist_array, int pix_count,
- const CostModel* const cost_model) {
- int i;
- const int cost_cache_size = (pix_count > MAX_LENGTH) ? MAX_LENGTH : pix_count;
-
- manager->costs_ = NULL;
- manager->cache_intervals_ = NULL;
- manager->head_ = NULL;
- manager->recycled_intervals_ = NULL;
- manager->count_ = 0;
- manager->dist_array_ = dist_array;
- CostManagerInitFreeList(manager);
-
- // Fill in the cost_cache_.
- manager->cache_intervals_size_ = 1;
- manager->cost_cache_[0] = GetLengthCost(cost_model, 0);
- for (i = 1; i < cost_cache_size; ++i) {
- manager->cost_cache_[i] = GetLengthCost(cost_model, i);
- // Get the number of bound intervals.
- if (manager->cost_cache_[i] != manager->cost_cache_[i - 1]) {
- ++manager->cache_intervals_size_;
- }
- }
-
- // With the current cost model, we usually have below 20 intervals.
- // The worst case scenario with a cost model would be if every length has a
- // different cost, hence MAX_LENGTH but that is impossible with the current
- // implementation that spirals around a pixel.
- assert(manager->cache_intervals_size_ <= MAX_LENGTH);
- manager->cache_intervals_ = (CostCacheInterval*)WebPSafeMalloc(
- manager->cache_intervals_size_, sizeof(*manager->cache_intervals_));
- if (manager->cache_intervals_ == NULL) {
- CostManagerClear(manager);
- return 0;
- }
-
- // Fill in the cache_intervals_.
- {
- CostCacheInterval* cur = manager->cache_intervals_;
-
- // Consecutive values in cost_cache_ are compared and if a big enough
- // difference is found, a new interval is created and bounded.
- cur->start_ = 0;
- cur->end_ = 1;
- cur->cost_ = manager->cost_cache_[0];
- for (i = 1; i < cost_cache_size; ++i) {
- const double cost_val = manager->cost_cache_[i];
- if (cost_val != cur->cost_) {
- ++cur;
- // Initialize an interval.
- cur->start_ = i;
- cur->cost_ = cost_val;
- }
- cur->end_ = i + 1;
- }
- }
-
- manager->costs_ = (float*)WebPSafeMalloc(pix_count, sizeof(*manager->costs_));
- if (manager->costs_ == NULL) {
- CostManagerClear(manager);
- return 0;
- }
- // Set the initial costs_ high for every pixel as we will keep the minimum.
- for (i = 0; i < pix_count; ++i) manager->costs_[i] = 1e38f;
-
- return 1;
-}
-
-// Given the cost and the position that define an interval, update the cost at
-// pixel 'i' if it is smaller than the previously computed value.
-static WEBP_INLINE void UpdateCost(CostManager* const manager, int i,
- int position, float cost) {
- const int k = i - position;
- assert(k >= 0 && k < MAX_LENGTH);
-
- if (manager->costs_[i] > cost) {
- manager->costs_[i] = cost;
- manager->dist_array_[i] = k + 1;
- }
-}
-
-// Given the cost and the position that define an interval, update the cost for
-// all the pixels between 'start' and 'end' excluded.
-static WEBP_INLINE void UpdateCostPerInterval(CostManager* const manager,
- int start, int end, int position,
- float cost) {
- int i;
- for (i = start; i < end; ++i) UpdateCost(manager, i, position, cost);
-}
-
-// Given two intervals, make 'prev' be the previous one of 'next' in 'manager'.
-static WEBP_INLINE void ConnectIntervals(CostManager* const manager,
- CostInterval* const prev,
- CostInterval* const next) {
- if (prev != NULL) {
- prev->next_ = next;
- } else {
- manager->head_ = next;
- }
-
- if (next != NULL) next->previous_ = prev;
-}
-
-// Pop an interval in the manager.
-static WEBP_INLINE void PopInterval(CostManager* const manager,
- CostInterval* const interval) {
- if (interval == NULL) return;
-
- ConnectIntervals(manager, interval->previous_, interval->next_);
- if (CostIntervalIsInFreeList(manager, interval)) {
- CostIntervalAddToFreeList(manager, interval);
- } else { // recycle regularly malloc'd intervals too
- interval->next_ = manager->recycled_intervals_;
- manager->recycled_intervals_ = interval;
- }
- --manager->count_;
- assert(manager->count_ >= 0);
-}
-
-// Update the cost at index i by going over all the stored intervals that
-// overlap with i.
-// If 'do_clean_intervals' is set to something different than 0, intervals that
-// end before 'i' will be popped.
-static WEBP_INLINE void UpdateCostAtIndex(CostManager* const manager, int i,
- int do_clean_intervals) {
- CostInterval* current = manager->head_;
-
- while (current != NULL && current->start_ <= i) {
- CostInterval* const next = current->next_;
- if (current->end_ <= i) {
- if (do_clean_intervals) {
- // We have an outdated interval, remove it.
- PopInterval(manager, current);
- }
- } else {
- UpdateCost(manager, i, current->index_, current->cost_);
- }
- current = next;
- }
-}
-
-// Given a current orphan interval and its previous interval, before
-// it was orphaned (which can be NULL), set it at the right place in the list
-// of intervals using the start_ ordering and the previous interval as a hint.
-static WEBP_INLINE void PositionOrphanInterval(CostManager* const manager,
- CostInterval* const current,
- CostInterval* previous) {
- assert(current != NULL);
-
- if (previous == NULL) previous = manager->head_;
- while (previous != NULL && current->start_ < previous->start_) {
- previous = previous->previous_;
- }
- while (previous != NULL && previous->next_ != NULL &&
- previous->next_->start_ < current->start_) {
- previous = previous->next_;
- }
-
- if (previous != NULL) {
- ConnectIntervals(manager, current, previous->next_);
- } else {
- ConnectIntervals(manager, current, manager->head_);
- }
- ConnectIntervals(manager, previous, current);
-}
-
-// Insert an interval in the list contained in the manager by starting at
-// interval_in as a hint. The intervals are sorted by start_ value.
-static WEBP_INLINE void InsertInterval(CostManager* const manager,
- CostInterval* const interval_in,
- float cost, int position, int start,
- int end) {
- CostInterval* interval_new;
-
- if (start >= end) return;
- if (manager->count_ >= COST_CACHE_INTERVAL_SIZE_MAX) {
- // Serialize the interval if we cannot store it.
- UpdateCostPerInterval(manager, start, end, position, cost);
- return;
- }
- if (manager->free_intervals_ != NULL) {
- interval_new = manager->free_intervals_;
- manager->free_intervals_ = interval_new->next_;
- } else if (manager->recycled_intervals_ != NULL) {
- interval_new = manager->recycled_intervals_;
- manager->recycled_intervals_ = interval_new->next_;
- } else { // malloc for good
- interval_new = (CostInterval*)WebPSafeMalloc(1, sizeof(*interval_new));
- if (interval_new == NULL) {
- // Write down the interval if we cannot create it.
- UpdateCostPerInterval(manager, start, end, position, cost);
- return;
- }
- }
-
- interval_new->cost_ = cost;
- interval_new->index_ = position;
- interval_new->start_ = start;
- interval_new->end_ = end;
- PositionOrphanInterval(manager, interval_new, interval_in);
-
- ++manager->count_;
-}
-
-// Given a new cost interval defined by its start at position, its length value
-// and distance_cost, add its contributions to the previous intervals and costs.
-// If handling the interval or one of its subintervals becomes to heavy, its
-// contribution is added to the costs right away.
-static WEBP_INLINE void PushInterval(CostManager* const manager,
- double distance_cost, int position,
- int len) {
- size_t i;
- CostInterval* interval = manager->head_;
- CostInterval* interval_next;
- const CostCacheInterval* const cost_cache_intervals =
- manager->cache_intervals_;
- // If the interval is small enough, no need to deal with the heavy
- // interval logic, just serialize it right away. This constant is empirical.
- const int kSkipDistance = 10;
-
- if (len < kSkipDistance) {
- int j;
- for (j = position; j < position + len; ++j) {
- const int k = j - position;
- float cost_tmp;
- assert(k >= 0 && k < MAX_LENGTH);
- cost_tmp = (float)(distance_cost + manager->cost_cache_[k]);
-
- if (manager->costs_[j] > cost_tmp) {
- manager->costs_[j] = cost_tmp;
- manager->dist_array_[j] = k + 1;
- }
- }
- return;
- }
-
- for (i = 0; i < manager->cache_intervals_size_ &&
- cost_cache_intervals[i].start_ < len;
- ++i) {
- // Define the intersection of the ith interval with the new one.
- int start = position + cost_cache_intervals[i].start_;
- const int end = position + (cost_cache_intervals[i].end_ > len
- ? len
- : cost_cache_intervals[i].end_);
- const float cost = (float)(distance_cost + cost_cache_intervals[i].cost_);
-
- for (; interval != NULL && interval->start_ < end;
- interval = interval_next) {
- interval_next = interval->next_;
-
- // Make sure we have some overlap
- if (start >= interval->end_) continue;
-
- if (cost >= interval->cost_) {
- // When intervals are represented, the lower, the better.
- // [**********************************************************[
- // start end
- // [----------------------------------[
- // interval->start_ interval->end_
- // If we are worse than what we already have, add whatever we have so
- // far up to interval.
- const int start_new = interval->end_;
- InsertInterval(manager, interval, cost, position, start,
- interval->start_);
- start = start_new;
- if (start >= end) break;
- continue;
- }
-
- if (start <= interval->start_) {
- if (interval->end_ <= end) {
- // [----------------------------------[
- // interval->start_ interval->end_
- // [**************************************************************[
- // start end
- // We can safely remove the old interval as it is fully included.
- PopInterval(manager, interval);
- } else {
- // [------------------------------------[
- // interval->start_ interval->end_
- // [*****************************[
- // start end
- interval->start_ = end;
- break;
- }
- } else {
- if (end < interval->end_) {
- // [--------------------------------------------------------------[
- // interval->start_ interval->end_
- // [*****************************[
- // start end
- // We have to split the old interval as it fully contains the new one.
- const int end_original = interval->end_;
- interval->end_ = start;
- InsertInterval(manager, interval, interval->cost_, interval->index_,
- end, end_original);
- interval = interval->next_;
- break;
- } else {
- // [------------------------------------[
- // interval->start_ interval->end_
- // [*****************************[
- // start end
- interval->end_ = start;
- }
- }
- }
- // Insert the remaining interval from start to end.
- InsertInterval(manager, interval, cost, position, start, end);
- }
-}
-
-static int BackwardReferencesHashChainDistanceOnly(
- int xsize, int ysize, const uint32_t* const argb, int cache_bits,
- const VP8LHashChain* const hash_chain, const VP8LBackwardRefs* const refs,
- uint16_t* const dist_array) {
- int i;
- int ok = 0;
- int cc_init = 0;
- const int pix_count = xsize * ysize;
- const int use_color_cache = (cache_bits > 0);
- const size_t literal_array_size =
- sizeof(double) * (NUM_LITERAL_CODES + NUM_LENGTH_CODES +
- ((cache_bits > 0) ? (1 << cache_bits) : 0));
- const size_t cost_model_size = sizeof(CostModel) + literal_array_size;
- CostModel* const cost_model =
- (CostModel*)WebPSafeCalloc(1ULL, cost_model_size);
- VP8LColorCache hashers;
- CostManager* cost_manager =
- (CostManager*)WebPSafeMalloc(1ULL, sizeof(*cost_manager));
- int offset_prev = -1, len_prev = -1;
- double offset_cost = -1;
- int first_offset_is_constant = -1; // initialized with 'impossible' value
- int reach = 0;
-
- if (cost_model == NULL || cost_manager == NULL) goto Error;
-
- cost_model->literal_ = (double*)(cost_model + 1);
- if (use_color_cache) {
- cc_init = VP8LColorCacheInit(&hashers, cache_bits);
- if (!cc_init) goto Error;
- }
-
- if (!CostModelBuild(cost_model, xsize, cache_bits, refs)) {
- goto Error;
- }
-
- if (!CostManagerInit(cost_manager, dist_array, pix_count, cost_model)) {
- goto Error;
- }
-
- // We loop one pixel at a time, but store all currently best points to
- // non-processed locations from this point.
- dist_array[0] = 0;
- // Add first pixel as literal.
- AddSingleLiteralWithCostModel(argb, &hashers, cost_model, 0, use_color_cache,
- 0.f, cost_manager->costs_, dist_array);
-
- for (i = 1; i < pix_count; ++i) {
- const float prev_cost = cost_manager->costs_[i - 1];
- int offset, len;
- VP8LHashChainFindCopy(hash_chain, i, &offset, &len);
-
- // Try adding the pixel as a literal.
- AddSingleLiteralWithCostModel(argb, &hashers, cost_model, i,
- use_color_cache, prev_cost,
- cost_manager->costs_, dist_array);
-
- // If we are dealing with a non-literal.
- if (len >= 2) {
- if (offset != offset_prev) {
- const int code = VP8LDistanceToPlaneCode(xsize, offset);
- offset_cost = GetDistanceCost(cost_model, code);
- first_offset_is_constant = 1;
- PushInterval(cost_manager, prev_cost + offset_cost, i, len);
- } else {
- assert(offset_cost >= 0);
- assert(len_prev >= 0);
- assert(first_offset_is_constant == 0 || first_offset_is_constant == 1);
- // Instead of considering all contributions from a pixel i by calling:
- // PushInterval(cost_manager, prev_cost + offset_cost, i, len);
- // we optimize these contributions in case offset_cost stays the same
- // for consecutive pixels. This describes a set of pixels similar to a
- // previous set (e.g. constant color regions).
- if (first_offset_is_constant) {
- reach = i - 1 + len_prev - 1;
- first_offset_is_constant = 0;
- }
-
- if (i + len - 1 > reach) {
- // We can only be go further with the same offset if the previous
- // length was maxed, hence len_prev == len == MAX_LENGTH.
- // TODO(vrabaud), bump i to the end right away (insert cache and
- // update cost).
- // TODO(vrabaud), check if one of the points in between does not have
- // a lower cost.
- // Already consider the pixel at "reach" to add intervals that are
- // better than whatever we add.
- int offset_j, len_j = 0;
- int j;
- assert(len == MAX_LENGTH || len == pix_count - i);
- // Figure out the last consecutive pixel within [i, reach + 1] with
- // the same offset.
- for (j = i; j <= reach; ++j) {
- VP8LHashChainFindCopy(hash_chain, j + 1, &offset_j, &len_j);
- if (offset_j != offset) {
- VP8LHashChainFindCopy(hash_chain, j, &offset_j, &len_j);
- break;
- }
- }
- // Update the cost at j - 1 and j.
- UpdateCostAtIndex(cost_manager, j - 1, 0);
- UpdateCostAtIndex(cost_manager, j, 0);
-
- PushInterval(cost_manager, cost_manager->costs_[j - 1] + offset_cost,
- j, len_j);
- reach = j + len_j - 1;
- }
- }
- }
-
- UpdateCostAtIndex(cost_manager, i, 1);
- offset_prev = offset;
- len_prev = len;
- }
-
- ok = !refs->error_;
-Error:
- if (cc_init) VP8LColorCacheClear(&hashers);
- CostManagerClear(cost_manager);
- WebPSafeFree(cost_model);
- WebPSafeFree(cost_manager);
- return ok;
-}
-
-// We pack the path at the end of *dist_array and return
-// a pointer to this part of the array. Example:
-// dist_array = [1x2xx3x2] => packed [1x2x1232], chosen_path = [1232]
-static void TraceBackwards(uint16_t* const dist_array,
- int dist_array_size,
- uint16_t** const chosen_path,
- int* const chosen_path_size) {
- uint16_t* path = dist_array + dist_array_size;
- uint16_t* cur = dist_array + dist_array_size - 1;
- while (cur >= dist_array) {
- const int k = *cur;
- --path;
- *path = k;
- cur -= k;
- }
- *chosen_path = path;
- *chosen_path_size = (int)(dist_array + dist_array_size - path);
-}
-
-static int BackwardReferencesHashChainFollowChosenPath(
- const uint32_t* const argb, int cache_bits,
- const uint16_t* const chosen_path, int chosen_path_size,
- const VP8LHashChain* const hash_chain, VP8LBackwardRefs* const refs) {
- const int use_color_cache = (cache_bits > 0);
- int ix;
- int i = 0;
- int ok = 0;
- int cc_init = 0;
- VP8LColorCache hashers;
-
- if (use_color_cache) {
- cc_init = VP8LColorCacheInit(&hashers, cache_bits);
- if (!cc_init) goto Error;
- }
-
- VP8LClearBackwardRefs(refs);
- for (ix = 0; ix < chosen_path_size; ++ix) {
- const int len = chosen_path[ix];
- if (len != 1) {
- int k;
- const int offset = VP8LHashChainFindOffset(hash_chain, i);
- VP8LBackwardRefsCursorAdd(refs, PixOrCopyCreateCopy(offset, len));
- if (use_color_cache) {
- for (k = 0; k < len; ++k) {
- VP8LColorCacheInsert(&hashers, argb[i + k]);
- }
- }
- i += len;
- } else {
- PixOrCopy v;
- const int idx =
- use_color_cache ? VP8LColorCacheContains(&hashers, argb[i]) : -1;
- if (idx >= 0) {
- // use_color_cache is true and hashers contains argb[i]
- // push pixel as a color cache index
- v = PixOrCopyCreateCacheIdx(idx);
- } else {
- if (use_color_cache) VP8LColorCacheInsert(&hashers, argb[i]);
- v = PixOrCopyCreateLiteral(argb[i]);
- }
- VP8LBackwardRefsCursorAdd(refs, v);
- ++i;
- }
- }
- ok = !refs->error_;
- Error:
- if (cc_init) VP8LColorCacheClear(&hashers);
- return ok;
-}
-
-// Returns 1 on success.
-extern int VP8LBackwardReferencesTraceBackwards(
- int xsize, int ysize, const uint32_t* const argb, int cache_bits,
- const VP8LHashChain* const hash_chain,
- const VP8LBackwardRefs* const refs_src, VP8LBackwardRefs* const refs_dst);
-int VP8LBackwardReferencesTraceBackwards(int xsize, int ysize,
- const uint32_t* const argb,
- int cache_bits,
- const VP8LHashChain* const hash_chain,
- const VP8LBackwardRefs* const refs_src,
- VP8LBackwardRefs* const refs_dst) {
- int ok = 0;
- const int dist_array_size = xsize * ysize;
- uint16_t* chosen_path = NULL;
- int chosen_path_size = 0;
- uint16_t* dist_array =
- (uint16_t*)WebPSafeMalloc(dist_array_size, sizeof(*dist_array));
-
- if (dist_array == NULL) goto Error;
-
- if (!BackwardReferencesHashChainDistanceOnly(
- xsize, ysize, argb, cache_bits, hash_chain, refs_src, dist_array)) {
- goto Error;
- }
- TraceBackwards(dist_array, dist_array_size, &chosen_path, &chosen_path_size);
- if (!BackwardReferencesHashChainFollowChosenPath(
- argb, cache_bits, chosen_path, chosen_path_size, hash_chain,
- refs_dst)) {
- goto Error;
- }
- ok = 1;
- Error:
- WebPSafeFree(dist_array);
- return ok;
-}
diff --git a/contrib/libs/libwebp/enc/backward_references_enc.c b/contrib/libs/libwebp/enc/backward_references_enc.c
deleted file mode 100644
index f24c394bb8..0000000000
--- a/contrib/libs/libwebp/enc/backward_references_enc.c
+++ /dev/null
@@ -1,1030 +0,0 @@
-// Copyright 2012 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Author: Jyrki Alakuijala (jyrki@google.com)
-//
-
-#include <assert.h>
-#include <float.h>
-#include <math.h>
-
-#include "../dsp/dsp.h"
-#include "../dsp/lossless.h"
-#include "../dsp/lossless_common.h"
-#include "./backward_references_enc.h"
-#include "./histogram_enc.h"
-#include "../utils/color_cache_utils.h"
-#include "../utils/utils.h"
-
-#define MIN_BLOCK_SIZE 256 // minimum block size for backward references
-
-#define MAX_ENTROPY (1e30f)
-
-// 1M window (4M bytes) minus 120 special codes for short distances.
-#define WINDOW_SIZE ((1 << WINDOW_SIZE_BITS) - 120)
-
-// Minimum number of pixels for which it is cheaper to encode a
-// distance + length instead of each pixel as a literal.
-#define MIN_LENGTH 4
-
-// -----------------------------------------------------------------------------
-
-static const uint8_t plane_to_code_lut[128] = {
- 96, 73, 55, 39, 23, 13, 5, 1, 255, 255, 255, 255, 255, 255, 255, 255,
- 101, 78, 58, 42, 26, 16, 8, 2, 0, 3, 9, 17, 27, 43, 59, 79,
- 102, 86, 62, 46, 32, 20, 10, 6, 4, 7, 11, 21, 33, 47, 63, 87,
- 105, 90, 70, 52, 37, 28, 18, 14, 12, 15, 19, 29, 38, 53, 71, 91,
- 110, 99, 82, 66, 48, 35, 30, 24, 22, 25, 31, 36, 49, 67, 83, 100,
- 115, 108, 94, 76, 64, 50, 44, 40, 34, 41, 45, 51, 65, 77, 95, 109,
- 118, 113, 103, 92, 80, 68, 60, 56, 54, 57, 61, 69, 81, 93, 104, 114,
- 119, 116, 111, 106, 97, 88, 84, 74, 72, 75, 85, 89, 98, 107, 112, 117
-};
-
-extern int VP8LDistanceToPlaneCode(int xsize, int dist);
-int VP8LDistanceToPlaneCode(int xsize, int dist) {
- const int yoffset = dist / xsize;
- const int xoffset = dist - yoffset * xsize;
- if (xoffset <= 8 && yoffset < 8) {
- return plane_to_code_lut[yoffset * 16 + 8 - xoffset] + 1;
- } else if (xoffset > xsize - 8 && yoffset < 7) {
- return plane_to_code_lut[(yoffset + 1) * 16 + 8 + (xsize - xoffset)] + 1;
- }
- return dist + 120;
-}
-
-// Returns the exact index where array1 and array2 are different. For an index
-// inferior or equal to best_len_match, the return value just has to be strictly
-// inferior to best_len_match. The current behavior is to return 0 if this index
-// is best_len_match, and the index itself otherwise.
-// If no two elements are the same, it returns max_limit.
-static WEBP_INLINE int FindMatchLength(const uint32_t* const array1,
- const uint32_t* const array2,
- int best_len_match, int max_limit) {
- // Before 'expensive' linear match, check if the two arrays match at the
- // current best length index.
- if (array1[best_len_match] != array2[best_len_match]) return 0;
-
- return VP8LVectorMismatch(array1, array2, max_limit);
-}
-
-// -----------------------------------------------------------------------------
-// VP8LBackwardRefs
-
-struct PixOrCopyBlock {
- PixOrCopyBlock* next_; // next block (or NULL)
- PixOrCopy* start_; // data start
- int size_; // currently used size
-};
-
-extern void VP8LClearBackwardRefs(VP8LBackwardRefs* const refs);
-void VP8LClearBackwardRefs(VP8LBackwardRefs* const refs) {
- assert(refs != NULL);
- if (refs->tail_ != NULL) {
- *refs->tail_ = refs->free_blocks_; // recycle all blocks at once
- }
- refs->free_blocks_ = refs->refs_;
- refs->tail_ = &refs->refs_;
- refs->last_block_ = NULL;
- refs->refs_ = NULL;
-}
-
-void VP8LBackwardRefsClear(VP8LBackwardRefs* const refs) {
- assert(refs != NULL);
- VP8LClearBackwardRefs(refs);
- while (refs->free_blocks_ != NULL) {
- PixOrCopyBlock* const next = refs->free_blocks_->next_;
- WebPSafeFree(refs->free_blocks_);
- refs->free_blocks_ = next;
- }
-}
-
-// Swaps the content of two VP8LBackwardRefs.
-static void BackwardRefsSwap(VP8LBackwardRefs* const refs1,
- VP8LBackwardRefs* const refs2) {
- const int point_to_refs1 =
- (refs1->tail_ != NULL && refs1->tail_ == &refs1->refs_);
- const int point_to_refs2 =
- (refs2->tail_ != NULL && refs2->tail_ == &refs2->refs_);
- const VP8LBackwardRefs tmp = *refs1;
- *refs1 = *refs2;
- *refs2 = tmp;
- if (point_to_refs2) refs1->tail_ = &refs1->refs_;
- if (point_to_refs1) refs2->tail_ = &refs2->refs_;
-}
-
-void VP8LBackwardRefsInit(VP8LBackwardRefs* const refs, int block_size) {
- assert(refs != NULL);
- memset(refs, 0, sizeof(*refs));
- refs->tail_ = &refs->refs_;
- refs->block_size_ =
- (block_size < MIN_BLOCK_SIZE) ? MIN_BLOCK_SIZE : block_size;
-}
-
-VP8LRefsCursor VP8LRefsCursorInit(const VP8LBackwardRefs* const refs) {
- VP8LRefsCursor c;
- c.cur_block_ = refs->refs_;
- if (refs->refs_ != NULL) {
- c.cur_pos = c.cur_block_->start_;
- c.last_pos_ = c.cur_pos + c.cur_block_->size_;
- } else {
- c.cur_pos = NULL;
- c.last_pos_ = NULL;
- }
- return c;
-}
-
-void VP8LRefsCursorNextBlock(VP8LRefsCursor* const c) {
- PixOrCopyBlock* const b = c->cur_block_->next_;
- c->cur_pos = (b == NULL) ? NULL : b->start_;
- c->last_pos_ = (b == NULL) ? NULL : b->start_ + b->size_;
- c->cur_block_ = b;
-}
-
-// Create a new block, either from the free list or allocated
-static PixOrCopyBlock* BackwardRefsNewBlock(VP8LBackwardRefs* const refs) {
- PixOrCopyBlock* b = refs->free_blocks_;
- if (b == NULL) { // allocate new memory chunk
- const size_t total_size =
- sizeof(*b) + refs->block_size_ * sizeof(*b->start_);
- b = (PixOrCopyBlock*)WebPSafeMalloc(1ULL, total_size);
- if (b == NULL) {
- refs->error_ |= 1;
- return NULL;
- }
- b->start_ = (PixOrCopy*)((uint8_t*)b + sizeof(*b)); // not always aligned
- } else { // recycle from free-list
- refs->free_blocks_ = b->next_;
- }
- *refs->tail_ = b;
- refs->tail_ = &b->next_;
- refs->last_block_ = b;
- b->next_ = NULL;
- b->size_ = 0;
- return b;
-}
-
-// Return 1 on success, 0 on error.
-static int BackwardRefsClone(const VP8LBackwardRefs* const from,
- VP8LBackwardRefs* const to) {
- const PixOrCopyBlock* block_from = from->refs_;
- VP8LClearBackwardRefs(to);
- while (block_from != NULL) {
- PixOrCopyBlock* const block_to = BackwardRefsNewBlock(to);
- if (block_to == NULL) return 0;
- memcpy(block_to->start_, block_from->start_,
- block_from->size_ * sizeof(PixOrCopy));
- block_to->size_ = block_from->size_;
- block_from = block_from->next_;
- }
- return 1;
-}
-
-extern void VP8LBackwardRefsCursorAdd(VP8LBackwardRefs* const refs,
- const PixOrCopy v);
-void VP8LBackwardRefsCursorAdd(VP8LBackwardRefs* const refs,
- const PixOrCopy v) {
- PixOrCopyBlock* b = refs->last_block_;
- if (b == NULL || b->size_ == refs->block_size_) {
- b = BackwardRefsNewBlock(refs);
- if (b == NULL) return; // refs->error_ is set
- }
- b->start_[b->size_++] = v;
-}
-
-// -----------------------------------------------------------------------------
-// Hash chains
-
-int VP8LHashChainInit(VP8LHashChain* const p, int size) {
- assert(p->size_ == 0);
- assert(p->offset_length_ == NULL);
- assert(size > 0);
- p->offset_length_ =
- (uint32_t*)WebPSafeMalloc(size, sizeof(*p->offset_length_));
- if (p->offset_length_ == NULL) return 0;
- p->size_ = size;
-
- return 1;
-}
-
-void VP8LHashChainClear(VP8LHashChain* const p) {
- assert(p != NULL);
- WebPSafeFree(p->offset_length_);
-
- p->size_ = 0;
- p->offset_length_ = NULL;
-}
-
-// -----------------------------------------------------------------------------
-
-static const uint32_t kHashMultiplierHi = 0xc6a4a793u;
-static const uint32_t kHashMultiplierLo = 0x5bd1e996u;
-
-static WEBP_UBSAN_IGNORE_UNSIGNED_OVERFLOW WEBP_INLINE
-uint32_t GetPixPairHash64(const uint32_t* const argb) {
- uint32_t key;
- key = argb[1] * kHashMultiplierHi;
- key += argb[0] * kHashMultiplierLo;
- key = key >> (32 - HASH_BITS);
- return key;
-}
-
-// Returns the maximum number of hash chain lookups to do for a
-// given compression quality. Return value in range [8, 86].
-static int GetMaxItersForQuality(int quality) {
- return 8 + (quality * quality) / 128;
-}
-
-static int GetWindowSizeForHashChain(int quality, int xsize) {
- const int max_window_size = (quality > 75) ? WINDOW_SIZE
- : (quality > 50) ? (xsize << 8)
- : (quality > 25) ? (xsize << 6)
- : (xsize << 4);
- assert(xsize > 0);
- return (max_window_size > WINDOW_SIZE) ? WINDOW_SIZE : max_window_size;
-}
-
-static WEBP_INLINE int MaxFindCopyLength(int len) {
- return (len < MAX_LENGTH) ? len : MAX_LENGTH;
-}
-
-int VP8LHashChainFill(VP8LHashChain* const p, int quality,
- const uint32_t* const argb, int xsize, int ysize,
- int low_effort) {
- const int size = xsize * ysize;
- const int iter_max = GetMaxItersForQuality(quality);
- const uint32_t window_size = GetWindowSizeForHashChain(quality, xsize);
- int pos;
- int argb_comp;
- uint32_t base_position;
- int32_t* hash_to_first_index;
- // Temporarily use the p->offset_length_ as a hash chain.
- int32_t* chain = (int32_t*)p->offset_length_;
- assert(size > 0);
- assert(p->size_ != 0);
- assert(p->offset_length_ != NULL);
-
- if (size <= 2) {
- p->offset_length_[0] = p->offset_length_[size - 1] = 0;
- return 1;
- }
-
- hash_to_first_index =
- (int32_t*)WebPSafeMalloc(HASH_SIZE, sizeof(*hash_to_first_index));
- if (hash_to_first_index == NULL) return 0;
-
- // Set the int32_t array to -1.
- memset(hash_to_first_index, 0xff, HASH_SIZE * sizeof(*hash_to_first_index));
- // Fill the chain linking pixels with the same hash.
- argb_comp = (argb[0] == argb[1]);
- for (pos = 0; pos < size - 2;) {
- uint32_t hash_code;
- const int argb_comp_next = (argb[pos + 1] == argb[pos + 2]);
- if (argb_comp && argb_comp_next) {
- // Consecutive pixels with the same color will share the same hash.
- // We therefore use a different hash: the color and its repetition
- // length.
- uint32_t tmp[2];
- uint32_t len = 1;
- tmp[0] = argb[pos];
- // Figure out how far the pixels are the same.
- // The last pixel has a different 64 bit hash, as its next pixel does
- // not have the same color, so we just need to get to the last pixel equal
- // to its follower.
- while (pos + (int)len + 2 < size && argb[pos + len + 2] == argb[pos]) {
- ++len;
- }
- if (len > MAX_LENGTH) {
- // Skip the pixels that match for distance=1 and length>MAX_LENGTH
- // because they are linked to their predecessor and we automatically
- // check that in the main for loop below. Skipping means setting no
- // predecessor in the chain, hence -1.
- memset(chain + pos, 0xff, (len - MAX_LENGTH) * sizeof(*chain));
- pos += len - MAX_LENGTH;
- len = MAX_LENGTH;
- }
- // Process the rest of the hash chain.
- while (len) {
- tmp[1] = len--;
- hash_code = GetPixPairHash64(tmp);
- chain[pos] = hash_to_first_index[hash_code];
- hash_to_first_index[hash_code] = pos++;
- }
- argb_comp = 0;
- } else {
- // Just move one pixel forward.
- hash_code = GetPixPairHash64(argb + pos);
- chain[pos] = hash_to_first_index[hash_code];
- hash_to_first_index[hash_code] = pos++;
- argb_comp = argb_comp_next;
- }
- }
- // Process the penultimate pixel.
- chain[pos] = hash_to_first_index[GetPixPairHash64(argb + pos)];
-
- WebPSafeFree(hash_to_first_index);
-
- // Find the best match interval at each pixel, defined by an offset to the
- // pixel and a length. The right-most pixel cannot match anything to the right
- // (hence a best length of 0) and the left-most pixel nothing to the left
- // (hence an offset of 0).
- assert(size > 2);
- p->offset_length_[0] = p->offset_length_[size - 1] = 0;
- for (base_position = size - 2; base_position > 0;) {
- const int max_len = MaxFindCopyLength(size - 1 - base_position);
- const uint32_t* const argb_start = argb + base_position;
- int iter = iter_max;
- int best_length = 0;
- uint32_t best_distance = 0;
- uint32_t best_argb;
- const int min_pos =
- (base_position > window_size) ? base_position - window_size : 0;
- const int length_max = (max_len < 256) ? max_len : 256;
- uint32_t max_base_position;
-
- pos = chain[base_position];
- if (!low_effort) {
- int curr_length;
- // Heuristic: use the comparison with the above line as an initialization.
- if (base_position >= (uint32_t)xsize) {
- curr_length = FindMatchLength(argb_start - xsize, argb_start,
- best_length, max_len);
- if (curr_length > best_length) {
- best_length = curr_length;
- best_distance = xsize;
- }
- --iter;
- }
- // Heuristic: compare to the previous pixel.
- curr_length =
- FindMatchLength(argb_start - 1, argb_start, best_length, max_len);
- if (curr_length > best_length) {
- best_length = curr_length;
- best_distance = 1;
- }
- --iter;
- // Skip the for loop if we already have the maximum.
- if (best_length == MAX_LENGTH) pos = min_pos - 1;
- }
- best_argb = argb_start[best_length];
-
- for (; pos >= min_pos && --iter; pos = chain[pos]) {
- int curr_length;
- assert(base_position > (uint32_t)pos);
-
- if (argb[pos + best_length] != best_argb) continue;
-
- curr_length = VP8LVectorMismatch(argb + pos, argb_start, max_len);
- if (best_length < curr_length) {
- best_length = curr_length;
- best_distance = base_position - pos;
- best_argb = argb_start[best_length];
- // Stop if we have reached a good enough length.
- if (best_length >= length_max) break;
- }
- }
- // We have the best match but in case the two intervals continue matching
- // to the left, we have the best matches for the left-extended pixels.
- max_base_position = base_position;
- while (1) {
- assert(best_length <= MAX_LENGTH);
- assert(best_distance <= WINDOW_SIZE);
- p->offset_length_[base_position] =
- (best_distance << MAX_LENGTH_BITS) | (uint32_t)best_length;
- --base_position;
- // Stop if we don't have a match or if we are out of bounds.
- if (best_distance == 0 || base_position == 0) break;
- // Stop if we cannot extend the matching intervals to the left.
- if (base_position < best_distance ||
- argb[base_position - best_distance] != argb[base_position]) {
- break;
- }
- // Stop if we are matching at its limit because there could be a closer
- // matching interval with the same maximum length. Then again, if the
- // matching interval is as close as possible (best_distance == 1), we will
- // never find anything better so let's continue.
- if (best_length == MAX_LENGTH && best_distance != 1 &&
- base_position + MAX_LENGTH < max_base_position) {
- break;
- }
- if (best_length < MAX_LENGTH) {
- ++best_length;
- max_base_position = base_position;
- }
- }
- }
- return 1;
-}
-
-static WEBP_INLINE void AddSingleLiteral(uint32_t pixel, int use_color_cache,
- VP8LColorCache* const hashers,
- VP8LBackwardRefs* const refs) {
- PixOrCopy v;
- if (use_color_cache) {
- const uint32_t key = VP8LColorCacheGetIndex(hashers, pixel);
- if (VP8LColorCacheLookup(hashers, key) == pixel) {
- v = PixOrCopyCreateCacheIdx(key);
- } else {
- v = PixOrCopyCreateLiteral(pixel);
- VP8LColorCacheSet(hashers, key, pixel);
- }
- } else {
- v = PixOrCopyCreateLiteral(pixel);
- }
- VP8LBackwardRefsCursorAdd(refs, v);
-}
-
-static int BackwardReferencesRle(int xsize, int ysize,
- const uint32_t* const argb,
- int cache_bits, VP8LBackwardRefs* const refs) {
- const int pix_count = xsize * ysize;
- int i, k;
- const int use_color_cache = (cache_bits > 0);
- VP8LColorCache hashers;
-
- if (use_color_cache && !VP8LColorCacheInit(&hashers, cache_bits)) {
- return 0;
- }
- VP8LClearBackwardRefs(refs);
- // Add first pixel as literal.
- AddSingleLiteral(argb[0], use_color_cache, &hashers, refs);
- i = 1;
- while (i < pix_count) {
- const int max_len = MaxFindCopyLength(pix_count - i);
- const int rle_len = FindMatchLength(argb + i, argb + i - 1, 0, max_len);
- const int prev_row_len = (i < xsize) ? 0 :
- FindMatchLength(argb + i, argb + i - xsize, 0, max_len);
- if (rle_len >= prev_row_len && rle_len >= MIN_LENGTH) {
- VP8LBackwardRefsCursorAdd(refs, PixOrCopyCreateCopy(1, rle_len));
- // We don't need to update the color cache here since it is always the
- // same pixel being copied, and that does not change the color cache
- // state.
- i += rle_len;
- } else if (prev_row_len >= MIN_LENGTH) {
- VP8LBackwardRefsCursorAdd(refs, PixOrCopyCreateCopy(xsize, prev_row_len));
- if (use_color_cache) {
- for (k = 0; k < prev_row_len; ++k) {
- VP8LColorCacheInsert(&hashers, argb[i + k]);
- }
- }
- i += prev_row_len;
- } else {
- AddSingleLiteral(argb[i], use_color_cache, &hashers, refs);
- i++;
- }
- }
- if (use_color_cache) VP8LColorCacheClear(&hashers);
- return !refs->error_;
-}
-
-static int BackwardReferencesLz77(int xsize, int ysize,
- const uint32_t* const argb, int cache_bits,
- const VP8LHashChain* const hash_chain,
- VP8LBackwardRefs* const refs) {
- int i;
- int i_last_check = -1;
- int ok = 0;
- int cc_init = 0;
- const int use_color_cache = (cache_bits > 0);
- const int pix_count = xsize * ysize;
- VP8LColorCache hashers;
-
- if (use_color_cache) {
- cc_init = VP8LColorCacheInit(&hashers, cache_bits);
- if (!cc_init) goto Error;
- }
- VP8LClearBackwardRefs(refs);
- for (i = 0; i < pix_count;) {
- // Alternative#1: Code the pixels starting at 'i' using backward reference.
- int offset = 0;
- int len = 0;
- int j;
- VP8LHashChainFindCopy(hash_chain, i, &offset, &len);
- if (len >= MIN_LENGTH) {
- const int len_ini = len;
- int max_reach = 0;
- const int j_max =
- (i + len_ini >= pix_count) ? pix_count - 1 : i + len_ini;
- // Only start from what we have not checked already.
- i_last_check = (i > i_last_check) ? i : i_last_check;
- // We know the best match for the current pixel but we try to find the
- // best matches for the current pixel AND the next one combined.
- // The naive method would use the intervals:
- // [i,i+len) + [i+len, length of best match at i+len)
- // while we check if we can use:
- // [i,j) (where j<=i+len) + [j, length of best match at j)
- for (j = i_last_check + 1; j <= j_max; ++j) {
- const int len_j = VP8LHashChainFindLength(hash_chain, j);
- const int reach =
- j + (len_j >= MIN_LENGTH ? len_j : 1); // 1 for single literal.
- if (reach > max_reach) {
- len = j - i;
- max_reach = reach;
- if (max_reach >= pix_count) break;
- }
- }
- } else {
- len = 1;
- }
- // Go with literal or backward reference.
- assert(len > 0);
- if (len == 1) {
- AddSingleLiteral(argb[i], use_color_cache, &hashers, refs);
- } else {
- VP8LBackwardRefsCursorAdd(refs, PixOrCopyCreateCopy(offset, len));
- if (use_color_cache) {
- for (j = i; j < i + len; ++j) VP8LColorCacheInsert(&hashers, argb[j]);
- }
- }
- i += len;
- }
-
- ok = !refs->error_;
- Error:
- if (cc_init) VP8LColorCacheClear(&hashers);
- return ok;
-}
-
-// Compute an LZ77 by forcing matches to happen within a given distance cost.
-// We therefore limit the algorithm to the lowest 32 values in the PlaneCode
-// definition.
-#define WINDOW_OFFSETS_SIZE_MAX 32
-static int BackwardReferencesLz77Box(int xsize, int ysize,
- const uint32_t* const argb, int cache_bits,
- const VP8LHashChain* const hash_chain_best,
- VP8LHashChain* hash_chain,
- VP8LBackwardRefs* const refs) {
- int i;
- const int pix_count = xsize * ysize;
- uint16_t* counts;
- int window_offsets[WINDOW_OFFSETS_SIZE_MAX] = {0};
- int window_offsets_new[WINDOW_OFFSETS_SIZE_MAX] = {0};
- int window_offsets_size = 0;
- int window_offsets_new_size = 0;
- uint16_t* const counts_ini =
- (uint16_t*)WebPSafeMalloc(xsize * ysize, sizeof(*counts_ini));
- int best_offset_prev = -1, best_length_prev = -1;
- if (counts_ini == NULL) return 0;
-
- // counts[i] counts how many times a pixel is repeated starting at position i.
- i = pix_count - 2;
- counts = counts_ini + i;
- counts[1] = 1;
- for (; i >= 0; --i, --counts) {
- if (argb[i] == argb[i + 1]) {
- // Max out the counts to MAX_LENGTH.
- counts[0] = counts[1] + (counts[1] != MAX_LENGTH);
- } else {
- counts[0] = 1;
- }
- }
-
- // Figure out the window offsets around a pixel. They are stored in a
- // spiraling order around the pixel as defined by VP8LDistanceToPlaneCode.
- {
- int x, y;
- for (y = 0; y <= 6; ++y) {
- for (x = -6; x <= 6; ++x) {
- const int offset = y * xsize + x;
- int plane_code;
- // Ignore offsets that bring us after the pixel.
- if (offset <= 0) continue;
- plane_code = VP8LDistanceToPlaneCode(xsize, offset) - 1;
- if (plane_code >= WINDOW_OFFSETS_SIZE_MAX) continue;
- window_offsets[plane_code] = offset;
- }
- }
- // For narrow images, not all plane codes are reached, so remove those.
- for (i = 0; i < WINDOW_OFFSETS_SIZE_MAX; ++i) {
- if (window_offsets[i] == 0) continue;
- window_offsets[window_offsets_size++] = window_offsets[i];
- }
- // Given a pixel P, find the offsets that reach pixels unreachable from P-1
- // with any of the offsets in window_offsets[].
- for (i = 0; i < window_offsets_size; ++i) {
- int j;
- int is_reachable = 0;
- for (j = 0; j < window_offsets_size && !is_reachable; ++j) {
- is_reachable |= (window_offsets[i] == window_offsets[j] + 1);
- }
- if (!is_reachable) {
- window_offsets_new[window_offsets_new_size] = window_offsets[i];
- ++window_offsets_new_size;
- }
- }
- }
-
- hash_chain->offset_length_[0] = 0;
- for (i = 1; i < pix_count; ++i) {
- int ind;
- int best_length = VP8LHashChainFindLength(hash_chain_best, i);
- int best_offset;
- int do_compute = 1;
-
- if (best_length >= MAX_LENGTH) {
- // Do not recompute the best match if we already have a maximal one in the
- // window.
- best_offset = VP8LHashChainFindOffset(hash_chain_best, i);
- for (ind = 0; ind < window_offsets_size; ++ind) {
- if (best_offset == window_offsets[ind]) {
- do_compute = 0;
- break;
- }
- }
- }
- if (do_compute) {
- // Figure out if we should use the offset/length from the previous pixel
- // as an initial guess and therefore only inspect the offsets in
- // window_offsets_new[].
- const int use_prev =
- (best_length_prev > 1) && (best_length_prev < MAX_LENGTH);
- const int num_ind =
- use_prev ? window_offsets_new_size : window_offsets_size;
- best_length = use_prev ? best_length_prev - 1 : 0;
- best_offset = use_prev ? best_offset_prev : 0;
- // Find the longest match in a window around the pixel.
- for (ind = 0; ind < num_ind; ++ind) {
- int curr_length = 0;
- int j = i;
- int j_offset =
- use_prev ? i - window_offsets_new[ind] : i - window_offsets[ind];
- if (j_offset < 0 || argb[j_offset] != argb[i]) continue;
- // The longest match is the sum of how many times each pixel is
- // repeated.
- do {
- const int counts_j_offset = counts_ini[j_offset];
- const int counts_j = counts_ini[j];
- if (counts_j_offset != counts_j) {
- curr_length +=
- (counts_j_offset < counts_j) ? counts_j_offset : counts_j;
- break;
- }
- // The same color is repeated counts_pos times at j_offset and j.
- curr_length += counts_j_offset;
- j_offset += counts_j_offset;
- j += counts_j_offset;
- } while (curr_length <= MAX_LENGTH && j < pix_count &&
- argb[j_offset] == argb[j]);
- if (best_length < curr_length) {
- best_offset =
- use_prev ? window_offsets_new[ind] : window_offsets[ind];
- if (curr_length >= MAX_LENGTH) {
- best_length = MAX_LENGTH;
- break;
- } else {
- best_length = curr_length;
- }
- }
- }
- }
-
- assert(i + best_length <= pix_count);
- assert(best_length <= MAX_LENGTH);
- if (best_length <= MIN_LENGTH) {
- hash_chain->offset_length_[i] = 0;
- best_offset_prev = 0;
- best_length_prev = 0;
- } else {
- hash_chain->offset_length_[i] =
- (best_offset << MAX_LENGTH_BITS) | (uint32_t)best_length;
- best_offset_prev = best_offset;
- best_length_prev = best_length;
- }
- }
- hash_chain->offset_length_[0] = 0;
- WebPSafeFree(counts_ini);
-
- return BackwardReferencesLz77(xsize, ysize, argb, cache_bits, hash_chain,
- refs);
-}
-
-// -----------------------------------------------------------------------------
-
-static void BackwardReferences2DLocality(int xsize,
- const VP8LBackwardRefs* const refs) {
- VP8LRefsCursor c = VP8LRefsCursorInit(refs);
- while (VP8LRefsCursorOk(&c)) {
- if (PixOrCopyIsCopy(c.cur_pos)) {
- const int dist = c.cur_pos->argb_or_distance;
- const int transformed_dist = VP8LDistanceToPlaneCode(xsize, dist);
- c.cur_pos->argb_or_distance = transformed_dist;
- }
- VP8LRefsCursorNext(&c);
- }
-}
-
-// Evaluate optimal cache bits for the local color cache.
-// The input *best_cache_bits sets the maximum cache bits to use (passing 0
-// implies disabling the local color cache). The local color cache is also
-// disabled for the lower (<= 25) quality.
-// Returns 0 in case of memory error.
-static int CalculateBestCacheSize(const uint32_t* argb, int quality,
- const VP8LBackwardRefs* const refs,
- int* const best_cache_bits) {
- int i;
- const int cache_bits_max = (quality <= 25) ? 0 : *best_cache_bits;
- double entropy_min = MAX_ENTROPY;
- int cc_init[MAX_COLOR_CACHE_BITS + 1] = { 0 };
- VP8LColorCache hashers[MAX_COLOR_CACHE_BITS + 1];
- VP8LRefsCursor c = VP8LRefsCursorInit(refs);
- VP8LHistogram* histos[MAX_COLOR_CACHE_BITS + 1] = { NULL };
- int ok = 0;
-
- assert(cache_bits_max >= 0 && cache_bits_max <= MAX_COLOR_CACHE_BITS);
-
- if (cache_bits_max == 0) {
- *best_cache_bits = 0;
- // Local color cache is disabled.
- return 1;
- }
-
- // Allocate data.
- for (i = 0; i <= cache_bits_max; ++i) {
- histos[i] = VP8LAllocateHistogram(i);
- if (histos[i] == NULL) goto Error;
- VP8LHistogramInit(histos[i], i, /*init_arrays=*/ 1);
- if (i == 0) continue;
- cc_init[i] = VP8LColorCacheInit(&hashers[i], i);
- if (!cc_init[i]) goto Error;
- }
-
- // Find the cache_bits giving the lowest entropy. The search is done in a
- // brute-force way as the function (entropy w.r.t cache_bits) can be
- // anything in practice.
- while (VP8LRefsCursorOk(&c)) {
- const PixOrCopy* const v = c.cur_pos;
- if (PixOrCopyIsLiteral(v)) {
- const uint32_t pix = *argb++;
- const uint32_t a = (pix >> 24) & 0xff;
- const uint32_t r = (pix >> 16) & 0xff;
- const uint32_t g = (pix >> 8) & 0xff;
- const uint32_t b = (pix >> 0) & 0xff;
- // The keys of the caches can be derived from the longest one.
- int key = VP8LHashPix(pix, 32 - cache_bits_max);
- // Do not use the color cache for cache_bits = 0.
- ++histos[0]->blue_[b];
- ++histos[0]->literal_[g];
- ++histos[0]->red_[r];
- ++histos[0]->alpha_[a];
- // Deal with cache_bits > 0.
- for (i = cache_bits_max; i >= 1; --i, key >>= 1) {
- if (VP8LColorCacheLookup(&hashers[i], key) == pix) {
- ++histos[i]->literal_[NUM_LITERAL_CODES + NUM_LENGTH_CODES + key];
- } else {
- VP8LColorCacheSet(&hashers[i], key, pix);
- ++histos[i]->blue_[b];
- ++histos[i]->literal_[g];
- ++histos[i]->red_[r];
- ++histos[i]->alpha_[a];
- }
- }
- } else {
- int code, extra_bits, extra_bits_value;
- // We should compute the contribution of the (distance,length)
- // histograms but those are the same independently from the cache size.
- // As those constant contributions are in the end added to the other
- // histogram contributions, we can ignore them, except for the length
- // prefix that is part of the literal_ histogram.
- int len = PixOrCopyLength(v);
- uint32_t argb_prev = *argb ^ 0xffffffffu;
- VP8LPrefixEncode(len, &code, &extra_bits, &extra_bits_value);
- for (i = 0; i <= cache_bits_max; ++i) {
- ++histos[i]->literal_[NUM_LITERAL_CODES + code];
- }
- // Update the color caches.
- do {
- if (*argb != argb_prev) {
- // Efficiency: insert only if the color changes.
- int key = VP8LHashPix(*argb, 32 - cache_bits_max);
- for (i = cache_bits_max; i >= 1; --i, key >>= 1) {
- hashers[i].colors_[key] = *argb;
- }
- argb_prev = *argb;
- }
- argb++;
- } while (--len != 0);
- }
- VP8LRefsCursorNext(&c);
- }
-
- for (i = 0; i <= cache_bits_max; ++i) {
- const double entropy = VP8LHistogramEstimateBits(histos[i]);
- if (i == 0 || entropy < entropy_min) {
- entropy_min = entropy;
- *best_cache_bits = i;
- }
- }
- ok = 1;
-Error:
- for (i = 0; i <= cache_bits_max; ++i) {
- if (cc_init[i]) VP8LColorCacheClear(&hashers[i]);
- VP8LFreeHistogram(histos[i]);
- }
- return ok;
-}
-
-// Update (in-place) backward references for specified cache_bits.
-static int BackwardRefsWithLocalCache(const uint32_t* const argb,
- int cache_bits,
- VP8LBackwardRefs* const refs) {
- int pixel_index = 0;
- VP8LColorCache hashers;
- VP8LRefsCursor c = VP8LRefsCursorInit(refs);
- if (!VP8LColorCacheInit(&hashers, cache_bits)) return 0;
-
- while (VP8LRefsCursorOk(&c)) {
- PixOrCopy* const v = c.cur_pos;
- if (PixOrCopyIsLiteral(v)) {
- const uint32_t argb_literal = v->argb_or_distance;
- const int ix = VP8LColorCacheContains(&hashers, argb_literal);
- if (ix >= 0) {
- // hashers contains argb_literal
- *v = PixOrCopyCreateCacheIdx(ix);
- } else {
- VP8LColorCacheInsert(&hashers, argb_literal);
- }
- ++pixel_index;
- } else {
- // refs was created without local cache, so it can not have cache indexes.
- int k;
- assert(PixOrCopyIsCopy(v));
- for (k = 0; k < v->len; ++k) {
- VP8LColorCacheInsert(&hashers, argb[pixel_index++]);
- }
- }
- VP8LRefsCursorNext(&c);
- }
- VP8LColorCacheClear(&hashers);
- return 1;
-}
-
-static VP8LBackwardRefs* GetBackwardReferencesLowEffort(
- int width, int height, const uint32_t* const argb,
- int* const cache_bits, const VP8LHashChain* const hash_chain,
- VP8LBackwardRefs* const refs_lz77) {
- *cache_bits = 0;
- if (!BackwardReferencesLz77(width, height, argb, 0, hash_chain, refs_lz77)) {
- return NULL;
- }
- BackwardReferences2DLocality(width, refs_lz77);
- return refs_lz77;
-}
-
-extern int VP8LBackwardReferencesTraceBackwards(
- int xsize, int ysize, const uint32_t* const argb, int cache_bits,
- const VP8LHashChain* const hash_chain,
- const VP8LBackwardRefs* const refs_src, VP8LBackwardRefs* const refs_dst);
-static int GetBackwardReferences(int width, int height,
- const uint32_t* const argb, int quality,
- int lz77_types_to_try, int cache_bits_max,
- int do_no_cache,
- const VP8LHashChain* const hash_chain,
- VP8LBackwardRefs* const refs,
- int* const cache_bits_best) {
- VP8LHistogram* histo = NULL;
- int i, lz77_type;
- // Index 0 is for a color cache, index 1 for no cache (if needed).
- int lz77_types_best[2] = {0, 0};
- double bit_costs_best[2] = {DBL_MAX, DBL_MAX};
- VP8LHashChain hash_chain_box;
- VP8LBackwardRefs* const refs_tmp = &refs[do_no_cache ? 2 : 1];
- int status = 0;
- memset(&hash_chain_box, 0, sizeof(hash_chain_box));
-
- histo = VP8LAllocateHistogram(MAX_COLOR_CACHE_BITS);
- if (histo == NULL) goto Error;
-
- for (lz77_type = 1; lz77_types_to_try;
- lz77_types_to_try &= ~lz77_type, lz77_type <<= 1) {
- int res = 0;
- double bit_cost = 0.;
- if ((lz77_types_to_try & lz77_type) == 0) continue;
- switch (lz77_type) {
- case kLZ77RLE:
- res = BackwardReferencesRle(width, height, argb, 0, refs_tmp);
- break;
- case kLZ77Standard:
- // Compute LZ77 with no cache (0 bits), as the ideal LZ77 with a color
- // cache is not that different in practice.
- res = BackwardReferencesLz77(width, height, argb, 0, hash_chain,
- refs_tmp);
- break;
- case kLZ77Box:
- if (!VP8LHashChainInit(&hash_chain_box, width * height)) goto Error;
- res = BackwardReferencesLz77Box(width, height, argb, 0, hash_chain,
- &hash_chain_box, refs_tmp);
- break;
- default:
- assert(0);
- }
- if (!res) goto Error;
-
- // Start with the no color cache case.
- for (i = 1; i >= 0; --i) {
- int cache_bits = (i == 1) ? 0 : cache_bits_max;
-
- if (i == 1 && !do_no_cache) continue;
-
- if (i == 0) {
- // Try with a color cache.
- if (!CalculateBestCacheSize(argb, quality, refs_tmp, &cache_bits)) {
- goto Error;
- }
- if (cache_bits > 0) {
- if (!BackwardRefsWithLocalCache(argb, cache_bits, refs_tmp)) {
- goto Error;
- }
- }
- }
-
- if (i == 0 && do_no_cache && cache_bits == 0) {
- // No need to re-compute bit_cost as it was computed at i == 1.
- } else {
- VP8LHistogramCreate(histo, refs_tmp, cache_bits);
- bit_cost = VP8LHistogramEstimateBits(histo);
- }
-
- if (bit_cost < bit_costs_best[i]) {
- if (i == 1) {
- // Do not swap as the full cache analysis would have the wrong
- // VP8LBackwardRefs to start with.
- if (!BackwardRefsClone(refs_tmp, &refs[1])) goto Error;
- } else {
- BackwardRefsSwap(refs_tmp, &refs[0]);
- }
- bit_costs_best[i] = bit_cost;
- lz77_types_best[i] = lz77_type;
- if (i == 0) *cache_bits_best = cache_bits;
- }
- }
- }
- assert(lz77_types_best[0] > 0);
- assert(!do_no_cache || lz77_types_best[1] > 0);
-
- // Improve on simple LZ77 but only for high quality (TraceBackwards is
- // costly).
- for (i = 1; i >= 0; --i) {
- if (i == 1 && !do_no_cache) continue;
- if ((lz77_types_best[i] == kLZ77Standard ||
- lz77_types_best[i] == kLZ77Box) &&
- quality >= 25) {
- const VP8LHashChain* const hash_chain_tmp =
- (lz77_types_best[i] == kLZ77Standard) ? hash_chain : &hash_chain_box;
- const int cache_bits = (i == 1) ? 0 : *cache_bits_best;
- if (VP8LBackwardReferencesTraceBackwards(width, height, argb, cache_bits,
- hash_chain_tmp, &refs[i],
- refs_tmp)) {
- double bit_cost_trace;
- VP8LHistogramCreate(histo, refs_tmp, cache_bits);
- bit_cost_trace = VP8LHistogramEstimateBits(histo);
- if (bit_cost_trace < bit_costs_best[i]) {
- BackwardRefsSwap(refs_tmp, &refs[i]);
- }
- }
- }
-
- BackwardReferences2DLocality(width, &refs[i]);
-
- if (i == 1 && lz77_types_best[0] == lz77_types_best[1] &&
- *cache_bits_best == 0) {
- // If the best cache size is 0 and we have the same best LZ77, just copy
- // the data over and stop here.
- if (!BackwardRefsClone(&refs[1], &refs[0])) goto Error;
- break;
- }
- }
- status = 1;
-
-Error:
- VP8LHashChainClear(&hash_chain_box);
- VP8LFreeHistogram(histo);
- return status;
-}
-
-WebPEncodingError VP8LGetBackwardReferences(
- int width, int height, const uint32_t* const argb, int quality,
- int low_effort, int lz77_types_to_try, int cache_bits_max, int do_no_cache,
- const VP8LHashChain* const hash_chain, VP8LBackwardRefs* const refs,
- int* const cache_bits_best) {
- if (low_effort) {
- VP8LBackwardRefs* refs_best;
- *cache_bits_best = cache_bits_max;
- refs_best = GetBackwardReferencesLowEffort(
- width, height, argb, cache_bits_best, hash_chain, refs);
- if (refs_best == NULL) return VP8_ENC_ERROR_OUT_OF_MEMORY;
- // Set it in first position.
- BackwardRefsSwap(refs_best, &refs[0]);
- } else {
- if (!GetBackwardReferences(width, height, argb, quality, lz77_types_to_try,
- cache_bits_max, do_no_cache, hash_chain, refs,
- cache_bits_best)) {
- return VP8_ENC_ERROR_OUT_OF_MEMORY;
- }
- }
- return VP8_ENC_OK;
-}
diff --git a/contrib/libs/libwebp/enc/backward_references_enc.h b/contrib/libs/libwebp/enc/backward_references_enc.h
deleted file mode 100644
index 292c630e5e..0000000000
--- a/contrib/libs/libwebp/enc/backward_references_enc.h
+++ /dev/null
@@ -1,240 +0,0 @@
-// Copyright 2012 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Author: Jyrki Alakuijala (jyrki@google.com)
-//
-
-#ifndef WEBP_ENC_BACKWARD_REFERENCES_ENC_H_
-#define WEBP_ENC_BACKWARD_REFERENCES_ENC_H_
-
-#include <assert.h>
-#include <stdlib.h>
-#include "../webp/types.h"
-#include "../webp/encode.h"
-#include "../webp/format_constants.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// The maximum allowed limit is 11.
-#define MAX_COLOR_CACHE_BITS 10
-
-// -----------------------------------------------------------------------------
-// PixOrCopy
-
-enum Mode {
- kLiteral,
- kCacheIdx,
- kCopy,
- kNone
-};
-
-typedef struct {
- // mode as uint8_t to make the memory layout to be exactly 8 bytes.
- uint8_t mode;
- uint16_t len;
- uint32_t argb_or_distance;
-} PixOrCopy;
-
-static WEBP_INLINE PixOrCopy PixOrCopyCreateCopy(uint32_t distance,
- uint16_t len) {
- PixOrCopy retval;
- retval.mode = kCopy;
- retval.argb_or_distance = distance;
- retval.len = len;
- return retval;
-}
-
-static WEBP_INLINE PixOrCopy PixOrCopyCreateCacheIdx(int idx) {
- PixOrCopy retval;
- assert(idx >= 0);
- assert(idx < (1 << MAX_COLOR_CACHE_BITS));
- retval.mode = kCacheIdx;
- retval.argb_or_distance = idx;
- retval.len = 1;
- return retval;
-}
-
-static WEBP_INLINE PixOrCopy PixOrCopyCreateLiteral(uint32_t argb) {
- PixOrCopy retval;
- retval.mode = kLiteral;
- retval.argb_or_distance = argb;
- retval.len = 1;
- return retval;
-}
-
-static WEBP_INLINE int PixOrCopyIsLiteral(const PixOrCopy* const p) {
- return (p->mode == kLiteral);
-}
-
-static WEBP_INLINE int PixOrCopyIsCacheIdx(const PixOrCopy* const p) {
- return (p->mode == kCacheIdx);
-}
-
-static WEBP_INLINE int PixOrCopyIsCopy(const PixOrCopy* const p) {
- return (p->mode == kCopy);
-}
-
-static WEBP_INLINE uint32_t PixOrCopyLiteral(const PixOrCopy* const p,
- int component) {
- assert(p->mode == kLiteral);
- return (p->argb_or_distance >> (component * 8)) & 0xff;
-}
-
-static WEBP_INLINE uint32_t PixOrCopyLength(const PixOrCopy* const p) {
- return p->len;
-}
-
-static WEBP_INLINE uint32_t PixOrCopyCacheIdx(const PixOrCopy* const p) {
- assert(p->mode == kCacheIdx);
- assert(p->argb_or_distance < (1U << MAX_COLOR_CACHE_BITS));
- return p->argb_or_distance;
-}
-
-static WEBP_INLINE uint32_t PixOrCopyDistance(const PixOrCopy* const p) {
- assert(p->mode == kCopy);
- return p->argb_or_distance;
-}
-
-// -----------------------------------------------------------------------------
-// VP8LHashChain
-
-#define HASH_BITS 18
-#define HASH_SIZE (1 << HASH_BITS)
-
-// If you change this, you need MAX_LENGTH_BITS + WINDOW_SIZE_BITS <= 32 as it
-// is used in VP8LHashChain.
-#define MAX_LENGTH_BITS 12
-#define WINDOW_SIZE_BITS 20
-// We want the max value to be attainable and stored in MAX_LENGTH_BITS bits.
-#define MAX_LENGTH ((1 << MAX_LENGTH_BITS) - 1)
-#if MAX_LENGTH_BITS + WINDOW_SIZE_BITS > 32
-#error "MAX_LENGTH_BITS + WINDOW_SIZE_BITS > 32"
-#endif
-
-typedef struct VP8LHashChain VP8LHashChain;
-struct VP8LHashChain {
- // The 20 most significant bits contain the offset at which the best match
- // is found. These 20 bits are the limit defined by GetWindowSizeForHashChain
- // (through WINDOW_SIZE = 1<<20).
- // The lower 12 bits contain the length of the match. The 12 bit limit is
- // defined in MaxFindCopyLength with MAX_LENGTH=4096.
- uint32_t* offset_length_;
- // This is the maximum size of the hash_chain that can be constructed.
- // Typically this is the pixel count (width x height) for a given image.
- int size_;
-};
-
-// Must be called first, to set size.
-int VP8LHashChainInit(VP8LHashChain* const p, int size);
-// Pre-compute the best matches for argb.
-int VP8LHashChainFill(VP8LHashChain* const p, int quality,
- const uint32_t* const argb, int xsize, int ysize,
- int low_effort);
-void VP8LHashChainClear(VP8LHashChain* const p); // release memory
-
-static WEBP_INLINE int VP8LHashChainFindOffset(const VP8LHashChain* const p,
- const int base_position) {
- return p->offset_length_[base_position] >> MAX_LENGTH_BITS;
-}
-
-static WEBP_INLINE int VP8LHashChainFindLength(const VP8LHashChain* const p,
- const int base_position) {
- return p->offset_length_[base_position] & ((1U << MAX_LENGTH_BITS) - 1);
-}
-
-static WEBP_INLINE void VP8LHashChainFindCopy(const VP8LHashChain* const p,
- int base_position,
- int* const offset_ptr,
- int* const length_ptr) {
- *offset_ptr = VP8LHashChainFindOffset(p, base_position);
- *length_ptr = VP8LHashChainFindLength(p, base_position);
-}
-
-// -----------------------------------------------------------------------------
-// VP8LBackwardRefs (block-based backward-references storage)
-
-// maximum number of reference blocks the image will be segmented into
-#define MAX_REFS_BLOCK_PER_IMAGE 16
-
-typedef struct PixOrCopyBlock PixOrCopyBlock; // forward declaration
-typedef struct VP8LBackwardRefs VP8LBackwardRefs;
-
-// Container for blocks chain
-struct VP8LBackwardRefs {
- int block_size_; // common block-size
- int error_; // set to true if some memory error occurred
- PixOrCopyBlock* refs_; // list of currently used blocks
- PixOrCopyBlock** tail_; // for list recycling
- PixOrCopyBlock* free_blocks_; // free-list
- PixOrCopyBlock* last_block_; // used for adding new refs (internal)
-};
-
-// Initialize the object. 'block_size' is the common block size to store
-// references (typically, width * height / MAX_REFS_BLOCK_PER_IMAGE).
-void VP8LBackwardRefsInit(VP8LBackwardRefs* const refs, int block_size);
-// Release memory for backward references.
-void VP8LBackwardRefsClear(VP8LBackwardRefs* const refs);
-
-// Cursor for iterating on references content
-typedef struct {
- // public:
- PixOrCopy* cur_pos; // current position
- // private:
- PixOrCopyBlock* cur_block_; // current block in the refs list
- const PixOrCopy* last_pos_; // sentinel for switching to next block
-} VP8LRefsCursor;
-
-// Returns a cursor positioned at the beginning of the references list.
-VP8LRefsCursor VP8LRefsCursorInit(const VP8LBackwardRefs* const refs);
-// Returns true if cursor is pointing at a valid position.
-static WEBP_INLINE int VP8LRefsCursorOk(const VP8LRefsCursor* const c) {
- return (c->cur_pos != NULL);
-}
-// Move to next block of references. Internal, not to be called directly.
-void VP8LRefsCursorNextBlock(VP8LRefsCursor* const c);
-// Move to next position, or NULL. Should not be called if !VP8LRefsCursorOk().
-static WEBP_INLINE void VP8LRefsCursorNext(VP8LRefsCursor* const c) {
- assert(c != NULL);
- assert(VP8LRefsCursorOk(c));
- if (++c->cur_pos == c->last_pos_) VP8LRefsCursorNextBlock(c);
-}
-
-// -----------------------------------------------------------------------------
-// Main entry points
-
-enum VP8LLZ77Type {
- kLZ77Standard = 1,
- kLZ77RLE = 2,
- kLZ77Box = 4
-};
-
-// Evaluates best possible backward references for specified quality.
-// The input cache_bits to 'VP8LGetBackwardReferences' sets the maximum cache
-// bits to use (passing 0 implies disabling the local color cache).
-// The optimal cache bits is evaluated and set for the *cache_bits_best
-// parameter with the matching refs_best.
-// If do_no_cache == 0, refs is an array of 2 values and the best
-// VP8LBackwardRefs is put in the first element.
-// If do_no_cache != 0, refs is an array of 3 values and the best
-// VP8LBackwardRefs is put in the first element, the best value with no-cache in
-// the second element.
-// In both cases, the last element is used as temporary internally.
-WebPEncodingError VP8LGetBackwardReferences(
- int width, int height, const uint32_t* const argb, int quality,
- int low_effort, int lz77_types_to_try, int cache_bits_max, int do_no_cache,
- const VP8LHashChain* const hash_chain, VP8LBackwardRefs* const refs,
- int* const cache_bits_best);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // WEBP_ENC_BACKWARD_REFERENCES_ENC_H_
diff --git a/contrib/libs/libwebp/enc/config_enc.c b/contrib/libs/libwebp/enc/config_enc.c
deleted file mode 100644
index 97df32d0d4..0000000000
--- a/contrib/libs/libwebp/enc/config_enc.c
+++ /dev/null
@@ -1,157 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Coding tools configuration
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#ifdef HAVE_CONFIG_H
-#include "../webp/config.h"
-#endif
-
-#include "../webp/encode.h"
-
-//------------------------------------------------------------------------------
-// WebPConfig
-//------------------------------------------------------------------------------
-
-int WebPConfigInitInternal(WebPConfig* config,
- WebPPreset preset, float quality, int version) {
- if (WEBP_ABI_IS_INCOMPATIBLE(version, WEBP_ENCODER_ABI_VERSION)) {
- return 0; // caller/system version mismatch!
- }
- if (config == NULL) return 0;
-
- config->quality = quality;
- config->target_size = 0;
- config->target_PSNR = 0.;
- config->method = 4;
- config->sns_strength = 50;
- config->filter_strength = 60; // mid-filtering
- config->filter_sharpness = 0;
- config->filter_type = 1; // default: strong (so U/V is filtered too)
- config->partitions = 0;
- config->segments = 4;
- config->pass = 1;
- config->qmin = 0;
- config->qmax = 100;
- config->show_compressed = 0;
- config->preprocessing = 0;
- config->autofilter = 0;
- config->partition_limit = 0;
- config->alpha_compression = 1;
- config->alpha_filtering = 1;
- config->alpha_quality = 100;
- config->lossless = 0;
- config->exact = 0;
- config->image_hint = WEBP_HINT_DEFAULT;
- config->emulate_jpeg_size = 0;
- config->thread_level = 0;
- config->low_memory = 0;
- config->near_lossless = 100;
- config->use_delta_palette = 0;
- config->use_sharp_yuv = 0;
-
- // TODO(skal): tune.
- switch (preset) {
- case WEBP_PRESET_PICTURE:
- config->sns_strength = 80;
- config->filter_sharpness = 4;
- config->filter_strength = 35;
- config->preprocessing &= ~2; // no dithering
- break;
- case WEBP_PRESET_PHOTO:
- config->sns_strength = 80;
- config->filter_sharpness = 3;
- config->filter_strength = 30;
- config->preprocessing |= 2;
- break;
- case WEBP_PRESET_DRAWING:
- config->sns_strength = 25;
- config->filter_sharpness = 6;
- config->filter_strength = 10;
- break;
- case WEBP_PRESET_ICON:
- config->sns_strength = 0;
- config->filter_strength = 0; // disable filtering to retain sharpness
- config->preprocessing &= ~2; // no dithering
- break;
- case WEBP_PRESET_TEXT:
- config->sns_strength = 0;
- config->filter_strength = 0; // disable filtering to retain sharpness
- config->preprocessing &= ~2; // no dithering
- config->segments = 2;
- break;
- case WEBP_PRESET_DEFAULT:
- default:
- break;
- }
- return WebPValidateConfig(config);
-}
-
-int WebPValidateConfig(const WebPConfig* config) {
- if (config == NULL) return 0;
- if (config->quality < 0 || config->quality > 100) return 0;
- if (config->target_size < 0) return 0;
- if (config->target_PSNR < 0) return 0;
- if (config->method < 0 || config->method > 6) return 0;
- if (config->segments < 1 || config->segments > 4) return 0;
- if (config->sns_strength < 0 || config->sns_strength > 100) return 0;
- if (config->filter_strength < 0 || config->filter_strength > 100) return 0;
- if (config->filter_sharpness < 0 || config->filter_sharpness > 7) return 0;
- if (config->filter_type < 0 || config->filter_type > 1) return 0;
- if (config->autofilter < 0 || config->autofilter > 1) return 0;
- if (config->pass < 1 || config->pass > 10) return 0;
- if (config->qmin < 0 || config->qmax > 100 || config->qmin > config->qmax) {
- return 0;
- }
- if (config->show_compressed < 0 || config->show_compressed > 1) return 0;
- if (config->preprocessing < 0 || config->preprocessing > 7) return 0;
- if (config->partitions < 0 || config->partitions > 3) return 0;
- if (config->partition_limit < 0 || config->partition_limit > 100) return 0;
- if (config->alpha_compression < 0) return 0;
- if (config->alpha_filtering < 0) return 0;
- if (config->alpha_quality < 0 || config->alpha_quality > 100) return 0;
- if (config->lossless < 0 || config->lossless > 1) return 0;
- if (config->near_lossless < 0 || config->near_lossless > 100) return 0;
- if (config->image_hint >= WEBP_HINT_LAST) return 0;
- if (config->emulate_jpeg_size < 0 || config->emulate_jpeg_size > 1) return 0;
- if (config->thread_level < 0 || config->thread_level > 1) return 0;
- if (config->low_memory < 0 || config->low_memory > 1) return 0;
- if (config->exact < 0 || config->exact > 1) return 0;
- if (config->use_delta_palette < 0 || config->use_delta_palette > 1) {
- return 0;
- }
- if (config->use_sharp_yuv < 0 || config->use_sharp_yuv > 1) return 0;
-
- return 1;
-}
-
-//------------------------------------------------------------------------------
-
-#define MAX_LEVEL 9
-
-// Mapping between -z level and -m / -q parameter settings.
-static const struct {
- uint8_t method_;
- uint8_t quality_;
-} kLosslessPresets[MAX_LEVEL + 1] = {
- { 0, 0 }, { 1, 20 }, { 2, 25 }, { 3, 30 }, { 3, 50 },
- { 4, 50 }, { 4, 75 }, { 4, 90 }, { 5, 90 }, { 6, 100 }
-};
-
-int WebPConfigLosslessPreset(WebPConfig* config, int level) {
- if (config == NULL || level < 0 || level > MAX_LEVEL) return 0;
- config->lossless = 1;
- config->method = kLosslessPresets[level].method_;
- config->quality = kLosslessPresets[level].quality_;
- return 1;
-}
-
-//------------------------------------------------------------------------------
diff --git a/contrib/libs/libwebp/enc/cost_enc.c b/contrib/libs/libwebp/enc/cost_enc.c
deleted file mode 100644
index c823f5a664..0000000000
--- a/contrib/libs/libwebp/enc/cost_enc.c
+++ /dev/null
@@ -1,342 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Cost tables for level and modes
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include "./cost_enc.h"
-
-//------------------------------------------------------------------------------
-// Level cost tables
-
-// For each given level, the following table gives the pattern of contexts to
-// use for coding it (in [][0]) as well as the bit value to use for each
-// context (in [][1]).
-const uint16_t VP8LevelCodes[MAX_VARIABLE_LEVEL][2] = {
- {0x001, 0x000}, {0x007, 0x001}, {0x00f, 0x005},
- {0x00f, 0x00d}, {0x033, 0x003}, {0x033, 0x003}, {0x033, 0x023},
- {0x033, 0x023}, {0x033, 0x023}, {0x033, 0x023}, {0x0d3, 0x013},
- {0x0d3, 0x013}, {0x0d3, 0x013}, {0x0d3, 0x013}, {0x0d3, 0x013},
- {0x0d3, 0x013}, {0x0d3, 0x013}, {0x0d3, 0x013}, {0x0d3, 0x093},
- {0x0d3, 0x093}, {0x0d3, 0x093}, {0x0d3, 0x093}, {0x0d3, 0x093},
- {0x0d3, 0x093}, {0x0d3, 0x093}, {0x0d3, 0x093}, {0x0d3, 0x093},
- {0x0d3, 0x093}, {0x0d3, 0x093}, {0x0d3, 0x093}, {0x0d3, 0x093},
- {0x0d3, 0x093}, {0x0d3, 0x093}, {0x0d3, 0x093}, {0x153, 0x053},
- {0x153, 0x053}, {0x153, 0x053}, {0x153, 0x053}, {0x153, 0x053},
- {0x153, 0x053}, {0x153, 0x053}, {0x153, 0x053}, {0x153, 0x053},
- {0x153, 0x053}, {0x153, 0x053}, {0x153, 0x053}, {0x153, 0x053},
- {0x153, 0x053}, {0x153, 0x053}, {0x153, 0x053}, {0x153, 0x053},
- {0x153, 0x053}, {0x153, 0x053}, {0x153, 0x053}, {0x153, 0x053},
- {0x153, 0x053}, {0x153, 0x053}, {0x153, 0x053}, {0x153, 0x053},
- {0x153, 0x053}, {0x153, 0x053}, {0x153, 0x053}, {0x153, 0x053},
- {0x153, 0x053}, {0x153, 0x053}, {0x153, 0x053}, {0x153, 0x153}
-};
-
-static int VariableLevelCost(int level, const uint8_t probas[NUM_PROBAS]) {
- int pattern = VP8LevelCodes[level - 1][0];
- int bits = VP8LevelCodes[level - 1][1];
- int cost = 0;
- int i;
- for (i = 2; pattern; ++i) {
- if (pattern & 1) {
- cost += VP8BitCost(bits & 1, probas[i]);
- }
- bits >>= 1;
- pattern >>= 1;
- }
- return cost;
-}
-
-//------------------------------------------------------------------------------
-// Pre-calc level costs once for all
-
-void VP8CalculateLevelCosts(VP8EncProba* const proba) {
- int ctype, band, ctx;
-
- if (!proba->dirty_) return; // nothing to do.
-
- for (ctype = 0; ctype < NUM_TYPES; ++ctype) {
- int n;
- for (band = 0; band < NUM_BANDS; ++band) {
- for (ctx = 0; ctx < NUM_CTX; ++ctx) {
- const uint8_t* const p = proba->coeffs_[ctype][band][ctx];
- uint16_t* const table = proba->level_cost_[ctype][band][ctx];
- const int cost0 = (ctx > 0) ? VP8BitCost(1, p[0]) : 0;
- const int cost_base = VP8BitCost(1, p[1]) + cost0;
- int v;
- table[0] = VP8BitCost(0, p[1]) + cost0;
- for (v = 1; v <= MAX_VARIABLE_LEVEL; ++v) {
- table[v] = cost_base + VariableLevelCost(v, p);
- }
- // Starting at level 67 and up, the variable part of the cost is
- // actually constant.
- }
- }
- for (n = 0; n < 16; ++n) { // replicate bands. We don't need to sentinel.
- for (ctx = 0; ctx < NUM_CTX; ++ctx) {
- proba->remapped_costs_[ctype][n][ctx] =
- proba->level_cost_[ctype][VP8EncBands[n]][ctx];
- }
- }
- }
- proba->dirty_ = 0;
-}
-
-//------------------------------------------------------------------------------
-// Mode cost tables.
-
-// These are the fixed probabilities (in the coding trees) turned into bit-cost
-// by calling VP8BitCost().
-const uint16_t VP8FixedCostsUV[4] = { 302, 984, 439, 642 };
-// note: these values include the fixed VP8BitCost(1, 145) mode selection cost.
-const uint16_t VP8FixedCostsI16[4] = { 663, 919, 872, 919 };
-const uint16_t VP8FixedCostsI4[NUM_BMODES][NUM_BMODES][NUM_BMODES] = {
- { { 40, 1151, 1723, 1874, 2103, 2019, 1628, 1777, 2226, 2137 },
- { 192, 469, 1296, 1308, 1849, 1794, 1781, 1703, 1713, 1522 },
- { 142, 910, 762, 1684, 1849, 1576, 1460, 1305, 1801, 1657 },
- { 559, 641, 1370, 421, 1182, 1569, 1612, 1725, 863, 1007 },
- { 299, 1059, 1256, 1108, 636, 1068, 1581, 1883, 869, 1142 },
- { 277, 1111, 707, 1362, 1089, 672, 1603, 1541, 1545, 1291 },
- { 214, 781, 1609, 1303, 1632, 2229, 726, 1560, 1713, 918 },
- { 152, 1037, 1046, 1759, 1983, 2174, 1358, 742, 1740, 1390 },
- { 512, 1046, 1420, 753, 752, 1297, 1486, 1613, 460, 1207 },
- { 424, 827, 1362, 719, 1462, 1202, 1199, 1476, 1199, 538 } },
- { { 240, 402, 1134, 1491, 1659, 1505, 1517, 1555, 1979, 2099 },
- { 467, 242, 960, 1232, 1714, 1620, 1834, 1570, 1676, 1391 },
- { 500, 455, 463, 1507, 1699, 1282, 1564, 982, 2114, 2114 },
- { 672, 643, 1372, 331, 1589, 1667, 1453, 1938, 996, 876 },
- { 458, 783, 1037, 911, 738, 968, 1165, 1518, 859, 1033 },
- { 504, 815, 504, 1139, 1219, 719, 1506, 1085, 1268, 1268 },
- { 333, 630, 1445, 1239, 1883, 3672, 799, 1548, 1865, 598 },
- { 399, 644, 746, 1342, 1856, 1350, 1493, 613, 1855, 1015 },
- { 622, 749, 1205, 608, 1066, 1408, 1290, 1406, 546, 971 },
- { 500, 753, 1041, 668, 1230, 1617, 1297, 1425, 1383, 523 } },
- { { 394, 553, 523, 1502, 1536, 981, 1608, 1142, 1666, 2181 },
- { 655, 430, 375, 1411, 1861, 1220, 1677, 1135, 1978, 1553 },
- { 690, 640, 245, 1954, 2070, 1194, 1528, 982, 1972, 2232 },
- { 559, 834, 741, 867, 1131, 980, 1225, 852, 1092, 784 },
- { 690, 875, 516, 959, 673, 894, 1056, 1190, 1528, 1126 },
- { 740, 951, 384, 1277, 1177, 492, 1579, 1155, 1846, 1513 },
- { 323, 775, 1062, 1776, 3062, 1274, 813, 1188, 1372, 655 },
- { 488, 971, 484, 1767, 1515, 1775, 1115, 503, 1539, 1461 },
- { 740, 1006, 998, 709, 851, 1230, 1337, 788, 741, 721 },
- { 522, 1073, 573, 1045, 1346, 887, 1046, 1146, 1203, 697 } },
- { { 105, 864, 1442, 1009, 1934, 1840, 1519, 1920, 1673, 1579 },
- { 534, 305, 1193, 683, 1388, 2164, 1802, 1894, 1264, 1170 },
- { 305, 518, 877, 1108, 1426, 3215, 1425, 1064, 1320, 1242 },
- { 683, 732, 1927, 257, 1493, 2048, 1858, 1552, 1055, 947 },
- { 394, 814, 1024, 660, 959, 1556, 1282, 1289, 893, 1047 },
- { 528, 615, 996, 940, 1201, 635, 1094, 2515, 803, 1358 },
- { 347, 614, 1609, 1187, 3133, 1345, 1007, 1339, 1017, 667 },
- { 218, 740, 878, 1605, 3650, 3650, 1345, 758, 1357, 1617 },
- { 672, 750, 1541, 558, 1257, 1599, 1870, 2135, 402, 1087 },
- { 592, 684, 1161, 430, 1092, 1497, 1475, 1489, 1095, 822 } },
- { { 228, 1056, 1059, 1368, 752, 982, 1512, 1518, 987, 1782 },
- { 494, 514, 818, 942, 965, 892, 1610, 1356, 1048, 1363 },
- { 512, 648, 591, 1042, 761, 991, 1196, 1454, 1309, 1463 },
- { 683, 749, 1043, 676, 841, 1396, 1133, 1138, 654, 939 },
- { 622, 1101, 1126, 994, 361, 1077, 1203, 1318, 877, 1219 },
- { 631, 1068, 857, 1650, 651, 477, 1650, 1419, 828, 1170 },
- { 555, 727, 1068, 1335, 3127, 1339, 820, 1331, 1077, 429 },
- { 504, 879, 624, 1398, 889, 889, 1392, 808, 891, 1406 },
- { 683, 1602, 1289, 977, 578, 983, 1280, 1708, 406, 1122 },
- { 399, 865, 1433, 1070, 1072, 764, 968, 1477, 1223, 678 } },
- { { 333, 760, 935, 1638, 1010, 529, 1646, 1410, 1472, 2219 },
- { 512, 494, 750, 1160, 1215, 610, 1870, 1868, 1628, 1169 },
- { 572, 646, 492, 1934, 1208, 603, 1580, 1099, 1398, 1995 },
- { 786, 789, 942, 581, 1018, 951, 1599, 1207, 731, 768 },
- { 690, 1015, 672, 1078, 582, 504, 1693, 1438, 1108, 2897 },
- { 768, 1267, 571, 2005, 1243, 244, 2881, 1380, 1786, 1453 },
- { 452, 899, 1293, 903, 1311, 3100, 465, 1311, 1319, 813 },
- { 394, 927, 942, 1103, 1358, 1104, 946, 593, 1363, 1109 },
- { 559, 1005, 1007, 1016, 658, 1173, 1021, 1164, 623, 1028 },
- { 564, 796, 632, 1005, 1014, 863, 2316, 1268, 938, 764 } },
- { { 266, 606, 1098, 1228, 1497, 1243, 948, 1030, 1734, 1461 },
- { 366, 585, 901, 1060, 1407, 1247, 876, 1134, 1620, 1054 },
- { 452, 565, 542, 1729, 1479, 1479, 1016, 886, 2938, 1150 },
- { 555, 1088, 1533, 950, 1354, 895, 834, 1019, 1021, 496 },
- { 704, 815, 1193, 971, 973, 640, 1217, 2214, 832, 578 },
- { 672, 1245, 579, 871, 875, 774, 872, 1273, 1027, 949 },
- { 296, 1134, 2050, 1784, 1636, 3425, 442, 1550, 2076, 722 },
- { 342, 982, 1259, 1846, 1848, 1848, 622, 568, 1847, 1052 },
- { 555, 1064, 1304, 828, 746, 1343, 1075, 1329, 1078, 494 },
- { 288, 1167, 1285, 1174, 1639, 1639, 833, 2254, 1304, 509 } },
- { { 342, 719, 767, 1866, 1757, 1270, 1246, 550, 1746, 2151 },
- { 483, 653, 694, 1509, 1459, 1410, 1218, 507, 1914, 1266 },
- { 488, 757, 447, 2979, 1813, 1268, 1654, 539, 1849, 2109 },
- { 522, 1097, 1085, 851, 1365, 1111, 851, 901, 961, 605 },
- { 709, 716, 841, 728, 736, 945, 941, 862, 2845, 1057 },
- { 512, 1323, 500, 1336, 1083, 681, 1342, 717, 1604, 1350 },
- { 452, 1155, 1372, 1900, 1501, 3290, 311, 944, 1919, 922 },
- { 403, 1520, 977, 2132, 1733, 3522, 1076, 276, 3335, 1547 },
- { 559, 1374, 1101, 615, 673, 2462, 974, 795, 984, 984 },
- { 547, 1122, 1062, 812, 1410, 951, 1140, 622, 1268, 651 } },
- { { 165, 982, 1235, 938, 1334, 1366, 1659, 1578, 964, 1612 },
- { 592, 422, 925, 847, 1139, 1112, 1387, 2036, 861, 1041 },
- { 403, 837, 732, 770, 941, 1658, 1250, 809, 1407, 1407 },
- { 896, 874, 1071, 381, 1568, 1722, 1437, 2192, 480, 1035 },
- { 640, 1098, 1012, 1032, 684, 1382, 1581, 2106, 416, 865 },
- { 559, 1005, 819, 914, 710, 770, 1418, 920, 838, 1435 },
- { 415, 1258, 1245, 870, 1278, 3067, 770, 1021, 1287, 522 },
- { 406, 990, 601, 1009, 1265, 1265, 1267, 759, 1017, 1277 },
- { 968, 1182, 1329, 788, 1032, 1292, 1705, 1714, 203, 1403 },
- { 732, 877, 1279, 471, 901, 1161, 1545, 1294, 755, 755 } },
- { { 111, 931, 1378, 1185, 1933, 1648, 1148, 1714, 1873, 1307 },
- { 406, 414, 1030, 1023, 1910, 1404, 1313, 1647, 1509, 793 },
- { 342, 640, 575, 1088, 1241, 1349, 1161, 1350, 1756, 1502 },
- { 559, 766, 1185, 357, 1682, 1428, 1329, 1897, 1219, 802 },
- { 473, 909, 1164, 771, 719, 2508, 1427, 1432, 722, 782 },
- { 342, 892, 785, 1145, 1150, 794, 1296, 1550, 973, 1057 },
- { 208, 1036, 1326, 1343, 1606, 3395, 815, 1455, 1618, 712 },
- { 228, 928, 890, 1046, 3499, 1711, 994, 829, 1720, 1318 },
- { 768, 724, 1058, 636, 991, 1075, 1319, 1324, 616, 825 },
- { 305, 1167, 1358, 899, 1587, 1587, 987, 1988, 1332, 501 } }
-};
-
-//------------------------------------------------------------------------------
-// helper functions for residuals struct VP8Residual.
-
-void VP8InitResidual(int first, int coeff_type,
- VP8Encoder* const enc, VP8Residual* const res) {
- res->coeff_type = coeff_type;
- res->prob = enc->proba_.coeffs_[coeff_type];
- res->stats = enc->proba_.stats_[coeff_type];
- res->costs = enc->proba_.remapped_costs_[coeff_type];
- res->first = first;
-}
-
-//------------------------------------------------------------------------------
-// Mode costs
-
-int VP8GetCostLuma4(VP8EncIterator* const it, const int16_t levels[16]) {
- const int x = (it->i4_ & 3), y = (it->i4_ >> 2);
- VP8Residual res;
- VP8Encoder* const enc = it->enc_;
- int R = 0;
- int ctx;
-
- VP8InitResidual(0, 3, enc, &res);
- ctx = it->top_nz_[x] + it->left_nz_[y];
- VP8SetResidualCoeffs(levels, &res);
- R += VP8GetResidualCost(ctx, &res);
- return R;
-}
-
-int VP8GetCostLuma16(VP8EncIterator* const it, const VP8ModeScore* const rd) {
- VP8Residual res;
- VP8Encoder* const enc = it->enc_;
- int x, y;
- int R = 0;
-
- VP8IteratorNzToBytes(it); // re-import the non-zero context
-
- // DC
- VP8InitResidual(0, 1, enc, &res);
- VP8SetResidualCoeffs(rd->y_dc_levels, &res);
- R += VP8GetResidualCost(it->top_nz_[8] + it->left_nz_[8], &res);
-
- // AC
- VP8InitResidual(1, 0, enc, &res);
- for (y = 0; y < 4; ++y) {
- for (x = 0; x < 4; ++x) {
- const int ctx = it->top_nz_[x] + it->left_nz_[y];
- VP8SetResidualCoeffs(rd->y_ac_levels[x + y * 4], &res);
- R += VP8GetResidualCost(ctx, &res);
- it->top_nz_[x] = it->left_nz_[y] = (res.last >= 0);
- }
- }
- return R;
-}
-
-int VP8GetCostUV(VP8EncIterator* const it, const VP8ModeScore* const rd) {
- VP8Residual res;
- VP8Encoder* const enc = it->enc_;
- int ch, x, y;
- int R = 0;
-
- VP8IteratorNzToBytes(it); // re-import the non-zero context
-
- VP8InitResidual(0, 2, enc, &res);
- for (ch = 0; ch <= 2; ch += 2) {
- for (y = 0; y < 2; ++y) {
- for (x = 0; x < 2; ++x) {
- const int ctx = it->top_nz_[4 + ch + x] + it->left_nz_[4 + ch + y];
- VP8SetResidualCoeffs(rd->uv_levels[ch * 2 + x + y * 2], &res);
- R += VP8GetResidualCost(ctx, &res);
- it->top_nz_[4 + ch + x] = it->left_nz_[4 + ch + y] = (res.last >= 0);
- }
- }
- }
- return R;
-}
-
-
-//------------------------------------------------------------------------------
-// Recording of token probabilities.
-
-// We keep the table-free variant around for reference, in case.
-#define USE_LEVEL_CODE_TABLE
-
-// Simulate block coding, but only record statistics.
-// Note: no need to record the fixed probas.
-int VP8RecordCoeffs(int ctx, const VP8Residual* const res) {
- int n = res->first;
- // should be stats[VP8EncBands[n]], but it's equivalent for n=0 or 1
- proba_t* s = res->stats[n][ctx];
- if (res->last < 0) {
- VP8RecordStats(0, s + 0);
- return 0;
- }
- while (n <= res->last) {
- int v;
- VP8RecordStats(1, s + 0); // order of record doesn't matter
- while ((v = res->coeffs[n++]) == 0) {
- VP8RecordStats(0, s + 1);
- s = res->stats[VP8EncBands[n]][0];
- }
- VP8RecordStats(1, s + 1);
- if (!VP8RecordStats(2u < (unsigned int)(v + 1), s + 2)) { // v = -1 or 1
- s = res->stats[VP8EncBands[n]][1];
- } else {
- v = abs(v);
-#if !defined(USE_LEVEL_CODE_TABLE)
- if (!VP8RecordStats(v > 4, s + 3)) {
- if (VP8RecordStats(v != 2, s + 4))
- VP8RecordStats(v == 4, s + 5);
- } else if (!VP8RecordStats(v > 10, s + 6)) {
- VP8RecordStats(v > 6, s + 7);
- } else if (!VP8RecordStats((v >= 3 + (8 << 2)), s + 8)) {
- VP8RecordStats((v >= 3 + (8 << 1)), s + 9);
- } else {
- VP8RecordStats((v >= 3 + (8 << 3)), s + 10);
- }
-#else
- if (v > MAX_VARIABLE_LEVEL) {
- v = MAX_VARIABLE_LEVEL;
- }
-
- {
- const int bits = VP8LevelCodes[v - 1][1];
- int pattern = VP8LevelCodes[v - 1][0];
- int i;
- for (i = 0; (pattern >>= 1) != 0; ++i) {
- const int mask = 2 << i;
- if (pattern & 1) VP8RecordStats(!!(bits & mask), s + 3 + i);
- }
- }
-#endif
- s = res->stats[VP8EncBands[n]][2];
- }
- }
- if (n < 16) VP8RecordStats(0, s + 0);
- return 1;
-}
-
-//------------------------------------------------------------------------------
diff --git a/contrib/libs/libwebp/enc/cost_enc.h b/contrib/libs/libwebp/enc/cost_enc.h
deleted file mode 100644
index 8fd0466001..0000000000
--- a/contrib/libs/libwebp/enc/cost_enc.h
+++ /dev/null
@@ -1,82 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Cost tables for level and modes.
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#ifndef WEBP_ENC_COST_ENC_H_
-#define WEBP_ENC_COST_ENC_H_
-
-#include <assert.h>
-#include <stdlib.h>
-#include "./vp8i_enc.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// On-the-fly info about the current set of residuals. Handy to avoid
-// passing zillions of params.
-typedef struct VP8Residual VP8Residual;
-struct VP8Residual {
- int first;
- int last;
- const int16_t* coeffs;
-
- int coeff_type;
- ProbaArray* prob;
- StatsArray* stats;
- CostArrayPtr costs;
-};
-
-void VP8InitResidual(int first, int coeff_type,
- VP8Encoder* const enc, VP8Residual* const res);
-
-int VP8RecordCoeffs(int ctx, const VP8Residual* const res);
-
-// Record proba context used.
-static WEBP_INLINE int VP8RecordStats(int bit, proba_t* const stats) {
- proba_t p = *stats;
- // An overflow is inbound. Note we handle this at 0xfffe0000u instead of
- // 0xffff0000u to make sure p + 1u does not overflow.
- if (p >= 0xfffe0000u) {
- p = ((p + 1u) >> 1) & 0x7fff7fffu; // -> divide the stats by 2.
- }
- // record bit count (lower 16 bits) and increment total count (upper 16 bits).
- p += 0x00010000u + bit;
- *stats = p;
- return bit;
-}
-
-// Cost of coding one event with probability 'proba'.
-static WEBP_INLINE int VP8BitCost(int bit, uint8_t proba) {
- return !bit ? VP8EntropyCost[proba] : VP8EntropyCost[255 - proba];
-}
-
-// Level cost calculations
-extern const uint16_t VP8LevelCodes[MAX_VARIABLE_LEVEL][2];
-void VP8CalculateLevelCosts(VP8EncProba* const proba);
-static WEBP_INLINE int VP8LevelCost(const uint16_t* const table, int level) {
- return VP8LevelFixedCosts[level]
- + table[(level > MAX_VARIABLE_LEVEL) ? MAX_VARIABLE_LEVEL : level];
-}
-
-// Mode costs
-extern const uint16_t VP8FixedCostsUV[4];
-extern const uint16_t VP8FixedCostsI16[4];
-extern const uint16_t VP8FixedCostsI4[NUM_BMODES][NUM_BMODES][NUM_BMODES];
-
-//------------------------------------------------------------------------------
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // WEBP_ENC_COST_ENC_H_
diff --git a/contrib/libs/libwebp/enc/filter_enc.c b/contrib/libs/libwebp/enc/filter_enc.c
deleted file mode 100644
index 1c2b12e1b5..0000000000
--- a/contrib/libs/libwebp/enc/filter_enc.c
+++ /dev/null
@@ -1,235 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Selecting filter level
-//
-// Author: somnath@google.com (Somnath Banerjee)
-
-#include <assert.h>
-#include "./vp8i_enc.h"
-#include "../dsp/dsp.h"
-
-// This table gives, for a given sharpness, the filtering strength to be
-// used (at least) in order to filter a given edge step delta.
-// This is constructed by brute force inspection: for all delta, we iterate
-// over all possible filtering strength / thresh until needs_filter() returns
-// true.
-#define MAX_DELTA_SIZE 64
-static const uint8_t kLevelsFromDelta[8][MAX_DELTA_SIZE] = {
- { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63 },
- { 0, 1, 2, 3, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 17, 18,
- 20, 21, 23, 24, 26, 27, 29, 30, 32, 33, 35, 36, 38, 39, 41, 42,
- 44, 45, 47, 48, 50, 51, 53, 54, 56, 57, 59, 60, 62, 63, 63, 63,
- 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63 },
- { 0, 1, 2, 3, 5, 6, 7, 8, 9, 11, 12, 13, 14, 16, 17, 19,
- 20, 22, 23, 25, 26, 28, 29, 31, 32, 34, 35, 37, 38, 40, 41, 43,
- 44, 46, 47, 49, 50, 52, 53, 55, 56, 58, 59, 61, 62, 63, 63, 63,
- 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63 },
- { 0, 1, 2, 3, 5, 6, 7, 8, 9, 11, 12, 13, 15, 16, 18, 19,
- 21, 22, 24, 25, 27, 28, 30, 31, 33, 34, 36, 37, 39, 40, 42, 43,
- 45, 46, 48, 49, 51, 52, 54, 55, 57, 58, 60, 61, 63, 63, 63, 63,
- 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63 },
- { 0, 1, 2, 3, 5, 6, 7, 8, 9, 11, 12, 14, 15, 17, 18, 20,
- 21, 23, 24, 26, 27, 29, 30, 32, 33, 35, 36, 38, 39, 41, 42, 44,
- 45, 47, 48, 50, 51, 53, 54, 56, 57, 59, 60, 62, 63, 63, 63, 63,
- 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63 },
- { 0, 1, 2, 4, 5, 7, 8, 9, 11, 12, 13, 15, 16, 17, 19, 20,
- 22, 23, 25, 26, 28, 29, 31, 32, 34, 35, 37, 38, 40, 41, 43, 44,
- 46, 47, 49, 50, 52, 53, 55, 56, 58, 59, 61, 62, 63, 63, 63, 63,
- 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63 },
- { 0, 1, 2, 4, 5, 7, 8, 9, 11, 12, 13, 15, 16, 18, 19, 21,
- 22, 24, 25, 27, 28, 30, 31, 33, 34, 36, 37, 39, 40, 42, 43, 45,
- 46, 48, 49, 51, 52, 54, 55, 57, 58, 60, 61, 63, 63, 63, 63, 63,
- 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63 },
- { 0, 1, 2, 4, 5, 7, 8, 9, 11, 12, 14, 15, 17, 18, 20, 21,
- 23, 24, 26, 27, 29, 30, 32, 33, 35, 36, 38, 39, 41, 42, 44, 45,
- 47, 48, 50, 51, 53, 54, 56, 57, 59, 60, 62, 63, 63, 63, 63, 63,
- 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63 }
-};
-
-int VP8FilterStrengthFromDelta(int sharpness, int delta) {
- const int pos = (delta < MAX_DELTA_SIZE) ? delta : MAX_DELTA_SIZE - 1;
- assert(sharpness >= 0 && sharpness <= 7);
- return kLevelsFromDelta[sharpness][pos];
-}
-
-//------------------------------------------------------------------------------
-// Paragraph 15.4: compute the inner-edge filtering strength
-
-#if !defined(WEBP_REDUCE_SIZE)
-
-static int GetILevel(int sharpness, int level) {
- if (sharpness > 0) {
- if (sharpness > 4) {
- level >>= 2;
- } else {
- level >>= 1;
- }
- if (level > 9 - sharpness) {
- level = 9 - sharpness;
- }
- }
- if (level < 1) level = 1;
- return level;
-}
-
-static void DoFilter(const VP8EncIterator* const it, int level) {
- const VP8Encoder* const enc = it->enc_;
- const int ilevel = GetILevel(enc->config_->filter_sharpness, level);
- const int limit = 2 * level + ilevel;
-
- uint8_t* const y_dst = it->yuv_out2_ + Y_OFF_ENC;
- uint8_t* const u_dst = it->yuv_out2_ + U_OFF_ENC;
- uint8_t* const v_dst = it->yuv_out2_ + V_OFF_ENC;
-
- // copy current block to yuv_out2_
- memcpy(y_dst, it->yuv_out_, YUV_SIZE_ENC * sizeof(uint8_t));
-
- if (enc->filter_hdr_.simple_ == 1) { // simple
- VP8SimpleHFilter16i(y_dst, BPS, limit);
- VP8SimpleVFilter16i(y_dst, BPS, limit);
- } else { // complex
- const int hev_thresh = (level >= 40) ? 2 : (level >= 15) ? 1 : 0;
- VP8HFilter16i(y_dst, BPS, limit, ilevel, hev_thresh);
- VP8HFilter8i(u_dst, v_dst, BPS, limit, ilevel, hev_thresh);
- VP8VFilter16i(y_dst, BPS, limit, ilevel, hev_thresh);
- VP8VFilter8i(u_dst, v_dst, BPS, limit, ilevel, hev_thresh);
- }
-}
-
-//------------------------------------------------------------------------------
-// SSIM metric for one macroblock
-
-static double GetMBSSIM(const uint8_t* yuv1, const uint8_t* yuv2) {
- int x, y;
- double sum = 0.;
-
- // compute SSIM in a 10 x 10 window
- for (y = VP8_SSIM_KERNEL; y < 16 - VP8_SSIM_KERNEL; y++) {
- for (x = VP8_SSIM_KERNEL; x < 16 - VP8_SSIM_KERNEL; x++) {
- sum += VP8SSIMGetClipped(yuv1 + Y_OFF_ENC, BPS, yuv2 + Y_OFF_ENC, BPS,
- x, y, 16, 16);
- }
- }
- for (x = 1; x < 7; x++) {
- for (y = 1; y < 7; y++) {
- sum += VP8SSIMGetClipped(yuv1 + U_OFF_ENC, BPS, yuv2 + U_OFF_ENC, BPS,
- x, y, 8, 8);
- sum += VP8SSIMGetClipped(yuv1 + V_OFF_ENC, BPS, yuv2 + V_OFF_ENC, BPS,
- x, y, 8, 8);
- }
- }
- return sum;
-}
-
-#endif // !defined(WEBP_REDUCE_SIZE)
-
-//------------------------------------------------------------------------------
-// Exposed APIs: Encoder should call the following 3 functions to adjust
-// loop filter strength
-
-void VP8InitFilter(VP8EncIterator* const it) {
-#if !defined(WEBP_REDUCE_SIZE)
- if (it->lf_stats_ != NULL) {
- int s, i;
- for (s = 0; s < NUM_MB_SEGMENTS; s++) {
- for (i = 0; i < MAX_LF_LEVELS; i++) {
- (*it->lf_stats_)[s][i] = 0;
- }
- }
- VP8SSIMDspInit();
- }
-#else
- (void)it;
-#endif
-}
-
-void VP8StoreFilterStats(VP8EncIterator* const it) {
-#if !defined(WEBP_REDUCE_SIZE)
- int d;
- VP8Encoder* const enc = it->enc_;
- const int s = it->mb_->segment_;
- const int level0 = enc->dqm_[s].fstrength_;
-
- // explore +/-quant range of values around level0
- const int delta_min = -enc->dqm_[s].quant_;
- const int delta_max = enc->dqm_[s].quant_;
- const int step_size = (delta_max - delta_min >= 4) ? 4 : 1;
-
- if (it->lf_stats_ == NULL) return;
-
- // NOTE: Currently we are applying filter only across the sublock edges
- // There are two reasons for that.
- // 1. Applying filter on macro block edges will change the pixels in
- // the left and top macro blocks. That will be hard to restore
- // 2. Macro Blocks on the bottom and right are not yet compressed. So we
- // cannot apply filter on the right and bottom macro block edges.
- if (it->mb_->type_ == 1 && it->mb_->skip_) return;
-
- // Always try filter level zero
- (*it->lf_stats_)[s][0] += GetMBSSIM(it->yuv_in_, it->yuv_out_);
-
- for (d = delta_min; d <= delta_max; d += step_size) {
- const int level = level0 + d;
- if (level <= 0 || level >= MAX_LF_LEVELS) {
- continue;
- }
- DoFilter(it, level);
- (*it->lf_stats_)[s][level] += GetMBSSIM(it->yuv_in_, it->yuv_out2_);
- }
-#else // defined(WEBP_REDUCE_SIZE)
- (void)it;
-#endif // !defined(WEBP_REDUCE_SIZE)
-}
-
-void VP8AdjustFilterStrength(VP8EncIterator* const it) {
- VP8Encoder* const enc = it->enc_;
-#if !defined(WEBP_REDUCE_SIZE)
- if (it->lf_stats_ != NULL) {
- int s;
- for (s = 0; s < NUM_MB_SEGMENTS; s++) {
- int i, best_level = 0;
- // Improvement over filter level 0 should be at least 1e-5 (relatively)
- double best_v = 1.00001 * (*it->lf_stats_)[s][0];
- for (i = 1; i < MAX_LF_LEVELS; i++) {
- const double v = (*it->lf_stats_)[s][i];
- if (v > best_v) {
- best_v = v;
- best_level = i;
- }
- }
- enc->dqm_[s].fstrength_ = best_level;
- }
- return;
- }
-#endif // !defined(WEBP_REDUCE_SIZE)
- if (enc->config_->filter_strength > 0) {
- int max_level = 0;
- int s;
- for (s = 0; s < NUM_MB_SEGMENTS; s++) {
- VP8SegmentInfo* const dqm = &enc->dqm_[s];
- // this '>> 3' accounts for some inverse WHT scaling
- const int delta = (dqm->max_edge_ * dqm->y2_.q_[1]) >> 3;
- const int level =
- VP8FilterStrengthFromDelta(enc->filter_hdr_.sharpness_, delta);
- if (level > dqm->fstrength_) {
- dqm->fstrength_ = level;
- }
- if (max_level < dqm->fstrength_) {
- max_level = dqm->fstrength_;
- }
- }
- enc->filter_hdr_.level_ = max_level;
- }
-}
-
-// -----------------------------------------------------------------------------
diff --git a/contrib/libs/libwebp/enc/frame_enc.c b/contrib/libs/libwebp/enc/frame_enc.c
deleted file mode 100644
index 17621f8dda..0000000000
--- a/contrib/libs/libwebp/enc/frame_enc.c
+++ /dev/null
@@ -1,899 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// frame coding and analysis
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include <string.h>
-#include <math.h>
-
-#include "./cost_enc.h"
-#include "./vp8i_enc.h"
-#include "../dsp/dsp.h"
-#include "../webp/format_constants.h" // RIFF constants
-
-#define SEGMENT_VISU 0
-#define DEBUG_SEARCH 0 // useful to track search convergence
-
-//------------------------------------------------------------------------------
-// multi-pass convergence
-
-#define HEADER_SIZE_ESTIMATE (RIFF_HEADER_SIZE + CHUNK_HEADER_SIZE + \
- VP8_FRAME_HEADER_SIZE)
-#define DQ_LIMIT 0.4 // convergence is considered reached if dq < DQ_LIMIT
-// we allow 2k of extra head-room in PARTITION0 limit.
-#define PARTITION0_SIZE_LIMIT ((VP8_MAX_PARTITION0_SIZE - 2048ULL) << 11)
-
-static float Clamp(float v, float min, float max) {
- return (v < min) ? min : (v > max) ? max : v;
-}
-
-typedef struct { // struct for organizing convergence in either size or PSNR
- int is_first;
- float dq;
- float q, last_q;
- float qmin, qmax;
- double value, last_value; // PSNR or size
- double target;
- int do_size_search;
-} PassStats;
-
-static int InitPassStats(const VP8Encoder* const enc, PassStats* const s) {
- const uint64_t target_size = (uint64_t)enc->config_->target_size;
- const int do_size_search = (target_size != 0);
- const float target_PSNR = enc->config_->target_PSNR;
-
- s->is_first = 1;
- s->dq = 10.f;
- s->qmin = 1.f * enc->config_->qmin;
- s->qmax = 1.f * enc->config_->qmax;
- s->q = s->last_q = Clamp(enc->config_->quality, s->qmin, s->qmax);
- s->target = do_size_search ? (double)target_size
- : (target_PSNR > 0.) ? target_PSNR
- : 40.; // default, just in case
- s->value = s->last_value = 0.;
- s->do_size_search = do_size_search;
- return do_size_search;
-}
-
-static float ComputeNextQ(PassStats* const s) {
- float dq;
- if (s->is_first) {
- dq = (s->value > s->target) ? -s->dq : s->dq;
- s->is_first = 0;
- } else if (s->value != s->last_value) {
- const double slope = (s->target - s->value) / (s->last_value - s->value);
- dq = (float)(slope * (s->last_q - s->q));
- } else {
- dq = 0.; // we're done?!
- }
- // Limit variable to avoid large swings.
- s->dq = Clamp(dq, -30.f, 30.f);
- s->last_q = s->q;
- s->last_value = s->value;
- s->q = Clamp(s->q + s->dq, s->qmin, s->qmax);
- return s->q;
-}
-
-//------------------------------------------------------------------------------
-// Tables for level coding
-
-const uint8_t VP8Cat3[] = { 173, 148, 140 };
-const uint8_t VP8Cat4[] = { 176, 155, 140, 135 };
-const uint8_t VP8Cat5[] = { 180, 157, 141, 134, 130 };
-const uint8_t VP8Cat6[] =
- { 254, 254, 243, 230, 196, 177, 153, 140, 133, 130, 129 };
-
-//------------------------------------------------------------------------------
-// Reset the statistics about: number of skips, token proba, level cost,...
-
-static void ResetStats(VP8Encoder* const enc) {
- VP8EncProba* const proba = &enc->proba_;
- VP8CalculateLevelCosts(proba);
- proba->nb_skip_ = 0;
-}
-
-//------------------------------------------------------------------------------
-// Skip decision probability
-
-#define SKIP_PROBA_THRESHOLD 250 // value below which using skip_proba is OK.
-
-static int CalcSkipProba(uint64_t nb, uint64_t total) {
- return (int)(total ? (total - nb) * 255 / total : 255);
-}
-
-// Returns the bit-cost for coding the skip probability.
-static int FinalizeSkipProba(VP8Encoder* const enc) {
- VP8EncProba* const proba = &enc->proba_;
- const int nb_mbs = enc->mb_w_ * enc->mb_h_;
- const int nb_events = proba->nb_skip_;
- int size;
- proba->skip_proba_ = CalcSkipProba(nb_events, nb_mbs);
- proba->use_skip_proba_ = (proba->skip_proba_ < SKIP_PROBA_THRESHOLD);
- size = 256; // 'use_skip_proba' bit
- if (proba->use_skip_proba_) {
- size += nb_events * VP8BitCost(1, proba->skip_proba_)
- + (nb_mbs - nb_events) * VP8BitCost(0, proba->skip_proba_);
- size += 8 * 256; // cost of signaling the skip_proba_ itself.
- }
- return size;
-}
-
-// Collect statistics and deduce probabilities for next coding pass.
-// Return the total bit-cost for coding the probability updates.
-static int CalcTokenProba(int nb, int total) {
- assert(nb <= total);
- return nb ? (255 - nb * 255 / total) : 255;
-}
-
-// Cost of coding 'nb' 1's and 'total-nb' 0's using 'proba' probability.
-static int BranchCost(int nb, int total, int proba) {
- return nb * VP8BitCost(1, proba) + (total - nb) * VP8BitCost(0, proba);
-}
-
-static void ResetTokenStats(VP8Encoder* const enc) {
- VP8EncProba* const proba = &enc->proba_;
- memset(proba->stats_, 0, sizeof(proba->stats_));
-}
-
-static int FinalizeTokenProbas(VP8EncProba* const proba) {
- int has_changed = 0;
- int size = 0;
- int t, b, c, p;
- for (t = 0; t < NUM_TYPES; ++t) {
- for (b = 0; b < NUM_BANDS; ++b) {
- for (c = 0; c < NUM_CTX; ++c) {
- for (p = 0; p < NUM_PROBAS; ++p) {
- const proba_t stats = proba->stats_[t][b][c][p];
- const int nb = (stats >> 0) & 0xffff;
- const int total = (stats >> 16) & 0xffff;
- const int update_proba = VP8CoeffsUpdateProba[t][b][c][p];
- const int old_p = VP8CoeffsProba0[t][b][c][p];
- const int new_p = CalcTokenProba(nb, total);
- const int old_cost = BranchCost(nb, total, old_p)
- + VP8BitCost(0, update_proba);
- const int new_cost = BranchCost(nb, total, new_p)
- + VP8BitCost(1, update_proba)
- + 8 * 256;
- const int use_new_p = (old_cost > new_cost);
- size += VP8BitCost(use_new_p, update_proba);
- if (use_new_p) { // only use proba that seem meaningful enough.
- proba->coeffs_[t][b][c][p] = new_p;
- has_changed |= (new_p != old_p);
- size += 8 * 256;
- } else {
- proba->coeffs_[t][b][c][p] = old_p;
- }
- }
- }
- }
- }
- proba->dirty_ = has_changed;
- return size;
-}
-
-//------------------------------------------------------------------------------
-// Finalize Segment probability based on the coding tree
-
-static int GetProba(int a, int b) {
- const int total = a + b;
- return (total == 0) ? 255 // that's the default probability.
- : (255 * a + total / 2) / total; // rounded proba
-}
-
-static void ResetSegments(VP8Encoder* const enc) {
- int n;
- for (n = 0; n < enc->mb_w_ * enc->mb_h_; ++n) {
- enc->mb_info_[n].segment_ = 0;
- }
-}
-
-static void SetSegmentProbas(VP8Encoder* const enc) {
- int p[NUM_MB_SEGMENTS] = { 0 };
- int n;
-
- for (n = 0; n < enc->mb_w_ * enc->mb_h_; ++n) {
- const VP8MBInfo* const mb = &enc->mb_info_[n];
- ++p[mb->segment_];
- }
-#if !defined(WEBP_DISABLE_STATS)
- if (enc->pic_->stats != NULL) {
- for (n = 0; n < NUM_MB_SEGMENTS; ++n) {
- enc->pic_->stats->segment_size[n] = p[n];
- }
- }
-#endif
- if (enc->segment_hdr_.num_segments_ > 1) {
- uint8_t* const probas = enc->proba_.segments_;
- probas[0] = GetProba(p[0] + p[1], p[2] + p[3]);
- probas[1] = GetProba(p[0], p[1]);
- probas[2] = GetProba(p[2], p[3]);
-
- enc->segment_hdr_.update_map_ =
- (probas[0] != 255) || (probas[1] != 255) || (probas[2] != 255);
- if (!enc->segment_hdr_.update_map_) ResetSegments(enc);
- enc->segment_hdr_.size_ =
- p[0] * (VP8BitCost(0, probas[0]) + VP8BitCost(0, probas[1])) +
- p[1] * (VP8BitCost(0, probas[0]) + VP8BitCost(1, probas[1])) +
- p[2] * (VP8BitCost(1, probas[0]) + VP8BitCost(0, probas[2])) +
- p[3] * (VP8BitCost(1, probas[0]) + VP8BitCost(1, probas[2]));
- } else {
- enc->segment_hdr_.update_map_ = 0;
- enc->segment_hdr_.size_ = 0;
- }
-}
-
-//------------------------------------------------------------------------------
-// Coefficient coding
-
-static int PutCoeffs(VP8BitWriter* const bw, int ctx, const VP8Residual* res) {
- int n = res->first;
- // should be prob[VP8EncBands[n]], but it's equivalent for n=0 or 1
- const uint8_t* p = res->prob[n][ctx];
- if (!VP8PutBit(bw, res->last >= 0, p[0])) {
- return 0;
- }
-
- while (n < 16) {
- const int c = res->coeffs[n++];
- const int sign = c < 0;
- int v = sign ? -c : c;
- if (!VP8PutBit(bw, v != 0, p[1])) {
- p = res->prob[VP8EncBands[n]][0];
- continue;
- }
- if (!VP8PutBit(bw, v > 1, p[2])) {
- p = res->prob[VP8EncBands[n]][1];
- } else {
- if (!VP8PutBit(bw, v > 4, p[3])) {
- if (VP8PutBit(bw, v != 2, p[4])) {
- VP8PutBit(bw, v == 4, p[5]);
- }
- } else if (!VP8PutBit(bw, v > 10, p[6])) {
- if (!VP8PutBit(bw, v > 6, p[7])) {
- VP8PutBit(bw, v == 6, 159);
- } else {
- VP8PutBit(bw, v >= 9, 165);
- VP8PutBit(bw, !(v & 1), 145);
- }
- } else {
- int mask;
- const uint8_t* tab;
- if (v < 3 + (8 << 1)) { // VP8Cat3 (3b)
- VP8PutBit(bw, 0, p[8]);
- VP8PutBit(bw, 0, p[9]);
- v -= 3 + (8 << 0);
- mask = 1 << 2;
- tab = VP8Cat3;
- } else if (v < 3 + (8 << 2)) { // VP8Cat4 (4b)
- VP8PutBit(bw, 0, p[8]);
- VP8PutBit(bw, 1, p[9]);
- v -= 3 + (8 << 1);
- mask = 1 << 3;
- tab = VP8Cat4;
- } else if (v < 3 + (8 << 3)) { // VP8Cat5 (5b)
- VP8PutBit(bw, 1, p[8]);
- VP8PutBit(bw, 0, p[10]);
- v -= 3 + (8 << 2);
- mask = 1 << 4;
- tab = VP8Cat5;
- } else { // VP8Cat6 (11b)
- VP8PutBit(bw, 1, p[8]);
- VP8PutBit(bw, 1, p[10]);
- v -= 3 + (8 << 3);
- mask = 1 << 10;
- tab = VP8Cat6;
- }
- while (mask) {
- VP8PutBit(bw, !!(v & mask), *tab++);
- mask >>= 1;
- }
- }
- p = res->prob[VP8EncBands[n]][2];
- }
- VP8PutBitUniform(bw, sign);
- if (n == 16 || !VP8PutBit(bw, n <= res->last, p[0])) {
- return 1; // EOB
- }
- }
- return 1;
-}
-
-static void CodeResiduals(VP8BitWriter* const bw, VP8EncIterator* const it,
- const VP8ModeScore* const rd) {
- int x, y, ch;
- VP8Residual res;
- uint64_t pos1, pos2, pos3;
- const int i16 = (it->mb_->type_ == 1);
- const int segment = it->mb_->segment_;
- VP8Encoder* const enc = it->enc_;
-
- VP8IteratorNzToBytes(it);
-
- pos1 = VP8BitWriterPos(bw);
- if (i16) {
- VP8InitResidual(0, 1, enc, &res);
- VP8SetResidualCoeffs(rd->y_dc_levels, &res);
- it->top_nz_[8] = it->left_nz_[8] =
- PutCoeffs(bw, it->top_nz_[8] + it->left_nz_[8], &res);
- VP8InitResidual(1, 0, enc, &res);
- } else {
- VP8InitResidual(0, 3, enc, &res);
- }
-
- // luma-AC
- for (y = 0; y < 4; ++y) {
- for (x = 0; x < 4; ++x) {
- const int ctx = it->top_nz_[x] + it->left_nz_[y];
- VP8SetResidualCoeffs(rd->y_ac_levels[x + y * 4], &res);
- it->top_nz_[x] = it->left_nz_[y] = PutCoeffs(bw, ctx, &res);
- }
- }
- pos2 = VP8BitWriterPos(bw);
-
- // U/V
- VP8InitResidual(0, 2, enc, &res);
- for (ch = 0; ch <= 2; ch += 2) {
- for (y = 0; y < 2; ++y) {
- for (x = 0; x < 2; ++x) {
- const int ctx = it->top_nz_[4 + ch + x] + it->left_nz_[4 + ch + y];
- VP8SetResidualCoeffs(rd->uv_levels[ch * 2 + x + y * 2], &res);
- it->top_nz_[4 + ch + x] = it->left_nz_[4 + ch + y] =
- PutCoeffs(bw, ctx, &res);
- }
- }
- }
- pos3 = VP8BitWriterPos(bw);
- it->luma_bits_ = pos2 - pos1;
- it->uv_bits_ = pos3 - pos2;
- it->bit_count_[segment][i16] += it->luma_bits_;
- it->bit_count_[segment][2] += it->uv_bits_;
- VP8IteratorBytesToNz(it);
-}
-
-// Same as CodeResiduals, but doesn't actually write anything.
-// Instead, it just records the event distribution.
-static void RecordResiduals(VP8EncIterator* const it,
- const VP8ModeScore* const rd) {
- int x, y, ch;
- VP8Residual res;
- VP8Encoder* const enc = it->enc_;
-
- VP8IteratorNzToBytes(it);
-
- if (it->mb_->type_ == 1) { // i16x16
- VP8InitResidual(0, 1, enc, &res);
- VP8SetResidualCoeffs(rd->y_dc_levels, &res);
- it->top_nz_[8] = it->left_nz_[8] =
- VP8RecordCoeffs(it->top_nz_[8] + it->left_nz_[8], &res);
- VP8InitResidual(1, 0, enc, &res);
- } else {
- VP8InitResidual(0, 3, enc, &res);
- }
-
- // luma-AC
- for (y = 0; y < 4; ++y) {
- for (x = 0; x < 4; ++x) {
- const int ctx = it->top_nz_[x] + it->left_nz_[y];
- VP8SetResidualCoeffs(rd->y_ac_levels[x + y * 4], &res);
- it->top_nz_[x] = it->left_nz_[y] = VP8RecordCoeffs(ctx, &res);
- }
- }
-
- // U/V
- VP8InitResidual(0, 2, enc, &res);
- for (ch = 0; ch <= 2; ch += 2) {
- for (y = 0; y < 2; ++y) {
- for (x = 0; x < 2; ++x) {
- const int ctx = it->top_nz_[4 + ch + x] + it->left_nz_[4 + ch + y];
- VP8SetResidualCoeffs(rd->uv_levels[ch * 2 + x + y * 2], &res);
- it->top_nz_[4 + ch + x] = it->left_nz_[4 + ch + y] =
- VP8RecordCoeffs(ctx, &res);
- }
- }
- }
-
- VP8IteratorBytesToNz(it);
-}
-
-//------------------------------------------------------------------------------
-// Token buffer
-
-#if !defined(DISABLE_TOKEN_BUFFER)
-
-static int RecordTokens(VP8EncIterator* const it, const VP8ModeScore* const rd,
- VP8TBuffer* const tokens) {
- int x, y, ch;
- VP8Residual res;
- VP8Encoder* const enc = it->enc_;
-
- VP8IteratorNzToBytes(it);
- if (it->mb_->type_ == 1) { // i16x16
- const int ctx = it->top_nz_[8] + it->left_nz_[8];
- VP8InitResidual(0, 1, enc, &res);
- VP8SetResidualCoeffs(rd->y_dc_levels, &res);
- it->top_nz_[8] = it->left_nz_[8] =
- VP8RecordCoeffTokens(ctx, &res, tokens);
- VP8InitResidual(1, 0, enc, &res);
- } else {
- VP8InitResidual(0, 3, enc, &res);
- }
-
- // luma-AC
- for (y = 0; y < 4; ++y) {
- for (x = 0; x < 4; ++x) {
- const int ctx = it->top_nz_[x] + it->left_nz_[y];
- VP8SetResidualCoeffs(rd->y_ac_levels[x + y * 4], &res);
- it->top_nz_[x] = it->left_nz_[y] =
- VP8RecordCoeffTokens(ctx, &res, tokens);
- }
- }
-
- // U/V
- VP8InitResidual(0, 2, enc, &res);
- for (ch = 0; ch <= 2; ch += 2) {
- for (y = 0; y < 2; ++y) {
- for (x = 0; x < 2; ++x) {
- const int ctx = it->top_nz_[4 + ch + x] + it->left_nz_[4 + ch + y];
- VP8SetResidualCoeffs(rd->uv_levels[ch * 2 + x + y * 2], &res);
- it->top_nz_[4 + ch + x] = it->left_nz_[4 + ch + y] =
- VP8RecordCoeffTokens(ctx, &res, tokens);
- }
- }
- }
- VP8IteratorBytesToNz(it);
- return !tokens->error_;
-}
-
-#endif // !DISABLE_TOKEN_BUFFER
-
-//------------------------------------------------------------------------------
-// ExtraInfo map / Debug function
-
-#if !defined(WEBP_DISABLE_STATS)
-
-#if SEGMENT_VISU
-static void SetBlock(uint8_t* p, int value, int size) {
- int y;
- for (y = 0; y < size; ++y) {
- memset(p, value, size);
- p += BPS;
- }
-}
-#endif
-
-static void ResetSSE(VP8Encoder* const enc) {
- enc->sse_[0] = 0;
- enc->sse_[1] = 0;
- enc->sse_[2] = 0;
- // Note: enc->sse_[3] is managed by alpha.c
- enc->sse_count_ = 0;
-}
-
-static void StoreSSE(const VP8EncIterator* const it) {
- VP8Encoder* const enc = it->enc_;
- const uint8_t* const in = it->yuv_in_;
- const uint8_t* const out = it->yuv_out_;
- // Note: not totally accurate at boundary. And doesn't include in-loop filter.
- enc->sse_[0] += VP8SSE16x16(in + Y_OFF_ENC, out + Y_OFF_ENC);
- enc->sse_[1] += VP8SSE8x8(in + U_OFF_ENC, out + U_OFF_ENC);
- enc->sse_[2] += VP8SSE8x8(in + V_OFF_ENC, out + V_OFF_ENC);
- enc->sse_count_ += 16 * 16;
-}
-
-static void StoreSideInfo(const VP8EncIterator* const it) {
- VP8Encoder* const enc = it->enc_;
- const VP8MBInfo* const mb = it->mb_;
- WebPPicture* const pic = enc->pic_;
-
- if (pic->stats != NULL) {
- StoreSSE(it);
- enc->block_count_[0] += (mb->type_ == 0);
- enc->block_count_[1] += (mb->type_ == 1);
- enc->block_count_[2] += (mb->skip_ != 0);
- }
-
- if (pic->extra_info != NULL) {
- uint8_t* const info = &pic->extra_info[it->x_ + it->y_ * enc->mb_w_];
- switch (pic->extra_info_type) {
- case 1: *info = mb->type_; break;
- case 2: *info = mb->segment_; break;
- case 3: *info = enc->dqm_[mb->segment_].quant_; break;
- case 4: *info = (mb->type_ == 1) ? it->preds_[0] : 0xff; break;
- case 5: *info = mb->uv_mode_; break;
- case 6: {
- const int b = (int)((it->luma_bits_ + it->uv_bits_ + 7) >> 3);
- *info = (b > 255) ? 255 : b; break;
- }
- case 7: *info = mb->alpha_; break;
- default: *info = 0; break;
- }
- }
-#if SEGMENT_VISU // visualize segments and prediction modes
- SetBlock(it->yuv_out_ + Y_OFF_ENC, mb->segment_ * 64, 16);
- SetBlock(it->yuv_out_ + U_OFF_ENC, it->preds_[0] * 64, 8);
- SetBlock(it->yuv_out_ + V_OFF_ENC, mb->uv_mode_ * 64, 8);
-#endif
-}
-
-static void ResetSideInfo(const VP8EncIterator* const it) {
- VP8Encoder* const enc = it->enc_;
- WebPPicture* const pic = enc->pic_;
- if (pic->stats != NULL) {
- memset(enc->block_count_, 0, sizeof(enc->block_count_));
- }
- ResetSSE(enc);
-}
-#else // defined(WEBP_DISABLE_STATS)
-static void ResetSSE(VP8Encoder* const enc) {
- (void)enc;
-}
-static void StoreSideInfo(const VP8EncIterator* const it) {
- VP8Encoder* const enc = it->enc_;
- WebPPicture* const pic = enc->pic_;
- if (pic->extra_info != NULL) {
- if (it->x_ == 0 && it->y_ == 0) { // only do it once, at start
- memset(pic->extra_info, 0,
- enc->mb_w_ * enc->mb_h_ * sizeof(*pic->extra_info));
- }
- }
-}
-
-static void ResetSideInfo(const VP8EncIterator* const it) {
- (void)it;
-}
-#endif // !defined(WEBP_DISABLE_STATS)
-
-static double GetPSNR(uint64_t mse, uint64_t size) {
- return (mse > 0 && size > 0) ? 10. * log10(255. * 255. * size / mse) : 99;
-}
-
-//------------------------------------------------------------------------------
-// StatLoop(): only collect statistics (number of skips, token usage, ...).
-// This is used for deciding optimal probabilities. It also modifies the
-// quantizer value if some target (size, PSNR) was specified.
-
-static void SetLoopParams(VP8Encoder* const enc, float q) {
- // Make sure the quality parameter is inside valid bounds
- q = Clamp(q, 0.f, 100.f);
-
- VP8SetSegmentParams(enc, q); // setup segment quantizations and filters
- SetSegmentProbas(enc); // compute segment probabilities
-
- ResetStats(enc);
- ResetSSE(enc);
-}
-
-static uint64_t OneStatPass(VP8Encoder* const enc, VP8RDLevel rd_opt,
- int nb_mbs, int percent_delta,
- PassStats* const s) {
- VP8EncIterator it;
- uint64_t size = 0;
- uint64_t size_p0 = 0;
- uint64_t distortion = 0;
- const uint64_t pixel_count = nb_mbs * 384;
-
- VP8IteratorInit(enc, &it);
- SetLoopParams(enc, s->q);
- do {
- VP8ModeScore info;
- VP8IteratorImport(&it, NULL);
- if (VP8Decimate(&it, &info, rd_opt)) {
- // Just record the number of skips and act like skip_proba is not used.
- ++enc->proba_.nb_skip_;
- }
- RecordResiduals(&it, &info);
- size += info.R + info.H;
- size_p0 += info.H;
- distortion += info.D;
- if (percent_delta && !VP8IteratorProgress(&it, percent_delta)) {
- return 0;
- }
- VP8IteratorSaveBoundary(&it);
- } while (VP8IteratorNext(&it) && --nb_mbs > 0);
-
- size_p0 += enc->segment_hdr_.size_;
- if (s->do_size_search) {
- size += FinalizeSkipProba(enc);
- size += FinalizeTokenProbas(&enc->proba_);
- size = ((size + size_p0 + 1024) >> 11) + HEADER_SIZE_ESTIMATE;
- s->value = (double)size;
- } else {
- s->value = GetPSNR(distortion, pixel_count);
- }
- return size_p0;
-}
-
-static int StatLoop(VP8Encoder* const enc) {
- const int method = enc->method_;
- const int do_search = enc->do_search_;
- const int fast_probe = ((method == 0 || method == 3) && !do_search);
- int num_pass_left = enc->config_->pass;
- const int task_percent = 20;
- const int percent_per_pass =
- (task_percent + num_pass_left / 2) / num_pass_left;
- const int final_percent = enc->percent_ + task_percent;
- const VP8RDLevel rd_opt =
- (method >= 3 || do_search) ? RD_OPT_BASIC : RD_OPT_NONE;
- int nb_mbs = enc->mb_w_ * enc->mb_h_;
- PassStats stats;
-
- InitPassStats(enc, &stats);
- ResetTokenStats(enc);
-
- // Fast mode: quick analysis pass over few mbs. Better than nothing.
- if (fast_probe) {
- if (method == 3) { // we need more stats for method 3 to be reliable.
- nb_mbs = (nb_mbs > 200) ? nb_mbs >> 1 : 100;
- } else {
- nb_mbs = (nb_mbs > 200) ? nb_mbs >> 2 : 50;
- }
- }
-
- while (num_pass_left-- > 0) {
- const int is_last_pass = (fabs(stats.dq) <= DQ_LIMIT) ||
- (num_pass_left == 0) ||
- (enc->max_i4_header_bits_ == 0);
- const uint64_t size_p0 =
- OneStatPass(enc, rd_opt, nb_mbs, percent_per_pass, &stats);
- if (size_p0 == 0) return 0;
-#if (DEBUG_SEARCH > 0)
- printf("#%d value:%.1lf -> %.1lf q:%.2f -> %.2f\n",
- num_pass_left, stats.last_value, stats.value, stats.last_q, stats.q);
-#endif
- if (enc->max_i4_header_bits_ > 0 && size_p0 > PARTITION0_SIZE_LIMIT) {
- ++num_pass_left;
- enc->max_i4_header_bits_ >>= 1; // strengthen header bit limitation...
- continue; // ...and start over
- }
- if (is_last_pass) {
- break;
- }
- // If no target size: just do several pass without changing 'q'
- if (do_search) {
- ComputeNextQ(&stats);
- if (fabs(stats.dq) <= DQ_LIMIT) break;
- }
- }
- if (!do_search || !stats.do_size_search) {
- // Need to finalize probas now, since it wasn't done during the search.
- FinalizeSkipProba(enc);
- FinalizeTokenProbas(&enc->proba_);
- }
- VP8CalculateLevelCosts(&enc->proba_); // finalize costs
- return WebPReportProgress(enc->pic_, final_percent, &enc->percent_);
-}
-
-//------------------------------------------------------------------------------
-// Main loops
-//
-
-static const uint8_t kAverageBytesPerMB[8] = { 50, 24, 16, 9, 7, 5, 3, 2 };
-
-static int PreLoopInitialize(VP8Encoder* const enc) {
- int p;
- int ok = 1;
- const int average_bytes_per_MB = kAverageBytesPerMB[enc->base_quant_ >> 4];
- const int bytes_per_parts =
- enc->mb_w_ * enc->mb_h_ * average_bytes_per_MB / enc->num_parts_;
- // Initialize the bit-writers
- for (p = 0; ok && p < enc->num_parts_; ++p) {
- ok = VP8BitWriterInit(enc->parts_ + p, bytes_per_parts);
- }
- if (!ok) {
- VP8EncFreeBitWriters(enc); // malloc error occurred
- WebPEncodingSetError(enc->pic_, VP8_ENC_ERROR_OUT_OF_MEMORY);
- }
- return ok;
-}
-
-static int PostLoopFinalize(VP8EncIterator* const it, int ok) {
- VP8Encoder* const enc = it->enc_;
- if (ok) { // Finalize the partitions, check for extra errors.
- int p;
- for (p = 0; p < enc->num_parts_; ++p) {
- VP8BitWriterFinish(enc->parts_ + p);
- ok &= !enc->parts_[p].error_;
- }
- }
-
- if (ok) { // All good. Finish up.
-#if !defined(WEBP_DISABLE_STATS)
- if (enc->pic_->stats != NULL) { // finalize byte counters...
- int i, s;
- for (i = 0; i <= 2; ++i) {
- for (s = 0; s < NUM_MB_SEGMENTS; ++s) {
- enc->residual_bytes_[i][s] = (int)((it->bit_count_[s][i] + 7) >> 3);
- }
- }
- }
-#endif
- VP8AdjustFilterStrength(it); // ...and store filter stats.
- } else {
- // Something bad happened -> need to do some memory cleanup.
- VP8EncFreeBitWriters(enc);
- }
- return ok;
-}
-
-//------------------------------------------------------------------------------
-// VP8EncLoop(): does the final bitstream coding.
-
-static void ResetAfterSkip(VP8EncIterator* const it) {
- if (it->mb_->type_ == 1) {
- *it->nz_ = 0; // reset all predictors
- it->left_nz_[8] = 0;
- } else {
- *it->nz_ &= (1 << 24); // preserve the dc_nz bit
- }
-}
-
-int VP8EncLoop(VP8Encoder* const enc) {
- VP8EncIterator it;
- int ok = PreLoopInitialize(enc);
- if (!ok) return 0;
-
- StatLoop(enc); // stats-collection loop
-
- VP8IteratorInit(enc, &it);
- VP8InitFilter(&it);
- do {
- VP8ModeScore info;
- const int dont_use_skip = !enc->proba_.use_skip_proba_;
- const VP8RDLevel rd_opt = enc->rd_opt_level_;
-
- VP8IteratorImport(&it, NULL);
- // Warning! order is important: first call VP8Decimate() and
- // *then* decide how to code the skip decision if there's one.
- if (!VP8Decimate(&it, &info, rd_opt) || dont_use_skip) {
- CodeResiduals(it.bw_, &it, &info);
- } else { // reset predictors after a skip
- ResetAfterSkip(&it);
- }
- StoreSideInfo(&it);
- VP8StoreFilterStats(&it);
- VP8IteratorExport(&it);
- ok = VP8IteratorProgress(&it, 20);
- VP8IteratorSaveBoundary(&it);
- } while (ok && VP8IteratorNext(&it));
-
- return PostLoopFinalize(&it, ok);
-}
-
-//------------------------------------------------------------------------------
-// Single pass using Token Buffer.
-
-#if !defined(DISABLE_TOKEN_BUFFER)
-
-#define MIN_COUNT 96 // minimum number of macroblocks before updating stats
-
-int VP8EncTokenLoop(VP8Encoder* const enc) {
- // Roughly refresh the proba eight times per pass
- int max_count = (enc->mb_w_ * enc->mb_h_) >> 3;
- int num_pass_left = enc->config_->pass;
- int remaining_progress = 40; // percents
- const int do_search = enc->do_search_;
- VP8EncIterator it;
- VP8EncProba* const proba = &enc->proba_;
- const VP8RDLevel rd_opt = enc->rd_opt_level_;
- const uint64_t pixel_count = enc->mb_w_ * enc->mb_h_ * 384;
- PassStats stats;
- int ok;
-
- InitPassStats(enc, &stats);
- ok = PreLoopInitialize(enc);
- if (!ok) return 0;
-
- if (max_count < MIN_COUNT) max_count = MIN_COUNT;
-
- assert(enc->num_parts_ == 1);
- assert(enc->use_tokens_);
- assert(proba->use_skip_proba_ == 0);
- assert(rd_opt >= RD_OPT_BASIC); // otherwise, token-buffer won't be useful
- assert(num_pass_left > 0);
-
- while (ok && num_pass_left-- > 0) {
- const int is_last_pass = (fabs(stats.dq) <= DQ_LIMIT) ||
- (num_pass_left == 0) ||
- (enc->max_i4_header_bits_ == 0);
- uint64_t size_p0 = 0;
- uint64_t distortion = 0;
- int cnt = max_count;
- // The final number of passes is not trivial to know in advance.
- const int pass_progress = remaining_progress / (2 + num_pass_left);
- remaining_progress -= pass_progress;
- VP8IteratorInit(enc, &it);
- SetLoopParams(enc, stats.q);
- if (is_last_pass) {
- ResetTokenStats(enc);
- VP8InitFilter(&it); // don't collect stats until last pass (too costly)
- }
- VP8TBufferClear(&enc->tokens_);
- do {
- VP8ModeScore info;
- VP8IteratorImport(&it, NULL);
- if (--cnt < 0) {
- FinalizeTokenProbas(proba);
- VP8CalculateLevelCosts(proba); // refresh cost tables for rd-opt
- cnt = max_count;
- }
- VP8Decimate(&it, &info, rd_opt);
- ok = RecordTokens(&it, &info, &enc->tokens_);
- if (!ok) {
- WebPEncodingSetError(enc->pic_, VP8_ENC_ERROR_OUT_OF_MEMORY);
- break;
- }
- size_p0 += info.H;
- distortion += info.D;
- if (is_last_pass) {
- StoreSideInfo(&it);
- VP8StoreFilterStats(&it);
- VP8IteratorExport(&it);
- ok = VP8IteratorProgress(&it, pass_progress);
- }
- VP8IteratorSaveBoundary(&it);
- } while (ok && VP8IteratorNext(&it));
- if (!ok) break;
-
- size_p0 += enc->segment_hdr_.size_;
- if (stats.do_size_search) {
- uint64_t size = FinalizeTokenProbas(&enc->proba_);
- size += VP8EstimateTokenSize(&enc->tokens_,
- (const uint8_t*)proba->coeffs_);
- size = (size + size_p0 + 1024) >> 11; // -> size in bytes
- size += HEADER_SIZE_ESTIMATE;
- stats.value = (double)size;
- } else { // compute and store PSNR
- stats.value = GetPSNR(distortion, pixel_count);
- }
-
-#if (DEBUG_SEARCH > 0)
- printf("#%2d metric:%.1lf -> %.1lf last_q=%.2lf q=%.2lf dq=%.2lf "
- " range:[%.1f, %.1f]\n",
- num_pass_left, stats.last_value, stats.value,
- stats.last_q, stats.q, stats.dq, stats.qmin, stats.qmax);
-#endif
- if (enc->max_i4_header_bits_ > 0 && size_p0 > PARTITION0_SIZE_LIMIT) {
- ++num_pass_left;
- enc->max_i4_header_bits_ >>= 1; // strengthen header bit limitation...
- if (is_last_pass) {
- ResetSideInfo(&it);
- }
- continue; // ...and start over
- }
- if (is_last_pass) {
- break; // done
- }
- if (do_search) {
- ComputeNextQ(&stats); // Adjust q
- }
- }
- if (ok) {
- if (!stats.do_size_search) {
- FinalizeTokenProbas(&enc->proba_);
- }
- ok = VP8EmitTokens(&enc->tokens_, enc->parts_ + 0,
- (const uint8_t*)proba->coeffs_, 1);
- }
- ok = ok && WebPReportProgress(enc->pic_, enc->percent_ + remaining_progress,
- &enc->percent_);
- return PostLoopFinalize(&it, ok);
-}
-
-#else
-
-int VP8EncTokenLoop(VP8Encoder* const enc) {
- (void)enc;
- return 0; // we shouldn't be here.
-}
-
-#endif // DISABLE_TOKEN_BUFFER
-
-//------------------------------------------------------------------------------
diff --git a/contrib/libs/libwebp/enc/histogram_enc.c b/contrib/libs/libwebp/enc/histogram_enc.c
deleted file mode 100644
index 2d04c67bd6..0000000000
--- a/contrib/libs/libwebp/enc/histogram_enc.c
+++ /dev/null
@@ -1,1252 +0,0 @@
-// Copyright 2012 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Author: Jyrki Alakuijala (jyrki@google.com)
-//
-#ifdef HAVE_CONFIG_H
-#include "../webp/config.h"
-#endif
-
-#include <math.h>
-
-#include "./backward_references_enc.h"
-#include "./histogram_enc.h"
-#include "../dsp/lossless.h"
-#include "../dsp/lossless_common.h"
-#include "../utils/utils.h"
-
-#define MAX_COST 1.e38
-
-// Number of partitions for the three dominant (literal, red and blue) symbol
-// costs.
-#define NUM_PARTITIONS 4
-// The size of the bin-hash corresponding to the three dominant costs.
-#define BIN_SIZE (NUM_PARTITIONS * NUM_PARTITIONS * NUM_PARTITIONS)
-// Maximum number of histograms allowed in greedy combining algorithm.
-#define MAX_HISTO_GREEDY 100
-
-static void HistogramClear(VP8LHistogram* const p) {
- uint32_t* const literal = p->literal_;
- const int cache_bits = p->palette_code_bits_;
- const int histo_size = VP8LGetHistogramSize(cache_bits);
- memset(p, 0, histo_size);
- p->palette_code_bits_ = cache_bits;
- p->literal_ = literal;
-}
-
-// Swap two histogram pointers.
-static void HistogramSwap(VP8LHistogram** const A, VP8LHistogram** const B) {
- VP8LHistogram* const tmp = *A;
- *A = *B;
- *B = tmp;
-}
-
-static void HistogramCopy(const VP8LHistogram* const src,
- VP8LHistogram* const dst) {
- uint32_t* const dst_literal = dst->literal_;
- const int dst_cache_bits = dst->palette_code_bits_;
- const int literal_size = VP8LHistogramNumCodes(dst_cache_bits);
- const int histo_size = VP8LGetHistogramSize(dst_cache_bits);
- assert(src->palette_code_bits_ == dst_cache_bits);
- memcpy(dst, src, histo_size);
- dst->literal_ = dst_literal;
- memcpy(dst->literal_, src->literal_, literal_size * sizeof(*dst->literal_));
-}
-
-int VP8LGetHistogramSize(int cache_bits) {
- const int literal_size = VP8LHistogramNumCodes(cache_bits);
- const size_t total_size = sizeof(VP8LHistogram) + sizeof(int) * literal_size;
- assert(total_size <= (size_t)0x7fffffff);
- return (int)total_size;
-}
-
-void VP8LFreeHistogram(VP8LHistogram* const histo) {
- WebPSafeFree(histo);
-}
-
-void VP8LFreeHistogramSet(VP8LHistogramSet* const histo) {
- WebPSafeFree(histo);
-}
-
-void VP8LHistogramStoreRefs(const VP8LBackwardRefs* const refs,
- VP8LHistogram* const histo) {
- VP8LRefsCursor c = VP8LRefsCursorInit(refs);
- while (VP8LRefsCursorOk(&c)) {
- VP8LHistogramAddSinglePixOrCopy(histo, c.cur_pos, NULL, 0);
- VP8LRefsCursorNext(&c);
- }
-}
-
-void VP8LHistogramCreate(VP8LHistogram* const p,
- const VP8LBackwardRefs* const refs,
- int palette_code_bits) {
- if (palette_code_bits >= 0) {
- p->palette_code_bits_ = palette_code_bits;
- }
- HistogramClear(p);
- VP8LHistogramStoreRefs(refs, p);
-}
-
-void VP8LHistogramInit(VP8LHistogram* const p, int palette_code_bits,
- int init_arrays) {
- p->palette_code_bits_ = palette_code_bits;
- if (init_arrays) {
- HistogramClear(p);
- } else {
- p->trivial_symbol_ = 0;
- p->bit_cost_ = 0.;
- p->literal_cost_ = 0.;
- p->red_cost_ = 0.;
- p->blue_cost_ = 0.;
- memset(p->is_used_, 0, sizeof(p->is_used_));
- }
-}
-
-VP8LHistogram* VP8LAllocateHistogram(int cache_bits) {
- VP8LHistogram* histo = NULL;
- const int total_size = VP8LGetHistogramSize(cache_bits);
- uint8_t* const memory = (uint8_t*)WebPSafeMalloc(total_size, sizeof(*memory));
- if (memory == NULL) return NULL;
- histo = (VP8LHistogram*)memory;
- // literal_ won't necessary be aligned.
- histo->literal_ = (uint32_t*)(memory + sizeof(VP8LHistogram));
- VP8LHistogramInit(histo, cache_bits, /*init_arrays=*/ 0);
- return histo;
-}
-
-// Resets the pointers of the histograms to point to the bit buffer in the set.
-static void HistogramSetResetPointers(VP8LHistogramSet* const set,
- int cache_bits) {
- int i;
- const int histo_size = VP8LGetHistogramSize(cache_bits);
- uint8_t* memory = (uint8_t*) (set->histograms);
- memory += set->max_size * sizeof(*set->histograms);
- for (i = 0; i < set->max_size; ++i) {
- memory = (uint8_t*) WEBP_ALIGN(memory);
- set->histograms[i] = (VP8LHistogram*) memory;
- // literal_ won't necessary be aligned.
- set->histograms[i]->literal_ = (uint32_t*)(memory + sizeof(VP8LHistogram));
- memory += histo_size;
- }
-}
-
-// Returns the total size of the VP8LHistogramSet.
-static size_t HistogramSetTotalSize(int size, int cache_bits) {
- const int histo_size = VP8LGetHistogramSize(cache_bits);
- return (sizeof(VP8LHistogramSet) + size * (sizeof(VP8LHistogram*) +
- histo_size + WEBP_ALIGN_CST));
-}
-
-VP8LHistogramSet* VP8LAllocateHistogramSet(int size, int cache_bits) {
- int i;
- VP8LHistogramSet* set;
- const size_t total_size = HistogramSetTotalSize(size, cache_bits);
- uint8_t* memory = (uint8_t*)WebPSafeMalloc(total_size, sizeof(*memory));
- if (memory == NULL) return NULL;
-
- set = (VP8LHistogramSet*)memory;
- memory += sizeof(*set);
- set->histograms = (VP8LHistogram**)memory;
- set->max_size = size;
- set->size = size;
- HistogramSetResetPointers(set, cache_bits);
- for (i = 0; i < size; ++i) {
- VP8LHistogramInit(set->histograms[i], cache_bits, /*init_arrays=*/ 0);
- }
- return set;
-}
-
-void VP8LHistogramSetClear(VP8LHistogramSet* const set) {
- int i;
- const int cache_bits = set->histograms[0]->palette_code_bits_;
- const int size = set->max_size;
- const size_t total_size = HistogramSetTotalSize(size, cache_bits);
- uint8_t* memory = (uint8_t*)set;
-
- memset(memory, 0, total_size);
- memory += sizeof(*set);
- set->histograms = (VP8LHistogram**)memory;
- set->max_size = size;
- set->size = size;
- HistogramSetResetPointers(set, cache_bits);
- for (i = 0; i < size; ++i) {
- set->histograms[i]->palette_code_bits_ = cache_bits;
- }
-}
-
-// Removes the histogram 'i' from 'set' by setting it to NULL.
-static void HistogramSetRemoveHistogram(VP8LHistogramSet* const set, int i,
- int* const num_used) {
- assert(set->histograms[i] != NULL);
- set->histograms[i] = NULL;
- --*num_used;
- // If we remove the last valid one, shrink until the next valid one.
- if (i == set->size - 1) {
- while (set->size >= 1 && set->histograms[set->size - 1] == NULL) {
- --set->size;
- }
- }
-}
-
-// -----------------------------------------------------------------------------
-
-void VP8LHistogramAddSinglePixOrCopy(VP8LHistogram* const histo,
- const PixOrCopy* const v,
- int (*const distance_modifier)(int, int),
- int distance_modifier_arg0) {
- if (PixOrCopyIsLiteral(v)) {
- ++histo->alpha_[PixOrCopyLiteral(v, 3)];
- ++histo->red_[PixOrCopyLiteral(v, 2)];
- ++histo->literal_[PixOrCopyLiteral(v, 1)];
- ++histo->blue_[PixOrCopyLiteral(v, 0)];
- } else if (PixOrCopyIsCacheIdx(v)) {
- const int literal_ix =
- NUM_LITERAL_CODES + NUM_LENGTH_CODES + PixOrCopyCacheIdx(v);
- assert(histo->palette_code_bits_ != 0);
- ++histo->literal_[literal_ix];
- } else {
- int code, extra_bits;
- VP8LPrefixEncodeBits(PixOrCopyLength(v), &code, &extra_bits);
- ++histo->literal_[NUM_LITERAL_CODES + code];
- if (distance_modifier == NULL) {
- VP8LPrefixEncodeBits(PixOrCopyDistance(v), &code, &extra_bits);
- } else {
- VP8LPrefixEncodeBits(
- distance_modifier(distance_modifier_arg0, PixOrCopyDistance(v)),
- &code, &extra_bits);
- }
- ++histo->distance_[code];
- }
-}
-
-// -----------------------------------------------------------------------------
-// Entropy-related functions.
-
-static WEBP_INLINE double BitsEntropyRefine(const VP8LBitEntropy* entropy) {
- double mix;
- if (entropy->nonzeros < 5) {
- if (entropy->nonzeros <= 1) {
- return 0;
- }
- // Two symbols, they will be 0 and 1 in a Huffman code.
- // Let's mix in a bit of entropy to favor good clustering when
- // distributions of these are combined.
- if (entropy->nonzeros == 2) {
- return 0.99 * entropy->sum + 0.01 * entropy->entropy;
- }
- // No matter what the entropy says, we cannot be better than min_limit
- // with Huffman coding. I am mixing a bit of entropy into the
- // min_limit since it produces much better (~0.5 %) compression results
- // perhaps because of better entropy clustering.
- if (entropy->nonzeros == 3) {
- mix = 0.95;
- } else {
- mix = 0.7; // nonzeros == 4.
- }
- } else {
- mix = 0.627;
- }
-
- {
- double min_limit = 2 * entropy->sum - entropy->max_val;
- min_limit = mix * min_limit + (1.0 - mix) * entropy->entropy;
- return (entropy->entropy < min_limit) ? min_limit : entropy->entropy;
- }
-}
-
-double VP8LBitsEntropy(const uint32_t* const array, int n) {
- VP8LBitEntropy entropy;
- VP8LBitsEntropyUnrefined(array, n, &entropy);
-
- return BitsEntropyRefine(&entropy);
-}
-
-static double InitialHuffmanCost(void) {
- // Small bias because Huffman code length is typically not stored in
- // full length.
- static const int kHuffmanCodeOfHuffmanCodeSize = CODE_LENGTH_CODES * 3;
- static const double kSmallBias = 9.1;
- return kHuffmanCodeOfHuffmanCodeSize - kSmallBias;
-}
-
-// Finalize the Huffman cost based on streak numbers and length type (<3 or >=3)
-static double FinalHuffmanCost(const VP8LStreaks* const stats) {
- // The constants in this function are experimental and got rounded from
- // their original values in 1/8 when switched to 1/1024.
- double retval = InitialHuffmanCost();
- // Second coefficient: Many zeros in the histogram are covered efficiently
- // by a run-length encode. Originally 2/8.
- retval += stats->counts[0] * 1.5625 + 0.234375 * stats->streaks[0][1];
- // Second coefficient: Constant values are encoded less efficiently, but still
- // RLE'ed. Originally 6/8.
- retval += stats->counts[1] * 2.578125 + 0.703125 * stats->streaks[1][1];
- // 0s are usually encoded more efficiently than non-0s.
- // Originally 15/8.
- retval += 1.796875 * stats->streaks[0][0];
- // Originally 26/8.
- retval += 3.28125 * stats->streaks[1][0];
- return retval;
-}
-
-// Get the symbol entropy for the distribution 'population'.
-// Set 'trivial_sym', if there's only one symbol present in the distribution.
-static double PopulationCost(const uint32_t* const population, int length,
- uint32_t* const trivial_sym,
- uint8_t* const is_used) {
- VP8LBitEntropy bit_entropy;
- VP8LStreaks stats;
- VP8LGetEntropyUnrefined(population, length, &bit_entropy, &stats);
- if (trivial_sym != NULL) {
- *trivial_sym = (bit_entropy.nonzeros == 1) ? bit_entropy.nonzero_code
- : VP8L_NON_TRIVIAL_SYM;
- }
- // The histogram is used if there is at least one non-zero streak.
- *is_used = (stats.streaks[1][0] != 0 || stats.streaks[1][1] != 0);
-
- return BitsEntropyRefine(&bit_entropy) + FinalHuffmanCost(&stats);
-}
-
-// trivial_at_end is 1 if the two histograms only have one element that is
-// non-zero: both the zero-th one, or both the last one.
-static WEBP_INLINE double GetCombinedEntropy(const uint32_t* const X,
- const uint32_t* const Y,
- int length, int is_X_used,
- int is_Y_used,
- int trivial_at_end) {
- VP8LStreaks stats;
- if (trivial_at_end) {
- // This configuration is due to palettization that transforms an indexed
- // pixel into 0xff000000 | (pixel << 8) in VP8LBundleColorMap.
- // BitsEntropyRefine is 0 for histograms with only one non-zero value.
- // Only FinalHuffmanCost needs to be evaluated.
- memset(&stats, 0, sizeof(stats));
- // Deal with the non-zero value at index 0 or length-1.
- stats.streaks[1][0] = 1;
- // Deal with the following/previous zero streak.
- stats.counts[0] = 1;
- stats.streaks[0][1] = length - 1;
- return FinalHuffmanCost(&stats);
- } else {
- VP8LBitEntropy bit_entropy;
- if (is_X_used) {
- if (is_Y_used) {
- VP8LGetCombinedEntropyUnrefined(X, Y, length, &bit_entropy, &stats);
- } else {
- VP8LGetEntropyUnrefined(X, length, &bit_entropy, &stats);
- }
- } else {
- if (is_Y_used) {
- VP8LGetEntropyUnrefined(Y, length, &bit_entropy, &stats);
- } else {
- memset(&stats, 0, sizeof(stats));
- stats.counts[0] = 1;
- stats.streaks[0][length > 3] = length;
- VP8LBitEntropyInit(&bit_entropy);
- }
- }
-
- return BitsEntropyRefine(&bit_entropy) + FinalHuffmanCost(&stats);
- }
-}
-
-// Estimates the Entropy + Huffman + other block overhead size cost.
-double VP8LHistogramEstimateBits(VP8LHistogram* const p) {
- return
- PopulationCost(p->literal_, VP8LHistogramNumCodes(p->palette_code_bits_),
- NULL, &p->is_used_[0])
- + PopulationCost(p->red_, NUM_LITERAL_CODES, NULL, &p->is_used_[1])
- + PopulationCost(p->blue_, NUM_LITERAL_CODES, NULL, &p->is_used_[2])
- + PopulationCost(p->alpha_, NUM_LITERAL_CODES, NULL, &p->is_used_[3])
- + PopulationCost(p->distance_, NUM_DISTANCE_CODES, NULL, &p->is_used_[4])
- + VP8LExtraCost(p->literal_ + NUM_LITERAL_CODES, NUM_LENGTH_CODES)
- + VP8LExtraCost(p->distance_, NUM_DISTANCE_CODES);
-}
-
-// -----------------------------------------------------------------------------
-// Various histogram combine/cost-eval functions
-
-static int GetCombinedHistogramEntropy(const VP8LHistogram* const a,
- const VP8LHistogram* const b,
- double cost_threshold,
- double* cost) {
- const int palette_code_bits = a->palette_code_bits_;
- int trivial_at_end = 0;
- assert(a->palette_code_bits_ == b->palette_code_bits_);
- *cost += GetCombinedEntropy(a->literal_, b->literal_,
- VP8LHistogramNumCodes(palette_code_bits),
- a->is_used_[0], b->is_used_[0], 0);
- *cost += VP8LExtraCostCombined(a->literal_ + NUM_LITERAL_CODES,
- b->literal_ + NUM_LITERAL_CODES,
- NUM_LENGTH_CODES);
- if (*cost > cost_threshold) return 0;
-
- if (a->trivial_symbol_ != VP8L_NON_TRIVIAL_SYM &&
- a->trivial_symbol_ == b->trivial_symbol_) {
- // A, R and B are all 0 or 0xff.
- const uint32_t color_a = (a->trivial_symbol_ >> 24) & 0xff;
- const uint32_t color_r = (a->trivial_symbol_ >> 16) & 0xff;
- const uint32_t color_b = (a->trivial_symbol_ >> 0) & 0xff;
- if ((color_a == 0 || color_a == 0xff) &&
- (color_r == 0 || color_r == 0xff) &&
- (color_b == 0 || color_b == 0xff)) {
- trivial_at_end = 1;
- }
- }
-
- *cost +=
- GetCombinedEntropy(a->red_, b->red_, NUM_LITERAL_CODES, a->is_used_[1],
- b->is_used_[1], trivial_at_end);
- if (*cost > cost_threshold) return 0;
-
- *cost +=
- GetCombinedEntropy(a->blue_, b->blue_, NUM_LITERAL_CODES, a->is_used_[2],
- b->is_used_[2], trivial_at_end);
- if (*cost > cost_threshold) return 0;
-
- *cost +=
- GetCombinedEntropy(a->alpha_, b->alpha_, NUM_LITERAL_CODES,
- a->is_used_[3], b->is_used_[3], trivial_at_end);
- if (*cost > cost_threshold) return 0;
-
- *cost +=
- GetCombinedEntropy(a->distance_, b->distance_, NUM_DISTANCE_CODES,
- a->is_used_[4], b->is_used_[4], 0);
- *cost +=
- VP8LExtraCostCombined(a->distance_, b->distance_, NUM_DISTANCE_CODES);
- if (*cost > cost_threshold) return 0;
-
- return 1;
-}
-
-static WEBP_INLINE void HistogramAdd(const VP8LHistogram* const a,
- const VP8LHistogram* const b,
- VP8LHistogram* const out) {
- VP8LHistogramAdd(a, b, out);
- out->trivial_symbol_ = (a->trivial_symbol_ == b->trivial_symbol_)
- ? a->trivial_symbol_
- : VP8L_NON_TRIVIAL_SYM;
-}
-
-// Performs out = a + b, computing the cost C(a+b) - C(a) - C(b) while comparing
-// to the threshold value 'cost_threshold'. The score returned is
-// Score = C(a+b) - C(a) - C(b), where C(a) + C(b) is known and fixed.
-// Since the previous score passed is 'cost_threshold', we only need to compare
-// the partial cost against 'cost_threshold + C(a) + C(b)' to possibly bail-out
-// early.
-static double HistogramAddEval(const VP8LHistogram* const a,
- const VP8LHistogram* const b,
- VP8LHistogram* const out,
- double cost_threshold) {
- double cost = 0;
- const double sum_cost = a->bit_cost_ + b->bit_cost_;
- cost_threshold += sum_cost;
-
- if (GetCombinedHistogramEntropy(a, b, cost_threshold, &cost)) {
- HistogramAdd(a, b, out);
- out->bit_cost_ = cost;
- out->palette_code_bits_ = a->palette_code_bits_;
- }
-
- return cost - sum_cost;
-}
-
-// Same as HistogramAddEval(), except that the resulting histogram
-// is not stored. Only the cost C(a+b) - C(a) is evaluated. We omit
-// the term C(b) which is constant over all the evaluations.
-static double HistogramAddThresh(const VP8LHistogram* const a,
- const VP8LHistogram* const b,
- double cost_threshold) {
- double cost;
- assert(a != NULL && b != NULL);
- cost = -a->bit_cost_;
- GetCombinedHistogramEntropy(a, b, cost_threshold, &cost);
- return cost;
-}
-
-// -----------------------------------------------------------------------------
-
-// The structure to keep track of cost range for the three dominant entropy
-// symbols.
-// TODO(skal): Evaluate if float can be used here instead of double for
-// representing the entropy costs.
-typedef struct {
- double literal_max_;
- double literal_min_;
- double red_max_;
- double red_min_;
- double blue_max_;
- double blue_min_;
-} DominantCostRange;
-
-static void DominantCostRangeInit(DominantCostRange* const c) {
- c->literal_max_ = 0.;
- c->literal_min_ = MAX_COST;
- c->red_max_ = 0.;
- c->red_min_ = MAX_COST;
- c->blue_max_ = 0.;
- c->blue_min_ = MAX_COST;
-}
-
-static void UpdateDominantCostRange(
- const VP8LHistogram* const h, DominantCostRange* const c) {
- if (c->literal_max_ < h->literal_cost_) c->literal_max_ = h->literal_cost_;
- if (c->literal_min_ > h->literal_cost_) c->literal_min_ = h->literal_cost_;
- if (c->red_max_ < h->red_cost_) c->red_max_ = h->red_cost_;
- if (c->red_min_ > h->red_cost_) c->red_min_ = h->red_cost_;
- if (c->blue_max_ < h->blue_cost_) c->blue_max_ = h->blue_cost_;
- if (c->blue_min_ > h->blue_cost_) c->blue_min_ = h->blue_cost_;
-}
-
-static void UpdateHistogramCost(VP8LHistogram* const h) {
- uint32_t alpha_sym, red_sym, blue_sym;
- const double alpha_cost =
- PopulationCost(h->alpha_, NUM_LITERAL_CODES, &alpha_sym,
- &h->is_used_[3]);
- const double distance_cost =
- PopulationCost(h->distance_, NUM_DISTANCE_CODES, NULL, &h->is_used_[4]) +
- VP8LExtraCost(h->distance_, NUM_DISTANCE_CODES);
- const int num_codes = VP8LHistogramNumCodes(h->palette_code_bits_);
- h->literal_cost_ =
- PopulationCost(h->literal_, num_codes, NULL, &h->is_used_[0]) +
- VP8LExtraCost(h->literal_ + NUM_LITERAL_CODES, NUM_LENGTH_CODES);
- h->red_cost_ =
- PopulationCost(h->red_, NUM_LITERAL_CODES, &red_sym, &h->is_used_[1]);
- h->blue_cost_ =
- PopulationCost(h->blue_, NUM_LITERAL_CODES, &blue_sym, &h->is_used_[2]);
- h->bit_cost_ = h->literal_cost_ + h->red_cost_ + h->blue_cost_ +
- alpha_cost + distance_cost;
- if ((alpha_sym | red_sym | blue_sym) == VP8L_NON_TRIVIAL_SYM) {
- h->trivial_symbol_ = VP8L_NON_TRIVIAL_SYM;
- } else {
- h->trivial_symbol_ =
- ((uint32_t)alpha_sym << 24) | (red_sym << 16) | (blue_sym << 0);
- }
-}
-
-static int GetBinIdForEntropy(double min, double max, double val) {
- const double range = max - min;
- if (range > 0.) {
- const double delta = val - min;
- return (int)((NUM_PARTITIONS - 1e-6) * delta / range);
- } else {
- return 0;
- }
-}
-
-static int GetHistoBinIndex(const VP8LHistogram* const h,
- const DominantCostRange* const c, int low_effort) {
- int bin_id = GetBinIdForEntropy(c->literal_min_, c->literal_max_,
- h->literal_cost_);
- assert(bin_id < NUM_PARTITIONS);
- if (!low_effort) {
- bin_id = bin_id * NUM_PARTITIONS
- + GetBinIdForEntropy(c->red_min_, c->red_max_, h->red_cost_);
- bin_id = bin_id * NUM_PARTITIONS
- + GetBinIdForEntropy(c->blue_min_, c->blue_max_, h->blue_cost_);
- assert(bin_id < BIN_SIZE);
- }
- return bin_id;
-}
-
-// Construct the histograms from backward references.
-static void HistogramBuild(
- int xsize, int histo_bits, const VP8LBackwardRefs* const backward_refs,
- VP8LHistogramSet* const image_histo) {
- int x = 0, y = 0;
- const int histo_xsize = VP8LSubSampleSize(xsize, histo_bits);
- VP8LHistogram** const histograms = image_histo->histograms;
- VP8LRefsCursor c = VP8LRefsCursorInit(backward_refs);
- assert(histo_bits > 0);
- VP8LHistogramSetClear(image_histo);
- while (VP8LRefsCursorOk(&c)) {
- const PixOrCopy* const v = c.cur_pos;
- const int ix = (y >> histo_bits) * histo_xsize + (x >> histo_bits);
- VP8LHistogramAddSinglePixOrCopy(histograms[ix], v, NULL, 0);
- x += PixOrCopyLength(v);
- while (x >= xsize) {
- x -= xsize;
- ++y;
- }
- VP8LRefsCursorNext(&c);
- }
-}
-
-// Copies the histograms and computes its bit_cost.
-static const uint16_t kInvalidHistogramSymbol = (uint16_t)(-1);
-static void HistogramCopyAndAnalyze(VP8LHistogramSet* const orig_histo,
- VP8LHistogramSet* const image_histo,
- int* const num_used,
- uint16_t* const histogram_symbols) {
- int i, cluster_id;
- int num_used_orig = *num_used;
- VP8LHistogram** const orig_histograms = orig_histo->histograms;
- VP8LHistogram** const histograms = image_histo->histograms;
- assert(image_histo->max_size == orig_histo->max_size);
- for (cluster_id = 0, i = 0; i < orig_histo->max_size; ++i) {
- VP8LHistogram* const histo = orig_histograms[i];
- UpdateHistogramCost(histo);
-
- // Skip the histogram if it is completely empty, which can happen for tiles
- // with no information (when they are skipped because of LZ77).
- if (!histo->is_used_[0] && !histo->is_used_[1] && !histo->is_used_[2]
- && !histo->is_used_[3] && !histo->is_used_[4]) {
- // The first histogram is always used. If an histogram is empty, we set
- // its id to be the same as the previous one: this will improve
- // compressibility for later LZ77.
- assert(i > 0);
- HistogramSetRemoveHistogram(image_histo, i, num_used);
- HistogramSetRemoveHistogram(orig_histo, i, &num_used_orig);
- histogram_symbols[i] = kInvalidHistogramSymbol;
- } else {
- // Copy histograms from orig_histo[] to image_histo[].
- HistogramCopy(histo, histograms[i]);
- histogram_symbols[i] = cluster_id++;
- assert(cluster_id <= image_histo->max_size);
- }
- }
-}
-
-// Partition histograms to different entropy bins for three dominant (literal,
-// red and blue) symbol costs and compute the histogram aggregate bit_cost.
-static void HistogramAnalyzeEntropyBin(VP8LHistogramSet* const image_histo,
- uint16_t* const bin_map,
- int low_effort) {
- int i;
- VP8LHistogram** const histograms = image_histo->histograms;
- const int histo_size = image_histo->size;
- DominantCostRange cost_range;
- DominantCostRangeInit(&cost_range);
-
- // Analyze the dominant (literal, red and blue) entropy costs.
- for (i = 0; i < histo_size; ++i) {
- if (histograms[i] == NULL) continue;
- UpdateDominantCostRange(histograms[i], &cost_range);
- }
-
- // bin-hash histograms on three of the dominant (literal, red and blue)
- // symbol costs and store the resulting bin_id for each histogram.
- for (i = 0; i < histo_size; ++i) {
- // bin_map[i] is not set to a special value as its use will later be guarded
- // by another (histograms[i] == NULL).
- if (histograms[i] == NULL) continue;
- bin_map[i] = GetHistoBinIndex(histograms[i], &cost_range, low_effort);
- }
-}
-
-// Merges some histograms with same bin_id together if it's advantageous.
-// Sets the remaining histograms to NULL.
-static void HistogramCombineEntropyBin(VP8LHistogramSet* const image_histo,
- int* num_used,
- const uint16_t* const clusters,
- uint16_t* const cluster_mappings,
- VP8LHistogram* cur_combo,
- const uint16_t* const bin_map,
- int num_bins,
- double combine_cost_factor,
- int low_effort) {
- VP8LHistogram** const histograms = image_histo->histograms;
- int idx;
- struct {
- int16_t first; // position of the histogram that accumulates all
- // histograms with the same bin_id
- uint16_t num_combine_failures; // number of combine failures per bin_id
- } bin_info[BIN_SIZE];
-
- assert(num_bins <= BIN_SIZE);
- for (idx = 0; idx < num_bins; ++idx) {
- bin_info[idx].first = -1;
- bin_info[idx].num_combine_failures = 0;
- }
-
- // By default, a cluster matches itself.
- for (idx = 0; idx < *num_used; ++idx) cluster_mappings[idx] = idx;
- for (idx = 0; idx < image_histo->size; ++idx) {
- int bin_id, first;
- if (histograms[idx] == NULL) continue;
- bin_id = bin_map[idx];
- first = bin_info[bin_id].first;
- if (first == -1) {
- bin_info[bin_id].first = idx;
- } else if (low_effort) {
- HistogramAdd(histograms[idx], histograms[first], histograms[first]);
- HistogramSetRemoveHistogram(image_histo, idx, num_used);
- cluster_mappings[clusters[idx]] = clusters[first];
- } else {
- // try to merge #idx into #first (both share the same bin_id)
- const double bit_cost = histograms[idx]->bit_cost_;
- const double bit_cost_thresh = -bit_cost * combine_cost_factor;
- const double curr_cost_diff =
- HistogramAddEval(histograms[first], histograms[idx],
- cur_combo, bit_cost_thresh);
- if (curr_cost_diff < bit_cost_thresh) {
- // Try to merge two histograms only if the combo is a trivial one or
- // the two candidate histograms are already non-trivial.
- // For some images, 'try_combine' turns out to be false for a lot of
- // histogram pairs. In that case, we fallback to combining
- // histograms as usual to avoid increasing the header size.
- const int try_combine =
- (cur_combo->trivial_symbol_ != VP8L_NON_TRIVIAL_SYM) ||
- ((histograms[idx]->trivial_symbol_ == VP8L_NON_TRIVIAL_SYM) &&
- (histograms[first]->trivial_symbol_ == VP8L_NON_TRIVIAL_SYM));
- const int max_combine_failures = 32;
- if (try_combine ||
- bin_info[bin_id].num_combine_failures >= max_combine_failures) {
- // move the (better) merged histogram to its final slot
- HistogramSwap(&cur_combo, &histograms[first]);
- HistogramSetRemoveHistogram(image_histo, idx, num_used);
- cluster_mappings[clusters[idx]] = clusters[first];
- } else {
- ++bin_info[bin_id].num_combine_failures;
- }
- }
- }
- }
- if (low_effort) {
- // for low_effort case, update the final cost when everything is merged
- for (idx = 0; idx < image_histo->size; ++idx) {
- if (histograms[idx] == NULL) continue;
- UpdateHistogramCost(histograms[idx]);
- }
- }
-}
-
-// Implement a Lehmer random number generator with a multiplicative constant of
-// 48271 and a modulo constant of 2^31 - 1.
-static uint32_t MyRand(uint32_t* const seed) {
- *seed = (uint32_t)(((uint64_t)(*seed) * 48271u) % 2147483647u);
- assert(*seed > 0);
- return *seed;
-}
-
-// -----------------------------------------------------------------------------
-// Histogram pairs priority queue
-
-// Pair of histograms. Negative idx1 value means that pair is out-of-date.
-typedef struct {
- int idx1;
- int idx2;
- double cost_diff;
- double cost_combo;
-} HistogramPair;
-
-typedef struct {
- HistogramPair* queue;
- int size;
- int max_size;
-} HistoQueue;
-
-static int HistoQueueInit(HistoQueue* const histo_queue, const int max_size) {
- histo_queue->size = 0;
- histo_queue->max_size = max_size;
- // We allocate max_size + 1 because the last element at index "size" is
- // used as temporary data (and it could be up to max_size).
- histo_queue->queue = (HistogramPair*)WebPSafeMalloc(
- histo_queue->max_size + 1, sizeof(*histo_queue->queue));
- return histo_queue->queue != NULL;
-}
-
-static void HistoQueueClear(HistoQueue* const histo_queue) {
- assert(histo_queue != NULL);
- WebPSafeFree(histo_queue->queue);
- histo_queue->size = 0;
- histo_queue->max_size = 0;
-}
-
-// Pop a specific pair in the queue by replacing it with the last one
-// and shrinking the queue.
-static void HistoQueuePopPair(HistoQueue* const histo_queue,
- HistogramPair* const pair) {
- assert(pair >= histo_queue->queue &&
- pair < (histo_queue->queue + histo_queue->size));
- assert(histo_queue->size > 0);
- *pair = histo_queue->queue[histo_queue->size - 1];
- --histo_queue->size;
-}
-
-// Check whether a pair in the queue should be updated as head or not.
-static void HistoQueueUpdateHead(HistoQueue* const histo_queue,
- HistogramPair* const pair) {
- assert(pair->cost_diff < 0.);
- assert(pair >= histo_queue->queue &&
- pair < (histo_queue->queue + histo_queue->size));
- assert(histo_queue->size > 0);
- if (pair->cost_diff < histo_queue->queue[0].cost_diff) {
- // Replace the best pair.
- const HistogramPair tmp = histo_queue->queue[0];
- histo_queue->queue[0] = *pair;
- *pair = tmp;
- }
-}
-
-// Update the cost diff and combo of a pair of histograms. This needs to be
-// called when the the histograms have been merged with a third one.
-static void HistoQueueUpdatePair(const VP8LHistogram* const h1,
- const VP8LHistogram* const h2,
- double threshold,
- HistogramPair* const pair) {
- const double sum_cost = h1->bit_cost_ + h2->bit_cost_;
- pair->cost_combo = 0.;
- GetCombinedHistogramEntropy(h1, h2, sum_cost + threshold, &pair->cost_combo);
- pair->cost_diff = pair->cost_combo - sum_cost;
-}
-
-// Create a pair from indices "idx1" and "idx2" provided its cost
-// is inferior to "threshold", a negative entropy.
-// It returns the cost of the pair, or 0. if it superior to threshold.
-static double HistoQueuePush(HistoQueue* const histo_queue,
- VP8LHistogram** const histograms, int idx1,
- int idx2, double threshold) {
- const VP8LHistogram* h1;
- const VP8LHistogram* h2;
- HistogramPair pair;
-
- // Stop here if the queue is full.
- if (histo_queue->size == histo_queue->max_size) return 0.;
- assert(threshold <= 0.);
- if (idx1 > idx2) {
- const int tmp = idx2;
- idx2 = idx1;
- idx1 = tmp;
- }
- pair.idx1 = idx1;
- pair.idx2 = idx2;
- h1 = histograms[idx1];
- h2 = histograms[idx2];
-
- HistoQueueUpdatePair(h1, h2, threshold, &pair);
-
- // Do not even consider the pair if it does not improve the entropy.
- if (pair.cost_diff >= threshold) return 0.;
-
- histo_queue->queue[histo_queue->size++] = pair;
- HistoQueueUpdateHead(histo_queue, &histo_queue->queue[histo_queue->size - 1]);
-
- return pair.cost_diff;
-}
-
-// -----------------------------------------------------------------------------
-
-// Combines histograms by continuously choosing the one with the highest cost
-// reduction.
-static int HistogramCombineGreedy(VP8LHistogramSet* const image_histo,
- int* const num_used) {
- int ok = 0;
- const int image_histo_size = image_histo->size;
- int i, j;
- VP8LHistogram** const histograms = image_histo->histograms;
- // Priority queue of histogram pairs.
- HistoQueue histo_queue;
-
- // image_histo_size^2 for the queue size is safe. If you look at
- // HistogramCombineGreedy, and imagine that UpdateQueueFront always pushes
- // data to the queue, you insert at most:
- // - image_histo_size*(image_histo_size-1)/2 (the first two for loops)
- // - image_histo_size - 1 in the last for loop at the first iteration of
- // the while loop, image_histo_size - 2 at the second iteration ...
- // therefore image_histo_size*(image_histo_size-1)/2 overall too
- if (!HistoQueueInit(&histo_queue, image_histo_size * image_histo_size)) {
- goto End;
- }
-
- for (i = 0; i < image_histo_size; ++i) {
- if (image_histo->histograms[i] == NULL) continue;
- for (j = i + 1; j < image_histo_size; ++j) {
- // Initialize queue.
- if (image_histo->histograms[j] == NULL) continue;
- HistoQueuePush(&histo_queue, histograms, i, j, 0.);
- }
- }
-
- while (histo_queue.size > 0) {
- const int idx1 = histo_queue.queue[0].idx1;
- const int idx2 = histo_queue.queue[0].idx2;
- HistogramAdd(histograms[idx2], histograms[idx1], histograms[idx1]);
- histograms[idx1]->bit_cost_ = histo_queue.queue[0].cost_combo;
-
- // Remove merged histogram.
- HistogramSetRemoveHistogram(image_histo, idx2, num_used);
-
- // Remove pairs intersecting the just combined best pair.
- for (i = 0; i < histo_queue.size;) {
- HistogramPair* const p = histo_queue.queue + i;
- if (p->idx1 == idx1 || p->idx2 == idx1 ||
- p->idx1 == idx2 || p->idx2 == idx2) {
- HistoQueuePopPair(&histo_queue, p);
- } else {
- HistoQueueUpdateHead(&histo_queue, p);
- ++i;
- }
- }
-
- // Push new pairs formed with combined histogram to the queue.
- for (i = 0; i < image_histo->size; ++i) {
- if (i == idx1 || image_histo->histograms[i] == NULL) continue;
- HistoQueuePush(&histo_queue, image_histo->histograms, idx1, i, 0.);
- }
- }
-
- ok = 1;
-
- End:
- HistoQueueClear(&histo_queue);
- return ok;
-}
-
-// Perform histogram aggregation using a stochastic approach.
-// 'do_greedy' is set to 1 if a greedy approach needs to be performed
-// afterwards, 0 otherwise.
-static int PairComparison(const void* idx1, const void* idx2) {
- // To be used with bsearch: <0 when *idx1<*idx2, >0 if >, 0 when ==.
- return (*(int*) idx1 - *(int*) idx2);
-}
-static int HistogramCombineStochastic(VP8LHistogramSet* const image_histo,
- int* const num_used, int min_cluster_size,
- int* const do_greedy) {
- int j, iter;
- uint32_t seed = 1;
- int tries_with_no_success = 0;
- const int outer_iters = *num_used;
- const int num_tries_no_success = outer_iters / 2;
- VP8LHistogram** const histograms = image_histo->histograms;
- // Priority queue of histogram pairs. Its size of 'kHistoQueueSize'
- // impacts the quality of the compression and the speed: the smaller the
- // faster but the worse for the compression.
- HistoQueue histo_queue;
- const int kHistoQueueSize = 9;
- int ok = 0;
- // mapping from an index in image_histo with no NULL histogram to the full
- // blown image_histo.
- int* mappings;
-
- if (*num_used < min_cluster_size) {
- *do_greedy = 1;
- return 1;
- }
-
- mappings = (int*) WebPSafeMalloc(*num_used, sizeof(*mappings));
- if (mappings == NULL) return 0;
- if (!HistoQueueInit(&histo_queue, kHistoQueueSize)) goto End;
- // Fill the initial mapping.
- for (j = 0, iter = 0; iter < image_histo->size; ++iter) {
- if (histograms[iter] == NULL) continue;
- mappings[j++] = iter;
- }
- assert(j == *num_used);
-
- // Collapse similar histograms in 'image_histo'.
- for (iter = 0;
- iter < outer_iters && *num_used >= min_cluster_size &&
- ++tries_with_no_success < num_tries_no_success;
- ++iter) {
- int* mapping_index;
- double best_cost =
- (histo_queue.size == 0) ? 0. : histo_queue.queue[0].cost_diff;
- int best_idx1 = -1, best_idx2 = 1;
- const uint32_t rand_range = (*num_used - 1) * (*num_used);
- // (*num_used) / 2 was chosen empirically. Less means faster but worse
- // compression.
- const int num_tries = (*num_used) / 2;
-
- // Pick random samples.
- for (j = 0; *num_used >= 2 && j < num_tries; ++j) {
- double curr_cost;
- // Choose two different histograms at random and try to combine them.
- const uint32_t tmp = MyRand(&seed) % rand_range;
- uint32_t idx1 = tmp / (*num_used - 1);
- uint32_t idx2 = tmp % (*num_used - 1);
- if (idx2 >= idx1) ++idx2;
- idx1 = mappings[idx1];
- idx2 = mappings[idx2];
-
- // Calculate cost reduction on combination.
- curr_cost =
- HistoQueuePush(&histo_queue, histograms, idx1, idx2, best_cost);
- if (curr_cost < 0) { // found a better pair?
- best_cost = curr_cost;
- // Empty the queue if we reached full capacity.
- if (histo_queue.size == histo_queue.max_size) break;
- }
- }
- if (histo_queue.size == 0) continue;
-
- // Get the best histograms.
- best_idx1 = histo_queue.queue[0].idx1;
- best_idx2 = histo_queue.queue[0].idx2;
- assert(best_idx1 < best_idx2);
- // Pop best_idx2 from mappings.
- mapping_index = (int*) bsearch(&best_idx2, mappings, *num_used,
- sizeof(best_idx2), &PairComparison);
- assert(mapping_index != NULL);
- memmove(mapping_index, mapping_index + 1, sizeof(*mapping_index) *
- ((*num_used) - (mapping_index - mappings) - 1));
- // Merge the histograms and remove best_idx2 from the queue.
- HistogramAdd(histograms[best_idx2], histograms[best_idx1],
- histograms[best_idx1]);
- histograms[best_idx1]->bit_cost_ = histo_queue.queue[0].cost_combo;
- HistogramSetRemoveHistogram(image_histo, best_idx2, num_used);
- // Parse the queue and update each pair that deals with best_idx1,
- // best_idx2 or image_histo_size.
- for (j = 0; j < histo_queue.size;) {
- HistogramPair* const p = histo_queue.queue + j;
- const int is_idx1_best = p->idx1 == best_idx1 || p->idx1 == best_idx2;
- const int is_idx2_best = p->idx2 == best_idx1 || p->idx2 == best_idx2;
- int do_eval = 0;
- // The front pair could have been duplicated by a random pick so
- // check for it all the time nevertheless.
- if (is_idx1_best && is_idx2_best) {
- HistoQueuePopPair(&histo_queue, p);
- continue;
- }
- // Any pair containing one of the two best indices should only refer to
- // best_idx1. Its cost should also be updated.
- if (is_idx1_best) {
- p->idx1 = best_idx1;
- do_eval = 1;
- } else if (is_idx2_best) {
- p->idx2 = best_idx1;
- do_eval = 1;
- }
- // Make sure the index order is respected.
- if (p->idx1 > p->idx2) {
- const int tmp = p->idx2;
- p->idx2 = p->idx1;
- p->idx1 = tmp;
- }
- if (do_eval) {
- // Re-evaluate the cost of an updated pair.
- HistoQueueUpdatePair(histograms[p->idx1], histograms[p->idx2], 0., p);
- if (p->cost_diff >= 0.) {
- HistoQueuePopPair(&histo_queue, p);
- continue;
- }
- }
- HistoQueueUpdateHead(&histo_queue, p);
- ++j;
- }
- tries_with_no_success = 0;
- }
- *do_greedy = (*num_used <= min_cluster_size);
- ok = 1;
-
-End:
- HistoQueueClear(&histo_queue);
- WebPSafeFree(mappings);
- return ok;
-}
-
-// -----------------------------------------------------------------------------
-// Histogram refinement
-
-// Find the best 'out' histogram for each of the 'in' histograms.
-// At call-time, 'out' contains the histograms of the clusters.
-// Note: we assume that out[]->bit_cost_ is already up-to-date.
-static void HistogramRemap(const VP8LHistogramSet* const in,
- VP8LHistogramSet* const out,
- uint16_t* const symbols) {
- int i;
- VP8LHistogram** const in_histo = in->histograms;
- VP8LHistogram** const out_histo = out->histograms;
- const int in_size = out->max_size;
- const int out_size = out->size;
- if (out_size > 1) {
- for (i = 0; i < in_size; ++i) {
- int best_out = 0;
- double best_bits = MAX_COST;
- int k;
- if (in_histo[i] == NULL) {
- // Arbitrarily set to the previous value if unused to help future LZ77.
- symbols[i] = symbols[i - 1];
- continue;
- }
- for (k = 0; k < out_size; ++k) {
- double cur_bits;
- cur_bits = HistogramAddThresh(out_histo[k], in_histo[i], best_bits);
- if (k == 0 || cur_bits < best_bits) {
- best_bits = cur_bits;
- best_out = k;
- }
- }
- symbols[i] = best_out;
- }
- } else {
- assert(out_size == 1);
- for (i = 0; i < in_size; ++i) {
- symbols[i] = 0;
- }
- }
-
- // Recompute each out based on raw and symbols.
- VP8LHistogramSetClear(out);
- out->size = out_size;
-
- for (i = 0; i < in_size; ++i) {
- int idx;
- if (in_histo[i] == NULL) continue;
- idx = symbols[i];
- HistogramAdd(in_histo[i], out_histo[idx], out_histo[idx]);
- }
-}
-
-static double GetCombineCostFactor(int histo_size, int quality) {
- double combine_cost_factor = 0.16;
- if (quality < 90) {
- if (histo_size > 256) combine_cost_factor /= 2.;
- if (histo_size > 512) combine_cost_factor /= 2.;
- if (histo_size > 1024) combine_cost_factor /= 2.;
- if (quality <= 50) combine_cost_factor /= 2.;
- }
- return combine_cost_factor;
-}
-
-// Given a HistogramSet 'set', the mapping of clusters 'cluster_mapping' and the
-// current assignment of the cells in 'symbols', merge the clusters and
-// assign the smallest possible clusters values.
-static void OptimizeHistogramSymbols(const VP8LHistogramSet* const set,
- uint16_t* const cluster_mappings,
- int num_clusters,
- uint16_t* const cluster_mappings_tmp,
- uint16_t* const symbols) {
- int i, cluster_max;
- int do_continue = 1;
- // First, assign the lowest cluster to each pixel.
- while (do_continue) {
- do_continue = 0;
- for (i = 0; i < num_clusters; ++i) {
- int k;
- k = cluster_mappings[i];
- while (k != cluster_mappings[k]) {
- cluster_mappings[k] = cluster_mappings[cluster_mappings[k]];
- k = cluster_mappings[k];
- }
- if (k != cluster_mappings[i]) {
- do_continue = 1;
- cluster_mappings[i] = k;
- }
- }
- }
- // Create a mapping from a cluster id to its minimal version.
- cluster_max = 0;
- memset(cluster_mappings_tmp, 0,
- set->max_size * sizeof(*cluster_mappings_tmp));
- assert(cluster_mappings[0] == 0);
- // Re-map the ids.
- for (i = 0; i < set->max_size; ++i) {
- int cluster;
- if (symbols[i] == kInvalidHistogramSymbol) continue;
- cluster = cluster_mappings[symbols[i]];
- assert(symbols[i] < num_clusters);
- if (cluster > 0 && cluster_mappings_tmp[cluster] == 0) {
- ++cluster_max;
- cluster_mappings_tmp[cluster] = cluster_max;
- }
- symbols[i] = cluster_mappings_tmp[cluster];
- }
-
- // Make sure all cluster values are used.
- cluster_max = 0;
- for (i = 0; i < set->max_size; ++i) {
- if (symbols[i] == kInvalidHistogramSymbol) continue;
- if (symbols[i] <= cluster_max) continue;
- ++cluster_max;
- assert(symbols[i] == cluster_max);
- }
-}
-
-static void RemoveEmptyHistograms(VP8LHistogramSet* const image_histo) {
- uint32_t size;
- int i;
- for (i = 0, size = 0; i < image_histo->size; ++i) {
- if (image_histo->histograms[i] == NULL) continue;
- image_histo->histograms[size++] = image_histo->histograms[i];
- }
- image_histo->size = size;
-}
-
-int VP8LGetHistoImageSymbols(int xsize, int ysize,
- const VP8LBackwardRefs* const refs,
- int quality, int low_effort,
- int histogram_bits, int cache_bits,
- VP8LHistogramSet* const image_histo,
- VP8LHistogram* const tmp_histo,
- uint16_t* const histogram_symbols) {
- int ok = 0;
- const int histo_xsize =
- histogram_bits ? VP8LSubSampleSize(xsize, histogram_bits) : 1;
- const int histo_ysize =
- histogram_bits ? VP8LSubSampleSize(ysize, histogram_bits) : 1;
- const int image_histo_raw_size = histo_xsize * histo_ysize;
- VP8LHistogramSet* const orig_histo =
- VP8LAllocateHistogramSet(image_histo_raw_size, cache_bits);
- // Don't attempt linear bin-partition heuristic for
- // histograms of small sizes (as bin_map will be very sparse) and
- // maximum quality q==100 (to preserve the compression gains at that level).
- const int entropy_combine_num_bins = low_effort ? NUM_PARTITIONS : BIN_SIZE;
- int entropy_combine;
- uint16_t* const map_tmp =
- WebPSafeMalloc(2 * image_histo_raw_size, sizeof(map_tmp));
- uint16_t* const cluster_mappings = map_tmp + image_histo_raw_size;
- int num_used = image_histo_raw_size;
- if (orig_histo == NULL || map_tmp == NULL) goto Error;
-
- // Construct the histograms from backward references.
- HistogramBuild(xsize, histogram_bits, refs, orig_histo);
- // Copies the histograms and computes its bit_cost.
- // histogram_symbols is optimized
- HistogramCopyAndAnalyze(orig_histo, image_histo, &num_used,
- histogram_symbols);
-
- entropy_combine =
- (num_used > entropy_combine_num_bins * 2) && (quality < 100);
-
- if (entropy_combine) {
- uint16_t* const bin_map = map_tmp;
- const double combine_cost_factor =
- GetCombineCostFactor(image_histo_raw_size, quality);
- const uint32_t num_clusters = num_used;
-
- HistogramAnalyzeEntropyBin(image_histo, bin_map, low_effort);
- // Collapse histograms with similar entropy.
- HistogramCombineEntropyBin(image_histo, &num_used, histogram_symbols,
- cluster_mappings, tmp_histo, bin_map,
- entropy_combine_num_bins, combine_cost_factor,
- low_effort);
- OptimizeHistogramSymbols(image_histo, cluster_mappings, num_clusters,
- map_tmp, histogram_symbols);
- }
-
- // Don't combine the histograms using stochastic and greedy heuristics for
- // low-effort compression mode.
- if (!low_effort || !entropy_combine) {
- const float x = quality / 100.f;
- // cubic ramp between 1 and MAX_HISTO_GREEDY:
- const int threshold_size = (int)(1 + (x * x * x) * (MAX_HISTO_GREEDY - 1));
- int do_greedy;
- if (!HistogramCombineStochastic(image_histo, &num_used, threshold_size,
- &do_greedy)) {
- goto Error;
- }
- if (do_greedy) {
- RemoveEmptyHistograms(image_histo);
- if (!HistogramCombineGreedy(image_histo, &num_used)) {
- goto Error;
- }
- }
- }
-
- // Find the optimal map from original histograms to the final ones.
- RemoveEmptyHistograms(image_histo);
- HistogramRemap(orig_histo, image_histo, histogram_symbols);
-
- ok = 1;
-
- Error:
- VP8LFreeHistogramSet(orig_histo);
- WebPSafeFree(map_tmp);
- return ok;
-}
diff --git a/contrib/libs/libwebp/enc/histogram_enc.h b/contrib/libs/libwebp/enc/histogram_enc.h
deleted file mode 100644
index edd06bd351..0000000000
--- a/contrib/libs/libwebp/enc/histogram_enc.h
+++ /dev/null
@@ -1,128 +0,0 @@
-// Copyright 2012 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Author: Jyrki Alakuijala (jyrki@google.com)
-//
-// Models the histograms of literal and distance codes.
-
-#ifndef WEBP_ENC_HISTOGRAM_ENC_H_
-#define WEBP_ENC_HISTOGRAM_ENC_H_
-
-#include <string.h>
-
-#include "./backward_references_enc.h"
-#include "../webp/format_constants.h"
-#include "../webp/types.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// Not a trivial literal symbol.
-#define VP8L_NON_TRIVIAL_SYM (0xffffffff)
-
-// A simple container for histograms of data.
-typedef struct {
- // literal_ contains green literal, palette-code and
- // copy-length-prefix histogram
- uint32_t* literal_; // Pointer to the allocated buffer for literal.
- uint32_t red_[NUM_LITERAL_CODES];
- uint32_t blue_[NUM_LITERAL_CODES];
- uint32_t alpha_[NUM_LITERAL_CODES];
- // Backward reference prefix-code histogram.
- uint32_t distance_[NUM_DISTANCE_CODES];
- int palette_code_bits_;
- uint32_t trivial_symbol_; // True, if histograms for Red, Blue & Alpha
- // literal symbols are single valued.
- double bit_cost_; // cached value of bit cost.
- double literal_cost_; // Cached values of dominant entropy costs:
- double red_cost_; // literal, red & blue.
- double blue_cost_;
- uint8_t is_used_[5]; // 5 for literal, red, blue, alpha, distance
-} VP8LHistogram;
-
-// Collection of histograms with fixed capacity, allocated as one
-// big memory chunk. Can be destroyed by calling WebPSafeFree().
-typedef struct {
- int size; // number of slots currently in use
- int max_size; // maximum capacity
- VP8LHistogram** histograms;
-} VP8LHistogramSet;
-
-// Create the histogram.
-//
-// The input data is the PixOrCopy data, which models the literals, stop
-// codes and backward references (both distances and lengths). Also: if
-// palette_code_bits is >= 0, initialize the histogram with this value.
-void VP8LHistogramCreate(VP8LHistogram* const p,
- const VP8LBackwardRefs* const refs,
- int palette_code_bits);
-
-// Return the size of the histogram for a given cache_bits.
-int VP8LGetHistogramSize(int cache_bits);
-
-// Set the palette_code_bits and reset the stats.
-// If init_arrays is true, the arrays are also filled with 0's.
-void VP8LHistogramInit(VP8LHistogram* const p, int palette_code_bits,
- int init_arrays);
-
-// Collect all the references into a histogram (without reset)
-void VP8LHistogramStoreRefs(const VP8LBackwardRefs* const refs,
- VP8LHistogram* const histo);
-
-// Free the memory allocated for the histogram.
-void VP8LFreeHistogram(VP8LHistogram* const histo);
-
-// Free the memory allocated for the histogram set.
-void VP8LFreeHistogramSet(VP8LHistogramSet* const histo);
-
-// Allocate an array of pointer to histograms, allocated and initialized
-// using 'cache_bits'. Return NULL in case of memory error.
-VP8LHistogramSet* VP8LAllocateHistogramSet(int size, int cache_bits);
-
-// Set the histograms in set to 0.
-void VP8LHistogramSetClear(VP8LHistogramSet* const set);
-
-// Allocate and initialize histogram object with specified 'cache_bits'.
-// Returns NULL in case of memory error.
-// Special case of VP8LAllocateHistogramSet, with size equals 1.
-VP8LHistogram* VP8LAllocateHistogram(int cache_bits);
-
-// Accumulate a token 'v' into a histogram.
-void VP8LHistogramAddSinglePixOrCopy(VP8LHistogram* const histo,
- const PixOrCopy* const v,
- int (*const distance_modifier)(int, int),
- int distance_modifier_arg0);
-
-static WEBP_INLINE int VP8LHistogramNumCodes(int palette_code_bits) {
- return NUM_LITERAL_CODES + NUM_LENGTH_CODES +
- ((palette_code_bits > 0) ? (1 << palette_code_bits) : 0);
-}
-
-// Builds the histogram image.
-int VP8LGetHistoImageSymbols(int xsize, int ysize,
- const VP8LBackwardRefs* const refs,
- int quality, int low_effort,
- int histogram_bits, int cache_bits,
- VP8LHistogramSet* const image_histo,
- VP8LHistogram* const tmp_histo,
- uint16_t* const histogram_symbols);
-
-// Returns the entropy for the symbols in the input array.
-double VP8LBitsEntropy(const uint32_t* const array, int n);
-
-// Estimate how many bits the combined entropy of literals and distance
-// approximately maps to.
-double VP8LHistogramEstimateBits(VP8LHistogram* const p);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // WEBP_ENC_HISTOGRAM_ENC_H_
diff --git a/contrib/libs/libwebp/enc/iterator_enc.c b/contrib/libs/libwebp/enc/iterator_enc.c
deleted file mode 100644
index 2de6545c24..0000000000
--- a/contrib/libs/libwebp/enc/iterator_enc.c
+++ /dev/null
@@ -1,459 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// VP8Iterator: block iterator
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include <string.h>
-
-#include "./vp8i_enc.h"
-
-//------------------------------------------------------------------------------
-// VP8Iterator
-//------------------------------------------------------------------------------
-
-static void InitLeft(VP8EncIterator* const it) {
- it->y_left_[-1] = it->u_left_[-1] = it->v_left_[-1] =
- (it->y_ > 0) ? 129 : 127;
- memset(it->y_left_, 129, 16);
- memset(it->u_left_, 129, 8);
- memset(it->v_left_, 129, 8);
- it->left_nz_[8] = 0;
- if (it->top_derr_ != NULL) {
- memset(&it->left_derr_, 0, sizeof(it->left_derr_));
- }
-}
-
-static void InitTop(VP8EncIterator* const it) {
- const VP8Encoder* const enc = it->enc_;
- const size_t top_size = enc->mb_w_ * 16;
- memset(enc->y_top_, 127, 2 * top_size);
- memset(enc->nz_, 0, enc->mb_w_ * sizeof(*enc->nz_));
- if (enc->top_derr_ != NULL) {
- memset(enc->top_derr_, 0, enc->mb_w_ * sizeof(*enc->top_derr_));
- }
-}
-
-void VP8IteratorSetRow(VP8EncIterator* const it, int y) {
- VP8Encoder* const enc = it->enc_;
- it->x_ = 0;
- it->y_ = y;
- it->bw_ = &enc->parts_[y & (enc->num_parts_ - 1)];
- it->preds_ = enc->preds_ + y * 4 * enc->preds_w_;
- it->nz_ = enc->nz_;
- it->mb_ = enc->mb_info_ + y * enc->mb_w_;
- it->y_top_ = enc->y_top_;
- it->uv_top_ = enc->uv_top_;
- InitLeft(it);
-}
-
-void VP8IteratorReset(VP8EncIterator* const it) {
- VP8Encoder* const enc = it->enc_;
- VP8IteratorSetRow(it, 0);
- VP8IteratorSetCountDown(it, enc->mb_w_ * enc->mb_h_); // default
- InitTop(it);
- memset(it->bit_count_, 0, sizeof(it->bit_count_));
- it->do_trellis_ = 0;
-}
-
-void VP8IteratorSetCountDown(VP8EncIterator* const it, int count_down) {
- it->count_down_ = it->count_down0_ = count_down;
-}
-
-int VP8IteratorIsDone(const VP8EncIterator* const it) {
- return (it->count_down_ <= 0);
-}
-
-void VP8IteratorInit(VP8Encoder* const enc, VP8EncIterator* const it) {
- it->enc_ = enc;
- it->yuv_in_ = (uint8_t*)WEBP_ALIGN(it->yuv_mem_);
- it->yuv_out_ = it->yuv_in_ + YUV_SIZE_ENC;
- it->yuv_out2_ = it->yuv_out_ + YUV_SIZE_ENC;
- it->yuv_p_ = it->yuv_out2_ + YUV_SIZE_ENC;
- it->lf_stats_ = enc->lf_stats_;
- it->percent0_ = enc->percent_;
- it->y_left_ = (uint8_t*)WEBP_ALIGN(it->yuv_left_mem_ + 1);
- it->u_left_ = it->y_left_ + 16 + 16;
- it->v_left_ = it->u_left_ + 16;
- it->top_derr_ = enc->top_derr_;
- VP8IteratorReset(it);
-}
-
-int VP8IteratorProgress(const VP8EncIterator* const it, int delta) {
- VP8Encoder* const enc = it->enc_;
- if (delta && enc->pic_->progress_hook != NULL) {
- const int done = it->count_down0_ - it->count_down_;
- const int percent = (it->count_down0_ <= 0)
- ? it->percent0_
- : it->percent0_ + delta * done / it->count_down0_;
- return WebPReportProgress(enc->pic_, percent, &enc->percent_);
- }
- return 1;
-}
-
-//------------------------------------------------------------------------------
-// Import the source samples into the cache. Takes care of replicating
-// boundary pixels if necessary.
-
-static WEBP_INLINE int MinSize(int a, int b) { return (a < b) ? a : b; }
-
-static void ImportBlock(const uint8_t* src, int src_stride,
- uint8_t* dst, int w, int h, int size) {
- int i;
- for (i = 0; i < h; ++i) {
- memcpy(dst, src, w);
- if (w < size) {
- memset(dst + w, dst[w - 1], size - w);
- }
- dst += BPS;
- src += src_stride;
- }
- for (i = h; i < size; ++i) {
- memcpy(dst, dst - BPS, size);
- dst += BPS;
- }
-}
-
-static void ImportLine(const uint8_t* src, int src_stride,
- uint8_t* dst, int len, int total_len) {
- int i;
- for (i = 0; i < len; ++i, src += src_stride) dst[i] = *src;
- for (; i < total_len; ++i) dst[i] = dst[len - 1];
-}
-
-void VP8IteratorImport(VP8EncIterator* const it, uint8_t* const tmp_32) {
- const VP8Encoder* const enc = it->enc_;
- const int x = it->x_, y = it->y_;
- const WebPPicture* const pic = enc->pic_;
- const uint8_t* const ysrc = pic->y + (y * pic->y_stride + x) * 16;
- const uint8_t* const usrc = pic->u + (y * pic->uv_stride + x) * 8;
- const uint8_t* const vsrc = pic->v + (y * pic->uv_stride + x) * 8;
- const int w = MinSize(pic->width - x * 16, 16);
- const int h = MinSize(pic->height - y * 16, 16);
- const int uv_w = (w + 1) >> 1;
- const int uv_h = (h + 1) >> 1;
-
- ImportBlock(ysrc, pic->y_stride, it->yuv_in_ + Y_OFF_ENC, w, h, 16);
- ImportBlock(usrc, pic->uv_stride, it->yuv_in_ + U_OFF_ENC, uv_w, uv_h, 8);
- ImportBlock(vsrc, pic->uv_stride, it->yuv_in_ + V_OFF_ENC, uv_w, uv_h, 8);
-
- if (tmp_32 == NULL) return;
-
- // Import source (uncompressed) samples into boundary.
- if (x == 0) {
- InitLeft(it);
- } else {
- if (y == 0) {
- it->y_left_[-1] = it->u_left_[-1] = it->v_left_[-1] = 127;
- } else {
- it->y_left_[-1] = ysrc[- 1 - pic->y_stride];
- it->u_left_[-1] = usrc[- 1 - pic->uv_stride];
- it->v_left_[-1] = vsrc[- 1 - pic->uv_stride];
- }
- ImportLine(ysrc - 1, pic->y_stride, it->y_left_, h, 16);
- ImportLine(usrc - 1, pic->uv_stride, it->u_left_, uv_h, 8);
- ImportLine(vsrc - 1, pic->uv_stride, it->v_left_, uv_h, 8);
- }
-
- it->y_top_ = tmp_32 + 0;
- it->uv_top_ = tmp_32 + 16;
- if (y == 0) {
- memset(tmp_32, 127, 32 * sizeof(*tmp_32));
- } else {
- ImportLine(ysrc - pic->y_stride, 1, tmp_32, w, 16);
- ImportLine(usrc - pic->uv_stride, 1, tmp_32 + 16, uv_w, 8);
- ImportLine(vsrc - pic->uv_stride, 1, tmp_32 + 16 + 8, uv_w, 8);
- }
-}
-
-//------------------------------------------------------------------------------
-// Copy back the compressed samples into user space if requested.
-
-static void ExportBlock(const uint8_t* src, uint8_t* dst, int dst_stride,
- int w, int h) {
- while (h-- > 0) {
- memcpy(dst, src, w);
- dst += dst_stride;
- src += BPS;
- }
-}
-
-void VP8IteratorExport(const VP8EncIterator* const it) {
- const VP8Encoder* const enc = it->enc_;
- if (enc->config_->show_compressed) {
- const int x = it->x_, y = it->y_;
- const uint8_t* const ysrc = it->yuv_out_ + Y_OFF_ENC;
- const uint8_t* const usrc = it->yuv_out_ + U_OFF_ENC;
- const uint8_t* const vsrc = it->yuv_out_ + V_OFF_ENC;
- const WebPPicture* const pic = enc->pic_;
- uint8_t* const ydst = pic->y + (y * pic->y_stride + x) * 16;
- uint8_t* const udst = pic->u + (y * pic->uv_stride + x) * 8;
- uint8_t* const vdst = pic->v + (y * pic->uv_stride + x) * 8;
- int w = (pic->width - x * 16);
- int h = (pic->height - y * 16);
-
- if (w > 16) w = 16;
- if (h > 16) h = 16;
-
- // Luma plane
- ExportBlock(ysrc, ydst, pic->y_stride, w, h);
-
- { // U/V planes
- const int uv_w = (w + 1) >> 1;
- const int uv_h = (h + 1) >> 1;
- ExportBlock(usrc, udst, pic->uv_stride, uv_w, uv_h);
- ExportBlock(vsrc, vdst, pic->uv_stride, uv_w, uv_h);
- }
- }
-}
-
-//------------------------------------------------------------------------------
-// Non-zero contexts setup/teardown
-
-// Nz bits:
-// 0 1 2 3 Y
-// 4 5 6 7
-// 8 9 10 11
-// 12 13 14 15
-// 16 17 U
-// 18 19
-// 20 21 V
-// 22 23
-// 24 DC-intra16
-
-// Convert packed context to byte array
-#define BIT(nz, n) (!!((nz) & (1 << (n))))
-
-void VP8IteratorNzToBytes(VP8EncIterator* const it) {
- const int tnz = it->nz_[0], lnz = it->nz_[-1];
- int* const top_nz = it->top_nz_;
- int* const left_nz = it->left_nz_;
-
- // Top-Y
- top_nz[0] = BIT(tnz, 12);
- top_nz[1] = BIT(tnz, 13);
- top_nz[2] = BIT(tnz, 14);
- top_nz[3] = BIT(tnz, 15);
- // Top-U
- top_nz[4] = BIT(tnz, 18);
- top_nz[5] = BIT(tnz, 19);
- // Top-V
- top_nz[6] = BIT(tnz, 22);
- top_nz[7] = BIT(tnz, 23);
- // DC
- top_nz[8] = BIT(tnz, 24);
-
- // left-Y
- left_nz[0] = BIT(lnz, 3);
- left_nz[1] = BIT(lnz, 7);
- left_nz[2] = BIT(lnz, 11);
- left_nz[3] = BIT(lnz, 15);
- // left-U
- left_nz[4] = BIT(lnz, 17);
- left_nz[5] = BIT(lnz, 19);
- // left-V
- left_nz[6] = BIT(lnz, 21);
- left_nz[7] = BIT(lnz, 23);
- // left-DC is special, iterated separately
-}
-
-void VP8IteratorBytesToNz(VP8EncIterator* const it) {
- uint32_t nz = 0;
- const int* const top_nz = it->top_nz_;
- const int* const left_nz = it->left_nz_;
- // top
- nz |= (top_nz[0] << 12) | (top_nz[1] << 13);
- nz |= (top_nz[2] << 14) | (top_nz[3] << 15);
- nz |= (top_nz[4] << 18) | (top_nz[5] << 19);
- nz |= (top_nz[6] << 22) | (top_nz[7] << 23);
- nz |= (top_nz[8] << 24); // we propagate the _top_ bit, esp. for intra4
- // left
- nz |= (left_nz[0] << 3) | (left_nz[1] << 7);
- nz |= (left_nz[2] << 11);
- nz |= (left_nz[4] << 17) | (left_nz[6] << 21);
-
- *it->nz_ = nz;
-}
-
-#undef BIT
-
-//------------------------------------------------------------------------------
-// Advance to the next position, doing the bookkeeping.
-
-void VP8IteratorSaveBoundary(VP8EncIterator* const it) {
- VP8Encoder* const enc = it->enc_;
- const int x = it->x_, y = it->y_;
- const uint8_t* const ysrc = it->yuv_out_ + Y_OFF_ENC;
- const uint8_t* const uvsrc = it->yuv_out_ + U_OFF_ENC;
- if (x < enc->mb_w_ - 1) { // left
- int i;
- for (i = 0; i < 16; ++i) {
- it->y_left_[i] = ysrc[15 + i * BPS];
- }
- for (i = 0; i < 8; ++i) {
- it->u_left_[i] = uvsrc[7 + i * BPS];
- it->v_left_[i] = uvsrc[15 + i * BPS];
- }
- // top-left (before 'top'!)
- it->y_left_[-1] = it->y_top_[15];
- it->u_left_[-1] = it->uv_top_[0 + 7];
- it->v_left_[-1] = it->uv_top_[8 + 7];
- }
- if (y < enc->mb_h_ - 1) { // top
- memcpy(it->y_top_, ysrc + 15 * BPS, 16);
- memcpy(it->uv_top_, uvsrc + 7 * BPS, 8 + 8);
- }
-}
-
-int VP8IteratorNext(VP8EncIterator* const it) {
- if (++it->x_ == it->enc_->mb_w_) {
- VP8IteratorSetRow(it, ++it->y_);
- } else {
- it->preds_ += 4;
- it->mb_ += 1;
- it->nz_ += 1;
- it->y_top_ += 16;
- it->uv_top_ += 16;
- }
- return (0 < --it->count_down_);
-}
-
-//------------------------------------------------------------------------------
-// Helper function to set mode properties
-
-void VP8SetIntra16Mode(const VP8EncIterator* const it, int mode) {
- uint8_t* preds = it->preds_;
- int y;
- for (y = 0; y < 4; ++y) {
- memset(preds, mode, 4);
- preds += it->enc_->preds_w_;
- }
- it->mb_->type_ = 1;
-}
-
-void VP8SetIntra4Mode(const VP8EncIterator* const it, const uint8_t* modes) {
- uint8_t* preds = it->preds_;
- int y;
- for (y = 4; y > 0; --y) {
- memcpy(preds, modes, 4 * sizeof(*modes));
- preds += it->enc_->preds_w_;
- modes += 4;
- }
- it->mb_->type_ = 0;
-}
-
-void VP8SetIntraUVMode(const VP8EncIterator* const it, int mode) {
- it->mb_->uv_mode_ = mode;
-}
-
-void VP8SetSkip(const VP8EncIterator* const it, int skip) {
- it->mb_->skip_ = skip;
-}
-
-void VP8SetSegment(const VP8EncIterator* const it, int segment) {
- it->mb_->segment_ = segment;
-}
-
-//------------------------------------------------------------------------------
-// Intra4x4 sub-blocks iteration
-//
-// We store and update the boundary samples into an array of 37 pixels. They
-// are updated as we iterate and reconstructs each intra4x4 blocks in turn.
-// The position of the samples has the following snake pattern:
-//
-// 16|17 18 19 20|21 22 23 24|25 26 27 28|29 30 31 32|33 34 35 36 <- Top-right
-// --+-----------+-----------+-----------+-----------+
-// 15| 19| 23| 27| 31|
-// 14| 18| 22| 26| 30|
-// 13| 17| 21| 25| 29|
-// 12|13 14 15 16|17 18 19 20|21 22 23 24|25 26 27 28|
-// --+-----------+-----------+-----------+-----------+
-// 11| 15| 19| 23| 27|
-// 10| 14| 18| 22| 26|
-// 9| 13| 17| 21| 25|
-// 8| 9 10 11 12|13 14 15 16|17 18 19 20|21 22 23 24|
-// --+-----------+-----------+-----------+-----------+
-// 7| 11| 15| 19| 23|
-// 6| 10| 14| 18| 22|
-// 5| 9| 13| 17| 21|
-// 4| 5 6 7 8| 9 10 11 12|13 14 15 16|17 18 19 20|
-// --+-----------+-----------+-----------+-----------+
-// 3| 7| 11| 15| 19|
-// 2| 6| 10| 14| 18|
-// 1| 5| 9| 13| 17|
-// 0| 1 2 3 4| 5 6 7 8| 9 10 11 12|13 14 15 16|
-// --+-----------+-----------+-----------+-----------+
-
-// Array to record the position of the top sample to pass to the prediction
-// functions in dsp.c.
-static const uint8_t VP8TopLeftI4[16] = {
- 17, 21, 25, 29,
- 13, 17, 21, 25,
- 9, 13, 17, 21,
- 5, 9, 13, 17
-};
-
-void VP8IteratorStartI4(VP8EncIterator* const it) {
- const VP8Encoder* const enc = it->enc_;
- int i;
-
- it->i4_ = 0; // first 4x4 sub-block
- it->i4_top_ = it->i4_boundary_ + VP8TopLeftI4[0];
-
- // Import the boundary samples
- for (i = 0; i < 17; ++i) { // left
- it->i4_boundary_[i] = it->y_left_[15 - i];
- }
- for (i = 0; i < 16; ++i) { // top
- it->i4_boundary_[17 + i] = it->y_top_[i];
- }
- // top-right samples have a special case on the far right of the picture
- if (it->x_ < enc->mb_w_ - 1) {
- for (i = 16; i < 16 + 4; ++i) {
- it->i4_boundary_[17 + i] = it->y_top_[i];
- }
- } else { // else, replicate the last valid pixel four times
- for (i = 16; i < 16 + 4; ++i) {
- it->i4_boundary_[17 + i] = it->i4_boundary_[17 + 15];
- }
- }
- VP8IteratorNzToBytes(it); // import the non-zero context
-}
-
-int VP8IteratorRotateI4(VP8EncIterator* const it,
- const uint8_t* const yuv_out) {
- const uint8_t* const blk = yuv_out + VP8Scan[it->i4_];
- uint8_t* const top = it->i4_top_;
- int i;
-
- // Update the cache with 7 fresh samples
- for (i = 0; i <= 3; ++i) {
- top[-4 + i] = blk[i + 3 * BPS]; // store future top samples
- }
- if ((it->i4_ & 3) != 3) { // if not on the right sub-blocks #3, #7, #11, #15
- for (i = 0; i <= 2; ++i) { // store future left samples
- top[i] = blk[3 + (2 - i) * BPS];
- }
- } else { // else replicate top-right samples, as says the specs.
- for (i = 0; i <= 3; ++i) {
- top[i] = top[i + 4];
- }
- }
- // move pointers to next sub-block
- ++it->i4_;
- if (it->i4_ == 16) { // we're done
- return 0;
- }
-
- it->i4_top_ = it->i4_boundary_ + VP8TopLeftI4[it->i4_];
- return 1;
-}
-
-//------------------------------------------------------------------------------
diff --git a/contrib/libs/libwebp/enc/near_lossless_enc.c b/contrib/libs/libwebp/enc/near_lossless_enc.c
deleted file mode 100644
index 94e4838590..0000000000
--- a/contrib/libs/libwebp/enc/near_lossless_enc.c
+++ /dev/null
@@ -1,151 +0,0 @@
-// Copyright 2014 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Near-lossless image preprocessing adjusts pixel values to help
-// compressibility with a guarantee of maximum deviation between original and
-// resulting pixel values.
-//
-// Author: Jyrki Alakuijala (jyrki@google.com)
-// Converted to C by Aleksander Kramarz (akramarz@google.com)
-
-#include <assert.h>
-#include <stdlib.h>
-
-#include "../dsp/lossless_common.h"
-#include "../utils/utils.h"
-#include "./vp8li_enc.h"
-
-#if (WEBP_NEAR_LOSSLESS == 1)
-
-#define MIN_DIM_FOR_NEAR_LOSSLESS 64
-#define MAX_LIMIT_BITS 5
-
-// Quantizes the value up or down to a multiple of 1<<bits (or to 255),
-// choosing the closer one, resolving ties using bankers' rounding.
-static uint32_t FindClosestDiscretized(uint32_t a, int bits) {
- const uint32_t mask = (1u << bits) - 1;
- const uint32_t biased = a + (mask >> 1) + ((a >> bits) & 1);
- assert(bits > 0);
- if (biased > 0xff) return 0xff;
- return biased & ~mask;
-}
-
-// Applies FindClosestDiscretized to all channels of pixel.
-static uint32_t ClosestDiscretizedArgb(uint32_t a, int bits) {
- return
- (FindClosestDiscretized(a >> 24, bits) << 24) |
- (FindClosestDiscretized((a >> 16) & 0xff, bits) << 16) |
- (FindClosestDiscretized((a >> 8) & 0xff, bits) << 8) |
- (FindClosestDiscretized(a & 0xff, bits));
-}
-
-// Checks if distance between corresponding channel values of pixels a and b
-// is within the given limit.
-static int IsNear(uint32_t a, uint32_t b, int limit) {
- int k;
- for (k = 0; k < 4; ++k) {
- const int delta =
- (int)((a >> (k * 8)) & 0xff) - (int)((b >> (k * 8)) & 0xff);
- if (delta >= limit || delta <= -limit) {
- return 0;
- }
- }
- return 1;
-}
-
-static int IsSmooth(const uint32_t* const prev_row,
- const uint32_t* const curr_row,
- const uint32_t* const next_row,
- int ix, int limit) {
- // Check that all pixels in 4-connected neighborhood are smooth.
- return (IsNear(curr_row[ix], curr_row[ix - 1], limit) &&
- IsNear(curr_row[ix], curr_row[ix + 1], limit) &&
- IsNear(curr_row[ix], prev_row[ix], limit) &&
- IsNear(curr_row[ix], next_row[ix], limit));
-}
-
-// Adjusts pixel values of image with given maximum error.
-static void NearLossless(int xsize, int ysize, const uint32_t* argb_src,
- int stride, int limit_bits, uint32_t* copy_buffer,
- uint32_t* argb_dst) {
- int x, y;
- const int limit = 1 << limit_bits;
- uint32_t* prev_row = copy_buffer;
- uint32_t* curr_row = prev_row + xsize;
- uint32_t* next_row = curr_row + xsize;
- memcpy(curr_row, argb_src, xsize * sizeof(argb_src[0]));
- memcpy(next_row, argb_src + stride, xsize * sizeof(argb_src[0]));
-
- for (y = 0; y < ysize; ++y, argb_src += stride, argb_dst += xsize) {
- if (y == 0 || y == ysize - 1) {
- memcpy(argb_dst, argb_src, xsize * sizeof(argb_src[0]));
- } else {
- memcpy(next_row, argb_src + stride, xsize * sizeof(argb_src[0]));
- argb_dst[0] = argb_src[0];
- argb_dst[xsize - 1] = argb_src[xsize - 1];
- for (x = 1; x < xsize - 1; ++x) {
- if (IsSmooth(prev_row, curr_row, next_row, x, limit)) {
- argb_dst[x] = curr_row[x];
- } else {
- argb_dst[x] = ClosestDiscretizedArgb(curr_row[x], limit_bits);
- }
- }
- }
- {
- // Three-way swap.
- uint32_t* const temp = prev_row;
- prev_row = curr_row;
- curr_row = next_row;
- next_row = temp;
- }
- }
-}
-
-int VP8ApplyNearLossless(const WebPPicture* const picture, int quality,
- uint32_t* const argb_dst) {
- int i;
- const int xsize = picture->width;
- const int ysize = picture->height;
- const int stride = picture->argb_stride;
- uint32_t* const copy_buffer =
- (uint32_t*)WebPSafeMalloc(xsize * 3, sizeof(*copy_buffer));
- const int limit_bits = VP8LNearLosslessBits(quality);
- assert(argb_dst != NULL);
- assert(limit_bits > 0);
- assert(limit_bits <= MAX_LIMIT_BITS);
- if (copy_buffer == NULL) {
- return 0;
- }
- // For small icon images, don't attempt to apply near-lossless compression.
- if ((xsize < MIN_DIM_FOR_NEAR_LOSSLESS &&
- ysize < MIN_DIM_FOR_NEAR_LOSSLESS) ||
- ysize < 3) {
- for (i = 0; i < ysize; ++i) {
- memcpy(argb_dst + i * xsize, picture->argb + i * picture->argb_stride,
- xsize * sizeof(*argb_dst));
- }
- WebPSafeFree(copy_buffer);
- return 1;
- }
-
- NearLossless(xsize, ysize, picture->argb, stride, limit_bits, copy_buffer,
- argb_dst);
- for (i = limit_bits - 1; i != 0; --i) {
- NearLossless(xsize, ysize, argb_dst, xsize, i, copy_buffer, argb_dst);
- }
- WebPSafeFree(copy_buffer);
- return 1;
-}
-#else // (WEBP_NEAR_LOSSLESS == 1)
-
-// Define a stub to suppress compiler warnings.
-extern void VP8LNearLosslessStub(void);
-void VP8LNearLosslessStub(void) {}
-
-#endif // (WEBP_NEAR_LOSSLESS == 1)
diff --git a/contrib/libs/libwebp/enc/picture_csp_enc.c b/contrib/libs/libwebp/enc/picture_csp_enc.c
deleted file mode 100644
index 00abbc6c67..0000000000
--- a/contrib/libs/libwebp/enc/picture_csp_enc.c
+++ /dev/null
@@ -1,1210 +0,0 @@
-// Copyright 2014 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// WebPPicture utils for colorspace conversion
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include <assert.h>
-#include <stdlib.h>
-#include <math.h>
-
-#include "./vp8i_enc.h"
-#include "../utils/random_utils.h"
-#include "../utils/utils.h"
-#include "../dsp/dsp.h"
-#include "../dsp/lossless.h"
-#include "../dsp/yuv.h"
-
-// Uncomment to disable gamma-compression during RGB->U/V averaging
-#define USE_GAMMA_COMPRESSION
-
-// If defined, use table to compute x / alpha.
-#define USE_INVERSE_ALPHA_TABLE
-
-#ifdef WORDS_BIGENDIAN
-// uint32_t 0xff000000 is 0xff,00,00,00 in memory
-#define CHANNEL_OFFSET(i) (i)
-#else
-// uint32_t 0xff000000 is 0x00,00,00,ff in memory
-#define CHANNEL_OFFSET(i) (3-(i))
-#endif
-
-#define ALPHA_OFFSET CHANNEL_OFFSET(0)
-
-//------------------------------------------------------------------------------
-// Detection of non-trivial transparency
-
-// Returns true if alpha[] has non-0xff values.
-static int CheckNonOpaque(const uint8_t* alpha, int width, int height,
- int x_step, int y_step) {
- if (alpha == NULL) return 0;
- WebPInitAlphaProcessing();
- if (x_step == 1) {
- for (; height-- > 0; alpha += y_step) {
- if (WebPHasAlpha8b(alpha, width)) return 1;
- }
- } else {
- for (; height-- > 0; alpha += y_step) {
- if (WebPHasAlpha32b(alpha, width)) return 1;
- }
- }
- return 0;
-}
-
-// Checking for the presence of non-opaque alpha.
-int WebPPictureHasTransparency(const WebPPicture* picture) {
- if (picture == NULL) return 0;
- if (picture->use_argb) {
- const int alpha_offset = ALPHA_OFFSET;
- return CheckNonOpaque((const uint8_t*)picture->argb + alpha_offset,
- picture->width, picture->height,
- 4, picture->argb_stride * sizeof(*picture->argb));
- }
- return CheckNonOpaque(picture->a, picture->width, picture->height,
- 1, picture->a_stride);
-}
-
-//------------------------------------------------------------------------------
-// Code for gamma correction
-
-#if defined(USE_GAMMA_COMPRESSION)
-
-// gamma-compensates loss of resolution during chroma subsampling
-#define kGamma 0.80 // for now we use a different gamma value than kGammaF
-#define kGammaFix 12 // fixed-point precision for linear values
-#define kGammaScale ((1 << kGammaFix) - 1)
-#define kGammaTabFix 7 // fixed-point fractional bits precision
-#define kGammaTabScale (1 << kGammaTabFix)
-#define kGammaTabRounder (kGammaTabScale >> 1)
-#define kGammaTabSize (1 << (kGammaFix - kGammaTabFix))
-
-static int kLinearToGammaTab[kGammaTabSize + 1];
-static uint16_t kGammaToLinearTab[256];
-static volatile int kGammaTablesOk = 0;
-static void InitGammaTables(void);
-
-WEBP_DSP_INIT_FUNC(InitGammaTables) {
- if (!kGammaTablesOk) {
- int v;
- const double scale = (double)(1 << kGammaTabFix) / kGammaScale;
- const double norm = 1. / 255.;
- for (v = 0; v <= 255; ++v) {
- kGammaToLinearTab[v] =
- (uint16_t)(pow(norm * v, kGamma) * kGammaScale + .5);
- }
- for (v = 0; v <= kGammaTabSize; ++v) {
- kLinearToGammaTab[v] = (int)(255. * pow(scale * v, 1. / kGamma) + .5);
- }
- kGammaTablesOk = 1;
- }
-}
-
-static WEBP_INLINE uint32_t GammaToLinear(uint8_t v) {
- return kGammaToLinearTab[v];
-}
-
-static WEBP_INLINE int Interpolate(int v) {
- const int tab_pos = v >> (kGammaTabFix + 2); // integer part
- const int x = v & ((kGammaTabScale << 2) - 1); // fractional part
- const int v0 = kLinearToGammaTab[tab_pos];
- const int v1 = kLinearToGammaTab[tab_pos + 1];
- const int y = v1 * x + v0 * ((kGammaTabScale << 2) - x); // interpolate
- assert(tab_pos + 1 < kGammaTabSize + 1);
- return y;
-}
-
-// Convert a linear value 'v' to YUV_FIX+2 fixed-point precision
-// U/V value, suitable for RGBToU/V calls.
-static WEBP_INLINE int LinearToGamma(uint32_t base_value, int shift) {
- const int y = Interpolate(base_value << shift); // final uplifted value
- return (y + kGammaTabRounder) >> kGammaTabFix; // descale
-}
-
-#else
-
-static void InitGammaTables(void) {}
-static WEBP_INLINE uint32_t GammaToLinear(uint8_t v) { return v; }
-static WEBP_INLINE int LinearToGamma(uint32_t base_value, int shift) {
- return (int)(base_value << shift);
-}
-
-#endif // USE_GAMMA_COMPRESSION
-
-//------------------------------------------------------------------------------
-// RGB -> YUV conversion
-
-static int RGBToY(int r, int g, int b, VP8Random* const rg) {
- return (rg == NULL) ? VP8RGBToY(r, g, b, YUV_HALF)
- : VP8RGBToY(r, g, b, VP8RandomBits(rg, YUV_FIX));
-}
-
-static int RGBToU(int r, int g, int b, VP8Random* const rg) {
- return (rg == NULL) ? VP8RGBToU(r, g, b, YUV_HALF << 2)
- : VP8RGBToU(r, g, b, VP8RandomBits(rg, YUV_FIX + 2));
-}
-
-static int RGBToV(int r, int g, int b, VP8Random* const rg) {
- return (rg == NULL) ? VP8RGBToV(r, g, b, YUV_HALF << 2)
- : VP8RGBToV(r, g, b, VP8RandomBits(rg, YUV_FIX + 2));
-}
-
-//------------------------------------------------------------------------------
-// Sharp RGB->YUV conversion
-
-static const int kNumIterations = 4;
-static const int kMinDimensionIterativeConversion = 4;
-
-// We could use SFIX=0 and only uint8_t for fixed_y_t, but it produces some
-// banding sometimes. Better use extra precision.
-#define SFIX 2 // fixed-point precision of RGB and Y/W
-typedef int16_t fixed_t; // signed type with extra SFIX precision for UV
-typedef uint16_t fixed_y_t; // unsigned type with extra SFIX precision for W
-
-#define SHALF (1 << SFIX >> 1)
-#define MAX_Y_T ((256 << SFIX) - 1)
-#define SROUNDER (1 << (YUV_FIX + SFIX - 1))
-
-#if defined(USE_GAMMA_COMPRESSION)
-
-// We use tables of different size and precision for the Rec709 / BT2020
-// transfer function.
-#define kGammaF (1./0.45)
-static uint32_t kLinearToGammaTabS[kGammaTabSize + 2];
-#define GAMMA_TO_LINEAR_BITS 14
-static uint32_t kGammaToLinearTabS[MAX_Y_T + 1]; // size scales with Y_FIX
-static volatile int kGammaTablesSOk = 0;
-static void InitGammaTablesS(void);
-
-WEBP_DSP_INIT_FUNC(InitGammaTablesS) {
- assert(2 * GAMMA_TO_LINEAR_BITS < 32); // we use uint32_t intermediate values
- if (!kGammaTablesSOk) {
- int v;
- const double norm = 1. / MAX_Y_T;
- const double scale = 1. / kGammaTabSize;
- const double a = 0.09929682680944;
- const double thresh = 0.018053968510807;
- const double final_scale = 1 << GAMMA_TO_LINEAR_BITS;
- for (v = 0; v <= MAX_Y_T; ++v) {
- const double g = norm * v;
- double value;
- if (g <= thresh * 4.5) {
- value = g / 4.5;
- } else {
- const double a_rec = 1. / (1. + a);
- value = pow(a_rec * (g + a), kGammaF);
- }
- kGammaToLinearTabS[v] = (uint32_t)(value * final_scale + .5);
- }
- for (v = 0; v <= kGammaTabSize; ++v) {
- const double g = scale * v;
- double value;
- if (g <= thresh) {
- value = 4.5 * g;
- } else {
- value = (1. + a) * pow(g, 1. / kGammaF) - a;
- }
- // we already incorporate the 1/2 rounding constant here
- kLinearToGammaTabS[v] =
- (uint32_t)(MAX_Y_T * value) + (1 << GAMMA_TO_LINEAR_BITS >> 1);
- }
- // to prevent small rounding errors to cause read-overflow:
- kLinearToGammaTabS[kGammaTabSize + 1] = kLinearToGammaTabS[kGammaTabSize];
- kGammaTablesSOk = 1;
- }
-}
-
-// return value has a fixed-point precision of GAMMA_TO_LINEAR_BITS
-static WEBP_INLINE uint32_t GammaToLinearS(int v) {
- return kGammaToLinearTabS[v];
-}
-
-static WEBP_INLINE uint32_t LinearToGammaS(uint32_t value) {
- // 'value' is in GAMMA_TO_LINEAR_BITS fractional precision
- const uint32_t v = value * kGammaTabSize;
- const uint32_t tab_pos = v >> GAMMA_TO_LINEAR_BITS;
- // fractional part, in GAMMA_TO_LINEAR_BITS fixed-point precision
- const uint32_t x = v - (tab_pos << GAMMA_TO_LINEAR_BITS); // fractional part
- // v0 / v1 are in GAMMA_TO_LINEAR_BITS fixed-point precision (range [0..1])
- const uint32_t v0 = kLinearToGammaTabS[tab_pos + 0];
- const uint32_t v1 = kLinearToGammaTabS[tab_pos + 1];
- // Final interpolation. Note that rounding is already included.
- const uint32_t v2 = (v1 - v0) * x; // note: v1 >= v0.
- const uint32_t result = v0 + (v2 >> GAMMA_TO_LINEAR_BITS);
- return result;
-}
-
-#else
-
-static void InitGammaTablesS(void) {}
-static WEBP_INLINE uint32_t GammaToLinearS(int v) {
- return (v << GAMMA_TO_LINEAR_BITS) / MAX_Y_T;
-}
-static WEBP_INLINE uint32_t LinearToGammaS(uint32_t value) {
- return (MAX_Y_T * value) >> GAMMA_TO_LINEAR_BITS;
-}
-
-#endif // USE_GAMMA_COMPRESSION
-
-//------------------------------------------------------------------------------
-
-static uint8_t clip_8b(fixed_t v) {
- return (!(v & ~0xff)) ? (uint8_t)v : (v < 0) ? 0u : 255u;
-}
-
-static fixed_y_t clip_y(int y) {
- return (!(y & ~MAX_Y_T)) ? (fixed_y_t)y : (y < 0) ? 0 : MAX_Y_T;
-}
-
-//------------------------------------------------------------------------------
-
-static int RGBToGray(int r, int g, int b) {
- const int luma = 13933 * r + 46871 * g + 4732 * b + YUV_HALF;
- return (luma >> YUV_FIX);
-}
-
-static uint32_t ScaleDown(int a, int b, int c, int d) {
- const uint32_t A = GammaToLinearS(a);
- const uint32_t B = GammaToLinearS(b);
- const uint32_t C = GammaToLinearS(c);
- const uint32_t D = GammaToLinearS(d);
- return LinearToGammaS((A + B + C + D + 2) >> 2);
-}
-
-static WEBP_INLINE void UpdateW(const fixed_y_t* src, fixed_y_t* dst, int w) {
- int i;
- for (i = 0; i < w; ++i) {
- const uint32_t R = GammaToLinearS(src[0 * w + i]);
- const uint32_t G = GammaToLinearS(src[1 * w + i]);
- const uint32_t B = GammaToLinearS(src[2 * w + i]);
- const uint32_t Y = RGBToGray(R, G, B);
- dst[i] = (fixed_y_t)LinearToGammaS(Y);
- }
-}
-
-static void UpdateChroma(const fixed_y_t* src1, const fixed_y_t* src2,
- fixed_t* dst, int uv_w) {
- int i;
- for (i = 0; i < uv_w; ++i) {
- const int r = ScaleDown(src1[0 * uv_w + 0], src1[0 * uv_w + 1],
- src2[0 * uv_w + 0], src2[0 * uv_w + 1]);
- const int g = ScaleDown(src1[2 * uv_w + 0], src1[2 * uv_w + 1],
- src2[2 * uv_w + 0], src2[2 * uv_w + 1]);
- const int b = ScaleDown(src1[4 * uv_w + 0], src1[4 * uv_w + 1],
- src2[4 * uv_w + 0], src2[4 * uv_w + 1]);
- const int W = RGBToGray(r, g, b);
- dst[0 * uv_w] = (fixed_t)(r - W);
- dst[1 * uv_w] = (fixed_t)(g - W);
- dst[2 * uv_w] = (fixed_t)(b - W);
- dst += 1;
- src1 += 2;
- src2 += 2;
- }
-}
-
-static void StoreGray(const fixed_y_t* rgb, fixed_y_t* y, int w) {
- int i;
- for (i = 0; i < w; ++i) {
- y[i] = RGBToGray(rgb[0 * w + i], rgb[1 * w + i], rgb[2 * w + i]);
- }
-}
-
-//------------------------------------------------------------------------------
-
-static WEBP_INLINE fixed_y_t Filter2(int A, int B, int W0) {
- const int v0 = (A * 3 + B + 2) >> 2;
- return clip_y(v0 + W0);
-}
-
-//------------------------------------------------------------------------------
-
-static WEBP_INLINE fixed_y_t UpLift(uint8_t a) { // 8bit -> SFIX
- return ((fixed_y_t)a << SFIX) | SHALF;
-}
-
-static void ImportOneRow(const uint8_t* const r_ptr,
- const uint8_t* const g_ptr,
- const uint8_t* const b_ptr,
- int step,
- int pic_width,
- fixed_y_t* const dst) {
- int i;
- const int w = (pic_width + 1) & ~1;
- for (i = 0; i < pic_width; ++i) {
- const int off = i * step;
- dst[i + 0 * w] = UpLift(r_ptr[off]);
- dst[i + 1 * w] = UpLift(g_ptr[off]);
- dst[i + 2 * w] = UpLift(b_ptr[off]);
- }
- if (pic_width & 1) { // replicate rightmost pixel
- dst[pic_width + 0 * w] = dst[pic_width + 0 * w - 1];
- dst[pic_width + 1 * w] = dst[pic_width + 1 * w - 1];
- dst[pic_width + 2 * w] = dst[pic_width + 2 * w - 1];
- }
-}
-
-static void InterpolateTwoRows(const fixed_y_t* const best_y,
- const fixed_t* prev_uv,
- const fixed_t* cur_uv,
- const fixed_t* next_uv,
- int w,
- fixed_y_t* out1,
- fixed_y_t* out2) {
- const int uv_w = w >> 1;
- const int len = (w - 1) >> 1; // length to filter
- int k = 3;
- while (k-- > 0) { // process each R/G/B segments in turn
- // special boundary case for i==0
- out1[0] = Filter2(cur_uv[0], prev_uv[0], best_y[0]);
- out2[0] = Filter2(cur_uv[0], next_uv[0], best_y[w]);
-
- WebPSharpYUVFilterRow(cur_uv, prev_uv, len, best_y + 0 + 1, out1 + 1);
- WebPSharpYUVFilterRow(cur_uv, next_uv, len, best_y + w + 1, out2 + 1);
-
- // special boundary case for i == w - 1 when w is even
- if (!(w & 1)) {
- out1[w - 1] = Filter2(cur_uv[uv_w - 1], prev_uv[uv_w - 1],
- best_y[w - 1 + 0]);
- out2[w - 1] = Filter2(cur_uv[uv_w - 1], next_uv[uv_w - 1],
- best_y[w - 1 + w]);
- }
- out1 += w;
- out2 += w;
- prev_uv += uv_w;
- cur_uv += uv_w;
- next_uv += uv_w;
- }
-}
-
-static WEBP_INLINE uint8_t ConvertRGBToY(int r, int g, int b) {
- const int luma = 16839 * r + 33059 * g + 6420 * b + SROUNDER;
- return clip_8b(16 + (luma >> (YUV_FIX + SFIX)));
-}
-
-static WEBP_INLINE uint8_t ConvertRGBToU(int r, int g, int b) {
- const int u = -9719 * r - 19081 * g + 28800 * b + SROUNDER;
- return clip_8b(128 + (u >> (YUV_FIX + SFIX)));
-}
-
-static WEBP_INLINE uint8_t ConvertRGBToV(int r, int g, int b) {
- const int v = +28800 * r - 24116 * g - 4684 * b + SROUNDER;
- return clip_8b(128 + (v >> (YUV_FIX + SFIX)));
-}
-
-static int ConvertWRGBToYUV(const fixed_y_t* best_y, const fixed_t* best_uv,
- WebPPicture* const picture) {
- int i, j;
- uint8_t* dst_y = picture->y;
- uint8_t* dst_u = picture->u;
- uint8_t* dst_v = picture->v;
- const fixed_t* const best_uv_base = best_uv;
- const int w = (picture->width + 1) & ~1;
- const int h = (picture->height + 1) & ~1;
- const int uv_w = w >> 1;
- const int uv_h = h >> 1;
- for (best_uv = best_uv_base, j = 0; j < picture->height; ++j) {
- for (i = 0; i < picture->width; ++i) {
- const int off = (i >> 1);
- const int W = best_y[i];
- const int r = best_uv[off + 0 * uv_w] + W;
- const int g = best_uv[off + 1 * uv_w] + W;
- const int b = best_uv[off + 2 * uv_w] + W;
- dst_y[i] = ConvertRGBToY(r, g, b);
- }
- best_y += w;
- best_uv += (j & 1) * 3 * uv_w;
- dst_y += picture->y_stride;
- }
- for (best_uv = best_uv_base, j = 0; j < uv_h; ++j) {
- for (i = 0; i < uv_w; ++i) {
- const int off = i;
- const int r = best_uv[off + 0 * uv_w];
- const int g = best_uv[off + 1 * uv_w];
- const int b = best_uv[off + 2 * uv_w];
- dst_u[i] = ConvertRGBToU(r, g, b);
- dst_v[i] = ConvertRGBToV(r, g, b);
- }
- best_uv += 3 * uv_w;
- dst_u += picture->uv_stride;
- dst_v += picture->uv_stride;
- }
- return 1;
-}
-
-//------------------------------------------------------------------------------
-// Main function
-
-#define SAFE_ALLOC(W, H, T) ((T*)WebPSafeMalloc((W) * (H), sizeof(T)))
-
-static int PreprocessARGB(const uint8_t* r_ptr,
- const uint8_t* g_ptr,
- const uint8_t* b_ptr,
- int step, int rgb_stride,
- WebPPicture* const picture) {
- // we expand the right/bottom border if needed
- const int w = (picture->width + 1) & ~1;
- const int h = (picture->height + 1) & ~1;
- const int uv_w = w >> 1;
- const int uv_h = h >> 1;
- uint64_t prev_diff_y_sum = ~0;
- int j, iter;
-
- // TODO(skal): allocate one big memory chunk. But for now, it's easier
- // for valgrind debugging to have several chunks.
- fixed_y_t* const tmp_buffer = SAFE_ALLOC(w * 3, 2, fixed_y_t); // scratch
- fixed_y_t* const best_y_base = SAFE_ALLOC(w, h, fixed_y_t);
- fixed_y_t* const target_y_base = SAFE_ALLOC(w, h, fixed_y_t);
- fixed_y_t* const best_rgb_y = SAFE_ALLOC(w, 2, fixed_y_t);
- fixed_t* const best_uv_base = SAFE_ALLOC(uv_w * 3, uv_h, fixed_t);
- fixed_t* const target_uv_base = SAFE_ALLOC(uv_w * 3, uv_h, fixed_t);
- fixed_t* const best_rgb_uv = SAFE_ALLOC(uv_w * 3, 1, fixed_t);
- fixed_y_t* best_y = best_y_base;
- fixed_y_t* target_y = target_y_base;
- fixed_t* best_uv = best_uv_base;
- fixed_t* target_uv = target_uv_base;
- const uint64_t diff_y_threshold = (uint64_t)(3.0 * w * h);
- int ok;
-
- if (best_y_base == NULL || best_uv_base == NULL ||
- target_y_base == NULL || target_uv_base == NULL ||
- best_rgb_y == NULL || best_rgb_uv == NULL ||
- tmp_buffer == NULL) {
- ok = WebPEncodingSetError(picture, VP8_ENC_ERROR_OUT_OF_MEMORY);
- goto End;
- }
- assert(picture->width >= kMinDimensionIterativeConversion);
- assert(picture->height >= kMinDimensionIterativeConversion);
-
- WebPInitConvertARGBToYUV();
-
- // Import RGB samples to W/RGB representation.
- for (j = 0; j < picture->height; j += 2) {
- const int is_last_row = (j == picture->height - 1);
- fixed_y_t* const src1 = tmp_buffer + 0 * w;
- fixed_y_t* const src2 = tmp_buffer + 3 * w;
-
- // prepare two rows of input
- ImportOneRow(r_ptr, g_ptr, b_ptr, step, picture->width, src1);
- if (!is_last_row) {
- ImportOneRow(r_ptr + rgb_stride, g_ptr + rgb_stride, b_ptr + rgb_stride,
- step, picture->width, src2);
- } else {
- memcpy(src2, src1, 3 * w * sizeof(*src2));
- }
- StoreGray(src1, best_y + 0, w);
- StoreGray(src2, best_y + w, w);
-
- UpdateW(src1, target_y, w);
- UpdateW(src2, target_y + w, w);
- UpdateChroma(src1, src2, target_uv, uv_w);
- memcpy(best_uv, target_uv, 3 * uv_w * sizeof(*best_uv));
- best_y += 2 * w;
- best_uv += 3 * uv_w;
- target_y += 2 * w;
- target_uv += 3 * uv_w;
- r_ptr += 2 * rgb_stride;
- g_ptr += 2 * rgb_stride;
- b_ptr += 2 * rgb_stride;
- }
-
- // Iterate and resolve clipping conflicts.
- for (iter = 0; iter < kNumIterations; ++iter) {
- const fixed_t* cur_uv = best_uv_base;
- const fixed_t* prev_uv = best_uv_base;
- uint64_t diff_y_sum = 0;
-
- best_y = best_y_base;
- best_uv = best_uv_base;
- target_y = target_y_base;
- target_uv = target_uv_base;
- for (j = 0; j < h; j += 2) {
- fixed_y_t* const src1 = tmp_buffer + 0 * w;
- fixed_y_t* const src2 = tmp_buffer + 3 * w;
- {
- const fixed_t* const next_uv = cur_uv + ((j < h - 2) ? 3 * uv_w : 0);
- InterpolateTwoRows(best_y, prev_uv, cur_uv, next_uv, w, src1, src2);
- prev_uv = cur_uv;
- cur_uv = next_uv;
- }
-
- UpdateW(src1, best_rgb_y + 0 * w, w);
- UpdateW(src2, best_rgb_y + 1 * w, w);
- UpdateChroma(src1, src2, best_rgb_uv, uv_w);
-
- // update two rows of Y and one row of RGB
- diff_y_sum += WebPSharpYUVUpdateY(target_y, best_rgb_y, best_y, 2 * w);
- WebPSharpYUVUpdateRGB(target_uv, best_rgb_uv, best_uv, 3 * uv_w);
-
- best_y += 2 * w;
- best_uv += 3 * uv_w;
- target_y += 2 * w;
- target_uv += 3 * uv_w;
- }
- // test exit condition
- if (iter > 0) {
- if (diff_y_sum < diff_y_threshold) break;
- if (diff_y_sum > prev_diff_y_sum) break;
- }
- prev_diff_y_sum = diff_y_sum;
- }
- // final reconstruction
- ok = ConvertWRGBToYUV(best_y_base, best_uv_base, picture);
-
- End:
- WebPSafeFree(best_y_base);
- WebPSafeFree(best_uv_base);
- WebPSafeFree(target_y_base);
- WebPSafeFree(target_uv_base);
- WebPSafeFree(best_rgb_y);
- WebPSafeFree(best_rgb_uv);
- WebPSafeFree(tmp_buffer);
- return ok;
-}
-#undef SAFE_ALLOC
-
-//------------------------------------------------------------------------------
-// "Fast" regular RGB->YUV
-
-#define SUM4(ptr, step) LinearToGamma( \
- GammaToLinear((ptr)[0]) + \
- GammaToLinear((ptr)[(step)]) + \
- GammaToLinear((ptr)[rgb_stride]) + \
- GammaToLinear((ptr)[rgb_stride + (step)]), 0) \
-
-#define SUM2(ptr) \
- LinearToGamma(GammaToLinear((ptr)[0]) + GammaToLinear((ptr)[rgb_stride]), 1)
-
-#define SUM2ALPHA(ptr) ((ptr)[0] + (ptr)[rgb_stride])
-#define SUM4ALPHA(ptr) (SUM2ALPHA(ptr) + SUM2ALPHA((ptr) + 4))
-
-#if defined(USE_INVERSE_ALPHA_TABLE)
-
-static const int kAlphaFix = 19;
-// Following table is (1 << kAlphaFix) / a. The (v * kInvAlpha[a]) >> kAlphaFix
-// formula is then equal to v / a in most (99.6%) cases. Note that this table
-// and constant are adjusted very tightly to fit 32b arithmetic.
-// In particular, they use the fact that the operands for 'v / a' are actually
-// derived as v = (a0.p0 + a1.p1 + a2.p2 + a3.p3) and a = a0 + a1 + a2 + a3
-// with ai in [0..255] and pi in [0..1<<kGammaFix). The constraint to avoid
-// overflow is: kGammaFix + kAlphaFix <= 31.
-static const uint32_t kInvAlpha[4 * 0xff + 1] = {
- 0, /* alpha = 0 */
- 524288, 262144, 174762, 131072, 104857, 87381, 74898, 65536,
- 58254, 52428, 47662, 43690, 40329, 37449, 34952, 32768,
- 30840, 29127, 27594, 26214, 24966, 23831, 22795, 21845,
- 20971, 20164, 19418, 18724, 18078, 17476, 16912, 16384,
- 15887, 15420, 14979, 14563, 14169, 13797, 13443, 13107,
- 12787, 12483, 12192, 11915, 11650, 11397, 11155, 10922,
- 10699, 10485, 10280, 10082, 9892, 9709, 9532, 9362,
- 9198, 9039, 8886, 8738, 8594, 8456, 8322, 8192,
- 8065, 7943, 7825, 7710, 7598, 7489, 7384, 7281,
- 7182, 7084, 6990, 6898, 6808, 6721, 6636, 6553,
- 6472, 6393, 6316, 6241, 6168, 6096, 6026, 5957,
- 5890, 5825, 5761, 5698, 5637, 5577, 5518, 5461,
- 5405, 5349, 5295, 5242, 5190, 5140, 5090, 5041,
- 4993, 4946, 4899, 4854, 4809, 4766, 4723, 4681,
- 4639, 4599, 4559, 4519, 4481, 4443, 4405, 4369,
- 4332, 4297, 4262, 4228, 4194, 4161, 4128, 4096,
- 4064, 4032, 4002, 3971, 3942, 3912, 3883, 3855,
- 3826, 3799, 3771, 3744, 3718, 3692, 3666, 3640,
- 3615, 3591, 3566, 3542, 3518, 3495, 3472, 3449,
- 3426, 3404, 3382, 3360, 3339, 3318, 3297, 3276,
- 3256, 3236, 3216, 3196, 3177, 3158, 3139, 3120,
- 3102, 3084, 3066, 3048, 3030, 3013, 2995, 2978,
- 2962, 2945, 2928, 2912, 2896, 2880, 2864, 2849,
- 2833, 2818, 2803, 2788, 2774, 2759, 2744, 2730,
- 2716, 2702, 2688, 2674, 2661, 2647, 2634, 2621,
- 2608, 2595, 2582, 2570, 2557, 2545, 2532, 2520,
- 2508, 2496, 2484, 2473, 2461, 2449, 2438, 2427,
- 2416, 2404, 2394, 2383, 2372, 2361, 2351, 2340,
- 2330, 2319, 2309, 2299, 2289, 2279, 2269, 2259,
- 2250, 2240, 2231, 2221, 2212, 2202, 2193, 2184,
- 2175, 2166, 2157, 2148, 2139, 2131, 2122, 2114,
- 2105, 2097, 2088, 2080, 2072, 2064, 2056, 2048,
- 2040, 2032, 2024, 2016, 2008, 2001, 1993, 1985,
- 1978, 1971, 1963, 1956, 1949, 1941, 1934, 1927,
- 1920, 1913, 1906, 1899, 1892, 1885, 1879, 1872,
- 1865, 1859, 1852, 1846, 1839, 1833, 1826, 1820,
- 1814, 1807, 1801, 1795, 1789, 1783, 1777, 1771,
- 1765, 1759, 1753, 1747, 1741, 1736, 1730, 1724,
- 1718, 1713, 1707, 1702, 1696, 1691, 1685, 1680,
- 1675, 1669, 1664, 1659, 1653, 1648, 1643, 1638,
- 1633, 1628, 1623, 1618, 1613, 1608, 1603, 1598,
- 1593, 1588, 1583, 1579, 1574, 1569, 1565, 1560,
- 1555, 1551, 1546, 1542, 1537, 1533, 1528, 1524,
- 1519, 1515, 1510, 1506, 1502, 1497, 1493, 1489,
- 1485, 1481, 1476, 1472, 1468, 1464, 1460, 1456,
- 1452, 1448, 1444, 1440, 1436, 1432, 1428, 1424,
- 1420, 1416, 1413, 1409, 1405, 1401, 1398, 1394,
- 1390, 1387, 1383, 1379, 1376, 1372, 1368, 1365,
- 1361, 1358, 1354, 1351, 1347, 1344, 1340, 1337,
- 1334, 1330, 1327, 1323, 1320, 1317, 1314, 1310,
- 1307, 1304, 1300, 1297, 1294, 1291, 1288, 1285,
- 1281, 1278, 1275, 1272, 1269, 1266, 1263, 1260,
- 1257, 1254, 1251, 1248, 1245, 1242, 1239, 1236,
- 1233, 1230, 1227, 1224, 1222, 1219, 1216, 1213,
- 1210, 1208, 1205, 1202, 1199, 1197, 1194, 1191,
- 1188, 1186, 1183, 1180, 1178, 1175, 1172, 1170,
- 1167, 1165, 1162, 1159, 1157, 1154, 1152, 1149,
- 1147, 1144, 1142, 1139, 1137, 1134, 1132, 1129,
- 1127, 1125, 1122, 1120, 1117, 1115, 1113, 1110,
- 1108, 1106, 1103, 1101, 1099, 1096, 1094, 1092,
- 1089, 1087, 1085, 1083, 1081, 1078, 1076, 1074,
- 1072, 1069, 1067, 1065, 1063, 1061, 1059, 1057,
- 1054, 1052, 1050, 1048, 1046, 1044, 1042, 1040,
- 1038, 1036, 1034, 1032, 1030, 1028, 1026, 1024,
- 1022, 1020, 1018, 1016, 1014, 1012, 1010, 1008,
- 1006, 1004, 1002, 1000, 998, 996, 994, 992,
- 991, 989, 987, 985, 983, 981, 979, 978,
- 976, 974, 972, 970, 969, 967, 965, 963,
- 961, 960, 958, 956, 954, 953, 951, 949,
- 948, 946, 944, 942, 941, 939, 937, 936,
- 934, 932, 931, 929, 927, 926, 924, 923,
- 921, 919, 918, 916, 914, 913, 911, 910,
- 908, 907, 905, 903, 902, 900, 899, 897,
- 896, 894, 893, 891, 890, 888, 887, 885,
- 884, 882, 881, 879, 878, 876, 875, 873,
- 872, 870, 869, 868, 866, 865, 863, 862,
- 860, 859, 858, 856, 855, 853, 852, 851,
- 849, 848, 846, 845, 844, 842, 841, 840,
- 838, 837, 836, 834, 833, 832, 830, 829,
- 828, 826, 825, 824, 823, 821, 820, 819,
- 817, 816, 815, 814, 812, 811, 810, 809,
- 807, 806, 805, 804, 802, 801, 800, 799,
- 798, 796, 795, 794, 793, 791, 790, 789,
- 788, 787, 786, 784, 783, 782, 781, 780,
- 779, 777, 776, 775, 774, 773, 772, 771,
- 769, 768, 767, 766, 765, 764, 763, 762,
- 760, 759, 758, 757, 756, 755, 754, 753,
- 752, 751, 750, 748, 747, 746, 745, 744,
- 743, 742, 741, 740, 739, 738, 737, 736,
- 735, 734, 733, 732, 731, 730, 729, 728,
- 727, 726, 725, 724, 723, 722, 721, 720,
- 719, 718, 717, 716, 715, 714, 713, 712,
- 711, 710, 709, 708, 707, 706, 705, 704,
- 703, 702, 701, 700, 699, 699, 698, 697,
- 696, 695, 694, 693, 692, 691, 690, 689,
- 688, 688, 687, 686, 685, 684, 683, 682,
- 681, 680, 680, 679, 678, 677, 676, 675,
- 674, 673, 673, 672, 671, 670, 669, 668,
- 667, 667, 666, 665, 664, 663, 662, 661,
- 661, 660, 659, 658, 657, 657, 656, 655,
- 654, 653, 652, 652, 651, 650, 649, 648,
- 648, 647, 646, 645, 644, 644, 643, 642,
- 641, 640, 640, 639, 638, 637, 637, 636,
- 635, 634, 633, 633, 632, 631, 630, 630,
- 629, 628, 627, 627, 626, 625, 624, 624,
- 623, 622, 621, 621, 620, 619, 618, 618,
- 617, 616, 616, 615, 614, 613, 613, 612,
- 611, 611, 610, 609, 608, 608, 607, 606,
- 606, 605, 604, 604, 603, 602, 601, 601,
- 600, 599, 599, 598, 597, 597, 596, 595,
- 595, 594, 593, 593, 592, 591, 591, 590,
- 589, 589, 588, 587, 587, 586, 585, 585,
- 584, 583, 583, 582, 581, 581, 580, 579,
- 579, 578, 578, 577, 576, 576, 575, 574,
- 574, 573, 572, 572, 571, 571, 570, 569,
- 569, 568, 568, 567, 566, 566, 565, 564,
- 564, 563, 563, 562, 561, 561, 560, 560,
- 559, 558, 558, 557, 557, 556, 555, 555,
- 554, 554, 553, 553, 552, 551, 551, 550,
- 550, 549, 548, 548, 547, 547, 546, 546,
- 545, 544, 544, 543, 543, 542, 542, 541,
- 541, 540, 539, 539, 538, 538, 537, 537,
- 536, 536, 535, 534, 534, 533, 533, 532,
- 532, 531, 531, 530, 530, 529, 529, 528,
- 527, 527, 526, 526, 525, 525, 524, 524,
- 523, 523, 522, 522, 521, 521, 520, 520,
- 519, 519, 518, 518, 517, 517, 516, 516,
- 515, 515, 514, 514
-};
-
-// Note that LinearToGamma() expects the values to be premultiplied by 4,
-// so we incorporate this factor 4 inside the DIVIDE_BY_ALPHA macro directly.
-#define DIVIDE_BY_ALPHA(sum, a) (((sum) * kInvAlpha[(a)]) >> (kAlphaFix - 2))
-
-#else
-
-#define DIVIDE_BY_ALPHA(sum, a) (4 * (sum) / (a))
-
-#endif // USE_INVERSE_ALPHA_TABLE
-
-static WEBP_INLINE int LinearToGammaWeighted(const uint8_t* src,
- const uint8_t* a_ptr,
- uint32_t total_a, int step,
- int rgb_stride) {
- const uint32_t sum =
- a_ptr[0] * GammaToLinear(src[0]) +
- a_ptr[step] * GammaToLinear(src[step]) +
- a_ptr[rgb_stride] * GammaToLinear(src[rgb_stride]) +
- a_ptr[rgb_stride + step] * GammaToLinear(src[rgb_stride + step]);
- assert(total_a > 0 && total_a <= 4 * 0xff);
-#if defined(USE_INVERSE_ALPHA_TABLE)
- assert((uint64_t)sum * kInvAlpha[total_a] < ((uint64_t)1 << 32));
-#endif
- return LinearToGamma(DIVIDE_BY_ALPHA(sum, total_a), 0);
-}
-
-static WEBP_INLINE void ConvertRowToY(const uint8_t* const r_ptr,
- const uint8_t* const g_ptr,
- const uint8_t* const b_ptr,
- int step,
- uint8_t* const dst_y,
- int width,
- VP8Random* const rg) {
- int i, j;
- for (i = 0, j = 0; i < width; i += 1, j += step) {
- dst_y[i] = RGBToY(r_ptr[j], g_ptr[j], b_ptr[j], rg);
- }
-}
-
-static WEBP_INLINE void AccumulateRGBA(const uint8_t* const r_ptr,
- const uint8_t* const g_ptr,
- const uint8_t* const b_ptr,
- const uint8_t* const a_ptr,
- int rgb_stride,
- uint16_t* dst, int width) {
- int i, j;
- // we loop over 2x2 blocks and produce one R/G/B/A value for each.
- for (i = 0, j = 0; i < (width >> 1); i += 1, j += 2 * 4, dst += 4) {
- const uint32_t a = SUM4ALPHA(a_ptr + j);
- int r, g, b;
- if (a == 4 * 0xff || a == 0) {
- r = SUM4(r_ptr + j, 4);
- g = SUM4(g_ptr + j, 4);
- b = SUM4(b_ptr + j, 4);
- } else {
- r = LinearToGammaWeighted(r_ptr + j, a_ptr + j, a, 4, rgb_stride);
- g = LinearToGammaWeighted(g_ptr + j, a_ptr + j, a, 4, rgb_stride);
- b = LinearToGammaWeighted(b_ptr + j, a_ptr + j, a, 4, rgb_stride);
- }
- dst[0] = r;
- dst[1] = g;
- dst[2] = b;
- dst[3] = a;
- }
- if (width & 1) {
- const uint32_t a = 2u * SUM2ALPHA(a_ptr + j);
- int r, g, b;
- if (a == 4 * 0xff || a == 0) {
- r = SUM2(r_ptr + j);
- g = SUM2(g_ptr + j);
- b = SUM2(b_ptr + j);
- } else {
- r = LinearToGammaWeighted(r_ptr + j, a_ptr + j, a, 0, rgb_stride);
- g = LinearToGammaWeighted(g_ptr + j, a_ptr + j, a, 0, rgb_stride);
- b = LinearToGammaWeighted(b_ptr + j, a_ptr + j, a, 0, rgb_stride);
- }
- dst[0] = r;
- dst[1] = g;
- dst[2] = b;
- dst[3] = a;
- }
-}
-
-static WEBP_INLINE void AccumulateRGB(const uint8_t* const r_ptr,
- const uint8_t* const g_ptr,
- const uint8_t* const b_ptr,
- int step, int rgb_stride,
- uint16_t* dst, int width) {
- int i, j;
- for (i = 0, j = 0; i < (width >> 1); i += 1, j += 2 * step, dst += 4) {
- dst[0] = SUM4(r_ptr + j, step);
- dst[1] = SUM4(g_ptr + j, step);
- dst[2] = SUM4(b_ptr + j, step);
- }
- if (width & 1) {
- dst[0] = SUM2(r_ptr + j);
- dst[1] = SUM2(g_ptr + j);
- dst[2] = SUM2(b_ptr + j);
- }
-}
-
-static WEBP_INLINE void ConvertRowsToUV(const uint16_t* rgb,
- uint8_t* const dst_u,
- uint8_t* const dst_v,
- int width,
- VP8Random* const rg) {
- int i;
- for (i = 0; i < width; i += 1, rgb += 4) {
- const int r = rgb[0], g = rgb[1], b = rgb[2];
- dst_u[i] = RGBToU(r, g, b, rg);
- dst_v[i] = RGBToV(r, g, b, rg);
- }
-}
-
-static int ImportYUVAFromRGBA(const uint8_t* r_ptr,
- const uint8_t* g_ptr,
- const uint8_t* b_ptr,
- const uint8_t* a_ptr,
- int step, // bytes per pixel
- int rgb_stride, // bytes per scanline
- float dithering,
- int use_iterative_conversion,
- WebPPicture* const picture) {
- int y;
- const int width = picture->width;
- const int height = picture->height;
- const int has_alpha = CheckNonOpaque(a_ptr, width, height, step, rgb_stride);
- const int is_rgb = (r_ptr < b_ptr); // otherwise it's bgr
-
- picture->colorspace = has_alpha ? WEBP_YUV420A : WEBP_YUV420;
- picture->use_argb = 0;
-
- // disable smart conversion if source is too small (overkill).
- if (width < kMinDimensionIterativeConversion ||
- height < kMinDimensionIterativeConversion) {
- use_iterative_conversion = 0;
- }
-
- if (!WebPPictureAllocYUVA(picture, width, height)) {
- return 0;
- }
- if (has_alpha) {
- assert(step == 4);
-#if defined(USE_GAMMA_COMPRESSION) && defined(USE_INVERSE_ALPHA_TABLE)
- assert(kAlphaFix + kGammaFix <= 31);
-#endif
- }
-
- if (use_iterative_conversion) {
- InitGammaTablesS();
- if (!PreprocessARGB(r_ptr, g_ptr, b_ptr, step, rgb_stride, picture)) {
- return 0;
- }
- if (has_alpha) {
- WebPExtractAlpha(a_ptr, rgb_stride, width, height,
- picture->a, picture->a_stride);
- }
- } else {
- const int uv_width = (width + 1) >> 1;
- int use_dsp = (step == 3); // use special function in this case
- // temporary storage for accumulated R/G/B values during conversion to U/V
- uint16_t* const tmp_rgb =
- (uint16_t*)WebPSafeMalloc(4 * uv_width, sizeof(*tmp_rgb));
- uint8_t* dst_y = picture->y;
- uint8_t* dst_u = picture->u;
- uint8_t* dst_v = picture->v;
- uint8_t* dst_a = picture->a;
-
- VP8Random base_rg;
- VP8Random* rg = NULL;
- if (dithering > 0.) {
- VP8InitRandom(&base_rg, dithering);
- rg = &base_rg;
- use_dsp = 0; // can't use dsp in this case
- }
- WebPInitConvertARGBToYUV();
- InitGammaTables();
-
- if (tmp_rgb == NULL) return 0; // malloc error
-
- // Downsample Y/U/V planes, two rows at a time
- for (y = 0; y < (height >> 1); ++y) {
- int rows_have_alpha = has_alpha;
- if (use_dsp) {
- if (is_rgb) {
- WebPConvertRGB24ToY(r_ptr, dst_y, width);
- WebPConvertRGB24ToY(r_ptr + rgb_stride,
- dst_y + picture->y_stride, width);
- } else {
- WebPConvertBGR24ToY(b_ptr, dst_y, width);
- WebPConvertBGR24ToY(b_ptr + rgb_stride,
- dst_y + picture->y_stride, width);
- }
- } else {
- ConvertRowToY(r_ptr, g_ptr, b_ptr, step, dst_y, width, rg);
- ConvertRowToY(r_ptr + rgb_stride,
- g_ptr + rgb_stride,
- b_ptr + rgb_stride, step,
- dst_y + picture->y_stride, width, rg);
- }
- dst_y += 2 * picture->y_stride;
- if (has_alpha) {
- rows_have_alpha &= !WebPExtractAlpha(a_ptr, rgb_stride, width, 2,
- dst_a, picture->a_stride);
- dst_a += 2 * picture->a_stride;
- }
- // Collect averaged R/G/B(/A)
- if (!rows_have_alpha) {
- AccumulateRGB(r_ptr, g_ptr, b_ptr, step, rgb_stride, tmp_rgb, width);
- } else {
- AccumulateRGBA(r_ptr, g_ptr, b_ptr, a_ptr, rgb_stride, tmp_rgb, width);
- }
- // Convert to U/V
- if (rg == NULL) {
- WebPConvertRGBA32ToUV(tmp_rgb, dst_u, dst_v, uv_width);
- } else {
- ConvertRowsToUV(tmp_rgb, dst_u, dst_v, uv_width, rg);
- }
- dst_u += picture->uv_stride;
- dst_v += picture->uv_stride;
- r_ptr += 2 * rgb_stride;
- b_ptr += 2 * rgb_stride;
- g_ptr += 2 * rgb_stride;
- if (has_alpha) a_ptr += 2 * rgb_stride;
- }
- if (height & 1) { // extra last row
- int row_has_alpha = has_alpha;
- if (use_dsp) {
- if (r_ptr < b_ptr) {
- WebPConvertRGB24ToY(r_ptr, dst_y, width);
- } else {
- WebPConvertBGR24ToY(b_ptr, dst_y, width);
- }
- } else {
- ConvertRowToY(r_ptr, g_ptr, b_ptr, step, dst_y, width, rg);
- }
- if (row_has_alpha) {
- row_has_alpha &= !WebPExtractAlpha(a_ptr, 0, width, 1, dst_a, 0);
- }
- // Collect averaged R/G/B(/A)
- if (!row_has_alpha) {
- // Collect averaged R/G/B
- AccumulateRGB(r_ptr, g_ptr, b_ptr, step, /* rgb_stride = */ 0,
- tmp_rgb, width);
- } else {
- AccumulateRGBA(r_ptr, g_ptr, b_ptr, a_ptr, /* rgb_stride = */ 0,
- tmp_rgb, width);
- }
- if (rg == NULL) {
- WebPConvertRGBA32ToUV(tmp_rgb, dst_u, dst_v, uv_width);
- } else {
- ConvertRowsToUV(tmp_rgb, dst_u, dst_v, uv_width, rg);
- }
- }
- WebPSafeFree(tmp_rgb);
- }
- return 1;
-}
-
-#undef SUM4
-#undef SUM2
-#undef SUM4ALPHA
-#undef SUM2ALPHA
-
-//------------------------------------------------------------------------------
-// call for ARGB->YUVA conversion
-
-static int PictureARGBToYUVA(WebPPicture* picture, WebPEncCSP colorspace,
- float dithering, int use_iterative_conversion) {
- if (picture == NULL) return 0;
- if (picture->argb == NULL) {
- return WebPEncodingSetError(picture, VP8_ENC_ERROR_NULL_PARAMETER);
- } else if ((colorspace & WEBP_CSP_UV_MASK) != WEBP_YUV420) {
- return WebPEncodingSetError(picture, VP8_ENC_ERROR_INVALID_CONFIGURATION);
- } else {
- const uint8_t* const argb = (const uint8_t*)picture->argb;
- const uint8_t* const a = argb + CHANNEL_OFFSET(0);
- const uint8_t* const r = argb + CHANNEL_OFFSET(1);
- const uint8_t* const g = argb + CHANNEL_OFFSET(2);
- const uint8_t* const b = argb + CHANNEL_OFFSET(3);
-
- picture->colorspace = WEBP_YUV420;
- return ImportYUVAFromRGBA(r, g, b, a, 4, 4 * picture->argb_stride,
- dithering, use_iterative_conversion, picture);
- }
-}
-
-int WebPPictureARGBToYUVADithered(WebPPicture* picture, WebPEncCSP colorspace,
- float dithering) {
- return PictureARGBToYUVA(picture, colorspace, dithering, 0);
-}
-
-int WebPPictureARGBToYUVA(WebPPicture* picture, WebPEncCSP colorspace) {
- return PictureARGBToYUVA(picture, colorspace, 0.f, 0);
-}
-
-int WebPPictureSharpARGBToYUVA(WebPPicture* picture) {
- return PictureARGBToYUVA(picture, WEBP_YUV420, 0.f, 1);
-}
-// for backward compatibility
-int WebPPictureSmartARGBToYUVA(WebPPicture* picture) {
- return WebPPictureSharpARGBToYUVA(picture);
-}
-
-//------------------------------------------------------------------------------
-// call for YUVA -> ARGB conversion
-
-int WebPPictureYUVAToARGB(WebPPicture* picture) {
- if (picture == NULL) return 0;
- if (picture->y == NULL || picture->u == NULL || picture->v == NULL) {
- return WebPEncodingSetError(picture, VP8_ENC_ERROR_NULL_PARAMETER);
- }
- if ((picture->colorspace & WEBP_CSP_ALPHA_BIT) && picture->a == NULL) {
- return WebPEncodingSetError(picture, VP8_ENC_ERROR_NULL_PARAMETER);
- }
- if ((picture->colorspace & WEBP_CSP_UV_MASK) != WEBP_YUV420) {
- return WebPEncodingSetError(picture, VP8_ENC_ERROR_INVALID_CONFIGURATION);
- }
- // Allocate a new argb buffer (discarding the previous one).
- if (!WebPPictureAllocARGB(picture, picture->width, picture->height)) return 0;
- picture->use_argb = 1;
-
- // Convert
- {
- int y;
- const int width = picture->width;
- const int height = picture->height;
- const int argb_stride = 4 * picture->argb_stride;
- uint8_t* dst = (uint8_t*)picture->argb;
- const uint8_t* cur_u = picture->u, *cur_v = picture->v, *cur_y = picture->y;
- WebPUpsampleLinePairFunc upsample =
- WebPGetLinePairConverter(ALPHA_OFFSET > 0);
-
- // First row, with replicated top samples.
- upsample(cur_y, NULL, cur_u, cur_v, cur_u, cur_v, dst, NULL, width);
- cur_y += picture->y_stride;
- dst += argb_stride;
- // Center rows.
- for (y = 1; y + 1 < height; y += 2) {
- const uint8_t* const top_u = cur_u;
- const uint8_t* const top_v = cur_v;
- cur_u += picture->uv_stride;
- cur_v += picture->uv_stride;
- upsample(cur_y, cur_y + picture->y_stride, top_u, top_v, cur_u, cur_v,
- dst, dst + argb_stride, width);
- cur_y += 2 * picture->y_stride;
- dst += 2 * argb_stride;
- }
- // Last row (if needed), with replicated bottom samples.
- if (height > 1 && !(height & 1)) {
- upsample(cur_y, NULL, cur_u, cur_v, cur_u, cur_v, dst, NULL, width);
- }
- // Insert alpha values if needed, in replacement for the default 0xff ones.
- if (picture->colorspace & WEBP_CSP_ALPHA_BIT) {
- for (y = 0; y < height; ++y) {
- uint32_t* const argb_dst = picture->argb + y * picture->argb_stride;
- const uint8_t* const src = picture->a + y * picture->a_stride;
- int x;
- for (x = 0; x < width; ++x) {
- argb_dst[x] = (argb_dst[x] & 0x00ffffffu) | ((uint32_t)src[x] << 24);
- }
- }
- }
- }
- return 1;
-}
-
-//------------------------------------------------------------------------------
-// automatic import / conversion
-
-static int Import(WebPPicture* const picture,
- const uint8_t* rgb, int rgb_stride,
- int step, int swap_rb, int import_alpha) {
- int y;
- // swap_rb -> b,g,r,a , !swap_rb -> r,g,b,a
- const uint8_t* r_ptr = rgb + (swap_rb ? 2 : 0);
- const uint8_t* g_ptr = rgb + 1;
- const uint8_t* b_ptr = rgb + (swap_rb ? 0 : 2);
- const int width = picture->width;
- const int height = picture->height;
-
- if (!picture->use_argb) {
- const uint8_t* a_ptr = import_alpha ? rgb + 3 : NULL;
- return ImportYUVAFromRGBA(r_ptr, g_ptr, b_ptr, a_ptr, step, rgb_stride,
- 0.f /* no dithering */, 0, picture);
- }
- if (!WebPPictureAlloc(picture)) return 0;
-
- VP8LDspInit();
- WebPInitAlphaProcessing();
-
- if (import_alpha) {
- // dst[] byte order is {a,r,g,b} for big-endian, {b,g,r,a} for little endian
- uint32_t* dst = picture->argb;
- const int do_copy = (ALPHA_OFFSET == 3) && swap_rb;
- assert(step == 4);
- if (do_copy) {
- for (y = 0; y < height; ++y) {
- memcpy(dst, rgb, width * 4);
- rgb += rgb_stride;
- dst += picture->argb_stride;
- }
- } else {
- for (y = 0; y < height; ++y) {
-#ifdef WORDS_BIGENDIAN
- // BGRA or RGBA input order.
- const uint8_t* a_ptr = rgb + 3;
- WebPPackARGB(a_ptr, r_ptr, g_ptr, b_ptr, width, dst);
- r_ptr += rgb_stride;
- g_ptr += rgb_stride;
- b_ptr += rgb_stride;
-#else
- // RGBA input order. Need to swap R and B.
- VP8LConvertBGRAToRGBA((const uint32_t*)rgb, width, (uint8_t*)dst);
-#endif
- rgb += rgb_stride;
- dst += picture->argb_stride;
- }
- }
- } else {
- uint32_t* dst = picture->argb;
- assert(step >= 3);
- for (y = 0; y < height; ++y) {
- WebPPackRGB(r_ptr, g_ptr, b_ptr, width, step, dst);
- r_ptr += rgb_stride;
- g_ptr += rgb_stride;
- b_ptr += rgb_stride;
- dst += picture->argb_stride;
- }
- }
- return 1;
-}
-
-// Public API
-
-#if !defined(WEBP_REDUCE_CSP)
-
-int WebPPictureImportBGR(WebPPicture* picture,
- const uint8_t* rgb, int rgb_stride) {
- return (picture != NULL && rgb != NULL)
- ? Import(picture, rgb, rgb_stride, 3, 1, 0)
- : 0;
-}
-
-int WebPPictureImportBGRA(WebPPicture* picture,
- const uint8_t* rgba, int rgba_stride) {
- return (picture != NULL && rgba != NULL)
- ? Import(picture, rgba, rgba_stride, 4, 1, 1)
- : 0;
-}
-
-
-int WebPPictureImportBGRX(WebPPicture* picture,
- const uint8_t* rgba, int rgba_stride) {
- return (picture != NULL && rgba != NULL)
- ? Import(picture, rgba, rgba_stride, 4, 1, 0)
- : 0;
-}
-
-#endif // WEBP_REDUCE_CSP
-
-int WebPPictureImportRGB(WebPPicture* picture,
- const uint8_t* rgb, int rgb_stride) {
- return (picture != NULL && rgb != NULL)
- ? Import(picture, rgb, rgb_stride, 3, 0, 0)
- : 0;
-}
-
-int WebPPictureImportRGBA(WebPPicture* picture,
- const uint8_t* rgba, int rgba_stride) {
- return (picture != NULL && rgba != NULL)
- ? Import(picture, rgba, rgba_stride, 4, 0, 1)
- : 0;
-}
-
-int WebPPictureImportRGBX(WebPPicture* picture,
- const uint8_t* rgba, int rgba_stride) {
- return (picture != NULL && rgba != NULL)
- ? Import(picture, rgba, rgba_stride, 4, 0, 0)
- : 0;
-}
-
-//------------------------------------------------------------------------------
diff --git a/contrib/libs/libwebp/enc/picture_enc.c b/contrib/libs/libwebp/enc/picture_enc.c
deleted file mode 100644
index 4d43894c52..0000000000
--- a/contrib/libs/libwebp/enc/picture_enc.c
+++ /dev/null
@@ -1,296 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// WebPPicture class basis
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include <assert.h>
-#include <stdlib.h>
-
-#include "./vp8i_enc.h"
-#include "../dsp/dsp.h"
-#include "../utils/utils.h"
-
-//------------------------------------------------------------------------------
-// WebPPicture
-//------------------------------------------------------------------------------
-
-static int DummyWriter(const uint8_t* data, size_t data_size,
- const WebPPicture* const picture) {
- // The following are to prevent 'unused variable' error message.
- (void)data;
- (void)data_size;
- (void)picture;
- return 1;
-}
-
-int WebPPictureInitInternal(WebPPicture* picture, int version) {
- if (WEBP_ABI_IS_INCOMPATIBLE(version, WEBP_ENCODER_ABI_VERSION)) {
- return 0; // caller/system version mismatch!
- }
- if (picture != NULL) {
- memset(picture, 0, sizeof(*picture));
- picture->writer = DummyWriter;
- WebPEncodingSetError(picture, VP8_ENC_OK);
- }
- return 1;
-}
-
-//------------------------------------------------------------------------------
-
-static void WebPPictureResetBufferARGB(WebPPicture* const picture) {
- picture->memory_argb_ = NULL;
- picture->argb = NULL;
- picture->argb_stride = 0;
-}
-
-static void WebPPictureResetBufferYUVA(WebPPicture* const picture) {
- picture->memory_ = NULL;
- picture->y = picture->u = picture->v = picture->a = NULL;
- picture->y_stride = picture->uv_stride = 0;
- picture->a_stride = 0;
-}
-
-void WebPPictureResetBuffers(WebPPicture* const picture) {
- WebPPictureResetBufferARGB(picture);
- WebPPictureResetBufferYUVA(picture);
-}
-
-int WebPPictureAllocARGB(WebPPicture* const picture, int width, int height) {
- void* memory;
- const uint64_t argb_size = (uint64_t)width * height;
-
- assert(picture != NULL);
-
- WebPSafeFree(picture->memory_argb_);
- WebPPictureResetBufferARGB(picture);
-
- if (width <= 0 || height <= 0) {
- return WebPEncodingSetError(picture, VP8_ENC_ERROR_BAD_DIMENSION);
- }
- // allocate a new buffer.
- memory = WebPSafeMalloc(argb_size + WEBP_ALIGN_CST, sizeof(*picture->argb));
- if (memory == NULL) {
- return WebPEncodingSetError(picture, VP8_ENC_ERROR_OUT_OF_MEMORY);
- }
- picture->memory_argb_ = memory;
- picture->argb = (uint32_t*)WEBP_ALIGN(memory);
- picture->argb_stride = width;
- return 1;
-}
-
-int WebPPictureAllocYUVA(WebPPicture* const picture, int width, int height) {
- const WebPEncCSP uv_csp =
- (WebPEncCSP)((int)picture->colorspace & WEBP_CSP_UV_MASK);
- const int has_alpha = (int)picture->colorspace & WEBP_CSP_ALPHA_BIT;
- const int y_stride = width;
- const int uv_width = (int)(((int64_t)width + 1) >> 1);
- const int uv_height = (int)(((int64_t)height + 1) >> 1);
- const int uv_stride = uv_width;
- int a_width, a_stride;
- uint64_t y_size, uv_size, a_size, total_size;
- uint8_t* mem;
-
- assert(picture != NULL);
-
- WebPSafeFree(picture->memory_);
- WebPPictureResetBufferYUVA(picture);
-
- if (uv_csp != WEBP_YUV420) {
- return WebPEncodingSetError(picture, VP8_ENC_ERROR_INVALID_CONFIGURATION);
- }
-
- // alpha
- a_width = has_alpha ? width : 0;
- a_stride = a_width;
- y_size = (uint64_t)y_stride * height;
- uv_size = (uint64_t)uv_stride * uv_height;
- a_size = (uint64_t)a_stride * height;
-
- total_size = y_size + a_size + 2 * uv_size;
-
- // Security and validation checks
- if (width <= 0 || height <= 0 || // luma/alpha param error
- uv_width <= 0 || uv_height <= 0) { // u/v param error
- return WebPEncodingSetError(picture, VP8_ENC_ERROR_BAD_DIMENSION);
- }
- // allocate a new buffer.
- mem = (uint8_t*)WebPSafeMalloc(total_size, sizeof(*mem));
- if (mem == NULL) {
- return WebPEncodingSetError(picture, VP8_ENC_ERROR_OUT_OF_MEMORY);
- }
-
- // From now on, we're in the clear, we can no longer fail...
- picture->memory_ = (void*)mem;
- picture->y_stride = y_stride;
- picture->uv_stride = uv_stride;
- picture->a_stride = a_stride;
-
- // TODO(skal): we could align the y/u/v planes and adjust stride.
- picture->y = mem;
- mem += y_size;
-
- picture->u = mem;
- mem += uv_size;
- picture->v = mem;
- mem += uv_size;
-
- if (a_size > 0) {
- picture->a = mem;
- mem += a_size;
- }
- (void)mem; // makes the static analyzer happy
- return 1;
-}
-
-int WebPPictureAlloc(WebPPicture* picture) {
- if (picture != NULL) {
- const int width = picture->width;
- const int height = picture->height;
-
- WebPPictureFree(picture); // erase previous buffer
-
- if (!picture->use_argb) {
- return WebPPictureAllocYUVA(picture, width, height);
- } else {
- return WebPPictureAllocARGB(picture, width, height);
- }
- }
- return 1;
-}
-
-void WebPPictureFree(WebPPicture* picture) {
- if (picture != NULL) {
- WebPSafeFree(picture->memory_);
- WebPSafeFree(picture->memory_argb_);
- WebPPictureResetBuffers(picture);
- }
-}
-
-//------------------------------------------------------------------------------
-// WebPMemoryWriter: Write-to-memory
-
-void WebPMemoryWriterInit(WebPMemoryWriter* writer) {
- writer->mem = NULL;
- writer->size = 0;
- writer->max_size = 0;
-}
-
-int WebPMemoryWrite(const uint8_t* data, size_t data_size,
- const WebPPicture* picture) {
- WebPMemoryWriter* const w = (WebPMemoryWriter*)picture->custom_ptr;
- uint64_t next_size;
- if (w == NULL) {
- return 1;
- }
- next_size = (uint64_t)w->size + data_size;
- if (next_size > w->max_size) {
- uint8_t* new_mem;
- uint64_t next_max_size = 2ULL * w->max_size;
- if (next_max_size < next_size) next_max_size = next_size;
- if (next_max_size < 8192ULL) next_max_size = 8192ULL;
- new_mem = (uint8_t*)WebPSafeMalloc(next_max_size, 1);
- if (new_mem == NULL) {
- return 0;
- }
- if (w->size > 0) {
- memcpy(new_mem, w->mem, w->size);
- }
- WebPSafeFree(w->mem);
- w->mem = new_mem;
- // down-cast is ok, thanks to WebPSafeMalloc
- w->max_size = (size_t)next_max_size;
- }
- if (data_size > 0) {
- memcpy(w->mem + w->size, data, data_size);
- w->size += data_size;
- }
- return 1;
-}
-
-void WebPMemoryWriterClear(WebPMemoryWriter* writer) {
- if (writer != NULL) {
- WebPSafeFree(writer->mem);
- writer->mem = NULL;
- writer->size = 0;
- writer->max_size = 0;
- }
-}
-
-//------------------------------------------------------------------------------
-// Simplest high-level calls:
-
-typedef int (*Importer)(WebPPicture* const, const uint8_t* const, int);
-
-static size_t Encode(const uint8_t* rgba, int width, int height, int stride,
- Importer import, float quality_factor, int lossless,
- uint8_t** output) {
- WebPPicture pic;
- WebPConfig config;
- WebPMemoryWriter wrt;
- int ok;
-
- if (output == NULL) return 0;
-
- if (!WebPConfigPreset(&config, WEBP_PRESET_DEFAULT, quality_factor) ||
- !WebPPictureInit(&pic)) {
- return 0; // shouldn't happen, except if system installation is broken
- }
-
- config.lossless = !!lossless;
- pic.use_argb = !!lossless;
- pic.width = width;
- pic.height = height;
- pic.writer = WebPMemoryWrite;
- pic.custom_ptr = &wrt;
- WebPMemoryWriterInit(&wrt);
-
- ok = import(&pic, rgba, stride) && WebPEncode(&config, &pic);
- WebPPictureFree(&pic);
- if (!ok) {
- WebPMemoryWriterClear(&wrt);
- *output = NULL;
- return 0;
- }
- *output = wrt.mem;
- return wrt.size;
-}
-
-#define ENCODE_FUNC(NAME, IMPORTER) \
-size_t NAME(const uint8_t* in, int w, int h, int bps, float q, \
- uint8_t** out) { \
- return Encode(in, w, h, bps, IMPORTER, q, 0, out); \
-}
-
-ENCODE_FUNC(WebPEncodeRGB, WebPPictureImportRGB)
-ENCODE_FUNC(WebPEncodeRGBA, WebPPictureImportRGBA)
-#if !defined(WEBP_REDUCE_CSP)
-ENCODE_FUNC(WebPEncodeBGR, WebPPictureImportBGR)
-ENCODE_FUNC(WebPEncodeBGRA, WebPPictureImportBGRA)
-#endif // WEBP_REDUCE_CSP
-
-#undef ENCODE_FUNC
-
-#define LOSSLESS_DEFAULT_QUALITY 70.
-#define LOSSLESS_ENCODE_FUNC(NAME, IMPORTER) \
-size_t NAME(const uint8_t* in, int w, int h, int bps, uint8_t** out) { \
- return Encode(in, w, h, bps, IMPORTER, LOSSLESS_DEFAULT_QUALITY, 1, out); \
-}
-
-LOSSLESS_ENCODE_FUNC(WebPEncodeLosslessRGB, WebPPictureImportRGB)
-LOSSLESS_ENCODE_FUNC(WebPEncodeLosslessRGBA, WebPPictureImportRGBA)
-#if !defined(WEBP_REDUCE_CSP)
-LOSSLESS_ENCODE_FUNC(WebPEncodeLosslessBGR, WebPPictureImportBGR)
-LOSSLESS_ENCODE_FUNC(WebPEncodeLosslessBGRA, WebPPictureImportBGRA)
-#endif // WEBP_REDUCE_CSP
-
-#undef LOSSLESS_ENCODE_FUNC
-
-//------------------------------------------------------------------------------
diff --git a/contrib/libs/libwebp/enc/picture_psnr_enc.c b/contrib/libs/libwebp/enc/picture_psnr_enc.c
deleted file mode 100644
index 744407ead4..0000000000
--- a/contrib/libs/libwebp/enc/picture_psnr_enc.c
+++ /dev/null
@@ -1,258 +0,0 @@
-// Copyright 2014 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// WebPPicture tools for measuring distortion
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include "../webp/encode.h"
-
-#if !(defined(WEBP_DISABLE_STATS) || defined(WEBP_REDUCE_SIZE))
-
-#include <math.h>
-#include <stdlib.h>
-
-#include "../dsp/dsp.h"
-#include "./vp8i_enc.h"
-#include "../utils/utils.h"
-
-typedef double (*AccumulateFunc)(const uint8_t* src, int src_stride,
- const uint8_t* ref, int ref_stride,
- int w, int h);
-
-//------------------------------------------------------------------------------
-// local-min distortion
-//
-// For every pixel in the *reference* picture, we search for the local best
-// match in the compressed image. This is not a symmetrical measure.
-
-#define RADIUS 2 // search radius. Shouldn't be too large.
-
-static double AccumulateLSIM(const uint8_t* src, int src_stride,
- const uint8_t* ref, int ref_stride,
- int w, int h) {
- int x, y;
- double total_sse = 0.;
- for (y = 0; y < h; ++y) {
- const int y_0 = (y - RADIUS < 0) ? 0 : y - RADIUS;
- const int y_1 = (y + RADIUS + 1 >= h) ? h : y + RADIUS + 1;
- for (x = 0; x < w; ++x) {
- const int x_0 = (x - RADIUS < 0) ? 0 : x - RADIUS;
- const int x_1 = (x + RADIUS + 1 >= w) ? w : x + RADIUS + 1;
- double best_sse = 255. * 255.;
- const double value = (double)ref[y * ref_stride + x];
- int i, j;
- for (j = y_0; j < y_1; ++j) {
- const uint8_t* const s = src + j * src_stride;
- for (i = x_0; i < x_1; ++i) {
- const double diff = s[i] - value;
- const double sse = diff * diff;
- if (sse < best_sse) best_sse = sse;
- }
- }
- total_sse += best_sse;
- }
- }
- return total_sse;
-}
-#undef RADIUS
-
-static double AccumulateSSE(const uint8_t* src, int src_stride,
- const uint8_t* ref, int ref_stride,
- int w, int h) {
- int y;
- double total_sse = 0.;
- for (y = 0; y < h; ++y) {
- total_sse += VP8AccumulateSSE(src, ref, w);
- src += src_stride;
- ref += ref_stride;
- }
- return total_sse;
-}
-
-//------------------------------------------------------------------------------
-
-static double AccumulateSSIM(const uint8_t* src, int src_stride,
- const uint8_t* ref, int ref_stride,
- int w, int h) {
- const int w0 = (w < VP8_SSIM_KERNEL) ? w : VP8_SSIM_KERNEL;
- const int w1 = w - VP8_SSIM_KERNEL - 1;
- const int h0 = (h < VP8_SSIM_KERNEL) ? h : VP8_SSIM_KERNEL;
- const int h1 = h - VP8_SSIM_KERNEL - 1;
- int x, y;
- double sum = 0.;
- for (y = 0; y < h0; ++y) {
- for (x = 0; x < w; ++x) {
- sum += VP8SSIMGetClipped(src, src_stride, ref, ref_stride, x, y, w, h);
- }
- }
- for (; y < h1; ++y) {
- for (x = 0; x < w0; ++x) {
- sum += VP8SSIMGetClipped(src, src_stride, ref, ref_stride, x, y, w, h);
- }
- for (; x < w1; ++x) {
- const int off1 = x - VP8_SSIM_KERNEL + (y - VP8_SSIM_KERNEL) * src_stride;
- const int off2 = x - VP8_SSIM_KERNEL + (y - VP8_SSIM_KERNEL) * ref_stride;
- sum += VP8SSIMGet(src + off1, src_stride, ref + off2, ref_stride);
- }
- for (; x < w; ++x) {
- sum += VP8SSIMGetClipped(src, src_stride, ref, ref_stride, x, y, w, h);
- }
- }
- for (; y < h; ++y) {
- for (x = 0; x < w; ++x) {
- sum += VP8SSIMGetClipped(src, src_stride, ref, ref_stride, x, y, w, h);
- }
- }
- return sum;
-}
-
-//------------------------------------------------------------------------------
-// Distortion
-
-// Max value returned in case of exact similarity.
-static const double kMinDistortion_dB = 99.;
-
-static double GetPSNR(double v, double size) {
- return (v > 0. && size > 0.) ? -4.3429448 * log(v / (size * 255 * 255.))
- : kMinDistortion_dB;
-}
-
-static double GetLogSSIM(double v, double size) {
- v = (size > 0.) ? v / size : 1.;
- return (v < 1.) ? -10.0 * log10(1. - v) : kMinDistortion_dB;
-}
-
-int WebPPlaneDistortion(const uint8_t* src, size_t src_stride,
- const uint8_t* ref, size_t ref_stride,
- int width, int height, size_t x_step,
- int type, float* distortion, float* result) {
- uint8_t* allocated = NULL;
- const AccumulateFunc metric = (type == 0) ? AccumulateSSE :
- (type == 1) ? AccumulateSSIM :
- AccumulateLSIM;
- if (src == NULL || ref == NULL ||
- src_stride < x_step * width || ref_stride < x_step * width ||
- result == NULL || distortion == NULL) {
- return 0;
- }
-
- VP8SSIMDspInit();
- if (x_step != 1) { // extract a packed plane if needed
- int x, y;
- uint8_t* tmp1;
- uint8_t* tmp2;
- allocated =
- (uint8_t*)WebPSafeMalloc(2ULL * width * height, sizeof(*allocated));
- if (allocated == NULL) return 0;
- tmp1 = allocated;
- tmp2 = tmp1 + (size_t)width * height;
- for (y = 0; y < height; ++y) {
- for (x = 0; x < width; ++x) {
- tmp1[x + y * width] = src[x * x_step + y * src_stride];
- tmp2[x + y * width] = ref[x * x_step + y * ref_stride];
- }
- }
- src = tmp1;
- ref = tmp2;
- }
- *distortion = (float)metric(src, width, ref, width, width, height);
- WebPSafeFree(allocated);
-
- *result = (type == 1) ? (float)GetLogSSIM(*distortion, (double)width * height)
- : (float)GetPSNR(*distortion, (double)width * height);
- return 1;
-}
-
-#ifdef WORDS_BIGENDIAN
-#define BLUE_OFFSET 3 // uint32_t 0x000000ff is 0x00,00,00,ff in memory
-#else
-#define BLUE_OFFSET 0 // uint32_t 0x000000ff is 0xff,00,00,00 in memory
-#endif
-
-int WebPPictureDistortion(const WebPPicture* src, const WebPPicture* ref,
- int type, float results[5]) {
- int w, h, c;
- int ok = 0;
- WebPPicture p0, p1;
- double total_size = 0., total_distortion = 0.;
- if (src == NULL || ref == NULL ||
- src->width != ref->width || src->height != ref->height ||
- results == NULL) {
- return 0;
- }
-
- VP8SSIMDspInit();
- if (!WebPPictureInit(&p0) || !WebPPictureInit(&p1)) return 0;
- w = src->width;
- h = src->height;
- if (!WebPPictureView(src, 0, 0, w, h, &p0)) goto Error;
- if (!WebPPictureView(ref, 0, 0, w, h, &p1)) goto Error;
-
- // We always measure distortion in ARGB space.
- if (p0.use_argb == 0 && !WebPPictureYUVAToARGB(&p0)) goto Error;
- if (p1.use_argb == 0 && !WebPPictureYUVAToARGB(&p1)) goto Error;
- for (c = 0; c < 4; ++c) {
- float distortion;
- const size_t stride0 = 4 * (size_t)p0.argb_stride;
- const size_t stride1 = 4 * (size_t)p1.argb_stride;
- // results are reported as BGRA
- const int offset = c ^ BLUE_OFFSET;
- if (!WebPPlaneDistortion((const uint8_t*)p0.argb + offset, stride0,
- (const uint8_t*)p1.argb + offset, stride1,
- w, h, 4, type, &distortion, results + c)) {
- goto Error;
- }
- total_distortion += distortion;
- total_size += w * h;
- }
-
- results[4] = (type == 1) ? (float)GetLogSSIM(total_distortion, total_size)
- : (float)GetPSNR(total_distortion, total_size);
- ok = 1;
-
- Error:
- WebPPictureFree(&p0);
- WebPPictureFree(&p1);
- return ok;
-}
-
-#undef BLUE_OFFSET
-
-#else // defined(WEBP_DISABLE_STATS)
-int WebPPlaneDistortion(const uint8_t* src, size_t src_stride,
- const uint8_t* ref, size_t ref_stride,
- int width, int height, size_t x_step,
- int type, float* distortion, float* result) {
- (void)src;
- (void)src_stride;
- (void)ref;
- (void)ref_stride;
- (void)width;
- (void)height;
- (void)x_step;
- (void)type;
- if (distortion == NULL || result == NULL) return 0;
- *distortion = 0.f;
- *result = 0.f;
- return 1;
-}
-
-int WebPPictureDistortion(const WebPPicture* src, const WebPPicture* ref,
- int type, float results[5]) {
- int i;
- (void)src;
- (void)ref;
- (void)type;
- if (results == NULL) return 0;
- for (i = 0; i < 5; ++i) results[i] = 0.f;
- return 1;
-}
-
-#endif // !defined(WEBP_DISABLE_STATS)
diff --git a/contrib/libs/libwebp/enc/picture_rescale_enc.c b/contrib/libs/libwebp/enc/picture_rescale_enc.c
deleted file mode 100644
index 6a894661e8..0000000000
--- a/contrib/libs/libwebp/enc/picture_rescale_enc.c
+++ /dev/null
@@ -1,316 +0,0 @@
-// Copyright 2014 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// WebPPicture tools: copy, crop, rescaling and view.
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include "../webp/encode.h"
-
-#if !defined(WEBP_REDUCE_SIZE)
-
-#include <assert.h>
-#include <stdlib.h>
-
-#include "./vp8i_enc.h"
-#include "../utils/rescaler_utils.h"
-#include "../utils/utils.h"
-
-#define HALVE(x) (((x) + 1) >> 1)
-
-// Grab the 'specs' (writer, *opaque, width, height...) from 'src' and copy them
-// into 'dst'. Mark 'dst' as not owning any memory.
-static void PictureGrabSpecs(const WebPPicture* const src,
- WebPPicture* const dst) {
- assert(src != NULL && dst != NULL);
- *dst = *src;
- WebPPictureResetBuffers(dst);
-}
-
-//------------------------------------------------------------------------------
-
-// Adjust top-left corner to chroma sample position.
-static void SnapTopLeftPosition(const WebPPicture* const pic,
- int* const left, int* const top) {
- if (!pic->use_argb) {
- *left &= ~1;
- *top &= ~1;
- }
-}
-
-// Adjust top-left corner and verify that the sub-rectangle is valid.
-static int AdjustAndCheckRectangle(const WebPPicture* const pic,
- int* const left, int* const top,
- int width, int height) {
- SnapTopLeftPosition(pic, left, top);
- if ((*left) < 0 || (*top) < 0) return 0;
- if (width <= 0 || height <= 0) return 0;
- if ((*left) + width > pic->width) return 0;
- if ((*top) + height > pic->height) return 0;
- return 1;
-}
-
-int WebPPictureCopy(const WebPPicture* src, WebPPicture* dst) {
- if (src == NULL || dst == NULL) return 0;
- if (src == dst) return 1;
-
- PictureGrabSpecs(src, dst);
- if (!WebPPictureAlloc(dst)) return 0;
-
- if (!src->use_argb) {
- WebPCopyPlane(src->y, src->y_stride,
- dst->y, dst->y_stride, dst->width, dst->height);
- WebPCopyPlane(src->u, src->uv_stride, dst->u, dst->uv_stride,
- HALVE(dst->width), HALVE(dst->height));
- WebPCopyPlane(src->v, src->uv_stride, dst->v, dst->uv_stride,
- HALVE(dst->width), HALVE(dst->height));
- if (dst->a != NULL) {
- WebPCopyPlane(src->a, src->a_stride,
- dst->a, dst->a_stride, dst->width, dst->height);
- }
- } else {
- WebPCopyPlane((const uint8_t*)src->argb, 4 * src->argb_stride,
- (uint8_t*)dst->argb, 4 * dst->argb_stride,
- 4 * dst->width, dst->height);
- }
- return 1;
-}
-
-int WebPPictureIsView(const WebPPicture* picture) {
- if (picture == NULL) return 0;
- if (picture->use_argb) {
- return (picture->memory_argb_ == NULL);
- }
- return (picture->memory_ == NULL);
-}
-
-int WebPPictureView(const WebPPicture* src,
- int left, int top, int width, int height,
- WebPPicture* dst) {
- if (src == NULL || dst == NULL) return 0;
-
- // verify rectangle position.
- if (!AdjustAndCheckRectangle(src, &left, &top, width, height)) return 0;
-
- if (src != dst) { // beware of aliasing! We don't want to leak 'memory_'.
- PictureGrabSpecs(src, dst);
- }
- dst->width = width;
- dst->height = height;
- if (!src->use_argb) {
- dst->y = src->y + top * src->y_stride + left;
- dst->u = src->u + (top >> 1) * src->uv_stride + (left >> 1);
- dst->v = src->v + (top >> 1) * src->uv_stride + (left >> 1);
- dst->y_stride = src->y_stride;
- dst->uv_stride = src->uv_stride;
- if (src->a != NULL) {
- dst->a = src->a + top * src->a_stride + left;
- dst->a_stride = src->a_stride;
- }
- } else {
- dst->argb = src->argb + top * src->argb_stride + left;
- dst->argb_stride = src->argb_stride;
- }
- return 1;
-}
-
-//------------------------------------------------------------------------------
-// Picture cropping
-
-int WebPPictureCrop(WebPPicture* pic,
- int left, int top, int width, int height) {
- WebPPicture tmp;
-
- if (pic == NULL) return 0;
- if (!AdjustAndCheckRectangle(pic, &left, &top, width, height)) return 0;
-
- PictureGrabSpecs(pic, &tmp);
- tmp.width = width;
- tmp.height = height;
- if (!WebPPictureAlloc(&tmp)) return 0;
-
- if (!pic->use_argb) {
- const int y_offset = top * pic->y_stride + left;
- const int uv_offset = (top / 2) * pic->uv_stride + left / 2;
- WebPCopyPlane(pic->y + y_offset, pic->y_stride,
- tmp.y, tmp.y_stride, width, height);
- WebPCopyPlane(pic->u + uv_offset, pic->uv_stride,
- tmp.u, tmp.uv_stride, HALVE(width), HALVE(height));
- WebPCopyPlane(pic->v + uv_offset, pic->uv_stride,
- tmp.v, tmp.uv_stride, HALVE(width), HALVE(height));
-
- if (tmp.a != NULL) {
- const int a_offset = top * pic->a_stride + left;
- WebPCopyPlane(pic->a + a_offset, pic->a_stride,
- tmp.a, tmp.a_stride, width, height);
- }
- } else {
- const uint8_t* const src =
- (const uint8_t*)(pic->argb + top * pic->argb_stride + left);
- WebPCopyPlane(src, pic->argb_stride * 4, (uint8_t*)tmp.argb,
- tmp.argb_stride * 4, width * 4, height);
- }
- WebPPictureFree(pic);
- *pic = tmp;
- return 1;
-}
-
-//------------------------------------------------------------------------------
-// Simple picture rescaler
-
-static int RescalePlane(const uint8_t* src,
- int src_width, int src_height, int src_stride,
- uint8_t* dst,
- int dst_width, int dst_height, int dst_stride,
- rescaler_t* const work,
- int num_channels) {
- WebPRescaler rescaler;
- int y = 0;
- if (!WebPRescalerInit(&rescaler, src_width, src_height,
- dst, dst_width, dst_height, dst_stride,
- num_channels, work)) {
- return 0;
- }
- while (y < src_height) {
- y += WebPRescalerImport(&rescaler, src_height - y,
- src + y * src_stride, src_stride);
- WebPRescalerExport(&rescaler);
- }
- return 1;
-}
-
-static void AlphaMultiplyARGB(WebPPicture* const pic, int inverse) {
- assert(pic->argb != NULL);
- WebPMultARGBRows((uint8_t*)pic->argb, pic->argb_stride * sizeof(*pic->argb),
- pic->width, pic->height, inverse);
-}
-
-static void AlphaMultiplyY(WebPPicture* const pic, int inverse) {
- if (pic->a != NULL) {
- WebPMultRows(pic->y, pic->y_stride, pic->a, pic->a_stride,
- pic->width, pic->height, inverse);
- }
-}
-
-int WebPPictureRescale(WebPPicture* pic, int width, int height) {
- WebPPicture tmp;
- int prev_width, prev_height;
- rescaler_t* work;
-
- if (pic == NULL) return 0;
- prev_width = pic->width;
- prev_height = pic->height;
- if (!WebPRescalerGetScaledDimensions(
- prev_width, prev_height, &width, &height)) {
- return 0;
- }
-
- PictureGrabSpecs(pic, &tmp);
- tmp.width = width;
- tmp.height = height;
- if (!WebPPictureAlloc(&tmp)) return 0;
-
- if (!pic->use_argb) {
- work = (rescaler_t*)WebPSafeMalloc(2ULL * width, sizeof(*work));
- if (work == NULL) {
- WebPPictureFree(&tmp);
- return 0;
- }
- // If present, we need to rescale alpha first (for AlphaMultiplyY).
- if (pic->a != NULL) {
- WebPInitAlphaProcessing();
- if (!RescalePlane(pic->a, prev_width, prev_height, pic->a_stride,
- tmp.a, width, height, tmp.a_stride, work, 1)) {
- return 0;
- }
- }
-
- // We take transparency into account on the luma plane only. That's not
- // totally exact blending, but still is a good approximation.
- AlphaMultiplyY(pic, 0);
- if (!RescalePlane(pic->y, prev_width, prev_height, pic->y_stride,
- tmp.y, width, height, tmp.y_stride, work, 1) ||
- !RescalePlane(pic->u,
- HALVE(prev_width), HALVE(prev_height), pic->uv_stride,
- tmp.u,
- HALVE(width), HALVE(height), tmp.uv_stride, work, 1) ||
- !RescalePlane(pic->v,
- HALVE(prev_width), HALVE(prev_height), pic->uv_stride,
- tmp.v,
- HALVE(width), HALVE(height), tmp.uv_stride, work, 1)) {
- return 0;
- }
- AlphaMultiplyY(&tmp, 1);
- } else {
- work = (rescaler_t*)WebPSafeMalloc(2ULL * width * 4, sizeof(*work));
- if (work == NULL) {
- WebPPictureFree(&tmp);
- return 0;
- }
- // In order to correctly interpolate colors, we need to apply the alpha
- // weighting first (black-matting), scale the RGB values, and remove
- // the premultiplication afterward (while preserving the alpha channel).
- WebPInitAlphaProcessing();
- AlphaMultiplyARGB(pic, 0);
- if (!RescalePlane((const uint8_t*)pic->argb, prev_width, prev_height,
- pic->argb_stride * 4,
- (uint8_t*)tmp.argb, width, height,
- tmp.argb_stride * 4, work, 4)) {
- return 0;
- }
- AlphaMultiplyARGB(&tmp, 1);
- }
- WebPPictureFree(pic);
- WebPSafeFree(work);
- *pic = tmp;
- return 1;
-}
-
-#else // defined(WEBP_REDUCE_SIZE)
-
-int WebPPictureCopy(const WebPPicture* src, WebPPicture* dst) {
- (void)src;
- (void)dst;
- return 0;
-}
-
-int WebPPictureIsView(const WebPPicture* picture) {
- (void)picture;
- return 0;
-}
-
-int WebPPictureView(const WebPPicture* src,
- int left, int top, int width, int height,
- WebPPicture* dst) {
- (void)src;
- (void)left;
- (void)top;
- (void)width;
- (void)height;
- (void)dst;
- return 0;
-}
-
-int WebPPictureCrop(WebPPicture* pic,
- int left, int top, int width, int height) {
- (void)pic;
- (void)left;
- (void)top;
- (void)width;
- (void)height;
- return 0;
-}
-
-int WebPPictureRescale(WebPPicture* pic, int width, int height) {
- (void)pic;
- (void)width;
- (void)height;
- return 0;
-}
-#endif // !defined(WEBP_REDUCE_SIZE)
diff --git a/contrib/libs/libwebp/enc/picture_tools_enc.c b/contrib/libs/libwebp/enc/picture_tools_enc.c
deleted file mode 100644
index d9051eb34a..0000000000
--- a/contrib/libs/libwebp/enc/picture_tools_enc.c
+++ /dev/null
@@ -1,273 +0,0 @@
-// Copyright 2014 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// WebPPicture tools: alpha handling, etc.
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include <assert.h>
-
-#include "./vp8i_enc.h"
-#include "../dsp/yuv.h"
-
-//------------------------------------------------------------------------------
-// Helper: clean up fully transparent area to help compressibility.
-
-#define SIZE 8
-#define SIZE2 (SIZE / 2)
-static int IsTransparentARGBArea(const uint32_t* ptr, int stride, int size) {
- int y, x;
- for (y = 0; y < size; ++y) {
- for (x = 0; x < size; ++x) {
- if (ptr[x] & 0xff000000u) {
- return 0;
- }
- }
- ptr += stride;
- }
- return 1;
-}
-
-static void Flatten(uint8_t* ptr, int v, int stride, int size) {
- int y;
- for (y = 0; y < size; ++y) {
- memset(ptr, v, size);
- ptr += stride;
- }
-}
-
-static void FlattenARGB(uint32_t* ptr, uint32_t v, int stride, int size) {
- int x, y;
- for (y = 0; y < size; ++y) {
- for (x = 0; x < size; ++x) ptr[x] = v;
- ptr += stride;
- }
-}
-
-// Smoothen the luma components of transparent pixels. Return true if the whole
-// block is transparent.
-static int SmoothenBlock(const uint8_t* a_ptr, int a_stride, uint8_t* y_ptr,
- int y_stride, int width, int height) {
- int sum = 0, count = 0;
- int x, y;
- const uint8_t* alpha_ptr = a_ptr;
- uint8_t* luma_ptr = y_ptr;
- for (y = 0; y < height; ++y) {
- for (x = 0; x < width; ++x) {
- if (alpha_ptr[x] != 0) {
- ++count;
- sum += luma_ptr[x];
- }
- }
- alpha_ptr += a_stride;
- luma_ptr += y_stride;
- }
- if (count > 0 && count < width * height) {
- const uint8_t avg_u8 = (uint8_t)(sum / count);
- alpha_ptr = a_ptr;
- luma_ptr = y_ptr;
- for (y = 0; y < height; ++y) {
- for (x = 0; x < width; ++x) {
- if (alpha_ptr[x] == 0) luma_ptr[x] = avg_u8;
- }
- alpha_ptr += a_stride;
- luma_ptr += y_stride;
- }
- }
- return (count == 0);
-}
-
-void WebPReplaceTransparentPixels(WebPPicture* const pic, uint32_t color) {
- if (pic != NULL && pic->use_argb) {
- int y = pic->height;
- uint32_t* argb = pic->argb;
- color &= 0xffffffu; // force alpha=0
- WebPInitAlphaProcessing();
- while (y-- > 0) {
- WebPAlphaReplace(argb, pic->width, color);
- argb += pic->argb_stride;
- }
- }
-}
-
-void WebPCleanupTransparentArea(WebPPicture* pic) {
- int x, y, w, h;
- if (pic == NULL) return;
- w = pic->width / SIZE;
- h = pic->height / SIZE;
-
- // note: we ignore the left-overs on right/bottom, except for SmoothenBlock().
- if (pic->use_argb) {
- uint32_t argb_value = 0;
- for (y = 0; y < h; ++y) {
- int need_reset = 1;
- for (x = 0; x < w; ++x) {
- const int off = (y * pic->argb_stride + x) * SIZE;
- if (IsTransparentARGBArea(pic->argb + off, pic->argb_stride, SIZE)) {
- if (need_reset) {
- argb_value = pic->argb[off];
- need_reset = 0;
- }
- FlattenARGB(pic->argb + off, argb_value, pic->argb_stride, SIZE);
- } else {
- need_reset = 1;
- }
- }
- }
- } else {
- const int width = pic->width;
- const int height = pic->height;
- const int y_stride = pic->y_stride;
- const int uv_stride = pic->uv_stride;
- const int a_stride = pic->a_stride;
- uint8_t* y_ptr = pic->y;
- uint8_t* u_ptr = pic->u;
- uint8_t* v_ptr = pic->v;
- const uint8_t* a_ptr = pic->a;
- int values[3] = { 0 };
- if (a_ptr == NULL || y_ptr == NULL || u_ptr == NULL || v_ptr == NULL) {
- return;
- }
- for (y = 0; y + SIZE <= height; y += SIZE) {
- int need_reset = 1;
- for (x = 0; x + SIZE <= width; x += SIZE) {
- if (SmoothenBlock(a_ptr + x, a_stride, y_ptr + x, y_stride,
- SIZE, SIZE)) {
- if (need_reset) {
- values[0] = y_ptr[x];
- values[1] = u_ptr[x >> 1];
- values[2] = v_ptr[x >> 1];
- need_reset = 0;
- }
- Flatten(y_ptr + x, values[0], y_stride, SIZE);
- Flatten(u_ptr + (x >> 1), values[1], uv_stride, SIZE2);
- Flatten(v_ptr + (x >> 1), values[2], uv_stride, SIZE2);
- } else {
- need_reset = 1;
- }
- }
- if (x < width) {
- SmoothenBlock(a_ptr + x, a_stride, y_ptr + x, y_stride,
- width - x, SIZE);
- }
- a_ptr += SIZE * a_stride;
- y_ptr += SIZE * y_stride;
- u_ptr += SIZE2 * uv_stride;
- v_ptr += SIZE2 * uv_stride;
- }
- if (y < height) {
- const int sub_height = height - y;
- for (x = 0; x + SIZE <= width; x += SIZE) {
- SmoothenBlock(a_ptr + x, a_stride, y_ptr + x, y_stride,
- SIZE, sub_height);
- }
- if (x < width) {
- SmoothenBlock(a_ptr + x, a_stride, y_ptr + x, y_stride,
- width - x, sub_height);
- }
- }
- }
-}
-
-#undef SIZE
-#undef SIZE2
-
-//------------------------------------------------------------------------------
-// Blend color and remove transparency info
-
-#define BLEND(V0, V1, ALPHA) \
- ((((V0) * (255 - (ALPHA)) + (V1) * (ALPHA)) * 0x101 + 256) >> 16)
-#define BLEND_10BIT(V0, V1, ALPHA) \
- ((((V0) * (1020 - (ALPHA)) + (V1) * (ALPHA)) * 0x101 + 1024) >> 18)
-
-static WEBP_INLINE uint32_t MakeARGB32(int r, int g, int b) {
- return (0xff000000u | (r << 16) | (g << 8) | b);
-}
-
-void WebPBlendAlpha(WebPPicture* pic, uint32_t background_rgb) {
- const int red = (background_rgb >> 16) & 0xff;
- const int green = (background_rgb >> 8) & 0xff;
- const int blue = (background_rgb >> 0) & 0xff;
- int x, y;
- if (pic == NULL) return;
- if (!pic->use_argb) {
- const int uv_width = (pic->width >> 1); // omit last pixel during u/v loop
- const int Y0 = VP8RGBToY(red, green, blue, YUV_HALF);
- // VP8RGBToU/V expects the u/v values summed over four pixels
- const int U0 = VP8RGBToU(4 * red, 4 * green, 4 * blue, 4 * YUV_HALF);
- const int V0 = VP8RGBToV(4 * red, 4 * green, 4 * blue, 4 * YUV_HALF);
- const int has_alpha = pic->colorspace & WEBP_CSP_ALPHA_BIT;
- uint8_t* y_ptr = pic->y;
- uint8_t* u_ptr = pic->u;
- uint8_t* v_ptr = pic->v;
- uint8_t* a_ptr = pic->a;
- if (!has_alpha || a_ptr == NULL) return; // nothing to do
- for (y = 0; y < pic->height; ++y) {
- // Luma blending
- for (x = 0; x < pic->width; ++x) {
- const uint8_t alpha = a_ptr[x];
- if (alpha < 0xff) {
- y_ptr[x] = BLEND(Y0, y_ptr[x], alpha);
- }
- }
- // Chroma blending every even line
- if ((y & 1) == 0) {
- uint8_t* const a_ptr2 =
- (y + 1 == pic->height) ? a_ptr : a_ptr + pic->a_stride;
- for (x = 0; x < uv_width; ++x) {
- // Average four alpha values into a single blending weight.
- // TODO(skal): might lead to visible contouring. Can we do better?
- const uint32_t alpha =
- a_ptr[2 * x + 0] + a_ptr[2 * x + 1] +
- a_ptr2[2 * x + 0] + a_ptr2[2 * x + 1];
- u_ptr[x] = BLEND_10BIT(U0, u_ptr[x], alpha);
- v_ptr[x] = BLEND_10BIT(V0, v_ptr[x], alpha);
- }
- if (pic->width & 1) { // rightmost pixel
- const uint32_t alpha = 2 * (a_ptr[2 * x + 0] + a_ptr2[2 * x + 0]);
- u_ptr[x] = BLEND_10BIT(U0, u_ptr[x], alpha);
- v_ptr[x] = BLEND_10BIT(V0, v_ptr[x], alpha);
- }
- } else {
- u_ptr += pic->uv_stride;
- v_ptr += pic->uv_stride;
- }
- memset(a_ptr, 0xff, pic->width); // reset alpha value to opaque
- a_ptr += pic->a_stride;
- y_ptr += pic->y_stride;
- }
- } else {
- uint32_t* argb = pic->argb;
- const uint32_t background = MakeARGB32(red, green, blue);
- for (y = 0; y < pic->height; ++y) {
- for (x = 0; x < pic->width; ++x) {
- const int alpha = (argb[x] >> 24) & 0xff;
- if (alpha != 0xff) {
- if (alpha > 0) {
- int r = (argb[x] >> 16) & 0xff;
- int g = (argb[x] >> 8) & 0xff;
- int b = (argb[x] >> 0) & 0xff;
- r = BLEND(red, r, alpha);
- g = BLEND(green, g, alpha);
- b = BLEND(blue, b, alpha);
- argb[x] = MakeARGB32(r, g, b);
- } else {
- argb[x] = background;
- }
- }
- }
- argb += pic->argb_stride;
- }
- }
-}
-
-#undef BLEND
-#undef BLEND_10BIT
-
-//------------------------------------------------------------------------------
diff --git a/contrib/libs/libwebp/enc/predictor_enc.c b/contrib/libs/libwebp/enc/predictor_enc.c
deleted file mode 100644
index fa366a1462..0000000000
--- a/contrib/libs/libwebp/enc/predictor_enc.c
+++ /dev/null
@@ -1,772 +0,0 @@
-// Copyright 2016 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Image transform methods for lossless encoder.
-//
-// Authors: Vikas Arora (vikaas.arora@gmail.com)
-// Jyrki Alakuijala (jyrki@google.com)
-// Urvang Joshi (urvang@google.com)
-// Vincent Rabaud (vrabaud@google.com)
-
-#include "../dsp/lossless.h"
-#include "../dsp/lossless_common.h"
-#include "./vp8li_enc.h"
-
-#define MAX_DIFF_COST (1e30f)
-
-static const float kSpatialPredictorBias = 15.f;
-static const int kPredLowEffort = 11;
-static const uint32_t kMaskAlpha = 0xff000000;
-
-// Mostly used to reduce code size + readability
-static WEBP_INLINE int GetMin(int a, int b) { return (a > b) ? b : a; }
-
-//------------------------------------------------------------------------------
-// Methods to calculate Entropy (Shannon).
-
-static float PredictionCostSpatial(const int counts[256], int weight_0,
- double exp_val) {
- const int significant_symbols = 256 >> 4;
- const double exp_decay_factor = 0.6;
- double bits = weight_0 * counts[0];
- int i;
- for (i = 1; i < significant_symbols; ++i) {
- bits += exp_val * (counts[i] + counts[256 - i]);
- exp_val *= exp_decay_factor;
- }
- return (float)(-0.1 * bits);
-}
-
-static float PredictionCostSpatialHistogram(const int accumulated[4][256],
- const int tile[4][256]) {
- int i;
- double retval = 0;
- for (i = 0; i < 4; ++i) {
- const double kExpValue = 0.94;
- retval += PredictionCostSpatial(tile[i], 1, kExpValue);
- retval += VP8LCombinedShannonEntropy(tile[i], accumulated[i]);
- }
- return (float)retval;
-}
-
-static WEBP_INLINE void UpdateHisto(int histo_argb[4][256], uint32_t argb) {
- ++histo_argb[0][argb >> 24];
- ++histo_argb[1][(argb >> 16) & 0xff];
- ++histo_argb[2][(argb >> 8) & 0xff];
- ++histo_argb[3][argb & 0xff];
-}
-
-//------------------------------------------------------------------------------
-// Spatial transform functions.
-
-static WEBP_INLINE void PredictBatch(int mode, int x_start, int y,
- int num_pixels, const uint32_t* current,
- const uint32_t* upper, uint32_t* out) {
- if (x_start == 0) {
- if (y == 0) {
- // ARGB_BLACK.
- VP8LPredictorsSub[0](current, NULL, 1, out);
- } else {
- // Top one.
- VP8LPredictorsSub[2](current, upper, 1, out);
- }
- ++x_start;
- ++out;
- --num_pixels;
- }
- if (y == 0) {
- // Left one.
- VP8LPredictorsSub[1](current + x_start, NULL, num_pixels, out);
- } else {
- VP8LPredictorsSub[mode](current + x_start, upper + x_start, num_pixels,
- out);
- }
-}
-
-#if (WEBP_NEAR_LOSSLESS == 1)
-static WEBP_INLINE int GetMax(int a, int b) { return (a < b) ? b : a; }
-
-static int MaxDiffBetweenPixels(uint32_t p1, uint32_t p2) {
- const int diff_a = abs((int)(p1 >> 24) - (int)(p2 >> 24));
- const int diff_r = abs((int)((p1 >> 16) & 0xff) - (int)((p2 >> 16) & 0xff));
- const int diff_g = abs((int)((p1 >> 8) & 0xff) - (int)((p2 >> 8) & 0xff));
- const int diff_b = abs((int)(p1 & 0xff) - (int)(p2 & 0xff));
- return GetMax(GetMax(diff_a, diff_r), GetMax(diff_g, diff_b));
-}
-
-static int MaxDiffAroundPixel(uint32_t current, uint32_t up, uint32_t down,
- uint32_t left, uint32_t right) {
- const int diff_up = MaxDiffBetweenPixels(current, up);
- const int diff_down = MaxDiffBetweenPixels(current, down);
- const int diff_left = MaxDiffBetweenPixels(current, left);
- const int diff_right = MaxDiffBetweenPixels(current, right);
- return GetMax(GetMax(diff_up, diff_down), GetMax(diff_left, diff_right));
-}
-
-static uint32_t AddGreenToBlueAndRed(uint32_t argb) {
- const uint32_t green = (argb >> 8) & 0xff;
- uint32_t red_blue = argb & 0x00ff00ffu;
- red_blue += (green << 16) | green;
- red_blue &= 0x00ff00ffu;
- return (argb & 0xff00ff00u) | red_blue;
-}
-
-static void MaxDiffsForRow(int width, int stride, const uint32_t* const argb,
- uint8_t* const max_diffs, int used_subtract_green) {
- uint32_t current, up, down, left, right;
- int x;
- if (width <= 2) return;
- current = argb[0];
- right = argb[1];
- if (used_subtract_green) {
- current = AddGreenToBlueAndRed(current);
- right = AddGreenToBlueAndRed(right);
- }
- // max_diffs[0] and max_diffs[width - 1] are never used.
- for (x = 1; x < width - 1; ++x) {
- up = argb[-stride + x];
- down = argb[stride + x];
- left = current;
- current = right;
- right = argb[x + 1];
- if (used_subtract_green) {
- up = AddGreenToBlueAndRed(up);
- down = AddGreenToBlueAndRed(down);
- right = AddGreenToBlueAndRed(right);
- }
- max_diffs[x] = MaxDiffAroundPixel(current, up, down, left, right);
- }
-}
-
-// Quantize the difference between the actual component value and its prediction
-// to a multiple of quantization, working modulo 256, taking care not to cross
-// a boundary (inclusive upper limit).
-static uint8_t NearLosslessComponent(uint8_t value, uint8_t predict,
- uint8_t boundary, int quantization) {
- const int residual = (value - predict) & 0xff;
- const int boundary_residual = (boundary - predict) & 0xff;
- const int lower = residual & ~(quantization - 1);
- const int upper = lower + quantization;
- // Resolve ties towards a value closer to the prediction (i.e. towards lower
- // if value comes after prediction and towards upper otherwise).
- const int bias = ((boundary - value) & 0xff) < boundary_residual;
- if (residual - lower < upper - residual + bias) {
- // lower is closer to residual than upper.
- if (residual > boundary_residual && lower <= boundary_residual) {
- // Halve quantization step to avoid crossing boundary. This midpoint is
- // on the same side of boundary as residual because midpoint >= residual
- // (since lower is closer than upper) and residual is above the boundary.
- return lower + (quantization >> 1);
- }
- return lower;
- } else {
- // upper is closer to residual than lower.
- if (residual <= boundary_residual && upper > boundary_residual) {
- // Halve quantization step to avoid crossing boundary. This midpoint is
- // on the same side of boundary as residual because midpoint <= residual
- // (since upper is closer than lower) and residual is below the boundary.
- return lower + (quantization >> 1);
- }
- return upper & 0xff;
- }
-}
-
-static WEBP_INLINE uint8_t NearLosslessDiff(uint8_t a, uint8_t b) {
- return (uint8_t)((((int)(a) - (int)(b))) & 0xff);
-}
-
-// Quantize every component of the difference between the actual pixel value and
-// its prediction to a multiple of a quantization (a power of 2, not larger than
-// max_quantization which is a power of 2, smaller than max_diff). Take care if
-// value and predict have undergone subtract green, which means that red and
-// blue are represented as offsets from green.
-static uint32_t NearLossless(uint32_t value, uint32_t predict,
- int max_quantization, int max_diff,
- int used_subtract_green) {
- int quantization;
- uint8_t new_green = 0;
- uint8_t green_diff = 0;
- uint8_t a, r, g, b;
- if (max_diff <= 2) {
- return VP8LSubPixels(value, predict);
- }
- quantization = max_quantization;
- while (quantization >= max_diff) {
- quantization >>= 1;
- }
- if ((value >> 24) == 0 || (value >> 24) == 0xff) {
- // Preserve transparency of fully transparent or fully opaque pixels.
- a = NearLosslessDiff((value >> 24) & 0xff, (predict >> 24) & 0xff);
- } else {
- a = NearLosslessComponent(value >> 24, predict >> 24, 0xff, quantization);
- }
- g = NearLosslessComponent((value >> 8) & 0xff, (predict >> 8) & 0xff, 0xff,
- quantization);
- if (used_subtract_green) {
- // The green offset will be added to red and blue components during decoding
- // to obtain the actual red and blue values.
- new_green = ((predict >> 8) + g) & 0xff;
- // The amount by which green has been adjusted during quantization. It is
- // subtracted from red and blue for compensation, to avoid accumulating two
- // quantization errors in them.
- green_diff = NearLosslessDiff(new_green, (value >> 8) & 0xff);
- }
- r = NearLosslessComponent(NearLosslessDiff((value >> 16) & 0xff, green_diff),
- (predict >> 16) & 0xff, 0xff - new_green,
- quantization);
- b = NearLosslessComponent(NearLosslessDiff(value & 0xff, green_diff),
- predict & 0xff, 0xff - new_green, quantization);
- return ((uint32_t)a << 24) | ((uint32_t)r << 16) | ((uint32_t)g << 8) | b;
-}
-#endif // (WEBP_NEAR_LOSSLESS == 1)
-
-// Stores the difference between the pixel and its prediction in "out".
-// In case of a lossy encoding, updates the source image to avoid propagating
-// the deviation further to pixels which depend on the current pixel for their
-// predictions.
-static WEBP_INLINE void GetResidual(
- int width, int height, uint32_t* const upper_row,
- uint32_t* const current_row, const uint8_t* const max_diffs, int mode,
- int x_start, int x_end, int y, int max_quantization, int exact,
- int used_subtract_green, uint32_t* const out) {
- if (exact) {
- PredictBatch(mode, x_start, y, x_end - x_start, current_row, upper_row,
- out);
- } else {
- const VP8LPredictorFunc pred_func = VP8LPredictors[mode];
- int x;
- for (x = x_start; x < x_end; ++x) {
- uint32_t predict;
- uint32_t residual;
- if (y == 0) {
- predict = (x == 0) ? ARGB_BLACK : current_row[x - 1]; // Left.
- } else if (x == 0) {
- predict = upper_row[x]; // Top.
- } else {
- predict = pred_func(&current_row[x - 1], upper_row + x);
- }
-#if (WEBP_NEAR_LOSSLESS == 1)
- if (max_quantization == 1 || mode == 0 || y == 0 || y == height - 1 ||
- x == 0 || x == width - 1) {
- residual = VP8LSubPixels(current_row[x], predict);
- } else {
- residual = NearLossless(current_row[x], predict, max_quantization,
- max_diffs[x], used_subtract_green);
- // Update the source image.
- current_row[x] = VP8LAddPixels(predict, residual);
- // x is never 0 here so we do not need to update upper_row like below.
- }
-#else
- (void)max_diffs;
- (void)height;
- (void)max_quantization;
- (void)used_subtract_green;
- residual = VP8LSubPixels(current_row[x], predict);
-#endif
- if ((current_row[x] & kMaskAlpha) == 0) {
- // If alpha is 0, cleanup RGB. We can choose the RGB values of the
- // residual for best compression. The prediction of alpha itself can be
- // non-zero and must be kept though. We choose RGB of the residual to be
- // 0.
- residual &= kMaskAlpha;
- // Update the source image.
- current_row[x] = predict & ~kMaskAlpha;
- // The prediction for the rightmost pixel in a row uses the leftmost
- // pixel
- // in that row as its top-right context pixel. Hence if we change the
- // leftmost pixel of current_row, the corresponding change must be
- // applied
- // to upper_row as well where top-right context is being read from.
- if (x == 0 && y != 0) upper_row[width] = current_row[0];
- }
- out[x - x_start] = residual;
- }
- }
-}
-
-// Returns best predictor and updates the accumulated histogram.
-// If max_quantization > 1, assumes that near lossless processing will be
-// applied, quantizing residuals to multiples of quantization levels up to
-// max_quantization (the actual quantization level depends on smoothness near
-// the given pixel).
-static int GetBestPredictorForTile(int width, int height,
- int tile_x, int tile_y, int bits,
- int accumulated[4][256],
- uint32_t* const argb_scratch,
- const uint32_t* const argb,
- int max_quantization,
- int exact, int used_subtract_green,
- const uint32_t* const modes) {
- const int kNumPredModes = 14;
- const int start_x = tile_x << bits;
- const int start_y = tile_y << bits;
- const int tile_size = 1 << bits;
- const int max_y = GetMin(tile_size, height - start_y);
- const int max_x = GetMin(tile_size, width - start_x);
- // Whether there exist columns just outside the tile.
- const int have_left = (start_x > 0);
- // Position and size of the strip covering the tile and adjacent columns if
- // they exist.
- const int context_start_x = start_x - have_left;
-#if (WEBP_NEAR_LOSSLESS == 1)
- const int context_width = max_x + have_left + (max_x < width - start_x);
-#endif
- const int tiles_per_row = VP8LSubSampleSize(width, bits);
- // Prediction modes of the left and above neighbor tiles.
- const int left_mode = (tile_x > 0) ?
- (modes[tile_y * tiles_per_row + tile_x - 1] >> 8) & 0xff : 0xff;
- const int above_mode = (tile_y > 0) ?
- (modes[(tile_y - 1) * tiles_per_row + tile_x] >> 8) & 0xff : 0xff;
- // The width of upper_row and current_row is one pixel larger than image width
- // to allow the top right pixel to point to the leftmost pixel of the next row
- // when at the right edge.
- uint32_t* upper_row = argb_scratch;
- uint32_t* current_row = upper_row + width + 1;
- uint8_t* const max_diffs = (uint8_t*)(current_row + width + 1);
- float best_diff = MAX_DIFF_COST;
- int best_mode = 0;
- int mode;
- int histo_stack_1[4][256];
- int histo_stack_2[4][256];
- // Need pointers to be able to swap arrays.
- int (*histo_argb)[256] = histo_stack_1;
- int (*best_histo)[256] = histo_stack_2;
- int i, j;
- uint32_t residuals[1 << MAX_TRANSFORM_BITS];
- assert(bits <= MAX_TRANSFORM_BITS);
- assert(max_x <= (1 << MAX_TRANSFORM_BITS));
-
- for (mode = 0; mode < kNumPredModes; ++mode) {
- float cur_diff;
- int relative_y;
- memset(histo_argb, 0, sizeof(histo_stack_1));
- if (start_y > 0) {
- // Read the row above the tile which will become the first upper_row.
- // Include a pixel to the left if it exists; include a pixel to the right
- // in all cases (wrapping to the leftmost pixel of the next row if it does
- // not exist).
- memcpy(current_row + context_start_x,
- argb + (start_y - 1) * width + context_start_x,
- sizeof(*argb) * (max_x + have_left + 1));
- }
- for (relative_y = 0; relative_y < max_y; ++relative_y) {
- const int y = start_y + relative_y;
- int relative_x;
- uint32_t* tmp = upper_row;
- upper_row = current_row;
- current_row = tmp;
- // Read current_row. Include a pixel to the left if it exists; include a
- // pixel to the right in all cases except at the bottom right corner of
- // the image (wrapping to the leftmost pixel of the next row if it does
- // not exist in the current row).
- memcpy(current_row + context_start_x,
- argb + y * width + context_start_x,
- sizeof(*argb) * (max_x + have_left + (y + 1 < height)));
-#if (WEBP_NEAR_LOSSLESS == 1)
- if (max_quantization > 1 && y >= 1 && y + 1 < height) {
- MaxDiffsForRow(context_width, width, argb + y * width + context_start_x,
- max_diffs + context_start_x, used_subtract_green);
- }
-#endif
-
- GetResidual(width, height, upper_row, current_row, max_diffs, mode,
- start_x, start_x + max_x, y, max_quantization, exact,
- used_subtract_green, residuals);
- for (relative_x = 0; relative_x < max_x; ++relative_x) {
- UpdateHisto(histo_argb, residuals[relative_x]);
- }
- }
- cur_diff = PredictionCostSpatialHistogram(
- (const int (*)[256])accumulated, (const int (*)[256])histo_argb);
- // Favor keeping the areas locally similar.
- if (mode == left_mode) cur_diff -= kSpatialPredictorBias;
- if (mode == above_mode) cur_diff -= kSpatialPredictorBias;
-
- if (cur_diff < best_diff) {
- int (*tmp)[256] = histo_argb;
- histo_argb = best_histo;
- best_histo = tmp;
- best_diff = cur_diff;
- best_mode = mode;
- }
- }
-
- for (i = 0; i < 4; i++) {
- for (j = 0; j < 256; j++) {
- accumulated[i][j] += best_histo[i][j];
- }
- }
-
- return best_mode;
-}
-
-// Converts pixels of the image to residuals with respect to predictions.
-// If max_quantization > 1, applies near lossless processing, quantizing
-// residuals to multiples of quantization levels up to max_quantization
-// (the actual quantization level depends on smoothness near the given pixel).
-static void CopyImageWithPrediction(int width, int height,
- int bits, uint32_t* const modes,
- uint32_t* const argb_scratch,
- uint32_t* const argb,
- int low_effort, int max_quantization,
- int exact, int used_subtract_green) {
- const int tiles_per_row = VP8LSubSampleSize(width, bits);
- // The width of upper_row and current_row is one pixel larger than image width
- // to allow the top right pixel to point to the leftmost pixel of the next row
- // when at the right edge.
- uint32_t* upper_row = argb_scratch;
- uint32_t* current_row = upper_row + width + 1;
- uint8_t* current_max_diffs = (uint8_t*)(current_row + width + 1);
-#if (WEBP_NEAR_LOSSLESS == 1)
- uint8_t* lower_max_diffs = current_max_diffs + width;
-#endif
- int y;
-
- for (y = 0; y < height; ++y) {
- int x;
- uint32_t* const tmp32 = upper_row;
- upper_row = current_row;
- current_row = tmp32;
- memcpy(current_row, argb + y * width,
- sizeof(*argb) * (width + (y + 1 < height)));
-
- if (low_effort) {
- PredictBatch(kPredLowEffort, 0, y, width, current_row, upper_row,
- argb + y * width);
- } else {
-#if (WEBP_NEAR_LOSSLESS == 1)
- if (max_quantization > 1) {
- // Compute max_diffs for the lower row now, because that needs the
- // contents of argb for the current row, which we will overwrite with
- // residuals before proceeding with the next row.
- uint8_t* const tmp8 = current_max_diffs;
- current_max_diffs = lower_max_diffs;
- lower_max_diffs = tmp8;
- if (y + 2 < height) {
- MaxDiffsForRow(width, width, argb + (y + 1) * width, lower_max_diffs,
- used_subtract_green);
- }
- }
-#endif
- for (x = 0; x < width;) {
- const int mode =
- (modes[(y >> bits) * tiles_per_row + (x >> bits)] >> 8) & 0xff;
- int x_end = x + (1 << bits);
- if (x_end > width) x_end = width;
- GetResidual(width, height, upper_row, current_row, current_max_diffs,
- mode, x, x_end, y, max_quantization, exact,
- used_subtract_green, argb + y * width + x);
- x = x_end;
- }
- }
- }
-}
-
-// Finds the best predictor for each tile, and converts the image to residuals
-// with respect to predictions. If near_lossless_quality < 100, applies
-// near lossless processing, shaving off more bits of residuals for lower
-// qualities.
-void VP8LResidualImage(int width, int height, int bits, int low_effort,
- uint32_t* const argb, uint32_t* const argb_scratch,
- uint32_t* const image, int near_lossless_quality,
- int exact, int used_subtract_green) {
- const int tiles_per_row = VP8LSubSampleSize(width, bits);
- const int tiles_per_col = VP8LSubSampleSize(height, bits);
- int tile_y;
- int histo[4][256];
- const int max_quantization = 1 << VP8LNearLosslessBits(near_lossless_quality);
- if (low_effort) {
- int i;
- for (i = 0; i < tiles_per_row * tiles_per_col; ++i) {
- image[i] = ARGB_BLACK | (kPredLowEffort << 8);
- }
- } else {
- memset(histo, 0, sizeof(histo));
- for (tile_y = 0; tile_y < tiles_per_col; ++tile_y) {
- int tile_x;
- for (tile_x = 0; tile_x < tiles_per_row; ++tile_x) {
- const int pred = GetBestPredictorForTile(width, height, tile_x, tile_y,
- bits, histo, argb_scratch, argb, max_quantization, exact,
- used_subtract_green, image);
- image[tile_y * tiles_per_row + tile_x] = ARGB_BLACK | (pred << 8);
- }
- }
- }
-
- CopyImageWithPrediction(width, height, bits, image, argb_scratch, argb,
- low_effort, max_quantization, exact,
- used_subtract_green);
-}
-
-//------------------------------------------------------------------------------
-// Color transform functions.
-
-static WEBP_INLINE void MultipliersClear(VP8LMultipliers* const m) {
- m->green_to_red_ = 0;
- m->green_to_blue_ = 0;
- m->red_to_blue_ = 0;
-}
-
-static WEBP_INLINE void ColorCodeToMultipliers(uint32_t color_code,
- VP8LMultipliers* const m) {
- m->green_to_red_ = (color_code >> 0) & 0xff;
- m->green_to_blue_ = (color_code >> 8) & 0xff;
- m->red_to_blue_ = (color_code >> 16) & 0xff;
-}
-
-static WEBP_INLINE uint32_t MultipliersToColorCode(
- const VP8LMultipliers* const m) {
- return 0xff000000u |
- ((uint32_t)(m->red_to_blue_) << 16) |
- ((uint32_t)(m->green_to_blue_) << 8) |
- m->green_to_red_;
-}
-
-static float PredictionCostCrossColor(const int accumulated[256],
- const int counts[256]) {
- // Favor low entropy, locally and globally.
- // Favor small absolute values for PredictionCostSpatial
- static const double kExpValue = 2.4;
- return VP8LCombinedShannonEntropy(counts, accumulated) +
- PredictionCostSpatial(counts, 3, kExpValue);
-}
-
-static float GetPredictionCostCrossColorRed(
- const uint32_t* argb, int stride, int tile_width, int tile_height,
- VP8LMultipliers prev_x, VP8LMultipliers prev_y, int green_to_red,
- const int accumulated_red_histo[256]) {
- int histo[256] = { 0 };
- float cur_diff;
-
- VP8LCollectColorRedTransforms(argb, stride, tile_width, tile_height,
- green_to_red, histo);
-
- cur_diff = PredictionCostCrossColor(accumulated_red_histo, histo);
- if ((uint8_t)green_to_red == prev_x.green_to_red_) {
- cur_diff -= 3; // favor keeping the areas locally similar
- }
- if ((uint8_t)green_to_red == prev_y.green_to_red_) {
- cur_diff -= 3; // favor keeping the areas locally similar
- }
- if (green_to_red == 0) {
- cur_diff -= 3;
- }
- return cur_diff;
-}
-
-static void GetBestGreenToRed(
- const uint32_t* argb, int stride, int tile_width, int tile_height,
- VP8LMultipliers prev_x, VP8LMultipliers prev_y, int quality,
- const int accumulated_red_histo[256], VP8LMultipliers* const best_tx) {
- const int kMaxIters = 4 + ((7 * quality) >> 8); // in range [4..6]
- int green_to_red_best = 0;
- int iter, offset;
- float best_diff = GetPredictionCostCrossColorRed(
- argb, stride, tile_width, tile_height, prev_x, prev_y,
- green_to_red_best, accumulated_red_histo);
- for (iter = 0; iter < kMaxIters; ++iter) {
- // ColorTransformDelta is a 3.5 bit fixed point, so 32 is equal to
- // one in color computation. Having initial delta here as 1 is sufficient
- // to explore the range of (-2, 2).
- const int delta = 32 >> iter;
- // Try a negative and a positive delta from the best known value.
- for (offset = -delta; offset <= delta; offset += 2 * delta) {
- const int green_to_red_cur = offset + green_to_red_best;
- const float cur_diff = GetPredictionCostCrossColorRed(
- argb, stride, tile_width, tile_height, prev_x, prev_y,
- green_to_red_cur, accumulated_red_histo);
- if (cur_diff < best_diff) {
- best_diff = cur_diff;
- green_to_red_best = green_to_red_cur;
- }
- }
- }
- best_tx->green_to_red_ = (green_to_red_best & 0xff);
-}
-
-static float GetPredictionCostCrossColorBlue(
- const uint32_t* argb, int stride, int tile_width, int tile_height,
- VP8LMultipliers prev_x, VP8LMultipliers prev_y,
- int green_to_blue, int red_to_blue, const int accumulated_blue_histo[256]) {
- int histo[256] = { 0 };
- float cur_diff;
-
- VP8LCollectColorBlueTransforms(argb, stride, tile_width, tile_height,
- green_to_blue, red_to_blue, histo);
-
- cur_diff = PredictionCostCrossColor(accumulated_blue_histo, histo);
- if ((uint8_t)green_to_blue == prev_x.green_to_blue_) {
- cur_diff -= 3; // favor keeping the areas locally similar
- }
- if ((uint8_t)green_to_blue == prev_y.green_to_blue_) {
- cur_diff -= 3; // favor keeping the areas locally similar
- }
- if ((uint8_t)red_to_blue == prev_x.red_to_blue_) {
- cur_diff -= 3; // favor keeping the areas locally similar
- }
- if ((uint8_t)red_to_blue == prev_y.red_to_blue_) {
- cur_diff -= 3; // favor keeping the areas locally similar
- }
- if (green_to_blue == 0) {
- cur_diff -= 3;
- }
- if (red_to_blue == 0) {
- cur_diff -= 3;
- }
- return cur_diff;
-}
-
-#define kGreenRedToBlueNumAxis 8
-#define kGreenRedToBlueMaxIters 7
-static void GetBestGreenRedToBlue(
- const uint32_t* argb, int stride, int tile_width, int tile_height,
- VP8LMultipliers prev_x, VP8LMultipliers prev_y, int quality,
- const int accumulated_blue_histo[256],
- VP8LMultipliers* const best_tx) {
- const int8_t offset[kGreenRedToBlueNumAxis][2] =
- {{0, -1}, {0, 1}, {-1, 0}, {1, 0}, {-1, -1}, {-1, 1}, {1, -1}, {1, 1}};
- const int8_t delta_lut[kGreenRedToBlueMaxIters] = { 16, 16, 8, 4, 2, 2, 2 };
- const int iters =
- (quality < 25) ? 1 : (quality > 50) ? kGreenRedToBlueMaxIters : 4;
- int green_to_blue_best = 0;
- int red_to_blue_best = 0;
- int iter;
- // Initial value at origin:
- float best_diff = GetPredictionCostCrossColorBlue(
- argb, stride, tile_width, tile_height, prev_x, prev_y,
- green_to_blue_best, red_to_blue_best, accumulated_blue_histo);
- for (iter = 0; iter < iters; ++iter) {
- const int delta = delta_lut[iter];
- int axis;
- for (axis = 0; axis < kGreenRedToBlueNumAxis; ++axis) {
- const int green_to_blue_cur =
- offset[axis][0] * delta + green_to_blue_best;
- const int red_to_blue_cur = offset[axis][1] * delta + red_to_blue_best;
- const float cur_diff = GetPredictionCostCrossColorBlue(
- argb, stride, tile_width, tile_height, prev_x, prev_y,
- green_to_blue_cur, red_to_blue_cur, accumulated_blue_histo);
- if (cur_diff < best_diff) {
- best_diff = cur_diff;
- green_to_blue_best = green_to_blue_cur;
- red_to_blue_best = red_to_blue_cur;
- }
- if (quality < 25 && iter == 4) {
- // Only axis aligned diffs for lower quality.
- break; // next iter.
- }
- }
- if (delta == 2 && green_to_blue_best == 0 && red_to_blue_best == 0) {
- // Further iterations would not help.
- break; // out of iter-loop.
- }
- }
- best_tx->green_to_blue_ = green_to_blue_best & 0xff;
- best_tx->red_to_blue_ = red_to_blue_best & 0xff;
-}
-#undef kGreenRedToBlueMaxIters
-#undef kGreenRedToBlueNumAxis
-
-static VP8LMultipliers GetBestColorTransformForTile(
- int tile_x, int tile_y, int bits,
- VP8LMultipliers prev_x,
- VP8LMultipliers prev_y,
- int quality, int xsize, int ysize,
- const int accumulated_red_histo[256],
- const int accumulated_blue_histo[256],
- const uint32_t* const argb) {
- const int max_tile_size = 1 << bits;
- const int tile_y_offset = tile_y * max_tile_size;
- const int tile_x_offset = tile_x * max_tile_size;
- const int all_x_max = GetMin(tile_x_offset + max_tile_size, xsize);
- const int all_y_max = GetMin(tile_y_offset + max_tile_size, ysize);
- const int tile_width = all_x_max - tile_x_offset;
- const int tile_height = all_y_max - tile_y_offset;
- const uint32_t* const tile_argb = argb + tile_y_offset * xsize
- + tile_x_offset;
- VP8LMultipliers best_tx;
- MultipliersClear(&best_tx);
-
- GetBestGreenToRed(tile_argb, xsize, tile_width, tile_height,
- prev_x, prev_y, quality, accumulated_red_histo, &best_tx);
- GetBestGreenRedToBlue(tile_argb, xsize, tile_width, tile_height,
- prev_x, prev_y, quality, accumulated_blue_histo,
- &best_tx);
- return best_tx;
-}
-
-static void CopyTileWithColorTransform(int xsize, int ysize,
- int tile_x, int tile_y,
- int max_tile_size,
- VP8LMultipliers color_transform,
- uint32_t* argb) {
- const int xscan = GetMin(max_tile_size, xsize - tile_x);
- int yscan = GetMin(max_tile_size, ysize - tile_y);
- argb += tile_y * xsize + tile_x;
- while (yscan-- > 0) {
- VP8LTransformColor(&color_transform, argb, xscan);
- argb += xsize;
- }
-}
-
-void VP8LColorSpaceTransform(int width, int height, int bits, int quality,
- uint32_t* const argb, uint32_t* image) {
- const int max_tile_size = 1 << bits;
- const int tile_xsize = VP8LSubSampleSize(width, bits);
- const int tile_ysize = VP8LSubSampleSize(height, bits);
- int accumulated_red_histo[256] = { 0 };
- int accumulated_blue_histo[256] = { 0 };
- int tile_x, tile_y;
- VP8LMultipliers prev_x, prev_y;
- MultipliersClear(&prev_y);
- MultipliersClear(&prev_x);
- for (tile_y = 0; tile_y < tile_ysize; ++tile_y) {
- for (tile_x = 0; tile_x < tile_xsize; ++tile_x) {
- int y;
- const int tile_x_offset = tile_x * max_tile_size;
- const int tile_y_offset = tile_y * max_tile_size;
- const int all_x_max = GetMin(tile_x_offset + max_tile_size, width);
- const int all_y_max = GetMin(tile_y_offset + max_tile_size, height);
- const int offset = tile_y * tile_xsize + tile_x;
- if (tile_y != 0) {
- ColorCodeToMultipliers(image[offset - tile_xsize], &prev_y);
- }
- prev_x = GetBestColorTransformForTile(tile_x, tile_y, bits,
- prev_x, prev_y,
- quality, width, height,
- accumulated_red_histo,
- accumulated_blue_histo,
- argb);
- image[offset] = MultipliersToColorCode(&prev_x);
- CopyTileWithColorTransform(width, height, tile_x_offset, tile_y_offset,
- max_tile_size, prev_x, argb);
-
- // Gather accumulated histogram data.
- for (y = tile_y_offset; y < all_y_max; ++y) {
- int ix = y * width + tile_x_offset;
- const int ix_end = ix + all_x_max - tile_x_offset;
- for (; ix < ix_end; ++ix) {
- const uint32_t pix = argb[ix];
- if (ix >= 2 &&
- pix == argb[ix - 2] &&
- pix == argb[ix - 1]) {
- continue; // repeated pixels are handled by backward references
- }
- if (ix >= width + 2 &&
- argb[ix - 2] == argb[ix - width - 2] &&
- argb[ix - 1] == argb[ix - width - 1] &&
- pix == argb[ix - width]) {
- continue; // repeated pixels are handled by backward references
- }
- ++accumulated_red_histo[(pix >> 16) & 0xff];
- ++accumulated_blue_histo[(pix >> 0) & 0xff];
- }
- }
- }
- }
-}
diff --git a/contrib/libs/libwebp/enc/quant_enc.c b/contrib/libs/libwebp/enc/quant_enc.c
deleted file mode 100644
index 881e014eea..0000000000
--- a/contrib/libs/libwebp/enc/quant_enc.c
+++ /dev/null
@@ -1,1388 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Quantization
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include <assert.h>
-#include <math.h>
-#include <stdlib.h> // for abs()
-
-#include "../dsp/quant.h"
-#include "./vp8i_enc.h"
-#include "./cost_enc.h"
-
-#define DO_TRELLIS_I4 1
-#define DO_TRELLIS_I16 1 // not a huge gain, but ok at low bitrate.
-#define DO_TRELLIS_UV 0 // disable trellis for UV. Risky. Not worth.
-#define USE_TDISTO 1
-
-#define MID_ALPHA 64 // neutral value for susceptibility
-#define MIN_ALPHA 30 // lowest usable value for susceptibility
-#define MAX_ALPHA 100 // higher meaningful value for susceptibility
-
-#define SNS_TO_DQ 0.9 // Scaling constant between the sns value and the QP
- // power-law modulation. Must be strictly less than 1.
-
-// number of non-zero coeffs below which we consider the block very flat
-// (and apply a penalty to complex predictions)
-#define FLATNESS_LIMIT_I16 0 // I16 mode (special case)
-#define FLATNESS_LIMIT_I4 3 // I4 mode
-#define FLATNESS_LIMIT_UV 2 // UV mode
-#define FLATNESS_PENALTY 140 // roughly ~1bit per block
-
-#define MULT_8B(a, b) (((a) * (b) + 128) >> 8)
-
-#define RD_DISTO_MULT 256 // distortion multiplier (equivalent of lambda)
-
-// #define DEBUG_BLOCK
-
-//------------------------------------------------------------------------------
-
-#if defined(DEBUG_BLOCK)
-
-#include <stdio.h>
-#include <stdlib.h>
-
-static void PrintBlockInfo(const VP8EncIterator* const it,
- const VP8ModeScore* const rd) {
- int i, j;
- const int is_i16 = (it->mb_->type_ == 1);
- const uint8_t* const y_in = it->yuv_in_ + Y_OFF_ENC;
- const uint8_t* const y_out = it->yuv_out_ + Y_OFF_ENC;
- const uint8_t* const uv_in = it->yuv_in_ + U_OFF_ENC;
- const uint8_t* const uv_out = it->yuv_out_ + U_OFF_ENC;
- printf("SOURCE / OUTPUT / ABS DELTA\n");
- for (j = 0; j < 16; ++j) {
- for (i = 0; i < 16; ++i) printf("%3d ", y_in[i + j * BPS]);
- printf(" ");
- for (i = 0; i < 16; ++i) printf("%3d ", y_out[i + j * BPS]);
- printf(" ");
- for (i = 0; i < 16; ++i) {
- printf("%1d ", abs(y_in[i + j * BPS] - y_out[i + j * BPS]));
- }
- printf("\n");
- }
- printf("\n"); // newline before the U/V block
- for (j = 0; j < 8; ++j) {
- for (i = 0; i < 8; ++i) printf("%3d ", uv_in[i + j * BPS]);
- printf(" ");
- for (i = 8; i < 16; ++i) printf("%3d ", uv_in[i + j * BPS]);
- printf(" ");
- for (i = 0; i < 8; ++i) printf("%3d ", uv_out[i + j * BPS]);
- printf(" ");
- for (i = 8; i < 16; ++i) printf("%3d ", uv_out[i + j * BPS]);
- printf(" ");
- for (i = 0; i < 8; ++i) {
- printf("%1d ", abs(uv_out[i + j * BPS] - uv_in[i + j * BPS]));
- }
- printf(" ");
- for (i = 8; i < 16; ++i) {
- printf("%1d ", abs(uv_out[i + j * BPS] - uv_in[i + j * BPS]));
- }
- printf("\n");
- }
- printf("\nD:%d SD:%d R:%d H:%d nz:0x%x score:%d\n",
- (int)rd->D, (int)rd->SD, (int)rd->R, (int)rd->H, (int)rd->nz,
- (int)rd->score);
- if (is_i16) {
- printf("Mode: %d\n", rd->mode_i16);
- printf("y_dc_levels:");
- for (i = 0; i < 16; ++i) printf("%3d ", rd->y_dc_levels[i]);
- printf("\n");
- } else {
- printf("Modes[16]: ");
- for (i = 0; i < 16; ++i) printf("%d ", rd->modes_i4[i]);
- printf("\n");
- }
- printf("y_ac_levels:\n");
- for (j = 0; j < 16; ++j) {
- for (i = is_i16 ? 1 : 0; i < 16; ++i) {
- printf("%4d ", rd->y_ac_levels[j][i]);
- }
- printf("\n");
- }
- printf("\n");
- printf("uv_levels (mode=%d):\n", rd->mode_uv);
- for (j = 0; j < 8; ++j) {
- for (i = 0; i < 16; ++i) {
- printf("%4d ", rd->uv_levels[j][i]);
- }
- printf("\n");
- }
-}
-
-#endif // DEBUG_BLOCK
-
-//------------------------------------------------------------------------------
-
-static WEBP_INLINE int clip(int v, int m, int M) {
- return v < m ? m : v > M ? M : v;
-}
-
-static const uint8_t kZigzag[16] = {
- 0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15
-};
-
-static const uint8_t kDcTable[128] = {
- 4, 5, 6, 7, 8, 9, 10, 10,
- 11, 12, 13, 14, 15, 16, 17, 17,
- 18, 19, 20, 20, 21, 21, 22, 22,
- 23, 23, 24, 25, 25, 26, 27, 28,
- 29, 30, 31, 32, 33, 34, 35, 36,
- 37, 37, 38, 39, 40, 41, 42, 43,
- 44, 45, 46, 46, 47, 48, 49, 50,
- 51, 52, 53, 54, 55, 56, 57, 58,
- 59, 60, 61, 62, 63, 64, 65, 66,
- 67, 68, 69, 70, 71, 72, 73, 74,
- 75, 76, 76, 77, 78, 79, 80, 81,
- 82, 83, 84, 85, 86, 87, 88, 89,
- 91, 93, 95, 96, 98, 100, 101, 102,
- 104, 106, 108, 110, 112, 114, 116, 118,
- 122, 124, 126, 128, 130, 132, 134, 136,
- 138, 140, 143, 145, 148, 151, 154, 157
-};
-
-static const uint16_t kAcTable[128] = {
- 4, 5, 6, 7, 8, 9, 10, 11,
- 12, 13, 14, 15, 16, 17, 18, 19,
- 20, 21, 22, 23, 24, 25, 26, 27,
- 28, 29, 30, 31, 32, 33, 34, 35,
- 36, 37, 38, 39, 40, 41, 42, 43,
- 44, 45, 46, 47, 48, 49, 50, 51,
- 52, 53, 54, 55, 56, 57, 58, 60,
- 62, 64, 66, 68, 70, 72, 74, 76,
- 78, 80, 82, 84, 86, 88, 90, 92,
- 94, 96, 98, 100, 102, 104, 106, 108,
- 110, 112, 114, 116, 119, 122, 125, 128,
- 131, 134, 137, 140, 143, 146, 149, 152,
- 155, 158, 161, 164, 167, 170, 173, 177,
- 181, 185, 189, 193, 197, 201, 205, 209,
- 213, 217, 221, 225, 229, 234, 239, 245,
- 249, 254, 259, 264, 269, 274, 279, 284
-};
-
-static const uint16_t kAcTable2[128] = {
- 8, 8, 9, 10, 12, 13, 15, 17,
- 18, 20, 21, 23, 24, 26, 27, 29,
- 31, 32, 34, 35, 37, 38, 40, 41,
- 43, 44, 46, 48, 49, 51, 52, 54,
- 55, 57, 58, 60, 62, 63, 65, 66,
- 68, 69, 71, 72, 74, 75, 77, 79,
- 80, 82, 83, 85, 86, 88, 89, 93,
- 96, 99, 102, 105, 108, 111, 114, 117,
- 120, 124, 127, 130, 133, 136, 139, 142,
- 145, 148, 151, 155, 158, 161, 164, 167,
- 170, 173, 176, 179, 184, 189, 193, 198,
- 203, 207, 212, 217, 221, 226, 230, 235,
- 240, 244, 249, 254, 258, 263, 268, 274,
- 280, 286, 292, 299, 305, 311, 317, 323,
- 330, 336, 342, 348, 354, 362, 370, 379,
- 385, 393, 401, 409, 416, 424, 432, 440
-};
-
-static const uint8_t kBiasMatrices[3][2] = { // [luma-ac,luma-dc,chroma][dc,ac]
- { 96, 110 }, { 96, 108 }, { 110, 115 }
-};
-
-// Sharpening by (slightly) raising the hi-frequency coeffs.
-// Hack-ish but helpful for mid-bitrate range. Use with care.
-#define SHARPEN_BITS 11 // number of descaling bits for sharpening bias
-static const uint8_t kFreqSharpening[16] = {
- 0, 30, 60, 90,
- 30, 60, 90, 90,
- 60, 90, 90, 90,
- 90, 90, 90, 90
-};
-
-//------------------------------------------------------------------------------
-// Initialize quantization parameters in VP8Matrix
-
-// Returns the average quantizer
-static int ExpandMatrix(VP8Matrix* const m, int type) {
- int i, sum;
- for (i = 0; i < 2; ++i) {
- const int is_ac_coeff = (i > 0);
- const int bias = kBiasMatrices[type][is_ac_coeff];
- m->iq_[i] = (1 << QFIX) / m->q_[i];
- m->bias_[i] = BIAS(bias);
- // zthresh_ is the exact value such that QUANTDIV(coeff, iQ, B) is:
- // * zero if coeff <= zthresh
- // * non-zero if coeff > zthresh
- m->zthresh_[i] = ((1 << QFIX) - 1 - m->bias_[i]) / m->iq_[i];
- }
- for (i = 2; i < 16; ++i) {
- m->q_[i] = m->q_[1];
- m->iq_[i] = m->iq_[1];
- m->bias_[i] = m->bias_[1];
- m->zthresh_[i] = m->zthresh_[1];
- }
- for (sum = 0, i = 0; i < 16; ++i) {
- if (type == 0) { // we only use sharpening for AC luma coeffs
- m->sharpen_[i] = (kFreqSharpening[i] * m->q_[i]) >> SHARPEN_BITS;
- } else {
- m->sharpen_[i] = 0;
- }
- sum += m->q_[i];
- }
- return (sum + 8) >> 4;
-}
-
-static void CheckLambdaValue(int* const v) { if (*v < 1) *v = 1; }
-
-static void SetupMatrices(VP8Encoder* enc) {
- int i;
- const int tlambda_scale =
- (enc->method_ >= 4) ? enc->config_->sns_strength
- : 0;
- const int num_segments = enc->segment_hdr_.num_segments_;
- for (i = 0; i < num_segments; ++i) {
- VP8SegmentInfo* const m = &enc->dqm_[i];
- const int q = m->quant_;
- int q_i4, q_i16, q_uv;
- m->y1_.q_[0] = kDcTable[clip(q + enc->dq_y1_dc_, 0, 127)];
- m->y1_.q_[1] = kAcTable[clip(q, 0, 127)];
-
- m->y2_.q_[0] = kDcTable[ clip(q + enc->dq_y2_dc_, 0, 127)] * 2;
- m->y2_.q_[1] = kAcTable2[clip(q + enc->dq_y2_ac_, 0, 127)];
-
- m->uv_.q_[0] = kDcTable[clip(q + enc->dq_uv_dc_, 0, 117)];
- m->uv_.q_[1] = kAcTable[clip(q + enc->dq_uv_ac_, 0, 127)];
-
- q_i4 = ExpandMatrix(&m->y1_, 0);
- q_i16 = ExpandMatrix(&m->y2_, 1);
- q_uv = ExpandMatrix(&m->uv_, 2);
-
- m->lambda_i4_ = (3 * q_i4 * q_i4) >> 7;
- m->lambda_i16_ = (3 * q_i16 * q_i16);
- m->lambda_uv_ = (3 * q_uv * q_uv) >> 6;
- m->lambda_mode_ = (1 * q_i4 * q_i4) >> 7;
- m->lambda_trellis_i4_ = (7 * q_i4 * q_i4) >> 3;
- m->lambda_trellis_i16_ = (q_i16 * q_i16) >> 2;
- m->lambda_trellis_uv_ = (q_uv * q_uv) << 1;
- m->tlambda_ = (tlambda_scale * q_i4) >> 5;
-
- // none of these constants should be < 1
- CheckLambdaValue(&m->lambda_i4_);
- CheckLambdaValue(&m->lambda_i16_);
- CheckLambdaValue(&m->lambda_uv_);
- CheckLambdaValue(&m->lambda_mode_);
- CheckLambdaValue(&m->lambda_trellis_i4_);
- CheckLambdaValue(&m->lambda_trellis_i16_);
- CheckLambdaValue(&m->lambda_trellis_uv_);
- CheckLambdaValue(&m->tlambda_);
-
- m->min_disto_ = 20 * m->y1_.q_[0]; // quantization-aware min disto
- m->max_edge_ = 0;
-
- m->i4_penalty_ = 1000 * q_i4 * q_i4;
- }
-}
-
-//------------------------------------------------------------------------------
-// Initialize filtering parameters
-
-// Very small filter-strength values have close to no visual effect. So we can
-// save a little decoding-CPU by turning filtering off for these.
-#define FSTRENGTH_CUTOFF 2
-
-static void SetupFilterStrength(VP8Encoder* const enc) {
- int i;
- // level0 is in [0..500]. Using '-f 50' as filter_strength is mid-filtering.
- const int level0 = 5 * enc->config_->filter_strength;
- for (i = 0; i < NUM_MB_SEGMENTS; ++i) {
- VP8SegmentInfo* const m = &enc->dqm_[i];
- // We focus on the quantization of AC coeffs.
- const int qstep = kAcTable[clip(m->quant_, 0, 127)] >> 2;
- const int base_strength =
- VP8FilterStrengthFromDelta(enc->filter_hdr_.sharpness_, qstep);
- // Segments with lower complexity ('beta') will be less filtered.
- const int f = base_strength * level0 / (256 + m->beta_);
- m->fstrength_ = (f < FSTRENGTH_CUTOFF) ? 0 : (f > 63) ? 63 : f;
- }
- // We record the initial strength (mainly for the case of 1-segment only).
- enc->filter_hdr_.level_ = enc->dqm_[0].fstrength_;
- enc->filter_hdr_.simple_ = (enc->config_->filter_type == 0);
- enc->filter_hdr_.sharpness_ = enc->config_->filter_sharpness;
-}
-
-//------------------------------------------------------------------------------
-
-// Note: if you change the values below, remember that the max range
-// allowed by the syntax for DQ_UV is [-16,16].
-#define MAX_DQ_UV (6)
-#define MIN_DQ_UV (-4)
-
-// We want to emulate jpeg-like behaviour where the expected "good" quality
-// is around q=75. Internally, our "good" middle is around c=50. So we
-// map accordingly using linear piece-wise function
-static double QualityToCompression(double c) {
- const double linear_c = (c < 0.75) ? c * (2. / 3.) : 2. * c - 1.;
- // The file size roughly scales as pow(quantizer, 3.). Actually, the
- // exponent is somewhere between 2.8 and 3.2, but we're mostly interested
- // in the mid-quant range. So we scale the compressibility inversely to
- // this power-law: quant ~= compression ^ 1/3. This law holds well for
- // low quant. Finer modeling for high-quant would make use of kAcTable[]
- // more explicitly.
- const double v = pow(linear_c, 1 / 3.);
- return v;
-}
-
-static double QualityToJPEGCompression(double c, double alpha) {
- // We map the complexity 'alpha' and quality setting 'c' to a compression
- // exponent empirically matched to the compression curve of libjpeg6b.
- // On average, the WebP output size will be roughly similar to that of a
- // JPEG file compressed with same quality factor.
- const double amin = 0.30;
- const double amax = 0.85;
- const double exp_min = 0.4;
- const double exp_max = 0.9;
- const double slope = (exp_min - exp_max) / (amax - amin);
- // Linearly interpolate 'expn' from exp_min to exp_max
- // in the [amin, amax] range.
- const double expn = (alpha > amax) ? exp_min
- : (alpha < amin) ? exp_max
- : exp_max + slope * (alpha - amin);
- const double v = pow(c, expn);
- return v;
-}
-
-static int SegmentsAreEquivalent(const VP8SegmentInfo* const S1,
- const VP8SegmentInfo* const S2) {
- return (S1->quant_ == S2->quant_) && (S1->fstrength_ == S2->fstrength_);
-}
-
-static void SimplifySegments(VP8Encoder* const enc) {
- int map[NUM_MB_SEGMENTS] = { 0, 1, 2, 3 };
- // 'num_segments_' is previously validated and <= NUM_MB_SEGMENTS, but an
- // explicit check is needed to avoid a spurious warning about 'i' exceeding
- // array bounds of 'dqm_' with some compilers (noticed with gcc-4.9).
- const int num_segments = (enc->segment_hdr_.num_segments_ < NUM_MB_SEGMENTS)
- ? enc->segment_hdr_.num_segments_
- : NUM_MB_SEGMENTS;
- int num_final_segments = 1;
- int s1, s2;
- for (s1 = 1; s1 < num_segments; ++s1) { // find similar segments
- const VP8SegmentInfo* const S1 = &enc->dqm_[s1];
- int found = 0;
- // check if we already have similar segment
- for (s2 = 0; s2 < num_final_segments; ++s2) {
- const VP8SegmentInfo* const S2 = &enc->dqm_[s2];
- if (SegmentsAreEquivalent(S1, S2)) {
- found = 1;
- break;
- }
- }
- map[s1] = s2;
- if (!found) {
- if (num_final_segments != s1) {
- enc->dqm_[num_final_segments] = enc->dqm_[s1];
- }
- ++num_final_segments;
- }
- }
- if (num_final_segments < num_segments) { // Remap
- int i = enc->mb_w_ * enc->mb_h_;
- while (i-- > 0) enc->mb_info_[i].segment_ = map[enc->mb_info_[i].segment_];
- enc->segment_hdr_.num_segments_ = num_final_segments;
- // Replicate the trailing segment infos (it's mostly cosmetics)
- for (i = num_final_segments; i < num_segments; ++i) {
- enc->dqm_[i] = enc->dqm_[num_final_segments - 1];
- }
- }
-}
-
-void VP8SetSegmentParams(VP8Encoder* const enc, float quality) {
- int i;
- int dq_uv_ac, dq_uv_dc;
- const int num_segments = enc->segment_hdr_.num_segments_;
- const double amp = SNS_TO_DQ * enc->config_->sns_strength / 100. / 128.;
- const double Q = quality / 100.;
- const double c_base = enc->config_->emulate_jpeg_size ?
- QualityToJPEGCompression(Q, enc->alpha_ / 255.) :
- QualityToCompression(Q);
- for (i = 0; i < num_segments; ++i) {
- // We modulate the base coefficient to accommodate for the quantization
- // susceptibility and allow denser segments to be quantized more.
- const double expn = 1. - amp * enc->dqm_[i].alpha_;
- const double c = pow(c_base, expn);
- const int q = (int)(127. * (1. - c));
- assert(expn > 0.);
- enc->dqm_[i].quant_ = clip(q, 0, 127);
- }
-
- // purely indicative in the bitstream (except for the 1-segment case)
- enc->base_quant_ = enc->dqm_[0].quant_;
-
- // fill-in values for the unused segments (required by the syntax)
- for (i = num_segments; i < NUM_MB_SEGMENTS; ++i) {
- enc->dqm_[i].quant_ = enc->base_quant_;
- }
-
- // uv_alpha_ is normally spread around ~60. The useful range is
- // typically ~30 (quite bad) to ~100 (ok to decimate UV more).
- // We map it to the safe maximal range of MAX/MIN_DQ_UV for dq_uv.
- dq_uv_ac = (enc->uv_alpha_ - MID_ALPHA) * (MAX_DQ_UV - MIN_DQ_UV)
- / (MAX_ALPHA - MIN_ALPHA);
- // we rescale by the user-defined strength of adaptation
- dq_uv_ac = dq_uv_ac * enc->config_->sns_strength / 100;
- // and make it safe.
- dq_uv_ac = clip(dq_uv_ac, MIN_DQ_UV, MAX_DQ_UV);
- // We also boost the dc-uv-quant a little, based on sns-strength, since
- // U/V channels are quite more reactive to high quants (flat DC-blocks
- // tend to appear, and are unpleasant).
- dq_uv_dc = -4 * enc->config_->sns_strength / 100;
- dq_uv_dc = clip(dq_uv_dc, -15, 15); // 4bit-signed max allowed
-
- enc->dq_y1_dc_ = 0; // TODO(skal): dq-lum
- enc->dq_y2_dc_ = 0;
- enc->dq_y2_ac_ = 0;
- enc->dq_uv_dc_ = dq_uv_dc;
- enc->dq_uv_ac_ = dq_uv_ac;
-
- SetupFilterStrength(enc); // initialize segments' filtering, eventually
-
- if (num_segments > 1) SimplifySegments(enc);
-
- SetupMatrices(enc); // finalize quantization matrices
-}
-
-//------------------------------------------------------------------------------
-// Form the predictions in cache
-
-// Must be ordered using {DC_PRED, TM_PRED, V_PRED, H_PRED} as index
-const uint16_t VP8I16ModeOffsets[4] = { I16DC16, I16TM16, I16VE16, I16HE16 };
-const uint16_t VP8UVModeOffsets[4] = { C8DC8, C8TM8, C8VE8, C8HE8 };
-
-// Must be indexed using {B_DC_PRED -> B_HU_PRED} as index
-const uint16_t VP8I4ModeOffsets[NUM_BMODES] = {
- I4DC4, I4TM4, I4VE4, I4HE4, I4RD4, I4VR4, I4LD4, I4VL4, I4HD4, I4HU4
-};
-
-void VP8MakeLuma16Preds(const VP8EncIterator* const it) {
- const uint8_t* const left = it->x_ ? it->y_left_ : NULL;
- const uint8_t* const top = it->y_ ? it->y_top_ : NULL;
- VP8EncPredLuma16(it->yuv_p_, left, top);
-}
-
-void VP8MakeChroma8Preds(const VP8EncIterator* const it) {
- const uint8_t* const left = it->x_ ? it->u_left_ : NULL;
- const uint8_t* const top = it->y_ ? it->uv_top_ : NULL;
- VP8EncPredChroma8(it->yuv_p_, left, top);
-}
-
-void VP8MakeIntra4Preds(const VP8EncIterator* const it) {
- VP8EncPredLuma4(it->yuv_p_, it->i4_top_);
-}
-
-//------------------------------------------------------------------------------
-// Quantize
-
-// Layout:
-// +----+----+
-// |YYYY|UUVV| 0
-// |YYYY|UUVV| 4
-// |YYYY|....| 8
-// |YYYY|....| 12
-// +----+----+
-
-const uint16_t VP8Scan[16] = { // Luma
- 0 + 0 * BPS, 4 + 0 * BPS, 8 + 0 * BPS, 12 + 0 * BPS,
- 0 + 4 * BPS, 4 + 4 * BPS, 8 + 4 * BPS, 12 + 4 * BPS,
- 0 + 8 * BPS, 4 + 8 * BPS, 8 + 8 * BPS, 12 + 8 * BPS,
- 0 + 12 * BPS, 4 + 12 * BPS, 8 + 12 * BPS, 12 + 12 * BPS,
-};
-
-static const uint16_t VP8ScanUV[4 + 4] = {
- 0 + 0 * BPS, 4 + 0 * BPS, 0 + 4 * BPS, 4 + 4 * BPS, // U
- 8 + 0 * BPS, 12 + 0 * BPS, 8 + 4 * BPS, 12 + 4 * BPS // V
-};
-
-//------------------------------------------------------------------------------
-// Distortion measurement
-
-static const uint16_t kWeightY[16] = {
- 38, 32, 20, 9, 32, 28, 17, 7, 20, 17, 10, 4, 9, 7, 4, 2
-};
-
-static const uint16_t kWeightTrellis[16] = {
-#if USE_TDISTO == 0
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16
-#else
- 30, 27, 19, 11,
- 27, 24, 17, 10,
- 19, 17, 12, 8,
- 11, 10, 8, 6
-#endif
-};
-
-// Init/Copy the common fields in score.
-static void InitScore(VP8ModeScore* const rd) {
- rd->D = 0;
- rd->SD = 0;
- rd->R = 0;
- rd->H = 0;
- rd->nz = 0;
- rd->score = MAX_COST;
-}
-
-static void CopyScore(VP8ModeScore* const dst, const VP8ModeScore* const src) {
- dst->D = src->D;
- dst->SD = src->SD;
- dst->R = src->R;
- dst->H = src->H;
- dst->nz = src->nz; // note that nz is not accumulated, but just copied.
- dst->score = src->score;
-}
-
-static void AddScore(VP8ModeScore* const dst, const VP8ModeScore* const src) {
- dst->D += src->D;
- dst->SD += src->SD;
- dst->R += src->R;
- dst->H += src->H;
- dst->nz |= src->nz; // here, new nz bits are accumulated.
- dst->score += src->score;
-}
-
-//------------------------------------------------------------------------------
-// Performs trellis-optimized quantization.
-
-// Trellis node
-typedef struct {
- int8_t prev; // best previous node
- int8_t sign; // sign of coeff_i
- int16_t level; // level
-} Node;
-
-// Score state
-typedef struct {
- score_t score; // partial RD score
- const uint16_t* costs; // shortcut to cost tables
-} ScoreState;
-
-// If a coefficient was quantized to a value Q (using a neutral bias),
-// we test all alternate possibilities between [Q-MIN_DELTA, Q+MAX_DELTA]
-// We don't test negative values though.
-#define MIN_DELTA 0 // how much lower level to try
-#define MAX_DELTA 1 // how much higher
-#define NUM_NODES (MIN_DELTA + 1 + MAX_DELTA)
-#define NODE(n, l) (nodes[(n)][(l) + MIN_DELTA])
-#define SCORE_STATE(n, l) (score_states[n][(l) + MIN_DELTA])
-
-static WEBP_INLINE void SetRDScore(int lambda, VP8ModeScore* const rd) {
- rd->score = (rd->R + rd->H) * lambda + RD_DISTO_MULT * (rd->D + rd->SD);
-}
-
-static WEBP_INLINE score_t RDScoreTrellis(int lambda, score_t rate,
- score_t distortion) {
- return rate * lambda + RD_DISTO_MULT * distortion;
-}
-
-// Coefficient type.
-enum { TYPE_I16_AC = 0, TYPE_I16_DC = 1, TYPE_CHROMA_A = 2, TYPE_I4_AC = 3 };
-
-static int TrellisQuantizeBlock(const VP8Encoder* const enc,
- int16_t in[16], int16_t out[16],
- int ctx0, int coeff_type,
- const VP8Matrix* const mtx,
- int lambda) {
- const ProbaArray* const probas = enc->proba_.coeffs_[coeff_type];
- CostArrayPtr const costs =
- (CostArrayPtr)enc->proba_.remapped_costs_[coeff_type];
- const int first = (coeff_type == TYPE_I16_AC) ? 1 : 0;
- Node nodes[16][NUM_NODES];
- ScoreState score_states[2][NUM_NODES];
- ScoreState* ss_cur = &SCORE_STATE(0, MIN_DELTA);
- ScoreState* ss_prev = &SCORE_STATE(1, MIN_DELTA);
- int best_path[3] = {-1, -1, -1}; // store best-last/best-level/best-previous
- score_t best_score;
- int n, m, p, last;
-
- {
- score_t cost;
- const int thresh = mtx->q_[1] * mtx->q_[1] / 4;
- const int last_proba = probas[VP8EncBands[first]][ctx0][0];
-
- // compute the position of the last interesting coefficient
- last = first - 1;
- for (n = 15; n >= first; --n) {
- const int j = kZigzag[n];
- const int err = in[j] * in[j];
- if (err > thresh) {
- last = n;
- break;
- }
- }
- // we don't need to go inspect up to n = 16 coeffs. We can just go up
- // to last + 1 (inclusive) without losing much.
- if (last < 15) ++last;
-
- // compute 'skip' score. This is the max score one can do.
- cost = VP8BitCost(0, last_proba);
- best_score = RDScoreTrellis(lambda, cost, 0);
-
- // initialize source node.
- for (m = -MIN_DELTA; m <= MAX_DELTA; ++m) {
- const score_t rate = (ctx0 == 0) ? VP8BitCost(1, last_proba) : 0;
- ss_cur[m].score = RDScoreTrellis(lambda, rate, 0);
- ss_cur[m].costs = costs[first][ctx0];
- }
- }
-
- // traverse trellis.
- for (n = first; n <= last; ++n) {
- const int j = kZigzag[n];
- const uint32_t Q = mtx->q_[j];
- const uint32_t iQ = mtx->iq_[j];
- const uint32_t B = BIAS(0x00); // neutral bias
- // note: it's important to take sign of the _original_ coeff,
- // so we don't have to consider level < 0 afterward.
- const int sign = (in[j] < 0);
- const uint32_t coeff0 = (sign ? -in[j] : in[j]) + mtx->sharpen_[j];
- int level0 = QUANTDIV(coeff0, iQ, B);
- int thresh_level = QUANTDIV(coeff0, iQ, BIAS(0x80));
- if (thresh_level > MAX_LEVEL) thresh_level = MAX_LEVEL;
- if (level0 > MAX_LEVEL) level0 = MAX_LEVEL;
-
- { // Swap current and previous score states
- ScoreState* const tmp = ss_cur;
- ss_cur = ss_prev;
- ss_prev = tmp;
- }
-
- // test all alternate level values around level0.
- for (m = -MIN_DELTA; m <= MAX_DELTA; ++m) {
- Node* const cur = &NODE(n, m);
- const int level = level0 + m;
- const int ctx = (level > 2) ? 2 : level;
- const int band = VP8EncBands[n + 1];
- score_t base_score;
- score_t best_cur_score;
- int best_prev;
- score_t cost, score;
-
- ss_cur[m].costs = costs[n + 1][ctx];
- if (level < 0 || level > thresh_level) {
- ss_cur[m].score = MAX_COST;
- // Node is dead.
- continue;
- }
-
- {
- // Compute delta_error = how much coding this level will
- // subtract to max_error as distortion.
- // Here, distortion = sum of (|coeff_i| - level_i * Q_i)^2
- const int new_error = coeff0 - level * Q;
- const int delta_error =
- kWeightTrellis[j] * (new_error * new_error - coeff0 * coeff0);
- base_score = RDScoreTrellis(lambda, 0, delta_error);
- }
-
- // Inspect all possible non-dead predecessors. Retain only the best one.
- // The base_score is added to all scores so it is only added for the final
- // value after the loop.
- cost = VP8LevelCost(ss_prev[-MIN_DELTA].costs, level);
- best_cur_score =
- ss_prev[-MIN_DELTA].score + RDScoreTrellis(lambda, cost, 0);
- best_prev = -MIN_DELTA;
- for (p = -MIN_DELTA + 1; p <= MAX_DELTA; ++p) {
- // Dead nodes (with ss_prev[p].score >= MAX_COST) are automatically
- // eliminated since their score can't be better than the current best.
- cost = VP8LevelCost(ss_prev[p].costs, level);
- // Examine node assuming it's a non-terminal one.
- score = ss_prev[p].score + RDScoreTrellis(lambda, cost, 0);
- if (score < best_cur_score) {
- best_cur_score = score;
- best_prev = p;
- }
- }
- best_cur_score += base_score;
- // Store best finding in current node.
- cur->sign = sign;
- cur->level = level;
- cur->prev = best_prev;
- ss_cur[m].score = best_cur_score;
-
- // Now, record best terminal node (and thus best entry in the graph).
- if (level != 0 && best_cur_score < best_score) {
- const score_t last_pos_cost =
- (n < 15) ? VP8BitCost(0, probas[band][ctx][0]) : 0;
- const score_t last_pos_score = RDScoreTrellis(lambda, last_pos_cost, 0);
- score = best_cur_score + last_pos_score;
- if (score < best_score) {
- best_score = score;
- best_path[0] = n; // best eob position
- best_path[1] = m; // best node index
- best_path[2] = best_prev; // best predecessor
- }
- }
- }
- }
-
- // Fresh start
- // Beware! We must preserve in[0]/out[0] value for TYPE_I16_AC case.
- if (coeff_type == TYPE_I16_AC) {
- memset(in + 1, 0, 15 * sizeof(*in));
- memset(out + 1, 0, 15 * sizeof(*out));
- } else {
- memset(in, 0, 16 * sizeof(*in));
- memset(out, 0, 16 * sizeof(*out));
- }
- if (best_path[0] == -1) {
- return 0; // skip!
- }
-
- {
- // Unwind the best path.
- // Note: best-prev on terminal node is not necessarily equal to the
- // best_prev for non-terminal. So we patch best_path[2] in.
- int nz = 0;
- int best_node = best_path[1];
- n = best_path[0];
- NODE(n, best_node).prev = best_path[2]; // force best-prev for terminal
-
- for (; n >= first; --n) {
- const Node* const node = &NODE(n, best_node);
- const int j = kZigzag[n];
- out[n] = node->sign ? -node->level : node->level;
- nz |= node->level;
- in[j] = out[n] * mtx->q_[j];
- best_node = node->prev;
- }
- return (nz != 0);
- }
-}
-
-#undef NODE
-
-//------------------------------------------------------------------------------
-// Performs: difference, transform, quantize, back-transform, add
-// all at once. Output is the reconstructed block in *yuv_out, and the
-// quantized levels in *levels.
-
-static int ReconstructIntra16(VP8EncIterator* const it,
- VP8ModeScore* const rd,
- uint8_t* const yuv_out,
- int mode) {
- const VP8Encoder* const enc = it->enc_;
- const uint8_t* const ref = it->yuv_p_ + VP8I16ModeOffsets[mode];
- const uint8_t* const src = it->yuv_in_ + Y_OFF_ENC;
- const VP8SegmentInfo* const dqm = &enc->dqm_[it->mb_->segment_];
- int nz = 0;
- int n;
- int16_t tmp[16][16], dc_tmp[16];
-
- for (n = 0; n < 16; n += 2) {
- VP8FTransform2(src + VP8Scan[n], ref + VP8Scan[n], tmp[n]);
- }
- VP8FTransformWHT(tmp[0], dc_tmp);
- nz |= VP8EncQuantizeBlockWHT(dc_tmp, rd->y_dc_levels, &dqm->y2_) << 24;
-
- if (DO_TRELLIS_I16 && it->do_trellis_) {
- int x, y;
- VP8IteratorNzToBytes(it);
- for (y = 0, n = 0; y < 4; ++y) {
- for (x = 0; x < 4; ++x, ++n) {
- const int ctx = it->top_nz_[x] + it->left_nz_[y];
- const int non_zero = TrellisQuantizeBlock(
- enc, tmp[n], rd->y_ac_levels[n], ctx, TYPE_I16_AC, &dqm->y1_,
- dqm->lambda_trellis_i16_);
- it->top_nz_[x] = it->left_nz_[y] = non_zero;
- rd->y_ac_levels[n][0] = 0;
- nz |= non_zero << n;
- }
- }
- } else {
- for (n = 0; n < 16; n += 2) {
- // Zero-out the first coeff, so that: a) nz is correct below, and
- // b) finding 'last' non-zero coeffs in SetResidualCoeffs() is simplified.
- tmp[n][0] = tmp[n + 1][0] = 0;
- nz |= VP8EncQuantize2Blocks(tmp[n], rd->y_ac_levels[n], &dqm->y1_) << n;
- assert(rd->y_ac_levels[n + 0][0] == 0);
- assert(rd->y_ac_levels[n + 1][0] == 0);
- }
- }
-
- // Transform back
- VP8TransformWHT(dc_tmp, tmp[0]);
- for (n = 0; n < 16; n += 2) {
- VP8ITransform(ref + VP8Scan[n], tmp[n], yuv_out + VP8Scan[n], 1);
- }
-
- return nz;
-}
-
-static int ReconstructIntra4(VP8EncIterator* const it,
- int16_t levels[16],
- const uint8_t* const src,
- uint8_t* const yuv_out,
- int mode) {
- const VP8Encoder* const enc = it->enc_;
- const uint8_t* const ref = it->yuv_p_ + VP8I4ModeOffsets[mode];
- const VP8SegmentInfo* const dqm = &enc->dqm_[it->mb_->segment_];
- int nz = 0;
- int16_t tmp[16];
-
- VP8FTransform(src, ref, tmp);
- if (DO_TRELLIS_I4 && it->do_trellis_) {
- const int x = it->i4_ & 3, y = it->i4_ >> 2;
- const int ctx = it->top_nz_[x] + it->left_nz_[y];
- nz = TrellisQuantizeBlock(enc, tmp, levels, ctx, TYPE_I4_AC, &dqm->y1_,
- dqm->lambda_trellis_i4_);
- } else {
- nz = VP8EncQuantizeBlock(tmp, levels, &dqm->y1_);
- }
- VP8ITransform(ref, tmp, yuv_out, 0);
- return nz;
-}
-
-//------------------------------------------------------------------------------
-// DC-error diffusion
-
-// Diffusion weights. We under-correct a bit (15/16th of the error is actually
-// diffused) to avoid 'rainbow' chessboard pattern of blocks at q~=0.
-#define C1 7 // fraction of error sent to the 4x4 block below
-#define C2 8 // fraction of error sent to the 4x4 block on the right
-#define DSHIFT 4
-#define DSCALE 1 // storage descaling, needed to make the error fit int8_t
-
-// Quantize as usual, but also compute and return the quantization error.
-// Error is already divided by DSHIFT.
-static int QuantizeSingle(int16_t* const v, const VP8Matrix* const mtx) {
- int V = *v;
- const int sign = (V < 0);
- if (sign) V = -V;
- if (V > (int)mtx->zthresh_[0]) {
- const int qV = QUANTDIV(V, mtx->iq_[0], mtx->bias_[0]) * mtx->q_[0];
- const int err = (V - qV);
- *v = sign ? -qV : qV;
- return (sign ? -err : err) >> DSCALE;
- }
- *v = 0;
- return (sign ? -V : V) >> DSCALE;
-}
-
-static void CorrectDCValues(const VP8EncIterator* const it,
- const VP8Matrix* const mtx,
- int16_t tmp[][16], VP8ModeScore* const rd) {
- // | top[0] | top[1]
- // --------+--------+---------
- // left[0] | tmp[0] tmp[1] <-> err0 err1
- // left[1] | tmp[2] tmp[3] err2 err3
- //
- // Final errors {err1,err2,err3} are preserved and later restored
- // as top[]/left[] on the next block.
- int ch;
- for (ch = 0; ch <= 1; ++ch) {
- const int8_t* const top = it->top_derr_[it->x_][ch];
- const int8_t* const left = it->left_derr_[ch];
- int16_t (* const c)[16] = &tmp[ch * 4];
- int err0, err1, err2, err3;
- c[0][0] += (C1 * top[0] + C2 * left[0]) >> (DSHIFT - DSCALE);
- err0 = QuantizeSingle(&c[0][0], mtx);
- c[1][0] += (C1 * top[1] + C2 * err0) >> (DSHIFT - DSCALE);
- err1 = QuantizeSingle(&c[1][0], mtx);
- c[2][0] += (C1 * err0 + C2 * left[1]) >> (DSHIFT - DSCALE);
- err2 = QuantizeSingle(&c[2][0], mtx);
- c[3][0] += (C1 * err1 + C2 * err2) >> (DSHIFT - DSCALE);
- err3 = QuantizeSingle(&c[3][0], mtx);
- // error 'err' is bounded by mtx->q_[0] which is 132 at max. Hence
- // err >> DSCALE will fit in an int8_t type if DSCALE>=1.
- assert(abs(err1) <= 127 && abs(err2) <= 127 && abs(err3) <= 127);
- rd->derr[ch][0] = (int8_t)err1;
- rd->derr[ch][1] = (int8_t)err2;
- rd->derr[ch][2] = (int8_t)err3;
- }
-}
-
-static void StoreDiffusionErrors(VP8EncIterator* const it,
- const VP8ModeScore* const rd) {
- int ch;
- for (ch = 0; ch <= 1; ++ch) {
- int8_t* const top = it->top_derr_[it->x_][ch];
- int8_t* const left = it->left_derr_[ch];
- left[0] = rd->derr[ch][0]; // restore err1
- left[1] = 3 * rd->derr[ch][2] >> 2; // ... 3/4th of err3
- top[0] = rd->derr[ch][1]; // ... err2
- top[1] = rd->derr[ch][2] - left[1]; // ... 1/4th of err3.
- }
-}
-
-#undef C1
-#undef C2
-#undef DSHIFT
-#undef DSCALE
-
-//------------------------------------------------------------------------------
-
-static int ReconstructUV(VP8EncIterator* const it, VP8ModeScore* const rd,
- uint8_t* const yuv_out, int mode) {
- const VP8Encoder* const enc = it->enc_;
- const uint8_t* const ref = it->yuv_p_ + VP8UVModeOffsets[mode];
- const uint8_t* const src = it->yuv_in_ + U_OFF_ENC;
- const VP8SegmentInfo* const dqm = &enc->dqm_[it->mb_->segment_];
- int nz = 0;
- int n;
- int16_t tmp[8][16];
-
- for (n = 0; n < 8; n += 2) {
- VP8FTransform2(src + VP8ScanUV[n], ref + VP8ScanUV[n], tmp[n]);
- }
- if (it->top_derr_ != NULL) CorrectDCValues(it, &dqm->uv_, tmp, rd);
-
- if (DO_TRELLIS_UV && it->do_trellis_) {
- int ch, x, y;
- for (ch = 0, n = 0; ch <= 2; ch += 2) {
- for (y = 0; y < 2; ++y) {
- for (x = 0; x < 2; ++x, ++n) {
- const int ctx = it->top_nz_[4 + ch + x] + it->left_nz_[4 + ch + y];
- const int non_zero = TrellisQuantizeBlock(
- enc, tmp[n], rd->uv_levels[n], ctx, TYPE_CHROMA_A, &dqm->uv_,
- dqm->lambda_trellis_uv_);
- it->top_nz_[4 + ch + x] = it->left_nz_[4 + ch + y] = non_zero;
- nz |= non_zero << n;
- }
- }
- }
- } else {
- for (n = 0; n < 8; n += 2) {
- nz |= VP8EncQuantize2Blocks(tmp[n], rd->uv_levels[n], &dqm->uv_) << n;
- }
- }
-
- for (n = 0; n < 8; n += 2) {
- VP8ITransform(ref + VP8ScanUV[n], tmp[n], yuv_out + VP8ScanUV[n], 1);
- }
- return (nz << 16);
-}
-
-//------------------------------------------------------------------------------
-// RD-opt decision. Reconstruct each modes, evalue distortion and bit-cost.
-// Pick the mode is lower RD-cost = Rate + lambda * Distortion.
-
-static void StoreMaxDelta(VP8SegmentInfo* const dqm, const int16_t DCs[16]) {
- // We look at the first three AC coefficients to determine what is the average
- // delta between each sub-4x4 block.
- const int v0 = abs(DCs[1]);
- const int v1 = abs(DCs[2]);
- const int v2 = abs(DCs[4]);
- int max_v = (v1 > v0) ? v1 : v0;
- max_v = (v2 > max_v) ? v2 : max_v;
- if (max_v > dqm->max_edge_) dqm->max_edge_ = max_v;
-}
-
-static void SwapModeScore(VP8ModeScore** a, VP8ModeScore** b) {
- VP8ModeScore* const tmp = *a;
- *a = *b;
- *b = tmp;
-}
-
-static void SwapPtr(uint8_t** a, uint8_t** b) {
- uint8_t* const tmp = *a;
- *a = *b;
- *b = tmp;
-}
-
-static void SwapOut(VP8EncIterator* const it) {
- SwapPtr(&it->yuv_out_, &it->yuv_out2_);
-}
-
-static void PickBestIntra16(VP8EncIterator* const it, VP8ModeScore* rd) {
- const int kNumBlocks = 16;
- VP8SegmentInfo* const dqm = &it->enc_->dqm_[it->mb_->segment_];
- const int lambda = dqm->lambda_i16_;
- const int tlambda = dqm->tlambda_;
- const uint8_t* const src = it->yuv_in_ + Y_OFF_ENC;
- VP8ModeScore rd_tmp;
- VP8ModeScore* rd_cur = &rd_tmp;
- VP8ModeScore* rd_best = rd;
- int mode;
- int is_flat = IsFlatSource16(it->yuv_in_ + Y_OFF_ENC);
-
- rd->mode_i16 = -1;
- for (mode = 0; mode < NUM_PRED_MODES; ++mode) {
- uint8_t* const tmp_dst = it->yuv_out2_ + Y_OFF_ENC; // scratch buffer
- rd_cur->mode_i16 = mode;
-
- // Reconstruct
- rd_cur->nz = ReconstructIntra16(it, rd_cur, tmp_dst, mode);
-
- // Measure RD-score
- rd_cur->D = VP8SSE16x16(src, tmp_dst);
- rd_cur->SD =
- tlambda ? MULT_8B(tlambda, VP8TDisto16x16(src, tmp_dst, kWeightY)) : 0;
- rd_cur->H = VP8FixedCostsI16[mode];
- rd_cur->R = VP8GetCostLuma16(it, rd_cur);
- if (is_flat) {
- // refine the first impression (which was in pixel space)
- is_flat = IsFlat(rd_cur->y_ac_levels[0], kNumBlocks, FLATNESS_LIMIT_I16);
- if (is_flat) {
- // Block is very flat. We put emphasis on the distortion being very low!
- rd_cur->D *= 2;
- rd_cur->SD *= 2;
- }
- }
-
- // Since we always examine Intra16 first, we can overwrite *rd directly.
- SetRDScore(lambda, rd_cur);
- if (mode == 0 || rd_cur->score < rd_best->score) {
- SwapModeScore(&rd_cur, &rd_best);
- SwapOut(it);
- }
- }
- if (rd_best != rd) {
- memcpy(rd, rd_best, sizeof(*rd));
- }
- SetRDScore(dqm->lambda_mode_, rd); // finalize score for mode decision.
- VP8SetIntra16Mode(it, rd->mode_i16);
-
- // we have a blocky macroblock (only DCs are non-zero) with fairly high
- // distortion, record max delta so we can later adjust the minimal filtering
- // strength needed to smooth these blocks out.
- if ((rd->nz & 0x100ffff) == 0x1000000 && rd->D > dqm->min_disto_) {
- StoreMaxDelta(dqm, rd->y_dc_levels);
- }
-}
-
-//------------------------------------------------------------------------------
-
-// return the cost array corresponding to the surrounding prediction modes.
-static const uint16_t* GetCostModeI4(VP8EncIterator* const it,
- const uint8_t modes[16]) {
- const int preds_w = it->enc_->preds_w_;
- const int x = (it->i4_ & 3), y = it->i4_ >> 2;
- const int left = (x == 0) ? it->preds_[y * preds_w - 1] : modes[it->i4_ - 1];
- const int top = (y == 0) ? it->preds_[-preds_w + x] : modes[it->i4_ - 4];
- return VP8FixedCostsI4[top][left];
-}
-
-static int PickBestIntra4(VP8EncIterator* const it, VP8ModeScore* const rd) {
- const VP8Encoder* const enc = it->enc_;
- const VP8SegmentInfo* const dqm = &enc->dqm_[it->mb_->segment_];
- const int lambda = dqm->lambda_i4_;
- const int tlambda = dqm->tlambda_;
- const uint8_t* const src0 = it->yuv_in_ + Y_OFF_ENC;
- uint8_t* const best_blocks = it->yuv_out2_ + Y_OFF_ENC;
- int total_header_bits = 0;
- VP8ModeScore rd_best;
-
- if (enc->max_i4_header_bits_ == 0) {
- return 0;
- }
-
- InitScore(&rd_best);
- rd_best.H = 211; // '211' is the value of VP8BitCost(0, 145)
- SetRDScore(dqm->lambda_mode_, &rd_best);
- VP8IteratorStartI4(it);
- do {
- const int kNumBlocks = 1;
- VP8ModeScore rd_i4;
- int mode;
- int best_mode = -1;
- const uint8_t* const src = src0 + VP8Scan[it->i4_];
- const uint16_t* const mode_costs = GetCostModeI4(it, rd->modes_i4);
- uint8_t* best_block = best_blocks + VP8Scan[it->i4_];
- uint8_t* tmp_dst = it->yuv_p_ + I4TMP; // scratch buffer.
-
- InitScore(&rd_i4);
- VP8MakeIntra4Preds(it);
- for (mode = 0; mode < NUM_BMODES; ++mode) {
- VP8ModeScore rd_tmp;
- int16_t tmp_levels[16];
-
- // Reconstruct
- rd_tmp.nz =
- ReconstructIntra4(it, tmp_levels, src, tmp_dst, mode) << it->i4_;
-
- // Compute RD-score
- rd_tmp.D = VP8SSE4x4(src, tmp_dst);
- rd_tmp.SD =
- tlambda ? MULT_8B(tlambda, VP8TDisto4x4(src, tmp_dst, kWeightY))
- : 0;
- rd_tmp.H = mode_costs[mode];
-
- // Add flatness penalty, to avoid flat area to be mispredicted
- // by a complex mode.
- if (mode > 0 && IsFlat(tmp_levels, kNumBlocks, FLATNESS_LIMIT_I4)) {
- rd_tmp.R = FLATNESS_PENALTY * kNumBlocks;
- } else {
- rd_tmp.R = 0;
- }
-
- // early-out check
- SetRDScore(lambda, &rd_tmp);
- if (best_mode >= 0 && rd_tmp.score >= rd_i4.score) continue;
-
- // finish computing score
- rd_tmp.R += VP8GetCostLuma4(it, tmp_levels);
- SetRDScore(lambda, &rd_tmp);
-
- if (best_mode < 0 || rd_tmp.score < rd_i4.score) {
- CopyScore(&rd_i4, &rd_tmp);
- best_mode = mode;
- SwapPtr(&tmp_dst, &best_block);
- memcpy(rd_best.y_ac_levels[it->i4_], tmp_levels,
- sizeof(rd_best.y_ac_levels[it->i4_]));
- }
- }
- SetRDScore(dqm->lambda_mode_, &rd_i4);
- AddScore(&rd_best, &rd_i4);
- if (rd_best.score >= rd->score) {
- return 0;
- }
- total_header_bits += (int)rd_i4.H; // <- equal to mode_costs[best_mode];
- if (total_header_bits > enc->max_i4_header_bits_) {
- return 0;
- }
- // Copy selected samples if not in the right place already.
- if (best_block != best_blocks + VP8Scan[it->i4_]) {
- VP8Copy4x4(best_block, best_blocks + VP8Scan[it->i4_]);
- }
- rd->modes_i4[it->i4_] = best_mode;
- it->top_nz_[it->i4_ & 3] = it->left_nz_[it->i4_ >> 2] = (rd_i4.nz ? 1 : 0);
- } while (VP8IteratorRotateI4(it, best_blocks));
-
- // finalize state
- CopyScore(rd, &rd_best);
- VP8SetIntra4Mode(it, rd->modes_i4);
- SwapOut(it);
- memcpy(rd->y_ac_levels, rd_best.y_ac_levels, sizeof(rd->y_ac_levels));
- return 1; // select intra4x4 over intra16x16
-}
-
-//------------------------------------------------------------------------------
-
-static void PickBestUV(VP8EncIterator* const it, VP8ModeScore* const rd) {
- const int kNumBlocks = 8;
- const VP8SegmentInfo* const dqm = &it->enc_->dqm_[it->mb_->segment_];
- const int lambda = dqm->lambda_uv_;
- const uint8_t* const src = it->yuv_in_ + U_OFF_ENC;
- uint8_t* tmp_dst = it->yuv_out2_ + U_OFF_ENC; // scratch buffer
- uint8_t* dst0 = it->yuv_out_ + U_OFF_ENC;
- uint8_t* dst = dst0;
- VP8ModeScore rd_best;
- int mode;
-
- rd->mode_uv = -1;
- InitScore(&rd_best);
- for (mode = 0; mode < NUM_PRED_MODES; ++mode) {
- VP8ModeScore rd_uv;
-
- // Reconstruct
- rd_uv.nz = ReconstructUV(it, &rd_uv, tmp_dst, mode);
-
- // Compute RD-score
- rd_uv.D = VP8SSE16x8(src, tmp_dst);
- rd_uv.SD = 0; // not calling TDisto here: it tends to flatten areas.
- rd_uv.H = VP8FixedCostsUV[mode];
- rd_uv.R = VP8GetCostUV(it, &rd_uv);
- if (mode > 0 && IsFlat(rd_uv.uv_levels[0], kNumBlocks, FLATNESS_LIMIT_UV)) {
- rd_uv.R += FLATNESS_PENALTY * kNumBlocks;
- }
-
- SetRDScore(lambda, &rd_uv);
- if (mode == 0 || rd_uv.score < rd_best.score) {
- CopyScore(&rd_best, &rd_uv);
- rd->mode_uv = mode;
- memcpy(rd->uv_levels, rd_uv.uv_levels, sizeof(rd->uv_levels));
- if (it->top_derr_ != NULL) {
- memcpy(rd->derr, rd_uv.derr, sizeof(rd_uv.derr));
- }
- SwapPtr(&dst, &tmp_dst);
- }
- }
- VP8SetIntraUVMode(it, rd->mode_uv);
- AddScore(rd, &rd_best);
- if (dst != dst0) { // copy 16x8 block if needed
- VP8Copy16x8(dst, dst0);
- }
- if (it->top_derr_ != NULL) { // store diffusion errors for next block
- StoreDiffusionErrors(it, rd);
- }
-}
-
-//------------------------------------------------------------------------------
-// Final reconstruction and quantization.
-
-static void SimpleQuantize(VP8EncIterator* const it, VP8ModeScore* const rd) {
- const VP8Encoder* const enc = it->enc_;
- const int is_i16 = (it->mb_->type_ == 1);
- int nz = 0;
-
- if (is_i16) {
- nz = ReconstructIntra16(it, rd, it->yuv_out_ + Y_OFF_ENC, it->preds_[0]);
- } else {
- VP8IteratorStartI4(it);
- do {
- const int mode =
- it->preds_[(it->i4_ & 3) + (it->i4_ >> 2) * enc->preds_w_];
- const uint8_t* const src = it->yuv_in_ + Y_OFF_ENC + VP8Scan[it->i4_];
- uint8_t* const dst = it->yuv_out_ + Y_OFF_ENC + VP8Scan[it->i4_];
- VP8MakeIntra4Preds(it);
- nz |= ReconstructIntra4(it, rd->y_ac_levels[it->i4_],
- src, dst, mode) << it->i4_;
- } while (VP8IteratorRotateI4(it, it->yuv_out_ + Y_OFF_ENC));
- }
-
- nz |= ReconstructUV(it, rd, it->yuv_out_ + U_OFF_ENC, it->mb_->uv_mode_);
- rd->nz = nz;
-}
-
-// Refine intra16/intra4 sub-modes based on distortion only (not rate).
-static void RefineUsingDistortion(VP8EncIterator* const it,
- int try_both_modes, int refine_uv_mode,
- VP8ModeScore* const rd) {
- score_t best_score = MAX_COST;
- int nz = 0;
- int mode;
- int is_i16 = try_both_modes || (it->mb_->type_ == 1);
-
- const VP8SegmentInfo* const dqm = &it->enc_->dqm_[it->mb_->segment_];
- // Some empiric constants, of approximate order of magnitude.
- const int lambda_d_i16 = 106;
- const int lambda_d_i4 = 11;
- const int lambda_d_uv = 120;
- score_t score_i4 = dqm->i4_penalty_;
- score_t i4_bit_sum = 0;
- const score_t bit_limit = try_both_modes ? it->enc_->mb_header_limit_
- : MAX_COST; // no early-out allowed
-
- if (is_i16) { // First, evaluate Intra16 distortion
- int best_mode = -1;
- const uint8_t* const src = it->yuv_in_ + Y_OFF_ENC;
- for (mode = 0; mode < NUM_PRED_MODES; ++mode) {
- const uint8_t* const ref = it->yuv_p_ + VP8I16ModeOffsets[mode];
- const score_t score = (score_t)VP8SSE16x16(src, ref) * RD_DISTO_MULT
- + VP8FixedCostsI16[mode] * lambda_d_i16;
- if (mode > 0 && VP8FixedCostsI16[mode] > bit_limit) {
- continue;
- }
-
- if (score < best_score) {
- best_mode = mode;
- best_score = score;
- }
- }
- if (it->x_ == 0 || it->y_ == 0) {
- // avoid starting a checkerboard resonance from the border. See bug #432.
- if (IsFlatSource16(src)) {
- best_mode = (it->x_ == 0) ? 0 : 2;
- try_both_modes = 0; // stick to i16
- }
- }
- VP8SetIntra16Mode(it, best_mode);
- // we'll reconstruct later, if i16 mode actually gets selected
- }
-
- // Next, evaluate Intra4
- if (try_both_modes || !is_i16) {
- // We don't evaluate the rate here, but just account for it through a
- // constant penalty (i4 mode usually needs more bits compared to i16).
- is_i16 = 0;
- VP8IteratorStartI4(it);
- do {
- int best_i4_mode = -1;
- score_t best_i4_score = MAX_COST;
- const uint8_t* const src = it->yuv_in_ + Y_OFF_ENC + VP8Scan[it->i4_];
- const uint16_t* const mode_costs = GetCostModeI4(it, rd->modes_i4);
-
- VP8MakeIntra4Preds(it);
- for (mode = 0; mode < NUM_BMODES; ++mode) {
- const uint8_t* const ref = it->yuv_p_ + VP8I4ModeOffsets[mode];
- const score_t score = VP8SSE4x4(src, ref) * RD_DISTO_MULT
- + mode_costs[mode] * lambda_d_i4;
- if (score < best_i4_score) {
- best_i4_mode = mode;
- best_i4_score = score;
- }
- }
- i4_bit_sum += mode_costs[best_i4_mode];
- rd->modes_i4[it->i4_] = best_i4_mode;
- score_i4 += best_i4_score;
- if (score_i4 >= best_score || i4_bit_sum > bit_limit) {
- // Intra4 won't be better than Intra16. Bail out and pick Intra16.
- is_i16 = 1;
- break;
- } else { // reconstruct partial block inside yuv_out2_ buffer
- uint8_t* const tmp_dst = it->yuv_out2_ + Y_OFF_ENC + VP8Scan[it->i4_];
- nz |= ReconstructIntra4(it, rd->y_ac_levels[it->i4_],
- src, tmp_dst, best_i4_mode) << it->i4_;
- }
- } while (VP8IteratorRotateI4(it, it->yuv_out2_ + Y_OFF_ENC));
- }
-
- // Final reconstruction, depending on which mode is selected.
- if (!is_i16) {
- VP8SetIntra4Mode(it, rd->modes_i4);
- SwapOut(it);
- best_score = score_i4;
- } else {
- nz = ReconstructIntra16(it, rd, it->yuv_out_ + Y_OFF_ENC, it->preds_[0]);
- }
-
- // ... and UV!
- if (refine_uv_mode) {
- int best_mode = -1;
- score_t best_uv_score = MAX_COST;
- const uint8_t* const src = it->yuv_in_ + U_OFF_ENC;
- for (mode = 0; mode < NUM_PRED_MODES; ++mode) {
- const uint8_t* const ref = it->yuv_p_ + VP8UVModeOffsets[mode];
- const score_t score = VP8SSE16x8(src, ref) * RD_DISTO_MULT
- + VP8FixedCostsUV[mode] * lambda_d_uv;
- if (score < best_uv_score) {
- best_mode = mode;
- best_uv_score = score;
- }
- }
- VP8SetIntraUVMode(it, best_mode);
- }
- nz |= ReconstructUV(it, rd, it->yuv_out_ + U_OFF_ENC, it->mb_->uv_mode_);
-
- rd->nz = nz;
- rd->score = best_score;
-}
-
-//------------------------------------------------------------------------------
-// Entry point
-
-int VP8Decimate(VP8EncIterator* const it, VP8ModeScore* const rd,
- VP8RDLevel rd_opt) {
- int is_skipped;
- const int method = it->enc_->method_;
-
- InitScore(rd);
-
- // We can perform predictions for Luma16x16 and Chroma8x8 already.
- // Luma4x4 predictions needs to be done as-we-go.
- VP8MakeLuma16Preds(it);
- VP8MakeChroma8Preds(it);
-
- if (rd_opt > RD_OPT_NONE) {
- it->do_trellis_ = (rd_opt >= RD_OPT_TRELLIS_ALL);
- PickBestIntra16(it, rd);
- if (method >= 2) {
- PickBestIntra4(it, rd);
- }
- PickBestUV(it, rd);
- if (rd_opt == RD_OPT_TRELLIS) { // finish off with trellis-optim now
- it->do_trellis_ = 1;
- SimpleQuantize(it, rd);
- }
- } else {
- // At this point we have heuristically decided intra16 / intra4.
- // For method >= 2, pick the best intra4/intra16 based on SSE (~tad slower).
- // For method <= 1, we don't re-examine the decision but just go ahead with
- // quantization/reconstruction.
- RefineUsingDistortion(it, (method >= 2), (method >= 1), rd);
- }
- is_skipped = (rd->nz == 0);
- VP8SetSkip(it, is_skipped);
- return is_skipped;
-}
diff --git a/contrib/libs/libwebp/enc/syntax_enc.c b/contrib/libs/libwebp/enc/syntax_enc.c
deleted file mode 100644
index 2894691ede..0000000000
--- a/contrib/libs/libwebp/enc/syntax_enc.c
+++ /dev/null
@@ -1,388 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Header syntax writing
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include <assert.h>
-
-#include "../utils/utils.h"
-#include "../webp/format_constants.h" // RIFF constants
-#include "../webp/mux_types.h" // ALPHA_FLAG
-#include "./vp8i_enc.h"
-
-//------------------------------------------------------------------------------
-// Helper functions
-
-static int IsVP8XNeeded(const VP8Encoder* const enc) {
- return !!enc->has_alpha_; // Currently the only case when VP8X is needed.
- // This could change in the future.
-}
-
-static int PutPaddingByte(const WebPPicture* const pic) {
- const uint8_t pad_byte[1] = { 0 };
- return !!pic->writer(pad_byte, 1, pic);
-}
-
-//------------------------------------------------------------------------------
-// Writers for header's various pieces (in order of appearance)
-
-static WebPEncodingError PutRIFFHeader(const VP8Encoder* const enc,
- size_t riff_size) {
- const WebPPicture* const pic = enc->pic_;
- uint8_t riff[RIFF_HEADER_SIZE] = {
- 'R', 'I', 'F', 'F', 0, 0, 0, 0, 'W', 'E', 'B', 'P'
- };
- assert(riff_size == (uint32_t)riff_size);
- PutLE32(riff + TAG_SIZE, (uint32_t)riff_size);
- if (!pic->writer(riff, sizeof(riff), pic)) {
- return VP8_ENC_ERROR_BAD_WRITE;
- }
- return VP8_ENC_OK;
-}
-
-static WebPEncodingError PutVP8XHeader(const VP8Encoder* const enc) {
- const WebPPicture* const pic = enc->pic_;
- uint8_t vp8x[CHUNK_HEADER_SIZE + VP8X_CHUNK_SIZE] = {
- 'V', 'P', '8', 'X'
- };
- uint32_t flags = 0;
-
- assert(IsVP8XNeeded(enc));
- assert(pic->width >= 1 && pic->height >= 1);
- assert(pic->width <= MAX_CANVAS_SIZE && pic->height <= MAX_CANVAS_SIZE);
-
- if (enc->has_alpha_) {
- flags |= ALPHA_FLAG;
- }
-
- PutLE32(vp8x + TAG_SIZE, VP8X_CHUNK_SIZE);
- PutLE32(vp8x + CHUNK_HEADER_SIZE, flags);
- PutLE24(vp8x + CHUNK_HEADER_SIZE + 4, pic->width - 1);
- PutLE24(vp8x + CHUNK_HEADER_SIZE + 7, pic->height - 1);
- if (!pic->writer(vp8x, sizeof(vp8x), pic)) {
- return VP8_ENC_ERROR_BAD_WRITE;
- }
- return VP8_ENC_OK;
-}
-
-static WebPEncodingError PutAlphaChunk(const VP8Encoder* const enc) {
- const WebPPicture* const pic = enc->pic_;
- uint8_t alpha_chunk_hdr[CHUNK_HEADER_SIZE] = {
- 'A', 'L', 'P', 'H'
- };
-
- assert(enc->has_alpha_);
-
- // Alpha chunk header.
- PutLE32(alpha_chunk_hdr + TAG_SIZE, enc->alpha_data_size_);
- if (!pic->writer(alpha_chunk_hdr, sizeof(alpha_chunk_hdr), pic)) {
- return VP8_ENC_ERROR_BAD_WRITE;
- }
-
- // Alpha chunk data.
- if (!pic->writer(enc->alpha_data_, enc->alpha_data_size_, pic)) {
- return VP8_ENC_ERROR_BAD_WRITE;
- }
-
- // Padding.
- if ((enc->alpha_data_size_ & 1) && !PutPaddingByte(pic)) {
- return VP8_ENC_ERROR_BAD_WRITE;
- }
- return VP8_ENC_OK;
-}
-
-static WebPEncodingError PutVP8Header(const WebPPicture* const pic,
- size_t vp8_size) {
- uint8_t vp8_chunk_hdr[CHUNK_HEADER_SIZE] = {
- 'V', 'P', '8', ' '
- };
- assert(vp8_size == (uint32_t)vp8_size);
- PutLE32(vp8_chunk_hdr + TAG_SIZE, (uint32_t)vp8_size);
- if (!pic->writer(vp8_chunk_hdr, sizeof(vp8_chunk_hdr), pic)) {
- return VP8_ENC_ERROR_BAD_WRITE;
- }
- return VP8_ENC_OK;
-}
-
-static WebPEncodingError PutVP8FrameHeader(const WebPPicture* const pic,
- int profile, size_t size0) {
- uint8_t vp8_frm_hdr[VP8_FRAME_HEADER_SIZE];
- uint32_t bits;
-
- if (size0 >= VP8_MAX_PARTITION0_SIZE) { // partition #0 is too big to fit
- return VP8_ENC_ERROR_PARTITION0_OVERFLOW;
- }
-
- // Paragraph 9.1.
- bits = 0 // keyframe (1b)
- | (profile << 1) // profile (3b)
- | (1 << 4) // visible (1b)
- | ((uint32_t)size0 << 5); // partition length (19b)
- vp8_frm_hdr[0] = (bits >> 0) & 0xff;
- vp8_frm_hdr[1] = (bits >> 8) & 0xff;
- vp8_frm_hdr[2] = (bits >> 16) & 0xff;
- // signature
- vp8_frm_hdr[3] = (VP8_SIGNATURE >> 16) & 0xff;
- vp8_frm_hdr[4] = (VP8_SIGNATURE >> 8) & 0xff;
- vp8_frm_hdr[5] = (VP8_SIGNATURE >> 0) & 0xff;
- // dimensions
- vp8_frm_hdr[6] = pic->width & 0xff;
- vp8_frm_hdr[7] = pic->width >> 8;
- vp8_frm_hdr[8] = pic->height & 0xff;
- vp8_frm_hdr[9] = pic->height >> 8;
-
- if (!pic->writer(vp8_frm_hdr, sizeof(vp8_frm_hdr), pic)) {
- return VP8_ENC_ERROR_BAD_WRITE;
- }
- return VP8_ENC_OK;
-}
-
-// WebP Headers.
-static int PutWebPHeaders(const VP8Encoder* const enc, size_t size0,
- size_t vp8_size, size_t riff_size) {
- WebPPicture* const pic = enc->pic_;
- WebPEncodingError err = VP8_ENC_OK;
-
- // RIFF header.
- err = PutRIFFHeader(enc, riff_size);
- if (err != VP8_ENC_OK) goto Error;
-
- // VP8X.
- if (IsVP8XNeeded(enc)) {
- err = PutVP8XHeader(enc);
- if (err != VP8_ENC_OK) goto Error;
- }
-
- // Alpha.
- if (enc->has_alpha_) {
- err = PutAlphaChunk(enc);
- if (err != VP8_ENC_OK) goto Error;
- }
-
- // VP8 header.
- err = PutVP8Header(pic, vp8_size);
- if (err != VP8_ENC_OK) goto Error;
-
- // VP8 frame header.
- err = PutVP8FrameHeader(pic, enc->profile_, size0);
- if (err != VP8_ENC_OK) goto Error;
-
- // All OK.
- return 1;
-
- // Error.
- Error:
- return WebPEncodingSetError(pic, err);
-}
-
-// Segmentation header
-static void PutSegmentHeader(VP8BitWriter* const bw,
- const VP8Encoder* const enc) {
- const VP8EncSegmentHeader* const hdr = &enc->segment_hdr_;
- const VP8EncProba* const proba = &enc->proba_;
- if (VP8PutBitUniform(bw, (hdr->num_segments_ > 1))) {
- // We always 'update' the quant and filter strength values
- const int update_data = 1;
- int s;
- VP8PutBitUniform(bw, hdr->update_map_);
- if (VP8PutBitUniform(bw, update_data)) {
- // we always use absolute values, not relative ones
- VP8PutBitUniform(bw, 1); // (segment_feature_mode = 1. Paragraph 9.3.)
- for (s = 0; s < NUM_MB_SEGMENTS; ++s) {
- VP8PutSignedBits(bw, enc->dqm_[s].quant_, 7);
- }
- for (s = 0; s < NUM_MB_SEGMENTS; ++s) {
- VP8PutSignedBits(bw, enc->dqm_[s].fstrength_, 6);
- }
- }
- if (hdr->update_map_) {
- for (s = 0; s < 3; ++s) {
- if (VP8PutBitUniform(bw, (proba->segments_[s] != 255u))) {
- VP8PutBits(bw, proba->segments_[s], 8);
- }
- }
- }
- }
-}
-
-// Filtering parameters header
-static void PutFilterHeader(VP8BitWriter* const bw,
- const VP8EncFilterHeader* const hdr) {
- const int use_lf_delta = (hdr->i4x4_lf_delta_ != 0);
- VP8PutBitUniform(bw, hdr->simple_);
- VP8PutBits(bw, hdr->level_, 6);
- VP8PutBits(bw, hdr->sharpness_, 3);
- if (VP8PutBitUniform(bw, use_lf_delta)) {
- // '0' is the default value for i4x4_lf_delta_ at frame #0.
- const int need_update = (hdr->i4x4_lf_delta_ != 0);
- if (VP8PutBitUniform(bw, need_update)) {
- // we don't use ref_lf_delta => emit four 0 bits
- VP8PutBits(bw, 0, 4);
- // we use mode_lf_delta for i4x4
- VP8PutSignedBits(bw, hdr->i4x4_lf_delta_, 6);
- VP8PutBits(bw, 0, 3); // all others unused
- }
- }
-}
-
-// Nominal quantization parameters
-static void PutQuant(VP8BitWriter* const bw,
- const VP8Encoder* const enc) {
- VP8PutBits(bw, enc->base_quant_, 7);
- VP8PutSignedBits(bw, enc->dq_y1_dc_, 4);
- VP8PutSignedBits(bw, enc->dq_y2_dc_, 4);
- VP8PutSignedBits(bw, enc->dq_y2_ac_, 4);
- VP8PutSignedBits(bw, enc->dq_uv_dc_, 4);
- VP8PutSignedBits(bw, enc->dq_uv_ac_, 4);
-}
-
-// Partition sizes
-static int EmitPartitionsSize(const VP8Encoder* const enc,
- WebPPicture* const pic) {
- uint8_t buf[3 * (MAX_NUM_PARTITIONS - 1)];
- int p;
- for (p = 0; p < enc->num_parts_ - 1; ++p) {
- const size_t part_size = VP8BitWriterSize(enc->parts_ + p);
- if (part_size >= VP8_MAX_PARTITION_SIZE) {
- return WebPEncodingSetError(pic, VP8_ENC_ERROR_PARTITION_OVERFLOW);
- }
- buf[3 * p + 0] = (part_size >> 0) & 0xff;
- buf[3 * p + 1] = (part_size >> 8) & 0xff;
- buf[3 * p + 2] = (part_size >> 16) & 0xff;
- }
- return p ? pic->writer(buf, 3 * p, pic) : 1;
-}
-
-//------------------------------------------------------------------------------
-
-static int GeneratePartition0(VP8Encoder* const enc) {
- VP8BitWriter* const bw = &enc->bw_;
- const int mb_size = enc->mb_w_ * enc->mb_h_;
- uint64_t pos1, pos2, pos3;
-
- pos1 = VP8BitWriterPos(bw);
- if (!VP8BitWriterInit(bw, mb_size * 7 / 8)) { // ~7 bits per macroblock
- return WebPEncodingSetError(enc->pic_, VP8_ENC_ERROR_OUT_OF_MEMORY);
- }
- VP8PutBitUniform(bw, 0); // colorspace
- VP8PutBitUniform(bw, 0); // clamp type
-
- PutSegmentHeader(bw, enc);
- PutFilterHeader(bw, &enc->filter_hdr_);
- VP8PutBits(bw, enc->num_parts_ == 8 ? 3 :
- enc->num_parts_ == 4 ? 2 :
- enc->num_parts_ == 2 ? 1 : 0, 2);
- PutQuant(bw, enc);
- VP8PutBitUniform(bw, 0); // no proba update
- VP8WriteProbas(bw, &enc->proba_);
- pos2 = VP8BitWriterPos(bw);
- VP8CodeIntraModes(enc);
- VP8BitWriterFinish(bw);
-
- pos3 = VP8BitWriterPos(bw);
-
-#if !defined(WEBP_DISABLE_STATS)
- if (enc->pic_->stats) {
- enc->pic_->stats->header_bytes[0] = (int)((pos2 - pos1 + 7) >> 3);
- enc->pic_->stats->header_bytes[1] = (int)((pos3 - pos2 + 7) >> 3);
- enc->pic_->stats->alpha_data_size = (int)enc->alpha_data_size_;
- }
-#else
- (void)pos1;
- (void)pos2;
- (void)pos3;
-#endif
- if (bw->error_) {
- return WebPEncodingSetError(enc->pic_, VP8_ENC_ERROR_OUT_OF_MEMORY);
- }
- return 1;
-}
-
-void VP8EncFreeBitWriters(VP8Encoder* const enc) {
- int p;
- VP8BitWriterWipeOut(&enc->bw_);
- for (p = 0; p < enc->num_parts_; ++p) {
- VP8BitWriterWipeOut(enc->parts_ + p);
- }
-}
-
-int VP8EncWrite(VP8Encoder* const enc) {
- WebPPicture* const pic = enc->pic_;
- VP8BitWriter* const bw = &enc->bw_;
- const int task_percent = 19;
- const int percent_per_part = task_percent / enc->num_parts_;
- const int final_percent = enc->percent_ + task_percent;
- int ok = 0;
- size_t vp8_size, pad, riff_size;
- int p;
-
- // Partition #0 with header and partition sizes
- ok = GeneratePartition0(enc);
- if (!ok) return 0;
-
- // Compute VP8 size
- vp8_size = VP8_FRAME_HEADER_SIZE +
- VP8BitWriterSize(bw) +
- 3 * (enc->num_parts_ - 1);
- for (p = 0; p < enc->num_parts_; ++p) {
- vp8_size += VP8BitWriterSize(enc->parts_ + p);
- }
- pad = vp8_size & 1;
- vp8_size += pad;
-
- // Compute RIFF size
- // At the minimum it is: "WEBPVP8 nnnn" + VP8 data size.
- riff_size = TAG_SIZE + CHUNK_HEADER_SIZE + vp8_size;
- if (IsVP8XNeeded(enc)) { // Add size for: VP8X header + data.
- riff_size += CHUNK_HEADER_SIZE + VP8X_CHUNK_SIZE;
- }
- if (enc->has_alpha_) { // Add size for: ALPH header + data.
- const uint32_t padded_alpha_size = enc->alpha_data_size_ +
- (enc->alpha_data_size_ & 1);
- riff_size += CHUNK_HEADER_SIZE + padded_alpha_size;
- }
- // RIFF size should fit in 32-bits.
- if (riff_size > 0xfffffffeU) {
- return WebPEncodingSetError(pic, VP8_ENC_ERROR_FILE_TOO_BIG);
- }
-
- // Emit headers and partition #0
- {
- const uint8_t* const part0 = VP8BitWriterBuf(bw);
- const size_t size0 = VP8BitWriterSize(bw);
- ok = ok && PutWebPHeaders(enc, size0, vp8_size, riff_size)
- && pic->writer(part0, size0, pic)
- && EmitPartitionsSize(enc, pic);
- VP8BitWriterWipeOut(bw); // will free the internal buffer.
- }
-
- // Token partitions
- for (p = 0; p < enc->num_parts_; ++p) {
- const uint8_t* const buf = VP8BitWriterBuf(enc->parts_ + p);
- const size_t size = VP8BitWriterSize(enc->parts_ + p);
- if (size) ok = ok && pic->writer(buf, size, pic);
- VP8BitWriterWipeOut(enc->parts_ + p); // will free the internal buffer.
- ok = ok && WebPReportProgress(pic, enc->percent_ + percent_per_part,
- &enc->percent_);
- }
-
- // Padding byte
- if (ok && pad) {
- ok = PutPaddingByte(pic);
- }
-
- enc->coded_size_ = (int)(CHUNK_HEADER_SIZE + riff_size);
- ok = ok && WebPReportProgress(pic, final_percent, &enc->percent_);
- return ok;
-}
-
-//------------------------------------------------------------------------------
-
diff --git a/contrib/libs/libwebp/enc/token_enc.c b/contrib/libs/libwebp/enc/token_enc.c
deleted file mode 100644
index e3a8981fc1..0000000000
--- a/contrib/libs/libwebp/enc/token_enc.c
+++ /dev/null
@@ -1,262 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Paginated token buffer
-//
-// A 'token' is a bit value associated with a probability, either fixed
-// or a later-to-be-determined after statistics have been collected.
-// For dynamic probability, we just record the slot id (idx) for the probability
-// value in the final probability array (uint8_t* probas in VP8EmitTokens).
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include <assert.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "./cost_enc.h"
-#include "./vp8i_enc.h"
-#include "../utils/utils.h"
-
-#if !defined(DISABLE_TOKEN_BUFFER)
-
-// we use pages to reduce the number of memcpy()
-#define MIN_PAGE_SIZE 8192 // minimum number of token per page
-#define FIXED_PROBA_BIT (1u << 14)
-
-typedef uint16_t token_t; // bit #15: bit value
- // bit #14: flags for constant proba or idx
- // bits #0..13: slot or constant proba
-struct VP8Tokens {
- VP8Tokens* next_; // pointer to next page
-};
-// Token data is located in memory just after the next_ field.
-// This macro is used to return their address and hide the trick.
-#define TOKEN_DATA(p) ((const token_t*)&(p)[1])
-
-//------------------------------------------------------------------------------
-
-void VP8TBufferInit(VP8TBuffer* const b, int page_size) {
- b->tokens_ = NULL;
- b->pages_ = NULL;
- b->last_page_ = &b->pages_;
- b->left_ = 0;
- b->page_size_ = (page_size < MIN_PAGE_SIZE) ? MIN_PAGE_SIZE : page_size;
- b->error_ = 0;
-}
-
-void VP8TBufferClear(VP8TBuffer* const b) {
- if (b != NULL) {
- VP8Tokens* p = b->pages_;
- while (p != NULL) {
- VP8Tokens* const next = p->next_;
- WebPSafeFree(p);
- p = next;
- }
- VP8TBufferInit(b, b->page_size_);
- }
-}
-
-static int TBufferNewPage(VP8TBuffer* const b) {
- VP8Tokens* page = NULL;
- if (!b->error_) {
- const size_t size = sizeof(*page) + b->page_size_ * sizeof(token_t);
- page = (VP8Tokens*)WebPSafeMalloc(1ULL, size);
- }
- if (page == NULL) {
- b->error_ = 1;
- return 0;
- }
- page->next_ = NULL;
-
- *b->last_page_ = page;
- b->last_page_ = &page->next_;
- b->left_ = b->page_size_;
- b->tokens_ = (token_t*)TOKEN_DATA(page);
- return 1;
-}
-
-//------------------------------------------------------------------------------
-
-#define TOKEN_ID(t, b, ctx) \
- (NUM_PROBAS * ((ctx) + NUM_CTX * ((b) + NUM_BANDS * (t))))
-
-static WEBP_INLINE uint32_t AddToken(VP8TBuffer* const b, uint32_t bit,
- uint32_t proba_idx,
- proba_t* const stats) {
- assert(proba_idx < FIXED_PROBA_BIT);
- assert(bit <= 1);
- if (b->left_ > 0 || TBufferNewPage(b)) {
- const int slot = --b->left_;
- b->tokens_[slot] = (bit << 15) | proba_idx;
- }
- VP8RecordStats(bit, stats);
- return bit;
-}
-
-static WEBP_INLINE void AddConstantToken(VP8TBuffer* const b,
- uint32_t bit, uint32_t proba) {
- assert(proba < 256);
- assert(bit <= 1);
- if (b->left_ > 0 || TBufferNewPage(b)) {
- const int slot = --b->left_;
- b->tokens_[slot] = (bit << 15) | FIXED_PROBA_BIT | proba;
- }
-}
-
-int VP8RecordCoeffTokens(int ctx, const struct VP8Residual* const res,
- VP8TBuffer* const tokens) {
- const int16_t* const coeffs = res->coeffs;
- const int coeff_type = res->coeff_type;
- const int last = res->last;
- int n = res->first;
- uint32_t base_id = TOKEN_ID(coeff_type, n, ctx);
- // should be stats[VP8EncBands[n]], but it's equivalent for n=0 or 1
- proba_t* s = res->stats[n][ctx];
- if (!AddToken(tokens, last >= 0, base_id + 0, s + 0)) {
- return 0;
- }
-
- while (n < 16) {
- const int c = coeffs[n++];
- const int sign = c < 0;
- const uint32_t v = sign ? -c : c;
- if (!AddToken(tokens, v != 0, base_id + 1, s + 1)) {
- base_id = TOKEN_ID(coeff_type, VP8EncBands[n], 0); // ctx=0
- s = res->stats[VP8EncBands[n]][0];
- continue;
- }
- if (!AddToken(tokens, v > 1, base_id + 2, s + 2)) {
- base_id = TOKEN_ID(coeff_type, VP8EncBands[n], 1); // ctx=1
- s = res->stats[VP8EncBands[n]][1];
- } else {
- if (!AddToken(tokens, v > 4, base_id + 3, s + 3)) {
- if (AddToken(tokens, v != 2, base_id + 4, s + 4)) {
- AddToken(tokens, v == 4, base_id + 5, s + 5);
- }
- } else if (!AddToken(tokens, v > 10, base_id + 6, s + 6)) {
- if (!AddToken(tokens, v > 6, base_id + 7, s + 7)) {
- AddConstantToken(tokens, v == 6, 159);
- } else {
- AddConstantToken(tokens, v >= 9, 165);
- AddConstantToken(tokens, !(v & 1), 145);
- }
- } else {
- int mask;
- const uint8_t* tab;
- uint32_t residue = v - 3;
- if (residue < (8 << 1)) { // VP8Cat3 (3b)
- AddToken(tokens, 0, base_id + 8, s + 8);
- AddToken(tokens, 0, base_id + 9, s + 9);
- residue -= (8 << 0);
- mask = 1 << 2;
- tab = VP8Cat3;
- } else if (residue < (8 << 2)) { // VP8Cat4 (4b)
- AddToken(tokens, 0, base_id + 8, s + 8);
- AddToken(tokens, 1, base_id + 9, s + 9);
- residue -= (8 << 1);
- mask = 1 << 3;
- tab = VP8Cat4;
- } else if (residue < (8 << 3)) { // VP8Cat5 (5b)
- AddToken(tokens, 1, base_id + 8, s + 8);
- AddToken(tokens, 0, base_id + 10, s + 9);
- residue -= (8 << 2);
- mask = 1 << 4;
- tab = VP8Cat5;
- } else { // VP8Cat6 (11b)
- AddToken(tokens, 1, base_id + 8, s + 8);
- AddToken(tokens, 1, base_id + 10, s + 9);
- residue -= (8 << 3);
- mask = 1 << 10;
- tab = VP8Cat6;
- }
- while (mask) {
- AddConstantToken(tokens, !!(residue & mask), *tab++);
- mask >>= 1;
- }
- }
- base_id = TOKEN_ID(coeff_type, VP8EncBands[n], 2); // ctx=2
- s = res->stats[VP8EncBands[n]][2];
- }
- AddConstantToken(tokens, sign, 128);
- if (n == 16 || !AddToken(tokens, n <= last, base_id + 0, s + 0)) {
- return 1; // EOB
- }
- }
- return 1;
-}
-
-#undef TOKEN_ID
-
-//------------------------------------------------------------------------------
-// Final coding pass, with known probabilities
-
-int VP8EmitTokens(VP8TBuffer* const b, VP8BitWriter* const bw,
- const uint8_t* const probas, int final_pass) {
- const VP8Tokens* p = b->pages_;
- assert(!b->error_);
- while (p != NULL) {
- const VP8Tokens* const next = p->next_;
- const int N = (next == NULL) ? b->left_ : 0;
- int n = b->page_size_;
- const token_t* const tokens = TOKEN_DATA(p);
- while (n-- > N) {
- const token_t token = tokens[n];
- const int bit = (token >> 15) & 1;
- if (token & FIXED_PROBA_BIT) {
- VP8PutBit(bw, bit, token & 0xffu); // constant proba
- } else {
- VP8PutBit(bw, bit, probas[token & 0x3fffu]);
- }
- }
- if (final_pass) WebPSafeFree((void*)p);
- p = next;
- }
- if (final_pass) b->pages_ = NULL;
- return 1;
-}
-
-// Size estimation
-size_t VP8EstimateTokenSize(VP8TBuffer* const b, const uint8_t* const probas) {
- size_t size = 0;
- const VP8Tokens* p = b->pages_;
- assert(!b->error_);
- while (p != NULL) {
- const VP8Tokens* const next = p->next_;
- const int N = (next == NULL) ? b->left_ : 0;
- int n = b->page_size_;
- const token_t* const tokens = TOKEN_DATA(p);
- while (n-- > N) {
- const token_t token = tokens[n];
- const int bit = token & (1 << 15);
- if (token & FIXED_PROBA_BIT) {
- size += VP8BitCost(bit, token & 0xffu);
- } else {
- size += VP8BitCost(bit, probas[token & 0x3fffu]);
- }
- }
- p = next;
- }
- return size;
-}
-
-//------------------------------------------------------------------------------
-
-#else // DISABLE_TOKEN_BUFFER
-
-void VP8TBufferInit(VP8TBuffer* const b, int page_size) {
- (void)b;
- (void)page_size;
-}
-void VP8TBufferClear(VP8TBuffer* const b) {
- (void)b;
-}
-
-#endif // !DISABLE_TOKEN_BUFFER
-
diff --git a/contrib/libs/libwebp/enc/tree_enc.c b/contrib/libs/libwebp/enc/tree_enc.c
deleted file mode 100644
index 2c40fe7f3d..0000000000
--- a/contrib/libs/libwebp/enc/tree_enc.c
+++ /dev/null
@@ -1,504 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Coding of token probabilities, intra modes and segments.
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include "./vp8i_enc.h"
-
-//------------------------------------------------------------------------------
-// Default probabilities
-
-// Paragraph 13.5
-const uint8_t
- VP8CoeffsProba0[NUM_TYPES][NUM_BANDS][NUM_CTX][NUM_PROBAS] = {
- { { { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 }
- },
- { { 253, 136, 254, 255, 228, 219, 128, 128, 128, 128, 128 },
- { 189, 129, 242, 255, 227, 213, 255, 219, 128, 128, 128 },
- { 106, 126, 227, 252, 214, 209, 255, 255, 128, 128, 128 }
- },
- { { 1, 98, 248, 255, 236, 226, 255, 255, 128, 128, 128 },
- { 181, 133, 238, 254, 221, 234, 255, 154, 128, 128, 128 },
- { 78, 134, 202, 247, 198, 180, 255, 219, 128, 128, 128 },
- },
- { { 1, 185, 249, 255, 243, 255, 128, 128, 128, 128, 128 },
- { 184, 150, 247, 255, 236, 224, 128, 128, 128, 128, 128 },
- { 77, 110, 216, 255, 236, 230, 128, 128, 128, 128, 128 },
- },
- { { 1, 101, 251, 255, 241, 255, 128, 128, 128, 128, 128 },
- { 170, 139, 241, 252, 236, 209, 255, 255, 128, 128, 128 },
- { 37, 116, 196, 243, 228, 255, 255, 255, 128, 128, 128 }
- },
- { { 1, 204, 254, 255, 245, 255, 128, 128, 128, 128, 128 },
- { 207, 160, 250, 255, 238, 128, 128, 128, 128, 128, 128 },
- { 102, 103, 231, 255, 211, 171, 128, 128, 128, 128, 128 }
- },
- { { 1, 152, 252, 255, 240, 255, 128, 128, 128, 128, 128 },
- { 177, 135, 243, 255, 234, 225, 128, 128, 128, 128, 128 },
- { 80, 129, 211, 255, 194, 224, 128, 128, 128, 128, 128 }
- },
- { { 1, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 246, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 255, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 }
- }
- },
- { { { 198, 35, 237, 223, 193, 187, 162, 160, 145, 155, 62 },
- { 131, 45, 198, 221, 172, 176, 220, 157, 252, 221, 1 },
- { 68, 47, 146, 208, 149, 167, 221, 162, 255, 223, 128 }
- },
- { { 1, 149, 241, 255, 221, 224, 255, 255, 128, 128, 128 },
- { 184, 141, 234, 253, 222, 220, 255, 199, 128, 128, 128 },
- { 81, 99, 181, 242, 176, 190, 249, 202, 255, 255, 128 }
- },
- { { 1, 129, 232, 253, 214, 197, 242, 196, 255, 255, 128 },
- { 99, 121, 210, 250, 201, 198, 255, 202, 128, 128, 128 },
- { 23, 91, 163, 242, 170, 187, 247, 210, 255, 255, 128 }
- },
- { { 1, 200, 246, 255, 234, 255, 128, 128, 128, 128, 128 },
- { 109, 178, 241, 255, 231, 245, 255, 255, 128, 128, 128 },
- { 44, 130, 201, 253, 205, 192, 255, 255, 128, 128, 128 }
- },
- { { 1, 132, 239, 251, 219, 209, 255, 165, 128, 128, 128 },
- { 94, 136, 225, 251, 218, 190, 255, 255, 128, 128, 128 },
- { 22, 100, 174, 245, 186, 161, 255, 199, 128, 128, 128 }
- },
- { { 1, 182, 249, 255, 232, 235, 128, 128, 128, 128, 128 },
- { 124, 143, 241, 255, 227, 234, 128, 128, 128, 128, 128 },
- { 35, 77, 181, 251, 193, 211, 255, 205, 128, 128, 128 }
- },
- { { 1, 157, 247, 255, 236, 231, 255, 255, 128, 128, 128 },
- { 121, 141, 235, 255, 225, 227, 255, 255, 128, 128, 128 },
- { 45, 99, 188, 251, 195, 217, 255, 224, 128, 128, 128 }
- },
- { { 1, 1, 251, 255, 213, 255, 128, 128, 128, 128, 128 },
- { 203, 1, 248, 255, 255, 128, 128, 128, 128, 128, 128 },
- { 137, 1, 177, 255, 224, 255, 128, 128, 128, 128, 128 }
- }
- },
- { { { 253, 9, 248, 251, 207, 208, 255, 192, 128, 128, 128 },
- { 175, 13, 224, 243, 193, 185, 249, 198, 255, 255, 128 },
- { 73, 17, 171, 221, 161, 179, 236, 167, 255, 234, 128 }
- },
- { { 1, 95, 247, 253, 212, 183, 255, 255, 128, 128, 128 },
- { 239, 90, 244, 250, 211, 209, 255, 255, 128, 128, 128 },
- { 155, 77, 195, 248, 188, 195, 255, 255, 128, 128, 128 }
- },
- { { 1, 24, 239, 251, 218, 219, 255, 205, 128, 128, 128 },
- { 201, 51, 219, 255, 196, 186, 128, 128, 128, 128, 128 },
- { 69, 46, 190, 239, 201, 218, 255, 228, 128, 128, 128 }
- },
- { { 1, 191, 251, 255, 255, 128, 128, 128, 128, 128, 128 },
- { 223, 165, 249, 255, 213, 255, 128, 128, 128, 128, 128 },
- { 141, 124, 248, 255, 255, 128, 128, 128, 128, 128, 128 }
- },
- { { 1, 16, 248, 255, 255, 128, 128, 128, 128, 128, 128 },
- { 190, 36, 230, 255, 236, 255, 128, 128, 128, 128, 128 },
- { 149, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 }
- },
- { { 1, 226, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 247, 192, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 240, 128, 255, 128, 128, 128, 128, 128, 128, 128, 128 }
- },
- { { 1, 134, 252, 255, 255, 128, 128, 128, 128, 128, 128 },
- { 213, 62, 250, 255, 255, 128, 128, 128, 128, 128, 128 },
- { 55, 93, 255, 128, 128, 128, 128, 128, 128, 128, 128 }
- },
- { { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 }
- }
- },
- { { { 202, 24, 213, 235, 186, 191, 220, 160, 240, 175, 255 },
- { 126, 38, 182, 232, 169, 184, 228, 174, 255, 187, 128 },
- { 61, 46, 138, 219, 151, 178, 240, 170, 255, 216, 128 }
- },
- { { 1, 112, 230, 250, 199, 191, 247, 159, 255, 255, 128 },
- { 166, 109, 228, 252, 211, 215, 255, 174, 128, 128, 128 },
- { 39, 77, 162, 232, 172, 180, 245, 178, 255, 255, 128 }
- },
- { { 1, 52, 220, 246, 198, 199, 249, 220, 255, 255, 128 },
- { 124, 74, 191, 243, 183, 193, 250, 221, 255, 255, 128 },
- { 24, 71, 130, 219, 154, 170, 243, 182, 255, 255, 128 }
- },
- { { 1, 182, 225, 249, 219, 240, 255, 224, 128, 128, 128 },
- { 149, 150, 226, 252, 216, 205, 255, 171, 128, 128, 128 },
- { 28, 108, 170, 242, 183, 194, 254, 223, 255, 255, 128 }
- },
- { { 1, 81, 230, 252, 204, 203, 255, 192, 128, 128, 128 },
- { 123, 102, 209, 247, 188, 196, 255, 233, 128, 128, 128 },
- { 20, 95, 153, 243, 164, 173, 255, 203, 128, 128, 128 }
- },
- { { 1, 222, 248, 255, 216, 213, 128, 128, 128, 128, 128 },
- { 168, 175, 246, 252, 235, 205, 255, 255, 128, 128, 128 },
- { 47, 116, 215, 255, 211, 212, 255, 255, 128, 128, 128 }
- },
- { { 1, 121, 236, 253, 212, 214, 255, 255, 128, 128, 128 },
- { 141, 84, 213, 252, 201, 202, 255, 219, 128, 128, 128 },
- { 42, 80, 160, 240, 162, 185, 255, 205, 128, 128, 128 }
- },
- { { 1, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 244, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 238, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 }
- }
- }
-};
-
-void VP8DefaultProbas(VP8Encoder* const enc) {
- VP8EncProba* const probas = &enc->proba_;
- probas->use_skip_proba_ = 0;
- memset(probas->segments_, 255u, sizeof(probas->segments_));
- memcpy(probas->coeffs_, VP8CoeffsProba0, sizeof(VP8CoeffsProba0));
- // Note: we could hard-code the level_costs_ corresponding to VP8CoeffsProba0,
- // but that's ~11k of static data. Better call VP8CalculateLevelCosts() later.
- probas->dirty_ = 1;
-}
-
-// Paragraph 11.5. 900bytes.
-static const uint8_t kBModesProba[NUM_BMODES][NUM_BMODES][NUM_BMODES - 1] = {
- { { 231, 120, 48, 89, 115, 113, 120, 152, 112 },
- { 152, 179, 64, 126, 170, 118, 46, 70, 95 },
- { 175, 69, 143, 80, 85, 82, 72, 155, 103 },
- { 56, 58, 10, 171, 218, 189, 17, 13, 152 },
- { 114, 26, 17, 163, 44, 195, 21, 10, 173 },
- { 121, 24, 80, 195, 26, 62, 44, 64, 85 },
- { 144, 71, 10, 38, 171, 213, 144, 34, 26 },
- { 170, 46, 55, 19, 136, 160, 33, 206, 71 },
- { 63, 20, 8, 114, 114, 208, 12, 9, 226 },
- { 81, 40, 11, 96, 182, 84, 29, 16, 36 } },
- { { 134, 183, 89, 137, 98, 101, 106, 165, 148 },
- { 72, 187, 100, 130, 157, 111, 32, 75, 80 },
- { 66, 102, 167, 99, 74, 62, 40, 234, 128 },
- { 41, 53, 9, 178, 241, 141, 26, 8, 107 },
- { 74, 43, 26, 146, 73, 166, 49, 23, 157 },
- { 65, 38, 105, 160, 51, 52, 31, 115, 128 },
- { 104, 79, 12, 27, 217, 255, 87, 17, 7 },
- { 87, 68, 71, 44, 114, 51, 15, 186, 23 },
- { 47, 41, 14, 110, 182, 183, 21, 17, 194 },
- { 66, 45, 25, 102, 197, 189, 23, 18, 22 } },
- { { 88, 88, 147, 150, 42, 46, 45, 196, 205 },
- { 43, 97, 183, 117, 85, 38, 35, 179, 61 },
- { 39, 53, 200, 87, 26, 21, 43, 232, 171 },
- { 56, 34, 51, 104, 114, 102, 29, 93, 77 },
- { 39, 28, 85, 171, 58, 165, 90, 98, 64 },
- { 34, 22, 116, 206, 23, 34, 43, 166, 73 },
- { 107, 54, 32, 26, 51, 1, 81, 43, 31 },
- { 68, 25, 106, 22, 64, 171, 36, 225, 114 },
- { 34, 19, 21, 102, 132, 188, 16, 76, 124 },
- { 62, 18, 78, 95, 85, 57, 50, 48, 51 } },
- { { 193, 101, 35, 159, 215, 111, 89, 46, 111 },
- { 60, 148, 31, 172, 219, 228, 21, 18, 111 },
- { 112, 113, 77, 85, 179, 255, 38, 120, 114 },
- { 40, 42, 1, 196, 245, 209, 10, 25, 109 },
- { 88, 43, 29, 140, 166, 213, 37, 43, 154 },
- { 61, 63, 30, 155, 67, 45, 68, 1, 209 },
- { 100, 80, 8, 43, 154, 1, 51, 26, 71 },
- { 142, 78, 78, 16, 255, 128, 34, 197, 171 },
- { 41, 40, 5, 102, 211, 183, 4, 1, 221 },
- { 51, 50, 17, 168, 209, 192, 23, 25, 82 } },
- { { 138, 31, 36, 171, 27, 166, 38, 44, 229 },
- { 67, 87, 58, 169, 82, 115, 26, 59, 179 },
- { 63, 59, 90, 180, 59, 166, 93, 73, 154 },
- { 40, 40, 21, 116, 143, 209, 34, 39, 175 },
- { 47, 15, 16, 183, 34, 223, 49, 45, 183 },
- { 46, 17, 33, 183, 6, 98, 15, 32, 183 },
- { 57, 46, 22, 24, 128, 1, 54, 17, 37 },
- { 65, 32, 73, 115, 28, 128, 23, 128, 205 },
- { 40, 3, 9, 115, 51, 192, 18, 6, 223 },
- { 87, 37, 9, 115, 59, 77, 64, 21, 47 } },
- { { 104, 55, 44, 218, 9, 54, 53, 130, 226 },
- { 64, 90, 70, 205, 40, 41, 23, 26, 57 },
- { 54, 57, 112, 184, 5, 41, 38, 166, 213 },
- { 30, 34, 26, 133, 152, 116, 10, 32, 134 },
- { 39, 19, 53, 221, 26, 114, 32, 73, 255 },
- { 31, 9, 65, 234, 2, 15, 1, 118, 73 },
- { 75, 32, 12, 51, 192, 255, 160, 43, 51 },
- { 88, 31, 35, 67, 102, 85, 55, 186, 85 },
- { 56, 21, 23, 111, 59, 205, 45, 37, 192 },
- { 55, 38, 70, 124, 73, 102, 1, 34, 98 } },
- { { 125, 98, 42, 88, 104, 85, 117, 175, 82 },
- { 95, 84, 53, 89, 128, 100, 113, 101, 45 },
- { 75, 79, 123, 47, 51, 128, 81, 171, 1 },
- { 57, 17, 5, 71, 102, 57, 53, 41, 49 },
- { 38, 33, 13, 121, 57, 73, 26, 1, 85 },
- { 41, 10, 67, 138, 77, 110, 90, 47, 114 },
- { 115, 21, 2, 10, 102, 255, 166, 23, 6 },
- { 101, 29, 16, 10, 85, 128, 101, 196, 26 },
- { 57, 18, 10, 102, 102, 213, 34, 20, 43 },
- { 117, 20, 15, 36, 163, 128, 68, 1, 26 } },
- { { 102, 61, 71, 37, 34, 53, 31, 243, 192 },
- { 69, 60, 71, 38, 73, 119, 28, 222, 37 },
- { 68, 45, 128, 34, 1, 47, 11, 245, 171 },
- { 62, 17, 19, 70, 146, 85, 55, 62, 70 },
- { 37, 43, 37, 154, 100, 163, 85, 160, 1 },
- { 63, 9, 92, 136, 28, 64, 32, 201, 85 },
- { 75, 15, 9, 9, 64, 255, 184, 119, 16 },
- { 86, 6, 28, 5, 64, 255, 25, 248, 1 },
- { 56, 8, 17, 132, 137, 255, 55, 116, 128 },
- { 58, 15, 20, 82, 135, 57, 26, 121, 40 } },
- { { 164, 50, 31, 137, 154, 133, 25, 35, 218 },
- { 51, 103, 44, 131, 131, 123, 31, 6, 158 },
- { 86, 40, 64, 135, 148, 224, 45, 183, 128 },
- { 22, 26, 17, 131, 240, 154, 14, 1, 209 },
- { 45, 16, 21, 91, 64, 222, 7, 1, 197 },
- { 56, 21, 39, 155, 60, 138, 23, 102, 213 },
- { 83, 12, 13, 54, 192, 255, 68, 47, 28 },
- { 85, 26, 85, 85, 128, 128, 32, 146, 171 },
- { 18, 11, 7, 63, 144, 171, 4, 4, 246 },
- { 35, 27, 10, 146, 174, 171, 12, 26, 128 } },
- { { 190, 80, 35, 99, 180, 80, 126, 54, 45 },
- { 85, 126, 47, 87, 176, 51, 41, 20, 32 },
- { 101, 75, 128, 139, 118, 146, 116, 128, 85 },
- { 56, 41, 15, 176, 236, 85, 37, 9, 62 },
- { 71, 30, 17, 119, 118, 255, 17, 18, 138 },
- { 101, 38, 60, 138, 55, 70, 43, 26, 142 },
- { 146, 36, 19, 30, 171, 255, 97, 27, 20 },
- { 138, 45, 61, 62, 219, 1, 81, 188, 64 },
- { 32, 41, 20, 117, 151, 142, 20, 21, 163 },
- { 112, 19, 12, 61, 195, 128, 48, 4, 24 } }
-};
-
-static int PutI4Mode(VP8BitWriter* const bw, int mode,
- const uint8_t* const prob) {
- if (VP8PutBit(bw, mode != B_DC_PRED, prob[0])) {
- if (VP8PutBit(bw, mode != B_TM_PRED, prob[1])) {
- if (VP8PutBit(bw, mode != B_VE_PRED, prob[2])) {
- if (!VP8PutBit(bw, mode >= B_LD_PRED, prob[3])) {
- if (VP8PutBit(bw, mode != B_HE_PRED, prob[4])) {
- VP8PutBit(bw, mode != B_RD_PRED, prob[5]);
- }
- } else {
- if (VP8PutBit(bw, mode != B_LD_PRED, prob[6])) {
- if (VP8PutBit(bw, mode != B_VL_PRED, prob[7])) {
- VP8PutBit(bw, mode != B_HD_PRED, prob[8]);
- }
- }
- }
- }
- }
- }
- return mode;
-}
-
-static void PutI16Mode(VP8BitWriter* const bw, int mode) {
- if (VP8PutBit(bw, (mode == TM_PRED || mode == H_PRED), 156)) {
- VP8PutBit(bw, mode == TM_PRED, 128); // TM or HE
- } else {
- VP8PutBit(bw, mode == V_PRED, 163); // VE or DC
- }
-}
-
-static void PutUVMode(VP8BitWriter* const bw, int uv_mode) {
- if (VP8PutBit(bw, uv_mode != DC_PRED, 142)) {
- if (VP8PutBit(bw, uv_mode != V_PRED, 114)) {
- VP8PutBit(bw, uv_mode != H_PRED, 183); // else: TM_PRED
- }
- }
-}
-
-static void PutSegment(VP8BitWriter* const bw, int s, const uint8_t* p) {
- if (VP8PutBit(bw, s >= 2, p[0])) p += 1;
- VP8PutBit(bw, s & 1, p[1]);
-}
-
-void VP8CodeIntraModes(VP8Encoder* const enc) {
- VP8BitWriter* const bw = &enc->bw_;
- VP8EncIterator it;
- VP8IteratorInit(enc, &it);
- do {
- const VP8MBInfo* const mb = it.mb_;
- const uint8_t* preds = it.preds_;
- if (enc->segment_hdr_.update_map_) {
- PutSegment(bw, mb->segment_, enc->proba_.segments_);
- }
- if (enc->proba_.use_skip_proba_) {
- VP8PutBit(bw, mb->skip_, enc->proba_.skip_proba_);
- }
- if (VP8PutBit(bw, (mb->type_ != 0), 145)) { // i16x16
- PutI16Mode(bw, preds[0]);
- } else {
- const int preds_w = enc->preds_w_;
- const uint8_t* top_pred = preds - preds_w;
- int x, y;
- for (y = 0; y < 4; ++y) {
- int left = preds[-1];
- for (x = 0; x < 4; ++x) {
- const uint8_t* const probas = kBModesProba[top_pred[x]][left];
- left = PutI4Mode(bw, preds[x], probas);
- }
- top_pred = preds;
- preds += preds_w;
- }
- }
- PutUVMode(bw, mb->uv_mode_);
- } while (VP8IteratorNext(&it));
-}
-
-//------------------------------------------------------------------------------
-// Paragraph 13
-
-const uint8_t
- VP8CoeffsUpdateProba[NUM_TYPES][NUM_BANDS][NUM_CTX][NUM_PROBAS] = {
- { { { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 176, 246, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 223, 241, 252, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 249, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 244, 252, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 234, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 253, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 246, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 239, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 254, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 248, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 251, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 251, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 254, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 254, 253, 255, 254, 255, 255, 255, 255, 255, 255 },
- { 250, 255, 254, 255, 254, 255, 255, 255, 255, 255, 255 },
- { 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }
- }
- },
- { { { 217, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 225, 252, 241, 253, 255, 255, 254, 255, 255, 255, 255 },
- { 234, 250, 241, 250, 253, 255, 253, 254, 255, 255, 255 }
- },
- { { 255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 223, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 238, 253, 254, 254, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 248, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 249, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 253, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 247, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 252, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 253, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 254, 253, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 250, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }
- }
- },
- { { { 186, 251, 250, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 234, 251, 244, 254, 255, 255, 255, 255, 255, 255, 255 },
- { 251, 251, 243, 253, 254, 255, 254, 255, 255, 255, 255 }
- },
- { { 255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 236, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 251, 253, 253, 254, 254, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 254, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 254, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }
- }
- },
- { { { 248, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 250, 254, 252, 254, 255, 255, 255, 255, 255, 255, 255 },
- { 248, 254, 249, 253, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 246, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 252, 254, 251, 254, 254, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 254, 252, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 248, 254, 253, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 253, 255, 254, 254, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 251, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 245, 251, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 253, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 251, 253, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 252, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 252, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 249, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 255, 253, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 250, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }
- },
- { { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }
- }
- }
-};
-
-void VP8WriteProbas(VP8BitWriter* const bw, const VP8EncProba* const probas) {
- int t, b, c, p;
- for (t = 0; t < NUM_TYPES; ++t) {
- for (b = 0; b < NUM_BANDS; ++b) {
- for (c = 0; c < NUM_CTX; ++c) {
- for (p = 0; p < NUM_PROBAS; ++p) {
- const uint8_t p0 = probas->coeffs_[t][b][c][p];
- const int update = (p0 != VP8CoeffsProba0[t][b][c][p]);
- if (VP8PutBit(bw, update, VP8CoeffsUpdateProba[t][b][c][p])) {
- VP8PutBits(bw, p0, 8);
- }
- }
- }
- }
- }
- if (VP8PutBitUniform(bw, probas->use_skip_proba_)) {
- VP8PutBits(bw, probas->skip_proba_, 8);
- }
-}
-
diff --git a/contrib/libs/libwebp/enc/vp8i_enc.h b/contrib/libs/libwebp/enc/vp8i_enc.h
deleted file mode 100644
index 9bca205e01..0000000000
--- a/contrib/libs/libwebp/enc/vp8i_enc.h
+++ /dev/null
@@ -1,517 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// WebP encoder: internal header.
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#ifndef WEBP_ENC_VP8I_ENC_H_
-#define WEBP_ENC_VP8I_ENC_H_
-
-#include <string.h> // for memcpy()
-#include "../dec/common_dec.h"
-#include "../dsp/dsp.h"
-#include "../utils/bit_writer_utils.h"
-#include "../utils/thread_utils.h"
-#include "../utils/utils.h"
-#include "../webp/encode.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-//------------------------------------------------------------------------------
-// Various defines and enums
-
-// version numbers
-#define ENC_MAJ_VERSION 1
-#define ENC_MIN_VERSION 2
-#define ENC_REV_VERSION 2
-
-enum { MAX_LF_LEVELS = 64, // Maximum loop filter level
- MAX_VARIABLE_LEVEL = 67, // last (inclusive) level with variable cost
- MAX_LEVEL = 2047 // max level (note: max codable is 2047 + 67)
- };
-
-typedef enum { // Rate-distortion optimization levels
- RD_OPT_NONE = 0, // no rd-opt
- RD_OPT_BASIC = 1, // basic scoring (no trellis)
- RD_OPT_TRELLIS = 2, // perform trellis-quant on the final decision only
- RD_OPT_TRELLIS_ALL = 3 // trellis-quant for every scoring (much slower)
-} VP8RDLevel;
-
-// YUV-cache parameters. Cache is 32-bytes wide (= one cacheline).
-// The original or reconstructed samples can be accessed using VP8Scan[].
-// The predicted blocks can be accessed using offsets to yuv_p_ and
-// the arrays VP8*ModeOffsets[].
-// * YUV Samples area (yuv_in_/yuv_out_/yuv_out2_)
-// (see VP8Scan[] for accessing the blocks, along with
-// Y_OFF_ENC/U_OFF_ENC/V_OFF_ENC):
-// +----+----+
-// Y_OFF_ENC |YYYY|UUVV|
-// U_OFF_ENC |YYYY|UUVV|
-// V_OFF_ENC |YYYY|....| <- 25% wasted U/V area
-// |YYYY|....|
-// +----+----+
-// * Prediction area ('yuv_p_', size = PRED_SIZE_ENC)
-// Intra16 predictions (16x16 block each, two per row):
-// |I16DC16|I16TM16|
-// |I16VE16|I16HE16|
-// Chroma U/V predictions (16x8 block each, two per row):
-// |C8DC8|C8TM8|
-// |C8VE8|C8HE8|
-// Intra 4x4 predictions (4x4 block each)
-// |I4DC4 I4TM4 I4VE4 I4HE4|I4RD4 I4VR4 I4LD4 I4VL4|
-// |I4HD4 I4HU4 I4TMP .....|.......................| <- ~31% wasted
-#define YUV_SIZE_ENC (BPS * 16)
-#define PRED_SIZE_ENC (32 * BPS + 16 * BPS + 8 * BPS) // I16+Chroma+I4 preds
-#define Y_OFF_ENC (0)
-#define U_OFF_ENC (16)
-#define V_OFF_ENC (16 + 8)
-
-extern const uint16_t VP8Scan[16];
-extern const uint16_t VP8UVModeOffsets[4];
-extern const uint16_t VP8I16ModeOffsets[4];
-extern const uint16_t VP8I4ModeOffsets[NUM_BMODES];
-
-// Layout of prediction blocks
-// intra 16x16
-#define I16DC16 (0 * 16 * BPS)
-#define I16TM16 (I16DC16 + 16)
-#define I16VE16 (1 * 16 * BPS)
-#define I16HE16 (I16VE16 + 16)
-// chroma 8x8, two U/V blocks side by side (hence: 16x8 each)
-#define C8DC8 (2 * 16 * BPS)
-#define C8TM8 (C8DC8 + 1 * 16)
-#define C8VE8 (2 * 16 * BPS + 8 * BPS)
-#define C8HE8 (C8VE8 + 1 * 16)
-// intra 4x4
-#define I4DC4 (3 * 16 * BPS + 0)
-#define I4TM4 (I4DC4 + 4)
-#define I4VE4 (I4DC4 + 8)
-#define I4HE4 (I4DC4 + 12)
-#define I4RD4 (I4DC4 + 16)
-#define I4VR4 (I4DC4 + 20)
-#define I4LD4 (I4DC4 + 24)
-#define I4VL4 (I4DC4 + 28)
-#define I4HD4 (3 * 16 * BPS + 4 * BPS)
-#define I4HU4 (I4HD4 + 4)
-#define I4TMP (I4HD4 + 8)
-
-typedef int64_t score_t; // type used for scores, rate, distortion
-// Note that MAX_COST is not the maximum allowed by sizeof(score_t),
-// in order to allow overflowing computations.
-#define MAX_COST ((score_t)0x7fffffffffffffLL)
-
-#define QFIX 17
-#define BIAS(b) ((b) << (QFIX - 8))
-// Fun fact: this is the _only_ line where we're actually being lossy and
-// discarding bits.
-static WEBP_INLINE int QUANTDIV(uint32_t n, uint32_t iQ, uint32_t B) {
- return (int)((n * iQ + B) >> QFIX);
-}
-
-// Uncomment the following to remove token-buffer code:
-// #define DISABLE_TOKEN_BUFFER
-
-// quality below which error-diffusion is enabled
-#define ERROR_DIFFUSION_QUALITY 98
-
-//------------------------------------------------------------------------------
-// Headers
-
-typedef uint32_t proba_t; // 16b + 16b
-typedef uint8_t ProbaArray[NUM_CTX][NUM_PROBAS];
-typedef proba_t StatsArray[NUM_CTX][NUM_PROBAS];
-typedef uint16_t CostArray[NUM_CTX][MAX_VARIABLE_LEVEL + 1];
-typedef const uint16_t* (*CostArrayPtr)[NUM_CTX]; // for easy casting
-typedef const uint16_t* CostArrayMap[16][NUM_CTX];
-typedef double LFStats[NUM_MB_SEGMENTS][MAX_LF_LEVELS]; // filter stats
-
-typedef struct VP8Encoder VP8Encoder;
-
-// segment features
-typedef struct {
- int num_segments_; // Actual number of segments. 1 segment only = unused.
- int update_map_; // whether to update the segment map or not.
- // must be 0 if there's only 1 segment.
- int size_; // bit-cost for transmitting the segment map
-} VP8EncSegmentHeader;
-
-// Struct collecting all frame-persistent probabilities.
-typedef struct {
- uint8_t segments_[3]; // probabilities for segment tree
- uint8_t skip_proba_; // final probability of being skipped.
- ProbaArray coeffs_[NUM_TYPES][NUM_BANDS]; // 1056 bytes
- StatsArray stats_[NUM_TYPES][NUM_BANDS]; // 4224 bytes
- CostArray level_cost_[NUM_TYPES][NUM_BANDS]; // 13056 bytes
- CostArrayMap remapped_costs_[NUM_TYPES]; // 1536 bytes
- int dirty_; // if true, need to call VP8CalculateLevelCosts()
- int use_skip_proba_; // Note: we always use skip_proba for now.
- int nb_skip_; // number of skipped blocks
-} VP8EncProba;
-
-// Filter parameters. Not actually used in the code (we don't perform
-// the in-loop filtering), but filled from user's config
-typedef struct {
- int simple_; // filtering type: 0=complex, 1=simple
- int level_; // base filter level [0..63]
- int sharpness_; // [0..7]
- int i4x4_lf_delta_; // delta filter level for i4x4 relative to i16x16
-} VP8EncFilterHeader;
-
-//------------------------------------------------------------------------------
-// Informations about the macroblocks.
-
-typedef struct {
- // block type
- unsigned int type_:2; // 0=i4x4, 1=i16x16
- unsigned int uv_mode_:2;
- unsigned int skip_:1;
- unsigned int segment_:2;
- uint8_t alpha_; // quantization-susceptibility
-} VP8MBInfo;
-
-typedef struct VP8Matrix {
- uint16_t q_[16]; // quantizer steps
- uint16_t iq_[16]; // reciprocals, fixed point.
- uint32_t bias_[16]; // rounding bias
- uint32_t zthresh_[16]; // value below which a coefficient is zeroed
- uint16_t sharpen_[16]; // frequency boosters for slight sharpening
-} VP8Matrix;
-
-typedef struct {
- VP8Matrix y1_, y2_, uv_; // quantization matrices
- int alpha_; // quant-susceptibility, range [-127,127]. Zero is neutral.
- // Lower values indicate a lower risk of blurriness.
- int beta_; // filter-susceptibility, range [0,255].
- int quant_; // final segment quantizer.
- int fstrength_; // final in-loop filtering strength
- int max_edge_; // max edge delta (for filtering strength)
- int min_disto_; // minimum distortion required to trigger filtering record
- // reactivities
- int lambda_i16_, lambda_i4_, lambda_uv_;
- int lambda_mode_, lambda_trellis_, tlambda_;
- int lambda_trellis_i16_, lambda_trellis_i4_, lambda_trellis_uv_;
-
- // lambda values for distortion-based evaluation
- score_t i4_penalty_; // penalty for using Intra4
-} VP8SegmentInfo;
-
-typedef int8_t DError[2 /* u/v */][2 /* top or left */];
-
-// Handy transient struct to accumulate score and info during RD-optimization
-// and mode evaluation.
-typedef struct {
- score_t D, SD; // Distortion, spectral distortion
- score_t H, R, score; // header bits, rate, score.
- int16_t y_dc_levels[16]; // Quantized levels for luma-DC, luma-AC, chroma.
- int16_t y_ac_levels[16][16];
- int16_t uv_levels[4 + 4][16];
- int mode_i16; // mode number for intra16 prediction
- uint8_t modes_i4[16]; // mode numbers for intra4 predictions
- int mode_uv; // mode number of chroma prediction
- uint32_t nz; // non-zero blocks
- int8_t derr[2][3]; // DC diffusion errors for U/V for blocks #1/2/3
-} VP8ModeScore;
-
-// Iterator structure to iterate through macroblocks, pointing to the
-// right neighbouring data (samples, predictions, contexts, ...)
-typedef struct {
- int x_, y_; // current macroblock
- uint8_t* yuv_in_; // input samples
- uint8_t* yuv_out_; // output samples
- uint8_t* yuv_out2_; // secondary buffer swapped with yuv_out_.
- uint8_t* yuv_p_; // scratch buffer for prediction
- VP8Encoder* enc_; // back-pointer
- VP8MBInfo* mb_; // current macroblock
- VP8BitWriter* bw_; // current bit-writer
- uint8_t* preds_; // intra mode predictors (4x4 blocks)
- uint32_t* nz_; // non-zero pattern
- uint8_t i4_boundary_[37]; // 32+5 boundary samples needed by intra4x4
- uint8_t* i4_top_; // pointer to the current top boundary sample
- int i4_; // current intra4x4 mode being tested
- int top_nz_[9]; // top-non-zero context.
- int left_nz_[9]; // left-non-zero. left_nz[8] is independent.
- uint64_t bit_count_[4][3]; // bit counters for coded levels.
- uint64_t luma_bits_; // macroblock bit-cost for luma
- uint64_t uv_bits_; // macroblock bit-cost for chroma
- LFStats* lf_stats_; // filter stats (borrowed from enc_)
- int do_trellis_; // if true, perform extra level optimisation
- int count_down_; // number of mb still to be processed
- int count_down0_; // starting counter value (for progress)
- int percent0_; // saved initial progress percent
-
- DError left_derr_; // left error diffusion (u/v)
- DError* top_derr_; // top diffusion error - NULL if disabled
-
- uint8_t* y_left_; // left luma samples (addressable from index -1 to 15).
- uint8_t* u_left_; // left u samples (addressable from index -1 to 7)
- uint8_t* v_left_; // left v samples (addressable from index -1 to 7)
-
- uint8_t* y_top_; // top luma samples at position 'x_'
- uint8_t* uv_top_; // top u/v samples at position 'x_', packed as 16 bytes
-
- // memory for storing y/u/v_left_
- uint8_t yuv_left_mem_[17 + 16 + 16 + 8 + WEBP_ALIGN_CST];
- // memory for yuv_*
- uint8_t yuv_mem_[3 * YUV_SIZE_ENC + PRED_SIZE_ENC + WEBP_ALIGN_CST];
-} VP8EncIterator;
-
- // in iterator.c
-// must be called first
-void VP8IteratorInit(VP8Encoder* const enc, VP8EncIterator* const it);
-// restart a scan
-void VP8IteratorReset(VP8EncIterator* const it);
-// reset iterator position to row 'y'
-void VP8IteratorSetRow(VP8EncIterator* const it, int y);
-// set count down (=number of iterations to go)
-void VP8IteratorSetCountDown(VP8EncIterator* const it, int count_down);
-// return true if iteration is finished
-int VP8IteratorIsDone(const VP8EncIterator* const it);
-// Import uncompressed samples from source.
-// If tmp_32 is not NULL, import boundary samples too.
-// tmp_32 is a 32-bytes scratch buffer that must be aligned in memory.
-void VP8IteratorImport(VP8EncIterator* const it, uint8_t* const tmp_32);
-// export decimated samples
-void VP8IteratorExport(const VP8EncIterator* const it);
-// go to next macroblock. Returns false if not finished.
-int VP8IteratorNext(VP8EncIterator* const it);
-// save the yuv_out_ boundary values to top_/left_ arrays for next iterations.
-void VP8IteratorSaveBoundary(VP8EncIterator* const it);
-// Report progression based on macroblock rows. Return 0 for user-abort request.
-int VP8IteratorProgress(const VP8EncIterator* const it, int delta);
-// Intra4x4 iterations
-void VP8IteratorStartI4(VP8EncIterator* const it);
-// returns true if not done.
-int VP8IteratorRotateI4(VP8EncIterator* const it,
- const uint8_t* const yuv_out);
-
-// Non-zero context setup/teardown
-void VP8IteratorNzToBytes(VP8EncIterator* const it);
-void VP8IteratorBytesToNz(VP8EncIterator* const it);
-
-// Helper functions to set mode properties
-void VP8SetIntra16Mode(const VP8EncIterator* const it, int mode);
-void VP8SetIntra4Mode(const VP8EncIterator* const it, const uint8_t* modes);
-void VP8SetIntraUVMode(const VP8EncIterator* const it, int mode);
-void VP8SetSkip(const VP8EncIterator* const it, int skip);
-void VP8SetSegment(const VP8EncIterator* const it, int segment);
-
-//------------------------------------------------------------------------------
-// Paginated token buffer
-
-typedef struct VP8Tokens VP8Tokens; // struct details in token.c
-
-typedef struct {
-#if !defined(DISABLE_TOKEN_BUFFER)
- VP8Tokens* pages_; // first page
- VP8Tokens** last_page_; // last page
- uint16_t* tokens_; // set to (*last_page_)->tokens_
- int left_; // how many free tokens left before the page is full
- int page_size_; // number of tokens per page
-#endif
- int error_; // true in case of malloc error
-} VP8TBuffer;
-
-// initialize an empty buffer
-void VP8TBufferInit(VP8TBuffer* const b, int page_size);
-void VP8TBufferClear(VP8TBuffer* const b); // de-allocate pages memory
-
-#if !defined(DISABLE_TOKEN_BUFFER)
-
-// Finalizes bitstream when probabilities are known.
-// Deletes the allocated token memory if final_pass is true.
-int VP8EmitTokens(VP8TBuffer* const b, VP8BitWriter* const bw,
- const uint8_t* const probas, int final_pass);
-
-// record the coding of coefficients without knowing the probabilities yet
-int VP8RecordCoeffTokens(int ctx, const struct VP8Residual* const res,
- VP8TBuffer* const tokens);
-
-// Estimate the final coded size given a set of 'probas'.
-size_t VP8EstimateTokenSize(VP8TBuffer* const b, const uint8_t* const probas);
-
-#endif // !DISABLE_TOKEN_BUFFER
-
-//------------------------------------------------------------------------------
-// VP8Encoder
-
-struct VP8Encoder {
- const WebPConfig* config_; // user configuration and parameters
- WebPPicture* pic_; // input / output picture
-
- // headers
- VP8EncFilterHeader filter_hdr_; // filtering information
- VP8EncSegmentHeader segment_hdr_; // segment information
-
- int profile_; // VP8's profile, deduced from Config.
-
- // dimension, in macroblock units.
- int mb_w_, mb_h_;
- int preds_w_; // stride of the *preds_ prediction plane (=4*mb_w + 1)
-
- // number of partitions (1, 2, 4 or 8 = MAX_NUM_PARTITIONS)
- int num_parts_;
-
- // per-partition boolean decoders.
- VP8BitWriter bw_; // part0
- VP8BitWriter parts_[MAX_NUM_PARTITIONS]; // token partitions
- VP8TBuffer tokens_; // token buffer
-
- int percent_; // for progress
-
- // transparency blob
- int has_alpha_;
- uint8_t* alpha_data_; // non-NULL if transparency is present
- uint32_t alpha_data_size_;
- WebPWorker alpha_worker_;
-
- // quantization info (one set of DC/AC dequant factor per segment)
- VP8SegmentInfo dqm_[NUM_MB_SEGMENTS];
- int base_quant_; // nominal quantizer value. Only used
- // for relative coding of segments' quant.
- int alpha_; // global susceptibility (<=> complexity)
- int uv_alpha_; // U/V quantization susceptibility
- // global offset of quantizers, shared by all segments
- int dq_y1_dc_;
- int dq_y2_dc_, dq_y2_ac_;
- int dq_uv_dc_, dq_uv_ac_;
-
- // probabilities and statistics
- VP8EncProba proba_;
- uint64_t sse_[4]; // sum of Y/U/V/A squared errors for all macroblocks
- uint64_t sse_count_; // pixel count for the sse_[] stats
- int coded_size_;
- int residual_bytes_[3][4];
- int block_count_[3];
-
- // quality/speed settings
- int method_; // 0=fastest, 6=best/slowest.
- VP8RDLevel rd_opt_level_; // Deduced from method_.
- int max_i4_header_bits_; // partition #0 safeness factor
- int mb_header_limit_; // rough limit for header bits per MB
- int thread_level_; // derived from config->thread_level
- int do_search_; // derived from config->target_XXX
- int use_tokens_; // if true, use token buffer
-
- // Memory
- VP8MBInfo* mb_info_; // contextual macroblock infos (mb_w_ + 1)
- uint8_t* preds_; // predictions modes: (4*mb_w+1) * (4*mb_h+1)
- uint32_t* nz_; // non-zero bit context: mb_w+1
- uint8_t* y_top_; // top luma samples.
- uint8_t* uv_top_; // top u/v samples.
- // U and V are packed into 16 bytes (8 U + 8 V)
- LFStats* lf_stats_; // autofilter stats (if NULL, autofilter is off)
- DError* top_derr_; // diffusion error (NULL if disabled)
-};
-
-//------------------------------------------------------------------------------
-// internal functions. Not public.
-
- // in tree.c
-extern const uint8_t VP8CoeffsProba0[NUM_TYPES][NUM_BANDS][NUM_CTX][NUM_PROBAS];
-extern const uint8_t
- VP8CoeffsUpdateProba[NUM_TYPES][NUM_BANDS][NUM_CTX][NUM_PROBAS];
-// Reset the token probabilities to their initial (default) values
-void VP8DefaultProbas(VP8Encoder* const enc);
-// Write the token probabilities
-void VP8WriteProbas(VP8BitWriter* const bw, const VP8EncProba* const probas);
-// Writes the partition #0 modes (that is: all intra modes)
-void VP8CodeIntraModes(VP8Encoder* const enc);
-
- // in syntax.c
-// Generates the final bitstream by coding the partition0 and headers,
-// and appending an assembly of all the pre-coded token partitions.
-// Return true if everything is ok.
-int VP8EncWrite(VP8Encoder* const enc);
-// Release memory allocated for bit-writing in VP8EncLoop & seq.
-void VP8EncFreeBitWriters(VP8Encoder* const enc);
-
- // in frame.c
-extern const uint8_t VP8Cat3[];
-extern const uint8_t VP8Cat4[];
-extern const uint8_t VP8Cat5[];
-extern const uint8_t VP8Cat6[];
-
-// Form all the four Intra16x16 predictions in the yuv_p_ cache
-void VP8MakeLuma16Preds(const VP8EncIterator* const it);
-// Form all the four Chroma8x8 predictions in the yuv_p_ cache
-void VP8MakeChroma8Preds(const VP8EncIterator* const it);
-// Form all the ten Intra4x4 predictions in the yuv_p_ cache
-// for the 4x4 block it->i4_
-void VP8MakeIntra4Preds(const VP8EncIterator* const it);
-// Rate calculation
-int VP8GetCostLuma16(VP8EncIterator* const it, const VP8ModeScore* const rd);
-int VP8GetCostLuma4(VP8EncIterator* const it, const int16_t levels[16]);
-int VP8GetCostUV(VP8EncIterator* const it, const VP8ModeScore* const rd);
-// Main coding calls
-int VP8EncLoop(VP8Encoder* const enc);
-int VP8EncTokenLoop(VP8Encoder* const enc);
-
- // in webpenc.c
-// Assign an error code to a picture. Return false for convenience.
-int WebPEncodingSetError(const WebPPicture* const pic, WebPEncodingError error);
-int WebPReportProgress(const WebPPicture* const pic,
- int percent, int* const percent_store);
-
- // in analysis.c
-// Main analysis loop. Decides the segmentations and complexity.
-// Assigns a first guess for Intra16 and uvmode_ prediction modes.
-int VP8EncAnalyze(VP8Encoder* const enc);
-
- // in quant.c
-// Sets up segment's quantization values, base_quant_ and filter strengths.
-void VP8SetSegmentParams(VP8Encoder* const enc, float quality);
-// Pick best modes and fills the levels. Returns true if skipped.
-int VP8Decimate(VP8EncIterator* const it, VP8ModeScore* const rd,
- VP8RDLevel rd_opt);
-
- // in alpha.c
-void VP8EncInitAlpha(VP8Encoder* const enc); // initialize alpha compression
-int VP8EncStartAlpha(VP8Encoder* const enc); // start alpha coding process
-int VP8EncFinishAlpha(VP8Encoder* const enc); // finalize compressed data
-int VP8EncDeleteAlpha(VP8Encoder* const enc); // delete compressed data
-
-// autofilter
-void VP8InitFilter(VP8EncIterator* const it);
-void VP8StoreFilterStats(VP8EncIterator* const it);
-void VP8AdjustFilterStrength(VP8EncIterator* const it);
-
-// returns the approximate filtering strength needed to smooth a edge
-// step of 'delta', given a sharpness parameter 'sharpness'.
-int VP8FilterStrengthFromDelta(int sharpness, int delta);
-
- // misc utils for picture_*.c:
-
-// Remove reference to the ARGB/YUVA buffer (doesn't free anything).
-void WebPPictureResetBuffers(WebPPicture* const picture);
-
-// Allocates ARGB buffer of given dimension (previous one is always free'd).
-// Preserves the YUV(A) buffer. Returns false in case of error (invalid param,
-// out-of-memory).
-int WebPPictureAllocARGB(WebPPicture* const picture, int width, int height);
-
-// Allocates YUVA buffer of given dimension (previous one is always free'd).
-// Uses picture->csp to determine whether an alpha buffer is needed.
-// Preserves the ARGB buffer.
-// Returns false in case of error (invalid param, out-of-memory).
-int WebPPictureAllocYUVA(WebPPicture* const picture, int width, int height);
-
-// Replace samples that are fully transparent by 'color' to help compressibility
-// (no guarantee, though). Assumes pic->use_argb is true.
-void WebPReplaceTransparentPixels(WebPPicture* const pic, uint32_t color);
-
-//------------------------------------------------------------------------------
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // WEBP_ENC_VP8I_ENC_H_
diff --git a/contrib/libs/libwebp/enc/vp8l_enc.c b/contrib/libs/libwebp/enc/vp8l_enc.c
deleted file mode 100644
index 29104deb2d..0000000000
--- a/contrib/libs/libwebp/enc/vp8l_enc.c
+++ /dev/null
@@ -1,2138 +0,0 @@
-// Copyright 2012 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// main entry for the lossless encoder.
-//
-// Author: Vikas Arora (vikaas.arora@gmail.com)
-//
-
-#include <assert.h>
-#include <stdlib.h>
-
-#include "./backward_references_enc.h"
-#include "./histogram_enc.h"
-#include "./vp8i_enc.h"
-#include "./vp8li_enc.h"
-#include "../dsp/lossless.h"
-#include "../dsp/lossless_common.h"
-#include "../utils/bit_writer_utils.h"
-#include "../utils/huffman_encode_utils.h"
-#include "../utils/utils.h"
-#include "../webp/format_constants.h"
-
-// Maximum number of histogram images (sub-blocks).
-#define MAX_HUFF_IMAGE_SIZE 2600
-
-// Palette reordering for smaller sum of deltas (and for smaller storage).
-
-static int PaletteCompareColorsForQsort(const void* p1, const void* p2) {
- const uint32_t a = WebPMemToUint32((uint8_t*)p1);
- const uint32_t b = WebPMemToUint32((uint8_t*)p2);
- assert(a != b);
- return (a < b) ? -1 : 1;
-}
-
-static WEBP_INLINE uint32_t PaletteComponentDistance(uint32_t v) {
- return (v <= 128) ? v : (256 - v);
-}
-
-// Computes a value that is related to the entropy created by the
-// palette entry diff.
-//
-// Note that the last & 0xff is a no-operation in the next statement, but
-// removed by most compilers and is here only for regularity of the code.
-static WEBP_INLINE uint32_t PaletteColorDistance(uint32_t col1, uint32_t col2) {
- const uint32_t diff = VP8LSubPixels(col1, col2);
- const int kMoreWeightForRGBThanForAlpha = 9;
- uint32_t score;
- score = PaletteComponentDistance((diff >> 0) & 0xff);
- score += PaletteComponentDistance((diff >> 8) & 0xff);
- score += PaletteComponentDistance((diff >> 16) & 0xff);
- score *= kMoreWeightForRGBThanForAlpha;
- score += PaletteComponentDistance((diff >> 24) & 0xff);
- return score;
-}
-
-static WEBP_INLINE void SwapColor(uint32_t* const col1, uint32_t* const col2) {
- const uint32_t tmp = *col1;
- *col1 = *col2;
- *col2 = tmp;
-}
-
-static WEBP_INLINE int SearchColorNoIdx(const uint32_t sorted[], uint32_t color,
- int num_colors) {
- int low = 0, hi = num_colors;
- if (sorted[low] == color) return low; // loop invariant: sorted[low] != color
- while (1) {
- const int mid = (low + hi) >> 1;
- if (sorted[mid] == color) {
- return mid;
- } else if (sorted[mid] < color) {
- low = mid;
- } else {
- hi = mid;
- }
- }
- assert(0);
- return 0;
-}
-
-// The palette has been sorted by alpha. This function checks if the other
-// components of the palette have a monotonic development with regards to
-// position in the palette. If all have monotonic development, there is
-// no benefit to re-organize them greedily. A monotonic development
-// would be spotted in green-only situations (like lossy alpha) or gray-scale
-// images.
-static int PaletteHasNonMonotonousDeltas(const uint32_t* const palette,
- int num_colors) {
- uint32_t predict = 0x000000;
- int i;
- uint8_t sign_found = 0x00;
- for (i = 0; i < num_colors; ++i) {
- const uint32_t diff = VP8LSubPixels(palette[i], predict);
- const uint8_t rd = (diff >> 16) & 0xff;
- const uint8_t gd = (diff >> 8) & 0xff;
- const uint8_t bd = (diff >> 0) & 0xff;
- if (rd != 0x00) {
- sign_found |= (rd < 0x80) ? 1 : 2;
- }
- if (gd != 0x00) {
- sign_found |= (gd < 0x80) ? 8 : 16;
- }
- if (bd != 0x00) {
- sign_found |= (bd < 0x80) ? 64 : 128;
- }
- predict = palette[i];
- }
- return (sign_found & (sign_found << 1)) != 0; // two consequent signs.
-}
-
-static void PaletteSortMinimizeDeltas(const uint32_t* const palette_sorted,
- int num_colors, uint32_t* const palette) {
- uint32_t predict = 0x00000000;
- int i, k;
- memcpy(palette, palette_sorted, num_colors * sizeof(*palette));
- if (!PaletteHasNonMonotonousDeltas(palette_sorted, num_colors)) return;
- // Find greedily always the closest color of the predicted color to minimize
- // deltas in the palette. This reduces storage needs since the
- // palette is stored with delta encoding.
- for (i = 0; i < num_colors; ++i) {
- int best_ix = i;
- uint32_t best_score = ~0U;
- for (k = i; k < num_colors; ++k) {
- const uint32_t cur_score = PaletteColorDistance(palette[k], predict);
- if (best_score > cur_score) {
- best_score = cur_score;
- best_ix = k;
- }
- }
- SwapColor(&palette[best_ix], &palette[i]);
- predict = palette[i];
- }
-}
-
-// Sort palette in increasing order and prepare an inverse mapping array.
-static void PrepareMapToPalette(const uint32_t palette[], uint32_t num_colors,
- uint32_t sorted[], uint32_t idx_map[]) {
- uint32_t i;
- memcpy(sorted, palette, num_colors * sizeof(*sorted));
- qsort(sorted, num_colors, sizeof(*sorted), PaletteCompareColorsForQsort);
- for (i = 0; i < num_colors; ++i) {
- idx_map[SearchColorNoIdx(sorted, palette[i], num_colors)] = i;
- }
-}
-
-// -----------------------------------------------------------------------------
-// Modified Zeng method from "A Survey on Palette Reordering
-// Methods for Improving the Compression of Color-Indexed Images" by Armando J.
-// Pinho and Antonio J. R. Neves.
-
-// Finds the biggest cooccurrence in the matrix.
-static void CoOccurrenceFindMax(const uint32_t* const cooccurrence,
- uint32_t num_colors, uint8_t* const c1,
- uint8_t* const c2) {
- // Find the index that is most frequently located adjacent to other
- // (different) indexes.
- uint32_t best_sum = 0u;
- uint32_t i, j, best_cooccurrence;
- *c1 = 0u;
- for (i = 0; i < num_colors; ++i) {
- uint32_t sum = 0;
- for (j = 0; j < num_colors; ++j) sum += cooccurrence[i * num_colors + j];
- if (sum > best_sum) {
- best_sum = sum;
- *c1 = i;
- }
- }
- // Find the index that is most frequently found adjacent to *c1.
- *c2 = 0u;
- best_cooccurrence = 0u;
- for (i = 0; i < num_colors; ++i) {
- if (cooccurrence[*c1 * num_colors + i] > best_cooccurrence) {
- best_cooccurrence = cooccurrence[*c1 * num_colors + i];
- *c2 = i;
- }
- }
- assert(*c1 != *c2);
-}
-
-// Builds the cooccurrence matrix
-static WebPEncodingError CoOccurrenceBuild(const WebPPicture* const pic,
- const uint32_t* const palette,
- uint32_t num_colors,
- uint32_t* cooccurrence) {
- uint32_t *lines, *line_top, *line_current, *line_tmp;
- int x, y;
- const uint32_t* src = pic->argb;
- uint32_t prev_pix = ~src[0];
- uint32_t prev_idx = 0u;
- uint32_t idx_map[MAX_PALETTE_SIZE] = {0};
- uint32_t palette_sorted[MAX_PALETTE_SIZE];
- lines = (uint32_t*)WebPSafeMalloc(2 * pic->width, sizeof(*lines));
- if (lines == NULL) return VP8_ENC_ERROR_OUT_OF_MEMORY;
- line_top = &lines[0];
- line_current = &lines[pic->width];
- PrepareMapToPalette(palette, num_colors, palette_sorted, idx_map);
- for (y = 0; y < pic->height; ++y) {
- for (x = 0; x < pic->width; ++x) {
- const uint32_t pix = src[x];
- if (pix != prev_pix) {
- prev_idx = idx_map[SearchColorNoIdx(palette_sorted, pix, num_colors)];
- prev_pix = pix;
- }
- line_current[x] = prev_idx;
- // 4-connectivity is what works best as mentioned in "On the relation
- // between Memon's and the modified Zeng's palette reordering methods".
- if (x > 0 && prev_idx != line_current[x - 1]) {
- const uint32_t left_idx = line_current[x - 1];
- ++cooccurrence[prev_idx * num_colors + left_idx];
- ++cooccurrence[left_idx * num_colors + prev_idx];
- }
- if (y > 0 && prev_idx != line_top[x]) {
- const uint32_t top_idx = line_top[x];
- ++cooccurrence[prev_idx * num_colors + top_idx];
- ++cooccurrence[top_idx * num_colors + prev_idx];
- }
- }
- line_tmp = line_top;
- line_top = line_current;
- line_current = line_tmp;
- src += pic->argb_stride;
- }
- WebPSafeFree(lines);
- return VP8_ENC_OK;
-}
-
-struct Sum {
- uint8_t index;
- uint32_t sum;
-};
-
-// Implements the modified Zeng method from "A Survey on Palette Reordering
-// Methods for Improving the Compression of Color-Indexed Images" by Armando J.
-// Pinho and Antonio J. R. Neves.
-static WebPEncodingError PaletteSortModifiedZeng(
- const WebPPicture* const pic, const uint32_t* const palette_sorted,
- uint32_t num_colors, uint32_t* const palette) {
- uint32_t i, j, ind;
- uint8_t remapping[MAX_PALETTE_SIZE];
- uint32_t* cooccurrence;
- struct Sum sums[MAX_PALETTE_SIZE];
- uint32_t first, last;
- uint32_t num_sums;
- // TODO(vrabaud) check whether one color images should use palette or not.
- if (num_colors <= 1) return VP8_ENC_OK;
- // Build the co-occurrence matrix.
- cooccurrence =
- (uint32_t*)WebPSafeCalloc(num_colors * num_colors, sizeof(*cooccurrence));
- if (cooccurrence == NULL) return VP8_ENC_ERROR_OUT_OF_MEMORY;
- if (CoOccurrenceBuild(pic, palette_sorted, num_colors, cooccurrence) !=
- VP8_ENC_OK) {
- WebPSafeFree(cooccurrence);
- return VP8_ENC_ERROR_OUT_OF_MEMORY;
- }
-
- // Initialize the mapping list with the two best indices.
- CoOccurrenceFindMax(cooccurrence, num_colors, &remapping[0], &remapping[1]);
-
- // We need to append and prepend to the list of remapping. To this end, we
- // actually define the next start/end of the list as indices in a vector (with
- // a wrap around when the end is reached).
- first = 0;
- last = 1;
- num_sums = num_colors - 2; // -2 because we know the first two values
- if (num_sums > 0) {
- // Initialize the sums with the first two remappings and find the best one
- struct Sum* best_sum = &sums[0];
- best_sum->index = 0u;
- best_sum->sum = 0u;
- for (i = 0, j = 0; i < num_colors; ++i) {
- if (i == remapping[0] || i == remapping[1]) continue;
- sums[j].index = i;
- sums[j].sum = cooccurrence[i * num_colors + remapping[0]] +
- cooccurrence[i * num_colors + remapping[1]];
- if (sums[j].sum > best_sum->sum) best_sum = &sums[j];
- ++j;
- }
-
- while (num_sums > 0) {
- const uint8_t best_index = best_sum->index;
- // Compute delta to know if we need to prepend or append the best index.
- int32_t delta = 0;
- const int32_t n = num_colors - num_sums;
- for (ind = first, j = 0; (ind + j) % num_colors != last + 1; ++j) {
- const uint16_t l_j = remapping[(ind + j) % num_colors];
- delta += (n - 1 - 2 * (int32_t)j) *
- (int32_t)cooccurrence[best_index * num_colors + l_j];
- }
- if (delta > 0) {
- first = (first == 0) ? num_colors - 1 : first - 1;
- remapping[first] = best_index;
- } else {
- ++last;
- remapping[last] = best_index;
- }
- // Remove best_sum from sums.
- *best_sum = sums[num_sums - 1];
- --num_sums;
- // Update all the sums and find the best one.
- best_sum = &sums[0];
- for (i = 0; i < num_sums; ++i) {
- sums[i].sum += cooccurrence[best_index * num_colors + sums[i].index];
- if (sums[i].sum > best_sum->sum) best_sum = &sums[i];
- }
- }
- }
- assert((last + 1) % num_colors == first);
- WebPSafeFree(cooccurrence);
-
- // Re-map the palette.
- for (i = 0; i < num_colors; ++i) {
- palette[i] = palette_sorted[remapping[(first + i) % num_colors]];
- }
- return VP8_ENC_OK;
-}
-
-// -----------------------------------------------------------------------------
-// Palette
-
-// These five modes are evaluated and their respective entropy is computed.
-typedef enum {
- kDirect = 0,
- kSpatial = 1,
- kSubGreen = 2,
- kSpatialSubGreen = 3,
- kPalette = 4,
- kPaletteAndSpatial = 5,
- kNumEntropyIx = 6
-} EntropyIx;
-
-typedef enum {
- kSortedDefault = 0,
- kMinimizeDelta = 1,
- kModifiedZeng = 2,
- kUnusedPalette = 3,
-} PaletteSorting;
-
-typedef enum {
- kHistoAlpha = 0,
- kHistoAlphaPred,
- kHistoGreen,
- kHistoGreenPred,
- kHistoRed,
- kHistoRedPred,
- kHistoBlue,
- kHistoBluePred,
- kHistoRedSubGreen,
- kHistoRedPredSubGreen,
- kHistoBlueSubGreen,
- kHistoBluePredSubGreen,
- kHistoPalette,
- kHistoTotal // Must be last.
-} HistoIx;
-
-static void AddSingleSubGreen(int p, uint32_t* const r, uint32_t* const b) {
- const int green = p >> 8; // The upper bits are masked away later.
- ++r[((p >> 16) - green) & 0xff];
- ++b[((p >> 0) - green) & 0xff];
-}
-
-static void AddSingle(uint32_t p,
- uint32_t* const a, uint32_t* const r,
- uint32_t* const g, uint32_t* const b) {
- ++a[(p >> 24) & 0xff];
- ++r[(p >> 16) & 0xff];
- ++g[(p >> 8) & 0xff];
- ++b[(p >> 0) & 0xff];
-}
-
-static WEBP_INLINE uint32_t HashPix(uint32_t pix) {
- // Note that masking with 0xffffffffu is for preventing an
- // 'unsigned int overflow' warning. Doesn't impact the compiled code.
- return ((((uint64_t)pix + (pix >> 19)) * 0x39c5fba7ull) & 0xffffffffu) >> 24;
-}
-
-static int AnalyzeEntropy(const uint32_t* argb,
- int width, int height, int argb_stride,
- int use_palette,
- int palette_size, int transform_bits,
- EntropyIx* const min_entropy_ix,
- int* const red_and_blue_always_zero) {
- // Allocate histogram set with cache_bits = 0.
- uint32_t* histo;
-
- if (use_palette && palette_size <= 16) {
- // In the case of small palettes, we pack 2, 4 or 8 pixels together. In
- // practice, small palettes are better than any other transform.
- *min_entropy_ix = kPalette;
- *red_and_blue_always_zero = 1;
- return 1;
- }
- histo = (uint32_t*)WebPSafeCalloc(kHistoTotal, sizeof(*histo) * 256);
- if (histo != NULL) {
- int i, x, y;
- const uint32_t* prev_row = NULL;
- const uint32_t* curr_row = argb;
- uint32_t pix_prev = argb[0]; // Skip the first pixel.
- for (y = 0; y < height; ++y) {
- for (x = 0; x < width; ++x) {
- const uint32_t pix = curr_row[x];
- const uint32_t pix_diff = VP8LSubPixels(pix, pix_prev);
- pix_prev = pix;
- if ((pix_diff == 0) || (prev_row != NULL && pix == prev_row[x])) {
- continue;
- }
- AddSingle(pix,
- &histo[kHistoAlpha * 256],
- &histo[kHistoRed * 256],
- &histo[kHistoGreen * 256],
- &histo[kHistoBlue * 256]);
- AddSingle(pix_diff,
- &histo[kHistoAlphaPred * 256],
- &histo[kHistoRedPred * 256],
- &histo[kHistoGreenPred * 256],
- &histo[kHistoBluePred * 256]);
- AddSingleSubGreen(pix,
- &histo[kHistoRedSubGreen * 256],
- &histo[kHistoBlueSubGreen * 256]);
- AddSingleSubGreen(pix_diff,
- &histo[kHistoRedPredSubGreen * 256],
- &histo[kHistoBluePredSubGreen * 256]);
- {
- // Approximate the palette by the entropy of the multiplicative hash.
- const uint32_t hash = HashPix(pix);
- ++histo[kHistoPalette * 256 + hash];
- }
- }
- prev_row = curr_row;
- curr_row += argb_stride;
- }
- {
- double entropy_comp[kHistoTotal];
- double entropy[kNumEntropyIx];
- int k;
- int last_mode_to_analyze = use_palette ? kPalette : kSpatialSubGreen;
- int j;
- // Let's add one zero to the predicted histograms. The zeros are removed
- // too efficiently by the pix_diff == 0 comparison, at least one of the
- // zeros is likely to exist.
- ++histo[kHistoRedPredSubGreen * 256];
- ++histo[kHistoBluePredSubGreen * 256];
- ++histo[kHistoRedPred * 256];
- ++histo[kHistoGreenPred * 256];
- ++histo[kHistoBluePred * 256];
- ++histo[kHistoAlphaPred * 256];
-
- for (j = 0; j < kHistoTotal; ++j) {
- entropy_comp[j] = VP8LBitsEntropy(&histo[j * 256], 256);
- }
- entropy[kDirect] = entropy_comp[kHistoAlpha] +
- entropy_comp[kHistoRed] +
- entropy_comp[kHistoGreen] +
- entropy_comp[kHistoBlue];
- entropy[kSpatial] = entropy_comp[kHistoAlphaPred] +
- entropy_comp[kHistoRedPred] +
- entropy_comp[kHistoGreenPred] +
- entropy_comp[kHistoBluePred];
- entropy[kSubGreen] = entropy_comp[kHistoAlpha] +
- entropy_comp[kHistoRedSubGreen] +
- entropy_comp[kHistoGreen] +
- entropy_comp[kHistoBlueSubGreen];
- entropy[kSpatialSubGreen] = entropy_comp[kHistoAlphaPred] +
- entropy_comp[kHistoRedPredSubGreen] +
- entropy_comp[kHistoGreenPred] +
- entropy_comp[kHistoBluePredSubGreen];
- entropy[kPalette] = entropy_comp[kHistoPalette];
-
- // When including transforms, there is an overhead in bits from
- // storing them. This overhead is small but matters for small images.
- // For spatial, there are 14 transformations.
- entropy[kSpatial] += VP8LSubSampleSize(width, transform_bits) *
- VP8LSubSampleSize(height, transform_bits) *
- VP8LFastLog2(14);
- // For color transforms: 24 as only 3 channels are considered in a
- // ColorTransformElement.
- entropy[kSpatialSubGreen] += VP8LSubSampleSize(width, transform_bits) *
- VP8LSubSampleSize(height, transform_bits) *
- VP8LFastLog2(24);
- // For palettes, add the cost of storing the palette.
- // We empirically estimate the cost of a compressed entry as 8 bits.
- // The palette is differential-coded when compressed hence a much
- // lower cost than sizeof(uint32_t)*8.
- entropy[kPalette] += palette_size * 8;
-
- *min_entropy_ix = kDirect;
- for (k = kDirect + 1; k <= last_mode_to_analyze; ++k) {
- if (entropy[*min_entropy_ix] > entropy[k]) {
- *min_entropy_ix = (EntropyIx)k;
- }
- }
- assert((int)*min_entropy_ix <= last_mode_to_analyze);
- *red_and_blue_always_zero = 1;
- // Let's check if the histogram of the chosen entropy mode has
- // non-zero red and blue values. If all are zero, we can later skip
- // the cross color optimization.
- {
- static const uint8_t kHistoPairs[5][2] = {
- { kHistoRed, kHistoBlue },
- { kHistoRedPred, kHistoBluePred },
- { kHistoRedSubGreen, kHistoBlueSubGreen },
- { kHistoRedPredSubGreen, kHistoBluePredSubGreen },
- { kHistoRed, kHistoBlue }
- };
- const uint32_t* const red_histo =
- &histo[256 * kHistoPairs[*min_entropy_ix][0]];
- const uint32_t* const blue_histo =
- &histo[256 * kHistoPairs[*min_entropy_ix][1]];
- for (i = 1; i < 256; ++i) {
- if ((red_histo[i] | blue_histo[i]) != 0) {
- *red_and_blue_always_zero = 0;
- break;
- }
- }
- }
- }
- WebPSafeFree(histo);
- return 1;
- } else {
- return 0;
- }
-}
-
-static int GetHistoBits(int method, int use_palette, int width, int height) {
- // Make tile size a function of encoding method (Range: 0 to 6).
- int histo_bits = (use_palette ? 9 : 7) - method;
- while (1) {
- const int huff_image_size = VP8LSubSampleSize(width, histo_bits) *
- VP8LSubSampleSize(height, histo_bits);
- if (huff_image_size <= MAX_HUFF_IMAGE_SIZE) break;
- ++histo_bits;
- }
- return (histo_bits < MIN_HUFFMAN_BITS) ? MIN_HUFFMAN_BITS :
- (histo_bits > MAX_HUFFMAN_BITS) ? MAX_HUFFMAN_BITS : histo_bits;
-}
-
-static int GetTransformBits(int method, int histo_bits) {
- const int max_transform_bits = (method < 4) ? 6 : (method > 4) ? 4 : 5;
- const int res =
- (histo_bits > max_transform_bits) ? max_transform_bits : histo_bits;
- assert(res <= MAX_TRANSFORM_BITS);
- return res;
-}
-
-// Set of parameters to be used in each iteration of the cruncher.
-#define CRUNCH_SUBCONFIGS_MAX 2
-typedef struct {
- int lz77_;
- int do_no_cache_;
-} CrunchSubConfig;
-typedef struct {
- int entropy_idx_;
- PaletteSorting palette_sorting_type_;
- CrunchSubConfig sub_configs_[CRUNCH_SUBCONFIGS_MAX];
- int sub_configs_size_;
-} CrunchConfig;
-
-// +2 because we add a palette sorting configuration for kPalette and
-// kPaletteAndSpatial.
-#define CRUNCH_CONFIGS_MAX (kNumEntropyIx + 2)
-
-static int EncoderAnalyze(VP8LEncoder* const enc,
- CrunchConfig crunch_configs[CRUNCH_CONFIGS_MAX],
- int* const crunch_configs_size,
- int* const red_and_blue_always_zero) {
- const WebPPicture* const pic = enc->pic_;
- const int width = pic->width;
- const int height = pic->height;
- const WebPConfig* const config = enc->config_;
- const int method = config->method;
- const int low_effort = (config->method == 0);
- int i;
- int use_palette;
- int n_lz77s;
- // If set to 0, analyze the cache with the computed cache value. If 1, also
- // analyze with no-cache.
- int do_no_cache = 0;
- assert(pic != NULL && pic->argb != NULL);
-
- // Check whether a palette is possible.
- enc->palette_size_ = WebPGetColorPalette(pic, enc->palette_sorted_);
- use_palette = (enc->palette_size_ <= MAX_PALETTE_SIZE);
- if (!use_palette) {
- enc->palette_size_ = 0;
- } else {
- qsort(enc->palette_sorted_, enc->palette_size_,
- sizeof(*enc->palette_sorted_), PaletteCompareColorsForQsort);
- }
-
- // Empirical bit sizes.
- enc->histo_bits_ = GetHistoBits(method, use_palette,
- pic->width, pic->height);
- enc->transform_bits_ = GetTransformBits(method, enc->histo_bits_);
-
- if (low_effort) {
- // AnalyzeEntropy is somewhat slow.
- crunch_configs[0].entropy_idx_ = use_palette ? kPalette : kSpatialSubGreen;
- crunch_configs[0].palette_sorting_type_ =
- use_palette ? kSortedDefault : kUnusedPalette;
- n_lz77s = 1;
- *crunch_configs_size = 1;
- } else {
- EntropyIx min_entropy_ix;
- // Try out multiple LZ77 on images with few colors.
- n_lz77s = (enc->palette_size_ > 0 && enc->palette_size_ <= 16) ? 2 : 1;
- if (!AnalyzeEntropy(pic->argb, width, height, pic->argb_stride, use_palette,
- enc->palette_size_, enc->transform_bits_,
- &min_entropy_ix, red_and_blue_always_zero)) {
- return 0;
- }
- if (method == 6 && config->quality == 100) {
- do_no_cache = 1;
- // Go brute force on all transforms.
- *crunch_configs_size = 0;
- for (i = 0; i < kNumEntropyIx; ++i) {
- // We can only apply kPalette or kPaletteAndSpatial if we can indeed use
- // a palette.
- if ((i != kPalette && i != kPaletteAndSpatial) || use_palette) {
- assert(*crunch_configs_size < CRUNCH_CONFIGS_MAX);
- crunch_configs[(*crunch_configs_size)].entropy_idx_ = i;
- if (use_palette && (i == kPalette || i == kPaletteAndSpatial)) {
- crunch_configs[(*crunch_configs_size)].palette_sorting_type_ =
- kMinimizeDelta;
- ++*crunch_configs_size;
- // Also add modified Zeng's method.
- crunch_configs[(*crunch_configs_size)].entropy_idx_ = i;
- crunch_configs[(*crunch_configs_size)].palette_sorting_type_ =
- kModifiedZeng;
- } else {
- crunch_configs[(*crunch_configs_size)].palette_sorting_type_ =
- kUnusedPalette;
- }
- ++*crunch_configs_size;
- }
- }
- } else {
- // Only choose the guessed best transform.
- *crunch_configs_size = 1;
- crunch_configs[0].entropy_idx_ = min_entropy_ix;
- crunch_configs[0].palette_sorting_type_ =
- use_palette ? kMinimizeDelta : kUnusedPalette;
- if (config->quality >= 75 && method == 5) {
- // Test with and without color cache.
- do_no_cache = 1;
- // If we have a palette, also check in combination with spatial.
- if (min_entropy_ix == kPalette) {
- *crunch_configs_size = 2;
- crunch_configs[1].entropy_idx_ = kPaletteAndSpatial;
- crunch_configs[1].palette_sorting_type_ = kMinimizeDelta;
- }
- }
- }
- }
- // Fill in the different LZ77s.
- assert(n_lz77s <= CRUNCH_SUBCONFIGS_MAX);
- for (i = 0; i < *crunch_configs_size; ++i) {
- int j;
- for (j = 0; j < n_lz77s; ++j) {
- assert(j < CRUNCH_SUBCONFIGS_MAX);
- crunch_configs[i].sub_configs_[j].lz77_ =
- (j == 0) ? kLZ77Standard | kLZ77RLE : kLZ77Box;
- crunch_configs[i].sub_configs_[j].do_no_cache_ = do_no_cache;
- }
- crunch_configs[i].sub_configs_size_ = n_lz77s;
- }
- return 1;
-}
-
-static int EncoderInit(VP8LEncoder* const enc) {
- const WebPPicture* const pic = enc->pic_;
- const int width = pic->width;
- const int height = pic->height;
- const int pix_cnt = width * height;
- // we round the block size up, so we're guaranteed to have
- // at most MAX_REFS_BLOCK_PER_IMAGE blocks used:
- const int refs_block_size = (pix_cnt - 1) / MAX_REFS_BLOCK_PER_IMAGE + 1;
- int i;
- if (!VP8LHashChainInit(&enc->hash_chain_, pix_cnt)) return 0;
-
- for (i = 0; i < 4; ++i) VP8LBackwardRefsInit(&enc->refs_[i], refs_block_size);
-
- return 1;
-}
-
-// Returns false in case of memory error.
-static int GetHuffBitLengthsAndCodes(
- const VP8LHistogramSet* const histogram_image,
- HuffmanTreeCode* const huffman_codes) {
- int i, k;
- int ok = 0;
- uint64_t total_length_size = 0;
- uint8_t* mem_buf = NULL;
- const int histogram_image_size = histogram_image->size;
- int max_num_symbols = 0;
- uint8_t* buf_rle = NULL;
- HuffmanTree* huff_tree = NULL;
-
- // Iterate over all histograms and get the aggregate number of codes used.
- for (i = 0; i < histogram_image_size; ++i) {
- const VP8LHistogram* const histo = histogram_image->histograms[i];
- HuffmanTreeCode* const codes = &huffman_codes[5 * i];
- assert(histo != NULL);
- for (k = 0; k < 5; ++k) {
- const int num_symbols =
- (k == 0) ? VP8LHistogramNumCodes(histo->palette_code_bits_) :
- (k == 4) ? NUM_DISTANCE_CODES : 256;
- codes[k].num_symbols = num_symbols;
- total_length_size += num_symbols;
- }
- }
-
- // Allocate and Set Huffman codes.
- {
- uint16_t* codes;
- uint8_t* lengths;
- mem_buf = (uint8_t*)WebPSafeCalloc(total_length_size,
- sizeof(*lengths) + sizeof(*codes));
- if (mem_buf == NULL) goto End;
-
- codes = (uint16_t*)mem_buf;
- lengths = (uint8_t*)&codes[total_length_size];
- for (i = 0; i < 5 * histogram_image_size; ++i) {
- const int bit_length = huffman_codes[i].num_symbols;
- huffman_codes[i].codes = codes;
- huffman_codes[i].code_lengths = lengths;
- codes += bit_length;
- lengths += bit_length;
- if (max_num_symbols < bit_length) {
- max_num_symbols = bit_length;
- }
- }
- }
-
- buf_rle = (uint8_t*)WebPSafeMalloc(1ULL, max_num_symbols);
- huff_tree = (HuffmanTree*)WebPSafeMalloc(3ULL * max_num_symbols,
- sizeof(*huff_tree));
- if (buf_rle == NULL || huff_tree == NULL) goto End;
-
- // Create Huffman trees.
- for (i = 0; i < histogram_image_size; ++i) {
- HuffmanTreeCode* const codes = &huffman_codes[5 * i];
- VP8LHistogram* const histo = histogram_image->histograms[i];
- VP8LCreateHuffmanTree(histo->literal_, 15, buf_rle, huff_tree, codes + 0);
- VP8LCreateHuffmanTree(histo->red_, 15, buf_rle, huff_tree, codes + 1);
- VP8LCreateHuffmanTree(histo->blue_, 15, buf_rle, huff_tree, codes + 2);
- VP8LCreateHuffmanTree(histo->alpha_, 15, buf_rle, huff_tree, codes + 3);
- VP8LCreateHuffmanTree(histo->distance_, 15, buf_rle, huff_tree, codes + 4);
- }
- ok = 1;
- End:
- WebPSafeFree(huff_tree);
- WebPSafeFree(buf_rle);
- if (!ok) {
- WebPSafeFree(mem_buf);
- memset(huffman_codes, 0, 5 * histogram_image_size * sizeof(*huffman_codes));
- }
- return ok;
-}
-
-static void StoreHuffmanTreeOfHuffmanTreeToBitMask(
- VP8LBitWriter* const bw, const uint8_t* code_length_bitdepth) {
- // RFC 1951 will calm you down if you are worried about this funny sequence.
- // This sequence is tuned from that, but more weighted for lower symbol count,
- // and more spiking histograms.
- static const uint8_t kStorageOrder[CODE_LENGTH_CODES] = {
- 17, 18, 0, 1, 2, 3, 4, 5, 16, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
- };
- int i;
- // Throw away trailing zeros:
- int codes_to_store = CODE_LENGTH_CODES;
- for (; codes_to_store > 4; --codes_to_store) {
- if (code_length_bitdepth[kStorageOrder[codes_to_store - 1]] != 0) {
- break;
- }
- }
- VP8LPutBits(bw, codes_to_store - 4, 4);
- for (i = 0; i < codes_to_store; ++i) {
- VP8LPutBits(bw, code_length_bitdepth[kStorageOrder[i]], 3);
- }
-}
-
-static void ClearHuffmanTreeIfOnlyOneSymbol(
- HuffmanTreeCode* const huffman_code) {
- int k;
- int count = 0;
- for (k = 0; k < huffman_code->num_symbols; ++k) {
- if (huffman_code->code_lengths[k] != 0) {
- ++count;
- if (count > 1) return;
- }
- }
- for (k = 0; k < huffman_code->num_symbols; ++k) {
- huffman_code->code_lengths[k] = 0;
- huffman_code->codes[k] = 0;
- }
-}
-
-static void StoreHuffmanTreeToBitMask(
- VP8LBitWriter* const bw,
- const HuffmanTreeToken* const tokens, const int num_tokens,
- const HuffmanTreeCode* const huffman_code) {
- int i;
- for (i = 0; i < num_tokens; ++i) {
- const int ix = tokens[i].code;
- const int extra_bits = tokens[i].extra_bits;
- VP8LPutBits(bw, huffman_code->codes[ix], huffman_code->code_lengths[ix]);
- switch (ix) {
- case 16:
- VP8LPutBits(bw, extra_bits, 2);
- break;
- case 17:
- VP8LPutBits(bw, extra_bits, 3);
- break;
- case 18:
- VP8LPutBits(bw, extra_bits, 7);
- break;
- }
- }
-}
-
-// 'huff_tree' and 'tokens' are pre-alloacted buffers.
-static void StoreFullHuffmanCode(VP8LBitWriter* const bw,
- HuffmanTree* const huff_tree,
- HuffmanTreeToken* const tokens,
- const HuffmanTreeCode* const tree) {
- uint8_t code_length_bitdepth[CODE_LENGTH_CODES] = { 0 };
- uint16_t code_length_bitdepth_symbols[CODE_LENGTH_CODES] = { 0 };
- const int max_tokens = tree->num_symbols;
- int num_tokens;
- HuffmanTreeCode huffman_code;
- huffman_code.num_symbols = CODE_LENGTH_CODES;
- huffman_code.code_lengths = code_length_bitdepth;
- huffman_code.codes = code_length_bitdepth_symbols;
-
- VP8LPutBits(bw, 0, 1);
- num_tokens = VP8LCreateCompressedHuffmanTree(tree, tokens, max_tokens);
- {
- uint32_t histogram[CODE_LENGTH_CODES] = { 0 };
- uint8_t buf_rle[CODE_LENGTH_CODES] = { 0 };
- int i;
- for (i = 0; i < num_tokens; ++i) {
- ++histogram[tokens[i].code];
- }
-
- VP8LCreateHuffmanTree(histogram, 7, buf_rle, huff_tree, &huffman_code);
- }
-
- StoreHuffmanTreeOfHuffmanTreeToBitMask(bw, code_length_bitdepth);
- ClearHuffmanTreeIfOnlyOneSymbol(&huffman_code);
- {
- int trailing_zero_bits = 0;
- int trimmed_length = num_tokens;
- int write_trimmed_length;
- int length;
- int i = num_tokens;
- while (i-- > 0) {
- const int ix = tokens[i].code;
- if (ix == 0 || ix == 17 || ix == 18) {
- --trimmed_length; // discount trailing zeros
- trailing_zero_bits += code_length_bitdepth[ix];
- if (ix == 17) {
- trailing_zero_bits += 3;
- } else if (ix == 18) {
- trailing_zero_bits += 7;
- }
- } else {
- break;
- }
- }
- write_trimmed_length = (trimmed_length > 1 && trailing_zero_bits > 12);
- length = write_trimmed_length ? trimmed_length : num_tokens;
- VP8LPutBits(bw, write_trimmed_length, 1);
- if (write_trimmed_length) {
- if (trimmed_length == 2) {
- VP8LPutBits(bw, 0, 3 + 2); // nbitpairs=1, trimmed_length=2
- } else {
- const int nbits = BitsLog2Floor(trimmed_length - 2);
- const int nbitpairs = nbits / 2 + 1;
- assert(trimmed_length > 2);
- assert(nbitpairs - 1 < 8);
- VP8LPutBits(bw, nbitpairs - 1, 3);
- VP8LPutBits(bw, trimmed_length - 2, nbitpairs * 2);
- }
- }
- StoreHuffmanTreeToBitMask(bw, tokens, length, &huffman_code);
- }
-}
-
-// 'huff_tree' and 'tokens' are pre-alloacted buffers.
-static void StoreHuffmanCode(VP8LBitWriter* const bw,
- HuffmanTree* const huff_tree,
- HuffmanTreeToken* const tokens,
- const HuffmanTreeCode* const huffman_code) {
- int i;
- int count = 0;
- int symbols[2] = { 0, 0 };
- const int kMaxBits = 8;
- const int kMaxSymbol = 1 << kMaxBits;
-
- // Check whether it's a small tree.
- for (i = 0; i < huffman_code->num_symbols && count < 3; ++i) {
- if (huffman_code->code_lengths[i] != 0) {
- if (count < 2) symbols[count] = i;
- ++count;
- }
- }
-
- if (count == 0) { // emit minimal tree for empty cases
- // bits: small tree marker: 1, count-1: 0, large 8-bit code: 0, code: 0
- VP8LPutBits(bw, 0x01, 4);
- } else if (count <= 2 && symbols[0] < kMaxSymbol && symbols[1] < kMaxSymbol) {
- VP8LPutBits(bw, 1, 1); // Small tree marker to encode 1 or 2 symbols.
- VP8LPutBits(bw, count - 1, 1);
- if (symbols[0] <= 1) {
- VP8LPutBits(bw, 0, 1); // Code bit for small (1 bit) symbol value.
- VP8LPutBits(bw, symbols[0], 1);
- } else {
- VP8LPutBits(bw, 1, 1);
- VP8LPutBits(bw, symbols[0], 8);
- }
- if (count == 2) {
- VP8LPutBits(bw, symbols[1], 8);
- }
- } else {
- StoreFullHuffmanCode(bw, huff_tree, tokens, huffman_code);
- }
-}
-
-static WEBP_INLINE void WriteHuffmanCode(VP8LBitWriter* const bw,
- const HuffmanTreeCode* const code,
- int code_index) {
- const int depth = code->code_lengths[code_index];
- const int symbol = code->codes[code_index];
- VP8LPutBits(bw, symbol, depth);
-}
-
-static WEBP_INLINE void WriteHuffmanCodeWithExtraBits(
- VP8LBitWriter* const bw,
- const HuffmanTreeCode* const code,
- int code_index,
- int bits,
- int n_bits) {
- const int depth = code->code_lengths[code_index];
- const int symbol = code->codes[code_index];
- VP8LPutBits(bw, (bits << depth) | symbol, depth + n_bits);
-}
-
-static WebPEncodingError StoreImageToBitMask(
- VP8LBitWriter* const bw, int width, int histo_bits,
- const VP8LBackwardRefs* const refs,
- const uint16_t* histogram_symbols,
- const HuffmanTreeCode* const huffman_codes) {
- const int histo_xsize = histo_bits ? VP8LSubSampleSize(width, histo_bits) : 1;
- const int tile_mask = (histo_bits == 0) ? 0 : -(1 << histo_bits);
- // x and y trace the position in the image.
- int x = 0;
- int y = 0;
- int tile_x = x & tile_mask;
- int tile_y = y & tile_mask;
- int histogram_ix = histogram_symbols[0];
- const HuffmanTreeCode* codes = huffman_codes + 5 * histogram_ix;
- VP8LRefsCursor c = VP8LRefsCursorInit(refs);
- while (VP8LRefsCursorOk(&c)) {
- const PixOrCopy* const v = c.cur_pos;
- if ((tile_x != (x & tile_mask)) || (tile_y != (y & tile_mask))) {
- tile_x = x & tile_mask;
- tile_y = y & tile_mask;
- histogram_ix = histogram_symbols[(y >> histo_bits) * histo_xsize +
- (x >> histo_bits)];
- codes = huffman_codes + 5 * histogram_ix;
- }
- if (PixOrCopyIsLiteral(v)) {
- static const uint8_t order[] = { 1, 2, 0, 3 };
- int k;
- for (k = 0; k < 4; ++k) {
- const int code = PixOrCopyLiteral(v, order[k]);
- WriteHuffmanCode(bw, codes + k, code);
- }
- } else if (PixOrCopyIsCacheIdx(v)) {
- const int code = PixOrCopyCacheIdx(v);
- const int literal_ix = 256 + NUM_LENGTH_CODES + code;
- WriteHuffmanCode(bw, codes, literal_ix);
- } else {
- int bits, n_bits;
- int code;
-
- const int distance = PixOrCopyDistance(v);
- VP8LPrefixEncode(v->len, &code, &n_bits, &bits);
- WriteHuffmanCodeWithExtraBits(bw, codes, 256 + code, bits, n_bits);
-
- // Don't write the distance with the extra bits code since
- // the distance can be up to 18 bits of extra bits, and the prefix
- // 15 bits, totaling to 33, and our PutBits only supports up to 32 bits.
- VP8LPrefixEncode(distance, &code, &n_bits, &bits);
- WriteHuffmanCode(bw, codes + 4, code);
- VP8LPutBits(bw, bits, n_bits);
- }
- x += PixOrCopyLength(v);
- while (x >= width) {
- x -= width;
- ++y;
- }
- VP8LRefsCursorNext(&c);
- }
- return bw->error_ ? VP8_ENC_ERROR_OUT_OF_MEMORY : VP8_ENC_OK;
-}
-
-// Special case of EncodeImageInternal() for cache-bits=0, histo_bits=31
-static WebPEncodingError EncodeImageNoHuffman(
- VP8LBitWriter* const bw, const uint32_t* const argb,
- VP8LHashChain* const hash_chain, VP8LBackwardRefs* const refs_array,
- int width, int height, int quality, int low_effort) {
- int i;
- int max_tokens = 0;
- WebPEncodingError err = VP8_ENC_OK;
- VP8LBackwardRefs* refs;
- HuffmanTreeToken* tokens = NULL;
- HuffmanTreeCode huffman_codes[5] = { { 0, NULL, NULL } };
- const uint16_t histogram_symbols[1] = { 0 }; // only one tree, one symbol
- int cache_bits = 0;
- VP8LHistogramSet* histogram_image = NULL;
- HuffmanTree* const huff_tree = (HuffmanTree*)WebPSafeMalloc(
- 3ULL * CODE_LENGTH_CODES, sizeof(*huff_tree));
- if (huff_tree == NULL) {
- err = VP8_ENC_ERROR_OUT_OF_MEMORY;
- goto Error;
- }
-
- // Calculate backward references from ARGB image.
- if (!VP8LHashChainFill(hash_chain, quality, argb, width, height,
- low_effort)) {
- err = VP8_ENC_ERROR_OUT_OF_MEMORY;
- goto Error;
- }
- err = VP8LGetBackwardReferences(
- width, height, argb, quality, /*low_effort=*/0, kLZ77Standard | kLZ77RLE,
- cache_bits, /*do_no_cache=*/0, hash_chain, refs_array, &cache_bits);
- if (err != VP8_ENC_OK) goto Error;
- refs = &refs_array[0];
- histogram_image = VP8LAllocateHistogramSet(1, cache_bits);
- if (histogram_image == NULL) {
- err = VP8_ENC_ERROR_OUT_OF_MEMORY;
- goto Error;
- }
- VP8LHistogramSetClear(histogram_image);
-
- // Build histogram image and symbols from backward references.
- VP8LHistogramStoreRefs(refs, histogram_image->histograms[0]);
-
- // Create Huffman bit lengths and codes for each histogram image.
- assert(histogram_image->size == 1);
- if (!GetHuffBitLengthsAndCodes(histogram_image, huffman_codes)) {
- err = VP8_ENC_ERROR_OUT_OF_MEMORY;
- goto Error;
- }
-
- // No color cache, no Huffman image.
- VP8LPutBits(bw, 0, 1);
-
- // Find maximum number of symbols for the huffman tree-set.
- for (i = 0; i < 5; ++i) {
- HuffmanTreeCode* const codes = &huffman_codes[i];
- if (max_tokens < codes->num_symbols) {
- max_tokens = codes->num_symbols;
- }
- }
-
- tokens = (HuffmanTreeToken*)WebPSafeMalloc(max_tokens, sizeof(*tokens));
- if (tokens == NULL) {
- err = VP8_ENC_ERROR_OUT_OF_MEMORY;
- goto Error;
- }
-
- // Store Huffman codes.
- for (i = 0; i < 5; ++i) {
- HuffmanTreeCode* const codes = &huffman_codes[i];
- StoreHuffmanCode(bw, huff_tree, tokens, codes);
- ClearHuffmanTreeIfOnlyOneSymbol(codes);
- }
-
- // Store actual literals.
- err = StoreImageToBitMask(bw, width, 0, refs, histogram_symbols,
- huffman_codes);
-
- Error:
- WebPSafeFree(tokens);
- WebPSafeFree(huff_tree);
- VP8LFreeHistogramSet(histogram_image);
- WebPSafeFree(huffman_codes[0].codes);
- return err;
-}
-
-static WebPEncodingError EncodeImageInternal(
- VP8LBitWriter* const bw, const uint32_t* const argb,
- VP8LHashChain* const hash_chain, VP8LBackwardRefs refs_array[4], int width,
- int height, int quality, int low_effort, int use_cache,
- const CrunchConfig* const config, int* cache_bits, int histogram_bits,
- size_t init_byte_position, int* const hdr_size, int* const data_size) {
- WebPEncodingError err = VP8_ENC_ERROR_OUT_OF_MEMORY;
- const uint32_t histogram_image_xysize =
- VP8LSubSampleSize(width, histogram_bits) *
- VP8LSubSampleSize(height, histogram_bits);
- VP8LHistogramSet* histogram_image = NULL;
- VP8LHistogram* tmp_histo = NULL;
- int histogram_image_size = 0;
- size_t bit_array_size = 0;
- HuffmanTree* const huff_tree = (HuffmanTree*)WebPSafeMalloc(
- 3ULL * CODE_LENGTH_CODES, sizeof(*huff_tree));
- HuffmanTreeToken* tokens = NULL;
- HuffmanTreeCode* huffman_codes = NULL;
- uint16_t* const histogram_symbols =
- (uint16_t*)WebPSafeMalloc(histogram_image_xysize,
- sizeof(*histogram_symbols));
- int sub_configs_idx;
- int cache_bits_init, write_histogram_image;
- VP8LBitWriter bw_init = *bw, bw_best;
- int hdr_size_tmp;
- VP8LHashChain hash_chain_histogram; // histogram image hash chain
- size_t bw_size_best = ~(size_t)0;
- assert(histogram_bits >= MIN_HUFFMAN_BITS);
- assert(histogram_bits <= MAX_HUFFMAN_BITS);
- assert(hdr_size != NULL);
- assert(data_size != NULL);
-
- // Make sure we can allocate the different objects.
- memset(&hash_chain_histogram, 0, sizeof(hash_chain_histogram));
- if (huff_tree == NULL || histogram_symbols == NULL ||
- !VP8LHashChainInit(&hash_chain_histogram, histogram_image_xysize) ||
- !VP8LHashChainFill(hash_chain, quality, argb, width, height,
- low_effort)) {
- goto Error;
- }
- if (use_cache) {
- // If the value is different from zero, it has been set during the
- // palette analysis.
- cache_bits_init = (*cache_bits == 0) ? MAX_COLOR_CACHE_BITS : *cache_bits;
- } else {
- cache_bits_init = 0;
- }
- // If several iterations will happen, clone into bw_best.
- if (!VP8LBitWriterInit(&bw_best, 0) ||
- ((config->sub_configs_size_ > 1 ||
- config->sub_configs_[0].do_no_cache_) &&
- !VP8LBitWriterClone(bw, &bw_best))) {
- goto Error;
- }
- for (sub_configs_idx = 0; sub_configs_idx < config->sub_configs_size_;
- ++sub_configs_idx) {
- const CrunchSubConfig* const sub_config =
- &config->sub_configs_[sub_configs_idx];
- int cache_bits_best, i_cache;
- err = VP8LGetBackwardReferences(width, height, argb, quality, low_effort,
- sub_config->lz77_, cache_bits_init,
- sub_config->do_no_cache_, hash_chain,
- &refs_array[0], &cache_bits_best);
- if (err != VP8_ENC_OK) goto Error;
-
- for (i_cache = 0; i_cache < (sub_config->do_no_cache_ ? 2 : 1); ++i_cache) {
- const int cache_bits_tmp = (i_cache == 0) ? cache_bits_best : 0;
- // Speed-up: no need to study the no-cache case if it was already studied
- // in i_cache == 0.
- if (i_cache == 1 && cache_bits_best == 0) break;
-
- // Reset the bit writer for this iteration.
- VP8LBitWriterReset(&bw_init, bw);
-
- // Build histogram image and symbols from backward references.
- histogram_image =
- VP8LAllocateHistogramSet(histogram_image_xysize, cache_bits_tmp);
- tmp_histo = VP8LAllocateHistogram(cache_bits_tmp);
- if (histogram_image == NULL || tmp_histo == NULL ||
- !VP8LGetHistoImageSymbols(width, height, &refs_array[i_cache],
- quality, low_effort, histogram_bits,
- cache_bits_tmp, histogram_image, tmp_histo,
- histogram_symbols)) {
- goto Error;
- }
- // Create Huffman bit lengths and codes for each histogram image.
- histogram_image_size = histogram_image->size;
- bit_array_size = 5 * histogram_image_size;
- huffman_codes = (HuffmanTreeCode*)WebPSafeCalloc(bit_array_size,
- sizeof(*huffman_codes));
- // Note: some histogram_image entries may point to tmp_histos[], so the
- // latter need to outlive the following call to
- // GetHuffBitLengthsAndCodes().
- if (huffman_codes == NULL ||
- !GetHuffBitLengthsAndCodes(histogram_image, huffman_codes)) {
- goto Error;
- }
- // Free combined histograms.
- VP8LFreeHistogramSet(histogram_image);
- histogram_image = NULL;
-
- // Free scratch histograms.
- VP8LFreeHistogram(tmp_histo);
- tmp_histo = NULL;
-
- // Color Cache parameters.
- if (cache_bits_tmp > 0) {
- VP8LPutBits(bw, 1, 1);
- VP8LPutBits(bw, cache_bits_tmp, 4);
- } else {
- VP8LPutBits(bw, 0, 1);
- }
-
- // Huffman image + meta huffman.
- write_histogram_image = (histogram_image_size > 1);
- VP8LPutBits(bw, write_histogram_image, 1);
- if (write_histogram_image) {
- uint32_t* const histogram_argb =
- (uint32_t*)WebPSafeMalloc(histogram_image_xysize,
- sizeof(*histogram_argb));
- int max_index = 0;
- uint32_t i;
- if (histogram_argb == NULL) goto Error;
- for (i = 0; i < histogram_image_xysize; ++i) {
- const int symbol_index = histogram_symbols[i] & 0xffff;
- histogram_argb[i] = (symbol_index << 8);
- if (symbol_index >= max_index) {
- max_index = symbol_index + 1;
- }
- }
- histogram_image_size = max_index;
-
- VP8LPutBits(bw, histogram_bits - 2, 3);
- err = EncodeImageNoHuffman(
- bw, histogram_argb, &hash_chain_histogram, &refs_array[2],
- VP8LSubSampleSize(width, histogram_bits),
- VP8LSubSampleSize(height, histogram_bits), quality, low_effort);
- WebPSafeFree(histogram_argb);
- if (err != VP8_ENC_OK) goto Error;
- }
-
- // Store Huffman codes.
- {
- int i;
- int max_tokens = 0;
- // Find maximum number of symbols for the huffman tree-set.
- for (i = 0; i < 5 * histogram_image_size; ++i) {
- HuffmanTreeCode* const codes = &huffman_codes[i];
- if (max_tokens < codes->num_symbols) {
- max_tokens = codes->num_symbols;
- }
- }
- tokens = (HuffmanTreeToken*)WebPSafeMalloc(max_tokens, sizeof(*tokens));
- if (tokens == NULL) goto Error;
- for (i = 0; i < 5 * histogram_image_size; ++i) {
- HuffmanTreeCode* const codes = &huffman_codes[i];
- StoreHuffmanCode(bw, huff_tree, tokens, codes);
- ClearHuffmanTreeIfOnlyOneSymbol(codes);
- }
- }
- // Store actual literals.
- hdr_size_tmp = (int)(VP8LBitWriterNumBytes(bw) - init_byte_position);
- err = StoreImageToBitMask(bw, width, histogram_bits, &refs_array[i_cache],
- histogram_symbols, huffman_codes);
- if (err != VP8_ENC_OK) goto Error;
- // Keep track of the smallest image so far.
- if (VP8LBitWriterNumBytes(bw) < bw_size_best) {
- bw_size_best = VP8LBitWriterNumBytes(bw);
- *cache_bits = cache_bits_tmp;
- *hdr_size = hdr_size_tmp;
- *data_size =
- (int)(VP8LBitWriterNumBytes(bw) - init_byte_position - *hdr_size);
- VP8LBitWriterSwap(bw, &bw_best);
- }
- WebPSafeFree(tokens);
- tokens = NULL;
- if (huffman_codes != NULL) {
- WebPSafeFree(huffman_codes->codes);
- WebPSafeFree(huffman_codes);
- huffman_codes = NULL;
- }
- }
- }
- VP8LBitWriterSwap(bw, &bw_best);
- err = VP8_ENC_OK;
-
- Error:
- WebPSafeFree(tokens);
- WebPSafeFree(huff_tree);
- VP8LFreeHistogramSet(histogram_image);
- VP8LFreeHistogram(tmp_histo);
- VP8LHashChainClear(&hash_chain_histogram);
- if (huffman_codes != NULL) {
- WebPSafeFree(huffman_codes->codes);
- WebPSafeFree(huffman_codes);
- }
- WebPSafeFree(histogram_symbols);
- VP8LBitWriterWipeOut(&bw_best);
- return err;
-}
-
-// -----------------------------------------------------------------------------
-// Transforms
-
-static void ApplySubtractGreen(VP8LEncoder* const enc, int width, int height,
- VP8LBitWriter* const bw) {
- VP8LPutBits(bw, TRANSFORM_PRESENT, 1);
- VP8LPutBits(bw, SUBTRACT_GREEN, 2);
- VP8LSubtractGreenFromBlueAndRed(enc->argb_, width * height);
-}
-
-static WebPEncodingError ApplyPredictFilter(const VP8LEncoder* const enc,
- int width, int height,
- int quality, int low_effort,
- int used_subtract_green,
- VP8LBitWriter* const bw) {
- const int pred_bits = enc->transform_bits_;
- const int transform_width = VP8LSubSampleSize(width, pred_bits);
- const int transform_height = VP8LSubSampleSize(height, pred_bits);
- // we disable near-lossless quantization if palette is used.
- const int near_lossless_strength = enc->use_palette_ ? 100
- : enc->config_->near_lossless;
-
- VP8LResidualImage(width, height, pred_bits, low_effort, enc->argb_,
- enc->argb_scratch_, enc->transform_data_,
- near_lossless_strength, enc->config_->exact,
- used_subtract_green);
- VP8LPutBits(bw, TRANSFORM_PRESENT, 1);
- VP8LPutBits(bw, PREDICTOR_TRANSFORM, 2);
- assert(pred_bits >= 2);
- VP8LPutBits(bw, pred_bits - 2, 3);
- return EncodeImageNoHuffman(
- bw, enc->transform_data_, (VP8LHashChain*)&enc->hash_chain_,
- (VP8LBackwardRefs*)&enc->refs_[0], transform_width, transform_height,
- quality, low_effort);
-}
-
-static WebPEncodingError ApplyCrossColorFilter(const VP8LEncoder* const enc,
- int width, int height,
- int quality, int low_effort,
- VP8LBitWriter* const bw) {
- const int ccolor_transform_bits = enc->transform_bits_;
- const int transform_width = VP8LSubSampleSize(width, ccolor_transform_bits);
- const int transform_height = VP8LSubSampleSize(height, ccolor_transform_bits);
-
- VP8LColorSpaceTransform(width, height, ccolor_transform_bits, quality,
- enc->argb_, enc->transform_data_);
- VP8LPutBits(bw, TRANSFORM_PRESENT, 1);
- VP8LPutBits(bw, CROSS_COLOR_TRANSFORM, 2);
- assert(ccolor_transform_bits >= 2);
- VP8LPutBits(bw, ccolor_transform_bits - 2, 3);
- return EncodeImageNoHuffman(
- bw, enc->transform_data_, (VP8LHashChain*)&enc->hash_chain_,
- (VP8LBackwardRefs*)&enc->refs_[0], transform_width, transform_height,
- quality, low_effort);
-}
-
-// -----------------------------------------------------------------------------
-
-static WebPEncodingError WriteRiffHeader(const WebPPicture* const pic,
- size_t riff_size, size_t vp8l_size) {
- uint8_t riff[RIFF_HEADER_SIZE + CHUNK_HEADER_SIZE + VP8L_SIGNATURE_SIZE] = {
- 'R', 'I', 'F', 'F', 0, 0, 0, 0, 'W', 'E', 'B', 'P',
- 'V', 'P', '8', 'L', 0, 0, 0, 0, VP8L_MAGIC_BYTE,
- };
- PutLE32(riff + TAG_SIZE, (uint32_t)riff_size);
- PutLE32(riff + RIFF_HEADER_SIZE + TAG_SIZE, (uint32_t)vp8l_size);
- if (!pic->writer(riff, sizeof(riff), pic)) {
- return VP8_ENC_ERROR_BAD_WRITE;
- }
- return VP8_ENC_OK;
-}
-
-static int WriteImageSize(const WebPPicture* const pic,
- VP8LBitWriter* const bw) {
- const int width = pic->width - 1;
- const int height = pic->height - 1;
- assert(width < WEBP_MAX_DIMENSION && height < WEBP_MAX_DIMENSION);
-
- VP8LPutBits(bw, width, VP8L_IMAGE_SIZE_BITS);
- VP8LPutBits(bw, height, VP8L_IMAGE_SIZE_BITS);
- return !bw->error_;
-}
-
-static int WriteRealAlphaAndVersion(VP8LBitWriter* const bw, int has_alpha) {
- VP8LPutBits(bw, has_alpha, 1);
- VP8LPutBits(bw, VP8L_VERSION, VP8L_VERSION_BITS);
- return !bw->error_;
-}
-
-static WebPEncodingError WriteImage(const WebPPicture* const pic,
- VP8LBitWriter* const bw,
- size_t* const coded_size) {
- WebPEncodingError err = VP8_ENC_OK;
- const uint8_t* const webpll_data = VP8LBitWriterFinish(bw);
- const size_t webpll_size = VP8LBitWriterNumBytes(bw);
- const size_t vp8l_size = VP8L_SIGNATURE_SIZE + webpll_size;
- const size_t pad = vp8l_size & 1;
- const size_t riff_size = TAG_SIZE + CHUNK_HEADER_SIZE + vp8l_size + pad;
-
- err = WriteRiffHeader(pic, riff_size, vp8l_size);
- if (err != VP8_ENC_OK) goto Error;
-
- if (!pic->writer(webpll_data, webpll_size, pic)) {
- err = VP8_ENC_ERROR_BAD_WRITE;
- goto Error;
- }
-
- if (pad) {
- const uint8_t pad_byte[1] = { 0 };
- if (!pic->writer(pad_byte, 1, pic)) {
- err = VP8_ENC_ERROR_BAD_WRITE;
- goto Error;
- }
- }
- *coded_size = CHUNK_HEADER_SIZE + riff_size;
- return VP8_ENC_OK;
-
- Error:
- return err;
-}
-
-// -----------------------------------------------------------------------------
-
-static void ClearTransformBuffer(VP8LEncoder* const enc) {
- WebPSafeFree(enc->transform_mem_);
- enc->transform_mem_ = NULL;
- enc->transform_mem_size_ = 0;
-}
-
-// Allocates the memory for argb (W x H) buffer, 2 rows of context for
-// prediction and transform data.
-// Flags influencing the memory allocated:
-// enc->transform_bits_
-// enc->use_predict_, enc->use_cross_color_
-static WebPEncodingError AllocateTransformBuffer(VP8LEncoder* const enc,
- int width, int height) {
- WebPEncodingError err = VP8_ENC_OK;
- const uint64_t image_size = width * height;
- // VP8LResidualImage needs room for 2 scanlines of uint32 pixels with an extra
- // pixel in each, plus 2 regular scanlines of bytes.
- // TODO(skal): Clean up by using arithmetic in bytes instead of words.
- const uint64_t argb_scratch_size =
- enc->use_predict_
- ? (width + 1) * 2 +
- (width * 2 + sizeof(uint32_t) - 1) / sizeof(uint32_t)
- : 0;
- const uint64_t transform_data_size =
- (enc->use_predict_ || enc->use_cross_color_)
- ? VP8LSubSampleSize(width, enc->transform_bits_) *
- VP8LSubSampleSize(height, enc->transform_bits_)
- : 0;
- const uint64_t max_alignment_in_words =
- (WEBP_ALIGN_CST + sizeof(uint32_t) - 1) / sizeof(uint32_t);
- const uint64_t mem_size =
- image_size + max_alignment_in_words +
- argb_scratch_size + max_alignment_in_words +
- transform_data_size;
- uint32_t* mem = enc->transform_mem_;
- if (mem == NULL || mem_size > enc->transform_mem_size_) {
- ClearTransformBuffer(enc);
- mem = (uint32_t*)WebPSafeMalloc(mem_size, sizeof(*mem));
- if (mem == NULL) {
- err = VP8_ENC_ERROR_OUT_OF_MEMORY;
- goto Error;
- }
- enc->transform_mem_ = mem;
- enc->transform_mem_size_ = (size_t)mem_size;
- enc->argb_content_ = kEncoderNone;
- }
- enc->argb_ = mem;
- mem = (uint32_t*)WEBP_ALIGN(mem + image_size);
- enc->argb_scratch_ = mem;
- mem = (uint32_t*)WEBP_ALIGN(mem + argb_scratch_size);
- enc->transform_data_ = mem;
-
- enc->current_width_ = width;
- Error:
- return err;
-}
-
-static WebPEncodingError MakeInputImageCopy(VP8LEncoder* const enc) {
- WebPEncodingError err = VP8_ENC_OK;
- const WebPPicture* const picture = enc->pic_;
- const int width = picture->width;
- const int height = picture->height;
-
- err = AllocateTransformBuffer(enc, width, height);
- if (err != VP8_ENC_OK) return err;
- if (enc->argb_content_ == kEncoderARGB) return VP8_ENC_OK;
-
- {
- uint32_t* dst = enc->argb_;
- const uint32_t* src = picture->argb;
- int y;
- for (y = 0; y < height; ++y) {
- memcpy(dst, src, width * sizeof(*dst));
- dst += width;
- src += picture->argb_stride;
- }
- }
- enc->argb_content_ = kEncoderARGB;
- assert(enc->current_width_ == width);
- return VP8_ENC_OK;
-}
-
-// -----------------------------------------------------------------------------
-
-#define APPLY_PALETTE_GREEDY_MAX 4
-
-static WEBP_INLINE uint32_t SearchColorGreedy(const uint32_t palette[],
- int palette_size,
- uint32_t color) {
- (void)palette_size;
- assert(palette_size < APPLY_PALETTE_GREEDY_MAX);
- assert(3 == APPLY_PALETTE_GREEDY_MAX - 1);
- if (color == palette[0]) return 0;
- if (color == palette[1]) return 1;
- if (color == palette[2]) return 2;
- return 3;
-}
-
-static WEBP_INLINE uint32_t ApplyPaletteHash0(uint32_t color) {
- // Focus on the green color.
- return (color >> 8) & 0xff;
-}
-
-#define PALETTE_INV_SIZE_BITS 11
-#define PALETTE_INV_SIZE (1 << PALETTE_INV_SIZE_BITS)
-
-static WEBP_INLINE uint32_t ApplyPaletteHash1(uint32_t color) {
- // Forget about alpha.
- return ((uint32_t)((color & 0x00ffffffu) * 4222244071ull)) >>
- (32 - PALETTE_INV_SIZE_BITS);
-}
-
-static WEBP_INLINE uint32_t ApplyPaletteHash2(uint32_t color) {
- // Forget about alpha.
- return ((uint32_t)((color & 0x00ffffffu) * ((1ull << 31) - 1))) >>
- (32 - PALETTE_INV_SIZE_BITS);
-}
-
-// Use 1 pixel cache for ARGB pixels.
-#define APPLY_PALETTE_FOR(COLOR_INDEX) do { \
- uint32_t prev_pix = palette[0]; \
- uint32_t prev_idx = 0; \
- for (y = 0; y < height; ++y) { \
- for (x = 0; x < width; ++x) { \
- const uint32_t pix = src[x]; \
- if (pix != prev_pix) { \
- prev_idx = COLOR_INDEX; \
- prev_pix = pix; \
- } \
- tmp_row[x] = prev_idx; \
- } \
- VP8LBundleColorMap(tmp_row, width, xbits, dst); \
- src += src_stride; \
- dst += dst_stride; \
- } \
-} while (0)
-
-// Remap argb values in src[] to packed palettes entries in dst[]
-// using 'row' as a temporary buffer of size 'width'.
-// We assume that all src[] values have a corresponding entry in the palette.
-// Note: src[] can be the same as dst[]
-static WebPEncodingError ApplyPalette(const uint32_t* src, uint32_t src_stride,
- uint32_t* dst, uint32_t dst_stride,
- const uint32_t* palette, int palette_size,
- int width, int height, int xbits) {
- // TODO(skal): this tmp buffer is not needed if VP8LBundleColorMap() can be
- // made to work in-place.
- uint8_t* const tmp_row = (uint8_t*)WebPSafeMalloc(width, sizeof(*tmp_row));
- int x, y;
-
- if (tmp_row == NULL) return VP8_ENC_ERROR_OUT_OF_MEMORY;
-
- if (palette_size < APPLY_PALETTE_GREEDY_MAX) {
- APPLY_PALETTE_FOR(SearchColorGreedy(palette, palette_size, pix));
- } else {
- int i, j;
- uint16_t buffer[PALETTE_INV_SIZE];
- uint32_t (*const hash_functions[])(uint32_t) = {
- ApplyPaletteHash0, ApplyPaletteHash1, ApplyPaletteHash2
- };
-
- // Try to find a perfect hash function able to go from a color to an index
- // within 1 << PALETTE_INV_SIZE_BITS in order to build a hash map to go
- // from color to index in palette.
- for (i = 0; i < 3; ++i) {
- int use_LUT = 1;
- // Set each element in buffer to max uint16_t.
- memset(buffer, 0xff, sizeof(buffer));
- for (j = 0; j < palette_size; ++j) {
- const uint32_t ind = hash_functions[i](palette[j]);
- if (buffer[ind] != 0xffffu) {
- use_LUT = 0;
- break;
- } else {
- buffer[ind] = j;
- }
- }
- if (use_LUT) break;
- }
-
- if (i == 0) {
- APPLY_PALETTE_FOR(buffer[ApplyPaletteHash0(pix)]);
- } else if (i == 1) {
- APPLY_PALETTE_FOR(buffer[ApplyPaletteHash1(pix)]);
- } else if (i == 2) {
- APPLY_PALETTE_FOR(buffer[ApplyPaletteHash2(pix)]);
- } else {
- uint32_t idx_map[MAX_PALETTE_SIZE];
- uint32_t palette_sorted[MAX_PALETTE_SIZE];
- PrepareMapToPalette(palette, palette_size, palette_sorted, idx_map);
- APPLY_PALETTE_FOR(
- idx_map[SearchColorNoIdx(palette_sorted, pix, palette_size)]);
- }
- }
- WebPSafeFree(tmp_row);
- return VP8_ENC_OK;
-}
-#undef APPLY_PALETTE_FOR
-#undef PALETTE_INV_SIZE_BITS
-#undef PALETTE_INV_SIZE
-#undef APPLY_PALETTE_GREEDY_MAX
-
-// Note: Expects "enc->palette_" to be set properly.
-static WebPEncodingError MapImageFromPalette(VP8LEncoder* const enc,
- int in_place) {
- WebPEncodingError err = VP8_ENC_OK;
- const WebPPicture* const pic = enc->pic_;
- const int width = pic->width;
- const int height = pic->height;
- const uint32_t* const palette = enc->palette_;
- const uint32_t* src = in_place ? enc->argb_ : pic->argb;
- const int src_stride = in_place ? enc->current_width_ : pic->argb_stride;
- const int palette_size = enc->palette_size_;
- int xbits;
-
- // Replace each input pixel by corresponding palette index.
- // This is done line by line.
- if (palette_size <= 4) {
- xbits = (palette_size <= 2) ? 3 : 2;
- } else {
- xbits = (palette_size <= 16) ? 1 : 0;
- }
-
- err = AllocateTransformBuffer(enc, VP8LSubSampleSize(width, xbits), height);
- if (err != VP8_ENC_OK) return err;
-
- err = ApplyPalette(src, src_stride,
- enc->argb_, enc->current_width_,
- palette, palette_size, width, height, xbits);
- enc->argb_content_ = kEncoderPalette;
- return err;
-}
-
-// Save palette_[] to bitstream.
-static WebPEncodingError EncodePalette(VP8LBitWriter* const bw, int low_effort,
- VP8LEncoder* const enc) {
- int i;
- uint32_t tmp_palette[MAX_PALETTE_SIZE];
- const int palette_size = enc->palette_size_;
- const uint32_t* const palette = enc->palette_;
- VP8LPutBits(bw, TRANSFORM_PRESENT, 1);
- VP8LPutBits(bw, COLOR_INDEXING_TRANSFORM, 2);
- assert(palette_size >= 1 && palette_size <= MAX_PALETTE_SIZE);
- VP8LPutBits(bw, palette_size - 1, 8);
- for (i = palette_size - 1; i >= 1; --i) {
- tmp_palette[i] = VP8LSubPixels(palette[i], palette[i - 1]);
- }
- tmp_palette[0] = palette[0];
- return EncodeImageNoHuffman(bw, tmp_palette, &enc->hash_chain_,
- &enc->refs_[0], palette_size, 1, /*quality=*/20,
- low_effort);
-}
-
-// -----------------------------------------------------------------------------
-// VP8LEncoder
-
-static VP8LEncoder* VP8LEncoderNew(const WebPConfig* const config,
- const WebPPicture* const picture) {
- VP8LEncoder* const enc = (VP8LEncoder*)WebPSafeCalloc(1ULL, sizeof(*enc));
- if (enc == NULL) {
- WebPEncodingSetError(picture, VP8_ENC_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
- enc->config_ = config;
- enc->pic_ = picture;
- enc->argb_content_ = kEncoderNone;
-
- VP8LEncDspInit();
-
- return enc;
-}
-
-static void VP8LEncoderDelete(VP8LEncoder* enc) {
- if (enc != NULL) {
- int i;
- VP8LHashChainClear(&enc->hash_chain_);
- for (i = 0; i < 4; ++i) VP8LBackwardRefsClear(&enc->refs_[i]);
- ClearTransformBuffer(enc);
- WebPSafeFree(enc);
- }
-}
-
-// -----------------------------------------------------------------------------
-// Main call
-
-typedef struct {
- const WebPConfig* config_;
- const WebPPicture* picture_;
- VP8LBitWriter* bw_;
- VP8LEncoder* enc_;
- int use_cache_;
- CrunchConfig crunch_configs_[CRUNCH_CONFIGS_MAX];
- int num_crunch_configs_;
- int red_and_blue_always_zero_;
- WebPEncodingError err_;
- WebPAuxStats* stats_;
-} StreamEncodeContext;
-
-static int EncodeStreamHook(void* input, void* data2) {
- StreamEncodeContext* const params = (StreamEncodeContext*)input;
- const WebPConfig* const config = params->config_;
- const WebPPicture* const picture = params->picture_;
- VP8LBitWriter* const bw = params->bw_;
- VP8LEncoder* const enc = params->enc_;
- const int use_cache = params->use_cache_;
- const CrunchConfig* const crunch_configs = params->crunch_configs_;
- const int num_crunch_configs = params->num_crunch_configs_;
- const int red_and_blue_always_zero = params->red_and_blue_always_zero_;
-#if !defined(WEBP_DISABLE_STATS)
- WebPAuxStats* const stats = params->stats_;
-#endif
- WebPEncodingError err = VP8_ENC_OK;
- const int quality = (int)config->quality;
- const int low_effort = (config->method == 0);
-#if (WEBP_NEAR_LOSSLESS == 1)
- const int width = picture->width;
-#endif
- const int height = picture->height;
- const size_t byte_position = VP8LBitWriterNumBytes(bw);
-#if (WEBP_NEAR_LOSSLESS == 1)
- int use_near_lossless = 0;
-#endif
- int hdr_size = 0;
- int data_size = 0;
- int use_delta_palette = 0;
- int idx;
- size_t best_size = ~(size_t)0;
- VP8LBitWriter bw_init = *bw, bw_best;
- (void)data2;
-
- if (!VP8LBitWriterInit(&bw_best, 0) ||
- (num_crunch_configs > 1 && !VP8LBitWriterClone(bw, &bw_best))) {
- err = VP8_ENC_ERROR_OUT_OF_MEMORY;
- goto Error;
- }
-
- for (idx = 0; idx < num_crunch_configs; ++idx) {
- const int entropy_idx = crunch_configs[idx].entropy_idx_;
- enc->use_palette_ =
- (entropy_idx == kPalette) || (entropy_idx == kPaletteAndSpatial);
- enc->use_subtract_green_ =
- (entropy_idx == kSubGreen) || (entropy_idx == kSpatialSubGreen);
- enc->use_predict_ = (entropy_idx == kSpatial) ||
- (entropy_idx == kSpatialSubGreen) ||
- (entropy_idx == kPaletteAndSpatial);
- // When using a palette, R/B==0, hence no need to test for cross-color.
- if (low_effort || enc->use_palette_) {
- enc->use_cross_color_ = 0;
- } else {
- enc->use_cross_color_ = red_and_blue_always_zero ? 0 : enc->use_predict_;
- }
- // Reset any parameter in the encoder that is set in the previous iteration.
- enc->cache_bits_ = 0;
- VP8LBackwardRefsClear(&enc->refs_[0]);
- VP8LBackwardRefsClear(&enc->refs_[1]);
-
-#if (WEBP_NEAR_LOSSLESS == 1)
- // Apply near-lossless preprocessing.
- use_near_lossless = (config->near_lossless < 100) && !enc->use_palette_ &&
- !enc->use_predict_;
- if (use_near_lossless) {
- err = AllocateTransformBuffer(enc, width, height);
- if (err != VP8_ENC_OK) goto Error;
- if ((enc->argb_content_ != kEncoderNearLossless) &&
- !VP8ApplyNearLossless(picture, config->near_lossless, enc->argb_)) {
- err = VP8_ENC_ERROR_OUT_OF_MEMORY;
- goto Error;
- }
- enc->argb_content_ = kEncoderNearLossless;
- } else {
- enc->argb_content_ = kEncoderNone;
- }
-#else
- enc->argb_content_ = kEncoderNone;
-#endif
-
- // Encode palette
- if (enc->use_palette_) {
- if (crunch_configs[idx].palette_sorting_type_ == kSortedDefault) {
- // Nothing to do, we have already sorted the palette.
- memcpy(enc->palette_, enc->palette_sorted_,
- enc->palette_size_ * sizeof(*enc->palette_));
- } else if (crunch_configs[idx].palette_sorting_type_ == kMinimizeDelta) {
- PaletteSortMinimizeDeltas(enc->palette_sorted_, enc->palette_size_,
- enc->palette_);
- } else {
- assert(crunch_configs[idx].palette_sorting_type_ == kModifiedZeng);
- err = PaletteSortModifiedZeng(enc->pic_, enc->palette_sorted_,
- enc->palette_size_, enc->palette_);
- if (err != VP8_ENC_OK) goto Error;
- }
- err = EncodePalette(bw, low_effort, enc);
- if (err != VP8_ENC_OK) goto Error;
- err = MapImageFromPalette(enc, use_delta_palette);
- if (err != VP8_ENC_OK) goto Error;
- // If using a color cache, do not have it bigger than the number of
- // colors.
- if (use_cache && enc->palette_size_ < (1 << MAX_COLOR_CACHE_BITS)) {
- enc->cache_bits_ = BitsLog2Floor(enc->palette_size_) + 1;
- }
- }
- if (!use_delta_palette) {
- // In case image is not packed.
- if (enc->argb_content_ != kEncoderNearLossless &&
- enc->argb_content_ != kEncoderPalette) {
- err = MakeInputImageCopy(enc);
- if (err != VP8_ENC_OK) goto Error;
- }
-
- // -----------------------------------------------------------------------
- // Apply transforms and write transform data.
-
- if (enc->use_subtract_green_) {
- ApplySubtractGreen(enc, enc->current_width_, height, bw);
- }
-
- if (enc->use_predict_) {
- err = ApplyPredictFilter(enc, enc->current_width_, height, quality,
- low_effort, enc->use_subtract_green_, bw);
- if (err != VP8_ENC_OK) goto Error;
- }
-
- if (enc->use_cross_color_) {
- err = ApplyCrossColorFilter(enc, enc->current_width_, height, quality,
- low_effort, bw);
- if (err != VP8_ENC_OK) goto Error;
- }
- }
-
- VP8LPutBits(bw, !TRANSFORM_PRESENT, 1); // No more transforms.
-
- // -------------------------------------------------------------------------
- // Encode and write the transformed image.
- err = EncodeImageInternal(bw, enc->argb_, &enc->hash_chain_, enc->refs_,
- enc->current_width_, height, quality, low_effort,
- use_cache, &crunch_configs[idx],
- &enc->cache_bits_, enc->histo_bits_,
- byte_position, &hdr_size, &data_size);
- if (err != VP8_ENC_OK) goto Error;
-
- // If we are better than what we already have.
- if (VP8LBitWriterNumBytes(bw) < best_size) {
- best_size = VP8LBitWriterNumBytes(bw);
- // Store the BitWriter.
- VP8LBitWriterSwap(bw, &bw_best);
-#if !defined(WEBP_DISABLE_STATS)
- // Update the stats.
- if (stats != NULL) {
- stats->lossless_features = 0;
- if (enc->use_predict_) stats->lossless_features |= 1;
- if (enc->use_cross_color_) stats->lossless_features |= 2;
- if (enc->use_subtract_green_) stats->lossless_features |= 4;
- if (enc->use_palette_) stats->lossless_features |= 8;
- stats->histogram_bits = enc->histo_bits_;
- stats->transform_bits = enc->transform_bits_;
- stats->cache_bits = enc->cache_bits_;
- stats->palette_size = enc->palette_size_;
- stats->lossless_size = (int)(best_size - byte_position);
- stats->lossless_hdr_size = hdr_size;
- stats->lossless_data_size = data_size;
- }
-#endif
- }
- // Reset the bit writer for the following iteration if any.
- if (num_crunch_configs > 1) VP8LBitWriterReset(&bw_init, bw);
- }
- VP8LBitWriterSwap(&bw_best, bw);
-
-Error:
- VP8LBitWriterWipeOut(&bw_best);
- params->err_ = err;
- // The hook should return false in case of error.
- return (err == VP8_ENC_OK);
-}
-
-WebPEncodingError VP8LEncodeStream(const WebPConfig* const config,
- const WebPPicture* const picture,
- VP8LBitWriter* const bw_main,
- int use_cache) {
- WebPEncodingError err = VP8_ENC_OK;
- VP8LEncoder* const enc_main = VP8LEncoderNew(config, picture);
- VP8LEncoder* enc_side = NULL;
- CrunchConfig crunch_configs[CRUNCH_CONFIGS_MAX];
- int num_crunch_configs_main, num_crunch_configs_side = 0;
- int idx;
- int red_and_blue_always_zero = 0;
- WebPWorker worker_main, worker_side;
- StreamEncodeContext params_main, params_side;
- // The main thread uses picture->stats, the side thread uses stats_side.
- WebPAuxStats stats_side;
- VP8LBitWriter bw_side;
- const WebPWorkerInterface* const worker_interface = WebPGetWorkerInterface();
- int ok_main;
-
- // Analyze image (entropy, num_palettes etc)
- if (enc_main == NULL ||
- !EncoderAnalyze(enc_main, crunch_configs, &num_crunch_configs_main,
- &red_and_blue_always_zero) ||
- !EncoderInit(enc_main) || !VP8LBitWriterInit(&bw_side, 0)) {
- err = VP8_ENC_ERROR_OUT_OF_MEMORY;
- goto Error;
- }
-
- // Split the configs between the main and side threads (if any).
- if (config->thread_level > 0) {
- num_crunch_configs_side = num_crunch_configs_main / 2;
- for (idx = 0; idx < num_crunch_configs_side; ++idx) {
- params_side.crunch_configs_[idx] =
- crunch_configs[num_crunch_configs_main - num_crunch_configs_side +
- idx];
- }
- params_side.num_crunch_configs_ = num_crunch_configs_side;
- }
- num_crunch_configs_main -= num_crunch_configs_side;
- for (idx = 0; idx < num_crunch_configs_main; ++idx) {
- params_main.crunch_configs_[idx] = crunch_configs[idx];
- }
- params_main.num_crunch_configs_ = num_crunch_configs_main;
-
- // Fill in the parameters for the thread workers.
- {
- const int params_size = (num_crunch_configs_side > 0) ? 2 : 1;
- for (idx = 0; idx < params_size; ++idx) {
- // Create the parameters for each worker.
- WebPWorker* const worker = (idx == 0) ? &worker_main : &worker_side;
- StreamEncodeContext* const param =
- (idx == 0) ? &params_main : &params_side;
- param->config_ = config;
- param->picture_ = picture;
- param->use_cache_ = use_cache;
- param->red_and_blue_always_zero_ = red_and_blue_always_zero;
- if (idx == 0) {
- param->stats_ = picture->stats;
- param->bw_ = bw_main;
- param->enc_ = enc_main;
- } else {
- param->stats_ = (picture->stats == NULL) ? NULL : &stats_side;
- // Create a side bit writer.
- if (!VP8LBitWriterClone(bw_main, &bw_side)) {
- err = VP8_ENC_ERROR_OUT_OF_MEMORY;
- goto Error;
- }
- param->bw_ = &bw_side;
- // Create a side encoder.
- enc_side = VP8LEncoderNew(config, picture);
- if (enc_side == NULL || !EncoderInit(enc_side)) {
- err = VP8_ENC_ERROR_OUT_OF_MEMORY;
- goto Error;
- }
- // Copy the values that were computed for the main encoder.
- enc_side->histo_bits_ = enc_main->histo_bits_;
- enc_side->transform_bits_ = enc_main->transform_bits_;
- enc_side->palette_size_ = enc_main->palette_size_;
- memcpy(enc_side->palette_, enc_main->palette_,
- sizeof(enc_main->palette_));
- memcpy(enc_side->palette_sorted_, enc_main->palette_sorted_,
- sizeof(enc_main->palette_sorted_));
- param->enc_ = enc_side;
- }
- // Create the workers.
- worker_interface->Init(worker);
- worker->data1 = param;
- worker->data2 = NULL;
- worker->hook = EncodeStreamHook;
- }
- }
-
- // Start the second thread if needed.
- if (num_crunch_configs_side != 0) {
- if (!worker_interface->Reset(&worker_side)) {
- err = VP8_ENC_ERROR_OUT_OF_MEMORY;
- goto Error;
- }
-#if !defined(WEBP_DISABLE_STATS)
- // This line is here and not in the param initialization above to remove a
- // Clang static analyzer warning.
- if (picture->stats != NULL) {
- memcpy(&stats_side, picture->stats, sizeof(stats_side));
- }
-#endif
- // This line is only useful to remove a Clang static analyzer warning.
- params_side.err_ = VP8_ENC_OK;
- worker_interface->Launch(&worker_side);
- }
- // Execute the main thread.
- worker_interface->Execute(&worker_main);
- ok_main = worker_interface->Sync(&worker_main);
- worker_interface->End(&worker_main);
- if (num_crunch_configs_side != 0) {
- // Wait for the second thread.
- const int ok_side = worker_interface->Sync(&worker_side);
- worker_interface->End(&worker_side);
- if (!ok_main || !ok_side) {
- err = ok_main ? params_side.err_ : params_main.err_;
- goto Error;
- }
- if (VP8LBitWriterNumBytes(&bw_side) < VP8LBitWriterNumBytes(bw_main)) {
- VP8LBitWriterSwap(bw_main, &bw_side);
-#if !defined(WEBP_DISABLE_STATS)
- if (picture->stats != NULL) {
- memcpy(picture->stats, &stats_side, sizeof(*picture->stats));
- }
-#endif
- }
- } else {
- if (!ok_main) {
- err = params_main.err_;
- goto Error;
- }
- }
-
-Error:
- VP8LBitWriterWipeOut(&bw_side);
- VP8LEncoderDelete(enc_main);
- VP8LEncoderDelete(enc_side);
- return err;
-}
-
-#undef CRUNCH_CONFIGS_MAX
-#undef CRUNCH_SUBCONFIGS_MAX
-
-int VP8LEncodeImage(const WebPConfig* const config,
- const WebPPicture* const picture) {
- int width, height;
- int has_alpha;
- size_t coded_size;
- int percent = 0;
- int initial_size;
- WebPEncodingError err = VP8_ENC_OK;
- VP8LBitWriter bw;
-
- if (picture == NULL) return 0;
-
- if (config == NULL || picture->argb == NULL) {
- err = VP8_ENC_ERROR_NULL_PARAMETER;
- WebPEncodingSetError(picture, err);
- return 0;
- }
-
- width = picture->width;
- height = picture->height;
- // Initialize BitWriter with size corresponding to 16 bpp to photo images and
- // 8 bpp for graphical images.
- initial_size = (config->image_hint == WEBP_HINT_GRAPH) ?
- width * height : width * height * 2;
- if (!VP8LBitWriterInit(&bw, initial_size)) {
- err = VP8_ENC_ERROR_OUT_OF_MEMORY;
- goto Error;
- }
-
- if (!WebPReportProgress(picture, 1, &percent)) {
- UserAbort:
- err = VP8_ENC_ERROR_USER_ABORT;
- goto Error;
- }
- // Reset stats (for pure lossless coding)
- if (picture->stats != NULL) {
- WebPAuxStats* const stats = picture->stats;
- memset(stats, 0, sizeof(*stats));
- stats->PSNR[0] = 99.f;
- stats->PSNR[1] = 99.f;
- stats->PSNR[2] = 99.f;
- stats->PSNR[3] = 99.f;
- stats->PSNR[4] = 99.f;
- }
-
- // Write image size.
- if (!WriteImageSize(picture, &bw)) {
- err = VP8_ENC_ERROR_OUT_OF_MEMORY;
- goto Error;
- }
-
- has_alpha = WebPPictureHasTransparency(picture);
- // Write the non-trivial Alpha flag and lossless version.
- if (!WriteRealAlphaAndVersion(&bw, has_alpha)) {
- err = VP8_ENC_ERROR_OUT_OF_MEMORY;
- goto Error;
- }
-
- if (!WebPReportProgress(picture, 5, &percent)) goto UserAbort;
-
- // Encode main image stream.
- err = VP8LEncodeStream(config, picture, &bw, 1 /*use_cache*/);
- if (err != VP8_ENC_OK) goto Error;
-
- if (!WebPReportProgress(picture, 90, &percent)) goto UserAbort;
-
- // Finish the RIFF chunk.
- err = WriteImage(picture, &bw, &coded_size);
- if (err != VP8_ENC_OK) goto Error;
-
- if (!WebPReportProgress(picture, 100, &percent)) goto UserAbort;
-
-#if !defined(WEBP_DISABLE_STATS)
- // Save size.
- if (picture->stats != NULL) {
- picture->stats->coded_size += (int)coded_size;
- picture->stats->lossless_size = (int)coded_size;
- }
-#endif
-
- if (picture->extra_info != NULL) {
- const int mb_w = (width + 15) >> 4;
- const int mb_h = (height + 15) >> 4;
- memset(picture->extra_info, 0, mb_w * mb_h * sizeof(*picture->extra_info));
- }
-
- Error:
- if (bw.error_) err = VP8_ENC_ERROR_OUT_OF_MEMORY;
- VP8LBitWriterWipeOut(&bw);
- if (err != VP8_ENC_OK) {
- WebPEncodingSetError(picture, err);
- return 0;
- }
- return 1;
-}
-
-//------------------------------------------------------------------------------
diff --git a/contrib/libs/libwebp/enc/vp8li_enc.h b/contrib/libs/libwebp/enc/vp8li_enc.h
deleted file mode 100644
index bbb2098b8f..0000000000
--- a/contrib/libs/libwebp/enc/vp8li_enc.h
+++ /dev/null
@@ -1,120 +0,0 @@
-// Copyright 2012 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Lossless encoder: internal header.
-//
-// Author: Vikas Arora (vikaas.arora@gmail.com)
-
-#ifndef WEBP_ENC_VP8LI_ENC_H_
-#define WEBP_ENC_VP8LI_ENC_H_
-
-#ifdef HAVE_CONFIG_H
-#include "../webp/config.h"
-#endif
-// Either WEBP_NEAR_LOSSLESS is defined as 0 in config.h when compiling to
-// disable near-lossless, or it is enabled by default.
-#ifndef WEBP_NEAR_LOSSLESS
-#define WEBP_NEAR_LOSSLESS 1
-#endif
-
-#include "./backward_references_enc.h"
-#include "./histogram_enc.h"
-#include "../utils/bit_writer_utils.h"
-#include "../webp/encode.h"
-#include "../webp/format_constants.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// maximum value of transform_bits_ in VP8LEncoder.
-#define MAX_TRANSFORM_BITS 6
-
-typedef enum {
- kEncoderNone = 0,
- kEncoderARGB,
- kEncoderNearLossless,
- kEncoderPalette
-} VP8LEncoderARGBContent;
-
-typedef struct {
- const WebPConfig* config_; // user configuration and parameters
- const WebPPicture* pic_; // input picture.
-
- uint32_t* argb_; // Transformed argb image data.
- VP8LEncoderARGBContent argb_content_; // Content type of the argb buffer.
- uint32_t* argb_scratch_; // Scratch memory for argb rows
- // (used for prediction).
- uint32_t* transform_data_; // Scratch memory for transform data.
- uint32_t* transform_mem_; // Currently allocated memory.
- size_t transform_mem_size_; // Currently allocated memory size.
-
- int current_width_; // Corresponds to packed image width.
-
- // Encoding parameters derived from quality parameter.
- int histo_bits_;
- int transform_bits_; // <= MAX_TRANSFORM_BITS.
- int cache_bits_; // If equal to 0, don't use color cache.
-
- // Encoding parameters derived from image characteristics.
- int use_cross_color_;
- int use_subtract_green_;
- int use_predict_;
- int use_palette_;
- int palette_size_;
- uint32_t palette_[MAX_PALETTE_SIZE];
- // Sorted version of palette_ for cache purposes.
- uint32_t palette_sorted_[MAX_PALETTE_SIZE];
-
- // Some 'scratch' (potentially large) objects.
- struct VP8LBackwardRefs refs_[4]; // Backward Refs array for temporaries.
- VP8LHashChain hash_chain_; // HashChain data for constructing
- // backward references.
-} VP8LEncoder;
-
-//------------------------------------------------------------------------------
-// internal functions. Not public.
-
-// Encodes the picture.
-// Returns 0 if config or picture is NULL or picture doesn't have valid argb
-// input.
-int VP8LEncodeImage(const WebPConfig* const config,
- const WebPPicture* const picture);
-
-// Encodes the main image stream using the supplied bit writer.
-// If 'use_cache' is false, disables the use of color cache.
-WebPEncodingError VP8LEncodeStream(const WebPConfig* const config,
- const WebPPicture* const picture,
- VP8LBitWriter* const bw, int use_cache);
-
-#if (WEBP_NEAR_LOSSLESS == 1)
-// in near_lossless.c
-// Near lossless preprocessing in RGB color-space.
-int VP8ApplyNearLossless(const WebPPicture* const picture, int quality,
- uint32_t* const argb_dst);
-#endif
-
-//------------------------------------------------------------------------------
-// Image transforms in predictor.c.
-
-void VP8LResidualImage(int width, int height, int bits, int low_effort,
- uint32_t* const argb, uint32_t* const argb_scratch,
- uint32_t* const image, int near_lossless, int exact,
- int used_subtract_green);
-
-void VP8LColorSpaceTransform(int width, int height, int bits, int quality,
- uint32_t* const argb, uint32_t* image);
-
-//------------------------------------------------------------------------------
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // WEBP_ENC_VP8LI_ENC_H_
diff --git a/contrib/libs/libwebp/enc/webp_enc.c b/contrib/libs/libwebp/enc/webp_enc.c
deleted file mode 100644
index 696143ae9b..0000000000
--- a/contrib/libs/libwebp/enc/webp_enc.c
+++ /dev/null
@@ -1,410 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// WebP encoder: main entry point
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include <assert.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-
-#include "./cost_enc.h"
-#include "./vp8i_enc.h"
-#include "./vp8li_enc.h"
-#include "../utils/utils.h"
-
-// #define PRINT_MEMORY_INFO
-
-#ifdef PRINT_MEMORY_INFO
-#include <stdio.h>
-#endif
-
-//------------------------------------------------------------------------------
-
-int WebPGetEncoderVersion(void) {
- return (ENC_MAJ_VERSION << 16) | (ENC_MIN_VERSION << 8) | ENC_REV_VERSION;
-}
-
-//------------------------------------------------------------------------------
-// VP8Encoder
-//------------------------------------------------------------------------------
-
-static void ResetSegmentHeader(VP8Encoder* const enc) {
- VP8EncSegmentHeader* const hdr = &enc->segment_hdr_;
- hdr->num_segments_ = enc->config_->segments;
- hdr->update_map_ = (hdr->num_segments_ > 1);
- hdr->size_ = 0;
-}
-
-static void ResetFilterHeader(VP8Encoder* const enc) {
- VP8EncFilterHeader* const hdr = &enc->filter_hdr_;
- hdr->simple_ = 1;
- hdr->level_ = 0;
- hdr->sharpness_ = 0;
- hdr->i4x4_lf_delta_ = 0;
-}
-
-static void ResetBoundaryPredictions(VP8Encoder* const enc) {
- // init boundary values once for all
- // Note: actually, initializing the preds_[] is only needed for intra4.
- int i;
- uint8_t* const top = enc->preds_ - enc->preds_w_;
- uint8_t* const left = enc->preds_ - 1;
- for (i = -1; i < 4 * enc->mb_w_; ++i) {
- top[i] = B_DC_PRED;
- }
- for (i = 0; i < 4 * enc->mb_h_; ++i) {
- left[i * enc->preds_w_] = B_DC_PRED;
- }
- enc->nz_[-1] = 0; // constant
-}
-
-// Mapping from config->method_ to coding tools used.
-//-------------------+---+---+---+---+---+---+---+
-// Method | 0 | 1 | 2 | 3 |(4)| 5 | 6 |
-//-------------------+---+---+---+---+---+---+---+
-// fast probe | x | | | x | | | |
-//-------------------+---+---+---+---+---+---+---+
-// dynamic proba | ~ | x | x | x | x | x | x |
-//-------------------+---+---+---+---+---+---+---+
-// fast mode analysis|[x]|[x]| | | x | x | x |
-//-------------------+---+---+---+---+---+---+---+
-// basic rd-opt | | | | x | x | x | x |
-//-------------------+---+---+---+---+---+---+---+
-// disto-refine i4/16| x | x | x | | | | |
-//-------------------+---+---+---+---+---+---+---+
-// disto-refine uv | | x | x | | | | |
-//-------------------+---+---+---+---+---+---+---+
-// rd-opt i4/16 | | | ~ | x | x | x | x |
-//-------------------+---+---+---+---+---+---+---+
-// token buffer (opt)| | | | x | x | x | x |
-//-------------------+---+---+---+---+---+---+---+
-// Trellis | | | | | | x |Ful|
-//-------------------+---+---+---+---+---+---+---+
-// full-SNS | | | | | x | x | x |
-//-------------------+---+---+---+---+---+---+---+
-
-static void MapConfigToTools(VP8Encoder* const enc) {
- const WebPConfig* const config = enc->config_;
- const int method = config->method;
- const int limit = 100 - config->partition_limit;
- enc->method_ = method;
- enc->rd_opt_level_ = (method >= 6) ? RD_OPT_TRELLIS_ALL
- : (method >= 5) ? RD_OPT_TRELLIS
- : (method >= 3) ? RD_OPT_BASIC
- : RD_OPT_NONE;
- enc->max_i4_header_bits_ =
- 256 * 16 * 16 * // upper bound: up to 16bit per 4x4 block
- (limit * limit) / (100 * 100); // ... modulated with a quadratic curve.
-
- // partition0 = 512k max.
- enc->mb_header_limit_ =
- (score_t)256 * 510 * 8 * 1024 / (enc->mb_w_ * enc->mb_h_);
-
- enc->thread_level_ = config->thread_level;
-
- enc->do_search_ = (config->target_size > 0 || config->target_PSNR > 0);
- if (!config->low_memory) {
-#if !defined(DISABLE_TOKEN_BUFFER)
- enc->use_tokens_ = (enc->rd_opt_level_ >= RD_OPT_BASIC); // need rd stats
-#endif
- if (enc->use_tokens_) {
- enc->num_parts_ = 1; // doesn't work with multi-partition
- }
- }
-}
-
-// Memory scaling with dimensions:
-// memory (bytes) ~= 2.25 * w + 0.0625 * w * h
-//
-// Typical memory footprint (614x440 picture)
-// encoder: 22111
-// info: 4368
-// preds: 17741
-// top samples: 1263
-// non-zero: 175
-// lf-stats: 0
-// total: 45658
-// Transient object sizes:
-// VP8EncIterator: 3360
-// VP8ModeScore: 872
-// VP8SegmentInfo: 732
-// VP8EncProba: 18352
-// LFStats: 2048
-// Picture size (yuv): 419328
-
-static VP8Encoder* InitVP8Encoder(const WebPConfig* const config,
- WebPPicture* const picture) {
- VP8Encoder* enc;
- const int use_filter =
- (config->filter_strength > 0) || (config->autofilter > 0);
- const int mb_w = (picture->width + 15) >> 4;
- const int mb_h = (picture->height + 15) >> 4;
- const int preds_w = 4 * mb_w + 1;
- const int preds_h = 4 * mb_h + 1;
- const size_t preds_size = preds_w * preds_h * sizeof(*enc->preds_);
- const int top_stride = mb_w * 16;
- const size_t nz_size = (mb_w + 1) * sizeof(*enc->nz_) + WEBP_ALIGN_CST;
- const size_t info_size = mb_w * mb_h * sizeof(*enc->mb_info_);
- const size_t samples_size =
- 2 * top_stride * sizeof(*enc->y_top_) // top-luma/u/v
- + WEBP_ALIGN_CST; // align all
- const size_t lf_stats_size =
- config->autofilter ? sizeof(*enc->lf_stats_) + WEBP_ALIGN_CST : 0;
- const size_t top_derr_size =
- (config->quality <= ERROR_DIFFUSION_QUALITY || config->pass > 1) ?
- mb_w * sizeof(*enc->top_derr_) : 0;
- uint8_t* mem;
- const uint64_t size = (uint64_t)sizeof(*enc) // main struct
- + WEBP_ALIGN_CST // cache alignment
- + info_size // modes info
- + preds_size // prediction modes
- + samples_size // top/left samples
- + top_derr_size // top diffusion error
- + nz_size // coeff context bits
- + lf_stats_size; // autofilter stats
-
-#ifdef PRINT_MEMORY_INFO
- printf("===================================\n");
- printf("Memory used:\n"
- " encoder: %ld\n"
- " info: %ld\n"
- " preds: %ld\n"
- " top samples: %ld\n"
- " top diffusion: %ld\n"
- " non-zero: %ld\n"
- " lf-stats: %ld\n"
- " total: %ld\n",
- sizeof(*enc) + WEBP_ALIGN_CST, info_size,
- preds_size, samples_size, top_derr_size, nz_size, lf_stats_size, size);
- printf("Transient object sizes:\n"
- " VP8EncIterator: %ld\n"
- " VP8ModeScore: %ld\n"
- " VP8SegmentInfo: %ld\n"
- " VP8EncProba: %ld\n"
- " LFStats: %ld\n",
- sizeof(VP8EncIterator), sizeof(VP8ModeScore),
- sizeof(VP8SegmentInfo), sizeof(VP8EncProba),
- sizeof(LFStats));
- printf("Picture size (yuv): %ld\n",
- mb_w * mb_h * 384 * sizeof(uint8_t));
- printf("===================================\n");
-#endif
- mem = (uint8_t*)WebPSafeMalloc(size, sizeof(*mem));
- if (mem == NULL) {
- WebPEncodingSetError(picture, VP8_ENC_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
- enc = (VP8Encoder*)mem;
- mem = (uint8_t*)WEBP_ALIGN(mem + sizeof(*enc));
- memset(enc, 0, sizeof(*enc));
- enc->num_parts_ = 1 << config->partitions;
- enc->mb_w_ = mb_w;
- enc->mb_h_ = mb_h;
- enc->preds_w_ = preds_w;
- enc->mb_info_ = (VP8MBInfo*)mem;
- mem += info_size;
- enc->preds_ = mem + 1 + enc->preds_w_;
- mem += preds_size;
- enc->nz_ = 1 + (uint32_t*)WEBP_ALIGN(mem);
- mem += nz_size;
- enc->lf_stats_ = lf_stats_size ? (LFStats*)WEBP_ALIGN(mem) : NULL;
- mem += lf_stats_size;
-
- // top samples (all 16-aligned)
- mem = (uint8_t*)WEBP_ALIGN(mem);
- enc->y_top_ = mem;
- enc->uv_top_ = enc->y_top_ + top_stride;
- mem += 2 * top_stride;
- enc->top_derr_ = top_derr_size ? (DError*)mem : NULL;
- mem += top_derr_size;
- assert(mem <= (uint8_t*)enc + size);
-
- enc->config_ = config;
- enc->profile_ = use_filter ? ((config->filter_type == 1) ? 0 : 1) : 2;
- enc->pic_ = picture;
- enc->percent_ = 0;
-
- MapConfigToTools(enc);
- VP8EncDspInit();
- VP8DefaultProbas(enc);
- ResetSegmentHeader(enc);
- ResetFilterHeader(enc);
- ResetBoundaryPredictions(enc);
- VP8EncDspCostInit();
- VP8EncInitAlpha(enc);
-
- // lower quality means smaller output -> we modulate a little the page
- // size based on quality. This is just a crude 1rst-order prediction.
- {
- const float scale = 1.f + config->quality * 5.f / 100.f; // in [1,6]
- VP8TBufferInit(&enc->tokens_, (int)(mb_w * mb_h * 4 * scale));
- }
- return enc;
-}
-
-static int DeleteVP8Encoder(VP8Encoder* enc) {
- int ok = 1;
- if (enc != NULL) {
- ok = VP8EncDeleteAlpha(enc);
- VP8TBufferClear(&enc->tokens_);
- WebPSafeFree(enc);
- }
- return ok;
-}
-
-//------------------------------------------------------------------------------
-
-#if !defined(WEBP_DISABLE_STATS)
-static double GetPSNR(uint64_t err, uint64_t size) {
- return (err > 0 && size > 0) ? 10. * log10(255. * 255. * size / err) : 99.;
-}
-
-static void FinalizePSNR(const VP8Encoder* const enc) {
- WebPAuxStats* stats = enc->pic_->stats;
- const uint64_t size = enc->sse_count_;
- const uint64_t* const sse = enc->sse_;
- stats->PSNR[0] = (float)GetPSNR(sse[0], size);
- stats->PSNR[1] = (float)GetPSNR(sse[1], size / 4);
- stats->PSNR[2] = (float)GetPSNR(sse[2], size / 4);
- stats->PSNR[3] = (float)GetPSNR(sse[0] + sse[1] + sse[2], size * 3 / 2);
- stats->PSNR[4] = (float)GetPSNR(sse[3], size);
-}
-#endif // !defined(WEBP_DISABLE_STATS)
-
-static void StoreStats(VP8Encoder* const enc) {
-#if !defined(WEBP_DISABLE_STATS)
- WebPAuxStats* const stats = enc->pic_->stats;
- if (stats != NULL) {
- int i, s;
- for (i = 0; i < NUM_MB_SEGMENTS; ++i) {
- stats->segment_level[i] = enc->dqm_[i].fstrength_;
- stats->segment_quant[i] = enc->dqm_[i].quant_;
- for (s = 0; s <= 2; ++s) {
- stats->residual_bytes[s][i] = enc->residual_bytes_[s][i];
- }
- }
- FinalizePSNR(enc);
- stats->coded_size = enc->coded_size_;
- for (i = 0; i < 3; ++i) {
- stats->block_count[i] = enc->block_count_[i];
- }
- }
-#else // defined(WEBP_DISABLE_STATS)
- WebPReportProgress(enc->pic_, 100, &enc->percent_); // done!
-#endif // !defined(WEBP_DISABLE_STATS)
-}
-
-int WebPEncodingSetError(const WebPPicture* const pic,
- WebPEncodingError error) {
- assert((int)error < VP8_ENC_ERROR_LAST);
- assert((int)error >= VP8_ENC_OK);
- ((WebPPicture*)pic)->error_code = error;
- return 0;
-}
-
-int WebPReportProgress(const WebPPicture* const pic,
- int percent, int* const percent_store) {
- if (percent_store != NULL && percent != *percent_store) {
- *percent_store = percent;
- if (pic->progress_hook && !pic->progress_hook(percent, pic)) {
- // user abort requested
- WebPEncodingSetError(pic, VP8_ENC_ERROR_USER_ABORT);
- return 0;
- }
- }
- return 1; // ok
-}
-//------------------------------------------------------------------------------
-
-int WebPEncode(const WebPConfig* config, WebPPicture* pic) {
- int ok = 0;
- if (pic == NULL) return 0;
-
- WebPEncodingSetError(pic, VP8_ENC_OK); // all ok so far
- if (config == NULL) { // bad params
- return WebPEncodingSetError(pic, VP8_ENC_ERROR_NULL_PARAMETER);
- }
- if (!WebPValidateConfig(config)) {
- return WebPEncodingSetError(pic, VP8_ENC_ERROR_INVALID_CONFIGURATION);
- }
- if (pic->width <= 0 || pic->height <= 0) {
- return WebPEncodingSetError(pic, VP8_ENC_ERROR_BAD_DIMENSION);
- }
- if (pic->width > WEBP_MAX_DIMENSION || pic->height > WEBP_MAX_DIMENSION) {
- return WebPEncodingSetError(pic, VP8_ENC_ERROR_BAD_DIMENSION);
- }
-
- if (pic->stats != NULL) memset(pic->stats, 0, sizeof(*pic->stats));
-
- if (!config->lossless) {
- VP8Encoder* enc = NULL;
-
- if (pic->use_argb || pic->y == NULL || pic->u == NULL || pic->v == NULL) {
- // Make sure we have YUVA samples.
- if (config->use_sharp_yuv || (config->preprocessing & 4)) {
- if (!WebPPictureSharpARGBToYUVA(pic)) {
- return 0;
- }
- } else {
- float dithering = 0.f;
- if (config->preprocessing & 2) {
- const float x = config->quality / 100.f;
- const float x2 = x * x;
- // slowly decreasing from max dithering at low quality (q->0)
- // to 0.5 dithering amplitude at high quality (q->100)
- dithering = 1.0f + (0.5f - 1.0f) * x2 * x2;
- }
- if (!WebPPictureARGBToYUVADithered(pic, WEBP_YUV420, dithering)) {
- return 0;
- }
- }
- }
-
- if (!config->exact) {
- WebPCleanupTransparentArea(pic);
- }
-
- enc = InitVP8Encoder(config, pic);
- if (enc == NULL) return 0; // pic->error is already set.
- // Note: each of the tasks below account for 20% in the progress report.
- ok = VP8EncAnalyze(enc);
-
- // Analysis is done, proceed to actual coding.
- ok = ok && VP8EncStartAlpha(enc); // possibly done in parallel
- if (!enc->use_tokens_) {
- ok = ok && VP8EncLoop(enc);
- } else {
- ok = ok && VP8EncTokenLoop(enc);
- }
- ok = ok && VP8EncFinishAlpha(enc);
-
- ok = ok && VP8EncWrite(enc);
- StoreStats(enc);
- if (!ok) {
- VP8EncFreeBitWriters(enc);
- }
- ok &= DeleteVP8Encoder(enc); // must always be called, even if !ok
- } else {
- // Make sure we have ARGB samples.
- if (pic->argb == NULL && !WebPPictureYUVAToARGB(pic)) {
- return 0;
- }
-
- if (!config->exact) {
- WebPReplaceTransparentPixels(pic, 0x000000);
- }
-
- ok = VP8LEncodeImage(config, pic); // Sets pic->error in case of problem.
- }
-
- return ok;
-}
diff --git a/contrib/libs/libwebp/enc/ya.make b/contrib/libs/libwebp/enc/ya.make
deleted file mode 100644
index 08f9703150..0000000000
--- a/contrib/libs/libwebp/enc/ya.make
+++ /dev/null
@@ -1,50 +0,0 @@
-# Generated by devtools/yamaker.
-
-LIBRARY()
-
-VERSION(1.2.2)
-
-LICENSE(BSD-3-Clause WITH Google-Patent-License-Webm)
-
-LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
-
-ADDINCL(
- contrib/libs/libwebp/enc
- contrib/libs/libwebp/webp
-)
-
-NO_COMPILER_WARNINGS()
-
-NO_RUNTIME()
-
-CFLAGS(
- -DHAVE_CONFIG_H
-)
-
-SRCS(
- alpha_enc.c
- analysis_enc.c
- backward_references_cost_enc.c
- backward_references_enc.c
- config_enc.c
- cost_enc.c
- filter_enc.c
- frame_enc.c
- histogram_enc.c
- iterator_enc.c
- near_lossless_enc.c
- picture_csp_enc.c
- picture_enc.c
- picture_psnr_enc.c
- picture_rescale_enc.c
- picture_tools_enc.c
- predictor_enc.c
- quant_enc.c
- syntax_enc.c
- token_enc.c
- tree_enc.c
- vp8l_enc.c
- webp_enc.c
-)
-
-END()
diff --git a/contrib/libs/libwebp/mux/.yandex_meta/licenses.list.txt b/contrib/libs/libwebp/mux/.yandex_meta/licenses.list.txt
deleted file mode 100644
index ecda37120f..0000000000
--- a/contrib/libs/libwebp/mux/.yandex_meta/licenses.list.txt
+++ /dev/null
@@ -1,132 +0,0 @@
-====================BSD-3-Clause WITH Google-Patent-License-Webm====================
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-
-
-====================COPYRIGHT====================
-// Copyright 2011 Google Inc. All Rights Reserved.
-
-
-====================COPYRIGHT====================
-// Copyright 2014 Google Inc. All Rights Reserved.
-
-
-====================COPYRIGHT====================
-// Copyright 2016 Google Inc. All Rights Reserved.
-
-
-====================File: AUTHORS====================
-Contributors:
-- Aidan O'Loan (aidanol at gmail dot com)
-- Alan Browning (browning at google dot com)
-- Charles Munger (clm at google dot com)
-- Cheng Yi (cyi at google dot com)
-- Christian Duvivier (cduvivier at google dot com)
-- Christopher Degawa (ccom at randomderp dot com)
-- Clement Courbet (courbet at google dot com)
-- Djordje Pesut (djordje dot pesut at imgtec dot com)
-- Hui Su (huisu at google dot com)
-- Ilya Kurdyukov (jpegqs at gmail dot com)
-- Ingvar Stepanyan (rreverser at google dot com)
-- James Zern (jzern at google dot com)
-- Jan Engelhardt (jengelh at medozas dot de)
-- Jehan (jehan at girinstud dot io)
-- Johann Koenig (johann dot koenig at duck dot com)
-- Jovan Zelincevic (jovan dot zelincevic at imgtec dot com)
-- Jyrki Alakuijala (jyrki at google dot com)
-- Konstantin Ivlev (tomskside at gmail dot com)
-- Lode Vandevenne (lode at google dot com)
-- Lou Quillio (louquillio at google dot com)
-- Mans Rullgard (mans at mansr dot com)
-- Marcin Kowalczyk (qrczak at google dot com)
-- Martin Olsson (mnemo at minimum dot se)
-- Mikołaj Zalewski (mikolajz at google dot com)
-- Mislav Bradac (mislavm at google dot com)
-- Nico Weber (thakis at chromium dot org)
-- Noel Chromium (noel at chromium dot org)
-- Oliver Wolff (oliver dot wolff at qt dot io)
-- Owen Rodley (orodley at google dot com)
-- Parag Salasakar (img dot mips1 at gmail dot com)
-- Pascal Massimino (pascal dot massimino at gmail dot com)
-- Paweł Hajdan, Jr (phajdan dot jr at chromium dot org)
-- Pierre Joye (pierre dot php at gmail dot com)
-- Roberto Alanis (alanisbaez at google dot com)
-- Sam Clegg (sbc at chromium dot org)
-- Scott Hancher (seh at google dot com)
-- Scott LaVarnway (slavarnway at google dot com)
-- Scott Talbot (s at chikachow dot org)
-- Slobodan Prijic (slobodan dot prijic at imgtec dot com)
-- Somnath Banerjee (somnath dot banerjee at gmail dot com)
-- Sriraman Tallam (tmsriram at google dot com)
-- Tamar Levy (tamar dot levy at intel dot com)
-- Timothy Gu (timothygu99 at gmail dot com)
-- Urvang Joshi (urvang at google dot com)
-- Vikas Arora (vikasa at google dot com)
-- Vincent Rabaud (vrabaud at google dot com)
-- Vlad Tsyrklevich (vtsyrklevich at chromium dot org)
-- Wan-Teh Chang (wtc at google dot com)
-- Yang Zhang (yang dot zhang at arm dot com)
-- Yannis Guyon (yguyon at google dot com)
-- Zhi An Ng (zhin at chromium dot org)
-
-
-====================File: COPYING====================
-Copyright (c) 2010, Google Inc. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
-
- * Neither the name of Google nor the names of its contributors may
- be used to endorse or promote products derived from this software
- without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-
-====================File: PATENTS====================
-Additional IP Rights Grant (Patents)
-------------------------------------
-
-"These implementations" means the copyrightable works that implement the WebM
-codecs distributed by Google as part of the WebM Project.
-
-Google hereby grants to you a perpetual, worldwide, non-exclusive, no-charge,
-royalty-free, irrevocable (except as stated in this section) patent license to
-make, have made, use, offer to sell, sell, import, transfer, and otherwise
-run, modify and propagate the contents of these implementations of WebM, where
-such license applies only to those patent claims, both currently owned by
-Google and acquired in the future, licensable by Google that are necessarily
-infringed by these implementations of WebM. This grant does not include claims
-that would be infringed only as a consequence of further modification of these
-implementations. If you or your agent or exclusive licensee institute or order
-or agree to the institution of patent litigation or any other patent
-enforcement activity against any entity (including a cross-claim or
-counterclaim in a lawsuit) alleging that any of these implementations of WebM
-or any code incorporated within any of these implementations of WebM
-constitute direct or contributory patent infringement, or inducement of
-patent infringement, then any patent rights granted to you under this License
-for these implementations of WebM shall terminate as of the date such
-litigation is filed.
diff --git a/contrib/libs/libwebp/mux/anim_encode.c b/contrib/libs/libwebp/mux/anim_encode.c
deleted file mode 100644
index a70938e730..0000000000
--- a/contrib/libs/libwebp/mux/anim_encode.c
+++ /dev/null
@@ -1,1585 +0,0 @@
-// Copyright 2014 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// AnimEncoder implementation.
-//
-
-#include <assert.h>
-#include <limits.h>
-#include <math.h> // for pow()
-#include <stdio.h>
-#include <stdlib.h> // for abs()
-
-#include "./animi.h"
-#include "../utils/utils.h"
-#include "../webp/decode.h"
-#include "../webp/encode.h"
-#include "../webp/format_constants.h"
-#include "../webp/mux.h"
-
-#if defined(_MSC_VER) && _MSC_VER < 1900
-#define snprintf _snprintf
-#endif
-
-#define ERROR_STR_MAX_LENGTH 100
-
-//------------------------------------------------------------------------------
-// Internal structs.
-
-// Stores frame rectangle dimensions.
-typedef struct {
- int x_offset_, y_offset_, width_, height_;
-} FrameRectangle;
-
-// Used to store two candidates of encoded data for an animation frame. One of
-// the two will be chosen later.
-typedef struct {
- WebPMuxFrameInfo sub_frame_; // Encoded frame rectangle.
- WebPMuxFrameInfo key_frame_; // Encoded frame if it is a key-frame.
- int is_key_frame_; // True if 'key_frame' has been chosen.
-} EncodedFrame;
-
-struct WebPAnimEncoder {
- const int canvas_width_; // Canvas width.
- const int canvas_height_; // Canvas height.
- const WebPAnimEncoderOptions options_; // Global encoding options.
-
- FrameRectangle prev_rect_; // Previous WebP frame rectangle.
- WebPConfig last_config_; // Cached in case a re-encode is needed.
- WebPConfig last_config_reversed_; // If 'last_config_' uses lossless, then
- // this config uses lossy and vice versa;
- // only valid if 'options_.allow_mixed'
- // is true.
-
- WebPPicture* curr_canvas_; // Only pointer; we don't own memory.
-
- // Canvas buffers.
- WebPPicture curr_canvas_copy_; // Possibly modified current canvas.
- int curr_canvas_copy_modified_; // True if pixels in 'curr_canvas_copy_'
- // differ from those in 'curr_canvas_'.
-
- WebPPicture prev_canvas_; // Previous canvas.
- WebPPicture prev_canvas_disposed_; // Previous canvas disposed to background.
-
- // Encoded data.
- EncodedFrame* encoded_frames_; // Array of encoded frames.
- size_t size_; // Number of allocated frames.
- size_t start_; // Frame start index.
- size_t count_; // Number of valid frames.
- size_t flush_count_; // If >0, 'flush_count' frames starting from
- // 'start' are ready to be added to mux.
-
- // key-frame related.
- int64_t best_delta_; // min(canvas size - frame size) over the frames.
- // Can be negative in certain cases due to
- // transparent pixels in a frame.
- int keyframe_; // Index of selected key-frame relative to 'start_'.
- int count_since_key_frame_; // Frames seen since the last key-frame.
-
- int first_timestamp_; // Timestamp of the first frame.
- int prev_timestamp_; // Timestamp of the last added frame.
- int prev_candidate_undecided_; // True if it's not yet decided if previous
- // frame would be a sub-frame or a key-frame.
-
- // Misc.
- int is_first_frame_; // True if first frame is yet to be added/being added.
- int got_null_frame_; // True if WebPAnimEncoderAdd() has already been called
- // with a NULL frame.
-
- size_t in_frame_count_; // Number of input frames processed so far.
- size_t out_frame_count_; // Number of frames added to mux so far. This may be
- // different from 'in_frame_count_' due to merging.
-
- WebPMux* mux_; // Muxer to assemble the WebP bitstream.
- char error_str_[ERROR_STR_MAX_LENGTH]; // Error string. Empty if no error.
-};
-
-// -----------------------------------------------------------------------------
-// Life of WebPAnimEncoder object.
-
-#define DELTA_INFINITY (1ULL << 32)
-#define KEYFRAME_NONE (-1)
-
-// Reset the counters in the WebPAnimEncoder.
-static void ResetCounters(WebPAnimEncoder* const enc) {
- enc->start_ = 0;
- enc->count_ = 0;
- enc->flush_count_ = 0;
- enc->best_delta_ = DELTA_INFINITY;
- enc->keyframe_ = KEYFRAME_NONE;
-}
-
-static void DisableKeyframes(WebPAnimEncoderOptions* const enc_options) {
- enc_options->kmax = INT_MAX;
- enc_options->kmin = enc_options->kmax - 1;
-}
-
-#define MAX_CACHED_FRAMES 30
-
-static void SanitizeEncoderOptions(WebPAnimEncoderOptions* const enc_options) {
- int print_warning = enc_options->verbose;
-
- if (enc_options->minimize_size) {
- DisableKeyframes(enc_options);
- }
-
- if (enc_options->kmax == 1) { // All frames will be key-frames.
- enc_options->kmin = 0;
- enc_options->kmax = 0;
- return;
- } else if (enc_options->kmax <= 0) {
- DisableKeyframes(enc_options);
- print_warning = 0;
- }
-
- if (enc_options->kmin >= enc_options->kmax) {
- enc_options->kmin = enc_options->kmax - 1;
- if (print_warning) {
- fprintf(stderr, "WARNING: Setting kmin = %d, so that kmin < kmax.\n",
- enc_options->kmin);
- }
- } else {
- const int kmin_limit = enc_options->kmax / 2 + 1;
- if (enc_options->kmin < kmin_limit && kmin_limit < enc_options->kmax) {
- // This ensures that enc.keyframe + kmin >= kmax is always true. So, we
- // can flush all the frames in the 'count_since_key_frame == kmax' case.
- enc_options->kmin = kmin_limit;
- if (print_warning) {
- fprintf(stderr,
- "WARNING: Setting kmin = %d, so that kmin >= kmax / 2 + 1.\n",
- enc_options->kmin);
- }
- }
- }
- // Limit the max number of frames that are allocated.
- if (enc_options->kmax - enc_options->kmin > MAX_CACHED_FRAMES) {
- enc_options->kmin = enc_options->kmax - MAX_CACHED_FRAMES;
- if (print_warning) {
- fprintf(stderr,
- "WARNING: Setting kmin = %d, so that kmax - kmin <= %d.\n",
- enc_options->kmin, MAX_CACHED_FRAMES);
- }
- }
- assert(enc_options->kmin < enc_options->kmax);
-}
-
-#undef MAX_CACHED_FRAMES
-
-static void DefaultEncoderOptions(WebPAnimEncoderOptions* const enc_options) {
- enc_options->anim_params.loop_count = 0;
- enc_options->anim_params.bgcolor = 0xffffffff; // White.
- enc_options->minimize_size = 0;
- DisableKeyframes(enc_options);
- enc_options->allow_mixed = 0;
- enc_options->verbose = 0;
-}
-
-int WebPAnimEncoderOptionsInitInternal(WebPAnimEncoderOptions* enc_options,
- int abi_version) {
- if (enc_options == NULL ||
- WEBP_ABI_IS_INCOMPATIBLE(abi_version, WEBP_MUX_ABI_VERSION)) {
- return 0;
- }
- DefaultEncoderOptions(enc_options);
- return 1;
-}
-
-// This starting value is more fit to WebPCleanupTransparentAreaLossless().
-#define TRANSPARENT_COLOR 0x00000000
-
-static void ClearRectangle(WebPPicture* const picture,
- int left, int top, int width, int height) {
- int j;
- for (j = top; j < top + height; ++j) {
- uint32_t* const dst = picture->argb + j * picture->argb_stride;
- int i;
- for (i = left; i < left + width; ++i) {
- dst[i] = TRANSPARENT_COLOR;
- }
- }
-}
-
-static void WebPUtilClearPic(WebPPicture* const picture,
- const FrameRectangle* const rect) {
- if (rect != NULL) {
- ClearRectangle(picture, rect->x_offset_, rect->y_offset_,
- rect->width_, rect->height_);
- } else {
- ClearRectangle(picture, 0, 0, picture->width, picture->height);
- }
-}
-
-static void MarkNoError(WebPAnimEncoder* const enc) {
- enc->error_str_[0] = '\0'; // Empty string.
-}
-
-static void MarkError(WebPAnimEncoder* const enc, const char* str) {
- if (snprintf(enc->error_str_, ERROR_STR_MAX_LENGTH, "%s.", str) < 0) {
- assert(0); // FIX ME!
- }
-}
-
-static void MarkError2(WebPAnimEncoder* const enc,
- const char* str, int error_code) {
- if (snprintf(enc->error_str_, ERROR_STR_MAX_LENGTH, "%s: %d.", str,
- error_code) < 0) {
- assert(0); // FIX ME!
- }
-}
-
-WebPAnimEncoder* WebPAnimEncoderNewInternal(
- int width, int height, const WebPAnimEncoderOptions* enc_options,
- int abi_version) {
- WebPAnimEncoder* enc;
-
- if (WEBP_ABI_IS_INCOMPATIBLE(abi_version, WEBP_MUX_ABI_VERSION)) {
- return NULL;
- }
- if (width <= 0 || height <= 0 ||
- (width * (uint64_t)height) >= MAX_IMAGE_AREA) {
- return NULL;
- }
-
- enc = (WebPAnimEncoder*)WebPSafeCalloc(1, sizeof(*enc));
- if (enc == NULL) return NULL;
- MarkNoError(enc);
-
- // Dimensions and options.
- *(int*)&enc->canvas_width_ = width;
- *(int*)&enc->canvas_height_ = height;
- if (enc_options != NULL) {
- *(WebPAnimEncoderOptions*)&enc->options_ = *enc_options;
- SanitizeEncoderOptions((WebPAnimEncoderOptions*)&enc->options_);
- } else {
- DefaultEncoderOptions((WebPAnimEncoderOptions*)&enc->options_);
- }
-
- // Canvas buffers.
- if (!WebPPictureInit(&enc->curr_canvas_copy_) ||
- !WebPPictureInit(&enc->prev_canvas_) ||
- !WebPPictureInit(&enc->prev_canvas_disposed_)) {
- goto Err;
- }
- enc->curr_canvas_copy_.width = width;
- enc->curr_canvas_copy_.height = height;
- enc->curr_canvas_copy_.use_argb = 1;
- if (!WebPPictureAlloc(&enc->curr_canvas_copy_) ||
- !WebPPictureCopy(&enc->curr_canvas_copy_, &enc->prev_canvas_) ||
- !WebPPictureCopy(&enc->curr_canvas_copy_, &enc->prev_canvas_disposed_)) {
- goto Err;
- }
- WebPUtilClearPic(&enc->prev_canvas_, NULL);
- enc->curr_canvas_copy_modified_ = 1;
-
- // Encoded frames.
- ResetCounters(enc);
- // Note: one extra storage is for the previous frame.
- enc->size_ = enc->options_.kmax - enc->options_.kmin + 1;
- // We need space for at least 2 frames. But when kmin, kmax are both zero,
- // enc->size_ will be 1. So we handle that special case below.
- if (enc->size_ < 2) enc->size_ = 2;
- enc->encoded_frames_ =
- (EncodedFrame*)WebPSafeCalloc(enc->size_, sizeof(*enc->encoded_frames_));
- if (enc->encoded_frames_ == NULL) goto Err;
-
- enc->mux_ = WebPMuxNew();
- if (enc->mux_ == NULL) goto Err;
-
- enc->count_since_key_frame_ = 0;
- enc->first_timestamp_ = 0;
- enc->prev_timestamp_ = 0;
- enc->prev_candidate_undecided_ = 0;
- enc->is_first_frame_ = 1;
- enc->got_null_frame_ = 0;
-
- return enc; // All OK.
-
- Err:
- WebPAnimEncoderDelete(enc);
- return NULL;
-}
-
-// Release the data contained by 'encoded_frame'.
-static void FrameRelease(EncodedFrame* const encoded_frame) {
- if (encoded_frame != NULL) {
- WebPDataClear(&encoded_frame->sub_frame_.bitstream);
- WebPDataClear(&encoded_frame->key_frame_.bitstream);
- memset(encoded_frame, 0, sizeof(*encoded_frame));
- }
-}
-
-void WebPAnimEncoderDelete(WebPAnimEncoder* enc) {
- if (enc != NULL) {
- WebPPictureFree(&enc->curr_canvas_copy_);
- WebPPictureFree(&enc->prev_canvas_);
- WebPPictureFree(&enc->prev_canvas_disposed_);
- if (enc->encoded_frames_ != NULL) {
- size_t i;
- for (i = 0; i < enc->size_; ++i) {
- FrameRelease(&enc->encoded_frames_[i]);
- }
- WebPSafeFree(enc->encoded_frames_);
- }
- WebPMuxDelete(enc->mux_);
- WebPSafeFree(enc);
- }
-}
-
-// -----------------------------------------------------------------------------
-// Frame addition.
-
-// Returns cached frame at the given 'position'.
-static EncodedFrame* GetFrame(const WebPAnimEncoder* const enc,
- size_t position) {
- assert(enc->start_ + position < enc->size_);
- return &enc->encoded_frames_[enc->start_ + position];
-}
-
-typedef int (*ComparePixelsFunc)(const uint32_t*, int, const uint32_t*, int,
- int, int);
-
-// Returns true if 'length' number of pixels in 'src' and 'dst' are equal,
-// assuming the given step sizes between pixels.
-// 'max_allowed_diff' is unused and only there to allow function pointer use.
-static WEBP_INLINE int ComparePixelsLossless(const uint32_t* src, int src_step,
- const uint32_t* dst, int dst_step,
- int length, int max_allowed_diff) {
- (void)max_allowed_diff;
- assert(length > 0);
- while (length-- > 0) {
- if (*src != *dst) {
- return 0;
- }
- src += src_step;
- dst += dst_step;
- }
- return 1;
-}
-
-// Helper to check if each channel in 'src' and 'dst' is at most off by
-// 'max_allowed_diff'.
-static WEBP_INLINE int PixelsAreSimilar(uint32_t src, uint32_t dst,
- int max_allowed_diff) {
- const int src_a = (src >> 24) & 0xff;
- const int src_r = (src >> 16) & 0xff;
- const int src_g = (src >> 8) & 0xff;
- const int src_b = (src >> 0) & 0xff;
- const int dst_a = (dst >> 24) & 0xff;
- const int dst_r = (dst >> 16) & 0xff;
- const int dst_g = (dst >> 8) & 0xff;
- const int dst_b = (dst >> 0) & 0xff;
-
- return (src_a == dst_a) &&
- (abs(src_r - dst_r) * dst_a <= (max_allowed_diff * 255)) &&
- (abs(src_g - dst_g) * dst_a <= (max_allowed_diff * 255)) &&
- (abs(src_b - dst_b) * dst_a <= (max_allowed_diff * 255));
-}
-
-// Returns true if 'length' number of pixels in 'src' and 'dst' are within an
-// error bound, assuming the given step sizes between pixels.
-static WEBP_INLINE int ComparePixelsLossy(const uint32_t* src, int src_step,
- const uint32_t* dst, int dst_step,
- int length, int max_allowed_diff) {
- assert(length > 0);
- while (length-- > 0) {
- if (!PixelsAreSimilar(*src, *dst, max_allowed_diff)) {
- return 0;
- }
- src += src_step;
- dst += dst_step;
- }
- return 1;
-}
-
-static int IsEmptyRect(const FrameRectangle* const rect) {
- return (rect->width_ == 0) || (rect->height_ == 0);
-}
-
-static int QualityToMaxDiff(float quality) {
- const double val = pow(quality / 100., 0.5);
- const double max_diff = 31 * (1 - val) + 1 * val;
- return (int)(max_diff + 0.5);
-}
-
-// Assumes that an initial valid guess of change rectangle 'rect' is passed.
-static void MinimizeChangeRectangle(const WebPPicture* const src,
- const WebPPicture* const dst,
- FrameRectangle* const rect,
- int is_lossless, float quality) {
- int i, j;
- const ComparePixelsFunc compare_pixels =
- is_lossless ? ComparePixelsLossless : ComparePixelsLossy;
- const int max_allowed_diff_lossy = QualityToMaxDiff(quality);
- const int max_allowed_diff = is_lossless ? 0 : max_allowed_diff_lossy;
-
- // Assumption/correctness checks.
- assert(src->width == dst->width && src->height == dst->height);
- assert(rect->x_offset_ + rect->width_ <= dst->width);
- assert(rect->y_offset_ + rect->height_ <= dst->height);
-
- // Left boundary.
- for (i = rect->x_offset_; i < rect->x_offset_ + rect->width_; ++i) {
- const uint32_t* const src_argb =
- &src->argb[rect->y_offset_ * src->argb_stride + i];
- const uint32_t* const dst_argb =
- &dst->argb[rect->y_offset_ * dst->argb_stride + i];
- if (compare_pixels(src_argb, src->argb_stride, dst_argb, dst->argb_stride,
- rect->height_, max_allowed_diff)) {
- --rect->width_; // Redundant column.
- ++rect->x_offset_;
- } else {
- break;
- }
- }
- if (rect->width_ == 0) goto NoChange;
-
- // Right boundary.
- for (i = rect->x_offset_ + rect->width_ - 1; i >= rect->x_offset_; --i) {
- const uint32_t* const src_argb =
- &src->argb[rect->y_offset_ * src->argb_stride + i];
- const uint32_t* const dst_argb =
- &dst->argb[rect->y_offset_ * dst->argb_stride + i];
- if (compare_pixels(src_argb, src->argb_stride, dst_argb, dst->argb_stride,
- rect->height_, max_allowed_diff)) {
- --rect->width_; // Redundant column.
- } else {
- break;
- }
- }
- if (rect->width_ == 0) goto NoChange;
-
- // Top boundary.
- for (j = rect->y_offset_; j < rect->y_offset_ + rect->height_; ++j) {
- const uint32_t* const src_argb =
- &src->argb[j * src->argb_stride + rect->x_offset_];
- const uint32_t* const dst_argb =
- &dst->argb[j * dst->argb_stride + rect->x_offset_];
- if (compare_pixels(src_argb, 1, dst_argb, 1, rect->width_,
- max_allowed_diff)) {
- --rect->height_; // Redundant row.
- ++rect->y_offset_;
- } else {
- break;
- }
- }
- if (rect->height_ == 0) goto NoChange;
-
- // Bottom boundary.
- for (j = rect->y_offset_ + rect->height_ - 1; j >= rect->y_offset_; --j) {
- const uint32_t* const src_argb =
- &src->argb[j * src->argb_stride + rect->x_offset_];
- const uint32_t* const dst_argb =
- &dst->argb[j * dst->argb_stride + rect->x_offset_];
- if (compare_pixels(src_argb, 1, dst_argb, 1, rect->width_,
- max_allowed_diff)) {
- --rect->height_; // Redundant row.
- } else {
- break;
- }
- }
- if (rect->height_ == 0) goto NoChange;
-
- if (IsEmptyRect(rect)) {
- NoChange:
- rect->x_offset_ = 0;
- rect->y_offset_ = 0;
- rect->width_ = 0;
- rect->height_ = 0;
- }
-}
-
-// Snap rectangle to even offsets (and adjust dimensions if needed).
-static WEBP_INLINE void SnapToEvenOffsets(FrameRectangle* const rect) {
- rect->width_ += (rect->x_offset_ & 1);
- rect->height_ += (rect->y_offset_ & 1);
- rect->x_offset_ &= ~1;
- rect->y_offset_ &= ~1;
-}
-
-typedef struct {
- int should_try_; // Should try this set of parameters.
- int empty_rect_allowed_; // Frame with empty rectangle can be skipped.
- FrameRectangle rect_ll_; // Frame rectangle for lossless compression.
- WebPPicture sub_frame_ll_; // Sub-frame pic for lossless compression.
- FrameRectangle rect_lossy_; // Frame rectangle for lossy compression.
- // Could be smaller than rect_ll_ as pixels
- // with small diffs can be ignored.
- WebPPicture sub_frame_lossy_; // Sub-frame pic for lossless compression.
-} SubFrameParams;
-
-static int SubFrameParamsInit(SubFrameParams* const params,
- int should_try, int empty_rect_allowed) {
- params->should_try_ = should_try;
- params->empty_rect_allowed_ = empty_rect_allowed;
- if (!WebPPictureInit(&params->sub_frame_ll_) ||
- !WebPPictureInit(&params->sub_frame_lossy_)) {
- return 0;
- }
- return 1;
-}
-
-static void SubFrameParamsFree(SubFrameParams* const params) {
- WebPPictureFree(&params->sub_frame_ll_);
- WebPPictureFree(&params->sub_frame_lossy_);
-}
-
-// Given previous and current canvas, picks the optimal rectangle for the
-// current frame based on 'is_lossless' and other parameters. Assumes that the
-// initial guess 'rect' is valid.
-static int GetSubRect(const WebPPicture* const prev_canvas,
- const WebPPicture* const curr_canvas, int is_key_frame,
- int is_first_frame, int empty_rect_allowed,
- int is_lossless, float quality,
- FrameRectangle* const rect,
- WebPPicture* const sub_frame) {
- if (!is_key_frame || is_first_frame) { // Optimize frame rectangle.
- // Note: This behaves as expected for first frame, as 'prev_canvas' is
- // initialized to a fully transparent canvas in the beginning.
- MinimizeChangeRectangle(prev_canvas, curr_canvas, rect,
- is_lossless, quality);
- }
-
- if (IsEmptyRect(rect)) {
- if (empty_rect_allowed) { // No need to get 'sub_frame'.
- return 1;
- } else { // Force a 1x1 rectangle.
- rect->width_ = 1;
- rect->height_ = 1;
- assert(rect->x_offset_ == 0);
- assert(rect->y_offset_ == 0);
- }
- }
-
- SnapToEvenOffsets(rect);
- return WebPPictureView(curr_canvas, rect->x_offset_, rect->y_offset_,
- rect->width_, rect->height_, sub_frame);
-}
-
-// Picks optimal frame rectangle for both lossless and lossy compression. The
-// initial guess for frame rectangles will be the full canvas.
-static int GetSubRects(const WebPPicture* const prev_canvas,
- const WebPPicture* const curr_canvas, int is_key_frame,
- int is_first_frame, float quality,
- SubFrameParams* const params) {
- // Lossless frame rectangle.
- params->rect_ll_.x_offset_ = 0;
- params->rect_ll_.y_offset_ = 0;
- params->rect_ll_.width_ = curr_canvas->width;
- params->rect_ll_.height_ = curr_canvas->height;
- if (!GetSubRect(prev_canvas, curr_canvas, is_key_frame, is_first_frame,
- params->empty_rect_allowed_, 1, quality,
- &params->rect_ll_, &params->sub_frame_ll_)) {
- return 0;
- }
- // Lossy frame rectangle.
- params->rect_lossy_ = params->rect_ll_; // seed with lossless rect.
- return GetSubRect(prev_canvas, curr_canvas, is_key_frame, is_first_frame,
- params->empty_rect_allowed_, 0, quality,
- &params->rect_lossy_, &params->sub_frame_lossy_);
-}
-
-static WEBP_INLINE int clip(int v, int min_v, int max_v) {
- return (v < min_v) ? min_v : (v > max_v) ? max_v : v;
-}
-
-int WebPAnimEncoderRefineRect(
- const WebPPicture* const prev_canvas, const WebPPicture* const curr_canvas,
- int is_lossless, float quality, int* const x_offset, int* const y_offset,
- int* const width, int* const height) {
- FrameRectangle rect;
- const int right = clip(*x_offset + *width, 0, curr_canvas->width);
- const int left = clip(*x_offset, 0, curr_canvas->width - 1);
- const int bottom = clip(*y_offset + *height, 0, curr_canvas->height);
- const int top = clip(*y_offset, 0, curr_canvas->height - 1);
- if (prev_canvas == NULL || curr_canvas == NULL ||
- prev_canvas->width != curr_canvas->width ||
- prev_canvas->height != curr_canvas->height ||
- !prev_canvas->use_argb || !curr_canvas->use_argb) {
- return 0;
- }
- rect.x_offset_ = left;
- rect.y_offset_ = top;
- rect.width_ = clip(right - left, 0, curr_canvas->width - rect.x_offset_);
- rect.height_ = clip(bottom - top, 0, curr_canvas->height - rect.y_offset_);
- MinimizeChangeRectangle(prev_canvas, curr_canvas, &rect, is_lossless,
- quality);
- SnapToEvenOffsets(&rect);
- *x_offset = rect.x_offset_;
- *y_offset = rect.y_offset_;
- *width = rect.width_;
- *height = rect.height_;
- return 1;
-}
-
-static void DisposeFrameRectangle(int dispose_method,
- const FrameRectangle* const rect,
- WebPPicture* const curr_canvas) {
- assert(rect != NULL);
- if (dispose_method == WEBP_MUX_DISPOSE_BACKGROUND) {
- WebPUtilClearPic(curr_canvas, rect);
- }
-}
-
-static uint32_t RectArea(const FrameRectangle* const rect) {
- return (uint32_t)rect->width_ * rect->height_;
-}
-
-static int IsLosslessBlendingPossible(const WebPPicture* const src,
- const WebPPicture* const dst,
- const FrameRectangle* const rect) {
- int i, j;
- assert(src->width == dst->width && src->height == dst->height);
- assert(rect->x_offset_ + rect->width_ <= dst->width);
- assert(rect->y_offset_ + rect->height_ <= dst->height);
- for (j = rect->y_offset_; j < rect->y_offset_ + rect->height_; ++j) {
- for (i = rect->x_offset_; i < rect->x_offset_ + rect->width_; ++i) {
- const uint32_t src_pixel = src->argb[j * src->argb_stride + i];
- const uint32_t dst_pixel = dst->argb[j * dst->argb_stride + i];
- const uint32_t dst_alpha = dst_pixel >> 24;
- if (dst_alpha != 0xff && src_pixel != dst_pixel) {
- // In this case, if we use blending, we can't attain the desired
- // 'dst_pixel' value for this pixel. So, blending is not possible.
- return 0;
- }
- }
- }
- return 1;
-}
-
-static int IsLossyBlendingPossible(const WebPPicture* const src,
- const WebPPicture* const dst,
- const FrameRectangle* const rect,
- float quality) {
- const int max_allowed_diff_lossy = QualityToMaxDiff(quality);
- int i, j;
- assert(src->width == dst->width && src->height == dst->height);
- assert(rect->x_offset_ + rect->width_ <= dst->width);
- assert(rect->y_offset_ + rect->height_ <= dst->height);
- for (j = rect->y_offset_; j < rect->y_offset_ + rect->height_; ++j) {
- for (i = rect->x_offset_; i < rect->x_offset_ + rect->width_; ++i) {
- const uint32_t src_pixel = src->argb[j * src->argb_stride + i];
- const uint32_t dst_pixel = dst->argb[j * dst->argb_stride + i];
- const uint32_t dst_alpha = dst_pixel >> 24;
- if (dst_alpha != 0xff &&
- !PixelsAreSimilar(src_pixel, dst_pixel, max_allowed_diff_lossy)) {
- // In this case, if we use blending, we can't attain the desired
- // 'dst_pixel' value for this pixel. So, blending is not possible.
- return 0;
- }
- }
- }
- return 1;
-}
-
-// For pixels in 'rect', replace those pixels in 'dst' that are same as 'src' by
-// transparent pixels.
-// Returns true if at least one pixel gets modified.
-static int IncreaseTransparency(const WebPPicture* const src,
- const FrameRectangle* const rect,
- WebPPicture* const dst) {
- int i, j;
- int modified = 0;
- assert(src != NULL && dst != NULL && rect != NULL);
- assert(src->width == dst->width && src->height == dst->height);
- for (j = rect->y_offset_; j < rect->y_offset_ + rect->height_; ++j) {
- const uint32_t* const psrc = src->argb + j * src->argb_stride;
- uint32_t* const pdst = dst->argb + j * dst->argb_stride;
- for (i = rect->x_offset_; i < rect->x_offset_ + rect->width_; ++i) {
- if (psrc[i] == pdst[i] && pdst[i] != TRANSPARENT_COLOR) {
- pdst[i] = TRANSPARENT_COLOR;
- modified = 1;
- }
- }
- }
- return modified;
-}
-
-#undef TRANSPARENT_COLOR
-
-// Replace similar blocks of pixels by a 'see-through' transparent block
-// with uniform average color.
-// Assumes lossy compression is being used.
-// Returns true if at least one pixel gets modified.
-static int FlattenSimilarBlocks(const WebPPicture* const src,
- const FrameRectangle* const rect,
- WebPPicture* const dst, float quality) {
- const int max_allowed_diff_lossy = QualityToMaxDiff(quality);
- int i, j;
- int modified = 0;
- const int block_size = 8;
- const int y_start = (rect->y_offset_ + block_size) & ~(block_size - 1);
- const int y_end = (rect->y_offset_ + rect->height_) & ~(block_size - 1);
- const int x_start = (rect->x_offset_ + block_size) & ~(block_size - 1);
- const int x_end = (rect->x_offset_ + rect->width_) & ~(block_size - 1);
- assert(src != NULL && dst != NULL && rect != NULL);
- assert(src->width == dst->width && src->height == dst->height);
- assert((block_size & (block_size - 1)) == 0); // must be a power of 2
- // Iterate over each block and count similar pixels.
- for (j = y_start; j < y_end; j += block_size) {
- for (i = x_start; i < x_end; i += block_size) {
- int cnt = 0;
- int avg_r = 0, avg_g = 0, avg_b = 0;
- int x, y;
- const uint32_t* const psrc = src->argb + j * src->argb_stride + i;
- uint32_t* const pdst = dst->argb + j * dst->argb_stride + i;
- for (y = 0; y < block_size; ++y) {
- for (x = 0; x < block_size; ++x) {
- const uint32_t src_pixel = psrc[x + y * src->argb_stride];
- const int alpha = src_pixel >> 24;
- if (alpha == 0xff &&
- PixelsAreSimilar(src_pixel, pdst[x + y * dst->argb_stride],
- max_allowed_diff_lossy)) {
- ++cnt;
- avg_r += (src_pixel >> 16) & 0xff;
- avg_g += (src_pixel >> 8) & 0xff;
- avg_b += (src_pixel >> 0) & 0xff;
- }
- }
- }
- // If we have a fully similar block, we replace it with an
- // average transparent block. This compresses better in lossy mode.
- if (cnt == block_size * block_size) {
- const uint32_t color = (0x00 << 24) |
- ((avg_r / cnt) << 16) |
- ((avg_g / cnt) << 8) |
- ((avg_b / cnt) << 0);
- for (y = 0; y < block_size; ++y) {
- for (x = 0; x < block_size; ++x) {
- pdst[x + y * dst->argb_stride] = color;
- }
- }
- modified = 1;
- }
- }
- }
- return modified;
-}
-
-static int EncodeFrame(const WebPConfig* const config, WebPPicture* const pic,
- WebPMemoryWriter* const memory) {
- pic->use_argb = 1;
- pic->writer = WebPMemoryWrite;
- pic->custom_ptr = memory;
- if (!WebPEncode(config, pic)) {
- return 0;
- }
- return 1;
-}
-
-// Struct representing a candidate encoded frame including its metadata.
-typedef struct {
- WebPMemoryWriter mem_;
- WebPMuxFrameInfo info_;
- FrameRectangle rect_;
- int evaluate_; // True if this candidate should be evaluated.
-} Candidate;
-
-// Generates a candidate encoded frame given a picture and metadata.
-static WebPEncodingError EncodeCandidate(WebPPicture* const sub_frame,
- const FrameRectangle* const rect,
- const WebPConfig* const encoder_config,
- int use_blending,
- Candidate* const candidate) {
- WebPConfig config = *encoder_config;
- WebPEncodingError error_code = VP8_ENC_OK;
- assert(candidate != NULL);
- memset(candidate, 0, sizeof(*candidate));
-
- // Set frame rect and info.
- candidate->rect_ = *rect;
- candidate->info_.id = WEBP_CHUNK_ANMF;
- candidate->info_.x_offset = rect->x_offset_;
- candidate->info_.y_offset = rect->y_offset_;
- candidate->info_.dispose_method = WEBP_MUX_DISPOSE_NONE; // Set later.
- candidate->info_.blend_method =
- use_blending ? WEBP_MUX_BLEND : WEBP_MUX_NO_BLEND;
- candidate->info_.duration = 0; // Set in next call to WebPAnimEncoderAdd().
-
- // Encode picture.
- WebPMemoryWriterInit(&candidate->mem_);
-
- if (!config.lossless && use_blending) {
- // Disable filtering to avoid blockiness in reconstructed frames at the
- // time of decoding.
- config.autofilter = 0;
- config.filter_strength = 0;
- }
- if (!EncodeFrame(&config, sub_frame, &candidate->mem_)) {
- error_code = sub_frame->error_code;
- goto Err;
- }
-
- candidate->evaluate_ = 1;
- return error_code;
-
- Err:
- WebPMemoryWriterClear(&candidate->mem_);
- return error_code;
-}
-
-static void CopyCurrentCanvas(WebPAnimEncoder* const enc) {
- if (enc->curr_canvas_copy_modified_) {
- WebPCopyPixels(enc->curr_canvas_, &enc->curr_canvas_copy_);
- enc->curr_canvas_copy_.progress_hook = enc->curr_canvas_->progress_hook;
- enc->curr_canvas_copy_.user_data = enc->curr_canvas_->user_data;
- enc->curr_canvas_copy_modified_ = 0;
- }
-}
-
-enum {
- LL_DISP_NONE = 0,
- LL_DISP_BG,
- LOSSY_DISP_NONE,
- LOSSY_DISP_BG,
- CANDIDATE_COUNT
-};
-
-#define MIN_COLORS_LOSSY 31 // Don't try lossy below this threshold.
-#define MAX_COLORS_LOSSLESS 194 // Don't try lossless above this threshold.
-
-// Generates candidates for a given dispose method given pre-filled sub-frame
-// 'params'.
-static WebPEncodingError GenerateCandidates(
- WebPAnimEncoder* const enc, Candidate candidates[CANDIDATE_COUNT],
- WebPMuxAnimDispose dispose_method, int is_lossless, int is_key_frame,
- SubFrameParams* const params,
- const WebPConfig* const config_ll, const WebPConfig* const config_lossy) {
- WebPEncodingError error_code = VP8_ENC_OK;
- const int is_dispose_none = (dispose_method == WEBP_MUX_DISPOSE_NONE);
- Candidate* const candidate_ll =
- is_dispose_none ? &candidates[LL_DISP_NONE] : &candidates[LL_DISP_BG];
- Candidate* const candidate_lossy = is_dispose_none
- ? &candidates[LOSSY_DISP_NONE]
- : &candidates[LOSSY_DISP_BG];
- WebPPicture* const curr_canvas = &enc->curr_canvas_copy_;
- const WebPPicture* const prev_canvas =
- is_dispose_none ? &enc->prev_canvas_ : &enc->prev_canvas_disposed_;
- int use_blending_ll, use_blending_lossy;
- int evaluate_ll, evaluate_lossy;
-
- CopyCurrentCanvas(enc);
- use_blending_ll =
- !is_key_frame &&
- IsLosslessBlendingPossible(prev_canvas, curr_canvas, &params->rect_ll_);
- use_blending_lossy =
- !is_key_frame &&
- IsLossyBlendingPossible(prev_canvas, curr_canvas, &params->rect_lossy_,
- config_lossy->quality);
-
- // Pick candidates to be tried.
- if (!enc->options_.allow_mixed) {
- evaluate_ll = is_lossless;
- evaluate_lossy = !is_lossless;
- } else if (enc->options_.minimize_size) {
- evaluate_ll = 1;
- evaluate_lossy = 1;
- } else { // Use a heuristic for trying lossless and/or lossy compression.
- const int num_colors = WebPGetColorPalette(&params->sub_frame_ll_, NULL);
- evaluate_ll = (num_colors < MAX_COLORS_LOSSLESS);
- evaluate_lossy = (num_colors >= MIN_COLORS_LOSSY);
- }
-
- // Generate candidates.
- if (evaluate_ll) {
- CopyCurrentCanvas(enc);
- if (use_blending_ll) {
- enc->curr_canvas_copy_modified_ =
- IncreaseTransparency(prev_canvas, &params->rect_ll_, curr_canvas);
- }
- error_code = EncodeCandidate(&params->sub_frame_ll_, &params->rect_ll_,
- config_ll, use_blending_ll, candidate_ll);
- if (error_code != VP8_ENC_OK) return error_code;
- }
- if (evaluate_lossy) {
- CopyCurrentCanvas(enc);
- if (use_blending_lossy) {
- enc->curr_canvas_copy_modified_ =
- FlattenSimilarBlocks(prev_canvas, &params->rect_lossy_, curr_canvas,
- config_lossy->quality);
- }
- error_code =
- EncodeCandidate(&params->sub_frame_lossy_, &params->rect_lossy_,
- config_lossy, use_blending_lossy, candidate_lossy);
- if (error_code != VP8_ENC_OK) return error_code;
- enc->curr_canvas_copy_modified_ = 1;
- }
- return error_code;
-}
-
-#undef MIN_COLORS_LOSSY
-#undef MAX_COLORS_LOSSLESS
-
-static void GetEncodedData(const WebPMemoryWriter* const memory,
- WebPData* const encoded_data) {
- encoded_data->bytes = memory->mem;
- encoded_data->size = memory->size;
-}
-
-// Sets dispose method of the previous frame to be 'dispose_method'.
-static void SetPreviousDisposeMethod(WebPAnimEncoder* const enc,
- WebPMuxAnimDispose dispose_method) {
- const size_t position = enc->count_ - 2;
- EncodedFrame* const prev_enc_frame = GetFrame(enc, position);
- assert(enc->count_ >= 2); // As current and previous frames are in enc.
-
- if (enc->prev_candidate_undecided_) {
- assert(dispose_method == WEBP_MUX_DISPOSE_NONE);
- prev_enc_frame->sub_frame_.dispose_method = dispose_method;
- prev_enc_frame->key_frame_.dispose_method = dispose_method;
- } else {
- WebPMuxFrameInfo* const prev_info = prev_enc_frame->is_key_frame_
- ? &prev_enc_frame->key_frame_
- : &prev_enc_frame->sub_frame_;
- prev_info->dispose_method = dispose_method;
- }
-}
-
-static int IncreasePreviousDuration(WebPAnimEncoder* const enc, int duration) {
- const size_t position = enc->count_ - 1;
- EncodedFrame* const prev_enc_frame = GetFrame(enc, position);
- int new_duration;
-
- assert(enc->count_ >= 1);
- assert(!prev_enc_frame->is_key_frame_ ||
- prev_enc_frame->sub_frame_.duration ==
- prev_enc_frame->key_frame_.duration);
- assert(prev_enc_frame->sub_frame_.duration ==
- (prev_enc_frame->sub_frame_.duration & (MAX_DURATION - 1)));
- assert(duration == (duration & (MAX_DURATION - 1)));
-
- new_duration = prev_enc_frame->sub_frame_.duration + duration;
- if (new_duration >= MAX_DURATION) { // Special case.
- // Separate out previous frame from earlier merged frames to avoid overflow.
- // We add a 1x1 transparent frame for the previous frame, with blending on.
- const FrameRectangle rect = { 0, 0, 1, 1 };
- const uint8_t lossless_1x1_bytes[] = {
- 0x52, 0x49, 0x46, 0x46, 0x14, 0x00, 0x00, 0x00, 0x57, 0x45, 0x42, 0x50,
- 0x56, 0x50, 0x38, 0x4c, 0x08, 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, 0x00,
- 0x10, 0x88, 0x88, 0x08
- };
- const WebPData lossless_1x1 = {
- lossless_1x1_bytes, sizeof(lossless_1x1_bytes)
- };
- const uint8_t lossy_1x1_bytes[] = {
- 0x52, 0x49, 0x46, 0x46, 0x40, 0x00, 0x00, 0x00, 0x57, 0x45, 0x42, 0x50,
- 0x56, 0x50, 0x38, 0x58, 0x0a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x4c, 0x50, 0x48, 0x02, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x56, 0x50, 0x38, 0x20, 0x18, 0x00, 0x00, 0x00,
- 0x30, 0x01, 0x00, 0x9d, 0x01, 0x2a, 0x01, 0x00, 0x01, 0x00, 0x02, 0x00,
- 0x34, 0x25, 0xa4, 0x00, 0x03, 0x70, 0x00, 0xfe, 0xfb, 0xfd, 0x50, 0x00
- };
- const WebPData lossy_1x1 = { lossy_1x1_bytes, sizeof(lossy_1x1_bytes) };
- const int can_use_lossless =
- (enc->last_config_.lossless || enc->options_.allow_mixed);
- EncodedFrame* const curr_enc_frame = GetFrame(enc, enc->count_);
- curr_enc_frame->is_key_frame_ = 0;
- curr_enc_frame->sub_frame_.id = WEBP_CHUNK_ANMF;
- curr_enc_frame->sub_frame_.x_offset = 0;
- curr_enc_frame->sub_frame_.y_offset = 0;
- curr_enc_frame->sub_frame_.dispose_method = WEBP_MUX_DISPOSE_NONE;
- curr_enc_frame->sub_frame_.blend_method = WEBP_MUX_BLEND;
- curr_enc_frame->sub_frame_.duration = duration;
- if (!WebPDataCopy(can_use_lossless ? &lossless_1x1 : &lossy_1x1,
- &curr_enc_frame->sub_frame_.bitstream)) {
- return 0;
- }
- ++enc->count_;
- ++enc->count_since_key_frame_;
- enc->flush_count_ = enc->count_ - 1;
- enc->prev_candidate_undecided_ = 0;
- enc->prev_rect_ = rect;
- } else { // Regular case.
- // Increase duration of the previous frame by 'duration'.
- prev_enc_frame->sub_frame_.duration = new_duration;
- prev_enc_frame->key_frame_.duration = new_duration;
- }
- return 1;
-}
-
-// Pick the candidate encoded frame with smallest size and release other
-// candidates.
-// TODO(later): Perhaps a rough SSIM/PSNR produced by the encoder should
-// also be a criteria, in addition to sizes.
-static void PickBestCandidate(WebPAnimEncoder* const enc,
- Candidate* const candidates, int is_key_frame,
- EncodedFrame* const encoded_frame) {
- int i;
- int best_idx = -1;
- size_t best_size = ~0;
- for (i = 0; i < CANDIDATE_COUNT; ++i) {
- if (candidates[i].evaluate_) {
- const size_t candidate_size = candidates[i].mem_.size;
- if (candidate_size < best_size) {
- best_idx = i;
- best_size = candidate_size;
- }
- }
- }
- assert(best_idx != -1);
- for (i = 0; i < CANDIDATE_COUNT; ++i) {
- if (candidates[i].evaluate_) {
- if (i == best_idx) {
- WebPMuxFrameInfo* const dst = is_key_frame
- ? &encoded_frame->key_frame_
- : &encoded_frame->sub_frame_;
- *dst = candidates[i].info_;
- GetEncodedData(&candidates[i].mem_, &dst->bitstream);
- if (!is_key_frame) {
- // Note: Previous dispose method only matters for non-keyframes.
- // Also, we don't want to modify previous dispose method that was
- // selected when a non key-frame was assumed.
- const WebPMuxAnimDispose prev_dispose_method =
- (best_idx == LL_DISP_NONE || best_idx == LOSSY_DISP_NONE)
- ? WEBP_MUX_DISPOSE_NONE
- : WEBP_MUX_DISPOSE_BACKGROUND;
- SetPreviousDisposeMethod(enc, prev_dispose_method);
- }
- enc->prev_rect_ = candidates[i].rect_; // save for next frame.
- } else {
- WebPMemoryWriterClear(&candidates[i].mem_);
- candidates[i].evaluate_ = 0;
- }
- }
- }
-}
-
-// Depending on the configuration, tries different compressions
-// (lossy/lossless), dispose methods, blending methods etc to encode the current
-// frame and outputs the best one in 'encoded_frame'.
-// 'frame_skipped' will be set to true if this frame should actually be skipped.
-static WebPEncodingError SetFrame(WebPAnimEncoder* const enc,
- const WebPConfig* const config,
- int is_key_frame,
- EncodedFrame* const encoded_frame,
- int* const frame_skipped) {
- int i;
- WebPEncodingError error_code = VP8_ENC_OK;
- const WebPPicture* const curr_canvas = &enc->curr_canvas_copy_;
- const WebPPicture* const prev_canvas = &enc->prev_canvas_;
- Candidate candidates[CANDIDATE_COUNT];
- const int is_lossless = config->lossless;
- const int consider_lossless = is_lossless || enc->options_.allow_mixed;
- const int consider_lossy = !is_lossless || enc->options_.allow_mixed;
- const int is_first_frame = enc->is_first_frame_;
-
- // First frame cannot be skipped as there is no 'previous frame' to merge it
- // to. So, empty rectangle is not allowed for the first frame.
- const int empty_rect_allowed_none = !is_first_frame;
-
- // Even if there is exact pixel match between 'disposed previous canvas' and
- // 'current canvas', we can't skip current frame, as there may not be exact
- // pixel match between 'previous canvas' and 'current canvas'. So, we don't
- // allow empty rectangle in this case.
- const int empty_rect_allowed_bg = 0;
-
- // If current frame is a key-frame, dispose method of previous frame doesn't
- // matter, so we don't try dispose to background.
- // Also, if key-frame insertion is on, and previous frame could be picked as
- // either a sub-frame or a key-frame, then we can't be sure about what frame
- // rectangle would be disposed. In that case too, we don't try dispose to
- // background.
- const int dispose_bg_possible =
- !is_key_frame && !enc->prev_candidate_undecided_;
-
- SubFrameParams dispose_none_params;
- SubFrameParams dispose_bg_params;
-
- WebPConfig config_ll = *config;
- WebPConfig config_lossy = *config;
- config_ll.lossless = 1;
- config_lossy.lossless = 0;
- enc->last_config_ = *config;
- enc->last_config_reversed_ = config->lossless ? config_lossy : config_ll;
- *frame_skipped = 0;
-
- if (!SubFrameParamsInit(&dispose_none_params, 1, empty_rect_allowed_none) ||
- !SubFrameParamsInit(&dispose_bg_params, 0, empty_rect_allowed_bg)) {
- return VP8_ENC_ERROR_INVALID_CONFIGURATION;
- }
-
- memset(candidates, 0, sizeof(candidates));
-
- // Change-rectangle assuming previous frame was DISPOSE_NONE.
- if (!GetSubRects(prev_canvas, curr_canvas, is_key_frame, is_first_frame,
- config_lossy.quality, &dispose_none_params)) {
- error_code = VP8_ENC_ERROR_INVALID_CONFIGURATION;
- goto Err;
- }
-
- if ((consider_lossless && IsEmptyRect(&dispose_none_params.rect_ll_)) ||
- (consider_lossy && IsEmptyRect(&dispose_none_params.rect_lossy_))) {
- // Don't encode the frame at all. Instead, the duration of the previous
- // frame will be increased later.
- assert(empty_rect_allowed_none);
- *frame_skipped = 1;
- goto End;
- }
-
- if (dispose_bg_possible) {
- // Change-rectangle assuming previous frame was DISPOSE_BACKGROUND.
- WebPPicture* const prev_canvas_disposed = &enc->prev_canvas_disposed_;
- WebPCopyPixels(prev_canvas, prev_canvas_disposed);
- DisposeFrameRectangle(WEBP_MUX_DISPOSE_BACKGROUND, &enc->prev_rect_,
- prev_canvas_disposed);
-
- if (!GetSubRects(prev_canvas_disposed, curr_canvas, is_key_frame,
- is_first_frame, config_lossy.quality,
- &dispose_bg_params)) {
- error_code = VP8_ENC_ERROR_INVALID_CONFIGURATION;
- goto Err;
- }
- assert(!IsEmptyRect(&dispose_bg_params.rect_ll_));
- assert(!IsEmptyRect(&dispose_bg_params.rect_lossy_));
-
- if (enc->options_.minimize_size) { // Try both dispose methods.
- dispose_bg_params.should_try_ = 1;
- dispose_none_params.should_try_ = 1;
- } else if ((is_lossless &&
- RectArea(&dispose_bg_params.rect_ll_) <
- RectArea(&dispose_none_params.rect_ll_)) ||
- (!is_lossless &&
- RectArea(&dispose_bg_params.rect_lossy_) <
- RectArea(&dispose_none_params.rect_lossy_))) {
- dispose_bg_params.should_try_ = 1; // Pick DISPOSE_BACKGROUND.
- dispose_none_params.should_try_ = 0;
- }
- }
-
- if (dispose_none_params.should_try_) {
- error_code = GenerateCandidates(
- enc, candidates, WEBP_MUX_DISPOSE_NONE, is_lossless, is_key_frame,
- &dispose_none_params, &config_ll, &config_lossy);
- if (error_code != VP8_ENC_OK) goto Err;
- }
-
- if (dispose_bg_params.should_try_) {
- assert(!enc->is_first_frame_);
- assert(dispose_bg_possible);
- error_code = GenerateCandidates(
- enc, candidates, WEBP_MUX_DISPOSE_BACKGROUND, is_lossless, is_key_frame,
- &dispose_bg_params, &config_ll, &config_lossy);
- if (error_code != VP8_ENC_OK) goto Err;
- }
-
- PickBestCandidate(enc, candidates, is_key_frame, encoded_frame);
-
- goto End;
-
- Err:
- for (i = 0; i < CANDIDATE_COUNT; ++i) {
- if (candidates[i].evaluate_) {
- WebPMemoryWriterClear(&candidates[i].mem_);
- }
- }
-
- End:
- SubFrameParamsFree(&dispose_none_params);
- SubFrameParamsFree(&dispose_bg_params);
- return error_code;
-}
-
-// Calculate the penalty incurred if we encode given frame as a key frame
-// instead of a sub-frame.
-static int64_t KeyFramePenalty(const EncodedFrame* const encoded_frame) {
- return ((int64_t)encoded_frame->key_frame_.bitstream.size -
- encoded_frame->sub_frame_.bitstream.size);
-}
-
-static int CacheFrame(WebPAnimEncoder* const enc,
- const WebPConfig* const config) {
- int ok = 0;
- int frame_skipped = 0;
- WebPEncodingError error_code = VP8_ENC_OK;
- const size_t position = enc->count_;
- EncodedFrame* const encoded_frame = GetFrame(enc, position);
-
- ++enc->count_;
-
- if (enc->is_first_frame_) { // Add this as a key-frame.
- error_code = SetFrame(enc, config, 1, encoded_frame, &frame_skipped);
- if (error_code != VP8_ENC_OK) goto End;
- assert(frame_skipped == 0); // First frame can't be skipped, even if empty.
- assert(position == 0 && enc->count_ == 1);
- encoded_frame->is_key_frame_ = 1;
- enc->flush_count_ = 0;
- enc->count_since_key_frame_ = 0;
- enc->prev_candidate_undecided_ = 0;
- } else {
- ++enc->count_since_key_frame_;
- if (enc->count_since_key_frame_ <= enc->options_.kmin) {
- // Add this as a frame rectangle.
- error_code = SetFrame(enc, config, 0, encoded_frame, &frame_skipped);
- if (error_code != VP8_ENC_OK) goto End;
- if (frame_skipped) goto Skip;
- encoded_frame->is_key_frame_ = 0;
- enc->flush_count_ = enc->count_ - 1;
- enc->prev_candidate_undecided_ = 0;
- } else {
- int64_t curr_delta;
- FrameRectangle prev_rect_key, prev_rect_sub;
-
- // Add this as a frame rectangle to enc.
- error_code = SetFrame(enc, config, 0, encoded_frame, &frame_skipped);
- if (error_code != VP8_ENC_OK) goto End;
- if (frame_skipped) goto Skip;
- prev_rect_sub = enc->prev_rect_;
-
-
- // Add this as a key-frame to enc, too.
- error_code = SetFrame(enc, config, 1, encoded_frame, &frame_skipped);
- if (error_code != VP8_ENC_OK) goto End;
- assert(frame_skipped == 0); // Key-frame cannot be an empty rectangle.
- prev_rect_key = enc->prev_rect_;
-
- // Analyze size difference of the two variants.
- curr_delta = KeyFramePenalty(encoded_frame);
- if (curr_delta <= enc->best_delta_) { // Pick this as the key-frame.
- if (enc->keyframe_ != KEYFRAME_NONE) {
- EncodedFrame* const old_keyframe = GetFrame(enc, enc->keyframe_);
- assert(old_keyframe->is_key_frame_);
- old_keyframe->is_key_frame_ = 0;
- }
- encoded_frame->is_key_frame_ = 1;
- enc->prev_candidate_undecided_ = 1;
- enc->keyframe_ = (int)position;
- enc->best_delta_ = curr_delta;
- enc->flush_count_ = enc->count_ - 1; // We can flush previous frames.
- } else {
- encoded_frame->is_key_frame_ = 0;
- enc->prev_candidate_undecided_ = 0;
- }
- // Note: We need '>=' below because when kmin and kmax are both zero,
- // count_since_key_frame will always be > kmax.
- if (enc->count_since_key_frame_ >= enc->options_.kmax) {
- enc->flush_count_ = enc->count_ - 1;
- enc->count_since_key_frame_ = 0;
- enc->keyframe_ = KEYFRAME_NONE;
- enc->best_delta_ = DELTA_INFINITY;
- }
- if (!enc->prev_candidate_undecided_) {
- enc->prev_rect_ =
- encoded_frame->is_key_frame_ ? prev_rect_key : prev_rect_sub;
- }
- }
- }
-
- // Update previous to previous and previous canvases for next call.
- WebPCopyPixels(enc->curr_canvas_, &enc->prev_canvas_);
- enc->is_first_frame_ = 0;
-
- Skip:
- ok = 1;
- ++enc->in_frame_count_;
-
- End:
- if (!ok || frame_skipped) {
- FrameRelease(encoded_frame);
- // We reset some counters, as the frame addition failed/was skipped.
- --enc->count_;
- if (!enc->is_first_frame_) --enc->count_since_key_frame_;
- if (!ok) {
- MarkError2(enc, "ERROR adding frame. WebPEncodingError", error_code);
- }
- }
- enc->curr_canvas_->error_code = error_code; // report error_code
- assert(ok || error_code != VP8_ENC_OK);
- return ok;
-}
-
-static int FlushFrames(WebPAnimEncoder* const enc) {
- while (enc->flush_count_ > 0) {
- WebPMuxError err;
- EncodedFrame* const curr = GetFrame(enc, 0);
- const WebPMuxFrameInfo* const info =
- curr->is_key_frame_ ? &curr->key_frame_ : &curr->sub_frame_;
- assert(enc->mux_ != NULL);
- err = WebPMuxPushFrame(enc->mux_, info, 1);
- if (err != WEBP_MUX_OK) {
- MarkError2(enc, "ERROR adding frame. WebPMuxError", err);
- return 0;
- }
- if (enc->options_.verbose) {
- fprintf(stderr, "INFO: Added frame. offset:%d,%d dispose:%d blend:%d\n",
- info->x_offset, info->y_offset, info->dispose_method,
- info->blend_method);
- }
- ++enc->out_frame_count_;
- FrameRelease(curr);
- ++enc->start_;
- --enc->flush_count_;
- --enc->count_;
- if (enc->keyframe_ != KEYFRAME_NONE) --enc->keyframe_;
- }
-
- if (enc->count_ == 1 && enc->start_ != 0) {
- // Move enc->start to index 0.
- const int enc_start_tmp = (int)enc->start_;
- EncodedFrame temp = enc->encoded_frames_[0];
- enc->encoded_frames_[0] = enc->encoded_frames_[enc_start_tmp];
- enc->encoded_frames_[enc_start_tmp] = temp;
- FrameRelease(&enc->encoded_frames_[enc_start_tmp]);
- enc->start_ = 0;
- }
- return 1;
-}
-
-#undef DELTA_INFINITY
-#undef KEYFRAME_NONE
-
-int WebPAnimEncoderAdd(WebPAnimEncoder* enc, WebPPicture* frame, int timestamp,
- const WebPConfig* encoder_config) {
- WebPConfig config;
- int ok;
-
- if (enc == NULL) {
- return 0;
- }
- MarkNoError(enc);
-
- if (!enc->is_first_frame_) {
- // Make sure timestamps are non-decreasing (integer wrap-around is OK).
- const uint32_t prev_frame_duration =
- (uint32_t)timestamp - enc->prev_timestamp_;
- if (prev_frame_duration >= MAX_DURATION) {
- if (frame != NULL) {
- frame->error_code = VP8_ENC_ERROR_INVALID_CONFIGURATION;
- }
- MarkError(enc, "ERROR adding frame: timestamps must be non-decreasing");
- return 0;
- }
- if (!IncreasePreviousDuration(enc, (int)prev_frame_duration)) {
- return 0;
- }
- // IncreasePreviousDuration() may add a frame to avoid exceeding
- // MAX_DURATION which could cause CacheFrame() to over read encoded_frames_
- // before the next flush.
- if (enc->count_ == enc->size_ && !FlushFrames(enc)) {
- return 0;
- }
- } else {
- enc->first_timestamp_ = timestamp;
- }
-
- if (frame == NULL) { // Special: last call.
- enc->got_null_frame_ = 1;
- enc->prev_timestamp_ = timestamp;
- return 1;
- }
-
- if (frame->width != enc->canvas_width_ ||
- frame->height != enc->canvas_height_) {
- frame->error_code = VP8_ENC_ERROR_INVALID_CONFIGURATION;
- MarkError(enc, "ERROR adding frame: Invalid frame dimensions");
- return 0;
- }
-
- if (!frame->use_argb) { // Convert frame from YUV(A) to ARGB.
- if (enc->options_.verbose) {
- fprintf(stderr, "WARNING: Converting frame from YUV(A) to ARGB format; "
- "this incurs a small loss.\n");
- }
- if (!WebPPictureYUVAToARGB(frame)) {
- MarkError(enc, "ERROR converting frame from YUV(A) to ARGB");
- return 0;
- }
- }
-
- if (encoder_config != NULL) {
- if (!WebPValidateConfig(encoder_config)) {
- MarkError(enc, "ERROR adding frame: Invalid WebPConfig");
- return 0;
- }
- config = *encoder_config;
- } else {
- WebPConfigInit(&config);
- config.lossless = 1;
- }
- assert(enc->curr_canvas_ == NULL);
- enc->curr_canvas_ = frame; // Store reference.
- assert(enc->curr_canvas_copy_modified_ == 1);
- CopyCurrentCanvas(enc);
-
- ok = CacheFrame(enc, &config) && FlushFrames(enc);
-
- enc->curr_canvas_ = NULL;
- enc->curr_canvas_copy_modified_ = 1;
- if (ok) {
- enc->prev_timestamp_ = timestamp;
- }
- return ok;
-}
-
-// -----------------------------------------------------------------------------
-// Bitstream assembly.
-
-static int DecodeFrameOntoCanvas(const WebPMuxFrameInfo* const frame,
- WebPPicture* const canvas) {
- const WebPData* const image = &frame->bitstream;
- WebPPicture sub_image;
- WebPDecoderConfig config;
- WebPInitDecoderConfig(&config);
- WebPUtilClearPic(canvas, NULL);
- if (WebPGetFeatures(image->bytes, image->size, &config.input) !=
- VP8_STATUS_OK) {
- return 0;
- }
- if (!WebPPictureView(canvas, frame->x_offset, frame->y_offset,
- config.input.width, config.input.height, &sub_image)) {
- return 0;
- }
- config.output.is_external_memory = 1;
- config.output.colorspace = MODE_BGRA;
- config.output.u.RGBA.rgba = (uint8_t*)sub_image.argb;
- config.output.u.RGBA.stride = sub_image.argb_stride * 4;
- config.output.u.RGBA.size = config.output.u.RGBA.stride * sub_image.height;
-
- if (WebPDecode(image->bytes, image->size, &config) != VP8_STATUS_OK) {
- return 0;
- }
- return 1;
-}
-
-static int FrameToFullCanvas(WebPAnimEncoder* const enc,
- const WebPMuxFrameInfo* const frame,
- WebPData* const full_image) {
- WebPPicture* const canvas_buf = &enc->curr_canvas_copy_;
- WebPMemoryWriter mem1, mem2;
- WebPMemoryWriterInit(&mem1);
- WebPMemoryWriterInit(&mem2);
-
- if (!DecodeFrameOntoCanvas(frame, canvas_buf)) goto Err;
- if (!EncodeFrame(&enc->last_config_, canvas_buf, &mem1)) goto Err;
- GetEncodedData(&mem1, full_image);
-
- if (enc->options_.allow_mixed) {
- if (!EncodeFrame(&enc->last_config_reversed_, canvas_buf, &mem2)) goto Err;
- if (mem2.size < mem1.size) {
- GetEncodedData(&mem2, full_image);
- WebPMemoryWriterClear(&mem1);
- } else {
- WebPMemoryWriterClear(&mem2);
- }
- }
- return 1;
-
- Err:
- WebPMemoryWriterClear(&mem1);
- WebPMemoryWriterClear(&mem2);
- return 0;
-}
-
-// Convert a single-frame animation to a non-animated image if appropriate.
-// TODO(urvang): Can we pick one of the two heuristically (based on frame
-// rectangle and/or presence of alpha)?
-static WebPMuxError OptimizeSingleFrame(WebPAnimEncoder* const enc,
- WebPData* const webp_data) {
- WebPMuxError err = WEBP_MUX_OK;
- int canvas_width, canvas_height;
- WebPMuxFrameInfo frame;
- WebPData full_image;
- WebPData webp_data2;
- WebPMux* const mux = WebPMuxCreate(webp_data, 0);
- if (mux == NULL) return WEBP_MUX_BAD_DATA;
- assert(enc->out_frame_count_ == 1);
- WebPDataInit(&frame.bitstream);
- WebPDataInit(&full_image);
- WebPDataInit(&webp_data2);
-
- err = WebPMuxGetFrame(mux, 1, &frame);
- if (err != WEBP_MUX_OK) goto End;
- if (frame.id != WEBP_CHUNK_ANMF) goto End; // Non-animation: nothing to do.
- err = WebPMuxGetCanvasSize(mux, &canvas_width, &canvas_height);
- if (err != WEBP_MUX_OK) goto End;
- if (!FrameToFullCanvas(enc, &frame, &full_image)) {
- err = WEBP_MUX_BAD_DATA;
- goto End;
- }
- err = WebPMuxSetImage(mux, &full_image, 1);
- if (err != WEBP_MUX_OK) goto End;
- err = WebPMuxAssemble(mux, &webp_data2);
- if (err != WEBP_MUX_OK) goto End;
-
- if (webp_data2.size < webp_data->size) { // Pick 'webp_data2' if smaller.
- WebPDataClear(webp_data);
- *webp_data = webp_data2;
- WebPDataInit(&webp_data2);
- }
-
- End:
- WebPDataClear(&frame.bitstream);
- WebPDataClear(&full_image);
- WebPMuxDelete(mux);
- WebPDataClear(&webp_data2);
- return err;
-}
-
-int WebPAnimEncoderAssemble(WebPAnimEncoder* enc, WebPData* webp_data) {
- WebPMux* mux;
- WebPMuxError err;
-
- if (enc == NULL) {
- return 0;
- }
- MarkNoError(enc);
-
- if (webp_data == NULL) {
- MarkError(enc, "ERROR assembling: NULL input");
- return 0;
- }
-
- if (enc->in_frame_count_ == 0) {
- MarkError(enc, "ERROR: No frames to assemble");
- return 0;
- }
-
- if (!enc->got_null_frame_ && enc->in_frame_count_ > 1 && enc->count_ > 0) {
- // set duration of the last frame to be avg of durations of previous frames.
- const double delta_time =
- (uint32_t)enc->prev_timestamp_ - enc->first_timestamp_;
- const int average_duration = (int)(delta_time / (enc->in_frame_count_ - 1));
- if (!IncreasePreviousDuration(enc, average_duration)) {
- return 0;
- }
- }
-
- // Flush any remaining frames.
- enc->flush_count_ = enc->count_;
- if (!FlushFrames(enc)) {
- return 0;
- }
-
- // Set definitive canvas size.
- mux = enc->mux_;
- err = WebPMuxSetCanvasSize(mux, enc->canvas_width_, enc->canvas_height_);
- if (err != WEBP_MUX_OK) goto Err;
-
- err = WebPMuxSetAnimationParams(mux, &enc->options_.anim_params);
- if (err != WEBP_MUX_OK) goto Err;
-
- // Assemble into a WebP bitstream.
- err = WebPMuxAssemble(mux, webp_data);
- if (err != WEBP_MUX_OK) goto Err;
-
- if (enc->out_frame_count_ == 1) {
- err = OptimizeSingleFrame(enc, webp_data);
- if (err != WEBP_MUX_OK) goto Err;
- }
- return 1;
-
- Err:
- MarkError2(enc, "ERROR assembling WebP", err);
- return 0;
-}
-
-const char* WebPAnimEncoderGetError(WebPAnimEncoder* enc) {
- if (enc == NULL) return NULL;
- return enc->error_str_;
-}
-
-// -----------------------------------------------------------------------------
diff --git a/contrib/libs/libwebp/mux/animi.h b/contrib/libs/libwebp/mux/animi.h
deleted file mode 100644
index 19d2974580..0000000000
--- a/contrib/libs/libwebp/mux/animi.h
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright 2016 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Internal header for animation related functions.
-//
-// Author: Hui Su (huisu@google.com)
-
-#ifndef WEBP_MUX_ANIMI_H_
-#define WEBP_MUX_ANIMI_H_
-
-#include "../webp/mux.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// Picks the optimal rectangle between two pictures, starting with initial
-// values of offsets and dimensions that are passed in. The initial
-// values will be clipped, if necessary, to make sure the rectangle is
-// within the canvas. "use_argb" must be true for both pictures.
-// Parameters:
-// prev_canvas, curr_canvas - (in) two input pictures to compare.
-// is_lossless, quality - (in) encoding settings.
-// x_offset, y_offset, width, height - (in/out) rectangle between the two
-// input pictures.
-// Returns true on success.
-int WebPAnimEncoderRefineRect(
- const struct WebPPicture* const prev_canvas,
- const struct WebPPicture* const curr_canvas,
- int is_lossless, float quality, int* const x_offset, int* const y_offset,
- int* const width, int* const height);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // WEBP_MUX_ANIMI_H_
diff --git a/contrib/libs/libwebp/mux/muxedit.c b/contrib/libs/libwebp/mux/muxedit.c
deleted file mode 100644
index 8ffe1cb5d3..0000000000
--- a/contrib/libs/libwebp/mux/muxedit.c
+++ /dev/null
@@ -1,655 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Set and delete APIs for mux.
-//
-// Authors: Urvang (urvang@google.com)
-// Vikas (vikasa@google.com)
-
-#include <assert.h>
-#include "./muxi.h"
-#include "../utils/utils.h"
-
-//------------------------------------------------------------------------------
-// Life of a mux object.
-
-static void MuxInit(WebPMux* const mux) {
- assert(mux != NULL);
- memset(mux, 0, sizeof(*mux));
- mux->canvas_width_ = 0; // just to be explicit
- mux->canvas_height_ = 0;
-}
-
-WebPMux* WebPNewInternal(int version) {
- if (WEBP_ABI_IS_INCOMPATIBLE(version, WEBP_MUX_ABI_VERSION)) {
- return NULL;
- } else {
- WebPMux* const mux = (WebPMux*)WebPSafeMalloc(1ULL, sizeof(WebPMux));
- if (mux != NULL) MuxInit(mux);
- return mux;
- }
-}
-
-// Delete all images in 'wpi_list'.
-static void DeleteAllImages(WebPMuxImage** const wpi_list) {
- while (*wpi_list != NULL) {
- *wpi_list = MuxImageDelete(*wpi_list);
- }
-}
-
-static void MuxRelease(WebPMux* const mux) {
- assert(mux != NULL);
- DeleteAllImages(&mux->images_);
- ChunkListDelete(&mux->vp8x_);
- ChunkListDelete(&mux->iccp_);
- ChunkListDelete(&mux->anim_);
- ChunkListDelete(&mux->exif_);
- ChunkListDelete(&mux->xmp_);
- ChunkListDelete(&mux->unknown_);
-}
-
-void WebPMuxDelete(WebPMux* mux) {
- if (mux != NULL) {
- MuxRelease(mux);
- WebPSafeFree(mux);
- }
-}
-
-//------------------------------------------------------------------------------
-// Helper method(s).
-
-// Handy MACRO, makes MuxSet() very symmetric to MuxGet().
-#define SWITCH_ID_LIST(INDEX, LIST) \
- if (idx == (INDEX)) { \
- err = ChunkAssignData(&chunk, data, copy_data, tag); \
- if (err == WEBP_MUX_OK) { \
- err = ChunkSetHead(&chunk, (LIST)); \
- } \
- return err; \
- }
-
-static WebPMuxError MuxSet(WebPMux* const mux, uint32_t tag,
- const WebPData* const data, int copy_data) {
- WebPChunk chunk;
- WebPMuxError err = WEBP_MUX_NOT_FOUND;
- const CHUNK_INDEX idx = ChunkGetIndexFromTag(tag);
- assert(mux != NULL);
- assert(!IsWPI(kChunks[idx].id));
-
- ChunkInit(&chunk);
- SWITCH_ID_LIST(IDX_VP8X, &mux->vp8x_);
- SWITCH_ID_LIST(IDX_ICCP, &mux->iccp_);
- SWITCH_ID_LIST(IDX_ANIM, &mux->anim_);
- SWITCH_ID_LIST(IDX_EXIF, &mux->exif_);
- SWITCH_ID_LIST(IDX_XMP, &mux->xmp_);
- SWITCH_ID_LIST(IDX_UNKNOWN, &mux->unknown_);
- return err;
-}
-#undef SWITCH_ID_LIST
-
-// Create data for frame given image data, offsets and duration.
-static WebPMuxError CreateFrameData(
- int width, int height, const WebPMuxFrameInfo* const info,
- WebPData* const frame) {
- uint8_t* frame_bytes;
- const size_t frame_size = kChunks[IDX_ANMF].size;
-
- assert(width > 0 && height > 0 && info->duration >= 0);
- assert(info->dispose_method == (info->dispose_method & 1));
- // Note: assertion on upper bounds is done in PutLE24().
-
- frame_bytes = (uint8_t*)WebPSafeMalloc(1ULL, frame_size);
- if (frame_bytes == NULL) return WEBP_MUX_MEMORY_ERROR;
-
- PutLE24(frame_bytes + 0, info->x_offset / 2);
- PutLE24(frame_bytes + 3, info->y_offset / 2);
-
- PutLE24(frame_bytes + 6, width - 1);
- PutLE24(frame_bytes + 9, height - 1);
- PutLE24(frame_bytes + 12, info->duration);
- frame_bytes[15] =
- (info->blend_method == WEBP_MUX_NO_BLEND ? 2 : 0) |
- (info->dispose_method == WEBP_MUX_DISPOSE_BACKGROUND ? 1 : 0);
-
- frame->bytes = frame_bytes;
- frame->size = frame_size;
- return WEBP_MUX_OK;
-}
-
-// Outputs image data given a bitstream. The bitstream can either be a
-// single-image WebP file or raw VP8/VP8L data.
-// Also outputs 'is_lossless' to be true if the given bitstream is lossless.
-static WebPMuxError GetImageData(const WebPData* const bitstream,
- WebPData* const image, WebPData* const alpha,
- int* const is_lossless) {
- WebPDataInit(alpha); // Default: no alpha.
- if (bitstream->size < TAG_SIZE ||
- memcmp(bitstream->bytes, "RIFF", TAG_SIZE)) {
- // It is NOT webp file data. Return input data as is.
- *image = *bitstream;
- } else {
- // It is webp file data. Extract image data from it.
- const WebPMuxImage* wpi;
- WebPMux* const mux = WebPMuxCreate(bitstream, 0);
- if (mux == NULL) return WEBP_MUX_BAD_DATA;
- wpi = mux->images_;
- assert(wpi != NULL && wpi->img_ != NULL);
- *image = wpi->img_->data_;
- if (wpi->alpha_ != NULL) {
- *alpha = wpi->alpha_->data_;
- }
- WebPMuxDelete(mux);
- }
- *is_lossless = VP8LCheckSignature(image->bytes, image->size);
- return WEBP_MUX_OK;
-}
-
-static WebPMuxError DeleteChunks(WebPChunk** chunk_list, uint32_t tag) {
- WebPMuxError err = WEBP_MUX_NOT_FOUND;
- assert(chunk_list);
- while (*chunk_list) {
- WebPChunk* const chunk = *chunk_list;
- if (chunk->tag_ == tag) {
- *chunk_list = ChunkDelete(chunk);
- err = WEBP_MUX_OK;
- } else {
- chunk_list = &chunk->next_;
- }
- }
- return err;
-}
-
-static WebPMuxError MuxDeleteAllNamedData(WebPMux* const mux, uint32_t tag) {
- const WebPChunkId id = ChunkGetIdFromTag(tag);
- assert(mux != NULL);
- if (IsWPI(id)) return WEBP_MUX_INVALID_ARGUMENT;
- return DeleteChunks(MuxGetChunkListFromId(mux, id), tag);
-}
-
-//------------------------------------------------------------------------------
-// Set API(s).
-
-WebPMuxError WebPMuxSetChunk(WebPMux* mux, const char fourcc[4],
- const WebPData* chunk_data, int copy_data) {
- uint32_t tag;
- WebPMuxError err;
- if (mux == NULL || fourcc == NULL || chunk_data == NULL ||
- chunk_data->bytes == NULL || chunk_data->size > MAX_CHUNK_PAYLOAD) {
- return WEBP_MUX_INVALID_ARGUMENT;
- }
- tag = ChunkGetTagFromFourCC(fourcc);
-
- // Delete existing chunk(s) with the same 'fourcc'.
- err = MuxDeleteAllNamedData(mux, tag);
- if (err != WEBP_MUX_OK && err != WEBP_MUX_NOT_FOUND) return err;
-
- // Add the given chunk.
- return MuxSet(mux, tag, chunk_data, copy_data);
-}
-
-// Creates a chunk from given 'data' and sets it as 1st chunk in 'chunk_list'.
-static WebPMuxError AddDataToChunkList(
- const WebPData* const data, int copy_data, uint32_t tag,
- WebPChunk** chunk_list) {
- WebPChunk chunk;
- WebPMuxError err;
- ChunkInit(&chunk);
- err = ChunkAssignData(&chunk, data, copy_data, tag);
- if (err != WEBP_MUX_OK) goto Err;
- err = ChunkSetHead(&chunk, chunk_list);
- if (err != WEBP_MUX_OK) goto Err;
- return WEBP_MUX_OK;
- Err:
- ChunkRelease(&chunk);
- return err;
-}
-
-// Extracts image & alpha data from the given bitstream and then sets wpi.alpha_
-// and wpi.img_ appropriately.
-static WebPMuxError SetAlphaAndImageChunks(
- const WebPData* const bitstream, int copy_data, WebPMuxImage* const wpi) {
- int is_lossless = 0;
- WebPData image, alpha;
- WebPMuxError err = GetImageData(bitstream, &image, &alpha, &is_lossless);
- const int image_tag =
- is_lossless ? kChunks[IDX_VP8L].tag : kChunks[IDX_VP8].tag;
- if (err != WEBP_MUX_OK) return err;
- if (alpha.bytes != NULL) {
- err = AddDataToChunkList(&alpha, copy_data, kChunks[IDX_ALPHA].tag,
- &wpi->alpha_);
- if (err != WEBP_MUX_OK) return err;
- }
- err = AddDataToChunkList(&image, copy_data, image_tag, &wpi->img_);
- if (err != WEBP_MUX_OK) return err;
- return MuxImageFinalize(wpi) ? WEBP_MUX_OK : WEBP_MUX_INVALID_ARGUMENT;
-}
-
-WebPMuxError WebPMuxSetImage(WebPMux* mux, const WebPData* bitstream,
- int copy_data) {
- WebPMuxImage wpi;
- WebPMuxError err;
-
- if (mux == NULL || bitstream == NULL || bitstream->bytes == NULL ||
- bitstream->size > MAX_CHUNK_PAYLOAD) {
- return WEBP_MUX_INVALID_ARGUMENT;
- }
-
- if (mux->images_ != NULL) {
- // Only one 'simple image' can be added in mux. So, remove present images.
- DeleteAllImages(&mux->images_);
- }
-
- MuxImageInit(&wpi);
- err = SetAlphaAndImageChunks(bitstream, copy_data, &wpi);
- if (err != WEBP_MUX_OK) goto Err;
-
- // Add this WebPMuxImage to mux.
- err = MuxImagePush(&wpi, &mux->images_);
- if (err != WEBP_MUX_OK) goto Err;
-
- // All is well.
- return WEBP_MUX_OK;
-
- Err: // Something bad happened.
- MuxImageRelease(&wpi);
- return err;
-}
-
-WebPMuxError WebPMuxPushFrame(WebPMux* mux, const WebPMuxFrameInfo* info,
- int copy_data) {
- WebPMuxImage wpi;
- WebPMuxError err;
-
- if (mux == NULL || info == NULL) return WEBP_MUX_INVALID_ARGUMENT;
-
- if (info->id != WEBP_CHUNK_ANMF) return WEBP_MUX_INVALID_ARGUMENT;
-
- if (info->bitstream.bytes == NULL ||
- info->bitstream.size > MAX_CHUNK_PAYLOAD) {
- return WEBP_MUX_INVALID_ARGUMENT;
- }
-
- if (mux->images_ != NULL) {
- const WebPMuxImage* const image = mux->images_;
- const uint32_t image_id = (image->header_ != NULL) ?
- ChunkGetIdFromTag(image->header_->tag_) : WEBP_CHUNK_IMAGE;
- if (image_id != info->id) {
- return WEBP_MUX_INVALID_ARGUMENT; // Conflicting frame types.
- }
- }
-
- MuxImageInit(&wpi);
- err = SetAlphaAndImageChunks(&info->bitstream, copy_data, &wpi);
- if (err != WEBP_MUX_OK) goto Err;
- assert(wpi.img_ != NULL); // As SetAlphaAndImageChunks() was successful.
-
- {
- WebPData frame;
- const uint32_t tag = kChunks[IDX_ANMF].tag;
- WebPMuxFrameInfo tmp = *info;
- tmp.x_offset &= ~1; // Snap offsets to even.
- tmp.y_offset &= ~1;
- if (tmp.x_offset < 0 || tmp.x_offset >= MAX_POSITION_OFFSET ||
- tmp.y_offset < 0 || tmp.y_offset >= MAX_POSITION_OFFSET ||
- (tmp.duration < 0 || tmp.duration >= MAX_DURATION) ||
- tmp.dispose_method != (tmp.dispose_method & 1)) {
- err = WEBP_MUX_INVALID_ARGUMENT;
- goto Err;
- }
- err = CreateFrameData(wpi.width_, wpi.height_, &tmp, &frame);
- if (err != WEBP_MUX_OK) goto Err;
- // Add frame chunk (with copy_data = 1).
- err = AddDataToChunkList(&frame, 1, tag, &wpi.header_);
- WebPDataClear(&frame); // frame owned by wpi.header_ now.
- if (err != WEBP_MUX_OK) goto Err;
- }
-
- // Add this WebPMuxImage to mux.
- err = MuxImagePush(&wpi, &mux->images_);
- if (err != WEBP_MUX_OK) goto Err;
-
- // All is well.
- return WEBP_MUX_OK;
-
- Err: // Something bad happened.
- MuxImageRelease(&wpi);
- return err;
-}
-
-WebPMuxError WebPMuxSetAnimationParams(WebPMux* mux,
- const WebPMuxAnimParams* params) {
- WebPMuxError err;
- uint8_t data[ANIM_CHUNK_SIZE];
- const WebPData anim = { data, ANIM_CHUNK_SIZE };
-
- if (mux == NULL || params == NULL) return WEBP_MUX_INVALID_ARGUMENT;
- if (params->loop_count < 0 || params->loop_count >= MAX_LOOP_COUNT) {
- return WEBP_MUX_INVALID_ARGUMENT;
- }
-
- // Delete any existing ANIM chunk(s).
- err = MuxDeleteAllNamedData(mux, kChunks[IDX_ANIM].tag);
- if (err != WEBP_MUX_OK && err != WEBP_MUX_NOT_FOUND) return err;
-
- // Set the animation parameters.
- PutLE32(data, params->bgcolor);
- PutLE16(data + 4, params->loop_count);
- return MuxSet(mux, kChunks[IDX_ANIM].tag, &anim, 1);
-}
-
-WebPMuxError WebPMuxSetCanvasSize(WebPMux* mux,
- int width, int height) {
- WebPMuxError err;
- if (mux == NULL) {
- return WEBP_MUX_INVALID_ARGUMENT;
- }
- if (width < 0 || height < 0 ||
- width > MAX_CANVAS_SIZE || height > MAX_CANVAS_SIZE) {
- return WEBP_MUX_INVALID_ARGUMENT;
- }
- if (width * (uint64_t)height >= MAX_IMAGE_AREA) {
- return WEBP_MUX_INVALID_ARGUMENT;
- }
- if ((width * height) == 0 && (width | height) != 0) {
- // one of width / height is zero, but not both -> invalid!
- return WEBP_MUX_INVALID_ARGUMENT;
- }
- // If we already assembled a VP8X chunk, invalidate it.
- err = MuxDeleteAllNamedData(mux, kChunks[IDX_VP8X].tag);
- if (err != WEBP_MUX_OK && err != WEBP_MUX_NOT_FOUND) return err;
-
- mux->canvas_width_ = width;
- mux->canvas_height_ = height;
- return WEBP_MUX_OK;
-}
-
-//------------------------------------------------------------------------------
-// Delete API(s).
-
-WebPMuxError WebPMuxDeleteChunk(WebPMux* mux, const char fourcc[4]) {
- if (mux == NULL || fourcc == NULL) return WEBP_MUX_INVALID_ARGUMENT;
- return MuxDeleteAllNamedData(mux, ChunkGetTagFromFourCC(fourcc));
-}
-
-WebPMuxError WebPMuxDeleteFrame(WebPMux* mux, uint32_t nth) {
- if (mux == NULL) return WEBP_MUX_INVALID_ARGUMENT;
- return MuxImageDeleteNth(&mux->images_, nth);
-}
-
-//------------------------------------------------------------------------------
-// Assembly of the WebP RIFF file.
-
-static WebPMuxError GetFrameInfo(
- const WebPChunk* const frame_chunk,
- int* const x_offset, int* const y_offset, int* const duration) {
- const WebPData* const data = &frame_chunk->data_;
- const size_t expected_data_size = ANMF_CHUNK_SIZE;
- assert(frame_chunk->tag_ == kChunks[IDX_ANMF].tag);
- assert(frame_chunk != NULL);
- if (data->size != expected_data_size) return WEBP_MUX_INVALID_ARGUMENT;
-
- *x_offset = 2 * GetLE24(data->bytes + 0);
- *y_offset = 2 * GetLE24(data->bytes + 3);
- *duration = GetLE24(data->bytes + 12);
- return WEBP_MUX_OK;
-}
-
-static WebPMuxError GetImageInfo(const WebPMuxImage* const wpi,
- int* const x_offset, int* const y_offset,
- int* const duration,
- int* const width, int* const height) {
- const WebPChunk* const frame_chunk = wpi->header_;
- WebPMuxError err;
- assert(wpi != NULL);
- assert(frame_chunk != NULL);
-
- // Get offsets and duration from ANMF chunk.
- err = GetFrameInfo(frame_chunk, x_offset, y_offset, duration);
- if (err != WEBP_MUX_OK) return err;
-
- // Get width and height from VP8/VP8L chunk.
- if (width != NULL) *width = wpi->width_;
- if (height != NULL) *height = wpi->height_;
- return WEBP_MUX_OK;
-}
-
-// Returns the tightest dimension for the canvas considering the image list.
-static WebPMuxError GetAdjustedCanvasSize(const WebPMux* const mux,
- int* const width, int* const height) {
- WebPMuxImage* wpi = NULL;
- assert(mux != NULL);
- assert(width != NULL && height != NULL);
-
- wpi = mux->images_;
- assert(wpi != NULL);
- assert(wpi->img_ != NULL);
-
- if (wpi->next_ != NULL) {
- int max_x = 0, max_y = 0;
- // if we have a chain of wpi's, header_ is necessarily set
- assert(wpi->header_ != NULL);
- // Aggregate the bounding box for animation frames.
- for (; wpi != NULL; wpi = wpi->next_) {
- int x_offset = 0, y_offset = 0, duration = 0, w = 0, h = 0;
- const WebPMuxError err = GetImageInfo(wpi, &x_offset, &y_offset,
- &duration, &w, &h);
- const int max_x_pos = x_offset + w;
- const int max_y_pos = y_offset + h;
- if (err != WEBP_MUX_OK) return err;
- assert(x_offset < MAX_POSITION_OFFSET);
- assert(y_offset < MAX_POSITION_OFFSET);
-
- if (max_x_pos > max_x) max_x = max_x_pos;
- if (max_y_pos > max_y) max_y = max_y_pos;
- }
- *width = max_x;
- *height = max_y;
- } else {
- // For a single image, canvas dimensions are same as image dimensions.
- *width = wpi->width_;
- *height = wpi->height_;
- }
- return WEBP_MUX_OK;
-}
-
-// VP8X format:
-// Total Size : 10,
-// Flags : 4 bytes,
-// Width : 3 bytes,
-// Height : 3 bytes.
-static WebPMuxError CreateVP8XChunk(WebPMux* const mux) {
- WebPMuxError err = WEBP_MUX_OK;
- uint32_t flags = 0;
- int width = 0;
- int height = 0;
- uint8_t data[VP8X_CHUNK_SIZE];
- const WebPData vp8x = { data, VP8X_CHUNK_SIZE };
- const WebPMuxImage* images = NULL;
-
- assert(mux != NULL);
- images = mux->images_; // First image.
- if (images == NULL || images->img_ == NULL ||
- images->img_->data_.bytes == NULL) {
- return WEBP_MUX_INVALID_ARGUMENT;
- }
-
- // If VP8X chunk(s) is(are) already present, remove them (and later add new
- // VP8X chunk with updated flags).
- err = MuxDeleteAllNamedData(mux, kChunks[IDX_VP8X].tag);
- if (err != WEBP_MUX_OK && err != WEBP_MUX_NOT_FOUND) return err;
-
- // Set flags.
- if (mux->iccp_ != NULL && mux->iccp_->data_.bytes != NULL) {
- flags |= ICCP_FLAG;
- }
- if (mux->exif_ != NULL && mux->exif_->data_.bytes != NULL) {
- flags |= EXIF_FLAG;
- }
- if (mux->xmp_ != NULL && mux->xmp_->data_.bytes != NULL) {
- flags |= XMP_FLAG;
- }
- if (images->header_ != NULL) {
- if (images->header_->tag_ == kChunks[IDX_ANMF].tag) {
- // This is an image with animation.
- flags |= ANIMATION_FLAG;
- }
- }
- if (MuxImageCount(images, WEBP_CHUNK_ALPHA) > 0) {
- flags |= ALPHA_FLAG; // Some images have an alpha channel.
- }
-
- err = GetAdjustedCanvasSize(mux, &width, &height);
- if (err != WEBP_MUX_OK) return err;
-
- if (width <= 0 || height <= 0) {
- return WEBP_MUX_INVALID_ARGUMENT;
- }
- if (width > MAX_CANVAS_SIZE || height > MAX_CANVAS_SIZE) {
- return WEBP_MUX_INVALID_ARGUMENT;
- }
-
- if (mux->canvas_width_ != 0 || mux->canvas_height_ != 0) {
- if (width > mux->canvas_width_ || height > mux->canvas_height_) {
- return WEBP_MUX_INVALID_ARGUMENT;
- }
- width = mux->canvas_width_;
- height = mux->canvas_height_;
- }
-
- if (flags == 0 && mux->unknown_ == NULL) {
- // For simple file format, VP8X chunk should not be added.
- return WEBP_MUX_OK;
- }
-
- if (MuxHasAlpha(images)) {
- // This means some frames explicitly/implicitly contain alpha.
- // Note: This 'flags' update must NOT be done for a lossless image
- // without a VP8X chunk!
- flags |= ALPHA_FLAG;
- }
-
- PutLE32(data + 0, flags); // VP8X chunk flags.
- PutLE24(data + 4, width - 1); // canvas width.
- PutLE24(data + 7, height - 1); // canvas height.
-
- return MuxSet(mux, kChunks[IDX_VP8X].tag, &vp8x, 1);
-}
-
-// Cleans up 'mux' by removing any unnecessary chunks.
-static WebPMuxError MuxCleanup(WebPMux* const mux) {
- int num_frames;
- int num_anim_chunks;
-
- // If we have an image with a single frame, and its rectangle
- // covers the whole canvas, convert it to a non-animated image
- // (to avoid writing ANMF chunk unnecessarily).
- WebPMuxError err = WebPMuxNumChunks(mux, kChunks[IDX_ANMF].id, &num_frames);
- if (err != WEBP_MUX_OK) return err;
- if (num_frames == 1) {
- WebPMuxImage* frame = NULL;
- err = MuxImageGetNth((const WebPMuxImage**)&mux->images_, 1, &frame);
- assert(err == WEBP_MUX_OK); // We know that one frame does exist.
- assert(frame != NULL);
- if (frame->header_ != NULL &&
- ((mux->canvas_width_ == 0 && mux->canvas_height_ == 0) ||
- (frame->width_ == mux->canvas_width_ &&
- frame->height_ == mux->canvas_height_))) {
- assert(frame->header_->tag_ == kChunks[IDX_ANMF].tag);
- ChunkDelete(frame->header_); // Removes ANMF chunk.
- frame->header_ = NULL;
- num_frames = 0;
- }
- }
- // Remove ANIM chunk if this is a non-animated image.
- err = WebPMuxNumChunks(mux, kChunks[IDX_ANIM].id, &num_anim_chunks);
- if (err != WEBP_MUX_OK) return err;
- if (num_anim_chunks >= 1 && num_frames == 0) {
- err = MuxDeleteAllNamedData(mux, kChunks[IDX_ANIM].tag);
- if (err != WEBP_MUX_OK) return err;
- }
- return WEBP_MUX_OK;
-}
-
-// Total size of a list of images.
-static size_t ImageListDiskSize(const WebPMuxImage* wpi_list) {
- size_t size = 0;
- while (wpi_list != NULL) {
- size += MuxImageDiskSize(wpi_list);
- wpi_list = wpi_list->next_;
- }
- return size;
-}
-
-// Write out the given list of images into 'dst'.
-static uint8_t* ImageListEmit(const WebPMuxImage* wpi_list, uint8_t* dst) {
- while (wpi_list != NULL) {
- dst = MuxImageEmit(wpi_list, dst);
- wpi_list = wpi_list->next_;
- }
- return dst;
-}
-
-WebPMuxError WebPMuxAssemble(WebPMux* mux, WebPData* assembled_data) {
- size_t size = 0;
- uint8_t* data = NULL;
- uint8_t* dst = NULL;
- WebPMuxError err;
-
- if (assembled_data == NULL) {
- return WEBP_MUX_INVALID_ARGUMENT;
- }
- // Clean up returned data, in case something goes wrong.
- memset(assembled_data, 0, sizeof(*assembled_data));
-
- if (mux == NULL) {
- return WEBP_MUX_INVALID_ARGUMENT;
- }
-
- // Finalize mux.
- err = MuxCleanup(mux);
- if (err != WEBP_MUX_OK) return err;
- err = CreateVP8XChunk(mux);
- if (err != WEBP_MUX_OK) return err;
-
- // Allocate data.
- size = ChunkListDiskSize(mux->vp8x_) + ChunkListDiskSize(mux->iccp_)
- + ChunkListDiskSize(mux->anim_) + ImageListDiskSize(mux->images_)
- + ChunkListDiskSize(mux->exif_) + ChunkListDiskSize(mux->xmp_)
- + ChunkListDiskSize(mux->unknown_) + RIFF_HEADER_SIZE;
-
- data = (uint8_t*)WebPSafeMalloc(1ULL, size);
- if (data == NULL) return WEBP_MUX_MEMORY_ERROR;
-
- // Emit header & chunks.
- dst = MuxEmitRiffHeader(data, size);
- dst = ChunkListEmit(mux->vp8x_, dst);
- dst = ChunkListEmit(mux->iccp_, dst);
- dst = ChunkListEmit(mux->anim_, dst);
- dst = ImageListEmit(mux->images_, dst);
- dst = ChunkListEmit(mux->exif_, dst);
- dst = ChunkListEmit(mux->xmp_, dst);
- dst = ChunkListEmit(mux->unknown_, dst);
- assert(dst == data + size);
-
- // Validate mux.
- err = MuxValidate(mux);
- if (err != WEBP_MUX_OK) {
- WebPSafeFree(data);
- data = NULL;
- size = 0;
- }
-
- // Finalize data.
- assembled_data->bytes = data;
- assembled_data->size = size;
-
- return err;
-}
-
-//------------------------------------------------------------------------------
diff --git a/contrib/libs/libwebp/mux/muxi.h b/contrib/libs/libwebp/mux/muxi.h
deleted file mode 100644
index f29f4ff3b1..0000000000
--- a/contrib/libs/libwebp/mux/muxi.h
+++ /dev/null
@@ -1,234 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Internal header for mux library.
-//
-// Author: Urvang (urvang@google.com)
-
-#ifndef WEBP_MUX_MUXI_H_
-#define WEBP_MUX_MUXI_H_
-
-#include <assert.h>
-#include <stdlib.h>
-#include "../dec/vp8i_dec.h"
-#include "../dec/vp8li_dec.h"
-#include "../webp/mux.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-//------------------------------------------------------------------------------
-// Defines and constants.
-
-#define MUX_MAJ_VERSION 1
-#define MUX_MIN_VERSION 2
-#define MUX_REV_VERSION 2
-
-// Chunk object.
-typedef struct WebPChunk WebPChunk;
-struct WebPChunk {
- uint32_t tag_;
- int owner_; // True if *data_ memory is owned internally.
- // VP8X, ANIM, and other internally created chunks
- // like ANMF are always owned.
- WebPData data_;
- WebPChunk* next_;
-};
-
-// MuxImage object. Store a full WebP image (including ANMF chunk, ALPH
-// chunk and VP8/VP8L chunk),
-typedef struct WebPMuxImage WebPMuxImage;
-struct WebPMuxImage {
- WebPChunk* header_; // Corresponds to WEBP_CHUNK_ANMF.
- WebPChunk* alpha_; // Corresponds to WEBP_CHUNK_ALPHA.
- WebPChunk* img_; // Corresponds to WEBP_CHUNK_IMAGE.
- WebPChunk* unknown_; // Corresponds to WEBP_CHUNK_UNKNOWN.
- int width_;
- int height_;
- int has_alpha_; // Through ALPH chunk or as part of VP8L.
- int is_partial_; // True if only some of the chunks are filled.
- WebPMuxImage* next_;
-};
-
-// Main mux object. Stores data chunks.
-struct WebPMux {
- WebPMuxImage* images_;
- WebPChunk* iccp_;
- WebPChunk* exif_;
- WebPChunk* xmp_;
- WebPChunk* anim_;
- WebPChunk* vp8x_;
-
- WebPChunk* unknown_;
- int canvas_width_;
- int canvas_height_;
-};
-
-// CHUNK_INDEX enum: used for indexing within 'kChunks' (defined below) only.
-// Note: the reason for having two enums ('WebPChunkId' and 'CHUNK_INDEX') is to
-// allow two different chunks to have the same id (e.g. WebPChunkId
-// 'WEBP_CHUNK_IMAGE' can correspond to CHUNK_INDEX 'IDX_VP8' or 'IDX_VP8L').
-typedef enum {
- IDX_VP8X = 0,
- IDX_ICCP,
- IDX_ANIM,
- IDX_ANMF,
- IDX_ALPHA,
- IDX_VP8,
- IDX_VP8L,
- IDX_EXIF,
- IDX_XMP,
- IDX_UNKNOWN,
-
- IDX_NIL,
- IDX_LAST_CHUNK
-} CHUNK_INDEX;
-
-#define NIL_TAG 0x00000000u // To signal void chunk.
-
-typedef struct {
- uint32_t tag;
- WebPChunkId id;
- uint32_t size;
-} ChunkInfo;
-
-extern const ChunkInfo kChunks[IDX_LAST_CHUNK];
-
-//------------------------------------------------------------------------------
-// Chunk object management.
-
-// Initialize.
-void ChunkInit(WebPChunk* const chunk);
-
-// Get chunk index from chunk tag. Returns IDX_UNKNOWN if not found.
-CHUNK_INDEX ChunkGetIndexFromTag(uint32_t tag);
-
-// Get chunk id from chunk tag. Returns WEBP_CHUNK_UNKNOWN if not found.
-WebPChunkId ChunkGetIdFromTag(uint32_t tag);
-
-// Convert a fourcc string to a tag.
-uint32_t ChunkGetTagFromFourCC(const char fourcc[4]);
-
-// Get chunk index from fourcc. Returns IDX_UNKNOWN if given fourcc is unknown.
-CHUNK_INDEX ChunkGetIndexFromFourCC(const char fourcc[4]);
-
-// Search for nth chunk with given 'tag' in the chunk list.
-// nth = 0 means "last of the list".
-WebPChunk* ChunkSearchList(WebPChunk* first, uint32_t nth, uint32_t tag);
-
-// Fill the chunk with the given data.
-WebPMuxError ChunkAssignData(WebPChunk* chunk, const WebPData* const data,
- int copy_data, uint32_t tag);
-
-// Sets 'chunk' as the only element in 'chunk_list' if it is empty.
-// On success ownership is transferred from 'chunk' to the 'chunk_list'.
-WebPMuxError ChunkSetHead(WebPChunk* const chunk, WebPChunk** const chunk_list);
-// Sets 'chunk' at last position in the 'chunk_list'.
-// On success ownership is transferred from 'chunk' to the 'chunk_list'.
-// *chunk_list also points towards the last valid element of the initial
-// *chunk_list.
-WebPMuxError ChunkAppend(WebPChunk* const chunk, WebPChunk*** const chunk_list);
-
-// Releases chunk and returns chunk->next_.
-WebPChunk* ChunkRelease(WebPChunk* const chunk);
-
-// Deletes given chunk & returns chunk->next_.
-WebPChunk* ChunkDelete(WebPChunk* const chunk);
-
-// Deletes all chunks in the given chunk list.
-void ChunkListDelete(WebPChunk** const chunk_list);
-
-// Returns size of the chunk including chunk header and padding byte (if any).
-static WEBP_INLINE size_t SizeWithPadding(size_t chunk_size) {
- assert(chunk_size <= MAX_CHUNK_PAYLOAD);
- return CHUNK_HEADER_SIZE + ((chunk_size + 1) & ~1U);
-}
-
-// Size of a chunk including header and padding.
-static WEBP_INLINE size_t ChunkDiskSize(const WebPChunk* chunk) {
- const size_t data_size = chunk->data_.size;
- return SizeWithPadding(data_size);
-}
-
-// Total size of a list of chunks.
-size_t ChunkListDiskSize(const WebPChunk* chunk_list);
-
-// Write out the given list of chunks into 'dst'.
-uint8_t* ChunkListEmit(const WebPChunk* chunk_list, uint8_t* dst);
-
-//------------------------------------------------------------------------------
-// MuxImage object management.
-
-// Initialize.
-void MuxImageInit(WebPMuxImage* const wpi);
-
-// Releases image 'wpi' and returns wpi->next.
-WebPMuxImage* MuxImageRelease(WebPMuxImage* const wpi);
-
-// Delete image 'wpi' and return the next image in the list or NULL.
-// 'wpi' can be NULL.
-WebPMuxImage* MuxImageDelete(WebPMuxImage* const wpi);
-
-// Count number of images matching the given tag id in the 'wpi_list'.
-// If id == WEBP_CHUNK_NIL, all images will be matched.
-int MuxImageCount(const WebPMuxImage* wpi_list, WebPChunkId id);
-
-// Update width/height/has_alpha info from chunks within wpi.
-// Also remove ALPH chunk if not needed.
-int MuxImageFinalize(WebPMuxImage* const wpi);
-
-// Check if given ID corresponds to an image related chunk.
-static WEBP_INLINE int IsWPI(WebPChunkId id) {
- switch (id) {
- case WEBP_CHUNK_ANMF:
- case WEBP_CHUNK_ALPHA:
- case WEBP_CHUNK_IMAGE: return 1;
- default: return 0;
- }
-}
-
-// Pushes 'wpi' at the end of 'wpi_list'.
-WebPMuxError MuxImagePush(const WebPMuxImage* wpi, WebPMuxImage** wpi_list);
-
-// Delete nth image in the image list.
-WebPMuxError MuxImageDeleteNth(WebPMuxImage** wpi_list, uint32_t nth);
-
-// Get nth image in the image list.
-WebPMuxError MuxImageGetNth(const WebPMuxImage** wpi_list, uint32_t nth,
- WebPMuxImage** wpi);
-
-// Total size of the given image.
-size_t MuxImageDiskSize(const WebPMuxImage* const wpi);
-
-// Write out the given image into 'dst'.
-uint8_t* MuxImageEmit(const WebPMuxImage* const wpi, uint8_t* dst);
-
-//------------------------------------------------------------------------------
-// Helper methods for mux.
-
-// Checks if the given image list contains at least one image with alpha.
-int MuxHasAlpha(const WebPMuxImage* images);
-
-// Write out RIFF header into 'data', given total data size 'size'.
-uint8_t* MuxEmitRiffHeader(uint8_t* const data, size_t size);
-
-// Returns the list where chunk with given ID is to be inserted in mux.
-WebPChunk** MuxGetChunkListFromId(const WebPMux* mux, WebPChunkId id);
-
-// Validates the given mux object.
-WebPMuxError MuxValidate(const WebPMux* const mux);
-
-//------------------------------------------------------------------------------
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // WEBP_MUX_MUXI_H_
diff --git a/contrib/libs/libwebp/mux/muxinternal.c b/contrib/libs/libwebp/mux/muxinternal.c
deleted file mode 100644
index bf4a18d6e2..0000000000
--- a/contrib/libs/libwebp/mux/muxinternal.c
+++ /dev/null
@@ -1,548 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Internal objects and utils for mux.
-//
-// Authors: Urvang (urvang@google.com)
-// Vikas (vikasa@google.com)
-
-#include <assert.h>
-#include "./muxi.h"
-#include "../utils/utils.h"
-
-#define UNDEFINED_CHUNK_SIZE ((uint32_t)(-1))
-
-const ChunkInfo kChunks[] = {
- { MKFOURCC('V', 'P', '8', 'X'), WEBP_CHUNK_VP8X, VP8X_CHUNK_SIZE },
- { MKFOURCC('I', 'C', 'C', 'P'), WEBP_CHUNK_ICCP, UNDEFINED_CHUNK_SIZE },
- { MKFOURCC('A', 'N', 'I', 'M'), WEBP_CHUNK_ANIM, ANIM_CHUNK_SIZE },
- { MKFOURCC('A', 'N', 'M', 'F'), WEBP_CHUNK_ANMF, ANMF_CHUNK_SIZE },
- { MKFOURCC('A', 'L', 'P', 'H'), WEBP_CHUNK_ALPHA, UNDEFINED_CHUNK_SIZE },
- { MKFOURCC('V', 'P', '8', ' '), WEBP_CHUNK_IMAGE, UNDEFINED_CHUNK_SIZE },
- { MKFOURCC('V', 'P', '8', 'L'), WEBP_CHUNK_IMAGE, UNDEFINED_CHUNK_SIZE },
- { MKFOURCC('E', 'X', 'I', 'F'), WEBP_CHUNK_EXIF, UNDEFINED_CHUNK_SIZE },
- { MKFOURCC('X', 'M', 'P', ' '), WEBP_CHUNK_XMP, UNDEFINED_CHUNK_SIZE },
- { NIL_TAG, WEBP_CHUNK_UNKNOWN, UNDEFINED_CHUNK_SIZE },
-
- { NIL_TAG, WEBP_CHUNK_NIL, UNDEFINED_CHUNK_SIZE }
-};
-
-//------------------------------------------------------------------------------
-
-int WebPGetMuxVersion(void) {
- return (MUX_MAJ_VERSION << 16) | (MUX_MIN_VERSION << 8) | MUX_REV_VERSION;
-}
-
-//------------------------------------------------------------------------------
-// Life of a chunk object.
-
-void ChunkInit(WebPChunk* const chunk) {
- assert(chunk);
- memset(chunk, 0, sizeof(*chunk));
- chunk->tag_ = NIL_TAG;
-}
-
-WebPChunk* ChunkRelease(WebPChunk* const chunk) {
- WebPChunk* next;
- if (chunk == NULL) return NULL;
- if (chunk->owner_) {
- WebPDataClear(&chunk->data_);
- }
- next = chunk->next_;
- ChunkInit(chunk);
- return next;
-}
-
-//------------------------------------------------------------------------------
-// Chunk misc methods.
-
-CHUNK_INDEX ChunkGetIndexFromTag(uint32_t tag) {
- int i;
- for (i = 0; kChunks[i].tag != NIL_TAG; ++i) {
- if (tag == kChunks[i].tag) return (CHUNK_INDEX)i;
- }
- return IDX_UNKNOWN;
-}
-
-WebPChunkId ChunkGetIdFromTag(uint32_t tag) {
- int i;
- for (i = 0; kChunks[i].tag != NIL_TAG; ++i) {
- if (tag == kChunks[i].tag) return kChunks[i].id;
- }
- return WEBP_CHUNK_UNKNOWN;
-}
-
-uint32_t ChunkGetTagFromFourCC(const char fourcc[4]) {
- return MKFOURCC(fourcc[0], fourcc[1], fourcc[2], fourcc[3]);
-}
-
-CHUNK_INDEX ChunkGetIndexFromFourCC(const char fourcc[4]) {
- const uint32_t tag = ChunkGetTagFromFourCC(fourcc);
- return ChunkGetIndexFromTag(tag);
-}
-
-//------------------------------------------------------------------------------
-// Chunk search methods.
-
-// Returns next chunk in the chunk list with the given tag.
-static WebPChunk* ChunkSearchNextInList(WebPChunk* chunk, uint32_t tag) {
- while (chunk != NULL && chunk->tag_ != tag) {
- chunk = chunk->next_;
- }
- return chunk;
-}
-
-WebPChunk* ChunkSearchList(WebPChunk* first, uint32_t nth, uint32_t tag) {
- uint32_t iter = nth;
- first = ChunkSearchNextInList(first, tag);
- if (first == NULL) return NULL;
-
- while (--iter != 0) {
- WebPChunk* next_chunk = ChunkSearchNextInList(first->next_, tag);
- if (next_chunk == NULL) break;
- first = next_chunk;
- }
- return ((nth > 0) && (iter > 0)) ? NULL : first;
-}
-
-//------------------------------------------------------------------------------
-// Chunk writer methods.
-
-WebPMuxError ChunkAssignData(WebPChunk* chunk, const WebPData* const data,
- int copy_data, uint32_t tag) {
- // For internally allocated chunks, always copy data & make it owner of data.
- if (tag == kChunks[IDX_VP8X].tag || tag == kChunks[IDX_ANIM].tag) {
- copy_data = 1;
- }
-
- ChunkRelease(chunk);
-
- if (data != NULL) {
- if (copy_data) { // Copy data.
- if (!WebPDataCopy(data, &chunk->data_)) return WEBP_MUX_MEMORY_ERROR;
- chunk->owner_ = 1; // Chunk is owner of data.
- } else { // Don't copy data.
- chunk->data_ = *data;
- }
- }
- chunk->tag_ = tag;
- return WEBP_MUX_OK;
-}
-
-WebPMuxError ChunkSetHead(WebPChunk* const chunk,
- WebPChunk** const chunk_list) {
- WebPChunk* new_chunk;
-
- assert(chunk_list != NULL);
- if (*chunk_list != NULL) {
- return WEBP_MUX_NOT_FOUND;
- }
-
- new_chunk = (WebPChunk*)WebPSafeMalloc(1ULL, sizeof(*new_chunk));
- if (new_chunk == NULL) return WEBP_MUX_MEMORY_ERROR;
- *new_chunk = *chunk;
- chunk->owner_ = 0;
- new_chunk->next_ = NULL;
- *chunk_list = new_chunk;
- return WEBP_MUX_OK;
-}
-
-WebPMuxError ChunkAppend(WebPChunk* const chunk,
- WebPChunk*** const chunk_list) {
- assert(chunk_list != NULL && *chunk_list != NULL);
-
- if (**chunk_list == NULL) {
- ChunkSetHead(chunk, *chunk_list);
- } else {
- WebPChunk* last_chunk = **chunk_list;
- while (last_chunk->next_ != NULL) last_chunk = last_chunk->next_;
- ChunkSetHead(chunk, &last_chunk->next_);
- *chunk_list = &last_chunk->next_;
- }
- return WEBP_MUX_OK;
-}
-
-//------------------------------------------------------------------------------
-// Chunk deletion method(s).
-
-WebPChunk* ChunkDelete(WebPChunk* const chunk) {
- WebPChunk* const next = ChunkRelease(chunk);
- WebPSafeFree(chunk);
- return next;
-}
-
-void ChunkListDelete(WebPChunk** const chunk_list) {
- while (*chunk_list != NULL) {
- *chunk_list = ChunkDelete(*chunk_list);
- }
-}
-
-//------------------------------------------------------------------------------
-// Chunk serialization methods.
-
-static uint8_t* ChunkEmit(const WebPChunk* const chunk, uint8_t* dst) {
- const size_t chunk_size = chunk->data_.size;
- assert(chunk);
- assert(chunk->tag_ != NIL_TAG);
- PutLE32(dst + 0, chunk->tag_);
- PutLE32(dst + TAG_SIZE, (uint32_t)chunk_size);
- assert(chunk_size == (uint32_t)chunk_size);
- memcpy(dst + CHUNK_HEADER_SIZE, chunk->data_.bytes, chunk_size);
- if (chunk_size & 1)
- dst[CHUNK_HEADER_SIZE + chunk_size] = 0; // Add padding.
- return dst + ChunkDiskSize(chunk);
-}
-
-uint8_t* ChunkListEmit(const WebPChunk* chunk_list, uint8_t* dst) {
- while (chunk_list != NULL) {
- dst = ChunkEmit(chunk_list, dst);
- chunk_list = chunk_list->next_;
- }
- return dst;
-}
-
-size_t ChunkListDiskSize(const WebPChunk* chunk_list) {
- size_t size = 0;
- while (chunk_list != NULL) {
- size += ChunkDiskSize(chunk_list);
- chunk_list = chunk_list->next_;
- }
- return size;
-}
-
-//------------------------------------------------------------------------------
-// Life of a MuxImage object.
-
-void MuxImageInit(WebPMuxImage* const wpi) {
- assert(wpi);
- memset(wpi, 0, sizeof(*wpi));
-}
-
-WebPMuxImage* MuxImageRelease(WebPMuxImage* const wpi) {
- WebPMuxImage* next;
- if (wpi == NULL) return NULL;
- // There should be at most one chunk of header_, alpha_, img_ but we call
- // ChunkListDelete to be safe
- ChunkListDelete(&wpi->header_);
- ChunkListDelete(&wpi->alpha_);
- ChunkListDelete(&wpi->img_);
- ChunkListDelete(&wpi->unknown_);
-
- next = wpi->next_;
- MuxImageInit(wpi);
- return next;
-}
-
-//------------------------------------------------------------------------------
-// MuxImage search methods.
-
-// Get a reference to appropriate chunk list within an image given chunk tag.
-static WebPChunk** GetChunkListFromId(const WebPMuxImage* const wpi,
- WebPChunkId id) {
- assert(wpi != NULL);
- switch (id) {
- case WEBP_CHUNK_ANMF: return (WebPChunk**)&wpi->header_;
- case WEBP_CHUNK_ALPHA: return (WebPChunk**)&wpi->alpha_;
- case WEBP_CHUNK_IMAGE: return (WebPChunk**)&wpi->img_;
- default: return NULL;
- }
-}
-
-int MuxImageCount(const WebPMuxImage* wpi_list, WebPChunkId id) {
- int count = 0;
- const WebPMuxImage* current;
- for (current = wpi_list; current != NULL; current = current->next_) {
- if (id == WEBP_CHUNK_NIL) {
- ++count; // Special case: count all images.
- } else {
- const WebPChunk* const wpi_chunk = *GetChunkListFromId(current, id);
- if (wpi_chunk != NULL) {
- const WebPChunkId wpi_chunk_id = ChunkGetIdFromTag(wpi_chunk->tag_);
- if (wpi_chunk_id == id) ++count; // Count images with a matching 'id'.
- }
- }
- }
- return count;
-}
-
-// Outputs a pointer to 'prev_wpi->next_',
-// where 'prev_wpi' is the pointer to the image at position (nth - 1).
-// Returns true if nth image was found.
-static int SearchImageToGetOrDelete(WebPMuxImage** wpi_list, uint32_t nth,
- WebPMuxImage*** const location) {
- uint32_t count = 0;
- assert(wpi_list);
- *location = wpi_list;
-
- if (nth == 0) {
- nth = MuxImageCount(*wpi_list, WEBP_CHUNK_NIL);
- if (nth == 0) return 0; // Not found.
- }
-
- while (*wpi_list != NULL) {
- WebPMuxImage* const cur_wpi = *wpi_list;
- ++count;
- if (count == nth) return 1; // Found.
- wpi_list = &cur_wpi->next_;
- *location = wpi_list;
- }
- return 0; // Not found.
-}
-
-//------------------------------------------------------------------------------
-// MuxImage writer methods.
-
-WebPMuxError MuxImagePush(const WebPMuxImage* wpi, WebPMuxImage** wpi_list) {
- WebPMuxImage* new_wpi;
-
- while (*wpi_list != NULL) {
- WebPMuxImage* const cur_wpi = *wpi_list;
- if (cur_wpi->next_ == NULL) break;
- wpi_list = &cur_wpi->next_;
- }
-
- new_wpi = (WebPMuxImage*)WebPSafeMalloc(1ULL, sizeof(*new_wpi));
- if (new_wpi == NULL) return WEBP_MUX_MEMORY_ERROR;
- *new_wpi = *wpi;
- new_wpi->next_ = NULL;
-
- if (*wpi_list != NULL) {
- (*wpi_list)->next_ = new_wpi;
- } else {
- *wpi_list = new_wpi;
- }
- return WEBP_MUX_OK;
-}
-
-//------------------------------------------------------------------------------
-// MuxImage deletion methods.
-
-WebPMuxImage* MuxImageDelete(WebPMuxImage* const wpi) {
- // Delete the components of wpi. If wpi is NULL this is a noop.
- WebPMuxImage* const next = MuxImageRelease(wpi);
- WebPSafeFree(wpi);
- return next;
-}
-
-WebPMuxError MuxImageDeleteNth(WebPMuxImage** wpi_list, uint32_t nth) {
- assert(wpi_list);
- if (!SearchImageToGetOrDelete(wpi_list, nth, &wpi_list)) {
- return WEBP_MUX_NOT_FOUND;
- }
- *wpi_list = MuxImageDelete(*wpi_list);
- return WEBP_MUX_OK;
-}
-
-//------------------------------------------------------------------------------
-// MuxImage reader methods.
-
-WebPMuxError MuxImageGetNth(const WebPMuxImage** wpi_list, uint32_t nth,
- WebPMuxImage** wpi) {
- assert(wpi_list);
- assert(wpi);
- if (!SearchImageToGetOrDelete((WebPMuxImage**)wpi_list, nth,
- (WebPMuxImage***)&wpi_list)) {
- return WEBP_MUX_NOT_FOUND;
- }
- *wpi = (WebPMuxImage*)*wpi_list;
- return WEBP_MUX_OK;
-}
-
-//------------------------------------------------------------------------------
-// MuxImage serialization methods.
-
-// Size of an image.
-size_t MuxImageDiskSize(const WebPMuxImage* const wpi) {
- size_t size = 0;
- if (wpi->header_ != NULL) size += ChunkDiskSize(wpi->header_);
- if (wpi->alpha_ != NULL) size += ChunkDiskSize(wpi->alpha_);
- if (wpi->img_ != NULL) size += ChunkDiskSize(wpi->img_);
- if (wpi->unknown_ != NULL) size += ChunkListDiskSize(wpi->unknown_);
- return size;
-}
-
-// Special case as ANMF chunk encapsulates other image chunks.
-static uint8_t* ChunkEmitSpecial(const WebPChunk* const header,
- size_t total_size, uint8_t* dst) {
- const size_t header_size = header->data_.size;
- const size_t offset_to_next = total_size - CHUNK_HEADER_SIZE;
- assert(header->tag_ == kChunks[IDX_ANMF].tag);
- PutLE32(dst + 0, header->tag_);
- PutLE32(dst + TAG_SIZE, (uint32_t)offset_to_next);
- assert(header_size == (uint32_t)header_size);
- memcpy(dst + CHUNK_HEADER_SIZE, header->data_.bytes, header_size);
- if (header_size & 1) {
- dst[CHUNK_HEADER_SIZE + header_size] = 0; // Add padding.
- }
- return dst + ChunkDiskSize(header);
-}
-
-uint8_t* MuxImageEmit(const WebPMuxImage* const wpi, uint8_t* dst) {
- // Ordering of chunks to be emitted is strictly as follows:
- // 1. ANMF chunk (if present).
- // 2. ALPH chunk (if present).
- // 3. VP8/VP8L chunk.
- assert(wpi);
- if (wpi->header_ != NULL) {
- dst = ChunkEmitSpecial(wpi->header_, MuxImageDiskSize(wpi), dst);
- }
- if (wpi->alpha_ != NULL) dst = ChunkEmit(wpi->alpha_, dst);
- if (wpi->img_ != NULL) dst = ChunkEmit(wpi->img_, dst);
- if (wpi->unknown_ != NULL) dst = ChunkListEmit(wpi->unknown_, dst);
- return dst;
-}
-
-//------------------------------------------------------------------------------
-// Helper methods for mux.
-
-int MuxHasAlpha(const WebPMuxImage* images) {
- while (images != NULL) {
- if (images->has_alpha_) return 1;
- images = images->next_;
- }
- return 0;
-}
-
-uint8_t* MuxEmitRiffHeader(uint8_t* const data, size_t size) {
- PutLE32(data + 0, MKFOURCC('R', 'I', 'F', 'F'));
- PutLE32(data + TAG_SIZE, (uint32_t)size - CHUNK_HEADER_SIZE);
- assert(size == (uint32_t)size);
- PutLE32(data + TAG_SIZE + CHUNK_SIZE_BYTES, MKFOURCC('W', 'E', 'B', 'P'));
- return data + RIFF_HEADER_SIZE;
-}
-
-WebPChunk** MuxGetChunkListFromId(const WebPMux* mux, WebPChunkId id) {
- assert(mux != NULL);
- switch (id) {
- case WEBP_CHUNK_VP8X: return (WebPChunk**)&mux->vp8x_;
- case WEBP_CHUNK_ICCP: return (WebPChunk**)&mux->iccp_;
- case WEBP_CHUNK_ANIM: return (WebPChunk**)&mux->anim_;
- case WEBP_CHUNK_EXIF: return (WebPChunk**)&mux->exif_;
- case WEBP_CHUNK_XMP: return (WebPChunk**)&mux->xmp_;
- default: return (WebPChunk**)&mux->unknown_;
- }
-}
-
-static int IsNotCompatible(int feature, int num_items) {
- return (feature != 0) != (num_items > 0);
-}
-
-#define NO_FLAG ((WebPFeatureFlags)0)
-
-// Test basic constraints:
-// retrieval, maximum number of chunks by index (use -1 to skip)
-// and feature incompatibility (use NO_FLAG to skip).
-// On success returns WEBP_MUX_OK and stores the chunk count in *num.
-static WebPMuxError ValidateChunk(const WebPMux* const mux, CHUNK_INDEX idx,
- WebPFeatureFlags feature,
- uint32_t vp8x_flags,
- int max, int* num) {
- const WebPMuxError err =
- WebPMuxNumChunks(mux, kChunks[idx].id, num);
- if (err != WEBP_MUX_OK) return err;
- if (max > -1 && *num > max) return WEBP_MUX_INVALID_ARGUMENT;
- if (feature != NO_FLAG && IsNotCompatible(vp8x_flags & feature, *num)) {
- return WEBP_MUX_INVALID_ARGUMENT;
- }
- return WEBP_MUX_OK;
-}
-
-WebPMuxError MuxValidate(const WebPMux* const mux) {
- int num_iccp;
- int num_exif;
- int num_xmp;
- int num_anim;
- int num_frames;
- int num_vp8x;
- int num_images;
- int num_alpha;
- uint32_t flags;
- WebPMuxError err;
-
- // Verify mux is not NULL.
- if (mux == NULL) return WEBP_MUX_INVALID_ARGUMENT;
-
- // Verify mux has at least one image.
- if (mux->images_ == NULL) return WEBP_MUX_INVALID_ARGUMENT;
-
- err = WebPMuxGetFeatures(mux, &flags);
- if (err != WEBP_MUX_OK) return err;
-
- // At most one color profile chunk.
- err = ValidateChunk(mux, IDX_ICCP, ICCP_FLAG, flags, 1, &num_iccp);
- if (err != WEBP_MUX_OK) return err;
-
- // At most one EXIF metadata.
- err = ValidateChunk(mux, IDX_EXIF, EXIF_FLAG, flags, 1, &num_exif);
- if (err != WEBP_MUX_OK) return err;
-
- // At most one XMP metadata.
- err = ValidateChunk(mux, IDX_XMP, XMP_FLAG, flags, 1, &num_xmp);
- if (err != WEBP_MUX_OK) return err;
-
- // Animation: ANIMATION_FLAG, ANIM chunk and ANMF chunk(s) are consistent.
- // At most one ANIM chunk.
- err = ValidateChunk(mux, IDX_ANIM, NO_FLAG, flags, 1, &num_anim);
- if (err != WEBP_MUX_OK) return err;
- err = ValidateChunk(mux, IDX_ANMF, NO_FLAG, flags, -1, &num_frames);
- if (err != WEBP_MUX_OK) return err;
-
- {
- const int has_animation = !!(flags & ANIMATION_FLAG);
- if (has_animation && (num_anim == 0 || num_frames == 0)) {
- return WEBP_MUX_INVALID_ARGUMENT;
- }
- if (!has_animation && (num_anim == 1 || num_frames > 0)) {
- return WEBP_MUX_INVALID_ARGUMENT;
- }
- if (!has_animation) {
- const WebPMuxImage* images = mux->images_;
- // There can be only one image.
- if (images == NULL || images->next_ != NULL) {
- return WEBP_MUX_INVALID_ARGUMENT;
- }
- // Size must match.
- if (mux->canvas_width_ > 0) {
- if (images->width_ != mux->canvas_width_ ||
- images->height_ != mux->canvas_height_) {
- return WEBP_MUX_INVALID_ARGUMENT;
- }
- }
- }
- }
-
- // Verify either VP8X chunk is present OR there is only one elem in
- // mux->images_.
- err = ValidateChunk(mux, IDX_VP8X, NO_FLAG, flags, 1, &num_vp8x);
- if (err != WEBP_MUX_OK) return err;
- err = ValidateChunk(mux, IDX_VP8, NO_FLAG, flags, -1, &num_images);
- if (err != WEBP_MUX_OK) return err;
- if (num_vp8x == 0 && num_images != 1) return WEBP_MUX_INVALID_ARGUMENT;
-
- // ALPHA_FLAG & alpha chunk(s) are consistent.
- // Note: ALPHA_FLAG can be set when there is actually no Alpha data present.
- if (MuxHasAlpha(mux->images_)) {
- if (num_vp8x > 0) {
- // VP8X chunk is present, so it should contain ALPHA_FLAG.
- if (!(flags & ALPHA_FLAG)) return WEBP_MUX_INVALID_ARGUMENT;
- } else {
- // VP8X chunk is not present, so ALPH chunks should NOT be present either.
- err = WebPMuxNumChunks(mux, WEBP_CHUNK_ALPHA, &num_alpha);
- if (err != WEBP_MUX_OK) return err;
- if (num_alpha > 0) return WEBP_MUX_INVALID_ARGUMENT;
- }
- }
-
- return WEBP_MUX_OK;
-}
-
-#undef NO_FLAG
-
-//------------------------------------------------------------------------------
-
diff --git a/contrib/libs/libwebp/mux/muxread.c b/contrib/libs/libwebp/mux/muxread.c
deleted file mode 100644
index 0ad3381811..0000000000
--- a/contrib/libs/libwebp/mux/muxread.c
+++ /dev/null
@@ -1,554 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Read APIs for mux.
-//
-// Authors: Urvang (urvang@google.com)
-// Vikas (vikasa@google.com)
-
-#include <assert.h>
-#include "./muxi.h"
-#include "../utils/utils.h"
-
-//------------------------------------------------------------------------------
-// Helper method(s).
-
-// Handy MACRO.
-#define SWITCH_ID_LIST(INDEX, LIST) \
- if (idx == (INDEX)) { \
- const WebPChunk* const chunk = ChunkSearchList((LIST), nth, \
- kChunks[(INDEX)].tag); \
- if (chunk) { \
- *data = chunk->data_; \
- return WEBP_MUX_OK; \
- } else { \
- return WEBP_MUX_NOT_FOUND; \
- } \
- }
-
-static WebPMuxError MuxGet(const WebPMux* const mux, CHUNK_INDEX idx,
- uint32_t nth, WebPData* const data) {
- assert(mux != NULL);
- assert(!IsWPI(kChunks[idx].id));
- WebPDataInit(data);
-
- SWITCH_ID_LIST(IDX_VP8X, mux->vp8x_);
- SWITCH_ID_LIST(IDX_ICCP, mux->iccp_);
- SWITCH_ID_LIST(IDX_ANIM, mux->anim_);
- SWITCH_ID_LIST(IDX_EXIF, mux->exif_);
- SWITCH_ID_LIST(IDX_XMP, mux->xmp_);
- assert(idx != IDX_UNKNOWN);
- return WEBP_MUX_NOT_FOUND;
-}
-#undef SWITCH_ID_LIST
-
-// Fill the chunk with the given data (includes chunk header bytes), after some
-// verifications.
-static WebPMuxError ChunkVerifyAndAssign(WebPChunk* chunk,
- const uint8_t* data, size_t data_size,
- size_t riff_size, int copy_data) {
- uint32_t chunk_size;
- WebPData chunk_data;
-
- // Correctness checks.
- if (data_size < CHUNK_HEADER_SIZE) return WEBP_MUX_NOT_ENOUGH_DATA;
- chunk_size = GetLE32(data + TAG_SIZE);
- if (chunk_size > MAX_CHUNK_PAYLOAD) return WEBP_MUX_BAD_DATA;
-
- {
- const size_t chunk_disk_size = SizeWithPadding(chunk_size);
- if (chunk_disk_size > riff_size) return WEBP_MUX_BAD_DATA;
- if (chunk_disk_size > data_size) return WEBP_MUX_NOT_ENOUGH_DATA;
- }
-
- // Data assignment.
- chunk_data.bytes = data + CHUNK_HEADER_SIZE;
- chunk_data.size = chunk_size;
- return ChunkAssignData(chunk, &chunk_data, copy_data, GetLE32(data + 0));
-}
-
-int MuxImageFinalize(WebPMuxImage* const wpi) {
- const WebPChunk* const img = wpi->img_;
- const WebPData* const image = &img->data_;
- const int is_lossless = (img->tag_ == kChunks[IDX_VP8L].tag);
- int w, h;
- int vp8l_has_alpha = 0;
- const int ok = is_lossless ?
- VP8LGetInfo(image->bytes, image->size, &w, &h, &vp8l_has_alpha) :
- VP8GetInfo(image->bytes, image->size, image->size, &w, &h);
- assert(img != NULL);
- if (ok) {
- // Ignore ALPH chunk accompanying VP8L.
- if (is_lossless && (wpi->alpha_ != NULL)) {
- ChunkDelete(wpi->alpha_);
- wpi->alpha_ = NULL;
- }
- wpi->width_ = w;
- wpi->height_ = h;
- wpi->has_alpha_ = vp8l_has_alpha || (wpi->alpha_ != NULL);
- }
- return ok;
-}
-
-static int MuxImageParse(const WebPChunk* const chunk, int copy_data,
- WebPMuxImage* const wpi) {
- const uint8_t* bytes = chunk->data_.bytes;
- size_t size = chunk->data_.size;
- const uint8_t* const last = (bytes == NULL) ? NULL : bytes + size;
- WebPChunk subchunk;
- size_t subchunk_size;
- WebPChunk** unknown_chunk_list = &wpi->unknown_;
- ChunkInit(&subchunk);
-
- assert(chunk->tag_ == kChunks[IDX_ANMF].tag);
- assert(!wpi->is_partial_);
-
- // ANMF.
- {
- const size_t hdr_size = ANMF_CHUNK_SIZE;
- const WebPData temp = { bytes, hdr_size };
- // Each of ANMF chunk contain a header at the beginning. So, its size should
- // be at least 'hdr_size'.
- if (size < hdr_size) goto Fail;
- ChunkAssignData(&subchunk, &temp, copy_data, chunk->tag_);
- }
- ChunkSetHead(&subchunk, &wpi->header_);
- wpi->is_partial_ = 1; // Waiting for ALPH and/or VP8/VP8L chunks.
-
- // Rest of the chunks.
- subchunk_size = ChunkDiskSize(&subchunk) - CHUNK_HEADER_SIZE;
- bytes += subchunk_size;
- size -= subchunk_size;
-
- while (bytes != last) {
- ChunkInit(&subchunk);
- if (ChunkVerifyAndAssign(&subchunk, bytes, size, size,
- copy_data) != WEBP_MUX_OK) {
- goto Fail;
- }
- switch (ChunkGetIdFromTag(subchunk.tag_)) {
- case WEBP_CHUNK_ALPHA:
- if (wpi->alpha_ != NULL) goto Fail; // Consecutive ALPH chunks.
- if (ChunkSetHead(&subchunk, &wpi->alpha_) != WEBP_MUX_OK) goto Fail;
- wpi->is_partial_ = 1; // Waiting for a VP8 chunk.
- break;
- case WEBP_CHUNK_IMAGE:
- if (wpi->img_ != NULL) goto Fail; // Only 1 image chunk allowed.
- if (ChunkSetHead(&subchunk, &wpi->img_) != WEBP_MUX_OK) goto Fail;
- if (!MuxImageFinalize(wpi)) goto Fail;
- wpi->is_partial_ = 0; // wpi is completely filled.
- break;
- case WEBP_CHUNK_UNKNOWN:
- if (wpi->is_partial_) {
- goto Fail; // Encountered an unknown chunk
- // before some image chunks.
- }
- if (ChunkAppend(&subchunk, &unknown_chunk_list) != WEBP_MUX_OK) {
- goto Fail;
- }
- break;
- default:
- goto Fail;
- }
- subchunk_size = ChunkDiskSize(&subchunk);
- bytes += subchunk_size;
- size -= subchunk_size;
- }
- if (wpi->is_partial_) goto Fail;
- return 1;
-
- Fail:
- ChunkRelease(&subchunk);
- return 0;
-}
-
-//------------------------------------------------------------------------------
-// Create a mux object from WebP-RIFF data.
-
-WebPMux* WebPMuxCreateInternal(const WebPData* bitstream, int copy_data,
- int version) {
- size_t riff_size;
- uint32_t tag;
- const uint8_t* end;
- WebPMux* mux = NULL;
- WebPMuxImage* wpi = NULL;
- const uint8_t* data;
- size_t size;
- WebPChunk chunk;
- // Stores the end of the chunk lists so that it is faster to append data to
- // their ends.
- WebPChunk** chunk_list_ends[WEBP_CHUNK_NIL + 1] = { NULL };
- ChunkInit(&chunk);
-
- if (WEBP_ABI_IS_INCOMPATIBLE(version, WEBP_MUX_ABI_VERSION)) {
- return NULL; // version mismatch
- }
- if (bitstream == NULL) return NULL;
-
- data = bitstream->bytes;
- size = bitstream->size;
-
- if (data == NULL) return NULL;
- if (size < RIFF_HEADER_SIZE + CHUNK_HEADER_SIZE) return NULL;
- if (GetLE32(data + 0) != MKFOURCC('R', 'I', 'F', 'F') ||
- GetLE32(data + CHUNK_HEADER_SIZE) != MKFOURCC('W', 'E', 'B', 'P')) {
- return NULL;
- }
-
- mux = WebPMuxNew();
- if (mux == NULL) return NULL;
-
- tag = GetLE32(data + RIFF_HEADER_SIZE);
- if (tag != kChunks[IDX_VP8].tag &&
- tag != kChunks[IDX_VP8L].tag &&
- tag != kChunks[IDX_VP8X].tag) {
- goto Err; // First chunk should be VP8, VP8L or VP8X.
- }
-
- riff_size = GetLE32(data + TAG_SIZE);
- if (riff_size > MAX_CHUNK_PAYLOAD) goto Err;
-
- // Note this padding is historical and differs from demux.c which does not
- // pad the file size.
- riff_size = SizeWithPadding(riff_size);
- if (riff_size < CHUNK_HEADER_SIZE) goto Err;
- if (riff_size > size) goto Err;
- // There's no point in reading past the end of the RIFF chunk.
- if (size > riff_size + CHUNK_HEADER_SIZE) {
- size = riff_size + CHUNK_HEADER_SIZE;
- }
-
- end = data + size;
- data += RIFF_HEADER_SIZE;
- size -= RIFF_HEADER_SIZE;
-
- wpi = (WebPMuxImage*)WebPSafeMalloc(1ULL, sizeof(*wpi));
- if (wpi == NULL) goto Err;
- MuxImageInit(wpi);
-
- // Loop over chunks.
- while (data != end) {
- size_t data_size;
- WebPChunkId id;
- if (ChunkVerifyAndAssign(&chunk, data, size, riff_size,
- copy_data) != WEBP_MUX_OK) {
- goto Err;
- }
- data_size = ChunkDiskSize(&chunk);
- id = ChunkGetIdFromTag(chunk.tag_);
- switch (id) {
- case WEBP_CHUNK_ALPHA:
- if (wpi->alpha_ != NULL) goto Err; // Consecutive ALPH chunks.
- if (ChunkSetHead(&chunk, &wpi->alpha_) != WEBP_MUX_OK) goto Err;
- wpi->is_partial_ = 1; // Waiting for a VP8 chunk.
- break;
- case WEBP_CHUNK_IMAGE:
- if (ChunkSetHead(&chunk, &wpi->img_) != WEBP_MUX_OK) goto Err;
- if (!MuxImageFinalize(wpi)) goto Err;
- wpi->is_partial_ = 0; // wpi is completely filled.
- PushImage:
- // Add this to mux->images_ list.
- if (MuxImagePush(wpi, &mux->images_) != WEBP_MUX_OK) goto Err;
- MuxImageInit(wpi); // Reset for reading next image.
- break;
- case WEBP_CHUNK_ANMF:
- if (wpi->is_partial_) goto Err; // Previous wpi is still incomplete.
- if (!MuxImageParse(&chunk, copy_data, wpi)) goto Err;
- ChunkRelease(&chunk);
- goto PushImage;
- default: // A non-image chunk.
- if (wpi->is_partial_) goto Err; // Encountered a non-image chunk before
- // getting all chunks of an image.
- if (chunk_list_ends[id] == NULL) {
- chunk_list_ends[id] =
- MuxGetChunkListFromId(mux, id); // List to add this chunk.
- }
- if (ChunkAppend(&chunk, &chunk_list_ends[id]) != WEBP_MUX_OK) goto Err;
- if (id == WEBP_CHUNK_VP8X) { // grab global specs
- if (data_size < CHUNK_HEADER_SIZE + VP8X_CHUNK_SIZE) goto Err;
- mux->canvas_width_ = GetLE24(data + 12) + 1;
- mux->canvas_height_ = GetLE24(data + 15) + 1;
- }
- break;
- }
- data += data_size;
- size -= data_size;
- ChunkInit(&chunk);
- }
-
- // Incomplete image.
- if (wpi->is_partial_) goto Err;
-
- // Validate mux if complete.
- if (MuxValidate(mux) != WEBP_MUX_OK) goto Err;
-
- MuxImageDelete(wpi);
- return mux; // All OK;
-
- Err: // Something bad happened.
- ChunkRelease(&chunk);
- MuxImageDelete(wpi);
- WebPMuxDelete(mux);
- return NULL;
-}
-
-//------------------------------------------------------------------------------
-// Get API(s).
-
-// Validates that the given mux has a single image.
-static WebPMuxError ValidateForSingleImage(const WebPMux* const mux) {
- const int num_images = MuxImageCount(mux->images_, WEBP_CHUNK_IMAGE);
- const int num_frames = MuxImageCount(mux->images_, WEBP_CHUNK_ANMF);
-
- if (num_images == 0) {
- // No images in mux.
- return WEBP_MUX_NOT_FOUND;
- } else if (num_images == 1 && num_frames == 0) {
- // Valid case (single image).
- return WEBP_MUX_OK;
- } else {
- // Frame case OR an invalid mux.
- return WEBP_MUX_INVALID_ARGUMENT;
- }
-}
-
-// Get the canvas width, height and flags after validating that VP8X/VP8/VP8L
-// chunk and canvas size are valid.
-static WebPMuxError MuxGetCanvasInfo(const WebPMux* const mux,
- int* width, int* height, uint32_t* flags) {
- int w, h;
- uint32_t f = 0;
- WebPData data;
- assert(mux != NULL);
-
- // Check if VP8X chunk is present.
- if (MuxGet(mux, IDX_VP8X, 1, &data) == WEBP_MUX_OK) {
- if (data.size < VP8X_CHUNK_SIZE) return WEBP_MUX_BAD_DATA;
- f = GetLE32(data.bytes + 0);
- w = GetLE24(data.bytes + 4) + 1;
- h = GetLE24(data.bytes + 7) + 1;
- } else {
- const WebPMuxImage* const wpi = mux->images_;
- // Grab user-forced canvas size as default.
- w = mux->canvas_width_;
- h = mux->canvas_height_;
- if (w == 0 && h == 0 && ValidateForSingleImage(mux) == WEBP_MUX_OK) {
- // single image and not forced canvas size => use dimension of first frame
- assert(wpi != NULL);
- w = wpi->width_;
- h = wpi->height_;
- }
- if (wpi != NULL) {
- if (wpi->has_alpha_) f |= ALPHA_FLAG;
- }
- }
- if (w * (uint64_t)h >= MAX_IMAGE_AREA) return WEBP_MUX_BAD_DATA;
-
- if (width != NULL) *width = w;
- if (height != NULL) *height = h;
- if (flags != NULL) *flags = f;
- return WEBP_MUX_OK;
-}
-
-WebPMuxError WebPMuxGetCanvasSize(const WebPMux* mux, int* width, int* height) {
- if (mux == NULL || width == NULL || height == NULL) {
- return WEBP_MUX_INVALID_ARGUMENT;
- }
- return MuxGetCanvasInfo(mux, width, height, NULL);
-}
-
-WebPMuxError WebPMuxGetFeatures(const WebPMux* mux, uint32_t* flags) {
- if (mux == NULL || flags == NULL) return WEBP_MUX_INVALID_ARGUMENT;
- return MuxGetCanvasInfo(mux, NULL, NULL, flags);
-}
-
-static uint8_t* EmitVP8XChunk(uint8_t* const dst, int width,
- int height, uint32_t flags) {
- const size_t vp8x_size = CHUNK_HEADER_SIZE + VP8X_CHUNK_SIZE;
- assert(width >= 1 && height >= 1);
- assert(width <= MAX_CANVAS_SIZE && height <= MAX_CANVAS_SIZE);
- assert(width * (uint64_t)height < MAX_IMAGE_AREA);
- PutLE32(dst, MKFOURCC('V', 'P', '8', 'X'));
- PutLE32(dst + TAG_SIZE, VP8X_CHUNK_SIZE);
- PutLE32(dst + CHUNK_HEADER_SIZE, flags);
- PutLE24(dst + CHUNK_HEADER_SIZE + 4, width - 1);
- PutLE24(dst + CHUNK_HEADER_SIZE + 7, height - 1);
- return dst + vp8x_size;
-}
-
-// Assemble a single image WebP bitstream from 'wpi'.
-static WebPMuxError SynthesizeBitstream(const WebPMuxImage* const wpi,
- WebPData* const bitstream) {
- uint8_t* dst;
-
- // Allocate data.
- const int need_vp8x = (wpi->alpha_ != NULL);
- const size_t vp8x_size = need_vp8x ? CHUNK_HEADER_SIZE + VP8X_CHUNK_SIZE : 0;
- const size_t alpha_size = need_vp8x ? ChunkDiskSize(wpi->alpha_) : 0;
- // Note: No need to output ANMF chunk for a single image.
- const size_t size = RIFF_HEADER_SIZE + vp8x_size + alpha_size +
- ChunkDiskSize(wpi->img_);
- uint8_t* const data = (uint8_t*)WebPSafeMalloc(1ULL, size);
- if (data == NULL) return WEBP_MUX_MEMORY_ERROR;
-
- // There should be at most one alpha_ chunk and exactly one img_ chunk.
- assert(wpi->alpha_ == NULL || wpi->alpha_->next_ == NULL);
- assert(wpi->img_ != NULL && wpi->img_->next_ == NULL);
-
- // Main RIFF header.
- dst = MuxEmitRiffHeader(data, size);
-
- if (need_vp8x) {
- dst = EmitVP8XChunk(dst, wpi->width_, wpi->height_, ALPHA_FLAG); // VP8X.
- dst = ChunkListEmit(wpi->alpha_, dst); // ALPH.
- }
-
- // Bitstream.
- dst = ChunkListEmit(wpi->img_, dst);
- assert(dst == data + size);
-
- // Output.
- bitstream->bytes = data;
- bitstream->size = size;
- return WEBP_MUX_OK;
-}
-
-WebPMuxError WebPMuxGetChunk(const WebPMux* mux, const char fourcc[4],
- WebPData* chunk_data) {
- CHUNK_INDEX idx;
- if (mux == NULL || fourcc == NULL || chunk_data == NULL) {
- return WEBP_MUX_INVALID_ARGUMENT;
- }
- idx = ChunkGetIndexFromFourCC(fourcc);
- if (IsWPI(kChunks[idx].id)) { // An image chunk.
- return WEBP_MUX_INVALID_ARGUMENT;
- } else if (idx != IDX_UNKNOWN) { // A known chunk type.
- return MuxGet(mux, idx, 1, chunk_data);
- } else { // An unknown chunk type.
- const WebPChunk* const chunk =
- ChunkSearchList(mux->unknown_, 1, ChunkGetTagFromFourCC(fourcc));
- if (chunk == NULL) return WEBP_MUX_NOT_FOUND;
- *chunk_data = chunk->data_;
- return WEBP_MUX_OK;
- }
-}
-
-static WebPMuxError MuxGetImageInternal(const WebPMuxImage* const wpi,
- WebPMuxFrameInfo* const info) {
- // Set some defaults for unrelated fields.
- info->x_offset = 0;
- info->y_offset = 0;
- info->duration = 1;
- info->dispose_method = WEBP_MUX_DISPOSE_NONE;
- info->blend_method = WEBP_MUX_BLEND;
- // Extract data for related fields.
- info->id = ChunkGetIdFromTag(wpi->img_->tag_);
- return SynthesizeBitstream(wpi, &info->bitstream);
-}
-
-static WebPMuxError MuxGetFrameInternal(const WebPMuxImage* const wpi,
- WebPMuxFrameInfo* const frame) {
- const int is_frame = (wpi->header_->tag_ == kChunks[IDX_ANMF].tag);
- const WebPData* frame_data;
- if (!is_frame) return WEBP_MUX_INVALID_ARGUMENT;
- assert(wpi->header_ != NULL); // Already checked by WebPMuxGetFrame().
- // Get frame chunk.
- frame_data = &wpi->header_->data_;
- if (frame_data->size < kChunks[IDX_ANMF].size) return WEBP_MUX_BAD_DATA;
- // Extract info.
- frame->x_offset = 2 * GetLE24(frame_data->bytes + 0);
- frame->y_offset = 2 * GetLE24(frame_data->bytes + 3);
- {
- const uint8_t bits = frame_data->bytes[15];
- frame->duration = GetLE24(frame_data->bytes + 12);
- frame->dispose_method =
- (bits & 1) ? WEBP_MUX_DISPOSE_BACKGROUND : WEBP_MUX_DISPOSE_NONE;
- frame->blend_method = (bits & 2) ? WEBP_MUX_NO_BLEND : WEBP_MUX_BLEND;
- }
- frame->id = ChunkGetIdFromTag(wpi->header_->tag_);
- return SynthesizeBitstream(wpi, &frame->bitstream);
-}
-
-WebPMuxError WebPMuxGetFrame(
- const WebPMux* mux, uint32_t nth, WebPMuxFrameInfo* frame) {
- WebPMuxError err;
- WebPMuxImage* wpi;
-
- if (mux == NULL || frame == NULL) {
- return WEBP_MUX_INVALID_ARGUMENT;
- }
-
- // Get the nth WebPMuxImage.
- err = MuxImageGetNth((const WebPMuxImage**)&mux->images_, nth, &wpi);
- if (err != WEBP_MUX_OK) return err;
-
- // Get frame info.
- if (wpi->header_ == NULL) {
- return MuxGetImageInternal(wpi, frame);
- } else {
- return MuxGetFrameInternal(wpi, frame);
- }
-}
-
-WebPMuxError WebPMuxGetAnimationParams(const WebPMux* mux,
- WebPMuxAnimParams* params) {
- WebPData anim;
- WebPMuxError err;
-
- if (mux == NULL || params == NULL) return WEBP_MUX_INVALID_ARGUMENT;
-
- err = MuxGet(mux, IDX_ANIM, 1, &anim);
- if (err != WEBP_MUX_OK) return err;
- if (anim.size < kChunks[WEBP_CHUNK_ANIM].size) return WEBP_MUX_BAD_DATA;
- params->bgcolor = GetLE32(anim.bytes);
- params->loop_count = GetLE16(anim.bytes + 4);
-
- return WEBP_MUX_OK;
-}
-
-// Get chunk index from chunk id. Returns IDX_NIL if not found.
-static CHUNK_INDEX ChunkGetIndexFromId(WebPChunkId id) {
- int i;
- for (i = 0; kChunks[i].id != WEBP_CHUNK_NIL; ++i) {
- if (id == kChunks[i].id) return (CHUNK_INDEX)i;
- }
- return IDX_NIL;
-}
-
-// Count number of chunks matching 'tag' in the 'chunk_list'.
-// If tag == NIL_TAG, any tag will be matched.
-static int CountChunks(const WebPChunk* const chunk_list, uint32_t tag) {
- int count = 0;
- const WebPChunk* current;
- for (current = chunk_list; current != NULL; current = current->next_) {
- if (tag == NIL_TAG || current->tag_ == tag) {
- count++; // Count chunks whose tags match.
- }
- }
- return count;
-}
-
-WebPMuxError WebPMuxNumChunks(const WebPMux* mux,
- WebPChunkId id, int* num_elements) {
- if (mux == NULL || num_elements == NULL) {
- return WEBP_MUX_INVALID_ARGUMENT;
- }
-
- if (IsWPI(id)) {
- *num_elements = MuxImageCount(mux->images_, id);
- } else {
- WebPChunk* const* chunk_list = MuxGetChunkListFromId(mux, id);
- const CHUNK_INDEX idx = ChunkGetIndexFromId(id);
- *num_elements = CountChunks(*chunk_list, kChunks[idx].tag);
- }
-
- return WEBP_MUX_OK;
-}
-
-//------------------------------------------------------------------------------
diff --git a/contrib/libs/libwebp/mux/ya.make b/contrib/libs/libwebp/mux/ya.make
deleted file mode 100644
index b4eaf89f4c..0000000000
--- a/contrib/libs/libwebp/mux/ya.make
+++ /dev/null
@@ -1,35 +0,0 @@
-# Generated by devtools/yamaker.
-
-LIBRARY()
-
-VERSION(1.2.2)
-
-LICENSE(BSD-3-Clause WITH Google-Patent-License-Webm)
-
-LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
-
-PEERDIR(
- contrib/libs/libwebp
-)
-
-ADDINCL(
- contrib/libs/libwebp/mux
- contrib/libs/libwebp/webp
-)
-
-NO_COMPILER_WARNINGS()
-
-NO_RUNTIME()
-
-CFLAGS(
- -DHAVE_CONFIG_H
-)
-
-SRCS(
- anim_encode.c
- muxedit.c
- muxinternal.c
- muxread.c
-)
-
-END()
diff --git a/contrib/libs/libwebp/utils/bit_reader_inl_utils.h b/contrib/libs/libwebp/utils/bit_reader_inl_utils.h
deleted file mode 100644
index d7f6d8844d..0000000000
--- a/contrib/libs/libwebp/utils/bit_reader_inl_utils.h
+++ /dev/null
@@ -1,196 +0,0 @@
-// Copyright 2014 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Specific inlined methods for boolean decoder [VP8GetBit() ...]
-// This file should be included by the .c sources that actually need to call
-// these methods.
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#ifndef WEBP_UTILS_BIT_READER_INL_UTILS_H_
-#define WEBP_UTILS_BIT_READER_INL_UTILS_H_
-
-#ifdef HAVE_CONFIG_H
-#include "../webp/config.h"
-#endif
-
-#include <string.h> // for memcpy
-
-#include "../dsp/dsp.h"
-#include "./bit_reader_utils.h"
-#include "./endian_inl_utils.h"
-#include "./utils.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-//------------------------------------------------------------------------------
-// Derived type lbit_t = natural type for memory I/O
-
-#if (BITS > 32)
-typedef uint64_t lbit_t;
-#elif (BITS > 16)
-typedef uint32_t lbit_t;
-#elif (BITS > 8)
-typedef uint16_t lbit_t;
-#else
-typedef uint8_t lbit_t;
-#endif
-
-extern const uint8_t kVP8Log2Range[128];
-extern const uint8_t kVP8NewRange[128];
-
-// special case for the tail byte-reading
-void VP8LoadFinalBytes(VP8BitReader* const br);
-
-//------------------------------------------------------------------------------
-// Inlined critical functions
-
-// makes sure br->value_ has at least BITS bits worth of data
-static WEBP_UBSAN_IGNORE_UNDEF WEBP_INLINE
-void VP8LoadNewBytes(VP8BitReader* WEBP_RESTRICT const br) {
- assert(br != NULL && br->buf_ != NULL);
- // Read 'BITS' bits at a time if possible.
- if (br->buf_ < br->buf_max_) {
- // convert memory type to register type (with some zero'ing!)
- bit_t bits;
-#if defined(WEBP_USE_MIPS32)
- // This is needed because of un-aligned read.
- lbit_t in_bits;
- lbit_t* p_buf_ = (lbit_t*)br->buf_;
- __asm__ volatile(
- ".set push \n\t"
- ".set at \n\t"
- ".set macro \n\t"
- "ulw %[in_bits], 0(%[p_buf_]) \n\t"
- ".set pop \n\t"
- : [in_bits]"=r"(in_bits)
- : [p_buf_]"r"(p_buf_)
- : "memory", "at"
- );
-#else
- lbit_t in_bits;
- memcpy(&in_bits, br->buf_, sizeof(in_bits));
-#endif
- br->buf_ += BITS >> 3;
-#if !defined(WORDS_BIGENDIAN)
-#if (BITS > 32)
- bits = BSwap64(in_bits);
- bits >>= 64 - BITS;
-#elif (BITS >= 24)
- bits = BSwap32(in_bits);
- bits >>= (32 - BITS);
-#elif (BITS == 16)
- bits = BSwap16(in_bits);
-#else // BITS == 8
- bits = (bit_t)in_bits;
-#endif // BITS > 32
-#else // WORDS_BIGENDIAN
- bits = (bit_t)in_bits;
- if (BITS != 8 * sizeof(bit_t)) bits >>= (8 * sizeof(bit_t) - BITS);
-#endif
- br->value_ = bits | (br->value_ << BITS);
- br->bits_ += BITS;
- } else {
- VP8LoadFinalBytes(br); // no need to be inlined
- }
-}
-
-// Read a bit with proba 'prob'. Speed-critical function!
-static WEBP_INLINE int VP8GetBit(VP8BitReader* WEBP_RESTRICT const br,
- int prob, const char label[]) {
- // Don't move this declaration! It makes a big speed difference to store
- // 'range' *before* calling VP8LoadNewBytes(), even if this function doesn't
- // alter br->range_ value.
- range_t range = br->range_;
- if (br->bits_ < 0) {
- VP8LoadNewBytes(br);
- }
- {
- const int pos = br->bits_;
- const range_t split = (range * prob) >> 8;
- const range_t value = (range_t)(br->value_ >> pos);
- const int bit = (value > split);
- if (bit) {
- range -= split;
- br->value_ -= (bit_t)(split + 1) << pos;
- } else {
- range = split + 1;
- }
- {
- const int shift = 7 ^ BitsLog2Floor(range);
- range <<= shift;
- br->bits_ -= shift;
- }
- br->range_ = range - 1;
- BT_TRACK(br);
- return bit;
- }
-}
-
-// simplified version of VP8GetBit() for prob=0x80 (note shift is always 1 here)
-static WEBP_UBSAN_IGNORE_UNSIGNED_OVERFLOW WEBP_INLINE
-int VP8GetSigned(VP8BitReader* WEBP_RESTRICT const br, int v,
- const char label[]) {
- if (br->bits_ < 0) {
- VP8LoadNewBytes(br);
- }
- {
- const int pos = br->bits_;
- const range_t split = br->range_ >> 1;
- const range_t value = (range_t)(br->value_ >> pos);
- const int32_t mask = (int32_t)(split - value) >> 31; // -1 or 0
- br->bits_ -= 1;
- br->range_ += mask;
- br->range_ |= 1;
- br->value_ -= (bit_t)((split + 1) & mask) << pos;
- BT_TRACK(br);
- return (v ^ mask) - mask;
- }
-}
-
-static WEBP_INLINE int VP8GetBitAlt(VP8BitReader* WEBP_RESTRICT const br,
- int prob, const char label[]) {
- // Don't move this declaration! It makes a big speed difference to store
- // 'range' *before* calling VP8LoadNewBytes(), even if this function doesn't
- // alter br->range_ value.
- range_t range = br->range_;
- if (br->bits_ < 0) {
- VP8LoadNewBytes(br);
- }
- {
- const int pos = br->bits_;
- const range_t split = (range * prob) >> 8;
- const range_t value = (range_t)(br->value_ >> pos);
- int bit; // Don't use 'const int bit = (value > split);", it's slower.
- if (value > split) {
- range -= split + 1;
- br->value_ -= (bit_t)(split + 1) << pos;
- bit = 1;
- } else {
- range = split;
- bit = 0;
- }
- if (range <= (range_t)0x7e) {
- const int shift = kVP8Log2Range[range];
- range = kVP8NewRange[range];
- br->bits_ -= shift;
- }
- br->range_ = range;
- BT_TRACK(br);
- return bit;
- }
-}
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // WEBP_UTILS_BIT_READER_INL_UTILS_H_
diff --git a/contrib/libs/libwebp/utils/bit_reader_utils.c b/contrib/libs/libwebp/utils/bit_reader_utils.c
deleted file mode 100644
index 6f6451d3cd..0000000000
--- a/contrib/libs/libwebp/utils/bit_reader_utils.c
+++ /dev/null
@@ -1,298 +0,0 @@
-// Copyright 2010 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Boolean decoder non-inlined methods
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#ifdef HAVE_CONFIG_H
-#include "../webp/config.h"
-#endif
-
-#include "./bit_reader_inl_utils.h"
-#include "./utils.h"
-
-//------------------------------------------------------------------------------
-// VP8BitReader
-
-void VP8BitReaderSetBuffer(VP8BitReader* const br,
- const uint8_t* const start,
- size_t size) {
- br->buf_ = start;
- br->buf_end_ = start + size;
- br->buf_max_ =
- (size >= sizeof(lbit_t)) ? start + size - sizeof(lbit_t) + 1
- : start;
-}
-
-void VP8InitBitReader(VP8BitReader* const br,
- const uint8_t* const start, size_t size) {
- assert(br != NULL);
- assert(start != NULL);
- assert(size < (1u << 31)); // limit ensured by format and upstream checks
- br->range_ = 255 - 1;
- br->value_ = 0;
- br->bits_ = -8; // to load the very first 8bits
- br->eof_ = 0;
- VP8BitReaderSetBuffer(br, start, size);
- VP8LoadNewBytes(br);
-}
-
-void VP8RemapBitReader(VP8BitReader* const br, ptrdiff_t offset) {
- if (br->buf_ != NULL) {
- br->buf_ += offset;
- br->buf_end_ += offset;
- br->buf_max_ += offset;
- }
-}
-
-const uint8_t kVP8Log2Range[128] = {
- 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 0
-};
-
-// range = ((range - 1) << kVP8Log2Range[range]) + 1
-const uint8_t kVP8NewRange[128] = {
- 127, 127, 191, 127, 159, 191, 223, 127,
- 143, 159, 175, 191, 207, 223, 239, 127,
- 135, 143, 151, 159, 167, 175, 183, 191,
- 199, 207, 215, 223, 231, 239, 247, 127,
- 131, 135, 139, 143, 147, 151, 155, 159,
- 163, 167, 171, 175, 179, 183, 187, 191,
- 195, 199, 203, 207, 211, 215, 219, 223,
- 227, 231, 235, 239, 243, 247, 251, 127,
- 129, 131, 133, 135, 137, 139, 141, 143,
- 145, 147, 149, 151, 153, 155, 157, 159,
- 161, 163, 165, 167, 169, 171, 173, 175,
- 177, 179, 181, 183, 185, 187, 189, 191,
- 193, 195, 197, 199, 201, 203, 205, 207,
- 209, 211, 213, 215, 217, 219, 221, 223,
- 225, 227, 229, 231, 233, 235, 237, 239,
- 241, 243, 245, 247, 249, 251, 253, 127
-};
-
-void VP8LoadFinalBytes(VP8BitReader* const br) {
- assert(br != NULL && br->buf_ != NULL);
- // Only read 8bits at a time
- if (br->buf_ < br->buf_end_) {
- br->bits_ += 8;
- br->value_ = (bit_t)(*br->buf_++) | (br->value_ << 8);
- } else if (!br->eof_) {
- br->value_ <<= 8;
- br->bits_ += 8;
- br->eof_ = 1;
- } else {
- br->bits_ = 0; // This is to avoid undefined behaviour with shifts.
- }
-}
-
-//------------------------------------------------------------------------------
-// Higher-level calls
-
-uint32_t VP8GetValue(VP8BitReader* const br, int bits, const char label[]) {
- uint32_t v = 0;
- while (bits-- > 0) {
- v |= VP8GetBit(br, 0x80, label) << bits;
- }
- return v;
-}
-
-int32_t VP8GetSignedValue(VP8BitReader* const br, int bits,
- const char label[]) {
- const int value = VP8GetValue(br, bits, label);
- return VP8Get(br, label) ? -value : value;
-}
-
-//------------------------------------------------------------------------------
-// VP8LBitReader
-
-#define VP8L_LOG8_WBITS 4 // Number of bytes needed to store VP8L_WBITS bits.
-
-#if defined(__arm__) || defined(_M_ARM) || defined(__aarch64__) || \
- defined(__i386__) || defined(_M_IX86) || \
- defined(__x86_64__) || defined(_M_X64)
-#define VP8L_USE_FAST_LOAD
-#endif
-
-static const uint32_t kBitMask[VP8L_MAX_NUM_BIT_READ + 1] = {
- 0,
- 0x000001, 0x000003, 0x000007, 0x00000f,
- 0x00001f, 0x00003f, 0x00007f, 0x0000ff,
- 0x0001ff, 0x0003ff, 0x0007ff, 0x000fff,
- 0x001fff, 0x003fff, 0x007fff, 0x00ffff,
- 0x01ffff, 0x03ffff, 0x07ffff, 0x0fffff,
- 0x1fffff, 0x3fffff, 0x7fffff, 0xffffff
-};
-
-void VP8LInitBitReader(VP8LBitReader* const br, const uint8_t* const start,
- size_t length) {
- size_t i;
- vp8l_val_t value = 0;
- assert(br != NULL);
- assert(start != NULL);
- assert(length < 0xfffffff8u); // can't happen with a RIFF chunk.
-
- br->len_ = length;
- br->val_ = 0;
- br->bit_pos_ = 0;
- br->eos_ = 0;
-
- if (length > sizeof(br->val_)) {
- length = sizeof(br->val_);
- }
- for (i = 0; i < length; ++i) {
- value |= (vp8l_val_t)start[i] << (8 * i);
- }
- br->val_ = value;
- br->pos_ = length;
- br->buf_ = start;
-}
-
-void VP8LBitReaderSetBuffer(VP8LBitReader* const br,
- const uint8_t* const buf, size_t len) {
- assert(br != NULL);
- assert(buf != NULL);
- assert(len < 0xfffffff8u); // can't happen with a RIFF chunk.
- br->buf_ = buf;
- br->len_ = len;
- // pos_ > len_ should be considered a param error.
- br->eos_ = (br->pos_ > br->len_) || VP8LIsEndOfStream(br);
-}
-
-static void VP8LSetEndOfStream(VP8LBitReader* const br) {
- br->eos_ = 1;
- br->bit_pos_ = 0; // To avoid undefined behaviour with shifts.
-}
-
-// If not at EOS, reload up to VP8L_LBITS byte-by-byte
-static void ShiftBytes(VP8LBitReader* const br) {
- while (br->bit_pos_ >= 8 && br->pos_ < br->len_) {
- br->val_ >>= 8;
- br->val_ |= ((vp8l_val_t)br->buf_[br->pos_]) << (VP8L_LBITS - 8);
- ++br->pos_;
- br->bit_pos_ -= 8;
- }
- if (VP8LIsEndOfStream(br)) {
- VP8LSetEndOfStream(br);
- }
-}
-
-void VP8LDoFillBitWindow(VP8LBitReader* const br) {
- assert(br->bit_pos_ >= VP8L_WBITS);
-#if defined(VP8L_USE_FAST_LOAD)
- if (br->pos_ + sizeof(br->val_) < br->len_) {
- br->val_ >>= VP8L_WBITS;
- br->bit_pos_ -= VP8L_WBITS;
- br->val_ |= (vp8l_val_t)HToLE32(WebPMemToUint32(br->buf_ + br->pos_)) <<
- (VP8L_LBITS - VP8L_WBITS);
- br->pos_ += VP8L_LOG8_WBITS;
- return;
- }
-#endif
- ShiftBytes(br); // Slow path.
-}
-
-uint32_t VP8LReadBits(VP8LBitReader* const br, int n_bits) {
- assert(n_bits >= 0);
- // Flag an error if end_of_stream or n_bits is more than allowed limit.
- if (!br->eos_ && n_bits <= VP8L_MAX_NUM_BIT_READ) {
- const uint32_t val = VP8LPrefetchBits(br) & kBitMask[n_bits];
- const int new_bits = br->bit_pos_ + n_bits;
- br->bit_pos_ = new_bits;
- ShiftBytes(br);
- return val;
- } else {
- VP8LSetEndOfStream(br);
- return 0;
- }
-}
-
-//------------------------------------------------------------------------------
-// Bit-tracing tool
-
-#if (BITTRACE > 0)
-
-#include <stdlib.h> // for atexit()
-#include <stdio.h>
-#include <string.h>
-
-#define MAX_NUM_LABELS 32
-static struct {
- const char* label;
- int size;
- int count;
-} kLabels[MAX_NUM_LABELS];
-
-static int last_label = 0;
-static int last_pos = 0;
-static const uint8_t* buf_start = NULL;
-static int init_done = 0;
-
-static void PrintBitTraces(void) {
- int i;
- int scale = 1;
- int total = 0;
- const char* units = "bits";
-#if (BITTRACE == 2)
- scale = 8;
- units = "bytes";
-#endif
- for (i = 0; i < last_label; ++i) total += kLabels[i].size;
- if (total < 1) total = 1; // avoid rounding errors
- printf("=== Bit traces ===\n");
- for (i = 0; i < last_label; ++i) {
- const int skip = 16 - (int)strlen(kLabels[i].label);
- const int value = (kLabels[i].size + scale - 1) / scale;
- assert(skip > 0);
- printf("%s \%*s: %6d %s \t[%5.2f%%] [count: %7d]\n",
- kLabels[i].label, skip, "", value, units,
- 100.f * kLabels[i].size / total,
- kLabels[i].count);
- }
- total = (total + scale - 1) / scale;
- printf("Total: %d %s\n", total, units);
-}
-
-void BitTrace(const struct VP8BitReader* const br, const char label[]) {
- int i, pos;
- if (!init_done) {
- memset(kLabels, 0, sizeof(kLabels));
- atexit(PrintBitTraces);
- buf_start = br->buf_;
- init_done = 1;
- }
- pos = (int)(br->buf_ - buf_start) * 8 - br->bits_;
- // if there's a too large jump, we've changed partition -> reset counter
- if (abs(pos - last_pos) > 32) {
- buf_start = br->buf_;
- pos = 0;
- last_pos = 0;
- }
- if (br->range_ >= 0x7f) pos += kVP8Log2Range[br->range_ - 0x7f];
- for (i = 0; i < last_label; ++i) {
- if (!strcmp(label, kLabels[i].label)) break;
- }
- if (i == MAX_NUM_LABELS) abort(); // overflow!
- kLabels[i].label = label;
- kLabels[i].size += pos - last_pos;
- kLabels[i].count += 1;
- if (i == last_label) ++last_label;
- last_pos = pos;
-}
-
-#endif // BITTRACE > 0
-
-//------------------------------------------------------------------------------
diff --git a/contrib/libs/libwebp/utils/bit_reader_utils.h b/contrib/libs/libwebp/utils/bit_reader_utils.h
deleted file mode 100644
index 2df9c417cf..0000000000
--- a/contrib/libs/libwebp/utils/bit_reader_utils.h
+++ /dev/null
@@ -1,194 +0,0 @@
-// Copyright 2010 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Boolean decoder
-//
-// Author: Skal (pascal.massimino@gmail.com)
-// Vikas Arora (vikaas.arora@gmail.com)
-
-#ifndef WEBP_UTILS_BIT_READER_UTILS_H_
-#define WEBP_UTILS_BIT_READER_UTILS_H_
-
-#include <assert.h>
-#ifdef _MSC_VER
-#include <stdlib.h> // _byteswap_ulong
-#endif
-#include "../webp/types.h"
-
-// Warning! This macro triggers quite some MACRO wizardry around func signature!
-#if !defined(BITTRACE)
-#define BITTRACE 0 // 0 = off, 1 = print bits, 2 = print bytes
-#endif
-
-#if (BITTRACE > 0)
-struct VP8BitReader;
-extern void BitTrace(const struct VP8BitReader* const br, const char label[]);
-#define BT_TRACK(br) BitTrace(br, label)
-#define VP8Get(BR, L) VP8GetValue(BR, 1, L)
-#else
-#define BT_TRACK(br)
-// We'll REMOVE the 'const char label[]' from all signatures and calls (!!):
-#define VP8GetValue(BR, N, L) VP8GetValue(BR, N)
-#define VP8Get(BR, L) VP8GetValue(BR, 1, L)
-#define VP8GetSignedValue(BR, N, L) VP8GetSignedValue(BR, N)
-#define VP8GetBit(BR, P, L) VP8GetBit(BR, P)
-#define VP8GetBitAlt(BR, P, L) VP8GetBitAlt(BR, P)
-#define VP8GetSigned(BR, V, L) VP8GetSigned(BR, V)
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// The Boolean decoder needs to maintain infinite precision on the value_ field.
-// However, since range_ is only 8bit, we only need an active window of 8 bits
-// for value_. Left bits (MSB) gets zeroed and shifted away when value_ falls
-// below 128, range_ is updated, and fresh bits read from the bitstream are
-// brought in as LSB. To avoid reading the fresh bits one by one (slow), we
-// cache BITS of them ahead. The total of (BITS + 8) bits must fit into a
-// natural register (with type bit_t). To fetch BITS bits from bitstream we
-// use a type lbit_t.
-//
-// BITS can be any multiple of 8 from 8 to 56 (inclusive).
-// Pick values that fit natural register size.
-
-#if defined(__i386__) || defined(_M_IX86) // x86 32bit
-#define BITS 24
-#elif defined(__x86_64__) || defined(_M_X64) // x86 64bit
-#define BITS 56
-#elif defined(__arm__) || defined(_M_ARM) // ARM
-#define BITS 24
-#elif defined(__aarch64__) // ARM 64bit
-#define BITS 56
-#elif defined(__mips__) // MIPS
-#define BITS 24
-#else // reasonable default
-#define BITS 24
-#endif
-
-//------------------------------------------------------------------------------
-// Derived types and constants:
-// bit_t = natural register type for storing 'value_' (which is BITS+8 bits)
-// range_t = register for 'range_' (which is 8bits only)
-
-#if (BITS > 24)
-typedef uint64_t bit_t;
-#else
-typedef uint32_t bit_t;
-#endif
-
-typedef uint32_t range_t;
-
-//------------------------------------------------------------------------------
-// Bitreader
-
-typedef struct VP8BitReader VP8BitReader;
-struct VP8BitReader {
- // boolean decoder (keep the field ordering as is!)
- bit_t value_; // current value
- range_t range_; // current range minus 1. In [127, 254] interval.
- int bits_; // number of valid bits left
- // read buffer
- const uint8_t* buf_; // next byte to be read
- const uint8_t* buf_end_; // end of read buffer
- const uint8_t* buf_max_; // max packed-read position on buffer
- int eof_; // true if input is exhausted
-};
-
-// Initialize the bit reader and the boolean decoder.
-void VP8InitBitReader(VP8BitReader* const br,
- const uint8_t* const start, size_t size);
-// Sets the working read buffer.
-void VP8BitReaderSetBuffer(VP8BitReader* const br,
- const uint8_t* const start, size_t size);
-
-// Update internal pointers to displace the byte buffer by the
-// relative offset 'offset'.
-void VP8RemapBitReader(VP8BitReader* const br, ptrdiff_t offset);
-
-// return the next value made of 'num_bits' bits
-uint32_t VP8GetValue(VP8BitReader* const br, int num_bits, const char label[]);
-
-// return the next value with sign-extension.
-int32_t VP8GetSignedValue(VP8BitReader* const br, int num_bits,
- const char label[]);
-
-// bit_reader_inl.h will implement the following methods:
-// static WEBP_INLINE int VP8GetBit(VP8BitReader* const br, int prob, ...)
-// static WEBP_INLINE int VP8GetSigned(VP8BitReader* const br, int v, ...)
-// and should be included by the .c files that actually need them.
-// This is to avoid recompiling the whole library whenever this file is touched,
-// and also allowing platform-specific ad-hoc hacks.
-
-// -----------------------------------------------------------------------------
-// Bitreader for lossless format
-
-// maximum number of bits (inclusive) the bit-reader can handle:
-#define VP8L_MAX_NUM_BIT_READ 24
-
-#define VP8L_LBITS 64 // Number of bits prefetched (= bit-size of vp8l_val_t).
-#define VP8L_WBITS 32 // Minimum number of bytes ready after VP8LFillBitWindow.
-
-typedef uint64_t vp8l_val_t; // right now, this bit-reader can only use 64bit.
-
-typedef struct {
- vp8l_val_t val_; // pre-fetched bits
- const uint8_t* buf_; // input byte buffer
- size_t len_; // buffer length
- size_t pos_; // byte position in buf_
- int bit_pos_; // current bit-reading position in val_
- int eos_; // true if a bit was read past the end of buffer
-} VP8LBitReader;
-
-void VP8LInitBitReader(VP8LBitReader* const br,
- const uint8_t* const start,
- size_t length);
-
-// Sets a new data buffer.
-void VP8LBitReaderSetBuffer(VP8LBitReader* const br,
- const uint8_t* const buffer, size_t length);
-
-// Reads the specified number of bits from read buffer.
-// Flags an error in case end_of_stream or n_bits is more than the allowed limit
-// of VP8L_MAX_NUM_BIT_READ (inclusive).
-// Flags eos_ if this read attempt is going to cross the read buffer.
-uint32_t VP8LReadBits(VP8LBitReader* const br, int n_bits);
-
-// Return the prefetched bits, so they can be looked up.
-static WEBP_INLINE uint32_t VP8LPrefetchBits(VP8LBitReader* const br) {
- return (uint32_t)(br->val_ >> (br->bit_pos_ & (VP8L_LBITS - 1)));
-}
-
-// Returns true if there was an attempt at reading bit past the end of
-// the buffer. Doesn't set br->eos_ flag.
-static WEBP_INLINE int VP8LIsEndOfStream(const VP8LBitReader* const br) {
- assert(br->pos_ <= br->len_);
- return br->eos_ || ((br->pos_ == br->len_) && (br->bit_pos_ > VP8L_LBITS));
-}
-
-// For jumping over a number of bits in the bit stream when accessed with
-// VP8LPrefetchBits and VP8LFillBitWindow.
-// This function does *not* set br->eos_, since it's speed-critical.
-// Use with extreme care!
-static WEBP_INLINE void VP8LSetBitPos(VP8LBitReader* const br, int val) {
- br->bit_pos_ = val;
-}
-
-// Advances the read buffer by 4 bytes to make room for reading next 32 bits.
-// Speed critical, but infrequent part of the code can be non-inlined.
-extern void VP8LDoFillBitWindow(VP8LBitReader* const br);
-static WEBP_INLINE void VP8LFillBitWindow(VP8LBitReader* const br) {
- if (br->bit_pos_ >= VP8L_WBITS) VP8LDoFillBitWindow(br);
-}
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // WEBP_UTILS_BIT_READER_UTILS_H_
diff --git a/contrib/libs/libwebp/utils/bit_writer_utils.c b/contrib/libs/libwebp/utils/bit_writer_utils.c
deleted file mode 100644
index 0a253fb611..0000000000
--- a/contrib/libs/libwebp/utils/bit_writer_utils.c
+++ /dev/null
@@ -1,347 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Bit writing and boolean coder
-//
-// Author: Skal (pascal.massimino@gmail.com)
-// Vikas Arora (vikaas.arora@gmail.com)
-
-#include <assert.h>
-#include <string.h> // for memcpy()
-#include <stdlib.h>
-
-#include "./bit_writer_utils.h"
-#include "./endian_inl_utils.h"
-#include "./utils.h"
-
-//------------------------------------------------------------------------------
-// VP8BitWriter
-
-static int BitWriterResize(VP8BitWriter* const bw, size_t extra_size) {
- uint8_t* new_buf;
- size_t new_size;
- const uint64_t needed_size_64b = (uint64_t)bw->pos_ + extra_size;
- const size_t needed_size = (size_t)needed_size_64b;
- if (needed_size_64b != needed_size) {
- bw->error_ = 1;
- return 0;
- }
- if (needed_size <= bw->max_pos_) return 1;
- // If the following line wraps over 32bit, the test just after will catch it.
- new_size = 2 * bw->max_pos_;
- if (new_size < needed_size) new_size = needed_size;
- if (new_size < 1024) new_size = 1024;
- new_buf = (uint8_t*)WebPSafeMalloc(1ULL, new_size);
- if (new_buf == NULL) {
- bw->error_ = 1;
- return 0;
- }
- if (bw->pos_ > 0) {
- assert(bw->buf_ != NULL);
- memcpy(new_buf, bw->buf_, bw->pos_);
- }
- WebPSafeFree(bw->buf_);
- bw->buf_ = new_buf;
- bw->max_pos_ = new_size;
- return 1;
-}
-
-static void Flush(VP8BitWriter* const bw) {
- const int s = 8 + bw->nb_bits_;
- const int32_t bits = bw->value_ >> s;
- assert(bw->nb_bits_ >= 0);
- bw->value_ -= bits << s;
- bw->nb_bits_ -= 8;
- if ((bits & 0xff) != 0xff) {
- size_t pos = bw->pos_;
- if (!BitWriterResize(bw, bw->run_ + 1)) {
- return;
- }
- if (bits & 0x100) { // overflow -> propagate carry over pending 0xff's
- if (pos > 0) bw->buf_[pos - 1]++;
- }
- if (bw->run_ > 0) {
- const int value = (bits & 0x100) ? 0x00 : 0xff;
- for (; bw->run_ > 0; --bw->run_) bw->buf_[pos++] = value;
- }
- bw->buf_[pos++] = bits & 0xff;
- bw->pos_ = pos;
- } else {
- bw->run_++; // delay writing of bytes 0xff, pending eventual carry.
- }
-}
-
-//------------------------------------------------------------------------------
-// renormalization
-
-static const uint8_t kNorm[128] = { // renorm_sizes[i] = 8 - log2(i)
- 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 0
-};
-
-// range = ((range + 1) << kVP8Log2Range[range]) - 1
-static const uint8_t kNewRange[128] = {
- 127, 127, 191, 127, 159, 191, 223, 127, 143, 159, 175, 191, 207, 223, 239,
- 127, 135, 143, 151, 159, 167, 175, 183, 191, 199, 207, 215, 223, 231, 239,
- 247, 127, 131, 135, 139, 143, 147, 151, 155, 159, 163, 167, 171, 175, 179,
- 183, 187, 191, 195, 199, 203, 207, 211, 215, 219, 223, 227, 231, 235, 239,
- 243, 247, 251, 127, 129, 131, 133, 135, 137, 139, 141, 143, 145, 147, 149,
- 151, 153, 155, 157, 159, 161, 163, 165, 167, 169, 171, 173, 175, 177, 179,
- 181, 183, 185, 187, 189, 191, 193, 195, 197, 199, 201, 203, 205, 207, 209,
- 211, 213, 215, 217, 219, 221, 223, 225, 227, 229, 231, 233, 235, 237, 239,
- 241, 243, 245, 247, 249, 251, 253, 127
-};
-
-int VP8PutBit(VP8BitWriter* const bw, int bit, int prob) {
- const int split = (bw->range_ * prob) >> 8;
- if (bit) {
- bw->value_ += split + 1;
- bw->range_ -= split + 1;
- } else {
- bw->range_ = split;
- }
- if (bw->range_ < 127) { // emit 'shift' bits out and renormalize
- const int shift = kNorm[bw->range_];
- bw->range_ = kNewRange[bw->range_];
- bw->value_ <<= shift;
- bw->nb_bits_ += shift;
- if (bw->nb_bits_ > 0) Flush(bw);
- }
- return bit;
-}
-
-int VP8PutBitUniform(VP8BitWriter* const bw, int bit) {
- const int split = bw->range_ >> 1;
- if (bit) {
- bw->value_ += split + 1;
- bw->range_ -= split + 1;
- } else {
- bw->range_ = split;
- }
- if (bw->range_ < 127) {
- bw->range_ = kNewRange[bw->range_];
- bw->value_ <<= 1;
- bw->nb_bits_ += 1;
- if (bw->nb_bits_ > 0) Flush(bw);
- }
- return bit;
-}
-
-void VP8PutBits(VP8BitWriter* const bw, uint32_t value, int nb_bits) {
- uint32_t mask;
- assert(nb_bits > 0 && nb_bits < 32);
- for (mask = 1u << (nb_bits - 1); mask; mask >>= 1) {
- VP8PutBitUniform(bw, value & mask);
- }
-}
-
-void VP8PutSignedBits(VP8BitWriter* const bw, int value, int nb_bits) {
- if (!VP8PutBitUniform(bw, value != 0)) return;
- if (value < 0) {
- VP8PutBits(bw, ((-value) << 1) | 1, nb_bits + 1);
- } else {
- VP8PutBits(bw, value << 1, nb_bits + 1);
- }
-}
-
-//------------------------------------------------------------------------------
-
-int VP8BitWriterInit(VP8BitWriter* const bw, size_t expected_size) {
- bw->range_ = 255 - 1;
- bw->value_ = 0;
- bw->run_ = 0;
- bw->nb_bits_ = -8;
- bw->pos_ = 0;
- bw->max_pos_ = 0;
- bw->error_ = 0;
- bw->buf_ = NULL;
- return (expected_size > 0) ? BitWriterResize(bw, expected_size) : 1;
-}
-
-uint8_t* VP8BitWriterFinish(VP8BitWriter* const bw) {
- VP8PutBits(bw, 0, 9 - bw->nb_bits_);
- bw->nb_bits_ = 0; // pad with zeroes
- Flush(bw);
- return bw->buf_;
-}
-
-int VP8BitWriterAppend(VP8BitWriter* const bw,
- const uint8_t* data, size_t size) {
- assert(data != NULL);
- if (bw->nb_bits_ != -8) return 0; // Flush() must have been called
- if (!BitWriterResize(bw, size)) return 0;
- memcpy(bw->buf_ + bw->pos_, data, size);
- bw->pos_ += size;
- return 1;
-}
-
-void VP8BitWriterWipeOut(VP8BitWriter* const bw) {
- if (bw != NULL) {
- WebPSafeFree(bw->buf_);
- memset(bw, 0, sizeof(*bw));
- }
-}
-
-//------------------------------------------------------------------------------
-// VP8LBitWriter
-
-// This is the minimum amount of size the memory buffer is guaranteed to grow
-// when extra space is needed.
-#define MIN_EXTRA_SIZE (32768ULL)
-
-// Returns 1 on success.
-static int VP8LBitWriterResize(VP8LBitWriter* const bw, size_t extra_size) {
- uint8_t* allocated_buf;
- size_t allocated_size;
- const size_t max_bytes = bw->end_ - bw->buf_;
- const size_t current_size = bw->cur_ - bw->buf_;
- const uint64_t size_required_64b = (uint64_t)current_size + extra_size;
- const size_t size_required = (size_t)size_required_64b;
- if (size_required != size_required_64b) {
- bw->error_ = 1;
- return 0;
- }
- if (max_bytes > 0 && size_required <= max_bytes) return 1;
- allocated_size = (3 * max_bytes) >> 1;
- if (allocated_size < size_required) allocated_size = size_required;
- // make allocated size multiple of 1k
- allocated_size = (((allocated_size >> 10) + 1) << 10);
- allocated_buf = (uint8_t*)WebPSafeMalloc(1ULL, allocated_size);
- if (allocated_buf == NULL) {
- bw->error_ = 1;
- return 0;
- }
- if (current_size > 0) {
- memcpy(allocated_buf, bw->buf_, current_size);
- }
- WebPSafeFree(bw->buf_);
- bw->buf_ = allocated_buf;
- bw->cur_ = bw->buf_ + current_size;
- bw->end_ = bw->buf_ + allocated_size;
- return 1;
-}
-
-int VP8LBitWriterInit(VP8LBitWriter* const bw, size_t expected_size) {
- memset(bw, 0, sizeof(*bw));
- return VP8LBitWriterResize(bw, expected_size);
-}
-
-int VP8LBitWriterClone(const VP8LBitWriter* const src,
- VP8LBitWriter* const dst) {
- const size_t current_size = src->cur_ - src->buf_;
- assert(src->cur_ >= src->buf_ && src->cur_ <= src->end_);
- if (!VP8LBitWriterResize(dst, current_size)) return 0;
- memcpy(dst->buf_, src->buf_, current_size);
- dst->bits_ = src->bits_;
- dst->used_ = src->used_;
- dst->error_ = src->error_;
- dst->cur_ = dst->buf_ + current_size;
- return 1;
-}
-
-void VP8LBitWriterWipeOut(VP8LBitWriter* const bw) {
- if (bw != NULL) {
- WebPSafeFree(bw->buf_);
- memset(bw, 0, sizeof(*bw));
- }
-}
-
-void VP8LBitWriterReset(const VP8LBitWriter* const bw_init,
- VP8LBitWriter* const bw) {
- bw->bits_ = bw_init->bits_;
- bw->used_ = bw_init->used_;
- bw->cur_ = bw->buf_ + (bw_init->cur_ - bw_init->buf_);
- assert(bw->cur_ <= bw->end_);
- bw->error_ = bw_init->error_;
-}
-
-void VP8LBitWriterSwap(VP8LBitWriter* const src, VP8LBitWriter* const dst) {
- const VP8LBitWriter tmp = *src;
- *src = *dst;
- *dst = tmp;
-}
-
-void VP8LPutBitsFlushBits(VP8LBitWriter* const bw) {
- // If needed, make some room by flushing some bits out.
- if (bw->cur_ + VP8L_WRITER_BYTES > bw->end_) {
- const uint64_t extra_size = (bw->end_ - bw->buf_) + MIN_EXTRA_SIZE;
- if (!CheckSizeOverflow(extra_size) ||
- !VP8LBitWriterResize(bw, (size_t)extra_size)) {
- bw->cur_ = bw->buf_;
- bw->error_ = 1;
- return;
- }
- }
- *(vp8l_wtype_t*)bw->cur_ = (vp8l_wtype_t)WSWAP((vp8l_wtype_t)bw->bits_);
- bw->cur_ += VP8L_WRITER_BYTES;
- bw->bits_ >>= VP8L_WRITER_BITS;
- bw->used_ -= VP8L_WRITER_BITS;
-}
-
-void VP8LPutBitsInternal(VP8LBitWriter* const bw, uint32_t bits, int n_bits) {
- assert(n_bits <= 32);
- // That's the max we can handle:
- assert(sizeof(vp8l_wtype_t) == 2);
- if (n_bits > 0) {
- vp8l_atype_t lbits = bw->bits_;
- int used = bw->used_;
- // Special case of overflow handling for 32bit accumulator (2-steps flush).
-#if VP8L_WRITER_BITS == 16
- if (used + n_bits >= VP8L_WRITER_MAX_BITS) {
- // Fill up all the VP8L_WRITER_MAX_BITS so it can be flushed out below.
- const int shift = VP8L_WRITER_MAX_BITS - used;
- lbits |= (vp8l_atype_t)bits << used;
- used = VP8L_WRITER_MAX_BITS;
- n_bits -= shift;
- bits >>= shift;
- assert(n_bits <= VP8L_WRITER_MAX_BITS);
- }
-#endif
- // If needed, make some room by flushing some bits out.
- while (used >= VP8L_WRITER_BITS) {
- if (bw->cur_ + VP8L_WRITER_BYTES > bw->end_) {
- const uint64_t extra_size = (bw->end_ - bw->buf_) + MIN_EXTRA_SIZE;
- if (!CheckSizeOverflow(extra_size) ||
- !VP8LBitWriterResize(bw, (size_t)extra_size)) {
- bw->cur_ = bw->buf_;
- bw->error_ = 1;
- return;
- }
- }
- *(vp8l_wtype_t*)bw->cur_ = (vp8l_wtype_t)WSWAP((vp8l_wtype_t)lbits);
- bw->cur_ += VP8L_WRITER_BYTES;
- lbits >>= VP8L_WRITER_BITS;
- used -= VP8L_WRITER_BITS;
- }
- bw->bits_ = lbits | ((vp8l_atype_t)bits << used);
- bw->used_ = used + n_bits;
- }
-}
-
-uint8_t* VP8LBitWriterFinish(VP8LBitWriter* const bw) {
- // flush leftover bits
- if (VP8LBitWriterResize(bw, (bw->used_ + 7) >> 3)) {
- while (bw->used_ > 0) {
- *bw->cur_++ = (uint8_t)bw->bits_;
- bw->bits_ >>= 8;
- bw->used_ -= 8;
- }
- bw->used_ = 0;
- }
- return bw->buf_;
-}
-
-//------------------------------------------------------------------------------
diff --git a/contrib/libs/libwebp/utils/bit_writer_utils.h b/contrib/libs/libwebp/utils/bit_writer_utils.h
deleted file mode 100644
index b854fae730..0000000000
--- a/contrib/libs/libwebp/utils/bit_writer_utils.h
+++ /dev/null
@@ -1,154 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Bit writing and boolean coder
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#ifndef WEBP_UTILS_BIT_WRITER_UTILS_H_
-#define WEBP_UTILS_BIT_WRITER_UTILS_H_
-
-#include "../webp/types.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-//------------------------------------------------------------------------------
-// Bit-writing
-
-typedef struct VP8BitWriter VP8BitWriter;
-struct VP8BitWriter {
- int32_t range_; // range-1
- int32_t value_;
- int run_; // number of outstanding bits
- int nb_bits_; // number of pending bits
- uint8_t* buf_; // internal buffer. Re-allocated regularly. Not owned.
- size_t pos_;
- size_t max_pos_;
- int error_; // true in case of error
-};
-
-// Initialize the object. Allocates some initial memory based on expected_size.
-int VP8BitWriterInit(VP8BitWriter* const bw, size_t expected_size);
-// Finalize the bitstream coding. Returns a pointer to the internal buffer.
-uint8_t* VP8BitWriterFinish(VP8BitWriter* const bw);
-// Release any pending memory and zeroes the object. Not a mandatory call.
-// Only useful in case of error, when the internal buffer hasn't been grabbed!
-void VP8BitWriterWipeOut(VP8BitWriter* const bw);
-
-int VP8PutBit(VP8BitWriter* const bw, int bit, int prob);
-int VP8PutBitUniform(VP8BitWriter* const bw, int bit);
-void VP8PutBits(VP8BitWriter* const bw, uint32_t value, int nb_bits);
-void VP8PutSignedBits(VP8BitWriter* const bw, int value, int nb_bits);
-
-// Appends some bytes to the internal buffer. Data is copied.
-int VP8BitWriterAppend(VP8BitWriter* const bw,
- const uint8_t* data, size_t size);
-
-// return approximate write position (in bits)
-static WEBP_INLINE uint64_t VP8BitWriterPos(const VP8BitWriter* const bw) {
- const uint64_t nb_bits = 8 + bw->nb_bits_; // bw->nb_bits_ is <= 0, note
- return (bw->pos_ + bw->run_) * 8 + nb_bits;
-}
-
-// Returns a pointer to the internal buffer.
-static WEBP_INLINE uint8_t* VP8BitWriterBuf(const VP8BitWriter* const bw) {
- return bw->buf_;
-}
-// Returns the size of the internal buffer.
-static WEBP_INLINE size_t VP8BitWriterSize(const VP8BitWriter* const bw) {
- return bw->pos_;
-}
-
-//------------------------------------------------------------------------------
-// VP8LBitWriter
-
-#if defined(__x86_64__) || defined(_M_X64) // 64bit
-typedef uint64_t vp8l_atype_t; // accumulator type
-typedef uint32_t vp8l_wtype_t; // writing type
-#define WSWAP HToLE32
-#define VP8L_WRITER_BYTES 4 // sizeof(vp8l_wtype_t)
-#define VP8L_WRITER_BITS 32 // 8 * sizeof(vp8l_wtype_t)
-#define VP8L_WRITER_MAX_BITS 64 // 8 * sizeof(vp8l_atype_t)
-#else
-typedef uint32_t vp8l_atype_t;
-typedef uint16_t vp8l_wtype_t;
-#define WSWAP HToLE16
-#define VP8L_WRITER_BYTES 2
-#define VP8L_WRITER_BITS 16
-#define VP8L_WRITER_MAX_BITS 32
-#endif
-
-typedef struct {
- vp8l_atype_t bits_; // bit accumulator
- int used_; // number of bits used in accumulator
- uint8_t* buf_; // start of buffer
- uint8_t* cur_; // current write position
- uint8_t* end_; // end of buffer
-
- // After all bits are written (VP8LBitWriterFinish()), the caller must observe
- // the state of error_. A value of 1 indicates that a memory allocation
- // failure has happened during bit writing. A value of 0 indicates successful
- // writing of bits.
- int error_;
-} VP8LBitWriter;
-
-static WEBP_INLINE size_t VP8LBitWriterNumBytes(const VP8LBitWriter* const bw) {
- return (bw->cur_ - bw->buf_) + ((bw->used_ + 7) >> 3);
-}
-
-// Returns false in case of memory allocation error.
-int VP8LBitWriterInit(VP8LBitWriter* const bw, size_t expected_size);
-// Returns false in case of memory allocation error.
-int VP8LBitWriterClone(const VP8LBitWriter* const src,
- VP8LBitWriter* const dst);
-// Finalize the bitstream coding. Returns a pointer to the internal buffer.
-uint8_t* VP8LBitWriterFinish(VP8LBitWriter* const bw);
-// Release any pending memory and zeroes the object.
-void VP8LBitWriterWipeOut(VP8LBitWriter* const bw);
-// Resets the cursor of the BitWriter bw to when it was like in bw_init.
-void VP8LBitWriterReset(const VP8LBitWriter* const bw_init,
- VP8LBitWriter* const bw);
-// Swaps the memory held by two BitWriters.
-void VP8LBitWriterSwap(VP8LBitWriter* const src, VP8LBitWriter* const dst);
-
-// Internal function for VP8LPutBits flushing 32 bits from the written state.
-void VP8LPutBitsFlushBits(VP8LBitWriter* const bw);
-
-// PutBits internal function used in the 16 bit vp8l_wtype_t case.
-void VP8LPutBitsInternal(VP8LBitWriter* const bw, uint32_t bits, int n_bits);
-
-// This function writes bits into bytes in increasing addresses (little endian),
-// and within a byte least-significant-bit first.
-// This function can write up to 32 bits in one go, but VP8LBitReader can only
-// read 24 bits max (VP8L_MAX_NUM_BIT_READ).
-// VP8LBitWriter's error_ flag is set in case of memory allocation error.
-static WEBP_INLINE void VP8LPutBits(VP8LBitWriter* const bw,
- uint32_t bits, int n_bits) {
- if (sizeof(vp8l_wtype_t) == 4) {
- if (n_bits > 0) {
- if (bw->used_ >= 32) {
- VP8LPutBitsFlushBits(bw);
- }
- bw->bits_ |= (vp8l_atype_t)bits << bw->used_;
- bw->used_ += n_bits;
- }
- } else {
- VP8LPutBitsInternal(bw, bits, n_bits);
- }
-}
-
-//------------------------------------------------------------------------------
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // WEBP_UTILS_BIT_WRITER_UTILS_H_
diff --git a/contrib/libs/libwebp/utils/color_cache_utils.c b/contrib/libs/libwebp/utils/color_cache_utils.c
deleted file mode 100644
index 498adea8e9..0000000000
--- a/contrib/libs/libwebp/utils/color_cache_utils.c
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright 2012 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Color Cache for WebP Lossless
-//
-// Author: Jyrki Alakuijala (jyrki@google.com)
-
-#include <assert.h>
-#include <stdlib.h>
-#include <string.h>
-#include "./color_cache_utils.h"
-#include "./utils.h"
-
-//------------------------------------------------------------------------------
-// VP8LColorCache.
-
-int VP8LColorCacheInit(VP8LColorCache* const color_cache, int hash_bits) {
- const int hash_size = 1 << hash_bits;
- assert(color_cache != NULL);
- assert(hash_bits > 0);
- color_cache->colors_ = (uint32_t*)WebPSafeCalloc(
- (uint64_t)hash_size, sizeof(*color_cache->colors_));
- if (color_cache->colors_ == NULL) return 0;
- color_cache->hash_shift_ = 32 - hash_bits;
- color_cache->hash_bits_ = hash_bits;
- return 1;
-}
-
-void VP8LColorCacheClear(VP8LColorCache* const color_cache) {
- if (color_cache != NULL) {
- WebPSafeFree(color_cache->colors_);
- color_cache->colors_ = NULL;
- }
-}
-
-void VP8LColorCacheCopy(const VP8LColorCache* const src,
- VP8LColorCache* const dst) {
- assert(src != NULL);
- assert(dst != NULL);
- assert(src->hash_bits_ == dst->hash_bits_);
- memcpy(dst->colors_, src->colors_,
- ((size_t)1u << dst->hash_bits_) * sizeof(*dst->colors_));
-}
diff --git a/contrib/libs/libwebp/utils/color_cache_utils.h b/contrib/libs/libwebp/utils/color_cache_utils.h
deleted file mode 100644
index 34e9e68795..0000000000
--- a/contrib/libs/libwebp/utils/color_cache_utils.h
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright 2012 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Color Cache for WebP Lossless
-//
-// Authors: Jyrki Alakuijala (jyrki@google.com)
-// Urvang Joshi (urvang@google.com)
-
-#ifndef WEBP_UTILS_COLOR_CACHE_UTILS_H_
-#define WEBP_UTILS_COLOR_CACHE_UTILS_H_
-
-#include <assert.h>
-
-#include "../dsp/dsp.h"
-#include "../webp/types.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// Main color cache struct.
-typedef struct {
- uint32_t* colors_; // color entries
- int hash_shift_; // Hash shift: 32 - hash_bits_.
- int hash_bits_;
-} VP8LColorCache;
-
-static const uint32_t kHashMul = 0x1e35a7bdu;
-
-static WEBP_UBSAN_IGNORE_UNSIGNED_OVERFLOW WEBP_INLINE
-int VP8LHashPix(uint32_t argb, int shift) {
- return (int)((argb * kHashMul) >> shift);
-}
-
-static WEBP_INLINE uint32_t VP8LColorCacheLookup(
- const VP8LColorCache* const cc, uint32_t key) {
- assert((key >> cc->hash_bits_) == 0u);
- return cc->colors_[key];
-}
-
-static WEBP_INLINE void VP8LColorCacheSet(const VP8LColorCache* const cc,
- uint32_t key, uint32_t argb) {
- assert((key >> cc->hash_bits_) == 0u);
- cc->colors_[key] = argb;
-}
-
-static WEBP_INLINE void VP8LColorCacheInsert(const VP8LColorCache* const cc,
- uint32_t argb) {
- const int key = VP8LHashPix(argb, cc->hash_shift_);
- cc->colors_[key] = argb;
-}
-
-static WEBP_INLINE int VP8LColorCacheGetIndex(const VP8LColorCache* const cc,
- uint32_t argb) {
- return VP8LHashPix(argb, cc->hash_shift_);
-}
-
-// Return the key if cc contains argb, and -1 otherwise.
-static WEBP_INLINE int VP8LColorCacheContains(const VP8LColorCache* const cc,
- uint32_t argb) {
- const int key = VP8LHashPix(argb, cc->hash_shift_);
- return (cc->colors_[key] == argb) ? key : -1;
-}
-
-//------------------------------------------------------------------------------
-
-// Initializes the color cache with 'hash_bits' bits for the keys.
-// Returns false in case of memory error.
-int VP8LColorCacheInit(VP8LColorCache* const color_cache, int hash_bits);
-
-void VP8LColorCacheCopy(const VP8LColorCache* const src,
- VP8LColorCache* const dst);
-
-// Delete the memory associated to color cache.
-void VP8LColorCacheClear(VP8LColorCache* const color_cache);
-
-//------------------------------------------------------------------------------
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // WEBP_UTILS_COLOR_CACHE_UTILS_H_
diff --git a/contrib/libs/libwebp/utils/endian_inl_utils.h b/contrib/libs/libwebp/utils/endian_inl_utils.h
deleted file mode 100644
index 1c01450b95..0000000000
--- a/contrib/libs/libwebp/utils/endian_inl_utils.h
+++ /dev/null
@@ -1,93 +0,0 @@
-// Copyright 2014 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Endian related functions.
-
-#ifndef WEBP_UTILS_ENDIAN_INL_UTILS_H_
-#define WEBP_UTILS_ENDIAN_INL_UTILS_H_
-
-#ifdef HAVE_CONFIG_H
-#include "../webp/config.h"
-#endif
-
-#include "../dsp/dsp.h"
-#include "../webp/types.h"
-
-#if defined(WORDS_BIGENDIAN)
-#define HToLE32 BSwap32
-#define HToLE16 BSwap16
-#else
-#define HToLE32(x) (x)
-#define HToLE16(x) (x)
-#endif
-
-#if !defined(HAVE_CONFIG_H)
-#if LOCAL_GCC_PREREQ(4,8) || __has_builtin(__builtin_bswap16)
-#define HAVE_BUILTIN_BSWAP16
-#endif
-#if LOCAL_GCC_PREREQ(4,3) || __has_builtin(__builtin_bswap32)
-#define HAVE_BUILTIN_BSWAP32
-#endif
-#if LOCAL_GCC_PREREQ(4,3) || __has_builtin(__builtin_bswap64)
-#define HAVE_BUILTIN_BSWAP64
-#endif
-#endif // !HAVE_CONFIG_H
-
-static WEBP_INLINE uint16_t BSwap16(uint16_t x) {
-#if defined(HAVE_BUILTIN_BSWAP16)
- return __builtin_bswap16(x);
-#elif defined(_MSC_VER)
- return _byteswap_ushort(x);
-#else
- // gcc will recognize a 'rorw $8, ...' here:
- return (x >> 8) | ((x & 0xff) << 8);
-#endif // HAVE_BUILTIN_BSWAP16
-}
-
-static WEBP_INLINE uint32_t BSwap32(uint32_t x) {
-#if defined(WEBP_USE_MIPS32_R2)
- uint32_t ret;
- __asm__ volatile (
- "wsbh %[ret], %[x] \n\t"
- "rotr %[ret], %[ret], 16 \n\t"
- : [ret]"=r"(ret)
- : [x]"r"(x)
- );
- return ret;
-#elif defined(HAVE_BUILTIN_BSWAP32)
- return __builtin_bswap32(x);
-#elif defined(__i386__) || defined(__x86_64__)
- uint32_t swapped_bytes;
- __asm__ volatile("bswap %0" : "=r"(swapped_bytes) : "0"(x));
- return swapped_bytes;
-#elif defined(_MSC_VER)
- return (uint32_t)_byteswap_ulong(x);
-#else
- return (x >> 24) | ((x >> 8) & 0xff00) | ((x << 8) & 0xff0000) | (x << 24);
-#endif // HAVE_BUILTIN_BSWAP32
-}
-
-static WEBP_INLINE uint64_t BSwap64(uint64_t x) {
-#if defined(HAVE_BUILTIN_BSWAP64)
- return __builtin_bswap64(x);
-#elif defined(__x86_64__)
- uint64_t swapped_bytes;
- __asm__ volatile("bswapq %0" : "=r"(swapped_bytes) : "0"(x));
- return swapped_bytes;
-#elif defined(_MSC_VER)
- return (uint64_t)_byteswap_uint64(x);
-#else // generic code for swapping 64-bit values (suggested by bdb@)
- x = ((x & 0xffffffff00000000ull) >> 32) | ((x & 0x00000000ffffffffull) << 32);
- x = ((x & 0xffff0000ffff0000ull) >> 16) | ((x & 0x0000ffff0000ffffull) << 16);
- x = ((x & 0xff00ff00ff00ff00ull) >> 8) | ((x & 0x00ff00ff00ff00ffull) << 8);
- return x;
-#endif // HAVE_BUILTIN_BSWAP64
-}
-
-#endif // WEBP_UTILS_ENDIAN_INL_UTILS_H_
diff --git a/contrib/libs/libwebp/utils/filters_utils.c b/contrib/libs/libwebp/utils/filters_utils.c
deleted file mode 100644
index 49c1d18a22..0000000000
--- a/contrib/libs/libwebp/utils/filters_utils.c
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// filter estimation
-//
-// Author: Urvang (urvang@google.com)
-
-#include "./filters_utils.h"
-#include <stdlib.h>
-#include <string.h>
-
-// -----------------------------------------------------------------------------
-// Quick estimate of a potentially interesting filter mode to try.
-
-#define SMAX 16
-#define SDIFF(a, b) (abs((a) - (b)) >> 4) // Scoring diff, in [0..SMAX)
-
-static WEBP_INLINE int GradientPredictor(uint8_t a, uint8_t b, uint8_t c) {
- const int g = a + b - c;
- return ((g & ~0xff) == 0) ? g : (g < 0) ? 0 : 255; // clip to 8bit
-}
-
-WEBP_FILTER_TYPE WebPEstimateBestFilter(const uint8_t* data,
- int width, int height, int stride) {
- int i, j;
- int bins[WEBP_FILTER_LAST][SMAX];
- memset(bins, 0, sizeof(bins));
-
- // We only sample every other pixels. That's enough.
- for (j = 2; j < height - 1; j += 2) {
- const uint8_t* const p = data + j * stride;
- int mean = p[0];
- for (i = 2; i < width - 1; i += 2) {
- const int diff0 = SDIFF(p[i], mean);
- const int diff1 = SDIFF(p[i], p[i - 1]);
- const int diff2 = SDIFF(p[i], p[i - width]);
- const int grad_pred =
- GradientPredictor(p[i - 1], p[i - width], p[i - width - 1]);
- const int diff3 = SDIFF(p[i], grad_pred);
- bins[WEBP_FILTER_NONE][diff0] = 1;
- bins[WEBP_FILTER_HORIZONTAL][diff1] = 1;
- bins[WEBP_FILTER_VERTICAL][diff2] = 1;
- bins[WEBP_FILTER_GRADIENT][diff3] = 1;
- mean = (3 * mean + p[i] + 2) >> 2;
- }
- }
- {
- int filter;
- WEBP_FILTER_TYPE best_filter = WEBP_FILTER_NONE;
- int best_score = 0x7fffffff;
- for (filter = WEBP_FILTER_NONE; filter < WEBP_FILTER_LAST; ++filter) {
- int score = 0;
- for (i = 0; i < SMAX; ++i) {
- if (bins[filter][i] > 0) {
- score += i;
- }
- }
- if (score < best_score) {
- best_score = score;
- best_filter = (WEBP_FILTER_TYPE)filter;
- }
- }
- return best_filter;
- }
-}
-
-#undef SMAX
-#undef SDIFF
-
-//------------------------------------------------------------------------------
diff --git a/contrib/libs/libwebp/utils/filters_utils.h b/contrib/libs/libwebp/utils/filters_utils.h
deleted file mode 100644
index 891771ddc0..0000000000
--- a/contrib/libs/libwebp/utils/filters_utils.h
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Spatial prediction using various filters
-//
-// Author: Urvang (urvang@google.com)
-
-#ifndef WEBP_UTILS_FILTERS_UTILS_H_
-#define WEBP_UTILS_FILTERS_UTILS_H_
-
-#include "../webp/types.h"
-#include "../dsp/dsp.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// Fast estimate of a potentially good filter.
-WEBP_FILTER_TYPE WebPEstimateBestFilter(const uint8_t* data,
- int width, int height, int stride);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // WEBP_UTILS_FILTERS_UTILS_H_
diff --git a/contrib/libs/libwebp/utils/huffman_encode_utils.c b/contrib/libs/libwebp/utils/huffman_encode_utils.c
deleted file mode 100644
index 18919b389d..0000000000
--- a/contrib/libs/libwebp/utils/huffman_encode_utils.c
+++ /dev/null
@@ -1,416 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Author: Jyrki Alakuijala (jyrki@google.com)
-//
-// Entropy encoding (Huffman) for webp lossless.
-
-#include <assert.h>
-#include <stdlib.h>
-#include <string.h>
-#include "./huffman_encode_utils.h"
-#include "./utils.h"
-#include "../webp/format_constants.h"
-
-// -----------------------------------------------------------------------------
-// Util function to optimize the symbol map for RLE coding
-
-// Heuristics for selecting the stride ranges to collapse.
-static int ValuesShouldBeCollapsedToStrideAverage(int a, int b) {
- return abs(a - b) < 4;
-}
-
-// Change the population counts in a way that the consequent
-// Huffman tree compression, especially its RLE-part, give smaller output.
-static void OptimizeHuffmanForRle(int length, uint8_t* const good_for_rle,
- uint32_t* const counts) {
- // 1) Let's make the Huffman code more compatible with rle encoding.
- int i;
- for (; length >= 0; --length) {
- if (length == 0) {
- return; // All zeros.
- }
- if (counts[length - 1] != 0) {
- // Now counts[0..length - 1] does not have trailing zeros.
- break;
- }
- }
- // 2) Let's mark all population counts that already can be encoded
- // with an rle code.
- {
- // Let's not spoil any of the existing good rle codes.
- // Mark any seq of 0's that is longer as 5 as a good_for_rle.
- // Mark any seq of non-0's that is longer as 7 as a good_for_rle.
- uint32_t symbol = counts[0];
- int stride = 0;
- for (i = 0; i < length + 1; ++i) {
- if (i == length || counts[i] != symbol) {
- if ((symbol == 0 && stride >= 5) ||
- (symbol != 0 && stride >= 7)) {
- int k;
- for (k = 0; k < stride; ++k) {
- good_for_rle[i - k - 1] = 1;
- }
- }
- stride = 1;
- if (i != length) {
- symbol = counts[i];
- }
- } else {
- ++stride;
- }
- }
- }
- // 3) Let's replace those population counts that lead to more rle codes.
- {
- uint32_t stride = 0;
- uint32_t limit = counts[0];
- uint32_t sum = 0;
- for (i = 0; i < length + 1; ++i) {
- if (i == length || good_for_rle[i] ||
- (i != 0 && good_for_rle[i - 1]) ||
- !ValuesShouldBeCollapsedToStrideAverage(counts[i], limit)) {
- if (stride >= 4 || (stride >= 3 && sum == 0)) {
- uint32_t k;
- // The stride must end, collapse what we have, if we have enough (4).
- uint32_t count = (sum + stride / 2) / stride;
- if (count < 1) {
- count = 1;
- }
- if (sum == 0) {
- // Don't make an all zeros stride to be upgraded to ones.
- count = 0;
- }
- for (k = 0; k < stride; ++k) {
- // We don't want to change value at counts[i],
- // that is already belonging to the next stride. Thus - 1.
- counts[i - k - 1] = count;
- }
- }
- stride = 0;
- sum = 0;
- if (i < length - 3) {
- // All interesting strides have a count of at least 4,
- // at least when non-zeros.
- limit = (counts[i] + counts[i + 1] +
- counts[i + 2] + counts[i + 3] + 2) / 4;
- } else if (i < length) {
- limit = counts[i];
- } else {
- limit = 0;
- }
- }
- ++stride;
- if (i != length) {
- sum += counts[i];
- if (stride >= 4) {
- limit = (sum + stride / 2) / stride;
- }
- }
- }
- }
-}
-
-// A comparer function for two Huffman trees: sorts first by 'total count'
-// (more comes first), and then by 'value' (more comes first).
-static int CompareHuffmanTrees(const void* ptr1, const void* ptr2) {
- const HuffmanTree* const t1 = (const HuffmanTree*)ptr1;
- const HuffmanTree* const t2 = (const HuffmanTree*)ptr2;
- if (t1->total_count_ > t2->total_count_) {
- return -1;
- } else if (t1->total_count_ < t2->total_count_) {
- return 1;
- } else {
- assert(t1->value_ != t2->value_);
- return (t1->value_ < t2->value_) ? -1 : 1;
- }
-}
-
-static void SetBitDepths(const HuffmanTree* const tree,
- const HuffmanTree* const pool,
- uint8_t* const bit_depths, int level) {
- if (tree->pool_index_left_ >= 0) {
- SetBitDepths(&pool[tree->pool_index_left_], pool, bit_depths, level + 1);
- SetBitDepths(&pool[tree->pool_index_right_], pool, bit_depths, level + 1);
- } else {
- bit_depths[tree->value_] = level;
- }
-}
-
-// Create an optimal Huffman tree.
-//
-// (data,length): population counts.
-// tree_limit: maximum bit depth (inclusive) of the codes.
-// bit_depths[]: how many bits are used for the symbol.
-//
-// Returns 0 when an error has occurred.
-//
-// The catch here is that the tree cannot be arbitrarily deep
-//
-// count_limit is the value that is to be faked as the minimum value
-// and this minimum value is raised until the tree matches the
-// maximum length requirement.
-//
-// This algorithm is not of excellent performance for very long data blocks,
-// especially when population counts are longer than 2**tree_limit, but
-// we are not planning to use this with extremely long blocks.
-//
-// See https://en.wikipedia.org/wiki/Huffman_coding
-static void GenerateOptimalTree(const uint32_t* const histogram,
- int histogram_size,
- HuffmanTree* tree, int tree_depth_limit,
- uint8_t* const bit_depths) {
- uint32_t count_min;
- HuffmanTree* tree_pool;
- int tree_size_orig = 0;
- int i;
-
- for (i = 0; i < histogram_size; ++i) {
- if (histogram[i] != 0) {
- ++tree_size_orig;
- }
- }
-
- if (tree_size_orig == 0) { // pretty optimal already!
- return;
- }
-
- tree_pool = tree + tree_size_orig;
-
- // For block sizes with less than 64k symbols we never need to do a
- // second iteration of this loop.
- // If we actually start running inside this loop a lot, we would perhaps
- // be better off with the Katajainen algorithm.
- assert(tree_size_orig <= (1 << (tree_depth_limit - 1)));
- for (count_min = 1; ; count_min *= 2) {
- int tree_size = tree_size_orig;
- // We need to pack the Huffman tree in tree_depth_limit bits.
- // So, we try by faking histogram entries to be at least 'count_min'.
- int idx = 0;
- int j;
- for (j = 0; j < histogram_size; ++j) {
- if (histogram[j] != 0) {
- const uint32_t count =
- (histogram[j] < count_min) ? count_min : histogram[j];
- tree[idx].total_count_ = count;
- tree[idx].value_ = j;
- tree[idx].pool_index_left_ = -1;
- tree[idx].pool_index_right_ = -1;
- ++idx;
- }
- }
-
- // Build the Huffman tree.
- qsort(tree, tree_size, sizeof(*tree), CompareHuffmanTrees);
-
- if (tree_size > 1) { // Normal case.
- int tree_pool_size = 0;
- while (tree_size > 1) { // Finish when we have only one root.
- uint32_t count;
- tree_pool[tree_pool_size++] = tree[tree_size - 1];
- tree_pool[tree_pool_size++] = tree[tree_size - 2];
- count = tree_pool[tree_pool_size - 1].total_count_ +
- tree_pool[tree_pool_size - 2].total_count_;
- tree_size -= 2;
- {
- // Search for the insertion point.
- int k;
- for (k = 0; k < tree_size; ++k) {
- if (tree[k].total_count_ <= count) {
- break;
- }
- }
- memmove(tree + (k + 1), tree + k, (tree_size - k) * sizeof(*tree));
- tree[k].total_count_ = count;
- tree[k].value_ = -1;
-
- tree[k].pool_index_left_ = tree_pool_size - 1;
- tree[k].pool_index_right_ = tree_pool_size - 2;
- tree_size = tree_size + 1;
- }
- }
- SetBitDepths(&tree[0], tree_pool, bit_depths, 0);
- } else if (tree_size == 1) { // Trivial case: only one element.
- bit_depths[tree[0].value_] = 1;
- }
-
- {
- // Test if this Huffman tree satisfies our 'tree_depth_limit' criteria.
- int max_depth = bit_depths[0];
- for (j = 1; j < histogram_size; ++j) {
- if (max_depth < bit_depths[j]) {
- max_depth = bit_depths[j];
- }
- }
- if (max_depth <= tree_depth_limit) {
- break;
- }
- }
- }
-}
-
-// -----------------------------------------------------------------------------
-// Coding of the Huffman tree values
-
-static HuffmanTreeToken* CodeRepeatedValues(int repetitions,
- HuffmanTreeToken* tokens,
- int value, int prev_value) {
- assert(value <= MAX_ALLOWED_CODE_LENGTH);
- if (value != prev_value) {
- tokens->code = value;
- tokens->extra_bits = 0;
- ++tokens;
- --repetitions;
- }
- while (repetitions >= 1) {
- if (repetitions < 3) {
- int i;
- for (i = 0; i < repetitions; ++i) {
- tokens->code = value;
- tokens->extra_bits = 0;
- ++tokens;
- }
- break;
- } else if (repetitions < 7) {
- tokens->code = 16;
- tokens->extra_bits = repetitions - 3;
- ++tokens;
- break;
- } else {
- tokens->code = 16;
- tokens->extra_bits = 3;
- ++tokens;
- repetitions -= 6;
- }
- }
- return tokens;
-}
-
-static HuffmanTreeToken* CodeRepeatedZeros(int repetitions,
- HuffmanTreeToken* tokens) {
- while (repetitions >= 1) {
- if (repetitions < 3) {
- int i;
- for (i = 0; i < repetitions; ++i) {
- tokens->code = 0; // 0-value
- tokens->extra_bits = 0;
- ++tokens;
- }
- break;
- } else if (repetitions < 11) {
- tokens->code = 17;
- tokens->extra_bits = repetitions - 3;
- ++tokens;
- break;
- } else if (repetitions < 139) {
- tokens->code = 18;
- tokens->extra_bits = repetitions - 11;
- ++tokens;
- break;
- } else {
- tokens->code = 18;
- tokens->extra_bits = 0x7f; // 138 repeated 0s
- ++tokens;
- repetitions -= 138;
- }
- }
- return tokens;
-}
-
-int VP8LCreateCompressedHuffmanTree(const HuffmanTreeCode* const tree,
- HuffmanTreeToken* tokens, int max_tokens) {
- HuffmanTreeToken* const starting_token = tokens;
- HuffmanTreeToken* const ending_token = tokens + max_tokens;
- const int depth_size = tree->num_symbols;
- int prev_value = 8; // 8 is the initial value for rle.
- int i = 0;
- assert(tokens != NULL);
- while (i < depth_size) {
- const int value = tree->code_lengths[i];
- int k = i + 1;
- int runs;
- while (k < depth_size && tree->code_lengths[k] == value) ++k;
- runs = k - i;
- if (value == 0) {
- tokens = CodeRepeatedZeros(runs, tokens);
- } else {
- tokens = CodeRepeatedValues(runs, tokens, value, prev_value);
- prev_value = value;
- }
- i += runs;
- assert(tokens <= ending_token);
- }
- (void)ending_token; // suppress 'unused variable' warning
- return (int)(tokens - starting_token);
-}
-
-// -----------------------------------------------------------------------------
-
-// Pre-reversed 4-bit values.
-static const uint8_t kReversedBits[16] = {
- 0x0, 0x8, 0x4, 0xc, 0x2, 0xa, 0x6, 0xe,
- 0x1, 0x9, 0x5, 0xd, 0x3, 0xb, 0x7, 0xf
-};
-
-static uint32_t ReverseBits(int num_bits, uint32_t bits) {
- uint32_t retval = 0;
- int i = 0;
- while (i < num_bits) {
- i += 4;
- retval |= kReversedBits[bits & 0xf] << (MAX_ALLOWED_CODE_LENGTH + 1 - i);
- bits >>= 4;
- }
- retval >>= (MAX_ALLOWED_CODE_LENGTH + 1 - num_bits);
- return retval;
-}
-
-// Get the actual bit values for a tree of bit depths.
-static void ConvertBitDepthsToSymbols(HuffmanTreeCode* const tree) {
- // 0 bit-depth means that the symbol does not exist.
- int i;
- int len;
- uint32_t next_code[MAX_ALLOWED_CODE_LENGTH + 1];
- int depth_count[MAX_ALLOWED_CODE_LENGTH + 1] = { 0 };
-
- assert(tree != NULL);
- len = tree->num_symbols;
- for (i = 0; i < len; ++i) {
- const int code_length = tree->code_lengths[i];
- assert(code_length <= MAX_ALLOWED_CODE_LENGTH);
- ++depth_count[code_length];
- }
- depth_count[0] = 0; // ignore unused symbol
- next_code[0] = 0;
- {
- uint32_t code = 0;
- for (i = 1; i <= MAX_ALLOWED_CODE_LENGTH; ++i) {
- code = (code + depth_count[i - 1]) << 1;
- next_code[i] = code;
- }
- }
- for (i = 0; i < len; ++i) {
- const int code_length = tree->code_lengths[i];
- tree->codes[i] = ReverseBits(code_length, next_code[code_length]++);
- }
-}
-
-// -----------------------------------------------------------------------------
-// Main entry point
-
-void VP8LCreateHuffmanTree(uint32_t* const histogram, int tree_depth_limit,
- uint8_t* const buf_rle, HuffmanTree* const huff_tree,
- HuffmanTreeCode* const huff_code) {
- const int num_symbols = huff_code->num_symbols;
- memset(buf_rle, 0, num_symbols * sizeof(*buf_rle));
- OptimizeHuffmanForRle(num_symbols, buf_rle, histogram);
- GenerateOptimalTree(histogram, num_symbols, huff_tree, tree_depth_limit,
- huff_code->code_lengths);
- // Create the actual bit codes for the bit lengths.
- ConvertBitDepthsToSymbols(huff_code);
-}
diff --git a/contrib/libs/libwebp/utils/huffman_encode_utils.h b/contrib/libs/libwebp/utils/huffman_encode_utils.h
deleted file mode 100644
index 892d514751..0000000000
--- a/contrib/libs/libwebp/utils/huffman_encode_utils.h
+++ /dev/null
@@ -1,60 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Author: Jyrki Alakuijala (jyrki@google.com)
-//
-// Entropy encoding (Huffman) for webp lossless
-
-#ifndef WEBP_UTILS_HUFFMAN_ENCODE_UTILS_H_
-#define WEBP_UTILS_HUFFMAN_ENCODE_UTILS_H_
-
-#include "../webp/types.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// Struct for holding the tree header in coded form.
-typedef struct {
- uint8_t code; // value (0..15) or escape code (16,17,18)
- uint8_t extra_bits; // extra bits for escape codes
-} HuffmanTreeToken;
-
-// Struct to represent the tree codes (depth and bits array).
-typedef struct {
- int num_symbols; // Number of symbols.
- uint8_t* code_lengths; // Code lengths of the symbols.
- uint16_t* codes; // Symbol Codes.
-} HuffmanTreeCode;
-
-// Struct to represent the Huffman tree.
-typedef struct {
- uint32_t total_count_; // Symbol frequency.
- int value_; // Symbol value.
- int pool_index_left_; // Index for the left sub-tree.
- int pool_index_right_; // Index for the right sub-tree.
-} HuffmanTree;
-
-// Turn the Huffman tree into a token sequence.
-// Returns the number of tokens used.
-int VP8LCreateCompressedHuffmanTree(const HuffmanTreeCode* const tree,
- HuffmanTreeToken* tokens, int max_tokens);
-
-// Create an optimized tree, and tokenize it.
-// 'buf_rle' and 'huff_tree' are pre-allocated and the 'tree' is the constructed
-// huffman code tree.
-void VP8LCreateHuffmanTree(uint32_t* const histogram, int tree_depth_limit,
- uint8_t* const buf_rle, HuffmanTree* const huff_tree,
- HuffmanTreeCode* const huff_code);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // WEBP_UTILS_HUFFMAN_ENCODE_UTILS_H_
diff --git a/contrib/libs/libwebp/utils/huffman_utils.c b/contrib/libs/libwebp/utils/huffman_utils.c
deleted file mode 100644
index 98c3aa51aa..0000000000
--- a/contrib/libs/libwebp/utils/huffman_utils.c
+++ /dev/null
@@ -1,235 +0,0 @@
-// Copyright 2012 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Utilities for building and looking up Huffman trees.
-//
-// Author: Urvang Joshi (urvang@google.com)
-
-#include <assert.h>
-#include <stdlib.h>
-#include <string.h>
-#include "./huffman_utils.h"
-#include "./utils.h"
-#include "../webp/format_constants.h"
-
-// Huffman data read via DecodeImageStream is represented in two (red and green)
-// bytes.
-#define MAX_HTREE_GROUPS 0x10000
-
-HTreeGroup* VP8LHtreeGroupsNew(int num_htree_groups) {
- HTreeGroup* const htree_groups =
- (HTreeGroup*)WebPSafeMalloc(num_htree_groups, sizeof(*htree_groups));
- if (htree_groups == NULL) {
- return NULL;
- }
- assert(num_htree_groups <= MAX_HTREE_GROUPS);
- return htree_groups;
-}
-
-void VP8LHtreeGroupsFree(HTreeGroup* const htree_groups) {
- if (htree_groups != NULL) {
- WebPSafeFree(htree_groups);
- }
-}
-
-// Returns reverse(reverse(key, len) + 1, len), where reverse(key, len) is the
-// bit-wise reversal of the len least significant bits of key.
-static WEBP_INLINE uint32_t GetNextKey(uint32_t key, int len) {
- uint32_t step = 1 << (len - 1);
- while (key & step) {
- step >>= 1;
- }
- return step ? (key & (step - 1)) + step : key;
-}
-
-// Stores code in table[0], table[step], table[2*step], ..., table[end].
-// Assumes that end is an integer multiple of step.
-static WEBP_INLINE void ReplicateValue(HuffmanCode* table,
- int step, int end,
- HuffmanCode code) {
- assert(end % step == 0);
- do {
- end -= step;
- table[end] = code;
- } while (end > 0);
-}
-
-// Returns the table width of the next 2nd level table. count is the histogram
-// of bit lengths for the remaining symbols, len is the code length of the next
-// processed symbol
-static WEBP_INLINE int NextTableBitSize(const int* const count,
- int len, int root_bits) {
- int left = 1 << (len - root_bits);
- while (len < MAX_ALLOWED_CODE_LENGTH) {
- left -= count[len];
- if (left <= 0) break;
- ++len;
- left <<= 1;
- }
- return len - root_bits;
-}
-
-// sorted[code_lengths_size] is a pre-allocated array for sorting symbols
-// by code length.
-static int BuildHuffmanTable(HuffmanCode* const root_table, int root_bits,
- const int code_lengths[], int code_lengths_size,
- uint16_t sorted[]) {
- HuffmanCode* table = root_table; // next available space in table
- int total_size = 1 << root_bits; // total size root table + 2nd level table
- int len; // current code length
- int symbol; // symbol index in original or sorted table
- // number of codes of each length:
- int count[MAX_ALLOWED_CODE_LENGTH + 1] = { 0 };
- // offsets in sorted table for each length:
- int offset[MAX_ALLOWED_CODE_LENGTH + 1];
-
- assert(code_lengths_size != 0);
- assert(code_lengths != NULL);
- assert((root_table != NULL && sorted != NULL) ||
- (root_table == NULL && sorted == NULL));
- assert(root_bits > 0);
-
- // Build histogram of code lengths.
- for (symbol = 0; symbol < code_lengths_size; ++symbol) {
- if (code_lengths[symbol] > MAX_ALLOWED_CODE_LENGTH) {
- return 0;
- }
- ++count[code_lengths[symbol]];
- }
-
- // Error, all code lengths are zeros.
- if (count[0] == code_lengths_size) {
- return 0;
- }
-
- // Generate offsets into sorted symbol table by code length.
- offset[1] = 0;
- for (len = 1; len < MAX_ALLOWED_CODE_LENGTH; ++len) {
- if (count[len] > (1 << len)) {
- return 0;
- }
- offset[len + 1] = offset[len] + count[len];
- }
-
- // Sort symbols by length, by symbol order within each length.
- for (symbol = 0; symbol < code_lengths_size; ++symbol) {
- const int symbol_code_length = code_lengths[symbol];
- if (code_lengths[symbol] > 0) {
- if (sorted != NULL) {
- sorted[offset[symbol_code_length]++] = symbol;
- } else {
- offset[symbol_code_length]++;
- }
- }
- }
-
- // Special case code with only one value.
- if (offset[MAX_ALLOWED_CODE_LENGTH] == 1) {
- if (sorted != NULL) {
- HuffmanCode code;
- code.bits = 0;
- code.value = (uint16_t)sorted[0];
- ReplicateValue(table, 1, total_size, code);
- }
- return total_size;
- }
-
- {
- int step; // step size to replicate values in current table
- uint32_t low = -1; // low bits for current root entry
- uint32_t mask = total_size - 1; // mask for low bits
- uint32_t key = 0; // reversed prefix code
- int num_nodes = 1; // number of Huffman tree nodes
- int num_open = 1; // number of open branches in current tree level
- int table_bits = root_bits; // key length of current table
- int table_size = 1 << table_bits; // size of current table
- symbol = 0;
- // Fill in root table.
- for (len = 1, step = 2; len <= root_bits; ++len, step <<= 1) {
- num_open <<= 1;
- num_nodes += num_open;
- num_open -= count[len];
- if (num_open < 0) {
- return 0;
- }
- if (root_table == NULL) continue;
- for (; count[len] > 0; --count[len]) {
- HuffmanCode code;
- code.bits = (uint8_t)len;
- code.value = (uint16_t)sorted[symbol++];
- ReplicateValue(&table[key], step, table_size, code);
- key = GetNextKey(key, len);
- }
- }
-
- // Fill in 2nd level tables and add pointers to root table.
- for (len = root_bits + 1, step = 2; len <= MAX_ALLOWED_CODE_LENGTH;
- ++len, step <<= 1) {
- num_open <<= 1;
- num_nodes += num_open;
- num_open -= count[len];
- if (num_open < 0) {
- return 0;
- }
- if (root_table == NULL) continue;
- for (; count[len] > 0; --count[len]) {
- HuffmanCode code;
- if ((key & mask) != low) {
- table += table_size;
- table_bits = NextTableBitSize(count, len, root_bits);
- table_size = 1 << table_bits;
- total_size += table_size;
- low = key & mask;
- root_table[low].bits = (uint8_t)(table_bits + root_bits);
- root_table[low].value = (uint16_t)((table - root_table) - low);
- }
- code.bits = (uint8_t)(len - root_bits);
- code.value = (uint16_t)sorted[symbol++];
- ReplicateValue(&table[key >> root_bits], step, table_size, code);
- key = GetNextKey(key, len);
- }
- }
-
- // Check if tree is full.
- if (num_nodes != 2 * offset[MAX_ALLOWED_CODE_LENGTH] - 1) {
- return 0;
- }
- }
-
- return total_size;
-}
-
-// Maximum code_lengths_size is 2328 (reached for 11-bit color_cache_bits).
-// More commonly, the value is around ~280.
-#define MAX_CODE_LENGTHS_SIZE \
- ((1 << MAX_CACHE_BITS) + NUM_LITERAL_CODES + NUM_LENGTH_CODES)
-// Cut-off value for switching between heap and stack allocation.
-#define SORTED_SIZE_CUTOFF 512
-int VP8LBuildHuffmanTable(HuffmanCode* const root_table, int root_bits,
- const int code_lengths[], int code_lengths_size) {
- int total_size;
- assert(code_lengths_size <= MAX_CODE_LENGTHS_SIZE);
- if (root_table == NULL) {
- total_size = BuildHuffmanTable(NULL, root_bits,
- code_lengths, code_lengths_size, NULL);
- } else if (code_lengths_size <= SORTED_SIZE_CUTOFF) {
- // use local stack-allocated array.
- uint16_t sorted[SORTED_SIZE_CUTOFF];
- total_size = BuildHuffmanTable(root_table, root_bits,
- code_lengths, code_lengths_size, sorted);
- } else { // rare case. Use heap allocation.
- uint16_t* const sorted =
- (uint16_t*)WebPSafeMalloc(code_lengths_size, sizeof(*sorted));
- if (sorted == NULL) return 0;
- total_size = BuildHuffmanTable(root_table, root_bits,
- code_lengths, code_lengths_size, sorted);
- WebPSafeFree(sorted);
- }
- return total_size;
-}
diff --git a/contrib/libs/libwebp/utils/huffman_utils.h b/contrib/libs/libwebp/utils/huffman_utils.h
deleted file mode 100644
index 4f54691d20..0000000000
--- a/contrib/libs/libwebp/utils/huffman_utils.h
+++ /dev/null
@@ -1,90 +0,0 @@
-// Copyright 2012 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Utilities for building and looking up Huffman trees.
-//
-// Author: Urvang Joshi (urvang@google.com)
-
-#ifndef WEBP_UTILS_HUFFMAN_UTILS_H_
-#define WEBP_UTILS_HUFFMAN_UTILS_H_
-
-#include <assert.h>
-#include "../webp/format_constants.h"
-#include "../webp/types.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define HUFFMAN_TABLE_BITS 8
-#define HUFFMAN_TABLE_MASK ((1 << HUFFMAN_TABLE_BITS) - 1)
-
-#define LENGTHS_TABLE_BITS 7
-#define LENGTHS_TABLE_MASK ((1 << LENGTHS_TABLE_BITS) - 1)
-
-
-// Huffman lookup table entry
-typedef struct {
- uint8_t bits; // number of bits used for this symbol
- uint16_t value; // symbol value or table offset
-} HuffmanCode;
-
-// long version for holding 32b values
-typedef struct {
- int bits; // number of bits used for this symbol,
- // or an impossible value if not a literal code.
- uint32_t value; // 32b packed ARGB value if literal,
- // or non-literal symbol otherwise
-} HuffmanCode32;
-
-#define HUFFMAN_PACKED_BITS 6
-#define HUFFMAN_PACKED_TABLE_SIZE (1u << HUFFMAN_PACKED_BITS)
-
-// Huffman table group.
-// Includes special handling for the following cases:
-// - is_trivial_literal: one common literal base for RED/BLUE/ALPHA (not GREEN)
-// - is_trivial_code: only 1 code (no bit is read from bitstream)
-// - use_packed_table: few enough literal symbols, so all the bit codes
-// can fit into a small look-up table packed_table[]
-// The common literal base, if applicable, is stored in 'literal_arb'.
-typedef struct HTreeGroup HTreeGroup;
-struct HTreeGroup {
- HuffmanCode* htrees[HUFFMAN_CODES_PER_META_CODE];
- int is_trivial_literal; // True, if huffman trees for Red, Blue & Alpha
- // Symbols are trivial (have a single code).
- uint32_t literal_arb; // If is_trivial_literal is true, this is the
- // ARGB value of the pixel, with Green channel
- // being set to zero.
- int is_trivial_code; // true if is_trivial_literal with only one code
- int use_packed_table; // use packed table below for short literal code
- // table mapping input bits to a packed values, or escape case to literal code
- HuffmanCode32 packed_table[HUFFMAN_PACKED_TABLE_SIZE];
-};
-
-// Creates the instance of HTreeGroup with specified number of tree-groups.
-HTreeGroup* VP8LHtreeGroupsNew(int num_htree_groups);
-
-// Releases the memory allocated for HTreeGroup.
-void VP8LHtreeGroupsFree(HTreeGroup* const htree_groups);
-
-// Builds Huffman lookup table assuming code lengths are in symbol order.
-// The 'code_lengths' is pre-allocated temporary memory buffer used for creating
-// the huffman table.
-// Returns built table size or 0 in case of error (invalid tree or
-// memory error).
-// If root_table is NULL, it returns 0 if a lookup cannot be built, something
-// > 0 otherwise (but not the table size).
-int VP8LBuildHuffmanTable(HuffmanCode* const root_table, int root_bits,
- const int code_lengths[], int code_lengths_size);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // WEBP_UTILS_HUFFMAN_UTILS_H_
diff --git a/contrib/libs/libwebp/utils/quant_levels_dec_utils.c b/contrib/libs/libwebp/utils/quant_levels_dec_utils.c
deleted file mode 100644
index 7a62606415..0000000000
--- a/contrib/libs/libwebp/utils/quant_levels_dec_utils.c
+++ /dev/null
@@ -1,291 +0,0 @@
-// Copyright 2013 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Implement gradient smoothing: we replace a current alpha value by its
-// surrounding average if it's close enough (that is: the change will be less
-// than the minimum distance between two quantized level).
-// We use sliding window for computing the 2d moving average.
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include "./quant_levels_dec_utils.h"
-
-#include <string.h> // for memset
-
-#include "./utils.h"
-
-// #define USE_DITHERING // uncomment to enable ordered dithering (not vital)
-
-#define FIX 16 // fix-point precision for averaging
-#define LFIX 2 // extra precision for look-up table
-#define LUT_SIZE ((1 << (8 + LFIX)) - 1) // look-up table size
-
-#if defined(USE_DITHERING)
-
-#define DFIX 4 // extra precision for ordered dithering
-#define DSIZE 4 // dithering size (must be a power of two)
-// cf. https://en.wikipedia.org/wiki/Ordered_dithering
-static const uint8_t kOrderedDither[DSIZE][DSIZE] = {
- { 0, 8, 2, 10 }, // coefficients are in DFIX fixed-point precision
- { 12, 4, 14, 6 },
- { 3, 11, 1, 9 },
- { 15, 7, 13, 5 }
-};
-
-#else
-#define DFIX 0
-#endif
-
-typedef struct {
- int width_, height_; // dimension
- int stride_; // stride in bytes
- int row_; // current input row being processed
- uint8_t* src_; // input pointer
- uint8_t* dst_; // output pointer
-
- int radius_; // filter radius (=delay)
- int scale_; // normalization factor, in FIX bits precision
-
- void* mem_; // all memory
-
- // various scratch buffers
- uint16_t* start_;
- uint16_t* cur_;
- uint16_t* end_;
- uint16_t* top_;
- uint16_t* average_;
-
- // input levels distribution
- int num_levels_; // number of quantized levels
- int min_, max_; // min and max level values
- int min_level_dist_; // smallest distance between two consecutive levels
-
- int16_t* correction_; // size = 1 + 2*LUT_SIZE -> ~4k memory
-} SmoothParams;
-
-//------------------------------------------------------------------------------
-
-#define CLIP_8b_MASK (int)(~0U << (8 + DFIX))
-static WEBP_INLINE uint8_t clip_8b(int v) {
- return (!(v & CLIP_8b_MASK)) ? (uint8_t)(v >> DFIX) : (v < 0) ? 0u : 255u;
-}
-#undef CLIP_8b_MASK
-
-// vertical accumulation
-static void VFilter(SmoothParams* const p) {
- const uint8_t* src = p->src_;
- const int w = p->width_;
- uint16_t* const cur = p->cur_;
- const uint16_t* const top = p->top_;
- uint16_t* const out = p->end_;
- uint16_t sum = 0; // all arithmetic is modulo 16bit
- int x;
-
- for (x = 0; x < w; ++x) {
- uint16_t new_value;
- sum += src[x];
- new_value = top[x] + sum;
- out[x] = new_value - cur[x]; // vertical sum of 'r' pixels.
- cur[x] = new_value;
- }
- // move input pointers one row down
- p->top_ = p->cur_;
- p->cur_ += w;
- if (p->cur_ == p->end_) p->cur_ = p->start_; // roll-over
- // We replicate edges, as it's somewhat easier as a boundary condition.
- // That's why we don't update the 'src' pointer on top/bottom area:
- if (p->row_ >= 0 && p->row_ < p->height_ - 1) {
- p->src_ += p->stride_;
- }
-}
-
-// horizontal accumulation. We use mirror replication of missing pixels, as it's
-// a little easier to implement (surprisingly).
-static void HFilter(SmoothParams* const p) {
- const uint16_t* const in = p->end_;
- uint16_t* const out = p->average_;
- const uint32_t scale = p->scale_;
- const int w = p->width_;
- const int r = p->radius_;
-
- int x;
- for (x = 0; x <= r; ++x) { // left mirroring
- const uint16_t delta = in[x + r - 1] + in[r - x];
- out[x] = (delta * scale) >> FIX;
- }
- for (; x < w - r; ++x) { // bulk middle run
- const uint16_t delta = in[x + r] - in[x - r - 1];
- out[x] = (delta * scale) >> FIX;
- }
- for (; x < w; ++x) { // right mirroring
- const uint16_t delta =
- 2 * in[w - 1] - in[2 * w - 2 - r - x] - in[x - r - 1];
- out[x] = (delta * scale) >> FIX;
- }
-}
-
-// emit one filtered output row
-static void ApplyFilter(SmoothParams* const p) {
- const uint16_t* const average = p->average_;
- const int w = p->width_;
- const int16_t* const correction = p->correction_;
-#if defined(USE_DITHERING)
- const uint8_t* const dither = kOrderedDither[p->row_ % DSIZE];
-#endif
- uint8_t* const dst = p->dst_;
- int x;
- for (x = 0; x < w; ++x) {
- const int v = dst[x];
- if (v < p->max_ && v > p->min_) {
- const int c = (v << DFIX) + correction[average[x] - (v << LFIX)];
-#if defined(USE_DITHERING)
- dst[x] = clip_8b(c + dither[x % DSIZE]);
-#else
- dst[x] = clip_8b(c);
-#endif
- }
- }
- p->dst_ += p->stride_; // advance output pointer
-}
-
-//------------------------------------------------------------------------------
-// Initialize correction table
-
-static void InitCorrectionLUT(int16_t* const lut, int min_dist) {
- // The correction curve is:
- // f(x) = x for x <= threshold2
- // f(x) = 0 for x >= threshold1
- // and a linear interpolation for range x=[threshold2, threshold1]
- // (along with f(-x) = -f(x) symmetry).
- // Note that: threshold2 = 3/4 * threshold1
- const int threshold1 = min_dist << LFIX;
- const int threshold2 = (3 * threshold1) >> 2;
- const int max_threshold = threshold2 << DFIX;
- const int delta = threshold1 - threshold2;
- int i;
- for (i = 1; i <= LUT_SIZE; ++i) {
- int c = (i <= threshold2) ? (i << DFIX)
- : (i < threshold1) ? max_threshold * (threshold1 - i) / delta
- : 0;
- c >>= LFIX;
- lut[+i] = +c;
- lut[-i] = -c;
- }
- lut[0] = 0;
-}
-
-static void CountLevels(SmoothParams* const p) {
- int i, j, last_level;
- uint8_t used_levels[256] = { 0 };
- const uint8_t* data = p->src_;
- p->min_ = 255;
- p->max_ = 0;
- for (j = 0; j < p->height_; ++j) {
- for (i = 0; i < p->width_; ++i) {
- const int v = data[i];
- if (v < p->min_) p->min_ = v;
- if (v > p->max_) p->max_ = v;
- used_levels[v] = 1;
- }
- data += p->stride_;
- }
- // Compute the mininum distance between two non-zero levels.
- p->min_level_dist_ = p->max_ - p->min_;
- last_level = -1;
- for (i = 0; i < 256; ++i) {
- if (used_levels[i]) {
- ++p->num_levels_;
- if (last_level >= 0) {
- const int level_dist = i - last_level;
- if (level_dist < p->min_level_dist_) {
- p->min_level_dist_ = level_dist;
- }
- }
- last_level = i;
- }
- }
-}
-
-// Initialize all params.
-static int InitParams(uint8_t* const data, int width, int height, int stride,
- int radius, SmoothParams* const p) {
- const int R = 2 * radius + 1; // total size of the kernel
-
- const size_t size_scratch_m = (R + 1) * width * sizeof(*p->start_);
- const size_t size_m = width * sizeof(*p->average_);
- const size_t size_lut = (1 + 2 * LUT_SIZE) * sizeof(*p->correction_);
- const size_t total_size = size_scratch_m + size_m + size_lut;
- uint8_t* mem = (uint8_t*)WebPSafeMalloc(1U, total_size);
-
- if (mem == NULL) return 0;
- p->mem_ = (void*)mem;
-
- p->start_ = (uint16_t*)mem;
- p->cur_ = p->start_;
- p->end_ = p->start_ + R * width;
- p->top_ = p->end_ - width;
- memset(p->top_, 0, width * sizeof(*p->top_));
- mem += size_scratch_m;
-
- p->average_ = (uint16_t*)mem;
- mem += size_m;
-
- p->width_ = width;
- p->height_ = height;
- p->stride_ = stride;
- p->src_ = data;
- p->dst_ = data;
- p->radius_ = radius;
- p->scale_ = (1 << (FIX + LFIX)) / (R * R); // normalization constant
- p->row_ = -radius;
-
- // analyze the input distribution so we can best-fit the threshold
- CountLevels(p);
-
- // correction table
- p->correction_ = ((int16_t*)mem) + LUT_SIZE;
- InitCorrectionLUT(p->correction_, p->min_level_dist_);
-
- return 1;
-}
-
-static void CleanupParams(SmoothParams* const p) {
- WebPSafeFree(p->mem_);
-}
-
-int WebPDequantizeLevels(uint8_t* const data, int width, int height, int stride,
- int strength) {
- int radius = 4 * strength / 100;
-
- if (strength < 0 || strength > 100) return 0;
- if (data == NULL || width <= 0 || height <= 0) return 0; // bad params
-
- // limit the filter size to not exceed the image dimensions
- if (2 * radius + 1 > width) radius = (width - 1) >> 1;
- if (2 * radius + 1 > height) radius = (height - 1) >> 1;
-
- if (radius > 0) {
- SmoothParams p;
- memset(&p, 0, sizeof(p));
- if (!InitParams(data, width, height, stride, radius, &p)) return 0;
- if (p.num_levels_ > 2) {
- for (; p.row_ < p.height_; ++p.row_) {
- VFilter(&p); // accumulate average of input
- // Need to wait few rows in order to prime the filter,
- // before emitting some output.
- if (p.row_ >= p.radius_) {
- HFilter(&p);
- ApplyFilter(&p);
- }
- }
- }
- CleanupParams(&p);
- }
- return 1;
-}
diff --git a/contrib/libs/libwebp/utils/quant_levels_dec_utils.h b/contrib/libs/libwebp/utils/quant_levels_dec_utils.h
deleted file mode 100644
index c05376c671..0000000000
--- a/contrib/libs/libwebp/utils/quant_levels_dec_utils.h
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright 2013 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Alpha plane de-quantization utility
-//
-// Author: Vikas Arora (vikasa@google.com)
-
-#ifndef WEBP_UTILS_QUANT_LEVELS_DEC_UTILS_H_
-#define WEBP_UTILS_QUANT_LEVELS_DEC_UTILS_H_
-
-#include "../webp/types.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// Apply post-processing to input 'data' of size 'width'x'height' assuming that
-// the source was quantized to a reduced number of levels. 'stride' is in bytes.
-// Strength is in [0..100] and controls the amount of dithering applied.
-// Returns false in case of error (data is NULL, invalid parameters,
-// malloc failure, ...).
-int WebPDequantizeLevels(uint8_t* const data, int width, int height, int stride,
- int strength);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // WEBP_UTILS_QUANT_LEVELS_DEC_UTILS_H_
diff --git a/contrib/libs/libwebp/utils/quant_levels_utils.c b/contrib/libs/libwebp/utils/quant_levels_utils.c
deleted file mode 100644
index 73174e8ab9..0000000000
--- a/contrib/libs/libwebp/utils/quant_levels_utils.c
+++ /dev/null
@@ -1,140 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Quantize levels for specified number of quantization-levels ([2, 256]).
-// Min and max values are preserved (usual 0 and 255 for alpha plane).
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include <assert.h>
-
-#include "./quant_levels_utils.h"
-
-#define NUM_SYMBOLS 256
-
-#define MAX_ITER 6 // Maximum number of convergence steps.
-#define ERROR_THRESHOLD 1e-4 // MSE stopping criterion.
-
-// -----------------------------------------------------------------------------
-// Quantize levels.
-
-int QuantizeLevels(uint8_t* const data, int width, int height,
- int num_levels, uint64_t* const sse) {
- int freq[NUM_SYMBOLS] = { 0 };
- int q_level[NUM_SYMBOLS] = { 0 };
- double inv_q_level[NUM_SYMBOLS] = { 0 };
- int min_s = 255, max_s = 0;
- const size_t data_size = height * width;
- int i, num_levels_in, iter;
- double last_err = 1.e38, err = 0.;
- const double err_threshold = ERROR_THRESHOLD * data_size;
-
- if (data == NULL) {
- return 0;
- }
-
- if (width <= 0 || height <= 0) {
- return 0;
- }
-
- if (num_levels < 2 || num_levels > 256) {
- return 0;
- }
-
- {
- size_t n;
- num_levels_in = 0;
- for (n = 0; n < data_size; ++n) {
- num_levels_in += (freq[data[n]] == 0);
- if (min_s > data[n]) min_s = data[n];
- if (max_s < data[n]) max_s = data[n];
- ++freq[data[n]];
- }
- }
-
- if (num_levels_in <= num_levels) goto End; // nothing to do!
-
- // Start with uniformly spread centroids.
- for (i = 0; i < num_levels; ++i) {
- inv_q_level[i] = min_s + (double)(max_s - min_s) * i / (num_levels - 1);
- }
-
- // Fixed values. Won't be changed.
- q_level[min_s] = 0;
- q_level[max_s] = num_levels - 1;
- assert(inv_q_level[0] == min_s);
- assert(inv_q_level[num_levels - 1] == max_s);
-
- // k-Means iterations.
- for (iter = 0; iter < MAX_ITER; ++iter) {
- double q_sum[NUM_SYMBOLS] = { 0 };
- double q_count[NUM_SYMBOLS] = { 0 };
- int s, slot = 0;
-
- // Assign classes to representatives.
- for (s = min_s; s <= max_s; ++s) {
- // Keep track of the nearest neighbour 'slot'
- while (slot < num_levels - 1 &&
- 2 * s > inv_q_level[slot] + inv_q_level[slot + 1]) {
- ++slot;
- }
- if (freq[s] > 0) {
- q_sum[slot] += s * freq[s];
- q_count[slot] += freq[s];
- }
- q_level[s] = slot;
- }
-
- // Assign new representatives to classes.
- if (num_levels > 2) {
- for (slot = 1; slot < num_levels - 1; ++slot) {
- const double count = q_count[slot];
- if (count > 0.) {
- inv_q_level[slot] = q_sum[slot] / count;
- }
- }
- }
-
- // Compute convergence error.
- err = 0.;
- for (s = min_s; s <= max_s; ++s) {
- const double error = s - inv_q_level[q_level[s]];
- err += freq[s] * error * error;
- }
-
- // Check for convergence: we stop as soon as the error is no
- // longer improving.
- if (last_err - err < err_threshold) break;
- last_err = err;
- }
-
- // Remap the alpha plane to quantized values.
- {
- // double->int rounding operation can be costly, so we do it
- // once for all before remapping. We also perform the data[] -> slot
- // mapping, while at it (avoid one indirection in the final loop).
- uint8_t map[NUM_SYMBOLS];
- int s;
- size_t n;
- for (s = min_s; s <= max_s; ++s) {
- const int slot = q_level[s];
- map[s] = (uint8_t)(inv_q_level[slot] + .5);
- }
- // Final pass.
- for (n = 0; n < data_size; ++n) {
- data[n] = map[data[n]];
- }
- }
- End:
- // Store sum of squared error if needed.
- if (sse != NULL) *sse = (uint64_t)err;
-
- return 1;
-}
-
diff --git a/contrib/libs/libwebp/utils/quant_levels_utils.h b/contrib/libs/libwebp/utils/quant_levels_utils.h
deleted file mode 100644
index 52a25a5f99..0000000000
--- a/contrib/libs/libwebp/utils/quant_levels_utils.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Alpha plane quantization utility
-//
-// Author: Vikas Arora (vikasa@google.com)
-
-#ifndef WEBP_UTILS_QUANT_LEVELS_UTILS_H_
-#define WEBP_UTILS_QUANT_LEVELS_UTILS_H_
-
-#include <stdlib.h>
-
-#include "../webp/types.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// Replace the input 'data' of size 'width'x'height' with 'num-levels'
-// quantized values. If not NULL, 'sse' will contain the sum of squared error.
-// Valid range for 'num_levels' is [2, 256].
-// Returns false in case of error (data is NULL, or parameters are invalid).
-int QuantizeLevels(uint8_t* const data, int width, int height, int num_levels,
- uint64_t* const sse);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // WEBP_UTILS_QUANT_LEVELS_UTILS_H_
diff --git a/contrib/libs/libwebp/utils/random_utils.c b/contrib/libs/libwebp/utils/random_utils.c
deleted file mode 100644
index 9f1e4154a6..0000000000
--- a/contrib/libs/libwebp/utils/random_utils.c
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright 2013 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Pseudo-random utilities
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include <string.h>
-#include "./random_utils.h"
-
-//------------------------------------------------------------------------------
-
-// 31b-range values
-static const uint32_t kRandomTable[VP8_RANDOM_TABLE_SIZE] = {
- 0x0de15230, 0x03b31886, 0x775faccb, 0x1c88626a, 0x68385c55, 0x14b3b828,
- 0x4a85fef8, 0x49ddb84b, 0x64fcf397, 0x5c550289, 0x4a290000, 0x0d7ec1da,
- 0x5940b7ab, 0x5492577d, 0x4e19ca72, 0x38d38c69, 0x0c01ee65, 0x32a1755f,
- 0x5437f652, 0x5abb2c32, 0x0faa57b1, 0x73f533e7, 0x685feeda, 0x7563cce2,
- 0x6e990e83, 0x4730a7ed, 0x4fc0d9c6, 0x496b153c, 0x4f1403fa, 0x541afb0c,
- 0x73990b32, 0x26d7cb1c, 0x6fcc3706, 0x2cbb77d8, 0x75762f2a, 0x6425ccdd,
- 0x24b35461, 0x0a7d8715, 0x220414a8, 0x141ebf67, 0x56b41583, 0x73e502e3,
- 0x44cab16f, 0x28264d42, 0x73baaefb, 0x0a50ebed, 0x1d6ab6fb, 0x0d3ad40b,
- 0x35db3b68, 0x2b081e83, 0x77ce6b95, 0x5181e5f0, 0x78853bbc, 0x009f9494,
- 0x27e5ed3c
-};
-
-void VP8InitRandom(VP8Random* const rg, float dithering) {
- memcpy(rg->tab_, kRandomTable, sizeof(rg->tab_));
- rg->index1_ = 0;
- rg->index2_ = 31;
- rg->amp_ = (dithering < 0.0) ? 0
- : (dithering > 1.0) ? (1 << VP8_RANDOM_DITHER_FIX)
- : (uint32_t)((1 << VP8_RANDOM_DITHER_FIX) * dithering);
-}
-
-//------------------------------------------------------------------------------
-
diff --git a/contrib/libs/libwebp/utils/random_utils.h b/contrib/libs/libwebp/utils/random_utils.h
deleted file mode 100644
index 6688d2801d..0000000000
--- a/contrib/libs/libwebp/utils/random_utils.h
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright 2013 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Pseudo-random utilities
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#ifndef WEBP_UTILS_RANDOM_UTILS_H_
-#define WEBP_UTILS_RANDOM_UTILS_H_
-
-#include <assert.h>
-#include "../webp/types.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define VP8_RANDOM_DITHER_FIX 8 // fixed-point precision for dithering
-#define VP8_RANDOM_TABLE_SIZE 55
-
-typedef struct {
- int index1_, index2_;
- uint32_t tab_[VP8_RANDOM_TABLE_SIZE];
- int amp_;
-} VP8Random;
-
-// Initializes random generator with an amplitude 'dithering' in range [0..1].
-void VP8InitRandom(VP8Random* const rg, float dithering);
-
-// Returns a centered pseudo-random number with 'num_bits' amplitude.
-// (uses D.Knuth's Difference-based random generator).
-// 'amp' is in VP8_RANDOM_DITHER_FIX fixed-point precision.
-static WEBP_INLINE int VP8RandomBits2(VP8Random* const rg, int num_bits,
- int amp) {
- int diff;
- assert(num_bits + VP8_RANDOM_DITHER_FIX <= 31);
- diff = rg->tab_[rg->index1_] - rg->tab_[rg->index2_];
- if (diff < 0) diff += (1u << 31);
- rg->tab_[rg->index1_] = diff;
- if (++rg->index1_ == VP8_RANDOM_TABLE_SIZE) rg->index1_ = 0;
- if (++rg->index2_ == VP8_RANDOM_TABLE_SIZE) rg->index2_ = 0;
- // sign-extend, 0-center
- diff = (int)((uint32_t)diff << 1) >> (32 - num_bits);
- diff = (diff * amp) >> VP8_RANDOM_DITHER_FIX; // restrict range
- diff += 1 << (num_bits - 1); // shift back to 0.5-center
- return diff;
-}
-
-static WEBP_INLINE int VP8RandomBits(VP8Random* const rg, int num_bits) {
- return VP8RandomBits2(rg, num_bits, rg->amp_);
-}
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // WEBP_UTILS_RANDOM_UTILS_H_
diff --git a/contrib/libs/libwebp/utils/rescaler_utils.c b/contrib/libs/libwebp/utils/rescaler_utils.c
deleted file mode 100644
index 268689b257..0000000000
--- a/contrib/libs/libwebp/utils/rescaler_utils.c
+++ /dev/null
@@ -1,160 +0,0 @@
-// Copyright 2012 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Rescaling functions
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include <assert.h>
-#include <limits.h>
-#include <stdlib.h>
-#include <string.h>
-#include "../dsp/dsp.h"
-#include "./rescaler_utils.h"
-#include "./utils.h"
-
-//------------------------------------------------------------------------------
-
-int WebPRescalerInit(WebPRescaler* const rescaler,
- int src_width, int src_height,
- uint8_t* const dst,
- int dst_width, int dst_height, int dst_stride,
- int num_channels, rescaler_t* const work) {
- const int x_add = src_width, x_sub = dst_width;
- const int y_add = src_height, y_sub = dst_height;
- const uint64_t total_size = 2ull * dst_width * num_channels * sizeof(*work);
- if (!CheckSizeOverflow(total_size)) return 0;
-
- rescaler->x_expand = (src_width < dst_width);
- rescaler->y_expand = (src_height < dst_height);
- rescaler->src_width = src_width;
- rescaler->src_height = src_height;
- rescaler->dst_width = dst_width;
- rescaler->dst_height = dst_height;
- rescaler->src_y = 0;
- rescaler->dst_y = 0;
- rescaler->dst = dst;
- rescaler->dst_stride = dst_stride;
- rescaler->num_channels = num_channels;
-
- // for 'x_expand', we use bilinear interpolation
- rescaler->x_add = rescaler->x_expand ? (x_sub - 1) : x_add;
- rescaler->x_sub = rescaler->x_expand ? (x_add - 1) : x_sub;
- if (!rescaler->x_expand) { // fx_scale is not used otherwise
- rescaler->fx_scale = WEBP_RESCALER_FRAC(1, rescaler->x_sub);
- }
- // vertical scaling parameters
- rescaler->y_add = rescaler->y_expand ? y_add - 1 : y_add;
- rescaler->y_sub = rescaler->y_expand ? y_sub - 1 : y_sub;
- rescaler->y_accum = rescaler->y_expand ? rescaler->y_sub : rescaler->y_add;
- if (!rescaler->y_expand) {
- // This is WEBP_RESCALER_FRAC(dst_height, x_add * y_add) without the cast.
- // Its value is <= WEBP_RESCALER_ONE, because dst_height <= rescaler->y_add
- // and rescaler->x_add >= 1;
- const uint64_t num = (uint64_t)dst_height * WEBP_RESCALER_ONE;
- const uint64_t den = (uint64_t)rescaler->x_add * rescaler->y_add;
- const uint64_t ratio = num / den;
- if (ratio != (uint32_t)ratio) {
- // When ratio == WEBP_RESCALER_ONE, we can't represent the ratio with the
- // current fixed-point precision. This happens when src_height ==
- // rescaler->y_add (which == src_height), and rescaler->x_add == 1.
- // => We special-case fxy_scale = 0, in WebPRescalerExportRow().
- rescaler->fxy_scale = 0;
- } else {
- rescaler->fxy_scale = (uint32_t)ratio;
- }
- rescaler->fy_scale = WEBP_RESCALER_FRAC(1, rescaler->y_sub);
- } else {
- rescaler->fy_scale = WEBP_RESCALER_FRAC(1, rescaler->x_add);
- // rescaler->fxy_scale is unused here.
- }
- rescaler->irow = work;
- rescaler->frow = work + num_channels * dst_width;
- memset(work, 0, (size_t)total_size);
-
- WebPRescalerDspInit();
- return 1;
-}
-
-int WebPRescalerGetScaledDimensions(int src_width, int src_height,
- int* const scaled_width,
- int* const scaled_height) {
- assert(scaled_width != NULL);
- assert(scaled_height != NULL);
- {
- int width = *scaled_width;
- int height = *scaled_height;
- const int max_size = INT_MAX / 2;
-
- // if width is unspecified, scale original proportionally to height ratio.
- if (width == 0 && src_height > 0) {
- width =
- (int)(((uint64_t)src_width * height + src_height - 1) / src_height);
- }
- // if height is unspecified, scale original proportionally to width ratio.
- if (height == 0 && src_width > 0) {
- height =
- (int)(((uint64_t)src_height * width + src_width - 1) / src_width);
- }
- // Check if the overall dimensions still make sense.
- if (width <= 0 || height <= 0 || width > max_size || height > max_size) {
- return 0;
- }
-
- *scaled_width = width;
- *scaled_height = height;
- return 1;
- }
-}
-
-//------------------------------------------------------------------------------
-// all-in-one calls
-
-int WebPRescaleNeededLines(const WebPRescaler* const rescaler,
- int max_num_lines) {
- const int num_lines =
- (rescaler->y_accum + rescaler->y_sub - 1) / rescaler->y_sub;
- return (num_lines > max_num_lines) ? max_num_lines : num_lines;
-}
-
-int WebPRescalerImport(WebPRescaler* const rescaler, int num_lines,
- const uint8_t* src, int src_stride) {
- int total_imported = 0;
- while (total_imported < num_lines &&
- !WebPRescalerHasPendingOutput(rescaler)) {
- if (rescaler->y_expand) {
- rescaler_t* const tmp = rescaler->irow;
- rescaler->irow = rescaler->frow;
- rescaler->frow = tmp;
- }
- WebPRescalerImportRow(rescaler, src);
- if (!rescaler->y_expand) { // Accumulate the contribution of the new row.
- int x;
- for (x = 0; x < rescaler->num_channels * rescaler->dst_width; ++x) {
- rescaler->irow[x] += rescaler->frow[x];
- }
- }
- ++rescaler->src_y;
- src += src_stride;
- ++total_imported;
- rescaler->y_accum -= rescaler->y_sub;
- }
- return total_imported;
-}
-
-int WebPRescalerExport(WebPRescaler* const rescaler) {
- int total_exported = 0;
- while (WebPRescalerHasPendingOutput(rescaler)) {
- WebPRescalerExportRow(rescaler);
- ++total_exported;
- }
- return total_exported;
-}
-
-//------------------------------------------------------------------------------
diff --git a/contrib/libs/libwebp/utils/rescaler_utils.h b/contrib/libs/libwebp/utils/rescaler_utils.h
deleted file mode 100644
index 1c1942ddf5..0000000000
--- a/contrib/libs/libwebp/utils/rescaler_utils.h
+++ /dev/null
@@ -1,102 +0,0 @@
-// Copyright 2012 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Rescaling functions
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#ifndef WEBP_UTILS_RESCALER_UTILS_H_
-#define WEBP_UTILS_RESCALER_UTILS_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "../webp/types.h"
-
-#define WEBP_RESCALER_RFIX 32 // fixed-point precision for multiplies
-#define WEBP_RESCALER_ONE (1ull << WEBP_RESCALER_RFIX)
-#define WEBP_RESCALER_FRAC(x, y) \
- ((uint32_t)(((uint64_t)(x) << WEBP_RESCALER_RFIX) / (y)))
-
-// Structure used for on-the-fly rescaling
-typedef uint32_t rescaler_t; // type for side-buffer
-typedef struct WebPRescaler WebPRescaler;
-struct WebPRescaler {
- int x_expand; // true if we're expanding in the x direction
- int y_expand; // true if we're expanding in the y direction
- int num_channels; // bytes to jump between pixels
- uint32_t fx_scale; // fixed-point scaling factors
- uint32_t fy_scale; // ''
- uint32_t fxy_scale; // ''
- int y_accum; // vertical accumulator
- int y_add, y_sub; // vertical increments
- int x_add, x_sub; // horizontal increments
- int src_width, src_height; // source dimensions
- int dst_width, dst_height; // destination dimensions
- int src_y, dst_y; // row counters for input and output
- uint8_t* dst;
- int dst_stride;
- rescaler_t* irow, *frow; // work buffer
-};
-
-// Initialize a rescaler given scratch area 'work' and dimensions of src & dst.
-// Returns false in case of error.
-int WebPRescalerInit(WebPRescaler* const rescaler,
- int src_width, int src_height,
- uint8_t* const dst,
- int dst_width, int dst_height, int dst_stride,
- int num_channels,
- rescaler_t* const work);
-
-// If either 'scaled_width' or 'scaled_height' (but not both) is 0 the value
-// will be calculated preserving the aspect ratio, otherwise the values are
-// left unmodified. Returns true on success, false if either value is 0 after
-// performing the scaling calculation.
-int WebPRescalerGetScaledDimensions(int src_width, int src_height,
- int* const scaled_width,
- int* const scaled_height);
-
-// Returns the number of input lines needed next to produce one output line,
-// considering that the maximum available input lines are 'max_num_lines'.
-int WebPRescaleNeededLines(const WebPRescaler* const rescaler,
- int max_num_lines);
-
-// Import multiple rows over all channels, until at least one row is ready to
-// be exported. Returns the actual number of lines that were imported.
-int WebPRescalerImport(WebPRescaler* const rescaler, int num_rows,
- const uint8_t* src, int src_stride);
-
-// Export as many rows as possible. Return the numbers of rows written.
-int WebPRescalerExport(WebPRescaler* const rescaler);
-
-// Return true if input is finished
-static WEBP_INLINE
-int WebPRescalerInputDone(const WebPRescaler* const rescaler) {
- return (rescaler->src_y >= rescaler->src_height);
-}
-// Return true if output is finished
-static WEBP_INLINE
-int WebPRescalerOutputDone(const WebPRescaler* const rescaler) {
- return (rescaler->dst_y >= rescaler->dst_height);
-}
-
-// Return true if there are pending output rows ready.
-static WEBP_INLINE
-int WebPRescalerHasPendingOutput(const WebPRescaler* const rescaler) {
- return !WebPRescalerOutputDone(rescaler) && (rescaler->y_accum <= 0);
-}
-
-//------------------------------------------------------------------------------
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // WEBP_UTILS_RESCALER_UTILS_H_
diff --git a/contrib/libs/libwebp/utils/thread_utils.c b/contrib/libs/libwebp/utils/thread_utils.c
deleted file mode 100644
index b29a5398e1..0000000000
--- a/contrib/libs/libwebp/utils/thread_utils.c
+++ /dev/null
@@ -1,369 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Multi-threaded worker
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include <assert.h>
-#include <string.h> // for memset()
-#include "./thread_utils.h"
-#include "./utils.h"
-
-#ifdef WEBP_USE_THREAD
-
-#if defined(_WIN32)
-
-#include <windows.h>
-typedef HANDLE pthread_t;
-typedef CRITICAL_SECTION pthread_mutex_t;
-
-#if _WIN32_WINNT >= 0x0600 // Windows Vista / Server 2008 or greater
-#define USE_WINDOWS_CONDITION_VARIABLE
-typedef CONDITION_VARIABLE pthread_cond_t;
-#else
-typedef struct {
- HANDLE waiting_sem_;
- HANDLE received_sem_;
- HANDLE signal_event_;
-} pthread_cond_t;
-#endif // _WIN32_WINNT >= 0x600
-
-#ifndef WINAPI_FAMILY_PARTITION
-#define WINAPI_PARTITION_DESKTOP 1
-#define WINAPI_FAMILY_PARTITION(x) x
-#endif
-
-#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
-#define USE_CREATE_THREAD
-#endif
-
-#else // !_WIN32
-
-#include <pthread.h>
-
-#endif // _WIN32
-
-typedef struct {
- pthread_mutex_t mutex_;
- pthread_cond_t condition_;
- pthread_t thread_;
-} WebPWorkerImpl;
-
-#if defined(_WIN32)
-
-//------------------------------------------------------------------------------
-// simplistic pthread emulation layer
-
-#include <process.h>
-
-// _beginthreadex requires __stdcall
-#define THREADFN unsigned int __stdcall
-#define THREAD_RETURN(val) (unsigned int)((DWORD_PTR)val)
-
-#if _WIN32_WINNT >= 0x0501 // Windows XP or greater
-#define WaitForSingleObject(obj, timeout) \
- WaitForSingleObjectEx(obj, timeout, FALSE /*bAlertable*/)
-#endif
-
-static int pthread_create(pthread_t* const thread, const void* attr,
- unsigned int (__stdcall* start)(void*), void* arg) {
- (void)attr;
-#ifdef USE_CREATE_THREAD
- *thread = CreateThread(NULL, /* lpThreadAttributes */
- 0, /* dwStackSize */
- start,
- arg,
- 0, /* dwStackSize */
- NULL); /* lpThreadId */
-#else
- *thread = (pthread_t)_beginthreadex(NULL, /* void *security */
- 0, /* unsigned stack_size */
- start,
- arg,
- 0, /* unsigned initflag */
- NULL); /* unsigned *thrdaddr */
-#endif
- if (*thread == NULL) return 1;
- SetThreadPriority(*thread, THREAD_PRIORITY_ABOVE_NORMAL);
- return 0;
-}
-
-static int pthread_join(pthread_t thread, void** value_ptr) {
- (void)value_ptr;
- return (WaitForSingleObject(thread, INFINITE) != WAIT_OBJECT_0 ||
- CloseHandle(thread) == 0);
-}
-
-// Mutex
-static int pthread_mutex_init(pthread_mutex_t* const mutex, void* mutexattr) {
- (void)mutexattr;
-#if _WIN32_WINNT >= 0x0600 // Windows Vista / Server 2008 or greater
- InitializeCriticalSectionEx(mutex, 0 /*dwSpinCount*/, 0 /*Flags*/);
-#else
- InitializeCriticalSection(mutex);
-#endif
- return 0;
-}
-
-static int pthread_mutex_lock(pthread_mutex_t* const mutex) {
- EnterCriticalSection(mutex);
- return 0;
-}
-
-static int pthread_mutex_unlock(pthread_mutex_t* const mutex) {
- LeaveCriticalSection(mutex);
- return 0;
-}
-
-static int pthread_mutex_destroy(pthread_mutex_t* const mutex) {
- DeleteCriticalSection(mutex);
- return 0;
-}
-
-// Condition
-static int pthread_cond_destroy(pthread_cond_t* const condition) {
- int ok = 1;
-#ifdef USE_WINDOWS_CONDITION_VARIABLE
- (void)condition;
-#else
- ok &= (CloseHandle(condition->waiting_sem_) != 0);
- ok &= (CloseHandle(condition->received_sem_) != 0);
- ok &= (CloseHandle(condition->signal_event_) != 0);
-#endif
- return !ok;
-}
-
-static int pthread_cond_init(pthread_cond_t* const condition, void* cond_attr) {
- (void)cond_attr;
-#ifdef USE_WINDOWS_CONDITION_VARIABLE
- InitializeConditionVariable(condition);
-#else
- condition->waiting_sem_ = CreateSemaphore(NULL, 0, 1, NULL);
- condition->received_sem_ = CreateSemaphore(NULL, 0, 1, NULL);
- condition->signal_event_ = CreateEvent(NULL, FALSE, FALSE, NULL);
- if (condition->waiting_sem_ == NULL ||
- condition->received_sem_ == NULL ||
- condition->signal_event_ == NULL) {
- pthread_cond_destroy(condition);
- return 1;
- }
-#endif
- return 0;
-}
-
-static int pthread_cond_signal(pthread_cond_t* const condition) {
- int ok = 1;
-#ifdef USE_WINDOWS_CONDITION_VARIABLE
- WakeConditionVariable(condition);
-#else
- if (WaitForSingleObject(condition->waiting_sem_, 0) == WAIT_OBJECT_0) {
- // a thread is waiting in pthread_cond_wait: allow it to be notified
- ok = SetEvent(condition->signal_event_);
- // wait until the event is consumed so the signaler cannot consume
- // the event via its own pthread_cond_wait.
- ok &= (WaitForSingleObject(condition->received_sem_, INFINITE) !=
- WAIT_OBJECT_0);
- }
-#endif
- return !ok;
-}
-
-static int pthread_cond_wait(pthread_cond_t* const condition,
- pthread_mutex_t* const mutex) {
- int ok;
-#ifdef USE_WINDOWS_CONDITION_VARIABLE
- ok = SleepConditionVariableCS(condition, mutex, INFINITE);
-#else
- // note that there is a consumer available so the signal isn't dropped in
- // pthread_cond_signal
- if (!ReleaseSemaphore(condition->waiting_sem_, 1, NULL)) return 1;
- // now unlock the mutex so pthread_cond_signal may be issued
- pthread_mutex_unlock(mutex);
- ok = (WaitForSingleObject(condition->signal_event_, INFINITE) ==
- WAIT_OBJECT_0);
- ok &= ReleaseSemaphore(condition->received_sem_, 1, NULL);
- pthread_mutex_lock(mutex);
-#endif
- return !ok;
-}
-
-#else // !_WIN32
-# define THREADFN void*
-# define THREAD_RETURN(val) val
-#endif // _WIN32
-
-//------------------------------------------------------------------------------
-
-static THREADFN ThreadLoop(void* ptr) {
- WebPWorker* const worker = (WebPWorker*)ptr;
- WebPWorkerImpl* const impl = (WebPWorkerImpl*)worker->impl_;
- int done = 0;
- while (!done) {
- pthread_mutex_lock(&impl->mutex_);
- while (worker->status_ == OK) { // wait in idling mode
- pthread_cond_wait(&impl->condition_, &impl->mutex_);
- }
- if (worker->status_ == WORK) {
- WebPGetWorkerInterface()->Execute(worker);
- worker->status_ = OK;
- } else if (worker->status_ == NOT_OK) { // finish the worker
- done = 1;
- }
- // signal to the main thread that we're done (for Sync())
- // Note the associated mutex does not need to be held when signaling the
- // condition. Unlocking the mutex first may improve performance in some
- // implementations, avoiding the case where the waiting thread can't
- // reacquire the mutex when woken.
- pthread_mutex_unlock(&impl->mutex_);
- pthread_cond_signal(&impl->condition_);
- }
- return THREAD_RETURN(NULL); // Thread is finished
-}
-
-// main thread state control
-static void ChangeState(WebPWorker* const worker, WebPWorkerStatus new_status) {
- // No-op when attempting to change state on a thread that didn't come up.
- // Checking status_ without acquiring the lock first would result in a data
- // race.
- WebPWorkerImpl* const impl = (WebPWorkerImpl*)worker->impl_;
- if (impl == NULL) return;
-
- pthread_mutex_lock(&impl->mutex_);
- if (worker->status_ >= OK) {
- // wait for the worker to finish
- while (worker->status_ != OK) {
- pthread_cond_wait(&impl->condition_, &impl->mutex_);
- }
- // assign new status and release the working thread if needed
- if (new_status != OK) {
- worker->status_ = new_status;
- // Note the associated mutex does not need to be held when signaling the
- // condition. Unlocking the mutex first may improve performance in some
- // implementations, avoiding the case where the waiting thread can't
- // reacquire the mutex when woken.
- pthread_mutex_unlock(&impl->mutex_);
- pthread_cond_signal(&impl->condition_);
- return;
- }
- }
- pthread_mutex_unlock(&impl->mutex_);
-}
-
-#endif // WEBP_USE_THREAD
-
-//------------------------------------------------------------------------------
-
-static void Init(WebPWorker* const worker) {
- memset(worker, 0, sizeof(*worker));
- worker->status_ = NOT_OK;
-}
-
-static int Sync(WebPWorker* const worker) {
-#ifdef WEBP_USE_THREAD
- ChangeState(worker, OK);
-#endif
- assert(worker->status_ <= OK);
- return !worker->had_error;
-}
-
-static int Reset(WebPWorker* const worker) {
- int ok = 1;
- worker->had_error = 0;
- if (worker->status_ < OK) {
-#ifdef WEBP_USE_THREAD
- WebPWorkerImpl* const impl =
- (WebPWorkerImpl*)WebPSafeCalloc(1, sizeof(WebPWorkerImpl));
- worker->impl_ = (void*)impl;
- if (worker->impl_ == NULL) {
- return 0;
- }
- if (pthread_mutex_init(&impl->mutex_, NULL)) {
- goto Error;
- }
- if (pthread_cond_init(&impl->condition_, NULL)) {
- pthread_mutex_destroy(&impl->mutex_);
- goto Error;
- }
- pthread_mutex_lock(&impl->mutex_);
- ok = !pthread_create(&impl->thread_, NULL, ThreadLoop, worker);
- if (ok) worker->status_ = OK;
- pthread_mutex_unlock(&impl->mutex_);
- if (!ok) {
- pthread_mutex_destroy(&impl->mutex_);
- pthread_cond_destroy(&impl->condition_);
- Error:
- WebPSafeFree(impl);
- worker->impl_ = NULL;
- return 0;
- }
-#else
- worker->status_ = OK;
-#endif
- } else if (worker->status_ > OK) {
- ok = Sync(worker);
- }
- assert(!ok || (worker->status_ == OK));
- return ok;
-}
-
-static void Execute(WebPWorker* const worker) {
- if (worker->hook != NULL) {
- worker->had_error |= !worker->hook(worker->data1, worker->data2);
- }
-}
-
-static void Launch(WebPWorker* const worker) {
-#ifdef WEBP_USE_THREAD
- ChangeState(worker, WORK);
-#else
- Execute(worker);
-#endif
-}
-
-static void End(WebPWorker* const worker) {
-#ifdef WEBP_USE_THREAD
- if (worker->impl_ != NULL) {
- WebPWorkerImpl* const impl = (WebPWorkerImpl*)worker->impl_;
- ChangeState(worker, NOT_OK);
- pthread_join(impl->thread_, NULL);
- pthread_mutex_destroy(&impl->mutex_);
- pthread_cond_destroy(&impl->condition_);
- WebPSafeFree(impl);
- worker->impl_ = NULL;
- }
-#else
- worker->status_ = NOT_OK;
- assert(worker->impl_ == NULL);
-#endif
- assert(worker->status_ == NOT_OK);
-}
-
-//------------------------------------------------------------------------------
-
-static WebPWorkerInterface g_worker_interface = {
- Init, Reset, Sync, Launch, Execute, End
-};
-
-int WebPSetWorkerInterface(const WebPWorkerInterface* const winterface) {
- if (winterface == NULL ||
- winterface->Init == NULL || winterface->Reset == NULL ||
- winterface->Sync == NULL || winterface->Launch == NULL ||
- winterface->Execute == NULL || winterface->End == NULL) {
- return 0;
- }
- g_worker_interface = *winterface;
- return 1;
-}
-
-const WebPWorkerInterface* WebPGetWorkerInterface(void) {
- return &g_worker_interface;
-}
-
-//------------------------------------------------------------------------------
diff --git a/contrib/libs/libwebp/utils/thread_utils.h b/contrib/libs/libwebp/utils/thread_utils.h
deleted file mode 100644
index eb788f6e05..0000000000
--- a/contrib/libs/libwebp/utils/thread_utils.h
+++ /dev/null
@@ -1,90 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Multi-threaded worker
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#ifndef WEBP_UTILS_THREAD_UTILS_H_
-#define WEBP_UTILS_THREAD_UTILS_H_
-
-#ifdef HAVE_CONFIG_H
-#include "../webp/config.h"
-#endif
-
-#include "../webp/types.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// State of the worker thread object
-typedef enum {
- NOT_OK = 0, // object is unusable
- OK, // ready to work
- WORK // busy finishing the current task
-} WebPWorkerStatus;
-
-// Function to be called by the worker thread. Takes two opaque pointers as
-// arguments (data1 and data2), and should return false in case of error.
-typedef int (*WebPWorkerHook)(void*, void*);
-
-// Synchronization object used to launch job in the worker thread
-typedef struct {
- void* impl_; // platform-dependent implementation worker details
- WebPWorkerStatus status_;
- WebPWorkerHook hook; // hook to call
- void* data1; // first argument passed to 'hook'
- void* data2; // second argument passed to 'hook'
- int had_error; // return value of the last call to 'hook'
-} WebPWorker;
-
-// The interface for all thread-worker related functions. All these functions
-// must be implemented.
-typedef struct {
- // Must be called first, before any other method.
- void (*Init)(WebPWorker* const worker);
- // Must be called to initialize the object and spawn the thread. Re-entrant.
- // Will potentially launch the thread. Returns false in case of error.
- int (*Reset)(WebPWorker* const worker);
- // Makes sure the previous work is finished. Returns true if worker->had_error
- // was not set and no error condition was triggered by the working thread.
- int (*Sync)(WebPWorker* const worker);
- // Triggers the thread to call hook() with data1 and data2 arguments. These
- // hook/data1/data2 values can be changed at any time before calling this
- // function, but not be changed afterward until the next call to Sync().
- void (*Launch)(WebPWorker* const worker);
- // This function is similar to Launch() except that it calls the
- // hook directly instead of using a thread. Convenient to bypass the thread
- // mechanism while still using the WebPWorker structs. Sync() must
- // still be called afterward (for error reporting).
- void (*Execute)(WebPWorker* const worker);
- // Kill the thread and terminate the object. To use the object again, one
- // must call Reset() again.
- void (*End)(WebPWorker* const worker);
-} WebPWorkerInterface;
-
-// Install a new set of threading functions, overriding the defaults. This
-// should be done before any workers are started, i.e., before any encoding or
-// decoding takes place. The contents of the interface struct are copied, it
-// is safe to free the corresponding memory after this call. This function is
-// not thread-safe. Return false in case of invalid pointer or methods.
-WEBP_EXTERN int WebPSetWorkerInterface(
- const WebPWorkerInterface* const winterface);
-
-// Retrieve the currently set thread worker interface.
-WEBP_EXTERN const WebPWorkerInterface* WebPGetWorkerInterface(void);
-
-//------------------------------------------------------------------------------
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // WEBP_UTILS_THREAD_UTILS_H_
diff --git a/contrib/libs/libwebp/utils/utils.c b/contrib/libs/libwebp/utils/utils.c
deleted file mode 100644
index 6d85b2df9f..0000000000
--- a/contrib/libs/libwebp/utils/utils.c
+++ /dev/null
@@ -1,338 +0,0 @@
-// Copyright 2012 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Misc. common utility functions
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include <stdlib.h>
-#include <string.h> // for memcpy()
-#include "../webp/decode.h"
-#include "../webp/encode.h"
-#include "../webp/format_constants.h" // for MAX_PALETTE_SIZE
-#include "./color_cache_utils.h"
-#include "./utils.h"
-
-// If PRINT_MEM_INFO is defined, extra info (like total memory used, number of
-// alloc/free etc) is printed. For debugging/tuning purpose only (it's slow,
-// and not multi-thread safe!).
-// An interesting alternative is valgrind's 'massif' tool:
-// https://valgrind.org/docs/manual/ms-manual.html
-// Here is an example command line:
-/* valgrind --tool=massif --massif-out-file=massif.out \
- --stacks=yes --alloc-fn=WebPSafeMalloc --alloc-fn=WebPSafeCalloc
- ms_print massif.out
-*/
-// In addition:
-// * if PRINT_MEM_TRAFFIC is defined, all the details of the malloc/free cycles
-// are printed.
-// * if MALLOC_FAIL_AT is defined, the global environment variable
-// $MALLOC_FAIL_AT is used to simulate a memory error when calloc or malloc
-// is called for the nth time. Example usage:
-// export MALLOC_FAIL_AT=50 && ./examples/cwebp input.png
-// * if MALLOC_LIMIT is defined, the global environment variable $MALLOC_LIMIT
-// sets the maximum amount of memory (in bytes) made available to libwebp.
-// This can be used to emulate environment with very limited memory.
-// Example: export MALLOC_LIMIT=64000000 && ./examples/dwebp picture.webp
-
-// #define PRINT_MEM_INFO
-// #define PRINT_MEM_TRAFFIC
-// #define MALLOC_FAIL_AT
-// #define MALLOC_LIMIT
-
-//------------------------------------------------------------------------------
-// Checked memory allocation
-
-#if defined(PRINT_MEM_INFO)
-
-#include <stdio.h>
-
-static int num_malloc_calls = 0;
-static int num_calloc_calls = 0;
-static int num_free_calls = 0;
-static int countdown_to_fail = 0; // 0 = off
-
-typedef struct MemBlock MemBlock;
-struct MemBlock {
- void* ptr_;
- size_t size_;
- MemBlock* next_;
-};
-
-static MemBlock* all_blocks = NULL;
-static size_t total_mem = 0;
-static size_t total_mem_allocated = 0;
-static size_t high_water_mark = 0;
-static size_t mem_limit = 0;
-
-static int exit_registered = 0;
-
-static void PrintMemInfo(void) {
- fprintf(stderr, "\nMEMORY INFO:\n");
- fprintf(stderr, "num calls to: malloc = %4d\n", num_malloc_calls);
- fprintf(stderr, " calloc = %4d\n", num_calloc_calls);
- fprintf(stderr, " free = %4d\n", num_free_calls);
- fprintf(stderr, "total_mem: %u\n", (uint32_t)total_mem);
- fprintf(stderr, "total_mem allocated: %u\n", (uint32_t)total_mem_allocated);
- fprintf(stderr, "high-water mark: %u\n", (uint32_t)high_water_mark);
- while (all_blocks != NULL) {
- MemBlock* b = all_blocks;
- all_blocks = b->next_;
- free(b);
- }
-}
-
-static void Increment(int* const v) {
- if (!exit_registered) {
-#if defined(MALLOC_FAIL_AT)
- {
- const char* const malloc_fail_at_str = getenv("MALLOC_FAIL_AT");
- if (malloc_fail_at_str != NULL) {
- countdown_to_fail = atoi(malloc_fail_at_str);
- }
- }
-#endif
-#if defined(MALLOC_LIMIT)
- {
- const char* const malloc_limit_str = getenv("MALLOC_LIMIT");
-#if MALLOC_LIMIT > 1
- mem_limit = (size_t)MALLOC_LIMIT;
-#endif
- if (malloc_limit_str != NULL) {
- mem_limit = atoi(malloc_limit_str);
- }
- }
-#endif
- (void)countdown_to_fail;
- (void)mem_limit;
- atexit(PrintMemInfo);
- exit_registered = 1;
- }
- ++*v;
-}
-
-static void AddMem(void* ptr, size_t size) {
- if (ptr != NULL) {
- MemBlock* const b = (MemBlock*)malloc(sizeof(*b));
- if (b == NULL) abort();
- b->next_ = all_blocks;
- all_blocks = b;
- b->ptr_ = ptr;
- b->size_ = size;
- total_mem += size;
- total_mem_allocated += size;
-#if defined(PRINT_MEM_TRAFFIC)
-#if defined(MALLOC_FAIL_AT)
- fprintf(stderr, "fail-count: %5d [mem=%u]\n",
- num_malloc_calls + num_calloc_calls, (uint32_t)total_mem);
-#else
- fprintf(stderr, "Mem: %u (+%u)\n", (uint32_t)total_mem, (uint32_t)size);
-#endif
-#endif
- if (total_mem > high_water_mark) high_water_mark = total_mem;
- }
-}
-
-static void SubMem(void* ptr) {
- if (ptr != NULL) {
- MemBlock** b = &all_blocks;
- // Inefficient search, but that's just for debugging.
- while (*b != NULL && (*b)->ptr_ != ptr) b = &(*b)->next_;
- if (*b == NULL) {
- fprintf(stderr, "Invalid pointer free! (%p)\n", ptr);
- abort();
- }
- {
- MemBlock* const block = *b;
- *b = block->next_;
- total_mem -= block->size_;
-#if defined(PRINT_MEM_TRAFFIC)
- fprintf(stderr, "Mem: %u (-%u)\n",
- (uint32_t)total_mem, (uint32_t)block->size_);
-#endif
- free(block);
- }
- }
-}
-
-#else
-#define Increment(v) do {} while (0)
-#define AddMem(p, s) do {} while (0)
-#define SubMem(p) do {} while (0)
-#endif
-
-// Returns 0 in case of overflow of nmemb * size.
-static int CheckSizeArgumentsOverflow(uint64_t nmemb, size_t size) {
- const uint64_t total_size = nmemb * size;
- if (nmemb == 0) return 1;
- if ((uint64_t)size > WEBP_MAX_ALLOCABLE_MEMORY / nmemb) return 0;
- if (!CheckSizeOverflow(total_size)) return 0;
-#if defined(PRINT_MEM_INFO) && defined(MALLOC_FAIL_AT)
- if (countdown_to_fail > 0 && --countdown_to_fail == 0) {
- return 0; // fake fail!
- }
-#endif
-#if defined(PRINT_MEM_INFO) && defined(MALLOC_LIMIT)
- if (mem_limit > 0) {
- const uint64_t new_total_mem = (uint64_t)total_mem + total_size;
- if (!CheckSizeOverflow(new_total_mem) ||
- new_total_mem > mem_limit) {
- return 0; // fake fail!
- }
- }
-#endif
-
- return 1;
-}
-
-void* WebPSafeMalloc(uint64_t nmemb, size_t size) {
- void* ptr;
- Increment(&num_malloc_calls);
- if (!CheckSizeArgumentsOverflow(nmemb, size)) return NULL;
- assert(nmemb * size > 0);
- ptr = malloc((size_t)(nmemb * size));
- AddMem(ptr, (size_t)(nmemb * size));
- return ptr;
-}
-
-void* WebPSafeCalloc(uint64_t nmemb, size_t size) {
- void* ptr;
- Increment(&num_calloc_calls);
- if (!CheckSizeArgumentsOverflow(nmemb, size)) return NULL;
- assert(nmemb * size > 0);
- ptr = calloc((size_t)nmemb, size);
- AddMem(ptr, (size_t)(nmemb * size));
- return ptr;
-}
-
-void WebPSafeFree(void* const ptr) {
- if (ptr != NULL) {
- Increment(&num_free_calls);
- SubMem(ptr);
- }
- free(ptr);
-}
-
-// Public API functions.
-
-void* WebPMalloc(size_t size) {
- return WebPSafeMalloc(1, size);
-}
-
-void WebPFree(void* ptr) {
- WebPSafeFree(ptr);
-}
-
-//------------------------------------------------------------------------------
-
-void WebPCopyPlane(const uint8_t* src, int src_stride,
- uint8_t* dst, int dst_stride, int width, int height) {
- assert(src != NULL && dst != NULL);
- assert(abs(src_stride) >= width && abs(dst_stride) >= width);
- while (height-- > 0) {
- memcpy(dst, src, width);
- src += src_stride;
- dst += dst_stride;
- }
-}
-
-void WebPCopyPixels(const WebPPicture* const src, WebPPicture* const dst) {
- assert(src != NULL && dst != NULL);
- assert(src->width == dst->width && src->height == dst->height);
- assert(src->use_argb && dst->use_argb);
- WebPCopyPlane((uint8_t*)src->argb, 4 * src->argb_stride, (uint8_t*)dst->argb,
- 4 * dst->argb_stride, 4 * src->width, src->height);
-}
-
-//------------------------------------------------------------------------------
-
-#define COLOR_HASH_SIZE (MAX_PALETTE_SIZE * 4)
-#define COLOR_HASH_RIGHT_SHIFT 22 // 32 - log2(COLOR_HASH_SIZE).
-
-int WebPGetColorPalette(const WebPPicture* const pic, uint32_t* const palette) {
- int i;
- int x, y;
- int num_colors = 0;
- uint8_t in_use[COLOR_HASH_SIZE] = { 0 };
- uint32_t colors[COLOR_HASH_SIZE];
- const uint32_t* argb = pic->argb;
- const int width = pic->width;
- const int height = pic->height;
- uint32_t last_pix = ~argb[0]; // so we're sure that last_pix != argb[0]
- assert(pic != NULL);
- assert(pic->use_argb);
-
- for (y = 0; y < height; ++y) {
- for (x = 0; x < width; ++x) {
- int key;
- if (argb[x] == last_pix) {
- continue;
- }
- last_pix = argb[x];
- key = VP8LHashPix(last_pix, COLOR_HASH_RIGHT_SHIFT);
- while (1) {
- if (!in_use[key]) {
- colors[key] = last_pix;
- in_use[key] = 1;
- ++num_colors;
- if (num_colors > MAX_PALETTE_SIZE) {
- return MAX_PALETTE_SIZE + 1; // Exact count not needed.
- }
- break;
- } else if (colors[key] == last_pix) {
- break; // The color is already there.
- } else {
- // Some other color sits here, so do linear conflict resolution.
- ++key;
- key &= (COLOR_HASH_SIZE - 1); // Key mask.
- }
- }
- }
- argb += pic->argb_stride;
- }
-
- if (palette != NULL) { // Fill the colors into palette.
- num_colors = 0;
- for (i = 0; i < COLOR_HASH_SIZE; ++i) {
- if (in_use[i]) {
- palette[num_colors] = colors[i];
- ++num_colors;
- }
- }
- }
- return num_colors;
-}
-
-#undef COLOR_HASH_SIZE
-#undef COLOR_HASH_RIGHT_SHIFT
-
-//------------------------------------------------------------------------------
-
-#if defined(WEBP_NEED_LOG_TABLE_8BIT)
-const uint8_t WebPLogTable8bit[256] = { // 31 ^ clz(i)
- 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
-};
-#endif
-
-//------------------------------------------------------------------------------
diff --git a/contrib/libs/libwebp/utils/utils.h b/contrib/libs/libwebp/utils/utils.h
deleted file mode 100644
index 20abf03c69..0000000000
--- a/contrib/libs/libwebp/utils/utils.h
+++ /dev/null
@@ -1,200 +0,0 @@
-// Copyright 2012 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Misc. common utility functions
-//
-// Authors: Skal (pascal.massimino@gmail.com)
-// Urvang (urvang@google.com)
-
-#ifndef WEBP_UTILS_UTILS_H_
-#define WEBP_UTILS_UTILS_H_
-
-#ifdef HAVE_CONFIG_H
-#include "../webp/config.h"
-#endif
-
-#include <assert.h>
-#include <limits.h>
-
-#include "../dsp/dsp.h"
-#include "../webp/types.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-//------------------------------------------------------------------------------
-// Memory allocation
-
-// This is the maximum memory amount that libwebp will ever try to allocate.
-#ifndef WEBP_MAX_ALLOCABLE_MEMORY
-#if SIZE_MAX > (1ULL << 34)
-#define WEBP_MAX_ALLOCABLE_MEMORY (1ULL << 34)
-#else
-// For 32-bit targets keep this below INT_MAX to avoid valgrind warnings.
-#define WEBP_MAX_ALLOCABLE_MEMORY ((1ULL << 31) - (1 << 16))
-#endif
-#endif // WEBP_MAX_ALLOCABLE_MEMORY
-
-static WEBP_INLINE int CheckSizeOverflow(uint64_t size) {
- return size == (size_t)size;
-}
-
-// size-checking safe malloc/calloc: verify that the requested size is not too
-// large, or return NULL. You don't need to call these for constructs like
-// malloc(sizeof(foo)), but only if there's picture-dependent size involved
-// somewhere (like: malloc(num_pixels * sizeof(*something))). That's why this
-// safe malloc() borrows the signature from calloc(), pointing at the dangerous
-// underlying multiply involved.
-WEBP_EXTERN void* WebPSafeMalloc(uint64_t nmemb, size_t size);
-// Note that WebPSafeCalloc() expects the second argument type to be 'size_t'
-// in order to favor the "calloc(num_foo, sizeof(foo))" pattern.
-WEBP_EXTERN void* WebPSafeCalloc(uint64_t nmemb, size_t size);
-
-// Companion deallocation function to the above allocations.
-WEBP_EXTERN void WebPSafeFree(void* const ptr);
-
-//------------------------------------------------------------------------------
-// Alignment
-
-#define WEBP_ALIGN_CST 31
-#define WEBP_ALIGN(PTR) (((uintptr_t)(PTR) + WEBP_ALIGN_CST) & ~WEBP_ALIGN_CST)
-
-#include <string.h>
-// memcpy() is the safe way of moving potentially unaligned 32b memory.
-static WEBP_INLINE uint32_t WebPMemToUint32(const uint8_t* const ptr) {
- uint32_t A;
- memcpy(&A, ptr, sizeof(A));
- return A;
-}
-static WEBP_INLINE void WebPUint32ToMem(uint8_t* const ptr, uint32_t val) {
- memcpy(ptr, &val, sizeof(val));
-}
-
-//------------------------------------------------------------------------------
-// Reading/writing data.
-
-// Read 16, 24 or 32 bits stored in little-endian order.
-static WEBP_INLINE int GetLE16(const uint8_t* const data) {
- return (int)(data[0] << 0) | (data[1] << 8);
-}
-
-static WEBP_INLINE int GetLE24(const uint8_t* const data) {
- return GetLE16(data) | (data[2] << 16);
-}
-
-static WEBP_INLINE uint32_t GetLE32(const uint8_t* const data) {
- return GetLE16(data) | ((uint32_t)GetLE16(data + 2) << 16);
-}
-
-// Store 16, 24 or 32 bits in little-endian order.
-static WEBP_INLINE void PutLE16(uint8_t* const data, int val) {
- assert(val < (1 << 16));
- data[0] = (val >> 0) & 0xff;
- data[1] = (val >> 8) & 0xff;
-}
-
-static WEBP_INLINE void PutLE24(uint8_t* const data, int val) {
- assert(val < (1 << 24));
- PutLE16(data, val & 0xffff);
- data[2] = (val >> 16) & 0xff;
-}
-
-static WEBP_INLINE void PutLE32(uint8_t* const data, uint32_t val) {
- PutLE16(data, (int)(val & 0xffff));
- PutLE16(data + 2, (int)(val >> 16));
-}
-
-// use GNU builtins where available.
-#if defined(__GNUC__) && \
- ((__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || __GNUC__ >= 4)
-// Returns (int)floor(log2(n)). n must be > 0.
-static WEBP_INLINE int BitsLog2Floor(uint32_t n) {
- return 31 ^ __builtin_clz(n);
-}
-// counts the number of trailing zero
-static WEBP_INLINE int BitsCtz(uint32_t n) { return __builtin_ctz(n); }
-#elif defined(_MSC_VER) && _MSC_VER > 1310 && \
- (defined(_M_X64) || defined(_M_IX86))
-#include <intrin.h>
-#pragma intrinsic(_BitScanReverse)
-#pragma intrinsic(_BitScanForward)
-
-static WEBP_INLINE int BitsLog2Floor(uint32_t n) {
- unsigned long first_set_bit; // NOLINT (runtime/int)
- _BitScanReverse(&first_set_bit, n);
- return first_set_bit;
-}
-static WEBP_INLINE int BitsCtz(uint32_t n) {
- unsigned long first_set_bit; // NOLINT (runtime/int)
- _BitScanForward(&first_set_bit, n);
- return first_set_bit;
-}
-#else // default: use the (slow) C-version.
-#define WEBP_HAVE_SLOW_CLZ_CTZ // signal that the Clz/Ctz function are slow
-// Returns 31 ^ clz(n) = log2(n). This is the default C-implementation, either
-// based on table or not. Can be used as fallback if clz() is not available.
-#define WEBP_NEED_LOG_TABLE_8BIT
-extern const uint8_t WebPLogTable8bit[256];
-static WEBP_INLINE int WebPLog2FloorC(uint32_t n) {
- int log_value = 0;
- while (n >= 256) {
- log_value += 8;
- n >>= 8;
- }
- return log_value + WebPLogTable8bit[n];
-}
-
-static WEBP_INLINE int BitsLog2Floor(uint32_t n) { return WebPLog2FloorC(n); }
-
-static WEBP_INLINE int BitsCtz(uint32_t n) {
- int i;
- for (i = 0; i < 32; ++i, n >>= 1) {
- if (n & 1) return i;
- }
- return 32;
-}
-
-#endif
-
-//------------------------------------------------------------------------------
-// Pixel copying.
-
-struct WebPPicture;
-
-// Copy width x height pixels from 'src' to 'dst' honoring the strides.
-WEBP_EXTERN void WebPCopyPlane(const uint8_t* src, int src_stride,
- uint8_t* dst, int dst_stride,
- int width, int height);
-
-// Copy ARGB pixels from 'src' to 'dst' honoring strides. 'src' and 'dst' are
-// assumed to be already allocated and using ARGB data.
-WEBP_EXTERN void WebPCopyPixels(const struct WebPPicture* const src,
- struct WebPPicture* const dst);
-
-//------------------------------------------------------------------------------
-// Unique colors.
-
-// Returns count of unique colors in 'pic', assuming pic->use_argb is true.
-// If the unique color count is more than MAX_PALETTE_SIZE, returns
-// MAX_PALETTE_SIZE+1.
-// If 'palette' is not NULL and number of unique colors is less than or equal to
-// MAX_PALETTE_SIZE, also outputs the actual unique colors into 'palette'.
-// Note: 'palette' is assumed to be an array already allocated with at least
-// MAX_PALETTE_SIZE elements.
-WEBP_EXTERN int WebPGetColorPalette(const struct WebPPicture* const pic,
- uint32_t* const palette);
-
-//------------------------------------------------------------------------------
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // WEBP_UTILS_UTILS_H_
diff --git a/contrib/libs/libwebp/utils/webputils/ya.make b/contrib/libs/libwebp/utils/webputils/ya.make
deleted file mode 100644
index 23dcbfe3b9..0000000000
--- a/contrib/libs/libwebp/utils/webputils/ya.make
+++ /dev/null
@@ -1,36 +0,0 @@
-# Generated by devtools/yamaker.
-
-LIBRARY()
-
-WITHOUT_LICENSE_TEXTS()
-
-VERSION(1.2.2)
-
-LICENSE(BSD-3-Clause)
-
-PEERDIR(
- contrib/libs/libwebp/utils/webputilsdecode
-)
-
-ADDINCL(
- contrib/libs/libwebp/utils
- contrib/libs/libwebp/webp
-)
-
-NO_COMPILER_WARNINGS()
-
-NO_RUNTIME()
-
-CFLAGS(
- -DHAVE_CONFIG_H
-)
-
-SRCDIR(contrib/libs/libwebp/utils)
-
-SRCS(
- bit_writer_utils.c
- huffman_encode_utils.c
- quant_levels_utils.c
-)
-
-END()
diff --git a/contrib/libs/libwebp/utils/webputilsdecode/ya.make b/contrib/libs/libwebp/utils/webputilsdecode/ya.make
deleted file mode 100644
index 724adbe840..0000000000
--- a/contrib/libs/libwebp/utils/webputilsdecode/ya.make
+++ /dev/null
@@ -1,38 +0,0 @@
-# Generated by devtools/yamaker.
-
-LIBRARY()
-
-WITHOUT_LICENSE_TEXTS()
-
-VERSION(1.2.2)
-
-LICENSE(BSD-3-Clause)
-
-ADDINCL(
- contrib/libs/libwebp/utils
- contrib/libs/libwebp/webp
-)
-
-NO_COMPILER_WARNINGS()
-
-NO_RUNTIME()
-
-CFLAGS(
- -DHAVE_CONFIG_H
-)
-
-SRCDIR(contrib/libs/libwebp/utils)
-
-SRCS(
- bit_reader_utils.c
- color_cache_utils.c
- filters_utils.c
- huffman_utils.c
- quant_levels_dec_utils.c
- random_utils.c
- rescaler_utils.c
- thread_utils.c
- utils.c
-)
-
-END()
diff --git a/contrib/libs/libwebp/webp/config-android.h b/contrib/libs/libwebp/webp/config-android.h
deleted file mode 100644
index 5268d8fc01..0000000000
--- a/contrib/libs/libwebp/webp/config-android.h
+++ /dev/null
@@ -1,5 +0,0 @@
-#pragma once
-
-#include "config-linux.h"
-
-#define HAVE_CPU_FEATURES_H
diff --git a/contrib/libs/libwebp/webp/config-linux.h b/contrib/libs/libwebp/webp/config-linux.h
deleted file mode 100644
index f7f2284ec0..0000000000
--- a/contrib/libs/libwebp/webp/config-linux.h
+++ /dev/null
@@ -1,152 +0,0 @@
-/* src/webp/config.h. Generated from config.h.in by configure. */
-/* src/webp/config.h.in. Generated from configure.ac by autoheader. */
-
-/* Define if building universal (internal helper macro) */
-/* #undef AC_APPLE_UNIVERSAL_BUILD */
-
-/* Set to 1 if __builtin_bswap16 is available */
-#define HAVE_BUILTIN_BSWAP16 1
-
-/* Set to 1 if __builtin_bswap32 is available */
-#define HAVE_BUILTIN_BSWAP32 1
-
-/* Set to 1 if __builtin_bswap64 is available */
-#define HAVE_BUILTIN_BSWAP64 1
-
-/* Define to 1 if you have the <cpu-features.h> header file. */
-/* #undef HAVE_CPU_FEATURES_H */
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#define HAVE_DLFCN_H 1
-
-/* Define to 1 if you have the <GLUT/glut.h> header file. */
-/* #undef HAVE_GLUT_GLUT_H */
-
-/* Define to 1 if you have the <GL/glut.h> header file. */
-/* #undef HAVE_GL_GLUT_H */
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#define HAVE_INTTYPES_H 1
-
-/* Define to 1 if you have the <OpenGL/glut.h> header file. */
-/* #undef HAVE_OPENGL_GLUT_H */
-
-/* Have PTHREAD_PRIO_INHERIT. */
-#define HAVE_PTHREAD_PRIO_INHERIT 1
-
-/* Define to 1 if you have the <shlwapi.h> header file. */
-/* #undef HAVE_SHLWAPI_H */
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#define HAVE_STDINT_H 1
-
-/* Define to 1 if you have the <stdio.h> header file. */
-#define HAVE_STDIO_H 1
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#define HAVE_STDLIB_H 1
-
-/* Define to 1 if you have the <strings.h> header file. */
-#define HAVE_STRINGS_H 1
-
-/* Define to 1 if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#define HAVE_SYS_STAT_H 1
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#define HAVE_SYS_TYPES_H 1
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#define HAVE_UNISTD_H 1
-
-/* Define to 1 if you have the <wincodec.h> header file. */
-/* #undef HAVE_WINCODEC_H */
-
-/* Define to 1 if you have the <windows.h> header file. */
-/* #undef HAVE_WINDOWS_H */
-
-/* Define to the sub-directory where libtool stores uninstalled libraries. */
-#define LT_OBJDIR ".libs/"
-
-/* Name of package */
-#define PACKAGE "libwebp"
-
-/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT "https://bugs.chromium.org/p/webp"
-
-/* Define to the full name of this package. */
-#define PACKAGE_NAME "libwebp"
-
-/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "libwebp 1.2.2"
-
-/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME "libwebp"
-
-/* Define to the home page for this package. */
-#define PACKAGE_URL "https://developers.google.com/speed/webp"
-
-/* Define to the version of this package. */
-#define PACKAGE_VERSION "1.2.2"
-
-/* Define to necessary symbol if this constant uses a non-standard name on
- your system. */
-/* #undef PTHREAD_CREATE_JOINABLE */
-
-/* Define to 1 if all of the C90 standard headers exist (not just the ones
- required in a freestanding environment). This macro is provided for
- backward compatibility; new code need not use it. */
-#define STDC_HEADERS 1
-
-/* Version number of package */
-#define VERSION "1.2.2"
-
-/* Set to 1 if GIF library is installed */
-#define WEBP_HAVE_GIF 1
-
-/* Set to 1 if OpenGL is supported */
-/* #undef WEBP_HAVE_GL */
-
-/* Set to 1 if JPEG library is installed */
-#define WEBP_HAVE_JPEG 1
-
-/* Set to 1 if NEON is supported */
-/* #undef WEBP_HAVE_NEON */
-
-/* Set to 1 if runtime detection of NEON is enabled */
-/* #undef WEBP_HAVE_NEON_RTCD */
-
-/* Set to 1 if PNG library is installed */
-#define WEBP_HAVE_PNG 1
-
-/* Set to 1 if SDL library is installed */
-/* #undef WEBP_HAVE_SDL */
-
-/* Set to 1 if SSE2 is supported */
-#define WEBP_HAVE_SSE2 1
-
-/* Set to 1 if SSE4.1 is supported */
-#define WEBP_HAVE_SSE41 1
-
-/* Set to 1 if TIFF library is installed */
-#define WEBP_HAVE_TIFF 1
-
-/* Enable near lossless encoding */
-#define WEBP_NEAR_LOSSLESS 1
-
-/* Undefine this to disable thread support. */
-#define WEBP_USE_THREAD 1
-
-/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
- significant byte first (like Motorola and SPARC, unlike Intel). */
-#if defined AC_APPLE_UNIVERSAL_BUILD
-# if defined __BIG_ENDIAN__
-# define WORDS_BIGENDIAN 1
-# endif
-#else
-# ifndef WORDS_BIGENDIAN
-/* # undef WORDS_BIGENDIAN */
-# endif
-#endif
diff --git a/contrib/libs/libwebp/webp/config.h b/contrib/libs/libwebp/webp/config.h
deleted file mode 100644
index 46f6316a05..0000000000
--- a/contrib/libs/libwebp/webp/config.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#pragma once
-
-#if defined(__ANDROID__)
-# include "config-android.h"
-#else
-# include "config-linux.h"
-#endif
diff --git a/contrib/libs/libwebp/webp/decode.h b/contrib/libs/libwebp/webp/decode.h
deleted file mode 100644
index d98247509a..0000000000
--- a/contrib/libs/libwebp/webp/decode.h
+++ /dev/null
@@ -1,503 +0,0 @@
-// Copyright 2010 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Main decoding functions for WebP images.
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#ifndef WEBP_WEBP_DECODE_H_
-#define WEBP_WEBP_DECODE_H_
-
-#include "./types.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define WEBP_DECODER_ABI_VERSION 0x0209 // MAJOR(8b) + MINOR(8b)
-
-// Note: forward declaring enumerations is not allowed in (strict) C and C++,
-// the types are left here for reference.
-// typedef enum VP8StatusCode VP8StatusCode;
-// typedef enum WEBP_CSP_MODE WEBP_CSP_MODE;
-typedef struct WebPRGBABuffer WebPRGBABuffer;
-typedef struct WebPYUVABuffer WebPYUVABuffer;
-typedef struct WebPDecBuffer WebPDecBuffer;
-typedef struct WebPIDecoder WebPIDecoder;
-typedef struct WebPBitstreamFeatures WebPBitstreamFeatures;
-typedef struct WebPDecoderOptions WebPDecoderOptions;
-typedef struct WebPDecoderConfig WebPDecoderConfig;
-
-// Return the decoder's version number, packed in hexadecimal using 8bits for
-// each of major/minor/revision. E.g: v2.5.7 is 0x020507.
-WEBP_EXTERN int WebPGetDecoderVersion(void);
-
-// Retrieve basic header information: width, height.
-// This function will also validate the header, returning true on success,
-// false otherwise. '*width' and '*height' are only valid on successful return.
-// Pointers 'width' and 'height' can be passed NULL if deemed irrelevant.
-// Note: The following chunk sequences (before the raw VP8/VP8L data) are
-// considered valid by this function:
-// RIFF + VP8(L)
-// RIFF + VP8X + (optional chunks) + VP8(L)
-// ALPH + VP8 <-- Not a valid WebP format: only allowed for internal purpose.
-// VP8(L) <-- Not a valid WebP format: only allowed for internal purpose.
-WEBP_EXTERN int WebPGetInfo(const uint8_t* data, size_t data_size,
- int* width, int* height);
-
-// Decodes WebP images pointed to by 'data' and returns RGBA samples, along
-// with the dimensions in *width and *height. The ordering of samples in
-// memory is R, G, B, A, R, G, B, A... in scan order (endian-independent).
-// The returned pointer should be deleted calling WebPFree().
-// Returns NULL in case of error.
-WEBP_EXTERN uint8_t* WebPDecodeRGBA(const uint8_t* data, size_t data_size,
- int* width, int* height);
-
-// Same as WebPDecodeRGBA, but returning A, R, G, B, A, R, G, B... ordered data.
-WEBP_EXTERN uint8_t* WebPDecodeARGB(const uint8_t* data, size_t data_size,
- int* width, int* height);
-
-// Same as WebPDecodeRGBA, but returning B, G, R, A, B, G, R, A... ordered data.
-WEBP_EXTERN uint8_t* WebPDecodeBGRA(const uint8_t* data, size_t data_size,
- int* width, int* height);
-
-// Same as WebPDecodeRGBA, but returning R, G, B, R, G, B... ordered data.
-// If the bitstream contains transparency, it is ignored.
-WEBP_EXTERN uint8_t* WebPDecodeRGB(const uint8_t* data, size_t data_size,
- int* width, int* height);
-
-// Same as WebPDecodeRGB, but returning B, G, R, B, G, R... ordered data.
-WEBP_EXTERN uint8_t* WebPDecodeBGR(const uint8_t* data, size_t data_size,
- int* width, int* height);
-
-
-// Decode WebP images pointed to by 'data' to Y'UV format(*). The pointer
-// returned is the Y samples buffer. Upon return, *u and *v will point to
-// the U and V chroma data. These U and V buffers need NOT be passed to
-// WebPFree(), unlike the returned Y luma one. The dimension of the U and V
-// planes are both (*width + 1) / 2 and (*height + 1)/ 2.
-// Upon return, the Y buffer has a stride returned as '*stride', while U and V
-// have a common stride returned as '*uv_stride'.
-// Return NULL in case of error.
-// (*) Also named Y'CbCr. See: https://en.wikipedia.org/wiki/YCbCr
-WEBP_EXTERN uint8_t* WebPDecodeYUV(const uint8_t* data, size_t data_size,
- int* width, int* height,
- uint8_t** u, uint8_t** v,
- int* stride, int* uv_stride);
-
-// These five functions are variants of the above ones, that decode the image
-// directly into a pre-allocated buffer 'output_buffer'. The maximum storage
-// available in this buffer is indicated by 'output_buffer_size'. If this
-// storage is not sufficient (or an error occurred), NULL is returned.
-// Otherwise, output_buffer is returned, for convenience.
-// The parameter 'output_stride' specifies the distance (in bytes)
-// between scanlines. Hence, output_buffer_size is expected to be at least
-// output_stride x picture-height.
-WEBP_EXTERN uint8_t* WebPDecodeRGBAInto(
- const uint8_t* data, size_t data_size,
- uint8_t* output_buffer, size_t output_buffer_size, int output_stride);
-WEBP_EXTERN uint8_t* WebPDecodeARGBInto(
- const uint8_t* data, size_t data_size,
- uint8_t* output_buffer, size_t output_buffer_size, int output_stride);
-WEBP_EXTERN uint8_t* WebPDecodeBGRAInto(
- const uint8_t* data, size_t data_size,
- uint8_t* output_buffer, size_t output_buffer_size, int output_stride);
-
-// RGB and BGR variants. Here too the transparency information, if present,
-// will be dropped and ignored.
-WEBP_EXTERN uint8_t* WebPDecodeRGBInto(
- const uint8_t* data, size_t data_size,
- uint8_t* output_buffer, size_t output_buffer_size, int output_stride);
-WEBP_EXTERN uint8_t* WebPDecodeBGRInto(
- const uint8_t* data, size_t data_size,
- uint8_t* output_buffer, size_t output_buffer_size, int output_stride);
-
-// WebPDecodeYUVInto() is a variant of WebPDecodeYUV() that operates directly
-// into pre-allocated luma/chroma plane buffers. This function requires the
-// strides to be passed: one for the luma plane and one for each of the
-// chroma ones. The size of each plane buffer is passed as 'luma_size',
-// 'u_size' and 'v_size' respectively.
-// Pointer to the luma plane ('*luma') is returned or NULL if an error occurred
-// during decoding (or because some buffers were found to be too small).
-WEBP_EXTERN uint8_t* WebPDecodeYUVInto(
- const uint8_t* data, size_t data_size,
- uint8_t* luma, size_t luma_size, int luma_stride,
- uint8_t* u, size_t u_size, int u_stride,
- uint8_t* v, size_t v_size, int v_stride);
-
-//------------------------------------------------------------------------------
-// Output colorspaces and buffer
-
-// Colorspaces
-// Note: the naming describes the byte-ordering of packed samples in memory.
-// For instance, MODE_BGRA relates to samples ordered as B,G,R,A,B,G,R,A,...
-// Non-capital names (e.g.:MODE_Argb) relates to pre-multiplied RGB channels.
-// RGBA-4444 and RGB-565 colorspaces are represented by following byte-order:
-// RGBA-4444: [r3 r2 r1 r0 g3 g2 g1 g0], [b3 b2 b1 b0 a3 a2 a1 a0], ...
-// RGB-565: [r4 r3 r2 r1 r0 g5 g4 g3], [g2 g1 g0 b4 b3 b2 b1 b0], ...
-// In the case WEBP_SWAP_16BITS_CSP is defined, the bytes are swapped for
-// these two modes:
-// RGBA-4444: [b3 b2 b1 b0 a3 a2 a1 a0], [r3 r2 r1 r0 g3 g2 g1 g0], ...
-// RGB-565: [g2 g1 g0 b4 b3 b2 b1 b0], [r4 r3 r2 r1 r0 g5 g4 g3], ...
-
-typedef enum WEBP_CSP_MODE {
- MODE_RGB = 0, MODE_RGBA = 1,
- MODE_BGR = 2, MODE_BGRA = 3,
- MODE_ARGB = 4, MODE_RGBA_4444 = 5,
- MODE_RGB_565 = 6,
- // RGB-premultiplied transparent modes (alpha value is preserved)
- MODE_rgbA = 7,
- MODE_bgrA = 8,
- MODE_Argb = 9,
- MODE_rgbA_4444 = 10,
- // YUV modes must come after RGB ones.
- MODE_YUV = 11, MODE_YUVA = 12, // yuv 4:2:0
- MODE_LAST = 13
-} WEBP_CSP_MODE;
-
-// Some useful macros:
-static WEBP_INLINE int WebPIsPremultipliedMode(WEBP_CSP_MODE mode) {
- return (mode == MODE_rgbA || mode == MODE_bgrA || mode == MODE_Argb ||
- mode == MODE_rgbA_4444);
-}
-
-static WEBP_INLINE int WebPIsAlphaMode(WEBP_CSP_MODE mode) {
- return (mode == MODE_RGBA || mode == MODE_BGRA || mode == MODE_ARGB ||
- mode == MODE_RGBA_4444 || mode == MODE_YUVA ||
- WebPIsPremultipliedMode(mode));
-}
-
-static WEBP_INLINE int WebPIsRGBMode(WEBP_CSP_MODE mode) {
- return (mode < MODE_YUV);
-}
-
-//------------------------------------------------------------------------------
-// WebPDecBuffer: Generic structure for describing the output sample buffer.
-
-struct WebPRGBABuffer { // view as RGBA
- uint8_t* rgba; // pointer to RGBA samples
- int stride; // stride in bytes from one scanline to the next.
- size_t size; // total size of the *rgba buffer.
-};
-
-struct WebPYUVABuffer { // view as YUVA
- uint8_t* y, *u, *v, *a; // pointer to luma, chroma U/V, alpha samples
- int y_stride; // luma stride
- int u_stride, v_stride; // chroma strides
- int a_stride; // alpha stride
- size_t y_size; // luma plane size
- size_t u_size, v_size; // chroma planes size
- size_t a_size; // alpha-plane size
-};
-
-// Output buffer
-struct WebPDecBuffer {
- WEBP_CSP_MODE colorspace; // Colorspace.
- int width, height; // Dimensions.
- int is_external_memory; // If non-zero, 'internal_memory' pointer is not
- // used. If value is '2' or more, the external
- // memory is considered 'slow' and multiple
- // read/write will be avoided.
- union {
- WebPRGBABuffer RGBA;
- WebPYUVABuffer YUVA;
- } u; // Nameless union of buffer parameters.
- uint32_t pad[4]; // padding for later use
-
- uint8_t* private_memory; // Internally allocated memory (only when
- // is_external_memory is 0). Should not be used
- // externally, but accessed via the buffer union.
-};
-
-// Internal, version-checked, entry point
-WEBP_EXTERN int WebPInitDecBufferInternal(WebPDecBuffer*, int);
-
-// Initialize the structure as empty. Must be called before any other use.
-// Returns false in case of version mismatch
-static WEBP_INLINE int WebPInitDecBuffer(WebPDecBuffer* buffer) {
- return WebPInitDecBufferInternal(buffer, WEBP_DECODER_ABI_VERSION);
-}
-
-// Free any memory associated with the buffer. Must always be called last.
-// Note: doesn't free the 'buffer' structure itself.
-WEBP_EXTERN void WebPFreeDecBuffer(WebPDecBuffer* buffer);
-
-//------------------------------------------------------------------------------
-// Enumeration of the status codes
-
-typedef enum VP8StatusCode {
- VP8_STATUS_OK = 0,
- VP8_STATUS_OUT_OF_MEMORY,
- VP8_STATUS_INVALID_PARAM,
- VP8_STATUS_BITSTREAM_ERROR,
- VP8_STATUS_UNSUPPORTED_FEATURE,
- VP8_STATUS_SUSPENDED,
- VP8_STATUS_USER_ABORT,
- VP8_STATUS_NOT_ENOUGH_DATA
-} VP8StatusCode;
-
-//------------------------------------------------------------------------------
-// Incremental decoding
-//
-// This API allows streamlined decoding of partial data.
-// Picture can be incrementally decoded as data become available thanks to the
-// WebPIDecoder object. This object can be left in a SUSPENDED state if the
-// picture is only partially decoded, pending additional input.
-// Code example:
-//
-// WebPInitDecBuffer(&output_buffer);
-// output_buffer.colorspace = mode;
-// ...
-// WebPIDecoder* idec = WebPINewDecoder(&output_buffer);
-// while (additional_data_is_available) {
-// // ... (get additional data in some new_data[] buffer)
-// status = WebPIAppend(idec, new_data, new_data_size);
-// if (status != VP8_STATUS_OK && status != VP8_STATUS_SUSPENDED) {
-// break; // an error occurred.
-// }
-//
-// // The above call decodes the current available buffer.
-// // Part of the image can now be refreshed by calling
-// // WebPIDecGetRGB()/WebPIDecGetYUVA() etc.
-// }
-// WebPIDelete(idec);
-
-// Creates a new incremental decoder with the supplied buffer parameter.
-// This output_buffer can be passed NULL, in which case a default output buffer
-// is used (with MODE_RGB). Otherwise, an internal reference to 'output_buffer'
-// is kept, which means that the lifespan of 'output_buffer' must be larger than
-// that of the returned WebPIDecoder object.
-// The supplied 'output_buffer' content MUST NOT be changed between calls to
-// WebPIAppend() or WebPIUpdate() unless 'output_buffer.is_external_memory' is
-// not set to 0. In such a case, it is allowed to modify the pointers, size and
-// stride of output_buffer.u.RGBA or output_buffer.u.YUVA, provided they remain
-// within valid bounds.
-// All other fields of WebPDecBuffer MUST remain constant between calls.
-// Returns NULL if the allocation failed.
-WEBP_EXTERN WebPIDecoder* WebPINewDecoder(WebPDecBuffer* output_buffer);
-
-// This function allocates and initializes an incremental-decoder object, which
-// will output the RGB/A samples specified by 'csp' into a preallocated
-// buffer 'output_buffer'. The size of this buffer is at least
-// 'output_buffer_size' and the stride (distance in bytes between two scanlines)
-// is specified by 'output_stride'.
-// Additionally, output_buffer can be passed NULL in which case the output
-// buffer will be allocated automatically when the decoding starts. The
-// colorspace 'csp' is taken into account for allocating this buffer. All other
-// parameters are ignored.
-// Returns NULL if the allocation failed, or if some parameters are invalid.
-WEBP_EXTERN WebPIDecoder* WebPINewRGB(
- WEBP_CSP_MODE csp,
- uint8_t* output_buffer, size_t output_buffer_size, int output_stride);
-
-// This function allocates and initializes an incremental-decoder object, which
-// will output the raw luma/chroma samples into a preallocated planes if
-// supplied. The luma plane is specified by its pointer 'luma', its size
-// 'luma_size' and its stride 'luma_stride'. Similarly, the chroma-u plane
-// is specified by the 'u', 'u_size' and 'u_stride' parameters, and the chroma-v
-// plane by 'v' and 'v_size'. And same for the alpha-plane. The 'a' pointer
-// can be pass NULL in case one is not interested in the transparency plane.
-// Conversely, 'luma' can be passed NULL if no preallocated planes are supplied.
-// In this case, the output buffer will be automatically allocated (using
-// MODE_YUVA) when decoding starts. All parameters are then ignored.
-// Returns NULL if the allocation failed or if a parameter is invalid.
-WEBP_EXTERN WebPIDecoder* WebPINewYUVA(
- uint8_t* luma, size_t luma_size, int luma_stride,
- uint8_t* u, size_t u_size, int u_stride,
- uint8_t* v, size_t v_size, int v_stride,
- uint8_t* a, size_t a_size, int a_stride);
-
-// Deprecated version of the above, without the alpha plane.
-// Kept for backward compatibility.
-WEBP_EXTERN WebPIDecoder* WebPINewYUV(
- uint8_t* luma, size_t luma_size, int luma_stride,
- uint8_t* u, size_t u_size, int u_stride,
- uint8_t* v, size_t v_size, int v_stride);
-
-// Deletes the WebPIDecoder object and associated memory. Must always be called
-// if WebPINewDecoder, WebPINewRGB or WebPINewYUV succeeded.
-WEBP_EXTERN void WebPIDelete(WebPIDecoder* idec);
-
-// Copies and decodes the next available data. Returns VP8_STATUS_OK when
-// the image is successfully decoded. Returns VP8_STATUS_SUSPENDED when more
-// data is expected. Returns error in other cases.
-WEBP_EXTERN VP8StatusCode WebPIAppend(
- WebPIDecoder* idec, const uint8_t* data, size_t data_size);
-
-// A variant of the above function to be used when data buffer contains
-// partial data from the beginning. In this case data buffer is not copied
-// to the internal memory.
-// Note that the value of the 'data' pointer can change between calls to
-// WebPIUpdate, for instance when the data buffer is resized to fit larger data.
-WEBP_EXTERN VP8StatusCode WebPIUpdate(
- WebPIDecoder* idec, const uint8_t* data, size_t data_size);
-
-// Returns the RGB/A image decoded so far. Returns NULL if output params
-// are not initialized yet. The RGB/A output type corresponds to the colorspace
-// specified during call to WebPINewDecoder() or WebPINewRGB().
-// *last_y is the index of last decoded row in raster scan order. Some pointers
-// (*last_y, *width etc.) can be NULL if corresponding information is not
-// needed. The values in these pointers are only valid on successful (non-NULL)
-// return.
-WEBP_EXTERN uint8_t* WebPIDecGetRGB(
- const WebPIDecoder* idec, int* last_y,
- int* width, int* height, int* stride);
-
-// Same as above function to get a YUVA image. Returns pointer to the luma
-// plane or NULL in case of error. If there is no alpha information
-// the alpha pointer '*a' will be returned NULL.
-WEBP_EXTERN uint8_t* WebPIDecGetYUVA(
- const WebPIDecoder* idec, int* last_y,
- uint8_t** u, uint8_t** v, uint8_t** a,
- int* width, int* height, int* stride, int* uv_stride, int* a_stride);
-
-// Deprecated alpha-less version of WebPIDecGetYUVA(): it will ignore the
-// alpha information (if present). Kept for backward compatibility.
-static WEBP_INLINE uint8_t* WebPIDecGetYUV(
- const WebPIDecoder* idec, int* last_y, uint8_t** u, uint8_t** v,
- int* width, int* height, int* stride, int* uv_stride) {
- return WebPIDecGetYUVA(idec, last_y, u, v, NULL, width, height,
- stride, uv_stride, NULL);
-}
-
-// Generic call to retrieve information about the displayable area.
-// If non NULL, the left/right/width/height pointers are filled with the visible
-// rectangular area so far.
-// Returns NULL in case the incremental decoder object is in an invalid state.
-// Otherwise returns the pointer to the internal representation. This structure
-// is read-only, tied to WebPIDecoder's lifespan and should not be modified.
-WEBP_EXTERN const WebPDecBuffer* WebPIDecodedArea(
- const WebPIDecoder* idec, int* left, int* top, int* width, int* height);
-
-//------------------------------------------------------------------------------
-// Advanced decoding parametrization
-//
-// Code sample for using the advanced decoding API
-/*
- // A) Init a configuration object
- WebPDecoderConfig config;
- CHECK(WebPInitDecoderConfig(&config));
-
- // B) optional: retrieve the bitstream's features.
- CHECK(WebPGetFeatures(data, data_size, &config.input) == VP8_STATUS_OK);
-
- // C) Adjust 'config', if needed
- config.no_fancy_upsampling = 1;
- config.output.colorspace = MODE_BGRA;
- // etc.
-
- // Note that you can also make config.output point to an externally
- // supplied memory buffer, provided it's big enough to store the decoded
- // picture. Otherwise, config.output will just be used to allocate memory
- // and store the decoded picture.
-
- // D) Decode!
- CHECK(WebPDecode(data, data_size, &config) == VP8_STATUS_OK);
-
- // E) Decoded image is now in config.output (and config.output.u.RGBA)
-
- // F) Reclaim memory allocated in config's object. It's safe to call
- // this function even if the memory is external and wasn't allocated
- // by WebPDecode().
- WebPFreeDecBuffer(&config.output);
-*/
-
-// Features gathered from the bitstream
-struct WebPBitstreamFeatures {
- int width; // Width in pixels, as read from the bitstream.
- int height; // Height in pixels, as read from the bitstream.
- int has_alpha; // True if the bitstream contains an alpha channel.
- int has_animation; // True if the bitstream is an animation.
- int format; // 0 = undefined (/mixed), 1 = lossy, 2 = lossless
-
- uint32_t pad[5]; // padding for later use
-};
-
-// Internal, version-checked, entry point
-WEBP_EXTERN VP8StatusCode WebPGetFeaturesInternal(
- const uint8_t*, size_t, WebPBitstreamFeatures*, int);
-
-// Retrieve features from the bitstream. The *features structure is filled
-// with information gathered from the bitstream.
-// Returns VP8_STATUS_OK when the features are successfully retrieved. Returns
-// VP8_STATUS_NOT_ENOUGH_DATA when more data is needed to retrieve the
-// features from headers. Returns error in other cases.
-// Note: The following chunk sequences (before the raw VP8/VP8L data) are
-// considered valid by this function:
-// RIFF + VP8(L)
-// RIFF + VP8X + (optional chunks) + VP8(L)
-// ALPH + VP8 <-- Not a valid WebP format: only allowed for internal purpose.
-// VP8(L) <-- Not a valid WebP format: only allowed for internal purpose.
-static WEBP_INLINE VP8StatusCode WebPGetFeatures(
- const uint8_t* data, size_t data_size,
- WebPBitstreamFeatures* features) {
- return WebPGetFeaturesInternal(data, data_size, features,
- WEBP_DECODER_ABI_VERSION);
-}
-
-// Decoding options
-struct WebPDecoderOptions {
- int bypass_filtering; // if true, skip the in-loop filtering
- int no_fancy_upsampling; // if true, use faster pointwise upsampler
- int use_cropping; // if true, cropping is applied _first_
- int crop_left, crop_top; // top-left position for cropping.
- // Will be snapped to even values.
- int crop_width, crop_height; // dimension of the cropping area
- int use_scaling; // if true, scaling is applied _afterward_
- int scaled_width, scaled_height; // final resolution
- int use_threads; // if true, use multi-threaded decoding
- int dithering_strength; // dithering strength (0=Off, 100=full)
- int flip; // if true, flip output vertically
- int alpha_dithering_strength; // alpha dithering strength in [0..100]
-
- uint32_t pad[5]; // padding for later use
-};
-
-// Main object storing the configuration for advanced decoding.
-struct WebPDecoderConfig {
- WebPBitstreamFeatures input; // Immutable bitstream features (optional)
- WebPDecBuffer output; // Output buffer (can point to external mem)
- WebPDecoderOptions options; // Decoding options
-};
-
-// Internal, version-checked, entry point
-WEBP_EXTERN int WebPInitDecoderConfigInternal(WebPDecoderConfig*, int);
-
-// Initialize the configuration as empty. This function must always be
-// called first, unless WebPGetFeatures() is to be called.
-// Returns false in case of mismatched version.
-static WEBP_INLINE int WebPInitDecoderConfig(WebPDecoderConfig* config) {
- return WebPInitDecoderConfigInternal(config, WEBP_DECODER_ABI_VERSION);
-}
-
-// Instantiate a new incremental decoder object with the requested
-// configuration. The bitstream can be passed using 'data' and 'data_size'
-// parameter, in which case the features will be parsed and stored into
-// config->input. Otherwise, 'data' can be NULL and no parsing will occur.
-// Note that 'config' can be NULL too, in which case a default configuration
-// is used. If 'config' is not NULL, it must outlive the WebPIDecoder object
-// as some references to its fields will be used. No internal copy of 'config'
-// is made.
-// The return WebPIDecoder object must always be deleted calling WebPIDelete().
-// Returns NULL in case of error (and config->status will then reflect
-// the error condition, if available).
-WEBP_EXTERN WebPIDecoder* WebPIDecode(const uint8_t* data, size_t data_size,
- WebPDecoderConfig* config);
-
-// Non-incremental version. This version decodes the full data at once, taking
-// 'config' into account. Returns decoding status (which should be VP8_STATUS_OK
-// if the decoding was successful). Note that 'config' cannot be NULL.
-WEBP_EXTERN VP8StatusCode WebPDecode(const uint8_t* data, size_t data_size,
- WebPDecoderConfig* config);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // WEBP_WEBP_DECODE_H_
diff --git a/contrib/libs/libwebp/webp/demux.h b/contrib/libs/libwebp/webp/demux.h
deleted file mode 100644
index 846eeb15a9..0000000000
--- a/contrib/libs/libwebp/webp/demux.h
+++ /dev/null
@@ -1,363 +0,0 @@
-// Copyright 2012 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Demux API.
-// Enables extraction of image and extended format data from WebP files.
-
-// Code Example: Demuxing WebP data to extract all the frames, ICC profile
-// and EXIF/XMP metadata.
-/*
- WebPDemuxer* demux = WebPDemux(&webp_data);
-
- uint32_t width = WebPDemuxGetI(demux, WEBP_FF_CANVAS_WIDTH);
- uint32_t height = WebPDemuxGetI(demux, WEBP_FF_CANVAS_HEIGHT);
- // ... (Get information about the features present in the WebP file).
- uint32_t flags = WebPDemuxGetI(demux, WEBP_FF_FORMAT_FLAGS);
-
- // ... (Iterate over all frames).
- WebPIterator iter;
- if (WebPDemuxGetFrame(demux, 1, &iter)) {
- do {
- // ... (Consume 'iter'; e.g. Decode 'iter.fragment' with WebPDecode(),
- // ... and get other frame properties like width, height, offsets etc.
- // ... see 'struct WebPIterator' below for more info).
- } while (WebPDemuxNextFrame(&iter));
- WebPDemuxReleaseIterator(&iter);
- }
-
- // ... (Extract metadata).
- WebPChunkIterator chunk_iter;
- if (flags & ICCP_FLAG) WebPDemuxGetChunk(demux, "ICCP", 1, &chunk_iter);
- // ... (Consume the ICC profile in 'chunk_iter.chunk').
- WebPDemuxReleaseChunkIterator(&chunk_iter);
- if (flags & EXIF_FLAG) WebPDemuxGetChunk(demux, "EXIF", 1, &chunk_iter);
- // ... (Consume the EXIF metadata in 'chunk_iter.chunk').
- WebPDemuxReleaseChunkIterator(&chunk_iter);
- if (flags & XMP_FLAG) WebPDemuxGetChunk(demux, "XMP ", 1, &chunk_iter);
- // ... (Consume the XMP metadata in 'chunk_iter.chunk').
- WebPDemuxReleaseChunkIterator(&chunk_iter);
- WebPDemuxDelete(demux);
-*/
-
-#ifndef WEBP_WEBP_DEMUX_H_
-#define WEBP_WEBP_DEMUX_H_
-
-#include "./decode.h" // for WEBP_CSP_MODE
-#include "./mux_types.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define WEBP_DEMUX_ABI_VERSION 0x0107 // MAJOR(8b) + MINOR(8b)
-
-// Note: forward declaring enumerations is not allowed in (strict) C and C++,
-// the types are left here for reference.
-// typedef enum WebPDemuxState WebPDemuxState;
-// typedef enum WebPFormatFeature WebPFormatFeature;
-typedef struct WebPDemuxer WebPDemuxer;
-typedef struct WebPIterator WebPIterator;
-typedef struct WebPChunkIterator WebPChunkIterator;
-typedef struct WebPAnimInfo WebPAnimInfo;
-typedef struct WebPAnimDecoderOptions WebPAnimDecoderOptions;
-
-//------------------------------------------------------------------------------
-
-// Returns the version number of the demux library, packed in hexadecimal using
-// 8bits for each of major/minor/revision. E.g: v2.5.7 is 0x020507.
-WEBP_EXTERN int WebPGetDemuxVersion(void);
-
-//------------------------------------------------------------------------------
-// Life of a Demux object
-
-typedef enum WebPDemuxState {
- WEBP_DEMUX_PARSE_ERROR = -1, // An error occurred while parsing.
- WEBP_DEMUX_PARSING_HEADER = 0, // Not enough data to parse full header.
- WEBP_DEMUX_PARSED_HEADER = 1, // Header parsing complete,
- // data may be available.
- WEBP_DEMUX_DONE = 2 // Entire file has been parsed.
-} WebPDemuxState;
-
-// Internal, version-checked, entry point
-WEBP_EXTERN WebPDemuxer* WebPDemuxInternal(
- const WebPData*, int, WebPDemuxState*, int);
-
-// Parses the full WebP file given by 'data'. For single images the WebP file
-// header alone or the file header and the chunk header may be absent.
-// Returns a WebPDemuxer object on successful parse, NULL otherwise.
-static WEBP_INLINE WebPDemuxer* WebPDemux(const WebPData* data) {
- return WebPDemuxInternal(data, 0, NULL, WEBP_DEMUX_ABI_VERSION);
-}
-
-// Parses the possibly incomplete WebP file given by 'data'.
-// If 'state' is non-NULL it will be set to indicate the status of the demuxer.
-// Returns NULL in case of error or if there isn't enough data to start parsing;
-// and a WebPDemuxer object on successful parse.
-// Note that WebPDemuxer keeps internal pointers to 'data' memory segment.
-// If this data is volatile, the demuxer object should be deleted (by calling
-// WebPDemuxDelete()) and WebPDemuxPartial() called again on the new data.
-// This is usually an inexpensive operation.
-static WEBP_INLINE WebPDemuxer* WebPDemuxPartial(
- const WebPData* data, WebPDemuxState* state) {
- return WebPDemuxInternal(data, 1, state, WEBP_DEMUX_ABI_VERSION);
-}
-
-// Frees memory associated with 'dmux'.
-WEBP_EXTERN void WebPDemuxDelete(WebPDemuxer* dmux);
-
-//------------------------------------------------------------------------------
-// Data/information extraction.
-
-typedef enum WebPFormatFeature {
- WEBP_FF_FORMAT_FLAGS, // bit-wise combination of WebPFeatureFlags
- // corresponding to the 'VP8X' chunk (if present).
- WEBP_FF_CANVAS_WIDTH,
- WEBP_FF_CANVAS_HEIGHT,
- WEBP_FF_LOOP_COUNT, // only relevant for animated file
- WEBP_FF_BACKGROUND_COLOR, // idem.
- WEBP_FF_FRAME_COUNT // Number of frames present in the demux object.
- // In case of a partial demux, this is the number
- // of frames seen so far, with the last frame
- // possibly being partial.
-} WebPFormatFeature;
-
-// Get the 'feature' value from the 'dmux'.
-// NOTE: values are only valid if WebPDemux() was used or WebPDemuxPartial()
-// returned a state > WEBP_DEMUX_PARSING_HEADER.
-// If 'feature' is WEBP_FF_FORMAT_FLAGS, the returned value is a bit-wise
-// combination of WebPFeatureFlags values.
-// If 'feature' is WEBP_FF_LOOP_COUNT, WEBP_FF_BACKGROUND_COLOR, the returned
-// value is only meaningful if the bitstream is animated.
-WEBP_EXTERN uint32_t WebPDemuxGetI(
- const WebPDemuxer* dmux, WebPFormatFeature feature);
-
-//------------------------------------------------------------------------------
-// Frame iteration.
-
-struct WebPIterator {
- int frame_num;
- int num_frames; // equivalent to WEBP_FF_FRAME_COUNT.
- int x_offset, y_offset; // offset relative to the canvas.
- int width, height; // dimensions of this frame.
- int duration; // display duration in milliseconds.
- WebPMuxAnimDispose dispose_method; // dispose method for the frame.
- int complete; // true if 'fragment' contains a full frame. partial images
- // may still be decoded with the WebP incremental decoder.
- WebPData fragment; // The frame given by 'frame_num'. Note for historical
- // reasons this is called a fragment.
- int has_alpha; // True if the frame contains transparency.
- WebPMuxAnimBlend blend_method; // Blend operation for the frame.
-
- uint32_t pad[2]; // padding for later use.
- void* private_; // for internal use only.
-};
-
-// Retrieves frame 'frame_number' from 'dmux'.
-// 'iter->fragment' points to the frame on return from this function.
-// Setting 'frame_number' equal to 0 will return the last frame of the image.
-// Returns false if 'dmux' is NULL or frame 'frame_number' is not present.
-// Call WebPDemuxReleaseIterator() when use of the iterator is complete.
-// NOTE: 'dmux' must persist for the lifetime of 'iter'.
-WEBP_EXTERN int WebPDemuxGetFrame(
- const WebPDemuxer* dmux, int frame_number, WebPIterator* iter);
-
-// Sets 'iter->fragment' to point to the next ('iter->frame_num' + 1) or
-// previous ('iter->frame_num' - 1) frame. These functions do not loop.
-// Returns true on success, false otherwise.
-WEBP_EXTERN int WebPDemuxNextFrame(WebPIterator* iter);
-WEBP_EXTERN int WebPDemuxPrevFrame(WebPIterator* iter);
-
-// Releases any memory associated with 'iter'.
-// Must be called before any subsequent calls to WebPDemuxGetChunk() on the same
-// iter. Also, must be called before destroying the associated WebPDemuxer with
-// WebPDemuxDelete().
-WEBP_EXTERN void WebPDemuxReleaseIterator(WebPIterator* iter);
-
-//------------------------------------------------------------------------------
-// Chunk iteration.
-
-struct WebPChunkIterator {
- // The current and total number of chunks with the fourcc given to
- // WebPDemuxGetChunk().
- int chunk_num;
- int num_chunks;
- WebPData chunk; // The payload of the chunk.
-
- uint32_t pad[6]; // padding for later use
- void* private_;
-};
-
-// Retrieves the 'chunk_number' instance of the chunk with id 'fourcc' from
-// 'dmux'.
-// 'fourcc' is a character array containing the fourcc of the chunk to return,
-// e.g., "ICCP", "XMP ", "EXIF", etc.
-// Setting 'chunk_number' equal to 0 will return the last chunk in a set.
-// Returns true if the chunk is found, false otherwise. Image related chunk
-// payloads are accessed through WebPDemuxGetFrame() and related functions.
-// Call WebPDemuxReleaseChunkIterator() when use of the iterator is complete.
-// NOTE: 'dmux' must persist for the lifetime of the iterator.
-WEBP_EXTERN int WebPDemuxGetChunk(const WebPDemuxer* dmux,
- const char fourcc[4], int chunk_number,
- WebPChunkIterator* iter);
-
-// Sets 'iter->chunk' to point to the next ('iter->chunk_num' + 1) or previous
-// ('iter->chunk_num' - 1) chunk. These functions do not loop.
-// Returns true on success, false otherwise.
-WEBP_EXTERN int WebPDemuxNextChunk(WebPChunkIterator* iter);
-WEBP_EXTERN int WebPDemuxPrevChunk(WebPChunkIterator* iter);
-
-// Releases any memory associated with 'iter'.
-// Must be called before destroying the associated WebPDemuxer with
-// WebPDemuxDelete().
-WEBP_EXTERN void WebPDemuxReleaseChunkIterator(WebPChunkIterator* iter);
-
-//------------------------------------------------------------------------------
-// WebPAnimDecoder API
-//
-// This API allows decoding (possibly) animated WebP images.
-//
-// Code Example:
-/*
- WebPAnimDecoderOptions dec_options;
- WebPAnimDecoderOptionsInit(&dec_options);
- // Tune 'dec_options' as needed.
- WebPAnimDecoder* dec = WebPAnimDecoderNew(webp_data, &dec_options);
- WebPAnimInfo anim_info;
- WebPAnimDecoderGetInfo(dec, &anim_info);
- for (uint32_t i = 0; i < anim_info.loop_count; ++i) {
- while (WebPAnimDecoderHasMoreFrames(dec)) {
- uint8_t* buf;
- int timestamp;
- WebPAnimDecoderGetNext(dec, &buf, &timestamp);
- // ... (Render 'buf' based on 'timestamp').
- // ... (Do NOT free 'buf', as it is owned by 'dec').
- }
- WebPAnimDecoderReset(dec);
- }
- const WebPDemuxer* demuxer = WebPAnimDecoderGetDemuxer(dec);
- // ... (Do something using 'demuxer'; e.g. get EXIF/XMP/ICC data).
- WebPAnimDecoderDelete(dec);
-*/
-
-typedef struct WebPAnimDecoder WebPAnimDecoder; // Main opaque object.
-
-// Global options.
-struct WebPAnimDecoderOptions {
- // Output colorspace. Only the following modes are supported:
- // MODE_RGBA, MODE_BGRA, MODE_rgbA and MODE_bgrA.
- WEBP_CSP_MODE color_mode;
- int use_threads; // If true, use multi-threaded decoding.
- uint32_t padding[7]; // Padding for later use.
-};
-
-// Internal, version-checked, entry point.
-WEBP_EXTERN int WebPAnimDecoderOptionsInitInternal(
- WebPAnimDecoderOptions*, int);
-
-// Should always be called, to initialize a fresh WebPAnimDecoderOptions
-// structure before modification. Returns false in case of version mismatch.
-// WebPAnimDecoderOptionsInit() must have succeeded before using the
-// 'dec_options' object.
-static WEBP_INLINE int WebPAnimDecoderOptionsInit(
- WebPAnimDecoderOptions* dec_options) {
- return WebPAnimDecoderOptionsInitInternal(dec_options,
- WEBP_DEMUX_ABI_VERSION);
-}
-
-// Internal, version-checked, entry point.
-WEBP_EXTERN WebPAnimDecoder* WebPAnimDecoderNewInternal(
- const WebPData*, const WebPAnimDecoderOptions*, int);
-
-// Creates and initializes a WebPAnimDecoder object.
-// Parameters:
-// webp_data - (in) WebP bitstream. This should remain unchanged during the
-// lifetime of the output WebPAnimDecoder object.
-// dec_options - (in) decoding options. Can be passed NULL to choose
-// reasonable defaults (in particular, color mode MODE_RGBA
-// will be picked).
-// Returns:
-// A pointer to the newly created WebPAnimDecoder object, or NULL in case of
-// parsing error, invalid option or memory error.
-static WEBP_INLINE WebPAnimDecoder* WebPAnimDecoderNew(
- const WebPData* webp_data, const WebPAnimDecoderOptions* dec_options) {
- return WebPAnimDecoderNewInternal(webp_data, dec_options,
- WEBP_DEMUX_ABI_VERSION);
-}
-
-// Global information about the animation..
-struct WebPAnimInfo {
- uint32_t canvas_width;
- uint32_t canvas_height;
- uint32_t loop_count;
- uint32_t bgcolor;
- uint32_t frame_count;
- uint32_t pad[4]; // padding for later use
-};
-
-// Get global information about the animation.
-// Parameters:
-// dec - (in) decoder instance to get information from.
-// info - (out) global information fetched from the animation.
-// Returns:
-// True on success.
-WEBP_EXTERN int WebPAnimDecoderGetInfo(const WebPAnimDecoder* dec,
- WebPAnimInfo* info);
-
-// Fetch the next frame from 'dec' based on options supplied to
-// WebPAnimDecoderNew(). This will be a fully reconstructed canvas of size
-// 'canvas_width * 4 * canvas_height', and not just the frame sub-rectangle. The
-// returned buffer 'buf' is valid only until the next call to
-// WebPAnimDecoderGetNext(), WebPAnimDecoderReset() or WebPAnimDecoderDelete().
-// Parameters:
-// dec - (in/out) decoder instance from which the next frame is to be fetched.
-// buf - (out) decoded frame.
-// timestamp - (out) timestamp of the frame in milliseconds.
-// Returns:
-// False if any of the arguments are NULL, or if there is a parsing or
-// decoding error, or if there are no more frames. Otherwise, returns true.
-WEBP_EXTERN int WebPAnimDecoderGetNext(WebPAnimDecoder* dec,
- uint8_t** buf, int* timestamp);
-
-// Check if there are more frames left to decode.
-// Parameters:
-// dec - (in) decoder instance to be checked.
-// Returns:
-// True if 'dec' is not NULL and some frames are yet to be decoded.
-// Otherwise, returns false.
-WEBP_EXTERN int WebPAnimDecoderHasMoreFrames(const WebPAnimDecoder* dec);
-
-// Resets the WebPAnimDecoder object, so that next call to
-// WebPAnimDecoderGetNext() will restart decoding from 1st frame. This would be
-// helpful when all frames need to be decoded multiple times (e.g.
-// info.loop_count times) without destroying and recreating the 'dec' object.
-// Parameters:
-// dec - (in/out) decoder instance to be reset
-WEBP_EXTERN void WebPAnimDecoderReset(WebPAnimDecoder* dec);
-
-// Grab the internal demuxer object.
-// Getting the demuxer object can be useful if one wants to use operations only
-// available through demuxer; e.g. to get XMP/EXIF/ICC metadata. The returned
-// demuxer object is owned by 'dec' and is valid only until the next call to
-// WebPAnimDecoderDelete().
-//
-// Parameters:
-// dec - (in) decoder instance from which the demuxer object is to be fetched.
-WEBP_EXTERN const WebPDemuxer* WebPAnimDecoderGetDemuxer(
- const WebPAnimDecoder* dec);
-
-// Deletes the WebPAnimDecoder object.
-// Parameters:
-// dec - (in/out) decoder instance to be deleted
-WEBP_EXTERN void WebPAnimDecoderDelete(WebPAnimDecoder* dec);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // WEBP_WEBP_DEMUX_H_
diff --git a/contrib/libs/libwebp/webp/encode.h b/contrib/libs/libwebp/webp/encode.h
deleted file mode 100644
index b4c599df87..0000000000
--- a/contrib/libs/libwebp/webp/encode.h
+++ /dev/null
@@ -1,552 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// WebP encoder: main interface
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#ifndef WEBP_WEBP_ENCODE_H_
-#define WEBP_WEBP_ENCODE_H_
-
-#include "./types.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define WEBP_ENCODER_ABI_VERSION 0x020f // MAJOR(8b) + MINOR(8b)
-
-// Note: forward declaring enumerations is not allowed in (strict) C and C++,
-// the types are left here for reference.
-// typedef enum WebPImageHint WebPImageHint;
-// typedef enum WebPEncCSP WebPEncCSP;
-// typedef enum WebPPreset WebPPreset;
-// typedef enum WebPEncodingError WebPEncodingError;
-typedef struct WebPConfig WebPConfig;
-typedef struct WebPPicture WebPPicture; // main structure for I/O
-typedef struct WebPAuxStats WebPAuxStats;
-typedef struct WebPMemoryWriter WebPMemoryWriter;
-
-// Return the encoder's version number, packed in hexadecimal using 8bits for
-// each of major/minor/revision. E.g: v2.5.7 is 0x020507.
-WEBP_EXTERN int WebPGetEncoderVersion(void);
-
-//------------------------------------------------------------------------------
-// One-stop-shop call! No questions asked:
-
-// Returns the size of the compressed data (pointed to by *output), or 0 if
-// an error occurred. The compressed data must be released by the caller
-// using the call 'WebPFree(*output)'.
-// These functions compress using the lossy format, and the quality_factor
-// can go from 0 (smaller output, lower quality) to 100 (best quality,
-// larger output).
-WEBP_EXTERN size_t WebPEncodeRGB(const uint8_t* rgb,
- int width, int height, int stride,
- float quality_factor, uint8_t** output);
-WEBP_EXTERN size_t WebPEncodeBGR(const uint8_t* bgr,
- int width, int height, int stride,
- float quality_factor, uint8_t** output);
-WEBP_EXTERN size_t WebPEncodeRGBA(const uint8_t* rgba,
- int width, int height, int stride,
- float quality_factor, uint8_t** output);
-WEBP_EXTERN size_t WebPEncodeBGRA(const uint8_t* bgra,
- int width, int height, int stride,
- float quality_factor, uint8_t** output);
-
-// These functions are the equivalent of the above, but compressing in a
-// lossless manner. Files are usually larger than lossy format, but will
-// not suffer any compression loss.
-// Note these functions, like the lossy versions, use the library's default
-// settings. For lossless this means 'exact' is disabled. RGB values in
-// transparent areas will be modified to improve compression. To avoid this,
-// use WebPEncode() and set WebPConfig::exact to 1.
-WEBP_EXTERN size_t WebPEncodeLosslessRGB(const uint8_t* rgb,
- int width, int height, int stride,
- uint8_t** output);
-WEBP_EXTERN size_t WebPEncodeLosslessBGR(const uint8_t* bgr,
- int width, int height, int stride,
- uint8_t** output);
-WEBP_EXTERN size_t WebPEncodeLosslessRGBA(const uint8_t* rgba,
- int width, int height, int stride,
- uint8_t** output);
-WEBP_EXTERN size_t WebPEncodeLosslessBGRA(const uint8_t* bgra,
- int width, int height, int stride,
- uint8_t** output);
-
-//------------------------------------------------------------------------------
-// Coding parameters
-
-// Image characteristics hint for the underlying encoder.
-typedef enum WebPImageHint {
- WEBP_HINT_DEFAULT = 0, // default preset.
- WEBP_HINT_PICTURE, // digital picture, like portrait, inner shot
- WEBP_HINT_PHOTO, // outdoor photograph, with natural lighting
- WEBP_HINT_GRAPH, // Discrete tone image (graph, map-tile etc).
- WEBP_HINT_LAST
-} WebPImageHint;
-
-// Compression parameters.
-struct WebPConfig {
- int lossless; // Lossless encoding (0=lossy(default), 1=lossless).
- float quality; // between 0 and 100. For lossy, 0 gives the smallest
- // size and 100 the largest. For lossless, this
- // parameter is the amount of effort put into the
- // compression: 0 is the fastest but gives larger
- // files compared to the slowest, but best, 100.
- int method; // quality/speed trade-off (0=fast, 6=slower-better)
-
- WebPImageHint image_hint; // Hint for image type (lossless only for now).
-
- int target_size; // if non-zero, set the desired target size in bytes.
- // Takes precedence over the 'compression' parameter.
- float target_PSNR; // if non-zero, specifies the minimal distortion to
- // try to achieve. Takes precedence over target_size.
- int segments; // maximum number of segments to use, in [1..4]
- int sns_strength; // Spatial Noise Shaping. 0=off, 100=maximum.
- int filter_strength; // range: [0 = off .. 100 = strongest]
- int filter_sharpness; // range: [0 = off .. 7 = least sharp]
- int filter_type; // filtering type: 0 = simple, 1 = strong (only used
- // if filter_strength > 0 or autofilter > 0)
- int autofilter; // Auto adjust filter's strength [0 = off, 1 = on]
- int alpha_compression; // Algorithm for encoding the alpha plane (0 = none,
- // 1 = compressed with WebP lossless). Default is 1.
- int alpha_filtering; // Predictive filtering method for alpha plane.
- // 0: none, 1: fast, 2: best. Default if 1.
- int alpha_quality; // Between 0 (smallest size) and 100 (lossless).
- // Default is 100.
- int pass; // number of entropy-analysis passes (in [1..10]).
-
- int show_compressed; // if true, export the compressed picture back.
- // In-loop filtering is not applied.
- int preprocessing; // preprocessing filter:
- // 0=none, 1=segment-smooth, 2=pseudo-random dithering
- int partitions; // log2(number of token partitions) in [0..3]. Default
- // is set to 0 for easier progressive decoding.
- int partition_limit; // quality degradation allowed to fit the 512k limit
- // on prediction modes coding (0: no degradation,
- // 100: maximum possible degradation).
- int emulate_jpeg_size; // If true, compression parameters will be remapped
- // to better match the expected output size from
- // JPEG compression. Generally, the output size will
- // be similar but the degradation will be lower.
- int thread_level; // If non-zero, try and use multi-threaded encoding.
- int low_memory; // If set, reduce memory usage (but increase CPU use).
-
- int near_lossless; // Near lossless encoding [0 = max loss .. 100 = off
- // (default)].
- int exact; // if non-zero, preserve the exact RGB values under
- // transparent area. Otherwise, discard this invisible
- // RGB information for better compression. The default
- // value is 0.
-
- int use_delta_palette; // reserved for future lossless feature
- int use_sharp_yuv; // if needed, use sharp (and slow) RGB->YUV conversion
-
- int qmin; // minimum permissible quality factor
- int qmax; // maximum permissible quality factor
-};
-
-// Enumerate some predefined settings for WebPConfig, depending on the type
-// of source picture. These presets are used when calling WebPConfigPreset().
-typedef enum WebPPreset {
- WEBP_PRESET_DEFAULT = 0, // default preset.
- WEBP_PRESET_PICTURE, // digital picture, like portrait, inner shot
- WEBP_PRESET_PHOTO, // outdoor photograph, with natural lighting
- WEBP_PRESET_DRAWING, // hand or line drawing, with high-contrast details
- WEBP_PRESET_ICON, // small-sized colorful images
- WEBP_PRESET_TEXT // text-like
-} WebPPreset;
-
-// Internal, version-checked, entry point
-WEBP_EXTERN int WebPConfigInitInternal(WebPConfig*, WebPPreset, float, int);
-
-// Should always be called, to initialize a fresh WebPConfig structure before
-// modification. Returns false in case of version mismatch. WebPConfigInit()
-// must have succeeded before using the 'config' object.
-// Note that the default values are lossless=0 and quality=75.
-static WEBP_INLINE int WebPConfigInit(WebPConfig* config) {
- return WebPConfigInitInternal(config, WEBP_PRESET_DEFAULT, 75.f,
- WEBP_ENCODER_ABI_VERSION);
-}
-
-// This function will initialize the configuration according to a predefined
-// set of parameters (referred to by 'preset') and a given quality factor.
-// This function can be called as a replacement to WebPConfigInit(). Will
-// return false in case of error.
-static WEBP_INLINE int WebPConfigPreset(WebPConfig* config,
- WebPPreset preset, float quality) {
- return WebPConfigInitInternal(config, preset, quality,
- WEBP_ENCODER_ABI_VERSION);
-}
-
-// Activate the lossless compression mode with the desired efficiency level
-// between 0 (fastest, lowest compression) and 9 (slower, best compression).
-// A good default level is '6', providing a fair tradeoff between compression
-// speed and final compressed size.
-// This function will overwrite several fields from config: 'method', 'quality'
-// and 'lossless'. Returns false in case of parameter error.
-WEBP_EXTERN int WebPConfigLosslessPreset(WebPConfig* config, int level);
-
-// Returns true if 'config' is non-NULL and all configuration parameters are
-// within their valid ranges.
-WEBP_EXTERN int WebPValidateConfig(const WebPConfig* config);
-
-//------------------------------------------------------------------------------
-// Input / Output
-// Structure for storing auxiliary statistics.
-
-struct WebPAuxStats {
- int coded_size; // final size
-
- float PSNR[5]; // peak-signal-to-noise ratio for Y/U/V/All/Alpha
- int block_count[3]; // number of intra4/intra16/skipped macroblocks
- int header_bytes[2]; // approximate number of bytes spent for header
- // and mode-partition #0
- int residual_bytes[3][4]; // approximate number of bytes spent for
- // DC/AC/uv coefficients for each (0..3) segments.
- int segment_size[4]; // number of macroblocks in each segments
- int segment_quant[4]; // quantizer values for each segments
- int segment_level[4]; // filtering strength for each segments [0..63]
-
- int alpha_data_size; // size of the transparency data
- int layer_data_size; // size of the enhancement layer data
-
- // lossless encoder statistics
- uint32_t lossless_features; // bit0:predictor bit1:cross-color transform
- // bit2:subtract-green bit3:color indexing
- int histogram_bits; // number of precision bits of histogram
- int transform_bits; // precision bits for transform
- int cache_bits; // number of bits for color cache lookup
- int palette_size; // number of color in palette, if used
- int lossless_size; // final lossless size
- int lossless_hdr_size; // lossless header (transform, huffman etc) size
- int lossless_data_size; // lossless image data size
-
- uint32_t pad[2]; // padding for later use
-};
-
-// Signature for output function. Should return true if writing was successful.
-// data/data_size is the segment of data to write, and 'picture' is for
-// reference (and so one can make use of picture->custom_ptr).
-typedef int (*WebPWriterFunction)(const uint8_t* data, size_t data_size,
- const WebPPicture* picture);
-
-// WebPMemoryWrite: a special WebPWriterFunction that writes to memory using
-// the following WebPMemoryWriter object (to be set as a custom_ptr).
-struct WebPMemoryWriter {
- uint8_t* mem; // final buffer (of size 'max_size', larger than 'size').
- size_t size; // final size
- size_t max_size; // total capacity
- uint32_t pad[1]; // padding for later use
-};
-
-// The following must be called first before any use.
-WEBP_EXTERN void WebPMemoryWriterInit(WebPMemoryWriter* writer);
-
-// The following must be called to deallocate writer->mem memory. The 'writer'
-// object itself is not deallocated.
-WEBP_EXTERN void WebPMemoryWriterClear(WebPMemoryWriter* writer);
-// The custom writer to be used with WebPMemoryWriter as custom_ptr. Upon
-// completion, writer.mem and writer.size will hold the coded data.
-// writer.mem must be freed by calling WebPMemoryWriterClear.
-WEBP_EXTERN int WebPMemoryWrite(const uint8_t* data, size_t data_size,
- const WebPPicture* picture);
-
-// Progress hook, called from time to time to report progress. It can return
-// false to request an abort of the encoding process, or true otherwise if
-// everything is OK.
-typedef int (*WebPProgressHook)(int percent, const WebPPicture* picture);
-
-// Color spaces.
-typedef enum WebPEncCSP {
- // chroma sampling
- WEBP_YUV420 = 0, // 4:2:0
- WEBP_YUV420A = 4, // alpha channel variant
- WEBP_CSP_UV_MASK = 3, // bit-mask to get the UV sampling factors
- WEBP_CSP_ALPHA_BIT = 4 // bit that is set if alpha is present
-} WebPEncCSP;
-
-// Encoding error conditions.
-typedef enum WebPEncodingError {
- VP8_ENC_OK = 0,
- VP8_ENC_ERROR_OUT_OF_MEMORY, // memory error allocating objects
- VP8_ENC_ERROR_BITSTREAM_OUT_OF_MEMORY, // memory error while flushing bits
- VP8_ENC_ERROR_NULL_PARAMETER, // a pointer parameter is NULL
- VP8_ENC_ERROR_INVALID_CONFIGURATION, // configuration is invalid
- VP8_ENC_ERROR_BAD_DIMENSION, // picture has invalid width/height
- VP8_ENC_ERROR_PARTITION0_OVERFLOW, // partition is bigger than 512k
- VP8_ENC_ERROR_PARTITION_OVERFLOW, // partition is bigger than 16M
- VP8_ENC_ERROR_BAD_WRITE, // error while flushing bytes
- VP8_ENC_ERROR_FILE_TOO_BIG, // file is bigger than 4G
- VP8_ENC_ERROR_USER_ABORT, // abort request by user
- VP8_ENC_ERROR_LAST // list terminator. always last.
-} WebPEncodingError;
-
-// maximum width/height allowed (inclusive), in pixels
-#define WEBP_MAX_DIMENSION 16383
-
-// Main exchange structure (input samples, output bytes, statistics)
-//
-// Once WebPPictureInit() has been called, it's ok to make all the INPUT fields
-// (use_argb, y/u/v, argb, ...) point to user-owned data, even if
-// WebPPictureAlloc() has been called. Depending on the value use_argb,
-// it's guaranteed that either *argb or *y/*u/*v content will be kept untouched.
-struct WebPPicture {
- // INPUT
- //////////////
- // Main flag for encoder selecting between ARGB or YUV input.
- // It is recommended to use ARGB input (*argb, argb_stride) for lossless
- // compression, and YUV input (*y, *u, *v, etc.) for lossy compression
- // since these are the respective native colorspace for these formats.
- int use_argb;
-
- // YUV input (mostly used for input to lossy compression)
- WebPEncCSP colorspace; // colorspace: should be YUV420 for now (=Y'CbCr).
- int width, height; // dimensions (less or equal to WEBP_MAX_DIMENSION)
- uint8_t* y, *u, *v; // pointers to luma/chroma planes.
- int y_stride, uv_stride; // luma/chroma strides.
- uint8_t* a; // pointer to the alpha plane
- int a_stride; // stride of the alpha plane
- uint32_t pad1[2]; // padding for later use
-
- // ARGB input (mostly used for input to lossless compression)
- uint32_t* argb; // Pointer to argb (32 bit) plane.
- int argb_stride; // This is stride in pixels units, not bytes.
- uint32_t pad2[3]; // padding for later use
-
- // OUTPUT
- ///////////////
- // Byte-emission hook, to store compressed bytes as they are ready.
- WebPWriterFunction writer; // can be NULL
- void* custom_ptr; // can be used by the writer.
-
- // map for extra information (only for lossy compression mode)
- int extra_info_type; // 1: intra type, 2: segment, 3: quant
- // 4: intra-16 prediction mode,
- // 5: chroma prediction mode,
- // 6: bit cost, 7: distortion
- uint8_t* extra_info; // if not NULL, points to an array of size
- // ((width + 15) / 16) * ((height + 15) / 16) that
- // will be filled with a macroblock map, depending
- // on extra_info_type.
-
- // STATS AND REPORTS
- ///////////////////////////
- // Pointer to side statistics (updated only if not NULL)
- WebPAuxStats* stats;
-
- // Error code for the latest error encountered during encoding
- WebPEncodingError error_code;
-
- // If not NULL, report progress during encoding.
- WebPProgressHook progress_hook;
-
- void* user_data; // this field is free to be set to any value and
- // used during callbacks (like progress-report e.g.).
-
- uint32_t pad3[3]; // padding for later use
-
- // Unused for now
- uint8_t* pad4, *pad5;
- uint32_t pad6[8]; // padding for later use
-
- // PRIVATE FIELDS
- ////////////////////
- void* memory_; // row chunk of memory for yuva planes
- void* memory_argb_; // and for argb too.
- void* pad7[2]; // padding for later use
-};
-
-// Internal, version-checked, entry point
-WEBP_EXTERN int WebPPictureInitInternal(WebPPicture*, int);
-
-// Should always be called, to initialize the structure. Returns false in case
-// of version mismatch. WebPPictureInit() must have succeeded before using the
-// 'picture' object.
-// Note that, by default, use_argb is false and colorspace is WEBP_YUV420.
-static WEBP_INLINE int WebPPictureInit(WebPPicture* picture) {
- return WebPPictureInitInternal(picture, WEBP_ENCODER_ABI_VERSION);
-}
-
-//------------------------------------------------------------------------------
-// WebPPicture utils
-
-// Convenience allocation / deallocation based on picture->width/height:
-// Allocate y/u/v buffers as per colorspace/width/height specification.
-// Note! This function will free the previous buffer if needed.
-// Returns false in case of memory error.
-WEBP_EXTERN int WebPPictureAlloc(WebPPicture* picture);
-
-// Release the memory allocated by WebPPictureAlloc() or WebPPictureImport*().
-// Note that this function does _not_ free the memory used by the 'picture'
-// object itself.
-// Besides memory (which is reclaimed) all other fields of 'picture' are
-// preserved.
-WEBP_EXTERN void WebPPictureFree(WebPPicture* picture);
-
-// Copy the pixels of *src into *dst, using WebPPictureAlloc. Upon return, *dst
-// will fully own the copied pixels (this is not a view). The 'dst' picture need
-// not be initialized as its content is overwritten.
-// Returns false in case of memory allocation error.
-WEBP_EXTERN int WebPPictureCopy(const WebPPicture* src, WebPPicture* dst);
-
-// Compute the single distortion for packed planes of samples.
-// 'src' will be compared to 'ref', and the raw distortion stored into
-// '*distortion'. The refined metric (log(MSE), log(1 - ssim),...' will be
-// stored in '*result'.
-// 'x_step' is the horizontal stride (in bytes) between samples.
-// 'src/ref_stride' is the byte distance between rows.
-// Returns false in case of error (bad parameter, memory allocation error, ...).
-WEBP_EXTERN int WebPPlaneDistortion(const uint8_t* src, size_t src_stride,
- const uint8_t* ref, size_t ref_stride,
- int width, int height,
- size_t x_step,
- int type, // 0 = PSNR, 1 = SSIM, 2 = LSIM
- float* distortion, float* result);
-
-// Compute PSNR, SSIM or LSIM distortion metric between two pictures. Results
-// are in dB, stored in result[] in the B/G/R/A/All order. The distortion is
-// always performed using ARGB samples. Hence if the input is YUV(A), the
-// picture will be internally converted to ARGB (just for the measurement).
-// Warning: this function is rather CPU-intensive.
-WEBP_EXTERN int WebPPictureDistortion(
- const WebPPicture* src, const WebPPicture* ref,
- int metric_type, // 0 = PSNR, 1 = SSIM, 2 = LSIM
- float result[5]);
-
-// self-crops a picture to the rectangle defined by top/left/width/height.
-// Returns false in case of memory allocation error, or if the rectangle is
-// outside of the source picture.
-// The rectangle for the view is defined by the top-left corner pixel
-// coordinates (left, top) as well as its width and height. This rectangle
-// must be fully be comprised inside the 'src' source picture. If the source
-// picture uses the YUV420 colorspace, the top and left coordinates will be
-// snapped to even values.
-WEBP_EXTERN int WebPPictureCrop(WebPPicture* picture,
- int left, int top, int width, int height);
-
-// Extracts a view from 'src' picture into 'dst'. The rectangle for the view
-// is defined by the top-left corner pixel coordinates (left, top) as well
-// as its width and height. This rectangle must be fully be comprised inside
-// the 'src' source picture. If the source picture uses the YUV420 colorspace,
-// the top and left coordinates will be snapped to even values.
-// Picture 'src' must out-live 'dst' picture. Self-extraction of view is allowed
-// ('src' equal to 'dst') as a mean of fast-cropping (but note that doing so,
-// the original dimension will be lost). Picture 'dst' need not be initialized
-// with WebPPictureInit() if it is different from 'src', since its content will
-// be overwritten.
-// Returns false in case of memory allocation error or invalid parameters.
-WEBP_EXTERN int WebPPictureView(const WebPPicture* src,
- int left, int top, int width, int height,
- WebPPicture* dst);
-
-// Returns true if the 'picture' is actually a view and therefore does
-// not own the memory for pixels.
-WEBP_EXTERN int WebPPictureIsView(const WebPPicture* picture);
-
-// Rescale a picture to new dimension width x height.
-// If either 'width' or 'height' (but not both) is 0 the corresponding
-// dimension will be calculated preserving the aspect ratio.
-// No gamma correction is applied.
-// Returns false in case of error (invalid parameter or insufficient memory).
-WEBP_EXTERN int WebPPictureRescale(WebPPicture* pic, int width, int height);
-
-// Colorspace conversion function to import RGB samples.
-// Previous buffer will be free'd, if any.
-// *rgb buffer should have a size of at least height * rgb_stride.
-// Returns false in case of memory error.
-WEBP_EXTERN int WebPPictureImportRGB(
- WebPPicture* picture, const uint8_t* rgb, int rgb_stride);
-// Same, but for RGBA buffer.
-WEBP_EXTERN int WebPPictureImportRGBA(
- WebPPicture* picture, const uint8_t* rgba, int rgba_stride);
-// Same, but for RGBA buffer. Imports the RGB direct from the 32-bit format
-// input buffer ignoring the alpha channel. Avoids needing to copy the data
-// to a temporary 24-bit RGB buffer to import the RGB only.
-WEBP_EXTERN int WebPPictureImportRGBX(
- WebPPicture* picture, const uint8_t* rgbx, int rgbx_stride);
-
-// Variants of the above, but taking BGR(A|X) input.
-WEBP_EXTERN int WebPPictureImportBGR(
- WebPPicture* picture, const uint8_t* bgr, int bgr_stride);
-WEBP_EXTERN int WebPPictureImportBGRA(
- WebPPicture* picture, const uint8_t* bgra, int bgra_stride);
-WEBP_EXTERN int WebPPictureImportBGRX(
- WebPPicture* picture, const uint8_t* bgrx, int bgrx_stride);
-
-// Converts picture->argb data to the YUV420A format. The 'colorspace'
-// parameter is deprecated and should be equal to WEBP_YUV420.
-// Upon return, picture->use_argb is set to false. The presence of real
-// non-opaque transparent values is detected, and 'colorspace' will be
-// adjusted accordingly. Note that this method is lossy.
-// Returns false in case of error.
-WEBP_EXTERN int WebPPictureARGBToYUVA(WebPPicture* picture,
- WebPEncCSP /*colorspace = WEBP_YUV420*/);
-
-// Same as WebPPictureARGBToYUVA(), but the conversion is done using
-// pseudo-random dithering with a strength 'dithering' between
-// 0.0 (no dithering) and 1.0 (maximum dithering). This is useful
-// for photographic picture.
-WEBP_EXTERN int WebPPictureARGBToYUVADithered(
- WebPPicture* picture, WebPEncCSP colorspace, float dithering);
-
-// Performs 'sharp' RGBA->YUVA420 downsampling and colorspace conversion.
-// Downsampling is handled with extra care in case of color clipping. This
-// method is roughly 2x slower than WebPPictureARGBToYUVA() but produces better
-// and sharper YUV representation.
-// Returns false in case of error.
-WEBP_EXTERN int WebPPictureSharpARGBToYUVA(WebPPicture* picture);
-// kept for backward compatibility:
-WEBP_EXTERN int WebPPictureSmartARGBToYUVA(WebPPicture* picture);
-
-// Converts picture->yuv to picture->argb and sets picture->use_argb to true.
-// The input format must be YUV_420 or YUV_420A. The conversion from YUV420 to
-// ARGB incurs a small loss too.
-// Note that the use of this colorspace is discouraged if one has access to the
-// raw ARGB samples, since using YUV420 is comparatively lossy.
-// Returns false in case of error.
-WEBP_EXTERN int WebPPictureYUVAToARGB(WebPPicture* picture);
-
-// Helper function: given a width x height plane of RGBA or YUV(A) samples
-// clean-up or smoothen the YUV or RGB samples under fully transparent area,
-// to help compressibility (no guarantee, though).
-WEBP_EXTERN void WebPCleanupTransparentArea(WebPPicture* picture);
-
-// Scan the picture 'picture' for the presence of non fully opaque alpha values.
-// Returns true in such case. Otherwise returns false (indicating that the
-// alpha plane can be ignored altogether e.g.).
-WEBP_EXTERN int WebPPictureHasTransparency(const WebPPicture* picture);
-
-// Remove the transparency information (if present) by blending the color with
-// the background color 'background_rgb' (specified as 24bit RGB triplet).
-// After this call, all alpha values are reset to 0xff.
-WEBP_EXTERN void WebPBlendAlpha(WebPPicture* pic, uint32_t background_rgb);
-
-//------------------------------------------------------------------------------
-// Main call
-
-// Main encoding call, after config and picture have been initialized.
-// 'picture' must be less than 16384x16384 in dimension (cf WEBP_MAX_DIMENSION),
-// and the 'config' object must be a valid one.
-// Returns false in case of error, true otherwise.
-// In case of error, picture->error_code is updated accordingly.
-// 'picture' can hold the source samples in both YUV(A) or ARGB input, depending
-// on the value of 'picture->use_argb'. It is highly recommended to use
-// the former for lossy encoding, and the latter for lossless encoding
-// (when config.lossless is true). Automatic conversion from one format to
-// another is provided but they both incur some loss.
-WEBP_EXTERN int WebPEncode(const WebPConfig* config, WebPPicture* picture);
-
-//------------------------------------------------------------------------------
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // WEBP_WEBP_ENCODE_H_
diff --git a/contrib/libs/libwebp/webp/format_constants.h b/contrib/libs/libwebp/webp/format_constants.h
deleted file mode 100644
index eca6981a47..0000000000
--- a/contrib/libs/libwebp/webp/format_constants.h
+++ /dev/null
@@ -1,87 +0,0 @@
-// Copyright 2012 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Internal header for constants related to WebP file format.
-//
-// Author: Urvang (urvang@google.com)
-
-#ifndef WEBP_WEBP_FORMAT_CONSTANTS_H_
-#define WEBP_WEBP_FORMAT_CONSTANTS_H_
-
-// Create fourcc of the chunk from the chunk tag characters.
-#define MKFOURCC(a, b, c, d) ((a) | (b) << 8 | (c) << 16 | (uint32_t)(d) << 24)
-
-// VP8 related constants.
-#define VP8_SIGNATURE 0x9d012a // Signature in VP8 data.
-#define VP8_MAX_PARTITION0_SIZE (1 << 19) // max size of mode partition
-#define VP8_MAX_PARTITION_SIZE (1 << 24) // max size for token partition
-#define VP8_FRAME_HEADER_SIZE 10 // Size of the frame header within VP8 data.
-
-// VP8L related constants.
-#define VP8L_SIGNATURE_SIZE 1 // VP8L signature size.
-#define VP8L_MAGIC_BYTE 0x2f // VP8L signature byte.
-#define VP8L_IMAGE_SIZE_BITS 14 // Number of bits used to store
- // width and height.
-#define VP8L_VERSION_BITS 3 // 3 bits reserved for version.
-#define VP8L_VERSION 0 // version 0
-#define VP8L_FRAME_HEADER_SIZE 5 // Size of the VP8L frame header.
-
-#define MAX_PALETTE_SIZE 256
-#define MAX_CACHE_BITS 11
-#define HUFFMAN_CODES_PER_META_CODE 5
-#define ARGB_BLACK 0xff000000
-
-#define DEFAULT_CODE_LENGTH 8
-#define MAX_ALLOWED_CODE_LENGTH 15
-
-#define NUM_LITERAL_CODES 256
-#define NUM_LENGTH_CODES 24
-#define NUM_DISTANCE_CODES 40
-#define CODE_LENGTH_CODES 19
-
-#define MIN_HUFFMAN_BITS 2 // min number of Huffman bits
-#define MAX_HUFFMAN_BITS 9 // max number of Huffman bits
-
-#define TRANSFORM_PRESENT 1 // The bit to be written when next data
- // to be read is a transform.
-#define NUM_TRANSFORMS 4 // Maximum number of allowed transform
- // in a bitstream.
-typedef enum {
- PREDICTOR_TRANSFORM = 0,
- CROSS_COLOR_TRANSFORM = 1,
- SUBTRACT_GREEN = 2,
- COLOR_INDEXING_TRANSFORM = 3
-} VP8LImageTransformType;
-
-// Alpha related constants.
-#define ALPHA_HEADER_LEN 1
-#define ALPHA_NO_COMPRESSION 0
-#define ALPHA_LOSSLESS_COMPRESSION 1
-#define ALPHA_PREPROCESSED_LEVELS 1
-
-// Mux related constants.
-#define TAG_SIZE 4 // Size of a chunk tag (e.g. "VP8L").
-#define CHUNK_SIZE_BYTES 4 // Size needed to store chunk's size.
-#define CHUNK_HEADER_SIZE 8 // Size of a chunk header.
-#define RIFF_HEADER_SIZE 12 // Size of the RIFF header ("RIFFnnnnWEBP").
-#define ANMF_CHUNK_SIZE 16 // Size of an ANMF chunk.
-#define ANIM_CHUNK_SIZE 6 // Size of an ANIM chunk.
-#define VP8X_CHUNK_SIZE 10 // Size of a VP8X chunk.
-
-#define MAX_CANVAS_SIZE (1 << 24) // 24-bit max for VP8X width/height.
-#define MAX_IMAGE_AREA (1ULL << 32) // 32-bit max for width x height.
-#define MAX_LOOP_COUNT (1 << 16) // maximum value for loop-count
-#define MAX_DURATION (1 << 24) // maximum duration
-#define MAX_POSITION_OFFSET (1 << 24) // maximum frame x/y offset
-
-// Maximum chunk payload is such that adding the header and padding won't
-// overflow a uint32_t.
-#define MAX_CHUNK_PAYLOAD (~0U - CHUNK_HEADER_SIZE - 1)
-
-#endif // WEBP_WEBP_FORMAT_CONSTANTS_H_
diff --git a/contrib/libs/libwebp/webp/mux.h b/contrib/libs/libwebp/webp/mux.h
deleted file mode 100644
index 7d27489a40..0000000000
--- a/contrib/libs/libwebp/webp/mux.h
+++ /dev/null
@@ -1,530 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// RIFF container manipulation and encoding for WebP images.
-//
-// Authors: Urvang (urvang@google.com)
-// Vikas (vikasa@google.com)
-
-#ifndef WEBP_WEBP_MUX_H_
-#define WEBP_WEBP_MUX_H_
-
-#include "./mux_types.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define WEBP_MUX_ABI_VERSION 0x0108 // MAJOR(8b) + MINOR(8b)
-
-//------------------------------------------------------------------------------
-// Mux API
-//
-// This API allows manipulation of WebP container images containing features
-// like color profile, metadata, animation.
-//
-// Code Example#1: Create a WebPMux object with image data, color profile and
-// XMP metadata.
-/*
- int copy_data = 0;
- WebPMux* mux = WebPMuxNew();
- // ... (Prepare image data).
- WebPMuxSetImage(mux, &image, copy_data);
- // ... (Prepare ICCP color profile data).
- WebPMuxSetChunk(mux, "ICCP", &icc_profile, copy_data);
- // ... (Prepare XMP metadata).
- WebPMuxSetChunk(mux, "XMP ", &xmp, copy_data);
- // Get data from mux in WebP RIFF format.
- WebPMuxAssemble(mux, &output_data);
- WebPMuxDelete(mux);
- // ... (Consume output_data; e.g. write output_data.bytes to file).
- WebPDataClear(&output_data);
-*/
-
-// Code Example#2: Get image and color profile data from a WebP file.
-/*
- int copy_data = 0;
- // ... (Read data from file).
- WebPMux* mux = WebPMuxCreate(&data, copy_data);
- WebPMuxGetFrame(mux, 1, &image);
- // ... (Consume image; e.g. call WebPDecode() to decode the data).
- WebPMuxGetChunk(mux, "ICCP", &icc_profile);
- // ... (Consume icc_data).
- WebPMuxDelete(mux);
- WebPFree(data);
-*/
-
-// Note: forward declaring enumerations is not allowed in (strict) C and C++,
-// the types are left here for reference.
-// typedef enum WebPMuxError WebPMuxError;
-// typedef enum WebPChunkId WebPChunkId;
-typedef struct WebPMux WebPMux; // main opaque object.
-typedef struct WebPMuxFrameInfo WebPMuxFrameInfo;
-typedef struct WebPMuxAnimParams WebPMuxAnimParams;
-typedef struct WebPAnimEncoderOptions WebPAnimEncoderOptions;
-
-// Error codes
-typedef enum WebPMuxError {
- WEBP_MUX_OK = 1,
- WEBP_MUX_NOT_FOUND = 0,
- WEBP_MUX_INVALID_ARGUMENT = -1,
- WEBP_MUX_BAD_DATA = -2,
- WEBP_MUX_MEMORY_ERROR = -3,
- WEBP_MUX_NOT_ENOUGH_DATA = -4
-} WebPMuxError;
-
-// IDs for different types of chunks.
-typedef enum WebPChunkId {
- WEBP_CHUNK_VP8X, // VP8X
- WEBP_CHUNK_ICCP, // ICCP
- WEBP_CHUNK_ANIM, // ANIM
- WEBP_CHUNK_ANMF, // ANMF
- WEBP_CHUNK_DEPRECATED, // (deprecated from FRGM)
- WEBP_CHUNK_ALPHA, // ALPH
- WEBP_CHUNK_IMAGE, // VP8/VP8L
- WEBP_CHUNK_EXIF, // EXIF
- WEBP_CHUNK_XMP, // XMP
- WEBP_CHUNK_UNKNOWN, // Other chunks.
- WEBP_CHUNK_NIL
-} WebPChunkId;
-
-//------------------------------------------------------------------------------
-
-// Returns the version number of the mux library, packed in hexadecimal using
-// 8bits for each of major/minor/revision. E.g: v2.5.7 is 0x020507.
-WEBP_EXTERN int WebPGetMuxVersion(void);
-
-//------------------------------------------------------------------------------
-// Life of a Mux object
-
-// Internal, version-checked, entry point
-WEBP_EXTERN WebPMux* WebPNewInternal(int);
-
-// Creates an empty mux object.
-// Returns:
-// A pointer to the newly created empty mux object.
-// Or NULL in case of memory error.
-static WEBP_INLINE WebPMux* WebPMuxNew(void) {
- return WebPNewInternal(WEBP_MUX_ABI_VERSION);
-}
-
-// Deletes the mux object.
-// Parameters:
-// mux - (in/out) object to be deleted
-WEBP_EXTERN void WebPMuxDelete(WebPMux* mux);
-
-//------------------------------------------------------------------------------
-// Mux creation.
-
-// Internal, version-checked, entry point
-WEBP_EXTERN WebPMux* WebPMuxCreateInternal(const WebPData*, int, int);
-
-// Creates a mux object from raw data given in WebP RIFF format.
-// Parameters:
-// bitstream - (in) the bitstream data in WebP RIFF format
-// copy_data - (in) value 1 indicates given data WILL be copied to the mux
-// object and value 0 indicates data will NOT be copied.
-// Returns:
-// A pointer to the mux object created from given data - on success.
-// NULL - In case of invalid data or memory error.
-static WEBP_INLINE WebPMux* WebPMuxCreate(const WebPData* bitstream,
- int copy_data) {
- return WebPMuxCreateInternal(bitstream, copy_data, WEBP_MUX_ABI_VERSION);
-}
-
-//------------------------------------------------------------------------------
-// Non-image chunks.
-
-// Note: Only non-image related chunks should be managed through chunk APIs.
-// (Image related chunks are: "ANMF", "VP8 ", "VP8L" and "ALPH").
-// To add, get and delete images, use WebPMuxSetImage(), WebPMuxPushFrame(),
-// WebPMuxGetFrame() and WebPMuxDeleteFrame().
-
-// Adds a chunk with id 'fourcc' and data 'chunk_data' in the mux object.
-// Any existing chunk(s) with the same id will be removed.
-// Parameters:
-// mux - (in/out) object to which the chunk is to be added
-// fourcc - (in) a character array containing the fourcc of the given chunk;
-// e.g., "ICCP", "XMP ", "EXIF" etc.
-// chunk_data - (in) the chunk data to be added
-// copy_data - (in) value 1 indicates given data WILL be copied to the mux
-// object and value 0 indicates data will NOT be copied.
-// Returns:
-// WEBP_MUX_INVALID_ARGUMENT - if mux, fourcc or chunk_data is NULL
-// or if fourcc corresponds to an image chunk.
-// WEBP_MUX_MEMORY_ERROR - on memory allocation error.
-// WEBP_MUX_OK - on success.
-WEBP_EXTERN WebPMuxError WebPMuxSetChunk(
- WebPMux* mux, const char fourcc[4], const WebPData* chunk_data,
- int copy_data);
-
-// Gets a reference to the data of the chunk with id 'fourcc' in the mux object.
-// The caller should NOT free the returned data.
-// Parameters:
-// mux - (in) object from which the chunk data is to be fetched
-// fourcc - (in) a character array containing the fourcc of the chunk;
-// e.g., "ICCP", "XMP ", "EXIF" etc.
-// chunk_data - (out) returned chunk data
-// Returns:
-// WEBP_MUX_INVALID_ARGUMENT - if mux, fourcc or chunk_data is NULL
-// or if fourcc corresponds to an image chunk.
-// WEBP_MUX_NOT_FOUND - If mux does not contain a chunk with the given id.
-// WEBP_MUX_OK - on success.
-WEBP_EXTERN WebPMuxError WebPMuxGetChunk(
- const WebPMux* mux, const char fourcc[4], WebPData* chunk_data);
-
-// Deletes the chunk with the given 'fourcc' from the mux object.
-// Parameters:
-// mux - (in/out) object from which the chunk is to be deleted
-// fourcc - (in) a character array containing the fourcc of the chunk;
-// e.g., "ICCP", "XMP ", "EXIF" etc.
-// Returns:
-// WEBP_MUX_INVALID_ARGUMENT - if mux or fourcc is NULL
-// or if fourcc corresponds to an image chunk.
-// WEBP_MUX_NOT_FOUND - If mux does not contain a chunk with the given fourcc.
-// WEBP_MUX_OK - on success.
-WEBP_EXTERN WebPMuxError WebPMuxDeleteChunk(
- WebPMux* mux, const char fourcc[4]);
-
-//------------------------------------------------------------------------------
-// Images.
-
-// Encapsulates data about a single frame.
-struct WebPMuxFrameInfo {
- WebPData bitstream; // image data: can be a raw VP8/VP8L bitstream
- // or a single-image WebP file.
- int x_offset; // x-offset of the frame.
- int y_offset; // y-offset of the frame.
- int duration; // duration of the frame (in milliseconds).
-
- WebPChunkId id; // frame type: should be one of WEBP_CHUNK_ANMF
- // or WEBP_CHUNK_IMAGE
- WebPMuxAnimDispose dispose_method; // Disposal method for the frame.
- WebPMuxAnimBlend blend_method; // Blend operation for the frame.
- uint32_t pad[1]; // padding for later use
-};
-
-// Sets the (non-animated) image in the mux object.
-// Note: Any existing images (including frames) will be removed.
-// Parameters:
-// mux - (in/out) object in which the image is to be set
-// bitstream - (in) can be a raw VP8/VP8L bitstream or a single-image
-// WebP file (non-animated)
-// copy_data - (in) value 1 indicates given data WILL be copied to the mux
-// object and value 0 indicates data will NOT be copied.
-// Returns:
-// WEBP_MUX_INVALID_ARGUMENT - if mux is NULL or bitstream is NULL.
-// WEBP_MUX_MEMORY_ERROR - on memory allocation error.
-// WEBP_MUX_OK - on success.
-WEBP_EXTERN WebPMuxError WebPMuxSetImage(
- WebPMux* mux, const WebPData* bitstream, int copy_data);
-
-// Adds a frame at the end of the mux object.
-// Notes: (1) frame.id should be WEBP_CHUNK_ANMF
-// (2) For setting a non-animated image, use WebPMuxSetImage() instead.
-// (3) Type of frame being pushed must be same as the frames in mux.
-// (4) As WebP only supports even offsets, any odd offset will be snapped
-// to an even location using: offset &= ~1
-// Parameters:
-// mux - (in/out) object to which the frame is to be added
-// frame - (in) frame data.
-// copy_data - (in) value 1 indicates given data WILL be copied to the mux
-// object and value 0 indicates data will NOT be copied.
-// Returns:
-// WEBP_MUX_INVALID_ARGUMENT - if mux or frame is NULL
-// or if content of 'frame' is invalid.
-// WEBP_MUX_MEMORY_ERROR - on memory allocation error.
-// WEBP_MUX_OK - on success.
-WEBP_EXTERN WebPMuxError WebPMuxPushFrame(
- WebPMux* mux, const WebPMuxFrameInfo* frame, int copy_data);
-
-// Gets the nth frame from the mux object.
-// The content of 'frame->bitstream' is allocated using WebPMalloc(), and NOT
-// owned by the 'mux' object. It MUST be deallocated by the caller by calling
-// WebPDataClear().
-// nth=0 has a special meaning - last position.
-// Parameters:
-// mux - (in) object from which the info is to be fetched
-// nth - (in) index of the frame in the mux object
-// frame - (out) data of the returned frame
-// Returns:
-// WEBP_MUX_INVALID_ARGUMENT - if mux or frame is NULL.
-// WEBP_MUX_NOT_FOUND - if there are less than nth frames in the mux object.
-// WEBP_MUX_BAD_DATA - if nth frame chunk in mux is invalid.
-// WEBP_MUX_MEMORY_ERROR - on memory allocation error.
-// WEBP_MUX_OK - on success.
-WEBP_EXTERN WebPMuxError WebPMuxGetFrame(
- const WebPMux* mux, uint32_t nth, WebPMuxFrameInfo* frame);
-
-// Deletes a frame from the mux object.
-// nth=0 has a special meaning - last position.
-// Parameters:
-// mux - (in/out) object from which a frame is to be deleted
-// nth - (in) The position from which the frame is to be deleted
-// Returns:
-// WEBP_MUX_INVALID_ARGUMENT - if mux is NULL.
-// WEBP_MUX_NOT_FOUND - If there are less than nth frames in the mux object
-// before deletion.
-// WEBP_MUX_OK - on success.
-WEBP_EXTERN WebPMuxError WebPMuxDeleteFrame(WebPMux* mux, uint32_t nth);
-
-//------------------------------------------------------------------------------
-// Animation.
-
-// Animation parameters.
-struct WebPMuxAnimParams {
- uint32_t bgcolor; // Background color of the canvas stored (in MSB order) as:
- // Bits 00 to 07: Alpha.
- // Bits 08 to 15: Red.
- // Bits 16 to 23: Green.
- // Bits 24 to 31: Blue.
- int loop_count; // Number of times to repeat the animation [0 = infinite].
-};
-
-// Sets the animation parameters in the mux object. Any existing ANIM chunks
-// will be removed.
-// Parameters:
-// mux - (in/out) object in which ANIM chunk is to be set/added
-// params - (in) animation parameters.
-// Returns:
-// WEBP_MUX_INVALID_ARGUMENT - if mux or params is NULL.
-// WEBP_MUX_MEMORY_ERROR - on memory allocation error.
-// WEBP_MUX_OK - on success.
-WEBP_EXTERN WebPMuxError WebPMuxSetAnimationParams(
- WebPMux* mux, const WebPMuxAnimParams* params);
-
-// Gets the animation parameters from the mux object.
-// Parameters:
-// mux - (in) object from which the animation parameters to be fetched
-// params - (out) animation parameters extracted from the ANIM chunk
-// Returns:
-// WEBP_MUX_INVALID_ARGUMENT - if mux or params is NULL.
-// WEBP_MUX_NOT_FOUND - if ANIM chunk is not present in mux object.
-// WEBP_MUX_OK - on success.
-WEBP_EXTERN WebPMuxError WebPMuxGetAnimationParams(
- const WebPMux* mux, WebPMuxAnimParams* params);
-
-//------------------------------------------------------------------------------
-// Misc Utilities.
-
-// Sets the canvas size for the mux object. The width and height can be
-// specified explicitly or left as zero (0, 0).
-// * When width and height are specified explicitly, then this frame bound is
-// enforced during subsequent calls to WebPMuxAssemble() and an error is
-// reported if any animated frame does not completely fit within the canvas.
-// * When unspecified (0, 0), the constructed canvas will get the frame bounds
-// from the bounding-box over all frames after calling WebPMuxAssemble().
-// Parameters:
-// mux - (in) object to which the canvas size is to be set
-// width - (in) canvas width
-// height - (in) canvas height
-// Returns:
-// WEBP_MUX_INVALID_ARGUMENT - if mux is NULL; or
-// width or height are invalid or out of bounds
-// WEBP_MUX_OK - on success.
-WEBP_EXTERN WebPMuxError WebPMuxSetCanvasSize(WebPMux* mux,
- int width, int height);
-
-// Gets the canvas size from the mux object.
-// Note: This method assumes that the VP8X chunk, if present, is up-to-date.
-// That is, the mux object hasn't been modified since the last call to
-// WebPMuxAssemble() or WebPMuxCreate().
-// Parameters:
-// mux - (in) object from which the canvas size is to be fetched
-// width - (out) canvas width
-// height - (out) canvas height
-// Returns:
-// WEBP_MUX_INVALID_ARGUMENT - if mux, width or height is NULL.
-// WEBP_MUX_BAD_DATA - if VP8X/VP8/VP8L chunk or canvas size is invalid.
-// WEBP_MUX_OK - on success.
-WEBP_EXTERN WebPMuxError WebPMuxGetCanvasSize(const WebPMux* mux,
- int* width, int* height);
-
-// Gets the feature flags from the mux object.
-// Note: This method assumes that the VP8X chunk, if present, is up-to-date.
-// That is, the mux object hasn't been modified since the last call to
-// WebPMuxAssemble() or WebPMuxCreate().
-// Parameters:
-// mux - (in) object from which the features are to be fetched
-// flags - (out) the flags specifying which features are present in the
-// mux object. This will be an OR of various flag values.
-// Enum 'WebPFeatureFlags' can be used to test individual flag values.
-// Returns:
-// WEBP_MUX_INVALID_ARGUMENT - if mux or flags is NULL.
-// WEBP_MUX_BAD_DATA - if VP8X/VP8/VP8L chunk or canvas size is invalid.
-// WEBP_MUX_OK - on success.
-WEBP_EXTERN WebPMuxError WebPMuxGetFeatures(const WebPMux* mux,
- uint32_t* flags);
-
-// Gets number of chunks with the given 'id' in the mux object.
-// Parameters:
-// mux - (in) object from which the info is to be fetched
-// id - (in) chunk id specifying the type of chunk
-// num_elements - (out) number of chunks with the given chunk id
-// Returns:
-// WEBP_MUX_INVALID_ARGUMENT - if mux, or num_elements is NULL.
-// WEBP_MUX_OK - on success.
-WEBP_EXTERN WebPMuxError WebPMuxNumChunks(const WebPMux* mux,
- WebPChunkId id, int* num_elements);
-
-// Assembles all chunks in WebP RIFF format and returns in 'assembled_data'.
-// This function also validates the mux object.
-// Note: The content of 'assembled_data' will be ignored and overwritten.
-// Also, the content of 'assembled_data' is allocated using WebPMalloc(), and
-// NOT owned by the 'mux' object. It MUST be deallocated by the caller by
-// calling WebPDataClear(). It's always safe to call WebPDataClear() upon
-// return, even in case of error.
-// Parameters:
-// mux - (in/out) object whose chunks are to be assembled
-// assembled_data - (out) assembled WebP data
-// Returns:
-// WEBP_MUX_BAD_DATA - if mux object is invalid.
-// WEBP_MUX_INVALID_ARGUMENT - if mux or assembled_data is NULL.
-// WEBP_MUX_MEMORY_ERROR - on memory allocation error.
-// WEBP_MUX_OK - on success.
-WEBP_EXTERN WebPMuxError WebPMuxAssemble(WebPMux* mux,
- WebPData* assembled_data);
-
-//------------------------------------------------------------------------------
-// WebPAnimEncoder API
-//
-// This API allows encoding (possibly) animated WebP images.
-//
-// Code Example:
-/*
- WebPAnimEncoderOptions enc_options;
- WebPAnimEncoderOptionsInit(&enc_options);
- // Tune 'enc_options' as needed.
- WebPAnimEncoder* enc = WebPAnimEncoderNew(width, height, &enc_options);
- while(<there are more frames>) {
- WebPConfig config;
- WebPConfigInit(&config);
- // Tune 'config' as needed.
- WebPAnimEncoderAdd(enc, frame, timestamp_ms, &config);
- }
- WebPAnimEncoderAdd(enc, NULL, timestamp_ms, NULL);
- WebPAnimEncoderAssemble(enc, webp_data);
- WebPAnimEncoderDelete(enc);
- // Write the 'webp_data' to a file, or re-mux it further.
-*/
-
-typedef struct WebPAnimEncoder WebPAnimEncoder; // Main opaque object.
-
-// Forward declarations. Defined in encode.h.
-struct WebPPicture;
-struct WebPConfig;
-
-// Global options.
-struct WebPAnimEncoderOptions {
- WebPMuxAnimParams anim_params; // Animation parameters.
- int minimize_size; // If true, minimize the output size (slow). Implicitly
- // disables key-frame insertion.
- int kmin;
- int kmax; // Minimum and maximum distance between consecutive key
- // frames in the output. The library may insert some key
- // frames as needed to satisfy this criteria.
- // Note that these conditions should hold: kmax > kmin
- // and kmin >= kmax / 2 + 1. Also, if kmax <= 0, then
- // key-frame insertion is disabled; and if kmax == 1,
- // then all frames will be key-frames (kmin value does
- // not matter for these special cases).
- int allow_mixed; // If true, use mixed compression mode; may choose
- // either lossy and lossless for each frame.
- int verbose; // If true, print info and warning messages to stderr.
-
- uint32_t padding[4]; // Padding for later use.
-};
-
-// Internal, version-checked, entry point.
-WEBP_EXTERN int WebPAnimEncoderOptionsInitInternal(
- WebPAnimEncoderOptions*, int);
-
-// Should always be called, to initialize a fresh WebPAnimEncoderOptions
-// structure before modification. Returns false in case of version mismatch.
-// WebPAnimEncoderOptionsInit() must have succeeded before using the
-// 'enc_options' object.
-static WEBP_INLINE int WebPAnimEncoderOptionsInit(
- WebPAnimEncoderOptions* enc_options) {
- return WebPAnimEncoderOptionsInitInternal(enc_options, WEBP_MUX_ABI_VERSION);
-}
-
-// Internal, version-checked, entry point.
-WEBP_EXTERN WebPAnimEncoder* WebPAnimEncoderNewInternal(
- int, int, const WebPAnimEncoderOptions*, int);
-
-// Creates and initializes a WebPAnimEncoder object.
-// Parameters:
-// width/height - (in) canvas width and height of the animation.
-// enc_options - (in) encoding options; can be passed NULL to pick
-// reasonable defaults.
-// Returns:
-// A pointer to the newly created WebPAnimEncoder object.
-// Or NULL in case of memory error.
-static WEBP_INLINE WebPAnimEncoder* WebPAnimEncoderNew(
- int width, int height, const WebPAnimEncoderOptions* enc_options) {
- return WebPAnimEncoderNewInternal(width, height, enc_options,
- WEBP_MUX_ABI_VERSION);
-}
-
-// Optimize the given frame for WebP, encode it and add it to the
-// WebPAnimEncoder object.
-// The last call to 'WebPAnimEncoderAdd' should be with frame = NULL, which
-// indicates that no more frames are to be added. This call is also used to
-// determine the duration of the last frame.
-// Parameters:
-// enc - (in/out) object to which the frame is to be added.
-// frame - (in/out) frame data in ARGB or YUV(A) format. If it is in YUV(A)
-// format, it will be converted to ARGB, which incurs a small loss.
-// timestamp_ms - (in) timestamp of this frame in milliseconds.
-// Duration of a frame would be calculated as
-// "timestamp of next frame - timestamp of this frame".
-// Hence, timestamps should be in non-decreasing order.
-// config - (in) encoding options; can be passed NULL to pick
-// reasonable defaults.
-// Returns:
-// On error, returns false and frame->error_code is set appropriately.
-// Otherwise, returns true.
-WEBP_EXTERN int WebPAnimEncoderAdd(
- WebPAnimEncoder* enc, struct WebPPicture* frame, int timestamp_ms,
- const struct WebPConfig* config);
-
-// Assemble all frames added so far into a WebP bitstream.
-// This call should be preceded by a call to 'WebPAnimEncoderAdd' with
-// frame = NULL; if not, the duration of the last frame will be internally
-// estimated.
-// Parameters:
-// enc - (in/out) object from which the frames are to be assembled.
-// webp_data - (out) generated WebP bitstream.
-// Returns:
-// True on success.
-WEBP_EXTERN int WebPAnimEncoderAssemble(WebPAnimEncoder* enc,
- WebPData* webp_data);
-
-// Get error string corresponding to the most recent call using 'enc'. The
-// returned string is owned by 'enc' and is valid only until the next call to
-// WebPAnimEncoderAdd() or WebPAnimEncoderAssemble() or WebPAnimEncoderDelete().
-// Parameters:
-// enc - (in/out) object from which the error string is to be fetched.
-// Returns:
-// NULL if 'enc' is NULL. Otherwise, returns the error string if the last call
-// to 'enc' had an error, or an empty string if the last call was a success.
-WEBP_EXTERN const char* WebPAnimEncoderGetError(WebPAnimEncoder* enc);
-
-// Deletes the WebPAnimEncoder object.
-// Parameters:
-// enc - (in/out) object to be deleted
-WEBP_EXTERN void WebPAnimEncoderDelete(WebPAnimEncoder* enc);
-
-//------------------------------------------------------------------------------
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // WEBP_WEBP_MUX_H_
diff --git a/contrib/libs/libwebp/webp/mux_types.h b/contrib/libs/libwebp/webp/mux_types.h
deleted file mode 100644
index 2fe8195839..0000000000
--- a/contrib/libs/libwebp/webp/mux_types.h
+++ /dev/null
@@ -1,98 +0,0 @@
-// Copyright 2012 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Data-types common to the mux and demux libraries.
-//
-// Author: Urvang (urvang@google.com)
-
-#ifndef WEBP_WEBP_MUX_TYPES_H_
-#define WEBP_WEBP_MUX_TYPES_H_
-
-#include <string.h> // memset()
-#include "./types.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// Note: forward declaring enumerations is not allowed in (strict) C and C++,
-// the types are left here for reference.
-// typedef enum WebPFeatureFlags WebPFeatureFlags;
-// typedef enum WebPMuxAnimDispose WebPMuxAnimDispose;
-// typedef enum WebPMuxAnimBlend WebPMuxAnimBlend;
-typedef struct WebPData WebPData;
-
-// VP8X Feature Flags.
-typedef enum WebPFeatureFlags {
- ANIMATION_FLAG = 0x00000002,
- XMP_FLAG = 0x00000004,
- EXIF_FLAG = 0x00000008,
- ALPHA_FLAG = 0x00000010,
- ICCP_FLAG = 0x00000020,
-
- ALL_VALID_FLAGS = 0x0000003e
-} WebPFeatureFlags;
-
-// Dispose method (animation only). Indicates how the area used by the current
-// frame is to be treated before rendering the next frame on the canvas.
-typedef enum WebPMuxAnimDispose {
- WEBP_MUX_DISPOSE_NONE, // Do not dispose.
- WEBP_MUX_DISPOSE_BACKGROUND // Dispose to background color.
-} WebPMuxAnimDispose;
-
-// Blend operation (animation only). Indicates how transparent pixels of the
-// current frame are blended with those of the previous canvas.
-typedef enum WebPMuxAnimBlend {
- WEBP_MUX_BLEND, // Blend.
- WEBP_MUX_NO_BLEND // Do not blend.
-} WebPMuxAnimBlend;
-
-// Data type used to describe 'raw' data, e.g., chunk data
-// (ICC profile, metadata) and WebP compressed image data.
-// 'bytes' memory must be allocated using WebPMalloc() and such.
-struct WebPData {
- const uint8_t* bytes;
- size_t size;
-};
-
-// Initializes the contents of the 'webp_data' object with default values.
-static WEBP_INLINE void WebPDataInit(WebPData* webp_data) {
- if (webp_data != NULL) {
- memset(webp_data, 0, sizeof(*webp_data));
- }
-}
-
-// Clears the contents of the 'webp_data' object by calling WebPFree().
-// Does not deallocate the object itself.
-static WEBP_INLINE void WebPDataClear(WebPData* webp_data) {
- if (webp_data != NULL) {
- WebPFree((void*)webp_data->bytes);
- WebPDataInit(webp_data);
- }
-}
-
-// Allocates necessary storage for 'dst' and copies the contents of 'src'.
-// Returns true on success.
-static WEBP_INLINE int WebPDataCopy(const WebPData* src, WebPData* dst) {
- if (src == NULL || dst == NULL) return 0;
- WebPDataInit(dst);
- if (src->bytes != NULL && src->size != 0) {
- dst->bytes = (uint8_t*)WebPMalloc(src->size);
- if (dst->bytes == NULL) return 0;
- memcpy((void*)dst->bytes, src->bytes, src->size);
- dst->size = src->size;
- }
- return 1;
-}
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // WEBP_WEBP_MUX_TYPES_H_
diff --git a/contrib/libs/libwebp/webp/types.h b/contrib/libs/libwebp/webp/types.h
deleted file mode 100644
index 47f7f2b007..0000000000
--- a/contrib/libs/libwebp/webp/types.h
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright 2010 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// Common types + memory wrappers
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#ifndef WEBP_WEBP_TYPES_H_
-#define WEBP_WEBP_TYPES_H_
-
-#include <stddef.h> // for size_t
-
-#ifndef _MSC_VER
-#include <inttypes.h>
-#if defined(__cplusplus) || !defined(__STRICT_ANSI__) || \
- (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
-#define WEBP_INLINE inline
-#else
-#define WEBP_INLINE
-#endif
-#else
-typedef signed char int8_t;
-typedef unsigned char uint8_t;
-typedef signed short int16_t;
-typedef unsigned short uint16_t;
-typedef signed int int32_t;
-typedef unsigned int uint32_t;
-typedef unsigned long long int uint64_t;
-typedef long long int int64_t;
-#define WEBP_INLINE __forceinline
-#endif /* _MSC_VER */
-
-#ifndef WEBP_EXTERN
-// This explicitly marks library functions and allows for changing the
-// signature for e.g., Windows DLL builds.
-# if defined(__GNUC__) && __GNUC__ >= 4
-# define WEBP_EXTERN extern __attribute__ ((visibility ("default")))
-# else
-# define WEBP_EXTERN extern
-# endif /* __GNUC__ >= 4 */
-#endif /* WEBP_EXTERN */
-
-// Macro to check ABI compatibility (same major revision number)
-#define WEBP_ABI_IS_INCOMPATIBLE(a, b) (((a) >> 8) != ((b) >> 8))
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// Allocates 'size' bytes of memory. Returns NULL upon error. Memory
-// must be deallocated by calling WebPFree(). This function is made available
-// by the core 'libwebp' library.
-WEBP_EXTERN void* WebPMalloc(size_t size);
-
-// Releases memory returned by the WebPDecode*() functions (from decode.h).
-WEBP_EXTERN void WebPFree(void* ptr);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // WEBP_WEBP_TYPES_H_
diff --git a/contrib/libs/libwebp/webpdecoder/ya.make b/contrib/libs/libwebp/webpdecoder/ya.make
deleted file mode 100644
index 6667b96dc1..0000000000
--- a/contrib/libs/libwebp/webpdecoder/ya.make
+++ /dev/null
@@ -1,21 +0,0 @@
-# Generated by devtools/yamaker.
-
-LIBRARY()
-
-WITHOUT_LICENSE_TEXTS()
-
-VERSION(1.2.2)
-
-LICENSE(BSD-3-Clause)
-
-PEERDIR(
- contrib/libs/libwebp/dec
- contrib/libs/libwebp/dsp/webpdspdecode
- contrib/libs/libwebp/utils/webputilsdecode
-)
-
-NO_COMPILER_WARNINGS()
-
-NO_RUNTIME()
-
-END()
diff --git a/contrib/libs/libwebp/ya.make b/contrib/libs/libwebp/ya.make
deleted file mode 100644
index 3b10c54146..0000000000
--- a/contrib/libs/libwebp/ya.make
+++ /dev/null
@@ -1,48 +0,0 @@
-# Generated by devtools/yamaker from nixpkgs 22.05.
-
-LIBRARY()
-
-VERSION(1.2.2)
-
-ORIGINAL_SOURCE(https://github.com/webmproject/libwebp/archive/v1.2.2.tar.gz)
-
-LICENSE(BSD-3-Clause WITH Google-Patent-License-Webm)
-
-LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
-
-PEERDIR(
- contrib/libs/libwebp/dec
- contrib/libs/libwebp/dsp/webpdsp
- contrib/libs/libwebp/enc
- contrib/libs/libwebp/utils/webputils
-)
-
-NO_COMPILER_WARNINGS()
-
-NO_RUNTIME()
-
-END()
-
-RECURSE(
- dec
- demux
- dsp/webpdsp
- dsp/webpdsp_mips32
- dsp/webpdsp_mips_dsp_r2
- dsp/webpdsp_msa
- dsp/webpdsp_neon
- dsp/webpdsp_sse2
- dsp/webpdsp_sse41
- dsp/webpdspdecode
- dsp/webpdspdecode_mips32
- dsp/webpdspdecode_mips_dsp_r2
- dsp/webpdspdecode_msa
- dsp/webpdspdecode_neon
- dsp/webpdspdecode_sse2
- dsp/webpdspdecode_sse41
- enc
- mux
- utils/webputils
- utils/webputilsdecode
- webpdecoder
-)
diff --git a/contrib/libs/openjpeg/.yandex_meta/__init__.py b/contrib/libs/openjpeg/.yandex_meta/__init__.py
deleted file mode 100644
index 7ba9e7326e..0000000000
--- a/contrib/libs/openjpeg/.yandex_meta/__init__.py
+++ /dev/null
@@ -1,42 +0,0 @@
-from devtools.yamaker.modules import GLOBAL, Linkable, Switch
-from devtools.yamaker.project import CMakeNinjaNixProject
-
-
-def post_install(self):
- with self.yamakes["."] as openjpeg:
- openjpeg.CFLAGS.remove("-DMUTEX_pthread")
- openjpeg.after(
- "CFLAGS",
- Switch(
- OS_WINDOWS=Linkable(
- CFLAGS=[
- GLOBAL("/DOPJ_STATIC"),
- "/DMUTEX_win32",
- ]
- ),
- default=Linkable(
- CFLAGS=[
- "-DMUTEX_pthread",
- ]
- ),
- ),
- )
-
-
-openjpeg = CMakeNinjaNixProject(
- owners=["g:cpp-contrib"],
- arcdir="contrib/libs/openjpeg",
- nixattr="openjpeg",
- flags=["-DBUILD_CODEC=OFF", "-DBUILD_MJ2=OFF", "-DBUILD_TESTING=OFF"],
- disable_includes=["cidx_manager.h", "indexbox_manager.h", "openjpwl/jpwl.h"],
- build_targets=["openjp2"],
- install_subdir="src/lib/openjp2",
- inclink={
- "include": [
- "opj_config.h",
- "openjpeg.h",
- ],
- },
- platform_dispatchers=["opj_config_private.h"],
- post_install=post_install,
-)
diff --git a/contrib/libs/openjpeg/.yandex_meta/devtools.copyrights.report b/contrib/libs/openjpeg/.yandex_meta/devtools.copyrights.report
deleted file mode 100644
index 45d8a08ca2..0000000000
--- a/contrib/libs/openjpeg/.yandex_meta/devtools.copyrights.report
+++ /dev/null
@@ -1,573 +0,0 @@
-# File format ($ symbol means the beginning of a line):
-#
-# $ # this message
-# $ # =======================
-# $ # comments (all commentaries should starts with some number of spaces and # symbol)
-# ${action} {license id} {license text hash}
-# $BELONGS ./ya/make/file/relative/path/1/ya.make ./ya/make/2/ya.make
-# ${all_file_action} filename
-# $ # user commentaries (many lines)
-# $ generated description - files with this license, license text... (some number of lines that starts with some number of spaces, do not modify)
-# ${action} {license spdx} {license text hash}
-# $BELONGS ./ya/make/file/relative/path/3/ya.make
-# ${all_file_action} filename
-# $ # user commentaries
-# $ generated description
-# $ ...
-#
-# You can modify action, all_file_action and add commentaries
-# Available actions:
-# keep - keep license in contrib and use in credits
-# skip - skip license
-# remove - remove all files with this license
-# rename - save license text/links into licenses texts file, but not store SPDX into LINCENSE macro. You should store correct license id into devtools.license.spdx.txt file
-#
-# {all file action} records will be generated when license text contains filename that exists on filesystem (in contrib directory)
-# We suppose that that files can contain some license info
-# Available all file actions:
-# FILE_IGNORE - ignore file (do nothing)
-# FILE_INCLUDE - include all file data into licenses text file
-# =======================
-
-KEEP COPYRIGHT_SERVICE_LABEL 156729456a69de93c11c39f023a0e2c2
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- j2k.c [7:20]
- j2k.h [7:17]
- openjpeg.h [7:19]
- pi.c [7:15]
- tcd.c [7:18]
-
-KEEP COPYRIGHT_SERVICE_LABEL 26ae08eeff365098c5a1454789219b30
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- LICENSE [7:15]
- bio.c [7:14]
- bio.h [7:14]
- cio.c [7:16]
- cio.h [7:16]
- dwt.c [7:17]
- dwt.h [7:14]
- event.c [7:10]
- event.h [7:10]
- image.c [7:8]
- image.h [7:8]
- j2k.c [7:20]
- j2k.h [7:17]
- jp2.c [7:17]
- jp2.h [7:13]
- mct.c [7:16]
- mct.h [7:16]
- mqc.c [7:15]
- mqc.h [7:15]
- mqc_inl.h [7:15]
- openjpeg.c [7:10]
- openjpeg.h [7:19]
- opj_clock.c [7:8]
- opj_clock.h [7:8]
- opj_includes.h [7:10]
- opj_intmath.h [7:14]
- opj_malloc.h [7:9]
- pi.c [7:15]
- pi.h [7:14]
- t1.c [7:17]
- t1.h [7:16]
- t2.c [7:17]
- t2.h [7:17]
- tcd.c [7:18]
- tcd.h [7:17]
- tgt.c [7:16]
- tgt.h [7:17]
-
-KEEP COPYRIGHT_SERVICE_LABEL 3255416921fce487d6eafd5a97a6963a
-BELONGS ya.make
- License text:
- // Copyright (c) 2021, Aous Naman
- // Copyright (c) 2021, Kakadu Software Pty Ltd, Australia
- // Copyright (c) 2021, The University of New South Wales, Australia
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- ht_dec.c [5:7]
-
-KEEP COPYRIGHT_SERVICE_LABEL 3e5a8817ea1d6ed125d0a29fb5781a76
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- LICENSE [7:15]
- bio.c [7:14]
- bio.h [7:14]
- cio.c [7:16]
- cio.h [7:16]
- dwt.c [7:17]
- dwt.h [7:14]
- j2k.c [7:20]
- j2k.h [7:17]
- jp2.c [7:17]
- mct.c [7:16]
- mct.h [7:16]
- mqc.c [7:15]
- mqc.h [7:15]
- mqc_inl.h [7:15]
- openjpeg.h [7:19]
- opj_intmath.h [7:14]
- pi.c [7:15]
- pi.h [7:14]
- t1.c [7:17]
- t1.h [7:16]
- t2.c [7:17]
- t2.h [7:17]
- tcd.c [7:18]
- tcd.h [7:17]
- tgt.c [7:16]
- tgt.h [7:17]
-
-KEEP COPYRIGHT_SERVICE_LABEL 55e4177f698d05dc721417a6103f01af
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- dwt.c [7:17]
-
-KEEP COPYRIGHT_SERVICE_LABEL 60bbb1946c5720a631b0e530309742ec
-BELONGS ya.make
- License text:
- * Copyright (c) 2015, Mathieu Malaterre <mathieu.malaterre@gmail.com>
- * Copyright (c) 2015, Matthieu Darbois
- * All rights reserved.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- opj_malloc.c [7:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL 68e1bb0be295ca341bd43c3face3ebc9
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- LICENSE [7:15]
- bio.c [7:14]
- bio.h [7:14]
- cio.c [7:16]
- cio.h [7:16]
- dwt.c [7:17]
- dwt.h [7:14]
- j2k.c [7:20]
- j2k.h [7:17]
- jp2.c [7:17]
- jp2.h [7:13]
- mct.c [7:16]
- mct.h [7:16]
- mqc.c [7:15]
- mqc.h [7:15]
- mqc_inl.h [7:15]
- openjpeg.h [7:19]
- opj_codec.h [7:9]
- opj_intmath.h [7:14]
- pi.c [7:15]
- pi.h [7:14]
- t1.c [7:17]
- t1.h [7:16]
- t2.c [7:17]
- t2.h [7:17]
- tcd.c [7:18]
- tcd.h [7:17]
- tgt.c [7:16]
- tgt.h [7:17]
-
-KEEP COPYRIGHT_SERVICE_LABEL 6e5ca22a0f30998bbb66a4c40109b94c
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- LICENSE [7:15]
- bio.c [7:14]
- bio.h [7:14]
- cio.c [7:16]
- cio.h [7:16]
- dwt.c [7:17]
- dwt.h [7:14]
- j2k.c [7:20]
- j2k.h [7:17]
- jp2.c [7:17]
- mct.c [7:16]
- mct.h [7:16]
- mqc.c [7:15]
- mqc.h [7:15]
- mqc_inl.h [7:15]
- openjpeg.h [7:19]
- opj_intmath.h [7:14]
- pi.c [7:15]
- pi.h [7:14]
- t1.c [7:17]
- t1.h [7:16]
- t2.c [7:17]
- t2.h [7:17]
- tcd.c [7:18]
- tcd.h [7:17]
- tgt.c [7:16]
- tgt.h [7:17]
-
-KEEP COPYRIGHT_SERVICE_LABEL 849525ac2dbf33d2094d6da92dd427c9
-BELONGS ya.make
- License text:
- // Copyright (c) 2021, Aous Naman
- // Copyright (c) 2021, Kakadu Software Pty Ltd, Australia
- // Copyright (c) 2021, The University of New South Wales, Australia
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- ht_dec.c [5:7]
-
-KEEP COPYRIGHT_SERVICE_LABEL 8d334eb2e5625c12e794ca846229d02d
-BELONGS ya.make
- License text:
- * Copyright (c) 2017, IntoPix SA <contact@intopix.com>
- * All rights reserved.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- sparse_array.c [7:8]
- sparse_array.h [7:8]
-
-KEEP COPYRIGHT_SERVICE_LABEL 93c2fab33e0487ca6082e8f4c0e760a6
-BELONGS ya.make
- License text:
- // Copyright (c) 2021, Aous Naman
- // Copyright (c) 2021, Kakadu Software Pty Ltd, Australia
- // Copyright (c) 2021, The University of New South Wales, Australia
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- ht_dec.c [5:7]
-
-KEEP COPYRIGHT_SERVICE_LABEL a179d465d626cd55fbefa8b8b0f395fe
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- j2k.c [7:20]
- jp2.c [7:17]
- openjpeg.h [7:19]
-
-KEEP COPYRIGHT_SERVICE_LABEL a3dcc7cc285538df6d03c99242e2cf44
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- cio.c [7:16]
- cio.h [7:16]
- event.c [7:10]
- event.h [7:10]
- jp2.c [7:17]
- jp2.h [7:13]
- mct.c [7:16]
- mct.h [7:16]
- openjpeg.c [7:10]
- opj_includes.h [7:10]
- t2.c [7:17]
- t2.h [7:17]
- tcd.c [7:18]
- tcd.h [7:17]
- tgt.c [7:16]
-
-KEEP COPYRIGHT_SERVICE_LABEL a589adbd314fd0742f06d257cbad909b
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- LICENSE [7:15]
- j2k.c [7:20]
- j2k.h [7:17]
- openjpeg.h [7:19]
- tgt.h [7:17]
-
-KEEP COPYRIGHT_SERVICE_LABEL ac5b0225c39a75ddc9b50da4434ddfc6
-BELONGS ya.make
- License text:
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@c-s.fr>
- * All rights reserved.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- function_list.c [7:8]
- function_list.h [7:8]
- invert.c [7:8]
- invert.h [7:8]
- j2k.c [7:20]
- j2k.h [7:17]
- mqc.c [7:15]
- mqc.h [7:15]
- mqc_inl.h [7:15]
- openjpeg.h [7:19]
- tgt.h [7:17]
-
-KEEP COPYRIGHT_SERVICE_LABEL bfcfb221aeb5a2c5163f3190bf6f72ed
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- LICENSE [7:15]
- bio.c [7:14]
- bio.h [7:14]
- cio.c [7:16]
- cio.h [7:16]
- dwt.c [7:17]
- dwt.h [7:14]
- j2k.c [7:20]
- j2k.h [7:17]
- jp2.c [7:17]
- jp2.h [7:13]
- mct.c [7:16]
- mct.h [7:16]
- mqc.c [7:15]
- mqc.h [7:15]
- mqc_inl.h [7:15]
- openjpeg.h [7:19]
- opj_intmath.h [7:14]
- pi.c [7:15]
- pi.h [7:14]
- t1.c [7:17]
- t1.h [7:16]
- t2.c [7:17]
- t2.h [7:17]
- tcd.c [7:18]
- tcd.h [7:17]
- tgt.c [7:16]
- tgt.h [7:17]
-
-KEEP COPYRIGHT_SERVICE_LABEL c55d957169a61d48b23333b6a8653870
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- dwt.c [7:17]
- opj_malloc.h [7:9]
- t1.c [7:17]
-
-KEEP COPYRIGHT_SERVICE_LABEL c9c2b77c5425f11ff9c0fac4b3e44d8f
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- LICENSE [7:15]
- bio.c [7:14]
- bio.h [7:14]
- cio.c [7:16]
- cio.h [7:16]
- dwt.c [7:17]
- dwt.h [7:14]
- j2k.c [7:20]
- j2k.h [7:17]
- jp2.c [7:17]
- jp2.h [7:13]
- mct.c [7:16]
- mct.h [7:16]
- mqc.c [7:15]
- mqc.h [7:15]
- mqc_inl.h [7:15]
- openjpeg.h [7:19]
- opj_codec.h [7:9]
- opj_intmath.h [7:14]
- pi.c [7:15]
- pi.h [7:14]
- t1.c [7:17]
- t1.h [7:16]
- t2.c [7:17]
- t2.h [7:17]
- tcd.c [7:18]
- tcd.h [7:17]
- tgt.c [7:16]
- tgt.h [7:17]
-
-KEEP COPYRIGHT_SERVICE_LABEL cc3e831570c01f17428af962edfdbcb4
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- cio.c [7:16]
- cio.h [7:16]
- event.c [7:10]
- event.h [7:10]
- jp2.c [7:17]
- jp2.h [7:13]
- mct.c [7:16]
- mct.h [7:16]
- openjpeg.c [7:10]
- opj_includes.h [7:10]
- t2.c [7:17]
- t2.h [7:17]
- tcd.c [7:18]
- tcd.h [7:17]
- tgt.c [7:16]
-
-KEEP COPYRIGHT_SERVICE_LABEL d4bebe97ba73b61bb4f06758758c3ae2
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- t1.c [7:17]
- t1.h [7:16]
-
-KEEP COPYRIGHT_SERVICE_LABEL d6cd4576170670e6662aaa6efc3cfc25
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- LICENSE [7:15]
- j2k.c [7:20]
- j2k.h [7:17]
- openjpeg.h [7:19]
- tgt.h [7:17]
-
-KEEP COPYRIGHT_SERVICE_LABEL d71fd7a07d2b8f92b4a4a7beea6f7c58
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- dwt.c [7:17]
- j2k.c [7:20]
- opj_common.h [7:8]
- t1.c [7:17]
- t1.h [7:16]
- t2.c [7:17]
- t2.h [7:17]
- tcd.c [7:18]
- tcd.h [7:17]
-
-KEEP COPYRIGHT_SERVICE_LABEL ea27e4bb66b6267783c1bb9666bdf66c
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- bio.c [7:14]
- bio.h [7:14]
- cio.c [7:16]
- cio.h [7:16]
- dwt.c [7:17]
- dwt.h [7:14]
- j2k.c [7:20]
- j2k.h [7:17]
- jp2.c [7:17]
- mct.c [7:16]
- mct.h [7:16]
- mqc.c [7:15]
- mqc.h [7:15]
- mqc_inl.h [7:15]
- openjpeg.h [7:19]
- opj_intmath.h [7:14]
- pi.c [7:15]
- pi.h [7:14]
- t1.c [7:17]
- t1.h [7:16]
- t2.c [7:17]
- t2.h [7:17]
- tcd.c [7:18]
- tcd.h [7:17]
- tgt.c [7:16]
- tgt.h [7:17]
-
-KEEP COPYRIGHT_SERVICE_LABEL ec90dc8b115731bc3da3ed34cead3788
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- LICENSE [7:15]
-
-KEEP COPYRIGHT_SERVICE_LABEL efd62ab9db6fe7e7540ef13ef8c534a0
-BELONGS ya.make
- License text:
- * Copyright (c) 2015, Mathieu Malaterre <mathieu.malaterre@gmail.com>
- * Copyright (c) 2015, Matthieu Darbois
- * All rights reserved.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- opj_malloc.c [7:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL f027075e354919011704dd9023651843
-BELONGS ya.make
- License text:
- * Copyright (c) 2016, Even Rouault
- * All rights reserved.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- thread.c [7:8]
- thread.h [7:8]
- tls_keys.h [7:8]
diff --git a/contrib/libs/openjpeg/.yandex_meta/devtools.licenses.report b/contrib/libs/openjpeg/.yandex_meta/devtools.licenses.report
deleted file mode 100644
index 4d3440fc80..0000000000
--- a/contrib/libs/openjpeg/.yandex_meta/devtools.licenses.report
+++ /dev/null
@@ -1,608 +0,0 @@
-# File format ($ symbol means the beginning of a line):
-#
-# $ # this message
-# $ # =======================
-# $ # comments (all commentaries should starts with some number of spaces and # symbol)
-# ${action} {license spdx} {license text hash}
-# $BELONGS ./ya/make/file/relative/path/1/ya.make ./ya/make/2/ya.make
-# ${all_file_action} filename
-# $ # user commentaries (many lines)
-# $ generated description - files with this license, license text... (some number of lines that starts with some number of spaces, do not modify)
-# ${action} {license spdx} {license text hash}
-# $BELONGS ./ya/make/file/relative/path/3/ya.make
-# ${all_file_action} filename
-# $ # user commentaries
-# $ generated description
-# $ ...
-#
-# You can modify action, all_file_action and add commentaries
-# Available actions:
-# keep - keep license in contrib and use in credits
-# skip - skip license
-# remove - remove all files with this license
-# rename - save license text/links into licenses texts file, but not store SPDX into LINCENSE macro. You should store correct license id into devtools.license.spdx.txt file
-#
-# {all file action} records will be generated when license text contains filename that exists on filesystem (in contrib directory)
-# We suppose that that files can contain some license info
-# Available all file actions:
-# FILE_IGNORE - ignore file (do nothing)
-# FILE_INCLUDE - include all file data into licenses text file
-# =======================
-
-KEEP BSD-2-Clause 02331e9ea322390a1b6413b63f636c20
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: BSD-2-Clause
- Score : 100.00
- Match type : NOTICE
- Links : http://opensource.org/licenses/bsd-license.php, http://www.opensource.org/licenses/BSD-2-Clause, https://spdx.org/licenses/BSD-2-Clause
- Files with this license:
- t2.c [19:38]
-
-KEEP BSD-2-Clause 039f4cbc2daf1c10b3c72e11871d89f9
-BELONGS ya.make
- License text:
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- Scancode info:
- Original SPDX id: BSD-2-Clause
- Score : 71.79
- Match type : NOTICE
- Links : http://opensource.org/licenses/bsd-license.php, http://www.opensource.org/licenses/BSD-2-Clause, https://spdx.org/licenses/BSD-2-Clause
- Files with this license:
- t2.c [3:5]
- Scancode info:
- Original SPDX id: LicenseRef-scancode-proprietary-license
- Score : 71.79
- Match type : NOTICE
- Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/proprietary-license.LICENSE
- Files with this license:
- t2.c [3:5]
-
-KEEP BSD-2-Clause 178c8af6750dceedf582cd6a442de403
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: GPL-2.0-only
- Score : 92.04
- Match type : NOTICE
- Links : http://www.gnu.org/licenses/gpl-2.0.html, http://www.gnu.org/licenses/gpl-2.0.txt, https://spdx.org/licenses/GPL-2.0-only
- Files with this license:
- event.c [3:31]
- event.h [3:31]
- Scancode info:
- Original SPDX id: BSD-2-Clause
- Score : 92.04
- Match type : NOTICE
- Links : http://opensource.org/licenses/bsd-license.php, http://www.opensource.org/licenses/BSD-2-Clause, https://spdx.org/licenses/BSD-2-Clause
- Files with this license:
- event.c [3:31]
- event.h [3:31]
- Scancode info:
- Original SPDX id: BSD-3-Clause
- Score : 88.94
- Match type : TEXT
- Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
- Files with this license:
- openjpeg.c [3:31]
- opj_includes.h [3:31]
-
-KEEP BSD-2-Clause 22e23988905968e9f66379f09bed1e89
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: GPL-2.0-only
- Score : 92.04
- Match type : NOTICE
- Links : http://www.gnu.org/licenses/gpl-2.0.html, http://www.gnu.org/licenses/gpl-2.0.txt, https://spdx.org/licenses/GPL-2.0-only
- Files with this license:
- jp2.h [3:34]
- Scancode info:
- Original SPDX id: BSD-2-Clause
- Score : 92.04
- Match type : NOTICE
- Links : http://opensource.org/licenses/bsd-license.php, http://www.opensource.org/licenses/BSD-2-Clause, https://spdx.org/licenses/BSD-2-Clause
- Files with this license:
- jp2.h [3:34]
-
-KEEP BSD-2-Clause 2a63c1dd03ca6a86ca2b0ce923ffc1db
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: GPL-2.0-only
- Score : 92.04
- Match type : NOTICE
- Links : http://www.gnu.org/licenses/gpl-2.0.html, http://www.gnu.org/licenses/gpl-2.0.txt, https://spdx.org/licenses/GPL-2.0-only
- Files with this license:
- mqc.c [3:36]
- mqc.h [3:36]
- Scancode info:
- Original SPDX id: BSD-2-Clause
- Score : 92.04
- Match type : NOTICE
- Links : http://opensource.org/licenses/bsd-license.php, http://www.opensource.org/licenses/BSD-2-Clause, https://spdx.org/licenses/BSD-2-Clause
- Files with this license:
- mqc.c [3:36]
- mqc.h [3:36]
- Scancode info:
- Original SPDX id: BSD-3-Clause
- Score : 85.78
- Match type : TEXT
- Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
- Files with this license:
- mqc_inl.h [3:36]
-
-KEEP BSD-3-Clause 2d3a4121edb1a0c3af2ca7449b65e65a
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: BSD-3-Clause
- Score : 81.30
- Match type : TEXT
- Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
- Files with this license:
- sparse_array.c [3:29]
- sparse_array.h [3:29]
-
-KEEP BSD-2-Clause 2e083a2b9a6f4f34564b948b20538f43
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: BSD-3-Clause
- Score : 88.94
- Match type : TEXT
- Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
- Files with this license:
- bio.c [3:35]
- Scancode info:
- Original SPDX id: GPL-2.0-only
- Score : 92.04
- Match type : NOTICE
- Links : http://www.gnu.org/licenses/gpl-2.0.html, http://www.gnu.org/licenses/gpl-2.0.txt, https://spdx.org/licenses/GPL-2.0-only
- Files with this license:
- bio.h [3:35]
- pi.h [3:35]
- Scancode info:
- Original SPDX id: BSD-2-Clause
- Score : 92.04
- Match type : NOTICE
- Links : http://opensource.org/licenses/bsd-license.php, http://www.opensource.org/licenses/BSD-2-Clause, https://spdx.org/licenses/BSD-2-Clause
- Files with this license:
- bio.h [3:35]
- pi.h [3:35]
- Scancode info:
- Original SPDX id: BSD-3-Clause
- Score : 85.78
- Match type : TEXT
- Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
- Files with this license:
- dwt.h [3:35]
- opj_intmath.h [3:35]
-
-KEEP BSD-2-Clause 342fd015ffbbbaf8c2f76f28fee0968e
-BELONGS ya.make
- License text:
- [link-license]: https://github.com/uclouvain/openjpeg/blob/master/LICENSE "BSD 2-clause \"Simplified\" License"
- Scancode info:
- Original SPDX id: BSD-2-Clause
- Score : 100.00
- Match type : TAG
- Links : http://opensource.org/licenses/bsd-license.php, http://www.opensource.org/licenses/BSD-2-Clause, https://spdx.org/licenses/BSD-2-Clause
- Files with this license:
- README.md [76:76]
-
-SKIP LicenseRef-scancode-proprietary-license 3d34ab6fdb373602c812ac673a4d0856
-BELONGS ya.make
- # it's about encoding test suite
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: LicenseRef-scancode-proprietary-license
- Score : 90.00
- Match type : REFERENCE
- Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/proprietary-license.LICENSE
- Files with this license:
- INSTALL.md [49:49]
-
-KEEP BSD-3-Clause 54b53dc3406dd44c9a2ad98427588e9e
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: BSD-3-Clause
- Score : 81.30
- Match type : TEXT
- Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
- Files with this license:
- function_list.c [3:29]
- function_list.h [3:29]
- invert.c [3:29]
- invert.h [3:29]
-
-KEEP BSD-2-Clause 5bac89da1ec9d2bc720eb2e342f9f519
-BELONGS ya.make
- License text:
- [comment-license]: https://img.shields.io/github/license/uclouvain/openjpeg.svg "https://img.shields.io/badge/license-BSD--2--Clause-blue.svg"
- Scancode info:
- Original SPDX id: BSD-2-Clause
- Score : 100.00
- Match type : TAG
- Links : http://opensource.org/licenses/bsd-license.php, http://www.opensource.org/licenses/BSD-2-Clause, https://spdx.org/licenses/BSD-2-Clause
- Files with this license:
- README.md [74:74]
- README.md [75:75]
-
-SKIP AGPL-3.0-or-later AND LicenseRef-scancode-commercial-license 5ebf4f73f9447b7e9332ce9279d5710b
-BELONGS ya.make
- # see text below
- License text:
- l_width + l_stride <= l_tile_comp->data_size / l_height); /*MUPDF*/
- Scancode info:
- Original SPDX id: AGPL-3.0-or-later
- Score : 90.00
- Match type : REFERENCE
- Links : http://www.gnu.org/licenses/agpl-3.0.html, http://www.gnu.org/licenses/agpl.txt, https://spdx.org/licenses/AGPL-3.0-or-later
- Files with this license:
- tcd.c [2307:2307]
- Scancode info:
- Original SPDX id: LicenseRef-scancode-commercial-license
- Score : 90.00
- Match type : REFERENCE
- Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/commercial-license.LICENSE
- Files with this license:
- tcd.c [2307:2307]
-
-KEEP BSD-2-Clause 5f9455f4055d30be6c326287df3e759c
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: BSD-2-Clause
- Score : 100.00
- Match type : NOTICE
- Links : http://opensource.org/licenses/bsd-license.php, http://www.opensource.org/licenses/BSD-2-Clause, https://spdx.org/licenses/BSD-2-Clause
- Files with this license:
- openjpeg.h [21:40]
-
-KEEP BSD-2-Clause 787cbc0227755fdd6add655f7edb48ae
-BELONGS ya.make
- License text:
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- Scancode info:
- Original SPDX id: BSD-2-Clause
- Score : 71.79
- Match type : NOTICE
- Links : http://opensource.org/licenses/bsd-license.php, http://www.opensource.org/licenses/BSD-2-Clause, https://spdx.org/licenses/BSD-2-Clause
- Files with this license:
- bio.c [3:5]
- bio.h [3:5]
- cio.c [3:5]
- cio.h [3:5]
- dwt.c [3:5]
- dwt.h [3:5]
- event.c [3:5]
- event.h [3:5]
- function_list.c [3:5]
- function_list.h [3:5]
- image.c [3:5]
- image.h [3:5]
- invert.c [3:5]
- invert.h [3:5]
- j2k.c [3:5]
- j2k.h [3:5]
- jp2.c [3:5]
- jp2.h [3:5]
- mct.c [3:5]
- mct.h [3:5]
- mqc.c [3:5]
- mqc.h [3:5]
- mqc_inl.h [3:5]
- openjpeg.c [3:5]
- opj_clock.c [3:5]
- opj_clock.h [3:5]
- opj_codec.h [3:5]
- opj_common.h [3:5]
- opj_includes.h [3:5]
- opj_intmath.h [3:5]
- opj_malloc.c [3:5]
- opj_malloc.h [3:5]
- pi.c [3:5]
- pi.h [3:5]
- sparse_array.c [3:5]
- sparse_array.h [3:5]
- t1.c [3:5]
- t1.h [3:5]
- t2.h [3:5]
- tcd.c [3:5]
- tcd.h [3:5]
- tgt.c [3:5]
- tgt.h [3:5]
- thread.c [3:5]
- thread.h [3:5]
- tls_keys.h [3:5]
- Scancode info:
- Original SPDX id: LicenseRef-scancode-proprietary-license
- Score : 71.79
- Match type : NOTICE
- Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/proprietary-license.LICENSE
- Files with this license:
- bio.c [3:5]
- bio.h [3:5]
- cio.c [3:5]
- cio.h [3:5]
- dwt.c [3:5]
- dwt.h [3:5]
- event.c [3:5]
- event.h [3:5]
- function_list.c [3:5]
- function_list.h [3:5]
- image.c [3:5]
- image.h [3:5]
- invert.c [3:5]
- invert.h [3:5]
- j2k.c [3:5]
- j2k.h [3:5]
- jp2.c [3:5]
- jp2.h [3:5]
- mct.c [3:5]
- mct.h [3:5]
- mqc.c [3:5]
- mqc.h [3:5]
- mqc_inl.h [3:5]
- openjpeg.c [3:5]
- opj_clock.c [3:5]
- opj_clock.h [3:5]
- opj_codec.h [3:5]
- opj_common.h [3:5]
- opj_includes.h [3:5]
- opj_intmath.h [3:5]
- opj_malloc.c [3:5]
- opj_malloc.h [3:5]
- pi.c [3:5]
- pi.h [3:5]
- sparse_array.c [3:5]
- sparse_array.h [3:5]
- t1.c [3:5]
- t1.h [3:5]
- t2.h [3:5]
- tcd.c [3:5]
- tcd.h [3:5]
- tgt.c [3:5]
- tgt.h [3:5]
- thread.c [3:5]
- thread.h [3:5]
- tls_keys.h [3:5]
-
-KEEP BSD-3-Clause 7d1dcf3029ca3a3a7bbfde323ef0f1db
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: BSD-3-Clause
- Score : 81.30
- Match type : TEXT
- Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
- Files with this license:
- thread.c [3:29]
- thread.h [3:29]
- tls_keys.h [3:29]
-
-KEEP BSD-2-Clause a97a9174f17218e94858e23378249acf
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: BSD-2-Clause
- Score : 100.00
- Match type : NOTICE
- Links : http://opensource.org/licenses/bsd-license.php, http://www.opensource.org/licenses/BSD-2-Clause, https://spdx.org/licenses/BSD-2-Clause
- Files with this license:
- LICENSE [19:38]
- cio.c [18:37]
- cio.h [18:37]
- dwt.c [19:38]
- j2k.c [22:41]
- j2k.h [21:40]
- jp2.c [19:38]
- mct.c [18:37]
- mct.h [18:37]
- t1.c [19:38]
- t2.h [19:38]
- tcd.c [20:39]
- tcd.h [19:38]
- tgt.c [18:37]
- tgt.h [19:38]
-
-KEEP BSD-2-Clause ad358b148963caea182797b9a3568f51
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: GPL-2.0-only
- Score : 92.04
- Match type : NOTICE
- Links : http://www.gnu.org/licenses/gpl-2.0.html, http://www.gnu.org/licenses/gpl-2.0.txt, https://spdx.org/licenses/GPL-2.0-only
- Files with this license:
- t1.h [3:37]
- Scancode info:
- Original SPDX id: BSD-2-Clause
- Score : 92.04
- Match type : NOTICE
- Links : http://opensource.org/licenses/bsd-license.php, http://www.opensource.org/licenses/BSD-2-Clause, https://spdx.org/licenses/BSD-2-Clause
- Files with this license:
- t1.h [3:37]
-
-KEEP BSD-2-Clause ae6c51561c26f8a4bf270ff96ee1c148
-BELONGS ya.make
- License text:
- // This software is released under the 2-Clause BSD license, included
- Scancode info:
- Original SPDX id: BSD-2-Clause
- Score : 100.00
- Match type : NOTICE
- Links : http://opensource.org/licenses/bsd-license.php, http://www.opensource.org/licenses/BSD-2-Clause, https://spdx.org/licenses/BSD-2-Clause
- Files with this license:
- ht_dec.c [2:2]
-
-SKIP LicenseRef-scancode-unknown-license-reference b356f31c329be98bbc0803bea4d2504f
-BELONGS ya.make
- # md markup
- License text:
- See [LICENSE][link-license] for license and copyright information.
- Scancode info:
- Original SPDX id: LicenseRef-scancode-unknown-license-reference
- Score : 100.00
- Match type : REFERENCE
- Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/unknown-license-reference.LICENSE
- Files with this license:
- README.md [48:48]
-
-KEEP BSD-2-Clause b36c2d0a34cfd03916b8947c26eab2bf
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: BSD-2-Clause
- Score : 83.04
- Match type : TEXT
- Links : http://opensource.org/licenses/bsd-license.php, http://www.opensource.org/licenses/BSD-2-Clause, https://spdx.org/licenses/BSD-2-Clause
- Files with this license:
- opj_malloc.h [3:30]
-
-KEEP BSD-2-Clause baca4cdca043ccfca36de26aaebd1c8d
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: BSD-2-Clause
- Score : 83.41
- Match type : TEXT
- Links : http://opensource.org/licenses/bsd-license.php, http://www.opensource.org/licenses/BSD-2-Clause, https://spdx.org/licenses/BSD-2-Clause
- Files with this license:
- opj_malloc.c [3:30]
-
-KEEP BSD-2-Clause c13256700b0cba142f16a31f10850754
-BELONGS ya.make
- License text:
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- Scancode info:
- Original SPDX id: BSD-2-Clause
- Score : 71.79
- Match type : NOTICE
- Links : http://opensource.org/licenses/bsd-license.php, http://www.opensource.org/licenses/BSD-2-Clause, https://spdx.org/licenses/BSD-2-Clause
- Files with this license:
- openjpeg.h [3:5]
- Scancode info:
- Original SPDX id: LicenseRef-scancode-proprietary-license
- Score : 71.79
- Match type : NOTICE
- Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/proprietary-license.LICENSE
- Files with this license:
- openjpeg.h [3:5]
-
-KEEP BSD-3-Clause c81c9af175299c33c9f8a282787f6707
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: BSD-3-Clause
- Score : 81.30
- Match type : TEXT
- Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
- Files with this license:
- image.c [3:29]
- image.h [3:29]
- opj_clock.c [3:29]
- opj_clock.h [3:29]
-
-KEEP BSD-3-Clause cbc8e86db2c3430d41e9f028b9262db2
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: BSD-3-Clause
- Score : 81.30
- Match type : TEXT
- Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
- Files with this license:
- opj_codec.h [3:30]
-
-KEEP BSD-3-Clause d2ae7a17d7aa676d0723706a97c0385c
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: BSD-3-Clause
- Score : 81.30
- Match type : TEXT
- Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
- Files with this license:
- opj_common.h [3:29]
-
-KEEP BSD-2-Clause d48ab5b2d6f9543e6d1ed06bd7b400f2
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: GPL-2.0-only
- Score : 92.04
- Match type : NOTICE
- Links : http://www.gnu.org/licenses/gpl-2.0.html, http://www.gnu.org/licenses/gpl-2.0.txt, https://spdx.org/licenses/GPL-2.0-only
- Files with this license:
- pi.c [3:36]
- Scancode info:
- Original SPDX id: BSD-2-Clause
- Score : 92.04
- Match type : NOTICE
- Links : http://opensource.org/licenses/bsd-license.php, http://www.opensource.org/licenses/BSD-2-Clause, https://spdx.org/licenses/BSD-2-Clause
- Files with this license:
- pi.c [3:36]
-
-KEEP BSD-2-Clause db946e2bed90ab172a363f67e00fddbd
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: BSD-2-Clause
- Score : 39.11
- Match type : REFERENCE
- Links : http://opensource.org/licenses/bsd-license.php, http://www.opensource.org/licenses/BSD-2-Clause, https://spdx.org/licenses/BSD-2-Clause
- Files with this license:
- README.md [11:11]
-
-KEEP BSD-2-Clause dd1fb4ce22a5cb19adf4991b54514268
-BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: BSD-2-Clause
- Score : 100.00
- Match type : TEXT
- Links : http://opensource.org/licenses/bsd-license.php, http://www.opensource.org/licenses/BSD-2-Clause, https://spdx.org/licenses/BSD-2-Clause
- Files with this license:
- ht_dec.c [9:30]
-
-KEEP BSD-2-Clause e3a0e4a60c9df6d912b04cb18fadc23d
-BELONGS ya.make
- License text:
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- Scancode info:
- Original SPDX id: BSD-2-Clause
- Score : 71.79
- Match type : NOTICE
- Links : http://opensource.org/licenses/bsd-license.php, http://www.opensource.org/licenses/BSD-2-Clause, https://spdx.org/licenses/BSD-2-Clause
- Files with this license:
- LICENSE [3:5]
- Scancode info:
- Original SPDX id: LicenseRef-scancode-proprietary-license
- Score : 71.79
- Match type : NOTICE
- Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/proprietary-license.LICENSE
- Files with this license:
- LICENSE [3:5]
-
-KEEP BSD-2-Clause fd4ec76654cd5b99f2e311027a6eb9b8
-BELONGS ya.make
- License text:
- [badge-license]: https://img.shields.io/badge/license-BSD--2--Clause-blue.svg "BSD 2-clause \"Simplified\" License"
- Scancode info:
- Original SPDX id: BSD-2-Clause
- Score : 100.00
- Match type : NOTICE
- Links : http://opensource.org/licenses/bsd-license.php, http://www.opensource.org/licenses/BSD-2-Clause, https://spdx.org/licenses/BSD-2-Clause
- Files with this license:
- README.md [75:75]
diff --git a/contrib/libs/openjpeg/.yandex_meta/licenses.list.txt b/contrib/libs/openjpeg/.yandex_meta/licenses.list.txt
deleted file mode 100644
index d1ce92384d..0000000000
--- a/contrib/libs/openjpeg/.yandex_meta/licenses.list.txt
+++ /dev/null
@@ -1,673 +0,0 @@
-====================BSD-2-Clause====================
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
-
-
-====================BSD-2-Clause====================
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2014, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux
- * Copyright (c) 2003-2014, Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
-
-
-====================BSD-2-Clause====================
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2014, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux
- * Copyright (c) 2003-2014, Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2006-2007, Parvatha Elangovan
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
-
-
-====================BSD-2-Clause====================
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2014, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux
- * Copyright (c) 2003-2014, Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
-
-
-====================BSD-2-Clause====================
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2014, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux
- * Copyright (c) 2003-2014, Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2012, Carl Hetherington
- * Copyright (c) 2017, IntoPIX SA <support@intopix.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
-
-
-====================BSD-2-Clause====================
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2014, Professor Benoit Macq
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR
- * Copyright (c) 2012, CS Systemes d'Information, France
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
-
-
-====================BSD-2-Clause====================
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2007, Callum Lerwick <seg@haxxed.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
-
-
-====================BSD-2-Clause====================
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR
- * Copyright (c) 2012, CS Systemes d'Information, France
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
-
-
-====================BSD-2-Clause====================
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2015, Mathieu Malaterre <mathieu.malaterre@gmail.com>
- * Copyright (c) 2015, Matthieu Darbois
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
-
-
-====================BSD-2-Clause====================
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
-
-
-====================BSD-2-Clause====================
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
-
-
-====================BSD-2-Clause====================
-* BSD License, included below. This software may be subject to other third
-* party and contributor rights, including patent rights, and no such rights
-* are granted under this license.
-
-
-====================BSD-2-Clause====================
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions
-* are met:
-* 1. Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* 2. Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-* POSSIBILITY OF SUCH DAMAGE.
-
-
-====================BSD-2-Clause====================
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// 1. Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//
-// 2. Redistributions in binary form must reproduce the above copyright
-// notice, this list of conditions and the following disclaimer in the
-// documentation and/or other materials provided with the distribution.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
-// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-====================BSD-2-Clause====================
-// This software is released under the 2-Clause BSD license, included
-
-
-====================BSD-2-Clause====================
-Anyone. As the OpenJPEG code is released under the [BSD 2-clause "Simplified" License][link-license], anyone can use or modify the code, even for commercial applications. The only restriction is to retain the copyright in the sources or in the binaries documentation. Of course, if you modified the code in a way that might be of interest for other users, you are encouraged to share it (through a [github pull request](https://github.com/uclouvain/openjpeg/pulls) or by filling an [issue](https://github.com/uclouvain/openjpeg/issues)) but this is not a requirement.
-
-
-====================BSD-2-Clause====================
-[badge-license]: https://img.shields.io/badge/license-BSD--2--Clause-blue.svg "BSD 2-clause \"Simplified\" License"
-
-
-====================BSD-2-Clause====================
-[comment-license]: https://img.shields.io/github/license/uclouvain/openjpeg.svg "https://img.shields.io/badge/license-BSD--2--Clause-blue.svg"
-
-
-====================BSD-2-Clause====================
-[link-license]: https://github.com/uclouvain/openjpeg/blob/master/LICENSE "BSD 2-clause \"Simplified\" License"
-
-
-====================BSD-3-Clause====================
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2014, Professor Benoit Macq
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
-
-
-====================BSD-3-Clause====================
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
-
-
-====================BSD-3-Clause====================
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
-
-
-====================BSD-3-Clause====================
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2016, Even Rouault
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
-
-
-====================BSD-3-Clause====================
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2017, IntoPIX SA <support@intopix.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
-
-
-====================BSD-3-Clause====================
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2017, IntoPix SA <contact@intopix.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
-
-
-====================COPYRIGHT====================
- * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2014, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux
- * Copyright (c) 2003-2014, Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * All rights reserved.
-
-
-====================COPYRIGHT====================
- * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2014, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux
- * Copyright (c) 2003-2014, Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2007, Callum Lerwick <seg@haxxed.com>
- * Copyright (c) 2012, Carl Hetherington
- * Copyright (c) 2017, IntoPIX SA <support@intopix.com>
- * All rights reserved.
-
-
-====================COPYRIGHT====================
- * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2014, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux
- * Copyright (c) 2003-2014, Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2007, Jonathan Ballard <dzonatas@dzonux.net>
- * Copyright (c) 2007, Callum Lerwick <seg@haxxed.com>
- * Copyright (c) 2017, IntoPIX SA <support@intopix.com>
- * All rights reserved.
-
-
-====================COPYRIGHT====================
- * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2014, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux
- * Copyright (c) 2003-2014, Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR
- * Copyright (c) 2012, CS Systemes d'Information, France
- * All rights reserved.
-
-
-====================COPYRIGHT====================
- * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2014, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux
- * Copyright (c) 2003-2014, Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@c-s.fr>
- * Copyright (c) 2006-2007, Parvatha Elangovan
- * Copyright (c) 2010-2011, Kaori Hagihara
- * Copyright (c) 2011-2012, Centre National d'Etudes Spatiales (CNES), France
- * Copyright (c) 2012, CS Systemes d'Information, France
- * Copyright (c) 2017, IntoPIX SA <support@intopix.com>
- * All rights reserved.
-
-
-====================COPYRIGHT====================
- * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2014, Professor Benoit Macq
- * Copyright (c) 2003-2014, Antonin Descampe
- * Copyright (c) 2003-2009, Francois-Olivier Devaux
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2011-2012, Centre National d'Etudes Spatiales (CNES), France
- * Copyright (c) 2012, CS Systemes d'Information, France
-
-
-====================COPYRIGHT====================
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@c-s.fr>
- * All rights reserved.
-
-
-====================COPYRIGHT====================
- * Copyright (c) 2015, Mathieu Malaterre <mathieu.malaterre@gmail.com>
- * Copyright (c) 2015, Matthieu Darbois
- * All rights reserved.
-
-
-====================COPYRIGHT====================
- * Copyright (c) 2016, Even Rouault
- * All rights reserved.
-
-
-====================COPYRIGHT====================
- * Copyright (c) 2017, IntoPix SA <contact@intopix.com>
- * All rights reserved.
-
-
-====================COPYRIGHT====================
-// Copyright (c) 2021, Aous Naman
-// Copyright (c) 2021, Kakadu Software Pty Ltd, Australia
-// Copyright (c) 2021, The University of New South Wales, Australia
diff --git a/contrib/libs/openjpeg/.yandex_meta/override.nix b/contrib/libs/openjpeg/.yandex_meta/override.nix
deleted file mode 100644
index d173012e1f..0000000000
--- a/contrib/libs/openjpeg/.yandex_meta/override.nix
+++ /dev/null
@@ -1,12 +0,0 @@
-pkgs: attrs: with pkgs; with attrs; rec {
- version = "2.5.3";
-
- src = fetchFromGitHub {
- owner = "uclouvain";
- repo = "openjpeg";
- rev = "v${version}";
- sha256 = "sha256-ONPahcQ80e3ahYRQU+Tu8Z7ZTARjRlpXqPAYpUlX5sY=";
- };
-
- patches = [];
-}
diff --git a/contrib/libs/openjpeg/AUTHORS.md b/contrib/libs/openjpeg/AUTHORS.md
deleted file mode 100644
index 35aa84b55e..0000000000
--- a/contrib/libs/openjpeg/AUTHORS.md
+++ /dev/null
@@ -1,21 +0,0 @@
-# Authors of OpenJPEG
-See also [THANKS](https://github.com/uclouvain/openjpeg/blob/master/THANKS.md)
-
-David Janssens designed and implemented the first version of OpenJPEG.
-
-Kaori Hagihara designed and implemented the first version of OpenJPIP.
-
-Jerome Fimes implemented the alpha version of OpenJPEG 2.0.
-
-Giuseppe Baruffa added the JPWL functionalities.
-
-Mickaël Savinaud implemented the final OpenJPEG 2.0 version based on a big merge between 1.5 version and alpha version of 2.0.
-
-Mathieu Malaterre participated to the OpenJPEG 2.0 version and improved the libraries and utilities.
-
-Yannick Verschueren,
-Herve Drolon,
-Francois-Olivier Devaux,
-Antonin Descampe
- improved the libraries and utilities.
-
diff --git a/contrib/libs/openjpeg/CHANGELOG.md b/contrib/libs/openjpeg/CHANGELOG.md
deleted file mode 100644
index 926e6f1f4f..0000000000
--- a/contrib/libs/openjpeg/CHANGELOG.md
+++ /dev/null
@@ -1,1021 +0,0 @@
-# Changelog
-
-## [v2.5.3](https://github.com/uclouvain/openjpeg/releases/v2.5.3) (2024-12-09)
-
-[Full Changelog](https://github.com/uclouvain/openjpeg/compare/v2.5.2...v2.5.3)
-
-**Closed issues:**
-
-- Memory Leak When Using Invalid Output Path in opj\_compress [\#1567](https://github.com/uclouvain/openjpeg/issues/1567)
-- heap-buffer-overflow at lib/openjp2/j2k.c:8460:84 in opj\_j2k\_add\_tlmarker in openjpeg/opj\_decompress [\#1564](https://github.com/uclouvain/openjpeg/issues/1564)
-- heap-buffer-overflow at bin/common/color.c:215:42 in sycc422\_to\_rgb in openjpeg/opj\_decompress [\#1563](https://github.com/uclouvain/openjpeg/issues/1563)
-- Can not open libjpeg [\#1550](https://github.com/uclouvain/openjpeg/issues/1550)
-- \[ERROR\] Wrong values for: w\(525\) h\(700\) numcomps\(0\) \(ihdr\) [\#1545](https://github.com/uclouvain/openjpeg/issues/1545)
-- Failed to Open a Specific JP2 file [\#1544](https://github.com/uclouvain/openjpeg/issues/1544)
-- Outdated File in OpenJPEG Project Leading to Vulnerability \(CVE-2016-9534\) [\#1539](https://github.com/uclouvain/openjpeg/issues/1539)
-- Heap-buffer-overflow in in opj\_mqc\_init\_dec\_common when disabling strict mode [\#1535](https://github.com/uclouvain/openjpeg/issues/1535)
-- Heap-buffer-overflow in in opj\_t1\_decode\_cblk when disabling strict mode [\#1533](https://github.com/uclouvain/openjpeg/issues/1533)
-- opj\_decode\_tile\_data takes a long time to decode a very small file [\#1524](https://github.com/uclouvain/openjpeg/issues/1524)
-- Release v2.5.2 tag is outside of the repository [\#1521](https://github.com/uclouvain/openjpeg/issues/1521)
-- Website broken [\#1513](https://github.com/uclouvain/openjpeg/issues/1513)
-- Guard Bits In CINEMA2K Profile [\#1340](https://github.com/uclouvain/openjpeg/issues/1340)
-- Support for OSX on ARM \(M1\) [\#1289](https://github.com/uclouvain/openjpeg/issues/1289)
-- Building on Windows creates \_\_stdcall-convention static lib/dll regardless of compiler settings [\#722](https://github.com/uclouvain/openjpeg/issues/722)
-
-**Merged pull requests:**
-
-- sycc422\_to\_rgb\(\): fix out-of-bounds read accesses when 2 \* width\_component\_1\_or\_2 + 1 == with\_component\_0 [\#1566](https://github.com/uclouvain/openjpeg/pull/1566) ([rouault](https://github.com/rouault))
-- opj\_j2k\_add\_tlmarker\(\): validate that current tile-part number if smaller that total number of tile-parts [\#1565](https://github.com/uclouvain/openjpeg/pull/1565) ([rouault](https://github.com/rouault))
-- Amend fix of PR 1530 regarding m\_sot\_length check [\#1561](https://github.com/uclouvain/openjpeg/pull/1561) ([rouault](https://github.com/rouault))
-- Do not turn on 'TPsot==TNsot detection fix' when TNsot==1, and [\#1560](https://github.com/uclouvain/openjpeg/pull/1560) ([rouault](https://github.com/rouault))
-- opj\_j2k\_setup\_encoder\(\): set numgbits = 1 for Cinema2K [\#1559](https://github.com/uclouvain/openjpeg/pull/1559) ([rouault](https://github.com/rouault))
-- bench\_dwt: Add assert for memory allocation failure [\#1555](https://github.com/uclouvain/openjpeg/pull/1555) ([hleft](https://github.com/hleft))
-- Add AVX2 and AVX512 optimization [\#1552](https://github.com/uclouvain/openjpeg/pull/1552) ([tszumski](https://github.com/tszumski))
-- Updated softprops/action-gh-release to v2 [\#1551](https://github.com/uclouvain/openjpeg/pull/1551) ([radarhere](https://github.com/radarhere))
-- Updated softprops/action-gh-release to v2 [\#1549](https://github.com/uclouvain/openjpeg/pull/1549) ([radarhere](https://github.com/radarhere))
-- fix: abi check [\#1548](https://github.com/uclouvain/openjpeg/pull/1548) ([mayeut](https://github.com/mayeut))
-- fix: when EPH markers are specified, they are required. [\#1547](https://github.com/uclouvain/openjpeg/pull/1547) ([mayeut](https://github.com/mayeut))
-- CI: add macOS arm64 [\#1546](https://github.com/uclouvain/openjpeg/pull/1546) ([mayeut](https://github.com/mayeut))
-- thirdparty/libz: update to zlib-1.3.1 [\#1542](https://github.com/uclouvain/openjpeg/pull/1542) ([rouault](https://github.com/rouault))
-- thirdparty/libpng: update to libpng-1.6.43 [\#1541](https://github.com/uclouvain/openjpeg/pull/1541) ([rouault](https://github.com/rouault))
-- thirdparty/libtiff: update to libtiff 4.6.0 [\#1540](https://github.com/uclouvain/openjpeg/pull/1540) ([rouault](https://github.com/rouault))
-- Use TLM \(Tile Length Marker\) segments to optimize decoding [\#1538](https://github.com/uclouvain/openjpeg/pull/1538) ([rouault](https://github.com/rouault))
-- Add new test for file with non-consecutive tilepart and TLM marker [\#1537](https://github.com/uclouvain/openjpeg/pull/1537) ([rouault](https://github.com/rouault))
-- Avoid heap-buffer-overflow read on corrupted image in non-strict mode [\#1536](https://github.com/uclouvain/openjpeg/pull/1536) ([rouault](https://github.com/rouault))
-- opj\_j2k\_read\_sod\(\): validate opj\_stream\_read\_data\(\) return to avoid … [\#1534](https://github.com/uclouvain/openjpeg/pull/1534) ([rouault](https://github.com/rouault))
-- Fixed typos [\#1532](https://github.com/uclouvain/openjpeg/pull/1532) ([radarhere](https://github.com/radarhere))
-- CI: pin macos job to macos-13 to get x86\_64 [\#1531](https://github.com/uclouvain/openjpeg/pull/1531) ([rouault](https://github.com/rouault))
-- Integer Overflow at j2k.c:9614 [\#1530](https://github.com/uclouvain/openjpeg/pull/1530) ([headshog](https://github.com/headshog))
-- Support setting enumcs for CMYK and EYCC color space [\#1529](https://github.com/uclouvain/openjpeg/pull/1529) ([radarhere](https://github.com/radarhere))
-- opj\_j2k\_decode\_tiles\(\): avoid use of uninitialized l\_current\_tile\_no variable [\#1528](https://github.com/uclouvain/openjpeg/pull/1528) ([rouault](https://github.com/rouault))
-- Updated actions/upload-artifact to v4 [\#1527](https://github.com/uclouvain/openjpeg/pull/1527) ([radarhere](https://github.com/radarhere))
-- Do not allow header length to be zero in non-zero length packet [\#1526](https://github.com/uclouvain/openjpeg/pull/1526) ([radarhere](https://github.com/radarhere))
-- Fix building on OpenBSD big endian hosts [\#1520](https://github.com/uclouvain/openjpeg/pull/1520) ([brad0](https://github.com/brad0))
-
-## [v2.5.2](https://github.com/uclouvain/openjpeg/releases/v2.5.2) (2024-02-28)
-
-[Full Changelog](https://github.com/uclouvain/openjpeg/compare/v2.5.1...v2.5.2)
-
-**Closed issues:**
-
-- API breakage in 2.5.1 / openjpeg version no longer detected \(openjpeg.h no longer includes opj\_config.h\) [\#1514](https://github.com/uclouvain/openjpeg/issues/1514)
-
-**Merged pull requests:**
-
-- openjpeg.h: make sure to include opj\_config.h \(fixes \#1514\) [\#1515](https://github.com/uclouvain/openjpeg/pull/1515) ([rouault](https://github.com/rouault))
-
-## [v2.5.1](https://github.com/uclouvain/openjpeg/releases/v2.5.1) (2024-02-26)
-
-[Full Changelog](https://github.com/uclouvain/openjpeg/compare/v2.5.0...v2.5.1)
-
-**Closed issues:**
-
-- Exist a undefined-behavior issue in file src/lib/openjp2/dwt.c:2124 [\#1505](https://github.com/uclouvain/openjpeg/issues/1505)
-- Potential double-free vulnerability in j2k.c [\#1498](https://github.com/uclouvain/openjpeg/issues/1498)
-- opj\_compress -I / -mct 0 should conflict each others [\#1485](https://github.com/uclouvain/openjpeg/issues/1485)
-- Exist a undefined-behavior issue in file src/lib/openjp2/tcd.c:2327 [\#1480](https://github.com/uclouvain/openjpeg/issues/1480)
-- OOM in opj\_decompress [\#1476](https://github.com/uclouvain/openjpeg/issues/1476)
-- v2.5.0 cannot be built successfully on aarch64 CentOS machine [\#1475](https://github.com/uclouvain/openjpeg/issues/1475)
-- \[ Heap Overflow \] opj\_decompress [\#1473](https://github.com/uclouvain/openjpeg/issues/1473)
-- Possible bug reading JP2 as grayscale when should be in color [\#1464](https://github.com/uclouvain/openjpeg/issues/1464)
-- Crashes due to internal bad memory references when using reduce on a truncated file. [\#1459](https://github.com/uclouvain/openjpeg/issues/1459)
-- No error.h \(non standard compliant\) [\#1453](https://github.com/uclouvain/openjpeg/issues/1453)
-- JP2 File incorrectly decompressed to noise [\#1447](https://github.com/uclouvain/openjpeg/issues/1447)
-- UB in tcd.c opj\_tcd\_dc\_level\_shift\_decode - pointer arithmetic on NULL pointer [\#1445](https://github.com/uclouvain/openjpeg/issues/1445)
-- UB in ht\_dec.c opj\_t1\_ht\_decode\_cblk - memcpy invoked on NULL pointer [\#1444](https://github.com/uclouvain/openjpeg/issues/1444)
-- Integer Overflow in `src/lib/openjp2/image.c` [\#1438](https://github.com/uclouvain/openjpeg/issues/1438)
-- Integer-overflow · opj\_t1\_encode\_cblk [\#1432](https://github.com/uclouvain/openjpeg/issues/1432)
-- OSX m1 v2.5.0 build fail [\#1430](https://github.com/uclouvain/openjpeg/issues/1430)
-- Pixel value could be changed by 0-4 after compression and decompression [\#1429](https://github.com/uclouvain/openjpeg/issues/1429)
-- Cannot determine library version at compile time [\#1428](https://github.com/uclouvain/openjpeg/issues/1428)
-- ARM builds on Windows unsupported with Version 2.5.0 [\#1422](https://github.com/uclouvain/openjpeg/issues/1422)
-- opj\_decompress heap overflow Denial of Service issue [\#1413](https://github.com/uclouvain/openjpeg/issues/1413)
-- Color channel swapping for some JPEG2000 pictures [\#1382](https://github.com/uclouvain/openjpeg/issues/1382)
-- Heap-buffer-overflow in color.c:379:42 in sycc420\_to\_rgb [\#1347](https://github.com/uclouvain/openjpeg/issues/1347)
-- No colorspace information after opj\_read\_header [\#570](https://github.com/uclouvain/openjpeg/issues/570)
-
-**Merged pull requests:**
-
-- opj\_t2\_read\_packet\_header\(\): avoid unsigned integer overflow [\#1511](https://github.com/uclouvain/openjpeg/pull/1511) ([rouault](https://github.com/rouault))
-- opj\_dwt\_decode\_tile\(\): avoid potential UndefinedBehaviorSanitizer 'applying zero offset to null pointer' \(fixes \#1505\) [\#1510](https://github.com/uclouvain/openjpeg/pull/1510) ([rouault](https://github.com/rouault))
-- opj\_decompress: fix off-by-one read heap-buffer-overflow in sycc420\_to\_rgb\(\) when x0 and y0 are odd \(CVE-2021-3575, fixes \#1347\) [\#1509](https://github.com/uclouvain/openjpeg/pull/1509) ([rouault](https://github.com/rouault))
-- Always install pkgconfig files [\#1507](https://github.com/uclouvain/openjpeg/pull/1507) ([kmilos](https://github.com/kmilos))
-- CMake: drop support for cmake \< 3.5 [\#1503](https://github.com/uclouvain/openjpeg/pull/1503) ([domin144](https://github.com/domin144))
-- Fix compiler error on Windows [\#1502](https://github.com/uclouvain/openjpeg/pull/1502) ([scaramallion](https://github.com/scaramallion))
-- opj\_tcd\_dc\_level\_shift\_decode\(\): avoid increment nullptr \(fixes \#1480\) [\#1496](https://github.com/uclouvain/openjpeg/pull/1496) ([rouault](https://github.com/rouault))
-- Fix CI [\#1495](https://github.com/uclouvain/openjpeg/pull/1495) ([rouault](https://github.com/rouault))
-- suppress warning during build using clang [\#1494](https://github.com/uclouvain/openjpeg/pull/1494) ([tomoaki0705](https://github.com/tomoaki0705))
-- Add cmake version file [\#1493](https://github.com/uclouvain/openjpeg/pull/1493) ([domin144](https://github.com/domin144))
-- fix ht\_dec.c:1215 [\#1492](https://github.com/uclouvain/openjpeg/pull/1492) ([headshog](https://github.com/headshog))
-- Integer Overflow at j2k.c:11114 [\#1491](https://github.com/uclouvain/openjpeg/pull/1491) ([headshog](https://github.com/headshog))
-- Integer Overflow at j2k.c:3962 [\#1490](https://github.com/uclouvain/openjpeg/pull/1490) ([headshog](https://github.com/headshog))
-- Fixed typos [\#1486](https://github.com/uclouvain/openjpeg/pull/1486) ([radarhere](https://github.com/radarhere))
-- Require `stdint.h` & `inttypes.h` [\#1484](https://github.com/uclouvain/openjpeg/pull/1484) ([mayeut](https://github.com/mayeut))
-- fix: use `opj_uint_ceildiv` instead of `opj_int_ceildiv` when necessary [\#1482](https://github.com/uclouvain/openjpeg/pull/1482) ([mayeut](https://github.com/mayeut))
-- ht\_dec.c: Improve MSVC arm64 popcount performance [\#1479](https://github.com/uclouvain/openjpeg/pull/1479) ([PeterJohnson](https://github.com/PeterJohnson))
-- opj\_jp2\_read\_header\(\): move setting color\_space here instead in opj\_jp2\_decode\(\)/get\_tile\(\) \(fixes \#570\) [\#1463](https://github.com/uclouvain/openjpeg/pull/1463) ([rouault](https://github.com/rouault))
-- CMake: error out on warnings for strict/missing prototypes. [\#1462](https://github.com/uclouvain/openjpeg/pull/1462) ([sebras](https://github.com/sebras))
-- Fix CI [\#1461](https://github.com/uclouvain/openjpeg/pull/1461) ([rouault](https://github.com/rouault))
-- opj\_t2\_skip\_packet\_data\(\): avoid out-of-bounds reads on truncated images in non-strict mode \(fixes \#1459\) [\#1460](https://github.com/uclouvain/openjpeg/pull/1460) ([rouault](https://github.com/rouault))
-- Fix \#1424 [\#1456](https://github.com/uclouvain/openjpeg/pull/1456) ([autoantwort](https://github.com/autoantwort))
-- openjp2/j2k: replace sprintf calls with snprintf [\#1450](https://github.com/uclouvain/openjpeg/pull/1450) ([markmentovai](https://github.com/markmentovai))
-- Fix incorrect decoding of image with large number of progression levels [\#1448](https://github.com/uclouvain/openjpeg/pull/1448) ([rouault](https://github.com/rouault))
-- Fix Heap-buffer-overflow READ in opj\_jp2\_apply\_pclr [\#1441](https://github.com/uclouvain/openjpeg/pull/1441) ([sashashura](https://github.com/sashashura))
-- Significant speed-up rate allocation by rate/distoratio ratio [\#1440](https://github.com/uclouvain/openjpeg/pull/1440) ([rouault](https://github.com/rouault))
-- Make OpenJPEGConfig.cmake relocatable with CMake \> 3.0 [\#1439](https://github.com/uclouvain/openjpeg/pull/1439) ([arichardson](https://github.com/arichardson))
-- Replace the assert in mel\_init to an if statement to address an issue with fuzzing. [\#1436](https://github.com/uclouvain/openjpeg/pull/1436) ([aous72](https://github.com/aous72))
-- opj\_t1\_encode\_cblk\(\): avoid undefined behaviour on fuzzed input \(fixes \#1432\) [\#1433](https://github.com/uclouvain/openjpeg/pull/1433) ([rouault](https://github.com/rouault))
-- Build: fix linking of executables on some systems where TIFF/LCMS2 static libraries are not in system directories \(fixes \#1430\) [\#1431](https://github.com/uclouvain/openjpeg/pull/1431) ([rouault](https://github.com/rouault))
-- Fix opj\_t1\_allocate\_buffers malloc size error [\#1426](https://github.com/uclouvain/openjpeg/pull/1426) ([zodf0055980](https://github.com/zodf0055980))
-- Switch to GNUInstallDirs \[v2\] [\#1424](https://github.com/uclouvain/openjpeg/pull/1424) ([laumann](https://github.com/laumann))
-- Fix windows arm builds [\#1423](https://github.com/uclouvain/openjpeg/pull/1423) ([Neumann-A](https://github.com/Neumann-A))
-- pkgconfig: Define OPJ\_STATIC for static linking with pkgconf [\#1421](https://github.com/uclouvain/openjpeg/pull/1421) ([Biswa96](https://github.com/Biswa96))
-
-
-## [v2.5.0](https://github.com/uclouvain/openjpeg/releases/v2.5.0) (2022-05-13)
-
-[Full Changelog](https://github.com/uclouvain/openjpeg/compare/v2.4.0...v2.5.0)
-
-**Merged pull requests:**
-
-- tools/travis-ci/install.sh: git clone with https:// to fix 'The unaut… [\#1419](https://github.com/uclouvain/openjpeg/pull/1419) ([rouault](https://github.com/rouault))
-- Java Support 1.8 now... [\#1418](https://github.com/uclouvain/openjpeg/pull/1418) ([jiapei100](https://github.com/jiapei100))
-- Separate fuzz targets to increase coverage [\#1416](https://github.com/uclouvain/openjpeg/pull/1416) ([Navidem](https://github.com/Navidem))
-- CMakeLists.txt: do not set INSTALL\_NAME\_DIR for MacOS builds for CMake \>= 3.0 \(fixes \#1404\) [\#1410](https://github.com/uclouvain/openjpeg/pull/1410) ([rouault](https://github.com/rouault))
-- Avoid integer overflows in DWT. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=44544 [\#1408](https://github.com/uclouvain/openjpeg/pull/1408) ([rouault](https://github.com/rouault))
-- Updated "added support for partial bitstream decoding" [\#1407](https://github.com/uclouvain/openjpeg/pull/1407) ([Neopallium](https://github.com/Neopallium))
-- opj\_encoder\_set\_extra\_options\(\): add a GUARD\_BITS=value option [\#1403](https://github.com/uclouvain/openjpeg/pull/1403) ([rouault](https://github.com/rouault))
-- More overflow related bug fixes [\#1402](https://github.com/uclouvain/openjpeg/pull/1402) ([Eharve14](https://github.com/Eharve14))
-- opj\_j2k\_setup\_encoder\(\): validate number of tiles to avoid illegal values and potential overflow \(fixes \#1399\) [\#1401](https://github.com/uclouvain/openjpeg/pull/1401) ([rouault](https://github.com/rouault))
-- Missed conversion from unsigned int to OPJ\_INT32 [\#1398](https://github.com/uclouvain/openjpeg/pull/1398) ([Eharve14](https://github.com/Eharve14))
-- Added check for integer overflow in get\_num\_images [\#1397](https://github.com/uclouvain/openjpeg/pull/1397) ([Eharve14](https://github.com/Eharve14))
-- Added overflow check for CVE-2021-29338 [\#1396](https://github.com/uclouvain/openjpeg/pull/1396) ([Eharve14](https://github.com/Eharve14))
-- Fix integer overflow in num\_images [\#1395](https://github.com/uclouvain/openjpeg/pull/1395) ([baparham](https://github.com/baparham))
-- Remove duplicate assignments in function tiftoimage [\#1392](https://github.com/uclouvain/openjpeg/pull/1392) ([stweil](https://github.com/stweil))
-- Fix some typos \(found by codespell\) [\#1390](https://github.com/uclouvain/openjpeg/pull/1390) ([stweil](https://github.com/stweil))
-- CI: Add CIFuzz action [\#1386](https://github.com/uclouvain/openjpeg/pull/1386) ([DavidKorczynski](https://github.com/DavidKorczynski))
-- Feature/decimation [\#1384](https://github.com/uclouvain/openjpeg/pull/1384) ([msheby](https://github.com/msheby))
-- API: deprecate 'bpp' member in favor of 'prec' [\#1383](https://github.com/uclouvain/openjpeg/pull/1383) ([rouault](https://github.com/rouault))
-- Added support for high throughput \(HTJ2K\) decoding. [\#1381](https://github.com/uclouvain/openjpeg/pull/1381) ([rouault](https://github.com/rouault))
-- verify-indentation.sh: fix for pull request from bar/master to foo/master [\#1380](https://github.com/uclouvain/openjpeg/pull/1380) ([rouault](https://github.com/rouault))
-- Change integer for version libtiff 4.3.0 [\#1377](https://github.com/uclouvain/openjpeg/pull/1377) ([Jamaika1](https://github.com/Jamaika1))
-- Port continuous integration to github actions [\#1376](https://github.com/uclouvain/openjpeg/pull/1376) ([rouault](https://github.com/rouault))
-- Avoid integer overflows in DWT. [\#1375](https://github.com/uclouvain/openjpeg/pull/1375) ([rouault](https://github.com/rouault))
-- LGTM warning: Comparison result is always the same [\#1373](https://github.com/uclouvain/openjpeg/pull/1373) ([DimitriPapadopoulos](https://github.com/DimitriPapadopoulos))
-- A couple typos found by codespell [\#1371](https://github.com/uclouvain/openjpeg/pull/1371) ([DimitriPapadopoulos](https://github.com/DimitriPapadopoulos))
-- cmake: add install interface include directory [\#1370](https://github.com/uclouvain/openjpeg/pull/1370) ([madebr](https://github.com/madebr))
-- fix issues 1368: exist a issues of freeing uninitialized pointer in src/bin/jp2/opj\_decompress.c,that will cause a segfault [\#1369](https://github.com/uclouvain/openjpeg/pull/1369) ([xiaoxiaoafeifei](https://github.com/xiaoxiaoafeifei))
-- opj\_j2k\_is\_imf\_compliant: Fix out of bounds access [\#1366](https://github.com/uclouvain/openjpeg/pull/1366) ([sebras](https://github.com/sebras))
-- opj\_j2k\_is\_imf\_compliant: Fix argument formatting for warnings. [\#1365](https://github.com/uclouvain/openjpeg/pull/1365) ([sebras](https://github.com/sebras))
-- CMakeLists.txt/appveyor.yml: update version number to 2.5.0… [\#1361](https://github.com/uclouvain/openjpeg/pull/1361) ([rouault](https://github.com/rouault))
-- .travis.yml: try to fix gcc 4.8 config by updating to xenial [\#1360](https://github.com/uclouvain/openjpeg/pull/1360) ([rouault](https://github.com/rouault))
-- Add support for enabling generation of TLM markers in encoder [\#1359](https://github.com/uclouvain/openjpeg/pull/1359) ([rouault](https://github.com/rouault))
-- Fix various compiler warnings [\#1358](https://github.com/uclouvain/openjpeg/pull/1358) ([rouault](https://github.com/rouault))
-- fix \#1345: don't remove big endian test for other platforms [\#1354](https://github.com/uclouvain/openjpeg/pull/1354) ([msabwat](https://github.com/msabwat))
-- Remove obsolete components JPWL, JP3D and MJ2 [\#1350](https://github.com/uclouvain/openjpeg/pull/1350) ([rouault](https://github.com/rouault))
-- tools/travis-ci/install.sh: fix links to Kakadu and jpylyzer binaries [\#1348](https://github.com/uclouvain/openjpeg/pull/1348) ([rouault](https://github.com/rouault))
-- emscripten: disable big endian test [\#1345](https://github.com/uclouvain/openjpeg/pull/1345) ([msabwat](https://github.com/msabwat))
-- Fix cmake file with DESTDIR [\#1321](https://github.com/uclouvain/openjpeg/pull/1321) ([ffontaine](https://github.com/ffontaine))
-- CMakeLists.txt: Don't require a C++ compiler [\#1317](https://github.com/uclouvain/openjpeg/pull/1317) ([ffontaine](https://github.com/ffontaine))
-- Import files tiff and yuv\(raw\) [\#1316](https://github.com/uclouvain/openjpeg/pull/1316) ([Jamaika1](https://github.com/Jamaika1))
-- Fix year in NEWS [\#1312](https://github.com/uclouvain/openjpeg/pull/1312) ([stweil](https://github.com/stweil))
-- Fix lcms2 static linking using pgk config [\#867](https://github.com/uclouvain/openjpeg/pull/867) ([pseiderer](https://github.com/pseiderer))
-- fix static build only against tiff and its indirect dependencies [\#866](https://github.com/uclouvain/openjpeg/pull/866) ([tSed](https://github.com/tSed))
-
-
-**Closed issues:**
-
-- integer constant is too large for 'long' type [\#61](https://github.com/uclouvain/openjpeg/issues/61)
-- Openjpeg3D lossy compression not working [\#501](https://github.com/uclouvain/openjpeg/issues/501)
-- mj2: Array overflow [\#485](https://github.com/uclouvain/openjpeg/issues/485)
-- OPJ fails to decode image that KDU manages correctly [\#419](https://github.com/uclouvain/openjpeg/issues/419)
-- yuvtoimage\(\) bug in v1 and v2 for 16-Bit: please apply ASAP [\#384](https://github.com/uclouvain/openjpeg/issues/384)
-- JP3D: Fix CVE-2013-4289 CVE-2013-4290 [\#298](https://github.com/uclouvain/openjpeg/issues/298)
-- MJ2 libraries are installed in lib [\#204](https://github.com/uclouvain/openjpeg/issues/204)
-- MJ2: realloc is misused and may leak memory [\#168](https://github.com/uclouvain/openjpeg/issues/168)
-- MJ2 wrapper not functional [\#143](https://github.com/uclouvain/openjpeg/issues/143)
-- JPWL is broken in trunk [\#137](https://github.com/uclouvain/openjpeg/issues/137)
-- MJ2 files not using OPENJPEG API correctly [\#53](https://github.com/uclouvain/openjpeg/issues/53)
-- Maximum bit depth supported by the OpenJPEG implementation of JP3D [\#9](https://github.com/uclouvain/openjpeg/issues/9)
-- does openjpeg support either visually lossless or numerically lossless jpeg2000 compression? [\#1406](https://github.com/uclouvain/openjpeg/issues/1406)
-- extract jpeg2000 tile without decompression [\#1405](https://github.com/uclouvain/openjpeg/issues/1405)
-- openjpeg doesn't install a relocatable shared lib on macOS [\#1404](https://github.com/uclouvain/openjpeg/issues/1404)
-- pull request - the cinema industry awaits! [\#1400](https://github.com/uclouvain/openjpeg/issues/1400)
-- Integer overflows in j2K [\#1399](https://github.com/uclouvain/openjpeg/issues/1399)
-- why lossly compression performance worse than jpeg when compress png? [\#1393](https://github.com/uclouvain/openjpeg/issues/1393)
-- cect [\#1389](https://github.com/uclouvain/openjpeg/issues/1389)
-- the docs don't describe bpp and prec in opj\_image\_comp very well [\#1379](https://github.com/uclouvain/openjpeg/issues/1379)
-- converting .png to .jp2 by opj\_compress is different from the original image [\#1378](https://github.com/uclouvain/openjpeg/issues/1378)
-- Comparison result is always the same [\#1372](https://github.com/uclouvain/openjpeg/issues/1372)
-- Exist a issues of freeing uninitialized pointer in src/bin/jp2/opj\_decompress.c,that will cause a segfault [\#1368](https://github.com/uclouvain/openjpeg/issues/1368)
-- \[TEST NOT RUNNING\]: bigendian test [\#1355](https://github.com/uclouvain/openjpeg/issues/1355)
-- opj\_decompress 2.4.0 built with library 2.3.0. [\#1352](https://github.com/uclouvain/openjpeg/issues/1352)
-- New library htjpeg2000 [\#1351](https://github.com/uclouvain/openjpeg/issues/1351)
-- Integer Overflow in num\_images [\#1338](https://github.com/uclouvain/openjpeg/issues/1338)
-- All IMF Profile Selections Result in PART1 [\#1337](https://github.com/uclouvain/openjpeg/issues/1337)
-- grayscale image [\#1334](https://github.com/uclouvain/openjpeg/issues/1334)
-- error C2169: 'lrintf': intrinsic function, cannot be defined [\#1333](https://github.com/uclouvain/openjpeg/issues/1333)
-- Generate lower-case extension [\#1332](https://github.com/uclouvain/openjpeg/issues/1332)
-- color of reconstructed png file much darker [\#1330](https://github.com/uclouvain/openjpeg/issues/1330)
-- CVE-2019-6988, CVE-2018-20846 and CVE-2018-16376 [\#1328](https://github.com/uclouvain/openjpeg/issues/1328)
-- opj 2.4.0: opj\_free missing in opj3d [\#1327](https://github.com/uclouvain/openjpeg/issues/1327)
-- Not able to compress volumetric data [\#1326](https://github.com/uclouvain/openjpeg/issues/1326)
-- HTML documents are not installed in specified place [\#1322](https://github.com/uclouvain/openjpeg/issues/1322)
-- Can't find openjpeg.h when cross-compile. [\#1320](https://github.com/uclouvain/openjpeg/issues/1320)
-- OpenJPEG is available with EasyConfig [\#1319](https://github.com/uclouvain/openjpeg/issues/1319)
-- Building Test Programs [\#1318](https://github.com/uclouvain/openjpeg/issues/1318)
-- Builds are not reproducible [\#1275](https://github.com/uclouvain/openjpeg/issues/1275)
-- strange behaviour of opj\_jp3d\_compress/decompress utility [\#1274](https://github.com/uclouvain/openjpeg/issues/1274)
-- Potential heap-based buffer overflow in function t2\_encode\_packet in src/lib/openmj2/t2.c and src/lib/openjp3d/t2.c [\#1272](https://github.com/uclouvain/openjpeg/issues/1272)
-- Function tgatoimage in src/bin/jpwl/convert.c need to check that the file is big enough to avoid excessive memory allocations [\#1271](https://github.com/uclouvain/openjpeg/issues/1271)
-- memory & cpu are exhausted when converting jp2 file into png [\#1250](https://github.com/uclouvain/openjpeg/issues/1250)
-- Cannot compress PGX into JP3D despite following the directions? [\#1134](https://github.com/uclouvain/openjpeg/issues/1134)
-- sscanf buffer overflow in opj\_jp3d\_compress.c [\#1130](https://github.com/uclouvain/openjpeg/issues/1130)
-- integer underflow may lead to writing garbage [\#1089](https://github.com/uclouvain/openjpeg/issues/1089)
-- sscanf buffer overflow [\#1087](https://github.com/uclouvain/openjpeg/issues/1087)
-- strcpy overflows [\#1086](https://github.com/uclouvain/openjpeg/issues/1086)
-- sprintf buffer overflows [\#1084](https://github.com/uclouvain/openjpeg/issues/1084)
-- strcpy buffer overflow [\#1083](https://github.com/uclouvain/openjpeg/issues/1083)
-- integer overflow in malloc\(\) [\#1082](https://github.com/uclouvain/openjpeg/issues/1082)
-- out of bounds writes [\#1078](https://github.com/uclouvain/openjpeg/issues/1078)
-- out of bounds writes [\#1077](https://github.com/uclouvain/openjpeg/issues/1077)
-- divide by zero, perhaps multiplication overflow [\#1076](https://github.com/uclouvain/openjpeg/issues/1076)
-- missing format string parameter [\#1075](https://github.com/uclouvain/openjpeg/issues/1075)
-- leaks from cppcheck in lib folder [\#1038](https://github.com/uclouvain/openjpeg/issues/1038)
-- How to initialize DEBUG\_PROFILE in color.c? [\#958](https://github.com/uclouvain/openjpeg/issues/958)
-- JP3D sample files [\#865](https://github.com/uclouvain/openjpeg/issues/865)
-- BIG\_ENDIAN bug in jpwl.c [\#839](https://github.com/uclouvain/openjpeg/issues/839)
-- OpenJPEG fails to decode partial j2c where kdu succeeds [\#715](https://github.com/uclouvain/openjpeg/issues/715)
-- building mj2 binaries fails [\#652](https://github.com/uclouvain/openjpeg/issues/652)
-- openmj2\mj2.c: Out of bounds [\#646](https://github.com/uclouvain/openjpeg/issues/646)
-- bin\mj2\opj\_mj2\_decompress.c 101 wrong check / leak [\#608](https://github.com/uclouvain/openjpeg/issues/608)
-
-
-## [v2.4.0](https://github.com/uclouvain/openjpeg/releases/v2.4.0) (2020-12-28)
-
-[Full Changelog](https://github.com/uclouvain/openjpeg/compare/v2.3.1...v2.4.0)
-
-**Closed issues:**
-
-- OPENJPEG\_INSTALL\_DOC\_DIR does not control a destination directory where HTML docs would be installed. [\#1309](https://github.com/uclouvain/openjpeg/issues/1309)
-- Heap-buffer-overflow in lib/openjp2/pi.c:312 [\#1302](https://github.com/uclouvain/openjpeg/issues/1302)
-- Heap-buffer-overflow in lib/openjp2/t2.c:973 [\#1299](https://github.com/uclouvain/openjpeg/issues/1299)
-- Heap-buffer-overflow in lib/openjp2/pi.c:623 [\#1293](https://github.com/uclouvain/openjpeg/issues/1293)
-- Global-buffer-overflow in lib/openjp2/dwt.c:1980 [\#1286](https://github.com/uclouvain/openjpeg/issues/1286)
-- Heap-buffer-overflow in lib/openjp2/tcd.c:2417 [\#1284](https://github.com/uclouvain/openjpeg/issues/1284)
-- Heap-buffer-overflow in lib/openjp2/mqc.c:499 [\#1283](https://github.com/uclouvain/openjpeg/issues/1283)
-- Openjpeg could not encode 32bit RGB float image [\#1281](https://github.com/uclouvain/openjpeg/issues/1281)
-- Openjpeg could not encode 32bit RGB float image [\#1280](https://github.com/uclouvain/openjpeg/issues/1280)
-- ISO/IEC 15444-1:2019 \(E\) compared with 'cio.h' [\#1277](https://github.com/uclouvain/openjpeg/issues/1277)
-- Test-suite failure due to hash mismatch [\#1264](https://github.com/uclouvain/openjpeg/issues/1264)
-- Heap use-after-free [\#1261](https://github.com/uclouvain/openjpeg/issues/1261)
-- Memory leak when failing to allocate object... [\#1259](https://github.com/uclouvain/openjpeg/issues/1259)
-- Memory leak of Tier 1 handle when OpenJPEG fails to set it as TLS... [\#1257](https://github.com/uclouvain/openjpeg/issues/1257)
-- Any plan to build release for CVE-2020-8112/CVE-2020-6851 [\#1247](https://github.com/uclouvain/openjpeg/issues/1247)
-- failing to convert 16-bit file: opj\_t2\_encode\_packet\(\): only 5251 bytes remaining in output buffer. 5621 needed. [\#1243](https://github.com/uclouvain/openjpeg/issues/1243)
-- CMake+VS2017 Compile OK, thirdparty Compile OK, but thirdparty not install [\#1239](https://github.com/uclouvain/openjpeg/issues/1239)
-- New release to solve CVE-2019-6988 ? [\#1238](https://github.com/uclouvain/openjpeg/issues/1238)
-- Many tests fail to pass after the update of libtiff to version 4.1.0 [\#1233](https://github.com/uclouvain/openjpeg/issues/1233)
-- Another heap buffer overflow in libopenjp2 [\#1231](https://github.com/uclouvain/openjpeg/issues/1231)
-- Heap buffer overflow in libopenjp2 [\#1228](https://github.com/uclouvain/openjpeg/issues/1228)
-- Endianness of binary volume \(JP3D\) [\#1224](https://github.com/uclouvain/openjpeg/issues/1224)
-- New release to resolve CVE-2019-12973 [\#1222](https://github.com/uclouvain/openjpeg/issues/1222)
-- how to set the block size,like 128,256 ? [\#1216](https://github.com/uclouvain/openjpeg/issues/1216)
-- compress YUV files to motion jpeg2000 standard [\#1213](https://github.com/uclouvain/openjpeg/issues/1213)
-- Repair/update Java wrapper, and include in release [\#1208](https://github.com/uclouvain/openjpeg/issues/1208)
-- abc [\#1206](https://github.com/uclouvain/openjpeg/issues/1206)
-- Slow decoding [\#1202](https://github.com/uclouvain/openjpeg/issues/1202)
-- Installation question [\#1201](https://github.com/uclouvain/openjpeg/issues/1201)
-- Typo in test\_decode\_area - \*ptilew is assigned instead of \*ptileh [\#1195](https://github.com/uclouvain/openjpeg/issues/1195)
-- Creating a J2K file with one POC is broken [\#1191](https://github.com/uclouvain/openjpeg/issues/1191)
-- Make fails on Arch Linux [\#1174](https://github.com/uclouvain/openjpeg/issues/1174)
-- Heap buffer overflow in opj\_t1\_clbl\_decode\_processor\(\) triggered with Ghostscript [\#1158](https://github.com/uclouvain/openjpeg/issues/1158)
-- opj\_stream\_get\_number\_byte\_left: Assertion `p\_stream-\>m\_byte\_offset \>= 0' failed. [\#1151](https://github.com/uclouvain/openjpeg/issues/1151)
-- The fuzzer ignores too many inputs [\#1079](https://github.com/uclouvain/openjpeg/issues/1079)
-- out of bounds read [\#1068](https://github.com/uclouvain/openjpeg/issues/1068)
-
-**Merged pull requests:**
-
-- Change defined WIN32 [\#1310](https://github.com/uclouvain/openjpeg/pull/1310) ([Jamaika1](https://github.com/Jamaika1))
-- docs: fix simple typo, producted -\> produced [\#1308](https://github.com/uclouvain/openjpeg/pull/1308) ([timgates42](https://github.com/timgates42))
-- Set ${OPENJPEG\_INSTALL\_DOC\_DIR} to DESTINATION of HTMLs [\#1307](https://github.com/uclouvain/openjpeg/pull/1307) ([lemniscati](https://github.com/lemniscati))
-- Use INC\_DIR for OPENJPEG\_INCLUDE\_DIRS \(fixes uclouvain\#1174\) [\#1306](https://github.com/uclouvain/openjpeg/pull/1306) ([matthew-sharp](https://github.com/matthew-sharp))
-- pi.c: avoid out of bounds access with POC \(fixes \#1302\) [\#1304](https://github.com/uclouvain/openjpeg/pull/1304) ([rouault](https://github.com/rouault))
-- Encoder: grow again buffer size [\#1303](https://github.com/uclouvain/openjpeg/pull/1303) ([zodf0055980](https://github.com/zodf0055980))
-- opj\_j2k\_write\_sod\(\): avoid potential heap buffer overflow \(fixes \#1299\) \(probably master only\) [\#1301](https://github.com/uclouvain/openjpeg/pull/1301) ([rouault](https://github.com/rouault))
-- pi.c: avoid out of bounds access with POC \(refs https://github.com/uclouvain/openjpeg/issues/1293\#issuecomment-737122836\) [\#1300](https://github.com/uclouvain/openjpeg/pull/1300) ([rouault](https://github.com/rouault))
-- opj\_t2\_encode\_packet\(\): avoid out of bound access of \#1297, but likely not the proper fix [\#1298](https://github.com/uclouvain/openjpeg/pull/1298) ([rouault](https://github.com/rouault))
-- opj\_t2\_encode\_packet\(\): avoid out of bound access of \#1294, but likely not the proper fix [\#1296](https://github.com/uclouvain/openjpeg/pull/1296) ([rouault](https://github.com/rouault))
-- opj\_j2k\_setup\_encoder\(\): validate POC compno0 and compno1 \(fixes \#1293\) [\#1295](https://github.com/uclouvain/openjpeg/pull/1295) ([rouault](https://github.com/rouault))
-- Encoder: avoid global buffer overflow on irreversible conversion when… [\#1292](https://github.com/uclouvain/openjpeg/pull/1292) ([rouault](https://github.com/rouault))
-- Decoding: deal with some SPOT6 images that have tiles with a single tile-part with TPsot == 0 and TNsot == 0, and with missing EOC [\#1291](https://github.com/uclouvain/openjpeg/pull/1291) ([rouault](https://github.com/rouault))
-- Free p\_tcd\_marker\_info to avoid memory leak [\#1288](https://github.com/uclouvain/openjpeg/pull/1288) ([zodf0055980](https://github.com/zodf0055980))
-- Encoder: grow again buffer size [\#1287](https://github.com/uclouvain/openjpeg/pull/1287) ([zodf0055980](https://github.com/zodf0055980))
-- Encoder: avoid uint32 overflow when allocating memory for codestream buffer \(fixes \#1243\) [\#1276](https://github.com/uclouvain/openjpeg/pull/1276) ([rouault](https://github.com/rouault))
-- Java compatibility from 1.5 to 1.6 [\#1263](https://github.com/uclouvain/openjpeg/pull/1263) ([jiapei100](https://github.com/jiapei100))
-- opj\_decompress: fix double-free on input directory with mix of valid and invalid images [\#1262](https://github.com/uclouvain/openjpeg/pull/1262) ([rouault](https://github.com/rouault))
-- openjp2: Plug image leak when failing to allocate codestream index. [\#1260](https://github.com/uclouvain/openjpeg/pull/1260) ([sebras](https://github.com/sebras))
-- openjp2: Plug memory leak when setting data as TLS fails. [\#1258](https://github.com/uclouvain/openjpeg/pull/1258) ([sebras](https://github.com/sebras))
-- openjp2: Error out if failing to create Tier 1 handle. [\#1256](https://github.com/uclouvain/openjpeg/pull/1256) ([sebras](https://github.com/sebras))
-- Testing for invalid values of width, height, numcomps [\#1254](https://github.com/uclouvain/openjpeg/pull/1254) ([szukw000](https://github.com/szukw000))
-- Single-threaded performance improvements in forward DWT for 5-3 and 9-7 \(and other improvements\) [\#1253](https://github.com/uclouvain/openjpeg/pull/1253) ([rouault](https://github.com/rouault))
-- Add support for multithreading in encoder [\#1248](https://github.com/uclouvain/openjpeg/pull/1248) ([rouault](https://github.com/rouault))
-- Add support for generation of PLT markers in encoder [\#1246](https://github.com/uclouvain/openjpeg/pull/1246) ([rouault](https://github.com/rouault))
-- Fix warnings about signed/unsigned casts in pi.c [\#1244](https://github.com/uclouvain/openjpeg/pull/1244) ([rouault](https://github.com/rouault))
-- opj\_decompress: add sanity checks to avoid segfault in case of decoding error [\#1240](https://github.com/uclouvain/openjpeg/pull/1240) ([rouault](https://github.com/rouault))
-- ignore wrong icc [\#1236](https://github.com/uclouvain/openjpeg/pull/1236) ([szukw000](https://github.com/szukw000))
-- Implement writing of IMF profiles [\#1235](https://github.com/uclouvain/openjpeg/pull/1235) ([rouault](https://github.com/rouault))
-- tests: add alternate checksums for libtiff 4.1 [\#1234](https://github.com/uclouvain/openjpeg/pull/1234) ([rouault](https://github.com/rouault))
-- opj\_tcd\_init\_tile\(\): avoid integer overflow [\#1232](https://github.com/uclouvain/openjpeg/pull/1232) ([rouault](https://github.com/rouault))
-- tests/fuzzers: link fuzz binaries using $LIB\_FUZZING\_ENGINE. [\#1230](https://github.com/uclouvain/openjpeg/pull/1230) ([Dor1s](https://github.com/Dor1s))
-- opj\_j2k\_update\_image\_dimensions\(\): reject images whose coordinates are beyond INT\_MAX \(fixes \#1228\) [\#1229](https://github.com/uclouvain/openjpeg/pull/1229) ([rouault](https://github.com/rouault))
-- Fix resource leaks [\#1226](https://github.com/uclouvain/openjpeg/pull/1226) ([dodys](https://github.com/dodys))
-- abi-check.sh: fix false positive ABI error, and display output error log [\#1218](https://github.com/uclouvain/openjpeg/pull/1218) ([rouault](https://github.com/rouault))
-- pi.c: avoid integer overflow, resulting in later invalid access to memory in opj\_t2\_decode\_packets\(\) [\#1217](https://github.com/uclouvain/openjpeg/pull/1217) ([rouault](https://github.com/rouault))
-- Add check to validate SGcod/SPcoc/SPcod parameter values. [\#1211](https://github.com/uclouvain/openjpeg/pull/1211) ([sebras](https://github.com/sebras))
-- Fix buffer overflow reading an image file less than four characters [\#1196](https://github.com/uclouvain/openjpeg/pull/1196) ([robert-ancell](https://github.com/robert-ancell))
-- compression: emit POC marker when only one single POC is requested \(f… [\#1192](https://github.com/uclouvain/openjpeg/pull/1192) ([rouault](https://github.com/rouault))
-- Fix several potential vulnerabilities [\#1185](https://github.com/uclouvain/openjpeg/pull/1185) ([Young-X](https://github.com/Young-X))
-- openjp2/j2k: Report error if all wanted components are not decoded. [\#1164](https://github.com/uclouvain/openjpeg/pull/1164) ([sebras](https://github.com/sebras))
-
-## [v2.3.1](https://github.com/uclouvain/openjpeg/releases/v2.3.1) (2019-04-02)
-[Full Changelog](https://github.com/uclouvain/openjpeg/compare/v2.3.0...v2.3.1)
-
-**Closed issues:**
-
-- v2.2.0 regression for decoding images where TNsot == 0 [\#1120](https://github.com/uclouvain/openjpeg/issues/1120)
-- Int overflow in jp3d [\#1162](https://github.com/uclouvain/openjpeg/issues/1162)
-- Heap buffer overflow in opj\_j2k\_update\_image\_data\(\) triggered with Ghostscript [\#1157](https://github.com/uclouvain/openjpeg/issues/1157)
-- LINUX install doesn't work when building shared libraries is disabled [\#1155](https://github.com/uclouvain/openjpeg/issues/1155)
-- OPENJPEG null ptr dereference in openjpeg-2.3.0/src/bin/jp2/convert.c:2243 [\#1152](https://github.com/uclouvain/openjpeg/issues/1152)
-- How to drop certain subbands/layers in DWT [\#1147](https://github.com/uclouvain/openjpeg/issues/1147)
-- where is the MQ-Coder output stream in t2.c? [\#1146](https://github.com/uclouvain/openjpeg/issues/1146)
-- OpenJPEG 2.3 \(and 2.2?\) multi component image fails to decode with KDU v7.10 [\#1132](https://github.com/uclouvain/openjpeg/issues/1132)
-- Missing checks for header\_info.height and header\_info.width in function pnmtoimage in src/bin/jpwl/convert.c, which can lead to heap buffer overflow [\#1126](https://github.com/uclouvain/openjpeg/issues/1126)
-- Assertion Failure in jp2.c [\#1125](https://github.com/uclouvain/openjpeg/issues/1125)
-- Division-by-zero vulnerabilities in the function pi\_next\_pcrl, pi\_next\_cprl and pi\_next\_rpcl in src/lib/openjp3d/pi.c [\#1123](https://github.com/uclouvain/openjpeg/issues/1123)
-- Precinct switch \(-c\) doesn't right-shift last record to remaining resolution levels [\#1117](https://github.com/uclouvain/openjpeg/issues/1117)
-- Sample: encode J2K a data using streams??? [\#1114](https://github.com/uclouvain/openjpeg/issues/1114)
-- HIGH THROUGHPUT JPEG 2000 \(HTJ2K\) [\#1112](https://github.com/uclouvain/openjpeg/issues/1112)
-- How to build openjpeg for arm linux? [\#1108](https://github.com/uclouvain/openjpeg/issues/1108)
-- crash [\#1106](https://github.com/uclouvain/openjpeg/issues/1106)
-- JP2000 returning OPJ\_CLRSPC\_UNKNOWN color space [\#1103](https://github.com/uclouvain/openjpeg/issues/1103)
-- Compilation successful but install unsuccessful: Calling executables throws libraries missing error [\#1102](https://github.com/uclouvain/openjpeg/issues/1102)
-- fprintf format string requires 1 parameter but only 0 are given [\#1093](https://github.com/uclouvain/openjpeg/issues/1093)
-- fprintf format string requires 1 parameter but only 0 are given [\#1092](https://github.com/uclouvain/openjpeg/issues/1092)
-- sprintf buffer overflow [\#1088](https://github.com/uclouvain/openjpeg/issues/1088)
-- sprintf buffer overflow [\#1085](https://github.com/uclouvain/openjpeg/issues/1085)
-- Infinite loop when reading jp2 [\#1081](https://github.com/uclouvain/openjpeg/issues/1081)
-- missing format string parameter [\#1074](https://github.com/uclouvain/openjpeg/issues/1074)
-- Excessive Iteration in opj\_t1\_encode\_cblks \(src/lib/openjp2/t1.c\) [\#1059](https://github.com/uclouvain/openjpeg/issues/1059)
-- Out-of-bound left shift in opj\_j2k\_setup\_encoder \(src/lib/openjp2/j2k.c\) [\#1057](https://github.com/uclouvain/openjpeg/issues/1057)
-- Encode image on Unsplash [\#1054](https://github.com/uclouvain/openjpeg/issues/1054)
-- Integer overflow in opj\_t1\_encode\_cblks \(src/lib/openjp2/t1.c\) [\#1053](https://github.com/uclouvain/openjpeg/issues/1053)
-- Signed Integer Overflow - 68065512 [\#1048](https://github.com/uclouvain/openjpeg/issues/1048)
-- Similar vulnerable functions related to CVE-2017-14041 [\#1044](https://github.com/uclouvain/openjpeg/issues/1044)
-- \[ERROR\] COD marker already read. No more than one COD marker per tile. [\#1043](https://github.com/uclouvain/openjpeg/issues/1043)
-- failing to install latest version of openjpeg from source [\#1041](https://github.com/uclouvain/openjpeg/issues/1041)
-- Trouble compressing large raw image [\#1032](https://github.com/uclouvain/openjpeg/issues/1032)
-- Download and installed code from 2.3 archive. Installing 2.2? [\#1030](https://github.com/uclouvain/openjpeg/issues/1030)
-- missing fclose [\#1029](https://github.com/uclouvain/openjpeg/issues/1029)
-- NULL Pointer Access in function imagetopnm of convert.c\(jp2\):1289 [\#860](https://github.com/uclouvain/openjpeg/issues/860)
-- NULL Pointer Access in function imagetopnm of convert.c:2226\(jp2\) [\#859](https://github.com/uclouvain/openjpeg/issues/859)
-- Heap Buffer Overflow in function imagetotga of convert.c\(jp2\):942 [\#858](https://github.com/uclouvain/openjpeg/issues/858)
-
-**Merged pull requests:**
-
-- abi-check.sh: fix broken download URL [\#1188](https://github.com/uclouvain/openjpeg/pull/1188) ([rouault](https://github.com/rouault))
-- opj\_t1\_encode\_cblks: fix UBSAN signed integer overflow [\#1187](https://github.com/uclouvain/openjpeg/pull/1187) ([rouault](https://github.com/rouault))
-- convertbmp: detect invalid file dimensions early \(CVE-2018-6616\) [\#1172](https://github.com/uclouvain/openjpeg/pull/1172) ([hlef](https://github.com/hlef))
-- color\_apply\_icc\_profile: avoid potential heap buffer overflow [\#1170](https://github.com/uclouvain/openjpeg/pull/1170) ([rouault](https://github.com/rouault))
-- Fix multiple potential vulnerabilities and bugs [\#1168](https://github.com/uclouvain/openjpeg/pull/1168) ([Young-X](https://github.com/Young-X))
-- Fix several memory and resource leaks [\#1163](https://github.com/uclouvain/openjpeg/pull/1163) ([nforro](https://github.com/nforro))
-- Fix some potential overflow issues [\#1161](https://github.com/uclouvain/openjpeg/pull/1161) ([stweil](https://github.com/stweil))
-- jp3d/jpwl convert: fix write stack buffer overflow [\#1160](https://github.com/uclouvain/openjpeg/pull/1160) ([hlef](https://github.com/hlef))
-- Int overflow fixed [\#1159](https://github.com/uclouvain/openjpeg/pull/1159) ([ichlubna](https://github.com/ichlubna))
-- Update knownfailures- files given current configurations [\#1149](https://github.com/uclouvain/openjpeg/pull/1149) ([rouault](https://github.com/rouault))
-- CVE-2018-5785: fix issues with zero bitmasks [\#1148](https://github.com/uclouvain/openjpeg/pull/1148) ([hlef](https://github.com/hlef))
-- openjp2/jp2: Fix two format strings [\#1143](https://github.com/uclouvain/openjpeg/pull/1143) ([stweil](https://github.com/stweil))
-- Changes in pnmtoimage if image data are missing [\#1141](https://github.com/uclouvain/openjpeg/pull/1141) ([szukw000](https://github.com/szukw000))
-- Relative path to header files is hardcoded in OpenJPEGConfig.cmake.in file [\#1140](https://github.com/uclouvain/openjpeg/pull/1140) ([bukatlib](https://github.com/bukatlib))
-- Cast on uint ceildiv [\#1136](https://github.com/uclouvain/openjpeg/pull/1136) ([reverson](https://github.com/reverson))
-- Add -DBUILD\_PKGCONFIG\_FILES to install instructions [\#1133](https://github.com/uclouvain/openjpeg/pull/1133) ([robe2](https://github.com/robe2))
-- Fix some typos in code comments and documentation [\#1128](https://github.com/uclouvain/openjpeg/pull/1128) ([stweil](https://github.com/stweil))
-- Fix regression in reading files with TNsot == 0 \(refs \#1120\) [\#1121](https://github.com/uclouvain/openjpeg/pull/1121) ([rouault](https://github.com/rouault))
-- Use local type declaration for POSIX standard type only for MS compiler [\#1119](https://github.com/uclouvain/openjpeg/pull/1119) ([stweil](https://github.com/stweil))
-- Fix Mac builds [\#1104](https://github.com/uclouvain/openjpeg/pull/1104) ([rouault](https://github.com/rouault))
-- jp3d: Replace sprintf\(\) by snprintf\(\) in volumetobin\(\) [\#1101](https://github.com/uclouvain/openjpeg/pull/1101) ([kbabioch](https://github.com/kbabioch))
-- opj\_mj2\_extract: Rename output\_location to output\_prefix [\#1096](https://github.com/uclouvain/openjpeg/pull/1096) ([kbabioch](https://github.com/kbabioch))
-- mj2: Add missing variable to format string in fprintf\(\) invocation in meta\_out.c [\#1094](https://github.com/uclouvain/openjpeg/pull/1094) ([kbabioch](https://github.com/kbabioch))
-- Convert files to UTF-8 encoding [\#1090](https://github.com/uclouvain/openjpeg/pull/1090) ([stweil](https://github.com/stweil))
-- fix unchecked integer multiplication overflow [\#1080](https://github.com/uclouvain/openjpeg/pull/1080) ([setharnold](https://github.com/setharnold))
-- Fixed typos [\#1062](https://github.com/uclouvain/openjpeg/pull/1062) ([radarhere](https://github.com/radarhere))
-- Note that seek uses SEEK\_SET behavior. [\#1055](https://github.com/uclouvain/openjpeg/pull/1055) ([ideasman42](https://github.com/ideasman42))
-- Some Doxygen tags are removed [\#1050](https://github.com/uclouvain/openjpeg/pull/1050) ([szukw000](https://github.com/szukw000))
-- Fix resource leak \(CID 179466\) [\#1047](https://github.com/uclouvain/openjpeg/pull/1047) ([stweil](https://github.com/stweil))
-- Changed cmake version test to allow for cmake 2.8.11.x [\#1042](https://github.com/uclouvain/openjpeg/pull/1042) ([radarhere](https://github.com/radarhere))
-- Add missing fclose\(\) statement in error condition. [\#1037](https://github.com/uclouvain/openjpeg/pull/1037) ([gfiumara](https://github.com/gfiumara))
-
-## [v2.3.0](https://github.com/uclouvain/openjpeg/releases/v2.3.0) (2017-10-04)
-[Full Changelog](https://github.com/uclouvain/openjpeg/compare/v2.2.0...v2.3.0)
-
-**Implemented enhancements:**
-
-- Sub-tile decoding: only decode precincts and codeblocks that intersect the window specified in opj_set_decode_area() [\#990](https://github.com/uclouvain/openjpeg/pull/990) ([rouault](https://github.com/rouault))
-- Sub-tile decoding: only apply IDWT on areas that participate to the window of interest [\#1001](https://github.com/uclouvain/openjpeg/pull/1001) ([rouault](https://github.com/rouault))
-- Sub-tile decoding: memory use reduction and perf improvements [\#1010](https://github.com/uclouvain/openjpeg/pull/1010) ([rouault](https://github.com/rouault))
-- Add capability to decode only a subset of all components of an image. [\#1022](https://github.com/uclouvain/openjpeg/pull/1022) ([rouault](https://github.com/rouault))
-
-**Fixed bugs:**
-
-- Setting x offset of decode region to -1 causes opj\_decompress to go into infinite loop [\#736](https://github.com/uclouvain/openjpeg/issues/736)
-- Problem decoding multiple tiles with get\_decoded\_tile when cmap/pclr/cdef boxes are present in jp2 file [\#484](https://github.com/uclouvain/openjpeg/issues/484)
-- set reduce\_factor\_may\_fail [\#474](https://github.com/uclouvain/openjpeg/issues/474)
-- opj\_compress.exe, command line parser, infinite loop [\#469](https://github.com/uclouvain/openjpeg/issues/469)
-- Various memory access issues found via fuzzing [\#448](https://github.com/uclouvain/openjpeg/issues/448)
-- Multiple warnings when building OpenJPEG \(trunk\) [\#442](https://github.com/uclouvain/openjpeg/issues/442)
-- Bulk fuzz-testing report [\#427](https://github.com/uclouvain/openjpeg/issues/427)
-- remove all printf from openjpeg / use proper function pointer for logging [\#371](https://github.com/uclouvain/openjpeg/issues/371)
-- minor changes, clean-up [\#349](https://github.com/uclouvain/openjpeg/issues/349)
-- image-\>numcomps \> 4 [\#333](https://github.com/uclouvain/openjpeg/issues/333)
-- Improve support for region of interest [\#39](https://github.com/uclouvain/openjpeg/issues/39)
-- Public function to tell kernel type used \(5x3 vs 9x7\) [\#3](https://github.com/uclouvain/openjpeg/issues/3)
-- elf binary in source package ? [\#1026](https://github.com/uclouvain/openjpeg/issues/1026)
-- opj\_cio\_open [\#1025](https://github.com/uclouvain/openjpeg/issues/1025)
-- Building with Visual Studio 2015 [\#1023](https://github.com/uclouvain/openjpeg/issues/1023)
-- tcd.cpp\>:1617:33: error: assigning to 'OPJ\_INT32 \*' \(aka 'int \*'\) from incompatible type 'void \*' [\#1021](https://github.com/uclouvain/openjpeg/issues/1021)
-- j2k.cpp \> comparison of address of 'p\_j2k-\>m\_cp.tcps\[0\].m\_data' not equal to a null pointer is always true [\#1020](https://github.com/uclouvain/openjpeg/issues/1020)
-- Openjpeg 2.2.0 always build shared library even though -DBUILD\_SHARED\_LIBS:bool=off [\#1019](https://github.com/uclouvain/openjpeg/issues/1019)
-- missing fclose [\#1018](https://github.com/uclouvain/openjpeg/issues/1018)
-- Use opj\_image\_data\_free instead of opj\_free for image-\>comps\[\].data [\#1014](https://github.com/uclouvain/openjpeg/issues/1014)
-- malloc poison on some compilers - cross compiling [\#1013](https://github.com/uclouvain/openjpeg/issues/1013)
-- Add OPJ\_VERSION\_MAJOR, OPJ\_VERSION\_MINOR, OPJ\_VERSION\_MICRO macros in openjpeg.h [\#1011](https://github.com/uclouvain/openjpeg/issues/1011)
-- Encode: do not perform rate control for single-tile lossless [\#1009](https://github.com/uclouvain/openjpeg/issues/1009)
-- opj\_set\_decoded\_resolution\_factor\(\): bad interaction with opj\_set\_decode\_area\(\) and/or opj\_decode\(\) [\#1006](https://github.com/uclouvain/openjpeg/issues/1006)
-- memory allocation failure with .pgx file [\#999](https://github.com/uclouvain/openjpeg/issues/999)
-- Unable to fuzz with raw image as input [\#998](https://github.com/uclouvain/openjpeg/issues/998)
-- stack-based buffer overflow write in pgxtoimage \(/convert.c\) [\#997](https://github.com/uclouvain/openjpeg/issues/997)
-- freeze with a crafted bmp [\#996](https://github.com/uclouvain/openjpeg/issues/996)
-- invalid memory write in tgatoimage \(convert.c\) [\#995](https://github.com/uclouvain/openjpeg/issues/995)
-- static build on Windows fails [\#994](https://github.com/uclouvain/openjpeg/issues/994)
-- another heap-based buffer overflow in opj\_t2\_encode\_packet \(t2.c\) [\#993](https://github.com/uclouvain/openjpeg/issues/993)
-- heap-based buffer overflow in opj\_t2\_encode\_packet \(t2.c\) [\#992](https://github.com/uclouvain/openjpeg/issues/992)
-- heap-based buffer overflow in opj\_write\_bytes\_LE \(cio.c\) \(unfixed \#985\) [\#991](https://github.com/uclouvain/openjpeg/issues/991)
-- heap overflow in opj\_compress [\#988](https://github.com/uclouvain/openjpeg/issues/988)
-- heap overflow in opj\_decompress [\#987](https://github.com/uclouvain/openjpeg/issues/987)
-- heap-based buffer overflow in opj\_bio\_byteout \(bio.c\) [\#986](https://github.com/uclouvain/openjpeg/issues/986)
-- heap-based buffer overflow in opj\_write\_bytes\_LE \(cio.c\) [\#985](https://github.com/uclouvain/openjpeg/issues/985)
-- memory allocation failure in opj\_aligned\_alloc\_n \(opj\_malloc.c\) [\#983](https://github.com/uclouvain/openjpeg/issues/983)
-- heap-base buffer overflow in opj\_mqc\_flush \(mqc.c\) [\#982](https://github.com/uclouvain/openjpeg/issues/982)
-- Decode fails for JP2s with ICC profile [\#981](https://github.com/uclouvain/openjpeg/issues/981)
-- Unit tests failing on Ubuntu 17.04 [\#916](https://github.com/uclouvain/openjpeg/issues/916)
-- Encoder crashes on small images [\#901](https://github.com/uclouvain/openjpeg/issues/901)
-- openjpeg-1.5.3 fails to compile [\#830](https://github.com/uclouvain/openjpeg/issues/830)
-- opj\_compress crops image \(win\) or creates a jp2 which cannot be decompressed \(lin\) [\#716](https://github.com/uclouvain/openjpeg/issues/716)
-- -d flag is silently ignored when decoding a single tile [\#693](https://github.com/uclouvain/openjpeg/issues/693)
-- transition away from dev-utils [\#628](https://github.com/uclouvain/openjpeg/issues/628)
-- update instructions to build with Visual Studio and 64-Bit Visual C++ Toolset. [\#1028](https://github.com/uclouvain/openjpeg/pull/1028) ([quangnh89](https://github.com/quangnh89))
-- Add missing newline at end of file [\#1024](https://github.com/uclouvain/openjpeg/pull/1024) ([stweil](https://github.com/stweil))
-- merge master into coverity\_scan to update coverity results [\#1008](https://github.com/uclouvain/openjpeg/pull/1008) ([detonin](https://github.com/detonin))
-- Use more const qualifiers [\#984](https://github.com/uclouvain/openjpeg/pull/984) ([stweil](https://github.com/stweil))
-- Changes in converttif.c for PPC64 [\#980](https://github.com/uclouvain/openjpeg/pull/980) ([szukw000](https://github.com/szukw000))
-
-## [v2.2.0](https://github.com/uclouvain/openjpeg/releases/v2.2.0) (2017-08-10)
-[Full Changelog](https://github.com/uclouvain/openjpeg/compare/v2.1.2...v2.2.0)
-
-**Implemented enhancements:**
-
-- Memory consumption reduction at decoding side [\#968](https://github.com/uclouvain/openjpeg/pull/968) ([rouault](https://github.com/rouault))
-- T1 & DWT multithreading decoding optimizations [\#786](https://github.com/uclouvain/openjpeg/pull/786) ([rouault](https://github.com/rouault))
-- Tier1 decoder speed optimizations [\#783](https://github.com/uclouvain/openjpeg/pull/783) ([rouault](https://github.com/rouault))
-- Inverse DWT 5x3: lift implementation / SSE accelerated version [\#953](https://github.com/uclouvain/openjpeg/issues/953)
-- install static libraries [\#969](https://github.com/uclouvain/openjpeg/pull/969) ([jeroen](https://github.com/jeroen))
-- IDWT 5x3 single-pass lifting and SSE2/AVX2 implementation [\#957](https://github.com/uclouvain/openjpeg/pull/957) ([rouault](https://github.com/rouault))
-- build both shared and static library [\#954](https://github.com/uclouvain/openjpeg/pull/954) ([jeroen](https://github.com/jeroen))
-- T1 flag optimizations \(\#172\) [\#945](https://github.com/uclouvain/openjpeg/pull/945) ([rouault](https://github.com/rouault))
-- CMake: add stronger warnings for openjp2 lib/bin by default, and error out on declaration-after-statement [\#936](https://github.com/uclouvain/openjpeg/pull/936) ([rouault](https://github.com/rouault))
-- Quiet mode for opj\_decompress via -quiet long parameter. [\#928](https://github.com/uclouvain/openjpeg/pull/928) ([RussellMcOrmond](https://github.com/RussellMcOrmond))
-- Implement predictive termination check [\#800](https://github.com/uclouvain/openjpeg/pull/800) ([rouault](https://github.com/rouault))
-
-**Fixed bugs:**
-
-- Several issues spotted by Google OSS Fuzz - [see here](https://github.com/search?l=&q=OSS+Fuzz+author-date%3A2017-07-04..2017-08-01+repo%3Auclouvain%2Fopenjpeg&ref=advsearch&type=Commits&utf8=%E2%9C%93)
-- Missing fclose [\#976](https://github.com/uclouvain/openjpeg/issues/976)
-- Heap buffer overflow read in openjpeg imagetopnm [\#970](https://github.com/uclouvain/openjpeg/issues/970)
-- opj\_decompress opj\_j2k\_update\_image\_data\(\) Segment falut [\#948](https://github.com/uclouvain/openjpeg/issues/948)
-- Generic Crash in 1.5.0 [\#941](https://github.com/uclouvain/openjpeg/issues/941)
-- Segmentation Faults [\#940](https://github.com/uclouvain/openjpeg/issues/940)
-- Assertions thrown [\#939](https://github.com/uclouvain/openjpeg/issues/939)
-- Floating Point Errors [\#938](https://github.com/uclouvain/openjpeg/issues/938)
-- Division by zero crash [\#937](https://github.com/uclouvain/openjpeg/issues/937)
-- malformed jp2 can cause heap-buffer-overflow [\#909](https://github.com/uclouvain/openjpeg/issues/909)
-- NULL dereference can cause by malformed file [\#908](https://github.com/uclouvain/openjpeg/issues/908)
-- Out of bound read in opj\_j2k\_add\_mct [\#907](https://github.com/uclouvain/openjpeg/issues/907)
-- Check bpno\_plus\_one in opj\_t1\_decode\_cblk [\#903](https://github.com/uclouvain/openjpeg/issues/903)
-- Undefined-shift in opj\_j2k\_read\_siz [\#902](https://github.com/uclouvain/openjpeg/issues/902)
-- opj\_compress v2.1.2 can create images opj\_decompress cannot read [\#891](https://github.com/uclouvain/openjpeg/issues/891)
-- Improper usage of opj\_int\_ceildiv can cause overflows [\#889](https://github.com/uclouvain/openjpeg/issues/889)
-- Undefined shift in opj\_get\_all\_encoding\_parameters [\#885](https://github.com/uclouvain/openjpeg/issues/885)
-- Denial of service \(crash\) due to use-after-free when decoding an illegal JPEG2000 image file v2.1.2 \(2017-04 [\#880](https://github.com/uclouvain/openjpeg/issues/880)
-- Denial of service \(crash\) when decoding an illegal JPEG2000 image file v2.1.2 \(2017-03\) [\#879](https://github.com/uclouvain/openjpeg/issues/879)
-- bug png 2 j2k [\#868](https://github.com/uclouvain/openjpeg/issues/868)
-- Inconsistent compression using cinema settings on folder of non-compliant image [\#864](https://github.com/uclouvain/openjpeg/issues/864)
-- Openjpeg-2.1.2 Heap Buffer Overflow Vulnerability due to Insufficient check [\#862](https://github.com/uclouvain/openjpeg/issues/862)
-- Heap Buffer Overflow in function pnmtoimage of convert.c [\#861](https://github.com/uclouvain/openjpeg/issues/861)
-- CVE-2016-9112 FPE\(Floating Point Exception\) in lib/openjp2/pi.c:523 [\#855](https://github.com/uclouvain/openjpeg/issues/855)
-- CVE-2016-5139, CVE-2016-5152, CVE-2016-5158, CVE-2016-5159 [\#854](https://github.com/uclouvain/openjpeg/issues/854)
-- Undefined Reference error [\#853](https://github.com/uclouvain/openjpeg/issues/853)
-- opj\_compress with lossy compression results in strange pixel values [\#851](https://github.com/uclouvain/openjpeg/issues/851)
-- CVE-2016-1626 and CVE-2016-1628 [\#850](https://github.com/uclouvain/openjpeg/issues/850)
-- Out-of-Bounds Write in opj\_mqc\_byteout of mqc.c [\#835](https://github.com/uclouvain/openjpeg/issues/835)
-- WARNING in tgt\_create tree-\>numnodes == 0, no tree created. [\#794](https://github.com/uclouvain/openjpeg/issues/794)
-- Potential overflow when precision is larger than 32 [\#781](https://github.com/uclouvain/openjpeg/issues/781)
-- division-by-zero in function opj\_pi\_next\_rpcl of pi.c \(line 366\) [\#780](https://github.com/uclouvain/openjpeg/issues/780)
-- division-by-zero in function opj\_pi\_next\_rpcl of pi.c \(line 363\) [\#779](https://github.com/uclouvain/openjpeg/issues/779)
-- division-by-zero in function opj\_pi\_next\_pcrl of pi.c \(line 447\) [\#778](https://github.com/uclouvain/openjpeg/issues/778)
-- division-by-zero in function opj\_pi\_next\_pcrl of pi.c \(line 444\) [\#777](https://github.com/uclouvain/openjpeg/issues/777)
-- Encoding the following file with 32x32 tiling produces jp2 image with artifact [\#737](https://github.com/uclouvain/openjpeg/issues/737)
-- division-by-zero \(SIGFPE\) error in opj\_pi\_next\_cprl function \(line 526 of pi.c\) [\#732](https://github.com/uclouvain/openjpeg/issues/732)
-- division-by-zero \(SIGFPE\) error in opj\_pi\_next\_cprl function \(line 523 of pi.c\) [\#731](https://github.com/uclouvain/openjpeg/issues/731)
-- OpenJpeg 2.1 and 1.4 fails to decompress this file correctly [\#721](https://github.com/uclouvain/openjpeg/issues/721)
-- MQ Encode :uninitialized memory access when first pass does not output any bytes [\#709](https://github.com/uclouvain/openjpeg/issues/709)
-- Out-of-bounds read in opj\_j2k\_update\_image\_data and opj\_tgt\_reset function [\#704](https://github.com/uclouvain/openjpeg/issues/704)
-- Remove opj\_aligned\_malloc / opj\_aligned\_realloc / opj\_aligned\_free? [\#689](https://github.com/uclouvain/openjpeg/issues/689)
-- There is an issue with rendering some type of jpeg file. Please ref the link. [\#672](https://github.com/uclouvain/openjpeg/issues/672)
-- Null Dereference in tcd\_malloc\_decode\_tile [\#657](https://github.com/uclouvain/openjpeg/issues/657)
-- ETS-C1P0-p0\_12.j2k-compare2ref & NR-C1P0-p0\_12.j2k-compare2base failing under windows [\#655](https://github.com/uclouvain/openjpeg/issues/655)
-- Memory leak [\#631](https://github.com/uclouvain/openjpeg/issues/631)
-- Test 481 reports error in valgrind memcheck [\#612](https://github.com/uclouvain/openjpeg/issues/612)
-- reserved identifier violation [\#587](https://github.com/uclouvain/openjpeg/issues/587)
-- Buffer overflow when compressing some 16 bits images of the test suite [\#539](https://github.com/uclouvain/openjpeg/issues/539)
-- Heap-buffer-overflow in opj\_dwt\_decode\_1 [\#480](https://github.com/uclouvain/openjpeg/issues/480)
-- Automated fuzz testing [\#468](https://github.com/uclouvain/openjpeg/issues/468)
-- Expected to find EPH marker [\#425](https://github.com/uclouvain/openjpeg/issues/425)
-- read: segment too long \(6182\) with max \(35872\) for codeblock 0 \(p=19, b=2, r=5, c=1\) [\#284](https://github.com/uclouvain/openjpeg/issues/284)
-- building 64bit version has lots of warnings [\#244](https://github.com/uclouvain/openjpeg/issues/244)
-- Wrong encoding of small tiles with high level number [\#239](https://github.com/uclouvain/openjpeg/issues/239)
-- Errors raised in pi.c by VS11 analyzer [\#190](https://github.com/uclouvain/openjpeg/issues/190)
-- Undocumented optimization found in v2 branch of openjpeg [\#183](https://github.com/uclouvain/openjpeg/issues/183)
-- T1 optimisations jpeg2000 [\#172](https://github.com/uclouvain/openjpeg/issues/172)
-- Remove OPJ\_NOSANITIZE in opj\_bio\_read\(\) and opj\_bio\_write\(\) \(\#761\) [\#955](https://github.com/uclouvain/openjpeg/pull/955) ([rouault](https://github.com/rouault))
-- Fix bypass pterm termall and lossless decomposition issue \(\#891, \#892\) [\#949](https://github.com/uclouvain/openjpeg/pull/949) ([rouault](https://github.com/rouault))
-- Escape quotes to ensure README renders on GitHub correctly [\#914](https://github.com/uclouvain/openjpeg/pull/914) ([alexwlchan](https://github.com/alexwlchan))
-- Remove spurious .R macros from manpages [\#899](https://github.com/uclouvain/openjpeg/pull/899) ([jwilk](https://github.com/jwilk))
-- Remove warnings related to empty tag-trees. [\#893](https://github.com/uclouvain/openjpeg/pull/893) ([rouault](https://github.com/rouault))
-
-**Maintenance-related tasks:**
-
-- Submit OpenJPEG to oss-fuzz [\#965](https://github.com/uclouvain/openjpeg/issues/965)
-- Updates for Doxygen to suppress warnings [\#849](https://github.com/uclouvain/openjpeg/issues/849)
-- Remove useless knownfailures \(since LAZY encoding is fixed\) [\#964](https://github.com/uclouvain/openjpeg/pull/964) ([rouault](https://github.com/rouault))
-- Enable AVX2 at runtime on Travis-CI and AppVeyor [\#963](https://github.com/uclouvain/openjpeg/pull/963) ([rouault](https://github.com/rouault))
-- Tests: test opj\_compress in VSC mode \(related to \#172\) [\#935](https://github.com/uclouvain/openjpeg/pull/935) ([rouault](https://github.com/rouault))
-- Reformat: apply reformattin on .h files \(\#128\) [\#926](https://github.com/uclouvain/openjpeg/pull/926) ([rouault](https://github.com/rouault))
-- Add mechanisms to reformat and check code style, and reformat whole codebase \(\#128\) [\#919](https://github.com/uclouvain/openjpeg/pull/919) ([rouault](https://github.com/rouault))
-- Add profiling of CPU and memory usage \(\#912\) [\#918](https://github.com/uclouvain/openjpeg/pull/918) ([rouault](https://github.com/rouault))
-- Add performance benchmarking scripts [\#917](https://github.com/uclouvain/openjpeg/pull/917) ([rouault](https://github.com/rouault))
-- Fix retrieval of jpylyzer in AppVeyor [\#915](https://github.com/uclouvain/openjpeg/pull/915) ([rouault](https://github.com/rouault))
-
-## [v2.1.2](https://github.com/uclouvain/openjpeg/releases/v2.1.2) (2016-09-28)
-[Full Changelog](https://github.com/uclouvain/openjpeg/compare/v2.1.1...v2.1.2)
-
-**Closed issues:**
-
-- null ptr dereference in convert.c:1331 [\#843](https://github.com/uclouvain/openjpeg/issues/843)
-- Out-of-Bounds Read in function bmp24toimage of convertbmp.c [\#833](https://github.com/uclouvain/openjpeg/issues/833)
-- Disable automatic compilation of t1\_generate\_luts in CMakeLists.txt [\#831](https://github.com/uclouvain/openjpeg/issues/831)
-- CVE-2016-7163 Integer overflow in opj\_pi\_create\_decode [\#826](https://github.com/uclouvain/openjpeg/issues/826)
-- Security Advisory for OpenJPEG [\#810](https://github.com/uclouvain/openjpeg/issues/810)
-- Add dashboard with static lib [\#804](https://github.com/uclouvain/openjpeg/issues/804)
-- hidden visibility for the static library / building with -DOPJ\_STATIC against shared lib [\#802](https://github.com/uclouvain/openjpeg/issues/802)
-- Optimization when building library from source [\#799](https://github.com/uclouvain/openjpeg/issues/799)
-- unsigned int16 on Solaris 11.2/sparc [\#796](https://github.com/uclouvain/openjpeg/issues/796)
-- appveyor [\#793](https://github.com/uclouvain/openjpeg/issues/793)
-- FFMpeg will not link to 2.1.1 release built as shared library [\#766](https://github.com/uclouvain/openjpeg/issues/766)
-- API change since v2: opj\_event\_mgr\_t not available [\#754](https://github.com/uclouvain/openjpeg/issues/754)
-- openjpeg.h needs dependencies [\#673](https://github.com/uclouvain/openjpeg/issues/673)
-- "master" does not build on ubuntu [\#658](https://github.com/uclouvain/openjpeg/issues/658)
-- Package 'openjp2', required by 'libopenjpip', not found [\#594](https://github.com/uclouvain/openjpeg/issues/594)
-
-**Merged pull requests:**
-
-- Fix PNM file reading [\#847](https://github.com/uclouvain/openjpeg/pull/847) ([mayeut](https://github.com/mayeut))
-- Fix some issues reported by Coverity Scan [\#846](https://github.com/uclouvain/openjpeg/pull/846) ([stweil](https://github.com/stweil))
-- Fix potential out-of-bounds read \(coverity\) [\#844](https://github.com/uclouvain/openjpeg/pull/844) ([stweil](https://github.com/stweil))
-- Remove TODO for overflow check [\#842](https://github.com/uclouvain/openjpeg/pull/842) ([mayeut](https://github.com/mayeut))
-- Add overflow checks for opj\_aligned\_malloc [\#841](https://github.com/uclouvain/openjpeg/pull/841) ([mayeut](https://github.com/mayeut))
-- Flags in T1 shall be unsigned [\#840](https://github.com/uclouvain/openjpeg/pull/840) ([mayeut](https://github.com/mayeut))
-- Fix some warnings [\#838](https://github.com/uclouvain/openjpeg/pull/838) ([mayeut](https://github.com/mayeut))
-- Fix issue 833. [\#834](https://github.com/uclouvain/openjpeg/pull/834) ([trylab](https://github.com/trylab))
-- Add overflow checks for opj\_aligned\_malloc [\#832](https://github.com/uclouvain/openjpeg/pull/832) ([mayeut](https://github.com/mayeut))
-- Add test for issue 820 [\#829](https://github.com/uclouvain/openjpeg/pull/829) ([mayeut](https://github.com/mayeut))
-- Add test for issue 826 [\#827](https://github.com/uclouvain/openjpeg/pull/827) ([mayeut](https://github.com/mayeut))
-- Fix coverity 113065 \(CWE-484\) [\#824](https://github.com/uclouvain/openjpeg/pull/824) ([mayeut](https://github.com/mayeut))
-- Add sanity check for tile coordinates [\#823](https://github.com/uclouvain/openjpeg/pull/823) ([mayeut](https://github.com/mayeut))
-- Add test for PR 818 [\#822](https://github.com/uclouvain/openjpeg/pull/822) ([mayeut](https://github.com/mayeut))
-- Update to libpng 1.6.25 [\#821](https://github.com/uclouvain/openjpeg/pull/821) ([mayeut](https://github.com/mayeut))
-- CVE-2016-8332: fix incrementing of "l\_tcp-\>m\_nb\_mcc\_records" in opj\_j2k\_read\_mcc [\#820](https://github.com/uclouvain/openjpeg/pull/820) ([mayeut](https://github.com/mayeut))
-- Add overflow check in opj\_tcd\_init\_tile [\#819](https://github.com/uclouvain/openjpeg/pull/819) ([mayeut](https://github.com/mayeut))
-- Fix leak & invalid behavior of opj\_jp2\_read\_ihdr [\#818](https://github.com/uclouvain/openjpeg/pull/818) ([mayeut](https://github.com/mayeut))
-- Add overflow check in opj\_j2k\_update\_image\_data [\#817](https://github.com/uclouvain/openjpeg/pull/817) ([mayeut](https://github.com/mayeut))
-- Change 'restrict' define to 'OPJ\_RESTRICT' [\#816](https://github.com/uclouvain/openjpeg/pull/816) ([mayeut](https://github.com/mayeut))
-- Switch to clang 3.8 [\#814](https://github.com/uclouvain/openjpeg/pull/814) ([mayeut](https://github.com/mayeut))
-- Fix an integer overflow issue [\#809](https://github.com/uclouvain/openjpeg/pull/809) ([trylab](https://github.com/trylab))
-- Update to lcms 2.8 [\#808](https://github.com/uclouvain/openjpeg/pull/808) ([mayeut](https://github.com/mayeut))
-- Update to libpng 1.6.24 [\#807](https://github.com/uclouvain/openjpeg/pull/807) ([mayeut](https://github.com/mayeut))
-- Reenable clang-3.9 build on travis [\#806](https://github.com/uclouvain/openjpeg/pull/806) ([mayeut](https://github.com/mayeut))
-- Bit fields type [\#805](https://github.com/uclouvain/openjpeg/pull/805) ([smuehlst](https://github.com/smuehlst))
-- Add compilation test for standalone inclusion of openjpeg.h [\#798](https://github.com/uclouvain/openjpeg/pull/798) ([mayeut](https://github.com/mayeut))
-- jpwl: Remove non-portable data type u\_int16\_t \(fix issue \#796\) [\#797](https://github.com/uclouvain/openjpeg/pull/797) ([stweil](https://github.com/stweil))
-- Fix dependency for pkg-config \(issue \#594\) [\#795](https://github.com/uclouvain/openjpeg/pull/795) ([stweil](https://github.com/stweil))
-- Add .gitignore [\#787](https://github.com/uclouvain/openjpeg/pull/787) ([stweil](https://github.com/stweil))
-
-## [v2.1.1](https://github.com/uclouvain/openjpeg/releases/tag/v2.1.1) (2016-07-05)
-[Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.2.1...v2.1.1)
-
-**Implemented enhancements:**
-
-- opj\_malloc replacement [\#625](https://github.com/uclouvain/openjpeg/issues/625)
-- backport "-p" and "-force-rgb" options in 1.5 [\#606](https://github.com/uclouvain/openjpeg/issues/606)
-- Use travis-ci matrix build [\#581](https://github.com/uclouvain/openjpeg/issues/581)
-- Add Coverity Scan analysis [\#580](https://github.com/uclouvain/openjpeg/issues/580)
-- Unnecessary rate distortion calculations [\#479](https://github.com/uclouvain/openjpeg/issues/479)
-- Add images from various security issues to test suite [\#415](https://github.com/uclouvain/openjpeg/issues/415)
-- Coding speed for 9/7 on 32bits platforms \(x86/ARM\) can be improved with a quick fix [\#220](https://github.com/uclouvain/openjpeg/issues/220)
-
-**Fixed bugs:**
-
-- Out-of-Bounds Access in function opj\_tgt\_reset of tgt.c [\#775](https://github.com/uclouvain/openjpeg/issues/775)
-- Heap Buffer Overflow in function color\_cmyk\_to\_rgb of color.c [\#774](https://github.com/uclouvain/openjpeg/issues/774)
-- division-by-zero \(SIGFPE\) error in opj\_tcd\_init\_tile function \(line 730 of tcd.c\) [\#733](https://github.com/uclouvain/openjpeg/issues/733)
-- Out-Of-Bounds Read in sycc422\_to\_rgb function [\#726](https://github.com/uclouvain/openjpeg/issues/726)
-- Heap Corruption in opj\_free function [\#725](https://github.com/uclouvain/openjpeg/issues/725)
-- Out-Of-Bounds Read in opj\_tcd\_free\_tile function [\#724](https://github.com/uclouvain/openjpeg/issues/724)
-- Cannot handle box of undefined size [\#653](https://github.com/uclouvain/openjpeg/issues/653)
-- Compilation fails without platform-supplied aligned malloc [\#642](https://github.com/uclouvain/openjpeg/issues/642)
-- HP compiler warns about redeclaration of static function [\#640](https://github.com/uclouvain/openjpeg/issues/640)
-- Implementation-defined behavior of malloc causes different behavior on Linux and AIX [\#635](https://github.com/uclouvain/openjpeg/issues/635)
-- Build on AIX fails because "opj\_includes.h" is included after system headers [\#633](https://github.com/uclouvain/openjpeg/issues/633)
-- Compiling with SSE2 on Linux 32-bit causes crashes in OpenJPEG [\#624](https://github.com/uclouvain/openjpeg/issues/624)
-- Build on AIX fails because of "restrict" pointers [\#620](https://github.com/uclouvain/openjpeg/issues/620)
-- bug in new tif conversion code [\#609](https://github.com/uclouvain/openjpeg/issues/609)
-- bin/jp2/convert.c line 1085 Resource leak [\#607](https://github.com/uclouvain/openjpeg/issues/607)
-- bin/jp2/convert.c memory leak [\#601](https://github.com/uclouvain/openjpeg/issues/601)
-- Resource leak in opj\_j2k\_create\_cstr\_index in case of failure [\#599](https://github.com/uclouvain/openjpeg/issues/599)
-- Resource leak in opj\_j2k\_encode in case of failure [\#598](https://github.com/uclouvain/openjpeg/issues/598)
-- Resource leak in opj\_j2k\_decode\_one\_tile in case of failure [\#597](https://github.com/uclouvain/openjpeg/issues/597)
-- Resource Leak [\#573](https://github.com/uclouvain/openjpeg/issues/573)
-- opj\_compress fails to compress lossless on gcc/x86 \(-m32\) [\#571](https://github.com/uclouvain/openjpeg/issues/571)
-- Use-after-free in opj\_j2k\_write\_mco [\#563](https://github.com/uclouvain/openjpeg/issues/563)
-- openjpeg-master-2015-07-30 failed to compile on LINUX [\#556](https://github.com/uclouvain/openjpeg/issues/556)
-- PNG images are always read as RGB\(A\) images [\#536](https://github.com/uclouvain/openjpeg/issues/536)
-- g4\_colr.j2c not handled properly [\#532](https://github.com/uclouvain/openjpeg/issues/532)
-- Bigendian: opj\_compress + opj\_decompress fails [\#518](https://github.com/uclouvain/openjpeg/issues/518)
-- Suspicious code in j2k.c [\#517](https://github.com/uclouvain/openjpeg/issues/517)
-- Decode times almost double\(!!\) on Visual Studio 2013, 2015 [\#505](https://github.com/uclouvain/openjpeg/issues/505)
-- opj\_data/input/nonregression/issue226.j2k [\#500](https://github.com/uclouvain/openjpeg/issues/500)
-- opj\_setup\_encoder always returns true [\#497](https://github.com/uclouvain/openjpeg/issues/497)
-- Double free in j2k\_read\_ppm\_v3 parsing \(\(presumably invalid\) image. [\#496](https://github.com/uclouvain/openjpeg/issues/496)
-- Invalid write in opj\_j2k\_update\_image\_data [\#495](https://github.com/uclouvain/openjpeg/issues/495)
-- Undefined printf format specifier %ud used in code [\#494](https://github.com/uclouvain/openjpeg/issues/494)
-- Potential double free on malloc failure in opj\_j2k\_copy\_default\_tcp\_and\_create\_tcp\(\) [\#492](https://github.com/uclouvain/openjpeg/issues/492)
-- Do not link with -ffast-math [\#488](https://github.com/uclouvain/openjpeg/issues/488)
-- Heap-buffer-overflow in opj\_dwt\_decode [\#486](https://github.com/uclouvain/openjpeg/issues/486)
-- opj\_dump fails on Windows 7, 64 bits [\#482](https://github.com/uclouvain/openjpeg/issues/482)
-- SIGSEGV in opj\_j2k\_update\_image\_data via pdfium\_test [\#481](https://github.com/uclouvain/openjpeg/issues/481)
-- Heap-buffer-overflow in opj\_j2k\_tcp\_destroy [\#477](https://github.com/uclouvain/openjpeg/issues/477)
-- Invalid image causes write past end of heap buffer [\#476](https://github.com/uclouvain/openjpeg/issues/476)
-- Assertion `l\_res-\>x0 \>= 0' fails when parsing invalid images [\#475](https://github.com/uclouvain/openjpeg/issues/475)
-- Bug on opj\_write\_bytes\_BE function [\#472](https://github.com/uclouvain/openjpeg/issues/472)
-- Refactor j2k\_read\_ppm\_v3 function [\#470](https://github.com/uclouvain/openjpeg/issues/470)
-- compression: strange precinct dimensions [\#466](https://github.com/uclouvain/openjpeg/issues/466)
-- \(:- Console message in opj\_decompress -:\) [\#465](https://github.com/uclouvain/openjpeg/issues/465)
-- opj\_decompress fails to decompress any files [\#463](https://github.com/uclouvain/openjpeg/issues/463)
-- bio-\>ct is unnecessarily set to zero in opj\_bio\_flush method [\#461](https://github.com/uclouvain/openjpeg/issues/461)
-- Maximal unsigned short is 65535, not 65536 [\#460](https://github.com/uclouvain/openjpeg/issues/460)
-- OpenJpeg fails to encode components with different precision properly [\#459](https://github.com/uclouvain/openjpeg/issues/459)
-- component precision upscaling isn't correct in opj\_decompress [\#458](https://github.com/uclouvain/openjpeg/issues/458)
-- Multiple precision components won't get encoded to jp2 if 1 component is unsigned 1 bit [\#457](https://github.com/uclouvain/openjpeg/issues/457)
-- Incorrect code in ../bin/jp2/convert.c, function rawtoimage\_common\(...\) [\#456](https://github.com/uclouvain/openjpeg/issues/456)
-- \[OpenJPEG-trunk\] opj\_stream\_get\_number\_byte\_left throws assert [\#455](https://github.com/uclouvain/openjpeg/issues/455)
-- NR-DEC-kodak\_2layers\_lrcp.j2c-31-decode-md5 fails randomly when running tests in parallel [\#454](https://github.com/uclouvain/openjpeg/issues/454)
-- compare\_raw\_files doesn't report an error on invalid arguments / missing input files [\#453](https://github.com/uclouvain/openjpeg/issues/453)
-- Forward discrete wavelet transform: implement periodic symmetric extension at boundaries [\#452](https://github.com/uclouvain/openjpeg/issues/452)
-- Bug in tiff reading method in convert.c [\#449](https://github.com/uclouvain/openjpeg/issues/449)
-- Image in pdf don't display [\#447](https://github.com/uclouvain/openjpeg/issues/447)
-- Multiple issues causing opj\_decompress to segfault [\#446](https://github.com/uclouvain/openjpeg/issues/446)
-- opj\_compress: 40% of encode time is spent freeing data [\#445](https://github.com/uclouvain/openjpeg/issues/445)
-- Multiple warnings when configuring OpenJPEG on MacOS with CMake 3.x \(trunk\) [\#443](https://github.com/uclouvain/openjpeg/issues/443)
-- valgrind memleak found [\#437](https://github.com/uclouvain/openjpeg/issues/437)
-- global-buffer-overflow src/lib/openjp2/t1.c:1146 opj\_t1\_getwmsedec [\#436](https://github.com/uclouvain/openjpeg/issues/436)
-- Warning introduced on trunk r2923 & r2924 [\#435](https://github.com/uclouvain/openjpeg/issues/435)
-- heap-buffer-overflow in opj\_t1\_decode\_cblks [\#432](https://github.com/uclouvain/openjpeg/issues/432)
-- Heap-buffer-overflow in opj\_tcd\_init\_decode\_tile [\#431](https://github.com/uclouvain/openjpeg/issues/431)
-- Heap-buffer-overflow in opj\_j2k\_tcp\_destroy [\#430](https://github.com/uclouvain/openjpeg/issues/430)
-- Heap-buffer-overflow in opj\_jp2\_apply\_pclr [\#429](https://github.com/uclouvain/openjpeg/issues/429)
-- issue412 revisited [\#428](https://github.com/uclouvain/openjpeg/issues/428)
-- Image distorted \(sides look cankered\) [\#423](https://github.com/uclouvain/openjpeg/issues/423)
-- openjpeg-2.x-trunk-r2918 is broken in color.c [\#422](https://github.com/uclouvain/openjpeg/issues/422)
-- Heap-buffer-overflow in opj\_tcd\_init\_decode\_tile [\#420](https://github.com/uclouvain/openjpeg/issues/420)
-- Heap-use-after-free in opj\_t1\_decode\_cblks [\#418](https://github.com/uclouvain/openjpeg/issues/418)
-- UNKNOWN in opj\_read\_bytes\_LE [\#417](https://github.com/uclouvain/openjpeg/issues/417)
-- Transparency problem [\#416](https://github.com/uclouvain/openjpeg/issues/416)
-- Image with per channel alpha \(cdef\) does not decode properly [\#414](https://github.com/uclouvain/openjpeg/issues/414)
-- OpenJPEG crashes with attached image [\#413](https://github.com/uclouvain/openjpeg/issues/413)
-- Palette image with cdef fails to decompress [\#412](https://github.com/uclouvain/openjpeg/issues/412)
-- Invalid member values from opj\_read\_header or opj\_decode ? [\#411](https://github.com/uclouvain/openjpeg/issues/411)
-- MD5 Checksum hangs under valgrind on MacOS X [\#410](https://github.com/uclouvain/openjpeg/issues/410)
-- Heap-buffer-overflow in opj\_tcd\_get\_decoded\_tile\_size [\#408](https://github.com/uclouvain/openjpeg/issues/408)
-- C++ style comments in trunk/src/lib/openjp2/j2k.c [\#407](https://github.com/uclouvain/openjpeg/issues/407)
-- Backport bugfixes from trunk to 2.1 branch [\#405](https://github.com/uclouvain/openjpeg/issues/405)
-- Heap-buffer-overflow in parse\_cmdline\_encoder [\#403](https://github.com/uclouvain/openjpeg/issues/403)
-- Heap-buffer-overflow in opj\_v4dwt\_interleave\_h [\#400](https://github.com/uclouvain/openjpeg/issues/400)
-- Heap-buffer-overflow in opj\_dwt\_decode [\#399](https://github.com/uclouvain/openjpeg/issues/399)
-- Heap-use-after-free in opj\_t1\_decode\_cblks [\#398](https://github.com/uclouvain/openjpeg/issues/398)
-- Heap-buffer-overflow in opj\_jp2\_apply\_cdef [\#397](https://github.com/uclouvain/openjpeg/issues/397)
-- Heap-buffer-overflow in opj\_t2\_read\_packet\_header [\#396](https://github.com/uclouvain/openjpeg/issues/396)
-- Heap-buffer-overflow in opj\_t2\_read\_packet\_header [\#395](https://github.com/uclouvain/openjpeg/issues/395)
-- Heap-buffer-overflow in opj\_dwt\_decode\_1 [\#394](https://github.com/uclouvain/openjpeg/issues/394)
-- Heap-double-free in j2k\_read\_ppm\_v3 [\#393](https://github.com/uclouvain/openjpeg/issues/393)
-- Security hole in j2k.c [\#392](https://github.com/uclouvain/openjpeg/issues/392)
-- Security: double-free in opj\_tcd\_code\_block\_dec\_deallocate [\#391](https://github.com/uclouvain/openjpeg/issues/391)
-- check for negative-size params in code [\#390](https://github.com/uclouvain/openjpeg/issues/390)
-- Heap-buffer-overflow in opj\_t2\_read\_packet\_header [\#389](https://github.com/uclouvain/openjpeg/issues/389)
-- Heap overflow in OpenJpeg 1.5.2 [\#388](https://github.com/uclouvain/openjpeg/issues/388)
-- openjpip.so.6 file too short [\#387](https://github.com/uclouvain/openjpeg/issues/387)
-- Corrupted JP3D file [\#386](https://github.com/uclouvain/openjpeg/issues/386)
-- variable assigned to itself [\#383](https://github.com/uclouvain/openjpeg/issues/383)
-- Null pointer dereferencing [\#382](https://github.com/uclouvain/openjpeg/issues/382)
-- bad use of case statement [\#381](https://github.com/uclouvain/openjpeg/issues/381)
-- Release 2.1 as a Ubuntu package [\#380](https://github.com/uclouvain/openjpeg/issues/380)
-- Bug in libopenjpwl.pc [\#374](https://github.com/uclouvain/openjpeg/issues/374)
-- inconsistent tile numbering in decode output message [\#370](https://github.com/uclouvain/openjpeg/issues/370)
-- error in code block calculations [\#369](https://github.com/uclouvain/openjpeg/issues/369)
-- r2872 fails to compile due to "attempt to use poisoned malloc" error in j2k.c [\#368](https://github.com/uclouvain/openjpeg/issues/368)
-- OSX build gives libopenjp2.6.dylib with not-absolute install name id [\#367](https://github.com/uclouvain/openjpeg/issues/367)
-- opj\_decompress gives error but successfully decompress in OPJ 2.1 [\#366](https://github.com/uclouvain/openjpeg/issues/366)
-- pngtoimage\(\) and imagetopng\(\) have wrong byte order for 16-Bit image [\#365](https://github.com/uclouvain/openjpeg/issues/365)
-- PDF crash in chrome - part2 \(due to attachment limit\) [\#364](https://github.com/uclouvain/openjpeg/issues/364)
-- PDF crash in chrome - part1 [\#363](https://github.com/uclouvain/openjpeg/issues/363)
-- PDF crash in chrome - part0 [\#362](https://github.com/uclouvain/openjpeg/issues/362)
-- Compilation fails on Windows with mingw32 gcc4.8 [\#361](https://github.com/uclouvain/openjpeg/issues/361)
-- security issue [\#360](https://github.com/uclouvain/openjpeg/issues/360)
-- improve memory management [\#359](https://github.com/uclouvain/openjpeg/issues/359)
-- how to compress a yuv420 raw data using opj\_compress [\#357](https://github.com/uclouvain/openjpeg/issues/357)
-- Some memory allocation are not checked [\#355](https://github.com/uclouvain/openjpeg/issues/355)
-- Static library symbols shall be marked as hidden [\#354](https://github.com/uclouvain/openjpeg/issues/354)
-- opj\_compress rejects valid bmp files [\#353](https://github.com/uclouvain/openjpeg/issues/353)
-- opj\_compress crashes when number of resolutions is set to zero [\#352](https://github.com/uclouvain/openjpeg/issues/352)
-- Compilation error under Visual Studio 2003 [\#351](https://github.com/uclouvain/openjpeg/issues/351)
-- opj\_compress description example error \[Low priority\] [\#350](https://github.com/uclouvain/openjpeg/issues/350)
-- opj\_write\_bytes\_BE is wrong in trunk [\#345](https://github.com/uclouvain/openjpeg/issues/345)
-- PART1ONLY option in release.sh doesn't work properly [\#332](https://github.com/uclouvain/openjpeg/issues/332)
-- openjpeg crash error [\#330](https://github.com/uclouvain/openjpeg/issues/330)
-- openjpeg decompress error [\#329](https://github.com/uclouvain/openjpeg/issues/329)
-- openjpeg decompress issue [\#326](https://github.com/uclouvain/openjpeg/issues/326)
-- limited tif support [\#322](https://github.com/uclouvain/openjpeg/issues/322)
-- asoc value of 65536 is allowed [\#321](https://github.com/uclouvain/openjpeg/issues/321)
-- opj\_skip\_from\_file error [\#314](https://github.com/uclouvain/openjpeg/issues/314)
-- Heavy quota usage in openjpeg [\#309](https://github.com/uclouvain/openjpeg/issues/309)
-- Verify -help actually match letter [\#307](https://github.com/uclouvain/openjpeg/issues/307)
-- g3\_colr.j2c not handled [\#288](https://github.com/uclouvain/openjpeg/issues/288)
-- reopen/fix issue 165 [\#280](https://github.com/uclouvain/openjpeg/issues/280)
-- kakadu conformance tests [\#279](https://github.com/uclouvain/openjpeg/issues/279)
-- missing break after case statement in opj\_dwt\_decode\_real [\#274](https://github.com/uclouvain/openjpeg/issues/274)
-- Run Coverity on trunk [\#270](https://github.com/uclouvain/openjpeg/issues/270)
-- NR-ENC-random-issue-0005.tif-12-encode [\#259](https://github.com/uclouvain/openjpeg/issues/259)
-- Use new add\_test signature to handle cross compilation [\#258](https://github.com/uclouvain/openjpeg/issues/258)
-- Loss decoding quality in 2.0.0 [\#254](https://github.com/uclouvain/openjpeg/issues/254)
-- Decompress that worked in 1.5.1 fails in 2.0 [\#252](https://github.com/uclouvain/openjpeg/issues/252)
-- Expected endianness with raw input is not documented leading to SEGFAULT [\#251](https://github.com/uclouvain/openjpeg/issues/251)
-- OpenJPEG writes to stderr [\#246](https://github.com/uclouvain/openjpeg/issues/246)
-- Inconsistent logging of tile index [\#245](https://github.com/uclouvain/openjpeg/issues/245)
-- patch for openjpeg-trunk-r2347 and BIG\_ENDIAN [\#242](https://github.com/uclouvain/openjpeg/issues/242)
-- CMAP: MTYP == 0 \(direct use\) not handled properly [\#235](https://github.com/uclouvain/openjpeg/issues/235)
-- Black Pixel [\#233](https://github.com/uclouvain/openjpeg/issues/233)
-- opj\_compress runtime error after fresh Linux install due to apparent failure to execute ldconfig [\#219](https://github.com/uclouvain/openjpeg/issues/219)
-- openjp2 debug works, release build does not [\#217](https://github.com/uclouvain/openjpeg/issues/217)
-- openjpeg-branch15-r2299 and openjpeg-trunk-r2299 fail to decode a JP2 file [\#212](https://github.com/uclouvain/openjpeg/issues/212)
-- openjpeg-trunk issue with Win7 [\#201](https://github.com/uclouvain/openjpeg/issues/201)
-- undefined reference to `opj\_version' [\#200](https://github.com/uclouvain/openjpeg/issues/200)
-- In tgt.c we used fprintf not the openjpeg message reporter [\#184](https://github.com/uclouvain/openjpeg/issues/184)
-- Windows binaries not working under WinXP [\#176](https://github.com/uclouvain/openjpeg/issues/176)
-- add ability to use intel ipp \(performance primitive\) within OpenJPEG [\#164](https://github.com/uclouvain/openjpeg/issues/164)
-- Migration guide v2 [\#160](https://github.com/uclouvain/openjpeg/issues/160)
-- Cannot decompress JPEG2000Aware3.18.7.3Win32\_kdutranscode6.3.1.j2k [\#158](https://github.com/uclouvain/openjpeg/issues/158)
-- Cannot decompress JPEG2000Aware3.18.7.3Win32.j2k [\#157](https://github.com/uclouvain/openjpeg/issues/157)
-- openjpeg@googlegroups.com has disappeared [\#153](https://github.com/uclouvain/openjpeg/issues/153)
-- OpenJPEG 1.5.0 crashes on a ridiculously big file... [\#151](https://github.com/uclouvain/openjpeg/issues/151)
-- opj\_image vs free [\#146](https://github.com/uclouvain/openjpeg/issues/146)
-- Windows .dll file invalid [\#140](https://github.com/uclouvain/openjpeg/issues/140)
-- Problem with second layer of a 2 layer coded LRCP \(with precincts\) [\#135](https://github.com/uclouvain/openjpeg/issues/135)
-- version 1.4 crashes when opening PDF file with JPEG2000 images [\#133](https://github.com/uclouvain/openjpeg/issues/133)
-- Setup a win64 dashboard [\#132](https://github.com/uclouvain/openjpeg/issues/132)
-- J2KP4files/codestreams\_profile0/p0\_13.j2k question jpeg2000 [\#131](https://github.com/uclouvain/openjpeg/issues/131)
-- Out of memory: Kill process 11204 \(opj\_server\) score 917 or sacrifice child [\#123](https://github.com/uclouvain/openjpeg/issues/123)
-- FILE\* in opj API is unsafe [\#120](https://github.com/uclouvain/openjpeg/issues/120)
-- third-party lib order [\#119](https://github.com/uclouvain/openjpeg/issues/119)
-- openjpeg-1.5.0-Darwin-powerpc.dmg is huge ! [\#113](https://github.com/uclouvain/openjpeg/issues/113)
-- misleading info in JP2 box lead to wrong number of components [\#110](https://github.com/uclouvain/openjpeg/issues/110)
-- Image\_to\_j2k says that j2k files is generated but no file is on the HDD [\#109](https://github.com/uclouvain/openjpeg/issues/109)
-- Error in openjpegV1.4 on compiling image\_to\_j2k: crash on reading bmp file [\#108](https://github.com/uclouvain/openjpeg/issues/108)
-- Update to abi-compliance-checker 1.96 [\#106](https://github.com/uclouvain/openjpeg/issues/106)
-- Decode error on the attached JPEG...works in KDU and with JASPER...please help! [\#101](https://github.com/uclouvain/openjpeg/issues/101)
-- Mac binaries v1.4 is broken [\#95](https://github.com/uclouvain/openjpeg/issues/95)
-- jp2\_read\_boxhdr\(\) has size bug in version 1 [\#92](https://github.com/uclouvain/openjpeg/issues/92)
-- Support for Java JAI Imageio [\#90](https://github.com/uclouvain/openjpeg/issues/90)
-- encoding test failing [\#86](https://github.com/uclouvain/openjpeg/issues/86)
-- source archive on demand [\#85](https://github.com/uclouvain/openjpeg/issues/85)
-- CMakeLists.txt and Makefile.am for JPIP are buggy [\#84](https://github.com/uclouvain/openjpeg/issues/84)
-- pclr-cmap-cdef [\#82](https://github.com/uclouvain/openjpeg/issues/82)
-- Error when compiling openjpeg\_v1\_4\_sources\_r697 [\#79](https://github.com/uclouvain/openjpeg/issues/79)
-- J2K codec issue on Windows Mobile [\#77](https://github.com/uclouvain/openjpeg/issues/77)
-- image\_to\_j2k.exe crashes on large .bmp file [\#75](https://github.com/uclouvain/openjpeg/issues/75)
-- fatal error C1900 building the project on windows [\#65](https://github.com/uclouvain/openjpeg/issues/65)
-- same option but different size [\#54](https://github.com/uclouvain/openjpeg/issues/54)
-- Missing openjpegConfigure.h [\#38](https://github.com/uclouvain/openjpeg/issues/38)
-- Not an issue in openjpeg, but ... [\#37](https://github.com/uclouvain/openjpeg/issues/37)
-- OpenJPEG-1.3.0 pclr, cmap and cdef [\#27](https://github.com/uclouvain/openjpeg/issues/27)
-- realloc maybe too big \(t2.c\) [\#26](https://github.com/uclouvain/openjpeg/issues/26)
-- libopenjpeg/opj\_malloc.h breaks on FreeBSD/Darwin systems [\#20](https://github.com/uclouvain/openjpeg/issues/20)
-- image\_to\_j2k not outputting to win32 console properly [\#18](https://github.com/uclouvain/openjpeg/issues/18)
-- \[OpenJPEG\] OpenJPEG\_v13: tiled image part 2 [\#17](https://github.com/uclouvain/openjpeg/issues/17)
-- JP2 Color Space modification by Matteo Italia [\#13](https://github.com/uclouvain/openjpeg/issues/13)
-- Patch submission \( exotic video formats, and a few things \) [\#12](https://github.com/uclouvain/openjpeg/issues/12)
-- 16 bits lossy compression [\#10](https://github.com/uclouvain/openjpeg/issues/10)
-- pnm file formats not accepting bitdepth greater than 8 bpp [\#8](https://github.com/uclouvain/openjpeg/issues/8)
-- Heap corruption in j2k encoder [\#5](https://github.com/uclouvain/openjpeg/issues/5)
-- JPWL crash in marker reallocation\(+patch\), segfault while decoding image with main header protection [\#4](https://github.com/uclouvain/openjpeg/issues/4)
-- a couple of small errors in libopenjpeg detected by coverity [\#1](https://github.com/uclouvain/openjpeg/issues/1)
-
-**Closed issues:**
-
-- Shared library build broken on ubuntu [\#728](https://github.com/uclouvain/openjpeg/issues/728)
-- opj\_includes.h shouldn't define `\_\_attribute\_\_` [\#727](https://github.com/uclouvain/openjpeg/issues/727)
-- Possible website problems due to Jekyll upgrade [\#713](https://github.com/uclouvain/openjpeg/issues/713)
-- Stable Release? [\#712](https://github.com/uclouvain/openjpeg/issues/712)
-- Meta Issue : try to fix some of these critical bugs before thinking about optimizing the library [\#710](https://github.com/uclouvain/openjpeg/issues/710)
-- Tiled encoding broken for images with non power of 2 dimensions [\#702](https://github.com/uclouvain/openjpeg/issues/702)
-- install\_name \(still\) not set on OS X [\#700](https://github.com/uclouvain/openjpeg/issues/700)
-- Add section in wiki describing where one can get test images [\#699](https://github.com/uclouvain/openjpeg/issues/699)
-- Make EvenManager into singleton [\#698](https://github.com/uclouvain/openjpeg/issues/698)
-- Remove old branches from repo [\#696](https://github.com/uclouvain/openjpeg/issues/696)
-- MQ Coder encode: Conditional jump or move depends on uninitialised value\(s\) [\#695](https://github.com/uclouvain/openjpeg/issues/695)
-- Can we add these files to our test suite ? [\#688](https://github.com/uclouvain/openjpeg/issues/688)
-- -t and -d command line flags for decode are not documented on OpenJPEG website [\#685](https://github.com/uclouvain/openjpeg/issues/685)
-- Decoding at the precinct level [\#676](https://github.com/uclouvain/openjpeg/issues/676)
-- Support unscaled 10 bit data for 2K cinema @ 48 FPS, as per DCI standard [\#671](https://github.com/uclouvain/openjpeg/issues/671)
-- Use parallel jobs in ctest [\#664](https://github.com/uclouvain/openjpeg/issues/664)
-- \[Security\]Multiple Memory error [\#663](https://github.com/uclouvain/openjpeg/issues/663)
-- lossy encoding a 16 bit TIF file : severe artifacts in decompressed image [\#660](https://github.com/uclouvain/openjpeg/issues/660)
-- opj\_compress and opj\_decompress : get\_next\_file method uses hard-coded unix path separator [\#630](https://github.com/uclouvain/openjpeg/issues/630)
-- Uninitialized variable [\#629](https://github.com/uclouvain/openjpeg/issues/629)
-- Use of enum variable for bit flags prevents compilation as C++ source [\#619](https://github.com/uclouvain/openjpeg/issues/619)
-- Serious problem with quantization during lossy encoding [\#615](https://github.com/uclouvain/openjpeg/issues/615)
-- Decompression does not work with sequential data source [\#613](https://github.com/uclouvain/openjpeg/issues/613)
-- potential overflow in opj\_tcd\_tile\_t [\#605](https://github.com/uclouvain/openjpeg/issues/605)
-- Logical condition [\#596](https://github.com/uclouvain/openjpeg/issues/596)
-- file9.jp2 does not dump correctly on 1.5 [\#595](https://github.com/uclouvain/openjpeg/issues/595)
-- opj\_compress man page is missing documentation of -jpip option [\#593](https://github.com/uclouvain/openjpeg/issues/593)
-- opj\_compress fails to compress lossless on gcc/x86 \(-m32\) in 1.5 branch [\#591](https://github.com/uclouvain/openjpeg/issues/591)
-- Example: opj\_compress -i image.j2k -o image.pgm [\#577](https://github.com/uclouvain/openjpeg/issues/577)
-- Mismatching delete [\#575](https://github.com/uclouvain/openjpeg/issues/575)
-- Compilation fails on Win7 [\#546](https://github.com/uclouvain/openjpeg/issues/546)
-- NR-JP2-file5.jp2-compare2base fails with third party libcms [\#540](https://github.com/uclouvain/openjpeg/issues/540)
-- CTest spits out an error at the end of the test run [\#516](https://github.com/uclouvain/openjpeg/issues/516)
-- opj\_uint\_adds\(\) is questionable [\#515](https://github.com/uclouvain/openjpeg/issues/515)
-- Might consider renaming this method: [\#491](https://github.com/uclouvain/openjpeg/issues/491)
-- opj\_compress run twice gives different fiile sizes for same file [\#490](https://github.com/uclouvain/openjpeg/issues/490)
-- Android Support [\#483](https://github.com/uclouvain/openjpeg/issues/483)
-- Add SSE2/SSE41 implementations for mct.c [\#451](https://github.com/uclouvain/openjpeg/issues/451)
-- Reduce encoder code block memory usage for non 64x64 code block sizes [\#444](https://github.com/uclouvain/openjpeg/issues/444)
-- valgrind "Uninitialized Memory Read" & "Uninitialized Memory Conditional" found [\#438](https://github.com/uclouvain/openjpeg/issues/438)
-- No way to debug opj\_tcd\_init\_encode\_tile or opj\_tcd\_init\_decode\_tile [\#433](https://github.com/uclouvain/openjpeg/issues/433)
-- Add option to call dsymutil on built binaries [\#409](https://github.com/uclouvain/openjpeg/issues/409)
-- Allow opj\_compress and opj\_decompress to read/write images over stdin/stdout [\#379](https://github.com/uclouvain/openjpeg/issues/379)
-- reduce memory significantly for single tile RGB encoding [\#375](https://github.com/uclouvain/openjpeg/issues/375)
-- Switch code repo to github and start using pull request workflow [\#373](https://github.com/uclouvain/openjpeg/issues/373)
-- This is a BigTIFF file. This format not supported [\#125](https://github.com/uclouvain/openjpeg/issues/125)
-- Add a test suite to check the convert functions [\#99](https://github.com/uclouvain/openjpeg/issues/99)
-- Add build config to the dashboard to verify the autotools build [\#88](https://github.com/uclouvain/openjpeg/issues/88)
-
-**Merged pull requests:**
-
-- Correct abi-check.sh for PR [\#791](https://github.com/uclouvain/openjpeg/pull/791) ([mayeut](https://github.com/mayeut))
-- Update tcd.c [\#790](https://github.com/uclouvain/openjpeg/pull/790) ([maddin200](https://github.com/maddin200))
-- Update lcms2 [\#773](https://github.com/uclouvain/openjpeg/pull/773) ([mayeut](https://github.com/mayeut))
-- Use lowercase for cmake commands consistently [\#769](https://github.com/uclouvain/openjpeg/pull/769) ([julienmalik](https://github.com/julienmalik))
-- Ignore clang's summary warning [\#768](https://github.com/uclouvain/openjpeg/pull/768) ([julienmalik](https://github.com/julienmalik))
-- Fix UBSan gcc warning for first arg to memset non null [\#767](https://github.com/uclouvain/openjpeg/pull/767) ([julienmalik](https://github.com/julienmalik))
-- Update to libtiff-4.0.6 [\#764](https://github.com/uclouvain/openjpeg/pull/764) ([mayeut](https://github.com/mayeut))
-- Fix warnings [\#763](https://github.com/uclouvain/openjpeg/pull/763) ([mayeut](https://github.com/mayeut))
-- Check SSIZ is valid in opj\_j2k\_read\_siz [\#762](https://github.com/uclouvain/openjpeg/pull/762) ([mayeut](https://github.com/mayeut))
-- Fix unsigned int overflow reported by UBSan [\#761](https://github.com/uclouvain/openjpeg/pull/761) ([mayeut](https://github.com/mayeut))
-- Fix unsigned int overflow reported by UBSan [\#759](https://github.com/uclouvain/openjpeg/pull/759) ([mayeut](https://github.com/mayeut))
-- Fix negative shift left reported by UBSan [\#758](https://github.com/uclouvain/openjpeg/pull/758) ([mayeut](https://github.com/mayeut))
-- Fix negative shift left reported by UBSan [\#757](https://github.com/uclouvain/openjpeg/pull/757) ([mayeut](https://github.com/mayeut))
-- Add clang 3.9 build to Travis matrix [\#753](https://github.com/uclouvain/openjpeg/pull/753) ([julienmalik](https://github.com/julienmalik))
-- Fix implicit floating bool conversion [\#752](https://github.com/uclouvain/openjpeg/pull/752) ([julienmalik](https://github.com/julienmalik))
-- Do not define \_\_attribute\_\_ in opj\_includes.h [\#751](https://github.com/uclouvain/openjpeg/pull/751) ([mayeut](https://github.com/mayeut))
-- Allow to read/write 3/5/7/9/11/13/15 bpp TIF files [\#750](https://github.com/uclouvain/openjpeg/pull/750) ([mayeut](https://github.com/mayeut))
-- Fix heap-buffer-overflow in color\_esycc\_to\_rgb [\#748](https://github.com/uclouvain/openjpeg/pull/748) ([mayeut](https://github.com/mayeut))
-- update libpng to from 1.6.17 to 1.6.21 [\#747](https://github.com/uclouvain/openjpeg/pull/747) ([julienmalik](https://github.com/julienmalik))
-- Update cmake & jpylyzer for travis builds [\#746](https://github.com/uclouvain/openjpeg/pull/746) ([julienmalik](https://github.com/julienmalik))
-- Fix Out-Of-Bounds Read in sycc42x\_to\_rgb function [\#745](https://github.com/uclouvain/openjpeg/pull/745) ([mayeut](https://github.com/mayeut))
-- cppcheck fix for openjp2 [\#740](https://github.com/uclouvain/openjpeg/pull/740) ([julienmalik](https://github.com/julienmalik))
-- Fix uninitialized variable reported by cppcheck [\#735](https://github.com/uclouvain/openjpeg/pull/735) ([julienmalik](https://github.com/julienmalik))
-- Remove dead code in opj\_dump [\#734](https://github.com/uclouvain/openjpeg/pull/734) ([julienmalik](https://github.com/julienmalik))
-- issue \#695 MQ Encode: ensure that bp pointer never points to uninitialized memory [\#708](https://github.com/uclouvain/openjpeg/pull/708) ([boxerab](https://github.com/boxerab))
-- Fix issue 135 [\#706](https://github.com/uclouvain/openjpeg/pull/706) ([mayeut](https://github.com/mayeut))
-- Fix implementation of opj\_calloc [\#705](https://github.com/uclouvain/openjpeg/pull/705) ([stweil](https://github.com/stweil))
-- \[git/2.1 regression\] Fix opj\_write\_tile\(\) failure when numresolutions=1 [\#690](https://github.com/uclouvain/openjpeg/pull/690) ([rouault](https://github.com/rouault))
-- Fix fatal crash on 64 bit Linux [\#687](https://github.com/uclouvain/openjpeg/pull/687) ([stweil](https://github.com/stweil))
-- \[libtiff\] Add missing include statement for ssize\_t [\#686](https://github.com/uclouvain/openjpeg/pull/686) ([mayeut](https://github.com/mayeut))
-- Fix duplicate article in comments [\#684](https://github.com/uclouvain/openjpeg/pull/684) ([stweil](https://github.com/stweil))
-- Fix grammar in comment [\#679](https://github.com/uclouvain/openjpeg/pull/679) ([stweil](https://github.com/stweil))
-- Remove whitespace and CR at line endings [\#678](https://github.com/uclouvain/openjpeg/pull/678) ([stweil](https://github.com/stweil))
-- Fix typos [\#665](https://github.com/uclouvain/openjpeg/pull/665) ([jwilk](https://github.com/jwilk))
-- Add missing source for the JPIP library and executables \(issue \#658\) [\#659](https://github.com/uclouvain/openjpeg/pull/659) ([stweil](https://github.com/stweil))
-- Fix undefined size jp2 box handling [\#654](https://github.com/uclouvain/openjpeg/pull/654) ([mayeut](https://github.com/mayeut))
-- opj\_decompress: Update error message [\#651](https://github.com/uclouvain/openjpeg/pull/651) ([stweil](https://github.com/stweil))
-- Fix support of posix\_memalloc for Linux [\#648](https://github.com/uclouvain/openjpeg/pull/648) ([stweil](https://github.com/stweil))
-- Fix typo in comments [\#647](https://github.com/uclouvain/openjpeg/pull/647) ([stweil](https://github.com/stweil))
-- Avoid pointer arithmetic with \(void \*\) pointers [\#644](https://github.com/uclouvain/openjpeg/pull/644) ([smuehlst](https://github.com/smuehlst))
-- Fix HP compiler warning about redeclaration of function \(\#640\) [\#641](https://github.com/uclouvain/openjpeg/pull/641) ([smuehlst](https://github.com/smuehlst))
-- Fix format strings and unneeded assignment [\#638](https://github.com/uclouvain/openjpeg/pull/638) ([stweil](https://github.com/stweil))
-- Fix repository for JPEG2000 test data [\#637](https://github.com/uclouvain/openjpeg/pull/637) ([stweil](https://github.com/stweil))
-- Update allocation functions [\#636](https://github.com/uclouvain/openjpeg/pull/636) ([mayeut](https://github.com/mayeut))
-- Fix OpenJPEG GitHub issue \#633. [\#634](https://github.com/uclouvain/openjpeg/pull/634) ([smuehlst](https://github.com/smuehlst))
-- travis-ci: Include add ons in matrix [\#632](https://github.com/uclouvain/openjpeg/pull/632) ([mayeut](https://github.com/mayeut))
-- Add Appveyor [\#627](https://github.com/uclouvain/openjpeg/pull/627) ([mayeut](https://github.com/mayeut))
-- Use Travis-ci to run ABI check [\#626](https://github.com/uclouvain/openjpeg/pull/626) ([mayeut](https://github.com/mayeut))
-- Fix warnings for C++ [\#623](https://github.com/uclouvain/openjpeg/pull/623) ([stweil](https://github.com/stweil))
-- Fixed problem that C++ compilation failed because of enum variable. [\#622](https://github.com/uclouvain/openjpeg/pull/622) ([smuehlst](https://github.com/smuehlst))
-- Added missing casts for return values of opj\_malloc\(\)/opj\_calloc\(\). [\#618](https://github.com/uclouvain/openjpeg/pull/618) ([smuehlst](https://github.com/smuehlst))
-- Add check for seek support before trying TPsot==TNsot workaround [\#617](https://github.com/uclouvain/openjpeg/pull/617) ([mayeut](https://github.com/mayeut))
-- Fix some typos found by codespell [\#610](https://github.com/uclouvain/openjpeg/pull/610) ([stweil](https://github.com/stweil))
-- Correct leak in color\_cielab\_to\_rgb [\#590](https://github.com/uclouvain/openjpeg/pull/590) ([mayeut](https://github.com/mayeut))
-- Add Travis-ci build matrix [\#584](https://github.com/uclouvain/openjpeg/pull/584) ([mayeut](https://github.com/mayeut))
-- Correct lossless issue on linux x86 [\#579](https://github.com/uclouvain/openjpeg/pull/579) ([mayeut](https://github.com/mayeut))
-- Travis-ci update [\#578](https://github.com/uclouvain/openjpeg/pull/578) ([mayeut](https://github.com/mayeut))
-- Correct CMake version requirements [\#572](https://github.com/uclouvain/openjpeg/pull/572) ([mayeut](https://github.com/mayeut))
-- Add tests for CMYK/esYCC/CIELab [\#567](https://github.com/uclouvain/openjpeg/pull/567) ([mayeut](https://github.com/mayeut))
-- Add support for CIELab, EYCC and CMYK [\#559](https://github.com/uclouvain/openjpeg/pull/559) ([szukw000](https://github.com/szukw000))
-- Remove printf/fprintf to stdout/stderr throughout openjp2 lib [\#558](https://github.com/uclouvain/openjpeg/pull/558) ([mayeut](https://github.com/mayeut))
-- better -ffast-math handling [\#555](https://github.com/uclouvain/openjpeg/pull/555) ([rdieter](https://github.com/rdieter))
-- Add jpylyzer tests for JP2 compression [\#552](https://github.com/uclouvain/openjpeg/pull/552) ([mayeut](https://github.com/mayeut))
-- Add COC/QCC in main header when needed [\#551](https://github.com/uclouvain/openjpeg/pull/551) ([mayeut](https://github.com/mayeut))
-- Use \_\_emul under msvc x86 for fast 64 = 32 \* 32 [\#550](https://github.com/uclouvain/openjpeg/pull/550) ([mayeut](https://github.com/mayeut))
-- Update convert for PNG output [\#549](https://github.com/uclouvain/openjpeg/pull/549) ([mayeut](https://github.com/mayeut))
-- Remove some warnings when building [\#548](https://github.com/uclouvain/openjpeg/pull/548) ([mayeut](https://github.com/mayeut))
-- Switch to libpng-1.6.17 [\#547](https://github.com/uclouvain/openjpeg/pull/547) ([mayeut](https://github.com/mayeut))
-- Add some missing static keywords [\#545](https://github.com/uclouvain/openjpeg/pull/545) ([mayeut](https://github.com/mayeut))
-- Switch to libcms2 mm2/Little-CMS@0e8234e090d6aab33f90e2eb0296f30aa0705e57 [\#544](https://github.com/uclouvain/openjpeg/pull/544) ([mayeut](https://github.com/mayeut))
-- Prevent overflow when coding 16 bits images [\#543](https://github.com/uclouvain/openjpeg/pull/543) ([mayeut](https://github.com/mayeut))
-- Switch to libcms2-2.6 [\#542](https://github.com/uclouvain/openjpeg/pull/542) ([mayeut](https://github.com/mayeut))
-- Update PNG support [\#538](https://github.com/uclouvain/openjpeg/pull/538) ([mayeut](https://github.com/mayeut))
-- Various Minor fixes [\#537](https://github.com/uclouvain/openjpeg/pull/537) ([mayeut](https://github.com/mayeut))
-- Update TIFF conversion to support more bit depth. [\#535](https://github.com/uclouvain/openjpeg/pull/535) ([mayeut](https://github.com/mayeut))
-- Add checks for odd looking cmap & for cmap outside jp2h box [\#534](https://github.com/uclouvain/openjpeg/pull/534) ([mayeut](https://github.com/mayeut))
-- Refactor opj\_j2k\_read\_ppm & opj\_j2k\_read\_ppt [\#533](https://github.com/uclouvain/openjpeg/pull/533) ([mayeut](https://github.com/mayeut))
-- Add option to force component splitting in imagetopnm [\#531](https://github.com/uclouvain/openjpeg/pull/531) ([mayeut](https://github.com/mayeut))
-- fix Suspicious code in j2k.c \#517 [\#529](https://github.com/uclouvain/openjpeg/pull/529) ([renevanderark](https://github.com/renevanderark))
-- Update zlib to version 1.2.8 [\#528](https://github.com/uclouvain/openjpeg/pull/528) ([mayeut](https://github.com/mayeut))
-- Fix opj\_write\_bytes\_BE \(\#518\) [\#521](https://github.com/uclouvain/openjpeg/pull/521) ([manisandro](https://github.com/manisandro))
-- Correctly decode files with incorrect tile-part header fields \(TPsot==TNsot\) [\#514](https://github.com/uclouvain/openjpeg/pull/514) ([mayeut](https://github.com/mayeut))
-- Fixed typos [\#510](https://github.com/uclouvain/openjpeg/pull/510) ([radarhere](https://github.com/radarhere))
-- Formatted the readme file [\#507](https://github.com/uclouvain/openjpeg/pull/507) ([htmfilho](https://github.com/htmfilho))
-
-## [version.2.1](https://github.com/uclouvain/openjpeg/releases/tag/version.2.1) (2014-04-29)
-List of fixed issues and enhancements unavailable, see [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) or [Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.2.0.1...version.2.1)
-
-## [version.2.0.1](https://github.com/uclouvain/openjpeg/releases/tag/version.2.0.1) (2014-04-22)
-List of fixed issues and enhancements unavailable, see [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) or [Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.1.5.2...version.2.0.1)
-
-## [version.1.5.2](https://github.com/uclouvain/openjpeg/releases/tag/version.1.5.2) (2014-03-28)
-List of fixed issues and enhancements unavailable, see [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) or [Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.2.0...version.1.5.2)
-
-## [version.2.0](https://github.com/uclouvain/openjpeg/releases/tag/version.2.0) (2014-03-28)
-List of fixed issues and enhancements unavailable, see [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) or [Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.1.5.1...version.2.0)
-
-## [version.1.5.1](https://github.com/uclouvain/openjpeg/releases/tag/version.1.5.1) (2012-09-13)
-List of fixed issues and enhancements unavailable, see [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) or [Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.1.5...version.1.5.1)
-
-## [version.1.5](https://github.com/uclouvain/openjpeg/releases/tag/version.1.5) (2012-02-07)
-List of fixed issues and enhancements unavailable, see [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) or [Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.1.3...version.1.5)
-
-## [version.1.3](https://github.com/uclouvain/openjpeg/releases/tag/version.1.3) (2011-07-03)
-List of fixed issues and enhancements unavailable, see [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) or [Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.1.4...version.1.3)
-
-## [version.1.4](https://github.com/uclouvain/openjpeg/releases/tag/version.1.4) (2011-07-03)
-List of fixed issues and enhancements unavailable, see [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) or [Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.1.2...version.1.4)
-
-## [version.1.2](https://github.com/uclouvain/openjpeg/releases/tag/version.1.2) (2007-06-04)
-List of fixed issues and enhancements unavailable, see [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) or [Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.1.1...version.1.2)
-
-## [version.1.1](https://github.com/uclouvain/openjpeg/releases/tag/version.1.1) (2007-01-31)
-List of fixed issues and enhancements unavailable, see [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) or [Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.1.0...version.1.1)
-
-
-
-\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
diff --git a/contrib/libs/openjpeg/HOWTO-RELEASE b/contrib/libs/openjpeg/HOWTO-RELEASE
deleted file mode 100644
index 2e4450c370..0000000000
--- a/contrib/libs/openjpeg/HOWTO-RELEASE
+++ /dev/null
@@ -1,34 +0,0 @@
-Check-list OpenJPEG Release
-
-* update MAJOR, MINOR, BUILD, SOVERSION in CMakeLists.txt
-* update MAJOR, MINOR, BUILD in appveyor.yml
-* update CHANGELOG with
-`github_changelog_generator --token TOKEN_HERE --exclude-labels gcode_fixed,OpjVersion-1.x --release-url "https://github.com/uclouvain/openjpeg/releases/%s" --since-tag v2.5.0 --future-release v2.5.1 --output append2changelog.md --user uclouvain --project openjpeg --exclude-tags version.1.0` . TOKEN_HERE is created at https://github.com/settings/tokens
-* update NEWS.md
-* git commit -a -m "Prepare for OpenJPEG v2.5.1 release"
-* git tag -a v2.5.1 -m "OpenJPEG v2.5.1 release"
-* git push origin --tags
-* add post to OpenJPEG website in gh-pages branch in _posts/ subdirectory. See commit https://github.com/uclouvain/openjpeg/commit/6563d704f5fb896209dd862ccfc6b97eb9183c5c
-* change binversion of openjpeg website in _config.yml in gh-pages branch
-* update release description if needed
-* update openjpeg.json with latest release
-* update OPJ_LATEST_VERSION in abi-check.sh, uncomment and update OPJ_PREVIOUS_VERSION in abi-check.sh, and push
-* locally run: OPJ_CI_ABI_CHECK=1 ./tools/travis-ci/abi-check.sh
-* cd ~/abi-check/work/abi-check/
-* put the sources of the new version in src/openjpeg/2.5.1/version.-2.5.1.tar.gz
-* PATH=$PWD/../../tools/abi-tracker/bin:$PWD/../../tools/wdiff/bin:$PWD/../../tools:$PATH abi-monitor -v 2.5.1 -build ./openjpeg.json
-* PATH=$PWD/../../tools/abi-tracker/bin:$PWD/../../tools/wdiff/bin:$PWD/../../tools:$PATH abi-tracker -build ./openjpeg.json
-* rm -rf src/openjpeg/current
-* rm -rf build_logs
-* Remove symbolic links: rm -f installed/openjpeg/2.5.1/lib/libopenjp2.so installed/openjpeg/2.5.1/lib/libopenjp2.so.7 installed/openjpeg/current/lib/libopenjp2.so abi-check/installed/openjpeg/current/lib/libopenjp2.so.7
-* git add --all .
-* git commit -m "Update ABI/API compatibility reports after 2.5.1 release"
-* git push
-* cd ~/openjpeg/openjpeg
-* comment back OPJ_PREVIOUS_VERSION and push
-* build doc and update Doxygen on website
-* manual build on Windows:
- - cmake .. -G "Visual Studio 15 2017" -A x64 -DCMAKE_CONFIGURATION_TYPES=Release -DBUILD_THIRDPARTY=ON -D CPACK_GENERATOR:STRING=ZIP -D CPACK_PACKAGE_FILE_NAME:STRING=openjpeg-v2.4.0-windows-x64
- - cmake --build . --target package --config Release
-* send email to ML opj, comp.compression, iiif
-* tweet
diff --git a/contrib/libs/openjpeg/INSTALL.md b/contrib/libs/openjpeg/INSTALL.md
deleted file mode 100644
index a931404055..0000000000
--- a/contrib/libs/openjpeg/INSTALL.md
+++ /dev/null
@@ -1,137 +0,0 @@
-
-# OpenJPEG installation
-
-The build method maintained by OpenJPEG is [CMake](https://cmake.org/).
-
-## UNIX/LINUX - MacOS (terminal) - WINDOWS (cygwin, MinGW)
-
-To build the library, type from source tree directory:
-```
-mkdir build
-cd build
-cmake .. -DCMAKE_BUILD_TYPE=Release
-make
-```
-Binaries are then located in the 'bin' directory.
-
-To install the library, type with root privileges:
-```
-make install
-make clean
-```
-
-To build the html documentation, you need doxygen to be installed on your system.
-It will create an "html" directory in TOP\_LEVEL/build/doc)
-```
-make doc
-```
-
-Main available cmake flags:
- * To specify the install path: '-DCMAKE\_INSTALL\_PREFIX=/path'
- * To build the shared libraries and links the executables against it: '-DBUILD\_SHARED\_LIBS:bool=on' (default: 'ON')
-> Note: when using this option, static libraries are not built and executables are dynamically linked.
- * To build the CODEC executables: '-DBUILD\_CODEC:bool=on' (default: 'ON')
- * To build opjstyle (internal version of astyle) for OpenJPEG development: '-DWITH_ASTYLE=ON'
- * [OBSOLETE] To build the MJ2 executables: '-DBUILD\_MJ2:bool=on' (default: 'OFF')
- * [OBSOLETE] To build the JPWL executables and JPWL library: '-DBUILD\_JPWL:bool=on' (default: 'OFF')
- * [OBSOLETE] To build the JPIP client (java compiler recommended) library and executables: '-DBUILD\_JPIP:bool=on' (default: 'OFF')
- * [OBSOLETE] To build the JPIP server (need fcgi) library and executables: '-DBUILD\_JPIP\_SERVER:bool=on' (default: 'OFF')
- * To enable testing (and automatic result upload to http://my.cdash.org/index.php?project=OPENJPEG):
-```
-cmake . -DBUILD_TESTING:BOOL=ON -DOPJ_DATA_ROOT:PATH='path/to/the/data/directory' -DBUILDNAME:STRING='name_of_the_build'
-make
-make Experimental
-```
-Note : test data is available on the following github repo: https://github.com/uclouvain/openjpeg-data
-
-If '-DOPJ\_DATA\_ROOT:PATH' option is omitted, test files will be automatically searched in '${CMAKE\_SOURCE\_DIR}/../data'.
-
-Note 2 : to execute the encoding test suite, kakadu binaries are needed to decode encoded image and compare it to the baseline. Kakadu binaries are freely available for non-commercial purposes at http://www.kakadusoftware.com. kdu\_expand will need to be in your PATH for cmake to find it.
-
-Note 3 : OpenJPEG encoder and decoder (not the library itself !) depends on several libraries: png, tiff, lcms, z. If these libraries are not found on the system, they are automatically built from the versions available in the source tree. You can force the use of these embedded version with BUILD\_THIRDPARTY:BOOL=ON. On a Debian-like system you can also simply install these libraries with:
-```
-sudo apt-get install liblcms2-dev libtiff-dev libpng-dev libz-dev
-```
-
-Note 4 : On MacOS, if it does not work, try adding the following flag to the cmake command :
-```
--DCMAKE_OSX_ARCHITECTURES:STRING=i386
-```
-
-## MacOS (XCode) - WINDOWS (VisualStudio, etc)
-
-You can use cmake to generate the project files for the IDE you are using (VC2010, XCode, etc).
-Type `cmake --help` for available generators on your platform.
-
-Examples for Windows with Visual Studio C++ compiler:
-
-If using directly the cl compiler:
-
-```
-cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE:string="Release" -DBUILD_SHARED_LIBS:bool=on -DCMAKE_INSTALL_PREFIX:path="%USERPROFILE%" -DCMAKE_LIBRARY_PATH:path="%USERPROFILE%" -DCMAKE_INCLUDE_PATH:path="%USERPROFILE%\include" ..
-```
-
-To compile a 64-bit application, open 64-Bit Visual C\+\+ toolset on the command line and run cmake. For further information, please refer to: [How to: Enable a 64-Bit Visual C\+\+ Toolset on the Command Line](https://msdn.microsoft.com/en-us/library/x4d2c09s.aspx).
-
-
-If you do not want directly use the cl compiler, you could use:
-
-```
-cmake -DCMAKE_BUILD_TYPE:string="Release" -DBUILD_SHARED_LIBS:bool=on -DCMAKE_INSTALL_PREFIX:path="%USERPROFILE%" -DCMAKE_LIBRARY_PATH:path="%USERPROFILE%" -DCMAKE_INCLUDE_PATH:path="%USERPROFILE%\include" ..
-```
-
-To create Visual Studio solution (.sln) and project files (.vcproj / .vcxproj):
-```
-cmake -G "Visual Studio 14 2015" -DCMAKE_BUILD_TYPE:string="Release" -DBUILD_SHARED_LIBS:bool=on -DCMAKE_INSTALL_PREFIX:path="%USERPROFILE%" -DCMAKE_LIBRARY_PATH:path="%USERPROFILE%" -DCMAKE_INCLUDE_PATH:path="%USERPROFILE%\include" ..
-```
-
-64-bit application:
-```
-cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE:string="Release" -DBUILD_SHARED_LIBS:bool=on -DCMAKE_INSTALL_PREFIX:path="%USERPROFILE%" -DCMAKE_LIBRARY_PATH:path="%USERPROFILE%" -DCMAKE_INCLUDE_PATH:path="%USERPROFILE%\include" ..
-```
-
-
-# Enabling CPU specific optimizations
-
-For Intel/AMD processors, OpenJPEG implements optimizations using the SSE4.1
-instruction set (for example, for the 9x7 inverse MCT transform) and the AVX2
-instruction set (for example, for the 5x3 inverse discrete wavelet transform).
-Currently, those optimizations are only available if OpenJPEG is built to
-use those instruction sets (and the resulting binary will only run on compatible
-CPUs)
-
-With gcc/clang, it is possible to enable those instruction sets with the following :
-
-```
-cmake -DCMAKE_C_FLAGS="-O3 -msse4.1 -DNDEBUG" ..
-```
-
-```
-cmake -DCMAKE_C_FLAGS="-O3 -mavx2 -DNDEBUG" ..
-```
-
-(AVX2 implies SSE4.1)
-
-Or if the binary is dedicated to run on the machine where it has
-been compiled :
-
-```
-cmake -DCMAKE_C_FLAGS="-O3 -march=native -DNDEBUG" ..
-```
-
-# Modifying OpenJPEG
-
-Before committing changes, run:
-```scripts/prepare-commit.sh```
-
-# Using OpenJPEG
-
-To use openjpeg exported cmake file, simply create your application doing:
-
-```
-$ cat CMakeLists.txt
-find_package(OpenJPEG REQUIRED)
-include_directories(${OPENJPEG_INCLUDE_DIRS})
-add_executable(myapp myapp.c)
-target_link_libraries(myapp ${OPENJPEG_LIBRARIES})
-```
diff --git a/contrib/libs/openjpeg/LICENSE b/contrib/libs/openjpeg/LICENSE
deleted file mode 100644
index e8fa41040d..0000000000
--- a/contrib/libs/openjpeg/LICENSE
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2014, Professor Benoit Macq
- * Copyright (c) 2003-2014, Antonin Descampe
- * Copyright (c) 2003-2009, Francois-Olivier Devaux
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2011-2012, Centre National d'Etudes Spatiales (CNES), France
- * Copyright (c) 2012, CS Systemes d'Information, France
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
diff --git a/contrib/libs/openjpeg/NEWS.md b/contrib/libs/openjpeg/NEWS.md
deleted file mode 100644
index 9e8b6b72a8..0000000000
--- a/contrib/libs/openjpeg/NEWS.md
+++ /dev/null
@@ -1,174 +0,0 @@
-# OpenJPEG NEWS
-
-More details in the [CHANGELOG](https://github.com/uclouvain/openjpeg/blob/master/CHANGELOG.md)
-
-## OpenJPEG 2.5.3 (Dec 2024)
-
-No API/ABI break compared to v2.5.2
-
-### New Features
-
-* Use TLM \(Tile Length Marker\) segments to optimize decoding [\#1538](https://github.com/uclouvain/openjpeg/pull/1538)
-* Add AVX2 and AVX512 optimization [\#1552](https://github.com/uclouvain/openjpeg/pull/1552)
-* Support setting enumcs for CMYK and EYCC color space [\#1529](https://github.com/uclouvain/openjpeg/pull/1529)
-
-### Bug fixes
-
-* Do not turn on 'TPsot==TNsot detection fix' when TNsot==1, and add a OPJ_DPARAMETERS_DISABLE_TPSOT_FIX flag to disable it [\#1560](https://github.com/uclouvain/openjpeg/pull/1560)
-* opj\_j2k\_setup\_encoder\(\): set numgbits = 1 for Cinema2K [\#1559](https://github.com/uclouvain/openjpeg/pull/1559)
-* fix: when EPH markers are specified, they are required. [\#1547](https://github.com/uclouvain/openjpeg/pull/1547)
-* sycc422\_to\_rgb\(\): fix out-of-bounds read accesses when 2 \* width\_component\_1\_or\_2 + 1 == with\_component\_0 [\#1566](https://github.com/uclouvain/openjpeg/pull/1566)
-* Avoid heap-buffer-overflow read on corrupted image in non-strict mode [\#1536](https://github.com/uclouvain/openjpeg/pull/1536)
-* opj\_j2k\_read\_sod\(\): validate opj\_stream\_read\_data\(\) return to avoid potential later heap-buffer-overflow in in opj_t1_decode_cblk when disabling strict mode [\#1534](https://github.com/uclouvain/openjpeg/pull/1534)
-* fix integer Overflow at j2k.c:9614 [\#1530](https://github.com/uclouvain/openjpeg/pull/1530)
-* Memory leak fixes in error code path of opj\_compress [\#1567](https://github.com/uclouvain/openjpeg/issues/1567)
-* opj\_j2k\_decode\_tiles\(\): avoid use of uninitialized l\_current\_tile\_no variable [\#1528](https://github.com/uclouvain/openjpeg/pull/1528)
-* Do not allow header length to be zero in non-zero length packet [\#1526](https://github.com/uclouvain/openjpeg/pull/1526)
-* Fix building on OpenBSD big endian hosts [\#1520](https://github.com/uclouvain/openjpeg/pull/1520)
-
-### Changes in third party components
-
-* thirdparty/libz: update to zlib-1.3.1 [\#1542](https://github.com/uclouvain/openjpeg/pull/1542)
-* thirdparty/libpng: update to libpng-1.6.43 [\#1541](https://github.com/uclouvain/openjpeg/pull/1541)
-* thirdparty/libtiff: update to libtiff 4.6.0 [\#1540](https://github.com/uclouvain/openjpeg/pull/1540)
-
-## OpenJPEG 2.5.2 (Feb 2024)
-
-No API/ABI break compared to v2.5.1
-
-* Make sure openjpeg.h includes opj_config.h [\#1514](https://github.com/uclouvain/openjpeg/issues/1514)
-
-## OpenJPEG 2.5.1 (Feb 2024)
-
-No API/ABI break compared to v2.5.0
-
-* CMake: drop support for cmake < 3.5
-* Several bugfixes, including [\#1509](https://github.com/uclouvain/openjpeg/pull/1509) for CVE-2021-3575
-* Significant speed-up rate allocation by rate/distoratio ratio [\#1440](https://github.com/uclouvain/openjpeg/pull/1440)
-
-## OpenJPEG 2.5.0 (May 2022)
-
-No API/ABI break compared to v2.4.0, but additional symbols for subset of components decoding (hence the MINOR version bump).
-
-* Encoder: add support for generation of TLM markers [\#1359](https://github.com/uclouvain/openjpeg/pull/1359)
-* Decoder: add support for high throughput \(HTJ2K\) decoding. [\#1381](https://github.com/uclouvain/openjpeg/pull/1381)
-* Decoder: add support for partial bitstream decoding [\#1407](https://github.com/uclouvain/openjpeg/pull/1407)
-* Bug fixes (including security fixes)
-
-## OpenJPEG 2.4.0 (December 2020)
-
-No API/ABI break compared to v2.3.1, but additional symbols for subset of components decoding (hence the MINOR version bump).
-
-* Encoder: add support for multithreading [\#1248](https://github.com/uclouvain/openjpeg/pull/1248)
-* Encoder: add support for generation of PLT markers [\#1246](https://github.com/uclouvain/openjpeg/pull/1246)
-* Encoder: single-threaded performance improvements in forward DWT for 5-3 and 9-7 (and other improvements) [\#1253](https://github.com/uclouvain/openjpeg/pull/1253)
-* Encoder: support IMF profiles [\#1235](https://github.com/uclouvain/openjpeg/pull/1235)
-* Many bug fixes (including security fixes)
-
-## OpenJPEG 2.3.1 (April 2019)
-
-No API/ABI break compared to v2.3.0
-
-* Many bug fixes (including security fixes)
-
-## OpenJPEG 2.3.0 (October 2017)
-
-No API/ABI break compared to v2.2.0 but additional symbols for subset of components decoding (hence the MINOR version bump).
-
-* Sub-tile decoding: when setting a window of interest through the API function opj_set_decode_area(), only codeblocks that intersect this window are now decoded (i.e. MCT, IDWT, and entropy decoding are only done on the window of interest). Moreover, memory allocation now depends on the size of the window of interest (instead of the full tile size).
-[\#990](https://github.com/uclouvain/openjpeg/pull/990) [\#1001](https://github.com/uclouvain/openjpeg/pull/1001) [\#1010](https://github.com/uclouvain/openjpeg/pull/1010)
-* Ability to decode only a subset of components. This adds the following function `opj_set_decoded_components(opj_codec_t p_codec, OPJ_UINT32 numcomps, const OPJ_UINT32 comps_indices, OPJ_BOOL apply_color_transforms)` and equivalent `opj_decompress -c compno[,compno]*`
-option.
-[\#1022](https://github.com/uclouvain/openjpeg/pull/1022)
-* Many bug fixes (including security fixes)
-
-## OpenJPEG 2.2.0 (August 2017)
-
-No API/ABI break compared to v2.1.2 but additional symbols for multithreading support (hence the MINOR version bump).
-
-### Codebase improvements
-
-* Memory consumption reduction at decoding side [\#968](https://github.com/uclouvain/openjpeg/pull/968)
-* Multi-threading support at decoding side [\#786](https://github.com/uclouvain/openjpeg/pull/786)
-* Tier-1 speed optimizations (encoder and decoder) [\#945](https://github.com/uclouvain/openjpeg/pull/945)
-* Tier-1 decoder further optimization [\#783](https://github.com/uclouvain/openjpeg/pull/783)
-* Inverse 5x3 DWT speed optimization: single-pass lifting and SSE2/AVX2 implementation [\#957](https://github.com/uclouvain/openjpeg/pull/957)
-* Fixed a bug that prevented OpenJPEG to compress losslessly in some situations [\#949](https://github.com/uclouvain/openjpeg/pull/949)
-* Fixed BYPASS/LAZY, RESTART/TERMALL and PTERM mode switches
-* Many other bug fixes (including security fixes)
-
-### Maintenance improvements
-
-* Benchmarking scripts to automatically compare the speed of latest OpenJPEG build with latest release and/or Kakadu binaries [\#917](https://github.com/uclouvain/openjpeg/pull/917)
-* CPU and RAM usage profiling scripts [\#918](https://github.com/uclouvain/openjpeg/pull/918)
-* Codebase reformatting (with astyle) and scripts to automatically check that new commits comply with formatting guidelines [\#919](https://github.com/uclouvain/openjpeg/pull/919)
-* Register OpenJPEG at Google OSS Fuzz initiative, so as to automatically have OpenJPEG tested against Google fuzzer [\#965](https://github.com/uclouvain/openjpeg/issues/965)
-
-## OpenJPEG 2.1.2 (September 2016)
-
-* Bug fixes (including security fixes)
-* No API/ABI break compared to v2.1.1
-
-## OpenJPEG 2.1.1 (July 2016)
-
-* Huge amount of critical bugfixes
-* Speed improvements
-* No API/ABI break compared to v2.1
-
-## OpenJPEG 2.1.0 (April 2014)
-
-### New Features
-
- * Digital Cinema profiles have been fixed and updated
- * New option to disable MCT if needed
- * extended RAW support: it is now possible to input raw images
- with subsampled color components (422, 420, etc)
- * New way to deal with profiles
-
-### API/ABI modifications
-(see [here](http://www.openjpeg.org/abi-check/timeline/openjpeg/) for details)
-
- * Removed deprecated functions
- * opj_stream_create_default_file_stream(FILE*,...)
- * opj_stream_create_file_stream(FILE*,...)
- * opj_stream_set_user_data (opj_stream_t* p_stream, void * p_data)
- * Added
- * opj_stream_create_default_file_stream(char*,...)
- * opj_stream_create_file_stream(char*,...)
- * opj_stream_destroy(opj_stream_t*)
- * opj_stream_set_user_data (opj_stream_t* p_stream, void * p_data,
- ... opj_stream_free_user_data_fn p_function)
- * JPEG 2000 profiles and Part-2 extensions defined through '#define'
- * Changed
- * 'alpha' field added to 'opj_image_comp' structure
- * 'OPJ_CLRSPC_EYCC' added to enum COLOR_SPACE
- * 'OPJ_CLRSPC_CMYK' added to enum COLOR_SPACE
- * 'OPJ_CODEC_JPP' and 'OPJ_CODEC_JPX' added to CODEC_FORMAT
- (not yet used in use)
- * 'max_cs_size' and 'rsiz' fields added to opj_cparameters_t
-
-### Misc
-
- * OpenJPEG is now officially conformant with JPEG 2000 Part-1
- and will soon become official reference software at the
- JPEG committee.
- * Huge amount of bug fixes. See CHANGES for details.
-
-
-## OpenJPEG 2.0.0
-
-### New Features
-
- * streaming capabilities
- * merge JP3D
-
-### API modifications
-(see [here](http://www.openjpeg.org/abi-check/timeline/openjpeg/) for details)
-
- * Use a 64bits capable API
-
-### Misc
-
- * removed autotools build system
- * folders hierarchies reorganisation
- * Huge amount of bug fixes. See CHANGES for details.
diff --git a/contrib/libs/openjpeg/README.md b/contrib/libs/openjpeg/README.md
deleted file mode 100644
index 75ba171048..0000000000
--- a/contrib/libs/openjpeg/README.md
+++ /dev/null
@@ -1,83 +0,0 @@
-
-# OPENJPEG Library and Applications
-
-## What is OpenJPEG ?
-
-OpenJPEG is an open-source JPEG 2000 codec written in C language. It has been developed in order to promote the use of [JPEG 2000](http://www.jpeg.org/jpeg2000), a still-image compression standard from the Joint Photographic Experts Group ([JPEG](http://www.jpeg.org)). Since April 2015, it is officially recognized by ISO/IEC and ITU-T as a [JPEG 2000 Reference Software](http://www.itu.int/rec/T-REC-T.804-201504-I!Amd2).
-
-## Who can use the code ?
-[![badge-license]][link-license]
-
-Anyone. As the OpenJPEG code is released under the [BSD 2-clause "Simplified" License][link-license], anyone can use or modify the code, even for commercial applications. The only restriction is to retain the copyright in the sources or in the binaries documentation. Of course, if you modified the code in a way that might be of interest for other users, you are encouraged to share it (through a [github pull request](https://github.com/uclouvain/openjpeg/pulls) or by filling an [issue](https://github.com/uclouvain/openjpeg/issues)) but this is not a requirement.
-
-## How to install and use OpenJPEG ?
-API Documentation needs a major refactoring. Meanwhile, you can check [installation](https://github.com/uclouvain/openjpeg/wiki/Installation) instructions and [codec documentation](https://github.com/uclouvain/openjpeg/wiki/DocJ2KCodec).
-
-## Current Status
-[![badge-build]][link-build]
-
-[![badge-msvc-build]][link-msvc-build]
-
-[![badge-coverity]][link-coverity]
-
-## Who are the developers ?
-
-The library is developed and maintained by the Image and Signal Processing Group ([ISPGroup](http://sites.uclouvain.be/ispgroup/)), in the Université catholique de Louvain ([UCL](http://www.uclouvain.be/en-index.html), with the support of the [CNES](https://cnes.fr/), the [CS](http://www.c-s.fr/) company and the [intoPIX](http://www.intopix.com) company. The JPWL module has been developed by the Digital Signal Processing Lab ([DSPLab](http://dsplab.diei.unipg.it/)) of the University of Perugia, Italy ([UNIPG](http://www.unipg.it/)).
-
-## Details on folders hierarchy
-
-* src
- * lib
- * openjp2: contains the sources of the openjp2 library (Part 1 & 2)
- * openjpip: complete client-server architecture for remote browsing of jpeg 2000 images.
- * bin: contains all applications that use the openjpeg library
- * common: common files to all applications
- * jp2: a basic codec
- * jpip: OpenJPIP applications (server and dec server)
- * java: a Java client viewer for JPIP
- * wx
- * OPJViewer: gui for displaying j2k files (based on wxWidget)
-* wrapping
- * java: java jni to use openjpeg in a java program
-* thirdparty: thirdparty libraries used by some applications. These libraries will be built only if there are not found on the system. Note that libopenjpeg itself does not have any dependency.
-* doc: doxygen documentation setup file and man pages
-* tests: configuration files and utilities for the openjpeg test suite. All test images are located in [openjpeg-data](https://github.com/uclouvain/openjpeg-data) repository.
-* cmake: cmake related files
-* scripts: scripts for developers
-
-See [LICENSE][link-license] for license and copyright information.
-
-See [INSTALL](https://github.com/uclouvain/openjpeg/blob/master/INSTALL.md) for installation procedures.
-
-See [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) for user visible changes in successive releases.
-
-## Deprecated components
-
-The openjpwl, openjp3d and openmj2 components have been removed after the
-2.4.0 release. Their building and working state is unknown. People interested
-in them should start from the 2.4.0 tag.
-
-## API/ABI
-
-An API/ABI timeline is automatically updated [here][link-api-timeline].
-
-OpenJPEG strives to provide a stable API/ABI for your applications. As such it
-only exposes a limited subset of its functions. It uses a mechanism of
-exporting/hiding functions. If you are unsure which functions you can use in
-your applications, you should compile OpenJPEG using something similar to gcc:
-`-fvisibility=hidden` compilation flag.
-See also: http://gcc.gnu.org/wiki/Visibility
-
-On windows, MSVC directly supports export/hiding function and as such the only
-API available is the one supported by OpenJPEG.
-
-[comment-license]: https://img.shields.io/github/license/uclouvain/openjpeg.svg "https://img.shields.io/badge/license-BSD--2--Clause-blue.svg"
-[badge-license]: https://img.shields.io/badge/license-BSD--2--Clause-blue.svg "BSD 2-clause \"Simplified\" License"
-[link-license]: https://github.com/uclouvain/openjpeg/blob/master/LICENSE "BSD 2-clause \"Simplified\" License"
-[badge-build]: https://github.com/uclouvain/openjpeg/actions/workflows/build.yml/badge.svg "Build Status"
-[link-build]: https://github.com/uclouvain/openjpeg/actions/workflows/build.yml "Build Status"
-[badge-msvc-build]: https://ci.appveyor.com/api/projects/status/github/uclouvain/openjpeg?branch=master&svg=true "Windows Build Status"
-[link-msvc-build]: https://ci.appveyor.com/project/detonin/openjpeg/branch/master "Windows Build Status"
-[badge-coverity]: https://scan.coverity.com/projects/6383/badge.svg "Coverity Scan Build Status"
-[link-coverity]: https://scan.coverity.com/projects/uclouvain-openjpeg "Coverity Scan Build Status"
-[link-api-timeline]: http://www.openjpeg.org/abi-check/timeline/openjpeg "OpenJPEG API/ABI timeline"
diff --git a/contrib/libs/openjpeg/THANKS.md b/contrib/libs/openjpeg/THANKS.md
deleted file mode 100644
index 460eab10ae..0000000000
--- a/contrib/libs/openjpeg/THANKS.md
+++ /dev/null
@@ -1,39 +0,0 @@
-# OpenJPEG THANKS file
-
-Many people have contributed to OpenJPEG by reporting problems, suggesting various improvements,
-or submitting actual code. Here is a list of these people. Help me keep
-it complete and exempt of errors.
-
-* Giuseppe Baruffa
-* Ben Boeckel
-* Aaron Boxer
-* David Burken
-* Matthieu Darbois
-* Rex Dieter
-* Herve Drolon
-* Antonin Descampe
-* Francois-Olivier Devaux
-* Parvatha Elangovan
-* Jerôme Fimes
-* Bob Friesenhahn
-* Kaori Hagihara
-* Luc Hermitte
-* Luis Ibanez
-* David Janssens
-* Hans Johnson
-* Callum Lerwick
-* Ke Liu (Tencent's Xuanwu LAB)
-* Sebastien Lugan
-* Benoit Macq
-* Mathieu Malaterre
-* Julien Malik
-* Arnaud Maye
-* Vincent Nicolas
-* Aleksander Nikolic (Cisco Talos)
-* Glenn Pearson
-* Even Rouault
-* Dzonatas Sol
-* Winfried Szukalski
-* Vincent Torri
-* Yannick Verschueren
-* Peter Wimmer
diff --git a/contrib/libs/openjpeg/bio.c b/contrib/libs/openjpeg/bio.c
deleted file mode 100644
index 8106df754e..0000000000
--- a/contrib/libs/openjpeg/bio.c
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2014, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux
- * Copyright (c) 2003-2014, Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "opj_includes.h"
-
-/** @defgroup BIO BIO - Individual bit input-output stream */
-/*@{*/
-
-/** @name Local static functions */
-/*@{*/
-
-/**
-Read a bit
-@param bio BIO handle
-@return Returns the read bit
-*/
-static OPJ_UINT32 opj_bio_getbit(opj_bio_t *bio);
-/**
-Write a byte
-@param bio BIO handle
-@return Returns OPJ_TRUE if successful, returns OPJ_FALSE otherwise
-*/
-static OPJ_BOOL opj_bio_byteout(opj_bio_t *bio);
-/**
-Read a byte
-@param bio BIO handle
-@return Returns OPJ_TRUE if successful, returns OPJ_FALSE otherwise
-*/
-static OPJ_BOOL opj_bio_bytein(opj_bio_t *bio);
-
-/*@}*/
-
-/*@}*/
-
-/*
-==========================================================
- local functions
-==========================================================
-*/
-
-static OPJ_BOOL opj_bio_byteout(opj_bio_t *bio)
-{
- bio->buf = (bio->buf << 8) & 0xffff;
- bio->ct = bio->buf == 0xff00 ? 7 : 8;
- if ((OPJ_SIZE_T)bio->bp >= (OPJ_SIZE_T)bio->end) {
- return OPJ_FALSE;
- }
- *bio->bp++ = (OPJ_BYTE)(bio->buf >> 8);
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_bio_bytein(opj_bio_t *bio)
-{
- bio->buf = (bio->buf << 8) & 0xffff;
- bio->ct = bio->buf == 0xff00 ? 7 : 8;
- if ((OPJ_SIZE_T)bio->bp >= (OPJ_SIZE_T)bio->end) {
- return OPJ_FALSE;
- }
- bio->buf |= *bio->bp++;
- return OPJ_TRUE;
-}
-
-static OPJ_UINT32 opj_bio_getbit(opj_bio_t *bio)
-{
- if (bio->ct == 0) {
- opj_bio_bytein(
- bio); /* MSD: why not check the return value of this function ? */
- }
- bio->ct--;
- return (bio->buf >> bio->ct) & 1;
-}
-
-/*
-==========================================================
- Bit Input/Output interface
-==========================================================
-*/
-
-opj_bio_t* opj_bio_create(void)
-{
- opj_bio_t *bio = (opj_bio_t*)opj_malloc(sizeof(opj_bio_t));
- return bio;
-}
-
-void opj_bio_destroy(opj_bio_t *bio)
-{
- if (bio) {
- opj_free(bio);
- }
-}
-
-ptrdiff_t opj_bio_numbytes(opj_bio_t *bio)
-{
- return (bio->bp - bio->start);
-}
-
-void opj_bio_init_enc(opj_bio_t *bio, OPJ_BYTE *bp, OPJ_UINT32 len)
-{
- bio->start = bp;
- bio->end = bp + len;
- bio->bp = bp;
- bio->buf = 0;
- bio->ct = 8;
-}
-
-void opj_bio_init_dec(opj_bio_t *bio, OPJ_BYTE *bp, OPJ_UINT32 len)
-{
- bio->start = bp;
- bio->end = bp + len;
- bio->bp = bp;
- bio->buf = 0;
- bio->ct = 0;
-}
-
-void opj_bio_putbit(opj_bio_t *bio, OPJ_UINT32 b)
-{
- if (bio->ct == 0) {
- opj_bio_byteout(
- bio); /* MSD: why not check the return value of this function ? */
- }
- bio->ct--;
- bio->buf |= b << bio->ct;
-}
-
-void opj_bio_write(opj_bio_t *bio, OPJ_UINT32 v, OPJ_UINT32 n)
-{
- OPJ_INT32 i;
-
- assert((n > 0U) && (n <= 32U));
- for (i = (OPJ_INT32)n - 1; i >= 0; i--) {
- opj_bio_putbit(bio, (v >> i) & 1);
- }
-}
-
-OPJ_UINT32 opj_bio_read(opj_bio_t *bio, OPJ_UINT32 n)
-{
- OPJ_INT32 i;
- OPJ_UINT32 v;
-
- assert((n > 0U) /* && (n <= 32U)*/);
-#ifdef OPJ_UBSAN_BUILD
- /* This assert fails for some corrupted images which are gracefully rejected */
- /* Add this assert only for ubsan build. */
- /* This is the condition for overflow not to occur below which is needed because of OPJ_NOSANITIZE */
- assert(n <= 32U);
-#endif
- v = 0U;
- for (i = (OPJ_INT32)n - 1; i >= 0; i--) {
- v |= opj_bio_getbit(bio) <<
- i; /* can't overflow, opj_bio_getbit returns 0 or 1 */
- }
- return v;
-}
-
-OPJ_BOOL opj_bio_flush(opj_bio_t *bio)
-{
- if (! opj_bio_byteout(bio)) {
- return OPJ_FALSE;
- }
- if (bio->ct == 7) {
- if (! opj_bio_byteout(bio)) {
- return OPJ_FALSE;
- }
- }
- return OPJ_TRUE;
-}
-
-OPJ_BOOL opj_bio_inalign(opj_bio_t *bio)
-{
- if ((bio->buf & 0xff) == 0xff) {
- if (! opj_bio_bytein(bio)) {
- return OPJ_FALSE;
- }
- }
- bio->ct = 0;
- return OPJ_TRUE;
-}
diff --git a/contrib/libs/openjpeg/bio.h b/contrib/libs/openjpeg/bio.h
deleted file mode 100644
index d482f9ead5..0000000000
--- a/contrib/libs/openjpeg/bio.h
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2014, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux
- * Copyright (c) 2003-2014, Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef OPJ_BIO_H
-#define OPJ_BIO_H
-
-#include <stddef.h> /* ptrdiff_t */
-
-/**
-@file bio.h
-@brief Implementation of an individual bit input-output (BIO)
-
-The functions in BIO.C have for goal to realize an individual bit input - output.
-*/
-
-/** @defgroup BIO BIO - Individual bit input-output stream */
-/*@{*/
-
-/**
-Individual bit input-output stream (BIO)
-*/
-typedef struct opj_bio {
- /** pointer to the start of the buffer */
- OPJ_BYTE *start;
- /** pointer to the end of the buffer */
- OPJ_BYTE *end;
- /** pointer to the present position in the buffer */
- OPJ_BYTE *bp;
- /** temporary place where each byte is read or written */
- OPJ_UINT32 buf;
- /** coder : number of bits free to write. decoder : number of bits read */
- OPJ_UINT32 ct;
-} opj_bio_t;
-
-/** @name Exported functions */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-/**
-Create a new BIO handle
-@return Returns a new BIO handle if successful, returns NULL otherwise
-*/
-opj_bio_t* opj_bio_create(void);
-/**
-Destroy a previously created BIO handle
-@param bio BIO handle to destroy
-*/
-void opj_bio_destroy(opj_bio_t *bio);
-/**
-Number of bytes written.
-@param bio BIO handle
-@return Returns the number of bytes written
-*/
-ptrdiff_t opj_bio_numbytes(opj_bio_t *bio);
-/**
-Init encoder
-@param bio BIO handle
-@param bp Output buffer
-@param len Output buffer length
-*/
-void opj_bio_init_enc(opj_bio_t *bio, OPJ_BYTE *bp, OPJ_UINT32 len);
-/**
-Init decoder
-@param bio BIO handle
-@param bp Input buffer
-@param len Input buffer length
-*/
-void opj_bio_init_dec(opj_bio_t *bio, OPJ_BYTE *bp, OPJ_UINT32 len);
-/**
-Write bits
-@param bio BIO handle
-@param v Value of bits
-@param n Number of bits to write
-*/
-void opj_bio_write(opj_bio_t *bio, OPJ_UINT32 v, OPJ_UINT32 n);
-
-/**
-Write a bit
-@param bio BIO handle
-@param b Bit to write (0 or 1)
-*/
-void opj_bio_putbit(opj_bio_t *bio, OPJ_UINT32 b);
-
-/**
-Read bits
-@param bio BIO handle
-@param n Number of bits to read
-@return Returns the corresponding read number
-*/
-OPJ_UINT32 opj_bio_read(opj_bio_t *bio, OPJ_UINT32 n);
-/**
-Flush bits
-@param bio BIO handle
-@return Returns OPJ_TRUE if successful, returns OPJ_FALSE otherwise
-*/
-OPJ_BOOL opj_bio_flush(opj_bio_t *bio);
-/**
-Passes the ending bits (coming from flushing)
-@param bio BIO handle
-@return Returns OPJ_TRUE if successful, returns OPJ_FALSE otherwise
-*/
-OPJ_BOOL opj_bio_inalign(opj_bio_t *bio);
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* OPJ_BIO_H */
-
diff --git a/contrib/libs/openjpeg/cio.c b/contrib/libs/openjpeg/cio.c
deleted file mode 100644
index 4fde9fe239..0000000000
--- a/contrib/libs/openjpeg/cio.c
+++ /dev/null
@@ -1,683 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2014, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux
- * Copyright (c) 2003-2014, Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR
- * Copyright (c) 2012, CS Systemes d'Information, France
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "opj_includes.h"
-
-/* ----------------------------------------------------------------------- */
-
-
-/* ----------------------------------------------------------------------- */
-
-void opj_write_bytes_BE(OPJ_BYTE * p_buffer, OPJ_UINT32 p_value,
- OPJ_UINT32 p_nb_bytes)
-{
- const OPJ_BYTE * l_data_ptr = ((const OPJ_BYTE *) &p_value) + sizeof(
- OPJ_UINT32) - p_nb_bytes;
-
- assert(p_nb_bytes > 0 && p_nb_bytes <= sizeof(OPJ_UINT32));
-
- memcpy(p_buffer, l_data_ptr, p_nb_bytes);
-}
-
-void opj_write_bytes_LE(OPJ_BYTE * p_buffer, OPJ_UINT32 p_value,
- OPJ_UINT32 p_nb_bytes)
-{
- const OPJ_BYTE * l_data_ptr = ((const OPJ_BYTE *) &p_value) + p_nb_bytes - 1;
- OPJ_UINT32 i;
-
- assert(p_nb_bytes > 0 && p_nb_bytes <= sizeof(OPJ_UINT32));
-
- for (i = 0; i < p_nb_bytes; ++i) {
- *(p_buffer++) = *(l_data_ptr--);
- }
-}
-
-void opj_read_bytes_BE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value,
- OPJ_UINT32 p_nb_bytes)
-{
- OPJ_BYTE * l_data_ptr = ((OPJ_BYTE *) p_value);
-
- assert(p_nb_bytes > 0 && p_nb_bytes <= sizeof(OPJ_UINT32));
-
- *p_value = 0;
- memcpy(l_data_ptr + sizeof(OPJ_UINT32) - p_nb_bytes, p_buffer, p_nb_bytes);
-}
-
-void opj_read_bytes_LE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value,
- OPJ_UINT32 p_nb_bytes)
-{
- OPJ_BYTE * l_data_ptr = ((OPJ_BYTE *) p_value) + p_nb_bytes - 1;
- OPJ_UINT32 i;
-
- assert(p_nb_bytes > 0 && p_nb_bytes <= sizeof(OPJ_UINT32));
-
- *p_value = 0;
- for (i = 0; i < p_nb_bytes; ++i) {
- *(l_data_ptr--) = *(p_buffer++);
- }
-}
-
-void opj_write_double_BE(OPJ_BYTE * p_buffer, OPJ_FLOAT64 p_value)
-{
- const OPJ_BYTE * l_data_ptr = ((const OPJ_BYTE *) &p_value);
- memcpy(p_buffer, l_data_ptr, sizeof(OPJ_FLOAT64));
-}
-
-void opj_write_double_LE(OPJ_BYTE * p_buffer, OPJ_FLOAT64 p_value)
-{
- const OPJ_BYTE * l_data_ptr = ((const OPJ_BYTE *) &p_value) + sizeof(
- OPJ_FLOAT64) - 1;
- OPJ_UINT32 i;
- for (i = 0; i < sizeof(OPJ_FLOAT64); ++i) {
- *(p_buffer++) = *(l_data_ptr--);
- }
-}
-
-void opj_read_double_BE(const OPJ_BYTE * p_buffer, OPJ_FLOAT64 * p_value)
-{
- OPJ_BYTE * l_data_ptr = ((OPJ_BYTE *) p_value);
- memcpy(l_data_ptr, p_buffer, sizeof(OPJ_FLOAT64));
-}
-
-void opj_read_double_LE(const OPJ_BYTE * p_buffer, OPJ_FLOAT64 * p_value)
-{
- OPJ_BYTE * l_data_ptr = ((OPJ_BYTE *) p_value) + sizeof(OPJ_FLOAT64) - 1;
- OPJ_UINT32 i;
- for (i = 0; i < sizeof(OPJ_FLOAT64); ++i) {
- *(l_data_ptr--) = *(p_buffer++);
- }
-}
-
-void opj_write_float_BE(OPJ_BYTE * p_buffer, OPJ_FLOAT32 p_value)
-{
- const OPJ_BYTE * l_data_ptr = ((const OPJ_BYTE *) &p_value);
- memcpy(p_buffer, l_data_ptr, sizeof(OPJ_FLOAT32));
-}
-
-void opj_write_float_LE(OPJ_BYTE * p_buffer, OPJ_FLOAT32 p_value)
-{
- const OPJ_BYTE * l_data_ptr = ((const OPJ_BYTE *) &p_value) + sizeof(
- OPJ_FLOAT32) - 1;
- OPJ_UINT32 i;
- for (i = 0; i < sizeof(OPJ_FLOAT32); ++i) {
- *(p_buffer++) = *(l_data_ptr--);
- }
-}
-
-void opj_read_float_BE(const OPJ_BYTE * p_buffer, OPJ_FLOAT32 * p_value)
-{
- OPJ_BYTE * l_data_ptr = ((OPJ_BYTE *) p_value);
- memcpy(l_data_ptr, p_buffer, sizeof(OPJ_FLOAT32));
-}
-
-void opj_read_float_LE(const OPJ_BYTE * p_buffer, OPJ_FLOAT32 * p_value)
-{
- OPJ_BYTE * l_data_ptr = ((OPJ_BYTE *) p_value) + sizeof(OPJ_FLOAT32) - 1;
- OPJ_UINT32 i;
- for (i = 0; i < sizeof(OPJ_FLOAT32); ++i) {
- *(l_data_ptr--) = *(p_buffer++);
- }
-}
-
-opj_stream_t* OPJ_CALLCONV opj_stream_create(OPJ_SIZE_T p_buffer_size,
- OPJ_BOOL l_is_input)
-{
- opj_stream_private_t * l_stream = 00;
- l_stream = (opj_stream_private_t*) opj_calloc(1, sizeof(opj_stream_private_t));
- if (! l_stream) {
- return 00;
- }
-
- l_stream->m_buffer_size = p_buffer_size;
- l_stream->m_stored_data = (OPJ_BYTE *) opj_malloc(p_buffer_size);
- if (! l_stream->m_stored_data) {
- opj_free(l_stream);
- return 00;
- }
-
- l_stream->m_current_data = l_stream->m_stored_data;
-
- if (l_is_input) {
- l_stream->m_status |= OPJ_STREAM_STATUS_INPUT;
- l_stream->m_opj_skip = opj_stream_read_skip;
- l_stream->m_opj_seek = opj_stream_read_seek;
- } else {
- l_stream->m_status |= OPJ_STREAM_STATUS_OUTPUT;
- l_stream->m_opj_skip = opj_stream_write_skip;
- l_stream->m_opj_seek = opj_stream_write_seek;
- }
-
- l_stream->m_read_fn = opj_stream_default_read;
- l_stream->m_write_fn = opj_stream_default_write;
- l_stream->m_skip_fn = opj_stream_default_skip;
- l_stream->m_seek_fn = opj_stream_default_seek;
-
- return (opj_stream_t *) l_stream;
-}
-
-opj_stream_t* OPJ_CALLCONV opj_stream_default_create(OPJ_BOOL l_is_input)
-{
- return opj_stream_create(OPJ_J2K_STREAM_CHUNK_SIZE, l_is_input);
-}
-
-void OPJ_CALLCONV opj_stream_destroy(opj_stream_t* p_stream)
-{
- opj_stream_private_t* l_stream = (opj_stream_private_t*) p_stream;
-
- if (l_stream) {
- if (l_stream->m_free_user_data_fn) {
- l_stream->m_free_user_data_fn(l_stream->m_user_data);
- }
- opj_free(l_stream->m_stored_data);
- l_stream->m_stored_data = 00;
- opj_free(l_stream);
- }
-}
-
-void OPJ_CALLCONV opj_stream_set_read_function(opj_stream_t* p_stream,
- opj_stream_read_fn p_function)
-{
- opj_stream_private_t* l_stream = (opj_stream_private_t*) p_stream;
-
- if ((!l_stream) || (!(l_stream->m_status & OPJ_STREAM_STATUS_INPUT))) {
- return;
- }
-
- l_stream->m_read_fn = p_function;
-}
-
-void OPJ_CALLCONV opj_stream_set_seek_function(opj_stream_t* p_stream,
- opj_stream_seek_fn p_function)
-{
- opj_stream_private_t* l_stream = (opj_stream_private_t*) p_stream;
-
- if (!l_stream) {
- return;
- }
- l_stream->m_seek_fn = p_function;
-}
-
-void OPJ_CALLCONV opj_stream_set_write_function(opj_stream_t* p_stream,
- opj_stream_write_fn p_function)
-{
- opj_stream_private_t* l_stream = (opj_stream_private_t*) p_stream;
-
- if ((!l_stream) || (!(l_stream->m_status & OPJ_STREAM_STATUS_OUTPUT))) {
- return;
- }
-
- l_stream->m_write_fn = p_function;
-}
-
-void OPJ_CALLCONV opj_stream_set_skip_function(opj_stream_t* p_stream,
- opj_stream_skip_fn p_function)
-{
- opj_stream_private_t* l_stream = (opj_stream_private_t*) p_stream;
-
- if (! l_stream) {
- return;
- }
-
- l_stream->m_skip_fn = p_function;
-}
-
-void OPJ_CALLCONV opj_stream_set_user_data(opj_stream_t* p_stream,
- void * p_data, opj_stream_free_user_data_fn p_function)
-{
- opj_stream_private_t* l_stream = (opj_stream_private_t*) p_stream;
- if (!l_stream) {
- return;
- }
- l_stream->m_user_data = p_data;
- l_stream->m_free_user_data_fn = p_function;
-}
-
-void OPJ_CALLCONV opj_stream_set_user_data_length(opj_stream_t* p_stream,
- OPJ_UINT64 data_length)
-{
- opj_stream_private_t* l_stream = (opj_stream_private_t*) p_stream;
- if (!l_stream) {
- return;
- }
- l_stream->m_user_data_length = data_length;
-}
-
-OPJ_SIZE_T opj_stream_read_data(opj_stream_private_t * p_stream,
- OPJ_BYTE * p_buffer, OPJ_SIZE_T p_size, opj_event_mgr_t * p_event_mgr)
-{
- OPJ_SIZE_T l_read_nb_bytes = 0;
- if (p_stream->m_bytes_in_buffer >= p_size) {
- memcpy(p_buffer, p_stream->m_current_data, p_size);
- p_stream->m_current_data += p_size;
- p_stream->m_bytes_in_buffer -= p_size;
- l_read_nb_bytes += p_size;
- p_stream->m_byte_offset += (OPJ_OFF_T)p_size;
- return l_read_nb_bytes;
- }
-
- /* we are now in the case when the remaining data if not sufficient */
- if (p_stream->m_status & OPJ_STREAM_STATUS_END) {
- l_read_nb_bytes += p_stream->m_bytes_in_buffer;
- memcpy(p_buffer, p_stream->m_current_data, p_stream->m_bytes_in_buffer);
- p_stream->m_current_data += p_stream->m_bytes_in_buffer;
- p_stream->m_byte_offset += (OPJ_OFF_T)p_stream->m_bytes_in_buffer;
- p_stream->m_bytes_in_buffer = 0;
- return l_read_nb_bytes ? l_read_nb_bytes : (OPJ_SIZE_T) - 1;
- }
-
- /* the flag is not set, we copy data and then do an actual read on the stream */
- if (p_stream->m_bytes_in_buffer) {
- l_read_nb_bytes += p_stream->m_bytes_in_buffer;
- memcpy(p_buffer, p_stream->m_current_data, p_stream->m_bytes_in_buffer);
- p_stream->m_current_data = p_stream->m_stored_data;
- p_buffer += p_stream->m_bytes_in_buffer;
- p_size -= p_stream->m_bytes_in_buffer;
- p_stream->m_byte_offset += (OPJ_OFF_T)p_stream->m_bytes_in_buffer;
- p_stream->m_bytes_in_buffer = 0;
- } else {
- /* case where we are already at the end of the buffer
- so reset the m_current_data to point to the start of the
- stored buffer to get ready to read from disk*/
- p_stream->m_current_data = p_stream->m_stored_data;
- }
-
- for (;;) {
- /* we should read less than a chunk -> read a chunk */
- if (p_size < p_stream->m_buffer_size) {
- /* we should do an actual read on the media */
- p_stream->m_bytes_in_buffer = p_stream->m_read_fn(p_stream->m_stored_data,
- p_stream->m_buffer_size, p_stream->m_user_data);
-
- if (p_stream->m_bytes_in_buffer == (OPJ_SIZE_T) - 1) {
- /* end of stream */
- opj_event_msg(p_event_mgr, EVT_INFO, "Stream reached its end !\n");
-
- p_stream->m_bytes_in_buffer = 0;
- p_stream->m_status |= OPJ_STREAM_STATUS_END;
- /* end of stream */
- return l_read_nb_bytes ? l_read_nb_bytes : (OPJ_SIZE_T) - 1;
- } else if (p_stream->m_bytes_in_buffer < p_size) {
- /* not enough data */
- l_read_nb_bytes += p_stream->m_bytes_in_buffer;
- memcpy(p_buffer, p_stream->m_current_data, p_stream->m_bytes_in_buffer);
- p_stream->m_current_data = p_stream->m_stored_data;
- p_buffer += p_stream->m_bytes_in_buffer;
- p_size -= p_stream->m_bytes_in_buffer;
- p_stream->m_byte_offset += (OPJ_OFF_T)p_stream->m_bytes_in_buffer;
- p_stream->m_bytes_in_buffer = 0;
- } else {
- l_read_nb_bytes += p_size;
- memcpy(p_buffer, p_stream->m_current_data, p_size);
- p_stream->m_current_data += p_size;
- p_stream->m_bytes_in_buffer -= p_size;
- p_stream->m_byte_offset += (OPJ_OFF_T)p_size;
- return l_read_nb_bytes;
- }
- } else {
- /* direct read on the dest buffer */
- p_stream->m_bytes_in_buffer = p_stream->m_read_fn(p_buffer, p_size,
- p_stream->m_user_data);
-
- if (p_stream->m_bytes_in_buffer == (OPJ_SIZE_T) - 1) {
- /* end of stream */
- opj_event_msg(p_event_mgr, EVT_INFO, "Stream reached its end !\n");
-
- p_stream->m_bytes_in_buffer = 0;
- p_stream->m_status |= OPJ_STREAM_STATUS_END;
- /* end of stream */
- return l_read_nb_bytes ? l_read_nb_bytes : (OPJ_SIZE_T) - 1;
- } else if (p_stream->m_bytes_in_buffer < p_size) {
- /* not enough data */
- l_read_nb_bytes += p_stream->m_bytes_in_buffer;
- p_stream->m_current_data = p_stream->m_stored_data;
- p_buffer += p_stream->m_bytes_in_buffer;
- p_size -= p_stream->m_bytes_in_buffer;
- p_stream->m_byte_offset += (OPJ_OFF_T)p_stream->m_bytes_in_buffer;
- p_stream->m_bytes_in_buffer = 0;
- } else {
- /* we have read the exact size */
- l_read_nb_bytes += p_stream->m_bytes_in_buffer;
- p_stream->m_byte_offset += (OPJ_OFF_T)p_stream->m_bytes_in_buffer;
- p_stream->m_current_data = p_stream->m_stored_data;
- p_stream->m_bytes_in_buffer = 0;
- return l_read_nb_bytes;
- }
- }
- }
-}
-
-OPJ_SIZE_T opj_stream_write_data(opj_stream_private_t * p_stream,
- const OPJ_BYTE * p_buffer,
- OPJ_SIZE_T p_size,
- opj_event_mgr_t * p_event_mgr)
-{
- OPJ_SIZE_T l_remaining_bytes = 0;
- OPJ_SIZE_T l_write_nb_bytes = 0;
-
- if (p_stream->m_status & OPJ_STREAM_STATUS_ERROR) {
- return (OPJ_SIZE_T) - 1;
- }
-
- for (;;) {
- l_remaining_bytes = p_stream->m_buffer_size - p_stream->m_bytes_in_buffer;
-
- /* we have more memory than required */
- if (l_remaining_bytes >= p_size) {
- memcpy(p_stream->m_current_data, p_buffer, p_size);
-
- p_stream->m_current_data += p_size;
- p_stream->m_bytes_in_buffer += p_size;
- l_write_nb_bytes += p_size;
- p_stream->m_byte_offset += (OPJ_OFF_T)p_size;
-
- return l_write_nb_bytes;
- }
-
- /* we copy data and then do an actual read on the stream */
- if (l_remaining_bytes) {
- l_write_nb_bytes += l_remaining_bytes;
-
- memcpy(p_stream->m_current_data, p_buffer, l_remaining_bytes);
-
- p_stream->m_current_data = p_stream->m_stored_data;
-
- p_buffer += l_remaining_bytes;
- p_size -= l_remaining_bytes;
- p_stream->m_bytes_in_buffer += l_remaining_bytes;
- p_stream->m_byte_offset += (OPJ_OFF_T)l_remaining_bytes;
- }
-
- if (! opj_stream_flush(p_stream, p_event_mgr)) {
- return (OPJ_SIZE_T) - 1;
- }
- }
-
-}
-
-OPJ_BOOL opj_stream_flush(opj_stream_private_t * p_stream,
- opj_event_mgr_t * p_event_mgr)
-{
- /* the number of bytes written on the media. */
- OPJ_SIZE_T l_current_write_nb_bytes = 0;
-
- p_stream->m_current_data = p_stream->m_stored_data;
-
- while (p_stream->m_bytes_in_buffer) {
- /* we should do an actual write on the media */
- l_current_write_nb_bytes = p_stream->m_write_fn(p_stream->m_current_data,
- p_stream->m_bytes_in_buffer,
- p_stream->m_user_data);
-
- if (l_current_write_nb_bytes == (OPJ_SIZE_T) - 1) {
- p_stream->m_status |= OPJ_STREAM_STATUS_ERROR;
- opj_event_msg(p_event_mgr, EVT_INFO, "Error on writing stream!\n");
-
- return OPJ_FALSE;
- }
-
- p_stream->m_current_data += l_current_write_nb_bytes;
- p_stream->m_bytes_in_buffer -= l_current_write_nb_bytes;
- }
-
- p_stream->m_current_data = p_stream->m_stored_data;
-
- return OPJ_TRUE;
-}
-
-OPJ_OFF_T opj_stream_read_skip(opj_stream_private_t * p_stream,
- OPJ_OFF_T p_size, opj_event_mgr_t * p_event_mgr)
-{
- OPJ_OFF_T l_skip_nb_bytes = 0;
- OPJ_OFF_T l_current_skip_nb_bytes = 0;
-
- assert(p_size >= 0);
-
- if (p_stream->m_bytes_in_buffer >= (OPJ_SIZE_T)p_size) {
- p_stream->m_current_data += p_size;
- /* it is safe to cast p_size to OPJ_SIZE_T since it is <= m_bytes_in_buffer
- which is of type OPJ_SIZE_T */
- p_stream->m_bytes_in_buffer -= (OPJ_SIZE_T)p_size;
- l_skip_nb_bytes += p_size;
- p_stream->m_byte_offset += l_skip_nb_bytes;
- return l_skip_nb_bytes;
- }
-
- /* we are now in the case when the remaining data if not sufficient */
- if (p_stream->m_status & OPJ_STREAM_STATUS_END) {
- l_skip_nb_bytes += (OPJ_OFF_T)p_stream->m_bytes_in_buffer;
- p_stream->m_current_data += p_stream->m_bytes_in_buffer;
- p_stream->m_bytes_in_buffer = 0;
- p_stream->m_byte_offset += l_skip_nb_bytes;
- return l_skip_nb_bytes ? l_skip_nb_bytes : (OPJ_OFF_T) - 1;
- }
-
- /* the flag is not set, we copy data and then do an actual skip on the stream */
- if (p_stream->m_bytes_in_buffer) {
- l_skip_nb_bytes += (OPJ_OFF_T)p_stream->m_bytes_in_buffer;
- p_stream->m_current_data = p_stream->m_stored_data;
- p_size -= (OPJ_OFF_T)p_stream->m_bytes_in_buffer;
- p_stream->m_bytes_in_buffer = 0;
- }
-
- while (p_size > 0) {
- /* Check if we are going beyond the end of file. Most skip_fn do not */
- /* check that, but we must be careful not to advance m_byte_offset */
- /* beyond m_user_data_length, otherwise */
- /* opj_stream_get_number_byte_left() will assert. */
- if ((OPJ_UINT64)(p_stream->m_byte_offset + l_skip_nb_bytes + p_size) >
- p_stream->m_user_data_length) {
- opj_event_msg(p_event_mgr, EVT_INFO, "Stream reached its end !\n");
-
- p_stream->m_byte_offset += l_skip_nb_bytes;
- l_skip_nb_bytes = (OPJ_OFF_T)(p_stream->m_user_data_length -
- (OPJ_UINT64)p_stream->m_byte_offset);
-
- opj_stream_read_seek(p_stream, (OPJ_OFF_T)p_stream->m_user_data_length,
- p_event_mgr);
- p_stream->m_status |= OPJ_STREAM_STATUS_END;
-
- /* end if stream */
- return l_skip_nb_bytes ? l_skip_nb_bytes : (OPJ_OFF_T) - 1;
- }
-
- /* we should do an actual skip on the media */
- l_current_skip_nb_bytes = p_stream->m_skip_fn(p_size, p_stream->m_user_data);
- if (l_current_skip_nb_bytes == (OPJ_OFF_T) - 1) {
- opj_event_msg(p_event_mgr, EVT_INFO, "Stream reached its end !\n");
-
- p_stream->m_status |= OPJ_STREAM_STATUS_END;
- p_stream->m_byte_offset += l_skip_nb_bytes;
- /* end if stream */
- return l_skip_nb_bytes ? l_skip_nb_bytes : (OPJ_OFF_T) - 1;
- }
- p_size -= l_current_skip_nb_bytes;
- l_skip_nb_bytes += l_current_skip_nb_bytes;
- }
-
- p_stream->m_byte_offset += l_skip_nb_bytes;
-
- return l_skip_nb_bytes;
-}
-
-OPJ_OFF_T opj_stream_write_skip(opj_stream_private_t * p_stream,
- OPJ_OFF_T p_size, opj_event_mgr_t * p_event_mgr)
-{
- OPJ_BOOL l_is_written = 0;
- OPJ_OFF_T l_current_skip_nb_bytes = 0;
- OPJ_OFF_T l_skip_nb_bytes = 0;
-
- if (p_stream->m_status & OPJ_STREAM_STATUS_ERROR) {
- return (OPJ_OFF_T) - 1;
- }
-
- /* we should flush data */
- l_is_written = opj_stream_flush(p_stream, p_event_mgr);
- if (! l_is_written) {
- p_stream->m_status |= OPJ_STREAM_STATUS_ERROR;
- p_stream->m_bytes_in_buffer = 0;
- return (OPJ_OFF_T) - 1;
- }
- /* then skip */
-
- while (p_size > 0) {
- /* we should do an actual skip on the media */
- l_current_skip_nb_bytes = p_stream->m_skip_fn(p_size, p_stream->m_user_data);
-
- if (l_current_skip_nb_bytes == (OPJ_OFF_T) - 1) {
- opj_event_msg(p_event_mgr, EVT_INFO, "Stream error!\n");
-
- p_stream->m_status |= OPJ_STREAM_STATUS_ERROR;
- p_stream->m_byte_offset += l_skip_nb_bytes;
- /* end if stream */
- return l_skip_nb_bytes ? l_skip_nb_bytes : (OPJ_OFF_T) - 1;
- }
- p_size -= l_current_skip_nb_bytes;
- l_skip_nb_bytes += l_current_skip_nb_bytes;
- }
-
- p_stream->m_byte_offset += l_skip_nb_bytes;
-
- return l_skip_nb_bytes;
-}
-
-OPJ_OFF_T opj_stream_tell(const opj_stream_private_t * p_stream)
-{
- return p_stream->m_byte_offset;
-}
-
-OPJ_OFF_T opj_stream_get_number_byte_left(const opj_stream_private_t * p_stream)
-{
- assert(p_stream->m_byte_offset >= 0);
- assert(p_stream->m_user_data_length >= (OPJ_UINT64)p_stream->m_byte_offset);
- return p_stream->m_user_data_length ?
- (OPJ_OFF_T)(p_stream->m_user_data_length) - p_stream->m_byte_offset :
- 0;
-}
-
-OPJ_OFF_T opj_stream_skip(opj_stream_private_t * p_stream, OPJ_OFF_T p_size,
- opj_event_mgr_t * p_event_mgr)
-{
- assert(p_size >= 0);
- return p_stream->m_opj_skip(p_stream, p_size, p_event_mgr);
-}
-
-OPJ_BOOL opj_stream_read_seek(opj_stream_private_t * p_stream, OPJ_OFF_T p_size,
- opj_event_mgr_t * p_event_mgr)
-{
- OPJ_ARG_NOT_USED(p_event_mgr);
- p_stream->m_current_data = p_stream->m_stored_data;
- p_stream->m_bytes_in_buffer = 0;
-
- if (!(p_stream->m_seek_fn(p_size, p_stream->m_user_data))) {
- p_stream->m_status |= OPJ_STREAM_STATUS_END;
- return OPJ_FALSE;
- } else {
- /* reset stream status */
- p_stream->m_status &= (~OPJ_STREAM_STATUS_END);
- p_stream->m_byte_offset = p_size;
-
- }
-
- return OPJ_TRUE;
-}
-
-OPJ_BOOL opj_stream_write_seek(opj_stream_private_t * p_stream,
- OPJ_OFF_T p_size, opj_event_mgr_t * p_event_mgr)
-{
- if (! opj_stream_flush(p_stream, p_event_mgr)) {
- p_stream->m_status |= OPJ_STREAM_STATUS_ERROR;
- return OPJ_FALSE;
- }
-
- p_stream->m_current_data = p_stream->m_stored_data;
- p_stream->m_bytes_in_buffer = 0;
-
- if (! p_stream->m_seek_fn(p_size, p_stream->m_user_data)) {
- p_stream->m_status |= OPJ_STREAM_STATUS_ERROR;
- return OPJ_FALSE;
- } else {
- p_stream->m_byte_offset = p_size;
- }
-
- return OPJ_TRUE;
-}
-
-OPJ_BOOL opj_stream_seek(opj_stream_private_t * p_stream, OPJ_OFF_T p_size,
- struct opj_event_mgr * p_event_mgr)
-{
- assert(p_size >= 0);
- return p_stream->m_opj_seek(p_stream, p_size, p_event_mgr);
-}
-
-OPJ_BOOL opj_stream_has_seek(const opj_stream_private_t * p_stream)
-{
- return p_stream->m_seek_fn != opj_stream_default_seek;
-}
-
-OPJ_SIZE_T opj_stream_default_read(void * p_buffer, OPJ_SIZE_T p_nb_bytes,
- void * p_user_data)
-{
- OPJ_ARG_NOT_USED(p_buffer);
- OPJ_ARG_NOT_USED(p_nb_bytes);
- OPJ_ARG_NOT_USED(p_user_data);
- return (OPJ_SIZE_T) - 1;
-}
-
-OPJ_SIZE_T opj_stream_default_write(void * p_buffer, OPJ_SIZE_T p_nb_bytes,
- void * p_user_data)
-{
- OPJ_ARG_NOT_USED(p_buffer);
- OPJ_ARG_NOT_USED(p_nb_bytes);
- OPJ_ARG_NOT_USED(p_user_data);
- return (OPJ_SIZE_T) - 1;
-}
-
-OPJ_OFF_T opj_stream_default_skip(OPJ_OFF_T p_nb_bytes, void * p_user_data)
-{
- OPJ_ARG_NOT_USED(p_nb_bytes);
- OPJ_ARG_NOT_USED(p_user_data);
- return (OPJ_OFF_T) - 1;
-}
-
-OPJ_BOOL opj_stream_default_seek(OPJ_OFF_T p_nb_bytes, void * p_user_data)
-{
- OPJ_ARG_NOT_USED(p_nb_bytes);
- OPJ_ARG_NOT_USED(p_user_data);
- return OPJ_FALSE;
-}
diff --git a/contrib/libs/openjpeg/cio.h b/contrib/libs/openjpeg/cio.h
deleted file mode 100644
index 7caee30af9..0000000000
--- a/contrib/libs/openjpeg/cio.h
+++ /dev/null
@@ -1,412 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2014, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux
- * Copyright (c) 2003-2014, Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR
- * Copyright (c) 2012, CS Systemes d'Information, France
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef OPJ_CIO_H
-#define OPJ_CIO_H
-/**
-@file cio.h
-@brief Implementation of a byte input-output process (CIO)
-
-The functions in CIO.C have for goal to realize a byte input / output process.
-*/
-
-/** @defgroup CIO CIO - byte input-output stream */
-/*@{*/
-
-#include "opj_config_private.h"
-
-/* ----------------------------------------------------------------------- */
-
-#if defined(OPJ_BIG_ENDIAN)
-#define opj_write_bytes opj_write_bytes_BE
-#define opj_read_bytes opj_read_bytes_BE
-#define opj_write_double opj_write_double_BE
-#define opj_read_double opj_read_double_BE
-#define opj_write_float opj_write_float_BE
-#define opj_read_float opj_read_float_BE
-#else
-#define opj_write_bytes opj_write_bytes_LE
-#define opj_read_bytes opj_read_bytes_LE
-#define opj_write_double opj_write_double_LE
-#define opj_read_double opj_read_double_LE
-#define opj_write_float opj_write_float_LE
-#define opj_read_float opj_read_float_LE
-#endif
-
-
-#define OPJ_STREAM_STATUS_OUTPUT 0x1U
-#define OPJ_STREAM_STATUS_INPUT 0x2U
-#define OPJ_STREAM_STATUS_END 0x4U
-#define OPJ_STREAM_STATUS_ERROR 0x8U
-
-/**
-Byte input-output stream.
-*/
-typedef struct opj_stream_private {
- /**
- * User data, be it files, ... The actual data depends on the type of the stream.
- */
- void * m_user_data;
-
- /**
- * Pointer to function to free m_user_data (NULL at initialization)
- * when destroying the stream. If pointer is NULL the function is not
- * called and the m_user_data is not freed (even if non-NULL).
- */
- opj_stream_free_user_data_fn m_free_user_data_fn;
-
- /**
- * User data length
- */
- OPJ_UINT64 m_user_data_length;
-
- /**
- * Pointer to actual read function (NULL at the initialization of the cio.
- */
- opj_stream_read_fn m_read_fn;
-
- /**
- * Pointer to actual write function (NULL at the initialization of the cio.
- */
- opj_stream_write_fn m_write_fn;
-
- /**
- * Pointer to actual skip function (NULL at the initialization of the cio.
- * There is no seek function to prevent from back and forth slow procedures.
- */
- opj_stream_skip_fn m_skip_fn;
-
- /**
- * Pointer to actual seek function (if available).
- */
- opj_stream_seek_fn m_seek_fn;
-
- /**
- * Actual data stored into the stream if read from. Data is read by chunk of fixed size.
- * you should never access this data directly.
- */
- OPJ_BYTE * m_stored_data;
-
- /**
- * Pointer to the current read data.
- */
- OPJ_BYTE * m_current_data;
-
- /**
- * FIXME DOC.
- */
- OPJ_OFF_T(* m_opj_skip)(struct opj_stream_private *, OPJ_OFF_T,
- struct opj_event_mgr *);
-
- /**
- * FIXME DOC.
- */
- OPJ_BOOL(* m_opj_seek)(struct opj_stream_private *, OPJ_OFF_T,
- struct opj_event_mgr *);
-
- /**
- * number of bytes containing in the buffer.
- */
- OPJ_SIZE_T m_bytes_in_buffer;
-
- /**
- * The number of bytes read/written from the beginning of the stream
- */
- OPJ_OFF_T m_byte_offset;
-
- /**
- * The size of the buffer.
- */
- OPJ_SIZE_T m_buffer_size;
-
- /**
- * Flags to tell the status of the stream.
- * Used with OPJ_STREAM_STATUS_* defines.
- */
- OPJ_UINT32 m_status;
-
-}
-opj_stream_private_t;
-
-/** @name Exported functions (see also openjpeg.h) */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-/**
- * Write some bytes to the given data buffer, this function is used in Big Endian cpus.
- * @param p_buffer pointer the data buffer to write data to.
- * @param p_value the value to write
- * @param p_nb_bytes the number of bytes to write
-*/
-void opj_write_bytes_BE(OPJ_BYTE * p_buffer, OPJ_UINT32 p_value,
- OPJ_UINT32 p_nb_bytes);
-
-/**
- * Reads some bytes from the given data buffer, this function is used in Big Endian cpus.
- * @param p_buffer pointer the data buffer to read data from.
- * @param p_value pointer to the value that will store the data.
- * @param p_nb_bytes the nb bytes to read.
- * @return the number of bytes read or -1 if an error occurred.
- */
-void opj_read_bytes_BE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value,
- OPJ_UINT32 p_nb_bytes);
-
-/**
- * Write some bytes to the given data buffer, this function is used in Little Endian cpus.
- * @param p_buffer pointer the data buffer to write data to.
- * @param p_value the value to write
- * @param p_nb_bytes the number of bytes to write
- * @return the number of bytes written or -1 if an error occurred
-*/
-void opj_write_bytes_LE(OPJ_BYTE * p_buffer, OPJ_UINT32 p_value,
- OPJ_UINT32 p_nb_bytes);
-
-/**
- * Reads some bytes from the given data buffer, this function is used in Little Endian cpus.
- * @param p_buffer pointer the data buffer to read data from.
- * @param p_value pointer to the value that will store the data.
- * @param p_nb_bytes the nb bytes to read.
- * @return the number of bytes read or -1 if an error occurred.
- */
-void opj_read_bytes_LE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value,
- OPJ_UINT32 p_nb_bytes);
-
-
-/**
- * Write some bytes to the given data buffer, this function is used in Little Endian cpus.
- * @param p_buffer pointer the data buffer to write data to.
- * @param p_value the value to write
- */
-void opj_write_double_LE(OPJ_BYTE * p_buffer, OPJ_FLOAT64 p_value);
-
-/***
- * Write some bytes to the given data buffer, this function is used in Big Endian cpus.
- * @param p_buffer pointer the data buffer to write data to.
- * @param p_value the value to write
- */
-void opj_write_double_BE(OPJ_BYTE * p_buffer, OPJ_FLOAT64 p_value);
-
-/**
- * Reads some bytes from the given data buffer, this function is used in Little Endian cpus.
- * @param p_buffer pointer the data buffer to read data from.
- * @param p_value pointer to the value that will store the data.
- */
-void opj_read_double_LE(const OPJ_BYTE * p_buffer, OPJ_FLOAT64 * p_value);
-
-/**
- * Reads some bytes from the given data buffer, this function is used in Big Endian cpus.
- * @param p_buffer pointer the data buffer to read data from.
- * @param p_value pointer to the value that will store the data.
- */
-void opj_read_double_BE(const OPJ_BYTE * p_buffer, OPJ_FLOAT64 * p_value);
-
-/**
- * Reads some bytes from the given data buffer, this function is used in Little Endian cpus.
- * @param p_buffer pointer the data buffer to read data from.
- * @param p_value pointer to the value that will store the data.
- */
-void opj_read_float_LE(const OPJ_BYTE * p_buffer, OPJ_FLOAT32 * p_value);
-
-/**
- * Reads some bytes from the given data buffer, this function is used in Big Endian cpus.
- * @param p_buffer pointer the data buffer to read data from.
- * @param p_value pointer to the value that will store the data.
- */
-void opj_read_float_BE(const OPJ_BYTE * p_buffer, OPJ_FLOAT32 * p_value);
-
-/**
- * Write some bytes to the given data buffer, this function is used in Little Endian cpus.
- * @param p_buffer pointer the data buffer to write data to.
- * @param p_value the value to write
- */
-void opj_write_float_LE(OPJ_BYTE * p_buffer, OPJ_FLOAT32 p_value);
-
-/***
- * Write some bytes to the given data buffer, this function is used in Big Endian cpus.
- * @param p_buffer pointer the data buffer to write data to.
- * @param p_value the value to write
- */
-void opj_write_float_BE(OPJ_BYTE * p_buffer, OPJ_FLOAT32 p_value);
-
-/**
- * Reads some bytes from the stream.
- * @param p_stream the stream to read data from.
- * @param p_buffer pointer to the data buffer that will receive the data.
- * @param p_size number of bytes to read.
- * @param p_event_mgr the user event manager to be notified of special events.
- * @return the number of bytes read, or -1 if an error occurred or if the stream is at the end.
- */
-OPJ_SIZE_T opj_stream_read_data(opj_stream_private_t * p_stream,
- OPJ_BYTE * p_buffer, OPJ_SIZE_T p_size, struct opj_event_mgr * p_event_mgr);
-
-/**
- * Writes some bytes to the stream.
- * @param p_stream the stream to write data to.
- * @param p_buffer pointer to the data buffer holds the data to be writtent.
- * @param p_size number of bytes to write.
- * @param p_event_mgr the user event manager to be notified of special events.
- * @return the number of bytes writtent, or -1 if an error occurred.
- */
-OPJ_SIZE_T opj_stream_write_data(opj_stream_private_t * p_stream,
- const OPJ_BYTE * p_buffer, OPJ_SIZE_T p_size,
- struct opj_event_mgr * p_event_mgr);
-
-/**
- * Writes the content of the stream buffer to the stream.
- * @param p_stream the stream to write data to.
- * @param p_event_mgr the user event manager to be notified of special events.
- * @return true if the data could be flushed, false else.
- */
-OPJ_BOOL opj_stream_flush(opj_stream_private_t * p_stream,
- struct opj_event_mgr * p_event_mgr);
-
-/**
- * Skips a number of bytes from the stream.
- * @param p_stream the stream to skip data from.
- * @param p_size the number of bytes to skip.
- * @param p_event_mgr the user event manager to be notified of special events.
- * @return the number of bytes skipped, or -1 if an error occurred.
- */
-OPJ_OFF_T opj_stream_skip(opj_stream_private_t * p_stream, OPJ_OFF_T p_size,
- struct opj_event_mgr * p_event_mgr);
-
-/**
- * Tells the byte offset on the stream (similar to ftell).
- *
- * @param p_stream the stream to get the information from.
- *
- * @return the current position o fthe stream.
- */
-OPJ_OFF_T opj_stream_tell(const opj_stream_private_t * p_stream);
-
-
-/**
- * Get the number of bytes left before the end of the stream (similar to cio_numbytesleft).
- *
- * @param p_stream the stream to get the information from.
- *
- * @return Number of bytes left before the end of the stream.
- */
-OPJ_OFF_T opj_stream_get_number_byte_left(const opj_stream_private_t *
- p_stream);
-
-/**
- * Skips a number of bytes from the stream.
- * @param p_stream the stream to skip data from.
- * @param p_size the number of bytes to skip.
- * @param p_event_mgr the user event manager to be notified of special events.
- * @return the number of bytes skipped, or -1 if an error occurred.
- */
-OPJ_OFF_T opj_stream_write_skip(opj_stream_private_t * p_stream,
- OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr);
-
-/**
- * Skips a number of bytes from the stream.
- * @param p_stream the stream to skip data from.
- * @param p_size the number of bytes to skip.
- * @param p_event_mgr the user event manager to be notified of special events.
- * @return the number of bytes skipped, or -1 if an error occurred.
- */
-OPJ_OFF_T opj_stream_read_skip(opj_stream_private_t * p_stream,
- OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr);
-
-/**
- * Skips a number of bytes from the stream.
- * @param p_stream the stream to skip data from.
- * @param p_size the number of bytes to skip.
- * @param p_event_mgr the user event manager to be notified of special events.
- * @return OPJ_TRUE if success, or OPJ_FALSE if an error occurred.
- */
-OPJ_BOOL opj_stream_read_seek(opj_stream_private_t * p_stream, OPJ_OFF_T p_size,
- struct opj_event_mgr * p_event_mgr);
-
-/**
- * Skips a number of bytes from the stream.
- * @param p_stream the stream to skip data from.
- * @param p_size the number of bytes to skip.
- * @param p_event_mgr the user event manager to be notified of special events.
- * @return the number of bytes skipped, or -1 if an error occurred.
- */
-OPJ_BOOL opj_stream_write_seek(opj_stream_private_t * p_stream,
- OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr);
-
-/**
- * Seeks a number of bytes from the stream.
- * @param p_stream the stream to skip data from.
- * @param p_size the number of bytes to skip.
- * @param p_event_mgr the user event manager to be notified of special events.
- * @return true if the stream is seekable.
- */
-OPJ_BOOL opj_stream_seek(opj_stream_private_t * p_stream, OPJ_OFF_T p_size,
- struct opj_event_mgr * p_event_mgr);
-
-/**
- * Tells if the given stream is seekable.
- */
-OPJ_BOOL opj_stream_has_seek(const opj_stream_private_t * p_stream);
-
-/**
- * FIXME DOC.
- */
-OPJ_SIZE_T opj_stream_default_read(void * p_buffer, OPJ_SIZE_T p_nb_bytes,
- void * p_user_data);
-
-/**
- * FIXME DOC.
- */
-OPJ_SIZE_T opj_stream_default_write(void * p_buffer, OPJ_SIZE_T p_nb_bytes,
- void * p_user_data);
-
-/**
- * FIXME DOC.
- */
-OPJ_OFF_T opj_stream_default_skip(OPJ_OFF_T p_nb_bytes, void * p_user_data);
-
-/**
- * FIXME DOC.
- */
-OPJ_BOOL opj_stream_default_seek(OPJ_OFF_T p_nb_bytes, void * p_user_data);
-
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-
-#endif /* OPJ_CIO_H */
-
diff --git a/contrib/libs/openjpeg/dwt.c b/contrib/libs/openjpeg/dwt.c
deleted file mode 100644
index 11aae472de..0000000000
--- a/contrib/libs/openjpeg/dwt.c
+++ /dev/null
@@ -1,3979 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2014, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux
- * Copyright (c) 2003-2014, Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2007, Jonathan Ballard <dzonatas@dzonux.net>
- * Copyright (c) 2007, Callum Lerwick <seg@haxxed.com>
- * Copyright (c) 2017, IntoPIX SA <support@intopix.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <assert.h>
-
-#define OPJ_SKIP_POISON
-#include "opj_includes.h"
-
-#ifdef __SSE__
-#include <xmmintrin.h>
-#endif
-#ifdef __SSE2__
-#include <emmintrin.h>
-#endif
-#ifdef __SSSE3__
-#include <tmmintrin.h>
-#endif
-#if (defined(__AVX2__) || defined(__AVX512F__))
-#include <immintrin.h>
-#endif
-
-#if defined(__GNUC__)
-#pragma GCC poison malloc calloc realloc free
-#endif
-
-/** @defgroup DWT DWT - Implementation of a discrete wavelet transform */
-/*@{*/
-
-#define OPJ_WS(i) v->mem[(i)*2]
-#define OPJ_WD(i) v->mem[(1+(i)*2)]
-
-#if defined(__AVX512F__)
-/** Number of int32 values in a AVX512 register */
-#define VREG_INT_COUNT 16
-#elif defined(__AVX2__)
-/** Number of int32 values in a AVX2 register */
-#define VREG_INT_COUNT 8
-#else
-/** Number of int32 values in a SSE2 register */
-#define VREG_INT_COUNT 4
-#endif
-
-/** Number of columns that we can process in parallel in the vertical pass */
-#define PARALLEL_COLS_53 (2*VREG_INT_COUNT)
-
-/** @name Local data structures */
-/*@{*/
-
-typedef struct dwt_local {
- OPJ_INT32* mem;
- OPJ_INT32 dn; /* number of elements in high pass band */
- OPJ_INT32 sn; /* number of elements in low pass band */
- OPJ_INT32 cas; /* 0 = start on even coord, 1 = start on odd coord */
-} opj_dwt_t;
-
-#define NB_ELTS_V8 8
-
-typedef union {
- OPJ_FLOAT32 f[NB_ELTS_V8];
-} opj_v8_t;
-
-typedef struct v8dwt_local {
- opj_v8_t* wavelet ;
- OPJ_INT32 dn ; /* number of elements in high pass band */
- OPJ_INT32 sn ; /* number of elements in low pass band */
- OPJ_INT32 cas ; /* 0 = start on even coord, 1 = start on odd coord */
- OPJ_UINT32 win_l_x0; /* start coord in low pass band */
- OPJ_UINT32 win_l_x1; /* end coord in low pass band */
- OPJ_UINT32 win_h_x0; /* start coord in high pass band */
- OPJ_UINT32 win_h_x1; /* end coord in high pass band */
-} opj_v8dwt_t ;
-
-/* From table F.4 from the standard */
-static const OPJ_FLOAT32 opj_dwt_alpha = -1.586134342f;
-static const OPJ_FLOAT32 opj_dwt_beta = -0.052980118f;
-static const OPJ_FLOAT32 opj_dwt_gamma = 0.882911075f;
-static const OPJ_FLOAT32 opj_dwt_delta = 0.443506852f;
-
-static const OPJ_FLOAT32 opj_K = 1.230174105f;
-static const OPJ_FLOAT32 opj_invK = (OPJ_FLOAT32)(1.0 / 1.230174105);
-
-/*@}*/
-
-/** @name Local static functions */
-/*@{*/
-
-/**
-Forward lazy transform (horizontal)
-*/
-static void opj_dwt_deinterleave_h(const OPJ_INT32 * OPJ_RESTRICT a,
- OPJ_INT32 * OPJ_RESTRICT b,
- OPJ_INT32 dn,
- OPJ_INT32 sn, OPJ_INT32 cas);
-
-/**
-Forward 9-7 wavelet transform in 1-D
-*/
-static void opj_dwt_encode_1_real(void *a, OPJ_INT32 dn, OPJ_INT32 sn,
- OPJ_INT32 cas);
-/**
-Explicit calculation of the Quantization Stepsizes
-*/
-static void opj_dwt_encode_stepsize(OPJ_INT32 stepsize, OPJ_INT32 numbps,
- opj_stepsize_t *bandno_stepsize);
-/**
-Inverse wavelet transform in 2-D.
-*/
-static OPJ_BOOL opj_dwt_decode_tile(opj_thread_pool_t* tp,
- opj_tcd_tilecomp_t* tilec, OPJ_UINT32 i);
-
-static OPJ_BOOL opj_dwt_decode_partial_tile(
- opj_tcd_tilecomp_t* tilec,
- OPJ_UINT32 numres);
-
-/* Forward transform, for the vertical pass, processing cols columns */
-/* where cols <= NB_ELTS_V8 */
-/* Where void* is a OPJ_INT32* for 5x3 and OPJ_FLOAT32* for 9x7 */
-typedef void (*opj_encode_and_deinterleave_v_fnptr_type)(
- void *array,
- void *tmp,
- OPJ_UINT32 height,
- OPJ_BOOL even,
- OPJ_UINT32 stride_width,
- OPJ_UINT32 cols);
-
-/* Where void* is a OPJ_INT32* for 5x3 and OPJ_FLOAT32* for 9x7 */
-typedef void (*opj_encode_and_deinterleave_h_one_row_fnptr_type)(
- void *row,
- void *tmp,
- OPJ_UINT32 width,
- OPJ_BOOL even);
-
-static OPJ_BOOL opj_dwt_encode_procedure(opj_thread_pool_t* tp,
- opj_tcd_tilecomp_t * tilec,
- opj_encode_and_deinterleave_v_fnptr_type p_encode_and_deinterleave_v,
- opj_encode_and_deinterleave_h_one_row_fnptr_type
- p_encode_and_deinterleave_h_one_row);
-
-static OPJ_UINT32 opj_dwt_max_resolution(opj_tcd_resolution_t* OPJ_RESTRICT r,
- OPJ_UINT32 i);
-
-/* <summary> */
-/* Inverse 9-7 wavelet transform in 1-D. */
-/* </summary> */
-
-/*@}*/
-
-/*@}*/
-
-#define OPJ_S(i) a[(i)*2]
-#define OPJ_D(i) a[(1+(i)*2)]
-#define OPJ_S_(i) ((i)<0?OPJ_S(0):((i)>=sn?OPJ_S(sn-1):OPJ_S(i)))
-#define OPJ_D_(i) ((i)<0?OPJ_D(0):((i)>=dn?OPJ_D(dn-1):OPJ_D(i)))
-/* new */
-#define OPJ_SS_(i) ((i)<0?OPJ_S(0):((i)>=dn?OPJ_S(dn-1):OPJ_S(i)))
-#define OPJ_DD_(i) ((i)<0?OPJ_D(0):((i)>=sn?OPJ_D(sn-1):OPJ_D(i)))
-
-/* <summary> */
-/* This table contains the norms of the 5-3 wavelets for different bands. */
-/* </summary> */
-/* FIXME! the array should really be extended up to 33 resolution levels */
-/* See https://github.com/uclouvain/openjpeg/issues/493 */
-static const OPJ_FLOAT64 opj_dwt_norms[4][10] = {
- {1.000, 1.500, 2.750, 5.375, 10.68, 21.34, 42.67, 85.33, 170.7, 341.3},
- {1.038, 1.592, 2.919, 5.703, 11.33, 22.64, 45.25, 90.48, 180.9},
- {1.038, 1.592, 2.919, 5.703, 11.33, 22.64, 45.25, 90.48, 180.9},
- {.7186, .9218, 1.586, 3.043, 6.019, 12.01, 24.00, 47.97, 95.93}
-};
-
-/* <summary> */
-/* This table contains the norms of the 9-7 wavelets for different bands. */
-/* </summary> */
-/* FIXME! the array should really be extended up to 33 resolution levels */
-/* See https://github.com/uclouvain/openjpeg/issues/493 */
-static const OPJ_FLOAT64 opj_dwt_norms_real[4][10] = {
- {1.000, 1.965, 4.177, 8.403, 16.90, 33.84, 67.69, 135.3, 270.6, 540.9},
- {2.022, 3.989, 8.355, 17.04, 34.27, 68.63, 137.3, 274.6, 549.0},
- {2.022, 3.989, 8.355, 17.04, 34.27, 68.63, 137.3, 274.6, 549.0},
- {2.080, 3.865, 8.307, 17.18, 34.71, 69.59, 139.3, 278.6, 557.2}
-};
-
-/*
-==========================================================
- local functions
-==========================================================
-*/
-
-/* <summary> */
-/* Forward lazy transform (horizontal). */
-/* </summary> */
-static void opj_dwt_deinterleave_h(const OPJ_INT32 * OPJ_RESTRICT a,
- OPJ_INT32 * OPJ_RESTRICT b,
- OPJ_INT32 dn,
- OPJ_INT32 sn, OPJ_INT32 cas)
-{
- OPJ_INT32 i;
- OPJ_INT32 * OPJ_RESTRICT l_dest = b;
- const OPJ_INT32 * OPJ_RESTRICT l_src = a + cas;
-
- for (i = 0; i < sn; ++i) {
- *l_dest++ = *l_src;
- l_src += 2;
- }
-
- l_dest = b + sn;
- l_src = a + 1 - cas;
-
- for (i = 0; i < dn; ++i) {
- *l_dest++ = *l_src;
- l_src += 2;
- }
-}
-
-#ifdef STANDARD_SLOW_VERSION
-/* <summary> */
-/* Inverse lazy transform (horizontal). */
-/* </summary> */
-static void opj_dwt_interleave_h(const opj_dwt_t* h, OPJ_INT32 *a)
-{
- const OPJ_INT32 *ai = a;
- OPJ_INT32 *bi = h->mem + h->cas;
- OPJ_INT32 i = h->sn;
- while (i--) {
- *bi = *(ai++);
- bi += 2;
- }
- ai = a + h->sn;
- bi = h->mem + 1 - h->cas;
- i = h->dn ;
- while (i--) {
- *bi = *(ai++);
- bi += 2;
- }
-}
-
-/* <summary> */
-/* Inverse lazy transform (vertical). */
-/* </summary> */
-static void opj_dwt_interleave_v(const opj_dwt_t* v, OPJ_INT32 *a, OPJ_INT32 x)
-{
- const OPJ_INT32 *ai = a;
- OPJ_INT32 *bi = v->mem + v->cas;
- OPJ_INT32 i = v->sn;
- while (i--) {
- *bi = *ai;
- bi += 2;
- ai += x;
- }
- ai = a + (v->sn * (OPJ_SIZE_T)x);
- bi = v->mem + 1 - v->cas;
- i = v->dn ;
- while (i--) {
- *bi = *ai;
- bi += 2;
- ai += x;
- }
-}
-
-#endif /* STANDARD_SLOW_VERSION */
-
-#ifdef STANDARD_SLOW_VERSION
-/* <summary> */
-/* Inverse 5-3 wavelet transform in 1-D. */
-/* </summary> */
-static void opj_dwt_decode_1_(OPJ_INT32 *a, OPJ_INT32 dn, OPJ_INT32 sn,
- OPJ_INT32 cas)
-{
- OPJ_INT32 i;
-
- if (!cas) {
- if ((dn > 0) || (sn > 1)) { /* NEW : CASE ONE ELEMENT */
- for (i = 0; i < sn; i++) {
- OPJ_S(i) -= (OPJ_D_(i - 1) + OPJ_D_(i) + 2) >> 2;
- }
- for (i = 0; i < dn; i++) {
- OPJ_D(i) += (OPJ_S_(i) + OPJ_S_(i + 1)) >> 1;
- }
- }
- } else {
- if (!sn && dn == 1) { /* NEW : CASE ONE ELEMENT */
- OPJ_S(0) /= 2;
- } else {
- for (i = 0; i < sn; i++) {
- OPJ_D(i) -= (OPJ_SS_(i) + OPJ_SS_(i + 1) + 2) >> 2;
- }
- for (i = 0; i < dn; i++) {
- OPJ_S(i) += (OPJ_DD_(i) + OPJ_DD_(i - 1)) >> 1;
- }
- }
- }
-}
-
-static void opj_dwt_decode_1(const opj_dwt_t *v)
-{
- opj_dwt_decode_1_(v->mem, v->dn, v->sn, v->cas);
-}
-
-#endif /* STANDARD_SLOW_VERSION */
-
-#if defined(__AVX512F__)
-static int32_t loop_short_sse(int32_t len, const int32_t** lf_ptr,
- const int32_t** hf_ptr, int32_t** out_ptr,
- int32_t* prev_even)
-{
- int32_t next_even;
- __m128i odd, even_m1, unpack1, unpack2;
- const int32_t batch = (len - 2) / 8;
- const __m128i two = _mm_set1_epi32(2);
-
- for (int32_t i = 0; i < batch; i++) {
- const __m128i lf_ = _mm_loadu_si128((__m128i*)(*lf_ptr + 1));
- const __m128i hf1_ = _mm_loadu_si128((__m128i*)(*hf_ptr));
- const __m128i hf2_ = _mm_loadu_si128((__m128i*)(*hf_ptr + 1));
-
- __m128i even = _mm_add_epi32(hf1_, hf2_);
- even = _mm_add_epi32(even, two);
- even = _mm_srai_epi32(even, 2);
- even = _mm_sub_epi32(lf_, even);
-
- next_even = _mm_extract_epi32(even, 3);
- even_m1 = _mm_bslli_si128(even, 4);
- even_m1 = _mm_insert_epi32(even_m1, *prev_even, 0);
-
- //out[0] + out[2]
- odd = _mm_add_epi32(even_m1, even);
- odd = _mm_srai_epi32(odd, 1);
- odd = _mm_add_epi32(odd, hf1_);
-
- unpack1 = _mm_unpacklo_epi32(even_m1, odd);
- unpack2 = _mm_unpackhi_epi32(even_m1, odd);
-
- _mm_storeu_si128((__m128i*)(*out_ptr + 0), unpack1);
- _mm_storeu_si128((__m128i*)(*out_ptr + 4), unpack2);
-
- *prev_even = next_even;
-
- *out_ptr += 8;
- *lf_ptr += 4;
- *hf_ptr += 4;
- }
- return batch;
-}
-#endif
-
-#if !defined(STANDARD_SLOW_VERSION)
-static void opj_idwt53_h_cas0(OPJ_INT32* tmp,
- const OPJ_INT32 sn,
- const OPJ_INT32 len,
- OPJ_INT32* tiledp)
-{
- OPJ_INT32 i, j;
- const OPJ_INT32* in_even = &tiledp[0];
- const OPJ_INT32* in_odd = &tiledp[sn];
-
-#ifdef TWO_PASS_VERSION
- /* For documentation purpose: performs lifting in two iterations, */
- /* but without explicit interleaving */
-
- assert(len > 1);
-
- /* Even */
- tmp[0] = in_even[0] - ((in_odd[0] + 1) >> 1);
- for (i = 2, j = 0; i <= len - 2; i += 2, j++) {
- tmp[i] = in_even[j + 1] - ((in_odd[j] + in_odd[j + 1] + 2) >> 2);
- }
- if (len & 1) { /* if len is odd */
- tmp[len - 1] = in_even[(len - 1) / 2] - ((in_odd[(len - 2) / 2] + 1) >> 1);
- }
-
- /* Odd */
- for (i = 1, j = 0; i < len - 1; i += 2, j++) {
- tmp[i] = in_odd[j] + ((tmp[i - 1] + tmp[i + 1]) >> 1);
- }
- if (!(len & 1)) { /* if len is even */
- tmp[len - 1] = in_odd[(len - 1) / 2] + tmp[len - 2];
- }
-#else
-#if defined(__AVX512F__)
- OPJ_INT32* out_ptr = tmp;
- int32_t prev_even = in_even[0] - ((in_odd[0] + 1) >> 1);
-
- const __m512i permutevar_mask = _mm512_setr_epi32(
- 0x10, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
- 0x0c, 0x0d, 0x0e);
- const __m512i store1_perm = _mm512_setr_epi64(0x00, 0x01, 0x08, 0x09, 0x02,
- 0x03, 0x0a, 0x0b);
- const __m512i store2_perm = _mm512_setr_epi64(0x04, 0x05, 0x0c, 0x0d, 0x06,
- 0x07, 0x0e, 0x0f);
-
- const __m512i two = _mm512_set1_epi32(2);
-
- int32_t simd_batch_512 = (len - 2) / 32;
- int32_t leftover;
-
- for (i = 0; i < simd_batch_512; i++) {
- const __m512i lf_avx2 = _mm512_loadu_si512((__m512i*)(in_even + 1));
- const __m512i hf1_avx2 = _mm512_loadu_si512((__m512i*)(in_odd));
- const __m512i hf2_avx2 = _mm512_loadu_si512((__m512i*)(in_odd + 1));
- int32_t next_even;
- __m512i duplicate, even_m1, odd, unpack1, unpack2, store1, store2;
-
- __m512i even = _mm512_add_epi32(hf1_avx2, hf2_avx2);
- even = _mm512_add_epi32(even, two);
- even = _mm512_srai_epi32(even, 2);
- even = _mm512_sub_epi32(lf_avx2, even);
-
- next_even = _mm_extract_epi32(_mm512_extracti32x4_epi32(even, 3), 3);
-
- duplicate = _mm512_set1_epi32(prev_even);
- even_m1 = _mm512_permutex2var_epi32(even, permutevar_mask, duplicate);
-
- //out[0] + out[2]
- odd = _mm512_add_epi32(even_m1, even);
- odd = _mm512_srai_epi32(odd, 1);
- odd = _mm512_add_epi32(odd, hf1_avx2);
-
- unpack1 = _mm512_unpacklo_epi32(even_m1, odd);
- unpack2 = _mm512_unpackhi_epi32(even_m1, odd);
-
- store1 = _mm512_permutex2var_epi64(unpack1, store1_perm, unpack2);
- store2 = _mm512_permutex2var_epi64(unpack1, store2_perm, unpack2);
-
- _mm512_storeu_si512(out_ptr, store1);
- _mm512_storeu_si512(out_ptr + 16, store2);
-
- prev_even = next_even;
-
- out_ptr += 32;
- in_even += 16;
- in_odd += 16;
- }
-
- leftover = len - simd_batch_512 * 32;
- if (leftover > 8) {
- leftover -= 8 * loop_short_sse(leftover, &in_even, &in_odd, &out_ptr,
- &prev_even);
- }
- out_ptr[0] = prev_even;
-
- for (j = 1; j < (leftover - 2); j += 2) {
- out_ptr[2] = in_even[1] - ((in_odd[0] + (in_odd[1]) + 2) >> 2);
- out_ptr[1] = in_odd[0] + ((out_ptr[0] + out_ptr[2]) >> 1);
- in_even++;
- in_odd++;
- out_ptr += 2;
- }
-
- if (len & 1) {
- out_ptr[2] = in_even[1] - ((in_odd[0] + 1) >> 1);
- out_ptr[1] = in_odd[0] + ((out_ptr[0] + out_ptr[2]) >> 1);
- } else { //!(len & 1)
- out_ptr[1] = in_odd[0] + out_ptr[0];
- }
-#elif defined(__AVX2__)
- OPJ_INT32* out_ptr = tmp;
- int32_t prev_even = in_even[0] - ((in_odd[0] + 1) >> 1);
-
- const __m256i reg_permutevar_mask_move_right = _mm256_setr_epi32(0x00, 0x00,
- 0x01, 0x02, 0x03, 0x04, 0x05, 0x06);
- const __m256i two = _mm256_set1_epi32(2);
-
- int32_t simd_batch = (len - 2) / 16;
- int32_t next_even;
- __m256i even_m1, odd, unpack1_avx2, unpack2_avx2;
-
- for (i = 0; i < simd_batch; i++) {
- const __m256i lf_avx2 = _mm256_loadu_si256((__m256i*)(in_even + 1));
- const __m256i hf1_avx2 = _mm256_loadu_si256((__m256i*)(in_odd));
- const __m256i hf2_avx2 = _mm256_loadu_si256((__m256i*)(in_odd + 1));
-
- __m256i even = _mm256_add_epi32(hf1_avx2, hf2_avx2);
- even = _mm256_add_epi32(even, two);
- even = _mm256_srai_epi32(even, 2);
- even = _mm256_sub_epi32(lf_avx2, even);
-
- next_even = _mm_extract_epi32(_mm256_extracti128_si256(even, 1), 3);
- even_m1 = _mm256_permutevar8x32_epi32(even, reg_permutevar_mask_move_right);
- even_m1 = _mm256_blend_epi32(even_m1, _mm256_set1_epi32(prev_even), (1 << 0));
-
- //out[0] + out[2]
- odd = _mm256_add_epi32(even_m1, even);
- odd = _mm256_srai_epi32(odd, 1);
- odd = _mm256_add_epi32(odd, hf1_avx2);
-
- unpack1_avx2 = _mm256_unpacklo_epi32(even_m1, odd);
- unpack2_avx2 = _mm256_unpackhi_epi32(even_m1, odd);
-
- _mm_storeu_si128((__m128i*)(out_ptr + 0), _mm256_castsi256_si128(unpack1_avx2));
- _mm_storeu_si128((__m128i*)(out_ptr + 4), _mm256_castsi256_si128(unpack2_avx2));
- _mm_storeu_si128((__m128i*)(out_ptr + 8), _mm256_extracti128_si256(unpack1_avx2,
- 0x1));
- _mm_storeu_si128((__m128i*)(out_ptr + 12),
- _mm256_extracti128_si256(unpack2_avx2, 0x1));
-
- prev_even = next_even;
-
- out_ptr += 16;
- in_even += 8;
- in_odd += 8;
- }
- out_ptr[0] = prev_even;
- for (j = simd_batch * 16 + 1; j < (len - 2); j += 2) {
- out_ptr[2] = in_even[1] - ((in_odd[0] + in_odd[1] + 2) >> 2);
- out_ptr[1] = in_odd[0] + ((out_ptr[0] + out_ptr[2]) >> 1);
- in_even++;
- in_odd++;
- out_ptr += 2;
- }
-
- if (len & 1) {
- out_ptr[2] = in_even[1] - ((in_odd[0] + 1) >> 1);
- out_ptr[1] = in_odd[0] + ((out_ptr[0] + out_ptr[2]) >> 1);
- } else { //!(len & 1)
- out_ptr[1] = in_odd[0] + out_ptr[0];
- }
-#else
- OPJ_INT32 d1c, d1n, s1n, s0c, s0n;
-
- assert(len > 1);
-
- /* Improved version of the TWO_PASS_VERSION: */
- /* Performs lifting in one single iteration. Saves memory */
- /* accesses and explicit interleaving. */
- s1n = in_even[0];
- d1n = in_odd[0];
- s0n = s1n - ((d1n + 1) >> 1);
-
- for (i = 0, j = 1; i < (len - 3); i += 2, j++) {
- d1c = d1n;
- s0c = s0n;
-
- s1n = in_even[j];
- d1n = in_odd[j];
-
- s0n = s1n - ((d1c + d1n + 2) >> 2);
-
- tmp[i ] = s0c;
- tmp[i + 1] = opj_int_add_no_overflow(d1c, opj_int_add_no_overflow(s0c,
- s0n) >> 1);
- }
-
- tmp[i] = s0n;
-
- if (len & 1) {
- tmp[len - 1] = in_even[(len - 1) / 2] - ((d1n + 1) >> 1);
- tmp[len - 2] = d1n + ((s0n + tmp[len - 1]) >> 1);
- } else {
- tmp[len - 1] = d1n + s0n;
- }
-#endif /*(__AVX512F__ || __AVX2__)*/
-#endif /*TWO_PASS_VERSION*/
- memcpy(tiledp, tmp, (OPJ_UINT32)len * sizeof(OPJ_INT32));
-}
-
-static void opj_idwt53_h_cas1(OPJ_INT32* tmp,
- const OPJ_INT32 sn,
- const OPJ_INT32 len,
- OPJ_INT32* tiledp)
-{
- OPJ_INT32 i, j;
- const OPJ_INT32* in_even = &tiledp[sn];
- const OPJ_INT32* in_odd = &tiledp[0];
-
-#ifdef TWO_PASS_VERSION
- /* For documentation purpose: performs lifting in two iterations, */
- /* but without explicit interleaving */
-
- assert(len > 2);
-
- /* Odd */
- for (i = 1, j = 0; i < len - 1; i += 2, j++) {
- tmp[i] = in_odd[j] - ((in_even[j] + in_even[j + 1] + 2) >> 2);
- }
- if (!(len & 1)) {
- tmp[len - 1] = in_odd[len / 2 - 1] - ((in_even[len / 2 - 1] + 1) >> 1);
- }
-
- /* Even */
- tmp[0] = in_even[0] + tmp[1];
- for (i = 2, j = 1; i < len - 1; i += 2, j++) {
- tmp[i] = in_even[j] + ((tmp[i + 1] + tmp[i - 1]) >> 1);
- }
- if (len & 1) {
- tmp[len - 1] = in_even[len / 2] + tmp[len - 2];
- }
-#else
- OPJ_INT32 s1, s2, dc, dn;
-
- assert(len > 2);
-
- /* Improved version of the TWO_PASS_VERSION: */
- /* Performs lifting in one single iteration. Saves memory */
- /* accesses and explicit interleaving. */
-
- s1 = in_even[1];
- dc = in_odd[0] - ((in_even[0] + s1 + 2) >> 2);
- tmp[0] = in_even[0] + dc;
-
- for (i = 1, j = 1; i < (len - 2 - !(len & 1)); i += 2, j++) {
-
- s2 = in_even[j + 1];
-
- dn = in_odd[j] - ((s1 + s2 + 2) >> 2);
- tmp[i ] = dc;
- tmp[i + 1] = opj_int_add_no_overflow(s1, opj_int_add_no_overflow(dn, dc) >> 1);
-
- dc = dn;
- s1 = s2;
- }
-
- tmp[i] = dc;
-
- if (!(len & 1)) {
- dn = in_odd[len / 2 - 1] - ((s1 + 1) >> 1);
- tmp[len - 2] = s1 + ((dn + dc) >> 1);
- tmp[len - 1] = dn;
- } else {
- tmp[len - 1] = s1 + dc;
- }
-#endif
- memcpy(tiledp, tmp, (OPJ_UINT32)len * sizeof(OPJ_INT32));
-}
-
-
-#endif /* !defined(STANDARD_SLOW_VERSION) */
-
-/* <summary> */
-/* Inverse 5-3 wavelet transform in 1-D for one row. */
-/* </summary> */
-/* Performs interleave, inverse wavelet transform and copy back to buffer */
-static void opj_idwt53_h(const opj_dwt_t *dwt,
- OPJ_INT32* tiledp)
-{
-#ifdef STANDARD_SLOW_VERSION
- /* For documentation purpose */
- opj_dwt_interleave_h(dwt, tiledp);
- opj_dwt_decode_1(dwt);
- memcpy(tiledp, dwt->mem, (OPJ_UINT32)(dwt->sn + dwt->dn) * sizeof(OPJ_INT32));
-#else
- const OPJ_INT32 sn = dwt->sn;
- const OPJ_INT32 len = sn + dwt->dn;
- if (dwt->cas == 0) { /* Left-most sample is on even coordinate */
- if (len > 1) {
- opj_idwt53_h_cas0(dwt->mem, sn, len, tiledp);
- } else {
- /* Unmodified value */
- }
- } else { /* Left-most sample is on odd coordinate */
- if (len == 1) {
- tiledp[0] /= 2;
- } else if (len == 2) {
- OPJ_INT32* out = dwt->mem;
- const OPJ_INT32* in_even = &tiledp[sn];
- const OPJ_INT32* in_odd = &tiledp[0];
- out[1] = in_odd[0] - ((in_even[0] + 1) >> 1);
- out[0] = in_even[0] + out[1];
- memcpy(tiledp, dwt->mem, (OPJ_UINT32)len * sizeof(OPJ_INT32));
- } else if (len > 2) {
- opj_idwt53_h_cas1(dwt->mem, sn, len, tiledp);
- }
- }
-#endif
-}
-
-#if (defined(__SSE2__) || defined(__AVX2__) || defined(__AVX512F__)) && !defined(STANDARD_SLOW_VERSION)
-
-/* Conveniency macros to improve the readability of the formulas */
-#if defined(__AVX512F__)
-#define VREG __m512i
-#define LOAD_CST(x) _mm512_set1_epi32(x)
-#define LOAD(x) _mm512_loadu_si512((const VREG*)(x))
-#define LOADU(x) _mm512_loadu_si512((const VREG*)(x))
-#define STORE(x,y) _mm512_storeu_si512((VREG*)(x),(y))
-#define STOREU(x,y) _mm512_storeu_si512((VREG*)(x),(y))
-#define ADD(x,y) _mm512_add_epi32((x),(y))
-#define SUB(x,y) _mm512_sub_epi32((x),(y))
-#define SAR(x,y) _mm512_srai_epi32((x),(y))
-#elif defined(__AVX2__)
-#define VREG __m256i
-#define LOAD_CST(x) _mm256_set1_epi32(x)
-#define LOAD(x) _mm256_load_si256((const VREG*)(x))
-#define LOADU(x) _mm256_loadu_si256((const VREG*)(x))
-#define STORE(x,y) _mm256_store_si256((VREG*)(x),(y))
-#define STOREU(x,y) _mm256_storeu_si256((VREG*)(x),(y))
-#define ADD(x,y) _mm256_add_epi32((x),(y))
-#define SUB(x,y) _mm256_sub_epi32((x),(y))
-#define SAR(x,y) _mm256_srai_epi32((x),(y))
-#else
-#define VREG __m128i
-#define LOAD_CST(x) _mm_set1_epi32(x)
-#define LOAD(x) _mm_load_si128((const VREG*)(x))
-#define LOADU(x) _mm_loadu_si128((const VREG*)(x))
-#define STORE(x,y) _mm_store_si128((VREG*)(x),(y))
-#define STOREU(x,y) _mm_storeu_si128((VREG*)(x),(y))
-#define ADD(x,y) _mm_add_epi32((x),(y))
-#define SUB(x,y) _mm_sub_epi32((x),(y))
-#define SAR(x,y) _mm_srai_epi32((x),(y))
-#endif
-#define ADD3(x,y,z) ADD(ADD(x,y),z)
-
-static
-void opj_idwt53_v_final_memcpy(OPJ_INT32* tiledp_col,
- const OPJ_INT32* tmp,
- OPJ_INT32 len,
- OPJ_SIZE_T stride)
-{
- OPJ_INT32 i;
- for (i = 0; i < len; ++i) {
- /* A memcpy(&tiledp_col[i * stride + 0],
- &tmp[PARALLEL_COLS_53 * i + 0],
- PARALLEL_COLS_53 * sizeof(OPJ_INT32))
- would do but would be a tiny bit slower.
- We can take here advantage of our knowledge of alignment */
- STOREU(&tiledp_col[(OPJ_SIZE_T)i * stride + 0],
- LOAD(&tmp[PARALLEL_COLS_53 * i + 0]));
- STOREU(&tiledp_col[(OPJ_SIZE_T)i * stride + VREG_INT_COUNT],
- LOAD(&tmp[PARALLEL_COLS_53 * i + VREG_INT_COUNT]));
- }
-}
-
-/** Vertical inverse 5x3 wavelet transform for 8 columns in SSE2, or
- * 16 in AVX2, when top-most pixel is on even coordinate */
-static void opj_idwt53_v_cas0_mcols_SSE2_OR_AVX2(
- OPJ_INT32* tmp,
- const OPJ_INT32 sn,
- const OPJ_INT32 len,
- OPJ_INT32* tiledp_col,
- const OPJ_SIZE_T stride)
-{
- const OPJ_INT32* in_even = &tiledp_col[0];
- const OPJ_INT32* in_odd = &tiledp_col[(OPJ_SIZE_T)sn * stride];
-
- OPJ_INT32 i;
- OPJ_SIZE_T j;
- VREG d1c_0, d1n_0, s1n_0, s0c_0, s0n_0;
- VREG d1c_1, d1n_1, s1n_1, s0c_1, s0n_1;
- const VREG two = LOAD_CST(2);
-
- assert(len > 1);
-#if defined(__AVX512F__)
- assert(PARALLEL_COLS_53 == 32);
- assert(VREG_INT_COUNT == 16);
-#elif defined(__AVX2__)
- assert(PARALLEL_COLS_53 == 16);
- assert(VREG_INT_COUNT == 8);
-#else
- assert(PARALLEL_COLS_53 == 8);
- assert(VREG_INT_COUNT == 4);
-#endif
-
-//For AVX512 code aligned load/store is set to it's unaligned equivalents
-#if !defined(__AVX512F__)
- /* Note: loads of input even/odd values must be done in a unaligned */
- /* fashion. But stores in tmp can be done with aligned store, since */
- /* the temporary buffer is properly aligned */
- assert((OPJ_SIZE_T)tmp % (sizeof(OPJ_INT32) * VREG_INT_COUNT) == 0);
-#endif
-
- s1n_0 = LOADU(in_even + 0);
- s1n_1 = LOADU(in_even + VREG_INT_COUNT);
- d1n_0 = LOADU(in_odd);
- d1n_1 = LOADU(in_odd + VREG_INT_COUNT);
-
- /* s0n = s1n - ((d1n + 1) >> 1); <==> */
- /* s0n = s1n - ((d1n + d1n + 2) >> 2); */
- s0n_0 = SUB(s1n_0, SAR(ADD3(d1n_0, d1n_0, two), 2));
- s0n_1 = SUB(s1n_1, SAR(ADD3(d1n_1, d1n_1, two), 2));
-
- for (i = 0, j = 1; i < (len - 3); i += 2, j++) {
- d1c_0 = d1n_0;
- s0c_0 = s0n_0;
- d1c_1 = d1n_1;
- s0c_1 = s0n_1;
-
- s1n_0 = LOADU(in_even + j * stride);
- s1n_1 = LOADU(in_even + j * stride + VREG_INT_COUNT);
- d1n_0 = LOADU(in_odd + j * stride);
- d1n_1 = LOADU(in_odd + j * stride + VREG_INT_COUNT);
-
- /*s0n = s1n - ((d1c + d1n + 2) >> 2);*/
- s0n_0 = SUB(s1n_0, SAR(ADD3(d1c_0, d1n_0, two), 2));
- s0n_1 = SUB(s1n_1, SAR(ADD3(d1c_1, d1n_1, two), 2));
-
- STORE(tmp + PARALLEL_COLS_53 * (i + 0), s0c_0);
- STORE(tmp + PARALLEL_COLS_53 * (i + 0) + VREG_INT_COUNT, s0c_1);
-
- /* d1c + ((s0c + s0n) >> 1) */
- STORE(tmp + PARALLEL_COLS_53 * (i + 1) + 0,
- ADD(d1c_0, SAR(ADD(s0c_0, s0n_0), 1)));
- STORE(tmp + PARALLEL_COLS_53 * (i + 1) + VREG_INT_COUNT,
- ADD(d1c_1, SAR(ADD(s0c_1, s0n_1), 1)));
- }
-
- STORE(tmp + PARALLEL_COLS_53 * (i + 0) + 0, s0n_0);
- STORE(tmp + PARALLEL_COLS_53 * (i + 0) + VREG_INT_COUNT, s0n_1);
-
- if (len & 1) {
- VREG tmp_len_minus_1;
- s1n_0 = LOADU(in_even + (OPJ_SIZE_T)((len - 1) / 2) * stride);
- /* tmp_len_minus_1 = s1n - ((d1n + 1) >> 1); */
- tmp_len_minus_1 = SUB(s1n_0, SAR(ADD3(d1n_0, d1n_0, two), 2));
- STORE(tmp + PARALLEL_COLS_53 * (len - 1), tmp_len_minus_1);
- /* d1n + ((s0n + tmp_len_minus_1) >> 1) */
- STORE(tmp + PARALLEL_COLS_53 * (len - 2),
- ADD(d1n_0, SAR(ADD(s0n_0, tmp_len_minus_1), 1)));
-
- s1n_1 = LOADU(in_even + (OPJ_SIZE_T)((len - 1) / 2) * stride + VREG_INT_COUNT);
- /* tmp_len_minus_1 = s1n - ((d1n + 1) >> 1); */
- tmp_len_minus_1 = SUB(s1n_1, SAR(ADD3(d1n_1, d1n_1, two), 2));
- STORE(tmp + PARALLEL_COLS_53 * (len - 1) + VREG_INT_COUNT,
- tmp_len_minus_1);
- /* d1n + ((s0n + tmp_len_minus_1) >> 1) */
- STORE(tmp + PARALLEL_COLS_53 * (len - 2) + VREG_INT_COUNT,
- ADD(d1n_1, SAR(ADD(s0n_1, tmp_len_minus_1), 1)));
-
-
- } else {
- STORE(tmp + PARALLEL_COLS_53 * (len - 1) + 0,
- ADD(d1n_0, s0n_0));
- STORE(tmp + PARALLEL_COLS_53 * (len - 1) + VREG_INT_COUNT,
- ADD(d1n_1, s0n_1));
- }
-
- opj_idwt53_v_final_memcpy(tiledp_col, tmp, len, stride);
-}
-
-
-/** Vertical inverse 5x3 wavelet transform for 8 columns in SSE2, or
- * 16 in AVX2, when top-most pixel is on odd coordinate */
-static void opj_idwt53_v_cas1_mcols_SSE2_OR_AVX2(
- OPJ_INT32* tmp,
- const OPJ_INT32 sn,
- const OPJ_INT32 len,
- OPJ_INT32* tiledp_col,
- const OPJ_SIZE_T stride)
-{
- OPJ_INT32 i;
- OPJ_SIZE_T j;
-
- VREG s1_0, s2_0, dc_0, dn_0;
- VREG s1_1, s2_1, dc_1, dn_1;
- const VREG two = LOAD_CST(2);
-
- const OPJ_INT32* in_even = &tiledp_col[(OPJ_SIZE_T)sn * stride];
- const OPJ_INT32* in_odd = &tiledp_col[0];
-
- assert(len > 2);
-#if defined(__AVX512F__)
- assert(PARALLEL_COLS_53 == 32);
- assert(VREG_INT_COUNT == 16);
-#elif defined(__AVX2__)
- assert(PARALLEL_COLS_53 == 16);
- assert(VREG_INT_COUNT == 8);
-#else
- assert(PARALLEL_COLS_53 == 8);
- assert(VREG_INT_COUNT == 4);
-#endif
-
-//For AVX512 code aligned load/store is set to it's unaligned equivalents
-#if !defined(__AVX512F__)
- /* Note: loads of input even/odd values must be done in a unaligned */
- /* fashion. But stores in tmp can be done with aligned store, since */
- /* the temporary buffer is properly aligned */
- assert((OPJ_SIZE_T)tmp % (sizeof(OPJ_INT32) * VREG_INT_COUNT) == 0);
-#endif
-
- s1_0 = LOADU(in_even + stride);
- /* in_odd[0] - ((in_even[0] + s1 + 2) >> 2); */
- dc_0 = SUB(LOADU(in_odd + 0),
- SAR(ADD3(LOADU(in_even + 0), s1_0, two), 2));
- STORE(tmp + PARALLEL_COLS_53 * 0, ADD(LOADU(in_even + 0), dc_0));
-
- s1_1 = LOADU(in_even + stride + VREG_INT_COUNT);
- /* in_odd[0] - ((in_even[0] + s1 + 2) >> 2); */
- dc_1 = SUB(LOADU(in_odd + VREG_INT_COUNT),
- SAR(ADD3(LOADU(in_even + VREG_INT_COUNT), s1_1, two), 2));
- STORE(tmp + PARALLEL_COLS_53 * 0 + VREG_INT_COUNT,
- ADD(LOADU(in_even + VREG_INT_COUNT), dc_1));
-
- for (i = 1, j = 1; i < (len - 2 - !(len & 1)); i += 2, j++) {
-
- s2_0 = LOADU(in_even + (j + 1) * stride);
- s2_1 = LOADU(in_even + (j + 1) * stride + VREG_INT_COUNT);
-
- /* dn = in_odd[j * stride] - ((s1 + s2 + 2) >> 2); */
- dn_0 = SUB(LOADU(in_odd + j * stride),
- SAR(ADD3(s1_0, s2_0, two), 2));
- dn_1 = SUB(LOADU(in_odd + j * stride + VREG_INT_COUNT),
- SAR(ADD3(s1_1, s2_1, two), 2));
-
- STORE(tmp + PARALLEL_COLS_53 * i, dc_0);
- STORE(tmp + PARALLEL_COLS_53 * i + VREG_INT_COUNT, dc_1);
-
- /* tmp[i + 1] = s1 + ((dn + dc) >> 1); */
- STORE(tmp + PARALLEL_COLS_53 * (i + 1) + 0,
- ADD(s1_0, SAR(ADD(dn_0, dc_0), 1)));
- STORE(tmp + PARALLEL_COLS_53 * (i + 1) + VREG_INT_COUNT,
- ADD(s1_1, SAR(ADD(dn_1, dc_1), 1)));
-
- dc_0 = dn_0;
- s1_0 = s2_0;
- dc_1 = dn_1;
- s1_1 = s2_1;
- }
- STORE(tmp + PARALLEL_COLS_53 * i, dc_0);
- STORE(tmp + PARALLEL_COLS_53 * i + VREG_INT_COUNT, dc_1);
-
- if (!(len & 1)) {
- /*dn = in_odd[(len / 2 - 1) * stride] - ((s1 + 1) >> 1); */
- dn_0 = SUB(LOADU(in_odd + (OPJ_SIZE_T)(len / 2 - 1) * stride),
- SAR(ADD3(s1_0, s1_0, two), 2));
- dn_1 = SUB(LOADU(in_odd + (OPJ_SIZE_T)(len / 2 - 1) * stride + VREG_INT_COUNT),
- SAR(ADD3(s1_1, s1_1, two), 2));
-
- /* tmp[len - 2] = s1 + ((dn + dc) >> 1); */
- STORE(tmp + PARALLEL_COLS_53 * (len - 2) + 0,
- ADD(s1_0, SAR(ADD(dn_0, dc_0), 1)));
- STORE(tmp + PARALLEL_COLS_53 * (len - 2) + VREG_INT_COUNT,
- ADD(s1_1, SAR(ADD(dn_1, dc_1), 1)));
-
- STORE(tmp + PARALLEL_COLS_53 * (len - 1) + 0, dn_0);
- STORE(tmp + PARALLEL_COLS_53 * (len - 1) + VREG_INT_COUNT, dn_1);
- } else {
- STORE(tmp + PARALLEL_COLS_53 * (len - 1) + 0, ADD(s1_0, dc_0));
- STORE(tmp + PARALLEL_COLS_53 * (len - 1) + VREG_INT_COUNT,
- ADD(s1_1, dc_1));
- }
-
- opj_idwt53_v_final_memcpy(tiledp_col, tmp, len, stride);
-}
-
-#undef VREG
-#undef LOAD_CST
-#undef LOADU
-#undef LOAD
-#undef STORE
-#undef STOREU
-#undef ADD
-#undef ADD3
-#undef SUB
-#undef SAR
-
-#endif /* (defined(__SSE2__) || defined(__AVX2__)) && !defined(STANDARD_SLOW_VERSION) */
-
-#if !defined(STANDARD_SLOW_VERSION)
-/** Vertical inverse 5x3 wavelet transform for one column, when top-most
- * pixel is on even coordinate */
-static void opj_idwt3_v_cas0(OPJ_INT32* tmp,
- const OPJ_INT32 sn,
- const OPJ_INT32 len,
- OPJ_INT32* tiledp_col,
- const OPJ_SIZE_T stride)
-{
- OPJ_INT32 i, j;
- OPJ_INT32 d1c, d1n, s1n, s0c, s0n;
-
- assert(len > 1);
-
- /* Performs lifting in one single iteration. Saves memory */
- /* accesses and explicit interleaving. */
-
- s1n = tiledp_col[0];
- d1n = tiledp_col[(OPJ_SIZE_T)sn * stride];
- s0n = s1n - ((d1n + 1) >> 1);
-
- for (i = 0, j = 0; i < (len - 3); i += 2, j++) {
- d1c = d1n;
- s0c = s0n;
-
- s1n = tiledp_col[(OPJ_SIZE_T)(j + 1) * stride];
- d1n = tiledp_col[(OPJ_SIZE_T)(sn + j + 1) * stride];
-
- s0n = opj_int_sub_no_overflow(s1n,
- opj_int_add_no_overflow(opj_int_add_no_overflow(d1c, d1n), 2) >> 2);
-
- tmp[i ] = s0c;
- tmp[i + 1] = opj_int_add_no_overflow(d1c, opj_int_add_no_overflow(s0c,
- s0n) >> 1);
- }
-
- tmp[i] = s0n;
-
- if (len & 1) {
- tmp[len - 1] =
- tiledp_col[(OPJ_SIZE_T)((len - 1) / 2) * stride] -
- ((d1n + 1) >> 1);
- tmp[len - 2] = d1n + ((s0n + tmp[len - 1]) >> 1);
- } else {
- tmp[len - 1] = d1n + s0n;
- }
-
- for (i = 0; i < len; ++i) {
- tiledp_col[(OPJ_SIZE_T)i * stride] = tmp[i];
- }
-}
-
-
-/** Vertical inverse 5x3 wavelet transform for one column, when top-most
- * pixel is on odd coordinate */
-static void opj_idwt3_v_cas1(OPJ_INT32* tmp,
- const OPJ_INT32 sn,
- const OPJ_INT32 len,
- OPJ_INT32* tiledp_col,
- const OPJ_SIZE_T stride)
-{
- OPJ_INT32 i, j;
- OPJ_INT32 s1, s2, dc, dn;
- const OPJ_INT32* in_even = &tiledp_col[(OPJ_SIZE_T)sn * stride];
- const OPJ_INT32* in_odd = &tiledp_col[0];
-
- assert(len > 2);
-
- /* Performs lifting in one single iteration. Saves memory */
- /* accesses and explicit interleaving. */
-
- s1 = in_even[stride];
- dc = in_odd[0] - ((in_even[0] + s1 + 2) >> 2);
- tmp[0] = in_even[0] + dc;
- for (i = 1, j = 1; i < (len - 2 - !(len & 1)); i += 2, j++) {
-
- s2 = in_even[(OPJ_SIZE_T)(j + 1) * stride];
-
- dn = in_odd[(OPJ_SIZE_T)j * stride] - ((s1 + s2 + 2) >> 2);
- tmp[i ] = dc;
- tmp[i + 1] = s1 + ((dn + dc) >> 1);
-
- dc = dn;
- s1 = s2;
- }
- tmp[i] = dc;
- if (!(len & 1)) {
- dn = in_odd[(OPJ_SIZE_T)(len / 2 - 1) * stride] - ((s1 + 1) >> 1);
- tmp[len - 2] = s1 + ((dn + dc) >> 1);
- tmp[len - 1] = dn;
- } else {
- tmp[len - 1] = s1 + dc;
- }
-
- for (i = 0; i < len; ++i) {
- tiledp_col[(OPJ_SIZE_T)i * stride] = tmp[i];
- }
-}
-#endif /* !defined(STANDARD_SLOW_VERSION) */
-
-/* <summary> */
-/* Inverse vertical 5-3 wavelet transform in 1-D for several columns. */
-/* </summary> */
-/* Performs interleave, inverse wavelet transform and copy back to buffer */
-static void opj_idwt53_v(const opj_dwt_t *dwt,
- OPJ_INT32* tiledp_col,
- OPJ_SIZE_T stride,
- OPJ_INT32 nb_cols)
-{
-#ifdef STANDARD_SLOW_VERSION
- /* For documentation purpose */
- OPJ_INT32 k, c;
- for (c = 0; c < nb_cols; c ++) {
- opj_dwt_interleave_v(dwt, tiledp_col + c, stride);
- opj_dwt_decode_1(dwt);
- for (k = 0; k < dwt->sn + dwt->dn; ++k) {
- tiledp_col[c + k * stride] = dwt->mem[k];
- }
- }
-#else
- const OPJ_INT32 sn = dwt->sn;
- const OPJ_INT32 len = sn + dwt->dn;
- if (dwt->cas == 0) {
- /* If len == 1, unmodified value */
-
-#if (defined(__SSE2__) || defined(__AVX2__))
- if (len > 1 && nb_cols == PARALLEL_COLS_53) {
- /* Same as below general case, except that thanks to SSE2/AVX2 */
- /* we can efficiently process 8/16 columns in parallel */
- opj_idwt53_v_cas0_mcols_SSE2_OR_AVX2(dwt->mem, sn, len, tiledp_col, stride);
- return;
- }
-#endif
- if (len > 1) {
- OPJ_INT32 c;
- for (c = 0; c < nb_cols; c++, tiledp_col++) {
- opj_idwt3_v_cas0(dwt->mem, sn, len, tiledp_col, stride);
- }
- return;
- }
- } else {
- if (len == 1) {
- OPJ_INT32 c;
- for (c = 0; c < nb_cols; c++, tiledp_col++) {
- tiledp_col[0] /= 2;
- }
- return;
- }
-
- if (len == 2) {
- OPJ_INT32 c;
- OPJ_INT32* out = dwt->mem;
- for (c = 0; c < nb_cols; c++, tiledp_col++) {
- OPJ_INT32 i;
- const OPJ_INT32* in_even = &tiledp_col[(OPJ_SIZE_T)sn * stride];
- const OPJ_INT32* in_odd = &tiledp_col[0];
-
- out[1] = in_odd[0] - ((in_even[0] + 1) >> 1);
- out[0] = in_even[0] + out[1];
-
- for (i = 0; i < len; ++i) {
- tiledp_col[(OPJ_SIZE_T)i * stride] = out[i];
- }
- }
-
- return;
- }
-
-#if (defined(__SSE2__) || defined(__AVX2__))
- if (len > 2 && nb_cols == PARALLEL_COLS_53) {
- /* Same as below general case, except that thanks to SSE2/AVX2 */
- /* we can efficiently process 8/16 columns in parallel */
- opj_idwt53_v_cas1_mcols_SSE2_OR_AVX2(dwt->mem, sn, len, tiledp_col, stride);
- return;
- }
-#endif
- if (len > 2) {
- OPJ_INT32 c;
- for (c = 0; c < nb_cols; c++, tiledp_col++) {
- opj_idwt3_v_cas1(dwt->mem, sn, len, tiledp_col, stride);
- }
- return;
- }
- }
-#endif
-}
-
-#if 0
-static void opj_dwt_encode_step1(OPJ_FLOAT32* fw,
- OPJ_UINT32 end,
- const OPJ_FLOAT32 c)
-{
- OPJ_UINT32 i = 0;
- for (; i < end; ++i) {
- fw[0] *= c;
- fw += 2;
- }
-}
-#else
-static void opj_dwt_encode_step1_combined(OPJ_FLOAT32* fw,
- OPJ_UINT32 iters_c1,
- OPJ_UINT32 iters_c2,
- const OPJ_FLOAT32 c1,
- const OPJ_FLOAT32 c2)
-{
- OPJ_UINT32 i = 0;
- const OPJ_UINT32 iters_common = opj_uint_min(iters_c1, iters_c2);
- assert((((OPJ_SIZE_T)fw) & 0xf) == 0);
- assert(opj_int_abs((OPJ_INT32)iters_c1 - (OPJ_INT32)iters_c2) <= 1);
- for (; i + 3 < iters_common; i += 4) {
-#ifdef __SSE__
- const __m128 vcst = _mm_set_ps(c2, c1, c2, c1);
- *(__m128*)fw = _mm_mul_ps(*(__m128*)fw, vcst);
- *(__m128*)(fw + 4) = _mm_mul_ps(*(__m128*)(fw + 4), vcst);
-#else
- fw[0] *= c1;
- fw[1] *= c2;
- fw[2] *= c1;
- fw[3] *= c2;
- fw[4] *= c1;
- fw[5] *= c2;
- fw[6] *= c1;
- fw[7] *= c2;
-#endif
- fw += 8;
- }
- for (; i < iters_common; i++) {
- fw[0] *= c1;
- fw[1] *= c2;
- fw += 2;
- }
- if (i < iters_c1) {
- fw[0] *= c1;
- } else if (i < iters_c2) {
- fw[1] *= c2;
- }
-}
-
-#endif
-
-static void opj_dwt_encode_step2(OPJ_FLOAT32* fl, OPJ_FLOAT32* fw,
- OPJ_UINT32 end,
- OPJ_UINT32 m,
- OPJ_FLOAT32 c)
-{
- OPJ_UINT32 i;
- OPJ_UINT32 imax = opj_uint_min(end, m);
- if (imax > 0) {
- fw[-1] += (fl[0] + fw[0]) * c;
- fw += 2;
- i = 1;
- for (; i + 3 < imax; i += 4) {
- fw[-1] += (fw[-2] + fw[0]) * c;
- fw[1] += (fw[0] + fw[2]) * c;
- fw[3] += (fw[2] + fw[4]) * c;
- fw[5] += (fw[4] + fw[6]) * c;
- fw += 8;
- }
- for (; i < imax; ++i) {
- fw[-1] += (fw[-2] + fw[0]) * c;
- fw += 2;
- }
- }
- if (m < end) {
- assert(m + 1 == end);
- fw[-1] += (2 * fw[-2]) * c;
- }
-}
-
-static void opj_dwt_encode_1_real(void *aIn, OPJ_INT32 dn, OPJ_INT32 sn,
- OPJ_INT32 cas)
-{
- OPJ_FLOAT32* w = (OPJ_FLOAT32*)aIn;
- OPJ_INT32 a, b;
- assert(dn + sn > 1);
- if (cas == 0) {
- a = 0;
- b = 1;
- } else {
- a = 1;
- b = 0;
- }
- opj_dwt_encode_step2(w + a, w + b + 1,
- (OPJ_UINT32)dn,
- (OPJ_UINT32)opj_int_min(dn, sn - b),
- opj_dwt_alpha);
- opj_dwt_encode_step2(w + b, w + a + 1,
- (OPJ_UINT32)sn,
- (OPJ_UINT32)opj_int_min(sn, dn - a),
- opj_dwt_beta);
- opj_dwt_encode_step2(w + a, w + b + 1,
- (OPJ_UINT32)dn,
- (OPJ_UINT32)opj_int_min(dn, sn - b),
- opj_dwt_gamma);
- opj_dwt_encode_step2(w + b, w + a + 1,
- (OPJ_UINT32)sn,
- (OPJ_UINT32)opj_int_min(sn, dn - a),
- opj_dwt_delta);
-#if 0
- opj_dwt_encode_step1(w + b, (OPJ_UINT32)dn,
- opj_K);
- opj_dwt_encode_step1(w + a, (OPJ_UINT32)sn,
- opj_invK);
-#else
- if (a == 0) {
- opj_dwt_encode_step1_combined(w,
- (OPJ_UINT32)sn,
- (OPJ_UINT32)dn,
- opj_invK,
- opj_K);
- } else {
- opj_dwt_encode_step1_combined(w,
- (OPJ_UINT32)dn,
- (OPJ_UINT32)sn,
- opj_K,
- opj_invK);
- }
-#endif
-}
-
-static void opj_dwt_encode_stepsize(OPJ_INT32 stepsize, OPJ_INT32 numbps,
- opj_stepsize_t *bandno_stepsize)
-{
- OPJ_INT32 p, n;
- p = opj_int_floorlog2(stepsize) - 13;
- n = 11 - opj_int_floorlog2(stepsize);
- bandno_stepsize->mant = (n < 0 ? stepsize >> -n : stepsize << n) & 0x7ff;
- bandno_stepsize->expn = numbps - p;
-}
-
-/*
-==========================================================
- DWT interface
-==========================================================
-*/
-
-/** Process one line for the horizontal pass of the 5x3 forward transform */
-static
-void opj_dwt_encode_and_deinterleave_h_one_row(void* rowIn,
- void* tmpIn,
- OPJ_UINT32 width,
- OPJ_BOOL even)
-{
- OPJ_INT32* OPJ_RESTRICT row = (OPJ_INT32*)rowIn;
- OPJ_INT32* OPJ_RESTRICT tmp = (OPJ_INT32*)tmpIn;
- const OPJ_INT32 sn = (OPJ_INT32)((width + (even ? 1 : 0)) >> 1);
- const OPJ_INT32 dn = (OPJ_INT32)(width - (OPJ_UINT32)sn);
-
- if (even) {
- if (width > 1) {
- OPJ_INT32 i;
- for (i = 0; i < sn - 1; i++) {
- tmp[sn + i] = row[2 * i + 1] - ((row[(i) * 2] + row[(i + 1) * 2]) >> 1);
- }
- if ((width % 2) == 0) {
- tmp[sn + i] = row[2 * i + 1] - row[(i) * 2];
- }
- row[0] += (tmp[sn] + tmp[sn] + 2) >> 2;
- for (i = 1; i < dn; i++) {
- row[i] = row[2 * i] + ((tmp[sn + (i - 1)] + tmp[sn + i] + 2) >> 2);
- }
- if ((width % 2) == 1) {
- row[i] = row[2 * i] + ((tmp[sn + (i - 1)] + tmp[sn + (i - 1)] + 2) >> 2);
- }
- memcpy(row + sn, tmp + sn, (OPJ_SIZE_T)dn * sizeof(OPJ_INT32));
- }
- } else {
- if (width == 1) {
- row[0] *= 2;
- } else {
- OPJ_INT32 i;
- tmp[sn + 0] = row[0] - row[1];
- for (i = 1; i < sn; i++) {
- tmp[sn + i] = row[2 * i] - ((row[2 * i + 1] + row[2 * (i - 1) + 1]) >> 1);
- }
- if ((width % 2) == 1) {
- tmp[sn + i] = row[2 * i] - row[2 * (i - 1) + 1];
- }
-
- for (i = 0; i < dn - 1; i++) {
- row[i] = row[2 * i + 1] + ((tmp[sn + i] + tmp[sn + i + 1] + 2) >> 2);
- }
- if ((width % 2) == 0) {
- row[i] = row[2 * i + 1] + ((tmp[sn + i] + tmp[sn + i] + 2) >> 2);
- }
- memcpy(row + sn, tmp + sn, (OPJ_SIZE_T)dn * sizeof(OPJ_INT32));
- }
- }
-}
-
-/** Process one line for the horizontal pass of the 9x7 forward transform */
-static
-void opj_dwt_encode_and_deinterleave_h_one_row_real(void* rowIn,
- void* tmpIn,
- OPJ_UINT32 width,
- OPJ_BOOL even)
-{
- OPJ_FLOAT32* OPJ_RESTRICT row = (OPJ_FLOAT32*)rowIn;
- OPJ_FLOAT32* OPJ_RESTRICT tmp = (OPJ_FLOAT32*)tmpIn;
- const OPJ_INT32 sn = (OPJ_INT32)((width + (even ? 1 : 0)) >> 1);
- const OPJ_INT32 dn = (OPJ_INT32)(width - (OPJ_UINT32)sn);
- if (width == 1) {
- return;
- }
- memcpy(tmp, row, width * sizeof(OPJ_FLOAT32));
- opj_dwt_encode_1_real(tmp, dn, sn, even ? 0 : 1);
- opj_dwt_deinterleave_h((OPJ_INT32 * OPJ_RESTRICT)tmp,
- (OPJ_INT32 * OPJ_RESTRICT)row,
- dn, sn, even ? 0 : 1);
-}
-
-typedef struct {
- opj_dwt_t h;
- OPJ_UINT32 rw; /* Width of the resolution to process */
- OPJ_UINT32 w; /* Width of tiledp */
- OPJ_INT32 * OPJ_RESTRICT tiledp;
- OPJ_UINT32 min_j;
- OPJ_UINT32 max_j;
- opj_encode_and_deinterleave_h_one_row_fnptr_type p_function;
-} opj_dwt_encode_h_job_t;
-
-static void opj_dwt_encode_h_func(void* user_data, opj_tls_t* tls)
-{
- OPJ_UINT32 j;
- opj_dwt_encode_h_job_t* job;
- (void)tls;
-
- job = (opj_dwt_encode_h_job_t*)user_data;
- for (j = job->min_j; j < job->max_j; j++) {
- OPJ_INT32* OPJ_RESTRICT aj = job->tiledp + j * job->w;
- (*job->p_function)(aj, job->h.mem, job->rw,
- job->h.cas == 0 ? OPJ_TRUE : OPJ_FALSE);
- }
-
- opj_aligned_free(job->h.mem);
- opj_free(job);
-}
-
-typedef struct {
- opj_dwt_t v;
- OPJ_UINT32 rh;
- OPJ_UINT32 w;
- OPJ_INT32 * OPJ_RESTRICT tiledp;
- OPJ_UINT32 min_j;
- OPJ_UINT32 max_j;
- opj_encode_and_deinterleave_v_fnptr_type p_encode_and_deinterleave_v;
-} opj_dwt_encode_v_job_t;
-
-static void opj_dwt_encode_v_func(void* user_data, opj_tls_t* tls)
-{
- OPJ_UINT32 j;
- opj_dwt_encode_v_job_t* job;
- (void)tls;
-
- job = (opj_dwt_encode_v_job_t*)user_data;
- for (j = job->min_j; j + NB_ELTS_V8 - 1 < job->max_j; j += NB_ELTS_V8) {
- (*job->p_encode_and_deinterleave_v)(job->tiledp + j,
- job->v.mem,
- job->rh,
- job->v.cas == 0,
- job->w,
- NB_ELTS_V8);
- }
- if (j < job->max_j) {
- (*job->p_encode_and_deinterleave_v)(job->tiledp + j,
- job->v.mem,
- job->rh,
- job->v.cas == 0,
- job->w,
- job->max_j - j);
- }
-
- opj_aligned_free(job->v.mem);
- opj_free(job);
-}
-
-/** Fetch up to cols <= NB_ELTS_V8 for each line, and put them in tmpOut */
-/* that has a NB_ELTS_V8 interleave factor. */
-static void opj_dwt_fetch_cols_vertical_pass(const void *arrayIn,
- void *tmpOut,
- OPJ_UINT32 height,
- OPJ_UINT32 stride_width,
- OPJ_UINT32 cols)
-{
- const OPJ_INT32* OPJ_RESTRICT array = (const OPJ_INT32 * OPJ_RESTRICT)arrayIn;
- OPJ_INT32* OPJ_RESTRICT tmp = (OPJ_INT32 * OPJ_RESTRICT)tmpOut;
- if (cols == NB_ELTS_V8) {
- OPJ_UINT32 k;
- for (k = 0; k < height; ++k) {
- memcpy(tmp + NB_ELTS_V8 * k,
- array + k * stride_width,
- NB_ELTS_V8 * sizeof(OPJ_INT32));
- }
- } else {
- OPJ_UINT32 k;
- for (k = 0; k < height; ++k) {
- OPJ_UINT32 c;
- for (c = 0; c < cols; c++) {
- tmp[NB_ELTS_V8 * k + c] = array[c + k * stride_width];
- }
- for (; c < NB_ELTS_V8; c++) {
- tmp[NB_ELTS_V8 * k + c] = 0;
- }
- }
- }
-}
-
-/* Deinterleave result of forward transform, where cols <= NB_ELTS_V8 */
-/* and src contains NB_ELTS_V8 consecutive values for up to NB_ELTS_V8 */
-/* columns. */
-static INLINE void opj_dwt_deinterleave_v_cols(
- const OPJ_INT32 * OPJ_RESTRICT src,
- OPJ_INT32 * OPJ_RESTRICT dst,
- OPJ_INT32 dn,
- OPJ_INT32 sn,
- OPJ_UINT32 stride_width,
- OPJ_INT32 cas,
- OPJ_UINT32 cols)
-{
- OPJ_INT32 k;
- OPJ_INT32 i = sn;
- OPJ_INT32 * OPJ_RESTRICT l_dest = dst;
- const OPJ_INT32 * OPJ_RESTRICT l_src = src + cas * NB_ELTS_V8;
- OPJ_UINT32 c;
-
- for (k = 0; k < 2; k++) {
- while (i--) {
- if (cols == NB_ELTS_V8) {
- memcpy(l_dest, l_src, NB_ELTS_V8 * sizeof(OPJ_INT32));
- } else {
- c = 0;
- switch (cols) {
- case 7:
- l_dest[c] = l_src[c];
- c++; /* fallthru */
- case 6:
- l_dest[c] = l_src[c];
- c++; /* fallthru */
- case 5:
- l_dest[c] = l_src[c];
- c++; /* fallthru */
- case 4:
- l_dest[c] = l_src[c];
- c++; /* fallthru */
- case 3:
- l_dest[c] = l_src[c];
- c++; /* fallthru */
- case 2:
- l_dest[c] = l_src[c];
- c++; /* fallthru */
- default:
- l_dest[c] = l_src[c];
- break;
- }
- }
- l_dest += stride_width;
- l_src += 2 * NB_ELTS_V8;
- }
-
- l_dest = dst + (OPJ_SIZE_T)sn * (OPJ_SIZE_T)stride_width;
- l_src = src + (1 - cas) * NB_ELTS_V8;
- i = dn;
- }
-}
-
-
-/* Forward 5-3 transform, for the vertical pass, processing cols columns */
-/* where cols <= NB_ELTS_V8 */
-static void opj_dwt_encode_and_deinterleave_v(
- void *arrayIn,
- void *tmpIn,
- OPJ_UINT32 height,
- OPJ_BOOL even,
- OPJ_UINT32 stride_width,
- OPJ_UINT32 cols)
-{
- OPJ_INT32* OPJ_RESTRICT array = (OPJ_INT32 * OPJ_RESTRICT)arrayIn;
- OPJ_INT32* OPJ_RESTRICT tmp = (OPJ_INT32 * OPJ_RESTRICT)tmpIn;
- const OPJ_UINT32 sn = (height + (even ? 1 : 0)) >> 1;
- const OPJ_UINT32 dn = height - sn;
-
- opj_dwt_fetch_cols_vertical_pass(arrayIn, tmpIn, height, stride_width, cols);
-
-#define OPJ_Sc(i) tmp[(i)*2* NB_ELTS_V8 + c]
-#define OPJ_Dc(i) tmp[((1+(i)*2))* NB_ELTS_V8 + c]
-
-#ifdef __SSE2__
- if (height == 1) {
- if (!even) {
- OPJ_UINT32 c;
- for (c = 0; c < NB_ELTS_V8; c++) {
- tmp[c] *= 2;
- }
- }
- } else if (even) {
- OPJ_UINT32 c;
- OPJ_UINT32 i;
- i = 0;
- if (i + 1 < sn) {
- __m128i xmm_Si_0 = *(const __m128i*)(tmp + 4 * 0);
- __m128i xmm_Si_1 = *(const __m128i*)(tmp + 4 * 1);
- for (; i + 1 < sn; i++) {
- __m128i xmm_Sip1_0 = *(const __m128i*)(tmp +
- (i + 1) * 2 * NB_ELTS_V8 + 4 * 0);
- __m128i xmm_Sip1_1 = *(const __m128i*)(tmp +
- (i + 1) * 2 * NB_ELTS_V8 + 4 * 1);
- __m128i xmm_Di_0 = *(const __m128i*)(tmp +
- (1 + i * 2) * NB_ELTS_V8 + 4 * 0);
- __m128i xmm_Di_1 = *(const __m128i*)(tmp +
- (1 + i * 2) * NB_ELTS_V8 + 4 * 1);
- xmm_Di_0 = _mm_sub_epi32(xmm_Di_0,
- _mm_srai_epi32(_mm_add_epi32(xmm_Si_0, xmm_Sip1_0), 1));
- xmm_Di_1 = _mm_sub_epi32(xmm_Di_1,
- _mm_srai_epi32(_mm_add_epi32(xmm_Si_1, xmm_Sip1_1), 1));
- *(__m128i*)(tmp + (1 + i * 2) * NB_ELTS_V8 + 4 * 0) = xmm_Di_0;
- *(__m128i*)(tmp + (1 + i * 2) * NB_ELTS_V8 + 4 * 1) = xmm_Di_1;
- xmm_Si_0 = xmm_Sip1_0;
- xmm_Si_1 = xmm_Sip1_1;
- }
- }
- if (((height) % 2) == 0) {
- for (c = 0; c < NB_ELTS_V8; c++) {
- OPJ_Dc(i) -= OPJ_Sc(i);
- }
- }
- for (c = 0; c < NB_ELTS_V8; c++) {
- OPJ_Sc(0) += (OPJ_Dc(0) + OPJ_Dc(0) + 2) >> 2;
- }
- i = 1;
- if (i < dn) {
- __m128i xmm_Dim1_0 = *(const __m128i*)(tmp + (1 +
- (i - 1) * 2) * NB_ELTS_V8 + 4 * 0);
- __m128i xmm_Dim1_1 = *(const __m128i*)(tmp + (1 +
- (i - 1) * 2) * NB_ELTS_V8 + 4 * 1);
- const __m128i xmm_two = _mm_set1_epi32(2);
- for (; i < dn; i++) {
- __m128i xmm_Di_0 = *(const __m128i*)(tmp +
- (1 + i * 2) * NB_ELTS_V8 + 4 * 0);
- __m128i xmm_Di_1 = *(const __m128i*)(tmp +
- (1 + i * 2) * NB_ELTS_V8 + 4 * 1);
- __m128i xmm_Si_0 = *(const __m128i*)(tmp +
- (i * 2) * NB_ELTS_V8 + 4 * 0);
- __m128i xmm_Si_1 = *(const __m128i*)(tmp +
- (i * 2) * NB_ELTS_V8 + 4 * 1);
- xmm_Si_0 = _mm_add_epi32(xmm_Si_0,
- _mm_srai_epi32(_mm_add_epi32(_mm_add_epi32(xmm_Dim1_0, xmm_Di_0), xmm_two), 2));
- xmm_Si_1 = _mm_add_epi32(xmm_Si_1,
- _mm_srai_epi32(_mm_add_epi32(_mm_add_epi32(xmm_Dim1_1, xmm_Di_1), xmm_two), 2));
- *(__m128i*)(tmp + (i * 2) * NB_ELTS_V8 + 4 * 0) = xmm_Si_0;
- *(__m128i*)(tmp + (i * 2) * NB_ELTS_V8 + 4 * 1) = xmm_Si_1;
- xmm_Dim1_0 = xmm_Di_0;
- xmm_Dim1_1 = xmm_Di_1;
- }
- }
- if (((height) % 2) == 1) {
- for (c = 0; c < NB_ELTS_V8; c++) {
- OPJ_Sc(i) += (OPJ_Dc(i - 1) + OPJ_Dc(i - 1) + 2) >> 2;
- }
- }
- } else {
- OPJ_UINT32 c;
- OPJ_UINT32 i;
- for (c = 0; c < NB_ELTS_V8; c++) {
- OPJ_Sc(0) -= OPJ_Dc(0);
- }
- i = 1;
- if (i < sn) {
- __m128i xmm_Dim1_0 = *(const __m128i*)(tmp + (1 +
- (i - 1) * 2) * NB_ELTS_V8 + 4 * 0);
- __m128i xmm_Dim1_1 = *(const __m128i*)(tmp + (1 +
- (i - 1) * 2) * NB_ELTS_V8 + 4 * 1);
- for (; i < sn; i++) {
- __m128i xmm_Di_0 = *(const __m128i*)(tmp +
- (1 + i * 2) * NB_ELTS_V8 + 4 * 0);
- __m128i xmm_Di_1 = *(const __m128i*)(tmp +
- (1 + i * 2) * NB_ELTS_V8 + 4 * 1);
- __m128i xmm_Si_0 = *(const __m128i*)(tmp +
- (i * 2) * NB_ELTS_V8 + 4 * 0);
- __m128i xmm_Si_1 = *(const __m128i*)(tmp +
- (i * 2) * NB_ELTS_V8 + 4 * 1);
- xmm_Si_0 = _mm_sub_epi32(xmm_Si_0,
- _mm_srai_epi32(_mm_add_epi32(xmm_Di_0, xmm_Dim1_0), 1));
- xmm_Si_1 = _mm_sub_epi32(xmm_Si_1,
- _mm_srai_epi32(_mm_add_epi32(xmm_Di_1, xmm_Dim1_1), 1));
- *(__m128i*)(tmp + (i * 2) * NB_ELTS_V8 + 4 * 0) = xmm_Si_0;
- *(__m128i*)(tmp + (i * 2) * NB_ELTS_V8 + 4 * 1) = xmm_Si_1;
- xmm_Dim1_0 = xmm_Di_0;
- xmm_Dim1_1 = xmm_Di_1;
- }
- }
- if (((height) % 2) == 1) {
- for (c = 0; c < NB_ELTS_V8; c++) {
- OPJ_Sc(i) -= OPJ_Dc(i - 1);
- }
- }
- i = 0;
- if (i + 1 < dn) {
- __m128i xmm_Si_0 = *((const __m128i*)(tmp + 4 * 0));
- __m128i xmm_Si_1 = *((const __m128i*)(tmp + 4 * 1));
- const __m128i xmm_two = _mm_set1_epi32(2);
- for (; i + 1 < dn; i++) {
- __m128i xmm_Sip1_0 = *(const __m128i*)(tmp +
- (i + 1) * 2 * NB_ELTS_V8 + 4 * 0);
- __m128i xmm_Sip1_1 = *(const __m128i*)(tmp +
- (i + 1) * 2 * NB_ELTS_V8 + 4 * 1);
- __m128i xmm_Di_0 = *(const __m128i*)(tmp +
- (1 + i * 2) * NB_ELTS_V8 + 4 * 0);
- __m128i xmm_Di_1 = *(const __m128i*)(tmp +
- (1 + i * 2) * NB_ELTS_V8 + 4 * 1);
- xmm_Di_0 = _mm_add_epi32(xmm_Di_0,
- _mm_srai_epi32(_mm_add_epi32(_mm_add_epi32(xmm_Si_0, xmm_Sip1_0), xmm_two), 2));
- xmm_Di_1 = _mm_add_epi32(xmm_Di_1,
- _mm_srai_epi32(_mm_add_epi32(_mm_add_epi32(xmm_Si_1, xmm_Sip1_1), xmm_two), 2));
- *(__m128i*)(tmp + (1 + i * 2) * NB_ELTS_V8 + 4 * 0) = xmm_Di_0;
- *(__m128i*)(tmp + (1 + i * 2) * NB_ELTS_V8 + 4 * 1) = xmm_Di_1;
- xmm_Si_0 = xmm_Sip1_0;
- xmm_Si_1 = xmm_Sip1_1;
- }
- }
- if (((height) % 2) == 0) {
- for (c = 0; c < NB_ELTS_V8; c++) {
- OPJ_Dc(i) += (OPJ_Sc(i) + OPJ_Sc(i) + 2) >> 2;
- }
- }
- }
-#else
- if (even) {
- OPJ_UINT32 c;
- if (height > 1) {
- OPJ_UINT32 i;
- for (i = 0; i + 1 < sn; i++) {
- for (c = 0; c < NB_ELTS_V8; c++) {
- OPJ_Dc(i) -= (OPJ_Sc(i) + OPJ_Sc(i + 1)) >> 1;
- }
- }
- if (((height) % 2) == 0) {
- for (c = 0; c < NB_ELTS_V8; c++) {
- OPJ_Dc(i) -= OPJ_Sc(i);
- }
- }
- for (c = 0; c < NB_ELTS_V8; c++) {
- OPJ_Sc(0) += (OPJ_Dc(0) + OPJ_Dc(0) + 2) >> 2;
- }
- for (i = 1; i < dn; i++) {
- for (c = 0; c < NB_ELTS_V8; c++) {
- OPJ_Sc(i) += (OPJ_Dc(i - 1) + OPJ_Dc(i) + 2) >> 2;
- }
- }
- if (((height) % 2) == 1) {
- for (c = 0; c < NB_ELTS_V8; c++) {
- OPJ_Sc(i) += (OPJ_Dc(i - 1) + OPJ_Dc(i - 1) + 2) >> 2;
- }
- }
- }
- } else {
- OPJ_UINT32 c;
- if (height == 1) {
- for (c = 0; c < NB_ELTS_V8; c++) {
- OPJ_Sc(0) *= 2;
- }
- } else {
- OPJ_UINT32 i;
- for (c = 0; c < NB_ELTS_V8; c++) {
- OPJ_Sc(0) -= OPJ_Dc(0);
- }
- for (i = 1; i < sn; i++) {
- for (c = 0; c < NB_ELTS_V8; c++) {
- OPJ_Sc(i) -= (OPJ_Dc(i) + OPJ_Dc(i - 1)) >> 1;
- }
- }
- if (((height) % 2) == 1) {
- for (c = 0; c < NB_ELTS_V8; c++) {
- OPJ_Sc(i) -= OPJ_Dc(i - 1);
- }
- }
- for (i = 0; i + 1 < dn; i++) {
- for (c = 0; c < NB_ELTS_V8; c++) {
- OPJ_Dc(i) += (OPJ_Sc(i) + OPJ_Sc(i + 1) + 2) >> 2;
- }
- }
- if (((height) % 2) == 0) {
- for (c = 0; c < NB_ELTS_V8; c++) {
- OPJ_Dc(i) += (OPJ_Sc(i) + OPJ_Sc(i) + 2) >> 2;
- }
- }
- }
- }
-#endif
-
- if (cols == NB_ELTS_V8) {
- opj_dwt_deinterleave_v_cols(tmp, array, (OPJ_INT32)dn, (OPJ_INT32)sn,
- stride_width, even ? 0 : 1, NB_ELTS_V8);
- } else {
- opj_dwt_deinterleave_v_cols(tmp, array, (OPJ_INT32)dn, (OPJ_INT32)sn,
- stride_width, even ? 0 : 1, cols);
- }
-}
-
-static void opj_v8dwt_encode_step1(OPJ_FLOAT32* fw,
- OPJ_UINT32 end,
- const OPJ_FLOAT32 cst)
-{
- OPJ_UINT32 i;
-#ifdef __SSE__
- __m128* vw = (__m128*) fw;
- const __m128 vcst = _mm_set1_ps(cst);
- for (i = 0; i < end; ++i) {
- vw[0] = _mm_mul_ps(vw[0], vcst);
- vw[1] = _mm_mul_ps(vw[1], vcst);
- vw += 2 * (NB_ELTS_V8 * sizeof(OPJ_FLOAT32) / sizeof(__m128));
- }
-#else
- OPJ_UINT32 c;
- for (i = 0; i < end; ++i) {
- for (c = 0; c < NB_ELTS_V8; c++) {
- fw[i * 2 * NB_ELTS_V8 + c] *= cst;
- }
- }
-#endif
-}
-
-static void opj_v8dwt_encode_step2(OPJ_FLOAT32* fl, OPJ_FLOAT32* fw,
- OPJ_UINT32 end,
- OPJ_UINT32 m,
- OPJ_FLOAT32 cst)
-{
- OPJ_UINT32 i;
- OPJ_UINT32 imax = opj_uint_min(end, m);
-#ifdef __SSE__
- __m128* vw = (__m128*) fw;
- __m128 vcst = _mm_set1_ps(cst);
- if (imax > 0) {
- __m128* vl = (__m128*) fl;
- vw[-2] = _mm_add_ps(vw[-2], _mm_mul_ps(_mm_add_ps(vl[0], vw[0]), vcst));
- vw[-1] = _mm_add_ps(vw[-1], _mm_mul_ps(_mm_add_ps(vl[1], vw[1]), vcst));
- vw += 2 * (NB_ELTS_V8 * sizeof(OPJ_FLOAT32) / sizeof(__m128));
- i = 1;
-
- for (; i < imax; ++i) {
- vw[-2] = _mm_add_ps(vw[-2], _mm_mul_ps(_mm_add_ps(vw[-4], vw[0]), vcst));
- vw[-1] = _mm_add_ps(vw[-1], _mm_mul_ps(_mm_add_ps(vw[-3], vw[1]), vcst));
- vw += 2 * (NB_ELTS_V8 * sizeof(OPJ_FLOAT32) / sizeof(__m128));
- }
- }
- if (m < end) {
- assert(m + 1 == end);
- vcst = _mm_add_ps(vcst, vcst);
- vw[-2] = _mm_add_ps(vw[-2], _mm_mul_ps(vw[-4], vcst));
- vw[-1] = _mm_add_ps(vw[-1], _mm_mul_ps(vw[-3], vcst));
- }
-#else
- OPJ_INT32 c;
- if (imax > 0) {
- for (c = 0; c < NB_ELTS_V8; c++) {
- fw[-1 * NB_ELTS_V8 + c] += (fl[0 * NB_ELTS_V8 + c] + fw[0 * NB_ELTS_V8 + c]) *
- cst;
- }
- fw += 2 * NB_ELTS_V8;
- i = 1;
- for (; i < imax; ++i) {
- for (c = 0; c < NB_ELTS_V8; c++) {
- fw[-1 * NB_ELTS_V8 + c] += (fw[-2 * NB_ELTS_V8 + c] + fw[0 * NB_ELTS_V8 + c]) *
- cst;
- }
- fw += 2 * NB_ELTS_V8;
- }
- }
- if (m < end) {
- assert(m + 1 == end);
- for (c = 0; c < NB_ELTS_V8; c++) {
- fw[-1 * NB_ELTS_V8 + c] += (2 * fw[-2 * NB_ELTS_V8 + c]) * cst;
- }
- }
-#endif
-}
-
-/* Forward 9-7 transform, for the vertical pass, processing cols columns */
-/* where cols <= NB_ELTS_V8 */
-static void opj_dwt_encode_and_deinterleave_v_real(
- void *arrayIn,
- void *tmpIn,
- OPJ_UINT32 height,
- OPJ_BOOL even,
- OPJ_UINT32 stride_width,
- OPJ_UINT32 cols)
-{
- OPJ_FLOAT32* OPJ_RESTRICT array = (OPJ_FLOAT32 * OPJ_RESTRICT)arrayIn;
- OPJ_FLOAT32* OPJ_RESTRICT tmp = (OPJ_FLOAT32 * OPJ_RESTRICT)tmpIn;
- const OPJ_INT32 sn = (OPJ_INT32)((height + (even ? 1 : 0)) >> 1);
- const OPJ_INT32 dn = (OPJ_INT32)(height - (OPJ_UINT32)sn);
- OPJ_INT32 a, b;
-
- if (height == 1) {
- return;
- }
-
- opj_dwt_fetch_cols_vertical_pass(arrayIn, tmpIn, height, stride_width, cols);
-
- if (even) {
- a = 0;
- b = 1;
- } else {
- a = 1;
- b = 0;
- }
- opj_v8dwt_encode_step2(tmp + a * NB_ELTS_V8,
- tmp + (b + 1) * NB_ELTS_V8,
- (OPJ_UINT32)dn,
- (OPJ_UINT32)opj_int_min(dn, sn - b),
- opj_dwt_alpha);
- opj_v8dwt_encode_step2(tmp + b * NB_ELTS_V8,
- tmp + (a + 1) * NB_ELTS_V8,
- (OPJ_UINT32)sn,
- (OPJ_UINT32)opj_int_min(sn, dn - a),
- opj_dwt_beta);
- opj_v8dwt_encode_step2(tmp + a * NB_ELTS_V8,
- tmp + (b + 1) * NB_ELTS_V8,
- (OPJ_UINT32)dn,
- (OPJ_UINT32)opj_int_min(dn, sn - b),
- opj_dwt_gamma);
- opj_v8dwt_encode_step2(tmp + b * NB_ELTS_V8,
- tmp + (a + 1) * NB_ELTS_V8,
- (OPJ_UINT32)sn,
- (OPJ_UINT32)opj_int_min(sn, dn - a),
- opj_dwt_delta);
- opj_v8dwt_encode_step1(tmp + b * NB_ELTS_V8, (OPJ_UINT32)dn,
- opj_K);
- opj_v8dwt_encode_step1(tmp + a * NB_ELTS_V8, (OPJ_UINT32)sn,
- opj_invK);
-
-
- if (cols == NB_ELTS_V8) {
- opj_dwt_deinterleave_v_cols((OPJ_INT32*)tmp,
- (OPJ_INT32*)array,
- (OPJ_INT32)dn, (OPJ_INT32)sn,
- stride_width, even ? 0 : 1, NB_ELTS_V8);
- } else {
- opj_dwt_deinterleave_v_cols((OPJ_INT32*)tmp,
- (OPJ_INT32*)array,
- (OPJ_INT32)dn, (OPJ_INT32)sn,
- stride_width, even ? 0 : 1, cols);
- }
-}
-
-
-/* <summary> */
-/* Forward 5-3 wavelet transform in 2-D. */
-/* </summary> */
-static INLINE OPJ_BOOL opj_dwt_encode_procedure(opj_thread_pool_t* tp,
- opj_tcd_tilecomp_t * tilec,
- opj_encode_and_deinterleave_v_fnptr_type p_encode_and_deinterleave_v,
- opj_encode_and_deinterleave_h_one_row_fnptr_type
- p_encode_and_deinterleave_h_one_row)
-{
- OPJ_INT32 i;
- OPJ_INT32 *bj = 00;
- OPJ_UINT32 w;
- OPJ_INT32 l;
-
- OPJ_SIZE_T l_data_size;
-
- opj_tcd_resolution_t * l_cur_res = 0;
- opj_tcd_resolution_t * l_last_res = 0;
- const int num_threads = opj_thread_pool_get_thread_count(tp);
- OPJ_INT32 * OPJ_RESTRICT tiledp = tilec->data;
-
- w = (OPJ_UINT32)(tilec->x1 - tilec->x0);
- l = (OPJ_INT32)tilec->numresolutions - 1;
-
- l_cur_res = tilec->resolutions + l;
- l_last_res = l_cur_res - 1;
-
- l_data_size = opj_dwt_max_resolution(tilec->resolutions, tilec->numresolutions);
- /* overflow check */
- if (l_data_size > (SIZE_MAX / (NB_ELTS_V8 * sizeof(OPJ_INT32)))) {
- /* FIXME event manager error callback */
- return OPJ_FALSE;
- }
- l_data_size *= NB_ELTS_V8 * sizeof(OPJ_INT32);
- bj = (OPJ_INT32*)opj_aligned_32_malloc(l_data_size);
- /* l_data_size is equal to 0 when numresolutions == 1 but bj is not used */
- /* in that case, so do not error out */
- if (l_data_size != 0 && ! bj) {
- return OPJ_FALSE;
- }
- i = l;
-
- while (i--) {
- OPJ_UINT32 j;
- OPJ_UINT32 rw; /* width of the resolution level computed */
- OPJ_UINT32 rh; /* height of the resolution level computed */
- OPJ_UINT32
- rw1; /* width of the resolution level once lower than computed one */
- OPJ_UINT32
- rh1; /* height of the resolution level once lower than computed one */
- OPJ_INT32 cas_col; /* 0 = non inversion on horizontal filtering 1 = inversion between low-pass and high-pass filtering */
- OPJ_INT32 cas_row; /* 0 = non inversion on vertical filtering 1 = inversion between low-pass and high-pass filtering */
- OPJ_INT32 dn, sn;
-
- rw = (OPJ_UINT32)(l_cur_res->x1 - l_cur_res->x0);
- rh = (OPJ_UINT32)(l_cur_res->y1 - l_cur_res->y0);
- rw1 = (OPJ_UINT32)(l_last_res->x1 - l_last_res->x0);
- rh1 = (OPJ_UINT32)(l_last_res->y1 - l_last_res->y0);
-
- cas_row = l_cur_res->x0 & 1;
- cas_col = l_cur_res->y0 & 1;
-
- sn = (OPJ_INT32)rh1;
- dn = (OPJ_INT32)(rh - rh1);
-
- /* Perform vertical pass */
- if (num_threads <= 1 || rw < 2 * NB_ELTS_V8) {
- for (j = 0; j + NB_ELTS_V8 - 1 < rw; j += NB_ELTS_V8) {
- p_encode_and_deinterleave_v(tiledp + j,
- bj,
- rh,
- cas_col == 0,
- w,
- NB_ELTS_V8);
- }
- if (j < rw) {
- p_encode_and_deinterleave_v(tiledp + j,
- bj,
- rh,
- cas_col == 0,
- w,
- rw - j);
- }
- } else {
- OPJ_UINT32 num_jobs = (OPJ_UINT32)num_threads;
- OPJ_UINT32 step_j;
-
- if (rw < num_jobs) {
- num_jobs = rw;
- }
- step_j = ((rw / num_jobs) / NB_ELTS_V8) * NB_ELTS_V8;
-
- for (j = 0; j < num_jobs; j++) {
- opj_dwt_encode_v_job_t* job;
-
- job = (opj_dwt_encode_v_job_t*) opj_malloc(sizeof(opj_dwt_encode_v_job_t));
- if (!job) {
- opj_thread_pool_wait_completion(tp, 0);
- opj_aligned_free(bj);
- return OPJ_FALSE;
- }
- job->v.mem = (OPJ_INT32*)opj_aligned_32_malloc(l_data_size);
- if (!job->v.mem) {
- opj_thread_pool_wait_completion(tp, 0);
- opj_free(job);
- opj_aligned_free(bj);
- return OPJ_FALSE;
- }
- job->v.dn = dn;
- job->v.sn = sn;
- job->v.cas = cas_col;
- job->rh = rh;
- job->w = w;
- job->tiledp = tiledp;
- job->min_j = j * step_j;
- job->max_j = (j + 1 == num_jobs) ? rw : (j + 1) * step_j;
- job->p_encode_and_deinterleave_v = p_encode_and_deinterleave_v;
- opj_thread_pool_submit_job(tp, opj_dwt_encode_v_func, job);
- }
- opj_thread_pool_wait_completion(tp, 0);
- }
-
- sn = (OPJ_INT32)rw1;
- dn = (OPJ_INT32)(rw - rw1);
-
- /* Perform horizontal pass */
- if (num_threads <= 1 || rh <= 1) {
- for (j = 0; j < rh; j++) {
- OPJ_INT32* OPJ_RESTRICT aj = tiledp + j * w;
- (*p_encode_and_deinterleave_h_one_row)(aj, bj, rw,
- cas_row == 0 ? OPJ_TRUE : OPJ_FALSE);
- }
- } else {
- OPJ_UINT32 num_jobs = (OPJ_UINT32)num_threads;
- OPJ_UINT32 step_j;
-
- if (rh < num_jobs) {
- num_jobs = rh;
- }
- step_j = (rh / num_jobs);
-
- for (j = 0; j < num_jobs; j++) {
- opj_dwt_encode_h_job_t* job;
-
- job = (opj_dwt_encode_h_job_t*) opj_malloc(sizeof(opj_dwt_encode_h_job_t));
- if (!job) {
- opj_thread_pool_wait_completion(tp, 0);
- opj_aligned_free(bj);
- return OPJ_FALSE;
- }
- job->h.mem = (OPJ_INT32*)opj_aligned_32_malloc(l_data_size);
- if (!job->h.mem) {
- opj_thread_pool_wait_completion(tp, 0);
- opj_free(job);
- opj_aligned_free(bj);
- return OPJ_FALSE;
- }
- job->h.dn = dn;
- job->h.sn = sn;
- job->h.cas = cas_row;
- job->rw = rw;
- job->w = w;
- job->tiledp = tiledp;
- job->min_j = j * step_j;
- job->max_j = (j + 1U) * step_j; /* this can overflow */
- if (j == (num_jobs - 1U)) { /* this will take care of the overflow */
- job->max_j = rh;
- }
- job->p_function = p_encode_and_deinterleave_h_one_row;
- opj_thread_pool_submit_job(tp, opj_dwt_encode_h_func, job);
- }
- opj_thread_pool_wait_completion(tp, 0);
- }
-
- l_cur_res = l_last_res;
-
- --l_last_res;
- }
-
- opj_aligned_free(bj);
- return OPJ_TRUE;
-}
-
-/* Forward 5-3 wavelet transform in 2-D. */
-/* </summary> */
-OPJ_BOOL opj_dwt_encode(opj_tcd_t *p_tcd,
- opj_tcd_tilecomp_t * tilec)
-{
- return opj_dwt_encode_procedure(p_tcd->thread_pool, tilec,
- opj_dwt_encode_and_deinterleave_v,
- opj_dwt_encode_and_deinterleave_h_one_row);
-}
-
-/* <summary> */
-/* Inverse 5-3 wavelet transform in 2-D. */
-/* </summary> */
-OPJ_BOOL opj_dwt_decode(opj_tcd_t *p_tcd, opj_tcd_tilecomp_t* tilec,
- OPJ_UINT32 numres)
-{
- if (p_tcd->whole_tile_decoding) {
- return opj_dwt_decode_tile(p_tcd->thread_pool, tilec, numres);
- } else {
- return opj_dwt_decode_partial_tile(tilec, numres);
- }
-}
-
-/* <summary> */
-/* Get norm of 5-3 wavelet. */
-/* </summary> */
-OPJ_FLOAT64 opj_dwt_getnorm(OPJ_UINT32 level, OPJ_UINT32 orient)
-{
- /* FIXME ! This is just a band-aid to avoid a buffer overflow */
- /* but the array should really be extended up to 33 resolution levels */
- /* See https://github.com/uclouvain/openjpeg/issues/493 */
- if (orient == 0 && level >= 10) {
- level = 9;
- } else if (orient > 0 && level >= 9) {
- level = 8;
- }
- return opj_dwt_norms[orient][level];
-}
-
-/* <summary> */
-/* Forward 9-7 wavelet transform in 2-D. */
-/* </summary> */
-OPJ_BOOL opj_dwt_encode_real(opj_tcd_t *p_tcd,
- opj_tcd_tilecomp_t * tilec)
-{
- return opj_dwt_encode_procedure(p_tcd->thread_pool, tilec,
- opj_dwt_encode_and_deinterleave_v_real,
- opj_dwt_encode_and_deinterleave_h_one_row_real);
-}
-
-/* <summary> */
-/* Get norm of 9-7 wavelet. */
-/* </summary> */
-OPJ_FLOAT64 opj_dwt_getnorm_real(OPJ_UINT32 level, OPJ_UINT32 orient)
-{
- /* FIXME ! This is just a band-aid to avoid a buffer overflow */
- /* but the array should really be extended up to 33 resolution levels */
- /* See https://github.com/uclouvain/openjpeg/issues/493 */
- if (orient == 0 && level >= 10) {
- level = 9;
- } else if (orient > 0 && level >= 9) {
- level = 8;
- }
- return opj_dwt_norms_real[orient][level];
-}
-
-void opj_dwt_calc_explicit_stepsizes(opj_tccp_t * tccp, OPJ_UINT32 prec)
-{
- OPJ_UINT32 numbands, bandno;
- numbands = 3 * tccp->numresolutions - 2;
- for (bandno = 0; bandno < numbands; bandno++) {
- OPJ_FLOAT64 stepsize;
- OPJ_UINT32 resno, level, orient, gain;
-
- resno = (bandno == 0) ? 0 : ((bandno - 1) / 3 + 1);
- orient = (bandno == 0) ? 0 : ((bandno - 1) % 3 + 1);
- level = tccp->numresolutions - 1 - resno;
- gain = (tccp->qmfbid == 0) ? 0 : ((orient == 0) ? 0 : (((orient == 1) ||
- (orient == 2)) ? 1 : 2));
- if (tccp->qntsty == J2K_CCP_QNTSTY_NOQNT) {
- stepsize = 1.0;
- } else {
- OPJ_FLOAT64 norm = opj_dwt_getnorm_real(level, orient);
- stepsize = (1 << (gain)) / norm;
- }
- opj_dwt_encode_stepsize((OPJ_INT32) floor(stepsize * 8192.0),
- (OPJ_INT32)(prec + gain), &tccp->stepsizes[bandno]);
- }
-}
-
-/* <summary> */
-/* Determine maximum computed resolution level for inverse wavelet transform */
-/* </summary> */
-static OPJ_UINT32 opj_dwt_max_resolution(opj_tcd_resolution_t* OPJ_RESTRICT r,
- OPJ_UINT32 i)
-{
- OPJ_UINT32 mr = 0;
- OPJ_UINT32 w;
- while (--i) {
- ++r;
- if (mr < (w = (OPJ_UINT32)(r->x1 - r->x0))) {
- mr = w ;
- }
- if (mr < (w = (OPJ_UINT32)(r->y1 - r->y0))) {
- mr = w ;
- }
- }
- return mr ;
-}
-
-typedef struct {
- opj_dwt_t h;
- OPJ_UINT32 rw;
- OPJ_UINT32 w;
- OPJ_INT32 * OPJ_RESTRICT tiledp;
- OPJ_UINT32 min_j;
- OPJ_UINT32 max_j;
-} opj_dwt_decode_h_job_t;
-
-static void opj_dwt_decode_h_func(void* user_data, opj_tls_t* tls)
-{
- OPJ_UINT32 j;
- opj_dwt_decode_h_job_t* job;
- (void)tls;
-
- job = (opj_dwt_decode_h_job_t*)user_data;
- for (j = job->min_j; j < job->max_j; j++) {
- opj_idwt53_h(&job->h, &job->tiledp[j * job->w]);
- }
-
- opj_aligned_free(job->h.mem);
- opj_free(job);
-}
-
-typedef struct {
- opj_dwt_t v;
- OPJ_UINT32 rh;
- OPJ_UINT32 w;
- OPJ_INT32 * OPJ_RESTRICT tiledp;
- OPJ_UINT32 min_j;
- OPJ_UINT32 max_j;
-} opj_dwt_decode_v_job_t;
-
-static void opj_dwt_decode_v_func(void* user_data, opj_tls_t* tls)
-{
- OPJ_UINT32 j;
- opj_dwt_decode_v_job_t* job;
- (void)tls;
-
- job = (opj_dwt_decode_v_job_t*)user_data;
- for (j = job->min_j; j + PARALLEL_COLS_53 <= job->max_j;
- j += PARALLEL_COLS_53) {
- opj_idwt53_v(&job->v, &job->tiledp[j], (OPJ_SIZE_T)job->w,
- PARALLEL_COLS_53);
- }
- if (j < job->max_j)
- opj_idwt53_v(&job->v, &job->tiledp[j], (OPJ_SIZE_T)job->w,
- (OPJ_INT32)(job->max_j - j));
-
- opj_aligned_free(job->v.mem);
- opj_free(job);
-}
-
-
-/* <summary> */
-/* Inverse wavelet transform in 2-D. */
-/* </summary> */
-static OPJ_BOOL opj_dwt_decode_tile(opj_thread_pool_t* tp,
- opj_tcd_tilecomp_t* tilec, OPJ_UINT32 numres)
-{
- opj_dwt_t h;
- opj_dwt_t v;
-
- opj_tcd_resolution_t* tr = tilec->resolutions;
-
- OPJ_UINT32 rw = (OPJ_UINT32)(tr->x1 -
- tr->x0); /* width of the resolution level computed */
- OPJ_UINT32 rh = (OPJ_UINT32)(tr->y1 -
- tr->y0); /* height of the resolution level computed */
-
- OPJ_UINT32 w = (OPJ_UINT32)(tilec->resolutions[tilec->minimum_num_resolutions -
- 1].x1 -
- tilec->resolutions[tilec->minimum_num_resolutions - 1].x0);
- OPJ_SIZE_T h_mem_size;
- int num_threads;
-
- /* Not entirely sure for the return code of w == 0 which is triggered per */
- /* https://github.com/uclouvain/openjpeg/issues/1505 */
- if (numres == 1U || w == 0) {
- return OPJ_TRUE;
- }
- num_threads = opj_thread_pool_get_thread_count(tp);
- h_mem_size = opj_dwt_max_resolution(tr, numres);
- /* overflow check */
- if (h_mem_size > (SIZE_MAX / PARALLEL_COLS_53 / sizeof(OPJ_INT32))) {
- /* FIXME event manager error callback */
- return OPJ_FALSE;
- }
- /* We need PARALLEL_COLS_53 times the height of the array, */
- /* since for the vertical pass */
- /* we process PARALLEL_COLS_53 columns at a time */
- h_mem_size *= PARALLEL_COLS_53 * sizeof(OPJ_INT32);
- h.mem = (OPJ_INT32*)opj_aligned_32_malloc(h_mem_size);
- if (! h.mem) {
- /* FIXME event manager error callback */
- return OPJ_FALSE;
- }
-
- v.mem = h.mem;
-
- while (--numres) {
- OPJ_INT32 * OPJ_RESTRICT tiledp = tilec->data;
- OPJ_UINT32 j;
-
- ++tr;
- h.sn = (OPJ_INT32)rw;
- v.sn = (OPJ_INT32)rh;
-
- rw = (OPJ_UINT32)(tr->x1 - tr->x0);
- rh = (OPJ_UINT32)(tr->y1 - tr->y0);
-
- h.dn = (OPJ_INT32)(rw - (OPJ_UINT32)h.sn);
- h.cas = tr->x0 % 2;
-
- if (num_threads <= 1 || rh <= 1) {
- for (j = 0; j < rh; ++j) {
- opj_idwt53_h(&h, &tiledp[(OPJ_SIZE_T)j * w]);
- }
- } else {
- OPJ_UINT32 num_jobs = (OPJ_UINT32)num_threads;
- OPJ_UINT32 step_j;
-
- if (rh < num_jobs) {
- num_jobs = rh;
- }
- step_j = (rh / num_jobs);
-
- for (j = 0; j < num_jobs; j++) {
- opj_dwt_decode_h_job_t* job;
-
- job = (opj_dwt_decode_h_job_t*) opj_malloc(sizeof(opj_dwt_decode_h_job_t));
- if (!job) {
- /* It would be nice to fallback to single thread case, but */
- /* unfortunately some jobs may be launched and have modified */
- /* tiledp, so it is not practical to recover from that error */
- /* FIXME event manager error callback */
- opj_thread_pool_wait_completion(tp, 0);
- opj_aligned_free(h.mem);
- return OPJ_FALSE;
- }
- job->h = h;
- job->rw = rw;
- job->w = w;
- job->tiledp = tiledp;
- job->min_j = j * step_j;
- job->max_j = (j + 1U) * step_j; /* this can overflow */
- if (j == (num_jobs - 1U)) { /* this will take care of the overflow */
- job->max_j = rh;
- }
- job->h.mem = (OPJ_INT32*)opj_aligned_32_malloc(h_mem_size);
- if (!job->h.mem) {
- /* FIXME event manager error callback */
- opj_thread_pool_wait_completion(tp, 0);
- opj_free(job);
- opj_aligned_free(h.mem);
- return OPJ_FALSE;
- }
- opj_thread_pool_submit_job(tp, opj_dwt_decode_h_func, job);
- }
- opj_thread_pool_wait_completion(tp, 0);
- }
-
- v.dn = (OPJ_INT32)(rh - (OPJ_UINT32)v.sn);
- v.cas = tr->y0 % 2;
-
- if (num_threads <= 1 || rw <= 1) {
- for (j = 0; j + PARALLEL_COLS_53 <= rw;
- j += PARALLEL_COLS_53) {
- opj_idwt53_v(&v, &tiledp[j], (OPJ_SIZE_T)w, PARALLEL_COLS_53);
- }
- if (j < rw) {
- opj_idwt53_v(&v, &tiledp[j], (OPJ_SIZE_T)w, (OPJ_INT32)(rw - j));
- }
- } else {
- OPJ_UINT32 num_jobs = (OPJ_UINT32)num_threads;
- OPJ_UINT32 step_j;
-
- if (rw < num_jobs) {
- num_jobs = rw;
- }
- step_j = (rw / num_jobs);
-
- for (j = 0; j < num_jobs; j++) {
- opj_dwt_decode_v_job_t* job;
-
- job = (opj_dwt_decode_v_job_t*) opj_malloc(sizeof(opj_dwt_decode_v_job_t));
- if (!job) {
- /* It would be nice to fallback to single thread case, but */
- /* unfortunately some jobs may be launched and have modified */
- /* tiledp, so it is not practical to recover from that error */
- /* FIXME event manager error callback */
- opj_thread_pool_wait_completion(tp, 0);
- opj_aligned_free(v.mem);
- return OPJ_FALSE;
- }
- job->v = v;
- job->rh = rh;
- job->w = w;
- job->tiledp = tiledp;
- job->min_j = j * step_j;
- job->max_j = (j + 1U) * step_j; /* this can overflow */
- if (j == (num_jobs - 1U)) { /* this will take care of the overflow */
- job->max_j = rw;
- }
- job->v.mem = (OPJ_INT32*)opj_aligned_32_malloc(h_mem_size);
- if (!job->v.mem) {
- /* FIXME event manager error callback */
- opj_thread_pool_wait_completion(tp, 0);
- opj_free(job);
- opj_aligned_free(v.mem);
- return OPJ_FALSE;
- }
- opj_thread_pool_submit_job(tp, opj_dwt_decode_v_func, job);
- }
- opj_thread_pool_wait_completion(tp, 0);
- }
- }
- opj_aligned_free(h.mem);
- return OPJ_TRUE;
-}
-
-static void opj_dwt_interleave_partial_h(OPJ_INT32 *dest,
- OPJ_INT32 cas,
- opj_sparse_array_int32_t* sa,
- OPJ_UINT32 sa_line,
- OPJ_UINT32 sn,
- OPJ_UINT32 win_l_x0,
- OPJ_UINT32 win_l_x1,
- OPJ_UINT32 win_h_x0,
- OPJ_UINT32 win_h_x1)
-{
- OPJ_BOOL ret;
- ret = opj_sparse_array_int32_read(sa,
- win_l_x0, sa_line,
- win_l_x1, sa_line + 1,
- dest + cas + 2 * win_l_x0,
- 2, 0, OPJ_TRUE);
- assert(ret);
- ret = opj_sparse_array_int32_read(sa,
- sn + win_h_x0, sa_line,
- sn + win_h_x1, sa_line + 1,
- dest + 1 - cas + 2 * win_h_x0,
- 2, 0, OPJ_TRUE);
- assert(ret);
- OPJ_UNUSED(ret);
-}
-
-
-static void opj_dwt_interleave_partial_v(OPJ_INT32 *dest,
- OPJ_INT32 cas,
- opj_sparse_array_int32_t* sa,
- OPJ_UINT32 sa_col,
- OPJ_UINT32 nb_cols,
- OPJ_UINT32 sn,
- OPJ_UINT32 win_l_y0,
- OPJ_UINT32 win_l_y1,
- OPJ_UINT32 win_h_y0,
- OPJ_UINT32 win_h_y1)
-{
- OPJ_BOOL ret;
- ret = opj_sparse_array_int32_read(sa,
- sa_col, win_l_y0,
- sa_col + nb_cols, win_l_y1,
- dest + cas * 4 + 2 * 4 * win_l_y0,
- 1, 2 * 4, OPJ_TRUE);
- assert(ret);
- ret = opj_sparse_array_int32_read(sa,
- sa_col, sn + win_h_y0,
- sa_col + nb_cols, sn + win_h_y1,
- dest + (1 - cas) * 4 + 2 * 4 * win_h_y0,
- 1, 2 * 4, OPJ_TRUE);
- assert(ret);
- OPJ_UNUSED(ret);
-}
-
-static void opj_dwt_decode_partial_1(OPJ_INT32 *a, OPJ_INT32 dn, OPJ_INT32 sn,
- OPJ_INT32 cas,
- OPJ_INT32 win_l_x0,
- OPJ_INT32 win_l_x1,
- OPJ_INT32 win_h_x0,
- OPJ_INT32 win_h_x1)
-{
- OPJ_INT32 i;
-
- if (!cas) {
- if ((dn > 0) || (sn > 1)) { /* NEW : CASE ONE ELEMENT */
-
- /* Naive version is :
- for (i = win_l_x0; i < i_max; i++) {
- OPJ_S(i) -= (OPJ_D_(i - 1) + OPJ_D_(i) + 2) >> 2;
- }
- for (i = win_h_x0; i < win_h_x1; i++) {
- OPJ_D(i) += (OPJ_S_(i) + OPJ_S_(i + 1)) >> 1;
- }
- but the compiler doesn't manage to unroll it to avoid bound
- checking in OPJ_S_ and OPJ_D_ macros
- */
-
- i = win_l_x0;
- if (i < win_l_x1) {
- OPJ_INT32 i_max;
-
- /* Left-most case */
- OPJ_S(i) -= (OPJ_D_(i - 1) + OPJ_D_(i) + 2) >> 2;
- i ++;
-
- i_max = win_l_x1;
- if (i_max > dn) {
- i_max = dn;
- }
- for (; i < i_max; i++) {
- /* No bound checking */
- OPJ_S(i) -= (OPJ_D(i - 1) + OPJ_D(i) + 2) >> 2;
- }
- for (; i < win_l_x1; i++) {
- /* Right-most case */
- OPJ_S(i) -= (OPJ_D_(i - 1) + OPJ_D_(i) + 2) >> 2;
- }
- }
-
- i = win_h_x0;
- if (i < win_h_x1) {
- OPJ_INT32 i_max = win_h_x1;
- if (i_max >= sn) {
- i_max = sn - 1;
- }
- for (; i < i_max; i++) {
- /* No bound checking */
- OPJ_D(i) += (OPJ_S(i) + OPJ_S(i + 1)) >> 1;
- }
- for (; i < win_h_x1; i++) {
- /* Right-most case */
- OPJ_D(i) += (OPJ_S_(i) + OPJ_S_(i + 1)) >> 1;
- }
- }
- }
- } else {
- if (!sn && dn == 1) { /* NEW : CASE ONE ELEMENT */
- OPJ_S(0) /= 2;
- } else {
- for (i = win_l_x0; i < win_l_x1; i++) {
- OPJ_D(i) = opj_int_sub_no_overflow(OPJ_D(i),
- opj_int_add_no_overflow(opj_int_add_no_overflow(OPJ_SS_(i), OPJ_SS_(i + 1)),
- 2) >> 2);
- }
- for (i = win_h_x0; i < win_h_x1; i++) {
- OPJ_S(i) = opj_int_add_no_overflow(OPJ_S(i),
- opj_int_add_no_overflow(OPJ_DD_(i), OPJ_DD_(i - 1)) >> 1);
- }
- }
- }
-}
-
-#define OPJ_S_off(i,off) a[(OPJ_UINT32)(i)*2*4+off]
-#define OPJ_D_off(i,off) a[(1+(OPJ_UINT32)(i)*2)*4+off]
-#define OPJ_S__off(i,off) ((i)<0?OPJ_S_off(0,off):((i)>=sn?OPJ_S_off(sn-1,off):OPJ_S_off(i,off)))
-#define OPJ_D__off(i,off) ((i)<0?OPJ_D_off(0,off):((i)>=dn?OPJ_D_off(dn-1,off):OPJ_D_off(i,off)))
-#define OPJ_SS__off(i,off) ((i)<0?OPJ_S_off(0,off):((i)>=dn?OPJ_S_off(dn-1,off):OPJ_S_off(i,off)))
-#define OPJ_DD__off(i,off) ((i)<0?OPJ_D_off(0,off):((i)>=sn?OPJ_D_off(sn-1,off):OPJ_D_off(i,off)))
-
-static void opj_dwt_decode_partial_1_parallel(OPJ_INT32 *a,
- OPJ_UINT32 nb_cols,
- OPJ_INT32 dn, OPJ_INT32 sn,
- OPJ_INT32 cas,
- OPJ_INT32 win_l_x0,
- OPJ_INT32 win_l_x1,
- OPJ_INT32 win_h_x0,
- OPJ_INT32 win_h_x1)
-{
- OPJ_INT32 i;
- OPJ_UINT32 off;
-
- (void)nb_cols;
-
- if (!cas) {
- if ((dn > 0) || (sn > 1)) { /* NEW : CASE ONE ELEMENT */
-
- /* Naive version is :
- for (i = win_l_x0; i < i_max; i++) {
- OPJ_S(i) -= (OPJ_D_(i - 1) + OPJ_D_(i) + 2) >> 2;
- }
- for (i = win_h_x0; i < win_h_x1; i++) {
- OPJ_D(i) += (OPJ_S_(i) + OPJ_S_(i + 1)) >> 1;
- }
- but the compiler doesn't manage to unroll it to avoid bound
- checking in OPJ_S_ and OPJ_D_ macros
- */
-
- i = win_l_x0;
- if (i < win_l_x1) {
- OPJ_INT32 i_max;
-
- /* Left-most case */
- for (off = 0; off < 4; off++) {
- OPJ_S_off(i, off) -= (OPJ_D__off(i - 1, off) + OPJ_D__off(i, off) + 2) >> 2;
- }
- i ++;
-
- i_max = win_l_x1;
- if (i_max > dn) {
- i_max = dn;
- }
-
-#ifdef __SSE2__
- if (i + 1 < i_max) {
- const __m128i two = _mm_set1_epi32(2);
- __m128i Dm1 = _mm_load_si128((__m128i * const)(a + 4 + (i - 1) * 8));
- for (; i + 1 < i_max; i += 2) {
- /* No bound checking */
- __m128i S = _mm_load_si128((__m128i * const)(a + i * 8));
- __m128i D = _mm_load_si128((__m128i * const)(a + 4 + i * 8));
- __m128i S1 = _mm_load_si128((__m128i * const)(a + (i + 1) * 8));
- __m128i D1 = _mm_load_si128((__m128i * const)(a + 4 + (i + 1) * 8));
- S = _mm_sub_epi32(S,
- _mm_srai_epi32(_mm_add_epi32(_mm_add_epi32(Dm1, D), two), 2));
- S1 = _mm_sub_epi32(S1,
- _mm_srai_epi32(_mm_add_epi32(_mm_add_epi32(D, D1), two), 2));
- _mm_store_si128((__m128i*)(a + i * 8), S);
- _mm_store_si128((__m128i*)(a + (i + 1) * 8), S1);
- Dm1 = D1;
- }
- }
-#endif
-
- for (; i < i_max; i++) {
- /* No bound checking */
- for (off = 0; off < 4; off++) {
- OPJ_S_off(i, off) -= (OPJ_D_off(i - 1, off) + OPJ_D_off(i, off) + 2) >> 2;
- }
- }
- for (; i < win_l_x1; i++) {
- /* Right-most case */
- for (off = 0; off < 4; off++) {
- OPJ_S_off(i, off) -= (OPJ_D__off(i - 1, off) + OPJ_D__off(i, off) + 2) >> 2;
- }
- }
- }
-
- i = win_h_x0;
- if (i < win_h_x1) {
- OPJ_INT32 i_max = win_h_x1;
- if (i_max >= sn) {
- i_max = sn - 1;
- }
-
-#ifdef __SSE2__
- if (i + 1 < i_max) {
- __m128i S = _mm_load_si128((__m128i * const)(a + i * 8));
- for (; i + 1 < i_max; i += 2) {
- /* No bound checking */
- __m128i D = _mm_load_si128((__m128i * const)(a + 4 + i * 8));
- __m128i S1 = _mm_load_si128((__m128i * const)(a + (i + 1) * 8));
- __m128i D1 = _mm_load_si128((__m128i * const)(a + 4 + (i + 1) * 8));
- __m128i S2 = _mm_load_si128((__m128i * const)(a + (i + 2) * 8));
- D = _mm_add_epi32(D, _mm_srai_epi32(_mm_add_epi32(S, S1), 1));
- D1 = _mm_add_epi32(D1, _mm_srai_epi32(_mm_add_epi32(S1, S2), 1));
- _mm_store_si128((__m128i*)(a + 4 + i * 8), D);
- _mm_store_si128((__m128i*)(a + 4 + (i + 1) * 8), D1);
- S = S2;
- }
- }
-#endif
-
- for (; i < i_max; i++) {
- /* No bound checking */
- for (off = 0; off < 4; off++) {
- OPJ_D_off(i, off) += (OPJ_S_off(i, off) + OPJ_S_off(i + 1, off)) >> 1;
- }
- }
- for (; i < win_h_x1; i++) {
- /* Right-most case */
- for (off = 0; off < 4; off++) {
- OPJ_D_off(i, off) += (OPJ_S__off(i, off) + OPJ_S__off(i + 1, off)) >> 1;
- }
- }
- }
- }
- } else {
- if (!sn && dn == 1) { /* NEW : CASE ONE ELEMENT */
- for (off = 0; off < 4; off++) {
- OPJ_S_off(0, off) /= 2;
- }
- } else {
- for (i = win_l_x0; i < win_l_x1; i++) {
- for (off = 0; off < 4; off++) {
- OPJ_D_off(i, off) = opj_int_sub_no_overflow(
- OPJ_D_off(i, off),
- opj_int_add_no_overflow(
- opj_int_add_no_overflow(OPJ_SS__off(i, off), OPJ_SS__off(i + 1, off)), 2) >> 2);
- }
- }
- for (i = win_h_x0; i < win_h_x1; i++) {
- for (off = 0; off < 4; off++) {
- OPJ_S_off(i, off) = opj_int_add_no_overflow(
- OPJ_S_off(i, off),
- opj_int_add_no_overflow(OPJ_DD__off(i, off), OPJ_DD__off(i - 1, off)) >> 1);
- }
- }
- }
- }
-}
-
-static void opj_dwt_get_band_coordinates(opj_tcd_tilecomp_t* tilec,
- OPJ_UINT32 resno,
- OPJ_UINT32 bandno,
- OPJ_UINT32 tcx0,
- OPJ_UINT32 tcy0,
- OPJ_UINT32 tcx1,
- OPJ_UINT32 tcy1,
- OPJ_UINT32* tbx0,
- OPJ_UINT32* tby0,
- OPJ_UINT32* tbx1,
- OPJ_UINT32* tby1)
-{
- /* Compute number of decomposition for this band. See table F-1 */
- OPJ_UINT32 nb = (resno == 0) ?
- tilec->numresolutions - 1 :
- tilec->numresolutions - resno;
- /* Map above tile-based coordinates to sub-band-based coordinates per */
- /* equation B-15 of the standard */
- OPJ_UINT32 x0b = bandno & 1;
- OPJ_UINT32 y0b = bandno >> 1;
- if (tbx0) {
- *tbx0 = (nb == 0) ? tcx0 :
- (tcx0 <= (1U << (nb - 1)) * x0b) ? 0 :
- opj_uint_ceildivpow2(tcx0 - (1U << (nb - 1)) * x0b, nb);
- }
- if (tby0) {
- *tby0 = (nb == 0) ? tcy0 :
- (tcy0 <= (1U << (nb - 1)) * y0b) ? 0 :
- opj_uint_ceildivpow2(tcy0 - (1U << (nb - 1)) * y0b, nb);
- }
- if (tbx1) {
- *tbx1 = (nb == 0) ? tcx1 :
- (tcx1 <= (1U << (nb - 1)) * x0b) ? 0 :
- opj_uint_ceildivpow2(tcx1 - (1U << (nb - 1)) * x0b, nb);
- }
- if (tby1) {
- *tby1 = (nb == 0) ? tcy1 :
- (tcy1 <= (1U << (nb - 1)) * y0b) ? 0 :
- opj_uint_ceildivpow2(tcy1 - (1U << (nb - 1)) * y0b, nb);
- }
-}
-
-static void opj_dwt_segment_grow(OPJ_UINT32 filter_width,
- OPJ_UINT32 max_size,
- OPJ_UINT32* start,
- OPJ_UINT32* end)
-{
- *start = opj_uint_subs(*start, filter_width);
- *end = opj_uint_adds(*end, filter_width);
- *end = opj_uint_min(*end, max_size);
-}
-
-
-static opj_sparse_array_int32_t* opj_dwt_init_sparse_array(
- opj_tcd_tilecomp_t* tilec,
- OPJ_UINT32 numres)
-{
- opj_tcd_resolution_t* tr_max = &(tilec->resolutions[numres - 1]);
- OPJ_UINT32 w = (OPJ_UINT32)(tr_max->x1 - tr_max->x0);
- OPJ_UINT32 h = (OPJ_UINT32)(tr_max->y1 - tr_max->y0);
- OPJ_UINT32 resno, bandno, precno, cblkno;
- opj_sparse_array_int32_t* sa = opj_sparse_array_int32_create(
- w, h, opj_uint_min(w, 64), opj_uint_min(h, 64));
- if (sa == NULL) {
- return NULL;
- }
-
- for (resno = 0; resno < numres; ++resno) {
- opj_tcd_resolution_t* res = &tilec->resolutions[resno];
-
- for (bandno = 0; bandno < res->numbands; ++bandno) {
- opj_tcd_band_t* band = &res->bands[bandno];
-
- for (precno = 0; precno < res->pw * res->ph; ++precno) {
- opj_tcd_precinct_t* precinct = &band->precincts[precno];
- for (cblkno = 0; cblkno < precinct->cw * precinct->ch; ++cblkno) {
- opj_tcd_cblk_dec_t* cblk = &precinct->cblks.dec[cblkno];
- if (cblk->decoded_data != NULL) {
- OPJ_UINT32 x = (OPJ_UINT32)(cblk->x0 - band->x0);
- OPJ_UINT32 y = (OPJ_UINT32)(cblk->y0 - band->y0);
- OPJ_UINT32 cblk_w = (OPJ_UINT32)(cblk->x1 - cblk->x0);
- OPJ_UINT32 cblk_h = (OPJ_UINT32)(cblk->y1 - cblk->y0);
-
- if (band->bandno & 1) {
- opj_tcd_resolution_t* pres = &tilec->resolutions[resno - 1];
- x += (OPJ_UINT32)(pres->x1 - pres->x0);
- }
- if (band->bandno & 2) {
- opj_tcd_resolution_t* pres = &tilec->resolutions[resno - 1];
- y += (OPJ_UINT32)(pres->y1 - pres->y0);
- }
-
- if (!opj_sparse_array_int32_write(sa, x, y,
- x + cblk_w, y + cblk_h,
- cblk->decoded_data,
- 1, cblk_w, OPJ_TRUE)) {
- opj_sparse_array_int32_free(sa);
- return NULL;
- }
- }
- }
- }
- }
- }
-
- return sa;
-}
-
-
-static OPJ_BOOL opj_dwt_decode_partial_tile(
- opj_tcd_tilecomp_t* tilec,
- OPJ_UINT32 numres)
-{
- opj_sparse_array_int32_t* sa;
- opj_dwt_t h;
- opj_dwt_t v;
- OPJ_UINT32 resno;
- /* This value matches the maximum left/right extension given in tables */
- /* F.2 and F.3 of the standard. */
- const OPJ_UINT32 filter_width = 2U;
-
- opj_tcd_resolution_t* tr = tilec->resolutions;
- opj_tcd_resolution_t* tr_max = &(tilec->resolutions[numres - 1]);
-
- OPJ_UINT32 rw = (OPJ_UINT32)(tr->x1 -
- tr->x0); /* width of the resolution level computed */
- OPJ_UINT32 rh = (OPJ_UINT32)(tr->y1 -
- tr->y0); /* height of the resolution level computed */
-
- OPJ_SIZE_T h_mem_size;
-
- /* Compute the intersection of the area of interest, expressed in tile coordinates */
- /* with the tile coordinates */
- OPJ_UINT32 win_tcx0 = tilec->win_x0;
- OPJ_UINT32 win_tcy0 = tilec->win_y0;
- OPJ_UINT32 win_tcx1 = tilec->win_x1;
- OPJ_UINT32 win_tcy1 = tilec->win_y1;
-
- if (tr_max->x0 == tr_max->x1 || tr_max->y0 == tr_max->y1) {
- return OPJ_TRUE;
- }
-
- sa = opj_dwt_init_sparse_array(tilec, numres);
- if (sa == NULL) {
- return OPJ_FALSE;
- }
-
- if (numres == 1U) {
- OPJ_BOOL ret = opj_sparse_array_int32_read(sa,
- tr_max->win_x0 - (OPJ_UINT32)tr_max->x0,
- tr_max->win_y0 - (OPJ_UINT32)tr_max->y0,
- tr_max->win_x1 - (OPJ_UINT32)tr_max->x0,
- tr_max->win_y1 - (OPJ_UINT32)tr_max->y0,
- tilec->data_win,
- 1, tr_max->win_x1 - tr_max->win_x0,
- OPJ_TRUE);
- assert(ret);
- OPJ_UNUSED(ret);
- opj_sparse_array_int32_free(sa);
- return OPJ_TRUE;
- }
- h_mem_size = opj_dwt_max_resolution(tr, numres);
- /* overflow check */
- /* in vertical pass, we process 4 columns at a time */
- if (h_mem_size > (SIZE_MAX / (4 * sizeof(OPJ_INT32)))) {
- /* FIXME event manager error callback */
- opj_sparse_array_int32_free(sa);
- return OPJ_FALSE;
- }
-
- h_mem_size *= 4 * sizeof(OPJ_INT32);
- h.mem = (OPJ_INT32*)opj_aligned_32_malloc(h_mem_size);
- if (! h.mem) {
- /* FIXME event manager error callback */
- opj_sparse_array_int32_free(sa);
- return OPJ_FALSE;
- }
-
- v.mem = h.mem;
-
- for (resno = 1; resno < numres; resno ++) {
- OPJ_UINT32 i, j;
- /* Window of interest subband-based coordinates */
- OPJ_UINT32 win_ll_x0, win_ll_y0, win_ll_x1, win_ll_y1;
- OPJ_UINT32 win_hl_x0, win_hl_x1;
- OPJ_UINT32 win_lh_y0, win_lh_y1;
- /* Window of interest tile-resolution-based coordinates */
- OPJ_UINT32 win_tr_x0, win_tr_x1, win_tr_y0, win_tr_y1;
- /* Tile-resolution subband-based coordinates */
- OPJ_UINT32 tr_ll_x0, tr_ll_y0, tr_hl_x0, tr_lh_y0;
-
- ++tr;
-
- h.sn = (OPJ_INT32)rw;
- v.sn = (OPJ_INT32)rh;
-
- rw = (OPJ_UINT32)(tr->x1 - tr->x0);
- rh = (OPJ_UINT32)(tr->y1 - tr->y0);
-
- h.dn = (OPJ_INT32)(rw - (OPJ_UINT32)h.sn);
- h.cas = tr->x0 % 2;
-
- v.dn = (OPJ_INT32)(rh - (OPJ_UINT32)v.sn);
- v.cas = tr->y0 % 2;
-
- /* Get the subband coordinates for the window of interest */
- /* LL band */
- opj_dwt_get_band_coordinates(tilec, resno, 0,
- win_tcx0, win_tcy0, win_tcx1, win_tcy1,
- &win_ll_x0, &win_ll_y0,
- &win_ll_x1, &win_ll_y1);
-
- /* HL band */
- opj_dwt_get_band_coordinates(tilec, resno, 1,
- win_tcx0, win_tcy0, win_tcx1, win_tcy1,
- &win_hl_x0, NULL, &win_hl_x1, NULL);
-
- /* LH band */
- opj_dwt_get_band_coordinates(tilec, resno, 2,
- win_tcx0, win_tcy0, win_tcx1, win_tcy1,
- NULL, &win_lh_y0, NULL, &win_lh_y1);
-
- /* Beware: band index for non-LL0 resolution are 0=HL, 1=LH and 2=HH */
- tr_ll_x0 = (OPJ_UINT32)tr->bands[1].x0;
- tr_ll_y0 = (OPJ_UINT32)tr->bands[0].y0;
- tr_hl_x0 = (OPJ_UINT32)tr->bands[0].x0;
- tr_lh_y0 = (OPJ_UINT32)tr->bands[1].y0;
-
- /* Subtract the origin of the bands for this tile, to the subwindow */
- /* of interest band coordinates, so as to get them relative to the */
- /* tile */
- win_ll_x0 = opj_uint_subs(win_ll_x0, tr_ll_x0);
- win_ll_y0 = opj_uint_subs(win_ll_y0, tr_ll_y0);
- win_ll_x1 = opj_uint_subs(win_ll_x1, tr_ll_x0);
- win_ll_y1 = opj_uint_subs(win_ll_y1, tr_ll_y0);
- win_hl_x0 = opj_uint_subs(win_hl_x0, tr_hl_x0);
- win_hl_x1 = opj_uint_subs(win_hl_x1, tr_hl_x0);
- win_lh_y0 = opj_uint_subs(win_lh_y0, tr_lh_y0);
- win_lh_y1 = opj_uint_subs(win_lh_y1, tr_lh_y0);
-
- opj_dwt_segment_grow(filter_width, (OPJ_UINT32)h.sn, &win_ll_x0, &win_ll_x1);
- opj_dwt_segment_grow(filter_width, (OPJ_UINT32)h.dn, &win_hl_x0, &win_hl_x1);
-
- opj_dwt_segment_grow(filter_width, (OPJ_UINT32)v.sn, &win_ll_y0, &win_ll_y1);
- opj_dwt_segment_grow(filter_width, (OPJ_UINT32)v.dn, &win_lh_y0, &win_lh_y1);
-
- /* Compute the tile-resolution-based coordinates for the window of interest */
- if (h.cas == 0) {
- win_tr_x0 = opj_uint_min(2 * win_ll_x0, 2 * win_hl_x0 + 1);
- win_tr_x1 = opj_uint_min(opj_uint_max(2 * win_ll_x1, 2 * win_hl_x1 + 1), rw);
- } else {
- win_tr_x0 = opj_uint_min(2 * win_hl_x0, 2 * win_ll_x0 + 1);
- win_tr_x1 = opj_uint_min(opj_uint_max(2 * win_hl_x1, 2 * win_ll_x1 + 1), rw);
- }
-
- if (v.cas == 0) {
- win_tr_y0 = opj_uint_min(2 * win_ll_y0, 2 * win_lh_y0 + 1);
- win_tr_y1 = opj_uint_min(opj_uint_max(2 * win_ll_y1, 2 * win_lh_y1 + 1), rh);
- } else {
- win_tr_y0 = opj_uint_min(2 * win_lh_y0, 2 * win_ll_y0 + 1);
- win_tr_y1 = opj_uint_min(opj_uint_max(2 * win_lh_y1, 2 * win_ll_y1 + 1), rh);
- }
-
- for (j = 0; j < rh; ++j) {
- if ((j >= win_ll_y0 && j < win_ll_y1) ||
- (j >= win_lh_y0 + (OPJ_UINT32)v.sn && j < win_lh_y1 + (OPJ_UINT32)v.sn)) {
-
- /* Avoids dwt.c:1584:44 (in opj_dwt_decode_partial_1): runtime error: */
- /* signed integer overflow: -1094795586 + -1094795586 cannot be represented in type 'int' */
- /* on opj_decompress -i ../../openjpeg/MAPA.jp2 -o out.tif -d 0,0,256,256 */
- /* This is less extreme than memsetting the whole buffer to 0 */
- /* although we could potentially do better with better handling of edge conditions */
- if (win_tr_x1 >= 1 && win_tr_x1 < rw) {
- h.mem[win_tr_x1 - 1] = 0;
- }
- if (win_tr_x1 < rw) {
- h.mem[win_tr_x1] = 0;
- }
-
- opj_dwt_interleave_partial_h(h.mem,
- h.cas,
- sa,
- j,
- (OPJ_UINT32)h.sn,
- win_ll_x0,
- win_ll_x1,
- win_hl_x0,
- win_hl_x1);
- opj_dwt_decode_partial_1(h.mem, h.dn, h.sn, h.cas,
- (OPJ_INT32)win_ll_x0,
- (OPJ_INT32)win_ll_x1,
- (OPJ_INT32)win_hl_x0,
- (OPJ_INT32)win_hl_x1);
- if (!opj_sparse_array_int32_write(sa,
- win_tr_x0, j,
- win_tr_x1, j + 1,
- h.mem + win_tr_x0,
- 1, 0, OPJ_TRUE)) {
- /* FIXME event manager error callback */
- opj_sparse_array_int32_free(sa);
- opj_aligned_free(h.mem);
- return OPJ_FALSE;
- }
- }
- }
-
- for (i = win_tr_x0; i < win_tr_x1;) {
- OPJ_UINT32 nb_cols = opj_uint_min(4U, win_tr_x1 - i);
- opj_dwt_interleave_partial_v(v.mem,
- v.cas,
- sa,
- i,
- nb_cols,
- (OPJ_UINT32)v.sn,
- win_ll_y0,
- win_ll_y1,
- win_lh_y0,
- win_lh_y1);
- opj_dwt_decode_partial_1_parallel(v.mem, nb_cols, v.dn, v.sn, v.cas,
- (OPJ_INT32)win_ll_y0,
- (OPJ_INT32)win_ll_y1,
- (OPJ_INT32)win_lh_y0,
- (OPJ_INT32)win_lh_y1);
- if (!opj_sparse_array_int32_write(sa,
- i, win_tr_y0,
- i + nb_cols, win_tr_y1,
- v.mem + 4 * win_tr_y0,
- 1, 4, OPJ_TRUE)) {
- /* FIXME event manager error callback */
- opj_sparse_array_int32_free(sa);
- opj_aligned_free(h.mem);
- return OPJ_FALSE;
- }
-
- i += nb_cols;
- }
- }
- opj_aligned_free(h.mem);
-
- {
- OPJ_BOOL ret = opj_sparse_array_int32_read(sa,
- tr_max->win_x0 - (OPJ_UINT32)tr_max->x0,
- tr_max->win_y0 - (OPJ_UINT32)tr_max->y0,
- tr_max->win_x1 - (OPJ_UINT32)tr_max->x0,
- tr_max->win_y1 - (OPJ_UINT32)tr_max->y0,
- tilec->data_win,
- 1, tr_max->win_x1 - tr_max->win_x0,
- OPJ_TRUE);
- assert(ret);
- OPJ_UNUSED(ret);
- }
- opj_sparse_array_int32_free(sa);
- return OPJ_TRUE;
-}
-
-static void opj_v8dwt_interleave_h(opj_v8dwt_t* OPJ_RESTRICT dwt,
- OPJ_FLOAT32* OPJ_RESTRICT a,
- OPJ_UINT32 width,
- OPJ_UINT32 remaining_height)
-{
- OPJ_FLOAT32* OPJ_RESTRICT bi = (OPJ_FLOAT32*)(dwt->wavelet + dwt->cas);
- OPJ_UINT32 i, k;
- OPJ_UINT32 x0 = dwt->win_l_x0;
- OPJ_UINT32 x1 = dwt->win_l_x1;
-
- for (k = 0; k < 2; ++k) {
- if (remaining_height >= NB_ELTS_V8 && ((OPJ_SIZE_T) a & 0x0f) == 0 &&
- ((OPJ_SIZE_T) bi & 0x0f) == 0) {
- /* Fast code path */
- for (i = x0; i < x1; ++i) {
- OPJ_UINT32 j = i;
- OPJ_FLOAT32* OPJ_RESTRICT dst = bi + i * 2 * NB_ELTS_V8;
- dst[0] = a[j];
- j += width;
- dst[1] = a[j];
- j += width;
- dst[2] = a[j];
- j += width;
- dst[3] = a[j];
- j += width;
- dst[4] = a[j];
- j += width;
- dst[5] = a[j];
- j += width;
- dst[6] = a[j];
- j += width;
- dst[7] = a[j];
- }
- } else {
- /* Slow code path */
- for (i = x0; i < x1; ++i) {
- OPJ_UINT32 j = i;
- OPJ_FLOAT32* OPJ_RESTRICT dst = bi + i * 2 * NB_ELTS_V8;
- dst[0] = a[j];
- j += width;
- if (remaining_height == 1) {
- continue;
- }
- dst[1] = a[j];
- j += width;
- if (remaining_height == 2) {
- continue;
- }
- dst[2] = a[j];
- j += width;
- if (remaining_height == 3) {
- continue;
- }
- dst[3] = a[j];
- j += width;
- if (remaining_height == 4) {
- continue;
- }
- dst[4] = a[j];
- j += width;
- if (remaining_height == 5) {
- continue;
- }
- dst[5] = a[j];
- j += width;
- if (remaining_height == 6) {
- continue;
- }
- dst[6] = a[j];
- j += width;
- if (remaining_height == 7) {
- continue;
- }
- dst[7] = a[j];
- }
- }
-
- bi = (OPJ_FLOAT32*)(dwt->wavelet + 1 - dwt->cas);
- a += dwt->sn;
- x0 = dwt->win_h_x0;
- x1 = dwt->win_h_x1;
- }
-}
-
-static void opj_v8dwt_interleave_partial_h(opj_v8dwt_t* dwt,
- opj_sparse_array_int32_t* sa,
- OPJ_UINT32 sa_line,
- OPJ_UINT32 remaining_height)
-{
- OPJ_UINT32 i;
- for (i = 0; i < remaining_height; i++) {
- OPJ_BOOL ret;
- ret = opj_sparse_array_int32_read(sa,
- dwt->win_l_x0, sa_line + i,
- dwt->win_l_x1, sa_line + i + 1,
- /* Nasty cast from float* to int32* */
- (OPJ_INT32*)(dwt->wavelet + dwt->cas + 2 * dwt->win_l_x0) + i,
- 2 * NB_ELTS_V8, 0, OPJ_TRUE);
- assert(ret);
- ret = opj_sparse_array_int32_read(sa,
- (OPJ_UINT32)dwt->sn + dwt->win_h_x0, sa_line + i,
- (OPJ_UINT32)dwt->sn + dwt->win_h_x1, sa_line + i + 1,
- /* Nasty cast from float* to int32* */
- (OPJ_INT32*)(dwt->wavelet + 1 - dwt->cas + 2 * dwt->win_h_x0) + i,
- 2 * NB_ELTS_V8, 0, OPJ_TRUE);
- assert(ret);
- OPJ_UNUSED(ret);
- }
-}
-
-static INLINE void opj_v8dwt_interleave_v(opj_v8dwt_t* OPJ_RESTRICT dwt,
- OPJ_FLOAT32* OPJ_RESTRICT a,
- OPJ_UINT32 width,
- OPJ_UINT32 nb_elts_read)
-{
- opj_v8_t* OPJ_RESTRICT bi = dwt->wavelet + dwt->cas;
- OPJ_UINT32 i;
-
- for (i = dwt->win_l_x0; i < dwt->win_l_x1; ++i) {
- memcpy(&bi[i * 2], &a[i * (OPJ_SIZE_T)width],
- (OPJ_SIZE_T)nb_elts_read * sizeof(OPJ_FLOAT32));
- }
-
- a += (OPJ_UINT32)dwt->sn * (OPJ_SIZE_T)width;
- bi = dwt->wavelet + 1 - dwt->cas;
-
- for (i = dwt->win_h_x0; i < dwt->win_h_x1; ++i) {
- memcpy(&bi[i * 2], &a[i * (OPJ_SIZE_T)width],
- (OPJ_SIZE_T)nb_elts_read * sizeof(OPJ_FLOAT32));
- }
-}
-
-static void opj_v8dwt_interleave_partial_v(opj_v8dwt_t* OPJ_RESTRICT dwt,
- opj_sparse_array_int32_t* sa,
- OPJ_UINT32 sa_col,
- OPJ_UINT32 nb_elts_read)
-{
- OPJ_BOOL ret;
- ret = opj_sparse_array_int32_read(sa,
- sa_col, dwt->win_l_x0,
- sa_col + nb_elts_read, dwt->win_l_x1,
- (OPJ_INT32*)(dwt->wavelet + dwt->cas + 2 * dwt->win_l_x0),
- 1, 2 * NB_ELTS_V8, OPJ_TRUE);
- assert(ret);
- ret = opj_sparse_array_int32_read(sa,
- sa_col, (OPJ_UINT32)dwt->sn + dwt->win_h_x0,
- sa_col + nb_elts_read, (OPJ_UINT32)dwt->sn + dwt->win_h_x1,
- (OPJ_INT32*)(dwt->wavelet + 1 - dwt->cas + 2 * dwt->win_h_x0),
- 1, 2 * NB_ELTS_V8, OPJ_TRUE);
- assert(ret);
- OPJ_UNUSED(ret);
-}
-
-#ifdef __SSE__
-
-static void opj_v8dwt_decode_step1_sse(opj_v8_t* w,
- OPJ_UINT32 start,
- OPJ_UINT32 end,
- const __m128 c)
-{
- __m128* OPJ_RESTRICT vw = (__m128*) w;
- OPJ_UINT32 i = start;
- /* To be adapted if NB_ELTS_V8 changes */
- vw += 4 * start;
- /* Note: attempt at loop unrolling x2 doesn't help */
- for (; i < end; ++i, vw += 4) {
- vw[0] = _mm_mul_ps(vw[0], c);
- vw[1] = _mm_mul_ps(vw[1], c);
- }
-}
-
-static void opj_v8dwt_decode_step2_sse(opj_v8_t* l, opj_v8_t* w,
- OPJ_UINT32 start,
- OPJ_UINT32 end,
- OPJ_UINT32 m,
- __m128 c)
-{
- __m128* OPJ_RESTRICT vl = (__m128*) l;
- __m128* OPJ_RESTRICT vw = (__m128*) w;
- /* To be adapted if NB_ELTS_V8 changes */
- OPJ_UINT32 i;
- OPJ_UINT32 imax = opj_uint_min(end, m);
- if (start == 0) {
- if (imax >= 1) {
- vw[-2] = _mm_add_ps(vw[-2], _mm_mul_ps(_mm_add_ps(vl[0], vw[0]), c));
- vw[-1] = _mm_add_ps(vw[-1], _mm_mul_ps(_mm_add_ps(vl[1], vw[1]), c));
- vw += 4;
- start = 1;
- }
- } else {
- vw += start * 4;
- }
-
- i = start;
- /* Note: attempt at loop unrolling x2 doesn't help */
- for (; i < imax; ++i) {
- vw[-2] = _mm_add_ps(vw[-2], _mm_mul_ps(_mm_add_ps(vw[-4], vw[0]), c));
- vw[-1] = _mm_add_ps(vw[-1], _mm_mul_ps(_mm_add_ps(vw[-3], vw[1]), c));
- vw += 4;
- }
- if (m < end) {
- assert(m + 1 == end);
- c = _mm_add_ps(c, c);
- vw[-2] = _mm_add_ps(vw[-2], _mm_mul_ps(c, vw[-4]));
- vw[-1] = _mm_add_ps(vw[-1], _mm_mul_ps(c, vw[-3]));
- }
-}
-
-#else
-
-static void opj_v8dwt_decode_step1(opj_v8_t* w,
- OPJ_UINT32 start,
- OPJ_UINT32 end,
- const OPJ_FLOAT32 c)
-{
- OPJ_FLOAT32* OPJ_RESTRICT fw = (OPJ_FLOAT32*) w;
- OPJ_UINT32 i;
- /* To be adapted if NB_ELTS_V8 changes */
- for (i = start; i < end; ++i) {
- fw[i * 2 * 8 ] = fw[i * 2 * 8 ] * c;
- fw[i * 2 * 8 + 1] = fw[i * 2 * 8 + 1] * c;
- fw[i * 2 * 8 + 2] = fw[i * 2 * 8 + 2] * c;
- fw[i * 2 * 8 + 3] = fw[i * 2 * 8 + 3] * c;
- fw[i * 2 * 8 + 4] = fw[i * 2 * 8 + 4] * c;
- fw[i * 2 * 8 + 5] = fw[i * 2 * 8 + 5] * c;
- fw[i * 2 * 8 + 6] = fw[i * 2 * 8 + 6] * c;
- fw[i * 2 * 8 + 7] = fw[i * 2 * 8 + 7] * c;
- }
-}
-
-static void opj_v8dwt_decode_step2(opj_v8_t* l, opj_v8_t* w,
- OPJ_UINT32 start,
- OPJ_UINT32 end,
- OPJ_UINT32 m,
- OPJ_FLOAT32 c)
-{
- OPJ_FLOAT32* fl = (OPJ_FLOAT32*) l;
- OPJ_FLOAT32* fw = (OPJ_FLOAT32*) w;
- OPJ_UINT32 i;
- OPJ_UINT32 imax = opj_uint_min(end, m);
- if (start > 0) {
- fw += 2 * NB_ELTS_V8 * start;
- fl = fw - 2 * NB_ELTS_V8;
- }
- /* To be adapted if NB_ELTS_V8 changes */
- for (i = start; i < imax; ++i) {
- fw[-8] = fw[-8] + ((fl[0] + fw[0]) * c);
- fw[-7] = fw[-7] + ((fl[1] + fw[1]) * c);
- fw[-6] = fw[-6] + ((fl[2] + fw[2]) * c);
- fw[-5] = fw[-5] + ((fl[3] + fw[3]) * c);
- fw[-4] = fw[-4] + ((fl[4] + fw[4]) * c);
- fw[-3] = fw[-3] + ((fl[5] + fw[5]) * c);
- fw[-2] = fw[-2] + ((fl[6] + fw[6]) * c);
- fw[-1] = fw[-1] + ((fl[7] + fw[7]) * c);
- fl = fw;
- fw += 2 * NB_ELTS_V8;
- }
- if (m < end) {
- assert(m + 1 == end);
- c += c;
- fw[-8] = fw[-8] + fl[0] * c;
- fw[-7] = fw[-7] + fl[1] * c;
- fw[-6] = fw[-6] + fl[2] * c;
- fw[-5] = fw[-5] + fl[3] * c;
- fw[-4] = fw[-4] + fl[4] * c;
- fw[-3] = fw[-3] + fl[5] * c;
- fw[-2] = fw[-2] + fl[6] * c;
- fw[-1] = fw[-1] + fl[7] * c;
- }
-}
-
-#endif
-
-/* <summary> */
-/* Inverse 9-7 wavelet transform in 1-D. */
-/* </summary> */
-static void opj_v8dwt_decode(opj_v8dwt_t* OPJ_RESTRICT dwt)
-{
- OPJ_INT32 a, b;
- /* BUG_WEIRD_TWO_INVK (look for this identifier in tcd.c) */
- /* Historic value for 2 / opj_invK */
- /* Normally, we should use invK, but if we do so, we have failures in the */
- /* conformance test, due to MSE and peak errors significantly higher than */
- /* accepted value */
- /* Due to using two_invK instead of invK, we have to compensate in tcd.c */
- /* the computation of the stepsize for the non LL subbands */
- const float two_invK = 1.625732422f;
- if (dwt->cas == 0) {
- if (!((dwt->dn > 0) || (dwt->sn > 1))) {
- return;
- }
- a = 0;
- b = 1;
- } else {
- if (!((dwt->sn > 0) || (dwt->dn > 1))) {
- return;
- }
- a = 1;
- b = 0;
- }
-#ifdef __SSE__
- opj_v8dwt_decode_step1_sse(dwt->wavelet + a, dwt->win_l_x0, dwt->win_l_x1,
- _mm_set1_ps(opj_K));
- opj_v8dwt_decode_step1_sse(dwt->wavelet + b, dwt->win_h_x0, dwt->win_h_x1,
- _mm_set1_ps(two_invK));
- opj_v8dwt_decode_step2_sse(dwt->wavelet + b, dwt->wavelet + a + 1,
- dwt->win_l_x0, dwt->win_l_x1,
- (OPJ_UINT32)opj_int_min(dwt->sn, dwt->dn - a),
- _mm_set1_ps(-opj_dwt_delta));
- opj_v8dwt_decode_step2_sse(dwt->wavelet + a, dwt->wavelet + b + 1,
- dwt->win_h_x0, dwt->win_h_x1,
- (OPJ_UINT32)opj_int_min(dwt->dn, dwt->sn - b),
- _mm_set1_ps(-opj_dwt_gamma));
- opj_v8dwt_decode_step2_sse(dwt->wavelet + b, dwt->wavelet + a + 1,
- dwt->win_l_x0, dwt->win_l_x1,
- (OPJ_UINT32)opj_int_min(dwt->sn, dwt->dn - a),
- _mm_set1_ps(-opj_dwt_beta));
- opj_v8dwt_decode_step2_sse(dwt->wavelet + a, dwt->wavelet + b + 1,
- dwt->win_h_x0, dwt->win_h_x1,
- (OPJ_UINT32)opj_int_min(dwt->dn, dwt->sn - b),
- _mm_set1_ps(-opj_dwt_alpha));
-#else
- opj_v8dwt_decode_step1(dwt->wavelet + a, dwt->win_l_x0, dwt->win_l_x1,
- opj_K);
- opj_v8dwt_decode_step1(dwt->wavelet + b, dwt->win_h_x0, dwt->win_h_x1,
- two_invK);
- opj_v8dwt_decode_step2(dwt->wavelet + b, dwt->wavelet + a + 1,
- dwt->win_l_x0, dwt->win_l_x1,
- (OPJ_UINT32)opj_int_min(dwt->sn, dwt->dn - a),
- -opj_dwt_delta);
- opj_v8dwt_decode_step2(dwt->wavelet + a, dwt->wavelet + b + 1,
- dwt->win_h_x0, dwt->win_h_x1,
- (OPJ_UINT32)opj_int_min(dwt->dn, dwt->sn - b),
- -opj_dwt_gamma);
- opj_v8dwt_decode_step2(dwt->wavelet + b, dwt->wavelet + a + 1,
- dwt->win_l_x0, dwt->win_l_x1,
- (OPJ_UINT32)opj_int_min(dwt->sn, dwt->dn - a),
- -opj_dwt_beta);
- opj_v8dwt_decode_step2(dwt->wavelet + a, dwt->wavelet + b + 1,
- dwt->win_h_x0, dwt->win_h_x1,
- (OPJ_UINT32)opj_int_min(dwt->dn, dwt->sn - b),
- -opj_dwt_alpha);
-#endif
-}
-
-typedef struct {
- opj_v8dwt_t h;
- OPJ_UINT32 rw;
- OPJ_UINT32 w;
- OPJ_FLOAT32 * OPJ_RESTRICT aj;
- OPJ_UINT32 nb_rows;
-} opj_dwt97_decode_h_job_t;
-
-static void opj_dwt97_decode_h_func(void* user_data, opj_tls_t* tls)
-{
- OPJ_UINT32 j;
- opj_dwt97_decode_h_job_t* job;
- OPJ_FLOAT32 * OPJ_RESTRICT aj;
- OPJ_UINT32 w;
- (void)tls;
-
- job = (opj_dwt97_decode_h_job_t*)user_data;
- w = job->w;
-
- assert((job->nb_rows % NB_ELTS_V8) == 0);
-
- aj = job->aj;
- for (j = 0; j + NB_ELTS_V8 <= job->nb_rows; j += NB_ELTS_V8) {
- OPJ_UINT32 k;
- opj_v8dwt_interleave_h(&job->h, aj, job->w, NB_ELTS_V8);
- opj_v8dwt_decode(&job->h);
-
- /* To be adapted if NB_ELTS_V8 changes */
- for (k = 0; k < job->rw; k++) {
- aj[k ] = job->h.wavelet[k].f[0];
- aj[k + (OPJ_SIZE_T)w ] = job->h.wavelet[k].f[1];
- aj[k + (OPJ_SIZE_T)w * 2] = job->h.wavelet[k].f[2];
- aj[k + (OPJ_SIZE_T)w * 3] = job->h.wavelet[k].f[3];
- }
- for (k = 0; k < job->rw; k++) {
- aj[k + (OPJ_SIZE_T)w * 4] = job->h.wavelet[k].f[4];
- aj[k + (OPJ_SIZE_T)w * 5] = job->h.wavelet[k].f[5];
- aj[k + (OPJ_SIZE_T)w * 6] = job->h.wavelet[k].f[6];
- aj[k + (OPJ_SIZE_T)w * 7] = job->h.wavelet[k].f[7];
- }
-
- aj += w * NB_ELTS_V8;
- }
-
- opj_aligned_free(job->h.wavelet);
- opj_free(job);
-}
-
-
-typedef struct {
- opj_v8dwt_t v;
- OPJ_UINT32 rh;
- OPJ_UINT32 w;
- OPJ_FLOAT32 * OPJ_RESTRICT aj;
- OPJ_UINT32 nb_columns;
-} opj_dwt97_decode_v_job_t;
-
-static void opj_dwt97_decode_v_func(void* user_data, opj_tls_t* tls)
-{
- OPJ_UINT32 j;
- opj_dwt97_decode_v_job_t* job;
- OPJ_FLOAT32 * OPJ_RESTRICT aj;
- (void)tls;
-
- job = (opj_dwt97_decode_v_job_t*)user_data;
-
- assert((job->nb_columns % NB_ELTS_V8) == 0);
-
- aj = job->aj;
- for (j = 0; j + NB_ELTS_V8 <= job->nb_columns; j += NB_ELTS_V8) {
- OPJ_UINT32 k;
-
- opj_v8dwt_interleave_v(&job->v, aj, job->w, NB_ELTS_V8);
- opj_v8dwt_decode(&job->v);
-
- for (k = 0; k < job->rh; ++k) {
- memcpy(&aj[k * (OPJ_SIZE_T)job->w], &job->v.wavelet[k],
- NB_ELTS_V8 * sizeof(OPJ_FLOAT32));
- }
- aj += NB_ELTS_V8;
- }
-
- opj_aligned_free(job->v.wavelet);
- opj_free(job);
-}
-
-
-/* <summary> */
-/* Inverse 9-7 wavelet transform in 2-D. */
-/* </summary> */
-static
-OPJ_BOOL opj_dwt_decode_tile_97(opj_thread_pool_t* tp,
- opj_tcd_tilecomp_t* OPJ_RESTRICT tilec,
- OPJ_UINT32 numres)
-{
- opj_v8dwt_t h;
- opj_v8dwt_t v;
-
- opj_tcd_resolution_t* res = tilec->resolutions;
-
- OPJ_UINT32 rw = (OPJ_UINT32)(res->x1 -
- res->x0); /* width of the resolution level computed */
- OPJ_UINT32 rh = (OPJ_UINT32)(res->y1 -
- res->y0); /* height of the resolution level computed */
-
- OPJ_UINT32 w = (OPJ_UINT32)(tilec->resolutions[tilec->minimum_num_resolutions -
- 1].x1 -
- tilec->resolutions[tilec->minimum_num_resolutions - 1].x0);
-
- OPJ_SIZE_T l_data_size;
- const int num_threads = opj_thread_pool_get_thread_count(tp);
-
- if (numres == 1) {
- return OPJ_TRUE;
- }
-
- l_data_size = opj_dwt_max_resolution(res, numres);
- /* overflow check */
- if (l_data_size > (SIZE_MAX / sizeof(opj_v8_t))) {
- /* FIXME event manager error callback */
- return OPJ_FALSE;
- }
- h.wavelet = (opj_v8_t*) opj_aligned_malloc(l_data_size * sizeof(opj_v8_t));
- if (!h.wavelet) {
- /* FIXME event manager error callback */
- return OPJ_FALSE;
- }
- v.wavelet = h.wavelet;
-
- while (--numres) {
- OPJ_FLOAT32 * OPJ_RESTRICT aj = (OPJ_FLOAT32*) tilec->data;
- OPJ_UINT32 j;
-
- h.sn = (OPJ_INT32)rw;
- v.sn = (OPJ_INT32)rh;
-
- ++res;
-
- rw = (OPJ_UINT32)(res->x1 -
- res->x0); /* width of the resolution level computed */
- rh = (OPJ_UINT32)(res->y1 -
- res->y0); /* height of the resolution level computed */
-
- h.dn = (OPJ_INT32)(rw - (OPJ_UINT32)h.sn);
- h.cas = res->x0 % 2;
-
- h.win_l_x0 = 0;
- h.win_l_x1 = (OPJ_UINT32)h.sn;
- h.win_h_x0 = 0;
- h.win_h_x1 = (OPJ_UINT32)h.dn;
-
- if (num_threads <= 1 || rh < 2 * NB_ELTS_V8) {
- for (j = 0; j + (NB_ELTS_V8 - 1) < rh; j += NB_ELTS_V8) {
- OPJ_UINT32 k;
- opj_v8dwt_interleave_h(&h, aj, w, NB_ELTS_V8);
- opj_v8dwt_decode(&h);
-
- /* To be adapted if NB_ELTS_V8 changes */
- for (k = 0; k < rw; k++) {
- aj[k ] = h.wavelet[k].f[0];
- aj[k + (OPJ_SIZE_T)w ] = h.wavelet[k].f[1];
- aj[k + (OPJ_SIZE_T)w * 2] = h.wavelet[k].f[2];
- aj[k + (OPJ_SIZE_T)w * 3] = h.wavelet[k].f[3];
- }
- for (k = 0; k < rw; k++) {
- aj[k + (OPJ_SIZE_T)w * 4] = h.wavelet[k].f[4];
- aj[k + (OPJ_SIZE_T)w * 5] = h.wavelet[k].f[5];
- aj[k + (OPJ_SIZE_T)w * 6] = h.wavelet[k].f[6];
- aj[k + (OPJ_SIZE_T)w * 7] = h.wavelet[k].f[7];
- }
-
- aj += w * NB_ELTS_V8;
- }
- } else {
- OPJ_UINT32 num_jobs = (OPJ_UINT32)num_threads;
- OPJ_UINT32 step_j;
-
- if ((rh / NB_ELTS_V8) < num_jobs) {
- num_jobs = rh / NB_ELTS_V8;
- }
- step_j = ((rh / num_jobs) / NB_ELTS_V8) * NB_ELTS_V8;
- for (j = 0; j < num_jobs; j++) {
- opj_dwt97_decode_h_job_t* job;
-
- job = (opj_dwt97_decode_h_job_t*) opj_malloc(sizeof(opj_dwt97_decode_h_job_t));
- if (!job) {
- opj_thread_pool_wait_completion(tp, 0);
- opj_aligned_free(h.wavelet);
- return OPJ_FALSE;
- }
- job->h.wavelet = (opj_v8_t*)opj_aligned_malloc(l_data_size * sizeof(opj_v8_t));
- if (!job->h.wavelet) {
- opj_thread_pool_wait_completion(tp, 0);
- opj_free(job);
- opj_aligned_free(h.wavelet);
- return OPJ_FALSE;
- }
- job->h.dn = h.dn;
- job->h.sn = h.sn;
- job->h.cas = h.cas;
- job->h.win_l_x0 = h.win_l_x0;
- job->h.win_l_x1 = h.win_l_x1;
- job->h.win_h_x0 = h.win_h_x0;
- job->h.win_h_x1 = h.win_h_x1;
- job->rw = rw;
- job->w = w;
- job->aj = aj;
- job->nb_rows = (j + 1 == num_jobs) ? (rh & (OPJ_UINT32)~
- (NB_ELTS_V8 - 1)) - j * step_j : step_j;
- aj += w * job->nb_rows;
- opj_thread_pool_submit_job(tp, opj_dwt97_decode_h_func, job);
- }
- opj_thread_pool_wait_completion(tp, 0);
- j = rh & (OPJ_UINT32)~(NB_ELTS_V8 - 1);
- }
-
- if (j < rh) {
- OPJ_UINT32 k;
- opj_v8dwt_interleave_h(&h, aj, w, rh - j);
- opj_v8dwt_decode(&h);
- for (k = 0; k < rw; k++) {
- OPJ_UINT32 l;
- for (l = 0; l < rh - j; l++) {
- aj[k + (OPJ_SIZE_T)w * l ] = h.wavelet[k].f[l];
- }
- }
- }
-
- v.dn = (OPJ_INT32)(rh - (OPJ_UINT32)v.sn);
- v.cas = res->y0 % 2;
- v.win_l_x0 = 0;
- v.win_l_x1 = (OPJ_UINT32)v.sn;
- v.win_h_x0 = 0;
- v.win_h_x1 = (OPJ_UINT32)v.dn;
-
- aj = (OPJ_FLOAT32*) tilec->data;
- if (num_threads <= 1 || rw < 2 * NB_ELTS_V8) {
- for (j = rw; j > (NB_ELTS_V8 - 1); j -= NB_ELTS_V8) {
- OPJ_UINT32 k;
-
- opj_v8dwt_interleave_v(&v, aj, w, NB_ELTS_V8);
- opj_v8dwt_decode(&v);
-
- for (k = 0; k < rh; ++k) {
- memcpy(&aj[k * (OPJ_SIZE_T)w], &v.wavelet[k], NB_ELTS_V8 * sizeof(OPJ_FLOAT32));
- }
- aj += NB_ELTS_V8;
- }
- } else {
- /* "bench_dwt -I" shows that scaling is poor, likely due to RAM
- transfer being the limiting factor. So limit the number of
- threads.
- */
- OPJ_UINT32 num_jobs = opj_uint_max((OPJ_UINT32)num_threads / 2, 2U);
- OPJ_UINT32 step_j;
-
- if ((rw / NB_ELTS_V8) < num_jobs) {
- num_jobs = rw / NB_ELTS_V8;
- }
- step_j = ((rw / num_jobs) / NB_ELTS_V8) * NB_ELTS_V8;
- for (j = 0; j < num_jobs; j++) {
- opj_dwt97_decode_v_job_t* job;
-
- job = (opj_dwt97_decode_v_job_t*) opj_malloc(sizeof(opj_dwt97_decode_v_job_t));
- if (!job) {
- opj_thread_pool_wait_completion(tp, 0);
- opj_aligned_free(h.wavelet);
- return OPJ_FALSE;
- }
- job->v.wavelet = (opj_v8_t*)opj_aligned_malloc(l_data_size * sizeof(opj_v8_t));
- if (!job->v.wavelet) {
- opj_thread_pool_wait_completion(tp, 0);
- opj_free(job);
- opj_aligned_free(h.wavelet);
- return OPJ_FALSE;
- }
- job->v.dn = v.dn;
- job->v.sn = v.sn;
- job->v.cas = v.cas;
- job->v.win_l_x0 = v.win_l_x0;
- job->v.win_l_x1 = v.win_l_x1;
- job->v.win_h_x0 = v.win_h_x0;
- job->v.win_h_x1 = v.win_h_x1;
- job->rh = rh;
- job->w = w;
- job->aj = aj;
- job->nb_columns = (j + 1 == num_jobs) ? (rw & (OPJ_UINT32)~
- (NB_ELTS_V8 - 1)) - j * step_j : step_j;
- aj += job->nb_columns;
- opj_thread_pool_submit_job(tp, opj_dwt97_decode_v_func, job);
- }
- opj_thread_pool_wait_completion(tp, 0);
- }
-
- if (rw & (NB_ELTS_V8 - 1)) {
- OPJ_UINT32 k;
-
- j = rw & (NB_ELTS_V8 - 1);
-
- opj_v8dwt_interleave_v(&v, aj, w, j);
- opj_v8dwt_decode(&v);
-
- for (k = 0; k < rh; ++k) {
- memcpy(&aj[k * (OPJ_SIZE_T)w], &v.wavelet[k],
- (OPJ_SIZE_T)j * sizeof(OPJ_FLOAT32));
- }
- }
- }
-
- opj_aligned_free(h.wavelet);
- return OPJ_TRUE;
-}
-
-static
-OPJ_BOOL opj_dwt_decode_partial_97(opj_tcd_tilecomp_t* OPJ_RESTRICT tilec,
- OPJ_UINT32 numres)
-{
- opj_sparse_array_int32_t* sa;
- opj_v8dwt_t h;
- opj_v8dwt_t v;
- OPJ_UINT32 resno;
- /* This value matches the maximum left/right extension given in tables */
- /* F.2 and F.3 of the standard. Note: in opj_tcd_is_subband_area_of_interest() */
- /* we currently use 3. */
- const OPJ_UINT32 filter_width = 4U;
-
- opj_tcd_resolution_t* tr = tilec->resolutions;
- opj_tcd_resolution_t* tr_max = &(tilec->resolutions[numres - 1]);
-
- OPJ_UINT32 rw = (OPJ_UINT32)(tr->x1 -
- tr->x0); /* width of the resolution level computed */
- OPJ_UINT32 rh = (OPJ_UINT32)(tr->y1 -
- tr->y0); /* height of the resolution level computed */
-
- OPJ_SIZE_T l_data_size;
-
- /* Compute the intersection of the area of interest, expressed in tile coordinates */
- /* with the tile coordinates */
- OPJ_UINT32 win_tcx0 = tilec->win_x0;
- OPJ_UINT32 win_tcy0 = tilec->win_y0;
- OPJ_UINT32 win_tcx1 = tilec->win_x1;
- OPJ_UINT32 win_tcy1 = tilec->win_y1;
-
- if (tr_max->x0 == tr_max->x1 || tr_max->y0 == tr_max->y1) {
- return OPJ_TRUE;
- }
-
- sa = opj_dwt_init_sparse_array(tilec, numres);
- if (sa == NULL) {
- return OPJ_FALSE;
- }
-
- if (numres == 1U) {
- OPJ_BOOL ret = opj_sparse_array_int32_read(sa,
- tr_max->win_x0 - (OPJ_UINT32)tr_max->x0,
- tr_max->win_y0 - (OPJ_UINT32)tr_max->y0,
- tr_max->win_x1 - (OPJ_UINT32)tr_max->x0,
- tr_max->win_y1 - (OPJ_UINT32)tr_max->y0,
- tilec->data_win,
- 1, tr_max->win_x1 - tr_max->win_x0,
- OPJ_TRUE);
- assert(ret);
- OPJ_UNUSED(ret);
- opj_sparse_array_int32_free(sa);
- return OPJ_TRUE;
- }
-
- l_data_size = opj_dwt_max_resolution(tr, numres);
- /* overflow check */
- if (l_data_size > (SIZE_MAX / sizeof(opj_v8_t))) {
- /* FIXME event manager error callback */
- opj_sparse_array_int32_free(sa);
- return OPJ_FALSE;
- }
- h.wavelet = (opj_v8_t*) opj_aligned_malloc(l_data_size * sizeof(opj_v8_t));
- if (!h.wavelet) {
- /* FIXME event manager error callback */
- opj_sparse_array_int32_free(sa);
- return OPJ_FALSE;
- }
- v.wavelet = h.wavelet;
-
- for (resno = 1; resno < numres; resno ++) {
- OPJ_UINT32 j;
- /* Window of interest subband-based coordinates */
- OPJ_UINT32 win_ll_x0, win_ll_y0, win_ll_x1, win_ll_y1;
- OPJ_UINT32 win_hl_x0, win_hl_x1;
- OPJ_UINT32 win_lh_y0, win_lh_y1;
- /* Window of interest tile-resolution-based coordinates */
- OPJ_UINT32 win_tr_x0, win_tr_x1, win_tr_y0, win_tr_y1;
- /* Tile-resolution subband-based coordinates */
- OPJ_UINT32 tr_ll_x0, tr_ll_y0, tr_hl_x0, tr_lh_y0;
-
- ++tr;
-
- h.sn = (OPJ_INT32)rw;
- v.sn = (OPJ_INT32)rh;
-
- rw = (OPJ_UINT32)(tr->x1 - tr->x0);
- rh = (OPJ_UINT32)(tr->y1 - tr->y0);
-
- h.dn = (OPJ_INT32)(rw - (OPJ_UINT32)h.sn);
- h.cas = tr->x0 % 2;
-
- v.dn = (OPJ_INT32)(rh - (OPJ_UINT32)v.sn);
- v.cas = tr->y0 % 2;
-
- /* Get the subband coordinates for the window of interest */
- /* LL band */
- opj_dwt_get_band_coordinates(tilec, resno, 0,
- win_tcx0, win_tcy0, win_tcx1, win_tcy1,
- &win_ll_x0, &win_ll_y0,
- &win_ll_x1, &win_ll_y1);
-
- /* HL band */
- opj_dwt_get_band_coordinates(tilec, resno, 1,
- win_tcx0, win_tcy0, win_tcx1, win_tcy1,
- &win_hl_x0, NULL, &win_hl_x1, NULL);
-
- /* LH band */
- opj_dwt_get_band_coordinates(tilec, resno, 2,
- win_tcx0, win_tcy0, win_tcx1, win_tcy1,
- NULL, &win_lh_y0, NULL, &win_lh_y1);
-
- /* Beware: band index for non-LL0 resolution are 0=HL, 1=LH and 2=HH */
- tr_ll_x0 = (OPJ_UINT32)tr->bands[1].x0;
- tr_ll_y0 = (OPJ_UINT32)tr->bands[0].y0;
- tr_hl_x0 = (OPJ_UINT32)tr->bands[0].x0;
- tr_lh_y0 = (OPJ_UINT32)tr->bands[1].y0;
-
- /* Subtract the origin of the bands for this tile, to the subwindow */
- /* of interest band coordinates, so as to get them relative to the */
- /* tile */
- win_ll_x0 = opj_uint_subs(win_ll_x0, tr_ll_x0);
- win_ll_y0 = opj_uint_subs(win_ll_y0, tr_ll_y0);
- win_ll_x1 = opj_uint_subs(win_ll_x1, tr_ll_x0);
- win_ll_y1 = opj_uint_subs(win_ll_y1, tr_ll_y0);
- win_hl_x0 = opj_uint_subs(win_hl_x0, tr_hl_x0);
- win_hl_x1 = opj_uint_subs(win_hl_x1, tr_hl_x0);
- win_lh_y0 = opj_uint_subs(win_lh_y0, tr_lh_y0);
- win_lh_y1 = opj_uint_subs(win_lh_y1, tr_lh_y0);
-
- opj_dwt_segment_grow(filter_width, (OPJ_UINT32)h.sn, &win_ll_x0, &win_ll_x1);
- opj_dwt_segment_grow(filter_width, (OPJ_UINT32)h.dn, &win_hl_x0, &win_hl_x1);
-
- opj_dwt_segment_grow(filter_width, (OPJ_UINT32)v.sn, &win_ll_y0, &win_ll_y1);
- opj_dwt_segment_grow(filter_width, (OPJ_UINT32)v.dn, &win_lh_y0, &win_lh_y1);
-
- /* Compute the tile-resolution-based coordinates for the window of interest */
- if (h.cas == 0) {
- win_tr_x0 = opj_uint_min(2 * win_ll_x0, 2 * win_hl_x0 + 1);
- win_tr_x1 = opj_uint_min(opj_uint_max(2 * win_ll_x1, 2 * win_hl_x1 + 1), rw);
- } else {
- win_tr_x0 = opj_uint_min(2 * win_hl_x0, 2 * win_ll_x0 + 1);
- win_tr_x1 = opj_uint_min(opj_uint_max(2 * win_hl_x1, 2 * win_ll_x1 + 1), rw);
- }
-
- if (v.cas == 0) {
- win_tr_y0 = opj_uint_min(2 * win_ll_y0, 2 * win_lh_y0 + 1);
- win_tr_y1 = opj_uint_min(opj_uint_max(2 * win_ll_y1, 2 * win_lh_y1 + 1), rh);
- } else {
- win_tr_y0 = opj_uint_min(2 * win_lh_y0, 2 * win_ll_y0 + 1);
- win_tr_y1 = opj_uint_min(opj_uint_max(2 * win_lh_y1, 2 * win_ll_y1 + 1), rh);
- }
-
- h.win_l_x0 = win_ll_x0;
- h.win_l_x1 = win_ll_x1;
- h.win_h_x0 = win_hl_x0;
- h.win_h_x1 = win_hl_x1;
- for (j = 0; j + (NB_ELTS_V8 - 1) < rh; j += NB_ELTS_V8) {
- if ((j + (NB_ELTS_V8 - 1) >= win_ll_y0 && j < win_ll_y1) ||
- (j + (NB_ELTS_V8 - 1) >= win_lh_y0 + (OPJ_UINT32)v.sn &&
- j < win_lh_y1 + (OPJ_UINT32)v.sn)) {
- opj_v8dwt_interleave_partial_h(&h, sa, j, opj_uint_min(NB_ELTS_V8, rh - j));
- opj_v8dwt_decode(&h);
- if (!opj_sparse_array_int32_write(sa,
- win_tr_x0, j,
- win_tr_x1, j + NB_ELTS_V8,
- (OPJ_INT32*)&h.wavelet[win_tr_x0].f[0],
- NB_ELTS_V8, 1, OPJ_TRUE)) {
- /* FIXME event manager error callback */
- opj_sparse_array_int32_free(sa);
- opj_aligned_free(h.wavelet);
- return OPJ_FALSE;
- }
- }
- }
-
- if (j < rh &&
- ((j + (NB_ELTS_V8 - 1) >= win_ll_y0 && j < win_ll_y1) ||
- (j + (NB_ELTS_V8 - 1) >= win_lh_y0 + (OPJ_UINT32)v.sn &&
- j < win_lh_y1 + (OPJ_UINT32)v.sn))) {
- opj_v8dwt_interleave_partial_h(&h, sa, j, rh - j);
- opj_v8dwt_decode(&h);
- if (!opj_sparse_array_int32_write(sa,
- win_tr_x0, j,
- win_tr_x1, rh,
- (OPJ_INT32*)&h.wavelet[win_tr_x0].f[0],
- NB_ELTS_V8, 1, OPJ_TRUE)) {
- /* FIXME event manager error callback */
- opj_sparse_array_int32_free(sa);
- opj_aligned_free(h.wavelet);
- return OPJ_FALSE;
- }
- }
-
- v.win_l_x0 = win_ll_y0;
- v.win_l_x1 = win_ll_y1;
- v.win_h_x0 = win_lh_y0;
- v.win_h_x1 = win_lh_y1;
- for (j = win_tr_x0; j < win_tr_x1; j += NB_ELTS_V8) {
- OPJ_UINT32 nb_elts = opj_uint_min(NB_ELTS_V8, win_tr_x1 - j);
-
- opj_v8dwt_interleave_partial_v(&v, sa, j, nb_elts);
- opj_v8dwt_decode(&v);
-
- if (!opj_sparse_array_int32_write(sa,
- j, win_tr_y0,
- j + nb_elts, win_tr_y1,
- (OPJ_INT32*)&h.wavelet[win_tr_y0].f[0],
- 1, NB_ELTS_V8, OPJ_TRUE)) {
- /* FIXME event manager error callback */
- opj_sparse_array_int32_free(sa);
- opj_aligned_free(h.wavelet);
- return OPJ_FALSE;
- }
- }
- }
-
- {
- OPJ_BOOL ret = opj_sparse_array_int32_read(sa,
- tr_max->win_x0 - (OPJ_UINT32)tr_max->x0,
- tr_max->win_y0 - (OPJ_UINT32)tr_max->y0,
- tr_max->win_x1 - (OPJ_UINT32)tr_max->x0,
- tr_max->win_y1 - (OPJ_UINT32)tr_max->y0,
- tilec->data_win,
- 1, tr_max->win_x1 - tr_max->win_x0,
- OPJ_TRUE);
- assert(ret);
- OPJ_UNUSED(ret);
- }
- opj_sparse_array_int32_free(sa);
-
- opj_aligned_free(h.wavelet);
- return OPJ_TRUE;
-}
-
-
-OPJ_BOOL opj_dwt_decode_real(opj_tcd_t *p_tcd,
- opj_tcd_tilecomp_t* OPJ_RESTRICT tilec,
- OPJ_UINT32 numres)
-{
- if (p_tcd->whole_tile_decoding) {
- return opj_dwt_decode_tile_97(p_tcd->thread_pool, tilec, numres);
- } else {
- return opj_dwt_decode_partial_97(tilec, numres);
- }
-}
diff --git a/contrib/libs/openjpeg/dwt.h b/contrib/libs/openjpeg/dwt.h
deleted file mode 100644
index 215061e6b9..0000000000
--- a/contrib/libs/openjpeg/dwt.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2014, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux
- * Copyright (c) 2003-2014, Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef OPJ_DWT_H
-#define OPJ_DWT_H
-/**
-@file dwt.h
-@brief Implementation of a discrete wavelet transform (DWT)
-
-The functions in DWT.C have for goal to realize forward and inverse discret wavelet
-transform with filter 5-3 (reversible) and filter 9-7 (irreversible). The functions in
-DWT.C are used by some function in TCD.C.
-*/
-
-/** @defgroup DWT DWT - Implementation of a discrete wavelet transform */
-/*@{*/
-
-
-/** @name Exported functions */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-/**
-Forward 5-3 wavelet transform in 2-D.
-Apply a reversible DWT transform to a component of an image.
-@param p_tcd TCD handle
-@param tilec Tile component information (current tile)
-*/
-OPJ_BOOL opj_dwt_encode(opj_tcd_t *p_tcd,
- opj_tcd_tilecomp_t * tilec);
-
-/**
-Inverse 5-3 wavelet transform in 2-D.
-Apply a reversible inverse DWT transform to a component of an image.
-@param p_tcd TCD handle
-@param tilec Tile component information (current tile)
-@param numres Number of resolution levels to decode
-*/
-OPJ_BOOL opj_dwt_decode(opj_tcd_t *p_tcd,
- opj_tcd_tilecomp_t* tilec,
- OPJ_UINT32 numres);
-
-/**
-Get the norm of a wavelet function of a subband at a specified level for the reversible 5-3 DWT.
-@param level Level of the wavelet function
-@param orient Band of the wavelet function
-@return Returns the norm of the wavelet function
-*/
-OPJ_FLOAT64 opj_dwt_getnorm(OPJ_UINT32 level, OPJ_UINT32 orient);
-/**
-Forward 9-7 wavelet transform in 2-D.
-Apply an irreversible DWT transform to a component of an image.
-@param p_tcd TCD handle
-@param tilec Tile component information (current tile)
-*/
-OPJ_BOOL opj_dwt_encode_real(opj_tcd_t *p_tcd,
- opj_tcd_tilecomp_t * tilec);
-/**
-Inverse 9-7 wavelet transform in 2-D.
-Apply an irreversible inverse DWT transform to a component of an image.
-@param p_tcd TCD handle
-@param tilec Tile component information (current tile)
-@param numres Number of resolution levels to decode
-*/
-OPJ_BOOL opj_dwt_decode_real(opj_tcd_t *p_tcd,
- opj_tcd_tilecomp_t* OPJ_RESTRICT tilec,
- OPJ_UINT32 numres);
-
-/**
-Get the norm of a wavelet function of a subband at a specified level for the irreversible 9-7 DWT
-@param level Level of the wavelet function
-@param orient Band of the wavelet function
-@return Returns the norm of the 9-7 wavelet
-*/
-OPJ_FLOAT64 opj_dwt_getnorm_real(OPJ_UINT32 level, OPJ_UINT32 orient);
-/**
-Explicit calculation of the Quantization Stepsizes
-@param tccp Tile-component coding parameters
-@param prec Precint analyzed
-*/
-void opj_dwt_calc_explicit_stepsizes(opj_tccp_t * tccp, OPJ_UINT32 prec);
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* OPJ_DWT_H */
diff --git a/contrib/libs/openjpeg/event.c b/contrib/libs/openjpeg/event.c
deleted file mode 100644
index aad9d76c98..0000000000
--- a/contrib/libs/openjpeg/event.c
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR
- * Copyright (c) 2012, CS Systemes d'Information, France
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "opj_includes.h"
-
-/* ==========================================================
- Utility functions
- ==========================================================*/
-
-#ifdef OPJ_CODE_NOT_USED
-#ifndef _WIN32
-static char*
-i2a(unsigned i, char *a, unsigned r)
-{
- if (i / r > 0) {
- a = i2a(i / r, a, r);
- }
- *a = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"[i % r];
- return a + 1;
-}
-
-/**
- Transforms integer i into an ascii string and stores the result in a;
- string is encoded in the base indicated by r.
- @param i Number to be converted
- @param a String result
- @param r Base of value; must be in the range 2 - 36
- @return Returns a
-*/
-static char *
-_itoa(int i, char *a, int r)
-{
- r = ((r < 2) || (r > 36)) ? 10 : r;
- if (i < 0) {
- *a = '-';
- *i2a(-i, a + 1, r) = 0;
- } else {
- *i2a(i, a, r) = 0;
- }
- return a;
-}
-
-#endif /* !_WIN32 */
-#endif
-
-/* ----------------------------------------------------------------------- */
-/**
- * Default callback function.
- * Do nothing.
- */
-static void opj_default_callback(const char *msg, void *client_data)
-{
- OPJ_ARG_NOT_USED(msg);
- OPJ_ARG_NOT_USED(client_data);
-}
-
-/* ----------------------------------------------------------------------- */
-
-
-/* ----------------------------------------------------------------------- */
-OPJ_BOOL opj_event_msg(opj_event_mgr_t* p_event_mgr, OPJ_INT32 event_type,
- const char *fmt, ...)
-{
-#define OPJ_MSG_SIZE 512 /* 512 bytes should be more than enough for a short message */
- opj_msg_callback msg_handler = 00;
- void * l_data = 00;
-
- if (p_event_mgr != 00) {
- switch (event_type) {
- case EVT_ERROR:
- msg_handler = p_event_mgr->error_handler;
- l_data = p_event_mgr->m_error_data;
- break;
- case EVT_WARNING:
- msg_handler = p_event_mgr->warning_handler;
- l_data = p_event_mgr->m_warning_data;
- break;
- case EVT_INFO:
- msg_handler = p_event_mgr->info_handler;
- l_data = p_event_mgr->m_info_data;
- break;
- default:
- break;
- }
- if (msg_handler == 00) {
- return OPJ_FALSE;
- }
- } else {
- return OPJ_FALSE;
- }
-
- if ((fmt != 00) && (p_event_mgr != 00)) {
- va_list arg;
- char message[OPJ_MSG_SIZE];
- memset(message, 0, OPJ_MSG_SIZE);
- /* initialize the optional parameter list */
- va_start(arg, fmt);
- /* parse the format string and put the result in 'message' */
- vsnprintf(message, OPJ_MSG_SIZE, fmt, arg);
- /* force zero termination for Windows _vsnprintf() of old MSVC */
- message[OPJ_MSG_SIZE - 1] = '\0';
- /* deinitialize the optional parameter list */
- va_end(arg);
-
- /* output the message to the user program */
- msg_handler(message, l_data);
- }
-
- return OPJ_TRUE;
-}
-
-void opj_set_default_event_handler(opj_event_mgr_t * p_manager)
-{
- p_manager->m_error_data = 00;
- p_manager->m_warning_data = 00;
- p_manager->m_info_data = 00;
- p_manager->error_handler = opj_default_callback;
- p_manager->info_handler = opj_default_callback;
- p_manager->warning_handler = opj_default_callback;
-}
-
diff --git a/contrib/libs/openjpeg/event.h b/contrib/libs/openjpeg/event.h
deleted file mode 100644
index d880388d07..0000000000
--- a/contrib/libs/openjpeg/event.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR
- * Copyright (c) 2012, CS Systemes d'Information, France
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef OPJ_EVENT_H
-#define OPJ_EVENT_H
-/**
-@file event.h
-@brief Implementation of a event callback system
-
-The functions in EVENT.C have for goal to send output messages (errors, warnings, debug) to the user.
-*/
-/**
-Message handler object
-used for
-<ul>
-<li>Error messages
-<li>Warning messages
-<li>Debugging messages
-</ul>
-*/
-typedef struct opj_event_mgr {
- /** Data to call the event manager upon */
- void * m_error_data;
- /** Data to call the event manager upon */
- void * m_warning_data;
- /** Data to call the event manager upon */
- void * m_info_data;
- /** Error message callback if available, NULL otherwise */
- opj_msg_callback error_handler;
- /** Warning message callback if available, NULL otherwise */
- opj_msg_callback warning_handler;
- /** Debug message callback if available, NULL otherwise */
- opj_msg_callback info_handler;
-} opj_event_mgr_t;
-
-
-#define EVT_ERROR 1 /**< Error event type */
-#define EVT_WARNING 2 /**< Warning event type */
-#define EVT_INFO 4 /**< Debug event type */
-
-/** @defgroup EVENT EVENT - Implementation of a event callback system */
-/*@{*/
-
-/** @name Exported functions (see also openjpeg.h) */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-
-
-/* ----------------------------------------------------------------------- */
-
-/**
- * Write formatted data to a string and send the string to a user callback.
- *
- * @param event_mgr Event handler
- * @param event_type Event type or callback to use to send the message
- * @param fmt Format-control string (plus optional arguments)
- *
- * @return Returns true if successful, returns false otherwise
- */
-OPJ_BOOL opj_event_msg(opj_event_mgr_t* event_mgr, OPJ_INT32 event_type,
- const char *fmt, ...);
-/* ----------------------------------------------------------------------- */
-
-/**
- * Set the event manager with the default callback function for the 3 levels.
- */
-void opj_set_default_event_handler(opj_event_mgr_t * p_manager);
-
-/*
-#ifdef __GNUC__
-#pragma GCC poison printf fprintf
-#endif
-*/
-
-/*@}*/
-
-/*@}*/
-
-#endif /* OPJ_EVENT_H */
diff --git a/contrib/libs/openjpeg/function_list.c b/contrib/libs/openjpeg/function_list.c
deleted file mode 100644
index e1c1af3897..0000000000
--- a/contrib/libs/openjpeg/function_list.c
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "opj_includes.h"
-
-/**
- * Default size of the validation list, if not sufficient, data will be reallocated with a double size.
- */
-#define OPJ_VALIDATION_SIZE 10
-
-opj_procedure_list_t * opj_procedure_list_create()
-{
- /* memory allocation */
- opj_procedure_list_t * l_validation = (opj_procedure_list_t *) opj_calloc(1,
- sizeof(opj_procedure_list_t));
- if (! l_validation) {
- return 00;
- }
- /* initialization */
- l_validation->m_nb_max_procedures = OPJ_VALIDATION_SIZE;
- l_validation->m_procedures = (opj_procedure*)opj_calloc(OPJ_VALIDATION_SIZE,
- sizeof(opj_procedure));
- if (! l_validation->m_procedures) {
- opj_free(l_validation);
- return 00;
- }
- return l_validation;
-}
-
-void opj_procedure_list_destroy(opj_procedure_list_t * p_list)
-{
- if (! p_list) {
- return;
- }
- /* initialization */
- if (p_list->m_procedures) {
- opj_free(p_list->m_procedures);
- }
- opj_free(p_list);
-}
-
-OPJ_BOOL opj_procedure_list_add_procedure(opj_procedure_list_t *
- p_validation_list, opj_procedure p_procedure, opj_event_mgr_t* p_manager)
-{
-
- assert(p_manager != NULL);
-
- if (p_validation_list->m_nb_max_procedures ==
- p_validation_list->m_nb_procedures) {
- opj_procedure * new_procedures;
-
- p_validation_list->m_nb_max_procedures += OPJ_VALIDATION_SIZE;
- new_procedures = (opj_procedure*)opj_realloc(
- p_validation_list->m_procedures,
- p_validation_list->m_nb_max_procedures * sizeof(opj_procedure));
- if (! new_procedures) {
- opj_free(p_validation_list->m_procedures);
- p_validation_list->m_nb_max_procedures = 0;
- p_validation_list->m_nb_procedures = 0;
- opj_event_msg(p_manager, EVT_ERROR,
- "Not enough memory to add a new validation procedure\n");
- return OPJ_FALSE;
- } else {
- p_validation_list->m_procedures = new_procedures;
- }
- }
- p_validation_list->m_procedures[p_validation_list->m_nb_procedures] =
- p_procedure;
- ++p_validation_list->m_nb_procedures;
-
- return OPJ_TRUE;
-}
-
-OPJ_UINT32 opj_procedure_list_get_nb_procedures(opj_procedure_list_t *
- p_validation_list)
-{
- return p_validation_list->m_nb_procedures;
-}
-
-opj_procedure* opj_procedure_list_get_first_procedure(opj_procedure_list_t *
- p_validation_list)
-{
- return p_validation_list->m_procedures;
-}
-
-void opj_procedure_list_clear(opj_procedure_list_t * p_validation_list)
-{
- p_validation_list->m_nb_procedures = 0;
-}
diff --git a/contrib/libs/openjpeg/function_list.h b/contrib/libs/openjpeg/function_list.h
deleted file mode 100644
index 81a3954a16..0000000000
--- a/contrib/libs/openjpeg/function_list.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef OPJ_FUNCTION_LIST_H
-#define OPJ_FUNCTION_LIST_H
-
-/**
- * @file function_list.h
- * @brief Implementation of a list of procedures.
-
- * The functions in validation.c aims to have access to a list of procedures.
-*/
-
-/** @defgroup VAL VAL - validation procedure*/
-/*@{*/
-
-/**************************************************************************************************
- ***************************************** FORWARD DECLARATION ************************************
- **************************************************************************************************/
-
-/**
- * declare a function pointer
- */
-typedef void (*opj_procedure)(void);
-
-/**
- * A list of procedures.
-*/
-typedef struct opj_procedure_list {
- /**
- * The number of validation procedures.
- */
- OPJ_UINT32 m_nb_procedures;
- /**
- * The number of the array of validation procedures.
- */
- OPJ_UINT32 m_nb_max_procedures;
- /**
- * The array of procedures.
- */
- opj_procedure * m_procedures;
-
-} opj_procedure_list_t;
-
-/* ----------------------------------------------------------------------- */
-
-/**
- * Creates a validation list.
- *
- * @return the newly created validation list.
- */
-opj_procedure_list_t * opj_procedure_list_create(void);
-
-/**
- * Destroys a validation list.
- *
- * @param p_list the list to destroy.
- */
-void opj_procedure_list_destroy(opj_procedure_list_t * p_list);
-
-/**
- * Adds a new validation procedure.
- *
- * @param p_validation_list the list of procedure to modify.
- * @param p_procedure the procedure to add.
- * @param p_manager the user event manager.
- *
- * @return OPJ_TRUE if the procedure could be added.
- */
-OPJ_BOOL opj_procedure_list_add_procedure(opj_procedure_list_t *
- p_validation_list, opj_procedure p_procedure, opj_event_mgr_t* p_manager);
-
-/**
- * Gets the number of validation procedures.
- *
- * @param p_validation_list the list of procedure to modify.
- *
- * @return the number of validation procedures.
- */
-OPJ_UINT32 opj_procedure_list_get_nb_procedures(opj_procedure_list_t *
- p_validation_list);
-
-/**
- * Gets the pointer on the first validation procedure. This function is similar to the C++
- * iterator class to iterate through all the procedures inside the validation list.
- * the caller does not take ownership of the pointer.
- *
- * @param p_validation_list the list of procedure to get the first procedure from.
- *
- * @return a pointer to the first procedure.
- */
-opj_procedure* opj_procedure_list_get_first_procedure(opj_procedure_list_t *
- p_validation_list);
-
-
-/**
- * Clears the list of validation procedures.
- *
- * @param p_validation_list the list of procedure to clear.
- *
- */
-void opj_procedure_list_clear(opj_procedure_list_t * p_validation_list);
-/*@}*/
-
-#endif /* OPJ_FUNCTION_LIST_H */
-
diff --git a/contrib/libs/openjpeg/ht_dec.c b/contrib/libs/openjpeg/ht_dec.c
deleted file mode 100644
index 2984f56098..0000000000
--- a/contrib/libs/openjpeg/ht_dec.c
+++ /dev/null
@@ -1,2689 +0,0 @@
-//***************************************************************************/
-// This software is released under the 2-Clause BSD license, included
-// below.
-//
-// Copyright (c) 2021, Aous Naman
-// Copyright (c) 2021, Kakadu Software Pty Ltd, Australia
-// Copyright (c) 2021, The University of New South Wales, Australia
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// 1. Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//
-// 2. Redistributions in binary form must reproduce the above copyright
-// notice, this list of conditions and the following disclaimer in the
-// documentation and/or other materials provided with the distribution.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
-// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//***************************************************************************/
-// This file is part of the OpenJpeg software implementation.
-// File: ht_dec.c
-// Author: Aous Naman
-// Date: 01 September 2021
-//***************************************************************************/
-
-//***************************************************************************/
-/** @file ht_dec.c
- * @brief implements HTJ2K block decoder
- */
-
-#include <assert.h>
-#include <string.h>
-#include "opj_includes.h"
-
-#include "t1_ht_luts.h"
-
-/////////////////////////////////////////////////////////////////////////////
-// compiler detection
-/////////////////////////////////////////////////////////////////////////////
-#ifdef _MSC_VER
-#define OPJ_COMPILER_MSVC
-#elif (defined __GNUC__)
-#define OPJ_COMPILER_GNUC
-#endif
-
-#if defined(OPJ_COMPILER_MSVC) && defined(_M_ARM64) \
- && !defined(_M_ARM64EC) && !defined(_M_CEE_PURE) && !defined(__CUDACC__) \
- && !defined(__INTEL_COMPILER) && !defined(__clang__)
-#define MSVC_NEON_INTRINSICS
-#endif
-
-#ifdef MSVC_NEON_INTRINSICS
-#include <arm64_neon.h>
-#endif
-
-//************************************************************************/
-/** @brief Displays the error message for disabling the decoding of SPP and
- * MRP passes
- */
-static OPJ_BOOL only_cleanup_pass_is_decoded = OPJ_FALSE;
-
-//************************************************************************/
-/** @brief Generates population count (i.e., the number of set bits)
- *
- * @param [in] val is the value for which population count is sought
- */
-static INLINE
-OPJ_UINT32 population_count(OPJ_UINT32 val)
-{
-#if defined(OPJ_COMPILER_MSVC) && (defined(_M_IX86) || defined(_M_AMD64))
- return (OPJ_UINT32)__popcnt(val);
-#elif defined(OPJ_COMPILER_MSVC) && defined(MSVC_NEON_INTRINSICS)
- const __n64 temp = neon_cnt(__uint64ToN64_v(val));
- return neon_addv8(temp).n8_i8[0];
-#elif (defined OPJ_COMPILER_GNUC)
- return (OPJ_UINT32)__builtin_popcount(val);
-#else
- val -= ((val >> 1) & 0x55555555);
- val = (((val >> 2) & 0x33333333) + (val & 0x33333333));
- val = (((val >> 4) + val) & 0x0f0f0f0f);
- val += (val >> 8);
- val += (val >> 16);
- return (OPJ_UINT32)(val & 0x0000003f);
-#endif
-}
-
-//************************************************************************/
-/** @brief Counts the number of leading zeros
- *
- * @param [in] val is the value for which leading zero count is sought
- */
-#ifdef OPJ_COMPILER_MSVC
-#pragma intrinsic(_BitScanReverse)
-#endif
-static INLINE
-OPJ_UINT32 count_leading_zeros(OPJ_UINT32 val)
-{
-#ifdef OPJ_COMPILER_MSVC
- unsigned long result = 0;
- _BitScanReverse(&result, val);
- return 31U ^ (OPJ_UINT32)result;
-#elif (defined OPJ_COMPILER_GNUC)
- return (OPJ_UINT32)__builtin_clz(val);
-#else
- val |= (val >> 1);
- val |= (val >> 2);
- val |= (val >> 4);
- val |= (val >> 8);
- val |= (val >> 16);
- return 32U - population_count(val);
-#endif
-}
-
-//************************************************************************/
-/** @brief Read a little-endian serialized UINT32.
- *
- * @param [in] dataIn pointer to byte stream to read from
- */
-static INLINE OPJ_UINT32 read_le_uint32(const void* dataIn)
-{
-#if defined(OPJ_BIG_ENDIAN)
- const OPJ_UINT8* data = (const OPJ_UINT8*)dataIn;
- return ((OPJ_UINT32)data[0]) | (OPJ_UINT32)(data[1] << 8) | (OPJ_UINT32)(
- data[2] << 16) | (((
- OPJ_UINT32)data[3]) <<
- 24U);
-#else
- return *(OPJ_UINT32*)dataIn;
-#endif
-}
-
-//************************************************************************/
-/** @brief MEL state structure for reading and decoding the MEL bitstream
- *
- * A number of events is decoded from the MEL bitstream ahead of time
- * and stored in run/num_runs.
- * Each run represents the number of zero events before a one event.
- */
-typedef struct dec_mel {
- // data decoding machinery
- OPJ_UINT8* data; //!<the address of data (or bitstream)
- OPJ_UINT64 tmp; //!<temporary buffer for read data
- int bits; //!<number of bits stored in tmp
- int size; //!<number of bytes in MEL code
- OPJ_BOOL unstuff; //!<true if the next bit needs to be unstuffed
- int k; //!<state of MEL decoder
-
- // queue of decoded runs
- int num_runs; //!<number of decoded runs left in runs (maximum 8)
- OPJ_UINT64 runs; //!<runs of decoded MEL codewords (7 bits/run)
-} dec_mel_t;
-
-//************************************************************************/
-/** @brief Reads and unstuffs the MEL bitstream
- *
- * This design needs more bytes in the codeblock buffer than the length
- * of the cleanup pass by up to 2 bytes.
- *
- * Unstuffing removes the MSB of the byte following a byte whose
- * value is 0xFF; this prevents sequences larger than 0xFF7F in value
- * from appearing the bitstream.
- *
- * @param [in] melp is a pointer to dec_mel_t structure
- */
-static INLINE
-void mel_read(dec_mel_t *melp)
-{
- OPJ_UINT32 val;
- int bits;
- OPJ_UINT32 t;
- OPJ_BOOL unstuff;
-
- if (melp->bits > 32) { //there are enough bits in the tmp variable
- return; // return without reading new data
- }
-
- val = 0xFFFFFFFF; // feed in 0xFF if buffer is exhausted
- if (melp->size > 4) { // if there is more than 4 bytes the MEL segment
- val = read_le_uint32(melp->data); // read 32 bits from MEL data
- melp->data += 4; // advance pointer
- melp->size -= 4; // reduce counter
- } else if (melp->size > 0) { // 4 or less
- OPJ_UINT32 m, v;
- int i = 0;
- while (melp->size > 1) {
- OPJ_UINT32 v = *melp->data++; // read one byte at a time
- OPJ_UINT32 m = ~(0xFFu << i); // mask of location
- val = (val & m) | (v << i); // put byte in its correct location
- --melp->size;
- i += 8;
- }
- // size equal to 1
- v = *melp->data++; // the one before the last is different
- v |= 0xF; // MEL and VLC segments can overlap
- m = ~(0xFFu << i);
- val = (val & m) | (v << i);
- --melp->size;
- }
-
- // next we unstuff them before adding them to the buffer
- bits = 32 - melp->unstuff; // number of bits in val, subtract 1 if
- // the previously read byte requires
- // unstuffing
-
- // data is unstuffed and accumulated in t
- // bits has the number of bits in t
- t = val & 0xFF;
- unstuff = ((val & 0xFF) == 0xFF); // true if the byte needs unstuffing
- bits -= unstuff; // there is one less bit in t if unstuffing is needed
- t = t << (8 - unstuff); // move up to make room for the next byte
-
- //this is a repeat of the above
- t |= (val >> 8) & 0xFF;
- unstuff = (((val >> 8) & 0xFF) == 0xFF);
- bits -= unstuff;
- t = t << (8 - unstuff);
-
- t |= (val >> 16) & 0xFF;
- unstuff = (((val >> 16) & 0xFF) == 0xFF);
- bits -= unstuff;
- t = t << (8 - unstuff);
-
- t |= (val >> 24) & 0xFF;
- melp->unstuff = (((val >> 24) & 0xFF) == 0xFF);
-
- // move t to tmp, and push the result all the way up, so we read from
- // the MSB
- melp->tmp |= ((OPJ_UINT64)t) << (64 - bits - melp->bits);
- melp->bits += bits; //increment the number of bits in tmp
-}
-
-//************************************************************************/
-/** @brief Decodes unstuffed MEL segment bits stored in tmp to runs
- *
- * Runs are stored in "runs" and the number of runs in "num_runs".
- * Each run represents a number of zero events that may or may not
- * terminate in a 1 event.
- * Each run is stored in 7 bits. The LSB is 1 if the run terminates in
- * a 1 event, 0 otherwise. The next 6 bits, for the case terminating
- * with 1, contain the number of consecutive 0 zero events * 2; for the
- * case terminating with 0, they store (number of consecutive 0 zero
- * events - 1) * 2.
- * A total of 6 bits (made up of 1 + 5) should have been enough.
- *
- * @param [in] melp is a pointer to dec_mel_t structure
- */
-static INLINE
-void mel_decode(dec_mel_t *melp)
-{
- static const int mel_exp[13] = { //MEL exponents
- 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5
- };
-
- if (melp->bits < 6) { // if there are less than 6 bits in tmp
- mel_read(melp); // then read from the MEL bitstream
- }
- // 6 bits is the largest decodable MEL cwd
-
- //repeat so long that there is enough decodable bits in tmp,
- // and the runs store is not full (num_runs < 8)
- while (melp->bits >= 6 && melp->num_runs < 8) {
- int eval = mel_exp[melp->k]; // number of bits associated with state
- int run = 0;
- if (melp->tmp & (1ull << 63)) { //The next bit to decode (stored in MSB)
- //one is found
- run = 1 << eval;
- run--; // consecutive runs of 0 events - 1
- melp->k = melp->k + 1 < 12 ? melp->k + 1 : 12;//increment, max is 12
- melp->tmp <<= 1; // consume one bit from tmp
- melp->bits -= 1;
- run = run << 1; // a stretch of zeros not terminating in one
- } else {
- //0 is found
- run = (int)(melp->tmp >> (63 - eval)) & ((1 << eval) - 1);
- melp->k = melp->k - 1 > 0 ? melp->k - 1 : 0; //decrement, min is 0
- melp->tmp <<= eval + 1; //consume eval + 1 bits (max is 6)
- melp->bits -= eval + 1;
- run = (run << 1) + 1; // a stretch of zeros terminating with one
- }
- eval = melp->num_runs * 7; // 7 bits per run
- melp->runs &= ~((OPJ_UINT64)0x3F << eval); // 6 bits are sufficient
- melp->runs |= ((OPJ_UINT64)run) << eval; // store the value in runs
- melp->num_runs++; // increment count
- }
-}
-
-//************************************************************************/
-/** @brief Initiates a dec_mel_t structure for MEL decoding and reads
- * some bytes in order to get the read address to a multiple
- * of 4
- *
- * @param [in] melp is a pointer to dec_mel_t structure
- * @param [in] bbuf is a pointer to byte buffer
- * @param [in] lcup is the length of MagSgn+MEL+VLC segments
- * @param [in] scup is the length of MEL+VLC segments
- */
-static INLINE
-OPJ_BOOL mel_init(dec_mel_t *melp, OPJ_UINT8* bbuf, int lcup, int scup)
-{
- int num;
- int i;
-
- melp->data = bbuf + lcup - scup; // move the pointer to the start of MEL
- melp->bits = 0; // 0 bits in tmp
- melp->tmp = 0; //
- melp->unstuff = OPJ_FALSE; // no unstuffing
- melp->size = scup - 1; // size is the length of MEL+VLC-1
- melp->k = 0; // 0 for state
- melp->num_runs = 0; // num_runs is 0
- melp->runs = 0; //
-
- //This code is borrowed; original is for a different architecture
- //These few lines take care of the case where data is not at a multiple
- // of 4 boundary. It reads 1,2,3 up to 4 bytes from the MEL segment
- num = 4 - (int)((intptr_t)(melp->data) & 0x3);
- for (i = 0; i < num; ++i) { // this code is similar to mel_read
- OPJ_UINT64 d;
- int d_bits;
-
- if (melp->unstuff == OPJ_TRUE && melp->data[0] > 0x8F) {
- return OPJ_FALSE;
- }
- d = (melp->size > 0) ? *melp->data : 0xFF; // if buffer is consumed
- // set data to 0xFF
- if (melp->size == 1) {
- d |= 0xF; //if this is MEL+VLC-1, set LSBs to 0xF
- }
- // see the standard
- melp->data += melp->size-- > 0; //increment if the end is not reached
- d_bits = 8 - melp->unstuff; //if unstuffing is needed, reduce by 1
- melp->tmp = (melp->tmp << d_bits) | d; //store bits in tmp
- melp->bits += d_bits; //increment tmp by number of bits
- melp->unstuff = ((d & 0xFF) == 0xFF); //true of next byte needs
- //unstuffing
- }
- melp->tmp <<= (64 - melp->bits); //push all the way up so the first bit
- // is the MSB
- return OPJ_TRUE;
-}
-
-//************************************************************************/
-/** @brief Retrieves one run from dec_mel_t; if there are no runs stored
- * MEL segment is decoded
- *
- * @param [in] melp is a pointer to dec_mel_t structure
- */
-static INLINE
-int mel_get_run(dec_mel_t *melp)
-{
- int t;
- if (melp->num_runs == 0) { //if no runs, decode more bit from MEL segment
- mel_decode(melp);
- }
-
- t = melp->runs & 0x7F; //retrieve one run
- melp->runs >>= 7; // remove the retrieved run
- melp->num_runs--;
- return t; // return run
-}
-
-//************************************************************************/
-/** @brief A structure for reading and unstuffing a segment that grows
- * backward, such as VLC and MRP
- */
-typedef struct rev_struct {
- //storage
- OPJ_UINT8* data; //!<pointer to where to read data
- OPJ_UINT64 tmp; //!<temporary buffer of read data
- OPJ_UINT32 bits; //!<number of bits stored in tmp
- int size; //!<number of bytes left
- OPJ_BOOL unstuff; //!<true if the last byte is more than 0x8F
- //!<then the current byte is unstuffed if it is 0x7F
-} rev_struct_t;
-
-//************************************************************************/
-/** @brief Read and unstuff data from a backwardly-growing segment
- *
- * This reader can read up to 8 bytes from before the VLC segment.
- * Care must be taken not read from unreadable memory, causing a
- * segmentation fault.
- *
- * Note that there is another subroutine rev_read_mrp that is slightly
- * different. The other one fills zeros when the buffer is exhausted.
- * This one basically does not care if the bytes are consumed, because
- * any extra data should not be used in the actual decoding.
- *
- * Unstuffing is needed to prevent sequences more than 0xFF8F from
- * appearing in the bits stream; since we are reading backward, we keep
- * watch when a value larger than 0x8F appears in the bitstream.
- * If the byte following this is 0x7F, we unstuff this byte (ignore the
- * MSB of that byte, which should be 0).
- *
- * @param [in] vlcp is a pointer to rev_struct_t structure
- */
-static INLINE
-void rev_read(rev_struct_t *vlcp)
-{
- OPJ_UINT32 val;
- OPJ_UINT32 tmp;
- OPJ_UINT32 bits;
- OPJ_BOOL unstuff;
-
- //process 4 bytes at a time
- if (vlcp->bits > 32) { // if there are more than 32 bits in tmp, then
- return; // reading 32 bits can overflow vlcp->tmp
- }
- val = 0;
- //the next line (the if statement) needs to be tested first
- if (vlcp->size > 3) { // if there are more than 3 bytes left in VLC
- // (vlcp->data - 3) move pointer back to read 32 bits at once
- val = read_le_uint32(vlcp->data - 3); // then read 32 bits
- vlcp->data -= 4; // move data pointer back by 4
- vlcp->size -= 4; // reduce available byte by 4
- } else if (vlcp->size > 0) { // 4 or less
- int i = 24;
- while (vlcp->size > 0) {
- OPJ_UINT32 v = *vlcp->data--; // read one byte at a time
- val |= (v << i); // put byte in its correct location
- --vlcp->size;
- i -= 8;
- }
- }
-
- //accumulate in tmp, number of bits in tmp are stored in bits
- tmp = val >> 24; //start with the MSB byte
-
- // test unstuff (previous byte is >0x8F), and this byte is 0x7F
- bits = 8u - ((vlcp->unstuff && (((val >> 24) & 0x7F) == 0x7F)) ? 1u : 0u);
- unstuff = (val >> 24) > 0x8F; //this is for the next byte
-
- tmp |= ((val >> 16) & 0xFF) << bits; //process the next byte
- bits += 8u - ((unstuff && (((val >> 16) & 0x7F) == 0x7F)) ? 1u : 0u);
- unstuff = ((val >> 16) & 0xFF) > 0x8F;
-
- tmp |= ((val >> 8) & 0xFF) << bits;
- bits += 8u - ((unstuff && (((val >> 8) & 0x7F) == 0x7F)) ? 1u : 0u);
- unstuff = ((val >> 8) & 0xFF) > 0x8F;
-
- tmp |= (val & 0xFF) << bits;
- bits += 8u - ((unstuff && ((val & 0x7F) == 0x7F)) ? 1u : 0u);
- unstuff = (val & 0xFF) > 0x8F;
-
- // now move the read and unstuffed bits into vlcp->tmp
- vlcp->tmp |= (OPJ_UINT64)tmp << vlcp->bits;
- vlcp->bits += bits;
- vlcp->unstuff = unstuff; // this for the next read
-}
-
-//************************************************************************/
-/** @brief Initiates the rev_struct_t structure and reads a few bytes to
- * move the read address to multiple of 4
- *
- * There is another similar rev_init_mrp subroutine. The difference is
- * that this one, rev_init, discards the first 12 bits (they have the
- * sum of the lengths of VLC and MEL segments), and first unstuff depends
- * on first 4 bits.
- *
- * @param [in] vlcp is a pointer to rev_struct_t structure
- * @param [in] data is a pointer to byte at the start of the cleanup pass
- * @param [in] lcup is the length of MagSgn+MEL+VLC segments
- * @param [in] scup is the length of MEL+VLC segments
- */
-static INLINE
-void rev_init(rev_struct_t *vlcp, OPJ_UINT8* data, int lcup, int scup)
-{
- OPJ_UINT32 d;
- int num, tnum, i;
-
- //first byte has only the upper 4 bits
- vlcp->data = data + lcup - 2;
-
- //size can not be larger than this, in fact it should be smaller
- vlcp->size = scup - 2;
-
- d = *vlcp->data--; // read one byte (this is a half byte)
- vlcp->tmp = d >> 4; // both initialize and set
- vlcp->bits = 4 - ((vlcp->tmp & 7) == 7); //check standard
- vlcp->unstuff = (d | 0xF) > 0x8F; //this is useful for the next byte
-
- //This code is designed for an architecture that read address should
- // align to the read size (address multiple of 4 if read size is 4)
- //These few lines take care of the case where data is not at a multiple
- // of 4 boundary. It reads 1,2,3 up to 4 bytes from the VLC bitstream.
- // To read 32 bits, read from (vlcp->data - 3)
- num = 1 + (int)((intptr_t)(vlcp->data) & 0x3);
- tnum = num < vlcp->size ? num : vlcp->size;
- for (i = 0; i < tnum; ++i) {
- OPJ_UINT64 d;
- OPJ_UINT32 d_bits;
- d = *vlcp->data--; // read one byte and move read pointer
- //check if the last byte was >0x8F (unstuff == true) and this is 0x7F
- d_bits = 8u - ((vlcp->unstuff && ((d & 0x7F) == 0x7F)) ? 1u : 0u);
- vlcp->tmp |= d << vlcp->bits; // move data to vlcp->tmp
- vlcp->bits += d_bits;
- vlcp->unstuff = d > 0x8F; // for next byte
- }
- vlcp->size -= tnum;
- rev_read(vlcp); // read another 32 buts
-}
-
-//************************************************************************/
-/** @brief Retrieves 32 bits from the head of a rev_struct structure
- *
- * By the end of this call, vlcp->tmp must have no less than 33 bits
- *
- * @param [in] vlcp is a pointer to rev_struct structure
- */
-static INLINE
-OPJ_UINT32 rev_fetch(rev_struct_t *vlcp)
-{
- if (vlcp->bits < 32) { // if there are less then 32 bits, read more
- rev_read(vlcp); // read 32 bits, but unstuffing might reduce this
- if (vlcp->bits < 32) { // if there is still space in vlcp->tmp for 32 bits
- rev_read(vlcp); // read another 32
- }
- }
- return (OPJ_UINT32)vlcp->tmp; // return the head (bottom-most) of vlcp->tmp
-}
-
-//************************************************************************/
-/** @brief Consumes num_bits from a rev_struct structure
- *
- * @param [in] vlcp is a pointer to rev_struct structure
- * @param [in] num_bits is the number of bits to be removed
- */
-static INLINE
-OPJ_UINT32 rev_advance(rev_struct_t *vlcp, OPJ_UINT32 num_bits)
-{
- assert(num_bits <= vlcp->bits); // vlcp->tmp must have more than num_bits
- vlcp->tmp >>= num_bits; // remove bits
- vlcp->bits -= num_bits; // decrement the number of bits
- return (OPJ_UINT32)vlcp->tmp;
-}
-
-//************************************************************************/
-/** @brief Reads and unstuffs from rev_struct
- *
- * This is different than rev_read in that this fills in zeros when the
- * the available data is consumed. The other does not care about the
- * values when all data is consumed.
- *
- * See rev_read for more information about unstuffing
- *
- * @param [in] mrp is a pointer to rev_struct structure
- */
-static INLINE
-void rev_read_mrp(rev_struct_t *mrp)
-{
- OPJ_UINT32 val;
- OPJ_UINT32 tmp;
- OPJ_UINT32 bits;
- OPJ_BOOL unstuff;
-
- //process 4 bytes at a time
- if (mrp->bits > 32) {
- return;
- }
- val = 0;
- if (mrp->size > 3) { // If there are 3 byte or more
- // (mrp->data - 3) move pointer back to read 32 bits at once
- val = read_le_uint32(mrp->data - 3); // read 32 bits
- mrp->data -= 4; // move back pointer
- mrp->size -= 4; // reduce count
- } else if (mrp->size > 0) {
- int i = 24;
- while (mrp->size > 0) {
- OPJ_UINT32 v = *mrp->data--; // read one byte at a time
- val |= (v << i); // put byte in its correct location
- --mrp->size;
- i -= 8;
- }
- }
-
-
- //accumulate in tmp, and keep count in bits
- tmp = val >> 24;
-
- //test if the last byte > 0x8F (unstuff must be true) and this is 0x7F
- bits = 8u - ((mrp->unstuff && (((val >> 24) & 0x7F) == 0x7F)) ? 1u : 0u);
- unstuff = (val >> 24) > 0x8F;
-
- //process the next byte
- tmp |= ((val >> 16) & 0xFF) << bits;
- bits += 8u - ((unstuff && (((val >> 16) & 0x7F) == 0x7F)) ? 1u : 0u);
- unstuff = ((val >> 16) & 0xFF) > 0x8F;
-
- tmp |= ((val >> 8) & 0xFF) << bits;
- bits += 8u - ((unstuff && (((val >> 8) & 0x7F) == 0x7F)) ? 1u : 0u);
- unstuff = ((val >> 8) & 0xFF) > 0x8F;
-
- tmp |= (val & 0xFF) << bits;
- bits += 8u - ((unstuff && ((val & 0x7F) == 0x7F)) ? 1u : 0u);
- unstuff = (val & 0xFF) > 0x8F;
-
- mrp->tmp |= (OPJ_UINT64)tmp << mrp->bits; // move data to mrp pointer
- mrp->bits += bits;
- mrp->unstuff = unstuff; // next byte
-}
-
-//************************************************************************/
-/** @brief Initialized rev_struct structure for MRP segment, and reads
- * a number of bytes such that the next 32 bits read are from
- * an address that is a multiple of 4. Note this is designed for
- * an architecture that read size must be compatible with the
- * alignment of the read address
- *
- * There is another similar subroutine rev_init. This subroutine does
- * NOT skip the first 12 bits, and starts with unstuff set to true.
- *
- * @param [in] mrp is a pointer to rev_struct structure
- * @param [in] data is a pointer to byte at the start of the cleanup pass
- * @param [in] lcup is the length of MagSgn+MEL+VLC segments
- * @param [in] len2 is the length of SPP+MRP segments
- */
-static INLINE
-void rev_init_mrp(rev_struct_t *mrp, OPJ_UINT8* data, int lcup, int len2)
-{
- int num, i;
-
- mrp->data = data + lcup + len2 - 1;
- mrp->size = len2;
- mrp->unstuff = OPJ_TRUE;
- mrp->bits = 0;
- mrp->tmp = 0;
-
- //This code is designed for an architecture that read address should
- // align to the read size (address multiple of 4 if read size is 4)
- //These few lines take care of the case where data is not at a multiple
- // of 4 boundary. It reads 1,2,3 up to 4 bytes from the MRP stream
- num = 1 + (int)((intptr_t)(mrp->data) & 0x3);
- for (i = 0; i < num; ++i) {
- OPJ_UINT64 d;
- OPJ_UINT32 d_bits;
-
- //read a byte, 0 if no more data
- d = (mrp->size-- > 0) ? *mrp->data-- : 0;
- //check if unstuffing is needed
- d_bits = 8u - ((mrp->unstuff && ((d & 0x7F) == 0x7F)) ? 1u : 0u);
- mrp->tmp |= d << mrp->bits; // move data to vlcp->tmp
- mrp->bits += d_bits;
- mrp->unstuff = d > 0x8F; // for next byte
- }
- rev_read_mrp(mrp);
-}
-
-//************************************************************************/
-/** @brief Retrieves 32 bits from the head of a rev_struct structure
- *
- * By the end of this call, mrp->tmp must have no less than 33 bits
- *
- * @param [in] mrp is a pointer to rev_struct structure
- */
-static INLINE
-OPJ_UINT32 rev_fetch_mrp(rev_struct_t *mrp)
-{
- if (mrp->bits < 32) { // if there are less than 32 bits in mrp->tmp
- rev_read_mrp(mrp); // read 30-32 bits from mrp
- if (mrp->bits < 32) { // if there is a space of 32 bits
- rev_read_mrp(mrp); // read more
- }
- }
- return (OPJ_UINT32)mrp->tmp; // return the head of mrp->tmp
-}
-
-//************************************************************************/
-/** @brief Consumes num_bits from a rev_struct structure
- *
- * @param [in] mrp is a pointer to rev_struct structure
- * @param [in] num_bits is the number of bits to be removed
- */
-static INLINE
-OPJ_UINT32 rev_advance_mrp(rev_struct_t *mrp, OPJ_UINT32 num_bits)
-{
- assert(num_bits <= mrp->bits); // we must not consume more than mrp->bits
- mrp->tmp >>= num_bits; // discard the lowest num_bits bits
- mrp->bits -= num_bits;
- return (OPJ_UINT32)mrp->tmp; // return data after consumption
-}
-
-//************************************************************************/
-/** @brief Decode initial UVLC to get the u value (or u_q)
- *
- * @param [in] vlc is the head of the VLC bitstream
- * @param [in] mode is 0, 1, 2, 3, or 4. Values in 0 to 3 are composed of
- * u_off of 1st quad and 2nd quad of a quad pair. The value
- * 4 occurs when both bits are 1, and the event decoded
- * from MEL bitstream is also 1.
- * @param [out] u is the u value (or u_q) + 1. Note: we produce u + 1;
- * this value is a partial calculation of u + kappa.
- */
-static INLINE
-OPJ_UINT32 decode_init_uvlc(OPJ_UINT32 vlc, OPJ_UINT32 mode, OPJ_UINT32 *u)
-{
- //table stores possible decoding three bits from vlc
- // there are 8 entries for xx1, x10, 100, 000, where x means do not care
- // table value is made up of
- // 2 bits in the LSB for prefix length
- // 3 bits for suffix length
- // 3 bits in the MSB for prefix value (u_pfx in Table 3 of ITU T.814)
- static const OPJ_UINT8 dec[8] = { // the index is the prefix codeword
- 3 | (5 << 2) | (5 << 5), //000 == 000, prefix codeword "000"
- 1 | (0 << 2) | (1 << 5), //001 == xx1, prefix codeword "1"
- 2 | (0 << 2) | (2 << 5), //010 == x10, prefix codeword "01"
- 1 | (0 << 2) | (1 << 5), //011 == xx1, prefix codeword "1"
- 3 | (1 << 2) | (3 << 5), //100 == 100, prefix codeword "001"
- 1 | (0 << 2) | (1 << 5), //101 == xx1, prefix codeword "1"
- 2 | (0 << 2) | (2 << 5), //110 == x10, prefix codeword "01"
- 1 | (0 << 2) | (1 << 5) //111 == xx1, prefix codeword "1"
- };
-
- OPJ_UINT32 consumed_bits = 0;
- if (mode == 0) { // both u_off are 0
- u[0] = u[1] = 1; //Kappa is 1 for initial line
- } else if (mode <= 2) { // u_off are either 01 or 10
- OPJ_UINT32 d;
- OPJ_UINT32 suffix_len;
-
- d = dec[vlc & 0x7]; //look at the least significant 3 bits
- vlc >>= d & 0x3; //prefix length
- consumed_bits += d & 0x3;
-
- suffix_len = ((d >> 2) & 0x7);
- consumed_bits += suffix_len;
-
- d = (d >> 5) + (vlc & ((1U << suffix_len) - 1)); // u value
- u[0] = (mode == 1) ? d + 1 : 1; // kappa is 1 for initial line
- u[1] = (mode == 1) ? 1 : d + 1; // kappa is 1 for initial line
- } else if (mode == 3) { // both u_off are 1, and MEL event is 0
- OPJ_UINT32 d1 = dec[vlc & 0x7]; // LSBs of VLC are prefix codeword
- vlc >>= d1 & 0x3; // Consume bits
- consumed_bits += d1 & 0x3;
-
- if ((d1 & 0x3) > 2) {
- OPJ_UINT32 suffix_len;
-
- //u_{q_2} prefix
- u[1] = (vlc & 1) + 1 + 1; //Kappa is 1 for initial line
- ++consumed_bits;
- vlc >>= 1;
-
- suffix_len = ((d1 >> 2) & 0x7);
- consumed_bits += suffix_len;
- d1 = (d1 >> 5) + (vlc & ((1U << suffix_len) - 1)); // u value
- u[0] = d1 + 1; //Kappa is 1 for initial line
- } else {
- OPJ_UINT32 d2;
- OPJ_UINT32 suffix_len;
-
- d2 = dec[vlc & 0x7]; // LSBs of VLC are prefix codeword
- vlc >>= d2 & 0x3; // Consume bits
- consumed_bits += d2 & 0x3;
-
- suffix_len = ((d1 >> 2) & 0x7);
- consumed_bits += suffix_len;
-
- d1 = (d1 >> 5) + (vlc & ((1U << suffix_len) - 1)); // u value
- u[0] = d1 + 1; //Kappa is 1 for initial line
- vlc >>= suffix_len;
-
- suffix_len = ((d2 >> 2) & 0x7);
- consumed_bits += suffix_len;
-
- d2 = (d2 >> 5) + (vlc & ((1U << suffix_len) - 1)); // u value
- u[1] = d2 + 1; //Kappa is 1 for initial line
- }
- } else if (mode == 4) { // both u_off are 1, and MEL event is 1
- OPJ_UINT32 d1;
- OPJ_UINT32 d2;
- OPJ_UINT32 suffix_len;
-
- d1 = dec[vlc & 0x7]; // LSBs of VLC are prefix codeword
- vlc >>= d1 & 0x3; // Consume bits
- consumed_bits += d1 & 0x3;
-
- d2 = dec[vlc & 0x7]; // LSBs of VLC are prefix codeword
- vlc >>= d2 & 0x3; // Consume bits
- consumed_bits += d2 & 0x3;
-
- suffix_len = ((d1 >> 2) & 0x7);
- consumed_bits += suffix_len;
-
- d1 = (d1 >> 5) + (vlc & ((1U << suffix_len) - 1)); // u value
- u[0] = d1 + 3; // add 2+kappa
- vlc >>= suffix_len;
-
- suffix_len = ((d2 >> 2) & 0x7);
- consumed_bits += suffix_len;
-
- d2 = (d2 >> 5) + (vlc & ((1U << suffix_len) - 1)); // u value
- u[1] = d2 + 3; // add 2+kappa
- }
- return consumed_bits;
-}
-
-//************************************************************************/
-/** @brief Decode non-initial UVLC to get the u value (or u_q)
- *
- * @param [in] vlc is the head of the VLC bitstream
- * @param [in] mode is 0, 1, 2, or 3. The 1st bit is u_off of 1st quad
- * and 2nd for 2nd quad of a quad pair
- * @param [out] u is the u value (or u_q) + 1. Note: we produce u + 1;
- * this value is a partial calculation of u + kappa.
- */
-static INLINE
-OPJ_UINT32 decode_noninit_uvlc(OPJ_UINT32 vlc, OPJ_UINT32 mode, OPJ_UINT32 *u)
-{
- //table stores possible decoding three bits from vlc
- // there are 8 entries for xx1, x10, 100, 000, where x means do not care
- // table value is made up of
- // 2 bits in the LSB for prefix length
- // 3 bits for suffix length
- // 3 bits in the MSB for prefix value (u_pfx in Table 3 of ITU T.814)
- static const OPJ_UINT8 dec[8] = {
- 3 | (5 << 2) | (5 << 5), //000 == 000, prefix codeword "000"
- 1 | (0 << 2) | (1 << 5), //001 == xx1, prefix codeword "1"
- 2 | (0 << 2) | (2 << 5), //010 == x10, prefix codeword "01"
- 1 | (0 << 2) | (1 << 5), //011 == xx1, prefix codeword "1"
- 3 | (1 << 2) | (3 << 5), //100 == 100, prefix codeword "001"
- 1 | (0 << 2) | (1 << 5), //101 == xx1, prefix codeword "1"
- 2 | (0 << 2) | (2 << 5), //110 == x10, prefix codeword "01"
- 1 | (0 << 2) | (1 << 5) //111 == xx1, prefix codeword "1"
- };
-
- OPJ_UINT32 consumed_bits = 0;
- if (mode == 0) {
- u[0] = u[1] = 1; //for kappa
- } else if (mode <= 2) { //u_off are either 01 or 10
- OPJ_UINT32 d;
- OPJ_UINT32 suffix_len;
-
- d = dec[vlc & 0x7]; //look at the least significant 3 bits
- vlc >>= d & 0x3; //prefix length
- consumed_bits += d & 0x3;
-
- suffix_len = ((d >> 2) & 0x7);
- consumed_bits += suffix_len;
-
- d = (d >> 5) + (vlc & ((1U << suffix_len) - 1)); // u value
- u[0] = (mode == 1) ? d + 1 : 1; //for kappa
- u[1] = (mode == 1) ? 1 : d + 1; //for kappa
- } else if (mode == 3) { // both u_off are 1
- OPJ_UINT32 d1;
- OPJ_UINT32 d2;
- OPJ_UINT32 suffix_len;
-
- d1 = dec[vlc & 0x7]; // LSBs of VLC are prefix codeword
- vlc >>= d1 & 0x3; // Consume bits
- consumed_bits += d1 & 0x3;
-
- d2 = dec[vlc & 0x7]; // LSBs of VLC are prefix codeword
- vlc >>= d2 & 0x3; // Consume bits
- consumed_bits += d2 & 0x3;
-
- suffix_len = ((d1 >> 2) & 0x7);
- consumed_bits += suffix_len;
-
- d1 = (d1 >> 5) + (vlc & ((1U << suffix_len) - 1)); // u value
- u[0] = d1 + 1; //1 for kappa
- vlc >>= suffix_len;
-
- suffix_len = ((d2 >> 2) & 0x7);
- consumed_bits += suffix_len;
-
- d2 = (d2 >> 5) + (vlc & ((1U << suffix_len) - 1)); // u value
- u[1] = d2 + 1; //1 for kappa
- }
- return consumed_bits;
-}
-
-//************************************************************************/
-/** @brief State structure for reading and unstuffing of forward-growing
- * bitstreams; these are: MagSgn and SPP bitstreams
- */
-typedef struct frwd_struct {
- const OPJ_UINT8* data; //!<pointer to bitstream
- OPJ_UINT64 tmp; //!<temporary buffer of read data
- OPJ_UINT32 bits; //!<number of bits stored in tmp
- OPJ_BOOL unstuff; //!<true if a bit needs to be unstuffed from next byte
- int size; //!<size of data
- OPJ_UINT32 X; //!<0 or 0xFF, X's are inserted at end of bitstream
-} frwd_struct_t;
-
-//************************************************************************/
-/** @brief Read and unstuffs 32 bits from forward-growing bitstream
- *
- * A subroutine to read from both the MagSgn or SPP bitstreams;
- * in particular, when MagSgn bitstream is consumed, 0xFF's are fed,
- * while when SPP is exhausted 0's are fed in.
- * X controls this value.
- *
- * Unstuffing prevent sequences that are more than 0xFF7F from appearing
- * in the compressed sequence. So whenever a value of 0xFF is coded, the
- * MSB of the next byte is set 0 and must be ignored during decoding.
- *
- * Reading can go beyond the end of buffer by up to 3 bytes.
- *
- * @param [in] msp is a pointer to frwd_struct_t structure
- *
- */
-static INLINE
-void frwd_read(frwd_struct_t *msp)
-{
- OPJ_UINT32 val;
- OPJ_UINT32 bits;
- OPJ_UINT32 t;
- OPJ_BOOL unstuff;
-
- assert(msp->bits <= 32); // assert that there is a space for 32 bits
-
- val = 0u;
- if (msp->size > 3) {
- val = read_le_uint32(msp->data); // read 32 bits
- msp->data += 4; // increment pointer
- msp->size -= 4; // reduce size
- } else if (msp->size > 0) {
- int i = 0;
- val = msp->X != 0 ? 0xFFFFFFFFu : 0;
- while (msp->size > 0) {
- OPJ_UINT32 v = *msp->data++; // read one byte at a time
- OPJ_UINT32 m = ~(0xFFu << i); // mask of location
- val = (val & m) | (v << i); // put one byte in its correct location
- --msp->size;
- i += 8;
- }
- } else {
- val = msp->X != 0 ? 0xFFFFFFFFu : 0;
- }
-
- // we accumulate in t and keep a count of the number of bits in bits
- bits = 8u - (msp->unstuff ? 1u : 0u);
- t = val & 0xFF;
- unstuff = ((val & 0xFF) == 0xFF); // Do we need unstuffing next?
-
- t |= ((val >> 8) & 0xFF) << bits;
- bits += 8u - (unstuff ? 1u : 0u);
- unstuff = (((val >> 8) & 0xFF) == 0xFF);
-
- t |= ((val >> 16) & 0xFF) << bits;
- bits += 8u - (unstuff ? 1u : 0u);
- unstuff = (((val >> 16) & 0xFF) == 0xFF);
-
- t |= ((val >> 24) & 0xFF) << bits;
- bits += 8u - (unstuff ? 1u : 0u);
- msp->unstuff = (((val >> 24) & 0xFF) == 0xFF); // for next byte
-
- msp->tmp |= ((OPJ_UINT64)t) << msp->bits; // move data to msp->tmp
- msp->bits += bits;
-}
-
-//************************************************************************/
-/** @brief Initialize frwd_struct_t struct and reads some bytes
- *
- * @param [in] msp is a pointer to frwd_struct_t
- * @param [in] data is a pointer to the start of data
- * @param [in] size is the number of byte in the bitstream
- * @param [in] X is the value fed in when the bitstream is exhausted.
- * See frwd_read.
- */
-static INLINE
-void frwd_init(frwd_struct_t *msp, const OPJ_UINT8* data, int size,
- OPJ_UINT32 X)
-{
- int num, i;
-
- msp->data = data;
- msp->tmp = 0;
- msp->bits = 0;
- msp->unstuff = OPJ_FALSE;
- msp->size = size;
- msp->X = X;
- assert(msp->X == 0 || msp->X == 0xFF);
-
- //This code is designed for an architecture that read address should
- // align to the read size (address multiple of 4 if read size is 4)
- //These few lines take care of the case where data is not at a multiple
- // of 4 boundary. It reads 1,2,3 up to 4 bytes from the bitstream
- num = 4 - (int)((intptr_t)(msp->data) & 0x3);
- for (i = 0; i < num; ++i) {
- OPJ_UINT64 d;
- //read a byte if the buffer is not exhausted, otherwise set it to X
- d = msp->size-- > 0 ? *msp->data++ : msp->X;
- msp->tmp |= (d << msp->bits); // store data in msp->tmp
- msp->bits += 8u - (msp->unstuff ? 1u : 0u); // number of bits added to msp->tmp
- msp->unstuff = ((d & 0xFF) == 0xFF); // unstuffing for next byte
- }
- frwd_read(msp); // read 32 bits more
-}
-
-//************************************************************************/
-/** @brief Consume num_bits bits from the bitstream of frwd_struct_t
- *
- * @param [in] msp is a pointer to frwd_struct_t
- * @param [in] num_bits is the number of bit to consume
- */
-static INLINE
-void frwd_advance(frwd_struct_t *msp, OPJ_UINT32 num_bits)
-{
- assert(num_bits <= msp->bits);
- msp->tmp >>= num_bits; // consume num_bits
- msp->bits -= num_bits;
-}
-
-//************************************************************************/
-/** @brief Fetches 32 bits from the frwd_struct_t bitstream
- *
- * @param [in] msp is a pointer to frwd_struct_t
- */
-static INLINE
-OPJ_UINT32 frwd_fetch(frwd_struct_t *msp)
-{
- if (msp->bits < 32) {
- frwd_read(msp);
- if (msp->bits < 32) { //need to test
- frwd_read(msp);
- }
- }
- return (OPJ_UINT32)msp->tmp;
-}
-
-//************************************************************************/
-/** @brief Allocates T1 buffers
- *
- * @param [in, out] t1 is codeblock coefficients storage
- * @param [in] w is codeblock width
- * @param [in] h is codeblock height
- */
-static OPJ_BOOL opj_t1_allocate_buffers(
- opj_t1_t *t1,
- OPJ_UINT32 w,
- OPJ_UINT32 h)
-{
- OPJ_UINT32 flagssize;
-
- /* No risk of overflow. Prior checks ensure those assert are met */
- /* They are per the specification */
- assert(w <= 1024);
- assert(h <= 1024);
- assert(w * h <= 4096);
-
- /* encoder uses tile buffer, so no need to allocate */
- {
- OPJ_UINT32 datasize = w * h;
-
- if (datasize > t1->datasize) {
- opj_aligned_free(t1->data);
- t1->data = (OPJ_INT32*)
- opj_aligned_malloc(datasize * sizeof(OPJ_INT32));
- if (!t1->data) {
- /* FIXME event manager error callback */
- return OPJ_FALSE;
- }
- t1->datasize = datasize;
- }
- /* memset first arg is declared to never be null by gcc */
- if (t1->data != NULL) {
- memset(t1->data, 0, datasize * sizeof(OPJ_INT32));
- }
- }
-
- // We expand these buffers to multiples of 16 bytes.
- // We need 4 buffers of 129 integers each, expanded to 132 integers each
- // We also need 514 bytes of buffer, expanded to 528 bytes
- flagssize = 132U * sizeof(OPJ_UINT32) * 4U; // expanded to multiple of 16
- flagssize += 528U; // 514 expanded to multiples of 16
-
- {
- if (flagssize > t1->flagssize) {
-
- opj_aligned_free(t1->flags);
- t1->flags = (opj_flag_t*) opj_aligned_malloc(flagssize * sizeof(opj_flag_t));
- if (!t1->flags) {
- /* FIXME event manager error callback */
- return OPJ_FALSE;
- }
- }
- t1->flagssize = flagssize;
-
- memset(t1->flags, 0, flagssize * sizeof(opj_flag_t));
- }
-
- t1->w = w;
- t1->h = h;
-
- return OPJ_TRUE;
-}
-
-/**
-Decode 1 HT code-block
-@param t1 T1 handle
-@param cblk Code-block coding parameters
-@param orient
-@param roishift Region of interest shifting value
-@param cblksty Code-block style
-@param p_manager the event manager
-@param p_manager_mutex mutex for the event manager
-@param check_pterm whether PTERM correct termination should be checked
-*/
-OPJ_BOOL opj_t1_ht_decode_cblk(opj_t1_t *t1,
- opj_tcd_cblk_dec_t* cblk,
- OPJ_UINT32 orient,
- OPJ_UINT32 roishift,
- OPJ_UINT32 cblksty,
- opj_event_mgr_t *p_manager,
- opj_mutex_t* p_manager_mutex,
- OPJ_BOOL check_pterm);
-
-//************************************************************************/
-/** @brief Decodes one codeblock, processing the cleanup, siginificance
- * propagation, and magnitude refinement pass
- *
- * @param [in, out] t1 is codeblock coefficients storage
- * @param [in] cblk is codeblock properties
- * @param [in] orient is the subband to which the codeblock belongs (not needed)
- * @param [in] roishift is region of interest shift
- * @param [in] cblksty is codeblock style
- * @param [in] p_manager is events print manager
- * @param [in] p_manager_mutex a mutex to control access to p_manager
- * @param [in] check_pterm: check termination (not used)
- */
-OPJ_BOOL opj_t1_ht_decode_cblk(opj_t1_t *t1,
- opj_tcd_cblk_dec_t* cblk,
- OPJ_UINT32 orient,
- OPJ_UINT32 roishift,
- OPJ_UINT32 cblksty,
- opj_event_mgr_t *p_manager,
- opj_mutex_t* p_manager_mutex,
- OPJ_BOOL check_pterm)
-{
- OPJ_BYTE* cblkdata = NULL;
- OPJ_UINT8* coded_data;
- OPJ_UINT32* decoded_data;
- OPJ_UINT32 zero_bplanes;
- OPJ_UINT32 num_passes;
- OPJ_UINT32 lengths1;
- OPJ_UINT32 lengths2;
- OPJ_INT32 width;
- OPJ_INT32 height;
- OPJ_INT32 stride;
- OPJ_UINT32 *pflags, *sigma1, *sigma2, *mbr1, *mbr2, *sip, sip_shift;
- OPJ_UINT32 p;
- OPJ_UINT32 zero_bplanes_p1;
- int lcup, scup;
- dec_mel_t mel;
- rev_struct_t vlc;
- frwd_struct_t magsgn;
- frwd_struct_t sigprop;
- rev_struct_t magref;
- OPJ_UINT8 *lsp, *line_state;
- int run;
- OPJ_UINT32 vlc_val; // fetched data from VLC bitstream
- OPJ_UINT32 qinf[2];
- OPJ_UINT32 c_q;
- OPJ_UINT32* sp;
- OPJ_INT32 x, y; // loop indices
- OPJ_BOOL stripe_causal = (cblksty & J2K_CCP_CBLKSTY_VSC) != 0;
- OPJ_UINT32 cblk_len = 0;
-
- (void)(orient); // stops unused parameter message
- (void)(check_pterm); // stops unused parameter message
-
- // We ignor orient, because the same decoder is used for all subbands
- // We also ignore check_pterm, because I am not sure how it applies
- if (roishift != 0) {
- if (p_manager_mutex) {
- opj_mutex_lock(p_manager_mutex);
- }
- opj_event_msg(p_manager, EVT_ERROR, "We do not support ROI in decoding "
- "HT codeblocks\n");
- if (p_manager_mutex) {
- opj_mutex_unlock(p_manager_mutex);
- }
- return OPJ_FALSE;
- }
-
- if (!opj_t1_allocate_buffers(
- t1,
- (OPJ_UINT32)(cblk->x1 - cblk->x0),
- (OPJ_UINT32)(cblk->y1 - cblk->y0))) {
- return OPJ_FALSE;
- }
-
- if (cblk->Mb == 0) {
- return OPJ_TRUE;
- }
-
- /* numbps = Mb + 1 - zero_bplanes, Mb = Kmax, zero_bplanes = missing_msbs */
- zero_bplanes = (cblk->Mb + 1) - cblk->numbps;
-
- /* Compute whole codeblock length from chunk lengths */
- cblk_len = 0;
- {
- OPJ_UINT32 i;
- for (i = 0; i < cblk->numchunks; i++) {
- cblk_len += cblk->chunks[i].len;
- }
- }
-
- if (cblk->numchunks > 1 || t1->mustuse_cblkdatabuffer) {
- OPJ_UINT32 i;
-
- /* Allocate temporary memory if needed */
- if (cblk_len > t1->cblkdatabuffersize) {
- cblkdata = (OPJ_BYTE*)opj_realloc(
- t1->cblkdatabuffer, cblk_len);
- if (cblkdata == NULL) {
- return OPJ_FALSE;
- }
- t1->cblkdatabuffer = cblkdata;
- t1->cblkdatabuffersize = cblk_len;
- }
-
- /* Concatenate all chunks */
- cblkdata = t1->cblkdatabuffer;
- if (cblkdata == NULL) {
- return OPJ_FALSE;
- }
- cblk_len = 0;
- for (i = 0; i < cblk->numchunks; i++) {
- memcpy(cblkdata + cblk_len, cblk->chunks[i].data, cblk->chunks[i].len);
- cblk_len += cblk->chunks[i].len;
- }
- } else if (cblk->numchunks == 1) {
- cblkdata = cblk->chunks[0].data;
- } else {
- /* Not sure if that can happen in practice, but avoid Coverity to */
- /* think we will dereference a null cblkdta pointer */
- return OPJ_TRUE;
- }
-
- // OPJ_BYTE* coded_data is a pointer to bitstream
- coded_data = cblkdata;
- // OPJ_UINT32* decoded_data is a pointer to decoded codeblock data buf.
- decoded_data = (OPJ_UINT32*)t1->data;
- // OPJ_UINT32 num_passes is the number of passes: 1 if CUP only, 2 for
- // CUP+SPP, and 3 for CUP+SPP+MRP
- num_passes = cblk->numsegs > 0 ? cblk->segs[0].real_num_passes : 0;
- num_passes += cblk->numsegs > 1 ? cblk->segs[1].real_num_passes : 0;
- // OPJ_UINT32 lengths1 is the length of cleanup pass
- lengths1 = num_passes > 0 ? cblk->segs[0].len : 0;
- // OPJ_UINT32 lengths2 is the length of refinement passes (either SPP only or SPP+MRP)
- lengths2 = num_passes > 1 ? cblk->segs[1].len : 0;
- // OPJ_INT32 width is the decoded codeblock width
- width = cblk->x1 - cblk->x0;
- // OPJ_INT32 height is the decoded codeblock height
- height = cblk->y1 - cblk->y0;
- // OPJ_INT32 stride is the decoded codeblock buffer stride
- stride = width;
-
- /* sigma1 and sigma2 contains significant (i.e., non-zero) pixel
- * locations. The buffers are used interchangeably, because we need
- * more than 4 rows of significance information at a given time.
- * Each 32 bits contain significance information for 4 rows of 8
- * columns each. If we denote 32 bits by 0xaaaaaaaa, the each "a" is
- * called a nibble and has significance information for 4 rows.
- * The least significant nibble has information for the first column,
- * and so on. The nibble's LSB is for the first row, and so on.
- * Since, at most, we can have 1024 columns in a quad, we need 128
- * entries; we added 1 for convenience when propagation of signifcance
- * goes outside the structure
- * To work in OpenJPEG these buffers has been expanded to 132.
- */
- // OPJ_UINT32 *pflags, *sigma1, *sigma2, *mbr1, *mbr2, *sip, sip_shift;
- pflags = (OPJ_UINT32 *)t1->flags;
- sigma1 = pflags;
- sigma2 = sigma1 + 132;
- // mbr arrangement is similar to sigma; mbr contains locations
- // that become significant during significance propagation pass
- mbr1 = sigma2 + 132;
- mbr2 = mbr1 + 132;
- //a pointer to sigma
- sip = sigma1; //pointers to arrays to be used interchangeably
- sip_shift = 0; //the amount of shift needed for sigma
-
- if (num_passes > 1 && lengths2 == 0) {
- if (p_manager_mutex) {
- opj_mutex_lock(p_manager_mutex);
- }
- opj_event_msg(p_manager, EVT_WARNING, "A malformed codeblock that has "
- "more than one coding pass, but zero length for "
- "2nd and potentially the 3rd pass in an HT codeblock.\n");
- if (p_manager_mutex) {
- opj_mutex_unlock(p_manager_mutex);
- }
- num_passes = 1;
- }
- if (num_passes > 3) {
- if (p_manager_mutex) {
- opj_mutex_lock(p_manager_mutex);
- }
- opj_event_msg(p_manager, EVT_ERROR, "We do not support more than 3 "
- "coding passes in an HT codeblock; This codeblocks has "
- "%d passes.\n", num_passes);
- if (p_manager_mutex) {
- opj_mutex_unlock(p_manager_mutex);
- }
- return OPJ_FALSE;
- }
-
- if (cblk->Mb > 30) {
- /* This check is better moved to opj_t2_read_packet_header() in t2.c
- We do not have enough precision to decode any passes
- The design of openjpeg assumes that the bits of a 32-bit integer are
- assigned as follows:
- bit 31 is for sign
- bits 30-1 are for magnitude
- bit 0 is for the center of the quantization bin
- Therefore we can only do values of cblk->Mb <= 30
- */
- if (p_manager_mutex) {
- opj_mutex_lock(p_manager_mutex);
- }
- opj_event_msg(p_manager, EVT_ERROR, "32 bits are not enough to "
- "decode this codeblock, since the number of "
- "bitplane, %d, is larger than 30.\n", cblk->Mb);
- if (p_manager_mutex) {
- opj_mutex_unlock(p_manager_mutex);
- }
- return OPJ_FALSE;
- }
- if (zero_bplanes > cblk->Mb) {
- /* This check is better moved to opj_t2_read_packet_header() in t2.c,
- in the line "l_cblk->numbps = (OPJ_UINT32)l_band->numbps + 1 - i;"
- where i is the zero bitplanes, and should be no larger than cblk->Mb
- We cannot have more zero bitplanes than there are planes. */
- if (p_manager_mutex) {
- opj_mutex_lock(p_manager_mutex);
- }
- opj_event_msg(p_manager, EVT_ERROR, "Malformed HT codeblock. "
- "Decoding this codeblock is stopped. There are "
- "%d zero bitplanes in %d bitplanes.\n",
- zero_bplanes, cblk->Mb);
-
- if (p_manager_mutex) {
- opj_mutex_unlock(p_manager_mutex);
- }
- return OPJ_FALSE;
- } else if (zero_bplanes == cblk->Mb && num_passes > 1) {
- /* When the number of zero bitplanes is equal to the number of bitplanes,
- only the cleanup pass makes sense*/
- if (only_cleanup_pass_is_decoded == OPJ_FALSE) {
- if (p_manager_mutex) {
- opj_mutex_lock(p_manager_mutex);
- }
- /* We have a second check to prevent the possibility of an overrun condition,
- in the very unlikely event of a second thread discovering that
- only_cleanup_pass_is_decoded is false before the first thread changing
- the condition. */
- if (only_cleanup_pass_is_decoded == OPJ_FALSE) {
- only_cleanup_pass_is_decoded = OPJ_TRUE;
- opj_event_msg(p_manager, EVT_WARNING, "Malformed HT codeblock. "
- "When the number of zero planes bitplanes is "
- "equal to the number of bitplanes, only the cleanup "
- "pass makes sense, but we have %d passes in this "
- "codeblock. Therefore, only the cleanup pass will be "
- "decoded. This message will not be displayed again.\n",
- num_passes);
- }
- if (p_manager_mutex) {
- opj_mutex_unlock(p_manager_mutex);
- }
- }
- num_passes = 1;
- }
-
- /* OPJ_UINT32 */
- p = cblk->numbps;
-
- // OPJ_UINT32 zero planes plus 1
- zero_bplanes_p1 = zero_bplanes + 1;
-
- if (lengths1 < 2 || (OPJ_UINT32)lengths1 > cblk_len ||
- (OPJ_UINT32)(lengths1 + lengths2) > cblk_len) {
- if (p_manager_mutex) {
- opj_mutex_lock(p_manager_mutex);
- }
- opj_event_msg(p_manager, EVT_ERROR, "Malformed HT codeblock. "
- "Invalid codeblock length values.\n");
-
- if (p_manager_mutex) {
- opj_mutex_unlock(p_manager_mutex);
- }
- return OPJ_FALSE;
- }
- // read scup and fix the bytes there
- lcup = (int)lengths1; // length of CUP
- //scup is the length of MEL + VLC
- scup = (((int)coded_data[lcup - 1]) << 4) + (coded_data[lcup - 2] & 0xF);
- if (scup < 2 || scup > lcup || scup > 4079) { //something is wrong
- /* The standard stipulates 2 <= Scup <= min(Lcup, 4079) */
- if (p_manager_mutex) {
- opj_mutex_lock(p_manager_mutex);
- }
- opj_event_msg(p_manager, EVT_ERROR, "Malformed HT codeblock. "
- "One of the following condition is not met: "
- "2 <= Scup <= min(Lcup, 4079)\n");
-
- if (p_manager_mutex) {
- opj_mutex_unlock(p_manager_mutex);
- }
- return OPJ_FALSE;
- }
-
- // init structures
- if (mel_init(&mel, coded_data, lcup, scup) == OPJ_FALSE) {
- if (p_manager_mutex) {
- opj_mutex_lock(p_manager_mutex);
- }
- opj_event_msg(p_manager, EVT_ERROR, "Malformed HT codeblock. "
- "Incorrect MEL segment sequence.\n");
- if (p_manager_mutex) {
- opj_mutex_unlock(p_manager_mutex);
- }
- return OPJ_FALSE;
- }
- rev_init(&vlc, coded_data, lcup, scup);
- frwd_init(&magsgn, coded_data, lcup - scup, 0xFF);
- if (num_passes > 1) { // needs to be tested
- frwd_init(&sigprop, coded_data + lengths1, (int)lengths2, 0);
- }
- if (num_passes > 2) {
- rev_init_mrp(&magref, coded_data, (int)lengths1, (int)lengths2);
- }
-
- /** State storage
- * One byte per quad; for 1024 columns, or 512 quads, we need
- * 512 bytes. We are using 2 extra bytes one on the left and one on
- * the right for convenience.
- *
- * The MSB bit in each byte is (\sigma^nw | \sigma^n), and the 7 LSBs
- * contain max(E^nw | E^n)
- */
-
- // 514 is enough for a block width of 1024, +2 extra
- // here expanded to 528
- line_state = (OPJ_UINT8 *)(mbr2 + 132);
-
- //initial 2 lines
- /////////////////
- lsp = line_state; // point to line state
- lsp[0] = 0; // for initial row of quad, we set to 0
- run = mel_get_run(&mel); // decode runs of events from MEL bitstrm
- // data represented as runs of 0 events
- // See mel_decode description
- qinf[0] = qinf[1] = 0; // quad info decoded from VLC bitstream
- c_q = 0; // context for quad q
- sp = decoded_data; // decoded codeblock samples
- // vlc_val; // fetched data from VLC bitstream
-
- for (x = 0; x < width; x += 4) { // one iteration per quad pair
- OPJ_UINT32 U_q[2]; // u values for the quad pair
- OPJ_UINT32 uvlc_mode;
- OPJ_UINT32 consumed_bits;
- OPJ_UINT32 m_n, v_n;
- OPJ_UINT32 ms_val;
- OPJ_UINT32 locs;
-
- // decode VLC
- /////////////
-
- //first quad
- // Get the head of the VLC bitstream. One fetch is enough for two
- // quads, since the largest VLC code is 7 bits, and maximum number of
- // bits used for u is 8. Therefore for two quads we need 30 bits
- // (if we include unstuffing, then 32 bits are enough, since we have
- // a maximum of one stuffing per two bytes)
- vlc_val = rev_fetch(&vlc);
-
- //decode VLC using the context c_q and the head of the VLC bitstream
- qinf[0] = vlc_tbl0[(c_q << 7) | (vlc_val & 0x7F) ];
-
- if (c_q == 0) { // if zero context, we need to use one MEL event
- run -= 2; //the number of 0 events is multiplied by 2, so subtract 2
-
- // Is the run terminated in 1? if so, use decoded VLC code,
- // otherwise, discard decoded data, since we will decoded again
- // using a different context
- qinf[0] = (run == -1) ? qinf[0] : 0;
-
- // is run -1 or -2? this means a run has been consumed
- if (run < 0) {
- run = mel_get_run(&mel); // get another run
- }
- }
-
- // prepare context for the next quad; eqn. 1 in ITU T.814
- c_q = ((qinf[0] & 0x10) >> 4) | ((qinf[0] & 0xE0) >> 5);
-
- //remove data from vlc stream (0 bits are removed if qinf is not used)
- vlc_val = rev_advance(&vlc, qinf[0] & 0x7);
-
- //update sigma
- // The update depends on the value of x; consider one OPJ_UINT32
- // if x is 0, 8, 16 and so on, then this line update c locations
- // nibble (4 bits) number 0 1 2 3 4 5 6 7
- // LSB c c 0 0 0 0 0 0
- // c c 0 0 0 0 0 0
- // 0 0 0 0 0 0 0 0
- // 0 0 0 0 0 0 0 0
- // if x is 4, 12, 20, then this line update locations c
- // nibble (4 bits) number 0 1 2 3 4 5 6 7
- // LSB 0 0 0 0 c c 0 0
- // 0 0 0 0 c c 0 0
- // 0 0 0 0 0 0 0 0
- // 0 0 0 0 0 0 0 0
- *sip |= (((qinf[0] & 0x30) >> 4) | ((qinf[0] & 0xC0) >> 2)) << sip_shift;
-
- //second quad
- qinf[1] = 0;
- if (x + 2 < width) { // do not run if codeblock is narrower
- //decode VLC using the context c_q and the head of the VLC bitstream
- qinf[1] = vlc_tbl0[(c_q << 7) | (vlc_val & 0x7F)];
-
- // if context is zero, use one MEL event
- if (c_q == 0) { //zero context
- run -= 2; //subtract 2, since events number if multiplied by 2
-
- // if event is 0, discard decoded qinf
- qinf[1] = (run == -1) ? qinf[1] : 0;
-
- if (run < 0) { // have we consumed all events in a run
- run = mel_get_run(&mel); // if yes, then get another run
- }
- }
-
- //prepare context for the next quad, eqn. 1 in ITU T.814
- c_q = ((qinf[1] & 0x10) >> 4) | ((qinf[1] & 0xE0) >> 5);
-
- //remove data from vlc stream, if qinf is not used, cwdlen is 0
- vlc_val = rev_advance(&vlc, qinf[1] & 0x7);
- }
-
- //update sigma
- // The update depends on the value of x; consider one OPJ_UINT32
- // if x is 0, 8, 16 and so on, then this line update c locations
- // nibble (4 bits) number 0 1 2 3 4 5 6 7
- // LSB 0 0 c c 0 0 0 0
- // 0 0 c c 0 0 0 0
- // 0 0 0 0 0 0 0 0
- // 0 0 0 0 0 0 0 0
- // if x is 4, 12, 20, then this line update locations c
- // nibble (4 bits) number 0 1 2 3 4 5 6 7
- // LSB 0 0 0 0 0 0 c c
- // 0 0 0 0 0 0 c c
- // 0 0 0 0 0 0 0 0
- // 0 0 0 0 0 0 0 0
- *sip |= (((qinf[1] & 0x30) | ((qinf[1] & 0xC0) << 2))) << (4 + sip_shift);
-
- sip += x & 0x7 ? 1 : 0; // move sigma pointer to next entry
- sip_shift ^= 0x10; // increment/decrement sip_shift by 16
-
- // retrieve u
- /////////////
-
- // uvlc_mode is made up of u_offset bits from the quad pair
- uvlc_mode = ((qinf[0] & 0x8) >> 3) | ((qinf[1] & 0x8) >> 2);
- if (uvlc_mode == 3) { // if both u_offset are set, get an event from
- // the MEL run of events
- run -= 2; //subtract 2, since events number if multiplied by 2
- uvlc_mode += (run == -1) ? 1 : 0; //increment uvlc_mode if event is 1
- if (run < 0) { // if run is consumed (run is -1 or -2), get another run
- run = mel_get_run(&mel);
- }
- }
- //decode uvlc_mode to get u for both quads
- consumed_bits = decode_init_uvlc(vlc_val, uvlc_mode, U_q);
- if (U_q[0] > zero_bplanes_p1 || U_q[1] > zero_bplanes_p1) {
- if (p_manager_mutex) {
- opj_mutex_lock(p_manager_mutex);
- }
- opj_event_msg(p_manager, EVT_ERROR, "Malformed HT codeblock. Decoding "
- "this codeblock is stopped. U_q is larger than zero "
- "bitplanes + 1 \n");
- if (p_manager_mutex) {
- opj_mutex_unlock(p_manager_mutex);
- }
- return OPJ_FALSE;
- }
-
- //consume u bits in the VLC code
- vlc_val = rev_advance(&vlc, consumed_bits);
-
- //decode magsgn and update line_state
- /////////////////////////////////////
-
- //We obtain a mask for the samples locations that needs evaluation
- locs = 0xFF;
- if (x + 4 > width) {
- locs >>= (x + 4 - width) << 1; // limits width
- }
- locs = height > 1 ? locs : (locs & 0x55); // limits height
-
- if ((((qinf[0] & 0xF0) >> 4) | (qinf[1] & 0xF0)) & ~locs) {
- if (p_manager_mutex) {
- opj_mutex_lock(p_manager_mutex);
- }
- opj_event_msg(p_manager, EVT_ERROR, "Malformed HT codeblock. "
- "VLC code produces significant samples outside "
- "the codeblock area.\n");
- if (p_manager_mutex) {
- opj_mutex_unlock(p_manager_mutex);
- }
- return OPJ_FALSE;
- }
-
- //first quad, starting at first sample in quad and moving on
- if (qinf[0] & 0x10) { //is it significant? (sigma_n)
- OPJ_UINT32 val;
-
- ms_val = frwd_fetch(&magsgn); //get 32 bits of magsgn data
- m_n = U_q[0] - ((qinf[0] >> 12) & 1); //evaluate m_n (number of bits
- // to read from bitstream), using EMB e_k
- frwd_advance(&magsgn, m_n); //consume m_n
- val = ms_val << 31; //get sign bit
- v_n = ms_val & ((1U << m_n) - 1); //keep only m_n bits
- v_n |= ((qinf[0] & 0x100) >> 8) << m_n; //add EMB e_1 as MSB
- v_n |= 1; //add center of bin
- //v_n now has 2 * (\mu - 1) + 0.5 with correct sign bit
- //add 2 to make it 2*\mu+0.5, shift it up to missing MSBs
- sp[0] = val | ((v_n + 2) << (p - 1));
- } else if (locs & 0x1) { // if this is inside the codeblock, set the
- sp[0] = 0; // sample to zero
- }
-
- if (qinf[0] & 0x20) { //sigma_n
- OPJ_UINT32 val, t;
-
- ms_val = frwd_fetch(&magsgn); //get 32 bits
- m_n = U_q[0] - ((qinf[0] >> 13) & 1); //m_n, uses EMB e_k
- frwd_advance(&magsgn, m_n); //consume m_n
- val = ms_val << 31; //get sign bit
- v_n = ms_val & ((1U << m_n) - 1); //keep only m_n bits
- v_n |= ((qinf[0] & 0x200) >> 9) << m_n; //add EMB e_1
- v_n |= 1; //bin center
- //v_n now has 2 * (\mu - 1) + 0.5 with correct sign bit
- //add 2 to make it 2*\mu+0.5, shift it up to missing MSBs
- sp[stride] = val | ((v_n + 2) << (p - 1));
-
- //update line_state: bit 7 (\sigma^N), and E^N
- t = lsp[0] & 0x7F; // keep E^NW
- v_n = 32 - count_leading_zeros(v_n);
- lsp[0] = (OPJ_UINT8)(0x80 | (t > v_n ? t : v_n)); //max(E^NW, E^N) | s
- } else if (locs & 0x2) { // if this is inside the codeblock, set the
- sp[stride] = 0; // sample to zero
- }
-
- ++lsp; // move to next quad information
- ++sp; // move to next column of samples
-
- //this is similar to the above two samples
- if (qinf[0] & 0x40) {
- OPJ_UINT32 val;
-
- ms_val = frwd_fetch(&magsgn);
- m_n = U_q[0] - ((qinf[0] >> 14) & 1);
- frwd_advance(&magsgn, m_n);
- val = ms_val << 31;
- v_n = ms_val & ((1U << m_n) - 1);
- v_n |= (((qinf[0] & 0x400) >> 10) << m_n);
- v_n |= 1;
- sp[0] = val | ((v_n + 2) << (p - 1));
- } else if (locs & 0x4) {
- sp[0] = 0;
- }
-
- lsp[0] = 0;
- if (qinf[0] & 0x80) {
- OPJ_UINT32 val;
- ms_val = frwd_fetch(&magsgn);
- m_n = U_q[0] - ((qinf[0] >> 15) & 1); //m_n
- frwd_advance(&magsgn, m_n);
- val = ms_val << 31;
- v_n = ms_val & ((1U << m_n) - 1);
- v_n |= ((qinf[0] & 0x800) >> 11) << m_n;
- v_n |= 1; //center of bin
- sp[stride] = val | ((v_n + 2) << (p - 1));
-
- //line_state: bit 7 (\sigma^NW), and E^NW for next quad
- lsp[0] = (OPJ_UINT8)(0x80 | (32 - count_leading_zeros(v_n)));
- } else if (locs & 0x8) { //if outside set to 0
- sp[stride] = 0;
- }
-
- ++sp; //move to next column
-
- //second quad
- if (qinf[1] & 0x10) {
- OPJ_UINT32 val;
-
- ms_val = frwd_fetch(&magsgn);
- m_n = U_q[1] - ((qinf[1] >> 12) & 1); //m_n
- frwd_advance(&magsgn, m_n);
- val = ms_val << 31;
- v_n = ms_val & ((1U << m_n) - 1);
- v_n |= (((qinf[1] & 0x100) >> 8) << m_n);
- v_n |= 1;
- sp[0] = val | ((v_n + 2) << (p - 1));
- } else if (locs & 0x10) {
- sp[0] = 0;
- }
-
- if (qinf[1] & 0x20) {
- OPJ_UINT32 val, t;
-
- ms_val = frwd_fetch(&magsgn);
- m_n = U_q[1] - ((qinf[1] >> 13) & 1); //m_n
- frwd_advance(&magsgn, m_n);
- val = ms_val << 31;
- v_n = ms_val & ((1U << m_n) - 1);
- v_n |= (((qinf[1] & 0x200) >> 9) << m_n);
- v_n |= 1;
- sp[stride] = val | ((v_n + 2) << (p - 1));
-
- //update line_state: bit 7 (\sigma^N), and E^N
- t = lsp[0] & 0x7F; //E^NW
- v_n = 32 - count_leading_zeros(v_n); //E^N
- lsp[0] = (OPJ_UINT8)(0x80 | (t > v_n ? t : v_n)); //max(E^NW, E^N) | s
- } else if (locs & 0x20) {
- sp[stride] = 0; //no need to update line_state
- }
-
- ++lsp; //move line state to next quad
- ++sp; //move to next sample
-
- if (qinf[1] & 0x40) {
- OPJ_UINT32 val;
-
- ms_val = frwd_fetch(&magsgn);
- m_n = U_q[1] - ((qinf[1] >> 14) & 1); //m_n
- frwd_advance(&magsgn, m_n);
- val = ms_val << 31;
- v_n = ms_val & ((1U << m_n) - 1);
- v_n |= (((qinf[1] & 0x400) >> 10) << m_n);
- v_n |= 1;
- sp[0] = val | ((v_n + 2) << (p - 1));
- } else if (locs & 0x40) {
- sp[0] = 0;
- }
-
- lsp[0] = 0;
- if (qinf[1] & 0x80) {
- OPJ_UINT32 val;
-
- ms_val = frwd_fetch(&magsgn);
- m_n = U_q[1] - ((qinf[1] >> 15) & 1); //m_n
- frwd_advance(&magsgn, m_n);
- val = ms_val << 31;
- v_n = ms_val & ((1U << m_n) - 1);
- v_n |= (((qinf[1] & 0x800) >> 11) << m_n);
- v_n |= 1; //center of bin
- sp[stride] = val | ((v_n + 2) << (p - 1));
-
- //line_state: bit 7 (\sigma^NW), and E^NW for next quad
- lsp[0] = (OPJ_UINT8)(0x80 | (32 - count_leading_zeros(v_n)));
- } else if (locs & 0x80) {
- sp[stride] = 0;
- }
-
- ++sp;
- }
-
- //non-initial lines
- //////////////////////////
- for (y = 2; y < height; /*done at the end of loop*/) {
- OPJ_UINT32 *sip;
- OPJ_UINT8 ls0;
- OPJ_INT32 x;
-
- sip_shift ^= 0x2; // shift sigma to the upper half od the nibble
- sip_shift &= 0xFFFFFFEFU; //move back to 0 (it might have been at 0x10)
- sip = y & 0x4 ? sigma2 : sigma1; //choose sigma array
-
- lsp = line_state;
- ls0 = lsp[0]; // read the line state value
- lsp[0] = 0; // and set it to zero
- sp = decoded_data + y * stride; // generated samples
- c_q = 0; // context
- for (x = 0; x < width; x += 4) {
- OPJ_UINT32 U_q[2];
- OPJ_UINT32 uvlc_mode, consumed_bits;
- OPJ_UINT32 m_n, v_n;
- OPJ_UINT32 ms_val;
- OPJ_UINT32 locs;
-
- // decode vlc
- /////////////
-
- //first quad
- // get context, eqn. 2 ITU T.814
- // c_q has \sigma^W | \sigma^SW
- c_q |= (ls0 >> 7); //\sigma^NW | \sigma^N
- c_q |= (lsp[1] >> 5) & 0x4; //\sigma^NE | \sigma^NF
-
- //the following is very similar to previous code, so please refer to
- // that
- vlc_val = rev_fetch(&vlc);
- qinf[0] = vlc_tbl1[(c_q << 7) | (vlc_val & 0x7F)];
- if (c_q == 0) { //zero context
- run -= 2;
- qinf[0] = (run == -1) ? qinf[0] : 0;
- if (run < 0) {
- run = mel_get_run(&mel);
- }
- }
- //prepare context for the next quad, \sigma^W | \sigma^SW
- c_q = ((qinf[0] & 0x40) >> 5) | ((qinf[0] & 0x80) >> 6);
-
- //remove data from vlc stream
- vlc_val = rev_advance(&vlc, qinf[0] & 0x7);
-
- //update sigma
- // The update depends on the value of x and y; consider one OPJ_UINT32
- // if x is 0, 8, 16 and so on, and y is 2, 6, etc., then this
- // line update c locations
- // nibble (4 bits) number 0 1 2 3 4 5 6 7
- // LSB 0 0 0 0 0 0 0 0
- // 0 0 0 0 0 0 0 0
- // c c 0 0 0 0 0 0
- // c c 0 0 0 0 0 0
- *sip |= (((qinf[0] & 0x30) >> 4) | ((qinf[0] & 0xC0) >> 2)) << sip_shift;
-
- //second quad
- qinf[1] = 0;
- if (x + 2 < width) {
- c_q |= (lsp[1] >> 7);
- c_q |= (lsp[2] >> 5) & 0x4;
- qinf[1] = vlc_tbl1[(c_q << 7) | (vlc_val & 0x7F)];
- if (c_q == 0) { //zero context
- run -= 2;
- qinf[1] = (run == -1) ? qinf[1] : 0;
- if (run < 0) {
- run = mel_get_run(&mel);
- }
- }
- //prepare context for the next quad
- c_q = ((qinf[1] & 0x40) >> 5) | ((qinf[1] & 0x80) >> 6);
- //remove data from vlc stream
- vlc_val = rev_advance(&vlc, qinf[1] & 0x7);
- }
-
- //update sigma
- *sip |= (((qinf[1] & 0x30) | ((qinf[1] & 0xC0) << 2))) << (4 + sip_shift);
-
- sip += x & 0x7 ? 1 : 0;
- sip_shift ^= 0x10;
-
- //retrieve u
- ////////////
- uvlc_mode = ((qinf[0] & 0x8) >> 3) | ((qinf[1] & 0x8) >> 2);
- consumed_bits = decode_noninit_uvlc(vlc_val, uvlc_mode, U_q);
- vlc_val = rev_advance(&vlc, consumed_bits);
-
- //calculate E^max and add it to U_q, eqns 5 and 6 in ITU T.814
- if ((qinf[0] & 0xF0) & ((qinf[0] & 0xF0) - 1)) { // is \gamma_q 1?
- OPJ_UINT32 E = (ls0 & 0x7Fu);
- E = E > (lsp[1] & 0x7Fu) ? E : (lsp[1] & 0x7Fu); //max(E, E^NE, E^NF)
- //since U_q already has u_q + 1, we subtract 2 instead of 1
- U_q[0] += E > 2 ? E - 2 : 0;
- }
-
- if ((qinf[1] & 0xF0) & ((qinf[1] & 0xF0) - 1)) { //is \gamma_q 1?
- OPJ_UINT32 E = (lsp[1] & 0x7Fu);
- E = E > (lsp[2] & 0x7Fu) ? E : (lsp[2] & 0x7Fu); //max(E, E^NE, E^NF)
- //since U_q already has u_q + 1, we subtract 2 instead of 1
- U_q[1] += E > 2 ? E - 2 : 0;
- }
-
- if (U_q[0] > zero_bplanes_p1 || U_q[1] > zero_bplanes_p1) {
- if (p_manager_mutex) {
- opj_mutex_lock(p_manager_mutex);
- }
- opj_event_msg(p_manager, EVT_ERROR, "Malformed HT codeblock. "
- "Decoding this codeblock is stopped. U_q is"
- "larger than bitplanes + 1 \n");
- if (p_manager_mutex) {
- opj_mutex_unlock(p_manager_mutex);
- }
- return OPJ_FALSE;
- }
-
- ls0 = lsp[2]; //for next double quad
- lsp[1] = lsp[2] = 0;
-
- //decode magsgn and update line_state
- /////////////////////////////////////
-
- //locations where samples need update
- locs = 0xFF;
- if (x + 4 > width) {
- locs >>= (x + 4 - width) << 1;
- }
- locs = y + 2 <= height ? locs : (locs & 0x55);
-
- if ((((qinf[0] & 0xF0) >> 4) | (qinf[1] & 0xF0)) & ~locs) {
- if (p_manager_mutex) {
- opj_mutex_lock(p_manager_mutex);
- }
- opj_event_msg(p_manager, EVT_ERROR, "Malformed HT codeblock. "
- "VLC code produces significant samples outside "
- "the codeblock area.\n");
- if (p_manager_mutex) {
- opj_mutex_unlock(p_manager_mutex);
- }
- return OPJ_FALSE;
- }
-
-
-
- if (qinf[0] & 0x10) { //sigma_n
- OPJ_UINT32 val;
-
- ms_val = frwd_fetch(&magsgn);
- m_n = U_q[0] - ((qinf[0] >> 12) & 1); //m_n
- frwd_advance(&magsgn, m_n);
- val = ms_val << 31;
- v_n = ms_val & ((1U << m_n) - 1);
- v_n |= ((qinf[0] & 0x100) >> 8) << m_n;
- v_n |= 1; //center of bin
- sp[0] = val | ((v_n + 2) << (p - 1));
- } else if (locs & 0x1) {
- sp[0] = 0;
- }
-
- if (qinf[0] & 0x20) { //sigma_n
- OPJ_UINT32 val, t;
-
- ms_val = frwd_fetch(&magsgn);
- m_n = U_q[0] - ((qinf[0] >> 13) & 1); //m_n
- frwd_advance(&magsgn, m_n);
- val = ms_val << 31;
- v_n = ms_val & ((1U << m_n) - 1);
- v_n |= ((qinf[0] & 0x200) >> 9) << m_n;
- v_n |= 1; //center of bin
- sp[stride] = val | ((v_n + 2) << (p - 1));
-
- //update line_state: bit 7 (\sigma^N), and E^N
- t = lsp[0] & 0x7F; //E^NW
- v_n = 32 - count_leading_zeros(v_n);
- lsp[0] = (OPJ_UINT8)(0x80 | (t > v_n ? t : v_n));
- } else if (locs & 0x2) {
- sp[stride] = 0; //no need to update line_state
- }
-
- ++lsp;
- ++sp;
-
- if (qinf[0] & 0x40) { //sigma_n
- OPJ_UINT32 val;
-
- ms_val = frwd_fetch(&magsgn);
- m_n = U_q[0] - ((qinf[0] >> 14) & 1); //m_n
- frwd_advance(&magsgn, m_n);
- val = ms_val << 31;
- v_n = ms_val & ((1U << m_n) - 1);
- v_n |= (((qinf[0] & 0x400) >> 10) << m_n);
- v_n |= 1; //center of bin
- sp[0] = val | ((v_n + 2) << (p - 1));
- } else if (locs & 0x4) {
- sp[0] = 0;
- }
-
- if (qinf[0] & 0x80) { //sigma_n
- OPJ_UINT32 val;
-
- ms_val = frwd_fetch(&magsgn);
- m_n = U_q[0] - ((qinf[0] >> 15) & 1); //m_n
- frwd_advance(&magsgn, m_n);
- val = ms_val << 31;
- v_n = ms_val & ((1U << m_n) - 1);
- v_n |= ((qinf[0] & 0x800) >> 11) << m_n;
- v_n |= 1; //center of bin
- sp[stride] = val | ((v_n + 2) << (p - 1));
-
- //update line_state: bit 7 (\sigma^NW), and E^NW for next quad
- lsp[0] = (OPJ_UINT8)(0x80 | (32 - count_leading_zeros(v_n)));
- } else if (locs & 0x8) {
- sp[stride] = 0;
- }
-
- ++sp;
-
- if (qinf[1] & 0x10) { //sigma_n
- OPJ_UINT32 val;
-
- ms_val = frwd_fetch(&magsgn);
- m_n = U_q[1] - ((qinf[1] >> 12) & 1); //m_n
- frwd_advance(&magsgn, m_n);
- val = ms_val << 31;
- v_n = ms_val & ((1U << m_n) - 1);
- v_n |= (((qinf[1] & 0x100) >> 8) << m_n);
- v_n |= 1; //center of bin
- sp[0] = val | ((v_n + 2) << (p - 1));
- } else if (locs & 0x10) {
- sp[0] = 0;
- }
-
- if (qinf[1] & 0x20) { //sigma_n
- OPJ_UINT32 val, t;
-
- ms_val = frwd_fetch(&magsgn);
- m_n = U_q[1] - ((qinf[1] >> 13) & 1); //m_n
- frwd_advance(&magsgn, m_n);
- val = ms_val << 31;
- v_n = ms_val & ((1U << m_n) - 1);
- v_n |= (((qinf[1] & 0x200) >> 9) << m_n);
- v_n |= 1; //center of bin
- sp[stride] = val | ((v_n + 2) << (p - 1));
-
- //update line_state: bit 7 (\sigma^N), and E^N
- t = lsp[0] & 0x7F; //E^NW
- v_n = 32 - count_leading_zeros(v_n);
- lsp[0] = (OPJ_UINT8)(0x80 | (t > v_n ? t : v_n));
- } else if (locs & 0x20) {
- sp[stride] = 0; //no need to update line_state
- }
-
- ++lsp;
- ++sp;
-
- if (qinf[1] & 0x40) { //sigma_n
- OPJ_UINT32 val;
-
- ms_val = frwd_fetch(&magsgn);
- m_n = U_q[1] - ((qinf[1] >> 14) & 1); //m_n
- frwd_advance(&magsgn, m_n);
- val = ms_val << 31;
- v_n = ms_val & ((1U << m_n) - 1);
- v_n |= (((qinf[1] & 0x400) >> 10) << m_n);
- v_n |= 1; //center of bin
- sp[0] = val | ((v_n + 2) << (p - 1));
- } else if (locs & 0x40) {
- sp[0] = 0;
- }
-
- if (qinf[1] & 0x80) { //sigma_n
- OPJ_UINT32 val;
-
- ms_val = frwd_fetch(&magsgn);
- m_n = U_q[1] - ((qinf[1] >> 15) & 1); //m_n
- frwd_advance(&magsgn, m_n);
- val = ms_val << 31;
- v_n = ms_val & ((1U << m_n) - 1);
- v_n |= (((qinf[1] & 0x800) >> 11) << m_n);
- v_n |= 1; //center of bin
- sp[stride] = val | ((v_n + 2) << (p - 1));
-
- //update line_state: bit 7 (\sigma^NW), and E^NW for next quad
- lsp[0] = (OPJ_UINT8)(0x80 | (32 - count_leading_zeros(v_n)));
- } else if (locs & 0x80) {
- sp[stride] = 0;
- }
-
- ++sp;
- }
-
- y += 2;
- if (num_passes > 1 && (y & 3) == 0) { //executed at multiples of 4
- // This is for SPP and potentially MRP
-
- if (num_passes > 2) { //do MRP
- // select the current stripe
- OPJ_UINT32 *cur_sig = y & 0x4 ? sigma1 : sigma2;
- // the address of the data that needs updating
- OPJ_UINT32 *dpp = decoded_data + (y - 4) * stride;
- OPJ_UINT32 half = 1u << (p - 2); // half the center of the bin
- OPJ_INT32 i;
- for (i = 0; i < width; i += 8) {
- //Process one entry from sigma array at a time
- // Each nibble (4 bits) in the sigma array represents 4 rows,
- // and the 32 bits contain 8 columns
- OPJ_UINT32 cwd = rev_fetch_mrp(&magref); // get 32 bit data
- OPJ_UINT32 sig = *cur_sig++; // 32 bit that will be processed now
- OPJ_UINT32 col_mask = 0xFu; // a mask for a column in sig
- OPJ_UINT32 *dp = dpp + i; // next column in decode samples
- if (sig) { // if any of the 32 bits are set
- int j;
- for (j = 0; j < 8; ++j, dp++) { //one column at a time
- if (sig & col_mask) { // lowest nibble
- OPJ_UINT32 sample_mask = 0x11111111u & col_mask; //LSB
-
- if (sig & sample_mask) { //if LSB is set
- OPJ_UINT32 sym;
-
- assert(dp[0] != 0); // decoded value cannot be zero
- sym = cwd & 1; // get it value
- // remove center of bin if sym is 0
- dp[0] ^= (1 - sym) << (p - 1);
- dp[0] |= half; // put half the center of bin
- cwd >>= 1; //consume word
- }
- sample_mask += sample_mask; //next row
-
- if (sig & sample_mask) {
- OPJ_UINT32 sym;
-
- assert(dp[stride] != 0);
- sym = cwd & 1;
- dp[stride] ^= (1 - sym) << (p - 1);
- dp[stride] |= half;
- cwd >>= 1;
- }
- sample_mask += sample_mask;
-
- if (sig & sample_mask) {
- OPJ_UINT32 sym;
-
- assert(dp[2 * stride] != 0);
- sym = cwd & 1;
- dp[2 * stride] ^= (1 - sym) << (p - 1);
- dp[2 * stride] |= half;
- cwd >>= 1;
- }
- sample_mask += sample_mask;
-
- if (sig & sample_mask) {
- OPJ_UINT32 sym;
-
- assert(dp[3 * stride] != 0);
- sym = cwd & 1;
- dp[3 * stride] ^= (1 - sym) << (p - 1);
- dp[3 * stride] |= half;
- cwd >>= 1;
- }
- sample_mask += sample_mask;
- }
- col_mask <<= 4; //next column
- }
- }
- // consume data according to the number of bits set
- rev_advance_mrp(&magref, population_count(sig));
- }
- }
-
- if (y >= 4) { // update mbr array at the end of each stripe
- //generate mbr corresponding to a stripe
- OPJ_UINT32 *sig = y & 0x4 ? sigma1 : sigma2;
- OPJ_UINT32 *mbr = y & 0x4 ? mbr1 : mbr2;
-
- //data is processed in patches of 8 columns, each
- // each 32 bits in sigma1 or mbr1 represent 4 rows
-
- //integrate horizontally
- OPJ_UINT32 prev = 0; // previous columns
- OPJ_INT32 i;
- for (i = 0; i < width; i += 8, mbr++, sig++) {
- OPJ_UINT32 t, z;
-
- mbr[0] = sig[0]; //start with significant samples
- mbr[0] |= prev >> 28; //for first column, left neighbors
- mbr[0] |= sig[0] << 4; //left neighbors
- mbr[0] |= sig[0] >> 4; //right neighbors
- mbr[0] |= sig[1] << 28; //for last column, right neighbors
- prev = sig[0]; // for next group of columns
-
- //integrate vertically
- t = mbr[0], z = mbr[0];
- z |= (t & 0x77777777) << 1; //above neighbors
- z |= (t & 0xEEEEEEEE) >> 1; //below neighbors
- mbr[0] = z & ~sig[0]; //remove already significance samples
- }
- }
-
- if (y >= 8) { //wait until 8 rows has been processed
- OPJ_UINT32 *cur_sig, *cur_mbr, *nxt_sig, *nxt_mbr;
- OPJ_UINT32 prev;
- OPJ_UINT32 val;
- OPJ_INT32 i;
-
- // add membership from the next stripe, obtained above
- cur_sig = y & 0x4 ? sigma2 : sigma1;
- cur_mbr = y & 0x4 ? mbr2 : mbr1;
- nxt_sig = y & 0x4 ? sigma1 : sigma2; //future samples
- prev = 0; // the columns before these group of 8 columns
- for (i = 0; i < width; i += 8, cur_mbr++, cur_sig++, nxt_sig++) {
- OPJ_UINT32 t = nxt_sig[0];
- t |= prev >> 28; //for first column, left neighbors
- t |= nxt_sig[0] << 4; //left neighbors
- t |= nxt_sig[0] >> 4; //right neighbors
- t |= nxt_sig[1] << 28; //for last column, right neighbors
- prev = nxt_sig[0]; // for next group of columns
-
- if (!stripe_causal) {
- cur_mbr[0] |= (t & 0x11111111u) << 3; //propagate up to cur_mbr
- }
- cur_mbr[0] &= ~cur_sig[0]; //remove already significance samples
- }
-
- //find new locations and get signs
- cur_sig = y & 0x4 ? sigma2 : sigma1;
- cur_mbr = y & 0x4 ? mbr2 : mbr1;
- nxt_sig = y & 0x4 ? sigma1 : sigma2; //future samples
- nxt_mbr = y & 0x4 ? mbr1 : mbr2; //future samples
- val = 3u << (p - 2); // sample values for newly discovered
- // significant samples including the bin center
- for (i = 0; i < width;
- i += 8, cur_sig++, cur_mbr++, nxt_sig++, nxt_mbr++) {
- OPJ_UINT32 ux, tx;
- OPJ_UINT32 mbr = *cur_mbr;
- OPJ_UINT32 new_sig = 0;
- if (mbr) { //are there any samples that might be significant
- OPJ_INT32 n;
- for (n = 0; n < 8; n += 4) {
- OPJ_UINT32 col_mask;
- OPJ_UINT32 inv_sig;
- OPJ_INT32 end;
- OPJ_INT32 j;
-
- OPJ_UINT32 cwd = frwd_fetch(&sigprop); //get 32 bits
- OPJ_UINT32 cnt = 0;
-
- OPJ_UINT32 *dp = decoded_data + (y - 8) * stride;
- dp += i + n; //address for decoded samples
-
- col_mask = 0xFu << (4 * n); //a mask to select a column
-
- inv_sig = ~cur_sig[0]; // insignificant samples
-
- //find the last sample we operate on
- end = n + 4 + i < width ? n + 4 : width - i;
-
- for (j = n; j < end; ++j, ++dp, col_mask <<= 4) {
- OPJ_UINT32 sample_mask;
-
- if ((col_mask & mbr) == 0) { //no samples need checking
- continue;
- }
-
- //scan mbr to find a new significant sample
- sample_mask = 0x11111111u & col_mask; // LSB
- if (mbr & sample_mask) {
- assert(dp[0] == 0); // the sample must have been 0
- if (cwd & 1) { //if this sample has become significant
- // must propagate it to nearby samples
- OPJ_UINT32 t;
- new_sig |= sample_mask; // new significant samples
- t = 0x32u << (j * 4);// propagation to neighbors
- mbr |= t & inv_sig; //remove already significant samples
- }
- cwd >>= 1;
- ++cnt; //consume bit and increment number of
- //consumed bits
- }
-
- sample_mask += sample_mask; // next row
- if (mbr & sample_mask) {
- assert(dp[stride] == 0);
- if (cwd & 1) {
- OPJ_UINT32 t;
- new_sig |= sample_mask;
- t = 0x74u << (j * 4);
- mbr |= t & inv_sig;
- }
- cwd >>= 1;
- ++cnt;
- }
-
- sample_mask += sample_mask;
- if (mbr & sample_mask) {
- assert(dp[2 * stride] == 0);
- if (cwd & 1) {
- OPJ_UINT32 t;
- new_sig |= sample_mask;
- t = 0xE8u << (j * 4);
- mbr |= t & inv_sig;
- }
- cwd >>= 1;
- ++cnt;
- }
-
- sample_mask += sample_mask;
- if (mbr & sample_mask) {
- assert(dp[3 * stride] == 0);
- if (cwd & 1) {
- OPJ_UINT32 t;
- new_sig |= sample_mask;
- t = 0xC0u << (j * 4);
- mbr |= t & inv_sig;
- }
- cwd >>= 1;
- ++cnt;
- }
- }
-
- //obtain signs here
- if (new_sig & (0xFFFFu << (4 * n))) { //if any
- OPJ_UINT32 col_mask;
- OPJ_INT32 j;
- OPJ_UINT32 *dp = decoded_data + (y - 8) * stride;
- dp += i + n; // decoded samples address
- col_mask = 0xFu << (4 * n); //mask to select a column
-
- for (j = n; j < end; ++j, ++dp, col_mask <<= 4) {
- OPJ_UINT32 sample_mask;
-
- if ((col_mask & new_sig) == 0) { //if non is significant
- continue;
- }
-
- //scan 4 signs
- sample_mask = 0x11111111u & col_mask;
- if (new_sig & sample_mask) {
- assert(dp[0] == 0);
- dp[0] |= ((cwd & 1) << 31) | val; //put value and sign
- cwd >>= 1;
- ++cnt; //consume bit and increment number
- //of consumed bits
- }
-
- sample_mask += sample_mask;
- if (new_sig & sample_mask) {
- assert(dp[stride] == 0);
- dp[stride] |= ((cwd & 1) << 31) | val;
- cwd >>= 1;
- ++cnt;
- }
-
- sample_mask += sample_mask;
- if (new_sig & sample_mask) {
- assert(dp[2 * stride] == 0);
- dp[2 * stride] |= ((cwd & 1) << 31) | val;
- cwd >>= 1;
- ++cnt;
- }
-
- sample_mask += sample_mask;
- if (new_sig & sample_mask) {
- assert(dp[3 * stride] == 0);
- dp[3 * stride] |= ((cwd & 1) << 31) | val;
- cwd >>= 1;
- ++cnt;
- }
- }
-
- }
- frwd_advance(&sigprop, cnt); //consume the bits from bitstrm
- cnt = 0;
-
- //update the next 8 columns
- if (n == 4) {
- //horizontally
- OPJ_UINT32 t = new_sig >> 28;
- t |= ((t & 0xE) >> 1) | ((t & 7) << 1);
- cur_mbr[1] |= t & ~cur_sig[1];
- }
- }
- }
- //update the next stripe (vertically propagation)
- new_sig |= cur_sig[0];
- ux = (new_sig & 0x88888888) >> 3;
- tx = ux | (ux << 4) | (ux >> 4); //left and right neighbors
- if (i > 0) {
- nxt_mbr[-1] |= (ux << 28) & ~nxt_sig[-1];
- }
- nxt_mbr[0] |= tx & ~nxt_sig[0];
- nxt_mbr[1] |= (ux >> 28) & ~nxt_sig[1];
- }
-
- //clear current sigma
- //mbr need not be cleared because it is overwritten
- cur_sig = y & 0x4 ? sigma2 : sigma1;
- memset(cur_sig, 0, ((((OPJ_UINT32)width + 7u) >> 3) + 1u) << 2);
- }
- }
- }
-
- //terminating
- if (num_passes > 1) {
- OPJ_INT32 st, y;
-
- if (num_passes > 2 && ((height & 3) == 1 || (height & 3) == 2)) {
- //do magref
- OPJ_UINT32 *cur_sig = height & 0x4 ? sigma2 : sigma1; //reversed
- OPJ_UINT32 *dpp = decoded_data + (height & 0xFFFFFC) * stride;
- OPJ_UINT32 half = 1u << (p - 2);
- OPJ_INT32 i;
- for (i = 0; i < width; i += 8) {
- OPJ_UINT32 cwd = rev_fetch_mrp(&magref);
- OPJ_UINT32 sig = *cur_sig++;
- OPJ_UINT32 col_mask = 0xF;
- OPJ_UINT32 *dp = dpp + i;
- if (sig) {
- int j;
- for (j = 0; j < 8; ++j, dp++) {
- if (sig & col_mask) {
- OPJ_UINT32 sample_mask = 0x11111111 & col_mask;
-
- if (sig & sample_mask) {
- OPJ_UINT32 sym;
- assert(dp[0] != 0);
- sym = cwd & 1;
- dp[0] ^= (1 - sym) << (p - 1);
- dp[0] |= half;
- cwd >>= 1;
- }
- sample_mask += sample_mask;
-
- if (sig & sample_mask) {
- OPJ_UINT32 sym;
- assert(dp[stride] != 0);
- sym = cwd & 1;
- dp[stride] ^= (1 - sym) << (p - 1);
- dp[stride] |= half;
- cwd >>= 1;
- }
- sample_mask += sample_mask;
-
- if (sig & sample_mask) {
- OPJ_UINT32 sym;
- assert(dp[2 * stride] != 0);
- sym = cwd & 1;
- dp[2 * stride] ^= (1 - sym) << (p - 1);
- dp[2 * stride] |= half;
- cwd >>= 1;
- }
- sample_mask += sample_mask;
-
- if (sig & sample_mask) {
- OPJ_UINT32 sym;
- assert(dp[3 * stride] != 0);
- sym = cwd & 1;
- dp[3 * stride] ^= (1 - sym) << (p - 1);
- dp[3 * stride] |= half;
- cwd >>= 1;
- }
- sample_mask += sample_mask;
- }
- col_mask <<= 4;
- }
- }
- rev_advance_mrp(&magref, population_count(sig));
- }
- }
-
- //do the last incomplete stripe
- // for cases of (height & 3) == 0 and 3
- // the should have been processed previously
- if ((height & 3) == 1 || (height & 3) == 2) {
- //generate mbr of first stripe
- OPJ_UINT32 *sig = height & 0x4 ? sigma2 : sigma1;
- OPJ_UINT32 *mbr = height & 0x4 ? mbr2 : mbr1;
- //integrate horizontally
- OPJ_UINT32 prev = 0;
- OPJ_INT32 i;
- for (i = 0; i < width; i += 8, mbr++, sig++) {
- OPJ_UINT32 t, z;
-
- mbr[0] = sig[0];
- mbr[0] |= prev >> 28; //for first column, left neighbors
- mbr[0] |= sig[0] << 4; //left neighbors
- mbr[0] |= sig[0] >> 4; //left neighbors
- mbr[0] |= sig[1] << 28; //for last column, right neighbors
- prev = sig[0];
-
- //integrate vertically
- t = mbr[0], z = mbr[0];
- z |= (t & 0x77777777) << 1; //above neighbors
- z |= (t & 0xEEEEEEEE) >> 1; //below neighbors
- mbr[0] = z & ~sig[0]; //remove already significance samples
- }
- }
-
- st = height;
- st -= height > 6 ? (((height + 1) & 3) + 3) : height;
- for (y = st; y < height; y += 4) {
- OPJ_UINT32 *cur_sig, *cur_mbr, *nxt_sig, *nxt_mbr;
- OPJ_UINT32 val;
- OPJ_INT32 i;
-
- OPJ_UINT32 pattern = 0xFFFFFFFFu; // a pattern needed samples
- if (height - y == 3) {
- pattern = 0x77777777u;
- } else if (height - y == 2) {
- pattern = 0x33333333u;
- } else if (height - y == 1) {
- pattern = 0x11111111u;
- }
-
- //add membership from the next stripe, obtained above
- if (height - y > 4) {
- OPJ_UINT32 prev = 0;
- OPJ_INT32 i;
- cur_sig = y & 0x4 ? sigma2 : sigma1;
- cur_mbr = y & 0x4 ? mbr2 : mbr1;
- nxt_sig = y & 0x4 ? sigma1 : sigma2;
- for (i = 0; i < width; i += 8, cur_mbr++, cur_sig++, nxt_sig++) {
- OPJ_UINT32 t = nxt_sig[0];
- t |= prev >> 28; //for first column, left neighbors
- t |= nxt_sig[0] << 4; //left neighbors
- t |= nxt_sig[0] >> 4; //left neighbors
- t |= nxt_sig[1] << 28; //for last column, right neighbors
- prev = nxt_sig[0];
-
- if (!stripe_causal) {
- cur_mbr[0] |= (t & 0x11111111u) << 3;
- }
- //remove already significance samples
- cur_mbr[0] &= ~cur_sig[0];
- }
- }
-
- //find new locations and get signs
- cur_sig = y & 0x4 ? sigma2 : sigma1;
- cur_mbr = y & 0x4 ? mbr2 : mbr1;
- nxt_sig = y & 0x4 ? sigma1 : sigma2;
- nxt_mbr = y & 0x4 ? mbr1 : mbr2;
- val = 3u << (p - 2);
- for (i = 0; i < width; i += 8,
- cur_sig++, cur_mbr++, nxt_sig++, nxt_mbr++) {
- OPJ_UINT32 mbr = *cur_mbr & pattern; //skip unneeded samples
- OPJ_UINT32 new_sig = 0;
- OPJ_UINT32 ux, tx;
- if (mbr) {
- OPJ_INT32 n;
- for (n = 0; n < 8; n += 4) {
- OPJ_UINT32 col_mask;
- OPJ_UINT32 inv_sig;
- OPJ_INT32 end;
- OPJ_INT32 j;
-
- OPJ_UINT32 cwd = frwd_fetch(&sigprop);
- OPJ_UINT32 cnt = 0;
-
- OPJ_UINT32 *dp = decoded_data + y * stride;
- dp += i + n;
-
- col_mask = 0xFu << (4 * n);
-
- inv_sig = ~cur_sig[0] & pattern;
-
- end = n + 4 + i < width ? n + 4 : width - i;
- for (j = n; j < end; ++j, ++dp, col_mask <<= 4) {
- OPJ_UINT32 sample_mask;
-
- if ((col_mask & mbr) == 0) {
- continue;
- }
-
- //scan 4 mbr
- sample_mask = 0x11111111u & col_mask;
- if (mbr & sample_mask) {
- assert(dp[0] == 0);
- if (cwd & 1) {
- OPJ_UINT32 t;
- new_sig |= sample_mask;
- t = 0x32u << (j * 4);
- mbr |= t & inv_sig;
- }
- cwd >>= 1;
- ++cnt;
- }
-
- sample_mask += sample_mask;
- if (mbr & sample_mask) {
- assert(dp[stride] == 0);
- if (cwd & 1) {
- OPJ_UINT32 t;
- new_sig |= sample_mask;
- t = 0x74u << (j * 4);
- mbr |= t & inv_sig;
- }
- cwd >>= 1;
- ++cnt;
- }
-
- sample_mask += sample_mask;
- if (mbr & sample_mask) {
- assert(dp[2 * stride] == 0);
- if (cwd & 1) {
- OPJ_UINT32 t;
- new_sig |= sample_mask;
- t = 0xE8u << (j * 4);
- mbr |= t & inv_sig;
- }
- cwd >>= 1;
- ++cnt;
- }
-
- sample_mask += sample_mask;
- if (mbr & sample_mask) {
- assert(dp[3 * stride] == 0);
- if (cwd & 1) {
- OPJ_UINT32 t;
- new_sig |= sample_mask;
- t = 0xC0u << (j * 4);
- mbr |= t & inv_sig;
- }
- cwd >>= 1;
- ++cnt;
- }
- }
-
- //signs here
- if (new_sig & (0xFFFFu << (4 * n))) {
- OPJ_UINT32 col_mask;
- OPJ_INT32 j;
- OPJ_UINT32 *dp = decoded_data + y * stride;
- dp += i + n;
- col_mask = 0xFu << (4 * n);
-
- for (j = n; j < end; ++j, ++dp, col_mask <<= 4) {
- OPJ_UINT32 sample_mask;
- if ((col_mask & new_sig) == 0) {
- continue;
- }
-
- //scan 4 signs
- sample_mask = 0x11111111u & col_mask;
- if (new_sig & sample_mask) {
- assert(dp[0] == 0);
- dp[0] |= ((cwd & 1) << 31) | val;
- cwd >>= 1;
- ++cnt;
- }
-
- sample_mask += sample_mask;
- if (new_sig & sample_mask) {
- assert(dp[stride] == 0);
- dp[stride] |= ((cwd & 1) << 31) | val;
- cwd >>= 1;
- ++cnt;
- }
-
- sample_mask += sample_mask;
- if (new_sig & sample_mask) {
- assert(dp[2 * stride] == 0);
- dp[2 * stride] |= ((cwd & 1) << 31) | val;
- cwd >>= 1;
- ++cnt;
- }
-
- sample_mask += sample_mask;
- if (new_sig & sample_mask) {
- assert(dp[3 * stride] == 0);
- dp[3 * stride] |= ((cwd & 1) << 31) | val;
- cwd >>= 1;
- ++cnt;
- }
- }
-
- }
- frwd_advance(&sigprop, cnt);
- cnt = 0;
-
- //update next columns
- if (n == 4) {
- //horizontally
- OPJ_UINT32 t = new_sig >> 28;
- t |= ((t & 0xE) >> 1) | ((t & 7) << 1);
- cur_mbr[1] |= t & ~cur_sig[1];
- }
- }
- }
- //propagate down (vertically propagation)
- new_sig |= cur_sig[0];
- ux = (new_sig & 0x88888888) >> 3;
- tx = ux | (ux << 4) | (ux >> 4);
- if (i > 0) {
- nxt_mbr[-1] |= (ux << 28) & ~nxt_sig[-1];
- }
- nxt_mbr[0] |= tx & ~nxt_sig[0];
- nxt_mbr[1] |= (ux >> 28) & ~nxt_sig[1];
- }
- }
- }
-
- {
- OPJ_INT32 x, y;
- for (y = 0; y < height; ++y) {
- OPJ_INT32* sp = (OPJ_INT32*)decoded_data + y * stride;
- for (x = 0; x < width; ++x, ++sp) {
- OPJ_INT32 val = (*sp & 0x7FFFFFFF);
- *sp = ((OPJ_UINT32) * sp & 0x80000000) ? -val : val;
- }
- }
- }
-
- return OPJ_TRUE;
-}
diff --git a/contrib/libs/openjpeg/image.c b/contrib/libs/openjpeg/image.c
deleted file mode 100644
index 017201a002..0000000000
--- a/contrib/libs/openjpeg/image.c
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "opj_includes.h"
-
-opj_image_t* opj_image_create0(void)
-{
- opj_image_t *image = (opj_image_t*)opj_calloc(1, sizeof(opj_image_t));
- return image;
-}
-
-opj_image_t* OPJ_CALLCONV opj_image_create(OPJ_UINT32 numcmpts,
- opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc)
-{
- OPJ_UINT32 compno;
- opj_image_t *image = NULL;
-
- image = (opj_image_t*) opj_calloc(1, sizeof(opj_image_t));
- if (image) {
- image->color_space = clrspc;
- image->numcomps = numcmpts;
- /* allocate memory for the per-component information */
- image->comps = (opj_image_comp_t*)opj_calloc(image->numcomps,
- sizeof(opj_image_comp_t));
- if (!image->comps) {
- /* TODO replace with event manager, breaks API */
- /* fprintf(stderr,"Unable to allocate memory for image.\n"); */
- opj_image_destroy(image);
- return NULL;
- }
- /* create the individual image components */
- for (compno = 0; compno < numcmpts; compno++) {
- opj_image_comp_t *comp = &image->comps[compno];
- comp->dx = cmptparms[compno].dx;
- comp->dy = cmptparms[compno].dy;
- comp->w = cmptparms[compno].w;
- comp->h = cmptparms[compno].h;
- comp->x0 = cmptparms[compno].x0;
- comp->y0 = cmptparms[compno].y0;
- comp->prec = cmptparms[compno].prec;
- comp->sgnd = cmptparms[compno].sgnd;
- if (comp->h != 0 &&
- (OPJ_SIZE_T)comp->w > SIZE_MAX / comp->h / sizeof(OPJ_INT32)) {
- /* TODO event manager */
- opj_image_destroy(image);
- return NULL;
- }
- comp->data = (OPJ_INT32*) opj_image_data_alloc(
- (size_t)comp->w * comp->h * sizeof(OPJ_INT32));
- if (!comp->data) {
- /* TODO replace with event manager, breaks API */
- /* fprintf(stderr,"Unable to allocate memory for image.\n"); */
- opj_image_destroy(image);
- return NULL;
- }
- memset(comp->data, 0, (size_t)comp->w * comp->h * sizeof(OPJ_INT32));
- }
- }
-
- return image;
-}
-
-void OPJ_CALLCONV opj_image_destroy(opj_image_t *image)
-{
- if (image) {
- if (image->comps) {
- OPJ_UINT32 compno;
-
- /* image components */
- for (compno = 0; compno < image->numcomps; compno++) {
- opj_image_comp_t *image_comp = &(image->comps[compno]);
- if (image_comp->data) {
- opj_image_data_free(image_comp->data);
- }
- }
- opj_free(image->comps);
- }
-
- if (image->icc_profile_buf) {
- opj_free(image->icc_profile_buf);
- }
-
- opj_free(image);
- }
-}
-
-/**
- * Updates the components characteristics of the image from the coding parameters.
- *
- * @param p_image_header the image header to update.
- * @param p_cp the coding parameters from which to update the image.
- */
-void opj_image_comp_header_update(opj_image_t * p_image_header,
- const struct opj_cp * p_cp)
-{
- OPJ_UINT32 i, l_width, l_height;
- OPJ_UINT32 l_x0, l_y0, l_x1, l_y1;
- OPJ_UINT32 l_comp_x0, l_comp_y0, l_comp_x1, l_comp_y1;
- opj_image_comp_t* l_img_comp = NULL;
-
- l_x0 = opj_uint_max(p_cp->tx0, p_image_header->x0);
- l_y0 = opj_uint_max(p_cp->ty0, p_image_header->y0);
- l_x1 = p_cp->tx0 + (p_cp->tw - 1U) *
- p_cp->tdx; /* validity of p_cp members used here checked in opj_j2k_read_siz. Can't overflow. */
- l_y1 = p_cp->ty0 + (p_cp->th - 1U) * p_cp->tdy; /* can't overflow */
- l_x1 = opj_uint_min(opj_uint_adds(l_x1, p_cp->tdx),
- p_image_header->x1); /* use add saturated to prevent overflow */
- l_y1 = opj_uint_min(opj_uint_adds(l_y1, p_cp->tdy),
- p_image_header->y1); /* use add saturated to prevent overflow */
-
- l_img_comp = p_image_header->comps;
- for (i = 0; i < p_image_header->numcomps; ++i) {
- l_comp_x0 = opj_uint_ceildiv(l_x0, l_img_comp->dx);
- l_comp_y0 = opj_uint_ceildiv(l_y0, l_img_comp->dy);
- l_comp_x1 = opj_uint_ceildiv(l_x1, l_img_comp->dx);
- l_comp_y1 = opj_uint_ceildiv(l_y1, l_img_comp->dy);
- l_width = opj_uint_ceildivpow2(l_comp_x1 - l_comp_x0, l_img_comp->factor);
- l_height = opj_uint_ceildivpow2(l_comp_y1 - l_comp_y0, l_img_comp->factor);
- l_img_comp->w = l_width;
- l_img_comp->h = l_height;
- l_img_comp->x0 = l_comp_x0;
- l_img_comp->y0 = l_comp_y0;
- ++l_img_comp;
- }
-}
-
-
-/**
- * Copy only header of image and its component header (no data are copied)
- * if dest image have data, they will be freed
- *
- * @param p_image_src the src image
- * @param p_image_dest the dest image
- *
- */
-void opj_copy_image_header(const opj_image_t* p_image_src,
- opj_image_t* p_image_dest)
-{
- OPJ_UINT32 compno;
-
- /* preconditions */
- assert(p_image_src != 00);
- assert(p_image_dest != 00);
-
- p_image_dest->x0 = p_image_src->x0;
- p_image_dest->y0 = p_image_src->y0;
- p_image_dest->x1 = p_image_src->x1;
- p_image_dest->y1 = p_image_src->y1;
-
- if (p_image_dest->comps) {
- for (compno = 0; compno < p_image_dest->numcomps; compno++) {
- opj_image_comp_t *image_comp = &(p_image_dest->comps[compno]);
- if (image_comp->data) {
- opj_image_data_free(image_comp->data);
- }
- }
- opj_free(p_image_dest->comps);
- p_image_dest->comps = NULL;
- }
-
- p_image_dest->numcomps = p_image_src->numcomps;
-
- p_image_dest->comps = (opj_image_comp_t*) opj_malloc(p_image_dest->numcomps *
- sizeof(opj_image_comp_t));
- if (!p_image_dest->comps) {
- p_image_dest->comps = NULL;
- p_image_dest->numcomps = 0;
- return;
- }
-
- for (compno = 0; compno < p_image_dest->numcomps; compno++) {
- memcpy(&(p_image_dest->comps[compno]),
- &(p_image_src->comps[compno]),
- sizeof(opj_image_comp_t));
- p_image_dest->comps[compno].data = NULL;
- }
-
- p_image_dest->color_space = p_image_src->color_space;
- p_image_dest->icc_profile_len = p_image_src->icc_profile_len;
-
- if (p_image_dest->icc_profile_len) {
- p_image_dest->icc_profile_buf = (OPJ_BYTE*)opj_malloc(
- p_image_dest->icc_profile_len);
- if (!p_image_dest->icc_profile_buf) {
- p_image_dest->icc_profile_buf = NULL;
- p_image_dest->icc_profile_len = 0;
- return;
- }
- memcpy(p_image_dest->icc_profile_buf,
- p_image_src->icc_profile_buf,
- p_image_src->icc_profile_len);
- } else {
- p_image_dest->icc_profile_buf = NULL;
- }
-
- return;
-}
-
-opj_image_t* OPJ_CALLCONV opj_image_tile_create(OPJ_UINT32 numcmpts,
- opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc)
-{
- OPJ_UINT32 compno;
- opj_image_t *image = 00;
-
- image = (opj_image_t*) opj_calloc(1, sizeof(opj_image_t));
- if (image) {
-
- image->color_space = clrspc;
- image->numcomps = numcmpts;
-
- /* allocate memory for the per-component information */
- image->comps = (opj_image_comp_t*)opj_calloc(image->numcomps,
- sizeof(opj_image_comp_t));
- if (!image->comps) {
- opj_image_destroy(image);
- return 00;
- }
-
- /* create the individual image components */
- for (compno = 0; compno < numcmpts; compno++) {
- opj_image_comp_t *comp = &image->comps[compno];
- comp->dx = cmptparms[compno].dx;
- comp->dy = cmptparms[compno].dy;
- comp->w = cmptparms[compno].w;
- comp->h = cmptparms[compno].h;
- comp->x0 = cmptparms[compno].x0;
- comp->y0 = cmptparms[compno].y0;
- comp->prec = cmptparms[compno].prec;
- comp->sgnd = cmptparms[compno].sgnd;
- comp->data = 0;
- }
- }
-
- return image;
-}
diff --git a/contrib/libs/openjpeg/image.h b/contrib/libs/openjpeg/image.h
deleted file mode 100644
index bad83c6135..0000000000
--- a/contrib/libs/openjpeg/image.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef OPJ_IMAGE_H
-#define OPJ_IMAGE_H
-/**
-@file image.h
-@brief Implementation of operations on images (IMAGE)
-
-The functions in IMAGE.C have for goal to realize operations on images.
-*/
-
-struct opj_image;
-struct opj_cp;
-
-/** @defgroup IMAGE IMAGE - Implementation of operations on images */
-/*@{*/
-
-/**
- * Create an empty image
- *
- * @return returns an empty image if successful, returns NULL otherwise
- */
-opj_image_t* opj_image_create0(void);
-
-
-
-/**
- * Updates the components characteristics of the image from the coding parameters.
- *
- * @param p_image_header the image header to update.
- * @param p_cp the coding parameters from which to update the image.
- */
-void opj_image_comp_header_update(opj_image_t * p_image,
- const struct opj_cp* p_cp);
-
-void opj_copy_image_header(const opj_image_t* p_image_src,
- opj_image_t* p_image_dest);
-
-/*@}*/
-
-#endif /* OPJ_IMAGE_H */
-
diff --git a/contrib/libs/openjpeg/include/openjpeg.h b/contrib/libs/openjpeg/include/openjpeg.h
deleted file mode 100644
index 39adc998c7..0000000000
--- a/contrib/libs/openjpeg/include/openjpeg.h
+++ /dev/null
@@ -1 +0,0 @@
-#include "../openjpeg.h" /* inclink generated by yamaker */
diff --git a/contrib/libs/openjpeg/include/opj_config.h b/contrib/libs/openjpeg/include/opj_config.h
deleted file mode 100644
index 657b34f009..0000000000
--- a/contrib/libs/openjpeg/include/opj_config.h
+++ /dev/null
@@ -1 +0,0 @@
-#include "../opj_config.h" /* inclink generated by yamaker */
diff --git a/contrib/libs/openjpeg/invert.c b/contrib/libs/openjpeg/invert.c
deleted file mode 100644
index 89f607155f..0000000000
--- a/contrib/libs/openjpeg/invert.c
+++ /dev/null
@@ -1,295 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "opj_includes.h"
-
-/**
- * LUP decomposition
- */
-static OPJ_BOOL opj_lupDecompose(OPJ_FLOAT32 * matrix,
- OPJ_UINT32 * permutations,
- OPJ_FLOAT32 * p_swap_area,
- OPJ_UINT32 nb_compo);
-/**
- * LUP solving
- */
-static void opj_lupSolve(OPJ_FLOAT32 * pResult,
- OPJ_FLOAT32* pMatrix,
- OPJ_FLOAT32* pVector,
- OPJ_UINT32* pPermutations,
- OPJ_UINT32 nb_compo,
- OPJ_FLOAT32 * p_intermediate_data);
-
-/**
- *LUP inversion (call with the result of lupDecompose)
- */
-static void opj_lupInvert(OPJ_FLOAT32 * pSrcMatrix,
- OPJ_FLOAT32 * pDestMatrix,
- OPJ_UINT32 nb_compo,
- OPJ_UINT32 * pPermutations,
- OPJ_FLOAT32 * p_src_temp,
- OPJ_FLOAT32 * p_dest_temp,
- OPJ_FLOAT32 * p_swap_area);
-
-/*
-==========================================================
- Matric inversion interface
-==========================================================
-*/
-/**
- * Matrix inversion.
- */
-OPJ_BOOL opj_matrix_inversion_f(OPJ_FLOAT32 * pSrcMatrix,
- OPJ_FLOAT32 * pDestMatrix,
- OPJ_UINT32 nb_compo)
-{
- OPJ_BYTE * l_data = 00;
- OPJ_UINT32 l_permutation_size = nb_compo * (OPJ_UINT32)sizeof(OPJ_UINT32);
- OPJ_UINT32 l_swap_size = nb_compo * (OPJ_UINT32)sizeof(OPJ_FLOAT32);
- OPJ_UINT32 l_total_size = l_permutation_size + 3 * l_swap_size;
- OPJ_UINT32 * lPermutations = 00;
- OPJ_FLOAT32 * l_double_data = 00;
-
- l_data = (OPJ_BYTE *) opj_malloc(l_total_size);
- if (l_data == 0) {
- return OPJ_FALSE;
- }
- lPermutations = (OPJ_UINT32 *) l_data;
- l_double_data = (OPJ_FLOAT32 *)(l_data + l_permutation_size);
- memset(lPermutations, 0, l_permutation_size);
-
- if (! opj_lupDecompose(pSrcMatrix, lPermutations, l_double_data, nb_compo)) {
- opj_free(l_data);
- return OPJ_FALSE;
- }
-
- opj_lupInvert(pSrcMatrix, pDestMatrix, nb_compo, lPermutations, l_double_data,
- l_double_data + nb_compo, l_double_data + 2 * nb_compo);
- opj_free(l_data);
-
- return OPJ_TRUE;
-}
-
-
-/*
-==========================================================
- Local functions
-==========================================================
-*/
-static OPJ_BOOL opj_lupDecompose(OPJ_FLOAT32 * matrix,
- OPJ_UINT32 * permutations,
- OPJ_FLOAT32 * p_swap_area,
- OPJ_UINT32 nb_compo)
-{
- OPJ_UINT32 * tmpPermutations = permutations;
- OPJ_UINT32 * dstPermutations;
- OPJ_UINT32 k2 = 0, t;
- OPJ_FLOAT32 temp;
- OPJ_UINT32 i, j, k;
- OPJ_FLOAT32 p;
- OPJ_UINT32 lLastColum = nb_compo - 1;
- OPJ_UINT32 lSwapSize = nb_compo * (OPJ_UINT32)sizeof(OPJ_FLOAT32);
- OPJ_FLOAT32 * lTmpMatrix = matrix;
- OPJ_FLOAT32 * lColumnMatrix, * lDestMatrix;
- OPJ_UINT32 offset = 1;
- OPJ_UINT32 lStride = nb_compo - 1;
-
- /*initialize permutations */
- for (i = 0; i < nb_compo; ++i) {
- *tmpPermutations++ = i;
- }
- /* now make a pivot with column switch */
- tmpPermutations = permutations;
- for (k = 0; k < lLastColum; ++k) {
- p = 0.0;
-
- /* take the middle element */
- lColumnMatrix = lTmpMatrix + k;
-
- /* make permutation with the biggest value in the column */
- for (i = k; i < nb_compo; ++i) {
- temp = ((*lColumnMatrix > 0) ? *lColumnMatrix : -(*lColumnMatrix));
- if (temp > p) {
- p = temp;
- k2 = i;
- }
- /* next line */
- lColumnMatrix += nb_compo;
- }
-
- /* a whole rest of 0 -> non singular */
- if (p == 0.0) {
- return OPJ_FALSE;
- }
-
- /* should we permute ? */
- if (k2 != k) {
- /*exchange of line */
- /* k2 > k */
- dstPermutations = tmpPermutations + k2 - k;
- /* swap indices */
- t = *tmpPermutations;
- *tmpPermutations = *dstPermutations;
- *dstPermutations = t;
-
- /* and swap entire line. */
- lColumnMatrix = lTmpMatrix + (k2 - k) * nb_compo;
- memcpy(p_swap_area, lColumnMatrix, lSwapSize);
- memcpy(lColumnMatrix, lTmpMatrix, lSwapSize);
- memcpy(lTmpMatrix, p_swap_area, lSwapSize);
- }
-
- /* now update data in the rest of the line and line after */
- lDestMatrix = lTmpMatrix + k;
- lColumnMatrix = lDestMatrix + nb_compo;
- /* take the middle element */
- temp = *(lDestMatrix++);
-
- /* now compute up data (i.e. coeff up of the diagonal). */
- for (i = offset; i < nb_compo; ++i) {
- /*lColumnMatrix; */
- /* divide the lower column elements by the diagonal value */
-
- /* matrix[i][k] /= matrix[k][k]; */
- /* p = matrix[i][k] */
- p = *lColumnMatrix / temp;
- *(lColumnMatrix++) = p;
-
- for (j = /* k + 1 */ offset; j < nb_compo; ++j) {
- /* matrix[i][j] -= matrix[i][k] * matrix[k][j]; */
- *(lColumnMatrix++) -= p * (*(lDestMatrix++));
- }
- /* come back to the k+1th element */
- lDestMatrix -= lStride;
- /* go to kth element of the next line */
- lColumnMatrix += k;
- }
-
- /* offset is now k+2 */
- ++offset;
- /* 1 element less for stride */
- --lStride;
- /* next line */
- lTmpMatrix += nb_compo;
- /* next permutation element */
- ++tmpPermutations;
- }
- return OPJ_TRUE;
-}
-
-static void opj_lupSolve(OPJ_FLOAT32 * pResult,
- OPJ_FLOAT32 * pMatrix,
- OPJ_FLOAT32 * pVector,
- OPJ_UINT32* pPermutations,
- OPJ_UINT32 nb_compo, OPJ_FLOAT32 * p_intermediate_data)
-{
- OPJ_INT32 k;
- OPJ_UINT32 i, j;
- OPJ_FLOAT32 sum;
- OPJ_FLOAT32 u;
- OPJ_UINT32 lStride = nb_compo + 1;
- OPJ_FLOAT32 * lCurrentPtr;
- OPJ_FLOAT32 * lIntermediatePtr;
- OPJ_FLOAT32 * lDestPtr;
- OPJ_FLOAT32 * lTmpMatrix;
- OPJ_FLOAT32 * lLineMatrix = pMatrix;
- OPJ_FLOAT32 * lBeginPtr = pResult + nb_compo - 1;
- OPJ_FLOAT32 * lGeneratedData;
- OPJ_UINT32 * lCurrentPermutationPtr = pPermutations;
-
-
- lIntermediatePtr = p_intermediate_data;
- lGeneratedData = p_intermediate_data + nb_compo - 1;
-
- for (i = 0; i < nb_compo; ++i) {
- sum = 0.0;
- lCurrentPtr = p_intermediate_data;
- lTmpMatrix = lLineMatrix;
- for (j = 1; j <= i; ++j) {
- /* sum += matrix[i][j-1] * y[j-1]; */
- sum += (*(lTmpMatrix++)) * (*(lCurrentPtr++));
- }
- /*y[i] = pVector[pPermutations[i]] - sum; */
- *(lIntermediatePtr++) = pVector[*(lCurrentPermutationPtr++)] - sum;
- lLineMatrix += nb_compo;
- }
-
- /* we take the last point of the matrix */
- lLineMatrix = pMatrix + nb_compo * nb_compo - 1;
-
- /* and we take after the last point of the destination vector */
- lDestPtr = pResult + nb_compo;
-
-
- assert(nb_compo != 0);
- for (k = (OPJ_INT32)nb_compo - 1; k != -1 ; --k) {
- sum = 0.0;
- lTmpMatrix = lLineMatrix;
- u = *(lTmpMatrix++);
- lCurrentPtr = lDestPtr--;
- for (j = (OPJ_UINT32)(k + 1); j < nb_compo; ++j) {
- /* sum += matrix[k][j] * x[j] */
- sum += (*(lTmpMatrix++)) * (*(lCurrentPtr++));
- }
- /*x[k] = (y[k] - sum) / u; */
- *(lBeginPtr--) = (*(lGeneratedData--) - sum) / u;
- lLineMatrix -= lStride;
- }
-}
-
-
-static void opj_lupInvert(OPJ_FLOAT32 * pSrcMatrix,
- OPJ_FLOAT32 * pDestMatrix,
- OPJ_UINT32 nb_compo,
- OPJ_UINT32 * pPermutations,
- OPJ_FLOAT32 * p_src_temp,
- OPJ_FLOAT32 * p_dest_temp,
- OPJ_FLOAT32 * p_swap_area)
-{
- OPJ_UINT32 j, i;
- OPJ_FLOAT32 * lCurrentPtr;
- OPJ_FLOAT32 * lLineMatrix = pDestMatrix;
- OPJ_UINT32 lSwapSize = nb_compo * (OPJ_UINT32)sizeof(OPJ_FLOAT32);
-
- for (j = 0; j < nb_compo; ++j) {
- lCurrentPtr = lLineMatrix++;
- memset(p_src_temp, 0, lSwapSize);
- p_src_temp[j] = 1.0;
- opj_lupSolve(p_dest_temp, pSrcMatrix, p_src_temp, pPermutations, nb_compo,
- p_swap_area);
-
- for (i = 0; i < nb_compo; ++i) {
- *(lCurrentPtr) = p_dest_temp[i];
- lCurrentPtr += nb_compo;
- }
- }
-}
-
diff --git a/contrib/libs/openjpeg/invert.h b/contrib/libs/openjpeg/invert.h
deleted file mode 100644
index 7040213559..0000000000
--- a/contrib/libs/openjpeg/invert.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef OPJ_INVERT_H
-#define OPJ_INVERT_H
-/**
-@file invert.h
-@brief Implementation of the matrix inversion
-
-The function in INVERT.H compute a matrix inversion with a LUP method
-*/
-
-/** @defgroup INVERT INVERT - Implementation of a matrix inversion */
-/*@{*/
-/** @name Exported functions */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-
-/**
- * Calculates a n x n double matrix inversion with a LUP method. Data is aligned, rows after rows (or columns after columns).
- * The function does not take ownership of any memory block, data must be fred by the user.
- *
- * @param pSrcMatrix the matrix to invert.
- * @param pDestMatrix data to store the inverted matrix.
- * @param nb_compo size of the matrix
- * @return OPJ_TRUE if the inversion is successful, OPJ_FALSE if the matrix is singular.
- */
-OPJ_BOOL opj_matrix_inversion_f(OPJ_FLOAT32 * pSrcMatrix,
- OPJ_FLOAT32 * pDestMatrix,
- OPJ_UINT32 nb_compo);
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* OPJ_INVERT_H */
diff --git a/contrib/libs/openjpeg/j2k.c b/contrib/libs/openjpeg/j2k.c
deleted file mode 100644
index a2014c89b0..0000000000
--- a/contrib/libs/openjpeg/j2k.c
+++ /dev/null
@@ -1,13595 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2014, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux
- * Copyright (c) 2003-2014, Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@c-s.fr>
- * Copyright (c) 2006-2007, Parvatha Elangovan
- * Copyright (c) 2010-2011, Kaori Hagihara
- * Copyright (c) 2011-2012, Centre National d'Etudes Spatiales (CNES), France
- * Copyright (c) 2012, CS Systemes d'Information, France
- * Copyright (c) 2017, IntoPIX SA <support@intopix.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "opj_includes.h"
-
-/** @defgroup J2K J2K - JPEG-2000 codestream reader/writer */
-/*@{*/
-
-/** @name Local static functions */
-/*@{*/
-
-/**
- * Sets up the procedures to do on reading header. Developers wanting to extend the library can add their own reading procedures.
- */
-static OPJ_BOOL opj_j2k_setup_header_reading(opj_j2k_t *p_j2k,
- opj_event_mgr_t * p_manager);
-
-/**
- * The read header procedure.
- */
-static OPJ_BOOL opj_j2k_read_header_procedure(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * The default encoding validation procedure without any extension.
- *
- * @param p_j2k the jpeg2000 codec to validate.
- * @param p_stream the input stream to validate.
- * @param p_manager the user event manager.
- *
- * @return true if the parameters are correct.
- */
-static OPJ_BOOL opj_j2k_encoding_validation(opj_j2k_t * p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * The default decoding validation procedure without any extension.
- *
- * @param p_j2k the jpeg2000 codec to validate.
- * @param p_stream the input stream to validate.
- * @param p_manager the user event manager.
- *
- * @return true if the parameters are correct.
- */
-static OPJ_BOOL opj_j2k_decoding_validation(opj_j2k_t * p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * Sets up the validation ,i.e. adds the procedures to launch to make sure the codec parameters
- * are valid. Developers wanting to extend the library can add their own validation procedures.
- */
-static OPJ_BOOL opj_j2k_setup_encoding_validation(opj_j2k_t *p_j2k,
- opj_event_mgr_t * p_manager);
-
-/**
- * Sets up the validation ,i.e. adds the procedures to launch to make sure the codec parameters
- * are valid. Developers wanting to extend the library can add their own validation procedures.
- */
-static OPJ_BOOL opj_j2k_setup_decoding_validation(opj_j2k_t *p_j2k,
- opj_event_mgr_t * p_manager);
-
-/**
- * Sets up the validation ,i.e. adds the procedures to launch to make sure the codec parameters
- * are valid. Developers wanting to extend the library can add their own validation procedures.
- */
-static OPJ_BOOL opj_j2k_setup_end_compress(opj_j2k_t *p_j2k,
- opj_event_mgr_t * p_manager);
-
-/**
- * The mct encoding validation procedure.
- *
- * @param p_j2k the jpeg2000 codec to validate.
- * @param p_stream the input stream to validate.
- * @param p_manager the user event manager.
- *
- * @return true if the parameters are correct.
- */
-static OPJ_BOOL opj_j2k_mct_validation(opj_j2k_t * p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * Builds the tcd decoder to use to decode tile.
- */
-static OPJ_BOOL opj_j2k_build_decoder(opj_j2k_t * p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-/**
- * Builds the tcd encoder to use to encode tile.
- */
-static OPJ_BOOL opj_j2k_build_encoder(opj_j2k_t * p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * Creates a tile-coder encoder.
- *
- * @param p_stream the stream to write data to.
- * @param p_j2k J2K codec.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_create_tcd(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * Executes the given procedures on the given codec.
- *
- * @param p_procedure_list the list of procedures to execute
- * @param p_j2k the jpeg2000 codec to execute the procedures on.
- * @param p_stream the stream to execute the procedures on.
- * @param p_manager the user manager.
- *
- * @return true if all the procedures were successfully executed.
- */
-static OPJ_BOOL opj_j2k_exec(opj_j2k_t * p_j2k,
- opj_procedure_list_t * p_procedure_list,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * Updates the rates of the tcp.
- *
- * @param p_stream the stream to write data to.
- * @param p_j2k J2K codec.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_update_rates(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * Copies the decoding tile parameters onto all the tile parameters.
- * Creates also the tile decoder.
- */
-static OPJ_BOOL opj_j2k_copy_default_tcp_and_create_tcd(opj_j2k_t * p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * Destroys the memory associated with the decoding of headers.
- */
-static OPJ_BOOL opj_j2k_destroy_header_memory(opj_j2k_t * p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * Reads the lookup table containing all the marker, status and action, and returns the handler associated
- * with the marker value.
- * @param p_id Marker value to look up
- *
- * @return the handler associated with the id.
-*/
-static const struct opj_dec_memory_marker_handler * opj_j2k_get_marker_handler(
- OPJ_UINT32 p_id);
-
-/**
- * Destroys a tile coding parameter structure.
- *
- * @param p_tcp the tile coding parameter to destroy.
- */
-static void opj_j2k_tcp_destroy(opj_tcp_t *p_tcp);
-
-/**
- * Destroys the data inside a tile coding parameter structure.
- *
- * @param p_tcp the tile coding parameter which contain data to destroy.
- */
-static void opj_j2k_tcp_data_destroy(opj_tcp_t *p_tcp);
-
-/**
- * Destroys a coding parameter structure.
- *
- * @param p_cp the coding parameter to destroy.
- */
-static void opj_j2k_cp_destroy(opj_cp_t *p_cp);
-
-/**
- * Compare 2 a SPCod/ SPCoc elements, i.e. the coding style of a given component of a tile.
- *
- * @param p_j2k J2K codec.
- * @param p_tile_no Tile number
- * @param p_first_comp_no The 1st component number to compare.
- * @param p_second_comp_no The 1st component number to compare.
- *
- * @return OPJ_TRUE if SPCdod are equals.
- */
-static OPJ_BOOL opj_j2k_compare_SPCod_SPCoc(opj_j2k_t *p_j2k,
- OPJ_UINT32 p_tile_no, OPJ_UINT32 p_first_comp_no, OPJ_UINT32 p_second_comp_no);
-
-/**
- * Writes a SPCod or SPCoc element, i.e. the coding style of a given component of a tile.
- *
- * @param p_j2k J2K codec.
- * @param p_tile_no FIXME DOC
- * @param p_comp_no the component number to output.
- * @param p_data FIXME DOC
- * @param p_header_size FIXME DOC
- * @param p_manager the user event manager.
- *
- * @return FIXME DOC
-*/
-static OPJ_BOOL opj_j2k_write_SPCod_SPCoc(opj_j2k_t *p_j2k,
- OPJ_UINT32 p_tile_no,
- OPJ_UINT32 p_comp_no,
- OPJ_BYTE * p_data,
- OPJ_UINT32 * p_header_size,
- opj_event_mgr_t * p_manager);
-
-/**
- * Gets the size taken by writing a SPCod or SPCoc for the given tile and component.
- *
- * @param p_j2k the J2K codec.
- * @param p_tile_no the tile index.
- * @param p_comp_no the component being outputted.
- *
- * @return the number of bytes taken by the SPCod element.
- */
-static OPJ_UINT32 opj_j2k_get_SPCod_SPCoc_size(opj_j2k_t *p_j2k,
- OPJ_UINT32 p_tile_no,
- OPJ_UINT32 p_comp_no);
-
-/**
- * Reads a SPCod or SPCoc element, i.e. the coding style of a given component of a tile.
- * @param p_j2k the jpeg2000 codec.
- * @param compno FIXME DOC
- * @param p_header_data the data contained in the COM box.
- * @param p_header_size the size of the data contained in the COM marker.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_SPCod_SPCoc(opj_j2k_t *p_j2k,
- OPJ_UINT32 compno,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 * p_header_size,
- opj_event_mgr_t * p_manager);
-
-/**
- * Gets the size taken by writing SQcd or SQcc element, i.e. the quantization values of a band in the QCD or QCC.
- *
- * @param p_tile_no the tile index.
- * @param p_comp_no the component being outputted.
- * @param p_j2k the J2K codec.
- *
- * @return the number of bytes taken by the SPCod element.
- */
-static OPJ_UINT32 opj_j2k_get_SQcd_SQcc_size(opj_j2k_t *p_j2k,
- OPJ_UINT32 p_tile_no,
- OPJ_UINT32 p_comp_no);
-
-/**
- * Compares 2 SQcd or SQcc element, i.e. the quantization values of a band in the QCD or QCC.
- *
- * @param p_j2k J2K codec.
- * @param p_tile_no the tile to output.
- * @param p_first_comp_no the first component number to compare.
- * @param p_second_comp_no the second component number to compare.
- *
- * @return OPJ_TRUE if equals.
- */
-static OPJ_BOOL opj_j2k_compare_SQcd_SQcc(opj_j2k_t *p_j2k,
- OPJ_UINT32 p_tile_no, OPJ_UINT32 p_first_comp_no, OPJ_UINT32 p_second_comp_no);
-
-
-/**
- * Writes a SQcd or SQcc element, i.e. the quantization values of a band in the QCD or QCC.
- *
- * @param p_tile_no the tile to output.
- * @param p_comp_no the component number to output.
- * @param p_data the data buffer.
- * @param p_header_size pointer to the size of the data buffer, it is changed by the function.
- * @param p_j2k J2K codec.
- * @param p_manager the user event manager.
- *
-*/
-static OPJ_BOOL opj_j2k_write_SQcd_SQcc(opj_j2k_t *p_j2k,
- OPJ_UINT32 p_tile_no,
- OPJ_UINT32 p_comp_no,
- OPJ_BYTE * p_data,
- OPJ_UINT32 * p_header_size,
- opj_event_mgr_t * p_manager);
-
-/**
- * Updates the Tile Length Marker.
- */
-static void opj_j2k_update_tlm(opj_j2k_t * p_j2k, OPJ_UINT32 p_tile_part_size);
-
-/**
- * Reads a SQcd or SQcc element, i.e. the quantization values of a band in the QCD or QCC.
- *
- * @param p_j2k J2K codec.
- * @param compno the component number to output.
- * @param p_header_data the data buffer.
- * @param p_header_size pointer to the size of the data buffer, it is changed by the function.
- * @param p_manager the user event manager.
- *
-*/
-static OPJ_BOOL opj_j2k_read_SQcd_SQcc(opj_j2k_t *p_j2k,
- OPJ_UINT32 compno,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 * p_header_size,
- opj_event_mgr_t * p_manager);
-
-/**
- * Copies the tile component parameters of all the component from the first tile component.
- *
- * @param p_j2k the J2k codec.
- */
-static void opj_j2k_copy_tile_component_parameters(opj_j2k_t *p_j2k);
-
-/**
- * Copies the tile quantization parameters of all the component from the first tile component.
- *
- * @param p_j2k the J2k codec.
- */
-static void opj_j2k_copy_tile_quantization_parameters(opj_j2k_t *p_j2k);
-
-/**
- * Reads the tiles.
- */
-static OPJ_BOOL opj_j2k_decode_tiles(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-static OPJ_BOOL opj_j2k_pre_write_tile(opj_j2k_t * p_j2k,
- OPJ_UINT32 p_tile_index,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-static OPJ_BOOL opj_j2k_update_image_data(opj_tcd_t * p_tcd,
- opj_image_t* p_output_image);
-
-static void opj_get_tile_dimensions(opj_image_t * l_image,
- opj_tcd_tilecomp_t * l_tilec,
- opj_image_comp_t * l_img_comp,
- OPJ_UINT32* l_size_comp,
- OPJ_UINT32* l_width,
- OPJ_UINT32* l_height,
- OPJ_UINT32* l_offset_x,
- OPJ_UINT32* l_offset_y,
- OPJ_UINT32* l_image_width,
- OPJ_UINT32* l_stride,
- OPJ_UINT32* l_tile_offset);
-
-static void opj_j2k_get_tile_data(opj_tcd_t * p_tcd, OPJ_BYTE * p_data);
-
-static OPJ_BOOL opj_j2k_post_write_tile(opj_j2k_t * p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * Sets up the procedures to do on writing header.
- * Developers wanting to extend the library can add their own writing procedures.
- */
-static OPJ_BOOL opj_j2k_setup_header_writing(opj_j2k_t *p_j2k,
- opj_event_mgr_t * p_manager);
-
-static OPJ_BOOL opj_j2k_write_first_tile_part(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_data,
- OPJ_UINT32 * p_data_written,
- OPJ_UINT32 total_data_size,
- opj_stream_private_t *p_stream,
- struct opj_event_mgr * p_manager);
-
-static OPJ_BOOL opj_j2k_write_all_tile_parts(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_data,
- OPJ_UINT32 * p_data_written,
- OPJ_UINT32 total_data_size,
- opj_stream_private_t *p_stream,
- struct opj_event_mgr * p_manager);
-
-/**
- * Gets the offset of the header.
- *
- * @param p_stream the stream to write data to.
- * @param p_j2k J2K codec.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_get_end_header(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-static OPJ_BOOL opj_j2k_allocate_tile_element_cstr_index(opj_j2k_t *p_j2k);
-
-/*
- * -----------------------------------------------------------------------
- * -----------------------------------------------------------------------
- * -----------------------------------------------------------------------
- */
-
-/**
- * Writes the SOC marker (Start Of Codestream)
- *
- * @param p_stream the stream to write data to.
- * @param p_j2k J2K codec.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_write_soc(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * Reads a SOC marker (Start of Codestream)
- * @param p_j2k the jpeg2000 file codec.
- * @param p_stream XXX needs data
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_soc(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * Writes the SIZ marker (image and tile size)
- *
- * @param p_j2k J2K codec.
- * @param p_stream the stream to write data to.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_write_siz(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * Reads a SIZ marker (image and tile size)
- * @param p_j2k the jpeg2000 file codec.
- * @param p_header_data the data contained in the SIZ box.
- * @param p_header_size the size of the data contained in the SIZ marker.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_siz(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager);
-
-/**
- * Writes the COM marker (comment)
- *
- * @param p_stream the stream to write data to.
- * @param p_j2k J2K codec.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_write_com(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * Reads a COM marker (comments)
- * @param p_j2k the jpeg2000 file codec.
- * @param p_header_data the data contained in the COM box.
- * @param p_header_size the size of the data contained in the COM marker.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_com(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager);
-/**
- * Writes the COD marker (Coding style default)
- *
- * @param p_stream the stream to write data to.
- * @param p_j2k J2K codec.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_write_cod(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * Reads a COD marker (Coding style defaults)
- * @param p_header_data the data contained in the COD box.
- * @param p_j2k the jpeg2000 codec.
- * @param p_header_size the size of the data contained in the COD marker.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_cod(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager);
-
-/**
- * Compares 2 COC markers (Coding style component)
- *
- * @param p_j2k J2K codec.
- * @param p_first_comp_no the index of the first component to compare.
- * @param p_second_comp_no the index of the second component to compare.
- *
- * @return OPJ_TRUE if equals
- */
-static OPJ_BOOL opj_j2k_compare_coc(opj_j2k_t *p_j2k,
- OPJ_UINT32 p_first_comp_no, OPJ_UINT32 p_second_comp_no);
-
-/**
- * Writes the COC marker (Coding style component)
- *
- * @param p_j2k J2K codec.
- * @param p_comp_no the index of the component to output.
- * @param p_stream the stream to write data to.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_write_coc(opj_j2k_t *p_j2k,
- OPJ_UINT32 p_comp_no,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * Writes the COC marker (Coding style component)
- *
- * @param p_j2k J2K codec.
- * @param p_comp_no the index of the component to output.
- * @param p_data FIXME DOC
- * @param p_data_written FIXME DOC
- * @param p_manager the user event manager.
-*/
-static void opj_j2k_write_coc_in_memory(opj_j2k_t *p_j2k,
- OPJ_UINT32 p_comp_no,
- OPJ_BYTE * p_data,
- OPJ_UINT32 * p_data_written,
- opj_event_mgr_t * p_manager);
-
-/**
- * Gets the maximum size taken by a coc.
- *
- * @param p_j2k the jpeg2000 codec to use.
- */
-static OPJ_UINT32 opj_j2k_get_max_coc_size(opj_j2k_t *p_j2k);
-
-/**
- * Reads a COC marker (Coding Style Component)
- * @param p_header_data the data contained in the COC box.
- * @param p_j2k the jpeg2000 codec.
- * @param p_header_size the size of the data contained in the COC marker.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_coc(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager);
-
-/**
- * Writes the QCD marker (quantization default)
- *
- * @param p_j2k J2K codec.
- * @param p_stream the stream to write data to.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_write_qcd(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * Reads a QCD marker (Quantization defaults)
- * @param p_header_data the data contained in the QCD box.
- * @param p_j2k the jpeg2000 codec.
- * @param p_header_size the size of the data contained in the QCD marker.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_qcd(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager);
-
-/**
- * Compare QCC markers (quantization component)
- *
- * @param p_j2k J2K codec.
- * @param p_first_comp_no the index of the first component to compare.
- * @param p_second_comp_no the index of the second component to compare.
- *
- * @return OPJ_TRUE if equals.
- */
-static OPJ_BOOL opj_j2k_compare_qcc(opj_j2k_t *p_j2k,
- OPJ_UINT32 p_first_comp_no, OPJ_UINT32 p_second_comp_no);
-
-/**
- * Writes the QCC marker (quantization component)
- *
- * @param p_comp_no the index of the component to output.
- * @param p_stream the stream to write data to.
- * @param p_j2k J2K codec.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_write_qcc(opj_j2k_t *p_j2k,
- OPJ_UINT32 p_comp_no,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * Writes the QCC marker (quantization component)
- *
- * @param p_j2k J2K codec.
- * @param p_comp_no the index of the component to output.
- * @param p_data FIXME DOC
- * @param p_data_written the stream to write data to.
- * @param p_manager the user event manager.
-*/
-static void opj_j2k_write_qcc_in_memory(opj_j2k_t *p_j2k,
- OPJ_UINT32 p_comp_no,
- OPJ_BYTE * p_data,
- OPJ_UINT32 * p_data_written,
- opj_event_mgr_t * p_manager);
-
-/**
- * Gets the maximum size taken by a qcc.
- */
-static OPJ_UINT32 opj_j2k_get_max_qcc_size(opj_j2k_t *p_j2k);
-
-/**
- * Reads a QCC marker (Quantization component)
- * @param p_header_data the data contained in the QCC box.
- * @param p_j2k the jpeg2000 codec.
- * @param p_header_size the size of the data contained in the QCC marker.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_qcc(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager);
-/**
- * Writes the POC marker (Progression Order Change)
- *
- * @param p_stream the stream to write data to.
- * @param p_j2k J2K codec.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_write_poc(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-/**
- * Writes the POC marker (Progression Order Change)
- *
- * @param p_j2k J2K codec.
- * @param p_data FIXME DOC
- * @param p_data_written the stream to write data to.
- * @param p_manager the user event manager.
- */
-static void opj_j2k_write_poc_in_memory(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_data,
- OPJ_UINT32 * p_data_written,
- opj_event_mgr_t * p_manager);
-/**
- * Gets the maximum size taken by the writing of a POC.
- */
-static OPJ_UINT32 opj_j2k_get_max_poc_size(opj_j2k_t *p_j2k);
-
-/**
- * Reads a POC marker (Progression Order Change)
- *
- * @param p_header_data the data contained in the POC box.
- * @param p_j2k the jpeg2000 codec.
- * @param p_header_size the size of the data contained in the POC marker.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_poc(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager);
-
-/**
- * Gets the maximum size taken by the toc headers of all the tile parts of any given tile.
- */
-static OPJ_UINT32 opj_j2k_get_max_toc_size(opj_j2k_t *p_j2k);
-
-/**
- * Gets the maximum size taken by the headers of the SOT.
- *
- * @param p_j2k the jpeg2000 codec to use.
- */
-static OPJ_UINT32 opj_j2k_get_specific_header_sizes(opj_j2k_t *p_j2k);
-
-/**
- * Reads a CRG marker (Component registration)
- *
- * @param p_header_data the data contained in the TLM box.
- * @param p_j2k the jpeg2000 codec.
- * @param p_header_size the size of the data contained in the TLM marker.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_crg(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager);
-/**
- * Reads a TLM marker (Tile Length Marker)
- *
- * @param p_header_data the data contained in the TLM box.
- * @param p_j2k the jpeg2000 codec.
- * @param p_header_size the size of the data contained in the TLM marker.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_tlm(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager);
-
-/**
- * Writes the updated tlm.
- *
- * @param p_stream the stream to write data to.
- * @param p_j2k J2K codec.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_write_updated_tlm(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * Reads a PLM marker (Packet length, main header marker)
- *
- * @param p_header_data the data contained in the TLM box.
- * @param p_j2k the jpeg2000 codec.
- * @param p_header_size the size of the data contained in the TLM marker.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_plm(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager);
-/**
- * Reads a PLT marker (Packet length, tile-part header)
- *
- * @param p_header_data the data contained in the PLT box.
- * @param p_j2k the jpeg2000 codec.
- * @param p_header_size the size of the data contained in the PLT marker.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_plt(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager);
-
-/**
- * Reads a PPM marker (Packed headers, main header)
- *
- * @param p_header_data the data contained in the POC box.
- * @param p_j2k the jpeg2000 codec.
- * @param p_header_size the size of the data contained in the POC marker.
- * @param p_manager the user event manager.
- */
-
-static OPJ_BOOL opj_j2k_read_ppm(
- opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager);
-
-/**
- * Merges all PPM markers read (Packed headers, main header)
- *
- * @param p_cp main coding parameters.
- * @param p_manager the user event manager.
- */
-static OPJ_BOOL opj_j2k_merge_ppm(opj_cp_t *p_cp, opj_event_mgr_t * p_manager);
-
-/**
- * Reads a PPT marker (Packed packet headers, tile-part header)
- *
- * @param p_header_data the data contained in the PPT box.
- * @param p_j2k the jpeg2000 codec.
- * @param p_header_size the size of the data contained in the PPT marker.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_ppt(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager);
-
-/**
- * Merges all PPT markers read (Packed headers, tile-part header)
- *
- * @param p_tcp the tile.
- * @param p_manager the user event manager.
- */
-static OPJ_BOOL opj_j2k_merge_ppt(opj_tcp_t *p_tcp,
- opj_event_mgr_t * p_manager);
-
-
-/**
- * Writes the TLM marker (Tile Length Marker)
- *
- * @param p_stream the stream to write data to.
- * @param p_j2k J2K codec.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_write_tlm(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * Writes the SOT marker (Start of tile-part)
- *
- * @param p_j2k J2K codec.
- * @param p_data Output buffer
- * @param total_data_size Output buffer size
- * @param p_data_written Number of bytes written into stream
- * @param p_stream the stream to write data to.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_write_sot(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_data,
- OPJ_UINT32 total_data_size,
- OPJ_UINT32 * p_data_written,
- const opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * Reads values from a SOT marker (Start of tile-part)
- *
- * the j2k decoder state is not affected. No side effects, no checks except for p_header_size.
- *
- * @param p_header_data the data contained in the SOT marker.
- * @param p_header_size the size of the data contained in the SOT marker.
- * @param p_tile_no Isot.
- * @param p_tot_len Psot.
- * @param p_current_part TPsot.
- * @param p_num_parts TNsot.
- * @param p_manager the user event manager.
- */
-static OPJ_BOOL opj_j2k_get_sot_values(OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- OPJ_UINT32* p_tile_no,
- OPJ_UINT32* p_tot_len,
- OPJ_UINT32* p_current_part,
- OPJ_UINT32* p_num_parts,
- opj_event_mgr_t * p_manager);
-/**
- * Reads a SOT marker (Start of tile-part)
- *
- * @param p_header_data the data contained in the SOT marker.
- * @param p_j2k the jpeg2000 codec.
- * @param p_header_size the size of the data contained in the PPT marker.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_sot(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager);
-/**
- * Writes the SOD marker (Start of data)
- *
- * This also writes optional PLT markers (before SOD)
- *
- * @param p_j2k J2K codec.
- * @param p_tile_coder FIXME DOC
- * @param p_data FIXME DOC
- * @param p_data_written FIXME DOC
- * @param total_data_size FIXME DOC
- * @param p_stream the stream to write data to.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_write_sod(opj_j2k_t *p_j2k,
- opj_tcd_t * p_tile_coder,
- OPJ_BYTE * p_data,
- OPJ_UINT32 * p_data_written,
- OPJ_UINT32 total_data_size,
- const opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * Reads a SOD marker (Start Of Data)
- *
- * @param p_j2k the jpeg2000 codec.
- * @param p_stream FIXME DOC
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_sod(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-static void opj_j2k_update_tlm(opj_j2k_t * p_j2k, OPJ_UINT32 p_tile_part_size)
-{
- if (p_j2k->m_specific_param.m_encoder.m_Ttlmi_is_byte) {
- opj_write_bytes(p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_current,
- p_j2k->m_current_tile_number, 1);
- p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_current += 1;
- } else {
- opj_write_bytes(p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_current,
- p_j2k->m_current_tile_number, 2);
- p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_current += 2;
- }
-
- opj_write_bytes(p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_current,
- p_tile_part_size, 4); /* PSOT */
- p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_current += 4;
-}
-
-/**
- * Writes the RGN marker (Region Of Interest)
- *
- * @param p_tile_no the tile to output
- * @param p_comp_no the component to output
- * @param nb_comps the number of components
- * @param p_stream the stream to write data to.
- * @param p_j2k J2K codec.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_write_rgn(opj_j2k_t *p_j2k,
- OPJ_UINT32 p_tile_no,
- OPJ_UINT32 p_comp_no,
- OPJ_UINT32 nb_comps,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * Reads a RGN marker (Region Of Interest)
- *
- * @param p_header_data the data contained in the POC box.
- * @param p_j2k the jpeg2000 codec.
- * @param p_header_size the size of the data contained in the POC marker.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_rgn(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager);
-
-/**
- * Writes the EOC marker (End of Codestream)
- *
- * @param p_stream the stream to write data to.
- * @param p_j2k J2K codec.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_write_eoc(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-#if 0
-/**
- * Reads a EOC marker (End Of Codestream)
- *
- * @param p_j2k the jpeg2000 codec.
- * @param p_stream FIXME DOC
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_eoc(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-#endif
-
-/**
- * Writes the CBD-MCT-MCC-MCO markers (Multi components transform)
- *
- * @param p_stream the stream to write data to.
- * @param p_j2k J2K codec.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_write_mct_data_group(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * Inits the Info
- *
- * @param p_stream the stream to write data to.
- * @param p_j2k J2K codec.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_init_info(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-/**
-Add main header marker information
-@param cstr_index Codestream information structure
-@param type marker type
-@param pos byte offset of marker segment
-@param len length of marker segment
- */
-static OPJ_BOOL opj_j2k_add_mhmarker(opj_codestream_index_t *cstr_index,
- OPJ_UINT32 type, OPJ_OFF_T pos, OPJ_UINT32 len) ;
-/**
-Add tile header marker information
-@param tileno tile index number
-@param cstr_index Codestream information structure
-@param type marker type
-@param pos byte offset of marker segment
-@param len length of marker segment
- */
-static OPJ_BOOL opj_j2k_add_tlmarker(OPJ_UINT32 tileno,
- opj_codestream_index_t *cstr_index, OPJ_UINT32 type, OPJ_OFF_T pos,
- OPJ_UINT32 len);
-
-/**
- * Reads an unknown marker
- *
- * @param p_j2k the jpeg2000 codec.
- * @param p_stream the stream object to read from.
- * @param output_marker FIXME DOC
- * @param p_manager the user event manager.
- *
- * @return true if the marker could be deduced.
-*/
-static OPJ_BOOL opj_j2k_read_unk(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- OPJ_UINT32 *output_marker,
- opj_event_mgr_t * p_manager);
-
-/**
- * Writes the MCT marker (Multiple Component Transform)
- *
- * @param p_j2k J2K codec.
- * @param p_mct_record FIXME DOC
- * @param p_stream the stream to write data to.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_write_mct_record(opj_j2k_t *p_j2k,
- opj_mct_data_t * p_mct_record,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * Reads a MCT marker (Multiple Component Transform)
- *
- * @param p_header_data the data contained in the MCT box.
- * @param p_j2k the jpeg2000 codec.
- * @param p_header_size the size of the data contained in the MCT marker.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_mct(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager);
-
-/**
- * Writes the MCC marker (Multiple Component Collection)
- *
- * @param p_j2k J2K codec.
- * @param p_mcc_record FIXME DOC
- * @param p_stream the stream to write data to.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_write_mcc_record(opj_j2k_t *p_j2k,
- opj_simple_mcc_decorrelation_data_t * p_mcc_record,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * Reads a MCC marker (Multiple Component Collection)
- *
- * @param p_header_data the data contained in the MCC box.
- * @param p_j2k the jpeg2000 codec.
- * @param p_header_size the size of the data contained in the MCC marker.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_mcc(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager);
-
-/**
- * Writes the MCO marker (Multiple component transformation ordering)
- *
- * @param p_stream the stream to write data to.
- * @param p_j2k J2K codec.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_write_mco(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * Reads a MCO marker (Multiple Component Transform Ordering)
- *
- * @param p_header_data the data contained in the MCO box.
- * @param p_j2k the jpeg2000 codec.
- * @param p_header_size the size of the data contained in the MCO marker.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_mco(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager);
-
-static OPJ_BOOL opj_j2k_add_mct(opj_tcp_t * p_tcp, opj_image_t * p_image,
- OPJ_UINT32 p_index);
-
-static void opj_j2k_read_int16_to_float(const void * p_src_data,
- void * p_dest_data, OPJ_UINT32 p_nb_elem);
-static void opj_j2k_read_int32_to_float(const void * p_src_data,
- void * p_dest_data, OPJ_UINT32 p_nb_elem);
-static void opj_j2k_read_float32_to_float(const void * p_src_data,
- void * p_dest_data, OPJ_UINT32 p_nb_elem);
-static void opj_j2k_read_float64_to_float(const void * p_src_data,
- void * p_dest_data, OPJ_UINT32 p_nb_elem);
-
-static void opj_j2k_read_int16_to_int32(const void * p_src_data,
- void * p_dest_data, OPJ_UINT32 p_nb_elem);
-static void opj_j2k_read_int32_to_int32(const void * p_src_data,
- void * p_dest_data, OPJ_UINT32 p_nb_elem);
-static void opj_j2k_read_float32_to_int32(const void * p_src_data,
- void * p_dest_data, OPJ_UINT32 p_nb_elem);
-static void opj_j2k_read_float64_to_int32(const void * p_src_data,
- void * p_dest_data, OPJ_UINT32 p_nb_elem);
-
-static void opj_j2k_write_float_to_int16(const void * p_src_data,
- void * p_dest_data, OPJ_UINT32 p_nb_elem);
-static void opj_j2k_write_float_to_int32(const void * p_src_data,
- void * p_dest_data, OPJ_UINT32 p_nb_elem);
-static void opj_j2k_write_float_to_float(const void * p_src_data,
- void * p_dest_data, OPJ_UINT32 p_nb_elem);
-static void opj_j2k_write_float_to_float64(const void * p_src_data,
- void * p_dest_data, OPJ_UINT32 p_nb_elem);
-
-/**
- * Ends the encoding, i.e. frees memory.
- *
- * @param p_stream the stream to write data to.
- * @param p_j2k J2K codec.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_end_encoding(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * Writes the CBD marker (Component bit depth definition)
- *
- * @param p_stream the stream to write data to.
- * @param p_j2k J2K codec.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_write_cbd(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * Reads a CBD marker (Component bit depth definition)
- * @param p_header_data the data contained in the CBD box.
- * @param p_j2k the jpeg2000 codec.
- * @param p_header_size the size of the data contained in the CBD marker.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_cbd(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager);
-
-/**
- * Reads a CAP marker (extended capabilities definition). Empty implementation.
- * Found in HTJ2K files
- *
- * @param p_header_data the data contained in the CAP box.
- * @param p_j2k the jpeg2000 codec.
- * @param p_header_size the size of the data contained in the CAP marker.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_cap(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager);
-
-/**
- * Reads a CPF marker (corresponding profile). Empty implementation. Found in HTJ2K files
- * @param p_header_data the data contained in the CPF box.
- * @param p_j2k the jpeg2000 codec.
- * @param p_header_size the size of the data contained in the CPF marker.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_cpf(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager);
-
-
-/**
- * Writes COC marker for each component.
- *
- * @param p_stream the stream to write data to.
- * @param p_j2k J2K codec.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_write_all_coc(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * Writes QCC marker for each component.
- *
- * @param p_stream the stream to write data to.
- * @param p_j2k J2K codec.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_write_all_qcc(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * Writes regions of interests.
- *
- * @param p_stream the stream to write data to.
- * @param p_j2k J2K codec.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_write_regions(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * Writes EPC ????
- *
- * @param p_stream the stream to write data to.
- * @param p_j2k J2K codec.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_write_epc(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * Checks the progression order changes values. Tells of the poc given as input are valid.
- * A nice message is outputted at errors.
- *
- * @param p_pocs the progression order changes.
- * @param tileno the tile number of interest
- * @param p_nb_pocs the number of progression order changes.
- * @param p_nb_resolutions the number of resolutions.
- * @param numcomps the number of components
- * @param numlayers the number of layers.
- * @param p_manager the user event manager.
- *
- * @return true if the pocs are valid.
- */
-static OPJ_BOOL opj_j2k_check_poc_val(const opj_poc_t *p_pocs,
- OPJ_UINT32 tileno,
- OPJ_UINT32 p_nb_pocs,
- OPJ_UINT32 p_nb_resolutions,
- OPJ_UINT32 numcomps,
- OPJ_UINT32 numlayers,
- opj_event_mgr_t * p_manager);
-
-/**
- * Gets the number of tile parts used for the given change of progression (if any) and the given tile.
- *
- * @param cp the coding parameters.
- * @param pino the offset of the given poc (i.e. its position in the coding parameter).
- * @param tileno the given tile.
- *
- * @return the number of tile parts.
- */
-static OPJ_UINT32 opj_j2k_get_num_tp(opj_cp_t *cp, OPJ_UINT32 pino,
- OPJ_UINT32 tileno);
-
-/**
- * Calculates the total number of tile parts needed by the encoder to
- * encode such an image. If not enough memory is available, then the function return false.
- *
- * @param p_nb_tiles pointer that will hold the number of tile parts.
- * @param cp the coding parameters for the image.
- * @param image the image to encode.
- * @param p_j2k the p_j2k encoder.
- * @param p_manager the user event manager.
- *
- * @return true if the function was successful, false else.
- */
-static OPJ_BOOL opj_j2k_calculate_tp(opj_j2k_t *p_j2k,
- opj_cp_t *cp,
- OPJ_UINT32 * p_nb_tiles,
- opj_image_t *image,
- opj_event_mgr_t * p_manager);
-
-static void opj_j2k_dump_MH_info(opj_j2k_t* p_j2k, FILE* out_stream);
-
-static void opj_j2k_dump_MH_index(opj_j2k_t* p_j2k, FILE* out_stream);
-
-static opj_codestream_index_t* opj_j2k_create_cstr_index(void);
-
-static OPJ_FLOAT32 opj_j2k_get_tp_stride(opj_tcp_t * p_tcp);
-
-static OPJ_FLOAT32 opj_j2k_get_default_stride(opj_tcp_t * p_tcp);
-
-static int opj_j2k_initialise_4K_poc(opj_poc_t *POC, int numres);
-
-static void opj_j2k_set_cinema_parameters(opj_cparameters_t *parameters,
- opj_image_t *image, opj_event_mgr_t *p_manager);
-
-static OPJ_BOOL opj_j2k_is_cinema_compliant(opj_image_t *image, OPJ_UINT16 rsiz,
- opj_event_mgr_t *p_manager);
-
-static void opj_j2k_set_imf_parameters(opj_cparameters_t *parameters,
- opj_image_t *image, opj_event_mgr_t *p_manager);
-
-static OPJ_BOOL opj_j2k_is_imf_compliant(opj_cparameters_t *parameters,
- opj_image_t *image,
- opj_event_mgr_t *p_manager);
-
-/**
- * Checks for invalid number of tile-parts in SOT marker (TPsot==TNsot). See issue 254.
- *
- * @param p_stream the stream to read data from.
- * @param tile_no tile number we're looking for.
- * @param p_correction_needed output value. if true, non conformant codestream needs TNsot correction.
- * @param p_manager the user event manager.
- *
- * @return true if the function was successful, false else.
- */
-static OPJ_BOOL opj_j2k_need_nb_tile_parts_correction(opj_stream_private_t
- *p_stream, OPJ_UINT32 tile_no, OPJ_BOOL* p_correction_needed,
- opj_event_mgr_t * p_manager);
-
-/*@}*/
-
-/*@}*/
-
-/* ----------------------------------------------------------------------- */
-typedef struct j2k_prog_order {
- OPJ_PROG_ORDER enum_prog;
- char str_prog[5];
-} j2k_prog_order_t;
-
-static const j2k_prog_order_t j2k_prog_order_list[] = {
- {OPJ_CPRL, "CPRL"},
- {OPJ_LRCP, "LRCP"},
- {OPJ_PCRL, "PCRL"},
- {OPJ_RLCP, "RLCP"},
- {OPJ_RPCL, "RPCL"},
- {(OPJ_PROG_ORDER) - 1, ""}
-};
-
-/**
- * FIXME DOC
- */
-static const OPJ_UINT32 MCT_ELEMENT_SIZE [] = {
- 2,
- 4,
- 4,
- 8
-};
-
-typedef void (* opj_j2k_mct_function)(const void * p_src_data,
- void * p_dest_data, OPJ_UINT32 p_nb_elem);
-
-static const opj_j2k_mct_function j2k_mct_read_functions_to_float [] = {
- opj_j2k_read_int16_to_float,
- opj_j2k_read_int32_to_float,
- opj_j2k_read_float32_to_float,
- opj_j2k_read_float64_to_float
-};
-
-static const opj_j2k_mct_function j2k_mct_read_functions_to_int32 [] = {
- opj_j2k_read_int16_to_int32,
- opj_j2k_read_int32_to_int32,
- opj_j2k_read_float32_to_int32,
- opj_j2k_read_float64_to_int32
-};
-
-static const opj_j2k_mct_function j2k_mct_write_functions_from_float [] = {
- opj_j2k_write_float_to_int16,
- opj_j2k_write_float_to_int32,
- opj_j2k_write_float_to_float,
- opj_j2k_write_float_to_float64
-};
-
-typedef struct opj_dec_memory_marker_handler {
- /** marker value */
- OPJ_UINT32 id;
- /** value of the state when the marker can appear */
- OPJ_UINT32 states;
- /** action linked to the marker */
- OPJ_BOOL(*handler)(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager);
-}
-opj_dec_memory_marker_handler_t;
-
-static const opj_dec_memory_marker_handler_t j2k_memory_marker_handler_tab [] =
-{
- {J2K_MS_SOT, J2K_STATE_MH | J2K_STATE_TPHSOT, opj_j2k_read_sot},
- {J2K_MS_COD, J2K_STATE_MH | J2K_STATE_TPH, opj_j2k_read_cod},
- {J2K_MS_COC, J2K_STATE_MH | J2K_STATE_TPH, opj_j2k_read_coc},
- {J2K_MS_RGN, J2K_STATE_MH | J2K_STATE_TPH, opj_j2k_read_rgn},
- {J2K_MS_QCD, J2K_STATE_MH | J2K_STATE_TPH, opj_j2k_read_qcd},
- {J2K_MS_QCC, J2K_STATE_MH | J2K_STATE_TPH, opj_j2k_read_qcc},
- {J2K_MS_POC, J2K_STATE_MH | J2K_STATE_TPH, opj_j2k_read_poc},
- {J2K_MS_SIZ, J2K_STATE_MHSIZ, opj_j2k_read_siz},
- {J2K_MS_TLM, J2K_STATE_MH, opj_j2k_read_tlm},
- {J2K_MS_PLM, J2K_STATE_MH, opj_j2k_read_plm},
- {J2K_MS_PLT, J2K_STATE_TPH, opj_j2k_read_plt},
- {J2K_MS_PPM, J2K_STATE_MH, opj_j2k_read_ppm},
- {J2K_MS_PPT, J2K_STATE_TPH, opj_j2k_read_ppt},
- {J2K_MS_SOP, 0, 0},
- {J2K_MS_CRG, J2K_STATE_MH, opj_j2k_read_crg},
- {J2K_MS_COM, J2K_STATE_MH | J2K_STATE_TPH, opj_j2k_read_com},
- {J2K_MS_MCT, J2K_STATE_MH | J2K_STATE_TPH, opj_j2k_read_mct},
- {J2K_MS_CBD, J2K_STATE_MH, opj_j2k_read_cbd},
- {J2K_MS_CAP, J2K_STATE_MH, opj_j2k_read_cap},
- {J2K_MS_CPF, J2K_STATE_MH, opj_j2k_read_cpf},
- {J2K_MS_MCC, J2K_STATE_MH | J2K_STATE_TPH, opj_j2k_read_mcc},
- {J2K_MS_MCO, J2K_STATE_MH | J2K_STATE_TPH, opj_j2k_read_mco},
-#ifdef USE_JPWL
-#ifdef TODO_MS /* remove these functions which are not compatible with the v2 API */
- {J2K_MS_EPC, J2K_STATE_MH | J2K_STATE_TPH, j2k_read_epc},
- {J2K_MS_EPB, J2K_STATE_MH | J2K_STATE_TPH, j2k_read_epb},
- {J2K_MS_ESD, J2K_STATE_MH | J2K_STATE_TPH, j2k_read_esd},
- {J2K_MS_RED, J2K_STATE_MH | J2K_STATE_TPH, j2k_read_red},
-#endif
-#endif /* USE_JPWL */
-#ifdef USE_JPSEC
- {J2K_MS_SEC, J2K_DEC_STATE_MH, j2k_read_sec},
- {J2K_MS_INSEC, 0, j2k_read_insec}
-#endif /* USE_JPSEC */
- {J2K_MS_UNK, J2K_STATE_MH | J2K_STATE_TPH, 0}/*opj_j2k_read_unk is directly used*/
-};
-
-static void opj_j2k_read_int16_to_float(const void * p_src_data,
- void * p_dest_data, OPJ_UINT32 p_nb_elem)
-{
- OPJ_BYTE * l_src_data = (OPJ_BYTE *) p_src_data;
- OPJ_FLOAT32 * l_dest_data = (OPJ_FLOAT32 *) p_dest_data;
- OPJ_UINT32 i;
- OPJ_UINT32 l_temp;
-
- for (i = 0; i < p_nb_elem; ++i) {
- opj_read_bytes(l_src_data, &l_temp, 2);
-
- l_src_data += sizeof(OPJ_INT16);
-
- *(l_dest_data++) = (OPJ_FLOAT32) l_temp;
- }
-}
-
-static void opj_j2k_read_int32_to_float(const void * p_src_data,
- void * p_dest_data, OPJ_UINT32 p_nb_elem)
-{
- OPJ_BYTE * l_src_data = (OPJ_BYTE *) p_src_data;
- OPJ_FLOAT32 * l_dest_data = (OPJ_FLOAT32 *) p_dest_data;
- OPJ_UINT32 i;
- OPJ_UINT32 l_temp;
-
- for (i = 0; i < p_nb_elem; ++i) {
- opj_read_bytes(l_src_data, &l_temp, 4);
-
- l_src_data += sizeof(OPJ_INT32);
-
- *(l_dest_data++) = (OPJ_FLOAT32) l_temp;
- }
-}
-
-static void opj_j2k_read_float32_to_float(const void * p_src_data,
- void * p_dest_data, OPJ_UINT32 p_nb_elem)
-{
- OPJ_BYTE * l_src_data = (OPJ_BYTE *) p_src_data;
- OPJ_FLOAT32 * l_dest_data = (OPJ_FLOAT32 *) p_dest_data;
- OPJ_UINT32 i;
- OPJ_FLOAT32 l_temp;
-
- for (i = 0; i < p_nb_elem; ++i) {
- opj_read_float(l_src_data, &l_temp);
-
- l_src_data += sizeof(OPJ_FLOAT32);
-
- *(l_dest_data++) = l_temp;
- }
-}
-
-static void opj_j2k_read_float64_to_float(const void * p_src_data,
- void * p_dest_data, OPJ_UINT32 p_nb_elem)
-{
- OPJ_BYTE * l_src_data = (OPJ_BYTE *) p_src_data;
- OPJ_FLOAT32 * l_dest_data = (OPJ_FLOAT32 *) p_dest_data;
- OPJ_UINT32 i;
- OPJ_FLOAT64 l_temp;
-
- for (i = 0; i < p_nb_elem; ++i) {
- opj_read_double(l_src_data, &l_temp);
-
- l_src_data += sizeof(OPJ_FLOAT64);
-
- *(l_dest_data++) = (OPJ_FLOAT32) l_temp;
- }
-}
-
-static void opj_j2k_read_int16_to_int32(const void * p_src_data,
- void * p_dest_data, OPJ_UINT32 p_nb_elem)
-{
- OPJ_BYTE * l_src_data = (OPJ_BYTE *) p_src_data;
- OPJ_INT32 * l_dest_data = (OPJ_INT32 *) p_dest_data;
- OPJ_UINT32 i;
- OPJ_UINT32 l_temp;
-
- for (i = 0; i < p_nb_elem; ++i) {
- opj_read_bytes(l_src_data, &l_temp, 2);
-
- l_src_data += sizeof(OPJ_INT16);
-
- *(l_dest_data++) = (OPJ_INT32) l_temp;
- }
-}
-
-static void opj_j2k_read_int32_to_int32(const void * p_src_data,
- void * p_dest_data, OPJ_UINT32 p_nb_elem)
-{
- OPJ_BYTE * l_src_data = (OPJ_BYTE *) p_src_data;
- OPJ_INT32 * l_dest_data = (OPJ_INT32 *) p_dest_data;
- OPJ_UINT32 i;
- OPJ_UINT32 l_temp;
-
- for (i = 0; i < p_nb_elem; ++i) {
- opj_read_bytes(l_src_data, &l_temp, 4);
-
- l_src_data += sizeof(OPJ_INT32);
-
- *(l_dest_data++) = (OPJ_INT32) l_temp;
- }
-}
-
-static void opj_j2k_read_float32_to_int32(const void * p_src_data,
- void * p_dest_data, OPJ_UINT32 p_nb_elem)
-{
- OPJ_BYTE * l_src_data = (OPJ_BYTE *) p_src_data;
- OPJ_INT32 * l_dest_data = (OPJ_INT32 *) p_dest_data;
- OPJ_UINT32 i;
- OPJ_FLOAT32 l_temp;
-
- for (i = 0; i < p_nb_elem; ++i) {
- opj_read_float(l_src_data, &l_temp);
-
- l_src_data += sizeof(OPJ_FLOAT32);
-
- *(l_dest_data++) = (OPJ_INT32) l_temp;
- }
-}
-
-static void opj_j2k_read_float64_to_int32(const void * p_src_data,
- void * p_dest_data, OPJ_UINT32 p_nb_elem)
-{
- OPJ_BYTE * l_src_data = (OPJ_BYTE *) p_src_data;
- OPJ_INT32 * l_dest_data = (OPJ_INT32 *) p_dest_data;
- OPJ_UINT32 i;
- OPJ_FLOAT64 l_temp;
-
- for (i = 0; i < p_nb_elem; ++i) {
- opj_read_double(l_src_data, &l_temp);
-
- l_src_data += sizeof(OPJ_FLOAT64);
-
- *(l_dest_data++) = (OPJ_INT32) l_temp;
- }
-}
-
-static void opj_j2k_write_float_to_int16(const void * p_src_data,
- void * p_dest_data, OPJ_UINT32 p_nb_elem)
-{
- OPJ_BYTE * l_dest_data = (OPJ_BYTE *) p_dest_data;
- OPJ_FLOAT32 * l_src_data = (OPJ_FLOAT32 *) p_src_data;
- OPJ_UINT32 i;
- OPJ_UINT32 l_temp;
-
- for (i = 0; i < p_nb_elem; ++i) {
- l_temp = (OPJ_UINT32) * (l_src_data++);
-
- opj_write_bytes(l_dest_data, l_temp, sizeof(OPJ_INT16));
-
- l_dest_data += sizeof(OPJ_INT16);
- }
-}
-
-static void opj_j2k_write_float_to_int32(const void * p_src_data,
- void * p_dest_data, OPJ_UINT32 p_nb_elem)
-{
- OPJ_BYTE * l_dest_data = (OPJ_BYTE *) p_dest_data;
- OPJ_FLOAT32 * l_src_data = (OPJ_FLOAT32 *) p_src_data;
- OPJ_UINT32 i;
- OPJ_UINT32 l_temp;
-
- for (i = 0; i < p_nb_elem; ++i) {
- l_temp = (OPJ_UINT32) * (l_src_data++);
-
- opj_write_bytes(l_dest_data, l_temp, sizeof(OPJ_INT32));
-
- l_dest_data += sizeof(OPJ_INT32);
- }
-}
-
-static void opj_j2k_write_float_to_float(const void * p_src_data,
- void * p_dest_data, OPJ_UINT32 p_nb_elem)
-{
- OPJ_BYTE * l_dest_data = (OPJ_BYTE *) p_dest_data;
- OPJ_FLOAT32 * l_src_data = (OPJ_FLOAT32 *) p_src_data;
- OPJ_UINT32 i;
- OPJ_FLOAT32 l_temp;
-
- for (i = 0; i < p_nb_elem; ++i) {
- l_temp = (OPJ_FLOAT32) * (l_src_data++);
-
- opj_write_float(l_dest_data, l_temp);
-
- l_dest_data += sizeof(OPJ_FLOAT32);
- }
-}
-
-static void opj_j2k_write_float_to_float64(const void * p_src_data,
- void * p_dest_data, OPJ_UINT32 p_nb_elem)
-{
- OPJ_BYTE * l_dest_data = (OPJ_BYTE *) p_dest_data;
- OPJ_FLOAT32 * l_src_data = (OPJ_FLOAT32 *) p_src_data;
- OPJ_UINT32 i;
- OPJ_FLOAT64 l_temp;
-
- for (i = 0; i < p_nb_elem; ++i) {
- l_temp = (OPJ_FLOAT64) * (l_src_data++);
-
- opj_write_double(l_dest_data, l_temp);
-
- l_dest_data += sizeof(OPJ_FLOAT64);
- }
-}
-
-const char *opj_j2k_convert_progression_order(OPJ_PROG_ORDER prg_order)
-{
- const j2k_prog_order_t *po;
- for (po = j2k_prog_order_list; po->enum_prog != -1; po++) {
- if (po->enum_prog == prg_order) {
- return po->str_prog;
- }
- }
- return po->str_prog;
-}
-
-static OPJ_BOOL opj_j2k_check_poc_val(const opj_poc_t *p_pocs,
- OPJ_UINT32 tileno,
- OPJ_UINT32 p_nb_pocs,
- OPJ_UINT32 p_nb_resolutions,
- OPJ_UINT32 p_num_comps,
- OPJ_UINT32 p_num_layers,
- opj_event_mgr_t * p_manager)
-{
- OPJ_UINT32* packet_array;
- OPJ_UINT32 index, resno, compno, layno;
- OPJ_UINT32 i;
- OPJ_UINT32 step_c = 1;
- OPJ_UINT32 step_r = p_num_comps * step_c;
- OPJ_UINT32 step_l = p_nb_resolutions * step_r;
- OPJ_BOOL loss = OPJ_FALSE;
-
- assert(p_nb_pocs > 0);
-
- packet_array = (OPJ_UINT32*) opj_calloc((size_t)step_l * p_num_layers,
- sizeof(OPJ_UINT32));
- if (packet_array == 00) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Not enough memory for checking the poc values.\n");
- return OPJ_FALSE;
- }
-
- /* iterate through all the pocs that match our tile of interest. */
- for (i = 0; i < p_nb_pocs; ++i) {
- const opj_poc_t *poc = &p_pocs[i];
- if (tileno + 1 == poc->tile) {
- index = step_r * poc->resno0;
-
- /* take each resolution for each poc */
- for (resno = poc->resno0 ;
- resno < opj_uint_min(poc->resno1, p_nb_resolutions); ++resno) {
- OPJ_UINT32 res_index = index + poc->compno0 * step_c;
-
- /* take each comp of each resolution for each poc */
- for (compno = poc->compno0 ;
- compno < opj_uint_min(poc->compno1, p_num_comps); ++compno) {
- /* The layer index always starts at zero for every progression. */
- const OPJ_UINT32 layno0 = 0;
- OPJ_UINT32 comp_index = res_index + layno0 * step_l;
-
- /* and finally take each layer of each res of ... */
- for (layno = layno0; layno < opj_uint_min(poc->layno1, p_num_layers);
- ++layno) {
- packet_array[comp_index] = 1;
- comp_index += step_l;
- }
-
- res_index += step_c;
- }
-
- index += step_r;
- }
- }
- }
-
- index = 0;
- for (layno = 0; layno < p_num_layers ; ++layno) {
- for (resno = 0; resno < p_nb_resolutions; ++resno) {
- for (compno = 0; compno < p_num_comps; ++compno) {
- loss |= (packet_array[index] != 1);
-#ifdef DEBUG_VERBOSE
- if (packet_array[index] != 1) {
- fprintf(stderr,
- "Missing packet in POC: layno=%d resno=%d compno=%d\n",
- layno, resno, compno);
- }
-#endif
- index += step_c;
- }
- }
- }
-
- if (loss) {
- opj_event_msg(p_manager, EVT_ERROR, "Missing packets possible loss of data\n");
- }
-
- opj_free(packet_array);
-
- return !loss;
-}
-
-/* ----------------------------------------------------------------------- */
-
-static OPJ_UINT32 opj_j2k_get_num_tp(opj_cp_t *cp, OPJ_UINT32 pino,
- OPJ_UINT32 tileno)
-{
- const OPJ_CHAR *prog = 00;
- OPJ_INT32 i;
- OPJ_UINT32 tpnum = 1;
- opj_tcp_t *tcp = 00;
- opj_poc_t * l_current_poc = 00;
-
- /* preconditions */
- assert(tileno < (cp->tw * cp->th));
- assert(pino < (cp->tcps[tileno].numpocs + 1));
-
- /* get the given tile coding parameter */
- tcp = &cp->tcps[tileno];
- assert(tcp != 00);
-
- l_current_poc = &(tcp->pocs[pino]);
- assert(l_current_poc != 0);
-
- /* get the progression order as a character string */
- prog = opj_j2k_convert_progression_order(tcp->prg);
- assert(strlen(prog) > 0);
-
- if (cp->m_specific_param.m_enc.m_tp_on == 1) {
- for (i = 0; i < 4; ++i) {
- switch (prog[i]) {
- /* component wise */
- case 'C':
- tpnum *= l_current_poc->compE;
- break;
- /* resolution wise */
- case 'R':
- tpnum *= l_current_poc->resE;
- break;
- /* precinct wise */
- case 'P':
- tpnum *= l_current_poc->prcE;
- break;
- /* layer wise */
- case 'L':
- tpnum *= l_current_poc->layE;
- break;
- }
- /* would we split here ? */
- if (cp->m_specific_param.m_enc.m_tp_flag == prog[i]) {
- cp->m_specific_param.m_enc.m_tp_pos = i;
- break;
- }
- }
- } else {
- tpnum = 1;
- }
-
- return tpnum;
-}
-
-static OPJ_BOOL opj_j2k_calculate_tp(opj_j2k_t *p_j2k,
- opj_cp_t *cp,
- OPJ_UINT32 * p_nb_tiles,
- opj_image_t *image,
- opj_event_mgr_t * p_manager
- )
-{
- OPJ_UINT32 pino, tileno;
- OPJ_UINT32 l_nb_tiles;
- opj_tcp_t *tcp;
-
- /* preconditions */
- assert(p_nb_tiles != 00);
- assert(cp != 00);
- assert(image != 00);
- assert(p_j2k != 00);
- assert(p_manager != 00);
-
- OPJ_UNUSED(p_j2k);
- OPJ_UNUSED(p_manager);
-
- l_nb_tiles = cp->tw * cp->th;
- * p_nb_tiles = 0;
- tcp = cp->tcps;
-
- /* INDEX >> */
- /* TODO mergeV2: check this part which use cstr_info */
- /*if (p_j2k->cstr_info) {
- opj_tile_info_t * l_info_tile_ptr = p_j2k->cstr_info->tile;
-
- for (tileno = 0; tileno < l_nb_tiles; ++tileno) {
- OPJ_UINT32 cur_totnum_tp = 0;
-
- opj_pi_update_encoding_parameters(image,cp,tileno);
-
- for (pino = 0; pino <= tcp->numpocs; ++pino)
- {
- OPJ_UINT32 tp_num = opj_j2k_get_num_tp(cp,pino,tileno);
-
- *p_nb_tiles = *p_nb_tiles + tp_num;
-
- cur_totnum_tp += tp_num;
- }
-
- tcp->m_nb_tile_parts = cur_totnum_tp;
-
- l_info_tile_ptr->tp = (opj_tp_info_t *) opj_malloc(cur_totnum_tp * sizeof(opj_tp_info_t));
- if (l_info_tile_ptr->tp == 00) {
- return OPJ_FALSE;
- }
-
- memset(l_info_tile_ptr->tp,0,cur_totnum_tp * sizeof(opj_tp_info_t));
-
- l_info_tile_ptr->num_tps = cur_totnum_tp;
-
- ++l_info_tile_ptr;
- ++tcp;
- }
- }
- else */{
- for (tileno = 0; tileno < l_nb_tiles; ++tileno) {
- OPJ_UINT32 cur_totnum_tp = 0;
-
- opj_pi_update_encoding_parameters(image, cp, tileno);
-
- for (pino = 0; pino <= tcp->numpocs; ++pino) {
- OPJ_UINT32 tp_num = opj_j2k_get_num_tp(cp, pino, tileno);
-
- *p_nb_tiles = *p_nb_tiles + tp_num;
-
- cur_totnum_tp += tp_num;
- }
- tcp->m_nb_tile_parts = cur_totnum_tp;
-
- ++tcp;
- }
- }
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_write_soc(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager)
-{
- /* 2 bytes will be written */
- OPJ_BYTE * l_start_stream = 00;
-
- /* preconditions */
- assert(p_stream != 00);
- assert(p_j2k != 00);
- assert(p_manager != 00);
-
- l_start_stream = p_j2k->m_specific_param.m_encoder.m_header_tile_data;
-
- /* write SOC identifier */
- opj_write_bytes(l_start_stream, J2K_MS_SOC, 2);
-
- if (opj_stream_write_data(p_stream, l_start_stream, 2, p_manager) != 2) {
- return OPJ_FALSE;
- }
-
- /* UniPG>> */
-#ifdef USE_JPWL
- /* update markers struct */
- /*
- OPJ_BOOL res = j2k_add_marker(p_j2k->cstr_info, J2K_MS_SOC, p_stream_tell(p_stream) - 2, 2);
- */
- assert(0 && "TODO");
-#endif /* USE_JPWL */
- /* <<UniPG */
-
- return OPJ_TRUE;
-}
-
-/**
- * Reads a SOC marker (Start of Codestream)
- * @param p_j2k the jpeg2000 file codec.
- * @param p_stream FIXME DOC
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_soc(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager
- )
-{
- OPJ_BYTE l_data [2];
- OPJ_UINT32 l_marker;
-
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_manager != 00);
- assert(p_stream != 00);
-
- if (opj_stream_read_data(p_stream, l_data, 2, p_manager) != 2) {
- return OPJ_FALSE;
- }
-
- opj_read_bytes(l_data, &l_marker, 2);
- if (l_marker != J2K_MS_SOC) {
- return OPJ_FALSE;
- }
-
- /* Next marker should be a SIZ marker in the main header */
- p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_MHSIZ;
-
- /* FIXME move it in a index structure included in p_j2k*/
- p_j2k->cstr_index->main_head_start = opj_stream_tell(p_stream) - 2;
-
- opj_event_msg(p_manager, EVT_INFO,
- "Start to read j2k main header (%" PRId64 ").\n",
- p_j2k->cstr_index->main_head_start);
-
- /* Add the marker to the codestream index*/
- if (OPJ_FALSE == opj_j2k_add_mhmarker(p_j2k->cstr_index, J2K_MS_SOC,
- p_j2k->cstr_index->main_head_start, 2)) {
- opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to add mh marker\n");
- return OPJ_FALSE;
- }
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_write_siz(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager)
-{
- OPJ_UINT32 i;
- OPJ_UINT32 l_size_len;
- OPJ_BYTE * l_current_ptr;
- opj_image_t * l_image = 00;
- opj_cp_t *cp = 00;
- opj_image_comp_t * l_img_comp = 00;
-
- /* preconditions */
- assert(p_stream != 00);
- assert(p_j2k != 00);
- assert(p_manager != 00);
-
- l_image = p_j2k->m_private_image;
- cp = &(p_j2k->m_cp);
- l_size_len = 40 + 3 * l_image->numcomps;
- l_img_comp = l_image->comps;
-
- if (l_size_len > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size) {
-
- OPJ_BYTE *new_header_tile_data = (OPJ_BYTE *) opj_realloc(
- p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_size_len);
- if (! new_header_tile_data) {
- opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data);
- p_j2k->m_specific_param.m_encoder.m_header_tile_data = NULL;
- p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0;
- opj_event_msg(p_manager, EVT_ERROR, "Not enough memory for the SIZ marker\n");
- return OPJ_FALSE;
- }
- p_j2k->m_specific_param.m_encoder.m_header_tile_data = new_header_tile_data;
- p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_size_len;
- }
-
- l_current_ptr = p_j2k->m_specific_param.m_encoder.m_header_tile_data;
-
- /* write SOC identifier */
- opj_write_bytes(l_current_ptr, J2K_MS_SIZ, 2); /* SIZ */
- l_current_ptr += 2;
-
- opj_write_bytes(l_current_ptr, l_size_len - 2, 2); /* L_SIZ */
- l_current_ptr += 2;
-
- opj_write_bytes(l_current_ptr, cp->rsiz, 2); /* Rsiz (capabilities) */
- l_current_ptr += 2;
-
- opj_write_bytes(l_current_ptr, l_image->x1, 4); /* Xsiz */
- l_current_ptr += 4;
-
- opj_write_bytes(l_current_ptr, l_image->y1, 4); /* Ysiz */
- l_current_ptr += 4;
-
- opj_write_bytes(l_current_ptr, l_image->x0, 4); /* X0siz */
- l_current_ptr += 4;
-
- opj_write_bytes(l_current_ptr, l_image->y0, 4); /* Y0siz */
- l_current_ptr += 4;
-
- opj_write_bytes(l_current_ptr, cp->tdx, 4); /* XTsiz */
- l_current_ptr += 4;
-
- opj_write_bytes(l_current_ptr, cp->tdy, 4); /* YTsiz */
- l_current_ptr += 4;
-
- opj_write_bytes(l_current_ptr, cp->tx0, 4); /* XT0siz */
- l_current_ptr += 4;
-
- opj_write_bytes(l_current_ptr, cp->ty0, 4); /* YT0siz */
- l_current_ptr += 4;
-
- opj_write_bytes(l_current_ptr, l_image->numcomps, 2); /* Csiz */
- l_current_ptr += 2;
-
- for (i = 0; i < l_image->numcomps; ++i) {
- /* TODO here with MCT ? */
- opj_write_bytes(l_current_ptr, l_img_comp->prec - 1 + (l_img_comp->sgnd << 7),
- 1); /* Ssiz_i */
- ++l_current_ptr;
-
- opj_write_bytes(l_current_ptr, l_img_comp->dx, 1); /* XRsiz_i */
- ++l_current_ptr;
-
- opj_write_bytes(l_current_ptr, l_img_comp->dy, 1); /* YRsiz_i */
- ++l_current_ptr;
-
- ++l_img_comp;
- }
-
- if (opj_stream_write_data(p_stream,
- p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_size_len,
- p_manager) != l_size_len) {
- return OPJ_FALSE;
- }
-
- return OPJ_TRUE;
-}
-
-/**
- * Reads a SIZ marker (image and tile size)
- * @param p_j2k the jpeg2000 file codec.
- * @param p_header_data the data contained in the SIZ box.
- * @param p_header_size the size of the data contained in the SIZ marker.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_siz(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager
- )
-{
- OPJ_UINT32 i;
- OPJ_UINT32 l_nb_comp;
- OPJ_UINT32 l_nb_comp_remain;
- OPJ_UINT32 l_remaining_size;
- OPJ_UINT32 l_nb_tiles;
- OPJ_UINT32 l_tmp, l_tx1, l_ty1;
- OPJ_UINT32 l_prec0, l_sgnd0;
- opj_image_t *l_image = 00;
- opj_cp_t *l_cp = 00;
- opj_image_comp_t * l_img_comp = 00;
- opj_tcp_t * l_current_tile_param = 00;
-
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_manager != 00);
- assert(p_header_data != 00);
-
- l_image = p_j2k->m_private_image;
- l_cp = &(p_j2k->m_cp);
-
- /* minimum size == 39 - 3 (= minimum component parameter) */
- if (p_header_size < 36) {
- opj_event_msg(p_manager, EVT_ERROR, "Error with SIZ marker size\n");
- return OPJ_FALSE;
- }
-
- l_remaining_size = p_header_size - 36;
- l_nb_comp = l_remaining_size / 3;
- l_nb_comp_remain = l_remaining_size % 3;
- if (l_nb_comp_remain != 0) {
- opj_event_msg(p_manager, EVT_ERROR, "Error with SIZ marker size\n");
- return OPJ_FALSE;
- }
-
- opj_read_bytes(p_header_data, &l_tmp,
- 2); /* Rsiz (capabilities) */
- p_header_data += 2;
- l_cp->rsiz = (OPJ_UINT16) l_tmp;
- opj_read_bytes(p_header_data, (OPJ_UINT32*) &l_image->x1, 4); /* Xsiz */
- p_header_data += 4;
- opj_read_bytes(p_header_data, (OPJ_UINT32*) &l_image->y1, 4); /* Ysiz */
- p_header_data += 4;
- opj_read_bytes(p_header_data, (OPJ_UINT32*) &l_image->x0, 4); /* X0siz */
- p_header_data += 4;
- opj_read_bytes(p_header_data, (OPJ_UINT32*) &l_image->y0, 4); /* Y0siz */
- p_header_data += 4;
- opj_read_bytes(p_header_data, (OPJ_UINT32*) &l_cp->tdx,
- 4); /* XTsiz */
- p_header_data += 4;
- opj_read_bytes(p_header_data, (OPJ_UINT32*) &l_cp->tdy,
- 4); /* YTsiz */
- p_header_data += 4;
- opj_read_bytes(p_header_data, (OPJ_UINT32*) &l_cp->tx0,
- 4); /* XT0siz */
- p_header_data += 4;
- opj_read_bytes(p_header_data, (OPJ_UINT32*) &l_cp->ty0,
- 4); /* YT0siz */
- p_header_data += 4;
- opj_read_bytes(p_header_data, (OPJ_UINT32*) &l_tmp,
- 2); /* Csiz */
- p_header_data += 2;
- if (l_tmp < 16385) {
- l_image->numcomps = (OPJ_UINT16) l_tmp;
- } else {
- opj_event_msg(p_manager, EVT_ERROR,
- "Error with SIZ marker: number of component is illegal -> %d\n", l_tmp);
- return OPJ_FALSE;
- }
-
- if (l_image->numcomps != l_nb_comp) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Error with SIZ marker: number of component is not compatible with the remaining number of parameters ( %d vs %d)\n",
- l_image->numcomps, l_nb_comp);
- return OPJ_FALSE;
- }
-
- /* testcase 4035.pdf.SIGSEGV.d8b.3375 */
- /* testcase issue427-null-image-size.jp2 */
- if ((l_image->x0 >= l_image->x1) || (l_image->y0 >= l_image->y1)) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Error with SIZ marker: negative or zero image size (%" PRId64 " x %" PRId64
- ")\n", (OPJ_INT64)l_image->x1 - l_image->x0,
- (OPJ_INT64)l_image->y1 - l_image->y0);
- return OPJ_FALSE;
- }
- /* testcase 2539.pdf.SIGFPE.706.1712 (also 3622.pdf.SIGFPE.706.2916 and 4008.pdf.SIGFPE.706.3345 and maybe more) */
- if ((l_cp->tdx == 0U) || (l_cp->tdy == 0U)) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Error with SIZ marker: invalid tile size (tdx: %d, tdy: %d)\n", l_cp->tdx,
- l_cp->tdy);
- return OPJ_FALSE;
- }
-
- /* testcase issue427-illegal-tile-offset.jp2 */
- l_tx1 = opj_uint_adds(l_cp->tx0, l_cp->tdx); /* manage overflow */
- l_ty1 = opj_uint_adds(l_cp->ty0, l_cp->tdy); /* manage overflow */
- if ((l_cp->tx0 > l_image->x0) || (l_cp->ty0 > l_image->y0) ||
- (l_tx1 <= l_image->x0) || (l_ty1 <= l_image->y0)) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Error with SIZ marker: illegal tile offset\n");
- return OPJ_FALSE;
- }
- if (!p_j2k->dump_state) {
- OPJ_UINT32 siz_w, siz_h;
-
- siz_w = l_image->x1 - l_image->x0;
- siz_h = l_image->y1 - l_image->y0;
-
- if (p_j2k->ihdr_w > 0 && p_j2k->ihdr_h > 0
- && (p_j2k->ihdr_w != siz_w || p_j2k->ihdr_h != siz_h)) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Error with SIZ marker: IHDR w(%u) h(%u) vs. SIZ w(%u) h(%u)\n", p_j2k->ihdr_w,
- p_j2k->ihdr_h, siz_w, siz_h);
- return OPJ_FALSE;
- }
- }
-#ifdef USE_JPWL
- if (l_cp->correct) {
- /* if JPWL is on, we check whether TX errors have damaged
- too much the SIZ parameters */
- if (!(l_image->x1 * l_image->y1)) {
- opj_event_msg(p_manager, EVT_ERROR,
- "JPWL: bad image size (%d x %d)\n",
- l_image->x1, l_image->y1);
- if (!JPWL_ASSUME) {
- opj_event_msg(p_manager, EVT_ERROR, "JPWL: giving up\n");
- return OPJ_FALSE;
- }
- }
-
- /* FIXME check previously in the function so why keep this piece of code ? Need by the norm ?
- if (l_image->numcomps != ((len - 38) / 3)) {
- opj_event_msg(p_manager, JPWL_ASSUME ? EVT_WARNING : EVT_ERROR,
- "JPWL: Csiz is %d => space in SIZ only for %d comps.!!!\n",
- l_image->numcomps, ((len - 38) / 3));
- if (!JPWL_ASSUME) {
- opj_event_msg(p_manager, EVT_ERROR, "JPWL: giving up\n");
- return OPJ_FALSE;
- }
- */ /* we try to correct */
- /* opj_event_msg(p_manager, EVT_WARNING, "- trying to adjust this\n");
- if (l_image->numcomps < ((len - 38) / 3)) {
- len = 38 + 3 * l_image->numcomps;
- opj_event_msg(p_manager, EVT_WARNING, "- setting Lsiz to %d => HYPOTHESIS!!!\n",
- len);
- } else {
- l_image->numcomps = ((len - 38) / 3);
- opj_event_msg(p_manager, EVT_WARNING, "- setting Csiz to %d => HYPOTHESIS!!!\n",
- l_image->numcomps);
- }
- }
- */
-
- /* update components number in the jpwl_exp_comps filed */
- l_cp->exp_comps = l_image->numcomps;
- }
-#endif /* USE_JPWL */
-
- /* Allocate the resulting image components */
- l_image->comps = (opj_image_comp_t*) opj_calloc(l_image->numcomps,
- sizeof(opj_image_comp_t));
- if (l_image->comps == 00) {
- l_image->numcomps = 0;
- opj_event_msg(p_manager, EVT_ERROR,
- "Not enough memory to take in charge SIZ marker\n");
- return OPJ_FALSE;
- }
-
- l_img_comp = l_image->comps;
-
- l_prec0 = 0;
- l_sgnd0 = 0;
- /* Read the component information */
- for (i = 0; i < l_image->numcomps; ++i) {
- OPJ_UINT32 tmp;
- opj_read_bytes(p_header_data, &tmp, 1); /* Ssiz_i */
- ++p_header_data;
- l_img_comp->prec = (tmp & 0x7f) + 1;
- l_img_comp->sgnd = tmp >> 7;
-
- if (p_j2k->dump_state == 0) {
- if (i == 0) {
- l_prec0 = l_img_comp->prec;
- l_sgnd0 = l_img_comp->sgnd;
- } else if (!l_cp->allow_different_bit_depth_sign
- && (l_img_comp->prec != l_prec0 || l_img_comp->sgnd != l_sgnd0)) {
- opj_event_msg(p_manager, EVT_WARNING,
- "Despite JP2 BPC!=255, precision and/or sgnd values for comp[%d] is different than comp[0]:\n"
- " [0] prec(%d) sgnd(%d) [%d] prec(%d) sgnd(%d)\n", i, l_prec0, l_sgnd0,
- i, l_img_comp->prec, l_img_comp->sgnd);
- }
- /* TODO: we should perhaps also check against JP2 BPCC values */
- }
- opj_read_bytes(p_header_data, &tmp, 1); /* XRsiz_i */
- ++p_header_data;
- l_img_comp->dx = (OPJ_UINT32)tmp; /* should be between 1 and 255 */
- opj_read_bytes(p_header_data, &tmp, 1); /* YRsiz_i */
- ++p_header_data;
- l_img_comp->dy = (OPJ_UINT32)tmp; /* should be between 1 and 255 */
- if (l_img_comp->dx < 1 || l_img_comp->dx > 255 ||
- l_img_comp->dy < 1 || l_img_comp->dy > 255) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Invalid values for comp = %d : dx=%u dy=%u (should be between 1 and 255 according to the JPEG2000 norm)\n",
- i, l_img_comp->dx, l_img_comp->dy);
- return OPJ_FALSE;
- }
- /* Avoids later undefined shift in computation of */
- /* p_j2k->m_specific_param.m_decoder.m_default_tcp->tccps[i].m_dc_level_shift = 1
- << (l_image->comps[i].prec - 1); */
- if (l_img_comp->prec > 31) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Invalid values for comp = %d : prec=%u (should be between 1 and 38 according to the JPEG2000 norm. OpenJpeg only supports up to 31)\n",
- i, l_img_comp->prec);
- return OPJ_FALSE;
- }
-#ifdef USE_JPWL
- if (l_cp->correct) {
- /* if JPWL is on, we check whether TX errors have damaged
- too much the SIZ parameters, again */
- if (!(l_image->comps[i].dx * l_image->comps[i].dy)) {
- opj_event_msg(p_manager, JPWL_ASSUME ? EVT_WARNING : EVT_ERROR,
- "JPWL: bad XRsiz_%d/YRsiz_%d (%d x %d)\n",
- i, i, l_image->comps[i].dx, l_image->comps[i].dy);
- if (!JPWL_ASSUME) {
- opj_event_msg(p_manager, EVT_ERROR, "JPWL: giving up\n");
- return OPJ_FALSE;
- }
- /* we try to correct */
- opj_event_msg(p_manager, EVT_WARNING, "- trying to adjust them\n");
- if (!l_image->comps[i].dx) {
- l_image->comps[i].dx = 1;
- opj_event_msg(p_manager, EVT_WARNING,
- "- setting XRsiz_%d to %d => HYPOTHESIS!!!\n",
- i, l_image->comps[i].dx);
- }
- if (!l_image->comps[i].dy) {
- l_image->comps[i].dy = 1;
- opj_event_msg(p_manager, EVT_WARNING,
- "- setting YRsiz_%d to %d => HYPOTHESIS!!!\n",
- i, l_image->comps[i].dy);
- }
- }
- }
-#endif /* USE_JPWL */
- l_img_comp->resno_decoded =
- 0; /* number of resolution decoded */
- l_img_comp->factor =
- l_cp->m_specific_param.m_dec.m_reduce; /* reducing factor per component */
- ++l_img_comp;
- }
-
- if (l_cp->tdx == 0 || l_cp->tdy == 0) {
- return OPJ_FALSE;
- }
-
- /* Compute the number of tiles */
- l_cp->tw = opj_uint_ceildiv(l_image->x1 - l_cp->tx0, l_cp->tdx);
- l_cp->th = opj_uint_ceildiv(l_image->y1 - l_cp->ty0, l_cp->tdy);
-
- /* Check that the number of tiles is valid */
- if (l_cp->tw == 0 || l_cp->th == 0 || l_cp->tw > 65535 / l_cp->th) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Invalid number of tiles : %u x %u (maximum fixed by jpeg2000 norm is 65535 tiles)\n",
- l_cp->tw, l_cp->th);
- return OPJ_FALSE;
- }
- l_nb_tiles = l_cp->tw * l_cp->th;
-
- /* Define the tiles which will be decoded */
- if (p_j2k->m_specific_param.m_decoder.m_discard_tiles) {
- p_j2k->m_specific_param.m_decoder.m_start_tile_x =
- (p_j2k->m_specific_param.m_decoder.m_start_tile_x - l_cp->tx0) / l_cp->tdx;
- p_j2k->m_specific_param.m_decoder.m_start_tile_y =
- (p_j2k->m_specific_param.m_decoder.m_start_tile_y - l_cp->ty0) / l_cp->tdy;
- p_j2k->m_specific_param.m_decoder.m_end_tile_x = opj_uint_ceildiv(
- p_j2k->m_specific_param.m_decoder.m_end_tile_x - l_cp->tx0,
- l_cp->tdx);
- p_j2k->m_specific_param.m_decoder.m_end_tile_y = opj_uint_ceildiv(
- p_j2k->m_specific_param.m_decoder.m_end_tile_y - l_cp->ty0,
- l_cp->tdy);
- } else {
- p_j2k->m_specific_param.m_decoder.m_start_tile_x = 0;
- p_j2k->m_specific_param.m_decoder.m_start_tile_y = 0;
- p_j2k->m_specific_param.m_decoder.m_end_tile_x = l_cp->tw;
- p_j2k->m_specific_param.m_decoder.m_end_tile_y = l_cp->th;
- }
-
-#ifdef USE_JPWL
- if (l_cp->correct) {
- /* if JPWL is on, we check whether TX errors have damaged
- too much the SIZ parameters */
- if ((l_cp->tw < 1) || (l_cp->th < 1) || (l_cp->tw > l_cp->max_tiles) ||
- (l_cp->th > l_cp->max_tiles)) {
- opj_event_msg(p_manager, JPWL_ASSUME ? EVT_WARNING : EVT_ERROR,
- "JPWL: bad number of tiles (%d x %d)\n",
- l_cp->tw, l_cp->th);
- if (!JPWL_ASSUME) {
- opj_event_msg(p_manager, EVT_ERROR, "JPWL: giving up\n");
- return OPJ_FALSE;
- }
- /* we try to correct */
- opj_event_msg(p_manager, EVT_WARNING, "- trying to adjust them\n");
- if (l_cp->tw < 1) {
- l_cp->tw = 1;
- opj_event_msg(p_manager, EVT_WARNING,
- "- setting %d tiles in x => HYPOTHESIS!!!\n",
- l_cp->tw);
- }
- if (l_cp->tw > l_cp->max_tiles) {
- l_cp->tw = 1;
- opj_event_msg(p_manager, EVT_WARNING,
- "- too large x, increase expectance of %d\n"
- "- setting %d tiles in x => HYPOTHESIS!!!\n",
- l_cp->max_tiles, l_cp->tw);
- }
- if (l_cp->th < 1) {
- l_cp->th = 1;
- opj_event_msg(p_manager, EVT_WARNING,
- "- setting %d tiles in y => HYPOTHESIS!!!\n",
- l_cp->th);
- }
- if (l_cp->th > l_cp->max_tiles) {
- l_cp->th = 1;
- opj_event_msg(p_manager, EVT_WARNING,
- "- too large y, increase expectance of %d to continue\n",
- "- setting %d tiles in y => HYPOTHESIS!!!\n",
- l_cp->max_tiles, l_cp->th);
- }
- }
- }
-#endif /* USE_JPWL */
-
- /* memory allocations */
- l_cp->tcps = (opj_tcp_t*) opj_calloc(l_nb_tiles, sizeof(opj_tcp_t));
- if (l_cp->tcps == 00) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Not enough memory to take in charge SIZ marker\n");
- return OPJ_FALSE;
- }
-
-#ifdef USE_JPWL
- if (l_cp->correct) {
- if (!l_cp->tcps) {
- opj_event_msg(p_manager, JPWL_ASSUME ? EVT_WARNING : EVT_ERROR,
- "JPWL: could not alloc tcps field of cp\n");
- if (!JPWL_ASSUME) {
- opj_event_msg(p_manager, EVT_ERROR, "JPWL: giving up\n");
- return OPJ_FALSE;
- }
- }
- }
-#endif /* USE_JPWL */
-
- p_j2k->m_specific_param.m_decoder.m_default_tcp->tccps =
- (opj_tccp_t*) opj_calloc(l_image->numcomps, sizeof(opj_tccp_t));
- if (p_j2k->m_specific_param.m_decoder.m_default_tcp->tccps == 00) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Not enough memory to take in charge SIZ marker\n");
- return OPJ_FALSE;
- }
-
- p_j2k->m_specific_param.m_decoder.m_default_tcp->m_mct_records =
- (opj_mct_data_t*)opj_calloc(OPJ_J2K_MCT_DEFAULT_NB_RECORDS,
- sizeof(opj_mct_data_t));
-
- if (! p_j2k->m_specific_param.m_decoder.m_default_tcp->m_mct_records) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Not enough memory to take in charge SIZ marker\n");
- return OPJ_FALSE;
- }
- p_j2k->m_specific_param.m_decoder.m_default_tcp->m_nb_max_mct_records =
- OPJ_J2K_MCT_DEFAULT_NB_RECORDS;
-
- p_j2k->m_specific_param.m_decoder.m_default_tcp->m_mcc_records =
- (opj_simple_mcc_decorrelation_data_t*)
- opj_calloc(OPJ_J2K_MCC_DEFAULT_NB_RECORDS,
- sizeof(opj_simple_mcc_decorrelation_data_t));
-
- if (! p_j2k->m_specific_param.m_decoder.m_default_tcp->m_mcc_records) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Not enough memory to take in charge SIZ marker\n");
- return OPJ_FALSE;
- }
- p_j2k->m_specific_param.m_decoder.m_default_tcp->m_nb_max_mcc_records =
- OPJ_J2K_MCC_DEFAULT_NB_RECORDS;
-
- /* set up default dc level shift */
- for (i = 0; i < l_image->numcomps; ++i) {
- if (! l_image->comps[i].sgnd) {
- p_j2k->m_specific_param.m_decoder.m_default_tcp->tccps[i].m_dc_level_shift = 1
- << (l_image->comps[i].prec - 1);
- }
- }
-
- l_current_tile_param = l_cp->tcps;
- for (i = 0; i < l_nb_tiles; ++i) {
- l_current_tile_param->tccps = (opj_tccp_t*) opj_calloc(l_image->numcomps,
- sizeof(opj_tccp_t));
- if (l_current_tile_param->tccps == 00) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Not enough memory to take in charge SIZ marker\n");
- return OPJ_FALSE;
- }
-
- ++l_current_tile_param;
- }
-
- /*Allocate and initialize some elements of codestrem index*/
- if (!opj_j2k_allocate_tile_element_cstr_index(p_j2k)) {
- return OPJ_FALSE;
- }
-
- p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_MH;
- opj_image_comp_header_update(l_image, l_cp);
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_write_com(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager
- )
-{
- OPJ_UINT32 l_comment_size;
- OPJ_UINT32 l_total_com_size;
- const OPJ_CHAR *l_comment;
- OPJ_BYTE * l_current_ptr = 00;
-
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_stream != 00);
- assert(p_manager != 00);
-
- l_comment = p_j2k->m_cp.comment;
- l_comment_size = (OPJ_UINT32)strlen(l_comment);
- l_total_com_size = l_comment_size + 6;
-
- if (l_total_com_size >
- p_j2k->m_specific_param.m_encoder.m_header_tile_data_size) {
- OPJ_BYTE *new_header_tile_data = (OPJ_BYTE *) opj_realloc(
- p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_total_com_size);
- if (! new_header_tile_data) {
- opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data);
- p_j2k->m_specific_param.m_encoder.m_header_tile_data = NULL;
- p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0;
- opj_event_msg(p_manager, EVT_ERROR,
- "Not enough memory to write the COM marker\n");
- return OPJ_FALSE;
- }
- p_j2k->m_specific_param.m_encoder.m_header_tile_data = new_header_tile_data;
- p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_total_com_size;
- }
-
- l_current_ptr = p_j2k->m_specific_param.m_encoder.m_header_tile_data;
-
- opj_write_bytes(l_current_ptr, J2K_MS_COM, 2); /* COM */
- l_current_ptr += 2;
-
- opj_write_bytes(l_current_ptr, l_total_com_size - 2, 2); /* L_COM */
- l_current_ptr += 2;
-
- opj_write_bytes(l_current_ptr, 1,
- 2); /* General use (IS 8859-15:1999 (Latin) values) */
- l_current_ptr += 2;
-
- memcpy(l_current_ptr, l_comment, l_comment_size);
-
- if (opj_stream_write_data(p_stream,
- p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_total_com_size,
- p_manager) != l_total_com_size) {
- return OPJ_FALSE;
- }
-
- return OPJ_TRUE;
-}
-
-/**
- * Reads a COM marker (comments)
- * @param p_j2k the jpeg2000 file codec.
- * @param p_header_data the data contained in the COM box.
- * @param p_header_size the size of the data contained in the COM marker.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_com(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager
- )
-{
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_manager != 00);
- assert(p_header_data != 00);
-
- OPJ_UNUSED(p_j2k);
- OPJ_UNUSED(p_header_data);
- OPJ_UNUSED(p_header_size);
- OPJ_UNUSED(p_manager);
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_write_cod(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager)
-{
- opj_cp_t *l_cp = 00;
- opj_tcp_t *l_tcp = 00;
- OPJ_UINT32 l_code_size, l_remaining_size;
- OPJ_BYTE * l_current_data = 00;
-
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_manager != 00);
- assert(p_stream != 00);
-
- l_cp = &(p_j2k->m_cp);
- l_tcp = &l_cp->tcps[p_j2k->m_current_tile_number];
- l_code_size = 9 + opj_j2k_get_SPCod_SPCoc_size(p_j2k,
- p_j2k->m_current_tile_number, 0);
- l_remaining_size = l_code_size;
-
- if (l_code_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size) {
- OPJ_BYTE *new_header_tile_data = (OPJ_BYTE *) opj_realloc(
- p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_code_size);
- if (! new_header_tile_data) {
- opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data);
- p_j2k->m_specific_param.m_encoder.m_header_tile_data = NULL;
- p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0;
- opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to write COD marker\n");
- return OPJ_FALSE;
- }
- p_j2k->m_specific_param.m_encoder.m_header_tile_data = new_header_tile_data;
- p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_code_size;
- }
-
- l_current_data = p_j2k->m_specific_param.m_encoder.m_header_tile_data;
-
- opj_write_bytes(l_current_data, J2K_MS_COD, 2); /* COD */
- l_current_data += 2;
-
- opj_write_bytes(l_current_data, l_code_size - 2, 2); /* L_COD */
- l_current_data += 2;
-
- opj_write_bytes(l_current_data, l_tcp->csty, 1); /* Scod */
- ++l_current_data;
-
- opj_write_bytes(l_current_data, (OPJ_UINT32)l_tcp->prg, 1); /* SGcod (A) */
- ++l_current_data;
-
- opj_write_bytes(l_current_data, l_tcp->numlayers, 2); /* SGcod (B) */
- l_current_data += 2;
-
- opj_write_bytes(l_current_data, l_tcp->mct, 1); /* SGcod (C) */
- ++l_current_data;
-
- l_remaining_size -= 9;
-
- if (! opj_j2k_write_SPCod_SPCoc(p_j2k, p_j2k->m_current_tile_number, 0,
- l_current_data, &l_remaining_size, p_manager)) {
- opj_event_msg(p_manager, EVT_ERROR, "Error writing COD marker\n");
- return OPJ_FALSE;
- }
-
- if (l_remaining_size != 0) {
- opj_event_msg(p_manager, EVT_ERROR, "Error writing COD marker\n");
- return OPJ_FALSE;
- }
-
- if (opj_stream_write_data(p_stream,
- p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_code_size,
- p_manager) != l_code_size) {
- return OPJ_FALSE;
- }
-
- return OPJ_TRUE;
-}
-
-/**
- * Reads a COD marker (Coding style defaults)
- * @param p_header_data the data contained in the COD box.
- * @param p_j2k the jpeg2000 codec.
- * @param p_header_size the size of the data contained in the COD marker.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_cod(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager
- )
-{
- /* loop */
- OPJ_UINT32 i;
- OPJ_UINT32 l_tmp;
- opj_cp_t *l_cp = 00;
- opj_tcp_t *l_tcp = 00;
- opj_image_t *l_image = 00;
-
- /* preconditions */
- assert(p_header_data != 00);
- assert(p_j2k != 00);
- assert(p_manager != 00);
-
- l_image = p_j2k->m_private_image;
- l_cp = &(p_j2k->m_cp);
-
- /* If we are in the first tile-part header of the current tile */
- l_tcp = (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH) ?
- &l_cp->tcps[p_j2k->m_current_tile_number] :
- p_j2k->m_specific_param.m_decoder.m_default_tcp;
-
-#if 0
- /* This check was added per https://github.com/uclouvain/openjpeg/commit/daed8cc9195555e101ab708a501af2dfe6d5e001 */
- /* but this is no longer necessary to handle issue476.jp2 */
- /* and this actually cause issues on legit files. See https://github.com/uclouvain/openjpeg/issues/1043 */
- /* Only one COD per tile */
- if (l_tcp->cod) {
- opj_event_msg(p_manager, EVT_ERROR,
- "COD marker already read. No more than one COD marker per tile.\n");
- return OPJ_FALSE;
- }
-#endif
- l_tcp->cod = 1;
-
- /* Make sure room is sufficient */
- if (p_header_size < 5) {
- opj_event_msg(p_manager, EVT_ERROR, "Error reading COD marker\n");
- return OPJ_FALSE;
- }
-
- opj_read_bytes(p_header_data, &l_tcp->csty, 1); /* Scod */
- ++p_header_data;
- /* Make sure we know how to decode this */
- if ((l_tcp->csty & ~(OPJ_UINT32)(J2K_CP_CSTY_PRT | J2K_CP_CSTY_SOP |
- J2K_CP_CSTY_EPH)) != 0U) {
- opj_event_msg(p_manager, EVT_ERROR, "Unknown Scod value in COD marker\n");
- return OPJ_FALSE;
- }
- opj_read_bytes(p_header_data, &l_tmp, 1); /* SGcod (A) */
- ++p_header_data;
- l_tcp->prg = (OPJ_PROG_ORDER) l_tmp;
- /* Make sure progression order is valid */
- if (l_tcp->prg > OPJ_CPRL) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Unknown progression order in COD marker\n");
- l_tcp->prg = OPJ_PROG_UNKNOWN;
- }
- opj_read_bytes(p_header_data, &l_tcp->numlayers, 2); /* SGcod (B) */
- p_header_data += 2;
-
- if ((l_tcp->numlayers < 1U) || (l_tcp->numlayers > 65535U)) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Invalid number of layers in COD marker : %d not in range [1-65535]\n",
- l_tcp->numlayers);
- return OPJ_FALSE;
- }
-
- /* If user didn't set a number layer to decode take the max specify in the codestream. */
- if (l_cp->m_specific_param.m_dec.m_layer) {
- l_tcp->num_layers_to_decode = l_cp->m_specific_param.m_dec.m_layer;
- } else {
- l_tcp->num_layers_to_decode = l_tcp->numlayers;
- }
-
- opj_read_bytes(p_header_data, &l_tcp->mct, 1); /* SGcod (C) */
- ++p_header_data;
-
- if (l_tcp->mct > 1) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Invalid multiple component transformation\n");
- return OPJ_FALSE;
- }
-
- p_header_size -= 5;
- for (i = 0; i < l_image->numcomps; ++i) {
- l_tcp->tccps[i].csty = l_tcp->csty & J2K_CCP_CSTY_PRT;
- }
-
- if (! opj_j2k_read_SPCod_SPCoc(p_j2k, 0, p_header_data, &p_header_size,
- p_manager)) {
- opj_event_msg(p_manager, EVT_ERROR, "Error reading COD marker\n");
- return OPJ_FALSE;
- }
-
- if (p_header_size != 0) {
- opj_event_msg(p_manager, EVT_ERROR, "Error reading COD marker\n");
- return OPJ_FALSE;
- }
-
- /* Apply the coding style to other components of the current tile or the m_default_tcp*/
- opj_j2k_copy_tile_component_parameters(p_j2k);
-
- /* Index */
-#ifdef WIP_REMOVE_MSD
- if (p_j2k->cstr_info) {
- /*opj_codestream_info_t *l_cstr_info = p_j2k->cstr_info;*/
- p_j2k->cstr_info->prog = l_tcp->prg;
- p_j2k->cstr_info->numlayers = l_tcp->numlayers;
- p_j2k->cstr_info->numdecompos = (OPJ_INT32*) opj_malloc(
- l_image->numcomps * sizeof(OPJ_UINT32));
- if (!p_j2k->cstr_info->numdecompos) {
- return OPJ_FALSE;
- }
- for (i = 0; i < l_image->numcomps; ++i) {
- p_j2k->cstr_info->numdecompos[i] = l_tcp->tccps[i].numresolutions - 1;
- }
- }
-#endif
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_write_coc(opj_j2k_t *p_j2k,
- OPJ_UINT32 p_comp_no,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager)
-{
- OPJ_UINT32 l_coc_size, l_remaining_size;
- OPJ_UINT32 l_comp_room;
-
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_manager != 00);
- assert(p_stream != 00);
-
- l_comp_room = (p_j2k->m_private_image->numcomps <= 256) ? 1 : 2;
-
- l_coc_size = 5 + l_comp_room + opj_j2k_get_SPCod_SPCoc_size(p_j2k,
- p_j2k->m_current_tile_number, p_comp_no);
-
- if (l_coc_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size) {
- OPJ_BYTE *new_header_tile_data;
- /*p_j2k->m_specific_param.m_encoder.m_header_tile_data
- = (OPJ_BYTE*)opj_realloc(
- p_j2k->m_specific_param.m_encoder.m_header_tile_data,
- l_coc_size);*/
-
- new_header_tile_data = (OPJ_BYTE *) opj_realloc(
- p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_coc_size);
- if (! new_header_tile_data) {
- opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data);
- p_j2k->m_specific_param.m_encoder.m_header_tile_data = NULL;
- p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0;
- opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to write COC marker\n");
- return OPJ_FALSE;
- }
- p_j2k->m_specific_param.m_encoder.m_header_tile_data = new_header_tile_data;
- p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_coc_size;
- }
-
- opj_j2k_write_coc_in_memory(p_j2k, p_comp_no,
- p_j2k->m_specific_param.m_encoder.m_header_tile_data, &l_remaining_size,
- p_manager);
-
- if (opj_stream_write_data(p_stream,
- p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_coc_size,
- p_manager) != l_coc_size) {
- return OPJ_FALSE;
- }
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_compare_coc(opj_j2k_t *p_j2k,
- OPJ_UINT32 p_first_comp_no, OPJ_UINT32 p_second_comp_no)
-{
- opj_cp_t *l_cp = NULL;
- opj_tcp_t *l_tcp = NULL;
-
- /* preconditions */
- assert(p_j2k != 00);
-
- l_cp = &(p_j2k->m_cp);
- l_tcp = &l_cp->tcps[p_j2k->m_current_tile_number];
-
- if (l_tcp->tccps[p_first_comp_no].csty != l_tcp->tccps[p_second_comp_no].csty) {
- return OPJ_FALSE;
- }
-
-
- return opj_j2k_compare_SPCod_SPCoc(p_j2k, p_j2k->m_current_tile_number,
- p_first_comp_no, p_second_comp_no);
-}
-
-static void opj_j2k_write_coc_in_memory(opj_j2k_t *p_j2k,
- OPJ_UINT32 p_comp_no,
- OPJ_BYTE * p_data,
- OPJ_UINT32 * p_data_written,
- opj_event_mgr_t * p_manager
- )
-{
- opj_cp_t *l_cp = 00;
- opj_tcp_t *l_tcp = 00;
- OPJ_UINT32 l_coc_size, l_remaining_size;
- OPJ_BYTE * l_current_data = 00;
- opj_image_t *l_image = 00;
- OPJ_UINT32 l_comp_room;
-
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_manager != 00);
-
- l_cp = &(p_j2k->m_cp);
- l_tcp = &l_cp->tcps[p_j2k->m_current_tile_number];
- l_image = p_j2k->m_private_image;
- l_comp_room = (l_image->numcomps <= 256) ? 1 : 2;
-
- l_coc_size = 5 + l_comp_room + opj_j2k_get_SPCod_SPCoc_size(p_j2k,
- p_j2k->m_current_tile_number, p_comp_no);
- l_remaining_size = l_coc_size;
-
- l_current_data = p_data;
-
- opj_write_bytes(l_current_data, J2K_MS_COC,
- 2); /* COC */
- l_current_data += 2;
-
- opj_write_bytes(l_current_data, l_coc_size - 2,
- 2); /* L_COC */
- l_current_data += 2;
-
- opj_write_bytes(l_current_data, p_comp_no, l_comp_room); /* Ccoc */
- l_current_data += l_comp_room;
-
- opj_write_bytes(l_current_data, l_tcp->tccps[p_comp_no].csty,
- 1); /* Scoc */
- ++l_current_data;
-
- l_remaining_size -= (5 + l_comp_room);
- opj_j2k_write_SPCod_SPCoc(p_j2k, p_j2k->m_current_tile_number, 0,
- l_current_data, &l_remaining_size, p_manager);
- * p_data_written = l_coc_size;
-}
-
-static OPJ_UINT32 opj_j2k_get_max_coc_size(opj_j2k_t *p_j2k)
-{
- OPJ_UINT32 i, j;
- OPJ_UINT32 l_nb_comp;
- OPJ_UINT32 l_nb_tiles;
- OPJ_UINT32 l_max = 0;
-
- /* preconditions */
-
- l_nb_tiles = p_j2k->m_cp.tw * p_j2k->m_cp.th ;
- l_nb_comp = p_j2k->m_private_image->numcomps;
-
- for (i = 0; i < l_nb_tiles; ++i) {
- for (j = 0; j < l_nb_comp; ++j) {
- l_max = opj_uint_max(l_max, opj_j2k_get_SPCod_SPCoc_size(p_j2k, i, j));
- }
- }
-
- return 6 + l_max;
-}
-
-/**
- * Reads a COC marker (Coding Style Component)
- * @param p_header_data the data contained in the COC box.
- * @param p_j2k the jpeg2000 codec.
- * @param p_header_size the size of the data contained in the COC marker.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_coc(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager
- )
-{
- opj_cp_t *l_cp = NULL;
- opj_tcp_t *l_tcp = NULL;
- opj_image_t *l_image = NULL;
- OPJ_UINT32 l_comp_room;
- OPJ_UINT32 l_comp_no;
-
- /* preconditions */
- assert(p_header_data != 00);
- assert(p_j2k != 00);
- assert(p_manager != 00);
-
- l_cp = &(p_j2k->m_cp);
- l_tcp = (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH)
- ?
- &l_cp->tcps[p_j2k->m_current_tile_number] :
- p_j2k->m_specific_param.m_decoder.m_default_tcp;
- l_image = p_j2k->m_private_image;
-
- l_comp_room = l_image->numcomps <= 256 ? 1 : 2;
-
- /* make sure room is sufficient*/
- if (p_header_size < l_comp_room + 1) {
- opj_event_msg(p_manager, EVT_ERROR, "Error reading COC marker\n");
- return OPJ_FALSE;
- }
- p_header_size -= l_comp_room + 1;
-
- opj_read_bytes(p_header_data, &l_comp_no,
- l_comp_room); /* Ccoc */
- p_header_data += l_comp_room;
- if (l_comp_no >= l_image->numcomps) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Error reading COC marker (bad number of components)\n");
- return OPJ_FALSE;
- }
-
- opj_read_bytes(p_header_data, &l_tcp->tccps[l_comp_no].csty,
- 1); /* Scoc */
- ++p_header_data ;
-
- if (! opj_j2k_read_SPCod_SPCoc(p_j2k, l_comp_no, p_header_data, &p_header_size,
- p_manager)) {
- opj_event_msg(p_manager, EVT_ERROR, "Error reading COC marker\n");
- return OPJ_FALSE;
- }
-
- if (p_header_size != 0) {
- opj_event_msg(p_manager, EVT_ERROR, "Error reading COC marker\n");
- return OPJ_FALSE;
- }
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_write_qcd(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager
- )
-{
- OPJ_UINT32 l_qcd_size, l_remaining_size;
- OPJ_BYTE * l_current_data = 00;
-
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_manager != 00);
- assert(p_stream != 00);
-
- l_qcd_size = 4 + opj_j2k_get_SQcd_SQcc_size(p_j2k, p_j2k->m_current_tile_number,
- 0);
- l_remaining_size = l_qcd_size;
-
- if (l_qcd_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size) {
- OPJ_BYTE *new_header_tile_data = (OPJ_BYTE *) opj_realloc(
- p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_qcd_size);
- if (! new_header_tile_data) {
- opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data);
- p_j2k->m_specific_param.m_encoder.m_header_tile_data = NULL;
- p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0;
- opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to write QCD marker\n");
- return OPJ_FALSE;
- }
- p_j2k->m_specific_param.m_encoder.m_header_tile_data = new_header_tile_data;
- p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_qcd_size;
- }
-
- l_current_data = p_j2k->m_specific_param.m_encoder.m_header_tile_data;
-
- opj_write_bytes(l_current_data, J2K_MS_QCD, 2); /* QCD */
- l_current_data += 2;
-
- opj_write_bytes(l_current_data, l_qcd_size - 2, 2); /* L_QCD */
- l_current_data += 2;
-
- l_remaining_size -= 4;
-
- if (! opj_j2k_write_SQcd_SQcc(p_j2k, p_j2k->m_current_tile_number, 0,
- l_current_data, &l_remaining_size, p_manager)) {
- opj_event_msg(p_manager, EVT_ERROR, "Error writing QCD marker\n");
- return OPJ_FALSE;
- }
-
- if (l_remaining_size != 0) {
- opj_event_msg(p_manager, EVT_ERROR, "Error writing QCD marker\n");
- return OPJ_FALSE;
- }
-
- if (opj_stream_write_data(p_stream,
- p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_qcd_size,
- p_manager) != l_qcd_size) {
- return OPJ_FALSE;
- }
-
- return OPJ_TRUE;
-}
-
-/**
- * Reads a QCD marker (Quantization defaults)
- * @param p_header_data the data contained in the QCD box.
- * @param p_j2k the jpeg2000 codec.
- * @param p_header_size the size of the data contained in the QCD marker.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_qcd(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager
- )
-{
- /* preconditions */
- assert(p_header_data != 00);
- assert(p_j2k != 00);
- assert(p_manager != 00);
-
- if (! opj_j2k_read_SQcd_SQcc(p_j2k, 0, p_header_data, &p_header_size,
- p_manager)) {
- opj_event_msg(p_manager, EVT_ERROR, "Error reading QCD marker\n");
- return OPJ_FALSE;
- }
-
- if (p_header_size != 0) {
- opj_event_msg(p_manager, EVT_ERROR, "Error reading QCD marker\n");
- return OPJ_FALSE;
- }
-
- /* Apply the quantization parameters to other components of the current tile or the m_default_tcp */
- opj_j2k_copy_tile_quantization_parameters(p_j2k);
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_write_qcc(opj_j2k_t *p_j2k,
- OPJ_UINT32 p_comp_no,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager
- )
-{
- OPJ_UINT32 l_qcc_size, l_remaining_size;
-
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_manager != 00);
- assert(p_stream != 00);
-
- l_qcc_size = 5 + opj_j2k_get_SQcd_SQcc_size(p_j2k, p_j2k->m_current_tile_number,
- p_comp_no);
- l_qcc_size += p_j2k->m_private_image->numcomps <= 256 ? 0 : 1;
- l_remaining_size = l_qcc_size;
-
- if (l_qcc_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size) {
- OPJ_BYTE *new_header_tile_data = (OPJ_BYTE *) opj_realloc(
- p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_qcc_size);
- if (! new_header_tile_data) {
- opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data);
- p_j2k->m_specific_param.m_encoder.m_header_tile_data = NULL;
- p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0;
- opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to write QCC marker\n");
- return OPJ_FALSE;
- }
- p_j2k->m_specific_param.m_encoder.m_header_tile_data = new_header_tile_data;
- p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_qcc_size;
- }
-
- opj_j2k_write_qcc_in_memory(p_j2k, p_comp_no,
- p_j2k->m_specific_param.m_encoder.m_header_tile_data, &l_remaining_size,
- p_manager);
-
- if (opj_stream_write_data(p_stream,
- p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_qcc_size,
- p_manager) != l_qcc_size) {
- return OPJ_FALSE;
- }
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_compare_qcc(opj_j2k_t *p_j2k,
- OPJ_UINT32 p_first_comp_no, OPJ_UINT32 p_second_comp_no)
-{
- return opj_j2k_compare_SQcd_SQcc(p_j2k, p_j2k->m_current_tile_number,
- p_first_comp_no, p_second_comp_no);
-}
-
-static void opj_j2k_write_qcc_in_memory(opj_j2k_t *p_j2k,
- OPJ_UINT32 p_comp_no,
- OPJ_BYTE * p_data,
- OPJ_UINT32 * p_data_written,
- opj_event_mgr_t * p_manager
- )
-{
- OPJ_UINT32 l_qcc_size, l_remaining_size;
- OPJ_BYTE * l_current_data = 00;
-
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_manager != 00);
-
- l_qcc_size = 6 + opj_j2k_get_SQcd_SQcc_size(p_j2k, p_j2k->m_current_tile_number,
- p_comp_no);
- l_remaining_size = l_qcc_size;
-
- l_current_data = p_data;
-
- opj_write_bytes(l_current_data, J2K_MS_QCC, 2); /* QCC */
- l_current_data += 2;
-
- if (p_j2k->m_private_image->numcomps <= 256) {
- --l_qcc_size;
-
- opj_write_bytes(l_current_data, l_qcc_size - 2, 2); /* L_QCC */
- l_current_data += 2;
-
- opj_write_bytes(l_current_data, p_comp_no, 1); /* Cqcc */
- ++l_current_data;
-
- /* in the case only one byte is sufficient the last byte allocated is useless -> still do -6 for available */
- l_remaining_size -= 6;
- } else {
- opj_write_bytes(l_current_data, l_qcc_size - 2, 2); /* L_QCC */
- l_current_data += 2;
-
- opj_write_bytes(l_current_data, p_comp_no, 2); /* Cqcc */
- l_current_data += 2;
-
- l_remaining_size -= 6;
- }
-
- opj_j2k_write_SQcd_SQcc(p_j2k, p_j2k->m_current_tile_number, p_comp_no,
- l_current_data, &l_remaining_size, p_manager);
-
- *p_data_written = l_qcc_size;
-}
-
-static OPJ_UINT32 opj_j2k_get_max_qcc_size(opj_j2k_t *p_j2k)
-{
- return opj_j2k_get_max_coc_size(p_j2k);
-}
-
-/**
- * Reads a QCC marker (Quantization component)
- * @param p_header_data the data contained in the QCC box.
- * @param p_j2k the jpeg2000 codec.
- * @param p_header_size the size of the data contained in the QCC marker.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_qcc(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager
- )
-{
- OPJ_UINT32 l_num_comp, l_comp_no;
-
- /* preconditions */
- assert(p_header_data != 00);
- assert(p_j2k != 00);
- assert(p_manager != 00);
-
- l_num_comp = p_j2k->m_private_image->numcomps;
-
- if (l_num_comp <= 256) {
- if (p_header_size < 1) {
- opj_event_msg(p_manager, EVT_ERROR, "Error reading QCC marker\n");
- return OPJ_FALSE;
- }
- opj_read_bytes(p_header_data, &l_comp_no, 1);
- ++p_header_data;
- --p_header_size;
- } else {
- if (p_header_size < 2) {
- opj_event_msg(p_manager, EVT_ERROR, "Error reading QCC marker\n");
- return OPJ_FALSE;
- }
- opj_read_bytes(p_header_data, &l_comp_no, 2);
- p_header_data += 2;
- p_header_size -= 2;
- }
-
-#ifdef USE_JPWL
- if (p_j2k->m_cp.correct) {
-
- static OPJ_UINT32 backup_compno = 0;
-
- /* compno is negative or larger than the number of components!!! */
- if (/*(l_comp_no < 0) ||*/ (l_comp_no >= l_num_comp)) {
- opj_event_msg(p_manager, EVT_ERROR,
- "JPWL: bad component number in QCC (%d out of a maximum of %d)\n",
- l_comp_no, l_num_comp);
- if (!JPWL_ASSUME) {
- opj_event_msg(p_manager, EVT_ERROR, "JPWL: giving up\n");
- return OPJ_FALSE;
- }
- /* we try to correct */
- l_comp_no = backup_compno % l_num_comp;
- opj_event_msg(p_manager, EVT_WARNING, "- trying to adjust this\n"
- "- setting component number to %d\n",
- l_comp_no);
- }
-
- /* keep your private count of tiles */
- backup_compno++;
- };
-#endif /* USE_JPWL */
-
- if (l_comp_no >= p_j2k->m_private_image->numcomps) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Invalid component number: %d, regarding the number of components %d\n",
- l_comp_no, p_j2k->m_private_image->numcomps);
- return OPJ_FALSE;
- }
-
- if (! opj_j2k_read_SQcd_SQcc(p_j2k, l_comp_no, p_header_data, &p_header_size,
- p_manager)) {
- opj_event_msg(p_manager, EVT_ERROR, "Error reading QCC marker\n");
- return OPJ_FALSE;
- }
-
- if (p_header_size != 0) {
- opj_event_msg(p_manager, EVT_ERROR, "Error reading QCC marker\n");
- return OPJ_FALSE;
- }
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_write_poc(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager
- )
-{
- OPJ_UINT32 l_nb_comp;
- OPJ_UINT32 l_nb_poc;
- OPJ_UINT32 l_poc_size;
- OPJ_UINT32 l_written_size = 0;
- opj_tcp_t *l_tcp = 00;
- OPJ_UINT32 l_poc_room;
-
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_manager != 00);
- assert(p_stream != 00);
-
- l_tcp = &p_j2k->m_cp.tcps[p_j2k->m_current_tile_number];
- l_nb_comp = p_j2k->m_private_image->numcomps;
- l_nb_poc = 1 + l_tcp->numpocs;
-
- if (l_nb_comp <= 256) {
- l_poc_room = 1;
- } else {
- l_poc_room = 2;
- }
- l_poc_size = 4 + (5 + 2 * l_poc_room) * l_nb_poc;
-
- if (l_poc_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size) {
- OPJ_BYTE *new_header_tile_data = (OPJ_BYTE *) opj_realloc(
- p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_poc_size);
- if (! new_header_tile_data) {
- opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data);
- p_j2k->m_specific_param.m_encoder.m_header_tile_data = NULL;
- p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0;
- opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to write POC marker\n");
- return OPJ_FALSE;
- }
- p_j2k->m_specific_param.m_encoder.m_header_tile_data = new_header_tile_data;
- p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_poc_size;
- }
-
- opj_j2k_write_poc_in_memory(p_j2k,
- p_j2k->m_specific_param.m_encoder.m_header_tile_data, &l_written_size,
- p_manager);
-
- if (opj_stream_write_data(p_stream,
- p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_poc_size,
- p_manager) != l_poc_size) {
- return OPJ_FALSE;
- }
-
- return OPJ_TRUE;
-}
-
-static void opj_j2k_write_poc_in_memory(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_data,
- OPJ_UINT32 * p_data_written,
- opj_event_mgr_t * p_manager
- )
-{
- OPJ_UINT32 i;
- OPJ_BYTE * l_current_data = 00;
- OPJ_UINT32 l_nb_comp;
- OPJ_UINT32 l_nb_poc;
- OPJ_UINT32 l_poc_size;
- opj_image_t *l_image = 00;
- opj_tcp_t *l_tcp = 00;
- opj_tccp_t *l_tccp = 00;
- opj_poc_t *l_current_poc = 00;
- OPJ_UINT32 l_poc_room;
-
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_manager != 00);
-
- OPJ_UNUSED(p_manager);
-
- l_tcp = &p_j2k->m_cp.tcps[p_j2k->m_current_tile_number];
- l_tccp = &l_tcp->tccps[0];
- l_image = p_j2k->m_private_image;
- l_nb_comp = l_image->numcomps;
- l_nb_poc = 1 + l_tcp->numpocs;
-
- if (l_nb_comp <= 256) {
- l_poc_room = 1;
- } else {
- l_poc_room = 2;
- }
-
- l_poc_size = 4 + (5 + 2 * l_poc_room) * l_nb_poc;
-
- l_current_data = p_data;
-
- opj_write_bytes(l_current_data, J2K_MS_POC,
- 2); /* POC */
- l_current_data += 2;
-
- opj_write_bytes(l_current_data, l_poc_size - 2,
- 2); /* Lpoc */
- l_current_data += 2;
-
- l_current_poc = l_tcp->pocs;
- for (i = 0; i < l_nb_poc; ++i) {
- opj_write_bytes(l_current_data, l_current_poc->resno0,
- 1); /* RSpoc_i */
- ++l_current_data;
-
- opj_write_bytes(l_current_data, l_current_poc->compno0,
- l_poc_room); /* CSpoc_i */
- l_current_data += l_poc_room;
-
- opj_write_bytes(l_current_data, l_current_poc->layno1,
- 2); /* LYEpoc_i */
- l_current_data += 2;
-
- opj_write_bytes(l_current_data, l_current_poc->resno1,
- 1); /* REpoc_i */
- ++l_current_data;
-
- opj_write_bytes(l_current_data, l_current_poc->compno1,
- l_poc_room); /* CEpoc_i */
- l_current_data += l_poc_room;
-
- opj_write_bytes(l_current_data, (OPJ_UINT32)l_current_poc->prg,
- 1); /* Ppoc_i */
- ++l_current_data;
-
- /* change the value of the max layer according to the actual number of layers in the file, components and resolutions*/
- l_current_poc->layno1 = (OPJ_UINT32)opj_int_min((OPJ_INT32)
- l_current_poc->layno1, (OPJ_INT32)l_tcp->numlayers);
- l_current_poc->resno1 = (OPJ_UINT32)opj_int_min((OPJ_INT32)
- l_current_poc->resno1, (OPJ_INT32)l_tccp->numresolutions);
- l_current_poc->compno1 = (OPJ_UINT32)opj_int_min((OPJ_INT32)
- l_current_poc->compno1, (OPJ_INT32)l_nb_comp);
-
- ++l_current_poc;
- }
-
- *p_data_written = l_poc_size;
-}
-
-static OPJ_UINT32 opj_j2k_get_max_poc_size(opj_j2k_t *p_j2k)
-{
- opj_tcp_t * l_tcp = 00;
- OPJ_UINT32 l_nb_tiles = 0;
- OPJ_UINT32 l_max_poc = 0;
- OPJ_UINT32 i;
-
- l_tcp = p_j2k->m_cp.tcps;
- l_nb_tiles = p_j2k->m_cp.th * p_j2k->m_cp.tw;
-
- for (i = 0; i < l_nb_tiles; ++i) {
- l_max_poc = opj_uint_max(l_max_poc, l_tcp->numpocs);
- ++l_tcp;
- }
-
- ++l_max_poc;
-
- return 4 + 9 * l_max_poc;
-}
-
-static OPJ_UINT32 opj_j2k_get_max_toc_size(opj_j2k_t *p_j2k)
-{
- OPJ_UINT32 i;
- OPJ_UINT32 l_nb_tiles;
- OPJ_UINT32 l_max = 0;
- opj_tcp_t * l_tcp = 00;
-
- l_tcp = p_j2k->m_cp.tcps;
- l_nb_tiles = p_j2k->m_cp.tw * p_j2k->m_cp.th ;
-
- for (i = 0; i < l_nb_tiles; ++i) {
- l_max = opj_uint_max(l_max, l_tcp->m_nb_tile_parts);
-
- ++l_tcp;
- }
-
- return 12 * l_max;
-}
-
-static OPJ_UINT32 opj_j2k_get_specific_header_sizes(opj_j2k_t *p_j2k)
-{
- OPJ_UINT32 l_nb_bytes = 0;
- OPJ_UINT32 l_nb_comps;
- OPJ_UINT32 l_coc_bytes, l_qcc_bytes;
-
- l_nb_comps = p_j2k->m_private_image->numcomps - 1;
- l_nb_bytes += opj_j2k_get_max_toc_size(p_j2k);
-
- if (!(OPJ_IS_CINEMA(p_j2k->m_cp.rsiz))) {
- l_coc_bytes = opj_j2k_get_max_coc_size(p_j2k);
- l_nb_bytes += l_nb_comps * l_coc_bytes;
-
- l_qcc_bytes = opj_j2k_get_max_qcc_size(p_j2k);
- l_nb_bytes += l_nb_comps * l_qcc_bytes;
- }
-
- l_nb_bytes += opj_j2k_get_max_poc_size(p_j2k);
-
- if (p_j2k->m_specific_param.m_encoder.m_PLT) {
- /* Reserve space for PLT markers */
-
- OPJ_UINT32 i;
- const opj_cp_t * l_cp = &(p_j2k->m_cp);
- OPJ_UINT32 l_max_packet_count = 0;
- for (i = 0; i < l_cp->th * l_cp->tw; ++i) {
- l_max_packet_count = opj_uint_max(l_max_packet_count,
- opj_get_encoding_packet_count(p_j2k->m_private_image, l_cp, i));
- }
- /* Minimum 6 bytes per PLT marker, and at a minimum (taking a pessimistic */
- /* estimate of 4 bytes for a packet size), one can write */
- /* (65536-6) / 4 = 16382 paquet sizes per PLT marker */
- p_j2k->m_specific_param.m_encoder.m_reserved_bytes_for_PLT =
- 6 * opj_uint_ceildiv(l_max_packet_count, 16382);
- /* Maximum 5 bytes per packet to encode a full UINT32 */
- p_j2k->m_specific_param.m_encoder.m_reserved_bytes_for_PLT +=
- l_nb_bytes += 5 * l_max_packet_count;
- p_j2k->m_specific_param.m_encoder.m_reserved_bytes_for_PLT += 1;
- l_nb_bytes += p_j2k->m_specific_param.m_encoder.m_reserved_bytes_for_PLT;
- }
-
- /*** DEVELOPER CORNER, Add room for your headers ***/
-
- return l_nb_bytes;
-}
-
-/**
- * Reads a POC marker (Progression Order Change)
- *
- * @param p_header_data the data contained in the POC box.
- * @param p_j2k the jpeg2000 codec.
- * @param p_header_size the size of the data contained in the POC marker.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_poc(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager
- )
-{
- OPJ_UINT32 i, l_nb_comp, l_tmp;
- opj_image_t * l_image = 00;
- OPJ_UINT32 l_old_poc_nb, l_current_poc_nb, l_current_poc_remaining;
- OPJ_UINT32 l_chunk_size, l_comp_room;
-
- opj_cp_t *l_cp = 00;
- opj_tcp_t *l_tcp = 00;
- opj_poc_t *l_current_poc = 00;
-
- /* preconditions */
- assert(p_header_data != 00);
- assert(p_j2k != 00);
- assert(p_manager != 00);
-
- l_image = p_j2k->m_private_image;
- l_nb_comp = l_image->numcomps;
- if (l_nb_comp <= 256) {
- l_comp_room = 1;
- } else {
- l_comp_room = 2;
- }
- l_chunk_size = 5 + 2 * l_comp_room;
- l_current_poc_nb = p_header_size / l_chunk_size;
- l_current_poc_remaining = p_header_size % l_chunk_size;
-
- if ((l_current_poc_nb <= 0) || (l_current_poc_remaining != 0)) {
- opj_event_msg(p_manager, EVT_ERROR, "Error reading POC marker\n");
- return OPJ_FALSE;
- }
-
- l_cp = &(p_j2k->m_cp);
- l_tcp = (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH) ?
- &l_cp->tcps[p_j2k->m_current_tile_number] :
- p_j2k->m_specific_param.m_decoder.m_default_tcp;
- l_old_poc_nb = l_tcp->POC ? l_tcp->numpocs + 1 : 0;
- l_current_poc_nb += l_old_poc_nb;
-
- if (l_current_poc_nb >= J2K_MAX_POCS) {
- opj_event_msg(p_manager, EVT_ERROR, "Too many POCs %d\n", l_current_poc_nb);
- return OPJ_FALSE;
- }
-
- /* now poc is in use.*/
- l_tcp->POC = 1;
-
- l_current_poc = &l_tcp->pocs[l_old_poc_nb];
- for (i = l_old_poc_nb; i < l_current_poc_nb; ++i) {
- opj_read_bytes(p_header_data, &(l_current_poc->resno0),
- 1); /* RSpoc_i */
- ++p_header_data;
- opj_read_bytes(p_header_data, &(l_current_poc->compno0),
- l_comp_room); /* CSpoc_i */
- p_header_data += l_comp_room;
- opj_read_bytes(p_header_data, &(l_current_poc->layno1),
- 2); /* LYEpoc_i */
- /* make sure layer end is in acceptable bounds */
- l_current_poc->layno1 = opj_uint_min(l_current_poc->layno1, l_tcp->numlayers);
- p_header_data += 2;
- opj_read_bytes(p_header_data, &(l_current_poc->resno1),
- 1); /* REpoc_i */
- ++p_header_data;
- opj_read_bytes(p_header_data, &(l_current_poc->compno1),
- l_comp_room); /* CEpoc_i */
- p_header_data += l_comp_room;
- opj_read_bytes(p_header_data, &l_tmp,
- 1); /* Ppoc_i */
- ++p_header_data;
- l_current_poc->prg = (OPJ_PROG_ORDER) l_tmp;
- /* make sure comp is in acceptable bounds */
- l_current_poc->compno1 = opj_uint_min(l_current_poc->compno1, l_nb_comp);
- ++l_current_poc;
- }
-
- l_tcp->numpocs = l_current_poc_nb - 1;
- return OPJ_TRUE;
-}
-
-/**
- * Reads a CRG marker (Component registration)
- *
- * @param p_header_data the data contained in the TLM box.
- * @param p_j2k the jpeg2000 codec.
- * @param p_header_size the size of the data contained in the TLM marker.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_crg(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager
- )
-{
- OPJ_UINT32 l_nb_comp;
- /* preconditions */
- assert(p_header_data != 00);
- assert(p_j2k != 00);
- assert(p_manager != 00);
-
- OPJ_UNUSED(p_header_data);
-
- l_nb_comp = p_j2k->m_private_image->numcomps;
-
- if (p_header_size != l_nb_comp * 4) {
- opj_event_msg(p_manager, EVT_ERROR, "Error reading CRG marker\n");
- return OPJ_FALSE;
- }
- /* Do not care of this at the moment since only local variables are set here */
- /*
- for
- (i = 0; i < l_nb_comp; ++i)
- {
- opj_read_bytes(p_header_data,&l_Xcrg_i,2); // Xcrg_i
- p_header_data+=2;
- opj_read_bytes(p_header_data,&l_Ycrg_i,2); // Xcrg_i
- p_header_data+=2;
- }
- */
- return OPJ_TRUE;
-}
-
-/**
- * Reads a TLM marker (Tile Length Marker)
- *
- * @param p_header_data the data contained in the TLM box.
- * @param p_j2k the jpeg2000 codec.
- * @param p_header_size the size of the data contained in the TLM marker.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_tlm(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager
- )
-{
- OPJ_UINT32 l_Ztlm, l_Stlm, l_ST, l_SP,
- l_Ptlm_size, l_entry_size, l_num_tileparts;
- OPJ_UINT32 i;
- opj_j2k_tlm_tile_part_info_t* l_tile_part_infos;
- opj_j2k_tlm_info_t* l_tlm;
-
- /* preconditions */
- assert(p_header_data != 00);
- assert(p_j2k != 00);
- assert(p_manager != 00);
-
- l_tlm = &(p_j2k->m_specific_param.m_decoder.m_tlm);
-
- if (p_header_size < 2) {
- opj_event_msg(p_manager, EVT_ERROR, "Error reading TLM marker.\n");
- return OPJ_FALSE;
- }
- p_header_size -= 2;
-
- if (l_tlm->m_is_invalid) {
- return OPJ_TRUE;
- }
-
- opj_read_bytes(p_header_data, &l_Ztlm,
- 1); /* Ztlm */
- ++p_header_data;
- opj_read_bytes(p_header_data, &l_Stlm,
- 1); /* Stlm */
- ++p_header_data;
-
- l_ST = ((l_Stlm >> 4) & 0x3);
- if (l_ST == 3) {
- l_tlm->m_is_invalid = OPJ_TRUE;
- opj_event_msg(p_manager, EVT_WARNING,
- "opj_j2k_read_tlm(): ST = 3 is invalid.\n");
- return OPJ_TRUE;
- }
- l_SP = (l_Stlm >> 6) & 0x1;
-
- l_Ptlm_size = (l_SP + 1) * 2;
- l_entry_size = l_Ptlm_size + l_ST;
-
- if ((p_header_size % l_entry_size) != 0) {
- l_tlm->m_is_invalid = OPJ_TRUE;
- opj_event_msg(p_manager, EVT_WARNING,
- "opj_j2k_read_tlm(): TLM marker not of expected size.\n");
- return OPJ_TRUE;
- }
-
- l_num_tileparts = p_header_size / l_entry_size;
- if (l_num_tileparts == 0) {
- /* not totally sure if this is valid... */
- return OPJ_TRUE;
- }
-
- /* Highly unlikely, unless there are gazillions of TLM markers */
- if (l_tlm->m_entries_count > UINT32_MAX - l_num_tileparts ||
- l_tlm->m_entries_count + l_num_tileparts > UINT32_MAX / sizeof(
- opj_j2k_tlm_tile_part_info_t)) {
- l_tlm->m_is_invalid = OPJ_TRUE;
- opj_event_msg(p_manager, EVT_WARNING,
- "opj_j2k_read_tlm(): too many TLM markers.\n");
- return OPJ_TRUE;
- }
-
- l_tile_part_infos = (opj_j2k_tlm_tile_part_info_t*)opj_realloc(
- l_tlm->m_tile_part_infos,
- (l_tlm->m_entries_count + l_num_tileparts) * sizeof(
- opj_j2k_tlm_tile_part_info_t));
- if (!l_tile_part_infos) {
- l_tlm->m_is_invalid = OPJ_TRUE;
- opj_event_msg(p_manager, EVT_WARNING,
- "opj_j2k_read_tlm(): cannot allocate m_tile_part_infos.\n");
- return OPJ_TRUE;
- }
-
- l_tlm->m_tile_part_infos = l_tile_part_infos;
-
- for (i = 0; i < l_num_tileparts; ++ i) {
- OPJ_UINT32 l_tile_index;
- OPJ_UINT32 l_length;
-
- /* Read Ttlm_i */
- if (l_ST == 0) {
- l_tile_index = l_tlm->m_entries_count;
- } else {
- opj_read_bytes(p_header_data, &l_tile_index, l_ST);
- p_header_data += l_ST;
- }
-
- if (l_tile_index >= p_j2k->m_cp.tw * p_j2k->m_cp.th) {
- l_tlm->m_is_invalid = OPJ_TRUE;
- opj_event_msg(p_manager, EVT_WARNING,
- "opj_j2k_read_tlm(): invalid tile number %d\n",
- l_tile_index);
- return OPJ_TRUE;
- }
-
- /* Read Ptlm_i */
- opj_read_bytes(p_header_data, &l_length, l_Ptlm_size);
- p_header_data += l_Ptlm_size;
-
- l_tile_part_infos[l_tlm->m_entries_count].m_tile_index =
- (OPJ_UINT16)l_tile_index;
- l_tile_part_infos[l_tlm->m_entries_count].m_length = l_length;
- ++l_tlm->m_entries_count;
- }
-
- return OPJ_TRUE;
-}
-
-/**
- * Reads a PLM marker (Packet length, main header marker)
- *
- * @param p_header_data the data contained in the TLM box.
- * @param p_j2k the jpeg2000 codec.
- * @param p_header_size the size of the data contained in the TLM marker.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_plm(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager
- )
-{
- /* preconditions */
- assert(p_header_data != 00);
- assert(p_j2k != 00);
- assert(p_manager != 00);
-
- OPJ_UNUSED(p_j2k);
- OPJ_UNUSED(p_header_data);
-
- if (p_header_size < 1) {
- opj_event_msg(p_manager, EVT_ERROR, "Error reading PLM marker\n");
- return OPJ_FALSE;
- }
- /* Do not care of this at the moment since only local variables are set here */
- /*
- opj_read_bytes(p_header_data,&l_Zplm,1); // Zplm
- ++p_header_data;
- --p_header_size;
-
- while
- (p_header_size > 0)
- {
- opj_read_bytes(p_header_data,&l_Nplm,1); // Nplm
- ++p_header_data;
- p_header_size -= (1+l_Nplm);
- if
- (p_header_size < 0)
- {
- opj_event_msg(p_manager, EVT_ERROR, "Error reading PLM marker\n");
- return false;
- }
- for
- (i = 0; i < l_Nplm; ++i)
- {
- opj_read_bytes(p_header_data,&l_tmp,1); // Iplm_ij
- ++p_header_data;
- // take only the last seven bytes
- l_packet_len |= (l_tmp & 0x7f);
- if
- (l_tmp & 0x80)
- {
- l_packet_len <<= 7;
- }
- else
- {
- // store packet length and proceed to next packet
- l_packet_len = 0;
- }
- }
- if
- (l_packet_len != 0)
- {
- opj_event_msg(p_manager, EVT_ERROR, "Error reading PLM marker\n");
- return false;
- }
- }
- */
- return OPJ_TRUE;
-}
-
-/**
- * Reads a PLT marker (Packet length, tile-part header)
- *
- * @param p_header_data the data contained in the PLT box.
- * @param p_j2k the jpeg2000 codec.
- * @param p_header_size the size of the data contained in the PLT marker.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_plt(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager
- )
-{
- OPJ_UINT32 l_Zplt, l_tmp, l_packet_len = 0, i;
-
- /* preconditions */
- assert(p_header_data != 00);
- assert(p_j2k != 00);
- assert(p_manager != 00);
-
- OPJ_UNUSED(p_j2k);
-
- if (p_header_size < 1) {
- opj_event_msg(p_manager, EVT_ERROR, "Error reading PLT marker\n");
- return OPJ_FALSE;
- }
-
- opj_read_bytes(p_header_data, &l_Zplt, 1); /* Zplt */
- ++p_header_data;
- --p_header_size;
-
- for (i = 0; i < p_header_size; ++i) {
- opj_read_bytes(p_header_data, &l_tmp, 1); /* Iplt_ij */
- ++p_header_data;
- /* take only the last seven bytes */
- l_packet_len |= (l_tmp & 0x7f);
- if (l_tmp & 0x80) {
- l_packet_len <<= 7;
- } else {
- /* store packet length and proceed to next packet */
- l_packet_len = 0;
- }
- }
-
- if (l_packet_len != 0) {
- opj_event_msg(p_manager, EVT_ERROR, "Error reading PLT marker\n");
- return OPJ_FALSE;
- }
-
- return OPJ_TRUE;
-}
-
-/**
- * Reads a PPM marker (Packed packet headers, main header)
- *
- * @param p_header_data the data contained in the POC box.
- * @param p_j2k the jpeg2000 codec.
- * @param p_header_size the size of the data contained in the POC marker.
- * @param p_manager the user event manager.
- */
-
-static OPJ_BOOL opj_j2k_read_ppm(
- opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager)
-{
- opj_cp_t *l_cp = 00;
- OPJ_UINT32 l_Z_ppm;
-
- /* preconditions */
- assert(p_header_data != 00);
- assert(p_j2k != 00);
- assert(p_manager != 00);
-
- /* We need to have the Z_ppm element + 1 byte of Nppm/Ippm at minimum */
- if (p_header_size < 2) {
- opj_event_msg(p_manager, EVT_ERROR, "Error reading PPM marker\n");
- return OPJ_FALSE;
- }
-
- l_cp = &(p_j2k->m_cp);
- l_cp->ppm = 1;
-
- opj_read_bytes(p_header_data, &l_Z_ppm, 1); /* Z_ppm */
- ++p_header_data;
- --p_header_size;
-
- /* check allocation needed */
- if (l_cp->ppm_markers == NULL) { /* first PPM marker */
- OPJ_UINT32 l_newCount = l_Z_ppm + 1U; /* can't overflow, l_Z_ppm is UINT8 */
- assert(l_cp->ppm_markers_count == 0U);
-
- l_cp->ppm_markers = (opj_ppx *) opj_calloc(l_newCount, sizeof(opj_ppx));
- if (l_cp->ppm_markers == NULL) {
- opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to read PPM marker\n");
- return OPJ_FALSE;
- }
- l_cp->ppm_markers_count = l_newCount;
- } else if (l_cp->ppm_markers_count <= l_Z_ppm) {
- OPJ_UINT32 l_newCount = l_Z_ppm + 1U; /* can't overflow, l_Z_ppm is UINT8 */
- opj_ppx *new_ppm_markers;
- new_ppm_markers = (opj_ppx *) opj_realloc(l_cp->ppm_markers,
- l_newCount * sizeof(opj_ppx));
- if (new_ppm_markers == NULL) {
- /* clean up to be done on l_cp destruction */
- opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to read PPM marker\n");
- return OPJ_FALSE;
- }
- l_cp->ppm_markers = new_ppm_markers;
- memset(l_cp->ppm_markers + l_cp->ppm_markers_count, 0,
- (l_newCount - l_cp->ppm_markers_count) * sizeof(opj_ppx));
- l_cp->ppm_markers_count = l_newCount;
- }
-
- if (l_cp->ppm_markers[l_Z_ppm].m_data != NULL) {
- /* clean up to be done on l_cp destruction */
- opj_event_msg(p_manager, EVT_ERROR, "Zppm %u already read\n", l_Z_ppm);
- return OPJ_FALSE;
- }
-
- l_cp->ppm_markers[l_Z_ppm].m_data = (OPJ_BYTE *) opj_malloc(p_header_size);
- if (l_cp->ppm_markers[l_Z_ppm].m_data == NULL) {
- /* clean up to be done on l_cp destruction */
- opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to read PPM marker\n");
- return OPJ_FALSE;
- }
- l_cp->ppm_markers[l_Z_ppm].m_data_size = p_header_size;
- memcpy(l_cp->ppm_markers[l_Z_ppm].m_data, p_header_data, p_header_size);
-
- return OPJ_TRUE;
-}
-
-/**
- * Merges all PPM markers read (Packed headers, main header)
- *
- * @param p_cp main coding parameters.
- * @param p_manager the user event manager.
- */
-static OPJ_BOOL opj_j2k_merge_ppm(opj_cp_t *p_cp, opj_event_mgr_t * p_manager)
-{
- OPJ_UINT32 i, l_ppm_data_size, l_N_ppm_remaining;
-
- /* preconditions */
- assert(p_cp != 00);
- assert(p_manager != 00);
- assert(p_cp->ppm_buffer == NULL);
-
- if (p_cp->ppm == 0U) {
- return OPJ_TRUE;
- }
-
- l_ppm_data_size = 0U;
- l_N_ppm_remaining = 0U;
- for (i = 0U; i < p_cp->ppm_markers_count; ++i) {
- if (p_cp->ppm_markers[i].m_data !=
- NULL) { /* standard doesn't seem to require contiguous Zppm */
- OPJ_UINT32 l_N_ppm;
- OPJ_UINT32 l_data_size = p_cp->ppm_markers[i].m_data_size;
- const OPJ_BYTE* l_data = p_cp->ppm_markers[i].m_data;
-
- if (l_N_ppm_remaining >= l_data_size) {
- l_N_ppm_remaining -= l_data_size;
- l_data_size = 0U;
- } else {
- l_data += l_N_ppm_remaining;
- l_data_size -= l_N_ppm_remaining;
- l_N_ppm_remaining = 0U;
- }
-
- if (l_data_size > 0U) {
- do {
- /* read Nppm */
- if (l_data_size < 4U) {
- /* clean up to be done on l_cp destruction */
- opj_event_msg(p_manager, EVT_ERROR, "Not enough bytes to read Nppm\n");
- return OPJ_FALSE;
- }
- opj_read_bytes(l_data, &l_N_ppm, 4);
- l_data += 4;
- l_data_size -= 4;
-
- if (l_ppm_data_size > UINT_MAX - l_N_ppm) {
- opj_event_msg(p_manager, EVT_ERROR, "Too large value for Nppm\n");
- return OPJ_FALSE;
- }
- l_ppm_data_size += l_N_ppm;
- if (l_data_size >= l_N_ppm) {
- l_data_size -= l_N_ppm;
- l_data += l_N_ppm;
- } else {
- l_N_ppm_remaining = l_N_ppm - l_data_size;
- l_data_size = 0U;
- }
- } while (l_data_size > 0U);
- }
- }
- }
-
- if (l_N_ppm_remaining != 0U) {
- /* clean up to be done on l_cp destruction */
- opj_event_msg(p_manager, EVT_ERROR, "Corrupted PPM markers\n");
- return OPJ_FALSE;
- }
-
- p_cp->ppm_buffer = (OPJ_BYTE *) opj_malloc(l_ppm_data_size);
- if (p_cp->ppm_buffer == 00) {
- opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to read PPM marker\n");
- return OPJ_FALSE;
- }
- p_cp->ppm_len = l_ppm_data_size;
- l_ppm_data_size = 0U;
- l_N_ppm_remaining = 0U;
- for (i = 0U; i < p_cp->ppm_markers_count; ++i) {
- if (p_cp->ppm_markers[i].m_data !=
- NULL) { /* standard doesn't seem to require contiguous Zppm */
- OPJ_UINT32 l_N_ppm;
- OPJ_UINT32 l_data_size = p_cp->ppm_markers[i].m_data_size;
- const OPJ_BYTE* l_data = p_cp->ppm_markers[i].m_data;
-
- if (l_N_ppm_remaining >= l_data_size) {
- memcpy(p_cp->ppm_buffer + l_ppm_data_size, l_data, l_data_size);
- l_ppm_data_size += l_data_size;
- l_N_ppm_remaining -= l_data_size;
- l_data_size = 0U;
- } else {
- memcpy(p_cp->ppm_buffer + l_ppm_data_size, l_data, l_N_ppm_remaining);
- l_ppm_data_size += l_N_ppm_remaining;
- l_data += l_N_ppm_remaining;
- l_data_size -= l_N_ppm_remaining;
- l_N_ppm_remaining = 0U;
- }
-
- if (l_data_size > 0U) {
- do {
- /* read Nppm */
- if (l_data_size < 4U) {
- /* clean up to be done on l_cp destruction */
- opj_event_msg(p_manager, EVT_ERROR, "Not enough bytes to read Nppm\n");
- return OPJ_FALSE;
- }
- opj_read_bytes(l_data, &l_N_ppm, 4);
- l_data += 4;
- l_data_size -= 4;
-
- if (l_data_size >= l_N_ppm) {
- memcpy(p_cp->ppm_buffer + l_ppm_data_size, l_data, l_N_ppm);
- l_ppm_data_size += l_N_ppm;
- l_data_size -= l_N_ppm;
- l_data += l_N_ppm;
- } else {
- memcpy(p_cp->ppm_buffer + l_ppm_data_size, l_data, l_data_size);
- l_ppm_data_size += l_data_size;
- l_N_ppm_remaining = l_N_ppm - l_data_size;
- l_data_size = 0U;
- }
- } while (l_data_size > 0U);
- }
- opj_free(p_cp->ppm_markers[i].m_data);
- p_cp->ppm_markers[i].m_data = NULL;
- p_cp->ppm_markers[i].m_data_size = 0U;
- }
- }
-
- p_cp->ppm_data = p_cp->ppm_buffer;
- p_cp->ppm_data_size = p_cp->ppm_len;
-
- p_cp->ppm_markers_count = 0U;
- opj_free(p_cp->ppm_markers);
- p_cp->ppm_markers = NULL;
-
- return OPJ_TRUE;
-}
-
-/**
- * Reads a PPT marker (Packed packet headers, tile-part header)
- *
- * @param p_header_data the data contained in the PPT box.
- * @param p_j2k the jpeg2000 codec.
- * @param p_header_size the size of the data contained in the PPT marker.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_ppt(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager
- )
-{
- opj_cp_t *l_cp = 00;
- opj_tcp_t *l_tcp = 00;
- OPJ_UINT32 l_Z_ppt;
-
- /* preconditions */
- assert(p_header_data != 00);
- assert(p_j2k != 00);
- assert(p_manager != 00);
-
- /* We need to have the Z_ppt element + 1 byte of Ippt at minimum */
- if (p_header_size < 2) {
- opj_event_msg(p_manager, EVT_ERROR, "Error reading PPT marker\n");
- return OPJ_FALSE;
- }
-
- l_cp = &(p_j2k->m_cp);
- if (l_cp->ppm) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Error reading PPT marker: packet header have been previously found in the main header (PPM marker).\n");
- return OPJ_FALSE;
- }
-
- l_tcp = &(l_cp->tcps[p_j2k->m_current_tile_number]);
- l_tcp->ppt = 1;
-
- opj_read_bytes(p_header_data, &l_Z_ppt, 1); /* Z_ppt */
- ++p_header_data;
- --p_header_size;
-
- /* check allocation needed */
- if (l_tcp->ppt_markers == NULL) { /* first PPT marker */
- OPJ_UINT32 l_newCount = l_Z_ppt + 1U; /* can't overflow, l_Z_ppt is UINT8 */
- assert(l_tcp->ppt_markers_count == 0U);
-
- l_tcp->ppt_markers = (opj_ppx *) opj_calloc(l_newCount, sizeof(opj_ppx));
- if (l_tcp->ppt_markers == NULL) {
- opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to read PPT marker\n");
- return OPJ_FALSE;
- }
- l_tcp->ppt_markers_count = l_newCount;
- } else if (l_tcp->ppt_markers_count <= l_Z_ppt) {
- OPJ_UINT32 l_newCount = l_Z_ppt + 1U; /* can't overflow, l_Z_ppt is UINT8 */
- opj_ppx *new_ppt_markers;
- new_ppt_markers = (opj_ppx *) opj_realloc(l_tcp->ppt_markers,
- l_newCount * sizeof(opj_ppx));
- if (new_ppt_markers == NULL) {
- /* clean up to be done on l_tcp destruction */
- opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to read PPT marker\n");
- return OPJ_FALSE;
- }
- l_tcp->ppt_markers = new_ppt_markers;
- memset(l_tcp->ppt_markers + l_tcp->ppt_markers_count, 0,
- (l_newCount - l_tcp->ppt_markers_count) * sizeof(opj_ppx));
- l_tcp->ppt_markers_count = l_newCount;
- }
-
- if (l_tcp->ppt_markers[l_Z_ppt].m_data != NULL) {
- /* clean up to be done on l_tcp destruction */
- opj_event_msg(p_manager, EVT_ERROR, "Zppt %u already read\n", l_Z_ppt);
- return OPJ_FALSE;
- }
-
- l_tcp->ppt_markers[l_Z_ppt].m_data = (OPJ_BYTE *) opj_malloc(p_header_size);
- if (l_tcp->ppt_markers[l_Z_ppt].m_data == NULL) {
- /* clean up to be done on l_tcp destruction */
- opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to read PPT marker\n");
- return OPJ_FALSE;
- }
- l_tcp->ppt_markers[l_Z_ppt].m_data_size = p_header_size;
- memcpy(l_tcp->ppt_markers[l_Z_ppt].m_data, p_header_data, p_header_size);
- return OPJ_TRUE;
-}
-
-/**
- * Merges all PPT markers read (Packed packet headers, tile-part header)
- *
- * @param p_tcp the tile.
- * @param p_manager the user event manager.
- */
-static OPJ_BOOL opj_j2k_merge_ppt(opj_tcp_t *p_tcp, opj_event_mgr_t * p_manager)
-{
- OPJ_UINT32 i, l_ppt_data_size;
- /* preconditions */
- assert(p_tcp != 00);
- assert(p_manager != 00);
-
- if (p_tcp->ppt_buffer != NULL) {
- opj_event_msg(p_manager, EVT_ERROR,
- "opj_j2k_merge_ppt() has already been called\n");
- return OPJ_FALSE;
- }
-
- if (p_tcp->ppt == 0U) {
- return OPJ_TRUE;
- }
-
- l_ppt_data_size = 0U;
- for (i = 0U; i < p_tcp->ppt_markers_count; ++i) {
- l_ppt_data_size +=
- p_tcp->ppt_markers[i].m_data_size; /* can't overflow, max 256 markers of max 65536 bytes */
- }
-
- p_tcp->ppt_buffer = (OPJ_BYTE *) opj_malloc(l_ppt_data_size);
- if (p_tcp->ppt_buffer == 00) {
- opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to read PPT marker\n");
- return OPJ_FALSE;
- }
- p_tcp->ppt_len = l_ppt_data_size;
- l_ppt_data_size = 0U;
- for (i = 0U; i < p_tcp->ppt_markers_count; ++i) {
- if (p_tcp->ppt_markers[i].m_data !=
- NULL) { /* standard doesn't seem to require contiguous Zppt */
- memcpy(p_tcp->ppt_buffer + l_ppt_data_size, p_tcp->ppt_markers[i].m_data,
- p_tcp->ppt_markers[i].m_data_size);
- l_ppt_data_size +=
- p_tcp->ppt_markers[i].m_data_size; /* can't overflow, max 256 markers of max 65536 bytes */
-
- opj_free(p_tcp->ppt_markers[i].m_data);
- p_tcp->ppt_markers[i].m_data = NULL;
- p_tcp->ppt_markers[i].m_data_size = 0U;
- }
- }
-
- p_tcp->ppt_markers_count = 0U;
- opj_free(p_tcp->ppt_markers);
- p_tcp->ppt_markers = NULL;
-
- p_tcp->ppt_data = p_tcp->ppt_buffer;
- p_tcp->ppt_data_size = p_tcp->ppt_len;
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_write_tlm(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager
- )
-{
- OPJ_BYTE * l_current_data = 00;
- OPJ_UINT32 l_tlm_size;
- OPJ_UINT32 size_per_tile_part;
-
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_manager != 00);
- assert(p_stream != 00);
-
- /* 10921 = (65535 - header_size) / size_per_tile_part where */
- /* header_size = 4 and size_per_tile_part = 6 */
- if (p_j2k->m_specific_param.m_encoder.m_total_tile_parts > 10921) {
- /* We could do more but it would require writing several TLM markers */
- opj_event_msg(p_manager, EVT_ERROR,
- "A maximum of 10921 tile-parts are supported currently "
- "when writing TLM marker\n");
- return OPJ_FALSE;
- }
-
- if (p_j2k->m_specific_param.m_encoder.m_total_tile_parts <= 255) {
- size_per_tile_part = 5;
- p_j2k->m_specific_param.m_encoder.m_Ttlmi_is_byte = OPJ_TRUE;
- } else {
- size_per_tile_part = 6;
- p_j2k->m_specific_param.m_encoder.m_Ttlmi_is_byte = OPJ_FALSE;
- }
-
- l_tlm_size = 2 + 4 + (size_per_tile_part *
- p_j2k->m_specific_param.m_encoder.m_total_tile_parts);
-
- if (l_tlm_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size) {
- OPJ_BYTE *new_header_tile_data = (OPJ_BYTE *) opj_realloc(
- p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_tlm_size);
- if (! new_header_tile_data) {
- opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data);
- p_j2k->m_specific_param.m_encoder.m_header_tile_data = NULL;
- p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0;
- opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to write TLM marker\n");
- return OPJ_FALSE;
- }
- p_j2k->m_specific_param.m_encoder.m_header_tile_data = new_header_tile_data;
- p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_tlm_size;
- }
- memset(p_j2k->m_specific_param.m_encoder.m_header_tile_data, 0, l_tlm_size);
-
- l_current_data = p_j2k->m_specific_param.m_encoder.m_header_tile_data;
-
- /* change the way data is written to avoid seeking if possible */
- /* TODO */
- p_j2k->m_specific_param.m_encoder.m_tlm_start = opj_stream_tell(p_stream);
-
- opj_write_bytes(l_current_data, J2K_MS_TLM,
- 2); /* TLM */
- l_current_data += 2;
-
- opj_write_bytes(l_current_data, l_tlm_size - 2,
- 2); /* Lpoc */
- l_current_data += 2;
-
- opj_write_bytes(l_current_data, 0,
- 1); /* Ztlm=0*/
- ++l_current_data;
-
- /* Stlm 0x50= ST=1(8bits-255 tiles max),SP=1(Ptlm=32bits) */
- /* Stlm 0x60= ST=2(16bits-65535 tiles max),SP=1(Ptlm=32bits) */
- opj_write_bytes(l_current_data,
- size_per_tile_part == 5 ? 0x50 : 0x60,
- 1);
- ++l_current_data;
-
- /* do nothing on the size_per_tile_part * l_j2k->m_specific_param.m_encoder.m_total_tile_parts remaining data */
- if (opj_stream_write_data(p_stream,
- p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_tlm_size,
- p_manager) != l_tlm_size) {
- return OPJ_FALSE;
- }
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_write_sot(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_data,
- OPJ_UINT32 total_data_size,
- OPJ_UINT32 * p_data_written,
- const opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager
- )
-{
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_manager != 00);
- assert(p_stream != 00);
-
- OPJ_UNUSED(p_stream);
-
- if (total_data_size < 12) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Not enough bytes in output buffer to write SOT marker\n");
- return OPJ_FALSE;
- }
-
- opj_write_bytes(p_data, J2K_MS_SOT,
- 2); /* SOT */
- p_data += 2;
-
- opj_write_bytes(p_data, 10,
- 2); /* Lsot */
- p_data += 2;
-
- opj_write_bytes(p_data, p_j2k->m_current_tile_number,
- 2); /* Isot */
- p_data += 2;
-
- /* Psot */
- p_data += 4;
-
- opj_write_bytes(p_data,
- p_j2k->m_specific_param.m_encoder.m_current_tile_part_number,
- 1); /* TPsot */
- ++p_data;
-
- opj_write_bytes(p_data,
- p_j2k->m_cp.tcps[p_j2k->m_current_tile_number].m_nb_tile_parts,
- 1); /* TNsot */
- ++p_data;
-
- /* UniPG>> */
-#ifdef USE_JPWL
- /* update markers struct */
- /*
- OPJ_BOOL res = j2k_add_marker(p_j2k->cstr_info, J2K_MS_SOT, p_j2k->sot_start, len + 2);
- */
- assert(0 && "TODO");
-#endif /* USE_JPWL */
-
- * p_data_written = 12;
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_get_sot_values(OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- OPJ_UINT32* p_tile_no,
- OPJ_UINT32* p_tot_len,
- OPJ_UINT32* p_current_part,
- OPJ_UINT32* p_num_parts,
- opj_event_mgr_t * p_manager)
-{
- /* preconditions */
- assert(p_header_data != 00);
- assert(p_manager != 00);
-
- /* Size of this marker is fixed = 12 (we have already read marker and its size)*/
- if (p_header_size != 8) {
- opj_event_msg(p_manager, EVT_ERROR, "Error reading SOT marker\n");
- return OPJ_FALSE;
- }
-
- opj_read_bytes(p_header_data, p_tile_no, 2); /* Isot */
- p_header_data += 2;
- opj_read_bytes(p_header_data, p_tot_len, 4); /* Psot */
- p_header_data += 4;
- opj_read_bytes(p_header_data, p_current_part, 1); /* TPsot */
- ++p_header_data;
- opj_read_bytes(p_header_data, p_num_parts, 1); /* TNsot */
- ++p_header_data;
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_read_sot(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager)
-{
- opj_cp_t *l_cp = 00;
- opj_tcp_t *l_tcp = 00;
- OPJ_UINT32 l_tot_len, l_num_parts = 0;
- OPJ_UINT32 l_current_part;
- OPJ_UINT32 l_tile_x, l_tile_y;
-
- /* preconditions */
-
- assert(p_j2k != 00);
- assert(p_manager != 00);
-
- if (! opj_j2k_get_sot_values(p_header_data, p_header_size,
- &(p_j2k->m_current_tile_number), &l_tot_len, &l_current_part, &l_num_parts,
- p_manager)) {
- opj_event_msg(p_manager, EVT_ERROR, "Error reading SOT marker\n");
- return OPJ_FALSE;
- }
-#ifdef DEBUG_VERBOSE
- fprintf(stderr, "SOT %d %d %d %d\n",
- p_j2k->m_current_tile_number, l_tot_len, l_current_part, l_num_parts);
-#endif
-
- l_cp = &(p_j2k->m_cp);
-
- /* testcase 2.pdf.SIGFPE.706.1112 */
- if (p_j2k->m_current_tile_number >= l_cp->tw * l_cp->th) {
- opj_event_msg(p_manager, EVT_ERROR, "Invalid tile number %d\n",
- p_j2k->m_current_tile_number);
- return OPJ_FALSE;
- }
-
- l_tcp = &l_cp->tcps[p_j2k->m_current_tile_number];
- l_tile_x = p_j2k->m_current_tile_number % l_cp->tw;
- l_tile_y = p_j2k->m_current_tile_number / l_cp->tw;
-
- if (p_j2k->m_specific_param.m_decoder.m_tile_ind_to_dec < 0 ||
- p_j2k->m_current_tile_number == (OPJ_UINT32)
- p_j2k->m_specific_param.m_decoder.m_tile_ind_to_dec) {
- /* Do only this check if we decode all tile part headers, or if */
- /* we decode one precise tile. Otherwise the m_current_tile_part_number */
- /* might not be valid */
- /* Fixes issue with id_000020,sig_06,src_001958,op_flip4,pos_149 */
- /* of https://github.com/uclouvain/openjpeg/issues/939 */
- /* We must avoid reading twice the same tile part number for a given tile */
- /* so as to avoid various issues, like opj_j2k_merge_ppt being called */
- /* several times. */
- /* ISO 15444-1 A.4.2 Start of tile-part (SOT) mandates that tile parts */
- /* should appear in increasing order. */
- if (l_tcp->m_current_tile_part_number + 1 != (OPJ_INT32)l_current_part) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Invalid tile part index for tile number %d. "
- "Got %d, expected %d\n",
- p_j2k->m_current_tile_number,
- l_current_part,
- l_tcp->m_current_tile_part_number + 1);
- return OPJ_FALSE;
- }
- }
-
- l_tcp->m_current_tile_part_number = (OPJ_INT32) l_current_part;
-
-#ifdef USE_JPWL
- if (l_cp->correct) {
-
- OPJ_UINT32 tileno = p_j2k->m_current_tile_number;
- static OPJ_UINT32 backup_tileno = 0;
-
- /* tileno is negative or larger than the number of tiles!!! */
- if (tileno > (l_cp->tw * l_cp->th)) {
- opj_event_msg(p_manager, EVT_ERROR,
- "JPWL: bad tile number (%d out of a maximum of %d)\n",
- tileno, (l_cp->tw * l_cp->th));
- if (!JPWL_ASSUME) {
- opj_event_msg(p_manager, EVT_ERROR, "JPWL: giving up\n");
- return OPJ_FALSE;
- }
- /* we try to correct */
- tileno = backup_tileno;
- opj_event_msg(p_manager, EVT_WARNING, "- trying to adjust this\n"
- "- setting tile number to %d\n",
- tileno);
- }
-
- /* keep your private count of tiles */
- backup_tileno++;
- };
-#endif /* USE_JPWL */
-
- /* look for the tile in the list of already processed tile (in parts). */
- /* Optimization possible here with a more complex data structure and with the removing of tiles */
- /* since the time taken by this function can only grow at the time */
-
- /* PSot should be equal to zero or >=14 or <= 2^32-1 */
- if ((l_tot_len != 0) && (l_tot_len < 14)) {
- if (l_tot_len ==
- 12) { /* MSD: Special case for the PHR data which are read by kakadu*/
- opj_event_msg(p_manager, EVT_WARNING, "Empty SOT marker detected: Psot=%d.\n",
- l_tot_len);
- } else {
- opj_event_msg(p_manager, EVT_ERROR,
- "Psot value is not correct regards to the JPEG2000 norm: %d.\n", l_tot_len);
- return OPJ_FALSE;
- }
- }
-
-#ifdef USE_JPWL
- if (l_cp->correct) {
-
- /* totlen is negative or larger than the bytes left!!! */
- if (/*(l_tot_len < 0) ||*/ (l_tot_len >
- p_header_size)) { /* FIXME it seems correct; for info in V1 -> (p_stream_numbytesleft(p_stream) + 8))) { */
- opj_event_msg(p_manager, EVT_ERROR,
- "JPWL: bad tile byte size (%d bytes against %d bytes left)\n",
- l_tot_len,
- p_header_size); /* FIXME it seems correct; for info in V1 -> p_stream_numbytesleft(p_stream) + 8); */
- if (!JPWL_ASSUME) {
- opj_event_msg(p_manager, EVT_ERROR, "JPWL: giving up\n");
- return OPJ_FALSE;
- }
- /* we try to correct */
- l_tot_len = 0;
- opj_event_msg(p_manager, EVT_WARNING, "- trying to adjust this\n"
- "- setting Psot to %d => assuming it is the last tile\n",
- l_tot_len);
- }
- };
-#endif /* USE_JPWL */
-
- /* Ref A.4.2: Psot could be equal zero if it is the last tile-part of the codestream.*/
- if (!l_tot_len) {
- opj_event_msg(p_manager, EVT_INFO,
- "Psot value of the current tile-part is equal to zero, "
- "we assuming it is the last tile-part of the codestream.\n");
- p_j2k->m_specific_param.m_decoder.m_last_tile_part = 1;
- }
-
- if (l_tcp->m_nb_tile_parts != 0 && l_current_part >= l_tcp->m_nb_tile_parts) {
- /* Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2851 */
- opj_event_msg(p_manager, EVT_ERROR,
- "In SOT marker, TPSot (%d) is not valid regards to the previous "
- "number of tile-part (%d), giving up\n", l_current_part,
- l_tcp->m_nb_tile_parts);
- p_j2k->m_specific_param.m_decoder.m_last_tile_part = 1;
- return OPJ_FALSE;
- }
-
- if (l_num_parts !=
- 0) { /* Number of tile-part header is provided by this tile-part header */
- l_num_parts += p_j2k->m_specific_param.m_decoder.m_nb_tile_parts_correction;
- /* Useful to manage the case of textGBR.jp2 file because two values of TNSot are allowed: the correct numbers of
- * tile-parts for that tile and zero (A.4.2 of 15444-1 : 2002). */
- if (l_tcp->m_nb_tile_parts) {
- if (l_current_part >= l_tcp->m_nb_tile_parts) {
- opj_event_msg(p_manager, EVT_ERROR,
- "In SOT marker, TPSot (%d) is not valid regards to the current "
- "number of tile-part (%d), giving up\n", l_current_part,
- l_tcp->m_nb_tile_parts);
- p_j2k->m_specific_param.m_decoder.m_last_tile_part = 1;
- return OPJ_FALSE;
- }
- }
- if (l_current_part >= l_num_parts) {
- /* testcase 451.pdf.SIGSEGV.ce9.3723 */
- opj_event_msg(p_manager, EVT_ERROR,
- "In SOT marker, TPSot (%d) is not valid regards to the current "
- "number of tile-part (header) (%d), giving up\n", l_current_part, l_num_parts);
- p_j2k->m_specific_param.m_decoder.m_last_tile_part = 1;
- return OPJ_FALSE;
- }
- l_tcp->m_nb_tile_parts = l_num_parts;
- }
-
- /* If know the number of tile part header we will check if we didn't read the last*/
- if (l_tcp->m_nb_tile_parts) {
- if (l_tcp->m_nb_tile_parts == (l_current_part + 1)) {
- p_j2k->m_specific_param.m_decoder.m_can_decode =
- 1; /* Process the last tile-part header*/
- }
- }
-
- if (!p_j2k->m_specific_param.m_decoder.m_last_tile_part) {
- /* Keep the size of data to skip after this marker */
- p_j2k->m_specific_param.m_decoder.m_sot_length = l_tot_len -
- 12; /* SOT_marker_size = 12 */
- } else {
- /* FIXME: need to be computed from the number of bytes remaining in the codestream */
- p_j2k->m_specific_param.m_decoder.m_sot_length = 0;
- }
-
- p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_TPH;
-
- /* Check if the current tile is outside the area we want decode or not corresponding to the tile index*/
- if (p_j2k->m_specific_param.m_decoder.m_tile_ind_to_dec == -1) {
- p_j2k->m_specific_param.m_decoder.m_skip_data =
- (l_tile_x < p_j2k->m_specific_param.m_decoder.m_start_tile_x)
- || (l_tile_x >= p_j2k->m_specific_param.m_decoder.m_end_tile_x)
- || (l_tile_y < p_j2k->m_specific_param.m_decoder.m_start_tile_y)
- || (l_tile_y >= p_j2k->m_specific_param.m_decoder.m_end_tile_y);
- } else {
- assert(p_j2k->m_specific_param.m_decoder.m_tile_ind_to_dec >= 0);
- p_j2k->m_specific_param.m_decoder.m_skip_data =
- (p_j2k->m_current_tile_number != (OPJ_UINT32)
- p_j2k->m_specific_param.m_decoder.m_tile_ind_to_dec);
- }
-
- /* Index */
- {
- assert(p_j2k->cstr_index->tile_index != 00);
- p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tileno =
- p_j2k->m_current_tile_number;
- p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].current_tpsno =
- l_current_part;
-
- if (!p_j2k->m_specific_param.m_decoder.m_tlm.m_is_invalid &&
- l_num_parts >
- p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].nb_tps) {
- opj_event_msg(p_manager, EVT_WARNING,
- "SOT marker for tile %u declares more tile-parts than found in TLM marker.",
- p_j2k->m_current_tile_number);
- p_j2k->m_specific_param.m_decoder.m_tlm.m_is_invalid = OPJ_TRUE;
- }
-
- if (!p_j2k->m_specific_param.m_decoder.m_tlm.m_is_invalid) {
- /* do nothing */
- } else if (l_num_parts != 0) {
-
- p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].nb_tps =
- l_num_parts;
- p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].current_nb_tps =
- l_num_parts;
-
- if (!p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index) {
- p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index =
- (opj_tp_index_t*)opj_calloc(l_num_parts, sizeof(opj_tp_index_t));
- if (!p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Not enough memory to read SOT marker. Tile index allocation failed\n");
- return OPJ_FALSE;
- }
- } else {
- opj_tp_index_t *new_tp_index = (opj_tp_index_t *) opj_realloc(
- p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index,
- l_num_parts * sizeof(opj_tp_index_t));
- if (! new_tp_index) {
- opj_free(p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index);
- p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index = NULL;
- opj_event_msg(p_manager, EVT_ERROR,
- "Not enough memory to read SOT marker. Tile index allocation failed\n");
- return OPJ_FALSE;
- }
- p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index =
- new_tp_index;
- }
- } else {
- /*if (!p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index)*/ {
-
- if (!p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index) {
- p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].current_nb_tps = 10;
- p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index =
- (opj_tp_index_t*)opj_calloc(
- p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].current_nb_tps,
- sizeof(opj_tp_index_t));
- if (!p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index) {
- p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].current_nb_tps = 0;
- opj_event_msg(p_manager, EVT_ERROR,
- "Not enough memory to read SOT marker. Tile index allocation failed\n");
- return OPJ_FALSE;
- }
- }
-
- if (l_current_part >=
- p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].current_nb_tps) {
- opj_tp_index_t *new_tp_index;
- p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].current_nb_tps =
- l_current_part + 1;
- new_tp_index = (opj_tp_index_t *) opj_realloc(
- p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index,
- p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].current_nb_tps *
- sizeof(opj_tp_index_t));
- if (! new_tp_index) {
- opj_free(p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index);
- p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index = NULL;
- p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].current_nb_tps = 0;
- opj_event_msg(p_manager, EVT_ERROR,
- "Not enough memory to read SOT marker. Tile index allocation failed\n");
- return OPJ_FALSE;
- }
- p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index =
- new_tp_index;
- }
- }
-
- }
-
- }
-
- return OPJ_TRUE;
-}
-
-/**
- * Write one or more PLT markers in the provided buffer
- */
-static OPJ_BOOL opj_j2k_write_plt_in_memory(opj_j2k_t *p_j2k,
- opj_tcd_marker_info_t* marker_info,
- OPJ_BYTE * p_data,
- OPJ_UINT32 * p_data_written,
- opj_event_mgr_t * p_manager)
-{
- OPJ_BYTE Zplt = 0;
- OPJ_UINT16 Lplt;
- OPJ_BYTE* p_data_start = p_data;
- OPJ_BYTE* p_data_Lplt = p_data + 2;
- OPJ_UINT32 i;
-
- OPJ_UNUSED(p_j2k);
-
- opj_write_bytes(p_data, J2K_MS_PLT, 2);
- p_data += 2;
-
- /* Reserve space for Lplt */
- p_data += 2;
-
- opj_write_bytes(p_data, Zplt, 1);
- p_data += 1;
-
- Lplt = 3;
-
- for (i = 0; i < marker_info->packet_count; i++) {
- OPJ_BYTE var_bytes[5];
- OPJ_UINT8 var_bytes_size = 0;
- OPJ_UINT32 packet_size = marker_info->p_packet_size[i];
-
- /* Packet size written in variable-length way, starting with LSB */
- var_bytes[var_bytes_size] = (OPJ_BYTE)(packet_size & 0x7f);
- var_bytes_size ++;
- packet_size >>= 7;
- while (packet_size > 0) {
- var_bytes[var_bytes_size] = (OPJ_BYTE)((packet_size & 0x7f) | 0x80);
- var_bytes_size ++;
- packet_size >>= 7;
- }
-
- /* Check if that can fit in the current PLT marker. If not, finish */
- /* current one, and start a new one */
- if (Lplt + var_bytes_size > 65535) {
- if (Zplt == 255) {
- opj_event_msg(p_manager, EVT_ERROR,
- "More than 255 PLT markers would be needed for current tile-part !\n");
- return OPJ_FALSE;
- }
-
- /* Patch Lplt */
- opj_write_bytes(p_data_Lplt, Lplt, 2);
-
- /* Start new segment */
- opj_write_bytes(p_data, J2K_MS_PLT, 2);
- p_data += 2;
-
- /* Reserve space for Lplt */
- p_data_Lplt = p_data;
- p_data += 2;
-
- Zplt ++;
- opj_write_bytes(p_data, Zplt, 1);
- p_data += 1;
-
- Lplt = 3;
- }
-
- Lplt = (OPJ_UINT16)(Lplt + var_bytes_size);
-
- /* Serialize variable-length packet size, starting with MSB */
- for (; var_bytes_size > 0; --var_bytes_size) {
- opj_write_bytes(p_data, var_bytes[var_bytes_size - 1], 1);
- p_data += 1;
- }
- }
-
- *p_data_written = (OPJ_UINT32)(p_data - p_data_start);
-
- /* Patch Lplt */
- opj_write_bytes(p_data_Lplt, Lplt, 2);
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_write_sod(opj_j2k_t *p_j2k,
- opj_tcd_t * p_tile_coder,
- OPJ_BYTE * p_data,
- OPJ_UINT32 * p_data_written,
- OPJ_UINT32 total_data_size,
- const opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager
- )
-{
- opj_codestream_info_t *l_cstr_info = 00;
- OPJ_UINT32 l_remaining_data;
- opj_tcd_marker_info_t* marker_info = NULL;
-
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_manager != 00);
- assert(p_stream != 00);
-
- OPJ_UNUSED(p_stream);
-
- if (total_data_size < 4) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Not enough bytes in output buffer to write SOD marker\n");
- return OPJ_FALSE;
- }
-
- opj_write_bytes(p_data, J2K_MS_SOD,
- 2); /* SOD */
-
- /* make room for the EOF marker */
- l_remaining_data = total_data_size - 4;
-
- /* update tile coder */
- p_tile_coder->tp_num =
- p_j2k->m_specific_param.m_encoder.m_current_poc_tile_part_number ;
- p_tile_coder->cur_tp_num =
- p_j2k->m_specific_param.m_encoder.m_current_tile_part_number;
-
- /* INDEX >> */
- /* TODO mergeV2: check this part which use cstr_info */
- /*l_cstr_info = p_j2k->cstr_info;
- if (l_cstr_info) {
- if (!p_j2k->m_specific_param.m_encoder.m_current_tile_part_number ) {
- //TODO cstr_info->tile[p_j2k->m_current_tile_number].end_header = p_stream_tell(p_stream) + p_j2k->pos_correction - 1;
- l_cstr_info->tile[p_j2k->m_current_tile_number].tileno = p_j2k->m_current_tile_number;
- }
- else {*/
- /*
- TODO
- if
- (cstr_info->tile[p_j2k->m_current_tile_number].packet[cstr_info->packno - 1].end_pos < p_stream_tell(p_stream))
- {
- cstr_info->tile[p_j2k->m_current_tile_number].packet[cstr_info->packno].start_pos = p_stream_tell(p_stream);
- }*/
- /*}*/
- /* UniPG>> */
-#ifdef USE_JPWL
- /* update markers struct */
- /*OPJ_BOOL res = j2k_add_marker(p_j2k->cstr_info, J2K_MS_SOD, p_j2k->sod_start, 2);
- */
- assert(0 && "TODO");
-#endif /* USE_JPWL */
- /* <<UniPG */
- /*}*/
- /* << INDEX */
-
- if (p_j2k->m_specific_param.m_encoder.m_current_tile_part_number == 0) {
- p_tile_coder->tcd_image->tiles->packno = 0;
-#ifdef deadcode
- if (l_cstr_info) {
- l_cstr_info->packno = 0;
- }
-#endif
- }
-
- *p_data_written = 0;
-
- if (p_j2k->m_specific_param.m_encoder.m_PLT) {
- marker_info = opj_tcd_marker_info_create(
- p_j2k->m_specific_param.m_encoder.m_PLT);
- if (marker_info == NULL) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Cannot encode tile: opj_tcd_marker_info_create() failed\n");
- return OPJ_FALSE;
- }
- }
-
- if (l_remaining_data <
- p_j2k->m_specific_param.m_encoder.m_reserved_bytes_for_PLT) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Not enough bytes in output buffer to write SOD marker\n");
- opj_tcd_marker_info_destroy(marker_info);
- return OPJ_FALSE;
- }
- l_remaining_data -= p_j2k->m_specific_param.m_encoder.m_reserved_bytes_for_PLT;
-
- if (! opj_tcd_encode_tile(p_tile_coder, p_j2k->m_current_tile_number,
- p_data + 2,
- p_data_written, l_remaining_data, l_cstr_info,
- marker_info,
- p_manager)) {
- opj_event_msg(p_manager, EVT_ERROR, "Cannot encode tile\n");
- opj_tcd_marker_info_destroy(marker_info);
- return OPJ_FALSE;
- }
-
- /* For SOD */
- *p_data_written += 2;
-
- if (p_j2k->m_specific_param.m_encoder.m_PLT) {
- OPJ_UINT32 l_data_written_PLT = 0;
- OPJ_BYTE* p_PLT_buffer = (OPJ_BYTE*)opj_malloc(
- p_j2k->m_specific_param.m_encoder.m_reserved_bytes_for_PLT);
- if (!p_PLT_buffer) {
- opj_event_msg(p_manager, EVT_ERROR, "Cannot allocate memory\n");
- opj_tcd_marker_info_destroy(marker_info);
- return OPJ_FALSE;
- }
- if (!opj_j2k_write_plt_in_memory(p_j2k,
- marker_info,
- p_PLT_buffer,
- &l_data_written_PLT,
- p_manager)) {
- opj_tcd_marker_info_destroy(marker_info);
- opj_free(p_PLT_buffer);
- return OPJ_FALSE;
- }
-
- assert(l_data_written_PLT <=
- p_j2k->m_specific_param.m_encoder.m_reserved_bytes_for_PLT);
-
- /* Move PLT marker(s) before SOD */
- memmove(p_data + l_data_written_PLT, p_data, *p_data_written);
- memcpy(p_data, p_PLT_buffer, l_data_written_PLT);
- opj_free(p_PLT_buffer);
- *p_data_written += l_data_written_PLT;
- }
-
- opj_tcd_marker_info_destroy(marker_info);
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_read_sod(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager
- )
-{
- OPJ_SIZE_T l_current_read_size;
- opj_codestream_index_t * l_cstr_index = 00;
- OPJ_BYTE ** l_current_data = 00;
- opj_tcp_t * l_tcp = 00;
- OPJ_UINT32 * l_tile_len = 00;
- OPJ_BOOL l_sot_length_pb_detected = OPJ_FALSE;
-
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_manager != 00);
- assert(p_stream != 00);
-
- l_tcp = &(p_j2k->m_cp.tcps[p_j2k->m_current_tile_number]);
-
- if (p_j2k->m_specific_param.m_decoder.m_last_tile_part) {
- /* opj_stream_get_number_byte_left returns OPJ_OFF_T
- // but we are in the last tile part,
- // so its result will fit on OPJ_UINT32 unless we find
- // a file with a single tile part of more than 4 GB...*/
- p_j2k->m_specific_param.m_decoder.m_sot_length = (OPJ_UINT32)(
- opj_stream_get_number_byte_left(p_stream) - 2);
- } else {
- /* Check to avoid pass the limit of OPJ_UINT32 */
- if (p_j2k->m_specific_param.m_decoder.m_sot_length >= 2) {
- p_j2k->m_specific_param.m_decoder.m_sot_length -= 2;
- } else {
- /* MSD: case commented to support empty SOT marker (PHR data) */
- }
- }
-
- l_current_data = &(l_tcp->m_data);
- l_tile_len = &l_tcp->m_data_size;
-
- /* Patch to support new PHR data */
- if (p_j2k->m_specific_param.m_decoder.m_sot_length) {
- /* If we are here, we'll try to read the data after allocation */
- /* Check enough bytes left in stream before allocation */
- if ((OPJ_OFF_T)p_j2k->m_specific_param.m_decoder.m_sot_length >
- opj_stream_get_number_byte_left(p_stream)) {
- if (p_j2k->m_cp.strict) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Tile part length size inconsistent with stream length\n");
- return OPJ_FALSE;
- } else {
- opj_event_msg(p_manager, EVT_WARNING,
- "Tile part length size inconsistent with stream length\n");
- }
- }
- if (p_j2k->m_specific_param.m_decoder.m_sot_length >
- UINT_MAX - OPJ_COMMON_CBLK_DATA_EXTRA) {
- opj_event_msg(p_manager, EVT_ERROR,
- "p_j2k->m_specific_param.m_decoder.m_sot_length > "
- "UINT_MAX - OPJ_COMMON_CBLK_DATA_EXTRA");
- return OPJ_FALSE;
- }
- /* Add a margin of OPJ_COMMON_CBLK_DATA_EXTRA to the allocation we */
- /* do so that opj_mqc_init_dec_common() can safely add a synthetic */
- /* 0xFFFF marker. */
- if (! *l_current_data) {
- /* LH: oddly enough, in this path, l_tile_len!=0.
- * TODO: If this was consistent, we could simplify the code to only use realloc(), as realloc(0,...) default to malloc(0,...).
- */
- *l_current_data = (OPJ_BYTE*) opj_malloc(
- p_j2k->m_specific_param.m_decoder.m_sot_length + OPJ_COMMON_CBLK_DATA_EXTRA);
- } else {
- OPJ_BYTE *l_new_current_data;
- if (*l_tile_len > UINT_MAX - OPJ_COMMON_CBLK_DATA_EXTRA -
- p_j2k->m_specific_param.m_decoder.m_sot_length) {
- opj_event_msg(p_manager, EVT_ERROR,
- "*l_tile_len > UINT_MAX - OPJ_COMMON_CBLK_DATA_EXTRA - "
- "p_j2k->m_specific_param.m_decoder.m_sot_length");
- return OPJ_FALSE;
- }
-
- l_new_current_data = (OPJ_BYTE *) opj_realloc(*l_current_data,
- *l_tile_len + p_j2k->m_specific_param.m_decoder.m_sot_length +
- OPJ_COMMON_CBLK_DATA_EXTRA);
- if (! l_new_current_data) {
- opj_free(*l_current_data);
- /*nothing more is done as l_current_data will be set to null, and just
- afterward we enter in the error path
- and the actual tile_len is updated (committed) at the end of the
- function. */
- }
- *l_current_data = l_new_current_data;
- }
-
- if (*l_current_data == 00) {
- opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to decode tile\n");
- return OPJ_FALSE;
- }
- } else {
- l_sot_length_pb_detected = OPJ_TRUE;
- }
-
- /* Index */
- l_cstr_index = p_j2k->cstr_index;
- {
- OPJ_OFF_T l_current_pos = opj_stream_tell(p_stream) - 2;
-
- OPJ_UINT32 l_current_tile_part =
- l_cstr_index->tile_index[p_j2k->m_current_tile_number].current_tpsno;
- l_cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index[l_current_tile_part].end_header
- =
- l_current_pos;
- l_cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index[l_current_tile_part].end_pos
- =
- l_current_pos + p_j2k->m_specific_param.m_decoder.m_sot_length + 2;
-
- if (OPJ_FALSE == opj_j2k_add_tlmarker(p_j2k->m_current_tile_number,
- l_cstr_index,
- J2K_MS_SOD,
- l_current_pos,
- p_j2k->m_specific_param.m_decoder.m_sot_length + 2)) {
- opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to add tl marker\n");
- return OPJ_FALSE;
- }
-
- /*l_cstr_index->packno = 0;*/
- }
-
- /* Patch to support new PHR data */
- if (!l_sot_length_pb_detected) {
- l_current_read_size = opj_stream_read_data(
- p_stream,
- *l_current_data + *l_tile_len,
- p_j2k->m_specific_param.m_decoder.m_sot_length,
- p_manager);
- } else {
- l_current_read_size = 0;
- }
-
- if (l_current_read_size != p_j2k->m_specific_param.m_decoder.m_sot_length) {
- if (l_current_read_size == (OPJ_SIZE_T)(-1)) {
- /* Avoid issue of https://github.com/uclouvain/openjpeg/issues/1533 */
- opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
- return OPJ_FALSE;
- }
- p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_NEOC;
- } else {
- p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_TPHSOT;
- }
-
- *l_tile_len += (OPJ_UINT32)l_current_read_size;
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_write_rgn(opj_j2k_t *p_j2k,
- OPJ_UINT32 p_tile_no,
- OPJ_UINT32 p_comp_no,
- OPJ_UINT32 nb_comps,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager
- )
-{
- OPJ_BYTE * l_current_data = 00;
- OPJ_UINT32 l_rgn_size;
- opj_cp_t *l_cp = 00;
- opj_tcp_t *l_tcp = 00;
- opj_tccp_t *l_tccp = 00;
- OPJ_UINT32 l_comp_room;
-
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_manager != 00);
- assert(p_stream != 00);
-
- l_cp = &(p_j2k->m_cp);
- l_tcp = &l_cp->tcps[p_tile_no];
- l_tccp = &l_tcp->tccps[p_comp_no];
-
- if (nb_comps <= 256) {
- l_comp_room = 1;
- } else {
- l_comp_room = 2;
- }
-
- l_rgn_size = 6 + l_comp_room;
-
- l_current_data = p_j2k->m_specific_param.m_encoder.m_header_tile_data;
-
- opj_write_bytes(l_current_data, J2K_MS_RGN,
- 2); /* RGN */
- l_current_data += 2;
-
- opj_write_bytes(l_current_data, l_rgn_size - 2,
- 2); /* Lrgn */
- l_current_data += 2;
-
- opj_write_bytes(l_current_data, p_comp_no,
- l_comp_room); /* Crgn */
- l_current_data += l_comp_room;
-
- opj_write_bytes(l_current_data, 0,
- 1); /* Srgn */
- ++l_current_data;
-
- opj_write_bytes(l_current_data, (OPJ_UINT32)l_tccp->roishift,
- 1); /* SPrgn */
- ++l_current_data;
-
- if (opj_stream_write_data(p_stream,
- p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_rgn_size,
- p_manager) != l_rgn_size) {
- return OPJ_FALSE;
- }
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_write_eoc(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager
- )
-{
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_manager != 00);
- assert(p_stream != 00);
-
- opj_write_bytes(p_j2k->m_specific_param.m_encoder.m_header_tile_data,
- J2K_MS_EOC, 2); /* EOC */
-
- /* UniPG>> */
-#ifdef USE_JPWL
- /* update markers struct */
- /*
- OPJ_BOOL res = j2k_add_marker(p_j2k->cstr_info, J2K_MS_EOC, p_stream_tell(p_stream) - 2, 2);
- */
-#endif /* USE_JPWL */
-
- if (opj_stream_write_data(p_stream,
- p_j2k->m_specific_param.m_encoder.m_header_tile_data, 2, p_manager) != 2) {
- return OPJ_FALSE;
- }
-
- if (! opj_stream_flush(p_stream, p_manager)) {
- return OPJ_FALSE;
- }
-
- return OPJ_TRUE;
-}
-
-/**
- * Reads a RGN marker (Region Of Interest)
- *
- * @param p_header_data the data contained in the POC box.
- * @param p_j2k the jpeg2000 codec.
- * @param p_header_size the size of the data contained in the POC marker.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_rgn(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager
- )
-{
- OPJ_UINT32 l_nb_comp;
- opj_image_t * l_image = 00;
-
- opj_cp_t *l_cp = 00;
- opj_tcp_t *l_tcp = 00;
- OPJ_UINT32 l_comp_room, l_comp_no, l_roi_sty;
-
- /* preconditions*/
- assert(p_header_data != 00);
- assert(p_j2k != 00);
- assert(p_manager != 00);
-
- l_image = p_j2k->m_private_image;
- l_nb_comp = l_image->numcomps;
-
- if (l_nb_comp <= 256) {
- l_comp_room = 1;
- } else {
- l_comp_room = 2;
- }
-
- if (p_header_size != 2 + l_comp_room) {
- opj_event_msg(p_manager, EVT_ERROR, "Error reading RGN marker\n");
- return OPJ_FALSE;
- }
-
- l_cp = &(p_j2k->m_cp);
- l_tcp = (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH) ?
- &l_cp->tcps[p_j2k->m_current_tile_number] :
- p_j2k->m_specific_param.m_decoder.m_default_tcp;
-
- opj_read_bytes(p_header_data, &l_comp_no, l_comp_room); /* Crgn */
- p_header_data += l_comp_room;
- opj_read_bytes(p_header_data, &l_roi_sty,
- 1); /* Srgn */
- ++p_header_data;
-
-#ifdef USE_JPWL
- if (l_cp->correct) {
- /* totlen is negative or larger than the bytes left!!! */
- if (l_comp_room >= l_nb_comp) {
- opj_event_msg(p_manager, EVT_ERROR,
- "JPWL: bad component number in RGN (%d when there are only %d)\n",
- l_comp_room, l_nb_comp);
- if (!JPWL_ASSUME) {
- opj_event_msg(p_manager, EVT_ERROR, "JPWL: giving up\n");
- return OPJ_FALSE;
- }
- }
- };
-#endif /* USE_JPWL */
-
- /* testcase 3635.pdf.asan.77.2930 */
- if (l_comp_no >= l_nb_comp) {
- opj_event_msg(p_manager, EVT_ERROR,
- "bad component number in RGN (%d when there are only %d)\n",
- l_comp_no, l_nb_comp);
- return OPJ_FALSE;
- }
-
- opj_read_bytes(p_header_data,
- (OPJ_UINT32 *)(&(l_tcp->tccps[l_comp_no].roishift)), 1); /* SPrgn */
- ++p_header_data;
-
- return OPJ_TRUE;
-
-}
-
-static OPJ_FLOAT32 opj_j2k_get_tp_stride(opj_tcp_t * p_tcp)
-{
- return (OPJ_FLOAT32)((p_tcp->m_nb_tile_parts - 1) * 14);
-}
-
-static OPJ_FLOAT32 opj_j2k_get_default_stride(opj_tcp_t * p_tcp)
-{
- (void)p_tcp;
- return 0;
-}
-
-static OPJ_BOOL opj_j2k_update_rates(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager)
-{
- opj_cp_t * l_cp = 00;
- opj_image_t * l_image = 00;
- opj_tcp_t * l_tcp = 00;
- opj_image_comp_t * l_img_comp = 00;
-
- OPJ_UINT32 i, j, k;
- OPJ_INT32 l_x0, l_y0, l_x1, l_y1;
- OPJ_FLOAT32 * l_rates = 0;
- OPJ_FLOAT32 l_sot_remove;
- OPJ_UINT32 l_bits_empty, l_size_pixel;
- OPJ_UINT64 l_tile_size = 0;
- OPJ_UINT32 l_last_res;
- OPJ_FLOAT32(* l_tp_stride_func)(opj_tcp_t *) = 00;
-
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_manager != 00);
- assert(p_stream != 00);
-
- OPJ_UNUSED(p_manager);
-
- l_cp = &(p_j2k->m_cp);
- l_image = p_j2k->m_private_image;
- l_tcp = l_cp->tcps;
-
- l_bits_empty = 8 * l_image->comps->dx * l_image->comps->dy;
- l_size_pixel = l_image->numcomps * l_image->comps->prec;
- l_sot_remove = (OPJ_FLOAT32) opj_stream_tell(p_stream) / (OPJ_FLOAT32)(
- l_cp->th * l_cp->tw);
-
- if (l_cp->m_specific_param.m_enc.m_tp_on) {
- l_tp_stride_func = opj_j2k_get_tp_stride;
- } else {
- l_tp_stride_func = opj_j2k_get_default_stride;
- }
-
- for (i = 0; i < l_cp->th; ++i) {
- for (j = 0; j < l_cp->tw; ++j) {
- OPJ_FLOAT32 l_offset = (OPJ_FLOAT32)(*l_tp_stride_func)(l_tcp) /
- (OPJ_FLOAT32)l_tcp->numlayers;
-
- /* 4 borders of the tile rescale on the image if necessary */
- l_x0 = opj_int_max((OPJ_INT32)(l_cp->tx0 + j * l_cp->tdx),
- (OPJ_INT32)l_image->x0);
- l_y0 = opj_int_max((OPJ_INT32)(l_cp->ty0 + i * l_cp->tdy),
- (OPJ_INT32)l_image->y0);
- l_x1 = opj_int_min((OPJ_INT32)(l_cp->tx0 + (j + 1) * l_cp->tdx),
- (OPJ_INT32)l_image->x1);
- l_y1 = opj_int_min((OPJ_INT32)(l_cp->ty0 + (i + 1) * l_cp->tdy),
- (OPJ_INT32)l_image->y1);
-
- l_rates = l_tcp->rates;
-
- /* Modification of the RATE >> */
- for (k = 0; k < l_tcp->numlayers; ++k) {
- if (*l_rates > 0.0f) {
- *l_rates = (OPJ_FLOAT32)(((OPJ_FLOAT64)l_size_pixel * (OPJ_UINT32)(
- l_x1 - l_x0) *
- (OPJ_UINT32)(l_y1 - l_y0))
- / ((*l_rates) * (OPJ_FLOAT32)l_bits_empty))
- -
- l_offset;
- }
-
- ++l_rates;
- }
-
- ++l_tcp;
-
- }
- }
-
- l_tcp = l_cp->tcps;
-
- for (i = 0; i < l_cp->th; ++i) {
- for (j = 0; j < l_cp->tw; ++j) {
- l_rates = l_tcp->rates;
-
- if (*l_rates > 0.0f) {
- *l_rates -= l_sot_remove;
-
- if (*l_rates < 30.0f) {
- *l_rates = 30.0f;
- }
- }
-
- ++l_rates;
-
- l_last_res = l_tcp->numlayers - 1;
-
- for (k = 1; k < l_last_res; ++k) {
-
- if (*l_rates > 0.0f) {
- *l_rates -= l_sot_remove;
-
- if (*l_rates < * (l_rates - 1) + 10.0f) {
- *l_rates = (*(l_rates - 1)) + 20.0f;
- }
- }
-
- ++l_rates;
- }
-
- if (*l_rates > 0.0f) {
- *l_rates -= (l_sot_remove + 2.f);
-
- if (*l_rates < * (l_rates - 1) + 10.0f) {
- *l_rates = (*(l_rates - 1)) + 20.0f;
- }
- }
-
- ++l_tcp;
- }
- }
-
- l_img_comp = l_image->comps;
- l_tile_size = 0;
-
- for (i = 0; i < l_image->numcomps; ++i) {
- l_tile_size += (OPJ_UINT64)opj_uint_ceildiv(l_cp->tdx, l_img_comp->dx)
- *
- opj_uint_ceildiv(l_cp->tdy, l_img_comp->dy)
- *
- l_img_comp->prec;
-
- ++l_img_comp;
- }
-
- /* TODO: where does this magic value come from ? */
- /* This used to be 1.3 / 8, but with random data and very small code */
- /* block sizes, this is not enough. For example with */
- /* bin/test_tile_encoder 1 256 256 32 32 8 0 reversible_with_precinct.j2k 4 4 3 0 0 1 16 16 */
- /* TODO revise this to take into account the overhead linked to the */
- /* number of packets and number of code blocks in packets */
- l_tile_size = (OPJ_UINT64)((double)l_tile_size * 1.4 / 8);
-
- /* Arbitrary amount to make the following work: */
- /* bin/test_tile_encoder 1 256 256 17 16 8 0 reversible_no_precinct.j2k 4 4 3 0 0 1 */
- l_tile_size += 500;
-
- l_tile_size += opj_j2k_get_specific_header_sizes(p_j2k);
-
- if (l_tile_size > UINT_MAX) {
- l_tile_size = UINT_MAX;
- }
-
- p_j2k->m_specific_param.m_encoder.m_encoded_tile_size = (OPJ_UINT32)l_tile_size;
- p_j2k->m_specific_param.m_encoder.m_encoded_tile_data =
- (OPJ_BYTE *) opj_malloc(p_j2k->m_specific_param.m_encoder.m_encoded_tile_size);
- if (p_j2k->m_specific_param.m_encoder.m_encoded_tile_data == 00) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Not enough memory to allocate m_encoded_tile_data. %u MB required\n",
- (OPJ_UINT32)(l_tile_size / 1024 / 1024));
- return OPJ_FALSE;
- }
-
- if (p_j2k->m_specific_param.m_encoder.m_TLM) {
- p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer =
- (OPJ_BYTE *) opj_malloc(6 *
- p_j2k->m_specific_param.m_encoder.m_total_tile_parts);
- if (! p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer) {
- return OPJ_FALSE;
- }
-
- p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_current =
- p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer;
- }
-
- return OPJ_TRUE;
-}
-
-#if 0
-static OPJ_BOOL opj_j2k_read_eoc(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager)
-{
- OPJ_UINT32 i;
- opj_tcd_t * l_tcd = 00;
- OPJ_UINT32 l_nb_tiles;
- opj_tcp_t * l_tcp = 00;
- OPJ_BOOL l_success;
-
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_manager != 00);
- assert(p_stream != 00);
-
- l_nb_tiles = p_j2k->m_cp.th * p_j2k->m_cp.tw;
- l_tcp = p_j2k->m_cp.tcps;
-
- l_tcd = opj_tcd_create(OPJ_TRUE);
- if (l_tcd == 00) {
- opj_event_msg(p_manager, EVT_ERROR, "Cannot decode tile, memory error\n");
- return OPJ_FALSE;
- }
-
- for (i = 0; i < l_nb_tiles; ++i) {
- if (l_tcp->m_data) {
- if (! opj_tcd_init_decode_tile(l_tcd, i)) {
- opj_tcd_destroy(l_tcd);
- opj_event_msg(p_manager, EVT_ERROR, "Cannot decode tile, memory error\n");
- return OPJ_FALSE;
- }
-
- l_success = opj_tcd_decode_tile(l_tcd, l_tcp->m_data, l_tcp->m_data_size, i,
- p_j2k->cstr_index);
- /* cleanup */
-
- if (! l_success) {
- p_j2k->m_specific_param.m_decoder.m_state |= J2K_STATE_ERR;
- break;
- }
- }
-
- opj_j2k_tcp_destroy(l_tcp);
- ++l_tcp;
- }
-
- opj_tcd_destroy(l_tcd);
- return OPJ_TRUE;
-}
-#endif
-
-static OPJ_BOOL opj_j2k_get_end_header(opj_j2k_t *p_j2k,
- struct opj_stream_private *p_stream,
- struct opj_event_mgr * p_manager)
-{
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_manager != 00);
- assert(p_stream != 00);
-
- OPJ_UNUSED(p_manager);
-
- p_j2k->cstr_index->main_head_end = opj_stream_tell(p_stream);
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_write_mct_data_group(opj_j2k_t *p_j2k,
- struct opj_stream_private *p_stream,
- struct opj_event_mgr * p_manager)
-{
- OPJ_UINT32 i;
- opj_simple_mcc_decorrelation_data_t * l_mcc_record;
- opj_mct_data_t * l_mct_record;
- opj_tcp_t * l_tcp;
-
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_stream != 00);
- assert(p_manager != 00);
-
- if (! opj_j2k_write_cbd(p_j2k, p_stream, p_manager)) {
- return OPJ_FALSE;
- }
-
- l_tcp = &(p_j2k->m_cp.tcps[p_j2k->m_current_tile_number]);
- l_mct_record = l_tcp->m_mct_records;
-
- for (i = 0; i < l_tcp->m_nb_mct_records; ++i) {
-
- if (! opj_j2k_write_mct_record(p_j2k, l_mct_record, p_stream, p_manager)) {
- return OPJ_FALSE;
- }
-
- ++l_mct_record;
- }
-
- l_mcc_record = l_tcp->m_mcc_records;
-
- for (i = 0; i < l_tcp->m_nb_mcc_records; ++i) {
-
- if (! opj_j2k_write_mcc_record(p_j2k, l_mcc_record, p_stream, p_manager)) {
- return OPJ_FALSE;
- }
-
- ++l_mcc_record;
- }
-
- if (! opj_j2k_write_mco(p_j2k, p_stream, p_manager)) {
- return OPJ_FALSE;
- }
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_write_all_coc(
- opj_j2k_t *p_j2k,
- struct opj_stream_private *p_stream,
- struct opj_event_mgr * p_manager)
-{
- OPJ_UINT32 compno;
-
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_manager != 00);
- assert(p_stream != 00);
-
- for (compno = 1; compno < p_j2k->m_private_image->numcomps; ++compno) {
- /* cod is first component of first tile */
- if (! opj_j2k_compare_coc(p_j2k, 0, compno)) {
- if (! opj_j2k_write_coc(p_j2k, compno, p_stream, p_manager)) {
- return OPJ_FALSE;
- }
- }
- }
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_write_all_qcc(
- opj_j2k_t *p_j2k,
- struct opj_stream_private *p_stream,
- struct opj_event_mgr * p_manager)
-{
- OPJ_UINT32 compno;
-
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_manager != 00);
- assert(p_stream != 00);
-
- for (compno = 1; compno < p_j2k->m_private_image->numcomps; ++compno) {
- /* qcd is first component of first tile */
- if (! opj_j2k_compare_qcc(p_j2k, 0, compno)) {
- if (! opj_j2k_write_qcc(p_j2k, compno, p_stream, p_manager)) {
- return OPJ_FALSE;
- }
- }
- }
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_write_regions(opj_j2k_t *p_j2k,
- struct opj_stream_private *p_stream,
- struct opj_event_mgr * p_manager)
-{
- OPJ_UINT32 compno;
- const opj_tccp_t *l_tccp = 00;
-
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_manager != 00);
- assert(p_stream != 00);
-
- l_tccp = p_j2k->m_cp.tcps->tccps;
-
- for (compno = 0; compno < p_j2k->m_private_image->numcomps; ++compno) {
- if (l_tccp->roishift) {
-
- if (! opj_j2k_write_rgn(p_j2k, 0, compno, p_j2k->m_private_image->numcomps,
- p_stream, p_manager)) {
- return OPJ_FALSE;
- }
- }
-
- ++l_tccp;
- }
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_write_epc(opj_j2k_t *p_j2k,
- struct opj_stream_private *p_stream,
- struct opj_event_mgr * p_manager)
-{
- opj_codestream_index_t * l_cstr_index = 00;
-
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_manager != 00);
- assert(p_stream != 00);
-
- OPJ_UNUSED(p_manager);
-
- l_cstr_index = p_j2k->cstr_index;
- if (l_cstr_index) {
- l_cstr_index->codestream_size = (OPJ_UINT64)opj_stream_tell(p_stream);
- /* UniPG>> */
- /* The following adjustment is done to adjust the codestream size */
- /* if SOD is not at 0 in the buffer. Useful in case of JP2, where */
- /* the first bunch of bytes is not in the codestream */
- l_cstr_index->codestream_size -= (OPJ_UINT64)l_cstr_index->main_head_start;
- /* <<UniPG */
- }
-
-#ifdef USE_JPWL
- /* preparation of JPWL marker segments */
-#if 0
- if (cp->epc_on) {
-
- /* encode according to JPWL */
- jpwl_encode(p_j2k, p_stream, image);
-
- }
-#endif
- assert(0 && "TODO");
-#endif /* USE_JPWL */
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_read_unk(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- OPJ_UINT32 *output_marker,
- opj_event_mgr_t * p_manager
- )
-{
- OPJ_UINT32 l_unknown_marker;
- const opj_dec_memory_marker_handler_t * l_marker_handler;
- OPJ_UINT32 l_size_unk = 2;
-
- /* preconditions*/
- assert(p_j2k != 00);
- assert(p_manager != 00);
- assert(p_stream != 00);
-
- opj_event_msg(p_manager, EVT_WARNING, "Unknown marker\n");
-
- for (;;) {
- /* Try to read 2 bytes (the next marker ID) from stream and copy them into the buffer*/
- if (opj_stream_read_data(p_stream,
- p_j2k->m_specific_param.m_decoder.m_header_data, 2, p_manager) != 2) {
- opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
- return OPJ_FALSE;
- }
-
- /* read 2 bytes as the new marker ID*/
- opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data,
- &l_unknown_marker, 2);
-
- if (!(l_unknown_marker < 0xff00)) {
-
- /* Get the marker handler from the marker ID*/
- l_marker_handler = opj_j2k_get_marker_handler(l_unknown_marker);
-
- if (!(p_j2k->m_specific_param.m_decoder.m_state & l_marker_handler->states)) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Marker is not compliant with its position\n");
- return OPJ_FALSE;
- } else {
- if (l_marker_handler->id != J2K_MS_UNK) {
- /* Add the marker to the codestream index*/
- if (l_marker_handler->id != J2K_MS_SOT) {
- OPJ_BOOL res = opj_j2k_add_mhmarker(p_j2k->cstr_index, J2K_MS_UNK,
- (OPJ_UINT32) opj_stream_tell(p_stream) - l_size_unk,
- l_size_unk);
- if (res == OPJ_FALSE) {
- opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to add mh marker\n");
- return OPJ_FALSE;
- }
- }
- break; /* next marker is known and well located */
- } else {
- l_size_unk += 2;
- }
- }
- }
- }
-
- *output_marker = l_marker_handler->id ;
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_write_mct_record(opj_j2k_t *p_j2k,
- opj_mct_data_t * p_mct_record,
- struct opj_stream_private *p_stream,
- struct opj_event_mgr * p_manager)
-{
- OPJ_UINT32 l_mct_size;
- OPJ_BYTE * l_current_data = 00;
- OPJ_UINT32 l_tmp;
-
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_manager != 00);
- assert(p_stream != 00);
-
- l_mct_size = 10 + p_mct_record->m_data_size;
-
- if (l_mct_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size) {
- OPJ_BYTE *new_header_tile_data = (OPJ_BYTE *) opj_realloc(
- p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_mct_size);
- if (! new_header_tile_data) {
- opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data);
- p_j2k->m_specific_param.m_encoder.m_header_tile_data = NULL;
- p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0;
- opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to write MCT marker\n");
- return OPJ_FALSE;
- }
- p_j2k->m_specific_param.m_encoder.m_header_tile_data = new_header_tile_data;
- p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_mct_size;
- }
-
- l_current_data = p_j2k->m_specific_param.m_encoder.m_header_tile_data;
-
- opj_write_bytes(l_current_data, J2K_MS_MCT,
- 2); /* MCT */
- l_current_data += 2;
-
- opj_write_bytes(l_current_data, l_mct_size - 2,
- 2); /* Lmct */
- l_current_data += 2;
-
- opj_write_bytes(l_current_data, 0,
- 2); /* Zmct */
- l_current_data += 2;
-
- /* only one marker atm */
- l_tmp = (p_mct_record->m_index & 0xff) | (p_mct_record->m_array_type << 8) |
- (p_mct_record->m_element_type << 10);
-
- opj_write_bytes(l_current_data, l_tmp, 2);
- l_current_data += 2;
-
- opj_write_bytes(l_current_data, 0,
- 2); /* Ymct */
- l_current_data += 2;
-
- memcpy(l_current_data, p_mct_record->m_data, p_mct_record->m_data_size);
-
- if (opj_stream_write_data(p_stream,
- p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_mct_size,
- p_manager) != l_mct_size) {
- return OPJ_FALSE;
- }
-
- return OPJ_TRUE;
-}
-
-/**
- * Reads a MCT marker (Multiple Component Transform)
- *
- * @param p_header_data the data contained in the MCT box.
- * @param p_j2k the jpeg2000 codec.
- * @param p_header_size the size of the data contained in the MCT marker.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_mct(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager
- )
-{
- OPJ_UINT32 i;
- opj_tcp_t *l_tcp = 00;
- OPJ_UINT32 l_tmp;
- OPJ_UINT32 l_indix;
- opj_mct_data_t * l_mct_data;
-
- /* preconditions */
- assert(p_header_data != 00);
- assert(p_j2k != 00);
-
- l_tcp = p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH ?
- &p_j2k->m_cp.tcps[p_j2k->m_current_tile_number] :
- p_j2k->m_specific_param.m_decoder.m_default_tcp;
-
- if (p_header_size < 2) {
- opj_event_msg(p_manager, EVT_ERROR, "Error reading MCT marker\n");
- return OPJ_FALSE;
- }
-
- /* first marker */
- opj_read_bytes(p_header_data, &l_tmp, 2); /* Zmct */
- p_header_data += 2;
- if (l_tmp != 0) {
- opj_event_msg(p_manager, EVT_WARNING,
- "Cannot take in charge mct data within multiple MCT records\n");
- return OPJ_TRUE;
- }
-
- if (p_header_size <= 6) {
- opj_event_msg(p_manager, EVT_ERROR, "Error reading MCT marker\n");
- return OPJ_FALSE;
- }
-
- /* Imct -> no need for other values, take the first, type is double with decorrelation x0000 1101 0000 0000*/
- opj_read_bytes(p_header_data, &l_tmp, 2); /* Imct */
- p_header_data += 2;
-
- l_indix = l_tmp & 0xff;
- l_mct_data = l_tcp->m_mct_records;
-
- for (i = 0; i < l_tcp->m_nb_mct_records; ++i) {
- if (l_mct_data->m_index == l_indix) {
- break;
- }
- ++l_mct_data;
- }
-
- /* NOT FOUND */
- if (i == l_tcp->m_nb_mct_records) {
- if (l_tcp->m_nb_mct_records == l_tcp->m_nb_max_mct_records) {
- opj_mct_data_t *new_mct_records;
- l_tcp->m_nb_max_mct_records += OPJ_J2K_MCT_DEFAULT_NB_RECORDS;
-
- new_mct_records = (opj_mct_data_t *) opj_realloc(l_tcp->m_mct_records,
- l_tcp->m_nb_max_mct_records * sizeof(opj_mct_data_t));
- if (! new_mct_records) {
- opj_free(l_tcp->m_mct_records);
- l_tcp->m_mct_records = NULL;
- l_tcp->m_nb_max_mct_records = 0;
- l_tcp->m_nb_mct_records = 0;
- opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to read MCT marker\n");
- return OPJ_FALSE;
- }
-
- /* Update m_mcc_records[].m_offset_array and m_decorrelation_array
- * to point to the new addresses */
- if (new_mct_records != l_tcp->m_mct_records) {
- for (i = 0; i < l_tcp->m_nb_mcc_records; ++i) {
- opj_simple_mcc_decorrelation_data_t* l_mcc_record =
- &(l_tcp->m_mcc_records[i]);
- if (l_mcc_record->m_decorrelation_array) {
- l_mcc_record->m_decorrelation_array =
- new_mct_records +
- (l_mcc_record->m_decorrelation_array -
- l_tcp->m_mct_records);
- }
- if (l_mcc_record->m_offset_array) {
- l_mcc_record->m_offset_array =
- new_mct_records +
- (l_mcc_record->m_offset_array -
- l_tcp->m_mct_records);
- }
- }
- }
-
- l_tcp->m_mct_records = new_mct_records;
- l_mct_data = l_tcp->m_mct_records + l_tcp->m_nb_mct_records;
- memset(l_mct_data, 0, (l_tcp->m_nb_max_mct_records - l_tcp->m_nb_mct_records) *
- sizeof(opj_mct_data_t));
- }
-
- l_mct_data = l_tcp->m_mct_records + l_tcp->m_nb_mct_records;
- ++l_tcp->m_nb_mct_records;
- }
-
- if (l_mct_data->m_data) {
- opj_free(l_mct_data->m_data);
- l_mct_data->m_data = 00;
- l_mct_data->m_data_size = 0;
- }
-
- l_mct_data->m_index = l_indix;
- l_mct_data->m_array_type = (J2K_MCT_ARRAY_TYPE)((l_tmp >> 8) & 3);
- l_mct_data->m_element_type = (J2K_MCT_ELEMENT_TYPE)((l_tmp >> 10) & 3);
-
- opj_read_bytes(p_header_data, &l_tmp, 2); /* Ymct */
- p_header_data += 2;
- if (l_tmp != 0) {
- opj_event_msg(p_manager, EVT_WARNING,
- "Cannot take in charge multiple MCT markers\n");
- return OPJ_TRUE;
- }
-
- p_header_size -= 6;
-
- l_mct_data->m_data = (OPJ_BYTE*)opj_malloc(p_header_size);
- if (! l_mct_data->m_data) {
- opj_event_msg(p_manager, EVT_ERROR, "Error reading MCT marker\n");
- return OPJ_FALSE;
- }
- memcpy(l_mct_data->m_data, p_header_data, p_header_size);
-
- l_mct_data->m_data_size = p_header_size;
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_write_mcc_record(opj_j2k_t *p_j2k,
- struct opj_simple_mcc_decorrelation_data * p_mcc_record,
- struct opj_stream_private *p_stream,
- struct opj_event_mgr * p_manager)
-{
- OPJ_UINT32 i;
- OPJ_UINT32 l_mcc_size;
- OPJ_BYTE * l_current_data = 00;
- OPJ_UINT32 l_nb_bytes_for_comp;
- OPJ_UINT32 l_mask;
- OPJ_UINT32 l_tmcc;
-
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_manager != 00);
- assert(p_stream != 00);
-
- if (p_mcc_record->m_nb_comps > 255) {
- l_nb_bytes_for_comp = 2;
- l_mask = 0x8000;
- } else {
- l_nb_bytes_for_comp = 1;
- l_mask = 0;
- }
-
- l_mcc_size = p_mcc_record->m_nb_comps * 2 * l_nb_bytes_for_comp + 19;
- if (l_mcc_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size) {
- OPJ_BYTE *new_header_tile_data = (OPJ_BYTE *) opj_realloc(
- p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_mcc_size);
- if (! new_header_tile_data) {
- opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data);
- p_j2k->m_specific_param.m_encoder.m_header_tile_data = NULL;
- p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0;
- opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to write MCC marker\n");
- return OPJ_FALSE;
- }
- p_j2k->m_specific_param.m_encoder.m_header_tile_data = new_header_tile_data;
- p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_mcc_size;
- }
-
- l_current_data = p_j2k->m_specific_param.m_encoder.m_header_tile_data;
-
- opj_write_bytes(l_current_data, J2K_MS_MCC,
- 2); /* MCC */
- l_current_data += 2;
-
- opj_write_bytes(l_current_data, l_mcc_size - 2,
- 2); /* Lmcc */
- l_current_data += 2;
-
- /* first marker */
- opj_write_bytes(l_current_data, 0,
- 2); /* Zmcc */
- l_current_data += 2;
-
- opj_write_bytes(l_current_data, p_mcc_record->m_index,
- 1); /* Imcc -> no need for other values, take the first */
- ++l_current_data;
-
- /* only one marker atm */
- opj_write_bytes(l_current_data, 0,
- 2); /* Ymcc */
- l_current_data += 2;
-
- opj_write_bytes(l_current_data, 1,
- 2); /* Qmcc -> number of collections -> 1 */
- l_current_data += 2;
-
- opj_write_bytes(l_current_data, 0x1,
- 1); /* Xmcci type of component transformation -> array based decorrelation */
- ++l_current_data;
-
- opj_write_bytes(l_current_data, p_mcc_record->m_nb_comps | l_mask,
- 2); /* Nmcci number of input components involved and size for each component offset = 8 bits */
- l_current_data += 2;
-
- for (i = 0; i < p_mcc_record->m_nb_comps; ++i) {
- opj_write_bytes(l_current_data, i,
- l_nb_bytes_for_comp); /* Cmccij Component offset*/
- l_current_data += l_nb_bytes_for_comp;
- }
-
- opj_write_bytes(l_current_data, p_mcc_record->m_nb_comps | l_mask,
- 2); /* Mmcci number of output components involved and size for each component offset = 8 bits */
- l_current_data += 2;
-
- for (i = 0; i < p_mcc_record->m_nb_comps; ++i) {
- opj_write_bytes(l_current_data, i,
- l_nb_bytes_for_comp); /* Wmccij Component offset*/
- l_current_data += l_nb_bytes_for_comp;
- }
-
- l_tmcc = ((!p_mcc_record->m_is_irreversible) & 1U) << 16;
-
- if (p_mcc_record->m_decorrelation_array) {
- l_tmcc |= p_mcc_record->m_decorrelation_array->m_index;
- }
-
- if (p_mcc_record->m_offset_array) {
- l_tmcc |= ((p_mcc_record->m_offset_array->m_index) << 8);
- }
-
- opj_write_bytes(l_current_data, l_tmcc,
- 3); /* Tmcci : use MCT defined as number 1 and irreversible array based. */
- l_current_data += 3;
-
- if (opj_stream_write_data(p_stream,
- p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_mcc_size,
- p_manager) != l_mcc_size) {
- return OPJ_FALSE;
- }
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_read_mcc(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager)
-{
- OPJ_UINT32 i, j;
- OPJ_UINT32 l_tmp;
- OPJ_UINT32 l_indix;
- opj_tcp_t * l_tcp;
- opj_simple_mcc_decorrelation_data_t * l_mcc_record;
- opj_mct_data_t * l_mct_data;
- OPJ_UINT32 l_nb_collections;
- OPJ_UINT32 l_nb_comps;
- OPJ_UINT32 l_nb_bytes_by_comp;
- OPJ_BOOL l_new_mcc = OPJ_FALSE;
-
- /* preconditions */
- assert(p_header_data != 00);
- assert(p_j2k != 00);
- assert(p_manager != 00);
-
- l_tcp = p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH ?
- &p_j2k->m_cp.tcps[p_j2k->m_current_tile_number] :
- p_j2k->m_specific_param.m_decoder.m_default_tcp;
-
- if (p_header_size < 2) {
- opj_event_msg(p_manager, EVT_ERROR, "Error reading MCC marker\n");
- return OPJ_FALSE;
- }
-
- /* first marker */
- opj_read_bytes(p_header_data, &l_tmp, 2); /* Zmcc */
- p_header_data += 2;
- if (l_tmp != 0) {
- opj_event_msg(p_manager, EVT_WARNING,
- "Cannot take in charge multiple data spanning\n");
- return OPJ_TRUE;
- }
-
- if (p_header_size < 7) {
- opj_event_msg(p_manager, EVT_ERROR, "Error reading MCC marker\n");
- return OPJ_FALSE;
- }
-
- opj_read_bytes(p_header_data, &l_indix,
- 1); /* Imcc -> no need for other values, take the first */
- ++p_header_data;
-
- l_mcc_record = l_tcp->m_mcc_records;
-
- for (i = 0; i < l_tcp->m_nb_mcc_records; ++i) {
- if (l_mcc_record->m_index == l_indix) {
- break;
- }
- ++l_mcc_record;
- }
-
- /** NOT FOUND */
- if (i == l_tcp->m_nb_mcc_records) {
- if (l_tcp->m_nb_mcc_records == l_tcp->m_nb_max_mcc_records) {
- opj_simple_mcc_decorrelation_data_t *new_mcc_records;
- l_tcp->m_nb_max_mcc_records += OPJ_J2K_MCC_DEFAULT_NB_RECORDS;
-
- new_mcc_records = (opj_simple_mcc_decorrelation_data_t *) opj_realloc(
- l_tcp->m_mcc_records, l_tcp->m_nb_max_mcc_records * sizeof(
- opj_simple_mcc_decorrelation_data_t));
- if (! new_mcc_records) {
- opj_free(l_tcp->m_mcc_records);
- l_tcp->m_mcc_records = NULL;
- l_tcp->m_nb_max_mcc_records = 0;
- l_tcp->m_nb_mcc_records = 0;
- opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to read MCC marker\n");
- return OPJ_FALSE;
- }
- l_tcp->m_mcc_records = new_mcc_records;
- l_mcc_record = l_tcp->m_mcc_records + l_tcp->m_nb_mcc_records;
- memset(l_mcc_record, 0, (l_tcp->m_nb_max_mcc_records - l_tcp->m_nb_mcc_records)
- * sizeof(opj_simple_mcc_decorrelation_data_t));
- }
- l_mcc_record = l_tcp->m_mcc_records + l_tcp->m_nb_mcc_records;
- l_new_mcc = OPJ_TRUE;
- }
- l_mcc_record->m_index = l_indix;
-
- /* only one marker atm */
- opj_read_bytes(p_header_data, &l_tmp, 2); /* Ymcc */
- p_header_data += 2;
- if (l_tmp != 0) {
- opj_event_msg(p_manager, EVT_WARNING,
- "Cannot take in charge multiple data spanning\n");
- return OPJ_TRUE;
- }
-
- opj_read_bytes(p_header_data, &l_nb_collections,
- 2); /* Qmcc -> number of collections -> 1 */
- p_header_data += 2;
-
- if (l_nb_collections > 1) {
- opj_event_msg(p_manager, EVT_WARNING,
- "Cannot take in charge multiple collections\n");
- return OPJ_TRUE;
- }
-
- p_header_size -= 7;
-
- for (i = 0; i < l_nb_collections; ++i) {
- if (p_header_size < 3) {
- opj_event_msg(p_manager, EVT_ERROR, "Error reading MCC marker\n");
- return OPJ_FALSE;
- }
-
- opj_read_bytes(p_header_data, &l_tmp,
- 1); /* Xmcci type of component transformation -> array based decorrelation */
- ++p_header_data;
-
- if (l_tmp != 1) {
- opj_event_msg(p_manager, EVT_WARNING,
- "Cannot take in charge collections other than array decorrelation\n");
- return OPJ_TRUE;
- }
-
- opj_read_bytes(p_header_data, &l_nb_comps, 2);
-
- p_header_data += 2;
- p_header_size -= 3;
-
- l_nb_bytes_by_comp = 1 + (l_nb_comps >> 15);
- l_mcc_record->m_nb_comps = l_nb_comps & 0x7fff;
-
- if (p_header_size < (l_nb_bytes_by_comp * l_mcc_record->m_nb_comps + 2)) {
- opj_event_msg(p_manager, EVT_ERROR, "Error reading MCC marker\n");
- return OPJ_FALSE;
- }
-
- p_header_size -= (l_nb_bytes_by_comp * l_mcc_record->m_nb_comps + 2);
-
- for (j = 0; j < l_mcc_record->m_nb_comps; ++j) {
- opj_read_bytes(p_header_data, &l_tmp,
- l_nb_bytes_by_comp); /* Cmccij Component offset*/
- p_header_data += l_nb_bytes_by_comp;
-
- if (l_tmp != j) {
- opj_event_msg(p_manager, EVT_WARNING,
- "Cannot take in charge collections with indix shuffle\n");
- return OPJ_TRUE;
- }
- }
-
- opj_read_bytes(p_header_data, &l_nb_comps, 2);
- p_header_data += 2;
-
- l_nb_bytes_by_comp = 1 + (l_nb_comps >> 15);
- l_nb_comps &= 0x7fff;
-
- if (l_nb_comps != l_mcc_record->m_nb_comps) {
- opj_event_msg(p_manager, EVT_WARNING,
- "Cannot take in charge collections without same number of indixes\n");
- return OPJ_TRUE;
- }
-
- if (p_header_size < (l_nb_bytes_by_comp * l_mcc_record->m_nb_comps + 3)) {
- opj_event_msg(p_manager, EVT_ERROR, "Error reading MCC marker\n");
- return OPJ_FALSE;
- }
-
- p_header_size -= (l_nb_bytes_by_comp * l_mcc_record->m_nb_comps + 3);
-
- for (j = 0; j < l_mcc_record->m_nb_comps; ++j) {
- opj_read_bytes(p_header_data, &l_tmp,
- l_nb_bytes_by_comp); /* Wmccij Component offset*/
- p_header_data += l_nb_bytes_by_comp;
-
- if (l_tmp != j) {
- opj_event_msg(p_manager, EVT_WARNING,
- "Cannot take in charge collections with indix shuffle\n");
- return OPJ_TRUE;
- }
- }
-
- opj_read_bytes(p_header_data, &l_tmp, 3); /* Wmccij Component offset*/
- p_header_data += 3;
-
- l_mcc_record->m_is_irreversible = !((l_tmp >> 16) & 1);
- l_mcc_record->m_decorrelation_array = 00;
- l_mcc_record->m_offset_array = 00;
-
- l_indix = l_tmp & 0xff;
- if (l_indix != 0) {
- l_mct_data = l_tcp->m_mct_records;
- for (j = 0; j < l_tcp->m_nb_mct_records; ++j) {
- if (l_mct_data->m_index == l_indix) {
- l_mcc_record->m_decorrelation_array = l_mct_data;
- break;
- }
- ++l_mct_data;
- }
-
- if (l_mcc_record->m_decorrelation_array == 00) {
- opj_event_msg(p_manager, EVT_ERROR, "Error reading MCC marker\n");
- return OPJ_FALSE;
- }
- }
-
- l_indix = (l_tmp >> 8) & 0xff;
- if (l_indix != 0) {
- l_mct_data = l_tcp->m_mct_records;
- for (j = 0; j < l_tcp->m_nb_mct_records; ++j) {
- if (l_mct_data->m_index == l_indix) {
- l_mcc_record->m_offset_array = l_mct_data;
- break;
- }
- ++l_mct_data;
- }
-
- if (l_mcc_record->m_offset_array == 00) {
- opj_event_msg(p_manager, EVT_ERROR, "Error reading MCC marker\n");
- return OPJ_FALSE;
- }
- }
- }
-
- if (p_header_size != 0) {
- opj_event_msg(p_manager, EVT_ERROR, "Error reading MCC marker\n");
- return OPJ_FALSE;
- }
-
- if (l_new_mcc) {
- ++l_tcp->m_nb_mcc_records;
- }
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_write_mco(opj_j2k_t *p_j2k,
- struct opj_stream_private *p_stream,
- struct opj_event_mgr * p_manager
- )
-{
- OPJ_BYTE * l_current_data = 00;
- OPJ_UINT32 l_mco_size;
- opj_tcp_t * l_tcp = 00;
- opj_simple_mcc_decorrelation_data_t * l_mcc_record;
- OPJ_UINT32 i;
-
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_manager != 00);
- assert(p_stream != 00);
-
- l_tcp = &(p_j2k->m_cp.tcps[p_j2k->m_current_tile_number]);
-
- l_mco_size = 5 + l_tcp->m_nb_mcc_records;
- if (l_mco_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size) {
-
- OPJ_BYTE *new_header_tile_data = (OPJ_BYTE *) opj_realloc(
- p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_mco_size);
- if (! new_header_tile_data) {
- opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data);
- p_j2k->m_specific_param.m_encoder.m_header_tile_data = NULL;
- p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0;
- opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to write MCO marker\n");
- return OPJ_FALSE;
- }
- p_j2k->m_specific_param.m_encoder.m_header_tile_data = new_header_tile_data;
- p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_mco_size;
- }
- l_current_data = p_j2k->m_specific_param.m_encoder.m_header_tile_data;
-
-
- opj_write_bytes(l_current_data, J2K_MS_MCO, 2); /* MCO */
- l_current_data += 2;
-
- opj_write_bytes(l_current_data, l_mco_size - 2, 2); /* Lmco */
- l_current_data += 2;
-
- opj_write_bytes(l_current_data, l_tcp->m_nb_mcc_records,
- 1); /* Nmco : only one transform stage*/
- ++l_current_data;
-
- l_mcc_record = l_tcp->m_mcc_records;
- for (i = 0; i < l_tcp->m_nb_mcc_records; ++i) {
- opj_write_bytes(l_current_data, l_mcc_record->m_index,
- 1); /* Imco -> use the mcc indicated by 1*/
- ++l_current_data;
- ++l_mcc_record;
- }
-
- if (opj_stream_write_data(p_stream,
- p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_mco_size,
- p_manager) != l_mco_size) {
- return OPJ_FALSE;
- }
-
- return OPJ_TRUE;
-}
-
-/**
- * Reads a MCO marker (Multiple Component Transform Ordering)
- *
- * @param p_header_data the data contained in the MCO box.
- * @param p_j2k the jpeg2000 codec.
- * @param p_header_size the size of the data contained in the MCO marker.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_mco(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager
- )
-{
- OPJ_UINT32 l_tmp, i;
- OPJ_UINT32 l_nb_stages;
- opj_tcp_t * l_tcp;
- opj_tccp_t * l_tccp;
- opj_image_t * l_image;
-
- /* preconditions */
- assert(p_header_data != 00);
- assert(p_j2k != 00);
- assert(p_manager != 00);
-
- l_image = p_j2k->m_private_image;
- l_tcp = p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH ?
- &p_j2k->m_cp.tcps[p_j2k->m_current_tile_number] :
- p_j2k->m_specific_param.m_decoder.m_default_tcp;
-
- if (p_header_size < 1) {
- opj_event_msg(p_manager, EVT_ERROR, "Error reading MCO marker\n");
- return OPJ_FALSE;
- }
-
- opj_read_bytes(p_header_data, &l_nb_stages,
- 1); /* Nmco : only one transform stage*/
- ++p_header_data;
-
- if (l_nb_stages > 1) {
- opj_event_msg(p_manager, EVT_WARNING,
- "Cannot take in charge multiple transformation stages.\n");
- return OPJ_TRUE;
- }
-
- if (p_header_size != l_nb_stages + 1) {
- opj_event_msg(p_manager, EVT_WARNING, "Error reading MCO marker\n");
- return OPJ_FALSE;
- }
-
- l_tccp = l_tcp->tccps;
-
- for (i = 0; i < l_image->numcomps; ++i) {
- l_tccp->m_dc_level_shift = 0;
- ++l_tccp;
- }
-
- if (l_tcp->m_mct_decoding_matrix) {
- opj_free(l_tcp->m_mct_decoding_matrix);
- l_tcp->m_mct_decoding_matrix = 00;
- }
-
- for (i = 0; i < l_nb_stages; ++i) {
- opj_read_bytes(p_header_data, &l_tmp, 1);
- ++p_header_data;
-
- if (! opj_j2k_add_mct(l_tcp, p_j2k->m_private_image, l_tmp)) {
- return OPJ_FALSE;
- }
- }
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_add_mct(opj_tcp_t * p_tcp, opj_image_t * p_image,
- OPJ_UINT32 p_index)
-{
- OPJ_UINT32 i;
- opj_simple_mcc_decorrelation_data_t * l_mcc_record;
- opj_mct_data_t * l_deco_array, * l_offset_array;
- OPJ_UINT32 l_data_size, l_mct_size, l_offset_size;
- OPJ_UINT32 l_nb_elem;
- OPJ_UINT32 * l_offset_data, * l_current_offset_data;
- opj_tccp_t * l_tccp;
-
- /* preconditions */
- assert(p_tcp != 00);
-
- l_mcc_record = p_tcp->m_mcc_records;
-
- for (i = 0; i < p_tcp->m_nb_mcc_records; ++i) {
- if (l_mcc_record->m_index == p_index) {
- break;
- }
- }
-
- if (i == p_tcp->m_nb_mcc_records) {
- /** element discarded **/
- return OPJ_TRUE;
- }
-
- if (l_mcc_record->m_nb_comps != p_image->numcomps) {
- /** do not support number of comps != image */
- return OPJ_TRUE;
- }
-
- l_deco_array = l_mcc_record->m_decorrelation_array;
-
- if (l_deco_array) {
- l_data_size = MCT_ELEMENT_SIZE[l_deco_array->m_element_type] * p_image->numcomps
- * p_image->numcomps;
- if (l_deco_array->m_data_size != l_data_size) {
- return OPJ_FALSE;
- }
-
- l_nb_elem = p_image->numcomps * p_image->numcomps;
- l_mct_size = l_nb_elem * (OPJ_UINT32)sizeof(OPJ_FLOAT32);
- p_tcp->m_mct_decoding_matrix = (OPJ_FLOAT32*)opj_malloc(l_mct_size);
-
- if (! p_tcp->m_mct_decoding_matrix) {
- return OPJ_FALSE;
- }
-
- j2k_mct_read_functions_to_float[l_deco_array->m_element_type](
- l_deco_array->m_data, p_tcp->m_mct_decoding_matrix, l_nb_elem);
- }
-
- l_offset_array = l_mcc_record->m_offset_array;
-
- if (l_offset_array) {
- l_data_size = MCT_ELEMENT_SIZE[l_offset_array->m_element_type] *
- p_image->numcomps;
- if (l_offset_array->m_data_size != l_data_size) {
- return OPJ_FALSE;
- }
-
- l_nb_elem = p_image->numcomps;
- l_offset_size = l_nb_elem * (OPJ_UINT32)sizeof(OPJ_UINT32);
- l_offset_data = (OPJ_UINT32*)opj_malloc(l_offset_size);
-
- if (! l_offset_data) {
- return OPJ_FALSE;
- }
-
- j2k_mct_read_functions_to_int32[l_offset_array->m_element_type](
- l_offset_array->m_data, l_offset_data, l_nb_elem);
-
- l_tccp = p_tcp->tccps;
- l_current_offset_data = l_offset_data;
-
- for (i = 0; i < p_image->numcomps; ++i) {
- l_tccp->m_dc_level_shift = (OPJ_INT32) * (l_current_offset_data++);
- ++l_tccp;
- }
-
- opj_free(l_offset_data);
- }
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_write_cbd(opj_j2k_t *p_j2k,
- struct opj_stream_private *p_stream,
- struct opj_event_mgr * p_manager)
-{
- OPJ_UINT32 i;
- OPJ_UINT32 l_cbd_size;
- OPJ_BYTE * l_current_data = 00;
- opj_image_t *l_image = 00;
- opj_image_comp_t * l_comp = 00;
-
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_manager != 00);
- assert(p_stream != 00);
-
- l_image = p_j2k->m_private_image;
- l_cbd_size = 6 + p_j2k->m_private_image->numcomps;
-
- if (l_cbd_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size) {
- OPJ_BYTE *new_header_tile_data = (OPJ_BYTE *) opj_realloc(
- p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_cbd_size);
- if (! new_header_tile_data) {
- opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data);
- p_j2k->m_specific_param.m_encoder.m_header_tile_data = NULL;
- p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0;
- opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to write CBD marker\n");
- return OPJ_FALSE;
- }
- p_j2k->m_specific_param.m_encoder.m_header_tile_data = new_header_tile_data;
- p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_cbd_size;
- }
-
- l_current_data = p_j2k->m_specific_param.m_encoder.m_header_tile_data;
-
- opj_write_bytes(l_current_data, J2K_MS_CBD, 2); /* CBD */
- l_current_data += 2;
-
- opj_write_bytes(l_current_data, l_cbd_size - 2, 2); /* L_CBD */
- l_current_data += 2;
-
- opj_write_bytes(l_current_data, l_image->numcomps, 2); /* Ncbd */
- l_current_data += 2;
-
- l_comp = l_image->comps;
-
- for (i = 0; i < l_image->numcomps; ++i) {
- opj_write_bytes(l_current_data, (l_comp->sgnd << 7) | (l_comp->prec - 1),
- 1); /* Component bit depth */
- ++l_current_data;
-
- ++l_comp;
- }
-
- if (opj_stream_write_data(p_stream,
- p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_cbd_size,
- p_manager) != l_cbd_size) {
- return OPJ_FALSE;
- }
-
- return OPJ_TRUE;
-}
-
-/**
- * Reads a CBD marker (Component bit depth definition)
- * @param p_header_data the data contained in the CBD box.
- * @param p_j2k the jpeg2000 codec.
- * @param p_header_size the size of the data contained in the CBD marker.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_cbd(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager
- )
-{
- OPJ_UINT32 l_nb_comp, l_num_comp;
- OPJ_UINT32 l_comp_def;
- OPJ_UINT32 i;
- opj_image_comp_t * l_comp = 00;
-
- /* preconditions */
- assert(p_header_data != 00);
- assert(p_j2k != 00);
- assert(p_manager != 00);
-
- l_num_comp = p_j2k->m_private_image->numcomps;
-
- if (p_header_size != (p_j2k->m_private_image->numcomps + 2)) {
- opj_event_msg(p_manager, EVT_ERROR, "Crror reading CBD marker\n");
- return OPJ_FALSE;
- }
-
- opj_read_bytes(p_header_data, &l_nb_comp,
- 2); /* Ncbd */
- p_header_data += 2;
-
- if (l_nb_comp != l_num_comp) {
- opj_event_msg(p_manager, EVT_ERROR, "Crror reading CBD marker\n");
- return OPJ_FALSE;
- }
-
- l_comp = p_j2k->m_private_image->comps;
- for (i = 0; i < l_num_comp; ++i) {
- opj_read_bytes(p_header_data, &l_comp_def,
- 1); /* Component bit depth */
- ++p_header_data;
- l_comp->sgnd = (l_comp_def >> 7) & 1;
- l_comp->prec = (l_comp_def & 0x7f) + 1;
-
- if (l_comp->prec > 31) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Invalid values for comp = %d : prec=%u (should be between 1 and 38 according to the JPEG2000 norm. OpenJpeg only supports up to 31)\n",
- i, l_comp->prec);
- return OPJ_FALSE;
- }
- ++l_comp;
- }
-
- return OPJ_TRUE;
-}
-
-/**
- * Reads a CAP marker (extended capabilities definition). Empty implementation.
- * Found in HTJ2K files.
- *
- * @param p_header_data the data contained in the CAP box.
- * @param p_j2k the jpeg2000 codec.
- * @param p_header_size the size of the data contained in the CAP marker.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_cap(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager
- )
-{
- /* preconditions */
- assert(p_header_data != 00);
- assert(p_j2k != 00);
- assert(p_manager != 00);
-
- (void)p_j2k;
- (void)p_header_data;
- (void)p_header_size;
- (void)p_manager;
-
- return OPJ_TRUE;
-}
-
-/**
- * Reads a CPF marker (corresponding profile). Empty implementation. Found in HTJ2K files
- * @param p_header_data the data contained in the CPF box.
- * @param p_j2k the jpeg2000 codec.
- * @param p_header_size the size of the data contained in the CPF marker.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_read_cpf(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager
- )
-{
- /* preconditions */
- assert(p_header_data != 00);
- assert(p_j2k != 00);
- assert(p_manager != 00);
-
- (void)p_j2k;
- (void)p_header_data;
- (void)p_header_size;
- (void)p_manager;
-
- return OPJ_TRUE;
-}
-
-/* ----------------------------------------------------------------------- */
-/* J2K / JPT decoder interface */
-/* ----------------------------------------------------------------------- */
-
-void opj_j2k_setup_decoder(opj_j2k_t *j2k, opj_dparameters_t *parameters)
-{
- if (j2k && parameters) {
- j2k->m_cp.m_specific_param.m_dec.m_layer = parameters->cp_layer;
- j2k->m_cp.m_specific_param.m_dec.m_reduce = parameters->cp_reduce;
-
- j2k->dump_state = (parameters->flags & OPJ_DPARAMETERS_DUMP_FLAG);
-#ifdef USE_JPWL
- j2k->m_cp.correct = parameters->jpwl_correct;
- j2k->m_cp.exp_comps = parameters->jpwl_exp_comps;
- j2k->m_cp.max_tiles = parameters->jpwl_max_tiles;
-#endif /* USE_JPWL */
- }
-}
-
-void opj_j2k_decoder_set_strict_mode(opj_j2k_t *j2k, OPJ_BOOL strict)
-{
- if (j2k) {
- j2k->m_cp.strict = strict;
- if (strict) {
- j2k->m_specific_param.m_decoder.m_nb_tile_parts_correction_checked = 1;
- }
- }
-}
-
-OPJ_BOOL opj_j2k_set_threads(opj_j2k_t *j2k, OPJ_UINT32 num_threads)
-{
- /* Currently we pass the thread-pool to the tcd, so we cannot re-set it */
- /* afterwards */
- if (opj_has_thread_support() && j2k->m_tcd == NULL) {
- opj_thread_pool_destroy(j2k->m_tp);
- j2k->m_tp = NULL;
- if (num_threads <= (OPJ_UINT32)INT_MAX) {
- j2k->m_tp = opj_thread_pool_create((int)num_threads);
- }
- if (j2k->m_tp == NULL) {
- j2k->m_tp = opj_thread_pool_create(0);
- return OPJ_FALSE;
- }
- return OPJ_TRUE;
- }
- return OPJ_FALSE;
-}
-
-static int opj_j2k_get_default_thread_count(void)
-{
- const char* num_threads_str = getenv("OPJ_NUM_THREADS");
- int num_cpus;
- int num_threads;
-
- if (num_threads_str == NULL || !opj_has_thread_support()) {
- return 0;
- }
- num_cpus = opj_get_num_cpus();
- if (strcmp(num_threads_str, "ALL_CPUS") == 0) {
- return num_cpus;
- }
- if (num_cpus == 0) {
- num_cpus = 32;
- }
- num_threads = atoi(num_threads_str);
- if (num_threads < 0) {
- num_threads = 0;
- } else if (num_threads > 2 * num_cpus) {
- num_threads = 2 * num_cpus;
- }
- return num_threads;
-}
-
-/* ----------------------------------------------------------------------- */
-/* J2K encoder interface */
-/* ----------------------------------------------------------------------- */
-
-opj_j2k_t* opj_j2k_create_compress(void)
-{
- opj_j2k_t *l_j2k = (opj_j2k_t*) opj_calloc(1, sizeof(opj_j2k_t));
- if (!l_j2k) {
- return NULL;
- }
-
-
- l_j2k->m_is_decoder = 0;
- l_j2k->m_cp.m_is_decoder = 0;
-
- l_j2k->m_specific_param.m_encoder.m_header_tile_data = (OPJ_BYTE *) opj_malloc(
- OPJ_J2K_DEFAULT_HEADER_SIZE);
- if (! l_j2k->m_specific_param.m_encoder.m_header_tile_data) {
- opj_j2k_destroy(l_j2k);
- return NULL;
- }
-
- l_j2k->m_specific_param.m_encoder.m_header_tile_data_size =
- OPJ_J2K_DEFAULT_HEADER_SIZE;
-
- /* validation list creation*/
- l_j2k->m_validation_list = opj_procedure_list_create();
- if (! l_j2k->m_validation_list) {
- opj_j2k_destroy(l_j2k);
- return NULL;
- }
-
- /* execution list creation*/
- l_j2k->m_procedure_list = opj_procedure_list_create();
- if (! l_j2k->m_procedure_list) {
- opj_j2k_destroy(l_j2k);
- return NULL;
- }
-
- l_j2k->m_tp = opj_thread_pool_create(opj_j2k_get_default_thread_count());
- if (!l_j2k->m_tp) {
- l_j2k->m_tp = opj_thread_pool_create(0);
- }
- if (!l_j2k->m_tp) {
- opj_j2k_destroy(l_j2k);
- return NULL;
- }
-
- return l_j2k;
-}
-
-static int opj_j2k_initialise_4K_poc(opj_poc_t *POC, int numres)
-{
- POC[0].tile = 1;
- POC[0].resno0 = 0;
- POC[0].compno0 = 0;
- POC[0].layno1 = 1;
- POC[0].resno1 = (OPJ_UINT32)(numres - 1);
- POC[0].compno1 = 3;
- POC[0].prg1 = OPJ_CPRL;
- POC[1].tile = 1;
- POC[1].resno0 = (OPJ_UINT32)(numres - 1);
- POC[1].compno0 = 0;
- POC[1].layno1 = 1;
- POC[1].resno1 = (OPJ_UINT32)numres;
- POC[1].compno1 = 3;
- POC[1].prg1 = OPJ_CPRL;
- return 2;
-}
-
-static void opj_j2k_set_cinema_parameters(opj_cparameters_t *parameters,
- opj_image_t *image, opj_event_mgr_t *p_manager)
-{
- /* Configure cinema parameters */
- int i;
-
- /* No tiling */
- parameters->tile_size_on = OPJ_FALSE;
- parameters->cp_tdx = 1;
- parameters->cp_tdy = 1;
-
- /* One tile part for each component */
- parameters->tp_flag = 'C';
- parameters->tp_on = 1;
-
- /* Tile and Image shall be at (0,0) */
- parameters->cp_tx0 = 0;
- parameters->cp_ty0 = 0;
- parameters->image_offset_x0 = 0;
- parameters->image_offset_y0 = 0;
-
- /* Codeblock size= 32*32 */
- parameters->cblockw_init = 32;
- parameters->cblockh_init = 32;
-
- /* Codeblock style: no mode switch enabled */
- parameters->mode = 0;
-
- /* No ROI */
- parameters->roi_compno = -1;
-
- /* No subsampling */
- parameters->subsampling_dx = 1;
- parameters->subsampling_dy = 1;
-
- /* 9-7 transform */
- parameters->irreversible = 1;
-
- /* Number of layers */
- if (parameters->tcp_numlayers > 1) {
- opj_event_msg(p_manager, EVT_WARNING,
- "JPEG 2000 Profile-3 and 4 (2k/4k dc profile) requires:\n"
- "1 single quality layer"
- "-> Number of layers forced to 1 (rather than %d)\n"
- "-> Rate of the last layer (%3.1f) will be used",
- parameters->tcp_numlayers,
- parameters->tcp_rates[parameters->tcp_numlayers - 1]);
- parameters->tcp_rates[0] = parameters->tcp_rates[parameters->tcp_numlayers - 1];
- parameters->tcp_numlayers = 1;
- }
-
- /* Resolution levels */
- switch (parameters->rsiz) {
- case OPJ_PROFILE_CINEMA_2K:
- if (parameters->numresolution > 6) {
- opj_event_msg(p_manager, EVT_WARNING,
- "JPEG 2000 Profile-3 (2k dc profile) requires:\n"
- "Number of decomposition levels <= 5\n"
- "-> Number of decomposition levels forced to 5 (rather than %d)\n",
- parameters->numresolution + 1);
- parameters->numresolution = 6;
- }
- break;
- case OPJ_PROFILE_CINEMA_4K:
- if (parameters->numresolution < 2) {
- opj_event_msg(p_manager, EVT_WARNING,
- "JPEG 2000 Profile-4 (4k dc profile) requires:\n"
- "Number of decomposition levels >= 1 && <= 6\n"
- "-> Number of decomposition levels forced to 1 (rather than %d)\n",
- parameters->numresolution + 1);
- parameters->numresolution = 1;
- } else if (parameters->numresolution > 7) {
- opj_event_msg(p_manager, EVT_WARNING,
- "JPEG 2000 Profile-4 (4k dc profile) requires:\n"
- "Number of decomposition levels >= 1 && <= 6\n"
- "-> Number of decomposition levels forced to 6 (rather than %d)\n",
- parameters->numresolution + 1);
- parameters->numresolution = 7;
- }
- break;
- default :
- break;
- }
-
- /* Precincts */
- parameters->csty |= J2K_CP_CSTY_PRT;
- if (parameters->numresolution == 1) {
- parameters->res_spec = 1;
- parameters->prcw_init[0] = 128;
- parameters->prch_init[0] = 128;
- } else {
- parameters->res_spec = parameters->numresolution - 1;
- for (i = 0; i < parameters->res_spec; i++) {
- parameters->prcw_init[i] = 256;
- parameters->prch_init[i] = 256;
- }
- }
-
- /* The progression order shall be CPRL */
- parameters->prog_order = OPJ_CPRL;
-
- /* Progression order changes for 4K, disallowed for 2K */
- if (parameters->rsiz == OPJ_PROFILE_CINEMA_4K) {
- parameters->numpocs = (OPJ_UINT32)opj_j2k_initialise_4K_poc(parameters->POC,
- parameters->numresolution);
- } else {
- parameters->numpocs = 0;
- }
-
- /* Limited bit-rate */
- parameters->cp_disto_alloc = 1;
- if (parameters->max_cs_size <= 0) {
- /* No rate has been introduced, 24 fps is assumed */
- parameters->max_cs_size = OPJ_CINEMA_24_CS;
- opj_event_msg(p_manager, EVT_WARNING,
- "JPEG 2000 Profile-3 and 4 (2k/4k dc profile) requires:\n"
- "Maximum 1302083 compressed bytes @ 24fps\n"
- "As no rate has been given, this limit will be used.\n");
- } else if (parameters->max_cs_size > OPJ_CINEMA_24_CS) {
- opj_event_msg(p_manager, EVT_WARNING,
- "JPEG 2000 Profile-3 and 4 (2k/4k dc profile) requires:\n"
- "Maximum 1302083 compressed bytes @ 24fps\n"
- "-> Specified rate exceeds this limit. Rate will be forced to 1302083 bytes.\n");
- parameters->max_cs_size = OPJ_CINEMA_24_CS;
- }
-
- if (parameters->max_comp_size <= 0) {
- /* No rate has been introduced, 24 fps is assumed */
- parameters->max_comp_size = OPJ_CINEMA_24_COMP;
- opj_event_msg(p_manager, EVT_WARNING,
- "JPEG 2000 Profile-3 and 4 (2k/4k dc profile) requires:\n"
- "Maximum 1041666 compressed bytes @ 24fps\n"
- "As no rate has been given, this limit will be used.\n");
- } else if (parameters->max_comp_size > OPJ_CINEMA_24_COMP) {
- opj_event_msg(p_manager, EVT_WARNING,
- "JPEG 2000 Profile-3 and 4 (2k/4k dc profile) requires:\n"
- "Maximum 1041666 compressed bytes @ 24fps\n"
- "-> Specified rate exceeds this limit. Rate will be forced to 1041666 bytes.\n");
- parameters->max_comp_size = OPJ_CINEMA_24_COMP;
- }
-
- parameters->tcp_rates[0] = (OPJ_FLOAT32)(image->numcomps * image->comps[0].w *
- image->comps[0].h * image->comps[0].prec) /
- (OPJ_FLOAT32)(((OPJ_UINT32)parameters->max_cs_size) * 8 * image->comps[0].dx *
- image->comps[0].dy);
-
-}
-
-static OPJ_BOOL opj_j2k_is_cinema_compliant(opj_image_t *image, OPJ_UINT16 rsiz,
- opj_event_mgr_t *p_manager)
-{
- OPJ_UINT32 i;
-
- /* Number of components */
- if (image->numcomps != 3) {
- opj_event_msg(p_manager, EVT_WARNING,
- "JPEG 2000 Profile-3 (2k dc profile) requires:\n"
- "3 components"
- "-> Number of components of input image (%d) is not compliant\n"
- "-> Non-profile-3 codestream will be generated\n",
- image->numcomps);
- return OPJ_FALSE;
- }
-
- /* Bitdepth */
- for (i = 0; i < image->numcomps; i++) {
- if ((image->comps[i].prec != 12) | (image->comps[i].sgnd)) {
- char signed_str[] = "signed";
- char unsigned_str[] = "unsigned";
- char *tmp_str = image->comps[i].sgnd ? signed_str : unsigned_str;
- opj_event_msg(p_manager, EVT_WARNING,
- "JPEG 2000 Profile-3 (2k dc profile) requires:\n"
- "Precision of each component shall be 12 bits unsigned"
- "-> At least component %d of input image (%d bits, %s) is not compliant\n"
- "-> Non-profile-3 codestream will be generated\n",
- i, image->comps[i].prec, tmp_str);
- return OPJ_FALSE;
- }
- }
-
- /* Image size */
- switch (rsiz) {
- case OPJ_PROFILE_CINEMA_2K:
- if (((image->comps[0].w > 2048) | (image->comps[0].h > 1080))) {
- opj_event_msg(p_manager, EVT_WARNING,
- "JPEG 2000 Profile-3 (2k dc profile) requires:\n"
- "width <= 2048 and height <= 1080\n"
- "-> Input image size %d x %d is not compliant\n"
- "-> Non-profile-3 codestream will be generated\n",
- image->comps[0].w, image->comps[0].h);
- return OPJ_FALSE;
- }
- break;
- case OPJ_PROFILE_CINEMA_4K:
- if (((image->comps[0].w > 4096) | (image->comps[0].h > 2160))) {
- opj_event_msg(p_manager, EVT_WARNING,
- "JPEG 2000 Profile-4 (4k dc profile) requires:\n"
- "width <= 4096 and height <= 2160\n"
- "-> Image size %d x %d is not compliant\n"
- "-> Non-profile-4 codestream will be generated\n",
- image->comps[0].w, image->comps[0].h);
- return OPJ_FALSE;
- }
- break;
- default :
- break;
- }
-
- return OPJ_TRUE;
-}
-
-static int opj_j2k_get_imf_max_NL(opj_cparameters_t *parameters,
- opj_image_t *image)
-{
- /* Decomposition levels */
- const OPJ_UINT16 rsiz = parameters->rsiz;
- const OPJ_UINT16 profile = OPJ_GET_IMF_PROFILE(rsiz);
- const OPJ_UINT32 XTsiz = parameters->tile_size_on ? (OPJ_UINT32)
- parameters->cp_tdx : image->x1;
- switch (profile) {
- case OPJ_PROFILE_IMF_2K:
- return 5;
- case OPJ_PROFILE_IMF_4K:
- return 6;
- case OPJ_PROFILE_IMF_8K:
- return 7;
- case OPJ_PROFILE_IMF_2K_R: {
- if (XTsiz >= 2048) {
- return 5;
- } else if (XTsiz >= 1024) {
- return 4;
- }
- break;
- }
- case OPJ_PROFILE_IMF_4K_R: {
- if (XTsiz >= 4096) {
- return 6;
- } else if (XTsiz >= 2048) {
- return 5;
- } else if (XTsiz >= 1024) {
- return 4;
- }
- break;
- }
- case OPJ_PROFILE_IMF_8K_R: {
- if (XTsiz >= 8192) {
- return 7;
- } else if (XTsiz >= 4096) {
- return 6;
- } else if (XTsiz >= 2048) {
- return 5;
- } else if (XTsiz >= 1024) {
- return 4;
- }
- break;
- }
- default:
- break;
- }
- return -1;
-}
-
-static void opj_j2k_set_imf_parameters(opj_cparameters_t *parameters,
- opj_image_t *image, opj_event_mgr_t *p_manager)
-{
- const OPJ_UINT16 rsiz = parameters->rsiz;
- const OPJ_UINT16 profile = OPJ_GET_IMF_PROFILE(rsiz);
-
- OPJ_UNUSED(p_manager);
-
- /* Override defaults set by opj_set_default_encoder_parameters */
- if (parameters->cblockw_init == OPJ_COMP_PARAM_DEFAULT_CBLOCKW &&
- parameters->cblockh_init == OPJ_COMP_PARAM_DEFAULT_CBLOCKH) {
- parameters->cblockw_init = 32;
- parameters->cblockh_init = 32;
- }
-
- /* One tile part for each component */
- parameters->tp_flag = 'C';
- parameters->tp_on = 1;
-
- if (parameters->prog_order == OPJ_COMP_PARAM_DEFAULT_PROG_ORDER) {
- parameters->prog_order = OPJ_CPRL;
- }
-
- if (profile == OPJ_PROFILE_IMF_2K ||
- profile == OPJ_PROFILE_IMF_4K ||
- profile == OPJ_PROFILE_IMF_8K) {
- /* 9-7 transform */
- parameters->irreversible = 1;
- }
-
- /* Adjust the number of resolutions if set to its defaults */
- if (parameters->numresolution == OPJ_COMP_PARAM_DEFAULT_NUMRESOLUTION &&
- image->x0 == 0 &&
- image->y0 == 0) {
- const int max_NL = opj_j2k_get_imf_max_NL(parameters, image);
- if (max_NL >= 0 && parameters->numresolution > max_NL) {
- parameters->numresolution = max_NL + 1;
- }
-
- /* Note: below is generic logic */
- if (!parameters->tile_size_on) {
- while (parameters->numresolution > 0) {
- if (image->x1 < (1U << ((OPJ_UINT32)parameters->numresolution - 1U))) {
- parameters->numresolution --;
- continue;
- }
- if (image->y1 < (1U << ((OPJ_UINT32)parameters->numresolution - 1U))) {
- parameters->numresolution --;
- continue;
- }
- break;
- }
- }
- }
-
- /* Set defaults precincts */
- if (parameters->csty == 0) {
- parameters->csty |= J2K_CP_CSTY_PRT;
- if (parameters->numresolution == 1) {
- parameters->res_spec = 1;
- parameters->prcw_init[0] = 128;
- parameters->prch_init[0] = 128;
- } else {
- int i;
- parameters->res_spec = parameters->numresolution - 1;
- for (i = 0; i < parameters->res_spec; i++) {
- parameters->prcw_init[i] = 256;
- parameters->prch_init[i] = 256;
- }
- }
- }
-}
-
-/* Table A.53 from JPEG2000 standard */
-static const OPJ_UINT16 tabMaxSubLevelFromMainLevel[] = {
- 15, /* unspecified */
- 1,
- 1,
- 1,
- 2,
- 3,
- 4,
- 5,
- 6,
- 7,
- 8,
- 9
-};
-
-static OPJ_BOOL opj_j2k_is_imf_compliant(opj_cparameters_t *parameters,
- opj_image_t *image,
- opj_event_mgr_t *p_manager)
-{
- OPJ_UINT32 i;
- const OPJ_UINT16 rsiz = parameters->rsiz;
- const OPJ_UINT16 profile = OPJ_GET_IMF_PROFILE(rsiz);
- const OPJ_UINT16 mainlevel = OPJ_GET_IMF_MAINLEVEL(rsiz);
- const OPJ_UINT16 sublevel = OPJ_GET_IMF_SUBLEVEL(rsiz);
- const int NL = parameters->numresolution - 1;
- const OPJ_UINT32 XTsiz = parameters->tile_size_on ? (OPJ_UINT32)
- parameters->cp_tdx : image->x1;
- OPJ_BOOL ret = OPJ_TRUE;
-
- /* Validate mainlevel */
- if (mainlevel > OPJ_IMF_MAINLEVEL_MAX) {
- opj_event_msg(p_manager, EVT_WARNING,
- "IMF profile require mainlevel <= 11.\n"
- "-> %d is thus not compliant\n"
- "-> Non-IMF codestream will be generated\n",
- mainlevel);
- ret = OPJ_FALSE;
- } else {
- /* Validate sublevel */
- assert(sizeof(tabMaxSubLevelFromMainLevel) ==
- (OPJ_IMF_MAINLEVEL_MAX + 1) * sizeof(tabMaxSubLevelFromMainLevel[0]));
- if (sublevel > tabMaxSubLevelFromMainLevel[mainlevel]) {
- opj_event_msg(p_manager, EVT_WARNING,
- "IMF profile require sublevel <= %d for mainlevel = %d.\n"
- "-> %d is thus not compliant\n"
- "-> Non-IMF codestream will be generated\n",
- tabMaxSubLevelFromMainLevel[mainlevel],
- mainlevel,
- sublevel);
- ret = OPJ_FALSE;
- }
- }
-
- /* Number of components */
- if (image->numcomps > 3) {
- opj_event_msg(p_manager, EVT_WARNING,
- "IMF profiles require at most 3 components.\n"
- "-> Number of components of input image (%d) is not compliant\n"
- "-> Non-IMF codestream will be generated\n",
- image->numcomps);
- ret = OPJ_FALSE;
- }
-
- if (image->x0 != 0 || image->y0 != 0) {
- opj_event_msg(p_manager, EVT_WARNING,
- "IMF profiles require image origin to be at 0,0.\n"
- "-> %d,%d is not compliant\n"
- "-> Non-IMF codestream will be generated\n",
- image->x0, image->y0 != 0);
- ret = OPJ_FALSE;
- }
-
- if (parameters->cp_tx0 != 0 || parameters->cp_ty0 != 0) {
- opj_event_msg(p_manager, EVT_WARNING,
- "IMF profiles require tile origin to be at 0,0.\n"
- "-> %d,%d is not compliant\n"
- "-> Non-IMF codestream will be generated\n",
- parameters->cp_tx0, parameters->cp_ty0);
- ret = OPJ_FALSE;
- }
-
- if (parameters->tile_size_on) {
- if (profile == OPJ_PROFILE_IMF_2K ||
- profile == OPJ_PROFILE_IMF_4K ||
- profile == OPJ_PROFILE_IMF_8K) {
- if ((OPJ_UINT32)parameters->cp_tdx < image->x1 ||
- (OPJ_UINT32)parameters->cp_tdy < image->y1) {
- opj_event_msg(p_manager, EVT_WARNING,
- "IMF 2K/4K/8K single tile profiles require tile to be greater or equal to image size.\n"
- "-> %d,%d is lesser than %d,%d\n"
- "-> Non-IMF codestream will be generated\n",
- parameters->cp_tdx,
- parameters->cp_tdy,
- image->x1,
- image->y1);
- ret = OPJ_FALSE;
- }
- } else {
- if ((OPJ_UINT32)parameters->cp_tdx >= image->x1 &&
- (OPJ_UINT32)parameters->cp_tdy >= image->y1) {
- /* ok */
- } else if (parameters->cp_tdx == 1024 &&
- parameters->cp_tdy == 1024) {
- /* ok */
- } else if (parameters->cp_tdx == 2048 &&
- parameters->cp_tdy == 2048 &&
- (profile == OPJ_PROFILE_IMF_4K ||
- profile == OPJ_PROFILE_IMF_8K)) {
- /* ok */
- } else if (parameters->cp_tdx == 4096 &&
- parameters->cp_tdy == 4096 &&
- profile == OPJ_PROFILE_IMF_8K) {
- /* ok */
- } else {
- opj_event_msg(p_manager, EVT_WARNING,
- "IMF 2K_R/4K_R/8K_R single/multiple tile profiles "
- "require tile to be greater or equal to image size,\n"
- "or to be (1024,1024), or (2048,2048) for 4K_R/8K_R "
- "or (4096,4096) for 8K_R.\n"
- "-> %d,%d is non conformant\n"
- "-> Non-IMF codestream will be generated\n",
- parameters->cp_tdx,
- parameters->cp_tdy);
- ret = OPJ_FALSE;
- }
- }
- }
-
- /* Bitdepth */
- for (i = 0; i < image->numcomps; i++) {
- if (!(image->comps[i].prec >= 8 && image->comps[i].prec <= 16) ||
- (image->comps[i].sgnd)) {
- char signed_str[] = "signed";
- char unsigned_str[] = "unsigned";
- char *tmp_str = image->comps[i].sgnd ? signed_str : unsigned_str;
- opj_event_msg(p_manager, EVT_WARNING,
- "IMF profiles require precision of each component to b in [8-16] bits unsigned"
- "-> At least component %d of input image (%d bits, %s) is not compliant\n"
- "-> Non-IMF codestream will be generated\n",
- i, image->comps[i].prec, tmp_str);
- ret = OPJ_FALSE;
- }
- }
-
- /* Sub-sampling */
- for (i = 0; i < image->numcomps; i++) {
- if (i == 0 && image->comps[i].dx != 1) {
- opj_event_msg(p_manager, EVT_WARNING,
- "IMF profiles require XRSiz1 == 1. Here it is set to %d.\n"
- "-> Non-IMF codestream will be generated\n",
- image->comps[i].dx);
- ret = OPJ_FALSE;
- }
- if (i == 1 && image->comps[i].dx != 1 && image->comps[i].dx != 2) {
- opj_event_msg(p_manager, EVT_WARNING,
- "IMF profiles require XRSiz2 == 1 or 2. Here it is set to %d.\n"
- "-> Non-IMF codestream will be generated\n",
- image->comps[i].dx);
- ret = OPJ_FALSE;
- }
- if (i > 1 && image->comps[i].dx != image->comps[i - 1].dx) {
- opj_event_msg(p_manager, EVT_WARNING,
- "IMF profiles require XRSiz%d to be the same as XRSiz2. "
- "Here it is set to %d instead of %d.\n"
- "-> Non-IMF codestream will be generated\n",
- i + 1, image->comps[i].dx, image->comps[i - 1].dx);
- ret = OPJ_FALSE;
- }
- if (image->comps[i].dy != 1) {
- opj_event_msg(p_manager, EVT_WARNING,
- "IMF profiles require YRsiz == 1. "
- "Here it is set to %d for component %d.\n"
- "-> Non-IMF codestream will be generated\n",
- image->comps[i].dy, i);
- ret = OPJ_FALSE;
- }
- }
-
- /* Image size */
- switch (profile) {
- case OPJ_PROFILE_IMF_2K:
- case OPJ_PROFILE_IMF_2K_R:
- if (((image->comps[0].w > 2048) | (image->comps[0].h > 1556))) {
- opj_event_msg(p_manager, EVT_WARNING,
- "IMF 2K/2K_R profile require:\n"
- "width <= 2048 and height <= 1556\n"
- "-> Input image size %d x %d is not compliant\n"
- "-> Non-IMF codestream will be generated\n",
- image->comps[0].w, image->comps[0].h);
- ret = OPJ_FALSE;
- }
- break;
- case OPJ_PROFILE_IMF_4K:
- case OPJ_PROFILE_IMF_4K_R:
- if (((image->comps[0].w > 4096) | (image->comps[0].h > 3112))) {
- opj_event_msg(p_manager, EVT_WARNING,
- "IMF 4K/4K_R profile require:\n"
- "width <= 4096 and height <= 3112\n"
- "-> Input image size %d x %d is not compliant\n"
- "-> Non-IMF codestream will be generated\n",
- image->comps[0].w, image->comps[0].h);
- ret = OPJ_FALSE;
- }
- break;
- case OPJ_PROFILE_IMF_8K:
- case OPJ_PROFILE_IMF_8K_R:
- if (((image->comps[0].w > 8192) | (image->comps[0].h > 6224))) {
- opj_event_msg(p_manager, EVT_WARNING,
- "IMF 8K/8K_R profile require:\n"
- "width <= 8192 and height <= 6224\n"
- "-> Input image size %d x %d is not compliant\n"
- "-> Non-IMF codestream will be generated\n",
- image->comps[0].w, image->comps[0].h);
- ret = OPJ_FALSE;
- }
- break;
- default :
- assert(0);
- return OPJ_FALSE;
- }
-
- if (parameters->roi_compno != -1) {
- opj_event_msg(p_manager, EVT_WARNING,
- "IMF profile forbid RGN / region of interest marker.\n"
- "-> Compression parameters specify a ROI\n"
- "-> Non-IMF codestream will be generated\n");
- ret = OPJ_FALSE;
- }
-
- if (parameters->cblockw_init != 32 || parameters->cblockh_init != 32) {
- opj_event_msg(p_manager, EVT_WARNING,
- "IMF profile require code block size to be 32x32.\n"
- "-> Compression parameters set it to %dx%d.\n"
- "-> Non-IMF codestream will be generated\n",
- parameters->cblockw_init,
- parameters->cblockh_init);
- ret = OPJ_FALSE;
- }
-
- if (parameters->prog_order != OPJ_CPRL) {
- opj_event_msg(p_manager, EVT_WARNING,
- "IMF profile require progression order to be CPRL.\n"
- "-> Compression parameters set it to %d.\n"
- "-> Non-IMF codestream will be generated\n",
- parameters->prog_order);
- ret = OPJ_FALSE;
- }
-
- if (parameters->numpocs != 0) {
- opj_event_msg(p_manager, EVT_WARNING,
- "IMF profile forbid POC markers.\n"
- "-> Compression parameters set %d POC.\n"
- "-> Non-IMF codestream will be generated\n",
- parameters->numpocs);
- ret = OPJ_FALSE;
- }
-
- /* Codeblock style: no mode switch enabled */
- if (parameters->mode != 0) {
- opj_event_msg(p_manager, EVT_WARNING,
- "IMF profile forbid mode switch in code block style.\n"
- "-> Compression parameters set code block style to %d.\n"
- "-> Non-IMF codestream will be generated\n",
- parameters->mode);
- ret = OPJ_FALSE;
- }
-
- if (profile == OPJ_PROFILE_IMF_2K ||
- profile == OPJ_PROFILE_IMF_4K ||
- profile == OPJ_PROFILE_IMF_8K) {
- /* Expect 9-7 transform */
- if (parameters->irreversible != 1) {
- opj_event_msg(p_manager, EVT_WARNING,
- "IMF 2K/4K/8K profiles require 9-7 Irreversible Transform.\n"
- "-> Compression parameters set it to reversible.\n"
- "-> Non-IMF codestream will be generated\n");
- ret = OPJ_FALSE;
- }
- } else {
- /* Expect 5-3 transform */
- if (parameters->irreversible != 0) {
- opj_event_msg(p_manager, EVT_WARNING,
- "IMF 2K/4K/8K profiles require 5-3 reversible Transform.\n"
- "-> Compression parameters set it to irreversible.\n"
- "-> Non-IMF codestream will be generated\n");
- ret = OPJ_FALSE;
- }
- }
-
- /* Number of layers */
- if (parameters->tcp_numlayers != 1) {
- opj_event_msg(p_manager, EVT_WARNING,
- "IMF 2K/4K/8K profiles require 1 single quality layer.\n"
- "-> Number of layers is %d.\n"
- "-> Non-IMF codestream will be generated\n",
- parameters->tcp_numlayers);
- ret = OPJ_FALSE;
- }
-
- /* Decomposition levels */
- switch (profile) {
- case OPJ_PROFILE_IMF_2K:
- if (!(NL >= 1 && NL <= 5)) {
- opj_event_msg(p_manager, EVT_WARNING,
- "IMF 2K profile requires 1 <= NL <= 5:\n"
- "-> Number of decomposition levels is %d.\n"
- "-> Non-IMF codestream will be generated\n",
- NL);
- ret = OPJ_FALSE;
- }
- break;
- case OPJ_PROFILE_IMF_4K:
- if (!(NL >= 1 && NL <= 6)) {
- opj_event_msg(p_manager, EVT_WARNING,
- "IMF 4K profile requires 1 <= NL <= 6:\n"
- "-> Number of decomposition levels is %d.\n"
- "-> Non-IMF codestream will be generated\n",
- NL);
- ret = OPJ_FALSE;
- }
- break;
- case OPJ_PROFILE_IMF_8K:
- if (!(NL >= 1 && NL <= 7)) {
- opj_event_msg(p_manager, EVT_WARNING,
- "IMF 8K profile requires 1 <= NL <= 7:\n"
- "-> Number of decomposition levels is %d.\n"
- "-> Non-IMF codestream will be generated\n",
- NL);
- ret = OPJ_FALSE;
- }
- break;
- case OPJ_PROFILE_IMF_2K_R: {
- if (XTsiz >= 2048) {
- if (!(NL >= 1 && NL <= 5)) {
- opj_event_msg(p_manager, EVT_WARNING,
- "IMF 2K_R profile requires 1 <= NL <= 5 for XTsiz >= 2048:\n"
- "-> Number of decomposition levels is %d.\n"
- "-> Non-IMF codestream will be generated\n",
- NL);
- ret = OPJ_FALSE;
- }
- } else if (XTsiz >= 1024) {
- if (!(NL >= 1 && NL <= 4)) {
- opj_event_msg(p_manager, EVT_WARNING,
- "IMF 2K_R profile requires 1 <= NL <= 4 for XTsiz in [1024,2048[:\n"
- "-> Number of decomposition levels is %d.\n"
- "-> Non-IMF codestream will be generated\n",
- NL);
- ret = OPJ_FALSE;
- }
- }
- break;
- }
- case OPJ_PROFILE_IMF_4K_R: {
- if (XTsiz >= 4096) {
- if (!(NL >= 1 && NL <= 6)) {
- opj_event_msg(p_manager, EVT_WARNING,
- "IMF 4K_R profile requires 1 <= NL <= 6 for XTsiz >= 4096:\n"
- "-> Number of decomposition levels is %d.\n"
- "-> Non-IMF codestream will be generated\n",
- NL);
- ret = OPJ_FALSE;
- }
- } else if (XTsiz >= 2048) {
- if (!(NL >= 1 && NL <= 5)) {
- opj_event_msg(p_manager, EVT_WARNING,
- "IMF 4K_R profile requires 1 <= NL <= 5 for XTsiz in [2048,4096[:\n"
- "-> Number of decomposition levels is %d.\n"
- "-> Non-IMF codestream will be generated\n",
- NL);
- ret = OPJ_FALSE;
- }
- } else if (XTsiz >= 1024) {
- if (!(NL >= 1 && NL <= 4)) {
- opj_event_msg(p_manager, EVT_WARNING,
- "IMF 4K_R profile requires 1 <= NL <= 4 for XTsiz in [1024,2048[:\n"
- "-> Number of decomposition levels is %d.\n"
- "-> Non-IMF codestream will be generated\n",
- NL);
- ret = OPJ_FALSE;
- }
- }
- break;
- }
- case OPJ_PROFILE_IMF_8K_R: {
- if (XTsiz >= 8192) {
- if (!(NL >= 1 && NL <= 7)) {
- opj_event_msg(p_manager, EVT_WARNING,
- "IMF 4K_R profile requires 1 <= NL <= 7 for XTsiz >= 8192:\n"
- "-> Number of decomposition levels is %d.\n"
- "-> Non-IMF codestream will be generated\n",
- NL);
- ret = OPJ_FALSE;
- }
- } else if (XTsiz >= 4096) {
- if (!(NL >= 1 && NL <= 6)) {
- opj_event_msg(p_manager, EVT_WARNING,
- "IMF 4K_R profile requires 1 <= NL <= 6 for XTsiz in [4096,8192[:\n"
- "-> Number of decomposition levels is %d.\n"
- "-> Non-IMF codestream will be generated\n",
- NL);
- ret = OPJ_FALSE;
- }
- } else if (XTsiz >= 2048) {
- if (!(NL >= 1 && NL <= 5)) {
- opj_event_msg(p_manager, EVT_WARNING,
- "IMF 4K_R profile requires 1 <= NL <= 5 for XTsiz in [2048,4096[:\n"
- "-> Number of decomposition levels is %d.\n"
- "-> Non-IMF codestream will be generated\n",
- NL);
- ret = OPJ_FALSE;
- }
- } else if (XTsiz >= 1024) {
- if (!(NL >= 1 && NL <= 4)) {
- opj_event_msg(p_manager, EVT_WARNING,
- "IMF 4K_R profile requires 1 <= NL <= 4 for XTsiz in [1024,2048[:\n"
- "-> Number of decomposition levels is %d.\n"
- "-> Non-IMF codestream will be generated\n",
- NL);
- ret = OPJ_FALSE;
- }
- }
- break;
- }
- default:
- break;
- }
-
- if (parameters->numresolution == 1) {
- if (parameters->res_spec != 1 ||
- parameters->prcw_init[0] != 128 ||
- parameters->prch_init[0] != 128) {
- opj_event_msg(p_manager, EVT_WARNING,
- "IMF profiles require PPx = PPy = 7 for NLLL band, else 8.\n"
- "-> Supplied values are different from that.\n"
- "-> Non-IMF codestream will be generated\n");
- ret = OPJ_FALSE;
- }
- } else {
- int i;
- for (i = 0; i < parameters->res_spec; i++) {
- if (parameters->prcw_init[i] != 256 ||
- parameters->prch_init[i] != 256) {
- opj_event_msg(p_manager, EVT_WARNING,
- "IMF profiles require PPx = PPy = 7 for NLLL band, else 8.\n"
- "-> Supplied values are different from that.\n"
- "-> Non-IMF codestream will be generated\n");
- ret = OPJ_FALSE;
- }
- }
- }
-
- return ret;
-}
-
-
-OPJ_BOOL opj_j2k_setup_encoder(opj_j2k_t *p_j2k,
- opj_cparameters_t *parameters,
- opj_image_t *image,
- opj_event_mgr_t * p_manager)
-{
- OPJ_UINT32 i, j, tileno, numpocs_tile;
- opj_cp_t *cp = 00;
- OPJ_UINT32 cblkw, cblkh;
-
- if (!p_j2k || !parameters || ! image) {
- return OPJ_FALSE;
- }
-
- if ((parameters->numresolution <= 0) ||
- (parameters->numresolution > OPJ_J2K_MAXRLVLS)) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Invalid number of resolutions : %d not in range [1,%d]\n",
- parameters->numresolution, OPJ_J2K_MAXRLVLS);
- return OPJ_FALSE;
- }
-
- if (parameters->cblockw_init < 4 || parameters->cblockw_init > 1024) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Invalid value for cblockw_init: %d not a power of 2 in range [4,1024]\n",
- parameters->cblockw_init);
- return OPJ_FALSE;
- }
- if (parameters->cblockh_init < 4 || parameters->cblockh_init > 1024) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Invalid value for cblockh_init: %d not a power of 2 not in range [4,1024]\n",
- parameters->cblockh_init);
- return OPJ_FALSE;
- }
- if (parameters->cblockw_init * parameters->cblockh_init > 4096) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Invalid value for cblockw_init * cblockh_init: should be <= 4096\n");
- return OPJ_FALSE;
- }
- cblkw = (OPJ_UINT32)opj_int_floorlog2(parameters->cblockw_init);
- cblkh = (OPJ_UINT32)opj_int_floorlog2(parameters->cblockh_init);
- if (parameters->cblockw_init != (1 << cblkw)) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Invalid value for cblockw_init: %d not a power of 2 in range [4,1024]\n",
- parameters->cblockw_init);
- return OPJ_FALSE;
- }
- if (parameters->cblockh_init != (1 << cblkh)) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Invalid value for cblockw_init: %d not a power of 2 in range [4,1024]\n",
- parameters->cblockh_init);
- return OPJ_FALSE;
- }
-
- if (parameters->cp_fixed_alloc) {
- if (parameters->cp_matrice == NULL) {
- opj_event_msg(p_manager, EVT_ERROR,
- "cp_fixed_alloc set, but cp_matrice missing\n");
- return OPJ_FALSE;
- }
-
- if (parameters->tcp_numlayers > J2K_TCD_MATRIX_MAX_LAYER_COUNT) {
- opj_event_msg(p_manager, EVT_ERROR,
- "tcp_numlayers when cp_fixed_alloc set should not exceed %d\n",
- J2K_TCD_MATRIX_MAX_LAYER_COUNT);
- return OPJ_FALSE;
- }
- if (parameters->numresolution > J2K_TCD_MATRIX_MAX_RESOLUTION_COUNT) {
- opj_event_msg(p_manager, EVT_ERROR,
- "numresolution when cp_fixed_alloc set should not exceed %d\n",
- J2K_TCD_MATRIX_MAX_RESOLUTION_COUNT);
- return OPJ_FALSE;
- }
- }
-
- p_j2k->m_specific_param.m_encoder.m_nb_comps = image->numcomps;
-
- /* keep a link to cp so that we can destroy it later in j2k_destroy_compress */
- cp = &(p_j2k->m_cp);
-
- /* set default values for cp */
- cp->tw = 1;
- cp->th = 1;
-
- /* FIXME ADE: to be removed once deprecated cp_cinema and cp_rsiz have been removed */
- if (parameters->rsiz ==
- OPJ_PROFILE_NONE) { /* consider deprecated fields only if RSIZ has not been set */
- OPJ_BOOL deprecated_used = OPJ_FALSE;
- switch (parameters->cp_cinema) {
- case OPJ_CINEMA2K_24:
- parameters->rsiz = OPJ_PROFILE_CINEMA_2K;
- parameters->max_cs_size = OPJ_CINEMA_24_CS;
- parameters->max_comp_size = OPJ_CINEMA_24_COMP;
- deprecated_used = OPJ_TRUE;
- break;
- case OPJ_CINEMA2K_48:
- parameters->rsiz = OPJ_PROFILE_CINEMA_2K;
- parameters->max_cs_size = OPJ_CINEMA_48_CS;
- parameters->max_comp_size = OPJ_CINEMA_48_COMP;
- deprecated_used = OPJ_TRUE;
- break;
- case OPJ_CINEMA4K_24:
- parameters->rsiz = OPJ_PROFILE_CINEMA_4K;
- parameters->max_cs_size = OPJ_CINEMA_24_CS;
- parameters->max_comp_size = OPJ_CINEMA_24_COMP;
- deprecated_used = OPJ_TRUE;
- break;
- case OPJ_OFF:
- default:
- break;
- }
- switch (parameters->cp_rsiz) {
- case OPJ_CINEMA2K:
- parameters->rsiz = OPJ_PROFILE_CINEMA_2K;
- deprecated_used = OPJ_TRUE;
- break;
- case OPJ_CINEMA4K:
- parameters->rsiz = OPJ_PROFILE_CINEMA_4K;
- deprecated_used = OPJ_TRUE;
- break;
- case OPJ_MCT:
- parameters->rsiz = OPJ_PROFILE_PART2 | OPJ_EXTENSION_MCT;
- deprecated_used = OPJ_TRUE;
- case OPJ_STD_RSIZ:
- default:
- break;
- }
- if (deprecated_used) {
- opj_event_msg(p_manager, EVT_WARNING,
- "Deprecated fields cp_cinema or cp_rsiz are used\n"
- "Please consider using only the rsiz field\n"
- "See openjpeg.h documentation for more details\n");
- }
- }
-
- /* If no explicit layers are provided, use lossless settings */
- if (parameters->tcp_numlayers == 0) {
- parameters->tcp_numlayers = 1;
- parameters->cp_disto_alloc = 1;
- parameters->tcp_rates[0] = 0;
- }
-
- if (parameters->cp_disto_alloc) {
- /* Emit warnings if tcp_rates are not decreasing */
- for (i = 1; i < (OPJ_UINT32) parameters->tcp_numlayers; i++) {
- OPJ_FLOAT32 rate_i_corr = parameters->tcp_rates[i];
- OPJ_FLOAT32 rate_i_m_1_corr = parameters->tcp_rates[i - 1];
- if (rate_i_corr <= 1.0) {
- rate_i_corr = 1.0;
- }
- if (rate_i_m_1_corr <= 1.0) {
- rate_i_m_1_corr = 1.0;
- }
- if (rate_i_corr >= rate_i_m_1_corr) {
- if (rate_i_corr != parameters->tcp_rates[i] &&
- rate_i_m_1_corr != parameters->tcp_rates[i - 1]) {
- opj_event_msg(p_manager, EVT_WARNING,
- "tcp_rates[%d]=%f (corrected as %f) should be strictly lesser "
- "than tcp_rates[%d]=%f (corrected as %f)\n",
- i, parameters->tcp_rates[i], rate_i_corr,
- i - 1, parameters->tcp_rates[i - 1], rate_i_m_1_corr);
- } else if (rate_i_corr != parameters->tcp_rates[i]) {
- opj_event_msg(p_manager, EVT_WARNING,
- "tcp_rates[%d]=%f (corrected as %f) should be strictly lesser "
- "than tcp_rates[%d]=%f\n",
- i, parameters->tcp_rates[i], rate_i_corr,
- i - 1, parameters->tcp_rates[i - 1]);
- } else if (rate_i_m_1_corr != parameters->tcp_rates[i - 1]) {
- opj_event_msg(p_manager, EVT_WARNING,
- "tcp_rates[%d]=%f should be strictly lesser "
- "than tcp_rates[%d]=%f (corrected as %f)\n",
- i, parameters->tcp_rates[i],
- i - 1, parameters->tcp_rates[i - 1], rate_i_m_1_corr);
- } else {
- opj_event_msg(p_manager, EVT_WARNING,
- "tcp_rates[%d]=%f should be strictly lesser "
- "than tcp_rates[%d]=%f\n",
- i, parameters->tcp_rates[i],
- i - 1, parameters->tcp_rates[i - 1]);
- }
- }
- }
- } else if (parameters->cp_fixed_quality) {
- /* Emit warnings if tcp_distoratio are not increasing */
- for (i = 1; i < (OPJ_UINT32) parameters->tcp_numlayers; i++) {
- if (parameters->tcp_distoratio[i] < parameters->tcp_distoratio[i - 1] &&
- !(i == (OPJ_UINT32)parameters->tcp_numlayers - 1 &&
- parameters->tcp_distoratio[i] == 0)) {
- opj_event_msg(p_manager, EVT_WARNING,
- "tcp_distoratio[%d]=%f should be strictly greater "
- "than tcp_distoratio[%d]=%f\n",
- i, parameters->tcp_distoratio[i], i - 1,
- parameters->tcp_distoratio[i - 1]);
- }
- }
- }
-
- /* see if max_codestream_size does limit input rate */
- if (parameters->max_cs_size <= 0) {
- if (parameters->tcp_rates[parameters->tcp_numlayers - 1] > 0) {
- OPJ_FLOAT32 temp_size;
- temp_size = (OPJ_FLOAT32)(((double)image->numcomps * image->comps[0].w *
- image->comps[0].h * image->comps[0].prec) /
- ((double)parameters->tcp_rates[parameters->tcp_numlayers - 1] * 8 *
- image->comps[0].dx * image->comps[0].dy));
- if (temp_size > (OPJ_FLOAT32)INT_MAX) {
- parameters->max_cs_size = INT_MAX;
- } else {
- parameters->max_cs_size = (int) floor(temp_size);
- }
- } else {
- parameters->max_cs_size = 0;
- }
- } else {
- OPJ_FLOAT32 temp_rate;
- OPJ_BOOL cap = OPJ_FALSE;
-
- if (OPJ_IS_IMF(parameters->rsiz) && parameters->max_cs_size > 0 &&
- parameters->tcp_numlayers == 1 && parameters->tcp_rates[0] == 0) {
- parameters->tcp_rates[0] = (OPJ_FLOAT32)(image->numcomps * image->comps[0].w *
- image->comps[0].h * image->comps[0].prec) /
- (OPJ_FLOAT32)(((OPJ_UINT32)parameters->max_cs_size) * 8 * image->comps[0].dx *
- image->comps[0].dy);
- }
-
- temp_rate = (OPJ_FLOAT32)(((double)image->numcomps * image->comps[0].w *
- image->comps[0].h * image->comps[0].prec) /
- (((double)parameters->max_cs_size) * 8 * image->comps[0].dx *
- image->comps[0].dy));
- for (i = 0; i < (OPJ_UINT32) parameters->tcp_numlayers; i++) {
- if (parameters->tcp_rates[i] < temp_rate) {
- parameters->tcp_rates[i] = temp_rate;
- cap = OPJ_TRUE;
- }
- }
- if (cap) {
- opj_event_msg(p_manager, EVT_WARNING,
- "The desired maximum codestream size has limited\n"
- "at least one of the desired quality layers\n");
- }
- }
-
- if (OPJ_IS_CINEMA(parameters->rsiz) || OPJ_IS_IMF(parameters->rsiz)) {
- p_j2k->m_specific_param.m_encoder.m_TLM = OPJ_TRUE;
- }
-
- /* Manage profiles and applications and set RSIZ */
- /* set cinema parameters if required */
- if (OPJ_IS_CINEMA(parameters->rsiz)) {
- if ((parameters->rsiz == OPJ_PROFILE_CINEMA_S2K)
- || (parameters->rsiz == OPJ_PROFILE_CINEMA_S4K)) {
- opj_event_msg(p_manager, EVT_WARNING,
- "JPEG 2000 Scalable Digital Cinema profiles not yet supported\n");
- parameters->rsiz = OPJ_PROFILE_NONE;
- } else {
- opj_j2k_set_cinema_parameters(parameters, image, p_manager);
- if (!opj_j2k_is_cinema_compliant(image, parameters->rsiz, p_manager)) {
- parameters->rsiz = OPJ_PROFILE_NONE;
- }
- }
- } else if (OPJ_IS_STORAGE(parameters->rsiz)) {
- opj_event_msg(p_manager, EVT_WARNING,
- "JPEG 2000 Long Term Storage profile not yet supported\n");
- parameters->rsiz = OPJ_PROFILE_NONE;
- } else if (OPJ_IS_BROADCAST(parameters->rsiz)) {
- opj_event_msg(p_manager, EVT_WARNING,
- "JPEG 2000 Broadcast profiles not yet supported\n");
- parameters->rsiz = OPJ_PROFILE_NONE;
- } else if (OPJ_IS_IMF(parameters->rsiz)) {
- opj_j2k_set_imf_parameters(parameters, image, p_manager);
- if (!opj_j2k_is_imf_compliant(parameters, image, p_manager)) {
- parameters->rsiz = OPJ_PROFILE_NONE;
- }
- } else if (OPJ_IS_PART2(parameters->rsiz)) {
- if (parameters->rsiz == ((OPJ_PROFILE_PART2) | (OPJ_EXTENSION_NONE))) {
- opj_event_msg(p_manager, EVT_WARNING,
- "JPEG 2000 Part-2 profile defined\n"
- "but no Part-2 extension enabled.\n"
- "Profile set to NONE.\n");
- parameters->rsiz = OPJ_PROFILE_NONE;
- } else if (parameters->rsiz != ((OPJ_PROFILE_PART2) | (OPJ_EXTENSION_MCT))) {
- opj_event_msg(p_manager, EVT_WARNING,
- "Unsupported Part-2 extension enabled\n"
- "Profile set to NONE.\n");
- parameters->rsiz = OPJ_PROFILE_NONE;
- }
- }
-
- /*
- copy user encoding parameters
- */
- cp->m_specific_param.m_enc.m_max_comp_size = (OPJ_UINT32)
- parameters->max_comp_size;
- cp->rsiz = parameters->rsiz;
- if (parameters->cp_fixed_alloc) {
- cp->m_specific_param.m_enc.m_quality_layer_alloc_strategy = FIXED_LAYER;
- } else if (parameters->cp_fixed_quality) {
- cp->m_specific_param.m_enc.m_quality_layer_alloc_strategy =
- FIXED_DISTORTION_RATIO;
- } else {
- cp->m_specific_param.m_enc.m_quality_layer_alloc_strategy =
- RATE_DISTORTION_RATIO;
- }
-
- if (parameters->cp_fixed_alloc) {
- size_t array_size = (size_t)parameters->tcp_numlayers *
- (size_t)parameters->numresolution * 3 * sizeof(OPJ_INT32);
- cp->m_specific_param.m_enc.m_matrice = (OPJ_INT32 *) opj_malloc(array_size);
- if (!cp->m_specific_param.m_enc.m_matrice) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Not enough memory to allocate copy of user encoding parameters matrix \n");
- return OPJ_FALSE;
- }
- memcpy(cp->m_specific_param.m_enc.m_matrice, parameters->cp_matrice,
- array_size);
- }
-
- /* tiles */
- cp->tdx = (OPJ_UINT32)parameters->cp_tdx;
- cp->tdy = (OPJ_UINT32)parameters->cp_tdy;
-
- /* tile offset */
- cp->tx0 = (OPJ_UINT32)parameters->cp_tx0;
- cp->ty0 = (OPJ_UINT32)parameters->cp_ty0;
-
- /* comment string */
- if (parameters->cp_comment) {
- cp->comment = (char*)opj_malloc(strlen(parameters->cp_comment) + 1U);
- if (!cp->comment) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Not enough memory to allocate copy of comment string\n");
- return OPJ_FALSE;
- }
- strcpy(cp->comment, parameters->cp_comment);
- } else {
- /* Create default comment for codestream */
- const char comment[] = "Created by OpenJPEG version ";
- const size_t clen = strlen(comment);
- const char *version = opj_version();
-
- /* UniPG>> */
-#ifdef USE_JPWL
- const size_t cp_comment_buf_size = clen + strlen(version) + 11;
- cp->comment = (char*)opj_malloc(cp_comment_buf_size);
- if (!cp->comment) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Not enough memory to allocate comment string\n");
- return OPJ_FALSE;
- }
- snprintf(cp->comment, cp_comment_buf_size, "%s%s with JPWL",
- comment, version);
-#else
- const size_t cp_comment_buf_size = clen + strlen(version) + 1;
- cp->comment = (char*)opj_malloc(cp_comment_buf_size);
- if (!cp->comment) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Not enough memory to allocate comment string\n");
- return OPJ_FALSE;
- }
- snprintf(cp->comment, cp_comment_buf_size, "%s%s", comment, version);
-#endif
- /* <<UniPG */
- }
-
- /*
- calculate other encoding parameters
- */
-
- if (parameters->tile_size_on) {
- if (cp->tdx == 0) {
- opj_event_msg(p_manager, EVT_ERROR, "Invalid tile width\n");
- return OPJ_FALSE;
- }
- if (cp->tdy == 0) {
- opj_event_msg(p_manager, EVT_ERROR, "Invalid tile height\n");
- return OPJ_FALSE;
- }
- cp->tw = opj_uint_ceildiv(image->x1 - cp->tx0, cp->tdx);
- cp->th = opj_uint_ceildiv(image->y1 - cp->ty0, cp->tdy);
- /* Check that the number of tiles is valid */
- if (cp->tw > 65535 / cp->th) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Invalid number of tiles : %u x %u (maximum fixed by jpeg2000 norm is 65535 tiles)\n",
- cp->tw, cp->th);
- return OPJ_FALSE;
- }
- } else {
- cp->tdx = image->x1 - cp->tx0;
- cp->tdy = image->y1 - cp->ty0;
- }
-
- if (parameters->tp_on) {
- cp->m_specific_param.m_enc.m_tp_flag = (OPJ_BYTE)parameters->tp_flag;
- cp->m_specific_param.m_enc.m_tp_on = 1;
- }
-
-#ifdef USE_JPWL
- /*
- calculate JPWL encoding parameters
- */
-
- if (parameters->jpwl_epc_on) {
- OPJ_INT32 i;
-
- /* set JPWL on */
- cp->epc_on = OPJ_TRUE;
- cp->info_on = OPJ_FALSE; /* no informative technique */
-
- /* set EPB on */
- if ((parameters->jpwl_hprot_MH > 0) || (parameters->jpwl_hprot_TPH[0] > 0)) {
- cp->epb_on = OPJ_TRUE;
-
- cp->hprot_MH = parameters->jpwl_hprot_MH;
- for (i = 0; i < JPWL_MAX_NO_TILESPECS; i++) {
- cp->hprot_TPH_tileno[i] = parameters->jpwl_hprot_TPH_tileno[i];
- cp->hprot_TPH[i] = parameters->jpwl_hprot_TPH[i];
- }
- /* if tile specs are not specified, copy MH specs */
- if (cp->hprot_TPH[0] == -1) {
- cp->hprot_TPH_tileno[0] = 0;
- cp->hprot_TPH[0] = parameters->jpwl_hprot_MH;
- }
- for (i = 0; i < JPWL_MAX_NO_PACKSPECS; i++) {
- cp->pprot_tileno[i] = parameters->jpwl_pprot_tileno[i];
- cp->pprot_packno[i] = parameters->jpwl_pprot_packno[i];
- cp->pprot[i] = parameters->jpwl_pprot[i];
- }
- }
-
- /* set ESD writing */
- if ((parameters->jpwl_sens_size == 1) || (parameters->jpwl_sens_size == 2)) {
- cp->esd_on = OPJ_TRUE;
-
- cp->sens_size = parameters->jpwl_sens_size;
- cp->sens_addr = parameters->jpwl_sens_addr;
- cp->sens_range = parameters->jpwl_sens_range;
-
- cp->sens_MH = parameters->jpwl_sens_MH;
- for (i = 0; i < JPWL_MAX_NO_TILESPECS; i++) {
- cp->sens_TPH_tileno[i] = parameters->jpwl_sens_TPH_tileno[i];
- cp->sens_TPH[i] = parameters->jpwl_sens_TPH[i];
- }
- }
-
- /* always set RED writing to false: we are at the encoder */
- cp->red_on = OPJ_FALSE;
-
- } else {
- cp->epc_on = OPJ_FALSE;
- }
-#endif /* USE_JPWL */
-
- /* initialize the multiple tiles */
- /* ---------------------------- */
- cp->tcps = (opj_tcp_t*) opj_calloc(cp->tw * cp->th, sizeof(opj_tcp_t));
- if (!cp->tcps) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Not enough memory to allocate tile coding parameters\n");
- return OPJ_FALSE;
- }
-
- for (tileno = 0; tileno < cp->tw * cp->th; tileno++) {
- opj_tcp_t *tcp = &cp->tcps[tileno];
- const OPJ_BOOL fixed_distoratio =
- cp->m_specific_param.m_enc.m_quality_layer_alloc_strategy ==
- FIXED_DISTORTION_RATIO;
- tcp->numlayers = (OPJ_UINT32)parameters->tcp_numlayers;
-
- for (j = 0; j < tcp->numlayers; j++) {
- if (OPJ_IS_CINEMA(cp->rsiz) || OPJ_IS_IMF(cp->rsiz)) {
- if (fixed_distoratio) {
- tcp->distoratio[j] = parameters->tcp_distoratio[j];
- }
- tcp->rates[j] = parameters->tcp_rates[j];
- } else {
- if (fixed_distoratio) {
- tcp->distoratio[j] = parameters->tcp_distoratio[j];
- } else {
- tcp->rates[j] = parameters->tcp_rates[j];
- }
- }
- if (!fixed_distoratio &&
- tcp->rates[j] <= 1.0) {
- tcp->rates[j] = 0.0; /* force lossless */
- }
- }
-
- tcp->csty = (OPJ_UINT32)parameters->csty;
- tcp->prg = parameters->prog_order;
- tcp->mct = (OPJ_UINT32)parameters->tcp_mct;
-
- numpocs_tile = 0;
- tcp->POC = 0;
-
- if (parameters->numpocs) {
- /* initialisation of POC */
- for (i = 0; i < parameters->numpocs; i++) {
- if (tileno + 1 == parameters->POC[i].tile) {
- opj_poc_t *tcp_poc = &tcp->pocs[numpocs_tile];
-
- if (parameters->POC[numpocs_tile].compno0 >= image->numcomps) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Invalid compno0 for POC %d\n", i);
- return OPJ_FALSE;
- }
-
- tcp_poc->resno0 = parameters->POC[numpocs_tile].resno0;
- tcp_poc->compno0 = parameters->POC[numpocs_tile].compno0;
- tcp_poc->layno1 = parameters->POC[numpocs_tile].layno1;
- tcp_poc->resno1 = parameters->POC[numpocs_tile].resno1;
- tcp_poc->compno1 = opj_uint_min(parameters->POC[numpocs_tile].compno1,
- image->numcomps);
- tcp_poc->prg1 = parameters->POC[numpocs_tile].prg1;
- tcp_poc->tile = parameters->POC[numpocs_tile].tile;
-
- numpocs_tile++;
- }
- }
-
- if (numpocs_tile) {
-
- /* TODO MSD use the return value*/
- opj_j2k_check_poc_val(parameters->POC, tileno, parameters->numpocs,
- (OPJ_UINT32)parameters->numresolution, image->numcomps,
- (OPJ_UINT32)parameters->tcp_numlayers, p_manager);
-
- tcp->POC = 1;
- tcp->numpocs = numpocs_tile - 1 ;
- }
- } else {
- tcp->numpocs = 0;
- }
-
- tcp->tccps = (opj_tccp_t*) opj_calloc(image->numcomps, sizeof(opj_tccp_t));
- if (!tcp->tccps) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Not enough memory to allocate tile component coding parameters\n");
- return OPJ_FALSE;
- }
- if (parameters->mct_data) {
-
- OPJ_UINT32 lMctSize = image->numcomps * image->numcomps * (OPJ_UINT32)sizeof(
- OPJ_FLOAT32);
- OPJ_FLOAT32 * lTmpBuf = (OPJ_FLOAT32*)opj_malloc(lMctSize);
- OPJ_INT32 * l_dc_shift = (OPJ_INT32 *)((OPJ_BYTE *) parameters->mct_data +
- lMctSize);
-
- if (!lTmpBuf) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Not enough memory to allocate temp buffer\n");
- return OPJ_FALSE;
- }
-
- tcp->mct = 2;
- tcp->m_mct_coding_matrix = (OPJ_FLOAT32*)opj_malloc(lMctSize);
- if (! tcp->m_mct_coding_matrix) {
- opj_free(lTmpBuf);
- lTmpBuf = NULL;
- opj_event_msg(p_manager, EVT_ERROR,
- "Not enough memory to allocate encoder MCT coding matrix \n");
- return OPJ_FALSE;
- }
- memcpy(tcp->m_mct_coding_matrix, parameters->mct_data, lMctSize);
- memcpy(lTmpBuf, parameters->mct_data, lMctSize);
-
- tcp->m_mct_decoding_matrix = (OPJ_FLOAT32*)opj_malloc(lMctSize);
- if (! tcp->m_mct_decoding_matrix) {
- opj_free(lTmpBuf);
- lTmpBuf = NULL;
- opj_event_msg(p_manager, EVT_ERROR,
- "Not enough memory to allocate encoder MCT decoding matrix \n");
- return OPJ_FALSE;
- }
- if (opj_matrix_inversion_f(lTmpBuf, (tcp->m_mct_decoding_matrix),
- image->numcomps) == OPJ_FALSE) {
- opj_free(lTmpBuf);
- lTmpBuf = NULL;
- opj_event_msg(p_manager, EVT_ERROR,
- "Failed to inverse encoder MCT decoding matrix \n");
- return OPJ_FALSE;
- }
-
- tcp->mct_norms = (OPJ_FLOAT64*)
- opj_malloc(image->numcomps * sizeof(OPJ_FLOAT64));
- if (! tcp->mct_norms) {
- opj_free(lTmpBuf);
- lTmpBuf = NULL;
- opj_event_msg(p_manager, EVT_ERROR,
- "Not enough memory to allocate encoder MCT norms \n");
- return OPJ_FALSE;
- }
- opj_calculate_norms(tcp->mct_norms, image->numcomps,
- tcp->m_mct_decoding_matrix);
- opj_free(lTmpBuf);
-
- for (i = 0; i < image->numcomps; i++) {
- opj_tccp_t *tccp = &tcp->tccps[i];
- tccp->m_dc_level_shift = l_dc_shift[i];
- }
-
- if (opj_j2k_setup_mct_encoding(tcp, image) == OPJ_FALSE) {
- /* free will be handled by opj_j2k_destroy */
- opj_event_msg(p_manager, EVT_ERROR, "Failed to setup j2k mct encoding\n");
- return OPJ_FALSE;
- }
- } else {
- if (tcp->mct == 1 && image->numcomps >= 3) { /* RGB->YCC MCT is enabled */
- if ((image->comps[0].dx != image->comps[1].dx) ||
- (image->comps[0].dx != image->comps[2].dx) ||
- (image->comps[0].dy != image->comps[1].dy) ||
- (image->comps[0].dy != image->comps[2].dy)) {
- opj_event_msg(p_manager, EVT_WARNING,
- "Cannot perform MCT on components with different sizes. Disabling MCT.\n");
- tcp->mct = 0;
- }
- }
- for (i = 0; i < image->numcomps; i++) {
- opj_tccp_t *tccp = &tcp->tccps[i];
- opj_image_comp_t * l_comp = &(image->comps[i]);
-
- if (! l_comp->sgnd) {
- tccp->m_dc_level_shift = 1 << (l_comp->prec - 1);
- }
- }
- }
-
- for (i = 0; i < image->numcomps; i++) {
- opj_tccp_t *tccp = &tcp->tccps[i];
-
- tccp->csty = parameters->csty &
- 0x01; /* 0 => one precinct || 1 => custom precinct */
- tccp->numresolutions = (OPJ_UINT32)parameters->numresolution;
- tccp->cblkw = (OPJ_UINT32)opj_int_floorlog2(parameters->cblockw_init);
- tccp->cblkh = (OPJ_UINT32)opj_int_floorlog2(parameters->cblockh_init);
- tccp->cblksty = (OPJ_UINT32)parameters->mode;
- tccp->qmfbid = parameters->irreversible ? 0 : 1;
- tccp->qntsty = parameters->irreversible ? J2K_CCP_QNTSTY_SEQNT :
- J2K_CCP_QNTSTY_NOQNT;
-
- if (OPJ_IS_CINEMA(parameters->rsiz) &&
- parameters->rsiz == OPJ_PROFILE_CINEMA_2K) {
- /* From https://github.com/uclouvain/openjpeg/issues/1340 */
- tccp->numgbits = 1;
- } else {
- tccp->numgbits = 2;
- }
-
- if ((OPJ_INT32)i == parameters->roi_compno) {
- tccp->roishift = parameters->roi_shift;
- } else {
- tccp->roishift = 0;
- }
-
- if (parameters->csty & J2K_CCP_CSTY_PRT) {
- OPJ_INT32 p = 0, it_res;
- assert(tccp->numresolutions > 0);
- for (it_res = (OPJ_INT32)tccp->numresolutions - 1; it_res >= 0; it_res--) {
- if (p < parameters->res_spec) {
-
- if (parameters->prcw_init[p] < 1) {
- tccp->prcw[it_res] = 1;
- } else {
- tccp->prcw[it_res] = (OPJ_UINT32)opj_int_floorlog2(parameters->prcw_init[p]);
- }
-
- if (parameters->prch_init[p] < 1) {
- tccp->prch[it_res] = 1;
- } else {
- tccp->prch[it_res] = (OPJ_UINT32)opj_int_floorlog2(parameters->prch_init[p]);
- }
-
- } else {
- OPJ_INT32 res_spec = parameters->res_spec;
- OPJ_INT32 size_prcw = 0;
- OPJ_INT32 size_prch = 0;
-
- assert(res_spec > 0); /* issue 189 */
- size_prcw = parameters->prcw_init[res_spec - 1] >> (p - (res_spec - 1));
- size_prch = parameters->prch_init[res_spec - 1] >> (p - (res_spec - 1));
-
-
- if (size_prcw < 1) {
- tccp->prcw[it_res] = 1;
- } else {
- tccp->prcw[it_res] = (OPJ_UINT32)opj_int_floorlog2(size_prcw);
- }
-
- if (size_prch < 1) {
- tccp->prch[it_res] = 1;
- } else {
- tccp->prch[it_res] = (OPJ_UINT32)opj_int_floorlog2(size_prch);
- }
- }
- p++;
- /*printf("\nsize precinct for level %d : %d,%d\n", it_res,tccp->prcw[it_res], tccp->prch[it_res]); */
- } /*end for*/
- } else {
- for (j = 0; j < tccp->numresolutions; j++) {
- tccp->prcw[j] = 15;
- tccp->prch[j] = 15;
- }
- }
-
- opj_dwt_calc_explicit_stepsizes(tccp, image->comps[i].prec);
- }
- }
-
- if (parameters->mct_data) {
- opj_free(parameters->mct_data);
- parameters->mct_data = 00;
- }
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_add_mhmarker(opj_codestream_index_t *cstr_index,
- OPJ_UINT32 type, OPJ_OFF_T pos, OPJ_UINT32 len)
-{
- assert(cstr_index != 00);
-
- /* expand the list? */
- if ((cstr_index->marknum + 1) > cstr_index->maxmarknum) {
- opj_marker_info_t *new_marker;
- cstr_index->maxmarknum = (OPJ_UINT32)(100 + (OPJ_FLOAT32)
- cstr_index->maxmarknum);
- new_marker = (opj_marker_info_t *) opj_realloc(cstr_index->marker,
- cstr_index->maxmarknum * sizeof(opj_marker_info_t));
- if (! new_marker) {
- opj_free(cstr_index->marker);
- cstr_index->marker = NULL;
- cstr_index->maxmarknum = 0;
- cstr_index->marknum = 0;
- /* opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to add mh marker\n"); */
- return OPJ_FALSE;
- }
- cstr_index->marker = new_marker;
- }
-
- /* add the marker */
- cstr_index->marker[cstr_index->marknum].type = (OPJ_UINT16)type;
- cstr_index->marker[cstr_index->marknum].pos = (OPJ_INT32)pos;
- cstr_index->marker[cstr_index->marknum].len = (OPJ_INT32)len;
- cstr_index->marknum++;
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_add_tlmarker(OPJ_UINT32 tileno,
- opj_codestream_index_t *cstr_index, OPJ_UINT32 type, OPJ_OFF_T pos,
- OPJ_UINT32 len)
-{
- assert(cstr_index != 00);
- assert(cstr_index->tile_index != 00);
-
- /* expand the list? */
- if ((cstr_index->tile_index[tileno].marknum + 1) >
- cstr_index->tile_index[tileno].maxmarknum) {
- opj_marker_info_t *new_marker;
- cstr_index->tile_index[tileno].maxmarknum = (OPJ_UINT32)(100 +
- (OPJ_FLOAT32) cstr_index->tile_index[tileno].maxmarknum);
- new_marker = (opj_marker_info_t *) opj_realloc(
- cstr_index->tile_index[tileno].marker,
- cstr_index->tile_index[tileno].maxmarknum * sizeof(opj_marker_info_t));
- if (! new_marker) {
- opj_free(cstr_index->tile_index[tileno].marker);
- cstr_index->tile_index[tileno].marker = NULL;
- cstr_index->tile_index[tileno].maxmarknum = 0;
- cstr_index->tile_index[tileno].marknum = 0;
- /* opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to add tl marker\n"); */
- return OPJ_FALSE;
- }
- cstr_index->tile_index[tileno].marker = new_marker;
- }
-
- /* add the marker */
- cstr_index->tile_index[tileno].marker[cstr_index->tile_index[tileno].marknum].type
- = (OPJ_UINT16)type;
- cstr_index->tile_index[tileno].marker[cstr_index->tile_index[tileno].marknum].pos
- = (OPJ_INT32)pos;
- cstr_index->tile_index[tileno].marker[cstr_index->tile_index[tileno].marknum].len
- = (OPJ_INT32)len;
- cstr_index->tile_index[tileno].marknum++;
-
- if (type == J2K_MS_SOT) {
- OPJ_UINT32 l_current_tile_part = cstr_index->tile_index[tileno].current_tpsno;
-
- if (cstr_index->tile_index[tileno].tp_index &&
- l_current_tile_part < cstr_index->tile_index[tileno].nb_tps) {
- cstr_index->tile_index[tileno].tp_index[l_current_tile_part].start_pos = pos;
- }
-
- }
- return OPJ_TRUE;
-}
-
-/*
- * -----------------------------------------------------------------------
- * -----------------------------------------------------------------------
- * -----------------------------------------------------------------------
- */
-
-OPJ_BOOL opj_j2k_end_decompress(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager
- )
-{
- (void)p_j2k;
- (void)p_stream;
- (void)p_manager;
- return OPJ_TRUE;
-}
-
-OPJ_BOOL opj_j2k_read_header(opj_stream_private_t *p_stream,
- opj_j2k_t* p_j2k,
- opj_image_t** p_image,
- opj_event_mgr_t* p_manager)
-{
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_stream != 00);
- assert(p_manager != 00);
-
- /* create an empty image header */
- p_j2k->m_private_image = opj_image_create0();
- if (! p_j2k->m_private_image) {
- return OPJ_FALSE;
- }
-
- /* customization of the validation */
- if (! opj_j2k_setup_decoding_validation(p_j2k, p_manager)) {
- opj_image_destroy(p_j2k->m_private_image);
- p_j2k->m_private_image = NULL;
- return OPJ_FALSE;
- }
-
- /* validation of the parameters codec */
- if (! opj_j2k_exec(p_j2k, p_j2k->m_validation_list, p_stream, p_manager)) {
- opj_image_destroy(p_j2k->m_private_image);
- p_j2k->m_private_image = NULL;
- return OPJ_FALSE;
- }
-
- /* customization of the encoding */
- if (! opj_j2k_setup_header_reading(p_j2k, p_manager)) {
- opj_image_destroy(p_j2k->m_private_image);
- p_j2k->m_private_image = NULL;
- return OPJ_FALSE;
- }
-
- /* read header */
- if (! opj_j2k_exec(p_j2k, p_j2k->m_procedure_list, p_stream, p_manager)) {
- opj_image_destroy(p_j2k->m_private_image);
- p_j2k->m_private_image = NULL;
- return OPJ_FALSE;
- }
-
- *p_image = opj_image_create0();
- if (!(*p_image)) {
- return OPJ_FALSE;
- }
-
- /* Copy codestream image information to the output image */
- opj_copy_image_header(p_j2k->m_private_image, *p_image);
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_setup_header_reading(opj_j2k_t *p_j2k,
- opj_event_mgr_t * p_manager)
-{
- /* preconditions*/
- assert(p_j2k != 00);
- assert(p_manager != 00);
-
- if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,
- (opj_procedure)opj_j2k_read_header_procedure, p_manager)) {
- return OPJ_FALSE;
- }
-
- /* DEVELOPER CORNER, add your custom procedures */
- if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,
- (opj_procedure)opj_j2k_copy_default_tcp_and_create_tcd, p_manager)) {
- return OPJ_FALSE;
- }
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_setup_decoding_validation(opj_j2k_t *p_j2k,
- opj_event_mgr_t * p_manager)
-{
- /* preconditions*/
- assert(p_j2k != 00);
- assert(p_manager != 00);
-
- if (! opj_procedure_list_add_procedure(p_j2k->m_validation_list,
- (opj_procedure)opj_j2k_build_decoder, p_manager)) {
- return OPJ_FALSE;
- }
- if (! opj_procedure_list_add_procedure(p_j2k->m_validation_list,
- (opj_procedure)opj_j2k_decoding_validation, p_manager)) {
- return OPJ_FALSE;
- }
-
- /* DEVELOPER CORNER, add your custom validation procedure */
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_mct_validation(opj_j2k_t * p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager)
-{
- OPJ_BOOL l_is_valid = OPJ_TRUE;
- OPJ_UINT32 i, j;
-
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_stream != 00);
- assert(p_manager != 00);
-
- OPJ_UNUSED(p_stream);
- OPJ_UNUSED(p_manager);
-
- if ((p_j2k->m_cp.rsiz & 0x8200) == 0x8200) {
- OPJ_UINT32 l_nb_tiles = p_j2k->m_cp.th * p_j2k->m_cp.tw;
- opj_tcp_t * l_tcp = p_j2k->m_cp.tcps;
-
- for (i = 0; i < l_nb_tiles; ++i) {
- if (l_tcp->mct == 2) {
- opj_tccp_t * l_tccp = l_tcp->tccps;
- l_is_valid &= (l_tcp->m_mct_coding_matrix != 00);
-
- for (j = 0; j < p_j2k->m_private_image->numcomps; ++j) {
- l_is_valid &= !(l_tccp->qmfbid & 1);
- ++l_tccp;
- }
- }
- ++l_tcp;
- }
- }
-
- return l_is_valid;
-}
-
-OPJ_BOOL opj_j2k_setup_mct_encoding(opj_tcp_t * p_tcp, opj_image_t * p_image)
-{
- OPJ_UINT32 i;
- OPJ_UINT32 l_indix = 1;
- opj_mct_data_t * l_mct_deco_data = 00, * l_mct_offset_data = 00;
- opj_simple_mcc_decorrelation_data_t * l_mcc_data;
- OPJ_UINT32 l_mct_size, l_nb_elem;
- OPJ_FLOAT32 * l_data, * l_current_data;
- opj_tccp_t * l_tccp;
-
- /* preconditions */
- assert(p_tcp != 00);
-
- if (p_tcp->mct != 2) {
- return OPJ_TRUE;
- }
-
- if (p_tcp->m_mct_decoding_matrix) {
- if (p_tcp->m_nb_mct_records == p_tcp->m_nb_max_mct_records) {
- opj_mct_data_t *new_mct_records;
- p_tcp->m_nb_max_mct_records += OPJ_J2K_MCT_DEFAULT_NB_RECORDS;
-
- new_mct_records = (opj_mct_data_t *) opj_realloc(p_tcp->m_mct_records,
- p_tcp->m_nb_max_mct_records * sizeof(opj_mct_data_t));
- if (! new_mct_records) {
- opj_free(p_tcp->m_mct_records);
- p_tcp->m_mct_records = NULL;
- p_tcp->m_nb_max_mct_records = 0;
- p_tcp->m_nb_mct_records = 0;
- /* opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to setup mct encoding\n"); */
- return OPJ_FALSE;
- }
- p_tcp->m_mct_records = new_mct_records;
- l_mct_deco_data = p_tcp->m_mct_records + p_tcp->m_nb_mct_records;
-
- memset(l_mct_deco_data, 0,
- (p_tcp->m_nb_max_mct_records - p_tcp->m_nb_mct_records) * sizeof(
- opj_mct_data_t));
- }
- l_mct_deco_data = p_tcp->m_mct_records + p_tcp->m_nb_mct_records;
-
- if (l_mct_deco_data->m_data) {
- opj_free(l_mct_deco_data->m_data);
- l_mct_deco_data->m_data = 00;
- }
-
- l_mct_deco_data->m_index = l_indix++;
- l_mct_deco_data->m_array_type = MCT_TYPE_DECORRELATION;
- l_mct_deco_data->m_element_type = MCT_TYPE_FLOAT;
- l_nb_elem = p_image->numcomps * p_image->numcomps;
- l_mct_size = l_nb_elem * MCT_ELEMENT_SIZE[l_mct_deco_data->m_element_type];
- l_mct_deco_data->m_data = (OPJ_BYTE*)opj_malloc(l_mct_size);
-
- if (! l_mct_deco_data->m_data) {
- return OPJ_FALSE;
- }
-
- j2k_mct_write_functions_from_float[l_mct_deco_data->m_element_type](
- p_tcp->m_mct_decoding_matrix, l_mct_deco_data->m_data, l_nb_elem);
-
- l_mct_deco_data->m_data_size = l_mct_size;
- ++p_tcp->m_nb_mct_records;
- }
-
- if (p_tcp->m_nb_mct_records == p_tcp->m_nb_max_mct_records) {
- opj_mct_data_t *new_mct_records;
- p_tcp->m_nb_max_mct_records += OPJ_J2K_MCT_DEFAULT_NB_RECORDS;
- new_mct_records = (opj_mct_data_t *) opj_realloc(p_tcp->m_mct_records,
- p_tcp->m_nb_max_mct_records * sizeof(opj_mct_data_t));
- if (! new_mct_records) {
- opj_free(p_tcp->m_mct_records);
- p_tcp->m_mct_records = NULL;
- p_tcp->m_nb_max_mct_records = 0;
- p_tcp->m_nb_mct_records = 0;
- /* opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to setup mct encoding\n"); */
- return OPJ_FALSE;
- }
- p_tcp->m_mct_records = new_mct_records;
- l_mct_offset_data = p_tcp->m_mct_records + p_tcp->m_nb_mct_records;
-
- memset(l_mct_offset_data, 0,
- (p_tcp->m_nb_max_mct_records - p_tcp->m_nb_mct_records) * sizeof(
- opj_mct_data_t));
-
- if (l_mct_deco_data) {
- l_mct_deco_data = l_mct_offset_data - 1;
- }
- }
-
- l_mct_offset_data = p_tcp->m_mct_records + p_tcp->m_nb_mct_records;
-
- if (l_mct_offset_data->m_data) {
- opj_free(l_mct_offset_data->m_data);
- l_mct_offset_data->m_data = 00;
- }
-
- l_mct_offset_data->m_index = l_indix++;
- l_mct_offset_data->m_array_type = MCT_TYPE_OFFSET;
- l_mct_offset_data->m_element_type = MCT_TYPE_FLOAT;
- l_nb_elem = p_image->numcomps;
- l_mct_size = l_nb_elem * MCT_ELEMENT_SIZE[l_mct_offset_data->m_element_type];
- l_mct_offset_data->m_data = (OPJ_BYTE*)opj_malloc(l_mct_size);
-
- if (! l_mct_offset_data->m_data) {
- return OPJ_FALSE;
- }
-
- l_data = (OPJ_FLOAT32*)opj_malloc(l_nb_elem * sizeof(OPJ_FLOAT32));
- if (! l_data) {
- opj_free(l_mct_offset_data->m_data);
- l_mct_offset_data->m_data = 00;
- return OPJ_FALSE;
- }
-
- l_tccp = p_tcp->tccps;
- l_current_data = l_data;
-
- for (i = 0; i < l_nb_elem; ++i) {
- *(l_current_data++) = (OPJ_FLOAT32)(l_tccp->m_dc_level_shift);
- ++l_tccp;
- }
-
- j2k_mct_write_functions_from_float[l_mct_offset_data->m_element_type](l_data,
- l_mct_offset_data->m_data, l_nb_elem);
-
- opj_free(l_data);
-
- l_mct_offset_data->m_data_size = l_mct_size;
-
- ++p_tcp->m_nb_mct_records;
-
- if (p_tcp->m_nb_mcc_records == p_tcp->m_nb_max_mcc_records) {
- opj_simple_mcc_decorrelation_data_t *new_mcc_records;
- p_tcp->m_nb_max_mcc_records += OPJ_J2K_MCT_DEFAULT_NB_RECORDS;
- new_mcc_records = (opj_simple_mcc_decorrelation_data_t *) opj_realloc(
- p_tcp->m_mcc_records, p_tcp->m_nb_max_mcc_records * sizeof(
- opj_simple_mcc_decorrelation_data_t));
- if (! new_mcc_records) {
- opj_free(p_tcp->m_mcc_records);
- p_tcp->m_mcc_records = NULL;
- p_tcp->m_nb_max_mcc_records = 0;
- p_tcp->m_nb_mcc_records = 0;
- /* opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to setup mct encoding\n"); */
- return OPJ_FALSE;
- }
- p_tcp->m_mcc_records = new_mcc_records;
- l_mcc_data = p_tcp->m_mcc_records + p_tcp->m_nb_mcc_records;
- memset(l_mcc_data, 0, (p_tcp->m_nb_max_mcc_records - p_tcp->m_nb_mcc_records) *
- sizeof(opj_simple_mcc_decorrelation_data_t));
-
- }
-
- l_mcc_data = p_tcp->m_mcc_records + p_tcp->m_nb_mcc_records;
- l_mcc_data->m_decorrelation_array = l_mct_deco_data;
- l_mcc_data->m_is_irreversible = 1;
- l_mcc_data->m_nb_comps = p_image->numcomps;
- l_mcc_data->m_index = l_indix++;
- l_mcc_data->m_offset_array = l_mct_offset_data;
- ++p_tcp->m_nb_mcc_records;
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_build_decoder(opj_j2k_t * p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager)
-{
- /* add here initialization of cp
- copy paste of setup_decoder */
- (void)p_j2k;
- (void)p_stream;
- (void)p_manager;
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_build_encoder(opj_j2k_t * p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager)
-{
- /* add here initialization of cp
- copy paste of setup_encoder */
- (void)p_j2k;
- (void)p_stream;
- (void)p_manager;
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_encoding_validation(opj_j2k_t * p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager)
-{
- OPJ_BOOL l_is_valid = OPJ_TRUE;
-
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_stream != 00);
- assert(p_manager != 00);
-
- OPJ_UNUSED(p_stream);
-
- /* STATE checking */
- /* make sure the state is at 0 */
- l_is_valid &= (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_NONE);
-
- /* POINTER validation */
- /* make sure a p_j2k codec is present */
- l_is_valid &= (p_j2k->m_procedure_list != 00);
- /* make sure a validation list is present */
- l_is_valid &= (p_j2k->m_validation_list != 00);
-
- /* ISO 15444-1:2004 states between 1 & 33 (0 -> 32) */
- /* 33 (32) would always fail the check below (if a cast to 64bits was done) */
- /* FIXME Shall we change OPJ_J2K_MAXRLVLS to 32 ? */
- if ((p_j2k->m_cp.tcps->tccps->numresolutions <= 0) ||
- (p_j2k->m_cp.tcps->tccps->numresolutions > 32)) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Number of resolutions is too high in comparison to the size of tiles\n");
- return OPJ_FALSE;
- }
-
- if ((p_j2k->m_cp.tdx) < (OPJ_UINT32)(1 <<
- (p_j2k->m_cp.tcps->tccps->numresolutions - 1U))) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Number of resolutions is too high in comparison to the size of tiles\n");
- return OPJ_FALSE;
- }
-
- if ((p_j2k->m_cp.tdy) < (OPJ_UINT32)(1 <<
- (p_j2k->m_cp.tcps->tccps->numresolutions - 1U))) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Number of resolutions is too high in comparison to the size of tiles\n");
- return OPJ_FALSE;
- }
-
- /* PARAMETER VALIDATION */
- return l_is_valid;
-}
-
-static OPJ_BOOL opj_j2k_decoding_validation(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager
- )
-{
- OPJ_BOOL l_is_valid = OPJ_TRUE;
-
- /* preconditions*/
- assert(p_j2k != 00);
- assert(p_stream != 00);
- assert(p_manager != 00);
-
- OPJ_UNUSED(p_stream);
- OPJ_UNUSED(p_manager);
-
- /* STATE checking */
- /* make sure the state is at 0 */
-#ifdef TODO_MSD
- l_is_valid &= (p_j2k->m_specific_param.m_decoder.m_state == J2K_DEC_STATE_NONE);
-#endif
- l_is_valid &= (p_j2k->m_specific_param.m_decoder.m_state == 0x0000);
-
- /* POINTER validation */
- /* make sure a p_j2k codec is present */
- /* make sure a procedure list is present */
- l_is_valid &= (p_j2k->m_procedure_list != 00);
- /* make sure a validation list is present */
- l_is_valid &= (p_j2k->m_validation_list != 00);
-
- /* PARAMETER VALIDATION */
- return l_is_valid;
-}
-
-/** Fill p_j2k->cstr_index->tp_index[].start_pos/end_pos fields from TLM marker segments */
-static void opj_j2k_build_tp_index_from_tlm(opj_j2k_t* p_j2k,
- opj_event_mgr_t * p_manager)
-{
- opj_j2k_tlm_info_t* l_tlm;
- OPJ_UINT32 i;
- OPJ_OFF_T l_cur_offset;
-
- assert(p_j2k->cstr_index->main_head_end > 0);
- assert(p_j2k->cstr_index->nb_of_tiles > 0);
- assert(p_j2k->cstr_index->tile_index != NULL);
-
- l_tlm = &(p_j2k->m_specific_param.m_decoder.m_tlm);
-
- if (l_tlm->m_entries_count == 0) {
- l_tlm->m_is_invalid = OPJ_TRUE;
- return;
- }
-
- if (l_tlm->m_is_invalid) {
- return;
- }
-
- /* Initial pass to count the number of tile-parts per tile */
- for (i = 0; i < l_tlm->m_entries_count; ++i) {
- OPJ_UINT32 l_tile_index_no = l_tlm->m_tile_part_infos[i].m_tile_index;
- assert(l_tile_index_no < p_j2k->cstr_index->nb_of_tiles);
- p_j2k->cstr_index->tile_index[l_tile_index_no].tileno = l_tile_index_no;
- ++p_j2k->cstr_index->tile_index[l_tile_index_no].current_nb_tps;
- }
-
- /* Now check that all tiles have at least one tile-part */
- for (i = 0; i < p_j2k->cstr_index->nb_of_tiles; ++i) {
- if (p_j2k->cstr_index->tile_index[i].current_nb_tps == 0) {
- opj_event_msg(p_manager, EVT_ERROR,
- "opj_j2k_build_tp_index_from_tlm(): tile %d has no "
- "registered tile-part in TLM marker segments.\n", i);
- goto error;
- }
- }
-
- /* Final pass to fill p_j2k->cstr_index */
- l_cur_offset = p_j2k->cstr_index->main_head_end;
- for (i = 0; i < l_tlm->m_entries_count; ++i) {
- OPJ_UINT32 l_tile_index_no = l_tlm->m_tile_part_infos[i].m_tile_index;
- opj_tile_index_t* l_tile_index = &
- (p_j2k->cstr_index->tile_index[l_tile_index_no]);
- if (!l_tile_index->tp_index) {
- l_tile_index->tp_index = (opj_tp_index_t *) opj_calloc(
- l_tile_index->current_nb_tps, sizeof(opj_tp_index_t));
- if (! l_tile_index->tp_index) {
- opj_event_msg(p_manager, EVT_ERROR,
- "opj_j2k_build_tp_index_from_tlm(): tile index allocation failed\n");
- goto error;
- }
- }
-
- assert(l_tile_index->nb_tps < l_tile_index->current_nb_tps);
- l_tile_index->tp_index[l_tile_index->nb_tps].start_pos = l_cur_offset;
- /* We don't know how to set the tp_index[].end_header field, but this is not really needed */
- /* If there would be no markers between SOT and SOD, that would be : */
- /* l_tile_index->tp_index[l_tile_index->nb_tps].end_header = l_cur_offset + 12; */
- l_tile_index->tp_index[l_tile_index->nb_tps].end_pos = l_cur_offset +
- l_tlm->m_tile_part_infos[i].m_length;
- ++l_tile_index->nb_tps;
-
- l_cur_offset += l_tlm->m_tile_part_infos[i].m_length;
- }
-
- return;
-
-error:
- l_tlm->m_is_invalid = OPJ_TRUE;
- for (i = 0; i < l_tlm->m_entries_count; ++i) {
- OPJ_UINT32 l_tile_index = l_tlm->m_tile_part_infos[i].m_tile_index;
- p_j2k->cstr_index->tile_index[l_tile_index].current_nb_tps = 0;
- opj_free(p_j2k->cstr_index->tile_index[l_tile_index].tp_index);
- p_j2k->cstr_index->tile_index[l_tile_index].tp_index = NULL;
- }
-}
-
-static OPJ_BOOL opj_j2k_read_header_procedure(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager)
-{
- OPJ_UINT32 l_current_marker;
- OPJ_UINT32 l_marker_size;
- const opj_dec_memory_marker_handler_t * l_marker_handler = 00;
- OPJ_BOOL l_has_siz = 0;
- OPJ_BOOL l_has_cod = 0;
- OPJ_BOOL l_has_qcd = 0;
-
- /* preconditions */
- assert(p_stream != 00);
- assert(p_j2k != 00);
- assert(p_manager != 00);
-
- /* We enter in the main header */
- p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_MHSOC;
-
- /* Try to read the SOC marker, the codestream must begin with SOC marker */
- if (! opj_j2k_read_soc(p_j2k, p_stream, p_manager)) {
- opj_event_msg(p_manager, EVT_ERROR, "Expected a SOC marker \n");
- return OPJ_FALSE;
- }
-
- /* Try to read 2 bytes (the next marker ID) from stream and copy them into the buffer */
- if (opj_stream_read_data(p_stream,
- p_j2k->m_specific_param.m_decoder.m_header_data, 2, p_manager) != 2) {
- opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
- return OPJ_FALSE;
- }
-
- /* Read 2 bytes as the new marker ID */
- opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data,
- &l_current_marker, 2);
-
- /* Try to read until the SOT is detected */
- while (l_current_marker != J2K_MS_SOT) {
-
- /* Check if the current marker ID is valid */
- if (l_current_marker < 0xff00) {
- opj_event_msg(p_manager, EVT_ERROR,
- "A marker ID was expected (0xff--) instead of %.8x\n", l_current_marker);
- return OPJ_FALSE;
- }
-
- /* Get the marker handler from the marker ID */
- l_marker_handler = opj_j2k_get_marker_handler(l_current_marker);
-
- /* Manage case where marker is unknown */
- if (l_marker_handler->id == J2K_MS_UNK) {
- if (! opj_j2k_read_unk(p_j2k, p_stream, &l_current_marker, p_manager)) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Unknown marker has been detected and generated error.\n");
- return OPJ_FALSE;
- }
-
- if (l_current_marker == J2K_MS_SOT) {
- break; /* SOT marker is detected main header is completely read */
- } else { /* Get the marker handler from the marker ID */
- l_marker_handler = opj_j2k_get_marker_handler(l_current_marker);
- }
- }
-
- if (l_marker_handler->id == J2K_MS_SIZ) {
- /* Mark required SIZ marker as found */
- l_has_siz = 1;
- }
- if (l_marker_handler->id == J2K_MS_COD) {
- /* Mark required COD marker as found */
- l_has_cod = 1;
- }
- if (l_marker_handler->id == J2K_MS_QCD) {
- /* Mark required QCD marker as found */
- l_has_qcd = 1;
- }
-
- /* Check if the marker is known and if it is the right place to find it */
- if (!(p_j2k->m_specific_param.m_decoder.m_state & l_marker_handler->states)) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Marker is not compliant with its position\n");
- return OPJ_FALSE;
- }
-
- /* Try to read 2 bytes (the marker size) from stream and copy them into the buffer */
- if (opj_stream_read_data(p_stream,
- p_j2k->m_specific_param.m_decoder.m_header_data, 2, p_manager) != 2) {
- opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
- return OPJ_FALSE;
- }
-
- /* read 2 bytes as the marker size */
- opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data, &l_marker_size,
- 2);
- if (l_marker_size < 2) {
- opj_event_msg(p_manager, EVT_ERROR, "Invalid marker size\n");
- return OPJ_FALSE;
- }
- l_marker_size -= 2; /* Subtract the size of the marker ID already read */
-
- /* Check if the marker size is compatible with the header data size */
- if (l_marker_size > p_j2k->m_specific_param.m_decoder.m_header_data_size) {
- OPJ_BYTE *new_header_data = (OPJ_BYTE *) opj_realloc(
- p_j2k->m_specific_param.m_decoder.m_header_data, l_marker_size);
- if (! new_header_data) {
- opj_free(p_j2k->m_specific_param.m_decoder.m_header_data);
- p_j2k->m_specific_param.m_decoder.m_header_data = NULL;
- p_j2k->m_specific_param.m_decoder.m_header_data_size = 0;
- opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to read header\n");
- return OPJ_FALSE;
- }
- p_j2k->m_specific_param.m_decoder.m_header_data = new_header_data;
- p_j2k->m_specific_param.m_decoder.m_header_data_size = l_marker_size;
- }
-
- /* Try to read the rest of the marker segment from stream and copy them into the buffer */
- if (opj_stream_read_data(p_stream,
- p_j2k->m_specific_param.m_decoder.m_header_data, l_marker_size,
- p_manager) != l_marker_size) {
- opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
- return OPJ_FALSE;
- }
-
- /* Read the marker segment with the correct marker handler */
- if (!(*(l_marker_handler->handler))(p_j2k,
- p_j2k->m_specific_param.m_decoder.m_header_data, l_marker_size, p_manager)) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Marker handler function failed to read the marker segment\n");
- return OPJ_FALSE;
- }
-
- /* Add the marker to the codestream index*/
- if (OPJ_FALSE == opj_j2k_add_mhmarker(
- p_j2k->cstr_index,
- l_marker_handler->id,
- (OPJ_UINT32) opj_stream_tell(p_stream) - l_marker_size - 4,
- l_marker_size + 4)) {
- opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to add mh marker\n");
- return OPJ_FALSE;
- }
-
- /* Try to read 2 bytes (the next marker ID) from stream and copy them into the buffer */
- if (opj_stream_read_data(p_stream,
- p_j2k->m_specific_param.m_decoder.m_header_data, 2, p_manager) != 2) {
- opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
- return OPJ_FALSE;
- }
-
- /* read 2 bytes as the new marker ID */
- opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data,
- &l_current_marker, 2);
- }
-
- if (l_has_siz == 0) {
- opj_event_msg(p_manager, EVT_ERROR,
- "required SIZ marker not found in main header\n");
- return OPJ_FALSE;
- }
- if (l_has_cod == 0) {
- opj_event_msg(p_manager, EVT_ERROR,
- "required COD marker not found in main header\n");
- return OPJ_FALSE;
- }
- if (l_has_qcd == 0) {
- opj_event_msg(p_manager, EVT_ERROR,
- "required QCD marker not found in main header\n");
- return OPJ_FALSE;
- }
-
- if (! opj_j2k_merge_ppm(&(p_j2k->m_cp), p_manager)) {
- opj_event_msg(p_manager, EVT_ERROR, "Failed to merge PPM data\n");
- return OPJ_FALSE;
- }
-
- opj_event_msg(p_manager, EVT_INFO, "Main header has been correctly decoded.\n");
-
- /* Position of the last element if the main header */
- p_j2k->cstr_index->main_head_end = (OPJ_UINT32) opj_stream_tell(p_stream) - 2;
-
- /* Build tile-part index from TLM information */
- opj_j2k_build_tp_index_from_tlm(p_j2k, p_manager);
-
- /* Next step: read a tile-part header */
- p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_TPHSOT;
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_exec(opj_j2k_t * p_j2k,
- opj_procedure_list_t * p_procedure_list,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager)
-{
- OPJ_BOOL(** l_procedure)(opj_j2k_t *, opj_stream_private_t *,
- opj_event_mgr_t *) = 00;
- OPJ_BOOL l_result = OPJ_TRUE;
- OPJ_UINT32 l_nb_proc, i;
-
- /* preconditions*/
- assert(p_procedure_list != 00);
- assert(p_j2k != 00);
- assert(p_stream != 00);
- assert(p_manager != 00);
-
- l_nb_proc = opj_procedure_list_get_nb_procedures(p_procedure_list);
- l_procedure = (OPJ_BOOL(**)(opj_j2k_t *, opj_stream_private_t *,
- opj_event_mgr_t *)) opj_procedure_list_get_first_procedure(p_procedure_list);
-
- for (i = 0; i < l_nb_proc; ++i) {
- l_result = l_result && ((*l_procedure)(p_j2k, p_stream, p_manager));
- ++l_procedure;
- }
-
- /* and clear the procedure list at the end.*/
- opj_procedure_list_clear(p_procedure_list);
- return l_result;
-}
-
-/* FIXME DOC*/
-static OPJ_BOOL opj_j2k_copy_default_tcp_and_create_tcd(opj_j2k_t * p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager
- )
-{
- opj_tcp_t * l_tcp = 00;
- opj_tcp_t * l_default_tcp = 00;
- OPJ_UINT32 l_nb_tiles;
- OPJ_UINT32 i, j;
- opj_tccp_t *l_current_tccp = 00;
- OPJ_UINT32 l_tccp_size;
- OPJ_UINT32 l_mct_size;
- opj_image_t * l_image;
- OPJ_UINT32 l_mcc_records_size, l_mct_records_size;
- opj_mct_data_t * l_src_mct_rec, *l_dest_mct_rec;
- opj_simple_mcc_decorrelation_data_t * l_src_mcc_rec, *l_dest_mcc_rec;
- OPJ_UINT32 l_offset;
-
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_stream != 00);
- assert(p_manager != 00);
-
- OPJ_UNUSED(p_stream);
-
- l_image = p_j2k->m_private_image;
- l_nb_tiles = p_j2k->m_cp.th * p_j2k->m_cp.tw;
- l_tcp = p_j2k->m_cp.tcps;
- l_tccp_size = l_image->numcomps * (OPJ_UINT32)sizeof(opj_tccp_t);
- l_default_tcp = p_j2k->m_specific_param.m_decoder.m_default_tcp;
- l_mct_size = l_image->numcomps * l_image->numcomps * (OPJ_UINT32)sizeof(
- OPJ_FLOAT32);
-
- /* For each tile */
- for (i = 0; i < l_nb_tiles; ++i) {
- /* keep the tile-compo coding parameters pointer of the current tile coding parameters*/
- l_current_tccp = l_tcp->tccps;
- /*Copy default coding parameters into the current tile coding parameters*/
- memcpy(l_tcp, l_default_tcp, sizeof(opj_tcp_t));
- /* Initialize some values of the current tile coding parameters*/
- l_tcp->cod = 0;
- l_tcp->ppt = 0;
- l_tcp->ppt_data = 00;
- l_tcp->m_current_tile_part_number = -1;
- /* Remove memory not owned by this tile in case of early error return. */
- l_tcp->m_mct_decoding_matrix = 00;
- l_tcp->m_nb_max_mct_records = 0;
- l_tcp->m_mct_records = 00;
- l_tcp->m_nb_max_mcc_records = 0;
- l_tcp->m_mcc_records = 00;
- /* Reconnect the tile-compo coding parameters pointer to the current tile coding parameters*/
- l_tcp->tccps = l_current_tccp;
-
- /* Get the mct_decoding_matrix of the dflt_tile_cp and copy them into the current tile cp*/
- if (l_default_tcp->m_mct_decoding_matrix) {
- l_tcp->m_mct_decoding_matrix = (OPJ_FLOAT32*)opj_malloc(l_mct_size);
- if (! l_tcp->m_mct_decoding_matrix) {
- return OPJ_FALSE;
- }
- memcpy(l_tcp->m_mct_decoding_matrix, l_default_tcp->m_mct_decoding_matrix,
- l_mct_size);
- }
-
- /* Get the mct_record of the dflt_tile_cp and copy them into the current tile cp*/
- l_mct_records_size = l_default_tcp->m_nb_max_mct_records * (OPJ_UINT32)sizeof(
- opj_mct_data_t);
- l_tcp->m_mct_records = (opj_mct_data_t*)opj_malloc(l_mct_records_size);
- if (! l_tcp->m_mct_records) {
- return OPJ_FALSE;
- }
- memcpy(l_tcp->m_mct_records, l_default_tcp->m_mct_records, l_mct_records_size);
-
- /* Copy the mct record data from dflt_tile_cp to the current tile*/
- l_src_mct_rec = l_default_tcp->m_mct_records;
- l_dest_mct_rec = l_tcp->m_mct_records;
-
- for (j = 0; j < l_default_tcp->m_nb_mct_records; ++j) {
-
- if (l_src_mct_rec->m_data) {
-
- l_dest_mct_rec->m_data = (OPJ_BYTE*) opj_malloc(l_src_mct_rec->m_data_size);
- if (! l_dest_mct_rec->m_data) {
- return OPJ_FALSE;
- }
- memcpy(l_dest_mct_rec->m_data, l_src_mct_rec->m_data,
- l_src_mct_rec->m_data_size);
- }
-
- ++l_src_mct_rec;
- ++l_dest_mct_rec;
- /* Update with each pass to free exactly what has been allocated on early return. */
- l_tcp->m_nb_max_mct_records += 1;
- }
-
- /* Get the mcc_record of the dflt_tile_cp and copy them into the current tile cp*/
- l_mcc_records_size = l_default_tcp->m_nb_max_mcc_records * (OPJ_UINT32)sizeof(
- opj_simple_mcc_decorrelation_data_t);
- l_tcp->m_mcc_records = (opj_simple_mcc_decorrelation_data_t*) opj_malloc(
- l_mcc_records_size);
- if (! l_tcp->m_mcc_records) {
- return OPJ_FALSE;
- }
- memcpy(l_tcp->m_mcc_records, l_default_tcp->m_mcc_records, l_mcc_records_size);
- l_tcp->m_nb_max_mcc_records = l_default_tcp->m_nb_max_mcc_records;
-
- /* Copy the mcc record data from dflt_tile_cp to the current tile*/
- l_src_mcc_rec = l_default_tcp->m_mcc_records;
- l_dest_mcc_rec = l_tcp->m_mcc_records;
-
- for (j = 0; j < l_default_tcp->m_nb_max_mcc_records; ++j) {
-
- if (l_src_mcc_rec->m_decorrelation_array) {
- l_offset = (OPJ_UINT32)(l_src_mcc_rec->m_decorrelation_array -
- l_default_tcp->m_mct_records);
- l_dest_mcc_rec->m_decorrelation_array = l_tcp->m_mct_records + l_offset;
- }
-
- if (l_src_mcc_rec->m_offset_array) {
- l_offset = (OPJ_UINT32)(l_src_mcc_rec->m_offset_array -
- l_default_tcp->m_mct_records);
- l_dest_mcc_rec->m_offset_array = l_tcp->m_mct_records + l_offset;
- }
-
- ++l_src_mcc_rec;
- ++l_dest_mcc_rec;
- }
-
- /* Copy all the dflt_tile_compo_cp to the current tile cp */
- memcpy(l_current_tccp, l_default_tcp->tccps, l_tccp_size);
-
- /* Move to next tile cp*/
- ++l_tcp;
- }
-
- /* Create the current tile decoder*/
- p_j2k->m_tcd = opj_tcd_create(OPJ_TRUE);
- if (! p_j2k->m_tcd) {
- return OPJ_FALSE;
- }
-
- if (!opj_tcd_init(p_j2k->m_tcd, l_image, &(p_j2k->m_cp), p_j2k->m_tp)) {
- opj_tcd_destroy(p_j2k->m_tcd);
- p_j2k->m_tcd = 00;
- opj_event_msg(p_manager, EVT_ERROR, "Cannot decode tile, memory error\n");
- return OPJ_FALSE;
- }
-
- return OPJ_TRUE;
-}
-
-static const opj_dec_memory_marker_handler_t * opj_j2k_get_marker_handler(
- OPJ_UINT32 p_id)
-{
- const opj_dec_memory_marker_handler_t *e;
- for (e = j2k_memory_marker_handler_tab; e->id != 0; ++e) {
- if (e->id == p_id) {
- break; /* we find a handler corresponding to the marker ID*/
- }
- }
- return e;
-}
-
-void opj_j2k_destroy(opj_j2k_t *p_j2k)
-{
- if (p_j2k == 00) {
- return;
- }
-
- if (p_j2k->m_is_decoder) {
-
- if (p_j2k->m_specific_param.m_decoder.m_default_tcp != 00) {
- opj_j2k_tcp_destroy(p_j2k->m_specific_param.m_decoder.m_default_tcp);
- opj_free(p_j2k->m_specific_param.m_decoder.m_default_tcp);
- p_j2k->m_specific_param.m_decoder.m_default_tcp = 00;
- }
-
- if (p_j2k->m_specific_param.m_decoder.m_header_data != 00) {
- opj_free(p_j2k->m_specific_param.m_decoder.m_header_data);
- p_j2k->m_specific_param.m_decoder.m_header_data = 00;
- p_j2k->m_specific_param.m_decoder.m_header_data_size = 0;
- }
-
- opj_free(p_j2k->m_specific_param.m_decoder.m_comps_indices_to_decode);
- p_j2k->m_specific_param.m_decoder.m_comps_indices_to_decode = 00;
- p_j2k->m_specific_param.m_decoder.m_numcomps_to_decode = 0;
-
- opj_free(p_j2k->m_specific_param.m_decoder.m_tlm.m_tile_part_infos);
- p_j2k->m_specific_param.m_decoder.m_tlm.m_tile_part_infos = NULL;
-
- opj_free(p_j2k->m_specific_param.m_decoder.m_intersecting_tile_parts_offset);
- p_j2k->m_specific_param.m_decoder.m_intersecting_tile_parts_offset = NULL;
-
- } else {
-
- if (p_j2k->m_specific_param.m_encoder.m_encoded_tile_data) {
- opj_free(p_j2k->m_specific_param.m_encoder.m_encoded_tile_data);
- p_j2k->m_specific_param.m_encoder.m_encoded_tile_data = 00;
- }
-
- if (p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer) {
- opj_free(p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer);
- p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer = 00;
- p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_current = 00;
- }
-
- if (p_j2k->m_specific_param.m_encoder.m_header_tile_data) {
- opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data);
- p_j2k->m_specific_param.m_encoder.m_header_tile_data = 00;
- p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0;
- }
- }
-
- opj_tcd_destroy(p_j2k->m_tcd);
-
- opj_j2k_cp_destroy(&(p_j2k->m_cp));
- memset(&(p_j2k->m_cp), 0, sizeof(opj_cp_t));
-
- opj_procedure_list_destroy(p_j2k->m_procedure_list);
- p_j2k->m_procedure_list = 00;
-
- opj_procedure_list_destroy(p_j2k->m_validation_list);
- p_j2k->m_procedure_list = 00;
-
- j2k_destroy_cstr_index(p_j2k->cstr_index);
- p_j2k->cstr_index = NULL;
-
- opj_image_destroy(p_j2k->m_private_image);
- p_j2k->m_private_image = NULL;
-
- opj_image_destroy(p_j2k->m_output_image);
- p_j2k->m_output_image = NULL;
-
- opj_thread_pool_destroy(p_j2k->m_tp);
- p_j2k->m_tp = NULL;
-
- opj_free(p_j2k);
-}
-
-void j2k_destroy_cstr_index(opj_codestream_index_t *p_cstr_ind)
-{
- if (p_cstr_ind) {
-
- if (p_cstr_ind->marker) {
- opj_free(p_cstr_ind->marker);
- p_cstr_ind->marker = NULL;
- }
-
- if (p_cstr_ind->tile_index) {
- OPJ_UINT32 it_tile = 0;
-
- for (it_tile = 0; it_tile < p_cstr_ind->nb_of_tiles; it_tile++) {
-
- if (p_cstr_ind->tile_index[it_tile].packet_index) {
- opj_free(p_cstr_ind->tile_index[it_tile].packet_index);
- p_cstr_ind->tile_index[it_tile].packet_index = NULL;
- }
-
- if (p_cstr_ind->tile_index[it_tile].tp_index) {
- opj_free(p_cstr_ind->tile_index[it_tile].tp_index);
- p_cstr_ind->tile_index[it_tile].tp_index = NULL;
- }
-
- if (p_cstr_ind->tile_index[it_tile].marker) {
- opj_free(p_cstr_ind->tile_index[it_tile].marker);
- p_cstr_ind->tile_index[it_tile].marker = NULL;
-
- }
- }
-
- opj_free(p_cstr_ind->tile_index);
- p_cstr_ind->tile_index = NULL;
- }
-
- opj_free(p_cstr_ind);
- }
-}
-
-static void opj_j2k_tcp_destroy(opj_tcp_t *p_tcp)
-{
- if (p_tcp == 00) {
- return;
- }
-
- if (p_tcp->ppt_markers != 00) {
- OPJ_UINT32 i;
- for (i = 0U; i < p_tcp->ppt_markers_count; ++i) {
- if (p_tcp->ppt_markers[i].m_data != NULL) {
- opj_free(p_tcp->ppt_markers[i].m_data);
- }
- }
- p_tcp->ppt_markers_count = 0U;
- opj_free(p_tcp->ppt_markers);
- p_tcp->ppt_markers = NULL;
- }
-
- if (p_tcp->ppt_buffer != 00) {
- opj_free(p_tcp->ppt_buffer);
- p_tcp->ppt_buffer = 00;
- }
-
- if (p_tcp->tccps != 00) {
- opj_free(p_tcp->tccps);
- p_tcp->tccps = 00;
- }
-
- if (p_tcp->m_mct_coding_matrix != 00) {
- opj_free(p_tcp->m_mct_coding_matrix);
- p_tcp->m_mct_coding_matrix = 00;
- }
-
- if (p_tcp->m_mct_decoding_matrix != 00) {
- opj_free(p_tcp->m_mct_decoding_matrix);
- p_tcp->m_mct_decoding_matrix = 00;
- }
-
- if (p_tcp->m_mcc_records) {
- opj_free(p_tcp->m_mcc_records);
- p_tcp->m_mcc_records = 00;
- p_tcp->m_nb_max_mcc_records = 0;
- p_tcp->m_nb_mcc_records = 0;
- }
-
- if (p_tcp->m_mct_records) {
- opj_mct_data_t * l_mct_data = p_tcp->m_mct_records;
- OPJ_UINT32 i;
-
- for (i = 0; i < p_tcp->m_nb_mct_records; ++i) {
- if (l_mct_data->m_data) {
- opj_free(l_mct_data->m_data);
- l_mct_data->m_data = 00;
- }
-
- ++l_mct_data;
- }
-
- opj_free(p_tcp->m_mct_records);
- p_tcp->m_mct_records = 00;
- }
-
- if (p_tcp->mct_norms != 00) {
- opj_free(p_tcp->mct_norms);
- p_tcp->mct_norms = 00;
- }
-
- opj_j2k_tcp_data_destroy(p_tcp);
-
-}
-
-static void opj_j2k_tcp_data_destroy(opj_tcp_t *p_tcp)
-{
- if (p_tcp->m_data) {
- opj_free(p_tcp->m_data);
- p_tcp->m_data = NULL;
- p_tcp->m_data_size = 0;
- }
-}
-
-static void opj_j2k_cp_destroy(opj_cp_t *p_cp)
-{
- OPJ_UINT32 l_nb_tiles;
- opj_tcp_t * l_current_tile = 00;
-
- if (p_cp == 00) {
- return;
- }
- if (p_cp->tcps != 00) {
- OPJ_UINT32 i;
- l_current_tile = p_cp->tcps;
- l_nb_tiles = p_cp->th * p_cp->tw;
-
- for (i = 0U; i < l_nb_tiles; ++i) {
- opj_j2k_tcp_destroy(l_current_tile);
- ++l_current_tile;
- }
- opj_free(p_cp->tcps);
- p_cp->tcps = 00;
- }
- if (p_cp->ppm_markers != 00) {
- OPJ_UINT32 i;
- for (i = 0U; i < p_cp->ppm_markers_count; ++i) {
- if (p_cp->ppm_markers[i].m_data != NULL) {
- opj_free(p_cp->ppm_markers[i].m_data);
- }
- }
- p_cp->ppm_markers_count = 0U;
- opj_free(p_cp->ppm_markers);
- p_cp->ppm_markers = NULL;
- }
- opj_free(p_cp->ppm_buffer);
- p_cp->ppm_buffer = 00;
- p_cp->ppm_data =
- NULL; /* ppm_data belongs to the allocated buffer pointed by ppm_buffer */
- opj_free(p_cp->comment);
- p_cp->comment = 00;
- if (! p_cp->m_is_decoder) {
- opj_free(p_cp->m_specific_param.m_enc.m_matrice);
- p_cp->m_specific_param.m_enc.m_matrice = 00;
- }
-}
-
-static OPJ_BOOL opj_j2k_need_nb_tile_parts_correction(opj_stream_private_t
- *p_stream, OPJ_UINT32 tile_no, OPJ_BOOL* p_correction_needed,
- opj_event_mgr_t * p_manager)
-{
- OPJ_BYTE l_header_data[10];
- OPJ_OFF_T l_stream_pos_backup;
- OPJ_UINT32 l_current_marker;
- OPJ_UINT32 l_marker_size;
- OPJ_UINT32 l_tile_no, l_tot_len, l_current_part, l_num_parts;
-
- /* initialize to no correction needed */
- *p_correction_needed = OPJ_FALSE;
-
- if (!opj_stream_has_seek(p_stream)) {
- /* We can't do much in this case, seek is needed */
- return OPJ_TRUE;
- }
-
- l_stream_pos_backup = opj_stream_tell(p_stream);
- if (l_stream_pos_backup == -1) {
- /* let's do nothing */
- return OPJ_TRUE;
- }
-
- for (;;) {
- /* Try to read 2 bytes (the next marker ID) from stream and copy them into the buffer */
- if (opj_stream_read_data(p_stream, l_header_data, 2, p_manager) != 2) {
- /* assume all is OK */
- if (! opj_stream_seek(p_stream, l_stream_pos_backup, p_manager)) {
- return OPJ_FALSE;
- }
- return OPJ_TRUE;
- }
-
- /* Read 2 bytes from buffer as the new marker ID */
- opj_read_bytes(l_header_data, &l_current_marker, 2);
-
- if (l_current_marker != J2K_MS_SOT) {
- /* assume all is OK */
- if (! opj_stream_seek(p_stream, l_stream_pos_backup, p_manager)) {
- return OPJ_FALSE;
- }
- return OPJ_TRUE;
- }
-
- /* Try to read 2 bytes (the marker size) from stream and copy them into the buffer */
- if (opj_stream_read_data(p_stream, l_header_data, 2, p_manager) != 2) {
- opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
- return OPJ_FALSE;
- }
-
- /* Read 2 bytes from the buffer as the marker size */
- opj_read_bytes(l_header_data, &l_marker_size, 2);
-
- /* Check marker size for SOT Marker */
- if (l_marker_size != 10) {
- opj_event_msg(p_manager, EVT_ERROR, "Inconsistent marker size\n");
- return OPJ_FALSE;
- }
- l_marker_size -= 2;
-
- if (opj_stream_read_data(p_stream, l_header_data, l_marker_size,
- p_manager) != l_marker_size) {
- opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
- return OPJ_FALSE;
- }
-
- if (! opj_j2k_get_sot_values(l_header_data, l_marker_size, &l_tile_no,
- &l_tot_len, &l_current_part, &l_num_parts, p_manager)) {
- return OPJ_FALSE;
- }
-
- if (l_tile_no == tile_no) {
- /* we found what we were looking for */
- break;
- }
-
- if (l_tot_len < 14U) {
- /* last SOT until EOC or invalid Psot value */
- /* assume all is OK */
- if (! opj_stream_seek(p_stream, l_stream_pos_backup, p_manager)) {
- return OPJ_FALSE;
- }
- return OPJ_TRUE;
- }
- l_tot_len -= 12U;
- /* look for next SOT marker */
- if (opj_stream_skip(p_stream, (OPJ_OFF_T)(l_tot_len),
- p_manager) != (OPJ_OFF_T)(l_tot_len)) {
- /* assume all is OK */
- if (! opj_stream_seek(p_stream, l_stream_pos_backup, p_manager)) {
- return OPJ_FALSE;
- }
- return OPJ_TRUE;
- }
- }
-
- /* check for correction */
- if (l_current_part == l_num_parts) {
- *p_correction_needed = OPJ_TRUE;
- }
-
- if (! opj_stream_seek(p_stream, l_stream_pos_backup, p_manager)) {
- return OPJ_FALSE;
- }
- return OPJ_TRUE;
-}
-
-OPJ_BOOL opj_j2k_read_tile_header(opj_j2k_t * p_j2k,
- OPJ_UINT32 * p_tile_index,
- OPJ_UINT32 * p_data_size,
- OPJ_INT32 * p_tile_x0, OPJ_INT32 * p_tile_y0,
- OPJ_INT32 * p_tile_x1, OPJ_INT32 * p_tile_y1,
- OPJ_UINT32 * p_nb_comps,
- OPJ_BOOL * p_go_on,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager)
-{
- OPJ_UINT32 l_current_marker = J2K_MS_SOT;
- OPJ_UINT32 l_marker_size;
- const opj_dec_memory_marker_handler_t * l_marker_handler = 00;
- opj_tcp_t * l_tcp = NULL;
- const OPJ_UINT32 l_nb_tiles = p_j2k->m_cp.tw * p_j2k->m_cp.th;
-
- /* preconditions */
- assert(p_stream != 00);
- assert(p_j2k != 00);
- assert(p_manager != 00);
-
- /* Reach the End Of Codestream ?*/
- if (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_EOC) {
- l_current_marker = J2K_MS_EOC;
- }
- /* We need to encounter a SOT marker (a new tile-part header) */
- else if (p_j2k->m_specific_param.m_decoder.m_state != J2K_STATE_TPHSOT) {
- return OPJ_FALSE;
- }
-
- /* Read into the codestream until reach the EOC or ! can_decode ??? FIXME */
- while ((!p_j2k->m_specific_param.m_decoder.m_can_decode) &&
- (l_current_marker != J2K_MS_EOC)) {
-
- if (p_j2k->m_specific_param.m_decoder.m_num_intersecting_tile_parts > 0 &&
- p_j2k->m_specific_param.m_decoder.m_idx_intersecting_tile_parts <
- p_j2k->m_specific_param.m_decoder.m_num_intersecting_tile_parts) {
- OPJ_OFF_T next_tp_sot_pos;
-
- next_tp_sot_pos =
- p_j2k->m_specific_param.m_decoder.m_intersecting_tile_parts_offset[p_j2k->m_specific_param.m_decoder.m_idx_intersecting_tile_parts];
- ++p_j2k->m_specific_param.m_decoder.m_idx_intersecting_tile_parts;
- if (!(opj_stream_read_seek(p_stream,
- next_tp_sot_pos,
- p_manager))) {
- opj_event_msg(p_manager, EVT_ERROR, "Problem with seek function\n");
- return OPJ_FALSE;
- }
-
- /* Try to read 2 bytes (the marker ID) from stream and copy them into the buffer */
- if (opj_stream_read_data(p_stream,
- p_j2k->m_specific_param.m_decoder.m_header_data, 2, p_manager) != 2) {
- opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
- return OPJ_FALSE;
- }
-
- /* Read 2 bytes from the buffer as the marker ID */
- opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data,
- &l_current_marker,
- 2);
-
- if (l_current_marker != J2K_MS_SOT) {
- opj_event_msg(p_manager, EVT_ERROR, "Did not get expected SOT marker\n");
- return OPJ_FALSE;
- }
- }
-
- /* Try to read until the Start Of Data is detected */
- while (l_current_marker != J2K_MS_SOD) {
-
- if (opj_stream_get_number_byte_left(p_stream) == 0) {
- p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_NEOC;
- break;
- }
-
- /* Try to read 2 bytes (the marker size) from stream and copy them into the buffer */
- if (opj_stream_read_data(p_stream,
- p_j2k->m_specific_param.m_decoder.m_header_data, 2, p_manager) != 2) {
- opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
- return OPJ_FALSE;
- }
-
- /* Read 2 bytes from the buffer as the marker size */
- opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data, &l_marker_size,
- 2);
-
- /* Check marker size (does not include marker ID but includes marker size) */
- if (l_marker_size < 2) {
- opj_event_msg(p_manager, EVT_ERROR, "Inconsistent marker size\n");
- return OPJ_FALSE;
- }
-
- /* cf. https://code.google.com/p/openjpeg/issues/detail?id=226 */
- if (l_current_marker == 0x8080 &&
- opj_stream_get_number_byte_left(p_stream) == 0) {
- p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_NEOC;
- break;
- }
-
- /* Why this condition? FIXME */
- if ((p_j2k->m_specific_param.m_decoder.m_state & J2K_STATE_TPH) &&
- p_j2k->m_specific_param.m_decoder.m_sot_length != 0) {
- if (p_j2k->m_specific_param.m_decoder.m_sot_length < l_marker_size + 2) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Sot length is less than marker size + marker ID\n");
- return OPJ_FALSE;
- }
- p_j2k->m_specific_param.m_decoder.m_sot_length -= (l_marker_size + 2);
- }
- l_marker_size -= 2; /* Subtract the size of the marker ID already read */
-
- /* Get the marker handler from the marker ID */
- l_marker_handler = opj_j2k_get_marker_handler(l_current_marker);
-
- /* Check if the marker is known and if it is the right place to find it */
- if (!(p_j2k->m_specific_param.m_decoder.m_state & l_marker_handler->states)) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Marker is not compliant with its position\n");
- return OPJ_FALSE;
- }
- /* FIXME manage case of unknown marker as in the main header ? */
-
- /* Check if the marker size is compatible with the header data size */
- if (l_marker_size > p_j2k->m_specific_param.m_decoder.m_header_data_size) {
- OPJ_BYTE *new_header_data = NULL;
- /* If we are here, this means we consider this marker as known & we will read it */
- /* Check enough bytes left in stream before allocation */
- if ((OPJ_OFF_T)l_marker_size > opj_stream_get_number_byte_left(p_stream)) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Marker size inconsistent with stream length\n");
- return OPJ_FALSE;
- }
- new_header_data = (OPJ_BYTE *) opj_realloc(
- p_j2k->m_specific_param.m_decoder.m_header_data, l_marker_size);
- if (! new_header_data) {
- opj_free(p_j2k->m_specific_param.m_decoder.m_header_data);
- p_j2k->m_specific_param.m_decoder.m_header_data = NULL;
- p_j2k->m_specific_param.m_decoder.m_header_data_size = 0;
- opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to read header\n");
- return OPJ_FALSE;
- }
- p_j2k->m_specific_param.m_decoder.m_header_data = new_header_data;
- p_j2k->m_specific_param.m_decoder.m_header_data_size = l_marker_size;
- }
-
- /* Try to read the rest of the marker segment from stream and copy them into the buffer */
- if (opj_stream_read_data(p_stream,
- p_j2k->m_specific_param.m_decoder.m_header_data, l_marker_size,
- p_manager) != l_marker_size) {
- opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
- return OPJ_FALSE;
- }
-
- if (!l_marker_handler->handler) {
- /* See issue #175 */
- opj_event_msg(p_manager, EVT_ERROR, "Not sure how that happened.\n");
- return OPJ_FALSE;
- }
- /* Read the marker segment with the correct marker handler */
- if (!(*(l_marker_handler->handler))(p_j2k,
- p_j2k->m_specific_param.m_decoder.m_header_data, l_marker_size, p_manager)) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Fail to read the current marker segment (%#x)\n", l_current_marker);
- return OPJ_FALSE;
- }
-
- /* Add the marker to the codestream index*/
- if (OPJ_FALSE == opj_j2k_add_tlmarker(p_j2k->m_current_tile_number,
- p_j2k->cstr_index,
- l_marker_handler->id,
- (OPJ_UINT32) opj_stream_tell(p_stream) - l_marker_size - 4,
- l_marker_size + 4)) {
- opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to add tl marker\n");
- return OPJ_FALSE;
- }
-
- /* Keep the position of the last SOT marker read */
- if (l_marker_handler->id == J2K_MS_SOT) {
- OPJ_UINT32 sot_pos = (OPJ_UINT32) opj_stream_tell(p_stream) - l_marker_size - 4
- ;
- if (sot_pos > p_j2k->m_specific_param.m_decoder.m_last_sot_read_pos) {
- p_j2k->m_specific_param.m_decoder.m_last_sot_read_pos = sot_pos;
- }
- }
-
- if (p_j2k->m_specific_param.m_decoder.m_skip_data) {
- /* Skip the rest of the tile part header*/
- if (opj_stream_skip(p_stream, p_j2k->m_specific_param.m_decoder.m_sot_length,
- p_manager) != p_j2k->m_specific_param.m_decoder.m_sot_length) {
- opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
- return OPJ_FALSE;
- }
- l_current_marker = J2K_MS_SOD; /* Normally we reached a SOD */
- } else {
- /* Try to read 2 bytes (the next marker ID) from stream and copy them into the buffer*/
- if (opj_stream_read_data(p_stream,
- p_j2k->m_specific_param.m_decoder.m_header_data, 2, p_manager) != 2) {
- opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
- return OPJ_FALSE;
- }
- /* Read 2 bytes from the buffer as the new marker ID */
- opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data,
- &l_current_marker, 2);
- }
- }
- if (opj_stream_get_number_byte_left(p_stream) == 0
- && p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_NEOC) {
- break;
- }
-
- /* If we didn't skip data before, we need to read the SOD marker*/
- if (! p_j2k->m_specific_param.m_decoder.m_skip_data) {
- /* Try to read the SOD marker and skip data ? FIXME */
- if (! opj_j2k_read_sod(p_j2k, p_stream, p_manager)) {
- return OPJ_FALSE;
- }
-
- /* Check if we can use the TLM index to access the next tile-part */
- if (!p_j2k->m_specific_param.m_decoder.m_can_decode &&
- p_j2k->m_specific_param.m_decoder.m_tile_ind_to_dec >= 0 &&
- p_j2k->m_current_tile_number == (OPJ_UINT32)
- p_j2k->m_specific_param.m_decoder.m_tile_ind_to_dec &&
- !p_j2k->m_specific_param.m_decoder.m_tlm.m_is_invalid &&
- opj_stream_has_seek(p_stream)) {
- l_tcp = p_j2k->m_cp.tcps + p_j2k->m_current_tile_number;
- if (l_tcp->m_nb_tile_parts ==
- p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].nb_tps &&
- (OPJ_UINT32)l_tcp->m_current_tile_part_number + 1 < l_tcp->m_nb_tile_parts) {
- const OPJ_OFF_T next_tp_sot_pos = p_j2k->cstr_index->tile_index[
- p_j2k->m_current_tile_number].tp_index[l_tcp->m_current_tile_part_number +
- 1].start_pos;
-
- if (next_tp_sot_pos != opj_stream_tell(p_stream)) {
-#if 0
- opj_event_msg(p_manager, EVT_INFO,
- "opj_j2k_read_tile_header(tile=%u): seek to tile part %u at %" PRId64 "\n",
- p_j2k->m_current_tile_number,
- l_tcp->m_current_tile_part_number + 1,
- next_tp_sot_pos);
-#endif
-
- if (!(opj_stream_read_seek(p_stream,
- next_tp_sot_pos,
- p_manager))) {
- opj_event_msg(p_manager, EVT_ERROR, "Problem with seek function\n");
- return OPJ_FALSE;
- }
- }
-
- /* Try to read 2 bytes (the marker ID) from stream and copy them into the buffer */
- if (opj_stream_read_data(p_stream,
- p_j2k->m_specific_param.m_decoder.m_header_data, 2, p_manager) != 2) {
- opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
- return OPJ_FALSE;
- }
-
- /* Read 2 bytes from the buffer as the marker ID */
- opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data,
- &l_current_marker,
- 2);
-
- if (l_current_marker != J2K_MS_SOT) {
- opj_event_msg(p_manager, EVT_ERROR, "Did not get expected SOT marker\n");
- return OPJ_FALSE;
- }
-
- continue;
- }
- }
-
- if (p_j2k->m_specific_param.m_decoder.m_can_decode &&
- !p_j2k->m_specific_param.m_decoder.m_nb_tile_parts_correction_checked) {
- /* Issue 254 */
- OPJ_BOOL l_correction_needed = OPJ_FALSE;
-
- p_j2k->m_specific_param.m_decoder.m_nb_tile_parts_correction_checked = 1;
- if (p_j2k->m_cp.tcps[p_j2k->m_current_tile_number].m_nb_tile_parts == 1) {
- /* Skip opj_j2k_need_nb_tile_parts_correction() if there is
- * only a single tile part declared. The
- * opj_j2k_need_nb_tile_parts_correction() hack was needed
- * for files with 5 declared tileparts (where they were
- * actually 6).
- * Doing it systematically hurts performance when reading
- * Sentinel2 L1C JPEG2000 files as explained in
- * https://lists.osgeo.org/pipermail/gdal-dev/2024-November/059805.html
- */
- } else if (!opj_j2k_need_nb_tile_parts_correction(p_stream,
- p_j2k->m_current_tile_number, &l_correction_needed, p_manager)) {
- opj_event_msg(p_manager, EVT_ERROR,
- "opj_j2k_apply_nb_tile_parts_correction error\n");
- return OPJ_FALSE;
- }
- if (l_correction_needed) {
- OPJ_UINT32 l_tile_no;
-
- p_j2k->m_specific_param.m_decoder.m_can_decode = 0;
- p_j2k->m_specific_param.m_decoder.m_nb_tile_parts_correction = 1;
- /* correct tiles */
- for (l_tile_no = 0U; l_tile_no < l_nb_tiles; ++l_tile_no) {
- if (p_j2k->m_cp.tcps[l_tile_no].m_nb_tile_parts != 0U) {
- p_j2k->m_cp.tcps[l_tile_no].m_nb_tile_parts += 1;
- }
- }
- opj_event_msg(p_manager, EVT_WARNING,
- "Non conformant codestream TPsot==TNsot.\n");
- }
- }
- } else {
- /* Indicate we will try to read a new tile-part header*/
- p_j2k->m_specific_param.m_decoder.m_skip_data = 0;
- p_j2k->m_specific_param.m_decoder.m_can_decode = 0;
- p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_TPHSOT;
- }
-
- if (! p_j2k->m_specific_param.m_decoder.m_can_decode) {
- /* Try to read 2 bytes (the next marker ID) from stream and copy them into the buffer */
- if (opj_stream_read_data(p_stream,
- p_j2k->m_specific_param.m_decoder.m_header_data, 2, p_manager) != 2) {
-
- /* Deal with likely non conformant SPOT6 files, where the last */
- /* row of tiles have TPsot == 0 and TNsot == 0, and missing EOC, */
- /* but no other tile-parts were found. */
- if (p_j2k->m_current_tile_number + 1 == l_nb_tiles) {
- OPJ_UINT32 l_tile_no;
- for (l_tile_no = 0U; l_tile_no < l_nb_tiles; ++l_tile_no) {
- if (p_j2k->m_cp.tcps[l_tile_no].m_current_tile_part_number == 0 &&
- p_j2k->m_cp.tcps[l_tile_no].m_nb_tile_parts == 0) {
- break;
- }
- }
- if (l_tile_no < l_nb_tiles) {
- opj_event_msg(p_manager, EVT_INFO,
- "Tile %u has TPsot == 0 and TNsot == 0, "
- "but no other tile-parts were found. "
- "EOC is also missing.\n",
- l_tile_no);
- p_j2k->m_current_tile_number = l_tile_no;
- l_current_marker = J2K_MS_EOC;
- p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_EOC;
- break;
- }
- }
-
- opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
- return OPJ_FALSE;
- }
-
- /* Read 2 bytes from buffer as the new marker ID */
- opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data,
- &l_current_marker, 2);
- }
- }
-
- /* Current marker is the EOC marker ?*/
- if (l_current_marker == J2K_MS_EOC) {
- if (p_j2k->m_specific_param.m_decoder.m_state != J2K_STATE_EOC) {
- p_j2k->m_current_tile_number = 0;
- p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_EOC;
- }
- }
-
- /* Deal with tiles that have a single tile-part with TPsot == 0 and TNsot == 0 */
- if (! p_j2k->m_specific_param.m_decoder.m_can_decode) {
- l_tcp = p_j2k->m_cp.tcps + p_j2k->m_current_tile_number;
-
- while ((p_j2k->m_current_tile_number < l_nb_tiles) && (l_tcp->m_data == 00)) {
- ++p_j2k->m_current_tile_number;
- ++l_tcp;
- }
-
- if (p_j2k->m_current_tile_number == l_nb_tiles) {
- *p_go_on = OPJ_FALSE;
- return OPJ_TRUE;
- }
- }
-
- if (! opj_j2k_merge_ppt(p_j2k->m_cp.tcps + p_j2k->m_current_tile_number,
- p_manager)) {
- opj_event_msg(p_manager, EVT_ERROR, "Failed to merge PPT data\n");
- return OPJ_FALSE;
- }
- /*FIXME ???*/
- if (! opj_tcd_init_decode_tile(p_j2k->m_tcd, p_j2k->m_current_tile_number,
- p_manager)) {
- opj_event_msg(p_manager, EVT_ERROR, "Cannot decode tile, memory error\n");
- return OPJ_FALSE;
- }
-
- opj_event_msg(p_manager, EVT_INFO, "Header of tile %d / %d has been read.\n",
- p_j2k->m_current_tile_number + 1, (p_j2k->m_cp.th * p_j2k->m_cp.tw));
-
- *p_tile_index = p_j2k->m_current_tile_number;
- *p_go_on = OPJ_TRUE;
- if (p_data_size) {
- /* For internal use in j2k.c, we don't need this */
- /* This is just needed for folks using the opj_read_tile_header() / opj_decode_tile_data() combo */
- *p_data_size = opj_tcd_get_decoded_tile_size(p_j2k->m_tcd, OPJ_FALSE);
- if (*p_data_size == UINT_MAX) {
- return OPJ_FALSE;
- }
- }
- *p_tile_x0 = p_j2k->m_tcd->tcd_image->tiles->x0;
- *p_tile_y0 = p_j2k->m_tcd->tcd_image->tiles->y0;
- *p_tile_x1 = p_j2k->m_tcd->tcd_image->tiles->x1;
- *p_tile_y1 = p_j2k->m_tcd->tcd_image->tiles->y1;
- *p_nb_comps = p_j2k->m_tcd->tcd_image->tiles->numcomps;
-
- p_j2k->m_specific_param.m_decoder.m_state |= J2K_STATE_DATA;
-
- return OPJ_TRUE;
-}
-
-OPJ_BOOL opj_j2k_decode_tile(opj_j2k_t * p_j2k,
- OPJ_UINT32 p_tile_index,
- OPJ_BYTE * p_data,
- OPJ_UINT32 p_data_size,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager)
-{
- OPJ_UINT32 l_current_marker;
- OPJ_BYTE l_data [2];
- opj_tcp_t * l_tcp;
- opj_image_t* l_image_for_bounds;
-
- /* preconditions */
- assert(p_stream != 00);
- assert(p_j2k != 00);
- assert(p_manager != 00);
-
- if (!(p_j2k->m_specific_param.m_decoder.m_state & J2K_STATE_DATA)
- || (p_tile_index != p_j2k->m_current_tile_number)) {
- return OPJ_FALSE;
- }
-
- l_tcp = &(p_j2k->m_cp.tcps[p_tile_index]);
- if (! l_tcp->m_data) {
- opj_j2k_tcp_destroy(l_tcp);
- return OPJ_FALSE;
- }
-
- /* When using the opj_read_tile_header / opj_decode_tile_data API */
- /* such as in test_tile_decoder, m_output_image is NULL, so fall back */
- /* to the full image dimension. This is a bit surprising that */
- /* opj_set_decode_area() is only used to determine intersecting tiles, */
- /* but full tile decoding is done */
- l_image_for_bounds = p_j2k->m_output_image ? p_j2k->m_output_image :
- p_j2k->m_private_image;
- if (! opj_tcd_decode_tile(p_j2k->m_tcd,
- l_image_for_bounds->x0,
- l_image_for_bounds->y0,
- l_image_for_bounds->x1,
- l_image_for_bounds->y1,
- p_j2k->m_specific_param.m_decoder.m_numcomps_to_decode,
- p_j2k->m_specific_param.m_decoder.m_comps_indices_to_decode,
- l_tcp->m_data,
- l_tcp->m_data_size,
- p_tile_index,
- p_j2k->cstr_index, p_manager)) {
- opj_j2k_tcp_destroy(l_tcp);
- p_j2k->m_specific_param.m_decoder.m_state |= J2K_STATE_ERR;
- opj_event_msg(p_manager, EVT_ERROR, "Failed to decode.\n");
- return OPJ_FALSE;
- }
-
- /* p_data can be set to NULL when the call will take care of using */
- /* itself the TCD data. This is typically the case for whole single */
- /* tile decoding optimization. */
- if (p_data != NULL) {
- if (! opj_tcd_update_tile_data(p_j2k->m_tcd, p_data, p_data_size)) {
- return OPJ_FALSE;
- }
-
- /* To avoid to destroy the tcp which can be useful when we try to decode a tile decoded before (cf j2k_random_tile_access)
- * we destroy just the data which will be re-read in read_tile_header*/
- /*opj_j2k_tcp_destroy(l_tcp);
- p_j2k->m_tcd->tcp = 0;*/
- opj_j2k_tcp_data_destroy(l_tcp);
- }
-
- p_j2k->m_specific_param.m_decoder.m_can_decode = 0;
- p_j2k->m_specific_param.m_decoder.m_state &= (~(OPJ_UINT32)J2K_STATE_DATA);
-
- if (opj_stream_get_number_byte_left(p_stream) == 0
- && p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_NEOC) {
- return OPJ_TRUE;
- }
-
- if (p_j2k->m_specific_param.m_decoder.m_state != J2K_STATE_EOC) {
- if (opj_stream_read_data(p_stream, l_data, 2, p_manager) != 2) {
- opj_event_msg(p_manager, p_j2k->m_cp.strict ? EVT_ERROR : EVT_WARNING,
- "Stream too short\n");
- return p_j2k->m_cp.strict ? OPJ_FALSE : OPJ_TRUE;
- }
- opj_read_bytes(l_data, &l_current_marker, 2);
-
- if (l_current_marker == J2K_MS_EOC) {
- p_j2k->m_current_tile_number = 0;
- p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_EOC;
- } else if (l_current_marker != J2K_MS_SOT) {
- if (opj_stream_get_number_byte_left(p_stream) == 0) {
- p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_NEOC;
- opj_event_msg(p_manager, EVT_WARNING, "Stream does not end with EOC\n");
- return OPJ_TRUE;
- }
- opj_event_msg(p_manager, EVT_ERROR, "Stream too short, expected SOT\n");
- return OPJ_FALSE;
- }
- }
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_update_image_data(opj_tcd_t * p_tcd,
- opj_image_t* p_output_image)
-{
- OPJ_UINT32 i, j;
- OPJ_UINT32 l_width_src, l_height_src;
- OPJ_UINT32 l_width_dest, l_height_dest;
- OPJ_INT32 l_offset_x0_src, l_offset_y0_src, l_offset_x1_src, l_offset_y1_src;
- OPJ_SIZE_T l_start_offset_src;
- OPJ_UINT32 l_start_x_dest, l_start_y_dest;
- OPJ_UINT32 l_x0_dest, l_y0_dest, l_x1_dest, l_y1_dest;
- OPJ_SIZE_T l_start_offset_dest;
-
- opj_image_comp_t * l_img_comp_src = 00;
- opj_image_comp_t * l_img_comp_dest = 00;
-
- opj_tcd_tilecomp_t * l_tilec = 00;
- opj_image_t * l_image_src = 00;
- OPJ_INT32 * l_dest_ptr;
-
- l_tilec = p_tcd->tcd_image->tiles->comps;
- l_image_src = p_tcd->image;
- l_img_comp_src = l_image_src->comps;
-
- l_img_comp_dest = p_output_image->comps;
-
- for (i = 0; i < l_image_src->numcomps;
- i++, ++l_img_comp_dest, ++l_img_comp_src, ++l_tilec) {
- OPJ_INT32 res_x0, res_x1, res_y0, res_y1;
- OPJ_UINT32 src_data_stride;
- const OPJ_INT32* p_src_data;
-
- /* Copy info from decoded comp image to output image */
- l_img_comp_dest->resno_decoded = l_img_comp_src->resno_decoded;
-
- if (p_tcd->whole_tile_decoding) {
- opj_tcd_resolution_t* l_res = l_tilec->resolutions +
- l_img_comp_src->resno_decoded;
- res_x0 = l_res->x0;
- res_y0 = l_res->y0;
- res_x1 = l_res->x1;
- res_y1 = l_res->y1;
- src_data_stride = (OPJ_UINT32)(
- l_tilec->resolutions[l_tilec->minimum_num_resolutions - 1].x1 -
- l_tilec->resolutions[l_tilec->minimum_num_resolutions - 1].x0);
- p_src_data = l_tilec->data;
- } else {
- opj_tcd_resolution_t* l_res = l_tilec->resolutions +
- l_img_comp_src->resno_decoded;
- res_x0 = (OPJ_INT32)l_res->win_x0;
- res_y0 = (OPJ_INT32)l_res->win_y0;
- res_x1 = (OPJ_INT32)l_res->win_x1;
- res_y1 = (OPJ_INT32)l_res->win_y1;
- src_data_stride = l_res->win_x1 - l_res->win_x0;
- p_src_data = l_tilec->data_win;
- }
-
- if (p_src_data == NULL) {
- /* Happens for partial component decoding */
- continue;
- }
-
- l_width_src = (OPJ_UINT32)(res_x1 - res_x0);
- l_height_src = (OPJ_UINT32)(res_y1 - res_y0);
-
-
- /* Current tile component size*/
- /*if (i == 0) {
- fprintf(stdout, "SRC: l_res_x0=%d, l_res_x1=%d, l_res_y0=%d, l_res_y1=%d\n",
- res_x0, res_x1, res_y0, res_y1);
- }*/
-
-
- /* Border of the current output component*/
- l_x0_dest = opj_uint_ceildivpow2(l_img_comp_dest->x0, l_img_comp_dest->factor);
- l_y0_dest = opj_uint_ceildivpow2(l_img_comp_dest->y0, l_img_comp_dest->factor);
- l_x1_dest = l_x0_dest +
- l_img_comp_dest->w; /* can't overflow given that image->x1 is uint32 */
- l_y1_dest = l_y0_dest + l_img_comp_dest->h;
-
- /*if (i == 0) {
- fprintf(stdout, "DEST: l_x0_dest=%d, l_x1_dest=%d, l_y0_dest=%d, l_y1_dest=%d (%d)\n",
- l_x0_dest, l_x1_dest, l_y0_dest, l_y1_dest, l_img_comp_dest->factor );
- }*/
-
- /*-----*/
- /* Compute the area (l_offset_x0_src, l_offset_y0_src, l_offset_x1_src, l_offset_y1_src)
- * of the input buffer (decoded tile component) which will be move
- * in the output buffer. Compute the area of the output buffer (l_start_x_dest,
- * l_start_y_dest, l_width_dest, l_height_dest) which will be modified
- * by this input area.
- * */
- assert(res_x0 >= 0);
- assert(res_x1 >= 0);
- if (l_x0_dest < (OPJ_UINT32)res_x0) {
- l_start_x_dest = (OPJ_UINT32)res_x0 - l_x0_dest;
- l_offset_x0_src = 0;
-
- if (l_x1_dest >= (OPJ_UINT32)res_x1) {
- l_width_dest = l_width_src;
- l_offset_x1_src = 0;
- } else {
- l_width_dest = l_x1_dest - (OPJ_UINT32)res_x0 ;
- l_offset_x1_src = (OPJ_INT32)(l_width_src - l_width_dest);
- }
- } else {
- l_start_x_dest = 0U;
- l_offset_x0_src = (OPJ_INT32)l_x0_dest - res_x0;
-
- if (l_x1_dest >= (OPJ_UINT32)res_x1) {
- l_width_dest = l_width_src - (OPJ_UINT32)l_offset_x0_src;
- l_offset_x1_src = 0;
- } else {
- l_width_dest = l_img_comp_dest->w ;
- l_offset_x1_src = res_x1 - (OPJ_INT32)l_x1_dest;
- }
- }
-
- if (l_y0_dest < (OPJ_UINT32)res_y0) {
- l_start_y_dest = (OPJ_UINT32)res_y0 - l_y0_dest;
- l_offset_y0_src = 0;
-
- if (l_y1_dest >= (OPJ_UINT32)res_y1) {
- l_height_dest = l_height_src;
- l_offset_y1_src = 0;
- } else {
- l_height_dest = l_y1_dest - (OPJ_UINT32)res_y0 ;
- l_offset_y1_src = (OPJ_INT32)(l_height_src - l_height_dest);
- }
- } else {
- l_start_y_dest = 0U;
- l_offset_y0_src = (OPJ_INT32)l_y0_dest - res_y0;
-
- if (l_y1_dest >= (OPJ_UINT32)res_y1) {
- l_height_dest = l_height_src - (OPJ_UINT32)l_offset_y0_src;
- l_offset_y1_src = 0;
- } else {
- l_height_dest = l_img_comp_dest->h ;
- l_offset_y1_src = res_y1 - (OPJ_INT32)l_y1_dest;
- }
- }
-
- if ((l_offset_x0_src < 0) || (l_offset_y0_src < 0) || (l_offset_x1_src < 0) ||
- (l_offset_y1_src < 0)) {
- return OPJ_FALSE;
- }
- /* testcase 2977.pdf.asan.67.2198 */
- if ((OPJ_INT32)l_width_dest < 0 || (OPJ_INT32)l_height_dest < 0) {
- return OPJ_FALSE;
- }
- /*-----*/
-
- /* Compute the input buffer offset */
- l_start_offset_src = (OPJ_SIZE_T)l_offset_x0_src + (OPJ_SIZE_T)l_offset_y0_src
- * (OPJ_SIZE_T)src_data_stride;
-
- /* Compute the output buffer offset */
- l_start_offset_dest = (OPJ_SIZE_T)l_start_x_dest + (OPJ_SIZE_T)l_start_y_dest
- * (OPJ_SIZE_T)l_img_comp_dest->w;
-
- /* Allocate output component buffer if necessary */
- if (l_img_comp_dest->data == NULL &&
- l_start_offset_src == 0 && l_start_offset_dest == 0 &&
- src_data_stride == l_img_comp_dest->w &&
- l_width_dest == l_img_comp_dest->w &&
- l_height_dest == l_img_comp_dest->h) {
- /* If the final image matches the tile buffer, then borrow it */
- /* directly to save a copy */
- if (p_tcd->whole_tile_decoding) {
- l_img_comp_dest->data = l_tilec->data;
- l_tilec->data = NULL;
- } else {
- l_img_comp_dest->data = l_tilec->data_win;
- l_tilec->data_win = NULL;
- }
- continue;
- } else if (l_img_comp_dest->data == NULL) {
- OPJ_SIZE_T l_width = l_img_comp_dest->w;
- OPJ_SIZE_T l_height = l_img_comp_dest->h;
-
- if ((l_height == 0U) || (l_width > (SIZE_MAX / l_height)) ||
- l_width * l_height > SIZE_MAX / sizeof(OPJ_INT32)) {
- /* would overflow */
- return OPJ_FALSE;
- }
- l_img_comp_dest->data = (OPJ_INT32*) opj_image_data_alloc(l_width * l_height *
- sizeof(OPJ_INT32));
- if (! l_img_comp_dest->data) {
- return OPJ_FALSE;
- }
-
- if (l_img_comp_dest->w != l_width_dest ||
- l_img_comp_dest->h != l_height_dest) {
- memset(l_img_comp_dest->data, 0,
- (OPJ_SIZE_T)l_img_comp_dest->w * l_img_comp_dest->h * sizeof(OPJ_INT32));
- }
- }
-
- /* Move the output buffer to the first place where we will write*/
- l_dest_ptr = l_img_comp_dest->data + l_start_offset_dest;
-
- {
- const OPJ_INT32 * l_src_ptr = p_src_data;
- l_src_ptr += l_start_offset_src;
-
- for (j = 0; j < l_height_dest; ++j) {
- memcpy(l_dest_ptr, l_src_ptr, l_width_dest * sizeof(OPJ_INT32));
- l_dest_ptr += l_img_comp_dest->w;
- l_src_ptr += src_data_stride;
- }
- }
-
-
- }
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_update_image_dimensions(opj_image_t* p_image,
- opj_event_mgr_t * p_manager)
-{
- OPJ_UINT32 it_comp;
- OPJ_INT32 l_comp_x1, l_comp_y1;
- opj_image_comp_t* l_img_comp = NULL;
-
- l_img_comp = p_image->comps;
- for (it_comp = 0; it_comp < p_image->numcomps; ++it_comp) {
- OPJ_INT32 l_h, l_w;
- if (p_image->x0 > (OPJ_UINT32)INT_MAX ||
- p_image->y0 > (OPJ_UINT32)INT_MAX ||
- p_image->x1 > (OPJ_UINT32)INT_MAX ||
- p_image->y1 > (OPJ_UINT32)INT_MAX) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Image coordinates above INT_MAX are not supported\n");
- return OPJ_FALSE;
- }
-
- l_img_comp->x0 = opj_uint_ceildiv(p_image->x0, l_img_comp->dx);
- l_img_comp->y0 = opj_uint_ceildiv(p_image->y0, l_img_comp->dy);
- l_comp_x1 = opj_int_ceildiv((OPJ_INT32)p_image->x1, (OPJ_INT32)l_img_comp->dx);
- l_comp_y1 = opj_int_ceildiv((OPJ_INT32)p_image->y1, (OPJ_INT32)l_img_comp->dy);
-
- l_w = opj_int_ceildivpow2(l_comp_x1, (OPJ_INT32)l_img_comp->factor)
- - opj_int_ceildivpow2((OPJ_INT32)l_img_comp->x0, (OPJ_INT32)l_img_comp->factor);
- if (l_w < 0) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Size x of the decoded component image is incorrect (comp[%d].w=%d).\n",
- it_comp, l_w);
- return OPJ_FALSE;
- }
- l_img_comp->w = (OPJ_UINT32)l_w;
-
- l_h = opj_int_ceildivpow2(l_comp_y1, (OPJ_INT32)l_img_comp->factor)
- - opj_int_ceildivpow2((OPJ_INT32)l_img_comp->y0, (OPJ_INT32)l_img_comp->factor);
- if (l_h < 0) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Size y of the decoded component image is incorrect (comp[%d].h=%d).\n",
- it_comp, l_h);
- return OPJ_FALSE;
- }
- l_img_comp->h = (OPJ_UINT32)l_h;
-
- l_img_comp++;
- }
-
- return OPJ_TRUE;
-}
-
-OPJ_BOOL opj_j2k_set_decoded_components(opj_j2k_t *p_j2k,
- OPJ_UINT32 numcomps,
- const OPJ_UINT32* comps_indices,
- opj_event_mgr_t * p_manager)
-{
- OPJ_UINT32 i;
- OPJ_BOOL* already_mapped;
-
- if (p_j2k->m_private_image == NULL) {
- opj_event_msg(p_manager, EVT_ERROR,
- "opj_read_header() should be called before "
- "opj_set_decoded_components().\n");
- return OPJ_FALSE;
- }
-
- already_mapped = (OPJ_BOOL*) opj_calloc(sizeof(OPJ_BOOL),
- p_j2k->m_private_image->numcomps);
- if (already_mapped == NULL) {
- return OPJ_FALSE;
- }
-
- for (i = 0; i < numcomps; i++) {
- if (comps_indices[i] >= p_j2k->m_private_image->numcomps) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Invalid component index: %u\n",
- comps_indices[i]);
- opj_free(already_mapped);
- return OPJ_FALSE;
- }
- if (already_mapped[comps_indices[i]]) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Component index %u used several times\n",
- comps_indices[i]);
- opj_free(already_mapped);
- return OPJ_FALSE;
- }
- already_mapped[comps_indices[i]] = OPJ_TRUE;
- }
- opj_free(already_mapped);
-
- opj_free(p_j2k->m_specific_param.m_decoder.m_comps_indices_to_decode);
- if (numcomps) {
- p_j2k->m_specific_param.m_decoder.m_comps_indices_to_decode =
- (OPJ_UINT32*) opj_malloc(numcomps * sizeof(OPJ_UINT32));
- if (p_j2k->m_specific_param.m_decoder.m_comps_indices_to_decode == NULL) {
- p_j2k->m_specific_param.m_decoder.m_numcomps_to_decode = 0;
- return OPJ_FALSE;
- }
- memcpy(p_j2k->m_specific_param.m_decoder.m_comps_indices_to_decode,
- comps_indices,
- numcomps * sizeof(OPJ_UINT32));
- } else {
- p_j2k->m_specific_param.m_decoder.m_comps_indices_to_decode = NULL;
- }
- p_j2k->m_specific_param.m_decoder.m_numcomps_to_decode = numcomps;
-
- return OPJ_TRUE;
-}
-
-
-OPJ_BOOL opj_j2k_set_decode_area(opj_j2k_t *p_j2k,
- opj_image_t* p_image,
- OPJ_INT32 p_start_x, OPJ_INT32 p_start_y,
- OPJ_INT32 p_end_x, OPJ_INT32 p_end_y,
- opj_event_mgr_t * p_manager)
-{
- opj_cp_t * l_cp = &(p_j2k->m_cp);
- opj_image_t * l_image = p_j2k->m_private_image;
- OPJ_BOOL ret;
- OPJ_UINT32 it_comp;
-
- if (p_j2k->m_cp.tw == 1 && p_j2k->m_cp.th == 1 &&
- p_j2k->m_cp.tcps[0].m_data != NULL) {
- /* In the case of a single-tiled image whose codestream we have already */
- /* ingested, go on */
- }
- /* Check if we are read the main header */
- else if (p_j2k->m_specific_param.m_decoder.m_state != J2K_STATE_TPHSOT) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Need to decode the main header before begin to decode the remaining codestream.\n");
- return OPJ_FALSE;
- }
-
- /* Update the comps[].factor member of the output image with the one */
- /* of m_reduce */
- for (it_comp = 0; it_comp < p_image->numcomps; ++it_comp) {
- p_image->comps[it_comp].factor = p_j2k->m_cp.m_specific_param.m_dec.m_reduce;
- }
-
- if (!p_start_x && !p_start_y && !p_end_x && !p_end_y) {
- opj_event_msg(p_manager, EVT_INFO,
- "No decoded area parameters, set the decoded area to the whole image\n");
-
- p_j2k->m_specific_param.m_decoder.m_start_tile_x = 0;
- p_j2k->m_specific_param.m_decoder.m_start_tile_y = 0;
- p_j2k->m_specific_param.m_decoder.m_end_tile_x = l_cp->tw;
- p_j2k->m_specific_param.m_decoder.m_end_tile_y = l_cp->th;
-
- p_image->x0 = l_image->x0;
- p_image->y0 = l_image->y0;
- p_image->x1 = l_image->x1;
- p_image->y1 = l_image->y1;
-
- return opj_j2k_update_image_dimensions(p_image, p_manager);
- }
-
- /* ----- */
- /* Check if the positions provided by the user are correct */
-
- /* Left */
- if (p_start_x < 0) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Left position of the decoded area (region_x0=%d) should be >= 0.\n",
- p_start_x);
- return OPJ_FALSE;
- } else if ((OPJ_UINT32)p_start_x > l_image->x1) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Left position of the decoded area (region_x0=%d) is outside the image area (Xsiz=%d).\n",
- p_start_x, l_image->x1);
- return OPJ_FALSE;
- } else if ((OPJ_UINT32)p_start_x < l_image->x0) {
- opj_event_msg(p_manager, EVT_WARNING,
- "Left position of the decoded area (region_x0=%d) is outside the image area (XOsiz=%d).\n",
- p_start_x, l_image->x0);
- p_j2k->m_specific_param.m_decoder.m_start_tile_x = 0;
- p_image->x0 = l_image->x0;
- } else {
- p_j2k->m_specific_param.m_decoder.m_start_tile_x = ((OPJ_UINT32)p_start_x -
- l_cp->tx0) / l_cp->tdx;
- p_image->x0 = (OPJ_UINT32)p_start_x;
- }
-
- /* Up */
- if (p_start_y < 0) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Up position of the decoded area (region_y0=%d) should be >= 0.\n",
- p_start_y);
- return OPJ_FALSE;
- } else if ((OPJ_UINT32)p_start_y > l_image->y1) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Up position of the decoded area (region_y0=%d) is outside the image area (Ysiz=%d).\n",
- p_start_y, l_image->y1);
- return OPJ_FALSE;
- } else if ((OPJ_UINT32)p_start_y < l_image->y0) {
- opj_event_msg(p_manager, EVT_WARNING,
- "Up position of the decoded area (region_y0=%d) is outside the image area (YOsiz=%d).\n",
- p_start_y, l_image->y0);
- p_j2k->m_specific_param.m_decoder.m_start_tile_y = 0;
- p_image->y0 = l_image->y0;
- } else {
- p_j2k->m_specific_param.m_decoder.m_start_tile_y = ((OPJ_UINT32)p_start_y -
- l_cp->ty0) / l_cp->tdy;
- p_image->y0 = (OPJ_UINT32)p_start_y;
- }
-
- /* Right */
- if (p_end_x <= 0) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Right position of the decoded area (region_x1=%d) should be > 0.\n",
- p_end_x);
- return OPJ_FALSE;
- } else if ((OPJ_UINT32)p_end_x < l_image->x0) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Right position of the decoded area (region_x1=%d) is outside the image area (XOsiz=%d).\n",
- p_end_x, l_image->x0);
- return OPJ_FALSE;
- } else if ((OPJ_UINT32)p_end_x > l_image->x1) {
- opj_event_msg(p_manager, EVT_WARNING,
- "Right position of the decoded area (region_x1=%d) is outside the image area (Xsiz=%d).\n",
- p_end_x, l_image->x1);
- p_j2k->m_specific_param.m_decoder.m_end_tile_x = l_cp->tw;
- p_image->x1 = l_image->x1;
- } else {
- p_j2k->m_specific_param.m_decoder.m_end_tile_x = opj_uint_ceildiv((
- OPJ_UINT32)p_end_x - l_cp->tx0, l_cp->tdx);
- p_image->x1 = (OPJ_UINT32)p_end_x;
- }
-
- /* Bottom */
- if (p_end_y <= 0) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Bottom position of the decoded area (region_y1=%d) should be > 0.\n",
- p_end_y);
- return OPJ_FALSE;
- } else if ((OPJ_UINT32)p_end_y < l_image->y0) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Bottom position of the decoded area (region_y1=%d) is outside the image area (YOsiz=%d).\n",
- p_end_y, l_image->y0);
- return OPJ_FALSE;
- }
- if ((OPJ_UINT32)p_end_y > l_image->y1) {
- opj_event_msg(p_manager, EVT_WARNING,
- "Bottom position of the decoded area (region_y1=%d) is outside the image area (Ysiz=%d).\n",
- p_end_y, l_image->y1);
- p_j2k->m_specific_param.m_decoder.m_end_tile_y = l_cp->th;
- p_image->y1 = l_image->y1;
- } else {
- p_j2k->m_specific_param.m_decoder.m_end_tile_y = opj_uint_ceildiv((
- OPJ_UINT32)p_end_y - l_cp->ty0, l_cp->tdy);
- p_image->y1 = (OPJ_UINT32)p_end_y;
- }
- /* ----- */
-
- p_j2k->m_specific_param.m_decoder.m_discard_tiles = 1;
-
- ret = opj_j2k_update_image_dimensions(p_image, p_manager);
-
- if (ret) {
- opj_event_msg(p_manager, EVT_INFO, "Setting decoding area to %d,%d,%d,%d\n",
- p_image->x0, p_image->y0, p_image->x1, p_image->y1);
- }
-
- return ret;
-}
-
-opj_j2k_t* opj_j2k_create_decompress(void)
-{
- opj_j2k_t *l_j2k = (opj_j2k_t*) opj_calloc(1, sizeof(opj_j2k_t));
- if (!l_j2k) {
- return 00;
- }
-
- l_j2k->m_is_decoder = 1;
- l_j2k->m_cp.m_is_decoder = 1;
- /* in the absence of JP2 boxes, consider different bit depth / sign */
- /* per component is allowed */
- l_j2k->m_cp.allow_different_bit_depth_sign = 1;
-
- /* Default to using strict mode. */
- l_j2k->m_cp.strict = OPJ_TRUE;
-
-#ifdef OPJ_DISABLE_TPSOT_FIX
- l_j2k->m_specific_param.m_decoder.m_nb_tile_parts_correction_checked = 1;
-#endif
-
- l_j2k->m_specific_param.m_decoder.m_default_tcp = (opj_tcp_t*) opj_calloc(1,
- sizeof(opj_tcp_t));
- if (!l_j2k->m_specific_param.m_decoder.m_default_tcp) {
- opj_j2k_destroy(l_j2k);
- return 00;
- }
-
- l_j2k->m_specific_param.m_decoder.m_header_data = (OPJ_BYTE *) opj_calloc(1,
- OPJ_J2K_DEFAULT_HEADER_SIZE);
- if (! l_j2k->m_specific_param.m_decoder.m_header_data) {
- opj_j2k_destroy(l_j2k);
- return 00;
- }
-
- l_j2k->m_specific_param.m_decoder.m_header_data_size =
- OPJ_J2K_DEFAULT_HEADER_SIZE;
-
- l_j2k->m_specific_param.m_decoder.m_tile_ind_to_dec = -1 ;
-
- l_j2k->m_specific_param.m_decoder.m_last_sot_read_pos = 0 ;
-
- /* codestream index creation */
- l_j2k->cstr_index = opj_j2k_create_cstr_index();
- if (!l_j2k->cstr_index) {
- opj_j2k_destroy(l_j2k);
- return 00;
- }
-
- /* validation list creation */
- l_j2k->m_validation_list = opj_procedure_list_create();
- if (! l_j2k->m_validation_list) {
- opj_j2k_destroy(l_j2k);
- return 00;
- }
-
- /* execution list creation */
- l_j2k->m_procedure_list = opj_procedure_list_create();
- if (! l_j2k->m_procedure_list) {
- opj_j2k_destroy(l_j2k);
- return 00;
- }
-
- l_j2k->m_tp = opj_thread_pool_create(opj_j2k_get_default_thread_count());
- if (!l_j2k->m_tp) {
- l_j2k->m_tp = opj_thread_pool_create(0);
- }
- if (!l_j2k->m_tp) {
- opj_j2k_destroy(l_j2k);
- return NULL;
- }
-
- return l_j2k;
-}
-
-static opj_codestream_index_t* opj_j2k_create_cstr_index(void)
-{
- opj_codestream_index_t* cstr_index = (opj_codestream_index_t*)
- opj_calloc(1, sizeof(opj_codestream_index_t));
- if (!cstr_index) {
- return NULL;
- }
-
- cstr_index->maxmarknum = 100;
- cstr_index->marknum = 0;
- cstr_index->marker = (opj_marker_info_t*)
- opj_calloc(cstr_index->maxmarknum, sizeof(opj_marker_info_t));
- if (!cstr_index-> marker) {
- opj_free(cstr_index);
- return NULL;
- }
-
- cstr_index->tile_index = NULL;
-
- return cstr_index;
-}
-
-static OPJ_UINT32 opj_j2k_get_SPCod_SPCoc_size(opj_j2k_t *p_j2k,
- OPJ_UINT32 p_tile_no,
- OPJ_UINT32 p_comp_no)
-{
- opj_cp_t *l_cp = 00;
- opj_tcp_t *l_tcp = 00;
- opj_tccp_t *l_tccp = 00;
-
- /* preconditions */
- assert(p_j2k != 00);
-
- l_cp = &(p_j2k->m_cp);
- l_tcp = &l_cp->tcps[p_tile_no];
- l_tccp = &l_tcp->tccps[p_comp_no];
-
- /* preconditions again */
- assert(p_tile_no < (l_cp->tw * l_cp->th));
- assert(p_comp_no < p_j2k->m_private_image->numcomps);
-
- if (l_tccp->csty & J2K_CCP_CSTY_PRT) {
- return 5 + l_tccp->numresolutions;
- } else {
- return 5;
- }
-}
-
-static OPJ_BOOL opj_j2k_compare_SPCod_SPCoc(opj_j2k_t *p_j2k,
- OPJ_UINT32 p_tile_no, OPJ_UINT32 p_first_comp_no, OPJ_UINT32 p_second_comp_no)
-{
- OPJ_UINT32 i;
- opj_cp_t *l_cp = NULL;
- opj_tcp_t *l_tcp = NULL;
- opj_tccp_t *l_tccp0 = NULL;
- opj_tccp_t *l_tccp1 = NULL;
-
- /* preconditions */
- assert(p_j2k != 00);
-
- l_cp = &(p_j2k->m_cp);
- l_tcp = &l_cp->tcps[p_tile_no];
- l_tccp0 = &l_tcp->tccps[p_first_comp_no];
- l_tccp1 = &l_tcp->tccps[p_second_comp_no];
-
- if (l_tccp0->numresolutions != l_tccp1->numresolutions) {
- return OPJ_FALSE;
- }
- if (l_tccp0->cblkw != l_tccp1->cblkw) {
- return OPJ_FALSE;
- }
- if (l_tccp0->cblkh != l_tccp1->cblkh) {
- return OPJ_FALSE;
- }
- if (l_tccp0->cblksty != l_tccp1->cblksty) {
- return OPJ_FALSE;
- }
- if (l_tccp0->qmfbid != l_tccp1->qmfbid) {
- return OPJ_FALSE;
- }
- if ((l_tccp0->csty & J2K_CCP_CSTY_PRT) != (l_tccp1->csty & J2K_CCP_CSTY_PRT)) {
- return OPJ_FALSE;
- }
-
- for (i = 0U; i < l_tccp0->numresolutions; ++i) {
- if (l_tccp0->prcw[i] != l_tccp1->prcw[i]) {
- return OPJ_FALSE;
- }
- if (l_tccp0->prch[i] != l_tccp1->prch[i]) {
- return OPJ_FALSE;
- }
- }
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_write_SPCod_SPCoc(opj_j2k_t *p_j2k,
- OPJ_UINT32 p_tile_no,
- OPJ_UINT32 p_comp_no,
- OPJ_BYTE * p_data,
- OPJ_UINT32 * p_header_size,
- struct opj_event_mgr * p_manager)
-{
- OPJ_UINT32 i;
- opj_cp_t *l_cp = 00;
- opj_tcp_t *l_tcp = 00;
- opj_tccp_t *l_tccp = 00;
-
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_header_size != 00);
- assert(p_manager != 00);
- assert(p_data != 00);
-
- l_cp = &(p_j2k->m_cp);
- l_tcp = &l_cp->tcps[p_tile_no];
- l_tccp = &l_tcp->tccps[p_comp_no];
-
- /* preconditions again */
- assert(p_tile_no < (l_cp->tw * l_cp->th));
- assert(p_comp_no < (p_j2k->m_private_image->numcomps));
-
- if (*p_header_size < 5) {
- opj_event_msg(p_manager, EVT_ERROR, "Error writing SPCod SPCoc element\n");
- return OPJ_FALSE;
- }
-
- opj_write_bytes(p_data, l_tccp->numresolutions - 1, 1); /* SPcoc (D) */
- ++p_data;
-
- opj_write_bytes(p_data, l_tccp->cblkw - 2, 1); /* SPcoc (E) */
- ++p_data;
-
- opj_write_bytes(p_data, l_tccp->cblkh - 2, 1); /* SPcoc (F) */
- ++p_data;
-
- opj_write_bytes(p_data, l_tccp->cblksty,
- 1); /* SPcoc (G) */
- ++p_data;
-
- opj_write_bytes(p_data, l_tccp->qmfbid,
- 1); /* SPcoc (H) */
- ++p_data;
-
- *p_header_size = *p_header_size - 5;
-
- if (l_tccp->csty & J2K_CCP_CSTY_PRT) {
-
- if (*p_header_size < l_tccp->numresolutions) {
- opj_event_msg(p_manager, EVT_ERROR, "Error writing SPCod SPCoc element\n");
- return OPJ_FALSE;
- }
-
- for (i = 0; i < l_tccp->numresolutions; ++i) {
- opj_write_bytes(p_data, l_tccp->prcw[i] + (l_tccp->prch[i] << 4),
- 1); /* SPcoc (I_i) */
- ++p_data;
- }
-
- *p_header_size = *p_header_size - l_tccp->numresolutions;
- }
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_read_SPCod_SPCoc(opj_j2k_t *p_j2k,
- OPJ_UINT32 compno,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 * p_header_size,
- opj_event_mgr_t * p_manager)
-{
- OPJ_UINT32 i, l_tmp;
- opj_cp_t *l_cp = NULL;
- opj_tcp_t *l_tcp = NULL;
- opj_tccp_t *l_tccp = NULL;
- OPJ_BYTE * l_current_ptr = NULL;
-
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_manager != 00);
- assert(p_header_data != 00);
-
- l_cp = &(p_j2k->m_cp);
- l_tcp = (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH) ?
- &l_cp->tcps[p_j2k->m_current_tile_number] :
- p_j2k->m_specific_param.m_decoder.m_default_tcp;
-
- /* precondition again */
- assert(compno < p_j2k->m_private_image->numcomps);
-
- l_tccp = &l_tcp->tccps[compno];
- l_current_ptr = p_header_data;
-
- /* make sure room is sufficient */
- if (*p_header_size < 5) {
- opj_event_msg(p_manager, EVT_ERROR, "Error reading SPCod SPCoc element\n");
- return OPJ_FALSE;
- }
-
- /* SPcod (D) / SPcoc (A) */
- opj_read_bytes(l_current_ptr, &l_tccp->numresolutions, 1);
- ++l_tccp->numresolutions; /* tccp->numresolutions = read() + 1 */
- if (l_tccp->numresolutions > OPJ_J2K_MAXRLVLS) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Invalid value for numresolutions : %d, max value is set in openjpeg.h at %d\n",
- l_tccp->numresolutions, OPJ_J2K_MAXRLVLS);
- return OPJ_FALSE;
- }
- ++l_current_ptr;
-
- /* If user wants to remove more resolutions than the codestream contains, return error */
- if (l_cp->m_specific_param.m_dec.m_reduce >= l_tccp->numresolutions) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Error decoding component %d.\nThe number of resolutions "
- "to remove (%d) is greater or equal than the number "
- "of resolutions of this component (%d)\nModify the cp_reduce parameter.\n\n",
- compno, l_cp->m_specific_param.m_dec.m_reduce, l_tccp->numresolutions);
- p_j2k->m_specific_param.m_decoder.m_state |=
- 0x8000;/* FIXME J2K_DEC_STATE_ERR;*/
- return OPJ_FALSE;
- }
-
- /* SPcod (E) / SPcoc (B) */
- opj_read_bytes(l_current_ptr, &l_tccp->cblkw, 1);
- ++l_current_ptr;
- l_tccp->cblkw += 2;
-
- /* SPcod (F) / SPcoc (C) */
- opj_read_bytes(l_current_ptr, &l_tccp->cblkh, 1);
- ++l_current_ptr;
- l_tccp->cblkh += 2;
-
- if ((l_tccp->cblkw > 10) || (l_tccp->cblkh > 10) ||
- ((l_tccp->cblkw + l_tccp->cblkh) > 12)) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Error reading SPCod SPCoc element, Invalid cblkw/cblkh combination\n");
- return OPJ_FALSE;
- }
-
- /* SPcod (G) / SPcoc (D) */
- opj_read_bytes(l_current_ptr, &l_tccp->cblksty, 1);
- ++l_current_ptr;
- if ((l_tccp->cblksty & J2K_CCP_CBLKSTY_HTMIXED) != 0) {
- /* We do not support HT mixed mode yet. For conformance, it should be supported.*/
- opj_event_msg(p_manager, EVT_ERROR,
- "Error reading SPCod SPCoc element. Unsupported Mixed HT code-block style found\n");
- return OPJ_FALSE;
- }
-
- /* SPcod (H) / SPcoc (E) */
- opj_read_bytes(l_current_ptr, &l_tccp->qmfbid, 1);
- ++l_current_ptr;
-
- if (l_tccp->qmfbid > 1) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Error reading SPCod SPCoc element, Invalid transformation found\n");
- return OPJ_FALSE;
- }
-
- *p_header_size = *p_header_size - 5;
-
- /* use custom precinct size ? */
- if (l_tccp->csty & J2K_CCP_CSTY_PRT) {
- if (*p_header_size < l_tccp->numresolutions) {
- opj_event_msg(p_manager, EVT_ERROR, "Error reading SPCod SPCoc element\n");
- return OPJ_FALSE;
- }
-
- /* SPcod (I_i) / SPcoc (F_i) */
- for (i = 0; i < l_tccp->numresolutions; ++i) {
- opj_read_bytes(l_current_ptr, &l_tmp, 1);
- ++l_current_ptr;
- /* Precinct exponent 0 is only allowed for lowest resolution level (Table A.21) */
- if ((i != 0) && (((l_tmp & 0xf) == 0) || ((l_tmp >> 4) == 0))) {
- opj_event_msg(p_manager, EVT_ERROR, "Invalid precinct size\n");
- return OPJ_FALSE;
- }
- l_tccp->prcw[i] = l_tmp & 0xf;
- l_tccp->prch[i] = l_tmp >> 4;
- }
-
- *p_header_size = *p_header_size - l_tccp->numresolutions;
- } else {
- /* set default size for the precinct width and height */
- for (i = 0; i < l_tccp->numresolutions; ++i) {
- l_tccp->prcw[i] = 15;
- l_tccp->prch[i] = 15;
- }
- }
-
-#ifdef WIP_REMOVE_MSD
- /* INDEX >> */
- if (p_j2k->cstr_info && compno == 0) {
- OPJ_UINT32 l_data_size = l_tccp->numresolutions * sizeof(OPJ_UINT32);
-
- p_j2k->cstr_info->tile[p_j2k->m_current_tile_number].tccp_info[compno].cblkh =
- l_tccp->cblkh;
- p_j2k->cstr_info->tile[p_j2k->m_current_tile_number].tccp_info[compno].cblkw =
- l_tccp->cblkw;
- p_j2k->cstr_info->tile[p_j2k->m_current_tile_number].tccp_info[compno].numresolutions
- = l_tccp->numresolutions;
- p_j2k->cstr_info->tile[p_j2k->m_current_tile_number].tccp_info[compno].cblksty =
- l_tccp->cblksty;
- p_j2k->cstr_info->tile[p_j2k->m_current_tile_number].tccp_info[compno].qmfbid =
- l_tccp->qmfbid;
-
- memcpy(p_j2k->cstr_info->tile[p_j2k->m_current_tile_number].pdx, l_tccp->prcw,
- l_data_size);
- memcpy(p_j2k->cstr_info->tile[p_j2k->m_current_tile_number].pdy, l_tccp->prch,
- l_data_size);
- }
- /* << INDEX */
-#endif
-
- return OPJ_TRUE;
-}
-
-static void opj_j2k_copy_tile_component_parameters(opj_j2k_t *p_j2k)
-{
- /* loop */
- OPJ_UINT32 i;
- opj_cp_t *l_cp = NULL;
- opj_tcp_t *l_tcp = NULL;
- opj_tccp_t *l_ref_tccp = NULL, *l_copied_tccp = NULL;
- OPJ_UINT32 l_prc_size;
-
- /* preconditions */
- assert(p_j2k != 00);
-
- l_cp = &(p_j2k->m_cp);
- l_tcp = (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH)
- ?
- &l_cp->tcps[p_j2k->m_current_tile_number] :
- p_j2k->m_specific_param.m_decoder.m_default_tcp;
-
- l_ref_tccp = &l_tcp->tccps[0];
- l_copied_tccp = l_ref_tccp + 1;
- l_prc_size = l_ref_tccp->numresolutions * (OPJ_UINT32)sizeof(OPJ_UINT32);
-
- for (i = 1; i < p_j2k->m_private_image->numcomps; ++i) {
- l_copied_tccp->numresolutions = l_ref_tccp->numresolutions;
- l_copied_tccp->cblkw = l_ref_tccp->cblkw;
- l_copied_tccp->cblkh = l_ref_tccp->cblkh;
- l_copied_tccp->cblksty = l_ref_tccp->cblksty;
- l_copied_tccp->qmfbid = l_ref_tccp->qmfbid;
- memcpy(l_copied_tccp->prcw, l_ref_tccp->prcw, l_prc_size);
- memcpy(l_copied_tccp->prch, l_ref_tccp->prch, l_prc_size);
- ++l_copied_tccp;
- }
-}
-
-static OPJ_UINT32 opj_j2k_get_SQcd_SQcc_size(opj_j2k_t *p_j2k,
- OPJ_UINT32 p_tile_no,
- OPJ_UINT32 p_comp_no)
-{
- OPJ_UINT32 l_num_bands;
-
- opj_cp_t *l_cp = 00;
- opj_tcp_t *l_tcp = 00;
- opj_tccp_t *l_tccp = 00;
-
- /* preconditions */
- assert(p_j2k != 00);
-
- l_cp = &(p_j2k->m_cp);
- l_tcp = &l_cp->tcps[p_tile_no];
- l_tccp = &l_tcp->tccps[p_comp_no];
-
- /* preconditions again */
- assert(p_tile_no < l_cp->tw * l_cp->th);
- assert(p_comp_no < p_j2k->m_private_image->numcomps);
-
- l_num_bands = (l_tccp->qntsty == J2K_CCP_QNTSTY_SIQNT) ? 1 :
- (l_tccp->numresolutions * 3 - 2);
-
- if (l_tccp->qntsty == J2K_CCP_QNTSTY_NOQNT) {
- return 1 + l_num_bands;
- } else {
- return 1 + 2 * l_num_bands;
- }
-}
-
-static OPJ_BOOL opj_j2k_compare_SQcd_SQcc(opj_j2k_t *p_j2k,
- OPJ_UINT32 p_tile_no, OPJ_UINT32 p_first_comp_no, OPJ_UINT32 p_second_comp_no)
-{
- opj_cp_t *l_cp = NULL;
- opj_tcp_t *l_tcp = NULL;
- opj_tccp_t *l_tccp0 = NULL;
- opj_tccp_t *l_tccp1 = NULL;
- OPJ_UINT32 l_band_no, l_num_bands;
-
- /* preconditions */
- assert(p_j2k != 00);
-
- l_cp = &(p_j2k->m_cp);
- l_tcp = &l_cp->tcps[p_tile_no];
- l_tccp0 = &l_tcp->tccps[p_first_comp_no];
- l_tccp1 = &l_tcp->tccps[p_second_comp_no];
-
- if (l_tccp0->qntsty != l_tccp1->qntsty) {
- return OPJ_FALSE;
- }
- if (l_tccp0->numgbits != l_tccp1->numgbits) {
- return OPJ_FALSE;
- }
- if (l_tccp0->qntsty == J2K_CCP_QNTSTY_SIQNT) {
- l_num_bands = 1U;
- } else {
- l_num_bands = l_tccp0->numresolutions * 3U - 2U;
- if (l_num_bands != (l_tccp1->numresolutions * 3U - 2U)) {
- return OPJ_FALSE;
- }
- }
-
- for (l_band_no = 0; l_band_no < l_num_bands; ++l_band_no) {
- if (l_tccp0->stepsizes[l_band_no].expn != l_tccp1->stepsizes[l_band_no].expn) {
- return OPJ_FALSE;
- }
- }
- if (l_tccp0->qntsty != J2K_CCP_QNTSTY_NOQNT) {
- for (l_band_no = 0; l_band_no < l_num_bands; ++l_band_no) {
- if (l_tccp0->stepsizes[l_band_no].mant != l_tccp1->stepsizes[l_band_no].mant) {
- return OPJ_FALSE;
- }
- }
- }
- return OPJ_TRUE;
-}
-
-
-static OPJ_BOOL opj_j2k_write_SQcd_SQcc(opj_j2k_t *p_j2k,
- OPJ_UINT32 p_tile_no,
- OPJ_UINT32 p_comp_no,
- OPJ_BYTE * p_data,
- OPJ_UINT32 * p_header_size,
- struct opj_event_mgr * p_manager)
-{
- OPJ_UINT32 l_header_size;
- OPJ_UINT32 l_band_no, l_num_bands;
- OPJ_UINT32 l_expn, l_mant;
-
- opj_cp_t *l_cp = 00;
- opj_tcp_t *l_tcp = 00;
- opj_tccp_t *l_tccp = 00;
-
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_header_size != 00);
- assert(p_manager != 00);
- assert(p_data != 00);
-
- l_cp = &(p_j2k->m_cp);
- l_tcp = &l_cp->tcps[p_tile_no];
- l_tccp = &l_tcp->tccps[p_comp_no];
-
- /* preconditions again */
- assert(p_tile_no < l_cp->tw * l_cp->th);
- assert(p_comp_no < p_j2k->m_private_image->numcomps);
-
- l_num_bands = (l_tccp->qntsty == J2K_CCP_QNTSTY_SIQNT) ? 1 :
- (l_tccp->numresolutions * 3 - 2);
-
- if (l_tccp->qntsty == J2K_CCP_QNTSTY_NOQNT) {
- l_header_size = 1 + l_num_bands;
-
- if (*p_header_size < l_header_size) {
- opj_event_msg(p_manager, EVT_ERROR, "Error writing SQcd SQcc element\n");
- return OPJ_FALSE;
- }
-
- opj_write_bytes(p_data, l_tccp->qntsty + (l_tccp->numgbits << 5),
- 1); /* Sqcx */
- ++p_data;
-
- for (l_band_no = 0; l_band_no < l_num_bands; ++l_band_no) {
- l_expn = (OPJ_UINT32)l_tccp->stepsizes[l_band_no].expn;
- opj_write_bytes(p_data, l_expn << 3, 1); /* SPqcx_i */
- ++p_data;
- }
- } else {
- l_header_size = 1 + 2 * l_num_bands;
-
- if (*p_header_size < l_header_size) {
- opj_event_msg(p_manager, EVT_ERROR, "Error writing SQcd SQcc element\n");
- return OPJ_FALSE;
- }
-
- opj_write_bytes(p_data, l_tccp->qntsty + (l_tccp->numgbits << 5),
- 1); /* Sqcx */
- ++p_data;
-
- for (l_band_no = 0; l_band_no < l_num_bands; ++l_band_no) {
- l_expn = (OPJ_UINT32)l_tccp->stepsizes[l_band_no].expn;
- l_mant = (OPJ_UINT32)l_tccp->stepsizes[l_band_no].mant;
-
- opj_write_bytes(p_data, (l_expn << 11) + l_mant, 2); /* SPqcx_i */
- p_data += 2;
- }
- }
-
- *p_header_size = *p_header_size - l_header_size;
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_read_SQcd_SQcc(opj_j2k_t *p_j2k,
- OPJ_UINT32 p_comp_no,
- OPJ_BYTE* p_header_data,
- OPJ_UINT32 * p_header_size,
- opj_event_mgr_t * p_manager
- )
-{
- /* loop*/
- OPJ_UINT32 l_band_no;
- opj_cp_t *l_cp = 00;
- opj_tcp_t *l_tcp = 00;
- opj_tccp_t *l_tccp = 00;
- OPJ_BYTE * l_current_ptr = 00;
- OPJ_UINT32 l_tmp, l_num_band;
-
- /* preconditions*/
- assert(p_j2k != 00);
- assert(p_manager != 00);
- assert(p_header_data != 00);
-
- l_cp = &(p_j2k->m_cp);
- /* come from tile part header or main header ?*/
- l_tcp = (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH)
- ?
- &l_cp->tcps[p_j2k->m_current_tile_number] :
- p_j2k->m_specific_param.m_decoder.m_default_tcp;
-
- /* precondition again*/
- assert(p_comp_no < p_j2k->m_private_image->numcomps);
-
- l_tccp = &l_tcp->tccps[p_comp_no];
- l_current_ptr = p_header_data;
-
- if (*p_header_size < 1) {
- opj_event_msg(p_manager, EVT_ERROR, "Error reading SQcd or SQcc element\n");
- return OPJ_FALSE;
- }
- *p_header_size -= 1;
-
- opj_read_bytes(l_current_ptr, &l_tmp, 1); /* Sqcx */
- ++l_current_ptr;
-
- l_tccp->qntsty = l_tmp & 0x1f;
- l_tccp->numgbits = l_tmp >> 5;
- if (l_tccp->qntsty == J2K_CCP_QNTSTY_SIQNT) {
- l_num_band = 1;
- } else {
- l_num_band = (l_tccp->qntsty == J2K_CCP_QNTSTY_NOQNT) ?
- (*p_header_size) :
- (*p_header_size) / 2;
-
- if (l_num_band > OPJ_J2K_MAXBANDS) {
- opj_event_msg(p_manager, EVT_WARNING,
- "While reading CCP_QNTSTY element inside QCD or QCC marker segment, "
- "number of subbands (%d) is greater to OPJ_J2K_MAXBANDS (%d). So we limit the number of elements stored to "
- "OPJ_J2K_MAXBANDS (%d) and skip the rest. \n", l_num_band, OPJ_J2K_MAXBANDS,
- OPJ_J2K_MAXBANDS);
- /*return OPJ_FALSE;*/
- }
- }
-
-#ifdef USE_JPWL
- if (l_cp->correct) {
-
- /* if JPWL is on, we check whether there are too many subbands */
- if (/*(l_num_band < 0) ||*/ (l_num_band >= OPJ_J2K_MAXBANDS)) {
- opj_event_msg(p_manager, JPWL_ASSUME ? EVT_WARNING : EVT_ERROR,
- "JPWL: bad number of subbands in Sqcx (%d)\n",
- l_num_band);
- if (!JPWL_ASSUME) {
- opj_event_msg(p_manager, EVT_ERROR, "JPWL: giving up\n");
- return OPJ_FALSE;
- }
- /* we try to correct */
- l_num_band = 1;
- opj_event_msg(p_manager, EVT_WARNING, "- trying to adjust them\n"
- "- setting number of bands to %d => HYPOTHESIS!!!\n",
- l_num_band);
- };
-
- };
-#endif /* USE_JPWL */
-
- if (l_tccp->qntsty == J2K_CCP_QNTSTY_NOQNT) {
- for (l_band_no = 0; l_band_no < l_num_band; l_band_no++) {
- opj_read_bytes(l_current_ptr, &l_tmp, 1); /* SPqcx_i */
- ++l_current_ptr;
- if (l_band_no < OPJ_J2K_MAXBANDS) {
- l_tccp->stepsizes[l_band_no].expn = (OPJ_INT32)(l_tmp >> 3);
- l_tccp->stepsizes[l_band_no].mant = 0;
- }
- }
-
- if (*p_header_size < l_num_band) {
- return OPJ_FALSE;
- }
- *p_header_size = *p_header_size - l_num_band;
- } else {
- for (l_band_no = 0; l_band_no < l_num_band; l_band_no++) {
- opj_read_bytes(l_current_ptr, &l_tmp, 2); /* SPqcx_i */
- l_current_ptr += 2;
- if (l_band_no < OPJ_J2K_MAXBANDS) {
- l_tccp->stepsizes[l_band_no].expn = (OPJ_INT32)(l_tmp >> 11);
- l_tccp->stepsizes[l_band_no].mant = l_tmp & 0x7ff;
- }
- }
-
- if (*p_header_size < 2 * l_num_band) {
- return OPJ_FALSE;
- }
- *p_header_size = *p_header_size - 2 * l_num_band;
- }
-
- /* Add Antonin : if scalar_derived -> compute other stepsizes */
- if (l_tccp->qntsty == J2K_CCP_QNTSTY_SIQNT) {
- for (l_band_no = 1; l_band_no < OPJ_J2K_MAXBANDS; l_band_no++) {
- l_tccp->stepsizes[l_band_no].expn =
- ((OPJ_INT32)(l_tccp->stepsizes[0].expn) - (OPJ_INT32)((l_band_no - 1) / 3) > 0)
- ?
- (OPJ_INT32)(l_tccp->stepsizes[0].expn) - (OPJ_INT32)((l_band_no - 1) / 3) : 0;
- l_tccp->stepsizes[l_band_no].mant = l_tccp->stepsizes[0].mant;
- }
- }
-
- return OPJ_TRUE;
-}
-
-static void opj_j2k_copy_tile_quantization_parameters(opj_j2k_t *p_j2k)
-{
- OPJ_UINT32 i;
- opj_cp_t *l_cp = NULL;
- opj_tcp_t *l_tcp = NULL;
- opj_tccp_t *l_ref_tccp = NULL;
- opj_tccp_t *l_copied_tccp = NULL;
- OPJ_UINT32 l_size;
-
- /* preconditions */
- assert(p_j2k != 00);
-
- l_cp = &(p_j2k->m_cp);
- l_tcp = p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH ?
- &l_cp->tcps[p_j2k->m_current_tile_number] :
- p_j2k->m_specific_param.m_decoder.m_default_tcp;
-
- l_ref_tccp = &l_tcp->tccps[0];
- l_copied_tccp = l_ref_tccp + 1;
- l_size = OPJ_J2K_MAXBANDS * sizeof(opj_stepsize_t);
-
- for (i = 1; i < p_j2k->m_private_image->numcomps; ++i) {
- l_copied_tccp->qntsty = l_ref_tccp->qntsty;
- l_copied_tccp->numgbits = l_ref_tccp->numgbits;
- memcpy(l_copied_tccp->stepsizes, l_ref_tccp->stepsizes, l_size);
- ++l_copied_tccp;
- }
-}
-
-static void opj_j2k_dump_tile_info(opj_tcp_t * l_default_tile,
- OPJ_INT32 numcomps, FILE* out_stream)
-{
- if (l_default_tile) {
- OPJ_INT32 compno;
-
- fprintf(out_stream, "\t default tile {\n");
- fprintf(out_stream, "\t\t csty=%#x\n", l_default_tile->csty);
- fprintf(out_stream, "\t\t prg=%#x\n", l_default_tile->prg);
- fprintf(out_stream, "\t\t numlayers=%d\n", l_default_tile->numlayers);
- fprintf(out_stream, "\t\t mct=%x\n", l_default_tile->mct);
-
- for (compno = 0; compno < numcomps; compno++) {
- opj_tccp_t *l_tccp = &(l_default_tile->tccps[compno]);
- OPJ_UINT32 resno;
- OPJ_INT32 bandno, numbands;
-
- /* coding style*/
- fprintf(out_stream, "\t\t comp %d {\n", compno);
- fprintf(out_stream, "\t\t\t csty=%#x\n", l_tccp->csty);
- fprintf(out_stream, "\t\t\t numresolutions=%d\n", l_tccp->numresolutions);
- fprintf(out_stream, "\t\t\t cblkw=2^%d\n", l_tccp->cblkw);
- fprintf(out_stream, "\t\t\t cblkh=2^%d\n", l_tccp->cblkh);
- fprintf(out_stream, "\t\t\t cblksty=%#x\n", l_tccp->cblksty);
- fprintf(out_stream, "\t\t\t qmfbid=%d\n", l_tccp->qmfbid);
-
- fprintf(out_stream, "\t\t\t preccintsize (w,h)=");
- for (resno = 0; resno < l_tccp->numresolutions; resno++) {
- fprintf(out_stream, "(%d,%d) ", l_tccp->prcw[resno], l_tccp->prch[resno]);
- }
- fprintf(out_stream, "\n");
-
- /* quantization style*/
- fprintf(out_stream, "\t\t\t qntsty=%d\n", l_tccp->qntsty);
- fprintf(out_stream, "\t\t\t numgbits=%d\n", l_tccp->numgbits);
- fprintf(out_stream, "\t\t\t stepsizes (m,e)=");
- numbands = (l_tccp->qntsty == J2K_CCP_QNTSTY_SIQNT) ? 1 :
- (OPJ_INT32)l_tccp->numresolutions * 3 - 2;
- for (bandno = 0; bandno < numbands; bandno++) {
- fprintf(out_stream, "(%d,%d) ", l_tccp->stepsizes[bandno].mant,
- l_tccp->stepsizes[bandno].expn);
- }
- fprintf(out_stream, "\n");
-
- /* RGN value*/
- fprintf(out_stream, "\t\t\t roishift=%d\n", l_tccp->roishift);
-
- fprintf(out_stream, "\t\t }\n");
- } /*end of component of default tile*/
- fprintf(out_stream, "\t }\n"); /*end of default tile*/
- }
-}
-
-void j2k_dump(opj_j2k_t* p_j2k, OPJ_INT32 flag, FILE* out_stream)
-{
- /* Check if the flag is compatible with j2k file*/
- if ((flag & OPJ_JP2_INFO) || (flag & OPJ_JP2_IND)) {
- fprintf(out_stream, "Wrong flag\n");
- return;
- }
-
- /* Dump the image_header */
- if (flag & OPJ_IMG_INFO) {
- if (p_j2k->m_private_image) {
- j2k_dump_image_header(p_j2k->m_private_image, 0, out_stream);
- }
- }
-
- /* Dump the codestream info from main header */
- if (flag & OPJ_J2K_MH_INFO) {
- if (p_j2k->m_private_image) {
- opj_j2k_dump_MH_info(p_j2k, out_stream);
- }
- }
- /* Dump all tile/codestream info */
- if (flag & OPJ_J2K_TCH_INFO) {
- OPJ_UINT32 l_nb_tiles = p_j2k->m_cp.th * p_j2k->m_cp.tw;
- OPJ_UINT32 i;
- opj_tcp_t * l_tcp = p_j2k->m_cp.tcps;
- if (p_j2k->m_private_image) {
- for (i = 0; i < l_nb_tiles; ++i) {
- opj_j2k_dump_tile_info(l_tcp, (OPJ_INT32)p_j2k->m_private_image->numcomps,
- out_stream);
- ++l_tcp;
- }
- }
- }
-
- /* Dump the codestream info of the current tile */
- if (flag & OPJ_J2K_TH_INFO) {
-
- }
-
- /* Dump the codestream index from main header */
- if (flag & OPJ_J2K_MH_IND) {
- opj_j2k_dump_MH_index(p_j2k, out_stream);
- }
-
- /* Dump the codestream index of the current tile */
- if (flag & OPJ_J2K_TH_IND) {
-
- }
-
-}
-
-static void opj_j2k_dump_MH_index(opj_j2k_t* p_j2k, FILE* out_stream)
-{
- opj_codestream_index_t* cstr_index = p_j2k->cstr_index;
- OPJ_UINT32 it_marker, it_tile, it_tile_part;
-
- fprintf(out_stream, "Codestream index from main header: {\n");
-
- fprintf(out_stream, "\t Main header start position=%" PRIi64 "\n"
- "\t Main header end position=%" PRIi64 "\n",
- cstr_index->main_head_start, cstr_index->main_head_end);
-
- fprintf(out_stream, "\t Marker list: {\n");
-
- if (cstr_index->marker) {
- for (it_marker = 0; it_marker < cstr_index->marknum ; it_marker++) {
- fprintf(out_stream, "\t\t type=%#x, pos=%" PRIi64 ", len=%d\n",
- cstr_index->marker[it_marker].type,
- cstr_index->marker[it_marker].pos,
- cstr_index->marker[it_marker].len);
- }
- }
-
- fprintf(out_stream, "\t }\n");
-
- if (cstr_index->tile_index) {
-
- /* Simple test to avoid to write empty information*/
- OPJ_UINT32 l_acc_nb_of_tile_part = 0;
- for (it_tile = 0; it_tile < cstr_index->nb_of_tiles ; it_tile++) {
- l_acc_nb_of_tile_part += cstr_index->tile_index[it_tile].nb_tps;
-
- /* To avoid regenerating expected opj_dump results from the test */
- /* suite when there is a TLM marker present */
- if (cstr_index->tile_index[it_tile].nb_tps &&
- cstr_index->tile_index[it_tile].tp_index &&
- cstr_index->tile_index[it_tile].tp_index[0].start_pos > 0 &&
- cstr_index->tile_index[it_tile].tp_index[0].end_header == 0 &&
- getenv("OJP_DO_NOT_DISPLAY_TILE_INDEX_IF_TLM") != NULL) {
- l_acc_nb_of_tile_part = 0;
- break;
- }
- }
-
- if (l_acc_nb_of_tile_part) {
- fprintf(out_stream, "\t Tile index: {\n");
-
- for (it_tile = 0; it_tile < cstr_index->nb_of_tiles ; it_tile++) {
- OPJ_UINT32 nb_of_tile_part = cstr_index->tile_index[it_tile].nb_tps;
-
- fprintf(out_stream, "\t\t nb of tile-part in tile [%d]=%d\n", it_tile,
- nb_of_tile_part);
-
- if (cstr_index->tile_index[it_tile].tp_index) {
- for (it_tile_part = 0; it_tile_part < nb_of_tile_part; it_tile_part++) {
- fprintf(out_stream, "\t\t\t tile-part[%d]: star_pos=%" PRIi64 ", end_header=%"
- PRIi64 ", end_pos=%" PRIi64 ".\n",
- it_tile_part,
- cstr_index->tile_index[it_tile].tp_index[it_tile_part].start_pos,
- cstr_index->tile_index[it_tile].tp_index[it_tile_part].end_header,
- cstr_index->tile_index[it_tile].tp_index[it_tile_part].end_pos);
- }
- }
-
- if (cstr_index->tile_index[it_tile].marker) {
- for (it_marker = 0; it_marker < cstr_index->tile_index[it_tile].marknum ;
- it_marker++) {
- fprintf(out_stream, "\t\t type=%#x, pos=%" PRIi64 ", len=%d\n",
- cstr_index->tile_index[it_tile].marker[it_marker].type,
- cstr_index->tile_index[it_tile].marker[it_marker].pos,
- cstr_index->tile_index[it_tile].marker[it_marker].len);
- }
- }
- }
- fprintf(out_stream, "\t }\n");
- }
- }
-
- fprintf(out_stream, "}\n");
-
-}
-
-
-static void opj_j2k_dump_MH_info(opj_j2k_t* p_j2k, FILE* out_stream)
-{
-
- fprintf(out_stream, "Codestream info from main header: {\n");
-
- fprintf(out_stream, "\t tx0=%" PRIu32 ", ty0=%" PRIu32 "\n", p_j2k->m_cp.tx0,
- p_j2k->m_cp.ty0);
- fprintf(out_stream, "\t tdx=%" PRIu32 ", tdy=%" PRIu32 "\n", p_j2k->m_cp.tdx,
- p_j2k->m_cp.tdy);
- fprintf(out_stream, "\t tw=%" PRIu32 ", th=%" PRIu32 "\n", p_j2k->m_cp.tw,
- p_j2k->m_cp.th);
- opj_j2k_dump_tile_info(p_j2k->m_specific_param.m_decoder.m_default_tcp,
- (OPJ_INT32)p_j2k->m_private_image->numcomps, out_stream);
- fprintf(out_stream, "}\n");
-}
-
-void j2k_dump_image_header(opj_image_t* img_header, OPJ_BOOL dev_dump_flag,
- FILE* out_stream)
-{
- char tab[2];
-
- if (dev_dump_flag) {
- fprintf(stdout, "[DEV] Dump an image_header struct {\n");
- tab[0] = '\0';
- } else {
- fprintf(out_stream, "Image info {\n");
- tab[0] = '\t';
- tab[1] = '\0';
- }
-
- fprintf(out_stream, "%s x0=%d, y0=%d\n", tab, img_header->x0, img_header->y0);
- fprintf(out_stream, "%s x1=%d, y1=%d\n", tab, img_header->x1,
- img_header->y1);
- fprintf(out_stream, "%s numcomps=%d\n", tab, img_header->numcomps);
-
- if (img_header->comps) {
- OPJ_UINT32 compno;
- for (compno = 0; compno < img_header->numcomps; compno++) {
- fprintf(out_stream, "%s\t component %d {\n", tab, compno);
- j2k_dump_image_comp_header(&(img_header->comps[compno]), dev_dump_flag,
- out_stream);
- fprintf(out_stream, "%s}\n", tab);
- }
- }
-
- fprintf(out_stream, "}\n");
-}
-
-void j2k_dump_image_comp_header(opj_image_comp_t* comp_header,
- OPJ_BOOL dev_dump_flag, FILE* out_stream)
-{
- char tab[3];
-
- if (dev_dump_flag) {
- fprintf(stdout, "[DEV] Dump an image_comp_header struct {\n");
- tab[0] = '\0';
- } else {
- tab[0] = '\t';
- tab[1] = '\t';
- tab[2] = '\0';
- }
-
- fprintf(out_stream, "%s dx=%d, dy=%d\n", tab, comp_header->dx, comp_header->dy);
- fprintf(out_stream, "%s prec=%d\n", tab, comp_header->prec);
- fprintf(out_stream, "%s sgnd=%d\n", tab, comp_header->sgnd);
-
- if (dev_dump_flag) {
- fprintf(out_stream, "}\n");
- }
-}
-
-opj_codestream_info_v2_t* j2k_get_cstr_info(opj_j2k_t* p_j2k)
-{
- OPJ_UINT32 compno;
- OPJ_UINT32 numcomps = p_j2k->m_private_image->numcomps;
- opj_tcp_t *l_default_tile;
- opj_codestream_info_v2_t* cstr_info = (opj_codestream_info_v2_t*) opj_calloc(1,
- sizeof(opj_codestream_info_v2_t));
- if (!cstr_info) {
- return NULL;
- }
-
- cstr_info->nbcomps = p_j2k->m_private_image->numcomps;
-
- cstr_info->tx0 = p_j2k->m_cp.tx0;
- cstr_info->ty0 = p_j2k->m_cp.ty0;
- cstr_info->tdx = p_j2k->m_cp.tdx;
- cstr_info->tdy = p_j2k->m_cp.tdy;
- cstr_info->tw = p_j2k->m_cp.tw;
- cstr_info->th = p_j2k->m_cp.th;
-
- cstr_info->tile_info = NULL; /* Not fill from the main header*/
-
- l_default_tile = p_j2k->m_specific_param.m_decoder.m_default_tcp;
-
- cstr_info->m_default_tile_info.csty = l_default_tile->csty;
- cstr_info->m_default_tile_info.prg = l_default_tile->prg;
- cstr_info->m_default_tile_info.numlayers = l_default_tile->numlayers;
- cstr_info->m_default_tile_info.mct = l_default_tile->mct;
-
- cstr_info->m_default_tile_info.tccp_info = (opj_tccp_info_t*) opj_calloc(
- cstr_info->nbcomps, sizeof(opj_tccp_info_t));
- if (!cstr_info->m_default_tile_info.tccp_info) {
- opj_destroy_cstr_info(&cstr_info);
- return NULL;
- }
-
- for (compno = 0; compno < numcomps; compno++) {
- opj_tccp_t *l_tccp = &(l_default_tile->tccps[compno]);
- opj_tccp_info_t *l_tccp_info = &
- (cstr_info->m_default_tile_info.tccp_info[compno]);
- OPJ_INT32 bandno, numbands;
-
- /* coding style*/
- l_tccp_info->csty = l_tccp->csty;
- l_tccp_info->numresolutions = l_tccp->numresolutions;
- l_tccp_info->cblkw = l_tccp->cblkw;
- l_tccp_info->cblkh = l_tccp->cblkh;
- l_tccp_info->cblksty = l_tccp->cblksty;
- l_tccp_info->qmfbid = l_tccp->qmfbid;
- if (l_tccp->numresolutions < OPJ_J2K_MAXRLVLS) {
- memcpy(l_tccp_info->prch, l_tccp->prch, l_tccp->numresolutions);
- memcpy(l_tccp_info->prcw, l_tccp->prcw, l_tccp->numresolutions);
- }
-
- /* quantization style*/
- l_tccp_info->qntsty = l_tccp->qntsty;
- l_tccp_info->numgbits = l_tccp->numgbits;
-
- numbands = (l_tccp->qntsty == J2K_CCP_QNTSTY_SIQNT) ? 1 :
- (OPJ_INT32)l_tccp->numresolutions * 3 - 2;
- if (numbands < OPJ_J2K_MAXBANDS) {
- for (bandno = 0; bandno < numbands; bandno++) {
- l_tccp_info->stepsizes_mant[bandno] = (OPJ_UINT32)
- l_tccp->stepsizes[bandno].mant;
- l_tccp_info->stepsizes_expn[bandno] = (OPJ_UINT32)
- l_tccp->stepsizes[bandno].expn;
- }
- }
-
- /* RGN value*/
- l_tccp_info->roishift = l_tccp->roishift;
- }
-
- return cstr_info;
-}
-
-opj_codestream_index_t* j2k_get_cstr_index(opj_j2k_t* p_j2k)
-{
- opj_codestream_index_t* l_cstr_index = (opj_codestream_index_t*)
- opj_calloc(1, sizeof(opj_codestream_index_t));
- if (!l_cstr_index) {
- return NULL;
- }
-
- l_cstr_index->main_head_start = p_j2k->cstr_index->main_head_start;
- l_cstr_index->main_head_end = p_j2k->cstr_index->main_head_end;
- l_cstr_index->codestream_size = p_j2k->cstr_index->codestream_size;
-
- l_cstr_index->marknum = p_j2k->cstr_index->marknum;
- l_cstr_index->marker = (opj_marker_info_t*)opj_malloc(l_cstr_index->marknum *
- sizeof(opj_marker_info_t));
- if (!l_cstr_index->marker) {
- opj_free(l_cstr_index);
- return NULL;
- }
-
- if (p_j2k->cstr_index->marker) {
- memcpy(l_cstr_index->marker, p_j2k->cstr_index->marker,
- l_cstr_index->marknum * sizeof(opj_marker_info_t));
- } else {
- opj_free(l_cstr_index->marker);
- l_cstr_index->marker = NULL;
- }
-
- l_cstr_index->nb_of_tiles = p_j2k->cstr_index->nb_of_tiles;
- l_cstr_index->tile_index = (opj_tile_index_t*)opj_calloc(
- l_cstr_index->nb_of_tiles, sizeof(opj_tile_index_t));
- if (!l_cstr_index->tile_index) {
- opj_free(l_cstr_index->marker);
- opj_free(l_cstr_index);
- return NULL;
- }
-
- if (!p_j2k->cstr_index->tile_index) {
- opj_free(l_cstr_index->tile_index);
- l_cstr_index->tile_index = NULL;
- } else {
- OPJ_UINT32 it_tile = 0;
- for (it_tile = 0; it_tile < l_cstr_index->nb_of_tiles; it_tile++) {
-
- /* Tile Marker*/
- l_cstr_index->tile_index[it_tile].marknum =
- p_j2k->cstr_index->tile_index[it_tile].marknum;
-
- l_cstr_index->tile_index[it_tile].marker =
- (opj_marker_info_t*)opj_malloc(l_cstr_index->tile_index[it_tile].marknum *
- sizeof(opj_marker_info_t));
-
- if (!l_cstr_index->tile_index[it_tile].marker) {
- OPJ_UINT32 it_tile_free;
-
- for (it_tile_free = 0; it_tile_free < it_tile; it_tile_free++) {
- opj_free(l_cstr_index->tile_index[it_tile_free].marker);
- }
-
- opj_free(l_cstr_index->tile_index);
- opj_free(l_cstr_index->marker);
- opj_free(l_cstr_index);
- return NULL;
- }
-
- if (p_j2k->cstr_index->tile_index[it_tile].marker)
- memcpy(l_cstr_index->tile_index[it_tile].marker,
- p_j2k->cstr_index->tile_index[it_tile].marker,
- l_cstr_index->tile_index[it_tile].marknum * sizeof(opj_marker_info_t));
- else {
- opj_free(l_cstr_index->tile_index[it_tile].marker);
- l_cstr_index->tile_index[it_tile].marker = NULL;
- }
-
- /* Tile part index*/
- l_cstr_index->tile_index[it_tile].nb_tps =
- p_j2k->cstr_index->tile_index[it_tile].nb_tps;
-
- l_cstr_index->tile_index[it_tile].tp_index =
- (opj_tp_index_t*)opj_malloc(l_cstr_index->tile_index[it_tile].nb_tps * sizeof(
- opj_tp_index_t));
-
- if (!l_cstr_index->tile_index[it_tile].tp_index) {
- OPJ_UINT32 it_tile_free;
-
- for (it_tile_free = 0; it_tile_free < it_tile; it_tile_free++) {
- opj_free(l_cstr_index->tile_index[it_tile_free].marker);
- opj_free(l_cstr_index->tile_index[it_tile_free].tp_index);
- }
-
- opj_free(l_cstr_index->tile_index);
- opj_free(l_cstr_index->marker);
- opj_free(l_cstr_index);
- return NULL;
- }
-
- if (p_j2k->cstr_index->tile_index[it_tile].tp_index) {
- memcpy(l_cstr_index->tile_index[it_tile].tp_index,
- p_j2k->cstr_index->tile_index[it_tile].tp_index,
- l_cstr_index->tile_index[it_tile].nb_tps * sizeof(opj_tp_index_t));
- } else {
- opj_free(l_cstr_index->tile_index[it_tile].tp_index);
- l_cstr_index->tile_index[it_tile].tp_index = NULL;
- }
-
- /* Packet index (NOT USED)*/
- l_cstr_index->tile_index[it_tile].nb_packet = 0;
- l_cstr_index->tile_index[it_tile].packet_index = NULL;
-
- }
- }
-
- return l_cstr_index;
-}
-
-static OPJ_BOOL opj_j2k_allocate_tile_element_cstr_index(opj_j2k_t *p_j2k)
-{
- OPJ_UINT32 it_tile = 0;
-
- p_j2k->cstr_index->nb_of_tiles = p_j2k->m_cp.tw * p_j2k->m_cp.th;
- p_j2k->cstr_index->tile_index = (opj_tile_index_t*)opj_calloc(
- p_j2k->cstr_index->nb_of_tiles, sizeof(opj_tile_index_t));
- if (!p_j2k->cstr_index->tile_index) {
- return OPJ_FALSE;
- }
-
- for (it_tile = 0; it_tile < p_j2k->cstr_index->nb_of_tiles; it_tile++) {
- p_j2k->cstr_index->tile_index[it_tile].maxmarknum = 100;
- p_j2k->cstr_index->tile_index[it_tile].marknum = 0;
- p_j2k->cstr_index->tile_index[it_tile].marker = (opj_marker_info_t*)
- opj_calloc(p_j2k->cstr_index->tile_index[it_tile].maxmarknum,
- sizeof(opj_marker_info_t));
- if (!p_j2k->cstr_index->tile_index[it_tile].marker) {
- return OPJ_FALSE;
- }
- }
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_are_all_used_components_decoded(opj_j2k_t *p_j2k,
- opj_event_mgr_t * p_manager)
-{
- OPJ_UINT32 compno;
- OPJ_BOOL decoded_all_used_components = OPJ_TRUE;
-
- if (p_j2k->m_specific_param.m_decoder.m_numcomps_to_decode) {
- for (compno = 0;
- compno < p_j2k->m_specific_param.m_decoder.m_numcomps_to_decode; compno++) {
- OPJ_UINT32 dec_compno =
- p_j2k->m_specific_param.m_decoder.m_comps_indices_to_decode[compno];
- if (p_j2k->m_output_image->comps[dec_compno].data == NULL) {
- opj_event_msg(p_manager, EVT_WARNING, "Failed to decode component %d\n",
- dec_compno);
- decoded_all_used_components = OPJ_FALSE;
- }
- }
- } else {
- for (compno = 0; compno < p_j2k->m_output_image->numcomps; compno++) {
- if (p_j2k->m_output_image->comps[compno].data == NULL) {
- opj_event_msg(p_manager, EVT_WARNING, "Failed to decode component %d\n",
- compno);
- decoded_all_used_components = OPJ_FALSE;
- }
- }
- }
-
- if (decoded_all_used_components == OPJ_FALSE) {
- opj_event_msg(p_manager, EVT_ERROR, "Failed to decode all used components\n");
- return OPJ_FALSE;
- }
-
- return OPJ_TRUE;
-}
-
-static int CompareOffT(const void* a, const void* b)
-{
- const OPJ_OFF_T offA = *(const OPJ_OFF_T*)a;
- const OPJ_OFF_T offB = *(const OPJ_OFF_T*)b;
- if (offA < offB) {
- return -1;
- }
- if (offA == offB) {
- return 0;
- }
- return 1;
-}
-
-static OPJ_BOOL opj_j2k_decode_tiles(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager)
-{
- OPJ_BOOL l_go_on = OPJ_TRUE;
- OPJ_UINT32 l_current_tile_no;
- OPJ_INT32 l_tile_x0, l_tile_y0, l_tile_x1, l_tile_y1;
- OPJ_UINT32 l_nb_comps;
- OPJ_UINT32 nr_tiles = 0;
- OPJ_OFF_T end_pos = 0;
-
- /* Particular case for whole single tile decoding */
- /* We can avoid allocating intermediate tile buffers */
- if (p_j2k->m_cp.tw == 1 && p_j2k->m_cp.th == 1 &&
- p_j2k->m_cp.tx0 == 0 && p_j2k->m_cp.ty0 == 0 &&
- p_j2k->m_output_image->x0 == 0 &&
- p_j2k->m_output_image->y0 == 0 &&
- p_j2k->m_output_image->x1 == p_j2k->m_cp.tdx &&
- p_j2k->m_output_image->y1 == p_j2k->m_cp.tdy) {
- OPJ_UINT32 i;
- if (! opj_j2k_read_tile_header(p_j2k,
- &l_current_tile_no,
- NULL,
- &l_tile_x0, &l_tile_y0,
- &l_tile_x1, &l_tile_y1,
- &l_nb_comps,
- &l_go_on,
- p_stream,
- p_manager)) {
- return OPJ_FALSE;
- }
-
- if (!l_go_on ||
- ! opj_j2k_decode_tile(p_j2k, l_current_tile_no, NULL, 0,
- p_stream, p_manager)) {
- opj_event_msg(p_manager, EVT_ERROR, "Failed to decode tile 1/1\n");
- return OPJ_FALSE;
- }
-
- /* Transfer TCD data to output image data */
- for (i = 0; i < p_j2k->m_output_image->numcomps; i++) {
- opj_image_data_free(p_j2k->m_output_image->comps[i].data);
- p_j2k->m_output_image->comps[i].data =
- p_j2k->m_tcd->tcd_image->tiles->comps[i].data;
- p_j2k->m_output_image->comps[i].resno_decoded =
- p_j2k->m_tcd->image->comps[i].resno_decoded;
- p_j2k->m_tcd->tcd_image->tiles->comps[i].data = NULL;
- }
-
- return OPJ_TRUE;
- }
-
- p_j2k->m_specific_param.m_decoder.m_num_intersecting_tile_parts = 0;
- p_j2k->m_specific_param.m_decoder.m_idx_intersecting_tile_parts = 0;
- opj_free(p_j2k->m_specific_param.m_decoder.m_intersecting_tile_parts_offset);
- p_j2k->m_specific_param.m_decoder.m_intersecting_tile_parts_offset = NULL;
-
- /* If the area to decode only intersects a subset of tiles, and we have
- * valid TLM information, then use it to plan the tilepart offsets to
- * seek to.
- */
- if (!(p_j2k->m_specific_param.m_decoder.m_start_tile_x == 0 &&
- p_j2k->m_specific_param.m_decoder.m_start_tile_y == 0 &&
- p_j2k->m_specific_param.m_decoder.m_end_tile_x == p_j2k->m_cp.tw &&
- p_j2k->m_specific_param.m_decoder.m_end_tile_y == p_j2k->m_cp.th) &&
- !p_j2k->m_specific_param.m_decoder.m_tlm.m_is_invalid &&
- opj_stream_has_seek(p_stream)) {
- OPJ_UINT32 m_num_intersecting_tile_parts = 0;
-
- OPJ_UINT32 j;
- for (j = 0; j < p_j2k->m_cp.tw * p_j2k->m_cp.th; ++j) {
- if (p_j2k->cstr_index->tile_index[j].nb_tps > 0 &&
- p_j2k->cstr_index->tile_index[j].tp_index[
- p_j2k->cstr_index->tile_index[j].nb_tps - 1].end_pos > end_pos) {
- end_pos = p_j2k->cstr_index->tile_index[j].tp_index[
- p_j2k->cstr_index->tile_index[j].nb_tps - 1].end_pos;
- }
- }
-
- for (j = p_j2k->m_specific_param.m_decoder.m_start_tile_y;
- j < p_j2k->m_specific_param.m_decoder.m_end_tile_y; ++j) {
- OPJ_UINT32 i;
- for (i = p_j2k->m_specific_param.m_decoder.m_start_tile_x;
- i < p_j2k->m_specific_param.m_decoder.m_end_tile_x; ++i) {
- const OPJ_UINT32 tile_number = j * p_j2k->m_cp.tw + i;
- m_num_intersecting_tile_parts +=
- p_j2k->cstr_index->tile_index[tile_number].nb_tps;
- }
- }
-
- p_j2k->m_specific_param.m_decoder.m_intersecting_tile_parts_offset =
- (OPJ_OFF_T*)
- opj_malloc(m_num_intersecting_tile_parts * sizeof(OPJ_OFF_T));
- if (m_num_intersecting_tile_parts > 0 &&
- p_j2k->m_specific_param.m_decoder.m_intersecting_tile_parts_offset) {
- OPJ_UINT32 idx = 0;
- for (j = p_j2k->m_specific_param.m_decoder.m_start_tile_y;
- j < p_j2k->m_specific_param.m_decoder.m_end_tile_y; ++j) {
- OPJ_UINT32 i;
- for (i = p_j2k->m_specific_param.m_decoder.m_start_tile_x;
- i < p_j2k->m_specific_param.m_decoder.m_end_tile_x; ++i) {
- const OPJ_UINT32 tile_number = j * p_j2k->m_cp.tw + i;
- OPJ_UINT32 k;
- for (k = 0; k < p_j2k->cstr_index->tile_index[tile_number].nb_tps; ++k) {
- const OPJ_OFF_T next_tp_sot_pos =
- p_j2k->cstr_index->tile_index[tile_number].tp_index[k].start_pos;
- p_j2k->m_specific_param.m_decoder.m_intersecting_tile_parts_offset[idx] =
- next_tp_sot_pos;
- ++idx;
- }
- }
- }
-
- p_j2k->m_specific_param.m_decoder.m_num_intersecting_tile_parts = idx;
-
- /* Sort by increasing offset */
- qsort(p_j2k->m_specific_param.m_decoder.m_intersecting_tile_parts_offset,
- p_j2k->m_specific_param.m_decoder.m_num_intersecting_tile_parts,
- sizeof(OPJ_OFF_T),
- CompareOffT);
- }
- }
-
- for (;;) {
- if (p_j2k->m_cp.tw == 1 && p_j2k->m_cp.th == 1 &&
- p_j2k->m_cp.tcps[0].m_data != NULL) {
- l_current_tile_no = 0;
- p_j2k->m_current_tile_number = 0;
- p_j2k->m_specific_param.m_decoder.m_state |= J2K_STATE_DATA;
- } else {
- if (! opj_j2k_read_tile_header(p_j2k,
- &l_current_tile_no,
- NULL,
- &l_tile_x0, &l_tile_y0,
- &l_tile_x1, &l_tile_y1,
- &l_nb_comps,
- &l_go_on,
- p_stream,
- p_manager)) {
- return OPJ_FALSE;
- }
-
- if (! l_go_on) {
- break;
- }
- }
-
- if (! opj_j2k_decode_tile(p_j2k, l_current_tile_no, NULL, 0,
- p_stream, p_manager)) {
- opj_event_msg(p_manager, EVT_ERROR, "Failed to decode tile %d/%d\n",
- l_current_tile_no + 1, p_j2k->m_cp.th * p_j2k->m_cp.tw);
- return OPJ_FALSE;
- }
-
- opj_event_msg(p_manager, EVT_INFO, "Tile %d/%d has been decoded.\n",
- l_current_tile_no + 1, p_j2k->m_cp.th * p_j2k->m_cp.tw);
-
- if (! opj_j2k_update_image_data(p_j2k->m_tcd,
- p_j2k->m_output_image)) {
- return OPJ_FALSE;
- }
-
- if (p_j2k->m_cp.tw == 1 && p_j2k->m_cp.th == 1 &&
- !(p_j2k->m_output_image->x0 == p_j2k->m_private_image->x0 &&
- p_j2k->m_output_image->y0 == p_j2k->m_private_image->y0 &&
- p_j2k->m_output_image->x1 == p_j2k->m_private_image->x1 &&
- p_j2k->m_output_image->y1 == p_j2k->m_private_image->y1)) {
- /* Keep current tcp data */
- } else {
- opj_j2k_tcp_data_destroy(&p_j2k->m_cp.tcps[l_current_tile_no]);
- }
-
- opj_event_msg(p_manager, EVT_INFO,
- "Image data has been updated with tile %d.\n\n", l_current_tile_no + 1);
-
- if (opj_stream_get_number_byte_left(p_stream) == 0
- && p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_NEOC) {
- break;
- }
- if (++nr_tiles == p_j2k->m_cp.th * p_j2k->m_cp.tw) {
- break;
- }
- if (p_j2k->m_specific_param.m_decoder.m_num_intersecting_tile_parts > 0 &&
- p_j2k->m_specific_param.m_decoder.m_idx_intersecting_tile_parts ==
- p_j2k->m_specific_param.m_decoder.m_num_intersecting_tile_parts) {
- opj_stream_seek(p_stream, end_pos + 2, p_manager);
- break;
- }
- }
-
- if (! opj_j2k_are_all_used_components_decoded(p_j2k, p_manager)) {
- return OPJ_FALSE;
- }
-
- return OPJ_TRUE;
-}
-
-/**
- * Sets up the procedures to do on decoding data. Developers wanting to extend the library can add their own reading procedures.
- */
-static OPJ_BOOL opj_j2k_setup_decoding(opj_j2k_t *p_j2k,
- opj_event_mgr_t * p_manager)
-{
- /* preconditions*/
- assert(p_j2k != 00);
- assert(p_manager != 00);
-
- if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,
- (opj_procedure)opj_j2k_decode_tiles, p_manager)) {
- return OPJ_FALSE;
- }
- /* DEVELOPER CORNER, add your custom procedures */
-
- return OPJ_TRUE;
-}
-
-/*
- * Read and decode one tile.
- */
-static OPJ_BOOL opj_j2k_decode_one_tile(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager)
-{
- OPJ_BOOL l_go_on = OPJ_TRUE;
- OPJ_UINT32 l_current_tile_no;
- OPJ_UINT32 l_tile_no_to_dec;
- OPJ_INT32 l_tile_x0, l_tile_y0, l_tile_x1, l_tile_y1;
- OPJ_UINT32 l_nb_comps;
- OPJ_UINT32 l_nb_tiles;
- OPJ_UINT32 i;
-
- /* Move into the codestream to the first SOT used to decode the desired tile */
- l_tile_no_to_dec = (OPJ_UINT32)
- p_j2k->m_specific_param.m_decoder.m_tile_ind_to_dec;
- if (p_j2k->cstr_index->tile_index)
- if (p_j2k->cstr_index->tile_index->tp_index) {
- if (! p_j2k->cstr_index->tile_index[l_tile_no_to_dec].nb_tps) {
- /* the index for this tile has not been built,
- * so move to the last SOT read */
- if (!(opj_stream_read_seek(p_stream,
- p_j2k->m_specific_param.m_decoder.m_last_sot_read_pos + 2, p_manager))) {
- opj_event_msg(p_manager, EVT_ERROR, "Problem with seek function\n");
- return OPJ_FALSE;
- }
- } else {
- OPJ_OFF_T sot_pos =
- p_j2k->cstr_index->tile_index[l_tile_no_to_dec].tp_index[0].start_pos;
- OPJ_UINT32 l_marker;
-
-#if 0
- opj_event_msg(p_manager, EVT_INFO,
- "opj_j2k_decode_one_tile(%u): seek to %" PRId64 "\n",
- l_tile_no_to_dec,
- sot_pos);
-#endif
- if (!(opj_stream_read_seek(p_stream,
- sot_pos,
- p_manager))) {
- opj_event_msg(p_manager, EVT_ERROR, "Problem with seek function\n");
- return OPJ_FALSE;
- }
-
- /* Try to read 2 bytes (the marker ID) from stream and copy them into the buffer */
- if (opj_stream_read_data(p_stream,
- p_j2k->m_specific_param.m_decoder.m_header_data, 2, p_manager) != 2) {
- opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
- return OPJ_FALSE;
- }
-
- /* Read 2 bytes from the buffer as the marker ID */
- opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data, &l_marker,
- 2);
-
- if (l_marker != J2K_MS_SOT) {
- opj_event_msg(p_manager, EVT_ERROR, "Did not get expected SOT marker\n");
- return OPJ_FALSE;
- }
- }
- /* Special case if we have previously read the EOC marker (if the previous tile getted is the last ) */
- if (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_EOC) {
- p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_TPHSOT;
- }
- }
-
- /* Reset current tile part number for all tiles, and not only the one */
- /* of interest. */
- /* Not completely sure this is always correct but required for */
- /* ./build/bin/j2k_random_tile_access ./build/tests/tte1.j2k */
- l_nb_tiles = p_j2k->m_cp.tw * p_j2k->m_cp.th;
- for (i = 0; i < l_nb_tiles; ++i) {
- p_j2k->m_cp.tcps[i].m_current_tile_part_number = -1;
- }
-
- for (;;) {
- if (! opj_j2k_read_tile_header(p_j2k,
- &l_current_tile_no,
- NULL,
- &l_tile_x0, &l_tile_y0,
- &l_tile_x1, &l_tile_y1,
- &l_nb_comps,
- &l_go_on,
- p_stream,
- p_manager)) {
- return OPJ_FALSE;
- }
-
- if (! l_go_on) {
- break;
- }
-
- if (! opj_j2k_decode_tile(p_j2k, l_current_tile_no, NULL, 0,
- p_stream, p_manager)) {
- return OPJ_FALSE;
- }
- opj_event_msg(p_manager, EVT_INFO, "Tile %d/%d has been decoded.\n",
- l_current_tile_no + 1, p_j2k->m_cp.th * p_j2k->m_cp.tw);
-
- if (! opj_j2k_update_image_data(p_j2k->m_tcd,
- p_j2k->m_output_image)) {
- return OPJ_FALSE;
- }
- opj_j2k_tcp_data_destroy(&p_j2k->m_cp.tcps[l_current_tile_no]);
-
- opj_event_msg(p_manager, EVT_INFO,
- "Image data has been updated with tile %d.\n\n", l_current_tile_no + 1);
-
- if (l_current_tile_no == l_tile_no_to_dec) {
- /* move into the codestream to the first SOT (FIXME or not move?)*/
- if (!(opj_stream_read_seek(p_stream, p_j2k->cstr_index->main_head_end + 2,
- p_manager))) {
- opj_event_msg(p_manager, EVT_ERROR, "Problem with seek function\n");
- return OPJ_FALSE;
- }
- break;
- } else {
- opj_event_msg(p_manager, EVT_WARNING,
- "Tile read, decoded and updated is not the desired one (%d vs %d).\n",
- l_current_tile_no + 1, l_tile_no_to_dec + 1);
- }
-
- }
-
- if (! opj_j2k_are_all_used_components_decoded(p_j2k, p_manager)) {
- return OPJ_FALSE;
- }
-
- return OPJ_TRUE;
-}
-
-/**
- * Sets up the procedures to do on decoding one tile. Developers wanting to extend the library can add their own reading procedures.
- */
-static OPJ_BOOL opj_j2k_setup_decoding_tile(opj_j2k_t *p_j2k,
- opj_event_mgr_t * p_manager)
-{
- /* preconditions*/
- assert(p_j2k != 00);
- assert(p_manager != 00);
-
- if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,
- (opj_procedure)opj_j2k_decode_one_tile, p_manager)) {
- return OPJ_FALSE;
- }
- /* DEVELOPER CORNER, add your custom procedures */
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_move_data_from_codec_to_output_image(opj_j2k_t * p_j2k,
- opj_image_t * p_image)
-{
- OPJ_UINT32 compno;
-
- /* Move data and copy one information from codec to output image*/
- if (p_j2k->m_specific_param.m_decoder.m_numcomps_to_decode > 0) {
- opj_image_comp_t* newcomps =
- (opj_image_comp_t*) opj_malloc(
- p_j2k->m_specific_param.m_decoder.m_numcomps_to_decode *
- sizeof(opj_image_comp_t));
- if (newcomps == NULL) {
- opj_image_destroy(p_j2k->m_private_image);
- p_j2k->m_private_image = NULL;
- return OPJ_FALSE;
- }
- for (compno = 0; compno < p_image->numcomps; compno++) {
- opj_image_data_free(p_image->comps[compno].data);
- p_image->comps[compno].data = NULL;
- }
- for (compno = 0;
- compno < p_j2k->m_specific_param.m_decoder.m_numcomps_to_decode; compno++) {
- OPJ_UINT32 src_compno =
- p_j2k->m_specific_param.m_decoder.m_comps_indices_to_decode[compno];
- memcpy(&(newcomps[compno]),
- &(p_j2k->m_output_image->comps[src_compno]),
- sizeof(opj_image_comp_t));
- newcomps[compno].resno_decoded =
- p_j2k->m_output_image->comps[src_compno].resno_decoded;
- newcomps[compno].data = p_j2k->m_output_image->comps[src_compno].data;
- p_j2k->m_output_image->comps[src_compno].data = NULL;
- }
- for (compno = 0; compno < p_image->numcomps; compno++) {
- assert(p_j2k->m_output_image->comps[compno].data == NULL);
- opj_image_data_free(p_j2k->m_output_image->comps[compno].data);
- p_j2k->m_output_image->comps[compno].data = NULL;
- }
- p_image->numcomps = p_j2k->m_specific_param.m_decoder.m_numcomps_to_decode;
- opj_free(p_image->comps);
- p_image->comps = newcomps;
- } else {
- for (compno = 0; compno < p_image->numcomps; compno++) {
- p_image->comps[compno].resno_decoded =
- p_j2k->m_output_image->comps[compno].resno_decoded;
- opj_image_data_free(p_image->comps[compno].data);
- p_image->comps[compno].data = p_j2k->m_output_image->comps[compno].data;
-#if 0
- char fn[256];
- snprintf(fn, sizeof fn, "/tmp/%d.raw", compno);
- FILE *debug = fopen(fn, "wb");
- fwrite(p_image->comps[compno].data, sizeof(OPJ_INT32),
- p_image->comps[compno].w * p_image->comps[compno].h, debug);
- fclose(debug);
-#endif
- p_j2k->m_output_image->comps[compno].data = NULL;
- }
- }
- return OPJ_TRUE;
-}
-
-OPJ_BOOL opj_j2k_decode(opj_j2k_t * p_j2k,
- opj_stream_private_t * p_stream,
- opj_image_t * p_image,
- opj_event_mgr_t * p_manager)
-{
- if (!p_image) {
- return OPJ_FALSE;
- }
-
- /* Heuristics to detect sequence opj_read_header(), opj_set_decoded_resolution_factor() */
- /* and finally opj_decode_image() without manual setting of comps[].factor */
- /* We could potentially always execute it, if we don't allow people to do */
- /* opj_read_header(), modify x0,y0,x1,y1 of returned image an call opj_decode_image() */
- if (p_j2k->m_cp.m_specific_param.m_dec.m_reduce > 0 &&
- p_j2k->m_private_image != NULL &&
- p_j2k->m_private_image->numcomps > 0 &&
- p_j2k->m_private_image->comps[0].factor ==
- p_j2k->m_cp.m_specific_param.m_dec.m_reduce &&
- p_image->numcomps > 0 &&
- p_image->comps[0].factor == 0 &&
- /* Don't mess with image dimension if the user has allocated it */
- p_image->comps[0].data == NULL) {
- OPJ_UINT32 it_comp;
-
- /* Update the comps[].factor member of the output image with the one */
- /* of m_reduce */
- for (it_comp = 0; it_comp < p_image->numcomps; ++it_comp) {
- p_image->comps[it_comp].factor = p_j2k->m_cp.m_specific_param.m_dec.m_reduce;
- }
- if (!opj_j2k_update_image_dimensions(p_image, p_manager)) {
- return OPJ_FALSE;
- }
- }
-
- if (p_j2k->m_output_image == NULL) {
- p_j2k->m_output_image = opj_image_create0();
- if (!(p_j2k->m_output_image)) {
- return OPJ_FALSE;
- }
- }
- opj_copy_image_header(p_image, p_j2k->m_output_image);
-
- /* customization of the decoding */
- if (!opj_j2k_setup_decoding(p_j2k, p_manager)) {
- return OPJ_FALSE;
- }
-
- /* Decode the codestream */
- if (! opj_j2k_exec(p_j2k, p_j2k->m_procedure_list, p_stream, p_manager)) {
- opj_image_destroy(p_j2k->m_private_image);
- p_j2k->m_private_image = NULL;
- return OPJ_FALSE;
- }
-
- /* Move data and copy one information from codec to output image*/
- return opj_j2k_move_data_from_codec_to_output_image(p_j2k, p_image);
-}
-
-OPJ_BOOL opj_j2k_get_tile(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_image_t* p_image,
- opj_event_mgr_t * p_manager,
- OPJ_UINT32 tile_index)
-{
- OPJ_UINT32 compno;
- OPJ_UINT32 l_tile_x, l_tile_y;
- opj_image_comp_t* l_img_comp;
-
- if (!p_image) {
- opj_event_msg(p_manager, EVT_ERROR, "We need an image previously created.\n");
- return OPJ_FALSE;
- }
-
- if (p_image->numcomps < p_j2k->m_private_image->numcomps) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Image has less components than codestream.\n");
- return OPJ_FALSE;
- }
-
- if (/*(tile_index < 0) &&*/ (tile_index >= p_j2k->m_cp.tw * p_j2k->m_cp.th)) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Tile index provided by the user is incorrect %d (max = %d) \n", tile_index,
- (p_j2k->m_cp.tw * p_j2k->m_cp.th) - 1);
- return OPJ_FALSE;
- }
-
- /* Compute the dimension of the desired tile*/
- l_tile_x = tile_index % p_j2k->m_cp.tw;
- l_tile_y = tile_index / p_j2k->m_cp.tw;
-
- p_image->x0 = l_tile_x * p_j2k->m_cp.tdx + p_j2k->m_cp.tx0;
- if (p_image->x0 < p_j2k->m_private_image->x0) {
- p_image->x0 = p_j2k->m_private_image->x0;
- }
- p_image->x1 = (l_tile_x + 1) * p_j2k->m_cp.tdx + p_j2k->m_cp.tx0;
- if (p_image->x1 > p_j2k->m_private_image->x1) {
- p_image->x1 = p_j2k->m_private_image->x1;
- }
-
- p_image->y0 = l_tile_y * p_j2k->m_cp.tdy + p_j2k->m_cp.ty0;
- if (p_image->y0 < p_j2k->m_private_image->y0) {
- p_image->y0 = p_j2k->m_private_image->y0;
- }
- p_image->y1 = (l_tile_y + 1) * p_j2k->m_cp.tdy + p_j2k->m_cp.ty0;
- if (p_image->y1 > p_j2k->m_private_image->y1) {
- p_image->y1 = p_j2k->m_private_image->y1;
- }
-
- l_img_comp = p_image->comps;
- for (compno = 0; compno < p_j2k->m_private_image->numcomps; ++compno) {
- OPJ_INT32 l_comp_x1, l_comp_y1;
-
- l_img_comp->factor = p_j2k->m_private_image->comps[compno].factor;
-
- l_img_comp->x0 = opj_uint_ceildiv(p_image->x0, l_img_comp->dx);
- l_img_comp->y0 = opj_uint_ceildiv(p_image->y0, l_img_comp->dy);
- l_comp_x1 = opj_int_ceildiv((OPJ_INT32)p_image->x1, (OPJ_INT32)l_img_comp->dx);
- l_comp_y1 = opj_int_ceildiv((OPJ_INT32)p_image->y1, (OPJ_INT32)l_img_comp->dy);
-
- l_img_comp->w = (OPJ_UINT32)(opj_int_ceildivpow2(l_comp_x1,
- (OPJ_INT32)l_img_comp->factor) - opj_int_ceildivpow2((OPJ_INT32)l_img_comp->x0,
- (OPJ_INT32)l_img_comp->factor));
- l_img_comp->h = (OPJ_UINT32)(opj_int_ceildivpow2(l_comp_y1,
- (OPJ_INT32)l_img_comp->factor) - opj_int_ceildivpow2((OPJ_INT32)l_img_comp->y0,
- (OPJ_INT32)l_img_comp->factor));
-
- l_img_comp++;
- }
-
- if (p_image->numcomps > p_j2k->m_private_image->numcomps) {
- /* Can happen when calling repeatdly opj_get_decoded_tile() on an
- * image with a color palette, where color palette expansion is done
- * later in jp2.c */
- for (compno = p_j2k->m_private_image->numcomps; compno < p_image->numcomps;
- ++compno) {
- opj_image_data_free(p_image->comps[compno].data);
- p_image->comps[compno].data = NULL;
- }
- p_image->numcomps = p_j2k->m_private_image->numcomps;
- }
-
- /* Destroy the previous output image*/
- if (p_j2k->m_output_image) {
- opj_image_destroy(p_j2k->m_output_image);
- }
-
- /* Create the output image from the information previously computed*/
- p_j2k->m_output_image = opj_image_create0();
- if (!(p_j2k->m_output_image)) {
- return OPJ_FALSE;
- }
- opj_copy_image_header(p_image, p_j2k->m_output_image);
-
- p_j2k->m_specific_param.m_decoder.m_tile_ind_to_dec = (OPJ_INT32)tile_index;
-
- /* customization of the decoding */
- if (!opj_j2k_setup_decoding_tile(p_j2k, p_manager)) {
- return OPJ_FALSE;
- }
-
- /* Decode the codestream */
- if (! opj_j2k_exec(p_j2k, p_j2k->m_procedure_list, p_stream, p_manager)) {
- opj_image_destroy(p_j2k->m_private_image);
- p_j2k->m_private_image = NULL;
- return OPJ_FALSE;
- }
-
- /* Move data and copy one information from codec to output image*/
- return opj_j2k_move_data_from_codec_to_output_image(p_j2k, p_image);
-}
-
-OPJ_BOOL opj_j2k_set_decoded_resolution_factor(opj_j2k_t *p_j2k,
- OPJ_UINT32 res_factor,
- opj_event_mgr_t * p_manager)
-{
- OPJ_UINT32 it_comp;
-
- p_j2k->m_cp.m_specific_param.m_dec.m_reduce = res_factor;
-
- if (p_j2k->m_private_image) {
- if (p_j2k->m_private_image->comps) {
- if (p_j2k->m_specific_param.m_decoder.m_default_tcp) {
- if (p_j2k->m_specific_param.m_decoder.m_default_tcp->tccps) {
- for (it_comp = 0 ; it_comp < p_j2k->m_private_image->numcomps; it_comp++) {
- OPJ_UINT32 max_res =
- p_j2k->m_specific_param.m_decoder.m_default_tcp->tccps[it_comp].numresolutions;
- if (res_factor >= max_res) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Resolution factor is greater than the maximum resolution in the component.\n");
- return OPJ_FALSE;
- }
- p_j2k->m_private_image->comps[it_comp].factor = res_factor;
- }
- return OPJ_TRUE;
- }
- }
- }
- }
-
- return OPJ_FALSE;
-}
-
-/* ----------------------------------------------------------------------- */
-
-OPJ_BOOL opj_j2k_encoder_set_extra_options(
- opj_j2k_t *p_j2k,
- const char* const* p_options,
- opj_event_mgr_t * p_manager)
-{
- const char* const* p_option_iter;
-
- if (p_options == NULL) {
- return OPJ_TRUE;
- }
-
- for (p_option_iter = p_options; *p_option_iter != NULL; ++p_option_iter) {
- if (strncmp(*p_option_iter, "PLT=", 4) == 0) {
- if (strcmp(*p_option_iter, "PLT=YES") == 0) {
- p_j2k->m_specific_param.m_encoder.m_PLT = OPJ_TRUE;
- } else if (strcmp(*p_option_iter, "PLT=NO") == 0) {
- p_j2k->m_specific_param.m_encoder.m_PLT = OPJ_FALSE;
- } else {
- opj_event_msg(p_manager, EVT_ERROR,
- "Invalid value for option: %s.\n", *p_option_iter);
- return OPJ_FALSE;
- }
- } else if (strncmp(*p_option_iter, "TLM=", 4) == 0) {
- if (strcmp(*p_option_iter, "TLM=YES") == 0) {
- p_j2k->m_specific_param.m_encoder.m_TLM = OPJ_TRUE;
- } else if (strcmp(*p_option_iter, "TLM=NO") == 0) {
- p_j2k->m_specific_param.m_encoder.m_TLM = OPJ_FALSE;
- } else {
- opj_event_msg(p_manager, EVT_ERROR,
- "Invalid value for option: %s.\n", *p_option_iter);
- return OPJ_FALSE;
- }
- } else if (strncmp(*p_option_iter, "GUARD_BITS=", strlen("GUARD_BITS=")) == 0) {
- OPJ_UINT32 tileno;
- opj_cp_t *cp = cp = &(p_j2k->m_cp);
-
- int numgbits = atoi(*p_option_iter + strlen("GUARD_BITS="));
- if (numgbits < 0 || numgbits > 7) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Invalid value for option: %s. Should be in [0,7]\n", *p_option_iter);
- return OPJ_FALSE;
- }
-
- for (tileno = 0; tileno < cp->tw * cp->th; tileno++) {
- OPJ_UINT32 i;
- opj_tcp_t *tcp = &cp->tcps[tileno];
- for (i = 0; i < p_j2k->m_specific_param.m_encoder.m_nb_comps; i++) {
- opj_tccp_t *tccp = &tcp->tccps[i];
- tccp->numgbits = (OPJ_UINT32)numgbits;
- }
- }
- } else {
- opj_event_msg(p_manager, EVT_ERROR,
- "Invalid option: %s.\n", *p_option_iter);
- return OPJ_FALSE;
- }
- }
-
- return OPJ_TRUE;
-}
-
-/* ----------------------------------------------------------------------- */
-
-OPJ_BOOL opj_j2k_encode(opj_j2k_t * p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager)
-{
- OPJ_UINT32 i, j;
- OPJ_UINT32 l_nb_tiles;
- OPJ_SIZE_T l_max_tile_size = 0, l_current_tile_size;
- OPJ_BYTE * l_current_data = 00;
- OPJ_BOOL l_reuse_data = OPJ_FALSE;
- opj_tcd_t* p_tcd = 00;
-
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_stream != 00);
- assert(p_manager != 00);
-
- p_tcd = p_j2k->m_tcd;
-
- l_nb_tiles = p_j2k->m_cp.th * p_j2k->m_cp.tw;
- if (l_nb_tiles == 1) {
- l_reuse_data = OPJ_TRUE;
-#ifdef __SSE__
- for (j = 0; j < p_j2k->m_tcd->image->numcomps; ++j) {
- opj_image_comp_t * l_img_comp = p_tcd->image->comps + j;
- if (((size_t)l_img_comp->data & 0xFU) !=
- 0U) { /* tile data shall be aligned on 16 bytes */
- l_reuse_data = OPJ_FALSE;
- }
- }
-#endif
- }
- for (i = 0; i < l_nb_tiles; ++i) {
- if (! opj_j2k_pre_write_tile(p_j2k, i, p_stream, p_manager)) {
- if (l_current_data) {
- opj_free(l_current_data);
- }
- return OPJ_FALSE;
- }
-
- /* if we only have one tile, then simply set tile component data equal to image component data */
- /* otherwise, allocate the data */
- for (j = 0; j < p_j2k->m_tcd->image->numcomps; ++j) {
- opj_tcd_tilecomp_t* l_tilec = p_tcd->tcd_image->tiles->comps + j;
- if (l_reuse_data) {
- opj_image_comp_t * l_img_comp = p_tcd->image->comps + j;
- l_tilec->data = l_img_comp->data;
- l_tilec->ownsData = OPJ_FALSE;
- } else {
- if (! opj_alloc_tile_component_data(l_tilec)) {
- opj_event_msg(p_manager, EVT_ERROR, "Error allocating tile component data.");
- if (l_current_data) {
- opj_free(l_current_data);
- }
- return OPJ_FALSE;
- }
- }
- }
- l_current_tile_size = opj_tcd_get_encoder_input_buffer_size(p_j2k->m_tcd);
- if (!l_reuse_data) {
- if (l_current_tile_size > l_max_tile_size) {
- OPJ_BYTE *l_new_current_data = (OPJ_BYTE *) opj_realloc(l_current_data,
- l_current_tile_size);
- if (! l_new_current_data) {
- if (l_current_data) {
- opj_free(l_current_data);
- }
- opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to encode all tiles\n");
- return OPJ_FALSE;
- }
- l_current_data = l_new_current_data;
- l_max_tile_size = l_current_tile_size;
- }
- if (l_current_data == NULL) {
- /* Should not happen in practice, but will avoid Coverity to */
- /* complain about a null pointer dereference */
- assert(0);
- return OPJ_FALSE;
- }
-
- /* copy image data (32 bit) to l_current_data as contiguous, all-component, zero offset buffer */
- /* 32 bit components @ 8 bit precision get converted to 8 bit */
- /* 32 bit components @ 16 bit precision get converted to 16 bit */
- opj_j2k_get_tile_data(p_j2k->m_tcd, l_current_data);
-
- /* now copy this data into the tile component */
- if (! opj_tcd_copy_tile_data(p_j2k->m_tcd, l_current_data,
- l_current_tile_size)) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Size mismatch between tile data and sent data.");
- opj_free(l_current_data);
- return OPJ_FALSE;
- }
- }
-
- if (! opj_j2k_post_write_tile(p_j2k, p_stream, p_manager)) {
- if (l_current_data) {
- opj_free(l_current_data);
- }
- return OPJ_FALSE;
- }
- }
-
- if (l_current_data) {
- opj_free(l_current_data);
- }
- return OPJ_TRUE;
-}
-
-OPJ_BOOL opj_j2k_end_compress(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager)
-{
- /* customization of the encoding */
- if (! opj_j2k_setup_end_compress(p_j2k, p_manager)) {
- return OPJ_FALSE;
- }
-
- if (! opj_j2k_exec(p_j2k, p_j2k->m_procedure_list, p_stream, p_manager)) {
- return OPJ_FALSE;
- }
-
- return OPJ_TRUE;
-}
-
-OPJ_BOOL opj_j2k_start_compress(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_image_t * p_image,
- opj_event_mgr_t * p_manager)
-{
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_stream != 00);
- assert(p_manager != 00);
-
- p_j2k->m_private_image = opj_image_create0();
- if (! p_j2k->m_private_image) {
- opj_event_msg(p_manager, EVT_ERROR, "Failed to allocate image header.");
- return OPJ_FALSE;
- }
- opj_copy_image_header(p_image, p_j2k->m_private_image);
-
- /* TODO_MSD: Find a better way */
- if (p_image->comps) {
- OPJ_UINT32 it_comp;
- for (it_comp = 0 ; it_comp < p_image->numcomps; it_comp++) {
- if (p_image->comps[it_comp].data) {
- p_j2k->m_private_image->comps[it_comp].data = p_image->comps[it_comp].data;
- p_image->comps[it_comp].data = NULL;
-
- }
- }
- }
-
- /* customization of the validation */
- if (! opj_j2k_setup_encoding_validation(p_j2k, p_manager)) {
- return OPJ_FALSE;
- }
-
- /* validation of the parameters codec */
- if (! opj_j2k_exec(p_j2k, p_j2k->m_validation_list, p_stream, p_manager)) {
- return OPJ_FALSE;
- }
-
- /* customization of the encoding */
- if (! opj_j2k_setup_header_writing(p_j2k, p_manager)) {
- return OPJ_FALSE;
- }
-
- /* write header */
- if (! opj_j2k_exec(p_j2k, p_j2k->m_procedure_list, p_stream, p_manager)) {
- return OPJ_FALSE;
- }
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_pre_write_tile(opj_j2k_t * p_j2k,
- OPJ_UINT32 p_tile_index,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager)
-{
- (void)p_stream;
- if (p_tile_index != p_j2k->m_current_tile_number) {
- opj_event_msg(p_manager, EVT_ERROR, "The given tile index does not match.");
- return OPJ_FALSE;
- }
-
- opj_event_msg(p_manager, EVT_INFO, "tile number %d / %d\n",
- p_j2k->m_current_tile_number + 1, p_j2k->m_cp.tw * p_j2k->m_cp.th);
-
- p_j2k->m_specific_param.m_encoder.m_current_tile_part_number = 0;
- p_j2k->m_tcd->cur_totnum_tp = p_j2k->m_cp.tcps[p_tile_index].m_nb_tile_parts;
- p_j2k->m_specific_param.m_encoder.m_current_poc_tile_part_number = 0;
-
- /* initialisation before tile encoding */
- if (! opj_tcd_init_encode_tile(p_j2k->m_tcd, p_j2k->m_current_tile_number,
- p_manager)) {
- return OPJ_FALSE;
- }
-
- return OPJ_TRUE;
-}
-
-static void opj_get_tile_dimensions(opj_image_t * l_image,
- opj_tcd_tilecomp_t * l_tilec,
- opj_image_comp_t * l_img_comp,
- OPJ_UINT32* l_size_comp,
- OPJ_UINT32* l_width,
- OPJ_UINT32* l_height,
- OPJ_UINT32* l_offset_x,
- OPJ_UINT32* l_offset_y,
- OPJ_UINT32* l_image_width,
- OPJ_UINT32* l_stride,
- OPJ_UINT32* l_tile_offset)
-{
- OPJ_UINT32 l_remaining;
- *l_size_comp = l_img_comp->prec >> 3; /* (/8) */
- l_remaining = l_img_comp->prec & 7; /* (%8) */
- if (l_remaining) {
- *l_size_comp += 1;
- }
-
- if (*l_size_comp == 3) {
- *l_size_comp = 4;
- }
-
- *l_width = (OPJ_UINT32)(l_tilec->x1 - l_tilec->x0);
- *l_height = (OPJ_UINT32)(l_tilec->y1 - l_tilec->y0);
- *l_offset_x = opj_uint_ceildiv(l_image->x0, l_img_comp->dx);
- *l_offset_y = opj_uint_ceildiv(l_image->y0, l_img_comp->dy);
- *l_image_width = opj_uint_ceildiv(l_image->x1 - l_image->x0, l_img_comp->dx);
- *l_stride = *l_image_width - *l_width;
- *l_tile_offset = ((OPJ_UINT32)l_tilec->x0 - *l_offset_x) + ((
- OPJ_UINT32)l_tilec->y0 - *l_offset_y) * *l_image_width;
-}
-
-static void opj_j2k_get_tile_data(opj_tcd_t * p_tcd, OPJ_BYTE * p_data)
-{
- OPJ_UINT32 i, j, k = 0;
-
- for (i = 0; i < p_tcd->image->numcomps; ++i) {
- opj_image_t * l_image = p_tcd->image;
- OPJ_INT32 * l_src_ptr;
- opj_tcd_tilecomp_t * l_tilec = p_tcd->tcd_image->tiles->comps + i;
- opj_image_comp_t * l_img_comp = l_image->comps + i;
- OPJ_UINT32 l_size_comp, l_width, l_height, l_offset_x, l_offset_y,
- l_image_width, l_stride, l_tile_offset;
-
- opj_get_tile_dimensions(l_image,
- l_tilec,
- l_img_comp,
- &l_size_comp,
- &l_width,
- &l_height,
- &l_offset_x,
- &l_offset_y,
- &l_image_width,
- &l_stride,
- &l_tile_offset);
-
- l_src_ptr = l_img_comp->data + l_tile_offset;
-
- switch (l_size_comp) {
- case 1: {
- OPJ_CHAR * l_dest_ptr = (OPJ_CHAR*) p_data;
- if (l_img_comp->sgnd) {
- for (j = 0; j < l_height; ++j) {
- for (k = 0; k < l_width; ++k) {
- *(l_dest_ptr) = (OPJ_CHAR)(*l_src_ptr);
- ++l_dest_ptr;
- ++l_src_ptr;
- }
- l_src_ptr += l_stride;
- }
- } else {
- for (j = 0; j < l_height; ++j) {
- for (k = 0; k < l_width; ++k) {
- *(l_dest_ptr) = (OPJ_CHAR)((*l_src_ptr) & 0xff);
- ++l_dest_ptr;
- ++l_src_ptr;
- }
- l_src_ptr += l_stride;
- }
- }
-
- p_data = (OPJ_BYTE*) l_dest_ptr;
- }
- break;
- case 2: {
- OPJ_INT16 * l_dest_ptr = (OPJ_INT16 *) p_data;
- if (l_img_comp->sgnd) {
- for (j = 0; j < l_height; ++j) {
- for (k = 0; k < l_width; ++k) {
- *(l_dest_ptr++) = (OPJ_INT16)(*(l_src_ptr++));
- }
- l_src_ptr += l_stride;
- }
- } else {
- for (j = 0; j < l_height; ++j) {
- for (k = 0; k < l_width; ++k) {
- *(l_dest_ptr++) = (OPJ_INT16)((*(l_src_ptr++)) & 0xffff);
- }
- l_src_ptr += l_stride;
- }
- }
-
- p_data = (OPJ_BYTE*) l_dest_ptr;
- }
- break;
- case 4: {
- OPJ_INT32 * l_dest_ptr = (OPJ_INT32 *) p_data;
- for (j = 0; j < l_height; ++j) {
- for (k = 0; k < l_width; ++k) {
- *(l_dest_ptr++) = *(l_src_ptr++);
- }
- l_src_ptr += l_stride;
- }
-
- p_data = (OPJ_BYTE*) l_dest_ptr;
- }
- break;
- }
- }
-}
-
-static OPJ_BOOL opj_j2k_post_write_tile(opj_j2k_t * p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager)
-{
- OPJ_UINT32 l_nb_bytes_written;
- OPJ_BYTE * l_current_data = 00;
- OPJ_UINT32 l_tile_size = 0;
- OPJ_UINT32 l_available_data;
-
- /* preconditions */
- assert(p_j2k->m_specific_param.m_encoder.m_encoded_tile_data);
-
- l_tile_size = p_j2k->m_specific_param.m_encoder.m_encoded_tile_size;
- l_available_data = l_tile_size;
- l_current_data = p_j2k->m_specific_param.m_encoder.m_encoded_tile_data;
-
- l_nb_bytes_written = 0;
- if (! opj_j2k_write_first_tile_part(p_j2k, l_current_data, &l_nb_bytes_written,
- l_available_data, p_stream, p_manager)) {
- return OPJ_FALSE;
- }
- l_current_data += l_nb_bytes_written;
- l_available_data -= l_nb_bytes_written;
-
- l_nb_bytes_written = 0;
- if (! opj_j2k_write_all_tile_parts(p_j2k, l_current_data, &l_nb_bytes_written,
- l_available_data, p_stream, p_manager)) {
- return OPJ_FALSE;
- }
-
- l_available_data -= l_nb_bytes_written;
- l_nb_bytes_written = l_tile_size - l_available_data;
-
- if (opj_stream_write_data(p_stream,
- p_j2k->m_specific_param.m_encoder.m_encoded_tile_data,
- l_nb_bytes_written, p_manager) != l_nb_bytes_written) {
- return OPJ_FALSE;
- }
-
- ++p_j2k->m_current_tile_number;
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_setup_end_compress(opj_j2k_t *p_j2k,
- opj_event_mgr_t * p_manager)
-{
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_manager != 00);
-
- /* DEVELOPER CORNER, insert your custom procedures */
- if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,
- (opj_procedure)opj_j2k_write_eoc, p_manager)) {
- return OPJ_FALSE;
- }
-
- if (p_j2k->m_specific_param.m_encoder.m_TLM) {
- if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,
- (opj_procedure)opj_j2k_write_updated_tlm, p_manager)) {
- return OPJ_FALSE;
- }
- }
-
- if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,
- (opj_procedure)opj_j2k_write_epc, p_manager)) {
- return OPJ_FALSE;
- }
- if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,
- (opj_procedure)opj_j2k_end_encoding, p_manager)) {
- return OPJ_FALSE;
- }
- if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,
- (opj_procedure)opj_j2k_destroy_header_memory, p_manager)) {
- return OPJ_FALSE;
- }
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_setup_encoding_validation(opj_j2k_t *p_j2k,
- opj_event_mgr_t * p_manager)
-{
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_manager != 00);
-
- if (! opj_procedure_list_add_procedure(p_j2k->m_validation_list,
- (opj_procedure)opj_j2k_build_encoder, p_manager)) {
- return OPJ_FALSE;
- }
- if (! opj_procedure_list_add_procedure(p_j2k->m_validation_list,
- (opj_procedure)opj_j2k_encoding_validation, p_manager)) {
- return OPJ_FALSE;
- }
-
- /* DEVELOPER CORNER, add your custom validation procedure */
- if (! opj_procedure_list_add_procedure(p_j2k->m_validation_list,
- (opj_procedure)opj_j2k_mct_validation, p_manager)) {
- return OPJ_FALSE;
- }
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_setup_header_writing(opj_j2k_t *p_j2k,
- opj_event_mgr_t * p_manager)
-{
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_manager != 00);
-
- if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,
- (opj_procedure)opj_j2k_init_info, p_manager)) {
- return OPJ_FALSE;
- }
- if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,
- (opj_procedure)opj_j2k_write_soc, p_manager)) {
- return OPJ_FALSE;
- }
- if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,
- (opj_procedure)opj_j2k_write_siz, p_manager)) {
- return OPJ_FALSE;
- }
- if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,
- (opj_procedure)opj_j2k_write_cod, p_manager)) {
- return OPJ_FALSE;
- }
- if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,
- (opj_procedure)opj_j2k_write_qcd, p_manager)) {
- return OPJ_FALSE;
- }
- if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,
- (opj_procedure)opj_j2k_write_all_coc, p_manager)) {
- return OPJ_FALSE;
- }
- if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,
- (opj_procedure)opj_j2k_write_all_qcc, p_manager)) {
- return OPJ_FALSE;
- }
-
- if (p_j2k->m_specific_param.m_encoder.m_TLM) {
- if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,
- (opj_procedure)opj_j2k_write_tlm, p_manager)) {
- return OPJ_FALSE;
- }
-
- if (p_j2k->m_cp.rsiz == OPJ_PROFILE_CINEMA_4K) {
- if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,
- (opj_procedure)opj_j2k_write_poc, p_manager)) {
- return OPJ_FALSE;
- }
- }
- }
-
- if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,
- (opj_procedure)opj_j2k_write_regions, p_manager)) {
- return OPJ_FALSE;
- }
-
- if (p_j2k->m_cp.comment != 00) {
- if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,
- (opj_procedure)opj_j2k_write_com, p_manager)) {
- return OPJ_FALSE;
- }
- }
-
- /* DEVELOPER CORNER, insert your custom procedures */
- if ((p_j2k->m_cp.rsiz & (OPJ_PROFILE_PART2 | OPJ_EXTENSION_MCT)) ==
- (OPJ_PROFILE_PART2 | OPJ_EXTENSION_MCT)) {
- if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,
- (opj_procedure)opj_j2k_write_mct_data_group, p_manager)) {
- return OPJ_FALSE;
- }
- }
- /* End of Developer Corner */
-
- if (p_j2k->cstr_index) {
- if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,
- (opj_procedure)opj_j2k_get_end_header, p_manager)) {
- return OPJ_FALSE;
- }
- }
-
- if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,
- (opj_procedure)opj_j2k_create_tcd, p_manager)) {
- return OPJ_FALSE;
- }
- if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,
- (opj_procedure)opj_j2k_update_rates, p_manager)) {
- return OPJ_FALSE;
- }
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_write_first_tile_part(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_data,
- OPJ_UINT32 * p_data_written,
- OPJ_UINT32 total_data_size,
- opj_stream_private_t *p_stream,
- struct opj_event_mgr * p_manager)
-{
- OPJ_UINT32 l_nb_bytes_written = 0;
- OPJ_UINT32 l_current_nb_bytes_written;
- OPJ_BYTE * l_begin_data = 00;
-
- opj_tcd_t * l_tcd = 00;
- opj_cp_t * l_cp = 00;
-
- l_tcd = p_j2k->m_tcd;
- l_cp = &(p_j2k->m_cp);
-
- l_tcd->cur_pino = 0;
-
- /*Get number of tile parts*/
- p_j2k->m_specific_param.m_encoder.m_current_poc_tile_part_number = 0;
-
- /* INDEX >> */
- /* << INDEX */
-
- l_current_nb_bytes_written = 0;
- l_begin_data = p_data;
- if (! opj_j2k_write_sot(p_j2k, p_data, total_data_size,
- &l_current_nb_bytes_written, p_stream,
- p_manager)) {
- return OPJ_FALSE;
- }
-
- l_nb_bytes_written += l_current_nb_bytes_written;
- p_data += l_current_nb_bytes_written;
- total_data_size -= l_current_nb_bytes_written;
-
- if (!OPJ_IS_CINEMA(l_cp->rsiz)) {
-#if 0
- for (compno = 1; compno < p_j2k->m_private_image->numcomps; compno++) {
- l_current_nb_bytes_written = 0;
- opj_j2k_write_coc_in_memory(p_j2k, compno, p_data, &l_current_nb_bytes_written,
- p_manager);
- l_nb_bytes_written += l_current_nb_bytes_written;
- p_data += l_current_nb_bytes_written;
- total_data_size -= l_current_nb_bytes_written;
-
- l_current_nb_bytes_written = 0;
- opj_j2k_write_qcc_in_memory(p_j2k, compno, p_data, &l_current_nb_bytes_written,
- p_manager);
- l_nb_bytes_written += l_current_nb_bytes_written;
- p_data += l_current_nb_bytes_written;
- total_data_size -= l_current_nb_bytes_written;
- }
-#endif
- if (l_cp->tcps[p_j2k->m_current_tile_number].POC) {
- l_current_nb_bytes_written = 0;
- opj_j2k_write_poc_in_memory(p_j2k, p_data, &l_current_nb_bytes_written,
- p_manager);
- l_nb_bytes_written += l_current_nb_bytes_written;
- p_data += l_current_nb_bytes_written;
- total_data_size -= l_current_nb_bytes_written;
- }
- }
-
- l_current_nb_bytes_written = 0;
- if (! opj_j2k_write_sod(p_j2k, l_tcd, p_data, &l_current_nb_bytes_written,
- total_data_size, p_stream, p_manager)) {
- return OPJ_FALSE;
- }
-
- l_nb_bytes_written += l_current_nb_bytes_written;
- * p_data_written = l_nb_bytes_written;
-
- /* Writing Psot in SOT marker */
- opj_write_bytes(l_begin_data + 6, l_nb_bytes_written,
- 4); /* PSOT */
-
- if (p_j2k->m_specific_param.m_encoder.m_TLM) {
- opj_j2k_update_tlm(p_j2k, l_nb_bytes_written);
- }
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_write_all_tile_parts(opj_j2k_t *p_j2k,
- OPJ_BYTE * p_data,
- OPJ_UINT32 * p_data_written,
- OPJ_UINT32 total_data_size,
- opj_stream_private_t *p_stream,
- struct opj_event_mgr * p_manager
- )
-{
- OPJ_UINT32 tilepartno = 0;
- OPJ_UINT32 l_nb_bytes_written = 0;
- OPJ_UINT32 l_current_nb_bytes_written;
- OPJ_UINT32 l_part_tile_size;
- OPJ_UINT32 tot_num_tp;
- OPJ_UINT32 pino;
-
- OPJ_BYTE * l_begin_data;
- opj_tcp_t *l_tcp = 00;
- opj_tcd_t * l_tcd = 00;
- opj_cp_t * l_cp = 00;
-
- l_tcd = p_j2k->m_tcd;
- l_cp = &(p_j2k->m_cp);
- l_tcp = l_cp->tcps + p_j2k->m_current_tile_number;
-
- /*Get number of tile parts*/
- tot_num_tp = opj_j2k_get_num_tp(l_cp, 0, p_j2k->m_current_tile_number);
-
- /* start writing remaining tile parts */
- ++p_j2k->m_specific_param.m_encoder.m_current_tile_part_number;
- for (tilepartno = 1; tilepartno < tot_num_tp ; ++tilepartno) {
- p_j2k->m_specific_param.m_encoder.m_current_poc_tile_part_number = tilepartno;
- l_current_nb_bytes_written = 0;
- l_part_tile_size = 0;
- l_begin_data = p_data;
-
- if (! opj_j2k_write_sot(p_j2k, p_data,
- total_data_size,
- &l_current_nb_bytes_written,
- p_stream,
- p_manager)) {
- return OPJ_FALSE;
- }
-
- l_nb_bytes_written += l_current_nb_bytes_written;
- p_data += l_current_nb_bytes_written;
- total_data_size -= l_current_nb_bytes_written;
- l_part_tile_size += l_current_nb_bytes_written;
-
- l_current_nb_bytes_written = 0;
- if (! opj_j2k_write_sod(p_j2k, l_tcd, p_data, &l_current_nb_bytes_written,
- total_data_size, p_stream, p_manager)) {
- return OPJ_FALSE;
- }
-
- p_data += l_current_nb_bytes_written;
- l_nb_bytes_written += l_current_nb_bytes_written;
- total_data_size -= l_current_nb_bytes_written;
- l_part_tile_size += l_current_nb_bytes_written;
-
- /* Writing Psot in SOT marker */
- opj_write_bytes(l_begin_data + 6, l_part_tile_size,
- 4); /* PSOT */
-
- if (p_j2k->m_specific_param.m_encoder.m_TLM) {
- opj_j2k_update_tlm(p_j2k, l_part_tile_size);
- }
-
- ++p_j2k->m_specific_param.m_encoder.m_current_tile_part_number;
- }
-
- for (pino = 1; pino <= l_tcp->numpocs; ++pino) {
- l_tcd->cur_pino = pino;
-
- /*Get number of tile parts*/
- tot_num_tp = opj_j2k_get_num_tp(l_cp, pino, p_j2k->m_current_tile_number);
- for (tilepartno = 0; tilepartno < tot_num_tp ; ++tilepartno) {
- p_j2k->m_specific_param.m_encoder.m_current_poc_tile_part_number = tilepartno;
- l_current_nb_bytes_written = 0;
- l_part_tile_size = 0;
- l_begin_data = p_data;
-
- if (! opj_j2k_write_sot(p_j2k, p_data,
- total_data_size,
- &l_current_nb_bytes_written, p_stream,
- p_manager)) {
- return OPJ_FALSE;
- }
-
- l_nb_bytes_written += l_current_nb_bytes_written;
- p_data += l_current_nb_bytes_written;
- total_data_size -= l_current_nb_bytes_written;
- l_part_tile_size += l_current_nb_bytes_written;
-
- l_current_nb_bytes_written = 0;
-
- if (! opj_j2k_write_sod(p_j2k, l_tcd, p_data, &l_current_nb_bytes_written,
- total_data_size, p_stream, p_manager)) {
- return OPJ_FALSE;
- }
-
- l_nb_bytes_written += l_current_nb_bytes_written;
- p_data += l_current_nb_bytes_written;
- total_data_size -= l_current_nb_bytes_written;
- l_part_tile_size += l_current_nb_bytes_written;
-
- /* Writing Psot in SOT marker */
- opj_write_bytes(l_begin_data + 6, l_part_tile_size,
- 4); /* PSOT */
-
- if (p_j2k->m_specific_param.m_encoder.m_TLM) {
- opj_j2k_update_tlm(p_j2k, l_part_tile_size);
- }
-
- ++p_j2k->m_specific_param.m_encoder.m_current_tile_part_number;
- }
- }
-
- *p_data_written = l_nb_bytes_written;
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_write_updated_tlm(opj_j2k_t *p_j2k,
- struct opj_stream_private *p_stream,
- struct opj_event_mgr * p_manager)
-{
- OPJ_UINT32 l_tlm_size;
- OPJ_OFF_T l_tlm_position, l_current_position;
- OPJ_UINT32 size_per_tile_part;
-
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_manager != 00);
- assert(p_stream != 00);
-
- size_per_tile_part = p_j2k->m_specific_param.m_encoder.m_Ttlmi_is_byte ? 5 : 6;
- l_tlm_size = size_per_tile_part *
- p_j2k->m_specific_param.m_encoder.m_total_tile_parts;
- l_tlm_position = 6 + p_j2k->m_specific_param.m_encoder.m_tlm_start;
- l_current_position = opj_stream_tell(p_stream);
-
- if (! opj_stream_seek(p_stream, l_tlm_position, p_manager)) {
- return OPJ_FALSE;
- }
-
- if (opj_stream_write_data(p_stream,
- p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer, l_tlm_size,
- p_manager) != l_tlm_size) {
- return OPJ_FALSE;
- }
-
- if (! opj_stream_seek(p_stream, l_current_position, p_manager)) {
- return OPJ_FALSE;
- }
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_end_encoding(opj_j2k_t *p_j2k,
- struct opj_stream_private *p_stream,
- struct opj_event_mgr * p_manager)
-{
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_manager != 00);
- assert(p_stream != 00);
-
- OPJ_UNUSED(p_stream);
- OPJ_UNUSED(p_manager);
-
- opj_tcd_destroy(p_j2k->m_tcd);
- p_j2k->m_tcd = 00;
-
- if (p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer) {
- opj_free(p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer);
- p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer = 0;
- p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_current = 0;
- }
-
- if (p_j2k->m_specific_param.m_encoder.m_encoded_tile_data) {
- opj_free(p_j2k->m_specific_param.m_encoder.m_encoded_tile_data);
- p_j2k->m_specific_param.m_encoder.m_encoded_tile_data = 0;
- }
-
- p_j2k->m_specific_param.m_encoder.m_encoded_tile_size = 0;
-
- return OPJ_TRUE;
-}
-
-/**
- * Destroys the memory associated with the decoding of headers.
- */
-static OPJ_BOOL opj_j2k_destroy_header_memory(opj_j2k_t * p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager
- )
-{
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_stream != 00);
- assert(p_manager != 00);
-
- OPJ_UNUSED(p_stream);
- OPJ_UNUSED(p_manager);
-
- if (p_j2k->m_specific_param.m_encoder.m_header_tile_data) {
- opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data);
- p_j2k->m_specific_param.m_encoder.m_header_tile_data = 0;
- }
-
- p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0;
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_j2k_init_info(opj_j2k_t *p_j2k,
- struct opj_stream_private *p_stream,
- struct opj_event_mgr * p_manager)
-{
- opj_codestream_info_t * l_cstr_info = 00;
-
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_manager != 00);
- assert(p_stream != 00);
- (void)l_cstr_info;
-
- OPJ_UNUSED(p_stream);
-
- /* TODO mergeV2: check this part which use cstr_info */
- /*l_cstr_info = p_j2k->cstr_info;
-
- if (l_cstr_info) {
- OPJ_UINT32 compno;
- l_cstr_info->tile = (opj_tile_info_t *) opj_malloc(p_j2k->m_cp.tw * p_j2k->m_cp.th * sizeof(opj_tile_info_t));
-
- l_cstr_info->image_w = p_j2k->m_image->x1 - p_j2k->m_image->x0;
- l_cstr_info->image_h = p_j2k->m_image->y1 - p_j2k->m_image->y0;
-
- l_cstr_info->prog = (&p_j2k->m_cp.tcps[0])->prg;
-
- l_cstr_info->tw = p_j2k->m_cp.tw;
- l_cstr_info->th = p_j2k->m_cp.th;
-
- l_cstr_info->tile_x = p_j2k->m_cp.tdx;*/ /* new version parser */
- /*l_cstr_info->tile_y = p_j2k->m_cp.tdy;*/ /* new version parser */
- /*l_cstr_info->tile_Ox = p_j2k->m_cp.tx0;*/ /* new version parser */
- /*l_cstr_info->tile_Oy = p_j2k->m_cp.ty0;*/ /* new version parser */
-
- /*l_cstr_info->numcomps = p_j2k->m_image->numcomps;
-
- l_cstr_info->numlayers = (&p_j2k->m_cp.tcps[0])->numlayers;
-
- l_cstr_info->numdecompos = (OPJ_INT32*) opj_malloc(p_j2k->m_image->numcomps * sizeof(OPJ_INT32));
-
- for (compno=0; compno < p_j2k->m_image->numcomps; compno++) {
- l_cstr_info->numdecompos[compno] = (&p_j2k->m_cp.tcps[0])->tccps->numresolutions - 1;
- }
-
- l_cstr_info->D_max = 0.0; */ /* ADD Marcela */
-
- /*l_cstr_info->main_head_start = opj_stream_tell(p_stream);*/ /* position of SOC */
-
- /*l_cstr_info->maxmarknum = 100;
- l_cstr_info->marker = (opj_marker_info_t *) opj_malloc(l_cstr_info->maxmarknum * sizeof(opj_marker_info_t));
- l_cstr_info->marknum = 0;
- }*/
-
- return opj_j2k_calculate_tp(p_j2k, &(p_j2k->m_cp),
- &p_j2k->m_specific_param.m_encoder.m_total_tile_parts, p_j2k->m_private_image,
- p_manager);
-}
-
-/**
- * Creates a tile-coder encoder.
- *
- * @param p_stream the stream to write data to.
- * @param p_j2k J2K codec.
- * @param p_manager the user event manager.
-*/
-static OPJ_BOOL opj_j2k_create_tcd(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager
- )
-{
- /* preconditions */
- assert(p_j2k != 00);
- assert(p_manager != 00);
- assert(p_stream != 00);
-
- OPJ_UNUSED(p_stream);
-
- p_j2k->m_tcd = opj_tcd_create(OPJ_FALSE);
-
- if (! p_j2k->m_tcd) {
- opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to create Tile Coder\n");
- return OPJ_FALSE;
- }
-
- if (!opj_tcd_init(p_j2k->m_tcd, p_j2k->m_private_image, &p_j2k->m_cp,
- p_j2k->m_tp)) {
- opj_tcd_destroy(p_j2k->m_tcd);
- p_j2k->m_tcd = 00;
- return OPJ_FALSE;
- }
-
- return OPJ_TRUE;
-}
-
-OPJ_BOOL opj_j2k_write_tile(opj_j2k_t * p_j2k,
- OPJ_UINT32 p_tile_index,
- OPJ_BYTE * p_data,
- OPJ_UINT32 p_data_size,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager)
-{
- if (! opj_j2k_pre_write_tile(p_j2k, p_tile_index, p_stream, p_manager)) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Error while opj_j2k_pre_write_tile with tile index = %d\n", p_tile_index);
- return OPJ_FALSE;
- } else {
- OPJ_UINT32 j;
- /* Allocate data */
- for (j = 0; j < p_j2k->m_tcd->image->numcomps; ++j) {
- opj_tcd_tilecomp_t* l_tilec = p_j2k->m_tcd->tcd_image->tiles->comps + j;
-
- if (! opj_alloc_tile_component_data(l_tilec)) {
- opj_event_msg(p_manager, EVT_ERROR, "Error allocating tile component data.");
- return OPJ_FALSE;
- }
- }
-
- /* now copy data into the tile component */
- if (! opj_tcd_copy_tile_data(p_j2k->m_tcd, p_data, p_data_size)) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Size mismatch between tile data and sent data.");
- return OPJ_FALSE;
- }
- if (! opj_j2k_post_write_tile(p_j2k, p_stream, p_manager)) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Error while opj_j2k_post_write_tile with tile index = %d\n", p_tile_index);
- return OPJ_FALSE;
- }
- }
-
- return OPJ_TRUE;
-}
diff --git a/contrib/libs/openjpeg/j2k.h b/contrib/libs/openjpeg/j2k.h
deleted file mode 100644
index bcf70a419c..0000000000
--- a/contrib/libs/openjpeg/j2k.h
+++ /dev/null
@@ -1,954 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2014, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux
- * Copyright (c) 2003-2014, Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2006-2007, Parvatha Elangovan
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@c-s.fr>
- * Copyright (c) 2011-2012, Centre National d'Etudes Spatiales (CNES), France
- * Copyright (c) 2012, CS Systemes d'Information, France
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef OPJ_J2K_H
-#define OPJ_J2K_H
-/**
-@file j2k.h
-@brief The JPEG-2000 Codestream Reader/Writer (J2K)
-
-The functions in J2K.C have for goal to read/write the several parts of the codestream: markers and data.
-*/
-
-/** @defgroup J2K J2K - JPEG-2000 codestream reader/writer */
-/*@{*/
-
-#define J2K_CP_CSTY_PRT 0x01
-#define J2K_CP_CSTY_SOP 0x02
-#define J2K_CP_CSTY_EPH 0x04
-#define J2K_CCP_CSTY_PRT 0x01
-#define J2K_CCP_CBLKSTY_LAZY 0x01 /**< Selective arithmetic coding bypass */
-#define J2K_CCP_CBLKSTY_RESET 0x02 /**< Reset context probabilities on coding pass boundaries */
-#define J2K_CCP_CBLKSTY_TERMALL 0x04 /**< Termination on each coding pass */
-#define J2K_CCP_CBLKSTY_VSC 0x08 /**< Vertically stripe causal context */
-#define J2K_CCP_CBLKSTY_PTERM 0x10 /**< Predictable termination */
-#define J2K_CCP_CBLKSTY_SEGSYM 0x20 /**< Segmentation symbols are used */
-#define J2K_CCP_CBLKSTY_HT 0x40 /**< (high throughput) HT codeblocks */
-#define J2K_CCP_CBLKSTY_HTMIXED 0x80 /**< MIXED mode HT codeblocks */
-#define J2K_CCP_QNTSTY_NOQNT 0
-#define J2K_CCP_QNTSTY_SIQNT 1
-#define J2K_CCP_QNTSTY_SEQNT 2
-
-/* ----------------------------------------------------------------------- */
-
-#define J2K_MS_SOC 0xff4f /**< SOC marker value */
-#define J2K_MS_SOT 0xff90 /**< SOT marker value */
-#define J2K_MS_SOD 0xff93 /**< SOD marker value */
-#define J2K_MS_EOC 0xffd9 /**< EOC marker value */
-#define J2K_MS_CAP 0xff50 /**< CAP marker value */
-#define J2K_MS_SIZ 0xff51 /**< SIZ marker value */
-#define J2K_MS_COD 0xff52 /**< COD marker value */
-#define J2K_MS_COC 0xff53 /**< COC marker value */
-#define J2K_MS_CPF 0xff59 /**< CPF marker value */
-#define J2K_MS_RGN 0xff5e /**< RGN marker value */
-#define J2K_MS_QCD 0xff5c /**< QCD marker value */
-#define J2K_MS_QCC 0xff5d /**< QCC marker value */
-#define J2K_MS_POC 0xff5f /**< POC marker value */
-#define J2K_MS_TLM 0xff55 /**< TLM marker value */
-#define J2K_MS_PLM 0xff57 /**< PLM marker value */
-#define J2K_MS_PLT 0xff58 /**< PLT marker value */
-#define J2K_MS_PPM 0xff60 /**< PPM marker value */
-#define J2K_MS_PPT 0xff61 /**< PPT marker value */
-#define J2K_MS_SOP 0xff91 /**< SOP marker value */
-#define J2K_MS_EPH 0xff92 /**< EPH marker value */
-#define J2K_MS_CRG 0xff63 /**< CRG marker value */
-#define J2K_MS_COM 0xff64 /**< COM marker value */
-#define J2K_MS_CBD 0xff78 /**< CBD marker value */
-#define J2K_MS_MCC 0xff75 /**< MCC marker value */
-#define J2K_MS_MCT 0xff74 /**< MCT marker value */
-#define J2K_MS_MCO 0xff77 /**< MCO marker value */
-
-#define J2K_MS_UNK 0 /**< UNKNOWN marker value */
-
-/* UniPG>> */
-#ifdef USE_JPWL
-#define J2K_MS_EPC 0xff68 /**< EPC marker value (Part 11: JPEG 2000 for Wireless) */
-#define J2K_MS_EPB 0xff66 /**< EPB marker value (Part 11: JPEG 2000 for Wireless) */
-#define J2K_MS_ESD 0xff67 /**< ESD marker value (Part 11: JPEG 2000 for Wireless) */
-#define J2K_MS_RED 0xff69 /**< RED marker value (Part 11: JPEG 2000 for Wireless) */
-#endif /* USE_JPWL */
-#ifdef USE_JPSEC
-#define J2K_MS_SEC 0xff65 /**< SEC marker value (Part 8: Secure JPEG 2000) */
-#define J2K_MS_INSEC 0xff94 /**< INSEC marker value (Part 8: Secure JPEG 2000) */
-#endif /* USE_JPSEC */
-/* <<UniPG */
-
-#define J2K_MAX_POCS 32 /**< Maximum number of POCs */
-
-#define J2K_TCD_MATRIX_MAX_LAYER_COUNT 10
-#define J2K_TCD_MATRIX_MAX_RESOLUTION_COUNT 10
-
-/* ----------------------------------------------------------------------- */
-
-/**
- * Values that specify the status of the decoding process when decoding the main header.
- * These values may be combined with a | operator.
- * */
-typedef enum J2K_STATUS {
- J2K_STATE_NONE = 0x0000, /**< a SOC marker is expected */
- J2K_STATE_MHSOC = 0x0001, /**< a SOC marker is expected */
- J2K_STATE_MHSIZ = 0x0002, /**< a SIZ marker is expected */
- J2K_STATE_MH = 0x0004, /**< the decoding process is in the main header */
- J2K_STATE_TPHSOT = 0x0008, /**< the decoding process is in a tile part header and expects a SOT marker */
- J2K_STATE_TPH = 0x0010, /**< the decoding process is in a tile part header */
- J2K_STATE_MT = 0x0020, /**< the EOC marker has just been read */
- J2K_STATE_NEOC = 0x0040, /**< the decoding process must not expect a EOC marker because the codestream is truncated */
- J2K_STATE_DATA = 0x0080, /**< a tile header has been successfully read and codestream is expected */
-
- J2K_STATE_EOC = 0x0100, /**< the decoding process has encountered the EOC marker */
- J2K_STATE_ERR = 0x8000 /**< the decoding process has encountered an error (FIXME warning V1 = 0x0080)*/
-} J2K_STATUS;
-
-/**
- * Type of elements storing in the MCT data
- */
-typedef enum MCT_ELEMENT_TYPE {
- MCT_TYPE_INT16 = 0, /** MCT data is stored as signed shorts*/
- MCT_TYPE_INT32 = 1, /** MCT data is stored as signed integers*/
- MCT_TYPE_FLOAT = 2, /** MCT data is stored as floats*/
- MCT_TYPE_DOUBLE = 3 /** MCT data is stored as doubles*/
-} J2K_MCT_ELEMENT_TYPE;
-
-/**
- * Type of MCT array
- */
-typedef enum MCT_ARRAY_TYPE {
- MCT_TYPE_DEPENDENCY = 0,
- MCT_TYPE_DECORRELATION = 1,
- MCT_TYPE_OFFSET = 2
-} J2K_MCT_ARRAY_TYPE;
-
-/* ----------------------------------------------------------------------- */
-
-/**
-T2 encoding mode
-*/
-typedef enum T2_MODE {
- THRESH_CALC = 0, /** Function called in Rate allocation process*/
- FINAL_PASS = 1 /** Function called in Tier 2 process*/
-} J2K_T2_MODE;
-
-/**
- * Quantization stepsize
- */
-typedef struct opj_stepsize {
- /** exponent */
- OPJ_INT32 expn;
- /** mantissa */
- OPJ_INT32 mant;
-} opj_stepsize_t;
-
-/**
-Tile-component coding parameters
-*/
-typedef struct opj_tccp {
- /** coding style */
- OPJ_UINT32 csty;
- /** number of resolutions */
- OPJ_UINT32 numresolutions;
- /** code-blocks width */
- OPJ_UINT32 cblkw;
- /** code-blocks height */
- OPJ_UINT32 cblkh;
- /** code-block coding style */
- OPJ_UINT32 cblksty;
- /** discrete wavelet transform identifier */
- OPJ_UINT32 qmfbid;
- /** quantisation style */
- OPJ_UINT32 qntsty;
- /** stepsizes used for quantization */
- opj_stepsize_t stepsizes[OPJ_J2K_MAXBANDS];
- /** number of guard bits */
- OPJ_UINT32 numgbits;
- /** Region Of Interest shift */
- OPJ_INT32 roishift;
- /** precinct width */
- OPJ_UINT32 prcw[OPJ_J2K_MAXRLVLS];
- /** precinct height */
- OPJ_UINT32 prch[OPJ_J2K_MAXRLVLS];
- /** the dc_level_shift **/
- OPJ_INT32 m_dc_level_shift;
-}
-opj_tccp_t;
-
-
-
-/**
- * FIXME DOC
- */
-typedef struct opj_mct_data {
- J2K_MCT_ELEMENT_TYPE m_element_type;
- J2K_MCT_ARRAY_TYPE m_array_type;
- OPJ_UINT32 m_index;
- OPJ_BYTE * m_data;
- OPJ_UINT32 m_data_size;
-}
-opj_mct_data_t;
-
-/**
- * FIXME DOC
- */
-typedef struct opj_simple_mcc_decorrelation_data {
- OPJ_UINT32 m_index;
- OPJ_UINT32 m_nb_comps;
- opj_mct_data_t * m_decorrelation_array;
- opj_mct_data_t * m_offset_array;
- OPJ_BITFIELD m_is_irreversible : 1;
-}
-opj_simple_mcc_decorrelation_data_t;
-
-typedef struct opj_ppx_struct {
- OPJ_BYTE* m_data; /* m_data == NULL => Zppx not read yet */
- OPJ_UINT32 m_data_size;
-} opj_ppx;
-
-/**
-Tile coding parameters :
-this structure is used to store coding/decoding parameters common to all
-tiles (information like COD, COC in main header)
-*/
-typedef struct opj_tcp {
- /** coding style */
- OPJ_UINT32 csty;
- /** progression order */
- OPJ_PROG_ORDER prg;
- /** number of layers */
- OPJ_UINT32 numlayers;
- OPJ_UINT32 num_layers_to_decode;
- /** multi-component transform identifier */
- OPJ_UINT32 mct;
- /** rates of layers */
- OPJ_FLOAT32 rates[100];
- /** number of progression order changes */
- OPJ_UINT32 numpocs;
- /** progression order changes */
- opj_poc_t pocs[J2K_MAX_POCS];
-
- /** number of ppt markers (reserved size) */
- OPJ_UINT32 ppt_markers_count;
- /** ppt markers data (table indexed by Zppt) */
- opj_ppx* ppt_markers;
-
- /** packet header store there for future use in t2_decode_packet */
- OPJ_BYTE *ppt_data;
- /** used to keep a track of the allocated memory */
- OPJ_BYTE *ppt_buffer;
- /** Number of bytes stored inside ppt_data*/
- OPJ_UINT32 ppt_data_size;
- /** size of ppt_data*/
- OPJ_UINT32 ppt_len;
- /** PSNR values */
- OPJ_FLOAT32 distoratio[100];
- /** tile-component coding parameters */
- opj_tccp_t *tccps;
- /** current tile part number or -1 if first time into this tile */
- OPJ_INT32 m_current_tile_part_number;
- /** number of tile parts for the tile. */
- OPJ_UINT32 m_nb_tile_parts;
- /** data for the tile */
- OPJ_BYTE * m_data;
- /** size of data */
- OPJ_UINT32 m_data_size;
- /** encoding norms */
- OPJ_FLOAT64 * mct_norms;
- /** the mct decoding matrix */
- OPJ_FLOAT32 * m_mct_decoding_matrix;
- /** the mct coding matrix */
- OPJ_FLOAT32 * m_mct_coding_matrix;
- /** mct records */
- opj_mct_data_t * m_mct_records;
- /** the number of mct records. */
- OPJ_UINT32 m_nb_mct_records;
- /** the max number of mct records. */
- OPJ_UINT32 m_nb_max_mct_records;
- /** mcc records */
- opj_simple_mcc_decorrelation_data_t * m_mcc_records;
- /** the number of mct records. */
- OPJ_UINT32 m_nb_mcc_records;
- /** the max number of mct records. */
- OPJ_UINT32 m_nb_max_mcc_records;
-
-
- /***** FLAGS *******/
- /** If cod == 1 --> there was a COD marker for the present tile */
- OPJ_BITFIELD cod : 1;
- /** If ppt == 1 --> there was a PPT marker for the present tile */
- OPJ_BITFIELD ppt : 1;
- /** indicates if a POC marker has been used O:NO, 1:YES */
- OPJ_BITFIELD POC : 1;
-} opj_tcp_t;
-
-
-/**
-Rate allocation strategy
-*/
-typedef enum {
- RATE_DISTORTION_RATIO = 0, /** allocation by rate/distortion */
- FIXED_DISTORTION_RATIO = 1, /** allocation by fixed distortion ratio (PSNR) (fixed quality) */
- FIXED_LAYER = 2, /** allocation by fixed layer (number of passes per layer / resolution / subband) */
-} J2K_QUALITY_LAYER_ALLOCATION_STRATEGY;
-
-
-typedef struct opj_encoding_param {
- /** Maximum rate for each component. If == 0, component size limitation is not considered */
- OPJ_UINT32 m_max_comp_size;
- /** Position of tile part flag in progression order*/
- OPJ_INT32 m_tp_pos;
- /** fixed layer */
- OPJ_INT32 *m_matrice;
- /** Flag determining tile part generation*/
- OPJ_BYTE m_tp_flag;
- /** Quality layer allocation strategy */
- J2K_QUALITY_LAYER_ALLOCATION_STRATEGY m_quality_layer_alloc_strategy;
- /** Enabling Tile part generation*/
- OPJ_BITFIELD m_tp_on : 1;
-}
-opj_encoding_param_t;
-
-typedef struct opj_decoding_param {
- /** if != 0, then original dimension divided by 2^(reduce); if == 0 or not used, image is decoded to the full resolution */
- OPJ_UINT32 m_reduce;
- /** if != 0, then only the first "layer" layers are decoded; if == 0 or not used, all the quality layers are decoded */
- OPJ_UINT32 m_layer;
-}
-opj_decoding_param_t;
-
-
-/**
- * Coding parameters
- */
-typedef struct opj_cp {
- /** Size of the image in bits*/
- /*int img_size;*/
- /** Rsiz*/
- OPJ_UINT16 rsiz;
- /** XTOsiz */
- OPJ_UINT32 tx0; /* MSD see norm */
- /** YTOsiz */
- OPJ_UINT32 ty0; /* MSD see norm */
- /** XTsiz */
- OPJ_UINT32 tdx;
- /** YTsiz */
- OPJ_UINT32 tdy;
- /** comment */
- OPJ_CHAR *comment;
- /** number of tiles in width */
- OPJ_UINT32 tw;
- /** number of tiles in height */
- OPJ_UINT32 th;
-
- /** number of ppm markers (reserved size) */
- OPJ_UINT32 ppm_markers_count;
- /** ppm markers data (table indexed by Zppm) */
- opj_ppx* ppm_markers;
-
- /** packet header store there for future use in t2_decode_packet */
- OPJ_BYTE *ppm_data;
- /** size of the ppm_data*/
- OPJ_UINT32 ppm_len;
- /** size of the ppm_data*/
- OPJ_UINT32 ppm_data_read;
-
- OPJ_BYTE *ppm_data_current;
-
- /** packet header storage original buffer */
- OPJ_BYTE *ppm_buffer;
- /** pointer remaining on the first byte of the first header if ppm is used */
- OPJ_BYTE *ppm_data_first;
- /** Number of bytes actually stored inside the ppm_data */
- OPJ_UINT32 ppm_data_size;
- /** use in case of multiple marker PPM (number of info already store) */
- OPJ_INT32 ppm_store;
- /** use in case of multiple marker PPM (case on non-finished previous info) */
- OPJ_INT32 ppm_previous;
-
- /** tile coding parameters */
- opj_tcp_t *tcps;
-
- union {
- opj_decoding_param_t m_dec;
- opj_encoding_param_t m_enc;
- }
- m_specific_param;
-
- /** OPJ_TRUE if entire bit stream must be decoded, OPJ_FALSE if partial bitstream decoding allowed */
- OPJ_BOOL strict;
-
- /* UniPG>> */
-#ifdef USE_JPWL
- /** enables writing of EPC in MH, thus activating JPWL */
- OPJ_BOOL epc_on;
- /** enables writing of EPB, in case of activated JPWL */
- OPJ_BOOL epb_on;
- /** enables writing of ESD, in case of activated JPWL */
- OPJ_BOOL esd_on;
- /** enables writing of informative techniques of ESD, in case of activated JPWL */
- OPJ_BOOL info_on;
- /** enables writing of RED, in case of activated JPWL */
- OPJ_BOOL red_on;
- /** error protection method for MH (0,1,16,32,37-128) */
- int hprot_MH;
- /** tile number of header protection specification (>=0) */
- int hprot_TPH_tileno[JPWL_MAX_NO_TILESPECS];
- /** error protection methods for TPHs (0,1,16,32,37-128) */
- int hprot_TPH[JPWL_MAX_NO_TILESPECS];
- /** tile number of packet protection specification (>=0) */
- int pprot_tileno[JPWL_MAX_NO_PACKSPECS];
- /** packet number of packet protection specification (>=0) */
- int pprot_packno[JPWL_MAX_NO_PACKSPECS];
- /** error protection methods for packets (0,1,16,32,37-128) */
- int pprot[JPWL_MAX_NO_PACKSPECS];
- /** enables writing of ESD, (0/2/4 bytes) */
- int sens_size;
- /** sensitivity addressing size (0=auto/2/4 bytes) */
- int sens_addr;
- /** sensitivity range (0-3) */
- int sens_range;
- /** sensitivity method for MH (-1,0-7) */
- int sens_MH;
- /** tile number of sensitivity specification (>=0) */
- int sens_TPH_tileno[JPWL_MAX_NO_TILESPECS];
- /** sensitivity methods for TPHs (-1,0-7) */
- int sens_TPH[JPWL_MAX_NO_TILESPECS];
- /** enables JPWL correction at the decoder */
- OPJ_BOOL correct;
- /** expected number of components at the decoder */
- int exp_comps;
- /** maximum number of tiles at the decoder */
- OPJ_UINT32 max_tiles;
-#endif /* USE_JPWL */
-
- /******** FLAGS *********/
- /** if ppm == 1 --> there was a PPM marker*/
- OPJ_BITFIELD ppm : 1;
- /** tells if the parameter is a coding or decoding one */
- OPJ_BITFIELD m_is_decoder : 1;
- /** whether different bit depth or sign per component is allowed. Decoder only for ow */
- OPJ_BITFIELD allow_different_bit_depth_sign : 1;
- /* <<UniPG */
-} opj_cp_t;
-
-/** Entry of a TLM marker segment */
-typedef struct opj_j2k_tlm_tile_part_info {
- /** Tile index of the tile part. Ttlmi field */
- OPJ_UINT16 m_tile_index;
- /** Length in bytes, from the beginning of the SOT marker to the end of
- * the bit stream data for that tile-part. Ptlmi field */
- OPJ_UINT32 m_length;
-} opj_j2k_tlm_tile_part_info_t;
-
-/** Information got from the concatenation of TLM marker semgnets. */
-typedef struct opj_j2k_tlm_info {
- /** Number of entries in m_tile_part_infos. */
- OPJ_UINT32 m_entries_count;
- /** Array of m_entries_count values. */
- opj_j2k_tlm_tile_part_info_t* m_tile_part_infos;
-
- OPJ_BOOL m_is_invalid;
-} opj_j2k_tlm_info_t;
-
-typedef struct opj_j2k_dec {
- /** locate in which part of the codestream the decoder is (main header, tile header, end) */
- OPJ_UINT32 m_state;
- /**
- * store decoding parameters common to all tiles (information like COD, COC in main header)
- */
- opj_tcp_t *m_default_tcp;
- OPJ_BYTE *m_header_data;
- OPJ_UINT32 m_header_data_size;
- /** to tell the tile part length */
- OPJ_UINT32 m_sot_length;
- /** Only tiles index in the correct range will be decoded.*/
- OPJ_UINT32 m_start_tile_x;
- OPJ_UINT32 m_start_tile_y;
- OPJ_UINT32 m_end_tile_x;
- OPJ_UINT32 m_end_tile_y;
-
- /** Index of the tile to decode (used in get_tile) */
- OPJ_INT32 m_tile_ind_to_dec;
- /** Position of the last SOT marker read */
- OPJ_OFF_T m_last_sot_read_pos;
-
- /**
- * Indicate that the current tile-part is assume as the last tile part of the codestream.
- * It is useful in the case of PSot is equal to zero. The sot length will be compute in the
- * SOD reader function. FIXME NOT USED for the moment
- */
- OPJ_BOOL m_last_tile_part;
-
- OPJ_UINT32 m_numcomps_to_decode;
- OPJ_UINT32 *m_comps_indices_to_decode;
-
- opj_j2k_tlm_info_t m_tlm;
-
- /** Below if used when there's TLM information available and we use
- * opj_set_decoded_area() to a subset of all tiles.
- */
- /* Current index in m_intersecting_tile_parts_offset[] to seek to */
- OPJ_UINT32 m_idx_intersecting_tile_parts;
- /* Number of elements of m_intersecting_tile_parts_offset[] */
- OPJ_UINT32 m_num_intersecting_tile_parts;
- /* Start offset of contributing tile parts */
- OPJ_OFF_T* m_intersecting_tile_parts_offset;
-
- /** to tell that a tile can be decoded. */
- OPJ_BITFIELD m_can_decode : 1;
- OPJ_BITFIELD m_discard_tiles : 1;
- OPJ_BITFIELD m_skip_data : 1;
- /** TNsot correction : see issue 254 **/
- OPJ_BITFIELD m_nb_tile_parts_correction_checked : 1;
- OPJ_BITFIELD m_nb_tile_parts_correction : 1;
-
-} opj_j2k_dec_t;
-
-typedef struct opj_j2k_enc {
- /** Tile part number, regardless of poc, for each new poc, tp is reset to 1*/
- OPJ_UINT32 m_current_poc_tile_part_number; /* tp_num */
-
- /** Tile part number currently coding, taking into account POC. m_current_tile_part_number holds the total number of tile parts while encoding the last tile part.*/
- OPJ_UINT32 m_current_tile_part_number; /*cur_tp_num */
-
- /* whether to generate TLM markers */
- OPJ_BOOL m_TLM;
-
- /* whether the Ttlmi field in a TLM marker is a byte (otherwise a uint16) */
- OPJ_BOOL m_Ttlmi_is_byte;
-
- /**
- locate the start position of the TLM marker
- after encoding the tilepart, a jump (in j2k_write_sod) is done to the TLM marker to store the value of its length.
- */
- OPJ_OFF_T m_tlm_start;
- /**
- * Stores the sizes of the tlm.
- */
- OPJ_BYTE * m_tlm_sot_offsets_buffer;
- /**
- * The current offset of the tlm buffer.
- */
- OPJ_BYTE * m_tlm_sot_offsets_current;
-
- /** Total num of tile parts in whole image = num tiles* num tileparts in each tile*/
- /** used in TLMmarker*/
- OPJ_UINT32 m_total_tile_parts; /* totnum_tp */
-
- /* encoded data for a tile */
- OPJ_BYTE * m_encoded_tile_data;
-
- /* size of the encoded_data */
- OPJ_UINT32 m_encoded_tile_size;
-
- /* encoded data for a tile */
- OPJ_BYTE * m_header_tile_data;
-
- /* size of the encoded_data */
-
- OPJ_UINT32 m_header_tile_data_size;
-
- /* whether to generate PLT markers */
- OPJ_BOOL m_PLT;
-
- /* reserved bytes in m_encoded_tile_size for PLT markers */
- OPJ_UINT32 m_reserved_bytes_for_PLT;
-
- /** Number of components */
- OPJ_UINT32 m_nb_comps;
-
-} opj_j2k_enc_t;
-
-
-
-struct opj_tcd;
-/**
-JPEG-2000 codestream reader/writer
-*/
-typedef struct opj_j2k {
- /* J2K codestream is decoded*/
- OPJ_BOOL m_is_decoder;
-
- /* FIXME DOC*/
- union {
- opj_j2k_dec_t m_decoder;
- opj_j2k_enc_t m_encoder;
- }
- m_specific_param;
-
- /** pointer to the internal/private encoded / decoded image */
- opj_image_t* m_private_image;
-
- /* pointer to the output image (decoded)*/
- opj_image_t* m_output_image;
-
- /** Coding parameters */
- opj_cp_t m_cp;
-
- /** the list of procedures to exec **/
- opj_procedure_list_t * m_procedure_list;
-
- /** the list of validation procedures to follow to make sure the code is valid **/
- opj_procedure_list_t * m_validation_list;
-
- /** helper used to write the index file */
- opj_codestream_index_t *cstr_index;
-
- /** number of the tile currently concern by coding/decoding */
- OPJ_UINT32 m_current_tile_number;
-
- /** the current tile coder/decoder **/
- struct opj_tcd * m_tcd;
-
- /** Thread pool */
- opj_thread_pool_t* m_tp;
-
- /** Image width coming from JP2 IHDR box. 0 from a pure codestream */
- OPJ_UINT32 ihdr_w;
-
- /** Image height coming from JP2 IHDR box. 0 from a pure codestream */
- OPJ_UINT32 ihdr_h;
-
- /** Set to 1 by the decoder initialization if OPJ_DPARAMETERS_DUMP_FLAG is set */
- unsigned int dump_state;
-}
-opj_j2k_t;
-
-
-
-
-/** @name Exported functions */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-
-/**
-Setup the decoder decoding parameters using user parameters.
-Decoding parameters are returned in j2k->cp.
-@param j2k J2K decompressor handle
-@param parameters decompression parameters
-*/
-void opj_j2k_setup_decoder(opj_j2k_t *j2k, opj_dparameters_t *parameters);
-
-void opj_j2k_decoder_set_strict_mode(opj_j2k_t *j2k, OPJ_BOOL strict);
-
-OPJ_BOOL opj_j2k_set_threads(opj_j2k_t *j2k, OPJ_UINT32 num_threads);
-
-/**
- * Creates a J2K compression structure
- *
- * @return Returns a handle to a J2K compressor if successful, returns NULL otherwise
-*/
-opj_j2k_t* opj_j2k_create_compress(void);
-
-
-OPJ_BOOL opj_j2k_setup_encoder(opj_j2k_t *p_j2k,
- opj_cparameters_t *parameters,
- opj_image_t *image,
- opj_event_mgr_t * p_manager);
-
-/**
-Converts an enum type progression order to string type
-*/
-const char *opj_j2k_convert_progression_order(OPJ_PROG_ORDER prg_order);
-
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-/**
- * Ends the decompression procedures and possibiliy add data to be read after the
- * codestream.
- */
-OPJ_BOOL opj_j2k_end_decompress(opj_j2k_t *j2k,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * Reads a jpeg2000 codestream header structure.
- *
- * @param p_stream the stream to read data from.
- * @param p_j2k the jpeg2000 codec.
- * @param p_image FIXME DOC
- * @param p_manager the user event manager.
- *
- * @return true if the box is valid.
- */
-OPJ_BOOL opj_j2k_read_header(opj_stream_private_t *p_stream,
- opj_j2k_t* p_j2k,
- opj_image_t** p_image,
- opj_event_mgr_t* p_manager);
-
-
-/**
- * Destroys a jpeg2000 codec.
- *
- * @param p_j2k the jpeg20000 structure to destroy.
- */
-void opj_j2k_destroy(opj_j2k_t *p_j2k);
-
-/**
- * Destroys a codestream index structure.
- *
- * @param p_cstr_ind the codestream index parameter to destroy.
- */
-void j2k_destroy_cstr_index(opj_codestream_index_t *p_cstr_ind);
-
-/**
- * Decode tile data.
- * @param p_j2k the jpeg2000 codec.
- * @param p_tile_index
- * @param p_data FIXME DOC
- * @param p_data_size FIXME DOC
- * @param p_stream the stream to write data to.
- * @param p_manager the user event manager.
- */
-OPJ_BOOL opj_j2k_decode_tile(opj_j2k_t * p_j2k,
- OPJ_UINT32 p_tile_index,
- OPJ_BYTE * p_data,
- OPJ_UINT32 p_data_size,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * Reads a tile header.
- * @param p_j2k the jpeg2000 codec.
- * @param p_tile_index FIXME DOC
- * @param p_data_size FIXME DOC
- * @param p_tile_x0 FIXME DOC
- * @param p_tile_y0 FIXME DOC
- * @param p_tile_x1 FIXME DOC
- * @param p_tile_y1 FIXME DOC
- * @param p_nb_comps FIXME DOC
- * @param p_go_on FIXME DOC
- * @param p_stream the stream to write data to.
- * @param p_manager the user event manager.
- */
-OPJ_BOOL opj_j2k_read_tile_header(opj_j2k_t * p_j2k,
- OPJ_UINT32 * p_tile_index,
- OPJ_UINT32 * p_data_size,
- OPJ_INT32 * p_tile_x0,
- OPJ_INT32 * p_tile_y0,
- OPJ_INT32 * p_tile_x1,
- OPJ_INT32 * p_tile_y1,
- OPJ_UINT32 * p_nb_comps,
- OPJ_BOOL * p_go_on,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-
-/** Sets the indices of the components to decode.
- *
- * @param p_j2k the jpeg2000 codec.
- * @param numcomps Number of components to decode.
- * @param comps_indices Array of num_compts indices (numbering starting at 0)
- * corresponding to the components to decode.
- * @param p_manager Event manager
- *
- * @return OPJ_TRUE in case of success.
- */
-OPJ_BOOL opj_j2k_set_decoded_components(opj_j2k_t *p_j2k,
- OPJ_UINT32 numcomps,
- const OPJ_UINT32* comps_indices,
- opj_event_mgr_t * p_manager);
-
-/**
- * Sets the given area to be decoded. This function should be called right after opj_read_header and before any tile header reading.
- *
- * @param p_j2k the jpeg2000 codec.
- * @param p_image FIXME DOC
- * @param p_start_x the left position of the rectangle to decode (in image coordinates).
- * @param p_start_y the up position of the rectangle to decode (in image coordinates).
- * @param p_end_x the right position of the rectangle to decode (in image coordinates).
- * @param p_end_y the bottom position of the rectangle to decode (in image coordinates).
- * @param p_manager the user event manager
- *
- * @return true if the area could be set.
- */
-OPJ_BOOL opj_j2k_set_decode_area(opj_j2k_t *p_j2k,
- opj_image_t* p_image,
- OPJ_INT32 p_start_x, OPJ_INT32 p_start_y,
- OPJ_INT32 p_end_x, OPJ_INT32 p_end_y,
- opj_event_mgr_t * p_manager);
-
-/**
- * Creates a J2K decompression structure.
- *
- * @return a handle to a J2K decompressor if successful, NULL otherwise.
- */
-opj_j2k_t* opj_j2k_create_decompress(void);
-
-
-/**
- * Dump some elements from the J2K decompression structure .
- *
- *@param p_j2k the jpeg2000 codec.
- *@param flag flag to describe what elements are dump.
- *@param out_stream output stream where dump the elements.
- *
-*/
-void j2k_dump(opj_j2k_t* p_j2k, OPJ_INT32 flag, FILE* out_stream);
-
-
-
-/**
- * Dump an image header structure.
- *
- *@param image the image header to dump.
- *@param dev_dump_flag flag to describe if we are in the case of this function is use outside j2k_dump function
- *@param out_stream output stream where dump the elements.
- */
-void j2k_dump_image_header(opj_image_t* image, OPJ_BOOL dev_dump_flag,
- FILE* out_stream);
-
-/**
- * Dump a component image header structure.
- *
- *@param comp the component image header to dump.
- *@param dev_dump_flag flag to describe if we are in the case of this function is use outside j2k_dump function
- *@param out_stream output stream where dump the elements.
- */
-void j2k_dump_image_comp_header(opj_image_comp_t* comp, OPJ_BOOL dev_dump_flag,
- FILE* out_stream);
-
-/**
- * Get the codestream info from a JPEG2000 codec.
- *
- *@param p_j2k the component image header to dump.
- *
- *@return the codestream information extract from the jpg2000 codec
- */
-opj_codestream_info_v2_t* j2k_get_cstr_info(opj_j2k_t* p_j2k);
-
-/**
- * Get the codestream index from a JPEG2000 codec.
- *
- *@param p_j2k the component image header to dump.
- *
- *@return the codestream index extract from the jpg2000 codec
- */
-opj_codestream_index_t* j2k_get_cstr_index(opj_j2k_t* p_j2k);
-
-/**
- * Decode an image from a JPEG-2000 codestream
- * @param j2k J2K decompressor handle
- * @param p_stream FIXME DOC
- * @param p_image FIXME DOC
- * @param p_manager FIXME DOC
- * @return FIXME DOC
-*/
-OPJ_BOOL opj_j2k_decode(opj_j2k_t *j2k,
- opj_stream_private_t *p_stream,
- opj_image_t *p_image,
- opj_event_mgr_t *p_manager);
-
-
-OPJ_BOOL opj_j2k_get_tile(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_image_t* p_image,
- opj_event_mgr_t * p_manager,
- OPJ_UINT32 tile_index);
-
-OPJ_BOOL opj_j2k_set_decoded_resolution_factor(opj_j2k_t *p_j2k,
- OPJ_UINT32 res_factor,
- opj_event_mgr_t * p_manager);
-
-/**
- * Specify extra options for the encoder.
- *
- * @param p_j2k the jpeg2000 codec.
- * @param p_options options
- * @param p_manager the user event manager
- *
- * @see opj_encoder_set_extra_options() for more details.
- */
-OPJ_BOOL opj_j2k_encoder_set_extra_options(
- opj_j2k_t *p_j2k,
- const char* const* p_options,
- opj_event_mgr_t * p_manager);
-
-/**
- * Writes a tile.
- * @param p_j2k the jpeg2000 codec.
- * @param p_tile_index FIXME DOC
- * @param p_data FIXME DOC
- * @param p_data_size FIXME DOC
- * @param p_stream the stream to write data to.
- * @param p_manager the user event manager.
- */
-OPJ_BOOL opj_j2k_write_tile(opj_j2k_t * p_j2k,
- OPJ_UINT32 p_tile_index,
- OPJ_BYTE * p_data,
- OPJ_UINT32 p_data_size,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * Encodes an image into a JPEG-2000 codestream
- */
-OPJ_BOOL opj_j2k_encode(opj_j2k_t * p_j2k,
- opj_stream_private_t *cio,
- opj_event_mgr_t * p_manager);
-
-/**
- * Starts a compression scheme, i.e. validates the codec parameters, writes the header.
- *
- * @param p_j2k the jpeg2000 codec.
- * @param p_stream the stream object.
- * @param p_image FIXME DOC
- * @param p_manager the user event manager.
- *
- * @return true if the codec is valid.
- */
-OPJ_BOOL opj_j2k_start_compress(opj_j2k_t *p_j2k,
- opj_stream_private_t *p_stream,
- opj_image_t * p_image,
- opj_event_mgr_t * p_manager);
-
-/**
- * Ends the compression procedures and possibiliy add data to be read after the
- * codestream.
- */
-OPJ_BOOL opj_j2k_end_compress(opj_j2k_t *p_j2k,
- opj_stream_private_t *cio,
- opj_event_mgr_t * p_manager);
-
-OPJ_BOOL opj_j2k_setup_mct_encoding(opj_tcp_t * p_tcp, opj_image_t * p_image);
-
-
-#endif /* OPJ_J2K_H */
diff --git a/contrib/libs/openjpeg/jp2.c b/contrib/libs/openjpeg/jp2.c
deleted file mode 100644
index 4df055a542..0000000000
--- a/contrib/libs/openjpeg/jp2.c
+++ /dev/null
@@ -1,3418 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2014, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux
- * Copyright (c) 2003-2014, Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2010-2011, Kaori Hagihara
- * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR
- * Copyright (c) 2012, CS Systemes d'Information, France
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#include "opj_includes.h"
-
-/** @defgroup JP2 JP2 - JPEG-2000 file format reader/writer */
-/*@{*/
-
-#define OPJ_BOX_SIZE 1024
-
-#define OPJ_UNUSED(x) (void)x
-
-/** @name Local static functions */
-/*@{*/
-
-/*static void jp2_write_url(opj_cio_t *cio, char *Idx_file);*/
-
-/**
- * Reads a IHDR box - Image Header box
- *
- * @param p_image_header_data pointer to actual data (already read from file)
- * @param jp2 the jpeg2000 file codec.
- * @param p_image_header_size the size of the image header
- * @param p_manager the user event manager.
- *
- * @return true if the image header is valid, false else.
- */
-static OPJ_BOOL opj_jp2_read_ihdr(opj_jp2_t *jp2,
- OPJ_BYTE *p_image_header_data,
- OPJ_UINT32 p_image_header_size,
- opj_event_mgr_t * p_manager);
-
-/**
- * Writes the Image Header box - Image Header box.
- *
- * @param jp2 jpeg2000 file codec.
- * @param p_nb_bytes_written pointer to store the nb of bytes written by the function.
- *
- * @return the data being copied.
-*/
-static OPJ_BYTE * opj_jp2_write_ihdr(opj_jp2_t *jp2,
- OPJ_UINT32 * p_nb_bytes_written);
-
-/**
- * Writes the Bit per Component box.
- *
- * @param jp2 jpeg2000 file codec.
- * @param p_nb_bytes_written pointer to store the nb of bytes written by the function.
- *
- * @return the data being copied.
-*/
-static OPJ_BYTE * opj_jp2_write_bpcc(opj_jp2_t *jp2,
- OPJ_UINT32 * p_nb_bytes_written);
-
-/**
- * Reads a Bit per Component box.
- *
- * @param p_bpc_header_data pointer to actual data (already read from file)
- * @param jp2 the jpeg2000 file codec.
- * @param p_bpc_header_size the size of the bpc header
- * @param p_manager the user event manager.
- *
- * @return true if the bpc header is valid, false else.
- */
-static OPJ_BOOL opj_jp2_read_bpcc(opj_jp2_t *jp2,
- OPJ_BYTE * p_bpc_header_data,
- OPJ_UINT32 p_bpc_header_size,
- opj_event_mgr_t * p_manager);
-
-static OPJ_BOOL opj_jp2_read_cdef(opj_jp2_t * jp2,
- OPJ_BYTE * p_cdef_header_data,
- OPJ_UINT32 p_cdef_header_size,
- opj_event_mgr_t * p_manager);
-
-static void opj_jp2_apply_cdef(opj_image_t *image, opj_jp2_color_t *color,
- opj_event_mgr_t *);
-
-/**
- * Writes the Channel Definition box.
- *
- * @param jp2 jpeg2000 file codec.
- * @param p_nb_bytes_written pointer to store the nb of bytes written by the function.
- *
- * @return the data being copied.
- */
-static OPJ_BYTE * opj_jp2_write_cdef(opj_jp2_t *jp2,
- OPJ_UINT32 * p_nb_bytes_written);
-
-/**
- * Writes the Colour Specification box.
- *
- * @param jp2 jpeg2000 file codec.
- * @param p_nb_bytes_written pointer to store the nb of bytes written by the function.
- *
- * @return the data being copied.
-*/
-static OPJ_BYTE * opj_jp2_write_colr(opj_jp2_t *jp2,
- OPJ_UINT32 * p_nb_bytes_written);
-
-/**
- * Writes a FTYP box - File type box
- *
- * @param cio the stream to write data to.
- * @param jp2 the jpeg2000 file codec.
- * @param p_manager the user event manager.
- *
- * @return true if writing was successful.
- */
-static OPJ_BOOL opj_jp2_write_ftyp(opj_jp2_t *jp2,
- opj_stream_private_t *cio,
- opj_event_mgr_t * p_manager);
-
-/**
- * Reads a a FTYP box - File type box
- *
- * @param p_header_data the data contained in the FTYP box.
- * @param jp2 the jpeg2000 file codec.
- * @param p_header_size the size of the data contained in the FTYP box.
- * @param p_manager the user event manager.
- *
- * @return true if the FTYP box is valid.
- */
-static OPJ_BOOL opj_jp2_read_ftyp(opj_jp2_t *jp2,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager);
-
-static OPJ_BOOL opj_jp2_skip_jp2c(opj_jp2_t *jp2,
- opj_stream_private_t *stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * Reads the Jpeg2000 file Header box - JP2 Header box (warning, this is a super box).
- *
- * @param p_header_data the data contained in the file header box.
- * @param jp2 the jpeg2000 file codec.
- * @param p_header_size the size of the data contained in the file header box.
- * @param p_manager the user event manager.
- *
- * @return true if the JP2 Header box was successfully recognized.
-*/
-static OPJ_BOOL opj_jp2_read_jp2h(opj_jp2_t *jp2,
- OPJ_BYTE *p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager);
-
-/**
- * Writes the Jpeg2000 file Header box - JP2 Header box (warning, this is a super box).
- *
- * @param jp2 the jpeg2000 file codec.
- * @param stream the stream to write data to.
- * @param p_manager user event manager.
- *
- * @return true if writing was successful.
- */
-static OPJ_BOOL opj_jp2_write_jp2h(opj_jp2_t *jp2,
- opj_stream_private_t *stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * Writes the Jpeg2000 codestream Header box - JP2C Header box. This function must be called AFTER the coding has been done.
- *
- * @param cio the stream to write data to.
- * @param jp2 the jpeg2000 file codec.
- * @param p_manager user event manager.
- *
- * @return true if writing was successful.
-*/
-static OPJ_BOOL opj_jp2_write_jp2c(opj_jp2_t *jp2,
- opj_stream_private_t *cio,
- opj_event_mgr_t * p_manager);
-
-#ifdef USE_JPIP
-/**
- * Write index Finder box
- * @param cio the stream to write to.
- * @param jp2 the jpeg2000 file codec.
- * @param p_manager user event manager.
-*/
-static OPJ_BOOL opj_jpip_write_iptr(opj_jp2_t *jp2,
- opj_stream_private_t *cio,
- opj_event_mgr_t * p_manager);
-
-/**
- * Write index Finder box
- * @param cio the stream to write to.
- * @param jp2 the jpeg2000 file codec.
- * @param p_manager user event manager.
- */
-static OPJ_BOOL opj_jpip_write_cidx(opj_jp2_t *jp2,
- opj_stream_private_t *cio,
- opj_event_mgr_t * p_manager);
-
-/**
- * Write file Index (superbox)
- * @param cio the stream to write to.
- * @param jp2 the jpeg2000 file codec.
- * @param p_manager user event manager.
- */
-static OPJ_BOOL opj_jpip_write_fidx(opj_jp2_t *jp2,
- opj_stream_private_t *cio,
- opj_event_mgr_t * p_manager);
-#endif /* USE_JPIP */
-
-/**
- * Reads a jpeg2000 file signature box.
- *
- * @param p_header_data the data contained in the signature box.
- * @param jp2 the jpeg2000 file codec.
- * @param p_header_size the size of the data contained in the signature box.
- * @param p_manager the user event manager.
- *
- * @return true if the file signature box is valid.
- */
-static OPJ_BOOL opj_jp2_read_jp(opj_jp2_t *jp2,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager);
-
-/**
- * Writes a jpeg2000 file signature box.
- *
- * @param cio the stream to write data to.
- * @param jp2 the jpeg2000 file codec.
- * @param p_manager the user event manager.
- *
- * @return true if writing was successful.
- */
-static OPJ_BOOL opj_jp2_write_jp(opj_jp2_t *jp2,
- opj_stream_private_t *cio,
- opj_event_mgr_t * p_manager);
-
-/**
-Apply collected palette data
-@param image Image.
-@param color Collector for profile, cdef and pclr data.
-@param p_manager the user event manager.
-@return true in case of success
-*/
-static OPJ_BOOL opj_jp2_apply_pclr(opj_image_t *image,
- opj_jp2_color_t *color,
- opj_event_mgr_t * p_manager);
-
-static void opj_jp2_free_pclr(opj_jp2_color_t *color);
-
-/**
- * Collect palette data
- *
- * @param jp2 JP2 handle
- * @param p_pclr_header_data FIXME DOC
- * @param p_pclr_header_size FIXME DOC
- * @param p_manager
- *
- * @return Returns true if successful, returns false otherwise
-*/
-static OPJ_BOOL opj_jp2_read_pclr(opj_jp2_t *jp2,
- OPJ_BYTE * p_pclr_header_data,
- OPJ_UINT32 p_pclr_header_size,
- opj_event_mgr_t * p_manager);
-
-/**
- * Collect component mapping data
- *
- * @param jp2 JP2 handle
- * @param p_cmap_header_data FIXME DOC
- * @param p_cmap_header_size FIXME DOC
- * @param p_manager FIXME DOC
- *
- * @return Returns true if successful, returns false otherwise
-*/
-
-static OPJ_BOOL opj_jp2_read_cmap(opj_jp2_t * jp2,
- OPJ_BYTE * p_cmap_header_data,
- OPJ_UINT32 p_cmap_header_size,
- opj_event_mgr_t * p_manager);
-
-/**
- * Reads the Color Specification box.
- *
- * @param p_colr_header_data pointer to actual data (already read from file)
- * @param jp2 the jpeg2000 file codec.
- * @param p_colr_header_size the size of the color header
- * @param p_manager the user event manager.
- *
- * @return true if the bpc header is valid, false else.
-*/
-static OPJ_BOOL opj_jp2_read_colr(opj_jp2_t *jp2,
- OPJ_BYTE * p_colr_header_data,
- OPJ_UINT32 p_colr_header_size,
- opj_event_mgr_t * p_manager);
-
-/*@}*/
-
-/*@}*/
-
-/**
- * Sets up the procedures to do on writing header after the codestream.
- * Developers wanting to extend the library can add their own writing procedures.
- */
-static OPJ_BOOL opj_jp2_setup_end_header_writing(opj_jp2_t *jp2,
- opj_event_mgr_t * p_manager);
-
-/**
- * Sets up the procedures to do on reading header after the codestream.
- * Developers wanting to extend the library can add their own writing procedures.
- */
-static OPJ_BOOL opj_jp2_setup_end_header_reading(opj_jp2_t *jp2,
- opj_event_mgr_t * p_manager);
-
-/**
- * Reads a jpeg2000 file header structure.
- *
- * @param jp2 the jpeg2000 file header structure.
- * @param stream the stream to read data from.
- * @param p_manager the user event manager.
- *
- * @return true if the box is valid.
- */
-static OPJ_BOOL opj_jp2_read_header_procedure(opj_jp2_t *jp2,
- opj_stream_private_t *stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * Executes the given procedures on the given codec.
- *
- * @param p_procedure_list the list of procedures to execute
- * @param jp2 the jpeg2000 file codec to execute the procedures on.
- * @param stream the stream to execute the procedures on.
- * @param p_manager the user manager.
- *
- * @return true if all the procedures were successfully executed.
- */
-static OPJ_BOOL opj_jp2_exec(opj_jp2_t * jp2,
- opj_procedure_list_t * p_procedure_list,
- opj_stream_private_t *stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * Reads a box header. The box is the way data is packed inside a jpeg2000 file structure.
- *
- * @param cio the input stream to read data from.
- * @param box the box structure to fill.
- * @param p_number_bytes_read pointer to an int that will store the number of bytes read from the stream (shoul usually be 2).
- * @param p_manager user event manager.
- *
- * @return true if the box is recognized, false otherwise
-*/
-static OPJ_BOOL opj_jp2_read_boxhdr(opj_jp2_box_t *box,
- OPJ_UINT32 * p_number_bytes_read,
- opj_stream_private_t *cio,
- opj_event_mgr_t * p_manager);
-
-/**
- * Sets up the validation ,i.e. adds the procedures to launch to make sure the codec parameters
- * are valid. Developers wanting to extend the library can add their own validation procedures.
- */
-static OPJ_BOOL opj_jp2_setup_encoding_validation(opj_jp2_t *jp2,
- opj_event_mgr_t * p_manager);
-
-/**
- * Sets up the procedures to do on writing header. Developers wanting to extend the library can add their own writing procedures.
- */
-static OPJ_BOOL opj_jp2_setup_header_writing(opj_jp2_t *jp2,
- opj_event_mgr_t * p_manager);
-
-static OPJ_BOOL opj_jp2_default_validation(opj_jp2_t * jp2,
- opj_stream_private_t *cio,
- opj_event_mgr_t * p_manager);
-
-/**
- * Finds the image execution function related to the given box id.
- *
- * @param p_id the id of the handler to fetch.
- *
- * @return the given handler or NULL if it could not be found.
- */
-static const opj_jp2_header_handler_t * opj_jp2_img_find_handler(
- OPJ_UINT32 p_id);
-
-/**
- * Finds the execution function related to the given box id.
- *
- * @param p_id the id of the handler to fetch.
- *
- * @return the given handler or NULL if it could not be found.
- */
-static const opj_jp2_header_handler_t * opj_jp2_find_handler(OPJ_UINT32 p_id);
-
-static const opj_jp2_header_handler_t jp2_header [] = {
- {JP2_JP, opj_jp2_read_jp},
- {JP2_FTYP, opj_jp2_read_ftyp},
- {JP2_JP2H, opj_jp2_read_jp2h}
-};
-
-static const opj_jp2_header_handler_t jp2_img_header [] = {
- {JP2_IHDR, opj_jp2_read_ihdr},
- {JP2_COLR, opj_jp2_read_colr},
- {JP2_BPCC, opj_jp2_read_bpcc},
- {JP2_PCLR, opj_jp2_read_pclr},
- {JP2_CMAP, opj_jp2_read_cmap},
- {JP2_CDEF, opj_jp2_read_cdef}
-
-};
-
-/**
- * Reads a box header. The box is the way data is packed inside a jpeg2000 file structure. Data is read from a character string
- *
- * @param box the box structure to fill.
- * @param p_data the character string to read data from.
- * @param p_number_bytes_read pointer to an int that will store the number of bytes read from the stream (shoul usually be 2).
- * @param p_box_max_size the maximum number of bytes in the box.
- * @param p_manager FIXME DOC
- *
- * @return true if the box is recognized, false otherwise
-*/
-static OPJ_BOOL opj_jp2_read_boxhdr_char(opj_jp2_box_t *box,
- OPJ_BYTE * p_data,
- OPJ_UINT32 * p_number_bytes_read,
- OPJ_UINT32 p_box_max_size,
- opj_event_mgr_t * p_manager);
-
-/**
- * Sets up the validation ,i.e. adds the procedures to launch to make sure the codec parameters
- * are valid. Developers wanting to extend the library can add their own validation procedures.
- */
-static OPJ_BOOL opj_jp2_setup_decoding_validation(opj_jp2_t *jp2,
- opj_event_mgr_t * p_manager);
-
-/**
- * Sets up the procedures to do on reading header.
- * Developers wanting to extend the library can add their own writing procedures.
- */
-static OPJ_BOOL opj_jp2_setup_header_reading(opj_jp2_t *jp2,
- opj_event_mgr_t * p_manager);
-
-/* ----------------------------------------------------------------------- */
-static OPJ_BOOL opj_jp2_read_boxhdr(opj_jp2_box_t *box,
- OPJ_UINT32 * p_number_bytes_read,
- opj_stream_private_t *cio,
- opj_event_mgr_t * p_manager)
-{
- /* read header from file */
- OPJ_BYTE l_data_header [8];
-
- /* preconditions */
- assert(cio != 00);
- assert(box != 00);
- assert(p_number_bytes_read != 00);
- assert(p_manager != 00);
-
- *p_number_bytes_read = (OPJ_UINT32)opj_stream_read_data(cio, l_data_header, 8,
- p_manager);
- if (*p_number_bytes_read != 8) {
- return OPJ_FALSE;
- }
-
- /* process read data */
- opj_read_bytes(l_data_header, &(box->length), 4);
- opj_read_bytes(l_data_header + 4, &(box->type), 4);
-
- if (box->length == 0) { /* last box */
- const OPJ_OFF_T bleft = opj_stream_get_number_byte_left(cio);
- if (bleft > (OPJ_OFF_T)(0xFFFFFFFFU - 8U)) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Cannot handle box sizes higher than 2^32\n");
- return OPJ_FALSE;
- }
- box->length = (OPJ_UINT32)bleft + 8U;
- assert((OPJ_OFF_T)box->length == bleft + 8);
- return OPJ_TRUE;
- }
-
- /* do we have a "special very large box ?" */
- /* read then the XLBox */
- if (box->length == 1) {
- OPJ_UINT32 l_xl_part_size;
-
- OPJ_UINT32 l_nb_bytes_read = (OPJ_UINT32)opj_stream_read_data(cio,
- l_data_header, 8, p_manager);
- if (l_nb_bytes_read != 8) {
- if (l_nb_bytes_read > 0) {
- *p_number_bytes_read += l_nb_bytes_read;
- }
-
- return OPJ_FALSE;
- }
-
- *p_number_bytes_read = 16;
- opj_read_bytes(l_data_header, &l_xl_part_size, 4);
- if (l_xl_part_size != 0) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Cannot handle box sizes higher than 2^32\n");
- return OPJ_FALSE;
- }
- opj_read_bytes(l_data_header + 4, &(box->length), 4);
- }
- return OPJ_TRUE;
-}
-
-#if 0
-static void jp2_write_url(opj_cio_t *cio, char *Idx_file)
-{
- OPJ_UINT32 i;
- opj_jp2_box_t box;
-
- box.init_pos = cio_tell(cio);
- cio_skip(cio, 4);
- cio_write(cio, JP2_URL, 4); /* DBTL */
- cio_write(cio, 0, 1); /* VERS */
- cio_write(cio, 0, 3); /* FLAG */
-
- if (Idx_file) {
- for (i = 0; i < strlen(Idx_file); i++) {
- cio_write(cio, Idx_file[i], 1);
- }
- }
-
- box.length = cio_tell(cio) - box.init_pos;
- cio_seek(cio, box.init_pos);
- cio_write(cio, box.length, 4); /* L */
- cio_seek(cio, box.init_pos + box.length);
-}
-#endif
-
-static OPJ_BOOL opj_jp2_read_ihdr(opj_jp2_t *jp2,
- OPJ_BYTE *p_image_header_data,
- OPJ_UINT32 p_image_header_size,
- opj_event_mgr_t * p_manager)
-{
- /* preconditions */
- assert(p_image_header_data != 00);
- assert(jp2 != 00);
- assert(p_manager != 00);
-
- if (jp2->comps != NULL) {
- opj_event_msg(p_manager, EVT_WARNING,
- "Ignoring ihdr box. First ihdr box already read\n");
- return OPJ_TRUE;
- }
-
- if (p_image_header_size != 14) {
- opj_event_msg(p_manager, EVT_ERROR, "Bad image header box (bad size)\n");
- return OPJ_FALSE;
- }
-
- opj_read_bytes(p_image_header_data, &(jp2->h), 4); /* HEIGHT */
- p_image_header_data += 4;
- opj_read_bytes(p_image_header_data, &(jp2->w), 4); /* WIDTH */
- p_image_header_data += 4;
- opj_read_bytes(p_image_header_data, &(jp2->numcomps), 2); /* NC */
- p_image_header_data += 2;
-
- if (jp2->h < 1 || jp2->w < 1 || jp2->numcomps < 1) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Wrong values for: w(%d) h(%d) numcomps(%d) (ihdr)\n",
- jp2->w, jp2->h, jp2->numcomps);
- return OPJ_FALSE;
- }
- if ((jp2->numcomps - 1U) >=
- 16384U) { /* unsigned underflow is well defined: 1U <= jp2->numcomps <= 16384U */
- opj_event_msg(p_manager, EVT_ERROR, "Invalid number of components (ihdr)\n");
- return OPJ_FALSE;
- }
-
- /* allocate memory for components */
- jp2->comps = (opj_jp2_comps_t*) opj_calloc(jp2->numcomps,
- sizeof(opj_jp2_comps_t));
- if (jp2->comps == 0) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Not enough memory to handle image header (ihdr)\n");
- return OPJ_FALSE;
- }
-
- opj_read_bytes(p_image_header_data, &(jp2->bpc), 1); /* BPC */
- ++ p_image_header_data;
-
- opj_read_bytes(p_image_header_data, &(jp2->C), 1); /* C */
- ++ p_image_header_data;
-
- /* Should be equal to 7 cf. chapter about image header box of the norm */
- if (jp2->C != 7) {
- opj_event_msg(p_manager, EVT_INFO,
- "JP2 IHDR box: compression type indicate that the file is not a conforming JP2 file (%d) \n",
- jp2->C);
- }
-
- opj_read_bytes(p_image_header_data, &(jp2->UnkC), 1); /* UnkC */
- ++ p_image_header_data;
- opj_read_bytes(p_image_header_data, &(jp2->IPR), 1); /* IPR */
- ++ p_image_header_data;
-
- jp2->j2k->m_cp.allow_different_bit_depth_sign = (jp2->bpc == 255);
- jp2->j2k->ihdr_w = jp2->w;
- jp2->j2k->ihdr_h = jp2->h;
- jp2->has_ihdr = 1;
-
- return OPJ_TRUE;
-}
-
-static OPJ_BYTE * opj_jp2_write_ihdr(opj_jp2_t *jp2,
- OPJ_UINT32 * p_nb_bytes_written
- )
-{
- OPJ_BYTE * l_ihdr_data, * l_current_ihdr_ptr;
-
- /* preconditions */
- assert(jp2 != 00);
- assert(p_nb_bytes_written != 00);
-
- /* default image header is 22 bytes wide */
- l_ihdr_data = (OPJ_BYTE *) opj_calloc(1, 22);
- if (l_ihdr_data == 00) {
- return 00;
- }
-
- l_current_ihdr_ptr = l_ihdr_data;
-
- opj_write_bytes(l_current_ihdr_ptr, 22, 4); /* write box size */
- l_current_ihdr_ptr += 4;
-
- opj_write_bytes(l_current_ihdr_ptr, JP2_IHDR, 4); /* IHDR */
- l_current_ihdr_ptr += 4;
-
- opj_write_bytes(l_current_ihdr_ptr, jp2->h, 4); /* HEIGHT */
- l_current_ihdr_ptr += 4;
-
- opj_write_bytes(l_current_ihdr_ptr, jp2->w, 4); /* WIDTH */
- l_current_ihdr_ptr += 4;
-
- opj_write_bytes(l_current_ihdr_ptr, jp2->numcomps, 2); /* NC */
- l_current_ihdr_ptr += 2;
-
- opj_write_bytes(l_current_ihdr_ptr, jp2->bpc, 1); /* BPC */
- ++l_current_ihdr_ptr;
-
- opj_write_bytes(l_current_ihdr_ptr, jp2->C, 1); /* C : Always 7 */
- ++l_current_ihdr_ptr;
-
- opj_write_bytes(l_current_ihdr_ptr, jp2->UnkC,
- 1); /* UnkC, colorspace unknown */
- ++l_current_ihdr_ptr;
-
- opj_write_bytes(l_current_ihdr_ptr, jp2->IPR,
- 1); /* IPR, no intellectual property */
- ++l_current_ihdr_ptr;
-
- *p_nb_bytes_written = 22;
-
- return l_ihdr_data;
-}
-
-static OPJ_BYTE * opj_jp2_write_bpcc(opj_jp2_t *jp2,
- OPJ_UINT32 * p_nb_bytes_written
- )
-{
- OPJ_UINT32 i;
- /* room for 8 bytes for box and 1 byte for each component */
- OPJ_UINT32 l_bpcc_size;
- OPJ_BYTE * l_bpcc_data, * l_current_bpcc_ptr;
-
- /* preconditions */
- assert(jp2 != 00);
- assert(p_nb_bytes_written != 00);
- l_bpcc_size = 8 + jp2->numcomps;
-
- l_bpcc_data = (OPJ_BYTE *) opj_calloc(1, l_bpcc_size);
- if (l_bpcc_data == 00) {
- return 00;
- }
-
- l_current_bpcc_ptr = l_bpcc_data;
-
- opj_write_bytes(l_current_bpcc_ptr, l_bpcc_size,
- 4); /* write box size */
- l_current_bpcc_ptr += 4;
-
- opj_write_bytes(l_current_bpcc_ptr, JP2_BPCC, 4); /* BPCC */
- l_current_bpcc_ptr += 4;
-
- for (i = 0; i < jp2->numcomps; ++i) {
- opj_write_bytes(l_current_bpcc_ptr, jp2->comps[i].bpcc,
- 1); /* write each component information */
- ++l_current_bpcc_ptr;
- }
-
- *p_nb_bytes_written = l_bpcc_size;
-
- return l_bpcc_data;
-}
-
-static OPJ_BOOL opj_jp2_read_bpcc(opj_jp2_t *jp2,
- OPJ_BYTE * p_bpc_header_data,
- OPJ_UINT32 p_bpc_header_size,
- opj_event_mgr_t * p_manager
- )
-{
- OPJ_UINT32 i;
-
- /* preconditions */
- assert(p_bpc_header_data != 00);
- assert(jp2 != 00);
- assert(p_manager != 00);
-
-
- if (jp2->bpc != 255) {
- opj_event_msg(p_manager, EVT_WARNING,
- "A BPCC header box is available although BPC given by the IHDR box (%d) indicate components bit depth is constant\n",
- jp2->bpc);
- }
-
- /* and length is relevant */
- if (p_bpc_header_size != jp2->numcomps) {
- opj_event_msg(p_manager, EVT_ERROR, "Bad BPCC header box (bad size)\n");
- return OPJ_FALSE;
- }
-
- /* read info for each component */
- for (i = 0; i < jp2->numcomps; ++i) {
- opj_read_bytes(p_bpc_header_data, &jp2->comps[i].bpcc,
- 1); /* read each BPCC component */
- ++p_bpc_header_data;
- }
-
- return OPJ_TRUE;
-}
-static OPJ_BYTE * opj_jp2_write_cdef(opj_jp2_t *jp2,
- OPJ_UINT32 * p_nb_bytes_written)
-{
- /* room for 8 bytes for box, 2 for n */
- OPJ_UINT32 l_cdef_size = 10;
- OPJ_BYTE * l_cdef_data, * l_current_cdef_ptr;
- OPJ_UINT32 l_value;
- OPJ_UINT16 i;
-
- /* preconditions */
- assert(jp2 != 00);
- assert(p_nb_bytes_written != 00);
- assert(jp2->color.jp2_cdef != 00);
- assert(jp2->color.jp2_cdef->info != 00);
- assert(jp2->color.jp2_cdef->n > 0U);
-
- l_cdef_size += 6U * jp2->color.jp2_cdef->n;
-
- l_cdef_data = (OPJ_BYTE *) opj_malloc(l_cdef_size);
- if (l_cdef_data == 00) {
- return 00;
- }
-
- l_current_cdef_ptr = l_cdef_data;
-
- opj_write_bytes(l_current_cdef_ptr, l_cdef_size, 4); /* write box size */
- l_current_cdef_ptr += 4;
-
- opj_write_bytes(l_current_cdef_ptr, JP2_CDEF, 4); /* BPCC */
- l_current_cdef_ptr += 4;
-
- l_value = jp2->color.jp2_cdef->n;
- opj_write_bytes(l_current_cdef_ptr, l_value, 2); /* N */
- l_current_cdef_ptr += 2;
-
- for (i = 0U; i < jp2->color.jp2_cdef->n; ++i) {
- l_value = jp2->color.jp2_cdef->info[i].cn;
- opj_write_bytes(l_current_cdef_ptr, l_value, 2); /* Cni */
- l_current_cdef_ptr += 2;
- l_value = jp2->color.jp2_cdef->info[i].typ;
- opj_write_bytes(l_current_cdef_ptr, l_value, 2); /* Typi */
- l_current_cdef_ptr += 2;
- l_value = jp2->color.jp2_cdef->info[i].asoc;
- opj_write_bytes(l_current_cdef_ptr, l_value, 2); /* Asoci */
- l_current_cdef_ptr += 2;
- }
- *p_nb_bytes_written = l_cdef_size;
-
- return l_cdef_data;
-}
-
-static OPJ_BYTE * opj_jp2_write_colr(opj_jp2_t *jp2,
- OPJ_UINT32 * p_nb_bytes_written
- )
-{
- /* room for 8 bytes for box 3 for common data and variable upon profile*/
- OPJ_UINT32 l_colr_size = 11;
- OPJ_BYTE * l_colr_data, * l_current_colr_ptr;
-
- /* preconditions */
- assert(jp2 != 00);
- assert(p_nb_bytes_written != 00);
- assert(jp2->meth == 1 || jp2->meth == 2);
-
- switch (jp2->meth) {
- case 1 :
- l_colr_size += 4; /* EnumCS */
- break;
- case 2 :
- assert(jp2->color.icc_profile_len); /* ICC profile */
- l_colr_size += jp2->color.icc_profile_len;
- break;
- default :
- return 00;
- }
-
- l_colr_data = (OPJ_BYTE *) opj_calloc(1, l_colr_size);
- if (l_colr_data == 00) {
- return 00;
- }
-
- l_current_colr_ptr = l_colr_data;
-
- opj_write_bytes(l_current_colr_ptr, l_colr_size,
- 4); /* write box size */
- l_current_colr_ptr += 4;
-
- opj_write_bytes(l_current_colr_ptr, JP2_COLR, 4); /* BPCC */
- l_current_colr_ptr += 4;
-
- opj_write_bytes(l_current_colr_ptr, jp2->meth, 1); /* METH */
- ++l_current_colr_ptr;
-
- opj_write_bytes(l_current_colr_ptr, jp2->precedence, 1); /* PRECEDENCE */
- ++l_current_colr_ptr;
-
- opj_write_bytes(l_current_colr_ptr, jp2->approx, 1); /* APPROX */
- ++l_current_colr_ptr;
-
- if (jp2->meth ==
- 1) { /* Meth value is restricted to 1 or 2 (Table I.9 of part 1) */
- opj_write_bytes(l_current_colr_ptr, jp2->enumcs, 4);
- } /* EnumCS */
- else {
- if (jp2->meth == 2) { /* ICC profile */
- OPJ_UINT32 i;
- for (i = 0; i < jp2->color.icc_profile_len; ++i) {
- opj_write_bytes(l_current_colr_ptr, jp2->color.icc_profile_buf[i], 1);
- ++l_current_colr_ptr;
- }
- }
- }
-
- *p_nb_bytes_written = l_colr_size;
-
- return l_colr_data;
-}
-
-static void opj_jp2_free_pclr(opj_jp2_color_t *color)
-{
- opj_free(color->jp2_pclr->channel_sign);
- opj_free(color->jp2_pclr->channel_size);
- opj_free(color->jp2_pclr->entries);
-
- if (color->jp2_pclr->cmap) {
- opj_free(color->jp2_pclr->cmap);
- }
-
- opj_free(color->jp2_pclr);
- color->jp2_pclr = NULL;
-}
-
-static OPJ_BOOL opj_jp2_check_color(opj_image_t *image, opj_jp2_color_t *color,
- opj_event_mgr_t *p_manager)
-{
- OPJ_UINT16 i;
-
- /* testcase 4149.pdf.SIGSEGV.cf7.3501 */
- if (color->jp2_cdef) {
- opj_jp2_cdef_info_t *info = color->jp2_cdef->info;
- OPJ_UINT16 n = color->jp2_cdef->n;
- OPJ_UINT32 nr_channels =
- image->numcomps; /* FIXME image->numcomps == jp2->numcomps before color is applied ??? */
-
- /* cdef applies to cmap channels if any */
- if (color->jp2_pclr && color->jp2_pclr->cmap) {
- nr_channels = (OPJ_UINT32)color->jp2_pclr->nr_channels;
- }
-
- for (i = 0; i < n; i++) {
- if (info[i].cn >= nr_channels) {
- opj_event_msg(p_manager, EVT_ERROR, "Invalid component index %d (>= %d).\n",
- info[i].cn, nr_channels);
- return OPJ_FALSE;
- }
- if (info[i].asoc == 65535U) {
- continue;
- }
-
- if (info[i].asoc > 0 && (OPJ_UINT32)(info[i].asoc - 1) >= nr_channels) {
- opj_event_msg(p_manager, EVT_ERROR, "Invalid component index %d (>= %d).\n",
- info[i].asoc - 1, nr_channels);
- return OPJ_FALSE;
- }
- }
-
- /* issue 397 */
- /* ISO 15444-1 states that if cdef is present, it shall contain a complete list of channel definitions. */
- while (nr_channels > 0) {
- for (i = 0; i < n; ++i) {
- if ((OPJ_UINT32)info[i].cn == (nr_channels - 1U)) {
- break;
- }
- }
- if (i == n) {
- opj_event_msg(p_manager, EVT_ERROR, "Incomplete channel definitions.\n");
- return OPJ_FALSE;
- }
- --nr_channels;
- }
- }
-
- /* testcases 451.pdf.SIGSEGV.f4c.3723, 451.pdf.SIGSEGV.5b5.3723 and
- 66ea31acbb0f23a2bbc91f64d69a03f5_signal_sigsegv_13937c0_7030_5725.pdf */
- if (color->jp2_pclr && color->jp2_pclr->cmap) {
- OPJ_UINT16 nr_channels = color->jp2_pclr->nr_channels;
- opj_jp2_cmap_comp_t *cmap = color->jp2_pclr->cmap;
- OPJ_BOOL *pcol_usage, is_sane = OPJ_TRUE;
-
- /* verify that all original components match an existing one */
- for (i = 0; i < nr_channels; i++) {
- if (cmap[i].cmp >= image->numcomps) {
- opj_event_msg(p_manager, EVT_ERROR, "Invalid component index %d (>= %d).\n",
- cmap[i].cmp, image->numcomps);
- is_sane = OPJ_FALSE;
- }
- }
-
- pcol_usage = (OPJ_BOOL *) opj_calloc(nr_channels, sizeof(OPJ_BOOL));
- if (!pcol_usage) {
- opj_event_msg(p_manager, EVT_ERROR, "Unexpected OOM.\n");
- return OPJ_FALSE;
- }
- /* verify that no component is targeted more than once */
- for (i = 0; i < nr_channels; i++) {
- OPJ_BYTE mtyp = cmap[i].mtyp;
- OPJ_BYTE pcol = cmap[i].pcol;
- /* See ISO 15444-1 Table I.14 – MTYPi field values */
- if (mtyp != 0 && mtyp != 1) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Invalid value for cmap[%d].mtyp = %d.\n", i,
- mtyp);
- is_sane = OPJ_FALSE;
- } else if (pcol >= nr_channels) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Invalid component/palette index for direct mapping %d.\n", pcol);
- is_sane = OPJ_FALSE;
- } else if (pcol_usage[pcol] && mtyp == 1) {
- opj_event_msg(p_manager, EVT_ERROR, "Component %d is mapped twice.\n", pcol);
- is_sane = OPJ_FALSE;
- } else if (mtyp == 0 && pcol != 0) {
- /* I.5.3.5 PCOL: If the value of the MTYP field for this channel is 0, then
- * the value of this field shall be 0. */
- opj_event_msg(p_manager, EVT_ERROR, "Direct use at #%d however pcol=%d.\n", i,
- pcol);
- is_sane = OPJ_FALSE;
- } else if (mtyp == 1 && pcol != i) {
- /* OpenJPEG implementation limitation. See assert(i == pcol); */
- /* in opj_jp2_apply_pclr() */
- opj_event_msg(p_manager, EVT_ERROR,
- "Implementation limitation: for palette mapping, "
- "pcol[%d] should be equal to %d, but is equal "
- "to %d.\n", i, i, pcol);
- is_sane = OPJ_FALSE;
- } else {
- pcol_usage[pcol] = OPJ_TRUE;
- }
- }
- /* verify that all components are targeted at least once */
- for (i = 0; i < nr_channels; i++) {
- if (!pcol_usage[i] && cmap[i].mtyp != 0) {
- opj_event_msg(p_manager, EVT_ERROR, "Component %d doesn't have a mapping.\n",
- i);
- is_sane = OPJ_FALSE;
- }
- }
- /* Issue 235/447 weird cmap */
- if (1 && is_sane && (image->numcomps == 1U)) {
- for (i = 0; i < nr_channels; i++) {
- if (!pcol_usage[i]) {
- is_sane = 0U;
- opj_event_msg(p_manager, EVT_WARNING,
- "Component mapping seems wrong. Trying to correct.\n");
- break;
- }
- }
- if (!is_sane) {
- is_sane = OPJ_TRUE;
- for (i = 0; i < nr_channels; i++) {
- cmap[i].mtyp = 1U;
- cmap[i].pcol = (OPJ_BYTE) i;
- }
- }
- }
- opj_free(pcol_usage);
- if (!is_sane) {
- return OPJ_FALSE;
- }
- }
-
- return OPJ_TRUE;
-}
-
-/* file9.jp2 */
-static OPJ_BOOL opj_jp2_apply_pclr(opj_image_t *image,
- opj_jp2_color_t *color,
- opj_event_mgr_t * p_manager)
-{
- opj_image_comp_t *old_comps, *new_comps;
- OPJ_BYTE *channel_size, *channel_sign;
- OPJ_UINT32 *entries;
- opj_jp2_cmap_comp_t *cmap;
- OPJ_INT32 *src, *dst;
- OPJ_UINT32 j, max;
- OPJ_UINT16 i, nr_channels, cmp, pcol;
- OPJ_INT32 k, top_k;
-
- channel_size = color->jp2_pclr->channel_size;
- channel_sign = color->jp2_pclr->channel_sign;
- entries = color->jp2_pclr->entries;
- cmap = color->jp2_pclr->cmap;
- nr_channels = color->jp2_pclr->nr_channels;
-
- for (i = 0; i < nr_channels; ++i) {
- /* Palette mapping: */
- cmp = cmap[i].cmp;
- if (image->comps[cmp].data == NULL) {
- opj_event_msg(p_manager, EVT_ERROR,
- "image->comps[%d].data == NULL in opj_jp2_apply_pclr().\n", i);
- return OPJ_FALSE;
- }
- }
-
- old_comps = image->comps;
- new_comps = (opj_image_comp_t*)
- opj_malloc(nr_channels * sizeof(opj_image_comp_t));
- if (!new_comps) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Memory allocation failure in opj_jp2_apply_pclr().\n");
- return OPJ_FALSE;
- }
- for (i = 0; i < nr_channels; ++i) {
- pcol = cmap[i].pcol;
- cmp = cmap[i].cmp;
-
- /* Direct use */
- if (cmap[i].mtyp == 0) {
- assert(pcol == 0);
- new_comps[i] = old_comps[cmp];
- } else {
- assert(i == pcol);
- new_comps[pcol] = old_comps[cmp];
- }
-
- /* Palette mapping: */
- new_comps[i].data = (OPJ_INT32*)
- opj_image_data_alloc(sizeof(OPJ_INT32) * old_comps[cmp].w * old_comps[cmp].h);
- if (!new_comps[i].data) {
- while (i > 0) {
- -- i;
- opj_image_data_free(new_comps[i].data);
- }
- opj_free(new_comps);
- opj_event_msg(p_manager, EVT_ERROR,
- "Memory allocation failure in opj_jp2_apply_pclr().\n");
- return OPJ_FALSE;
- }
- new_comps[i].prec = channel_size[i];
- new_comps[i].sgnd = channel_sign[i];
- }
-
- top_k = color->jp2_pclr->nr_entries - 1;
-
- for (i = 0; i < nr_channels; ++i) {
- /* Palette mapping: */
- cmp = cmap[i].cmp;
- pcol = cmap[i].pcol;
- src = old_comps[cmp].data;
- assert(src); /* verified above */
- max = new_comps[i].w * new_comps[i].h;
-
- /* Direct use: */
- if (cmap[i].mtyp == 0) {
- dst = new_comps[i].data;
- assert(dst);
- for (j = 0; j < max; ++j) {
- dst[j] = src[j];
- }
- } else {
- assert(i == pcol);
- dst = new_comps[pcol].data;
- assert(dst);
- for (j = 0; j < max; ++j) {
- /* The index */
- if ((k = src[j]) < 0) {
- k = 0;
- } else if (k > top_k) {
- k = top_k;
- }
-
- /* The colour */
- dst[j] = (OPJ_INT32)entries[k * nr_channels + pcol];
- }
- }
- }
-
- max = image->numcomps;
- for (j = 0; j < max; ++j) {
- if (old_comps[j].data) {
- opj_image_data_free(old_comps[j].data);
- }
- }
-
- opj_free(old_comps);
- image->comps = new_comps;
- image->numcomps = nr_channels;
-
- return OPJ_TRUE;
-}/* apply_pclr() */
-
-static OPJ_BOOL opj_jp2_read_pclr(opj_jp2_t *jp2,
- OPJ_BYTE * p_pclr_header_data,
- OPJ_UINT32 p_pclr_header_size,
- opj_event_mgr_t * p_manager
- )
-{
- opj_jp2_pclr_t *jp2_pclr;
- OPJ_BYTE *channel_size, *channel_sign;
- OPJ_UINT32 *entries;
- OPJ_UINT16 nr_entries, nr_channels;
- OPJ_UINT16 i, j;
- OPJ_UINT32 l_value;
- OPJ_BYTE *orig_header_data = p_pclr_header_data;
-
- /* preconditions */
- assert(p_pclr_header_data != 00);
- assert(jp2 != 00);
- assert(p_manager != 00);
- (void)p_pclr_header_size;
-
- if (jp2->color.jp2_pclr) {
- return OPJ_FALSE;
- }
-
- if (p_pclr_header_size < 3) {
- return OPJ_FALSE;
- }
-
- opj_read_bytes(p_pclr_header_data, &l_value, 2); /* NE */
- p_pclr_header_data += 2;
- nr_entries = (OPJ_UINT16) l_value;
- if ((nr_entries == 0U) || (nr_entries > 1024U)) {
- opj_event_msg(p_manager, EVT_ERROR, "Invalid PCLR box. Reports %d entries\n",
- (int)nr_entries);
- return OPJ_FALSE;
- }
-
- opj_read_bytes(p_pclr_header_data, &l_value, 1); /* NPC */
- ++p_pclr_header_data;
- nr_channels = (OPJ_UINT16) l_value;
- if (nr_channels == 0U) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Invalid PCLR box. Reports 0 palette columns\n");
- return OPJ_FALSE;
- }
-
- if (p_pclr_header_size < 3 + (OPJ_UINT32)nr_channels) {
- return OPJ_FALSE;
- }
-
- entries = (OPJ_UINT32*) opj_malloc(sizeof(OPJ_UINT32) * nr_channels *
- nr_entries);
- if (!entries) {
- return OPJ_FALSE;
- }
- channel_size = (OPJ_BYTE*) opj_malloc(nr_channels);
- if (!channel_size) {
- opj_free(entries);
- return OPJ_FALSE;
- }
- channel_sign = (OPJ_BYTE*) opj_malloc(nr_channels);
- if (!channel_sign) {
- opj_free(entries);
- opj_free(channel_size);
- return OPJ_FALSE;
- }
-
- jp2_pclr = (opj_jp2_pclr_t*)opj_malloc(sizeof(opj_jp2_pclr_t));
- if (!jp2_pclr) {
- opj_free(entries);
- opj_free(channel_size);
- opj_free(channel_sign);
- return OPJ_FALSE;
- }
-
- jp2_pclr->channel_sign = channel_sign;
- jp2_pclr->channel_size = channel_size;
- jp2_pclr->entries = entries;
- jp2_pclr->nr_entries = nr_entries;
- jp2_pclr->nr_channels = (OPJ_BYTE) l_value;
- jp2_pclr->cmap = NULL;
-
- jp2->color.jp2_pclr = jp2_pclr;
-
- for (i = 0; i < nr_channels; ++i) {
- opj_read_bytes(p_pclr_header_data, &l_value, 1); /* Bi */
- ++p_pclr_header_data;
-
- channel_size[i] = (OPJ_BYTE)((l_value & 0x7f) + 1);
- channel_sign[i] = (l_value & 0x80) ? 1 : 0;
- }
-
- for (j = 0; j < nr_entries; ++j) {
- for (i = 0; i < nr_channels; ++i) {
- OPJ_UINT32 bytes_to_read = (OPJ_UINT32)((channel_size[i] + 7) >> 3);
-
- if (bytes_to_read > sizeof(OPJ_UINT32)) {
- bytes_to_read = sizeof(OPJ_UINT32);
- }
- if ((ptrdiff_t)p_pclr_header_size < (ptrdiff_t)(p_pclr_header_data -
- orig_header_data) + (ptrdiff_t)bytes_to_read) {
- return OPJ_FALSE;
- }
-
- opj_read_bytes(p_pclr_header_data, &l_value, bytes_to_read); /* Cji */
- p_pclr_header_data += bytes_to_read;
- *entries = (OPJ_UINT32) l_value;
- entries++;
- }
- }
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_jp2_read_cmap(opj_jp2_t * jp2,
- OPJ_BYTE * p_cmap_header_data,
- OPJ_UINT32 p_cmap_header_size,
- opj_event_mgr_t * p_manager
- )
-{
- opj_jp2_cmap_comp_t *cmap;
- OPJ_BYTE i, nr_channels;
- OPJ_UINT32 l_value;
-
- /* preconditions */
- assert(jp2 != 00);
- assert(p_cmap_header_data != 00);
- assert(p_manager != 00);
- (void)p_cmap_header_size;
-
- /* Need nr_channels: */
- if (jp2->color.jp2_pclr == NULL) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Need to read a PCLR box before the CMAP box.\n");
- return OPJ_FALSE;
- }
-
- /* Part 1, I.5.3.5: 'There shall be at most one Component Mapping box
- * inside a JP2 Header box' :
- */
- if (jp2->color.jp2_pclr->cmap) {
- opj_event_msg(p_manager, EVT_ERROR, "Only one CMAP box is allowed.\n");
- return OPJ_FALSE;
- }
-
- nr_channels = jp2->color.jp2_pclr->nr_channels;
- if (p_cmap_header_size < (OPJ_UINT32)nr_channels * 4) {
- opj_event_msg(p_manager, EVT_ERROR, "Insufficient data for CMAP box.\n");
- return OPJ_FALSE;
- }
-
- cmap = (opj_jp2_cmap_comp_t*) opj_malloc(nr_channels * sizeof(
- opj_jp2_cmap_comp_t));
- if (!cmap) {
- return OPJ_FALSE;
- }
-
-
- for (i = 0; i < nr_channels; ++i) {
- opj_read_bytes(p_cmap_header_data, &l_value, 2); /* CMP^i */
- p_cmap_header_data += 2;
- cmap[i].cmp = (OPJ_UINT16) l_value;
-
- opj_read_bytes(p_cmap_header_data, &l_value, 1); /* MTYP^i */
- ++p_cmap_header_data;
- cmap[i].mtyp = (OPJ_BYTE) l_value;
-
- opj_read_bytes(p_cmap_header_data, &l_value, 1); /* PCOL^i */
- ++p_cmap_header_data;
- cmap[i].pcol = (OPJ_BYTE) l_value;
- }
-
- jp2->color.jp2_pclr->cmap = cmap;
-
- return OPJ_TRUE;
-}
-
-static void opj_jp2_apply_cdef(opj_image_t *image, opj_jp2_color_t *color,
- opj_event_mgr_t *manager)
-{
- opj_jp2_cdef_info_t *info;
- OPJ_UINT16 i, n, cn, asoc, acn;
-
- info = color->jp2_cdef->info;
- n = color->jp2_cdef->n;
-
- for (i = 0; i < n; ++i) {
- /* WATCH: acn = asoc - 1 ! */
- asoc = info[i].asoc;
- cn = info[i].cn;
-
- if (cn >= image->numcomps) {
- opj_event_msg(manager, EVT_WARNING, "opj_jp2_apply_cdef: cn=%d, numcomps=%d\n",
- cn, image->numcomps);
- continue;
- }
- if (asoc == 0 || asoc == 65535) {
- image->comps[cn].alpha = info[i].typ;
- continue;
- }
-
- acn = (OPJ_UINT16)(asoc - 1);
- if (acn >= image->numcomps) {
- opj_event_msg(manager, EVT_WARNING, "opj_jp2_apply_cdef: acn=%d, numcomps=%d\n",
- acn, image->numcomps);
- continue;
- }
-
- /* Swap only if color channel */
- if ((cn != acn) && (info[i].typ == 0)) {
- opj_image_comp_t saved;
- OPJ_UINT16 j;
-
- memcpy(&saved, &image->comps[cn], sizeof(opj_image_comp_t));
- memcpy(&image->comps[cn], &image->comps[acn], sizeof(opj_image_comp_t));
- memcpy(&image->comps[acn], &saved, sizeof(opj_image_comp_t));
-
- /* Swap channels in following channel definitions, don't bother with j <= i that are already processed */
- for (j = (OPJ_UINT16)(i + 1U); j < n ; ++j) {
- if (info[j].cn == cn) {
- info[j].cn = acn;
- } else if (info[j].cn == acn) {
- info[j].cn = cn;
- }
- /* asoc is related to color index. Do not update. */
- }
- }
-
- image->comps[cn].alpha = info[i].typ;
- }
-
- if (color->jp2_cdef->info) {
- opj_free(color->jp2_cdef->info);
- }
-
- opj_free(color->jp2_cdef);
- color->jp2_cdef = NULL;
-
-}/* jp2_apply_cdef() */
-
-static OPJ_BOOL opj_jp2_read_cdef(opj_jp2_t * jp2,
- OPJ_BYTE * p_cdef_header_data,
- OPJ_UINT32 p_cdef_header_size,
- opj_event_mgr_t * p_manager
- )
-{
- opj_jp2_cdef_info_t *cdef_info;
- OPJ_UINT16 i;
- OPJ_UINT32 l_value;
-
- /* preconditions */
- assert(jp2 != 00);
- assert(p_cdef_header_data != 00);
- assert(p_manager != 00);
- (void)p_cdef_header_size;
-
- /* Part 1, I.5.3.6: 'The shall be at most one Channel Definition box
- * inside a JP2 Header box.'*/
- if (jp2->color.jp2_cdef) {
- return OPJ_FALSE;
- }
-
- if (p_cdef_header_size < 2) {
- opj_event_msg(p_manager, EVT_ERROR, "Insufficient data for CDEF box.\n");
- return OPJ_FALSE;
- }
-
- opj_read_bytes(p_cdef_header_data, &l_value, 2); /* N */
- p_cdef_header_data += 2;
-
- if ((OPJ_UINT16)l_value == 0) { /* szukw000: FIXME */
- opj_event_msg(p_manager, EVT_ERROR,
- "Number of channel description is equal to zero in CDEF box.\n");
- return OPJ_FALSE;
- }
-
- if (p_cdef_header_size < 2 + (OPJ_UINT32)(OPJ_UINT16)l_value * 6) {
- opj_event_msg(p_manager, EVT_ERROR, "Insufficient data for CDEF box.\n");
- return OPJ_FALSE;
- }
-
- cdef_info = (opj_jp2_cdef_info_t*) opj_malloc(l_value * sizeof(
- opj_jp2_cdef_info_t));
- if (!cdef_info) {
- return OPJ_FALSE;
- }
-
- jp2->color.jp2_cdef = (opj_jp2_cdef_t*)opj_malloc(sizeof(opj_jp2_cdef_t));
- if (!jp2->color.jp2_cdef) {
- opj_free(cdef_info);
- return OPJ_FALSE;
- }
- jp2->color.jp2_cdef->info = cdef_info;
- jp2->color.jp2_cdef->n = (OPJ_UINT16) l_value;
-
- for (i = 0; i < jp2->color.jp2_cdef->n; ++i) {
- opj_read_bytes(p_cdef_header_data, &l_value, 2); /* Cn^i */
- p_cdef_header_data += 2;
- cdef_info[i].cn = (OPJ_UINT16) l_value;
-
- opj_read_bytes(p_cdef_header_data, &l_value, 2); /* Typ^i */
- p_cdef_header_data += 2;
- cdef_info[i].typ = (OPJ_UINT16) l_value;
-
- opj_read_bytes(p_cdef_header_data, &l_value, 2); /* Asoc^i */
- p_cdef_header_data += 2;
- cdef_info[i].asoc = (OPJ_UINT16) l_value;
- }
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_jp2_read_colr(opj_jp2_t *jp2,
- OPJ_BYTE * p_colr_header_data,
- OPJ_UINT32 p_colr_header_size,
- opj_event_mgr_t * p_manager
- )
-{
- OPJ_UINT32 l_value;
-
- /* preconditions */
- assert(jp2 != 00);
- assert(p_colr_header_data != 00);
- assert(p_manager != 00);
-
- if (p_colr_header_size < 3) {
- opj_event_msg(p_manager, EVT_ERROR, "Bad COLR header box (bad size)\n");
- return OPJ_FALSE;
- }
-
- /* Part 1, I.5.3.3 : 'A conforming JP2 reader shall ignore all Colour
- * Specification boxes after the first.'
- */
- if (jp2->color.jp2_has_colr) {
- opj_event_msg(p_manager, EVT_INFO,
- "A conforming JP2 reader shall ignore all Colour Specification boxes after the first, so we ignore this one.\n");
- p_colr_header_data += p_colr_header_size;
- return OPJ_TRUE;
- }
-
- opj_read_bytes(p_colr_header_data, &jp2->meth, 1); /* METH */
- ++p_colr_header_data;
-
- opj_read_bytes(p_colr_header_data, &jp2->precedence, 1); /* PRECEDENCE */
- ++p_colr_header_data;
-
- opj_read_bytes(p_colr_header_data, &jp2->approx, 1); /* APPROX */
- ++p_colr_header_data;
-
- if (jp2->meth == 1) {
- if (p_colr_header_size < 7) {
- opj_event_msg(p_manager, EVT_ERROR, "Bad COLR header box (bad size: %d)\n",
- p_colr_header_size);
- return OPJ_FALSE;
- }
- if ((p_colr_header_size > 7) &&
- (jp2->enumcs != 14)) { /* handled below for CIELab) */
- /* testcase Altona_Technical_v20_x4.pdf */
- opj_event_msg(p_manager, EVT_WARNING, "Bad COLR header box (bad size: %d)\n",
- p_colr_header_size);
- }
-
- opj_read_bytes(p_colr_header_data, &jp2->enumcs, 4); /* EnumCS */
-
- p_colr_header_data += 4;
-
- if (jp2->enumcs == 14) { /* CIELab */
- OPJ_UINT32 *cielab;
- OPJ_UINT32 rl, ol, ra, oa, rb, ob, il;
-
- cielab = (OPJ_UINT32*)opj_malloc(9 * sizeof(OPJ_UINT32));
- if (cielab == NULL) {
- opj_event_msg(p_manager, EVT_ERROR, "Not enough memory for cielab\n");
- return OPJ_FALSE;
- }
- cielab[0] = 14; /* enumcs */
-
- /* default values */
- rl = ra = rb = ol = oa = ob = 0;
- il = 0x00443530; /* D50 */
- cielab[1] = 0x44454600;/* DEF */
-
- if (p_colr_header_size == 35) {
- opj_read_bytes(p_colr_header_data, &rl, 4);
- p_colr_header_data += 4;
- opj_read_bytes(p_colr_header_data, &ol, 4);
- p_colr_header_data += 4;
- opj_read_bytes(p_colr_header_data, &ra, 4);
- p_colr_header_data += 4;
- opj_read_bytes(p_colr_header_data, &oa, 4);
- p_colr_header_data += 4;
- opj_read_bytes(p_colr_header_data, &rb, 4);
- p_colr_header_data += 4;
- opj_read_bytes(p_colr_header_data, &ob, 4);
- p_colr_header_data += 4;
- opj_read_bytes(p_colr_header_data, &il, 4);
- p_colr_header_data += 4;
-
- cielab[1] = 0;
- } else if (p_colr_header_size != 7) {
- opj_event_msg(p_manager, EVT_WARNING,
- "Bad COLR header box (CIELab, bad size: %d)\n", p_colr_header_size);
- }
- cielab[2] = rl;
- cielab[4] = ra;
- cielab[6] = rb;
- cielab[3] = ol;
- cielab[5] = oa;
- cielab[7] = ob;
- cielab[8] = il;
-
- jp2->color.icc_profile_buf = (OPJ_BYTE*)cielab;
- jp2->color.icc_profile_len = 0;
- }
- jp2->color.jp2_has_colr = 1;
- } else if (jp2->meth == 2) {
- /* ICC profile */
- OPJ_INT32 it_icc_value = 0;
- OPJ_INT32 icc_len = (OPJ_INT32)p_colr_header_size - 3;
-
- jp2->color.icc_profile_len = (OPJ_UINT32)icc_len;
- jp2->color.icc_profile_buf = (OPJ_BYTE*) opj_calloc(1, (size_t)icc_len);
- if (!jp2->color.icc_profile_buf) {
- jp2->color.icc_profile_len = 0;
- return OPJ_FALSE;
- }
-
- for (it_icc_value = 0; it_icc_value < icc_len; ++it_icc_value) {
- opj_read_bytes(p_colr_header_data, &l_value, 1); /* icc values */
- ++p_colr_header_data;
- jp2->color.icc_profile_buf[it_icc_value] = (OPJ_BYTE) l_value;
- }
-
- jp2->color.jp2_has_colr = 1;
- } else if (jp2->meth > 2) {
- /* ISO/IEC 15444-1:2004 (E), Table I.9 Legal METH values:
- conforming JP2 reader shall ignore the entire Colour Specification box.*/
- opj_event_msg(p_manager, EVT_INFO,
- "COLR BOX meth value is not a regular value (%d), "
- "so we will ignore the entire Colour Specification box. \n", jp2->meth);
- }
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_jp2_apply_color_postprocessing(opj_jp2_t *jp2,
- opj_image_t* p_image,
- opj_event_mgr_t * p_manager)
-{
- if (jp2->j2k->m_specific_param.m_decoder.m_numcomps_to_decode) {
- /* Bypass all JP2 component transforms */
- return OPJ_TRUE;
- }
-
- if (!jp2->ignore_pclr_cmap_cdef) {
- if (!opj_jp2_check_color(p_image, &(jp2->color), p_manager)) {
- return OPJ_FALSE;
- }
-
- if (jp2->color.jp2_pclr) {
- /* Part 1, I.5.3.4: Either both or none : */
- if (!jp2->color.jp2_pclr->cmap) {
- opj_jp2_free_pclr(&(jp2->color));
- } else {
- if (!opj_jp2_apply_pclr(p_image, &(jp2->color), p_manager)) {
- return OPJ_FALSE;
- }
- }
- }
-
- /* Apply the color space if needed */
- if (jp2->color.jp2_cdef) {
- opj_jp2_apply_cdef(p_image, &(jp2->color), p_manager);
- }
- }
-
- return OPJ_TRUE;
-}
-
-OPJ_BOOL opj_jp2_decode(opj_jp2_t *jp2,
- opj_stream_private_t *p_stream,
- opj_image_t* p_image,
- opj_event_mgr_t * p_manager)
-{
- if (!p_image) {
- return OPJ_FALSE;
- }
-
- /* J2K decoding */
- if (! opj_j2k_decode(jp2->j2k, p_stream, p_image, p_manager)) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Failed to decode the codestream in the JP2 file\n");
- return OPJ_FALSE;
- }
-
- return opj_jp2_apply_color_postprocessing(jp2, p_image, p_manager);
-}
-
-static OPJ_BOOL opj_jp2_write_jp2h(opj_jp2_t *jp2,
- opj_stream_private_t *stream,
- opj_event_mgr_t * p_manager
- )
-{
- opj_jp2_img_header_writer_handler_t l_writers [4];
- opj_jp2_img_header_writer_handler_t * l_current_writer;
-
- OPJ_INT32 i, l_nb_pass;
- /* size of data for super box*/
- OPJ_UINT32 l_jp2h_size = 8;
- OPJ_BOOL l_result = OPJ_TRUE;
-
- /* to store the data of the super box */
- OPJ_BYTE l_jp2h_data [8];
-
- /* preconditions */
- assert(stream != 00);
- assert(jp2 != 00);
- assert(p_manager != 00);
-
- memset(l_writers, 0, sizeof(l_writers));
-
- if (jp2->bpc == 255) {
- l_nb_pass = 3;
- l_writers[0].handler = opj_jp2_write_ihdr;
- l_writers[1].handler = opj_jp2_write_bpcc;
- l_writers[2].handler = opj_jp2_write_colr;
- } else {
- l_nb_pass = 2;
- l_writers[0].handler = opj_jp2_write_ihdr;
- l_writers[1].handler = opj_jp2_write_colr;
- }
-
- if (jp2->color.jp2_cdef != NULL) {
- l_writers[l_nb_pass].handler = opj_jp2_write_cdef;
- l_nb_pass++;
- }
-
- /* write box header */
- /* write JP2H type */
- opj_write_bytes(l_jp2h_data + 4, JP2_JP2H, 4);
-
- l_current_writer = l_writers;
- for (i = 0; i < l_nb_pass; ++i) {
- l_current_writer->m_data = l_current_writer->handler(jp2,
- &(l_current_writer->m_size));
- if (l_current_writer->m_data == 00) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Not enough memory to hold JP2 Header data\n");
- l_result = OPJ_FALSE;
- break;
- }
-
- l_jp2h_size += l_current_writer->m_size;
- ++l_current_writer;
- }
-
- if (! l_result) {
- l_current_writer = l_writers;
- for (i = 0; i < l_nb_pass; ++i) {
- if (l_current_writer->m_data != 00) {
- opj_free(l_current_writer->m_data);
- }
- ++l_current_writer;
- }
-
- return OPJ_FALSE;
- }
-
- /* write super box size */
- opj_write_bytes(l_jp2h_data, l_jp2h_size, 4);
-
- /* write super box data on stream */
- if (opj_stream_write_data(stream, l_jp2h_data, 8, p_manager) != 8) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Stream error while writing JP2 Header box\n");
- l_result = OPJ_FALSE;
- }
-
- if (l_result) {
- l_current_writer = l_writers;
- for (i = 0; i < l_nb_pass; ++i) {
- if (opj_stream_write_data(stream, l_current_writer->m_data,
- l_current_writer->m_size, p_manager) != l_current_writer->m_size) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Stream error while writing JP2 Header box\n");
- l_result = OPJ_FALSE;
- break;
- }
- ++l_current_writer;
- }
- }
-
- l_current_writer = l_writers;
-
- /* cleanup */
- for (i = 0; i < l_nb_pass; ++i) {
- if (l_current_writer->m_data != 00) {
- opj_free(l_current_writer->m_data);
- }
- ++l_current_writer;
- }
-
- return l_result;
-}
-
-static OPJ_BOOL opj_jp2_write_ftyp(opj_jp2_t *jp2,
- opj_stream_private_t *cio,
- opj_event_mgr_t * p_manager)
-{
- OPJ_UINT32 i;
- OPJ_UINT32 l_ftyp_size;
- OPJ_BYTE * l_ftyp_data, * l_current_data_ptr;
- OPJ_BOOL l_result;
-
- /* preconditions */
- assert(cio != 00);
- assert(jp2 != 00);
- assert(p_manager != 00);
- l_ftyp_size = 16 + 4 * jp2->numcl;
-
- l_ftyp_data = (OPJ_BYTE *) opj_calloc(1, l_ftyp_size);
-
- if (l_ftyp_data == 00) {
- opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to handle ftyp data\n");
- return OPJ_FALSE;
- }
-
- l_current_data_ptr = l_ftyp_data;
-
- opj_write_bytes(l_current_data_ptr, l_ftyp_size, 4); /* box size */
- l_current_data_ptr += 4;
-
- opj_write_bytes(l_current_data_ptr, JP2_FTYP, 4); /* FTYP */
- l_current_data_ptr += 4;
-
- opj_write_bytes(l_current_data_ptr, jp2->brand, 4); /* BR */
- l_current_data_ptr += 4;
-
- opj_write_bytes(l_current_data_ptr, jp2->minversion, 4); /* MinV */
- l_current_data_ptr += 4;
-
- for (i = 0; i < jp2->numcl; i++) {
- opj_write_bytes(l_current_data_ptr, jp2->cl[i], 4); /* CL */
- }
-
- l_result = (opj_stream_write_data(cio, l_ftyp_data, l_ftyp_size,
- p_manager) == l_ftyp_size);
- if (! l_result) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Error while writing ftyp data to stream\n");
- }
-
- opj_free(l_ftyp_data);
-
- return l_result;
-}
-
-static OPJ_BOOL opj_jp2_write_jp2c(opj_jp2_t *jp2,
- opj_stream_private_t *cio,
- opj_event_mgr_t * p_manager)
-{
- OPJ_OFF_T j2k_codestream_exit;
- OPJ_BYTE l_data_header [8];
-
- /* preconditions */
- assert(jp2 != 00);
- assert(cio != 00);
- assert(p_manager != 00);
- assert(opj_stream_has_seek(cio));
-
- j2k_codestream_exit = opj_stream_tell(cio);
- opj_write_bytes(l_data_header,
- (OPJ_UINT32)(j2k_codestream_exit - jp2->j2k_codestream_offset),
- 4); /* size of codestream */
- opj_write_bytes(l_data_header + 4, JP2_JP2C,
- 4); /* JP2C */
-
- if (! opj_stream_seek(cio, jp2->j2k_codestream_offset, p_manager)) {
- opj_event_msg(p_manager, EVT_ERROR, "Failed to seek in the stream.\n");
- return OPJ_FALSE;
- }
-
- if (opj_stream_write_data(cio, l_data_header, 8, p_manager) != 8) {
- opj_event_msg(p_manager, EVT_ERROR, "Failed to seek in the stream.\n");
- return OPJ_FALSE;
- }
-
- if (! opj_stream_seek(cio, j2k_codestream_exit, p_manager)) {
- opj_event_msg(p_manager, EVT_ERROR, "Failed to seek in the stream.\n");
- return OPJ_FALSE;
- }
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_jp2_write_jp(opj_jp2_t *jp2,
- opj_stream_private_t *cio,
- opj_event_mgr_t * p_manager)
-{
- /* 12 bytes will be read */
- OPJ_BYTE l_signature_data [12];
-
- /* preconditions */
- assert(cio != 00);
- assert(jp2 != 00);
- assert(p_manager != 00);
-
- OPJ_UNUSED(jp2);
-
- /* write box length */
- opj_write_bytes(l_signature_data, 12, 4);
- /* writes box type */
- opj_write_bytes(l_signature_data + 4, JP2_JP, 4);
- /* writes magic number*/
- opj_write_bytes(l_signature_data + 8, 0x0d0a870a, 4);
-
- if (opj_stream_write_data(cio, l_signature_data, 12, p_manager) != 12) {
- return OPJ_FALSE;
- }
-
- return OPJ_TRUE;
-}
-
-/* ----------------------------------------------------------------------- */
-/* JP2 decoder interface */
-/* ----------------------------------------------------------------------- */
-
-void opj_jp2_setup_decoder(opj_jp2_t *jp2, opj_dparameters_t *parameters)
-{
- /* setup the J2K codec */
- opj_j2k_setup_decoder(jp2->j2k, parameters);
-
- /* further JP2 initializations go here */
- jp2->color.jp2_has_colr = 0;
- jp2->ignore_pclr_cmap_cdef = parameters->flags &
- OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG;
-}
-
-void opj_jp2_decoder_set_strict_mode(opj_jp2_t *jp2, OPJ_BOOL strict)
-{
- opj_j2k_decoder_set_strict_mode(jp2->j2k, strict);
-}
-
-OPJ_BOOL opj_jp2_set_threads(opj_jp2_t *jp2, OPJ_UINT32 num_threads)
-{
- return opj_j2k_set_threads(jp2->j2k, num_threads);
-}
-
-/* ----------------------------------------------------------------------- */
-/* JP2 encoder interface */
-/* ----------------------------------------------------------------------- */
-
-OPJ_BOOL opj_jp2_setup_encoder(opj_jp2_t *jp2,
- opj_cparameters_t *parameters,
- opj_image_t *image,
- opj_event_mgr_t * p_manager)
-{
- OPJ_UINT32 i;
- OPJ_UINT32 depth_0;
- OPJ_UINT32 sign;
- OPJ_UINT32 alpha_count;
- OPJ_UINT32 color_channels = 0U;
- OPJ_UINT32 alpha_channel = 0U;
-
-
- if (!jp2 || !parameters || !image) {
- return OPJ_FALSE;
- }
-
- /* setup the J2K codec */
- /* ------------------- */
-
- /* Check if number of components respects standard */
- if (image->numcomps < 1 || image->numcomps > 16384) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Invalid number of components specified while setting up JP2 encoder\n");
- return OPJ_FALSE;
- }
-
- if (opj_j2k_setup_encoder(jp2->j2k, parameters, image,
- p_manager) == OPJ_FALSE) {
- return OPJ_FALSE;
- }
-
- /* setup the JP2 codec */
- /* ------------------- */
-
- /* Profile box */
-
- jp2->brand = JP2_JP2; /* BR */
- jp2->minversion = 0; /* MinV */
- jp2->numcl = 1;
- jp2->cl = (OPJ_UINT32*) opj_malloc(jp2->numcl * sizeof(OPJ_UINT32));
- if (!jp2->cl) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Not enough memory when setup the JP2 encoder\n");
- return OPJ_FALSE;
- }
- jp2->cl[0] = JP2_JP2; /* CL0 : JP2 */
-
- /* Image Header box */
-
- jp2->numcomps = image->numcomps; /* NC */
- jp2->comps = (opj_jp2_comps_t*) opj_malloc(jp2->numcomps * sizeof(
- opj_jp2_comps_t));
- if (!jp2->comps) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Not enough memory when setup the JP2 encoder\n");
- /* Memory of jp2->cl will be freed by opj_jp2_destroy */
- return OPJ_FALSE;
- }
-
- jp2->h = image->y1 - image->y0; /* HEIGHT */
- jp2->w = image->x1 - image->x0; /* WIDTH */
- /* BPC */
- depth_0 = image->comps[0].prec - 1;
- sign = image->comps[0].sgnd;
- jp2->bpc = depth_0 + (sign << 7);
- for (i = 1; i < image->numcomps; i++) {
- OPJ_UINT32 depth = image->comps[i].prec - 1;
- sign = image->comps[i].sgnd;
- if (depth_0 != depth) {
- jp2->bpc = 255;
- }
- }
- jp2->C = 7; /* C : Always 7 */
- jp2->UnkC = 0; /* UnkC, colorspace specified in colr box */
- jp2->IPR = 0; /* IPR, no intellectual property */
-
- /* BitsPerComponent box */
- for (i = 0; i < image->numcomps; i++) {
- jp2->comps[i].bpcc = image->comps[i].prec - 1 + (image->comps[i].sgnd << 7);
- }
-
- /* Colour Specification box */
- if (image->icc_profile_len) {
- jp2->meth = 2;
- jp2->enumcs = 0;
- } else {
- jp2->meth = 1;
- if (image->color_space == OPJ_CLRSPC_SRGB) {
- jp2->enumcs = 16; /* sRGB as defined by IEC 61966-2-1 */
- } else if (image->color_space == OPJ_CLRSPC_GRAY) {
- jp2->enumcs = 17;
- } else if (image->color_space == OPJ_CLRSPC_SYCC) {
- jp2->enumcs = 18; /* YUV */
- } else if (image->color_space == OPJ_CLRSPC_EYCC) {
- jp2->enumcs = 24;
- } else if (image->color_space == OPJ_CLRSPC_CMYK) {
- jp2->enumcs = 12;
- }
- }
-
- /* Channel Definition box */
- /* FIXME not provided by parameters */
- /* We try to do what we can... */
- alpha_count = 0U;
- for (i = 0; i < image->numcomps; i++) {
- if (image->comps[i].alpha != 0) {
- alpha_count++;
- alpha_channel = i;
- }
- }
- if (alpha_count == 1U) { /* no way to deal with more than 1 alpha channel */
- switch (jp2->enumcs) {
- case 16:
- case 18:
- color_channels = 3;
- break;
- case 17:
- color_channels = 1;
- break;
- default:
- alpha_count = 0U;
- break;
- }
- if (alpha_count == 0U) {
- opj_event_msg(p_manager, EVT_WARNING,
- "Alpha channel specified but unknown enumcs. No cdef box will be created.\n");
- } else if (image->numcomps < (color_channels + 1)) {
- opj_event_msg(p_manager, EVT_WARNING,
- "Alpha channel specified but not enough image components for an automatic cdef box creation.\n");
- alpha_count = 0U;
- } else if ((OPJ_UINT32)alpha_channel < color_channels) {
- opj_event_msg(p_manager, EVT_WARNING,
- "Alpha channel position conflicts with color channel. No cdef box will be created.\n");
- alpha_count = 0U;
- }
- } else if (alpha_count > 1) {
- opj_event_msg(p_manager, EVT_WARNING,
- "Multiple alpha channels specified. No cdef box will be created.\n");
- }
- if (alpha_count == 1U) { /* if here, we know what we can do */
- jp2->color.jp2_cdef = (opj_jp2_cdef_t*)opj_malloc(sizeof(opj_jp2_cdef_t));
- if (!jp2->color.jp2_cdef) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Not enough memory to setup the JP2 encoder\n");
- return OPJ_FALSE;
- }
- /* no memset needed, all values will be overwritten except if jp2->color.jp2_cdef->info allocation fails, */
- /* in which case jp2->color.jp2_cdef->info will be NULL => valid for destruction */
- jp2->color.jp2_cdef->info = (opj_jp2_cdef_info_t*) opj_malloc(
- image->numcomps * sizeof(opj_jp2_cdef_info_t));
- if (!jp2->color.jp2_cdef->info) {
- /* memory will be freed by opj_jp2_destroy */
- opj_event_msg(p_manager, EVT_ERROR,
- "Not enough memory to setup the JP2 encoder\n");
- return OPJ_FALSE;
- }
- jp2->color.jp2_cdef->n = (OPJ_UINT16)
- image->numcomps; /* cast is valid : image->numcomps [1,16384] */
- for (i = 0U; i < color_channels; i++) {
- jp2->color.jp2_cdef->info[i].cn = (OPJ_UINT16)
- i; /* cast is valid : image->numcomps [1,16384] */
- jp2->color.jp2_cdef->info[i].typ = 0U;
- jp2->color.jp2_cdef->info[i].asoc = (OPJ_UINT16)(i +
- 1U); /* No overflow + cast is valid : image->numcomps [1,16384] */
- }
- for (; i < image->numcomps; i++) {
- if (image->comps[i].alpha != 0) { /* we'll be here exactly once */
- jp2->color.jp2_cdef->info[i].cn = (OPJ_UINT16)
- i; /* cast is valid : image->numcomps [1,16384] */
- jp2->color.jp2_cdef->info[i].typ = 1U; /* Opacity channel */
- jp2->color.jp2_cdef->info[i].asoc =
- 0U; /* Apply alpha channel to the whole image */
- } else {
- /* Unknown channel */
- jp2->color.jp2_cdef->info[i].cn = (OPJ_UINT16)
- i; /* cast is valid : image->numcomps [1,16384] */
- jp2->color.jp2_cdef->info[i].typ = 65535U;
- jp2->color.jp2_cdef->info[i].asoc = 65535U;
- }
- }
- }
-
- jp2->precedence = 0; /* PRECEDENCE */
- jp2->approx = 0; /* APPROX */
-
- jp2->jpip_on = parameters->jpip_on;
-
- return OPJ_TRUE;
-}
-
-OPJ_BOOL opj_jp2_encode(opj_jp2_t *jp2,
- opj_stream_private_t *stream,
- opj_event_mgr_t * p_manager)
-{
- return opj_j2k_encode(jp2->j2k, stream, p_manager);
-}
-
-OPJ_BOOL opj_jp2_end_decompress(opj_jp2_t *jp2,
- opj_stream_private_t *cio,
- opj_event_mgr_t * p_manager
- )
-{
- /* preconditions */
- assert(jp2 != 00);
- assert(cio != 00);
- assert(p_manager != 00);
-
- /* customization of the end encoding */
- if (! opj_jp2_setup_end_header_reading(jp2, p_manager)) {
- return OPJ_FALSE;
- }
-
- /* write header */
- if (! opj_jp2_exec(jp2, jp2->m_procedure_list, cio, p_manager)) {
- return OPJ_FALSE;
- }
-
- return opj_j2k_end_decompress(jp2->j2k, cio, p_manager);
-}
-
-OPJ_BOOL opj_jp2_end_compress(opj_jp2_t *jp2,
- opj_stream_private_t *cio,
- opj_event_mgr_t * p_manager
- )
-{
- /* preconditions */
- assert(jp2 != 00);
- assert(cio != 00);
- assert(p_manager != 00);
-
- /* customization of the end encoding */
- if (! opj_jp2_setup_end_header_writing(jp2, p_manager)) {
- return OPJ_FALSE;
- }
-
- if (! opj_j2k_end_compress(jp2->j2k, cio, p_manager)) {
- return OPJ_FALSE;
- }
-
- /* write header */
- return opj_jp2_exec(jp2, jp2->m_procedure_list, cio, p_manager);
-}
-
-static OPJ_BOOL opj_jp2_setup_end_header_writing(opj_jp2_t *jp2,
- opj_event_mgr_t * p_manager)
-{
- /* preconditions */
- assert(jp2 != 00);
- assert(p_manager != 00);
-
-#ifdef USE_JPIP
- if (jp2->jpip_on) {
- if (! opj_procedure_list_add_procedure(jp2->m_procedure_list,
- (opj_procedure)opj_jpip_write_iptr, p_manager)) {
- return OPJ_FALSE;
- }
- }
-#endif
- if (! opj_procedure_list_add_procedure(jp2->m_procedure_list,
- (opj_procedure)opj_jp2_write_jp2c, p_manager)) {
- return OPJ_FALSE;
- }
- /* DEVELOPER CORNER, add your custom procedures */
-#ifdef USE_JPIP
- if (jp2->jpip_on) {
- if (! opj_procedure_list_add_procedure(jp2->m_procedure_list,
- (opj_procedure)opj_jpip_write_cidx, p_manager)) {
- return OPJ_FALSE;
- }
- if (! opj_procedure_list_add_procedure(jp2->m_procedure_list,
- (opj_procedure)opj_jpip_write_fidx, p_manager)) {
- return OPJ_FALSE;
- }
- }
-#endif
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_jp2_setup_end_header_reading(opj_jp2_t *jp2,
- opj_event_mgr_t * p_manager)
-{
- /* preconditions */
- assert(jp2 != 00);
- assert(p_manager != 00);
-
- if (! opj_procedure_list_add_procedure(jp2->m_procedure_list,
- (opj_procedure)opj_jp2_read_header_procedure, p_manager)) {
- return OPJ_FALSE;
- }
- /* DEVELOPER CORNER, add your custom procedures */
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_jp2_default_validation(opj_jp2_t * jp2,
- opj_stream_private_t *cio,
- opj_event_mgr_t * p_manager
- )
-{
- OPJ_BOOL l_is_valid = OPJ_TRUE;
- OPJ_UINT32 i;
-
- /* preconditions */
- assert(jp2 != 00);
- assert(cio != 00);
- assert(p_manager != 00);
-
- OPJ_UNUSED(p_manager);
-
- /* JPEG2000 codec validation */
-
- /* STATE checking */
- /* make sure the state is at 0 */
- l_is_valid &= (jp2->jp2_state == JP2_STATE_NONE);
-
- /* make sure not reading a jp2h ???? WEIRD */
- l_is_valid &= (jp2->jp2_img_state == JP2_IMG_STATE_NONE);
-
- /* POINTER validation */
- /* make sure a j2k codec is present */
- l_is_valid &= (jp2->j2k != 00);
-
- /* make sure a procedure list is present */
- l_is_valid &= (jp2->m_procedure_list != 00);
-
- /* make sure a validation list is present */
- l_is_valid &= (jp2->m_validation_list != 00);
-
- /* PARAMETER VALIDATION */
- /* number of components */
- l_is_valid &= (jp2->numcl > 0);
- /* width */
- l_is_valid &= (jp2->h > 0);
- /* height */
- l_is_valid &= (jp2->w > 0);
- /* precision */
- for (i = 0; i < jp2->numcomps; ++i) {
- l_is_valid &= ((jp2->comps[i].bpcc & 0x7FU) <
- 38U); /* 0 is valid, ignore sign for check */
- }
-
- /* METH */
- l_is_valid &= ((jp2->meth > 0) && (jp2->meth < 3));
-
- /* stream validation */
- /* back and forth is needed */
- l_is_valid &= opj_stream_has_seek(cio);
-
- return l_is_valid;
-}
-
-static OPJ_BOOL opj_jp2_read_header_procedure(opj_jp2_t *jp2,
- opj_stream_private_t *stream,
- opj_event_mgr_t * p_manager
- )
-{
- opj_jp2_box_t box;
- OPJ_UINT32 l_nb_bytes_read;
- const opj_jp2_header_handler_t * l_current_handler;
- const opj_jp2_header_handler_t * l_current_handler_misplaced;
- OPJ_UINT32 l_last_data_size = OPJ_BOX_SIZE;
- OPJ_UINT32 l_current_data_size;
- OPJ_BYTE * l_current_data = 00;
-
- /* preconditions */
- assert(stream != 00);
- assert(jp2 != 00);
- assert(p_manager != 00);
-
- l_current_data = (OPJ_BYTE*)opj_calloc(1, l_last_data_size);
-
- if (l_current_data == 00) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Not enough memory to handle jpeg2000 file header\n");
- return OPJ_FALSE;
- }
-
- while (opj_jp2_read_boxhdr(&box, &l_nb_bytes_read, stream, p_manager)) {
- /* is it the codestream box ? */
- if (box.type == JP2_JP2C) {
- if (jp2->jp2_state & JP2_STATE_HEADER) {
- jp2->jp2_state |= JP2_STATE_CODESTREAM;
- opj_free(l_current_data);
- return OPJ_TRUE;
- } else {
- opj_event_msg(p_manager, EVT_ERROR, "bad placed jpeg codestream\n");
- opj_free(l_current_data);
- return OPJ_FALSE;
- }
- } else if (box.length == 0) {
- opj_event_msg(p_manager, EVT_ERROR, "Cannot handle box of undefined sizes\n");
- opj_free(l_current_data);
- return OPJ_FALSE;
- }
- /* testcase 1851.pdf.SIGSEGV.ce9.948 */
- else if (box.length < l_nb_bytes_read) {
- opj_event_msg(p_manager, EVT_ERROR, "invalid box size %d (%x)\n", box.length,
- box.type);
- opj_free(l_current_data);
- return OPJ_FALSE;
- }
-
- l_current_handler = opj_jp2_find_handler(box.type);
- l_current_handler_misplaced = opj_jp2_img_find_handler(box.type);
- l_current_data_size = box.length - l_nb_bytes_read;
-
- if ((l_current_handler != 00) || (l_current_handler_misplaced != 00)) {
- if (l_current_handler == 00) {
- opj_event_msg(p_manager, EVT_WARNING,
- "Found a misplaced '%c%c%c%c' box outside jp2h box\n",
- (OPJ_BYTE)(box.type >> 24), (OPJ_BYTE)(box.type >> 16),
- (OPJ_BYTE)(box.type >> 8), (OPJ_BYTE)(box.type >> 0));
- if (jp2->jp2_state & JP2_STATE_HEADER) {
- /* read anyway, we already have jp2h */
- l_current_handler = l_current_handler_misplaced;
- } else {
- opj_event_msg(p_manager, EVT_WARNING,
- "JPEG2000 Header box not read yet, '%c%c%c%c' box will be ignored\n",
- (OPJ_BYTE)(box.type >> 24), (OPJ_BYTE)(box.type >> 16),
- (OPJ_BYTE)(box.type >> 8), (OPJ_BYTE)(box.type >> 0));
- jp2->jp2_state |= JP2_STATE_UNKNOWN;
- if (opj_stream_skip(stream, l_current_data_size,
- p_manager) != l_current_data_size) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Problem with skipping JPEG2000 box, stream error\n");
- opj_free(l_current_data);
- return OPJ_FALSE;
- }
- continue;
- }
- }
- if ((OPJ_OFF_T)l_current_data_size > opj_stream_get_number_byte_left(stream)) {
- /* do not even try to malloc if we can't read */
- opj_event_msg(p_manager, EVT_ERROR,
- "Invalid box size %d for box '%c%c%c%c'. Need %d bytes, %d bytes remaining \n",
- box.length, (OPJ_BYTE)(box.type >> 24), (OPJ_BYTE)(box.type >> 16),
- (OPJ_BYTE)(box.type >> 8), (OPJ_BYTE)(box.type >> 0), l_current_data_size,
- (OPJ_UINT32)opj_stream_get_number_byte_left(stream));
- opj_free(l_current_data);
- return OPJ_FALSE;
- }
- if (l_current_data_size > l_last_data_size) {
- OPJ_BYTE* new_current_data = (OPJ_BYTE*)opj_realloc(l_current_data,
- l_current_data_size);
- if (!new_current_data) {
- opj_free(l_current_data);
- opj_event_msg(p_manager, EVT_ERROR,
- "Not enough memory to handle jpeg2000 box\n");
- return OPJ_FALSE;
- }
- l_current_data = new_current_data;
- l_last_data_size = l_current_data_size;
- }
-
- l_nb_bytes_read = (OPJ_UINT32)opj_stream_read_data(stream, l_current_data,
- l_current_data_size, p_manager);
- if (l_nb_bytes_read != l_current_data_size) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Problem with reading JPEG2000 box, stream error\n");
- opj_free(l_current_data);
- return OPJ_FALSE;
- }
-
- if (! l_current_handler->handler(jp2, l_current_data, l_current_data_size,
- p_manager)) {
- opj_free(l_current_data);
- return OPJ_FALSE;
- }
- } else {
- if (!(jp2->jp2_state & JP2_STATE_SIGNATURE)) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Malformed JP2 file format: first box must be JPEG 2000 signature box\n");
- opj_free(l_current_data);
- return OPJ_FALSE;
- }
- if (!(jp2->jp2_state & JP2_STATE_FILE_TYPE)) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Malformed JP2 file format: second box must be file type box\n");
- opj_free(l_current_data);
- return OPJ_FALSE;
- }
- jp2->jp2_state |= JP2_STATE_UNKNOWN;
- if (opj_stream_skip(stream, l_current_data_size,
- p_manager) != l_current_data_size) {
- if (jp2->jp2_state & JP2_STATE_CODESTREAM) {
- /* If we already read the codestream, do not error out */
- /* Needed for data/input/nonregression/issue254.jp2 */
- opj_event_msg(p_manager, EVT_WARNING,
- "Problem with skipping JPEG2000 box, stream error\n");
- opj_free(l_current_data);
- return OPJ_TRUE;
- } else {
- opj_event_msg(p_manager, EVT_ERROR,
- "Problem with skipping JPEG2000 box, stream error\n");
- opj_free(l_current_data);
- return OPJ_FALSE;
- }
- }
- }
- }
-
- opj_free(l_current_data);
-
- return OPJ_TRUE;
-}
-
-/**
- * Executes the given procedures on the given codec.
- *
- * @param p_procedure_list the list of procedures to execute
- * @param jp2 the jpeg2000 file codec to execute the procedures on.
- * @param stream the stream to execute the procedures on.
- * @param p_manager the user manager.
- *
- * @return true if all the procedures were successfully executed.
- */
-static OPJ_BOOL opj_jp2_exec(opj_jp2_t * jp2,
- opj_procedure_list_t * p_procedure_list,
- opj_stream_private_t *stream,
- opj_event_mgr_t * p_manager
- )
-
-{
- OPJ_BOOL(** l_procedure)(opj_jp2_t * jp2, opj_stream_private_t *,
- opj_event_mgr_t *) = 00;
- OPJ_BOOL l_result = OPJ_TRUE;
- OPJ_UINT32 l_nb_proc, i;
-
- /* preconditions */
- assert(p_procedure_list != 00);
- assert(jp2 != 00);
- assert(stream != 00);
- assert(p_manager != 00);
-
- l_nb_proc = opj_procedure_list_get_nb_procedures(p_procedure_list);
- l_procedure = (OPJ_BOOL(**)(opj_jp2_t * jp2, opj_stream_private_t *,
- opj_event_mgr_t *)) opj_procedure_list_get_first_procedure(p_procedure_list);
-
- for (i = 0; i < l_nb_proc; ++i) {
- l_result = l_result && (*l_procedure)(jp2, stream, p_manager);
- ++l_procedure;
- }
-
- /* and clear the procedure list at the end. */
- opj_procedure_list_clear(p_procedure_list);
- return l_result;
-}
-
-OPJ_BOOL opj_jp2_start_compress(opj_jp2_t *jp2,
- opj_stream_private_t *stream,
- opj_image_t * p_image,
- opj_event_mgr_t * p_manager
- )
-{
- /* preconditions */
- assert(jp2 != 00);
- assert(stream != 00);
- assert(p_manager != 00);
-
- /* customization of the validation */
- if (! opj_jp2_setup_encoding_validation(jp2, p_manager)) {
- return OPJ_FALSE;
- }
-
- /* validation of the parameters codec */
- if (! opj_jp2_exec(jp2, jp2->m_validation_list, stream, p_manager)) {
- return OPJ_FALSE;
- }
-
- /* customization of the encoding */
- if (! opj_jp2_setup_header_writing(jp2, p_manager)) {
- return OPJ_FALSE;
- }
-
- /* write header */
- if (! opj_jp2_exec(jp2, jp2->m_procedure_list, stream, p_manager)) {
- return OPJ_FALSE;
- }
-
- return opj_j2k_start_compress(jp2->j2k, stream, p_image, p_manager);
-}
-
-static const opj_jp2_header_handler_t * opj_jp2_find_handler(OPJ_UINT32 p_id)
-{
- OPJ_UINT32 i, l_handler_size = sizeof(jp2_header) / sizeof(
- opj_jp2_header_handler_t);
-
- for (i = 0; i < l_handler_size; ++i) {
- if (jp2_header[i].id == p_id) {
- return &jp2_header[i];
- }
- }
- return NULL;
-}
-
-/**
- * Finds the image execution function related to the given box id.
- *
- * @param p_id the id of the handler to fetch.
- *
- * @return the given handler or 00 if it could not be found.
- */
-static const opj_jp2_header_handler_t * opj_jp2_img_find_handler(
- OPJ_UINT32 p_id)
-{
- OPJ_UINT32 i, l_handler_size = sizeof(jp2_img_header) / sizeof(
- opj_jp2_header_handler_t);
- for (i = 0; i < l_handler_size; ++i) {
- if (jp2_img_header[i].id == p_id) {
- return &jp2_img_header[i];
- }
- }
-
- return NULL;
-}
-
-/**
- * Reads a jpeg2000 file signature box.
- *
- * @param p_header_data the data contained in the signature box.
- * @param jp2 the jpeg2000 file codec.
- * @param p_header_size the size of the data contained in the signature box.
- * @param p_manager the user event manager.
- *
- * @return true if the file signature box is valid.
- */
-static OPJ_BOOL opj_jp2_read_jp(opj_jp2_t *jp2,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager
- )
-
-{
- OPJ_UINT32 l_magic_number;
-
- /* preconditions */
- assert(p_header_data != 00);
- assert(jp2 != 00);
- assert(p_manager != 00);
-
- if (jp2->jp2_state != JP2_STATE_NONE) {
- opj_event_msg(p_manager, EVT_ERROR,
- "The signature box must be the first box in the file.\n");
- return OPJ_FALSE;
- }
-
- /* assure length of data is correct (4 -> magic number) */
- if (p_header_size != 4) {
- opj_event_msg(p_manager, EVT_ERROR, "Error with JP signature Box size\n");
- return OPJ_FALSE;
- }
-
- /* rearrange data */
- opj_read_bytes(p_header_data, &l_magic_number, 4);
- if (l_magic_number != 0x0d0a870a) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Error with JP Signature : bad magic number\n");
- return OPJ_FALSE;
- }
-
- jp2->jp2_state |= JP2_STATE_SIGNATURE;
-
- return OPJ_TRUE;
-}
-
-/**
- * Reads a a FTYP box - File type box
- *
- * @param p_header_data the data contained in the FTYP box.
- * @param jp2 the jpeg2000 file codec.
- * @param p_header_size the size of the data contained in the FTYP box.
- * @param p_manager the user event manager.
- *
- * @return true if the FTYP box is valid.
- */
-static OPJ_BOOL opj_jp2_read_ftyp(opj_jp2_t *jp2,
- OPJ_BYTE * p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager
- )
-{
- OPJ_UINT32 i, l_remaining_bytes;
-
- /* preconditions */
- assert(p_header_data != 00);
- assert(jp2 != 00);
- assert(p_manager != 00);
-
- if (jp2->jp2_state != JP2_STATE_SIGNATURE) {
- opj_event_msg(p_manager, EVT_ERROR,
- "The ftyp box must be the second box in the file.\n");
- return OPJ_FALSE;
- }
-
- /* assure length of data is correct */
- if (p_header_size < 8) {
- opj_event_msg(p_manager, EVT_ERROR, "Error with FTYP signature Box size\n");
- return OPJ_FALSE;
- }
-
- opj_read_bytes(p_header_data, &jp2->brand, 4); /* BR */
- p_header_data += 4;
-
- opj_read_bytes(p_header_data, &jp2->minversion, 4); /* MinV */
- p_header_data += 4;
-
- l_remaining_bytes = p_header_size - 8;
-
- /* the number of remaining bytes should be a multiple of 4 */
- if ((l_remaining_bytes & 0x3) != 0) {
- opj_event_msg(p_manager, EVT_ERROR, "Error with FTYP signature Box size\n");
- return OPJ_FALSE;
- }
-
- /* div by 4 */
- jp2->numcl = l_remaining_bytes >> 2;
- if (jp2->numcl) {
- jp2->cl = (OPJ_UINT32 *) opj_calloc(jp2->numcl, sizeof(OPJ_UINT32));
- if (jp2->cl == 00) {
- opj_event_msg(p_manager, EVT_ERROR, "Not enough memory with FTYP Box\n");
- return OPJ_FALSE;
- }
- }
-
- for (i = 0; i < jp2->numcl; ++i) {
- opj_read_bytes(p_header_data, &jp2->cl[i], 4); /* CLi */
- p_header_data += 4;
- }
-
- jp2->jp2_state |= JP2_STATE_FILE_TYPE;
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_jp2_skip_jp2c(opj_jp2_t *jp2,
- opj_stream_private_t *stream,
- opj_event_mgr_t * p_manager)
-{
- /* preconditions */
- assert(jp2 != 00);
- assert(stream != 00);
- assert(p_manager != 00);
-
- jp2->j2k_codestream_offset = opj_stream_tell(stream);
-
- if (opj_stream_skip(stream, 8, p_manager) != 8) {
- return OPJ_FALSE;
- }
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_jpip_skip_iptr(opj_jp2_t *jp2,
- opj_stream_private_t *stream,
- opj_event_mgr_t * p_manager)
-{
- /* preconditions */
- assert(jp2 != 00);
- assert(stream != 00);
- assert(p_manager != 00);
-
- jp2->jpip_iptr_offset = opj_stream_tell(stream);
-
- if (opj_stream_skip(stream, 24, p_manager) != 24) {
- return OPJ_FALSE;
- }
-
- return OPJ_TRUE;
-}
-
-/**
- * Reads the Jpeg2000 file Header box - JP2 Header box (warning, this is a super box).
- *
- * @param p_header_data the data contained in the file header box.
- * @param jp2 the jpeg2000 file codec.
- * @param p_header_size the size of the data contained in the file header box.
- * @param p_manager the user event manager.
- *
- * @return true if the JP2 Header box was successfully recognized.
-*/
-static OPJ_BOOL opj_jp2_read_jp2h(opj_jp2_t *jp2,
- OPJ_BYTE *p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager
- )
-{
- OPJ_UINT32 l_box_size = 0, l_current_data_size = 0;
- opj_jp2_box_t box;
- const opj_jp2_header_handler_t * l_current_handler;
- OPJ_BOOL l_has_ihdr = 0;
-
- /* preconditions */
- assert(p_header_data != 00);
- assert(jp2 != 00);
- assert(p_manager != 00);
-
- /* make sure the box is well placed */
- if ((jp2->jp2_state & JP2_STATE_FILE_TYPE) != JP2_STATE_FILE_TYPE) {
- opj_event_msg(p_manager, EVT_ERROR,
- "The box must be the first box in the file.\n");
- return OPJ_FALSE;
- }
-
- jp2->jp2_img_state = JP2_IMG_STATE_NONE;
-
- /* iterate while remaining data */
- while (p_header_size > 0) {
-
- if (! opj_jp2_read_boxhdr_char(&box, p_header_data, &l_box_size, p_header_size,
- p_manager)) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Stream error while reading JP2 Header box\n");
- return OPJ_FALSE;
- }
-
- if (box.length > p_header_size) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Stream error while reading JP2 Header box: box length is inconsistent.\n");
- return OPJ_FALSE;
- }
-
- l_current_handler = opj_jp2_img_find_handler(box.type);
- l_current_data_size = box.length - l_box_size;
- p_header_data += l_box_size;
-
- if (l_current_handler != 00) {
- if (! l_current_handler->handler(jp2, p_header_data, l_current_data_size,
- p_manager)) {
- return OPJ_FALSE;
- }
- } else {
- jp2->jp2_img_state |= JP2_IMG_STATE_UNKNOWN;
- }
-
- if (box.type == JP2_IHDR) {
- l_has_ihdr = 1;
- }
-
- p_header_data += l_current_data_size;
- p_header_size -= box.length;
- }
-
- if (l_has_ihdr == 0) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Stream error while reading JP2 Header box: no 'ihdr' box.\n");
- return OPJ_FALSE;
- }
-
- jp2->jp2_state |= JP2_STATE_HEADER;
- jp2->has_jp2h = 1;
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_jp2_read_boxhdr_char(opj_jp2_box_t *box,
- OPJ_BYTE * p_data,
- OPJ_UINT32 * p_number_bytes_read,
- OPJ_UINT32 p_box_max_size,
- opj_event_mgr_t * p_manager
- )
-{
- OPJ_UINT32 l_value;
-
- /* preconditions */
- assert(p_data != 00);
- assert(box != 00);
- assert(p_number_bytes_read != 00);
- assert(p_manager != 00);
-
- if (p_box_max_size < 8) {
- opj_event_msg(p_manager, EVT_ERROR, "Cannot handle box of less than 8 bytes\n");
- return OPJ_FALSE;
- }
-
- /* process read data */
- opj_read_bytes(p_data, &l_value, 4);
- p_data += 4;
- box->length = (OPJ_UINT32)(l_value);
-
- opj_read_bytes(p_data, &l_value, 4);
- p_data += 4;
- box->type = (OPJ_UINT32)(l_value);
-
- *p_number_bytes_read = 8;
-
- /* do we have a "special very large box ?" */
- /* read then the XLBox */
- if (box->length == 1) {
- OPJ_UINT32 l_xl_part_size;
-
- if (p_box_max_size < 16) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Cannot handle XL box of less than 16 bytes\n");
- return OPJ_FALSE;
- }
-
- opj_read_bytes(p_data, &l_xl_part_size, 4);
- p_data += 4;
- *p_number_bytes_read += 4;
-
- if (l_xl_part_size != 0) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Cannot handle box sizes higher than 2^32\n");
- return OPJ_FALSE;
- }
-
- opj_read_bytes(p_data, &l_value, 4);
- *p_number_bytes_read += 4;
- box->length = (OPJ_UINT32)(l_value);
-
- if (box->length == 0) {
- opj_event_msg(p_manager, EVT_ERROR, "Cannot handle box of undefined sizes\n");
- return OPJ_FALSE;
- }
- } else if (box->length == 0) {
- opj_event_msg(p_manager, EVT_ERROR, "Cannot handle box of undefined sizes\n");
- return OPJ_FALSE;
- }
- if (box->length < *p_number_bytes_read) {
- opj_event_msg(p_manager, EVT_ERROR, "Box length is inconsistent.\n");
- return OPJ_FALSE;
- }
- return OPJ_TRUE;
-}
-
-OPJ_BOOL opj_jp2_read_header(opj_stream_private_t *p_stream,
- opj_jp2_t *jp2,
- opj_image_t ** p_image,
- opj_event_mgr_t * p_manager
- )
-{
- int ret;
-
- /* preconditions */
- assert(jp2 != 00);
- assert(p_stream != 00);
- assert(p_manager != 00);
-
- /* customization of the validation */
- if (! opj_jp2_setup_decoding_validation(jp2, p_manager)) {
- return OPJ_FALSE;
- }
-
- /* customization of the encoding */
- if (! opj_jp2_setup_header_reading(jp2, p_manager)) {
- return OPJ_FALSE;
- }
-
- /* validation of the parameters codec */
- if (! opj_jp2_exec(jp2, jp2->m_validation_list, p_stream, p_manager)) {
- return OPJ_FALSE;
- }
-
- /* read header */
- if (! opj_jp2_exec(jp2, jp2->m_procedure_list, p_stream, p_manager)) {
- return OPJ_FALSE;
- }
- if (jp2->has_jp2h == 0) {
- opj_event_msg(p_manager, EVT_ERROR, "JP2H box missing. Required.\n");
- return OPJ_FALSE;
- }
- if (jp2->has_ihdr == 0) {
- opj_event_msg(p_manager, EVT_ERROR, "IHDR box_missing. Required.\n");
- return OPJ_FALSE;
- }
-
- ret = opj_j2k_read_header(p_stream,
- jp2->j2k,
- p_image,
- p_manager);
-
- if (p_image && *p_image) {
- /* Set Image Color Space */
- if (jp2->enumcs == 16) {
- (*p_image)->color_space = OPJ_CLRSPC_SRGB;
- } else if (jp2->enumcs == 17) {
- (*p_image)->color_space = OPJ_CLRSPC_GRAY;
- } else if (jp2->enumcs == 18) {
- (*p_image)->color_space = OPJ_CLRSPC_SYCC;
- } else if (jp2->enumcs == 24) {
- (*p_image)->color_space = OPJ_CLRSPC_EYCC;
- } else if (jp2->enumcs == 12) {
- (*p_image)->color_space = OPJ_CLRSPC_CMYK;
- } else {
- (*p_image)->color_space = OPJ_CLRSPC_UNKNOWN;
- }
-
- if (jp2->color.icc_profile_buf) {
- (*p_image)->icc_profile_buf = jp2->color.icc_profile_buf;
- (*p_image)->icc_profile_len = jp2->color.icc_profile_len;
- jp2->color.icc_profile_buf = NULL;
- }
- }
- return ret;
-}
-
-static OPJ_BOOL opj_jp2_setup_encoding_validation(opj_jp2_t *jp2,
- opj_event_mgr_t * p_manager)
-{
- /* preconditions */
- assert(jp2 != 00);
- assert(p_manager != 00);
-
- if (! opj_procedure_list_add_procedure(jp2->m_validation_list,
- (opj_procedure)opj_jp2_default_validation, p_manager)) {
- return OPJ_FALSE;
- }
- /* DEVELOPER CORNER, add your custom validation procedure */
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_jp2_setup_decoding_validation(opj_jp2_t *jp2,
- opj_event_mgr_t * p_manager)
-{
- /* preconditions */
- assert(jp2 != 00);
- assert(p_manager != 00);
-
- OPJ_UNUSED(jp2);
- OPJ_UNUSED(p_manager);
-
- /* DEVELOPER CORNER, add your custom validation procedure */
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_jp2_setup_header_writing(opj_jp2_t *jp2,
- opj_event_mgr_t * p_manager)
-{
- /* preconditions */
- assert(jp2 != 00);
- assert(p_manager != 00);
-
- if (! opj_procedure_list_add_procedure(jp2->m_procedure_list,
- (opj_procedure)opj_jp2_write_jp, p_manager)) {
- return OPJ_FALSE;
- }
- if (! opj_procedure_list_add_procedure(jp2->m_procedure_list,
- (opj_procedure)opj_jp2_write_ftyp, p_manager)) {
- return OPJ_FALSE;
- }
- if (! opj_procedure_list_add_procedure(jp2->m_procedure_list,
- (opj_procedure)opj_jp2_write_jp2h, p_manager)) {
- return OPJ_FALSE;
- }
- if (jp2->jpip_on) {
- if (! opj_procedure_list_add_procedure(jp2->m_procedure_list,
- (opj_procedure)opj_jpip_skip_iptr, p_manager)) {
- return OPJ_FALSE;
- }
- }
- if (! opj_procedure_list_add_procedure(jp2->m_procedure_list,
- (opj_procedure)opj_jp2_skip_jp2c, p_manager)) {
- return OPJ_FALSE;
- }
-
- /* DEVELOPER CORNER, insert your custom procedures */
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_jp2_setup_header_reading(opj_jp2_t *jp2,
- opj_event_mgr_t * p_manager)
-{
- /* preconditions */
- assert(jp2 != 00);
- assert(p_manager != 00);
-
- if (! opj_procedure_list_add_procedure(jp2->m_procedure_list,
- (opj_procedure)opj_jp2_read_header_procedure, p_manager)) {
- return OPJ_FALSE;
- }
-
- /* DEVELOPER CORNER, add your custom procedures */
-
- return OPJ_TRUE;
-}
-
-OPJ_BOOL opj_jp2_read_tile_header(opj_jp2_t * p_jp2,
- OPJ_UINT32 * p_tile_index,
- OPJ_UINT32 * p_data_size,
- OPJ_INT32 * p_tile_x0,
- OPJ_INT32 * p_tile_y0,
- OPJ_INT32 * p_tile_x1,
- OPJ_INT32 * p_tile_y1,
- OPJ_UINT32 * p_nb_comps,
- OPJ_BOOL * p_go_on,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager
- )
-{
- return opj_j2k_read_tile_header(p_jp2->j2k,
- p_tile_index,
- p_data_size,
- p_tile_x0, p_tile_y0,
- p_tile_x1, p_tile_y1,
- p_nb_comps,
- p_go_on,
- p_stream,
- p_manager);
-}
-
-OPJ_BOOL opj_jp2_write_tile(opj_jp2_t *p_jp2,
- OPJ_UINT32 p_tile_index,
- OPJ_BYTE * p_data,
- OPJ_UINT32 p_data_size,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager
- )
-
-{
- return opj_j2k_write_tile(p_jp2->j2k, p_tile_index, p_data, p_data_size,
- p_stream, p_manager);
-}
-
-OPJ_BOOL opj_jp2_decode_tile(opj_jp2_t * p_jp2,
- OPJ_UINT32 p_tile_index,
- OPJ_BYTE * p_data,
- OPJ_UINT32 p_data_size,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager
- )
-{
- return opj_j2k_decode_tile(p_jp2->j2k, p_tile_index, p_data, p_data_size,
- p_stream, p_manager);
-}
-
-void opj_jp2_destroy(opj_jp2_t *jp2)
-{
- if (jp2) {
- /* destroy the J2K codec */
- opj_j2k_destroy(jp2->j2k);
- jp2->j2k = 00;
-
- if (jp2->comps) {
- opj_free(jp2->comps);
- jp2->comps = 00;
- }
-
- if (jp2->cl) {
- opj_free(jp2->cl);
- jp2->cl = 00;
- }
-
- if (jp2->color.icc_profile_buf) {
- opj_free(jp2->color.icc_profile_buf);
- jp2->color.icc_profile_buf = 00;
- }
-
- if (jp2->color.jp2_cdef) {
- if (jp2->color.jp2_cdef->info) {
- opj_free(jp2->color.jp2_cdef->info);
- jp2->color.jp2_cdef->info = NULL;
- }
-
- opj_free(jp2->color.jp2_cdef);
- jp2->color.jp2_cdef = 00;
- }
-
- if (jp2->color.jp2_pclr) {
- if (jp2->color.jp2_pclr->cmap) {
- opj_free(jp2->color.jp2_pclr->cmap);
- jp2->color.jp2_pclr->cmap = NULL;
- }
- if (jp2->color.jp2_pclr->channel_sign) {
- opj_free(jp2->color.jp2_pclr->channel_sign);
- jp2->color.jp2_pclr->channel_sign = NULL;
- }
- if (jp2->color.jp2_pclr->channel_size) {
- opj_free(jp2->color.jp2_pclr->channel_size);
- jp2->color.jp2_pclr->channel_size = NULL;
- }
- if (jp2->color.jp2_pclr->entries) {
- opj_free(jp2->color.jp2_pclr->entries);
- jp2->color.jp2_pclr->entries = NULL;
- }
-
- opj_free(jp2->color.jp2_pclr);
- jp2->color.jp2_pclr = 00;
- }
-
- if (jp2->m_validation_list) {
- opj_procedure_list_destroy(jp2->m_validation_list);
- jp2->m_validation_list = 00;
- }
-
- if (jp2->m_procedure_list) {
- opj_procedure_list_destroy(jp2->m_procedure_list);
- jp2->m_procedure_list = 00;
- }
-
- opj_free(jp2);
- }
-}
-
-OPJ_BOOL opj_jp2_set_decoded_components(opj_jp2_t *p_jp2,
- OPJ_UINT32 numcomps,
- const OPJ_UINT32* comps_indices,
- opj_event_mgr_t * p_manager)
-{
- return opj_j2k_set_decoded_components(p_jp2->j2k,
- numcomps, comps_indices,
- p_manager);
-}
-
-OPJ_BOOL opj_jp2_set_decode_area(opj_jp2_t *p_jp2,
- opj_image_t* p_image,
- OPJ_INT32 p_start_x, OPJ_INT32 p_start_y,
- OPJ_INT32 p_end_x, OPJ_INT32 p_end_y,
- opj_event_mgr_t * p_manager
- )
-{
- return opj_j2k_set_decode_area(p_jp2->j2k, p_image, p_start_x, p_start_y,
- p_end_x, p_end_y, p_manager);
-}
-
-OPJ_BOOL opj_jp2_get_tile(opj_jp2_t *p_jp2,
- opj_stream_private_t *p_stream,
- opj_image_t* p_image,
- opj_event_mgr_t * p_manager,
- OPJ_UINT32 tile_index
- )
-{
- if (!p_image) {
- return OPJ_FALSE;
- }
-
- opj_event_msg(p_manager, EVT_WARNING,
- "JP2 box which are after the codestream will not be read by this function.\n");
-
- if (! opj_j2k_get_tile(p_jp2->j2k, p_stream, p_image, p_manager, tile_index)) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Failed to decode the codestream in the JP2 file\n");
- return OPJ_FALSE;
- }
-
- return opj_jp2_apply_color_postprocessing(p_jp2, p_image, p_manager);
-}
-
-/* ----------------------------------------------------------------------- */
-/* JP2 encoder interface */
-/* ----------------------------------------------------------------------- */
-
-opj_jp2_t* opj_jp2_create(OPJ_BOOL p_is_decoder)
-{
- opj_jp2_t *jp2 = (opj_jp2_t*)opj_calloc(1, sizeof(opj_jp2_t));
- if (jp2) {
-
- /* create the J2K codec */
- if (! p_is_decoder) {
- jp2->j2k = opj_j2k_create_compress();
- } else {
- jp2->j2k = opj_j2k_create_decompress();
- }
-
- if (jp2->j2k == 00) {
- opj_jp2_destroy(jp2);
- return 00;
- }
-
- /* Color structure */
- jp2->color.icc_profile_buf = NULL;
- jp2->color.icc_profile_len = 0;
- jp2->color.jp2_cdef = NULL;
- jp2->color.jp2_pclr = NULL;
- jp2->color.jp2_has_colr = 0;
-
- /* validation list creation */
- jp2->m_validation_list = opj_procedure_list_create();
- if (! jp2->m_validation_list) {
- opj_jp2_destroy(jp2);
- return 00;
- }
-
- /* execution list creation */
- jp2->m_procedure_list = opj_procedure_list_create();
- if (! jp2->m_procedure_list) {
- opj_jp2_destroy(jp2);
- return 00;
- }
- }
-
- return jp2;
-}
-
-void jp2_dump(opj_jp2_t* p_jp2, OPJ_INT32 flag, FILE* out_stream)
-{
- /* preconditions */
- assert(p_jp2 != 00);
-
- j2k_dump(p_jp2->j2k,
- flag,
- out_stream);
-}
-
-opj_codestream_index_t* jp2_get_cstr_index(opj_jp2_t* p_jp2)
-{
- return j2k_get_cstr_index(p_jp2->j2k);
-}
-
-opj_codestream_info_v2_t* jp2_get_cstr_info(opj_jp2_t* p_jp2)
-{
- return j2k_get_cstr_info(p_jp2->j2k);
-}
-
-OPJ_BOOL opj_jp2_set_decoded_resolution_factor(opj_jp2_t *p_jp2,
- OPJ_UINT32 res_factor,
- opj_event_mgr_t * p_manager)
-{
- return opj_j2k_set_decoded_resolution_factor(p_jp2->j2k, res_factor, p_manager);
-}
-
-/* ----------------------------------------------------------------------- */
-
-OPJ_BOOL opj_jp2_encoder_set_extra_options(
- opj_jp2_t *p_jp2,
- const char* const* p_options,
- opj_event_mgr_t * p_manager)
-{
- return opj_j2k_encoder_set_extra_options(p_jp2->j2k, p_options, p_manager);
-}
-
-/* ----------------------------------------------------------------------- */
-
-/* JPIP specific */
-
-#ifdef USE_JPIP
-static OPJ_BOOL opj_jpip_write_iptr(opj_jp2_t *jp2,
- opj_stream_private_t *cio,
- opj_event_mgr_t * p_manager)
-{
- OPJ_OFF_T j2k_codestream_exit;
- OPJ_BYTE l_data_header [24];
-
- /* preconditions */
- assert(jp2 != 00);
- assert(cio != 00);
- assert(p_manager != 00);
- assert(opj_stream_has_seek(cio));
-
- j2k_codestream_exit = opj_stream_tell(cio);
- opj_write_bytes(l_data_header, 24, 4); /* size of iptr */
- opj_write_bytes(l_data_header + 4, JPIP_IPTR,
- 4); /* IPTR */
-#if 0
- opj_write_bytes(l_data_header + 4 + 4, 0, 8); /* offset */
- opj_write_bytes(l_data_header + 8 + 8, 0, 8); /* length */
-#else
- opj_write_double(l_data_header + 4 + 4, 0); /* offset */
- opj_write_double(l_data_header + 8 + 8, 0); /* length */
-#endif
-
- if (! opj_stream_seek(cio, jp2->jpip_iptr_offset, p_manager)) {
- opj_event_msg(p_manager, EVT_ERROR, "Failed to seek in the stream.\n");
- return OPJ_FALSE;
- }
-
- if (opj_stream_write_data(cio, l_data_header, 24, p_manager) != 24) {
- opj_event_msg(p_manager, EVT_ERROR, "Failed to seek in the stream.\n");
- return OPJ_FALSE;
- }
-
- if (! opj_stream_seek(cio, j2k_codestream_exit, p_manager)) {
- opj_event_msg(p_manager, EVT_ERROR, "Failed to seek in the stream.\n");
- return OPJ_FALSE;
- }
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_jpip_write_fidx(opj_jp2_t *jp2,
- opj_stream_private_t *cio,
- opj_event_mgr_t * p_manager)
-{
- OPJ_OFF_T j2k_codestream_exit;
- OPJ_BYTE l_data_header [24];
-
- OPJ_UNUSED(jp2);
-
- /* preconditions */
- assert(jp2 != 00);
- assert(cio != 00);
- assert(p_manager != 00);
- assert(opj_stream_has_seek(cio));
-
- opj_write_bytes(l_data_header, 24, 4); /* size of iptr */
- opj_write_bytes(l_data_header + 4, JPIP_FIDX,
- 4); /* IPTR */
- opj_write_double(l_data_header + 4 + 4, 0); /* offset */
- opj_write_double(l_data_header + 8 + 8, 0); /* length */
-
- if (opj_stream_write_data(cio, l_data_header, 24, p_manager) != 24) {
- opj_event_msg(p_manager, EVT_ERROR, "Failed to seek in the stream.\n");
- return OPJ_FALSE;
- }
-
- j2k_codestream_exit = opj_stream_tell(cio);
- if (! opj_stream_seek(cio, j2k_codestream_exit, p_manager)) {
- opj_event_msg(p_manager, EVT_ERROR, "Failed to seek in the stream.\n");
- return OPJ_FALSE;
- }
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_jpip_write_cidx(opj_jp2_t *jp2,
- opj_stream_private_t *cio,
- opj_event_mgr_t * p_manager)
-{
- OPJ_OFF_T j2k_codestream_exit;
- OPJ_BYTE l_data_header [24];
-
- OPJ_UNUSED(jp2);
-
- /* preconditions */
- assert(jp2 != 00);
- assert(cio != 00);
- assert(p_manager != 00);
- assert(opj_stream_has_seek(cio));
-
- j2k_codestream_exit = opj_stream_tell(cio);
- opj_write_bytes(l_data_header, 24, 4); /* size of iptr */
- opj_write_bytes(l_data_header + 4, JPIP_CIDX,
- 4); /* IPTR */
-#if 0
- opj_write_bytes(l_data_header + 4 + 4, 0, 8); /* offset */
- opj_write_bytes(l_data_header + 8 + 8, 0, 8); /* length */
-#else
- opj_write_double(l_data_header + 4 + 4, 0); /* offset */
- opj_write_double(l_data_header + 8 + 8, 0); /* length */
-#endif
-
- if (! opj_stream_seek(cio, j2k_codestream_exit, p_manager)) {
- opj_event_msg(p_manager, EVT_ERROR, "Failed to seek in the stream.\n");
- return OPJ_FALSE;
- }
-
- if (opj_stream_write_data(cio, l_data_header, 24, p_manager) != 24) {
- opj_event_msg(p_manager, EVT_ERROR, "Failed to seek in the stream.\n");
- return OPJ_FALSE;
- }
-
- j2k_codestream_exit = opj_stream_tell(cio);
- if (! opj_stream_seek(cio, j2k_codestream_exit, p_manager)) {
- opj_event_msg(p_manager, EVT_ERROR, "Failed to seek in the stream.\n");
- return OPJ_FALSE;
- }
-
- return OPJ_TRUE;
-}
-
-#if 0
-static void write_prxy(int offset_jp2c, int length_jp2c, int offset_idx,
- int length_idx, opj_stream_private_t *cio,
- opj_event_mgr_t * p_manager)
-{
- OPJ_BYTE l_data_header [8];
- OPJ_OFF_T len, lenp;
-
- lenp = opj_stream_tell(cio);
- opj_stream_skip(cio, 4, p_manager); /* L [at the end] */
- opj_write_bytes(l_data_header, JPIP_PRXY, 4); /* IPTR */
- opj_stream_write_data(cio, l_data_header, 4, p_manager);
-
- opj_write_bytes(l_data_header, offset_jp2c, 8); /* OOFF */
- opj_stream_write_data(cio, l_data_header, 8, p_manager);
- opj_write_bytes(l_data_header, length_jp2c, 4); /* OBH part 1 */
- opj_write_bytes(l_data_header + 4, JP2_JP2C, 4); /* OBH part 2 */
- opj_stream_write_data(cio, l_data_header, 8, p_manager);
-
- opj_write_bytes(l_data_header, 1, 1); /* NI */
- opj_stream_write_data(cio, l_data_header, 1, p_manager);
-
- opj_write_bytes(l_data_header, offset_idx, 8); /* IOFF */
- opj_stream_write_data(cio, l_data_header, 8, p_manager);
- opj_write_bytes(l_data_header, length_idx, 4); /* IBH part 1 */
- opj_write_bytes(l_data_header + 4, JPIP_CIDX, 4); /* IBH part 2 */
- opj_stream_write_data(cio, l_data_header, 8, p_manager);
-
- len = opj_stream_tell(cio) - lenp;
- opj_stream_skip(cio, lenp, p_manager);
- opj_write_bytes(l_data_header, len, 4); /* L */
- opj_stream_write_data(cio, l_data_header, 4, p_manager);
- opj_stream_seek(cio, lenp + len, p_manager);
-}
-#endif
-
-
-#if 0
-static int write_fidx(int offset_jp2c, int length_jp2c, int offset_idx,
- int length_idx, opj_stream_private_t *cio,
- opj_event_mgr_t * p_manager)
-{
- OPJ_BYTE l_data_header [4];
- OPJ_OFF_T len, lenp;
-
- lenp = opj_stream_tell(cio);
- opj_stream_skip(cio, 4, p_manager);
- opj_write_bytes(l_data_header, JPIP_FIDX, 4); /* FIDX */
- opj_stream_write_data(cio, l_data_header, 4, p_manager);
-
- write_prxy(offset_jp2c, length_jp2c, offset_idx, length_idx, cio, p_manager);
-
- len = opj_stream_tell(cio) - lenp;
- opj_stream_skip(cio, lenp, p_manager);
- opj_write_bytes(l_data_header, len, 4); /* L */
- opj_stream_write_data(cio, l_data_header, 4, p_manager);
- opj_stream_seek(cio, lenp + len, p_manager);
-
- return len;
-}
-#endif
-#endif /* USE_JPIP */
diff --git a/contrib/libs/openjpeg/jp2.h b/contrib/libs/openjpeg/jp2.h
deleted file mode 100644
index 173f25119b..0000000000
--- a/contrib/libs/openjpeg/jp2.h
+++ /dev/null
@@ -1,521 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2014, Professor Benoit Macq
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR
- * Copyright (c) 2012, CS Systemes d'Information, France
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef OPJ_JP2_H
-#define OPJ_JP2_H
-/**
-@file jp2.h
-@brief The JPEG-2000 file format Reader/Writer (JP2)
-
-*/
-
-/** @defgroup JP2 JP2 - JPEG-2000 file format reader/writer */
-/*@{*/
-
-/*#define JPIP_JPIP 0x6a706970*/
-
-#define JP2_JP 0x6a502020 /**< JPEG 2000 signature box */
-#define JP2_FTYP 0x66747970 /**< File type box */
-#define JP2_JP2H 0x6a703268 /**< JP2 header box (super-box) */
-#define JP2_IHDR 0x69686472 /**< Image header box */
-#define JP2_COLR 0x636f6c72 /**< Colour specification box */
-#define JP2_JP2C 0x6a703263 /**< Contiguous codestream box */
-#define JP2_URL 0x75726c20 /**< Data entry URL box */
-#define JP2_PCLR 0x70636c72 /**< Palette box */
-#define JP2_CMAP 0x636d6170 /**< Component Mapping box */
-#define JP2_CDEF 0x63646566 /**< Channel Definition box */
-#define JP2_DTBL 0x6474626c /**< Data Reference box */
-#define JP2_BPCC 0x62706363 /**< Bits per component box */
-#define JP2_JP2 0x6a703220 /**< File type fields */
-
-/* For the future */
-/* #define JP2_RES 0x72657320 */ /**< Resolution box (super-box) */
-/* #define JP2_JP2I 0x6a703269 */ /**< Intellectual property box */
-/* #define JP2_XML 0x786d6c20 */ /**< XML box */
-/* #define JP2_UUID 0x75756994 */ /**< UUID box */
-/* #define JP2_UINF 0x75696e66 */ /**< UUID info box (super-box) */
-/* #define JP2_ULST 0x756c7374 */ /**< UUID list box */
-
-/* ----------------------------------------------------------------------- */
-
-typedef enum {
- JP2_STATE_NONE = 0x0,
- JP2_STATE_SIGNATURE = 0x1,
- JP2_STATE_FILE_TYPE = 0x2,
- JP2_STATE_HEADER = 0x4,
- JP2_STATE_CODESTREAM = 0x8,
- JP2_STATE_END_CODESTREAM = 0x10,
- JP2_STATE_UNKNOWN = 0x7fffffff /* ISO C restricts enumerator values to range of 'int' */
-}
-JP2_STATE;
-
-typedef enum {
- JP2_IMG_STATE_NONE = 0x0,
- JP2_IMG_STATE_UNKNOWN = 0x7fffffff
-}
-JP2_IMG_STATE;
-
-/**
-Channel description: channel index, type, association
-*/
-typedef struct opj_jp2_cdef_info {
- OPJ_UINT16 cn, typ, asoc;
-} opj_jp2_cdef_info_t;
-
-/**
-Channel descriptions and number of descriptions
-*/
-typedef struct opj_jp2_cdef {
- opj_jp2_cdef_info_t *info;
- OPJ_UINT16 n;
-} opj_jp2_cdef_t;
-
-/**
-Component mappings: channel index, mapping type, palette index
-*/
-typedef struct opj_jp2_cmap_comp {
- OPJ_UINT16 cmp;
- OPJ_BYTE mtyp, pcol;
-} opj_jp2_cmap_comp_t;
-
-/**
-Palette data: table entries, palette columns
-*/
-typedef struct opj_jp2_pclr {
- OPJ_UINT32 *entries;
- OPJ_BYTE *channel_sign;
- OPJ_BYTE *channel_size;
- opj_jp2_cmap_comp_t *cmap;
- OPJ_UINT16 nr_entries;
- OPJ_BYTE nr_channels;
-} opj_jp2_pclr_t;
-
-/**
-Collector for ICC profile, palette, component mapping, channel description
-*/
-typedef struct opj_jp2_color {
- OPJ_BYTE *icc_profile_buf;
- OPJ_UINT32 icc_profile_len;
-
- opj_jp2_cdef_t *jp2_cdef;
- opj_jp2_pclr_t *jp2_pclr;
- OPJ_BYTE jp2_has_colr;
-} opj_jp2_color_t;
-
-/**
-JP2 component
-*/
-typedef struct opj_jp2_comps {
- OPJ_UINT32 depth;
- OPJ_UINT32 sgnd;
- OPJ_UINT32 bpcc;
-} opj_jp2_comps_t;
-
-/**
-JPEG-2000 file format reader/writer
-*/
-typedef struct opj_jp2 {
- /** handle to the J2K codec */
- opj_j2k_t *j2k;
- /** list of validation procedures */
- struct opj_procedure_list * m_validation_list;
- /** list of execution procedures */
- struct opj_procedure_list * m_procedure_list;
-
- /* width of image */
- OPJ_UINT32 w;
- /* height of image */
- OPJ_UINT32 h;
- /* number of components in the image */
- OPJ_UINT32 numcomps;
- OPJ_UINT32 bpc;
- OPJ_UINT32 C;
- OPJ_UINT32 UnkC;
- OPJ_UINT32 IPR;
- OPJ_UINT32 meth;
- OPJ_UINT32 approx;
- OPJ_UINT32 enumcs;
- OPJ_UINT32 precedence;
- OPJ_UINT32 brand;
- OPJ_UINT32 minversion;
- OPJ_UINT32 numcl;
- OPJ_UINT32 *cl;
- opj_jp2_comps_t *comps;
- /* FIXME: The following two variables are used to save offset
- as we write out a JP2 file to disk. This mechanism is not flexible
- as codec writers will need to extand those fields as new part
- of the standard are implemented.
- */
- OPJ_OFF_T j2k_codestream_offset;
- OPJ_OFF_T jpip_iptr_offset;
- OPJ_BOOL jpip_on;
- OPJ_UINT32 jp2_state;
- OPJ_UINT32 jp2_img_state;
-
- opj_jp2_color_t color;
-
- OPJ_BOOL ignore_pclr_cmap_cdef;
- OPJ_BYTE has_jp2h;
- OPJ_BYTE has_ihdr;
-}
-opj_jp2_t;
-
-/**
-JP2 Box
-*/
-typedef struct opj_jp2_box {
- OPJ_UINT32 length;
- OPJ_UINT32 type;
- OPJ_INT32 init_pos;
-} opj_jp2_box_t;
-
-typedef struct opj_jp2_header_handler {
- /* marker value */
- OPJ_UINT32 id;
- /* action linked to the marker */
- OPJ_BOOL(*handler)(opj_jp2_t *jp2,
- OPJ_BYTE *p_header_data,
- OPJ_UINT32 p_header_size,
- opj_event_mgr_t * p_manager);
-}
-opj_jp2_header_handler_t;
-
-
-typedef struct opj_jp2_img_header_writer_handler {
- /* action to perform */
- OPJ_BYTE* (*handler)(opj_jp2_t *jp2, OPJ_UINT32 * p_data_size);
- /* result of the action : data */
- OPJ_BYTE* m_data;
- /* size of data */
- OPJ_UINT32 m_size;
-}
-opj_jp2_img_header_writer_handler_t;
-
-/** @name Exported functions */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-
-/**
-Setup the decoder decoding parameters using user parameters.
-Decoding parameters are returned in jp2->j2k->cp.
-@param jp2 JP2 decompressor handle
-@param parameters decompression parameters
-*/
-void opj_jp2_setup_decoder(opj_jp2_t *jp2, opj_dparameters_t *parameters);
-
-/**
-Set the strict mode parameter. When strict mode is enabled, the entire
-bitstream must be decoded or an error is returned. When it is disabled,
-the decoder will decode partial bitstreams.
-@param jp2 JP2 decompressor handle
-@param strict OPJ_TRUE for strict mode
-*/
-void opj_jp2_decoder_set_strict_mode(opj_jp2_t *jp2, OPJ_BOOL strict);
-
-/** Allocates worker threads for the compressor/decompressor.
- *
- * @param jp2 JP2 decompressor handle
- * @param num_threads Number of threads.
- * @return OPJ_TRUE in case of success.
- */
-OPJ_BOOL opj_jp2_set_threads(opj_jp2_t *jp2, OPJ_UINT32 num_threads);
-
-/**
- * Decode an image from a JPEG-2000 file stream
- * @param jp2 JP2 decompressor handle
- * @param p_stream FIXME DOC
- * @param p_image FIXME DOC
- * @param p_manager FIXME DOC
- *
- * @return Returns a decoded image if successful, returns NULL otherwise
-*/
-OPJ_BOOL opj_jp2_decode(opj_jp2_t *jp2,
- opj_stream_private_t *p_stream,
- opj_image_t* p_image,
- opj_event_mgr_t * p_manager);
-
-/**
- * Setup the encoder parameters using the current image and using user parameters.
- * Coding parameters are returned in jp2->j2k->cp.
- *
- * @param jp2 JP2 compressor handle
- * @param parameters compression parameters
- * @param image input filled image
- * @param p_manager FIXME DOC
- * @return OPJ_TRUE if successful, OPJ_FALSE otherwise
-*/
-OPJ_BOOL opj_jp2_setup_encoder(opj_jp2_t *jp2,
- opj_cparameters_t *parameters,
- opj_image_t *image,
- opj_event_mgr_t * p_manager);
-
-/**
-Encode an image into a JPEG-2000 file stream
-@param jp2 JP2 compressor handle
-@param stream Output buffer stream
-@param p_manager event manager
-@return Returns true if successful, returns false otherwise
-*/
-OPJ_BOOL opj_jp2_encode(opj_jp2_t *jp2,
- opj_stream_private_t *stream,
- opj_event_mgr_t * p_manager);
-
-
-/**
- * Starts a compression scheme, i.e. validates the codec parameters, writes the header.
- *
- * @param jp2 the jpeg2000 file codec.
- * @param stream the stream object.
- * @param p_image FIXME DOC
- * @param p_manager FIXME DOC
- *
- * @return true if the codec is valid.
- */
-OPJ_BOOL opj_jp2_start_compress(opj_jp2_t *jp2,
- opj_stream_private_t *stream,
- opj_image_t * p_image,
- opj_event_mgr_t * p_manager);
-
-
-/**
- * Ends the compression procedures and possibiliy add data to be read after the
- * codestream.
- */
-OPJ_BOOL opj_jp2_end_compress(opj_jp2_t *jp2,
- opj_stream_private_t *cio,
- opj_event_mgr_t * p_manager);
-
-/* ----------------------------------------------------------------------- */
-
-/**
- * Ends the decompression procedures and possibiliy add data to be read after the
- * codestream.
- */
-OPJ_BOOL opj_jp2_end_decompress(opj_jp2_t *jp2,
- opj_stream_private_t *cio,
- opj_event_mgr_t * p_manager);
-
-/**
- * Reads a jpeg2000 file header structure.
- *
- * @param p_stream the stream to read data from.
- * @param jp2 the jpeg2000 file header structure.
- * @param p_image FIXME DOC
- * @param p_manager the user event manager.
- *
- * @return true if the box is valid.
- */
-OPJ_BOOL opj_jp2_read_header(opj_stream_private_t *p_stream,
- opj_jp2_t *jp2,
- opj_image_t ** p_image,
- opj_event_mgr_t * p_manager);
-
-/** Sets the indices of the components to decode.
- *
- * @param jp2 JP2 decompressor handle
- * @param numcomps Number of components to decode.
- * @param comps_indices Array of num_compts indices (numbering starting at 0)
- * corresponding to the components to decode.
- * @param p_manager Event manager;
- *
- * @return OPJ_TRUE in case of success.
- */
-OPJ_BOOL opj_jp2_set_decoded_components(opj_jp2_t *jp2,
- OPJ_UINT32 numcomps,
- const OPJ_UINT32* comps_indices,
- opj_event_mgr_t * p_manager);
-
-/**
- * Reads a tile header.
- * @param p_jp2 the jpeg2000 codec.
- * @param p_tile_index FIXME DOC
- * @param p_data_size FIXME DOC
- * @param p_tile_x0 FIXME DOC
- * @param p_tile_y0 FIXME DOC
- * @param p_tile_x1 FIXME DOC
- * @param p_tile_y1 FIXME DOC
- * @param p_nb_comps FIXME DOC
- * @param p_go_on FIXME DOC
- * @param p_stream the stream to write data to.
- * @param p_manager the user event manager.
- */
-OPJ_BOOL opj_jp2_read_tile_header(opj_jp2_t * p_jp2,
- OPJ_UINT32 * p_tile_index,
- OPJ_UINT32 * p_data_size,
- OPJ_INT32 * p_tile_x0,
- OPJ_INT32 * p_tile_y0,
- OPJ_INT32 * p_tile_x1,
- OPJ_INT32 * p_tile_y1,
- OPJ_UINT32 * p_nb_comps,
- OPJ_BOOL * p_go_on,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * Writes a tile.
- *
- * @param p_jp2 the jpeg2000 codec.
- * @param p_tile_index FIXME DOC
- * @param p_data FIXME DOC
- * @param p_data_size FIXME DOC
- * @param p_stream the stream to write data to.
- * @param p_manager the user event manager.
- */
-OPJ_BOOL opj_jp2_write_tile(opj_jp2_t *p_jp2,
- OPJ_UINT32 p_tile_index,
- OPJ_BYTE * p_data,
- OPJ_UINT32 p_data_size,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * Decode tile data.
- * @param p_jp2 the jpeg2000 codec.
- * @param p_tile_index FIXME DOC
- * @param p_data FIXME DOC
- * @param p_data_size FIXME DOC
- * @param p_stream the stream to write data to.
- * @param p_manager the user event manager.
- *
- * @return FIXME DOC
- */
-OPJ_BOOL opj_jp2_decode_tile(opj_jp2_t * p_jp2,
- OPJ_UINT32 p_tile_index,
- OPJ_BYTE * p_data,
- OPJ_UINT32 p_data_size,
- opj_stream_private_t *p_stream,
- opj_event_mgr_t * p_manager);
-
-/**
- * Creates a jpeg2000 file decompressor.
- *
- * @return an empty jpeg2000 file codec.
- */
-opj_jp2_t* opj_jp2_create(OPJ_BOOL p_is_decoder);
-
-/**
-Destroy a JP2 decompressor handle
-@param jp2 JP2 decompressor handle to destroy
-*/
-void opj_jp2_destroy(opj_jp2_t *jp2);
-
-
-/**
- * Sets the given area to be decoded. This function should be called right after opj_read_header and before any tile header reading.
- *
- * @param p_jp2 the jpeg2000 codec.
- * @param p_image FIXME DOC
- * @param p_start_x the left position of the rectangle to decode (in image coordinates).
- * @param p_start_y the up position of the rectangle to decode (in image coordinates).
- * @param p_end_x the right position of the rectangle to decode (in image coordinates).
- * @param p_end_y the bottom position of the rectangle to decode (in image coordinates).
- * @param p_manager the user event manager
- *
- * @return true if the area could be set.
- */
-OPJ_BOOL opj_jp2_set_decode_area(opj_jp2_t *p_jp2,
- opj_image_t* p_image,
- OPJ_INT32 p_start_x, OPJ_INT32 p_start_y,
- OPJ_INT32 p_end_x, OPJ_INT32 p_end_y,
- opj_event_mgr_t * p_manager);
-
-/**
-*
-*/
-OPJ_BOOL opj_jp2_get_tile(opj_jp2_t *p_jp2,
- opj_stream_private_t *p_stream,
- opj_image_t* p_image,
- opj_event_mgr_t * p_manager,
- OPJ_UINT32 tile_index);
-
-
-/**
- *
- */
-OPJ_BOOL opj_jp2_set_decoded_resolution_factor(opj_jp2_t *p_jp2,
- OPJ_UINT32 res_factor,
- opj_event_mgr_t * p_manager);
-
-/**
- * Specify extra options for the encoder.
- *
- * @param p_jp2 the jpeg2000 codec.
- * @param p_options options
- * @param p_manager the user event manager
- *
- * @see opj_encoder_set_extra_options() for more details.
- */
-OPJ_BOOL opj_jp2_encoder_set_extra_options(
- opj_jp2_t *p_jp2,
- const char* const* p_options,
- opj_event_mgr_t * p_manager);
-
-
-/* TODO MSD: clean these 3 functions */
-/**
- * Dump some elements from the JP2 decompression structure .
- *
- *@param p_jp2 the jp2 codec.
- *@param flag flag to describe what elements are dump.
- *@param out_stream output stream where dump the elements.
- *
-*/
-void jp2_dump(opj_jp2_t* p_jp2, OPJ_INT32 flag, FILE* out_stream);
-
-/**
- * Get the codestream info from a JPEG2000 codec.
- *
- *@param p_jp2 jp2 codec.
- *
- *@return the codestream information extract from the jpg2000 codec
- */
-opj_codestream_info_v2_t* jp2_get_cstr_info(opj_jp2_t* p_jp2);
-
-/**
- * Get the codestream index from a JPEG2000 codec.
- *
- *@param p_jp2 jp2 codec.
- *
- *@return the codestream index extract from the jpg2000 codec
- */
-opj_codestream_index_t* jp2_get_cstr_index(opj_jp2_t* p_jp2);
-
-
-/*@}*/
-
-/*@}*/
-
-#endif /* OPJ_JP2_H */
-
diff --git a/contrib/libs/openjpeg/mct.c b/contrib/libs/openjpeg/mct.c
deleted file mode 100644
index 7805812801..0000000000
--- a/contrib/libs/openjpeg/mct.c
+++ /dev/null
@@ -1,464 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2014, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux
- * Copyright (c) 2003-2014, Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR
- * Copyright (c) 2012, CS Systemes d'Information, France
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifdef __SSE__
-#include <xmmintrin.h>
-#endif
-#ifdef __SSE2__
-#include <emmintrin.h>
-#endif
-#ifdef __SSE4_1__
-#include <smmintrin.h>
-#endif
-
-#include "opj_includes.h"
-
-/* <summary> */
-/* This table contains the norms of the basis function of the reversible MCT. */
-/* </summary> */
-static const OPJ_FLOAT64 opj_mct_norms[3] = { 1.732, .8292, .8292 };
-
-/* <summary> */
-/* This table contains the norms of the basis function of the irreversible MCT. */
-/* </summary> */
-static const OPJ_FLOAT64 opj_mct_norms_real[3] = { 1.732, 1.805, 1.573 };
-
-const OPJ_FLOAT64 * opj_mct_get_mct_norms()
-{
- return opj_mct_norms;
-}
-
-const OPJ_FLOAT64 * opj_mct_get_mct_norms_real()
-{
- return opj_mct_norms_real;
-}
-
-/* <summary> */
-/* Forward reversible MCT. */
-/* </summary> */
-#ifdef __SSE2__
-void opj_mct_encode(
- OPJ_INT32* OPJ_RESTRICT c0,
- OPJ_INT32* OPJ_RESTRICT c1,
- OPJ_INT32* OPJ_RESTRICT c2,
- OPJ_SIZE_T n)
-{
- OPJ_SIZE_T i;
- const OPJ_SIZE_T len = n;
- /* buffer are aligned on 16 bytes */
- assert(((size_t)c0 & 0xf) == 0);
- assert(((size_t)c1 & 0xf) == 0);
- assert(((size_t)c2 & 0xf) == 0);
-
- for (i = 0; i < (len & ~3U); i += 4) {
- __m128i y, u, v;
- __m128i r = _mm_load_si128((const __m128i *) & (c0[i]));
- __m128i g = _mm_load_si128((const __m128i *) & (c1[i]));
- __m128i b = _mm_load_si128((const __m128i *) & (c2[i]));
- y = _mm_add_epi32(g, g);
- y = _mm_add_epi32(y, b);
- y = _mm_add_epi32(y, r);
- y = _mm_srai_epi32(y, 2);
- u = _mm_sub_epi32(b, g);
- v = _mm_sub_epi32(r, g);
- _mm_store_si128((__m128i *) & (c0[i]), y);
- _mm_store_si128((__m128i *) & (c1[i]), u);
- _mm_store_si128((__m128i *) & (c2[i]), v);
- }
-
- for (; i < len; ++i) {
- OPJ_INT32 r = c0[i];
- OPJ_INT32 g = c1[i];
- OPJ_INT32 b = c2[i];
- OPJ_INT32 y = (r + (g * 2) + b) >> 2;
- OPJ_INT32 u = b - g;
- OPJ_INT32 v = r - g;
- c0[i] = y;
- c1[i] = u;
- c2[i] = v;
- }
-}
-#else
-void opj_mct_encode(
- OPJ_INT32* OPJ_RESTRICT c0,
- OPJ_INT32* OPJ_RESTRICT c1,
- OPJ_INT32* OPJ_RESTRICT c2,
- OPJ_SIZE_T n)
-{
- OPJ_SIZE_T i;
- const OPJ_SIZE_T len = n;
-
- for (i = 0; i < len; ++i) {
- OPJ_INT32 r = c0[i];
- OPJ_INT32 g = c1[i];
- OPJ_INT32 b = c2[i];
- OPJ_INT32 y = (r + (g * 2) + b) >> 2;
- OPJ_INT32 u = b - g;
- OPJ_INT32 v = r - g;
- c0[i] = y;
- c1[i] = u;
- c2[i] = v;
- }
-}
-#endif
-
-/* <summary> */
-/* Inverse reversible MCT. */
-/* </summary> */
-#ifdef __SSE2__
-void opj_mct_decode(
- OPJ_INT32* OPJ_RESTRICT c0,
- OPJ_INT32* OPJ_RESTRICT c1,
- OPJ_INT32* OPJ_RESTRICT c2,
- OPJ_SIZE_T n)
-{
- OPJ_SIZE_T i;
- const OPJ_SIZE_T len = n;
-
- for (i = 0; i < (len & ~3U); i += 4) {
- __m128i r, g, b;
- __m128i y = _mm_load_si128((const __m128i *) & (c0[i]));
- __m128i u = _mm_load_si128((const __m128i *) & (c1[i]));
- __m128i v = _mm_load_si128((const __m128i *) & (c2[i]));
- g = y;
- g = _mm_sub_epi32(g, _mm_srai_epi32(_mm_add_epi32(u, v), 2));
- r = _mm_add_epi32(v, g);
- b = _mm_add_epi32(u, g);
- _mm_store_si128((__m128i *) & (c0[i]), r);
- _mm_store_si128((__m128i *) & (c1[i]), g);
- _mm_store_si128((__m128i *) & (c2[i]), b);
- }
- for (; i < len; ++i) {
- OPJ_INT32 y = c0[i];
- OPJ_INT32 u = c1[i];
- OPJ_INT32 v = c2[i];
- OPJ_INT32 g = y - ((u + v) >> 2);
- OPJ_INT32 r = v + g;
- OPJ_INT32 b = u + g;
- c0[i] = r;
- c1[i] = g;
- c2[i] = b;
- }
-}
-#else
-void opj_mct_decode(
- OPJ_INT32* OPJ_RESTRICT c0,
- OPJ_INT32* OPJ_RESTRICT c1,
- OPJ_INT32* OPJ_RESTRICT c2,
- OPJ_SIZE_T n)
-{
- OPJ_SIZE_T i;
- for (i = 0; i < n; ++i) {
- OPJ_INT32 y = c0[i];
- OPJ_INT32 u = c1[i];
- OPJ_INT32 v = c2[i];
- OPJ_INT32 g = y - ((u + v) >> 2);
- OPJ_INT32 r = v + g;
- OPJ_INT32 b = u + g;
- c0[i] = r;
- c1[i] = g;
- c2[i] = b;
- }
-}
-#endif
-
-/* <summary> */
-/* Get norm of basis function of reversible MCT. */
-/* </summary> */
-OPJ_FLOAT64 opj_mct_getnorm(OPJ_UINT32 compno)
-{
- return opj_mct_norms[compno];
-}
-
-/* <summary> */
-/* Forward irreversible MCT. */
-/* </summary> */
-void opj_mct_encode_real(
- OPJ_FLOAT32* OPJ_RESTRICT c0,
- OPJ_FLOAT32* OPJ_RESTRICT c1,
- OPJ_FLOAT32* OPJ_RESTRICT c2,
- OPJ_SIZE_T n)
-{
- OPJ_SIZE_T i;
-#ifdef __SSE__
- const __m128 YR = _mm_set1_ps(0.299f);
- const __m128 YG = _mm_set1_ps(0.587f);
- const __m128 YB = _mm_set1_ps(0.114f);
- const __m128 UR = _mm_set1_ps(-0.16875f);
- const __m128 UG = _mm_set1_ps(-0.331260f);
- const __m128 UB = _mm_set1_ps(0.5f);
- const __m128 VR = _mm_set1_ps(0.5f);
- const __m128 VG = _mm_set1_ps(-0.41869f);
- const __m128 VB = _mm_set1_ps(-0.08131f);
- for (i = 0; i < (n >> 3); i ++) {
- __m128 r, g, b, y, u, v;
-
- r = _mm_load_ps(c0);
- g = _mm_load_ps(c1);
- b = _mm_load_ps(c2);
- y = _mm_add_ps(_mm_add_ps(_mm_mul_ps(r, YR), _mm_mul_ps(g, YG)),
- _mm_mul_ps(b, YB));
- u = _mm_add_ps(_mm_add_ps(_mm_mul_ps(r, UR), _mm_mul_ps(g, UG)),
- _mm_mul_ps(b, UB));
- v = _mm_add_ps(_mm_add_ps(_mm_mul_ps(r, VR), _mm_mul_ps(g, VG)),
- _mm_mul_ps(b, VB));
- _mm_store_ps(c0, y);
- _mm_store_ps(c1, u);
- _mm_store_ps(c2, v);
- c0 += 4;
- c1 += 4;
- c2 += 4;
-
- r = _mm_load_ps(c0);
- g = _mm_load_ps(c1);
- b = _mm_load_ps(c2);
- y = _mm_add_ps(_mm_add_ps(_mm_mul_ps(r, YR), _mm_mul_ps(g, YG)),
- _mm_mul_ps(b, YB));
- u = _mm_add_ps(_mm_add_ps(_mm_mul_ps(r, UR), _mm_mul_ps(g, UG)),
- _mm_mul_ps(b, UB));
- v = _mm_add_ps(_mm_add_ps(_mm_mul_ps(r, VR), _mm_mul_ps(g, VG)),
- _mm_mul_ps(b, VB));
- _mm_store_ps(c0, y);
- _mm_store_ps(c1, u);
- _mm_store_ps(c2, v);
- c0 += 4;
- c1 += 4;
- c2 += 4;
- }
- n &= 7;
-#endif
- for (i = 0; i < n; ++i) {
- OPJ_FLOAT32 r = c0[i];
- OPJ_FLOAT32 g = c1[i];
- OPJ_FLOAT32 b = c2[i];
- OPJ_FLOAT32 y = 0.299f * r + 0.587f * g + 0.114f * b;
- OPJ_FLOAT32 u = -0.16875f * r - 0.331260f * g + 0.5f * b;
- OPJ_FLOAT32 v = 0.5f * r - 0.41869f * g - 0.08131f * b;
- c0[i] = y;
- c1[i] = u;
- c2[i] = v;
- }
-}
-
-/* <summary> */
-/* Inverse irreversible MCT. */
-/* </summary> */
-void opj_mct_decode_real(
- OPJ_FLOAT32* OPJ_RESTRICT c0,
- OPJ_FLOAT32* OPJ_RESTRICT c1,
- OPJ_FLOAT32* OPJ_RESTRICT c2,
- OPJ_SIZE_T n)
-{
- OPJ_SIZE_T i;
-#ifdef __SSE__
- __m128 vrv, vgu, vgv, vbu;
- vrv = _mm_set1_ps(1.402f);
- vgu = _mm_set1_ps(0.34413f);
- vgv = _mm_set1_ps(0.71414f);
- vbu = _mm_set1_ps(1.772f);
- for (i = 0; i < (n >> 3); ++i) {
- __m128 vy, vu, vv;
- __m128 vr, vg, vb;
-
- vy = _mm_load_ps(c0);
- vu = _mm_load_ps(c1);
- vv = _mm_load_ps(c2);
- vr = _mm_add_ps(vy, _mm_mul_ps(vv, vrv));
- vg = _mm_sub_ps(_mm_sub_ps(vy, _mm_mul_ps(vu, vgu)), _mm_mul_ps(vv, vgv));
- vb = _mm_add_ps(vy, _mm_mul_ps(vu, vbu));
- _mm_store_ps(c0, vr);
- _mm_store_ps(c1, vg);
- _mm_store_ps(c2, vb);
- c0 += 4;
- c1 += 4;
- c2 += 4;
-
- vy = _mm_load_ps(c0);
- vu = _mm_load_ps(c1);
- vv = _mm_load_ps(c2);
- vr = _mm_add_ps(vy, _mm_mul_ps(vv, vrv));
- vg = _mm_sub_ps(_mm_sub_ps(vy, _mm_mul_ps(vu, vgu)), _mm_mul_ps(vv, vgv));
- vb = _mm_add_ps(vy, _mm_mul_ps(vu, vbu));
- _mm_store_ps(c0, vr);
- _mm_store_ps(c1, vg);
- _mm_store_ps(c2, vb);
- c0 += 4;
- c1 += 4;
- c2 += 4;
- }
- n &= 7;
-#endif
- for (i = 0; i < n; ++i) {
- OPJ_FLOAT32 y = c0[i];
- OPJ_FLOAT32 u = c1[i];
- OPJ_FLOAT32 v = c2[i];
- OPJ_FLOAT32 r = y + (v * 1.402f);
- OPJ_FLOAT32 g = y - (u * 0.34413f) - (v * (0.71414f));
- OPJ_FLOAT32 b = y + (u * 1.772f);
- c0[i] = r;
- c1[i] = g;
- c2[i] = b;
- }
-}
-
-/* <summary> */
-/* Get norm of basis function of irreversible MCT. */
-/* </summary> */
-OPJ_FLOAT64 opj_mct_getnorm_real(OPJ_UINT32 compno)
-{
- return opj_mct_norms_real[compno];
-}
-
-
-OPJ_BOOL opj_mct_encode_custom(
- OPJ_BYTE * pCodingdata,
- OPJ_SIZE_T n,
- OPJ_BYTE ** pData,
- OPJ_UINT32 pNbComp,
- OPJ_UINT32 isSigned)
-{
- OPJ_FLOAT32 * lMct = (OPJ_FLOAT32 *) pCodingdata;
- OPJ_SIZE_T i;
- OPJ_UINT32 j;
- OPJ_UINT32 k;
- OPJ_UINT32 lNbMatCoeff = pNbComp * pNbComp;
- OPJ_INT32 * lCurrentData = 00;
- OPJ_INT32 * lCurrentMatrix = 00;
- OPJ_INT32 ** lData = (OPJ_INT32 **) pData;
- OPJ_UINT32 lMultiplicator = 1 << 13;
- OPJ_INT32 * lMctPtr;
-
- OPJ_ARG_NOT_USED(isSigned);
-
- lCurrentData = (OPJ_INT32 *) opj_malloc((pNbComp + lNbMatCoeff) * sizeof(
- OPJ_INT32));
- if (! lCurrentData) {
- return OPJ_FALSE;
- }
-
- lCurrentMatrix = lCurrentData + pNbComp;
-
- for (i = 0; i < lNbMatCoeff; ++i) {
- lCurrentMatrix[i] = (OPJ_INT32)(*(lMct++) * (OPJ_FLOAT32)lMultiplicator);
- }
-
- for (i = 0; i < n; ++i) {
- lMctPtr = lCurrentMatrix;
- for (j = 0; j < pNbComp; ++j) {
- lCurrentData[j] = (*(lData[j]));
- }
-
- for (j = 0; j < pNbComp; ++j) {
- *(lData[j]) = 0;
- for (k = 0; k < pNbComp; ++k) {
- *(lData[j]) += opj_int_fix_mul(*lMctPtr, lCurrentData[k]);
- ++lMctPtr;
- }
-
- ++lData[j];
- }
- }
-
- opj_free(lCurrentData);
-
- return OPJ_TRUE;
-}
-
-OPJ_BOOL opj_mct_decode_custom(
- OPJ_BYTE * pDecodingData,
- OPJ_SIZE_T n,
- OPJ_BYTE ** pData,
- OPJ_UINT32 pNbComp,
- OPJ_UINT32 isSigned)
-{
- OPJ_FLOAT32 * lMct;
- OPJ_SIZE_T i;
- OPJ_UINT32 j;
- OPJ_UINT32 k;
-
- OPJ_FLOAT32 * lCurrentData = 00;
- OPJ_FLOAT32 * lCurrentResult = 00;
- OPJ_FLOAT32 ** lData = (OPJ_FLOAT32 **) pData;
-
- OPJ_ARG_NOT_USED(isSigned);
-
- lCurrentData = (OPJ_FLOAT32 *) opj_malloc(2 * pNbComp * sizeof(OPJ_FLOAT32));
- if (! lCurrentData) {
- return OPJ_FALSE;
- }
- lCurrentResult = lCurrentData + pNbComp;
-
- for (i = 0; i < n; ++i) {
- lMct = (OPJ_FLOAT32 *) pDecodingData;
- for (j = 0; j < pNbComp; ++j) {
- lCurrentData[j] = (OPJ_FLOAT32)(*(lData[j]));
- }
- for (j = 0; j < pNbComp; ++j) {
- lCurrentResult[j] = 0;
- for (k = 0; k < pNbComp; ++k) {
- lCurrentResult[j] += *(lMct++) * lCurrentData[k];
- }
- *(lData[j]++) = (OPJ_FLOAT32)(lCurrentResult[j]);
- }
- }
- opj_free(lCurrentData);
- return OPJ_TRUE;
-}
-
-void opj_calculate_norms(OPJ_FLOAT64 * pNorms,
- OPJ_UINT32 pNbComps,
- OPJ_FLOAT32 * pMatrix)
-{
- OPJ_UINT32 i, j, lIndex;
- OPJ_FLOAT32 lCurrentValue;
- OPJ_FLOAT64 * lNorms = (OPJ_FLOAT64 *) pNorms;
- OPJ_FLOAT32 * lMatrix = (OPJ_FLOAT32 *) pMatrix;
-
- for (i = 0; i < pNbComps; ++i) {
- lNorms[i] = 0;
- lIndex = i;
-
- for (j = 0; j < pNbComps; ++j) {
- lCurrentValue = lMatrix[lIndex];
- lIndex += pNbComps;
- lNorms[i] += (OPJ_FLOAT64) lCurrentValue * lCurrentValue;
- }
- lNorms[i] = sqrt(lNorms[i]);
- }
-}
diff --git a/contrib/libs/openjpeg/mct.h b/contrib/libs/openjpeg/mct.h
deleted file mode 100644
index 3e1f5e4946..0000000000
--- a/contrib/libs/openjpeg/mct.h
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2014, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux
- * Copyright (c) 2003-2014, Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR
- * Copyright (c) 2012, CS Systemes d'Information, France
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef OPJ_MCT_H
-#define OPJ_MCT_H
-/**
-@file mct.h
-@brief Implementation of a multi-component transforms (MCT)
-
-The functions in MCT.C have for goal to realize reversible and irreversible multicomponent
-transform. The functions in MCT.C are used by some function in TCD.C.
-*/
-
-/** @defgroup MCT MCT - Implementation of a multi-component transform */
-/*@{*/
-
-/** @name Exported functions */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-/**
-Apply a reversible multi-component transform to an image
-@param c0 Samples for red component
-@param c1 Samples for green component
-@param c2 Samples blue component
-@param n Number of samples for each component
-*/
-void opj_mct_encode(OPJ_INT32* OPJ_RESTRICT c0, OPJ_INT32* OPJ_RESTRICT c1,
- OPJ_INT32* OPJ_RESTRICT c2, OPJ_SIZE_T n);
-/**
-Apply a reversible multi-component inverse transform to an image
-@param c0 Samples for luminance component
-@param c1 Samples for red chrominance component
-@param c2 Samples for blue chrominance component
-@param n Number of samples for each component
-*/
-void opj_mct_decode(OPJ_INT32* OPJ_RESTRICT c0, OPJ_INT32* OPJ_RESTRICT c1,
- OPJ_INT32* OPJ_RESTRICT c2, OPJ_SIZE_T n);
-/**
-Get norm of the basis function used for the reversible multi-component transform
-@param compno Number of the component (0->Y, 1->U, 2->V)
-@return
-*/
-OPJ_FLOAT64 opj_mct_getnorm(OPJ_UINT32 compno);
-
-/**
-Apply an irreversible multi-component transform to an image
-@param c0 Samples for red component
-@param c1 Samples for green component
-@param c2 Samples blue component
-@param n Number of samples for each component
-*/
-void opj_mct_encode_real(OPJ_FLOAT32* OPJ_RESTRICT c0,
- OPJ_FLOAT32* OPJ_RESTRICT c1,
- OPJ_FLOAT32* OPJ_RESTRICT c2, OPJ_SIZE_T n);
-/**
-Apply an irreversible multi-component inverse transform to an image
-@param c0 Samples for luminance component
-@param c1 Samples for red chrominance component
-@param c2 Samples for blue chrominance component
-@param n Number of samples for each component
-*/
-void opj_mct_decode_real(OPJ_FLOAT32* OPJ_RESTRICT c0,
- OPJ_FLOAT32* OPJ_RESTRICT c1, OPJ_FLOAT32* OPJ_RESTRICT c2, OPJ_SIZE_T n);
-/**
-Get norm of the basis function used for the irreversible multi-component transform
-@param compno Number of the component (0->Y, 1->U, 2->V)
-@return
-*/
-OPJ_FLOAT64 opj_mct_getnorm_real(OPJ_UINT32 compno);
-
-/**
-FIXME DOC
-@param p_coding_data MCT data
-@param n size of components
-@param p_data components
-@param p_nb_comp nb of components (i.e. size of p_data)
-@param is_signed tells if the data is signed
-@return OPJ_FALSE if function encounter a problem, OPJ_TRUE otherwise
-*/
-OPJ_BOOL opj_mct_encode_custom(
- OPJ_BYTE * p_coding_data,
- OPJ_SIZE_T n,
- OPJ_BYTE ** p_data,
- OPJ_UINT32 p_nb_comp,
- OPJ_UINT32 is_signed);
-/**
-FIXME DOC
-@param pDecodingData MCT data
-@param n size of components
-@param pData components
-@param pNbComp nb of components (i.e. size of p_data)
-@param isSigned tells if the data is signed
-@return OPJ_FALSE if function encounter a problem, OPJ_TRUE otherwise
-*/
-OPJ_BOOL opj_mct_decode_custom(
- OPJ_BYTE * pDecodingData,
- OPJ_SIZE_T n,
- OPJ_BYTE ** pData,
- OPJ_UINT32 pNbComp,
- OPJ_UINT32 isSigned);
-/**
-FIXME DOC
-@param pNorms MCT data
-@param p_nb_comps size of components
-@param pMatrix components
-@return
-*/
-void opj_calculate_norms(OPJ_FLOAT64 * pNorms,
- OPJ_UINT32 p_nb_comps,
- OPJ_FLOAT32 * pMatrix);
-/**
-FIXME DOC
-*/
-const OPJ_FLOAT64 * opj_mct_get_mct_norms(void);
-/**
-FIXME DOC
-*/
-const OPJ_FLOAT64 * opj_mct_get_mct_norms_real(void);
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* OPJ_MCT_H */
diff --git a/contrib/libs/openjpeg/mqc.c b/contrib/libs/openjpeg/mqc.c
deleted file mode 100644
index 4cbfabd033..0000000000
--- a/contrib/libs/openjpeg/mqc.c
+++ /dev/null
@@ -1,524 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2014, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux
- * Copyright (c) 2003-2014, Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "opj_includes.h"
-
-#include <assert.h>
-
-/** @defgroup MQC MQC - Implementation of an MQ-Coder */
-/*@{*/
-
-/** @name Local static functions */
-/*@{*/
-
-/**
-Fill mqc->c with 1's for flushing
-@param mqc MQC handle
-*/
-static void opj_mqc_setbits(opj_mqc_t *mqc);
-/*@}*/
-
-/*@}*/
-
-/* <summary> */
-/* This array defines all the possible states for a context. */
-/* </summary> */
-static const opj_mqc_state_t mqc_states[47 * 2] = {
- {0x5601, 0, &mqc_states[2], &mqc_states[3]},
- {0x5601, 1, &mqc_states[3], &mqc_states[2]},
- {0x3401, 0, &mqc_states[4], &mqc_states[12]},
- {0x3401, 1, &mqc_states[5], &mqc_states[13]},
- {0x1801, 0, &mqc_states[6], &mqc_states[18]},
- {0x1801, 1, &mqc_states[7], &mqc_states[19]},
- {0x0ac1, 0, &mqc_states[8], &mqc_states[24]},
- {0x0ac1, 1, &mqc_states[9], &mqc_states[25]},
- {0x0521, 0, &mqc_states[10], &mqc_states[58]},
- {0x0521, 1, &mqc_states[11], &mqc_states[59]},
- {0x0221, 0, &mqc_states[76], &mqc_states[66]},
- {0x0221, 1, &mqc_states[77], &mqc_states[67]},
- {0x5601, 0, &mqc_states[14], &mqc_states[13]},
- {0x5601, 1, &mqc_states[15], &mqc_states[12]},
- {0x5401, 0, &mqc_states[16], &mqc_states[28]},
- {0x5401, 1, &mqc_states[17], &mqc_states[29]},
- {0x4801, 0, &mqc_states[18], &mqc_states[28]},
- {0x4801, 1, &mqc_states[19], &mqc_states[29]},
- {0x3801, 0, &mqc_states[20], &mqc_states[28]},
- {0x3801, 1, &mqc_states[21], &mqc_states[29]},
- {0x3001, 0, &mqc_states[22], &mqc_states[34]},
- {0x3001, 1, &mqc_states[23], &mqc_states[35]},
- {0x2401, 0, &mqc_states[24], &mqc_states[36]},
- {0x2401, 1, &mqc_states[25], &mqc_states[37]},
- {0x1c01, 0, &mqc_states[26], &mqc_states[40]},
- {0x1c01, 1, &mqc_states[27], &mqc_states[41]},
- {0x1601, 0, &mqc_states[58], &mqc_states[42]},
- {0x1601, 1, &mqc_states[59], &mqc_states[43]},
- {0x5601, 0, &mqc_states[30], &mqc_states[29]},
- {0x5601, 1, &mqc_states[31], &mqc_states[28]},
- {0x5401, 0, &mqc_states[32], &mqc_states[28]},
- {0x5401, 1, &mqc_states[33], &mqc_states[29]},
- {0x5101, 0, &mqc_states[34], &mqc_states[30]},
- {0x5101, 1, &mqc_states[35], &mqc_states[31]},
- {0x4801, 0, &mqc_states[36], &mqc_states[32]},
- {0x4801, 1, &mqc_states[37], &mqc_states[33]},
- {0x3801, 0, &mqc_states[38], &mqc_states[34]},
- {0x3801, 1, &mqc_states[39], &mqc_states[35]},
- {0x3401, 0, &mqc_states[40], &mqc_states[36]},
- {0x3401, 1, &mqc_states[41], &mqc_states[37]},
- {0x3001, 0, &mqc_states[42], &mqc_states[38]},
- {0x3001, 1, &mqc_states[43], &mqc_states[39]},
- {0x2801, 0, &mqc_states[44], &mqc_states[38]},
- {0x2801, 1, &mqc_states[45], &mqc_states[39]},
- {0x2401, 0, &mqc_states[46], &mqc_states[40]},
- {0x2401, 1, &mqc_states[47], &mqc_states[41]},
- {0x2201, 0, &mqc_states[48], &mqc_states[42]},
- {0x2201, 1, &mqc_states[49], &mqc_states[43]},
- {0x1c01, 0, &mqc_states[50], &mqc_states[44]},
- {0x1c01, 1, &mqc_states[51], &mqc_states[45]},
- {0x1801, 0, &mqc_states[52], &mqc_states[46]},
- {0x1801, 1, &mqc_states[53], &mqc_states[47]},
- {0x1601, 0, &mqc_states[54], &mqc_states[48]},
- {0x1601, 1, &mqc_states[55], &mqc_states[49]},
- {0x1401, 0, &mqc_states[56], &mqc_states[50]},
- {0x1401, 1, &mqc_states[57], &mqc_states[51]},
- {0x1201, 0, &mqc_states[58], &mqc_states[52]},
- {0x1201, 1, &mqc_states[59], &mqc_states[53]},
- {0x1101, 0, &mqc_states[60], &mqc_states[54]},
- {0x1101, 1, &mqc_states[61], &mqc_states[55]},
- {0x0ac1, 0, &mqc_states[62], &mqc_states[56]},
- {0x0ac1, 1, &mqc_states[63], &mqc_states[57]},
- {0x09c1, 0, &mqc_states[64], &mqc_states[58]},
- {0x09c1, 1, &mqc_states[65], &mqc_states[59]},
- {0x08a1, 0, &mqc_states[66], &mqc_states[60]},
- {0x08a1, 1, &mqc_states[67], &mqc_states[61]},
- {0x0521, 0, &mqc_states[68], &mqc_states[62]},
- {0x0521, 1, &mqc_states[69], &mqc_states[63]},
- {0x0441, 0, &mqc_states[70], &mqc_states[64]},
- {0x0441, 1, &mqc_states[71], &mqc_states[65]},
- {0x02a1, 0, &mqc_states[72], &mqc_states[66]},
- {0x02a1, 1, &mqc_states[73], &mqc_states[67]},
- {0x0221, 0, &mqc_states[74], &mqc_states[68]},
- {0x0221, 1, &mqc_states[75], &mqc_states[69]},
- {0x0141, 0, &mqc_states[76], &mqc_states[70]},
- {0x0141, 1, &mqc_states[77], &mqc_states[71]},
- {0x0111, 0, &mqc_states[78], &mqc_states[72]},
- {0x0111, 1, &mqc_states[79], &mqc_states[73]},
- {0x0085, 0, &mqc_states[80], &mqc_states[74]},
- {0x0085, 1, &mqc_states[81], &mqc_states[75]},
- {0x0049, 0, &mqc_states[82], &mqc_states[76]},
- {0x0049, 1, &mqc_states[83], &mqc_states[77]},
- {0x0025, 0, &mqc_states[84], &mqc_states[78]},
- {0x0025, 1, &mqc_states[85], &mqc_states[79]},
- {0x0015, 0, &mqc_states[86], &mqc_states[80]},
- {0x0015, 1, &mqc_states[87], &mqc_states[81]},
- {0x0009, 0, &mqc_states[88], &mqc_states[82]},
- {0x0009, 1, &mqc_states[89], &mqc_states[83]},
- {0x0005, 0, &mqc_states[90], &mqc_states[84]},
- {0x0005, 1, &mqc_states[91], &mqc_states[85]},
- {0x0001, 0, &mqc_states[90], &mqc_states[86]},
- {0x0001, 1, &mqc_states[91], &mqc_states[87]},
- {0x5601, 0, &mqc_states[92], &mqc_states[92]},
- {0x5601, 1, &mqc_states[93], &mqc_states[93]},
-};
-
-/*
-==========================================================
- local functions
-==========================================================
-*/
-
-static void opj_mqc_setbits(opj_mqc_t *mqc)
-{
- OPJ_UINT32 tempc = mqc->c + mqc->a;
- mqc->c |= 0xffff;
- if (mqc->c >= tempc) {
- mqc->c -= 0x8000;
- }
-}
-
-/*
-==========================================================
- MQ-Coder interface
-==========================================================
-*/
-
-OPJ_UINT32 opj_mqc_numbytes(opj_mqc_t *mqc)
-{
- const ptrdiff_t diff = mqc->bp - mqc->start;
-#if 0
- assert(diff <= 0xffffffff && diff >= 0); /* UINT32_MAX */
-#endif
- return (OPJ_UINT32)diff;
-}
-
-void opj_mqc_init_enc(opj_mqc_t *mqc, OPJ_BYTE *bp)
-{
- /* To avoid the curctx pointer to be dangling, but not strictly */
- /* required as the current context is always set before encoding */
- opj_mqc_setcurctx(mqc, 0);
-
- /* As specified in Figure C.10 - Initialization of the encoder */
- /* (C.2.8 Initialization of the encoder (INITENC)) */
- mqc->a = 0x8000;
- mqc->c = 0;
- /* Yes, we point before the start of the buffer, but this is safe */
- /* given opj_tcd_code_block_enc_allocate_data() */
- mqc->bp = bp - 1;
- mqc->ct = 12;
- /* At this point we should test *(mqc->bp) against 0xFF, but this is not */
- /* necessary, as this is only used at the beginning of the code block */
- /* and our initial fake byte is set at 0 */
- assert(*(mqc->bp) != 0xff);
-
- mqc->start = bp;
- mqc->end_of_byte_stream_counter = 0;
-}
-
-
-void opj_mqc_flush(opj_mqc_t *mqc)
-{
- /* C.2.9 Termination of coding (FLUSH) */
- /* Figure C.11 – FLUSH procedure */
- opj_mqc_setbits(mqc);
- mqc->c <<= mqc->ct;
- opj_mqc_byteout(mqc);
- mqc->c <<= mqc->ct;
- opj_mqc_byteout(mqc);
-
- /* It is forbidden that a coding pass ends with 0xff */
- if (*mqc->bp != 0xff) {
- /* Advance pointer so that opj_mqc_numbytes() returns a valid value */
- mqc->bp++;
- }
-}
-
-void opj_mqc_bypass_init_enc(opj_mqc_t *mqc)
-{
- /* This function is normally called after at least one opj_mqc_flush() */
- /* which will have advance mqc->bp by at least 2 bytes beyond its */
- /* initial position */
- assert(mqc->bp >= mqc->start);
- mqc->c = 0;
- /* in theory we should initialize to 8, but use this special value */
- /* as a hint that opj_mqc_bypass_enc() has never been called, so */
- /* as to avoid the 0xff 0x7f elimination trick in opj_mqc_bypass_flush_enc() */
- /* to trigger when we don't have output any bit during this bypass sequence */
- /* Any value > 8 will do */
- mqc->ct = BYPASS_CT_INIT;
- /* Given that we are called after opj_mqc_flush(), the previous byte */
- /* cannot be 0xff. */
- assert(mqc->bp[-1] != 0xff);
-}
-
-void opj_mqc_bypass_enc(opj_mqc_t *mqc, OPJ_UINT32 d)
-{
- if (mqc->ct == BYPASS_CT_INIT) {
- mqc->ct = 8;
- }
- mqc->ct--;
- mqc->c = mqc->c + (d << mqc->ct);
- if (mqc->ct == 0) {
- *mqc->bp = (OPJ_BYTE)mqc->c;
- mqc->ct = 8;
- /* If the previous byte was 0xff, make sure that the next msb is 0 */
- if (*mqc->bp == 0xff) {
- mqc->ct = 7;
- }
- mqc->bp++;
- mqc->c = 0;
- }
-}
-
-OPJ_UINT32 opj_mqc_bypass_get_extra_bytes(opj_mqc_t *mqc, OPJ_BOOL erterm)
-{
- return (mqc->ct < 7 ||
- (mqc->ct == 7 && (erterm || mqc->bp[-1] != 0xff))) ? 1 : 0;
-}
-
-void opj_mqc_bypass_flush_enc(opj_mqc_t *mqc, OPJ_BOOL erterm)
-{
- /* Is there any bit remaining to be flushed ? */
- /* If the last output byte is 0xff, we can discard it, unless */
- /* erterm is required (I'm not completely sure why in erterm */
- /* we must output 0xff 0x2a if the last byte was 0xff instead of */
- /* discarding it, but Kakadu requires it when decoding */
- /* in -fussy mode) */
- if (mqc->ct < 7 || (mqc->ct == 7 && (erterm || mqc->bp[-1] != 0xff))) {
- OPJ_BYTE bit_value = 0;
- /* If so, fill the remaining lsbs with an alternating sequence of */
- /* 0,1,... */
- /* Note: it seems the standard only requires that for a ERTERM flush */
- /* and doesn't specify what to do for a regular BYPASS flush */
- while (mqc->ct > 0) {
- mqc->ct--;
- mqc->c += (OPJ_UINT32)(bit_value << mqc->ct);
- bit_value = (OPJ_BYTE)(1U - bit_value);
- }
- *mqc->bp = (OPJ_BYTE)mqc->c;
- /* Advance pointer so that opj_mqc_numbytes() returns a valid value */
- mqc->bp++;
- } else if (mqc->ct == 7 && mqc->bp[-1] == 0xff) {
- /* Discard last 0xff */
- assert(!erterm);
- mqc->bp --;
- } else if (mqc->ct == 8 && !erterm &&
- mqc->bp[-1] == 0x7f && mqc->bp[-2] == 0xff) {
- /* Tiny optimization: discard terminating 0xff 0x7f since it is */
- /* interpreted as 0xff 0x7f [0xff 0xff] by the decoder, and given */
- /* the bit stuffing, in fact as 0xff 0xff [0xff ..] */
- /* Happens once on opj_compress -i ../MAPA.tif -o MAPA.j2k -M 1 */
- mqc->bp -= 2;
- }
-
- assert(mqc->bp[-1] != 0xff);
-}
-
-void opj_mqc_reset_enc(opj_mqc_t *mqc)
-{
- opj_mqc_resetstates(mqc);
- opj_mqc_setstate(mqc, T1_CTXNO_UNI, 0, 46);
- opj_mqc_setstate(mqc, T1_CTXNO_AGG, 0, 3);
- opj_mqc_setstate(mqc, T1_CTXNO_ZC, 0, 4);
-}
-
-#ifdef notdef
-OPJ_UINT32 opj_mqc_restart_enc(opj_mqc_t *mqc)
-{
- OPJ_UINT32 correction = 1;
-
- /* <flush part> */
- OPJ_INT32 n = (OPJ_INT32)(27 - 15 - mqc->ct);
- mqc->c <<= mqc->ct;
- while (n > 0) {
- opj_mqc_byteout(mqc);
- n -= (OPJ_INT32)mqc->ct;
- mqc->c <<= mqc->ct;
- }
- opj_mqc_byteout(mqc);
-
- return correction;
-}
-#endif
-
-void opj_mqc_restart_init_enc(opj_mqc_t *mqc)
-{
- /* <Re-init part> */
-
- /* As specified in Figure C.10 - Initialization of the encoder */
- /* (C.2.8 Initialization of the encoder (INITENC)) */
- mqc->a = 0x8000;
- mqc->c = 0;
- mqc->ct = 12;
- /* This function is normally called after at least one opj_mqc_flush() */
- /* which will have advance mqc->bp by at least 2 bytes beyond its */
- /* initial position */
- mqc->bp --;
- assert(mqc->bp >= mqc->start - 1);
- assert(*mqc->bp != 0xff);
- if (*mqc->bp == 0xff) {
- mqc->ct = 13;
- }
-}
-
-void opj_mqc_erterm_enc(opj_mqc_t *mqc)
-{
- OPJ_INT32 k = (OPJ_INT32)(11 - mqc->ct + 1);
-
- while (k > 0) {
- mqc->c <<= mqc->ct;
- mqc->ct = 0;
- opj_mqc_byteout(mqc);
- k -= (OPJ_INT32)mqc->ct;
- }
-
- if (*mqc->bp != 0xff) {
- opj_mqc_byteout(mqc);
- }
-}
-
-static INLINE void opj_mqc_renorme(opj_mqc_t *mqc)
-{
- opj_mqc_renorme_macro(mqc, mqc->a, mqc->c, mqc->ct);
-}
-
-/**
-Encode the most probable symbol
-@param mqc MQC handle
-*/
-static INLINE void opj_mqc_codemps(opj_mqc_t *mqc)
-{
- opj_mqc_codemps_macro(mqc, mqc->curctx, mqc->a, mqc->c, mqc->ct);
-}
-
-/**
-Encode the most least symbol
-@param mqc MQC handle
-*/
-static INLINE void opj_mqc_codelps(opj_mqc_t *mqc)
-{
- opj_mqc_codelps_macro(mqc, mqc->curctx, mqc->a, mqc->c, mqc->ct);
-}
-
-/**
-Encode a symbol using the MQ-coder
-@param mqc MQC handle
-@param d The symbol to be encoded (0 or 1)
-*/
-static INLINE void opj_mqc_encode(opj_mqc_t *mqc, OPJ_UINT32 d)
-{
- if ((*mqc->curctx)->mps == d) {
- opj_mqc_codemps(mqc);
- } else {
- opj_mqc_codelps(mqc);
- }
-}
-
-void opj_mqc_segmark_enc(opj_mqc_t *mqc)
-{
- OPJ_UINT32 i;
- opj_mqc_setcurctx(mqc, 18);
-
- for (i = 1; i < 5; i++) {
- opj_mqc_encode(mqc, i % 2);
- }
-}
-
-static void opj_mqc_init_dec_common(opj_mqc_t *mqc,
- OPJ_BYTE *bp,
- OPJ_UINT32 len,
- OPJ_UINT32 extra_writable_bytes)
-{
- (void)extra_writable_bytes;
-
- assert(extra_writable_bytes >= OPJ_COMMON_CBLK_DATA_EXTRA);
- mqc->start = bp;
- mqc->end = bp + len;
- /* Insert an artificial 0xFF 0xFF marker at end of the code block */
- /* data so that the bytein routines stop on it. This saves us comparing */
- /* the bp and end pointers */
- /* But before inserting it, backup th bytes we will overwrite */
- memcpy(mqc->backup, mqc->end, OPJ_COMMON_CBLK_DATA_EXTRA);
- mqc->end[0] = 0xFF;
- mqc->end[1] = 0xFF;
- mqc->bp = bp;
-}
-void opj_mqc_init_dec(opj_mqc_t *mqc, OPJ_BYTE *bp, OPJ_UINT32 len,
- OPJ_UINT32 extra_writable_bytes)
-{
- /* Implements ISO 15444-1 C.3.5 Initialization of the decoder (INITDEC) */
- /* Note: alternate "J.1 - Initialization of the software-conventions */
- /* decoder" has been tried, but does */
- /* not bring any improvement. */
- /* See https://github.com/uclouvain/openjpeg/issues/921 */
- opj_mqc_init_dec_common(mqc, bp, len, extra_writable_bytes);
- opj_mqc_setcurctx(mqc, 0);
- mqc->end_of_byte_stream_counter = 0;
- if (len == 0) {
- mqc->c = 0xff << 16;
- } else {
- mqc->c = (OPJ_UINT32)(*mqc->bp << 16);
- }
-
- opj_mqc_bytein(mqc);
- mqc->c <<= 7;
- mqc->ct -= 7;
- mqc->a = 0x8000;
-}
-
-
-void opj_mqc_raw_init_dec(opj_mqc_t *mqc, OPJ_BYTE *bp, OPJ_UINT32 len,
- OPJ_UINT32 extra_writable_bytes)
-{
- opj_mqc_init_dec_common(mqc, bp, len, extra_writable_bytes);
- mqc->c = 0;
- mqc->ct = 0;
-}
-
-
-void opq_mqc_finish_dec(opj_mqc_t *mqc)
-{
- /* Restore the bytes overwritten by opj_mqc_init_dec_common() */
- memcpy(mqc->end, mqc->backup, OPJ_COMMON_CBLK_DATA_EXTRA);
-}
-
-void opj_mqc_resetstates(opj_mqc_t *mqc)
-{
- OPJ_UINT32 i;
- for (i = 0; i < MQC_NUMCTXS; i++) {
- mqc->ctxs[i] = mqc_states;
- }
-}
-
-void opj_mqc_setstate(opj_mqc_t *mqc, OPJ_UINT32 ctxno, OPJ_UINT32 msb,
- OPJ_INT32 prob)
-{
- mqc->ctxs[ctxno] = &mqc_states[msb + (OPJ_UINT32)(prob << 1)];
-}
-
-void opj_mqc_byteout(opj_mqc_t *mqc)
-{
- /* bp is initialized to start - 1 in opj_mqc_init_enc() */
- /* but this is safe, see opj_tcd_code_block_enc_allocate_data() */
- assert(mqc->bp >= mqc->start - 1);
- if (*mqc->bp == 0xff) {
- mqc->bp++;
- *mqc->bp = (OPJ_BYTE)(mqc->c >> 20);
- mqc->c &= 0xfffff;
- mqc->ct = 7;
- } else {
- if ((mqc->c & 0x8000000) == 0) {
- mqc->bp++;
- *mqc->bp = (OPJ_BYTE)(mqc->c >> 19);
- mqc->c &= 0x7ffff;
- mqc->ct = 8;
- } else {
- (*mqc->bp)++;
- if (*mqc->bp == 0xff) {
- mqc->c &= 0x7ffffff;
- mqc->bp++;
- *mqc->bp = (OPJ_BYTE)(mqc->c >> 20);
- mqc->c &= 0xfffff;
- mqc->ct = 7;
- } else {
- mqc->bp++;
- *mqc->bp = (OPJ_BYTE)(mqc->c >> 19);
- mqc->c &= 0x7ffff;
- mqc->ct = 8;
- }
- }
- }
-} \ No newline at end of file
diff --git a/contrib/libs/openjpeg/mqc.h b/contrib/libs/openjpeg/mqc.h
deleted file mode 100644
index 9850fed031..0000000000
--- a/contrib/libs/openjpeg/mqc.h
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2014, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux
- * Copyright (c) 2003-2014, Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef OPJ_MQC_H
-#define OPJ_MQC_H
-
-#include "opj_common.h"
-
-/**
-@file mqc.h
-@brief Implementation of an MQ-Coder (MQC)
-
-The functions in MQC.C have for goal to realize the MQ-coder operations. The functions
-in MQC.C are used by some function in T1.C.
-*/
-
-/** @defgroup MQC MQC - Implementation of an MQ-Coder */
-/*@{*/
-
-/**
-This struct defines the state of a context.
-*/
-typedef struct opj_mqc_state {
- /** the probability of the Least Probable Symbol (0.75->0x8000, 1.5->0xffff) */
- OPJ_UINT32 qeval;
- /** the Most Probable Symbol (0 or 1) */
- OPJ_UINT32 mps;
- /** next state if the next encoded symbol is the MPS */
- const struct opj_mqc_state *nmps;
- /** next state if the next encoded symbol is the LPS */
- const struct opj_mqc_state *nlps;
-} opj_mqc_state_t;
-
-#define MQC_NUMCTXS 19
-
-/**
-MQ coder
-*/
-typedef struct opj_mqc {
- /** temporary buffer where bits are coded or decoded */
- OPJ_UINT32 c;
- /** only used by MQ decoder */
- OPJ_UINT32 a;
- /** number of bits already read or free to write */
- OPJ_UINT32 ct;
- /* only used by decoder, to count the number of times a terminating 0xFF >0x8F marker is read */
- OPJ_UINT32 end_of_byte_stream_counter;
- /** pointer to the current position in the buffer */
- OPJ_BYTE *bp;
- /** pointer to the start of the buffer */
- OPJ_BYTE *start;
- /** pointer to the end of the buffer */
- OPJ_BYTE *end;
- /** Array of contexts */
- const opj_mqc_state_t *ctxs[MQC_NUMCTXS];
- /** Active context */
- const opj_mqc_state_t **curctx;
- /* lut_ctxno_zc shifted by (1 << 9) * bandno */
- const OPJ_BYTE* lut_ctxno_zc_orient;
- /** Original value of the 2 bytes at end[0] and end[1] */
- OPJ_BYTE backup[OPJ_COMMON_CBLK_DATA_EXTRA];
-} opj_mqc_t;
-
-#define BYPASS_CT_INIT 0xDEADBEEF
-
-#include "mqc_inl.h"
-
-/** @name Exported functions */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-
-/**
-Return the number of bytes written/read since initialisation
-@param mqc MQC handle
-@return Returns the number of bytes already encoded
-*/
-OPJ_UINT32 opj_mqc_numbytes(opj_mqc_t *mqc);
-/**
-Reset the states of all the context of the coder/decoder
-(each context is set to a state where 0 and 1 are more or less equiprobable)
-@param mqc MQC handle
-*/
-void opj_mqc_resetstates(opj_mqc_t *mqc);
-/**
-Set the state of a particular context
-@param mqc MQC handle
-@param ctxno Number that identifies the context
-@param msb The MSB of the new state of the context
-@param prob Number that identifies the probability of the symbols for the new state of the context
-*/
-void opj_mqc_setstate(opj_mqc_t *mqc, OPJ_UINT32 ctxno, OPJ_UINT32 msb,
- OPJ_INT32 prob);
-/**
-Initialize the encoder
-@param mqc MQC handle
-@param bp Pointer to the start of the buffer where the bytes will be written
-*/
-void opj_mqc_init_enc(opj_mqc_t *mqc, OPJ_BYTE *bp);
-/**
-Set the current context used for coding/decoding
-@param mqc MQC handle
-@param ctxno Number that identifies the context
-*/
-#define opj_mqc_setcurctx(mqc, ctxno) (mqc)->curctx = &(mqc)->ctxs[(OPJ_UINT32)(ctxno)]
-
-/**
-Flush the encoder, so that all remaining data is written
-@param mqc MQC handle
-*/
-void opj_mqc_flush(opj_mqc_t *mqc);
-/**
-BYPASS mode switch, initialization operation.
-JPEG 2000 p 505.
-@param mqc MQC handle
-*/
-void opj_mqc_bypass_init_enc(opj_mqc_t *mqc);
-
-/** Return number of extra bytes to add to opj_mqc_numbytes() for the²
- size of a non-terminating BYPASS pass
-@param mqc MQC handle
-@param erterm 1 if ERTERM is enabled, 0 otherwise
-*/
-OPJ_UINT32 opj_mqc_bypass_get_extra_bytes(opj_mqc_t *mqc, OPJ_BOOL erterm);
-
-/**
-BYPASS mode switch, coding operation.
-JPEG 2000 p 505.
-@param mqc MQC handle
-@param d The symbol to be encoded (0 or 1)
-*/
-void opj_mqc_bypass_enc(opj_mqc_t *mqc, OPJ_UINT32 d);
-/**
-BYPASS mode switch, flush operation
-@param mqc MQC handle
-@param erterm 1 if ERTERM is enabled, 0 otherwise
-*/
-void opj_mqc_bypass_flush_enc(opj_mqc_t *mqc, OPJ_BOOL erterm);
-/**
-RESET mode switch
-@param mqc MQC handle
-*/
-void opj_mqc_reset_enc(opj_mqc_t *mqc);
-
-#ifdef notdef
-/**
-RESTART mode switch (TERMALL)
-@param mqc MQC handle
-@return Returns 1 (always)
-*/
-OPJ_UINT32 opj_mqc_restart_enc(opj_mqc_t *mqc);
-#endif
-
-/**
-RESTART mode switch (TERMALL) reinitialisation
-@param mqc MQC handle
-*/
-void opj_mqc_restart_init_enc(opj_mqc_t *mqc);
-/**
-ERTERM mode switch (PTERM)
-@param mqc MQC handle
-*/
-void opj_mqc_erterm_enc(opj_mqc_t *mqc);
-/**
-SEGMARK mode switch (SEGSYM)
-@param mqc MQC handle
-*/
-void opj_mqc_segmark_enc(opj_mqc_t *mqc);
-
-/**
-Initialize the decoder for MQ decoding.
-
-opj_mqc_finish_dec() must be absolutely called after finishing the decoding
-passes, so as to restore the bytes temporarily overwritten.
-
-@param mqc MQC handle
-@param bp Pointer to the start of the buffer from which the bytes will be read
- Note that OPJ_COMMON_CBLK_DATA_EXTRA bytes at the end of the buffer
- will be temporarily overwritten with an artificial 0xFF 0xFF marker.
- (they will be backuped in the mqc structure to be restored later)
- So bp must be at least len + OPJ_COMMON_CBLK_DATA_EXTRA large, and
- writable.
-@param len Length of the input buffer
-@param extra_writable_bytes Indicate how many bytes after len are writable.
- This is to indicate your consent that bp must be
- large enough.
-*/
-void opj_mqc_init_dec(opj_mqc_t *mqc, OPJ_BYTE *bp, OPJ_UINT32 len,
- OPJ_UINT32 extra_writable_bytes);
-
-/**
-Initialize the decoder for RAW decoding.
-
-opj_mqc_finish_dec() must be absolutely called after finishing the decoding
-passes, so as to restore the bytes temporarily overwritten.
-
-@param mqc MQC handle
-@param bp Pointer to the start of the buffer from which the bytes will be read
- Note that OPJ_COMMON_CBLK_DATA_EXTRA bytes at the end of the buffer
- will be temporarily overwritten with an artificial 0xFF 0xFF marker.
- (they will be backuped in the mqc structure to be restored later)
- So bp must be at least len + OPJ_COMMON_CBLK_DATA_EXTRA large, and
- writable.
-@param len Length of the input buffer
-@param extra_writable_bytes Indicate how many bytes after len are writable.
- This is to indicate your consent that bp must be
- large enough.
-*/
-void opj_mqc_raw_init_dec(opj_mqc_t *mqc, OPJ_BYTE *bp, OPJ_UINT32 len,
- OPJ_UINT32 extra_writable_bytes);
-
-
-/**
-Terminate RAW/MQC decoding
-
-This restores the bytes temporarily overwritten by opj_mqc_init_dec()/
-opj_mqc_raw_init_dec()
-
-@param mqc MQC handle
-*/
-void opq_mqc_finish_dec(opj_mqc_t *mqc);
-
-/**
-Decode a symbol
-@param mqc MQC handle
-@return Returns the decoded symbol (0 or 1)
-*/
-/*static INLINE OPJ_UINT32 opj_mqc_decode(opj_mqc_t * const mqc);*/
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* OPJ_MQC_H */
diff --git a/contrib/libs/openjpeg/mqc_inl.h b/contrib/libs/openjpeg/mqc_inl.h
deleted file mode 100644
index 0031b94be3..0000000000
--- a/contrib/libs/openjpeg/mqc_inl.h
+++ /dev/null
@@ -1,282 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2014, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux
- * Copyright (c) 2003-2014, Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef OPJ_MQC_INL_H
-#define OPJ_MQC_INL_H
-
-/* For internal use of opj_mqc_decode_macro() */
-#define opj_mqc_mpsexchange_macro(d, curctx, a) \
-{ \
- if (a < (*curctx)->qeval) { \
- d = !((*curctx)->mps); \
- *curctx = (*curctx)->nlps; \
- } else { \
- d = (*curctx)->mps; \
- *curctx = (*curctx)->nmps; \
- } \
-}
-
-/* For internal use of opj_mqc_decode_macro() */
-#define opj_mqc_lpsexchange_macro(d, curctx, a) \
-{ \
- if (a < (*curctx)->qeval) { \
- a = (*curctx)->qeval; \
- d = (*curctx)->mps; \
- *curctx = (*curctx)->nmps; \
- } else { \
- a = (*curctx)->qeval; \
- d = !((*curctx)->mps); \
- *curctx = (*curctx)->nlps; \
- } \
-}
-
-
-/**
-Decode a symbol using raw-decoder. Cfr p.506 TAUBMAN
-@param mqc MQC handle
-@return Returns the decoded symbol (0 or 1)
-*/
-static INLINE OPJ_UINT32 opj_mqc_raw_decode(opj_mqc_t *mqc)
-{
- OPJ_UINT32 d;
- if (mqc->ct == 0) {
- /* Given opj_mqc_raw_init_dec() we know that at some point we will */
- /* have a 0xFF 0xFF artificial marker */
- if (mqc->c == 0xff) {
- if (*mqc->bp > 0x8f) {
- mqc->c = 0xff;
- mqc->ct = 8;
- } else {
- mqc->c = *mqc->bp;
- mqc->bp ++;
- mqc->ct = 7;
- }
- } else {
- mqc->c = *mqc->bp;
- mqc->bp ++;
- mqc->ct = 8;
- }
- }
- mqc->ct--;
- d = ((OPJ_UINT32)mqc->c >> mqc->ct) & 0x01U;
-
- return d;
-}
-
-
-#define opj_mqc_bytein_macro(mqc, c, ct) \
-{ \
- OPJ_UINT32 l_c; \
- /* Given opj_mqc_init_dec() we know that at some point we will */ \
- /* have a 0xFF 0xFF artificial marker */ \
- l_c = *(mqc->bp + 1); \
- if (*mqc->bp == 0xff) { \
- if (l_c > 0x8f) { \
- c += 0xff00; \
- ct = 8; \
- mqc->end_of_byte_stream_counter ++; \
- } else { \
- mqc->bp++; \
- c += l_c << 9; \
- ct = 7; \
- } \
- } else { \
- mqc->bp++; \
- c += l_c << 8; \
- ct = 8; \
- } \
-}
-
-/* For internal use of opj_mqc_decode_macro() */
-#define opj_mqc_renormd_macro(mqc, a, c, ct) \
-{ \
- do { \
- if (ct == 0) { \
- opj_mqc_bytein_macro(mqc, c, ct); \
- } \
- a <<= 1; \
- c <<= 1; \
- ct--; \
- } while (a < 0x8000); \
-}
-
-#define opj_mqc_decode_macro(d, mqc, curctx, a, c, ct) \
-{ \
- /* Implements ISO 15444-1 C.3.2 Decoding a decision (DECODE) */ \
- /* Note: alternate "J.2 - Decoding an MPS or an LPS in the */ \
- /* software-conventions decoder" has been tried, but does not bring any */ \
- /* improvement. See https://github.com/uclouvain/openjpeg/issues/921 */ \
- a -= (*curctx)->qeval; \
- if ((c >> 16) < (*curctx)->qeval) { \
- opj_mqc_lpsexchange_macro(d, curctx, a); \
- opj_mqc_renormd_macro(mqc, a, c, ct); \
- } else { \
- c -= (*curctx)->qeval << 16; \
- if ((a & 0x8000) == 0) { \
- opj_mqc_mpsexchange_macro(d, curctx, a); \
- opj_mqc_renormd_macro(mqc, a, c, ct); \
- } else { \
- d = (*curctx)->mps; \
- } \
- } \
-}
-
-#define DOWNLOAD_MQC_VARIABLES(mqc, curctx, a, c, ct) \
- register const opj_mqc_state_t **curctx = mqc->curctx; \
- register OPJ_UINT32 c = mqc->c; \
- register OPJ_UINT32 a = mqc->a; \
- register OPJ_UINT32 ct = mqc->ct
-
-#define UPLOAD_MQC_VARIABLES(mqc, curctx, a, c, ct) \
- mqc->curctx = curctx; \
- mqc->c = c; \
- mqc->a = a; \
- mqc->ct = ct;
-
-/**
-Input a byte
-@param mqc MQC handle
-*/
-static INLINE void opj_mqc_bytein(opj_mqc_t *const mqc)
-{
- opj_mqc_bytein_macro(mqc, mqc->c, mqc->ct);
-}
-
-/**
-Renormalize mqc->a and mqc->c while decoding
-@param mqc MQC handle
-*/
-#define opj_mqc_renormd(mqc) \
- opj_mqc_renormd_macro(mqc, mqc->a, mqc->c, mqc->ct)
-
-/**
-Decode a symbol
-@param d OPJ_UINT32 value where to store the decoded symbol
-@param mqc MQC handle
-@return Returns the decoded symbol (0 or 1) in d
-*/
-#define opj_mqc_decode(d, mqc) \
- opj_mqc_decode_macro(d, mqc, mqc->curctx, mqc->a, mqc->c, mqc->ct)
-
-/**
-Output a byte, doing bit-stuffing if necessary.
-After a 0xff byte, the next byte must be smaller than 0x90.
-@param mqc MQC handle
-*/
-void opj_mqc_byteout(opj_mqc_t *mqc);
-
-/**
-Renormalize mqc->a and mqc->c while encoding, so that mqc->a stays between 0x8000 and 0x10000
-@param mqc MQC handle
-@param a_ value of mqc->a
-@param c_ value of mqc->c_
-@param ct_ value of mqc->ct_
-*/
-#define opj_mqc_renorme_macro(mqc, a_, c_, ct_) \
-{ \
- do { \
- a_ <<= 1; \
- c_ <<= 1; \
- ct_--; \
- if (ct_ == 0) { \
- mqc->c = c_; \
- opj_mqc_byteout(mqc); \
- c_ = mqc->c; \
- ct_ = mqc->ct; \
- } \
- } while( (a_ & 0x8000) == 0); \
-}
-
-#define opj_mqc_codemps_macro(mqc, curctx, a, c, ct) \
-{ \
- a -= (*curctx)->qeval; \
- if ((a & 0x8000) == 0) { \
- if (a < (*curctx)->qeval) { \
- a = (*curctx)->qeval; \
- } else { \
- c += (*curctx)->qeval; \
- } \
- *curctx = (*curctx)->nmps; \
- opj_mqc_renorme_macro(mqc, a, c, ct); \
- } else { \
- c += (*curctx)->qeval; \
- } \
-}
-
-#define opj_mqc_codelps_macro(mqc, curctx, a, c, ct) \
-{ \
- a -= (*curctx)->qeval; \
- if (a < (*curctx)->qeval) { \
- c += (*curctx)->qeval; \
- } else { \
- a = (*curctx)->qeval; \
- } \
- *curctx = (*curctx)->nlps; \
- opj_mqc_renorme_macro(mqc, a, c, ct); \
-}
-
-#define opj_mqc_encode_macro(mqc, curctx, a, c, ct, d) \
-{ \
- if ((*curctx)->mps == (d)) { \
- opj_mqc_codemps_macro(mqc, curctx, a, c, ct); \
- } else { \
- opj_mqc_codelps_macro(mqc, curctx, a, c, ct); \
- } \
-}
-
-
-#define opj_mqc_bypass_enc_macro(mqc, c, ct, d) \
-{\
- if (ct == BYPASS_CT_INIT) {\
- ct = 8;\
- }\
- ct--;\
- c = c + ((d) << ct);\
- if (ct == 0) {\
- *mqc->bp = (OPJ_BYTE)c;\
- ct = 8;\
- /* If the previous byte was 0xff, make sure that the next msb is 0 */ \
- if (*mqc->bp == 0xff) {\
- ct = 7;\
- }\
- mqc->bp++;\
- c = 0;\
- }\
-}
-
-#endif /* OPJ_MQC_INL_H */
diff --git a/contrib/libs/openjpeg/openjpeg.c b/contrib/libs/openjpeg/openjpeg.c
deleted file mode 100644
index 382d8f4f0f..0000000000
--- a/contrib/libs/openjpeg/openjpeg.c
+++ /dev/null
@@ -1,1144 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR
- * Copyright (c) 2012, CS Systemes d'Information, France
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifdef _WIN32
-#include <windows.h>
-#endif /* _WIN32 */
-
-#include "opj_includes.h"
-
-
-/* ---------------------------------------------------------------------- */
-/* Functions to set the message handlers */
-
-OPJ_BOOL OPJ_CALLCONV opj_set_info_handler(opj_codec_t * p_codec,
- opj_msg_callback p_callback,
- void * p_user_data)
-{
- opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
- if (! l_codec) {
- return OPJ_FALSE;
- }
-
- l_codec->m_event_mgr.info_handler = p_callback;
- l_codec->m_event_mgr.m_info_data = p_user_data;
-
- return OPJ_TRUE;
-}
-
-OPJ_BOOL OPJ_CALLCONV opj_set_warning_handler(opj_codec_t * p_codec,
- opj_msg_callback p_callback,
- void * p_user_data)
-{
- opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
- if (! l_codec) {
- return OPJ_FALSE;
- }
-
- l_codec->m_event_mgr.warning_handler = p_callback;
- l_codec->m_event_mgr.m_warning_data = p_user_data;
-
- return OPJ_TRUE;
-}
-
-OPJ_BOOL OPJ_CALLCONV opj_set_error_handler(opj_codec_t * p_codec,
- opj_msg_callback p_callback,
- void * p_user_data)
-{
- opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
- if (! l_codec) {
- return OPJ_FALSE;
- }
-
- l_codec->m_event_mgr.error_handler = p_callback;
- l_codec->m_event_mgr.m_error_data = p_user_data;
-
- return OPJ_TRUE;
-}
-
-/* ---------------------------------------------------------------------- */
-
-static OPJ_SIZE_T opj_read_from_file(void * p_buffer, OPJ_SIZE_T p_nb_bytes,
- void * p_user_data)
-{
- FILE* p_file = (FILE*)p_user_data;
- OPJ_SIZE_T l_nb_read = fread(p_buffer, 1, p_nb_bytes, (FILE*)p_file);
- return l_nb_read ? l_nb_read : (OPJ_SIZE_T) - 1;
-}
-
-static OPJ_UINT64 opj_get_data_length_from_file(void * p_user_data)
-{
- FILE* p_file = (FILE*)p_user_data;
- OPJ_OFF_T file_length = 0;
-
- OPJ_FSEEK(p_file, 0, SEEK_END);
- file_length = (OPJ_OFF_T)OPJ_FTELL(p_file);
- OPJ_FSEEK(p_file, 0, SEEK_SET);
-
- return (OPJ_UINT64)file_length;
-}
-
-static OPJ_SIZE_T opj_write_from_file(void * p_buffer, OPJ_SIZE_T p_nb_bytes,
- void * p_user_data)
-{
- FILE* p_file = (FILE*)p_user_data;
- return fwrite(p_buffer, 1, p_nb_bytes, p_file);
-}
-
-static OPJ_OFF_T opj_skip_from_file(OPJ_OFF_T p_nb_bytes, void * p_user_data)
-{
- FILE* p_file = (FILE*)p_user_data;
- if (OPJ_FSEEK(p_file, p_nb_bytes, SEEK_CUR)) {
- return -1;
- }
-
- return p_nb_bytes;
-}
-
-static OPJ_BOOL opj_seek_from_file(OPJ_OFF_T p_nb_bytes, void * p_user_data)
-{
- FILE* p_file = (FILE*)p_user_data;
- if (OPJ_FSEEK(p_file, p_nb_bytes, SEEK_SET)) {
- return OPJ_FALSE;
- }
-
- return OPJ_TRUE;
-}
-
-static void opj_close_from_file(void* p_user_data)
-{
- FILE* p_file = (FILE*)p_user_data;
- fclose(p_file);
-}
-
-/* ---------------------------------------------------------------------- */
-#ifdef _WIN32
-#ifndef OPJ_STATIC
-
-/* declaration to avoid warning: no previous prototype for 'DllMain' */
-BOOL APIENTRY
-DllMain(HINSTANCE hModule, DWORD ul_reason_for_call, LPVOID lpReserved);
-
-BOOL APIENTRY
-DllMain(HINSTANCE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
-{
-
- OPJ_ARG_NOT_USED(lpReserved);
- OPJ_ARG_NOT_USED(hModule);
-
- switch (ul_reason_for_call) {
- case DLL_PROCESS_ATTACH :
- break;
- case DLL_PROCESS_DETACH :
- break;
- case DLL_THREAD_ATTACH :
- case DLL_THREAD_DETACH :
- break;
- }
-
- return TRUE;
-}
-#endif /* OPJ_STATIC */
-#endif /* _WIN32 */
-
-/* ---------------------------------------------------------------------- */
-
-const char* OPJ_CALLCONV opj_version(void)
-{
- return OPJ_PACKAGE_VERSION;
-}
-
-/* ---------------------------------------------------------------------- */
-/* DECOMPRESSION FUNCTIONS*/
-
-opj_codec_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT p_format)
-{
- opj_codec_private_t *l_codec = 00;
-
- l_codec = (opj_codec_private_t*) opj_calloc(1, sizeof(opj_codec_private_t));
- if (!l_codec) {
- return 00;
- }
-
- l_codec->is_decompressor = 1;
-
- switch (p_format) {
- case OPJ_CODEC_J2K:
- l_codec->opj_dump_codec = (void (*)(void*, OPJ_INT32, FILE*)) j2k_dump;
-
- l_codec->opj_get_codec_info = (opj_codestream_info_v2_t* (*)(
- void*)) j2k_get_cstr_info;
-
- l_codec->opj_get_codec_index = (opj_codestream_index_t* (*)(
- void*)) j2k_get_cstr_index;
-
- l_codec->m_codec_data.m_decompression.opj_decode =
- (OPJ_BOOL(*)(void *,
- struct opj_stream_private *,
- opj_image_t*, struct opj_event_mgr *)) opj_j2k_decode;
-
- l_codec->m_codec_data.m_decompression.opj_end_decompress =
- (OPJ_BOOL(*)(void *,
- struct opj_stream_private *,
- struct opj_event_mgr *)) opj_j2k_end_decompress;
-
- l_codec->m_codec_data.m_decompression.opj_read_header =
- (OPJ_BOOL(*)(struct opj_stream_private *,
- void *,
- opj_image_t **,
- struct opj_event_mgr *)) opj_j2k_read_header;
-
- l_codec->m_codec_data.m_decompression.opj_destroy =
- (void (*)(void *))opj_j2k_destroy;
-
- l_codec->m_codec_data.m_decompression.opj_setup_decoder =
- (void (*)(void *, opj_dparameters_t *)) opj_j2k_setup_decoder;
-
- l_codec->m_codec_data.m_decompression.opj_decoder_set_strict_mode =
- (void (*)(void *, OPJ_BOOL)) opj_j2k_decoder_set_strict_mode;
-
-
- l_codec->m_codec_data.m_decompression.opj_read_tile_header =
- (OPJ_BOOL(*)(void *,
- OPJ_UINT32*,
- OPJ_UINT32*,
- OPJ_INT32*, OPJ_INT32*,
- OPJ_INT32*, OPJ_INT32*,
- OPJ_UINT32*,
- OPJ_BOOL*,
- struct opj_stream_private *,
- struct opj_event_mgr *)) opj_j2k_read_tile_header;
-
- l_codec->m_codec_data.m_decompression.opj_decode_tile_data =
- (OPJ_BOOL(*)(void *,
- OPJ_UINT32,
- OPJ_BYTE*,
- OPJ_UINT32,
- struct opj_stream_private *,
- struct opj_event_mgr *)) opj_j2k_decode_tile;
-
- l_codec->m_codec_data.m_decompression.opj_set_decode_area =
- (OPJ_BOOL(*)(void *,
- opj_image_t*,
- OPJ_INT32, OPJ_INT32, OPJ_INT32, OPJ_INT32,
- struct opj_event_mgr *)) opj_j2k_set_decode_area;
-
- l_codec->m_codec_data.m_decompression.opj_get_decoded_tile =
- (OPJ_BOOL(*)(void *p_codec,
- opj_stream_private_t *p_cio,
- opj_image_t *p_image,
- struct opj_event_mgr * p_manager,
- OPJ_UINT32 tile_index)) opj_j2k_get_tile;
-
- l_codec->m_codec_data.m_decompression.opj_set_decoded_resolution_factor =
- (OPJ_BOOL(*)(void * p_codec,
- OPJ_UINT32 res_factor,
- struct opj_event_mgr * p_manager)) opj_j2k_set_decoded_resolution_factor;
-
- l_codec->m_codec_data.m_decompression.opj_set_decoded_components =
- (OPJ_BOOL(*)(void * p_codec,
- OPJ_UINT32 numcomps,
- const OPJ_UINT32 * comps_indices,
- struct opj_event_mgr * p_manager)) opj_j2k_set_decoded_components;
-
- l_codec->opj_set_threads =
- (OPJ_BOOL(*)(void * p_codec, OPJ_UINT32 num_threads)) opj_j2k_set_threads;
-
- l_codec->m_codec = opj_j2k_create_decompress();
-
- if (! l_codec->m_codec) {
- opj_free(l_codec);
- return NULL;
- }
-
- break;
-
- case OPJ_CODEC_JP2:
- /* get a JP2 decoder handle */
- l_codec->opj_dump_codec = (void (*)(void*, OPJ_INT32, FILE*)) jp2_dump;
-
- l_codec->opj_get_codec_info = (opj_codestream_info_v2_t* (*)(
- void*)) jp2_get_cstr_info;
-
- l_codec->opj_get_codec_index = (opj_codestream_index_t* (*)(
- void*)) jp2_get_cstr_index;
-
- l_codec->m_codec_data.m_decompression.opj_decode =
- (OPJ_BOOL(*)(void *,
- struct opj_stream_private *,
- opj_image_t*,
- struct opj_event_mgr *)) opj_jp2_decode;
-
- l_codec->m_codec_data.m_decompression.opj_end_decompress =
- (OPJ_BOOL(*)(void *,
- struct opj_stream_private *,
- struct opj_event_mgr *)) opj_jp2_end_decompress;
-
- l_codec->m_codec_data.m_decompression.opj_read_header =
- (OPJ_BOOL(*)(struct opj_stream_private *,
- void *,
- opj_image_t **,
- struct opj_event_mgr *)) opj_jp2_read_header;
-
- l_codec->m_codec_data.m_decompression.opj_read_tile_header =
- (OPJ_BOOL(*)(void *,
- OPJ_UINT32*,
- OPJ_UINT32*,
- OPJ_INT32*,
- OPJ_INT32*,
- OPJ_INT32 *,
- OPJ_INT32 *,
- OPJ_UINT32 *,
- OPJ_BOOL *,
- struct opj_stream_private *,
- struct opj_event_mgr *)) opj_jp2_read_tile_header;
-
- l_codec->m_codec_data.m_decompression.opj_decode_tile_data =
- (OPJ_BOOL(*)(void *,
- OPJ_UINT32, OPJ_BYTE*, OPJ_UINT32,
- struct opj_stream_private *,
- struct opj_event_mgr *)) opj_jp2_decode_tile;
-
- l_codec->m_codec_data.m_decompression.opj_destroy = (void (*)(
- void *))opj_jp2_destroy;
-
- l_codec->m_codec_data.m_decompression.opj_setup_decoder =
- (void (*)(void *, opj_dparameters_t *)) opj_jp2_setup_decoder;
-
- l_codec->m_codec_data.m_decompression.opj_decoder_set_strict_mode =
- (void (*)(void *, OPJ_BOOL)) opj_jp2_decoder_set_strict_mode;
-
- l_codec->m_codec_data.m_decompression.opj_set_decode_area =
- (OPJ_BOOL(*)(void *,
- opj_image_t*,
- OPJ_INT32, OPJ_INT32, OPJ_INT32, OPJ_INT32,
- struct opj_event_mgr *)) opj_jp2_set_decode_area;
-
- l_codec->m_codec_data.m_decompression.opj_get_decoded_tile =
- (OPJ_BOOL(*)(void *p_codec,
- opj_stream_private_t *p_cio,
- opj_image_t *p_image,
- struct opj_event_mgr * p_manager,
- OPJ_UINT32 tile_index)) opj_jp2_get_tile;
-
- l_codec->m_codec_data.m_decompression.opj_set_decoded_resolution_factor =
- (OPJ_BOOL(*)(void * p_codec,
- OPJ_UINT32 res_factor,
- opj_event_mgr_t * p_manager)) opj_jp2_set_decoded_resolution_factor;
-
- l_codec->m_codec_data.m_decompression.opj_set_decoded_components =
- (OPJ_BOOL(*)(void * p_codec,
- OPJ_UINT32 numcomps,
- const OPJ_UINT32 * comps_indices,
- struct opj_event_mgr * p_manager)) opj_jp2_set_decoded_components;
-
- l_codec->opj_set_threads =
- (OPJ_BOOL(*)(void * p_codec, OPJ_UINT32 num_threads)) opj_jp2_set_threads;
-
- l_codec->m_codec = opj_jp2_create(OPJ_TRUE);
-
- if (! l_codec->m_codec) {
- opj_free(l_codec);
- return 00;
- }
-
- break;
- case OPJ_CODEC_UNKNOWN:
- case OPJ_CODEC_JPT:
- default:
- opj_free(l_codec);
- return 00;
- }
-
- opj_set_default_event_handler(&(l_codec->m_event_mgr));
- return (opj_codec_t*) l_codec;
-}
-
-void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t
- *parameters)
-{
- if (parameters) {
- memset(parameters, 0, sizeof(opj_dparameters_t));
- /* default decoding parameters */
- parameters->cp_layer = 0;
- parameters->cp_reduce = 0;
-
- parameters->decod_format = -1;
- parameters->cod_format = -1;
- parameters->flags = 0;
- /* UniPG>> */
-#ifdef USE_JPWL
- parameters->jpwl_correct = OPJ_FALSE;
- parameters->jpwl_exp_comps = JPWL_EXPECTED_COMPONENTS;
- parameters->jpwl_max_tiles = JPWL_MAXIMUM_TILES;
-#endif /* USE_JPWL */
- /* <<UniPG */
- }
-}
-
-
-OPJ_BOOL OPJ_CALLCONV opj_codec_set_threads(opj_codec_t *p_codec,
- int num_threads)
-{
- if (p_codec && (num_threads >= 0)) {
- opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
-
- return l_codec->opj_set_threads(l_codec->m_codec, (OPJ_UINT32)num_threads);
- }
- return OPJ_FALSE;
-}
-
-OPJ_BOOL OPJ_CALLCONV opj_setup_decoder(opj_codec_t *p_codec,
- opj_dparameters_t *parameters
- )
-{
- if (p_codec && parameters) {
- opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
-
- if (! l_codec->is_decompressor) {
- opj_event_msg(&(l_codec->m_event_mgr), EVT_ERROR,
- "Codec provided to the opj_setup_decoder function is not a decompressor handler.\n");
- return OPJ_FALSE;
- }
-
- l_codec->m_codec_data.m_decompression.opj_setup_decoder(l_codec->m_codec,
- parameters);
- return OPJ_TRUE;
- }
- return OPJ_FALSE;
-}
-
-OPJ_BOOL OPJ_CALLCONV opj_decoder_set_strict_mode(opj_codec_t *p_codec,
- OPJ_BOOL strict)
-{
- if (p_codec) {
- opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
-
- if (! l_codec->is_decompressor) {
- opj_event_msg(&(l_codec->m_event_mgr), EVT_ERROR,
- "Codec provided to the opj_decoder_set_strict_mode function is not a decompressor handler.\n");
- return OPJ_FALSE;
- }
-
- l_codec->m_codec_data.m_decompression.opj_decoder_set_strict_mode(
- l_codec->m_codec,
- strict);
- return OPJ_TRUE;
- }
- return OPJ_FALSE;
-}
-
-OPJ_BOOL OPJ_CALLCONV opj_read_header(opj_stream_t *p_stream,
- opj_codec_t *p_codec,
- opj_image_t **p_image)
-{
- if (p_codec && p_stream) {
- opj_codec_private_t* l_codec = (opj_codec_private_t*) p_codec;
- opj_stream_private_t* l_stream = (opj_stream_private_t*) p_stream;
-
- if (! l_codec->is_decompressor) {
- opj_event_msg(&(l_codec->m_event_mgr), EVT_ERROR,
- "Codec provided to the opj_read_header function is not a decompressor handler.\n");
- return OPJ_FALSE;
- }
-
- return l_codec->m_codec_data.m_decompression.opj_read_header(l_stream,
- l_codec->m_codec,
- p_image,
- &(l_codec->m_event_mgr));
- }
-
- return OPJ_FALSE;
-}
-
-
-OPJ_BOOL OPJ_CALLCONV opj_set_decoded_components(opj_codec_t *p_codec,
- OPJ_UINT32 numcomps,
- const OPJ_UINT32* comps_indices,
- OPJ_BOOL apply_color_transforms)
-{
- if (p_codec) {
- opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
-
- if (! l_codec->is_decompressor) {
- opj_event_msg(&(l_codec->m_event_mgr), EVT_ERROR,
- "Codec provided to the opj_set_decoded_components function is not a decompressor handler.\n");
- return OPJ_FALSE;
- }
-
- if (apply_color_transforms) {
- opj_event_msg(&(l_codec->m_event_mgr), EVT_ERROR,
- "apply_color_transforms = OPJ_TRUE is not supported.\n");
- return OPJ_FALSE;
- }
-
- return l_codec->m_codec_data.m_decompression.opj_set_decoded_components(
- l_codec->m_codec,
- numcomps,
- comps_indices,
- &(l_codec->m_event_mgr));
- }
- return OPJ_FALSE;
-}
-
-OPJ_BOOL OPJ_CALLCONV opj_decode(opj_codec_t *p_codec,
- opj_stream_t *p_stream,
- opj_image_t* p_image)
-{
- if (p_codec && p_stream) {
- opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
- opj_stream_private_t * l_stream = (opj_stream_private_t *) p_stream;
-
- if (! l_codec->is_decompressor) {
- return OPJ_FALSE;
- }
-
- return l_codec->m_codec_data.m_decompression.opj_decode(l_codec->m_codec,
- l_stream,
- p_image,
- &(l_codec->m_event_mgr));
- }
-
- return OPJ_FALSE;
-}
-
-OPJ_BOOL OPJ_CALLCONV opj_set_decode_area(opj_codec_t *p_codec,
- opj_image_t* p_image,
- OPJ_INT32 p_start_x, OPJ_INT32 p_start_y,
- OPJ_INT32 p_end_x, OPJ_INT32 p_end_y
- )
-{
- if (p_codec) {
- opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
-
- if (! l_codec->is_decompressor) {
- return OPJ_FALSE;
- }
-
- return l_codec->m_codec_data.m_decompression.opj_set_decode_area(
- l_codec->m_codec,
- p_image,
- p_start_x, p_start_y,
- p_end_x, p_end_y,
- &(l_codec->m_event_mgr));
- }
- return OPJ_FALSE;
-}
-
-OPJ_BOOL OPJ_CALLCONV opj_read_tile_header(opj_codec_t *p_codec,
- opj_stream_t * p_stream,
- OPJ_UINT32 * p_tile_index,
- OPJ_UINT32 * p_data_size,
- OPJ_INT32 * p_tile_x0, OPJ_INT32 * p_tile_y0,
- OPJ_INT32 * p_tile_x1, OPJ_INT32 * p_tile_y1,
- OPJ_UINT32 * p_nb_comps,
- OPJ_BOOL * p_should_go_on)
-{
- if (p_codec && p_stream && p_data_size && p_tile_index) {
- opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
- opj_stream_private_t * l_stream = (opj_stream_private_t *) p_stream;
-
- if (! l_codec->is_decompressor) {
- return OPJ_FALSE;
- }
-
- return l_codec->m_codec_data.m_decompression.opj_read_tile_header(
- l_codec->m_codec,
- p_tile_index,
- p_data_size,
- p_tile_x0, p_tile_y0,
- p_tile_x1, p_tile_y1,
- p_nb_comps,
- p_should_go_on,
- l_stream,
- &(l_codec->m_event_mgr));
- }
- return OPJ_FALSE;
-}
-
-OPJ_BOOL OPJ_CALLCONV opj_decode_tile_data(opj_codec_t *p_codec,
- OPJ_UINT32 p_tile_index,
- OPJ_BYTE * p_data,
- OPJ_UINT32 p_data_size,
- opj_stream_t *p_stream
- )
-{
- if (p_codec && p_data && p_stream) {
- opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
- opj_stream_private_t * l_stream = (opj_stream_private_t *) p_stream;
-
- if (! l_codec->is_decompressor) {
- return OPJ_FALSE;
- }
-
- return l_codec->m_codec_data.m_decompression.opj_decode_tile_data(
- l_codec->m_codec,
- p_tile_index,
- p_data,
- p_data_size,
- l_stream,
- &(l_codec->m_event_mgr));
- }
- return OPJ_FALSE;
-}
-
-OPJ_BOOL OPJ_CALLCONV opj_get_decoded_tile(opj_codec_t *p_codec,
- opj_stream_t *p_stream,
- opj_image_t *p_image,
- OPJ_UINT32 tile_index)
-{
- if (p_codec && p_stream) {
- opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
- opj_stream_private_t * l_stream = (opj_stream_private_t *) p_stream;
-
- if (! l_codec->is_decompressor) {
- return OPJ_FALSE;
- }
-
- return l_codec->m_codec_data.m_decompression.opj_get_decoded_tile(
- l_codec->m_codec,
- l_stream,
- p_image,
- &(l_codec->m_event_mgr),
- tile_index);
- }
-
- return OPJ_FALSE;
-}
-
-OPJ_BOOL OPJ_CALLCONV opj_set_decoded_resolution_factor(opj_codec_t *p_codec,
- OPJ_UINT32 res_factor)
-{
- opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
-
- if (!l_codec) {
- return OPJ_FALSE;
- }
-
- return l_codec->m_codec_data.m_decompression.opj_set_decoded_resolution_factor(
- l_codec->m_codec,
- res_factor,
- &(l_codec->m_event_mgr));
-}
-
-/* ---------------------------------------------------------------------- */
-/* COMPRESSION FUNCTIONS*/
-
-opj_codec_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT p_format)
-{
- opj_codec_private_t *l_codec = 00;
-
- l_codec = (opj_codec_private_t*)opj_calloc(1, sizeof(opj_codec_private_t));
- if (!l_codec) {
- return 00;
- }
-
- l_codec->is_decompressor = 0;
-
- switch (p_format) {
- case OPJ_CODEC_J2K:
- l_codec->m_codec_data.m_compression.opj_encode = (OPJ_BOOL(*)(void *,
- struct opj_stream_private *,
- struct opj_event_mgr *)) opj_j2k_encode;
-
- l_codec->m_codec_data.m_compression.opj_end_compress = (OPJ_BOOL(*)(void *,
- struct opj_stream_private *,
- struct opj_event_mgr *)) opj_j2k_end_compress;
-
- l_codec->m_codec_data.m_compression.opj_start_compress = (OPJ_BOOL(*)(void *,
- struct opj_stream_private *,
- struct opj_image *,
- struct opj_event_mgr *)) opj_j2k_start_compress;
-
- l_codec->m_codec_data.m_compression.opj_write_tile = (OPJ_BOOL(*)(void *,
- OPJ_UINT32,
- OPJ_BYTE*,
- OPJ_UINT32,
- struct opj_stream_private *,
- struct opj_event_mgr *)) opj_j2k_write_tile;
-
- l_codec->m_codec_data.m_compression.opj_destroy = (void (*)(
- void *)) opj_j2k_destroy;
-
- l_codec->m_codec_data.m_compression.opj_setup_encoder = (OPJ_BOOL(*)(void *,
- opj_cparameters_t *,
- struct opj_image *,
- struct opj_event_mgr *)) opj_j2k_setup_encoder;
-
- l_codec->m_codec_data.m_compression.opj_encoder_set_extra_options = (OPJ_BOOL(
- *)(void *,
- const char* const*,
- struct opj_event_mgr *)) opj_j2k_encoder_set_extra_options;
-
- l_codec->opj_set_threads =
- (OPJ_BOOL(*)(void * p_codec, OPJ_UINT32 num_threads)) opj_j2k_set_threads;
-
- l_codec->m_codec = opj_j2k_create_compress();
- if (! l_codec->m_codec) {
- opj_free(l_codec);
- return 00;
- }
-
- break;
-
- case OPJ_CODEC_JP2:
- /* get a JP2 decoder handle */
- l_codec->m_codec_data.m_compression.opj_encode = (OPJ_BOOL(*)(void *,
- struct opj_stream_private *,
- struct opj_event_mgr *)) opj_jp2_encode;
-
- l_codec->m_codec_data.m_compression.opj_end_compress = (OPJ_BOOL(*)(void *,
- struct opj_stream_private *,
- struct opj_event_mgr *)) opj_jp2_end_compress;
-
- l_codec->m_codec_data.m_compression.opj_start_compress = (OPJ_BOOL(*)(void *,
- struct opj_stream_private *,
- struct opj_image *,
- struct opj_event_mgr *)) opj_jp2_start_compress;
-
- l_codec->m_codec_data.m_compression.opj_write_tile = (OPJ_BOOL(*)(void *,
- OPJ_UINT32,
- OPJ_BYTE*,
- OPJ_UINT32,
- struct opj_stream_private *,
- struct opj_event_mgr *)) opj_jp2_write_tile;
-
- l_codec->m_codec_data.m_compression.opj_destroy = (void (*)(
- void *)) opj_jp2_destroy;
-
- l_codec->m_codec_data.m_compression.opj_setup_encoder = (OPJ_BOOL(*)(void *,
- opj_cparameters_t *,
- struct opj_image *,
- struct opj_event_mgr *)) opj_jp2_setup_encoder;
-
- l_codec->m_codec_data.m_compression.opj_encoder_set_extra_options = (OPJ_BOOL(
- *)(void *,
- const char* const*,
- struct opj_event_mgr *)) opj_jp2_encoder_set_extra_options;
-
- l_codec->opj_set_threads =
- (OPJ_BOOL(*)(void * p_codec, OPJ_UINT32 num_threads)) opj_jp2_set_threads;
-
- l_codec->m_codec = opj_jp2_create(OPJ_FALSE);
- if (! l_codec->m_codec) {
- opj_free(l_codec);
- return 00;
- }
-
- break;
-
- case OPJ_CODEC_UNKNOWN:
- case OPJ_CODEC_JPT:
- default:
- opj_free(l_codec);
- return 00;
- }
-
- opj_set_default_event_handler(&(l_codec->m_event_mgr));
- return (opj_codec_t*) l_codec;
-}
-
-void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t
- *parameters)
-{
- if (parameters) {
- memset(parameters, 0, sizeof(opj_cparameters_t));
- /* default coding parameters */
- parameters->cp_cinema = OPJ_OFF; /* DEPRECATED */
- parameters->rsiz = OPJ_PROFILE_NONE;
- parameters->max_comp_size = 0;
- parameters->numresolution = OPJ_COMP_PARAM_DEFAULT_NUMRESOLUTION;
- parameters->cp_rsiz = OPJ_STD_RSIZ; /* DEPRECATED */
- parameters->cblockw_init = OPJ_COMP_PARAM_DEFAULT_CBLOCKW;
- parameters->cblockh_init = OPJ_COMP_PARAM_DEFAULT_CBLOCKH;
- parameters->prog_order = OPJ_COMP_PARAM_DEFAULT_PROG_ORDER;
- parameters->roi_compno = -1; /* no ROI */
- parameters->subsampling_dx = 1;
- parameters->subsampling_dy = 1;
- parameters->tp_on = 0;
- parameters->decod_format = -1;
- parameters->cod_format = -1;
- parameters->tcp_rates[0] = 0;
- parameters->tcp_numlayers = 0;
- parameters->cp_disto_alloc = 0;
- parameters->cp_fixed_alloc = 0;
- parameters->cp_fixed_quality = 0;
- parameters->jpip_on = OPJ_FALSE;
- /* UniPG>> */
-#ifdef USE_JPWL
- parameters->jpwl_epc_on = OPJ_FALSE;
- parameters->jpwl_hprot_MH = -1; /* -1 means unassigned */
- {
- int i;
- for (i = 0; i < JPWL_MAX_NO_TILESPECS; i++) {
- parameters->jpwl_hprot_TPH_tileno[i] = -1; /* unassigned */
- parameters->jpwl_hprot_TPH[i] = 0; /* absent */
- }
- };
- {
- int i;
- for (i = 0; i < JPWL_MAX_NO_PACKSPECS; i++) {
- parameters->jpwl_pprot_tileno[i] = -1; /* unassigned */
- parameters->jpwl_pprot_packno[i] = -1; /* unassigned */
- parameters->jpwl_pprot[i] = 0; /* absent */
- }
- };
- parameters->jpwl_sens_size = 0; /* 0 means no ESD */
- parameters->jpwl_sens_addr = 0; /* 0 means auto */
- parameters->jpwl_sens_range = 0; /* 0 means packet */
- parameters->jpwl_sens_MH = -1; /* -1 means unassigned */
- {
- int i;
- for (i = 0; i < JPWL_MAX_NO_TILESPECS; i++) {
- parameters->jpwl_sens_TPH_tileno[i] = -1; /* unassigned */
- parameters->jpwl_sens_TPH[i] = -1; /* absent */
- }
- };
-#endif /* USE_JPWL */
- /* <<UniPG */
- }
-}
-
-OPJ_BOOL OPJ_CALLCONV opj_setup_encoder(opj_codec_t *p_codec,
- opj_cparameters_t *parameters,
- opj_image_t *p_image)
-{
- if (p_codec && parameters && p_image) {
- opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
-
- if (! l_codec->is_decompressor) {
- return l_codec->m_codec_data.m_compression.opj_setup_encoder(l_codec->m_codec,
- parameters,
- p_image,
- &(l_codec->m_event_mgr));
- }
- }
-
- return OPJ_FALSE;
-}
-
-/* ----------------------------------------------------------------------- */
-
-OPJ_BOOL OPJ_CALLCONV opj_encoder_set_extra_options(opj_codec_t *p_codec,
- const char* const* options)
-{
- if (p_codec) {
- opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
-
- if (! l_codec->is_decompressor) {
- return l_codec->m_codec_data.m_compression.opj_encoder_set_extra_options(
- l_codec->m_codec,
- options,
- &(l_codec->m_event_mgr));
- }
- }
-
- return OPJ_FALSE;
-}
-
-/* ----------------------------------------------------------------------- */
-
-OPJ_BOOL OPJ_CALLCONV opj_start_compress(opj_codec_t *p_codec,
- opj_image_t * p_image,
- opj_stream_t *p_stream)
-{
- if (p_codec && p_stream) {
- opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
- opj_stream_private_t * l_stream = (opj_stream_private_t *) p_stream;
-
- if (! l_codec->is_decompressor) {
- return l_codec->m_codec_data.m_compression.opj_start_compress(l_codec->m_codec,
- l_stream,
- p_image,
- &(l_codec->m_event_mgr));
- }
- }
-
- return OPJ_FALSE;
-}
-
-OPJ_BOOL OPJ_CALLCONV opj_encode(opj_codec_t *p_info, opj_stream_t *p_stream)
-{
- if (p_info && p_stream) {
- opj_codec_private_t * l_codec = (opj_codec_private_t *) p_info;
- opj_stream_private_t * l_stream = (opj_stream_private_t *) p_stream;
-
- if (! l_codec->is_decompressor) {
- return l_codec->m_codec_data.m_compression.opj_encode(l_codec->m_codec,
- l_stream,
- &(l_codec->m_event_mgr));
- }
- }
-
- return OPJ_FALSE;
-
-}
-
-OPJ_BOOL OPJ_CALLCONV opj_end_compress(opj_codec_t *p_codec,
- opj_stream_t *p_stream)
-{
- if (p_codec && p_stream) {
- opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
- opj_stream_private_t * l_stream = (opj_stream_private_t *) p_stream;
-
- if (! l_codec->is_decompressor) {
- return l_codec->m_codec_data.m_compression.opj_end_compress(l_codec->m_codec,
- l_stream,
- &(l_codec->m_event_mgr));
- }
- }
- return OPJ_FALSE;
-
-}
-
-OPJ_BOOL OPJ_CALLCONV opj_end_decompress(opj_codec_t *p_codec,
- opj_stream_t *p_stream)
-{
- if (p_codec && p_stream) {
- opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
- opj_stream_private_t * l_stream = (opj_stream_private_t *) p_stream;
-
- if (! l_codec->is_decompressor) {
- return OPJ_FALSE;
- }
-
- return l_codec->m_codec_data.m_decompression.opj_end_decompress(
- l_codec->m_codec,
- l_stream,
- &(l_codec->m_event_mgr));
- }
-
- return OPJ_FALSE;
-}
-
-OPJ_BOOL OPJ_CALLCONV opj_set_MCT(opj_cparameters_t *parameters,
- OPJ_FLOAT32 * pEncodingMatrix,
- OPJ_INT32 * p_dc_shift, OPJ_UINT32 pNbComp)
-{
- OPJ_UINT32 l_matrix_size = pNbComp * pNbComp * (OPJ_UINT32)sizeof(OPJ_FLOAT32);
- OPJ_UINT32 l_dc_shift_size = pNbComp * (OPJ_UINT32)sizeof(OPJ_INT32);
- OPJ_UINT32 l_mct_total_size = l_matrix_size + l_dc_shift_size;
-
- /* add MCT capability */
- if (OPJ_IS_PART2(parameters->rsiz)) {
- parameters->rsiz |= OPJ_EXTENSION_MCT;
- } else {
- parameters->rsiz = ((OPJ_PROFILE_PART2) | (OPJ_EXTENSION_MCT));
- }
- parameters->irreversible = 1;
-
- /* use array based MCT */
- parameters->tcp_mct = 2;
- parameters->mct_data = opj_malloc(l_mct_total_size);
- if (! parameters->mct_data) {
- return OPJ_FALSE;
- }
-
- memcpy(parameters->mct_data, pEncodingMatrix, l_matrix_size);
- memcpy(((OPJ_BYTE *) parameters->mct_data) + l_matrix_size, p_dc_shift,
- l_dc_shift_size);
-
- return OPJ_TRUE;
-}
-
-OPJ_BOOL OPJ_CALLCONV opj_write_tile(opj_codec_t *p_codec,
- OPJ_UINT32 p_tile_index,
- OPJ_BYTE * p_data,
- OPJ_UINT32 p_data_size,
- opj_stream_t *p_stream)
-{
- if (p_codec && p_stream && p_data) {
- opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
- opj_stream_private_t * l_stream = (opj_stream_private_t *) p_stream;
-
- if (l_codec->is_decompressor) {
- return OPJ_FALSE;
- }
-
- return l_codec->m_codec_data.m_compression.opj_write_tile(l_codec->m_codec,
- p_tile_index,
- p_data,
- p_data_size,
- l_stream,
- &(l_codec->m_event_mgr));
- }
-
- return OPJ_FALSE;
-}
-
-/* ---------------------------------------------------------------------- */
-
-void OPJ_CALLCONV opj_destroy_codec(opj_codec_t *p_codec)
-{
- if (p_codec) {
- opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
-
- if (l_codec->is_decompressor) {
- l_codec->m_codec_data.m_decompression.opj_destroy(l_codec->m_codec);
- } else {
- l_codec->m_codec_data.m_compression.opj_destroy(l_codec->m_codec);
- }
-
- l_codec->m_codec = 00;
- opj_free(l_codec);
- }
-}
-
-/* ---------------------------------------------------------------------- */
-
-void OPJ_CALLCONV opj_dump_codec(opj_codec_t *p_codec,
- OPJ_INT32 info_flag,
- FILE* output_stream)
-{
- if (p_codec) {
- opj_codec_private_t* l_codec = (opj_codec_private_t*) p_codec;
-
- l_codec->opj_dump_codec(l_codec->m_codec, info_flag, output_stream);
- return;
- }
-
- /* TODO return error */
- /* fprintf(stderr, "[ERROR] Input parameter of the dump_codec function are incorrect.\n"); */
- return;
-}
-
-opj_codestream_info_v2_t* OPJ_CALLCONV opj_get_cstr_info(opj_codec_t *p_codec)
-{
- if (p_codec) {
- opj_codec_private_t* l_codec = (opj_codec_private_t*) p_codec;
-
- return l_codec->opj_get_codec_info(l_codec->m_codec);
- }
-
- return NULL;
-}
-
-void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_v2_t **cstr_info)
-{
- if (cstr_info) {
-
- if ((*cstr_info)->m_default_tile_info.tccp_info) {
- opj_free((*cstr_info)->m_default_tile_info.tccp_info);
- }
-
- if ((*cstr_info)->tile_info) {
- /* FIXME not used for the moment*/
- }
-
- opj_free((*cstr_info));
- (*cstr_info) = NULL;
- }
-}
-
-opj_codestream_index_t * OPJ_CALLCONV opj_get_cstr_index(opj_codec_t *p_codec)
-{
- if (p_codec) {
- opj_codec_private_t* l_codec = (opj_codec_private_t*) p_codec;
-
- return l_codec->opj_get_codec_index(l_codec->m_codec);
- }
-
- return NULL;
-}
-
-void OPJ_CALLCONV opj_destroy_cstr_index(opj_codestream_index_t **p_cstr_index)
-{
- if (*p_cstr_index) {
- j2k_destroy_cstr_index(*p_cstr_index);
- (*p_cstr_index) = NULL;
- }
-}
-
-opj_stream_t* OPJ_CALLCONV opj_stream_create_default_file_stream(
- const char *fname, OPJ_BOOL p_is_read_stream)
-{
- return opj_stream_create_file_stream(fname, OPJ_J2K_STREAM_CHUNK_SIZE,
- p_is_read_stream);
-}
-
-opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream(
- const char *fname,
- OPJ_SIZE_T p_size,
- OPJ_BOOL p_is_read_stream)
-{
- opj_stream_t* l_stream = 00;
- FILE *p_file;
- const char *mode;
-
- if (! fname) {
- return NULL;
- }
-
- if (p_is_read_stream) {
- mode = "rb";
- } else {
- mode = "wb";
- }
-
- p_file = fopen(fname, mode);
-
- if (! p_file) {
- return NULL;
- }
-
- l_stream = opj_stream_create(p_size, p_is_read_stream);
- if (! l_stream) {
- fclose(p_file);
- return NULL;
- }
-
- opj_stream_set_user_data(l_stream, p_file, opj_close_from_file);
- opj_stream_set_user_data_length(l_stream,
- opj_get_data_length_from_file(p_file));
- opj_stream_set_read_function(l_stream, opj_read_from_file);
- opj_stream_set_write_function(l_stream,
- (opj_stream_write_fn) opj_write_from_file);
- opj_stream_set_skip_function(l_stream, opj_skip_from_file);
- opj_stream_set_seek_function(l_stream, opj_seek_from_file);
-
- return l_stream;
-}
-
-
-void* OPJ_CALLCONV opj_image_data_alloc(OPJ_SIZE_T size)
-{
- void* ret = opj_aligned_malloc(size);
- /* printf("opj_image_data_alloc %p\n", ret); */
- return ret;
-}
-
-void OPJ_CALLCONV opj_image_data_free(void* ptr)
-{
- /* printf("opj_image_data_free %p\n", ptr); */
- opj_aligned_free(ptr);
-}
diff --git a/contrib/libs/openjpeg/openjpeg.h b/contrib/libs/openjpeg/openjpeg.h
deleted file mode 100644
index 59abd323ae..0000000000
--- a/contrib/libs/openjpeg/openjpeg.h
+++ /dev/null
@@ -1,1783 +0,0 @@
-/*
-* The copyright in this software is being made available under the 2-clauses
-* BSD License, included below. This software may be subject to other third
-* party and contributor rights, including patent rights, and no such rights
-* are granted under this license.
-*
-* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
-* Copyright (c) 2002-2014, Professor Benoit Macq
-* Copyright (c) 2001-2003, David Janssens
-* Copyright (c) 2002-2003, Yannick Verschueren
-* Copyright (c) 2003-2007, Francois-Olivier Devaux
-* Copyright (c) 2003-2014, Antonin Descampe
-* Copyright (c) 2005, Herve Drolon, FreeImage Team
-* Copyright (c) 2006-2007, Parvatha Elangovan
-* Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@c-s.fr>
-* Copyright (c) 2010-2011, Kaori Hagihara
-* Copyright (c) 2011-2012, Centre National d'Etudes Spatiales (CNES), France
-* Copyright (c) 2012, CS Systemes d'Information, France
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions
-* are met:
-* 1. Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* 2. Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-* POSSIBILITY OF SUCH DAMAGE.
-*/
-#ifndef OPENJPEG_H
-#define OPENJPEG_H
-
-
-/*
-==========================================================
- Compiler directives
-==========================================================
-*/
-
-/*
-The inline keyword is supported by C99 but not by C90.
-Most compilers implement their own version of this keyword ...
-*/
-#ifndef INLINE
-#if defined(_MSC_VER)
-#define INLINE __forceinline
-#elif defined(__GNUC__)
-#define INLINE __inline__
-#elif defined(__MWERKS__)
-#define INLINE inline
-#else
-/* add other compilers here ... */
-#define INLINE
-#endif /* defined(<Compiler>) */
-#endif /* INLINE */
-
-/* deprecated attribute */
-#ifdef __GNUC__
-#define OPJ_DEPRECATED(func) func __attribute__ ((deprecated))
-#elif defined(_MSC_VER)
-#define OPJ_DEPRECATED(func) __declspec(deprecated) func
-#else
-#pragma message("WARNING: You need to implement DEPRECATED for this compiler")
-#define OPJ_DEPRECATED(func) func
-#endif
-
-#if defined(__GNUC__) && __GNUC__ >= 6
-#define OPJ_DEPRECATED_STRUCT_MEMBER(memb, msg) __attribute__ ((deprecated(msg))) memb
-#else
-#define OPJ_DEPRECATED_STRUCT_MEMBER(memb, msg) memb
-#endif
-
-#if defined(OPJ_STATIC) || !defined(_WIN32)
-/* http://gcc.gnu.org/wiki/Visibility */
-# if !defined(_WIN32) && __GNUC__ >= 4
-# if defined(OPJ_STATIC) /* static library uses "hidden" */
-# define OPJ_API __attribute__ ((visibility ("hidden")))
-# else
-# define OPJ_API __attribute__ ((visibility ("default")))
-# endif
-# define OPJ_LOCAL __attribute__ ((visibility ("hidden")))
-# else
-# define OPJ_API
-# define OPJ_LOCAL
-# endif
-# define OPJ_CALLCONV
-#else
-# define OPJ_CALLCONV __stdcall
-/*
-The following ifdef block is the standard way of creating macros which make exporting
-from a DLL simpler. All files within this DLL are compiled with the OPJ_EXPORTS
-symbol defined on the command line. this symbol should not be defined on any project
-that uses this DLL. This way any other project whose source files include this file see
-OPJ_API functions as being imported from a DLL, whereas this DLL sees symbols
-defined with this macro as being exported.
-*/
-# if defined(OPJ_EXPORTS) || defined(DLL_EXPORT)
-# define OPJ_API __declspec(dllexport)
-# else
-# define OPJ_API __declspec(dllimport)
-# endif /* OPJ_EXPORTS */
-#endif /* !OPJ_STATIC || !_WIN32 */
-
-typedef int OPJ_BOOL;
-#define OPJ_TRUE 1
-#define OPJ_FALSE 0
-
-typedef char OPJ_CHAR;
-typedef float OPJ_FLOAT32;
-typedef double OPJ_FLOAT64;
-typedef unsigned char OPJ_BYTE;
-
-#include <stdint.h>
-
-typedef int8_t OPJ_INT8;
-typedef uint8_t OPJ_UINT8;
-typedef int16_t OPJ_INT16;
-typedef uint16_t OPJ_UINT16;
-typedef int32_t OPJ_INT32;
-typedef uint32_t OPJ_UINT32;
-typedef int64_t OPJ_INT64;
-typedef uint64_t OPJ_UINT64;
-
-typedef int64_t OPJ_OFF_T; /* 64-bit file offset type */
-
-#include <stdio.h>
-typedef size_t OPJ_SIZE_T;
-
-#include "opj_config.h"
-
-/* Avoid compile-time warning because parameter is not used */
-#define OPJ_ARG_NOT_USED(x) (void)(x)
-
-/*
-==========================================================
- Useful constant definitions
-==========================================================
-*/
-
-#define OPJ_PATH_LEN 4096 /**< Maximum allowed size for filenames */
-
-#define OPJ_J2K_MAXRLVLS 33 /**< Number of maximum resolution level authorized */
-#define OPJ_J2K_MAXBANDS (3*OPJ_J2K_MAXRLVLS-2) /**< Number of maximum sub-band linked to number of resolution level */
-
-#define OPJ_J2K_DEFAULT_NB_SEGS 10
-#define OPJ_J2K_STREAM_CHUNK_SIZE 0x100000 /** 1 mega by default */
-#define OPJ_J2K_DEFAULT_HEADER_SIZE 1000
-#define OPJ_J2K_MCC_DEFAULT_NB_RECORDS 10
-#define OPJ_J2K_MCT_DEFAULT_NB_RECORDS 10
-
-/* UniPG>> */ /* NOT YET USED IN THE V2 VERSION OF OPENJPEG */
-#define JPWL_MAX_NO_TILESPECS 16 /**< Maximum number of tile parts expected by JPWL: increase at your will */
-#define JPWL_MAX_NO_PACKSPECS 16 /**< Maximum number of packet parts expected by JPWL: increase at your will */
-#define JPWL_MAX_NO_MARKERS 512 /**< Maximum number of JPWL markers: increase at your will */
-#define JPWL_PRIVATEINDEX_NAME "jpwl_index_privatefilename" /**< index file name used when JPWL is on */
-#define JPWL_EXPECTED_COMPONENTS 3 /**< Expect this number of components, so you'll find better the first EPB */
-#define JPWL_MAXIMUM_TILES 8192 /**< Expect this maximum number of tiles, to avoid some crashes */
-#define JPWL_MAXIMUM_HAMMING 2 /**< Expect this maximum number of bit errors in marker id's */
-#define JPWL_MAXIMUM_EPB_ROOM 65450 /**< Expect this maximum number of bytes for composition of EPBs */
-/* <<UniPG */
-
-/**
- * EXPERIMENTAL FOR THE MOMENT
- * Supported options about file information used only in j2k_dump
-*/
-#define OPJ_IMG_INFO 1 /**< Basic image information provided to the user */
-#define OPJ_J2K_MH_INFO 2 /**< Codestream information based only on the main header */
-#define OPJ_J2K_TH_INFO 4 /**< Tile information based on the current tile header */
-#define OPJ_J2K_TCH_INFO 8 /**< Tile/Component information of all tiles */
-#define OPJ_J2K_MH_IND 16 /**< Codestream index based only on the main header */
-#define OPJ_J2K_TH_IND 32 /**< Tile index based on the current tile */
-/*FIXME #define OPJ_J2K_CSTR_IND 48*/ /**< */
-#define OPJ_JP2_INFO 128 /**< JP2 file information */
-#define OPJ_JP2_IND 256 /**< JP2 file index */
-
-/**
- * JPEG 2000 Profiles, see Table A.10 from 15444-1 (updated in various AMD)
- * These values help choosing the RSIZ value for the J2K codestream.
- * The RSIZ value triggers various encoding options, as detailed in Table A.10.
- * If OPJ_PROFILE_PART2 is chosen, it has to be combined with one or more extensions
- * described hereunder.
- * Example: rsiz = OPJ_PROFILE_PART2 | OPJ_EXTENSION_MCT;
- * For broadcast profiles, the OPJ_PROFILE value has to be combined with the targeted
- * mainlevel (3-0 LSB, value between 0 and 11):
- * Example: rsiz = OPJ_PROFILE_BC_MULTI | 0x0005; (here mainlevel 5)
- * For IMF profiles, the OPJ_PROFILE value has to be combined with the targeted mainlevel
- * (3-0 LSB, value between 0 and 11) and sublevel (7-4 LSB, value between 0 and 9):
- * Example: rsiz = OPJ_PROFILE_IMF_2K | 0x0040 | 0x0005; (here main 5 and sublevel 4)
- * */
-#define OPJ_PROFILE_NONE 0x0000 /** no profile, conform to 15444-1 */
-#define OPJ_PROFILE_0 0x0001 /** Profile 0 as described in 15444-1,Table A.45 */
-#define OPJ_PROFILE_1 0x0002 /** Profile 1 as described in 15444-1,Table A.45 */
-#define OPJ_PROFILE_PART2 0x8000 /** At least 1 extension defined in 15444-2 (Part-2) */
-#define OPJ_PROFILE_CINEMA_2K 0x0003 /** 2K cinema profile defined in 15444-1 AMD1 */
-#define OPJ_PROFILE_CINEMA_4K 0x0004 /** 4K cinema profile defined in 15444-1 AMD1 */
-#define OPJ_PROFILE_CINEMA_S2K 0x0005 /** Scalable 2K cinema profile defined in 15444-1 AMD2 */
-#define OPJ_PROFILE_CINEMA_S4K 0x0006 /** Scalable 4K cinema profile defined in 15444-1 AMD2 */
-#define OPJ_PROFILE_CINEMA_LTS 0x0007 /** Long term storage cinema profile defined in 15444-1 AMD2 */
-#define OPJ_PROFILE_BC_SINGLE 0x0100 /** Single Tile Broadcast profile defined in 15444-1 AMD3 */
-#define OPJ_PROFILE_BC_MULTI 0x0200 /** Multi Tile Broadcast profile defined in 15444-1 AMD3 */
-#define OPJ_PROFILE_BC_MULTI_R 0x0300 /** Multi Tile Reversible Broadcast profile defined in 15444-1 AMD3 */
-#define OPJ_PROFILE_IMF_2K 0x0400 /** 2K Single Tile Lossy IMF profile defined in 15444-1 AMD 8 */
-#define OPJ_PROFILE_IMF_4K 0x0500 /** 4K Single Tile Lossy IMF profile defined in 15444-1 AMD 8 */
-#define OPJ_PROFILE_IMF_8K 0x0600 /** 8K Single Tile Lossy IMF profile defined in 15444-1 AMD 8 */
-#define OPJ_PROFILE_IMF_2K_R 0x0700 /** 2K Single/Multi Tile Reversible IMF profile defined in 15444-1 AMD 8 */
-#define OPJ_PROFILE_IMF_4K_R 0x0800 /** 4K Single/Multi Tile Reversible IMF profile defined in 15444-1 AMD 8 */
-#define OPJ_PROFILE_IMF_8K_R 0x0900 /** 8K Single/Multi Tile Reversible IMF profile defined in 15444-1 AMD 8 */
-
-/**
- * JPEG 2000 Part-2 extensions
- * */
-#define OPJ_EXTENSION_NONE 0x0000 /** No Part-2 extension */
-#define OPJ_EXTENSION_MCT 0x0100 /** Custom MCT support */
-
-/**
- * JPEG 2000 profile macros
- * */
-#define OPJ_IS_CINEMA(v) (((v) >= OPJ_PROFILE_CINEMA_2K)&&((v) <= OPJ_PROFILE_CINEMA_S4K))
-#define OPJ_IS_STORAGE(v) ((v) == OPJ_PROFILE_CINEMA_LTS)
-#define OPJ_IS_BROADCAST(v) (((v) >= OPJ_PROFILE_BC_SINGLE)&&((v) <= ((OPJ_PROFILE_BC_MULTI_R) | (0x000b))))
-#define OPJ_IS_IMF(v) (((v) >= OPJ_PROFILE_IMF_2K)&&((v) <= ((OPJ_PROFILE_IMF_8K_R) | (0x009b))))
-#define OPJ_IS_PART2(v) ((v) & OPJ_PROFILE_PART2)
-
-#define OPJ_GET_IMF_PROFILE(v) ((v) & 0xff00) /** Extract IMF profile without mainlevel/sublevel */
-#define OPJ_GET_IMF_MAINLEVEL(v) ((v) & 0xf) /** Extract IMF main level */
-#define OPJ_GET_IMF_SUBLEVEL(v) (((v) >> 4) & 0xf) /** Extract IMF sub level */
-
-#define OPJ_IMF_MAINLEVEL_MAX 11 /** Maximum main level */
-
-/** Max. Components Sampling Rate (MSamples/sec) per IMF main level */
-#define OPJ_IMF_MAINLEVEL_1_MSAMPLESEC 65 /** MSamples/sec for IMF main level 1 */
-#define OPJ_IMF_MAINLEVEL_2_MSAMPLESEC 130 /** MSamples/sec for IMF main level 2 */
-#define OPJ_IMF_MAINLEVEL_3_MSAMPLESEC 195 /** MSamples/sec for IMF main level 3 */
-#define OPJ_IMF_MAINLEVEL_4_MSAMPLESEC 260 /** MSamples/sec for IMF main level 4 */
-#define OPJ_IMF_MAINLEVEL_5_MSAMPLESEC 520 /** MSamples/sec for IMF main level 5 */
-#define OPJ_IMF_MAINLEVEL_6_MSAMPLESEC 1200 /** MSamples/sec for IMF main level 6 */
-#define OPJ_IMF_MAINLEVEL_7_MSAMPLESEC 2400 /** MSamples/sec for IMF main level 7 */
-#define OPJ_IMF_MAINLEVEL_8_MSAMPLESEC 4800 /** MSamples/sec for IMF main level 8 */
-#define OPJ_IMF_MAINLEVEL_9_MSAMPLESEC 9600 /** MSamples/sec for IMF main level 9 */
-#define OPJ_IMF_MAINLEVEL_10_MSAMPLESEC 19200 /** MSamples/sec for IMF main level 10 */
-#define OPJ_IMF_MAINLEVEL_11_MSAMPLESEC 38400 /** MSamples/sec for IMF main level 11 */
-
-/** Max. compressed Bit Rate (Mbits/s) per IMF sub level */
-#define OPJ_IMF_SUBLEVEL_1_MBITSSEC 200 /** Mbits/s for IMF sub level 1 */
-#define OPJ_IMF_SUBLEVEL_2_MBITSSEC 400 /** Mbits/s for IMF sub level 2 */
-#define OPJ_IMF_SUBLEVEL_3_MBITSSEC 800 /** Mbits/s for IMF sub level 3 */
-#define OPJ_IMF_SUBLEVEL_4_MBITSSEC 1600 /** Mbits/s for IMF sub level 4 */
-#define OPJ_IMF_SUBLEVEL_5_MBITSSEC 3200 /** Mbits/s for IMF sub level 5 */
-#define OPJ_IMF_SUBLEVEL_6_MBITSSEC 6400 /** Mbits/s for IMF sub level 6 */
-#define OPJ_IMF_SUBLEVEL_7_MBITSSEC 12800 /** Mbits/s for IMF sub level 7 */
-#define OPJ_IMF_SUBLEVEL_8_MBITSSEC 25600 /** Mbits/s for IMF sub level 8 */
-#define OPJ_IMF_SUBLEVEL_9_MBITSSEC 51200 /** Mbits/s for IMF sub level 9 */
-
-/**
- * JPEG 2000 codestream and component size limits in cinema profiles
- * */
-#define OPJ_CINEMA_24_CS 1302083 /** Maximum codestream length for 24fps */
-#define OPJ_CINEMA_48_CS 651041 /** Maximum codestream length for 48fps */
-#define OPJ_CINEMA_24_COMP 1041666 /** Maximum size per color component for 2K & 4K @ 24fps */
-#define OPJ_CINEMA_48_COMP 520833 /** Maximum size per color component for 2K @ 48fps */
-
-/*
-==========================================================
- enum definitions
-==========================================================
-*/
-
-/**
- * DEPRECATED: use RSIZ, OPJ_PROFILE_* and OPJ_EXTENSION_* instead
- * Rsiz Capabilities
- * */
-typedef enum RSIZ_CAPABILITIES {
- OPJ_STD_RSIZ = 0, /** Standard JPEG2000 profile*/
- OPJ_CINEMA2K = 3, /** Profile name for a 2K image*/
- OPJ_CINEMA4K = 4, /** Profile name for a 4K image*/
- OPJ_MCT = 0x8100
-} OPJ_RSIZ_CAPABILITIES;
-
-/**
- * DEPRECATED: use RSIZ, OPJ_PROFILE_* and OPJ_EXTENSION_* instead
- * Digital cinema operation mode
- * */
-typedef enum CINEMA_MODE {
- OPJ_OFF = 0, /** Not Digital Cinema*/
- OPJ_CINEMA2K_24 = 1, /** 2K Digital Cinema at 24 fps*/
- OPJ_CINEMA2K_48 = 2, /** 2K Digital Cinema at 48 fps*/
- OPJ_CINEMA4K_24 = 3 /** 4K Digital Cinema at 24 fps*/
-} OPJ_CINEMA_MODE;
-
-/**
- * Progression order
- * */
-typedef enum PROG_ORDER {
- OPJ_PROG_UNKNOWN = -1, /**< place-holder */
- OPJ_LRCP = 0, /**< layer-resolution-component-precinct order */
- OPJ_RLCP = 1, /**< resolution-layer-component-precinct order */
- OPJ_RPCL = 2, /**< resolution-precinct-component-layer order */
- OPJ_PCRL = 3, /**< precinct-component-resolution-layer order */
- OPJ_CPRL = 4 /**< component-precinct-resolution-layer order */
-} OPJ_PROG_ORDER;
-
-/**
- * Supported image color spaces
-*/
-typedef enum COLOR_SPACE {
- OPJ_CLRSPC_UNKNOWN = -1, /**< not supported by the library */
- OPJ_CLRSPC_UNSPECIFIED = 0, /**< not specified in the codestream */
- OPJ_CLRSPC_SRGB = 1, /**< sRGB */
- OPJ_CLRSPC_GRAY = 2, /**< grayscale */
- OPJ_CLRSPC_SYCC = 3, /**< YUV */
- OPJ_CLRSPC_EYCC = 4, /**< e-YCC */
- OPJ_CLRSPC_CMYK = 5 /**< CMYK */
-} OPJ_COLOR_SPACE;
-
-/**
- * Supported codec
-*/
-typedef enum CODEC_FORMAT {
- OPJ_CODEC_UNKNOWN = -1, /**< place-holder */
- OPJ_CODEC_J2K = 0, /**< JPEG-2000 codestream : read/write */
- OPJ_CODEC_JPT = 1, /**< JPT-stream (JPEG 2000, JPIP) : read only */
- OPJ_CODEC_JP2 = 2, /**< JP2 file format : read/write */
- OPJ_CODEC_JPP = 3, /**< JPP-stream (JPEG 2000, JPIP) : to be coded */
- OPJ_CODEC_JPX = 4 /**< JPX file format (JPEG 2000 Part-2) : to be coded */
-} OPJ_CODEC_FORMAT;
-
-
-/*
-==========================================================
- event manager typedef definitions
-==========================================================
-*/
-
-/**
- * Callback function prototype for events
- * @param msg Event message
- * @param client_data Client object where will be return the event message
- * */
-typedef void (*opj_msg_callback)(const char *msg, void *client_data);
-
-/*
-==========================================================
- codec typedef definitions
-==========================================================
-*/
-
-#ifndef OPJ_UINT32_SEMANTICALLY_BUT_INT32
-#define OPJ_UINT32_SEMANTICALLY_BUT_INT32 OPJ_INT32
-#endif
-
-/**
- * Progression order changes
- *
- */
-typedef struct opj_poc {
- /** Resolution num start, Component num start, given by POC */
- OPJ_UINT32 resno0, compno0;
- /** Layer num end,Resolution num end, Component num end, given by POC */
- OPJ_UINT32 layno1, resno1, compno1;
- /** Layer num start,Precinct num start, Precinct num end */
- OPJ_UINT32 layno0, precno0, precno1;
- /** Progression order enum*/
- OPJ_PROG_ORDER prg1, prg;
- /** Progression order string*/
- OPJ_CHAR progorder[5];
- /** Tile number (starting at 1) */
- OPJ_UINT32 tile;
- /** Start and end values for Tile width and height*/
- OPJ_UINT32_SEMANTICALLY_BUT_INT32 tx0, tx1, ty0, ty1;
- /** Start value, initialised in pi_initialise_encode*/
- OPJ_UINT32 layS, resS, compS, prcS;
- /** End value, initialised in pi_initialise_encode */
- OPJ_UINT32 layE, resE, compE, prcE;
- /** Start and end values of Tile width and height, initialised in pi_initialise_encode*/
- OPJ_UINT32 txS, txE, tyS, tyE, dx, dy;
- /** Temporary values for Tile parts, initialised in pi_create_encode */
- OPJ_UINT32 lay_t, res_t, comp_t, prc_t, tx0_t, ty0_t;
-} opj_poc_t;
-
-/**
- * Compression parameters
- * */
-typedef struct opj_cparameters {
- /** size of tile: tile_size_on = false (not in argument) or = true (in argument) */
- OPJ_BOOL tile_size_on;
- /** XTOsiz */
- int cp_tx0;
- /** YTOsiz */
- int cp_ty0;
- /** XTsiz */
- int cp_tdx;
- /** YTsiz */
- int cp_tdy;
- /** allocation by rate/distortion */
- int cp_disto_alloc;
- /** allocation by fixed layer */
- int cp_fixed_alloc;
- /** allocation by fixed quality (PSNR) */
- int cp_fixed_quality;
- /** fixed layer */
- int *cp_matrice;
- /** comment for coding */
- char *cp_comment;
- /** csty : coding style */
- int csty;
- /** progression order (default OPJ_LRCP) */
- OPJ_PROG_ORDER prog_order;
- /** progression order changes */
- opj_poc_t POC[32];
- /** number of progression order changes (POC), default to 0 */
- OPJ_UINT32 numpocs;
- /** number of layers */
- int tcp_numlayers;
- /** rates of layers - might be subsequently limited by the max_cs_size field.
- * Should be decreasing. 1 can be
- * used as last value to indicate the last layer is lossless. */
- float tcp_rates[100];
- /** different psnr for successive layers. Should be increasing. 0 can be
- * used as last value to indicate the last layer is lossless. */
- float tcp_distoratio[100];
- /** number of resolutions */
- int numresolution;
- /** initial code block width, default to 64 */
- int cblockw_init;
- /** initial code block height, default to 64 */
- int cblockh_init;
- /** mode switch (cblk_style) */
- int mode;
- /** 1 : use the irreversible DWT 9-7, 0 : use lossless compression (default) */
- int irreversible;
- /** region of interest: affected component in [0..3], -1 means no ROI */
- int roi_compno;
- /** region of interest: upshift value */
- int roi_shift;
- /* number of precinct size specifications */
- int res_spec;
- /** initial precinct width */
- int prcw_init[OPJ_J2K_MAXRLVLS];
- /** initial precinct height */
- int prch_init[OPJ_J2K_MAXRLVLS];
-
- /**@name command line encoder parameters (not used inside the library) */
- /*@{*/
- /** input file name */
- char infile[OPJ_PATH_LEN];
- /** output file name */
- char outfile[OPJ_PATH_LEN];
- /** DEPRECATED. Index generation is now handled with the opj_encode_with_info() function. Set to NULL */
- int index_on;
- /** DEPRECATED. Index generation is now handled with the opj_encode_with_info() function. Set to NULL */
- char index[OPJ_PATH_LEN];
- /** subimage encoding: origin image offset in x direction */
- int image_offset_x0;
- /** subimage encoding: origin image offset in y direction */
- int image_offset_y0;
- /** subsampling value for dx */
- int subsampling_dx;
- /** subsampling value for dy */
- int subsampling_dy;
- /** input file format 0: PGX, 1: PxM, 2: BMP 3:TIF*/
- int decod_format;
- /** output file format 0: J2K, 1: JP2, 2: JPT */
- int cod_format;
- /*@}*/
-
- /* UniPG>> */ /* NOT YET USED IN THE V2 VERSION OF OPENJPEG */
- /**@name JPWL encoding parameters */
- /*@{*/
- /** enables writing of EPC in MH, thus activating JPWL */
- OPJ_BOOL jpwl_epc_on;
- /** error protection method for MH (0,1,16,32,37-128) */
- int jpwl_hprot_MH;
- /** tile number of header protection specification (>=0) */
- int jpwl_hprot_TPH_tileno[JPWL_MAX_NO_TILESPECS];
- /** error protection methods for TPHs (0,1,16,32,37-128) */
- int jpwl_hprot_TPH[JPWL_MAX_NO_TILESPECS];
- /** tile number of packet protection specification (>=0) */
- int jpwl_pprot_tileno[JPWL_MAX_NO_PACKSPECS];
- /** packet number of packet protection specification (>=0) */
- int jpwl_pprot_packno[JPWL_MAX_NO_PACKSPECS];
- /** error protection methods for packets (0,1,16,32,37-128) */
- int jpwl_pprot[JPWL_MAX_NO_PACKSPECS];
- /** enables writing of ESD, (0=no/1/2 bytes) */
- int jpwl_sens_size;
- /** sensitivity addressing size (0=auto/2/4 bytes) */
- int jpwl_sens_addr;
- /** sensitivity range (0-3) */
- int jpwl_sens_range;
- /** sensitivity method for MH (-1=no,0-7) */
- int jpwl_sens_MH;
- /** tile number of sensitivity specification (>=0) */
- int jpwl_sens_TPH_tileno[JPWL_MAX_NO_TILESPECS];
- /** sensitivity methods for TPHs (-1=no,0-7) */
- int jpwl_sens_TPH[JPWL_MAX_NO_TILESPECS];
- /*@}*/
- /* <<UniPG */
-
- /**
- * DEPRECATED: use RSIZ, OPJ_PROFILE_* and MAX_COMP_SIZE instead
- * Digital Cinema compliance 0-not compliant, 1-compliant
- * */
- OPJ_CINEMA_MODE cp_cinema;
- /**
- * Maximum size (in bytes) for each component.
- * If == 0, component size limitation is not considered
- * */
- int max_comp_size;
- /**
- * DEPRECATED: use RSIZ, OPJ_PROFILE_* and OPJ_EXTENSION_* instead
- * Profile name
- * */
- OPJ_RSIZ_CAPABILITIES cp_rsiz;
- /** Tile part generation*/
- char tp_on;
- /** Flag for Tile part generation*/
- char tp_flag;
- /** MCT (multiple component transform) */
- char tcp_mct;
- /** Enable JPIP indexing*/
- OPJ_BOOL jpip_on;
- /** Naive implementation of MCT restricted to a single reversible array based
- encoding without offset concerning all the components. */
- void * mct_data;
- /**
- * Maximum size (in bytes) for the whole codestream.
- * If == 0, codestream size limitation is not considered
- * If it does not comply with tcp_rates, max_cs_size prevails
- * and a warning is issued.
- * */
- int max_cs_size;
- /** RSIZ value
- To be used to combine OPJ_PROFILE_*, OPJ_EXTENSION_* and (sub)levels values. */
- OPJ_UINT16 rsiz;
-} opj_cparameters_t;
-
-#define OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG 0x0001
-#define OPJ_DPARAMETERS_DUMP_FLAG 0x0002
-
-/**
- * Decompression parameters
- * */
-typedef struct opj_dparameters {
- /**
- Set the number of highest resolution levels to be discarded.
- The image resolution is effectively divided by 2 to the power of the number of discarded levels.
- The reduce factor is limited by the smallest total number of decomposition levels among tiles.
- if != 0, then original dimension divided by 2^(reduce);
- if == 0 or not used, image is decoded to the full resolution
- */
- OPJ_UINT32 cp_reduce;
- /**
- Set the maximum number of quality layers to decode.
- If there are less quality layers than the specified number, all the quality layers are decoded.
- if != 0, then only the first "layer" layers are decoded;
- if == 0 or not used, all the quality layers are decoded
- */
- OPJ_UINT32 cp_layer;
-
- /**@name command line decoder parameters (not used inside the library) */
- /*@{*/
- /** input file name */
- char infile[OPJ_PATH_LEN];
- /** output file name */
- char outfile[OPJ_PATH_LEN];
- /** input file format 0: J2K, 1: JP2, 2: JPT */
- int decod_format;
- /** output file format 0: PGX, 1: PxM, 2: BMP */
- int cod_format;
-
- /** Decoding area left boundary */
- OPJ_UINT32 DA_x0;
- /** Decoding area right boundary */
- OPJ_UINT32 DA_x1;
- /** Decoding area up boundary */
- OPJ_UINT32 DA_y0;
- /** Decoding area bottom boundary */
- OPJ_UINT32 DA_y1;
- /** Verbose mode */
- OPJ_BOOL m_verbose;
-
- /** tile number of the decoded tile */
- OPJ_UINT32 tile_index;
- /** Nb of tile to decode */
- OPJ_UINT32 nb_tile_to_decode;
-
- /*@}*/
-
- /* UniPG>> */ /* NOT YET USED IN THE V2 VERSION OF OPENJPEG */
- /**@name JPWL decoding parameters */
- /*@{*/
- /** activates the JPWL correction capabilities */
- OPJ_BOOL jpwl_correct;
- /** expected number of components */
- int jpwl_exp_comps;
- /** maximum number of tiles */
- int jpwl_max_tiles;
- /*@}*/
- /* <<UniPG */
-
- unsigned int flags;
-
-} opj_dparameters_t;
-
-
-/**
- * JPEG2000 codec V2.
- * */
-typedef void * opj_codec_t;
-
-/*
-==========================================================
- I/O stream typedef definitions
-==========================================================
-*/
-
-/**
- * Stream open flags.
- * */
-/** The stream was opened for reading. */
-#define OPJ_STREAM_READ OPJ_TRUE
-/** The stream was opened for writing. */
-#define OPJ_STREAM_WRITE OPJ_FALSE
-
-/*
- * Callback function prototype for read function
- */
-typedef OPJ_SIZE_T(* opj_stream_read_fn)(void * p_buffer, OPJ_SIZE_T p_nb_bytes,
- void * p_user_data) ;
-
-/*
- * Callback function prototype for write function
- */
-typedef OPJ_SIZE_T(* opj_stream_write_fn)(void * p_buffer,
- OPJ_SIZE_T p_nb_bytes, void * p_user_data) ;
-
-/*
- * Callback function prototype for skip function
- */
-typedef OPJ_OFF_T(* opj_stream_skip_fn)(OPJ_OFF_T p_nb_bytes,
- void * p_user_data) ;
-
-/*
- * Callback function prototype for seek function
- */
-typedef OPJ_BOOL(* opj_stream_seek_fn)(OPJ_OFF_T p_nb_bytes,
- void * p_user_data) ;
-
-/*
- * Callback function prototype for free user data function
- */
-typedef void (* opj_stream_free_user_data_fn)(void * p_user_data) ;
-
-/*
- * JPEG2000 Stream.
- */
-typedef void * opj_stream_t;
-
-/*
-==========================================================
- image typedef definitions
-==========================================================
-*/
-
-/**
- * Defines a single image component
- * */
-typedef struct opj_image_comp {
- /** XRsiz: horizontal separation of a sample of ith component with respect to the reference grid */
- OPJ_UINT32 dx;
- /** YRsiz: vertical separation of a sample of ith component with respect to the reference grid */
- OPJ_UINT32 dy;
- /** data width */
- OPJ_UINT32 w;
- /** data height */
- OPJ_UINT32 h;
- /** x component offset compared to the whole image */
- OPJ_UINT32 x0;
- /** y component offset compared to the whole image */
- OPJ_UINT32 y0;
- /** precision: number of bits per component per pixel */
- OPJ_UINT32 prec;
- /** obsolete: use prec instead */
- OPJ_DEPRECATED_STRUCT_MEMBER(OPJ_UINT32 bpp, "Use prec instead");
- /** signed (1) / unsigned (0) */
- OPJ_UINT32 sgnd;
- /** number of decoded resolution */
- OPJ_UINT32 resno_decoded;
- /** number of division by 2 of the out image compared to the original size of image */
- OPJ_UINT32 factor;
- /** image component data */
- OPJ_INT32 *data;
- /** alpha channel */
- OPJ_UINT16 alpha;
-} opj_image_comp_t;
-
-/**
- * Defines image data and characteristics
- * */
-typedef struct opj_image {
- /** XOsiz: horizontal offset from the origin of the reference grid to the left side of the image area */
- OPJ_UINT32 x0;
- /** YOsiz: vertical offset from the origin of the reference grid to the top side of the image area */
- OPJ_UINT32 y0;
- /** Xsiz: width of the reference grid */
- OPJ_UINT32 x1;
- /** Ysiz: height of the reference grid */
- OPJ_UINT32 y1;
- /** number of components in the image */
- OPJ_UINT32 numcomps;
- /** color space: sRGB, Greyscale or YUV */
- OPJ_COLOR_SPACE color_space;
- /** image components */
- opj_image_comp_t *comps;
- /** 'restricted' ICC profile */
- OPJ_BYTE *icc_profile_buf;
- /** size of ICC profile */
- OPJ_UINT32 icc_profile_len;
-} opj_image_t;
-
-
-/**
- * Component parameters structure used by the opj_image_create function
- * */
-typedef struct opj_image_comptparm {
- /** XRsiz: horizontal separation of a sample of ith component with respect to the reference grid */
- OPJ_UINT32 dx;
- /** YRsiz: vertical separation of a sample of ith component with respect to the reference grid */
- OPJ_UINT32 dy;
- /** data width */
- OPJ_UINT32 w;
- /** data height */
- OPJ_UINT32 h;
- /** x component offset compared to the whole image */
- OPJ_UINT32 x0;
- /** y component offset compared to the whole image */
- OPJ_UINT32 y0;
- /** precision: number of bits per component per pixel */
- OPJ_UINT32 prec;
- /** obsolete: use prec instead */
- OPJ_DEPRECATED_STRUCT_MEMBER(OPJ_UINT32 bpp, "Use prec instead");
- /** signed (1) / unsigned (0) */
- OPJ_UINT32 sgnd;
-} opj_image_cmptparm_t;
-
-
-/*
-==========================================================
- Information on the JPEG 2000 codestream
-==========================================================
-*/
-/* QUITE EXPERIMENTAL FOR THE MOMENT */
-
-/**
- * Index structure : Information concerning a packet inside tile
- * */
-typedef struct opj_packet_info {
- /** packet start position (including SOP marker if it exists) */
- OPJ_OFF_T start_pos;
- /** end of packet header position (including EPH marker if it exists)*/
- OPJ_OFF_T end_ph_pos;
- /** packet end position */
- OPJ_OFF_T end_pos;
- /** packet distortion */
- double disto;
-} opj_packet_info_t;
-
-
-/* UniPG>> */
-/**
- * Marker structure
- * */
-typedef struct opj_marker_info {
- /** marker type */
- unsigned short int type;
- /** position in codestream */
- OPJ_OFF_T pos;
- /** length, marker val included */
- int len;
-} opj_marker_info_t;
-/* <<UniPG */
-
-/**
- * Index structure : Information concerning tile-parts
-*/
-typedef struct opj_tp_info {
- /** start position of tile part */
- int tp_start_pos;
- /** end position of tile part header */
- int tp_end_header;
- /** end position of tile part */
- int tp_end_pos;
- /** start packet of tile part */
- int tp_start_pack;
- /** number of packets of tile part */
- int tp_numpacks;
-} opj_tp_info_t;
-
-/**
- * Index structure : information regarding tiles
-*/
-typedef struct opj_tile_info {
- /** value of thresh for each layer by tile cfr. Marcela */
- double *thresh;
- /** number of tile */
- int tileno;
- /** start position */
- int start_pos;
- /** end position of the header */
- int end_header;
- /** end position */
- int end_pos;
- /** precinct number for each resolution level (width) */
- int pw[33];
- /** precinct number for each resolution level (height) */
- int ph[33];
- /** precinct size (in power of 2), in X for each resolution level */
- int pdx[33];
- /** precinct size (in power of 2), in Y for each resolution level */
- int pdy[33];
- /** information concerning packets inside tile */
- opj_packet_info_t *packet;
- /** number of pixels of the tile */
- int numpix;
- /** distortion of the tile */
- double distotile;
- /** number of markers */
- int marknum;
- /** list of markers */
- opj_marker_info_t *marker;
- /** actual size of markers array */
- int maxmarknum;
- /** number of tile parts */
- int num_tps;
- /** information concerning tile parts */
- opj_tp_info_t *tp;
-} opj_tile_info_t;
-
-/**
- * Index structure of the codestream
-*/
-typedef struct opj_codestream_info {
- /** maximum distortion reduction on the whole image (add for Marcela) */
- double D_max;
- /** packet number */
- int packno;
- /** writing the packet in the index with t2_encode_packets */
- int index_write;
- /** image width */
- int image_w;
- /** image height */
- int image_h;
- /** progression order */
- OPJ_PROG_ORDER prog;
- /** tile size in x */
- int tile_x;
- /** tile size in y */
- int tile_y;
- /** */
- int tile_Ox;
- /** */
- int tile_Oy;
- /** number of tiles in X */
- int tw;
- /** number of tiles in Y */
- int th;
- /** component numbers */
- int numcomps;
- /** number of layer */
- int numlayers;
- /** number of decomposition for each component */
- int *numdecompos;
- /* UniPG>> */
- /** number of markers */
- int marknum;
- /** list of markers */
- opj_marker_info_t *marker;
- /** actual size of markers array */
- int maxmarknum;
- /* <<UniPG */
- /** main header position */
- int main_head_start;
- /** main header position */
- int main_head_end;
- /** codestream's size */
- int codestream_size;
- /** information regarding tiles inside image */
- opj_tile_info_t *tile;
-} opj_codestream_info_t;
-
-/* <----------------------------------------------------------- */
-/* new output management of the codestream information and index */
-
-/**
- * Tile-component coding parameters information
- */
-typedef struct opj_tccp_info {
- /** component index */
- OPJ_UINT32 compno;
- /** coding style */
- OPJ_UINT32 csty;
- /** number of resolutions */
- OPJ_UINT32 numresolutions;
- /** log2 of code-blocks width */
- OPJ_UINT32 cblkw;
- /** log2 of code-blocks height */
- OPJ_UINT32 cblkh;
- /** code-block coding style */
- OPJ_UINT32 cblksty;
- /** discrete wavelet transform identifier: 0 = 9-7 irreversible, 1 = 5-3 reversible */
- OPJ_UINT32 qmfbid;
- /** quantisation style */
- OPJ_UINT32 qntsty;
- /** stepsizes used for quantization */
- OPJ_UINT32 stepsizes_mant[OPJ_J2K_MAXBANDS];
- /** stepsizes used for quantization */
- OPJ_UINT32 stepsizes_expn[OPJ_J2K_MAXBANDS];
- /** number of guard bits */
- OPJ_UINT32 numgbits;
- /** Region Of Interest shift */
- OPJ_INT32 roishift;
- /** precinct width */
- OPJ_UINT32 prcw[OPJ_J2K_MAXRLVLS];
- /** precinct height */
- OPJ_UINT32 prch[OPJ_J2K_MAXRLVLS];
-}
-opj_tccp_info_t;
-
-/**
- * Tile coding parameters information
- */
-typedef struct opj_tile_v2_info {
-
- /** number (index) of tile */
- int tileno;
- /** coding style */
- OPJ_UINT32 csty;
- /** progression order */
- OPJ_PROG_ORDER prg;
- /** number of layers */
- OPJ_UINT32 numlayers;
- /** multi-component transform identifier */
- OPJ_UINT32 mct;
-
- /** information concerning tile component parameters*/
- opj_tccp_info_t *tccp_info;
-
-} opj_tile_info_v2_t;
-
-/**
- * Information structure about the codestream (FIXME should be expand and enhance)
- */
-typedef struct opj_codestream_info_v2 {
- /* Tile info */
- /** tile origin in x = XTOsiz */
- OPJ_UINT32 tx0;
- /** tile origin in y = YTOsiz */
- OPJ_UINT32 ty0;
- /** tile size in x = XTsiz */
- OPJ_UINT32 tdx;
- /** tile size in y = YTsiz */
- OPJ_UINT32 tdy;
- /** number of tiles in X */
- OPJ_UINT32 tw;
- /** number of tiles in Y */
- OPJ_UINT32 th;
-
- /** number of components*/
- OPJ_UINT32 nbcomps;
-
- /** Default information regarding tiles inside image */
- opj_tile_info_v2_t m_default_tile_info;
-
- /** information regarding tiles inside image */
- opj_tile_info_v2_t *tile_info; /* FIXME not used for the moment */
-
-} opj_codestream_info_v2_t;
-
-
-/**
- * Index structure about a tile part
- */
-typedef struct opj_tp_index {
- /** start position */
- OPJ_OFF_T start_pos;
- /** end position of the header */
- OPJ_OFF_T end_header;
- /** end position */
- OPJ_OFF_T end_pos;
-
-} opj_tp_index_t;
-
-/**
- * Index structure about a tile
- */
-typedef struct opj_tile_index {
- /** tile index */
- OPJ_UINT32 tileno;
-
- /** number of tile parts */
- OPJ_UINT32 nb_tps;
- /** current nb of tile part (allocated)*/
- OPJ_UINT32 current_nb_tps;
- /** current tile-part index */
- OPJ_UINT32 current_tpsno;
- /** information concerning tile parts */
- opj_tp_index_t *tp_index;
-
- /* UniPG>> */ /* NOT USED FOR THE MOMENT IN THE V2 VERSION */
- /** number of markers */
- OPJ_UINT32 marknum;
- /** list of markers */
- opj_marker_info_t *marker;
- /** actual size of markers array */
- OPJ_UINT32 maxmarknum;
- /* <<UniPG */
-
- /** packet number */
- OPJ_UINT32 nb_packet;
- /** information concerning packets inside tile */
- opj_packet_info_t *packet_index;
-
-} opj_tile_index_t;
-
-/**
- * Index structure of the codestream (FIXME should be expand and enhance)
- */
-typedef struct opj_codestream_index {
- /** main header start position (SOC position) */
- OPJ_OFF_T main_head_start;
- /** main header end position (first SOT position) */
- OPJ_OFF_T main_head_end;
-
- /** codestream's size */
- OPJ_UINT64 codestream_size;
-
- /* UniPG>> */ /* NOT USED FOR THE MOMENT IN THE V2 VERSION */
- /** number of markers */
- OPJ_UINT32 marknum;
- /** list of markers */
- opj_marker_info_t *marker;
- /** actual size of markers array */
- OPJ_UINT32 maxmarknum;
- /* <<UniPG */
-
- /** */
- OPJ_UINT32 nb_of_tiles;
- /** */
- opj_tile_index_t *tile_index; /* FIXME not used for the moment */
-
-} opj_codestream_index_t;
-/* -----------------------------------------------------------> */
-
-/*
-==========================================================
- Metadata from the JP2file
-==========================================================
-*/
-
-/**
- * Info structure of the JP2 file
- * EXPERIMENTAL FOR THE MOMENT
- */
-typedef struct opj_jp2_metadata {
- /** */
- OPJ_INT32 not_used;
-
-} opj_jp2_metadata_t;
-
-/**
- * Index structure of the JP2 file
- * EXPERIMENTAL FOR THE MOMENT
- */
-typedef struct opj_jp2_index {
- /** */
- OPJ_INT32 not_used;
-
-} opj_jp2_index_t;
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/*
-==========================================================
- openjpeg version
-==========================================================
-*/
-
-/* Get the version of the openjpeg library*/
-OPJ_API const char * OPJ_CALLCONV opj_version(void);
-
-/*
-==========================================================
- image functions definitions
-==========================================================
-*/
-
-/**
- * Create an image
- *
- * @param numcmpts number of components
- * @param cmptparms components parameters
- * @param clrspc image color space
- * @return returns a new image structure if successful, returns NULL otherwise
- * */
-OPJ_API opj_image_t* OPJ_CALLCONV opj_image_create(OPJ_UINT32 numcmpts,
- opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc);
-
-/**
- * Deallocate any resources associated with an image
- *
- * @param image image to be destroyed
- */
-OPJ_API void OPJ_CALLCONV opj_image_destroy(opj_image_t *image);
-
-/**
- * Creates an image without allocating memory for the image (used in the new version of the library).
- *
- * @param numcmpts the number of components
- * @param cmptparms the components parameters
- * @param clrspc the image color space
- *
- * @return a new image structure if successful, NULL otherwise.
-*/
-OPJ_API opj_image_t* OPJ_CALLCONV opj_image_tile_create(OPJ_UINT32 numcmpts,
- opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc);
-
-/**
- * Allocator for opj_image_t->comps[].data
- * To be paired with opj_image_data_free.
- *
- * @param size number of bytes to allocate
- *
- * @return a new pointer if successful, NULL otherwise.
- * @since 2.2.0
-*/
-OPJ_API void* OPJ_CALLCONV opj_image_data_alloc(OPJ_SIZE_T size);
-
-/**
- * Destructor for opj_image_t->comps[].data
- * To be paired with opj_image_data_alloc.
- *
- * @param ptr Pointer to free
- *
- * @since 2.2.0
-*/
-OPJ_API void OPJ_CALLCONV opj_image_data_free(void* ptr);
-
-/*
-==========================================================
- stream functions definitions
-==========================================================
-*/
-
-/**
- * Creates an abstract stream. This function does nothing except allocating memory and initializing the abstract stream.
- *
- * @param p_is_input if set to true then the stream will be an input stream, an output stream else.
- *
- * @return a stream object.
-*/
-OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_default_create(
- OPJ_BOOL p_is_input);
-
-/**
- * Creates an abstract stream. This function does nothing except allocating memory and initializing the abstract stream.
- *
- * @param p_buffer_size FIXME DOC
- * @param p_is_input if set to true then the stream will be an input stream, an output stream else.
- *
- * @return a stream object.
-*/
-OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create(OPJ_SIZE_T p_buffer_size,
- OPJ_BOOL p_is_input);
-
-/**
- * Destroys a stream created by opj_create_stream. This function does NOT close the abstract stream. If needed the user must
- * close its own implementation of the stream.
- *
- * @param p_stream the stream to destroy.
- */
-OPJ_API void OPJ_CALLCONV opj_stream_destroy(opj_stream_t* p_stream);
-
-/**
- * Sets the given function to be used as a read function.
- * @param p_stream the stream to modify
- * @param p_function the function to use a read function.
-*/
-OPJ_API void OPJ_CALLCONV opj_stream_set_read_function(opj_stream_t* p_stream,
- opj_stream_read_fn p_function);
-
-/**
- * Sets the given function to be used as a write function.
- * @param p_stream the stream to modify
- * @param p_function the function to use a write function.
-*/
-OPJ_API void OPJ_CALLCONV opj_stream_set_write_function(opj_stream_t* p_stream,
- opj_stream_write_fn p_function);
-
-/**
- * Sets the given function to be used as a skip function.
- * @param p_stream the stream to modify
- * @param p_function the function to use a skip function.
-*/
-OPJ_API void OPJ_CALLCONV opj_stream_set_skip_function(opj_stream_t* p_stream,
- opj_stream_skip_fn p_function);
-
-/**
- * Sets the given function to be used as a seek function, the stream is then seekable,
- * using SEEK_SET behavior.
- * @param p_stream the stream to modify
- * @param p_function the function to use a skip function.
-*/
-OPJ_API void OPJ_CALLCONV opj_stream_set_seek_function(opj_stream_t* p_stream,
- opj_stream_seek_fn p_function);
-
-/**
- * Sets the given data to be used as a user data for the stream.
- * @param p_stream the stream to modify
- * @param p_data the data to set.
- * @param p_function the function to free p_data when opj_stream_destroy() is called.
-*/
-OPJ_API void OPJ_CALLCONV opj_stream_set_user_data(opj_stream_t* p_stream,
- void * p_data, opj_stream_free_user_data_fn p_function);
-
-/**
- * Sets the length of the user data for the stream.
- *
- * @param p_stream the stream to modify
- * @param data_length length of the user_data.
-*/
-OPJ_API void OPJ_CALLCONV opj_stream_set_user_data_length(
- opj_stream_t* p_stream, OPJ_UINT64 data_length);
-
-/**
- * Create a stream from a file identified with its filename with default parameters (helper function)
- * @param fname the filename of the file to stream
- * @param p_is_read_stream whether the stream is a read stream (true) or not (false)
-*/
-OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create_default_file_stream(
- const char *fname, OPJ_BOOL p_is_read_stream);
-
-/** Create a stream from a file identified with its filename with a specific buffer size
- * @param fname the filename of the file to stream
- * @param p_buffer_size size of the chunk used to stream
- * @param p_is_read_stream whether the stream is a read stream (true) or not (false)
-*/
-OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream(
- const char *fname,
- OPJ_SIZE_T p_buffer_size,
- OPJ_BOOL p_is_read_stream);
-
-/*
-==========================================================
- event manager functions definitions
-==========================================================
-*/
-/**
- * Set the info handler use by openjpeg.
- * @param p_codec the codec previously initialise
- * @param p_callback the callback function which will be used
- * @param p_user_data client object where will be returned the message
-*/
-OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_info_handler(opj_codec_t * p_codec,
- opj_msg_callback p_callback,
- void * p_user_data);
-/**
- * Set the warning handler use by openjpeg.
- * @param p_codec the codec previously initialise
- * @param p_callback the callback function which will be used
- * @param p_user_data client object where will be returned the message
-*/
-OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_warning_handler(opj_codec_t * p_codec,
- opj_msg_callback p_callback,
- void * p_user_data);
-/**
- * Set the error handler use by openjpeg.
- * @param p_codec the codec previously initialise
- * @param p_callback the callback function which will be used
- * @param p_user_data client object where will be returned the message
-*/
-OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_error_handler(opj_codec_t * p_codec,
- opj_msg_callback p_callback,
- void * p_user_data);
-
-/*
-==========================================================
- codec functions definitions
-==========================================================
-*/
-
-/**
- * Creates a J2K/JP2 decompression structure
- * @param format Decoder to select
- *
- * @return Returns a handle to a decompressor if successful, returns NULL otherwise
- * */
-OPJ_API opj_codec_t* OPJ_CALLCONV opj_create_decompress(
- OPJ_CODEC_FORMAT format);
-
-/**
- * Destroy a decompressor handle
- *
- * @param p_codec decompressor handle to destroy
- */
-OPJ_API void OPJ_CALLCONV opj_destroy_codec(opj_codec_t * p_codec);
-
-/**
- * Read after the codestream if necessary
- * @param p_codec the JPEG2000 codec to read.
- * @param p_stream the JPEG2000 stream.
- */
-OPJ_API OPJ_BOOL OPJ_CALLCONV opj_end_decompress(opj_codec_t *p_codec,
- opj_stream_t *p_stream);
-
-
-/**
- * Set decoding parameters to default values
- * @param parameters Decompression parameters
- */
-OPJ_API void OPJ_CALLCONV opj_set_default_decoder_parameters(
- opj_dparameters_t *parameters);
-
-/**
- * Setup the decoder with decompression parameters provided by the user and with the message handler
- * provided by the user.
- *
- * @param p_codec decompressor handler
- * @param parameters decompression parameters
- *
- * @return true if the decoder is correctly set
- */
-OPJ_API OPJ_BOOL OPJ_CALLCONV opj_setup_decoder(opj_codec_t *p_codec,
- opj_dparameters_t *parameters);
-
-/**
- * Set strict decoding parameter for this decoder.
- * If strict decoding is enabled, partial bit streams will fail to decode, and
- * the check for invalid TPSOT values added in https://github.com/uclouvain/openjpeg/pull/514
- * will be disabled.
- * If strict decoding is disabled, the decoder will decode partial
- * bitstreams as much as possible without erroring, and the TPSOT fixing logic
- * will be enabled.
- *
- * @param p_codec decompressor handler
- * @param strict OPJ_TRUE to enable strict decoding, OPJ_FALSE to disable
- *
- * @return true if the decoder is correctly set
- */
-
-OPJ_API OPJ_BOOL OPJ_CALLCONV opj_decoder_set_strict_mode(opj_codec_t *p_codec,
- OPJ_BOOL strict);
-
-/**
- * Allocates worker threads for the compressor/decompressor.
- *
- * By default, only the main thread is used. If this function is not used,
- * but the OPJ_NUM_THREADS environment variable is set, its value will be
- * used to initialize the number of threads. The value can be either an integer
- * number, or "ALL_CPUS". If OPJ_NUM_THREADS is set and this function is called,
- * this function will override the behaviour of the environment variable.
- *
- * This function must be called after opj_setup_decoder() and
- * before opj_read_header() for the decoding side, or after opj_setup_encoder()
- * and before opj_start_compress() for the encoding side.
- *
- * @param p_codec decompressor or compressor handler
- * @param num_threads number of threads.
- *
- * @return OPJ_TRUE if the function is successful.
- */
-OPJ_API OPJ_BOOL OPJ_CALLCONV opj_codec_set_threads(opj_codec_t *p_codec,
- int num_threads);
-
-/**
- * Decodes an image header.
- *
- * @param p_stream the jpeg2000 stream.
- * @param p_codec the jpeg2000 codec to read.
- * @param p_image the image structure initialized with the characteristics of encoded image.
- *
- * @return true if the main header of the codestream and the JP2 header is correctly read.
- */
-OPJ_API OPJ_BOOL OPJ_CALLCONV opj_read_header(opj_stream_t *p_stream,
- opj_codec_t *p_codec,
- opj_image_t **p_image);
-
-
-/** Restrict the number of components to decode.
- *
- * This function should be called after opj_read_header().
- *
- * This function enables to restrict the set of decoded components to the
- * specified indices.
- * Note that the current implementation (apply_color_transforms == OPJ_FALSE)
- * is such that neither the multi-component transform at codestream level,
- * nor JP2 channel transformations will be applied.
- * Consequently the indices are relative to the codestream.
- *
- * Note: opj_decode_tile_data() should not be used together with opj_set_decoded_components().
- *
- * @param p_codec the jpeg2000 codec to read.
- * @param numcomps Size of the comps_indices array.
- * @param comps_indices Array of numcomps values representing the indices
- * of the components to decode (relative to the
- * codestream, starting at 0)
- * @param apply_color_transforms Whether multi-component transform at codestream level
- * or JP2 channel transformations should be applied.
- * Currently this parameter should be set to OPJ_FALSE.
- * Setting it to OPJ_TRUE will result in an error.
- *
- * @return OPJ_TRUE in case of success.
- */
-OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_decoded_components(opj_codec_t *p_codec,
- OPJ_UINT32 numcomps,
- const OPJ_UINT32* comps_indices,
- OPJ_BOOL apply_color_transforms);
-
-/**
- * Sets the given area to be decoded. This function should be called right after opj_read_header and before any tile header reading.
- *
- * The coordinates passed to this function should be expressed in the reference grid,
- * that is to say at the highest resolution level, even if requesting the image at lower
- * resolution levels.
- *
- * Generally opj_set_decode_area() should be followed by opj_decode(), and the
- * codec cannot be re-used.
- * In the particular case of an image made of a single tile, several sequences of
- * calls to opoj_set_decode_area() and opj_decode() are allowed, and will bring
- * performance improvements when reading an image by chunks.
- *
- * @param p_codec the jpeg2000 codec.
- * @param p_image the decoded image previously set by opj_read_header
- * @param p_start_x the left position of the rectangle to decode (in image coordinates).
- * @param p_end_x the right position of the rectangle to decode (in image coordinates).
- * @param p_start_y the up position of the rectangle to decode (in image coordinates).
- * @param p_end_y the bottom position of the rectangle to decode (in image coordinates).
- *
- * @return true if the area could be set.
- */
-OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_decode_area(opj_codec_t *p_codec,
- opj_image_t* p_image,
- OPJ_INT32 p_start_x, OPJ_INT32 p_start_y,
- OPJ_INT32 p_end_x, OPJ_INT32 p_end_y);
-
-/**
- * Decode an image from a JPEG-2000 codestream
- *
- * @param p_decompressor decompressor handle
- * @param p_stream Input buffer stream
- * @param p_image the decoded image
- * @return true if success, otherwise false
- * */
-OPJ_API OPJ_BOOL OPJ_CALLCONV opj_decode(opj_codec_t *p_decompressor,
- opj_stream_t *p_stream,
- opj_image_t *p_image);
-
-/**
- * Get the decoded tile from the codec
- *
- * @param p_codec the jpeg2000 codec.
- * @param p_stream input stream
- * @param p_image output image
- * @param tile_index index of the tile which will be decode
- *
- * @return true if success, otherwise false
- */
-OPJ_API OPJ_BOOL OPJ_CALLCONV opj_get_decoded_tile(opj_codec_t *p_codec,
- opj_stream_t *p_stream,
- opj_image_t *p_image,
- OPJ_UINT32 tile_index);
-
-/**
- * Set the resolution factor of the decoded image
- * @param p_codec the jpeg2000 codec.
- * @param res_factor resolution factor to set
- *
- * @return true if success, otherwise false
- */
-OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_decoded_resolution_factor(
- opj_codec_t *p_codec, OPJ_UINT32 res_factor);
-
-/**
- * Writes a tile with the given data.
- *
- * @param p_codec the jpeg2000 codec.
- * @param p_tile_index the index of the tile to write. At the moment, the tiles must be written from 0 to n-1 in sequence.
- * @param p_data pointer to the data to write. Data is arranged in sequence, data_comp0, then data_comp1, then ... NO INTERLEAVING should be set.
- * @param p_data_size this value os used to make sure the data being written is correct. The size must be equal to the sum for each component of
- * tile_width * tile_height * component_size. component_size can be 1,2 or 4 bytes, depending on the precision of the given component.
- * @param p_stream the stream to write data to.
- *
- * @return true if the data could be written.
- */
-OPJ_API OPJ_BOOL OPJ_CALLCONV opj_write_tile(opj_codec_t *p_codec,
- OPJ_UINT32 p_tile_index,
- OPJ_BYTE * p_data,
- OPJ_UINT32 p_data_size,
- opj_stream_t *p_stream);
-
-/**
- * Reads a tile header. This function is compulsory and allows one to know the size of the tile that will be decoded.
- * The user may need to refer to the image got by opj_read_header to understand the size being taken by the tile.
- *
- * @param p_codec the jpeg2000 codec.
- * @param p_tile_index pointer to a value that will hold the index of the tile being decoded, in case of success.
- * @param p_data_size pointer to a value that will hold the maximum size of the decoded data, in case of success. In case
- * of truncated codestreams, the actual number of bytes decoded may be lower. The computation of the size is the same
- * as depicted in opj_write_tile.
- * @param p_tile_x0 pointer to a value that will hold the x0 pos of the tile (in the image).
- * @param p_tile_y0 pointer to a value that will hold the y0 pos of the tile (in the image).
- * @param p_tile_x1 pointer to a value that will hold the x1 pos of the tile (in the image).
- * @param p_tile_y1 pointer to a value that will hold the y1 pos of the tile (in the image).
- * @param p_nb_comps pointer to a value that will hold the number of components in the tile.
- * @param p_should_go_on pointer to a boolean that will hold the fact that the decoding should go on. In case the
- * codestream is over at the time of the call, the value will be set to false. The user should then stop
- * the decoding.
- * @param p_stream the stream to decode.
- * @return true if the tile header could be decoded. In case the decoding should end, the returned value is still true.
- * returning false may be the result of a shortage of memory or an internal error.
- */
-OPJ_API OPJ_BOOL OPJ_CALLCONV opj_read_tile_header(opj_codec_t *p_codec,
- opj_stream_t * p_stream,
- OPJ_UINT32 * p_tile_index,
- OPJ_UINT32 * p_data_size,
- OPJ_INT32 * p_tile_x0, OPJ_INT32 * p_tile_y0,
- OPJ_INT32 * p_tile_x1, OPJ_INT32 * p_tile_y1,
- OPJ_UINT32 * p_nb_comps,
- OPJ_BOOL * p_should_go_on);
-
-/**
- * Reads a tile data. This function is compulsory and allows one to decode tile data. opj_read_tile_header should be called before.
- * The user may need to refer to the image got by opj_read_header to understand the size being taken by the tile.
- *
- * Note: opj_decode_tile_data() should not be used together with opj_set_decoded_components().
- *
- * @param p_codec the jpeg2000 codec.
- * @param p_tile_index the index of the tile being decoded, this should be the value set by opj_read_tile_header.
- * @param p_data pointer to a memory block that will hold the decoded data.
- * @param p_data_size size of p_data. p_data_size should be bigger or equal to the value set by opj_read_tile_header.
- * @param p_stream the stream to decode.
- *
- * @return true if the data could be decoded.
- */
-OPJ_API OPJ_BOOL OPJ_CALLCONV opj_decode_tile_data(opj_codec_t *p_codec,
- OPJ_UINT32 p_tile_index,
- OPJ_BYTE * p_data,
- OPJ_UINT32 p_data_size,
- opj_stream_t *p_stream);
-
-/* COMPRESSION FUNCTIONS*/
-
-/**
- * Creates a J2K/JP2 compression structure
- * @param format Coder to select
- * @return Returns a handle to a compressor if successful, returns NULL otherwise
- */
-OPJ_API opj_codec_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format);
-
-/**
-Set encoding parameters to default values, that means :
-<ul>
-<li>Lossless
-<li>1 tile
-<li>Size of precinct : 2^15 x 2^15 (means 1 precinct)
-<li>Size of code-block : 64 x 64
-<li>Number of resolutions: 6
-<li>No SOP marker in the codestream
-<li>No EPH marker in the codestream
-<li>No sub-sampling in x or y direction
-<li>No mode switch activated
-<li>Progression order: LRCP
-<li>No index file
-<li>No ROI upshifted
-<li>No offset of the origin of the image
-<li>No offset of the origin of the tiles
-<li>Reversible DWT 5-3
-</ul>
-@param parameters Compression parameters
-*/
-OPJ_API void OPJ_CALLCONV opj_set_default_encoder_parameters(
- opj_cparameters_t *parameters);
-
-/**
- * Setup the encoder parameters using the current image and using user parameters.
- * @param p_codec Compressor handle
- * @param parameters Compression parameters
- * @param image Input filled image
- */
-OPJ_API OPJ_BOOL OPJ_CALLCONV opj_setup_encoder(opj_codec_t *p_codec,
- opj_cparameters_t *parameters,
- opj_image_t *image);
-
-
-/**
- * Specify extra options for the encoder.
- *
- * This may be called after opj_setup_encoder() and before opj_start_compress()
- *
- * This is the way to add new options in a fully ABI compatible way, without
- * extending the opj_cparameters_t structure.
- *
- * Currently supported options are:
- * <ul>
- * <li>PLT=YES/NO. Defaults to NO. If set to YES, PLT marker segments,
- * indicating the length of each packet in the tile-part header, will be
- * written. Since 2.4.0</li>
- * <li>TLM=YES/NO. Defaults to NO (except for Cinema and IMF profiles).
- * If set to YES, TLM marker segments, indicating the length of each
- * tile-part part will be written. Since 2.4.0</li>
- * <li>GUARD_BITS=value. Number of guard bits in [0,7] range. Default value is 2.
- * 1 may be used sometimes (like in SMPTE DCP Bv2.1 Application Profile for 2K images).
- * Since 2.5.0</li>
- * </ul>
- *
- * @param p_codec Compressor handle
- * @param p_options Compression options. This should be a NULL terminated
- * array of strings. Each string is of the form KEY=VALUE.
- *
- * @return OPJ_TRUE in case of success.
- * @since 2.4.0
- */
-OPJ_API OPJ_BOOL OPJ_CALLCONV opj_encoder_set_extra_options(
- opj_codec_t *p_codec,
- const char* const* p_options);
-
-/**
- * Start to compress the current image.
- * @param p_codec Compressor handle
- * @param p_image Input filled image
- * @param p_stream Input stgream
- */
-OPJ_API OPJ_BOOL OPJ_CALLCONV opj_start_compress(opj_codec_t *p_codec,
- opj_image_t * p_image,
- opj_stream_t *p_stream);
-
-/**
- * End to compress the current image.
- * @param p_codec Compressor handle
- * @param p_stream Input stgream
- */
-OPJ_API OPJ_BOOL OPJ_CALLCONV opj_end_compress(opj_codec_t *p_codec,
- opj_stream_t *p_stream);
-
-/**
- * Encode an image into a JPEG-2000 codestream
- * @param p_codec compressor handle
- * @param p_stream Output buffer stream
- *
- * @return Returns true if successful, returns false otherwise
- */
-OPJ_API OPJ_BOOL OPJ_CALLCONV opj_encode(opj_codec_t *p_codec,
- opj_stream_t *p_stream);
-/*
-==========================================================
- codec output functions definitions
-==========================================================
-*/
-/* EXPERIMENTAL FUNCTIONS FOR NOW, USED ONLY IN J2K_DUMP*/
-
-/**
-Destroy Codestream information after compression or decompression
-@param cstr_info Codestream information structure
-*/
-OPJ_API void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_v2_t
- **cstr_info);
-
-
-/**
- * Dump the codec information into the output stream
- *
- * @param p_codec the jpeg2000 codec.
- * @param info_flag type of information dump.
- * @param output_stream output stream where dump the information gotten from the codec.
- *
- */
-OPJ_API void OPJ_CALLCONV opj_dump_codec(opj_codec_t *p_codec,
- OPJ_INT32 info_flag,
- FILE* output_stream);
-
-/**
- * Get the codestream information from the codec
- *
- * @param p_codec the jpeg2000 codec.
- *
- * @return a pointer to a codestream information structure.
- *
- */
-OPJ_API opj_codestream_info_v2_t* OPJ_CALLCONV opj_get_cstr_info(
- opj_codec_t *p_codec);
-
-/**
- * Get the codestream index from the codec
- *
- * @param p_codec the jpeg2000 codec.
- *
- * @return a pointer to a codestream index structure.
- *
- */
-OPJ_API opj_codestream_index_t * OPJ_CALLCONV opj_get_cstr_index(
- opj_codec_t *p_codec);
-
-OPJ_API void OPJ_CALLCONV opj_destroy_cstr_index(opj_codestream_index_t
- **p_cstr_index);
-
-
-/**
- * Get the JP2 file information from the codec FIXME
- *
- * @param p_codec the jpeg2000 codec.
- *
- * @return a pointer to a JP2 metadata structure.
- *
- */
-OPJ_API opj_jp2_metadata_t* OPJ_CALLCONV opj_get_jp2_metadata(
- opj_codec_t *p_codec);
-
-/**
- * Get the JP2 file index from the codec FIXME
- *
- * @param p_codec the jpeg2000 codec.
- *
- * @return a pointer to a JP2 index structure.
- *
- */
-OPJ_API opj_jp2_index_t* OPJ_CALLCONV opj_get_jp2_index(opj_codec_t *p_codec);
-
-
-/*
-==========================================================
- MCT functions
-==========================================================
-*/
-
-/**
- * Sets the MCT matrix to use.
- *
- * @param parameters the parameters to change.
- * @param pEncodingMatrix the encoding matrix.
- * @param p_dc_shift the dc shift coefficients to use.
- * @param pNbComp the number of components of the image.
- *
- * @return true if the parameters could be set.
- */
-OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_MCT(opj_cparameters_t *parameters,
- OPJ_FLOAT32 * pEncodingMatrix,
- OPJ_INT32 * p_dc_shift,
- OPJ_UINT32 pNbComp);
-
-/*
-==========================================================
- Thread functions
-==========================================================
-*/
-
-/** Returns if the library is built with thread support.
- * OPJ_TRUE if mutex, condition, thread, thread pool are available.
- */
-OPJ_API OPJ_BOOL OPJ_CALLCONV opj_has_thread_support(void);
-
-/** Return the number of virtual CPUs */
-OPJ_API int OPJ_CALLCONV opj_get_num_cpus(void);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* OPENJPEG_H */
diff --git a/contrib/libs/openjpeg/opj_clock.c b/contrib/libs/openjpeg/opj_clock.c
deleted file mode 100644
index 24f79a9ae7..0000000000
--- a/contrib/libs/openjpeg/opj_clock.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "opj_includes.h"
-
-#ifdef _WIN32
-#include <windows.h>
-#else
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <sys/times.h>
-#endif /* _WIN32 */
-
-OPJ_FLOAT64 opj_clock(void)
-{
-#ifdef _WIN32
- /* _WIN32: use QueryPerformance (very accurate) */
- LARGE_INTEGER freq, t ;
- /* freq is the clock speed of the CPU */
- QueryPerformanceFrequency(&freq) ;
- /* cout << "freq = " << ((double) freq.QuadPart) << endl; */
- /* t is the high resolution performance counter (see MSDN) */
- QueryPerformanceCounter(& t) ;
- return ((OPJ_FLOAT64) t.QuadPart / (OPJ_FLOAT64) freq.QuadPart) ;
-#else
- /* Unix or Linux: use resource usage */
- struct rusage t;
- OPJ_FLOAT64 procTime;
- /* (1) Get the rusage data structure at this moment (man getrusage) */
- getrusage(0, &t);
- /* (2) What is the elapsed time ? - CPU time = User time + System time */
- /* (2a) Get the seconds */
- procTime = (OPJ_FLOAT64)(t.ru_utime.tv_sec + t.ru_stime.tv_sec);
- /* (2b) More precisely! Get the microseconds part ! */
- return (procTime + (OPJ_FLOAT64)(t.ru_utime.tv_usec + t.ru_stime.tv_usec) *
- 1e-6) ;
-#endif
-}
-
diff --git a/contrib/libs/openjpeg/opj_clock.h b/contrib/libs/openjpeg/opj_clock.h
deleted file mode 100644
index 76366f53b5..0000000000
--- a/contrib/libs/openjpeg/opj_clock.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef OPJ_CLOCK_H
-#define OPJ_CLOCK_H
-/**
-@file opj_clock.h
-@brief Internal function for timing
-
-The functions in OPJ_CLOCK.C are internal utilities mainly used for timing.
-*/
-
-/** @defgroup MISC MISC - Miscellaneous internal functions */
-/*@{*/
-
-/** @name Exported functions */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-
-/**
-Difference in successive opj_clock() calls tells you the elapsed time
-@return Returns time in seconds
-*/
-OPJ_FLOAT64 opj_clock(void);
-
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* OPJ_CLOCK_H */
-
diff --git a/contrib/libs/openjpeg/opj_codec.h b/contrib/libs/openjpeg/opj_codec.h
deleted file mode 100644
index 7cff670824..0000000000
--- a/contrib/libs/openjpeg/opj_codec.h
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2014, Professor Benoit Macq
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef OPJ_CODEC_H
-#define OPJ_CODEC_H
-/**
-@file opj_codec.h
-*/
-
-
-/**
- * Main codec handler used for compression or decompression.
- */
-typedef struct opj_codec_private {
- /** FIXME DOC */
- union {
- /**
- * Decompression handler.
- */
- struct opj_decompression {
- /** Main header reading function handler */
- OPJ_BOOL(*opj_read_header)(struct opj_stream_private * cio,
- void * p_codec,
- opj_image_t **p_image,
- struct opj_event_mgr * p_manager);
-
- /** Decoding function */
- OPJ_BOOL(*opj_decode)(void * p_codec,
- struct opj_stream_private * p_cio,
- opj_image_t * p_image,
- struct opj_event_mgr * p_manager);
-
- /** FIXME DOC */
- OPJ_BOOL(*opj_read_tile_header)(void * p_codec,
- OPJ_UINT32 * p_tile_index,
- OPJ_UINT32 * p_data_size,
- OPJ_INT32 * p_tile_x0,
- OPJ_INT32 * p_tile_y0,
- OPJ_INT32 * p_tile_x1,
- OPJ_INT32 * p_tile_y1,
- OPJ_UINT32 * p_nb_comps,
- OPJ_BOOL * p_should_go_on,
- struct opj_stream_private * p_cio,
- struct opj_event_mgr * p_manager);
-
- /** FIXME DOC */
- OPJ_BOOL(*opj_decode_tile_data)(void * p_codec,
- OPJ_UINT32 p_tile_index,
- OPJ_BYTE * p_data,
- OPJ_UINT32 p_data_size,
- struct opj_stream_private * p_cio,
- struct opj_event_mgr * p_manager);
-
- /** Reading function used after codestream if necessary */
- OPJ_BOOL(* opj_end_decompress)(void *p_codec,
- struct opj_stream_private * cio,
- struct opj_event_mgr * p_manager);
-
- /** Codec destroy function handler */
- void (*opj_destroy)(void * p_codec);
-
- /** Setup decoder function handler */
- void (*opj_setup_decoder)(void * p_codec, opj_dparameters_t * p_param);
-
- /** Strict mode function handler */
- void (*opj_decoder_set_strict_mode)(void * p_codec, OPJ_BOOL strict);
-
- /** Set decode area function handler */
- OPJ_BOOL(*opj_set_decode_area)(void * p_codec,
- opj_image_t * p_image,
- OPJ_INT32 p_start_x,
- OPJ_INT32 p_end_x,
- OPJ_INT32 p_start_y,
- OPJ_INT32 p_end_y,
- struct opj_event_mgr * p_manager);
-
- /** Get tile function */
- OPJ_BOOL(*opj_get_decoded_tile)(void *p_codec,
- opj_stream_private_t * p_cio,
- opj_image_t *p_image,
- struct opj_event_mgr * p_manager,
- OPJ_UINT32 tile_index);
-
- /** Set the decoded resolution factor */
- OPJ_BOOL(*opj_set_decoded_resolution_factor)(void * p_codec,
- OPJ_UINT32 res_factor,
- opj_event_mgr_t * p_manager);
-
- /** Set the decoded components */
- OPJ_BOOL(*opj_set_decoded_components)(void * p_codec,
- OPJ_UINT32 num_comps,
- const OPJ_UINT32* comps_indices,
- opj_event_mgr_t * p_manager);
- } m_decompression;
-
- /**
- * Compression handler. FIXME DOC
- */
- struct opj_compression {
- OPJ_BOOL(* opj_start_compress)(void *p_codec,
- struct opj_stream_private * cio,
- struct opj_image * p_image,
- struct opj_event_mgr * p_manager);
-
- OPJ_BOOL(* opj_encode)(void * p_codec,
- struct opj_stream_private *p_cio,
- struct opj_event_mgr * p_manager);
-
- OPJ_BOOL(* opj_write_tile)(void * p_codec,
- OPJ_UINT32 p_tile_index,
- OPJ_BYTE * p_data,
- OPJ_UINT32 p_data_size,
- struct opj_stream_private * p_cio,
- struct opj_event_mgr * p_manager);
-
- OPJ_BOOL(* opj_end_compress)(void * p_codec,
- struct opj_stream_private * p_cio,
- struct opj_event_mgr * p_manager);
-
- void (* opj_destroy)(void * p_codec);
-
- OPJ_BOOL(* opj_setup_encoder)(void * p_codec,
- opj_cparameters_t * p_param,
- struct opj_image * p_image,
- struct opj_event_mgr * p_manager);
-
- OPJ_BOOL(* opj_encoder_set_extra_options)(void * p_codec,
- const char* const* p_options,
- struct opj_event_mgr * p_manager);
-
- } m_compression;
- } m_codec_data;
- /** FIXME DOC*/
- void * m_codec;
- /** Event handler */
- opj_event_mgr_t m_event_mgr;
- /** Flag to indicate if the codec is used to decode or encode*/
- OPJ_BOOL is_decompressor;
- void (*opj_dump_codec)(void * p_codec, OPJ_INT32 info_flag,
- FILE* output_stream);
- opj_codestream_info_v2_t* (*opj_get_codec_info)(void* p_codec);
- opj_codestream_index_t* (*opj_get_codec_index)(void* p_codec);
-
- /** Set number of threads */
- OPJ_BOOL(*opj_set_threads)(void * p_codec, OPJ_UINT32 num_threads);
-}
-opj_codec_private_t;
-
-
-#endif /* OPJ_CODEC_H */
-
diff --git a/contrib/libs/openjpeg/opj_common.h b/contrib/libs/openjpeg/opj_common.h
deleted file mode 100644
index 2923a35b7f..0000000000
--- a/contrib/libs/openjpeg/opj_common.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2017, IntoPIX SA <support@intopix.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef OPJ_COMMON_H
-#define OPJ_COMMON_H
-
-/*
- ==========================================================
- Common constants shared among several modules
- ==========================================================
-*/
-#define OPJ_COMMON_CBLK_DATA_EXTRA 2 /**< Margin for a fake FFFF marker */
-
-
-#define OPJ_COMP_PARAM_DEFAULT_CBLOCKW 64
-#define OPJ_COMP_PARAM_DEFAULT_CBLOCKH 64
-#define OPJ_COMP_PARAM_DEFAULT_PROG_ORDER OPJ_LRCP
-#define OPJ_COMP_PARAM_DEFAULT_NUMRESOLUTION 6
-
-#endif /* OPJ_COMMON_H */
diff --git a/contrib/libs/openjpeg/opj_config.h b/contrib/libs/openjpeg/opj_config.h
deleted file mode 100644
index 50d156357d..0000000000
--- a/contrib/libs/openjpeg/opj_config.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef OPJ_CONFIG_H_INCLUDED
-#define OPJ_CONFIG_H_INCLUDED
-
-/* create opj_config.h for CMake */
-
-/*--------------------------------------------------------------------------*/
-/* OpenJPEG Versioning */
-
-/* Version number. */
-#define OPJ_VERSION_MAJOR 2
-#define OPJ_VERSION_MINOR 5
-#define OPJ_VERSION_BUILD 3
-
-#endif
diff --git a/contrib/libs/openjpeg/opj_config_private-linux.h b/contrib/libs/openjpeg/opj_config_private-linux.h
deleted file mode 100644
index 8076e7d32a..0000000000
--- a/contrib/libs/openjpeg/opj_config_private-linux.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/* create opj_config_private.h for CMake */
-
-#define OPJ_PACKAGE_VERSION "2.5.3"
-
-/* Not used by openjp2*/
-/*#define HAVE_MEMORY_H 1*/
-/*#define HAVE_STDLIB_H 1*/
-/*#define HAVE_STRINGS_H 1*/
-/*#define HAVE_STRING_H 1*/
-/*#define HAVE_SYS_STAT_H 1*/
-/*#define HAVE_SYS_TYPES_H 1 */
-/*#define HAVE_UNISTD_H 1*/
-/*#define HAVE_INTTYPES_H 1 */
-/*#define HAVE_STDINT_H 1 */
-
-/* #undef _LARGEFILE_SOURCE */
-/* #undef _LARGE_FILES */
-/* #undef _FILE_OFFSET_BITS */
-#define OPJ_HAVE_FSEEKO ON
-
-/* find whether or not have <malloc.h> */
-#define OPJ_HAVE_MALLOC_H
-/* check if function `aligned_alloc` exists */
-/* #undef OPJ_HAVE_ALIGNED_ALLOC */
-/* check if function `_aligned_malloc` exists */
-/* #undef OPJ_HAVE__ALIGNED_MALLOC */
-/* check if function `memalign` exists */
-#define OPJ_HAVE_MEMALIGN
-/* check if function `posix_memalign` exists */
-#define OPJ_HAVE_POSIX_MEMALIGN
-
-#if !defined(_POSIX_C_SOURCE)
-#if defined(OPJ_HAVE_FSEEKO) || defined(OPJ_HAVE_POSIX_MEMALIGN)
-/* Get declarations of fseeko, ftello, posix_memalign. */
-#define _POSIX_C_SOURCE 200112L
-#endif
-#endif
-
-/* Byte order. */
-/* All compilers that support Mac OS X define either __BIG_ENDIAN__ or
-__LITTLE_ENDIAN__ to match the endianness of the architecture being
-compiled for. This is not necessarily the same as the architecture of the
-machine doing the building. In order to support Universal Binaries on
-Mac OS X, we prefer those defines to decide the endianness.
-On other platforms we use the result of the TRY_RUN. */
-#if !defined(__APPLE__)
-/* #undef OPJ_BIG_ENDIAN */
-#elif defined(__BIG_ENDIAN__)
-# define OPJ_BIG_ENDIAN
-#endif
diff --git a/contrib/libs/openjpeg/opj_config_private-osx.h b/contrib/libs/openjpeg/opj_config_private-osx.h
deleted file mode 100644
index 63de557822..0000000000
--- a/contrib/libs/openjpeg/opj_config_private-osx.h
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "opj_config_private-linux.h"
-#undef OPJ_HAVE_MALLOC_H
-#undef OPJ_HAVE_MEMALIGN
diff --git a/contrib/libs/openjpeg/opj_config_private-win.h b/contrib/libs/openjpeg/opj_config_private-win.h
deleted file mode 100644
index b276db0e9c..0000000000
--- a/contrib/libs/openjpeg/opj_config_private-win.h
+++ /dev/null
@@ -1,4 +0,0 @@
-#include "opj_config_private-linux.h"
-#undef OPJ_HAVE_POSIX_MEMALIGN
-#undef OPJ_HAVE_MEMALIGN
-#define OPJ_HAVE__ALIGNED_MALLOC
diff --git a/contrib/libs/openjpeg/opj_config_private.h b/contrib/libs/openjpeg/opj_config_private.h
deleted file mode 100644
index c2f1b5392b..0000000000
--- a/contrib/libs/openjpeg/opj_config_private.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#pragma once
-
-#if defined(__APPLE__)
-# include "opj_config_private-osx.h"
-#elif defined(_MSC_VER)
-# include "opj_config_private-win.h"
-#else
-# include "opj_config_private-linux.h"
-#endif
diff --git a/contrib/libs/openjpeg/opj_includes.h b/contrib/libs/openjpeg/opj_includes.h
deleted file mode 100644
index 787d029d3f..0000000000
--- a/contrib/libs/openjpeg/opj_includes.h
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR
- * Copyright (c) 2012, CS Systemes d'Information, France
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef OPJ_INCLUDES_H
-#define OPJ_INCLUDES_H
-
-/*
- * This must be included before any system headers,
- * since they can react to macro defined there
- */
-#include "opj_config_private.h"
-
-/*
- ==========================================================
- Standard includes used by the library
- ==========================================================
-*/
-#include <memory.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-#include <float.h>
-#include <time.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <ctype.h>
-#include <assert.h>
-#include <limits.h>
-#include <stdint.h>
-#include <inttypes.h>
-
-/*
- Use fseeko() and ftello() if they are available since they use
- 'off_t' rather than 'long'. It is wrong to use fseeko() and
- ftello() only on systems with special LFS support since some systems
- (e.g. FreeBSD) support a 64-bit off_t by default.
-*/
-#if defined(OPJ_HAVE_FSEEKO) && !defined(fseek)
-# define fseek fseeko
-# define ftell ftello
-#endif
-
-
-#if defined(WIN32) && !defined(Windows95) && !defined(__BORLANDC__) && \
- !(defined(_MSC_VER) && _MSC_VER < 1400) && \
- !(defined(__MINGW32__) && __MSVCRT_VERSION__ < 0x800)
-/*
- Windows '95 and Borland C do not support _lseeki64
- Visual Studio does not support _fseeki64 and _ftelli64 until the 2005 release.
- Without these interfaces, files over 2GB in size are not supported for Windows.
-*/
-# define OPJ_FSEEK(stream,offset,whence) _fseeki64(stream,/* __int64 */ offset,whence)
-# define OPJ_FSTAT(fildes,stat_buff) _fstati64(fildes,/* struct _stati64 */ stat_buff)
-# define OPJ_FTELL(stream) /* __int64 */ _ftelli64(stream)
-# define OPJ_STAT_STRUCT_T struct _stati64
-# define OPJ_STAT(path,stat_buff) _stati64(path,/* struct _stati64 */ stat_buff)
-#else
-# define OPJ_FSEEK(stream,offset,whence) fseek(stream,offset,whence)
-# define OPJ_FSTAT(fildes,stat_buff) fstat(fildes,stat_buff)
-# define OPJ_FTELL(stream) ftell(stream)
-# define OPJ_STAT_STRUCT_T struct stat
-# define OPJ_STAT(path,stat_buff) stat(path,stat_buff)
-#endif
-
-
-/*
- ==========================================================
- OpenJPEG interface
- ==========================================================
- */
-#include "openjpeg.h"
-
-/*
- ==========================================================
- OpenJPEG modules
- ==========================================================
-*/
-
-/* Are restricted pointers available? (C99) */
-#if (__STDC_VERSION__ >= 199901L)
-#define OPJ_RESTRICT restrict
-#else
-/* Not a C99 compiler */
-#if defined(__GNUC__)
-#define OPJ_RESTRICT __restrict__
-
-/*
- vc14 (2015) outputs wrong results.
- Need to check OPJ_RESTRICT usage (or a bug in vc14)
- #elif defined(_MSC_VER) && (_MSC_VER >= 1400)
- #define OPJ_RESTRICT __restrict
-*/
-#else
-#define OPJ_RESTRICT /* restrict */
-#endif
-#endif
-
-#ifdef __has_attribute
-#if __has_attribute(no_sanitize)
-#define OPJ_NOSANITIZE(kind) __attribute__((no_sanitize(kind)))
-#endif
-#endif
-#ifndef OPJ_NOSANITIZE
-#define OPJ_NOSANITIZE(kind)
-#endif
-
-
-/* MSVC before 2013 and Borland C do not have lrintf */
-#if defined(_MSC_VER)
-#include <intrin.h>
-static INLINE long opj_lrintf(float f)
-{
-#ifdef _M_X64
- return _mm_cvt_ss2si(_mm_load_ss(&f));
-
- /* commented out line breaks many tests */
- /* return (long)((f>0.0f) ? (f + 0.5f):(f -0.5f)); */
-#elif defined(_M_IX86)
- int i;
- _asm{
- fld f
- fistp i
- };
-
- return i;
-#else
- return (long)((f>0.0f) ? (f + 0.5f) : (f - 0.5f));
-#endif
-}
-#elif defined(__BORLANDC__)
-static INLINE long opj_lrintf(float f)
-{
-#ifdef _M_X64
- return (long)((f > 0.0f) ? (f + 0.5f) : (f - 0.5f));
-#else
- int i;
-
- _asm {
- fld f
- fistp i
- };
-
- return i;
-#endif
-}
-#else
-static INLINE long opj_lrintf(float f)
-{
- return lrintf(f);
-}
-#endif
-
-#if defined(_MSC_VER) && (_MSC_VER < 1400)
-#define vsnprintf _vsnprintf
-#endif
-
-/* MSVC x86 is really bad at doing int64 = int32 * int32 on its own. Use intrinsic. */
-#if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(__INTEL_COMPILER) && defined(_M_IX86)
-# include <intrin.h>
-# pragma intrinsic(__emul)
-#endif
-
-/* Apparently Visual Studio doesn't define __SSE__ / __SSE2__ macros */
-#if defined(_M_X64)
-/* Intel 64bit support SSE and SSE2 */
-# ifndef __SSE__
-# define __SSE__ 1
-# endif
-# ifndef __SSE2__
-# define __SSE2__ 1
-# endif
-#endif
-
-/* For x86, test the value of the _M_IX86_FP macro. */
-/* See https://msdn.microsoft.com/en-us/library/b0084kay.aspx */
-#if defined(_M_IX86_FP)
-# if _M_IX86_FP >= 1
-# ifndef __SSE__
-# define __SSE__ 1
-# endif
-# endif
-# if _M_IX86_FP >= 2
-# ifndef __SSE2__
-# define __SSE2__ 1
-# endif
-# endif
-#endif
-
-/* Type to use for bit-fields in internal headers */
-typedef unsigned int OPJ_BITFIELD;
-
-#define OPJ_UNUSED(x) (void)x
-
-#include "opj_clock.h"
-#include "opj_malloc.h"
-#include "event.h"
-#include "function_list.h"
-#include "bio.h"
-#include "cio.h"
-
-#include "thread.h"
-#include "tls_keys.h"
-
-#include "image.h"
-#include "invert.h"
-#include "j2k.h"
-#include "jp2.h"
-
-#include "mqc.h"
-#include "bio.h"
-
-#include "pi.h"
-#include "tgt.h"
-#include "tcd.h"
-#include "t1.h"
-#include "dwt.h"
-#include "t2.h"
-#include "mct.h"
-#include "opj_intmath.h"
-#include "sparse_array.h"
-
-#ifdef USE_JPIP
-#error #include "cidx_manager.h"
-#error #include "indexbox_manager.h"
-#endif
-
-/* JPWL>> */
-#ifdef USE_JPWL
-#error #include "openjpwl/jpwl.h"
-#endif /* USE_JPWL */
-/* <<JPWL */
-
-/* V2 */
-#include "opj_codec.h"
-
-
-#endif /* OPJ_INCLUDES_H */
diff --git a/contrib/libs/openjpeg/opj_intmath.h b/contrib/libs/openjpeg/opj_intmath.h
deleted file mode 100644
index cce7a3cafa..0000000000
--- a/contrib/libs/openjpeg/opj_intmath.h
+++ /dev/null
@@ -1,333 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2014, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux
- * Copyright (c) 2003-2014, Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef OPJ_INTMATH_H
-#define OPJ_INTMATH_H
-/**
-@file opj_intmath.h
-@brief Implementation of operations on integers (INT)
-
-The functions in OPJ_INTMATH.H have for goal to realize operations on integers.
-*/
-
-/** @defgroup OPJ_INTMATH OPJ_INTMATH - Implementation of operations on integers */
-/*@{*/
-
-/** @name Exported functions (see also openjpeg.h) */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-/**
-Get the minimum of two integers
-@return Returns a if a < b else b
-*/
-static INLINE OPJ_INT32 opj_int_min(OPJ_INT32 a, OPJ_INT32 b)
-{
- return a < b ? a : b;
-}
-
-/**
-Get the minimum of two integers
-@return Returns a if a < b else b
-*/
-static INLINE OPJ_UINT32 opj_uint_min(OPJ_UINT32 a, OPJ_UINT32 b)
-{
- return a < b ? a : b;
-}
-
-/**
-Get the maximum of two integers
-@return Returns a if a > b else b
-*/
-static INLINE OPJ_INT32 opj_int_max(OPJ_INT32 a, OPJ_INT32 b)
-{
- return (a > b) ? a : b;
-}
-
-/**
-Get the maximum of two integers
-@return Returns a if a > b else b
-*/
-static INLINE OPJ_UINT32 opj_uint_max(OPJ_UINT32 a, OPJ_UINT32 b)
-{
- return (a > b) ? a : b;
-}
-
-/**
- Get the saturated sum of two unsigned integers
- @return Returns saturated sum of a+b
- */
-static INLINE OPJ_UINT32 opj_uint_adds(OPJ_UINT32 a, OPJ_UINT32 b)
-{
- OPJ_UINT64 sum = (OPJ_UINT64)a + (OPJ_UINT64)b;
- return (OPJ_UINT32)(-(OPJ_INT32)(sum >> 32)) | (OPJ_UINT32)sum;
-}
-
-/**
- Get the saturated difference of two unsigned integers
- @return Returns saturated sum of a-b
- */
-static INLINE OPJ_UINT32 opj_uint_subs(OPJ_UINT32 a, OPJ_UINT32 b)
-{
- return (a >= b) ? a - b : 0;
-}
-
-/**
-Clamp an integer inside an interval
-@return
-<ul>
-<li>Returns a if (min < a < max)
-<li>Returns max if (a > max)
-<li>Returns min if (a < min)
-</ul>
-*/
-static INLINE OPJ_INT32 opj_int_clamp(OPJ_INT32 a, OPJ_INT32 min,
- OPJ_INT32 max)
-{
- if (a < min) {
- return min;
- }
- if (a > max) {
- return max;
- }
- return a;
-}
-
-/**
-Clamp an integer inside an interval
-@return
-<ul>
-<li>Returns a if (min < a < max)
-<li>Returns max if (a > max)
-<li>Returns min if (a < min)
-</ul>
-*/
-static INLINE OPJ_INT64 opj_int64_clamp(OPJ_INT64 a, OPJ_INT64 min,
- OPJ_INT64 max)
-{
- if (a < min) {
- return min;
- }
- if (a > max) {
- return max;
- }
- return a;
-}
-
-/**
-@return Get absolute value of integer
-*/
-static INLINE OPJ_INT32 opj_int_abs(OPJ_INT32 a)
-{
- return a < 0 ? -a : a;
-}
-/**
-Divide an integer and round upwards
-@return Returns a divided by b
-*/
-static INLINE OPJ_INT32 opj_int_ceildiv(OPJ_INT32 a, OPJ_INT32 b)
-{
- assert(b);
- return (OPJ_INT32)(((OPJ_INT64)a + b - 1) / b);
-}
-
-/**
-Divide an integer and round upwards
-@return Returns a divided by b
-*/
-static INLINE OPJ_UINT32 opj_uint_ceildiv(OPJ_UINT32 a, OPJ_UINT32 b)
-{
- assert(b);
- return (OPJ_UINT32)(((OPJ_UINT64)a + b - 1) / b);
-}
-
-/**
-Divide an integer and round upwards
-@return Returns a divided by b
-*/
-static INLINE OPJ_UINT32 opj_uint64_ceildiv_res_uint32(OPJ_UINT64 a,
- OPJ_UINT64 b)
-{
- assert(b);
- return (OPJ_UINT32)((a + b - 1) / b);
-}
-
-/**
-Divide an integer by a power of 2 and round upwards
-@return Returns a divided by 2^b
-*/
-static INLINE OPJ_INT32 opj_int_ceildivpow2(OPJ_INT32 a, OPJ_INT32 b)
-{
- return (OPJ_INT32)((a + ((OPJ_INT64)1 << b) - 1) >> b);
-}
-
-/**
- Divide a 64bits integer by a power of 2 and round upwards
- @return Returns a divided by 2^b
- */
-static INLINE OPJ_INT32 opj_int64_ceildivpow2(OPJ_INT64 a, OPJ_INT32 b)
-{
- return (OPJ_INT32)((a + ((OPJ_INT64)1 << b) - 1) >> b);
-}
-
-/**
- Divide an integer by a power of 2 and round upwards
- @return Returns a divided by 2^b
- */
-static INLINE OPJ_UINT32 opj_uint_ceildivpow2(OPJ_UINT32 a, OPJ_UINT32 b)
-{
- return (OPJ_UINT32)((a + ((OPJ_UINT64)1U << b) - 1U) >> b);
-}
-
-/**
-Divide an integer by a power of 2 and round downwards
-@return Returns a divided by 2^b
-*/
-static INLINE OPJ_INT32 opj_int_floordivpow2(OPJ_INT32 a, OPJ_INT32 b)
-{
- return a >> b;
-}
-
-/**
-Divide an integer by a power of 2 and round downwards
-@return Returns a divided by 2^b
-*/
-static INLINE OPJ_UINT32 opj_uint_floordivpow2(OPJ_UINT32 a, OPJ_UINT32 b)
-{
- return a >> b;
-}
-
-/**
-Get logarithm of an integer and round downwards
-@return Returns log2(a)
-*/
-static INLINE OPJ_INT32 opj_int_floorlog2(OPJ_INT32 a)
-{
- OPJ_INT32 l;
- for (l = 0; a > 1; l++) {
- a >>= 1;
- }
- return l;
-}
-/**
-Get logarithm of an integer and round downwards
-@return Returns log2(a)
-*/
-static INLINE OPJ_UINT32 opj_uint_floorlog2(OPJ_UINT32 a)
-{
- OPJ_UINT32 l;
- for (l = 0; a > 1; ++l) {
- a >>= 1;
- }
- return l;
-}
-
-/**
-Multiply two fixed-precision rational numbers.
-@param a
-@param b
-@return Returns a * b
-*/
-static INLINE OPJ_INT32 opj_int_fix_mul(OPJ_INT32 a, OPJ_INT32 b)
-{
-#if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(__INTEL_COMPILER) && defined(_M_IX86)
- OPJ_INT64 temp = __emul(a, b);
-#else
- OPJ_INT64 temp = (OPJ_INT64) a * (OPJ_INT64) b ;
-#endif
- temp += 4096;
- assert((temp >> 13) <= (OPJ_INT64)0x7FFFFFFF);
- assert((temp >> 13) >= (-(OPJ_INT64)0x7FFFFFFF - (OPJ_INT64)1));
- return (OPJ_INT32)(temp >> 13);
-}
-
-static INLINE OPJ_INT32 opj_int_fix_mul_t1(OPJ_INT32 a, OPJ_INT32 b)
-{
-#if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(__INTEL_COMPILER) && defined(_M_IX86)
- OPJ_INT64 temp = __emul(a, b);
-#else
- OPJ_INT64 temp = (OPJ_INT64) a * (OPJ_INT64) b ;
-#endif
- temp += 4096;
- assert((temp >> (13 + 11 - T1_NMSEDEC_FRACBITS)) <= (OPJ_INT64)0x7FFFFFFF);
- assert((temp >> (13 + 11 - T1_NMSEDEC_FRACBITS)) >= (-(OPJ_INT64)0x7FFFFFFF -
- (OPJ_INT64)1));
- return (OPJ_INT32)(temp >> (13 + 11 - T1_NMSEDEC_FRACBITS)) ;
-}
-
-/**
-Addition two signed integers with a wrap-around behaviour.
-Assumes complement-to-two signed integers.
-@param a
-@param b
-@return Returns a + b
-*/
-static INLINE OPJ_INT32 opj_int_add_no_overflow(OPJ_INT32 a, OPJ_INT32 b)
-{
- void* pa = &a;
- void* pb = &b;
- OPJ_UINT32* upa = (OPJ_UINT32*)pa;
- OPJ_UINT32* upb = (OPJ_UINT32*)pb;
- OPJ_UINT32 ures = *upa + *upb;
- void* pures = &ures;
- OPJ_INT32* ipres = (OPJ_INT32*)pures;
- return *ipres;
-}
-
-/**
-Subtract two signed integers with a wrap-around behaviour.
-Assumes complement-to-two signed integers.
-@param a
-@param b
-@return Returns a - b
-*/
-static INLINE OPJ_INT32 opj_int_sub_no_overflow(OPJ_INT32 a, OPJ_INT32 b)
-{
- void* pa = &a;
- void* pb = &b;
- OPJ_UINT32* upa = (OPJ_UINT32*)pa;
- OPJ_UINT32* upb = (OPJ_UINT32*)pb;
- OPJ_UINT32 ures = *upa - *upb;
- void* pures = &ures;
- OPJ_INT32* ipres = (OPJ_INT32*)pures;
- return *ipres;
-}
-
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* OPJ_INTMATH_H */
diff --git a/contrib/libs/openjpeg/opj_malloc.c b/contrib/libs/openjpeg/opj_malloc.c
deleted file mode 100644
index dca91bfcbe..0000000000
--- a/contrib/libs/openjpeg/opj_malloc.c
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2015, Mathieu Malaterre <mathieu.malaterre@gmail.com>
- * Copyright (c) 2015, Matthieu Darbois
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#define OPJ_SKIP_POISON
-#include "opj_includes.h"
-
-#if defined(OPJ_HAVE_MALLOC_H) && defined(OPJ_HAVE_MEMALIGN)
-# include <malloc.h>
-#endif
-
-#ifndef SIZE_MAX
-# define SIZE_MAX ((size_t) -1)
-#endif
-
-static INLINE void *opj_aligned_alloc_n(size_t alignment, size_t size)
-{
- void* ptr;
-
- /* alignment shall be power of 2 */
- assert((alignment != 0U) && ((alignment & (alignment - 1U)) == 0U));
- /* alignment shall be at least sizeof(void*) */
- assert(alignment >= sizeof(void*));
-
- if (size == 0U) { /* prevent implementation defined behavior of realloc */
- return NULL;
- }
-
-#if defined(OPJ_HAVE_POSIX_MEMALIGN)
- /* aligned_alloc requires c11, restrict to posix_memalign for now. Quote:
- * This function was introduced in POSIX 1003.1d. Although this function is
- * superseded by aligned_alloc, it is more portable to older POSIX systems
- * that do not support ISO C11. */
- if (posix_memalign(&ptr, alignment, size)) {
- ptr = NULL;
- }
- /* older linux */
-#elif defined(OPJ_HAVE_MEMALIGN)
- ptr = memalign(alignment, size);
- /* _MSC_VER */
-#elif defined(OPJ_HAVE__ALIGNED_MALLOC)
- ptr = _aligned_malloc(size, alignment);
-#else
- /*
- * Generic aligned malloc implementation.
- * Uses size_t offset for the integer manipulation of the pointer,
- * as uintptr_t is not available in C89 to do
- * bitwise operations on the pointer itself.
- */
- alignment--;
- {
- size_t offset;
- OPJ_UINT8 *mem;
-
- /* Room for padding and extra pointer stored in front of allocated area */
- size_t overhead = alignment + sizeof(void *);
-
- /* let's be extra careful */
- assert(alignment <= (SIZE_MAX - sizeof(void *)));
-
- /* Avoid integer overflow */
- if (size > (SIZE_MAX - overhead)) {
- return NULL;
- }
-
- mem = (OPJ_UINT8*)malloc(size + overhead);
- if (mem == NULL) {
- return mem;
- }
- /* offset = ((alignment + 1U) - ((size_t)(mem + sizeof(void*)) & alignment)) & alignment; */
- /* Use the fact that alignment + 1U is a power of 2 */
- offset = ((alignment ^ ((size_t)(mem + sizeof(void*)) & alignment)) + 1U) &
- alignment;
- ptr = (void *)(mem + sizeof(void*) + offset);
- ((void**) ptr)[-1] = mem;
- }
-#endif
- return ptr;
-}
-static INLINE void *opj_aligned_realloc_n(void *ptr, size_t alignment,
- size_t new_size)
-{
- void *r_ptr;
-
- /* alignment shall be power of 2 */
- assert((alignment != 0U) && ((alignment & (alignment - 1U)) == 0U));
- /* alignment shall be at least sizeof(void*) */
- assert(alignment >= sizeof(void*));
-
- if (new_size == 0U) { /* prevent implementation defined behavior of realloc */
- return NULL;
- }
-
- /* no portable aligned realloc */
-#if defined(OPJ_HAVE_POSIX_MEMALIGN) || defined(OPJ_HAVE_MEMALIGN)
- /* glibc doc states one can mix aligned malloc with realloc */
- r_ptr = realloc(ptr, new_size); /* fast path */
- /* we simply use `size_t` to cast, since we are only interest in binary AND
- * operator */
- if (((size_t)r_ptr & (alignment - 1U)) != 0U) {
- /* this is non-trivial to implement a portable aligned realloc, so use a
- * simple approach where we do not need a function that return the size of an
- * allocated array (eg. _msize on Windows, malloc_size on MacOS,
- * malloc_usable_size on systems with glibc) */
- void *a_ptr = opj_aligned_alloc_n(alignment, new_size);
- if (a_ptr != NULL) {
- memcpy(a_ptr, r_ptr, new_size);
- }
- free(r_ptr);
- r_ptr = a_ptr;
- }
- /* _MSC_VER */
-#elif defined(OPJ_HAVE__ALIGNED_MALLOC)
- r_ptr = _aligned_realloc(ptr, new_size, alignment);
-#else
- if (ptr == NULL) {
- return opj_aligned_alloc_n(alignment, new_size);
- }
- alignment--;
- {
- void *oldmem;
- OPJ_UINT8 *newmem;
- size_t overhead = alignment + sizeof(void *);
-
- /* let's be extra careful */
- assert(alignment <= (SIZE_MAX - sizeof(void *)));
-
- /* Avoid integer overflow */
- if (new_size > SIZE_MAX - overhead) {
- return NULL;
- }
-
- oldmem = ((void**) ptr)[-1];
- newmem = (OPJ_UINT8*)realloc(oldmem, new_size + overhead);
- if (newmem == NULL) {
- return newmem;
- }
-
- if (newmem == oldmem) {
- r_ptr = ptr;
- } else {
- size_t old_offset;
- size_t new_offset;
-
- /* realloc created a new copy, realign the copied memory block */
- old_offset = (size_t)((OPJ_UINT8*)ptr - (OPJ_UINT8*)oldmem);
-
- /* offset = ((alignment + 1U) - ((size_t)(mem + sizeof(void*)) & alignment)) & alignment; */
- /* Use the fact that alignment + 1U is a power of 2 */
- new_offset = ((alignment ^ ((size_t)(newmem + sizeof(void*)) & alignment)) +
- 1U) & alignment;
- new_offset += sizeof(void*);
- r_ptr = (void *)(newmem + new_offset);
-
- if (new_offset != old_offset) {
- memmove(newmem + new_offset, newmem + old_offset, new_size);
- }
- ((void**) r_ptr)[-1] = newmem;
- }
- }
-#endif
- return r_ptr;
-}
-void * opj_malloc(size_t size)
-{
- if (size == 0U) { /* prevent implementation defined behavior of realloc */
- return NULL;
- }
- return malloc(size);
-}
-void * opj_calloc(size_t num, size_t size)
-{
- if (num == 0 || size == 0) {
- /* prevent implementation defined behavior of realloc */
- return NULL;
- }
- return calloc(num, size);
-}
-
-void *opj_aligned_malloc(size_t size)
-{
- return opj_aligned_alloc_n(16U, size);
-}
-void * opj_aligned_realloc(void *ptr, size_t size)
-{
- return opj_aligned_realloc_n(ptr, 16U, size);
-}
-
-void *opj_aligned_32_malloc(size_t size)
-{
- return opj_aligned_alloc_n(32U, size);
-}
-void * opj_aligned_32_realloc(void *ptr, size_t size)
-{
- return opj_aligned_realloc_n(ptr, 32U, size);
-}
-
-void opj_aligned_free(void* ptr)
-{
-#if defined(OPJ_HAVE_POSIX_MEMALIGN) || defined(OPJ_HAVE_MEMALIGN)
- free(ptr);
-#elif defined(OPJ_HAVE__ALIGNED_MALLOC)
- _aligned_free(ptr);
-#else
- /* Generic implementation has malloced pointer stored in front of used area */
- if (ptr != NULL) {
- free(((void**) ptr)[-1]);
- }
-#endif
-}
-
-void * opj_realloc(void *ptr, size_t new_size)
-{
- if (new_size == 0U) { /* prevent implementation defined behavior of realloc */
- return NULL;
- }
- return realloc(ptr, new_size);
-}
-void opj_free(void *ptr)
-{
- free(ptr);
-}
diff --git a/contrib/libs/openjpeg/opj_malloc.h b/contrib/libs/openjpeg/opj_malloc.h
deleted file mode 100644
index cbc4106c7c..0000000000
--- a/contrib/libs/openjpeg/opj_malloc.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2007, Callum Lerwick <seg@haxxed.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef OPJ_MALLOC_H
-#define OPJ_MALLOC_H
-
-#include <stddef.h>
-/**
-@file opj_malloc.h
-@brief Internal functions
-
-The functions in opj_malloc.h are internal utilities used for memory management.
-*/
-
-/** @defgroup MISC MISC - Miscellaneous internal functions */
-/*@{*/
-
-/** @name Exported functions */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-
-/**
-Allocate an uninitialized memory block
-@param size Bytes to allocate
-@return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
-*/
-void * opj_malloc(size_t size);
-
-/**
-Allocate a memory block with elements initialized to 0
-@param numOfElements Blocks to allocate
-@param sizeOfElements Bytes per block to allocate
-@return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
-*/
-void * opj_calloc(size_t numOfElements, size_t sizeOfElements);
-
-/**
-Allocate memory aligned to a 16 byte boundary
-@param size Bytes to allocate
-@return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
-*/
-void * opj_aligned_malloc(size_t size);
-void * opj_aligned_realloc(void *ptr, size_t size);
-void opj_aligned_free(void* ptr);
-
-/**
-Allocate memory aligned to a 32 byte boundary
-@param size Bytes to allocate
-@return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
-*/
-void * opj_aligned_32_malloc(size_t size);
-void * opj_aligned_32_realloc(void *ptr, size_t size);
-
-/**
-Reallocate memory blocks.
-@param m Pointer to previously allocated memory block
-@param s New size in bytes
-@return Returns a void pointer to the reallocated (and possibly moved) memory block
-*/
-void * opj_realloc(void * m, size_t s);
-
-/**
-Deallocates or frees a memory block.
-@param m Previously allocated memory block to be freed
-*/
-void opj_free(void * m);
-
-#if defined(__GNUC__) && !defined(OPJ_SKIP_POISON)
-#pragma GCC poison malloc calloc realloc free
-#endif
-
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* OPJ_MALLOC_H */
-
diff --git a/contrib/libs/openjpeg/pi.c b/contrib/libs/openjpeg/pi.c
deleted file mode 100644
index 15ac331425..0000000000
--- a/contrib/libs/openjpeg/pi.c
+++ /dev/null
@@ -1,2149 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2014, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux
- * Copyright (c) 2003-2014, Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2006-2007, Parvatha Elangovan
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#define OPJ_UINT32_SEMANTICALLY_BUT_INT32 OPJ_UINT32
-
-#include "opj_includes.h"
-
-/** @defgroup PI PI - Implementation of a packet iterator */
-/*@{*/
-
-/** @name Local static functions */
-/*@{*/
-
-/**
-Get next packet in layer-resolution-component-precinct order.
-@param pi packet iterator to modify
-@return returns false if pi pointed to the last packet or else returns true
-*/
-static OPJ_BOOL opj_pi_next_lrcp(opj_pi_iterator_t * pi);
-/**
-Get next packet in resolution-layer-component-precinct order.
-@param pi packet iterator to modify
-@return returns false if pi pointed to the last packet or else returns true
-*/
-static OPJ_BOOL opj_pi_next_rlcp(opj_pi_iterator_t * pi);
-/**
-Get next packet in resolution-precinct-component-layer order.
-@param pi packet iterator to modify
-@return returns false if pi pointed to the last packet or else returns true
-*/
-static OPJ_BOOL opj_pi_next_rpcl(opj_pi_iterator_t * pi);
-/**
-Get next packet in precinct-component-resolution-layer order.
-@param pi packet iterator to modify
-@return returns false if pi pointed to the last packet or else returns true
-*/
-static OPJ_BOOL opj_pi_next_pcrl(opj_pi_iterator_t * pi);
-/**
-Get next packet in component-precinct-resolution-layer order.
-@param pi packet iterator to modify
-@return returns false if pi pointed to the last packet or else returns true
-*/
-static OPJ_BOOL opj_pi_next_cprl(opj_pi_iterator_t * pi);
-
-/**
- * Updates the coding parameters if the encoding is used with Progression order changes and final (or cinema parameters are used).
- *
- * @param p_cp the coding parameters to modify
- * @param p_tileno the tile index being concerned.
- * @param p_tx0 X0 parameter for the tile
- * @param p_tx1 X1 parameter for the tile
- * @param p_ty0 Y0 parameter for the tile
- * @param p_ty1 Y1 parameter for the tile
- * @param p_max_prec the maximum precision for all the bands of the tile
- * @param p_max_res the maximum number of resolutions for all the poc inside the tile.
- * @param p_dx_min the minimum dx of all the components of all the resolutions for the tile.
- * @param p_dy_min the minimum dy of all the components of all the resolutions for the tile.
- */
-static void opj_pi_update_encode_poc_and_final(opj_cp_t *p_cp,
- OPJ_UINT32 p_tileno,
- OPJ_UINT32 p_tx0,
- OPJ_UINT32 p_tx1,
- OPJ_UINT32 p_ty0,
- OPJ_UINT32 p_ty1,
- OPJ_UINT32 p_max_prec,
- OPJ_UINT32 p_max_res,
- OPJ_UINT32 p_dx_min,
- OPJ_UINT32 p_dy_min);
-
-/**
- * Updates the coding parameters if the encoding is not used with Progression order changes and final (and cinema parameters are used).
- *
- * @param p_cp the coding parameters to modify
- * @param p_num_comps the number of components
- * @param p_tileno the tile index being concerned.
- * @param p_tx0 X0 parameter for the tile
- * @param p_tx1 X1 parameter for the tile
- * @param p_ty0 Y0 parameter for the tile
- * @param p_ty1 Y1 parameter for the tile
- * @param p_max_prec the maximum precision for all the bands of the tile
- * @param p_max_res the maximum number of resolutions for all the poc inside the tile.
- * @param p_dx_min the minimum dx of all the components of all the resolutions for the tile.
- * @param p_dy_min the minimum dy of all the components of all the resolutions for the tile.
- */
-static void opj_pi_update_encode_not_poc(opj_cp_t *p_cp,
- OPJ_UINT32 p_num_comps,
- OPJ_UINT32 p_tileno,
- OPJ_UINT32 p_tx0,
- OPJ_UINT32 p_tx1,
- OPJ_UINT32 p_ty0,
- OPJ_UINT32 p_ty1,
- OPJ_UINT32 p_max_prec,
- OPJ_UINT32 p_max_res,
- OPJ_UINT32 p_dx_min,
- OPJ_UINT32 p_dy_min);
-/**
- * Gets the encoding parameters needed to update the coding parameters and all the pocs.
- *
- * @param p_image the image being encoded.
- * @param p_cp the coding parameters.
- * @param tileno the tile index of the tile being encoded.
- * @param p_tx0 pointer that will hold the X0 parameter for the tile
- * @param p_tx1 pointer that will hold the X1 parameter for the tile
- * @param p_ty0 pointer that will hold the Y0 parameter for the tile
- * @param p_ty1 pointer that will hold the Y1 parameter for the tile
- * @param p_max_prec pointer that will hold the maximum precision for all the bands of the tile
- * @param p_max_res pointer that will hold the maximum number of resolutions for all the poc inside the tile.
- * @param p_dx_min pointer that will hold the minimum dx of all the components of all the resolutions for the tile.
- * @param p_dy_min pointer that will hold the minimum dy of all the components of all the resolutions for the tile.
- */
-static void opj_get_encoding_parameters(const opj_image_t *p_image,
- const opj_cp_t *p_cp,
- OPJ_UINT32 tileno,
- OPJ_UINT32 * p_tx0,
- OPJ_UINT32 * p_tx1,
- OPJ_UINT32 * p_ty0,
- OPJ_UINT32 * p_ty1,
- OPJ_UINT32 * p_dx_min,
- OPJ_UINT32 * p_dy_min,
- OPJ_UINT32 * p_max_prec,
- OPJ_UINT32 * p_max_res);
-
-/**
- * Gets the encoding parameters needed to update the coding parameters and all the pocs.
- * The precinct widths, heights, dx and dy for each component at each resolution will be stored as well.
- * the last parameter of the function should be an array of pointers of size nb components, each pointer leading
- * to an area of size 4 * max_res. The data is stored inside this area with the following pattern :
- * dx_compi_res0 , dy_compi_res0 , w_compi_res0, h_compi_res0 , dx_compi_res1 , dy_compi_res1 , w_compi_res1, h_compi_res1 , ...
- *
- * @param p_image the image being encoded.
- * @param p_cp the coding parameters.
- * @param tileno the tile index of the tile being encoded.
- * @param p_tx0 pointer that will hold the X0 parameter for the tile
- * @param p_tx1 pointer that will hold the X1 parameter for the tile
- * @param p_ty0 pointer that will hold the Y0 parameter for the tile
- * @param p_ty1 pointer that will hold the Y1 parameter for the tile
- * @param p_max_prec pointer that will hold the maximum precision for all the bands of the tile
- * @param p_max_res pointer that will hold the maximum number of resolutions for all the poc inside the tile.
- * @param p_dx_min pointer that will hold the minimum dx of all the components of all the resolutions for the tile.
- * @param p_dy_min pointer that will hold the minimum dy of all the components of all the resolutions for the tile.
- * @param p_resolutions pointer to an area corresponding to the one described above.
- */
-static void opj_get_all_encoding_parameters(const opj_image_t *p_image,
- const opj_cp_t *p_cp,
- OPJ_UINT32 tileno,
- OPJ_UINT32 * p_tx0,
- OPJ_UINT32 * p_tx1,
- OPJ_UINT32 * p_ty0,
- OPJ_UINT32 * p_ty1,
- OPJ_UINT32 * p_dx_min,
- OPJ_UINT32 * p_dy_min,
- OPJ_UINT32 * p_max_prec,
- OPJ_UINT32 * p_max_res,
- OPJ_UINT32 ** p_resolutions);
-/**
- * Allocates memory for a packet iterator. Data and data sizes are set by this operation.
- * No other data is set. The include section of the packet iterator is not allocated.
- *
- * @param p_image the image used to initialize the packet iterator (in fact only the number of components is relevant.
- * @param p_cp the coding parameters.
- * @param tileno the index of the tile from which creating the packet iterator.
- * @param manager Event manager
- */
-static opj_pi_iterator_t * opj_pi_create(const opj_image_t *p_image,
- const opj_cp_t *p_cp,
- OPJ_UINT32 tileno,
- opj_event_mgr_t* manager);
-/**
- * FIXME DOC
- */
-static void opj_pi_update_decode_not_poc(opj_pi_iterator_t * p_pi,
- opj_tcp_t * p_tcp,
- OPJ_UINT32 p_max_precision,
- OPJ_UINT32 p_max_res);
-/**
- * FIXME DOC
- */
-static void opj_pi_update_decode_poc(opj_pi_iterator_t * p_pi,
- opj_tcp_t * p_tcp,
- OPJ_UINT32 p_max_precision,
- OPJ_UINT32 p_max_res);
-
-/**
- * FIXME DOC
- */
-static OPJ_BOOL opj_pi_check_next_level(OPJ_INT32 pos,
- opj_cp_t *cp,
- OPJ_UINT32 tileno,
- OPJ_UINT32 pino,
- const OPJ_CHAR *prog);
-
-/*@}*/
-
-/*@}*/
-
-/*
-==========================================================
- local functions
-==========================================================
-*/
-
-static OPJ_BOOL opj_pi_next_lrcp(opj_pi_iterator_t * pi)
-{
- opj_pi_comp_t *comp = NULL;
- opj_pi_resolution_t *res = NULL;
- OPJ_UINT32 index = 0;
-
- if (pi->poc.compno0 >= pi->numcomps ||
- pi->poc.compno1 >= pi->numcomps + 1) {
- opj_event_msg(pi->manager, EVT_ERROR,
- "opj_pi_next_lrcp(): invalid compno0/compno1\n");
- return OPJ_FALSE;
- }
-
- if (!pi->first) {
- comp = &pi->comps[pi->compno];
- res = &comp->resolutions[pi->resno];
- goto LABEL_SKIP;
- } else {
- pi->first = 0;
- }
-
- for (pi->layno = pi->poc.layno0; pi->layno < pi->poc.layno1; pi->layno++) {
- for (pi->resno = pi->poc.resno0; pi->resno < pi->poc.resno1;
- pi->resno++) {
- for (pi->compno = pi->poc.compno0; pi->compno < pi->poc.compno1; pi->compno++) {
- comp = &pi->comps[pi->compno];
- if (pi->resno >= comp->numresolutions) {
- continue;
- }
- res = &comp->resolutions[pi->resno];
- if (!pi->tp_on) {
- pi->poc.precno1 = res->pw * res->ph;
- }
- for (pi->precno = pi->poc.precno0; pi->precno < pi->poc.precno1; pi->precno++) {
- index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno *
- pi->step_c + pi->precno * pi->step_p;
- /* Avoids index out of bounds access with */
- /* id_000098,sig_11,src_005411,op_havoc,rep_2 of */
- /* https://github.com/uclouvain/openjpeg/issues/938 */
- /* Not sure if this is the most clever fix. Perhaps */
- /* include should be resized when a POC arises, or */
- /* the POC should be rejected */
- if (index >= pi->include_size) {
- opj_event_msg(pi->manager, EVT_ERROR, "Invalid access to pi->include");
- return OPJ_FALSE;
- }
- if (!pi->include[index]) {
- pi->include[index] = 1;
- return OPJ_TRUE;
- }
-LABEL_SKIP:
- ;
- }
- }
- }
- }
-
- return OPJ_FALSE;
-}
-
-static OPJ_BOOL opj_pi_next_rlcp(opj_pi_iterator_t * pi)
-{
- opj_pi_comp_t *comp = NULL;
- opj_pi_resolution_t *res = NULL;
- OPJ_UINT32 index = 0;
-
- if (pi->poc.compno0 >= pi->numcomps ||
- pi->poc.compno1 >= pi->numcomps + 1) {
- opj_event_msg(pi->manager, EVT_ERROR,
- "opj_pi_next_rlcp(): invalid compno0/compno1\n");
- return OPJ_FALSE;
- }
-
- if (!pi->first) {
- comp = &pi->comps[pi->compno];
- res = &comp->resolutions[pi->resno];
- goto LABEL_SKIP;
- } else {
- pi->first = 0;
- }
-
- for (pi->resno = pi->poc.resno0; pi->resno < pi->poc.resno1; pi->resno++) {
- for (pi->layno = pi->poc.layno0; pi->layno < pi->poc.layno1; pi->layno++) {
- for (pi->compno = pi->poc.compno0; pi->compno < pi->poc.compno1; pi->compno++) {
- comp = &pi->comps[pi->compno];
- if (pi->resno >= comp->numresolutions) {
- continue;
- }
- res = &comp->resolutions[pi->resno];
- if (!pi->tp_on) {
- pi->poc.precno1 = res->pw * res->ph;
- }
- for (pi->precno = pi->poc.precno0; pi->precno < pi->poc.precno1; pi->precno++) {
- index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno *
- pi->step_c + pi->precno * pi->step_p;
- if (index >= pi->include_size) {
- opj_event_msg(pi->manager, EVT_ERROR, "Invalid access to pi->include");
- return OPJ_FALSE;
- }
- if (!pi->include[index]) {
- pi->include[index] = 1;
- return OPJ_TRUE;
- }
-LABEL_SKIP:
- ;
- }
- }
- }
- }
-
- return OPJ_FALSE;
-}
-
-static OPJ_BOOL opj_pi_next_rpcl(opj_pi_iterator_t * pi)
-{
- opj_pi_comp_t *comp = NULL;
- opj_pi_resolution_t *res = NULL;
- OPJ_UINT32 index = 0;
-
- if (pi->poc.compno0 >= pi->numcomps ||
- pi->poc.compno1 >= pi->numcomps + 1) {
- opj_event_msg(pi->manager, EVT_ERROR,
- "opj_pi_next_rpcl(): invalid compno0/compno1\n");
- return OPJ_FALSE;
- }
-
- if (!pi->first) {
- goto LABEL_SKIP;
- } else {
- OPJ_UINT32 compno, resno;
- pi->first = 0;
- pi->dx = 0;
- pi->dy = 0;
- for (compno = 0; compno < pi->numcomps; compno++) {
- comp = &pi->comps[compno];
- for (resno = 0; resno < comp->numresolutions; resno++) {
- OPJ_UINT32 dx, dy;
- res = &comp->resolutions[resno];
- if (res->pdx + comp->numresolutions - 1 - resno < 32 &&
- comp->dx <= UINT_MAX / (1u << (res->pdx + comp->numresolutions - 1 - resno))) {
- dx = comp->dx * (1u << (res->pdx + comp->numresolutions - 1 - resno));
- pi->dx = !pi->dx ? dx : opj_uint_min(pi->dx, dx);
- }
- if (res->pdy + comp->numresolutions - 1 - resno < 32 &&
- comp->dy <= UINT_MAX / (1u << (res->pdy + comp->numresolutions - 1 - resno))) {
- dy = comp->dy * (1u << (res->pdy + comp->numresolutions - 1 - resno));
- pi->dy = !pi->dy ? dy : opj_uint_min(pi->dy, dy);
- }
- }
- }
- if (pi->dx == 0 || pi->dy == 0) {
- return OPJ_FALSE;
- }
- }
- if (!pi->tp_on) {
- pi->poc.ty0 = pi->ty0;
- pi->poc.tx0 = pi->tx0;
- pi->poc.ty1 = pi->ty1;
- pi->poc.tx1 = pi->tx1;
- }
- for (pi->resno = pi->poc.resno0; pi->resno < pi->poc.resno1; pi->resno++) {
- for (pi->y = (OPJ_UINT32)pi->poc.ty0; pi->y < (OPJ_UINT32)pi->poc.ty1;
- pi->y += (pi->dy - (pi->y % pi->dy))) {
- for (pi->x = (OPJ_UINT32)pi->poc.tx0; pi->x < (OPJ_UINT32)pi->poc.tx1;
- pi->x += (pi->dx - (pi->x % pi->dx))) {
- for (pi->compno = pi->poc.compno0; pi->compno < pi->poc.compno1; pi->compno++) {
- OPJ_UINT32 levelno;
- OPJ_UINT32 trx0, try0;
- OPJ_UINT32 trx1, try1;
- OPJ_UINT32 rpx, rpy;
- OPJ_UINT32 prci, prcj;
- comp = &pi->comps[pi->compno];
- if (pi->resno >= comp->numresolutions) {
- continue;
- }
- res = &comp->resolutions[pi->resno];
- levelno = comp->numresolutions - 1 - pi->resno;
-
- if ((OPJ_UINT32)(((OPJ_UINT64)comp->dx << levelno) >> levelno) != comp->dx ||
- (OPJ_UINT32)(((OPJ_UINT64)comp->dy << levelno) >> levelno) != comp->dy) {
- continue;
- }
-
- trx0 = opj_uint64_ceildiv_res_uint32((OPJ_UINT64)pi->tx0,
- ((OPJ_UINT64)comp->dx << levelno));
- try0 = opj_uint64_ceildiv_res_uint32((OPJ_UINT64)pi->ty0,
- ((OPJ_UINT64)comp->dy << levelno));
- trx1 = opj_uint64_ceildiv_res_uint32((OPJ_UINT64)pi->tx1,
- ((OPJ_UINT64)comp->dx << levelno));
- try1 = opj_uint64_ceildiv_res_uint32((OPJ_UINT64)pi->ty1,
- ((OPJ_UINT64)comp->dy << levelno));
- rpx = res->pdx + levelno;
- rpy = res->pdy + levelno;
-
- if ((OPJ_UINT32)(((OPJ_UINT64)comp->dx << rpx) >> rpx) != comp->dx ||
- (OPJ_UINT32)(((OPJ_UINT64)comp->dy << rpy) >> rpy) != comp->dy) {
- continue;
- }
-
- /* See ISO-15441. B.12.1.3 Resolution level-position-component-layer progression */
- if (!(((OPJ_UINT64)pi->y % ((OPJ_UINT64)comp->dy << rpy) == 0) ||
- ((pi->y == pi->ty0) &&
- (((OPJ_UINT64)try0 << levelno) % ((OPJ_UINT64)1U << rpy))))) {
- continue;
- }
- if (!(((OPJ_UINT64)pi->x % ((OPJ_UINT64)comp->dx << rpx) == 0) ||
- ((pi->x == pi->tx0) &&
- (((OPJ_UINT64)trx0 << levelno) % ((OPJ_UINT64)1U << rpx))))) {
- continue;
- }
-
- if ((res->pw == 0) || (res->ph == 0)) {
- continue;
- }
-
- if ((trx0 == trx1) || (try0 == try1)) {
- continue;
- }
-
- prci = opj_uint_floordivpow2(opj_uint64_ceildiv_res_uint32((OPJ_UINT64)pi->x,
- ((OPJ_UINT64)comp->dx << levelno)), res->pdx)
- - opj_uint_floordivpow2(trx0, res->pdx);
- prcj = opj_uint_floordivpow2(opj_uint64_ceildiv_res_uint32((OPJ_UINT64)pi->y,
- ((OPJ_UINT64)comp->dy << levelno)), res->pdy)
- - opj_uint_floordivpow2(try0, res->pdy);
- pi->precno = prci + prcj * res->pw;
- for (pi->layno = pi->poc.layno0; pi->layno < pi->poc.layno1; pi->layno++) {
- index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno *
- pi->step_c + pi->precno * pi->step_p;
- if (index >= pi->include_size) {
- opj_event_msg(pi->manager, EVT_ERROR, "Invalid access to pi->include");
- return OPJ_FALSE;
- }
- if (!pi->include[index]) {
- pi->include[index] = 1;
- return OPJ_TRUE;
- }
-LABEL_SKIP:
- ;
- }
- }
- }
- }
- }
-
- return OPJ_FALSE;
-}
-
-static OPJ_BOOL opj_pi_next_pcrl(opj_pi_iterator_t * pi)
-{
- opj_pi_comp_t *comp = NULL;
- opj_pi_resolution_t *res = NULL;
- OPJ_UINT32 index = 0;
-
- if (pi->poc.compno0 >= pi->numcomps ||
- pi->poc.compno1 >= pi->numcomps + 1) {
- opj_event_msg(pi->manager, EVT_ERROR,
- "opj_pi_next_pcrl(): invalid compno0/compno1\n");
- return OPJ_FALSE;
- }
-
- if (!pi->first) {
- comp = &pi->comps[pi->compno];
- goto LABEL_SKIP;
- } else {
- OPJ_UINT32 compno, resno;
- pi->first = 0;
- pi->dx = 0;
- pi->dy = 0;
- for (compno = 0; compno < pi->numcomps; compno++) {
- comp = &pi->comps[compno];
- for (resno = 0; resno < comp->numresolutions; resno++) {
- OPJ_UINT32 dx, dy;
- res = &comp->resolutions[resno];
- if (res->pdx + comp->numresolutions - 1 - resno < 32 &&
- comp->dx <= UINT_MAX / (1u << (res->pdx + comp->numresolutions - 1 - resno))) {
- dx = comp->dx * (1u << (res->pdx + comp->numresolutions - 1 - resno));
- pi->dx = !pi->dx ? dx : opj_uint_min(pi->dx, dx);
- }
- if (res->pdy + comp->numresolutions - 1 - resno < 32 &&
- comp->dy <= UINT_MAX / (1u << (res->pdy + comp->numresolutions - 1 - resno))) {
- dy = comp->dy * (1u << (res->pdy + comp->numresolutions - 1 - resno));
- pi->dy = !pi->dy ? dy : opj_uint_min(pi->dy, dy);
- }
- }
- }
- if (pi->dx == 0 || pi->dy == 0) {
- return OPJ_FALSE;
- }
- }
- if (!pi->tp_on) {
- pi->poc.ty0 = pi->ty0;
- pi->poc.tx0 = pi->tx0;
- pi->poc.ty1 = pi->ty1;
- pi->poc.tx1 = pi->tx1;
- }
- for (pi->y = (OPJ_UINT32)pi->poc.ty0; pi->y < (OPJ_UINT32)pi->poc.ty1;
- pi->y += (pi->dy - (pi->y % pi->dy))) {
- for (pi->x = (OPJ_UINT32)pi->poc.tx0; pi->x < (OPJ_UINT32)pi->poc.tx1;
- pi->x += (pi->dx - (pi->x % pi->dx))) {
- for (pi->compno = pi->poc.compno0; pi->compno < pi->poc.compno1; pi->compno++) {
- comp = &pi->comps[pi->compno];
- for (pi->resno = pi->poc.resno0;
- pi->resno < opj_uint_min(pi->poc.resno1, comp->numresolutions); pi->resno++) {
- OPJ_UINT32 levelno;
- OPJ_UINT32 trx0, try0;
- OPJ_UINT32 trx1, try1;
- OPJ_UINT32 rpx, rpy;
- OPJ_UINT32 prci, prcj;
- res = &comp->resolutions[pi->resno];
- levelno = comp->numresolutions - 1 - pi->resno;
-
- if ((OPJ_UINT32)(((OPJ_UINT64)comp->dx << levelno) >> levelno) != comp->dx ||
- (OPJ_UINT32)(((OPJ_UINT64)comp->dy << levelno) >> levelno) != comp->dy) {
- continue;
- }
-
- trx0 = opj_uint64_ceildiv_res_uint32((OPJ_UINT64)pi->tx0,
- ((OPJ_UINT64)comp->dx << levelno));
- try0 = opj_uint64_ceildiv_res_uint32((OPJ_UINT64)pi->ty0,
- ((OPJ_UINT64)comp->dy << levelno));
- trx1 = opj_uint64_ceildiv_res_uint32((OPJ_UINT64)pi->tx1,
- ((OPJ_UINT64)comp->dx << levelno));
- try1 = opj_uint64_ceildiv_res_uint32((OPJ_UINT64)pi->ty1,
- ((OPJ_UINT64)comp->dy << levelno));
- rpx = res->pdx + levelno;
- rpy = res->pdy + levelno;
-
- if ((OPJ_UINT32)(((OPJ_UINT64)comp->dx << rpx) >> rpx) != comp->dx ||
- (OPJ_UINT32)(((OPJ_UINT64)comp->dy << rpy) >> rpy) != comp->dy) {
- continue;
- }
-
- /* See ISO-15441. B.12.1.4 Position-component-resolution level-layer progression */
- if (!(((OPJ_UINT64)pi->y % ((OPJ_UINT64)comp->dy << rpy) == 0) ||
- ((pi->y == pi->ty0) &&
- (((OPJ_UINT64)try0 << levelno) % ((OPJ_UINT64)1U << rpy))))) {
- continue;
- }
- if (!(((OPJ_UINT64)pi->x % ((OPJ_UINT64)comp->dx << rpx) == 0) ||
- ((pi->x == pi->tx0) &&
- (((OPJ_UINT64)trx0 << levelno) % ((OPJ_UINT64)1U << rpx))))) {
- continue;
- }
-
- if ((res->pw == 0) || (res->ph == 0)) {
- continue;
- }
-
- if ((trx0 == trx1) || (try0 == try1)) {
- continue;
- }
-
- prci = opj_uint_floordivpow2(opj_uint64_ceildiv_res_uint32((OPJ_UINT64)pi->x,
- ((OPJ_UINT64)comp->dx << levelno)), res->pdx)
- - opj_uint_floordivpow2(trx0, res->pdx);
- prcj = opj_uint_floordivpow2(opj_uint64_ceildiv_res_uint32((OPJ_UINT64)pi->y,
- ((OPJ_UINT64)comp->dy << levelno)), res->pdy)
- - opj_uint_floordivpow2(try0, res->pdy);
- pi->precno = prci + prcj * res->pw;
- for (pi->layno = pi->poc.layno0; pi->layno < pi->poc.layno1; pi->layno++) {
- index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno *
- pi->step_c + pi->precno * pi->step_p;
- if (index >= pi->include_size) {
- opj_event_msg(pi->manager, EVT_ERROR, "Invalid access to pi->include");
- return OPJ_FALSE;
- }
- if (!pi->include[index]) {
- pi->include[index] = 1;
- return OPJ_TRUE;
- }
-LABEL_SKIP:
- ;
- }
- }
- }
- }
- }
-
- return OPJ_FALSE;
-}
-
-static OPJ_BOOL opj_pi_next_cprl(opj_pi_iterator_t * pi)
-{
- opj_pi_comp_t *comp = NULL;
- opj_pi_resolution_t *res = NULL;
- OPJ_UINT32 index = 0;
-
- if (pi->poc.compno0 >= pi->numcomps ||
- pi->poc.compno1 >= pi->numcomps + 1) {
- opj_event_msg(pi->manager, EVT_ERROR,
- "opj_pi_next_cprl(): invalid compno0/compno1\n");
- return OPJ_FALSE;
- }
-
- if (!pi->first) {
- comp = &pi->comps[pi->compno];
- goto LABEL_SKIP;
- } else {
- pi->first = 0;
- }
-
- for (pi->compno = pi->poc.compno0; pi->compno < pi->poc.compno1; pi->compno++) {
- OPJ_UINT32 resno;
- comp = &pi->comps[pi->compno];
- pi->dx = 0;
- pi->dy = 0;
- for (resno = 0; resno < comp->numresolutions; resno++) {
- OPJ_UINT32 dx, dy;
- res = &comp->resolutions[resno];
- if (res->pdx + comp->numresolutions - 1 - resno < 32 &&
- comp->dx <= UINT_MAX / (1u << (res->pdx + comp->numresolutions - 1 - resno))) {
- dx = comp->dx * (1u << (res->pdx + comp->numresolutions - 1 - resno));
- pi->dx = !pi->dx ? dx : opj_uint_min(pi->dx, dx);
- }
- if (res->pdy + comp->numresolutions - 1 - resno < 32 &&
- comp->dy <= UINT_MAX / (1u << (res->pdy + comp->numresolutions - 1 - resno))) {
- dy = comp->dy * (1u << (res->pdy + comp->numresolutions - 1 - resno));
- pi->dy = !pi->dy ? dy : opj_uint_min(pi->dy, dy);
- }
- }
- if (pi->dx == 0 || pi->dy == 0) {
- return OPJ_FALSE;
- }
- if (!pi->tp_on) {
- pi->poc.ty0 = pi->ty0;
- pi->poc.tx0 = pi->tx0;
- pi->poc.ty1 = pi->ty1;
- pi->poc.tx1 = pi->tx1;
- }
- for (pi->y = (OPJ_UINT32)pi->poc.ty0; pi->y < (OPJ_UINT32)pi->poc.ty1;
- pi->y += (pi->dy - (pi->y % pi->dy))) {
- for (pi->x = (OPJ_UINT32)pi->poc.tx0; pi->x < (OPJ_UINT32)pi->poc.tx1;
- pi->x += (pi->dx - (pi->x % pi->dx))) {
- for (pi->resno = pi->poc.resno0;
- pi->resno < opj_uint_min(pi->poc.resno1, comp->numresolutions); pi->resno++) {
- OPJ_UINT32 levelno;
- OPJ_UINT32 trx0, try0;
- OPJ_UINT32 trx1, try1;
- OPJ_UINT32 rpx, rpy;
- OPJ_UINT32 prci, prcj;
- res = &comp->resolutions[pi->resno];
- levelno = comp->numresolutions - 1 - pi->resno;
-
- if ((OPJ_UINT32)(((OPJ_UINT64)comp->dx << levelno) >> levelno) != comp->dx ||
- (OPJ_UINT32)(((OPJ_UINT64)comp->dy << levelno) >> levelno) != comp->dy) {
- continue;
- }
-
- trx0 = opj_uint64_ceildiv_res_uint32((OPJ_UINT64)pi->tx0,
- ((OPJ_UINT64)comp->dx << levelno));
- try0 = opj_uint64_ceildiv_res_uint32((OPJ_UINT64)pi->ty0,
- ((OPJ_UINT64)comp->dy << levelno));
- trx1 = opj_uint64_ceildiv_res_uint32((OPJ_UINT64)pi->tx1,
- ((OPJ_UINT64)comp->dx << levelno));
- try1 = opj_uint64_ceildiv_res_uint32((OPJ_UINT64)pi->ty1,
- ((OPJ_UINT64)comp->dy << levelno));
- rpx = res->pdx + levelno;
- rpy = res->pdy + levelno;
-
- if ((OPJ_UINT32)(((OPJ_UINT64)comp->dx << rpx) >> rpx) != comp->dx ||
- (OPJ_UINT32)(((OPJ_UINT64)comp->dy << rpy) >> rpy) != comp->dy) {
- continue;
- }
-
- /* See ISO-15441. B.12.1.5 Component-position-resolution level-layer progression */
- if (!(((OPJ_UINT64)pi->y % ((OPJ_UINT64)comp->dy << rpy) == 0) ||
- ((pi->y == pi->ty0) &&
- (((OPJ_UINT64)try0 << levelno) % ((OPJ_UINT64)1U << rpy))))) {
- continue;
- }
- if (!(((OPJ_UINT64)pi->x % ((OPJ_UINT64)comp->dx << rpx) == 0) ||
- ((pi->x == pi->tx0) &&
- (((OPJ_UINT64)trx0 << levelno) % ((OPJ_UINT64)1U << rpx))))) {
- continue;
- }
-
- if ((res->pw == 0) || (res->ph == 0)) {
- continue;
- }
-
- if ((trx0 == trx1) || (try0 == try1)) {
- continue;
- }
-
- prci = opj_uint_floordivpow2(opj_uint64_ceildiv_res_uint32((OPJ_UINT64)pi->x,
- ((OPJ_UINT64)comp->dx << levelno)), res->pdx)
- - opj_uint_floordivpow2(trx0, res->pdx);
- prcj = opj_uint_floordivpow2(opj_uint64_ceildiv_res_uint32((OPJ_UINT64)pi->y,
- ((OPJ_UINT64)comp->dy << levelno)), res->pdy)
- - opj_uint_floordivpow2(try0, res->pdy);
- pi->precno = (OPJ_UINT32)(prci + prcj * res->pw);
- for (pi->layno = pi->poc.layno0; pi->layno < pi->poc.layno1; pi->layno++) {
- index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno *
- pi->step_c + pi->precno * pi->step_p;
- if (index >= pi->include_size) {
- opj_event_msg(pi->manager, EVT_ERROR, "Invalid access to pi->include");
- return OPJ_FALSE;
- }
- if (!pi->include[index]) {
- pi->include[index] = 1;
- return OPJ_TRUE;
- }
-LABEL_SKIP:
- ;
- }
- }
- }
- }
- }
-
- return OPJ_FALSE;
-}
-
-static void opj_get_encoding_parameters(const opj_image_t *p_image,
- const opj_cp_t *p_cp,
- OPJ_UINT32 p_tileno,
- OPJ_UINT32 * p_tx0,
- OPJ_UINT32 * p_tx1,
- OPJ_UINT32 * p_ty0,
- OPJ_UINT32 * p_ty1,
- OPJ_UINT32 * p_dx_min,
- OPJ_UINT32 * p_dy_min,
- OPJ_UINT32 * p_max_prec,
- OPJ_UINT32 * p_max_res)
-{
- /* loop */
- OPJ_UINT32 compno, resno;
- /* pointers */
- const opj_tcp_t *l_tcp = 00;
- const opj_tccp_t * l_tccp = 00;
- const opj_image_comp_t * l_img_comp = 00;
-
- /* position in x and y of tile */
- OPJ_UINT32 p, q;
-
- /* non-corrected (in regard to image offset) tile offset */
- OPJ_UINT32 l_tx0, l_ty0;
-
- /* preconditions */
- assert(p_cp != 00);
- assert(p_image != 00);
- assert(p_tileno < p_cp->tw * p_cp->th);
-
- /* initializations */
- l_tcp = &p_cp->tcps [p_tileno];
- l_img_comp = p_image->comps;
- l_tccp = l_tcp->tccps;
-
- /* here calculation of tx0, tx1, ty0, ty1, maxprec, dx and dy */
- p = p_tileno % p_cp->tw;
- q = p_tileno / p_cp->tw;
-
- /* find extent of tile */
- l_tx0 = p_cp->tx0 + p *
- p_cp->tdx; /* can't be greater than p_image->x1 so won't overflow */
- *p_tx0 = opj_uint_max(l_tx0, p_image->x0);
- *p_tx1 = opj_uint_min(opj_uint_adds(l_tx0, p_cp->tdx), p_image->x1);
- l_ty0 = p_cp->ty0 + q *
- p_cp->tdy; /* can't be greater than p_image->y1 so won't overflow */
- *p_ty0 = opj_uint_max(l_ty0, p_image->y0);
- *p_ty1 = opj_uint_min(opj_uint_adds(l_ty0, p_cp->tdy), p_image->y1);
-
- /* max precision is 0 (can only grow) */
- *p_max_prec = 0;
- *p_max_res = 0;
-
- /* take the largest value for dx_min and dy_min */
- *p_dx_min = 0x7fffffff;
- *p_dy_min = 0x7fffffff;
-
- for (compno = 0; compno < p_image->numcomps; ++compno) {
- /* arithmetic variables to calculate */
- OPJ_UINT32 l_level_no;
- OPJ_UINT32 l_rx0, l_ry0, l_rx1, l_ry1;
- OPJ_UINT32 l_px0, l_py0, l_px1, py1;
- OPJ_UINT32 l_pdx, l_pdy;
- OPJ_UINT32 l_pw, l_ph;
- OPJ_UINT32 l_product;
- OPJ_UINT32 l_tcx0, l_tcy0, l_tcx1, l_tcy1;
-
- l_tcx0 = opj_uint_ceildiv(*p_tx0, l_img_comp->dx);
- l_tcy0 = opj_uint_ceildiv(*p_ty0, l_img_comp->dy);
- l_tcx1 = opj_uint_ceildiv(*p_tx1, l_img_comp->dx);
- l_tcy1 = opj_uint_ceildiv(*p_ty1, l_img_comp->dy);
-
- if (l_tccp->numresolutions > *p_max_res) {
- *p_max_res = l_tccp->numresolutions;
- }
-
- /* use custom size for precincts */
- for (resno = 0; resno < l_tccp->numresolutions; ++resno) {
- OPJ_UINT64 l_dx, l_dy;
-
- /* precinct width and height */
- l_pdx = l_tccp->prcw[resno];
- l_pdy = l_tccp->prch[resno];
-
- l_dx = l_img_comp->dx * ((OPJ_UINT64)1u << (l_pdx + l_tccp->numresolutions - 1 -
- resno));
- l_dy = l_img_comp->dy * ((OPJ_UINT64)1u << (l_pdy + l_tccp->numresolutions - 1 -
- resno));
-
- /* take the minimum size for dx for each comp and resolution */
- if (l_dx <= UINT_MAX) {
- *p_dx_min = opj_uint_min(*p_dx_min, (OPJ_UINT32)l_dx);
- }
- if (l_dy <= UINT_MAX) {
- *p_dy_min = opj_uint_min(*p_dy_min, (OPJ_UINT32)l_dy);
- }
-
- /* various calculations of extents */
- l_level_no = l_tccp->numresolutions - 1 - resno;
-
- l_rx0 = opj_uint_ceildivpow2(l_tcx0, l_level_no);
- l_ry0 = opj_uint_ceildivpow2(l_tcy0, l_level_no);
- l_rx1 = opj_uint_ceildivpow2(l_tcx1, l_level_no);
- l_ry1 = opj_uint_ceildivpow2(l_tcy1, l_level_no);
-
- l_px0 = opj_uint_floordivpow2(l_rx0, l_pdx) << l_pdx;
- l_py0 = opj_uint_floordivpow2(l_ry0, l_pdy) << l_pdy;
- l_px1 = opj_uint_ceildivpow2(l_rx1, l_pdx) << l_pdx;
-
- py1 = opj_uint_ceildivpow2(l_ry1, l_pdy) << l_pdy;
-
- l_pw = (l_rx0 == l_rx1) ? 0 : ((l_px1 - l_px0) >> l_pdx);
- l_ph = (l_ry0 == l_ry1) ? 0 : ((py1 - l_py0) >> l_pdy);
-
- l_product = l_pw * l_ph;
-
- /* update precision */
- if (l_product > *p_max_prec) {
- *p_max_prec = l_product;
- }
- }
- ++l_img_comp;
- ++l_tccp;
- }
-}
-
-
-static void opj_get_all_encoding_parameters(const opj_image_t *p_image,
- const opj_cp_t *p_cp,
- OPJ_UINT32 tileno,
- OPJ_UINT32 * p_tx0,
- OPJ_UINT32 * p_tx1,
- OPJ_UINT32 * p_ty0,
- OPJ_UINT32 * p_ty1,
- OPJ_UINT32 * p_dx_min,
- OPJ_UINT32 * p_dy_min,
- OPJ_UINT32 * p_max_prec,
- OPJ_UINT32 * p_max_res,
- OPJ_UINT32 ** p_resolutions)
-{
- /* loop*/
- OPJ_UINT32 compno, resno;
-
- /* pointers*/
- const opj_tcp_t *tcp = 00;
- const opj_tccp_t * l_tccp = 00;
- const opj_image_comp_t * l_img_comp = 00;
-
- /* to store l_dx, l_dy, w and h for each resolution and component.*/
- OPJ_UINT32 * lResolutionPtr;
-
- /* position in x and y of tile*/
- OPJ_UINT32 p, q;
-
- /* non-corrected (in regard to image offset) tile offset */
- OPJ_UINT32 l_tx0, l_ty0;
-
- /* preconditions in debug*/
- assert(p_cp != 00);
- assert(p_image != 00);
- assert(tileno < p_cp->tw * p_cp->th);
-
- /* initializations*/
- tcp = &p_cp->tcps [tileno];
- l_tccp = tcp->tccps;
- l_img_comp = p_image->comps;
-
- /* position in x and y of tile*/
- p = tileno % p_cp->tw;
- q = tileno / p_cp->tw;
-
- /* here calculation of tx0, tx1, ty0, ty1, maxprec, l_dx and l_dy */
- l_tx0 = p_cp->tx0 + p *
- p_cp->tdx; /* can't be greater than p_image->x1 so won't overflow */
- *p_tx0 = opj_uint_max(l_tx0, p_image->x0);
- *p_tx1 = opj_uint_min(opj_uint_adds(l_tx0, p_cp->tdx), p_image->x1);
- l_ty0 = p_cp->ty0 + q *
- p_cp->tdy; /* can't be greater than p_image->y1 so won't overflow */
- *p_ty0 = opj_uint_max(l_ty0, p_image->y0);
- *p_ty1 = opj_uint_min(opj_uint_adds(l_ty0, p_cp->tdy), p_image->y1);
-
- /* max precision and resolution is 0 (can only grow)*/
- *p_max_prec = 0;
- *p_max_res = 0;
-
- /* take the largest value for dx_min and dy_min*/
- *p_dx_min = 0x7fffffff;
- *p_dy_min = 0x7fffffff;
-
- for (compno = 0; compno < p_image->numcomps; ++compno) {
- /* arithmetic variables to calculate*/
- OPJ_UINT32 l_level_no;
- OPJ_UINT32 l_rx0, l_ry0, l_rx1, l_ry1;
- OPJ_UINT32 l_px0, l_py0, l_px1, py1;
- OPJ_UINT32 l_product;
- OPJ_UINT32 l_tcx0, l_tcy0, l_tcx1, l_tcy1;
- OPJ_UINT32 l_pdx, l_pdy, l_pw, l_ph;
-
- lResolutionPtr = p_resolutions ? p_resolutions[compno] : NULL;
-
- l_tcx0 = opj_uint_ceildiv(*p_tx0, l_img_comp->dx);
- l_tcy0 = opj_uint_ceildiv(*p_ty0, l_img_comp->dy);
- l_tcx1 = opj_uint_ceildiv(*p_tx1, l_img_comp->dx);
- l_tcy1 = opj_uint_ceildiv(*p_ty1, l_img_comp->dy);
-
- if (l_tccp->numresolutions > *p_max_res) {
- *p_max_res = l_tccp->numresolutions;
- }
-
- /* use custom size for precincts*/
- l_level_no = l_tccp->numresolutions;
- for (resno = 0; resno < l_tccp->numresolutions; ++resno) {
- OPJ_UINT32 l_dx, l_dy;
-
- --l_level_no;
-
- /* precinct width and height*/
- l_pdx = l_tccp->prcw[resno];
- l_pdy = l_tccp->prch[resno];
- if (lResolutionPtr) {
- *lResolutionPtr++ = l_pdx;
- *lResolutionPtr++ = l_pdy;
- }
- if (l_pdx + l_level_no < 32 &&
- l_img_comp->dx <= UINT_MAX / (1u << (l_pdx + l_level_no))) {
- l_dx = l_img_comp->dx * (1u << (l_pdx + l_level_no));
- /* take the minimum size for l_dx for each comp and resolution*/
- *p_dx_min = opj_uint_min(*p_dx_min, l_dx);
- }
- if (l_pdy + l_level_no < 32 &&
- l_img_comp->dy <= UINT_MAX / (1u << (l_pdy + l_level_no))) {
- l_dy = l_img_comp->dy * (1u << (l_pdy + l_level_no));
- *p_dy_min = opj_uint_min(*p_dy_min, l_dy);
- }
-
- /* various calculations of extents*/
- l_rx0 = opj_uint_ceildivpow2(l_tcx0, l_level_no);
- l_ry0 = opj_uint_ceildivpow2(l_tcy0, l_level_no);
- l_rx1 = opj_uint_ceildivpow2(l_tcx1, l_level_no);
- l_ry1 = opj_uint_ceildivpow2(l_tcy1, l_level_no);
- l_px0 = opj_uint_floordivpow2(l_rx0, l_pdx) << l_pdx;
- l_py0 = opj_uint_floordivpow2(l_ry0, l_pdy) << l_pdy;
- l_px1 = opj_uint_ceildivpow2(l_rx1, l_pdx) << l_pdx;
- py1 = opj_uint_ceildivpow2(l_ry1, l_pdy) << l_pdy;
- l_pw = (l_rx0 == l_rx1) ? 0 : ((l_px1 - l_px0) >> l_pdx);
- l_ph = (l_ry0 == l_ry1) ? 0 : ((py1 - l_py0) >> l_pdy);
- if (lResolutionPtr) {
- *lResolutionPtr++ = l_pw;
- *lResolutionPtr++ = l_ph;
- }
- l_product = l_pw * l_ph;
-
- /* update precision*/
- if (l_product > *p_max_prec) {
- *p_max_prec = l_product;
- }
-
- }
- ++l_tccp;
- ++l_img_comp;
- }
-}
-
-static opj_pi_iterator_t * opj_pi_create(const opj_image_t *image,
- const opj_cp_t *cp,
- OPJ_UINT32 tileno,
- opj_event_mgr_t* manager)
-{
- /* loop*/
- OPJ_UINT32 pino, compno;
- /* number of poc in the p_pi*/
- OPJ_UINT32 l_poc_bound;
-
- /* pointers to tile coding parameters and components.*/
- opj_pi_iterator_t *l_pi = 00;
- opj_tcp_t *tcp = 00;
- const opj_tccp_t *tccp = 00;
-
- /* current packet iterator being allocated*/
- opj_pi_iterator_t *l_current_pi = 00;
-
- /* preconditions in debug*/
- assert(cp != 00);
- assert(image != 00);
- assert(tileno < cp->tw * cp->th);
-
- /* initializations*/
- tcp = &cp->tcps[tileno];
- l_poc_bound = tcp->numpocs + 1;
-
- /* memory allocations*/
- l_pi = (opj_pi_iterator_t*) opj_calloc((l_poc_bound),
- sizeof(opj_pi_iterator_t));
- if (!l_pi) {
- return NULL;
- }
-
- l_current_pi = l_pi;
- for (pino = 0; pino < l_poc_bound ; ++pino) {
-
- l_current_pi->manager = manager;
-
- l_current_pi->comps = (opj_pi_comp_t*) opj_calloc(image->numcomps,
- sizeof(opj_pi_comp_t));
- if (! l_current_pi->comps) {
- opj_pi_destroy(l_pi, l_poc_bound);
- return NULL;
- }
-
- l_current_pi->numcomps = image->numcomps;
-
- for (compno = 0; compno < image->numcomps; ++compno) {
- opj_pi_comp_t *comp = &l_current_pi->comps[compno];
-
- tccp = &tcp->tccps[compno];
-
- comp->resolutions = (opj_pi_resolution_t*) opj_calloc(tccp->numresolutions,
- sizeof(opj_pi_resolution_t));
- if (!comp->resolutions) {
- opj_pi_destroy(l_pi, l_poc_bound);
- return 00;
- }
-
- comp->numresolutions = tccp->numresolutions;
- }
- ++l_current_pi;
- }
- return l_pi;
-}
-
-static void opj_pi_update_encode_poc_and_final(opj_cp_t *p_cp,
- OPJ_UINT32 p_tileno,
- OPJ_UINT32 p_tx0,
- OPJ_UINT32 p_tx1,
- OPJ_UINT32 p_ty0,
- OPJ_UINT32 p_ty1,
- OPJ_UINT32 p_max_prec,
- OPJ_UINT32 p_max_res,
- OPJ_UINT32 p_dx_min,
- OPJ_UINT32 p_dy_min)
-{
- /* loop*/
- OPJ_UINT32 pino;
- /* tile coding parameter*/
- opj_tcp_t *l_tcp = 00;
- /* current poc being updated*/
- opj_poc_t * l_current_poc = 00;
-
- /* number of pocs*/
- OPJ_UINT32 l_poc_bound;
-
- OPJ_ARG_NOT_USED(p_max_res);
-
- /* preconditions in debug*/
- assert(p_cp != 00);
- assert(p_tileno < p_cp->tw * p_cp->th);
-
- /* initializations*/
- l_tcp = &p_cp->tcps [p_tileno];
- /* number of iterations in the loop */
- l_poc_bound = l_tcp->numpocs + 1;
-
- /* start at first element, and to make sure the compiler will not make a calculation each time in the loop
- store a pointer to the current element to modify rather than l_tcp->pocs[i]*/
- l_current_poc = l_tcp->pocs;
-
- l_current_poc->compS = l_current_poc->compno0;
- l_current_poc->compE = l_current_poc->compno1;
- l_current_poc->resS = l_current_poc->resno0;
- l_current_poc->resE = l_current_poc->resno1;
- l_current_poc->layE = l_current_poc->layno1;
-
- /* special treatment for the first element*/
- l_current_poc->layS = 0;
- l_current_poc->prg = l_current_poc->prg1;
- l_current_poc->prcS = 0;
-
- l_current_poc->prcE = p_max_prec;
- l_current_poc->txS = (OPJ_UINT32)p_tx0;
- l_current_poc->txE = (OPJ_UINT32)p_tx1;
- l_current_poc->tyS = (OPJ_UINT32)p_ty0;
- l_current_poc->tyE = (OPJ_UINT32)p_ty1;
- l_current_poc->dx = p_dx_min;
- l_current_poc->dy = p_dy_min;
-
- ++ l_current_poc;
- for (pino = 1; pino < l_poc_bound ; ++pino) {
- l_current_poc->compS = l_current_poc->compno0;
- l_current_poc->compE = l_current_poc->compno1;
- l_current_poc->resS = l_current_poc->resno0;
- l_current_poc->resE = l_current_poc->resno1;
- l_current_poc->layE = l_current_poc->layno1;
- l_current_poc->prg = l_current_poc->prg1;
- l_current_poc->prcS = 0;
- /* special treatment here different from the first element*/
- l_current_poc->layS = (l_current_poc->layE > (l_current_poc - 1)->layE) ?
- l_current_poc->layE : 0;
-
- l_current_poc->prcE = p_max_prec;
- l_current_poc->txS = (OPJ_UINT32)p_tx0;
- l_current_poc->txE = (OPJ_UINT32)p_tx1;
- l_current_poc->tyS = (OPJ_UINT32)p_ty0;
- l_current_poc->tyE = (OPJ_UINT32)p_ty1;
- l_current_poc->dx = p_dx_min;
- l_current_poc->dy = p_dy_min;
- ++ l_current_poc;
- }
-}
-
-static void opj_pi_update_encode_not_poc(opj_cp_t *p_cp,
- OPJ_UINT32 p_num_comps,
- OPJ_UINT32 p_tileno,
- OPJ_UINT32 p_tx0,
- OPJ_UINT32 p_tx1,
- OPJ_UINT32 p_ty0,
- OPJ_UINT32 p_ty1,
- OPJ_UINT32 p_max_prec,
- OPJ_UINT32 p_max_res,
- OPJ_UINT32 p_dx_min,
- OPJ_UINT32 p_dy_min)
-{
- /* loop*/
- OPJ_UINT32 pino;
- /* tile coding parameter*/
- opj_tcp_t *l_tcp = 00;
- /* current poc being updated*/
- opj_poc_t * l_current_poc = 00;
- /* number of pocs*/
- OPJ_UINT32 l_poc_bound;
-
- /* preconditions in debug*/
- assert(p_cp != 00);
- assert(p_tileno < p_cp->tw * p_cp->th);
-
- /* initializations*/
- l_tcp = &p_cp->tcps [p_tileno];
-
- /* number of iterations in the loop */
- l_poc_bound = l_tcp->numpocs + 1;
-
- /* start at first element, and to make sure the compiler will not make a calculation each time in the loop
- store a pointer to the current element to modify rather than l_tcp->pocs[i]*/
- l_current_poc = l_tcp->pocs;
-
- for (pino = 0; pino < l_poc_bound ; ++pino) {
- l_current_poc->compS = 0;
- l_current_poc->compE = p_num_comps;/*p_image->numcomps;*/
- l_current_poc->resS = 0;
- l_current_poc->resE = p_max_res;
- l_current_poc->layS = 0;
- l_current_poc->layE = l_tcp->numlayers;
- l_current_poc->prg = l_tcp->prg;
- l_current_poc->prcS = 0;
- l_current_poc->prcE = p_max_prec;
- l_current_poc->txS = p_tx0;
- l_current_poc->txE = p_tx1;
- l_current_poc->tyS = p_ty0;
- l_current_poc->tyE = p_ty1;
- l_current_poc->dx = p_dx_min;
- l_current_poc->dy = p_dy_min;
- ++ l_current_poc;
- }
-}
-
-static void opj_pi_update_decode_poc(opj_pi_iterator_t * p_pi,
- opj_tcp_t * p_tcp,
- OPJ_UINT32 p_max_precision,
- OPJ_UINT32 p_max_res)
-{
- /* loop*/
- OPJ_UINT32 pino;
-
- /* encoding parameters to set*/
- OPJ_UINT32 l_bound;
-
- opj_pi_iterator_t * l_current_pi = 00;
- opj_poc_t* l_current_poc = 0;
-
- OPJ_ARG_NOT_USED(p_max_res);
-
- /* preconditions in debug*/
- assert(p_pi != 00);
- assert(p_tcp != 00);
-
- /* initializations*/
- l_bound = p_tcp->numpocs + 1;
- l_current_pi = p_pi;
- l_current_poc = p_tcp->pocs;
-
- for (pino = 0; pino < l_bound; ++pino) {
- l_current_pi->poc.prg = l_current_poc->prg; /* Progression Order #0 */
- l_current_pi->first = 1;
-
- l_current_pi->poc.resno0 =
- l_current_poc->resno0; /* Resolution Level Index #0 (Start) */
- l_current_pi->poc.compno0 =
- l_current_poc->compno0; /* Component Index #0 (Start) */
- l_current_pi->poc.layno0 = 0;
- l_current_pi->poc.precno0 = 0;
- l_current_pi->poc.resno1 =
- l_current_poc->resno1; /* Resolution Level Index #0 (End) */
- l_current_pi->poc.compno1 =
- l_current_poc->compno1; /* Component Index #0 (End) */
- l_current_pi->poc.layno1 = opj_uint_min(l_current_poc->layno1,
- p_tcp->numlayers); /* Layer Index #0 (End) */
- l_current_pi->poc.precno1 = p_max_precision;
- ++l_current_pi;
- ++l_current_poc;
- }
-}
-
-static void opj_pi_update_decode_not_poc(opj_pi_iterator_t * p_pi,
- opj_tcp_t * p_tcp,
- OPJ_UINT32 p_max_precision,
- OPJ_UINT32 p_max_res)
-{
- /* loop*/
- OPJ_UINT32 pino;
-
- /* encoding parameters to set*/
- OPJ_UINT32 l_bound;
-
- opj_pi_iterator_t * l_current_pi = 00;
- /* preconditions in debug*/
- assert(p_tcp != 00);
- assert(p_pi != 00);
-
- /* initializations*/
- l_bound = p_tcp->numpocs + 1;
- l_current_pi = p_pi;
-
- for (pino = 0; pino < l_bound; ++pino) {
- l_current_pi->poc.prg = p_tcp->prg;
- l_current_pi->first = 1;
- l_current_pi->poc.resno0 = 0;
- l_current_pi->poc.compno0 = 0;
- l_current_pi->poc.layno0 = 0;
- l_current_pi->poc.precno0 = 0;
- l_current_pi->poc.resno1 = p_max_res;
- l_current_pi->poc.compno1 = l_current_pi->numcomps;
- l_current_pi->poc.layno1 = p_tcp->numlayers;
- l_current_pi->poc.precno1 = p_max_precision;
- ++l_current_pi;
- }
-}
-
-
-
-static OPJ_BOOL opj_pi_check_next_level(OPJ_INT32 pos,
- opj_cp_t *cp,
- OPJ_UINT32 tileno,
- OPJ_UINT32 pino,
- const OPJ_CHAR *prog)
-{
- OPJ_INT32 i;
- opj_tcp_t *tcps = &cp->tcps[tileno];
- opj_poc_t *tcp = &tcps->pocs[pino];
-
- if (pos >= 0) {
- for (i = pos; i >= 0; i--) {
- switch (prog[i]) {
- case 'R':
- if (tcp->res_t == tcp->resE) {
- if (opj_pi_check_next_level(pos - 1, cp, tileno, pino, prog)) {
- return OPJ_TRUE;
- } else {
- return OPJ_FALSE;
- }
- } else {
- return OPJ_TRUE;
- }
- break;
- case 'C':
- if (tcp->comp_t == tcp->compE) {
- if (opj_pi_check_next_level(pos - 1, cp, tileno, pino, prog)) {
- return OPJ_TRUE;
- } else {
- return OPJ_FALSE;
- }
- } else {
- return OPJ_TRUE;
- }
- break;
- case 'L':
- if (tcp->lay_t == tcp->layE) {
- if (opj_pi_check_next_level(pos - 1, cp, tileno, pino, prog)) {
- return OPJ_TRUE;
- } else {
- return OPJ_FALSE;
- }
- } else {
- return OPJ_TRUE;
- }
- break;
- case 'P':
- switch (tcp->prg) {
- case OPJ_LRCP: /* fall through */
- case OPJ_RLCP:
- if (tcp->prc_t == tcp->prcE) {
- if (opj_pi_check_next_level(i - 1, cp, tileno, pino, prog)) {
- return OPJ_TRUE;
- } else {
- return OPJ_FALSE;
- }
- } else {
- return OPJ_TRUE;
- }
- break;
- default:
- if (tcp->tx0_t == tcp->txE) {
- /*TY*/
- if (tcp->ty0_t == tcp->tyE) {
- if (opj_pi_check_next_level(i - 1, cp, tileno, pino, prog)) {
- return OPJ_TRUE;
- } else {
- return OPJ_FALSE;
- }
- } else {
- return OPJ_TRUE;
- }/*TY*/
- } else {
- return OPJ_TRUE;
- }
- break;
- }/*end case P*/
- }/*end switch*/
- }/*end for*/
- }/*end if*/
- return OPJ_FALSE;
-}
-
-
-/*
-==========================================================
- Packet iterator interface
-==========================================================
-*/
-opj_pi_iterator_t *opj_pi_create_decode(opj_image_t *p_image,
- opj_cp_t *p_cp,
- OPJ_UINT32 p_tile_no,
- opj_event_mgr_t* manager)
-{
- OPJ_UINT32 numcomps = p_image->numcomps;
-
- /* loop */
- OPJ_UINT32 pino;
- OPJ_UINT32 compno, resno;
-
- /* to store w, h, dx and dy for all components and resolutions */
- OPJ_UINT32 * l_tmp_data;
- OPJ_UINT32 ** l_tmp_ptr;
-
- /* encoding parameters to set */
- OPJ_UINT32 l_max_res;
- OPJ_UINT32 l_max_prec;
- OPJ_UINT32 l_tx0, l_tx1, l_ty0, l_ty1;
- OPJ_UINT32 l_dx_min, l_dy_min;
- OPJ_UINT32 l_bound;
- OPJ_UINT32 l_step_p, l_step_c, l_step_r, l_step_l ;
- OPJ_UINT32 l_data_stride;
-
- /* pointers */
- opj_pi_iterator_t *l_pi = 00;
- opj_tcp_t *l_tcp = 00;
- const opj_tccp_t *l_tccp = 00;
- opj_pi_comp_t *l_current_comp = 00;
- opj_image_comp_t * l_img_comp = 00;
- opj_pi_iterator_t * l_current_pi = 00;
- OPJ_UINT32 * l_encoding_value_ptr = 00;
-
- /* preconditions in debug */
- assert(p_cp != 00);
- assert(p_image != 00);
- assert(p_tile_no < p_cp->tw * p_cp->th);
-
- /* initializations */
- l_tcp = &p_cp->tcps[p_tile_no];
- l_bound = l_tcp->numpocs + 1;
-
- l_data_stride = 4 * OPJ_J2K_MAXRLVLS;
- l_tmp_data = (OPJ_UINT32*)opj_malloc(
- l_data_stride * numcomps * sizeof(OPJ_UINT32));
- if
- (! l_tmp_data) {
- return 00;
- }
- l_tmp_ptr = (OPJ_UINT32**)opj_malloc(
- numcomps * sizeof(OPJ_UINT32 *));
- if
- (! l_tmp_ptr) {
- opj_free(l_tmp_data);
- return 00;
- }
-
- /* memory allocation for pi */
- l_pi = opj_pi_create(p_image, p_cp, p_tile_no, manager);
- if (!l_pi) {
- opj_free(l_tmp_data);
- opj_free(l_tmp_ptr);
- return 00;
- }
-
- l_encoding_value_ptr = l_tmp_data;
- /* update pointer array */
- for
- (compno = 0; compno < numcomps; ++compno) {
- l_tmp_ptr[compno] = l_encoding_value_ptr;
- l_encoding_value_ptr += l_data_stride;
- }
- /* get encoding parameters */
- opj_get_all_encoding_parameters(p_image, p_cp, p_tile_no, &l_tx0, &l_tx1,
- &l_ty0, &l_ty1, &l_dx_min, &l_dy_min, &l_max_prec, &l_max_res, l_tmp_ptr);
-
- /* step calculations */
- l_step_p = 1;
- l_step_c = l_max_prec * l_step_p;
- l_step_r = numcomps * l_step_c;
- l_step_l = l_max_res * l_step_r;
-
- /* set values for first packet iterator */
- l_current_pi = l_pi;
-
- /* memory allocation for include */
- /* prevent an integer overflow issue */
- /* 0 < l_tcp->numlayers < 65536 c.f. opj_j2k_read_cod in j2k.c */
- l_current_pi->include = 00;
- if (l_step_l <= (UINT_MAX / (l_tcp->numlayers + 1U))) {
- l_current_pi->include_size = (l_tcp->numlayers + 1U) * l_step_l;
- l_current_pi->include = (OPJ_INT16*) opj_calloc(
- l_current_pi->include_size, sizeof(OPJ_INT16));
- }
-
- if (!l_current_pi->include) {
- opj_free(l_tmp_data);
- opj_free(l_tmp_ptr);
- opj_pi_destroy(l_pi, l_bound);
- return 00;
- }
-
- /* special treatment for the first packet iterator */
- l_current_comp = l_current_pi->comps;
- l_img_comp = p_image->comps;
- l_tccp = l_tcp->tccps;
-
- l_current_pi->tx0 = l_tx0;
- l_current_pi->ty0 = l_ty0;
- l_current_pi->tx1 = l_tx1;
- l_current_pi->ty1 = l_ty1;
-
- /*l_current_pi->dx = l_img_comp->dx;*/
- /*l_current_pi->dy = l_img_comp->dy;*/
-
- l_current_pi->step_p = l_step_p;
- l_current_pi->step_c = l_step_c;
- l_current_pi->step_r = l_step_r;
- l_current_pi->step_l = l_step_l;
-
- /* allocation for components and number of components has already been calculated by opj_pi_create */
- for
- (compno = 0; compno < numcomps; ++compno) {
- opj_pi_resolution_t *l_res = l_current_comp->resolutions;
- l_encoding_value_ptr = l_tmp_ptr[compno];
-
- l_current_comp->dx = l_img_comp->dx;
- l_current_comp->dy = l_img_comp->dy;
- /* resolutions have already been initialized */
- for
- (resno = 0; resno < l_current_comp->numresolutions; resno++) {
- l_res->pdx = *(l_encoding_value_ptr++);
- l_res->pdy = *(l_encoding_value_ptr++);
- l_res->pw = *(l_encoding_value_ptr++);
- l_res->ph = *(l_encoding_value_ptr++);
- ++l_res;
- }
- ++l_current_comp;
- ++l_img_comp;
- ++l_tccp;
- }
- ++l_current_pi;
-
- for (pino = 1 ; pino < l_bound ; ++pino) {
- l_current_comp = l_current_pi->comps;
- l_img_comp = p_image->comps;
- l_tccp = l_tcp->tccps;
-
- l_current_pi->tx0 = l_tx0;
- l_current_pi->ty0 = l_ty0;
- l_current_pi->tx1 = l_tx1;
- l_current_pi->ty1 = l_ty1;
- /*l_current_pi->dx = l_dx_min;*/
- /*l_current_pi->dy = l_dy_min;*/
- l_current_pi->step_p = l_step_p;
- l_current_pi->step_c = l_step_c;
- l_current_pi->step_r = l_step_r;
- l_current_pi->step_l = l_step_l;
-
- /* allocation for components and number of components has already been calculated by opj_pi_create */
- for
- (compno = 0; compno < numcomps; ++compno) {
- opj_pi_resolution_t *l_res = l_current_comp->resolutions;
- l_encoding_value_ptr = l_tmp_ptr[compno];
-
- l_current_comp->dx = l_img_comp->dx;
- l_current_comp->dy = l_img_comp->dy;
- /* resolutions have already been initialized */
- for
- (resno = 0; resno < l_current_comp->numresolutions; resno++) {
- l_res->pdx = *(l_encoding_value_ptr++);
- l_res->pdy = *(l_encoding_value_ptr++);
- l_res->pw = *(l_encoding_value_ptr++);
- l_res->ph = *(l_encoding_value_ptr++);
- ++l_res;
- }
- ++l_current_comp;
- ++l_img_comp;
- ++l_tccp;
- }
- /* special treatment*/
- l_current_pi->include = (l_current_pi - 1)->include;
- l_current_pi->include_size = (l_current_pi - 1)->include_size;
- ++l_current_pi;
- }
- opj_free(l_tmp_data);
- l_tmp_data = 00;
- opj_free(l_tmp_ptr);
- l_tmp_ptr = 00;
- if
- (l_tcp->POC) {
- opj_pi_update_decode_poc(l_pi, l_tcp, l_max_prec, l_max_res);
- } else {
- opj_pi_update_decode_not_poc(l_pi, l_tcp, l_max_prec, l_max_res);
- }
- return l_pi;
-}
-
-
-OPJ_UINT32 opj_get_encoding_packet_count(const opj_image_t *p_image,
- const opj_cp_t *p_cp,
- OPJ_UINT32 p_tile_no)
-{
- OPJ_UINT32 l_max_res;
- OPJ_UINT32 l_max_prec;
- OPJ_UINT32 l_tx0, l_tx1, l_ty0, l_ty1;
- OPJ_UINT32 l_dx_min, l_dy_min;
-
- /* preconditions in debug*/
- assert(p_cp != 00);
- assert(p_image != 00);
- assert(p_tile_no < p_cp->tw * p_cp->th);
-
- /* get encoding parameters*/
- opj_get_all_encoding_parameters(p_image, p_cp, p_tile_no, &l_tx0, &l_tx1,
- &l_ty0, &l_ty1, &l_dx_min, &l_dy_min, &l_max_prec, &l_max_res, NULL);
-
- return p_cp->tcps[p_tile_no].numlayers * l_max_prec * p_image->numcomps *
- l_max_res;
-}
-
-
-opj_pi_iterator_t *opj_pi_initialise_encode(const opj_image_t *p_image,
- opj_cp_t *p_cp,
- OPJ_UINT32 p_tile_no,
- J2K_T2_MODE p_t2_mode,
- opj_event_mgr_t* manager)
-{
- OPJ_UINT32 numcomps = p_image->numcomps;
-
- /* loop*/
- OPJ_UINT32 pino;
- OPJ_UINT32 compno, resno;
-
- /* to store w, h, dx and dy for all components and resolutions*/
- OPJ_UINT32 * l_tmp_data;
- OPJ_UINT32 ** l_tmp_ptr;
-
- /* encoding parameters to set*/
- OPJ_UINT32 l_max_res;
- OPJ_UINT32 l_max_prec;
- OPJ_UINT32 l_tx0, l_tx1, l_ty0, l_ty1;
- OPJ_UINT32 l_dx_min, l_dy_min;
- OPJ_UINT32 l_bound;
- OPJ_UINT32 l_step_p, l_step_c, l_step_r, l_step_l ;
- OPJ_UINT32 l_data_stride;
-
- /* pointers*/
- opj_pi_iterator_t *l_pi = 00;
- opj_tcp_t *l_tcp = 00;
- const opj_tccp_t *l_tccp = 00;
- opj_pi_comp_t *l_current_comp = 00;
- opj_image_comp_t * l_img_comp = 00;
- opj_pi_iterator_t * l_current_pi = 00;
- OPJ_UINT32 * l_encoding_value_ptr = 00;
-
- /* preconditions in debug*/
- assert(p_cp != 00);
- assert(p_image != 00);
- assert(p_tile_no < p_cp->tw * p_cp->th);
-
- /* initializations*/
- l_tcp = &p_cp->tcps[p_tile_no];
- l_bound = l_tcp->numpocs + 1;
-
- l_data_stride = 4 * OPJ_J2K_MAXRLVLS;
- l_tmp_data = (OPJ_UINT32*)opj_malloc(
- l_data_stride * numcomps * sizeof(OPJ_UINT32));
- if (! l_tmp_data) {
- return 00;
- }
-
- l_tmp_ptr = (OPJ_UINT32**)opj_malloc(
- numcomps * sizeof(OPJ_UINT32 *));
- if (! l_tmp_ptr) {
- opj_free(l_tmp_data);
- return 00;
- }
-
- /* memory allocation for pi*/
- l_pi = opj_pi_create(p_image, p_cp, p_tile_no, manager);
- if (!l_pi) {
- opj_free(l_tmp_data);
- opj_free(l_tmp_ptr);
- return 00;
- }
-
- l_encoding_value_ptr = l_tmp_data;
- /* update pointer array*/
- for (compno = 0; compno < numcomps; ++compno) {
- l_tmp_ptr[compno] = l_encoding_value_ptr;
- l_encoding_value_ptr += l_data_stride;
- }
-
- /* get encoding parameters*/
- opj_get_all_encoding_parameters(p_image, p_cp, p_tile_no, &l_tx0, &l_tx1,
- &l_ty0, &l_ty1, &l_dx_min, &l_dy_min, &l_max_prec, &l_max_res, l_tmp_ptr);
-
- /* step calculations*/
- l_step_p = 1;
- l_step_c = l_max_prec * l_step_p;
- l_step_r = numcomps * l_step_c;
- l_step_l = l_max_res * l_step_r;
-
- /* set values for first packet iterator*/
- l_pi->tp_on = (OPJ_BYTE)p_cp->m_specific_param.m_enc.m_tp_on;
- l_current_pi = l_pi;
-
- /* memory allocation for include*/
- l_current_pi->include_size = l_tcp->numlayers * l_step_l;
- l_current_pi->include = (OPJ_INT16*) opj_calloc(l_current_pi->include_size,
- sizeof(OPJ_INT16));
- if (!l_current_pi->include) {
- opj_free(l_tmp_data);
- opj_free(l_tmp_ptr);
- opj_pi_destroy(l_pi, l_bound);
- return 00;
- }
-
- /* special treatment for the first packet iterator*/
- l_current_comp = l_current_pi->comps;
- l_img_comp = p_image->comps;
- l_tccp = l_tcp->tccps;
- l_current_pi->tx0 = l_tx0;
- l_current_pi->ty0 = l_ty0;
- l_current_pi->tx1 = l_tx1;
- l_current_pi->ty1 = l_ty1;
- l_current_pi->dx = l_dx_min;
- l_current_pi->dy = l_dy_min;
- l_current_pi->step_p = l_step_p;
- l_current_pi->step_c = l_step_c;
- l_current_pi->step_r = l_step_r;
- l_current_pi->step_l = l_step_l;
-
- /* allocation for components and number of components has already been calculated by opj_pi_create */
- for (compno = 0; compno < numcomps; ++compno) {
- opj_pi_resolution_t *l_res = l_current_comp->resolutions;
- l_encoding_value_ptr = l_tmp_ptr[compno];
-
- l_current_comp->dx = l_img_comp->dx;
- l_current_comp->dy = l_img_comp->dy;
-
- /* resolutions have already been initialized */
- for (resno = 0; resno < l_current_comp->numresolutions; resno++) {
- l_res->pdx = *(l_encoding_value_ptr++);
- l_res->pdy = *(l_encoding_value_ptr++);
- l_res->pw = *(l_encoding_value_ptr++);
- l_res->ph = *(l_encoding_value_ptr++);
- ++l_res;
- }
-
- ++l_current_comp;
- ++l_img_comp;
- ++l_tccp;
- }
- ++l_current_pi;
-
- for (pino = 1 ; pino < l_bound ; ++pino) {
- l_current_comp = l_current_pi->comps;
- l_img_comp = p_image->comps;
- l_tccp = l_tcp->tccps;
-
- l_current_pi->tx0 = l_tx0;
- l_current_pi->ty0 = l_ty0;
- l_current_pi->tx1 = l_tx1;
- l_current_pi->ty1 = l_ty1;
- l_current_pi->dx = l_dx_min;
- l_current_pi->dy = l_dy_min;
- l_current_pi->step_p = l_step_p;
- l_current_pi->step_c = l_step_c;
- l_current_pi->step_r = l_step_r;
- l_current_pi->step_l = l_step_l;
-
- /* allocation for components and number of components has already been calculated by opj_pi_create */
- for (compno = 0; compno < numcomps; ++compno) {
- opj_pi_resolution_t *l_res = l_current_comp->resolutions;
- l_encoding_value_ptr = l_tmp_ptr[compno];
-
- l_current_comp->dx = l_img_comp->dx;
- l_current_comp->dy = l_img_comp->dy;
- /* resolutions have already been initialized */
- for (resno = 0; resno < l_current_comp->numresolutions; resno++) {
- l_res->pdx = *(l_encoding_value_ptr++);
- l_res->pdy = *(l_encoding_value_ptr++);
- l_res->pw = *(l_encoding_value_ptr++);
- l_res->ph = *(l_encoding_value_ptr++);
- ++l_res;
- }
- ++l_current_comp;
- ++l_img_comp;
- ++l_tccp;
- }
-
- /* special treatment*/
- l_current_pi->include = (l_current_pi - 1)->include;
- l_current_pi->include_size = (l_current_pi - 1)->include_size;
- ++l_current_pi;
- }
-
- opj_free(l_tmp_data);
- l_tmp_data = 00;
- opj_free(l_tmp_ptr);
- l_tmp_ptr = 00;
-
- if (l_tcp->POC && (OPJ_IS_CINEMA(p_cp->rsiz) || p_t2_mode == FINAL_PASS)) {
- opj_pi_update_encode_poc_and_final(p_cp, p_tile_no, l_tx0, l_tx1, l_ty0, l_ty1,
- l_max_prec, l_max_res, l_dx_min, l_dy_min);
- } else {
- opj_pi_update_encode_not_poc(p_cp, numcomps, p_tile_no, l_tx0, l_tx1,
- l_ty0, l_ty1, l_max_prec, l_max_res, l_dx_min, l_dy_min);
- }
-
- return l_pi;
-}
-
-void opj_pi_create_encode(opj_pi_iterator_t *pi,
- opj_cp_t *cp,
- OPJ_UINT32 tileno,
- OPJ_UINT32 pino,
- OPJ_UINT32 tpnum,
- OPJ_INT32 tppos,
- J2K_T2_MODE t2_mode)
-{
- const OPJ_CHAR *prog;
- OPJ_INT32 i;
- OPJ_UINT32 incr_top = 1, resetX = 0;
- opj_tcp_t *tcps = &cp->tcps[tileno];
- opj_poc_t *tcp = &tcps->pocs[pino];
-
- prog = opj_j2k_convert_progression_order(tcp->prg);
-
- pi[pino].first = 1;
- pi[pino].poc.prg = tcp->prg;
-
- if (!(cp->m_specific_param.m_enc.m_tp_on && ((!OPJ_IS_CINEMA(cp->rsiz) &&
- !OPJ_IS_IMF(cp->rsiz) &&
- (t2_mode == FINAL_PASS)) || OPJ_IS_CINEMA(cp->rsiz) || OPJ_IS_IMF(cp->rsiz)))) {
- pi[pino].poc.resno0 = tcp->resS;
- pi[pino].poc.resno1 = tcp->resE;
- pi[pino].poc.compno0 = tcp->compS;
- pi[pino].poc.compno1 = tcp->compE;
- pi[pino].poc.layno0 = tcp->layS;
- pi[pino].poc.layno1 = tcp->layE;
- pi[pino].poc.precno0 = tcp->prcS;
- pi[pino].poc.precno1 = tcp->prcE;
- pi[pino].poc.tx0 = tcp->txS;
- pi[pino].poc.ty0 = tcp->tyS;
- pi[pino].poc.tx1 = tcp->txE;
- pi[pino].poc.ty1 = tcp->tyE;
- } else {
- for (i = tppos + 1; i < 4; i++) {
- switch (prog[i]) {
- case 'R':
- pi[pino].poc.resno0 = tcp->resS;
- pi[pino].poc.resno1 = tcp->resE;
- break;
- case 'C':
- pi[pino].poc.compno0 = tcp->compS;
- pi[pino].poc.compno1 = tcp->compE;
- break;
- case 'L':
- pi[pino].poc.layno0 = tcp->layS;
- pi[pino].poc.layno1 = tcp->layE;
- break;
- case 'P':
- switch (tcp->prg) {
- case OPJ_LRCP:
- case OPJ_RLCP:
- pi[pino].poc.precno0 = tcp->prcS;
- pi[pino].poc.precno1 = tcp->prcE;
- break;
- default:
- pi[pino].poc.tx0 = tcp->txS;
- pi[pino].poc.ty0 = tcp->tyS;
- pi[pino].poc.tx1 = tcp->txE;
- pi[pino].poc.ty1 = tcp->tyE;
- break;
- }
- break;
- }
- }
-
- if (tpnum == 0) {
- for (i = tppos; i >= 0; i--) {
- switch (prog[i]) {
- case 'C':
- tcp->comp_t = tcp->compS;
- pi[pino].poc.compno0 = tcp->comp_t;
- pi[pino].poc.compno1 = tcp->comp_t + 1;
- tcp->comp_t += 1;
- break;
- case 'R':
- tcp->res_t = tcp->resS;
- pi[pino].poc.resno0 = tcp->res_t;
- pi[pino].poc.resno1 = tcp->res_t + 1;
- tcp->res_t += 1;
- break;
- case 'L':
- tcp->lay_t = tcp->layS;
- pi[pino].poc.layno0 = tcp->lay_t;
- pi[pino].poc.layno1 = tcp->lay_t + 1;
- tcp->lay_t += 1;
- break;
- case 'P':
- switch (tcp->prg) {
- case OPJ_LRCP:
- case OPJ_RLCP:
- tcp->prc_t = tcp->prcS;
- pi[pino].poc.precno0 = tcp->prc_t;
- pi[pino].poc.precno1 = tcp->prc_t + 1;
- tcp->prc_t += 1;
- break;
- default:
- tcp->tx0_t = tcp->txS;
- tcp->ty0_t = tcp->tyS;
- pi[pino].poc.tx0 = tcp->tx0_t;
- pi[pino].poc.tx1 = tcp->tx0_t + tcp->dx - (tcp->tx0_t % tcp->dx);
- pi[pino].poc.ty0 = tcp->ty0_t;
- pi[pino].poc.ty1 = tcp->ty0_t + tcp->dy - (tcp->ty0_t % tcp->dy);
- tcp->tx0_t = (OPJ_UINT32)pi[pino].poc.tx1;
- tcp->ty0_t = (OPJ_UINT32)pi[pino].poc.ty1;
- break;
- }
- break;
- }
- }
- incr_top = 1;
- } else {
- for (i = tppos; i >= 0; i--) {
- switch (prog[i]) {
- case 'C':
- pi[pino].poc.compno0 = tcp->comp_t - 1;
- pi[pino].poc.compno1 = tcp->comp_t;
- break;
- case 'R':
- pi[pino].poc.resno0 = tcp->res_t - 1;
- pi[pino].poc.resno1 = tcp->res_t;
- break;
- case 'L':
- pi[pino].poc.layno0 = tcp->lay_t - 1;
- pi[pino].poc.layno1 = tcp->lay_t;
- break;
- case 'P':
- switch (tcp->prg) {
- case OPJ_LRCP:
- case OPJ_RLCP:
- pi[pino].poc.precno0 = tcp->prc_t - 1;
- pi[pino].poc.precno1 = tcp->prc_t;
- break;
- default:
- pi[pino].poc.tx0 = tcp->tx0_t - tcp->dx - (tcp->tx0_t % tcp->dx);
- pi[pino].poc.tx1 = tcp->tx0_t ;
- pi[pino].poc.ty0 = tcp->ty0_t - tcp->dy - (tcp->ty0_t % tcp->dy);
- pi[pino].poc.ty1 = tcp->ty0_t ;
- break;
- }
- break;
- }
- if (incr_top == 1) {
- switch (prog[i]) {
- case 'R':
- if (tcp->res_t == tcp->resE) {
- if (opj_pi_check_next_level(i - 1, cp, tileno, pino, prog)) {
- tcp->res_t = tcp->resS;
- pi[pino].poc.resno0 = tcp->res_t;
- pi[pino].poc.resno1 = tcp->res_t + 1;
- tcp->res_t += 1;
- incr_top = 1;
- } else {
- incr_top = 0;
- }
- } else {
- pi[pino].poc.resno0 = tcp->res_t;
- pi[pino].poc.resno1 = tcp->res_t + 1;
- tcp->res_t += 1;
- incr_top = 0;
- }
- break;
- case 'C':
- if (tcp->comp_t == tcp->compE) {
- if (opj_pi_check_next_level(i - 1, cp, tileno, pino, prog)) {
- tcp->comp_t = tcp->compS;
- pi[pino].poc.compno0 = tcp->comp_t;
- pi[pino].poc.compno1 = tcp->comp_t + 1;
- tcp->comp_t += 1;
- incr_top = 1;
- } else {
- incr_top = 0;
- }
- } else {
- pi[pino].poc.compno0 = tcp->comp_t;
- pi[pino].poc.compno1 = tcp->comp_t + 1;
- tcp->comp_t += 1;
- incr_top = 0;
- }
- break;
- case 'L':
- if (tcp->lay_t == tcp->layE) {
- if (opj_pi_check_next_level(i - 1, cp, tileno, pino, prog)) {
- tcp->lay_t = tcp->layS;
- pi[pino].poc.layno0 = tcp->lay_t;
- pi[pino].poc.layno1 = tcp->lay_t + 1;
- tcp->lay_t += 1;
- incr_top = 1;
- } else {
- incr_top = 0;
- }
- } else {
- pi[pino].poc.layno0 = tcp->lay_t;
- pi[pino].poc.layno1 = tcp->lay_t + 1;
- tcp->lay_t += 1;
- incr_top = 0;
- }
- break;
- case 'P':
- switch (tcp->prg) {
- case OPJ_LRCP:
- case OPJ_RLCP:
- if (tcp->prc_t == tcp->prcE) {
- if (opj_pi_check_next_level(i - 1, cp, tileno, pino, prog)) {
- tcp->prc_t = tcp->prcS;
- pi[pino].poc.precno0 = tcp->prc_t;
- pi[pino].poc.precno1 = tcp->prc_t + 1;
- tcp->prc_t += 1;
- incr_top = 1;
- } else {
- incr_top = 0;
- }
- } else {
- pi[pino].poc.precno0 = tcp->prc_t;
- pi[pino].poc.precno1 = tcp->prc_t + 1;
- tcp->prc_t += 1;
- incr_top = 0;
- }
- break;
- default:
- if (tcp->tx0_t >= tcp->txE) {
- if (tcp->ty0_t >= tcp->tyE) {
- if (opj_pi_check_next_level(i - 1, cp, tileno, pino, prog)) {
- tcp->ty0_t = tcp->tyS;
- pi[pino].poc.ty0 = tcp->ty0_t;
- pi[pino].poc.ty1 = tcp->ty0_t + tcp->dy - (tcp->ty0_t % tcp->dy);
- tcp->ty0_t = (OPJ_UINT32)pi[pino].poc.ty1;
- incr_top = 1;
- resetX = 1;
- } else {
- incr_top = 0;
- resetX = 0;
- }
- } else {
- pi[pino].poc.ty0 = tcp->ty0_t;
- pi[pino].poc.ty1 = tcp->ty0_t + tcp->dy - (tcp->ty0_t % tcp->dy);
- tcp->ty0_t = (OPJ_UINT32)pi[pino].poc.ty1;
- incr_top = 0;
- resetX = 1;
- }
- if (resetX == 1) {
- tcp->tx0_t = tcp->txS;
- pi[pino].poc.tx0 = tcp->tx0_t;
- pi[pino].poc.tx1 = tcp->tx0_t + tcp->dx - (tcp->tx0_t % tcp->dx);
- tcp->tx0_t = (OPJ_UINT32)pi[pino].poc.tx1;
- }
- } else {
- pi[pino].poc.tx0 = tcp->tx0_t;
- pi[pino].poc.tx1 = tcp->tx0_t + tcp->dx - (tcp->tx0_t % tcp->dx);
- tcp->tx0_t = (OPJ_UINT32)pi[pino].poc.tx1;
- incr_top = 0;
- }
- break;
- }
- break;
- }
- }
- }
- }
- }
-}
-
-void opj_pi_destroy(opj_pi_iterator_t *p_pi,
- OPJ_UINT32 p_nb_elements)
-{
- OPJ_UINT32 compno, pino;
- opj_pi_iterator_t *l_current_pi = p_pi;
- if (p_pi) {
- if (p_pi->include) {
- opj_free(p_pi->include);
- p_pi->include = 00;
- }
- for (pino = 0; pino < p_nb_elements; ++pino) {
- if (l_current_pi->comps) {
- opj_pi_comp_t *l_current_component = l_current_pi->comps;
- for (compno = 0; compno < l_current_pi->numcomps; compno++) {
- if (l_current_component->resolutions) {
- opj_free(l_current_component->resolutions);
- l_current_component->resolutions = 00;
- }
-
- ++l_current_component;
- }
- opj_free(l_current_pi->comps);
- l_current_pi->comps = 0;
- }
- ++l_current_pi;
- }
- opj_free(p_pi);
- }
-}
-
-
-
-void opj_pi_update_encoding_parameters(const opj_image_t *p_image,
- opj_cp_t *p_cp,
- OPJ_UINT32 p_tile_no)
-{
- /* encoding parameters to set */
- OPJ_UINT32 l_max_res;
- OPJ_UINT32 l_max_prec;
- OPJ_UINT32 l_tx0, l_tx1, l_ty0, l_ty1;
- OPJ_UINT32 l_dx_min, l_dy_min;
-
- /* pointers */
- opj_tcp_t *l_tcp = 00;
-
- /* preconditions */
- assert(p_cp != 00);
- assert(p_image != 00);
- assert(p_tile_no < p_cp->tw * p_cp->th);
-
- l_tcp = &(p_cp->tcps[p_tile_no]);
-
- /* get encoding parameters */
- opj_get_encoding_parameters(p_image, p_cp, p_tile_no, &l_tx0, &l_tx1, &l_ty0,
- &l_ty1, &l_dx_min, &l_dy_min, &l_max_prec, &l_max_res);
-
- if (l_tcp->POC) {
- opj_pi_update_encode_poc_and_final(p_cp, p_tile_no, l_tx0, l_tx1, l_ty0, l_ty1,
- l_max_prec, l_max_res, l_dx_min, l_dy_min);
- } else {
- opj_pi_update_encode_not_poc(p_cp, p_image->numcomps, p_tile_no, l_tx0, l_tx1,
- l_ty0, l_ty1, l_max_prec, l_max_res, l_dx_min, l_dy_min);
- }
-}
-
-OPJ_BOOL opj_pi_next(opj_pi_iterator_t * pi)
-{
- switch (pi->poc.prg) {
- case OPJ_LRCP:
- return opj_pi_next_lrcp(pi);
- case OPJ_RLCP:
- return opj_pi_next_rlcp(pi);
- case OPJ_RPCL:
- return opj_pi_next_rpcl(pi);
- case OPJ_PCRL:
- return opj_pi_next_pcrl(pi);
- case OPJ_CPRL:
- return opj_pi_next_cprl(pi);
- case OPJ_PROG_UNKNOWN:
- return OPJ_FALSE;
- }
-
- return OPJ_FALSE;
-}
diff --git a/contrib/libs/openjpeg/pi.h b/contrib/libs/openjpeg/pi.h
deleted file mode 100644
index 0320523b76..0000000000
--- a/contrib/libs/openjpeg/pi.h
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2014, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux
- * Copyright (c) 2003-2014, Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef OPJ_PI_H
-#define OPJ_PI_H
-/**
-@file pi.h
-@brief Implementation of a packet iterator (PI)
-
-The functions in PI.C have for goal to realize a packet iterator that permits to get the next
-packet following the progression order and change of it. The functions in PI.C are used
-by some function in T2.C.
-*/
-
-/** @defgroup PI PI - Implementation of a packet iterator */
-/*@{*/
-
-/**
-FIXME DOC
-*/
-typedef struct opj_pi_resolution {
- OPJ_UINT32 pdx, pdy;
- OPJ_UINT32 pw, ph;
-} opj_pi_resolution_t;
-
-/**
-FIXME DOC
-*/
-typedef struct opj_pi_comp {
- OPJ_UINT32 dx, dy;
- /** number of resolution levels */
- OPJ_UINT32 numresolutions;
- opj_pi_resolution_t *resolutions;
-} opj_pi_comp_t;
-
-/**
-Packet iterator
-*/
-typedef struct opj_pi_iterator {
- /** Enabling Tile part generation*/
- OPJ_BYTE tp_on;
- /** precise if the packet has been already used (useful for progression order change) */
- OPJ_INT16 *include;
- /** Number of elements in include array */
- OPJ_UINT32 include_size;
- /** layer step used to localize the packet in the include vector */
- OPJ_UINT32 step_l;
- /** resolution step used to localize the packet in the include vector */
- OPJ_UINT32 step_r;
- /** component step used to localize the packet in the include vector */
- OPJ_UINT32 step_c;
- /** precinct step used to localize the packet in the include vector */
- OPJ_UINT32 step_p;
- /** component that identify the packet */
- OPJ_UINT32 compno;
- /** resolution that identify the packet */
- OPJ_UINT32 resno;
- /** precinct that identify the packet */
- OPJ_UINT32 precno;
- /** layer that identify the packet */
- OPJ_UINT32 layno;
- /** 0 if the first packet */
- OPJ_BOOL first;
- /** progression order change information */
- opj_poc_t poc;
- /** number of components in the image */
- OPJ_UINT32 numcomps;
- /** Components*/
- opj_pi_comp_t *comps;
- /** FIXME DOC*/
- OPJ_UINT32 tx0, ty0, tx1, ty1;
- /** FIXME DOC*/
- OPJ_UINT32 x, y;
- /** FIXME DOC*/
- OPJ_UINT32 dx, dy;
- /** event manager */
- opj_event_mgr_t* manager;
-} opj_pi_iterator_t;
-
-/** @name Exported functions */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-/**
- * Creates a packet iterator for encoding.
- *
- * @param image the image being encoded.
- * @param cp the coding parameters.
- * @param tileno index of the tile being encoded.
- * @param t2_mode the type of pass for generating the packet iterator
- * @param manager Event manager
- *
- * @return a list of packet iterator that points to the first packet of the tile (not true).
-*/
-opj_pi_iterator_t *opj_pi_initialise_encode(const opj_image_t *image,
- opj_cp_t *cp,
- OPJ_UINT32 tileno,
- J2K_T2_MODE t2_mode,
- opj_event_mgr_t* manager);
-
-/**
- * Updates the encoding parameters of the codec.
- *
- * @param p_image the image being encoded.
- * @param p_cp the coding parameters.
- * @param p_tile_no index of the tile being encoded.
-*/
-void opj_pi_update_encoding_parameters(const opj_image_t *p_image,
- opj_cp_t *p_cp,
- OPJ_UINT32 p_tile_no);
-
-/**
-Modify the packet iterator for enabling tile part generation
-@param pi Handle to the packet iterator generated in pi_initialise_encode
-@param cp Coding parameters
-@param tileno Number that identifies the tile for which to list the packets
-@param pino FIXME DOC
-@param tpnum Tile part number of the current tile
-@param tppos The position of the tile part flag in the progression order
-@param t2_mode FIXME DOC
-*/
-void opj_pi_create_encode(opj_pi_iterator_t *pi,
- opj_cp_t *cp,
- OPJ_UINT32 tileno,
- OPJ_UINT32 pino,
- OPJ_UINT32 tpnum,
- OPJ_INT32 tppos,
- J2K_T2_MODE t2_mode);
-
-/**
-Create a packet iterator for Decoder
-@param image Raw image for which the packets will be listed
-@param cp Coding parameters
-@param tileno Number that identifies the tile for which to list the packets
-@param manager Event manager
-@return Returns a packet iterator that points to the first packet of the tile
-@see opj_pi_destroy
-*/
-opj_pi_iterator_t *opj_pi_create_decode(opj_image_t * image,
- opj_cp_t * cp,
- OPJ_UINT32 tileno,
- opj_event_mgr_t* manager);
-/**
- * Destroys a packet iterator array.
- *
- * @param p_pi the packet iterator array to destroy.
- * @param p_nb_elements the number of elements in the array.
- */
-void opj_pi_destroy(opj_pi_iterator_t *p_pi,
- OPJ_UINT32 p_nb_elements);
-
-/**
-Modify the packet iterator to point to the next packet
-@param pi Packet iterator to modify
-@return Returns false if pi pointed to the last packet or else returns true
-*/
-OPJ_BOOL opj_pi_next(opj_pi_iterator_t * pi);
-
-/**
- * Return the number of packets in the tile.
- * @param image the image being encoded.
- * @param cp Coding parameters
- * @param tileno Number that identifies the tile.
- */
-OPJ_UINT32 opj_get_encoding_packet_count(const opj_image_t *p_image,
- const opj_cp_t *p_cp,
- OPJ_UINT32 p_tile_no);
-
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* OPJ_PI_H */
diff --git a/contrib/libs/openjpeg/sparse_array.c b/contrib/libs/openjpeg/sparse_array.c
deleted file mode 100644
index 50d1a9041a..0000000000
--- a/contrib/libs/openjpeg/sparse_array.c
+++ /dev/null
@@ -1,346 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2017, IntoPix SA <contact@intopix.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "opj_includes.h"
-
-
-struct opj_sparse_array_int32 {
- OPJ_UINT32 width;
- OPJ_UINT32 height;
- OPJ_UINT32 block_width;
- OPJ_UINT32 block_height;
- OPJ_UINT32 block_count_hor;
- OPJ_UINT32 block_count_ver;
- OPJ_INT32** data_blocks;
-};
-
-opj_sparse_array_int32_t* opj_sparse_array_int32_create(OPJ_UINT32 width,
- OPJ_UINT32 height,
- OPJ_UINT32 block_width,
- OPJ_UINT32 block_height)
-{
- opj_sparse_array_int32_t* sa;
-
- if (width == 0 || height == 0 || block_width == 0 || block_height == 0) {
- return NULL;
- }
- if (block_width > ((OPJ_UINT32)~0U) / block_height / sizeof(OPJ_INT32)) {
- return NULL;
- }
-
- sa = (opj_sparse_array_int32_t*) opj_calloc(1,
- sizeof(opj_sparse_array_int32_t));
- sa->width = width;
- sa->height = height;
- sa->block_width = block_width;
- sa->block_height = block_height;
- sa->block_count_hor = opj_uint_ceildiv(width, block_width);
- sa->block_count_ver = opj_uint_ceildiv(height, block_height);
- if (sa->block_count_hor > ((OPJ_UINT32)~0U) / sa->block_count_ver) {
- opj_free(sa);
- return NULL;
- }
- sa->data_blocks = (OPJ_INT32**) opj_calloc(sizeof(OPJ_INT32*),
- (size_t) sa->block_count_hor * sa->block_count_ver);
- if (sa->data_blocks == NULL) {
- opj_free(sa);
- return NULL;
- }
-
- return sa;
-}
-
-void opj_sparse_array_int32_free(opj_sparse_array_int32_t* sa)
-{
- if (sa) {
- OPJ_UINT32 i;
- for (i = 0; i < sa->block_count_hor * sa->block_count_ver; i++) {
- if (sa->data_blocks[i]) {
- opj_free(sa->data_blocks[i]);
- }
- }
- opj_free(sa->data_blocks);
- opj_free(sa);
- }
-}
-
-OPJ_BOOL opj_sparse_array_is_region_valid(const opj_sparse_array_int32_t* sa,
- OPJ_UINT32 x0,
- OPJ_UINT32 y0,
- OPJ_UINT32 x1,
- OPJ_UINT32 y1)
-{
- return !(x0 >= sa->width || x1 <= x0 || x1 > sa->width ||
- y0 >= sa->height || y1 <= y0 || y1 > sa->height);
-}
-
-static OPJ_BOOL opj_sparse_array_int32_read_or_write(
- const opj_sparse_array_int32_t* sa,
- OPJ_UINT32 x0,
- OPJ_UINT32 y0,
- OPJ_UINT32 x1,
- OPJ_UINT32 y1,
- OPJ_INT32* buf,
- OPJ_UINT32 buf_col_stride,
- OPJ_UINT32 buf_line_stride,
- OPJ_BOOL forgiving,
- OPJ_BOOL is_read_op)
-{
- OPJ_UINT32 y, block_y;
- OPJ_UINT32 y_incr = 0;
- const OPJ_UINT32 block_width = sa->block_width;
-
- if (!opj_sparse_array_is_region_valid(sa, x0, y0, x1, y1)) {
- return forgiving;
- }
-
- block_y = y0 / sa->block_height;
- for (y = y0; y < y1; block_y ++, y += y_incr) {
- OPJ_UINT32 x, block_x;
- OPJ_UINT32 x_incr = 0;
- OPJ_UINT32 block_y_offset;
- y_incr = (y == y0) ? sa->block_height - (y0 % sa->block_height) :
- sa->block_height;
- block_y_offset = sa->block_height - y_incr;
- y_incr = opj_uint_min(y_incr, y1 - y);
- block_x = x0 / block_width;
- for (x = x0; x < x1; block_x ++, x += x_incr) {
- OPJ_UINT32 j;
- OPJ_UINT32 block_x_offset;
- OPJ_INT32* src_block;
- x_incr = (x == x0) ? block_width - (x0 % block_width) : block_width;
- block_x_offset = block_width - x_incr;
- x_incr = opj_uint_min(x_incr, x1 - x);
- src_block = sa->data_blocks[block_y * sa->block_count_hor + block_x];
- if (is_read_op) {
- if (src_block == NULL) {
- if (buf_col_stride == 1) {
- OPJ_INT32* dest_ptr = buf + (y - y0) * (OPJ_SIZE_T)buf_line_stride +
- (x - x0) * buf_col_stride;
- for (j = 0; j < y_incr; j++) {
- memset(dest_ptr, 0, sizeof(OPJ_INT32) * x_incr);
- dest_ptr += buf_line_stride;
- }
- } else {
- OPJ_INT32* dest_ptr = buf + (y - y0) * (OPJ_SIZE_T)buf_line_stride +
- (x - x0) * buf_col_stride;
- for (j = 0; j < y_incr; j++) {
- OPJ_UINT32 k;
- for (k = 0; k < x_incr; k++) {
- dest_ptr[k * buf_col_stride] = 0;
- }
- dest_ptr += buf_line_stride;
- }
- }
- } else {
- const OPJ_INT32* OPJ_RESTRICT src_ptr = src_block + block_y_offset *
- (OPJ_SIZE_T)block_width + block_x_offset;
- if (buf_col_stride == 1) {
- OPJ_INT32* OPJ_RESTRICT dest_ptr = buf + (y - y0) * (OPJ_SIZE_T)buf_line_stride
- +
- (x - x0) * buf_col_stride;
- if (x_incr == 4) {
- /* Same code as general branch, but the compiler */
- /* can have an efficient memcpy() */
- (void)(x_incr); /* trick to silent cppcheck duplicateBranch warning */
- for (j = 0; j < y_incr; j++) {
- memcpy(dest_ptr, src_ptr, sizeof(OPJ_INT32) * x_incr);
- dest_ptr += buf_line_stride;
- src_ptr += block_width;
- }
- } else {
- for (j = 0; j < y_incr; j++) {
- memcpy(dest_ptr, src_ptr, sizeof(OPJ_INT32) * x_incr);
- dest_ptr += buf_line_stride;
- src_ptr += block_width;
- }
- }
- } else {
- OPJ_INT32* OPJ_RESTRICT dest_ptr = buf + (y - y0) * (OPJ_SIZE_T)buf_line_stride
- +
- (x - x0) * buf_col_stride;
- if (x_incr == 1) {
- for (j = 0; j < y_incr; j++) {
- *dest_ptr = *src_ptr;
- dest_ptr += buf_line_stride;
- src_ptr += block_width;
- }
- } else if (y_incr == 1 && buf_col_stride == 2) {
- OPJ_UINT32 k;
- for (k = 0; k < (x_incr & ~3U); k += 4) {
- dest_ptr[k * buf_col_stride] = src_ptr[k];
- dest_ptr[(k + 1) * buf_col_stride] = src_ptr[k + 1];
- dest_ptr[(k + 2) * buf_col_stride] = src_ptr[k + 2];
- dest_ptr[(k + 3) * buf_col_stride] = src_ptr[k + 3];
- }
- for (; k < x_incr; k++) {
- dest_ptr[k * buf_col_stride] = src_ptr[k];
- }
- } else if (x_incr >= 8 && buf_col_stride == 8) {
- for (j = 0; j < y_incr; j++) {
- OPJ_UINT32 k;
- for (k = 0; k < (x_incr & ~3U); k += 4) {
- dest_ptr[k * buf_col_stride] = src_ptr[k];
- dest_ptr[(k + 1) * buf_col_stride] = src_ptr[k + 1];
- dest_ptr[(k + 2) * buf_col_stride] = src_ptr[k + 2];
- dest_ptr[(k + 3) * buf_col_stride] = src_ptr[k + 3];
- }
- for (; k < x_incr; k++) {
- dest_ptr[k * buf_col_stride] = src_ptr[k];
- }
- dest_ptr += buf_line_stride;
- src_ptr += block_width;
- }
- } else {
- /* General case */
- for (j = 0; j < y_incr; j++) {
- OPJ_UINT32 k;
- for (k = 0; k < x_incr; k++) {
- dest_ptr[k * buf_col_stride] = src_ptr[k];
- }
- dest_ptr += buf_line_stride;
- src_ptr += block_width;
- }
- }
- }
- }
- } else {
- if (src_block == NULL) {
- src_block = (OPJ_INT32*) opj_calloc(1,
- (size_t) sa->block_width * sa->block_height * sizeof(OPJ_INT32));
- if (src_block == NULL) {
- return OPJ_FALSE;
- }
- sa->data_blocks[block_y * sa->block_count_hor + block_x] = src_block;
- }
-
- if (buf_col_stride == 1) {
- OPJ_INT32* OPJ_RESTRICT dest_ptr = src_block + block_y_offset *
- (OPJ_SIZE_T)block_width + block_x_offset;
- const OPJ_INT32* OPJ_RESTRICT src_ptr = buf + (y - y0) *
- (OPJ_SIZE_T)buf_line_stride + (x - x0) * buf_col_stride;
- if (x_incr == 4) {
- /* Same code as general branch, but the compiler */
- /* can have an efficient memcpy() */
- (void)(x_incr); /* trick to silent cppcheck duplicateBranch warning */
- for (j = 0; j < y_incr; j++) {
- memcpy(dest_ptr, src_ptr, sizeof(OPJ_INT32) * x_incr);
- dest_ptr += block_width;
- src_ptr += buf_line_stride;
- }
- } else {
- for (j = 0; j < y_incr; j++) {
- memcpy(dest_ptr, src_ptr, sizeof(OPJ_INT32) * x_incr);
- dest_ptr += block_width;
- src_ptr += buf_line_stride;
- }
- }
- } else {
- OPJ_INT32* OPJ_RESTRICT dest_ptr = src_block + block_y_offset *
- (OPJ_SIZE_T)block_width + block_x_offset;
- const OPJ_INT32* OPJ_RESTRICT src_ptr = buf + (y - y0) *
- (OPJ_SIZE_T)buf_line_stride + (x - x0) * buf_col_stride;
- if (x_incr == 1) {
- for (j = 0; j < y_incr; j++) {
- *dest_ptr = *src_ptr;
- src_ptr += buf_line_stride;
- dest_ptr += block_width;
- }
- } else if (x_incr >= 8 && buf_col_stride == 8) {
- for (j = 0; j < y_incr; j++) {
- OPJ_UINT32 k;
- for (k = 0; k < (x_incr & ~3U); k += 4) {
- dest_ptr[k] = src_ptr[k * buf_col_stride];
- dest_ptr[k + 1] = src_ptr[(k + 1) * buf_col_stride];
- dest_ptr[k + 2] = src_ptr[(k + 2) * buf_col_stride];
- dest_ptr[k + 3] = src_ptr[(k + 3) * buf_col_stride];
- }
- for (; k < x_incr; k++) {
- dest_ptr[k] = src_ptr[k * buf_col_stride];
- }
- src_ptr += buf_line_stride;
- dest_ptr += block_width;
- }
- } else {
- /* General case */
- for (j = 0; j < y_incr; j++) {
- OPJ_UINT32 k;
- for (k = 0; k < x_incr; k++) {
- dest_ptr[k] = src_ptr[k * buf_col_stride];
- }
- src_ptr += buf_line_stride;
- dest_ptr += block_width;
- }
- }
- }
- }
- }
- }
-
- return OPJ_TRUE;
-}
-
-OPJ_BOOL opj_sparse_array_int32_read(const opj_sparse_array_int32_t* sa,
- OPJ_UINT32 x0,
- OPJ_UINT32 y0,
- OPJ_UINT32 x1,
- OPJ_UINT32 y1,
- OPJ_INT32* dest,
- OPJ_UINT32 dest_col_stride,
- OPJ_UINT32 dest_line_stride,
- OPJ_BOOL forgiving)
-{
- return opj_sparse_array_int32_read_or_write(
- (opj_sparse_array_int32_t*)sa, x0, y0, x1, y1,
- dest,
- dest_col_stride,
- dest_line_stride,
- forgiving,
- OPJ_TRUE);
-}
-
-OPJ_BOOL opj_sparse_array_int32_write(opj_sparse_array_int32_t* sa,
- OPJ_UINT32 x0,
- OPJ_UINT32 y0,
- OPJ_UINT32 x1,
- OPJ_UINT32 y1,
- const OPJ_INT32* src,
- OPJ_UINT32 src_col_stride,
- OPJ_UINT32 src_line_stride,
- OPJ_BOOL forgiving)
-{
- return opj_sparse_array_int32_read_or_write(sa, x0, y0, x1, y1,
- (OPJ_INT32*)src,
- src_col_stride,
- src_line_stride,
- forgiving,
- OPJ_FALSE);
-}
diff --git a/contrib/libs/openjpeg/sparse_array.h b/contrib/libs/openjpeg/sparse_array.h
deleted file mode 100644
index fd927eaa0b..0000000000
--- a/contrib/libs/openjpeg/sparse_array.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2017, IntoPix SA <contact@intopix.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "opj_includes.h"
-
-#ifndef OPJ_SPARSE_ARRAY_H
-#define OPJ_SPARSE_ARRAY_H
-/**
-@file sparse_array.h
-@brief Sparse array management
-
-The functions in this file manage sparse arrays. Sparse arrays are arrays with
-potential big dimensions, but with very few samples actually set. Such sparse
-arrays require allocating a low amount of memory, by just allocating memory
-for blocks of the array that are set. The minimum memory allocation unit is a
-a block. There is a trade-off to pick up an appropriate dimension for blocks.
-If it is too big, and pixels set are far from each other, too much memory will
-be used. If blocks are too small, the book-keeping costs of blocks will raise.
-*/
-
-/** @defgroup SPARSE_ARRAY SPARSE ARRAYS - Sparse arrays */
-/*@{*/
-
-/** Opaque type for sparse arrays that contain int32 values */
-typedef struct opj_sparse_array_int32 opj_sparse_array_int32_t;
-
-/** Creates a new sparse array.
- * @param width total width of the array.
- * @param height total height of the array
- * @param block_width width of a block.
- * @param block_height height of a block.
- * @return a new sparse array instance, or NULL in case of failure.
- */
-opj_sparse_array_int32_t* opj_sparse_array_int32_create(OPJ_UINT32 width,
- OPJ_UINT32 height,
- OPJ_UINT32 block_width,
- OPJ_UINT32 block_height);
-
-/** Frees a sparse array.
- * @param sa sparse array instance.
- */
-void opj_sparse_array_int32_free(opj_sparse_array_int32_t* sa);
-
-/** Returns whether region bounds are valid (non empty and within array bounds)
- * @param sa sparse array instance.
- * @param x0 left x coordinate of the region.
- * @param y0 top x coordinate of the region.
- * @param x1 right x coordinate (not included) of the region. Must be greater than x0.
- * @param y1 bottom y coordinate (not included) of the region. Must be greater than y0.
- * @return OPJ_TRUE or OPJ_FALSE.
- */
-OPJ_BOOL opj_sparse_array_is_region_valid(const opj_sparse_array_int32_t* sa,
- OPJ_UINT32 x0,
- OPJ_UINT32 y0,
- OPJ_UINT32 x1,
- OPJ_UINT32 y1);
-
-/** Read the content of a rectangular region of the sparse array into a
- * user buffer.
- *
- * Regions not written with opj_sparse_array_int32_write() are read as 0.
- *
- * @param sa sparse array instance.
- * @param x0 left x coordinate of the region to read in the sparse array.
- * @param y0 top x coordinate of the region to read in the sparse array.
- * @param x1 right x coordinate (not included) of the region to read in the sparse array. Must be greater than x0.
- * @param y1 bottom y coordinate (not included) of the region to read in the sparse array. Must be greater than y0.
- * @param dest user buffer to fill. Must be at least sizeof(int32) * ( (y1 - y0 - 1) * dest_line_stride + (x1 - x0 - 1) * dest_col_stride + 1) bytes large.
- * @param dest_col_stride spacing (in elements, not in bytes) in x dimension between consecutive elements of the user buffer.
- * @param dest_line_stride spacing (in elements, not in bytes) in y dimension between consecutive elements of the user buffer.
- * @param forgiving if set to TRUE and the region is invalid, OPJ_TRUE will still be returned.
- * @return OPJ_TRUE in case of success.
- */
-OPJ_BOOL opj_sparse_array_int32_read(const opj_sparse_array_int32_t* sa,
- OPJ_UINT32 x0,
- OPJ_UINT32 y0,
- OPJ_UINT32 x1,
- OPJ_UINT32 y1,
- OPJ_INT32* dest,
- OPJ_UINT32 dest_col_stride,
- OPJ_UINT32 dest_line_stride,
- OPJ_BOOL forgiving);
-
-
-/** Write the content of a rectangular region into the sparse array from a
- * user buffer.
- *
- * Blocks intersecting the region are allocated, if not already done.
- *
- * @param sa sparse array instance.
- * @param x0 left x coordinate of the region to write into the sparse array.
- * @param y0 top x coordinate of the region to write into the sparse array.
- * @param x1 right x coordinate (not included) of the region to write into the sparse array. Must be greater than x0.
- * @param y1 bottom y coordinate (not included) of the region to write into the sparse array. Must be greater than y0.
- * @param src user buffer to fill. Must be at least sizeof(int32) * ( (y1 - y0 - 1) * src_line_stride + (x1 - x0 - 1) * src_col_stride + 1) bytes large.
- * @param src_col_stride spacing (in elements, not in bytes) in x dimension between consecutive elements of the user buffer.
- * @param src_line_stride spacing (in elements, not in bytes) in y dimension between consecutive elements of the user buffer.
- * @param forgiving if set to TRUE and the region is invalid, OPJ_TRUE will still be returned.
- * @return OPJ_TRUE in case of success.
- */
-OPJ_BOOL opj_sparse_array_int32_write(opj_sparse_array_int32_t* sa,
- OPJ_UINT32 x0,
- OPJ_UINT32 y0,
- OPJ_UINT32 x1,
- OPJ_UINT32 y1,
- const OPJ_INT32* src,
- OPJ_UINT32 src_col_stride,
- OPJ_UINT32 src_line_stride,
- OPJ_BOOL forgiving);
-
-/*@}*/
-
-#endif /* OPJ_SPARSE_ARRAY_H */
diff --git a/contrib/libs/openjpeg/t1.c b/contrib/libs/openjpeg/t1.c
deleted file mode 100644
index 98dce47f55..0000000000
--- a/contrib/libs/openjpeg/t1.c
+++ /dev/null
@@ -1,2741 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2014, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux
- * Copyright (c) 2003-2014, Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2007, Callum Lerwick <seg@haxxed.com>
- * Copyright (c) 2012, Carl Hetherington
- * Copyright (c) 2017, IntoPIX SA <support@intopix.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#define OPJ_SKIP_POISON
-#include "opj_includes.h"
-
-#ifdef __SSE__
-#include <xmmintrin.h>
-#endif
-#ifdef __SSE2__
-#include <emmintrin.h>
-#endif
-#if (defined(__AVX2__) || defined(__AVX512F__))
-#include <immintrin.h>
-#endif
-
-#if defined(__GNUC__)
-#pragma GCC poison malloc calloc realloc free
-#endif
-
-#include "t1_luts.h"
-
-/** @defgroup T1 T1 - Implementation of the tier-1 coding */
-/*@{*/
-
-#define T1_FLAGS(x, y) (t1->flags[x + 1 + ((y / 4) + 1) * (t1->w+2)])
-
-#define opj_t1_setcurctx(curctx, ctxno) curctx = &(mqc)->ctxs[(OPJ_UINT32)(ctxno)]
-
-/* Macros to deal with signed integer with just MSB bit set for
- * negative values (smr = signed magnitude representation) */
-#define opj_smr_abs(x) (((OPJ_UINT32)(x)) & 0x7FFFFFFFU)
-#define opj_smr_sign(x) (((OPJ_UINT32)(x)) >> 31)
-#define opj_to_smr(x) ((x) >= 0 ? (OPJ_UINT32)(x) : ((OPJ_UINT32)(-x) | 0x80000000U))
-
-
-/** @name Local static functions */
-/*@{*/
-
-static INLINE OPJ_BYTE opj_t1_getctxno_zc(opj_mqc_t *mqc, OPJ_UINT32 f);
-static INLINE OPJ_UINT32 opj_t1_getctxno_mag(OPJ_UINT32 f);
-static OPJ_INT16 opj_t1_getnmsedec_sig(OPJ_UINT32 x, OPJ_UINT32 bitpos);
-static OPJ_INT16 opj_t1_getnmsedec_ref(OPJ_UINT32 x, OPJ_UINT32 bitpos);
-static INLINE void opj_t1_update_flags(opj_flag_t *flagsp, OPJ_UINT32 ci,
- OPJ_UINT32 s, OPJ_UINT32 stride,
- OPJ_UINT32 vsc);
-
-
-/**
-Decode significant pass
-*/
-
-static INLINE void opj_t1_dec_sigpass_step_raw(
- opj_t1_t *t1,
- opj_flag_t *flagsp,
- OPJ_INT32 *datap,
- OPJ_INT32 oneplushalf,
- OPJ_UINT32 vsc,
- OPJ_UINT32 row);
-static INLINE void opj_t1_dec_sigpass_step_mqc(
- opj_t1_t *t1,
- opj_flag_t *flagsp,
- OPJ_INT32 *datap,
- OPJ_INT32 oneplushalf,
- OPJ_UINT32 row,
- OPJ_UINT32 flags_stride,
- OPJ_UINT32 vsc);
-
-/**
-Encode significant pass
-*/
-static void opj_t1_enc_sigpass(opj_t1_t *t1,
- OPJ_INT32 bpno,
- OPJ_INT32 *nmsedec,
- OPJ_BYTE type,
- OPJ_UINT32 cblksty);
-
-/**
-Decode significant pass
-*/
-static void opj_t1_dec_sigpass_raw(
- opj_t1_t *t1,
- OPJ_INT32 bpno,
- OPJ_INT32 cblksty);
-
-/**
-Encode refinement pass
-*/
-static void opj_t1_enc_refpass(opj_t1_t *t1,
- OPJ_INT32 bpno,
- OPJ_INT32 *nmsedec,
- OPJ_BYTE type);
-
-/**
-Decode refinement pass
-*/
-static void opj_t1_dec_refpass_raw(
- opj_t1_t *t1,
- OPJ_INT32 bpno);
-
-
-/**
-Decode refinement pass
-*/
-
-static INLINE void opj_t1_dec_refpass_step_raw(
- opj_t1_t *t1,
- opj_flag_t *flagsp,
- OPJ_INT32 *datap,
- OPJ_INT32 poshalf,
- OPJ_UINT32 row);
-static INLINE void opj_t1_dec_refpass_step_mqc(
- opj_t1_t *t1,
- opj_flag_t *flagsp,
- OPJ_INT32 *datap,
- OPJ_INT32 poshalf,
- OPJ_UINT32 row);
-
-
-/**
-Decode clean-up pass
-*/
-
-static void opj_t1_dec_clnpass_step(
- opj_t1_t *t1,
- opj_flag_t *flagsp,
- OPJ_INT32 *datap,
- OPJ_INT32 oneplushalf,
- OPJ_UINT32 row,
- OPJ_UINT32 vsc);
-
-/**
-Encode clean-up pass
-*/
-static void opj_t1_enc_clnpass(
- opj_t1_t *t1,
- OPJ_INT32 bpno,
- OPJ_INT32 *nmsedec,
- OPJ_UINT32 cblksty);
-
-static OPJ_FLOAT64 opj_t1_getwmsedec(
- OPJ_INT32 nmsedec,
- OPJ_UINT32 compno,
- OPJ_UINT32 level,
- OPJ_UINT32 orient,
- OPJ_INT32 bpno,
- OPJ_UINT32 qmfbid,
- OPJ_FLOAT64 stepsize,
- OPJ_UINT32 numcomps,
- const OPJ_FLOAT64 * mct_norms,
- OPJ_UINT32 mct_numcomps);
-
-/** Return "cumwmsedec" that should be used to increase tile->distotile */
-static double opj_t1_encode_cblk(opj_t1_t *t1,
- opj_tcd_cblk_enc_t* cblk,
- OPJ_UINT32 orient,
- OPJ_UINT32 compno,
- OPJ_UINT32 level,
- OPJ_UINT32 qmfbid,
- OPJ_FLOAT64 stepsize,
- OPJ_UINT32 cblksty,
- OPJ_UINT32 numcomps,
- const OPJ_FLOAT64 * mct_norms,
- OPJ_UINT32 mct_numcomps);
-
-/**
-Decode 1 code-block
-@param t1 T1 handle
-@param cblk Code-block coding parameters
-@param orient
-@param roishift Region of interest shifting value
-@param cblksty Code-block style
-@param p_manager the event manager
-@param p_manager_mutex mutex for the event manager
-@param check_pterm whether PTERM correct termination should be checked
-*/
-static OPJ_BOOL opj_t1_decode_cblk(opj_t1_t *t1,
- opj_tcd_cblk_dec_t* cblk,
- OPJ_UINT32 orient,
- OPJ_UINT32 roishift,
- OPJ_UINT32 cblksty,
- opj_event_mgr_t *p_manager,
- opj_mutex_t* p_manager_mutex,
- OPJ_BOOL check_pterm);
-
-/**
-Decode 1 HT code-block
-@param t1 T1 handle
-@param cblk Code-block coding parameters
-@param orient
-@param roishift Region of interest shifting value
-@param cblksty Code-block style
-@param p_manager the event manager
-@param p_manager_mutex mutex for the event manager
-@param check_pterm whether PTERM correct termination should be checked
-*/
-OPJ_BOOL opj_t1_ht_decode_cblk(opj_t1_t *t1,
- opj_tcd_cblk_dec_t* cblk,
- OPJ_UINT32 orient,
- OPJ_UINT32 roishift,
- OPJ_UINT32 cblksty,
- opj_event_mgr_t *p_manager,
- opj_mutex_t* p_manager_mutex,
- OPJ_BOOL check_pterm);
-
-
-static OPJ_BOOL opj_t1_allocate_buffers(opj_t1_t *t1,
- OPJ_UINT32 w,
- OPJ_UINT32 h);
-
-/*@}*/
-
-/*@}*/
-
-/* ----------------------------------------------------------------------- */
-
-static INLINE OPJ_BYTE opj_t1_getctxno_zc(opj_mqc_t *mqc, OPJ_UINT32 f)
-{
- return mqc->lut_ctxno_zc_orient[(f & T1_SIGMA_NEIGHBOURS)];
-}
-
-static INLINE OPJ_UINT32 opj_t1_getctxtno_sc_or_spb_index(OPJ_UINT32 fX,
- OPJ_UINT32 pfX,
- OPJ_UINT32 nfX,
- OPJ_UINT32 ci)
-{
- /*
- 0 pfX T1_CHI_THIS T1_LUT_SGN_W
- 1 tfX T1_SIGMA_1 T1_LUT_SIG_N
- 2 nfX T1_CHI_THIS T1_LUT_SGN_E
- 3 tfX T1_SIGMA_3 T1_LUT_SIG_W
- 4 fX T1_CHI_(THIS - 1) T1_LUT_SGN_N
- 5 tfX T1_SIGMA_5 T1_LUT_SIG_E
- 6 fX T1_CHI_(THIS + 1) T1_LUT_SGN_S
- 7 tfX T1_SIGMA_7 T1_LUT_SIG_S
- */
-
- OPJ_UINT32 lu = (fX >> (ci * 3U)) & (T1_SIGMA_1 | T1_SIGMA_3 | T1_SIGMA_5 |
- T1_SIGMA_7);
-
- lu |= (pfX >> (T1_CHI_THIS_I + (ci * 3U))) & (1U << 0);
- lu |= (nfX >> (T1_CHI_THIS_I - 2U + (ci * 3U))) & (1U << 2);
- if (ci == 0U) {
- lu |= (fX >> (T1_CHI_0_I - 4U)) & (1U << 4);
- } else {
- lu |= (fX >> (T1_CHI_1_I - 4U + ((ci - 1U) * 3U))) & (1U << 4);
- }
- lu |= (fX >> (T1_CHI_2_I - 6U + (ci * 3U))) & (1U << 6);
- return lu;
-}
-
-static INLINE OPJ_BYTE opj_t1_getctxno_sc(OPJ_UINT32 lu)
-{
- return lut_ctxno_sc[lu];
-}
-
-static INLINE OPJ_UINT32 opj_t1_getctxno_mag(OPJ_UINT32 f)
-{
- OPJ_UINT32 tmp = (f & T1_SIGMA_NEIGHBOURS) ? T1_CTXNO_MAG + 1 : T1_CTXNO_MAG;
- OPJ_UINT32 tmp2 = (f & T1_MU_0) ? T1_CTXNO_MAG + 2 : tmp;
- return tmp2;
-}
-
-static INLINE OPJ_BYTE opj_t1_getspb(OPJ_UINT32 lu)
-{
- return lut_spb[lu];
-}
-
-static OPJ_INT16 opj_t1_getnmsedec_sig(OPJ_UINT32 x, OPJ_UINT32 bitpos)
-{
- if (bitpos > 0) {
- return lut_nmsedec_sig[(x >> (bitpos)) & ((1 << T1_NMSEDEC_BITS) - 1)];
- }
-
- return lut_nmsedec_sig0[x & ((1 << T1_NMSEDEC_BITS) - 1)];
-}
-
-static OPJ_INT16 opj_t1_getnmsedec_ref(OPJ_UINT32 x, OPJ_UINT32 bitpos)
-{
- if (bitpos > 0) {
- return lut_nmsedec_ref[(x >> (bitpos)) & ((1 << T1_NMSEDEC_BITS) - 1)];
- }
-
- return lut_nmsedec_ref0[x & ((1 << T1_NMSEDEC_BITS) - 1)];
-}
-
-#define opj_t1_update_flags_macro(flags, flagsp, ci, s, stride, vsc) \
-{ \
- /* east */ \
- flagsp[-1] |= T1_SIGMA_5 << (3U * ci); \
- \
- /* mark target as significant */ \
- flags |= ((s << T1_CHI_1_I) | T1_SIGMA_4) << (3U * ci); \
- \
- /* west */ \
- flagsp[1] |= T1_SIGMA_3 << (3U * ci); \
- \
- /* north-west, north, north-east */ \
- if (ci == 0U && !(vsc)) { \
- opj_flag_t* north = flagsp - (stride); \
- *north |= (s << T1_CHI_5_I) | T1_SIGMA_16; \
- north[-1] |= T1_SIGMA_17; \
- north[1] |= T1_SIGMA_15; \
- } \
- \
- /* south-west, south, south-east */ \
- if (ci == 3U) { \
- opj_flag_t* south = flagsp + (stride); \
- *south |= (s << T1_CHI_0_I) | T1_SIGMA_1; \
- south[-1] |= T1_SIGMA_2; \
- south[1] |= T1_SIGMA_0; \
- } \
-}
-
-
-static INLINE void opj_t1_update_flags(opj_flag_t *flagsp, OPJ_UINT32 ci,
- OPJ_UINT32 s, OPJ_UINT32 stride,
- OPJ_UINT32 vsc)
-{
- opj_t1_update_flags_macro(*flagsp, flagsp, ci, s, stride, vsc);
-}
-
-/**
-Encode significant pass
-*/
-#define opj_t1_enc_sigpass_step_macro(mqc, curctx, a, c, ct, flagspIn, datapIn, bpno, one, nmsedec, type, ciIn, vscIn) \
-{ \
- OPJ_UINT32 v; \
- const OPJ_UINT32 ci = (ciIn); \
- const OPJ_UINT32 vsc = (vscIn); \
- const OPJ_INT32* l_datap = (datapIn); \
- opj_flag_t* flagsp = (flagspIn); \
- OPJ_UINT32 const flags = *flagsp; \
- if ((flags & ((T1_SIGMA_THIS | T1_PI_THIS) << (ci * 3U))) == 0U && \
- (flags & (T1_SIGMA_NEIGHBOURS << (ci * 3U))) != 0U) { \
- OPJ_UINT32 ctxt1 = opj_t1_getctxno_zc(mqc, flags >> (ci * 3U)); \
- v = (opj_smr_abs(*l_datap) & (OPJ_UINT32)one) ? 1 : 0; \
-/* #ifdef DEBUG_ENC_SIG */ \
-/* fprintf(stderr, " ctxt1=%d\n", ctxt1); */ \
-/* #endif */ \
- opj_t1_setcurctx(curctx, ctxt1); \
- if (type == T1_TYPE_RAW) { /* BYPASS/LAZY MODE */ \
- opj_mqc_bypass_enc_macro(mqc, c, ct, v); \
- } else { \
- opj_mqc_encode_macro(mqc, curctx, a, c, ct, v); \
- } \
- if (v) { \
- OPJ_UINT32 lu = opj_t1_getctxtno_sc_or_spb_index( \
- *flagsp, \
- flagsp[-1], flagsp[1], \
- ci); \
- OPJ_UINT32 ctxt2 = opj_t1_getctxno_sc(lu); \
- v = opj_smr_sign(*l_datap); \
- *nmsedec += opj_t1_getnmsedec_sig(opj_smr_abs(*l_datap), \
- (OPJ_UINT32)bpno); \
-/* #ifdef DEBUG_ENC_SIG */ \
-/* fprintf(stderr, " ctxt2=%d\n", ctxt2); */ \
-/* #endif */ \
- opj_t1_setcurctx(curctx, ctxt2); \
- if (type == T1_TYPE_RAW) { /* BYPASS/LAZY MODE */ \
- opj_mqc_bypass_enc_macro(mqc, c, ct, v); \
- } else { \
- OPJ_UINT32 spb = opj_t1_getspb(lu); \
-/* #ifdef DEBUG_ENC_SIG */ \
-/* fprintf(stderr, " spb=%d\n", spb); */ \
-/* #endif */ \
- opj_mqc_encode_macro(mqc, curctx, a, c, ct, v ^ spb); \
- } \
- opj_t1_update_flags(flagsp, ci, v, t1->w + 2, vsc); \
- } \
- *flagsp |= T1_PI_THIS << (ci * 3U); \
- } \
-}
-
-static INLINE void opj_t1_dec_sigpass_step_raw(
- opj_t1_t *t1,
- opj_flag_t *flagsp,
- OPJ_INT32 *datap,
- OPJ_INT32 oneplushalf,
- OPJ_UINT32 vsc,
- OPJ_UINT32 ci)
-{
- OPJ_UINT32 v;
- opj_mqc_t *mqc = &(t1->mqc); /* RAW component */
-
- OPJ_UINT32 const flags = *flagsp;
-
- if ((flags & ((T1_SIGMA_THIS | T1_PI_THIS) << (ci * 3U))) == 0U &&
- (flags & (T1_SIGMA_NEIGHBOURS << (ci * 3U))) != 0U) {
- if (opj_mqc_raw_decode(mqc)) {
- v = opj_mqc_raw_decode(mqc);
- *datap = v ? -oneplushalf : oneplushalf;
- opj_t1_update_flags(flagsp, ci, v, t1->w + 2, vsc);
- }
- *flagsp |= T1_PI_THIS << (ci * 3U);
- }
-}
-
-#define opj_t1_dec_sigpass_step_mqc_macro(flags, flagsp, flags_stride, data, \
- data_stride, ci, mqc, curctx, \
- v, a, c, ct, oneplushalf, vsc) \
-{ \
- if ((flags & ((T1_SIGMA_THIS | T1_PI_THIS) << (ci * 3U))) == 0U && \
- (flags & (T1_SIGMA_NEIGHBOURS << (ci * 3U))) != 0U) { \
- OPJ_UINT32 ctxt1 = opj_t1_getctxno_zc(mqc, flags >> (ci * 3U)); \
- opj_t1_setcurctx(curctx, ctxt1); \
- opj_mqc_decode_macro(v, mqc, curctx, a, c, ct); \
- if (v) { \
- OPJ_UINT32 lu = opj_t1_getctxtno_sc_or_spb_index( \
- flags, \
- flagsp[-1], flagsp[1], \
- ci); \
- OPJ_UINT32 ctxt2 = opj_t1_getctxno_sc(lu); \
- OPJ_UINT32 spb = opj_t1_getspb(lu); \
- opj_t1_setcurctx(curctx, ctxt2); \
- opj_mqc_decode_macro(v, mqc, curctx, a, c, ct); \
- v = v ^ spb; \
- data[ci*data_stride] = v ? -oneplushalf : oneplushalf; \
- opj_t1_update_flags_macro(flags, flagsp, ci, v, flags_stride, vsc); \
- } \
- flags |= T1_PI_THIS << (ci * 3U); \
- } \
-}
-
-static INLINE void opj_t1_dec_sigpass_step_mqc(
- opj_t1_t *t1,
- opj_flag_t *flagsp,
- OPJ_INT32 *datap,
- OPJ_INT32 oneplushalf,
- OPJ_UINT32 ci,
- OPJ_UINT32 flags_stride,
- OPJ_UINT32 vsc)
-{
- OPJ_UINT32 v;
-
- opj_mqc_t *mqc = &(t1->mqc); /* MQC component */
- opj_t1_dec_sigpass_step_mqc_macro(*flagsp, flagsp, flags_stride, datap,
- 0, ci, mqc, mqc->curctx,
- v, mqc->a, mqc->c, mqc->ct, oneplushalf, vsc);
-}
-
-static void opj_t1_enc_sigpass(opj_t1_t *t1,
- OPJ_INT32 bpno,
- OPJ_INT32 *nmsedec,
- OPJ_BYTE type,
- OPJ_UINT32 cblksty
- )
-{
- OPJ_UINT32 i, k;
- OPJ_INT32 const one = 1 << (bpno + T1_NMSEDEC_FRACBITS);
- opj_flag_t* f = &T1_FLAGS(0, 0);
- OPJ_UINT32 const extra = 2;
- opj_mqc_t* mqc = &(t1->mqc);
- DOWNLOAD_MQC_VARIABLES(mqc, curctx, a, c, ct);
- const OPJ_INT32* datap = t1->data;
-
- *nmsedec = 0;
-#ifdef DEBUG_ENC_SIG
- fprintf(stderr, "enc_sigpass: bpno=%d\n", bpno);
-#endif
- for (k = 0; k < (t1->h & ~3U); k += 4, f += extra) {
- const OPJ_UINT32 w = t1->w;
-#ifdef DEBUG_ENC_SIG
- fprintf(stderr, " k=%d\n", k);
-#endif
- for (i = 0; i < w; ++i, ++f, datap += 4) {
-#ifdef DEBUG_ENC_SIG
- fprintf(stderr, " i=%d\n", i);
-#endif
- if (*f == 0U) {
- /* Nothing to do for any of the 4 data points */
- continue;
- }
- opj_t1_enc_sigpass_step_macro(
- mqc, curctx, a, c, ct,
- f,
- &datap[0],
- bpno,
- one,
- nmsedec,
- type,
- 0, cblksty & J2K_CCP_CBLKSTY_VSC);
- opj_t1_enc_sigpass_step_macro(
- mqc, curctx, a, c, ct,
- f,
- &datap[1],
- bpno,
- one,
- nmsedec,
- type,
- 1, 0);
- opj_t1_enc_sigpass_step_macro(
- mqc, curctx, a, c, ct,
- f,
- &datap[2],
- bpno,
- one,
- nmsedec,
- type,
- 2, 0);
- opj_t1_enc_sigpass_step_macro(
- mqc, curctx, a, c, ct,
- f,
- &datap[3],
- bpno,
- one,
- nmsedec,
- type,
- 3, 0);
- }
- }
-
- if (k < t1->h) {
- OPJ_UINT32 j;
-#ifdef DEBUG_ENC_SIG
- fprintf(stderr, " k=%d\n", k);
-#endif
- for (i = 0; i < t1->w; ++i, ++f) {
-#ifdef DEBUG_ENC_SIG
- fprintf(stderr, " i=%d\n", i);
-#endif
- if (*f == 0U) {
- /* Nothing to do for any of the 4 data points */
- datap += (t1->h - k);
- continue;
- }
- for (j = k; j < t1->h; ++j, ++datap) {
- opj_t1_enc_sigpass_step_macro(
- mqc, curctx, a, c, ct,
- f,
- &datap[0],
- bpno,
- one,
- nmsedec,
- type,
- j - k,
- (j == k && (cblksty & J2K_CCP_CBLKSTY_VSC) != 0));
- }
- }
- }
-
- UPLOAD_MQC_VARIABLES(mqc, curctx, a, c, ct);
-}
-
-static void opj_t1_dec_sigpass_raw(
- opj_t1_t *t1,
- OPJ_INT32 bpno,
- OPJ_INT32 cblksty)
-{
- OPJ_INT32 one, half, oneplushalf;
- OPJ_UINT32 i, j, k;
- OPJ_INT32 *data = t1->data;
- opj_flag_t *flagsp = &T1_FLAGS(0, 0);
- const OPJ_UINT32 l_w = t1->w;
- one = 1 << bpno;
- half = one >> 1;
- oneplushalf = one | half;
-
- for (k = 0; k < (t1->h & ~3U); k += 4, flagsp += 2, data += 3 * l_w) {
- for (i = 0; i < l_w; ++i, ++flagsp, ++data) {
- opj_flag_t flags = *flagsp;
- if (flags != 0) {
- opj_t1_dec_sigpass_step_raw(
- t1,
- flagsp,
- data,
- oneplushalf,
- cblksty & J2K_CCP_CBLKSTY_VSC, /* vsc */
- 0U);
- opj_t1_dec_sigpass_step_raw(
- t1,
- flagsp,
- data + l_w,
- oneplushalf,
- OPJ_FALSE, /* vsc */
- 1U);
- opj_t1_dec_sigpass_step_raw(
- t1,
- flagsp,
- data + 2 * l_w,
- oneplushalf,
- OPJ_FALSE, /* vsc */
- 2U);
- opj_t1_dec_sigpass_step_raw(
- t1,
- flagsp,
- data + 3 * l_w,
- oneplushalf,
- OPJ_FALSE, /* vsc */
- 3U);
- }
- }
- }
- if (k < t1->h) {
- for (i = 0; i < l_w; ++i, ++flagsp, ++data) {
- for (j = 0; j < t1->h - k; ++j) {
- opj_t1_dec_sigpass_step_raw(
- t1,
- flagsp,
- data + j * l_w,
- oneplushalf,
- cblksty & J2K_CCP_CBLKSTY_VSC, /* vsc */
- j);
- }
- }
- }
-}
-
-#define opj_t1_dec_sigpass_mqc_internal(t1, bpno, vsc, w, h, flags_stride) \
-{ \
- OPJ_INT32 one, half, oneplushalf; \
- OPJ_UINT32 i, j, k; \
- register OPJ_INT32 *data = t1->data; \
- register opj_flag_t *flagsp = &t1->flags[(flags_stride) + 1]; \
- const OPJ_UINT32 l_w = w; \
- opj_mqc_t* mqc = &(t1->mqc); \
- DOWNLOAD_MQC_VARIABLES(mqc, curctx, a, c, ct); \
- register OPJ_UINT32 v; \
- one = 1 << bpno; \
- half = one >> 1; \
- oneplushalf = one | half; \
- for (k = 0; k < (h & ~3u); k += 4, data += 3*l_w, flagsp += 2) { \
- for (i = 0; i < l_w; ++i, ++data, ++flagsp) { \
- opj_flag_t flags = *flagsp; \
- if( flags != 0 ) { \
- opj_t1_dec_sigpass_step_mqc_macro( \
- flags, flagsp, flags_stride, data, \
- l_w, 0, mqc, curctx, v, a, c, ct, oneplushalf, vsc); \
- opj_t1_dec_sigpass_step_mqc_macro( \
- flags, flagsp, flags_stride, data, \
- l_w, 1, mqc, curctx, v, a, c, ct, oneplushalf, OPJ_FALSE); \
- opj_t1_dec_sigpass_step_mqc_macro( \
- flags, flagsp, flags_stride, data, \
- l_w, 2, mqc, curctx, v, a, c, ct, oneplushalf, OPJ_FALSE); \
- opj_t1_dec_sigpass_step_mqc_macro( \
- flags, flagsp, flags_stride, data, \
- l_w, 3, mqc, curctx, v, a, c, ct, oneplushalf, OPJ_FALSE); \
- *flagsp = flags; \
- } \
- } \
- } \
- UPLOAD_MQC_VARIABLES(mqc, curctx, a, c, ct); \
- if( k < h ) { \
- for (i = 0; i < l_w; ++i, ++data, ++flagsp) { \
- for (j = 0; j < h - k; ++j) { \
- opj_t1_dec_sigpass_step_mqc(t1, flagsp, \
- data + j * l_w, oneplushalf, j, flags_stride, vsc); \
- } \
- } \
- } \
-}
-
-static void opj_t1_dec_sigpass_mqc_64x64_novsc(
- opj_t1_t *t1,
- OPJ_INT32 bpno)
-{
- opj_t1_dec_sigpass_mqc_internal(t1, bpno, OPJ_FALSE, 64, 64, 66);
-}
-
-static void opj_t1_dec_sigpass_mqc_64x64_vsc(
- opj_t1_t *t1,
- OPJ_INT32 bpno)
-{
- opj_t1_dec_sigpass_mqc_internal(t1, bpno, OPJ_TRUE, 64, 64, 66);
-}
-
-static void opj_t1_dec_sigpass_mqc_generic_novsc(
- opj_t1_t *t1,
- OPJ_INT32 bpno)
-{
- opj_t1_dec_sigpass_mqc_internal(t1, bpno, OPJ_FALSE, t1->w, t1->h,
- t1->w + 2U);
-}
-
-static void opj_t1_dec_sigpass_mqc_generic_vsc(
- opj_t1_t *t1,
- OPJ_INT32 bpno)
-{
- opj_t1_dec_sigpass_mqc_internal(t1, bpno, OPJ_TRUE, t1->w, t1->h,
- t1->w + 2U);
-}
-
-static void opj_t1_dec_sigpass_mqc(
- opj_t1_t *t1,
- OPJ_INT32 bpno,
- OPJ_INT32 cblksty)
-{
- if (t1->w == 64 && t1->h == 64) {
- if (cblksty & J2K_CCP_CBLKSTY_VSC) {
- opj_t1_dec_sigpass_mqc_64x64_vsc(t1, bpno);
- } else {
- opj_t1_dec_sigpass_mqc_64x64_novsc(t1, bpno);
- }
- } else {
- if (cblksty & J2K_CCP_CBLKSTY_VSC) {
- opj_t1_dec_sigpass_mqc_generic_vsc(t1, bpno);
- } else {
- opj_t1_dec_sigpass_mqc_generic_novsc(t1, bpno);
- }
- }
-}
-
-/**
-Encode refinement pass step
-*/
-#define opj_t1_enc_refpass_step_macro(mqc, curctx, a, c, ct, flags, flagsUpdated, datap, bpno, one, nmsedec, type, ci) \
-{\
- OPJ_UINT32 v; \
- if ((flags & ((T1_SIGMA_THIS | T1_PI_THIS) << ((ci) * 3U))) == (T1_SIGMA_THIS << ((ci) * 3U))) { \
- const OPJ_UINT32 shift_flags = (flags >> ((ci) * 3U)); \
- OPJ_UINT32 ctxt = opj_t1_getctxno_mag(shift_flags); \
- OPJ_UINT32 abs_data = opj_smr_abs(*datap); \
- *nmsedec += opj_t1_getnmsedec_ref(abs_data, \
- (OPJ_UINT32)bpno); \
- v = ((OPJ_INT32)abs_data & one) ? 1 : 0; \
-/* #ifdef DEBUG_ENC_REF */ \
-/* fprintf(stderr, " ctxt=%d\n", ctxt); */ \
-/* #endif */ \
- opj_t1_setcurctx(curctx, ctxt); \
- if (type == T1_TYPE_RAW) { /* BYPASS/LAZY MODE */ \
- opj_mqc_bypass_enc_macro(mqc, c, ct, v); \
- } else { \
- opj_mqc_encode_macro(mqc, curctx, a, c, ct, v); \
- } \
- flagsUpdated |= T1_MU_THIS << ((ci) * 3U); \
- } \
-}
-
-
-static INLINE void opj_t1_dec_refpass_step_raw(
- opj_t1_t *t1,
- opj_flag_t *flagsp,
- OPJ_INT32 *datap,
- OPJ_INT32 poshalf,
- OPJ_UINT32 ci)
-{
- OPJ_UINT32 v;
-
- opj_mqc_t *mqc = &(t1->mqc); /* RAW component */
-
- if ((*flagsp & ((T1_SIGMA_THIS | T1_PI_THIS) << (ci * 3U))) ==
- (T1_SIGMA_THIS << (ci * 3U))) {
- v = opj_mqc_raw_decode(mqc);
- *datap += (v ^ (*datap < 0)) ? poshalf : -poshalf;
- *flagsp |= T1_MU_THIS << (ci * 3U);
- }
-}
-
-#define opj_t1_dec_refpass_step_mqc_macro(flags, data, data_stride, ci, \
- mqc, curctx, v, a, c, ct, poshalf) \
-{ \
- if ((flags & ((T1_SIGMA_THIS | T1_PI_THIS) << (ci * 3U))) == \
- (T1_SIGMA_THIS << (ci * 3U))) { \
- OPJ_UINT32 ctxt = opj_t1_getctxno_mag(flags >> (ci * 3U)); \
- opj_t1_setcurctx(curctx, ctxt); \
- opj_mqc_decode_macro(v, mqc, curctx, a, c, ct); \
- data[ci*data_stride] += (v ^ (data[ci*data_stride] < 0)) ? poshalf : -poshalf; \
- flags |= T1_MU_THIS << (ci * 3U); \
- } \
-}
-
-static INLINE void opj_t1_dec_refpass_step_mqc(
- opj_t1_t *t1,
- opj_flag_t *flagsp,
- OPJ_INT32 *datap,
- OPJ_INT32 poshalf,
- OPJ_UINT32 ci)
-{
- OPJ_UINT32 v;
-
- opj_mqc_t *mqc = &(t1->mqc); /* MQC component */
- opj_t1_dec_refpass_step_mqc_macro(*flagsp, datap, 0, ci,
- mqc, mqc->curctx, v, mqc->a, mqc->c,
- mqc->ct, poshalf);
-}
-
-static void opj_t1_enc_refpass(
- opj_t1_t *t1,
- OPJ_INT32 bpno,
- OPJ_INT32 *nmsedec,
- OPJ_BYTE type)
-{
- OPJ_UINT32 i, k;
- const OPJ_INT32 one = 1 << (bpno + T1_NMSEDEC_FRACBITS);
- opj_flag_t* f = &T1_FLAGS(0, 0);
- const OPJ_UINT32 extra = 2U;
- opj_mqc_t* mqc = &(t1->mqc);
- DOWNLOAD_MQC_VARIABLES(mqc, curctx, a, c, ct);
- const OPJ_INT32* datap = t1->data;
-
- *nmsedec = 0;
-#ifdef DEBUG_ENC_REF
- fprintf(stderr, "enc_refpass: bpno=%d\n", bpno);
-#endif
- for (k = 0; k < (t1->h & ~3U); k += 4, f += extra) {
-#ifdef DEBUG_ENC_REF
- fprintf(stderr, " k=%d\n", k);
-#endif
- for (i = 0; i < t1->w; ++i, f++, datap += 4) {
- const OPJ_UINT32 flags = *f;
- OPJ_UINT32 flagsUpdated = flags;
-#ifdef DEBUG_ENC_REF
- fprintf(stderr, " i=%d\n", i);
-#endif
- if ((flags & (T1_SIGMA_4 | T1_SIGMA_7 | T1_SIGMA_10 | T1_SIGMA_13)) == 0) {
- /* none significant */
- continue;
- }
- if ((flags & (T1_PI_0 | T1_PI_1 | T1_PI_2 | T1_PI_3)) ==
- (T1_PI_0 | T1_PI_1 | T1_PI_2 | T1_PI_3)) {
- /* all processed by sigpass */
- continue;
- }
-
- opj_t1_enc_refpass_step_macro(
- mqc, curctx, a, c, ct,
- flags, flagsUpdated,
- &datap[0],
- bpno,
- one,
- nmsedec,
- type,
- 0);
- opj_t1_enc_refpass_step_macro(
- mqc, curctx, a, c, ct,
- flags, flagsUpdated,
- &datap[1],
- bpno,
- one,
- nmsedec,
- type,
- 1);
- opj_t1_enc_refpass_step_macro(
- mqc, curctx, a, c, ct,
- flags, flagsUpdated,
- &datap[2],
- bpno,
- one,
- nmsedec,
- type,
- 2);
- opj_t1_enc_refpass_step_macro(
- mqc, curctx, a, c, ct,
- flags, flagsUpdated,
- &datap[3],
- bpno,
- one,
- nmsedec,
- type,
- 3);
- *f = flagsUpdated;
- }
- }
-
- if (k < t1->h) {
- OPJ_UINT32 j;
- const OPJ_UINT32 remaining_lines = t1->h - k;
-#ifdef DEBUG_ENC_REF
- fprintf(stderr, " k=%d\n", k);
-#endif
- for (i = 0; i < t1->w; ++i, ++f) {
-#ifdef DEBUG_ENC_REF
- fprintf(stderr, " i=%d\n", i);
-#endif
- if ((*f & (T1_SIGMA_4 | T1_SIGMA_7 | T1_SIGMA_10 | T1_SIGMA_13)) == 0) {
- /* none significant */
- datap += remaining_lines;
- continue;
- }
- for (j = 0; j < remaining_lines; ++j, datap ++) {
- opj_t1_enc_refpass_step_macro(
- mqc, curctx, a, c, ct,
- *f, *f,
- &datap[0],
- bpno,
- one,
- nmsedec,
- type,
- j);
- }
- }
- }
-
- UPLOAD_MQC_VARIABLES(mqc, curctx, a, c, ct);
-}
-
-
-static void opj_t1_dec_refpass_raw(
- opj_t1_t *t1,
- OPJ_INT32 bpno)
-{
- OPJ_INT32 one, poshalf;
- OPJ_UINT32 i, j, k;
- OPJ_INT32 *data = t1->data;
- opj_flag_t *flagsp = &T1_FLAGS(0, 0);
- const OPJ_UINT32 l_w = t1->w;
- one = 1 << bpno;
- poshalf = one >> 1;
- for (k = 0; k < (t1->h & ~3U); k += 4, flagsp += 2, data += 3 * l_w) {
- for (i = 0; i < l_w; ++i, ++flagsp, ++data) {
- opj_flag_t flags = *flagsp;
- if (flags != 0) {
- opj_t1_dec_refpass_step_raw(
- t1,
- flagsp,
- data,
- poshalf,
- 0U);
- opj_t1_dec_refpass_step_raw(
- t1,
- flagsp,
- data + l_w,
- poshalf,
- 1U);
- opj_t1_dec_refpass_step_raw(
- t1,
- flagsp,
- data + 2 * l_w,
- poshalf,
- 2U);
- opj_t1_dec_refpass_step_raw(
- t1,
- flagsp,
- data + 3 * l_w,
- poshalf,
- 3U);
- }
- }
- }
- if (k < t1->h) {
- for (i = 0; i < l_w; ++i, ++flagsp, ++data) {
- for (j = 0; j < t1->h - k; ++j) {
- opj_t1_dec_refpass_step_raw(
- t1,
- flagsp,
- data + j * l_w,
- poshalf,
- j);
- }
- }
- }
-}
-
-#define opj_t1_dec_refpass_mqc_internal(t1, bpno, w, h, flags_stride) \
-{ \
- OPJ_INT32 one, poshalf; \
- OPJ_UINT32 i, j, k; \
- register OPJ_INT32 *data = t1->data; \
- register opj_flag_t *flagsp = &t1->flags[flags_stride + 1]; \
- const OPJ_UINT32 l_w = w; \
- opj_mqc_t* mqc = &(t1->mqc); \
- DOWNLOAD_MQC_VARIABLES(mqc, curctx, a, c, ct); \
- register OPJ_UINT32 v; \
- one = 1 << bpno; \
- poshalf = one >> 1; \
- for (k = 0; k < (h & ~3u); k += 4, data += 3*l_w, flagsp += 2) { \
- for (i = 0; i < l_w; ++i, ++data, ++flagsp) { \
- opj_flag_t flags = *flagsp; \
- if( flags != 0 ) { \
- opj_t1_dec_refpass_step_mqc_macro( \
- flags, data, l_w, 0, \
- mqc, curctx, v, a, c, ct, poshalf); \
- opj_t1_dec_refpass_step_mqc_macro( \
- flags, data, l_w, 1, \
- mqc, curctx, v, a, c, ct, poshalf); \
- opj_t1_dec_refpass_step_mqc_macro( \
- flags, data, l_w, 2, \
- mqc, curctx, v, a, c, ct, poshalf); \
- opj_t1_dec_refpass_step_mqc_macro( \
- flags, data, l_w, 3, \
- mqc, curctx, v, a, c, ct, poshalf); \
- *flagsp = flags; \
- } \
- } \
- } \
- UPLOAD_MQC_VARIABLES(mqc, curctx, a, c, ct); \
- if( k < h ) { \
- for (i = 0; i < l_w; ++i, ++data, ++flagsp) { \
- for (j = 0; j < h - k; ++j) { \
- opj_t1_dec_refpass_step_mqc(t1, flagsp, data + j * l_w, poshalf, j); \
- } \
- } \
- } \
-}
-
-static void opj_t1_dec_refpass_mqc_64x64(
- opj_t1_t *t1,
- OPJ_INT32 bpno)
-{
- opj_t1_dec_refpass_mqc_internal(t1, bpno, 64, 64, 66);
-}
-
-static void opj_t1_dec_refpass_mqc_generic(
- opj_t1_t *t1,
- OPJ_INT32 bpno)
-{
- opj_t1_dec_refpass_mqc_internal(t1, bpno, t1->w, t1->h, t1->w + 2U);
-}
-
-static void opj_t1_dec_refpass_mqc(
- opj_t1_t *t1,
- OPJ_INT32 bpno)
-{
- if (t1->w == 64 && t1->h == 64) {
- opj_t1_dec_refpass_mqc_64x64(t1, bpno);
- } else {
- opj_t1_dec_refpass_mqc_generic(t1, bpno);
- }
-}
-
-/**
-Encode clean-up pass step
-*/
-#define opj_t1_enc_clnpass_step_macro(mqc, curctx, a, c, ct, flagspIn, datapIn, bpno, one, nmsedec, agg, runlen, lim, cblksty) \
-{ \
- OPJ_UINT32 v; \
- OPJ_UINT32 ci; \
- opj_flag_t* const flagsp = (flagspIn); \
- const OPJ_INT32* l_datap = (datapIn); \
- const OPJ_UINT32 check = (T1_SIGMA_4 | T1_SIGMA_7 | T1_SIGMA_10 | T1_SIGMA_13 | \
- T1_PI_0 | T1_PI_1 | T1_PI_2 | T1_PI_3); \
- \
- if ((*flagsp & check) == check) { \
- if (runlen == 0) { \
- *flagsp &= ~(T1_PI_0 | T1_PI_1 | T1_PI_2 | T1_PI_3); \
- } else if (runlen == 1) { \
- *flagsp &= ~(T1_PI_1 | T1_PI_2 | T1_PI_3); \
- } else if (runlen == 2) { \
- *flagsp &= ~(T1_PI_2 | T1_PI_3); \
- } else if (runlen == 3) { \
- *flagsp &= ~(T1_PI_3); \
- } \
- } \
- else \
- for (ci = runlen; ci < lim; ++ci) { \
- OPJ_BOOL goto_PARTIAL = OPJ_FALSE; \
- if ((agg != 0) && (ci == runlen)) { \
- goto_PARTIAL = OPJ_TRUE; \
- } \
- else if (!(*flagsp & ((T1_SIGMA_THIS | T1_PI_THIS) << (ci * 3U)))) { \
- OPJ_UINT32 ctxt1 = opj_t1_getctxno_zc(mqc, *flagsp >> (ci * 3U)); \
-/* #ifdef DEBUG_ENC_CLN */ \
-/* printf(" ctxt1=%d\n", ctxt1); */ \
-/* #endif */ \
- opj_t1_setcurctx(curctx, ctxt1); \
- v = (opj_smr_abs(*l_datap) & (OPJ_UINT32)one) ? 1 : 0; \
- opj_mqc_encode_macro(mqc, curctx, a, c, ct, v); \
- if (v) { \
- goto_PARTIAL = OPJ_TRUE; \
- } \
- } \
- if( goto_PARTIAL ) { \
- OPJ_UINT32 vsc; \
- OPJ_UINT32 ctxt2, spb; \
- OPJ_UINT32 lu = opj_t1_getctxtno_sc_or_spb_index( \
- *flagsp, \
- flagsp[-1], flagsp[1], \
- ci); \
- *nmsedec += opj_t1_getnmsedec_sig(opj_smr_abs(*l_datap), \
- (OPJ_UINT32)bpno); \
- ctxt2 = opj_t1_getctxno_sc(lu); \
-/* #ifdef DEBUG_ENC_CLN */ \
-/* printf(" ctxt2=%d\n", ctxt2); */ \
-/* #endif */ \
- opj_t1_setcurctx(curctx, ctxt2); \
- \
- v = opj_smr_sign(*l_datap); \
- spb = opj_t1_getspb(lu); \
-/* #ifdef DEBUG_ENC_CLN */ \
-/* printf(" spb=%d\n", spb); */\
-/* #endif */ \
- opj_mqc_encode_macro(mqc, curctx, a, c, ct, v ^ spb); \
- vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (ci == 0)) ? 1 : 0; \
- opj_t1_update_flags(flagsp, ci, v, t1->w + 2U, vsc); \
- } \
- *flagsp &= ~(T1_PI_THIS << (3U * ci)); \
- l_datap ++; \
- } \
-}
-
-#define opj_t1_dec_clnpass_step_macro(check_flags, partial, \
- flags, flagsp, flags_stride, data, \
- data_stride, ci, mqc, curctx, \
- v, a, c, ct, oneplushalf, vsc) \
-{ \
- if ( !check_flags || !(flags & ((T1_SIGMA_THIS | T1_PI_THIS) << (ci * 3U)))) {\
- do { \
- if( !partial ) { \
- OPJ_UINT32 ctxt1 = opj_t1_getctxno_zc(mqc, flags >> (ci * 3U)); \
- opj_t1_setcurctx(curctx, ctxt1); \
- opj_mqc_decode_macro(v, mqc, curctx, a, c, ct); \
- if( !v ) \
- break; \
- } \
- { \
- OPJ_UINT32 lu = opj_t1_getctxtno_sc_or_spb_index( \
- flags, flagsp[-1], flagsp[1], \
- ci); \
- opj_t1_setcurctx(curctx, opj_t1_getctxno_sc(lu)); \
- opj_mqc_decode_macro(v, mqc, curctx, a, c, ct); \
- v = v ^ opj_t1_getspb(lu); \
- data[ci*data_stride] = v ? -oneplushalf : oneplushalf; \
- opj_t1_update_flags_macro(flags, flagsp, ci, v, flags_stride, vsc); \
- } \
- } while(0); \
- } \
-}
-
-static void opj_t1_dec_clnpass_step(
- opj_t1_t *t1,
- opj_flag_t *flagsp,
- OPJ_INT32 *datap,
- OPJ_INT32 oneplushalf,
- OPJ_UINT32 ci,
- OPJ_UINT32 vsc)
-{
- OPJ_UINT32 v;
-
- opj_mqc_t *mqc = &(t1->mqc); /* MQC component */
- opj_t1_dec_clnpass_step_macro(OPJ_TRUE, OPJ_FALSE,
- *flagsp, flagsp, t1->w + 2U, datap,
- 0, ci, mqc, mqc->curctx,
- v, mqc->a, mqc->c, mqc->ct, oneplushalf, vsc);
-}
-
-static void opj_t1_enc_clnpass(
- opj_t1_t *t1,
- OPJ_INT32 bpno,
- OPJ_INT32 *nmsedec,
- OPJ_UINT32 cblksty)
-{
- OPJ_UINT32 i, k;
- const OPJ_INT32 one = 1 << (bpno + T1_NMSEDEC_FRACBITS);
- opj_mqc_t* mqc = &(t1->mqc);
- DOWNLOAD_MQC_VARIABLES(mqc, curctx, a, c, ct);
- const OPJ_INT32* datap = t1->data;
- opj_flag_t *f = &T1_FLAGS(0, 0);
- const OPJ_UINT32 extra = 2U;
-
- *nmsedec = 0;
-#ifdef DEBUG_ENC_CLN
- printf("enc_clnpass: bpno=%d\n", bpno);
-#endif
- for (k = 0; k < (t1->h & ~3U); k += 4, f += extra) {
-#ifdef DEBUG_ENC_CLN
- printf(" k=%d\n", k);
-#endif
- for (i = 0; i < t1->w; ++i, f++) {
- OPJ_UINT32 agg, runlen;
-#ifdef DEBUG_ENC_CLN
- printf(" i=%d\n", i);
-#endif
- agg = !*f;
-#ifdef DEBUG_ENC_CLN
- printf(" agg=%d\n", agg);
-#endif
- if (agg) {
- for (runlen = 0; runlen < 4; ++runlen, ++datap) {
- if (opj_smr_abs(*datap) & (OPJ_UINT32)one) {
- break;
- }
- }
- opj_t1_setcurctx(curctx, T1_CTXNO_AGG);
- opj_mqc_encode_macro(mqc, curctx, a, c, ct, runlen != 4);
- if (runlen == 4) {
- continue;
- }
- opj_t1_setcurctx(curctx, T1_CTXNO_UNI);
- opj_mqc_encode_macro(mqc, curctx, a, c, ct, runlen >> 1);
- opj_mqc_encode_macro(mqc, curctx, a, c, ct, runlen & 1);
- } else {
- runlen = 0;
- }
- opj_t1_enc_clnpass_step_macro(
- mqc, curctx, a, c, ct,
- f,
- datap,
- bpno,
- one,
- nmsedec,
- agg,
- runlen,
- 4U,
- cblksty);
- datap += 4 - runlen;
- }
- }
- if (k < t1->h) {
- const OPJ_UINT32 agg = 0;
- const OPJ_UINT32 runlen = 0;
-#ifdef DEBUG_ENC_CLN
- printf(" k=%d\n", k);
-#endif
- for (i = 0; i < t1->w; ++i, f++) {
-#ifdef DEBUG_ENC_CLN
- printf(" i=%d\n", i);
- printf(" agg=%d\n", agg);
-#endif
- opj_t1_enc_clnpass_step_macro(
- mqc, curctx, a, c, ct,
- f,
- datap,
- bpno,
- one,
- nmsedec,
- agg,
- runlen,
- t1->h - k,
- cblksty);
- datap += t1->h - k;
- }
- }
-
- UPLOAD_MQC_VARIABLES(mqc, curctx, a, c, ct);
-}
-
-#define opj_t1_dec_clnpass_internal(t1, bpno, vsc, w, h, flags_stride) \
-{ \
- OPJ_INT32 one, half, oneplushalf; \
- OPJ_UINT32 runlen; \
- OPJ_UINT32 i, j, k; \
- const OPJ_UINT32 l_w = w; \
- opj_mqc_t* mqc = &(t1->mqc); \
- register OPJ_INT32 *data = t1->data; \
- register opj_flag_t *flagsp = &t1->flags[flags_stride + 1]; \
- DOWNLOAD_MQC_VARIABLES(mqc, curctx, a, c, ct); \
- register OPJ_UINT32 v; \
- one = 1 << bpno; \
- half = one >> 1; \
- oneplushalf = one | half; \
- for (k = 0; k < (h & ~3u); k += 4, data += 3*l_w, flagsp += 2) { \
- for (i = 0; i < l_w; ++i, ++data, ++flagsp) { \
- opj_flag_t flags = *flagsp; \
- if (flags == 0) { \
- OPJ_UINT32 partial = OPJ_TRUE; \
- opj_t1_setcurctx(curctx, T1_CTXNO_AGG); \
- opj_mqc_decode_macro(v, mqc, curctx, a, c, ct); \
- if (!v) { \
- continue; \
- } \
- opj_t1_setcurctx(curctx, T1_CTXNO_UNI); \
- opj_mqc_decode_macro(runlen, mqc, curctx, a, c, ct); \
- opj_mqc_decode_macro(v, mqc, curctx, a, c, ct); \
- runlen = (runlen << 1) | v; \
- switch(runlen) { \
- case 0: \
- opj_t1_dec_clnpass_step_macro(OPJ_FALSE, OPJ_TRUE,\
- flags, flagsp, flags_stride, data, \
- l_w, 0, mqc, curctx, \
- v, a, c, ct, oneplushalf, vsc); \
- partial = OPJ_FALSE; \
- /* FALLTHRU */ \
- case 1: \
- opj_t1_dec_clnpass_step_macro(OPJ_FALSE, partial,\
- flags, flagsp, flags_stride, data, \
- l_w, 1, mqc, curctx, \
- v, a, c, ct, oneplushalf, OPJ_FALSE); \
- partial = OPJ_FALSE; \
- /* FALLTHRU */ \
- case 2: \
- opj_t1_dec_clnpass_step_macro(OPJ_FALSE, partial,\
- flags, flagsp, flags_stride, data, \
- l_w, 2, mqc, curctx, \
- v, a, c, ct, oneplushalf, OPJ_FALSE); \
- partial = OPJ_FALSE; \
- /* FALLTHRU */ \
- case 3: \
- opj_t1_dec_clnpass_step_macro(OPJ_FALSE, partial,\
- flags, flagsp, flags_stride, data, \
- l_w, 3, mqc, curctx, \
- v, a, c, ct, oneplushalf, OPJ_FALSE); \
- break; \
- } \
- } else { \
- opj_t1_dec_clnpass_step_macro(OPJ_TRUE, OPJ_FALSE, \
- flags, flagsp, flags_stride, data, \
- l_w, 0, mqc, curctx, \
- v, a, c, ct, oneplushalf, vsc); \
- opj_t1_dec_clnpass_step_macro(OPJ_TRUE, OPJ_FALSE, \
- flags, flagsp, flags_stride, data, \
- l_w, 1, mqc, curctx, \
- v, a, c, ct, oneplushalf, OPJ_FALSE); \
- opj_t1_dec_clnpass_step_macro(OPJ_TRUE, OPJ_FALSE, \
- flags, flagsp, flags_stride, data, \
- l_w, 2, mqc, curctx, \
- v, a, c, ct, oneplushalf, OPJ_FALSE); \
- opj_t1_dec_clnpass_step_macro(OPJ_TRUE, OPJ_FALSE, \
- flags, flagsp, flags_stride, data, \
- l_w, 3, mqc, curctx, \
- v, a, c, ct, oneplushalf, OPJ_FALSE); \
- } \
- *flagsp = flags & ~(T1_PI_0 | T1_PI_1 | T1_PI_2 | T1_PI_3); \
- } \
- } \
- UPLOAD_MQC_VARIABLES(mqc, curctx, a, c, ct); \
- if( k < h ) { \
- for (i = 0; i < l_w; ++i, ++flagsp, ++data) { \
- for (j = 0; j < h - k; ++j) { \
- opj_t1_dec_clnpass_step(t1, flagsp, data + j * l_w, oneplushalf, j, vsc); \
- } \
- *flagsp &= ~(T1_PI_0 | T1_PI_1 | T1_PI_2 | T1_PI_3); \
- } \
- } \
-}
-
-static void opj_t1_dec_clnpass_check_segsym(opj_t1_t *t1, OPJ_INT32 cblksty)
-{
- if (cblksty & J2K_CCP_CBLKSTY_SEGSYM) {
- opj_mqc_t* mqc = &(t1->mqc);
- OPJ_UINT32 v, v2;
- opj_mqc_setcurctx(mqc, T1_CTXNO_UNI);
- opj_mqc_decode(v, mqc);
- opj_mqc_decode(v2, mqc);
- v = (v << 1) | v2;
- opj_mqc_decode(v2, mqc);
- v = (v << 1) | v2;
- opj_mqc_decode(v2, mqc);
- v = (v << 1) | v2;
- /*
- if (v!=0xa) {
- opj_event_msg(t1->cinfo, EVT_WARNING, "Bad segmentation symbol %x\n", v);
- }
- */
- }
-}
-
-static void opj_t1_dec_clnpass_64x64_novsc(
- opj_t1_t *t1,
- OPJ_INT32 bpno)
-{
- opj_t1_dec_clnpass_internal(t1, bpno, OPJ_FALSE, 64, 64, 66);
-}
-
-static void opj_t1_dec_clnpass_64x64_vsc(
- opj_t1_t *t1,
- OPJ_INT32 bpno)
-{
- opj_t1_dec_clnpass_internal(t1, bpno, OPJ_TRUE, 64, 64, 66);
-}
-
-static void opj_t1_dec_clnpass_generic_novsc(
- opj_t1_t *t1,
- OPJ_INT32 bpno)
-{
- opj_t1_dec_clnpass_internal(t1, bpno, OPJ_FALSE, t1->w, t1->h,
- t1->w + 2U);
-}
-
-static void opj_t1_dec_clnpass_generic_vsc(
- opj_t1_t *t1,
- OPJ_INT32 bpno)
-{
- opj_t1_dec_clnpass_internal(t1, bpno, OPJ_TRUE, t1->w, t1->h,
- t1->w + 2U);
-}
-
-static void opj_t1_dec_clnpass(
- opj_t1_t *t1,
- OPJ_INT32 bpno,
- OPJ_INT32 cblksty)
-{
- if (t1->w == 64 && t1->h == 64) {
- if (cblksty & J2K_CCP_CBLKSTY_VSC) {
- opj_t1_dec_clnpass_64x64_vsc(t1, bpno);
- } else {
- opj_t1_dec_clnpass_64x64_novsc(t1, bpno);
- }
- } else {
- if (cblksty & J2K_CCP_CBLKSTY_VSC) {
- opj_t1_dec_clnpass_generic_vsc(t1, bpno);
- } else {
- opj_t1_dec_clnpass_generic_novsc(t1, bpno);
- }
- }
- opj_t1_dec_clnpass_check_segsym(t1, cblksty);
-}
-
-
-static OPJ_FLOAT64 opj_t1_getwmsedec(
- OPJ_INT32 nmsedec,
- OPJ_UINT32 compno,
- OPJ_UINT32 level,
- OPJ_UINT32 orient,
- OPJ_INT32 bpno,
- OPJ_UINT32 qmfbid,
- OPJ_FLOAT64 stepsize,
- OPJ_UINT32 numcomps,
- const OPJ_FLOAT64 * mct_norms,
- OPJ_UINT32 mct_numcomps)
-{
- OPJ_FLOAT64 w1 = 1, w2, wmsedec;
- OPJ_ARG_NOT_USED(numcomps);
-
- if (mct_norms && (compno < mct_numcomps)) {
- w1 = mct_norms[compno];
- }
-
- if (qmfbid == 1) {
- w2 = opj_dwt_getnorm(level, orient);
- } else { /* if (qmfbid == 0) */
- const OPJ_INT32 log2_gain = (orient == 0) ? 0 :
- (orient == 3) ? 2 : 1;
- w2 = opj_dwt_getnorm_real(level, orient);
- /* Not sure this is right. But preserves past behaviour */
- stepsize /= (1 << log2_gain);
- }
-
- wmsedec = w1 * w2 * stepsize * (1 << bpno);
- wmsedec *= wmsedec * nmsedec / 8192.0;
-
- return wmsedec;
-}
-
-static OPJ_BOOL opj_t1_allocate_buffers(
- opj_t1_t *t1,
- OPJ_UINT32 w,
- OPJ_UINT32 h)
-{
- OPJ_UINT32 flagssize;
- OPJ_UINT32 flags_stride;
-
- /* No risk of overflow. Prior checks ensure those assert are met */
- /* They are per the specification */
- assert(w <= 1024);
- assert(h <= 1024);
- assert(w * h <= 4096);
-
- /* encoder uses tile buffer, so no need to allocate */
- {
- OPJ_UINT32 datasize = w * h;
-
- if (datasize > t1->datasize) {
- opj_aligned_free(t1->data);
- t1->data = (OPJ_INT32*) opj_aligned_malloc(datasize * sizeof(OPJ_INT32));
- if (!t1->data) {
- /* FIXME event manager error callback */
- return OPJ_FALSE;
- }
- t1->datasize = datasize;
- }
- /* memset first arg is declared to never be null by gcc */
- if (t1->data != NULL) {
- memset(t1->data, 0, datasize * sizeof(OPJ_INT32));
- }
- }
-
- flags_stride = w + 2U; /* can't be 0U */
-
- flagssize = (h + 3U) / 4U + 2U;
-
- flagssize *= flags_stride;
- {
- opj_flag_t* p;
- OPJ_UINT32 x;
- OPJ_UINT32 flags_height = (h + 3U) / 4U;
-
- if (flagssize > t1->flagssize) {
-
- opj_aligned_free(t1->flags);
- t1->flags = (opj_flag_t*) opj_aligned_malloc(flagssize * sizeof(
- opj_flag_t));
- if (!t1->flags) {
- /* FIXME event manager error callback */
- return OPJ_FALSE;
- }
- }
- t1->flagssize = flagssize;
-
- memset(t1->flags, 0, flagssize * sizeof(opj_flag_t));
-
- p = &t1->flags[0];
- for (x = 0; x < flags_stride; ++x) {
- /* magic value to hopefully stop any passes being interested in this entry */
- *p++ = (T1_PI_0 | T1_PI_1 | T1_PI_2 | T1_PI_3);
- }
-
- p = &t1->flags[((flags_height + 1) * flags_stride)];
- for (x = 0; x < flags_stride; ++x) {
- /* magic value to hopefully stop any passes being interested in this entry */
- *p++ = (T1_PI_0 | T1_PI_1 | T1_PI_2 | T1_PI_3);
- }
-
- if (h % 4) {
- OPJ_UINT32 v = 0;
- p = &t1->flags[((flags_height) * flags_stride)];
- if (h % 4 == 1) {
- v |= T1_PI_1 | T1_PI_2 | T1_PI_3;
- } else if (h % 4 == 2) {
- v |= T1_PI_2 | T1_PI_3;
- } else if (h % 4 == 3) {
- v |= T1_PI_3;
- }
- for (x = 0; x < flags_stride; ++x) {
- *p++ = v;
- }
- }
- }
-
- t1->w = w;
- t1->h = h;
-
- return OPJ_TRUE;
-}
-
-/* ----------------------------------------------------------------------- */
-
-/* ----------------------------------------------------------------------- */
-/**
- * Creates a new Tier 1 handle
- * and initializes the look-up tables of the Tier-1 coder/decoder
- * @return a new T1 handle if successful, returns NULL otherwise
-*/
-opj_t1_t* opj_t1_create(OPJ_BOOL isEncoder)
-{
- opj_t1_t *l_t1 = 00;
-
- l_t1 = (opj_t1_t*) opj_calloc(1, sizeof(opj_t1_t));
- if (!l_t1) {
- return 00;
- }
-
- l_t1->encoder = isEncoder;
-
- return l_t1;
-}
-
-
-/**
- * Destroys a previously created T1 handle
- *
- * @param p_t1 Tier 1 handle to destroy
-*/
-void opj_t1_destroy(opj_t1_t *p_t1)
-{
- if (! p_t1) {
- return;
- }
-
- if (p_t1->data) {
- opj_aligned_free(p_t1->data);
- p_t1->data = 00;
- }
-
- if (p_t1->flags) {
- opj_aligned_free(p_t1->flags);
- p_t1->flags = 00;
- }
-
- opj_free(p_t1->cblkdatabuffer);
-
- opj_free(p_t1);
-}
-
-typedef struct {
- OPJ_BOOL whole_tile_decoding;
- OPJ_UINT32 resno;
- opj_tcd_cblk_dec_t* cblk;
- opj_tcd_band_t* band;
- opj_tcd_tilecomp_t* tilec;
- opj_tccp_t* tccp;
- OPJ_BOOL mustuse_cblkdatabuffer;
- volatile OPJ_BOOL* pret;
- opj_event_mgr_t *p_manager;
- opj_mutex_t* p_manager_mutex;
- OPJ_BOOL check_pterm;
-} opj_t1_cblk_decode_processing_job_t;
-
-static void opj_t1_destroy_wrapper(void* t1)
-{
- opj_t1_destroy((opj_t1_t*) t1);
-}
-
-static void opj_t1_clbl_decode_processor(void* user_data, opj_tls_t* tls)
-{
- opj_tcd_cblk_dec_t* cblk;
- opj_tcd_band_t* band;
- opj_tcd_tilecomp_t* tilec;
- opj_tccp_t* tccp;
- OPJ_INT32* OPJ_RESTRICT datap;
- OPJ_UINT32 cblk_w, cblk_h;
- OPJ_INT32 x, y;
- OPJ_UINT32 i, j;
- opj_t1_cblk_decode_processing_job_t* job;
- opj_t1_t* t1;
- OPJ_UINT32 resno;
- OPJ_UINT32 tile_w;
-
- job = (opj_t1_cblk_decode_processing_job_t*) user_data;
-
- cblk = job->cblk;
-
- if (!job->whole_tile_decoding) {
- cblk_w = (OPJ_UINT32)(cblk->x1 - cblk->x0);
- cblk_h = (OPJ_UINT32)(cblk->y1 - cblk->y0);
-
- cblk->decoded_data = (OPJ_INT32*)opj_aligned_malloc(sizeof(OPJ_INT32) *
- cblk_w * cblk_h);
- if (cblk->decoded_data == NULL) {
- if (job->p_manager_mutex) {
- opj_mutex_lock(job->p_manager_mutex);
- }
- opj_event_msg(job->p_manager, EVT_ERROR,
- "Cannot allocate cblk->decoded_data\n");
- if (job->p_manager_mutex) {
- opj_mutex_unlock(job->p_manager_mutex);
- }
- *(job->pret) = OPJ_FALSE;
- opj_free(job);
- return;
- }
- /* Zero-init required */
- memset(cblk->decoded_data, 0, sizeof(OPJ_INT32) * cblk_w * cblk_h);
- } else if (cblk->decoded_data) {
- /* Not sure if that code path can happen, but better be */
- /* safe than sorry */
- opj_aligned_free(cblk->decoded_data);
- cblk->decoded_data = NULL;
- }
-
- resno = job->resno;
- band = job->band;
- tilec = job->tilec;
- tccp = job->tccp;
- tile_w = (OPJ_UINT32)(tilec->resolutions[tilec->minimum_num_resolutions - 1].x1
- -
- tilec->resolutions[tilec->minimum_num_resolutions - 1].x0);
-
- if (!*(job->pret)) {
- opj_free(job);
- return;
- }
-
- t1 = (opj_t1_t*) opj_tls_get(tls, OPJ_TLS_KEY_T1);
- if (t1 == NULL) {
- t1 = opj_t1_create(OPJ_FALSE);
- if (t1 == NULL) {
- opj_event_msg(job->p_manager, EVT_ERROR,
- "Cannot allocate Tier 1 handle\n");
- *(job->pret) = OPJ_FALSE;
- opj_free(job);
- return;
- }
- if (!opj_tls_set(tls, OPJ_TLS_KEY_T1, t1, opj_t1_destroy_wrapper)) {
- opj_event_msg(job->p_manager, EVT_ERROR,
- "Unable to set t1 handle as TLS\n");
- opj_t1_destroy(t1);
- *(job->pret) = OPJ_FALSE;
- opj_free(job);
- return;
- }
- }
- t1->mustuse_cblkdatabuffer = job->mustuse_cblkdatabuffer;
-
- if ((tccp->cblksty & J2K_CCP_CBLKSTY_HT) != 0) {
- if (OPJ_FALSE == opj_t1_ht_decode_cblk(
- t1,
- cblk,
- band->bandno,
- (OPJ_UINT32)tccp->roishift,
- tccp->cblksty,
- job->p_manager,
- job->p_manager_mutex,
- job->check_pterm)) {
- *(job->pret) = OPJ_FALSE;
- opj_free(job);
- return;
- }
- } else {
- if (OPJ_FALSE == opj_t1_decode_cblk(
- t1,
- cblk,
- band->bandno,
- (OPJ_UINT32)tccp->roishift,
- tccp->cblksty,
- job->p_manager,
- job->p_manager_mutex,
- job->check_pterm)) {
- *(job->pret) = OPJ_FALSE;
- opj_free(job);
- return;
- }
- }
-
- x = cblk->x0 - band->x0;
- y = cblk->y0 - band->y0;
- if (band->bandno & 1) {
- opj_tcd_resolution_t* pres = &tilec->resolutions[resno - 1];
- x += pres->x1 - pres->x0;
- }
- if (band->bandno & 2) {
- opj_tcd_resolution_t* pres = &tilec->resolutions[resno - 1];
- y += pres->y1 - pres->y0;
- }
-
- datap = cblk->decoded_data ? cblk->decoded_data : t1->data;
- cblk_w = t1->w;
- cblk_h = t1->h;
-
- if (tccp->roishift) {
- if (tccp->roishift >= 31) {
- for (j = 0; j < cblk_h; ++j) {
- for (i = 0; i < cblk_w; ++i) {
- datap[(j * cblk_w) + i] = 0;
- }
- }
- } else {
- OPJ_INT32 thresh = 1 << tccp->roishift;
- for (j = 0; j < cblk_h; ++j) {
- for (i = 0; i < cblk_w; ++i) {
- OPJ_INT32 val = datap[(j * cblk_w) + i];
- OPJ_INT32 mag = abs(val);
- if (mag >= thresh) {
- mag >>= tccp->roishift;
- datap[(j * cblk_w) + i] = val < 0 ? -mag : mag;
- }
- }
- }
- }
- }
-
- /* Both can be non NULL if for example decoding a full tile and then */
- /* partially a tile. In which case partial decoding should be the */
- /* priority */
- assert((cblk->decoded_data != NULL) || (tilec->data != NULL));
-
- if (cblk->decoded_data) {
- OPJ_UINT32 cblk_size = cblk_w * cblk_h;
- if (tccp->qmfbid == 1) {
- for (i = 0; i < cblk_size; ++i) {
- datap[i] /= 2;
- }
- } else { /* if (tccp->qmfbid == 0) */
- const float stepsize = 0.5f * band->stepsize;
- i = 0;
-#ifdef __SSE2__
- {
- const __m128 xmm_stepsize = _mm_set1_ps(stepsize);
- for (; i < (cblk_size & ~15U); i += 16) {
- __m128 xmm0_data = _mm_cvtepi32_ps(_mm_load_si128((__m128i * const)(
- datap + 0)));
- __m128 xmm1_data = _mm_cvtepi32_ps(_mm_load_si128((__m128i * const)(
- datap + 4)));
- __m128 xmm2_data = _mm_cvtepi32_ps(_mm_load_si128((__m128i * const)(
- datap + 8)));
- __m128 xmm3_data = _mm_cvtepi32_ps(_mm_load_si128((__m128i * const)(
- datap + 12)));
- _mm_store_ps((float*)(datap + 0), _mm_mul_ps(xmm0_data, xmm_stepsize));
- _mm_store_ps((float*)(datap + 4), _mm_mul_ps(xmm1_data, xmm_stepsize));
- _mm_store_ps((float*)(datap + 8), _mm_mul_ps(xmm2_data, xmm_stepsize));
- _mm_store_ps((float*)(datap + 12), _mm_mul_ps(xmm3_data, xmm_stepsize));
- datap += 16;
- }
- }
-#endif
- for (; i < cblk_size; ++i) {
- OPJ_FLOAT32 tmp = ((OPJ_FLOAT32)(*datap)) * stepsize;
- memcpy(datap, &tmp, sizeof(tmp));
- datap++;
- }
- }
- } else if (tccp->qmfbid == 1) {
- OPJ_INT32* OPJ_RESTRICT tiledp = &tilec->data[(OPJ_SIZE_T)y * tile_w +
- (OPJ_SIZE_T)x];
- for (j = 0; j < cblk_h; ++j) {
- //positive -> round down aka. (83)/2 = 41.5 -> 41
- //negative -> round up aka. (-83)/2 = -41.5 -> -41
-#if defined(__AVX512F__)
- OPJ_INT32* ptr_in = datap + (j * cblk_w);
- OPJ_INT32* ptr_out = tiledp + (j * (OPJ_SIZE_T)tile_w);
- for (i = 0; i < cblk_w / 16; ++i) {
- __m512i in_avx = _mm512_loadu_si512((__m512i*)(ptr_in));
- const __m512i add_avx = _mm512_srli_epi32(in_avx, 31);
- in_avx = _mm512_add_epi32(in_avx, add_avx);
- _mm512_storeu_si512((__m512i*)(ptr_out), _mm512_srai_epi32(in_avx, 1));
- ptr_in += 16;
- ptr_out += 16;
- }
-
- for (i = 0; i < cblk_w % 16; ++i) {
- ptr_out[i] = ptr_in[i] / 2;
- }
-#elif defined(__AVX2__)
- OPJ_INT32* ptr_in = datap + (j * cblk_w);
- OPJ_INT32* ptr_out = tiledp + (j * (OPJ_SIZE_T)tile_w);
- for (i = 0; i < cblk_w / 8; ++i) {
- __m256i in_avx = _mm256_loadu_si256((__m256i*)(ptr_in));
- const __m256i add_avx = _mm256_srli_epi32(in_avx, 31);
- in_avx = _mm256_add_epi32(in_avx, add_avx);
- _mm256_storeu_si256((__m256i*)(ptr_out), _mm256_srai_epi32(in_avx, 1));
- ptr_in += 8;
- ptr_out += 8;
- }
-
- for (i = 0; i < cblk_w % 8; ++i) {
- ptr_out[i] = ptr_in[i] / 2;
- }
-#else
- i = 0;
- for (; i < (cblk_w & ~(OPJ_UINT32)3U); i += 4U) {
- OPJ_INT32 tmp0 = datap[(j * cblk_w) + i + 0U];
- OPJ_INT32 tmp1 = datap[(j * cblk_w) + i + 1U];
- OPJ_INT32 tmp2 = datap[(j * cblk_w) + i + 2U];
- OPJ_INT32 tmp3 = datap[(j * cblk_w) + i + 3U];
- ((OPJ_INT32*)tiledp)[(j * (OPJ_SIZE_T)tile_w) + i + 0U] = tmp0 / 2;
- ((OPJ_INT32*)tiledp)[(j * (OPJ_SIZE_T)tile_w) + i + 1U] = tmp1 / 2;
- ((OPJ_INT32*)tiledp)[(j * (OPJ_SIZE_T)tile_w) + i + 2U] = tmp2 / 2;
- ((OPJ_INT32*)tiledp)[(j * (OPJ_SIZE_T)tile_w) + i + 3U] = tmp3 / 2;
- }
- for (; i < cblk_w; ++i) {
- OPJ_INT32 tmp = datap[(j * cblk_w) + i];
- ((OPJ_INT32*)tiledp)[(j * (OPJ_SIZE_T)tile_w) + i] = tmp / 2;
- }
-#endif
- }
- } else { /* if (tccp->qmfbid == 0) */
- const float stepsize = 0.5f * band->stepsize;
- OPJ_FLOAT32* OPJ_RESTRICT tiledp = (OPJ_FLOAT32*) &tilec->data[(OPJ_SIZE_T)y *
- tile_w + (OPJ_SIZE_T)x];
- for (j = 0; j < cblk_h; ++j) {
- OPJ_FLOAT32* OPJ_RESTRICT tiledp2 = tiledp;
- for (i = 0; i < cblk_w; ++i) {
- OPJ_FLOAT32 tmp = (OPJ_FLOAT32) * datap * stepsize;
- *tiledp2 = tmp;
- datap++;
- tiledp2++;
- }
- tiledp += tile_w;
- }
- }
-
- opj_free(job);
-}
-
-
-void opj_t1_decode_cblks(opj_tcd_t* tcd,
- volatile OPJ_BOOL* pret,
- opj_tcd_tilecomp_t* tilec,
- opj_tccp_t* tccp,
- opj_event_mgr_t *p_manager,
- opj_mutex_t* p_manager_mutex,
- OPJ_BOOL check_pterm
- )
-{
- opj_thread_pool_t* tp = tcd->thread_pool;
- OPJ_UINT32 resno, bandno, precno, cblkno;
-
-#ifdef DEBUG_VERBOSE
- OPJ_UINT32 codeblocks_decoded = 0;
- printf("Enter opj_t1_decode_cblks()\n");
-#endif
-
- for (resno = 0; resno < tilec->minimum_num_resolutions; ++resno) {
- opj_tcd_resolution_t* res = &tilec->resolutions[resno];
-
- for (bandno = 0; bandno < res->numbands; ++bandno) {
- opj_tcd_band_t* OPJ_RESTRICT band = &res->bands[bandno];
-
- for (precno = 0; precno < res->pw * res->ph; ++precno) {
- opj_tcd_precinct_t* precinct = &band->precincts[precno];
-
- if (!opj_tcd_is_subband_area_of_interest(tcd,
- tilec->compno,
- resno,
- band->bandno,
- (OPJ_UINT32)precinct->x0,
- (OPJ_UINT32)precinct->y0,
- (OPJ_UINT32)precinct->x1,
- (OPJ_UINT32)precinct->y1)) {
- for (cblkno = 0; cblkno < precinct->cw * precinct->ch; ++cblkno) {
- opj_tcd_cblk_dec_t* cblk = &precinct->cblks.dec[cblkno];
- if (cblk->decoded_data) {
-#ifdef DEBUG_VERBOSE
- printf("Discarding codeblock %d,%d at resno=%d, bandno=%d\n",
- cblk->x0, cblk->y0, resno, bandno);
-#endif
- opj_aligned_free(cblk->decoded_data);
- cblk->decoded_data = NULL;
- }
- }
- continue;
- }
-
- for (cblkno = 0; cblkno < precinct->cw * precinct->ch; ++cblkno) {
- opj_tcd_cblk_dec_t* cblk = &precinct->cblks.dec[cblkno];
- opj_t1_cblk_decode_processing_job_t* job;
-
- if (!opj_tcd_is_subband_area_of_interest(tcd,
- tilec->compno,
- resno,
- band->bandno,
- (OPJ_UINT32)cblk->x0,
- (OPJ_UINT32)cblk->y0,
- (OPJ_UINT32)cblk->x1,
- (OPJ_UINT32)cblk->y1)) {
- if (cblk->decoded_data) {
-#ifdef DEBUG_VERBOSE
- printf("Discarding codeblock %d,%d at resno=%d, bandno=%d\n",
- cblk->x0, cblk->y0, resno, bandno);
-#endif
- opj_aligned_free(cblk->decoded_data);
- cblk->decoded_data = NULL;
- }
- continue;
- }
-
- if (!tcd->whole_tile_decoding) {
- OPJ_UINT32 cblk_w = (OPJ_UINT32)(cblk->x1 - cblk->x0);
- OPJ_UINT32 cblk_h = (OPJ_UINT32)(cblk->y1 - cblk->y0);
- if (cblk->decoded_data != NULL) {
-#ifdef DEBUG_VERBOSE
- printf("Reusing codeblock %d,%d at resno=%d, bandno=%d\n",
- cblk->x0, cblk->y0, resno, bandno);
-#endif
- continue;
- }
- if (cblk_w == 0 || cblk_h == 0) {
- continue;
- }
-#ifdef DEBUG_VERBOSE
- printf("Decoding codeblock %d,%d at resno=%d, bandno=%d\n",
- cblk->x0, cblk->y0, resno, bandno);
-#endif
- }
-
- job = (opj_t1_cblk_decode_processing_job_t*) opj_calloc(1,
- sizeof(opj_t1_cblk_decode_processing_job_t));
- if (!job) {
- *pret = OPJ_FALSE;
- return;
- }
- job->whole_tile_decoding = tcd->whole_tile_decoding;
- job->resno = resno;
- job->cblk = cblk;
- job->band = band;
- job->tilec = tilec;
- job->tccp = tccp;
- job->pret = pret;
- job->p_manager_mutex = p_manager_mutex;
- job->p_manager = p_manager;
- job->check_pterm = check_pterm;
- job->mustuse_cblkdatabuffer = opj_thread_pool_get_thread_count(tp) > 1;
- opj_thread_pool_submit_job(tp, opj_t1_clbl_decode_processor, job);
-#ifdef DEBUG_VERBOSE
- codeblocks_decoded ++;
-#endif
- if (!(*pret)) {
- return;
- }
- } /* cblkno */
- } /* precno */
- } /* bandno */
- } /* resno */
-
-#ifdef DEBUG_VERBOSE
- printf("Leave opj_t1_decode_cblks(). Number decoded: %d\n", codeblocks_decoded);
-#endif
- return;
-}
-
-
-static OPJ_BOOL opj_t1_decode_cblk(opj_t1_t *t1,
- opj_tcd_cblk_dec_t* cblk,
- OPJ_UINT32 orient,
- OPJ_UINT32 roishift,
- OPJ_UINT32 cblksty,
- opj_event_mgr_t *p_manager,
- opj_mutex_t* p_manager_mutex,
- OPJ_BOOL check_pterm)
-{
- opj_mqc_t *mqc = &(t1->mqc); /* MQC component */
-
- OPJ_INT32 bpno_plus_one;
- OPJ_UINT32 passtype;
- OPJ_UINT32 segno, passno;
- OPJ_BYTE* cblkdata = NULL;
- OPJ_UINT32 cblkdataindex = 0;
- OPJ_BYTE type = T1_TYPE_MQ; /* BYPASS mode */
- OPJ_INT32* original_t1_data = NULL;
-
- mqc->lut_ctxno_zc_orient = lut_ctxno_zc + (orient << 9);
-
- if (!opj_t1_allocate_buffers(
- t1,
- (OPJ_UINT32)(cblk->x1 - cblk->x0),
- (OPJ_UINT32)(cblk->y1 - cblk->y0))) {
- return OPJ_FALSE;
- }
-
- bpno_plus_one = (OPJ_INT32)(roishift + cblk->numbps);
- if (bpno_plus_one >= 31) {
- if (p_manager_mutex) {
- opj_mutex_lock(p_manager_mutex);
- }
- opj_event_msg(p_manager, EVT_WARNING,
- "opj_t1_decode_cblk(): unsupported bpno_plus_one = %d >= 31\n",
- bpno_plus_one);
- if (p_manager_mutex) {
- opj_mutex_unlock(p_manager_mutex);
- }
- return OPJ_FALSE;
- }
- passtype = 2;
-
- opj_mqc_resetstates(mqc);
- opj_mqc_setstate(mqc, T1_CTXNO_UNI, 0, 46);
- opj_mqc_setstate(mqc, T1_CTXNO_AGG, 0, 3);
- opj_mqc_setstate(mqc, T1_CTXNO_ZC, 0, 4);
-
- if (cblk->corrupted) {
- assert(cblk->numchunks == 0);
- return OPJ_TRUE;
- }
-
- /* Even if we have a single chunk, in multi-threaded decoding */
- /* the insertion of our synthetic marker might potentially override */
- /* valid codestream of other codeblocks decoded in parallel. */
- if (cblk->numchunks > 1 || (t1->mustuse_cblkdatabuffer &&
- cblk->numchunks > 0)) {
- OPJ_UINT32 i;
- OPJ_UINT32 cblk_len;
-
- /* Compute whole codeblock length from chunk lengths */
- cblk_len = 0;
- for (i = 0; i < cblk->numchunks; i++) {
- cblk_len += cblk->chunks[i].len;
- }
-
- /* Allocate temporary memory if needed */
- if (cblk_len + OPJ_COMMON_CBLK_DATA_EXTRA > t1->cblkdatabuffersize) {
- cblkdata = (OPJ_BYTE*)opj_realloc(t1->cblkdatabuffer,
- cblk_len + OPJ_COMMON_CBLK_DATA_EXTRA);
- if (cblkdata == NULL) {
- return OPJ_FALSE;
- }
- t1->cblkdatabuffer = cblkdata;
- memset(t1->cblkdatabuffer + cblk_len, 0, OPJ_COMMON_CBLK_DATA_EXTRA);
- t1->cblkdatabuffersize = cblk_len + OPJ_COMMON_CBLK_DATA_EXTRA;
- }
-
- /* Concatenate all chunks */
- cblkdata = t1->cblkdatabuffer;
- cblk_len = 0;
- for (i = 0; i < cblk->numchunks; i++) {
- memcpy(cblkdata + cblk_len, cblk->chunks[i].data, cblk->chunks[i].len);
- cblk_len += cblk->chunks[i].len;
- }
- } else if (cblk->numchunks == 1) {
- cblkdata = cblk->chunks[0].data;
- } else {
- /* Not sure if that can happen in practice, but avoid Coverity to */
- /* think we will dereference a null cblkdta pointer */
- return OPJ_TRUE;
- }
-
- /* For subtile decoding, directly decode in the decoded_data buffer of */
- /* the code-block. Hack t1->data to point to it, and restore it later */
- if (cblk->decoded_data) {
- original_t1_data = t1->data;
- t1->data = cblk->decoded_data;
- }
-
- for (segno = 0; segno < cblk->real_num_segs; ++segno) {
- opj_tcd_seg_t *seg = &cblk->segs[segno];
-
- /* BYPASS mode */
- type = ((bpno_plus_one <= ((OPJ_INT32)(cblk->numbps)) - 4) && (passtype < 2) &&
- (cblksty & J2K_CCP_CBLKSTY_LAZY)) ? T1_TYPE_RAW : T1_TYPE_MQ;
-
- if (type == T1_TYPE_RAW) {
- opj_mqc_raw_init_dec(mqc, cblkdata + cblkdataindex, seg->len,
- OPJ_COMMON_CBLK_DATA_EXTRA);
- } else {
- opj_mqc_init_dec(mqc, cblkdata + cblkdataindex, seg->len,
- OPJ_COMMON_CBLK_DATA_EXTRA);
- }
- cblkdataindex += seg->len;
-
- for (passno = 0; (passno < seg->real_num_passes) &&
- (bpno_plus_one >= 1); ++passno) {
- switch (passtype) {
- case 0:
- if (type == T1_TYPE_RAW) {
- opj_t1_dec_sigpass_raw(t1, bpno_plus_one, (OPJ_INT32)cblksty);
- } else {
- opj_t1_dec_sigpass_mqc(t1, bpno_plus_one, (OPJ_INT32)cblksty);
- }
- break;
- case 1:
- if (type == T1_TYPE_RAW) {
- opj_t1_dec_refpass_raw(t1, bpno_plus_one);
- } else {
- opj_t1_dec_refpass_mqc(t1, bpno_plus_one);
- }
- break;
- case 2:
- opj_t1_dec_clnpass(t1, bpno_plus_one, (OPJ_INT32)cblksty);
- break;
- }
-
- if ((cblksty & J2K_CCP_CBLKSTY_RESET) && type == T1_TYPE_MQ) {
- opj_mqc_resetstates(mqc);
- opj_mqc_setstate(mqc, T1_CTXNO_UNI, 0, 46);
- opj_mqc_setstate(mqc, T1_CTXNO_AGG, 0, 3);
- opj_mqc_setstate(mqc, T1_CTXNO_ZC, 0, 4);
- }
- if (++passtype == 3) {
- passtype = 0;
- bpno_plus_one--;
- }
- }
-
- opq_mqc_finish_dec(mqc);
- }
-
- if (check_pterm) {
- if (mqc->bp + 2 < mqc->end) {
- if (p_manager_mutex) {
- opj_mutex_lock(p_manager_mutex);
- }
- opj_event_msg(p_manager, EVT_WARNING,
- "PTERM check failure: %d remaining bytes in code block (%d used / %d)\n",
- (int)(mqc->end - mqc->bp) - 2,
- (int)(mqc->bp - mqc->start),
- (int)(mqc->end - mqc->start));
- if (p_manager_mutex) {
- opj_mutex_unlock(p_manager_mutex);
- }
- } else if (mqc->end_of_byte_stream_counter > 2) {
- if (p_manager_mutex) {
- opj_mutex_lock(p_manager_mutex);
- }
- opj_event_msg(p_manager, EVT_WARNING,
- "PTERM check failure: %d synthesized 0xFF markers read\n",
- mqc->end_of_byte_stream_counter);
- if (p_manager_mutex) {
- opj_mutex_unlock(p_manager_mutex);
- }
- }
- }
-
- /* Restore original t1->data is needed */
- if (cblk->decoded_data) {
- t1->data = original_t1_data;
- }
-
- return OPJ_TRUE;
-}
-
-
-typedef struct {
- OPJ_UINT32 compno;
- OPJ_UINT32 resno;
- opj_tcd_cblk_enc_t* cblk;
- opj_tcd_tile_t *tile;
- opj_tcd_band_t* band;
- opj_tcd_tilecomp_t* tilec;
- opj_tccp_t* tccp;
- const OPJ_FLOAT64 * mct_norms;
- OPJ_UINT32 mct_numcomps;
- volatile OPJ_BOOL* pret;
- opj_mutex_t* mutex;
-} opj_t1_cblk_encode_processing_job_t;
-
-/** Procedure to deal with a asynchronous code-block encoding job.
- *
- * @param user_data Pointer to a opj_t1_cblk_encode_processing_job_t* structure
- * @param tls TLS handle.
- */
-static void opj_t1_cblk_encode_processor(void* user_data, opj_tls_t* tls)
-{
- opj_t1_cblk_encode_processing_job_t* job =
- (opj_t1_cblk_encode_processing_job_t*)user_data;
- opj_tcd_cblk_enc_t* cblk = job->cblk;
- const opj_tcd_band_t* band = job->band;
- const opj_tcd_tilecomp_t* tilec = job->tilec;
- const opj_tccp_t* tccp = job->tccp;
- const OPJ_UINT32 resno = job->resno;
- opj_t1_t* t1;
- const OPJ_UINT32 tile_w = (OPJ_UINT32)(tilec->x1 - tilec->x0);
-
- OPJ_INT32* OPJ_RESTRICT tiledp;
- OPJ_UINT32 cblk_w;
- OPJ_UINT32 cblk_h;
- OPJ_UINT32 i, j;
-
- OPJ_INT32 x = cblk->x0 - band->x0;
- OPJ_INT32 y = cblk->y0 - band->y0;
-
- if (!*(job->pret)) {
- opj_free(job);
- return;
- }
-
- t1 = (opj_t1_t*) opj_tls_get(tls, OPJ_TLS_KEY_T1);
- if (t1 == NULL) {
- t1 = opj_t1_create(OPJ_TRUE); /* OPJ_TRUE == T1 for encoding */
- opj_tls_set(tls, OPJ_TLS_KEY_T1, t1, opj_t1_destroy_wrapper);
- }
-
- if (band->bandno & 1) {
- opj_tcd_resolution_t *pres = &tilec->resolutions[resno - 1];
- x += pres->x1 - pres->x0;
- }
- if (band->bandno & 2) {
- opj_tcd_resolution_t *pres = &tilec->resolutions[resno - 1];
- y += pres->y1 - pres->y0;
- }
-
- if (!opj_t1_allocate_buffers(
- t1,
- (OPJ_UINT32)(cblk->x1 - cblk->x0),
- (OPJ_UINT32)(cblk->y1 - cblk->y0))) {
- *(job->pret) = OPJ_FALSE;
- opj_free(job);
- return;
- }
-
- cblk_w = t1->w;
- cblk_h = t1->h;
-
- tiledp = &tilec->data[(OPJ_SIZE_T)y * tile_w + (OPJ_SIZE_T)x];
-
- if (tccp->qmfbid == 1) {
- /* Do multiplication on unsigned type, even if the
- * underlying type is signed, to avoid potential
- * int overflow on large value (the output will be
- * incorrect in such situation, but whatever...)
- * This assumes complement-to-2 signed integer
- * representation
- * Fixes https://github.com/uclouvain/openjpeg/issues/1053
- */
- OPJ_UINT32* OPJ_RESTRICT tiledp_u = (OPJ_UINT32*) tiledp;
- OPJ_UINT32* OPJ_RESTRICT t1data = (OPJ_UINT32*) t1->data;
- /* Change from "natural" order to "zigzag" order of T1 passes */
- for (j = 0; j < (cblk_h & ~3U); j += 4) {
-#if defined(__AVX512F__)
- const __m512i perm1 = _mm512_setr_epi64(2, 3, 10, 11, 4, 5, 12, 13);
- const __m512i perm2 = _mm512_setr_epi64(6, 7, 14, 15, 0, 0, 0, 0);
- OPJ_UINT32* ptr = tiledp_u;
- for (i = 0; i < cblk_w / 16; ++i) {
- // INPUT OUTPUT
- // 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 00 10 20 30 01 11 21 31 02 12 22 32 03 13 23 33
- // 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 04 14 24 34 05 15 25 35 06 16 26 36 07 17 27 37
- // 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 08 18 28 38 09 19 29 39 0A 1A 2A 3A 0B 1B 2B 3B
- // 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 0C 1C 2C 3C 0D 1D 2D 3D 0E 1E 2E 3E 0F 1F 2F 3F
- __m512i in1 = _mm512_slli_epi32(_mm512_loadu_si512((__m512i*)(ptr +
- (j + 0) * tile_w)), T1_NMSEDEC_FRACBITS);
- __m512i in2 = _mm512_slli_epi32(_mm512_loadu_si512((__m512i*)(ptr +
- (j + 1) * tile_w)), T1_NMSEDEC_FRACBITS);
- __m512i in3 = _mm512_slli_epi32(_mm512_loadu_si512((__m512i*)(ptr +
- (j + 2) * tile_w)), T1_NMSEDEC_FRACBITS);
- __m512i in4 = _mm512_slli_epi32(_mm512_loadu_si512((__m512i*)(ptr +
- (j + 3) * tile_w)), T1_NMSEDEC_FRACBITS);
-
- __m512i tmp1 = _mm512_unpacklo_epi32(in1, in2);
- __m512i tmp2 = _mm512_unpacklo_epi32(in3, in4);
- __m512i tmp3 = _mm512_unpackhi_epi32(in1, in2);
- __m512i tmp4 = _mm512_unpackhi_epi32(in3, in4);
-
- in1 = _mm512_unpacklo_epi64(tmp1, tmp2);
- in2 = _mm512_unpacklo_epi64(tmp3, tmp4);
- in3 = _mm512_unpackhi_epi64(tmp1, tmp2);
- in4 = _mm512_unpackhi_epi64(tmp3, tmp4);
-
- _mm_storeu_si128((__m128i*)(t1data + 0), _mm512_castsi512_si128(in1));
- _mm_storeu_si128((__m128i*)(t1data + 4), _mm512_castsi512_si128(in3));
- _mm_storeu_si128((__m128i*)(t1data + 8), _mm512_castsi512_si128(in2));
- _mm_storeu_si128((__m128i*)(t1data + 12), _mm512_castsi512_si128(in4));
-
- tmp1 = _mm512_permutex2var_epi64(in1, perm1, in3);
- tmp2 = _mm512_permutex2var_epi64(in2, perm1, in4);
-
- _mm256_storeu_si256((__m256i*)(t1data + 16), _mm512_castsi512_si256(tmp1));
- _mm256_storeu_si256((__m256i*)(t1data + 24), _mm512_castsi512_si256(tmp2));
- _mm256_storeu_si256((__m256i*)(t1data + 32), _mm512_extracti64x4_epi64(tmp1,
- 0x1));
- _mm256_storeu_si256((__m256i*)(t1data + 40), _mm512_extracti64x4_epi64(tmp2,
- 0x1));
- _mm256_storeu_si256((__m256i*)(t1data + 48),
- _mm512_castsi512_si256(_mm512_permutex2var_epi64(in1, perm2, in3)));
- _mm256_storeu_si256((__m256i*)(t1data + 56),
- _mm512_castsi512_si256(_mm512_permutex2var_epi64(in2, perm2, in4)));
- t1data += 64;
- ptr += 16;
- }
- for (i = 0; i < cblk_w % 16; ++i) {
- t1data[0] = ptr[(j + 0) * tile_w] << T1_NMSEDEC_FRACBITS;
- t1data[1] = ptr[(j + 1) * tile_w] << T1_NMSEDEC_FRACBITS;
- t1data[2] = ptr[(j + 2) * tile_w] << T1_NMSEDEC_FRACBITS;
- t1data[3] = ptr[(j + 3) * tile_w] << T1_NMSEDEC_FRACBITS;
- t1data += 4;
- ptr += 1;
- }
-#elif defined(__AVX2__)
- OPJ_UINT32* ptr = tiledp_u;
- for (i = 0; i < cblk_w / 8; ++i) {
- // INPUT OUTPUT
- // 00 01 02 03 04 05 06 07 00 10 20 30 01 11 21 31
- // 10 11 12 13 14 15 16 17 02 12 22 32 03 13 23 33
- // 20 21 22 23 24 25 26 27 04 14 24 34 05 15 25 35
- // 30 31 32 33 34 35 36 37 06 16 26 36 07 17 27 37
- __m256i in1 = _mm256_slli_epi32(_mm256_loadu_si256((__m256i*)(ptr +
- (j + 0) * tile_w)), T1_NMSEDEC_FRACBITS);
- __m256i in2 = _mm256_slli_epi32(_mm256_loadu_si256((__m256i*)(ptr +
- (j + 1) * tile_w)), T1_NMSEDEC_FRACBITS);
- __m256i in3 = _mm256_slli_epi32(_mm256_loadu_si256((__m256i*)(ptr +
- (j + 2) * tile_w)), T1_NMSEDEC_FRACBITS);
- __m256i in4 = _mm256_slli_epi32(_mm256_loadu_si256((__m256i*)(ptr +
- (j + 3) * tile_w)), T1_NMSEDEC_FRACBITS);
-
- __m256i tmp1 = _mm256_unpacklo_epi32(in1, in2);
- __m256i tmp2 = _mm256_unpacklo_epi32(in3, in4);
- __m256i tmp3 = _mm256_unpackhi_epi32(in1, in2);
- __m256i tmp4 = _mm256_unpackhi_epi32(in3, in4);
-
- in1 = _mm256_unpacklo_epi64(tmp1, tmp2);
- in2 = _mm256_unpacklo_epi64(tmp3, tmp4);
- in3 = _mm256_unpackhi_epi64(tmp1, tmp2);
- in4 = _mm256_unpackhi_epi64(tmp3, tmp4);
-
- _mm_storeu_si128((__m128i*)(t1data + 0), _mm256_castsi256_si128(in1));
- _mm_storeu_si128((__m128i*)(t1data + 4), _mm256_castsi256_si128(in3));
- _mm_storeu_si128((__m128i*)(t1data + 8), _mm256_castsi256_si128(in2));
- _mm_storeu_si128((__m128i*)(t1data + 12), _mm256_castsi256_si128(in4));
- _mm256_storeu_si256((__m256i*)(t1data + 16), _mm256_permute2x128_si256(in1, in3,
- 0x31));
- _mm256_storeu_si256((__m256i*)(t1data + 24), _mm256_permute2x128_si256(in2, in4,
- 0x31));
- t1data += 32;
- ptr += 8;
- }
- for (i = 0; i < cblk_w % 8; ++i) {
- t1data[0] = ptr[(j + 0) * tile_w] << T1_NMSEDEC_FRACBITS;
- t1data[1] = ptr[(j + 1) * tile_w] << T1_NMSEDEC_FRACBITS;
- t1data[2] = ptr[(j + 2) * tile_w] << T1_NMSEDEC_FRACBITS;
- t1data[3] = ptr[(j + 3) * tile_w] << T1_NMSEDEC_FRACBITS;
- t1data += 4;
- ptr += 1;
- }
-#else
- for (i = 0; i < cblk_w; ++i) {
- t1data[0] = tiledp_u[(j + 0) * tile_w + i] << T1_NMSEDEC_FRACBITS;
- t1data[1] = tiledp_u[(j + 1) * tile_w + i] << T1_NMSEDEC_FRACBITS;
- t1data[2] = tiledp_u[(j + 2) * tile_w + i] << T1_NMSEDEC_FRACBITS;
- t1data[3] = tiledp_u[(j + 3) * tile_w + i] << T1_NMSEDEC_FRACBITS;
- t1data += 4;
- }
-#endif
- }
- if (j < cblk_h) {
- for (i = 0; i < cblk_w; ++i) {
- OPJ_UINT32 k;
- for (k = j; k < cblk_h; k++) {
- t1data[0] = tiledp_u[k * tile_w + i] << T1_NMSEDEC_FRACBITS;
- t1data ++;
- }
- }
- }
- } else { /* if (tccp->qmfbid == 0) */
- OPJ_FLOAT32* OPJ_RESTRICT tiledp_f = (OPJ_FLOAT32*) tiledp;
- OPJ_INT32* OPJ_RESTRICT t1data = t1->data;
- /* Change from "natural" order to "zigzag" order of T1 passes */
- for (j = 0; j < (cblk_h & ~3U); j += 4) {
- for (i = 0; i < cblk_w; ++i) {
- t1data[0] = (OPJ_INT32)opj_lrintf((tiledp_f[(j + 0) * tile_w + i] /
- band->stepsize) * (1 << T1_NMSEDEC_FRACBITS));
- t1data[1] = (OPJ_INT32)opj_lrintf((tiledp_f[(j + 1) * tile_w + i] /
- band->stepsize) * (1 << T1_NMSEDEC_FRACBITS));
- t1data[2] = (OPJ_INT32)opj_lrintf((tiledp_f[(j + 2) * tile_w + i] /
- band->stepsize) * (1 << T1_NMSEDEC_FRACBITS));
- t1data[3] = (OPJ_INT32)opj_lrintf((tiledp_f[(j + 3) * tile_w + i] /
- band->stepsize) * (1 << T1_NMSEDEC_FRACBITS));
- t1data += 4;
- }
- }
- if (j < cblk_h) {
- for (i = 0; i < cblk_w; ++i) {
- OPJ_UINT32 k;
- for (k = j; k < cblk_h; k++) {
- t1data[0] = (OPJ_INT32)opj_lrintf((tiledp_f[k * tile_w + i] / band->stepsize)
- * (1 << T1_NMSEDEC_FRACBITS));
- t1data ++;
- }
- }
- }
- }
-
- {
- OPJ_FLOAT64 cumwmsedec =
- opj_t1_encode_cblk(
- t1,
- cblk,
- band->bandno,
- job->compno,
- tilec->numresolutions - 1 - resno,
- tccp->qmfbid,
- band->stepsize,
- tccp->cblksty,
- job->tile->numcomps,
- job->mct_norms,
- job->mct_numcomps);
- if (job->mutex) {
- opj_mutex_lock(job->mutex);
- }
- job->tile->distotile += cumwmsedec;
- if (job->mutex) {
- opj_mutex_unlock(job->mutex);
- }
- }
-
- opj_free(job);
-}
-
-
-OPJ_BOOL opj_t1_encode_cblks(opj_tcd_t* tcd,
- opj_tcd_tile_t *tile,
- opj_tcp_t *tcp,
- const OPJ_FLOAT64 * mct_norms,
- OPJ_UINT32 mct_numcomps
- )
-{
- volatile OPJ_BOOL ret = OPJ_TRUE;
- opj_thread_pool_t* tp = tcd->thread_pool;
- OPJ_UINT32 compno, resno, bandno, precno, cblkno;
- opj_mutex_t* mutex = opj_mutex_create();
-
- tile->distotile = 0;
-
- for (compno = 0; compno < tile->numcomps; ++compno) {
- opj_tcd_tilecomp_t* tilec = &tile->comps[compno];
- opj_tccp_t* tccp = &tcp->tccps[compno];
-
- for (resno = 0; resno < tilec->numresolutions; ++resno) {
- opj_tcd_resolution_t *res = &tilec->resolutions[resno];
-
- for (bandno = 0; bandno < res->numbands; ++bandno) {
- opj_tcd_band_t* OPJ_RESTRICT band = &res->bands[bandno];
-
- /* Skip empty bands */
- if (opj_tcd_is_band_empty(band)) {
- continue;
- }
- for (precno = 0; precno < res->pw * res->ph; ++precno) {
- opj_tcd_precinct_t *prc = &band->precincts[precno];
-
- for (cblkno = 0; cblkno < prc->cw * prc->ch; ++cblkno) {
- opj_tcd_cblk_enc_t* cblk = &prc->cblks.enc[cblkno];
-
- opj_t1_cblk_encode_processing_job_t* job =
- (opj_t1_cblk_encode_processing_job_t*) opj_calloc(1,
- sizeof(opj_t1_cblk_encode_processing_job_t));
- if (!job) {
- ret = OPJ_FALSE;
- goto end;
- }
- job->compno = compno;
- job->tile = tile;
- job->resno = resno;
- job->cblk = cblk;
- job->band = band;
- job->tilec = tilec;
- job->tccp = tccp;
- job->mct_norms = mct_norms;
- job->mct_numcomps = mct_numcomps;
- job->pret = &ret;
- job->mutex = mutex;
- opj_thread_pool_submit_job(tp, opj_t1_cblk_encode_processor, job);
-
- } /* cblkno */
- } /* precno */
- } /* bandno */
- } /* resno */
- } /* compno */
-
-end:
- opj_thread_pool_wait_completion(tcd->thread_pool, 0);
- if (mutex) {
- opj_mutex_destroy(mutex);
- }
-
- return ret;
-}
-
-/* Returns whether the pass (bpno, passtype) is terminated */
-static int opj_t1_enc_is_term_pass(opj_tcd_cblk_enc_t* cblk,
- OPJ_UINT32 cblksty,
- OPJ_INT32 bpno,
- OPJ_UINT32 passtype)
-{
- /* Is it the last cleanup pass ? */
- if (passtype == 2 && bpno == 0) {
- return OPJ_TRUE;
- }
-
- if (cblksty & J2K_CCP_CBLKSTY_TERMALL) {
- return OPJ_TRUE;
- }
-
- if ((cblksty & J2K_CCP_CBLKSTY_LAZY)) {
- /* For bypass arithmetic bypass, terminate the 4th cleanup pass */
- if ((bpno == ((OPJ_INT32)cblk->numbps - 4)) && (passtype == 2)) {
- return OPJ_TRUE;
- }
- /* and beyond terminate all the magnitude refinement passes (in raw) */
- /* and cleanup passes (in MQC) */
- if ((bpno < ((OPJ_INT32)(cblk->numbps) - 4)) && (passtype > 0)) {
- return OPJ_TRUE;
- }
- }
-
- return OPJ_FALSE;
-}
-
-
-static OPJ_FLOAT64 opj_t1_encode_cblk(opj_t1_t *t1,
- opj_tcd_cblk_enc_t* cblk,
- OPJ_UINT32 orient,
- OPJ_UINT32 compno,
- OPJ_UINT32 level,
- OPJ_UINT32 qmfbid,
- OPJ_FLOAT64 stepsize,
- OPJ_UINT32 cblksty,
- OPJ_UINT32 numcomps,
- const OPJ_FLOAT64 * mct_norms,
- OPJ_UINT32 mct_numcomps)
-{
- OPJ_FLOAT64 cumwmsedec = 0.0;
-
- opj_mqc_t *mqc = &(t1->mqc); /* MQC component */
-
- OPJ_UINT32 passno;
- OPJ_INT32 bpno;
- OPJ_UINT32 passtype;
- OPJ_INT32 nmsedec = 0;
- OPJ_INT32 max;
- OPJ_UINT32 i, j;
- OPJ_BYTE type = T1_TYPE_MQ;
- OPJ_FLOAT64 tempwmsedec;
- OPJ_INT32* datap;
-
-#ifdef EXTRA_DEBUG
- printf("encode_cblk(x=%d,y=%d,x1=%d,y1=%d,orient=%d,compno=%d,level=%d\n",
- cblk->x0, cblk->y0, cblk->x1, cblk->y1, orient, compno, level);
-#endif
-
- mqc->lut_ctxno_zc_orient = lut_ctxno_zc + (orient << 9);
-
- max = 0;
- datap = t1->data;
- for (j = 0; j < t1->h; ++j) {
- const OPJ_UINT32 w = t1->w;
- for (i = 0; i < w; ++i, ++datap) {
- OPJ_INT32 tmp = *datap;
- if (tmp < 0) {
- OPJ_UINT32 tmp_unsigned;
- if (tmp == INT_MIN) {
- /* To avoid undefined behaviour when negating INT_MIN */
- /* but if we go here, it means we have supplied an input */
- /* with more bit depth than we we can really support. */
- /* Cf https://github.com/uclouvain/openjpeg/issues/1432 */
- tmp = INT_MIN + 1;
- }
- max = opj_int_max(max, -tmp);
- tmp_unsigned = opj_to_smr(tmp);
- memcpy(datap, &tmp_unsigned, sizeof(OPJ_INT32));
- } else {
- max = opj_int_max(max, tmp);
- }
- }
- }
-
- cblk->numbps = max ? (OPJ_UINT32)((opj_int_floorlog2(max) + 1) -
- T1_NMSEDEC_FRACBITS) : 0;
- if (cblk->numbps == 0) {
- cblk->totalpasses = 0;
- return cumwmsedec;
- }
-
- bpno = (OPJ_INT32)(cblk->numbps - 1);
- passtype = 2;
-
- opj_mqc_resetstates(mqc);
- opj_mqc_setstate(mqc, T1_CTXNO_UNI, 0, 46);
- opj_mqc_setstate(mqc, T1_CTXNO_AGG, 0, 3);
- opj_mqc_setstate(mqc, T1_CTXNO_ZC, 0, 4);
- opj_mqc_init_enc(mqc, cblk->data);
-
- for (passno = 0; bpno >= 0; ++passno) {
- opj_tcd_pass_t *pass = &cblk->passes[passno];
- type = ((bpno < ((OPJ_INT32)(cblk->numbps) - 4)) && (passtype < 2) &&
- (cblksty & J2K_CCP_CBLKSTY_LAZY)) ? T1_TYPE_RAW : T1_TYPE_MQ;
-
- /* If the previous pass was terminating, we need to reset the encoder */
- if (passno > 0 && cblk->passes[passno - 1].term) {
- if (type == T1_TYPE_RAW) {
- opj_mqc_bypass_init_enc(mqc);
- } else {
- opj_mqc_restart_init_enc(mqc);
- }
- }
-
- switch (passtype) {
- case 0:
- opj_t1_enc_sigpass(t1, bpno, &nmsedec, type, cblksty);
- break;
- case 1:
- opj_t1_enc_refpass(t1, bpno, &nmsedec, type);
- break;
- case 2:
- opj_t1_enc_clnpass(t1, bpno, &nmsedec, cblksty);
- /* code switch SEGMARK (i.e. SEGSYM) */
- if (cblksty & J2K_CCP_CBLKSTY_SEGSYM) {
- opj_mqc_segmark_enc(mqc);
- }
- break;
- }
-
- tempwmsedec = opj_t1_getwmsedec(nmsedec, compno, level, orient, bpno, qmfbid,
- stepsize, numcomps, mct_norms, mct_numcomps) ;
- cumwmsedec += tempwmsedec;
- pass->distortiondec = cumwmsedec;
-
- if (opj_t1_enc_is_term_pass(cblk, cblksty, bpno, passtype)) {
- /* If it is a terminated pass, terminate it */
- if (type == T1_TYPE_RAW) {
- opj_mqc_bypass_flush_enc(mqc, cblksty & J2K_CCP_CBLKSTY_PTERM);
- } else {
- if (cblksty & J2K_CCP_CBLKSTY_PTERM) {
- opj_mqc_erterm_enc(mqc);
- } else {
- opj_mqc_flush(mqc);
- }
- }
- pass->term = 1;
- pass->rate = opj_mqc_numbytes(mqc);
- } else {
- /* Non terminated pass */
- OPJ_UINT32 rate_extra_bytes;
- if (type == T1_TYPE_RAW) {
- rate_extra_bytes = opj_mqc_bypass_get_extra_bytes(
- mqc, (cblksty & J2K_CCP_CBLKSTY_PTERM));
- } else {
- rate_extra_bytes = 3;
- }
- pass->term = 0;
- pass->rate = opj_mqc_numbytes(mqc) + rate_extra_bytes;
- }
-
- if (++passtype == 3) {
- passtype = 0;
- bpno--;
- }
-
- /* Code-switch "RESET" */
- if (cblksty & J2K_CCP_CBLKSTY_RESET) {
- opj_mqc_reset_enc(mqc);
- }
- }
-
- cblk->totalpasses = passno;
-
- if (cblk->totalpasses) {
- /* Make sure that pass rates are increasing */
- OPJ_UINT32 last_pass_rate = opj_mqc_numbytes(mqc);
- for (passno = cblk->totalpasses; passno > 0;) {
- opj_tcd_pass_t *pass = &cblk->passes[--passno];
- if (pass->rate > last_pass_rate) {
- pass->rate = last_pass_rate;
- } else {
- last_pass_rate = pass->rate;
- }
- }
- }
-
- for (passno = 0; passno < cblk->totalpasses; passno++) {
- opj_tcd_pass_t *pass = &cblk->passes[passno];
-
- /* Prevent generation of FF as last data byte of a pass*/
- /* For terminating passes, the flushing procedure ensured this already */
- assert(pass->rate > 0);
- if (cblk->data[pass->rate - 1] == 0xFF) {
- pass->rate--;
- }
- pass->len = pass->rate - (passno == 0 ? 0 : cblk->passes[passno - 1].rate);
- }
-
-#ifdef EXTRA_DEBUG
- printf(" len=%d\n", (cblk->totalpasses) ? opj_mqc_numbytes(mqc) : 0);
-
- /* Check that there not 0xff >=0x90 sequences */
- if (cblk->totalpasses) {
- OPJ_UINT32 i;
- OPJ_UINT32 len = opj_mqc_numbytes(mqc);
- for (i = 1; i < len; ++i) {
- if (cblk->data[i - 1] == 0xff && cblk->data[i] >= 0x90) {
- printf("0xff %02x at offset %d\n", cblk->data[i], i - 1);
- abort();
- }
- }
- }
-#endif
-
- return cumwmsedec;
-}
diff --git a/contrib/libs/openjpeg/t1.h b/contrib/libs/openjpeg/t1.h
deleted file mode 100644
index ce43658ba3..0000000000
--- a/contrib/libs/openjpeg/t1.h
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2014, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux
- * Copyright (c) 2003-2014, Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2012, Carl Hetherington
- * Copyright (c) 2017, IntoPIX SA <support@intopix.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef OPJ_T1_H
-#define OPJ_T1_H
-/**
-@file t1.h
-@brief Implementation of the tier-1 coding (coding of code-block coefficients) (T1)
-
-The functions in T1.C have for goal to realize the tier-1 coding operation. The functions
-in T1.C are used by some function in TCD.C.
-*/
-
-/** @defgroup T1 T1 - Implementation of the tier-1 coding */
-/*@{*/
-
-/* ----------------------------------------------------------------------- */
-#define T1_NMSEDEC_BITS 7
-
-#define T1_NUMCTXS_ZC 9
-#define T1_NUMCTXS_SC 5
-#define T1_NUMCTXS_MAG 3
-#define T1_NUMCTXS_AGG 1
-#define T1_NUMCTXS_UNI 1
-
-#define T1_CTXNO_ZC 0
-#define T1_CTXNO_SC (T1_CTXNO_ZC+T1_NUMCTXS_ZC)
-#define T1_CTXNO_MAG (T1_CTXNO_SC+T1_NUMCTXS_SC)
-#define T1_CTXNO_AGG (T1_CTXNO_MAG+T1_NUMCTXS_MAG)
-#define T1_CTXNO_UNI (T1_CTXNO_AGG+T1_NUMCTXS_AGG)
-#define T1_NUMCTXS (T1_CTXNO_UNI+T1_NUMCTXS_UNI)
-
-#define T1_NMSEDEC_FRACBITS (T1_NMSEDEC_BITS-1)
-
-#define T1_TYPE_MQ 0 /**< Normal coding using entropy coder */
-#define T1_TYPE_RAW 1 /**< No encoding the information is store under raw format in codestream (mode switch RAW)*/
-
-/* BEGINNING of flags that apply to opj_flag_t */
-/** We hold the state of individual data points for the T1 encoder using
- * a single 32-bit flags word to hold the state of 4 data points. This corresponds
- * to the 4-point-high columns that the data is processed in.
- *
- * These \#defines declare the layout of a 32-bit flags word.
- *
- * This is currently done for encoding only.
- * The values must NOT be changed, otherwise this is going to break a lot of
- * assumptions.
- */
-
-/* SIGMA: significance state (3 cols x 6 rows)
- * CHI: state for negative sample value (1 col x 6 rows)
- * MU: state for visited in refinement pass (1 col x 4 rows)
- * PI: state for visited in significance pass (1 col * 4 rows)
- */
-
-#define T1_SIGMA_0 (1U << 0)
-#define T1_SIGMA_1 (1U << 1)
-#define T1_SIGMA_2 (1U << 2)
-#define T1_SIGMA_3 (1U << 3)
-#define T1_SIGMA_4 (1U << 4)
-#define T1_SIGMA_5 (1U << 5)
-#define T1_SIGMA_6 (1U << 6)
-#define T1_SIGMA_7 (1U << 7)
-#define T1_SIGMA_8 (1U << 8)
-#define T1_SIGMA_9 (1U << 9)
-#define T1_SIGMA_10 (1U << 10)
-#define T1_SIGMA_11 (1U << 11)
-#define T1_SIGMA_12 (1U << 12)
-#define T1_SIGMA_13 (1U << 13)
-#define T1_SIGMA_14 (1U << 14)
-#define T1_SIGMA_15 (1U << 15)
-#define T1_SIGMA_16 (1U << 16)
-#define T1_SIGMA_17 (1U << 17)
-
-#define T1_CHI_0 (1U << 18)
-#define T1_CHI_0_I 18
-#define T1_CHI_1 (1U << 19)
-#define T1_CHI_1_I 19
-#define T1_MU_0 (1U << 20)
-#define T1_PI_0 (1U << 21)
-#define T1_CHI_2 (1U << 22)
-#define T1_CHI_2_I 22
-#define T1_MU_1 (1U << 23)
-#define T1_PI_1 (1U << 24)
-#define T1_CHI_3 (1U << 25)
-#define T1_MU_2 (1U << 26)
-#define T1_PI_2 (1U << 27)
-#define T1_CHI_4 (1U << 28)
-#define T1_MU_3 (1U << 29)
-#define T1_PI_3 (1U << 30)
-#define T1_CHI_5 (1U << 31)
-#define T1_CHI_5_I 31
-
-/** As an example, the bits T1_SIGMA_3, T1_SIGMA_4 and T1_SIGMA_5
- * indicate the significance state of the west neighbour of data point zero
- * of our four, the point itself, and its east neighbour respectively.
- * Many of the bits are arranged so that given a flags word, you can
- * look at the values for the data point 0, then shift the flags
- * word right by 3 bits and look at the same bit positions to see the
- * values for data point 1.
- *
- * The \#defines below help a bit with this; say you have a flags word
- * f, you can do things like
- *
- * (f & T1_SIGMA_THIS)
- *
- * to see the significance bit of data point 0, then do
- *
- * ((f >> 3) & T1_SIGMA_THIS)
- *
- * to see the significance bit of data point 1.
- */
-
-#define T1_SIGMA_NW T1_SIGMA_0
-#define T1_SIGMA_N T1_SIGMA_1
-#define T1_SIGMA_NE T1_SIGMA_2
-#define T1_SIGMA_W T1_SIGMA_3
-#define T1_SIGMA_THIS T1_SIGMA_4
-#define T1_SIGMA_E T1_SIGMA_5
-#define T1_SIGMA_SW T1_SIGMA_6
-#define T1_SIGMA_S T1_SIGMA_7
-#define T1_SIGMA_SE T1_SIGMA_8
-#define T1_SIGMA_NEIGHBOURS (T1_SIGMA_NW | T1_SIGMA_N | T1_SIGMA_NE | T1_SIGMA_W | T1_SIGMA_E | T1_SIGMA_SW | T1_SIGMA_S | T1_SIGMA_SE)
-
-#define T1_CHI_THIS T1_CHI_1
-#define T1_CHI_THIS_I T1_CHI_1_I
-#define T1_MU_THIS T1_MU_0
-#define T1_PI_THIS T1_PI_0
-#define T1_CHI_S T1_CHI_2
-
-#define T1_LUT_SGN_W (1U << 0)
-#define T1_LUT_SIG_N (1U << 1)
-#define T1_LUT_SGN_E (1U << 2)
-#define T1_LUT_SIG_W (1U << 3)
-#define T1_LUT_SGN_N (1U << 4)
-#define T1_LUT_SIG_E (1U << 5)
-#define T1_LUT_SGN_S (1U << 6)
-#define T1_LUT_SIG_S (1U << 7)
-/* END of flags that apply to opj_flag_t */
-
-/* ----------------------------------------------------------------------- */
-
-/** Flags for 4 consecutive rows of a column */
-typedef OPJ_UINT32 opj_flag_t;
-
-/**
-Tier-1 coding (coding of code-block coefficients)
-*/
-typedef struct opj_t1 {
-
- /** MQC component */
- opj_mqc_t mqc;
-
- OPJ_INT32 *data;
- /** Flags used by decoder and encoder.
- * Such that flags[1+0] is for state of col=0,row=0..3,
- flags[1+1] for col=1, row=0..3, flags[1+flags_stride] for col=0,row=4..7, ...
- This array avoids too much cache trashing when processing by 4 vertical samples
- as done in the various decoding steps. */
- opj_flag_t *flags;
-
- OPJ_UINT32 w;
- OPJ_UINT32 h;
- OPJ_UINT32 datasize;
- OPJ_UINT32 flagssize;
- OPJ_BOOL encoder;
-
- /* The 3 variables below are only used by the decoder */
- /* set to TRUE in multithreaded context */
- OPJ_BOOL mustuse_cblkdatabuffer;
- /* Temporary buffer to concatenate all chunks of a codebock */
- OPJ_BYTE *cblkdatabuffer;
- /* Maximum size available in cblkdatabuffer */
- OPJ_UINT32 cblkdatabuffersize;
-} opj_t1_t;
-
-/** @name Exported functions */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-
-/**
-Encode the code-blocks of a tile
-@param tcd TCD handle
-@param tile The tile to encode
-@param tcp Tile coding parameters
-@param mct_norms FIXME DOC
-@param mct_numcomps Number of components used for MCT
-*/
-OPJ_BOOL opj_t1_encode_cblks(opj_tcd_t* tcd,
- opj_tcd_tile_t *tile,
- opj_tcp_t *tcp,
- const OPJ_FLOAT64 * mct_norms,
- OPJ_UINT32 mct_numcomps);
-
-/**
-Decode the code-blocks of a tile
-@param tcd TCD handle
-@param pret Pointer to return value
-@param tilec The tile to decode
-@param tccp Tile coding parameters
-@param p_manager the event manager
-@param p_manager_mutex mutex for the event manager
-@param check_pterm whether PTERM correct termination should be checked
-*/
-void opj_t1_decode_cblks(opj_tcd_t* tcd,
- volatile OPJ_BOOL* pret,
- opj_tcd_tilecomp_t* tilec,
- opj_tccp_t* tccp,
- opj_event_mgr_t *p_manager,
- opj_mutex_t* p_manager_mutex,
- OPJ_BOOL check_pterm);
-
-
-
-/**
- * Creates a new Tier 1 handle
- * and initializes the look-up tables of the Tier-1 coder/decoder
- * @return a new T1 handle if successful, returns NULL otherwise
-*/
-opj_t1_t* opj_t1_create(OPJ_BOOL isEncoder);
-
-/**
- * Destroys a previously created T1 handle
- *
- * @param p_t1 Tier 1 handle to destroy
-*/
-void opj_t1_destroy(opj_t1_t *p_t1);
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* OPJ_T1_H */
diff --git a/contrib/libs/openjpeg/t1_ht_luts.h b/contrib/libs/openjpeg/t1_ht_luts.h
deleted file mode 100644
index f39d5d0577..0000000000
--- a/contrib/libs/openjpeg/t1_ht_luts.h
+++ /dev/null
@@ -1,261 +0,0 @@
-static const OPJ_UINT16 vlc_tbl0[1024] = {
- 0x0023, 0x00a5, 0x0043, 0x0066, 0x0083, 0xa8ee, 0x0014, 0xd8df,
- 0x0023, 0x10be, 0x0043, 0xf5ff, 0x0083, 0x207e, 0x0055, 0x515f,
- 0x0023, 0x0035, 0x0043, 0x444e, 0x0083, 0xc4ce, 0x0014, 0xcccf,
- 0x0023, 0xe2fe, 0x0043, 0x99ff, 0x0083, 0x0096, 0x00c5, 0x313f,
- 0x0023, 0x00a5, 0x0043, 0x445e, 0x0083, 0xc8ce, 0x0014, 0x11df,
- 0x0023, 0xf4fe, 0x0043, 0xfcff, 0x0083, 0x009e, 0x0055, 0x0077,
- 0x0023, 0x0035, 0x0043, 0xf1ff, 0x0083, 0x88ae, 0x0014, 0x00b7,
- 0x0023, 0xf8fe, 0x0043, 0xe4ef, 0x0083, 0x888e, 0x00c5, 0x111f,
- 0x0023, 0x00a5, 0x0043, 0x0066, 0x0083, 0xa8ee, 0x0014, 0x54df,
- 0x0023, 0x10be, 0x0043, 0x22ef, 0x0083, 0x207e, 0x0055, 0x227f,
- 0x0023, 0x0035, 0x0043, 0x444e, 0x0083, 0xc4ce, 0x0014, 0x11bf,
- 0x0023, 0xe2fe, 0x0043, 0x00f7, 0x0083, 0x0096, 0x00c5, 0x223f,
- 0x0023, 0x00a5, 0x0043, 0x445e, 0x0083, 0xc8ce, 0x0014, 0x00d7,
- 0x0023, 0xf4fe, 0x0043, 0xbaff, 0x0083, 0x009e, 0x0055, 0x006f,
- 0x0023, 0x0035, 0x0043, 0xe6ff, 0x0083, 0x88ae, 0x0014, 0xa2af,
- 0x0023, 0xf8fe, 0x0043, 0x00e7, 0x0083, 0x888e, 0x00c5, 0x222f,
- 0x0002, 0x00c5, 0x0084, 0x207e, 0x0002, 0xc4ce, 0x0024, 0x00f7,
- 0x0002, 0xa2fe, 0x0044, 0x0056, 0x0002, 0x009e, 0x0014, 0x00d7,
- 0x0002, 0x10be, 0x0084, 0x0066, 0x0002, 0x88ae, 0x0024, 0x11df,
- 0x0002, 0xa8ee, 0x0044, 0x0036, 0x0002, 0x888e, 0x0014, 0x111f,
- 0x0002, 0x00c5, 0x0084, 0x006e, 0x0002, 0x88ce, 0x0024, 0x88ff,
- 0x0002, 0xb8fe, 0x0044, 0x444e, 0x0002, 0x0096, 0x0014, 0x00b7,
- 0x0002, 0xe4fe, 0x0084, 0x445e, 0x0002, 0x00a6, 0x0024, 0x00e7,
- 0x0002, 0x54de, 0x0044, 0x222e, 0x0002, 0x003e, 0x0014, 0x0077,
- 0x0002, 0x00c5, 0x0084, 0x207e, 0x0002, 0xc4ce, 0x0024, 0xf1ff,
- 0x0002, 0xa2fe, 0x0044, 0x0056, 0x0002, 0x009e, 0x0014, 0x11bf,
- 0x0002, 0x10be, 0x0084, 0x0066, 0x0002, 0x88ae, 0x0024, 0x22ef,
- 0x0002, 0xa8ee, 0x0044, 0x0036, 0x0002, 0x888e, 0x0014, 0x227f,
- 0x0002, 0x00c5, 0x0084, 0x006e, 0x0002, 0x88ce, 0x0024, 0xe4ef,
- 0x0002, 0xb8fe, 0x0044, 0x444e, 0x0002, 0x0096, 0x0014, 0xa2af,
- 0x0002, 0xe4fe, 0x0084, 0x445e, 0x0002, 0x00a6, 0x0024, 0xd8df,
- 0x0002, 0x54de, 0x0044, 0x222e, 0x0002, 0x003e, 0x0014, 0x515f,
- 0x0002, 0x0055, 0x0084, 0x0066, 0x0002, 0x88de, 0x0024, 0x32ff,
- 0x0002, 0x11fe, 0x0044, 0x444e, 0x0002, 0x00ae, 0x0014, 0x00b7,
- 0x0002, 0x317e, 0x0084, 0x515e, 0x0002, 0x00c6, 0x0024, 0x00d7,
- 0x0002, 0x20ee, 0x0044, 0x111e, 0x0002, 0x009e, 0x0014, 0x0077,
- 0x0002, 0x0055, 0x0084, 0x545e, 0x0002, 0x44ce, 0x0024, 0x00e7,
- 0x0002, 0xf1fe, 0x0044, 0x0036, 0x0002, 0x00a6, 0x0014, 0x555f,
- 0x0002, 0x74fe, 0x0084, 0x113e, 0x0002, 0x20be, 0x0024, 0x747f,
- 0x0002, 0xc4de, 0x0044, 0xf8ff, 0x0002, 0x0096, 0x0014, 0x222f,
- 0x0002, 0x0055, 0x0084, 0x0066, 0x0002, 0x88de, 0x0024, 0x00f7,
- 0x0002, 0x11fe, 0x0044, 0x444e, 0x0002, 0x00ae, 0x0014, 0x888f,
- 0x0002, 0x317e, 0x0084, 0x515e, 0x0002, 0x00c6, 0x0024, 0xc8cf,
- 0x0002, 0x20ee, 0x0044, 0x111e, 0x0002, 0x009e, 0x0014, 0x006f,
- 0x0002, 0x0055, 0x0084, 0x545e, 0x0002, 0x44ce, 0x0024, 0xd1df,
- 0x0002, 0xf1fe, 0x0044, 0x0036, 0x0002, 0x00a6, 0x0014, 0x227f,
- 0x0002, 0x74fe, 0x0084, 0x113e, 0x0002, 0x20be, 0x0024, 0x22bf,
- 0x0002, 0xc4de, 0x0044, 0x22ef, 0x0002, 0x0096, 0x0014, 0x323f,
- 0x0003, 0xd4de, 0xf4fd, 0xfcff, 0x0014, 0x113e, 0x0055, 0x888f,
- 0x0003, 0x32be, 0x0085, 0x00e7, 0x0025, 0x515e, 0xaafe, 0x727f,
- 0x0003, 0x44ce, 0xf8fd, 0x44ef, 0x0014, 0x647e, 0x0045, 0xa2af,
- 0x0003, 0x00a6, 0x555d, 0x99df, 0xf1fd, 0x0036, 0xf5fe, 0x626f,
- 0x0003, 0xd1de, 0xf4fd, 0xe6ff, 0x0014, 0x717e, 0x0055, 0xb1bf,
- 0x0003, 0x88ae, 0x0085, 0xd5df, 0x0025, 0x444e, 0xf2fe, 0x667f,
- 0x0003, 0x00c6, 0xf8fd, 0xe2ef, 0x0014, 0x545e, 0x0045, 0x119f,
- 0x0003, 0x0096, 0x555d, 0xc8cf, 0xf1fd, 0x111e, 0xc8ee, 0x0067,
- 0x0003, 0xd4de, 0xf4fd, 0xf3ff, 0x0014, 0x113e, 0x0055, 0x11bf,
- 0x0003, 0x32be, 0x0085, 0xd8df, 0x0025, 0x515e, 0xaafe, 0x222f,
- 0x0003, 0x44ce, 0xf8fd, 0x00f7, 0x0014, 0x647e, 0x0045, 0x989f,
- 0x0003, 0x00a6, 0x555d, 0x00d7, 0xf1fd, 0x0036, 0xf5fe, 0x446f,
- 0x0003, 0xd1de, 0xf4fd, 0xb9ff, 0x0014, 0x717e, 0x0055, 0x00b7,
- 0x0003, 0x88ae, 0x0085, 0xdcdf, 0x0025, 0x444e, 0xf2fe, 0x0077,
- 0x0003, 0x00c6, 0xf8fd, 0xe4ef, 0x0014, 0x545e, 0x0045, 0x737f,
- 0x0003, 0x0096, 0x555d, 0xb8bf, 0xf1fd, 0x111e, 0xc8ee, 0x323f,
- 0x0002, 0x00a5, 0x0084, 0x407e, 0x0002, 0x10de, 0x0024, 0x11df,
- 0x0002, 0x72fe, 0x0044, 0x0056, 0x0002, 0xa8ae, 0x0014, 0xb2bf,
- 0x0002, 0x0096, 0x0084, 0x0066, 0x0002, 0x00c6, 0x0024, 0x00e7,
- 0x0002, 0xc8ee, 0x0044, 0x222e, 0x0002, 0x888e, 0x0014, 0x0077,
- 0x0002, 0x00a5, 0x0084, 0x006e, 0x0002, 0x88ce, 0x0024, 0x00f7,
- 0x0002, 0x91fe, 0x0044, 0x0036, 0x0002, 0xa2ae, 0x0014, 0xaaaf,
- 0x0002, 0xb8fe, 0x0084, 0x005e, 0x0002, 0x00be, 0x0024, 0xc4cf,
- 0x0002, 0x44ee, 0x0044, 0xf4ff, 0x0002, 0x223e, 0x0014, 0x111f,
- 0x0002, 0x00a5, 0x0084, 0x407e, 0x0002, 0x10de, 0x0024, 0x99ff,
- 0x0002, 0x72fe, 0x0044, 0x0056, 0x0002, 0xa8ae, 0x0014, 0x00b7,
- 0x0002, 0x0096, 0x0084, 0x0066, 0x0002, 0x00c6, 0x0024, 0x00d7,
- 0x0002, 0xc8ee, 0x0044, 0x222e, 0x0002, 0x888e, 0x0014, 0x444f,
- 0x0002, 0x00a5, 0x0084, 0x006e, 0x0002, 0x88ce, 0x0024, 0xe2ef,
- 0x0002, 0x91fe, 0x0044, 0x0036, 0x0002, 0xa2ae, 0x0014, 0x447f,
- 0x0002, 0xb8fe, 0x0084, 0x005e, 0x0002, 0x00be, 0x0024, 0x009f,
- 0x0002, 0x44ee, 0x0044, 0x76ff, 0x0002, 0x223e, 0x0014, 0x313f,
- 0x0003, 0x00c6, 0x0085, 0xd9ff, 0xf2fd, 0x647e, 0xf1fe, 0x99bf,
- 0x0003, 0xa2ae, 0x0025, 0x66ef, 0xf4fd, 0x0056, 0xe2ee, 0x737f,
- 0x0003, 0x98be, 0x0045, 0x00f7, 0xf8fd, 0x0066, 0x76fe, 0x889f,
- 0x0003, 0x888e, 0x0015, 0xd5df, 0x00a5, 0x222e, 0x98de, 0x444f,
- 0x0003, 0xb2be, 0x0085, 0xfcff, 0xf2fd, 0x226e, 0x0096, 0x00b7,
- 0x0003, 0xaaae, 0x0025, 0xd1df, 0xf4fd, 0x0036, 0xd4de, 0x646f,
- 0x0003, 0xa8ae, 0x0045, 0xeaef, 0xf8fd, 0x445e, 0xe8ee, 0x717f,
- 0x0003, 0x323e, 0x0015, 0xc4cf, 0x00a5, 0xfaff, 0x88ce, 0x313f,
- 0x0003, 0x00c6, 0x0085, 0x77ff, 0xf2fd, 0x647e, 0xf1fe, 0xb3bf,
- 0x0003, 0xa2ae, 0x0025, 0x00e7, 0xf4fd, 0x0056, 0xe2ee, 0x0077,
- 0x0003, 0x98be, 0x0045, 0xe4ef, 0xf8fd, 0x0066, 0x76fe, 0x667f,
- 0x0003, 0x888e, 0x0015, 0x00d7, 0x00a5, 0x222e, 0x98de, 0x333f,
- 0x0003, 0xb2be, 0x0085, 0x75ff, 0xf2fd, 0x226e, 0x0096, 0x919f,
- 0x0003, 0xaaae, 0x0025, 0x99df, 0xf4fd, 0x0036, 0xd4de, 0x515f,
- 0x0003, 0xa8ae, 0x0045, 0xecef, 0xf8fd, 0x445e, 0xe8ee, 0x727f,
- 0x0003, 0x323e, 0x0015, 0xb1bf, 0x00a5, 0xf3ff, 0x88ce, 0x111f,
- 0x0003, 0x54de, 0xf2fd, 0x111e, 0x0014, 0x647e, 0xf8fe, 0xcccf,
- 0x0003, 0x91be, 0x0045, 0x22ef, 0x0025, 0x222e, 0xf3fe, 0x888f,
- 0x0003, 0x00c6, 0x0085, 0x00f7, 0x0014, 0x115e, 0xfcfe, 0xa8af,
- 0x0003, 0x00a6, 0x0035, 0xc8df, 0xf1fd, 0x313e, 0x66fe, 0x646f,
- 0x0003, 0xc8ce, 0xf2fd, 0xf5ff, 0x0014, 0x0066, 0xf4fe, 0xbabf,
- 0x0003, 0x22ae, 0x0045, 0x00e7, 0x0025, 0x323e, 0xeafe, 0x737f,
- 0x0003, 0xb2be, 0x0085, 0x55df, 0x0014, 0x0056, 0x717e, 0x119f,
- 0x0003, 0x0096, 0x0035, 0xc4cf, 0xf1fd, 0x333e, 0xe8ee, 0x444f,
- 0x0003, 0x54de, 0xf2fd, 0x111e, 0x0014, 0x647e, 0xf8fe, 0x99bf,
- 0x0003, 0x91be, 0x0045, 0xe2ef, 0x0025, 0x222e, 0xf3fe, 0x667f,
- 0x0003, 0x00c6, 0x0085, 0xe4ef, 0x0014, 0x115e, 0xfcfe, 0x989f,
- 0x0003, 0x00a6, 0x0035, 0x00d7, 0xf1fd, 0x313e, 0x66fe, 0x226f,
- 0x0003, 0xc8ce, 0xf2fd, 0xb9ff, 0x0014, 0x0066, 0xf4fe, 0x00b7,
- 0x0003, 0x22ae, 0x0045, 0xd1df, 0x0025, 0x323e, 0xeafe, 0x0077,
- 0x0003, 0xb2be, 0x0085, 0xecef, 0x0014, 0x0056, 0x717e, 0x727f,
- 0x0003, 0x0096, 0x0035, 0xb8bf, 0xf1fd, 0x333e, 0xe8ee, 0x545f,
- 0xf1fc, 0xd1de, 0xfafd, 0x00d7, 0xf8fc, 0x0016, 0xfffd, 0x747f,
- 0xf4fc, 0x717e, 0xf3fd, 0xb3bf, 0xf2fc, 0xeaef, 0xe8ee, 0x444f,
- 0xf1fc, 0x22ae, 0x0005, 0xb8bf, 0xf8fc, 0x00f7, 0xfcfe, 0x0077,
- 0xf4fc, 0x115e, 0xf5fd, 0x757f, 0xf2fc, 0xd8df, 0xe2ee, 0x333f,
- 0xf1fc, 0xb2be, 0xfafd, 0x88cf, 0xf8fc, 0xfbff, 0xfffd, 0x737f,
- 0xf4fc, 0x006e, 0xf3fd, 0x00b7, 0xf2fc, 0x66ef, 0xf9fe, 0x313f,
- 0xf1fc, 0x009e, 0x0005, 0xbabf, 0xf8fc, 0xfdff, 0xf6fe, 0x0067,
- 0xf4fc, 0x0026, 0xf5fd, 0x888f, 0xf2fc, 0xdcdf, 0xd4de, 0x222f,
- 0xf1fc, 0xd1de, 0xfafd, 0xc4cf, 0xf8fc, 0x0016, 0xfffd, 0x727f,
- 0xf4fc, 0x717e, 0xf3fd, 0x99bf, 0xf2fc, 0xecef, 0xe8ee, 0x0047,
- 0xf1fc, 0x22ae, 0x0005, 0x00a7, 0xf8fc, 0xf7ff, 0xfcfe, 0x0057,
- 0xf4fc, 0x115e, 0xf5fd, 0x0097, 0xf2fc, 0xd5df, 0xe2ee, 0x0037,
- 0xf1fc, 0xb2be, 0xfafd, 0x00c7, 0xf8fc, 0xfeff, 0xfffd, 0x667f,
- 0xf4fc, 0x006e, 0xf3fd, 0xa8af, 0xf2fc, 0x00e7, 0xf9fe, 0x323f,
- 0xf1fc, 0x009e, 0x0005, 0xb1bf, 0xf8fc, 0xe4ef, 0xf6fe, 0x545f,
- 0xf4fc, 0x0026, 0xf5fd, 0x0087, 0xf2fc, 0x99df, 0xd4de, 0x111f
-};
-
-static const OPJ_UINT16 vlc_tbl1[1024] = {
- 0x0013, 0x0065, 0x0043, 0x00de, 0x0083, 0x888d, 0x0023, 0x444e,
- 0x0013, 0x00a5, 0x0043, 0x88ae, 0x0083, 0x0035, 0x0023, 0x00d7,
- 0x0013, 0x00c5, 0x0043, 0x009e, 0x0083, 0x0055, 0x0023, 0x222e,
- 0x0013, 0x0095, 0x0043, 0x007e, 0x0083, 0x10fe, 0x0023, 0x0077,
- 0x0013, 0x0065, 0x0043, 0x88ce, 0x0083, 0x888d, 0x0023, 0x111e,
- 0x0013, 0x00a5, 0x0043, 0x005e, 0x0083, 0x0035, 0x0023, 0x00e7,
- 0x0013, 0x00c5, 0x0043, 0x00be, 0x0083, 0x0055, 0x0023, 0x11ff,
- 0x0013, 0x0095, 0x0043, 0x003e, 0x0083, 0x40ee, 0x0023, 0xa2af,
- 0x0013, 0x0065, 0x0043, 0x00de, 0x0083, 0x888d, 0x0023, 0x444e,
- 0x0013, 0x00a5, 0x0043, 0x88ae, 0x0083, 0x0035, 0x0023, 0x44ef,
- 0x0013, 0x00c5, 0x0043, 0x009e, 0x0083, 0x0055, 0x0023, 0x222e,
- 0x0013, 0x0095, 0x0043, 0x007e, 0x0083, 0x10fe, 0x0023, 0x00b7,
- 0x0013, 0x0065, 0x0043, 0x88ce, 0x0083, 0x888d, 0x0023, 0x111e,
- 0x0013, 0x00a5, 0x0043, 0x005e, 0x0083, 0x0035, 0x0023, 0xc4cf,
- 0x0013, 0x00c5, 0x0043, 0x00be, 0x0083, 0x0055, 0x0023, 0x00f7,
- 0x0013, 0x0095, 0x0043, 0x003e, 0x0083, 0x40ee, 0x0023, 0x006f,
- 0x0001, 0x0084, 0x0001, 0x0056, 0x0001, 0x0014, 0x0001, 0x00d7,
- 0x0001, 0x0024, 0x0001, 0x0096, 0x0001, 0x0045, 0x0001, 0x0077,
- 0x0001, 0x0084, 0x0001, 0x00c6, 0x0001, 0x0014, 0x0001, 0x888f,
- 0x0001, 0x0024, 0x0001, 0x00f7, 0x0001, 0x0035, 0x0001, 0x222f,
- 0x0001, 0x0084, 0x0001, 0x40fe, 0x0001, 0x0014, 0x0001, 0x00b7,
- 0x0001, 0x0024, 0x0001, 0x00bf, 0x0001, 0x0045, 0x0001, 0x0067,
- 0x0001, 0x0084, 0x0001, 0x00a6, 0x0001, 0x0014, 0x0001, 0x444f,
- 0x0001, 0x0024, 0x0001, 0x00e7, 0x0001, 0x0035, 0x0001, 0x113f,
- 0x0001, 0x0084, 0x0001, 0x0056, 0x0001, 0x0014, 0x0001, 0x00cf,
- 0x0001, 0x0024, 0x0001, 0x0096, 0x0001, 0x0045, 0x0001, 0x006f,
- 0x0001, 0x0084, 0x0001, 0x00c6, 0x0001, 0x0014, 0x0001, 0x009f,
- 0x0001, 0x0024, 0x0001, 0x00ef, 0x0001, 0x0035, 0x0001, 0x323f,
- 0x0001, 0x0084, 0x0001, 0x40fe, 0x0001, 0x0014, 0x0001, 0x00af,
- 0x0001, 0x0024, 0x0001, 0x44ff, 0x0001, 0x0045, 0x0001, 0x005f,
- 0x0001, 0x0084, 0x0001, 0x00a6, 0x0001, 0x0014, 0x0001, 0x007f,
- 0x0001, 0x0024, 0x0001, 0x00df, 0x0001, 0x0035, 0x0001, 0x111f,
- 0x0001, 0x0024, 0x0001, 0x0056, 0x0001, 0x0085, 0x0001, 0x00bf,
- 0x0001, 0x0014, 0x0001, 0x00f7, 0x0001, 0x00c6, 0x0001, 0x0077,
- 0x0001, 0x0024, 0x0001, 0xf8ff, 0x0001, 0x0045, 0x0001, 0x007f,
- 0x0001, 0x0014, 0x0001, 0x00df, 0x0001, 0x00a6, 0x0001, 0x313f,
- 0x0001, 0x0024, 0x0001, 0x222e, 0x0001, 0x0085, 0x0001, 0x00b7,
- 0x0001, 0x0014, 0x0001, 0x44ef, 0x0001, 0xa2ae, 0x0001, 0x0067,
- 0x0001, 0x0024, 0x0001, 0x51ff, 0x0001, 0x0045, 0x0001, 0x0097,
- 0x0001, 0x0014, 0x0001, 0x00cf, 0x0001, 0x0036, 0x0001, 0x223f,
- 0x0001, 0x0024, 0x0001, 0x0056, 0x0001, 0x0085, 0x0001, 0xb2bf,
- 0x0001, 0x0014, 0x0001, 0x40ef, 0x0001, 0x00c6, 0x0001, 0x006f,
- 0x0001, 0x0024, 0x0001, 0x72ff, 0x0001, 0x0045, 0x0001, 0x009f,
- 0x0001, 0x0014, 0x0001, 0x00d7, 0x0001, 0x00a6, 0x0001, 0x444f,
- 0x0001, 0x0024, 0x0001, 0x222e, 0x0001, 0x0085, 0x0001, 0xa8af,
- 0x0001, 0x0014, 0x0001, 0x00e7, 0x0001, 0xa2ae, 0x0001, 0x005f,
- 0x0001, 0x0024, 0x0001, 0x44ff, 0x0001, 0x0045, 0x0001, 0x888f,
- 0x0001, 0x0014, 0x0001, 0xaaaf, 0x0001, 0x0036, 0x0001, 0x111f,
- 0x0002, 0xf8fe, 0x0024, 0x0056, 0x0002, 0x00b6, 0x0085, 0x66ff,
- 0x0002, 0x00ce, 0x0014, 0x111e, 0x0002, 0x0096, 0x0035, 0xa8af,
- 0x0002, 0x00f6, 0x0024, 0x313e, 0x0002, 0x00a6, 0x0045, 0xb3bf,
- 0x0002, 0xb2be, 0x0014, 0xf5ff, 0x0002, 0x0066, 0x517e, 0x545f,
- 0x0002, 0xf2fe, 0x0024, 0x222e, 0x0002, 0x22ae, 0x0085, 0x44ef,
- 0x0002, 0x00c6, 0x0014, 0xf4ff, 0x0002, 0x0076, 0x0035, 0x447f,
- 0x0002, 0x40de, 0x0024, 0x323e, 0x0002, 0x009e, 0x0045, 0x00d7,
- 0x0002, 0x88be, 0x0014, 0xfaff, 0x0002, 0x115e, 0xf1fe, 0x444f,
- 0x0002, 0xf8fe, 0x0024, 0x0056, 0x0002, 0x00b6, 0x0085, 0xc8ef,
- 0x0002, 0x00ce, 0x0014, 0x111e, 0x0002, 0x0096, 0x0035, 0x888f,
- 0x0002, 0x00f6, 0x0024, 0x313e, 0x0002, 0x00a6, 0x0045, 0x44df,
- 0x0002, 0xb2be, 0x0014, 0xa8ff, 0x0002, 0x0066, 0x517e, 0x006f,
- 0x0002, 0xf2fe, 0x0024, 0x222e, 0x0002, 0x22ae, 0x0085, 0x00e7,
- 0x0002, 0x00c6, 0x0014, 0xe2ef, 0x0002, 0x0076, 0x0035, 0x727f,
- 0x0002, 0x40de, 0x0024, 0x323e, 0x0002, 0x009e, 0x0045, 0xb1bf,
- 0x0002, 0x88be, 0x0014, 0x73ff, 0x0002, 0x115e, 0xf1fe, 0x333f,
- 0x0001, 0x0084, 0x0001, 0x20ee, 0x0001, 0x00c5, 0x0001, 0xc4cf,
- 0x0001, 0x0044, 0x0001, 0x32ff, 0x0001, 0x0015, 0x0001, 0x888f,
- 0x0001, 0x0084, 0x0001, 0x0066, 0x0001, 0x0025, 0x0001, 0x00af,
- 0x0001, 0x0044, 0x0001, 0x22ef, 0x0001, 0x00a6, 0x0001, 0x005f,
- 0x0001, 0x0084, 0x0001, 0x444e, 0x0001, 0x00c5, 0x0001, 0xcccf,
- 0x0001, 0x0044, 0x0001, 0x00f7, 0x0001, 0x0015, 0x0001, 0x006f,
- 0x0001, 0x0084, 0x0001, 0x0056, 0x0001, 0x0025, 0x0001, 0x009f,
- 0x0001, 0x0044, 0x0001, 0x00df, 0x0001, 0x30fe, 0x0001, 0x222f,
- 0x0001, 0x0084, 0x0001, 0x20ee, 0x0001, 0x00c5, 0x0001, 0xc8cf,
- 0x0001, 0x0044, 0x0001, 0x11ff, 0x0001, 0x0015, 0x0001, 0x0077,
- 0x0001, 0x0084, 0x0001, 0x0066, 0x0001, 0x0025, 0x0001, 0x007f,
- 0x0001, 0x0044, 0x0001, 0x00e7, 0x0001, 0x00a6, 0x0001, 0x0037,
- 0x0001, 0x0084, 0x0001, 0x444e, 0x0001, 0x00c5, 0x0001, 0x00b7,
- 0x0001, 0x0044, 0x0001, 0x00bf, 0x0001, 0x0015, 0x0001, 0x003f,
- 0x0001, 0x0084, 0x0001, 0x0056, 0x0001, 0x0025, 0x0001, 0x0097,
- 0x0001, 0x0044, 0x0001, 0x00d7, 0x0001, 0x30fe, 0x0001, 0x111f,
- 0x0002, 0xa8ee, 0x0044, 0x888e, 0x0002, 0x00d6, 0x00c5, 0xf3ff,
- 0x0002, 0xfcfe, 0x0025, 0x003e, 0x0002, 0x00b6, 0x0055, 0xd8df,
- 0x0002, 0xf8fe, 0x0044, 0x0066, 0x0002, 0x207e, 0x0085, 0x99ff,
- 0x0002, 0x00e6, 0x00f5, 0x0036, 0x0002, 0x00a6, 0x0015, 0x009f,
- 0x0002, 0xf2fe, 0x0044, 0x0076, 0x0002, 0x44ce, 0x00c5, 0x76ff,
- 0x0002, 0xf1fe, 0x0025, 0x444e, 0x0002, 0x00ae, 0x0055, 0xc8cf,
- 0x0002, 0xf4fe, 0x0044, 0x445e, 0x0002, 0x10be, 0x0085, 0xe4ef,
- 0x0002, 0x54de, 0x00f5, 0x111e, 0x0002, 0x0096, 0x0015, 0x222f,
- 0x0002, 0xa8ee, 0x0044, 0x888e, 0x0002, 0x00d6, 0x00c5, 0xfaff,
- 0x0002, 0xfcfe, 0x0025, 0x003e, 0x0002, 0x00b6, 0x0055, 0x11bf,
- 0x0002, 0xf8fe, 0x0044, 0x0066, 0x0002, 0x207e, 0x0085, 0x22ef,
- 0x0002, 0x00e6, 0x00f5, 0x0036, 0x0002, 0x00a6, 0x0015, 0x227f,
- 0x0002, 0xf2fe, 0x0044, 0x0076, 0x0002, 0x44ce, 0x00c5, 0xd5ff,
- 0x0002, 0xf1fe, 0x0025, 0x444e, 0x0002, 0x00ae, 0x0055, 0x006f,
- 0x0002, 0xf4fe, 0x0044, 0x445e, 0x0002, 0x10be, 0x0085, 0x11df,
- 0x0002, 0x54de, 0x00f5, 0x111e, 0x0002, 0x0096, 0x0015, 0x515f,
- 0x0003, 0x00f6, 0x0014, 0x111e, 0x0044, 0x888e, 0x00a5, 0xd4df,
- 0x0003, 0xa2ae, 0x0055, 0x76ff, 0x0024, 0x223e, 0x00b6, 0xaaaf,
- 0x0003, 0x00e6, 0x0014, 0xf5ff, 0x0044, 0x0066, 0x0085, 0xcccf,
- 0x0003, 0x009e, 0x00c5, 0x44ef, 0x0024, 0x0036, 0xf8fe, 0x317f,
- 0x0003, 0xe8ee, 0x0014, 0xf1ff, 0x0044, 0x0076, 0x00a5, 0xc4cf,
- 0x0003, 0x227e, 0x0055, 0xd1df, 0x0024, 0x444e, 0xf4fe, 0x515f,
- 0x0003, 0x00d6, 0x0014, 0xe2ef, 0x0044, 0x445e, 0x0085, 0x22bf,
- 0x0003, 0x0096, 0x00c5, 0xc8df, 0x0024, 0x222e, 0xf2fe, 0x226f,
- 0x0003, 0x00f6, 0x0014, 0x111e, 0x0044, 0x888e, 0x00a5, 0xb1bf,
- 0x0003, 0xa2ae, 0x0055, 0x33ff, 0x0024, 0x223e, 0x00b6, 0xa8af,
- 0x0003, 0x00e6, 0x0014, 0xb9ff, 0x0044, 0x0066, 0x0085, 0xa8bf,
- 0x0003, 0x009e, 0x00c5, 0xe4ef, 0x0024, 0x0036, 0xf8fe, 0x646f,
- 0x0003, 0xe8ee, 0x0014, 0xfcff, 0x0044, 0x0076, 0x00a5, 0xc8cf,
- 0x0003, 0x227e, 0x0055, 0xeaef, 0x0024, 0x444e, 0xf4fe, 0x747f,
- 0x0003, 0x00d6, 0x0014, 0xfaff, 0x0044, 0x445e, 0x0085, 0xb2bf,
- 0x0003, 0x0096, 0x00c5, 0x44df, 0x0024, 0x222e, 0xf2fe, 0x313f,
- 0x00f3, 0xfafe, 0xf1fd, 0x0036, 0x0004, 0x32be, 0x0075, 0x11df,
- 0x00f3, 0x54de, 0xf2fd, 0xe4ef, 0x00d5, 0x717e, 0xfcfe, 0x737f,
- 0x00f3, 0xf3fe, 0xf8fd, 0x111e, 0x0004, 0x0096, 0x0055, 0xb1bf,
- 0x00f3, 0x00ce, 0x00b5, 0xd8df, 0xf4fd, 0x0066, 0xb9fe, 0x545f,
- 0x00f3, 0x76fe, 0xf1fd, 0x0026, 0x0004, 0x00a6, 0x0075, 0x009f,
- 0x00f3, 0x00ae, 0xf2fd, 0xf7ff, 0x00d5, 0x0046, 0xf5fe, 0x747f,
- 0x00f3, 0x00e6, 0xf8fd, 0x0016, 0x0004, 0x0086, 0x0055, 0x888f,
- 0x00f3, 0x00c6, 0x00b5, 0xe2ef, 0xf4fd, 0x115e, 0xa8ee, 0x113f,
- 0x00f3, 0xfafe, 0xf1fd, 0x0036, 0x0004, 0x32be, 0x0075, 0xd1df,
- 0x00f3, 0x54de, 0xf2fd, 0xfbff, 0x00d5, 0x717e, 0xfcfe, 0x447f,
- 0x00f3, 0xf3fe, 0xf8fd, 0x111e, 0x0004, 0x0096, 0x0055, 0x727f,
- 0x00f3, 0x00ce, 0x00b5, 0x22ef, 0xf4fd, 0x0066, 0xb9fe, 0x444f,
- 0x00f3, 0x76fe, 0xf1fd, 0x0026, 0x0004, 0x00a6, 0x0075, 0x11bf,
- 0x00f3, 0x00ae, 0xf2fd, 0xffff, 0x00d5, 0x0046, 0xf5fe, 0x323f,
- 0x00f3, 0x00e6, 0xf8fd, 0x0016, 0x0004, 0x0086, 0x0055, 0x006f,
- 0x00f3, 0x00c6, 0x00b5, 0xb8bf, 0xf4fd, 0x115e, 0xa8ee, 0x222f
-}; \ No newline at end of file
diff --git a/contrib/libs/openjpeg/t1_luts.h b/contrib/libs/openjpeg/t1_luts.h
deleted file mode 100644
index 1a5e7844f7..0000000000
--- a/contrib/libs/openjpeg/t1_luts.h
+++ /dev/null
@@ -1,175 +0,0 @@
-/* This file was automatically generated by t1_generate_luts.c */
-
-static const OPJ_BYTE lut_ctxno_zc[2048] = {
- 0, 1, 3, 3, 1, 2, 3, 3, 5, 6, 7, 7, 6, 6, 7, 7, 0, 1, 3, 3, 1, 2, 3, 3, 5, 6, 7, 7, 6, 6, 7, 7,
- 5, 6, 7, 7, 6, 6, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 5, 6, 7, 7, 6, 6, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8,
- 1, 2, 3, 3, 2, 2, 3, 3, 6, 6, 7, 7, 6, 6, 7, 7, 1, 2, 3, 3, 2, 2, 3, 3, 6, 6, 7, 7, 6, 6, 7, 7,
- 6, 6, 7, 7, 6, 6, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 6, 6, 7, 7, 6, 6, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8,
- 3, 3, 4, 4, 3, 3, 4, 4, 7, 7, 7, 7, 7, 7, 7, 7, 3, 3, 4, 4, 3, 3, 4, 4, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8,
- 3, 3, 4, 4, 3, 3, 4, 4, 7, 7, 7, 7, 7, 7, 7, 7, 3, 3, 4, 4, 3, 3, 4, 4, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8,
- 1, 2, 3, 3, 2, 2, 3, 3, 6, 6, 7, 7, 6, 6, 7, 7, 1, 2, 3, 3, 2, 2, 3, 3, 6, 6, 7, 7, 6, 6, 7, 7,
- 6, 6, 7, 7, 6, 6, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 6, 6, 7, 7, 6, 6, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8,
- 2, 2, 3, 3, 2, 2, 3, 3, 6, 6, 7, 7, 6, 6, 7, 7, 2, 2, 3, 3, 2, 2, 3, 3, 6, 6, 7, 7, 6, 6, 7, 7,
- 6, 6, 7, 7, 6, 6, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 6, 6, 7, 7, 6, 6, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8,
- 3, 3, 4, 4, 3, 3, 4, 4, 7, 7, 7, 7, 7, 7, 7, 7, 3, 3, 4, 4, 3, 3, 4, 4, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8,
- 3, 3, 4, 4, 3, 3, 4, 4, 7, 7, 7, 7, 7, 7, 7, 7, 3, 3, 4, 4, 3, 3, 4, 4, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8,
- 0, 1, 5, 6, 1, 2, 6, 6, 3, 3, 7, 7, 3, 3, 7, 7, 0, 1, 5, 6, 1, 2, 6, 6, 3, 3, 7, 7, 3, 3, 7, 7,
- 3, 3, 7, 7, 3, 3, 7, 7, 4, 4, 7, 7, 4, 4, 7, 7, 3, 3, 7, 7, 3, 3, 7, 7, 4, 4, 7, 7, 4, 4, 7, 7,
- 1, 2, 6, 6, 2, 2, 6, 6, 3, 3, 7, 7, 3, 3, 7, 7, 1, 2, 6, 6, 2, 2, 6, 6, 3, 3, 7, 7, 3, 3, 7, 7,
- 3, 3, 7, 7, 3, 3, 7, 7, 4, 4, 7, 7, 4, 4, 7, 7, 3, 3, 7, 7, 3, 3, 7, 7, 4, 4, 7, 7, 4, 4, 7, 7,
- 5, 6, 8, 8, 6, 6, 8, 8, 7, 7, 8, 8, 7, 7, 8, 8, 5, 6, 8, 8, 6, 6, 8, 8, 7, 7, 8, 8, 7, 7, 8, 8,
- 7, 7, 8, 8, 7, 7, 8, 8, 7, 7, 8, 8, 7, 7, 8, 8, 7, 7, 8, 8, 7, 7, 8, 8, 7, 7, 8, 8, 7, 7, 8, 8,
- 6, 6, 8, 8, 6, 6, 8, 8, 7, 7, 8, 8, 7, 7, 8, 8, 6, 6, 8, 8, 6, 6, 8, 8, 7, 7, 8, 8, 7, 7, 8, 8,
- 7, 7, 8, 8, 7, 7, 8, 8, 7, 7, 8, 8, 7, 7, 8, 8, 7, 7, 8, 8, 7, 7, 8, 8, 7, 7, 8, 8, 7, 7, 8, 8,
- 1, 2, 6, 6, 2, 2, 6, 6, 3, 3, 7, 7, 3, 3, 7, 7, 1, 2, 6, 6, 2, 2, 6, 6, 3, 3, 7, 7, 3, 3, 7, 7,
- 3, 3, 7, 7, 3, 3, 7, 7, 4, 4, 7, 7, 4, 4, 7, 7, 3, 3, 7, 7, 3, 3, 7, 7, 4, 4, 7, 7, 4, 4, 7, 7,
- 2, 2, 6, 6, 2, 2, 6, 6, 3, 3, 7, 7, 3, 3, 7, 7, 2, 2, 6, 6, 2, 2, 6, 6, 3, 3, 7, 7, 3, 3, 7, 7,
- 3, 3, 7, 7, 3, 3, 7, 7, 4, 4, 7, 7, 4, 4, 7, 7, 3, 3, 7, 7, 3, 3, 7, 7, 4, 4, 7, 7, 4, 4, 7, 7,
- 6, 6, 8, 8, 6, 6, 8, 8, 7, 7, 8, 8, 7, 7, 8, 8, 6, 6, 8, 8, 6, 6, 8, 8, 7, 7, 8, 8, 7, 7, 8, 8,
- 7, 7, 8, 8, 7, 7, 8, 8, 7, 7, 8, 8, 7, 7, 8, 8, 7, 7, 8, 8, 7, 7, 8, 8, 7, 7, 8, 8, 7, 7, 8, 8,
- 6, 6, 8, 8, 6, 6, 8, 8, 7, 7, 8, 8, 7, 7, 8, 8, 6, 6, 8, 8, 6, 6, 8, 8, 7, 7, 8, 8, 7, 7, 8, 8,
- 7, 7, 8, 8, 7, 7, 8, 8, 7, 7, 8, 8, 7, 7, 8, 8, 7, 7, 8, 8, 7, 7, 8, 8, 7, 7, 8, 8, 7, 7, 8, 8,
- 0, 1, 3, 3, 1, 2, 3, 3, 5, 6, 7, 7, 6, 6, 7, 7, 0, 1, 3, 3, 1, 2, 3, 3, 5, 6, 7, 7, 6, 6, 7, 7,
- 5, 6, 7, 7, 6, 6, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 5, 6, 7, 7, 6, 6, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8,
- 1, 2, 3, 3, 2, 2, 3, 3, 6, 6, 7, 7, 6, 6, 7, 7, 1, 2, 3, 3, 2, 2, 3, 3, 6, 6, 7, 7, 6, 6, 7, 7,
- 6, 6, 7, 7, 6, 6, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 6, 6, 7, 7, 6, 6, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8,
- 3, 3, 4, 4, 3, 3, 4, 4, 7, 7, 7, 7, 7, 7, 7, 7, 3, 3, 4, 4, 3, 3, 4, 4, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8,
- 3, 3, 4, 4, 3, 3, 4, 4, 7, 7, 7, 7, 7, 7, 7, 7, 3, 3, 4, 4, 3, 3, 4, 4, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8,
- 1, 2, 3, 3, 2, 2, 3, 3, 6, 6, 7, 7, 6, 6, 7, 7, 1, 2, 3, 3, 2, 2, 3, 3, 6, 6, 7, 7, 6, 6, 7, 7,
- 6, 6, 7, 7, 6, 6, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 6, 6, 7, 7, 6, 6, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8,
- 2, 2, 3, 3, 2, 2, 3, 3, 6, 6, 7, 7, 6, 6, 7, 7, 2, 2, 3, 3, 2, 2, 3, 3, 6, 6, 7, 7, 6, 6, 7, 7,
- 6, 6, 7, 7, 6, 6, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 6, 6, 7, 7, 6, 6, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8,
- 3, 3, 4, 4, 3, 3, 4, 4, 7, 7, 7, 7, 7, 7, 7, 7, 3, 3, 4, 4, 3, 3, 4, 4, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8,
- 3, 3, 4, 4, 3, 3, 4, 4, 7, 7, 7, 7, 7, 7, 7, 7, 3, 3, 4, 4, 3, 3, 4, 4, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8,
- 0, 3, 1, 4, 3, 6, 4, 7, 1, 4, 2, 5, 4, 7, 5, 7, 0, 3, 1, 4, 3, 6, 4, 7, 1, 4, 2, 5, 4, 7, 5, 7,
- 1, 4, 2, 5, 4, 7, 5, 7, 2, 5, 2, 5, 5, 7, 5, 7, 1, 4, 2, 5, 4, 7, 5, 7, 2, 5, 2, 5, 5, 7, 5, 7,
- 3, 6, 4, 7, 6, 8, 7, 8, 4, 7, 5, 7, 7, 8, 7, 8, 3, 6, 4, 7, 6, 8, 7, 8, 4, 7, 5, 7, 7, 8, 7, 8,
- 4, 7, 5, 7, 7, 8, 7, 8, 5, 7, 5, 7, 7, 8, 7, 8, 4, 7, 5, 7, 7, 8, 7, 8, 5, 7, 5, 7, 7, 8, 7, 8,
- 1, 4, 2, 5, 4, 7, 5, 7, 2, 5, 2, 5, 5, 7, 5, 7, 1, 4, 2, 5, 4, 7, 5, 7, 2, 5, 2, 5, 5, 7, 5, 7,
- 2, 5, 2, 5, 5, 7, 5, 7, 2, 5, 2, 5, 5, 7, 5, 7, 2, 5, 2, 5, 5, 7, 5, 7, 2, 5, 2, 5, 5, 7, 5, 7,
- 4, 7, 5, 7, 7, 8, 7, 8, 5, 7, 5, 7, 7, 8, 7, 8, 4, 7, 5, 7, 7, 8, 7, 8, 5, 7, 5, 7, 7, 8, 7, 8,
- 5, 7, 5, 7, 7, 8, 7, 8, 5, 7, 5, 7, 7, 8, 7, 8, 5, 7, 5, 7, 7, 8, 7, 8, 5, 7, 5, 7, 7, 8, 7, 8,
- 3, 6, 4, 7, 6, 8, 7, 8, 4, 7, 5, 7, 7, 8, 7, 8, 3, 6, 4, 7, 6, 8, 7, 8, 4, 7, 5, 7, 7, 8, 7, 8,
- 4, 7, 5, 7, 7, 8, 7, 8, 5, 7, 5, 7, 7, 8, 7, 8, 4, 7, 5, 7, 7, 8, 7, 8, 5, 7, 5, 7, 7, 8, 7, 8,
- 6, 8, 7, 8, 8, 8, 8, 8, 7, 8, 7, 8, 8, 8, 8, 8, 6, 8, 7, 8, 8, 8, 8, 8, 7, 8, 7, 8, 8, 8, 8, 8,
- 7, 8, 7, 8, 8, 8, 8, 8, 7, 8, 7, 8, 8, 8, 8, 8, 7, 8, 7, 8, 8, 8, 8, 8, 7, 8, 7, 8, 8, 8, 8, 8,
- 4, 7, 5, 7, 7, 8, 7, 8, 5, 7, 5, 7, 7, 8, 7, 8, 4, 7, 5, 7, 7, 8, 7, 8, 5, 7, 5, 7, 7, 8, 7, 8,
- 5, 7, 5, 7, 7, 8, 7, 8, 5, 7, 5, 7, 7, 8, 7, 8, 5, 7, 5, 7, 7, 8, 7, 8, 5, 7, 5, 7, 7, 8, 7, 8,
- 7, 8, 7, 8, 8, 8, 8, 8, 7, 8, 7, 8, 8, 8, 8, 8, 7, 8, 7, 8, 8, 8, 8, 8, 7, 8, 7, 8, 8, 8, 8, 8,
- 7, 8, 7, 8, 8, 8, 8, 8, 7, 8, 7, 8, 8, 8, 8, 8, 7, 8, 7, 8, 8, 8, 8, 8, 7, 8, 7, 8, 8, 8, 8, 8
-};
-
-static const OPJ_BYTE lut_ctxno_sc[256] = {
- 0x9, 0x9, 0xa, 0xa, 0x9, 0x9, 0xa, 0xa, 0xc, 0xc, 0xd, 0xb, 0xc, 0xc, 0xd, 0xb,
- 0x9, 0x9, 0xa, 0xa, 0x9, 0x9, 0xa, 0xa, 0xc, 0xc, 0xb, 0xd, 0xc, 0xc, 0xb, 0xd,
- 0xc, 0xc, 0xd, 0xd, 0xc, 0xc, 0xb, 0xb, 0xc, 0x9, 0xd, 0xa, 0x9, 0xc, 0xa, 0xb,
- 0xc, 0xc, 0xb, 0xb, 0xc, 0xc, 0xd, 0xd, 0xc, 0x9, 0xb, 0xa, 0x9, 0xc, 0xa, 0xd,
- 0x9, 0x9, 0xa, 0xa, 0x9, 0x9, 0xa, 0xa, 0xc, 0xc, 0xd, 0xb, 0xc, 0xc, 0xd, 0xb,
- 0x9, 0x9, 0xa, 0xa, 0x9, 0x9, 0xa, 0xa, 0xc, 0xc, 0xb, 0xd, 0xc, 0xc, 0xb, 0xd,
- 0xc, 0xc, 0xd, 0xd, 0xc, 0xc, 0xb, 0xb, 0xc, 0x9, 0xd, 0xa, 0x9, 0xc, 0xa, 0xb,
- 0xc, 0xc, 0xb, 0xb, 0xc, 0xc, 0xd, 0xd, 0xc, 0x9, 0xb, 0xa, 0x9, 0xc, 0xa, 0xd,
- 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xd, 0xb, 0xd, 0xb, 0xd, 0xb, 0xd, 0xb,
- 0xa, 0xa, 0x9, 0x9, 0xa, 0xa, 0x9, 0x9, 0xd, 0xb, 0xc, 0xc, 0xd, 0xb, 0xc, 0xc,
- 0xd, 0xd, 0xd, 0xd, 0xb, 0xb, 0xb, 0xb, 0xd, 0xa, 0xd, 0xa, 0xa, 0xb, 0xa, 0xb,
- 0xd, 0xd, 0xc, 0xc, 0xb, 0xb, 0xc, 0xc, 0xd, 0xa, 0xc, 0x9, 0xa, 0xb, 0x9, 0xc,
- 0xa, 0xa, 0x9, 0x9, 0xa, 0xa, 0x9, 0x9, 0xb, 0xd, 0xc, 0xc, 0xb, 0xd, 0xc, 0xc,
- 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xb, 0xd, 0xb, 0xd, 0xb, 0xd, 0xb, 0xd,
- 0xb, 0xb, 0xc, 0xc, 0xd, 0xd, 0xc, 0xc, 0xb, 0xa, 0xc, 0x9, 0xa, 0xd, 0x9, 0xc,
- 0xb, 0xb, 0xb, 0xb, 0xd, 0xd, 0xd, 0xd, 0xb, 0xa, 0xb, 0xa, 0xa, 0xd, 0xa, 0xd
-};
-
-static const OPJ_BYTE lut_spb[256] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1,
- 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1,
- 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1,
- 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1,
- 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1,
- 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1
-};
-
-static const OPJ_INT16 lut_nmsedec_sig[1U << T1_NMSEDEC_BITS] = {
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0180, 0x0300, 0x0480, 0x0600, 0x0780, 0x0900, 0x0a80,
- 0x0c00, 0x0d80, 0x0f00, 0x1080, 0x1200, 0x1380, 0x1500, 0x1680,
- 0x1800, 0x1980, 0x1b00, 0x1c80, 0x1e00, 0x1f80, 0x2100, 0x2280,
- 0x2400, 0x2580, 0x2700, 0x2880, 0x2a00, 0x2b80, 0x2d00, 0x2e80,
- 0x3000, 0x3180, 0x3300, 0x3480, 0x3600, 0x3780, 0x3900, 0x3a80,
- 0x3c00, 0x3d80, 0x3f00, 0x4080, 0x4200, 0x4380, 0x4500, 0x4680,
- 0x4800, 0x4980, 0x4b00, 0x4c80, 0x4e00, 0x4f80, 0x5100, 0x5280,
- 0x5400, 0x5580, 0x5700, 0x5880, 0x5a00, 0x5b80, 0x5d00, 0x5e80,
- 0x6000, 0x6180, 0x6300, 0x6480, 0x6600, 0x6780, 0x6900, 0x6a80,
- 0x6c00, 0x6d80, 0x6f00, 0x7080, 0x7200, 0x7380, 0x7500, 0x7680
-};
-
-static const OPJ_INT16 lut_nmsedec_sig0[1U << T1_NMSEDEC_BITS] = {
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0080, 0x0080,
- 0x0080, 0x0080, 0x0100, 0x0100, 0x0100, 0x0180, 0x0180, 0x0200,
- 0x0200, 0x0280, 0x0280, 0x0300, 0x0300, 0x0380, 0x0400, 0x0400,
- 0x0480, 0x0500, 0x0580, 0x0580, 0x0600, 0x0680, 0x0700, 0x0780,
- 0x0800, 0x0880, 0x0900, 0x0980, 0x0a00, 0x0a80, 0x0b80, 0x0c00,
- 0x0c80, 0x0d00, 0x0e00, 0x0e80, 0x0f00, 0x1000, 0x1080, 0x1180,
- 0x1200, 0x1300, 0x1380, 0x1480, 0x1500, 0x1600, 0x1700, 0x1780,
- 0x1880, 0x1980, 0x1a80, 0x1b00, 0x1c00, 0x1d00, 0x1e00, 0x1f00,
- 0x2000, 0x2100, 0x2200, 0x2300, 0x2400, 0x2500, 0x2680, 0x2780,
- 0x2880, 0x2980, 0x2b00, 0x2c00, 0x2d00, 0x2e80, 0x2f80, 0x3100,
- 0x3200, 0x3380, 0x3480, 0x3600, 0x3700, 0x3880, 0x3a00, 0x3b00,
- 0x3c80, 0x3e00, 0x3f80, 0x4080, 0x4200, 0x4380, 0x4500, 0x4680,
- 0x4800, 0x4980, 0x4b00, 0x4c80, 0x4e00, 0x4f80, 0x5180, 0x5300,
- 0x5480, 0x5600, 0x5800, 0x5980, 0x5b00, 0x5d00, 0x5e80, 0x6080,
- 0x6200, 0x6400, 0x6580, 0x6780, 0x6900, 0x6b00, 0x6d00, 0x6e80,
- 0x7080, 0x7280, 0x7480, 0x7600, 0x7800, 0x7a00, 0x7c00, 0x7e00
-};
-
-static const OPJ_INT16 lut_nmsedec_ref[1U << T1_NMSEDEC_BITS] = {
- 0x1800, 0x1780, 0x1700, 0x1680, 0x1600, 0x1580, 0x1500, 0x1480,
- 0x1400, 0x1380, 0x1300, 0x1280, 0x1200, 0x1180, 0x1100, 0x1080,
- 0x1000, 0x0f80, 0x0f00, 0x0e80, 0x0e00, 0x0d80, 0x0d00, 0x0c80,
- 0x0c00, 0x0b80, 0x0b00, 0x0a80, 0x0a00, 0x0980, 0x0900, 0x0880,
- 0x0800, 0x0780, 0x0700, 0x0680, 0x0600, 0x0580, 0x0500, 0x0480,
- 0x0400, 0x0380, 0x0300, 0x0280, 0x0200, 0x0180, 0x0100, 0x0080,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0080, 0x0100, 0x0180, 0x0200, 0x0280, 0x0300, 0x0380,
- 0x0400, 0x0480, 0x0500, 0x0580, 0x0600, 0x0680, 0x0700, 0x0780,
- 0x0800, 0x0880, 0x0900, 0x0980, 0x0a00, 0x0a80, 0x0b00, 0x0b80,
- 0x0c00, 0x0c80, 0x0d00, 0x0d80, 0x0e00, 0x0e80, 0x0f00, 0x0f80,
- 0x1000, 0x1080, 0x1100, 0x1180, 0x1200, 0x1280, 0x1300, 0x1380,
- 0x1400, 0x1480, 0x1500, 0x1580, 0x1600, 0x1680, 0x1700, 0x1780
-};
-
-static const OPJ_INT16 lut_nmsedec_ref0[1U << T1_NMSEDEC_BITS] = {
- 0x2000, 0x1f00, 0x1e00, 0x1d00, 0x1c00, 0x1b00, 0x1a80, 0x1980,
- 0x1880, 0x1780, 0x1700, 0x1600, 0x1500, 0x1480, 0x1380, 0x1300,
- 0x1200, 0x1180, 0x1080, 0x1000, 0x0f00, 0x0e80, 0x0e00, 0x0d00,
- 0x0c80, 0x0c00, 0x0b80, 0x0a80, 0x0a00, 0x0980, 0x0900, 0x0880,
- 0x0800, 0x0780, 0x0700, 0x0680, 0x0600, 0x0580, 0x0580, 0x0500,
- 0x0480, 0x0400, 0x0400, 0x0380, 0x0300, 0x0300, 0x0280, 0x0280,
- 0x0200, 0x0200, 0x0180, 0x0180, 0x0100, 0x0100, 0x0100, 0x0080,
- 0x0080, 0x0080, 0x0080, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0080, 0x0080,
- 0x0080, 0x0080, 0x0100, 0x0100, 0x0100, 0x0180, 0x0180, 0x0200,
- 0x0200, 0x0280, 0x0280, 0x0300, 0x0300, 0x0380, 0x0400, 0x0400,
- 0x0480, 0x0500, 0x0580, 0x0580, 0x0600, 0x0680, 0x0700, 0x0780,
- 0x0800, 0x0880, 0x0900, 0x0980, 0x0a00, 0x0a80, 0x0b80, 0x0c00,
- 0x0c80, 0x0d00, 0x0e00, 0x0e80, 0x0f00, 0x1000, 0x1080, 0x1180,
- 0x1200, 0x1300, 0x1380, 0x1480, 0x1500, 0x1600, 0x1700, 0x1780,
- 0x1880, 0x1980, 0x1a80, 0x1b00, 0x1c00, 0x1d00, 0x1e00, 0x1f00
-};
-
diff --git a/contrib/libs/openjpeg/t2.c b/contrib/libs/openjpeg/t2.c
deleted file mode 100644
index 4e8cf60182..0000000000
--- a/contrib/libs/openjpeg/t2.c
+++ /dev/null
@@ -1,1705 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2014, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux
- * Copyright (c) 2003-2014, Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR
- * Copyright (c) 2012, CS Systemes d'Information, France
- * Copyright (c) 2017, IntoPIX SA <support@intopix.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "opj_includes.h"
-#include "opj_common.h"
-
-
-/** @defgroup T2 T2 - Implementation of a tier-2 coding */
-/*@{*/
-
-/** @name Local static functions */
-/*@{*/
-
-static void opj_t2_putcommacode(opj_bio_t *bio, OPJ_INT32 n);
-
-static OPJ_UINT32 opj_t2_getcommacode(opj_bio_t *bio);
-/**
-Variable length code for signalling delta Zil (truncation point)
-@param bio Bit Input/Output component
-@param n delta Zil
-*/
-static void opj_t2_putnumpasses(opj_bio_t *bio, OPJ_UINT32 n);
-static OPJ_UINT32 opj_t2_getnumpasses(opj_bio_t *bio);
-
-/**
-Encode a packet of a tile to a destination buffer
-@param tileno Number of the tile encoded
-@param tile Tile for which to write the packets
-@param tcp Tile coding parameters
-@param pi Packet identity
-@param dest Destination buffer
-@param p_data_written FIXME DOC
-@param len Length of the destination buffer
-@param cstr_info Codestream information structure
-@param p_t2_mode If == THRESH_CALC In Threshold calculation ,If == FINAL_PASS Final pass
-@param p_manager the user event manager
-@return
-*/
-static OPJ_BOOL opj_t2_encode_packet(OPJ_UINT32 tileno,
- opj_tcd_tile_t *tile,
- opj_tcp_t *tcp,
- opj_pi_iterator_t *pi,
- OPJ_BYTE *dest,
- OPJ_UINT32 * p_data_written,
- OPJ_UINT32 len,
- opj_codestream_info_t *cstr_info,
- J2K_T2_MODE p_t2_mode,
- opj_event_mgr_t *p_manager);
-
-/**
-Decode a packet of a tile from a source buffer
-@param t2 T2 handle
-@param tile Tile for which to write the packets
-@param tcp Tile coding parameters
-@param pi Packet identity
-@param src Source buffer
-@param data_read FIXME DOC
-@param max_length FIXME DOC
-@param pack_info Packet information
-@param p_manager the user event manager
-
-@return FIXME DOC
-*/
-static OPJ_BOOL opj_t2_decode_packet(opj_t2_t* t2,
- opj_tcd_tile_t *tile,
- opj_tcp_t *tcp,
- opj_pi_iterator_t *pi,
- OPJ_BYTE *src,
- OPJ_UINT32 * data_read,
- OPJ_UINT32 max_length,
- opj_packet_info_t *pack_info,
- opj_event_mgr_t *p_manager);
-
-static OPJ_BOOL opj_t2_skip_packet(opj_t2_t* p_t2,
- opj_tcd_tile_t *p_tile,
- opj_tcp_t *p_tcp,
- opj_pi_iterator_t *p_pi,
- OPJ_BYTE *p_src,
- OPJ_UINT32 * p_data_read,
- OPJ_UINT32 p_max_length,
- opj_packet_info_t *p_pack_info,
- opj_event_mgr_t *p_manager);
-
-static OPJ_BOOL opj_t2_read_packet_header(opj_t2_t* p_t2,
- opj_tcd_tile_t *p_tile,
- opj_tcp_t *p_tcp,
- opj_pi_iterator_t *p_pi,
- OPJ_BOOL * p_is_data_present,
- OPJ_BYTE *p_src_data,
- OPJ_UINT32 * p_data_read,
- OPJ_UINT32 p_max_length,
- opj_packet_info_t *p_pack_info,
- opj_event_mgr_t *p_manager);
-
-static OPJ_BOOL opj_t2_read_packet_data(opj_t2_t* p_t2,
- opj_tcd_tile_t *p_tile,
- opj_pi_iterator_t *p_pi,
- OPJ_BYTE *p_src_data,
- OPJ_UINT32 * p_data_read,
- OPJ_UINT32 p_max_length,
- opj_packet_info_t *pack_info,
- opj_event_mgr_t *p_manager);
-
-static OPJ_BOOL opj_t2_skip_packet_data(opj_t2_t* p_t2,
- opj_tcd_tile_t *p_tile,
- opj_pi_iterator_t *p_pi,
- OPJ_UINT32 * p_data_read,
- OPJ_UINT32 p_max_length,
- opj_packet_info_t *pack_info,
- opj_event_mgr_t *p_manager);
-
-/**
-@param cblk
-@param index
-@param cblksty
-@param first
-*/
-static OPJ_BOOL opj_t2_init_seg(opj_tcd_cblk_dec_t* cblk,
- OPJ_UINT32 index,
- OPJ_UINT32 cblksty,
- OPJ_UINT32 first);
-
-/*@}*/
-
-/*@}*/
-
-/* ----------------------------------------------------------------------- */
-
-/* #define RESTART 0x04 */
-static void opj_t2_putcommacode(opj_bio_t *bio, OPJ_INT32 n)
-{
- while (--n >= 0) {
- opj_bio_putbit(bio, 1);
- }
- opj_bio_putbit(bio, 0);
-}
-
-static OPJ_UINT32 opj_t2_getcommacode(opj_bio_t *bio)
-{
- OPJ_UINT32 n = 0;
- while (opj_bio_read(bio, 1)) {
- ++n;
- }
- return n;
-}
-
-static void opj_t2_putnumpasses(opj_bio_t *bio, OPJ_UINT32 n)
-{
- if (n == 1) {
- opj_bio_putbit(bio, 0);
- } else if (n == 2) {
- opj_bio_write(bio, 2, 2);
- } else if (n <= 5) {
- opj_bio_write(bio, 0xc | (n - 3), 4);
- } else if (n <= 36) {
- opj_bio_write(bio, 0x1e0 | (n - 6), 9);
- } else if (n <= 164) {
- opj_bio_write(bio, 0xff80 | (n - 37), 16);
- }
-}
-
-static OPJ_UINT32 opj_t2_getnumpasses(opj_bio_t *bio)
-{
- OPJ_UINT32 n;
- if (!opj_bio_read(bio, 1)) {
- return 1;
- }
- if (!opj_bio_read(bio, 1)) {
- return 2;
- }
- if ((n = opj_bio_read(bio, 2)) != 3) {
- return (3 + n);
- }
- if ((n = opj_bio_read(bio, 5)) != 31) {
- return (6 + n);
- }
- return (37 + opj_bio_read(bio, 7));
-}
-
-/* ----------------------------------------------------------------------- */
-
-OPJ_BOOL opj_t2_encode_packets(opj_t2_t* p_t2,
- OPJ_UINT32 p_tile_no,
- opj_tcd_tile_t *p_tile,
- OPJ_UINT32 p_maxlayers,
- OPJ_BYTE *p_dest,
- OPJ_UINT32 * p_data_written,
- OPJ_UINT32 p_max_len,
- opj_codestream_info_t *cstr_info,
- opj_tcd_marker_info_t* p_marker_info,
- OPJ_UINT32 p_tp_num,
- OPJ_INT32 p_tp_pos,
- OPJ_UINT32 p_pino,
- J2K_T2_MODE p_t2_mode,
- opj_event_mgr_t *p_manager)
-{
- OPJ_BYTE *l_current_data = p_dest;
- OPJ_UINT32 l_nb_bytes = 0;
- OPJ_UINT32 compno;
- OPJ_UINT32 poc;
- opj_pi_iterator_t *l_pi = 00;
- opj_pi_iterator_t *l_current_pi = 00;
- opj_image_t *l_image = p_t2->image;
- opj_cp_t *l_cp = p_t2->cp;
- opj_tcp_t *l_tcp = &l_cp->tcps[p_tile_no];
- OPJ_UINT32 pocno = (l_cp->rsiz == OPJ_PROFILE_CINEMA_4K) ? 2 : 1;
- OPJ_UINT32 l_max_comp = l_cp->m_specific_param.m_enc.m_max_comp_size > 0 ?
- l_image->numcomps : 1;
- OPJ_UINT32 l_nb_pocs = l_tcp->numpocs + 1;
-
- l_pi = opj_pi_initialise_encode(l_image, l_cp, p_tile_no, p_t2_mode, p_manager);
- if (!l_pi) {
- return OPJ_FALSE;
- }
-
- * p_data_written = 0;
-
- if (p_t2_mode == THRESH_CALC) { /* Calculating threshold */
- l_current_pi = l_pi;
-
- for (compno = 0; compno < l_max_comp; ++compno) {
- OPJ_UINT32 l_comp_len = 0;
- l_current_pi = l_pi;
-
- for (poc = 0; poc < pocno ; ++poc) {
- OPJ_UINT32 l_tp_num = compno;
-
- /* TODO MSD : check why this function cannot fail (cf. v1) */
- opj_pi_create_encode(l_pi, l_cp, p_tile_no, poc, l_tp_num, p_tp_pos, p_t2_mode);
-
- if (l_current_pi->poc.prg == OPJ_PROG_UNKNOWN) {
- /* TODO ADE : add an error */
- opj_pi_destroy(l_pi, l_nb_pocs);
- return OPJ_FALSE;
- }
- while (opj_pi_next(l_current_pi)) {
- if (l_current_pi->layno < p_maxlayers) {
- l_nb_bytes = 0;
-
- if (! opj_t2_encode_packet(p_tile_no, p_tile, l_tcp, l_current_pi,
- l_current_data, &l_nb_bytes,
- p_max_len, cstr_info,
- p_t2_mode,
- p_manager)) {
- opj_pi_destroy(l_pi, l_nb_pocs);
- return OPJ_FALSE;
- }
-
- l_comp_len += l_nb_bytes;
- l_current_data += l_nb_bytes;
- p_max_len -= l_nb_bytes;
-
- * p_data_written += l_nb_bytes;
- }
- }
-
- if (l_cp->m_specific_param.m_enc.m_max_comp_size) {
- if (l_comp_len > l_cp->m_specific_param.m_enc.m_max_comp_size) {
- opj_pi_destroy(l_pi, l_nb_pocs);
- return OPJ_FALSE;
- }
- }
-
- ++l_current_pi;
- }
- }
- } else { /* t2_mode == FINAL_PASS */
- opj_pi_create_encode(l_pi, l_cp, p_tile_no, p_pino, p_tp_num, p_tp_pos,
- p_t2_mode);
-
- l_current_pi = &l_pi[p_pino];
- if (l_current_pi->poc.prg == OPJ_PROG_UNKNOWN) {
- /* TODO ADE : add an error */
- opj_pi_destroy(l_pi, l_nb_pocs);
- return OPJ_FALSE;
- }
-
- if (p_marker_info && p_marker_info->need_PLT) {
- /* One time use intended */
- assert(p_marker_info->packet_count == 0);
- assert(p_marker_info->p_packet_size == NULL);
-
- p_marker_info->p_packet_size = (OPJ_UINT32*) opj_malloc(
- opj_get_encoding_packet_count(l_image, l_cp, p_tile_no) * sizeof(OPJ_UINT32));
- if (p_marker_info->p_packet_size == NULL) {
- opj_pi_destroy(l_pi, l_nb_pocs);
- return OPJ_FALSE;
- }
- }
-
- while (opj_pi_next(l_current_pi)) {
- if (l_current_pi->layno < p_maxlayers) {
- l_nb_bytes = 0;
-
- if (! opj_t2_encode_packet(p_tile_no, p_tile, l_tcp, l_current_pi,
- l_current_data, &l_nb_bytes, p_max_len,
- cstr_info, p_t2_mode, p_manager)) {
- opj_pi_destroy(l_pi, l_nb_pocs);
- return OPJ_FALSE;
- }
-
- l_current_data += l_nb_bytes;
- p_max_len -= l_nb_bytes;
-
- * p_data_written += l_nb_bytes;
-
- if (p_marker_info && p_marker_info->need_PLT) {
- p_marker_info->p_packet_size[p_marker_info->packet_count] = l_nb_bytes;
- p_marker_info->packet_count ++;
- }
-
- /* INDEX >> */
- if (cstr_info) {
- if (cstr_info->index_write) {
- opj_tile_info_t *info_TL = &cstr_info->tile[p_tile_no];
- opj_packet_info_t *info_PK = &info_TL->packet[cstr_info->packno];
- if (!cstr_info->packno) {
- info_PK->start_pos = info_TL->end_header + 1;
- } else {
- info_PK->start_pos = ((l_cp->m_specific_param.m_enc.m_tp_on | l_tcp->POC) &&
- info_PK->start_pos) ? info_PK->start_pos : info_TL->packet[cstr_info->packno -
- 1].end_pos + 1;
- }
- info_PK->end_pos = info_PK->start_pos + l_nb_bytes - 1;
- info_PK->end_ph_pos += info_PK->start_pos -
- 1; /* End of packet header which now only represents the distance
- to start of packet is incremented by value of start of packet*/
- }
-
- cstr_info->packno++;
- }
- /* << INDEX */
- ++p_tile->packno;
- }
- }
- }
-
- opj_pi_destroy(l_pi, l_nb_pocs);
-
- return OPJ_TRUE;
-}
-
-/* see issue 80 */
-#if 0
-#define JAS_FPRINTF fprintf
-#else
-/* issue 290 */
-static void opj_null_jas_fprintf(FILE* file, const char * format, ...)
-{
- (void)file;
- (void)format;
-}
-#define JAS_FPRINTF opj_null_jas_fprintf
-#endif
-
-OPJ_BOOL opj_t2_decode_packets(opj_tcd_t* tcd,
- opj_t2_t *p_t2,
- OPJ_UINT32 p_tile_no,
- opj_tcd_tile_t *p_tile,
- OPJ_BYTE *p_src,
- OPJ_UINT32 * p_data_read,
- OPJ_UINT32 p_max_len,
- opj_codestream_index_t *p_cstr_index,
- opj_event_mgr_t *p_manager)
-{
- OPJ_BYTE *l_current_data = p_src;
- opj_pi_iterator_t *l_pi = 00;
- OPJ_UINT32 pino;
- opj_image_t *l_image = p_t2->image;
- opj_cp_t *l_cp = p_t2->cp;
- opj_tcp_t *l_tcp = &(p_t2->cp->tcps[p_tile_no]);
- OPJ_UINT32 l_nb_bytes_read;
- OPJ_UINT32 l_nb_pocs = l_tcp->numpocs + 1;
- opj_pi_iterator_t *l_current_pi = 00;
-#ifdef TODO_MSD
- OPJ_UINT32 curtp = 0;
- OPJ_UINT32 tp_start_packno;
-#endif
- opj_packet_info_t *l_pack_info = 00;
- opj_image_comp_t* l_img_comp = 00;
-
- OPJ_ARG_NOT_USED(p_cstr_index);
-
-#ifdef TODO_MSD
- if (p_cstr_index) {
- l_pack_info = p_cstr_index->tile_index[p_tile_no].packet;
- }
-#endif
-
- /* create a packet iterator */
- l_pi = opj_pi_create_decode(l_image, l_cp, p_tile_no, p_manager);
- if (!l_pi) {
- return OPJ_FALSE;
- }
-
-
- l_current_pi = l_pi;
-
- for (pino = 0; pino <= l_tcp->numpocs; ++pino) {
-
- /* if the resolution needed is too low, one dim of the tilec could be equal to zero
- * and no packets are used to decode this resolution and
- * l_current_pi->resno is always >= p_tile->comps[l_current_pi->compno].minimum_num_resolutions
- * and no l_img_comp->resno_decoded are computed
- */
- OPJ_BOOL* first_pass_failed = NULL;
-
- if (l_current_pi->poc.prg == OPJ_PROG_UNKNOWN) {
- /* TODO ADE : add an error */
- opj_pi_destroy(l_pi, l_nb_pocs);
- return OPJ_FALSE;
- }
-
- first_pass_failed = (OPJ_BOOL*)opj_malloc(l_image->numcomps * sizeof(OPJ_BOOL));
- if (!first_pass_failed) {
- opj_pi_destroy(l_pi, l_nb_pocs);
- return OPJ_FALSE;
- }
- memset(first_pass_failed, OPJ_TRUE, l_image->numcomps * sizeof(OPJ_BOOL));
-
- while (opj_pi_next(l_current_pi)) {
- OPJ_BOOL skip_packet = OPJ_FALSE;
- JAS_FPRINTF(stderr,
- "packet offset=00000166 prg=%d cmptno=%02d rlvlno=%02d prcno=%03d lyrno=%02d\n\n",
- l_current_pi->poc.prg1, l_current_pi->compno, l_current_pi->resno,
- l_current_pi->precno, l_current_pi->layno);
-
- /* If the packet layer is greater or equal than the maximum */
- /* number of layers, skip the packet */
- if (l_current_pi->layno >= l_tcp->num_layers_to_decode) {
- skip_packet = OPJ_TRUE;
- }
- /* If the packet resolution number is greater than the minimum */
- /* number of resolution allowed, skip the packet */
- else if (l_current_pi->resno >=
- p_tile->comps[l_current_pi->compno].minimum_num_resolutions) {
- skip_packet = OPJ_TRUE;
- } else {
- /* If no precincts of any band intersects the area of interest, */
- /* skip the packet */
- OPJ_UINT32 bandno;
- opj_tcd_tilecomp_t *tilec = &p_tile->comps[l_current_pi->compno];
- opj_tcd_resolution_t *res = &tilec->resolutions[l_current_pi->resno];
-
- skip_packet = OPJ_TRUE;
- for (bandno = 0; bandno < res->numbands; ++bandno) {
- opj_tcd_band_t* band = &res->bands[bandno];
- opj_tcd_precinct_t* prec = &band->precincts[l_current_pi->precno];
-
- if (opj_tcd_is_subband_area_of_interest(tcd,
- l_current_pi->compno,
- l_current_pi->resno,
- band->bandno,
- (OPJ_UINT32)prec->x0,
- (OPJ_UINT32)prec->y0,
- (OPJ_UINT32)prec->x1,
- (OPJ_UINT32)prec->y1)) {
- skip_packet = OPJ_FALSE;
- break;
- }
- }
- /*
- printf("packet cmptno=%02d rlvlno=%02d prcno=%03d lyrno=%02d -> %s\n",
- l_current_pi->compno, l_current_pi->resno,
- l_current_pi->precno, l_current_pi->layno, skip_packet ? "skipped" : "kept");
- */
- }
- if (!skip_packet) {
- l_nb_bytes_read = 0;
-
- first_pass_failed[l_current_pi->compno] = OPJ_FALSE;
-
- if (! opj_t2_decode_packet(p_t2, p_tile, l_tcp, l_current_pi, l_current_data,
- &l_nb_bytes_read, p_max_len, l_pack_info, p_manager)) {
- opj_pi_destroy(l_pi, l_nb_pocs);
- opj_free(first_pass_failed);
- return OPJ_FALSE;
- }
-
- l_img_comp = &(l_image->comps[l_current_pi->compno]);
- l_img_comp->resno_decoded = opj_uint_max(l_current_pi->resno,
- l_img_comp->resno_decoded);
- } else {
- l_nb_bytes_read = 0;
- if (! opj_t2_skip_packet(p_t2, p_tile, l_tcp, l_current_pi, l_current_data,
- &l_nb_bytes_read, p_max_len, l_pack_info, p_manager)) {
- opj_pi_destroy(l_pi, l_nb_pocs);
- opj_free(first_pass_failed);
- return OPJ_FALSE;
- }
- }
-
- if (first_pass_failed[l_current_pi->compno]) {
- l_img_comp = &(l_image->comps[l_current_pi->compno]);
- if (l_img_comp->resno_decoded == 0) {
- l_img_comp->resno_decoded =
- p_tile->comps[l_current_pi->compno].minimum_num_resolutions - 1;
- }
- }
-
- l_current_data += l_nb_bytes_read;
- p_max_len -= l_nb_bytes_read;
-
- /* INDEX >> */
-#ifdef TODO_MSD
- if (p_cstr_info) {
- opj_tile_info_v2_t *info_TL = &p_cstr_info->tile[p_tile_no];
- opj_packet_info_t *info_PK = &info_TL->packet[p_cstr_info->packno];
- tp_start_packno = 0;
- if (!p_cstr_info->packno) {
- info_PK->start_pos = info_TL->end_header + 1;
- } else if (info_TL->packet[p_cstr_info->packno - 1].end_pos >=
- (OPJ_INT32)
- p_cstr_info->tile[p_tile_no].tp[curtp].tp_end_pos) { /* New tile part */
- info_TL->tp[curtp].tp_numpacks = p_cstr_info->packno -
- tp_start_packno; /* Number of packets in previous tile-part */
- tp_start_packno = p_cstr_info->packno;
- curtp++;
- info_PK->start_pos = p_cstr_info->tile[p_tile_no].tp[curtp].tp_end_header + 1;
- } else {
- info_PK->start_pos = (l_cp->m_specific_param.m_enc.m_tp_on &&
- info_PK->start_pos) ? info_PK->start_pos : info_TL->packet[p_cstr_info->packno -
- 1].end_pos + 1;
- }
- info_PK->end_pos = info_PK->start_pos + l_nb_bytes_read - 1;
- info_PK->end_ph_pos += info_PK->start_pos -
- 1; /* End of packet header which now only represents the distance */
- ++p_cstr_info->packno;
- }
-#endif
- /* << INDEX */
- }
- ++l_current_pi;
-
- opj_free(first_pass_failed);
- }
- /* INDEX >> */
-#ifdef TODO_MSD
- if
- (p_cstr_info) {
- p_cstr_info->tile[p_tile_no].tp[curtp].tp_numpacks = p_cstr_info->packno -
- tp_start_packno; /* Number of packets in last tile-part */
- }
-#endif
- /* << INDEX */
-
- /* don't forget to release pi */
- opj_pi_destroy(l_pi, l_nb_pocs);
- *p_data_read = (OPJ_UINT32)(l_current_data - p_src);
- return OPJ_TRUE;
-}
-
-/* ----------------------------------------------------------------------- */
-
-/**
- * Creates a Tier 2 handle
- *
- * @param p_image Source or destination image
- * @param p_cp Image coding parameters.
- * @return a new T2 handle if successful, NULL otherwise.
-*/
-opj_t2_t* opj_t2_create(opj_image_t *p_image, opj_cp_t *p_cp)
-{
- /* create the t2 structure */
- opj_t2_t *l_t2 = (opj_t2_t*)opj_calloc(1, sizeof(opj_t2_t));
- if (!l_t2) {
- return NULL;
- }
-
- l_t2->image = p_image;
- l_t2->cp = p_cp;
-
- return l_t2;
-}
-
-void opj_t2_destroy(opj_t2_t *t2)
-{
- if (t2) {
- opj_free(t2);
- }
-}
-
-static OPJ_BOOL opj_t2_decode_packet(opj_t2_t* p_t2,
- opj_tcd_tile_t *p_tile,
- opj_tcp_t *p_tcp,
- opj_pi_iterator_t *p_pi,
- OPJ_BYTE *p_src,
- OPJ_UINT32 * p_data_read,
- OPJ_UINT32 p_max_length,
- opj_packet_info_t *p_pack_info,
- opj_event_mgr_t *p_manager)
-{
- OPJ_BOOL l_read_data;
- OPJ_UINT32 l_nb_bytes_read = 0;
- OPJ_UINT32 l_nb_total_bytes_read = 0;
-
- *p_data_read = 0;
-
- if (! opj_t2_read_packet_header(p_t2, p_tile, p_tcp, p_pi, &l_read_data, p_src,
- &l_nb_bytes_read, p_max_length, p_pack_info, p_manager)) {
- return OPJ_FALSE;
- }
-
- p_src += l_nb_bytes_read;
- l_nb_total_bytes_read += l_nb_bytes_read;
- p_max_length -= l_nb_bytes_read;
-
- /* we should read data for the packet */
- if (l_read_data) {
- l_nb_bytes_read = 0;
-
- if (! opj_t2_read_packet_data(p_t2, p_tile, p_pi, p_src, &l_nb_bytes_read,
- p_max_length, p_pack_info, p_manager)) {
- return OPJ_FALSE;
- }
-
- l_nb_total_bytes_read += l_nb_bytes_read;
- }
-
- *p_data_read = l_nb_total_bytes_read;
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_t2_encode_packet(OPJ_UINT32 tileno,
- opj_tcd_tile_t * tile,
- opj_tcp_t * tcp,
- opj_pi_iterator_t *pi,
- OPJ_BYTE *dest,
- OPJ_UINT32 * p_data_written,
- OPJ_UINT32 length,
- opj_codestream_info_t *cstr_info,
- J2K_T2_MODE p_t2_mode,
- opj_event_mgr_t *p_manager)
-{
- OPJ_UINT32 bandno, cblkno;
- OPJ_BYTE* c = dest;
- OPJ_UINT32 l_nb_bytes;
- OPJ_UINT32 compno = pi->compno; /* component value */
- OPJ_UINT32 resno = pi->resno; /* resolution level value */
- OPJ_UINT32 precno = pi->precno; /* precinct value */
- OPJ_UINT32 layno = pi->layno; /* quality layer value */
- OPJ_UINT32 l_nb_blocks;
- opj_tcd_band_t *band = 00;
- opj_tcd_cblk_enc_t* cblk = 00;
- opj_tcd_pass_t *pass = 00;
-
- opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
- opj_tcd_resolution_t *res = &tilec->resolutions[resno];
-
- opj_bio_t *bio = 00; /* BIO component */
-#ifdef ENABLE_EMPTY_PACKET_OPTIMIZATION
- OPJ_BOOL packet_empty = OPJ_TRUE;
-#else
- OPJ_BOOL packet_empty = OPJ_FALSE;
-#endif
-
-#ifdef DEBUG_VERBOSE
- if (p_t2_mode == FINAL_PASS) {
- fprintf(stderr,
- "encode packet compono=%d, resno=%d, precno=%d, layno=%d\n",
- compno, resno, precno, layno);
- }
-#endif
-
- /* <SOP 0xff91> */
- if (tcp->csty & J2K_CP_CSTY_SOP) {
- if (length < 6) {
- if (p_t2_mode == FINAL_PASS) {
- opj_event_msg(p_manager, EVT_ERROR,
- "opj_t2_encode_packet(): only %u bytes remaining in "
- "output buffer. %u needed.\n",
- length, 6);
- }
- return OPJ_FALSE;
- }
- c[0] = 255;
- c[1] = 145;
- c[2] = 0;
- c[3] = 4;
-#if 0
- c[4] = (tile->packno % 65536) / 256;
- c[5] = (tile->packno % 65536) % 256;
-#else
- c[4] = (tile->packno >> 8) & 0xff; /* packno is uint32_t */
- c[5] = tile->packno & 0xff;
-#endif
- c += 6;
- length -= 6;
- }
- /* </SOP> */
-
- if (!layno) {
- band = res->bands;
-
- for (bandno = 0; bandno < res->numbands; ++bandno, ++band) {
- opj_tcd_precinct_t *prc;
-
- /* Skip empty bands */
- if (opj_tcd_is_band_empty(band)) {
- continue;
- }
-
- /* Avoid out of bounds access of https://github.com/uclouvain/openjpeg/issues/1294 */
- /* but likely not a proper fix. */
- if (precno >= res->pw * res->ph) {
- opj_event_msg(p_manager, EVT_ERROR,
- "opj_t2_encode_packet(): accessing precno=%u >= %u\n",
- precno, res->pw * res->ph);
- return OPJ_FALSE;
- }
-
- prc = &band->precincts[precno];
- opj_tgt_reset(prc->incltree);
- opj_tgt_reset(prc->imsbtree);
-
- l_nb_blocks = prc->cw * prc->ch;
- for (cblkno = 0; cblkno < l_nb_blocks; ++cblkno) {
- cblk = &prc->cblks.enc[cblkno];
-
- cblk->numpasses = 0;
- opj_tgt_setvalue(prc->imsbtree, cblkno, band->numbps - (OPJ_INT32)cblk->numbps);
- }
- }
- }
-
- bio = opj_bio_create();
- if (!bio) {
- /* FIXME event manager error callback */
- return OPJ_FALSE;
- }
- opj_bio_init_enc(bio, c, length);
-
-#ifdef ENABLE_EMPTY_PACKET_OPTIMIZATION
- /* WARNING: this code branch is disabled, since it has been reported that */
- /* such packets cause decoding issues with cinema J2K hardware */
- /* decoders: https://groups.google.com/forum/#!topic/openjpeg/M7M_fLX_Bco */
-
- /* Check if the packet is empty */
- /* Note: we could also skip that step and always write a packet header */
- band = res->bands;
- for (bandno = 0; bandno < res->numbands; ++bandno, ++band) {
- opj_tcd_precinct_t *prc;
- /* Skip empty bands */
- if (opj_tcd_is_band_empty(band)) {
- continue;
- }
-
- prc = &band->precincts[precno];
- l_nb_blocks = prc->cw * prc->ch;
- cblk = prc->cblks.enc;
- for (cblkno = 0; cblkno < l_nb_blocks; cblkno++, ++cblk) {
- opj_tcd_layer_t *layer = &cblk->layers[layno];
-
- /* if cblk not included, go to the next cblk */
- if (!layer->numpasses) {
- continue;
- }
- packet_empty = OPJ_FALSE;
- break;
- }
- if (!packet_empty) {
- break;
- }
- }
-#endif
- opj_bio_putbit(bio, packet_empty ? 0 : 1); /* Empty header bit */
-
- /* Writing Packet header */
- band = res->bands;
- for (bandno = 0; !packet_empty &&
- bandno < res->numbands; ++bandno, ++band) {
- opj_tcd_precinct_t *prc;
-
- /* Skip empty bands */
- if (opj_tcd_is_band_empty(band)) {
- continue;
- }
-
- /* Avoid out of bounds access of https://github.com/uclouvain/openjpeg/issues/1297 */
- /* but likely not a proper fix. */
- if (precno >= res->pw * res->ph) {
- opj_event_msg(p_manager, EVT_ERROR,
- "opj_t2_encode_packet(): accessing precno=%u >= %u\n",
- precno, res->pw * res->ph);
- return OPJ_FALSE;
- }
-
- prc = &band->precincts[precno];
- l_nb_blocks = prc->cw * prc->ch;
- cblk = prc->cblks.enc;
-
- for (cblkno = 0; cblkno < l_nb_blocks; ++cblkno) {
- opj_tcd_layer_t *layer = &cblk->layers[layno];
-
- if (!cblk->numpasses && layer->numpasses) {
- opj_tgt_setvalue(prc->incltree, cblkno, (OPJ_INT32)layno);
- }
-
- ++cblk;
- }
-
- cblk = prc->cblks.enc;
- for (cblkno = 0; cblkno < l_nb_blocks; cblkno++) {
- opj_tcd_layer_t *layer = &cblk->layers[layno];
- OPJ_UINT32 increment = 0;
- OPJ_UINT32 nump = 0;
- OPJ_UINT32 len = 0, passno;
- OPJ_UINT32 l_nb_passes;
-
- /* cblk inclusion bits */
- if (!cblk->numpasses) {
- opj_tgt_encode(bio, prc->incltree, cblkno, (OPJ_INT32)(layno + 1));
- } else {
- opj_bio_putbit(bio, layer->numpasses != 0);
- }
-
- /* if cblk not included, go to the next cblk */
- if (!layer->numpasses) {
- ++cblk;
- continue;
- }
-
- /* if first instance of cblk --> zero bit-planes information */
- if (!cblk->numpasses) {
- cblk->numlenbits = 3;
- opj_tgt_encode(bio, prc->imsbtree, cblkno, 999);
- }
-
- /* number of coding passes included */
- opj_t2_putnumpasses(bio, layer->numpasses);
- l_nb_passes = cblk->numpasses + layer->numpasses;
- pass = cblk->passes + cblk->numpasses;
-
- /* computation of the increase of the length indicator and insertion in the header */
- for (passno = cblk->numpasses; passno < l_nb_passes; ++passno) {
- ++nump;
- len += pass->len;
-
- if (pass->term || passno == (cblk->numpasses + layer->numpasses) - 1) {
- increment = (OPJ_UINT32)opj_int_max((OPJ_INT32)increment,
- opj_int_floorlog2((OPJ_INT32)len) + 1
- - ((OPJ_INT32)cblk->numlenbits + opj_int_floorlog2((OPJ_INT32)nump)));
- len = 0;
- nump = 0;
- }
-
- ++pass;
- }
- opj_t2_putcommacode(bio, (OPJ_INT32)increment);
-
- /* computation of the new Length indicator */
- cblk->numlenbits += increment;
-
- pass = cblk->passes + cblk->numpasses;
- /* insertion of the codeword segment length */
- for (passno = cblk->numpasses; passno < l_nb_passes; ++passno) {
- nump++;
- len += pass->len;
-
- if (pass->term || passno == (cblk->numpasses + layer->numpasses) - 1) {
- opj_bio_write(bio, (OPJ_UINT32)len,
- cblk->numlenbits + (OPJ_UINT32)opj_int_floorlog2((OPJ_INT32)nump));
- len = 0;
- nump = 0;
- }
- ++pass;
- }
-
- ++cblk;
- }
- }
-
- if (!opj_bio_flush(bio)) {
- opj_bio_destroy(bio);
- return OPJ_FALSE; /* modified to eliminate longjmp !! */
- }
-
- l_nb_bytes = (OPJ_UINT32)opj_bio_numbytes(bio);
- c += l_nb_bytes;
- length -= l_nb_bytes;
-
- opj_bio_destroy(bio);
-
- /* <EPH 0xff92> */
- if (tcp->csty & J2K_CP_CSTY_EPH) {
- if (length < 2) {
- if (p_t2_mode == FINAL_PASS) {
- opj_event_msg(p_manager, EVT_ERROR,
- "opj_t2_encode_packet(): only %u bytes remaining in "
- "output buffer. %u needed.\n",
- length, 2);
- }
- return OPJ_FALSE;
- }
- c[0] = 255;
- c[1] = 146;
- c += 2;
- length -= 2;
- }
- /* </EPH> */
-
- /* << INDEX */
- /* End of packet header position. Currently only represents the distance to start of packet
- Will be updated later by incrementing with packet start value*/
- if (cstr_info && cstr_info->index_write) {
- opj_packet_info_t *info_PK = &cstr_info->tile[tileno].packet[cstr_info->packno];
- info_PK->end_ph_pos = (OPJ_INT32)(c - dest);
- }
- /* INDEX >> */
-
- /* Writing the packet body */
- band = res->bands;
- for (bandno = 0; !packet_empty && bandno < res->numbands; bandno++, ++band) {
- opj_tcd_precinct_t *prc;
-
- /* Skip empty bands */
- if (opj_tcd_is_band_empty(band)) {
- continue;
- }
-
- prc = &band->precincts[precno];
- l_nb_blocks = prc->cw * prc->ch;
- cblk = prc->cblks.enc;
-
- for (cblkno = 0; cblkno < l_nb_blocks; ++cblkno) {
- opj_tcd_layer_t *layer = &cblk->layers[layno];
-
- if (!layer->numpasses) {
- ++cblk;
- continue;
- }
-
- if (layer->len > length) {
- if (p_t2_mode == FINAL_PASS) {
- opj_event_msg(p_manager, EVT_ERROR,
- "opj_t2_encode_packet(): only %u bytes remaining in "
- "output buffer. %u needed.\n",
- length, layer->len);
- }
- return OPJ_FALSE;
- }
-
- if (p_t2_mode == FINAL_PASS) {
- memcpy(c, layer->data, layer->len);
- }
- cblk->numpasses += layer->numpasses;
- c += layer->len;
- length -= layer->len;
-
- /* << INDEX */
- if (cstr_info && cstr_info->index_write) {
- opj_packet_info_t *info_PK = &cstr_info->tile[tileno].packet[cstr_info->packno];
- info_PK->disto += layer->disto;
- if (cstr_info->D_max < info_PK->disto) {
- cstr_info->D_max = info_PK->disto;
- }
- }
-
- ++cblk;
- /* INDEX >> */
- }
- }
-
- assert(c >= dest);
- * p_data_written += (OPJ_UINT32)(c - dest);
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_t2_skip_packet(opj_t2_t* p_t2,
- opj_tcd_tile_t *p_tile,
- opj_tcp_t *p_tcp,
- opj_pi_iterator_t *p_pi,
- OPJ_BYTE *p_src,
- OPJ_UINT32 * p_data_read,
- OPJ_UINT32 p_max_length,
- opj_packet_info_t *p_pack_info,
- opj_event_mgr_t *p_manager)
-{
- OPJ_BOOL l_read_data;
- OPJ_UINT32 l_nb_bytes_read = 0;
- OPJ_UINT32 l_nb_total_bytes_read = 0;
-
- *p_data_read = 0;
-
- if (! opj_t2_read_packet_header(p_t2, p_tile, p_tcp, p_pi, &l_read_data, p_src,
- &l_nb_bytes_read, p_max_length, p_pack_info, p_manager)) {
- return OPJ_FALSE;
- }
-
- p_src += l_nb_bytes_read;
- l_nb_total_bytes_read += l_nb_bytes_read;
- p_max_length -= l_nb_bytes_read;
-
- /* we should read data for the packet */
- if (l_read_data) {
- l_nb_bytes_read = 0;
-
- if (! opj_t2_skip_packet_data(p_t2, p_tile, p_pi, &l_nb_bytes_read,
- p_max_length, p_pack_info, p_manager)) {
- return OPJ_FALSE;
- }
-
- l_nb_total_bytes_read += l_nb_bytes_read;
- }
- *p_data_read = l_nb_total_bytes_read;
-
- return OPJ_TRUE;
-}
-
-
-static OPJ_BOOL opj_t2_read_packet_header(opj_t2_t* p_t2,
- opj_tcd_tile_t *p_tile,
- opj_tcp_t *p_tcp,
- opj_pi_iterator_t *p_pi,
- OPJ_BOOL * p_is_data_present,
- OPJ_BYTE *p_src_data,
- OPJ_UINT32 * p_data_read,
- OPJ_UINT32 p_max_length,
- opj_packet_info_t *p_pack_info,
- opj_event_mgr_t *p_manager)
-
-{
- /* loop */
- OPJ_UINT32 bandno, cblkno;
- OPJ_UINT32 l_nb_code_blocks;
- OPJ_UINT32 l_remaining_length;
- OPJ_UINT32 l_header_length;
- OPJ_UINT32 * l_modified_length_ptr = 00;
- OPJ_BYTE *l_current_data = p_src_data;
- opj_cp_t *l_cp = p_t2->cp;
- opj_bio_t *l_bio = 00; /* BIO component */
- opj_tcd_band_t *l_band = 00;
- opj_tcd_cblk_dec_t* l_cblk = 00;
- opj_tcd_resolution_t* l_res =
- &p_tile->comps[p_pi->compno].resolutions[p_pi->resno];
-
- OPJ_BYTE *l_header_data = 00;
- OPJ_BYTE **l_header_data_start = 00;
-
- OPJ_UINT32 l_present;
-
- if (p_pi->layno == 0) {
- l_band = l_res->bands;
-
- /* reset tagtrees */
- for (bandno = 0; bandno < l_res->numbands; ++bandno) {
- if (!opj_tcd_is_band_empty(l_band)) {
- opj_tcd_precinct_t *l_prc = &l_band->precincts[p_pi->precno];
- if (!(p_pi->precno < (l_band->precincts_data_size / sizeof(
- opj_tcd_precinct_t)))) {
- opj_event_msg(p_manager, EVT_ERROR, "Invalid precinct\n");
- return OPJ_FALSE;
- }
-
-
- opj_tgt_reset(l_prc->incltree);
- opj_tgt_reset(l_prc->imsbtree);
- l_cblk = l_prc->cblks.dec;
-
- l_nb_code_blocks = l_prc->cw * l_prc->ch;
- for (cblkno = 0; cblkno < l_nb_code_blocks; ++cblkno) {
- l_cblk->numsegs = 0;
- l_cblk->real_num_segs = 0;
- ++l_cblk;
- }
- }
-
- ++l_band;
- }
- }
-
- /* SOP markers */
-
- if (p_tcp->csty & J2K_CP_CSTY_SOP) {
- /* SOP markers are allowed (i.e. optional), just warn */
- if (p_max_length < 6) {
- opj_event_msg(p_manager, EVT_WARNING,
- "Not enough space for expected SOP marker\n");
- } else if ((*l_current_data) != 0xff || (*(l_current_data + 1) != 0x91)) {
- opj_event_msg(p_manager, EVT_WARNING, "Expected SOP marker\n");
- } else {
- l_current_data += 6;
- }
-
- /** TODO : check the Nsop value */
- }
-
- /*
- When the marker PPT/PPM is used the packet header are store in PPT/PPM marker
- This part deal with this characteristic
- step 1: Read packet header in the saved structure
- step 2: Return to codestream for decoding
- */
-
- l_bio = opj_bio_create();
- if (! l_bio) {
- return OPJ_FALSE;
- }
-
- if (l_cp->ppm == 1) { /* PPM */
- l_header_data_start = &l_cp->ppm_data;
- l_header_data = *l_header_data_start;
- l_modified_length_ptr = &(l_cp->ppm_len);
-
- } else if (p_tcp->ppt == 1) { /* PPT */
- l_header_data_start = &(p_tcp->ppt_data);
- l_header_data = *l_header_data_start;
- l_modified_length_ptr = &(p_tcp->ppt_len);
- } else { /* Normal Case */
- l_header_data_start = &(l_current_data);
- l_header_data = *l_header_data_start;
- l_remaining_length = (OPJ_UINT32)(p_src_data + p_max_length - l_header_data);
- l_modified_length_ptr = &(l_remaining_length);
- }
-
- opj_bio_init_dec(l_bio, l_header_data, *l_modified_length_ptr);
-
- l_present = opj_bio_read(l_bio, 1);
- JAS_FPRINTF(stderr, "present=%d \n", l_present);
- if (!l_present) {
- /* TODO MSD: no test to control the output of this function*/
- opj_bio_inalign(l_bio);
- l_header_data += opj_bio_numbytes(l_bio);
- opj_bio_destroy(l_bio);
-
- /* EPH markers */
- if (p_tcp->csty & J2K_CP_CSTY_EPH) {
- /* EPH markers are required */
- if ((*l_modified_length_ptr - (OPJ_UINT32)(l_header_data -
- *l_header_data_start)) < 2U) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Not enough space for required EPH marker\n");
- return OPJ_FALSE;
- } else if ((*l_header_data) != 0xff || (*(l_header_data + 1) != 0x92)) {
- opj_event_msg(p_manager, EVT_ERROR, "Expected EPH marker\n");
- return OPJ_FALSE;
- } else {
- l_header_data += 2;
- }
- }
-
- l_header_length = (OPJ_UINT32)(l_header_data - *l_header_data_start);
- *l_modified_length_ptr -= l_header_length;
- *l_header_data_start += l_header_length;
-
- /* << INDEX */
- /* End of packet header position. Currently only represents the distance to start of packet
- Will be updated later by incrementing with packet start value */
- if (p_pack_info) {
- p_pack_info->end_ph_pos = (OPJ_INT32)(l_current_data - p_src_data);
- }
- /* INDEX >> */
-
- * p_is_data_present = OPJ_FALSE;
- *p_data_read = (OPJ_UINT32)(l_current_data - p_src_data);
- return OPJ_TRUE;
- }
-
- l_band = l_res->bands;
- for (bandno = 0; bandno < l_res->numbands; ++bandno, ++l_band) {
- opj_tcd_precinct_t *l_prc = &(l_band->precincts[p_pi->precno]);
-
- if (opj_tcd_is_band_empty(l_band)) {
- continue;
- }
-
- l_nb_code_blocks = l_prc->cw * l_prc->ch;
- l_cblk = l_prc->cblks.dec;
- for (cblkno = 0; cblkno < l_nb_code_blocks; cblkno++) {
- OPJ_UINT32 l_included, l_increment, l_segno;
- OPJ_INT32 n;
-
- /* if cblk not yet included before --> inclusion tagtree */
- if (!l_cblk->numsegs) {
- l_included = opj_tgt_decode(l_bio, l_prc->incltree, cblkno,
- (OPJ_INT32)(p_pi->layno + 1));
- /* else one bit */
- } else {
- l_included = opj_bio_read(l_bio, 1);
- }
-
- /* if cblk not included */
- if (!l_included) {
- l_cblk->numnewpasses = 0;
- ++l_cblk;
- JAS_FPRINTF(stderr, "included=%d \n", l_included);
- continue;
- }
-
- /* if cblk not yet included --> zero-bitplane tagtree */
- if (!l_cblk->numsegs) {
- OPJ_UINT32 i = 0;
-
- while (!opj_tgt_decode(l_bio, l_prc->imsbtree, cblkno, (OPJ_INT32)i)) {
- ++i;
- }
- l_cblk->Mb = (OPJ_UINT32)l_band->numbps;
- if ((OPJ_UINT32)l_band->numbps + 1 < i) {
- /* Not totally sure what we should do in that situation,
- * but that avoids the integer overflow of
- * https://github.com/uclouvain/openjpeg/pull/1488
- * while keeping the regression test suite happy.
- */
- l_cblk->numbps = (OPJ_UINT32)(l_band->numbps + 1 - (int)i);
- } else {
- l_cblk->numbps = (OPJ_UINT32)l_band->numbps + 1 - i;
- }
- l_cblk->numlenbits = 3;
- }
-
- /* number of coding passes */
- l_cblk->numnewpasses = opj_t2_getnumpasses(l_bio);
- l_increment = opj_t2_getcommacode(l_bio);
-
- /* length indicator increment */
- l_cblk->numlenbits += l_increment;
- l_segno = 0;
-
- if (!l_cblk->numsegs) {
- if (! opj_t2_init_seg(l_cblk, l_segno, p_tcp->tccps[p_pi->compno].cblksty, 1)) {
- opj_bio_destroy(l_bio);
- return OPJ_FALSE;
- }
- } else {
- l_segno = l_cblk->numsegs - 1;
- if (l_cblk->segs[l_segno].numpasses == l_cblk->segs[l_segno].maxpasses) {
- ++l_segno;
- if (! opj_t2_init_seg(l_cblk, l_segno, p_tcp->tccps[p_pi->compno].cblksty, 0)) {
- opj_bio_destroy(l_bio);
- return OPJ_FALSE;
- }
- }
- }
- n = (OPJ_INT32)l_cblk->numnewpasses;
-
- if ((p_tcp->tccps[p_pi->compno].cblksty & J2K_CCP_CBLKSTY_HT) != 0)
- do {
- OPJ_UINT32 bit_number;
- l_cblk->segs[l_segno].numnewpasses = l_segno == 0 ? 1 : (OPJ_UINT32)n;
- bit_number = l_cblk->numlenbits + opj_uint_floorlog2(
- l_cblk->segs[l_segno].numnewpasses);
- if (bit_number > 32) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Invalid bit number %d in opj_t2_read_packet_header()\n",
- bit_number);
- opj_bio_destroy(l_bio);
- return OPJ_FALSE;
- }
- l_cblk->segs[l_segno].newlen = opj_bio_read(l_bio, bit_number);
- JAS_FPRINTF(stderr, "included=%d numnewpasses=%d increment=%d len=%d \n",
- l_included, l_cblk->segs[l_segno].numnewpasses, l_increment,
- l_cblk->segs[l_segno].newlen);
-
- n -= (OPJ_INT32)l_cblk->segs[l_segno].numnewpasses;
- if (n > 0) {
- ++l_segno;
-
- if (! opj_t2_init_seg(l_cblk, l_segno, p_tcp->tccps[p_pi->compno].cblksty, 0)) {
- opj_bio_destroy(l_bio);
- return OPJ_FALSE;
- }
- }
- } while (n > 0);
- else
- do {
- OPJ_UINT32 bit_number;
- l_cblk->segs[l_segno].numnewpasses = (OPJ_UINT32)opj_int_min((OPJ_INT32)(
- l_cblk->segs[l_segno].maxpasses - l_cblk->segs[l_segno].numpasses), n);
- bit_number = l_cblk->numlenbits + opj_uint_floorlog2(
- l_cblk->segs[l_segno].numnewpasses);
- if (bit_number > 32) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Invalid bit number %d in opj_t2_read_packet_header()\n",
- bit_number);
- opj_bio_destroy(l_bio);
- return OPJ_FALSE;
- }
- l_cblk->segs[l_segno].newlen = opj_bio_read(l_bio, bit_number);
- JAS_FPRINTF(stderr, "included=%d numnewpasses=%d increment=%d len=%d \n",
- l_included, l_cblk->segs[l_segno].numnewpasses, l_increment,
- l_cblk->segs[l_segno].newlen);
-
- n -= (OPJ_INT32)l_cblk->segs[l_segno].numnewpasses;
- if (n > 0) {
- ++l_segno;
-
- if (! opj_t2_init_seg(l_cblk, l_segno, p_tcp->tccps[p_pi->compno].cblksty, 0)) {
- opj_bio_destroy(l_bio);
- return OPJ_FALSE;
- }
- }
- } while (n > 0);
-
- ++l_cblk;
- }
- }
-
- if (!opj_bio_inalign(l_bio)) {
- opj_bio_destroy(l_bio);
- return OPJ_FALSE;
- }
-
- l_header_data += opj_bio_numbytes(l_bio);
- opj_bio_destroy(l_bio);
-
- /* EPH markers */
- if (p_tcp->csty & J2K_CP_CSTY_EPH) {
- /* EPH markers are required */
- if ((*l_modified_length_ptr - (OPJ_UINT32)(l_header_data -
- *l_header_data_start)) < 2U) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Not enough space for required EPH marker\n");
- return OPJ_FALSE;
- } else if ((*l_header_data) != 0xff || (*(l_header_data + 1) != 0x92)) {
- opj_event_msg(p_manager, EVT_ERROR, "Expected EPH marker\n");
- return OPJ_FALSE;
- } else {
- l_header_data += 2;
- }
- }
-
- l_header_length = (OPJ_UINT32)(l_header_data - *l_header_data_start);
- JAS_FPRINTF(stderr, "hdrlen=%d \n", l_header_length);
- if (!l_header_length) {
- return OPJ_FALSE;
- }
- JAS_FPRINTF(stderr, "packet body\n");
- *l_modified_length_ptr -= l_header_length;
- *l_header_data_start += l_header_length;
-
- /* << INDEX */
- /* End of packet header position. Currently only represents the distance to start of packet
- Will be updated later by incrementing with packet start value */
- if (p_pack_info) {
- p_pack_info->end_ph_pos = (OPJ_INT32)(l_current_data - p_src_data);
- }
- /* INDEX >> */
-
- *p_is_data_present = OPJ_TRUE;
- *p_data_read = (OPJ_UINT32)(l_current_data - p_src_data);
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_t2_read_packet_data(opj_t2_t* p_t2,
- opj_tcd_tile_t *p_tile,
- opj_pi_iterator_t *p_pi,
- OPJ_BYTE *p_src_data,
- OPJ_UINT32 * p_data_read,
- OPJ_UINT32 p_max_length,
- opj_packet_info_t *pack_info,
- opj_event_mgr_t* p_manager)
-{
- OPJ_UINT32 bandno, cblkno;
- OPJ_UINT32 l_nb_code_blocks;
- OPJ_BYTE *l_current_data = p_src_data;
- opj_tcd_band_t *l_band = 00;
- opj_tcd_cblk_dec_t* l_cblk = 00;
- opj_tcd_resolution_t* l_res =
- &p_tile->comps[p_pi->compno].resolutions[p_pi->resno];
- OPJ_BOOL partial_buffer = OPJ_FALSE;
-
- OPJ_ARG_NOT_USED(p_t2);
- OPJ_ARG_NOT_USED(pack_info);
-
- l_band = l_res->bands;
- for (bandno = 0; bandno < l_res->numbands; ++bandno) {
- opj_tcd_precinct_t *l_prc = &l_band->precincts[p_pi->precno];
-
- if ((l_band->x1 - l_band->x0 == 0) || (l_band->y1 - l_band->y0 == 0)) {
- ++l_band;
- continue;
- }
-
- l_nb_code_blocks = l_prc->cw * l_prc->ch;
- l_cblk = l_prc->cblks.dec;
-
- for (cblkno = 0; cblkno < l_nb_code_blocks; ++cblkno, ++l_cblk) {
- opj_tcd_seg_t *l_seg = 00;
-
- if (!l_cblk->numnewpasses) {
- /* nothing to do */
- continue;
- }
-
- if (partial_buffer || l_cblk->corrupted) {
- /* if a previous segment in this packet couldn't be decoded,
- * or if this code block was corrupted in a previous layer,
- * then mark it as corrupted.
- */
- l_cblk->numchunks = 0;
- l_cblk->corrupted = OPJ_TRUE;
- continue;
- }
-
- if (!l_cblk->numsegs) {
- l_seg = l_cblk->segs;
- ++l_cblk->numsegs;
- } else {
- l_seg = &l_cblk->segs[l_cblk->numsegs - 1];
-
- if (l_seg->numpasses == l_seg->maxpasses) {
- ++l_seg;
- ++l_cblk->numsegs;
- }
- }
-
- do {
- /* Check possible overflow (on l_current_data only, assumes input args already checked) then size */
- if ((((OPJ_SIZE_T)l_current_data + (OPJ_SIZE_T)l_seg->newlen) <
- (OPJ_SIZE_T)l_current_data) ||
- (l_current_data + l_seg->newlen > p_src_data + p_max_length) ||
- (partial_buffer)) {
- if (p_t2->cp->strict) {
- opj_event_msg(p_manager, EVT_ERROR,
- "read: segment too long (%d) with max (%d) for codeblock %d (p=%d, b=%d, r=%d, c=%d)\n",
- l_seg->newlen, p_max_length, cblkno, p_pi->precno, bandno, p_pi->resno,
- p_pi->compno);
- return OPJ_FALSE;
- } else {
- opj_event_msg(p_manager, EVT_WARNING,
- "read: segment too long (%d) with max (%d) for codeblock %d (p=%d, b=%d, r=%d, c=%d)\n",
- l_seg->newlen, p_max_length, cblkno, p_pi->precno, bandno, p_pi->resno,
- p_pi->compno);
- /* skip this codeblock (and following ones in this
- * packet) since it is a partial read
- */
- partial_buffer = OPJ_TRUE;
- l_cblk->corrupted = OPJ_TRUE;
- l_cblk->numchunks = 0;
- break;
- }
- }
-
-#ifdef USE_JPWL
- /* we need here a j2k handle to verify if making a check to
- the validity of cblocks parameters is selected from user (-W) */
-
- /* let's check that we are not exceeding */
- if ((l_cblk->len + l_seg->newlen) > 8192) {
- opj_event_msg(p_manager, EVT_WARNING,
- "JPWL: segment too long (%d) for codeblock %d (p=%d, b=%d, r=%d, c=%d)\n",
- l_seg->newlen, cblkno, p_pi->precno, bandno, p_pi->resno, p_pi->compno);
- if (!JPWL_ASSUME) {
- opj_event_msg(p_manager, EVT_ERROR, "JPWL: giving up\n");
- return OPJ_FALSE;
- }
- l_seg->newlen = 8192 - l_cblk->len;
- opj_event_msg(p_manager, EVT_WARNING, " - truncating segment to %d\n",
- l_seg->newlen);
- break;
- };
-
-#endif /* USE_JPWL */
-
- if (l_cblk->numchunks == l_cblk->numchunksalloc) {
- OPJ_UINT32 l_numchunksalloc = l_cblk->numchunksalloc * 2 + 1;
- opj_tcd_seg_data_chunk_t* l_chunks =
- (opj_tcd_seg_data_chunk_t*)opj_realloc(l_cblk->chunks,
- l_numchunksalloc * sizeof(opj_tcd_seg_data_chunk_t));
- if (l_chunks == NULL) {
- opj_event_msg(p_manager, EVT_ERROR,
- "cannot allocate opj_tcd_seg_data_chunk_t* array");
- return OPJ_FALSE;
- }
- l_cblk->chunks = l_chunks;
- l_cblk->numchunksalloc = l_numchunksalloc;
- }
-
- l_cblk->chunks[l_cblk->numchunks].data = l_current_data;
- l_cblk->chunks[l_cblk->numchunks].len = l_seg->newlen;
- l_cblk->numchunks ++;
-
- l_current_data += l_seg->newlen;
- l_seg->len += l_seg->newlen;
- l_seg->numpasses += l_seg->numnewpasses;
- l_cblk->numnewpasses -= l_seg->numnewpasses;
-
- l_seg->real_num_passes = l_seg->numpasses;
-
- if (l_cblk->numnewpasses > 0) {
- ++l_seg;
- ++l_cblk->numsegs;
- }
- } while (l_cblk->numnewpasses > 0);
-
- l_cblk->real_num_segs = l_cblk->numsegs;
-
- } /* next code_block */
-
- ++l_band;
- }
-
- // return the number of bytes read
- if (partial_buffer) {
- *(p_data_read) = p_max_length;
- } else {
- *(p_data_read) = (OPJ_UINT32)(l_current_data - p_src_data);
- }
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_t2_skip_packet_data(opj_t2_t* p_t2,
- opj_tcd_tile_t *p_tile,
- opj_pi_iterator_t *p_pi,
- OPJ_UINT32 * p_data_read,
- OPJ_UINT32 p_max_length,
- opj_packet_info_t *pack_info,
- opj_event_mgr_t *p_manager)
-{
- OPJ_UINT32 bandno, cblkno;
- OPJ_UINT32 l_nb_code_blocks;
- opj_tcd_band_t *l_band = 00;
- opj_tcd_cblk_dec_t* l_cblk = 00;
- opj_tcd_resolution_t* l_res =
- &p_tile->comps[p_pi->compno].resolutions[p_pi->resno];
-
- OPJ_ARG_NOT_USED(p_t2);
- OPJ_ARG_NOT_USED(pack_info);
-
- *p_data_read = 0;
- l_band = l_res->bands;
-
- for (bandno = 0; bandno < l_res->numbands; ++bandno) {
- opj_tcd_precinct_t *l_prc = &l_band->precincts[p_pi->precno];
-
- if ((l_band->x1 - l_band->x0 == 0) || (l_band->y1 - l_band->y0 == 0)) {
- ++l_band;
- continue;
- }
-
- l_nb_code_blocks = l_prc->cw * l_prc->ch;
- l_cblk = l_prc->cblks.dec;
-
- for (cblkno = 0; cblkno < l_nb_code_blocks; ++cblkno) {
- opj_tcd_seg_t *l_seg = 00;
-
- if (!l_cblk->numnewpasses) {
- /* nothing to do */
- ++l_cblk;
- continue;
- }
-
- if (!l_cblk->numsegs) {
- l_seg = l_cblk->segs;
- ++l_cblk->numsegs;
- } else {
- l_seg = &l_cblk->segs[l_cblk->numsegs - 1];
-
- if (l_seg->numpasses == l_seg->maxpasses) {
- ++l_seg;
- ++l_cblk->numsegs;
- }
- }
-
- do {
- /* Check possible overflow then size */
- if (((*p_data_read + l_seg->newlen) < (*p_data_read)) ||
- ((*p_data_read + l_seg->newlen) > p_max_length)) {
- if (p_t2->cp->strict) {
- opj_event_msg(p_manager, EVT_ERROR,
- "skip: segment too long (%d) with max (%d) for codeblock %d (p=%d, b=%d, r=%d, c=%d)\n",
- l_seg->newlen, p_max_length, cblkno, p_pi->precno, bandno, p_pi->resno,
- p_pi->compno);
- return OPJ_FALSE;
- } else {
- opj_event_msg(p_manager, EVT_WARNING,
- "skip: segment too long (%d) with max (%d) for codeblock %d (p=%d, b=%d, r=%d, c=%d)\n",
- l_seg->newlen, p_max_length, cblkno, p_pi->precno, bandno, p_pi->resno,
- p_pi->compno);
-
- *p_data_read = p_max_length;
- return OPJ_TRUE;
- }
- }
-
-#ifdef USE_JPWL
- /* we need here a j2k handle to verify if making a check to
- the validity of cblocks parameters is selected from user (-W) */
-
- /* let's check that we are not exceeding */
- if ((l_cblk->len + l_seg->newlen) > 8192) {
- opj_event_msg(p_manager, EVT_WARNING,
- "JPWL: segment too long (%d) for codeblock %d (p=%d, b=%d, r=%d, c=%d)\n",
- l_seg->newlen, cblkno, p_pi->precno, bandno, p_pi->resno, p_pi->compno);
- if (!JPWL_ASSUME) {
- opj_event_msg(p_manager, EVT_ERROR, "JPWL: giving up\n");
- return -999;
- }
- l_seg->newlen = 8192 - l_cblk->len;
- opj_event_msg(p_manager, EVT_WARNING, " - truncating segment to %d\n",
- l_seg->newlen);
- break;
- };
-
-#endif /* USE_JPWL */
- JAS_FPRINTF(stderr, "p_data_read (%d) newlen (%d) \n", *p_data_read,
- l_seg->newlen);
- *(p_data_read) += l_seg->newlen;
-
- l_seg->numpasses += l_seg->numnewpasses;
- l_cblk->numnewpasses -= l_seg->numnewpasses;
- if (l_cblk->numnewpasses > 0) {
- ++l_seg;
- ++l_cblk->numsegs;
- }
- } while (l_cblk->numnewpasses > 0);
-
- ++l_cblk;
- }
-
- ++l_band;
- }
-
- return OPJ_TRUE;
-}
-
-
-static OPJ_BOOL opj_t2_init_seg(opj_tcd_cblk_dec_t* cblk,
- OPJ_UINT32 index,
- OPJ_UINT32 cblksty,
- OPJ_UINT32 first)
-{
- opj_tcd_seg_t* seg = 00;
- OPJ_UINT32 l_nb_segs = index + 1;
-
- if (l_nb_segs > cblk->m_current_max_segs) {
- opj_tcd_seg_t* new_segs;
- OPJ_UINT32 l_m_current_max_segs = cblk->m_current_max_segs +
- OPJ_J2K_DEFAULT_NB_SEGS;
-
- new_segs = (opj_tcd_seg_t*) opj_realloc(cblk->segs,
- l_m_current_max_segs * sizeof(opj_tcd_seg_t));
- if (! new_segs) {
- /* opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to initialize segment %d\n", l_nb_segs); */
- return OPJ_FALSE;
- }
- cblk->segs = new_segs;
- memset(new_segs + cblk->m_current_max_segs,
- 0, OPJ_J2K_DEFAULT_NB_SEGS * sizeof(opj_tcd_seg_t));
- cblk->m_current_max_segs = l_m_current_max_segs;
- }
-
- seg = &cblk->segs[index];
- opj_tcd_reinit_segment(seg);
-
- if (cblksty & J2K_CCP_CBLKSTY_TERMALL) {
- seg->maxpasses = 1;
- } else if (cblksty & J2K_CCP_CBLKSTY_LAZY) {
- if (first) {
- seg->maxpasses = 10;
- } else {
- seg->maxpasses = (((seg - 1)->maxpasses == 1) ||
- ((seg - 1)->maxpasses == 10)) ? 2 : 1;
- }
- } else {
- /* See paragraph "B.10.6 Number of coding passes" of the standard.
- * Probably that 109 must be interpreted a (Mb-1)*3 + 1 with Mb=37,
- * Mb being the maximum number of bit-planes available for the
- * representation of coefficients in the sub-band */
- seg->maxpasses = 109;
- }
-
- return OPJ_TRUE;
-}
diff --git a/contrib/libs/openjpeg/t2.h b/contrib/libs/openjpeg/t2.h
deleted file mode 100644
index becfa91a4d..0000000000
--- a/contrib/libs/openjpeg/t2.h
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2014, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux
- * Copyright (c) 2003-2014, Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR
- * Copyright (c) 2012, CS Systemes d'Information, France
- * Copyright (c) 2017, IntoPIX SA <support@intopix.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef OPJ_T2_H
-#define OPJ_T2_H
-/**
-@file t2.h
-@brief Implementation of a tier-2 coding (packetization of code-block data) (T2)
-
-*/
-
-/** @defgroup T2 T2 - Implementation of a tier-2 coding */
-/*@{*/
-
-/**
-Tier-2 coding
-*/
-typedef struct opj_t2 {
-
- /** Encoding: pointer to the src image. Decoding: pointer to the dst image. */
- opj_image_t *image;
- /** pointer to the image coding parameters */
- opj_cp_t *cp;
-} opj_t2_t;
-
-/** @name Exported functions */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-
-/**
-Encode the packets of a tile to a destination buffer
-@param t2 T2 handle
-@param tileno number of the tile encoded
-@param tile the tile for which to write the packets
-@param maxlayers maximum number of layers
-@param dest the destination buffer
-@param p_data_written FIXME DOC
-@param len the length of the destination buffer
-@param cstr_info Codestream information structure
-@param p_marker_info Marker information structure
-@param tpnum Tile part number of the current tile
-@param tppos The position of the tile part flag in the progression order
-@param pino FIXME DOC
-@param t2_mode If == THRESH_CALC In Threshold calculation ,If == FINAL_PASS Final pass
-@param p_manager the user event manager
-*/
-OPJ_BOOL opj_t2_encode_packets(opj_t2_t* t2,
- OPJ_UINT32 tileno,
- opj_tcd_tile_t *tile,
- OPJ_UINT32 maxlayers,
- OPJ_BYTE *dest,
- OPJ_UINT32 * p_data_written,
- OPJ_UINT32 len,
- opj_codestream_info_t *cstr_info,
- opj_tcd_marker_info_t* p_marker_info,
- OPJ_UINT32 tpnum,
- OPJ_INT32 tppos,
- OPJ_UINT32 pino,
- J2K_T2_MODE t2_mode,
- opj_event_mgr_t *p_manager);
-
-/**
-Decode the packets of a tile from a source buffer
-@param tcd TCD handle
-@param t2 T2 handle
-@param tileno number that identifies the tile for which to decode the packets
-@param tile tile for which to decode the packets
-@param src FIXME DOC
-@param p_data_read the source buffer
-@param len length of the source buffer
-@param cstr_info FIXME DOC
-@param p_manager the user event manager
-
-@return FIXME DOC
- */
-OPJ_BOOL opj_t2_decode_packets(opj_tcd_t* tcd,
- opj_t2_t *t2,
- OPJ_UINT32 tileno,
- opj_tcd_tile_t *tile,
- OPJ_BYTE *src,
- OPJ_UINT32 * p_data_read,
- OPJ_UINT32 len,
- opj_codestream_index_t *cstr_info,
- opj_event_mgr_t *p_manager);
-
-/**
- * Creates a Tier 2 handle
- *
- * @param p_image Source or destination image
- * @param p_cp Image coding parameters.
- * @return a new T2 handle if successful, NULL otherwise.
-*/
-opj_t2_t* opj_t2_create(opj_image_t *p_image, opj_cp_t *p_cp);
-
-/**
-Destroy a T2 handle
-@param t2 T2 handle to destroy
-*/
-void opj_t2_destroy(opj_t2_t *t2);
-
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* OPJ_T2_H */
diff --git a/contrib/libs/openjpeg/tcd.c b/contrib/libs/openjpeg/tcd.c
deleted file mode 100644
index 8ca259b71d..0000000000
--- a/contrib/libs/openjpeg/tcd.c
+++ /dev/null
@@ -1,2930 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2014, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux
- * Copyright (c) 2003-2014, Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2006-2007, Parvatha Elangovan
- * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR
- * Copyright (c) 2012, CS Systemes d'Information, France
- * Copyright (c) 2017, IntoPIX SA <support@intopix.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "opj_includes.h"
-#include "opj_common.h"
-
-// #define DEBUG_RATE_ALLOC
-
-/* ----------------------------------------------------------------------- */
-
-/* TODO MSD: */
-#ifdef TODO_MSD
-void tcd_dump(FILE *fd, opj_tcd_t *tcd, opj_tcd_image_t * img)
-{
- int tileno, compno, resno, bandno, precno;/*, cblkno;*/
-
- fprintf(fd, "image {\n");
- fprintf(fd, " tw=%d, th=%d x0=%d x1=%d y0=%d y1=%d\n",
- img->tw, img->th, tcd->image->x0, tcd->image->x1, tcd->image->y0,
- tcd->image->y1);
-
- for (tileno = 0; tileno < img->th * img->tw; tileno++) {
- opj_tcd_tile_t *tile = &tcd->tcd_image->tiles[tileno];
- fprintf(fd, " tile {\n");
- fprintf(fd, " x0=%d, y0=%d, x1=%d, y1=%d, numcomps=%d\n",
- tile->x0, tile->y0, tile->x1, tile->y1, tile->numcomps);
- for (compno = 0; compno < tile->numcomps; compno++) {
- opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
- fprintf(fd, " tilec {\n");
- fprintf(fd,
- " x0=%d, y0=%d, x1=%d, y1=%d, numresolutions=%d\n",
- tilec->x0, tilec->y0, tilec->x1, tilec->y1, tilec->numresolutions);
- for (resno = 0; resno < tilec->numresolutions; resno++) {
- opj_tcd_resolution_t *res = &tilec->resolutions[resno];
- fprintf(fd, "\n res {\n");
- fprintf(fd,
- " x0=%d, y0=%d, x1=%d, y1=%d, pw=%d, ph=%d, numbands=%d\n",
- res->x0, res->y0, res->x1, res->y1, res->pw, res->ph, res->numbands);
- for (bandno = 0; bandno < res->numbands; bandno++) {
- opj_tcd_band_t *band = &res->bands[bandno];
- fprintf(fd, " band {\n");
- fprintf(fd,
- " x0=%d, y0=%d, x1=%d, y1=%d, stepsize=%f, numbps=%d\n",
- band->x0, band->y0, band->x1, band->y1, band->stepsize, band->numbps);
- for (precno = 0; precno < res->pw * res->ph; precno++) {
- opj_tcd_precinct_t *prec = &band->precincts[precno];
- fprintf(fd, " prec {\n");
- fprintf(fd,
- " x0=%d, y0=%d, x1=%d, y1=%d, cw=%d, ch=%d\n",
- prec->x0, prec->y0, prec->x1, prec->y1, prec->cw, prec->ch);
- /*
- for (cblkno = 0; cblkno < prec->cw * prec->ch; cblkno++) {
- opj_tcd_cblk_t *cblk = &prec->cblks[cblkno];
- fprintf(fd, " cblk {\n");
- fprintf(fd,
- " x0=%d, y0=%d, x1=%d, y1=%d\n",
- cblk->x0, cblk->y0, cblk->x1, cblk->y1);
- fprintf(fd, " }\n");
- }
- */
- fprintf(fd, " }\n");
- }
- fprintf(fd, " }\n");
- }
- fprintf(fd, " }\n");
- }
- fprintf(fd, " }\n");
- }
- fprintf(fd, " }\n");
- }
- fprintf(fd, "}\n");
-}
-#endif
-
-/**
- * Initializes tile coding/decoding
- */
-static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
- OPJ_BOOL isEncoder, OPJ_SIZE_T sizeof_block,
- opj_event_mgr_t* manager);
-
-/**
-* Allocates memory for a decoding code block.
-*/
-static OPJ_BOOL opj_tcd_code_block_dec_allocate(opj_tcd_cblk_dec_t *
- p_code_block);
-
-/**
- * Deallocates the decoding data of the given precinct.
- */
-static void opj_tcd_code_block_dec_deallocate(opj_tcd_precinct_t * p_precinct);
-
-/**
- * Allocates memory for an encoding code block (but not data).
- */
-static OPJ_BOOL opj_tcd_code_block_enc_allocate(opj_tcd_cblk_enc_t *
- p_code_block);
-
-/**
- * Allocates data for an encoding code block
- */
-static OPJ_BOOL opj_tcd_code_block_enc_allocate_data(opj_tcd_cblk_enc_t *
- p_code_block);
-
-/**
- * Deallocates the encoding data of the given precinct.
- */
-static void opj_tcd_code_block_enc_deallocate(opj_tcd_precinct_t * p_precinct);
-
-static
-void opj_tcd_makelayer_fixed(opj_tcd_t *tcd, OPJ_UINT32 layno,
- OPJ_UINT32 final);
-
-/**
-Free the memory allocated for encoding
-@param tcd TCD handle
-*/
-static void opj_tcd_free_tile(opj_tcd_t *tcd);
-
-
-static OPJ_BOOL opj_tcd_t2_decode(opj_tcd_t *p_tcd,
- OPJ_BYTE * p_src_data,
- OPJ_UINT32 * p_data_read,
- OPJ_UINT32 p_max_src_size,
- opj_codestream_index_t *p_cstr_index,
- opj_event_mgr_t *p_manager);
-
-static OPJ_BOOL opj_tcd_t1_decode(opj_tcd_t *p_tcd,
- opj_event_mgr_t *p_manager);
-
-static OPJ_BOOL opj_tcd_dwt_decode(opj_tcd_t *p_tcd);
-
-static OPJ_BOOL opj_tcd_mct_decode(opj_tcd_t *p_tcd,
- opj_event_mgr_t *p_manager);
-
-static OPJ_BOOL opj_tcd_dc_level_shift_decode(opj_tcd_t *p_tcd);
-
-
-static OPJ_BOOL opj_tcd_dc_level_shift_encode(opj_tcd_t *p_tcd);
-
-static OPJ_BOOL opj_tcd_mct_encode(opj_tcd_t *p_tcd);
-
-static OPJ_BOOL opj_tcd_dwt_encode(opj_tcd_t *p_tcd);
-
-static OPJ_BOOL opj_tcd_t1_encode(opj_tcd_t *p_tcd);
-
-static OPJ_BOOL opj_tcd_t2_encode(opj_tcd_t *p_tcd,
- OPJ_BYTE * p_dest_data,
- OPJ_UINT32 * p_data_written,
- OPJ_UINT32 p_max_dest_size,
- opj_codestream_info_t *p_cstr_info,
- opj_tcd_marker_info_t* p_marker_info,
- opj_event_mgr_t *p_manager);
-
-static OPJ_BOOL opj_tcd_rate_allocate_encode(opj_tcd_t *p_tcd,
- OPJ_BYTE * p_dest_data,
- OPJ_UINT32 p_max_dest_size,
- opj_codestream_info_t *p_cstr_info,
- opj_event_mgr_t *p_manager);
-
-
-static OPJ_BOOL opj_tcd_is_whole_tilecomp_decoding(opj_tcd_t *tcd,
- OPJ_UINT32 compno);
-
-/* ----------------------------------------------------------------------- */
-
-/**
-Create a new TCD handle
-*/
-opj_tcd_t* opj_tcd_create(OPJ_BOOL p_is_decoder)
-{
- opj_tcd_t *l_tcd = 00;
-
- /* create the tcd structure */
- l_tcd = (opj_tcd_t*) opj_calloc(1, sizeof(opj_tcd_t));
- if (!l_tcd) {
- return 00;
- }
-
- l_tcd->m_is_decoder = p_is_decoder ? 1 : 0;
-
- l_tcd->tcd_image = (opj_tcd_image_t*)opj_calloc(1, sizeof(opj_tcd_image_t));
- if (!l_tcd->tcd_image) {
- opj_free(l_tcd);
- return 00;
- }
-
- return l_tcd;
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-static
-void opj_tcd_rateallocate_fixed(opj_tcd_t *tcd)
-{
- OPJ_UINT32 layno;
-
- for (layno = 0; layno < tcd->tcp->numlayers; layno++) {
- opj_tcd_makelayer_fixed(tcd, layno, 1);
- }
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-/** Returns OPJ_TRUE if the layer allocation is unchanged w.r.t to the previous
- * invocation with a different threshold */
-static
-OPJ_BOOL opj_tcd_makelayer(opj_tcd_t *tcd,
- OPJ_UINT32 layno,
- OPJ_FLOAT64 thresh,
- OPJ_UINT32 final)
-{
- OPJ_UINT32 compno, resno, bandno, precno, cblkno;
- OPJ_UINT32 passno;
-
- opj_tcd_tile_t *tcd_tile = tcd->tcd_image->tiles;
- OPJ_BOOL layer_allocation_is_same = OPJ_TRUE;
-
- tcd_tile->distolayer[layno] = 0;
-
- for (compno = 0; compno < tcd_tile->numcomps; compno++) {
- opj_tcd_tilecomp_t *tilec = &tcd_tile->comps[compno];
-
- for (resno = 0; resno < tilec->numresolutions; resno++) {
- opj_tcd_resolution_t *res = &tilec->resolutions[resno];
-
- for (bandno = 0; bandno < res->numbands; bandno++) {
- opj_tcd_band_t *band = &res->bands[bandno];
-
- /* Skip empty bands */
- if (opj_tcd_is_band_empty(band)) {
- continue;
- }
-
- for (precno = 0; precno < res->pw * res->ph; precno++) {
- opj_tcd_precinct_t *prc = &band->precincts[precno];
-
- for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
- opj_tcd_cblk_enc_t *cblk = &prc->cblks.enc[cblkno];
- opj_tcd_layer_t *layer = &cblk->layers[layno];
- OPJ_UINT32 n;
-
- if (layno == 0) {
- cblk->numpassesinlayers = 0;
- }
-
- n = cblk->numpassesinlayers;
-
- if (thresh < 0) {
- /* Special value to indicate to use all passes */
- n = cblk->totalpasses;
- } else {
- for (passno = cblk->numpassesinlayers; passno < cblk->totalpasses; passno++) {
- OPJ_UINT32 dr;
- OPJ_FLOAT64 dd;
- opj_tcd_pass_t *pass = &cblk->passes[passno];
-
- if (n == 0) {
- dr = pass->rate;
- dd = pass->distortiondec;
- } else {
- dr = pass->rate - cblk->passes[n - 1].rate;
- dd = pass->distortiondec - cblk->passes[n - 1].distortiondec;
- }
-
- if (!dr) {
- if (dd != 0) {
- n = passno + 1;
- }
- continue;
- }
- if (thresh - (dd / dr) <
- DBL_EPSILON) { /* do not rely on float equality, check with DBL_EPSILON margin */
- n = passno + 1;
- }
- }
- }
-
- if (layer->numpasses != n - cblk->numpassesinlayers) {
- layer_allocation_is_same = OPJ_FALSE;
- layer->numpasses = n - cblk->numpassesinlayers;
- }
-
- if (!layer->numpasses) {
- layer->disto = 0;
- continue;
- }
-
- if (cblk->numpassesinlayers == 0) {
- layer->len = cblk->passes[n - 1].rate;
- layer->data = cblk->data;
- layer->disto = cblk->passes[n - 1].distortiondec;
- } else {
- layer->len = cblk->passes[n - 1].rate - cblk->passes[cblk->numpassesinlayers -
- 1].rate;
- layer->data = cblk->data + cblk->passes[cblk->numpassesinlayers - 1].rate;
- layer->disto = cblk->passes[n - 1].distortiondec -
- cblk->passes[cblk->numpassesinlayers - 1].distortiondec;
- }
-
- tcd_tile->distolayer[layno] += layer->disto;
-
- if (final) {
- cblk->numpassesinlayers = n;
- }
- }
- }
- }
- }
- }
- return layer_allocation_is_same;
-}
-
-/** For m_quality_layer_alloc_strategy == FIXED_LAYER */
-static
-void opj_tcd_makelayer_fixed(opj_tcd_t *tcd, OPJ_UINT32 layno,
- OPJ_UINT32 final)
-{
- OPJ_UINT32 compno, resno, bandno, precno, cblkno;
- OPJ_INT32 value; /*, matrice[tcd_tcp->numlayers][tcd_tile->comps[0].numresolutions][3]; */
- OPJ_INT32 matrice[J2K_TCD_MATRIX_MAX_LAYER_COUNT][J2K_TCD_MATRIX_MAX_RESOLUTION_COUNT][3];
- OPJ_UINT32 i, j, k;
-
- opj_cp_t *cp = tcd->cp;
- opj_tcd_tile_t *tcd_tile = tcd->tcd_image->tiles;
- opj_tcp_t *tcd_tcp = tcd->tcp;
-
- for (compno = 0; compno < tcd_tile->numcomps; compno++) {
- opj_tcd_tilecomp_t *tilec = &tcd_tile->comps[compno];
-
- for (i = 0; i < tcd_tcp->numlayers; i++) {
- for (j = 0; j < tilec->numresolutions; j++) {
- for (k = 0; k < 3; k++) {
- matrice[i][j][k] =
- (OPJ_INT32)((OPJ_FLOAT32)cp->m_specific_param.m_enc.m_matrice[i *
- tilec->numresolutions * 3 + j * 3 + k]
- * (OPJ_FLOAT32)(tcd->image->comps[compno].prec / 16.0));
- }
- }
- }
-
- for (resno = 0; resno < tilec->numresolutions; resno++) {
- opj_tcd_resolution_t *res = &tilec->resolutions[resno];
-
- for (bandno = 0; bandno < res->numbands; bandno++) {
- opj_tcd_band_t *band = &res->bands[bandno];
-
- /* Skip empty bands */
- if (opj_tcd_is_band_empty(band)) {
- continue;
- }
-
- for (precno = 0; precno < res->pw * res->ph; precno++) {
- opj_tcd_precinct_t *prc = &band->precincts[precno];
-
- for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
- opj_tcd_cblk_enc_t *cblk = &prc->cblks.enc[cblkno];
- opj_tcd_layer_t *layer = &cblk->layers[layno];
- OPJ_UINT32 n;
- OPJ_INT32 imsb = (OPJ_INT32)(tcd->image->comps[compno].prec -
- cblk->numbps); /* number of bit-plan equal to zero */
-
- /* Correction of the matrix of coefficient to include the IMSB information */
- if (layno == 0) {
- value = matrice[layno][resno][bandno];
- if (imsb >= value) {
- value = 0;
- } else {
- value -= imsb;
- }
- } else {
- value = matrice[layno][resno][bandno] - matrice[layno - 1][resno][bandno];
- if (imsb >= matrice[layno - 1][resno][bandno]) {
- value -= (imsb - matrice[layno - 1][resno][bandno]);
- if (value < 0) {
- value = 0;
- }
- }
- }
-
- if (layno == 0) {
- cblk->numpassesinlayers = 0;
- }
-
- n = cblk->numpassesinlayers;
- if (cblk->numpassesinlayers == 0) {
- if (value != 0) {
- n = 3 * (OPJ_UINT32)value - 2 + cblk->numpassesinlayers;
- } else {
- n = cblk->numpassesinlayers;
- }
- } else {
- n = 3 * (OPJ_UINT32)value + cblk->numpassesinlayers;
- }
-
- layer->numpasses = n - cblk->numpassesinlayers;
-
- if (!layer->numpasses) {
- continue;
- }
-
- if (cblk->numpassesinlayers == 0) {
- layer->len = cblk->passes[n - 1].rate;
- layer->data = cblk->data;
- } else {
- layer->len = cblk->passes[n - 1].rate - cblk->passes[cblk->numpassesinlayers -
- 1].rate;
- layer->data = cblk->data + cblk->passes[cblk->numpassesinlayers - 1].rate;
- }
-
- if (final) {
- cblk->numpassesinlayers = n;
- }
- }
- }
- }
- }
- }
-}
-
-/** Rate allocation for the following methods:
- * - allocation by rate/distortio (m_quality_layer_alloc_strategy == RATE_DISTORTION_RATIO)
- * - allocation by fixed quality (m_quality_layer_alloc_strategy == FIXED_DISTORTION_RATIO)
- */
-static
-OPJ_BOOL opj_tcd_rateallocate(opj_tcd_t *tcd,
- OPJ_BYTE *dest,
- OPJ_UINT32 * p_data_written,
- OPJ_UINT32 len,
- opj_codestream_info_t *cstr_info,
- opj_event_mgr_t *p_manager)
-{
- OPJ_UINT32 compno, resno, bandno, precno, cblkno, layno;
- OPJ_UINT32 passno;
- OPJ_FLOAT64 min, max;
- OPJ_FLOAT64 cumdisto[100];
- const OPJ_FLOAT64 K = 1;
- OPJ_FLOAT64 maxSE = 0;
-
- opj_cp_t *cp = tcd->cp;
- opj_tcd_tile_t *tcd_tile = tcd->tcd_image->tiles;
- opj_tcp_t *tcd_tcp = tcd->tcp;
-
- min = DBL_MAX;
- max = 0;
-
- tcd_tile->numpix = 0;
-
- for (compno = 0; compno < tcd_tile->numcomps; compno++) {
- opj_tcd_tilecomp_t *tilec = &tcd_tile->comps[compno];
- tilec->numpix = 0;
-
- for (resno = 0; resno < tilec->numresolutions; resno++) {
- opj_tcd_resolution_t *res = &tilec->resolutions[resno];
-
- for (bandno = 0; bandno < res->numbands; bandno++) {
- opj_tcd_band_t *band = &res->bands[bandno];
-
- /* Skip empty bands */
- if (opj_tcd_is_band_empty(band)) {
- continue;
- }
-
- for (precno = 0; precno < res->pw * res->ph; precno++) {
- opj_tcd_precinct_t *prc = &band->precincts[precno];
-
- for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
- opj_tcd_cblk_enc_t *cblk = &prc->cblks.enc[cblkno];
-
- for (passno = 0; passno < cblk->totalpasses; passno++) {
- opj_tcd_pass_t *pass = &cblk->passes[passno];
- OPJ_INT32 dr;
- OPJ_FLOAT64 dd, rdslope;
-
- if (passno == 0) {
- dr = (OPJ_INT32)pass->rate;
- dd = pass->distortiondec;
- } else {
- dr = (OPJ_INT32)(pass->rate - cblk->passes[passno - 1].rate);
- dd = pass->distortiondec - cblk->passes[passno - 1].distortiondec;
- }
-
- if (dr == 0) {
- continue;
- }
-
- rdslope = dd / dr;
- if (rdslope < min) {
- min = rdslope;
- }
-
- if (rdslope > max) {
- max = rdslope;
- }
- } /* passno */
-
- {
- const OPJ_SIZE_T cblk_pix_count = (OPJ_SIZE_T)((cblk->x1 - cblk->x0) *
- (cblk->y1 - cblk->y0));
- tcd_tile->numpix += cblk_pix_count;
- tilec->numpix += cblk_pix_count;
- }
- } /* cbklno */
- } /* precno */
- } /* bandno */
- } /* resno */
-
- maxSE += (((OPJ_FLOAT64)(1 << tcd->image->comps[compno].prec) - 1.0)
- * ((OPJ_FLOAT64)(1 << tcd->image->comps[compno].prec) - 1.0))
- * ((OPJ_FLOAT64)(tilec->numpix));
- } /* compno */
-
- /* index file */
- if (cstr_info) {
- opj_tile_info_t *tile_info = &cstr_info->tile[tcd->tcd_tileno];
- tile_info->numpix = (int)tcd_tile->numpix;
- tile_info->distotile = (int)tcd_tile->distotile;
- tile_info->thresh = (OPJ_FLOAT64 *) opj_malloc(tcd_tcp->numlayers * sizeof(
- OPJ_FLOAT64));
- if (!tile_info->thresh) {
- /* FIXME event manager error callback */
- return OPJ_FALSE;
- }
- }
-
- for (layno = 0; layno < tcd_tcp->numlayers; layno++) {
- OPJ_FLOAT64 lo = min;
- OPJ_FLOAT64 hi = max;
- OPJ_UINT32 maxlen = tcd_tcp->rates[layno] > 0.0f ? opj_uint_min(((
- OPJ_UINT32) ceil(tcd_tcp->rates[layno])), len) : len;
- OPJ_FLOAT64 goodthresh = 0;
- OPJ_FLOAT64 stable_thresh = 0;
- OPJ_UINT32 i;
- OPJ_FLOAT64 distotarget;
-
- distotarget = tcd_tile->distotile - ((K * maxSE) / pow((OPJ_FLOAT32)10,
- tcd_tcp->distoratio[layno] / 10));
-
- /* Don't try to find an optimal threshold but rather take everything not included yet, if
- -r xx,yy,zz,0 (m_quality_layer_alloc_strategy == RATE_DISTORTION_RATIO and rates == NULL)
- -q xx,yy,zz,0 (m_quality_layer_alloc_strategy == FIXED_DISTORTION_RATIO and distoratio == NULL)
- ==> possible to have some lossy layers and the last layer for sure lossless */
- if (((cp->m_specific_param.m_enc.m_quality_layer_alloc_strategy ==
- RATE_DISTORTION_RATIO) &&
- (tcd_tcp->rates[layno] > 0.0f)) ||
- ((cp->m_specific_param.m_enc.m_quality_layer_alloc_strategy ==
- FIXED_DISTORTION_RATIO) &&
- (tcd_tcp->distoratio[layno] > 0.0))) {
- opj_t2_t*t2 = opj_t2_create(tcd->image, cp);
- OPJ_FLOAT64 thresh = 0;
- OPJ_BOOL last_layer_allocation_ok = OPJ_FALSE;
-
- if (t2 == 00) {
- return OPJ_FALSE;
- }
-
- for (i = 0; i < 128; ++i) {
- OPJ_FLOAT64 distoachieved = 0;
- OPJ_BOOL layer_allocation_is_same;
-
- OPJ_FLOAT64 new_thresh = (lo + hi) / 2;
- /* Stop iterating when the threshold has stabilized enough */
- /* 0.5 * 1e-5 is somewhat arbitrary, but has been selected */
- /* so that this doesn't change the results of the regression */
- /* test suite. */
- if (fabs(new_thresh - thresh) <= 0.5 * 1e-5 * thresh) {
- break;
- }
- thresh = new_thresh;
-#ifdef DEBUG_RATE_ALLOC
- opj_event_msg(p_manager, EVT_INFO, "layno=%u, iter=%u, thresh=%g",
- layno, i, new_thresh);
-#endif
-
- layer_allocation_is_same = opj_tcd_makelayer(tcd, layno, thresh, 0) && i != 0;
-#ifdef DEBUG_RATE_ALLOC
- opj_event_msg(p_manager, EVT_INFO, "--> layer_allocation_is_same = %d",
- layer_allocation_is_same);
-#endif
- if (cp->m_specific_param.m_enc.m_quality_layer_alloc_strategy ==
- FIXED_DISTORTION_RATIO) {
- if (OPJ_IS_CINEMA(cp->rsiz) || OPJ_IS_IMF(cp->rsiz)) {
- if (! opj_t2_encode_packets(t2, tcd->tcd_tileno, tcd_tile, layno + 1, dest,
- p_data_written, maxlen, cstr_info, NULL, tcd->cur_tp_num, tcd->tp_pos,
- tcd->cur_pino,
- THRESH_CALC, p_manager)) {
-
- lo = thresh;
- continue;
- } else {
- distoachieved = layno == 0 ?
- tcd_tile->distolayer[0] : cumdisto[layno - 1] + tcd_tile->distolayer[layno];
-
- if (distoachieved < distotarget) {
- hi = thresh;
- stable_thresh = thresh;
- continue;
- } else {
- lo = thresh;
- }
- }
- } else {
- distoachieved = (layno == 0) ?
- tcd_tile->distolayer[0] : (cumdisto[layno - 1] + tcd_tile->distolayer[layno]);
-
- if (distoachieved < distotarget) {
- hi = thresh;
- stable_thresh = thresh;
- continue;
- }
- lo = thresh;
- }
- } else { /* Disto/rate based optimization */
- /* Check if the layer allocation done by opj_tcd_makelayer()
- * is compatible of the maximum rate allocation. If not,
- * retry with a higher threshold.
- * If OK, try with a lower threshold.
- * Call opj_t2_encode_packets() only if opj_tcd_makelayer()
- * has resulted in different truncation points since its last
- * call. */
- if ((layer_allocation_is_same && !last_layer_allocation_ok) ||
- (!layer_allocation_is_same &&
- ! opj_t2_encode_packets(t2, tcd->tcd_tileno, tcd_tile, layno + 1, dest,
- p_data_written, maxlen, cstr_info, NULL, tcd->cur_tp_num, tcd->tp_pos,
- tcd->cur_pino,
- THRESH_CALC, p_manager))) {
-
-#ifdef DEBUG_RATE_ALLOC
- if (!layer_allocation_is_same) {
- opj_event_msg(p_manager, EVT_INFO,
- "--> check rate alloc failed (> maxlen=%u)\n", maxlen);
- }
-#endif
- last_layer_allocation_ok = OPJ_FALSE;
- lo = thresh;
- continue;
- }
-
-#ifdef DEBUG_RATE_ALLOC
- if (!layer_allocation_is_same) {
- opj_event_msg(p_manager, EVT_INFO,
- "--> check rate alloc success (len=%u <= maxlen=%u)\n", *p_data_written,
- maxlen);
- }
-#endif
-
- last_layer_allocation_ok = OPJ_TRUE;
- hi = thresh;
- stable_thresh = thresh;
- }
- }
-
- goodthresh = stable_thresh == 0 ? thresh : stable_thresh;
-
- opj_t2_destroy(t2);
- } else {
- /* Special value to indicate to use all passes */
- goodthresh = -1;
- }
-
- if (cstr_info) { /* Threshold for Marcela Index */
- cstr_info->tile[tcd->tcd_tileno].thresh[layno] = goodthresh;
- }
-
- opj_tcd_makelayer(tcd, layno, goodthresh, 1);
-
- cumdisto[layno] = (layno == 0) ? tcd_tile->distolayer[0] :
- (cumdisto[layno - 1] + tcd_tile->distolayer[layno]);
- }
-
- return OPJ_TRUE;
-}
-
-OPJ_BOOL opj_tcd_init(opj_tcd_t *p_tcd,
- opj_image_t * p_image,
- opj_cp_t * p_cp,
- opj_thread_pool_t* p_tp)
-{
- p_tcd->image = p_image;
- p_tcd->cp = p_cp;
-
- p_tcd->tcd_image->tiles = (opj_tcd_tile_t *) opj_calloc(1,
- sizeof(opj_tcd_tile_t));
- if (! p_tcd->tcd_image->tiles) {
- return OPJ_FALSE;
- }
-
- p_tcd->tcd_image->tiles->comps = (opj_tcd_tilecomp_t *) opj_calloc(
- p_image->numcomps, sizeof(opj_tcd_tilecomp_t));
- if (! p_tcd->tcd_image->tiles->comps) {
- return OPJ_FALSE;
- }
-
- p_tcd->tcd_image->tiles->numcomps = p_image->numcomps;
- p_tcd->tp_pos = p_cp->m_specific_param.m_enc.m_tp_pos;
- p_tcd->thread_pool = p_tp;
-
- return OPJ_TRUE;
-}
-
-/**
-Destroy a previously created TCD handle
-*/
-void opj_tcd_destroy(opj_tcd_t *tcd)
-{
- if (tcd) {
- opj_tcd_free_tile(tcd);
-
- if (tcd->tcd_image) {
- opj_free(tcd->tcd_image);
- tcd->tcd_image = 00;
- }
-
- opj_free(tcd->used_component);
-
- opj_free(tcd);
- }
-}
-
-OPJ_BOOL opj_alloc_tile_component_data(opj_tcd_tilecomp_t *l_tilec)
-{
- if ((l_tilec->data == 00) ||
- ((l_tilec->data_size_needed > l_tilec->data_size) &&
- (l_tilec->ownsData == OPJ_FALSE))) {
- l_tilec->data = (OPJ_INT32 *) opj_image_data_alloc(l_tilec->data_size_needed);
- if (!l_tilec->data && l_tilec->data_size_needed != 0) {
- return OPJ_FALSE;
- }
- /*fprintf(stderr, "tAllocate data of tilec (int): %d x OPJ_UINT32n",l_data_size);*/
- l_tilec->data_size = l_tilec->data_size_needed;
- l_tilec->ownsData = OPJ_TRUE;
- } else if (l_tilec->data_size_needed > l_tilec->data_size) {
- /* We don't need to keep old data */
- opj_image_data_free(l_tilec->data);
- l_tilec->data = (OPJ_INT32 *) opj_image_data_alloc(l_tilec->data_size_needed);
- if (! l_tilec->data) {
- l_tilec->data_size = 0;
- l_tilec->data_size_needed = 0;
- l_tilec->ownsData = OPJ_FALSE;
- return OPJ_FALSE;
- }
- /*fprintf(stderr, "tReallocate data of tilec (int): from %d to %d x OPJ_UINT32n", l_tilec->data_size, l_data_size);*/
- l_tilec->data_size = l_tilec->data_size_needed;
- l_tilec->ownsData = OPJ_TRUE;
- }
- return OPJ_TRUE;
-}
-
-/* ----------------------------------------------------------------------- */
-
-static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
- OPJ_BOOL isEncoder, OPJ_SIZE_T sizeof_block,
- opj_event_mgr_t* manager)
-{
- OPJ_UINT32 compno, resno, bandno, precno, cblkno;
- opj_tcp_t * l_tcp = 00;
- opj_cp_t * l_cp = 00;
- opj_tcd_tile_t * l_tile = 00;
- opj_tccp_t *l_tccp = 00;
- opj_tcd_tilecomp_t *l_tilec = 00;
- opj_image_comp_t * l_image_comp = 00;
- opj_tcd_resolution_t *l_res = 00;
- opj_tcd_band_t *l_band = 00;
- opj_stepsize_t * l_step_size = 00;
- opj_tcd_precinct_t *l_current_precinct = 00;
- opj_image_t *l_image = 00;
- OPJ_UINT32 p, q;
- OPJ_UINT32 l_level_no;
- OPJ_UINT32 l_pdx, l_pdy;
- OPJ_INT32 l_x0b, l_y0b;
- OPJ_UINT32 l_tx0, l_ty0;
- /* extent of precincts , top left, bottom right**/
- OPJ_INT32 l_tl_prc_x_start, l_tl_prc_y_start, l_br_prc_x_end, l_br_prc_y_end;
- /* number of precinct for a resolution */
- OPJ_UINT32 l_nb_precincts;
- /* room needed to store l_nb_precinct precinct for a resolution */
- OPJ_UINT32 l_nb_precinct_size;
- /* number of code blocks for a precinct*/
- OPJ_UINT32 l_nb_code_blocks;
- /* room needed to store l_nb_code_blocks code blocks for a precinct*/
- OPJ_UINT32 l_nb_code_blocks_size;
- /* size of data for a tile */
- OPJ_UINT32 l_data_size;
-
- l_cp = p_tcd->cp;
- l_tcp = &(l_cp->tcps[p_tile_no]);
- l_tile = p_tcd->tcd_image->tiles;
- l_tccp = l_tcp->tccps;
- l_tilec = l_tile->comps;
- l_image = p_tcd->image;
- l_image_comp = p_tcd->image->comps;
-
- p = p_tile_no % l_cp->tw; /* tile coordinates */
- q = p_tile_no / l_cp->tw;
- /*fprintf(stderr, "Tile coordinate = %d,%d\n", p, q);*/
-
- /* 4 borders of the tile rescale on the image if necessary */
- l_tx0 = l_cp->tx0 + p *
- l_cp->tdx; /* can't be greater than l_image->x1 so won't overflow */
- l_tile->x0 = (OPJ_INT32)opj_uint_max(l_tx0, l_image->x0);
- l_tile->x1 = (OPJ_INT32)opj_uint_min(opj_uint_adds(l_tx0, l_cp->tdx),
- l_image->x1);
- /* all those OPJ_UINT32 are casted to OPJ_INT32, let's do some sanity check */
- if ((l_tile->x0 < 0) || (l_tile->x1 <= l_tile->x0)) {
- opj_event_msg(manager, EVT_ERROR, "Tile X coordinates are not supported\n");
- return OPJ_FALSE;
- }
- l_ty0 = l_cp->ty0 + q *
- l_cp->tdy; /* can't be greater than l_image->y1 so won't overflow */
- l_tile->y0 = (OPJ_INT32)opj_uint_max(l_ty0, l_image->y0);
- l_tile->y1 = (OPJ_INT32)opj_uint_min(opj_uint_adds(l_ty0, l_cp->tdy),
- l_image->y1);
- /* all those OPJ_UINT32 are casted to OPJ_INT32, let's do some sanity check */
- if ((l_tile->y0 < 0) || (l_tile->y1 <= l_tile->y0)) {
- opj_event_msg(manager, EVT_ERROR, "Tile Y coordinates are not supported\n");
- return OPJ_FALSE;
- }
-
-
- /* testcase 1888.pdf.asan.35.988 */
- if (l_tccp->numresolutions == 0) {
- opj_event_msg(manager, EVT_ERROR, "tiles require at least one resolution\n");
- return OPJ_FALSE;
- }
- /*fprintf(stderr, "Tile border = %d,%d,%d,%d\n", l_tile->x0, l_tile->y0,l_tile->x1,l_tile->y1);*/
-
- /*tile->numcomps = image->numcomps; */
- for (compno = 0; compno < l_tile->numcomps; ++compno) {
- /*fprintf(stderr, "compno = %d/%d\n", compno, l_tile->numcomps);*/
- l_image_comp->resno_decoded = 0;
- /* border of each l_tile component (global) */
- l_tilec->x0 = opj_int_ceildiv(l_tile->x0, (OPJ_INT32)l_image_comp->dx);
- l_tilec->y0 = opj_int_ceildiv(l_tile->y0, (OPJ_INT32)l_image_comp->dy);
- l_tilec->x1 = opj_int_ceildiv(l_tile->x1, (OPJ_INT32)l_image_comp->dx);
- l_tilec->y1 = opj_int_ceildiv(l_tile->y1, (OPJ_INT32)l_image_comp->dy);
- l_tilec->compno = compno;
- /*fprintf(stderr, "\tTile compo border = %d,%d,%d,%d\n", l_tilec->x0, l_tilec->y0,l_tilec->x1,l_tilec->y1);*/
-
- l_tilec->numresolutions = l_tccp->numresolutions;
- if (l_tccp->numresolutions < l_cp->m_specific_param.m_dec.m_reduce) {
- l_tilec->minimum_num_resolutions = 1;
- } else {
- l_tilec->minimum_num_resolutions = l_tccp->numresolutions -
- l_cp->m_specific_param.m_dec.m_reduce;
- }
-
- if (isEncoder) {
- OPJ_SIZE_T l_tile_data_size;
-
- /* compute l_data_size with overflow check */
- OPJ_SIZE_T w = (OPJ_SIZE_T)(l_tilec->x1 - l_tilec->x0);
- OPJ_SIZE_T h = (OPJ_SIZE_T)(l_tilec->y1 - l_tilec->y0);
-
- /* issue 733, l_data_size == 0U, probably something wrong should be checked before getting here */
- if (h > 0 && w > SIZE_MAX / h) {
- opj_event_msg(manager, EVT_ERROR, "Size of tile data exceeds system limits\n");
- return OPJ_FALSE;
- }
- l_tile_data_size = w * h;
-
- if (SIZE_MAX / sizeof(OPJ_UINT32) < l_tile_data_size) {
- opj_event_msg(manager, EVT_ERROR, "Size of tile data exceeds system limits\n");
- return OPJ_FALSE;
- }
- l_tile_data_size = l_tile_data_size * sizeof(OPJ_UINT32);
-
- l_tilec->data_size_needed = l_tile_data_size;
- }
-
- l_data_size = l_tilec->numresolutions * (OPJ_UINT32)sizeof(
- opj_tcd_resolution_t);
-
- opj_image_data_free(l_tilec->data_win);
- l_tilec->data_win = NULL;
- l_tilec->win_x0 = 0;
- l_tilec->win_y0 = 0;
- l_tilec->win_x1 = 0;
- l_tilec->win_y1 = 0;
-
- if (l_tilec->resolutions == 00) {
- l_tilec->resolutions = (opj_tcd_resolution_t *) opj_malloc(l_data_size);
- if (! l_tilec->resolutions) {
- return OPJ_FALSE;
- }
- /*fprintf(stderr, "\tAllocate resolutions of tilec (opj_tcd_resolution_t): %d\n",l_data_size);*/
- l_tilec->resolutions_size = l_data_size;
- memset(l_tilec->resolutions, 0, l_data_size);
- } else if (l_data_size > l_tilec->resolutions_size) {
- opj_tcd_resolution_t* new_resolutions = (opj_tcd_resolution_t *) opj_realloc(
- l_tilec->resolutions, l_data_size);
- if (! new_resolutions) {
- opj_event_msg(manager, EVT_ERROR, "Not enough memory for tile resolutions\n");
- opj_free(l_tilec->resolutions);
- l_tilec->resolutions = NULL;
- l_tilec->resolutions_size = 0;
- return OPJ_FALSE;
- }
- l_tilec->resolutions = new_resolutions;
- /*fprintf(stderr, "\tReallocate data of tilec (int): from %d to %d x OPJ_UINT32\n", l_tilec->resolutions_size, l_data_size);*/
- memset(((OPJ_BYTE*) l_tilec->resolutions) + l_tilec->resolutions_size, 0,
- l_data_size - l_tilec->resolutions_size);
- l_tilec->resolutions_size = l_data_size;
- }
-
- l_level_no = l_tilec->numresolutions;
- l_res = l_tilec->resolutions;
- l_step_size = l_tccp->stepsizes;
- /*fprintf(stderr, "\tlevel_no=%d\n",l_level_no);*/
-
- for (resno = 0; resno < l_tilec->numresolutions; ++resno) {
- /*fprintf(stderr, "\t\tresno = %d/%d\n", resno, l_tilec->numresolutions);*/
- OPJ_INT32 tlcbgxstart, tlcbgystart /*, brcbgxend, brcbgyend*/;
- OPJ_UINT32 cbgwidthexpn, cbgheightexpn;
- OPJ_UINT32 cblkwidthexpn, cblkheightexpn;
-
- --l_level_no;
-
- /* border for each resolution level (global) */
- l_res->x0 = opj_int_ceildivpow2(l_tilec->x0, (OPJ_INT32)l_level_no);
- l_res->y0 = opj_int_ceildivpow2(l_tilec->y0, (OPJ_INT32)l_level_no);
- l_res->x1 = opj_int_ceildivpow2(l_tilec->x1, (OPJ_INT32)l_level_no);
- l_res->y1 = opj_int_ceildivpow2(l_tilec->y1, (OPJ_INT32)l_level_no);
-
- /*fprintf(stderr, "\t\t\tres_x0= %d, res_y0 =%d, res_x1=%d, res_y1=%d\n", l_res->x0, l_res->y0, l_res->x1, l_res->y1);*/
- /* p. 35, table A-23, ISO/IEC FDIS154444-1 : 2000 (18 august 2000) */
- l_pdx = l_tccp->prcw[resno];
- l_pdy = l_tccp->prch[resno];
- /*fprintf(stderr, "\t\t\tpdx=%d, pdy=%d\n", l_pdx, l_pdy);*/
- /* p. 64, B.6, ISO/IEC FDIS15444-1 : 2000 (18 august 2000) */
- l_tl_prc_x_start = opj_int_floordivpow2(l_res->x0, (OPJ_INT32)l_pdx) << l_pdx;
- l_tl_prc_y_start = opj_int_floordivpow2(l_res->y0, (OPJ_INT32)l_pdy) << l_pdy;
- {
- OPJ_UINT32 tmp = ((OPJ_UINT32)opj_int_ceildivpow2(l_res->x1,
- (OPJ_INT32)l_pdx)) << l_pdx;
- if (tmp > (OPJ_UINT32)INT_MAX) {
- opj_event_msg(manager, EVT_ERROR, "Integer overflow\n");
- return OPJ_FALSE;
- }
- l_br_prc_x_end = (OPJ_INT32)tmp;
- }
- {
- OPJ_UINT32 tmp = ((OPJ_UINT32)opj_int_ceildivpow2(l_res->y1,
- (OPJ_INT32)l_pdy)) << l_pdy;
- if (tmp > (OPJ_UINT32)INT_MAX) {
- opj_event_msg(manager, EVT_ERROR, "Integer overflow\n");
- return OPJ_FALSE;
- }
- l_br_prc_y_end = (OPJ_INT32)tmp;
- }
- /*fprintf(stderr, "\t\t\tprc_x_start=%d, prc_y_start=%d, br_prc_x_end=%d, br_prc_y_end=%d \n", l_tl_prc_x_start, l_tl_prc_y_start, l_br_prc_x_end ,l_br_prc_y_end );*/
-
- l_res->pw = (l_res->x0 == l_res->x1) ? 0U : (OPJ_UINT32)((
- l_br_prc_x_end - l_tl_prc_x_start) >> l_pdx);
- l_res->ph = (l_res->y0 == l_res->y1) ? 0U : (OPJ_UINT32)((
- l_br_prc_y_end - l_tl_prc_y_start) >> l_pdy);
- /*fprintf(stderr, "\t\t\tres_pw=%d, res_ph=%d\n", l_res->pw, l_res->ph );*/
-
- if ((l_res->pw != 0U) && ((((OPJ_UINT32) - 1) / l_res->pw) < l_res->ph)) {
- opj_event_msg(manager, EVT_ERROR, "Size of tile data exceeds system limits\n");
- return OPJ_FALSE;
- }
- l_nb_precincts = l_res->pw * l_res->ph;
-
- if ((((OPJ_UINT32) - 1) / (OPJ_UINT32)sizeof(opj_tcd_precinct_t)) <
- l_nb_precincts) {
- opj_event_msg(manager, EVT_ERROR, "Size of tile data exceeds system limits\n");
- return OPJ_FALSE;
- }
- l_nb_precinct_size = l_nb_precincts * (OPJ_UINT32)sizeof(opj_tcd_precinct_t);
-
- if (resno == 0) {
- tlcbgxstart = l_tl_prc_x_start;
- tlcbgystart = l_tl_prc_y_start;
- /*brcbgxend = l_br_prc_x_end;*/
- /* brcbgyend = l_br_prc_y_end;*/
- cbgwidthexpn = l_pdx;
- cbgheightexpn = l_pdy;
- l_res->numbands = 1;
- } else {
- tlcbgxstart = opj_int_ceildivpow2(l_tl_prc_x_start, 1);
- tlcbgystart = opj_int_ceildivpow2(l_tl_prc_y_start, 1);
- /*brcbgxend = opj_int_ceildivpow2(l_br_prc_x_end, 1);*/
- /*brcbgyend = opj_int_ceildivpow2(l_br_prc_y_end, 1);*/
- cbgwidthexpn = l_pdx - 1;
- cbgheightexpn = l_pdy - 1;
- l_res->numbands = 3;
- }
-
- cblkwidthexpn = opj_uint_min(l_tccp->cblkw, cbgwidthexpn);
- cblkheightexpn = opj_uint_min(l_tccp->cblkh, cbgheightexpn);
- l_band = l_res->bands;
-
- for (bandno = 0; bandno < l_res->numbands; ++bandno, ++l_band, ++l_step_size) {
- /*fprintf(stderr, "\t\t\tband_no=%d/%d\n", bandno, l_res->numbands );*/
-
- if (resno == 0) {
- l_band->bandno = 0 ;
- l_band->x0 = opj_int_ceildivpow2(l_tilec->x0, (OPJ_INT32)l_level_no);
- l_band->y0 = opj_int_ceildivpow2(l_tilec->y0, (OPJ_INT32)l_level_no);
- l_band->x1 = opj_int_ceildivpow2(l_tilec->x1, (OPJ_INT32)l_level_no);
- l_band->y1 = opj_int_ceildivpow2(l_tilec->y1, (OPJ_INT32)l_level_no);
- } else {
- l_band->bandno = bandno + 1;
- /* x0b = 1 if bandno = 1 or 3 */
- l_x0b = l_band->bandno & 1;
- /* y0b = 1 if bandno = 2 or 3 */
- l_y0b = (OPJ_INT32)((l_band->bandno) >> 1);
- /* l_band border (global) */
- l_band->x0 = opj_int64_ceildivpow2(l_tilec->x0 - ((OPJ_INT64)l_x0b <<
- l_level_no), (OPJ_INT32)(l_level_no + 1));
- l_band->y0 = opj_int64_ceildivpow2(l_tilec->y0 - ((OPJ_INT64)l_y0b <<
- l_level_no), (OPJ_INT32)(l_level_no + 1));
- l_band->x1 = opj_int64_ceildivpow2(l_tilec->x1 - ((OPJ_INT64)l_x0b <<
- l_level_no), (OPJ_INT32)(l_level_no + 1));
- l_band->y1 = opj_int64_ceildivpow2(l_tilec->y1 - ((OPJ_INT64)l_y0b <<
- l_level_no), (OPJ_INT32)(l_level_no + 1));
- }
-
- if (isEncoder) {
- /* Skip empty bands */
- if (opj_tcd_is_band_empty(l_band)) {
- /* Do not zero l_band->precints to avoid leaks */
- /* but make sure we don't use it later, since */
- /* it will point to precincts of previous bands... */
- continue;
- }
- }
-
- {
- /* Table E-1 - Sub-band gains */
- /* BUG_WEIRD_TWO_INVK (look for this identifier in dwt.c): */
- /* the test (!isEncoder && l_tccp->qmfbid == 0) is strongly */
- /* linked to the use of two_invK instead of invK */
- const OPJ_INT32 log2_gain = (!isEncoder &&
- l_tccp->qmfbid == 0) ? 0 : (l_band->bandno == 0) ? 0 :
- (l_band->bandno == 3) ? 2 : 1;
-
- /* Nominal dynamic range. Equation E-4 */
- const OPJ_INT32 Rb = (OPJ_INT32)l_image_comp->prec + log2_gain;
-
- /* Delta_b value of Equation E-3 in "E.1 Inverse quantization
- * procedure" of the standard */
- l_band->stepsize = (OPJ_FLOAT32)(((1.0 + l_step_size->mant / 2048.0) * pow(2.0,
- (OPJ_INT32)(Rb - l_step_size->expn))));
- }
-
- /* Mb value of Equation E-2 in "E.1 Inverse quantization
- * procedure" of the standard */
- l_band->numbps = l_step_size->expn + (OPJ_INT32)l_tccp->numgbits -
- 1;
-
- if (!l_band->precincts && (l_nb_precincts > 0U)) {
- l_band->precincts = (opj_tcd_precinct_t *) opj_malloc(/*3 * */
- l_nb_precinct_size);
- if (! l_band->precincts) {
- opj_event_msg(manager, EVT_ERROR,
- "Not enough memory to handle band precints\n");
- return OPJ_FALSE;
- }
- /*fprintf(stderr, "\t\t\t\tAllocate precincts of a band (opj_tcd_precinct_t): %d\n",l_nb_precinct_size); */
- memset(l_band->precincts, 0, l_nb_precinct_size);
- l_band->precincts_data_size = l_nb_precinct_size;
- } else if (l_band->precincts_data_size < l_nb_precinct_size) {
-
- opj_tcd_precinct_t * new_precincts = (opj_tcd_precinct_t *) opj_realloc(
- l_band->precincts,/*3 * */ l_nb_precinct_size);
- if (! new_precincts) {
- opj_event_msg(manager, EVT_ERROR,
- "Not enough memory to handle band precints\n");
- opj_free(l_band->precincts);
- l_band->precincts = NULL;
- l_band->precincts_data_size = 0;
- return OPJ_FALSE;
- }
- l_band->precincts = new_precincts;
- /*fprintf(stderr, "\t\t\t\tReallocate precincts of a band (opj_tcd_precinct_t): from %d to %d\n",l_band->precincts_data_size, l_nb_precinct_size);*/
- memset(((OPJ_BYTE *) l_band->precincts) + l_band->precincts_data_size, 0,
- l_nb_precinct_size - l_band->precincts_data_size);
- l_band->precincts_data_size = l_nb_precinct_size;
- }
-
- l_current_precinct = l_band->precincts;
- for (precno = 0; precno < l_nb_precincts; ++precno) {
- OPJ_INT32 tlcblkxstart, tlcblkystart, brcblkxend, brcblkyend;
- OPJ_INT32 cbgxstart = tlcbgxstart + (OPJ_INT32)(precno % l_res->pw) *
- (1 << cbgwidthexpn);
- OPJ_INT32 cbgystart = tlcbgystart + (OPJ_INT32)(precno / l_res->pw) *
- (1 << cbgheightexpn);
- OPJ_INT32 cbgxend = cbgxstart + (1 << cbgwidthexpn);
- OPJ_INT32 cbgyend = cbgystart + (1 << cbgheightexpn);
- /*fprintf(stderr, "\t precno=%d; bandno=%d, resno=%d; compno=%d\n", precno, bandno , resno, compno);*/
- /*fprintf(stderr, "\t tlcbgxstart(=%d) + (precno(=%d) percent res->pw(=%d)) * (1 << cbgwidthexpn(=%d)) \n",tlcbgxstart,precno,l_res->pw,cbgwidthexpn);*/
-
- /* precinct size (global) */
- /*fprintf(stderr, "\t cbgxstart=%d, l_band->x0 = %d \n",cbgxstart, l_band->x0);*/
-
- l_current_precinct->x0 = opj_int_max(cbgxstart, l_band->x0);
- l_current_precinct->y0 = opj_int_max(cbgystart, l_band->y0);
- l_current_precinct->x1 = opj_int_min(cbgxend, l_band->x1);
- l_current_precinct->y1 = opj_int_min(cbgyend, l_band->y1);
- /*fprintf(stderr, "\t prc_x0=%d; prc_y0=%d, prc_x1=%d; prc_y1=%d\n",l_current_precinct->x0, l_current_precinct->y0 ,l_current_precinct->x1, l_current_precinct->y1);*/
-
- tlcblkxstart = opj_int_floordivpow2(l_current_precinct->x0,
- (OPJ_INT32)cblkwidthexpn) << cblkwidthexpn;
- /*fprintf(stderr, "\t tlcblkxstart =%d\n",tlcblkxstart );*/
- tlcblkystart = opj_int_floordivpow2(l_current_precinct->y0,
- (OPJ_INT32)cblkheightexpn) << cblkheightexpn;
- /*fprintf(stderr, "\t tlcblkystart =%d\n",tlcblkystart );*/
- brcblkxend = opj_int_ceildivpow2(l_current_precinct->x1,
- (OPJ_INT32)cblkwidthexpn) << cblkwidthexpn;
- /*fprintf(stderr, "\t brcblkxend =%d\n",brcblkxend );*/
- brcblkyend = opj_int_ceildivpow2(l_current_precinct->y1,
- (OPJ_INT32)cblkheightexpn) << cblkheightexpn;
- /*fprintf(stderr, "\t brcblkyend =%d\n",brcblkyend );*/
- l_current_precinct->cw = (OPJ_UINT32)((brcblkxend - tlcblkxstart) >>
- cblkwidthexpn);
- l_current_precinct->ch = (OPJ_UINT32)((brcblkyend - tlcblkystart) >>
- cblkheightexpn);
-
- l_nb_code_blocks = l_current_precinct->cw * l_current_precinct->ch;
- /*fprintf(stderr, "\t\t\t\t precinct_cw = %d x recinct_ch = %d\n",l_current_precinct->cw, l_current_precinct->ch); */
- if ((((OPJ_UINT32) - 1) / (OPJ_UINT32)sizeof_block) <
- l_nb_code_blocks) {
- opj_event_msg(manager, EVT_ERROR,
- "Size of code block data exceeds system limits\n");
- return OPJ_FALSE;
- }
- l_nb_code_blocks_size = l_nb_code_blocks * (OPJ_UINT32)sizeof_block;
-
- if (!l_current_precinct->cblks.blocks && (l_nb_code_blocks > 0U)) {
- l_current_precinct->cblks.blocks = opj_malloc(l_nb_code_blocks_size);
- if (! l_current_precinct->cblks.blocks) {
- return OPJ_FALSE;
- }
- /*fprintf(stderr, "\t\t\t\tAllocate cblks of a precinct (opj_tcd_cblk_dec_t): %d\n",l_nb_code_blocks_size);*/
-
- memset(l_current_precinct->cblks.blocks, 0, l_nb_code_blocks_size);
-
- l_current_precinct->block_size = l_nb_code_blocks_size;
- } else if (l_nb_code_blocks_size > l_current_precinct->block_size) {
- void *new_blocks = opj_realloc(l_current_precinct->cblks.blocks,
- l_nb_code_blocks_size);
- if (! new_blocks) {
- opj_free(l_current_precinct->cblks.blocks);
- l_current_precinct->cblks.blocks = NULL;
- l_current_precinct->block_size = 0;
- opj_event_msg(manager, EVT_ERROR,
- "Not enough memory for current precinct codeblock element\n");
- return OPJ_FALSE;
- }
- l_current_precinct->cblks.blocks = new_blocks;
- /*fprintf(stderr, "\t\t\t\tReallocate cblks of a precinct (opj_tcd_cblk_dec_t): from %d to %d\n",l_current_precinct->block_size, l_nb_code_blocks_size); */
-
- memset(((OPJ_BYTE *) l_current_precinct->cblks.blocks) +
- l_current_precinct->block_size
- , 0
- , l_nb_code_blocks_size - l_current_precinct->block_size);
-
- l_current_precinct->block_size = l_nb_code_blocks_size;
- }
-
- if (! l_current_precinct->incltree) {
- l_current_precinct->incltree = opj_tgt_create(l_current_precinct->cw,
- l_current_precinct->ch, manager);
- } else {
- l_current_precinct->incltree = opj_tgt_init(l_current_precinct->incltree,
- l_current_precinct->cw, l_current_precinct->ch, manager);
- }
-
- if (! l_current_precinct->imsbtree) {
- l_current_precinct->imsbtree = opj_tgt_create(l_current_precinct->cw,
- l_current_precinct->ch, manager);
- } else {
- l_current_precinct->imsbtree = opj_tgt_init(l_current_precinct->imsbtree,
- l_current_precinct->cw, l_current_precinct->ch, manager);
- }
-
- for (cblkno = 0; cblkno < l_nb_code_blocks; ++cblkno) {
- OPJ_INT32 cblkxstart = tlcblkxstart + (OPJ_INT32)(cblkno %
- l_current_precinct->cw) * (1 << cblkwidthexpn);
- OPJ_INT32 cblkystart = tlcblkystart + (OPJ_INT32)(cblkno /
- l_current_precinct->cw) * (1 << cblkheightexpn);
- OPJ_INT32 cblkxend = cblkxstart + (1 << cblkwidthexpn);
- OPJ_INT32 cblkyend = cblkystart + (1 << cblkheightexpn);
-
- if (isEncoder) {
- opj_tcd_cblk_enc_t* l_code_block = l_current_precinct->cblks.enc + cblkno;
-
- if (! opj_tcd_code_block_enc_allocate(l_code_block)) {
- return OPJ_FALSE;
- }
- /* code-block size (global) */
- l_code_block->x0 = opj_int_max(cblkxstart, l_current_precinct->x0);
- l_code_block->y0 = opj_int_max(cblkystart, l_current_precinct->y0);
- l_code_block->x1 = opj_int_min(cblkxend, l_current_precinct->x1);
- l_code_block->y1 = opj_int_min(cblkyend, l_current_precinct->y1);
-
- if (! opj_tcd_code_block_enc_allocate_data(l_code_block)) {
- return OPJ_FALSE;
- }
- } else {
- opj_tcd_cblk_dec_t* l_code_block = l_current_precinct->cblks.dec + cblkno;
-
- if (! opj_tcd_code_block_dec_allocate(l_code_block)) {
- return OPJ_FALSE;
- }
- /* code-block size (global) */
- l_code_block->x0 = opj_int_max(cblkxstart, l_current_precinct->x0);
- l_code_block->y0 = opj_int_max(cblkystart, l_current_precinct->y0);
- l_code_block->x1 = opj_int_min(cblkxend, l_current_precinct->x1);
- l_code_block->y1 = opj_int_min(cblkyend, l_current_precinct->y1);
- }
- }
- ++l_current_precinct;
- } /* precno */
- } /* bandno */
- ++l_res;
- } /* resno */
- ++l_tccp;
- ++l_tilec;
- ++l_image_comp;
- } /* compno */
- return OPJ_TRUE;
-}
-
-OPJ_BOOL opj_tcd_init_encode_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
- opj_event_mgr_t* p_manager)
-{
- return opj_tcd_init_tile(p_tcd, p_tile_no, OPJ_TRUE,
- sizeof(opj_tcd_cblk_enc_t), p_manager);
-}
-
-OPJ_BOOL opj_tcd_init_decode_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
- opj_event_mgr_t* p_manager)
-{
- return opj_tcd_init_tile(p_tcd, p_tile_no, OPJ_FALSE,
- sizeof(opj_tcd_cblk_dec_t), p_manager);
-}
-
-/**
- * Allocates memory for an encoding code block (but not data memory).
- */
-static OPJ_BOOL opj_tcd_code_block_enc_allocate(opj_tcd_cblk_enc_t *
- p_code_block)
-{
- if (! p_code_block->layers) {
- /* no memset since data */
- p_code_block->layers = (opj_tcd_layer_t*) opj_calloc(100,
- sizeof(opj_tcd_layer_t));
- if (! p_code_block->layers) {
- return OPJ_FALSE;
- }
- }
- if (! p_code_block->passes) {
- p_code_block->passes = (opj_tcd_pass_t*) opj_calloc(100,
- sizeof(opj_tcd_pass_t));
- if (! p_code_block->passes) {
- return OPJ_FALSE;
- }
- }
- return OPJ_TRUE;
-}
-
-/**
- * Allocates data memory for an encoding code block.
- */
-static OPJ_BOOL opj_tcd_code_block_enc_allocate_data(opj_tcd_cblk_enc_t *
- p_code_block)
-{
- OPJ_UINT32 l_data_size;
-
- /* +1 is needed for https://github.com/uclouvain/openjpeg/issues/835 */
- /* and actually +2 required for https://github.com/uclouvain/openjpeg/issues/982 */
- /* and +7 for https://github.com/uclouvain/openjpeg/issues/1283 (-M 3) */
- /* and +26 for https://github.com/uclouvain/openjpeg/issues/1283 (-M 7) */
- /* and +28 for https://github.com/uclouvain/openjpeg/issues/1283 (-M 44) */
- /* and +33 for https://github.com/uclouvain/openjpeg/issues/1283 (-M 4) */
- /* and +63 for https://github.com/uclouvain/openjpeg/issues/1283 (-M 4 -IMF 2K) */
- /* and +74 for https://github.com/uclouvain/openjpeg/issues/1283 (-M 4 -n 8 -s 7,7 -I) */
- /* TODO: is there a theoretical upper-bound for the compressed code */
- /* block size ? */
- l_data_size = 74 + (OPJ_UINT32)((p_code_block->x1 - p_code_block->x0) *
- (p_code_block->y1 - p_code_block->y0) * (OPJ_INT32)sizeof(OPJ_UINT32));
-
- if (l_data_size > p_code_block->data_size) {
- if (p_code_block->data) {
- /* We refer to data - 1 since below we incremented it */
- opj_free(p_code_block->data - 1);
- }
- p_code_block->data = (OPJ_BYTE*) opj_malloc(l_data_size + 1);
- if (! p_code_block->data) {
- p_code_block->data_size = 0U;
- return OPJ_FALSE;
- }
- p_code_block->data_size = l_data_size;
-
- /* We reserve the initial byte as a fake byte to a non-FF value */
- /* and increment the data pointer, so that opj_mqc_init_enc() */
- /* can do bp = data - 1, and opj_mqc_byteout() can safely dereference */
- /* it. */
- p_code_block->data[0] = 0;
- p_code_block->data += 1; /*why +1 ?*/
- }
- return OPJ_TRUE;
-}
-
-
-void opj_tcd_reinit_segment(opj_tcd_seg_t* seg)
-{
- memset(seg, 0, sizeof(opj_tcd_seg_t));
-}
-
-/**
- * Allocates memory for a decoding code block.
- */
-static OPJ_BOOL opj_tcd_code_block_dec_allocate(opj_tcd_cblk_dec_t *
- p_code_block)
-{
- if (! p_code_block->segs) {
-
- p_code_block->segs = (opj_tcd_seg_t *) opj_calloc(OPJ_J2K_DEFAULT_NB_SEGS,
- sizeof(opj_tcd_seg_t));
- if (! p_code_block->segs) {
- return OPJ_FALSE;
- }
- /*fprintf(stderr, "Allocate %d elements of code_block->data\n", OPJ_J2K_DEFAULT_NB_SEGS * sizeof(opj_tcd_seg_t));*/
-
- p_code_block->m_current_max_segs = OPJ_J2K_DEFAULT_NB_SEGS;
- /*fprintf(stderr, "m_current_max_segs of code_block->data = %d\n", p_code_block->m_current_max_segs);*/
- } else {
- /* sanitize */
- opj_tcd_seg_t * l_segs = p_code_block->segs;
- OPJ_UINT32 l_current_max_segs = p_code_block->m_current_max_segs;
- opj_tcd_seg_data_chunk_t* l_chunks = p_code_block->chunks;
- OPJ_UINT32 l_numchunksalloc = p_code_block->numchunksalloc;
- OPJ_UINT32 i;
-
- opj_aligned_free(p_code_block->decoded_data);
- p_code_block->decoded_data = 00;
-
- memset(p_code_block, 0, sizeof(opj_tcd_cblk_dec_t));
- p_code_block->segs = l_segs;
- p_code_block->m_current_max_segs = l_current_max_segs;
- for (i = 0; i < l_current_max_segs; ++i) {
- opj_tcd_reinit_segment(&l_segs[i]);
- }
- p_code_block->chunks = l_chunks;
- p_code_block->numchunksalloc = l_numchunksalloc;
- }
-
- return OPJ_TRUE;
-}
-
-OPJ_UINT32 opj_tcd_get_decoded_tile_size(opj_tcd_t *p_tcd,
- OPJ_BOOL take_into_account_partial_decoding)
-{
- OPJ_UINT32 i;
- OPJ_UINT32 l_data_size = 0;
- opj_image_comp_t * l_img_comp = 00;
- opj_tcd_tilecomp_t * l_tile_comp = 00;
- opj_tcd_resolution_t * l_res = 00;
- OPJ_UINT32 l_size_comp, l_remaining;
- OPJ_UINT32 l_temp;
-
- l_tile_comp = p_tcd->tcd_image->tiles->comps;
- l_img_comp = p_tcd->image->comps;
-
- for (i = 0; i < p_tcd->image->numcomps; ++i) {
- OPJ_UINT32 w, h;
- l_size_comp = l_img_comp->prec >> 3; /*(/ 8)*/
- l_remaining = l_img_comp->prec & 7; /* (%8) */
-
- if (l_remaining) {
- ++l_size_comp;
- }
-
- if (l_size_comp == 3) {
- l_size_comp = 4;
- }
-
- l_res = l_tile_comp->resolutions + l_tile_comp->minimum_num_resolutions - 1;
- if (take_into_account_partial_decoding && !p_tcd->whole_tile_decoding) {
- w = l_res->win_x1 - l_res->win_x0;
- h = l_res->win_y1 - l_res->win_y0;
- } else {
- w = (OPJ_UINT32)(l_res->x1 - l_res->x0);
- h = (OPJ_UINT32)(l_res->y1 - l_res->y0);
- }
- if (h > 0 && UINT_MAX / w < h) {
- return UINT_MAX;
- }
- l_temp = w * h;
- if (l_size_comp && UINT_MAX / l_size_comp < l_temp) {
- return UINT_MAX;
- }
- l_temp *= l_size_comp;
-
- if (l_temp > UINT_MAX - l_data_size) {
- return UINT_MAX;
- }
- l_data_size += l_temp;
- ++l_img_comp;
- ++l_tile_comp;
- }
-
- return l_data_size;
-}
-
-OPJ_BOOL opj_tcd_encode_tile(opj_tcd_t *p_tcd,
- OPJ_UINT32 p_tile_no,
- OPJ_BYTE *p_dest,
- OPJ_UINT32 * p_data_written,
- OPJ_UINT32 p_max_length,
- opj_codestream_info_t *p_cstr_info,
- opj_tcd_marker_info_t* p_marker_info,
- opj_event_mgr_t *p_manager)
-{
-
- if (p_tcd->cur_tp_num == 0) {
-
- p_tcd->tcd_tileno = p_tile_no;
- p_tcd->tcp = &p_tcd->cp->tcps[p_tile_no];
-
- /* INDEX >> "Precinct_nb_X et Precinct_nb_Y" */
- if (p_cstr_info) {
- OPJ_UINT32 l_num_packs = 0;
- OPJ_UINT32 i;
- opj_tcd_tilecomp_t *l_tilec_idx =
- &p_tcd->tcd_image->tiles->comps[0]; /* based on component 0 */
- opj_tccp_t *l_tccp = p_tcd->tcp->tccps; /* based on component 0 */
-
- for (i = 0; i < l_tilec_idx->numresolutions; i++) {
- opj_tcd_resolution_t *l_res_idx = &l_tilec_idx->resolutions[i];
-
- p_cstr_info->tile[p_tile_no].pw[i] = (int)l_res_idx->pw;
- p_cstr_info->tile[p_tile_no].ph[i] = (int)l_res_idx->ph;
-
- l_num_packs += l_res_idx->pw * l_res_idx->ph;
- p_cstr_info->tile[p_tile_no].pdx[i] = (int)l_tccp->prcw[i];
- p_cstr_info->tile[p_tile_no].pdy[i] = (int)l_tccp->prch[i];
- }
- p_cstr_info->tile[p_tile_no].packet = (opj_packet_info_t*) opj_calloc((
- OPJ_SIZE_T)p_cstr_info->numcomps * (OPJ_SIZE_T)p_cstr_info->numlayers *
- l_num_packs,
- sizeof(opj_packet_info_t));
- if (!p_cstr_info->tile[p_tile_no].packet) {
- /* FIXME event manager error callback */
- return OPJ_FALSE;
- }
- }
- /* << INDEX */
-
- /* FIXME _ProfStart(PGROUP_DC_SHIFT); */
- /*---------------TILE-------------------*/
- if (! opj_tcd_dc_level_shift_encode(p_tcd)) {
- return OPJ_FALSE;
- }
- /* FIXME _ProfStop(PGROUP_DC_SHIFT); */
-
- /* FIXME _ProfStart(PGROUP_MCT); */
- if (! opj_tcd_mct_encode(p_tcd)) {
- return OPJ_FALSE;
- }
- /* FIXME _ProfStop(PGROUP_MCT); */
-
- /* FIXME _ProfStart(PGROUP_DWT); */
- if (! opj_tcd_dwt_encode(p_tcd)) {
- return OPJ_FALSE;
- }
- /* FIXME _ProfStop(PGROUP_DWT); */
-
- /* FIXME _ProfStart(PGROUP_T1); */
- if (! opj_tcd_t1_encode(p_tcd)) {
- return OPJ_FALSE;
- }
- /* FIXME _ProfStop(PGROUP_T1); */
-
- /* FIXME _ProfStart(PGROUP_RATE); */
- if (! opj_tcd_rate_allocate_encode(p_tcd, p_dest, p_max_length,
- p_cstr_info, p_manager)) {
- return OPJ_FALSE;
- }
- /* FIXME _ProfStop(PGROUP_RATE); */
-
- }
- /*--------------TIER2------------------*/
-
- /* INDEX */
- if (p_cstr_info) {
- p_cstr_info->index_write = 1;
- }
- /* FIXME _ProfStart(PGROUP_T2); */
-
- if (! opj_tcd_t2_encode(p_tcd, p_dest, p_data_written, p_max_length,
- p_cstr_info, p_marker_info, p_manager)) {
- return OPJ_FALSE;
- }
- /* FIXME _ProfStop(PGROUP_T2); */
-
- /*---------------CLEAN-------------------*/
-
- return OPJ_TRUE;
-}
-
-OPJ_BOOL opj_tcd_decode_tile(opj_tcd_t *p_tcd,
- OPJ_UINT32 win_x0,
- OPJ_UINT32 win_y0,
- OPJ_UINT32 win_x1,
- OPJ_UINT32 win_y1,
- OPJ_UINT32 numcomps_to_decode,
- const OPJ_UINT32 *comps_indices,
- OPJ_BYTE *p_src,
- OPJ_UINT32 p_max_length,
- OPJ_UINT32 p_tile_no,
- opj_codestream_index_t *p_cstr_index,
- opj_event_mgr_t *p_manager
- )
-{
- OPJ_UINT32 l_data_read;
- OPJ_UINT32 compno;
-
- p_tcd->tcd_tileno = p_tile_no;
- p_tcd->tcp = &(p_tcd->cp->tcps[p_tile_no]);
- p_tcd->win_x0 = win_x0;
- p_tcd->win_y0 = win_y0;
- p_tcd->win_x1 = win_x1;
- p_tcd->win_y1 = win_y1;
- p_tcd->whole_tile_decoding = OPJ_TRUE;
-
- opj_free(p_tcd->used_component);
- p_tcd->used_component = NULL;
-
- if (numcomps_to_decode) {
- OPJ_BOOL* used_component = (OPJ_BOOL*) opj_calloc(sizeof(OPJ_BOOL),
- p_tcd->image->numcomps);
- if (used_component == NULL) {
- return OPJ_FALSE;
- }
- for (compno = 0; compno < numcomps_to_decode; compno++) {
- used_component[ comps_indices[compno] ] = OPJ_TRUE;
- }
-
- p_tcd->used_component = used_component;
- }
-
- for (compno = 0; compno < p_tcd->image->numcomps; compno++) {
- if (p_tcd->used_component != NULL && !p_tcd->used_component[compno]) {
- continue;
- }
-
- if (!opj_tcd_is_whole_tilecomp_decoding(p_tcd, compno)) {
- p_tcd->whole_tile_decoding = OPJ_FALSE;
- break;
- }
- }
-
- if (p_tcd->whole_tile_decoding) {
- for (compno = 0; compno < p_tcd->image->numcomps; compno++) {
- opj_tcd_tilecomp_t* tilec = &(p_tcd->tcd_image->tiles->comps[compno]);
- opj_tcd_resolution_t *l_res = &
- (tilec->resolutions[tilec->minimum_num_resolutions - 1]);
- OPJ_SIZE_T l_data_size;
-
- /* compute l_data_size with overflow check */
- OPJ_SIZE_T res_w = (OPJ_SIZE_T)(l_res->x1 - l_res->x0);
- OPJ_SIZE_T res_h = (OPJ_SIZE_T)(l_res->y1 - l_res->y0);
-
- if (p_tcd->used_component != NULL && !p_tcd->used_component[compno]) {
- continue;
- }
-
- /* issue 733, l_data_size == 0U, probably something wrong should be checked before getting here */
- if (res_h > 0 && res_w > SIZE_MAX / res_h) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Size of tile data exceeds system limits\n");
- return OPJ_FALSE;
- }
- l_data_size = res_w * res_h;
-
- if (SIZE_MAX / sizeof(OPJ_UINT32) < l_data_size) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Size of tile data exceeds system limits\n");
- return OPJ_FALSE;
- }
- l_data_size *= sizeof(OPJ_UINT32);
-
- tilec->data_size_needed = l_data_size;
-
- if (!opj_alloc_tile_component_data(tilec)) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Size of tile data exceeds system limits\n");
- return OPJ_FALSE;
- }
- }
- } else {
- /* Compute restricted tile-component and tile-resolution coordinates */
- /* of the window of interest, but defer the memory allocation until */
- /* we know the resno_decoded */
- for (compno = 0; compno < p_tcd->image->numcomps; compno++) {
- OPJ_UINT32 resno;
- opj_tcd_tilecomp_t* tilec = &(p_tcd->tcd_image->tiles->comps[compno]);
- opj_image_comp_t* image_comp = &(p_tcd->image->comps[compno]);
-
- if (p_tcd->used_component != NULL && !p_tcd->used_component[compno]) {
- continue;
- }
-
- /* Compute the intersection of the area of interest, expressed in tile coordinates */
- /* with the tile coordinates */
- tilec->win_x0 = opj_uint_max(
- (OPJ_UINT32)tilec->x0,
- opj_uint_ceildiv(p_tcd->win_x0, image_comp->dx));
- tilec->win_y0 = opj_uint_max(
- (OPJ_UINT32)tilec->y0,
- opj_uint_ceildiv(p_tcd->win_y0, image_comp->dy));
- tilec->win_x1 = opj_uint_min(
- (OPJ_UINT32)tilec->x1,
- opj_uint_ceildiv(p_tcd->win_x1, image_comp->dx));
- tilec->win_y1 = opj_uint_min(
- (OPJ_UINT32)tilec->y1,
- opj_uint_ceildiv(p_tcd->win_y1, image_comp->dy));
- if (tilec->win_x1 < tilec->win_x0 ||
- tilec->win_y1 < tilec->win_y0) {
- /* We should not normally go there. The circumstance is when */
- /* the tile coordinates do not intersect the area of interest */
- /* Upper level logic should not even try to decode that tile */
- opj_event_msg(p_manager, EVT_ERROR,
- "Invalid tilec->win_xxx values\n");
- return OPJ_FALSE;
- }
-
- for (resno = 0; resno < tilec->numresolutions; ++resno) {
- opj_tcd_resolution_t *res = tilec->resolutions + resno;
- res->win_x0 = opj_uint_ceildivpow2(tilec->win_x0,
- tilec->numresolutions - 1 - resno);
- res->win_y0 = opj_uint_ceildivpow2(tilec->win_y0,
- tilec->numresolutions - 1 - resno);
- res->win_x1 = opj_uint_ceildivpow2(tilec->win_x1,
- tilec->numresolutions - 1 - resno);
- res->win_y1 = opj_uint_ceildivpow2(tilec->win_y1,
- tilec->numresolutions - 1 - resno);
- }
- }
- }
-
-#ifdef TODO_MSD /* FIXME */
- /* INDEX >> */
- if (p_cstr_info) {
- OPJ_UINT32 resno, compno, numprec = 0;
- for (compno = 0; compno < (OPJ_UINT32) p_cstr_info->numcomps; compno++) {
- opj_tcp_t *tcp = &p_tcd->cp->tcps[0];
- opj_tccp_t *tccp = &tcp->tccps[compno];
- opj_tcd_tilecomp_t *tilec_idx = &p_tcd->tcd_image->tiles->comps[compno];
- for (resno = 0; resno < tilec_idx->numresolutions; resno++) {
- opj_tcd_resolution_t *res_idx = &tilec_idx->resolutions[resno];
- p_cstr_info->tile[p_tile_no].pw[resno] = res_idx->pw;
- p_cstr_info->tile[p_tile_no].ph[resno] = res_idx->ph;
- numprec += res_idx->pw * res_idx->ph;
- p_cstr_info->tile[p_tile_no].pdx[resno] = tccp->prcw[resno];
- p_cstr_info->tile[p_tile_no].pdy[resno] = tccp->prch[resno];
- }
- }
- p_cstr_info->tile[p_tile_no].packet = (opj_packet_info_t *) opj_malloc(
- p_cstr_info->numlayers * numprec * sizeof(opj_packet_info_t));
- p_cstr_info->packno = 0;
- }
- /* << INDEX */
-#endif
-
- /*--------------TIER2------------------*/
- /* FIXME _ProfStart(PGROUP_T2); */
- l_data_read = 0;
- if (! opj_tcd_t2_decode(p_tcd, p_src, &l_data_read, p_max_length, p_cstr_index,
- p_manager)) {
- return OPJ_FALSE;
- }
- /* FIXME _ProfStop(PGROUP_T2); */
-
- /*------------------TIER1-----------------*/
-
- /* FIXME _ProfStart(PGROUP_T1); */
- if (! opj_tcd_t1_decode(p_tcd, p_manager)) {
- return OPJ_FALSE;
- }
- /* FIXME _ProfStop(PGROUP_T1); */
-
-
- /* For subtile decoding, now we know the resno_decoded, we can allocate */
- /* the tile data buffer */
- if (!p_tcd->whole_tile_decoding) {
- for (compno = 0; compno < p_tcd->image->numcomps; compno++) {
- opj_tcd_tilecomp_t* tilec = &(p_tcd->tcd_image->tiles->comps[compno]);
- opj_image_comp_t* image_comp = &(p_tcd->image->comps[compno]);
- opj_tcd_resolution_t *res = tilec->resolutions + image_comp->resno_decoded;
- OPJ_SIZE_T w = res->win_x1 - res->win_x0;
- OPJ_SIZE_T h = res->win_y1 - res->win_y0;
- OPJ_SIZE_T l_data_size;
-
- opj_image_data_free(tilec->data_win);
- tilec->data_win = NULL;
-
- if (p_tcd->used_component != NULL && !p_tcd->used_component[compno]) {
- continue;
- }
-
- if (w > 0 && h > 0) {
- if (w > SIZE_MAX / h) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Size of tile data exceeds system limits\n");
- return OPJ_FALSE;
- }
- l_data_size = w * h;
- if (l_data_size > SIZE_MAX / sizeof(OPJ_INT32)) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Size of tile data exceeds system limits\n");
- return OPJ_FALSE;
- }
- l_data_size *= sizeof(OPJ_INT32);
-
- tilec->data_win = (OPJ_INT32*) opj_image_data_alloc(l_data_size);
- if (tilec->data_win == NULL) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Size of tile data exceeds system limits\n");
- return OPJ_FALSE;
- }
- }
- }
- }
-
- /*----------------DWT---------------------*/
-
- /* FIXME _ProfStart(PGROUP_DWT); */
- if
- (! opj_tcd_dwt_decode(p_tcd)) {
- return OPJ_FALSE;
- }
- /* FIXME _ProfStop(PGROUP_DWT); */
-
- /*----------------MCT-------------------*/
- /* FIXME _ProfStart(PGROUP_MCT); */
- if
- (! opj_tcd_mct_decode(p_tcd, p_manager)) {
- return OPJ_FALSE;
- }
- /* FIXME _ProfStop(PGROUP_MCT); */
-
- /* FIXME _ProfStart(PGROUP_DC_SHIFT); */
- if
- (! opj_tcd_dc_level_shift_decode(p_tcd)) {
- return OPJ_FALSE;
- }
- /* FIXME _ProfStop(PGROUP_DC_SHIFT); */
-
-
- /*---------------TILE-------------------*/
- return OPJ_TRUE;
-}
-
-OPJ_BOOL opj_tcd_update_tile_data(opj_tcd_t *p_tcd,
- OPJ_BYTE * p_dest,
- OPJ_UINT32 p_dest_length
- )
-{
- OPJ_UINT32 i, j, k, l_data_size = 0;
- opj_image_comp_t * l_img_comp = 00;
- opj_tcd_tilecomp_t * l_tilec = 00;
- opj_tcd_resolution_t * l_res;
- OPJ_UINT32 l_size_comp, l_remaining;
- OPJ_UINT32 l_stride, l_width, l_height;
-
- l_data_size = opj_tcd_get_decoded_tile_size(p_tcd, OPJ_TRUE);
- if (l_data_size == UINT_MAX || l_data_size > p_dest_length) {
- return OPJ_FALSE;
- }
-
- l_tilec = p_tcd->tcd_image->tiles->comps;
- l_img_comp = p_tcd->image->comps;
-
- for (i = 0; i < p_tcd->image->numcomps; ++i) {
- const OPJ_INT32* l_src_data;
- l_size_comp = l_img_comp->prec >> 3; /*(/ 8)*/
- l_remaining = l_img_comp->prec & 7; /* (%8) */
- l_res = l_tilec->resolutions + l_img_comp->resno_decoded;
- if (p_tcd->whole_tile_decoding) {
- l_width = (OPJ_UINT32)(l_res->x1 - l_res->x0);
- l_height = (OPJ_UINT32)(l_res->y1 - l_res->y0);
- l_stride = (OPJ_UINT32)(l_tilec->resolutions[l_tilec->minimum_num_resolutions -
- 1].x1 -
- l_tilec->resolutions[l_tilec->minimum_num_resolutions - 1].x0) - l_width;
- l_src_data = l_tilec->data;
- } else {
- l_width = l_res->win_x1 - l_res->win_x0;
- l_height = l_res->win_y1 - l_res->win_y0;
- l_stride = 0;
- l_src_data = l_tilec->data_win;
- }
-
- if (l_remaining) {
- ++l_size_comp;
- }
-
- if (l_size_comp == 3) {
- l_size_comp = 4;
- }
-
- switch (l_size_comp) {
- case 1: {
- OPJ_CHAR * l_dest_ptr = (OPJ_CHAR *) p_dest;
- const OPJ_INT32 * l_src_ptr = l_src_data;
-
- if (l_img_comp->sgnd) {
- for (j = 0; j < l_height; ++j) {
- for (k = 0; k < l_width; ++k) {
- *(l_dest_ptr++) = (OPJ_CHAR)(*(l_src_ptr++));
- }
- l_src_ptr += l_stride;
- }
- } else {
- for (j = 0; j < l_height; ++j) {
- for (k = 0; k < l_width; ++k) {
- *(l_dest_ptr++) = (OPJ_CHAR)((*(l_src_ptr++)) & 0xff);
- }
- l_src_ptr += l_stride;
- }
- }
-
- p_dest = (OPJ_BYTE *)l_dest_ptr;
- }
- break;
- case 2: {
- const OPJ_INT32 * l_src_ptr = l_src_data;
- OPJ_INT16 * l_dest_ptr = (OPJ_INT16 *) p_dest;
-
- if (l_img_comp->sgnd) {
- for (j = 0; j < l_height; ++j) {
- for (k = 0; k < l_width; ++k) {
- OPJ_INT16 val = (OPJ_INT16)(*(l_src_ptr++));
- memcpy(l_dest_ptr, &val, sizeof(val));
- l_dest_ptr ++;
- }
- l_src_ptr += l_stride;
- }
- } else {
- for (j = 0; j < l_height; ++j) {
- for (k = 0; k < l_width; ++k) {
- OPJ_INT16 val = (OPJ_INT16)((*(l_src_ptr++)) & 0xffff);
- memcpy(l_dest_ptr, &val, sizeof(val));
- l_dest_ptr ++;
- }
- l_src_ptr += l_stride;
- }
- }
-
- p_dest = (OPJ_BYTE*) l_dest_ptr;
- }
- break;
- case 4: {
- OPJ_INT32 * l_dest_ptr = (OPJ_INT32 *) p_dest;
- const OPJ_INT32 * l_src_ptr = l_src_data;
-
- for (j = 0; j < l_height; ++j) {
- memcpy(l_dest_ptr, l_src_ptr, l_width * sizeof(OPJ_INT32));
- l_dest_ptr += l_width;
- l_src_ptr += l_width + l_stride;
- }
-
- p_dest = (OPJ_BYTE*) l_dest_ptr;
- }
- break;
- }
-
- ++l_img_comp;
- ++l_tilec;
- }
-
- return OPJ_TRUE;
-}
-
-
-
-
-static void opj_tcd_free_tile(opj_tcd_t *p_tcd)
-{
- OPJ_UINT32 compno, resno, bandno, precno;
- opj_tcd_tile_t *l_tile = 00;
- opj_tcd_tilecomp_t *l_tile_comp = 00;
- opj_tcd_resolution_t *l_res = 00;
- opj_tcd_band_t *l_band = 00;
- opj_tcd_precinct_t *l_precinct = 00;
- OPJ_UINT32 l_nb_resolutions, l_nb_precincts;
- void (* l_tcd_code_block_deallocate)(opj_tcd_precinct_t *) = 00;
-
- if (! p_tcd) {
- return;
- }
-
- if (! p_tcd->tcd_image) {
- return;
- }
-
- if (p_tcd->m_is_decoder) {
- l_tcd_code_block_deallocate = opj_tcd_code_block_dec_deallocate;
- } else {
- l_tcd_code_block_deallocate = opj_tcd_code_block_enc_deallocate;
- }
-
- l_tile = p_tcd->tcd_image->tiles;
- if (! l_tile) {
- return;
- }
-
- l_tile_comp = l_tile->comps;
-
- for (compno = 0; compno < l_tile->numcomps; ++compno) {
- l_res = l_tile_comp->resolutions;
- if (l_res) {
-
- l_nb_resolutions = l_tile_comp->resolutions_size / (OPJ_UINT32)sizeof(
- opj_tcd_resolution_t);
- for (resno = 0; resno < l_nb_resolutions; ++resno) {
- l_band = l_res->bands;
- for (bandno = 0; bandno < 3; ++bandno) {
- l_precinct = l_band->precincts;
- if (l_precinct) {
-
- l_nb_precincts = l_band->precincts_data_size / (OPJ_UINT32)sizeof(
- opj_tcd_precinct_t);
- for (precno = 0; precno < l_nb_precincts; ++precno) {
- opj_tgt_destroy(l_precinct->incltree);
- l_precinct->incltree = 00;
- opj_tgt_destroy(l_precinct->imsbtree);
- l_precinct->imsbtree = 00;
- (*l_tcd_code_block_deallocate)(l_precinct);
- ++l_precinct;
- }
-
- opj_free(l_band->precincts);
- l_band->precincts = 00;
- }
- ++l_band;
- } /* for (resno */
- ++l_res;
- }
-
- opj_free(l_tile_comp->resolutions);
- l_tile_comp->resolutions = 00;
- }
-
- if (l_tile_comp->ownsData && l_tile_comp->data) {
- opj_image_data_free(l_tile_comp->data);
- l_tile_comp->data = 00;
- l_tile_comp->ownsData = 0;
- l_tile_comp->data_size = 0;
- l_tile_comp->data_size_needed = 0;
- }
-
- opj_image_data_free(l_tile_comp->data_win);
-
- ++l_tile_comp;
- }
-
- opj_free(l_tile->comps);
- l_tile->comps = 00;
- opj_free(p_tcd->tcd_image->tiles);
- p_tcd->tcd_image->tiles = 00;
-}
-
-
-static OPJ_BOOL opj_tcd_t2_decode(opj_tcd_t *p_tcd,
- OPJ_BYTE * p_src_data,
- OPJ_UINT32 * p_data_read,
- OPJ_UINT32 p_max_src_size,
- opj_codestream_index_t *p_cstr_index,
- opj_event_mgr_t *p_manager
- )
-{
- opj_t2_t * l_t2;
-
- l_t2 = opj_t2_create(p_tcd->image, p_tcd->cp);
- if (l_t2 == 00) {
- return OPJ_FALSE;
- }
-
- if (! opj_t2_decode_packets(
- p_tcd,
- l_t2,
- p_tcd->tcd_tileno,
- p_tcd->tcd_image->tiles,
- p_src_data,
- p_data_read,
- p_max_src_size,
- p_cstr_index,
- p_manager)) {
- opj_t2_destroy(l_t2);
- return OPJ_FALSE;
- }
-
- opj_t2_destroy(l_t2);
-
- /*---------------CLEAN-------------------*/
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_tcd_t1_decode(opj_tcd_t *p_tcd, opj_event_mgr_t *p_manager)
-{
- OPJ_UINT32 compno;
- opj_tcd_tile_t * l_tile = p_tcd->tcd_image->tiles;
- opj_tcd_tilecomp_t* l_tile_comp = l_tile->comps;
- opj_tccp_t * l_tccp = p_tcd->tcp->tccps;
- volatile OPJ_BOOL ret = OPJ_TRUE;
- OPJ_BOOL check_pterm = OPJ_FALSE;
- opj_mutex_t* p_manager_mutex = NULL;
-
- p_manager_mutex = opj_mutex_create();
-
- /* Only enable PTERM check if we decode all layers */
- if (p_tcd->tcp->num_layers_to_decode == p_tcd->tcp->numlayers &&
- (l_tccp->cblksty & J2K_CCP_CBLKSTY_PTERM) != 0) {
- check_pterm = OPJ_TRUE;
- }
-
- for (compno = 0; compno < l_tile->numcomps;
- ++compno, ++l_tile_comp, ++l_tccp) {
- if (p_tcd->used_component != NULL && !p_tcd->used_component[compno]) {
- continue;
- }
-
- opj_t1_decode_cblks(p_tcd, &ret, l_tile_comp, l_tccp,
- p_manager, p_manager_mutex, check_pterm);
- if (!ret) {
- break;
- }
- }
-
- opj_thread_pool_wait_completion(p_tcd->thread_pool, 0);
- if (p_manager_mutex) {
- opj_mutex_destroy(p_manager_mutex);
- }
- return ret;
-}
-
-
-static OPJ_BOOL opj_tcd_dwt_decode(opj_tcd_t *p_tcd)
-{
- OPJ_UINT32 compno;
- opj_tcd_tile_t * l_tile = p_tcd->tcd_image->tiles;
- opj_tcd_tilecomp_t * l_tile_comp = l_tile->comps;
- opj_tccp_t * l_tccp = p_tcd->tcp->tccps;
- opj_image_comp_t * l_img_comp = p_tcd->image->comps;
-
- for (compno = 0; compno < l_tile->numcomps;
- compno++, ++l_tile_comp, ++l_img_comp, ++l_tccp) {
- if (p_tcd->used_component != NULL && !p_tcd->used_component[compno]) {
- continue;
- }
-
- if (l_tccp->qmfbid == 1) {
- if (! opj_dwt_decode(p_tcd, l_tile_comp,
- l_img_comp->resno_decoded + 1)) {
- return OPJ_FALSE;
- }
- } else {
- if (! opj_dwt_decode_real(p_tcd, l_tile_comp,
- l_img_comp->resno_decoded + 1)) {
- return OPJ_FALSE;
- }
- }
-
- }
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_tcd_mct_decode(opj_tcd_t *p_tcd, opj_event_mgr_t *p_manager)
-{
- opj_tcd_tile_t * l_tile = p_tcd->tcd_image->tiles;
- opj_tcp_t * l_tcp = p_tcd->tcp;
- opj_tcd_tilecomp_t * l_tile_comp = l_tile->comps;
- OPJ_SIZE_T l_samples;
- OPJ_UINT32 i;
-
- if (l_tcp->mct == 0 || p_tcd->used_component != NULL) {
- return OPJ_TRUE;
- }
-
- if (p_tcd->whole_tile_decoding) {
- opj_tcd_resolution_t* res_comp0 = l_tile->comps[0].resolutions +
- l_tile_comp->minimum_num_resolutions - 1;
-
- /* A bit inefficient: we process more data than needed if */
- /* resno_decoded < l_tile_comp->minimum_num_resolutions-1, */
- /* but we would need to take into account a stride then */
- l_samples = (OPJ_SIZE_T)(res_comp0->x1 - res_comp0->x0) *
- (OPJ_SIZE_T)(res_comp0->y1 - res_comp0->y0);
- if (l_tile->numcomps >= 3) {
- if (l_tile_comp->minimum_num_resolutions !=
- l_tile->comps[1].minimum_num_resolutions ||
- l_tile_comp->minimum_num_resolutions !=
- l_tile->comps[2].minimum_num_resolutions) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Tiles don't all have the same dimension. Skip the MCT step.\n");
- return OPJ_FALSE;
- }
- }
- if (l_tile->numcomps >= 3) {
- opj_tcd_resolution_t* res_comp1 = l_tile->comps[1].resolutions +
- l_tile_comp->minimum_num_resolutions - 1;
- opj_tcd_resolution_t* res_comp2 = l_tile->comps[2].resolutions +
- l_tile_comp->minimum_num_resolutions - 1;
- /* testcase 1336.pdf.asan.47.376 */
- if (p_tcd->image->comps[0].resno_decoded !=
- p_tcd->image->comps[1].resno_decoded ||
- p_tcd->image->comps[0].resno_decoded !=
- p_tcd->image->comps[2].resno_decoded ||
- (OPJ_SIZE_T)(res_comp1->x1 - res_comp1->x0) *
- (OPJ_SIZE_T)(res_comp1->y1 - res_comp1->y0) != l_samples ||
- (OPJ_SIZE_T)(res_comp2->x1 - res_comp2->x0) *
- (OPJ_SIZE_T)(res_comp2->y1 - res_comp2->y0) != l_samples) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Tiles don't all have the same dimension. Skip the MCT step.\n");
- return OPJ_FALSE;
- }
- }
- } else {
- opj_tcd_resolution_t* res_comp0 = l_tile->comps[0].resolutions +
- p_tcd->image->comps[0].resno_decoded;
-
- l_samples = (OPJ_SIZE_T)(res_comp0->win_x1 - res_comp0->win_x0) *
- (OPJ_SIZE_T)(res_comp0->win_y1 - res_comp0->win_y0);
- if (l_tile->numcomps >= 3) {
- opj_tcd_resolution_t* res_comp1 = l_tile->comps[1].resolutions +
- p_tcd->image->comps[1].resno_decoded;
- opj_tcd_resolution_t* res_comp2 = l_tile->comps[2].resolutions +
- p_tcd->image->comps[2].resno_decoded;
- /* testcase 1336.pdf.asan.47.376 */
- if (p_tcd->image->comps[0].resno_decoded !=
- p_tcd->image->comps[1].resno_decoded ||
- p_tcd->image->comps[0].resno_decoded !=
- p_tcd->image->comps[2].resno_decoded ||
- (OPJ_SIZE_T)(res_comp1->win_x1 - res_comp1->win_x0) *
- (OPJ_SIZE_T)(res_comp1->win_y1 - res_comp1->win_y0) != l_samples ||
- (OPJ_SIZE_T)(res_comp2->win_x1 - res_comp2->win_x0) *
- (OPJ_SIZE_T)(res_comp2->win_y1 - res_comp2->win_y0) != l_samples) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Tiles don't all have the same dimension. Skip the MCT step.\n");
- return OPJ_FALSE;
- }
- }
- }
-
- if (l_tile->numcomps >= 3) {
- if (l_tcp->mct == 2) {
- OPJ_BYTE ** l_data;
-
- if (! l_tcp->m_mct_decoding_matrix) {
- return OPJ_TRUE;
- }
-
- l_data = (OPJ_BYTE **) opj_malloc(l_tile->numcomps * sizeof(OPJ_BYTE*));
- if (! l_data) {
- return OPJ_FALSE;
- }
-
- for (i = 0; i < l_tile->numcomps; ++i) {
- if (p_tcd->whole_tile_decoding) {
- l_data[i] = (OPJ_BYTE*) l_tile_comp->data;
- } else {
- l_data[i] = (OPJ_BYTE*) l_tile_comp->data_win;
- }
- ++l_tile_comp;
- }
-
- if (! opj_mct_decode_custom(/* MCT data */
- (OPJ_BYTE*) l_tcp->m_mct_decoding_matrix,
- /* size of components */
- l_samples,
- /* components */
- l_data,
- /* nb of components (i.e. size of pData) */
- l_tile->numcomps,
- /* tells if the data is signed */
- p_tcd->image->comps->sgnd)) {
- opj_free(l_data);
- return OPJ_FALSE;
- }
-
- opj_free(l_data);
- } else {
- if (l_tcp->tccps->qmfbid == 1) {
- if (p_tcd->whole_tile_decoding) {
- opj_mct_decode(l_tile->comps[0].data,
- l_tile->comps[1].data,
- l_tile->comps[2].data,
- l_samples);
- } else {
- opj_mct_decode(l_tile->comps[0].data_win,
- l_tile->comps[1].data_win,
- l_tile->comps[2].data_win,
- l_samples);
- }
- } else {
- if (p_tcd->whole_tile_decoding) {
- opj_mct_decode_real((OPJ_FLOAT32*)l_tile->comps[0].data,
- (OPJ_FLOAT32*)l_tile->comps[1].data,
- (OPJ_FLOAT32*)l_tile->comps[2].data,
- l_samples);
- } else {
- opj_mct_decode_real((OPJ_FLOAT32*)l_tile->comps[0].data_win,
- (OPJ_FLOAT32*)l_tile->comps[1].data_win,
- (OPJ_FLOAT32*)l_tile->comps[2].data_win,
- l_samples);
- }
- }
- }
- } else {
- opj_event_msg(p_manager, EVT_ERROR,
- "Number of components (%d) is inconsistent with a MCT. Skip the MCT step.\n",
- l_tile->numcomps);
- }
-
- return OPJ_TRUE;
-}
-
-
-static OPJ_BOOL opj_tcd_dc_level_shift_decode(opj_tcd_t *p_tcd)
-{
- OPJ_UINT32 compno;
- opj_tcd_tilecomp_t * l_tile_comp = 00;
- opj_tccp_t * l_tccp = 00;
- opj_image_comp_t * l_img_comp = 00;
- opj_tcd_resolution_t* l_res = 00;
- opj_tcd_tile_t * l_tile;
- OPJ_UINT32 l_width, l_height, i, j;
- OPJ_INT32 * l_current_ptr;
- OPJ_INT32 l_min, l_max;
- OPJ_UINT32 l_stride;
-
- l_tile = p_tcd->tcd_image->tiles;
- l_tile_comp = l_tile->comps;
- l_tccp = p_tcd->tcp->tccps;
- l_img_comp = p_tcd->image->comps;
-
- for (compno = 0; compno < l_tile->numcomps;
- compno++, ++l_img_comp, ++l_tccp, ++l_tile_comp) {
-
- if (p_tcd->used_component != NULL && !p_tcd->used_component[compno]) {
- continue;
- }
-
- l_res = l_tile_comp->resolutions + l_img_comp->resno_decoded;
-
- if (!p_tcd->whole_tile_decoding) {
- l_width = l_res->win_x1 - l_res->win_x0;
- l_height = l_res->win_y1 - l_res->win_y0;
- l_stride = 0;
- l_current_ptr = l_tile_comp->data_win;
- } else {
- l_width = (OPJ_UINT32)(l_res->x1 - l_res->x0);
- l_height = (OPJ_UINT32)(l_res->y1 - l_res->y0);
- l_stride = (OPJ_UINT32)(
- l_tile_comp->resolutions[l_tile_comp->minimum_num_resolutions - 1].x1 -
- l_tile_comp->resolutions[l_tile_comp->minimum_num_resolutions - 1].x0)
- - l_width;
- l_current_ptr = l_tile_comp->data;
-
- assert(l_height == 0 ||
- l_width + l_stride <= l_tile_comp->data_size / l_height); /*MUPDF*/
- }
-
- if (l_img_comp->sgnd) {
- l_min = -(1 << (l_img_comp->prec - 1));
- l_max = (1 << (l_img_comp->prec - 1)) - 1;
- } else {
- l_min = 0;
- l_max = (OPJ_INT32)((1U << l_img_comp->prec) - 1);
- }
-
- if (l_width == 0 || l_height == 0) {
- continue;
- }
-
- if (l_tccp->qmfbid == 1) {
- for (j = 0; j < l_height; ++j) {
- for (i = 0; i < l_width; ++i) {
- /* TODO: do addition on int64 ? */
- *l_current_ptr = opj_int_clamp(*l_current_ptr + l_tccp->m_dc_level_shift, l_min,
- l_max);
- ++l_current_ptr;
- }
- l_current_ptr += l_stride;
- }
- } else {
- for (j = 0; j < l_height; ++j) {
- for (i = 0; i < l_width; ++i) {
- OPJ_FLOAT32 l_value = *((OPJ_FLOAT32 *) l_current_ptr);
- if (l_value > (OPJ_FLOAT32)INT_MAX) {
- *l_current_ptr = l_max;
- } else if (l_value < INT_MIN) {
- *l_current_ptr = l_min;
- } else {
- /* Do addition on int64 to avoid overflows */
- OPJ_INT64 l_value_int = (OPJ_INT64)opj_lrintf(l_value);
- *l_current_ptr = (OPJ_INT32)opj_int64_clamp(
- l_value_int + l_tccp->m_dc_level_shift, l_min, l_max);
- }
- ++l_current_ptr;
- }
- l_current_ptr += l_stride;
- }
- }
- }
-
- return OPJ_TRUE;
-}
-
-
-
-/**
- * Deallocates the encoding data of the given precinct.
- */
-static void opj_tcd_code_block_dec_deallocate(opj_tcd_precinct_t * p_precinct)
-{
- OPJ_UINT32 cblkno, l_nb_code_blocks;
-
- opj_tcd_cblk_dec_t * l_code_block = p_precinct->cblks.dec;
- if (l_code_block) {
- /*fprintf(stderr,"deallocate codeblock:{\n");*/
- /*fprintf(stderr,"\t x0=%d, y0=%d, x1=%d, y1=%d\n",l_code_block->x0, l_code_block->y0, l_code_block->x1, l_code_block->y1);*/
- /*fprintf(stderr,"\t numbps=%d, numlenbits=%d, len=%d, numnewpasses=%d, real_num_segs=%d, m_current_max_segs=%d\n ",
- l_code_block->numbps, l_code_block->numlenbits, l_code_block->len, l_code_block->numnewpasses, l_code_block->real_num_segs, l_code_block->m_current_max_segs );*/
-
-
- l_nb_code_blocks = p_precinct->block_size / (OPJ_UINT32)sizeof(
- opj_tcd_cblk_dec_t);
- /*fprintf(stderr,"nb_code_blocks =%d\t}\n", l_nb_code_blocks);*/
-
- for (cblkno = 0; cblkno < l_nb_code_blocks; ++cblkno) {
-
- if (l_code_block->segs) {
- opj_free(l_code_block->segs);
- l_code_block->segs = 00;
- }
-
- if (l_code_block->chunks) {
- opj_free(l_code_block->chunks);
- l_code_block->chunks = 00;
- }
-
- opj_aligned_free(l_code_block->decoded_data);
- l_code_block->decoded_data = NULL;
-
- ++l_code_block;
- }
-
- opj_free(p_precinct->cblks.dec);
- p_precinct->cblks.dec = 00;
- }
-}
-
-/**
- * Deallocates the encoding data of the given precinct.
- */
-static void opj_tcd_code_block_enc_deallocate(opj_tcd_precinct_t * p_precinct)
-{
- OPJ_UINT32 cblkno, l_nb_code_blocks;
-
- opj_tcd_cblk_enc_t * l_code_block = p_precinct->cblks.enc;
- if (l_code_block) {
- l_nb_code_blocks = p_precinct->block_size / (OPJ_UINT32)sizeof(
- opj_tcd_cblk_enc_t);
-
- for (cblkno = 0; cblkno < l_nb_code_blocks; ++cblkno) {
- if (l_code_block->data) {
- /* We refer to data - 1 since below we incremented it */
- /* in opj_tcd_code_block_enc_allocate_data() */
- opj_free(l_code_block->data - 1);
- l_code_block->data = 00;
- }
-
- if (l_code_block->layers) {
- opj_free(l_code_block->layers);
- l_code_block->layers = 00;
- }
-
- if (l_code_block->passes) {
- opj_free(l_code_block->passes);
- l_code_block->passes = 00;
- }
- ++l_code_block;
- }
-
- opj_free(p_precinct->cblks.enc);
-
- p_precinct->cblks.enc = 00;
- }
-}
-
-OPJ_SIZE_T opj_tcd_get_encoder_input_buffer_size(opj_tcd_t *p_tcd)
-{
- OPJ_UINT32 i;
- OPJ_SIZE_T l_data_size = 0;
- opj_image_comp_t * l_img_comp = 00;
- opj_tcd_tilecomp_t * l_tilec = 00;
- OPJ_UINT32 l_size_comp, l_remaining;
-
- l_tilec = p_tcd->tcd_image->tiles->comps;
- l_img_comp = p_tcd->image->comps;
- for (i = 0; i < p_tcd->image->numcomps; ++i) {
- l_size_comp = l_img_comp->prec >> 3; /*(/ 8)*/
- l_remaining = l_img_comp->prec & 7; /* (%8) */
-
- if (l_remaining) {
- ++l_size_comp;
- }
-
- if (l_size_comp == 3) {
- l_size_comp = 4;
- }
-
- l_data_size += l_size_comp * ((OPJ_SIZE_T)(l_tilec->x1 - l_tilec->x0) *
- (OPJ_SIZE_T)(l_tilec->y1 - l_tilec->y0));
- ++l_img_comp;
- ++l_tilec;
- }
-
- return l_data_size;
-}
-
-static OPJ_BOOL opj_tcd_dc_level_shift_encode(opj_tcd_t *p_tcd)
-{
- OPJ_UINT32 compno;
- opj_tcd_tilecomp_t * l_tile_comp = 00;
- opj_tccp_t * l_tccp = 00;
- opj_image_comp_t * l_img_comp = 00;
- opj_tcd_tile_t * l_tile;
- OPJ_SIZE_T l_nb_elem, i;
- OPJ_INT32 * l_current_ptr;
-
- l_tile = p_tcd->tcd_image->tiles;
- l_tile_comp = l_tile->comps;
- l_tccp = p_tcd->tcp->tccps;
- l_img_comp = p_tcd->image->comps;
-
- for (compno = 0; compno < l_tile->numcomps; compno++) {
- l_current_ptr = l_tile_comp->data;
- l_nb_elem = (OPJ_SIZE_T)(l_tile_comp->x1 - l_tile_comp->x0) *
- (OPJ_SIZE_T)(l_tile_comp->y1 - l_tile_comp->y0);
-
- if (l_tccp->qmfbid == 1) {
- for (i = 0; i < l_nb_elem; ++i) {
- *l_current_ptr -= l_tccp->m_dc_level_shift ;
- ++l_current_ptr;
- }
- } else {
- for (i = 0; i < l_nb_elem; ++i) {
- *((OPJ_FLOAT32 *) l_current_ptr) = (OPJ_FLOAT32)(*l_current_ptr -
- l_tccp->m_dc_level_shift);
- ++l_current_ptr;
- }
- }
-
- ++l_img_comp;
- ++l_tccp;
- ++l_tile_comp;
- }
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_tcd_mct_encode(opj_tcd_t *p_tcd)
-{
- opj_tcd_tile_t * l_tile = p_tcd->tcd_image->tiles;
- opj_tcd_tilecomp_t * l_tile_comp = p_tcd->tcd_image->tiles->comps;
- OPJ_SIZE_T samples = (OPJ_SIZE_T)(l_tile_comp->x1 - l_tile_comp->x0) *
- (OPJ_SIZE_T)(l_tile_comp->y1 - l_tile_comp->y0);
- OPJ_UINT32 i;
- OPJ_BYTE ** l_data = 00;
- opj_tcp_t * l_tcp = p_tcd->tcp;
-
- if (!p_tcd->tcp->mct) {
- return OPJ_TRUE;
- }
-
- if (p_tcd->tcp->mct == 2) {
- if (! p_tcd->tcp->m_mct_coding_matrix) {
- return OPJ_TRUE;
- }
-
- l_data = (OPJ_BYTE **) opj_malloc(l_tile->numcomps * sizeof(OPJ_BYTE*));
- if (! l_data) {
- return OPJ_FALSE;
- }
-
- for (i = 0; i < l_tile->numcomps; ++i) {
- l_data[i] = (OPJ_BYTE*) l_tile_comp->data;
- ++l_tile_comp;
- }
-
- if (! opj_mct_encode_custom(/* MCT data */
- (OPJ_BYTE*) p_tcd->tcp->m_mct_coding_matrix,
- /* size of components */
- samples,
- /* components */
- l_data,
- /* nb of components (i.e. size of pData) */
- l_tile->numcomps,
- /* tells if the data is signed */
- p_tcd->image->comps->sgnd)) {
- opj_free(l_data);
- return OPJ_FALSE;
- }
-
- opj_free(l_data);
- } else if (l_tcp->tccps->qmfbid == 0) {
- opj_mct_encode_real(
- (OPJ_FLOAT32*)l_tile->comps[0].data,
- (OPJ_FLOAT32*)l_tile->comps[1].data,
- (OPJ_FLOAT32*)l_tile->comps[2].data,
- samples);
- } else {
- opj_mct_encode(l_tile->comps[0].data, l_tile->comps[1].data,
- l_tile->comps[2].data, samples);
- }
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_tcd_dwt_encode(opj_tcd_t *p_tcd)
-{
- opj_tcd_tile_t * l_tile = p_tcd->tcd_image->tiles;
- opj_tcd_tilecomp_t * l_tile_comp = p_tcd->tcd_image->tiles->comps;
- opj_tccp_t * l_tccp = p_tcd->tcp->tccps;
- OPJ_UINT32 compno;
-
- for (compno = 0; compno < l_tile->numcomps; ++compno) {
- if (l_tccp->qmfbid == 1) {
- if (! opj_dwt_encode(p_tcd, l_tile_comp)) {
- return OPJ_FALSE;
- }
- } else if (l_tccp->qmfbid == 0) {
- if (! opj_dwt_encode_real(p_tcd, l_tile_comp)) {
- return OPJ_FALSE;
- }
- }
-
- ++l_tile_comp;
- ++l_tccp;
- }
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_tcd_t1_encode(opj_tcd_t *p_tcd)
-{
- const OPJ_FLOAT64 * l_mct_norms;
- OPJ_UINT32 l_mct_numcomps = 0U;
- opj_tcp_t * l_tcp = p_tcd->tcp;
-
- if (l_tcp->mct == 1) {
- l_mct_numcomps = 3U;
- /* irreversible encoding */
- if (l_tcp->tccps->qmfbid == 0) {
- l_mct_norms = opj_mct_get_mct_norms_real();
- } else {
- l_mct_norms = opj_mct_get_mct_norms();
- }
- } else {
- l_mct_numcomps = p_tcd->image->numcomps;
- l_mct_norms = (const OPJ_FLOAT64 *)(l_tcp->mct_norms);
- }
-
- return opj_t1_encode_cblks(p_tcd,
- p_tcd->tcd_image->tiles, l_tcp, l_mct_norms,
- l_mct_numcomps);
-
- return OPJ_TRUE;
-}
-
-static OPJ_BOOL opj_tcd_t2_encode(opj_tcd_t *p_tcd,
- OPJ_BYTE * p_dest_data,
- OPJ_UINT32 * p_data_written,
- OPJ_UINT32 p_max_dest_size,
- opj_codestream_info_t *p_cstr_info,
- opj_tcd_marker_info_t* p_marker_info,
- opj_event_mgr_t *p_manager)
-{
- opj_t2_t * l_t2;
-
- l_t2 = opj_t2_create(p_tcd->image, p_tcd->cp);
- if (l_t2 == 00) {
- return OPJ_FALSE;
- }
-
- if (! opj_t2_encode_packets(
- l_t2,
- p_tcd->tcd_tileno,
- p_tcd->tcd_image->tiles,
- p_tcd->tcp->numlayers,
- p_dest_data,
- p_data_written,
- p_max_dest_size,
- p_cstr_info,
- p_marker_info,
- p_tcd->tp_num,
- p_tcd->tp_pos,
- p_tcd->cur_pino,
- FINAL_PASS,
- p_manager)) {
- opj_t2_destroy(l_t2);
- return OPJ_FALSE;
- }
-
- opj_t2_destroy(l_t2);
-
- /*---------------CLEAN-------------------*/
- return OPJ_TRUE;
-}
-
-
-static OPJ_BOOL opj_tcd_rate_allocate_encode(opj_tcd_t *p_tcd,
- OPJ_BYTE * p_dest_data,
- OPJ_UINT32 p_max_dest_size,
- opj_codestream_info_t *p_cstr_info,
- opj_event_mgr_t *p_manager)
-{
- opj_cp_t * l_cp = p_tcd->cp;
- OPJ_UINT32 l_nb_written = 0;
-
- if (p_cstr_info) {
- p_cstr_info->index_write = 0;
- }
-
- if (l_cp->m_specific_param.m_enc.m_quality_layer_alloc_strategy ==
- RATE_DISTORTION_RATIO ||
- l_cp->m_specific_param.m_enc.m_quality_layer_alloc_strategy ==
- FIXED_DISTORTION_RATIO) {
- if (! opj_tcd_rateallocate(p_tcd, p_dest_data, &l_nb_written, p_max_dest_size,
- p_cstr_info, p_manager)) {
- return OPJ_FALSE;
- }
- } else {
- /* Fixed layer allocation */
- opj_tcd_rateallocate_fixed(p_tcd);
- }
-
- return OPJ_TRUE;
-}
-
-
-OPJ_BOOL opj_tcd_copy_tile_data(opj_tcd_t *p_tcd,
- OPJ_BYTE * p_src,
- OPJ_SIZE_T p_src_length)
-{
- OPJ_UINT32 i;
- OPJ_SIZE_T j;
- OPJ_SIZE_T l_data_size = 0;
- opj_image_comp_t * l_img_comp = 00;
- opj_tcd_tilecomp_t * l_tilec = 00;
- OPJ_UINT32 l_size_comp, l_remaining;
- OPJ_SIZE_T l_nb_elem;
-
- l_data_size = opj_tcd_get_encoder_input_buffer_size(p_tcd);
- if (l_data_size != p_src_length) {
- return OPJ_FALSE;
- }
-
- l_tilec = p_tcd->tcd_image->tiles->comps;
- l_img_comp = p_tcd->image->comps;
- for (i = 0; i < p_tcd->image->numcomps; ++i) {
- l_size_comp = l_img_comp->prec >> 3; /*(/ 8)*/
- l_remaining = l_img_comp->prec & 7; /* (%8) */
- l_nb_elem = (OPJ_SIZE_T)(l_tilec->x1 - l_tilec->x0) *
- (OPJ_SIZE_T)(l_tilec->y1 - l_tilec->y0);
-
- if (l_remaining) {
- ++l_size_comp;
- }
-
- if (l_size_comp == 3) {
- l_size_comp = 4;
- }
-
- switch (l_size_comp) {
- case 1: {
- OPJ_CHAR * l_src_ptr = (OPJ_CHAR *) p_src;
- OPJ_INT32 * l_dest_ptr = l_tilec->data;
-
- if (l_img_comp->sgnd) {
- for (j = 0; j < l_nb_elem; ++j) {
- *(l_dest_ptr++) = (OPJ_INT32)(*(l_src_ptr++));
- }
- } else {
- for (j = 0; j < l_nb_elem; ++j) {
- *(l_dest_ptr++) = (*(l_src_ptr++)) & 0xff;
- }
- }
-
- p_src = (OPJ_BYTE*) l_src_ptr;
- }
- break;
- case 2: {
- OPJ_INT32 * l_dest_ptr = l_tilec->data;
- OPJ_INT16 * l_src_ptr = (OPJ_INT16 *) p_src;
-
- if (l_img_comp->sgnd) {
- for (j = 0; j < l_nb_elem; ++j) {
- *(l_dest_ptr++) = (OPJ_INT32)(*(l_src_ptr++));
- }
- } else {
- for (j = 0; j < l_nb_elem; ++j) {
- *(l_dest_ptr++) = (*(l_src_ptr++)) & 0xffff;
- }
- }
-
- p_src = (OPJ_BYTE*) l_src_ptr;
- }
- break;
- case 4: {
- OPJ_INT32 * l_src_ptr = (OPJ_INT32 *) p_src;
- OPJ_INT32 * l_dest_ptr = l_tilec->data;
-
- for (j = 0; j < l_nb_elem; ++j) {
- *(l_dest_ptr++) = (OPJ_INT32)(*(l_src_ptr++));
- }
-
- p_src = (OPJ_BYTE*) l_src_ptr;
- }
- break;
- }
-
- ++l_img_comp;
- ++l_tilec;
- }
-
- return OPJ_TRUE;
-}
-
-OPJ_BOOL opj_tcd_is_band_empty(opj_tcd_band_t* band)
-{
- return (band->x1 - band->x0 == 0) || (band->y1 - band->y0 == 0);
-}
-
-OPJ_BOOL opj_tcd_is_subband_area_of_interest(opj_tcd_t *tcd,
- OPJ_UINT32 compno,
- OPJ_UINT32 resno,
- OPJ_UINT32 bandno,
- OPJ_UINT32 band_x0,
- OPJ_UINT32 band_y0,
- OPJ_UINT32 band_x1,
- OPJ_UINT32 band_y1)
-{
- /* Note: those values for filter_margin are in part the result of */
- /* experimentation. The value 2 for QMFBID=1 (5x3 filter) can be linked */
- /* to the maximum left/right extension given in tables F.2 and F.3 of the */
- /* standard. The value 3 for QMFBID=0 (9x7 filter) is more suspicious, */
- /* since F.2 and F.3 would lead to 4 instead, so the current 3 might be */
- /* needed to be bumped to 4, in case inconsistencies are found while */
- /* decoding parts of irreversible coded images. */
- /* See opj_dwt_decode_partial_53 and opj_dwt_decode_partial_97 as well */
- OPJ_UINT32 filter_margin = (tcd->tcp->tccps[compno].qmfbid == 1) ? 2 : 3;
- opj_tcd_tilecomp_t *tilec = &(tcd->tcd_image->tiles->comps[compno]);
- opj_image_comp_t* image_comp = &(tcd->image->comps[compno]);
- /* Compute the intersection of the area of interest, expressed in tile coordinates */
- /* with the tile coordinates */
- OPJ_UINT32 tcx0 = opj_uint_max(
- (OPJ_UINT32)tilec->x0,
- opj_uint_ceildiv(tcd->win_x0, image_comp->dx));
- OPJ_UINT32 tcy0 = opj_uint_max(
- (OPJ_UINT32)tilec->y0,
- opj_uint_ceildiv(tcd->win_y0, image_comp->dy));
- OPJ_UINT32 tcx1 = opj_uint_min(
- (OPJ_UINT32)tilec->x1,
- opj_uint_ceildiv(tcd->win_x1, image_comp->dx));
- OPJ_UINT32 tcy1 = opj_uint_min(
- (OPJ_UINT32)tilec->y1,
- opj_uint_ceildiv(tcd->win_y1, image_comp->dy));
- /* Compute number of decomposition for this band. See table F-1 */
- OPJ_UINT32 nb = (resno == 0) ?
- tilec->numresolutions - 1 :
- tilec->numresolutions - resno;
- /* Map above tile-based coordinates to sub-band-based coordinates per */
- /* equation B-15 of the standard */
- OPJ_UINT32 x0b = bandno & 1;
- OPJ_UINT32 y0b = bandno >> 1;
- OPJ_UINT32 tbx0 = (nb == 0) ? tcx0 :
- (tcx0 <= (1U << (nb - 1)) * x0b) ? 0 :
- opj_uint_ceildivpow2(tcx0 - (1U << (nb - 1)) * x0b, nb);
- OPJ_UINT32 tby0 = (nb == 0) ? tcy0 :
- (tcy0 <= (1U << (nb - 1)) * y0b) ? 0 :
- opj_uint_ceildivpow2(tcy0 - (1U << (nb - 1)) * y0b, nb);
- OPJ_UINT32 tbx1 = (nb == 0) ? tcx1 :
- (tcx1 <= (1U << (nb - 1)) * x0b) ? 0 :
- opj_uint_ceildivpow2(tcx1 - (1U << (nb - 1)) * x0b, nb);
- OPJ_UINT32 tby1 = (nb == 0) ? tcy1 :
- (tcy1 <= (1U << (nb - 1)) * y0b) ? 0 :
- opj_uint_ceildivpow2(tcy1 - (1U << (nb - 1)) * y0b, nb);
- OPJ_BOOL intersects;
-
- if (tbx0 < filter_margin) {
- tbx0 = 0;
- } else {
- tbx0 -= filter_margin;
- }
- if (tby0 < filter_margin) {
- tby0 = 0;
- } else {
- tby0 -= filter_margin;
- }
- tbx1 = opj_uint_adds(tbx1, filter_margin);
- tby1 = opj_uint_adds(tby1, filter_margin);
-
- intersects = band_x0 < tbx1 && band_y0 < tby1 && band_x1 > tbx0 &&
- band_y1 > tby0;
-
-#ifdef DEBUG_VERBOSE
- printf("compno=%u resno=%u nb=%u bandno=%u x0b=%u y0b=%u band=%u,%u,%u,%u tb=%u,%u,%u,%u -> %u\n",
- compno, resno, nb, bandno, x0b, y0b,
- band_x0, band_y0, band_x1, band_y1,
- tbx0, tby0, tbx1, tby1, intersects);
-#endif
- return intersects;
-}
-
-/** Returns whether a tile component is fully decoded, taking into account
- * p_tcd->win_* members.
- *
- * @param p_tcd TCD handle.
- * @param compno Component number
- * @return OPJ_TRUE whether the tile component is fully decoded
- */
-static OPJ_BOOL opj_tcd_is_whole_tilecomp_decoding(opj_tcd_t *p_tcd,
- OPJ_UINT32 compno)
-{
- opj_tcd_tilecomp_t* tilec = &(p_tcd->tcd_image->tiles->comps[compno]);
- opj_image_comp_t* image_comp = &(p_tcd->image->comps[compno]);
- /* Compute the intersection of the area of interest, expressed in tile coordinates */
- /* with the tile coordinates */
- OPJ_UINT32 tcx0 = opj_uint_max(
- (OPJ_UINT32)tilec->x0,
- opj_uint_ceildiv(p_tcd->win_x0, image_comp->dx));
- OPJ_UINT32 tcy0 = opj_uint_max(
- (OPJ_UINT32)tilec->y0,
- opj_uint_ceildiv(p_tcd->win_y0, image_comp->dy));
- OPJ_UINT32 tcx1 = opj_uint_min(
- (OPJ_UINT32)tilec->x1,
- opj_uint_ceildiv(p_tcd->win_x1, image_comp->dx));
- OPJ_UINT32 tcy1 = opj_uint_min(
- (OPJ_UINT32)tilec->y1,
- opj_uint_ceildiv(p_tcd->win_y1, image_comp->dy));
-
- OPJ_UINT32 shift = tilec->numresolutions - tilec->minimum_num_resolutions;
- /* Tolerate small margin within the reduced resolution factor to consider if */
- /* the whole tile path must be taken */
- return (tcx0 >= (OPJ_UINT32)tilec->x0 &&
- tcy0 >= (OPJ_UINT32)tilec->y0 &&
- tcx1 <= (OPJ_UINT32)tilec->x1 &&
- tcy1 <= (OPJ_UINT32)tilec->y1 &&
- (shift >= 32 ||
- (((tcx0 - (OPJ_UINT32)tilec->x0) >> shift) == 0 &&
- ((tcy0 - (OPJ_UINT32)tilec->y0) >> shift) == 0 &&
- (((OPJ_UINT32)tilec->x1 - tcx1) >> shift) == 0 &&
- (((OPJ_UINT32)tilec->y1 - tcy1) >> shift) == 0)));
-}
-
-/* ----------------------------------------------------------------------- */
-
-opj_tcd_marker_info_t* opj_tcd_marker_info_create(OPJ_BOOL need_PLT)
-{
- opj_tcd_marker_info_t *l_tcd_marker_info =
- (opj_tcd_marker_info_t*) opj_calloc(1, sizeof(opj_tcd_marker_info_t));
- if (!l_tcd_marker_info) {
- return NULL;
- }
-
- l_tcd_marker_info->need_PLT = need_PLT;
-
- return l_tcd_marker_info;
-}
-
-/* ----------------------------------------------------------------------- */
-
-void opj_tcd_marker_info_destroy(opj_tcd_marker_info_t *p_tcd_marker_info)
-{
- if (p_tcd_marker_info) {
- opj_free(p_tcd_marker_info->p_packet_size);
- opj_free(p_tcd_marker_info);
- }
-}
-
-/* ----------------------------------------------------------------------- */
diff --git a/contrib/libs/openjpeg/tcd.h b/contrib/libs/openjpeg/tcd.h
deleted file mode 100644
index 3371b08cb2..0000000000
--- a/contrib/libs/openjpeg/tcd.h
+++ /dev/null
@@ -1,512 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2014, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux
- * Copyright (c) 2003-2014, Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR
- * Copyright (c) 2012, CS Systemes d'Information, France
- * Copyright (c) 2017, IntoPIX SA <support@intopix.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef OPJ_TCD_H
-#define OPJ_TCD_H
-/**
-@file tcd.h
-@brief Implementation of a tile coder/decoder (TCD)
-
-The functions in TCD.C encode or decode each tile independently from
-each other. The functions in TCD.C are used by other functions in J2K.C.
-*/
-
-/** @defgroup TCD TCD - Implementation of a tile coder/decoder */
-/*@{*/
-
-
-/**
-FIXME DOC
-*/
-typedef struct opj_tcd_pass {
- OPJ_UINT32 rate;
- OPJ_FLOAT64 distortiondec;
- OPJ_UINT32 len;
- OPJ_BITFIELD term : 1;
-} opj_tcd_pass_t;
-
-/**
-FIXME DOC
-*/
-typedef struct opj_tcd_layer {
- OPJ_UINT32 numpasses; /* Number of passes in the layer */
- OPJ_UINT32 len; /* len of information */
- OPJ_FLOAT64 disto; /* add for index (Cfr. Marcela) */
- OPJ_BYTE *data; /* data */
-} opj_tcd_layer_t;
-
-/**
-FIXME DOC
-*/
-typedef struct opj_tcd_cblk_enc {
- OPJ_BYTE* data; /* Data */
- opj_tcd_layer_t* layers; /* layer information */
- opj_tcd_pass_t* passes; /* information about the passes */
- OPJ_INT32 x0, y0, x1,
- y1; /* dimension of the code-blocks : left upper corner (x0, y0) right low corner (x1,y1) */
- OPJ_UINT32 numbps;
- OPJ_UINT32 numlenbits;
- OPJ_UINT32 data_size; /* Size of allocated data buffer */
- OPJ_UINT32
- numpasses; /* number of pass already done for the code-blocks */
- OPJ_UINT32 numpassesinlayers; /* number of passes in the layer */
- OPJ_UINT32 totalpasses; /* total number of passes */
-} opj_tcd_cblk_enc_t;
-
-
-/** Chunk of codestream data that is part of a code block */
-typedef struct opj_tcd_seg_data_chunk {
- /* Point to tilepart buffer. We don't make a copy !
- So the tilepart buffer must be kept alive
- as long as we need to decode the codeblocks */
- OPJ_BYTE * data;
- OPJ_UINT32 len; /* Usable length of data */
-} opj_tcd_seg_data_chunk_t;
-
-/** Segment of a code-block.
- * A segment represent a number of consecutive coding passes, without termination
- * of MQC or RAW between them. */
-typedef struct opj_tcd_seg {
- OPJ_UINT32 len; /* Size of data related to this segment */
- /* Number of passes decoded. Including those that we skip */
- OPJ_UINT32 numpasses;
- /* Number of passes actually to be decoded. To be used for code-block decoding */
- OPJ_UINT32 real_num_passes;
- /* Maximum number of passes for this segment */
- OPJ_UINT32 maxpasses;
- /* Number of new passes for current packed. Transitory value */
- OPJ_UINT32 numnewpasses;
- /* Codestream length for this segment for current packed. Transitory value */
- OPJ_UINT32 newlen;
-} opj_tcd_seg_t;
-
-/** Code-block for decoding */
-typedef struct opj_tcd_cblk_dec {
- opj_tcd_seg_t* segs; /* segments information */
- opj_tcd_seg_data_chunk_t* chunks; /* Array of chunks */
- /* position of the code-blocks : left upper corner (x0, y0) right low corner (x1,y1) */
- OPJ_INT32 x0, y0, x1, y1;
- /* Mb is The maximum number of bit-planes available for the representation of
- coefficients in any sub-band, b, as defined in Equation (E-2). See
- Section B.10.5 of the standard */
- OPJ_UINT32 Mb; /* currently used only to check if HT decoding is correct */
- /* numbps is Mb - P as defined in Section B.10.5 of the standard */
- OPJ_UINT32 numbps;
- /* number of bits for len, for the current packet. Transitory value */
- OPJ_UINT32 numlenbits;
- /* number of pass added to the code-blocks, for the current packet. Transitory value */
- OPJ_UINT32 numnewpasses;
- /* number of segments, including those of packet we skip */
- OPJ_UINT32 numsegs;
- /* number of segments, to be used for code block decoding */
- OPJ_UINT32 real_num_segs;
- OPJ_UINT32 m_current_max_segs; /* allocated number of segs[] items */
- OPJ_UINT32 numchunks; /* Number of valid chunks items */
- OPJ_UINT32 numchunksalloc; /* Number of chunks item allocated */
- /* Decoded code-block. Only used for subtile decoding. Otherwise tilec->data is directly updated */
- OPJ_INT32* decoded_data;
- OPJ_BOOL corrupted; /* whether the code block data is corrupted */
-} opj_tcd_cblk_dec_t;
-
-/** Precinct structure */
-typedef struct opj_tcd_precinct {
- /* dimension of the precinct : left upper corner (x0, y0) right low corner (x1,y1) */
- OPJ_INT32 x0, y0, x1, y1;
- OPJ_UINT32 cw, ch; /* number of code-blocks, in width and height */
- union { /* code-blocks information */
- opj_tcd_cblk_enc_t* enc;
- opj_tcd_cblk_dec_t* dec;
- void* blocks;
- } cblks;
- OPJ_UINT32 block_size; /* size taken by cblks (in bytes) */
- opj_tgt_tree_t *incltree; /* inclusion tree */
- opj_tgt_tree_t *imsbtree; /* IMSB tree */
-} opj_tcd_precinct_t;
-
-/** Sub-band structure */
-typedef struct opj_tcd_band {
- /* dimension of the subband : left upper corner (x0, y0) right low corner (x1,y1) */
- OPJ_INT32 x0, y0, x1, y1;
- /* band number: for lowest resolution level (0=LL), otherwise (1=HL, 2=LH, 3=HH) */
- OPJ_UINT32 bandno;
- /* precinct information */
- opj_tcd_precinct_t *precincts;
- /* size of data taken by precincts */
- OPJ_UINT32 precincts_data_size;
- OPJ_INT32 numbps;
- OPJ_FLOAT32 stepsize;
-} opj_tcd_band_t;
-
-/** Tile-component resolution structure */
-typedef struct opj_tcd_resolution {
- /* dimension of the resolution level : left upper corner (x0, y0) right low corner (x1,y1) */
- OPJ_INT32 x0, y0, x1, y1;
- /* number of precincts, in width and height, for this resolution level */
- OPJ_UINT32 pw, ph;
- /* number of sub-bands for the resolution level (1 for lowest resolution level, 3 otherwise) */
- OPJ_UINT32 numbands;
- /* subband information */
- opj_tcd_band_t bands[3];
-
- /* dimension of the resolution limited to window of interest. Only valid if tcd->whole_tile_decoding is set */
- OPJ_UINT32 win_x0;
- OPJ_UINT32 win_y0;
- OPJ_UINT32 win_x1;
- OPJ_UINT32 win_y1;
-} opj_tcd_resolution_t;
-
-/** Tile-component structure */
-typedef struct opj_tcd_tilecomp {
- /* dimension of component : left upper corner (x0, y0) right low corner (x1,y1) */
- OPJ_INT32 x0, y0, x1, y1;
- /* component number */
- OPJ_UINT32 compno;
- /* number of resolutions level */
- OPJ_UINT32 numresolutions;
- /* number of resolutions level to decode (at max)*/
- OPJ_UINT32 minimum_num_resolutions;
- /* resolutions information */
- opj_tcd_resolution_t *resolutions;
- /* size of data for resolutions (in bytes) */
- OPJ_UINT32 resolutions_size;
-
- /* data of the component. For decoding, only valid if tcd->whole_tile_decoding is set (so exclusive of data_win member) */
- OPJ_INT32 *data;
- /* if true, then need to free after usage, otherwise do not free */
- OPJ_BOOL ownsData;
- /* we may either need to allocate this amount of data, or re-use image data and ignore this value */
- size_t data_size_needed;
- /* size of the data of the component */
- size_t data_size;
-
- /** data of the component limited to window of interest. Only valid for decoding and if tcd->whole_tile_decoding is NOT set (so exclusive of data member) */
- OPJ_INT32 *data_win;
- /* dimension of the component limited to window of interest. Only valid for decoding and if tcd->whole_tile_decoding is NOT set */
- OPJ_UINT32 win_x0;
- OPJ_UINT32 win_y0;
- OPJ_UINT32 win_x1;
- OPJ_UINT32 win_y1;
-
- /* number of pixels */
- OPJ_SIZE_T numpix;
-} opj_tcd_tilecomp_t;
-
-
-/**
-FIXME DOC
-*/
-typedef struct opj_tcd_tile {
- /* dimension of the tile : left upper corner (x0, y0) right low corner (x1,y1) */
- OPJ_INT32 x0, y0, x1, y1;
- OPJ_UINT32 numcomps; /* number of components in tile */
- opj_tcd_tilecomp_t *comps; /* Components information */
- OPJ_SIZE_T numpix; /* number of pixels */
- OPJ_FLOAT64 distotile; /* distortion of the tile */
- OPJ_FLOAT64 distolayer[100]; /* distortion per layer */
- OPJ_UINT32 packno; /* packet number */
-} opj_tcd_tile_t;
-
-/**
-FIXME DOC
-*/
-typedef struct opj_tcd_image {
- opj_tcd_tile_t *tiles; /* Tiles information */
-}
-opj_tcd_image_t;
-
-
-/**
-Tile coder/decoder
-*/
-typedef struct opj_tcd {
- /** Position of the tilepart flag in Progression order*/
- OPJ_INT32 tp_pos;
- /** Tile part number*/
- OPJ_UINT32 tp_num;
- /** Current tile part number*/
- OPJ_UINT32 cur_tp_num;
- /** Total number of tileparts of the current tile*/
- OPJ_UINT32 cur_totnum_tp;
- /** Current Packet iterator number */
- OPJ_UINT32 cur_pino;
- /** info on each image tile */
- opj_tcd_image_t *tcd_image;
- /** image header */
- opj_image_t *image;
- /** coding parameters */
- opj_cp_t *cp;
- /** coding/decoding parameters common to all tiles */
- opj_tcp_t *tcp;
- /** current encoded/decoded tile */
- OPJ_UINT32 tcd_tileno;
- /** tell if the tcd is a decoder. */
- OPJ_BITFIELD m_is_decoder : 1;
- /** Thread pool */
- opj_thread_pool_t* thread_pool;
- /** Coordinates of the window of interest, in grid reference space */
- OPJ_UINT32 win_x0;
- OPJ_UINT32 win_y0;
- OPJ_UINT32 win_x1;
- OPJ_UINT32 win_y1;
- /** Only valid for decoding. Whether the whole tile is decoded, or just the region in win_x0/win_y0/win_x1/win_y1 */
- OPJ_BOOL whole_tile_decoding;
- /* Array of size image->numcomps indicating if a component must be decoded. NULL if all components must be decoded */
- OPJ_BOOL* used_component;
-} opj_tcd_t;
-
-/**
- * Structure to hold information needed to generate some markers.
- * Used by encoder.
- */
-typedef struct opj_tcd_marker_info {
- /** In: Whether information to generate PLT markers in needed */
- OPJ_BOOL need_PLT;
-
- /** OUT: Number of elements in p_packet_size[] array */
- OPJ_UINT32 packet_count;
-
- /** OUT: Array of size packet_count, such that p_packet_size[i] is
- * the size in bytes of the ith packet */
- OPJ_UINT32* p_packet_size;
-} opj_tcd_marker_info_t;
-
-/** @name Exported functions */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-
-/**
-Dump the content of a tcd structure
-*/
-/*void tcd_dump(FILE *fd, opj_tcd_t *tcd, opj_tcd_image_t *img);*/ /* TODO MSD should use the new v2 structures */
-
-/**
-Create a new TCD handle
-@param p_is_decoder FIXME DOC
-@return Returns a new TCD handle if successful returns NULL otherwise
-*/
-opj_tcd_t* opj_tcd_create(OPJ_BOOL p_is_decoder);
-
-/**
-Destroy a previously created TCD handle
-@param tcd TCD handle to destroy
-*/
-void opj_tcd_destroy(opj_tcd_t *tcd);
-
-
-/**
- * Create a new opj_tcd_marker_info_t* structure
- * @param need_PLT Whether information is needed to generate PLT markers.
- */
-opj_tcd_marker_info_t* opj_tcd_marker_info_create(OPJ_BOOL need_PLT);
-
-
-/**
-Destroy a previously created opj_tcd_marker_info_t* structure
-@param p_tcd_marker_info Structure to destroy
-*/
-void opj_tcd_marker_info_destroy(opj_tcd_marker_info_t *p_tcd_marker_info);
-
-
-/**
- * Initialize the tile coder and may reuse some memory.
- * @param p_tcd TCD handle.
- * @param p_image raw image.
- * @param p_cp coding parameters.
- * @param p_tp thread pool
- *
- * @return true if the encoding values could be set (false otherwise).
-*/
-OPJ_BOOL opj_tcd_init(opj_tcd_t *p_tcd,
- opj_image_t * p_image,
- opj_cp_t * p_cp,
- opj_thread_pool_t* p_tp);
-
-/**
- * Allocates memory for decoding a specific tile.
- *
- * @param p_tcd the tile decoder.
- * @param p_tile_no the index of the tile received in sequence. This not necessarily lead to the
- * tile at index p_tile_no.
- * @param p_manager the event manager.
- *
- * @return true if the remaining data is sufficient.
- */
-OPJ_BOOL opj_tcd_init_decode_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
- opj_event_mgr_t* p_manager);
-
-/**
- * Gets the maximum tile size that will be taken by the tile once decoded.
- */
-OPJ_UINT32 opj_tcd_get_decoded_tile_size(opj_tcd_t *p_tcd,
- OPJ_BOOL take_into_account_partial_decoding);
-
-/**
- * Encodes a tile from the raw image into the given buffer.
- * @param p_tcd Tile Coder handle
- * @param p_tile_no Index of the tile to encode.
- * @param p_dest Destination buffer
- * @param p_data_written pointer to an int that is incremented by the number of bytes really written on p_dest
- * @param p_len Maximum length of the destination buffer
- * @param p_cstr_info Codestream information structure
- * @param p_marker_info Marker information structure
- * @param p_manager the user event manager
- * @return true if the coding is successful.
-*/
-OPJ_BOOL opj_tcd_encode_tile(opj_tcd_t *p_tcd,
- OPJ_UINT32 p_tile_no,
- OPJ_BYTE *p_dest,
- OPJ_UINT32 * p_data_written,
- OPJ_UINT32 p_len,
- struct opj_codestream_info *p_cstr_info,
- opj_tcd_marker_info_t* p_marker_info,
- opj_event_mgr_t *p_manager);
-
-
-/**
-Decode a tile from a buffer into a raw image
-@param tcd TCD handle
-@param win_x0 Upper left x of region to decode (in grid coordinates)
-@param win_y0 Upper left y of region to decode (in grid coordinates)
-@param win_x1 Lower right x of region to decode (in grid coordinates)
-@param win_y1 Lower right y of region to decode (in grid coordinates)
-@param numcomps_to_decode Size of the comps_indices array, or 0 if decoding all components.
-@param comps_indices Array of numcomps values representing the indices
- of the components to decode (relative to the
- codestream, starting at 0). Or NULL if decoding all components.
-@param src Source buffer
-@param len Length of source buffer
-@param tileno Number that identifies one of the tiles to be decoded
-@param cstr_info FIXME DOC
-@param manager the event manager.
-*/
-OPJ_BOOL opj_tcd_decode_tile(opj_tcd_t *tcd,
- OPJ_UINT32 win_x0,
- OPJ_UINT32 win_y0,
- OPJ_UINT32 win_x1,
- OPJ_UINT32 win_y1,
- OPJ_UINT32 numcomps_to_decode,
- const OPJ_UINT32 *comps_indices,
- OPJ_BYTE *src,
- OPJ_UINT32 len,
- OPJ_UINT32 tileno,
- opj_codestream_index_t *cstr_info,
- opj_event_mgr_t *manager);
-
-
-/**
- * Copies tile data from the system onto the given memory block.
- */
-OPJ_BOOL opj_tcd_update_tile_data(opj_tcd_t *p_tcd,
- OPJ_BYTE * p_dest,
- OPJ_UINT32 p_dest_length);
-
-/**
- * Get the size in bytes of the input buffer provided before encoded.
- * This must be the size provided to the p_src_length argument of
- * opj_tcd_copy_tile_data()
- */
-OPJ_SIZE_T opj_tcd_get_encoder_input_buffer_size(opj_tcd_t *p_tcd);
-
-/**
- * Initialize the tile coder and may reuse some memory.
- *
- * @param p_tcd TCD handle.
- * @param p_tile_no current tile index to encode.
- * @param p_manager the event manager.
- *
- * @return true if the encoding values could be set (false otherwise).
-*/
-OPJ_BOOL opj_tcd_init_encode_tile(opj_tcd_t *p_tcd,
- OPJ_UINT32 p_tile_no, opj_event_mgr_t* p_manager);
-
-/**
- * Copies tile data from the given memory block onto the system.
- *
- * p_src_length must be equal to opj_tcd_get_encoder_input_buffer_size()
- */
-OPJ_BOOL opj_tcd_copy_tile_data(opj_tcd_t *p_tcd,
- OPJ_BYTE * p_src,
- OPJ_SIZE_T p_src_length);
-
-/**
- * Allocates tile component data
- *
- *
- */
-OPJ_BOOL opj_alloc_tile_component_data(opj_tcd_tilecomp_t *l_tilec);
-
-/** Returns whether a sub-band is empty (i.e. whether it has a null area)
- * @param band Sub-band handle.
- * @return OPJ_TRUE whether the sub-band is empty.
- */
-OPJ_BOOL opj_tcd_is_band_empty(opj_tcd_band_t* band);
-
-/** Reinitialize a segment */
-void opj_tcd_reinit_segment(opj_tcd_seg_t* seg);
-
-
-/** Returns whether a sub-band region contributes to the area of interest
- * tcd->win_x0,tcd->win_y0,tcd->win_x1,tcd->win_y1.
- *
- * @param tcd TCD handle.
- * @param compno Component number
- * @param resno Resolution number
- * @param bandno Band number (*not* band index, ie 0, 1, 2 or 3)
- * @param x0 Upper left x in subband coordinates
- * @param y0 Upper left y in subband coordinates
- * @param x1 Lower right x in subband coordinates
- * @param y1 Lower right y in subband coordinates
- * @return OPJ_TRUE whether the sub-band region contributes to the area of
- * interest.
- */
-OPJ_BOOL opj_tcd_is_subband_area_of_interest(opj_tcd_t *tcd,
- OPJ_UINT32 compno,
- OPJ_UINT32 resno,
- OPJ_UINT32 bandno,
- OPJ_UINT32 x0,
- OPJ_UINT32 y0,
- OPJ_UINT32 x1,
- OPJ_UINT32 y1);
-
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* OPJ_TCD_H */
diff --git a/contrib/libs/openjpeg/tgt.c b/contrib/libs/openjpeg/tgt.c
deleted file mode 100644
index 711d753f46..0000000000
--- a/contrib/libs/openjpeg/tgt.c
+++ /dev/null
@@ -1,344 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2014, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux
- * Copyright (c) 2003-2014, Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR
- * Copyright (c) 2012, CS Systemes d'Information, France
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "opj_includes.h"
-
-/*
-==========================================================
- Tag-tree coder interface
-==========================================================
-*/
-
-opj_tgt_tree_t *opj_tgt_create(OPJ_UINT32 numleafsh, OPJ_UINT32 numleafsv,
- opj_event_mgr_t *p_manager)
-{
- OPJ_INT32 nplh[32];
- OPJ_INT32 nplv[32];
- opj_tgt_node_t *node = 00;
- opj_tgt_node_t *l_parent_node = 00;
- opj_tgt_node_t *l_parent_node0 = 00;
- opj_tgt_tree_t *tree = 00;
- OPJ_UINT32 i;
- OPJ_INT32 j, k;
- OPJ_UINT32 numlvls;
- OPJ_UINT32 n;
-
- tree = (opj_tgt_tree_t *) opj_calloc(1, sizeof(opj_tgt_tree_t));
- if (!tree) {
- opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to create Tag-tree\n");
- return 00;
- }
-
- tree->numleafsh = numleafsh;
- tree->numleafsv = numleafsv;
-
- numlvls = 0;
- nplh[0] = (OPJ_INT32)numleafsh;
- nplv[0] = (OPJ_INT32)numleafsv;
- tree->numnodes = 0;
- do {
- n = (OPJ_UINT32)(nplh[numlvls] * nplv[numlvls]);
- nplh[numlvls + 1] = (nplh[numlvls] + 1) / 2;
- nplv[numlvls + 1] = (nplv[numlvls] + 1) / 2;
- tree->numnodes += n;
- ++numlvls;
- } while (n > 1);
-
- /* ADD */
- if (tree->numnodes == 0) {
- opj_free(tree);
- return 00;
- }
-
- tree->nodes = (opj_tgt_node_t*) opj_calloc(tree->numnodes,
- sizeof(opj_tgt_node_t));
- if (!tree->nodes) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Not enough memory to create Tag-tree nodes\n");
- opj_free(tree);
- return 00;
- }
- tree->nodes_size = tree->numnodes * (OPJ_UINT32)sizeof(opj_tgt_node_t);
-
- node = tree->nodes;
- l_parent_node = &tree->nodes[tree->numleafsh * tree->numleafsv];
- l_parent_node0 = l_parent_node;
-
- for (i = 0; i < numlvls - 1; ++i) {
- for (j = 0; j < nplv[i]; ++j) {
- k = nplh[i];
- while (--k >= 0) {
- node->parent = l_parent_node;
- ++node;
- if (--k >= 0) {
- node->parent = l_parent_node;
- ++node;
- }
- ++l_parent_node;
- }
- if ((j & 1) || j == nplv[i] - 1) {
- l_parent_node0 = l_parent_node;
- } else {
- l_parent_node = l_parent_node0;
- l_parent_node0 += nplh[i];
- }
- }
- }
- node->parent = 0;
- opj_tgt_reset(tree);
- return tree;
-}
-
-/**
- * Reinitialises a tag-tree from an existing one.
- *
- * @param p_tree the tree to reinitialize.
- * @param p_num_leafs_h the width of the array of leafs of the tree
- * @param p_num_leafs_v the height of the array of leafs of the tree
- * @return a new tag-tree if successful, NULL otherwise
-*/
-opj_tgt_tree_t *opj_tgt_init(opj_tgt_tree_t * p_tree, OPJ_UINT32 p_num_leafs_h,
- OPJ_UINT32 p_num_leafs_v, opj_event_mgr_t *p_manager)
-{
- OPJ_INT32 l_nplh[32];
- OPJ_INT32 l_nplv[32];
- opj_tgt_node_t *l_node = 00;
- opj_tgt_node_t *l_parent_node = 00;
- opj_tgt_node_t *l_parent_node0 = 00;
- OPJ_UINT32 i;
- OPJ_INT32 j, k;
- OPJ_UINT32 l_num_levels;
- OPJ_UINT32 n;
- OPJ_UINT32 l_node_size;
-
- if (! p_tree) {
- return 00;
- }
-
- if ((p_tree->numleafsh != p_num_leafs_h) ||
- (p_tree->numleafsv != p_num_leafs_v)) {
- p_tree->numleafsh = p_num_leafs_h;
- p_tree->numleafsv = p_num_leafs_v;
-
- l_num_levels = 0;
- l_nplh[0] = (OPJ_INT32)p_num_leafs_h;
- l_nplv[0] = (OPJ_INT32)p_num_leafs_v;
- p_tree->numnodes = 0;
- do {
- n = (OPJ_UINT32)(l_nplh[l_num_levels] * l_nplv[l_num_levels]);
- l_nplh[l_num_levels + 1] = (l_nplh[l_num_levels] + 1) / 2;
- l_nplv[l_num_levels + 1] = (l_nplv[l_num_levels] + 1) / 2;
- p_tree->numnodes += n;
- ++l_num_levels;
- } while (n > 1);
-
- /* ADD */
- if (p_tree->numnodes == 0) {
- opj_tgt_destroy(p_tree);
- return 00;
- }
- l_node_size = p_tree->numnodes * (OPJ_UINT32)sizeof(opj_tgt_node_t);
-
- if (l_node_size > p_tree->nodes_size) {
- opj_tgt_node_t* new_nodes = (opj_tgt_node_t*) opj_realloc(p_tree->nodes,
- l_node_size);
- if (! new_nodes) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Not enough memory to reinitialize the tag tree\n");
- opj_tgt_destroy(p_tree);
- return 00;
- }
- p_tree->nodes = new_nodes;
- memset(((char *) p_tree->nodes) + p_tree->nodes_size, 0,
- l_node_size - p_tree->nodes_size);
- p_tree->nodes_size = l_node_size;
- }
- l_node = p_tree->nodes;
- l_parent_node = &p_tree->nodes[p_tree->numleafsh * p_tree->numleafsv];
- l_parent_node0 = l_parent_node;
-
- for (i = 0; i < l_num_levels - 1; ++i) {
- for (j = 0; j < l_nplv[i]; ++j) {
- k = l_nplh[i];
- while (--k >= 0) {
- l_node->parent = l_parent_node;
- ++l_node;
- if (--k >= 0) {
- l_node->parent = l_parent_node;
- ++l_node;
- }
- ++l_parent_node;
- }
- if ((j & 1) || j == l_nplv[i] - 1) {
- l_parent_node0 = l_parent_node;
- } else {
- l_parent_node = l_parent_node0;
- l_parent_node0 += l_nplh[i];
- }
- }
- }
- l_node->parent = 0;
- }
- opj_tgt_reset(p_tree);
-
- return p_tree;
-}
-
-void opj_tgt_destroy(opj_tgt_tree_t *p_tree)
-{
- if (! p_tree) {
- return;
- }
-
- if (p_tree->nodes) {
- opj_free(p_tree->nodes);
- p_tree->nodes = 00;
- }
- opj_free(p_tree);
-}
-
-void opj_tgt_reset(opj_tgt_tree_t *p_tree)
-{
- OPJ_UINT32 i;
- opj_tgt_node_t * l_current_node = 00;;
-
- if (! p_tree) {
- return;
- }
-
- l_current_node = p_tree->nodes;
- for (i = 0; i < p_tree->numnodes; ++i) {
- l_current_node->value = 999;
- l_current_node->low = 0;
- l_current_node->known = 0;
- ++l_current_node;
- }
-}
-
-void opj_tgt_setvalue(opj_tgt_tree_t *tree, OPJ_UINT32 leafno, OPJ_INT32 value)
-{
- opj_tgt_node_t *node;
- node = &tree->nodes[leafno];
- while (node && node->value > value) {
- node->value = value;
- node = node->parent;
- }
-}
-
-void opj_tgt_encode(opj_bio_t *bio, opj_tgt_tree_t *tree, OPJ_UINT32 leafno,
- OPJ_INT32 threshold)
-{
- opj_tgt_node_t *stk[31];
- opj_tgt_node_t **stkptr;
- opj_tgt_node_t *node;
- OPJ_INT32 low;
-
- stkptr = stk;
- node = &tree->nodes[leafno];
- while (node->parent) {
- *stkptr++ = node;
- node = node->parent;
- }
-
- low = 0;
- for (;;) {
- if (low > node->low) {
- node->low = low;
- } else {
- low = node->low;
- }
-
- while (low < threshold) {
- if (low >= node->value) {
- if (!node->known) {
- opj_bio_putbit(bio, 1);
- node->known = 1;
- }
- break;
- }
- opj_bio_putbit(bio, 0);
- ++low;
- }
-
- node->low = low;
- if (stkptr == stk) {
- break;
- }
- node = *--stkptr;
- }
-}
-
-OPJ_UINT32 opj_tgt_decode(opj_bio_t *bio, opj_tgt_tree_t *tree,
- OPJ_UINT32 leafno, OPJ_INT32 threshold)
-{
- opj_tgt_node_t *stk[31];
- opj_tgt_node_t **stkptr;
- opj_tgt_node_t *node;
- OPJ_INT32 low;
-
- stkptr = stk;
- node = &tree->nodes[leafno];
- while (node->parent) {
- *stkptr++ = node;
- node = node->parent;
- }
-
- low = 0;
- for (;;) {
- if (low > node->low) {
- node->low = low;
- } else {
- low = node->low;
- }
- while (low < threshold && low < node->value) {
- if (opj_bio_read(bio, 1)) {
- node->value = low;
- } else {
- ++low;
- }
- }
- node->low = low;
- if (stkptr == stk) {
- break;
- }
- node = *--stkptr;
- }
-
- return (node->value < threshold) ? 1 : 0;
-}
diff --git a/contrib/libs/openjpeg/tgt.h b/contrib/libs/openjpeg/tgt.h
deleted file mode 100644
index 9818208b82..0000000000
--- a/contrib/libs/openjpeg/tgt.h
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2014, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux
- * Copyright (c) 2003-2014, Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@c-s.fr>
- * Copyright (c) 2011-2012, Centre National d'Etudes Spatiales (CNES), France
- * Copyright (c) 2012, CS Systemes d'Information, France
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef OPJ_TGT_H
-#define OPJ_TGT_H
-/**
-@file tgt.h
-@brief Implementation of a tag-tree coder (TGT)
-
-The functions in TGT.C have for goal to realize a tag-tree coder. The functions in TGT.C
-are used by some function in T2.C.
-*/
-
-/** @defgroup TGT TGT - Implementation of a tag-tree coder */
-/*@{*/
-
-/**
-Tag node
-*/
-typedef struct opj_tgt_node {
- struct opj_tgt_node *parent;
- OPJ_INT32 value;
- OPJ_INT32 low;
- OPJ_UINT32 known;
-} opj_tgt_node_t;
-
-/**
-Tag tree
-*/
-typedef struct opj_tgt_tree {
- OPJ_UINT32 numleafsh;
- OPJ_UINT32 numleafsv;
- OPJ_UINT32 numnodes;
- opj_tgt_node_t *nodes;
- OPJ_UINT32 nodes_size; /* maximum size taken by nodes */
-} opj_tgt_tree_t;
-
-
-/** @name Exported functions */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-/**
-Create a tag-tree
-@param numleafsh Width of the array of leafs of the tree
-@param numleafsv Height of the array of leafs of the tree
-@param p_manager the event manager
-@return Returns a new tag-tree if successful, returns NULL otherwise
-*/
-opj_tgt_tree_t *opj_tgt_create(OPJ_UINT32 numleafsh, OPJ_UINT32 numleafsv,
- opj_event_mgr_t *p_manager);
-
-/**
- * Reinitialises a tag-tree from an exixting one.
- *
- * @param p_tree the tree to reinitialize.
- * @param p_num_leafs_h the width of the array of leafs of the tree
- * @param p_num_leafs_v the height of the array of leafs of the tree
- * @param p_manager the event manager
- * @return a new tag-tree if successful, NULL otherwise
-*/
-opj_tgt_tree_t *opj_tgt_init(opj_tgt_tree_t * p_tree,
- OPJ_UINT32 p_num_leafs_h,
- OPJ_UINT32 p_num_leafs_v, opj_event_mgr_t *p_manager);
-/**
-Destroy a tag-tree, liberating memory
-@param tree Tag-tree to destroy
-*/
-void opj_tgt_destroy(opj_tgt_tree_t *tree);
-/**
-Reset a tag-tree (set all leaves to 0)
-@param tree Tag-tree to reset
-*/
-void opj_tgt_reset(opj_tgt_tree_t *tree);
-/**
-Set the value of a leaf of a tag-tree
-@param tree Tag-tree to modify
-@param leafno Number that identifies the leaf to modify
-@param value New value of the leaf
-*/
-void opj_tgt_setvalue(opj_tgt_tree_t *tree,
- OPJ_UINT32 leafno,
- OPJ_INT32 value);
-/**
-Encode the value of a leaf of the tag-tree up to a given threshold
-@param bio Pointer to a BIO handle
-@param tree Tag-tree to modify
-@param leafno Number that identifies the leaf to encode
-@param threshold Threshold to use when encoding value of the leaf
-*/
-void opj_tgt_encode(opj_bio_t *bio,
- opj_tgt_tree_t *tree,
- OPJ_UINT32 leafno,
- OPJ_INT32 threshold);
-/**
-Decode the value of a leaf of the tag-tree up to a given threshold
-@param bio Pointer to a BIO handle
-@param tree Tag-tree to decode
-@param leafno Number that identifies the leaf to decode
-@param threshold Threshold to use when decoding value of the leaf
-@return Returns 1 if the node's value < threshold, returns 0 otherwise
-*/
-OPJ_UINT32 opj_tgt_decode(opj_bio_t *bio,
- opj_tgt_tree_t *tree,
- OPJ_UINT32 leafno,
- OPJ_INT32 threshold);
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* OPJ_TGT_H */
diff --git a/contrib/libs/openjpeg/thread.c b/contrib/libs/openjpeg/thread.c
deleted file mode 100644
index 240810b1c4..0000000000
--- a/contrib/libs/openjpeg/thread.c
+++ /dev/null
@@ -1,954 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2016, Even Rouault
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <assert.h>
-
-#ifdef MUTEX_win32
-
-/* Some versions of x86_64-w64-mingw32-gc -m32 resolve InterlockedCompareExchange() */
-/* as __sync_val_compare_and_swap_4 but fails to link it. As this protects against */
-/* a rather unlikely race, skip it */
-#if !(defined(__MINGW32__) && defined(__i386__))
-#define HAVE_INTERLOCKED_COMPARE_EXCHANGE 1
-#endif
-
-#include <windows.h>
-#include <process.h>
-
-#include "opj_includes.h"
-
-OPJ_BOOL OPJ_CALLCONV opj_has_thread_support(void)
-{
- return OPJ_TRUE;
-}
-
-int OPJ_CALLCONV opj_get_num_cpus(void)
-{
- SYSTEM_INFO info;
- DWORD dwNum;
- GetSystemInfo(&info);
- dwNum = info.dwNumberOfProcessors;
- if (dwNum < 1) {
- return 1;
- }
- return (int)dwNum;
-}
-
-struct opj_mutex_t {
- CRITICAL_SECTION cs;
-};
-
-opj_mutex_t* opj_mutex_create(void)
-{
- opj_mutex_t* mutex = (opj_mutex_t*) opj_malloc(sizeof(opj_mutex_t));
- if (!mutex) {
- return NULL;
- }
- InitializeCriticalSectionAndSpinCount(&(mutex->cs), 4000);
- return mutex;
-}
-
-void opj_mutex_lock(opj_mutex_t* mutex)
-{
- EnterCriticalSection(&(mutex->cs));
-}
-
-void opj_mutex_unlock(opj_mutex_t* mutex)
-{
- LeaveCriticalSection(&(mutex->cs));
-}
-
-void opj_mutex_destroy(opj_mutex_t* mutex)
-{
- if (!mutex) {
- return;
- }
- DeleteCriticalSection(&(mutex->cs));
- opj_free(mutex);
-}
-
-struct opj_cond_waiter_list_t {
- HANDLE hEvent;
- struct opj_cond_waiter_list_t* next;
-};
-typedef struct opj_cond_waiter_list_t opj_cond_waiter_list_t;
-
-struct opj_cond_t {
- opj_mutex_t *internal_mutex;
- opj_cond_waiter_list_t *waiter_list;
-};
-
-static DWORD TLSKey = 0;
-static volatile LONG inTLSLockedSection = 0;
-static volatile int TLSKeyInit = OPJ_FALSE;
-
-opj_cond_t* opj_cond_create(void)
-{
- opj_cond_t* cond = (opj_cond_t*) opj_malloc(sizeof(opj_cond_t));
- if (!cond) {
- return NULL;
- }
-
- /* Make sure that the TLS key is allocated in a thread-safe way */
- /* We cannot use a global mutex/critical section since its creation itself would not be */
- /* thread-safe, so use InterlockedCompareExchange trick */
- while (OPJ_TRUE) {
-
-#if HAVE_INTERLOCKED_COMPARE_EXCHANGE
- if (InterlockedCompareExchange(&inTLSLockedSection, 1, 0) == 0)
-#endif
- {
- if (!TLSKeyInit) {
- TLSKey = TlsAlloc();
- TLSKeyInit = OPJ_TRUE;
- }
-#if HAVE_INTERLOCKED_COMPARE_EXCHANGE
- InterlockedCompareExchange(&inTLSLockedSection, 0, 1);
-#endif
- break;
- }
- }
-
- if (TLSKey == TLS_OUT_OF_INDEXES) {
- opj_free(cond);
- return NULL;
- }
- cond->internal_mutex = opj_mutex_create();
- if (cond->internal_mutex == NULL) {
- opj_free(cond);
- return NULL;
- }
- cond->waiter_list = NULL;
- return cond;
-}
-
-void opj_cond_wait(opj_cond_t* cond, opj_mutex_t* mutex)
-{
- opj_cond_waiter_list_t* item;
- HANDLE hEvent = (HANDLE) TlsGetValue(TLSKey);
- if (hEvent == NULL) {
- hEvent = CreateEvent(NULL, /* security attributes */
- 0, /* manual reset = no */
- 0, /* initial state = unsignaled */
- NULL /* no name */);
- assert(hEvent);
-
- TlsSetValue(TLSKey, hEvent);
- }
-
- /* Insert the waiter into the waiter list of the condition */
- opj_mutex_lock(cond->internal_mutex);
-
- item = (opj_cond_waiter_list_t*)opj_malloc(sizeof(opj_cond_waiter_list_t));
- assert(item != NULL);
-
- item->hEvent = hEvent;
- item->next = cond->waiter_list;
-
- cond->waiter_list = item;
-
- opj_mutex_unlock(cond->internal_mutex);
-
- /* Release the client mutex before waiting for the event being signaled */
- opj_mutex_unlock(mutex);
-
- /* Ideally we would check that we do not get WAIT_FAILED but it is hard */
- /* to report a failure. */
- WaitForSingleObject(hEvent, INFINITE);
-
- /* Reacquire the client mutex */
- opj_mutex_lock(mutex);
-}
-
-void opj_cond_signal(opj_cond_t* cond)
-{
- opj_cond_waiter_list_t* psIter;
-
- /* Signal the first registered event, and remove it from the list */
- opj_mutex_lock(cond->internal_mutex);
-
- psIter = cond->waiter_list;
- if (psIter != NULL) {
- SetEvent(psIter->hEvent);
- cond->waiter_list = psIter->next;
- opj_free(psIter);
- }
-
- opj_mutex_unlock(cond->internal_mutex);
-}
-
-void opj_cond_destroy(opj_cond_t* cond)
-{
- if (!cond) {
- return;
- }
- opj_mutex_destroy(cond->internal_mutex);
- assert(cond->waiter_list == NULL);
- opj_free(cond);
-}
-
-struct opj_thread_t {
- opj_thread_fn thread_fn;
- void* user_data;
- HANDLE hThread;
-};
-
-static unsigned int __stdcall opj_thread_callback_adapter(void *info)
-{
- opj_thread_t* thread = (opj_thread_t*) info;
- HANDLE hEvent = NULL;
-
- thread->thread_fn(thread->user_data);
-
- /* Free the handle possible allocated by a cond */
- while (OPJ_TRUE) {
- /* Make sure TLSKey is not being created just at that moment... */
-#if HAVE_INTERLOCKED_COMPARE_EXCHANGE
- if (InterlockedCompareExchange(&inTLSLockedSection, 1, 0) == 0)
-#endif
- {
- if (TLSKeyInit) {
- hEvent = (HANDLE) TlsGetValue(TLSKey);
- }
-#if HAVE_INTERLOCKED_COMPARE_EXCHANGE
- InterlockedCompareExchange(&inTLSLockedSection, 0, 1);
-#endif
- break;
- }
- }
- if (hEvent) {
- CloseHandle(hEvent);
- }
-
- return 0;
-}
-
-opj_thread_t* opj_thread_create(opj_thread_fn thread_fn, void* user_data)
-{
- opj_thread_t* thread;
-
- assert(thread_fn);
-
- thread = (opj_thread_t*) opj_malloc(sizeof(opj_thread_t));
- if (!thread) {
- return NULL;
- }
- thread->thread_fn = thread_fn;
- thread->user_data = user_data;
-
- thread->hThread = (HANDLE)_beginthreadex(NULL, 0,
- opj_thread_callback_adapter, thread, 0, NULL);
-
- if (thread->hThread == NULL) {
- opj_free(thread);
- return NULL;
- }
- return thread;
-}
-
-void opj_thread_join(opj_thread_t* thread)
-{
- WaitForSingleObject(thread->hThread, INFINITE);
- CloseHandle(thread->hThread);
-
- opj_free(thread);
-}
-
-#elif MUTEX_pthread
-
-#include <pthread.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-/* Moved after all system includes, and in particular pthread.h, so as to */
-/* avoid poisoning issuing with malloc() use in pthread.h with ulibc (#1013) */
-#include "opj_includes.h"
-
-OPJ_BOOL OPJ_CALLCONV opj_has_thread_support(void)
-{
- return OPJ_TRUE;
-}
-
-int OPJ_CALLCONV opj_get_num_cpus(void)
-{
-#ifdef _SC_NPROCESSORS_ONLN
- return (int)sysconf(_SC_NPROCESSORS_ONLN);
-#else
- return 1;
-#endif
-}
-
-struct opj_mutex_t {
- pthread_mutex_t mutex;
-};
-
-opj_mutex_t* opj_mutex_create(void)
-{
- opj_mutex_t* mutex = (opj_mutex_t*) opj_calloc(1U, sizeof(opj_mutex_t));
- if (mutex != NULL) {
- if (pthread_mutex_init(&mutex->mutex, NULL) != 0) {
- opj_free(mutex);
- mutex = NULL;
- }
- }
- return mutex;
-}
-
-void opj_mutex_lock(opj_mutex_t* mutex)
-{
- pthread_mutex_lock(&(mutex->mutex));
-}
-
-void opj_mutex_unlock(opj_mutex_t* mutex)
-{
- pthread_mutex_unlock(&(mutex->mutex));
-}
-
-void opj_mutex_destroy(opj_mutex_t* mutex)
-{
- if (!mutex) {
- return;
- }
- pthread_mutex_destroy(&(mutex->mutex));
- opj_free(mutex);
-}
-
-struct opj_cond_t {
- pthread_cond_t cond;
-};
-
-opj_cond_t* opj_cond_create(void)
-{
- opj_cond_t* cond = (opj_cond_t*) opj_malloc(sizeof(opj_cond_t));
- if (!cond) {
- return NULL;
- }
- if (pthread_cond_init(&(cond->cond), NULL) != 0) {
- opj_free(cond);
- return NULL;
- }
- return cond;
-}
-
-void opj_cond_wait(opj_cond_t* cond, opj_mutex_t* mutex)
-{
- pthread_cond_wait(&(cond->cond), &(mutex->mutex));
-}
-
-void opj_cond_signal(opj_cond_t* cond)
-{
- int ret = pthread_cond_signal(&(cond->cond));
- (void)ret;
- assert(ret == 0);
-}
-
-void opj_cond_destroy(opj_cond_t* cond)
-{
- if (!cond) {
- return;
- }
- pthread_cond_destroy(&(cond->cond));
- opj_free(cond);
-}
-
-
-struct opj_thread_t {
- opj_thread_fn thread_fn;
- void* user_data;
- pthread_t thread;
-};
-
-static void* opj_thread_callback_adapter(void* info)
-{
- opj_thread_t* thread = (opj_thread_t*) info;
- thread->thread_fn(thread->user_data);
- return NULL;
-}
-
-opj_thread_t* opj_thread_create(opj_thread_fn thread_fn, void* user_data)
-{
- pthread_attr_t attr;
- opj_thread_t* thread;
-
- assert(thread_fn);
-
- thread = (opj_thread_t*) opj_malloc(sizeof(opj_thread_t));
- if (!thread) {
- return NULL;
- }
- thread->thread_fn = thread_fn;
- thread->user_data = user_data;
-
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
- if (pthread_create(&(thread->thread), &attr,
- opj_thread_callback_adapter, (void *) thread) != 0) {
- opj_free(thread);
- return NULL;
- }
- return thread;
-}
-
-void opj_thread_join(opj_thread_t* thread)
-{
- void* status;
- pthread_join(thread->thread, &status);
-
- opj_free(thread);
-}
-
-#else
-/* Stub implementation */
-
-#include "opj_includes.h"
-
-OPJ_BOOL OPJ_CALLCONV opj_has_thread_support(void)
-{
- return OPJ_FALSE;
-}
-
-int OPJ_CALLCONV opj_get_num_cpus(void)
-{
- return 1;
-}
-
-opj_mutex_t* opj_mutex_create(void)
-{
- return NULL;
-}
-
-void opj_mutex_lock(opj_mutex_t* mutex)
-{
- (void) mutex;
-}
-
-void opj_mutex_unlock(opj_mutex_t* mutex)
-{
- (void) mutex;
-}
-
-void opj_mutex_destroy(opj_mutex_t* mutex)
-{
- (void) mutex;
-}
-
-opj_cond_t* opj_cond_create(void)
-{
- return NULL;
-}
-
-void opj_cond_wait(opj_cond_t* cond, opj_mutex_t* mutex)
-{
- (void) cond;
- (void) mutex;
-}
-
-void opj_cond_signal(opj_cond_t* cond)
-{
- (void) cond;
-}
-
-void opj_cond_destroy(opj_cond_t* cond)
-{
- (void) cond;
-}
-
-opj_thread_t* opj_thread_create(opj_thread_fn thread_fn, void* user_data)
-{
- (void) thread_fn;
- (void) user_data;
- return NULL;
-}
-
-void opj_thread_join(opj_thread_t* thread)
-{
- (void) thread;
-}
-
-#endif
-
-typedef struct {
- int key;
- void* value;
- opj_tls_free_func opj_free_func;
-} opj_tls_key_val_t;
-
-struct opj_tls_t {
- opj_tls_key_val_t* key_val;
- int key_val_count;
-};
-
-static opj_tls_t* opj_tls_new(void)
-{
- return (opj_tls_t*) opj_calloc(1, sizeof(opj_tls_t));
-}
-
-static void opj_tls_destroy(opj_tls_t* tls)
-{
- int i;
- if (!tls) {
- return;
- }
- for (i = 0; i < tls->key_val_count; i++) {
- if (tls->key_val[i].opj_free_func) {
- tls->key_val[i].opj_free_func(tls->key_val[i].value);
- }
- }
- opj_free(tls->key_val);
- opj_free(tls);
-}
-
-void* opj_tls_get(opj_tls_t* tls, int key)
-{
- int i;
- for (i = 0; i < tls->key_val_count; i++) {
- if (tls->key_val[i].key == key) {
- return tls->key_val[i].value;
- }
- }
- return NULL;
-}
-
-OPJ_BOOL opj_tls_set(opj_tls_t* tls, int key, void* value,
- opj_tls_free_func opj_free_func)
-{
- opj_tls_key_val_t* new_key_val;
- int i;
-
- if (tls->key_val_count == INT_MAX) {
- return OPJ_FALSE;
- }
- for (i = 0; i < tls->key_val_count; i++) {
- if (tls->key_val[i].key == key) {
- if (tls->key_val[i].opj_free_func) {
- tls->key_val[i].opj_free_func(tls->key_val[i].value);
- }
- tls->key_val[i].value = value;
- tls->key_val[i].opj_free_func = opj_free_func;
- return OPJ_TRUE;
- }
- }
- new_key_val = (opj_tls_key_val_t*) opj_realloc(tls->key_val,
- ((size_t)tls->key_val_count + 1U) * sizeof(opj_tls_key_val_t));
- if (!new_key_val) {
- return OPJ_FALSE;
- }
- tls->key_val = new_key_val;
- new_key_val[tls->key_val_count].key = key;
- new_key_val[tls->key_val_count].value = value;
- new_key_val[tls->key_val_count].opj_free_func = opj_free_func;
- tls->key_val_count ++;
- return OPJ_TRUE;
-}
-
-
-typedef struct {
- opj_job_fn job_fn;
- void *user_data;
-} opj_worker_thread_job_t;
-
-typedef struct {
- opj_thread_pool_t *tp;
- opj_thread_t *thread;
- int marked_as_waiting;
-
- opj_mutex_t *mutex;
- opj_cond_t *cond;
-} opj_worker_thread_t;
-
-typedef enum {
- OPJWTS_OK,
- OPJWTS_STOP,
- OPJWTS_ERROR
-} opj_worker_thread_state;
-
-struct opj_job_list_t {
- opj_worker_thread_job_t* job;
- struct opj_job_list_t* next;
-};
-typedef struct opj_job_list_t opj_job_list_t;
-
-struct opj_worker_thread_list_t {
- opj_worker_thread_t* worker_thread;
- struct opj_worker_thread_list_t* next;
-};
-typedef struct opj_worker_thread_list_t opj_worker_thread_list_t;
-
-struct opj_thread_pool_t {
- opj_worker_thread_t* worker_threads;
- int worker_threads_count;
- opj_cond_t* cond;
- opj_mutex_t* mutex;
- volatile opj_worker_thread_state state;
- opj_job_list_t* job_queue;
- volatile int pending_jobs_count;
- opj_worker_thread_list_t* waiting_worker_thread_list;
- int waiting_worker_thread_count;
- opj_tls_t* tls;
- int signaling_threshold;
-};
-
-static OPJ_BOOL opj_thread_pool_setup(opj_thread_pool_t* tp, int num_threads);
-static opj_worker_thread_job_t* opj_thread_pool_get_next_job(
- opj_thread_pool_t* tp,
- opj_worker_thread_t* worker_thread,
- OPJ_BOOL signal_job_finished);
-
-opj_thread_pool_t* opj_thread_pool_create(int num_threads)
-{
- opj_thread_pool_t* tp;
-
- tp = (opj_thread_pool_t*) opj_calloc(1, sizeof(opj_thread_pool_t));
- if (!tp) {
- return NULL;
- }
- tp->state = OPJWTS_OK;
-
- if (num_threads <= 0) {
- tp->tls = opj_tls_new();
- if (!tp->tls) {
- opj_free(tp);
- tp = NULL;
- }
- return tp;
- }
-
- tp->mutex = opj_mutex_create();
- if (!tp->mutex) {
- opj_free(tp);
- return NULL;
- }
- if (!opj_thread_pool_setup(tp, num_threads)) {
- opj_thread_pool_destroy(tp);
- return NULL;
- }
- return tp;
-}
-
-static void opj_worker_thread_function(void* user_data)
-{
- opj_worker_thread_t* worker_thread;
- opj_thread_pool_t* tp;
- opj_tls_t* tls;
- OPJ_BOOL job_finished = OPJ_FALSE;
-
- worker_thread = (opj_worker_thread_t*) user_data;
- tp = worker_thread->tp;
- tls = opj_tls_new();
-
- while (OPJ_TRUE) {
- opj_worker_thread_job_t* job = opj_thread_pool_get_next_job(tp, worker_thread,
- job_finished);
- if (job == NULL) {
- break;
- }
-
- if (job->job_fn) {
- job->job_fn(job->user_data, tls);
- }
- opj_free(job);
- job_finished = OPJ_TRUE;
- }
-
- opj_tls_destroy(tls);
-}
-
-static OPJ_BOOL opj_thread_pool_setup(opj_thread_pool_t* tp, int num_threads)
-{
- int i;
- OPJ_BOOL bRet = OPJ_TRUE;
-
- assert(num_threads > 0);
-
- tp->cond = opj_cond_create();
- if (tp->cond == NULL) {
- return OPJ_FALSE;
- }
-
- tp->worker_threads = (opj_worker_thread_t*) opj_calloc((size_t)num_threads,
- sizeof(opj_worker_thread_t));
- if (tp->worker_threads == NULL) {
- return OPJ_FALSE;
- }
- tp->worker_threads_count = num_threads;
-
- for (i = 0; i < num_threads; i++) {
- tp->worker_threads[i].tp = tp;
-
- tp->worker_threads[i].mutex = opj_mutex_create();
- if (tp->worker_threads[i].mutex == NULL) {
- tp->worker_threads_count = i;
- bRet = OPJ_FALSE;
- break;
- }
-
- tp->worker_threads[i].cond = opj_cond_create();
- if (tp->worker_threads[i].cond == NULL) {
- opj_mutex_destroy(tp->worker_threads[i].mutex);
- tp->worker_threads_count = i;
- bRet = OPJ_FALSE;
- break;
- }
-
- tp->worker_threads[i].marked_as_waiting = OPJ_FALSE;
-
- tp->worker_threads[i].thread = opj_thread_create(opj_worker_thread_function,
- &(tp->worker_threads[i]));
- if (tp->worker_threads[i].thread == NULL) {
- opj_mutex_destroy(tp->worker_threads[i].mutex);
- opj_cond_destroy(tp->worker_threads[i].cond);
- tp->worker_threads_count = i;
- bRet = OPJ_FALSE;
- break;
- }
- }
-
- /* Wait all threads to be started */
- /* printf("waiting for all threads to be started\n"); */
- opj_mutex_lock(tp->mutex);
- while (tp->waiting_worker_thread_count < tp->worker_threads_count) {
- opj_cond_wait(tp->cond, tp->mutex);
- }
- opj_mutex_unlock(tp->mutex);
- /* printf("all threads started\n"); */
-
- if (tp->state == OPJWTS_ERROR) {
- bRet = OPJ_FALSE;
- }
-
- return bRet;
-}
-
-/*
-void opj_waiting()
-{
- printf("waiting!\n");
-}
-*/
-
-static opj_worker_thread_job_t* opj_thread_pool_get_next_job(
- opj_thread_pool_t* tp,
- opj_worker_thread_t* worker_thread,
- OPJ_BOOL signal_job_finished)
-{
- while (OPJ_TRUE) {
- opj_job_list_t* top_job_iter;
-
- opj_mutex_lock(tp->mutex);
-
- if (signal_job_finished) {
- signal_job_finished = OPJ_FALSE;
- tp->pending_jobs_count --;
- /*printf("tp=%p, remaining jobs: %d\n", tp, tp->pending_jobs_count);*/
- if (tp->pending_jobs_count <= tp->signaling_threshold) {
- opj_cond_signal(tp->cond);
- }
- }
-
- if (tp->state == OPJWTS_STOP) {
- opj_mutex_unlock(tp->mutex);
- return NULL;
- }
- top_job_iter = tp->job_queue;
- if (top_job_iter) {
- opj_worker_thread_job_t* job;
- tp->job_queue = top_job_iter->next;
-
- job = top_job_iter->job;
- opj_mutex_unlock(tp->mutex);
- opj_free(top_job_iter);
- return job;
- }
-
- /* opj_waiting(); */
- if (!worker_thread->marked_as_waiting) {
- opj_worker_thread_list_t* item;
-
- worker_thread->marked_as_waiting = OPJ_TRUE;
- tp->waiting_worker_thread_count ++;
- assert(tp->waiting_worker_thread_count <= tp->worker_threads_count);
-
- item = (opj_worker_thread_list_t*) opj_malloc(sizeof(opj_worker_thread_list_t));
- if (item == NULL) {
- tp->state = OPJWTS_ERROR;
- opj_cond_signal(tp->cond);
-
- opj_mutex_unlock(tp->mutex);
- return NULL;
- }
-
- item->worker_thread = worker_thread;
- item->next = tp->waiting_worker_thread_list;
- tp->waiting_worker_thread_list = item;
- }
-
- /* printf("signaling that worker thread is ready\n"); */
- opj_cond_signal(tp->cond);
-
- opj_mutex_lock(worker_thread->mutex);
- opj_mutex_unlock(tp->mutex);
-
- /* printf("waiting for job\n"); */
- opj_cond_wait(worker_thread->cond, worker_thread->mutex);
-
- opj_mutex_unlock(worker_thread->mutex);
- /* printf("got job\n"); */
- }
-}
-
-OPJ_BOOL opj_thread_pool_submit_job(opj_thread_pool_t* tp,
- opj_job_fn job_fn,
- void* user_data)
-{
- opj_worker_thread_job_t* job;
- opj_job_list_t* item;
-
- if (tp->mutex == NULL) {
- job_fn(user_data, tp->tls);
- return OPJ_TRUE;
- }
-
- job = (opj_worker_thread_job_t*)opj_malloc(sizeof(opj_worker_thread_job_t));
- if (job == NULL) {
- return OPJ_FALSE;
- }
- job->job_fn = job_fn;
- job->user_data = user_data;
-
- item = (opj_job_list_t*) opj_malloc(sizeof(opj_job_list_t));
- if (item == NULL) {
- opj_free(job);
- return OPJ_FALSE;
- }
- item->job = job;
-
- opj_mutex_lock(tp->mutex);
-
- tp->signaling_threshold = 100 * tp->worker_threads_count;
- while (tp->pending_jobs_count > tp->signaling_threshold) {
- /* printf("%d jobs enqueued. Waiting\n", tp->pending_jobs_count); */
- opj_cond_wait(tp->cond, tp->mutex);
- /* printf("...%d jobs enqueued.\n", tp->pending_jobs_count); */
- }
-
- item->next = tp->job_queue;
- tp->job_queue = item;
- tp->pending_jobs_count ++;
-
- if (tp->waiting_worker_thread_list) {
- opj_worker_thread_t* worker_thread;
- opj_worker_thread_list_t* next;
- opj_worker_thread_list_t* to_opj_free;
-
- worker_thread = tp->waiting_worker_thread_list->worker_thread;
-
- assert(worker_thread->marked_as_waiting);
- worker_thread->marked_as_waiting = OPJ_FALSE;
-
- next = tp->waiting_worker_thread_list->next;
- to_opj_free = tp->waiting_worker_thread_list;
- tp->waiting_worker_thread_list = next;
- tp->waiting_worker_thread_count --;
-
- opj_mutex_lock(worker_thread->mutex);
- opj_mutex_unlock(tp->mutex);
- opj_cond_signal(worker_thread->cond);
- opj_mutex_unlock(worker_thread->mutex);
-
- opj_free(to_opj_free);
- } else {
- opj_mutex_unlock(tp->mutex);
- }
-
- return OPJ_TRUE;
-}
-
-void opj_thread_pool_wait_completion(opj_thread_pool_t* tp,
- int max_remaining_jobs)
-{
- if (tp->mutex == NULL) {
- return;
- }
-
- if (max_remaining_jobs < 0) {
- max_remaining_jobs = 0;
- }
- opj_mutex_lock(tp->mutex);
- tp->signaling_threshold = max_remaining_jobs;
- while (tp->pending_jobs_count > max_remaining_jobs) {
- /*printf("tp=%p, jobs before wait = %d, max_remaining_jobs = %d\n", tp, tp->pending_jobs_count, max_remaining_jobs);*/
- opj_cond_wait(tp->cond, tp->mutex);
- /*printf("tp=%p, jobs after wait = %d\n", tp, tp->pending_jobs_count);*/
- }
- opj_mutex_unlock(tp->mutex);
-}
-
-int opj_thread_pool_get_thread_count(opj_thread_pool_t* tp)
-{
- return tp->worker_threads_count;
-}
-
-void opj_thread_pool_destroy(opj_thread_pool_t* tp)
-{
- if (!tp) {
- return;
- }
- if (tp->cond) {
- int i;
- opj_thread_pool_wait_completion(tp, 0);
-
- opj_mutex_lock(tp->mutex);
- tp->state = OPJWTS_STOP;
- opj_mutex_unlock(tp->mutex);
-
- for (i = 0; i < tp->worker_threads_count; i++) {
- opj_mutex_lock(tp->worker_threads[i].mutex);
- opj_cond_signal(tp->worker_threads[i].cond);
- opj_mutex_unlock(tp->worker_threads[i].mutex);
- opj_thread_join(tp->worker_threads[i].thread);
- opj_cond_destroy(tp->worker_threads[i].cond);
- opj_mutex_destroy(tp->worker_threads[i].mutex);
- }
-
- opj_free(tp->worker_threads);
-
- while (tp->waiting_worker_thread_list != NULL) {
- opj_worker_thread_list_t* next = tp->waiting_worker_thread_list->next;
- opj_free(tp->waiting_worker_thread_list);
- tp->waiting_worker_thread_list = next;
- }
-
- opj_cond_destroy(tp->cond);
- }
- opj_mutex_destroy(tp->mutex);
- opj_tls_destroy(tp->tls);
- opj_free(tp);
-}
diff --git a/contrib/libs/openjpeg/thread.h b/contrib/libs/openjpeg/thread.h
deleted file mode 100644
index c89e19b4a6..0000000000
--- a/contrib/libs/openjpeg/thread.h
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2016, Even Rouault
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef THREAD_H
-#define THREAD_H
-
-#include "openjpeg.h"
-
-/**
-@file thread.h
-@brief Thread API
-
-The functions in thread.c have for goal to manage mutex, conditions, thread
-creation and thread pools that accept jobs.
-*/
-
-/** @defgroup THREAD THREAD - Mutex, conditions, threads and thread pools */
-/*@{*/
-
-/** @name Mutex */
-/*@{*/
-
-/** Opaque type for a mutex */
-typedef struct opj_mutex_t opj_mutex_t;
-
-/** Creates a mutex.
- * @return the mutex or NULL in case of error (can for example happen if the library
- * is built without thread support)
- */
-opj_mutex_t* opj_mutex_create(void);
-
-/** Lock/acquire the mutex.
- * @param mutex the mutex to acquire.
- */
-void opj_mutex_lock(opj_mutex_t* mutex);
-
-/** Unlock/release the mutex.
- * @param mutex the mutex to release.
- */
-void opj_mutex_unlock(opj_mutex_t* mutex);
-
-/** Destroy a mutex
- * @param mutex the mutex to destroy.
- */
-void opj_mutex_destroy(opj_mutex_t* mutex);
-
-/*@}*/
-
-/** @name Condition */
-/*@{*/
-
-/** Opaque type for a condition */
-typedef struct opj_cond_t opj_cond_t;
-
-/** Creates a condition.
- * @return the condition or NULL in case of error (can for example happen if the library
- * is built without thread support)
- */
-opj_cond_t* opj_cond_create(void);
-
-/** Wait for the condition to be signaled.
- * The semantics is the same as the POSIX pthread_cond_wait.
- * The provided mutex *must* be acquired before calling this function, and
- * released afterwards.
- * The mutex will be released by this function while it must wait for the condition
- * and reacquired afterwards.
- * In some particular situations, the function might return even if the condition is not signaled
- * with opj_cond_signal(), hence the need to check with an application level
- * mechanism.
- *
- * Waiting thread :
- * \code
- * opj_mutex_lock(mutex);
- * while( !some_application_level_condition )
- * {
- * opj_cond_wait(cond, mutex);
- * }
- * opj_mutex_unlock(mutex);
- * \endcode
- *
- * Signaling thread :
- * \code
- * opj_mutex_lock(mutex);
- * some_application_level_condition = TRUE;
- * opj_cond_signal(cond);
- * opj_mutex_unlock(mutex);
- * \endcode
- *
- * @param cond the condition to wait.
- * @param mutex the mutex (in acquired state before calling this function)
- */
-void opj_cond_wait(opj_cond_t* cond, opj_mutex_t* mutex);
-
-/** Signal waiting threads on a condition.
- * One of the thread waiting with opj_cond_wait() will be waken up.
- * It is strongly advised that this call is done with the mutex that is used
- * by opj_cond_wait(), in a acquired state.
- * @param cond the condition to signal.
- */
-void opj_cond_signal(opj_cond_t* cond);
-
-/** Destroy a condition
- * @param cond the condition to destroy.
- */
-void opj_cond_destroy(opj_cond_t* cond);
-
-/*@}*/
-
-/** @name Thread */
-/*@{*/
-
-/** Opaque type for a thread handle */
-typedef struct opj_thread_t opj_thread_t;
-
-/** User function to execute in a thread
- * @param user_data user data provided with opj_thread_create()
- */
-typedef void (*opj_thread_fn)(void* user_data);
-
-/** Creates a new thread.
- * @param thread_fn Function to run in the new thread.
- * @param user_data user data provided to the thread function. Might be NULL.
- * @return a thread handle or NULL in case of failure (can for example happen if the library
- * is built without thread support)
- */
-opj_thread_t* opj_thread_create(opj_thread_fn thread_fn, void* user_data);
-
-/** Wait for a thread to be finished and release associated resources to the
- * thread handle.
- * @param thread the thread to wait for being finished.
- */
-void opj_thread_join(opj_thread_t* thread);
-
-/*@}*/
-
-/** @name Thread local storage */
-/*@{*/
-/** Opaque type for a thread local storage */
-typedef struct opj_tls_t opj_tls_t;
-
-/** Get a thread local value corresponding to the provided key.
- * @param tls thread local storage handle
- * @param key key whose value to retrieve.
- * @return value associated with the key, or NULL is missing.
- */
-void* opj_tls_get(opj_tls_t* tls, int key);
-
-/** Type of the function used to free a TLS value */
-typedef void (*opj_tls_free_func)(void* value);
-
-/** Set a thread local value corresponding to the provided key.
- * @param tls thread local storage handle
- * @param key key whose value to set.
- * @param value value to set (may be NULL).
- * @param free_func function to call currently installed value.
- * @return OPJ_TRUE if successful.
- */
-OPJ_BOOL opj_tls_set(opj_tls_t* tls, int key, void* value,
- opj_tls_free_func free_func);
-
-/*@}*/
-
-/** @name Thread pool */
-/*@{*/
-
-/** Opaque type for a thread pool */
-typedef struct opj_thread_pool_t opj_thread_pool_t;
-
-/** Create a new thread pool.
- * num_thread must nominally be >= 1 to create a real thread pool. If num_threads
- * is negative or null, then a dummy thread pool will be created. All functions
- * operating on the thread pool will work, but job submission will be run
- * synchronously in the calling thread.
- *
- * @param num_threads the number of threads to allocate for this thread pool.
- * @return a thread pool handle, or NULL in case of failure (can for example happen if the library
- * is built without thread support)
- */
-opj_thread_pool_t* opj_thread_pool_create(int num_threads);
-
-/** User function to execute in a thread
- * @param user_data user data provided with opj_thread_create()
- * @param tls handle to thread local storage
- */
-typedef void (*opj_job_fn)(void* user_data, opj_tls_t* tls);
-
-
-/** Submit a new job to be run by one of the thread in the thread pool.
- * The job ( thread_fn, user_data ) will be added in the queue of jobs managed
- * by the thread pool, and run by the first thread that is no longer busy.
- *
- * @param tp the thread pool handle.
- * @param job_fn Function to run. Must not be NULL.
- * @param user_data User data provided to thread_fn.
- * @return OPJ_TRUE if the job was successfully submitted.
- */
-OPJ_BOOL opj_thread_pool_submit_job(opj_thread_pool_t* tp, opj_job_fn job_fn,
- void* user_data);
-
-/** Wait that no more than max_remaining_jobs jobs are remaining in the queue of
- * the thread pool. The aim of this function is to avoid submitting too many
- * jobs while the thread pool cannot cope fast enough with them, which would
- * result potentially in out-of-memory situations with too many job descriptions
- * being queued.
- *
- * @param tp the thread pool handle
- * @param max_remaining_jobs maximum number of jobs allowed to be queued without waiting.
- */
-void opj_thread_pool_wait_completion(opj_thread_pool_t* tp,
- int max_remaining_jobs);
-
-/** Return the number of threads associated with the thread pool.
- *
- * @param tp the thread pool handle.
- * @return number of threads associated with the thread pool.
- */
-int opj_thread_pool_get_thread_count(opj_thread_pool_t* tp);
-
-/** Destroy a thread pool.
- * @param tp the thread pool handle.
- */
-void opj_thread_pool_destroy(opj_thread_pool_t* tp);
-
-/*@}*/
-
-/*@}*/
-
-#endif /* THREAD_H */
diff --git a/contrib/libs/openjpeg/tls_keys.h b/contrib/libs/openjpeg/tls_keys.h
deleted file mode 100644
index 23f8475418..0000000000
--- a/contrib/libs/openjpeg/tls_keys.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
- * party and contributor rights, including patent rights, and no such rights
- * are granted under this license.
- *
- * Copyright (c) 2016, Even Rouault
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef OPJ_TLS_KEYS_H
-#define OPJ_TLS_KEYS_H
-
-#define OPJ_TLS_KEY_T1 0
-
-#endif /* OPJ_TLS_KEY_H */
diff --git a/contrib/libs/openjpeg/ya.make b/contrib/libs/openjpeg/ya.make
deleted file mode 100644
index ebcca46a5f..0000000000
--- a/contrib/libs/openjpeg/ya.make
+++ /dev/null
@@ -1,60 +0,0 @@
-# Generated by devtools/yamaker from nixpkgs 22.11.
-
-LIBRARY()
-
-LICENSE(
- BSD-2-Clause AND
- BSD-3-Clause
-)
-
-LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
-
-VERSION(2.5.3)
-
-ORIGINAL_SOURCE(https://github.com/uclouvain/openjpeg/archive/v2.5.3.tar.gz)
-
-ADDINCL(
- contrib/libs/openjpeg
-)
-
-NO_COMPILER_WARNINGS()
-
-NO_RUNTIME()
-
-IF (OS_WINDOWS)
- CFLAGS(
- GLOBAL /DOPJ_STATIC
- /DMUTEX_win32
- )
-ELSE()
- CFLAGS(
- -DMUTEX_pthread
- )
-ENDIF()
-
-SRCS(
- bio.c
- cio.c
- dwt.c
- event.c
- function_list.c
- ht_dec.c
- image.c
- invert.c
- j2k.c
- jp2.c
- mct.c
- mqc.c
- openjpeg.c
- opj_clock.c
- opj_malloc.c
- pi.c
- sparse_array.c
- t1.c
- t2.c
- tcd.c
- tgt.c
- thread.c
-)
-
-END()
diff --git a/contrib/libs/openssl/ya.make b/contrib/libs/openssl/ya.make
index 7a7a8674dc..7d8ecf86fb 100644
--- a/contrib/libs/openssl/ya.make
+++ b/contrib/libs/openssl/ya.make
@@ -52,6 +52,10 @@ IF (EXPORT_CMAKE)
CFLAGS(GLOBAL -DOPENSSL_DONT_ADD_VERSION_PREFIX)
ENDIF()
+IF (MAPSMOBI_BUILD_TARGET)
+ CFLAGS(GLOBAL -DOPENSSL_DONT_ADD_VERSION_PREFIX)
+ENDIF()
+
IF (NOT EXPORT_CMAKE OR NOT OPENSOURCE_REPLACE_OPENSSL)
IF (OS_LINUX)